From c4ab4a7f679fceaa13ac808c238abf464e81d280 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Tue, 17 Sep 2019 11:46:36 -0700 Subject: [PATCH 01/26] Slightly working MQTT 5 --- examples/async.c | 3 +- examples/sync.c | 10 +- include/lwmqtt.h | 65 ++++++++++++- src/client.c | 29 ++++-- src/helpers.c | 18 ++++ src/helpers.h | 2 + src/packet.c | 240 +++++++++++++++++++++++++++++++++++++++++++---- src/packet.h | 26 ++--- tests/client.cpp | 20 ++-- tests/packet.cpp | 36 +++---- 10 files changed, 379 insertions(+), 70 deletions(-) diff --git a/examples/async.c b/examples/async.c index fdf5899..810cecc 100644 --- a/examples/async.c +++ b/examples/async.c @@ -135,7 +135,8 @@ int main() { pthread_mutex_lock(&mutex); // publish message - err = lwmqtt_publish(&client, lwmqtt_string("hello"), msg, COMMAND_TIMEOUT); + lwmqtt_properties_t props = lwmqtt_empty_props; + err = lwmqtt_publish(&client, lwmqtt_string("hello"), msg, props, COMMAND_TIMEOUT); if (err != LWMQTT_SUCCESS) { printf("failed lwmqtt_publish: %d\n", err); exit(1); diff --git a/examples/sync.c b/examples/sync.c index 16fdb36..f3cb043 100644 --- a/examples/sync.c +++ b/examples/sync.c @@ -26,12 +26,13 @@ int main() { lwmqtt_set_network(&client, &network, lwmqtt_unix_network_read, lwmqtt_unix_network_write); lwmqtt_set_timers(&client, &timer1, &timer2, lwmqtt_unix_timer_set, lwmqtt_unix_timer_get); lwmqtt_set_callback(&client, NULL, message_arrived); + lwmqtt_set_protocol(&client, LWMQTT_MQTT5); // configure message time lwmqtt_unix_timer_set(&timer3, MESSAGE_TIMEOUT); // connect to broker - lwmqtt_err_t err = lwmqtt_unix_network_connect(&network, "public.cloud.shiftr.io", 1883); + lwmqtt_err_t err = lwmqtt_unix_network_connect(&network, "localhost", 1883); if (err != LWMQTT_SUCCESS) { printf("failed lwmqtt_unix_network_connect: %d\n", err); exit(1); @@ -91,10 +92,13 @@ int main() { // check if message is due if (lwmqtt_unix_timer_get(&timer3) <= 0) { // prepare message - lwmqtt_message_t msg = {.qos = LWMQTT_QOS0, .retained = false, .payload = (uint8_t *)("world"), .payload_len = 5}; + lwmqtt_message_t msg = {.qos = LWMQTT_QOS0, .retained = true, .payload = (uint8_t *)("world"), .payload_len = 5}; // publish message - err = lwmqtt_publish(&client, lwmqtt_string("hello"), msg, COMMAND_TIMEOUT); + lwmqtt_property_t uprop = {.prop = LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL, .value = {.int32 = 30}}; + + lwmqtt_properties_t props = {1, &uprop}; + err = lwmqtt_publish(&client, lwmqtt_string("hello"), msg, props, COMMAND_TIMEOUT); if (err != LWMQTT_SUCCESS) { printf("failed lwmqtt_keep_alive: %d\n", err); exit(1); diff --git a/include/lwmqtt.h b/include/lwmqtt.h index 4feee57..0a166e0 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -5,6 +5,8 @@ #include #include +typedef enum { LWMQTT_MQTT311, LWMQTT_MQTT5 } lwmqtt_protocol_t; + /** * The error type used by all exposed APIs. * @@ -65,6 +67,59 @@ int lwmqtt_strcmp(lwmqtt_string_t a, const char *b); */ typedef enum { LWMQTT_QOS0 = 0, LWMQTT_QOS1 = 1, LWMQTT_QOS2 = 2, LWMQTT_QOS_FAILURE = 128 } lwmqtt_qos_t; +typedef enum { + LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR = 0x01, + LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL = 0x02, + LWMQTT_PROP_CONTENT_TYPE = 0x03, + LWMQTT_PROP_RESPONSE_TOPIC = 0x08, + LWMQTT_PROP_CORRELATION_DATA = 0x09, + LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER = 0x0B, + LWMQTT_PROP_SESSION_EXPIRY_INTERVAL = 0x11, + LWMQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER = 0x12, + LWMQTT_PROP_SERVER_KEEP_ALIVE = 0x13, + LWMQTT_PROP_AUTHENTICATION_METHOD = 0x15, + LWMQTT_PROP_AUTHENTICATION_DATA = 0x16, + LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION = 0x17, + LWMQTT_PROP_WILL_DELAY_INTERVAL = 0x18, + LWMQTT_PROP_REQUEST_RESPONSE_INFORMATION = 0x19, + LWMQTT_PROP_RESPONSE_INFORMATION = 0x1A, + LWMQTT_PROP_SERVER_REFERENCE = 0x1C, + LWMQTT_PROP_REASON_STRING = 0x1F, + LWMQTT_PROP_RECEIVE_MAXIMUM = 0x21, + LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM = 0x22, + LWMQTT_PROP_TOPIC_ALIAS = 0x23, + LWMQTT_PROP_MAXIMUM_QOS = 0x24, + LWMQTT_PROP_RETAIN_AVAILABLE = 0x25, + LWMQTT_PROP_USER_PROPERTY = 0x26, + LWMQTT_PROP_MAXIMUM_PACKET_SIZE = 0x27, + LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE = 0x28, + LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE = 0x29, + LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE = 0x2A, +} lwmqtt_prop_t; + +typedef struct { + lwmqtt_prop_t prop; + union { + uint8_t byte; + uint32_t int32; + uint16_t int16; + int varint; + lwmqtt_string_t str; + struct { + lwmqtt_string_t k; + lwmqtt_string_t v; + } pair; + } value; +} lwmqtt_property_t; + +typedef struct { + uint16_t len; + lwmqtt_property_t *props; +} lwmqtt_properties_t; + +#define lwmqtt_empty_props \ + { 0, NULL } + /** * The message object used to publish and receive messages. */ @@ -145,6 +200,8 @@ typedef void (*lwmqtt_callback_t)(lwmqtt_client_t *client, void *ref, lwmqtt_str * The client object. */ struct lwmqtt_client_t { + lwmqtt_protocol_t protocol; + uint16_t last_packet_id; uint32_t keep_alive_interval; bool pong_pending; @@ -180,6 +237,8 @@ struct lwmqtt_client_t { void lwmqtt_init(lwmqtt_client_t *client, uint8_t *write_buf, size_t write_buf_size, uint8_t *read_buf, size_t read_buf_size); +void lwmqtt_set_protocol(lwmqtt_client_t *client, lwmqtt_protocol_t prot); + /** * Will set the network reference and callbacks for this client object. * @@ -246,13 +305,14 @@ typedef struct { bool clean_session; lwmqtt_string_t username; lwmqtt_string_t password; + lwmqtt_properties_t properties; } lwmqtt_options_t; /** * The default initializer for the options object. */ #define lwmqtt_default_options \ - { lwmqtt_default_string, 60, true, lwmqtt_default_string, lwmqtt_default_string } + { lwmqtt_default_string, 60, true, lwmqtt_default_string, lwmqtt_default_string, lwmqtt_empty_props } /** * The available return codes transported by the connack packet. @@ -295,7 +355,8 @@ lwmqtt_err_t lwmqtt_connect(lwmqtt_client_t *client, lwmqtt_options_t options, l * @param timeout - The command timeout. * @return An error value. */ -lwmqtt_err_t lwmqtt_publish(lwmqtt_client_t *client, lwmqtt_string_t topic, lwmqtt_message_t msg, uint32_t timeout); +lwmqtt_err_t lwmqtt_publish(lwmqtt_client_t *client, lwmqtt_string_t topic, lwmqtt_message_t msg, + lwmqtt_properties_t props, uint32_t timeout); /** * Will send a subscribe packet with multiple topic filters plus QOS levels and wait for the suback to complete. diff --git a/src/client.c b/src/client.c index 806ec74..2c79716 100644 --- a/src/client.c +++ b/src/client.c @@ -5,6 +5,7 @@ void lwmqtt_init(lwmqtt_client_t *client, uint8_t *write_buf, size_t write_buf_s client->last_packet_id = 1; client->keep_alive_interval = 0; client->pong_pending = false; + client->protocol = LWMQTT_MQTT311; client->write_buf = write_buf; client->write_buf_size = write_buf_size; @@ -27,6 +28,8 @@ void lwmqtt_init(lwmqtt_client_t *client, uint8_t *write_buf, size_t write_buf_s client->overflow_counter = NULL; } +void lwmqtt_set_protocol(lwmqtt_client_t *client, lwmqtt_protocol_t prot) { client->protocol = prot; } + void lwmqtt_set_network(lwmqtt_client_t *client, void *ref, lwmqtt_network_read_t read, lwmqtt_network_write_t write) { client->network = ref; client->network_read = read; @@ -263,7 +266,8 @@ static lwmqtt_err_t lwmqtt_cycle(lwmqtt_client_t *client, size_t *read, lwmqtt_p uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - err = lwmqtt_decode_publish(client->read_buf, client->read_buf_size, &dup, &packet_id, &topic, &msg); + err = lwmqtt_decode_publish(client->read_buf, client->read_buf_size, client->protocol, &dup, &packet_id, &topic, + &msg); if (err != LWMQTT_SUCCESS) { return err; } @@ -363,7 +367,9 @@ static lwmqtt_err_t lwmqtt_cycle(lwmqtt_client_t *client, size_t *read, lwmqtt_p } // handle all other packets - default: { break; } + default: { + break; + } } return LWMQTT_SUCCESS; @@ -429,7 +435,8 @@ lwmqtt_err_t lwmqtt_connect(lwmqtt_client_t *client, lwmqtt_options_t options, l // encode connect packet size_t len; - lwmqtt_err_t err = lwmqtt_encode_connect(client->write_buf, client->write_buf_size, &len, options, will); + lwmqtt_err_t err = + lwmqtt_encode_connect(client->write_buf, client->write_buf_size, &len, client->protocol, options, will); if (err != LWMQTT_SUCCESS) { return err; } @@ -451,7 +458,7 @@ lwmqtt_err_t lwmqtt_connect(lwmqtt_client_t *client, lwmqtt_options_t options, l // decode connack packet bool session_present; - err = lwmqtt_decode_connack(client->read_buf, client->read_buf_size, &session_present, return_code); + err = lwmqtt_decode_connack(client->read_buf, client->read_buf_size, client->protocol, &session_present, return_code); if (err != LWMQTT_SUCCESS) { return err; } @@ -471,8 +478,9 @@ lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_ // encode subscribe packet size_t len; - lwmqtt_err_t err = lwmqtt_encode_subscribe(client->write_buf, client->write_buf_size, &len, - lwmqtt_get_next_packet_id(client), count, topic_filter, qos); + lwmqtt_properties_t props = lwmqtt_empty_props; + lwmqtt_err_t err = lwmqtt_encode_subscribe(client->write_buf, client->write_buf_size, &len, client->protocol, + lwmqtt_get_next_packet_id(client), count, topic_filter, qos, props); if (err != LWMQTT_SUCCESS) { return err; } @@ -496,7 +504,8 @@ lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_ int suback_count = 0; lwmqtt_qos_t granted_qos[count]; uint16_t packet_id; - err = lwmqtt_decode_suback(client->read_buf, client->read_buf_size, &packet_id, count, &suback_count, granted_qos); + err = lwmqtt_decode_suback(client->read_buf, client->read_buf_size, &packet_id, client->protocol, count, + &suback_count, granted_qos); if (err != LWMQTT_SUCCESS) { return err; } @@ -559,7 +568,7 @@ lwmqtt_err_t lwmqtt_unsubscribe_one(lwmqtt_client_t *client, lwmqtt_string_t top } lwmqtt_err_t lwmqtt_publish(lwmqtt_client_t *client, lwmqtt_string_t topic, lwmqtt_message_t message, - uint32_t timeout) { + lwmqtt_properties_t props, uint32_t timeout) { // set command timer client->timer_set(client->command_timer, timeout); @@ -571,8 +580,8 @@ lwmqtt_err_t lwmqtt_publish(lwmqtt_client_t *client, lwmqtt_string_t topic, lwmq // encode publish packet size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(client->write_buf, client->write_buf_size, &len, 0, packet_id, topic, message); + lwmqtt_err_t err = lwmqtt_encode_publish(client->write_buf, client->write_buf_size, &len, client->protocol, 0, + packet_id, topic, message, props); if (err != LWMQTT_SUCCESS) { return err; } diff --git a/src/helpers.c b/src/helpers.c index c3ae761..eae4f00 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -83,6 +83,24 @@ lwmqtt_err_t lwmqtt_write_num(uint8_t **buf, const uint8_t *buf_end, uint16_t nu return LWMQTT_SUCCESS; } +lwmqtt_err_t lwmqtt_write_num32(uint8_t **buf, const uint8_t *buf_end, uint32_t num) { + // check buffer size + if ((size_t)(buf_end - (*buf)) < 4) { + return LWMQTT_BUFFER_TOO_SHORT; + } + + // write bytes + (*buf)[0] = (uint8_t)(num >> 24); + (*buf)[1] = (uint8_t)((num >> 16) & 0xff); + (*buf)[2] = (uint8_t)((num >> 8) & 0xff); + (*buf)[3] = (uint8_t)(num & 0xff); + + // adjust pointer + *buf += 4; + + return LWMQTT_SUCCESS; +} + lwmqtt_err_t lwmqtt_read_string(uint8_t **buf, const uint8_t *buf_end, lwmqtt_string_t *str) { // read length uint16_t len; diff --git a/src/helpers.h b/src/helpers.h index 4a62e66..6d8a4b8 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -65,6 +65,8 @@ lwmqtt_err_t lwmqtt_read_num(uint8_t **buf, const uint8_t *buf_end, uint16_t *nu */ lwmqtt_err_t lwmqtt_write_num(uint8_t **buf, const uint8_t *buf_end, uint16_t num); +lwmqtt_err_t lwmqtt_write_num32(uint8_t **buf, const uint8_t *buf_end, uint32_t num); + /** * Reads a string from the specified buffer into the passed object. The pointer is incremented by the bytes read. * diff --git a/src/packet.c b/src/packet.c index 512b44d..9570989 100644 --- a/src/packet.c +++ b/src/packet.c @@ -55,14 +55,182 @@ lwmqtt_err_t lwmqtt_detect_remaining_length(uint8_t *buf, size_t buf_len, uint32 return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_options_t options, - lwmqtt_will_t *will) { +static size_t str_wire_len(lwmqtt_string_t str) { + int ll = 0; + lwmqtt_varnum_length(str.len, &ll); + return ll + str.len; +} + +static size_t proplen(lwmqtt_property_t prop) { + int ll; + switch (prop.prop) { + // one byte + case LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR: + case LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION: + case LWMQTT_PROP_MAXIMUM_QOS: + case LWMQTT_PROP_RETAIN_AVAILABLE: + case LWMQTT_PROP_REQUEST_RESPONSE_INFORMATION: + case LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE: + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE: + case LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE: + return 2; + + // two byte int + case LWMQTT_PROP_SERVER_KEEP_ALIVE: + case LWMQTT_PROP_RECEIVE_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS: + return 3; + + // 4 byte int + case LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL: + case LWMQTT_PROP_SESSION_EXPIRY_INTERVAL: + case LWMQTT_PROP_WILL_DELAY_INTERVAL: + case LWMQTT_PROP_MAXIMUM_PACKET_SIZE: + return 5; + + // Variable byte int + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: + lwmqtt_varnum_length(prop.value.varint, &ll); + return 1 + ll; + + // UTF-8 string + case LWMQTT_PROP_CONTENT_TYPE: + case LWMQTT_PROP_RESPONSE_TOPIC: + case LWMQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER: + case LWMQTT_PROP_AUTHENTICATION_METHOD: + case LWMQTT_PROP_RESPONSE_INFORMATION: + case LWMQTT_PROP_SERVER_REFERENCE: + case LWMQTT_PROP_REASON_STRING: + return 1 + str_wire_len(prop.value.str); + + case LWMQTT_PROP_CORRELATION_DATA: + case LWMQTT_PROP_AUTHENTICATION_DATA: + // TODO: Binary data + return LWMQTT_MISSING_OR_WRONG_PACKET; + + case LWMQTT_PROP_USER_PROPERTY: + return 1 + 2 + prop.value.pair.k.len + 2 + prop.value.pair.v.len; + } + return 0; +} + +static lwmqtt_err_t write_prop(uint8_t **buf, const uint8_t *buf_end, lwmqtt_property_t prop) { + lwmqtt_err_t err = lwmqtt_write_byte(buf, buf_end, prop.prop); + if (err != LWMQTT_SUCCESS) { + return err; + } + + switch (prop.prop) { + // one byte + case LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR: + case LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION: + case LWMQTT_PROP_MAXIMUM_QOS: + case LWMQTT_PROP_RETAIN_AVAILABLE: + case LWMQTT_PROP_REQUEST_RESPONSE_INFORMATION: + case LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE: + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE: + case LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE: + return lwmqtt_write_byte(buf, buf_end, prop.value.byte); + + // two byte int + case LWMQTT_PROP_SERVER_KEEP_ALIVE: + case LWMQTT_PROP_RECEIVE_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS: + return lwmqtt_write_num(buf, buf_end, prop.value.int16); + + // 4 byte int + case LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL: + case LWMQTT_PROP_SESSION_EXPIRY_INTERVAL: + case LWMQTT_PROP_WILL_DELAY_INTERVAL: + case LWMQTT_PROP_MAXIMUM_PACKET_SIZE: + return lwmqtt_write_num32(buf, buf_end, prop.value.int32); + + // Variable byte int + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: + return lwmqtt_write_varnum(buf, buf_end, prop.value.varint); + + // UTF-8 string + case LWMQTT_PROP_CONTENT_TYPE: + case LWMQTT_PROP_RESPONSE_TOPIC: + case LWMQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER: + case LWMQTT_PROP_AUTHENTICATION_METHOD: + case LWMQTT_PROP_RESPONSE_INFORMATION: + case LWMQTT_PROP_SERVER_REFERENCE: + case LWMQTT_PROP_REASON_STRING: + lwmqtt_write_string(buf, buf_end, prop.value.str); + break; + + case LWMQTT_PROP_CORRELATION_DATA: + case LWMQTT_PROP_AUTHENTICATION_DATA: + // TODO: Binary data + return LWMQTT_MISSING_OR_WRONG_PACKET; + + case LWMQTT_PROP_USER_PROPERTY: + lwmqtt_write_string(buf, buf_end, prop.value.pair.k); + lwmqtt_write_string(buf, buf_end, prop.value.pair.v); + } + + return LWMQTT_SUCCESS; +} + +// Length of the properties, not including their length. +static size_t propsintlen(lwmqtt_properties_t props) { + uint32_t l = 0; + + for (int i = 0; i < props.len; i++) { + l += proplen(props.props[i]); + } + + return l; +} + +// Length of a properties set as it may appear on the wire (including +// the length of the length). +static size_t propslen(lwmqtt_protocol_t prot, lwmqtt_properties_t props) { + if (prot == LWMQTT_MQTT311) { + return 0; + } + + uint32_t l = propsintlen(props); + int ll; + // lwmqtt_err_t err = + lwmqtt_varnum_length(l, &ll); + + return l + ll; +} + +static lwmqtt_err_t lwmqtt_write_props(uint8_t **buf, const uint8_t *buf_end, lwmqtt_protocol_t prot, + lwmqtt_properties_t props) { + if (prot == LWMQTT_MQTT311) { + return LWMQTT_SUCCESS; + } + + size_t len = propsintlen(props); + lwmqtt_err_t err = lwmqtt_write_varnum(buf, buf_end, len); + if (err != LWMQTT_SUCCESS) { + return err; + } + + for (int i = 0; i < props.len; i++) { + err = write_prop(buf, buf_end, props.props[i]); + if (err != LWMQTT_SUCCESS) { + return err; + } + } + + return LWMQTT_SUCCESS; +} + +lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, + lwmqtt_options_t options, lwmqtt_will_t *will) { // prepare pointers uint8_t *buf_ptr = buf; uint8_t *buf_end = buf + buf_len; // fixed header is 10 - uint32_t rem_len = 10; + uint32_t rem_len = 10 + propslen(protocol, options.properties); // add client id to remaining length rem_len += options.client_id.len + 2; @@ -112,7 +280,7 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw } // write version number - err = lwmqtt_write_byte(&buf_ptr, buf_end, 4); + err = lwmqtt_write_byte(&buf_ptr, buf_end, protocol == LWMQTT_MQTT311 ? 4 : 5); if (err != LWMQTT_SUCCESS) { return err; } @@ -152,6 +320,11 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw return err; } + err = lwmqtt_write_props(&buf_ptr, buf_end, protocol, options.properties); + if (err != LWMQTT_SUCCESS) { + return err; + } + // write client id err = lwmqtt_write_string(&buf_ptr, buf_end, options.client_id); if (err != LWMQTT_SUCCESS) { @@ -201,7 +374,7 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_decode_connack(uint8_t *buf, size_t buf_len, bool *session_present, +lwmqtt_err_t lwmqtt_decode_connack(uint8_t *buf, size_t buf_len, lwmqtt_protocol_t protocol, bool *session_present, lwmqtt_return_code_t *return_code) { // prepare pointers uint8_t *buf_ptr = buf; @@ -227,7 +400,7 @@ lwmqtt_err_t lwmqtt_decode_connack(uint8_t *buf, size_t buf_len, bool *session_p } // check remaining length - if (rem_len != 2) { + if (protocol == LWMQTT_MQTT311 && rem_len != 2) { return LWMQTT_REMAINING_LENGTH_MISMATCH; } @@ -384,8 +557,23 @@ lwmqtt_err_t lwmqtt_encode_ack(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_decode_publish(uint8_t *buf, size_t buf_len, bool *dup, uint16_t *packet_id, lwmqtt_string_t *topic, - lwmqtt_message_t *msg) { +static lwmqtt_err_t decode_props(uint8_t **buf, const uint8_t *buf_len, lwmqtt_protocol_t protocol, + lwmqtt_properties_t *props) { + if (protocol == LWMQTT_MQTT311) { + return LWMQTT_SUCCESS; + } + uint32_t prop_len; + lwmqtt_err_t err = lwmqtt_read_varnum(buf, buf_len, &prop_len); + if (err != LWMQTT_SUCCESS) { + return err; + } + // TODO: Actually grab them instead of just skipping over + *buf += prop_len; + return LWMQTT_SUCCESS; +} + +lwmqtt_err_t lwmqtt_decode_publish(uint8_t *buf, size_t buf_len, lwmqtt_protocol_t protocol, bool *dup, + uint16_t *packet_id, lwmqtt_string_t *topic, lwmqtt_message_t *msg) { // prepare pointer uint8_t *buf_ptr = buf; uint8_t *buf_end = buf + buf_len; @@ -460,6 +648,12 @@ lwmqtt_err_t lwmqtt_decode_publish(uint8_t *buf, size_t buf_len, bool *dup, uint *packet_id = 0; } + lwmqtt_properties_t props; + err = decode_props(&buf_ptr, buf_end, protocol, &props); + if (err != LWMQTT_SUCCESS) { + return err; + } + // set payload length msg->payload_len = buf_end - buf_ptr; @@ -472,14 +666,15 @@ lwmqtt_err_t lwmqtt_decode_publish(uint8_t *buf, size_t buf_len, bool *dup, uint return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_encode_publish(uint8_t *buf, size_t buf_len, size_t *len, bool dup, uint16_t packet_id, - lwmqtt_string_t topic, lwmqtt_message_t msg) { +lwmqtt_err_t lwmqtt_encode_publish(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, bool dup, + uint16_t packet_id, lwmqtt_string_t topic, lwmqtt_message_t msg, + lwmqtt_properties_t props) { // prepare pointer uint8_t *buf_ptr = buf; uint8_t *buf_end = buf + buf_len; // calculate remaining length - uint32_t rem_len = 2 + topic.len + (uint32_t)msg.payload_len; + uint32_t rem_len = 2 + topic.len + (uint32_t)msg.payload_len + propslen(protocol, props); if (msg.qos > 0) { rem_len += 2; } @@ -532,6 +727,11 @@ lwmqtt_err_t lwmqtt_encode_publish(uint8_t *buf, size_t buf_len, size_t *len, bo } } + err = lwmqtt_write_props(&buf_ptr, buf_end, protocol, props); + if (err != LWMQTT_SUCCESS) { + return err; + } + // write payload err = lwmqtt_write_data(&buf_ptr, buf_end, msg.payload, msg.payload_len); if (err != LWMQTT_SUCCESS) { @@ -544,14 +744,15 @@ lwmqtt_err_t lwmqtt_encode_publish(uint8_t *buf, size_t buf_len, size_t *len, bo return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, uint16_t packet_id, int count, - lwmqtt_string_t *topic_filters, lwmqtt_qos_t *qos_levels) { +lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, + uint16_t packet_id, int count, lwmqtt_string_t *topic_filters, + lwmqtt_qos_t *qos_levels, lwmqtt_properties_t props) { // prepare pointer uint8_t *buf_ptr = buf; uint8_t *buf_end = buf + buf_len; // calculate remaining length - uint32_t rem_len = 2; + uint32_t rem_len = 2 + propslen(protocol, props); for (int i = 0; i < count; i++) { rem_len += 2 + topic_filters[i].len + 1; } @@ -590,6 +791,11 @@ lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, return err; } + err = lwmqtt_write_props(&buf_ptr, buf_end, protocol, props); + if (err != LWMQTT_SUCCESS) { + return err; + } + // write all subscriptions for (int i = 0; i < count; i++) { // write topic @@ -611,8 +817,8 @@ lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet_id, int max_count, int *count, - lwmqtt_qos_t *granted_qos_levels) { +lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet_id, lwmqtt_protocol_t protocol, + int max_count, int *count, lwmqtt_qos_t *granted_qos_levels) { // prepare pointer uint8_t *buf_ptr = buf; uint8_t *buf_end = buf + buf_len; @@ -637,7 +843,7 @@ lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet } // check remaining length (packet id + min. one suback code) - if (rem_len < 3) { + if (protocol == LWMQTT_MQTT311 && rem_len < 3) { return LWMQTT_REMAINING_LENGTH_MISMATCH; } diff --git a/src/packet.h b/src/packet.h index 5fe9e50..f4f11f1 100644 --- a/src/packet.h +++ b/src/packet.h @@ -53,23 +53,25 @@ lwmqtt_err_t lwmqtt_detect_remaining_length(uint8_t *buf, size_t buf_len, uint32 * @param buf - The buffer into which the packet will be encoded. * @param buf_len - The length of the specified buffer. * @param len - The encoded length of the packet. + * @param protocol - The MQTT protocol to use for this connection. * @param options - The options to be used to build the connect packet. * @param will - The last will and testament. * @return An error value. */ -lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_options_t options, - lwmqtt_will_t *will); +lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, + lwmqtt_options_t options, lwmqtt_will_t *will); /** * Decodes a connack packet from the supplied buffer. * * @param buf - The raw buffer data. * @param buf_len - The length of the specified buffer. + * @param protocol - The protocol to parse the decode as. * @param session_present - The session present flag. * @param return_code - The return code. * @return An error value. */ -lwmqtt_err_t lwmqtt_decode_connack(uint8_t *buf, size_t buf_len, bool *session_present, +lwmqtt_err_t lwmqtt_decode_connack(uint8_t *buf, size_t buf_len, lwmqtt_protocol_t protocol, bool *session_present, lwmqtt_return_code_t *return_code); /** @@ -121,8 +123,8 @@ lwmqtt_err_t lwmqtt_encode_ack(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt * @parma msg - The message. * @return An error value. */ -lwmqtt_err_t lwmqtt_decode_publish(uint8_t *buf, size_t buf_len, bool *dup, uint16_t *packet_id, lwmqtt_string_t *topic, - lwmqtt_message_t *msg); +lwmqtt_err_t lwmqtt_decode_publish(uint8_t *buf, size_t buf_len, lwmqtt_protocol_t protocol, bool *dup, + uint16_t *packet_id, lwmqtt_string_t *topic, lwmqtt_message_t *msg); /** * Encodes a publish packet into the supplied buffer. @@ -136,8 +138,9 @@ lwmqtt_err_t lwmqtt_decode_publish(uint8_t *buf, size_t buf_len, bool *dup, uint * @param msg - The message. * @return An error value. */ -lwmqtt_err_t lwmqtt_encode_publish(uint8_t *buf, size_t buf_len, size_t *len, bool dup, uint16_t packet_id, - lwmqtt_string_t topic, lwmqtt_message_t msg); +lwmqtt_err_t lwmqtt_encode_publish(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, bool dup, + uint16_t packet_id, lwmqtt_string_t topic, lwmqtt_message_t msg, + lwmqtt_properties_t props); /** * Encodes a subscribe packet into the supplied buffer. @@ -151,8 +154,9 @@ lwmqtt_err_t lwmqtt_encode_publish(uint8_t *buf, size_t buf_len, size_t *len, bo * @param qos_levels - The array of requested QoS levels. * @return An error value. */ -lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, uint16_t packet_id, int count, - lwmqtt_string_t *topic_filters, lwmqtt_qos_t *qos_levels); +lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t prototocol, + uint16_t packet_id, int count, lwmqtt_string_t *topic_filters, + lwmqtt_qos_t *qos_levels, lwmqtt_properties_t props); /** * Decodes a suback packet from the supplied buffer. @@ -165,8 +169,8 @@ lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, * @param granted_qos_levels - The granted QoS levels. * @return An error value. */ -lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet_id, int max_count, int *count, - lwmqtt_qos_t *granted_qos_levels); +lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet_id, lwmqtt_protocol_t protocol, + int max_count, int *count, lwmqtt_qos_t *granted_qos_levels); /** * Encodes the supplied unsubscribe data into the supplied buffer, ready for sending diff --git a/tests/client.cpp b/tests/client.cpp index a90e43b..fc7fbaa 100644 --- a/tests/client.cpp +++ b/tests/client.cpp @@ -17,6 +17,8 @@ volatile int counter; const char *custom_ref = "cool"; +static lwmqtt_properties_t empty_props = lwmqtt_empty_props; + static void message_arrived(lwmqtt_client_t *c, void *ref, lwmqtt_string_t t, lwmqtt_message_t m) { ASSERT_EQ(ref, custom_ref); @@ -78,7 +80,7 @@ TEST(Client, PublishSubscribeQOS0) { msg.payload = payload; msg.payload_len = PAYLOAD_LEN; - err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, COMMAND_TIMEOUT); + err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); } @@ -137,7 +139,7 @@ TEST(Client, PublishSubscribeQOS1) { msg.payload = payload; msg.payload_len = PAYLOAD_LEN; - err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, COMMAND_TIMEOUT); + err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); } @@ -196,7 +198,7 @@ TEST(Client, PublishSubscribeQOS2) { msg.payload = payload; msg.payload_len = PAYLOAD_LEN; - err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, COMMAND_TIMEOUT); + err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); } @@ -252,7 +254,7 @@ TEST(Client, BufferOverflow) { msg.payload = big_payload; msg.payload_len = BIG_PAYLOAD_LEN; - err = lwmqtt_publish(&client, lwmqtt_string("error"), msg, COMMAND_TIMEOUT); + err = lwmqtt_publish(&client, lwmqtt_string("error"), msg, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_BUFFER_TOO_SHORT); counter = 0; @@ -262,7 +264,7 @@ TEST(Client, BufferOverflow) { msg.payload = payload; msg.payload_len = PAYLOAD_LEN; - err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, COMMAND_TIMEOUT); + err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); while (counter < 1) { @@ -320,10 +322,10 @@ TEST(Client, OverflowDropping) { msg.payload = payload; msg.payload_len = PAYLOAD_LEN; - err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, COMMAND_TIMEOUT); + err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, COMMAND_TIMEOUT); + err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); while (dropped < 2) { @@ -381,7 +383,7 @@ TEST(Client, BigBuffersAndPayload) { msg.payload = big_payload; msg.payload_len = BIG_PAYLOAD_LEN; - err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, COMMAND_TIMEOUT); + err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); } @@ -443,7 +445,7 @@ TEST(Client, MultipleSubscriptions) { msg.payload = payload; msg.payload_len = PAYLOAD_LEN; - err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, COMMAND_TIMEOUT); + err = lwmqtt_publish(&client, lwmqtt_string("lwmqtt"), msg, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); } diff --git a/tests/packet.cpp b/tests/packet.cpp index 05fa11e..d4160df 100644 --- a/tests/packet.cpp +++ b/tests/packet.cpp @@ -5,6 +5,8 @@ extern "C" { #include "../src/packet.h" } +lwmqtt_properties_t empty_props = lwmqtt_empty_props; + #define EXPECT_ARRAY_EQ(reference, actual, element_count) \ { \ for (size_t cmp_i = 0; cmp_i < element_count; cmp_i++) { \ @@ -139,7 +141,7 @@ TEST(ConnectTest, Encode1) { opts.password = lwmqtt_string("verysecret"); size_t len; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, 62, &len, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, 62, &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); @@ -168,7 +170,7 @@ TEST(ConnectTest, Encode2) { lwmqtt_options_t opts = lwmqtt_default_options; size_t len; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, 14, &len, opts, nullptr); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, 14, &len, LWMQTT_MQTT311, opts, nullptr); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); @@ -242,7 +244,7 @@ TEST(ConnectTest, Encode3) { opts.username = lwmqtt_string("surgemq"); size_t len; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, 62, &len, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, 62, &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); @@ -254,7 +256,7 @@ TEST(ConnectTest, EncodeError1) { lwmqtt_options_t opts = lwmqtt_default_options; size_t len; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, 4, &len, opts, nullptr); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, 4, &len, LWMQTT_MQTT311, opts, nullptr); EXPECT_EQ(err, LWMQTT_BUFFER_TOO_SHORT); } @@ -268,7 +270,7 @@ TEST(ConnackTest, Decode1) { bool session_present; lwmqtt_return_code_t return_code; - lwmqtt_err_t err = lwmqtt_decode_connack(pkt, 4, &session_present, &return_code); + lwmqtt_err_t err = lwmqtt_decode_connack(pkt, 4, LWMQTT_MQTT311, &session_present, &return_code); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(session_present, false); @@ -285,7 +287,7 @@ TEST(ConnackTest, DecodeError1) { bool session_present; lwmqtt_return_code_t return_code; - lwmqtt_err_t err = lwmqtt_decode_connack(pkt, 4, &session_present, &return_code); + lwmqtt_err_t err = lwmqtt_decode_connack(pkt, 4, LWMQTT_MQTT311, &session_present, &return_code); EXPECT_EQ(err, LWMQTT_REMAINING_LENGTH_MISMATCH); } @@ -299,7 +301,7 @@ TEST(ConnackTest, DecodeError2) { bool session_present; lwmqtt_return_code_t return_code; - lwmqtt_err_t err = lwmqtt_decode_connack(pkt, 3, &session_present, &return_code); + lwmqtt_err_t err = lwmqtt_decode_connack(pkt, 3, LWMQTT_MQTT311, &session_present, &return_code); EXPECT_EQ(err, LWMQTT_REMAINING_LENGTH_MISMATCH); } @@ -420,7 +422,7 @@ TEST(PublishTest, Decode1) { uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 25, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 25, LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(dup, true); @@ -463,7 +465,7 @@ TEST(PublishTest, Decode2) { uint16_t packet_id; lwmqtt_string_t topic = lwmqtt_default_string; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 23, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 23, LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(dup, false); @@ -485,7 +487,7 @@ TEST(PublishTest, DecodeError1) { uint16_t packet_id; lwmqtt_string_t topic = lwmqtt_default_string; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 2, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 2, LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_BUFFER_TOO_SHORT); } @@ -529,7 +531,7 @@ TEST(PublishTest, Encode1) { msg.retained = true; size_t len; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, 25, &len, true, 7, topic, msg); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, 25, &len, LWMQTT_MQTT311, true, 7, topic, msg, empty_props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); @@ -570,7 +572,7 @@ TEST(PublishTest, Encode2) { msg.payload_len = 12; size_t len; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, 23, &len, false, 0, topic, msg); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, 23, &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); @@ -585,7 +587,7 @@ TEST(PublishTest, EncodeError1) { msg.payload_len = 12; size_t len; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, 2, &len, false, 0, topic, msg); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, 2, &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); EXPECT_EQ(err, LWMQTT_BUFFER_TOO_SHORT); } @@ -603,7 +605,7 @@ TEST(SubackTest, Decode1) { uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, 8, &packet_id, 2, &count, granted_qos_levels); + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, 8, &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(packet_id, 7); @@ -624,7 +626,7 @@ TEST(SubackTest, DecodeError1) { uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, 5, &packet_id, 2, &count, granted_qos_levels); + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, 5, &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_REMAINING_LENGTH_MISMATCH); } @@ -681,7 +683,7 @@ TEST(SubscribeTest, Encode1) { lwmqtt_qos_t qos_levels[3] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, 38, &len, 7, 3, topic_filters, qos_levels); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, 38, &len, LWMQTT_MQTT311, 7, 3, topic_filters, qos_levels, empty_props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); @@ -696,7 +698,7 @@ TEST(SubscribeTest, EncodeError1) { lwmqtt_qos_t qos_levels[1] = {LWMQTT_QOS0}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, 2, &len, 7, 1, topic_filters, qos_levels); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, 2, &len, LWMQTT_MQTT311, 7, 1, topic_filters, qos_levels, empty_props); EXPECT_EQ(err, LWMQTT_BUFFER_TOO_SHORT); } From 8801f609e20578faa9d1f1207de0d12d34e84f55 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Tue, 17 Sep 2019 18:17:44 -0700 Subject: [PATCH 02/26] Publish more than one property in the example. --- examples/sync.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/sync.c b/examples/sync.c index f3cb043..71e1233 100644 --- a/examples/sync.c +++ b/examples/sync.c @@ -95,9 +95,14 @@ int main() { lwmqtt_message_t msg = {.qos = LWMQTT_QOS0, .retained = true, .payload = (uint8_t *)("world"), .payload_len = 5}; // publish message - lwmqtt_property_t uprop = {.prop = LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL, .value = {.int32 = 30}}; - - lwmqtt_properties_t props = {1, &uprop}; + lwmqtt_property_t proplist[] = { + {.prop = LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL, .value = {.int32 = 30}}, + {.prop = LWMQTT_PROP_USER_PROPERTY, + .value = {.pair = { .k = lwmqtt_string("hello from"), + .v=lwmqtt_string("lwmqtt")}}}, + }; + + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&proplist}; err = lwmqtt_publish(&client, lwmqtt_string("hello"), msg, props, COMMAND_TIMEOUT); if (err != LWMQTT_SUCCESS) { printf("failed lwmqtt_keep_alive: %d\n", err); From 27646b7f95048f13899ab0aba13b74bef4b63cb2 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Tue, 17 Sep 2019 18:27:05 -0700 Subject: [PATCH 03/26] []byte properties use the same encoding as strings --- src/packet.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/packet.c b/src/packet.c index 9570989..6409e02 100644 --- a/src/packet.c +++ b/src/packet.c @@ -102,12 +102,11 @@ static size_t proplen(lwmqtt_property_t prop) { case LWMQTT_PROP_RESPONSE_INFORMATION: case LWMQTT_PROP_SERVER_REFERENCE: case LWMQTT_PROP_REASON_STRING: - return 1 + str_wire_len(prop.value.str); + // Arbitrary blobs are the same encoding. case LWMQTT_PROP_CORRELATION_DATA: case LWMQTT_PROP_AUTHENTICATION_DATA: - // TODO: Binary data - return LWMQTT_MISSING_OR_WRONG_PACKET; + return 1 + str_wire_len(prop.value.str); case LWMQTT_PROP_USER_PROPERTY: return 1 + 2 + prop.value.pair.k.len + 2 + prop.value.pair.v.len; @@ -159,13 +158,11 @@ static lwmqtt_err_t write_prop(uint8_t **buf, const uint8_t *buf_end, lwmqtt_pro case LWMQTT_PROP_RESPONSE_INFORMATION: case LWMQTT_PROP_SERVER_REFERENCE: case LWMQTT_PROP_REASON_STRING: - lwmqtt_write_string(buf, buf_end, prop.value.str); - break; + // Arbitrary blobs as the same encoding. case LWMQTT_PROP_CORRELATION_DATA: case LWMQTT_PROP_AUTHENTICATION_DATA: - // TODO: Binary data - return LWMQTT_MISSING_OR_WRONG_PACKET; + return lwmqtt_write_string(buf, buf_end, prop.value.str); case LWMQTT_PROP_USER_PROPERTY: lwmqtt_write_string(buf, buf_end, prop.value.pair.k); From abc7ab7fa42658147c9ea74fe453f4ccd4305603 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Tue, 17 Sep 2019 23:04:57 -0700 Subject: [PATCH 04/26] Fix string property encoding. --- src/packet.c | 8 +------- tests/packet.cpp | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/packet.c b/src/packet.c index 6409e02..d2fab09 100644 --- a/src/packet.c +++ b/src/packet.c @@ -55,12 +55,6 @@ lwmqtt_err_t lwmqtt_detect_remaining_length(uint8_t *buf, size_t buf_len, uint32 return LWMQTT_SUCCESS; } -static size_t str_wire_len(lwmqtt_string_t str) { - int ll = 0; - lwmqtt_varnum_length(str.len, &ll); - return ll + str.len; -} - static size_t proplen(lwmqtt_property_t prop) { int ll; switch (prop.prop) { @@ -106,7 +100,7 @@ static size_t proplen(lwmqtt_property_t prop) { // Arbitrary blobs are the same encoding. case LWMQTT_PROP_CORRELATION_DATA: case LWMQTT_PROP_AUTHENTICATION_DATA: - return 1 + str_wire_len(prop.value.str); + return 3 + prop.value.str.len; case LWMQTT_PROP_USER_PROPERTY: return 1 + 2 + prop.value.pair.k.len + 2 + prop.value.pair.v.len; diff --git a/tests/packet.cpp b/tests/packet.cpp index d4160df..4e8732b 100644 --- a/tests/packet.cpp +++ b/tests/packet.cpp @@ -5,7 +5,7 @@ extern "C" { #include "../src/packet.h" } -lwmqtt_properties_t empty_props = lwmqtt_empty_props; +static lwmqtt_properties_t empty_props = lwmqtt_empty_props; #define EXPECT_ARRAY_EQ(reference, actual, element_count) \ { \ From 96f0894f3bd42461c7bb58043f91004a96964ab9 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Tue, 17 Sep 2019 23:06:59 -0700 Subject: [PATCH 05/26] Generated tests (and a test generator) --- CMakeLists.txt | 6 +- examples/sync.c | 9 +- gentests/.gitignore | 3 + gentests/Setup.hs | 2 + gentests/app/Main.hs | 204 + gentests/package.yaml | 35 + gentests/stack.yaml | 65 + tests/generated.cpp | 9370 +++++++++++++++++++++++++++++++++++++++++ tests/packet.cpp | 8 +- 9 files changed, 9692 insertions(+), 10 deletions(-) create mode 100644 gentests/.gitignore create mode 100644 gentests/Setup.hs create mode 100644 gentests/app/Main.hs create mode 100644 gentests/package.yaml create mode 100644 gentests/stack.yaml create mode 100644 tests/generated.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index cbbb8e7..e0f9945 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 11) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-unused-parameter") include_directories(include) @@ -40,7 +40,9 @@ set(TEST_FILES tests/helpers.cpp tests/packet.cpp tests/string.cpp - tests/tests.cpp) + tests/tests.cpp + tests/generated.cpp + ) add_executable(tests ${TEST_FILES}) diff --git a/examples/sync.c b/examples/sync.c index 71e1233..edc3cc5 100644 --- a/examples/sync.c +++ b/examples/sync.c @@ -96,13 +96,12 @@ int main() { // publish message lwmqtt_property_t proplist[] = { - {.prop = LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL, .value = {.int32 = 30}}, - {.prop = LWMQTT_PROP_USER_PROPERTY, - .value = {.pair = { .k = lwmqtt_string("hello from"), - .v=lwmqtt_string("lwmqtt")}}}, + {.prop = LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL, .value = {.int32 = 30}}, + {.prop = LWMQTT_PROP_USER_PROPERTY, + .value = {.pair = {.k = lwmqtt_string("hello from"), .v = lwmqtt_string("lwmqtt")}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t *)&proplist}; err = lwmqtt_publish(&client, lwmqtt_string("hello"), msg, props, COMMAND_TIMEOUT); if (err != LWMQTT_SUCCESS) { printf("failed lwmqtt_keep_alive: %d\n", err); diff --git a/gentests/.gitignore b/gentests/.gitignore new file mode 100644 index 0000000..3483168 --- /dev/null +++ b/gentests/.gitignore @@ -0,0 +1,3 @@ +.stack-work/ +gentests.cabal +*~ \ No newline at end of file diff --git a/gentests/Setup.hs b/gentests/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/gentests/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs new file mode 100644 index 0000000..7277530 --- /dev/null +++ b/gentests/app/Main.hs @@ -0,0 +1,204 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} +{-# LANGUAGE RecordWildCards #-} + +module Main where + +import Control.Monad (replicateM) +import qualified Data.ByteString.Char8 as BC +import qualified Data.ByteString.Lazy as BL +import Data.List (intercalate) +import Network.MQTT.Arbitrary +import Network.MQTT.Types as MT +import Numeric (showHex) +import Test.QuickCheck as QC +import Text.RawString.QQ + +hexa :: BL.ByteString -> String +hexa b + | BL.null b = "0" + | otherwise = (intercalate ", " . map (\x -> "0x" <> showHex x "") . BL.unpack) b + +bool :: Bool -> String +bool True = "true" +bool False = "false" + +qos :: QoS -> String +qos QoS0 = "LWMQTT_QOS0" +qos QoS1 = "LWMQTT_QOS1" +qos QoS2 = "LWMQTT_QOS2" + +v311PubReq :: PublishRequest -> PublishRequest +v311PubReq p50 = let (PublishPkt p) = v311mask (PublishPkt p50) in p + +genPublish311Test :: Int -> PublishRequest -> IO () +genPublish311Test i p@PublishRequest{..} = do + let e = toByteString Protocol311 p + + putStrLn $ "// " <> show p + putStrLn $ "TEST(Publish311QCTest, Encode" <> show i <> ") {" + putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" + + putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" + + putStrLn . mconcat $ [ + " uint8_t topic_bytes[] = {" <> hexa _pubTopic <> "};\n", + " lwmqtt_string_t topic = { " <> show (BL.length _pubTopic) <> ", (char*)&topic_bytes};\n", + " lwmqtt_message_t msg = lwmqtt_default_message;\n", + " msg.qos = " <> qos _pubQoS <> ";\n", + " msg.retained = " <> bool _pubRetain <> ";\n", + " uint8_t msg_bytes[] = {" <> hexa _pubBody <> "};\n", + " msg.payload = (unsigned char*)&msg_bytes;\n", + " msg.payload_len = " <> show (BL.length _pubBody) <> ";\n\n", + " size_t len = 0;\n", + " lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, ", + bool _pubDup, ", ", show _pubPktID, ", topic, msg, empty_props);\n\n", + " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + " EXPECT_ARRAY_EQ(pkt, buf, len);" + ] + putStrLn "}\n" + +data Prop = IProp Int String Int + | SProp Int String (Int,BL.ByteString) + | UProp Int (Int,BL.ByteString) (Int,BL.ByteString) + +captureProps :: [MT.Property] -> [Prop] +captureProps = map e + where + peW8 i x = IProp i "byte" (fromEnum x) + peW16 i x = IProp i "int16" (fromEnum x) + peW32 i x = IProp i "int32" (fromEnum x) + peUTF8 i x = SProp i "str" (0,x) + peBin i x = SProp i "str" (0,x) + peVarInt i x = IProp i "varint" x + pePair i k v = UProp i (0,k) (0,v) + + e (PropPayloadFormatIndicator x) = peW8 0x01 x + e (PropMessageExpiryInterval x) = peW32 0x02 x + e (PropContentType x) = peUTF8 0x03 x + e (PropResponseTopic x) = peUTF8 0x08 x + e (PropCorrelationData x) = peBin 0x09 x + e (PropSubscriptionIdentifier x) = peVarInt 0x0b x + e (PropSessionExpiryInterval x) = peW32 0x11 x + e (PropAssignedClientIdentifier x) = peUTF8 0x12 x + e (PropServerKeepAlive x) = peW16 0x13 x + e (PropAuthenticationMethod x) = peUTF8 0x15 x + e (PropAuthenticationData x) = peBin 0x16 x + e (PropRequestProblemInformation x) = peW8 0x17 x + e (PropWillDelayInterval x) = peW32 0x18 x + e (PropRequestResponseInformation x) = peW8 0x19 x + e (PropResponseInformation x) = peUTF8 0x1a x + e (PropServerReference x) = peUTF8 0x1c x + e (PropReasonString x) = peUTF8 0x1f x + e (PropReceiveMaximum x) = peW16 0x21 x + e (PropTopicAliasMaximum x) = peW16 0x22 x + e (PropTopicAlias x) = peW16 0x23 x + e (PropMaximumQoS x) = peW8 0x24 x + e (PropRetainAvailable x) = peW8 0x25 x + e (PropUserProperty k v) = pePair 0x26 k v + e (PropMaximumPacketSize x) = peW32 0x27 x + e (PropWildcardSubscriptionAvailable x) = peW8 0x28 x + e (PropSubscriptionIdentifierAvailable x) = peW8 0x29 x + e (PropSharedSubscriptionAvailable x) = peW8 0x2a x + +emitByteArrays :: [Prop] -> ([String], [Prop]) +emitByteArrays = go [] [] 0 + where + go :: [String] -> [Prop] -> Int -> [Prop] -> ([String], [Prop]) + go l p _ [] = (reverse l, reverse p) + go l p n ((x@IProp{}):xs) = go l (x:p) n xs + go l p n ((SProp i s (_,bs)):xs) = go (newstr n bs:l) (SProp i s (n,bs):p) (n+1) xs + go l p n ((UProp i (_,bs1) (_,bs2)):xs) = go (newstr n bs1 : newstr (n+1) bs2 : l) (UProp i (n,bs1) (n+1,bs2):p) (n+2) xs + + newstr n s = "uint8_t bytes" <> show n <> "[] = {" <> hexa s <> "};" + +encodePropList :: [MT.Property] -> String +encodePropList props = let (hdr, cp) = (emitByteArrays . captureProps) props in + mconcat (map (<>"\n ") hdr) <> "\n" + <> " lwmqtt_property_t proplist[] = {\n" + <> mconcat (map (indent.e) cp) + <> " };\n" + where + e :: Prop -> String + e (IProp i n v) = prop i n (show v) + e (SProp i n (x,xv)) = prop i n (b x xv) + e (UProp i (k,kv) (v,vv)) = prop i "pair" ("{.k=" <> b k kv <> ", .v=" <> b v vv <> "}") + + prop i n v = "{.prop = (lwmqtt_prop_t)" <> show i <> ", .value = {." <> n <> " = " <> v <> "}},\n" + + indent = (" " <>) + + b x xv = "{" <> show (BL.length xv) <> ", (char*)&bytes" <> show x <> "}" + + p :: [BL.ByteString] -> [String] + p = map (map (toEnum . fromEnum) . BL.unpack) + +genPublish50Test :: Int -> PublishRequest -> IO () +genPublish50Test i p@PublishRequest{..} = do + let e = toByteString Protocol50 p + + putStrLn $ "// " <> show p + putStrLn $ "TEST(Publish50QCTest, Encode" <> show i <> ") {" + putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" + + putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" + + putStrLn . mconcat $ [ + " uint8_t topic_bytes[] = {" <> hexa _pubTopic <> "};\n", + " lwmqtt_string_t topic = { " <> show (BL.length _pubTopic) <> ", (char*)&topic_bytes};\n", + " lwmqtt_message_t msg = lwmqtt_default_message;\n", + " msg.qos = " <> qos _pubQoS <> ";\n", + " msg.retained = " <> bool _pubRetain <> ";\n", + " uint8_t msg_bytes[] = {" <> hexa _pubBody <> "};\n", + " msg.payload = (unsigned char*)&msg_bytes;\n", + " msg.payload_len = " <> show (BL.length _pubBody) <> ";\n\n", + " ", encodePropList _pubProps, "\n", + " lwmqtt_properties_t props = {" <> show (length _pubProps) <> ", (lwmqtt_property_t*)&proplist};\n", + " size_t len = 0;\n", + " lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, ", + bool _pubDup, ", ", show _pubPktID, ", topic, msg, props);\n\n", + " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + " EXPECT_ARRAY_EQ(pkt, buf, len);" + ] + putStrLn "}\n" + + +main :: IO () +main = do + putStrLn [r|#include + +extern "C" { +#include +#include "../src/packet.h" +} + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#ifdef __clang__ +#pragma GCC diagnostic ignored "-Wc99-extensions" +#else +#pragma GCC diagnostic ignored "-Wpedantic" +#endif +#endif + +static lwmqtt_properties_t empty_props = lwmqtt_empty_props; + +#define EXPECT_ARRAY_EQ(reference, actual, element_count) \ + { \ + for (size_t cmp_i = 0; cmp_i < element_count; cmp_i++) { \ + EXPECT_EQ(reference[cmp_i], actual[cmp_i]) << "At byte: " << cmp_i; \ + } \ + } +|] + x <- replicateM 100 $ generate arbitrary + mapM_ (\(i,p) -> genPublish311Test i (v311PubReq p)) $ zip [1..] x + mapM_ (uncurry genPublish50Test) $ zip [1..] x + genPublish50Test 0 (PublishRequest{ + _pubTopic = "surgemq", + _pubBody = "send me home", + _pubRetain = True, + _pubQoS = QoS1, + _pubDup = False, + _pubPktID = 0, + _pubProps = [PropMessageExpiryInterval 33, + PropReasonString "a reason"]}) diff --git a/gentests/package.yaml b/gentests/package.yaml new file mode 100644 index 0000000..e5f00ba --- /dev/null +++ b/gentests/package.yaml @@ -0,0 +1,35 @@ +name: gentests +version: 0.1.0.0 +github: "dustin/gentests" +license: BSD3 +author: "Dustin Sallings" +maintainer: "dustin@spy.net" +copyright: "MIT" + +extra-source-files: [] + +# Metadata used when publishing your package +# synopsis: Short description of your package +# category: Web + +# To avoid duplicated efforts in documentation and dealing with the +# complications of embedding Haddock markup inside cabal files, it is +# common to point users to the README.md file. +description: Please see the README on GitHub at + +dependencies: +- base >= 4.7 && < 5 + +executables: + gentests: + main: Main.hs + source-dirs: app + ghc-options: + - -threaded + - -rtsopts + - -with-rtsopts=-N + dependencies: + - net-mqtt + - QuickCheck + - bytestring + - raw-strings-qq diff --git a/gentests/stack.yaml b/gentests/stack.yaml new file mode 100644 index 0000000..7ef783a --- /dev/null +++ b/gentests/stack.yaml @@ -0,0 +1,65 @@ +# This file was automatically generated by 'stack init' +# +# Some commonly used options have been documented as comments in this file. +# For advanced use and comprehensive documentation of the format, please see: +# https://docs.haskellstack.org/en/stable/yaml_configuration/ + +# Resolver to choose a 'specific' stackage snapshot or a compiler version. +# A snapshot resolver dictates the compiler version and the set of packages +# to be used for project dependencies. For example: +# +# resolver: lts-3.5 +# resolver: nightly-2015-09-21 +# resolver: ghc-7.10.2 +# +# The location of a snapshot can be provided as a file or url. Stack assumes +# a snapshot provided as a file might change, whereas a url resource does not. +# +# resolver: ./custom-snapshot.yaml +# resolver: https://example.com/snapshots/2018-01-01.yaml +resolver: lts-14.6 + +# User packages to be built. +# Various formats can be used as shown in the example below. +# +# packages: +# - some-directory +# - https://example.com/foo/bar/baz-0.0.2.tar.gz +# - location: +# git: https://github.com/commercialhaskell/stack.git +# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# subdirs: +# - auto-update +# - wai +packages: +- . +# Dependency packages to be pulled from upstream that are not in the resolver +# using the same syntax as the packages field. +# (e.g., acme-missiles-0.3) +extra-deps: +- net-mqtt-0.5.1.0 + +# Override default flag values for local packages and extra-deps +# flags: {} + +# Extra package databases containing global packages +# extra-package-dbs: [] + +# Control whether we use the GHC we find on the path +# system-ghc: true +# +# Require a specific version of stack, using version ranges +# require-stack-version: -any # Default +# require-stack-version: ">=1.9" +# +# Override the architecture used by stack, especially useful on Windows +# arch: i386 +# arch: x86_64 +# +# Extra directories used by stack for building +# extra-include-dirs: [/path/to/dir] +# extra-lib-dirs: [/path/to/dir] +# +# Allow a newer minor version of GHC than the snapshot specifies +# compiler-check: newer-minor diff --git a/tests/generated.cpp b/tests/generated.cpp new file mode 100644 index 0000000..81eb8b9 --- /dev/null +++ b/tests/generated.cpp @@ -0,0 +1,9370 @@ +#include + +extern "C" { +#include +#include "../src/packet.h" +} + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#ifdef __clang__ +#pragma GCC diagnostic ignored "-Wc99-extensions" +#else +#pragma GCC diagnostic ignored "-Wpedantic" +#endif +#endif + +static lwmqtt_properties_t empty_props = lwmqtt_empty_props; + +#define EXPECT_ARRAY_EQ(reference, actual, element_count) \ + { \ + for (size_t cmp_i = 0; cmp_i < element_count; cmp_i++) { \ + EXPECT_EQ(reference[cmp_i], actual[cmp_i]) << "At byte: " << cmp_i; \ + } \ + } + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\136Y\192\226{\129\199E\USu\182\215\SUB'\245\DC4\171\139\NAKY", _pubPktID = 15774, _pubBody = "\255", _pubProps = +// []} +TEST(Publish311QCTest, Encode1) { + uint8_t pkt[] = {0x32, 0x19, 0x0, 0x14, 0x88, 0x59, 0xc0, 0xe2, 0x7b, 0x81, 0xc7, 0x45, 0x1f, 0x75, + 0xb6, 0xd7, 0x1a, 0x27, 0xf5, 0x14, 0xab, 0x8b, 0x15, 0x59, 0x3d, 0x9e, 0xff}; + + uint8_t buf[37] = {0}; + + uint8_t topic_bytes[] = {0x88, 0x59, 0xc0, 0xe2, 0x7b, 0x81, 0xc7, 0x45, 0x1f, 0x75, + 0xb6, 0xd7, 0x1a, 0x27, 0xf5, 0x14, 0xab, 0x8b, 0x15, 0x59}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xff}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15774, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129/gG\151\&6y\225\246\193\230", +// _pubPktID = 31160, _pubBody = "\243\207\138\211\213\183N\154\SOafk\220\SUBT", _pubProps = []} +TEST(Publish311QCTest, Encode2) { + uint8_t pkt[] = {0x3d, 0x1e, 0x0, 0xb, 0x81, 0x2f, 0x67, 0x47, 0x97, 0x36, 0x79, 0xe1, 0xf6, 0xc1, 0xe6, 0x79, + 0xb8, 0xf3, 0xcf, 0x8a, 0xd3, 0xd5, 0xb7, 0x4e, 0x9a, 0xe, 0x61, 0x66, 0x6b, 0xdc, 0x1a, 0x54}; + + uint8_t buf[42] = {0}; + + uint8_t topic_bytes[] = {0x81, 0x2f, 0x67, 0x47, 0x97, 0x36, 0x79, 0xe1, 0xf6, 0xc1, 0xe6}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xf3, 0xcf, 0x8a, 0xd3, 0xd5, 0xb7, 0x4e, 0x9a, 0xe, 0x61, 0x66, 0x6b, 0xdc, 0x1a, 0x54}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 15; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 31160, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\173\FS\174\250\f\SYN6\ENQ\218i\199\ETB\213\180 \FS%", _pubPktID = 27531, _pubBody = "\129\232\a\215w\236", +// _pubProps = []} +TEST(Publish311QCTest, Encode3) { + uint8_t pkt[] = {0x35, 0x1b, 0x0, 0x11, 0xad, 0x1c, 0xae, 0xfa, 0xc, 0x16, 0x36, 0x5, 0xda, 0x69, 0xc7, + 0x17, 0xd5, 0xb4, 0x20, 0x1c, 0x25, 0x6b, 0x8b, 0x81, 0xe8, 0x7, 0xd7, 0x77, 0xec}; + + uint8_t buf[39] = {0}; + + uint8_t topic_bytes[] = {0xad, 0x1c, 0xae, 0xfa, 0xc, 0x16, 0x36, 0x5, 0xda, + 0x69, 0xc7, 0x17, 0xd5, 0xb4, 0x20, 0x1c, 0x25}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x81, 0xe8, 0x7, 0xd7, 0x77, 0xec}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 6; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 27531, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "y\135\f\ESC\175I\RS=", _pubPktID = +// 3010, _pubBody = "\198L\248\190/9\218\229\251^", _pubProps = []} +TEST(Publish311QCTest, Encode4) { + uint8_t pkt[] = {0x35, 0x16, 0x0, 0x8, 0x79, 0x87, 0xc, 0x1b, 0xaf, 0x49, 0x1e, 0x3d, + 0xb, 0xc2, 0xc6, 0x4c, 0xf8, 0xbe, 0x2f, 0x39, 0xda, 0xe5, 0xfb, 0x5e}; + + uint8_t buf[34] = {0}; + + uint8_t topic_bytes[] = {0x79, 0x87, 0xc, 0x1b, 0xaf, 0x49, 0x1e, 0x3d}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xc6, 0x4c, 0xf8, 0xbe, 0x2f, 0x39, 0xda, 0xe5, 0xfb, 0x5e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 10; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3010, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\fQ\131\202\NAK\EOTT\204\226\174\189\&72w\136\ETX\142I\166)\137*", _pubPktID = 0, _pubBody = "\148\134\189", +// _pubProps = []} +TEST(Publish311QCTest, Encode5) { + uint8_t pkt[] = {0x30, 0x1b, 0x0, 0x16, 0xc, 0x51, 0x83, 0xca, 0x15, 0x4, 0x54, 0xcc, 0xe2, 0xae, 0xbd, + 0x37, 0x32, 0x77, 0x88, 0x3, 0x8e, 0x49, 0xa6, 0x29, 0x89, 0x2a, 0x94, 0x86, 0xbd}; + + uint8_t buf[39] = {0}; + + uint8_t topic_bytes[] = {0xc, 0x51, 0x83, 0xca, 0x15, 0x4, 0x54, 0xcc, 0xe2, 0xae, 0xbd, + 0x37, 0x32, 0x77, 0x88, 0x3, 0x8e, 0x49, 0xa6, 0x29, 0x89, 0x2a}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x94, 0x86, 0xbd}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\186\EMG9\192\229\240\204\DC2o", +// _pubPktID = 0, _pubBody = "\166!\209#\147\&1%\222\235\133Gd\174=\SIf\247\215\US^6\b\r", _pubProps = []} +TEST(Publish311QCTest, Encode6) { + uint8_t pkt[] = {0x38, 0x23, 0x0, 0xa, 0xba, 0x19, 0x47, 0x39, 0xc0, 0xe5, 0xf0, 0xcc, 0x12, + 0x6f, 0xa6, 0x21, 0xd1, 0x23, 0x93, 0x31, 0x25, 0xde, 0xeb, 0x85, 0x47, 0x64, + 0xae, 0x3d, 0xf, 0x66, 0xf7, 0xd7, 0x1f, 0x5e, 0x36, 0x8, 0xd}; + + uint8_t buf[47] = {0}; + + uint8_t topic_bytes[] = {0xba, 0x19, 0x47, 0x39, 0xc0, 0xe5, 0xf0, 0xcc, 0x12, 0x6f}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xa6, 0x21, 0xd1, 0x23, 0x93, 0x31, 0x25, 0xde, 0xeb, 0x85, 0x47, 0x64, + 0xae, 0x3d, 0xf, 0x66, 0xf7, 0xd7, 0x1f, 0x5e, 0x36, 0x8, 0xd}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 23; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\249\r\220\v\234\SOH\157\DC1_\145mx\199\189\136\241\241\184\225\ETX\132\GS\231\210\133\RS\r", _pubPktID = 32631, +// _pubBody = "\145\209\172\139\202&x\240\162\148\\U", _pubProps = []} +TEST(Publish311QCTest, Encode7) { + uint8_t pkt[] = {0x33, 0x2b, 0x0, 0x1b, 0xf9, 0xd, 0xdc, 0xb, 0xea, 0x1, 0x9d, 0x11, 0x5f, 0x91, 0x6d, + 0x78, 0xc7, 0xbd, 0x88, 0xf1, 0xf1, 0xb8, 0xe1, 0x3, 0x84, 0x1d, 0xe7, 0xd2, 0x85, 0x1e, + 0xd, 0x7f, 0x77, 0x91, 0xd1, 0xac, 0x8b, 0xca, 0x26, 0x78, 0xf0, 0xa2, 0x94, 0x5c, 0x55}; + + uint8_t buf[55] = {0}; + + uint8_t topic_bytes[] = {0xf9, 0xd, 0xdc, 0xb, 0xea, 0x1, 0x9d, 0x11, 0x5f, 0x91, 0x6d, 0x78, 0xc7, 0xbd, + 0x88, 0xf1, 0xf1, 0xb8, 0xe1, 0x3, 0x84, 0x1d, 0xe7, 0xd2, 0x85, 0x1e, 0xd}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x91, 0xd1, 0xac, 0x8b, 0xca, 0x26, 0x78, 0xf0, 0xa2, 0x94, 0x5c, 0x55}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32631, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "b\213\SO\144\154E1Y", _pubPktID = +// 17459, _pubBody = "\197\176\151_P\DC4\162Y\176\178\tN}p\223\213\213\215\&9\208.dWr", _pubProps = []} +TEST(Publish311QCTest, Encode8) { + uint8_t pkt[] = {0x35, 0x24, 0x0, 0x8, 0x62, 0xd5, 0xe, 0x90, 0x9a, 0x45, 0x31, 0x59, 0x44, + 0x33, 0xc5, 0xb0, 0x97, 0x5f, 0x50, 0x14, 0xa2, 0x59, 0xb0, 0xb2, 0x9, 0x4e, + 0x7d, 0x70, 0xdf, 0xd5, 0xd5, 0xd7, 0x39, 0xd0, 0x2e, 0x64, 0x57, 0x72}; + + uint8_t buf[48] = {0}; + + uint8_t topic_bytes[] = {0x62, 0xd5, 0xe, 0x90, 0x9a, 0x45, 0x31, 0x59}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xc5, 0xb0, 0x97, 0x5f, 0x50, 0x14, 0xa2, 0x59, 0xb0, 0xb2, 0x9, 0x4e, + 0x7d, 0x70, 0xdf, 0xd5, 0xd5, 0xd7, 0x39, 0xd0, 0x2e, 0x64, 0x57, 0x72}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17459, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\222\129", _pubPktID = 4136, +// _pubBody = "\238\173\129\190\233\254\157\252\185\239@\147\192rs\143\219-\185\140j5\231\226Y\SYN+", _pubProps = []} +TEST(Publish311QCTest, Encode9) { + uint8_t pkt[] = {0x35, 0x21, 0x0, 0x2, 0xde, 0x81, 0x10, 0x28, 0xee, 0xad, 0x81, 0xbe, + 0xe9, 0xfe, 0x9d, 0xfc, 0xb9, 0xef, 0x40, 0x93, 0xc0, 0x72, 0x73, 0x8f, + 0xdb, 0x2d, 0xb9, 0x8c, 0x6a, 0x35, 0xe7, 0xe2, 0x59, 0x16, 0x2b}; + + uint8_t buf[45] = {0}; + + uint8_t topic_bytes[] = {0xde, 0x81}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xee, 0xad, 0x81, 0xbe, 0xe9, 0xfe, 0x9d, 0xfc, 0xb9, 0xef, 0x40, 0x93, 0xc0, 0x72, + 0x73, 0x8f, 0xdb, 0x2d, 0xb9, 0x8c, 0x6a, 0x35, 0xe7, 0xe2, 0x59, 0x16, 0x2b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 27; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 4136, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = +// "]Bpc\184\177\176\&3}-\DC4K", _pubProps = []} +TEST(Publish311QCTest, Encode10) { + uint8_t pkt[] = {0x30, 0xe, 0x0, 0x0, 0x5d, 0x42, 0x70, 0x63, 0xb8, 0xb1, 0xb0, 0x33, 0x7d, 0x2d, 0x14, 0x4b}; + + uint8_t buf[26] = {0}; + + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x5d, 0x42, 0x70, 0x63, 0xb8, 0xb1, 0xb0, 0x33, 0x7d, 0x2d, 0x14, 0x4b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "/u\181\175\201\CANO", _pubPktID = 0, +// _pubBody = "\234\204\242\217\131\187\a+\140\DC4NsE\f\166\DC1\206pf\ETB\150\193\138\249\166r\189-S\EOT", _pubProps = +// []} +TEST(Publish311QCTest, Encode11) { + uint8_t pkt[] = {0x38, 0x27, 0x0, 0x7, 0x2f, 0x75, 0xb5, 0xaf, 0xc9, 0x18, 0x4f, 0xea, 0xcc, 0xf2, + 0xd9, 0x83, 0xbb, 0x7, 0x2b, 0x8c, 0x14, 0x4e, 0x73, 0x45, 0xc, 0xa6, 0x11, 0xce, + 0x70, 0x66, 0x17, 0x96, 0xc1, 0x8a, 0xf9, 0xa6, 0x72, 0xbd, 0x2d, 0x53, 0x4}; + + uint8_t buf[51] = {0}; + + uint8_t topic_bytes[] = {0x2f, 0x75, 0xb5, 0xaf, 0xc9, 0x18, 0x4f}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xea, 0xcc, 0xf2, 0xd9, 0x83, 0xbb, 0x7, 0x2b, 0x8c, 0x14, 0x4e, 0x73, 0x45, 0xc, 0xa6, + 0x11, 0xce, 0x70, 0x66, 0x17, 0x96, 0xc1, 0x8a, 0xf9, 0xa6, 0x72, 0xbd, 0x2d, 0x53, 0x4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "-\243H\202R\162w&\149\233\171\223", +// _pubPktID = 0, _pubBody = "\216\SO\135\ENQ\236\223\tG\203\177\ESC\132\135)\187", _pubProps = []} +TEST(Publish311QCTest, Encode12) { + uint8_t pkt[] = {0x39, 0x1d, 0x0, 0xc, 0x2d, 0xf3, 0x48, 0xca, 0x52, 0xa2, 0x77, 0x26, 0x95, 0xe9, 0xab, 0xdf, + 0xd8, 0xe, 0x87, 0x5, 0xec, 0xdf, 0x9, 0x47, 0xcb, 0xb1, 0x1b, 0x84, 0x87, 0x29, 0xbb}; + + uint8_t buf[41] = {0}; + + uint8_t topic_bytes[] = {0x2d, 0xf3, 0x48, 0xca, 0x52, 0xa2, 0x77, 0x26, 0x95, 0xe9, 0xab, 0xdf}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xd8, 0xe, 0x87, 0x5, 0xec, 0xdf, 0x9, 0x47, 0xcb, 0xb1, 0x1b, 0x84, 0x87, 0x29, 0xbb}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 15; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "W\133\164\255\227+ +// \229\201\165[q\DC25\225\242\160 >\bi", _pubPktID = 0, _pubBody = "", _pubProps = []} +TEST(Publish311QCTest, Encode13) { + uint8_t pkt[] = {0x30, 0x17, 0x0, 0x15, 0x57, 0x85, 0xa4, 0xff, 0xe3, 0x2b, 0x20, 0xe5, 0xc9, + 0xa5, 0x5b, 0x71, 0x12, 0x35, 0xe1, 0xf2, 0xa0, 0x20, 0x3e, 0x8, 0x69}; + + uint8_t buf[35] = {0}; + + uint8_t topic_bytes[] = {0x57, 0x85, 0xa4, 0xff, 0xe3, 0x2b, 0x20, 0xe5, 0xc9, 0xa5, 0x5b, + 0x71, 0x12, 0x35, 0xe1, 0xf2, 0xa0, 0x20, 0x3e, 0x8, 0x69}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 0; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "R\227\143", _pubPktID = 0, _pubBody +// = "\199\n\253\247[u\151,J\129\t\179\246y0]\143\131\146\&4n*\175\136\&6\181\148Z\ETX", _pubProps = []} +TEST(Publish311QCTest, Encode14) { + uint8_t pkt[] = {0x38, 0x22, 0x0, 0x3, 0x52, 0xe3, 0x8f, 0xc7, 0xa, 0xfd, 0xf7, 0x5b, + 0x75, 0x97, 0x2c, 0x4a, 0x81, 0x9, 0xb3, 0xf6, 0x79, 0x30, 0x5d, 0x8f, + 0x83, 0x92, 0x34, 0x6e, 0x2a, 0xaf, 0x88, 0x36, 0xb5, 0x94, 0x5a, 0x3}; + + uint8_t buf[46] = {0}; + + uint8_t topic_bytes[] = {0x52, 0xe3, 0x8f}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xc7, 0xa, 0xfd, 0xf7, 0x5b, 0x75, 0x97, 0x2c, 0x4a, 0x81, 0x9, 0xb3, 0xf6, 0x79, 0x30, + 0x5d, 0x8f, 0x83, 0x92, 0x34, 0x6e, 0x2a, 0xaf, 0x88, 0x36, 0xb5, 0x94, 0x5a, 0x3}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\DEL-\129\&3\194M2T6\ETBV5_#\188$\131T\222\ESC\137\a.\147%b", _pubPktID = 0, _pubBody = +// "\v]\154\169\138\225f:\202\251\DLEgw{\243\150\155\DELc8", _pubProps = []} +TEST(Publish311QCTest, Encode15) { + uint8_t pkt[] = {0x30, 0x30, 0x0, 0x1a, 0x7f, 0x2d, 0x81, 0x33, 0xc2, 0x4d, 0x32, 0x54, 0x36, 0x17, 0x56, 0x35, 0x5f, + 0x23, 0xbc, 0x24, 0x83, 0x54, 0xde, 0x1b, 0x89, 0x7, 0x2e, 0x93, 0x25, 0x62, 0xb, 0x5d, 0x9a, 0xa9, + 0x8a, 0xe1, 0x66, 0x3a, 0xca, 0xfb, 0x10, 0x67, 0x77, 0x7b, 0xf3, 0x96, 0x9b, 0x7f, 0x63, 0x38}; + + uint8_t buf[60] = {0}; + + uint8_t topic_bytes[] = {0x7f, 0x2d, 0x81, 0x33, 0xc2, 0x4d, 0x32, 0x54, 0x36, 0x17, 0x56, 0x35, 0x5f, + 0x23, 0xbc, 0x24, 0x83, 0x54, 0xde, 0x1b, 0x89, 0x7, 0x2e, 0x93, 0x25, 0x62}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xb, 0x5d, 0x9a, 0xa9, 0x8a, 0xe1, 0x66, 0x3a, 0xca, 0xfb, + 0x10, 0x67, 0x77, 0x7b, 0xf3, 0x96, 0x9b, 0x7f, 0x63, 0x38}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 20; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\250\181\213\174\156\146\244\243\180\160\170=", _pubPktID = 24114, _pubBody = +// "\GS-\202|\237\STX\ENQ\EM\159\143\130\NAK\242\212\182Cg\172#\193\150v\226", _pubProps = []} +TEST(Publish311QCTest, Encode16) { + uint8_t pkt[] = {0x34, 0x27, 0x0, 0xc, 0xfa, 0xb5, 0xd5, 0xae, 0x9c, 0x92, 0xf4, 0xf3, 0xb4, 0xa0, + 0xaa, 0x3d, 0x5e, 0x32, 0x1d, 0x2d, 0xca, 0x7c, 0xed, 0x2, 0x5, 0x19, 0x9f, 0x8f, + 0x82, 0x15, 0xf2, 0xd4, 0xb6, 0x43, 0x67, 0xac, 0x23, 0xc1, 0x96, 0x76, 0xe2}; + + uint8_t buf[51] = {0}; + + uint8_t topic_bytes[] = {0xfa, 0xb5, 0xd5, 0xae, 0x9c, 0x92, 0xf4, 0xf3, 0xb4, 0xa0, 0xaa, 0x3d}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x1d, 0x2d, 0xca, 0x7c, 0xed, 0x2, 0x5, 0x19, 0x9f, 0x8f, 0x82, 0x15, + 0xf2, 0xd4, 0xb6, 0x43, 0x67, 0xac, 0x23, 0xc1, 0x96, 0x76, 0xe2}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 23; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24114, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "K\128\243a\178\253\219\184\171;*\244\172'5\EMTE\CAN", _pubPktID = 30980, _pubBody = "c\SUB\219{", _pubProps = []} +TEST(Publish311QCTest, Encode17) { + uint8_t pkt[] = {0x3b, 0x1b, 0x0, 0x13, 0x4b, 0x80, 0xf3, 0x61, 0xb2, 0xfd, 0xdb, 0xb8, 0xab, 0x3b, 0x2a, + 0xf4, 0xac, 0x27, 0x35, 0x19, 0x54, 0x45, 0x18, 0x79, 0x4, 0x63, 0x1a, 0xdb, 0x7b}; + + uint8_t buf[39] = {0}; + + uint8_t topic_bytes[] = {0x4b, 0x80, 0xf3, 0x61, 0xb2, 0xfd, 0xdb, 0xb8, 0xab, 0x3b, + 0x2a, 0xf4, 0xac, 0x27, 0x35, 0x19, 0x54, 0x45, 0x18}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x63, 0x1a, 0xdb, 0x7b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30980, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "q\133\153L\176\219b\169Cy", _pubPktID +// = 0, _pubBody = "R\253\227\&8\219\234\CANi\174R\250\248\234\146G]X\252\NAK\167/\195\SUB:\GS\182-", _pubProps = []} +TEST(Publish311QCTest, Encode18) { + uint8_t pkt[] = {0x39, 0x27, 0x0, 0xa, 0x71, 0x85, 0x99, 0x4c, 0xb0, 0xdb, 0x62, 0xa9, 0x43, 0x79, + 0x52, 0xfd, 0xe3, 0x38, 0xdb, 0xea, 0x18, 0x69, 0xae, 0x52, 0xfa, 0xf8, 0xea, 0x92, + 0x47, 0x5d, 0x58, 0xfc, 0x15, 0xa7, 0x2f, 0xc3, 0x1a, 0x3a, 0x1d, 0xb6, 0x2d}; + + uint8_t buf[51] = {0}; + + uint8_t topic_bytes[] = {0x71, 0x85, 0x99, 0x4c, 0xb0, 0xdb, 0x62, 0xa9, 0x43, 0x79}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x52, 0xfd, 0xe3, 0x38, 0xdb, 0xea, 0x18, 0x69, 0xae, 0x52, 0xfa, 0xf8, 0xea, 0x92, + 0x47, 0x5d, 0x58, 0xfc, 0x15, 0xa7, 0x2f, 0xc3, 0x1a, 0x3a, 0x1d, 0xb6, 0x2d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 27; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\DC2]^:\232\227~//\232\188z\183\183\&6\248\242", _pubPktID = 31614, _pubBody = +// "g\207\142Q\206\&8\FS#f]\154[\195\180\140FW\182\130\168\&6\191\251\b\214\&0\141", _pubProps = []} +TEST(Publish311QCTest, Encode19) { + uint8_t pkt[] = {0x3d, 0x30, 0x0, 0x11, 0x12, 0x5d, 0x5e, 0x3a, 0xe8, 0xe3, 0x7e, 0x2f, 0x2f, 0xe8, 0xbc, 0x7a, 0xb7, + 0xb7, 0x36, 0xf8, 0xf2, 0x7b, 0x7e, 0x67, 0xcf, 0x8e, 0x51, 0xce, 0x38, 0x1c, 0x23, 0x66, 0x5d, 0x9a, + 0x5b, 0xc3, 0xb4, 0x8c, 0x46, 0x57, 0xb6, 0x82, 0xa8, 0x36, 0xbf, 0xfb, 0x8, 0xd6, 0x30, 0x8d}; + + uint8_t buf[60] = {0}; + + uint8_t topic_bytes[] = {0x12, 0x5d, 0x5e, 0x3a, 0xe8, 0xe3, 0x7e, 0x2f, 0x2f, + 0xe8, 0xbc, 0x7a, 0xb7, 0xb7, 0x36, 0xf8, 0xf2}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x67, 0xcf, 0x8e, 0x51, 0xce, 0x38, 0x1c, 0x23, 0x66, 0x5d, 0x9a, 0x5b, 0xc3, 0xb4, + 0x8c, 0x46, 0x57, 0xb6, 0x82, 0xa8, 0x36, 0xbf, 0xfb, 0x8, 0xd6, 0x30, 0x8d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 27; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 31614, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "y[U\202v\201A\203\136\164\190[\aZ\201\199", _pubPktID = 0, _pubBody = "`\132\CAN\206_pD[R", _pubProps = []} +TEST(Publish311QCTest, Encode20) { + uint8_t pkt[] = {0x31, 0x1b, 0x0, 0x10, 0x79, 0x5b, 0x55, 0xca, 0x76, 0xc9, 0x41, 0xcb, 0x88, 0xa4, 0xbe, + 0x5b, 0x7, 0x5a, 0xc9, 0xc7, 0x60, 0x84, 0x18, 0xce, 0x5f, 0x70, 0x44, 0x5b, 0x52}; + + uint8_t buf[39] = {0}; + + uint8_t topic_bytes[] = {0x79, 0x5b, 0x55, 0xca, 0x76, 0xc9, 0x41, 0xcb, + 0x88, 0xa4, 0xbe, 0x5b, 0x7, 0x5a, 0xc9, 0xc7}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x60, 0x84, 0x18, 0xce, 0x5f, 0x70, 0x44, 0x5b, 0x52}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 9; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "]\198\"\SUB3J\207\rX", _pubPktID = +// 0, _pubBody = "\132\170$!\216\174\202%\vC\188\240\ETB'b\DC1\134", _pubProps = []} +TEST(Publish311QCTest, Encode21) { + uint8_t pkt[] = {0x30, 0x1c, 0x0, 0x9, 0x5d, 0xc6, 0x22, 0x1a, 0x33, 0x4a, 0xcf, 0xd, 0x58, 0x84, 0xaa, + 0x24, 0x21, 0xd8, 0xae, 0xca, 0x25, 0xb, 0x43, 0xbc, 0xf0, 0x17, 0x27, 0x62, 0x11, 0x86}; + + uint8_t buf[40] = {0}; + + uint8_t topic_bytes[] = {0x5d, 0xc6, 0x22, 0x1a, 0x33, 0x4a, 0xcf, 0xd, 0x58}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x84, 0xaa, 0x24, 0x21, 0xd8, 0xae, 0xca, 0x25, 0xb, + 0x43, 0xbc, 0xf0, 0x17, 0x27, 0x62, 0x11, 0x86}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 17; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O&", _pubPktID = 13252, _pubBody = +// "\169\202l\203dz\202-l\161\226\155\212J@v\179", _pubProps = []} +TEST(Publish311QCTest, Encode22) { + uint8_t pkt[] = {0x35, 0x17, 0x0, 0x2, 0x4f, 0x26, 0x33, 0xc4, 0xa9, 0xca, 0x6c, 0xcb, 0x64, + 0x7a, 0xca, 0x2d, 0x6c, 0xa1, 0xe2, 0x9b, 0xd4, 0x4a, 0x40, 0x76, 0xb3}; + + uint8_t buf[35] = {0}; + + uint8_t topic_bytes[] = {0x4f, 0x26}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa9, 0xca, 0x6c, 0xcb, 0x64, 0x7a, 0xca, 0x2d, 0x6c, + 0xa1, 0xe2, 0x9b, 0xd4, 0x4a, 0x40, 0x76, 0xb3}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 17; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 13252, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\v\164J\248\ACKw\168\152\154\236q\RS\ESC\fX\129\180K\FS", _pubPktID = 14693, _pubBody = +// "3MM\195\166\SIw\199E\250\155\253\164\239\US\195\168\222\171\244\206\&7/\SO ?\231\SIK", _pubProps = []} +TEST(Publish311QCTest, Encode23) { + uint8_t pkt[] = {0x3b, 0x34, 0x0, 0x13, 0xb, 0xa4, 0x4a, 0xf8, 0x6, 0x77, 0xa8, 0x98, 0x9a, 0xec, + 0x71, 0x1e, 0x1b, 0xc, 0x58, 0x81, 0xb4, 0x4b, 0x1c, 0x39, 0x65, 0x33, 0x4d, 0x4d, + 0xc3, 0xa6, 0xf, 0x77, 0xc7, 0x45, 0xfa, 0x9b, 0xfd, 0xa4, 0xef, 0x1f, 0xc3, 0xa8, + 0xde, 0xab, 0xf4, 0xce, 0x37, 0x2f, 0xe, 0x20, 0x3f, 0xe7, 0xf, 0x4b}; + + uint8_t buf[64] = {0}; + + uint8_t topic_bytes[] = {0xb, 0xa4, 0x4a, 0xf8, 0x6, 0x77, 0xa8, 0x98, 0x9a, 0xec, + 0x71, 0x1e, 0x1b, 0xc, 0x58, 0x81, 0xb4, 0x4b, 0x1c}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x33, 0x4d, 0x4d, 0xc3, 0xa6, 0xf, 0x77, 0xc7, 0x45, 0xfa, 0x9b, 0xfd, 0xa4, 0xef, 0x1f, + 0xc3, 0xa8, 0xde, 0xab, 0xf4, 0xce, 0x37, 0x2f, 0xe, 0x20, 0x3f, 0xe7, 0xf, 0x4b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 14693, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\220\170\237\142", _pubPktID = 6499, +// _pubBody = "l\EOT h\135\217\143\178&\ETB$1\239@\177~BO}3V\"\176\SOH\255", _pubProps = []} +TEST(Publish311QCTest, Encode24) { + uint8_t pkt[] = {0x3a, 0x21, 0x0, 0x4, 0xdc, 0xaa, 0xed, 0x8e, 0x19, 0x63, 0x6c, 0x4, + 0x20, 0x68, 0x87, 0xd9, 0x8f, 0xb2, 0x26, 0x17, 0x24, 0x31, 0xef, 0x40, + 0xb1, 0x7e, 0x42, 0x4f, 0x7d, 0x33, 0x56, 0x22, 0xb0, 0x1, 0xff}; + + uint8_t buf[45] = {0}; + + uint8_t topic_bytes[] = {0xdc, 0xaa, 0xed, 0x8e}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x6c, 0x4, 0x20, 0x68, 0x87, 0xd9, 0x8f, 0xb2, 0x26, 0x17, 0x24, 0x31, 0xef, + 0x40, 0xb1, 0x7e, 0x42, 0x4f, 0x7d, 0x33, 0x56, 0x22, 0xb0, 0x1, 0xff}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 25; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6499, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\245Y\170\235\232x1\238Y\148", +// _pubPktID = 0, _pubBody = "\139\217\168\150q\SYN\144\176\SO\NAK\147\237", _pubProps = []} +TEST(Publish311QCTest, Encode25) { + uint8_t pkt[] = {0x38, 0x18, 0x0, 0xa, 0xf5, 0x59, 0xaa, 0xeb, 0xe8, 0x78, 0x31, 0xee, 0x59, + 0x94, 0x8b, 0xd9, 0xa8, 0x96, 0x71, 0x16, 0x90, 0xb0, 0xe, 0x15, 0x93, 0xed}; + + uint8_t buf[36] = {0}; + + uint8_t topic_bytes[] = {0xf5, 0x59, 0xaa, 0xeb, 0xe8, 0x78, 0x31, 0xee, 0x59, 0x94}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x8b, 0xd9, 0xa8, 0x96, 0x71, 0x16, 0x90, 0xb0, 0xe, 0x15, 0x93, 0xed}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\DC4\225[\128A\SUB\229p\254\164'\187\153F\223\219\&3\FS\US~\247\227\SYN(B\177\172", _pubPktID = 927, _pubBody = +// "b\DELS\153v\176m?\201\248\140\EOTe\174\196\EM\253\FS", _pubProps = []} +TEST(Publish311QCTest, Encode26) { + uint8_t pkt[] = {0x34, 0x31, 0x0, 0x1b, 0x14, 0xe1, 0x5b, 0x80, 0x41, 0x1a, 0xe5, 0x70, 0xfe, + 0xa4, 0x27, 0xbb, 0x99, 0x46, 0xdf, 0xdb, 0x33, 0x1c, 0x1f, 0x7e, 0xf7, 0xe3, + 0x16, 0x28, 0x42, 0xb1, 0xac, 0x3, 0x9f, 0x62, 0x7f, 0x53, 0x99, 0x76, 0xb0, + 0x6d, 0x3f, 0xc9, 0xf8, 0x8c, 0x4, 0x65, 0xae, 0xc4, 0x19, 0xfd, 0x1c}; + + uint8_t buf[61] = {0}; + + uint8_t topic_bytes[] = {0x14, 0xe1, 0x5b, 0x80, 0x41, 0x1a, 0xe5, 0x70, 0xfe, 0xa4, 0x27, 0xbb, 0x99, 0x46, + 0xdf, 0xdb, 0x33, 0x1c, 0x1f, 0x7e, 0xf7, 0xe3, 0x16, 0x28, 0x42, 0xb1, 0xac}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x62, 0x7f, 0x53, 0x99, 0x76, 0xb0, 0x6d, 0x3f, 0xc9, + 0xf8, 0x8c, 0x4, 0x65, 0xae, 0xc4, 0x19, 0xfd, 0x1c}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 18; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 927, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\132\158\245\v\236\159\129\175\159j(", _pubPktID = 19519, _pubBody = +// "\222Ut\223\169\215\ACK\238\228\137\147Z\EM\196", _pubProps = []} +TEST(Publish311QCTest, Encode27) { + uint8_t pkt[] = {0x33, 0x1d, 0x0, 0xb, 0x84, 0x9e, 0xf5, 0xb, 0xec, 0x9f, 0x81, 0xaf, 0x9f, 0x6a, 0x28, 0x4c, + 0x3f, 0xde, 0x55, 0x74, 0xdf, 0xa9, 0xd7, 0x6, 0xee, 0xe4, 0x89, 0x93, 0x5a, 0x19, 0xc4}; + + uint8_t buf[41] = {0}; + + uint8_t topic_bytes[] = {0x84, 0x9e, 0xf5, 0xb, 0xec, 0x9f, 0x81, 0xaf, 0x9f, 0x6a, 0x28}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xde, 0x55, 0x74, 0xdf, 0xa9, 0xd7, 0x6, 0xee, 0xe4, 0x89, 0x93, 0x5a, 0x19, 0xc4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19519, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "-\187#\178\187\239\RS\172\ETX\144=\172\185\192\232Q\197:A\171^\SUB\135)", _pubPktID = 18146, _pubBody = "\228\167", +// _pubProps = []} +TEST(Publish311QCTest, Encode28) { + uint8_t pkt[] = {0x32, 0x1e, 0x0, 0x18, 0x2d, 0xbb, 0x23, 0xb2, 0xbb, 0xef, 0x1e, 0xac, 0x3, 0x90, 0x3d, 0xac, + 0xb9, 0xc0, 0xe8, 0x51, 0xc5, 0x3a, 0x41, 0xab, 0x5e, 0x1a, 0x87, 0x29, 0x46, 0xe2, 0xe4, 0xa7}; + + uint8_t buf[42] = {0}; + + uint8_t topic_bytes[] = {0x2d, 0xbb, 0x23, 0xb2, 0xbb, 0xef, 0x1e, 0xac, 0x3, 0x90, 0x3d, 0xac, + 0xb9, 0xc0, 0xe8, 0x51, 0xc5, 0x3a, 0x41, 0xab, 0x5e, 0x1a, 0x87, 0x29}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xe4, 0xa7}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 2; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 18146, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "]\210f\CAN\144\189+\ETB\v~\235)\166\227\158\211\&9\SOHj\191\242\212T<", _pubPktID = 16544, _pubBody = +// "\210XDU\144\201\&4 \226VBDBmf\138\212\f\195\232", _pubProps = []} +TEST(Publish311QCTest, Encode29) { + uint8_t pkt[] = {0x3a, 0x30, 0x0, 0x18, 0x5d, 0xd2, 0x66, 0x18, 0x90, 0xbd, 0x2b, 0x17, 0xb, 0x7e, 0xeb, 0x29, 0xa6, + 0xe3, 0x9e, 0xd3, 0x39, 0x1, 0x6a, 0xbf, 0xf2, 0xd4, 0x54, 0x3c, 0x40, 0xa0, 0xd2, 0x58, 0x44, 0x55, + 0x90, 0xc9, 0x34, 0x20, 0xe2, 0x56, 0x42, 0x44, 0x42, 0x6d, 0x66, 0x8a, 0xd4, 0xc, 0xc3, 0xe8}; + + uint8_t buf[60] = {0}; + + uint8_t topic_bytes[] = {0x5d, 0xd2, 0x66, 0x18, 0x90, 0xbd, 0x2b, 0x17, 0xb, 0x7e, 0xeb, 0x29, + 0xa6, 0xe3, 0x9e, 0xd3, 0x39, 0x1, 0x6a, 0xbf, 0xf2, 0xd4, 0x54, 0x3c}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xd2, 0x58, 0x44, 0x55, 0x90, 0xc9, 0x34, 0x20, 0xe2, 0x56, + 0x42, 0x44, 0x42, 0x6d, 0x66, 0x8a, 0xd4, 0xc, 0xc3, 0xe8}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 20; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16544, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "/\151\180C\211\173\172u ", _pubPktID +// = 29329, _pubBody = "J\158~x\US\145@z/7C\157R\221Qm", _pubProps = []} +TEST(Publish311QCTest, Encode30) { + uint8_t pkt[] = {0x35, 0x1d, 0x0, 0x9, 0x2f, 0x97, 0xb4, 0x43, 0xd3, 0xad, 0xac, 0x75, 0x20, 0x72, 0x91, 0x4a, + 0x9e, 0x7e, 0x78, 0x1f, 0x91, 0x40, 0x7a, 0x2f, 0x37, 0x43, 0x9d, 0x52, 0xdd, 0x51, 0x6d}; + + uint8_t buf[41] = {0}; + + uint8_t topic_bytes[] = {0x2f, 0x97, 0xb4, 0x43, 0xd3, 0xad, 0xac, 0x75, 0x20}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x4a, 0x9e, 0x7e, 0x78, 0x1f, 0x91, 0x40, 0x7a, + 0x2f, 0x37, 0x43, 0x9d, 0x52, 0xdd, 0x51, 0x6d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 16; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29329, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "p\197\135\ETX\191\&8\221\RS\229\240\245$_2y\225iz\SYNx", _pubPktID = 12423, _pubBody = +// "\253\147\173\147\169r\130\DLE'\SUB\a\242\DC3/r\237[\213\209\140I\133\196EB\194", _pubProps = []} +TEST(Publish311QCTest, Encode31) { + uint8_t pkt[] = {0x3c, 0x32, 0x0, 0x14, 0x70, 0xc5, 0x87, 0x3, 0xbf, 0x38, 0xdd, 0x1e, 0xe5, + 0xf0, 0xf5, 0x24, 0x5f, 0x32, 0x79, 0xe1, 0x69, 0x7a, 0x16, 0x78, 0x30, 0x87, + 0xfd, 0x93, 0xad, 0x93, 0xa9, 0x72, 0x82, 0x10, 0x27, 0x1a, 0x7, 0xf2, 0x13, + 0x2f, 0x72, 0xed, 0x5b, 0xd5, 0xd1, 0x8c, 0x49, 0x85, 0xc4, 0x45, 0x42, 0xc2}; + + uint8_t buf[62] = {0}; + + uint8_t topic_bytes[] = {0x70, 0xc5, 0x87, 0x3, 0xbf, 0x38, 0xdd, 0x1e, 0xe5, 0xf0, + 0xf5, 0x24, 0x5f, 0x32, 0x79, 0xe1, 0x69, 0x7a, 0x16, 0x78}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xfd, 0x93, 0xad, 0x93, 0xa9, 0x72, 0x82, 0x10, 0x27, 0x1a, 0x7, 0xf2, 0x13, + 0x2f, 0x72, 0xed, 0x5b, 0xd5, 0xd1, 0x8c, 0x49, 0x85, 0xc4, 0x45, 0x42, 0xc2}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 12423, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "W(p\EOT\215,C\167\EOTJ\137\247C\\\183.\131\171\DELD$\195*\211\ETB\181", _pubPktID = 21051, _pubBody = +// "\131\218+\DC3Y.\244=\217J\173h\245\248\238\&8yD\219u\241", _pubProps = []} +TEST(Publish311QCTest, Encode32) { + uint8_t pkt[] = {0x3a, 0x33, 0x0, 0x1a, 0x57, 0x28, 0x70, 0x4, 0xd7, 0x2c, 0x43, 0xa7, 0x4, 0x4a, + 0x89, 0xf7, 0x43, 0x5c, 0xb7, 0x2e, 0x83, 0xab, 0x7f, 0x44, 0x24, 0xc3, 0x2a, 0xd3, + 0x17, 0xb5, 0x52, 0x3b, 0x83, 0xda, 0x2b, 0x13, 0x59, 0x2e, 0xf4, 0x3d, 0xd9, 0x4a, + 0xad, 0x68, 0xf5, 0xf8, 0xee, 0x38, 0x79, 0x44, 0xdb, 0x75, 0xf1}; + + uint8_t buf[63] = {0}; + + uint8_t topic_bytes[] = {0x57, 0x28, 0x70, 0x4, 0xd7, 0x2c, 0x43, 0xa7, 0x4, 0x4a, 0x89, 0xf7, 0x43, + 0x5c, 0xb7, 0x2e, 0x83, 0xab, 0x7f, 0x44, 0x24, 0xc3, 0x2a, 0xd3, 0x17, 0xb5}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x83, 0xda, 0x2b, 0x13, 0x59, 0x2e, 0xf4, 0x3d, 0xd9, 0x4a, 0xad, + 0x68, 0xf5, 0xf8, 0xee, 0x38, 0x79, 0x44, 0xdb, 0x75, 0xf1}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 21; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 21051, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\231\ACK\254\SIp\166\135\GS[\235\245\182#\181\186\172xu\EOT", _pubPktID = 0, _pubBody = +// "\170\DC1*\DC3\196\248-\191\212\142:", _pubProps = []} +TEST(Publish311QCTest, Encode33) { + uint8_t pkt[] = {0x38, 0x20, 0x0, 0x13, 0xe7, 0x6, 0xfe, 0xf, 0x70, 0xa6, 0x87, 0x1d, 0x5b, 0xeb, 0xf5, 0xb6, 0x23, + 0xb5, 0xba, 0xac, 0x78, 0x75, 0x4, 0xaa, 0x11, 0x2a, 0x13, 0xc4, 0xf8, 0x2d, 0xbf, 0xd4, 0x8e, 0x3a}; + + uint8_t buf[44] = {0}; + + uint8_t topic_bytes[] = {0xe7, 0x6, 0xfe, 0xf, 0x70, 0xa6, 0x87, 0x1d, 0x5b, 0xeb, + 0xf5, 0xb6, 0x23, 0xb5, 0xba, 0xac, 0x78, 0x75, 0x4}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xaa, 0x11, 0x2a, 0x13, 0xc4, 0xf8, 0x2d, 0xbf, 0xd4, 0x8e, 0x3a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 11; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\ESCe\222q\DC1?.N\128}{W\237:\250\ETB\SI\252(g\SIX\130\171\252\158", _pubPktID = 0, _pubBody = "\180v", _pubProps = +// []} +TEST(Publish311QCTest, Encode34) { + uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x1a, 0x1b, 0x65, 0xde, 0x71, 0x11, 0x3f, 0x2e, 0x4e, 0x80, 0x7d, 0x7b, 0x57, + 0xed, 0x3a, 0xfa, 0x17, 0xf, 0xfc, 0x28, 0x67, 0xf, 0x58, 0x82, 0xab, 0xfc, 0x9e, 0xb4, 0x76}; + + uint8_t buf[42] = {0}; + + uint8_t topic_bytes[] = {0x1b, 0x65, 0xde, 0x71, 0x11, 0x3f, 0x2e, 0x4e, 0x80, 0x7d, 0x7b, 0x57, 0xed, + 0x3a, 0xfa, 0x17, 0xf, 0xfc, 0x28, 0x67, 0xf, 0x58, 0x82, 0xab, 0xfc, 0x9e}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xb4, 0x76}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 2; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "6\228\247(\SUB\248\195J\179", +// _pubPktID = 16923, _pubBody = "\178", _pubProps = []} +TEST(Publish311QCTest, Encode35) { + uint8_t pkt[] = {0x32, 0xe, 0x0, 0x9, 0x36, 0xe4, 0xf7, 0x28, 0x1a, 0xf8, 0xc3, 0x4a, 0xb3, 0x42, 0x1b, 0xb2}; + + uint8_t buf[26] = {0}; + + uint8_t topic_bytes[] = {0x36, 0xe4, 0xf7, 0x28, 0x1a, 0xf8, 0xc3, 0x4a, 0xb3}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xb2}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16923, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "B\244\185\173\135\222\r/\201&\STX\197e\196Y\v\221\191\152\GS6r\131\172\188\196", _pubPktID = 7267, _pubBody = +// "ch\183\156\195l\159\210\242\FS\216/\DC4\233", _pubProps = []} +TEST(Publish311QCTest, Encode36) { + uint8_t pkt[] = {0x3a, 0x2c, 0x0, 0x1a, 0x42, 0xf4, 0xb9, 0xad, 0x87, 0xde, 0xd, 0x2f, 0xc9, 0x26, 0x2, 0xc5, + 0x65, 0xc4, 0x59, 0xb, 0xdd, 0xbf, 0x98, 0x1d, 0x36, 0x72, 0x83, 0xac, 0xbc, 0xc4, 0x1c, 0x63, + 0x63, 0x68, 0xb7, 0x9c, 0xc3, 0x6c, 0x9f, 0xd2, 0xf2, 0x1c, 0xd8, 0x2f, 0x14, 0xe9}; + + uint8_t buf[56] = {0}; + + uint8_t topic_bytes[] = {0x42, 0xf4, 0xb9, 0xad, 0x87, 0xde, 0xd, 0x2f, 0xc9, 0x26, 0x2, 0xc5, 0x65, + 0xc4, 0x59, 0xb, 0xdd, 0xbf, 0x98, 0x1d, 0x36, 0x72, 0x83, 0xac, 0xbc, 0xc4}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x63, 0x68, 0xb7, 0x9c, 0xc3, 0x6c, 0x9f, 0xd2, 0xf2, 0x1c, 0xd8, 0x2f, 0x14, 0xe9}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7267, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\174N\162+\219#\236%2\208\&5p\160Z\132\133%\ENQ\220", _pubPktID = 16245, _pubBody = "\208\219\197i\234Y\159", +// _pubProps = []} +TEST(Publish311QCTest, Encode37) { + uint8_t pkt[] = {0x3a, 0x1e, 0x0, 0x13, 0xae, 0x4e, 0xa2, 0x2b, 0xdb, 0x23, 0xec, 0x25, 0x32, 0xd0, 0x35, 0x70, + 0xa0, 0x5a, 0x84, 0x85, 0x25, 0x5, 0xdc, 0x3f, 0x75, 0xd0, 0xdb, 0xc5, 0x69, 0xea, 0x59, 0x9f}; + + uint8_t buf[42] = {0}; + + uint8_t topic_bytes[] = {0xae, 0x4e, 0xa2, 0x2b, 0xdb, 0x23, 0xec, 0x25, 0x32, 0xd0, + 0x35, 0x70, 0xa0, 0x5a, 0x84, 0x85, 0x25, 0x5, 0xdc}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xd0, 0xdb, 0xc5, 0x69, 0xea, 0x59, 0x9f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 7; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16245, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "(3\136}\227\211\FS\ETB&\222\219I\US\220}\129\253\151", _pubPktID = 28557, _pubBody = "\187|", _pubProps = []} +TEST(Publish311QCTest, Encode38) { + uint8_t pkt[] = {0x3d, 0x18, 0x0, 0x12, 0x28, 0x33, 0x88, 0x7d, 0xe3, 0xd3, 0x1c, 0x17, 0x26, + 0xde, 0xdb, 0x49, 0x1f, 0xdc, 0x7d, 0x81, 0xfd, 0x97, 0x6f, 0x8d, 0xbb, 0x7c}; + + uint8_t buf[36] = {0}; + + uint8_t topic_bytes[] = {0x28, 0x33, 0x88, 0x7d, 0xe3, 0xd3, 0x1c, 0x17, 0x26, + 0xde, 0xdb, 0x49, 0x1f, 0xdc, 0x7d, 0x81, 0xfd, 0x97}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xbb, 0x7c}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 2; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 28557, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\215\235\&1\174\249\STX", +// _pubPktID = 17754, _pubBody = "\246?w\EM\240\218\fF", _pubProps = []} +TEST(Publish311QCTest, Encode39) { + uint8_t pkt[] = {0x32, 0x13, 0x0, 0x7, 0x15, 0xd7, 0xeb, 0x31, 0xae, 0xf9, 0x2, + 0x45, 0x5a, 0xf6, 0x3f, 0x77, 0x19, 0xf0, 0xda, 0xc, 0x46}; + + uint8_t buf[31] = {0}; + + uint8_t topic_bytes[] = {0x15, 0xd7, 0xeb, 0x31, 0xae, 0xf9, 0x2}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xf6, 0x3f, 0x77, 0x19, 0xf0, 0xda, 0xc, 0x46}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 8; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17754, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "Q\188\GS\173\231\131\DC4\r\151\251\145\171\&2b\222\209\NUL\250\&4,KR", _pubPktID = 27100, _pubBody = +// "T\DC2\SO\244\150V\ENQ\RS\244\135\238\SIU#[M=#h\232\206U", _pubProps = []} +TEST(Publish311QCTest, Encode40) { + uint8_t pkt[] = {0x35, 0x30, 0x0, 0x16, 0x51, 0xbc, 0x1d, 0xad, 0xe7, 0x83, 0x14, 0xd, 0x97, 0xfb, 0x91, 0xab, 0x32, + 0x62, 0xde, 0xd1, 0x0, 0xfa, 0x34, 0x2c, 0x4b, 0x52, 0x69, 0xdc, 0x54, 0x12, 0xe, 0xf4, 0x96, 0x56, + 0x5, 0x1e, 0xf4, 0x87, 0xee, 0xf, 0x55, 0x23, 0x5b, 0x4d, 0x3d, 0x23, 0x68, 0xe8, 0xce, 0x55}; + + uint8_t buf[60] = {0}; + + uint8_t topic_bytes[] = {0x51, 0xbc, 0x1d, 0xad, 0xe7, 0x83, 0x14, 0xd, 0x97, 0xfb, 0x91, + 0xab, 0x32, 0x62, 0xde, 0xd1, 0x0, 0xfa, 0x34, 0x2c, 0x4b, 0x52}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x54, 0x12, 0xe, 0xf4, 0x96, 0x56, 0x5, 0x1e, 0xf4, 0x87, 0xee, + 0xf, 0x55, 0x23, 0x5b, 0x4d, 0x3d, 0x23, 0x68, 0xe8, 0xce, 0x55}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 27100, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\165\t\199\ESC[\fQ\131\177s\220X\DC1^\151s\198\213/`\162\175,\216o\160h[\ESC", _pubPktID = 0, _pubBody = "\132", +// _pubProps = []} +TEST(Publish311QCTest, Encode41) { + uint8_t pkt[] = {0x30, 0x20, 0x0, 0x1d, 0xa5, 0x9, 0xc7, 0x1b, 0x5b, 0xc, 0x51, 0x83, + 0xb1, 0x73, 0xdc, 0x58, 0x11, 0x5e, 0x97, 0x73, 0xc6, 0xd5, 0x2f, 0x60, + 0xa2, 0xaf, 0x2c, 0xd8, 0x6f, 0xa0, 0x68, 0x5b, 0x1b, 0x84}; + + uint8_t buf[44] = {0}; + + uint8_t topic_bytes[] = {0xa5, 0x9, 0xc7, 0x1b, 0x5b, 0xc, 0x51, 0x83, 0xb1, 0x73, 0xdc, 0x58, 0x11, 0x5e, 0x97, + 0x73, 0xc6, 0xd5, 0x2f, 0x60, 0xa2, 0xaf, 0x2c, 0xd8, 0x6f, 0xa0, 0x68, 0x5b, 0x1b}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x84}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\EM\170\165z\183C\231I\198\165a2BX\n\249\&6\157", _pubPktID = 0, _pubBody = +// "\187S\143\219\221B]\180\133k\247\STX6\v'S\152\t\STX\140J \v\173\&1", _pubProps = []} +TEST(Publish311QCTest, Encode42) { + uint8_t pkt[] = {0x30, 0x2d, 0x0, 0x12, 0x19, 0xaa, 0xa5, 0x7a, 0xb7, 0x43, 0xe7, 0x49, 0xc6, 0xa5, 0x61, 0x32, + 0x42, 0x58, 0xa, 0xf9, 0x36, 0x9d, 0xbb, 0x53, 0x8f, 0xdb, 0xdd, 0x42, 0x5d, 0xb4, 0x85, 0x6b, + 0xf7, 0x2, 0x36, 0xb, 0x27, 0x53, 0x98, 0x9, 0x2, 0x8c, 0x4a, 0x20, 0xb, 0xad, 0x31}; + + uint8_t buf[57] = {0}; + + uint8_t topic_bytes[] = {0x19, 0xaa, 0xa5, 0x7a, 0xb7, 0x43, 0xe7, 0x49, 0xc6, + 0xa5, 0x61, 0x32, 0x42, 0x58, 0xa, 0xf9, 0x36, 0x9d}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xbb, 0x53, 0x8f, 0xdb, 0xdd, 0x42, 0x5d, 0xb4, 0x85, 0x6b, 0xf7, 0x2, 0x36, + 0xb, 0x27, 0x53, 0x98, 0x9, 0x2, 0x8c, 0x4a, 0x20, 0xb, 0xad, 0x31}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 25; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\DC3puWV\211\161\DC3\DC2\158\213rb\196~o", _pubProps = []} +TEST(Publish311QCTest, Encode43) { + uint8_t pkt[] = {0x31, 0x12, 0x0, 0x0, 0x13, 0x70, 0x75, 0x57, 0x56, 0xd3, + 0xa1, 0x13, 0x12, 0x9e, 0xd5, 0x72, 0x62, 0xc4, 0x7e, 0x6f}; + + uint8_t buf[30] = {0}; + + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x13, 0x70, 0x75, 0x57, 0x56, 0xd3, 0xa1, 0x13, + 0x12, 0x9e, 0xd5, 0x72, 0x62, 0xc4, 0x7e, 0x6f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 16; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\183\171\EM\217\146\128\EOT", +// _pubPktID = 4653, _pubBody = "n\237\EMMW\138\234\154\191\141\158", _pubProps = []} +TEST(Publish311QCTest, Encode44) { + uint8_t pkt[] = {0x3d, 0x16, 0x0, 0x7, 0xb7, 0xab, 0x19, 0xd9, 0x92, 0x80, 0x4, 0x12, + 0x2d, 0x6e, 0xed, 0x19, 0x4d, 0x57, 0x8a, 0xea, 0x9a, 0xbf, 0x8d, 0x9e}; + + uint8_t buf[34] = {0}; + + uint8_t topic_bytes[] = {0xb7, 0xab, 0x19, 0xd9, 0x92, 0x80, 0x4}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x6e, 0xed, 0x19, 0x4d, 0x57, 0x8a, 0xea, 0x9a, 0xbf, 0x8d, 0x9e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 11; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 4653, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\DC4\238q\ACK\ESC\142Z\GS\147\186\v?\208O", _pubPktID = 0, _pubBody = "Q4\149", _pubProps = []} +TEST(Publish311QCTest, Encode45) { + uint8_t pkt[] = {0x30, 0x13, 0x0, 0xe, 0x14, 0xee, 0x71, 0x6, 0x1b, 0x8e, 0x5a, + 0x1d, 0x93, 0xba, 0xb, 0x3f, 0xd0, 0x4f, 0x51, 0x34, 0x95}; + + uint8_t buf[31] = {0}; + + uint8_t topic_bytes[] = {0x14, 0xee, 0x71, 0x6, 0x1b, 0x8e, 0x5a, 0x1d, 0x93, 0xba, 0xb, 0x3f, 0xd0, 0x4f}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x51, 0x34, 0x95}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\180=\US\SYN\229\232", _pubPktID = +// 28144, _pubBody = "\SYN\238,\186\225\221v\229\138\172", _pubProps = []} +TEST(Publish311QCTest, Encode46) { + uint8_t pkt[] = {0x35, 0x14, 0x0, 0x6, 0xb4, 0x3d, 0x1f, 0x16, 0xe5, 0xe8, 0x6d, + 0xf0, 0x16, 0xee, 0x2c, 0xba, 0xe1, 0xdd, 0x76, 0xe5, 0x8a, 0xac}; + + uint8_t buf[32] = {0}; + + uint8_t topic_bytes[] = {0xb4, 0x3d, 0x1f, 0x16, 0xe5, 0xe8}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x16, 0xee, 0x2c, 0xba, 0xe1, 0xdd, 0x76, 0xe5, 0x8a, 0xac}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 10; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 28144, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\186\182n\166", _pubPktID = 0, +// _pubBody = "\234+5&F\SYN\140C!\209\ACK\141C\138\180\SOH", _pubProps = []} +TEST(Publish311QCTest, Encode47) { + uint8_t pkt[] = {0x39, 0x16, 0x0, 0x4, 0xba, 0xb6, 0x6e, 0xa6, 0xea, 0x2b, 0x35, 0x26, + 0x46, 0x16, 0x8c, 0x43, 0x21, 0xd1, 0x6, 0x8d, 0x43, 0x8a, 0xb4, 0x1}; + + uint8_t buf[34] = {0}; + + uint8_t topic_bytes[] = {0xba, 0xb6, 0x6e, 0xa6}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xea, 0x2b, 0x35, 0x26, 0x46, 0x16, 0x8c, 0x43, 0x21, 0xd1, 0x6, 0x8d, 0x43, 0x8a, 0xb4, 0x1}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 16; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "3", _pubPktID = 0, _pubBody = +// "\DLE5\164cC\229MU\SYN0\131\230UV\187\196 1\210[2\232", _pubProps = []} +TEST(Publish311QCTest, Encode48) { + uint8_t pkt[] = {0x38, 0x19, 0x0, 0x1, 0x33, 0x10, 0x35, 0xa4, 0x63, 0x43, 0xe5, 0x4d, 0x55, 0x16, + 0x30, 0x83, 0xe6, 0x55, 0x56, 0xbb, 0xc4, 0x20, 0x31, 0xd2, 0x5b, 0x32, 0xe8}; + + uint8_t buf[37] = {0}; + + uint8_t topic_bytes[] = {0x33}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x10, 0x35, 0xa4, 0x63, 0x43, 0xe5, 0x4d, 0x55, 0x16, 0x30, 0x83, + 0xe6, 0x55, 0x56, 0xbb, 0xc4, 0x20, 0x31, 0xd2, 0x5b, 0x32, 0xe8}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\147\SUB\NUL\215\&1\153\202&79\r", +// _pubPktID = 0, _pubBody = "c\217\202\193\156\199\202\222\SO\143\145\202\135\136\239\147Z\197\245\196\133\249\191A", +// _pubProps = []} +TEST(Publish311QCTest, Encode49) { + uint8_t pkt[] = {0x31, 0x25, 0x0, 0xb, 0x93, 0x1a, 0x0, 0xd7, 0x31, 0x99, 0xca, 0x26, 0x37, + 0x39, 0xd, 0x63, 0xd9, 0xca, 0xc1, 0x9c, 0xc7, 0xca, 0xde, 0xe, 0x8f, 0x91, + 0xca, 0x87, 0x88, 0xef, 0x93, 0x5a, 0xc5, 0xf5, 0xc4, 0x85, 0xf9, 0xbf, 0x41}; + + uint8_t buf[49] = {0}; + + uint8_t topic_bytes[] = {0x93, 0x1a, 0x0, 0xd7, 0x31, 0x99, 0xca, 0x26, 0x37, 0x39, 0xd}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x63, 0xd9, 0xca, 0xc1, 0x9c, 0xc7, 0xca, 0xde, 0xe, 0x8f, 0x91, 0xca, + 0x87, 0x88, 0xef, 0x93, 0x5a, 0xc5, 0xf5, 0xc4, 0x85, 0xf9, 0xbf, 0x41}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\199\220\252\SI\147K\173", _pubPktID +// = 22359, _pubBody = "\179\135\192#+E7,\SO&0\CAN\239\145\190\193\159\161\ETX\v\205~yy\158v\209Tt\143", _pubProps = []} +TEST(Publish311QCTest, Encode50) { + uint8_t pkt[] = {0x35, 0x29, 0x0, 0x7, 0xc7, 0xdc, 0xfc, 0xf, 0x93, 0x4b, 0xad, 0x57, 0x57, 0xb3, 0x87, + 0xc0, 0x23, 0x2b, 0x45, 0x37, 0x2c, 0xe, 0x26, 0x30, 0x18, 0xef, 0x91, 0xbe, 0xc1, 0x9f, + 0xa1, 0x3, 0xb, 0xcd, 0x7e, 0x79, 0x79, 0x9e, 0x76, 0xd1, 0x54, 0x74, 0x8f}; + + uint8_t buf[53] = {0}; + + uint8_t topic_bytes[] = {0xc7, 0xdc, 0xfc, 0xf, 0x93, 0x4b, 0xad}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xb3, 0x87, 0xc0, 0x23, 0x2b, 0x45, 0x37, 0x2c, 0xe, 0x26, 0x30, 0x18, 0xef, 0x91, 0xbe, + 0xc1, 0x9f, 0xa1, 0x3, 0xb, 0xcd, 0x7e, 0x79, 0x79, 0x9e, 0x76, 0xd1, 0x54, 0x74, 0x8f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 22359, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\225Uc\EM\147>\149\248\SI9\ENQs\211]\179", _pubPktID = 25366, _pubBody = "\165c\155\220\241\175\249\EM\220Bi\224\t", +// _pubProps = []} +TEST(Publish311QCTest, Encode51) { + uint8_t pkt[] = {0x32, 0x20, 0x0, 0xf, 0xe1, 0x55, 0x63, 0x19, 0x93, 0x3e, 0x95, 0xf8, 0xf, 0x39, 0x5, 0x73, 0xd3, + 0x5d, 0xb3, 0x63, 0x16, 0xa5, 0x63, 0x9b, 0xdc, 0xf1, 0xaf, 0xf9, 0x19, 0xdc, 0x42, 0x69, 0xe0, 0x9}; + + uint8_t buf[44] = {0}; + + uint8_t topic_bytes[] = {0xe1, 0x55, 0x63, 0x19, 0x93, 0x3e, 0x95, 0xf8, 0xf, 0x39, 0x5, 0x73, 0xd3, 0x5d, 0xb3}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xa5, 0x63, 0x9b, 0xdc, 0xf1, 0xaf, 0xf9, 0x19, 0xdc, 0x42, 0x69, 0xe0, 0x9}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25366, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "sS\f@K\\`9t", _pubPktID = 0, +// _pubBody = "9?\202\215M\ENQvqz\243\164Lg", _pubProps = []} +TEST(Publish311QCTest, Encode52) { + uint8_t pkt[] = {0x30, 0x18, 0x0, 0x9, 0x73, 0x53, 0xc, 0x40, 0x4b, 0x5c, 0x60, 0x39, 0x74, + 0x39, 0x3f, 0xca, 0xd7, 0x4d, 0x5, 0x76, 0x71, 0x7a, 0xf3, 0xa4, 0x4c, 0x67}; + + uint8_t buf[36] = {0}; + + uint8_t topic_bytes[] = {0x73, 0x53, 0xc, 0x40, 0x4b, 0x5c, 0x60, 0x39, 0x74}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x39, 0x3f, 0xca, 0xd7, 0x4d, 0x5, 0x76, 0x71, 0x7a, 0xf3, 0xa4, 0x4c, 0x67}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\220", _pubPktID = 0, _pubBody = +// "m>\243z\246\250\139\171?\208F\f\240\232\EOTT`\241\212\SOH\182\b\SI@\228A", _pubProps = []} +TEST(Publish311QCTest, Encode53) { + uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x1, 0xdc, 0x6d, 0x3e, 0xf3, 0x7a, 0xf6, 0xfa, 0x8b, 0xab, 0x3f, 0xd0, 0x46, + 0xc, 0xf0, 0xe8, 0x4, 0x54, 0x60, 0xf1, 0xd4, 0x1, 0xb6, 0x8, 0xf, 0x40, 0xe4, 0x41}; + + uint8_t buf[41] = {0}; + + uint8_t topic_bytes[] = {0xdc}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x6d, 0x3e, 0xf3, 0x7a, 0xf6, 0xfa, 0x8b, 0xab, 0x3f, 0xd0, 0x46, 0xc, 0xf0, + 0xe8, 0x4, 0x54, 0x60, 0xf1, 0xd4, 0x1, 0xb6, 0x8, 0xf, 0x40, 0xe4, 0x41}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\f\143\204y\245\248\131\153\248\250\nj\156\173\166\174\GSIv\154\166w\r\136Y", _pubPktID = 0, _pubBody = +// "\177\216D\168\tF\242kx1\247\n", _pubProps = []} +TEST(Publish311QCTest, Encode54) { + uint8_t pkt[] = {0x31, 0x27, 0x0, 0x19, 0xc, 0x8f, 0xcc, 0x79, 0xf5, 0xf8, 0x83, 0x99, 0xf8, 0xfa, + 0xa, 0x6a, 0x9c, 0xad, 0xa6, 0xae, 0x1d, 0x49, 0x76, 0x9a, 0xa6, 0x77, 0xd, 0x88, + 0x59, 0xb1, 0xd8, 0x44, 0xa8, 0x9, 0x46, 0xf2, 0x6b, 0x78, 0x31, 0xf7, 0xa}; + + uint8_t buf[51] = {0}; + + uint8_t topic_bytes[] = {0xc, 0x8f, 0xcc, 0x79, 0xf5, 0xf8, 0x83, 0x99, 0xf8, 0xfa, 0xa, 0x6a, 0x9c, + 0xad, 0xa6, 0xae, 0x1d, 0x49, 0x76, 0x9a, 0xa6, 0x77, 0xd, 0x88, 0x59}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xb1, 0xd8, 0x44, 0xa8, 0x9, 0x46, 0xf2, 0x6b, 0x78, 0x31, 0xf7, 0xa}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "x\141i\235F", _pubPktID = 15511, +// _pubBody = "\174]0.\196?\198\195\202m`\179\253E\v|\204\214P\f\229\NAK\154\130", _pubProps = []} +TEST(Publish311QCTest, Encode55) { + uint8_t pkt[] = {0x32, 0x21, 0x0, 0x5, 0x78, 0x8d, 0x69, 0xeb, 0x46, 0x3c, 0x97, 0xae, + 0x5d, 0x30, 0x2e, 0xc4, 0x3f, 0xc6, 0xc3, 0xca, 0x6d, 0x60, 0xb3, 0xfd, + 0x45, 0xb, 0x7c, 0xcc, 0xd6, 0x50, 0xc, 0xe5, 0x15, 0x9a, 0x82}; + + uint8_t buf[45] = {0}; + + uint8_t topic_bytes[] = {0x78, 0x8d, 0x69, 0xeb, 0x46}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xae, 0x5d, 0x30, 0x2e, 0xc4, 0x3f, 0xc6, 0xc3, 0xca, 0x6d, 0x60, 0xb3, + 0xfd, 0x45, 0xb, 0x7c, 0xcc, 0xd6, 0x50, 0xc, 0xe5, 0x15, 0x9a, 0x82}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15511, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\207", _pubPktID = 12437, _pubBody = +// "\209\NAKT\231?\229R\176}\ESC\195\172\146\168\148\188;\237\205\216\134\&4\132\&5w", _pubProps = []} +TEST(Publish311QCTest, Encode56) { + uint8_t pkt[] = {0x3a, 0x1e, 0x0, 0x1, 0xcf, 0x30, 0x95, 0xd1, 0x15, 0x54, 0xe7, 0x3f, 0xe5, 0x52, 0xb0, 0x7d, + 0x1b, 0xc3, 0xac, 0x92, 0xa8, 0x94, 0xbc, 0x3b, 0xed, 0xcd, 0xd8, 0x86, 0x34, 0x84, 0x35, 0x77}; + + uint8_t buf[42] = {0}; + + uint8_t topic_bytes[] = {0xcf}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xd1, 0x15, 0x54, 0xe7, 0x3f, 0xe5, 0x52, 0xb0, 0x7d, 0x1b, 0xc3, 0xac, 0x92, + 0xa8, 0x94, 0xbc, 0x3b, 0xed, 0xcd, 0xd8, 0x86, 0x34, 0x84, 0x35, 0x77}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 25; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 12437, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\151\157\DC2\191\177A0d\141\181", +// _pubPktID = 0, _pubBody = "(W\SO\vJ\219Q\170]\to\a3\EOT\245X?\r\255\t&i\EM\213", _pubProps = []} +TEST(Publish311QCTest, Encode57) { + uint8_t pkt[] = {0x38, 0x24, 0x0, 0xa, 0x97, 0x9d, 0x12, 0xbf, 0xb1, 0x41, 0x30, 0x64, 0x8d, + 0xb5, 0x28, 0x57, 0xe, 0xb, 0x4a, 0xdb, 0x51, 0xaa, 0x5d, 0x9, 0x6f, 0x7, + 0x33, 0x4, 0xf5, 0x58, 0x3f, 0xd, 0xff, 0x9, 0x26, 0x69, 0x19, 0xd5}; + + uint8_t buf[48] = {0}; + + uint8_t topic_bytes[] = {0x97, 0x9d, 0x12, 0xbf, 0xb1, 0x41, 0x30, 0x64, 0x8d, 0xb5}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x28, 0x57, 0xe, 0xb, 0x4a, 0xdb, 0x51, 0xaa, 0x5d, 0x9, 0x6f, 0x7, + 0x33, 0x4, 0xf5, 0x58, 0x3f, 0xd, 0xff, 0x9, 0x26, 0x69, 0x19, 0xd5}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\ETB\133p7\NAK\217\177\185\186:\228-\158\214\255\170", _pubPktID = 5681, _pubBody = +// "\NULT\212\214&\205\222\154\236\130\237_\195\200\186\137\DEL\184\213\&6\192a\241\NUL\231\168\246\180", _pubProps = +// []} +TEST(Publish311QCTest, Encode58) { + uint8_t pkt[] = {0x3c, 0x30, 0x0, 0x10, 0x17, 0x85, 0x70, 0x37, 0x15, 0xd9, 0xb1, 0xb9, 0xba, 0x3a, 0xe4, 0x2d, 0x9e, + 0xd6, 0xff, 0xaa, 0x16, 0x31, 0x0, 0x54, 0xd4, 0xd6, 0x26, 0xcd, 0xde, 0x9a, 0xec, 0x82, 0xed, 0x5f, + 0xc3, 0xc8, 0xba, 0x89, 0x7f, 0xb8, 0xd5, 0x36, 0xc0, 0x61, 0xf1, 0x0, 0xe7, 0xa8, 0xf6, 0xb4}; + + uint8_t buf[60] = {0}; + + uint8_t topic_bytes[] = {0x17, 0x85, 0x70, 0x37, 0x15, 0xd9, 0xb1, 0xb9, + 0xba, 0x3a, 0xe4, 0x2d, 0x9e, 0xd6, 0xff, 0xaa}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x0, 0x54, 0xd4, 0xd6, 0x26, 0xcd, 0xde, 0x9a, 0xec, 0x82, 0xed, 0x5f, 0xc3, 0xc8, + 0xba, 0x89, 0x7f, 0xb8, 0xd5, 0x36, 0xc0, 0x61, 0xf1, 0x0, 0xe7, 0xa8, 0xf6, 0xb4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 28; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5681, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "K#\aZV,bl\168\131\197N", _pubPktID = +// 29545, _pubBody = "q\152\198\DC3v\US", _pubProps = []} +TEST(Publish311QCTest, Encode59) { + uint8_t pkt[] = {0x3b, 0x16, 0x0, 0xc, 0x4b, 0x23, 0x7, 0x5a, 0x56, 0x2c, 0x62, 0x6c, + 0xa8, 0x83, 0xc5, 0x4e, 0x73, 0x69, 0x71, 0x98, 0xc6, 0x13, 0x76, 0x1f}; + + uint8_t buf[34] = {0}; + + uint8_t topic_bytes[] = {0x4b, 0x23, 0x7, 0x5a, 0x56, 0x2c, 0x62, 0x6c, 0xa8, 0x83, 0xc5, 0x4e}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x71, 0x98, 0xc6, 0x13, 0x76, 0x1f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 6; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29545, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\ETB./iLG\236\218\159\SOH\n\ESC\203\FSs", _pubPktID = 19215, _pubBody = +// "I\157\182\DEL\135\249\197]P>b\248\202r\201\180\226\179\255", _pubProps = []} +TEST(Publish311QCTest, Encode60) { + uint8_t pkt[] = {0x34, 0x26, 0x0, 0xf, 0x17, 0x2e, 0x2f, 0x69, 0x4c, 0x47, 0xec, 0xda, 0x9f, 0x1, + 0xa, 0x1b, 0xcb, 0x1c, 0x73, 0x4b, 0xf, 0x49, 0x9d, 0xb6, 0x7f, 0x87, 0xf9, 0xc5, + 0x5d, 0x50, 0x3e, 0x62, 0xf8, 0xca, 0x72, 0xc9, 0xb4, 0xe2, 0xb3, 0xff}; + + uint8_t buf[50] = {0}; + + uint8_t topic_bytes[] = {0x17, 0x2e, 0x2f, 0x69, 0x4c, 0x47, 0xec, 0xda, 0x9f, 0x1, 0xa, 0x1b, 0xcb, 0x1c, 0x73}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x49, 0x9d, 0xb6, 0x7f, 0x87, 0xf9, 0xc5, 0x5d, 0x50, 0x3e, + 0x62, 0xf8, 0xca, 0x72, 0xc9, 0xb4, 0xe2, 0xb3, 0xff}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 19; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19215, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\ETXv\161\NUL\132\175\165\CAN2\131", +// _pubPktID = 31455, _pubBody = "P\232c#\237\r A\219\192Z\186\241T\196\154", _pubProps = []} +TEST(Publish311QCTest, Encode61) { + uint8_t pkt[] = {0x35, 0x1e, 0x0, 0xa, 0x3, 0x76, 0xa1, 0x0, 0x84, 0xaf, 0xa5, 0x18, 0x32, 0x83, 0x7a, 0xdf, + 0x50, 0xe8, 0x63, 0x23, 0xed, 0xd, 0x20, 0x41, 0xdb, 0xc0, 0x5a, 0xba, 0xf1, 0x54, 0xc4, 0x9a}; + + uint8_t buf[42] = {0}; + + uint8_t topic_bytes[] = {0x3, 0x76, 0xa1, 0x0, 0x84, 0xaf, 0xa5, 0x18, 0x32, 0x83}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x50, 0xe8, 0x63, 0x23, 0xed, 0xd, 0x20, 0x41, 0xdb, 0xc0, 0x5a, 0xba, 0xf1, 0x54, 0xc4, 0x9a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 16; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31455, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "(\193\NAK\240\&3\174\176\CAN:q$\160F7+\162\164\bNCu\128\&3P\131\130\151\239g7", _pubPktID = 31413, _pubBody = "", +// _pubProps = []} +TEST(Publish311QCTest, Encode62) { + uint8_t pkt[] = {0x3d, 0x22, 0x0, 0x1e, 0x28, 0xc1, 0x15, 0xf0, 0x33, 0xae, 0xb0, 0x18, + 0x3a, 0x71, 0x24, 0xa0, 0x46, 0x37, 0x2b, 0xa2, 0xa4, 0x8, 0x4e, 0x43, + 0x75, 0x80, 0x33, 0x50, 0x83, 0x82, 0x97, 0xef, 0x67, 0x37, 0x7a, 0xb5}; + + uint8_t buf[46] = {0}; + + uint8_t topic_bytes[] = {0x28, 0xc1, 0x15, 0xf0, 0x33, 0xae, 0xb0, 0x18, 0x3a, 0x71, 0x24, 0xa0, 0x46, 0x37, 0x2b, + 0xa2, 0xa4, 0x8, 0x4e, 0x43, 0x75, 0x80, 0x33, 0x50, 0x83, 0x82, 0x97, 0xef, 0x67, 0x37}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 0; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 31413, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "u\197\FS\156\226\226\156\fe7\SUBD\251}\132(:k", _pubPktID = 0, _pubBody = +// "=\RS\224\ENQ\"\187\165\211E\156*\f\133Ox\197\162J\168\131\167I\SUB\190)\240\DEL\EM\216\255", _pubProps = []} +TEST(Publish311QCTest, Encode63) { + uint8_t pkt[] = {0x30, 0x32, 0x0, 0x12, 0x75, 0xc5, 0x1c, 0x9c, 0xe2, 0xe2, 0x9c, 0xc, 0x65, + 0x37, 0x1a, 0x44, 0xfb, 0x7d, 0x84, 0x28, 0x3a, 0x6b, 0x3d, 0x1e, 0xe0, 0x5, + 0x22, 0xbb, 0xa5, 0xd3, 0x45, 0x9c, 0x2a, 0xc, 0x85, 0x4f, 0x78, 0xc5, 0xa2, + 0x4a, 0xa8, 0x83, 0xa7, 0x49, 0x1a, 0xbe, 0x29, 0xf0, 0x7f, 0x19, 0xd8, 0xff}; + + uint8_t buf[62] = {0}; + + uint8_t topic_bytes[] = {0x75, 0xc5, 0x1c, 0x9c, 0xe2, 0xe2, 0x9c, 0xc, 0x65, + 0x37, 0x1a, 0x44, 0xfb, 0x7d, 0x84, 0x28, 0x3a, 0x6b}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x3d, 0x1e, 0xe0, 0x5, 0x22, 0xbb, 0xa5, 0xd3, 0x45, 0x9c, 0x2a, 0xc, 0x85, 0x4f, 0x78, + 0xc5, 0xa2, 0x4a, 0xa8, 0x83, 0xa7, 0x49, 0x1a, 0xbe, 0x29, 0xf0, 0x7f, 0x19, 0xd8, 0xff}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "s`#B\129\251kP3\n8", _pubPktID = +// 13139, _pubBody = "\SI{\192", _pubProps = []} +TEST(Publish311QCTest, Encode64) { + uint8_t pkt[] = {0x3c, 0x12, 0x0, 0xb, 0x73, 0x60, 0x23, 0x42, 0x81, 0xfb, + 0x6b, 0x50, 0x33, 0xa, 0x38, 0x33, 0x53, 0xf, 0x7b, 0xc0}; + + uint8_t buf[30] = {0}; + + uint8_t topic_bytes[] = {0x73, 0x60, 0x23, 0x42, 0x81, 0xfb, 0x6b, 0x50, 0x33, 0xa, 0x38}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xf, 0x7b, 0xc0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13139, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163]", _pubPktID = 9229, _pubBody = +// ":,\175v\152}\RS8\178|K\148\f\219\184\129Ep^\n\194\148\SOHv\\\ETB\253^", _pubProps = []} +TEST(Publish311QCTest, Encode65) { + uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x2, 0xa3, 0x5d, 0x24, 0xd, 0x3a, 0x2c, 0xaf, 0x76, + 0x98, 0x7d, 0x1e, 0x38, 0xb2, 0x7c, 0x4b, 0x94, 0xc, 0xdb, 0xb8, 0x81, + 0x45, 0x70, 0x5e, 0xa, 0xc2, 0x94, 0x1, 0x76, 0x5c, 0x17, 0xfd, 0x5e}; + + uint8_t buf[46] = {0}; + + uint8_t topic_bytes[] = {0xa3, 0x5d}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x3a, 0x2c, 0xaf, 0x76, 0x98, 0x7d, 0x1e, 0x38, 0xb2, 0x7c, 0x4b, 0x94, 0xc, 0xdb, + 0xb8, 0x81, 0x45, 0x70, 0x5e, 0xa, 0xc2, 0x94, 0x1, 0x76, 0x5c, 0x17, 0xfd, 0x5e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 28; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 9229, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "'\148R\STX\207v\202o[1\154JIl\129\189\&9.\231\220u\233\200G\f \241\196M:", _pubPktID = 0, _pubBody = +// "\239\141wL\FS\241\255ZW8R\f\CAN\ACKT\215)ZZ\200z\239", _pubProps = []} +TEST(Publish311QCTest, Encode66) { + uint8_t pkt[] = {0x30, 0x36, 0x0, 0x1e, 0x27, 0x94, 0x52, 0x2, 0xcf, 0x76, 0xca, 0x6f, 0x5b, 0x31, + 0x9a, 0x4a, 0x49, 0x6c, 0x81, 0xbd, 0x39, 0x2e, 0xe7, 0xdc, 0x75, 0xe9, 0xc8, 0x47, + 0xc, 0x20, 0xf1, 0xc4, 0x4d, 0x3a, 0xef, 0x8d, 0x77, 0x4c, 0x1c, 0xf1, 0xff, 0x5a, + 0x57, 0x38, 0x52, 0xc, 0x18, 0x6, 0x54, 0xd7, 0x29, 0x5a, 0x5a, 0xc8, 0x7a, 0xef}; + + uint8_t buf[66] = {0}; + + uint8_t topic_bytes[] = {0x27, 0x94, 0x52, 0x2, 0xcf, 0x76, 0xca, 0x6f, 0x5b, 0x31, 0x9a, 0x4a, 0x49, 0x6c, 0x81, + 0xbd, 0x39, 0x2e, 0xe7, 0xdc, 0x75, 0xe9, 0xc8, 0x47, 0xc, 0x20, 0xf1, 0xc4, 0x4d, 0x3a}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xef, 0x8d, 0x77, 0x4c, 0x1c, 0xf1, 0xff, 0x5a, 0x57, 0x38, 0x52, + 0xc, 0x18, 0x6, 0x54, 0xd7, 0x29, 0x5a, 0x5a, 0xc8, 0x7a, 0xef}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "9\140\202\235A\137*\ESC\202=k\179\211?\NAK\238", _pubPktID = 0, _pubBody = +// "R\140Q\187\192\240\209=*\152Ov\136\254G\251", _pubProps = []} +TEST(Publish311QCTest, Encode67) { + uint8_t pkt[] = {0x38, 0x22, 0x0, 0x10, 0x39, 0x8c, 0xca, 0xeb, 0x41, 0x89, 0x2a, 0x1b, + 0xca, 0x3d, 0x6b, 0xb3, 0xd3, 0x3f, 0x15, 0xee, 0x52, 0x8c, 0x51, 0xbb, + 0xc0, 0xf0, 0xd1, 0x3d, 0x2a, 0x98, 0x4f, 0x76, 0x88, 0xfe, 0x47, 0xfb}; + + uint8_t buf[46] = {0}; + + uint8_t topic_bytes[] = {0x39, 0x8c, 0xca, 0xeb, 0x41, 0x89, 0x2a, 0x1b, + 0xca, 0x3d, 0x6b, 0xb3, 0xd3, 0x3f, 0x15, 0xee}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x52, 0x8c, 0x51, 0xbb, 0xc0, 0xf0, 0xd1, 0x3d, + 0x2a, 0x98, 0x4f, 0x76, 0x88, 0xfe, 0x47, 0xfb}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 16; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\255\250\242r^\171,{\253\254\200\128\135\225AG\149\&3", _pubPktID = 19170, _pubBody = "\GS", _pubProps = []} +TEST(Publish311QCTest, Encode68) { + uint8_t pkt[] = {0x35, 0x17, 0x0, 0x12, 0xff, 0xfa, 0xf2, 0x72, 0x5e, 0xab, 0x2c, 0x7b, 0xfd, + 0xfe, 0xc8, 0x80, 0x87, 0xe1, 0x41, 0x47, 0x95, 0x33, 0x4a, 0xe2, 0x1d}; + + uint8_t buf[35] = {0}; + + uint8_t topic_bytes[] = {0xff, 0xfa, 0xf2, 0x72, 0x5e, 0xab, 0x2c, 0x7b, 0xfd, + 0xfe, 0xc8, 0x80, 0x87, 0xe1, 0x41, 0x47, 0x95, 0x33}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x1d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19170, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\f<\223\175\243\197\227\253.l\204M\219\195\149\202\132\194\182\a\CAN\n9't=\191\DLEb", _pubPktID = 0, _pubBody = "", +// _pubProps = []} +TEST(Publish311QCTest, Encode69) { + uint8_t pkt[] = {0x31, 0x1f, 0x0, 0x1d, 0xc, 0x3c, 0xdf, 0xaf, 0xf3, 0xc5, 0xe3, 0xfd, 0x2e, 0x6c, 0xcc, 0x4d, 0xdb, + 0xc3, 0x95, 0xca, 0x84, 0xc2, 0xb6, 0x7, 0x18, 0xa, 0x39, 0x27, 0x74, 0x3d, 0xbf, 0x10, 0x62}; + + uint8_t buf[43] = {0}; + + uint8_t topic_bytes[] = {0xc, 0x3c, 0xdf, 0xaf, 0xf3, 0xc5, 0xe3, 0xfd, 0x2e, 0x6c, 0xcc, 0x4d, 0xdb, 0xc3, 0x95, + 0xca, 0x84, 0xc2, 0xb6, 0x7, 0x18, 0xa, 0x39, 0x27, 0x74, 0x3d, 0xbf, 0x10, 0x62}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 0; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "3", _pubPktID = 27883, _pubBody = +// "\246\DC1,I\237\135\&0/\210\164\233\223de\144\250\141\134\&7\190\194\144\206f", _pubProps = []} +TEST(Publish311QCTest, Encode70) { + uint8_t pkt[] = {0x33, 0x1d, 0x0, 0x1, 0x33, 0x6c, 0xeb, 0xf6, 0x11, 0x2c, 0x49, 0xed, 0x87, 0x30, 0x2f, 0xd2, + 0xa4, 0xe9, 0xdf, 0x64, 0x65, 0x90, 0xfa, 0x8d, 0x86, 0x37, 0xbe, 0xc2, 0x90, 0xce, 0x66}; + + uint8_t buf[41] = {0}; + + uint8_t topic_bytes[] = {0x33}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xf6, 0x11, 0x2c, 0x49, 0xed, 0x87, 0x30, 0x2f, 0xd2, 0xa4, 0xe9, 0xdf, + 0x64, 0x65, 0x90, 0xfa, 0x8d, 0x86, 0x37, 0xbe, 0xc2, 0x90, 0xce, 0x66}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 27883, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\210\n\244+\148\225\234\&5U\226r16\207\137\NAK}\GSX\204\250S\144\151b\224\184", _pubPktID = 20202, _pubBody = +// "\191\207\175uEn7\171\238\203\140\210I\200!", _pubProps = []} +TEST(Publish311QCTest, Encode71) { + uint8_t pkt[] = {0x3b, 0x2e, 0x0, 0x1b, 0xd2, 0xa, 0xf4, 0x2b, 0x94, 0xe1, 0xea, 0x35, 0x55, 0xe2, 0x72, 0x31, + 0x36, 0xcf, 0x89, 0x15, 0x7d, 0x1d, 0x58, 0xcc, 0xfa, 0x53, 0x90, 0x97, 0x62, 0xe0, 0xb8, 0x4e, + 0xea, 0xbf, 0xcf, 0xaf, 0x75, 0x45, 0x6e, 0x37, 0xab, 0xee, 0xcb, 0x8c, 0xd2, 0x49, 0xc8, 0x21}; + + uint8_t buf[58] = {0}; + + uint8_t topic_bytes[] = {0xd2, 0xa, 0xf4, 0x2b, 0x94, 0xe1, 0xea, 0x35, 0x55, 0xe2, 0x72, 0x31, 0x36, 0xcf, + 0x89, 0x15, 0x7d, 0x1d, 0x58, 0xcc, 0xfa, 0x53, 0x90, 0x97, 0x62, 0xe0, 0xb8}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xbf, 0xcf, 0xaf, 0x75, 0x45, 0x6e, 0x37, 0xab, 0xee, 0xcb, 0x8c, 0xd2, 0x49, 0xc8, 0x21}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 15; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 20202, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\240\247\161\170\180S\251(.\139\187\RS\199\\\USs\207!7\250\&8&q\ESC\236\153", _pubPktID = 1829, _pubBody = +// ")B\201\179\163\188%[\184\154\EOT\146x7,\DC3\v\180\DLE", _pubProps = []} +TEST(Publish311QCTest, Encode72) { + uint8_t pkt[] = {0x3b, 0x31, 0x0, 0x1a, 0xf0, 0xf7, 0xa1, 0xaa, 0xb4, 0x53, 0xfb, 0x28, 0x2e, + 0x8b, 0xbb, 0x1e, 0xc7, 0x5c, 0x1f, 0x73, 0xcf, 0x21, 0x37, 0xfa, 0x38, 0x26, + 0x71, 0x1b, 0xec, 0x99, 0x7, 0x25, 0x29, 0x42, 0xc9, 0xb3, 0xa3, 0xbc, 0x25, + 0x5b, 0xb8, 0x9a, 0x4, 0x92, 0x78, 0x37, 0x2c, 0x13, 0xb, 0xb4, 0x10}; + + uint8_t buf[61] = {0}; + + uint8_t topic_bytes[] = {0xf0, 0xf7, 0xa1, 0xaa, 0xb4, 0x53, 0xfb, 0x28, 0x2e, 0x8b, 0xbb, 0x1e, 0xc7, + 0x5c, 0x1f, 0x73, 0xcf, 0x21, 0x37, 0xfa, 0x38, 0x26, 0x71, 0x1b, 0xec, 0x99}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x29, 0x42, 0xc9, 0xb3, 0xa3, 0xbc, 0x25, 0x5b, 0xb8, 0x9a, + 0x4, 0x92, 0x78, 0x37, 0x2c, 0x13, 0xb, 0xb4, 0x10}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 19; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1829, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "2k\146\244f\164\212\DC4o\197\186", +// _pubPktID = 0, _pubBody = "\216C\204\149", _pubProps = []} +TEST(Publish311QCTest, Encode73) { + uint8_t pkt[] = {0x39, 0x11, 0x0, 0xb, 0x32, 0x6b, 0x92, 0xf4, 0x66, 0xa4, + 0xd4, 0x14, 0x6f, 0xc5, 0xba, 0xd8, 0x43, 0xcc, 0x95}; + + uint8_t buf[29] = {0}; + + uint8_t topic_bytes[] = {0x32, 0x6b, 0x92, 0xf4, 0x66, 0xa4, 0xd4, 0x14, 0x6f, 0xc5, 0xba}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xd8, 0x43, 0xcc, 0x95}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "Q\199\US@hY\186f", _pubPktID = 684, +// _pubBody = "\DC1/\179\209 !\230/\187 \220\191\212", _pubProps = []} +TEST(Publish311QCTest, Encode74) { + uint8_t pkt[] = {0x3a, 0x19, 0x0, 0x8, 0x51, 0xc7, 0x1f, 0x40, 0x68, 0x59, 0xba, 0x66, 0x2, 0xac, + 0x11, 0x2f, 0xb3, 0xd1, 0x20, 0x21, 0xe6, 0x2f, 0xbb, 0x20, 0xdc, 0xbf, 0xd4}; + + uint8_t buf[37] = {0}; + + uint8_t topic_bytes[] = {0x51, 0xc7, 0x1f, 0x40, 0x68, 0x59, 0xba, 0x66}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x11, 0x2f, 0xb3, 0xd1, 0x20, 0x21, 0xe6, 0x2f, 0xbb, 0x20, 0xdc, 0xbf, 0xd4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 684, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\142\&2\163\190T\212+\DC4[\234\248w\231\165@\206\&40", _pubPktID = 9582, _pubBody = +// "[(\157B\171\184\156\f\201\EM\160\166\206\199\168\222\153NX$\247\ACK2\183", _pubProps = []} +TEST(Publish311QCTest, Encode75) { + uint8_t pkt[] = {0x3b, 0x2e, 0x0, 0x12, 0x8e, 0x32, 0xa3, 0xbe, 0x54, 0xd4, 0x2b, 0x14, 0x5b, 0xea, 0xf8, 0x77, + 0xe7, 0xa5, 0x40, 0xce, 0x34, 0x30, 0x25, 0x6e, 0x5b, 0x28, 0x9d, 0x42, 0xab, 0xb8, 0x9c, 0xc, + 0xc9, 0x19, 0xa0, 0xa6, 0xce, 0xc7, 0xa8, 0xde, 0x99, 0x4e, 0x58, 0x24, 0xf7, 0x6, 0x32, 0xb7}; + + uint8_t buf[58] = {0}; + + uint8_t topic_bytes[] = {0x8e, 0x32, 0xa3, 0xbe, 0x54, 0xd4, 0x2b, 0x14, 0x5b, + 0xea, 0xf8, 0x77, 0xe7, 0xa5, 0x40, 0xce, 0x34, 0x30}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x5b, 0x28, 0x9d, 0x42, 0xab, 0xb8, 0x9c, 0xc, 0xc9, 0x19, 0xa0, 0xa6, + 0xce, 0xc7, 0xa8, 0xde, 0x99, 0x4e, 0x58, 0x24, 0xf7, 0x6, 0x32, 0xb7}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 9582, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "ox\254Qe\203<\176\195ES", _pubPktID +// = 20876, _pubBody = "J\224\148H\132xS\156Aov\199\244wF[\n\185\190;\142o\SOHg", _pubProps = []} +TEST(Publish311QCTest, Encode76) { + uint8_t pkt[] = {0x34, 0x27, 0x0, 0xb, 0x6f, 0x78, 0xfe, 0x51, 0x65, 0xcb, 0x3c, 0xb0, 0xc3, 0x45, + 0x53, 0x51, 0x8c, 0x4a, 0xe0, 0x94, 0x48, 0x84, 0x78, 0x53, 0x9c, 0x41, 0x6f, 0x76, + 0xc7, 0xf4, 0x77, 0x46, 0x5b, 0xa, 0xb9, 0xbe, 0x3b, 0x8e, 0x6f, 0x1, 0x67}; + + uint8_t buf[51] = {0}; + + uint8_t topic_bytes[] = {0x6f, 0x78, 0xfe, 0x51, 0x65, 0xcb, 0x3c, 0xb0, 0xc3, 0x45, 0x53}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x4a, 0xe0, 0x94, 0x48, 0x84, 0x78, 0x53, 0x9c, 0x41, 0x6f, 0x76, 0xc7, + 0xf4, 0x77, 0x46, 0x5b, 0xa, 0xb9, 0xbe, 0x3b, 0x8e, 0x6f, 0x1, 0x67}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 20876, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = ")\159\249\220\185\252\230\193", +// _pubPktID = 10776, _pubBody = "\144\230\&6K\134\194\176\153\v\145(]\222\255\155\231\225(?\150}\155\FS\173)", +// _pubProps = []} +TEST(Publish311QCTest, Encode77) { + uint8_t pkt[] = {0x34, 0x25, 0x0, 0x8, 0x29, 0x9f, 0xf9, 0xdc, 0xb9, 0xfc, 0xe6, 0xc1, 0x2a, + 0x18, 0x90, 0xe6, 0x36, 0x4b, 0x86, 0xc2, 0xb0, 0x99, 0xb, 0x91, 0x28, 0x5d, + 0xde, 0xff, 0x9b, 0xe7, 0xe1, 0x28, 0x3f, 0x96, 0x7d, 0x9b, 0x1c, 0xad, 0x29}; + + uint8_t buf[49] = {0}; + + uint8_t topic_bytes[] = {0x29, 0x9f, 0xf9, 0xdc, 0xb9, 0xfc, 0xe6, 0xc1}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x90, 0xe6, 0x36, 0x4b, 0x86, 0xc2, 0xb0, 0x99, 0xb, 0x91, 0x28, 0x5d, 0xde, + 0xff, 0x9b, 0xe7, 0xe1, 0x28, 0x3f, 0x96, 0x7d, 0x9b, 0x1c, 0xad, 0x29}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 25; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10776, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "6:\229<\217\235\180", _pubPktID = +// 21683, _pubBody = "y", _pubProps = []} +TEST(Publish311QCTest, Encode78) { + uint8_t pkt[] = {0x3c, 0xc, 0x0, 0x7, 0x36, 0x3a, 0xe5, 0x3c, 0xd9, 0xeb, 0xb4, 0x54, 0xb3, 0x79}; + + uint8_t buf[24] = {0}; + + uint8_t topic_bytes[] = {0x36, 0x3a, 0xe5, 0x3c, 0xd9, 0xeb, 0xb4}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x79}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 21683, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// ",l\239A\255.e\128\238\190\EOT\216\240\231", _pubPktID = 0, _pubBody = +// "\ENQ\DC3z\234.f[;\DC2\214i0\161P\251\171\160\RS\180\222J\202\191\DC2(.", _pubProps = []} +TEST(Publish311QCTest, Encode79) { + uint8_t pkt[] = {0x31, 0x2a, 0x0, 0xe, 0x2c, 0x6c, 0xef, 0x41, 0xff, 0x2e, 0x65, 0x80, 0xee, 0xbe, 0x4, + 0xd8, 0xf0, 0xe7, 0x5, 0x13, 0x7a, 0xea, 0x2e, 0x66, 0x5b, 0x3b, 0x12, 0xd6, 0x69, 0x30, + 0xa1, 0x50, 0xfb, 0xab, 0xa0, 0x1e, 0xb4, 0xde, 0x4a, 0xca, 0xbf, 0x12, 0x28, 0x2e}; + + uint8_t buf[54] = {0}; + + uint8_t topic_bytes[] = {0x2c, 0x6c, 0xef, 0x41, 0xff, 0x2e, 0x65, 0x80, 0xee, 0xbe, 0x4, 0xd8, 0xf0, 0xe7}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x5, 0x13, 0x7a, 0xea, 0x2e, 0x66, 0x5b, 0x3b, 0x12, 0xd6, 0x69, 0x30, 0xa1, + 0x50, 0xfb, 0xab, 0xa0, 0x1e, 0xb4, 0xde, 0x4a, 0xca, 0xbf, 0x12, 0x28, 0x2e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\179\182\194\v\149\131\&4\177\175cM\153\251\204B\RS\231\170n}y\198\197)\250\203\147\151\211\138", _pubPktID = 1399, +// _pubBody = "\156\228\194pPo\189\&6\255\NAK\245-\151\170\DC3;\191\196\136\241\191\255V\146`\250\183\234>\138", +// _pubProps = []} +TEST(Publish311QCTest, Encode80) { + uint8_t pkt[] = {0x3b, 0x40, 0x0, 0x1e, 0xb3, 0xb6, 0xc2, 0xb, 0x95, 0x83, 0x34, 0xb1, 0xaf, 0x63, 0x4d, 0x99, 0xfb, + 0xcc, 0x42, 0x1e, 0xe7, 0xaa, 0x6e, 0x7d, 0x79, 0xc6, 0xc5, 0x29, 0xfa, 0xcb, 0x93, 0x97, 0xd3, 0x8a, + 0x5, 0x77, 0x9c, 0xe4, 0xc2, 0x70, 0x50, 0x6f, 0xbd, 0x36, 0xff, 0x15, 0xf5, 0x2d, 0x97, 0xaa, 0x13, + 0x3b, 0xbf, 0xc4, 0x88, 0xf1, 0xbf, 0xff, 0x56, 0x92, 0x60, 0xfa, 0xb7, 0xea, 0x3e, 0x8a}; + + uint8_t buf[76] = {0}; + + uint8_t topic_bytes[] = {0xb3, 0xb6, 0xc2, 0xb, 0x95, 0x83, 0x34, 0xb1, 0xaf, 0x63, 0x4d, 0x99, 0xfb, 0xcc, 0x42, + 0x1e, 0xe7, 0xaa, 0x6e, 0x7d, 0x79, 0xc6, 0xc5, 0x29, 0xfa, 0xcb, 0x93, 0x97, 0xd3, 0x8a}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x9c, 0xe4, 0xc2, 0x70, 0x50, 0x6f, 0xbd, 0x36, 0xff, 0x15, 0xf5, 0x2d, 0x97, 0xaa, 0x13, + 0x3b, 0xbf, 0xc4, 0x88, 0xf1, 0xbf, 0xff, 0x56, 0x92, 0x60, 0xfa, 0xb7, 0xea, 0x3e, 0x8a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1399, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\183\185o\230@UI=\142/\201\188\216sZ\ESC\b\"\182\202\NAKU$`\181\rE\194t\f", _pubPktID = 17758, _pubBody = +// "\251~\215\217\SOH\189L!\244\EM\212\246_\154\185\179.\187\EOTE\242\169", _pubProps = []} +TEST(Publish311QCTest, Encode81) { + uint8_t pkt[] = {0x33, 0x38, 0x0, 0x1e, 0xb7, 0xb9, 0x6f, 0xe6, 0x40, 0x55, 0x49, 0x3d, 0x8e, 0x2f, 0xc9, + 0xbc, 0xd8, 0x73, 0x5a, 0x1b, 0x8, 0x22, 0xb6, 0xca, 0x15, 0x55, 0x24, 0x60, 0xb5, 0xd, + 0x45, 0xc2, 0x74, 0xc, 0x45, 0x5e, 0xfb, 0x7e, 0xd7, 0xd9, 0x1, 0xbd, 0x4c, 0x21, 0xf4, + 0x19, 0xd4, 0xf6, 0x5f, 0x9a, 0xb9, 0xb3, 0x2e, 0xbb, 0x4, 0x45, 0xf2, 0xa9}; + + uint8_t buf[68] = {0}; + + uint8_t topic_bytes[] = {0xb7, 0xb9, 0x6f, 0xe6, 0x40, 0x55, 0x49, 0x3d, 0x8e, 0x2f, 0xc9, 0xbc, 0xd8, 0x73, 0x5a, + 0x1b, 0x8, 0x22, 0xb6, 0xca, 0x15, 0x55, 0x24, 0x60, 0xb5, 0xd, 0x45, 0xc2, 0x74, 0xc}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xfb, 0x7e, 0xd7, 0xd9, 0x1, 0xbd, 0x4c, 0x21, 0xf4, 0x19, 0xd4, + 0xf6, 0x5f, 0x9a, 0xb9, 0xb3, 0x2e, 0xbb, 0x4, 0x45, 0xf2, 0xa9}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17758, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "", _pubPktID = 3165, _pubBody = +// "\168'\DC2\253\238;d\144\231\186\152t\206\166", _pubProps = []} +TEST(Publish311QCTest, Encode82) { + uint8_t pkt[] = {0x3d, 0x12, 0x0, 0x0, 0xc, 0x5d, 0xa8, 0x27, 0x12, 0xfd, + 0xee, 0x3b, 0x64, 0x90, 0xe7, 0xba, 0x98, 0x74, 0xce, 0xa6}; + + uint8_t buf[30] = {0}; + + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa8, 0x27, 0x12, 0xfd, 0xee, 0x3b, 0x64, 0x90, 0xe7, 0xba, 0x98, 0x74, 0xce, 0xa6}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 3165, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\GS\DC2", _pubPktID = 7799, _pubBody +// = "\138\249b\fd \199\239\220\147\235\233\214\152\139\130Q\163v?ZrG\215\139\236\184\230y", _pubProps = []} +TEST(Publish311QCTest, Encode83) { + uint8_t pkt[] = {0x3a, 0x23, 0x0, 0x2, 0x1d, 0x12, 0x1e, 0x77, 0x8a, 0xf9, 0x62, 0xc, 0x64, + 0x20, 0xc7, 0xef, 0xdc, 0x93, 0xeb, 0xe9, 0xd6, 0x98, 0x8b, 0x82, 0x51, 0xa3, + 0x76, 0x3f, 0x5a, 0x72, 0x47, 0xd7, 0x8b, 0xec, 0xb8, 0xe6, 0x79}; + + uint8_t buf[47] = {0}; + + uint8_t topic_bytes[] = {0x1d, 0x12}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x8a, 0xf9, 0x62, 0xc, 0x64, 0x20, 0xc7, 0xef, 0xdc, 0x93, 0xeb, 0xe9, 0xd6, 0x98, 0x8b, + 0x82, 0x51, 0xa3, 0x76, 0x3f, 0x5a, 0x72, 0x47, 0xd7, 0x8b, 0xec, 0xb8, 0xe6, 0x79}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7799, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\208\187K.", _pubPktID = 29034, +// _pubBody = "\221\ACK\199\144\EOTv\ACK\217\\", _pubProps = []} +TEST(Publish311QCTest, Encode84) { + uint8_t pkt[] = {0x3b, 0x11, 0x0, 0x4, 0xd0, 0xbb, 0x4b, 0x2e, 0x71, 0x6a, + 0xdd, 0x6, 0xc7, 0x90, 0x4, 0x76, 0x6, 0xd9, 0x5c}; + + uint8_t buf[29] = {0}; + + uint8_t topic_bytes[] = {0xd0, 0xbb, 0x4b, 0x2e}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xdd, 0x6, 0xc7, 0x90, 0x4, 0x76, 0x6, 0xd9, 0x5c}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 9; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29034, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201y\171\155\184C", _pubPktID = 0, +// _pubBody = "\180\178\&2\194\SUB5Z\254\US\217\144\t:4a\154\203\201\ETX\DC3\246_[<\224", _pubProps = []} +TEST(Publish311QCTest, Encode85) { + uint8_t pkt[] = {0x38, 0x21, 0x0, 0x6, 0xc9, 0x79, 0xab, 0x9b, 0xb8, 0x43, 0xb4, 0xb2, + 0x32, 0xc2, 0x1a, 0x35, 0x5a, 0xfe, 0x1f, 0xd9, 0x90, 0x9, 0x3a, 0x34, + 0x61, 0x9a, 0xcb, 0xc9, 0x3, 0x13, 0xf6, 0x5f, 0x5b, 0x3c, 0xe0}; + + uint8_t buf[45] = {0}; + + uint8_t topic_bytes[] = {0xc9, 0x79, 0xab, 0x9b, 0xb8, 0x43}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xb4, 0xb2, 0x32, 0xc2, 0x1a, 0x35, 0x5a, 0xfe, 0x1f, 0xd9, 0x90, 0x9, 0x3a, + 0x34, 0x61, 0x9a, 0xcb, 0xc9, 0x3, 0x13, 0xf6, 0x5f, 0x5b, 0x3c, 0xe0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 25; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "}q\213-\168\195\252$\139j^\DC1o\198\RS\172\159q", _pubPktID = 8388, _pubBody = "\196\&7\f\aA\EOT", _pubProps = []} +TEST(Publish311QCTest, Encode86) { + uint8_t pkt[] = {0x32, 0x1c, 0x0, 0x12, 0x7d, 0x71, 0xd5, 0x2d, 0xa8, 0xc3, 0xfc, 0x24, 0x8b, 0x6a, 0x5e, + 0x11, 0x6f, 0xc6, 0x1e, 0xac, 0x9f, 0x71, 0x20, 0xc4, 0xc4, 0x37, 0xc, 0x7, 0x41, 0x4}; + + uint8_t buf[40] = {0}; + + uint8_t topic_bytes[] = {0x7d, 0x71, 0xd5, 0x2d, 0xa8, 0xc3, 0xfc, 0x24, 0x8b, + 0x6a, 0x5e, 0x11, 0x6f, 0xc6, 0x1e, 0xac, 0x9f, 0x71}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xc4, 0x37, 0xc, 0x7, 0x41, 0x4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 6; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8388, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\214\177\ETBL\143\b\216", _pubPktID +// = 466, _pubBody = "sz\183u\DC3:\199\242\216%\137\EM\a\203\242\209\144\194fR6\240\163&\200H", _pubProps = []} +TEST(Publish311QCTest, Encode87) { + uint8_t pkt[] = {0x34, 0x25, 0x0, 0x7, 0xd6, 0xb1, 0x17, 0x4c, 0x8f, 0x8, 0xd8, 0x1, 0xd2, + 0x73, 0x7a, 0xb7, 0x75, 0x13, 0x3a, 0xc7, 0xf2, 0xd8, 0x25, 0x89, 0x19, 0x7, + 0xcb, 0xf2, 0xd1, 0x90, 0xc2, 0x66, 0x52, 0x36, 0xf0, 0xa3, 0x26, 0xc8, 0x48}; + + uint8_t buf[49] = {0}; + + uint8_t topic_bytes[] = {0xd6, 0xb1, 0x17, 0x4c, 0x8f, 0x8, 0xd8}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x73, 0x7a, 0xb7, 0x75, 0x13, 0x3a, 0xc7, 0xf2, 0xd8, 0x25, 0x89, 0x19, 0x7, + 0xcb, 0xf2, 0xd1, 0x90, 0xc2, 0x66, 0x52, 0x36, 0xf0, 0xa3, 0x26, 0xc8, 0x48}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 466, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\STX\213\240cI\204T-w\154\192|#=\254P\DC24\200\170\228\NUL\186\147/\225\193\b\FS\140", _pubPktID = 26668, _pubBody = +// ".T\237(\238\DELg0 \GS\STX\215*\156\169t\147\b\206\149\172\r\211\RS\205 5\US\t0", _pubProps = []} +TEST(Publish311QCTest, Encode88) { + uint8_t pkt[] = {0x33, 0x40, 0x0, 0x1e, 0x2, 0xd5, 0xf0, 0x63, 0x49, 0xcc, 0x54, 0x2d, 0x77, 0x9a, 0xc0, 0x7c, 0x23, + 0x3d, 0xfe, 0x50, 0x12, 0x34, 0xc8, 0xaa, 0xe4, 0x0, 0xba, 0x93, 0x2f, 0xe1, 0xc1, 0x8, 0x1c, 0x8c, + 0x68, 0x2c, 0x2e, 0x54, 0xed, 0x28, 0xee, 0x7f, 0x67, 0x30, 0x20, 0x1d, 0x2, 0xd7, 0x2a, 0x9c, 0xa9, + 0x74, 0x93, 0x8, 0xce, 0x95, 0xac, 0xd, 0xd3, 0x1e, 0xcd, 0x20, 0x35, 0x1f, 0x9, 0x30}; + + uint8_t buf[76] = {0}; + + uint8_t topic_bytes[] = {0x2, 0xd5, 0xf0, 0x63, 0x49, 0xcc, 0x54, 0x2d, 0x77, 0x9a, 0xc0, 0x7c, 0x23, 0x3d, 0xfe, + 0x50, 0x12, 0x34, 0xc8, 0xaa, 0xe4, 0x0, 0xba, 0x93, 0x2f, 0xe1, 0xc1, 0x8, 0x1c, 0x8c}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x2e, 0x54, 0xed, 0x28, 0xee, 0x7f, 0x67, 0x30, 0x20, 0x1d, 0x2, 0xd7, 0x2a, 0x9c, 0xa9, + 0x74, 0x93, 0x8, 0xce, 0x95, 0xac, 0xd, 0xd3, 0x1e, 0xcd, 0x20, 0x35, 0x1f, 0x9, 0x30}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 26668, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\"X\209\155% +// \FS1[\178\SI\134\232\SI\236n\212\r\FS", _pubPktID = 0, _pubBody = +// "`\190\143p\n\134\145\250\152\151,\233\245\224\143\FS\235_/\133\203", _pubProps = []} +TEST(Publish311QCTest, Encode89) { + uint8_t pkt[] = {0x39, 0x2a, 0x0, 0x13, 0x22, 0x58, 0xd1, 0x9b, 0x25, 0x20, 0x1c, 0x31, 0x5b, 0xb2, 0xf, + 0x86, 0xe8, 0xf, 0xec, 0x6e, 0xd4, 0xd, 0x1c, 0x60, 0xbe, 0x8f, 0x70, 0xa, 0x86, 0x91, + 0xfa, 0x98, 0x97, 0x2c, 0xe9, 0xf5, 0xe0, 0x8f, 0x1c, 0xeb, 0x5f, 0x2f, 0x85, 0xcb}; + + uint8_t buf[54] = {0}; + + uint8_t topic_bytes[] = {0x22, 0x58, 0xd1, 0x9b, 0x25, 0x20, 0x1c, 0x31, 0x5b, 0xb2, + 0xf, 0x86, 0xe8, 0xf, 0xec, 0x6e, 0xd4, 0xd, 0x1c}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x60, 0xbe, 0x8f, 0x70, 0xa, 0x86, 0x91, 0xfa, 0x98, 0x97, 0x2c, + 0xe9, 0xf5, 0xe0, 0x8f, 0x1c, 0xeb, 0x5f, 0x2f, 0x85, 0xcb}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 21; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\175\195\208b[q\226\128\DC4'", +// _pubPktID = 14979, _pubBody = "\US", _pubProps = []} +TEST(Publish311QCTest, Encode90) { + uint8_t pkt[] = {0x3c, 0xf, 0x0, 0xa, 0xaf, 0xc3, 0xd0, 0x62, 0x5b, 0x71, 0xe2, 0x80, 0x14, 0x27, 0x3a, 0x83, 0x1f}; + + uint8_t buf[27] = {0}; + + uint8_t topic_bytes[] = {0xaf, 0xc3, 0xd0, 0x62, 0x5b, 0x71, 0xe2, 0x80, 0x14, 0x27}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x1f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 14979, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\141\253\128M\210\215vFY\193c\236\174\r\155\SYN\\y", _pubPktID = 16476, _pubBody = "\DEL\250\&0\179-", _pubProps = +// []} +TEST(Publish311QCTest, Encode91) { + uint8_t pkt[] = {0x3b, 0x1b, 0x0, 0x12, 0x8d, 0xfd, 0x80, 0x4d, 0xd2, 0xd7, 0x76, 0x46, 0x59, 0xc1, 0x63, + 0xec, 0xae, 0xd, 0x9b, 0x16, 0x5c, 0x79, 0x40, 0x5c, 0x7f, 0xfa, 0x30, 0xb3, 0x2d}; + + uint8_t buf[39] = {0}; + + uint8_t topic_bytes[] = {0x8d, 0xfd, 0x80, 0x4d, 0xd2, 0xd7, 0x76, 0x46, 0x59, + 0xc1, 0x63, 0xec, 0xae, 0xd, 0x9b, 0x16, 0x5c, 0x79}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x7f, 0xfa, 0x30, 0xb3, 0x2d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 5; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16476, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\172\236 +// #(l]\NAK\197K\GS\156j\151\195\144\235C\\\137\199*\177", _pubPktID = 24115, _pubBody = "\138", _pubProps = []} +TEST(Publish311QCTest, Encode92) { + uint8_t pkt[] = {0x3a, 0x1c, 0x0, 0x17, 0xac, 0xec, 0x20, 0x23, 0x28, 0x6c, 0x5d, 0x15, 0xc5, 0x4b, 0x1d, + 0x9c, 0x6a, 0x97, 0xc3, 0x90, 0xeb, 0x43, 0x5c, 0x89, 0xc7, 0x2a, 0xb1, 0x5e, 0x33, 0x8a}; + + uint8_t buf[40] = {0}; + + uint8_t topic_bytes[] = {0xac, 0xec, 0x20, 0x23, 0x28, 0x6c, 0x5d, 0x15, 0xc5, 0x4b, 0x1d, 0x9c, + 0x6a, 0x97, 0xc3, 0x90, 0xeb, 0x43, 0x5c, 0x89, 0xc7, 0x2a, 0xb1}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x8a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 24115, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\SUB\250\FSj@\239n\DEL\t\158:\132\165\249\130\226L", _pubPktID = 159, _pubBody = +// "\131\140\143\172oD6\SIS\196O.\145\141\166\EOT\188\153\251U\SYNJT", _pubProps = []} +TEST(Publish311QCTest, Encode93) { + uint8_t pkt[] = {0x3d, 0x2c, 0x0, 0x11, 0x1a, 0xfa, 0x1c, 0x6a, 0x40, 0xef, 0x6e, 0x7f, 0x9, 0x9e, 0x3a, 0x84, + 0xa5, 0xf9, 0x82, 0xe2, 0x4c, 0x0, 0x9f, 0x83, 0x8c, 0x8f, 0xac, 0x6f, 0x44, 0x36, 0xf, 0x53, + 0xc4, 0x4f, 0x2e, 0x91, 0x8d, 0xa6, 0x4, 0xbc, 0x99, 0xfb, 0x55, 0x16, 0x4a, 0x54}; + + uint8_t buf[56] = {0}; + + uint8_t topic_bytes[] = {0x1a, 0xfa, 0x1c, 0x6a, 0x40, 0xef, 0x6e, 0x7f, 0x9, + 0x9e, 0x3a, 0x84, 0xa5, 0xf9, 0x82, 0xe2, 0x4c}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x83, 0x8c, 0x8f, 0xac, 0x6f, 0x44, 0x36, 0xf, 0x53, 0xc4, 0x4f, 0x2e, + 0x91, 0x8d, 0xa6, 0x4, 0xbc, 0x99, 0xfb, 0x55, 0x16, 0x4a, 0x54}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 23; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 159, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\192K\248\134\174}\198-\171\235\SUB\214]\204\&3\177\f", _pubPktID = 0, _pubBody = +// "%\131\215\218\147\225\ENQ\173Wh\129\234\197", _pubProps = []} +TEST(Publish311QCTest, Encode94) { + uint8_t pkt[] = {0x38, 0x20, 0x0, 0x11, 0xc0, 0x4b, 0xf8, 0x86, 0xae, 0x7d, 0xc6, 0x2d, + 0xab, 0xeb, 0x1a, 0xd6, 0x5d, 0xcc, 0x33, 0xb1, 0xc, 0x25, 0x83, 0xd7, + 0xda, 0x93, 0xe1, 0x5, 0xad, 0x57, 0x68, 0x81, 0xea, 0xc5}; + + uint8_t buf[44] = {0}; + + uint8_t topic_bytes[] = {0xc0, 0x4b, 0xf8, 0x86, 0xae, 0x7d, 0xc6, 0x2d, 0xab, + 0xeb, 0x1a, 0xd6, 0x5d, 0xcc, 0x33, 0xb1, 0xc}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x25, 0x83, 0xd7, 0xda, 0x93, 0xe1, 0x5, 0xad, 0x57, 0x68, 0x81, 0xea, 0xc5}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\161&K\GSu\164\DC1W\156\205\DC2e\US\253\SUB\212\GS\146u", _pubPktID = 4938, _pubBody = +// "\197\210\201\164\236`\GSJjyh\252c\GS\185\190\150xY\239>\220\165.", _pubProps = []} +TEST(Publish311QCTest, Encode95) { + uint8_t pkt[] = {0x3a, 0x2f, 0x0, 0x13, 0xa1, 0x26, 0x4b, 0x1d, 0x75, 0xa4, 0x11, 0x57, 0x9c, 0xcd, 0x12, 0x65, 0x1f, + 0xfd, 0x1a, 0xd4, 0x1d, 0x92, 0x75, 0x13, 0x4a, 0xc5, 0xd2, 0xc9, 0xa4, 0xec, 0x60, 0x1d, 0x4a, 0x6a, + 0x79, 0x68, 0xfc, 0x63, 0x1d, 0xb9, 0xbe, 0x96, 0x78, 0x59, 0xef, 0x3e, 0xdc, 0xa5, 0x2e}; + + uint8_t buf[59] = {0}; + + uint8_t topic_bytes[] = {0xa1, 0x26, 0x4b, 0x1d, 0x75, 0xa4, 0x11, 0x57, 0x9c, 0xcd, + 0x12, 0x65, 0x1f, 0xfd, 0x1a, 0xd4, 0x1d, 0x92, 0x75}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xc5, 0xd2, 0xc9, 0xa4, 0xec, 0x60, 0x1d, 0x4a, 0x6a, 0x79, 0x68, 0xfc, + 0x63, 0x1d, 0xb9, 0xbe, 0x96, 0x78, 0x59, 0xef, 0x3e, 0xdc, 0xa5, 0x2e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 4938, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\149\203\181S\"+\168\160\141\DEL~e8\150\193\SYN\t1", _pubPktID = 0, _pubBody = "m#Za\252\192\201Y\NAK\221", +// _pubProps = []} +TEST(Publish311QCTest, Encode96) { + uint8_t pkt[] = {0x38, 0x1e, 0x0, 0x12, 0x95, 0xcb, 0xb5, 0x53, 0x22, 0x2b, 0xa8, 0xa0, 0x8d, 0x7f, 0x7e, 0x65, + 0x38, 0x96, 0xc1, 0x16, 0x9, 0x31, 0x6d, 0x23, 0x5a, 0x61, 0xfc, 0xc0, 0xc9, 0x59, 0x15, 0xdd}; + + uint8_t buf[42] = {0}; + + uint8_t topic_bytes[] = {0x95, 0xcb, 0xb5, 0x53, 0x22, 0x2b, 0xa8, 0xa0, 0x8d, + 0x7f, 0x7e, 0x65, 0x38, 0x96, 0xc1, 0x16, 0x9, 0x31}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x6d, 0x23, 0x5a, 0x61, 0xfc, 0xc0, 0xc9, 0x59, 0x15, 0xdd}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 10; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\254\DLE\200m\251\190\157\139\&9=\175\219\238~:ap/{\148", _pubPktID = 0, _pubBody = "\163~rt", _pubProps = []} +TEST(Publish311QCTest, Encode97) { + uint8_t pkt[] = {0x38, 0x1a, 0x0, 0x14, 0xfe, 0x10, 0xc8, 0x6d, 0xfb, 0xbe, 0x9d, 0x8b, 0x39, 0x3d, + 0xaf, 0xdb, 0xee, 0x7e, 0x3a, 0x61, 0x70, 0x2f, 0x7b, 0x94, 0xa3, 0x7e, 0x72, 0x74}; + + uint8_t buf[38] = {0}; + + uint8_t topic_bytes[] = {0xfe, 0x10, 0xc8, 0x6d, 0xfb, 0xbe, 0x9d, 0x8b, 0x39, 0x3d, + 0xaf, 0xdb, 0xee, 0x7e, 0x3a, 0x61, 0x70, 0x2f, 0x7b, 0x94}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xa3, 0x7e, 0x72, 0x74}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\253a\DC4gD\189tvCr\177\&0w\132", +// _pubPktID = 26, _pubBody = "\188\SOx\169\171\214_\225\142.\SIW\SO\149\GS\184M\199\137\174\128cS\187OBD\139\218", +// _pubProps = []} +TEST(Publish311QCTest, Encode98) { + uint8_t pkt[] = {0x3a, 0x2f, 0x0, 0xe, 0xfd, 0x61, 0x14, 0x67, 0x44, 0xbd, 0x74, 0x76, 0x43, 0x72, 0xb1, 0x30, 0x77, + 0x84, 0x0, 0x1a, 0xbc, 0xe, 0x78, 0xa9, 0xab, 0xd6, 0x5f, 0xe1, 0x8e, 0x2e, 0xf, 0x57, 0xe, 0x95, + 0x1d, 0xb8, 0x4d, 0xc7, 0x89, 0xae, 0x80, 0x63, 0x53, 0xbb, 0x4f, 0x42, 0x44, 0x8b, 0xda}; + + uint8_t buf[59] = {0}; + + uint8_t topic_bytes[] = {0xfd, 0x61, 0x14, 0x67, 0x44, 0xbd, 0x74, 0x76, 0x43, 0x72, 0xb1, 0x30, 0x77, 0x84}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xbc, 0xe, 0x78, 0xa9, 0xab, 0xd6, 0x5f, 0xe1, 0x8e, 0x2e, 0xf, 0x57, 0xe, 0x95, 0x1d, + 0xb8, 0x4d, 0xc7, 0x89, 0xae, 0x80, 0x63, 0x53, 0xbb, 0x4f, 0x42, 0x44, 0x8b, 0xda}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 26, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\251\169\245\241\201;\SOH\174B\v\STX\SOH\202\137\ETX\139y\235\139\&8~b&\235", _pubPktID = 0, _pubBody = +// "O\222\143\SO\DC2\DC2\180\DC3\242\226I\151\ACKv\247\150\v\DC4\228", _pubProps = []} +TEST(Publish311QCTest, Encode99) { + uint8_t pkt[] = {0x39, 0x2d, 0x0, 0x18, 0xfb, 0xa9, 0xf5, 0xf1, 0xc9, 0x3b, 0x1, 0xae, 0x42, 0xb, 0x2, 0x1, + 0xca, 0x89, 0x3, 0x8b, 0x79, 0xeb, 0x8b, 0x38, 0x7e, 0x62, 0x26, 0xeb, 0x4f, 0xde, 0x8f, 0xe, + 0x12, 0x12, 0xb4, 0x13, 0xf2, 0xe2, 0x49, 0x97, 0x6, 0x76, 0xf7, 0x96, 0xb, 0x14, 0xe4}; + + uint8_t buf[57] = {0}; + + uint8_t topic_bytes[] = {0xfb, 0xa9, 0xf5, 0xf1, 0xc9, 0x3b, 0x1, 0xae, 0x42, 0xb, 0x2, 0x1, + 0xca, 0x89, 0x3, 0x8b, 0x79, 0xeb, 0x8b, 0x38, 0x7e, 0x62, 0x26, 0xeb}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x4f, 0xde, 0x8f, 0xe, 0x12, 0x12, 0xb4, 0x13, 0xf2, 0xe2, + 0x49, 0x97, 0x6, 0x76, 0xf7, 0x96, 0xb, 0x14, 0xe4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 19; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\130\195\DC3\129^;\DC2\222\159\233g\190\156\&9\DC2\149t\138<\191|", _pubPktID = 0, _pubBody = +// "\145m\248\188\208:\172\v\129\EOT\158\139\132\192yQ\206S\252\152\ETBQrEx\t\ENQ^\235\139", _pubProps = []} +TEST(Publish311QCTest, Encode100) { + uint8_t pkt[] = {0x30, 0x35, 0x0, 0x15, 0x82, 0xc3, 0x13, 0x81, 0x5e, 0x3b, 0x12, 0xde, 0x9f, 0xe9, + 0x67, 0xbe, 0x9c, 0x39, 0x12, 0x95, 0x74, 0x8a, 0x3c, 0xbf, 0x7c, 0x91, 0x6d, 0xf8, + 0xbc, 0xd0, 0x3a, 0xac, 0xb, 0x81, 0x4, 0x9e, 0x8b, 0x84, 0xc0, 0x79, 0x51, 0xce, + 0x53, 0xfc, 0x98, 0x17, 0x51, 0x72, 0x45, 0x78, 0x9, 0x5, 0x5e, 0xeb, 0x8b}; + + uint8_t buf[65] = {0}; + + uint8_t topic_bytes[] = {0x82, 0xc3, 0x13, 0x81, 0x5e, 0x3b, 0x12, 0xde, 0x9f, 0xe9, 0x67, + 0xbe, 0x9c, 0x39, 0x12, 0x95, 0x74, 0x8a, 0x3c, 0xbf, 0x7c}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x91, 0x6d, 0xf8, 0xbc, 0xd0, 0x3a, 0xac, 0xb, 0x81, 0x4, 0x9e, 0x8b, 0x84, 0xc0, 0x79, + 0x51, 0xce, 0x53, 0xfc, 0x98, 0x17, 0x51, 0x72, 0x45, 0x78, 0x9, 0x5, 0x5e, 0xeb, 0x8b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\136Y\192\226{\129\199E\USu\182\215\SUB'\245\DC4\171\139\NAKY", _pubPktID = 15774, _pubBody = "\255", _pubProps = +// [PropServerReference "*\172\"2WGRO\157\160<\211\203yR]\221\FS\167\DLE.\140\167U\132",PropServerReference +// "\NAK5\205\240!\219\r\254\f\198W\RS~\224\RSA",PropContentType +// "3\180K\SUB\225\135\158\b\137\130\239",PropServerReference "\133",PropWildcardSubscriptionAvailable +// 28,PropServerReference "&\t\"\195\v\139\254\232\232Q&X\202\192\196",PropCorrelationData "\187A",PropResponseTopic +// "\171\SUB\CAN\EM1\162\189\254uYT\233A\136'\195\195\v;\138t\194\148\153\nZw\189",PropMaximumPacketSize +// 20297,PropMessageExpiryInterval 28350,PropMessageExpiryInterval 1786,PropContentType +// "\173\235}$\DC4\222\167z\DC3\RS;k\180\ETB=\v2e\229$:t\b\243\243",PropServerKeepAlive 24429,PropWillDelayInterval +// 14881,PropServerKeepAlive 4484,PropRequestProblemInformation 52,PropCorrelationData +// "^\239",PropRequestResponseInformation 213,PropReasonString "\179nh28W",PropSessionExpiryInterval +// 12170,PropResponseTopic "\231\217\178\SYN",PropSessionExpiryInterval 28653,PropMessageExpiryInterval +// 23984,PropMessageExpiryInterval 23557,PropContentType "az\SUB\143\135hS\140Wx5m\SI\210\234?dR",PropRetainAvailable +// 216,PropSubscriptionIdentifier 9,PropWildcardSubscriptionAvailable 35]} +TEST(Publish50QCTest, Encode1) { + uint8_t pkt[] = { + 0x32, 0x92, 0x2, 0x0, 0x14, 0x88, 0x59, 0xc0, 0xe2, 0x7b, 0x81, 0xc7, 0x45, 0x1f, 0x75, 0xb6, 0xd7, 0x1a, 0x27, + 0xf5, 0x14, 0xab, 0x8b, 0x15, 0x59, 0x3d, 0x9e, 0xf7, 0x1, 0x1c, 0x0, 0x19, 0x2a, 0xac, 0x22, 0x32, 0x57, 0x47, + 0x52, 0x4f, 0x9d, 0xa0, 0x3c, 0xd3, 0xcb, 0x79, 0x52, 0x5d, 0xdd, 0x1c, 0xa7, 0x10, 0x2e, 0x8c, 0xa7, 0x55, 0x84, + 0x1c, 0x0, 0x10, 0x15, 0x35, 0xcd, 0xf0, 0x21, 0xdb, 0xd, 0xfe, 0xc, 0xc6, 0x57, 0x1e, 0x7e, 0xe0, 0x1e, 0x41, + 0x3, 0x0, 0xb, 0x33, 0xb4, 0x4b, 0x1a, 0xe1, 0x87, 0x9e, 0x8, 0x89, 0x82, 0xef, 0x1c, 0x0, 0x1, 0x85, 0x28, + 0x1c, 0x1c, 0x0, 0xf, 0x26, 0x9, 0x22, 0xc3, 0xb, 0x8b, 0xfe, 0xe8, 0xe8, 0x51, 0x26, 0x58, 0xca, 0xc0, 0xc4, + 0x9, 0x0, 0x2, 0xbb, 0x41, 0x8, 0x0, 0x1c, 0xab, 0x1a, 0x18, 0x19, 0x31, 0xa2, 0xbd, 0xfe, 0x75, 0x59, 0x54, + 0xe9, 0x41, 0x88, 0x27, 0xc3, 0xc3, 0xb, 0x3b, 0x8a, 0x74, 0xc2, 0x94, 0x99, 0xa, 0x5a, 0x77, 0xbd, 0x27, 0x0, + 0x0, 0x4f, 0x49, 0x2, 0x0, 0x0, 0x6e, 0xbe, 0x2, 0x0, 0x0, 0x6, 0xfa, 0x3, 0x0, 0x19, 0xad, 0xeb, 0x7d, + 0x24, 0x14, 0xde, 0xa7, 0x7a, 0x13, 0x1e, 0x3b, 0x6b, 0xb4, 0x17, 0x3d, 0xb, 0x32, 0x65, 0xe5, 0x24, 0x3a, 0x74, + 0x8, 0xf3, 0xf3, 0x13, 0x5f, 0x6d, 0x18, 0x0, 0x0, 0x3a, 0x21, 0x13, 0x11, 0x84, 0x17, 0x34, 0x9, 0x0, 0x2, + 0x5e, 0xef, 0x19, 0xd5, 0x1f, 0x0, 0x6, 0xb3, 0x6e, 0x68, 0x32, 0x38, 0x57, 0x11, 0x0, 0x0, 0x2f, 0x8a, 0x8, + 0x0, 0x4, 0xe7, 0xd9, 0xb2, 0x16, 0x11, 0x0, 0x0, 0x6f, 0xed, 0x2, 0x0, 0x0, 0x5d, 0xb0, 0x2, 0x0, 0x0, + 0x5c, 0x5, 0x3, 0x0, 0x12, 0x61, 0x7a, 0x1a, 0x8f, 0x87, 0x68, 0x53, 0x8c, 0x57, 0x78, 0x35, 0x6d, 0xf, 0xd2, + 0xea, 0x3f, 0x64, 0x52, 0x25, 0xd8, 0xb, 0x9, 0x28, 0x23, 0xff}; + + uint8_t buf[287] = {0}; + + uint8_t topic_bytes[] = {0x88, 0x59, 0xc0, 0xe2, 0x7b, 0x81, 0xc7, 0x45, 0x1f, 0x75, + 0xb6, 0xd7, 0x1a, 0x27, 0xf5, 0x14, 0xab, 0x8b, 0x15, 0x59}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xff}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + uint8_t bytes0[] = {0x2a, 0xac, 0x22, 0x32, 0x57, 0x47, 0x52, 0x4f, 0x9d, 0xa0, 0x3c, 0xd3, 0xcb, + 0x79, 0x52, 0x5d, 0xdd, 0x1c, 0xa7, 0x10, 0x2e, 0x8c, 0xa7, 0x55, 0x84}; + uint8_t bytes1[] = {0x15, 0x35, 0xcd, 0xf0, 0x21, 0xdb, 0xd, 0xfe, 0xc, 0xc6, 0x57, 0x1e, 0x7e, 0xe0, 0x1e, 0x41}; + uint8_t bytes2[] = {0x33, 0xb4, 0x4b, 0x1a, 0xe1, 0x87, 0x9e, 0x8, 0x89, 0x82, 0xef}; + uint8_t bytes3[] = {0x85}; + uint8_t bytes4[] = {0x26, 0x9, 0x22, 0xc3, 0xb, 0x8b, 0xfe, 0xe8, 0xe8, 0x51, 0x26, 0x58, 0xca, 0xc0, 0xc4}; + uint8_t bytes5[] = {0xbb, 0x41}; + uint8_t bytes6[] = {0xab, 0x1a, 0x18, 0x19, 0x31, 0xa2, 0xbd, 0xfe, 0x75, 0x59, 0x54, 0xe9, 0x41, 0x88, + 0x27, 0xc3, 0xc3, 0xb, 0x3b, 0x8a, 0x74, 0xc2, 0x94, 0x99, 0xa, 0x5a, 0x77, 0xbd}; + uint8_t bytes7[] = {0xad, 0xeb, 0x7d, 0x24, 0x14, 0xde, 0xa7, 0x7a, 0x13, 0x1e, 0x3b, 0x6b, 0xb4, + 0x17, 0x3d, 0xb, 0x32, 0x65, 0xe5, 0x24, 0x3a, 0x74, 0x8, 0xf3, 0xf3}; + uint8_t bytes8[] = {0x5e, 0xef}; + uint8_t bytes9[] = {0xb3, 0x6e, 0x68, 0x32, 0x38, 0x57}; + uint8_t bytes10[] = {0xe7, 0xd9, 0xb2, 0x16}; + uint8_t bytes11[] = {0x61, 0x7a, 0x1a, 0x8f, 0x87, 0x68, 0x53, 0x8c, 0x57, + 0x78, 0x35, 0x6d, 0xf, 0xd2, 0xea, 0x3f, 0x64, 0x52}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20297}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28350}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1786}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24429}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14881}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4484}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytes8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytes9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12170}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytes10}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28653}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23984}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23557}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytes11}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, + }; + + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15774, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129/gG\151\&6y\225\246\193\230", +// _pubPktID = 31160, _pubBody = "\243\207\138\211\213\183N\154\SOafk\220\SUBT", _pubProps = [PropWillDelayInterval +// 165,PropSubscriptionIdentifier 2,PropSubscriptionIdentifierAvailable 145,PropContentType +// "\168\f\245\DLE\253p\136\145\148\ETX6\DELk\198vc\163S\238\230\202!"]} +TEST(Publish50QCTest, Encode2) { + uint8_t pkt[] = {0x3d, 0x41, 0x0, 0xb, 0x81, 0x2f, 0x67, 0x47, 0x97, 0x36, 0x79, 0xe1, 0xf6, 0xc1, 0xe6, 0x79, 0xb8, + 0x22, 0x18, 0x0, 0x0, 0x0, 0xa5, 0xb, 0x2, 0x29, 0x91, 0x3, 0x0, 0x16, 0xa8, 0xc, 0xf5, 0x10, + 0xfd, 0x70, 0x88, 0x91, 0x94, 0x3, 0x36, 0x7f, 0x6b, 0xc6, 0x76, 0x63, 0xa3, 0x53, 0xee, 0xe6, 0xca, + 0x21, 0xf3, 0xcf, 0x8a, 0xd3, 0xd5, 0xb7, 0x4e, 0x9a, 0xe, 0x61, 0x66, 0x6b, 0xdc, 0x1a, 0x54}; + + uint8_t buf[77] = {0}; + + uint8_t topic_bytes[] = {0x81, 0x2f, 0x67, 0x47, 0x97, 0x36, 0x79, 0xe1, 0xf6, 0xc1, 0xe6}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xf3, 0xcf, 0x8a, 0xd3, 0xd5, 0xb7, 0x4e, 0x9a, 0xe, 0x61, 0x66, 0x6b, 0xdc, 0x1a, 0x54}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 15; + + uint8_t bytes0[] = {0xa8, 0xc, 0xf5, 0x10, 0xfd, 0x70, 0x88, 0x91, 0x94, 0x3, 0x36, + 0x7f, 0x6b, 0xc6, 0x76, 0x63, 0xa3, 0x53, 0xee, 0xe6, 0xca, 0x21}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 165}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytes0}}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 31160, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\173\FS\174\250\f\SYN6\ENQ\218i\199\ETB\213\180 \FS%", _pubPktID = 27531, _pubBody = "\129\232\a\215w\236", +// _pubProps = [PropMessageExpiryInterval 2064,PropAuthenticationMethod +// "5\187MR\NAK#d\135\207",PropSubscriptionIdentifier 13,PropContentType +// "\198\154%(@\179\250\203\246\134\193\194\213@N3\243'\149\DC1\128\163I]\194\138\157{\224",PropSubscriptionIdentifierAvailable +// 172,PropTopicAlias 6079,PropRequestProblemInformation 202,PropWildcardSubscriptionAvailable +// 85,PropSubscriptionIdentifierAvailable 226,PropReasonString "Y\243\204\GS-\161\139n\133",PropSubscriptionIdentifier +// 25,PropSharedSubscriptionAvailable 135,PropTopicAlias 32178,PropMessageExpiryInterval 9754,PropReceiveMaximum +// 27507,PropSubscriptionIdentifierAvailable 136,PropCorrelationData "'Dg",PropMaximumPacketSize 32580,PropContentType +// "\133D\195\150\250#\211ujub\229.P\214`\159ao\154\167.A[\174\132\155P"]} +TEST(Publish50QCTest, Encode3) { + uint8_t pkt[] = {0x35, 0xa2, 0x1, 0x0, 0x11, 0xad, 0x1c, 0xae, 0xfa, 0xc, 0x16, 0x36, 0x5, 0xda, 0x69, 0xc7, 0x17, + 0xd5, 0xb4, 0x20, 0x1c, 0x25, 0x6b, 0x8b, 0x85, 0x1, 0x2, 0x0, 0x0, 0x8, 0x10, 0x15, 0x0, 0x9, + 0x35, 0xbb, 0x4d, 0x52, 0x15, 0x23, 0x64, 0x87, 0xcf, 0xb, 0xd, 0x3, 0x0, 0x1d, 0xc6, 0x9a, 0x25, + 0x28, 0x40, 0xb3, 0xfa, 0xcb, 0xf6, 0x86, 0xc1, 0xc2, 0xd5, 0x40, 0x4e, 0x33, 0xf3, 0x27, 0x95, 0x11, + 0x80, 0xa3, 0x49, 0x5d, 0xc2, 0x8a, 0x9d, 0x7b, 0xe0, 0x29, 0xac, 0x23, 0x17, 0xbf, 0x17, 0xca, 0x28, + 0x55, 0x29, 0xe2, 0x1f, 0x0, 0x9, 0x59, 0xf3, 0xcc, 0x1d, 0x2d, 0xa1, 0x8b, 0x6e, 0x85, 0xb, 0x19, + 0x2a, 0x87, 0x23, 0x7d, 0xb2, 0x2, 0x0, 0x0, 0x26, 0x1a, 0x21, 0x6b, 0x73, 0x29, 0x88, 0x9, 0x0, + 0x3, 0x27, 0x44, 0x67, 0x27, 0x0, 0x0, 0x7f, 0x44, 0x3, 0x0, 0x1c, 0x85, 0x44, 0xc3, 0x96, 0xfa, + 0x23, 0xd3, 0x75, 0x6a, 0x75, 0x62, 0xe5, 0x2e, 0x50, 0xd6, 0x60, 0x9f, 0x61, 0x6f, 0x9a, 0xa7, 0x2e, + 0x41, 0x5b, 0xae, 0x84, 0x9b, 0x50, 0x81, 0xe8, 0x7, 0xd7, 0x77, 0xec}; + + uint8_t buf[175] = {0}; + + uint8_t topic_bytes[] = {0xad, 0x1c, 0xae, 0xfa, 0xc, 0x16, 0x36, 0x5, 0xda, + 0x69, 0xc7, 0x17, 0xd5, 0xb4, 0x20, 0x1c, 0x25}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x81, 0xe8, 0x7, 0xd7, 0x77, 0xec}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 6; + + uint8_t bytes0[] = {0x35, 0xbb, 0x4d, 0x52, 0x15, 0x23, 0x64, 0x87, 0xcf}; + uint8_t bytes1[] = {0xc6, 0x9a, 0x25, 0x28, 0x40, 0xb3, 0xfa, 0xcb, 0xf6, 0x86, 0xc1, 0xc2, 0xd5, 0x40, 0x4e, + 0x33, 0xf3, 0x27, 0x95, 0x11, 0x80, 0xa3, 0x49, 0x5d, 0xc2, 0x8a, 0x9d, 0x7b, 0xe0}; + uint8_t bytes2[] = {0x59, 0xf3, 0xcc, 0x1d, 0x2d, 0xa1, 0x8b, 0x6e, 0x85}; + uint8_t bytes3[] = {0x27, 0x44, 0x67}; + uint8_t bytes4[] = {0x85, 0x44, 0xc3, 0x96, 0xfa, 0x23, 0xd3, 0x75, 0x6a, 0x75, 0x62, 0xe5, 0x2e, 0x50, + 0xd6, 0x60, 0x9f, 0x61, 0x6f, 0x9a, 0xa7, 0x2e, 0x41, 0x5b, 0xae, 0x84, 0x9b, 0x50}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2064}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6079}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32178}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9754}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27507}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32580}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytes4}}}, + }; + + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 27531, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "y\135\f\ESC\175I\RS=", _pubPktID = +// 3010, _pubBody = "\198L\248\190/9\218\229\251^", _pubProps = [PropSubscriptionIdentifier 28,PropMessageExpiryInterval +// 27639,PropRequestResponseInformation 179]} +TEST(Publish50QCTest, Encode4) { + uint8_t pkt[] = {0x35, 0x20, 0x0, 0x8, 0x79, 0x87, 0xc, 0x1b, 0xaf, 0x49, 0x1e, 0x3d, 0xb, 0xc2, 0x9, 0xb, 0x1c, + 0x2, 0x0, 0x0, 0x6b, 0xf7, 0x19, 0xb3, 0xc6, 0x4c, 0xf8, 0xbe, 0x2f, 0x39, 0xda, 0xe5, 0xfb, 0x5e}; + + uint8_t buf[44] = {0}; + + uint8_t topic_bytes[] = {0x79, 0x87, 0xc, 0x1b, 0xaf, 0x49, 0x1e, 0x3d}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xc6, 0x4c, 0xf8, 0xbe, 0x2f, 0x39, 0xda, 0xe5, 0xfb, 0x5e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 10; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27639}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 179}}, + }; + + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 3010, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\fQ\131\202\NAK\EOTT\204\226\174\189\&72w\136\ETX\142I\166)\137*", _pubPktID = 0, _pubBody = "\148\134\189", +// _pubProps = [PropMaximumQoS 95,PropWillDelayInterval 12953,PropSharedSubscriptionAvailable +// 83,PropRequestResponseInformation 165,PropMaximumQoS 203,PropSubscriptionIdentifier 18,PropMessageExpiryInterval +// 22843,PropWildcardSubscriptionAvailable 157,PropAuthenticationMethod "\244\241\213d\201\142\169J\236\165\229 +// \246\133\177\ETX\248\186\174\241e\206\143\143i",PropTopicAlias 24582,PropRequestProblemInformation +// 126,PropWildcardSubscriptionAvailable 45,PropMessageExpiryInterval 2657,PropUserProperty +// "G\207%\tjz\CAN\162O\194\246-\139*O\ta4" "\135\215$\DELp\142B?",PropPayloadFormatIndicator 185,PropTopicAliasMaximum +// 18503,PropAuthenticationMethod "\241!^\f\199\172\144\199\208"]} +TEST(Publish50QCTest, Encode5) { + uint8_t pkt[] = {0x30, 0x8a, 0x1, 0x0, 0x16, 0xc, 0x51, 0x83, 0xca, 0x15, 0x4, 0x54, 0xcc, 0xe2, 0xae, 0xbd, + 0x37, 0x32, 0x77, 0x88, 0x3, 0x8e, 0x49, 0xa6, 0x29, 0x89, 0x2a, 0x6e, 0x24, 0x5f, 0x18, 0x0, + 0x0, 0x32, 0x99, 0x2a, 0x53, 0x19, 0xa5, 0x24, 0xcb, 0xb, 0x12, 0x2, 0x0, 0x0, 0x59, 0x3b, + 0x28, 0x9d, 0x15, 0x0, 0x19, 0xf4, 0xf1, 0xd5, 0x64, 0xc9, 0x8e, 0xa9, 0x4a, 0xec, 0xa5, 0xe5, + 0x20, 0xf6, 0x85, 0xb1, 0x3, 0xf8, 0xba, 0xae, 0xf1, 0x65, 0xce, 0x8f, 0x8f, 0x69, 0x23, 0x60, + 0x6, 0x17, 0x7e, 0x28, 0x2d, 0x2, 0x0, 0x0, 0xa, 0x61, 0x26, 0x0, 0x12, 0x47, 0xcf, 0x25, + 0x9, 0x6a, 0x7a, 0x18, 0xa2, 0x4f, 0xc2, 0xf6, 0x2d, 0x8b, 0x2a, 0x4f, 0x9, 0x61, 0x34, 0x0, + 0x8, 0x87, 0xd7, 0x24, 0x7f, 0x70, 0x8e, 0x42, 0x3f, 0x1, 0xb9, 0x22, 0x48, 0x47, 0x15, 0x0, + 0x9, 0xf1, 0x21, 0x5e, 0xc, 0xc7, 0xac, 0x90, 0xc7, 0xd0, 0x94, 0x86, 0xbd}; + + uint8_t buf[151] = {0}; + + uint8_t topic_bytes[] = {0xc, 0x51, 0x83, 0xca, 0x15, 0x4, 0x54, 0xcc, 0xe2, 0xae, 0xbd, + 0x37, 0x32, 0x77, 0x88, 0x3, 0x8e, 0x49, 0xa6, 0x29, 0x89, 0x2a}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x94, 0x86, 0xbd}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; + + uint8_t bytes0[] = {0xf4, 0xf1, 0xd5, 0x64, 0xc9, 0x8e, 0xa9, 0x4a, 0xec, 0xa5, 0xe5, 0x20, 0xf6, + 0x85, 0xb1, 0x3, 0xf8, 0xba, 0xae, 0xf1, 0x65, 0xce, 0x8f, 0x8f, 0x69}; + uint8_t bytes2[] = {0x87, 0xd7, 0x24, 0x7f, 0x70, 0x8e, 0x42, 0x3f}; + uint8_t bytes1[] = {0x47, 0xcf, 0x25, 0x9, 0x6a, 0x7a, 0x18, 0xa2, 0x4f, + 0xc2, 0xf6, 0x2d, 0x8b, 0x2a, 0x4f, 0x9, 0x61, 0x34}; + uint8_t bytes3[] = {0xf1, 0x21, 0x5e, 0xc, 0xc7, 0xac, 0x90, 0xc7, 0xd0}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12953}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22843}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24582}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2657}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytes1}, .v = {8, (char*)&bytes2}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18503}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytes3}}}, + }; + + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\186\EMG9\192\229\240\204\DC2o", +// _pubPktID = 0, _pubBody = "\166!\209#\147\&1%\222\235\133Gd\174=\SIf\247\215\US^6\b\r", _pubProps = +// [PropMaximumPacketSize 14608,PropServerKeepAlive 13002,PropContentType "\228 \ETX\252\187}P",PropTopicAlias +// 30258,PropUserProperty "\219UyW\v\EOT%\"\138{p\208{~\140\168wg\253" " +// Y\130\222\SYN3tx\NUL\232\&1\242\216_",PropServerKeepAlive 12368]} +TEST(Publish50QCTest, Encode6) { + uint8_t pkt[] = {0x38, 0x62, 0x0, 0xa, 0xba, 0x19, 0x47, 0x39, 0xc0, 0xe5, 0xf0, 0xcc, 0x12, 0x6f, 0x3e, 0x27, 0x0, + 0x0, 0x39, 0x10, 0x13, 0x32, 0xca, 0x3, 0x0, 0x7, 0xe4, 0x20, 0x3, 0xfc, 0xbb, 0x7d, 0x50, 0x23, + 0x76, 0x32, 0x26, 0x0, 0x13, 0xdb, 0x55, 0x79, 0x57, 0xb, 0x4, 0x25, 0x22, 0x8a, 0x7b, 0x70, 0xd0, + 0x7b, 0x7e, 0x8c, 0xa8, 0x77, 0x67, 0xfd, 0x0, 0xe, 0x20, 0x59, 0x82, 0xde, 0x16, 0x33, 0x74, 0x78, + 0x0, 0xe8, 0x31, 0xf2, 0xd8, 0x5f, 0x13, 0x30, 0x50, 0xa6, 0x21, 0xd1, 0x23, 0x93, 0x31, 0x25, 0xde, + 0xeb, 0x85, 0x47, 0x64, 0xae, 0x3d, 0xf, 0x66, 0xf7, 0xd7, 0x1f, 0x5e, 0x36, 0x8, 0xd}; + + uint8_t buf[110] = {0}; + + uint8_t topic_bytes[] = {0xba, 0x19, 0x47, 0x39, 0xc0, 0xe5, 0xf0, 0xcc, 0x12, 0x6f}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xa6, 0x21, 0xd1, 0x23, 0x93, 0x31, 0x25, 0xde, 0xeb, 0x85, 0x47, 0x64, + 0xae, 0x3d, 0xf, 0x66, 0xf7, 0xd7, 0x1f, 0x5e, 0x36, 0x8, 0xd}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 23; + + uint8_t bytes0[] = {0xe4, 0x20, 0x3, 0xfc, 0xbb, 0x7d, 0x50}; + uint8_t bytes2[] = {0x20, 0x59, 0x82, 0xde, 0x16, 0x33, 0x74, 0x78, 0x0, 0xe8, 0x31, 0xf2, 0xd8, 0x5f}; + uint8_t bytes1[] = {0xdb, 0x55, 0x79, 0x57, 0xb, 0x4, 0x25, 0x22, 0x8a, 0x7b, + 0x70, 0xd0, 0x7b, 0x7e, 0x8c, 0xa8, 0x77, 0x67, 0xfd}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14608}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13002}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30258}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytes1}, .v = {14, (char*)&bytes2}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12368}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\249\r\220\v\234\SOH\157\DC1_\145mx\199\189\136\241\241\184\225\ETX\132\GS\231\210\133\RS\r", _pubPktID = 32631, +// _pubBody = "\145\209\172\139\202&x\240\162\148\\U", _pubProps = [PropAuthenticationData +// "z\187\227b\SO\153e",PropSubscriptionIdentifier 1,PropContentType +// "\219\250L\140\ETX\177\238\144\157,\130\236\142\252\249\130g\199\246\248#\176\248x\179\161",PropContentType +// "\178c\180s\128I_\202\t9p\131\141\254\151",PropWildcardSubscriptionAvailable 154,PropTopicAliasMaximum +// 18494,PropCorrelationData "\SIc\230\n\143\128\EOT\194\182=\154R",PropSubscriptionIdentifier 30,PropContentType +// "\207TS\133\FS\211%\242\EM\161\EM\183\219",PropWildcardSubscriptionAvailable 9,PropMaximumQoS 120,PropServerKeepAlive +// 6661,PropUserProperty "\189\208X\237]Q\187F\166P8i\156l\138\255\179\237y" "d\154[\167SH",PropReasonString "\172 +// \193V\203\250\230J\151x\209\&9$_\235\150\189O\222\234\129\SYNq",PropRequestResponseInformation +// 71,PropSubscriptionIdentifierAvailable 63,PropResponseInformation +// "\253C\233\219W\193H\130\192\237a\236\254\165\239\ETX\233\248\221\234\231LU\230",PropReasonString +// "\129\209\178\&1\142\RSd",PropMessageExpiryInterval 19943,PropMessageExpiryInterval 21658,PropServerKeepAlive +// 10194,PropMessageExpiryInterval 12759,PropReceiveMaximum 6676,PropResponseTopic +// "\215\&4\214\ETX@A\228\251R\154\254y"]} +TEST(Publish50QCTest, Encode7) { + uint8_t pkt[] = { + 0x33, 0x9a, 0x2, 0x0, 0x1b, 0xf9, 0xd, 0xdc, 0xb, 0xea, 0x1, 0x9d, 0x11, 0x5f, 0x91, 0x6d, 0x78, 0xc7, 0xbd, + 0x88, 0xf1, 0xf1, 0xb8, 0xe1, 0x3, 0x84, 0x1d, 0xe7, 0xd2, 0x85, 0x1e, 0xd, 0x7f, 0x77, 0xed, 0x1, 0x16, 0x0, + 0x7, 0x7a, 0xbb, 0xe3, 0x62, 0xe, 0x99, 0x65, 0xb, 0x1, 0x3, 0x0, 0x1a, 0xdb, 0xfa, 0x4c, 0x8c, 0x3, 0xb1, + 0xee, 0x90, 0x9d, 0x2c, 0x82, 0xec, 0x8e, 0xfc, 0xf9, 0x82, 0x67, 0xc7, 0xf6, 0xf8, 0x23, 0xb0, 0xf8, 0x78, 0xb3, + 0xa1, 0x3, 0x0, 0xf, 0xb2, 0x63, 0xb4, 0x73, 0x80, 0x49, 0x5f, 0xca, 0x9, 0x39, 0x70, 0x83, 0x8d, 0xfe, 0x97, + 0x28, 0x9a, 0x22, 0x48, 0x3e, 0x9, 0x0, 0xc, 0xf, 0x63, 0xe6, 0xa, 0x8f, 0x80, 0x4, 0xc2, 0xb6, 0x3d, 0x9a, + 0x52, 0xb, 0x1e, 0x3, 0x0, 0xd, 0xcf, 0x54, 0x53, 0x85, 0x1c, 0xd3, 0x25, 0xf2, 0x19, 0xa1, 0x19, 0xb7, 0xdb, + 0x28, 0x9, 0x24, 0x78, 0x13, 0x1a, 0x5, 0x26, 0x0, 0x13, 0xbd, 0xd0, 0x58, 0xed, 0x5d, 0x51, 0xbb, 0x46, 0xa6, + 0x50, 0x38, 0x69, 0x9c, 0x6c, 0x8a, 0xff, 0xb3, 0xed, 0x79, 0x0, 0x6, 0x64, 0x9a, 0x5b, 0xa7, 0x53, 0x48, 0x1f, + 0x0, 0x17, 0xac, 0x20, 0xc1, 0x56, 0xcb, 0xfa, 0xe6, 0x4a, 0x97, 0x78, 0xd1, 0x39, 0x24, 0x5f, 0xeb, 0x96, 0xbd, + 0x4f, 0xde, 0xea, 0x81, 0x16, 0x71, 0x19, 0x47, 0x29, 0x3f, 0x1a, 0x0, 0x18, 0xfd, 0x43, 0xe9, 0xdb, 0x57, 0xc1, + 0x48, 0x82, 0xc0, 0xed, 0x61, 0xec, 0xfe, 0xa5, 0xef, 0x3, 0xe9, 0xf8, 0xdd, 0xea, 0xe7, 0x4c, 0x55, 0xe6, 0x1f, + 0x0, 0x7, 0x81, 0xd1, 0xb2, 0x31, 0x8e, 0x1e, 0x64, 0x2, 0x0, 0x0, 0x4d, 0xe7, 0x2, 0x0, 0x0, 0x54, 0x9a, + 0x13, 0x27, 0xd2, 0x2, 0x0, 0x0, 0x31, 0xd7, 0x21, 0x1a, 0x14, 0x8, 0x0, 0xc, 0xd7, 0x34, 0xd6, 0x3, 0x40, + 0x41, 0xe4, 0xfb, 0x52, 0x9a, 0xfe, 0x79, 0x91, 0xd1, 0xac, 0x8b, 0xca, 0x26, 0x78, 0xf0, 0xa2, 0x94, 0x5c, 0x55}; + + uint8_t buf[295] = {0}; + + uint8_t topic_bytes[] = {0xf9, 0xd, 0xdc, 0xb, 0xea, 0x1, 0x9d, 0x11, 0x5f, 0x91, 0x6d, 0x78, 0xc7, 0xbd, + 0x88, 0xf1, 0xf1, 0xb8, 0xe1, 0x3, 0x84, 0x1d, 0xe7, 0xd2, 0x85, 0x1e, 0xd}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x91, 0xd1, 0xac, 0x8b, 0xca, 0x26, 0x78, 0xf0, 0xa2, 0x94, 0x5c, 0x55}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; + + uint8_t bytes0[] = {0x7a, 0xbb, 0xe3, 0x62, 0xe, 0x99, 0x65}; + uint8_t bytes1[] = {0xdb, 0xfa, 0x4c, 0x8c, 0x3, 0xb1, 0xee, 0x90, 0x9d, 0x2c, 0x82, 0xec, 0x8e, + 0xfc, 0xf9, 0x82, 0x67, 0xc7, 0xf6, 0xf8, 0x23, 0xb0, 0xf8, 0x78, 0xb3, 0xa1}; + uint8_t bytes2[] = {0xb2, 0x63, 0xb4, 0x73, 0x80, 0x49, 0x5f, 0xca, 0x9, 0x39, 0x70, 0x83, 0x8d, 0xfe, 0x97}; + uint8_t bytes3[] = {0xf, 0x63, 0xe6, 0xa, 0x8f, 0x80, 0x4, 0xc2, 0xb6, 0x3d, 0x9a, 0x52}; + uint8_t bytes4[] = {0xcf, 0x54, 0x53, 0x85, 0x1c, 0xd3, 0x25, 0xf2, 0x19, 0xa1, 0x19, 0xb7, 0xdb}; + uint8_t bytes6[] = {0x64, 0x9a, 0x5b, 0xa7, 0x53, 0x48}; + uint8_t bytes5[] = {0xbd, 0xd0, 0x58, 0xed, 0x5d, 0x51, 0xbb, 0x46, 0xa6, 0x50, + 0x38, 0x69, 0x9c, 0x6c, 0x8a, 0xff, 0xb3, 0xed, 0x79}; + uint8_t bytes7[] = {0xac, 0x20, 0xc1, 0x56, 0xcb, 0xfa, 0xe6, 0x4a, 0x97, 0x78, 0xd1, 0x39, + 0x24, 0x5f, 0xeb, 0x96, 0xbd, 0x4f, 0xde, 0xea, 0x81, 0x16, 0x71}; + uint8_t bytes8[] = {0xfd, 0x43, 0xe9, 0xdb, 0x57, 0xc1, 0x48, 0x82, 0xc0, 0xed, 0x61, 0xec, + 0xfe, 0xa5, 0xef, 0x3, 0xe9, 0xf8, 0xdd, 0xea, 0xe7, 0x4c, 0x55, 0xe6}; + uint8_t bytes9[] = {0x81, 0xd1, 0xb2, 0x31, 0x8e, 0x1e, 0x64}; + uint8_t bytes10[] = {0xd7, 0x34, 0xd6, 0x3, 0x40, 0x41, 0xe4, 0xfb, 0x52, 0x9a, 0xfe, 0x79}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18494}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6661}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytes5}, .v = {6, (char*)&bytes6}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytes8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytes9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19943}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21658}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10194}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12759}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6676}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytes10}}}, + }; + + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32631, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "b\213\SO\144\154E1Y", _pubPktID = +// 17459, _pubBody = "\197\176\151_P\DC4\162Y\176\178\tN}p\223\213\213\215\&9\208.dWr", _pubProps = +// [PropRequestProblemInformation 5,PropRequestResponseInformation 145,PropRetainAvailable +// 57,PropAssignedClientIdentifier "\134\178\128F\173\229\ESC\250l(\167\156\201\130\189\187\192}\153>\166\185\219 +// sn\195\207",PropWillDelayInterval 10980,PropPayloadFormatIndicator 112,PropResponseInformation "XsO",PropUserProperty +// "<[\227'\208n\249\170\220\133#L\204\168*\198\155Sl\133\223\236\ENQ\152\RS" "\181\DC4\210):",PropSessionExpiryInterval +// 11656,PropUserProperty "\238<\162\202\&2\201-+J\DC1\225\GSt #*\129" +// "\248\222\212+T\180\FS5\netF\175\SOH\GS",PropRetainAvailable 182,PropResponseInformation +// "\221O|\ESCU\171\144\243\\\213\240\"\172X\250\176T",PropReasonString "\166G",PropTopicAliasMaximum +// 18131,PropRetainAvailable 21,PropReasonString "\178\DC4"]} +TEST(Publish50QCTest, Encode8) { + uint8_t pkt[] = { + 0x35, 0xca, 0x1, 0x0, 0x8, 0x62, 0xd5, 0xe, 0x90, 0x9a, 0x45, 0x31, 0x59, 0x44, 0x33, 0xa4, 0x1, 0x17, 0x5, + 0x19, 0x91, 0x25, 0x39, 0x12, 0x0, 0x1c, 0x86, 0xb2, 0x80, 0x46, 0xad, 0xe5, 0x1b, 0xfa, 0x6c, 0x28, 0xa7, 0x9c, + 0xc9, 0x82, 0xbd, 0xbb, 0xc0, 0x7d, 0x99, 0x3e, 0xa6, 0xb9, 0xdb, 0x20, 0x73, 0x6e, 0xc3, 0xcf, 0x18, 0x0, 0x0, + 0x2a, 0xe4, 0x1, 0x70, 0x1a, 0x0, 0x3, 0x58, 0x73, 0x4f, 0x26, 0x0, 0x19, 0x3c, 0x5b, 0xe3, 0x27, 0xd0, 0x6e, + 0xf9, 0xaa, 0xdc, 0x85, 0x23, 0x4c, 0xcc, 0xa8, 0x2a, 0xc6, 0x9b, 0x53, 0x6c, 0x85, 0xdf, 0xec, 0x5, 0x98, 0x1e, + 0x0, 0x5, 0xb5, 0x14, 0xd2, 0x29, 0x3a, 0x11, 0x0, 0x0, 0x2d, 0x88, 0x26, 0x0, 0x11, 0xee, 0x3c, 0xa2, 0xca, + 0x32, 0xc9, 0x2d, 0x2b, 0x4a, 0x11, 0xe1, 0x1d, 0x74, 0x20, 0x23, 0x2a, 0x81, 0x0, 0xf, 0xf8, 0xde, 0xd4, 0x2b, + 0x54, 0xb4, 0x1c, 0x35, 0xa, 0x65, 0x74, 0x46, 0xaf, 0x1, 0x1d, 0x25, 0xb6, 0x1a, 0x0, 0x11, 0xdd, 0x4f, 0x7c, + 0x1b, 0x55, 0xab, 0x90, 0xf3, 0x5c, 0xd5, 0xf0, 0x22, 0xac, 0x58, 0xfa, 0xb0, 0x54, 0x1f, 0x0, 0x2, 0xa6, 0x47, + 0x22, 0x46, 0xd3, 0x25, 0x15, 0x1f, 0x0, 0x2, 0xb2, 0x14, 0xc5, 0xb0, 0x97, 0x5f, 0x50, 0x14, 0xa2, 0x59, 0xb0, + 0xb2, 0x9, 0x4e, 0x7d, 0x70, 0xdf, 0xd5, 0xd5, 0xd7, 0x39, 0xd0, 0x2e, 0x64, 0x57, 0x72}; + + uint8_t buf[215] = {0}; + + uint8_t topic_bytes[] = {0x62, 0xd5, 0xe, 0x90, 0x9a, 0x45, 0x31, 0x59}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xc5, 0xb0, 0x97, 0x5f, 0x50, 0x14, 0xa2, 0x59, 0xb0, 0xb2, 0x9, 0x4e, + 0x7d, 0x70, 0xdf, 0xd5, 0xd5, 0xd7, 0x39, 0xd0, 0x2e, 0x64, 0x57, 0x72}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + uint8_t bytes0[] = {0x86, 0xb2, 0x80, 0x46, 0xad, 0xe5, 0x1b, 0xfa, 0x6c, 0x28, 0xa7, 0x9c, 0xc9, 0x82, + 0xbd, 0xbb, 0xc0, 0x7d, 0x99, 0x3e, 0xa6, 0xb9, 0xdb, 0x20, 0x73, 0x6e, 0xc3, 0xcf}; + uint8_t bytes1[] = {0x58, 0x73, 0x4f}; + uint8_t bytes3[] = {0xb5, 0x14, 0xd2, 0x29, 0x3a}; + uint8_t bytes2[] = {0x3c, 0x5b, 0xe3, 0x27, 0xd0, 0x6e, 0xf9, 0xaa, 0xdc, 0x85, 0x23, 0x4c, 0xcc, + 0xa8, 0x2a, 0xc6, 0x9b, 0x53, 0x6c, 0x85, 0xdf, 0xec, 0x5, 0x98, 0x1e}; + uint8_t bytes5[] = {0xf8, 0xde, 0xd4, 0x2b, 0x54, 0xb4, 0x1c, 0x35, 0xa, 0x65, 0x74, 0x46, 0xaf, 0x1, 0x1d}; + uint8_t bytes4[] = {0xee, 0x3c, 0xa2, 0xca, 0x32, 0xc9, 0x2d, 0x2b, 0x4a, + 0x11, 0xe1, 0x1d, 0x74, 0x20, 0x23, 0x2a, 0x81}; + uint8_t bytes6[] = {0xdd, 0x4f, 0x7c, 0x1b, 0x55, 0xab, 0x90, 0xf3, 0x5c, + 0xd5, 0xf0, 0x22, 0xac, 0x58, 0xfa, 0xb0, 0x54}; + uint8_t bytes7[] = {0xa6, 0x47}; + uint8_t bytes8[] = {0xb2, 0x14}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10980}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytes2}, .v = {5, (char*)&bytes3}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11656}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytes4}, .v = {15, (char*)&bytes5}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18131}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytes8}}}, + }; + + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17459, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\222\129", _pubPktID = 4136, +// _pubBody = "\238\173\129\190\233\254\157\252\185\239@\147\192rs\143\219-\185\140j5\231\226Y\SYN+", _pubProps = +// [PropPayloadFormatIndicator 205,PropSubscriptionIdentifierAvailable 143,PropSharedSubscriptionAvailable +// 37,PropCorrelationData "\203\139a^G\132kL",PropMessageExpiryInterval 3837,PropRequestResponseInformation +// 130,PropRequestResponseInformation 238,PropAssignedClientIdentifier +// "B\DLE\132S\191\218s\135z\187\224\237\130\EOT\ETX\195\US\201\183R>>\SOHvk",PropServerKeepAlive +// 10975,PropTopicAliasMaximum 9324,PropTopicAliasMaximum 30282,PropUserProperty "\221 +// v\t\168c,\173\157F\210\233\246\135" "",PropResponseTopic +// "\CAN\159=\DC2>\NAK\132\164\175\130\246\SO>'\187\218\141iF\204\EOT\232^\236{\154=y\135",PropMessageExpiryInterval +// 20998,PropMaximumPacketSize 30109,PropReceiveMaximum 18125,PropReceiveMaximum 19631,PropAuthenticationMethod +// "\211F`x\211\195`\197\211\198\192j\"\218\249\248\NAK",PropSessionExpiryInterval 4788,PropSessionExpiryInterval +// 10477,PropSubscriptionIdentifier 4,PropMaximumPacketSize 16320,PropAuthenticationData +// "\190.\238\220\NAK\230\180\156\228\134/\144\203\&0\b\231[B\129\197",PropPayloadFormatIndicator +// 44,PropSharedSubscriptionAvailable 141,PropRetainAvailable 213,PropRequestProblemInformation +// 147,PropWildcardSubscriptionAvailable 68]} +TEST(Publish50QCTest, Encode9) { + uint8_t pkt[] = { + 0x35, 0xeb, 0x1, 0x0, 0x2, 0xde, 0x81, 0x10, 0x28, 0xc8, 0x1, 0x1, 0xcd, 0x29, 0x8f, 0x2a, 0x25, 0x9, 0x0, + 0x8, 0xcb, 0x8b, 0x61, 0x5e, 0x47, 0x84, 0x6b, 0x4c, 0x2, 0x0, 0x0, 0xe, 0xfd, 0x19, 0x82, 0x19, 0xee, 0x12, + 0x0, 0x19, 0x42, 0x10, 0x84, 0x53, 0xbf, 0xda, 0x73, 0x87, 0x7a, 0xbb, 0xe0, 0xed, 0x82, 0x4, 0x3, 0xc3, 0x1f, + 0xc9, 0xb7, 0x52, 0x3e, 0x3e, 0x1, 0x76, 0x6b, 0x13, 0x2a, 0xdf, 0x22, 0x24, 0x6c, 0x22, 0x76, 0x4a, 0x26, 0x0, + 0xe, 0xdd, 0x20, 0x76, 0x9, 0xa8, 0x63, 0x2c, 0xad, 0x9d, 0x46, 0xd2, 0xe9, 0xf6, 0x87, 0x0, 0x0, 0x8, 0x0, + 0x1d, 0x18, 0x9f, 0x3d, 0x12, 0x3e, 0x15, 0x84, 0xa4, 0xaf, 0x82, 0xf6, 0xe, 0x3e, 0x27, 0xbb, 0xda, 0x8d, 0x69, + 0x46, 0xcc, 0x4, 0xe8, 0x5e, 0xec, 0x7b, 0x9a, 0x3d, 0x79, 0x87, 0x2, 0x0, 0x0, 0x52, 0x6, 0x27, 0x0, 0x0, + 0x75, 0x9d, 0x21, 0x46, 0xcd, 0x21, 0x4c, 0xaf, 0x15, 0x0, 0x11, 0xd3, 0x46, 0x60, 0x78, 0xd3, 0xc3, 0x60, 0xc5, + 0xd3, 0xc6, 0xc0, 0x6a, 0x22, 0xda, 0xf9, 0xf8, 0x15, 0x11, 0x0, 0x0, 0x12, 0xb4, 0x11, 0x0, 0x0, 0x28, 0xed, + 0xb, 0x4, 0x27, 0x0, 0x0, 0x3f, 0xc0, 0x16, 0x0, 0x14, 0xbe, 0x2e, 0xee, 0xdc, 0x15, 0xe6, 0xb4, 0x9c, 0xe4, + 0x86, 0x2f, 0x90, 0xcb, 0x30, 0x8, 0xe7, 0x5b, 0x42, 0x81, 0xc5, 0x1, 0x2c, 0x2a, 0x8d, 0x25, 0xd5, 0x17, 0x93, + 0x28, 0x44, 0xee, 0xad, 0x81, 0xbe, 0xe9, 0xfe, 0x9d, 0xfc, 0xb9, 0xef, 0x40, 0x93, 0xc0, 0x72, 0x73, 0x8f, 0xdb, + 0x2d, 0xb9, 0x8c, 0x6a, 0x35, 0xe7, 0xe2, 0x59, 0x16, 0x2b}; + + uint8_t buf[248] = {0}; + + uint8_t topic_bytes[] = {0xde, 0x81}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xee, 0xad, 0x81, 0xbe, 0xe9, 0xfe, 0x9d, 0xfc, 0xb9, 0xef, 0x40, 0x93, 0xc0, 0x72, + 0x73, 0x8f, 0xdb, 0x2d, 0xb9, 0x8c, 0x6a, 0x35, 0xe7, 0xe2, 0x59, 0x16, 0x2b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 27; + + uint8_t bytes0[] = {0xcb, 0x8b, 0x61, 0x5e, 0x47, 0x84, 0x6b, 0x4c}; + uint8_t bytes1[] = {0x42, 0x10, 0x84, 0x53, 0xbf, 0xda, 0x73, 0x87, 0x7a, 0xbb, 0xe0, 0xed, 0x82, + 0x4, 0x3, 0xc3, 0x1f, 0xc9, 0xb7, 0x52, 0x3e, 0x3e, 0x1, 0x76, 0x6b}; + uint8_t bytes3[] = {0}; + uint8_t bytes2[] = {0xdd, 0x20, 0x76, 0x9, 0xa8, 0x63, 0x2c, 0xad, 0x9d, 0x46, 0xd2, 0xe9, 0xf6, 0x87}; + uint8_t bytes4[] = {0x18, 0x9f, 0x3d, 0x12, 0x3e, 0x15, 0x84, 0xa4, 0xaf, 0x82, 0xf6, 0xe, 0x3e, 0x27, 0xbb, + 0xda, 0x8d, 0x69, 0x46, 0xcc, 0x4, 0xe8, 0x5e, 0xec, 0x7b, 0x9a, 0x3d, 0x79, 0x87}; + uint8_t bytes5[] = {0xd3, 0x46, 0x60, 0x78, 0xd3, 0xc3, 0x60, 0xc5, 0xd3, + 0xc6, 0xc0, 0x6a, 0x22, 0xda, 0xf9, 0xf8, 0x15}; + uint8_t bytes6[] = {0xbe, 0x2e, 0xee, 0xdc, 0x15, 0xe6, 0xb4, 0x9c, 0xe4, 0x86, + 0x2f, 0x90, 0xcb, 0x30, 0x8, 0xe7, 0x5b, 0x42, 0x81, 0xc5}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3837}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10975}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9324}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30282}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytes2}, .v = {0, (char*)&bytes3}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20998}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30109}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18125}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19631}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4788}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10477}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16320}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 68}}, + }; + + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 4136, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = +// "]Bpc\184\177\176\&3}-\DC4K", _pubProps = [PropRequestProblemInformation 126,PropAuthenticationMethod +// "\199^\140\147\247\203\131+\DLE\174\144\&8wN\203n\207qb\252\200\\\254\ACK`\220",PropWildcardSubscriptionAvailable +// 131,PropMaximumPacketSize 22048,PropRequestProblemInformation 6,PropTopicAlias 5382]} +TEST(Publish50QCTest, Encode10) { + uint8_t pkt[] = {0x30, 0x3a, 0x0, 0x0, 0x2b, 0x17, 0x7e, 0x15, 0x0, 0x1a, 0xc7, 0x5e, 0x8c, 0x93, 0xf7, + 0xcb, 0x83, 0x2b, 0x10, 0xae, 0x90, 0x38, 0x77, 0x4e, 0xcb, 0x6e, 0xcf, 0x71, 0x62, 0xfc, + 0xc8, 0x5c, 0xfe, 0x6, 0x60, 0xdc, 0x28, 0x83, 0x27, 0x0, 0x0, 0x56, 0x20, 0x17, 0x6, + 0x23, 0x15, 0x6, 0x5d, 0x42, 0x70, 0x63, 0xb8, 0xb1, 0xb0, 0x33, 0x7d, 0x2d, 0x14, 0x4b}; + + uint8_t buf[70] = {0}; + + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x5d, 0x42, 0x70, 0x63, 0xb8, 0xb1, 0xb0, 0x33, 0x7d, 0x2d, 0x14, 0x4b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; + + uint8_t bytes0[] = {0xc7, 0x5e, 0x8c, 0x93, 0xf7, 0xcb, 0x83, 0x2b, 0x10, 0xae, 0x90, 0x38, 0x77, + 0x4e, 0xcb, 0x6e, 0xcf, 0x71, 0x62, 0xfc, 0xc8, 0x5c, 0xfe, 0x6, 0x60, 0xdc}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22048}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5382}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "/u\181\175\201\CANO", _pubPktID = 0, +// _pubBody = "\234\204\242\217\131\187\a+\140\DC4NsE\f\166\DC1\206pf\ETB\150\193\138\249\166r\189-S\EOT", _pubProps = +// [PropSessionExpiryInterval 16505,PropUserProperty "h(<\233\b\r\183\168]n\190\204\149" "\228hW",PropTopicAliasMaximum +// 22742,PropWildcardSubscriptionAvailable 240,PropAssignedClientIdentifier +// "\133\169",PropSubscriptionIdentifierAvailable 158,PropPayloadFormatIndicator 141,PropSubscriptionIdentifierAvailable +// 8,PropTopicAlias 10002,PropReasonString "\144\205\ft\129\ETX=\129",PropWillDelayInterval 22357]} +TEST(Publish50QCTest, Encode11) { + uint8_t pkt[] = {0x38, 0x65, 0x0, 0x7, 0x2f, 0x75, 0xb5, 0xaf, 0xc9, 0x18, 0x4f, 0x3d, 0x11, 0x0, 0x0, + 0x40, 0x79, 0x26, 0x0, 0xd, 0x68, 0x28, 0x3c, 0xe9, 0x8, 0xd, 0xb7, 0xa8, 0x5d, 0x6e, + 0xbe, 0xcc, 0x95, 0x0, 0x3, 0xe4, 0x68, 0x57, 0x22, 0x58, 0xd6, 0x28, 0xf0, 0x12, 0x0, + 0x2, 0x85, 0xa9, 0x29, 0x9e, 0x1, 0x8d, 0x29, 0x8, 0x23, 0x27, 0x12, 0x1f, 0x0, 0x8, + 0x90, 0xcd, 0xc, 0x74, 0x81, 0x3, 0x3d, 0x81, 0x18, 0x0, 0x0, 0x57, 0x55, 0xea, 0xcc, + 0xf2, 0xd9, 0x83, 0xbb, 0x7, 0x2b, 0x8c, 0x14, 0x4e, 0x73, 0x45, 0xc, 0xa6, 0x11, 0xce, + 0x70, 0x66, 0x17, 0x96, 0xc1, 0x8a, 0xf9, 0xa6, 0x72, 0xbd, 0x2d, 0x53, 0x4}; + + uint8_t buf[113] = {0}; + + uint8_t topic_bytes[] = {0x2f, 0x75, 0xb5, 0xaf, 0xc9, 0x18, 0x4f}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xea, 0xcc, 0xf2, 0xd9, 0x83, 0xbb, 0x7, 0x2b, 0x8c, 0x14, 0x4e, 0x73, 0x45, 0xc, 0xa6, + 0x11, 0xce, 0x70, 0x66, 0x17, 0x96, 0xc1, 0x8a, 0xf9, 0xa6, 0x72, 0xbd, 0x2d, 0x53, 0x4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + uint8_t bytes1[] = {0xe4, 0x68, 0x57}; + uint8_t bytes0[] = {0x68, 0x28, 0x3c, 0xe9, 0x8, 0xd, 0xb7, 0xa8, 0x5d, 0x6e, 0xbe, 0xcc, 0x95}; + uint8_t bytes2[] = {0x85, 0xa9}; + uint8_t bytes3[] = {0x90, 0xcd, 0xc, 0x74, 0x81, 0x3, 0x3d, 0x81}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16505}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytes0}, .v = {3, (char*)&bytes1}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22742}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10002}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22357}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "-\243H\202R\162w&\149\233\171\223", +// _pubPktID = 0, _pubBody = "\216\SO\135\ENQ\236\223\tG\203\177\ESC\132\135)\187", _pubProps = [PropReceiveMaximum +// 18550,PropTopicAlias 22808,PropMessageExpiryInterval 2858,PropTopicAliasMaximum 31551,PropServerReference +// "\209M\US;?\164H\186*",PropAssignedClientIdentifier +// ".\146\v\NUL\221V\216@cX=\149\167\138\178^\220\223\198\205",PropAssignedClientIdentifier +// "`W\160\157\191",PropSharedSubscriptionAvailable 115,PropRequestProblemInformation 221,PropRequestResponseInformation +// 228,PropRequestResponseInformation 219,PropSharedSubscriptionAvailable 151,PropSessionExpiryInterval +// 10566,PropAuthenticationData "\168DW\140&\184E\132\251a0ln\201",PropRequestResponseInformation +// 16,PropRequestResponseInformation 115,PropRetainAvailable 178,PropSubscriptionIdentifier +// 15,PropAssignedClientIdentifier +// "\240\EM\v\232\222\145\242\221\228\229\GS!\156\195\230\SOH@y\222r'n\195\159)\225",PropAuthenticationMethod +// "t\171\232\148",PropContentType "}\136\SUB\ENQ-jNG\137\241\EOT\198j\200>\171\177S\ETB",PropContentType +// "U\205E\175",PropRequestProblemInformation 90,PropSubscriptionIdentifierAvailable 152]} +TEST(Publish50QCTest, Encode12) { + uint8_t pkt[] = {0x39, 0xc5, 0x1, 0x0, 0xc, 0x2d, 0xf3, 0x48, 0xca, 0x52, 0xa2, 0x77, 0x26, 0x95, 0xe9, 0xab, 0xdf, + 0xa6, 0x1, 0x21, 0x48, 0x76, 0x23, 0x59, 0x18, 0x2, 0x0, 0x0, 0xb, 0x2a, 0x22, 0x7b, 0x3f, 0x1c, + 0x0, 0x9, 0xd1, 0x4d, 0x1f, 0x3b, 0x3f, 0xa4, 0x48, 0xba, 0x2a, 0x12, 0x0, 0x14, 0x2e, 0x92, 0xb, + 0x0, 0xdd, 0x56, 0xd8, 0x40, 0x63, 0x58, 0x3d, 0x95, 0xa7, 0x8a, 0xb2, 0x5e, 0xdc, 0xdf, 0xc6, 0xcd, + 0x12, 0x0, 0x5, 0x60, 0x57, 0xa0, 0x9d, 0xbf, 0x2a, 0x73, 0x17, 0xdd, 0x19, 0xe4, 0x19, 0xdb, 0x2a, + 0x97, 0x11, 0x0, 0x0, 0x29, 0x46, 0x16, 0x0, 0xe, 0xa8, 0x44, 0x57, 0x8c, 0x26, 0xb8, 0x45, 0x84, + 0xfb, 0x61, 0x30, 0x6c, 0x6e, 0xc9, 0x19, 0x10, 0x19, 0x73, 0x25, 0xb2, 0xb, 0xf, 0x12, 0x0, 0x1a, + 0xf0, 0x19, 0xb, 0xe8, 0xde, 0x91, 0xf2, 0xdd, 0xe4, 0xe5, 0x1d, 0x21, 0x9c, 0xc3, 0xe6, 0x1, 0x40, + 0x79, 0xde, 0x72, 0x27, 0x6e, 0xc3, 0x9f, 0x29, 0xe1, 0x15, 0x0, 0x4, 0x74, 0xab, 0xe8, 0x94, 0x3, + 0x0, 0x13, 0x7d, 0x88, 0x1a, 0x5, 0x2d, 0x6a, 0x4e, 0x47, 0x89, 0xf1, 0x4, 0xc6, 0x6a, 0xc8, 0x3e, + 0xab, 0xb1, 0x53, 0x17, 0x3, 0x0, 0x4, 0x55, 0xcd, 0x45, 0xaf, 0x17, 0x5a, 0x29, 0x98, 0xd8, 0xe, + 0x87, 0x5, 0xec, 0xdf, 0x9, 0x47, 0xcb, 0xb1, 0x1b, 0x84, 0x87, 0x29, 0xbb}; + + uint8_t buf[210] = {0}; + + uint8_t topic_bytes[] = {0x2d, 0xf3, 0x48, 0xca, 0x52, 0xa2, 0x77, 0x26, 0x95, 0xe9, 0xab, 0xdf}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xd8, 0xe, 0x87, 0x5, 0xec, 0xdf, 0x9, 0x47, 0xcb, 0xb1, 0x1b, 0x84, 0x87, 0x29, 0xbb}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 15; + + uint8_t bytes0[] = {0xd1, 0x4d, 0x1f, 0x3b, 0x3f, 0xa4, 0x48, 0xba, 0x2a}; + uint8_t bytes1[] = {0x2e, 0x92, 0xb, 0x0, 0xdd, 0x56, 0xd8, 0x40, 0x63, 0x58, + 0x3d, 0x95, 0xa7, 0x8a, 0xb2, 0x5e, 0xdc, 0xdf, 0xc6, 0xcd}; + uint8_t bytes2[] = {0x60, 0x57, 0xa0, 0x9d, 0xbf}; + uint8_t bytes3[] = {0xa8, 0x44, 0x57, 0x8c, 0x26, 0xb8, 0x45, 0x84, 0xfb, 0x61, 0x30, 0x6c, 0x6e, 0xc9}; + uint8_t bytes4[] = {0xf0, 0x19, 0xb, 0xe8, 0xde, 0x91, 0xf2, 0xdd, 0xe4, 0xe5, 0x1d, 0x21, 0x9c, + 0xc3, 0xe6, 0x1, 0x40, 0x79, 0xde, 0x72, 0x27, 0x6e, 0xc3, 0x9f, 0x29, 0xe1}; + uint8_t bytes5[] = {0x74, 0xab, 0xe8, 0x94}; + uint8_t bytes6[] = {0x7d, 0x88, 0x1a, 0x5, 0x2d, 0x6a, 0x4e, 0x47, 0x89, 0xf1, + 0x4, 0xc6, 0x6a, 0xc8, 0x3e, 0xab, 0xb1, 0x53, 0x17}; + uint8_t bytes7[] = {0x55, 0xcd, 0x45, 0xaf}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18550}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22808}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2858}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31551}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10566}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, + }; + + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "W\133\164\255\227+ +// \229\201\165[q\DC25\225\242\160 >\bi", _pubPktID = 0, _pubBody = "", _pubProps = [PropSubscriptionIdentifierAvailable +// 214,PropRetainAvailable 23,PropWildcardSubscriptionAvailable 43,PropAuthenticationData +// "\157<\161\249\233\130",PropUserProperty "n*\177\220\176'\196\135\239a\129\133\166\175\SO#\167\238\SI\217\177" +// "\172K\211\132\226\&2\206\242\179>\244\244\237H\229\244d\247+]\a\177",PropServerReference +// "\ESCW\229\249)\243%\132\SI\136GvI\NAK",PropServerReference +// "\ACKH\235\240\213}\181?1\ACK\184\165\247\179\181\180\209",PropUserProperty +// "^8\DC1*\199/\166\208\172g$\161\210\160\217\\\f\DC2\181\254T" +// "\136o\140\255\237\&74\197\ETB\DEL\137\SO\r\222\US",PropMessageExpiryInterval 30944,PropTopicAlias +// 9769,PropAuthenticationData "\173\245\162\193C\249\t\DEL0#\236\142\175\149Y)\209\161\147\ETB",PropUserProperty +// "\t\148\136\138\241\ETX\198\CAN\130\147\186\148\171]\218I\DEL\158\174\&4\142" +// "Q\235&\DC2\159\DC1>\SYN\194\DC21\NAK\254\177#[\218\218Vb\159\197p<",PropSharedSubscriptionAvailable +// 111,PropMaximumQoS 156,PropAuthenticationData +// "d#p\253\181\237\190\v>&\DC1\150\193bE;\134\ENQ\181\198*]\207i",PropSessionExpiryInterval +// 18301,PropAuthenticationData "\152\168\ETX\\\222v%\252o\185\&9\184\&5\187",PropPayloadFormatIndicator +// 228,PropMaximumQoS 192,PropRetainAvailable 35,PropSubscriptionIdentifierAvailable 215,PropTopicAliasMaximum 19410]} +TEST(Publish50QCTest, Encode13) { + uint8_t pkt[] = { + 0x30, 0xb7, 0x2, 0x0, 0x15, 0x57, 0x85, 0xa4, 0xff, 0xe3, 0x2b, 0x20, 0xe5, 0xc9, 0xa5, 0x5b, 0x71, 0x12, 0x35, + 0xe1, 0xf2, 0xa0, 0x20, 0x3e, 0x8, 0x69, 0x9e, 0x2, 0x29, 0xd6, 0x25, 0x17, 0x28, 0x2b, 0x16, 0x0, 0x6, 0x9d, + 0x3c, 0xa1, 0xf9, 0xe9, 0x82, 0x26, 0x0, 0x15, 0x6e, 0x2a, 0xb1, 0xdc, 0xb0, 0x27, 0xc4, 0x87, 0xef, 0x61, 0x81, + 0x85, 0xa6, 0xaf, 0xe, 0x23, 0xa7, 0xee, 0xf, 0xd9, 0xb1, 0x0, 0x16, 0xac, 0x4b, 0xd3, 0x84, 0xe2, 0x32, 0xce, + 0xf2, 0xb3, 0x3e, 0xf4, 0xf4, 0xed, 0x48, 0xe5, 0xf4, 0x64, 0xf7, 0x2b, 0x5d, 0x7, 0xb1, 0x1c, 0x0, 0xe, 0x1b, + 0x57, 0xe5, 0xf9, 0x29, 0xf3, 0x25, 0x84, 0xf, 0x88, 0x47, 0x76, 0x49, 0x15, 0x1c, 0x0, 0x11, 0x6, 0x48, 0xeb, + 0xf0, 0xd5, 0x7d, 0xb5, 0x3f, 0x31, 0x6, 0xb8, 0xa5, 0xf7, 0xb3, 0xb5, 0xb4, 0xd1, 0x26, 0x0, 0x15, 0x5e, 0x38, + 0x11, 0x2a, 0xc7, 0x2f, 0xa6, 0xd0, 0xac, 0x67, 0x24, 0xa1, 0xd2, 0xa0, 0xd9, 0x5c, 0xc, 0x12, 0xb5, 0xfe, 0x54, + 0x0, 0xf, 0x88, 0x6f, 0x8c, 0xff, 0xed, 0x37, 0x34, 0xc5, 0x17, 0x7f, 0x89, 0xe, 0xd, 0xde, 0x1f, 0x2, 0x0, + 0x0, 0x78, 0xe0, 0x23, 0x26, 0x29, 0x16, 0x0, 0x14, 0xad, 0xf5, 0xa2, 0xc1, 0x43, 0xf9, 0x9, 0x7f, 0x30, 0x23, + 0xec, 0x8e, 0xaf, 0x95, 0x59, 0x29, 0xd1, 0xa1, 0x93, 0x17, 0x26, 0x0, 0x15, 0x9, 0x94, 0x88, 0x8a, 0xf1, 0x3, + 0xc6, 0x18, 0x82, 0x93, 0xba, 0x94, 0xab, 0x5d, 0xda, 0x49, 0x7f, 0x9e, 0xae, 0x34, 0x8e, 0x0, 0x18, 0x51, 0xeb, + 0x26, 0x12, 0x9f, 0x11, 0x3e, 0x16, 0xc2, 0x12, 0x31, 0x15, 0xfe, 0xb1, 0x23, 0x5b, 0xda, 0xda, 0x56, 0x62, 0x9f, + 0xc5, 0x70, 0x3c, 0x2a, 0x6f, 0x24, 0x9c, 0x16, 0x0, 0x18, 0x64, 0x23, 0x70, 0xfd, 0xb5, 0xed, 0xbe, 0xb, 0x3e, + 0x26, 0x11, 0x96, 0xc1, 0x62, 0x45, 0x3b, 0x86, 0x5, 0xb5, 0xc6, 0x2a, 0x5d, 0xcf, 0x69, 0x11, 0x0, 0x0, 0x47, + 0x7d, 0x16, 0x0, 0xe, 0x98, 0xa8, 0x3, 0x5c, 0xde, 0x76, 0x25, 0xfc, 0x6f, 0xb9, 0x39, 0xb8, 0x35, 0xbb, 0x1, + 0xe4, 0x24, 0xc0, 0x25, 0x23, 0x29, 0xd7, 0x22, 0x4b, 0xd2}; + + uint8_t buf[324] = {0}; + + uint8_t topic_bytes[] = {0x57, 0x85, 0xa4, 0xff, 0xe3, 0x2b, 0x20, 0xe5, 0xc9, 0xa5, 0x5b, + 0x71, 0x12, 0x35, 0xe1, 0xf2, 0xa0, 0x20, 0x3e, 0x8, 0x69}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 0; + + uint8_t bytes0[] = {0x9d, 0x3c, 0xa1, 0xf9, 0xe9, 0x82}; + uint8_t bytes2[] = {0xac, 0x4b, 0xd3, 0x84, 0xe2, 0x32, 0xce, 0xf2, 0xb3, 0x3e, 0xf4, + 0xf4, 0xed, 0x48, 0xe5, 0xf4, 0x64, 0xf7, 0x2b, 0x5d, 0x7, 0xb1}; + uint8_t bytes1[] = {0x6e, 0x2a, 0xb1, 0xdc, 0xb0, 0x27, 0xc4, 0x87, 0xef, 0x61, 0x81, + 0x85, 0xa6, 0xaf, 0xe, 0x23, 0xa7, 0xee, 0xf, 0xd9, 0xb1}; + uint8_t bytes3[] = {0x1b, 0x57, 0xe5, 0xf9, 0x29, 0xf3, 0x25, 0x84, 0xf, 0x88, 0x47, 0x76, 0x49, 0x15}; + uint8_t bytes4[] = {0x6, 0x48, 0xeb, 0xf0, 0xd5, 0x7d, 0xb5, 0x3f, 0x31, + 0x6, 0xb8, 0xa5, 0xf7, 0xb3, 0xb5, 0xb4, 0xd1}; + uint8_t bytes6[] = {0x88, 0x6f, 0x8c, 0xff, 0xed, 0x37, 0x34, 0xc5, 0x17, 0x7f, 0x89, 0xe, 0xd, 0xde, 0x1f}; + uint8_t bytes5[] = {0x5e, 0x38, 0x11, 0x2a, 0xc7, 0x2f, 0xa6, 0xd0, 0xac, 0x67, 0x24, + 0xa1, 0xd2, 0xa0, 0xd9, 0x5c, 0xc, 0x12, 0xb5, 0xfe, 0x54}; + uint8_t bytes7[] = {0xad, 0xf5, 0xa2, 0xc1, 0x43, 0xf9, 0x9, 0x7f, 0x30, 0x23, + 0xec, 0x8e, 0xaf, 0x95, 0x59, 0x29, 0xd1, 0xa1, 0x93, 0x17}; + uint8_t bytes9[] = {0x51, 0xeb, 0x26, 0x12, 0x9f, 0x11, 0x3e, 0x16, 0xc2, 0x12, 0x31, 0x15, + 0xfe, 0xb1, 0x23, 0x5b, 0xda, 0xda, 0x56, 0x62, 0x9f, 0xc5, 0x70, 0x3c}; + uint8_t bytes8[] = {0x9, 0x94, 0x88, 0x8a, 0xf1, 0x3, 0xc6, 0x18, 0x82, 0x93, 0xba, + 0x94, 0xab, 0x5d, 0xda, 0x49, 0x7f, 0x9e, 0xae, 0x34, 0x8e}; + uint8_t bytes10[] = {0x64, 0x23, 0x70, 0xfd, 0xb5, 0xed, 0xbe, 0xb, 0x3e, 0x26, 0x11, 0x96, + 0xc1, 0x62, 0x45, 0x3b, 0x86, 0x5, 0xb5, 0xc6, 0x2a, 0x5d, 0xcf, 0x69}; + uint8_t bytes11[] = {0x98, 0xa8, 0x3, 0x5c, 0xde, 0x76, 0x25, 0xfc, 0x6f, 0xb9, 0x39, 0xb8, 0x35, 0xbb}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes1}, .v = {22, (char*)&bytes2}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes5}, .v = {15, (char*)&bytes6}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30944}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9769}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes8}, .v = {24, (char*)&bytes9}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytes10}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18301}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytes11}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19410}}, + }; + + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "R\227\143", _pubPktID = 0, _pubBody +// = "\199\n\253\247[u\151,J\129\t\179\246y0]\143\131\146\&4n*\175\136\&6\181\148Z\ETX", _pubProps = +// [PropSubscriptionIdentifier 9,PropWildcardSubscriptionAvailable 205,PropSubscriptionIdentifierAvailable +// 20,PropAuthenticationData "`\215\227\DC3k\194\228\153\&4\r\194\144Q\145\169\131m\DC1\205\213j",PropReasonString +// "=N\196\ETX\FSF\244\&1\160W\203\232|\\,\DC3\172{\254\198\&4Y\170?\156N\NUL",PropReceiveMaximum +// 5394,PropSubscriptionIdentifierAvailable 138,PropSharedSubscriptionAvailable 56,PropServerKeepAlive +// 18116,PropTopicAliasMaximum 27624,PropServerKeepAlive 14050,PropServerKeepAlive +// 27431,PropSubscriptionIdentifierAvailable 88,PropResponseTopic +// "%A\213je\227\&9\143\204\&9u_\162\163\185S\191\177\218",PropWildcardSubscriptionAvailable 46,PropReasonString +// "\186I\218\vN\219\220\201",PropContentType "\194n|\131\DC2c\175\141",PropAuthenticationData +// "/\150\178\178\171\234A\ETX\237\&1w\214\150H",PropSubscriptionIdentifier 21,PropServerKeepAlive +// 7628,PropMessageExpiryInterval 30833]} +TEST(Publish50QCTest, Encode14) { + uint8_t pkt[] = {0x38, 0xbe, 0x1, 0x0, 0x3, 0x52, 0xe3, 0x8f, 0x9a, 0x1, 0xb, 0x9, 0x28, 0xcd, 0x29, 0x14, 0x16, + 0x0, 0x15, 0x60, 0xd7, 0xe3, 0x13, 0x6b, 0xc2, 0xe4, 0x99, 0x34, 0xd, 0xc2, 0x90, 0x51, 0x91, 0xa9, + 0x83, 0x6d, 0x11, 0xcd, 0xd5, 0x6a, 0x1f, 0x0, 0x1b, 0x3d, 0x4e, 0xc4, 0x3, 0x1c, 0x46, 0xf4, 0x31, + 0xa0, 0x57, 0xcb, 0xe8, 0x7c, 0x5c, 0x2c, 0x13, 0xac, 0x7b, 0xfe, 0xc6, 0x34, 0x59, 0xaa, 0x3f, 0x9c, + 0x4e, 0x0, 0x21, 0x15, 0x12, 0x29, 0x8a, 0x2a, 0x38, 0x13, 0x46, 0xc4, 0x22, 0x6b, 0xe8, 0x13, 0x36, + 0xe2, 0x13, 0x6b, 0x27, 0x29, 0x58, 0x8, 0x0, 0x13, 0x25, 0x41, 0xd5, 0x6a, 0x65, 0xe3, 0x39, 0x8f, + 0xcc, 0x39, 0x75, 0x5f, 0xa2, 0xa3, 0xb9, 0x53, 0xbf, 0xb1, 0xda, 0x28, 0x2e, 0x1f, 0x0, 0x8, 0xba, + 0x49, 0xda, 0xb, 0x4e, 0xdb, 0xdc, 0xc9, 0x3, 0x0, 0x8, 0xc2, 0x6e, 0x7c, 0x83, 0x12, 0x63, 0xaf, + 0x8d, 0x16, 0x0, 0xe, 0x2f, 0x96, 0xb2, 0xb2, 0xab, 0xea, 0x41, 0x3, 0xed, 0x31, 0x77, 0xd6, 0x96, + 0x48, 0xb, 0x15, 0x13, 0x1d, 0xcc, 0x2, 0x0, 0x0, 0x78, 0x71, 0xc7, 0xa, 0xfd, 0xf7, 0x5b, 0x75, + 0x97, 0x2c, 0x4a, 0x81, 0x9, 0xb3, 0xf6, 0x79, 0x30, 0x5d, 0x8f, 0x83, 0x92, 0x34, 0x6e, 0x2a, 0xaf, + 0x88, 0x36, 0xb5, 0x94, 0x5a, 0x3}; + + uint8_t buf[203] = {0}; + + uint8_t topic_bytes[] = {0x52, 0xe3, 0x8f}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xc7, 0xa, 0xfd, 0xf7, 0x5b, 0x75, 0x97, 0x2c, 0x4a, 0x81, 0x9, 0xb3, 0xf6, 0x79, 0x30, + 0x5d, 0x8f, 0x83, 0x92, 0x34, 0x6e, 0x2a, 0xaf, 0x88, 0x36, 0xb5, 0x94, 0x5a, 0x3}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; + + uint8_t bytes0[] = {0x60, 0xd7, 0xe3, 0x13, 0x6b, 0xc2, 0xe4, 0x99, 0x34, 0xd, 0xc2, + 0x90, 0x51, 0x91, 0xa9, 0x83, 0x6d, 0x11, 0xcd, 0xd5, 0x6a}; + uint8_t bytes1[] = {0x3d, 0x4e, 0xc4, 0x3, 0x1c, 0x46, 0xf4, 0x31, 0xa0, 0x57, 0xcb, 0xe8, 0x7c, 0x5c, + 0x2c, 0x13, 0xac, 0x7b, 0xfe, 0xc6, 0x34, 0x59, 0xaa, 0x3f, 0x9c, 0x4e, 0x0}; + uint8_t bytes2[] = {0x25, 0x41, 0xd5, 0x6a, 0x65, 0xe3, 0x39, 0x8f, 0xcc, 0x39, + 0x75, 0x5f, 0xa2, 0xa3, 0xb9, 0x53, 0xbf, 0xb1, 0xda}; + uint8_t bytes3[] = {0xba, 0x49, 0xda, 0xb, 0x4e, 0xdb, 0xdc, 0xc9}; + uint8_t bytes4[] = {0xc2, 0x6e, 0x7c, 0x83, 0x12, 0x63, 0xaf, 0x8d}; + uint8_t bytes5[] = {0x2f, 0x96, 0xb2, 0xb2, 0xab, 0xea, 0x41, 0x3, 0xed, 0x31, 0x77, 0xd6, 0x96, 0x48}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5394}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18116}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27624}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14050}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27431}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7628}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30833}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\DEL-\129\&3\194M2T6\ETBV5_#\188$\131T\222\ESC\137\a.\147%b", _pubPktID = 0, _pubBody = +// "\v]\154\169\138\225f:\202\251\DLEgw{\243\150\155\DELc8", _pubProps = [PropWillDelayInterval 7111,PropReasonString +// "\171",PropReasonString "\200\&4\NAKs\227\170{r\135\203\DEL\148\USeA",PropTopicAliasMaximum +// 27837,PropRequestProblemInformation 228,PropMessageExpiryInterval 2640,PropMessageExpiryInterval +// 21020,PropAssignedClientIdentifier "z\208%_;\f\SO3\US\186[\220\191?A\214\162I\248\200\144\172J",PropServerKeepAlive +// 5972,PropSessionExpiryInterval 2704,PropReasonString +// "\"\242\156\182\173n\198\218\207\249\179\194\138\250\145\162y#",PropTopicAliasMaximum 9402,PropRetainAvailable +// 8,PropAssignedClientIdentifier "\167\175 +// \144*\243/N\240p\139\237rMY^\128E\EM\SO_\151\SYN\208u]\181\212\190",PropSubscriptionIdentifier 5,PropReasonString +// "\155\254\128)\188\243\147\FS\239",PropServerReference +// "\EM(\162\209\GS\231\140\&3x\209\187\199E\144\201\213\154\252\248CF\226\&0\188\174]}",PropMaximumQoS 2]} +TEST(Publish50QCTest, Encode15) { + uint8_t pkt[] = {0x30, 0xe6, 0x1, 0x0, 0x1a, 0x7f, 0x2d, 0x81, 0x33, 0xc2, 0x4d, 0x32, 0x54, 0x36, 0x17, 0x56, 0x35, + 0x5f, 0x23, 0xbc, 0x24, 0x83, 0x54, 0xde, 0x1b, 0x89, 0x7, 0x2e, 0x93, 0x25, 0x62, 0xb4, 0x1, 0x18, + 0x0,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 0x3a, + 0xca, 0xfb, 0x10, 0x67, 0x77, 0x7b, 0xf3, 0x96, 0x9b, 0x7f, 0x63, 0x38}; + + uint8_t buf[243] = {0}; + + uint8_t topic_bytes[] = {0x7f, 0x2d, 0x81, 0x33, 0xc2, 0x4d, 0x32, 0x54, 0x36, 0x17, 0x56, 0x35, 0x5f, + 0x23, 0xbc, 0x24, 0x83, 0x54, 0xde, 0x1b, 0x89, 0x7, 0x2e, 0x93, 0x25, 0x62}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xb, 0x5d, 0x9a, 0xa9, 0x8a, 0xe1, 0x66, 0x3a, 0xca, 0xfb, + 0x10, 0x67, 0x77, 0x7b, 0xf3, 0x96, 0x9b, 0x7f, 0x63, 0x38}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 20; + + uint8_t bytes0[] = {0xab}; + uint8_t bytes1[] = {0xc8, 0x34, 0x15, 0x73, 0xe3, 0xaa, 0x7b, 0x72, 0x87, 0xcb, 0x7f, 0x94, 0x1f, 0x65, 0x41}; + uint8_t bytes2[] = {0x7a, 0xd0, 0x25, 0x5f, 0x3b, 0xc, 0xe, 0x33, 0x1f, 0xba, 0x5b, 0xdc, + 0xbf, 0x3f, 0x41, 0xd6, 0xa2, 0x49, 0xf8, 0xc8, 0x90, 0xac, 0x4a}; + uint8_t bytes3[] = {0x22, 0xf2, 0x9c, 0xb6, 0xad, 0x6e, 0xc6, 0xda, 0xcf, + 0xf9, 0xb3, 0xc2, 0x8a, 0xfa, 0x91, 0xa2, 0x79, 0x23}; + uint8_t bytes4[] = {0xa7, 0xaf, 0x20, 0x90, 0x2a, 0xf3, 0x2f, 0x4e, 0xf0, 0x70, 0x8b, 0xed, 0x72, 0x4d, 0x59, + 0x5e, 0x80, 0x45, 0x19, 0xe, 0x5f, 0x97, 0x16, 0xd0, 0x75, 0x5d, 0xb5, 0xd4, 0xbe}; + uint8_t bytes5[] = {0x9b, 0xfe, 0x80, 0x29, 0xbc, 0xf3, 0x93, 0x1c, 0xef}; + uint8_t bytes6[] = {0x19, 0x28, 0xa2, 0xd1, 0x1d, 0xe7, 0x8c, 0x33, 0x78, 0xd1, 0xbb, 0xc7, 0x45, 0x90, + 0xc9, 0xd5, 0x9a, 0xfc, 0xf8, 0x43, 0x46, 0xe2, 0x30, 0xbc, 0xae, 0x5d, 0x7d}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7111}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27837}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2640}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21020}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5972}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2704}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9402}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 2}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\250\181\213\174\156\146\244\243\180\160\170=", _pubPktID = 24114, _pubBody = +// "\GS-\202|\237\STX\ENQ\EM\159\143\130\NAK\242\212\182Cg\172#\193\150v\226", _pubProps = [PropResponseInformation +// "O\196\178g\200\DEL*\ETX\SOH\203\FS\162\159\147\DC1(\164\128\203\&4Y*",PropServerReference +// "5\159n\242\179\fp\164\at",PropPayloadFormatIndicator 46,PropWillDelayInterval 4675,PropMaximumPacketSize +// 11858,PropCorrelationData "\219\221\206\252\181\220\196#}0\243y\ETB\ETBM7R\155u\197\239\242\198\209",PropMaximumQoS +// 169,PropAuthenticationData +// "\189]0\223\235\224P'\131He\\\STX<\172\192\202m\242\149^\ETX\ACK,\151",PropSubscriptionIdentifier +// 17,PropSubscriptionIdentifier 29,PropMaximumQoS 216,PropMaximumPacketSize 19820,PropServerKeepAlive 21055]} +TEST(Publish50QCTest, Encode16) { + uint8_t pkt[] = {0x34, 0xa1, 0x1, 0x0, 0xc, 0xfa, 0xb5, 0xd5, 0xae, 0x9c, 0x92, 0xf4, 0xf3, 0xb4, 0xa0, 0xaa, 0x3d, + 0x5e, 0x32, 0x79, 0x1a, 0x0, 0x16, 0x4f, 0xc4, 0xb2, 0x67, 0xc8, 0x7f, 0x2a, 0x3, 0x1, 0xcb, 0x1c, + 0xa2, 0x9f, 0x93, 0x11, 0x28, 0xa4, 0x80, 0xcb, 0x34, 0x59, 0x2a, 0x1c, 0x0, 0xa, 0x35, 0x9f, 0x6e, + 0xf2, 0xb3, 0xc, 0x70, 0xa4, 0x7, 0x74, 0x1, 0x2e, 0x18, 0x0, 0x0, 0x12, 0x43, 0x27, 0x0, 0x0, + 0x2e, 0x52, 0x9, 0x0, 0x18, 0xdb, 0xdd, 0xce, 0xfc, 0xb5, 0xdc, 0xc4, 0x23, 0x7d, 0x30, 0xf3, 0x79, + 0x17, 0x17, 0x4d, 0x37, 0x52, 0x9b, 0x75, 0xc5, 0xef, 0xf2, 0xc6, 0xd1, 0x24, 0xa9, 0x16, 0x0, 0x19, + 0xbd, 0x5d, 0x30, 0xdf, 0xeb, 0xe0, 0x50, 0x27, 0x83, 0x48, 0x65, 0x5c, 0x2, 0x3c, 0xac, 0xc0, 0xca, + 0x6d, 0xf2, 0x95, 0x5e, 0x3, 0x6, 0x2c, 0x97, 0xb, 0x11, 0xb, 0x1d, 0x24, 0xd8, 0x27, 0x0, 0x0, + 0x4d, 0x6c, 0x13, 0x52, 0x3f, 0x1d, 0x2d, 0xca, 0x7c, 0xed, 0x2, 0x5, 0x19, 0x9f, 0x8f, 0x82, 0x15, + 0xf2, 0xd4, 0xb6, 0x43, 0x67, 0xac, 0x23, 0xc1, 0x96, 0x76, 0xe2}; + + uint8_t buf[174] = {0}; + + uint8_t topic_bytes[] = {0xfa, 0xb5, 0xd5, 0xae, 0x9c, 0x92, 0xf4, 0xf3, 0xb4, 0xa0, 0xaa, 0x3d}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x1d, 0x2d, 0xca, 0x7c, 0xed, 0x2, 0x5, 0x19, 0x9f, 0x8f, 0x82, 0x15, + 0xf2, 0xd4, 0xb6, 0x43, 0x67, 0xac, 0x23, 0xc1, 0x96, 0x76, 0xe2}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 23; + + uint8_t bytes0[] = {0x4f, 0xc4, 0xb2, 0x67, 0xc8, 0x7f, 0x2a, 0x3, 0x1, 0xcb, 0x1c, + 0xa2, 0x9f, 0x93, 0x11, 0x28, 0xa4, 0x80, 0xcb, 0x34, 0x59, 0x2a}; + uint8_t bytes1[] = {0x35, 0x9f, 0x6e, 0xf2, 0xb3, 0xc, 0x70, 0xa4, 0x7, 0x74}; + uint8_t bytes2[] = {0xdb, 0xdd, 0xce, 0xfc, 0xb5, 0xdc, 0xc4, 0x23, 0x7d, 0x30, 0xf3, 0x79, + 0x17, 0x17, 0x4d, 0x37, 0x52, 0x9b, 0x75, 0xc5, 0xef, 0xf2, 0xc6, 0xd1}; + uint8_t bytes3[] = {0xbd, 0x5d, 0x30, 0xdf, 0xeb, 0xe0, 0x50, 0x27, 0x83, 0x48, 0x65, 0x5c, 0x2, + 0x3c, 0xac, 0xc0, 0xca, 0x6d, 0xf2, 0x95, 0x5e, 0x3, 0x6, 0x2c, 0x97}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4675}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11858}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19820}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21055}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24114, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "K\128\243a\178\253\219\184\171;*\244\172'5\EMTE\CAN", _pubPktID = 30980, _pubBody = "c\SUB\219{", _pubProps = +// [PropAuthenticationMethod +// "\199\134\152\&6\187\NAK\133\163\179~@Y[\174&\ty\249X\225w\FS\233I\169",PropAuthenticationMethod +// ">\148\231J\209\131\155\194",PropCorrelationData +// "\187\SYNbg\CAN\237\170\148\218f[\237\223O]d|\DEL\225$J",PropServerKeepAlive 27234,PropAuthenticationMethod +// "q\163e\227C0\SUB",PropTopicAliasMaximum 12959,PropSessionExpiryInterval 4732,PropSessionExpiryInterval +// 30800,PropSubscriptionIdentifierAvailable 78,PropMessageExpiryInterval 29659,PropAuthenticationData +// "\207CIS\172\137X^\145^\ACK\200\"+\200\176\b\225\161\DC2",PropResponseInformation +// "J\213h\132",PropSessionExpiryInterval 16307,PropTopicAliasMaximum 7071,PropSubscriptionIdentifier +// 27,PropAssignedClientIdentifier "\160'\ACK\239\137!\211\CAN{?\133\228j\ETB\ENQkDxZ\131E",PropWillDelayInterval +// 22702,PropMessageExpiryInterval 11660,PropTopicAlias 26640,PropUserProperty +// "\b\SUB\v&'u\133K\210\206o\138d\136\189\&9@)\146u\149\244\&3f\181" +// "\238\227|x\222\246\STX=\DC3w{\SOH\211",PropTopicAlias 29877,PropResponseInformation +// "\200\188\219\154\NAKM\173\191\254I\\S",PropRequestResponseInformation 139,PropRequestResponseInformation +// 199,PropResponseTopic "\DC3\ETXh\253\&0\235g\DC4s\163E\132k\203\190\139\150\232,\169\178\DC3\ETB\215\162&\172\169"]} +TEST(Publish50QCTest, Encode17) { + uint8_t pkt[] = { + 0x3b, 0xaa, 0x2, 0x0, 0x13, 0x4b, 0x80, 0xf3, 0x61, 0xb2, 0xfd, 0xdb, 0xb8, 0xab, 0x3b, 0x2a, 0xf4, 0xac, 0x27, + 0x35, 0x19, 0x54, 0x45, 0x18, 0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 0x6f, 0x8a, 0x64, 0x88, 0xbd, 0x39, 0x40, 0x29, 0x92, 0x75, 0x95, 0xf4, 0x33, 0x66, + 0xb5, 0x0, 0xd, 0xee, 0xe3, 0x7c, 0x78, 0xde, 0xf6, 0x2, 0x3d, 0x13, 0x77, 0x7b, 0x1, 0xd3, 0x23, 0x74, 0xb5, + 0x1a, 0x0, 0xc, 0xc8, 0xbc, 0xdb, 0x9a, 0x15, 0x4d, 0xad, 0xbf, 0xfe, 0x49, 0x5c, 0x53, 0x19, 0x8b, 0x19, 0xc7, + 0x8, 0x0, 0x1c, 0x13, 0x3, 0x68, 0xfd, 0x30, 0xeb, 0x67, 0x14, 0x73, 0xa3, 0x45, 0x84, 0x6b, 0xcb, 0xbe, 0x8b, + 0x96, 0xe8, 0x2c, 0xa9, 0xb2, 0x13, 0x17, 0xd7, 0xa2, 0x26, 0xac, 0xa9, 0x63, 0x1a, 0xdb, 0x7b}; + + uint8_t buf[311] = {0}; + + uint8_t topic_bytes[] = {0x4b, 0x80, 0xf3, 0x61, 0xb2, 0xfd, 0xdb, 0xb8, 0xab, 0x3b, + 0x2a, 0xf4, 0xac, 0x27, 0x35, 0x19, 0x54, 0x45, 0x18}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x63, 0x1a, 0xdb, 0x7b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; + + uint8_t bytes0[] = {0xc7, 0x86, 0x98, 0x36, 0xbb, 0x15, 0x85, 0xa3, 0xb3, 0x7e, 0x40, 0x59, 0x5b, + 0xae, 0x26, 0x9, 0x79, 0xf9, 0x58, 0xe1, 0x77, 0x1c, 0xe9, 0x49, 0xa9}; + uint8_t bytes1[] = {0x3e, 0x94, 0xe7, 0x4a, 0xd1, 0x83, 0x9b, 0xc2}; + uint8_t bytes2[] = {0xbb, 0x16, 0x62, 0x67, 0x18, 0xed, 0xaa, 0x94, 0xda, 0x66, 0x5b, + 0xed, 0xdf, 0x4f, 0x5d, 0x64, 0x7c, 0x7f, 0xe1, 0x24, 0x4a}; + uint8_t bytes3[] = {0x71, 0xa3, 0x65, 0xe3, 0x43, 0x30, 0x1a}; + uint8_t bytes4[] = {0xcf, 0x43, 0x49, 0x53, 0xac, 0x89, 0x58, 0x5e, 0x91, 0x5e, + 0x6, 0xc8, 0x22, 0x2b, 0xc8, 0xb0, 0x8, 0xe1, 0xa1, 0x12}; + uint8_t bytes5[] = {0x4a, 0xd5, 0x68, 0x84}; + uint8_t bytes6[] = {0xa0, 0x27, 0x6, 0xef, 0x89, 0x21, 0xd3, 0x18, 0x7b, 0x3f, 0x85, + 0xe4, 0x6a, 0x17, 0x5, 0x6b, 0x44, 0x78, 0x5a, 0x83, 0x45}; + uint8_t bytes8[] = {0xee, 0xe3, 0x7c, 0x78, 0xde, 0xf6, 0x2, 0x3d, 0x13, 0x77, 0x7b, 0x1, 0xd3}; + uint8_t bytes7[] = {0x8, 0x1a, 0xb, 0x26, 0x27, 0x75, 0x85, 0x4b, 0xd2, 0xce, 0x6f, 0x8a, 0x64, + 0x88, 0xbd, 0x39, 0x40, 0x29, 0x92, 0x75, 0x95, 0xf4, 0x33, 0x66, 0xb5}; + uint8_t bytes9[] = {0xc8, 0xbc, 0xdb, 0x9a, 0x15, 0x4d, 0xad, 0xbf, 0xfe, 0x49, 0x5c, 0x53}; + uint8_t bytes10[] = {0x13, 0x3, 0x68, 0xfd, 0x30, 0xeb, 0x67, 0x14, 0x73, 0xa3, 0x45, 0x84, 0x6b, 0xcb, + 0xbe, 0x8b, 0x96, 0xe8, 0x2c, 0xa9, 0xb2, 0x13, 0x17, 0xd7, 0xa2, 0x26, 0xac, 0xa9}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27234}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12959}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4732}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30800}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29659}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16307}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7071}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22702}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11660}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26640}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytes7}, .v = {13, (char*)&bytes8}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29877}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytes9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytes10}}}, + }; + + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 30980, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "q\133\153L\176\219b\169Cy", _pubPktID +// = 0, _pubBody = "R\253\227\&8\219\234\CANi\174R\250\248\234\146G]X\252\NAK\167/\195\SUB:\GS\182-", _pubProps = +// [PropMessageExpiryInterval 19843,PropSubscriptionIdentifier 31,PropAssignedClientIdentifier +// "\142\128v\185Cql\255\206\&9",PropWildcardSubscriptionAvailable 230,PropMessageExpiryInterval +// 16053,PropWillDelayInterval 26161,PropCorrelationData +// "p\159M\SYN$\nt{\197\200~AN^\136",PropRequestResponseInformation 87,PropRequestResponseInformation 37,PropMaximumQoS +// 209]} +TEST(Publish50QCTest, Encode18) { + uint8_t pkt[] = {0x39, 0x60, 0x0, 0xa, 0x71, 0x85, 0x99, 0x4c, 0xb0, 0xdb, 0x62, 0xa9, 0x43, 0x79, 0x38, 0x2, 0x0, + 0x0, 0x4d, 0x83, 0xb, 0x1f, 0x12, 0x0, 0xa, 0x8e, 0x80, 0x76, 0xb9, 0x43, 0x71, 0x6c, 0xff, 0xce, + 0x39, 0x28, 0xe6, 0x2, 0x0, 0x0, 0x3e, 0xb5, 0x18, 0x0, 0x0, 0x66, 0x31, 0x9, 0x0, 0xf, 0x70, + 0x9f, 0x4d, 0x16, 0x24, 0xa, 0x74, 0x7b, 0xc5, 0xc8, 0x7e, 0x41, 0x4e, 0x5e, 0x88, 0x19, 0x57, 0x19, + 0x25, 0x24, 0xd1, 0x52, 0xfd, 0xe3, 0x38, 0xdb, 0xea, 0x18, 0x69, 0xae, 0x52, 0xfa, 0xf8, 0xea, 0x92, + 0x47, 0x5d, 0x58, 0xfc, 0x15, 0xa7, 0x2f, 0xc3, 0x1a, 0x3a, 0x1d, 0xb6, 0x2d}; + + uint8_t buf[108] = {0}; + + uint8_t topic_bytes[] = {0x71, 0x85, 0x99, 0x4c, 0xb0, 0xdb, 0x62, 0xa9, 0x43, 0x79}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x52, 0xfd, 0xe3, 0x38, 0xdb, 0xea, 0x18, 0x69, 0xae, 0x52, 0xfa, 0xf8, 0xea, 0x92, + 0x47, 0x5d, 0x58, 0xfc, 0x15, 0xa7, 0x2f, 0xc3, 0x1a, 0x3a, 0x1d, 0xb6, 0x2d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 27; + + uint8_t bytes0[] = {0x8e, 0x80, 0x76, 0xb9, 0x43, 0x71, 0x6c, 0xff, 0xce, 0x39}; + uint8_t bytes1[] = {0x70, 0x9f, 0x4d, 0x16, 0x24, 0xa, 0x74, 0x7b, 0xc5, 0xc8, 0x7e, 0x41, 0x4e, 0x5e, 0x88}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19843}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16053}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26161}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 209}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\DC2]^:\232\227~//\232\188z\183\183\&6\248\242", _pubPktID = 31614, _pubBody = +// "g\207\142Q\206\&8\FS#f]\154[\195\180\140FW\182\130\168\&6\191\251\b\214\&0\141", _pubProps = [PropReceiveMaximum +// 12957,PropRequestProblemInformation 52,PropSessionExpiryInterval 17481,PropMaximumQoS 8,PropResponseInformation +// "M\164\SUB\195\a\CAN4\193j\EM\RS\DC4\154\&1\129\200\168:\237\254D\NUL'\227",PropResponseTopic "",PropServerReference +// "'r\202\139\192\&0fnM\183\185",PropSharedSubscriptionAvailable 38,PropTopicAlias 13376,PropServerKeepAlive +// 17639,PropPayloadFormatIndicator 64]} +TEST(Publish50QCTest, Encode19) { + uint8_t pkt[] = {0x3d, 0x73, 0x0, 0x11, 0x12, 0x5d, 0x5e, 0x3a, 0xe8, 0xe3, 0x7e, 0x2f, 0x2f, 0xe8, 0xbc, 0x7a, 0xb7, + 0xb7, 0x36, 0xf8, 0xf2, 0x7b, 0x7e, 0x42, 0x21, 0x32, 0x9d, 0x17, 0x34, 0x11, 0x0, 0x0, 0x44, 0x49, + 0x24, 0x8, 0x1a, 0x0, 0x18, 0x4d, 0xa4, 0x1a, 0xc3, 0x7, 0x18, 0x34, 0xc1, 0x6a, 0x19, 0x1e, 0x14, + 0x9a, 0x31, 0x81, 0xc8, 0xa8, 0x3a, 0xed, 0xfe, 0x44, 0x0, 0x27, 0xe3, 0x8, 0x0, 0x0, 0x1c, 0x0, + 0xb, 0x27, 0x72, 0xca, 0x8b, 0xc0, 0x30, 0x66, 0x6e, 0x4d, 0xb7, 0xb9, 0x2a, 0x26, 0x23, 0x34, 0x40, + 0x13, 0x44, 0xe7, 0x1, 0x40, 0x67, 0xcf, 0x8e, 0x51, 0xce, 0x38, 0x1c, 0x23, 0x66, 0x5d, 0x9a, 0x5b, + 0xc3, 0xb4, 0x8c, 0x46, 0x57, 0xb6, 0x82, 0xa8, 0x36, 0xbf, 0xfb, 0x8, 0xd6, 0x30, 0x8d}; + + uint8_t buf[127] = {0}; + + uint8_t topic_bytes[] = {0x12, 0x5d, 0x5e, 0x3a, 0xe8, 0xe3, 0x7e, 0x2f, 0x2f, + 0xe8, 0xbc, 0x7a, 0xb7, 0xb7, 0x36, 0xf8, 0xf2}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x67, 0xcf, 0x8e, 0x51, 0xce, 0x38, 0x1c, 0x23, 0x66, 0x5d, 0x9a, 0x5b, 0xc3, 0xb4, + 0x8c, 0x46, 0x57, 0xb6, 0x82, 0xa8, 0x36, 0xbf, 0xfb, 0x8, 0xd6, 0x30, 0x8d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 27; + + uint8_t bytes0[] = {0x4d, 0xa4, 0x1a, 0xc3, 0x7, 0x18, 0x34, 0xc1, 0x6a, 0x19, 0x1e, 0x14, + 0x9a, 0x31, 0x81, 0xc8, 0xa8, 0x3a, 0xed, 0xfe, 0x44, 0x0, 0x27, 0xe3}; + uint8_t bytes1[] = {0}; + uint8_t bytes2[] = {0x27, 0x72, 0xca, 0x8b, 0xc0, 0x30, 0x66, 0x6e, 0x4d, 0xb7, 0xb9}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12957}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17481}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13376}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17639}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 64}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 31614, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "y[U\202v\201A\203\136\164\190[\aZ\201\199", _pubPktID = 0, _pubBody = "`\132\CAN\206_pD[R", _pubProps = +// [PropAuthenticationMethod "",PropSubscriptionIdentifier 26,PropTopicAlias 17476,PropReasonString +// "\203\190Y\181\EM\141\216\248R\202\241Fz\153\US\210\233I9\215\226?\238\138\135\238}.",PropSubscriptionIdentifierAvailable +// 151,PropTopicAliasMaximum 576,PropPayloadFormatIndicator 141,PropServerKeepAlive 14965,PropServerReference +// ":\184\148`\218\f{\241\207=\135\198\NAK\166\ENQ\171\176\ETB7\170\&6\196\223\143\154$\249\v",PropWillDelayInterval +// 21964,PropReceiveMaximum 4625,PropAssignedClientIdentifier +// "R\159>E\186\154\156\&0\134\169\200\249\200G\FS^\248\144pX\215\221\228\STX",PropMessageExpiryInterval +// 14507,PropContentType "\253DY\"i\SOHX",PropTopicAlias 4812,PropResponseInformation +// "\142\147\150\140\167;v\247@\174\183\GS\158\187E\212\223m\RS\137 \US\223\197\EOT\228\245\229\230",PropServerKeepAlive +// 27938,PropRetainAvailable 180,PropResponseInformation "\193\241\144\240F5]\202",PropMaximumPacketSize +// 6869,PropRetainAvailable 172]} +TEST(Publish50QCTest, Encode20) { + uint8_t pkt[] = {0x31, 0xd9, 0x1, 0x0, 0x10, 0x79, 0x5b, 0x55, 0xca, 0x76, 0xc9, 0x41, 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, 0xf1, 0x90, 0xf0, 0x46, 0x35, 0x5d, 0xca, + 0x27, 0x0, 0x0, 0x1a, 0xd5, 0x25, 0xac, 0x60, 0x84, 0x18, 0xce, 0x5f, 0x70, 0x44, 0x5b, 0x52}; + + uint8_t buf[230] = {0}; + + uint8_t topic_bytes[] = {0x79, 0x5b, 0x55, 0xca, 0x76, 0xc9, 0x41, 0xcb, + 0x88, 0xa4, 0xbe, 0x5b, 0x7, 0x5a, 0xc9, 0xc7}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x60, 0x84, 0x18, 0xce, 0x5f, 0x70, 0x44, 0x5b, 0x52}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 9; + + uint8_t bytes0[] = {0}; + uint8_t bytes1[] = {0xcb, 0xbe, 0x59, 0xb5, 0x19, 0x8d, 0xd8, 0xf8, 0x52, 0xca, 0xf1, 0x46, 0x7a, 0x99, + 0x1f, 0xd2, 0xe9, 0x49, 0x39, 0xd7, 0xe2, 0x3f, 0xee, 0x8a, 0x87, 0xee, 0x7d, 0x2e}; + uint8_t bytes2[] = {0x3a, 0xb8, 0x94, 0x60, 0xda, 0xc, 0x7b, 0xf1, 0xcf, 0x3d, 0x87, 0xc6, 0x15, 0xa6, + 0x5, 0xab, 0xb0, 0x17, 0x37, 0xaa, 0x36, 0xc4, 0xdf, 0x8f, 0x9a, 0x24, 0xf9, 0xb}; + uint8_t bytes3[] = {0x52, 0x9f, 0x3e, 0x45, 0xba, 0x9a, 0x9c, 0x30, 0x86, 0xa9, 0xc8, 0xf9, + 0xc8, 0x47, 0x1c, 0x5e, 0xf8, 0x90, 0x70, 0x58, 0xd7, 0xdd, 0xe4, 0x2}; + uint8_t bytes4[] = {0xfd, 0x44, 0x59, 0x22, 0x69, 0x1, 0x58}; + uint8_t bytes5[] = {0x8e, 0x93, 0x96, 0x8c, 0xa7, 0x3b, 0x76, 0xf7, 0x40, 0xae, 0xb7, 0x1d, 0x9e, 0xbb, 0x45, + 0xd4, 0xdf, 0x6d, 0x1e, 0x89, 0x20, 0x1f, 0xdf, 0xc5, 0x4, 0xe4, 0xf5, 0xe5, 0xe6}; + uint8_t bytes6[] = {0xc1, 0xf1, 0x90, 0xf0, 0x46, 0x35, 0x5d, 0xca}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17476}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 576}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14965}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21964}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4625}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14507}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4812}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27938}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6869}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 172}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "]\198\"\SUB3J\207\rX", _pubPktID = +// 0, _pubBody = "\132\170$!\216\174\202%\vC\188\240\ETB'b\DC1\134", _pubProps = [PropReasonString +// "\242\150\233\253t\128\ENQQR=\181q\164\&2\138\149x5\183\191i\150\206\SOH\130\202:\220\165",PropServerReference +// "\193\167\&6\DC3\205%\197T\206m\207]$\233f\169\250l\238\ETX\146\186\162\149\b",PropAuthenticationMethod +// "\235D",PropServerKeepAlive 7181]} +TEST(Publish50QCTest, Encode21) { + uint8_t pkt[] = {0x30, 0x61, 0x0, 0x9, 0x5d, 0xc6, 0x22, 0x1a, 0x33, 0x4a, 0xcf, 0xd, 0x58, 0x44, 0x1f, 0x0, 0x1d, + 0xf2, 0x96, 0xe9, 0xfd, 0x74, 0x80, 0x5, 0x51, 0x52, 0x3d, 0xb5, 0x71, 0xa4, 0x32, 0x8a, 0x95, 0x78, + 0x35, 0xb7, 0xbf, 0x69, 0x96, 0xce, 0x1, 0x82, 0xca, 0x3a, 0xdc, 0xa5, 0x1c, 0x0, 0x19, 0xc1, 0xa7, + 0x36, 0x13, 0xcd, 0x25, 0xc5, 0x54, 0xce, 0x6d, 0xcf, 0x5d, 0x24, 0xe9, 0x66, 0xa9, 0xfa, 0x6c, 0xee, + 0x3, 0x92, 0xba, 0xa2, 0x95, 0x8, 0x15, 0x0, 0x2, 0xeb, 0x44, 0x13, 0x1c, 0xd, 0x84, 0xaa, 0x24, + 0x21, 0xd8, 0xae, 0xca, 0x25, 0xb, 0x43, 0xbc, 0xf0, 0x17, 0x27, 0x62, 0x11, 0x86}; + + uint8_t buf[109] = {0}; + + uint8_t topic_bytes[] = {0x5d, 0xc6, 0x22, 0x1a, 0x33, 0x4a, 0xcf, 0xd, 0x58}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x84, 0xaa, 0x24, 0x21, 0xd8, 0xae, 0xca, 0x25, 0xb, + 0x43, 0xbc, 0xf0, 0x17, 0x27, 0x62, 0x11, 0x86}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 17; + + uint8_t bytes0[] = {0xf2, 0x96, 0xe9, 0xfd, 0x74, 0x80, 0x5, 0x51, 0x52, 0x3d, 0xb5, 0x71, 0xa4, 0x32, 0x8a, + 0x95, 0x78, 0x35, 0xb7, 0xbf, 0x69, 0x96, 0xce, 0x1, 0x82, 0xca, 0x3a, 0xdc, 0xa5}; + uint8_t bytes1[] = {0xc1, 0xa7, 0x36, 0x13, 0xcd, 0x25, 0xc5, 0x54, 0xce, 0x6d, 0xcf, 0x5d, 0x24, + 0xe9, 0x66, 0xa9, 0xfa, 0x6c, 0xee, 0x3, 0x92, 0xba, 0xa2, 0x95, 0x8}; + uint8_t bytes2[] = {0xeb, 0x44}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7181}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O&", _pubPktID = 13252, _pubBody = +// "\169\202l\203dz\202-l\161\226\155\212J@v\179", _pubProps = [PropTopicAlias 5304,PropContentType +// "\242\198\130%\ACK3\"\CAN\140\130\179\213\244\243'\233\186#\254\190\199\ETX\205_\214~\218\v\169\&7",PropPayloadFormatIndicator +// 145,PropRequestResponseInformation 129,PropMaximumQoS 20,PropSubscriptionIdentifierAvailable +// 213,PropRequestResponseInformation 30,PropReceiveMaximum 3053,PropPayloadFormatIndicator 10,PropResponseTopic +// "$\SYN\186A\163\197",PropServerReference "\180<)\225k\209u\147\175\&8",PropAuthenticationData +// "\195\130\223\198\139w\DEL\ETB\200k\251\254\234\255\174\"o\FS\233\RS\143",PropPayloadFormatIndicator +// 213,PropRequestResponseInformation 54,PropServerKeepAlive 5613,PropContentType +// "\209?}'\254m\153\215\146\243\201\251\144\SOH\RSQ\ESC \131E\163\SOH\227\GSI/\182B ",PropUserProperty +// "`\EOT-\149[m\210Z\160\154\142\f\NAK\138isz2\230^" +// "\178o\215\223\233\202\182\172\233\200K0U\135\143\197T\197{\FSQ\220",PropRequestResponseInformation +// 138,PropAuthenticationMethod +// "\147V\147\139z\NUL9j\DLE\219\225i!\220\143&\171\&8\188wF@]Y|\253`\FS",PropSessionExpiryInterval 2432]} +TEST(Publish50QCTest, Encode22) { + uint8_t pkt[] = {0x35, 0xf6, 0x1, 0x0, 0x2, 0x4f, 0x26, 0x33, 0xc4, 0xdd, 0x1, 0x23, 0x14, 0xb8, 0x3, 0x0, 0x1e, + 0xf2, 0xc6, 0x82, 0x25, 0x6, 0x33, 0x22, 0x18, 0x8c, 0x82, 0xb3, 0xd5, 0xf4, 0xf3, 0x27, 0xe9, 0xba, + 0x23, 0xfe, 0xbe, 0xc7, 0x3, 0xcd, 0x5f, 0xd6, 0x7e, 0xda, 0xb, 0xa9, 0x37, 0x1, 0x91, 0x19, 0x81, + 0x24, 0x14, 0x29, 0xd5, 0x19, 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 0xa1, 0xe2, 0x9b, 0xd4, 0x4a, 0x40, 0x76, 0xb3}; + + uint8_t buf[259] = {0}; + + uint8_t topic_bytes[] = {0x4f, 0x26}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa9, 0xca, 0x6c, 0xcb, 0x64, 0x7a, 0xca, 0x2d, 0x6c, + 0xa1, 0xe2, 0x9b, 0xd4, 0x4a, 0x40, 0x76, 0xb3}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 17; + + uint8_t bytes0[] = {0xf2, 0xc6, 0x82, 0x25, 0x6, 0x33, 0x22, 0x18, 0x8c, 0x82, 0xb3, 0xd5, 0xf4, 0xf3, 0x27, + 0xe9, 0xba, 0x23, 0xfe, 0xbe, 0xc7, 0x3, 0xcd, 0x5f, 0xd6, 0x7e, 0xda, 0xb, 0xa9, 0x37}; + uint8_t bytes1[] = {0x24, 0x16, 0xba, 0x41, 0xa3, 0xc5}; + uint8_t bytes2[] = {0xb4, 0x3c, 0x29, 0xe1, 0x6b, 0xd1, 0x75, 0x93, 0xaf, 0x38}; + uint8_t bytes3[] = {0xc3, 0x82, 0xdf, 0xc6, 0x8b, 0x77, 0x7f, 0x17, 0xc8, 0x6b, 0xfb, + 0xfe, 0xea, 0xff, 0xae, 0x22, 0x6f, 0x1c, 0xe9, 0x1e, 0x8f}; + uint8_t bytes4[] = {0xd1, 0x3f, 0x7d, 0x27, 0xfe, 0x6d, 0x99, 0xd7, 0x92, 0xf3, 0xc9, 0xfb, 0x90, 0x1, 0x1e, + 0x51, 0x1b, 0x20, 0x83, 0x45, 0xa3, 0x1, 0xe3, 0x1d, 0x49, 0x2f, 0xb6, 0x42, 0x20}; + uint8_t bytes6[] = {0xb2, 0x6f, 0xd7, 0xdf, 0xe9, 0xca, 0xb6, 0xac, 0xe9, 0xc8, 0x4b, + 0x30, 0x55, 0x87, 0x8f, 0xc5, 0x54, 0xc5, 0x7b, 0x1c, 0x51, 0xdc}; + uint8_t bytes5[] = {0x60, 0x4, 0x2d, 0x95, 0x5b, 0x6d, 0xd2, 0x5a, 0xa0, 0x9a, + 0x8e, 0xc, 0x15, 0x8a, 0x69, 0x73, 0x7a, 0x32, 0xe6, 0x5e}; + uint8_t bytes7[] = {0x93, 0x56, 0x93, 0x8b, 0x7a, 0x0, 0x39, 0x6a, 0x10, 0xdb, 0xe1, 0x69, 0x21, 0xdc, + 0x8f, 0x26, 0xab, 0x38, 0xbc, 0x77, 0x46, 0x40, 0x5d, 0x59, 0x7c, 0xfd, 0x60, 0x1c}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5304}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3053}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5613}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytes5}, .v = {22, (char*)&bytes6}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2432}}, + }; + + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 13252, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\v\164J\248\ACKw\168\152\154\236q\RS\ESC\fX\129\180K\FS", _pubPktID = 14693, _pubBody = +// "3MM\195\166\SIw\199E\250\155\253\164\239\US\195\168\222\171\244\206\&7/\SO ?\231\SIK", _pubProps = +// [PropServerKeepAlive 12149,PropMessageExpiryInterval 3682,PropUserProperty "\US" +// "\227\&0RP=\208\227\&6s",PropSubscriptionIdentifier 15,PropSubscriptionIdentifierAvailable +// 12,PropSubscriptionIdentifierAvailable 145,PropRequestResponseInformation 2,PropServerReference +// "\190yV\216\216|\176\DLE\198\\B\131gE\234[\205g\220\252X\US\r\250_\169h]\172",PropPayloadFormatIndicator +// 135,PropResponseTopic "H\142\&67!\178\&8\137c\148\251\172D",PropAuthenticationMethod +// "\222\135\170\SOH\222\221\224\139\130\t\129\ACK",PropAuthenticationMethod +// "\209\192y&\CAN\168\DC3\170m",PropRetainAvailable 19,PropServerKeepAlive 13760,PropSubscriptionIdentifier +// 10,PropWillDelayInterval 3711,PropSubscriptionIdentifier 6]} +TEST(Publish50QCTest, Encode23) { + uint8_t pkt[] = {0x3b, 0xaf, 0x1, 0x0, 0x13, 0xb, 0xa4, 0x4a, 0xf8, 0x6, 0x77, 0xa8, 0x98, 0x9a, 0xec, 0x71, 0x1e, + 0x1b, 0xc, 0x58, 0x81, 0xb4, 0x4b, 0x1c, 0x39, 0x65, 0x7a, 0x13, 0x2f, 0x75, 0x2, 0x0, 0x0, 0xe, + 0x62, 0x26, 0x0, 0x1, 0x1f, 0x0, 0x9, 0xe3, 0x30, 0x52, 0x50, 0x3d, 0xd0, 0xe3, 0x36, 0x73, 0xb, + 0xf, 0x29, 0xc, 0x29, 0x91, 0x19, 0x2, 0x1c, 0x0, 0x1d, 0xbe, 0x79, 0x56, 0xd8, 0xd8, 0x7c, 0xb0, + 0x10, 0xc6, 0x5c, 0x42, 0x83, 0x67, 0x45, 0xea, 0x5b, 0xcd, 0x67, 0xdc, 0xfc, 0x58, 0x1f, 0xd, 0xfa, + 0x5f, 0xa9, 0x68, 0x5d, 0xac, 0x1, 0x87, 0x8, 0x0, 0xd, 0x48, 0x8e, 0x36, 0x37, 0x21, 0xb2, 0x38, + 0x89, 0x63, 0x94, 0xfb, 0xac, 0x44, 0x15, 0x0, 0xc, 0xde, 0x87, 0xaa, 0x1, 0xde, 0xdd, 0xe0, 0x8b, + 0x82, 0x9, 0x81, 0x6, 0x15, 0x0, 0x9, 0xd1, 0xc0, 0x79, 0x26, 0x18, 0xa8, 0x13, 0xaa, 0x6d, 0x25, + 0x13, 0x13, 0x35, 0xc0, 0xb, 0xa, 0x18, 0x0, 0x0, 0xe, 0x7f, 0xb, 0x6, 0x33, 0x4d, 0x4d, 0xc3, + 0xa6, 0xf, 0x77, 0xc7, 0x45, 0xfa, 0x9b, 0xfd, 0xa4, 0xef, 0x1f, 0xc3, 0xa8, 0xde, 0xab, 0xf4, 0xce, + 0x37, 0x2f, 0xe, 0x20, 0x3f, 0xe7, 0xf, 0x4b}; + + uint8_t buf[188] = {0}; + + uint8_t topic_bytes[] = {0xb, 0xa4, 0x4a, 0xf8, 0x6, 0x77, 0xa8, 0x98, 0x9a, 0xec, + 0x71, 0x1e, 0x1b, 0xc, 0x58, 0x81, 0xb4, 0x4b, 0x1c}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x33, 0x4d, 0x4d, 0xc3, 0xa6, 0xf, 0x77, 0xc7, 0x45, 0xfa, 0x9b, 0xfd, 0xa4, 0xef, 0x1f, + 0xc3, 0xa8, 0xde, 0xab, 0xf4, 0xce, 0x37, 0x2f, 0xe, 0x20, 0x3f, 0xe7, 0xf, 0x4b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; + + uint8_t bytes1[] = {0xe3, 0x30, 0x52, 0x50, 0x3d, 0xd0, 0xe3, 0x36, 0x73}; + uint8_t bytes0[] = {0x1f}; + uint8_t bytes2[] = {0xbe, 0x79, 0x56, 0xd8, 0xd8, 0x7c, 0xb0, 0x10, 0xc6, 0x5c, 0x42, 0x83, 0x67, 0x45, 0xea, + 0x5b, 0xcd, 0x67, 0xdc, 0xfc, 0x58, 0x1f, 0xd, 0xfa, 0x5f, 0xa9, 0x68, 0x5d, 0xac}; + uint8_t bytes3[] = {0x48, 0x8e, 0x36, 0x37, 0x21, 0xb2, 0x38, 0x89, 0x63, 0x94, 0xfb, 0xac, 0x44}; + uint8_t bytes4[] = {0xde, 0x87, 0xaa, 0x1, 0xde, 0xdd, 0xe0, 0x8b, 0x82, 0x9, 0x81, 0x6}; + uint8_t bytes5[] = {0xd1, 0xc0, 0x79, 0x26, 0x18, 0xa8, 0x13, 0xaa, 0x6d}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12149}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3682}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytes0}, .v = {9, (char*)&bytes1}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13760}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3711}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + }; + + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 14693, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\220\170\237\142", _pubPktID = 6499, +// _pubBody = "l\EOT h\135\217\143\178&\ETB$1\239@\177~BO}3V\"\176\SOH\255", _pubProps = [PropMaximumQoS +// 153,PropWildcardSubscriptionAvailable 243,PropSubscriptionIdentifierAvailable 215,PropServerKeepAlive +// 1489,PropSessionExpiryInterval 3944,PropSubscriptionIdentifier 29,PropTopicAlias +// 29387,PropSharedSubscriptionAvailable 8,PropAuthenticationData "\219\145\n\255'",PropWildcardSubscriptionAvailable +// 44,PropMessageExpiryInterval 13597,PropTopicAliasMaximum 14055,PropAuthenticationMethod +// "%\164coT\195\n\208",PropSessionExpiryInterval 24863,PropWildcardSubscriptionAvailable +// 167,PropAssignedClientIdentifier "+\163n\142\SO\179\FS\RSS\US@\130\164\157\DC4",PropUserProperty +// "i\189h\197\245)\194\147i\134>\205.\196\239Z\ESC@|\177Q\r\221C\155\241n\193\FS\183" "a7N5$\208\151\213\173\"%\209Nu5 +// \141;\188\184\239\166\164\165\133\DC1\247\253@\132"]} +TEST(Publish50QCTest, Encode24) { + uint8_t pkt[] = {0x3a, 0xaf, 0x1, 0x0, 0x4, 0xdc, 0xaa, 0xed, 0x8e, 0x19, 0x63, 0x8c, 0x1, 0x24, 0x99, 0x28, 0xf3, + 0x29, 0xd7, 0x13, 0x5, 0xd1, 0x11, 0x0, 0x0, 0xf, 0x68, 0xb, 0x1d, 0x23, 0x72, 0xcb, 0x2a, 0x8, + 0x16, 0x0, 0x5, 0xdb, 0x91, 0xa, 0xff, 0x27, 0x28, 0x2c, 0x2, 0x0, 0x0, 0x35, 0x1d, 0x22, 0x36, + 0xe7, 0x15, 0x0, 0x8, 0x25, 0xa4, 0x63, 0x6f, 0x54, 0xc3, 0xa, 0xd0, 0x11, 0x0, 0x0, 0x61, 0x1f, + 0x28, 0xa7, 0x12, 0x0, 0xf, 0x2b, 0xa3, 0x6e, 0x8e, 0xe, 0xb3, 0x1c, 0x1e, 0x53, 0x1f, 0x40, 0x82, + 0xa4, 0x9d, 0x14, 0x26, 0x0, 0x1e, 0x69, 0xbd, 0x68, 0xc5, 0xf5, 0x29, 0xc2, 0x93, 0x69, 0x86, 0x3e, + 0xcd, 0x2e, 0xc4, 0xef, 0x5a, 0x1b, 0x40, 0x7c, 0xb1, 0x51, 0xd, 0xdd, 0x43, 0x9b, 0xf1, 0x6e, 0xc1, + 0x1c, 0xb7, 0x0, 0x1e, 0x61, 0x37, 0x4e, 0x35, 0x24, 0xd0, 0x97, 0xd5, 0xad, 0x22, 0x25, 0xd1, 0x4e, + 0x75, 0x35, 0x20, 0x8d, 0x3b, 0xbc, 0xb8, 0xef, 0xa6, 0xa4, 0xa5, 0x85, 0x11, 0xf7, 0xfd, 0x40, 0x84, + 0x6c, 0x4, 0x20, 0x68, 0x87, 0xd9, 0x8f, 0xb2, 0x26, 0x17, 0x24, 0x31, 0xef, 0x40, 0xb1, 0x7e, 0x42, + 0x4f, 0x7d, 0x33, 0x56, 0x22, 0xb0, 0x1, 0xff}; + + uint8_t buf[188] = {0}; + + uint8_t topic_bytes[] = {0xdc, 0xaa, 0xed, 0x8e}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x6c, 0x4, 0x20, 0x68, 0x87, 0xd9, 0x8f, 0xb2, 0x26, 0x17, 0x24, 0x31, 0xef, + 0x40, 0xb1, 0x7e, 0x42, 0x4f, 0x7d, 0x33, 0x56, 0x22, 0xb0, 0x1, 0xff}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 25; + + uint8_t bytes0[] = {0xdb, 0x91, 0xa, 0xff, 0x27}; + uint8_t bytes1[] = {0x25, 0xa4, 0x63, 0x6f, 0x54, 0xc3, 0xa, 0xd0}; + uint8_t bytes2[] = {0x2b, 0xa3, 0x6e, 0x8e, 0xe, 0xb3, 0x1c, 0x1e, 0x53, 0x1f, 0x40, 0x82, 0xa4, 0x9d, 0x14}; + uint8_t bytes4[] = {0x61, 0x37, 0x4e, 0x35, 0x24, 0xd0, 0x97, 0xd5, 0xad, 0x22, 0x25, 0xd1, 0x4e, 0x75, 0x35, + 0x20, 0x8d, 0x3b, 0xbc, 0xb8, 0xef, 0xa6, 0xa4, 0xa5, 0x85, 0x11, 0xf7, 0xfd, 0x40, 0x84}; + uint8_t bytes3[] = {0x69, 0xbd, 0x68, 0xc5, 0xf5, 0x29, 0xc2, 0x93, 0x69, 0x86, 0x3e, 0xcd, 0x2e, 0xc4, 0xef, + 0x5a, 0x1b, 0x40, 0x7c, 0xb1, 0x51, 0xd, 0xdd, 0x43, 0x9b, 0xf1, 0x6e, 0xc1, 0x1c, 0xb7}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1489}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3944}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29387}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13597}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14055}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24863}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytes3}, .v = {30, (char*)&bytes4}}}}, + }; + + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6499, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\245Y\170\235\232x1\238Y\148", +// _pubPktID = 0, _pubBody = "\139\217\168\150q\SYN\144\176\SO\NAK\147\237", _pubProps = [PropResponseInformation +// "\215\214\227\224\235\211\&1N\159_QX\201x\FS\212\153m\NAK\135\222\SOq}\206a\GS",PropReceiveMaximum +// 3917,PropSubscriptionIdentifier 14,PropMaximumQoS 11,PropPayloadFormatIndicator 61,PropServerKeepAlive +// 13351,PropRequestProblemInformation 172,PropServerReference "\181",PropSubscriptionIdentifierAvailable 167]} +TEST(Publish50QCTest, Encode25) { + uint8_t pkt[] = {0x38, 0x4b, 0x0, 0xa, 0xf5, 0x59, 0xaa, 0xeb, 0xe8, 0x78, 0x31, 0xee, 0x59, 0x94, 0x32, 0x1a, + 0x0, 0x1b, 0xd7, 0xd6, 0xe3, 0xe0, 0xeb, 0xd3, 0x31, 0x4e, 0x9f, 0x5f, 0x51, 0x58, 0xc9, 0x78, + 0x1c, 0xd4, 0x99, 0x6d, 0x15, 0x87, 0xde, 0xe, 0x71, 0x7d, 0xce, 0x61, 0x1d, 0x21, 0xf, 0x4d, + 0xb, 0xe, 0x24, 0xb, 0x1, 0x3d, 0x13, 0x34, 0x27, 0x17, 0xac, 0x1c, 0x0, 0x1, 0xb5, 0x29, + 0xa7, 0x8b, 0xd9, 0xa8, 0x96, 0x71, 0x16, 0x90, 0xb0, 0xe, 0x15, 0x93, 0xed}; + + uint8_t buf[87] = {0}; + + uint8_t topic_bytes[] = {0xf5, 0x59, 0xaa, 0xeb, 0xe8, 0x78, 0x31, 0xee, 0x59, 0x94}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x8b, 0xd9, 0xa8, 0x96, 0x71, 0x16, 0x90, 0xb0, 0xe, 0x15, 0x93, 0xed}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; + + uint8_t bytes0[] = {0xd7, 0xd6, 0xe3, 0xe0, 0xeb, 0xd3, 0x31, 0x4e, 0x9f, 0x5f, 0x51, 0x58, 0xc9, 0x78, + 0x1c, 0xd4, 0x99, 0x6d, 0x15, 0x87, 0xde, 0xe, 0x71, 0x7d, 0xce, 0x61, 0x1d}; + uint8_t bytes1[] = {0xb5}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3917}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13351}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 167}}, + }; + + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\DC4\225[\128A\SUB\229p\254\164'\187\153F\223\219\&3\FS\US~\247\227\SYN(B\177\172", _pubPktID = 927, _pubBody = +// "b\DELS\153v\176m?\201\248\140\EOTe\174\196\EM\253\FS", _pubProps = [PropResponseTopic +// "\t\v\152\222\231a\251\233\ENQ{'\176",PropAuthenticationMethod "-\183]\ETX*",PropUserProperty "\227F\131\144" +// "\251\139\229\208\248\DELV",PropPayloadFormatIndicator 126,PropServerKeepAlive 123]} +TEST(Publish50QCTest, Encode26) { + uint8_t pkt[] = {0x34, 0x5e, 0x0, 0x1b, 0x14, 0xe1, 0x5b, 0x80, 0x41, 0x1a, 0xe5, 0x70, 0xfe, 0xa4, 0x27, 0xbb, + 0x99, 0x46, 0xdf, 0xdb, 0x33, 0x1c, 0x1f, 0x7e, 0xf7, 0xe3, 0x16, 0x28, 0x42, 0xb1, 0xac, 0x3, + 0x9f, 0x2c, 0x8, 0x0, 0xc, 0x9, 0xb, 0x98, 0xde, 0xe7, 0x61, 0xfb, 0xe9, 0x5, 0x7b, 0x27, + 0xb0, 0x15, 0x0, 0x5, 0x2d, 0xb7, 0x5d, 0x3, 0x2a, 0x26, 0x0, 0x4, 0xe3, 0x46, 0x83, 0x90, + 0x0, 0x7, 0xfb, 0x8b, 0xe5, 0xd0, 0xf8, 0x7f, 0x56, 0x1, 0x7e, 0x13, 0x0, 0x7b, 0x62, 0x7f, + 0x53, 0x99, 0x76, 0xb0, 0x6d, 0x3f, 0xc9, 0xf8, 0x8c, 0x4, 0x65, 0xae, 0xc4, 0x19, 0xfd, 0x1c}; + + uint8_t buf[106] = {0}; + + uint8_t topic_bytes[] = {0x14, 0xe1, 0x5b, 0x80, 0x41, 0x1a, 0xe5, 0x70, 0xfe, 0xa4, 0x27, 0xbb, 0x99, 0x46, + 0xdf, 0xdb, 0x33, 0x1c, 0x1f, 0x7e, 0xf7, 0xe3, 0x16, 0x28, 0x42, 0xb1, 0xac}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x62, 0x7f, 0x53, 0x99, 0x76, 0xb0, 0x6d, 0x3f, 0xc9, + 0xf8, 0x8c, 0x4, 0x65, 0xae, 0xc4, 0x19, 0xfd, 0x1c}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 18; + + uint8_t bytes0[] = {0x9, 0xb, 0x98, 0xde, 0xe7, 0x61, 0xfb, 0xe9, 0x5, 0x7b, 0x27, 0xb0}; + uint8_t bytes1[] = {0x2d, 0xb7, 0x5d, 0x3, 0x2a}; + uint8_t bytes3[] = {0xfb, 0x8b, 0xe5, 0xd0, 0xf8, 0x7f, 0x56}; + uint8_t bytes2[] = {0xe3, 0x46, 0x83, 0x90}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytes2}, .v = {7, (char*)&bytes3}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 123}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 927, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\132\158\245\v\236\159\129\175\159j(", _pubPktID = 19519, _pubBody = +// "\222Ut\223\169\215\ACK\238\228\137\147Z\EM\196", _pubProps = [PropWillDelayInterval 25128,PropContentType +// "\241I#\247\141\201\EM\242y\182F^\204\138\a{c\230 ",PropServerReference +// "\136\&3\200\214\186\212\US\156\169\&7\SOH\138\147\&6s\189\US\240\171",PropRequestResponseInformation +// 54,PropReasonString +// "-\218&\130\225\167<6\247B\b\224\178\241\ESC\244\248eV!\ACK\133n\235\&5\255k\144\242",PropRequestProblemInformation +// 109,PropTopicAlias 26984,PropCorrelationData "=\SYN(\SI\DLE\213\139v\191\214 +// (E\143\213\210\232\DC3",PropServerKeepAlive 16628,PropMaximumPacketSize 29670,PropUserProperty "L\248\199^\157o" +// "`\139\175\"\215A\ESC\195\207\CAN\SUB\195\137\SUBFz\159\&2*\DC33R\174\n=[\246C",PropCorrelationData "&\GS"]} +TEST(Publish50QCTest, Encode32) { + uint8_t pkt[] = { + 0x3a, 0xa5, 0x2, 0x0, 0x1a, 0x57, 0x28, 0x70, 0x4, 0xd7, 0x2c, 0x43, 0xa7, 0x4, 0x4a, 0x89, 0xf7, 0x43, 0x5c, + 0xb7, 0x2e, 0x83, 0xab, 0x7f, 0x44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0x76, 0xbf, 0xd6, 0x20, 0x28, 0x45, 0x8f, 0xd5, 0xd2, 0xe8, 0x13, 0x13, 0x40, 0xf4, 0x27, 0x0, + 0x0, 0x73, 0xe6, 0x26, 0x0, 0x6, 0x4c, 0xf8, 0xc7, 0x5e, 0x9d, 0x6f, 0x0, 0x1c, 0x60, 0x8b, 0xaf, 0x22, 0xd7, + 0x41, 0x1b, 0xc3, 0xcf, 0x18, 0x1a, 0xc3, 0x89, 0x1a, 0x46, 0x7a, 0x9f, 0x32, 0x2a, 0x13, 0x33, 0x52, 0xae, 0xa, + 0x3d, 0x5b, 0xf6, 0x43, 0x9, 0x0, 0x2, 0x26, 0x1d, 0x83, 0xda, 0x2b, 0x13, 0x59, 0x2e, 0xf4, 0x3d, 0xd9, 0x4a, + 0xad, 0x68, 0xf5, 0xf8, 0xee, 0x38, 0x79, 0x44, 0xdb, 0x75, 0xf1}; + + uint8_t buf[306] = {0}; + + uint8_t topic_bytes[] = {0x57, 0x28, 0x70, 0x4, 0xd7, 0x2c, 0x43, 0xa7, 0x4, 0x4a, 0x89, 0xf7, 0x43, + 0x5c, 0xb7, 0x2e, 0x83, 0xab, 0x7f, 0x44, 0x24, 0xc3, 0x2a, 0xd3, 0x17, 0xb5}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x83, 0xda, 0x2b, 0x13, 0x59, 0x2e, 0xf4, 0x3d, 0xd9, 0x4a, 0xad, + 0x68, 0xf5, 0xf8, 0xee, 0x38, 0x79, 0x44, 0xdb, 0x75, 0xf1}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 21; + + uint8_t bytes0[] = {0x61, 0xf}; + uint8_t bytes1[] = {0x60, 0x24, 0xf3, 0x31, 0xd1, 0x44, 0xe, 0xe5, 0x44}; + uint8_t bytes2[] = {0xcc, 0xc6, 0xde, 0xc4, 0xd0, 0x6c, 0x1d, 0x2e}; + uint8_t bytes3[] = {0x4c, 0x4a, 0xc7, 0x2a, 0x52, 0x94, 0x7c, 0xa}; + uint8_t bytes4[] = {0xf7, 0x8, 0x68, 0xff, 0x44, 0x68, 0x8e, 0xe0, 0xb2, 0x37, 0x95, + 0xff, 0xb7, 0xd2, 0xf1, 0x96, 0xa3, 0xbd, 0x0, 0xab, 0xa8, 0x46}; + uint8_t bytes5[] = {0xbe, 0x93, 0x95, 0xae, 0xa8, 0x7d, 0xb, 0xd3, 0xa8, 0xe1, 0x67, 0x7b, 0x9e, 0xfe, 0x5d}; + uint8_t bytes6[] = {0}; + uint8_t bytes7[] = {0xc1, 0x9d, 0x6b, 0xa7, 0xf3, 0x45, 0x9c, 0x97, 0xee, 0x86, 0xb1}; + uint8_t bytes8[] = {0xfb, 0x7b, 0x4f, 0xd5, 0xb1, 0xf3, 0x69, 0x1d, 0x3e, 0x56, + 0x21, 0x6, 0x85, 0x6e, 0xeb, 0x35, 0xff, 0x6b, 0x90, 0xf2}; + uint8_t bytes9[] = {0x3d, 0x16, 0x28, 0xf, 0x10, 0xd5, 0x8b, 0x76, 0xbf, + 0xd6, 0x20, 0x28, 0x45, 0x8f, 0xd5, 0xd2, 0xe8, 0x13}; + uint8_t bytes11[] = {0x60, 0x8b, 0xaf, 0x22, 0xd7, 0x41, 0x1b, 0xc3, 0xcf, 0x18, 0x1a, 0xc3, 0x89, 0x1a, + 0x46, 0x7a, 0x9f, 0x32, 0x2a, 0x13, 0x33, 0x52, 0xae, 0xa, 0x3d, 0x5b, 0xf6, 0x43}; + uint8_t bytes10[] = {0x4c, 0xf8, 0xc7, 0x5e, 0x9d, 0x6f}; + uint8_t bytes12[] = {0x26, 0x1d}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28080}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14149}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28296}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1889}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytes8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26984}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytes9}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16628}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29670}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytes10}, .v = {28, (char*)&bytes11}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytes12}}}, + }; + + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 21051, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\231\ACK\254\SIp\166\135\GS[\235\245\182#\181\186\172xu\EOT", _pubPktID = 0, _pubBody = +// "\170\DC1*\DC3\196\248-\191\212\142:", _pubProps = [PropResponseTopic +// "\180\238>\147\208\SOH\254\251\ESC",PropSubscriptionIdentifier 21]} +TEST(Publish50QCTest, Encode33) { + uint8_t pkt[] = {0x38, 0x2f, 0x0, 0x13, 0xe7, 0x6, 0xfe, 0xf, 0x70, 0xa6, 0x87, 0x1d, 0x5b, 0xeb, 0xf5, 0xb6, 0x23, + 0xb5, 0xba, 0xac, 0x78, 0x75, 0x4, 0xe, 0x8, 0x0, 0x9, 0xb4, 0xee, 0x3e, 0x93, 0xd0, 0x1, 0xfe, + 0xfb, 0x1b, 0xb, 0x15, 0xaa, 0x11, 0x2a, 0x13, 0xc4, 0xf8, 0x2d, 0xbf, 0xd4, 0x8e, 0x3a}; + + uint8_t buf[59] = {0}; + + uint8_t topic_bytes[] = {0xe7, 0x6, 0xfe, 0xf, 0x70, 0xa6, 0x87, 0x1d, 0x5b, 0xeb, + 0xf5, 0xb6, 0x23, 0xb5, 0xba, 0xac, 0x78, 0x75, 0x4}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xaa, 0x11, 0x2a, 0x13, 0xc4, 0xf8, 0x2d, 0xbf, 0xd4, 0x8e, 0x3a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 11; + + uint8_t bytes0[] = {0xb4, 0xee, 0x3e, 0x93, 0xd0, 0x1, 0xfe, 0xfb, 0x1b}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + }; + + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\ESCe\222q\DC1?.N\128}{W\237:\250\ETB\SI\252(g\SIX\130\171\252\158", _pubPktID = 0, _pubBody = "\180v", _pubProps = +// [PropMessageExpiryInterval 24162,PropTopicAlias 24090,PropServerReference "REo48Y9Q\149",PropAuthenticationMethod +// "\188\138\ENQX\201t\192|\160\158A",PropSessionExpiryInterval 25361,PropContentType +// "\142\&9\178i\US\239\&7\189\170\&0\a\"}\227",PropCorrelationData "L",PropResponseTopic +// "\213\193\150\&7Fr_",PropRequestResponseInformation 78,PropRequestResponseInformation 14,PropWillDelayInterval 93]} +TEST(Publish50QCTest, Encode34) { + uint8_t pkt[] = {0x31, 0x6e, 0x0, 0x1a, 0x1b, 0x65, 0xde, 0x71, 0x11, 0x3f, 0x2e, 0x4e, 0x80, 0x7d, 0x7b, 0x57, + 0xed, 0x3a, 0xfa, 0x17, 0xf, 0xfc, 0x28, 0x67, 0xf, 0x58, 0x82, 0xab, 0xfc, 0x9e, 0x4f, 0x2, + 0x0, 0x0, 0x5e, 0x62, 0x23, 0x5e, 0x1a, 0x1c, 0x0, 0x9, 0x52, 0x45, 0x6f, 0x34, 0x38, 0x59, + 0x39, 0x51, 0x95, 0x15, 0x0, 0xb, 0xbc, 0x8a, 0x5, 0x58, 0xc9, 0x74, 0xc0, 0x7c, 0xa0, 0x9e, + 0x41, 0x11, 0x0, 0x0, 0x63, 0x11, 0x3, 0x0, 0xe, 0x8e, 0x39, 0xb2, 0x69, 0x1f, 0xef, 0x37, + 0xbd, 0xaa, 0x30, 0x7, 0x22, 0x7d, 0xe3, 0x9, 0x0, 0x1, 0x4c, 0x8, 0x0, 0x7, 0xd5, 0xc1, + 0x96, 0x37, 0x46, 0x72, 0x5f, 0x19, 0x4e, 0x19, 0xe, 0x18, 0x0, 0x0, 0x0, 0x5d, 0xb4, 0x76}; + + uint8_t buf[122] = {0}; + + uint8_t topic_bytes[] = {0x1b, 0x65, 0xde, 0x71, 0x11, 0x3f, 0x2e, 0x4e, 0x80, 0x7d, 0x7b, 0x57, 0xed, + 0x3a, 0xfa, 0x17, 0xf, 0xfc, 0x28, 0x67, 0xf, 0x58, 0x82, 0xab, 0xfc, 0x9e}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xb4, 0x76}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 2; + + uint8_t bytes0[] = {0x52, 0x45, 0x6f, 0x34, 0x38, 0x59, 0x39, 0x51, 0x95}; + uint8_t bytes1[] = {0xbc, 0x8a, 0x5, 0x58, 0xc9, 0x74, 0xc0, 0x7c, 0xa0, 0x9e, 0x41}; + uint8_t bytes2[] = {0x8e, 0x39, 0xb2, 0x69, 0x1f, 0xef, 0x37, 0xbd, 0xaa, 0x30, 0x7, 0x22, 0x7d, 0xe3}; + uint8_t bytes3[] = {0x4c}; + uint8_t bytes4[] = {0xd5, 0xc1, 0x96, 0x37, 0x46, 0x72, 0x5f}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24162}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24090}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25361}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 93}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "6\228\247(\SUB\248\195J\179", +// _pubPktID = 16923, _pubBody = "\178", _pubProps = [PropAuthenticationMethod +// "\234\136\193aZ;\148q\168\187I\195\153\248\&5\254\128Q*\180\ACK?\163",PropAuthenticationMethod +// "\ESC'\133^\151\214\151|vvyL\FS4",PropAssignedClientIdentifier +// "\244m\214v5\\\169{\168\167\254",PropMessageExpiryInterval 2708,PropReceiveMaximum 21750,PropReceiveMaximum +// 22454,PropSubscriptionIdentifierAvailable 222,PropSharedSubscriptionAvailable 117,PropServerReference +// "\NUL\"\157p\189\208\177\184d",PropReceiveMaximum 13520,PropSubscriptionIdentifierAvailable 208,PropMaximumQoS +// 87,PropMessageExpiryInterval 14331,PropMaximumPacketSize 15803,PropUserProperty "\247\242\238F\156sz\207\ESC\140" +// "\212\195\252\ACK\242\203\STX\SI\157@\231\157\226J\SOd\136",PropServerKeepAlive 15692,PropMessageExpiryInterval +// 26840,PropSubscriptionIdentifierAvailable 90,PropServerKeepAlive 7831,PropSubscriptionIdentifier 33,PropResponseTopic +// "M4\224\219A\131"]} +TEST(Publish50QCTest, Encode35) { + uint8_t pkt[] = {0x32, 0xad, 0x1, 0x0, 0x9, 0x36, 0xe4, 0xf7, 0x28, 0x1a, 0xf8, 0xc3, 0x4a, 0xb3, 0x42, 0x1b, + 0x9d, 0x1, 0x15, 0x0, 0x17, 0xea, 0x88, 0xc1, 0x61, 0x5a, 0x3b, 0x94, 0x71, 0xa8, 0xbb, 0x49, + 0xc3, 0x99, 0xf8, 0x35, 0xfe, 0x80, 0x51, 0x2a, 0xb4, 0x6, 0x3f, 0xa3, 0x15, 0x0, 0xe, 0x1b, + 0x27, 0x85, 0x5e, 0x97, 0xd6, 0x97, 0x7c, 0x76, 0x76, 0x79, 0x4c, 0x1c, 0x34, 0x12, 0x0, 0xb, + 0xf4, 0x6d, 0xd6, 0x76, 0x35, 0x5c, 0xa9, 0x7b, 0xa8, 0xa7, 0xfe, 0x2, 0x0, 0x0, 0xa, 0x94, + 0x21, 0x54, 0xf6, 0x21, 0x57, 0xb6, 0x29, 0xde, 0x2a, 0x75, 0x1c, 0x0, 0x9, 0x0, 0x22, 0x9d, + 0x70, 0xbd, 0xd0, 0xb1, 0xb8, 0x64, 0x21, 0x34, 0xd0, 0x29, 0xd0, 0x24, 0x57, 0x2, 0x0, 0x0, + 0x37, 0xfb, 0x27, 0x0, 0x0, 0x3d, 0xbb, 0x26, 0x0, 0xa, 0xf7, 0xf2, 0xee, 0x46, 0x9c, 0x73, + 0x7a, 0xcf, 0x1b, 0x8c, 0x0, 0x11, 0xd4, 0xc3, 0xfc, 0x6, 0xf2, 0xcb, 0x2, 0xf, 0x9d, 0x40, + 0xe7, 0x9d, 0xe2, 0x4a, 0xe, 0x64, 0x88, 0x13, 0x3d, 0x4c, 0x2, 0x0, 0x0, 0x68, 0xd8, 0x29, + 0x5a, 0x13, 0x1e, 0x97, 0xb, 0x21, 0x8, 0x0, 0x6, 0x4d, 0x34, 0xe0, 0xdb, 0x41, 0x83, 0xb2}; + + uint8_t buf[186] = {0}; + + uint8_t topic_bytes[] = {0x36, 0xe4, 0xf7, 0x28, 0x1a, 0xf8, 0xc3, 0x4a, 0xb3}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xb2}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + uint8_t bytes0[] = {0xea, 0x88, 0xc1, 0x61, 0x5a, 0x3b, 0x94, 0x71, 0xa8, 0xbb, 0x49, 0xc3, + 0x99, 0xf8, 0x35, 0xfe, 0x80, 0x51, 0x2a, 0xb4, 0x6, 0x3f, 0xa3}; + uint8_t bytes1[] = {0x1b, 0x27, 0x85, 0x5e, 0x97, 0xd6, 0x97, 0x7c, 0x76, 0x76, 0x79, 0x4c, 0x1c, 0x34}; + uint8_t bytes2[] = {0xf4, 0x6d, 0xd6, 0x76, 0x35, 0x5c, 0xa9, 0x7b, 0xa8, 0xa7, 0xfe}; + uint8_t bytes3[] = {0x0, 0x22, 0x9d, 0x70, 0xbd, 0xd0, 0xb1, 0xb8, 0x64}; + uint8_t bytes5[] = {0xd4, 0xc3, 0xfc, 0x6, 0xf2, 0xcb, 0x2, 0xf, 0x9d, 0x40, 0xe7, 0x9d, 0xe2, 0x4a, 0xe, 0x64, 0x88}; + uint8_t bytes4[] = {0xf7, 0xf2, 0xee, 0x46, 0x9c, 0x73, 0x7a, 0xcf, 0x1b, 0x8c}; + uint8_t bytes6[] = {0x4d, 0x34, 0xe0, 0xdb, 0x41, 0x83}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2708}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21750}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22454}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13520}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14331}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15803}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytes4}, .v = {17, (char*)&bytes5}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15692}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26840}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7831}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 33}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytes6}}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16923, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "B\244\185\173\135\222\r/\201&\STX\197e\196Y\v\221\191\152\GS6r\131\172\188\196", _pubPktID = 7267, _pubBody = +// "ch\183\156\195l\159\210\242\FS\216/\DC4\233", _pubProps = [PropUserProperty +// "\203N\198K\224IH\203\198\DLE\147N\234\219K" +// "\227\b\\J\130\235?\184\140\150_\232m\162\165h\DEL\RS\228?\203[V\252\227",PropResponseTopic +// "\vr#Q#!\234\DEL\252\193\154\132\&8`\195q\242",PropTopicAliasMaximum 25964,PropContentType +// "\f\170E\165\218\161\206}",PropResponseInformation +// "\174c\DEL\131\149I\139W\243\&1\190\201\141<\184\179%6\172\&3n",PropMessageExpiryInterval 18451,PropMaximumQoS +// 102,PropCorrelationData +// "q\205\161\173\218c\176%\177\223\&6.\t\ETX\ESCm\179\248\217M\255\217",PropRequestProblemInformation +// 33,PropRequestProblemInformation 200,PropServerKeepAlive 13697,PropMaximumQoS 35,PropWillDelayInterval +// 2122,PropAuthenticationData "\GSa\b\236\243o\144\\",PropSessionExpiryInterval 3573,PropResponseTopic +// "\173d\FS\194i\204\194\188P\EOT\DELqi/0\233xAo\167\183\253\169\200\194",PropSessionExpiryInterval +// 11523,PropRequestProblemInformation 52,PropMessageExpiryInterval 13459,PropMessageExpiryInterval +// 10166,PropContentType "\159S\208\157\199\165\199\b\176\178\RS\215\157\209"]} +TEST(Publish50QCTest, Encode36) { + uint8_t pkt[] = { + 0x3a, 0x97, 0x2, 0x0, 0x1a, 0x42, 0xf4, 0xb9, 0xad, 0x87, 0xde, 0xd, 0x2f, 0xc9, 0x26, 0x2, 0xc5, 0x65, 0xc4, + 0x59, 0xb, 0xdd, 0xbf, 0x98, 0x1d, 0x36, 0x72, 0x83, 0xac, 0xbc, 0xc4, 0x1c, 0x63, 0xe9, 0x1, 0x26, 0x0, 0xf, + 0xcb, 0x4e, 0xc6, 0x4b, 0xe0, 0x49, 0x48, 0xcb, 0xc6, 0x10, 0x93, 0x4e, 0xea, 0xdb, 0x4b, 0x0, 0x19, 0xe3, 0x8, + 0x5c, 0x4a, 0x82, 0xeb, 0x3f, 0xb8, 0x8c, 0x96, 0x5f, 0xe8, 0x6d, 0xa2, 0xa5, 0x68, 0x7f, 0x1e, 0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0x8, 0xb0, 0xb2, 0x1e, 0xd7, + 0x9d, 0xd1, 0x63, 0x68, 0xb7, 0x9c, 0xc3, 0x6c, 0x9f, 0xd2, 0xf2, 0x1c, 0xd8, 0x2f, 0x14, 0xe9}; + + uint8_t buf[292] = {0}; + + uint8_t topic_bytes[] = {0x42, 0xf4, 0xb9, 0xad, 0x87, 0xde, 0xd, 0x2f, 0xc9, 0x26, 0x2, 0xc5, 0x65, + 0xc4, 0x59, 0xb, 0xdd, 0xbf, 0x98, 0x1d, 0x36, 0x72, 0x83, 0xac, 0xbc, 0xc4}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x63, 0x68, 0xb7, 0x9c, 0xc3, 0x6c, 0x9f, 0xd2, 0xf2, 0x1c, 0xd8, 0x2f, 0x14, 0xe9}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; + + uint8_t bytes1[] = {0xe3, 0x8, 0x5c, 0x4a, 0x82, 0xeb, 0x3f, 0xb8, 0x8c, 0x96, 0x5f, 0xe8, 0x6d, + 0xa2, 0xa5, 0x68, 0x7f, 0x1e, 0xe4, 0x3f, 0xcb, 0x5b, 0x56, 0xfc, 0xe3}; + uint8_t bytes0[] = {0xcb, 0x4e, 0xc6, 0x4b, 0xe0, 0x49, 0x48, 0xcb, 0xc6, 0x10, 0x93, 0x4e, 0xea, 0xdb, 0x4b}; + uint8_t bytes2[] = {0xb, 0x72, 0x23, 0x51, 0x23, 0x21, 0xea, 0x7f, 0xfc, + 0xc1, 0x9a, 0x84, 0x38, 0x60, 0xc3, 0x71, 0xf2}; + uint8_t bytes3[] = {0xc, 0x3c, 0x74, 0x58, 0xfb, 0xc8, 0x3e, 0xaa, 0x45, 0xa5, 0xda, 0xa1, 0xce, 0x7d}; + uint8_t bytes4[] = {0xae, 0x63, 0x7f, 0x83, 0x95, 0x49, 0x8b, 0x57, 0xf3, 0x31, 0xbe, + 0xc9, 0x8d, 0x3c, 0xb8, 0xb3, 0x25, 0x36, 0xac, 0x33, 0x6e}; + uint8_t bytes5[] = {0x71, 0xcd, 0xa1, 0xad, 0xda, 0x63, 0xb0, 0x25, 0xb1, 0xdf, 0x36, + 0x2e, 0x9, 0x3, 0x1b, 0x6d, 0xb3, 0xf8, 0xd9, 0x4d, 0xff, 0xd9}; + uint8_t bytes6[] = {0x1d, 0x61, 0x8, 0xec, 0xf3, 0x6f, 0x90, 0x5c}; + uint8_t bytes7[] = {0xad, 0x64, 0x1c, 0xc2, 0x69, 0xcc, 0xc2, 0xbc, 0x50, 0x4, 0x7f, 0x71, 0x69, + 0x2f, 0x30, 0xe9, 0x78, 0x41, 0x6f, 0xa7, 0xb7, 0xfd, 0xa9, 0xc8, 0xc2}; + uint8_t bytes8[] = {0x9f, 0x53, 0xd0, 0x9d, 0xc7, 0xa5, 0xc7, 0x8, 0xb0, 0xb2, 0x1e, 0xd7, 0x9d, 0xd1}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytes0}, .v = {25, (char*)&bytes1}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25964}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18451}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13697}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2122}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3573}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11523}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13459}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10166}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytes8}}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7267, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\174N\162+\219#\236%2\208\&5p\160Z\132\133%\ENQ\220", _pubPktID = 16245, _pubBody = "\208\219\197i\234Y\159", +// _pubProps = [PropReceiveMaximum 8564,PropMaximumPacketSize 24665,PropAssignedClientIdentifier +// "\231\155\&5a#\225c\170S\192\213\136\SYN\210\214b",PropMessageExpiryInterval 9468,PropPayloadFormatIndicator +// 29,PropAuthenticationData "",PropRequestResponseInformation 140,PropRetainAvailable 51,PropPayloadFormatIndicator +// 167,PropWillDelayInterval 2112,PropMessageExpiryInterval 6975,PropAuthenticationData "j\205`\214\138\133 +// \193O\GS\245\158\206\t\180\217|\NUL_\SO\ACK\EOT",PropSubscriptionIdentifier 2,PropRequestResponseInformation +// 97,PropSharedSubscriptionAvailable 219,PropPayloadFormatIndicator 171,PropSharedSubscriptionAvailable +// 137,PropPayloadFormatIndicator 33,PropAuthenticationMethod +// "\NAK\175]\246\158zrg\164\182y\223\229",PropSubscriptionIdentifierAvailable 211,PropUserProperty "\184\222\225\157B[" +// "\185\201\177\n",PropSubscriptionIdentifier 2,PropSubscriptionIdentifier 11,PropCorrelationData "\135",PropMaximumQoS +// 89,PropReasonString "\230]\196vs\ETXLp\157\143`\r{\187\238\227\133\215-]\202rg\DC4\208AAT\233L",PropReceiveMaximum +// 15736,PropSharedSubscriptionAvailable 99]} +TEST(Publish50QCTest, Encode37) { + uint8_t pkt[] = { + 0x3a, 0xcb, 0x1, 0x0, 0x13, 0xae, 0x4e, 0xa2, 0x2b, 0xdb, 0x23, 0xec, 0x25, 0x32, 0xd0, 0x35, 0x70, 0xa0, 0x5a, + 0x84, 0x85, 0x25, 0x5, 0xdc, 0x3f, 0x75, 0xab, 0x1, 0x21, 0x21, 0x74, 0x27, 0x0, 0x0, 0x60, 0x59, 0x12, 0x0, + 0x10, 0xe7, 0x9b, 0x35, 0x61, 0x23, 0xe1, 0x63, 0xaa, 0x53, 0xc0, 0xd5, 0x88, 0x16, 0xd2, 0xd6, 0x62, 0x2, 0x0, + 0x0, 0x24, 0xfc, 0x1, 0x1d, 0x16, 0x0, 0x0, 0x19, 0x8c, 0x25, 0x33, 0x1, 0xa7, 0x18, 0x0, 0x0, 0x8, 0x40, + 0x2, 0x0, 0x0, 0x1b, 0x3f, 0x16, 0x0, 0x16, 0x6a, 0xcd, 0x60, 0xd6, 0x8a, 0x85, 0x20, 0xc1, 0x4f, 0x1d, 0xf5, + 0x9e, 0xce, 0x9, 0xb4, 0xd9, 0x7c, 0x0, 0x5f, 0xe, 0x6, 0x4, 0xb, 0x2, 0x19, 0x61, 0x2a, 0xdb, 0x1, 0xab, + 0x2a, 0x89, 0x1, 0x21, 0x15, 0x0, 0xd, 0x15, 0xaf, 0x5d, 0xf6, 0x9e, 0x7a, 0x72, 0x67, 0xa4, 0xb6, 0x79, 0xdf, + 0xe5, 0x29, 0xd3, 0x26, 0x0, 0x6, 0xb8, 0xde, 0xe1, 0x9d, 0x42, 0x5b, 0x0, 0x4, 0xb9, 0xc9, 0xb1, 0xa, 0xb, + 0x2, 0xb, 0xb, 0x9, 0x0, 0x1, 0x87, 0x24, 0x59, 0x1f, 0x0, 0x1e, 0xe6, 0x5d, 0xc4, 0x76, 0x73, 0x3, 0x4c, + 0x70, 0x9d, 0x8f, 0x60, 0xd, 0x7b, 0xbb, 0xee, 0xe3, 0x85, 0xd7, 0x2d, 0x5d, 0xca, 0x72, 0x67, 0x14, 0xd0, 0x41, + 0x41, 0x54, 0xe9, 0x4c, 0x21, 0x3d, 0x78, 0x2a, 0x63, 0xd0, 0xdb, 0xc5, 0x69, 0xea, 0x59, 0x9f}; + + uint8_t buf[216] = {0}; + + uint8_t topic_bytes[] = {0xae, 0x4e, 0xa2, 0x2b, 0xdb, 0x23, 0xec, 0x25, 0x32, 0xd0, + 0x35, 0x70, 0xa0, 0x5a, 0x84, 0x85, 0x25, 0x5, 0xdc}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xd0, 0xdb, 0xc5, 0x69, 0xea, 0x59, 0x9f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 7; + + uint8_t bytes0[] = {0xe7, 0x9b, 0x35, 0x61, 0x23, 0xe1, 0x63, 0xaa, 0x53, 0xc0, 0xd5, 0x88, 0x16, 0xd2, 0xd6, 0x62}; + uint8_t bytes1[] = {0}; + uint8_t bytes2[] = {0x6a, 0xcd, 0x60, 0xd6, 0x8a, 0x85, 0x20, 0xc1, 0x4f, 0x1d, 0xf5, + 0x9e, 0xce, 0x9, 0xb4, 0xd9, 0x7c, 0x0, 0x5f, 0xe, 0x6, 0x4}; + uint8_t bytes3[] = {0x15, 0xaf, 0x5d, 0xf6, 0x9e, 0x7a, 0x72, 0x67, 0xa4, 0xb6, 0x79, 0xdf, 0xe5}; + uint8_t bytes5[] = {0xb9, 0xc9, 0xb1, 0xa}; + uint8_t bytes4[] = {0xb8, 0xde, 0xe1, 0x9d, 0x42, 0x5b}; + uint8_t bytes6[] = {0x87}; + uint8_t bytes7[] = {0xe6, 0x5d, 0xc4, 0x76, 0x73, 0x3, 0x4c, 0x70, 0x9d, 0x8f, 0x60, 0xd, 0x7b, 0xbb, 0xee, + 0xe3, 0x85, 0xd7, 0x2d, 0x5d, 0xca, 0x72, 0x67, 0x14, 0xd0, 0x41, 0x41, 0x54, 0xe9, 0x4c}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8564}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24665}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9468}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2112}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6975}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytes4}, .v = {4, (char*)&bytes5}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15736}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, + }; + + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16245, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "(3\136}\227\211\FS\ETB&\222\219I\US\220}\129\253\151", _pubPktID = 28557, _pubBody = "\187|", _pubProps = +// [PropTopicAlias 10592,PropRequestProblemInformation 176,PropMaximumQoS 205,PropContentType +// "\189\FS\171\DC2\230\253\b\138\209",PropWillDelayInterval 8463,PropAssignedClientIdentifier +// "G\169\190\177\189\188^\DLE\128\FS\225P\195S",PropTopicAlias 9332,PropPayloadFormatIndicator +// 45,PropAuthenticationMethod "\149\180\240 \232\238\178Su*g\152\161\239`\137\128o\177I[\147\209",PropCorrelationData +// "\203\178\143\205\232\129\221f\251L\r",PropSubscriptionIdentifierAvailable 226]} +TEST(Publish50QCTest, Encode38) { + uint8_t pkt[] = {0x3d, 0x71, 0x0, 0x12, 0x28, 0x33, 0x88, 0x7d, 0xe3, 0xd3, 0x1c, 0x17, 0x26, 0xde, 0xdb, 0x49, 0x1f, + 0xdc, 0x7d, 0x81, 0xfd, 0x97, 0x6f, 0x8d, 0x58, 0x23, 0x29, 0x60, 0x17, 0xb0, 0x24, 0xcd, 0x3, 0x0, + 0x9, 0xbd, 0x1c, 0xab, 0x12, 0xe6, 0xfd, 0x8, 0x8a, 0xd1, 0x18, 0x0, 0x0, 0x21, 0xf, 0x12, 0x0, + 0xe, 0x47, 0xa9, 0xbe, 0xb1, 0xbd, 0xbc, 0x5e, 0x10, 0x80, 0x1c, 0xe1, 0x50, 0xc3, 0x53, 0x23, 0x24, + 0x74, 0x1, 0x2d, 0x15, 0x0, 0x17, 0x95, 0xb4, 0xf0, 0x20, 0xe8, 0xee, 0xb2, 0x53, 0x75, 0x2a, 0x67, + 0x98, 0xa1, 0xef, 0x60, 0x89, 0x80, 0x6f, 0xb1, 0x49, 0x5b, 0x93, 0xd1, 0x9, 0x0, 0xb, 0xcb, 0xb2, + 0x8f, 0xcd, 0xe8, 0x81, 0xdd, 0x66, 0xfb, 0x4c, 0xd, 0x29, 0xe2, 0xbb, 0x7c}; + + uint8_t buf[125] = {0}; + + uint8_t topic_bytes[] = {0x28, 0x33, 0x88, 0x7d, 0xe3, 0xd3, 0x1c, 0x17, 0x26, + 0xde, 0xdb, 0x49, 0x1f, 0xdc, 0x7d, 0x81, 0xfd, 0x97}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xbb, 0x7c}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 2; + + uint8_t bytes0[] = {0xbd, 0x1c, 0xab, 0x12, 0xe6, 0xfd, 0x8, 0x8a, 0xd1}; + uint8_t bytes1[] = {0x47, 0xa9, 0xbe, 0xb1, 0xbd, 0xbc, 0x5e, 0x10, 0x80, 0x1c, 0xe1, 0x50, 0xc3, 0x53}; + uint8_t bytes2[] = {0x95, 0xb4, 0xf0, 0x20, 0xe8, 0xee, 0xb2, 0x53, 0x75, 0x2a, 0x67, 0x98, + 0xa1, 0xef, 0x60, 0x89, 0x80, 0x6f, 0xb1, 0x49, 0x5b, 0x93, 0xd1}; + uint8_t bytes3[] = {0xcb, 0xb2, 0x8f, 0xcd, 0xe8, 0x81, 0xdd, 0x66, 0xfb, 0x4c, 0xd}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10592}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8463}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9332}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 28557, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\215\235\&1\174\249\STX", +// _pubPktID = 17754, _pubBody = "\246?w\EM\240\218\fF", _pubProps = [PropSharedSubscriptionAvailable +// 232,PropRequestProblemInformation 84,PropResponseTopic +// "~\240\236\DEL\195\&5\EOT\155\245\199\137w\151",PropSharedSubscriptionAvailable 160,PropSubscriptionIdentifier +// 8,PropResponseInformation +// ")\DC4\248\159\150\218\SOH\151X\221\222\185Ywq(\216tR\193\160",PropWildcardSubscriptionAvailable +// 53,PropPayloadFormatIndicator 189,PropTopicAlias 19435,PropResponseInformation +// "\CAN\184\&5\GS\148\&8<\186\232\138\132Z\ETB\t\SOHG",PropResponseInformation +// "\203w\DEL?W\242\235\137\181;3\132)l\188\ESC\190BKL!D\255\179T\152",PropUserProperty +// "\177\145\187\226:\ENQ\153\235\227\STX!\134xs_\191E-C\155\237" +// "\150L/\224\207\227\177a;*v\212K'\198s\174\144\\\DC4\134\142r\131\217",PropAuthenticationData +// "\202\209\214\199\DC1\147\181\254{j\193\EM\208K\157\162\195\175\250\STX\EOTyt\134\209\195HU\180",PropRetainAvailable +// 137,PropSubscriptionIdentifier 12,PropTopicAliasMaximum 17491,PropTopicAliasMaximum 31162,PropSessionExpiryInterval +// 21546,PropTopicAliasMaximum 29484,PropServerKeepAlive 7974,PropResponseInformation "\170\237",PropCorrelationData +// "\SOH\239\149g\SUB\225nz",PropPayloadFormatIndicator 183,PropReasonString "\226\249\t\229}\131Dp= +// {\181",PropServerReference +// "\242\248\183>\ACK\252_\r\209d/`\199\146\228.\a\253\223i\r\175",PropSubscriptionIdentifierAvailable +// 174,PropRetainAvailable 169,PropMaximumPacketSize 922]} +TEST(Publish50QCTest, Encode39) { + uint8_t pkt[] = { + 0x32, 0xa7, 0x2, 0x0, 0x7, 0x15, 0xd7, 0xeb, 0x31, 0xae, 0xf9, 0x2, 0x45, 0x5a, 0x92, 0x2, 0x2a, 0xe8, 0x17, + 0x54, 0x8, 0x0, 0xd, 0x7e, 0xf0, 0xec, 0x7f, 0xc3, 0x35, 0x4, 0x9b, 0xf5, 0xc7, 0x89, 0x77, 0x97, 0x2a, 0xa0, + 0xb, 0x8, 0x1a, 0x0, 0x15, 0x29, 0x14, 0xf8, 0x9f, 0x96, 0xda, 0x1, 0x97, 0x58, 0xdd, 0xde, 0xb9, 0x59, 0x77, + 0x71, 0x28, 0xd8, 0x74, 0x52, 0xc1, 0xa0, 0x28, 0x35, 0x1, 0xbd, 0x23, 0x4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b5, 0x1c, 0x0, 0x16, 0xf2, 0xf8, 0xb7, 0x3e, 0x6, 0xfc, 0x5f, + 0xd, 0xd1, 0x64, 0x2f, 0x60, 0xc7, 0x92, 0xe4, 0x2e, 0x7, 0xfd, 0xdf, 0x69, 0xd, 0xaf, 0x29, 0xae, 0x25, 0xa9, + 0x27, 0x0, 0x0, 0x3, 0x9a, 0xf6, 0x3f, 0x77, 0x19, 0xf0, 0xda, 0xc, 0x46}; + + uint8_t buf[308] = {0}; + + uint8_t topic_bytes[] = {0x15, 0xd7, 0xeb, 0x31, 0xae, 0xf9, 0x2}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xf6, 0x3f, 0x77, 0x19, 0xf0, 0xda, 0xc, 0x46}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 8; + + uint8_t bytes0[] = {0x7e, 0xf0, 0xec, 0x7f, 0xc3, 0x35, 0x4, 0x9b, 0xf5, 0xc7, 0x89, 0x77, 0x97}; + uint8_t bytes1[] = {0x29, 0x14, 0xf8, 0x9f, 0x96, 0xda, 0x1, 0x97, 0x58, 0xdd, 0xde, + 0xb9, 0x59, 0x77, 0x71, 0x28, 0xd8, 0x74, 0x52, 0xc1, 0xa0}; + uint8_t bytes2[] = {0x18, 0xb8, 0x35, 0x1d, 0x94, 0x38, 0x3c, 0xba, 0xe8, 0x8a, 0x84, 0x5a, 0x17, 0x9, 0x1, 0x47}; + uint8_t bytes3[] = {0xcb, 0x77, 0x7f, 0x3f, 0x57, 0xf2, 0xeb, 0x89, 0xb5, 0x3b, 0x33, 0x84, 0x29, + 0x6c, 0xbc, 0x1b, 0xbe, 0x42, 0x4b, 0x4c, 0x21, 0x44, 0xff, 0xb3, 0x54, 0x98}; + uint8_t bytes5[] = {0x96, 0x4c, 0x2f, 0xe0, 0xcf, 0xe3, 0xb1, 0x61, 0x3b, 0x2a, 0x76, 0xd4, 0x4b, + 0x27, 0xc6, 0x73, 0xae, 0x90, 0x5c, 0x14, 0x86, 0x8e, 0x72, 0x83, 0xd9}; + uint8_t bytes4[] = {0xb1, 0x91, 0xbb, 0xe2, 0x3a, 0x5, 0x99, 0xeb, 0xe3, 0x2, 0x21, + 0x86, 0x78, 0x73, 0x5f, 0xbf, 0x45, 0x2d, 0x43, 0x9b, 0xed}; + uint8_t bytes6[] = {0xca, 0xd1, 0xd6, 0xc7, 0x11, 0x93, 0xb5, 0xfe, 0x7b, 0x6a, 0xc1, 0x19, 0xd0, 0x4b, 0x9d, + 0xa2, 0xc3, 0xaf, 0xfa, 0x2, 0x4, 0x79, 0x74, 0x86, 0xd1, 0xc3, 0x48, 0x55, 0xb4}; + uint8_t bytes7[] = {0xaa, 0xed}; + uint8_t bytes8[] = {0x1, 0xef, 0x95, 0x67, 0x1a, 0xe1, 0x6e, 0x7a}; + uint8_t bytes9[] = {0xe2, 0xf9, 0x9, 0xe5, 0x7d, 0x83, 0x44, 0x70, 0x3d, 0x20, 0x7b, 0xb5}; + uint8_t bytes10[] = {0xf2, 0xf8, 0xb7, 0x3e, 0x6, 0xfc, 0x5f, 0xd, 0xd1, 0x64, 0x2f, + 0x60, 0xc7, 0x92, 0xe4, 0x2e, 0x7, 0xfd, 0xdf, 0x69, 0xd, 0xaf}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19435}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes4}, .v = {25, (char*)&bytes5}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17491}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31162}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21546}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29484}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7974}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytes8}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytes9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytes10}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 922}}, + }; + + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17754, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "Q\188\GS\173\231\131\DC4\r\151\251\145\171\&2b\222\209\NUL\250\&4,KR", _pubPktID = 27100, _pubBody = +// "T\DC2\SO\244\150V\ENQ\RS\244\135\238\SIU#[M=#h\232\206U", _pubProps = [PropReceiveMaximum 28857,PropContentType +// "\205\239\167\US\242\FS4A\153\190\193\DC3\173$}\137l\145",PropMessageExpiryInterval 7312,PropResponseTopic +// "\166\196\170\238\"\137\\\216\214P8\t1\181\&1\219\156\236^",PropPayloadFormatIndicator 208,PropServerKeepAlive +// 30404,PropSubscriptionIdentifierAvailable 210,PropRetainAvailable 83,PropResponseInformation +// "\169\137\228`\164\182\a",PropMaximumQoS 101,PropMaximumQoS 252,PropSharedSubscriptionAvailable +// 56,PropMaximumPacketSize 16247]} +TEST(Publish50QCTest, Encode40) { + uint8_t pkt[] = {0x35, 0x82, 0x1, 0x0, 0x16, 0x51, 0xbc, 0x1d, 0xad, 0xe7, 0x83, 0x14, 0xd, 0x97, 0xfb, 0x91, 0xab, + 0x32, 0x62, 0xde, 0xd1, 0x0, 0xfa, 0x34, 0x2c, 0x4b, 0x52, 0x69, 0xdc, 0x51, 0x21, 0x70, 0xb9, 0x3, + 0x0, 0x12, 0xcd, 0xef, 0xa7, 0x1f, 0xf2, 0x1c, 0x34, 0x41, 0x99, 0xbe, 0xc1, 0x13, 0xad, 0x24, 0x7d, + 0x89, 0x6c, 0x91, 0x2, 0x0, 0x0, 0x1c, 0x90, 0x8, 0x0, 0x13, 0xa6, 0xc4, 0xaa, 0xee, 0x22, 0x89, + 0x5c, 0xd8, 0xd6, 0x50, 0x38, 0x9, 0x31, 0xb5, 0x31, 0xdb, 0x9c, 0xec, 0x5e, 0x1, 0xd0, 0x13, 0x76, + 0xc4, 0x29, 0xd2, 0x25, 0x53, 0x1a, 0x0, 0x7, 0xa9, 0x89, 0xe4, 0x60, 0xa4, 0xb6, 0x7, 0x24, 0x65, + 0x24, 0xfc, 0x2a, 0x38, 0x27, 0x0, 0x0, 0x3f, 0x77, 0x54, 0x12, 0xe, 0xf4, 0x96, 0x56, 0x5, 0x1e, + 0xf4, 0x87, 0xee, 0xf, 0x55, 0x23, 0x5b, 0x4d, 0x3d, 0x23, 0x68, 0xe8, 0xce, 0x55}; + + uint8_t buf[143] = {0}; + + uint8_t topic_bytes[] = {0x51, 0xbc, 0x1d, 0xad, 0xe7, 0x83, 0x14, 0xd, 0x97, 0xfb, 0x91, + 0xab, 0x32, 0x62, 0xde, 0xd1, 0x0, 0xfa, 0x34, 0x2c, 0x4b, 0x52}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x54, 0x12, 0xe, 0xf4, 0x96, 0x56, 0x5, 0x1e, 0xf4, 0x87, 0xee, + 0xf, 0x55, 0x23, 0x5b, 0x4d, 0x3d, 0x23, 0x68, 0xe8, 0xce, 0x55}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + uint8_t bytes0[] = {0xcd, 0xef, 0xa7, 0x1f, 0xf2, 0x1c, 0x34, 0x41, 0x99, + 0xbe, 0xc1, 0x13, 0xad, 0x24, 0x7d, 0x89, 0x6c, 0x91}; + uint8_t bytes1[] = {0xa6, 0xc4, 0xaa, 0xee, 0x22, 0x89, 0x5c, 0xd8, 0xd6, 0x50, + 0x38, 0x9, 0x31, 0xb5, 0x31, 0xdb, 0x9c, 0xec, 0x5e}; + uint8_t bytes2[] = {0xa9, 0x89, 0xe4, 0x60, 0xa4, 0xb6, 0x7}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28857}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7312}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30404}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16247}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 27100, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\165\t\199\ESC[\fQ\131\177s\220X\DC1^\151s\198\213/`\162\175,\216o\160h[\ESC", _pubPktID = 0, _pubBody = "\132", +// _pubProps = [PropAssignedClientIdentifier "\150:\SOH\223\195c\DELD",PropContentType +// "",PropWildcardSubscriptionAvailable 127,PropMessageExpiryInterval 1256,PropMaximumQoS 165,PropSubscriptionIdentifier +// 29,PropAssignedClientIdentifier +// "c{\143\174\DC1gN&\201h8\DC1\194\214\207\137\DC3\f\171\160\197\238l\flj\SI\241",PropRetainAvailable +// 246,PropPayloadFormatIndicator 218,PropMaximumQoS 100,PropReceiveMaximum 5446,PropSubscriptionIdentifierAvailable +// 80,PropWildcardSubscriptionAvailable 181,PropUserProperty +// "\164\198R\179r\202K\131`ek\214V\180Nfrk~j",PropWillDelayInterval +// 18837,PropMaximumPacketSize 6933,PropWillDelayInterval 1171,PropRequestProblemInformation 103,PropTopicAliasMaximum +// 27814,PropPayloadFormatIndicator 5,PropRequestResponseInformation 211,PropCorrelationData "\129\&6:\159OC\247"]} +TEST(Publish50QCTest, Encode49) { + uint8_t pkt[] = {0x31, 0x71, 0x0, 0xb, 0x93, 0x1a, 0x0, 0xd7, 0x31, 0x99, 0xca, 0x26, 0x37, 0x39, 0xd, 0x4b, 0x1, + 0x3b, 0x17, 0x9c, 0x28, 0x9b, 0x11, 0x0, 0x0, 0x2c, 0xaa, 0x27, 0x0, 0x0, 0x26, 0x99, 0x8, 0x0, + 0x11, 0xd0, 0x9e, 0xf6, 0x7b, 0x3f, 0xfe, 0x47, 0xa0, 0x7d, 0x86, 0x96, 0x35, 0x9f, 0x9e, 0xdb, 0x98, + 0xc9, 0x1c, 0x0, 0x2, 0x3e, 0x6a, 0x18, 0x0, 0x0, 0x49, 0x95, 0x27, 0x0, 0x0, 0x1b, 0x15, 0x18, + 0x0, 0x0, 0x4, 0x93, 0x17, 0x67, 0x22, 0x6c, 0xa6, 0x1, 0x5, 0x19, 0xd3, 0x9, 0x0, 0x7, 0x81, + 0x36, 0x3a, 0x9f, 0x4f, 0x43, 0xf7, 0x63, 0xd9, 0xca, 0xc1, 0x9c, 0xc7, 0xca, 0xde, 0xe, 0x8f, 0x91, + 0xca, 0x87, 0x88, 0xef, 0x93, 0x5a, 0xc5, 0xf5, 0xc4, 0x85, 0xf9, 0xbf, 0x41}; + + uint8_t buf[125] = {0}; + + uint8_t topic_bytes[] = {0x93, 0x1a, 0x0, 0xd7, 0x31, 0x99, 0xca, 0x26, 0x37, 0x39, 0xd}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x63, 0xd9, 0xca, 0xc1, 0x9c, 0xc7, 0xca, 0xde, 0xe, 0x8f, 0x91, 0xca, + 0x87, 0x88, 0xef, 0x93, 0x5a, 0xc5, 0xf5, 0xc4, 0x85, 0xf9, 0xbf, 0x41}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + uint8_t bytes0[] = {0xd0, 0x9e, 0xf6, 0x7b, 0x3f, 0xfe, 0x47, 0xa0, 0x7d, + 0x86, 0x96, 0x35, 0x9f, 0x9e, 0xdb, 0x98, 0xc9}; + uint8_t bytes1[] = {0x3e, 0x6a}; + uint8_t bytes2[] = {0x81, 0x36, 0x3a, 0x9f, 0x4f, 0x43, 0xf7}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11434}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9881}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18837}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6933}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1171}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27814}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytes2}}}, + }; + + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\199\220\252\SI\147K\173", _pubPktID +// = 22359, _pubBody = "\179\135\192#+E7,\SO&0\CAN\239\145\190\193\159\161\ETX\v\205~yy\158v\209Tt\143", _pubProps = +// [PropSharedSubscriptionAvailable 148,PropAuthenticationData "",PropRequestProblemInformation +// 0,PropMessageExpiryInterval 7957,PropAuthenticationData +// "\146p\161Z\171\190\138j\133\135G\205\t\248\243\204\ETB\228\171\US\150\188\223\&4\f_\ESC",PropReceiveMaximum +// 26413,PropMaximumPacketSize 19648,PropCorrelationData "\219>\138\164.\130",PropSubscriptionIdentifierAvailable +// 113,PropPayloadFormatIndicator 27,PropReasonString "w\233j\150#\243\USpoz\183",PropSubscriptionIdentifier +// 27,PropSubscriptionIdentifier 3]} +TEST(Publish50QCTest, Encode50) { + uint8_t pkt[] = {0x35, 0x7b, 0x0, 0x7, 0xc7, 0xdc, 0xfc, 0xf, 0x93, 0x4b, 0xad, 0x57, 0x57, 0x51, 0x2a, 0x94, + 0x16, 0x0, 0x0, 0x17, 0x0, 0x2, 0x0, 0x0, 0x1f, 0x15, 0x16, 0x0, 0x1b, 0x92, 0x70, 0xa1, + 0x5a, 0xab, 0xbe, 0x8a, 0x6a, 0x85, 0x87, 0x47, 0xcd, 0x9, 0xf8, 0xf3, 0xcc, 0x17, 0xe4, 0xab, + 0x1f, 0x96, 0xbc, 0xdf, 0x34, 0xc, 0x5f, 0x1b, 0x21, 0x67, 0x2d, 0x27, 0x0, 0x0, 0x4c, 0xc0, + 0x9, 0x0, 0x6, 0xdb, 0x3e, 0x8a, 0xa4, 0x2e, 0x82, 0x29, 0x71, 0x1, 0x1b, 0x1f, 0x0, 0xb, + 0x77, 0xe9, 0x6a, 0x96, 0x23, 0xf3, 0x1f, 0x70, 0x6f, 0x7a, 0xb7, 0xb, 0x1b, 0xb, 0x3, 0xb3, + 0x87, 0xc0, 0x23, 0x2b, 0x45, 0x37, 0x2c, 0xe, 0x26, 0x30, 0x18, 0xef, 0x91, 0xbe, 0xc1, 0x9f, + 0xa1, 0x3, 0xb, 0xcd, 0x7e, 0x79, 0x79, 0x9e, 0x76, 0xd1, 0x54, 0x74, 0x8f}; + + uint8_t buf[135] = {0}; + + uint8_t topic_bytes[] = {0xc7, 0xdc, 0xfc, 0xf, 0x93, 0x4b, 0xad}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xb3, 0x87, 0xc0, 0x23, 0x2b, 0x45, 0x37, 0x2c, 0xe, 0x26, 0x30, 0x18, 0xef, 0x91, 0xbe, + 0xc1, 0x9f, 0xa1, 0x3, 0xb, 0xcd, 0x7e, 0x79, 0x79, 0x9e, 0x76, 0xd1, 0x54, 0x74, 0x8f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + uint8_t bytes0[] = {0}; + uint8_t bytes1[] = {0x92, 0x70, 0xa1, 0x5a, 0xab, 0xbe, 0x8a, 0x6a, 0x85, 0x87, 0x47, 0xcd, 0x9, 0xf8, + 0xf3, 0xcc, 0x17, 0xe4, 0xab, 0x1f, 0x96, 0xbc, 0xdf, 0x34, 0xc, 0x5f, 0x1b}; + uint8_t bytes2[] = {0xdb, 0x3e, 0x8a, 0xa4, 0x2e, 0x82}; + uint8_t bytes3[] = {0x77, 0xe9, 0x6a, 0x96, 0x23, 0xf3, 0x1f, 0x70, 0x6f, 0x7a, 0xb7}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7957}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26413}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19648}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 22359, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\225Uc\EM\147>\149\248\SI9\ENQs\211]\179", _pubPktID = 25366, _pubBody = "\165c\155\220\241\175\249\EM\220Bi\224\t", +// _pubProps = [PropMaximumQoS 251,PropSubscriptionIdentifier 23,PropPayloadFormatIndicator 215,PropAuthenticationMethod +// "B1\DC41\FS&,Tt\255\134\153>D\195@",PropMaximumPacketSize 24117,PropRequestProblemInformation +// 232,PropRequestProblemInformation 103,PropRetainAvailable 52,PropMaximumQoS 28,PropSharedSubscriptionAvailable +// 192,PropSubscriptionIdentifierAvailable 18,PropSessionExpiryInterval 4955,PropContentType +// "\187\208",PropResponseInformation "\FS\176\183G\252\230\n\141P\184>\DEL&\190",PropMaximumQoS 222,PropContentType +// "\212\r\243\182\226(\"\232\t\226\168\166\132\\\DC3s\242OY\175\207\195\234\188\163",PropResponseInformation +// "\197\197\&8\161\152\243\146\&4\t\164\237"]} +TEST(Publish50QCTest, Encode51) { + uint8_t pkt[] = {0x32, 0x92, 0x1, 0x0, 0xf, 0xe1, 0x55, 0x63, 0x19, 0x93, 0x3e, 0x95, 0xf8, 0xf, 0x39, 0x5, 0x73, + 0xd3, 0x5d, 0xb3, 0x63, 0x16, 0x71, 0x24, 0xfb, 0xb, 0x17, 0x1, 0xd7, 0x15, 0x0, 0x10, 0x42, 0x31, + 0x14, 0x31, 0x1c, 0x26, 0x2c, 0x54, 0x74, 0xff, 0x86, 0x99, 0x3e, 0x44, 0xc3, 0x40, 0x27, 0x0, 0x0, + 0x5e, 0x35, 0x17, 0xe8, 0x17, 0x67, 0x25, 0x34, 0x24, 0x1c, 0x2a, 0xc0, 0x29, 0x12, 0x11, 0x0, 0x0, + 0x13, 0x5b, 0x3, 0x0, 0x2, 0xbb, 0xd0, 0x1a, 0x0, 0xe, 0x1c, 0xb0, 0xb7, 0x47, 0xfc, 0xe6, 0xa, + 0x8d, 0x50, 0xb8, 0x3e, 0x7f, 0x26, 0xbe, 0x24, 0xde, 0x3, 0x0, 0x19, 0xd4, 0xd, 0xf3, 0xb6, 0xe2, + 0x28, 0x22, 0xe8, 0x9, 0xe2, 0xa8, 0xa6, 0x84, 0x5c, 0x13, 0x73, 0xf2, 0x4f, 0x59, 0xaf, 0xcf, 0xc3, + 0xea, 0xbc, 0xa3, 0x1a, 0x0, 0xb, 0xc5, 0xc5, 0x38, 0xa1, 0x98, 0xf3, 0x92, 0x34, 0x9, 0xa4, 0xed, + 0xa5, 0x63, 0x9b, 0xdc, 0xf1, 0xaf, 0xf9, 0x19, 0xdc, 0x42, 0x69, 0xe0, 0x9}; + + uint8_t buf[159] = {0}; + + uint8_t topic_bytes[] = {0xe1, 0x55, 0x63, 0x19, 0x93, 0x3e, 0x95, 0xf8, 0xf, 0x39, 0x5, 0x73, 0xd3, 0x5d, 0xb3}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xa5, 0x63, 0x9b, 0xdc, 0xf1, 0xaf, 0xf9, 0x19, 0xdc, 0x42, 0x69, 0xe0, 0x9}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; + + uint8_t bytes0[] = {0x42, 0x31, 0x14, 0x31, 0x1c, 0x26, 0x2c, 0x54, 0x74, 0xff, 0x86, 0x99, 0x3e, 0x44, 0xc3, 0x40}; + uint8_t bytes1[] = {0xbb, 0xd0}; + uint8_t bytes2[] = {0x1c, 0xb0, 0xb7, 0x47, 0xfc, 0xe6, 0xa, 0x8d, 0x50, 0xb8, 0x3e, 0x7f, 0x26, 0xbe}; + uint8_t bytes3[] = {0xd4, 0xd, 0xf3, 0xb6, 0xe2, 0x28, 0x22, 0xe8, 0x9, 0xe2, 0xa8, 0xa6, 0x84, + 0x5c, 0x13, 0x73, 0xf2, 0x4f, 0x59, 0xaf, 0xcf, 0xc3, 0xea, 0xbc, 0xa3}; + uint8_t bytes4[] = {0xc5, 0xc5, 0x38, 0xa1, 0x98, 0xf3, 0x92, 0x34, 0x9, 0xa4, 0xed}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24117}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4955}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytes4}}}, + }; + + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 25366, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "sS\f@K\\`9t", _pubPktID = 0, +// _pubBody = "9?\202\215M\ENQvqz\243\164Lg", _pubProps = [PropAssignedClientIdentifier +// "\179\&2\149\157\157\190gRR\140K\EOT\\\161\t\DC2\202`\DEL\200\240\\\a",PropMessageExpiryInterval +// 11207,PropServerReference "\185b+\252\250c\238\250\NAK\193\162Q\252\174\153\203",PropRetainAvailable +// 30,PropTopicAlias 23226,PropContentType "\v\132",PropResponseTopic +// "]U\132\DLE6\131mu\165\ACK\177\254qA?Y!%",PropReceiveMaximum 29851,PropWildcardSubscriptionAvailable +// 64,PropPayloadFormatIndicator 193,PropRetainAvailable 96]} +TEST(Publish50QCTest, Encode52) { + uint8_t pkt[] = {0x30, 0x73, 0x0, 0x9, 0x73, 0x53, 0xc, 0x40, 0x4b, 0x5c, 0x60, 0x39, 0x74, 0x5a, 0x12, 0x0, 0x17, + 0xb3, 0x32, 0x95, 0x9d, 0x9d, 0xbe, 0x67, 0x52, 0x52, 0x8c, 0x4b, 0x4, 0x5c, 0xa1, 0x9, 0x12, 0xca, + 0x60, 0x7f, 0xc8, 0xf0, 0x5c, 0x7, 0x2, 0x0, 0x0, 0x2b, 0xc7, 0x1c, 0x0, 0x10, 0xb9, 0x62, 0x2b, + 0xfc, 0xfa, 0x63, 0xee, 0xfa, 0x15, 0xc1, 0xa2, 0x51, 0xfc, 0xae, 0x99, 0xcb, 0x25, 0x1e, 0x23, 0x5a, + 0xba, 0x3, 0x0, 0x2, 0xb, 0x84, 0x8, 0x0, 0x12, 0x5d, 0x55, 0x84, 0x10, 0x36, 0x83, 0x6d, 0x75, + 0xa5, 0x6, 0xb1, 0xfe, 0x71, 0x41, 0x3f, 0x59, 0x21, 0x25, 0x21, 0x74, 0x9b, 0x28, 0x40, 0x1, 0xc1, + 0x25, 0x60, 0x39, 0x3f, 0xca, 0xd7, 0x4d, 0x5, 0x76, 0x71, 0x7a, 0xf3, 0xa4, 0x4c, 0x67}; + + uint8_t buf[127] = {0}; + + uint8_t topic_bytes[] = {0x73, 0x53, 0xc, 0x40, 0x4b, 0x5c, 0x60, 0x39, 0x74}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x39, 0x3f, 0xca, 0xd7, 0x4d, 0x5, 0x76, 0x71, 0x7a, 0xf3, 0xa4, 0x4c, 0x67}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; + + uint8_t bytes0[] = {0xb3, 0x32, 0x95, 0x9d, 0x9d, 0xbe, 0x67, 0x52, 0x52, 0x8c, 0x4b, 0x4, + 0x5c, 0xa1, 0x9, 0x12, 0xca, 0x60, 0x7f, 0xc8, 0xf0, 0x5c, 0x7}; + uint8_t bytes1[] = {0xb9, 0x62, 0x2b, 0xfc, 0xfa, 0x63, 0xee, 0xfa, 0x15, 0xc1, 0xa2, 0x51, 0xfc, 0xae, 0x99, 0xcb}; + uint8_t bytes2[] = {0xb, 0x84}; + uint8_t bytes3[] = {0x5d, 0x55, 0x84, 0x10, 0x36, 0x83, 0x6d, 0x75, 0xa5, + 0x6, 0xb1, 0xfe, 0x71, 0x41, 0x3f, 0x59, 0x21, 0x25}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11207}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23226}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29851}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 96}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\220", _pubPktID = 0, _pubBody = +// "m>\243z\246\250\139\171?\208F\f\240\232\EOTT`\241\212\SOH\182\b\SI@\228A", _pubProps = [PropSessionExpiryInterval +// 9445,PropCorrelationData "\235\250\159t\140\135\170\166\245a\r\NAK\138",PropSessionExpiryInterval +// 9422,PropPayloadFormatIndicator 100,PropSubscriptionIdentifier 25,PropSharedSubscriptionAvailable +// 182,PropResponseInformation "\221\146\181f\212\187\134\205"]} +TEST(Publish50QCTest, Encode53) { + uint8_t pkt[] = {0x38, 0x49, 0x0, 0x1, 0xdc, 0x2b, 0x11, 0x0, 0x0, 0x24, 0xe5, 0x9, 0x0, 0xd, 0xeb, + 0xfa, 0x9f, 0x74, 0x8c, 0x87, 0xaa, 0xa6, 0xf5, 0x61, 0xd, 0x15, 0x8a, 0x11, 0x0, 0x0, + 0x24, 0xce, 0x1, 0x64, 0xb, 0x19, 0x2a, 0xb6, 0x1a, 0x0, 0x8, 0xdd, 0x92, 0xb5, 0x66, + 0xd4, 0xbb, 0x86, 0xcd, 0x6d, 0x3e, 0xf3, 0x7a, 0xf6, 0xfa, 0x8b, 0xab, 0x3f, 0xd0, 0x46, + 0xc, 0xf0, 0xe8, 0x4, 0x54, 0x60, 0xf1, 0xd4, 0x1, 0xb6, 0x8, 0xf, 0x40, 0xe4, 0x41}; + + uint8_t buf[85] = {0}; + + uint8_t topic_bytes[] = {0xdc}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x6d, 0x3e, 0xf3, 0x7a, 0xf6, 0xfa, 0x8b, 0xab, 0x3f, 0xd0, 0x46, 0xc, 0xf0, + 0xe8, 0x4, 0x54, 0x60, 0xf1, 0xd4, 0x1, 0xb6, 0x8, 0xf, 0x40, 0xe4, 0x41}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + uint8_t bytes0[] = {0xeb, 0xfa, 0x9f, 0x74, 0x8c, 0x87, 0xaa, 0xa6, 0xf5, 0x61, 0xd, 0x15, 0x8a}; + uint8_t bytes1[] = {0xdd, 0x92, 0xb5, 0x66, 0xd4, 0xbb, 0x86, 0xcd}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9445}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9422}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytes1}}}, + }; + + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\f\143\204y\245\248\131\153\248\250\nj\156\173\166\174\GSIv\154\166w\r\136Y", _pubPktID = 0, _pubBody = +// "\177\216D\168\tF\242kx1\247\n", _pubProps = [PropMaximumPacketSize 6251,PropSubscriptionIdentifierAvailable +// 225,PropAuthenticationMethod "\fw\226B\SYN9\175O\182\203\229",PropMessageExpiryInterval +// 1651,PropSubscriptionIdentifier 9,PropResponseTopic +// "\142\234\130\217\SI\206\129\148*I\220\223\172\250yR\180ul\220B\147w\136\213",PropWillDelayInterval +// 23126,PropWildcardSubscriptionAvailable 183]} +TEST(Publish50QCTest, Encode54) { + uint8_t pkt[] = {0x31, 0x67, 0x0, 0x19, 0xc, 0x8f, 0xcc, 0x79, 0xf5, 0xf8, 0x83, 0x99, 0xf8, 0xfa, 0xa, + 0x6a, 0x9c, 0xad, 0xa6, 0xae, 0x1d, 0x49, 0x76, 0x9a, 0xa6, 0x77, 0xd, 0x88, 0x59, 0x3f, + 0x27, 0x0, 0x0, 0x18, 0x6b, 0x29, 0xe1, 0x15, 0x0, 0xb, 0xc, 0x77, 0xe2, 0x42, 0x16, + 0x39, 0xaf, 0x4f, 0xb6, 0xcb, 0xe5, 0x2, 0x0, 0x0, 0x6, 0x73, 0xb, 0x9, 0x8, 0x0, + 0x19, 0x8e, 0xea, 0x82, 0xd9, 0xf, 0xce, 0x81, 0x94, 0x2a, 0x49, 0xdc, 0xdf, 0xac, 0xfa, + 0x79, 0x52, 0xb4, 0x75, 0x6c, 0xdc, 0x42, 0x93, 0x77, 0x88, 0xd5, 0x18, 0x0, 0x0, 0x5a, + 0x56, 0x28, 0xb7, 0xb1, 0xd8, 0x44, 0xa8, 0x9, 0x46, 0xf2, 0x6b, 0x78, 0x31, 0xf7, 0xa}; + + uint8_t buf[115] = {0}; + + uint8_t topic_bytes[] = {0xc, 0x8f, 0xcc, 0x79, 0xf5, 0xf8, 0x83, 0x99, 0xf8, 0xfa, 0xa, 0x6a, 0x9c, + 0xad, 0xa6, 0xae, 0x1d, 0x49, 0x76, 0x9a, 0xa6, 0x77, 0xd, 0x88, 0x59}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xb1, 0xd8, 0x44, 0xa8, 0x9, 0x46, 0xf2, 0x6b, 0x78, 0x31, 0xf7, 0xa}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; + + uint8_t bytes0[] = {0xc, 0x77, 0xe2, 0x42, 0x16, 0x39, 0xaf, 0x4f, 0xb6, 0xcb, 0xe5}; + uint8_t bytes1[] = {0x8e, 0xea, 0x82, 0xd9, 0xf, 0xce, 0x81, 0x94, 0x2a, 0x49, 0xdc, 0xdf, 0xac, + 0xfa, 0x79, 0x52, 0xb4, 0x75, 0x6c, 0xdc, 0x42, 0x93, 0x77, 0x88, 0xd5}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6251}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1651}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23126}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "x\141i\235F", _pubPktID = 15511, +// _pubBody = "\174]0.\196?\198\195\202m`\179\253E\v|\204\214P\f\229\NAK\154\130", _pubProps = +// [PropSubscriptionIdentifier 21,PropResponseTopic +// "\221P\183\212\158\183\132\176\213\128wK\"\163\&8\137{B\173\192\186\130",PropResponseTopic +// "e\r:`\149\240\185)g\174M\137\DC4\232C",PropMessageExpiryInterval 16546,PropContentType +// "\231J\190\176\154\213\148$\190\210\r\133",PropRequestProblemInformation 23,PropServerReference +// "\226\&3M1(\147\241|.\129\183\&3Hb\211c\192,\207\EOT"]} +TEST(Publish50QCTest, Encode55) { + uint8_t pkt[] = {0x32, 0x7c, 0x0, 0x5, 0x78, 0x8d, 0x69, 0xeb, 0x46, 0x3c, 0x97, 0x5a, 0xb, 0x15, 0x8, 0x0, + 0x16, 0xdd, 0x50, 0xb7, 0xd4, 0x9e, 0xb7, 0x84, 0xb0, 0xd5, 0x80, 0x77, 0x4b, 0x22, 0xa3, 0x38, + 0x89, 0x7b, 0x42, 0xad, 0xc0, 0xba, 0x82, 0x8, 0x0, 0xf, 0x65, 0xd, 0x3a, 0x60, 0x95, 0xf0, + 0xb9, 0x29, 0x67, 0xae, 0x4d, 0x89, 0x14, 0xe8, 0x43, 0x2, 0x0, 0x0, 0x40, 0xa2, 0x3, 0x0, + 0xc, 0xe7, 0x4a, 0xbe, 0xb0, 0x9a, 0xd5, 0x94, 0x24, 0xbe, 0xd2, 0xd, 0x85, 0x17, 0x17, 0x1c, + 0x0, 0x14, 0xe2, 0x33, 0x4d, 0x31, 0x28, 0x93, 0xf1, 0x7c, 0x2e, 0x81, 0xb7, 0x33, 0x48, 0x62, + 0xd3, 0x63, 0xc0, 0x2c, 0xcf, 0x4, 0xae, 0x5d, 0x30, 0x2e, 0xc4, 0x3f, 0xc6, 0xc3, 0xca, 0x6d, + 0x60, 0xb3, 0xfd, 0x45, 0xb, 0x7c, 0xcc, 0xd6, 0x50, 0xc, 0xe5, 0x15, 0x9a, 0x82}; + + uint8_t buf[136] = {0}; + + uint8_t topic_bytes[] = {0x78, 0x8d, 0x69, 0xeb, 0x46}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xae, 0x5d, 0x30, 0x2e, 0xc4, 0x3f, 0xc6, 0xc3, 0xca, 0x6d, 0x60, 0xb3, + 0xfd, 0x45, 0xb, 0x7c, 0xcc, 0xd6, 0x50, 0xc, 0xe5, 0x15, 0x9a, 0x82}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + uint8_t bytes0[] = {0xdd, 0x50, 0xb7, 0xd4, 0x9e, 0xb7, 0x84, 0xb0, 0xd5, 0x80, 0x77, + 0x4b, 0x22, 0xa3, 0x38, 0x89, 0x7b, 0x42, 0xad, 0xc0, 0xba, 0x82}; + uint8_t bytes1[] = {0x65, 0xd, 0x3a, 0x60, 0x95, 0xf0, 0xb9, 0x29, 0x67, 0xae, 0x4d, 0x89, 0x14, 0xe8, 0x43}; + uint8_t bytes2[] = {0xe7, 0x4a, 0xbe, 0xb0, 0x9a, 0xd5, 0x94, 0x24, 0xbe, 0xd2, 0xd, 0x85}; + uint8_t bytes3[] = {0xe2, 0x33, 0x4d, 0x31, 0x28, 0x93, 0xf1, 0x7c, 0x2e, 0x81, + 0xb7, 0x33, 0x48, 0x62, 0xd3, 0x63, 0xc0, 0x2c, 0xcf, 0x4}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16546}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytes3}}}, + }; + + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15511, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\207", _pubPktID = 12437, _pubBody = +// "\209\NAKT\231?\229R\176}\ESC\195\172\146\168\148\188;\237\205\216\134\&4\132\&5w", _pubProps = +// [PropTopicAliasMaximum 9499,PropAuthenticationMethod "\166\ENQ\132mo\129\187\154%\158\EOT",PropTopicAliasMaximum +// 30051,PropTopicAliasMaximum 8839]} +TEST(Publish50QCTest, Encode56) { + uint8_t pkt[] = {0x3a, 0x36, 0x0, 0x1, 0xcf, 0x30, 0x95, 0x17, 0x22, 0x25, 0x1b, 0x15, 0x0, 0xb, + 0xa6, 0x5, 0x84, 0x6d, 0x6f, 0x81, 0xbb, 0x9a, 0x25, 0x9e, 0x4, 0x22, 0x75, 0x63, + 0x22, 0x22, 0x87, 0xd1, 0x15, 0x54, 0xe7, 0x3f, 0xe5, 0x52, 0xb0, 0x7d, 0x1b, 0xc3, + 0xac, 0x92, 0xa8, 0x94, 0xbc, 0x3b, 0xed, 0xcd, 0xd8, 0x86, 0x34, 0x84, 0x35, 0x77}; + + uint8_t buf[66] = {0}; + + uint8_t topic_bytes[] = {0xcf}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xd1, 0x15, 0x54, 0xe7, 0x3f, 0xe5, 0x52, 0xb0, 0x7d, 0x1b, 0xc3, 0xac, 0x92, + 0xa8, 0x94, 0xbc, 0x3b, 0xed, 0xcd, 0xd8, 0x86, 0x34, 0x84, 0x35, 0x77}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 25; + + uint8_t bytes0[] = {0xa6, 0x5, 0x84, 0x6d, 0x6f, 0x81, 0xbb, 0x9a, 0x25, 0x9e, 0x4}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9499}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30051}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8839}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 12437, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\151\157\DC2\191\177A0d\141\181", +// _pubPktID = 0, _pubBody = "(W\SO\vJ\219Q\170]\to\a3\EOT\245X?\r\255\t&i\EM\213", _pubProps = +// [PropAuthenticationMethod "\DC3\DLEHQ",PropMessageExpiryInterval 4440,PropPayloadFormatIndicator +// 234,PropServerKeepAlive 28079,PropTopicAliasMaximum 11882,PropSessionExpiryInterval 357]} +TEST(Publish50QCTest, Encode57) { + uint8_t pkt[] = {0x38, 0x3e, 0x0, 0xa, 0x97, 0x9d, 0x12, 0xbf, 0xb1, 0x41, 0x30, 0x64, 0x8d, 0xb5, 0x19, 0x15, + 0x0, 0x4, 0x13, 0x10, 0x48, 0x51, 0x2, 0x0, 0x0, 0x11, 0x58, 0x1, 0xea, 0x13, 0x6d, 0xaf, + 0x22, 0x2e, 0x6a, 0x11, 0x0, 0x0, 0x1, 0x65, 0x28, 0x57, 0xe, 0xb, 0x4a, 0xdb, 0x51, 0xaa, + 0x5d, 0x9, 0x6f, 0x7, 0x33, 0x4, 0xf5, 0x58, 0x3f, 0xd, 0xff, 0x9, 0x26, 0x69, 0x19, 0xd5}; + + uint8_t buf[74] = {0}; + + uint8_t topic_bytes[] = {0x97, 0x9d, 0x12, 0xbf, 0xb1, 0x41, 0x30, 0x64, 0x8d, 0xb5}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x28, 0x57, 0xe, 0xb, 0x4a, 0xdb, 0x51, 0xaa, 0x5d, 0x9, 0x6f, 0x7, + 0x33, 0x4, 0xf5, 0x58, 0x3f, 0xd, 0xff, 0x9, 0x26, 0x69, 0x19, 0xd5}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + uint8_t bytes0[] = {0x13, 0x10, 0x48, 0x51}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4440}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28079}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11882}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 357}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\ETB\133p7\NAK\217\177\185\186:\228-\158\214\255\170", _pubPktID = 5681, _pubBody = +// "\NULT\212\214&\205\222\154\236\130\237_\195\200\186\137\DEL\184\213\&6\192a\241\NUL\231\168\246\180", _pubProps = +// [PropMessageExpiryInterval 6752,PropResponseInformation "\DC2\DELf\202eTw\149\239",PropMaximumPacketSize +// 16265,PropRetainAvailable 229,PropReasonString "v5*\215u",PropRequestProblemInformation 220]} +TEST(Publish50QCTest, Encode58) { + uint8_t pkt[] = {0x3c, 0x53, 0x0, 0x10, 0x17, 0x85, 0x70, 0x37, 0x15, 0xd9, 0xb1, 0xb9, 0xba, 0x3a, 0xe4, + 0x2d, 0x9e, 0xd6, 0xff, 0xaa, 0x16, 0x31, 0x22, 0x2, 0x0, 0x0, 0x1a, 0x60, 0x1a, 0x0, + 0x9, 0x12, 0x7f, 0x66, 0xca, 0x65, 0x54, 0x77, 0x95, 0xef, 0x27, 0x0, 0x0, 0x3f, 0x89, + 0x25, 0xe5, 0x1f, 0x0, 0x5, 0x76, 0x35, 0x2a, 0xd7, 0x75, 0x17, 0xdc, 0x0, 0x54, 0xd4, + 0xd6, 0x26, 0xcd, 0xde, 0x9a, 0xec, 0x82, 0xed, 0x5f, 0xc3, 0xc8, 0xba, 0x89, 0x7f, 0xb8, + 0xd5, 0x36, 0xc0, 0x61, 0xf1, 0x0, 0xe7, 0xa8, 0xf6, 0xb4}; + + uint8_t buf[95] = {0}; + + uint8_t topic_bytes[] = {0x17, 0x85, 0x70, 0x37, 0x15, 0xd9, 0xb1, 0xb9, + 0xba, 0x3a, 0xe4, 0x2d, 0x9e, 0xd6, 0xff, 0xaa}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x0, 0x54, 0xd4, 0xd6, 0x26, 0xcd, 0xde, 0x9a, 0xec, 0x82, 0xed, 0x5f, 0xc3, 0xc8, + 0xba, 0x89, 0x7f, 0xb8, 0xd5, 0x36, 0xc0, 0x61, 0xf1, 0x0, 0xe7, 0xa8, 0xf6, 0xb4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 28; + + uint8_t bytes0[] = {0x12, 0x7f, 0x66, 0xca, 0x65, 0x54, 0x77, 0x95, 0xef}; + uint8_t bytes1[] = {0x76, 0x35, 0x2a, 0xd7, 0x75}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6752}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16265}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5681, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "K#\aZV,bl\168\131\197N", _pubPktID = +// 29545, _pubBody = "q\152\198\DC3v\US", _pubProps = [PropServerReference "\253\161\253",PropCorrelationData +// "\SI\241\169\229\186\174\ETX\EM\n\193\189>\237\214U\ESC\128",PropContentType "\220",PropSharedSubscriptionAvailable +// 10,PropRequestResponseInformation 112,PropSubscriptionIdentifier 22,PropUserProperty +// "\DC2\227j\196\236X8\252*\170Z\b\181\251\&2" +// "\178\140\222\163\ACK\215\&7\183\251\242\251[G\ETX\183\EOTH\SIwD=\141\180j.",PropCorrelationData +// "z\193\213\200\146PY\156\&9m?\166\134\a\206\144!",PropResponseTopic +// "3\248\238\SOu\145=\226+Z,\SO\199E\143\229\220\250iH\145\235)\168y\129,E8\n",PropMessageExpiryInterval +// 12141,PropTopicAlias 4176,PropResponseTopic "gT\208c!\224\151",PropSubscriptionIdentifierAvailable +// 61,PropRequestResponseInformation 138]} +TEST(Publish50QCTest, Encode59) { + uint8_t pkt[] = {0x3b, 0xb4, 0x1, 0x0, 0xc, 0x4b, 0x23, 0x7, 0x5a, 0x56, 0x2c, 0x62, 0x6c, 0xa8, 0x83, 0xc5, 0x4e, + 0x73, 0x69, 0x9c, 0x1, 0x1c, 0x0, 0x3, 0xfd, 0xa1, 0xfd, 0x9, 0x0, 0x11, 0xf, 0xf1, 0xa9, 0xe5, + 0xba, 0xae, 0x3, 0x19, 0xa, 0xc1, 0xbd, 0x3e, 0xed, 0xd6, 0x55, 0x1b, 0x80, 0x3, 0x0, 0x1, 0xdc, + 0x2a, 0xa, 0x19, 0x70, 0xb, 0x16, 0x26, 0x0, 0xf, 0x12, 0xe3, 0x6a, 0xc4, 0xec, 0x58, 0x38, 0xfc, + 0x2a, 0xaa, 0x5a, 0x8, 0xb5, 0xfb, 0x32, 0x0, 0x19, 0xb2, 0x8c, 0xde, 0xa3, 0x6, 0xd7, 0x37, 0xb7, + 0xfb, 0xf2, 0xfb, 0x5b, 0x47, 0x3, 0xb7, 0x4, 0x48, 0xf, 0x77, 0x44, 0x3d, 0x8d, 0xb4, 0x6a, 0x2e, + 0x9, 0x0, 0x11, 0x7a, 0xc1, 0xd5, 0xc8, 0x92, 0x50, 0x59, 0x9c, 0x39, 0x6d, 0x3f, 0xa6, 0x86, 0x7, + 0xce, 0x90, 0x21, 0x8, 0x0, 0x1e, 0x33, 0xf8, 0xee, 0xe, 0x75, 0x91, 0x3d, 0xe2, 0x2b, 0x5a, 0x2c, + 0xe, 0xc7, 0x45, 0x8f, 0xe5, 0xdc, 0xfa, 0x69, 0x48, 0x91, 0xeb, 0x29, 0xa8, 0x79, 0x81, 0x2c, 0x45, + 0x38, 0xa, 0x2, 0x0, 0x0, 0x2f, 0x6d, 0x23, 0x10, 0x50, 0x8, 0x0, 0x7, 0x67, 0x54, 0xd0, 0x63, + 0x21, 0xe0, 0x97, 0x29, 0x3d, 0x19, 0x8a, 0x71, 0x98, 0xc6, 0x13, 0x76, 0x1f}; + + uint8_t buf[193] = {0}; + + uint8_t topic_bytes[] = {0x4b, 0x23, 0x7, 0x5a, 0x56, 0x2c, 0x62, 0x6c, 0xa8, 0x83, 0xc5, 0x4e}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x71, 0x98, 0xc6, 0x13, 0x76, 0x1f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 6; + + uint8_t bytes0[] = {0xfd, 0xa1, 0xfd}; + uint8_t bytes1[] = {0xf, 0xf1, 0xa9, 0xe5, 0xba, 0xae, 0x3, 0x19, 0xa, + 0xc1, 0xbd, 0x3e, 0xed, 0xd6, 0x55, 0x1b, 0x80}; + uint8_t bytes2[] = {0xdc}; + uint8_t bytes4[] = {0xb2, 0x8c, 0xde, 0xa3, 0x6, 0xd7, 0x37, 0xb7, 0xfb, 0xf2, 0xfb, 0x5b, 0x47, + 0x3, 0xb7, 0x4, 0x48, 0xf, 0x77, 0x44, 0x3d, 0x8d, 0xb4, 0x6a, 0x2e}; + uint8_t bytes3[] = {0x12, 0xe3, 0x6a, 0xc4, 0xec, 0x58, 0x38, 0xfc, 0x2a, 0xaa, 0x5a, 0x8, 0xb5, 0xfb, 0x32}; + uint8_t bytes5[] = {0x7a, 0xc1, 0xd5, 0xc8, 0x92, 0x50, 0x59, 0x9c, 0x39, + 0x6d, 0x3f, 0xa6, 0x86, 0x7, 0xce, 0x90, 0x21}; + uint8_t bytes6[] = {0x33, 0xf8, 0xee, 0xe, 0x75, 0x91, 0x3d, 0xe2, 0x2b, 0x5a, 0x2c, 0xe, 0xc7, 0x45, 0x8f, + 0xe5, 0xdc, 0xfa, 0x69, 0x48, 0x91, 0xeb, 0x29, 0xa8, 0x79, 0x81, 0x2c, 0x45, 0x38, 0xa}; + uint8_t bytes7[] = {0x67, 0x54, 0xd0, 0x63, 0x21, 0xe0, 0x97}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytes3}, .v = {25, (char*)&bytes4}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12141}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4176}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, + }; + + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29545, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\ETB./iLG\236\218\159\SOH\n\ESC\203\FSs", _pubPktID = 19215, _pubBody = +// "I\157\182\DEL\135\249\197]P>b\248\202r\201\180\226\179\255", _pubProps = [PropReasonString +// "\184\168\186\240\234w\SIjs2\217\133r&0Z\DC3-X",PropResponseTopic +// "\221\141\186A\131\ETX\SI\CAN\b\145c\222\DC1\EM",PropRequestResponseInformation 190,PropUserProperty +// "\132\175a9\148\t\220k\EOT\251\161" "\147\133\237C\234C\150\GS\SO\204\245",PropAuthenticationMethod +// "\ETX\251\177?\243\192/\156\149\253\164\205\191\234%\231\223O\184kK%\201\&1\139\211d",PropMessageExpiryInterval +// 20507,PropReasonString "w\132\228[\230\221g\234",PropRequestProblemInformation 10]} +TEST(Publish50QCTest, Encode60) { + uint8_t pkt[] = {0x34, 0x9b, 0x1, 0x0, 0xf, 0x17, 0x2e, 0x2f, 0x69, 0x4c, 0x47, 0xec, 0xda, 0x9f, 0x1, 0xa, + 0x1b, 0xcb, 0x1c, 0x73, 0x4b, 0xf, 0x74, 0x1f, 0x0, 0x13, 0xb8, 0xa8, 0xba, 0xf0, 0xea, 0x77, + 0xf, 0x6a, 0x73, 0x32, 0xd9, 0x85, 0x72, 0x26, 0x30, 0x5a, 0x13, 0x2d, 0x58, 0x8, 0x0, 0xe, + 0xdd, 0x8d, 0xba, 0x41, 0x83, 0x3, 0xf, 0x18, 0x8, 0x91, 0x63, 0xde, 0x11, 0x19, 0x19, 0xbe, + 0x26, 0x0, 0xb, 0x84, 0xaf, 0x61, 0x39, 0x94, 0x9, 0xdc, 0x6b, 0x4, 0xfb, 0xa1, 0x0, 0xb, + 0x93, 0x85, 0xed, 0x43, 0xea, 0x43, 0x96, 0x1d, 0xe, 0xcc, 0xf5, 0x15, 0x0, 0x1b, 0x3, 0xfb, + 0xb1, 0x3f, 0xf3, 0xc0, 0x2f, 0x9c, 0x95, 0xfd, 0xa4, 0xcd, 0xbf, 0xea, 0x25, 0xe7, 0xdf, 0x4f, + 0xb8, 0x6b, 0x4b, 0x25, 0xc9, 0x31, 0x8b, 0xd3, 0x64, 0x2, 0x0, 0x0, 0x50, 0x1b, 0x1f, 0x0, + 0x8, 0x77, 0x84, 0xe4, 0x5b, 0xe6, 0xdd, 0x67, 0xea, 0x17, 0xa, 0x49, 0x9d, 0xb6, 0x7f, 0x87, + 0xf9, 0xc5, 0x5d, 0x50, 0x3e, 0x62, 0xf8, 0xca, 0x72, 0xc9, 0xb4, 0xe2, 0xb3, 0xff}; + + uint8_t buf[168] = {0}; + + uint8_t topic_bytes[] = {0x17, 0x2e, 0x2f, 0x69, 0x4c, 0x47, 0xec, 0xda, 0x9f, 0x1, 0xa, 0x1b, 0xcb, 0x1c, 0x73}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x49, 0x9d, 0xb6, 0x7f, 0x87, 0xf9, 0xc5, 0x5d, 0x50, 0x3e, + 0x62, 0xf8, 0xca, 0x72, 0xc9, 0xb4, 0xe2, 0xb3, 0xff}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 19; + + uint8_t bytes0[] = {0xb8, 0xa8, 0xba, 0xf0, 0xea, 0x77, 0xf, 0x6a, 0x73, 0x32, + 0xd9, 0x85, 0x72, 0x26, 0x30, 0x5a, 0x13, 0x2d, 0x58}; + uint8_t bytes1[] = {0xdd, 0x8d, 0xba, 0x41, 0x83, 0x3, 0xf, 0x18, 0x8, 0x91, 0x63, 0xde, 0x11, 0x19}; + uint8_t bytes3[] = {0x93, 0x85, 0xed, 0x43, 0xea, 0x43, 0x96, 0x1d, 0xe, 0xcc, 0xf5}; + uint8_t bytes2[] = {0x84, 0xaf, 0x61, 0x39, 0x94, 0x9, 0xdc, 0x6b, 0x4, 0xfb, 0xa1}; + uint8_t bytes4[] = {0x3, 0xfb, 0xb1, 0x3f, 0xf3, 0xc0, 0x2f, 0x9c, 0x95, 0xfd, 0xa4, 0xcd, 0xbf, 0xea, + 0x25, 0xe7, 0xdf, 0x4f, 0xb8, 0x6b, 0x4b, 0x25, 0xc9, 0x31, 0x8b, 0xd3, 0x64}; + uint8_t bytes5[] = {0x77, 0x84, 0xe4, 0x5b, 0xe6, 0xdd, 0x67, 0xea}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytes2}, .v = {11, (char*)&bytes3}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20507}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 10}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19215, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\ETXv\161\NUL\132\175\165\CAN2\131", +// _pubPktID = 31455, _pubBody = "P\232c#\237\r A\219\192Z\186\241T\196\154", _pubProps = [PropContentType +// "\SIB\207\144\236\165D\DC2\244\ESCiM\DC1\DC33\NUL\140\183\r+u65\211\GS\DC1",PropReasonString +// "\188Vm\185\DC4\193\251\183\218\ay\240:}\213\237c_\199\199\244T\204A\179L\211\CAN",PropUserProperty +// "\184\231\&3:\178\191\203\198\&5\164\223Z\208\164(oKv\205\146\138\213" +// "\181x\245o\222L\155\234\195\135\SUB\152\189\ACKj\NUL\220\176/\182\146\138(\v",PropSessionExpiryInterval +// 16128,PropServerReference "\221Am\185\221\153\187\227B\226\SIu\200\&4\219\t\137\145\195\SI",PropTopicAlias +// 340,PropTopicAliasMaximum 28072,PropMessageExpiryInterval 27514,PropContentType +// "\141\199\198\159!\171\164\nsz\212\240\224\233\207=\253\132\210\192M~\ETXZ\215\130i)e\243",PropSessionExpiryInterval +// 17275,PropContentType "\202\ETB\213D",PropResponseTopic +// "\ETB\184\SUB\DLE\218'tM!\131\167\158X\218\f\210\SUB\178\172",PropAssignedClientIdentifier +// ",\247\185\216\245\198{\218\DLE\190\SOH9j\237\&4\218\GS\198\200\180\231^\FS\184\134\130",PropWildcardSubscriptionAvailable +// 81,PropPayloadFormatIndicator 136,PropMessageExpiryInterval 32698,PropReceiveMaximum 22407,PropTopicAlias +// 11284,PropWillDelayInterval 22458,PropMessageExpiryInterval 17500,PropServerReference +// "\175\DEL\128\171nB\170Y\204\179\253\DC3",PropTopicAliasMaximum 20435,PropSessionExpiryInterval 23566]} +TEST(Publish50QCTest, Encode61) { + uint8_t pkt[] = { + 0x35, 0xc6, 0x2, 0x0, 0xa, 0x3, 0x76, 0xa1, 0x0, 0x84, 0xaf, 0xa5, 0x18, 0x32, 0x83, 0x7a, 0xdf, 0xa6, 0x2, + 0x3, 0x0, 0x1a, 0xf, 0x42, 0xcf, 0x90, 0xec, 0xa5, 0x44, 0x12, 0xf4, 0x1b, 0x69, 0x4d, 0x11, 0x13, 0x33, 0x0, + 0x8c, 0xb7, 0xd, 0x2b, 0x75, 0x36, 0x35, 0xd3, 0x1d, 0x11, 0x1f, 0x0, 0x1c, 0xbc, 0x56, 0x6d, 0xb9, 0x14, 0xc1, + 0xfb, 0xb7, 0xda, 0x7, 0x79, 0xf0, 0x3a, 0x7d, 0xd5, 0xed, 0x63, 0x5f, 0xc7, 0xc7, 0xf4, 0x54, 0xcc, 0x41, 0xb3, + 0x4c, 0xd3, 0x18, 0x26, 0x0, 0x16, 0xb8, 0xe7, 0x33, 0x3a, 0xb2, 0xbf, 0xcb, 0xc6, 0x35, 0xa4, 0xdf, 0x5a, 0xd0, + 0xa4, 0x28, 0x6f, 0x4b, 0x76, 0xcd, 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x0, 0x44, 0x5c, 0x1c, 0x0, 0xc, 0xaf, 0x7f, 0x80, 0xab, 0x6e, 0x42, 0xaa, 0x59, 0xcc, 0xb3, 0xfd, + 0x13, 0x22, 0x4f, 0xd3, 0x11, 0x0, 0x0, 0x5c, 0xe, 0x50, 0xe8, 0x63, 0x23, 0xed, 0xd, 0x20, 0x41, 0xdb, 0xc0, + 0x5a, 0xba, 0xf1, 0x54, 0xc4, 0x9a}; + + uint8_t buf[339] = {0}; + + uint8_t topic_bytes[] = {0x3, 0x76, 0xa1, 0x0, 0x84, 0xaf, 0xa5, 0x18, 0x32, 0x83}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x50, 0xe8, 0x63, 0x23, 0xed, 0xd, 0x20, 0x41, 0xdb, 0xc0, 0x5a, 0xba, 0xf1, 0x54, 0xc4, 0x9a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 16; + + uint8_t bytes0[] = {0xf, 0x42, 0xcf, 0x90, 0xec, 0xa5, 0x44, 0x12, 0xf4, 0x1b, 0x69, 0x4d, 0x11, + 0x13, 0x33, 0x0, 0x8c, 0xb7, 0xd, 0x2b, 0x75, 0x36, 0x35, 0xd3, 0x1d, 0x11}; + uint8_t bytes1[] = {0xbc, 0x56, 0x6d, 0xb9, 0x14, 0xc1, 0xfb, 0xb7, 0xda, 0x7, 0x79, 0xf0, 0x3a, 0x7d, + 0xd5, 0xed, 0x63, 0x5f, 0xc7, 0xc7, 0xf4, 0x54, 0xcc, 0x41, 0xb3, 0x4c, 0xd3, 0x18}; + uint8_t bytes3[] = {0xb5, 0x78, 0xf5, 0x6f, 0xde, 0x4c, 0x9b, 0xea, 0xc3, 0x87, 0x1a, 0x98, + 0xbd, 0x6, 0x6a, 0x0, 0xdc, 0xb0, 0x2f, 0xb6, 0x92, 0x8a, 0x28, 0xb}; + uint8_t bytes2[] = {0xb8, 0xe7, 0x33, 0x3a, 0xb2, 0xbf, 0xcb, 0xc6, 0x35, 0xa4, 0xdf, + 0x5a, 0xd0, 0xa4, 0x28, 0x6f, 0x4b, 0x76, 0xcd, 0x92, 0x8a, 0xd5}; + uint8_t bytes4[] = {0xdd, 0x41, 0x6d, 0xb9, 0xdd, 0x99, 0xbb, 0xe3, 0x42, 0xe2, + 0xf, 0x75, 0xc8, 0x34, 0xdb, 0x9, 0x89, 0x91, 0xc3, 0xf}; + uint8_t bytes5[] = {0x8d, 0xc7, 0xc6, 0x9f, 0x21, 0xab, 0xa4, 0xa, 0x73, 0x7a, 0xd4, 0xf0, 0xe0, 0xe9, 0xcf, + 0x3d, 0xfd, 0x84, 0xd2, 0xc0, 0x4d, 0x7e, 0x3, 0x5a, 0xd7, 0x82, 0x69, 0x29, 0x65, 0xf3}; + uint8_t bytes6[] = {0xca, 0x17, 0xd5, 0x44}; + uint8_t bytes7[] = {0x17, 0xb8, 0x1a, 0x10, 0xda, 0x27, 0x74, 0x4d, 0x21, 0x83, + 0xa7, 0x9e, 0x58, 0xda, 0xc, 0xd2, 0x1a, 0xb2, 0xac}; + uint8_t bytes8[] = {0x2c, 0xf7, 0xb9, 0xd8, 0xf5, 0xc6, 0x7b, 0xda, 0x10, 0xbe, 0x1, 0x39, 0x6a, + 0xed, 0x34, 0xda, 0x1d, 0xc6, 0xc8, 0xb4, 0xe7, 0x5e, 0x1c, 0xb8, 0x86, 0x82}; + uint8_t bytes9[] = {0xaf, 0x7f, 0x80, 0xab, 0x6e, 0x42, 0xaa, 0x59, 0xcc, 0xb3, 0xfd, 0x13}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytes2}, .v = {24, (char*)&bytes3}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16128}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 340}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28072}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27514}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17275}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytes8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32698}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22407}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11284}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22458}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17500}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytes9}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20435}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23566}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 31455, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "(\193\NAK\240\&3\174\176\CAN:q$\160F7+\162\164\bNCu\128\&3P\131\130\151\239g7", _pubPktID = 31413, _pubBody = "", +// _pubProps = [PropAuthenticationData +// "\141\201\231\233\244\139\nR\172\254\176\179+\161\136z\STX.\243VS",PropRetainAvailable 236,PropAuthenticationMethod +// "\248\184\140N\231~&C\DC2l\138\130bQ",PropTopicAlias 11716,PropUserProperty "\NULf\251\NUL\213E\217" +// "\"\ETXUz\195v\222\247f-\181)\161\212\170A",PropAuthenticationMethod "\165\235\129",PropRetainAvailable +// 55,PropWillDelayInterval 6889,PropWillDelayInterval 633,PropUserProperty +// "[,$\214\141\169\STX\DC1\255\189\ETX7\GSc,\189\151\217\134\165\196\167\154;" "\DLE",PropSessionExpiryInterval +// 32250,PropContentType "\245{~\213\167]",PropReasonString +// "\242\241B\213\205E\135\215MG\237\ACK\194\SYN",PropAuthenticationMethod "6\210D",PropRetainAvailable +// 129,PropAuthenticationMethod "\158\SIzy",PropMaximumQoS 44,PropCorrelationData "",PropSharedSubscriptionAvailable +// 24,PropResponseInformation +// "\160\184\DC1;\b\184\132\255F\245/\250O\224\US:\146\196~\DC4\189Y\195\247\190$\EOT\SUB\128",PropTopicAlias +// 26050,PropSubscriptionIdentifier 20]} +TEST(Publish50QCTest, Encode62) { + uint8_t pkt[] = {0x3d, 0xf8, 0x1, 0x0, 0x1e, 0x28, 0xc1, 0x15, 0xf0, 0x33, 0xae, 0xb0, 0x18, 0x3a, 0x71, 0x24, 0xa0, + 0x46, 0x37, 0x2b, 0xa2, 0xa4, 0x8, 0x4e, 0x43, 0x75, 0x80, 0x33, 0x50, 0x83, 0x82, 0x97, 0xef, 0x67, + 0x37, 0x7a, 0xb5, 0xd4, 0x1, 0x16, 0x0, 0x15, 0x8d, 0xc9, 0xe7, 0xe9, 0xf4, 0x8b, 0xa, 0x52, 0xac, + 0xfe, 0xb0, 0xb3, 0x2b, 0xa1, 0x88, 0x7a, 0x2, 0x2e, 0xf3, 0x56, 0x53, 0x25, 0xec, 0x15, 0x0, 0xe, + 0xf8, 0xb8, 0x8c, 0x4e, 0xe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 0x15, 0xf0, 0x33, 0xae, 0xb0, 0x18, 0x3a, 0x71, 0x24, 0xa0, 0x46, 0x37, 0x2b, + 0xa2, 0xa4, 0x8, 0x4e, 0x43, 0x75, 0x80, 0x33, 0x50, 0x83, 0x82, 0x97, 0xef, 0x67, 0x37}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 0; + + uint8_t bytes0[] = {0x8d, 0xc9, 0xe7, 0xe9, 0xf4, 0x8b, 0xa, 0x52, 0xac, 0xfe, 0xb0, + 0xb3, 0x2b, 0xa1, 0x88, 0x7a, 0x2, 0x2e, 0xf3, 0x56, 0x53}; + uint8_t bytes1[] = {0xf8, 0xb8, 0x8c, 0x4e, 0xe7, 0x7e, 0x26, 0x43, 0x12, 0x6c, 0x8a, 0x82, 0x62, 0x51}; + uint8_t bytes3[] = {0x22, 0x3, 0x55, 0x7a, 0xc3, 0x76, 0xde, 0xf7, 0x66, 0x2d, 0xb5, 0x29, 0xa1, 0xd4, 0xaa, 0x41}; + uint8_t bytes2[] = {0x0, 0x66, 0xfb, 0x0, 0xd5, 0x45, 0xd9}; + uint8_t bytes4[] = {0xa5, 0xeb, 0x81}; + uint8_t bytes6[] = {0x10}; + uint8_t bytes5[] = {0x5b, 0x2c, 0x24, 0xd6, 0x8d, 0xa9, 0x2, 0x11, 0xff, 0xbd, 0x3, 0x37, + 0x1d, 0x63, 0x2c, 0xbd, 0x97, 0xd9, 0x86, 0xa5, 0xc4, 0xa7, 0x9a, 0x3b}; + uint8_t bytes7[] = {0xf5, 0x7b, 0x7e, 0xd5, 0xa7, 0x5d}; + uint8_t bytes8[] = {0xf2, 0xf1, 0x42, 0xd5, 0xcd, 0x45, 0x87, 0xd7, 0x4d, 0x47, 0xed, 0x6, 0xc2, 0x16}; + uint8_t bytes9[] = {0x36, 0xd2, 0x44}; + uint8_t bytes10[] = {0x9e, 0xf, 0x7a, 0x79}; + uint8_t bytes11[] = {0}; + uint8_t bytes12[] = {0xa0, 0xb8, 0x11, 0x3b, 0x8, 0xb8, 0x84, 0xff, 0x46, 0xf5, 0x2f, 0xfa, 0x4f, 0xe0, 0x1f, + 0x3a, 0x92, 0xc4, 0x7e, 0x14, 0xbd, 0x59, 0xc3, 0xf7, 0xbe, 0x24, 0x4, 0x1a, 0x80}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11716}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytes2}, .v = {16, (char*)&bytes3}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6889}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 633}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytes5}, .v = {1, (char*)&bytes6}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32250}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytes8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytes9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytes10}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytes11}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytes12}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26050}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + }; + + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 31413, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "u\197\FS\156\226\226\156\fe7\SUBD\251}\132(:k", _pubPktID = 0, _pubBody = +// "=\RS\224\ENQ\"\187\165\211E\156*\f\133Ox\197\162J\168\131\167I\SUB\190)\240\DEL\EM\216\255", _pubProps = +// [PropRequestProblemInformation 38,PropServerKeepAlive 10076,PropAuthenticationData +// "\158\&5\RS\EMUr\232\129k\213\201\226\136W\157B\152NfH\226\183\168\149\NUL\208\219\162S\DC3",PropWillDelayInterval +// 21513,PropWildcardSubscriptionAvailable 21,PropWillDelayInterval 20941,PropTopicAliasMaximum 9284,PropUserProperty +// "{\202\ACKK\ETBsGc\ETX\SO\DC1\SI\141\157\193\170]@\191'\212\SO" +// "\156$K\244\&5\190qKYP\197\145",PropSubscriptionIdentifierAvailable 89,PropSessionExpiryInterval 29682,PropTopicAlias +// 27941,PropReceiveMaximum 25188,PropResponseTopic "5\231tlZ\205-\GS7\NULE9\236",PropMaximumPacketSize +// 24955,PropRequestProblemInformation 253,PropServerReference +// "A8}\139\176\238C\248\186\STX\EM\237:e-\185\&5\241\232\255\220\241\196H\198A\206w",PropRequestResponseInformation +// 50,PropSubscriptionIdentifier 5,PropTopicAliasMaximum 7034,PropTopicAliasMaximum 10862,PropPayloadFormatIndicator +// 0,PropReceiveMaximum 6924,PropRetainAvailable 196,PropRetainAvailable 211,PropResponseTopic +// "\179\176S\130|\148C",PropAuthenticationData "\165\225\230b\254\231c",PropMaximumQoS 77,PropAssignedClientIdentifier +// "1\178\254\156",PropRetainAvailable 224,PropSubscriptionIdentifier 27]} +TEST(Publish50QCTest, Encode63) { + uint8_t pkt[] = { + 0x30, 0x87, 0x2, 0x0, 0x12, 0x75, 0xc5, 0x1c, 0x9c, 0xe2, 0xe2, 0x9c, 0xc, 0x65, 0x37, 0x1a, 0x44, 0xfb, 0x7d, + 0x84, 0x28, 0x3a, 0x6b, 0xd3, 0x1, 0x17, 0x26, 0x13, 0x27, 0x5c, 0x16, 0x0, 0x1e, 0x9e, 0x35, 0x1e, 0x19, 0x55, + 0x72, 0xe8, 0x81, 0x6b, 0xd5, 0xc9, 0xe2, 0x88, 0x57, 0x9d, 0x42, 0x98, 0x4e, 0x66, 0x48, 0xe2, 0xb7, 0xa8, 0x95, + 0x0, 0xd0, 0xdb, 0xa2, 0x53, 0x13, 0x18, 0x0, 0x0, 0x54, 0x9, 0x28, 0x15, 0x18, 0x0, 0x0, 0x51, 0xcd, 0x22, + 0x24, 0x44, 0x26, 0x0, 0x16, 0x7b, 0xca, 0x6, 0x4b, 0x17, 0x73, 0x47, 0x63, 0x3, 0xe, 0x11, 0xf, 0x8d, 0x9d, + 0xc1, 0xaa, 0x5d, 0x40, 0xbf, 0x27, 0xd4, 0xe, 0x0, 0xc, 0x9c, 0x24, 0x4b, 0xf4, 0x35, 0xbe, 0x71, 0x4b, 0x59, + 0x50, 0xc5, 0x91, 0x29, 0x59, 0x11, 0x0, 0x0, 0x73, 0xf2, 0x23, 0x6d, 0x25, 0x21, 0x62, 0x64, 0x8, 0x0, 0xd, + 0x35, 0xe7, 0x74, 0x6c, 0x5a, 0xcd, 0x2d, 0x1d, 0x37, 0x0, 0x45, 0x39, 0xec, 0x27, 0x0, 0x0, 0x61, 0x7b, 0x17, + 0xfd, 0x1c, 0x0, 0x1c, 0x41, 0x38, 0x7d, 0x8b, 0xb0, 0xee, 0x43, 0xf8, 0xba, 0x2, 0x19, 0xed, 0x3a, 0x65, 0x2d, + 0xb9, 0x35, 0xf1, 0xe8, 0xff, 0xdc, 0xf1, 0xc4, 0x48, 0xc6, 0x41, 0xce, 0x77, 0x19, 0x32, 0xb, 0x5, 0x22, 0x1b, + 0x7a, 0x22, 0x2a, 0x6e, 0x1, 0x0, 0x21, 0x1b, 0xc, 0x25, 0xc4, 0x25, 0xd3, 0x8, 0x0, 0x7, 0xb3, 0xb0, 0x53, + 0x82, 0x7c, 0x94, 0x43, 0x16, 0x0, 0x7, 0xa5, 0xe1, 0xe6, 0x62, 0xfe, 0xe7, 0x63, 0x24, 0x4d, 0x12, 0x0, 0x4, + 0x31, 0xb2, 0xfe, 0x9c, 0x25, 0xe0, 0xb, 0x1b, 0x3d, 0x1e, 0xe0, 0x5, 0x22, 0xbb, 0xa5, 0xd3, 0x45, 0x9c, 0x2a, + 0xc, 0x85, 0x4f, 0x78, 0xc5, 0xa2, 0x4a, 0xa8, 0x83, 0xa7, 0x49, 0x1a, 0xbe, 0x29, 0xf0, 0x7f, 0x19, 0xd8, 0xff}; + + uint8_t buf[276] = {0}; + + uint8_t topic_bytes[] = {0x75, 0xc5, 0x1c, 0x9c, 0xe2, 0xe2, 0x9c, 0xc, 0x65, + 0x37, 0x1a, 0x44, 0xfb, 0x7d, 0x84, 0x28, 0x3a, 0x6b}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x3d, 0x1e, 0xe0, 0x5, 0x22, 0xbb, 0xa5, 0xd3, 0x45, 0x9c, 0x2a, 0xc, 0x85, 0x4f, 0x78, + 0xc5, 0xa2, 0x4a, 0xa8, 0x83, 0xa7, 0x49, 0x1a, 0xbe, 0x29, 0xf0, 0x7f, 0x19, 0xd8, 0xff}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + uint8_t bytes0[] = {0x9e, 0x35, 0x1e, 0x19, 0x55, 0x72, 0xe8, 0x81, 0x6b, 0xd5, 0xc9, 0xe2, 0x88, 0x57, 0x9d, + 0x42, 0x98, 0x4e, 0x66, 0x48, 0xe2, 0xb7, 0xa8, 0x95, 0x0, 0xd0, 0xdb, 0xa2, 0x53, 0x13}; + uint8_t bytes2[] = {0x9c, 0x24, 0x4b, 0xf4, 0x35, 0xbe, 0x71, 0x4b, 0x59, 0x50, 0xc5, 0x91}; + uint8_t bytes1[] = {0x7b, 0xca, 0x6, 0x4b, 0x17, 0x73, 0x47, 0x63, 0x3, 0xe, 0x11, + 0xf, 0x8d, 0x9d, 0xc1, 0xaa, 0x5d, 0x40, 0xbf, 0x27, 0xd4, 0xe}; + uint8_t bytes3[] = {0x35, 0xe7, 0x74, 0x6c, 0x5a, 0xcd, 0x2d, 0x1d, 0x37, 0x0, 0x45, 0x39, 0xec}; + uint8_t bytes4[] = {0x41, 0x38, 0x7d, 0x8b, 0xb0, 0xee, 0x43, 0xf8, 0xba, 0x2, 0x19, 0xed, 0x3a, 0x65, + 0x2d, 0xb9, 0x35, 0xf1, 0xe8, 0xff, 0xdc, 0xf1, 0xc4, 0x48, 0xc6, 0x41, 0xce, 0x77}; + uint8_t bytes5[] = {0xb3, 0xb0, 0x53, 0x82, 0x7c, 0x94, 0x43}; + uint8_t bytes6[] = {0xa5, 0xe1, 0xe6, 0x62, 0xfe, 0xe7, 0x63}; + uint8_t bytes7[] = {0x31, 0xb2, 0xfe, 0x9c}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10076}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21513}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20941}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9284}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytes1}, .v = {12, (char*)&bytes2}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29682}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27941}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25188}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24955}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7034}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10862}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6924}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + }; + + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "s`#B\129\251kP3\n8", _pubPktID = +// 13139, _pubBody = "\SI{\192", _pubProps = [PropTopicAliasMaximum 20038,PropWillDelayInterval +// 4,PropMessageExpiryInterval 16799,PropAuthenticationMethod +// "n\245\NUL\b\132\243\147\171\US:\252\174j\252\238\227\US\136\222P*\204\SO",PropWildcardSubscriptionAvailable +// 96,PropUserProperty "\SO5\189\152r\255\130S\241i\bW\182\133G\ENQ\164" "\138",PropAssignedClientIdentifier +// "\185^\DC1\n",PropReceiveMaximum 10939,PropWillDelayInterval 29097,PropReasonString +// "\195\241\255\t\DC3\154\232\EOTC\151\247\159)",PropWildcardSubscriptionAvailable 77,PropReceiveMaximum +// 26989,PropResponseInformation "*\DEL\143\EM\182A\140\169b\SOH\140\220T",PropReceiveMaximum +// 10597,PropMessageExpiryInterval 3410,PropResponseInformation +// "\SO\170\139\156vQ\161\149\ESCb\200\232",PropMaximumPacketSize 6859,PropContentType +// "L\161\225\222E\173&\207\&5M\177\209N\195s\161\181/<\149\147\&8\159.",PropCorrelationData +// "\SYN\231l\140\n\230\254w\228\195\144\244\129\CANo\250j\SYN\177v\190\\g\136{.",PropServerReference +// "\128\253\136A",PropServerReference "\176"]} +TEST(Publish50QCTest, Encode64) { + uint8_t pkt[] = {0x3c, 0xe7, 0x1, 0x0, 0xb, 0x73, 0x60, 0x23, 0x42, 0x81, 0xfb, 0x6b, 0x50, 0x33, 0xa, 0x38, 0x33, + 0x53, 0xd3, 0x1, 0x22, 0x4e, 0x46, 0x18, 0x0, 0x0, 0x0, 0x4, 0x2, 0x0, 0x0, 0x41, 0x9f, 0x15, + 0x0, 0x17, 0x6e, 0xf5, 0x0, 0x8, 0x84, 0xf3, 0x93, 0xab, 0x1f, 0x3a, 0xfc, 0x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}; + + uint8_t buf[244] = {0}; + + uint8_t topic_bytes[] = {0x73, 0x60, 0x23, 0x42, 0x81, 0xfb, 0x6b, 0x50, 0x33, 0xa, 0x38}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xf, 0x7b, 0xc0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; + + uint8_t bytes0[] = {0x6e, 0xf5, 0x0, 0x8, 0x84, 0xf3, 0x93, 0xab, 0x1f, 0x3a, 0xfc, 0xae, + 0x6a, 0xfc, 0xee, 0xe3, 0x1f, 0x88, 0xde, 0x50, 0x2a, 0xcc, 0xe}; + uint8_t bytes2[] = {0x8a}; + uint8_t bytes1[] = {0xe, 0x35, 0xbd, 0x98, 0x72, 0xff, 0x82, 0x53, 0xf1, + 0x69, 0x8, 0x57, 0xb6, 0x85, 0x47, 0x5, 0xa4}; + uint8_t bytes3[] = {0xb9, 0x5e, 0x11, 0xa}; + uint8_t bytes4[] = {0xc3, 0xf1, 0xff, 0x9, 0x13, 0x9a, 0xe8, 0x4, 0x43, 0x97, 0xf7, 0x9f, 0x29}; + uint8_t bytes5[] = {0x2a, 0x7f, 0x8f, 0x19, 0xb6, 0x41, 0x8c, 0xa9, 0x62, 0x1, 0x8c, 0xdc, 0x54}; + uint8_t bytes6[] = {0xe, 0xaa, 0x8b, 0x9c, 0x76, 0x51, 0xa1, 0x95, 0x1b, 0x62, 0xc8, 0xe8}; + uint8_t bytes7[] = {0x4c, 0xa1, 0xe1, 0xde, 0x45, 0xad, 0x26, 0xcf, 0x35, 0x4d, 0xb1, 0xd1, + 0x4e, 0xc3, 0x73, 0xa1, 0xb5, 0x2f, 0x3c, 0x95, 0x93, 0x38, 0x9f, 0x2e}; + uint8_t bytes8[] = {0x16, 0xe7, 0x6c, 0x8c, 0xa, 0xe6, 0xfe, 0x77, 0xe4, 0xc3, 0x90, 0xf4, 0x81, + 0x18, 0x6f, 0xfa, 0x6a, 0x16, 0xb1, 0x76, 0xbe, 0x5c, 0x67, 0x88, 0x7b, 0x2e}; + uint8_t bytes9[] = {0x80, 0xfd, 0x88, 0x41}; + uint8_t bytes10[] = {0xb0}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20038}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16799}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytes1}, .v = {1, (char*)&bytes2}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10939}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29097}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26989}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10597}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3410}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6859}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytes8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytes9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytes10}}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 13139, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163]", _pubPktID = 9229, _pubBody = +// ":,\175v\152}\RS8\178|K\148\f\219\184\129Ep^\n\194\148\SOHv\\\ETB\253^", _pubProps = [PropRequestProblemInformation +// 195]} +TEST(Publish50QCTest, Encode65) { + uint8_t pkt[] = {0x3c, 0x25, 0x0, 0x2, 0xa3, 0x5d, 0x24, 0xd, 0x2, 0x17, 0xc3, 0x3a, 0x2c, + 0xaf, 0x76, 0x98, 0x7d, 0x1e, 0x38, 0xb2, 0x7c, 0x4b, 0x94, 0xc, 0xdb, 0xb8, + 0x81, 0x45, 0x70, 0x5e, 0xa, 0xc2, 0x94, 0x1, 0x76, 0x5c, 0x17, 0xfd, 0x5e}; + + uint8_t buf[49] = {0}; + + uint8_t topic_bytes[] = {0xa3, 0x5d}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x3a, 0x2c, 0xaf, 0x76, 0x98, 0x7d, 0x1e, 0x38, 0xb2, 0x7c, 0x4b, 0x94, 0xc, 0xdb, + 0xb8, 0x81, 0x45, 0x70, 0x5e, 0xa, 0xc2, 0x94, 0x1, 0x76, 0x5c, 0x17, 0xfd, 0x5e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 28; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 9229, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "'\148R\STX\207v\202o[1\154JIl\129\189\&9.\231\220u\233\200G\f \241\196M:", _pubPktID = 0, _pubBody = +// "\239\141wL\FS\241\255ZW8R\f\CAN\ACKT\215)ZZ\200z\239", _pubProps = []} +TEST(Publish50QCTest, Encode66) { + uint8_t pkt[] = {0x30, 0x37, 0x0, 0x1e, 0x27, 0x94, 0x52, 0x2, 0xcf, 0x76, 0xca, 0x6f, 0x5b, 0x31, 0x9a, + 0x4a, 0x49, 0x6c, 0x81, 0xbd, 0x39, 0x2e, 0xe7, 0xdc, 0x75, 0xe9, 0xc8, 0x47, 0xc, 0x20, + 0xf1, 0xc4, 0x4d, 0x3a, 0x0, 0xef, 0x8d, 0x77, 0x4c, 0x1c, 0xf1, 0xff, 0x5a, 0x57, 0x38, + 0x52, 0xc, 0x18, 0x6, 0x54, 0xd7, 0x29, 0x5a, 0x5a, 0xc8, 0x7a, 0xef}; + + uint8_t buf[67] = {0}; + + uint8_t topic_bytes[] = {0x27, 0x94, 0x52, 0x2, 0xcf, 0x76, 0xca, 0x6f, 0x5b, 0x31, 0x9a, 0x4a, 0x49, 0x6c, 0x81, + 0xbd, 0x39, 0x2e, 0xe7, 0xdc, 0x75, 0xe9, 0xc8, 0x47, 0xc, 0x20, 0xf1, 0xc4, 0x4d, 0x3a}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xef, 0x8d, 0x77, 0x4c, 0x1c, 0xf1, 0xff, 0x5a, 0x57, 0x38, 0x52, + 0xc, 0x18, 0x6, 0x54, 0xd7, 0x29, 0x5a, 0x5a, 0xc8, 0x7a, 0xef}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + lwmqtt_property_t proplist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "9\140\202\235A\137*\ESC\202=k\179\211?\NAK\238", _pubPktID = 0, _pubBody = +// "R\140Q\187\192\240\209=*\152Ov\136\254G\251", _pubProps = [PropSessionExpiryInterval 12836,PropReasonString +// "\212\&7L\201\&2RS\250\130\218\228X\171\197",PropPayloadFormatIndicator 191,PropAssignedClientIdentifier +// "\132Z\DC2^H\ti\DC2b{VW\DLE\237\193\236y\207\132\236\133\&2\247\230\185j\233",PropMessageExpiryInterval +// 20000,PropAssignedClientIdentifier "\235\132",PropSubscriptionIdentifierAvailable 255,PropAssignedClientIdentifier +// "\\!\192"]} +TEST(Publish50QCTest, Encode67) { + uint8_t pkt[] = {0x38, 0x6b, 0x0, 0x10, 0x39, 0x8c, 0xca, 0xeb, 0x41, 0x89, 0x2a, 0x1b, 0xca, 0x3d, 0x6b, 0xb3, + 0xd3, 0x3f, 0x15, 0xee, 0x48, 0x11, 0x0, 0x0, 0x32, 0x24, 0x1f, 0x0, 0xe, 0xd4, 0x37, 0x4c, + 0xc9, 0x32, 0x52, 0x53, 0xfa, 0x82, 0xda, 0xe4, 0x58, 0xab, 0xc5, 0x1, 0xbf, 0x12, 0x0, 0x1b, + 0x84, 0x5a, 0x12, 0x5e, 0x48, 0x9, 0x69, 0x12, 0x62, 0x7b, 0x56, 0x57, 0x10, 0xed, 0xc1, 0xec, + 0x79, 0xcf, 0x84, 0xec, 0x85, 0x32, 0xf7, 0xe6, 0xb9, 0x6a, 0xe9, 0x2, 0x0, 0x0, 0x4e, 0x20, + 0x12, 0x0, 0x2, 0xeb, 0x84, 0x29, 0xff, 0x12, 0x0, 0x3, 0x5c, 0x21, 0xc0, 0x52, 0x8c, 0x51, + 0xbb, 0xc0, 0xf0, 0xd1, 0x3d, 0x2a, 0x98, 0x4f, 0x76, 0x88, 0xfe, 0x47, 0xfb}; + + uint8_t buf[119] = {0}; + + uint8_t topic_bytes[] = {0x39, 0x8c, 0xca, 0xeb, 0x41, 0x89, 0x2a, 0x1b, + 0xca, 0x3d, 0x6b, 0xb3, 0xd3, 0x3f, 0x15, 0xee}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x52, 0x8c, 0x51, 0xbb, 0xc0, 0xf0, 0xd1, 0x3d, + 0x2a, 0x98, 0x4f, 0x76, 0x88, 0xfe, 0x47, 0xfb}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 16; + + uint8_t bytes0[] = {0xd4, 0x37, 0x4c, 0xc9, 0x32, 0x52, 0x53, 0xfa, 0x82, 0xda, 0xe4, 0x58, 0xab, 0xc5}; + uint8_t bytes1[] = {0x84, 0x5a, 0x12, 0x5e, 0x48, 0x9, 0x69, 0x12, 0x62, 0x7b, 0x56, 0x57, 0x10, 0xed, + 0xc1, 0xec, 0x79, 0xcf, 0x84, 0xec, 0x85, 0x32, 0xf7, 0xe6, 0xb9, 0x6a, 0xe9}; + uint8_t bytes2[] = {0xeb, 0x84}; + uint8_t bytes3[] = {0x5c, 0x21, 0xc0}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12836}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20000}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytes3}}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\255\250\242r^\171,{\253\254\200\128\135\225AG\149\&3", _pubPktID = 19170, _pubBody = "\GS", _pubProps = +// [PropSharedSubscriptionAvailable 230,PropSubscriptionIdentifier 28,PropSessionExpiryInterval +// 9477,PropRequestResponseInformation 163,PropMessageExpiryInterval 21809,PropSessionExpiryInterval +// 8934,PropResponseTopic "\199<",PropUserProperty +// "\129\ETX\208\ETB\196\158Qu\159\148\214\188\150\178\245\221\132'\211\210Y3P?\213\203>\FS\CAN\254" +// "\163Q\173\EM\170\129!C\233Q\SYN\222A\247\188\DLEi\212Q&\DC3f\210\EOT)\247|",PropMaximumPacketSize +// 16084,PropReasonString +// "\178qh\NUL\211\202\136\v{\236\\\230\164^\174A\145]\225\172f\226\&6\180\&2\153",PropServerKeepAlive +// 25512,PropMaximumPacketSize 3094,PropSessionExpiryInterval 15014,PropAssignedClientIdentifier +// "G\195%\131\199\242(\164v\GSB\v<\196\189\157\239\176\212\&5",PropRequestProblemInformation 144,PropRetainAvailable +// 71,PropWillDelayInterval 2627,PropReceiveMaximum 5184,PropPayloadFormatIndicator 224,PropMaximumPacketSize +// 19270,PropResponseTopic "\129-",PropResponseTopic +// "\185\237\209\&5,!n\140\229\238\NUL\134\185\187&\156\NUL\146\218\154",PropCorrelationData +// "l\248\NUL\229\&1\216\236\166i\253\ETX\n\171if1\180\130\DC4\192\209\198\146",PropRequestResponseInformation 61]} +TEST(Publish50QCTest, Encode68) { + uint8_t pkt[] = { + 0x35, 0x82, 0x2, 0x0, 0x12, 0xff, 0xfa, 0xf2, 0x72, 0x5e, 0xab, 0x2c, 0x7b, 0xfd, 0xfe, 0xc8, 0x80, 0x87, 0xe1, + 0x41, 0x47, 0x95, 0x33, 0x4a, 0xe2, 0xe9, 0x1, 0x2a, 0xe6, 0xb, 0x1c, 0x11, 0x0, 0x0, 0x25, 0x5, 0x19, 0xa3, + 0x2, 0x0, 0x0, 0x55, 0x31, 0x11, 0x0, 0x0, 0x22, 0xe6, 0x8, 0x0, 0x2, 0xc7, 0x3c, 0x26, 0x0, 0x1e, 0x81, + 0x3, 0xd0, 0x17, 0xc4, 0x9e, 0x51, 0x75, 0x9f, 0x94, 0xd6, 0xbc, 0x96, 0xb2, 0xf5, 0xdd, 0x84, 0x27, 0xd3, 0xd2, + 0x59, 0x33, 0x50, 0x3f, 0xd5, 0xcb, 0x3e, 0x1c, 0x18, 0xfe, 0x0, 0x1b, 0xa3, 0x51, 0xad, 0x19, 0xaa, 0x81, 0x21, + 0x43, 0xe9, 0x51, 0x16, 0xde, 0x41, 0xf7, 0xbc, 0x10, 0x69, 0xd4, 0x51, 0x26, 0x13, 0x66, 0xd2, 0x4, 0x29, 0xf7, + 0x7c, 0x27, 0x0, 0x0, 0x3e, 0xd4, 0x1f, 0x0, 0x1a, 0xb2, 0x71, 0x68, 0x0, 0xd3, 0xca, 0x88, 0xb, 0x7b, 0xec, + 0x5c, 0xe6, 0xa4, 0x5e, 0xae, 0x41, 0x91, 0x5d, 0xe1, 0xac, 0x66, 0xe2, 0x36, 0xb4, 0x32, 0x99, 0x13, 0x63, 0xa8, + 0x27, 0x0, 0x0, 0xc, 0x16, 0x11, 0x0, 0x0, 0x3a, 0xa6, 0x12, 0x0, 0x14, 0x47, 0xc3, 0x25, 0x83, 0xc7, 0xf2, + 0x28, 0xa4, 0x76, 0x1d, 0x42, 0xb, 0x3c, 0xc4, 0xbd, 0x9d, 0xef, 0xb0, 0xd4, 0x35, 0x17, 0x90, 0x25, 0x47, 0x18, + 0x0, 0x0, 0xa, 0x43, 0x21, 0x14, 0x40, 0x1, 0xe0, 0x27, 0x0, 0x0, 0x4b, 0x46, 0x8, 0x0, 0x2, 0x81, 0x2d, + 0x8, 0x0, 0x14, 0xb9, 0xed, 0xd1, 0x35, 0x2c, 0x21, 0x6e, 0x8c, 0xe5, 0xee, 0x0, 0x86, 0xb9, 0xbb, 0x26, 0x9c, + 0x0, 0x92, 0xda, 0x9a, 0x9, 0x0, 0x17, 0x6c, 0xf8, 0x0, 0xe5, 0x31, 0xd8, 0xec, 0xa6, 0x69, 0xfd, 0x3, 0xa, + 0xab, 0x69, 0x66, 0x31, 0xb4, 0x82, 0x14, 0xc0, 0xd1, 0xc6, 0x92, 0x19, 0x3d, 0x1d}; + + uint8_t buf[271] = {0}; + + uint8_t topic_bytes[] = {0xff, 0xfa, 0xf2, 0x72, 0x5e, 0xab, 0x2c, 0x7b, 0xfd, + 0xfe, 0xc8, 0x80, 0x87, 0xe1, 0x41, 0x47, 0x95, 0x33}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x1d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + uint8_t bytes0[] = {0xc7, 0x3c}; + uint8_t bytes2[] = {0xa3, 0x51, 0xad, 0x19, 0xaa, 0x81, 0x21, 0x43, 0xe9, 0x51, 0x16, 0xde, 0x41, 0xf7, + 0xbc, 0x10, 0x69, 0xd4, 0x51, 0x26, 0x13, 0x66, 0xd2, 0x4, 0x29, 0xf7, 0x7c}; + uint8_t bytes1[] = {0x81, 0x3, 0xd0, 0x17, 0xc4, 0x9e, 0x51, 0x75, 0x9f, 0x94, 0xd6, 0xbc, 0x96, 0xb2, 0xf5, + 0xdd, 0x84, 0x27, 0xd3, 0xd2, 0x59, 0x33, 0x50, 0x3f, 0xd5, 0xcb, 0x3e, 0x1c, 0x18, 0xfe}; + uint8_t bytes3[] = {0xb2, 0x71, 0x68, 0x0, 0xd3, 0xca, 0x88, 0xb, 0x7b, 0xec, 0x5c, 0xe6, 0xa4, + 0x5e, 0xae, 0x41, 0x91, 0x5d, 0xe1, 0xac, 0x66, 0xe2, 0x36, 0xb4, 0x32, 0x99}; + uint8_t bytes4[] = {0x47, 0xc3, 0x25, 0x83, 0xc7, 0xf2, 0x28, 0xa4, 0x76, 0x1d, + 0x42, 0xb, 0x3c, 0xc4, 0xbd, 0x9d, 0xef, 0xb0, 0xd4, 0x35}; + uint8_t bytes5[] = {0x81, 0x2d}; + uint8_t bytes6[] = {0xb9, 0xed, 0xd1, 0x35, 0x2c, 0x21, 0x6e, 0x8c, 0xe5, 0xee, + 0x0, 0x86, 0xb9, 0xbb, 0x26, 0x9c, 0x0, 0x92, 0xda, 0x9a}; + uint8_t bytes7[] = {0x6c, 0xf8, 0x0, 0xe5, 0x31, 0xd8, 0xec, 0xa6, 0x69, 0xfd, 0x3, 0xa, + 0xab, 0x69, 0x66, 0x31, 0xb4, 0x82, 0x14, 0xc0, 0xd1, 0xc6, 0x92}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9477}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21809}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8934}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytes1}, .v = {27, (char*)&bytes2}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16084}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25512}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3094}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15014}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2627}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5184}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19270}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 61}}, + }; + + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19170, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\f<\223\175\243\197\227\253.l\204M\219\195\149\202\132\194\182\a\CAN\n9't=\191\DLEb", _pubPktID = 0, _pubBody = "", +// _pubProps = [PropTopicAlias 334,PropWildcardSubscriptionAvailable 17,PropSubscriptionIdentifier +// 0,PropMaximumPacketSize 32749,PropTopicAlias 3598,PropCorrelationData "",PropRetainAvailable +// 42,PropSessionExpiryInterval 32318,PropReasonString +// "\b\ENQ\138(U2\245\US\160X+l\225\b;\245\194\235\215",PropMessageExpiryInterval 21429,PropMessageExpiryInterval +// 13732,PropContentType "\195\&1\"",PropReceiveMaximum 17292,PropPayloadFormatIndicator 73,PropServerReference +// "X\CAN",PropSessionExpiryInterval 11644,PropMaximumPacketSize 8238,PropSubscriptionIdentifier +// 1,PropAuthenticationMethod "\246\190\168y\189\fU\139%\150w\236\255\134bw$#\156J",PropTopicAliasMaximum 15559]} +TEST(Publish50QCTest, Encode69) { + uint8_t pkt[] = {0x31, 0x8f, 0x1, 0x0, 0x1d, 0xc, 0x3c, 0xdf, 0xaf, 0xf3, 0xc5, 0xe3, 0xfd, 0x2e, 0x6c, 0xcc, 0x4d, + 0xdb, 0xc3, 0x95, 0xca, 0x84, 0xc2, 0xb6, 0x7, 0x18, 0xa, 0x39, 0x27, 0x74, 0x3d, 0xbf, 0x10, 0x62, + 0x6f, 0x23, 0x1, 0x4e, 0x28, 0x11, 0xb, 0x0, 0x27, 0x0, 0x0, 0x7f, 0xed, 0x23, 0xe, 0xe, 0x9, + 0x0, 0x0, 0x25, 0x2a, 0x11, 0x0, 0x0, 0x7e, 0x3e, 0x1f, 0x0, 0x13, 0x8, 0x5, 0x8a, 0x28, 0x55, + 0x32, 0xf5, 0x1f, 0xa0, 0x58, 0x2b, 0x6c, 0xe1, 0x8, 0x3b, 0xf5, 0xc2, 0xeb, 0xd7, 0x2, 0x0, 0x0, + 0x53, 0xb5, 0x2, 0x0, 0x0, 0x35, 0xa4, 0x3, 0x0, 0x3, 0xc3, 0x31, 0x22, 0x21, 0x43, 0x8c, 0x1, + 0x49, 0x1c, 0x0, 0x2, 0x58, 0x18, 0x11, 0x0, 0x0, 0x2d, 0x7c, 0x27, 0x0, 0x0, 0x20, 0x2e, 0xb, + 0x1, 0x15, 0x0, 0x14, 0xf6, 0xbe, 0xa8, 0x79, 0xbd, 0xc, 0x55, 0x8b, 0x25, 0x96, 0x77, 0xec, 0xff, + 0x86, 0x62, 0x77, 0x24, 0x23, 0x9c, 0x4a, 0x22, 0x3c, 0xc7}; + + uint8_t buf[156] = {0}; + + uint8_t topic_bytes[] = {0xc, 0x3c, 0xdf, 0xaf, 0xf3, 0xc5, 0xe3, 0xfd, 0x2e, 0x6c, 0xcc, 0x4d, 0xdb, 0xc3, 0x95, + 0xca, 0x84, 0xc2, 0xb6, 0x7, 0x18, 0xa, 0x39, 0x27, 0x74, 0x3d, 0xbf, 0x10, 0x62}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 0; + + uint8_t bytes0[] = {0}; + uint8_t bytes1[] = {0x8, 0x5, 0x8a, 0x28, 0x55, 0x32, 0xf5, 0x1f, 0xa0, 0x58, + 0x2b, 0x6c, 0xe1, 0x8, 0x3b, 0xf5, 0xc2, 0xeb, 0xd7}; + uint8_t bytes2[] = {0xc3, 0x31, 0x22}; + uint8_t bytes3[] = {0x58, 0x18}; + uint8_t bytes4[] = {0xf6, 0xbe, 0xa8, 0x79, 0xbd, 0xc, 0x55, 0x8b, 0x25, 0x96, + 0x77, 0xec, 0xff, 0x86, 0x62, 0x77, 0x24, 0x23, 0x9c, 0x4a}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 334}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32749}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3598}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32318}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21429}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13732}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17292}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11644}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8238}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15559}}, + }; + + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "3", _pubPktID = 27883, _pubBody = +// "\246\DC1,I\237\135\&0/\210\164\233\223de\144\250\141\134\&7\190\194\144\206f", _pubProps = [PropAuthenticationMethod +// "\195\194\210\230\229\150\219\249U\138\166",PropWillDelayInterval 14395,PropCorrelationData +// "\158\CAN\204\138JY\200L<\DLE\222\EM)\226\187\231\135\210b\213\210M\138",PropSharedSubscriptionAvailable +// 79,PropWildcardSubscriptionAvailable 151,PropSubscriptionIdentifier 14,PropRequestProblemInformation +// 161,PropMaximumPacketSize 1060,PropUserProperty "\DC3\DC4" +// "\194\228\135J\132\STX\142\240\151\232\&61\SUB\209\&9\196\239>\164\199\135*\DC4i\209U\249\141`",PropCorrelationData +// "\DEL\147\DC4\151\240\167\160",PropAuthenticationMethod ")\144K\213\b\184g\198\155\130\129\226\228",PropMaximumQoS +// 81,PropReceiveMaximum 31610,PropRetainAvailable 169,PropUserProperty "" +// "\STX3{\205\249\CAN\163\249\STX\163[\234w\171y\204\137\132LG\220o\136\232'\139",PropRequestProblemInformation +// 16,PropAuthenticationMethod "Mr\191c\DC3Cu\146",PropMessageExpiryInterval 9582,PropSubscriptionIdentifier +// 30,PropTopicAlias 11509,PropRetainAvailable 152,PropServerReference +// "\202\180om\130\155\ACK\SOH\132\133\GS60\180\192p\134\165XD\141",PropMaximumPacketSize 16715,PropServerKeepAlive +// 20089,PropRequestProblemInformation 33,PropAuthenticationMethod "[\147\255\210\188L\234",PropAuthenticationData +// "\245/\232\f\183\r\203n\143z\223<\DC3\169\173\183\253h\143\247\134b\129H\234",PropSubscriptionIdentifierAvailable +// 150,PropSubscriptionIdentifierAvailable 209,PropMessageExpiryInterval 29310]} +TEST(Publish50QCTest, Encode70) { + uint8_t pkt[] = { + 0x33, 0xa7, 0x2, 0x0, 0x1, 0x33, 0x6c, 0xeb, 0x88, 0x2, 0x15, 0x0, 0xb, 0xc3, 0xc2, 0xd2, 0xe6, 0xe5, 0x96, + 0xdb, 0xf9, 0x55, 0x8a, 0xa6, 0x18, 0x0, 0x0, 0x38, 0x3b, 0x9, 0x0, 0x17, 0x9e, 0x18, 0xcc, 0x8a, 0x4a, 0x59, + 0xc8, 0x4c, 0x3c, 0x10, 0xde, 0x19, 0x29, 0xe2, 0xbb, 0xe7, 0x87, 0xd2, 0x62, 0xd5, 0xd2, 0x4d, 0x8a, 0x2a, 0x4f, + 0x28, 0x97, 0xb, 0xe, 0x17, 0xa1, 0x27, 0x0, 0x0, 0x4, 0x24, 0x26, 0x0, 0x2, 0x13, 0x14, 0x0, 0x1d, 0xc2, + 0xe4, 0x87, 0x4a, 0x84, 0x2, 0x8e, 0xf0, 0x97, 0xe8, 0x36, 0x31, 0x1a, 0xd1, 0x39, 0xc4, 0xef, 0x3e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30, 0x2f, 0xd2, 0xa4, 0xe9, + 0xdf, 0x64, 0x65, 0x90, 0xfa, 0x8d, 0x86, 0x37, 0xbe, 0xc2, 0x90, 0xce, 0x66}; + + uint8_t buf[308] = {0}; + + uint8_t topic_bytes[] = {0x33}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xf6, 0x11, 0x2c, 0x49, 0xed, 0x87, 0x30, 0x2f, 0xd2, 0xa4, 0xe9, 0xdf, + 0x64, 0x65, 0x90, 0xfa, 0x8d, 0x86, 0x37, 0xbe, 0xc2, 0x90, 0xce, 0x66}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + uint8_t bytes0[] = {0xc3, 0xc2, 0xd2, 0xe6, 0xe5, 0x96, 0xdb, 0xf9, 0x55, 0x8a, 0xa6}; + uint8_t bytes1[] = {0x9e, 0x18, 0xcc, 0x8a, 0x4a, 0x59, 0xc8, 0x4c, 0x3c, 0x10, 0xde, 0x19, + 0x29, 0xe2, 0xbb, 0xe7, 0x87, 0xd2, 0x62, 0xd5, 0xd2, 0x4d, 0x8a}; + uint8_t bytes3[] = {0xc2, 0xe4, 0x87, 0x4a, 0x84, 0x2, 0x8e, 0xf0, 0x97, 0xe8, 0x36, 0x31, 0x1a, 0xd1, 0x39, + 0xc4, 0xef, 0x3e, 0xa4, 0xc7, 0x87, 0x2a, 0x14, 0x69, 0xd1, 0x55, 0xf9, 0x8d, 0x60}; + uint8_t bytes2[] = {0x13, 0x14}; + uint8_t bytes4[] = {0x7f, 0x93, 0x14, 0x97, 0xf0, 0xa7, 0xa0}; + uint8_t bytes5[] = {0x29, 0x90, 0x4b, 0xd5, 0x8, 0xb8, 0x67, 0xc6, 0x9b, 0x82, 0x81, 0xe2, 0xe4}; + uint8_t bytes7[] = {0x2, 0x33, 0x7b, 0xcd, 0xf9, 0x18, 0xa3, 0xf9, 0x2, 0xa3, 0x5b, 0xea, 0x77, + 0xab, 0x79, 0xcc, 0x89, 0x84, 0x4c, 0x47, 0xdc, 0x6f, 0x88, 0xe8, 0x27, 0x8b}; + uint8_t bytes6[] = {0}; + uint8_t bytes8[] = {0x4d, 0x72, 0xbf, 0x63, 0x13, 0x43, 0x75, 0x92}; + uint8_t bytes9[] = {0xca, 0xb4, 0x6f, 0x6d, 0x82, 0x9b, 0x6, 0x1, 0x84, 0x85, 0x1d, + 0x36, 0x30, 0xb4, 0xc0, 0x70, 0x86, 0xa5, 0x58, 0x44, 0x8d}; + uint8_t bytes10[] = {0x5b, 0x93, 0xff, 0xd2, 0xbc, 0x4c, 0xea}; + uint8_t bytes11[] = {0xf5, 0x2f, 0xe8, 0xc, 0xb7, 0xd, 0xcb, 0x6e, 0x8f, 0x7a, 0xdf, 0x3c, 0x13, + 0xa9, 0xad, 0xb7, 0xfd, 0x68, 0x8f, 0xf7, 0x86, 0x62, 0x81, 0x48, 0xea}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14395}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1060}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytes2}, .v = {29, (char*)&bytes3}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31610}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytes6}, .v = {26, (char*)&bytes7}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytes8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9582}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11509}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytes9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16715}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20089}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytes10}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytes11}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29310}}, + }; + + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 27883, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\210\n\244+\148\225\234\&5U\226r16\207\137\NAK}\GSX\204\250S\144\151b\224\184", _pubPktID = 20202, _pubBody = +// "\191\207\175uEn7\171\238\203\140\210I\200!", _pubProps = [PropPayloadFormatIndicator 182,PropMaximumPacketSize +// 28588,PropServerReference "j\171\148\SI\US\208\ENQ`Y;\139\177\US",PropContentType +// "<\SYNI\ACK\SYN\215\212\SUB\196.\133\r\240J\211"]} +TEST(Publish50QCTest, Encode71) { + uint8_t pkt[] = {0x3b, 0x58, 0x0, 0x1b, 0xd2, 0xa, 0xf4, 0x2b, 0x94, 0xe1, 0xea, 0x35, 0x55, 0xe2, 0x72, + 0x31, 0x36, 0xcf, 0x89, 0x15, 0x7d, 0x1d, 0x58, 0xcc, 0xfa, 0x53, 0x90, 0x97, 0x62, 0xe0, + 0xb8, 0x4e, 0xea, 0x29, 0x1, 0xb6, 0x27, 0x0, 0x0, 0x6f, 0xac, 0x1c, 0x0, 0xd, 0x6a, + 0xab, 0x94, 0xf, 0x1f, 0xd0, 0x5, 0x60, 0x59, 0x3b, 0x8b, 0xb1, 0x1f, 0x3, 0x0, 0xf, + 0x3c, 0x16, 0x49, 0x6, 0x16, 0xd7, 0xd4, 0x1a, 0xc4, 0x2e, 0x85, 0xd, 0xf0, 0x4a, 0xd3, + 0xbf, 0xcf, 0xaf, 0x75, 0x45, 0x6e, 0x37, 0xab, 0xee, 0xcb, 0x8c, 0xd2, 0x49, 0xc8, 0x21}; + + uint8_t buf[100] = {0}; + + uint8_t topic_bytes[] = {0xd2, 0xa, 0xf4, 0x2b, 0x94, 0xe1, 0xea, 0x35, 0x55, 0xe2, 0x72, 0x31, 0x36, 0xcf, + 0x89, 0x15, 0x7d, 0x1d, 0x58, 0xcc, 0xfa, 0x53, 0x90, 0x97, 0x62, 0xe0, 0xb8}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xbf, 0xcf, 0xaf, 0x75, 0x45, 0x6e, 0x37, 0xab, 0xee, 0xcb, 0x8c, 0xd2, 0x49, 0xc8, 0x21}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 15; + + uint8_t bytes0[] = {0x6a, 0xab, 0x94, 0xf, 0x1f, 0xd0, 0x5, 0x60, 0x59, 0x3b, 0x8b, 0xb1, 0x1f}; + uint8_t bytes1[] = {0x3c, 0x16, 0x49, 0x6, 0x16, 0xd7, 0xd4, 0x1a, 0xc4, 0x2e, 0x85, 0xd, 0xf0, 0x4a, 0xd3}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28588}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytes1}}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 20202, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\240\247\161\170\180S\251(.\139\187\RS\199\\\USs\207!7\250\&8&q\ESC\236\153", _pubPktID = 1829, _pubBody = +// ")B\201\179\163\188%[\184\154\EOT\146x7,\DC3\v\180\DLE", _pubProps = []} +TEST(Publish50QCTest, Encode72) { + uint8_t pkt[] = {0x3b, 0x32, 0x0, 0x1a, 0xf0, 0xf7, 0xa1, 0xaa, 0xb4, 0x53, 0xfb, 0x28, 0x2e, + 0x8b, 0xbb, 0x1e, 0xc7, 0x5c, 0x1f, 0x73, 0xcf, 0x21, 0x37, 0xfa, 0x38, 0x26, + 0x71, 0x1b, 0xec, 0x99, 0x7, 0x25, 0x0, 0x29, 0x42, 0xc9, 0xb3, 0xa3, 0xbc, + 0x25, 0x5b, 0xb8, 0x9a, 0x4, 0x92, 0x78, 0x37, 0x2c, 0x13, 0xb, 0xb4, 0x10}; + + uint8_t buf[62] = {0}; + + uint8_t topic_bytes[] = {0xf0, 0xf7, 0xa1, 0xaa, 0xb4, 0x53, 0xfb, 0x28, 0x2e, 0x8b, 0xbb, 0x1e, 0xc7, + 0x5c, 0x1f, 0x73, 0xcf, 0x21, 0x37, 0xfa, 0x38, 0x26, 0x71, 0x1b, 0xec, 0x99}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x29, 0x42, 0xc9, 0xb3, 0xa3, 0xbc, 0x25, 0x5b, 0xb8, 0x9a, + 0x4, 0x92, 0x78, 0x37, 0x2c, 0x13, 0xb, 0xb4, 0x10}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 19; + + lwmqtt_property_t proplist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1829, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "2k\146\244f\164\212\DC4o\197\186", +// _pubPktID = 0, _pubBody = "\216C\204\149", _pubProps = [PropResponseInformation +// "\189\143\&7\208\157']\n\207h\170\135\185",PropTopicAlias 905,PropResponseInformation +// "(S#\129:\175\&6\\j\f\184",PropRetainAvailable 68,PropMessageExpiryInterval 2801,PropSubscriptionIdentifier +// 20,PropTopicAliasMaximum 11510,PropAuthenticationData "\149\174\219\206\t",PropResponseInformation +// "\241\162\172\ESCY\144\ESCi\173\161\226Ik~\223\241\156x:\146\189M\204\179l(\170\DC4\ESC\177",PropAuthenticationData +// "\228\198\249\US\SYN\174$s\190%\147l\STX\171\225",PropWillDelayInterval 23982,PropTopicAlias +// 22742,PropWillDelayInterval 9688,PropMaximumPacketSize 11022,PropMaximumPacketSize 529,PropContentType +// "\208\ENQ\139\200\190L[\NAK/\159J\166\253\&8\246\US=,\132F\\\">",PropRetainAvailable 140,PropAssignedClientIdentifier +// ".\205\221\172{\ESC\207\246\129",PropReceiveMaximum 15742]} +TEST(Publish50QCTest, Encode73) { + uint8_t pkt[] = {0x39, 0xbd, 0x1, 0x0, 0xb, 0x32, 0x6b, 0x92, 0xf4, 0x66, 0xa4, 0xd4, 0x14, 0x6f, 0xc5, 0xba, + 0xaa, 0x1, 0x1a, 0x0, 0xd, 0xbd, 0x8f, 0x37, 0xd0, 0x9d, 0x27, 0x5d, 0xa, 0xcf, 0x68, 0xaa, + 0x87, 0xb9, 0x23, 0x3, 0x89, 0x1a, 0x0, 0xb, 0x28, 0x53, 0x23, 0x81, 0x3a, 0xaf, 0x36, 0x5c, + 0x6a, 0xc, 0xb8, 0x25, 0x44, 0x2, 0x0, 0x0, 0xa, 0xf1, 0xb, 0x14, 0x22, 0x2c, 0xf6, 0x16, + 0x0, 0x5, 0x95, 0xae, 0xdb, 0xce, 0x9, 0x1a, 0x0, 0x1e, 0xf1, 0xa2, 0xac, 0x1b, 0x59, 0x90, + 0x1b, 0x69, 0xad, 0xa1, 0xe2, 0x49, 0x6b, 0x7e, 0xdf, 0xf1, 0x9c, 0x78, 0x3a, 0x92, 0xbd, 0x4d, + 0xcc, 0xb3, 0x6c, 0x28, 0xaa, 0x14, 0x1b, 0xb1, 0x16, 0x0, 0xf, 0xe4, 0xc6, 0xf9, 0x1f, 0x16, + 0xae, 0x24, 0x73, 0xbe, 0x25, 0x93, 0x6c, 0x2, 0xab, 0xe1, 0x18, 0x0, 0x0, 0x5d, 0xae, 0x23, + 0x58, 0xd6, 0x18, 0x0, 0x0, 0x25, 0xd8, 0x27, 0x0, 0x0, 0x2b, 0xe, 0x27, 0x0, 0x0, 0x2, + 0x11, 0x3, 0x0, 0x17, 0xd0, 0x5, 0x8b, 0xc8, 0xbe, 0x4c, 0x5b, 0x15, 0x2f, 0x9f, 0x4a, 0xa6, + 0xfd, 0x38, 0xf6, 0x1f, 0x3d, 0x2c, 0x84, 0x46, 0x5c, 0x22, 0x3e, 0x25, 0x8c, 0x12, 0x0, 0x9, + 0x2e, 0xcd, 0xdd, 0xac, 0x7b, 0x1b, 0xcf, 0xf6, 0x81, 0x21, 0x3d, 0x7e, 0xd8, 0x43, 0xcc, 0x95}; + + uint8_t buf[202] = {0}; + + uint8_t topic_bytes[] = {0x32, 0x6b, 0x92, 0xf4, 0x66, 0xa4, 0xd4, 0x14, 0x6f, 0xc5, 0xba}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xd8, 0x43, 0xcc, 0x95}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; + + uint8_t bytes0[] = {0xbd, 0x8f, 0x37, 0xd0, 0x9d, 0x27, 0x5d, 0xa, 0xcf, 0x68, 0xaa, 0x87, 0xb9}; + uint8_t bytes1[] = {0x28, 0x53, 0x23, 0x81, 0x3a, 0xaf, 0x36, 0x5c, 0x6a, 0xc, 0xb8}; + uint8_t bytes2[] = {0x95, 0xae, 0xdb, 0xce, 0x9}; + uint8_t bytes3[] = {0xf1, 0xa2, 0xac, 0x1b, 0x59, 0x90, 0x1b, 0x69, 0xad, 0xa1, 0xe2, 0x49, 0x6b, 0x7e, 0xdf, + 0xf1, 0x9c, 0x78, 0x3a, 0x92, 0xbd, 0x4d, 0xcc, 0xb3, 0x6c, 0x28, 0xaa, 0x14, 0x1b, 0xb1}; + uint8_t bytes4[] = {0xe4, 0xc6, 0xf9, 0x1f, 0x16, 0xae, 0x24, 0x73, 0xbe, 0x25, 0x93, 0x6c, 0x2, 0xab, 0xe1}; + uint8_t bytes5[] = {0xd0, 0x5, 0x8b, 0xc8, 0xbe, 0x4c, 0x5b, 0x15, 0x2f, 0x9f, 0x4a, 0xa6, + 0xfd, 0x38, 0xf6, 0x1f, 0x3d, 0x2c, 0x84, 0x46, 0x5c, 0x22, 0x3e}; + uint8_t bytes6[] = {0x2e, 0xcd, 0xdd, 0xac, 0x7b, 0x1b, 0xcf, 0xf6, 0x81}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 905}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2801}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11510}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23982}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22742}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9688}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11022}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 529}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15742}}, + }; + + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "Q\199\US@hY\186f", _pubPktID = 684, +// _pubBody = "\DC1/\179\209 !\230/\187 \220\191\212", _pubProps = [PropMessageExpiryInterval 7888,PropWillDelayInterval +// 17341,PropResponseInformation "\232fp5\196\NUL",PropServerKeepAlive 17171,PropSharedSubscriptionAvailable +// 63,PropSessionExpiryInterval 30264,PropSharedSubscriptionAvailable 216,PropMaximumQoS 204,PropUserProperty +// "j\212e\SI\142oh\223\173\193z\253\DEL\248\201Ich\ENQ\207k\196\242\191\184T\231\156\222V" +// "\197O\DC1F\226\213\DC2!\CAN\207\191\167#\164s\SUB\176\130",PropResponseInformation +// "Iy\EM]\189",PropSessionExpiryInterval 7138,PropSubscriptionIdentifierAvailable 233,PropWillDelayInterval 14012]} +TEST(Publish50QCTest, Encode76) { + uint8_t pkt[] = {0x34, 0x83, 0x1, 0x0, 0xb, 0x6f, 0x78, 0xfe, 0x51, 0x65, 0xcb, 0x3c, 0xb0, 0xc3, 0x45, 0x53, 0x51, + 0x8c, 0x5b, 0x8, 0x0, 0xe, 0x95, 0x15, 0x9a, 0xd5, 0xad, 0x38, 0xb3, 0x1, 0x44, 0xc6, 0x3d, 0x7f, + 0x26, 0xf5, 0x13, 0x73, 0x33, 0x16, 0x0, 0x5, 0x61, 0xb6, 0x76, 0x11, 0xfd, 0x23, 0x78, 0xcc, 0x29, + 0x59, 0x29, 0xb7, 0x21, 0x10, 0x8a, 0x1, 0x99, 0x28, 0x11, 0x25, 0xa0, 0x16, 0x0, 0x18, 0x19, 0xce, + 0x64, 0xeb, 0x77, 0xea, 0xff, 0xe1, 0x7a, 0x7, 0x5, 0xd2, 0xe7, 0xae, 0x3e, 0xcf, 0xbf, 0xa7, 0x23, + 0xa4, 0x73, 0x1a, 0xb0, 0x82, 0x1a, 0x0, 0x5, 0x49, 0x79, 0x19, 0x5d, 0xbd, 0x11, 0x0, 0x0, 0x1b, + 0xe2, 0x29, 0xe9, 0x18, 0x0, 0x0, 0x36, 0xbc, 0x4a, 0xe0, 0x94, 0x48, 0x84, 0x78, 0x53, 0x9c, 0x41, + 0x6f, 0x76, 0xc7, 0xf4, 0x77, 0x46, 0x5b, 0xa, 0xb9, 0xbe, 0x3b, 0x8e, 0x6f, 0x1, 0x67}; + + uint8_t buf[144] = {0}; + + uint8_t topic_bytes[] = {0x6f, 0x78, 0xfe, 0x51, 0x65, 0xcb, 0x3c, 0xb0, 0xc3, 0x45, 0x53}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x4a, 0xe0, 0x94, 0x48, 0x84, 0x78, 0x53, 0x9c, 0x41, 0x6f, 0x76, 0xc7, + 0xf4, 0x77, 0x46, 0x5b, 0xa, 0xb9, 0xbe, 0x3b, 0x8e, 0x6f, 0x1, 0x67}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + uint8_t bytes0[] = {0x95, 0x15, 0x9a, 0xd5, 0xad, 0x38, 0xb3, 0x1, 0x44, 0xc6, 0x3d, 0x7f, 0x26, 0xf5}; + uint8_t bytes1[] = {0x61, 0xb6, 0x76, 0x11, 0xfd}; + uint8_t bytes2[] = {0x19, 0xce, 0x64, 0xeb, 0x77, 0xea, 0xff, 0xe1, 0x7a, 0x7, 0x5, 0xd2, + 0xe7, 0xae, 0x3e, 0xcf, 0xbf, 0xa7, 0x23, 0xa4, 0x73, 0x1a, 0xb0, 0x82}; + uint8_t bytes3[] = {0x49, 0x79, 0x19, 0x5d, 0xbd}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29491}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30924}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4234}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7138}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14012}}, + }; + + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 20876, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = ")\159\249\220\185\252\230\193", +// _pubPktID = 10776, _pubBody = "\144\230\&6K\134\194\176\153\v\145(]\222\255\155\231\225(?\150}\155\FS\173)", +// _pubProps = [PropMessageExpiryInterval 5760,PropSubscriptionIdentifierAvailable 195,PropAuthenticationData +// "\177S",PropServerReference "\158\&4\205\186\200\244\209$u\152\218\202r\162oH\163$\\\212\&4",PropMaximumQoS +// 206,PropCorrelationData "\229\235$;",PropSubscriptionIdentifier 30,PropWildcardSubscriptionAvailable +// 188,PropSharedSubscriptionAvailable 208,PropMessageExpiryInterval 15481,PropResponseInformation +// "n\142\&4\206\224\227*\166N\229\253J\192\206aK\132[\186\143\vh\156",PropPayloadFormatIndicator 86,PropServerReference +// "9@",PropSubscriptionIdentifierAvailable 10,PropWillDelayInterval 10019,PropContentType "u"]} +TEST(Publish50QCTest, Encode77) { + uint8_t pkt[] = {0x34, 0x8a, 0x1, 0x0, 0x8, 0x29, 0x9f, 0xf9, 0xdc, 0xb9, 0xfc, 0xe6, 0xc1, 0x2a, 0x18, 0x64, + 0x2, 0x0, 0x0, 0x16, 0x80, 0x29, 0xc3, 0x16, 0x0, 0x2, 0xb1, 0x53, 0x1c, 0x0, 0x15, 0x9e, + 0x34, 0xcd, 0xba, 0xc8, 0xf4, 0xd1, 0x24, 0x75, 0x98, 0xda, 0xca, 0x72, 0xa2, 0x6f, 0x48, 0xa3, + 0x24, 0x5c, 0xd4, 0x34, 0x24, 0xce, 0x9, 0x0, 0x4, 0xe5, 0xeb, 0x24, 0x3b, 0xb, 0x1e, 0x28, + 0xbc, 0x2a, 0xd0, 0x2, 0x0, 0x0, 0x3c, 0x79, 0x1a, 0x0, 0x17, 0x6e, 0x8e, 0x34, 0xce, 0xe0, + 0xe3, 0x2a, 0xa6, 0x4e, 0xe5, 0xfd, 0x4a, 0xc0, 0xce, 0x61, 0x4b, 0x84, 0x5b, 0xba, 0x8f, 0xb, + 0x68, 0x9c, 0x1, 0x56, 0x1c, 0x0, 0x2, 0x39, 0x40, 0x29, 0xa, 0x18, 0x0, 0x0, 0x27, 0x23, + 0x3, 0x0, 0x1, 0x75, 0x90, 0xe6, 0x36, 0x4b, 0x86, 0xc2, 0xb0, 0x99, 0xb, 0x91, 0x28, 0x5d, + 0xde, 0xff, 0x9b, 0xe7, 0xe1, 0x28, 0x3f, 0x96, 0x7d, 0x9b, 0x1c, 0xad, 0x29}; + + uint8_t buf[151] = {0}; + + uint8_t topic_bytes[] = {0x29, 0x9f, 0xf9, 0xdc, 0xb9, 0xfc, 0xe6, 0xc1}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x90, 0xe6, 0x36, 0x4b, 0x86, 0xc2, 0xb0, 0x99, 0xb, 0x91, 0x28, 0x5d, 0xde, + 0xff, 0x9b, 0xe7, 0xe1, 0x28, 0x3f, 0x96, 0x7d, 0x9b, 0x1c, 0xad, 0x29}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 25; + + uint8_t bytes0[] = {0xb1, 0x53}; + uint8_t bytes1[] = {0x9e, 0x34, 0xcd, 0xba, 0xc8, 0xf4, 0xd1, 0x24, 0x75, 0x98, 0xda, + 0xca, 0x72, 0xa2, 0x6f, 0x48, 0xa3, 0x24, 0x5c, 0xd4, 0x34}; + uint8_t bytes2[] = {0xe5, 0xeb, 0x24, 0x3b}; + uint8_t bytes3[] = {0x6e, 0x8e, 0x34, 0xce, 0xe0, 0xe3, 0x2a, 0xa6, 0x4e, 0xe5, 0xfd, 0x4a, + 0xc0, 0xce, 0x61, 0x4b, 0x84, 0x5b, 0xba, 0x8f, 0xb, 0x68, 0x9c}; + uint8_t bytes4[] = {0x39, 0x40}; + uint8_t bytes5[] = {0x75}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5760}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15481}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10019}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytes5}}}, + }; + + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10776, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "6:\229<\217\235\180", _pubPktID = +// 21683, _pubBody = "y", _pubProps = [PropWillDelayInterval 11318,PropAssignedClientIdentifier +// "7%\147o\ETB\248\231",PropTopicAliasMaximum 5541,PropAuthenticationMethod +// "\153>\209\255L\217",PropPayloadFormatIndicator 24,PropServerKeepAlive 2352,PropSharedSubscriptionAvailable +// 244,PropServerReference "\198!\248h\187y\161\239X",PropServerReference +// "6jm\232\b;\159xm\142\183\216N",PropSubscriptionIdentifier 2,PropWildcardSubscriptionAvailable 204,PropResponseTopic +// "\144\246\212\237\132",PropReceiveMaximum 27177,PropMessageExpiryInterval 2103,PropReasonString +// "\DLEq<\a\178",PropResponseTopic +// "a.\139m\207\184\FS]x\254\DC3\159\208\150\160\179\&3\184\157\189~75Z7\252\202\133",PropCorrelationData +// "\242\228>|&T5\209\178\185\222]\210\198\208\&0\f^\190\238-\NAKf\133\143\231\234,\197\STX",PropContentType +// "i\226)\144\194\SUBH8\159\212\131|\"z\147\135?\214S\"\145\176\ENQ\DEL7"]} +TEST(Publish50QCTest, Encode78) { + uint8_t pkt[] = {0x3c, 0xc4, 0x1, 0x0, 0x7, 0x36, 0x3a, 0xe5, 0x3c, 0xd9, 0xeb, 0xb4, 0x54, 0xb3, 0xb6, 0x1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{0}; + + uint8_t topic_bytes[] = {0x36, 0x3a, 0xe5, 0x3c, 0xd9, 0xeb, 0xb4}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x79}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + uint8_t bytes0[] = {0x37, 0x25, 0x93, 0x6f, 0x17, 0xf8, 0xe7}; + uint8_t bytes1[] = {0x99, 0x3e, 0xd1, 0xff, 0x4c, 0xd9}; + uint8_t bytes2[] = {0xc6, 0x21, 0xf8, 0x68, 0xbb, 0x79, 0xa1, 0xef, 0x58}; + uint8_t bytes3[] = {0x36, 0x6a, 0x6d, 0xe8, 0x8, 0x3b, 0x9f, 0x78, 0x6d, 0x8e, 0xb7, 0xd8, 0x4e}; + uint8_t bytes4[] = {0x90, 0xf6, 0xd4, 0xed, 0x84}; + uint8_t bytes5[] = {0x10, 0x71, 0x3c, 0x7, 0xb2}; + uint8_t bytes6[] = {0x61, 0x2e, 0x8b, 0x6d, 0xcf, 0xb8, 0x1c, 0x5d, 0x78, 0xfe, 0x13, 0x9f, 0xd0, 0x96, + 0xa0, 0xb3, 0x33, 0xb8, 0x9d, 0xbd, 0x7e, 0x37, 0x35, 0x5a, 0x37, 0xfc, 0xca, 0x85}; + uint8_t bytes7[] = {0xf2, 0xe4, 0x3e, 0x7c, 0x26, 0x54, 0x35, 0xd1, 0xb2, 0xb9, 0xde, 0x5d, 0xd2, 0xc6, 0xd0, + 0x30, 0xc, 0x5e, 0xbe, 0xee, 0x2d, 0x15, 0x66, 0x85, 0x8f, 0xe7, 0xea, 0x2c, 0xc5, 0x2}; + uint8_t bytes8[] = {0x69, 0xe2, 0x29, 0x90, 0xc2, 0x1a, 0x48, 0x38, 0x9f, 0xd4, 0x83, 0x7c, 0x22, + 0x7a, 0x93, 0x87, 0x3f, 0xd6, 0x53, 0x22, 0x91, 0xb0, 0x5, 0x7f, 0x37}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11318}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5541}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2352}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27177}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2103}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytes8}}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 21683, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// ",l\239A\255.e\128\238\190\EOT\216\240\231", _pubPktID = 0, _pubBody = +// "\ENQ\DC3z\234.f[;\DC2\214i0\161P\251\171\160\RS\180\222J\202\191\DC2(.", _pubProps = [PropRetainAvailable +// 162,PropAssignedClientIdentifier " \206\r\200\RS\221\EMmd-\178\238(\138\&1G\ESC%\GS",PropResponseTopic +// "o\146\164\247\DLE\168m\130",PropWildcardSubscriptionAvailable 143,PropRequestProblemInformation +// 24,PropServerReference +// "@CxY\197\198\&2\149:B\212\128\US\154\135\234\218p\a\209\178\SUB\SO\128",PropRequestProblemInformation +// 9,PropRequestProblemInformation 127,PropSharedSubscriptionAvailable 106,PropAssignedClientIdentifier +// "",PropMaximumPacketSize 1555,PropResponseTopic "1\150\191\229\249LK\174\148\142~\251<|U\239\205\226\n\134\218 +// 3}\SYNH\169",PropServerReference +// "\128k\199{\194\245`\158\194\246?\168\221\140Z\222/X\200x\165-\254\160f\250",PropSessionExpiryInterval 1631]} +TEST(Publish50QCTest, Encode79) { + uint8_t pkt[] = {0x31, 0xbc, 0x1, 0x0, 0xe, 0x2c, 0x6c, 0xef, 0x41, 0xff, 0x2e, 0x65, 0x80, 0xee, 0xbe, 0x4, + 0xd8, 0xf0, 0xe7, 0x90, 0x1, 0x25, 0xa2, 0x12, 0x0, 0x13, 0x20, 0xce, 0xd, 0xc8, 0x1e, 0xdd, + 0x19, 0x6d, 0x64, 0x2d, 0xb2, 0xee, 0x28, 0x8a, 0x31, 0x47, 0x1b, 0x25, 0x1d, 0x8, 0x0, 0x8, + 0x6f, 0x92, 0xa4, 0xf7, 0x10, 0xa8, 0x6d, 0x82, 0x28, 0x8f, 0x17, 0x18, 0x1c, 0x0, 0x18, 0x40, + 0x43, 0x78, 0x59, 0xc5, 0xc6, 0x32, 0x95, 0x3a, 0x42, 0xd4, 0x80, 0x1f, 0x9a, 0x87, 0xea, 0xda, + 0x70, 0x7, 0xd1, 0xb2, 0x1a, 0xe, 0x80, 0x17, 0x9, 0x17, 0x7f, 0x2a, 0x6a, 0x12, 0x0, 0x0, + 0x27, 0x0, 0x0, 0x6, 0x13, 0x8, 0x0, 0x1b, 0x31, 0x96, 0xbf, 0xe5, 0xf9, 0x4c, 0x4b, 0xae, + 0x94, 0x8e, 0x7e, 0xfb, 0x3c, 0x7c, 0x55, 0xef, 0xcd, 0xe2, 0xa, 0x86, 0xda, 0x20, 0x33, 0x7d, + 0x16, 0x48, 0xa9, 0x1c, 0x0, 0x1a, 0x80, 0x6b, 0xc7, 0x7b, 0xc2, 0xf5, 0x60, 0x9e, 0xc2, 0xf6, + 0x3f, 0xa8, 0xdd, 0x8c, 0x5a, 0xde, 0x2f, 0x58, 0xc8, 0x78, 0xa5, 0x2d, 0xfe, 0xa0, 0x66, 0xfa, + 0x11, 0x0, 0x0, 0x6, 0x5f, 0x5, 0x13, 0x7a, 0xea, 0x2e, 0x66, 0x5b, 0x3b, 0x12, 0xd6, 0x69, + 0x30, 0xa1, 0x50, 0xfb, 0xab, 0xa0, 0x1e, 0xb4, 0xde, 0x4a, 0xca, 0xbf, 0x12, 0x28, 0x2e}; + + uint8_t buf[201] = {0}; + + uint8_t topic_bytes[] = {0x2c, 0x6c, 0xef, 0x41, 0xff, 0x2e, 0x65, 0x80, 0xee, 0xbe, 0x4, 0xd8, 0xf0, 0xe7}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x5, 0x13, 0x7a, 0xea, 0x2e, 0x66, 0x5b, 0x3b, 0x12, 0xd6, 0x69, 0x30, 0xa1, + 0x50, 0xfb, 0xab, 0xa0, 0x1e, 0xb4, 0xde, 0x4a, 0xca, 0xbf, 0x12, 0x28, 0x2e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + uint8_t bytes0[] = {0x20, 0xce, 0xd, 0xc8, 0x1e, 0xdd, 0x19, 0x6d, 0x64, 0x2d, + 0xb2, 0xee, 0x28, 0x8a, 0x31, 0x47, 0x1b, 0x25, 0x1d}; + uint8_t bytes1[] = {0x6f, 0x92, 0xa4, 0xf7, 0x10, 0xa8, 0x6d, 0x82}; + uint8_t bytes2[] = {0x40, 0x43, 0x78, 0x59, 0xc5, 0xc6, 0x32, 0x95, 0x3a, 0x42, 0xd4, 0x80, + 0x1f, 0x9a, 0x87, 0xea, 0xda, 0x70, 0x7, 0xd1, 0xb2, 0x1a, 0xe, 0x80}; + uint8_t bytes3[] = {0}; + uint8_t bytes4[] = {0x31, 0x96, 0xbf, 0xe5, 0xf9, 0x4c, 0x4b, 0xae, 0x94, 0x8e, 0x7e, 0xfb, 0x3c, 0x7c, + 0x55, 0xef, 0xcd, 0xe2, 0xa, 0x86, 0xda, 0x20, 0x33, 0x7d, 0x16, 0x48, 0xa9}; + uint8_t bytes5[] = {0x80, 0x6b, 0xc7, 0x7b, 0xc2, 0xf5, 0x60, 0x9e, 0xc2, 0xf6, 0x3f, 0xa8, 0xdd, + 0x8c, 0x5a, 0xde, 0x2f, 0x58, 0xc8, 0x78, 0xa5, 0x2d, 0xfe, 0xa0, 0x66, 0xfa}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1555}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1631}}, + }; + + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\179\182\194\v\149\131\&4\177\175cM\153\251\204B\RS\231\170n}y\198\197)\250\203\147\151\211\138", _pubPktID = 1399, +// _pubBody = "\156\228\194pPo\189\&6\255\NAK\245-\151\170\DC3;\191\196\136\241\191\255V\146`\250\183\234>\138", +// _pubProps = [PropTopicAlias 10172]} +TEST(Publish50QCTest, Encode80) { + uint8_t pkt[] = {0x3b, 0x44, 0x0, 0x1e, 0xb3, 0xb6, 0xc2, 0xb, 0x95, 0x83, 0x34, 0xb1, 0xaf, 0x63, + 0x4d, 0x99, 0xfb, 0xcc, 0x42, 0x1e, 0xe7, 0xaa, 0x6e, 0x7d, 0x79, 0xc6, 0xc5, 0x29, + 0xfa, 0xcb, 0x93, 0x97, 0xd3, 0x8a, 0x5, 0x77, 0x3, 0x23, 0x27, 0xbc, 0x9c, 0xe4, + 0xc2, 0x70, 0x50, 0x6f, 0xbd, 0x36, 0xff, 0x15, 0xf5, 0x2d, 0x97, 0xaa, 0x13, 0x3b, + 0xbf, 0xc4, 0x88, 0xf1, 0xbf, 0xff, 0x56, 0x92, 0x60, 0xfa, 0xb7, 0xea, 0x3e, 0x8a}; + + uint8_t buf[80] = {0}; + + uint8_t topic_bytes[] = {0xb3, 0xb6, 0xc2, 0xb, 0x95, 0x83, 0x34, 0xb1, 0xaf, 0x63, 0x4d, 0x99, 0xfb, 0xcc, 0x42, + 0x1e, 0xe7, 0xaa, 0x6e, 0x7d, 0x79, 0xc6, 0xc5, 0x29, 0xfa, 0xcb, 0x93, 0x97, 0xd3, 0x8a}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x9c, 0xe4, 0xc2, 0x70, 0x50, 0x6f, 0xbd, 0x36, 0xff, 0x15, 0xf5, 0x2d, 0x97, 0xaa, 0x13, + 0x3b, 0xbf, 0xc4, 0x88, 0xf1, 0xbf, 0xff, 0x56, 0x92, 0x60, 0xfa, 0xb7, 0xea, 0x3e, 0x8a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10172}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1399, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\183\185o\230@UI=\142/\201\188\216sZ\ESC\b\"\182\202\NAKU$`\181\rE\194t\f", _pubPktID = 17758, _pubBody = +// "\251~\215\217\SOH\189L!\244\EM\212\246_\154\185\179.\187\EOTE\242\169", _pubProps = [PropAuthenticationMethod +// "\230$\159\147\SUB]\144\SUB\221\202P\170\179\154G\210E\219\255\134\132\191\158\133\219q\240\189",PropTopicAliasMaximum +// 24228,PropPayloadFormatIndicator 214,PropSharedSubscriptionAvailable 148,PropPayloadFormatIndicator +// 197,PropWillDelayInterval 5533,PropPayloadFormatIndicator 8,PropServerKeepAlive 5558,PropWillDelayInterval +// 9585,PropServerKeepAlive 27517,PropResponseInformation "\244\135\DC2\245}w\234\135",PropReasonString +// "\n\212NL\t\226\177\238\ESC\175\197\148V\141\194\162\164\190]e'",PropWildcardSubscriptionAvailable +// 226,PropWildcardSubscriptionAvailable 74,PropMessageExpiryInterval 26648,PropMaximumQoS +// 193,PropSubscriptionIdentifier 18,PropSessionExpiryInterval 1981,PropServerReference +// "O\ESCAo\223\174\DELGQ\173\231=\149t\129PE\NAK\201\181\163=I\133",PropServerReference +// "\154\ENQ\214S\202\212\ETXf\192\169\ETB",PropSessionExpiryInterval 23038,PropMaximumQoS 51,PropServerKeepAlive 1930]} +TEST(Publish50QCTest, Encode81) { + uint8_t pkt[] = { + 0x33, 0xdc, 0x1, 0x0, 0x1e, 0xb7, 0xb9, 0x6f, 0xe6, 0x40, 0x55, 0x49, 0x3d, 0x8e, 0x2f, 0xc9, 0xbc, 0xd8, 0x73, + 0x5a, 0x1b, 0x8, 0x22, 0xb6, 0xca, 0x15, 0x55, 0x24, 0x60, 0xb5, 0xd, 0x45, 0xc2, 0x74, 0xc, 0x45, 0x5e, 0xa2, + 0x1, 0x15, 0x0, 0x1c, 0xe6, 0x24, 0x9f, 0x93, 0x1a, 0x5d, 0x90, 0x1a, 0xdd, 0xca, 0x50, 0xaa, 0xb3, 0x9a, 0x47, + 0xd2, 0x45, 0xdb, 0xff, 0x86, 0x84, 0xbf, 0x9e, 0x85, 0xdb, 0x71, 0xf0, 0xbd, 0x22, 0x5e, 0xa4, 0x1, 0xd6, 0x2a, + 0x94, 0x1, 0xc5, 0x18, 0x0, 0x0, 0x15, 0x9d, 0x1, 0x8, 0x13, 0x15, 0xb6, 0x18, 0x0, 0x0, 0x25, 0x71, 0x13, + 0x6b, 0x7d, 0x1a, 0x0, 0x8, 0xf4, 0x87, 0x12, 0xf5, 0x7d, 0x77, 0xea, 0x87, 0x1f, 0x0, 0x15, 0xa, 0xd4, 0x4e, + 0x4c, 0x9, 0xe2, 0xb1, 0xee, 0x1b, 0xaf, 0xc5, 0x94, 0x56, 0x8d, 0xc2, 0xa2, 0xa4, 0xbe, 0x5d, 0x65, 0x27, 0x28, + 0xe2, 0x28, 0x4a, 0x2, 0x0, 0x0, 0x68, 0x18, 0x24, 0xc1, 0xb, 0x12, 0x11, 0x0, 0x0, 0x7, 0xbd, 0x1c, 0x0, + 0x18, 0x4f, 0x1b, 0x41, 0x6f, 0xdf, 0xae, 0x7f, 0x47, 0x51, 0xad, 0xe7, 0x3d, 0x95, 0x74, 0x81, 0x50, 0x45, 0x15, + 0xc9, 0xb5, 0xa3, 0x3d, 0x49, 0x85, 0x1c, 0x0, 0xb, 0x9a, 0x5, 0xd6, 0x53, 0xca, 0xd4, 0x3, 0x66, 0xc0, 0xa9, + 0x17, 0x11, 0x0, 0x0, 0x59, 0xfe, 0x24, 0x33, 0x13, 0x7, 0x8a, 0xfb, 0x7e, 0xd7, 0xd9, 0x1, 0xbd, 0x4c, 0x21, + 0xf4, 0x19, 0xd4, 0xf6, 0x5f, 0x9a, 0xb9, 0xb3, 0x2e, 0xbb, 0x4, 0x45, 0xf2, 0xa9}; + + uint8_t buf[233] = {0}; + + uint8_t topic_bytes[] = {0xb7, 0xb9, 0x6f, 0xe6, 0x40, 0x55, 0x49, 0x3d, 0x8e, 0x2f, 0xc9, 0xbc, 0xd8, 0x73, 0x5a, + 0x1b, 0x8, 0x22, 0xb6, 0xca, 0x15, 0x55, 0x24, 0x60, 0xb5, 0xd, 0x45, 0xc2, 0x74, 0xc}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xfb, 0x7e, 0xd7, 0xd9, 0x1, 0xbd, 0x4c, 0x21, 0xf4, 0x19, 0xd4, + 0xf6, 0x5f, 0x9a, 0xb9, 0xb3, 0x2e, 0xbb, 0x4, 0x45, 0xf2, 0xa9}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + uint8_t bytes0[] = {0xe6, 0x24, 0x9f, 0x93, 0x1a, 0x5d, 0x90, 0x1a, 0xdd, 0xca, 0x50, 0xaa, 0xb3, 0x9a, + 0x47, 0xd2, 0x45, 0xdb, 0xff, 0x86, 0x84, 0xbf, 0x9e, 0x85, 0xdb, 0x71, 0xf0, 0xbd}; + uint8_t bytes1[] = {0xf4, 0x87, 0x12, 0xf5, 0x7d, 0x77, 0xea, 0x87}; + uint8_t bytes2[] = {0xa, 0xd4, 0x4e, 0x4c, 0x9, 0xe2, 0xb1, 0xee, 0x1b, 0xaf, 0xc5, + 0x94, 0x56, 0x8d, 0xc2, 0xa2, 0xa4, 0xbe, 0x5d, 0x65, 0x27}; + uint8_t bytes3[] = {0x4f, 0x1b, 0x41, 0x6f, 0xdf, 0xae, 0x7f, 0x47, 0x51, 0xad, 0xe7, 0x3d, + 0x95, 0x74, 0x81, 0x50, 0x45, 0x15, 0xc9, 0xb5, 0xa3, 0x3d, 0x49, 0x85}; + uint8_t bytes4[] = {0x9a, 0x5, 0xd6, 0x53, 0xca, 0xd4, 0x3, 0x66, 0xc0, 0xa9, 0x17}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24228}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5533}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5558}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9585}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27517}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26648}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1981}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23038}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1930}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17758, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "", _pubPktID = 3165, _pubBody = +// "\168'\DC2\253\238;d\144\231\186\152t\206\166", _pubProps = [PropContentType +// "[\236<\152\128\186\169\221\182\180d\214\171d\227>\137\180\ETXQ",PropReceiveMaximum 22525,PropContentType +// "v\166\207e\200_\199\213\250\&4=l$\240,m)\EOT\ETB\171\133\222\ACK\162$\210\158",PropMessageExpiryInterval +// 13876,PropTopicAlias 9953,PropAuthenticationData +// "w\NUL\ACKf\196\178\193Ml}\159\213^\ACK9%\168\158\233r\171\134\223r\140"]} +TEST(Publish50QCTest, Encode82) { + uint8_t pkt[] = {0x3d, 0x6f, 0x0, 0x0, 0xc, 0x5d, 0x5c, 0x3, 0x0, 0x14, 0x5b, 0xec, 0x3c, 0x98, 0x80, 0xba, 0xa9, + 0xdd, 0xb6, 0xb4, 0x64, 0xd6, 0xab, 0x64, 0xe3, 0x3e, 0x89, 0xb4, 0x3, 0x51, 0x21, 0x57, 0xfd, 0x3, + 0x0, 0x1b, 0x76, 0xa6, 0xcf, 0x65, 0xc8, 0x5f, 0xc7, 0xd5, 0xfa, 0x34, 0x3d, 0x6c, 0x24, 0xf0, 0x2c, + 0x6d, 0x29, 0x4, 0x17, 0xab, 0x85, 0xde, 0x6, 0xa2, 0x24, 0xd2, 0x9e, 0x2, 0x0, 0x0, 0x36, 0x34, + 0x23, 0x26, 0xe1, 0x16, 0x0, 0x19, 0x77, 0x0, 0x6, 0x66, 0xc4, 0xb2, 0xc1, 0x4d, 0x6c, 0x7d, 0x9f, + 0xd5, 0x5e, 0x6, 0x39, 0x25, 0xa8, 0x9e, 0xe9, 0x72, 0xab, 0x86, 0xdf, 0x72, 0x8c, 0xa8, 0x27, 0x12, + 0xfd, 0xee, 0x3b, 0x64, 0x90, 0xe7, 0xba, 0x98, 0x74, 0xce, 0xa6}; + + uint8_t buf[123] = {0}; + + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa8, 0x27, 0x12, 0xfd, 0xee, 0x3b, 0x64, 0x90, 0xe7, 0xba, 0x98, 0x74, 0xce, 0xa6}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; + + uint8_t bytes0[] = {0x5b, 0xec, 0x3c, 0x98, 0x80, 0xba, 0xa9, 0xdd, 0xb6, 0xb4, + 0x64, 0xd6, 0xab, 0x64, 0xe3, 0x3e, 0x89, 0xb4, 0x3, 0x51}; + uint8_t bytes1[] = {0x76, 0xa6, 0xcf, 0x65, 0xc8, 0x5f, 0xc7, 0xd5, 0xfa, 0x34, 0x3d, 0x6c, 0x24, 0xf0, + 0x2c, 0x6d, 0x29, 0x4, 0x17, 0xab, 0x85, 0xde, 0x6, 0xa2, 0x24, 0xd2, 0x9e}; + uint8_t bytes2[] = {0x77, 0x0, 0x6, 0x66, 0xc4, 0xb2, 0xc1, 0x4d, 0x6c, 0x7d, 0x9f, 0xd5, 0x5e, + 0x6, 0x39, 0x25, 0xa8, 0x9e, 0xe9, 0x72, 0xab, 0x86, 0xdf, 0x72, 0x8c}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22525}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13876}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9953}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytes2}}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 3165, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\GS\DC2", _pubPktID = 7799, _pubBody +// = "\138\249b\fd \199\239\220\147\235\233\214\152\139\130Q\163v?ZrG\215\139\236\184\230y", _pubProps = +// [PropSubscriptionIdentifierAvailable 186,PropServerReference +// "u\171O\192\245i;\DC1\DEL\SI\143f\146\b\237i\242\250h\147\171\244\CAN\226n",PropSubscriptionIdentifier +// 19,PropResponseInformation "",PropCorrelationData "\197vg\238\248\222\160\219\187\243\b\219\135Ds\218\229C\195'\252h +// 4",PropWildcardSubscriptionAvailable 146]} +TEST(Publish50QCTest, Encode83) { + uint8_t pkt[] = {0x3a, 0x64, 0x0, 0x2, 0x1d, 0x12, 0x1e, 0x77, 0x40, 0x29, 0xba, 0x1c, 0x0, 0x19, 0x75, + 0xab, 0x4f, 0xc0, 0xf5, 0x69, 0x3b, 0x11, 0x7f, 0xf, 0x8f, 0x66, 0x92, 0x8, 0xed, 0x69, + 0xf2, 0xfa, 0x68, 0x93, 0xab, 0xf4, 0x18, 0xe2, 0x6e, 0xb, 0x13, 0x1a, 0x0, 0x0, 0x9, + 0x0, 0x18, 0xc5, 0x76, 0x67, 0xee, 0xf8, 0xde, 0xa0, 0xdb, 0xbb, 0xf3, 0x8, 0xdb, 0x87, + 0x44, 0x73, 0xda, 0xe5, 0x43, 0xc3, 0x27, 0xfc, 0x68, 0x20, 0x34, 0x28, 0x92, 0x8a, 0xf9, + 0x62, 0xc, 0x64, 0x20, 0xc7, 0xef, 0xdc, 0x93, 0xeb, 0xe9, 0xd6, 0x98, 0x8b, 0x82, 0x51, + 0xa3, 0x76, 0x3f, 0x5a, 0x72, 0x47, 0xd7, 0x8b, 0xec, 0xb8, 0xe6, 0x79}; + + uint8_t buf[112] = {0}; + + uint8_t topic_bytes[] = {0x1d, 0x12}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x8a, 0xf9, 0x62, 0xc, 0x64, 0x20, 0xc7, 0xef, 0xdc, 0x93, 0xeb, 0xe9, 0xd6, 0x98, 0x8b, + 0x82, 0x51, 0xa3, 0x76, 0x3f, 0x5a, 0x72, 0x47, 0xd7, 0x8b, 0xec, 0xb8, 0xe6, 0x79}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; + + uint8_t bytes0[] = {0x75, 0xab, 0x4f, 0xc0, 0xf5, 0x69, 0x3b, 0x11, 0x7f, 0xf, 0x8f, 0x66, 0x92, + 0x8, 0xed, 0x69, 0xf2, 0xfa, 0x68, 0x93, 0xab, 0xf4, 0x18, 0xe2, 0x6e}; + uint8_t bytes1[] = {0}; + uint8_t bytes2[] = {0xc5, 0x76, 0x67, 0xee, 0xf8, 0xde, 0xa0, 0xdb, 0xbb, 0xf3, 0x8, 0xdb, + 0x87, 0x44, 0x73, 0xda, 0xe5, 0x43, 0xc3, 0x27, 0xfc, 0x68, 0x20, 0x34}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 146}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7799, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\208\187K.", _pubPktID = 29034, +// _pubBody = "\221\ACK\199\144\EOTv\ACK\217\\", _pubProps = [PropServerKeepAlive 3513,PropUserProperty +// "e\141\b\252'\183\204\&0",PropWildcardSubscriptionAvailable 133,PropRequestProblemInformation +// 134,PropTopicAliasMaximum 26123,PropMessageExpiryInterval 31900,PropPayloadFormatIndicator 100,PropMaximumQoS +// 25,PropSubscriptionIdentifier 24]} +TEST(Publish50QCTest, Encode85) { + uint8_t pkt[] = {0x38, 0x3a, 0x0, 0x6, 0xc9, 0x79, 0xab, 0x9b, 0xb8, 0x43, 0x18, 0x1c, 0x0, 0x3, 0x3e, + 0xcc, 0x30, 0x28, 0x85, 0x17, 0x86, 0x22, 0x66, 0xb, 0x2, 0x0, 0x0, 0x7c, 0x9c, 0x1, + 0x64, 0x24, 0x19, 0xb, 0x18, 0xb4, 0xb2, 0x32, 0xc2, 0x1a, 0x35, 0x5a, 0xfe, 0x1f, 0xd9, + 0x90, 0x9, 0x3a, 0x34, 0x61, 0x9a, 0xcb, 0xc9, 0x3, 0x13, 0xf6, 0x5f, 0x5b, 0x3c, 0xe0}; + + uint8_t buf[70] = {0}; + + uint8_t topic_bytes[] = {0xc9, 0x79, 0xab, 0x9b, 0xb8, 0x43}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xb4, 0xb2, 0x32, 0xc2, 0x1a, 0x35, 0x5a, 0xfe, 0x1f, 0xd9, 0x90, 0x9, 0x3a, + 0x34, 0x61, 0x9a, 0xcb, 0xc9, 0x3, 0x13, 0xf6, 0x5f, 0x5b, 0x3c, 0xe0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 25; + + uint8_t bytes0[] = {0x3e, 0xcc, 0x30}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26123}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31900}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "}q\213-\168\195\252$\139j^\DC1o\198\RS\172\159q", _pubPktID = 8388, _pubBody = "\196\&7\f\aA\EOT", _pubProps = +// [PropTopicAlias 5216]} +TEST(Publish50QCTest, Encode86) { + uint8_t pkt[] = {0x32, 0x20, 0x0, 0x12, 0x7d, 0x71, 0xd5, 0x2d, 0xa8, 0xc3, 0xfc, 0x24, 0x8b, 0x6a, 0x5e, 0x11, 0x6f, + 0xc6, 0x1e, 0xac, 0x9f, 0x71, 0x20, 0xc4, 0x3, 0x23, 0x14, 0x60, 0xc4, 0x37, 0xc, 0x7, 0x41, 0x4}; + + uint8_t buf[44] = {0}; + + uint8_t topic_bytes[] = {0x7d, 0x71, 0xd5, 0x2d, 0xa8, 0xc3, 0xfc, 0x24, 0x8b, + 0x6a, 0x5e, 0x11, 0x6f, 0xc6, 0x1e, 0xac, 0x9f, 0x71}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xc4, 0x37, 0xc, 0x7, 0x41, 0x4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 6; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5216}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 8388, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\214\177\ETBL\143\b\216", _pubPktID +// = 466, _pubBody = "sz\183u\DC3:\199\242\216%\137\EM\a\203\242\209\144\194fR6\240\163&\200H", _pubProps = +// [PropSharedSubscriptionAvailable 47,PropRequestProblemInformation 51,PropPayloadFormatIndicator +// 185,PropServerReference "\207\205\ACK\148\196'\225\159\ENQG0\238`r4\135\ENQ\136\149\190",PropMaximumPacketSize +// 612,PropReasonString +// "\181\203E\b\225?8745\236\172$\f\228\247\153\186\163\214\DLE\176\205\b\164\248",PropServerKeepAlive +// 22517,PropAuthenticationMethod "",PropAuthenticationData +// "\a\DC4b7A>\249\247\239>\a\162\216\195",PropMaximumPacketSize 21926,PropAssignedClientIdentifier +// "U\a\203K\156\203\198bi\193\144\143\246XZ\133X",PropAuthenticationData +// "w(2\212\162^R\186\b\CAN\226o/;\155C\184\174\157S~\224Y\DC3\CAN\154r",PropAuthenticationMethod +// ">\254\169\246\252\233\&5\198\noB\228\129tT\237\204",PropMessageExpiryInterval 826,PropMessageExpiryInterval +// 29414,PropTopicAlias 6110,PropMaximumPacketSize 29501,PropMessageExpiryInterval 15604,PropServerReference +// "v\DC2\EOT$\195\182\146\252\207XI\FSF\197\217Sw\207I0e\201\205oj\196\129",PropPayloadFormatIndicator +// 53,PropReceiveMaximum 26780,PropRequestProblemInformation 218]} +TEST(Publish50QCTest, Encode87) { + uint8_t pkt[] = { + 0x34, 0x84, 0x2, 0x0, 0x7, 0xd6, 0xb1, 0x17, 0x4c, 0x8f, 0x8, 0xd8, 0x1, 0xd2, 0xdd, 0x1, 0x2a, 0x2f, 0x17, + 0x33, 0x1, 0xb9, 0x1c, 0x0, 0x14, 0xcf, 0xcd, 0x6, 0x94, 0xc4, 0x27, 0xe1, 0x9f, 0x5, 0x47, 0x30, 0xee, 0x60, + 0x72, 0x34, 0x87, 0x5, 0x88, 0x95, 0xbe, 0x27, 0x0, 0x0, 0x2, 0x64, 0x1f, 0x0, 0x1a, 0xb5, 0xcb, 0x45, 0x8, + 0xe1, 0x3f, 0x38, 0x37, 0x34, 0x35, 0xec, 0xac, 0x24, 0xc, 0xe4, 0xf7, 0x99, 0xba, 0xa3, 0xd6, 0x10, 0xb0, 0xcd, + 0x8, 0xa4, 0xf8, 0x13, 0x57, 0xf5, 0x15, 0x0, 0x0, 0x16, 0x0, 0xe, 0x7, 0x14, 0x62, 0x37, 0x41, 0x3e, 0xf9, + 0xf7, 0xef, 0x3e, 0x7, 0xa2, 0xd8, 0xc3, 0x27, 0x0, 0x0, 0x55, 0xa6, 0x12, 0x0, 0x11, 0x55, 0x7, 0xcb, 0x4b, + 0x9c, 0xcb, 0xc6, 0x62, 0x69, 0xc1, 0x90, 0x8f, 0xf6, 0x58, 0x5a, 0x85, 0x58, 0x16, 0x0, 0x1b, 0x77, 0x28, 0x32, + 0xd4, 0xa2, 0x5e, 0x52, 0xba, 0x8, 0x18, 0xe2, 0x6f, 0x2f, 0x3b, 0x9b, 0x43, 0xb8, 0xae, 0x9d, 0x53, 0x7e, 0xe0, + 0x59, 0x13, 0x18, 0x9a, 0x72, 0x15, 0x0, 0x11, 0x3e, 0xfe, 0xa9, 0xf6, 0xfc, 0xe9, 0x35, 0xc6, 0xa, 0x6f, 0x42, + 0xe4, 0x81, 0x74, 0x54, 0xed, 0xcc, 0x2, 0x0, 0x0, 0x3, 0x3a, 0x2, 0x0, 0x0, 0x72, 0xe6, 0x23, 0x17, 0xde, + 0x27, 0x0, 0x0, 0x73, 0x3d, 0x2, 0x0, 0x0, 0x3c, 0xf4, 0x1c, 0x0, 0x1b, 0x76, 0x12, 0x4, 0x24, 0xc3, 0xb6, + 0x92, 0xfc, 0xcf, 0x58, 0x49, 0x1c, 0x46, 0xc5, 0xd9, 0x53, 0x77, 0xcf, 0x49, 0x30, 0x65, 0xc9, 0xcd, 0x6f, 0x6a, + 0xc4, 0x81, 0x1, 0x35, 0x21, 0x68, 0x9c, 0x17, 0xda, 0x73, 0x7a, 0xb7, 0x75, 0x13, 0x3a, 0xc7, 0xf2, 0xd8, 0x25, + 0x89, 0x19, 0x7, 0xcb, 0xf2, 0xd1, 0x90, 0xc2, 0x66, 0x52, 0x36, 0xf0, 0xa3, 0x26, 0xc8, 0x48}; + + uint8_t buf[273] = {0}; + + uint8_t topic_bytes[] = {0xd6, 0xb1, 0x17, 0x4c, 0x8f, 0x8, 0xd8}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x73, 0x7a, 0xb7, 0x75, 0x13, 0x3a, 0xc7, 0xf2, 0xd8, 0x25, 0x89, 0x19, 0x7, + 0xcb, 0xf2, 0xd1, 0x90, 0xc2, 0x66, 0x52, 0x36, 0xf0, 0xa3, 0x26, 0xc8, 0x48}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + uint8_t bytes0[] = {0xcf, 0xcd, 0x6, 0x94, 0xc4, 0x27, 0xe1, 0x9f, 0x5, 0x47, + 0x30, 0xee, 0x60, 0x72, 0x34, 0x87, 0x5, 0x88, 0x95, 0xbe}; + uint8_t bytes1[] = {0xb5, 0xcb, 0x45, 0x8, 0xe1, 0x3f, 0x38, 0x37, 0x34, 0x35, 0xec, 0xac, 0x24, + 0xc, 0xe4, 0xf7, 0x99, 0xba, 0xa3, 0xd6, 0x10, 0xb0, 0xcd, 0x8, 0xa4, 0xf8}; + uint8_t bytes2[] = {0}; + uint8_t bytes3[] = {0x7, 0x14, 0x62, 0x37, 0x41, 0x3e, 0xf9, 0xf7, 0xef, 0x3e, 0x7, 0xa2, 0xd8, 0xc3}; + uint8_t bytes4[] = {0x55, 0x7, 0xcb, 0x4b, 0x9c, 0xcb, 0xc6, 0x62, 0x69, + 0xc1, 0x90, 0x8f, 0xf6, 0x58, 0x5a, 0x85, 0x58}; + uint8_t bytes5[] = {0x77, 0x28, 0x32, 0xd4, 0xa2, 0x5e, 0x52, 0xba, 0x8, 0x18, 0xe2, 0x6f, 0x2f, 0x3b, + 0x9b, 0x43, 0xb8, 0xae, 0x9d, 0x53, 0x7e, 0xe0, 0x59, 0x13, 0x18, 0x9a, 0x72}; + uint8_t bytes6[] = {0x3e, 0xfe, 0xa9, 0xf6, 0xfc, 0xe9, 0x35, 0xc6, 0xa, + 0x6f, 0x42, 0xe4, 0x81, 0x74, 0x54, 0xed, 0xcc}; + uint8_t bytes7[] = {0x76, 0x12, 0x4, 0x24, 0xc3, 0xb6, 0x92, 0xfc, 0xcf, 0x58, 0x49, 0x1c, 0x46, 0xc5, + 0xd9, 0x53, 0x77, 0xcf, 0x49, 0x30, 0x65, 0xc9, 0xcd, 0x6f, 0x6a, 0xc4, 0x81}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 612}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22517}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21926}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 826}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29414}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6110}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29501}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15604}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26780}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 218}}, + }; + + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 466, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\STX\213\240cI\204T-w\154\192|#=\254P\DC24\200\170\228\NUL\186\147/\225\193\b\FS\140", _pubPktID = 26668, _pubBody = +// ".T\237(\238\DELg0 \GS\STX\215*\156\169t\147\b\206\149\172\r\211\RS\205 5\US\t0", _pubProps = [PropContentType +// "6\198\194G\158_",PropReasonString "\249\167\172\RS/z\220\228",PropPayloadFormatIndicator 170,PropTopicAlias +// 21820,PropAuthenticationMethod "z\139\GS\152\133kU\143",PropResponseInformation +// "\189\218Yv\197\231\179q\216\219\DC2q'\131\227\DLEs}\NUL\200\203o\247y\202\177",PropServerReference +// "H\154\225&\139\196}.\aM~\218",PropWildcardSubscriptionAvailable 175,PropSharedSubscriptionAvailable +// 51,PropRequestProblemInformation 186,PropUserProperty +// "\SUB\200\198\242\189\161\v\242K\145C\155\168\162\204\213Kq\224\180n" +// "k\141Bq@^\DC3\210\226\163\222\211\254\214\211\253",PropTopicAlias 6507]} +TEST(Publish50QCTest, Encode88) { + uint8_t pkt[] = {0x33, 0xc5, 0x1, 0x0, 0x1e, 0x2, 0xd5, 0xf0, 0x63, 0x49, 0xcc, 0x54, 0x2d, 0x77, 0x9a, 0xc0, 0x7c, + 0x23, 0x3d, 0xfe, 0x50, 0x12, 0x34, 0xc8, 0xaa, 0xe4, 0x0, 0xba, 0x93, 0x2f, 0xe1, 0xc1, 0x8, 0x1c, + 0x8c, 0x68, 0x2c, 0x83, 0x1, 0x3, 0x0, 0x6, 0x36, 0xc6, 0xc2, 0x47, 0x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93, 0x2f, 0xe1, 0xc1, 0x8, 0x1c, 0x8c}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x2e, 0x54, 0xed, 0x28, 0xee, 0x7f, 0x67, 0x30, 0x20, 0x1d, 0x2, 0xd7, 0x2a, 0x9c, 0xa9, + 0x74, 0x93, 0x8, 0xce, 0x95, 0xac, 0xd, 0xd3, 0x1e, 0xcd, 0x20, 0x35, 0x1f, 0x9, 0x30}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + uint8_t bytes0[] = {0x36, 0xc6, 0xc2, 0x47, 0x9e, 0x5f}; + uint8_t bytes1[] = {0xf9, 0xa7, 0xac, 0x1e, 0x2f, 0x7a, 0xdc, 0xe4}; + uint8_t bytes2[] = {0x7a, 0x8b, 0x1d, 0x98, 0x85, 0x6b, 0x55, 0x8f}; + uint8_t bytes3[] = {0xbd, 0xda, 0x59, 0x76, 0xc5, 0xe7, 0xb3, 0x71, 0xd8, 0xdb, 0x12, 0x71, 0x27, + 0x83, 0xe3, 0x10, 0x73, 0x7d, 0x0, 0xc8, 0xcb, 0x6f, 0xf7, 0x79, 0xca, 0xb1}; + uint8_t bytes4[] = {0x48, 0x9a, 0xe1, 0x26, 0x8b, 0xc4, 0x7d, 0x2e, 0x7, 0x4d, 0x7e, 0xda}; + uint8_t bytes6[] = {0x6b, 0x8d, 0x42, 0x71, 0x40, 0x5e, 0x13, 0xd2, 0xe2, 0xa3, 0xde, 0xd3, 0xfe, 0xd6, 0xd3, 0xfd}; + uint8_t bytes5[] = {0x1a, 0xc8, 0xc6, 0xf2, 0xbd, 0xa1, 0xb, 0xf2, 0x4b, 0x91, 0x43, + 0x9b, 0xa8, 0xa2, 0xcc, 0xd5, 0x4b, 0x71, 0xe0, 0xb4, 0x6e}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21820}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes5}, .v = {16, (char*)&bytes6}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6507}}, + }; + + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 26668, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\"X\209\155% +// \FS1[\178\SI\134\232\SI\236n\212\r\FS", _pubPktID = 0, _pubBody = +// "`\190\143p\n\134\145\250\152\151,\233\245\224\143\FS\235_/\133\203", _pubProps = []} +TEST(Publish50QCTest, Encode89) { + uint8_t pkt[] = {0x39, 0x2b, 0x0, 0x13, 0x22, 0x58, 0xd1, 0x9b, 0x25, 0x20, 0x1c, 0x31, 0x5b, 0xb2, 0xf, + 0x86, 0xe8, 0xf, 0xec, 0x6e, 0xd4, 0xd, 0x1c, 0x0, 0x60, 0xbe, 0x8f, 0x70, 0xa, 0x86, + 0x91, 0xfa, 0x98, 0x97, 0x2c, 0xe9, 0xf5, 0xe0, 0x8f, 0x1c, 0xeb, 0x5f, 0x2f, 0x85, 0xcb}; + + uint8_t buf[55] = {0}; + + uint8_t topic_bytes[] = {0x22, 0x58, 0xd1, 0x9b, 0x25, 0x20, 0x1c, 0x31, 0x5b, 0xb2, + 0xf, 0x86, 0xe8, 0xf, 0xec, 0x6e, 0xd4, 0xd, 0x1c}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x60, 0xbe, 0x8f, 0x70, 0xa, 0x86, 0x91, 0xfa, 0x98, 0x97, 0x2c, + 0xe9, 0xf5, 0xe0, 0x8f, 0x1c, 0xeb, 0x5f, 0x2f, 0x85, 0xcb}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 21; + + lwmqtt_property_t proplist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\175\195\208b[q\226\128\DC4'", +// _pubPktID = 14979, _pubBody = "\US", _pubProps = [PropRetainAvailable 166,PropWildcardSubscriptionAvailable +// 171,PropReceiveMaximum 11631,PropSessionExpiryInterval 20049,PropAuthenticationMethod +// "i\191\170\DC3\254\220\DEL\172\235I\238\185\220~?\217\US$\251`R\NAK"]} +TEST(Publish50QCTest, Encode90) { + uint8_t pkt[] = {0x3c, 0x35, 0x0, 0xa, 0xaf, 0xc3, 0xd0, 0x62, 0x5b, 0x71, 0xe2, 0x80, 0x14, 0x27, + 0x3a, 0x83, 0x25, 0x25, 0xa6, 0x28, 0xab, 0x21, 0x2d, 0x6f, 0x11, 0x0, 0x0, 0x4e, + 0x51, 0x15, 0x0, 0x16, 0x69, 0xbf, 0xaa, 0x13, 0xfe, 0xdc, 0x7f, 0xac, 0xeb, 0x49, + 0xee, 0xb9, 0xdc, 0x7e, 0x3f, 0xd9, 0x1f, 0x24, 0xfb, 0x60, 0x52, 0x15, 0x1f}; + + uint8_t buf[65] = {0}; + + uint8_t topic_bytes[] = {0xaf, 0xc3, 0xd0, 0x62, 0x5b, 0x71, 0xe2, 0x80, 0x14, 0x27}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x1f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + uint8_t bytes0[] = {0x69, 0xbf, 0xaa, 0x13, 0xfe, 0xdc, 0x7f, 0xac, 0xeb, 0x49, 0xee, + 0xb9, 0xdc, 0x7e, 0x3f, 0xd9, 0x1f, 0x24, 0xfb, 0x60, 0x52, 0x15}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11631}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20049}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytes0}}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 14979, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\141\253\128M\210\215vFY\193c\236\174\r\155\SYN\\y", _pubPktID = 16476, _pubBody = "\DEL\250\&0\179-", _pubProps = +// [PropAssignedClientIdentifier +// "\216\241+/\207\161\145\DC1\206E/\SO\214\200\165s\SO\188{$/4W-s",PropSubscriptionIdentifierAvailable +// 190,PropTopicAlias 6411,PropRequestResponseInformation 34,PropRequestResponseInformation +// 121,PropMessageExpiryInterval 20715,PropMessageExpiryInterval 12396,PropMaximumQoS +// 106,PropWildcardSubscriptionAvailable 0,PropMessageExpiryInterval 9349,PropMaximumPacketSize +// 8829,PropPayloadFormatIndicator 161,PropMessageExpiryInterval 11310,PropAuthenticationMethod +// "\221\182\153\SYN\195",PropMessageExpiryInterval 3614,PropResponseTopic +// "\248\f\189\DC2_",PropRequestProblemInformation 3,PropWillDelayInterval 19200,PropRetainAvailable +// 72,PropAuthenticationData "I\219D\NUL\130)\131\178",PropTopicAlias 20261,PropReasonString +// "i\130\206\161",PropSharedSubscriptionAvailable 91]} +TEST(Publish50QCTest, Encode91) { + uint8_t pkt[] = {0x3b, 0x95, 0x1, 0x0, 0x12, 0x8d, 0xfd, 0x80, 0x4d, 0xd2, 0xd7, 0x76, 0x46, 0x59, 0xc1, 0x63, 0xec, + 0xae, 0xd, 0x9b, 0x16, 0x5c, 0x79, 0x40, 0x5c, 0x79, 0x12, 0x0, 0x19, 0xd8, 0xf1, 0x2b, 0x2f, 0xcf, + 0xa1, 0x91, 0x11, 0xce, 0x45, 0x2f, 0xe, 0xd6, 0xc8, 0xa5, 0x73, 0xe, 0xbc, 0x7b, 0x24, 0x2f, 0x34, + 0x57, 0x2d, 0x73, 0x29, 0xbe, 0x23, 0x19, 0xb, 0x19, 0x22, 0x19, 0x79, 0x2, 0x0, 0x0, 0x50, 0xeb, + 0x2, 0x0, 0x0, 0x30, 0x6c, 0x24, 0x6a, 0x28, 0x0, 0x2, 0x0, 0x0, 0x24, 0x85, 0x27, 0x0, 0x0, + 0x22, 0x7d, 0x1, 0xa1, 0x2, 0x0, 0x0, 0x2c, 0x2e, 0x15, 0x0, 0x5, 0xdd, 0xb6, 0x99, 0x16, 0xc3, + 0x2, 0x0, 0x0, 0xe, 0x1e, 0x8, 0x0, 0x5, 0xf8, 0xc, 0xbd, 0x12, 0x5f, 0x17, 0x3, 0x18, 0x0, + 0x0, 0x4b, 0x0, 0x25, 0x48, 0x16, 0x0, 0x8, 0x49, 0xdb, 0x44, 0x0, 0x82, 0x29, 0x83, 0xb2, 0x23, + 0x4f, 0x25, 0x1f, 0x0, 0x4, 0x69, 0x82, 0xce, 0xa1, 0x2a, 0x5b, 0x7f, 0xfa, 0x30, 0xb3, 0x2d}; + + uint8_t buf[162] = {0}; + + uint8_t topic_bytes[] = {0x8d, 0xfd, 0x80, 0x4d, 0xd2, 0xd7, 0x76, 0x46, 0x59, + 0xc1, 0x63, 0xec, 0xae, 0xd, 0x9b, 0x16, 0x5c, 0x79}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x7f, 0xfa, 0x30, 0xb3, 0x2d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 5; + + uint8_t bytes0[] = {0xd8, 0xf1, 0x2b, 0x2f, 0xcf, 0xa1, 0x91, 0x11, 0xce, 0x45, 0x2f, 0xe, 0xd6, + 0xc8, 0xa5, 0x73, 0xe, 0xbc, 0x7b, 0x24, 0x2f, 0x34, 0x57, 0x2d, 0x73}; + uint8_t bytes1[] = {0xdd, 0xb6, 0x99, 0x16, 0xc3}; + uint8_t bytes2[] = {0xf8, 0xc, 0xbd, 0x12, 0x5f}; + uint8_t bytes3[] = {0x49, 0xdb, 0x44, 0x0, 0x82, 0x29, 0x83, 0xb2}; + uint8_t bytes4[] = {0x69, 0x82, 0xce, 0xa1}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6411}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20715}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12396}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9349}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8829}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11310}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3614}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19200}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20261}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 91}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16476, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\172\236 +// #(l]\NAK\197K\GS\156j\151\195\144\235C\\\137\199*\177", _pubPktID = 24115, _pubBody = "\138", _pubProps = +// [PropAssignedClientIdentifier "\129a+n\170\188!\135\USlf\EM\248\247\227\155\206{&6",PropUserProperty "\214s\138\221" +// "\203\RSqhCk}E\DC1=C\227VW\189Payz\157",PropRetainAvailable 88,PropAssignedClientIdentifier +// "\243\206\165Q\DC2\220\165.", _pubProps = [PropUserProperty +// "\168=bnK\172\191t`\165\224\186\165" +// "\184r\211Q.9\174\239\243g\SYN\143\242\138\167\r\253LvD)\212\173:~\249\239w",PropSharedSubscriptionAvailable +// 159,PropMessageExpiryInterval 23375,PropPayloadFormatIndicator 235,PropResponseInformation "+\193=])\213+\RSj\226"]} +TEST(Publish50QCTest, Encode95) { + uint8_t pkt[] = {0x3a, 0x74, 0x0, 0x13, 0xa1, 0x26, 0x4b, 0x1d, 0x75, 0xa4, 0x11, 0x57, 0x9c, 0xcd, 0x12, 0x65, 0x1f, + 0xfd, 0x1a, 0xd4, 0x1d, 0x92, 0x75, 0x13, 0x4a, 0x44, 0x26, 0x0, 0xd, 0xa8, 0x3d, 0x62, 0x6e, 0x4b, + 0xac, 0xbf, 0x74, 0x60, 0xa5, 0xe0, 0xba, 0xa5, 0x0, 0x1c, 0xb8, 0x72, 0xd3, 0x51, 0x2e, 0x39, 0xae, + 0xef, 0xf3, 0x67, 0x16, 0x8f, 0xf2, 0x8a, 0xa7, 0xd, 0xfd, 0x4c, 0x76, 0x44, 0x29, 0xd4, 0xad, 0x3a, + 0x7e, 0xf9, 0xef, 0x77, 0x2a, 0x9f, 0x2, 0x0, 0x0, 0x5b, 0x4f, 0x1, 0xeb, 0x1a, 0x0, 0xa, 0x2b, + 0xc1, 0x3d, 0x5d, 0x29, 0xd5, 0x2b, 0x1e, 0x6a, 0xe2, 0xc5, 0xd2, 0xc9, 0xa4, 0xec, 0x60, 0x1d, 0x4a, + 0x6a, 0x79, 0x68, 0xfc, 0x63, 0x1d, 0xb9, 0xbe, 0x96, 0x78, 0x59, 0xef, 0x3e, 0xdc, 0xa5, 0x2e}; + + uint8_t buf[128] = {0}; + + uint8_t topic_bytes[] = {0xa1, 0x26, 0x4b, 0x1d, 0x75, 0xa4, 0x11, 0x57, 0x9c, 0xcd, + 0x12, 0x65, 0x1f, 0xfd, 0x1a, 0xd4, 0x1d, 0x92, 0x75}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xc5, 0xd2, 0xc9, 0xa4, 0xec, 0x60, 0x1d, 0x4a, 0x6a, 0x79, 0x68, 0xfc, + 0x63, 0x1d, 0xb9, 0xbe, 0x96, 0x78, 0x59, 0xef, 0x3e, 0xdc, 0xa5, 0x2e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 24; + + uint8_t bytes1[] = {0xb8, 0x72, 0xd3, 0x51, 0x2e, 0x39, 0xae, 0xef, 0xf3, 0x67, 0x16, 0x8f, 0xf2, 0x8a, + 0xa7, 0xd, 0xfd, 0x4c, 0x76, 0x44, 0x29, 0xd4, 0xad, 0x3a, 0x7e, 0xf9, 0xef, 0x77}; + uint8_t bytes0[] = {0xa8, 0x3d, 0x62, 0x6e, 0x4b, 0xac, 0xbf, 0x74, 0x60, 0xa5, 0xe0, 0xba, 0xa5}; + uint8_t bytes2[] = {0x2b, 0xc1, 0x3d, 0x5d, 0x29, 0xd5, 0x2b, 0x1e, 0x6a, 0xe2}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytes0}, .v = {28, (char*)&bytes1}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23375}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytes2}}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 4938, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\149\203\181S\"+\168\160\141\DEL~e8\150\193\SYN\t1", _pubPktID = 0, _pubBody = "m#Za\252\192\201Y\NAK\221", +// _pubProps = [PropAuthenticationMethod "\239\NAK Ne\152\241\151\247rn\164\185\146\&1u +// m\132\171O",PropWildcardSubscriptionAvailable 249,PropServerKeepAlive 18975]} +TEST(Publish50QCTest, Encode96) { + uint8_t pkt[] = {0x38, 0x3c, 0x0, 0x12, 0x95, 0xcb, 0xb5, 0x53, 0x22, 0x2b, 0xa8, 0xa0, 0x8d, 0x7f, 0x7e, 0x65, + 0x38, 0x96, 0xc1, 0x16, 0x9, 0x31, 0x1d, 0x15, 0x0, 0x15, 0xef, 0x15, 0x20, 0x4e, 0x65, 0x98, + 0xf1, 0x97, 0xf7, 0x72, 0x6e, 0xa4, 0xb9, 0x92, 0x31, 0x75, 0x20, 0x6d, 0x84, 0xab, 0x4f, 0x28, + 0xf9, 0x13, 0x4a, 0x1f, 0x6d, 0x23, 0x5a, 0x61, 0xfc, 0xc0, 0xc9, 0x59, 0x15, 0xdd}; + + uint8_t buf[72] = {0}; + + uint8_t topic_bytes[] = {0x95, 0xcb, 0xb5, 0x53, 0x22, 0x2b, 0xa8, 0xa0, 0x8d, + 0x7f, 0x7e, 0x65, 0x38, 0x96, 0xc1, 0x16, 0x9, 0x31}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x6d, 0x23, 0x5a, 0x61, 0xfc, 0xc0, 0xc9, 0x59, 0x15, 0xdd}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 10; + + uint8_t bytes0[] = {0xef, 0x15, 0x20, 0x4e, 0x65, 0x98, 0xf1, 0x97, 0xf7, 0x72, 0x6e, + 0xa4, 0xb9, 0x92, 0x31, 0x75, 0x20, 0x6d, 0x84, 0xab, 0x4f}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18975}}, + }; + + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\254\DLE\200m\251\190\157\139\&9=\175\219\238~:ap/{\148", _pubPktID = 0, _pubBody = "\163~rt", _pubProps = +// [PropReasonString "\vi\205g&\ENQ\169\&0X\187\&6\214~\131\185\EOT\DLE\140G\203.A\NUL\160\165\FS +// ZkV",PropCorrelationData "\STX",PropSessionExpiryInterval 9141,PropTopicAlias 2629,PropAssignedClientIdentifier +// "\172M)%\189\217zZ\194dR+\177\\Pl\212\201vL\DELs\242\182q",PropMaximumPacketSize 13928,PropMessageExpiryInterval +// 7205,PropRetainAvailable 115,PropReasonString +// "\CAN\180\ETXG~\197N\246%\202\178H\244\r\STXA\241re\225`%s\214l",PropWillDelayInterval +// 319,PropAssignedClientIdentifier "G\221\200e\243\191\v=\221C\177\b\241\227\139\157\213\&4H\187PH\235\222\DLE\ACK +// ",PropServerKeepAlive 3982,PropAuthenticationData +// "\246:\252\141\t\DC2\129p\254{\248\188\255\ESC)}\152\143\245",PropMaximumQoS 212,PropMaximumPacketSize +// 7512,PropCorrelationData "1\238\145\190\242\&3\174\\E\FS\144",PropReasonString +// "p\163{\STXc\219\223O\252\GS\242@|ujA\EOT\179\&7.",PropMessageExpiryInterval 27783,PropMessageExpiryInterval +// 17888,PropUserProperty "\204j\240k\180\&3\197\178\191\&3\137\193\216 \134~,\137k.Rt\129\205p4\249\244\226\241" +// "J\250\201\156*pD\156\248Q\212\212\165\245bf6\140\179\RS\ETB\202\136\238\249\&4^c#",PropTopicAlias +// 8403,PropReceiveMaximum 32198,PropSharedSubscriptionAvailable 103,PropUserProperty "\t'qd1#\255\248\160." +// "\215g\DC2\254\160F\247d\153\130\EM\EOT\\\163\236\189\148\US\154$\150\211\bQ\202\DC1",PropMessageExpiryInterval +// 1577,PropResponseInformation +// "\SUB\252\168\174\204\218\&2\233X\DC3\223,\195\ENQ9\n\DC1\152\239\RS\EM3\250\&6\by[\225\235\152",PropUserProperty +// "r\163\213\CAN\b3\197\201\CAN\DC1\194\211\211\201" "\225~",PropPayloadFormatIndicator 240,PropPayloadFormatIndicator +// 61]} +TEST(Publish50QCTest, Encode97) { + uint8_t pkt[] = { + 0x38, 0xaf, 0x3, 0x0, 0x14, 0xfe, 0x10, 0xc8, 0x6d, 0xfb, 0xbe, 0x9d, 0x8b, 0x39, 0x3d, 0xaf, 0xdb, 0xee, 0x7e, + 0x3a, 0x61, 0x70, 0x2f, 0x7b, 0x94, 0x93, 0x3, 0x1f, 0x0, 0x1e, 0xb, 0x69, 0xcd, 0x67, 0x26, 0x5, 0xa9, 0x30, + 0x58, 0xbb, 0x36, 0xd6, 0x7e, 0x83, 0xb9, 0x4, 0x10, 0x8c, 0x47, 0xcb, 0x2e, 0x41, 0x0, 0xa0, 0xa5, 0x1c, 0x20, + 0x5a, 0x6b, 0x56, 0x9, 0x0, 0x1, 0x2, 0x11, 0x0, 0x0, 0x23, 0xb5, 0x23, 0xa, 0x45, 0x12, 0x0, 0x19, 0xac, + 0x4d, 0x29, 0x25, 0xbd, 0xd9, 0x7a, 0x5a, 0xc2, 0x64, 0x52, 0x2b, 0xb1, 0x5c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 0x6b, 0x2e, 0x52, 0x74, 0x81, 0xcd, 0x70, 0x34, 0xf9, 0xf4, + 0xe2, 0xf1, 0x0, 0x1d, 0x4a, 0xfa, 0xc9, 0x9c, 0x2a, 0x70, 0x44, 0x9c, 0xf8, 0x51, 0xd4, 0xd4, 0xa5, 0xf5, 0x62, + 0x66, 0x36, 0x8c, 0xb3, 0x1e, 0x17, 0xca, 0x88, 0xee, 0xf9, 0x34, 0x5e, 0x63, 0x23, 0x23, 0x20, 0xd3, 0x21, 0x7d, + 0xc6, 0x2a, 0x67, 0x26, 0x0, 0xa, 0x9, 0x27, 0x71, 0x64, 0x31, 0x23, 0xff, 0xf8, 0xa0, 0x2e, 0x0, 0x1a, 0xd7, + 0x67, 0x12, 0xfe, 0xa0, 0x46, 0xf7, 0x64, 0x99, 0x82, 0x19, 0x4, 0x5c, 0xa3, 0xec, 0xbd, 0x94, 0x1f, 0x9a, 0x24, + 0x96, 0xd3, 0x8, 0x51, 0xca, 0x11, 0x2, 0x0, 0x0, 0x6, 0x29, 0x1a, 0x0, 0x1e, 0x1a, 0xfc, 0xa8, 0xae, 0xcc, + 0xda, 0x32, 0xe9, 0x58, 0x13, 0xdf, 0x2c, 0xc3, 0x5, 0x39, 0xa, 0x11, 0x98, 0xef, 0x1e, 0x19, 0x33, 0xfa, 0x36, + 0x8, 0x79, 0x5b, 0xe1, 0xeb, 0x98, 0x26, 0x0, 0xe, 0x72, 0xa3, 0xd5, 0x18, 0x8, 0x33, 0xc5, 0xc9, 0x18, 0x11, + 0xc2, 0xd3, 0xd3, 0xc9, 0x0, 0x2, 0xe1, 0x7e, 0x1, 0xf0, 0x1, 0x3d, 0xa3, 0x7e, 0x72, 0x74}; + + uint8_t buf[444] = {0}; + + uint8_t topic_bytes[] = {0xfe, 0x10, 0xc8, 0x6d, 0xfb, 0xbe, 0x9d, 0x8b, 0x39, 0x3d, + 0xaf, 0xdb, 0xee, 0x7e, 0x3a, 0x61, 0x70, 0x2f, 0x7b, 0x94}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xa3, 0x7e, 0x72, 0x74}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; + + uint8_t bytes0[] = {0xb, 0x69, 0xcd, 0x67, 0x26, 0x5, 0xa9, 0x30, 0x58, 0xbb, 0x36, 0xd6, 0x7e, 0x83, 0xb9, + 0x4, 0x10, 0x8c, 0x47, 0xcb, 0x2e, 0x41, 0x0, 0xa0, 0xa5, 0x1c, 0x20, 0x5a, 0x6b, 0x56}; + uint8_t bytes1[] = {0x2}; + uint8_t bytes2[] = {0xac, 0x4d, 0x29, 0x25, 0xbd, 0xd9, 0x7a, 0x5a, 0xc2, 0x64, 0x52, 0x2b, 0xb1, + 0x5c, 0x50, 0x6c, 0xd4, 0xc9, 0x76, 0x4c, 0x7f, 0x73, 0xf2, 0xb6, 0x71}; + uint8_t bytes3[] = {0x18, 0xb4, 0x3, 0x47, 0x7e, 0xc5, 0x4e, 0xf6, 0x25, 0xca, 0xb2, 0x48, 0xf4, + 0xd, 0x2, 0x41, 0xf1, 0x72, 0x65, 0xe1, 0x60, 0x25, 0x73, 0xd6, 0x6c}; + uint8_t bytes4[] = {0x47, 0xdd, 0xc8, 0x65, 0xf3, 0xbf, 0xb, 0x3d, 0xdd, 0x43, 0xb1, 0x8, 0xf1, 0xe3, + 0x8b, 0x9d, 0xd5, 0x34, 0x48, 0xbb, 0x50, 0x48, 0xeb, 0xde, 0x10, 0x6, 0x20}; + uint8_t bytes5[] = {0xf6, 0x3a, 0xfc, 0x8d, 0x9, 0x12, 0x81, 0x70, 0xfe, 0x7b, + 0xf8, 0xbc, 0xff, 0x1b, 0x29, 0x7d, 0x98, 0x8f, 0xf5}; + uint8_t bytes6[] = {0x31, 0xee, 0x91, 0xbe, 0xf2, 0x33, 0xae, 0x5c, 0x45, 0x1c, 0x90}; + uint8_t bytes7[] = {0x70, 0xa3, 0x7b, 0x2, 0x63, 0xdb, 0xdf, 0x4f, 0xfc, 0x1d, + 0xf2, 0x40, 0x7c, 0x75, 0x6a, 0x41, 0x4, 0xb3, 0x37, 0x2e}; + uint8_t bytes9[] = {0x4a, 0xfa, 0xc9, 0x9c, 0x2a, 0x70, 0x44, 0x9c, 0xf8, 0x51, 0xd4, 0xd4, 0xa5, 0xf5, 0x62, + 0x66, 0x36, 0x8c, 0xb3, 0x1e, 0x17, 0xca, 0x88, 0xee, 0xf9, 0x34, 0x5e, 0x63, 0x23}; + uint8_t bytes8[] = {0xcc, 0x6a, 0xf0, 0x6b, 0xb4, 0x33, 0xc5, 0xb2, 0xbf, 0x33, 0x89, 0xc1, 0xd8, 0x20, 0x86, + 0x7e, 0x2c, 0x89, 0x6b, 0x2e, 0x52, 0x74, 0x81, 0xcd, 0x70, 0x34, 0xf9, 0xf4, 0xe2, 0xf1}; + uint8_t bytes11[] = {0xd7, 0x67, 0x12, 0xfe, 0xa0, 0x46, 0xf7, 0x64, 0x99, 0x82, 0x19, 0x4, 0x5c, + 0xa3, 0xec, 0xbd, 0x94, 0x1f, 0x9a, 0x24, 0x96, 0xd3, 0x8, 0x51, 0xca, 0x11}; + uint8_t bytes10[] = {0x9, 0x27, 0x71, 0x64, 0x31, 0x23, 0xff, 0xf8, 0xa0, 0x2e}; + uint8_t bytes12[] = {0x1a, 0xfc, 0xa8, 0xae, 0xcc, 0xda, 0x32, 0xe9, 0x58, 0x13, 0xdf, 0x2c, 0xc3, 0x5, 0x39, + 0xa, 0x11, 0x98, 0xef, 0x1e, 0x19, 0x33, 0xfa, 0x36, 0x8, 0x79, 0x5b, 0xe1, 0xeb, 0x98}; + uint8_t bytes14[] = {0xe1, 0x7e}; + uint8_t bytes13[] = {0x72, 0xa3, 0xd5, 0x18, 0x8, 0x33, 0xc5, 0xc9, 0x18, 0x11, 0xc2, 0xd3, 0xd3, 0xc9}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9141}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2629}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13928}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7205}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 319}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3982}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7512}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytes7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27783}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17888}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytes8}, .v = {29, (char*)&bytes9}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8403}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32198}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytes10}, .v = {26, (char*)&bytes11}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1577}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytes12}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytes13}, .v = {2, (char*)&bytes14}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 61}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\253a\DC4gD\189tvCr\177\&0w\132", +// _pubPktID = 26, _pubBody = "\188\SOx\169\171\214_\225\142.\SIW\SO\149\GS\184M\199\137\174\128cS\187OBD\139\218", +// _pubProps = [PropAuthenticationData "\226\204/{?\249a\ro\SUB\DEL\SO",PropRetainAvailable 219,PropResponseTopic +// "\234\222\203\USD\DC1N\154B\SOHg\155\148\154\SYN\136\164\b#",PropCorrelationData +// "6\181\218\186\233`7IK\158\241P\191\157^\196\242&\178\ACK\RS\246\r\241h\189b\211",PropResponseInformation +// "Q|\255J\246:",PropMaximumPacketSize 32759,PropTopicAliasMaximum 7804,PropServerReference +// "\178\&2]^r\252qQ",PropPayloadFormatIndicator 84,PropServerReference +// "\216B\204\195\251\NAK\ETBE\179",PropSubscriptionIdentifier 19,PropServerKeepAlive +// 27535,PropWildcardSubscriptionAvailable 84,PropTopicAlias 29554,PropResponseTopic +// "\183\170\178\171",PropMessageExpiryInterval 6362,PropTopicAlias 5792,PropSubscriptionIdentifierAvailable 252]} +TEST(Publish50QCTest, Encode98) { + uint8_t pkt[] = {0x3a, 0xbc, 0x1, 0x0, 0xe, 0xfd, 0x61, 0x14, 0x67, 0x44, 0xbd, 0x74, 0x76, 0x43, 0x72, 0xb1, + 0x30, 0x77, 0x84, 0x0, 0x1a, 0x8b, 0x1, 0x16, 0x0, 0xc, 0xe2, 0xcc, 0x2f, 0x7b, 0x3f, 0xf9, + 0x61, 0xd, 0x6f, 0x1a, 0x7f, 0xe, 0x25, 0xdb, 0x8, 0x0, 0x13, 0xea, 0xde, 0xcb, 0x1f, 0x44, + 0x11, 0x4e, 0x9a, 0x42, 0x1, 0x67, 0x9b, 0x94, 0x9a, 0x16, 0x88, 0xa4, 0x8, 0x23, 0x9, 0x0, + 0x1c, 0x36, 0xb5, 0xda, 0xba, 0xe9, 0x60, 0x37, 0x49, 0x4b, 0x9e, 0xf1, 0x50, 0xbf, 0x9d, 0x5e, + 0xc4, 0xf2, 0x26, 0xb2, 0x6, 0x1e, 0xf6, 0xd, 0xf1, 0x68, 0xbd, 0x62, 0xd3, 0x1a, 0x0, 0x6, + 0x51, 0x7c, 0xff, 0x4a, 0xf6, 0x3a, 0x27, 0x0, 0x0, 0x7f, 0xf7, 0x22, 0x1e, 0x7c, 0x1c, 0x0, + 0x8, 0xb2, 0x32, 0x5d, 0x5e, 0x72, 0xfc, 0x71, 0x51, 0x1, 0x54, 0x1c, 0x0, 0x9, 0xd8, 0x42, + 0xcc, 0xc3, 0xfb, 0x15, 0x17, 0x45, 0xb3, 0xb, 0x13, 0x13, 0x6b, 0x8f, 0x28, 0x54, 0x23, 0x73, + 0x72, 0x8, 0x0, 0x4, 0xb7, 0xaa, 0xb2, 0xab, 0x2, 0x0, 0x0, 0x18, 0xda, 0x23, 0x16, 0xa0, + 0x29, 0xfc, 0xbc, 0xe, 0x78, 0xa9, 0xab, 0xd6, 0x5f, 0xe1, 0x8e, 0x2e, 0xf, 0x57, 0xe, 0x95, + 0x1d, 0xb8, 0x4d, 0xc7, 0x89, 0xae, 0x80, 0x63, 0x53, 0xbb, 0x4f, 0x42, 0x44, 0x8b, 0xda}; + + uint8_t buf[201] = {0}; + + uint8_t topic_bytes[] = {0xfd, 0x61, 0x14, 0x67, 0x44, 0xbd, 0x74, 0x76, 0x43, 0x72, 0xb1, 0x30, 0x77, 0x84}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xbc, 0xe, 0x78, 0xa9, 0xab, 0xd6, 0x5f, 0xe1, 0x8e, 0x2e, 0xf, 0x57, 0xe, 0x95, 0x1d, + 0xb8, 0x4d, 0xc7, 0x89, 0xae, 0x80, 0x63, 0x53, 0xbb, 0x4f, 0x42, 0x44, 0x8b, 0xda}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; + + uint8_t bytes0[] = {0xe2, 0xcc, 0x2f, 0x7b, 0x3f, 0xf9, 0x61, 0xd, 0x6f, 0x1a, 0x7f, 0xe}; + uint8_t bytes1[] = {0xea, 0xde, 0xcb, 0x1f, 0x44, 0x11, 0x4e, 0x9a, 0x42, 0x1, + 0x67, 0x9b, 0x94, 0x9a, 0x16, 0x88, 0xa4, 0x8, 0x23}; + uint8_t bytes2[] = {0x36, 0xb5, 0xda, 0xba, 0xe9, 0x60, 0x37, 0x49, 0x4b, 0x9e, 0xf1, 0x50, 0xbf, 0x9d, + 0x5e, 0xc4, 0xf2, 0x26, 0xb2, 0x6, 0x1e, 0xf6, 0xd, 0xf1, 0x68, 0xbd, 0x62, 0xd3}; + uint8_t bytes3[] = {0x51, 0x7c, 0xff, 0x4a, 0xf6, 0x3a}; + uint8_t bytes4[] = {0xb2, 0x32, 0x5d, 0x5e, 0x72, 0xfc, 0x71, 0x51}; + uint8_t bytes5[] = {0xd8, 0x42, 0xcc, 0xc3, 0xfb, 0x15, 0x17, 0x45, 0xb3}; + uint8_t bytes6[] = {0xb7, 0xaa, 0xb2, 0xab}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytes2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytes3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32759}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7804}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytes4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytes5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27535}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29554}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytes6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6362}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5792}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 252}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 26, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\251\169\245\241\201;\SOH\174B\v\STX\SOH\202\137\ETX\139y\235\139\&8~b&\235", _pubPktID = 0, _pubBody = +// "O\222\143\SO\DC2\DC2\180\DC3\242\226I\151\ACKv\247\150\v\DC4\228", _pubProps = [PropMaximumQoS 201]} +TEST(Publish50QCTest, Encode99) { + uint8_t pkt[] = {0x39, 0x30, 0x0, 0x18, 0xfb, 0xa9, 0xf5, 0xf1, 0xc9, 0x3b, 0x1, 0xae, 0x42, 0xb, 0x2, 0x1, 0xca, + 0x89, 0x3, 0x8b, 0x79, 0xeb, 0x8b, 0x38, 0x7e, 0x62, 0x26, 0xeb, 0x2, 0x24, 0xc9, 0x4f, 0xde, 0x8f, + 0xe, 0x12, 0x12, 0xb4, 0x13, 0xf2, 0xe2, 0x49, 0x97, 0x6, 0x76, 0xf7, 0x96, 0xb, 0x14, 0xe4}; + + uint8_t buf[60] = {0}; + + uint8_t topic_bytes[] = {0xfb, 0xa9, 0xf5, 0xf1, 0xc9, 0x3b, 0x1, 0xae, 0x42, 0xb, 0x2, 0x1, + 0xca, 0x89, 0x3, 0x8b, 0x79, 0xeb, 0x8b, 0x38, 0x7e, 0x62, 0x26, 0xeb}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x4f, 0xde, 0x8f, 0xe, 0x12, 0x12, 0xb4, 0x13, 0xf2, 0xe2, + 0x49, 0x97, 0x6, 0x76, 0xf7, 0x96, 0xb, 0x14, 0xe4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 19; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 201}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\130\195\DC3\129^;\DC2\222\159\233g\190\156\&9\DC2\149t\138<\191|", _pubPktID = 0, _pubBody = +// "\145m\248\188\208:\172\v\129\EOT\158\139\132\192yQ\206S\252\152\ETBQrEx\t\ENQ^\235\139", _pubProps = +// [PropServerReference "\168\163\168\138\bJ+*K|I\236\ESC\EOTQ{\129\141\217Oqj\184\219",PropRequestResponseInformation +// 17,PropRequestProblemInformation 13,PropTopicAlias 11748,PropContentType +// "\220\183\162\rn\131\195\155",PropMessageExpiryInterval 13181,PropWillDelayInterval 21300,PropCorrelationData +// "\130S\"\217G\SI\SYN\GS\188&n\184\194,\163\190Tx\159\141\218e\216\222\RS"]} +TEST(Publish50QCTest, Encode100) { + uint8_t pkt[] = {0x30, 0x89, 0x1, 0x0, 0x15, 0x82, 0xc3, 0x13, 0x81, 0x5e, 0x3b, 0x12, 0xde, 0x9f, 0xe9, 0x67, + 0xbe, 0x9c, 0x39, 0x12, 0x95, 0x74, 0x8a, 0x3c, 0xbf, 0x7c, 0x53, 0x1c, 0x0, 0x18, 0xa8, 0xa3, + 0xa8, 0x8a, 0x8, 0x4a, 0x2b, 0x2a, 0x4b, 0x7c, 0x49, 0xec, 0x1b, 0x4, 0x51, 0x7b, 0x81, 0x8d, + 0xd9, 0x4f, 0x71, 0x6a, 0xb8, 0xdb, 0x19, 0x11, 0x17, 0xd, 0x23, 0x2d, 0xe4, 0x3, 0x0, 0x8, + 0xdc, 0xb7, 0xa2, 0xd, 0x6e, 0x83, 0xc3, 0x9b, 0x2, 0x0, 0x0, 0x33, 0x7d, 0x18, 0x0, 0x0, + 0x53, 0x34, 0x9, 0x0, 0x19, 0x82, 0x53, 0x22, 0xd9, 0x47, 0xf, 0x16, 0x1d, 0xbc, 0x26, 0x6e, + 0xb8, 0xc2, 0x2c, 0xa3, 0xbe, 0x54, 0x78, 0x9f, 0x8d, 0xda, 0x65, 0xd8, 0xde, 0x1e, 0x91, 0x6d, + 0xf8, 0xbc, 0xd0, 0x3a, 0xac, 0xb, 0x81, 0x4, 0x9e, 0x8b, 0x84, 0xc0, 0x79, 0x51, 0xce, 0x53, + 0xfc, 0x98, 0x17, 0x51, 0x72, 0x45, 0x78, 0x9, 0x5, 0x5e, 0xeb, 0x8b}; + + uint8_t buf[150] = {0}; + + uint8_t topic_bytes[] = {0x82, 0xc3, 0x13, 0x81, 0x5e, 0x3b, 0x12, 0xde, 0x9f, 0xe9, 0x67, + 0xbe, 0x9c, 0x39, 0x12, 0x95, 0x74, 0x8a, 0x3c, 0xbf, 0x7c}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x91, 0x6d, 0xf8, 0xbc, 0xd0, 0x3a, 0xac, 0xb, 0x81, 0x4, 0x9e, 0x8b, 0x84, 0xc0, 0x79, + 0x51, 0xce, 0x53, 0xfc, 0x98, 0x17, 0x51, 0x72, 0x45, 0x78, 0x9, 0x5, 0x5e, 0xeb, 0x8b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + uint8_t bytes0[] = {0xa8, 0xa3, 0xa8, 0x8a, 0x8, 0x4a, 0x2b, 0x2a, 0x4b, 0x7c, 0x49, 0xec, + 0x1b, 0x4, 0x51, 0x7b, 0x81, 0x8d, 0xd9, 0x4f, 0x71, 0x6a, 0xb8, 0xdb}; + uint8_t bytes1[] = {0xdc, 0xb7, 0xa2, 0xd, 0x6e, 0x83, 0xc3, 0x9b}; + uint8_t bytes2[] = {0x82, 0x53, 0x22, 0xd9, 0x47, 0xf, 0x16, 0x1d, 0xbc, 0x26, 0x6e, 0xb8, 0xc2, + 0x2c, 0xa3, 0xbe, 0x54, 0x78, 0x9f, 0x8d, 0xda, 0x65, 0xd8, 0xde, 0x1e}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytes0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11748}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytes1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13181}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21300}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytes2}}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "surgemq", _pubPktID = 0, _pubBody = +// "send me home", _pubProps = [PropMessageExpiryInterval 33,PropReasonString "a reason"]} +TEST(Publish50QCTest, Encode0) { + uint8_t pkt[] = {0x33, 0x28, 0x0, 0x7, 0x73, 0x75, 0x72, 0x67, 0x65, 0x6d, 0x71, 0x0, 0x0, 0x10, + 0x2, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x0, 0x8, 0x61, 0x20, 0x72, 0x65, 0x61, 0x73, + 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x64, 0x20, 0x6d, 0x65, 0x20, 0x68, 0x6f, 0x6d, 0x65}; + + uint8_t buf[52] = {0}; + + uint8_t topic_bytes[] = {0x73, 0x75, 0x72, 0x67, 0x65, 0x6d, 0x71}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x73, 0x65, 0x6e, 0x64, 0x20, 0x6d, 0x65, 0x20, 0x68, 0x6f, 0x6d, 0x65}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; + + uint8_t bytes0[] = {0x61, 0x20, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e}; + + lwmqtt_property_t proplist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 33}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytes0}}}, + }; + + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&proplist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} diff --git a/tests/packet.cpp b/tests/packet.cpp index 4e8732b..28c2628 100644 --- a/tests/packet.cpp +++ b/tests/packet.cpp @@ -270,7 +270,7 @@ TEST(ConnackTest, Decode1) { bool session_present; lwmqtt_return_code_t return_code; - lwmqtt_err_t err = lwmqtt_decode_connack(pkt, 4, LWMQTT_MQTT311, &session_present, &return_code); + lwmqtt_err_t err = lwmqtt_decode_connack(pkt, 4, LWMQTT_MQTT311, &session_present, &return_code); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(session_present, false); @@ -683,7 +683,8 @@ TEST(SubscribeTest, Encode1) { lwmqtt_qos_t qos_levels[3] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, 38, &len, LWMQTT_MQTT311, 7, 3, topic_filters, qos_levels, empty_props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, 38, &len, LWMQTT_MQTT311, 7, 3, topic_filters, qos_levels, empty_props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); @@ -698,7 +699,8 @@ TEST(SubscribeTest, EncodeError1) { lwmqtt_qos_t qos_levels[1] = {LWMQTT_QOS0}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, 2, &len, LWMQTT_MQTT311, 7, 1, topic_filters, qos_levels, empty_props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, 2, &len, LWMQTT_MQTT311, 7, 1, topic_filters, qos_levels, empty_props); EXPECT_EQ(err, LWMQTT_BUFFER_TOO_SHORT); } From b4702b9b753563766ee42f944396205613b9dc1e Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 18 Sep 2019 09:15:11 -0700 Subject: [PATCH 06/26] Reuse publish test builder. --- gentests/app/Main.hs | 61 +++++++++++--------------------------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 7277530..d3e231f 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -28,35 +28,16 @@ qos QoS0 = "LWMQTT_QOS0" qos QoS1 = "LWMQTT_QOS1" qos QoS2 = "LWMQTT_QOS2" -v311PubReq :: PublishRequest -> PublishRequest -v311PubReq p50 = let (PublishPkt p) = v311mask (PublishPkt p50) in p +protlvl :: ProtocolLevel -> String +protlvl Protocol311 = "LWMQTT_MQTT311" +protlvl Protocol50 = "LWMQTT_MQTT5" -genPublish311Test :: Int -> PublishRequest -> IO () -genPublish311Test i p@PublishRequest{..} = do - let e = toByteString Protocol311 p - - putStrLn $ "// " <> show p - putStrLn $ "TEST(Publish311QCTest, Encode" <> show i <> ") {" - putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" - - putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" +shortprot :: ProtocolLevel -> String +shortprot Protocol311 = "311" +shortprot Protocol50 = "5" - putStrLn . mconcat $ [ - " uint8_t topic_bytes[] = {" <> hexa _pubTopic <> "};\n", - " lwmqtt_string_t topic = { " <> show (BL.length _pubTopic) <> ", (char*)&topic_bytes};\n", - " lwmqtt_message_t msg = lwmqtt_default_message;\n", - " msg.qos = " <> qos _pubQoS <> ";\n", - " msg.retained = " <> bool _pubRetain <> ";\n", - " uint8_t msg_bytes[] = {" <> hexa _pubBody <> "};\n", - " msg.payload = (unsigned char*)&msg_bytes;\n", - " msg.payload_len = " <> show (BL.length _pubBody) <> ";\n\n", - " size_t len = 0;\n", - " lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, ", - bool _pubDup, ", ", show _pubPktID, ", topic, msg, empty_props);\n\n", - " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", - " EXPECT_ARRAY_EQ(pkt, buf, len);" - ] - putStrLn "}\n" +v311PubReq :: PublishRequest -> PublishRequest +v311PubReq p50 = let (PublishPkt p) = v311mask (PublishPkt p50) in p data Prop = IProp Int String Int | SProp Int String (Int,BL.ByteString) @@ -133,12 +114,12 @@ encodePropList props = let (hdr, cp) = (emitByteArrays . captureProps) props in p :: [BL.ByteString] -> [String] p = map (map (toEnum . fromEnum) . BL.unpack) -genPublish50Test :: Int -> PublishRequest -> IO () -genPublish50Test i p@PublishRequest{..} = do - let e = toByteString Protocol50 p +genPublishTest :: ProtocolLevel -> Int -> PublishRequest -> IO () +genPublishTest prot i p@PublishRequest{..} = do + let e = toByteString prot p putStrLn $ "// " <> show p - putStrLn $ "TEST(Publish50QCTest, Encode" <> show i <> ") {" + putStrLn $ "TEST(Publish" <> shortprot prot <> "QCTest, Encode" <> show i <> ") {" putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" @@ -155,14 +136,13 @@ genPublish50Test i p@PublishRequest{..} = do " ", encodePropList _pubProps, "\n", " lwmqtt_properties_t props = {" <> show (length _pubProps) <> ", (lwmqtt_property_t*)&proplist};\n", " size_t len = 0;\n", - " lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, ", + " lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, " <> protlvl prot <> ", ", bool _pubDup, ", ", show _pubPktID, ", topic, msg, props);\n\n", " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", " EXPECT_ARRAY_EQ(pkt, buf, len);" ] putStrLn "}\n" - main :: IO () main = do putStrLn [r|#include @@ -181,8 +161,6 @@ extern "C" { #endif #endif -static lwmqtt_properties_t empty_props = lwmqtt_empty_props; - #define EXPECT_ARRAY_EQ(reference, actual, element_count) \ { \ for (size_t cmp_i = 0; cmp_i < element_count; cmp_i++) { \ @@ -191,14 +169,5 @@ static lwmqtt_properties_t empty_props = lwmqtt_empty_props; } |] x <- replicateM 100 $ generate arbitrary - mapM_ (\(i,p) -> genPublish311Test i (v311PubReq p)) $ zip [1..] x - mapM_ (uncurry genPublish50Test) $ zip [1..] x - genPublish50Test 0 (PublishRequest{ - _pubTopic = "surgemq", - _pubBody = "send me home", - _pubRetain = True, - _pubQoS = QoS1, - _pubDup = False, - _pubPktID = 0, - _pubProps = [PropMessageExpiryInterval 33, - PropReasonString "a reason"]}) + mapM_ (\(i,p) -> genPublishTest Protocol311 i (v311PubReq p)) $ zip [1..] x + mapM_ (uncurry $ genPublishTest Protocol50) $ zip [1..] x From 59ce1805ff5fdf6e2fff277d4f45bbea9a2ba0dc Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 18 Sep 2019 09:22:06 -0700 Subject: [PATCH 07/26] Reusable properties encoding --- gentests/app/Main.hs | 62 ++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index d3e231f..840e6f0 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -82,37 +82,44 @@ captureProps = map e e (PropSubscriptionIdentifierAvailable x) = peW8 0x29 x e (PropSharedSubscriptionAvailable x) = peW8 0x2a x -emitByteArrays :: [Prop] -> ([String], [Prop]) -emitByteArrays = go [] [] 0 - where - go :: [String] -> [Prop] -> Int -> [Prop] -> ([String], [Prop]) - go l p _ [] = (reverse l, reverse p) - go l p n ((x@IProp{}):xs) = go l (x:p) n xs - go l p n ((SProp i s (_,bs)):xs) = go (newstr n bs:l) (SProp i s (n,bs):p) (n+1) xs - go l p n ((UProp i (_,bs1) (_,bs2)):xs) = go (newstr n bs1 : newstr (n+1) bs2 : l) (UProp i (n,bs1) (n+1,bs2):p) (n+2) xs - - newstr n s = "uint8_t bytes" <> show n <> "[] = {" <> hexa s <> "};" - -encodePropList :: [MT.Property] -> String -encodePropList props = let (hdr, cp) = (emitByteArrays . captureProps) props in - mconcat (map (<>"\n ") hdr) <> "\n" - <> " lwmqtt_property_t proplist[] = {\n" - <> mconcat (map (indent.e) cp) - <> " };\n" +-- Emit the given list of properties as C code. +genProperties :: [MT.Property] -> String +genProperties props = mconcat [ + " ", encodePropList, "\n", + " lwmqtt_properties_t props = {" <> show (length props) <> ", (lwmqtt_property_t*)&proplist};\n" + ] + where - e :: Prop -> String - e (IProp i n v) = prop i n (show v) - e (SProp i n (x,xv)) = prop i n (b x xv) - e (UProp i (k,kv) (v,vv)) = prop i "pair" ("{.k=" <> b k kv <> ", .v=" <> b v vv <> "}") + encodePropList = let (hdr, cp) = (emitByteArrays . captureProps) props in + mconcat (map (<>"\n ") hdr) <> "\n" + <> " lwmqtt_property_t proplist[] = {\n" + <> mconcat (map (indent.e) cp) + <> " };\n" + where + emitByteArrays :: [Prop] -> ([String], [Prop]) + emitByteArrays = go [] [] 0 + where + go :: [String] -> [Prop] -> Int -> [Prop] -> ([String], [Prop]) + go l p _ [] = (reverse l, reverse p) + go l p n ((x@IProp{}):xs) = go l (x:p) n xs + go l p n ((SProp i s (_,bs)):xs) = go (newstr n bs:l) (SProp i s (n,bs):p) (n+1) xs + go l p n ((UProp i (_,bs1) (_,bs2)):xs) = go (newstr n bs1 : newstr (n+1) bs2 : l) (UProp i (n,bs1) (n+1,bs2):p) (n+2) xs + + newstr n s = "uint8_t bytes" <> show n <> "[] = {" <> hexa s <> "};" + + e :: Prop -> String + e (IProp i n v) = prop i n (show v) + e (SProp i n (x,xv)) = prop i n (b x xv) + e (UProp i (k,kv) (v,vv)) = prop i "pair" ("{.k=" <> b k kv <> ", .v=" <> b v vv <> "}") - prop i n v = "{.prop = (lwmqtt_prop_t)" <> show i <> ", .value = {." <> n <> " = " <> v <> "}},\n" + prop i n v = "{.prop = (lwmqtt_prop_t)" <> show i <> ", .value = {." <> n <> " = " <> v <> "}},\n" - indent = (" " <>) + indent = (" " <>) - b x xv = "{" <> show (BL.length xv) <> ", (char*)&bytes" <> show x <> "}" + b x xv = "{" <> show (BL.length xv) <> ", (char*)&bytes" <> show x <> "}" - p :: [BL.ByteString] -> [String] - p = map (map (toEnum . fromEnum) . BL.unpack) + p :: [BL.ByteString] -> [String] + p = map (map (toEnum . fromEnum) . BL.unpack) genPublishTest :: ProtocolLevel -> Int -> PublishRequest -> IO () genPublishTest prot i p@PublishRequest{..} = do @@ -133,8 +140,7 @@ genPublishTest prot i p@PublishRequest{..} = do " uint8_t msg_bytes[] = {" <> hexa _pubBody <> "};\n", " msg.payload = (unsigned char*)&msg_bytes;\n", " msg.payload_len = " <> show (BL.length _pubBody) <> ";\n\n", - " ", encodePropList _pubProps, "\n", - " lwmqtt_properties_t props = {" <> show (length _pubProps) <> ", (lwmqtt_property_t*)&proplist};\n", + genProperties _pubProps, " size_t len = 0;\n", " lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, " <> protlvl prot <> ", ", bool _pubDup, ", ", show _pubPktID, ", topic, msg, props);\n\n", From 9986847e4fad0ee7e9206b2c0fdfc875869c53cc Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 18 Sep 2019 10:28:34 -0700 Subject: [PATCH 08/26] Generate connection tests. I also found I needed to implement will properties since the tests generated those cases. And empty username or password handling is unexpected. --- gentests/app/Main.hs | 100 +- include/lwmqtt.h | 3 +- src/packet.c | 7 + tests/generated.cpp | 30113 +++++++++++++++++++++++++++++++---------- 4 files changed, 23380 insertions(+), 6843 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 840e6f0..089c7a6 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -8,6 +8,7 @@ import Control.Monad (replicateM) import qualified Data.ByteString.Char8 as BC import qualified Data.ByteString.Lazy as BL import Data.List (intercalate) +import Data.Maybe (isJust) import Network.MQTT.Arbitrary import Network.MQTT.Types as MT import Numeric (showHex) @@ -39,6 +40,19 @@ shortprot Protocol50 = "5" v311PubReq :: PublishRequest -> PublishRequest v311PubReq p50 = let (PublishPkt p) = v311mask (PublishPkt p50) in p +v311ConnReq :: ConnectRequest -> ConnectRequest +v311ConnReq p50 = let (ConnPkt p) = v311mask (ConnPkt p50) in p + +userFix :: ConnectRequest -> ConnectRequest +userFix = ufix . pfix + where + ufix p@ConnectRequest{..} + | _username == (Just "") = p{_username=Nothing} + | otherwise = p + pfix p@ConnectRequest{..} + | _password == (Just "") = p{_password=Nothing} + | otherwise = p + data Prop = IProp Int String Int | SProp Int String (Int,BL.ByteString) | UProp Int (Int,BL.ByteString) (Int,BL.ByteString) @@ -83,16 +97,16 @@ captureProps = map e e (PropSharedSubscriptionAvailable x) = peW8 0x2a x -- Emit the given list of properties as C code. -genProperties :: [MT.Property] -> String -genProperties props = mconcat [ +genProperties :: String -> [MT.Property] -> String +genProperties name props = mconcat [ " ", encodePropList, "\n", - " lwmqtt_properties_t props = {" <> show (length props) <> ", (lwmqtt_property_t*)&proplist};\n" + " lwmqtt_properties_t ", name, " = {" <> show (length props) <> ", (lwmqtt_property_t*)&", name, "list};\n" ] where encodePropList = let (hdr, cp) = (emitByteArrays . captureProps) props in mconcat (map (<>"\n ") hdr) <> "\n" - <> " lwmqtt_property_t proplist[] = {\n" + <> " lwmqtt_property_t " <> name <> "list[] = {\n" <> mconcat (map (indent.e) cp) <> " };\n" where @@ -105,7 +119,7 @@ genProperties props = mconcat [ go l p n ((SProp i s (_,bs)):xs) = go (newstr n bs:l) (SProp i s (n,bs):p) (n+1) xs go l p n ((UProp i (_,bs1) (_,bs2)):xs) = go (newstr n bs1 : newstr (n+1) bs2 : l) (UProp i (n,bs1) (n+1,bs2):p) (n+2) xs - newstr n s = "uint8_t bytes" <> show n <> "[] = {" <> hexa s <> "};" + newstr n s = "uint8_t bytes" <> name <> show n <> "[] = {" <> hexa s <> "};" e :: Prop -> String e (IProp i n v) = prop i n (show v) @@ -116,11 +130,17 @@ genProperties props = mconcat [ indent = (" " <>) - b x xv = "{" <> show (BL.length xv) <> ", (char*)&bytes" <> show x <> "}" + b x xv = "{" <> show (BL.length xv) <> ", (char*)&bytes" <> name <> show x <> "}" p :: [BL.ByteString] -> [String] p = map (map (toEnum . fromEnum) . BL.unpack) +encodeString :: String -> BL.ByteString -> String +encodeString name bytes = mconcat [ + " uint8_t " <> name <> "_bytes[] = {" <> hexa bytes <> "};\n", + " lwmqtt_string_t " <> name <> " = {" <> show (BL.length bytes) <> ", (char*)&" <> name <> "_bytes};\n" + ] + genPublishTest :: ProtocolLevel -> Int -> PublishRequest -> IO () genPublishTest prot i p@PublishRequest{..} = do let e = toByteString prot p @@ -132,15 +152,14 @@ genPublishTest prot i p@PublishRequest{..} = do putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" putStrLn . mconcat $ [ - " uint8_t topic_bytes[] = {" <> hexa _pubTopic <> "};\n", - " lwmqtt_string_t topic = { " <> show (BL.length _pubTopic) <> ", (char*)&topic_bytes};\n", + encodeString "topic" _pubTopic, " lwmqtt_message_t msg = lwmqtt_default_message;\n", " msg.qos = " <> qos _pubQoS <> ";\n", " msg.retained = " <> bool _pubRetain <> ";\n", " uint8_t msg_bytes[] = {" <> hexa _pubBody <> "};\n", " msg.payload = (unsigned char*)&msg_bytes;\n", " msg.payload_len = " <> show (BL.length _pubBody) <> ";\n\n", - genProperties _pubProps, + genProperties "props" _pubProps, " size_t len = 0;\n", " lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, " <> protlvl prot <> ", ", bool _pubDup, ", ", show _pubPktID, ", topic, msg, props);\n\n", @@ -149,6 +168,59 @@ genPublishTest prot i p@PublishRequest{..} = do ] putStrLn "}\n" +genConnectTest :: ProtocolLevel -> Int -> ConnectRequest -> IO () +genConnectTest prot i p@ConnectRequest{..} = do + let e = toByteString prot p + + putStrLn $ "// " <> show p + putStrLn $ "TEST(Connect" <> shortprot prot <> "QCTest, Encode" <> show i <> ") {" + putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" + + putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" + + putStrLn . mconcat $ [ + genProperties "props" _properties, + encodeWill _lastWill, + encodeOptions, + "size_t len = 0;\n", + "lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, " <> protlvl prot <> ", opts, ", + if isJust _lastWill then "&will" else "NULL", ");\n\n", + "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + "EXPECT_ARRAY_EQ(pkt, buf, len);" + ] + putStrLn "}\n" + + where + encodeWill Nothing = "" + encodeWill (Just LastWill{..}) = mconcat [ + "lwmqtt_will_t will = lwmqtt_default_will;\n", + genProperties "willprops" _willProps, + encodeString "will_topic" _willTopic, + encodeString "will_payload" _willMsg, + "will.topic = will_topic;\n", + "will.payload = will_payload;\n", + "will.qos = " <> qos _willQoS <> ";\n", + "will.retained = " <> bool _willRetain <> ";\n", + "will.properties = willprops;\n" + ] + + encodeOptions = mconcat [ + "lwmqtt_options_t opts = lwmqtt_default_options;\n", + "opts.properties = props;\n", + "opts.clean_session = " <> bool _cleanSession <> ";\n", + "opts.keep_alive = " <> show _keepAlive <> ";\n", + encodeString "client_id" _connID, + "opts.client_id = client_id;\n", + maybeString "username" _username, + maybeString "password" _password + ] + + where maybeString _ Nothing = "" + maybeString n (Just b) = mconcat [ + encodeString n b, + "opts.", n, " = ", n, ";\n" + ] + main :: IO () main = do putStrLn [r|#include @@ -174,6 +246,10 @@ extern "C" { } \ } |] - x <- replicateM 100 $ generate arbitrary - mapM_ (\(i,p) -> genPublishTest Protocol311 i (v311PubReq p)) $ zip [1..] x - mapM_ (uncurry $ genPublishTest Protocol50) $ zip [1..] x + pubs <- replicateM 100 $ generate arbitrary + mapM_ (uncurry $ genPublishTest Protocol311) $ zip [1..] (v311PubReq <$> pubs) + mapM_ (uncurry $ genPublishTest Protocol50) $ zip [1..] pubs + + conns <- replicateM 100 $ generate arbitrary + mapM_ (uncurry $ genConnectTest Protocol311) $ zip [1..] (userFix . v311ConnReq <$> conns) + mapM_ (uncurry $ genConnectTest Protocol50) $ zip [1..] (userFix <$> conns) diff --git a/include/lwmqtt.h b/include/lwmqtt.h index 0a166e0..d186895 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -288,13 +288,14 @@ typedef struct { lwmqtt_qos_t qos; bool retained; lwmqtt_string_t payload; + lwmqtt_properties_t properties; } lwmqtt_will_t; /** * The default initializer for the will object. */ #define lwmqtt_default_will \ - { lwmqtt_default_string, LWMQTT_QOS0, false, lwmqtt_default_string } + { lwmqtt_default_string, LWMQTT_QOS0, false, lwmqtt_default_string, lwmqtt_empty_props } /** * The object containing the connection options for a client. diff --git a/src/packet.c b/src/packet.c index d2fab09..1d4e54e 100644 --- a/src/packet.c +++ b/src/packet.c @@ -229,6 +229,7 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw // add will if present to remaining length if (will != NULL) { rem_len += will->topic.len + 2 + will->payload.len + 2; + rem_len += propslen(protocol, will->properties); } // add username if present to remaining length @@ -311,6 +312,7 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw return err; } + // write connection properties err = lwmqtt_write_props(&buf_ptr, buf_end, protocol, options.properties); if (err != LWMQTT_SUCCESS) { return err; @@ -324,6 +326,11 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw // write will if present if (will != NULL) { + err = lwmqtt_write_props(&buf_ptr, buf_end, protocol, will->properties); + if (err != LWMQTT_SUCCESS) { + return err; + } + // write topic err = lwmqtt_write_string(&buf_ptr, buf_end, will->topic); if (err != LWMQTT_SUCCESS) { diff --git a/tests/generated.cpp b/tests/generated.cpp index 81eb8b9..577ad5d 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -14,8 +14,6 @@ extern "C" { #endif #endif -static lwmqtt_properties_t empty_props = lwmqtt_empty_props; - #define EXPECT_ARRAY_EQ(reference, actual, element_count) \ { \ for (size_t cmp_i = 0; cmp_i < element_count; cmp_i++) { \ @@ -23,3011 +21,3240 @@ static lwmqtt_properties_t empty_props = lwmqtt_empty_props; } \ } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\136Y\192\226{\129\199E\USu\182\215\SUB'\245\DC4\171\139\NAKY", _pubPktID = 15774, _pubBody = "\255", _pubProps = -// []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\GS'O\GS\157L:\160!\232\238\251\210\SOH\149\247[\200\206V\228NIF", _pubPktID = 10712, _pubBody = +// "g\175\150\CANu\230<(Z\145\145 g\177\217P7\ENQ`V\167\212k\177\SUB.", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x32, 0x19, 0x0, 0x14, 0x88, 0x59, 0xc0, 0xe2, 0x7b, 0x81, 0xc7, 0x45, 0x1f, 0x75, - 0xb6, 0xd7, 0x1a, 0x27, 0xf5, 0x14, 0xab, 0x8b, 0x15, 0x59, 0x3d, 0x9e, 0xff}; + uint8_t pkt[] = {0x33, 0x36, 0x0, 0x18, 0x1d, 0x27, 0x4f, 0x1d, 0x9d, 0x4c, 0x3a, 0xa0, 0x21, 0xe8, + 0xee, 0xfb, 0xd2, 0x1, 0x95, 0xf7, 0x5b, 0xc8, 0xce, 0x56, 0xe4, 0x4e, 0x49, 0x46, + 0x29, 0xd8, 0x67, 0xaf, 0x96, 0x18, 0x75, 0xe6, 0x3c, 0x28, 0x5a, 0x91, 0x91, 0x20, + 0x67, 0xb1, 0xd9, 0x50, 0x37, 0x5, 0x60, 0x56, 0xa7, 0xd4, 0x6b, 0xb1, 0x1a, 0x2e}; - uint8_t buf[37] = {0}; + uint8_t buf[66] = {0}; - uint8_t topic_bytes[] = {0x88, 0x59, 0xc0, 0xe2, 0x7b, 0x81, 0xc7, 0x45, 0x1f, 0x75, - 0xb6, 0xd7, 0x1a, 0x27, 0xf5, 0x14, 0xab, 0x8b, 0x15, 0x59}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x1d, 0x27, 0x4f, 0x1d, 0x9d, 0x4c, 0x3a, 0xa0, 0x21, 0xe8, 0xee, 0xfb, + 0xd2, 0x1, 0x95, 0xf7, 0x5b, 0xc8, 0xce, 0x56, 0xe4, 0x4e, 0x49, 0x46}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xff}; + msg.retained = true; + uint8_t msg_bytes[] = {0x67, 0xaf, 0x96, 0x18, 0x75, 0xe6, 0x3c, 0x28, 0x5a, 0x91, 0x91, 0x20, 0x67, + 0xb1, 0xd9, 0x50, 0x37, 0x5, 0x60, 0x56, 0xa7, 0xd4, 0x6b, 0xb1, 0x1a, 0x2e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 26; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15774, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10712, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129/gG\151\&6y\225\246\193\230", -// _pubPktID = 31160, _pubBody = "\243\207\138\211\213\183N\154\SOafk\220\SUBT", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "q\140\EOT\210\163\254Vg\160L\221g\182\231\149f3\239k\200\DC2", _pubPktID = 10731, _pubBody = +// "\229\183\252?\173\165\FS\181?\130", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x3d, 0x1e, 0x0, 0xb, 0x81, 0x2f, 0x67, 0x47, 0x97, 0x36, 0x79, 0xe1, 0xf6, 0xc1, 0xe6, 0x79, - 0xb8, 0xf3, 0xcf, 0x8a, 0xd3, 0xd5, 0xb7, 0x4e, 0x9a, 0xe, 0x61, 0x66, 0x6b, 0xdc, 0x1a, 0x54}; + uint8_t pkt[] = {0x3c, 0x23, 0x0, 0x15, 0x71, 0x8c, 0x4, 0xd2, 0xa3, 0xfe, 0x56, 0x67, 0xa0, + 0x4c, 0xdd, 0x67, 0xb6, 0xe7, 0x95, 0x66, 0x33, 0xef, 0x6b, 0xc8, 0x12, 0x29, + 0xeb, 0xe5, 0xb7, 0xfc, 0x3f, 0xad, 0xa5, 0x1c, 0xb5, 0x3f, 0x82}; - uint8_t buf[42] = {0}; + uint8_t buf[47] = {0}; - uint8_t topic_bytes[] = {0x81, 0x2f, 0x67, 0x47, 0x97, 0x36, 0x79, 0xe1, 0xf6, 0xc1, 0xe6}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x71, 0x8c, 0x4, 0xd2, 0xa3, 0xfe, 0x56, 0x67, 0xa0, 0x4c, 0xdd, + 0x67, 0xb6, 0xe7, 0x95, 0x66, 0x33, 0xef, 0x6b, 0xc8, 0x12}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xf3, 0xcf, 0x8a, 0xd3, 0xd5, 0xb7, 0x4e, 0x9a, 0xe, 0x61, 0x66, 0x6b, 0xdc, 0x1a, 0x54}; + msg.retained = false; + uint8_t msg_bytes[] = {0xe5, 0xb7, 0xfc, 0x3f, 0xad, 0xa5, 0x1c, 0xb5, 0x3f, 0x82}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 10; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 31160, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10731, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\173\FS\174\250\f\SYN6\ENQ\218i\199\ETB\213\180 \FS%", _pubPktID = 27531, _pubBody = "\129\232\a\215w\236", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "I0\v\142\237", _pubPktID = 7560, +// _pubBody = "`\189\255\237\166\235-D\NAK", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x35, 0x1b, 0x0, 0x11, 0xad, 0x1c, 0xae, 0xfa, 0xc, 0x16, 0x36, 0x5, 0xda, 0x69, 0xc7, - 0x17, 0xd5, 0xb4, 0x20, 0x1c, 0x25, 0x6b, 0x8b, 0x81, 0xe8, 0x7, 0xd7, 0x77, 0xec}; + uint8_t pkt[] = {0x35, 0x12, 0x0, 0x5, 0x49, 0x30, 0xb, 0x8e, 0xed, 0x1d, + 0x88, 0x60, 0xbd, 0xff, 0xed, 0xa6, 0xeb, 0x2d, 0x44, 0x15}; - uint8_t buf[39] = {0}; + uint8_t buf[30] = {0}; - uint8_t topic_bytes[] = {0xad, 0x1c, 0xae, 0xfa, 0xc, 0x16, 0x36, 0x5, 0xda, - 0x69, 0xc7, 0x17, 0xd5, 0xb4, 0x20, 0x1c, 0x25}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x49, 0x30, 0xb, 0x8e, 0xed}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x81, 0xe8, 0x7, 0xd7, 0x77, 0xec}; + uint8_t msg_bytes[] = {0x60, 0xbd, 0xff, 0xed, 0xa6, 0xeb, 0x2d, 0x44, 0x15}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 9; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 27531, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7560, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "y\135\f\ESC\175I\RS=", _pubPktID = -// 3010, _pubBody = "\198L\248\190/9\218\229\251^", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\214d)\246\152\n-f", _pubPktID = +// 27404, _pubBody = "\187\167\151\192YY\244\252\216W\216\180S\218A\187\255\140'\172dG\187", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x35, 0x16, 0x0, 0x8, 0x79, 0x87, 0xc, 0x1b, 0xaf, 0x49, 0x1e, 0x3d, - 0xb, 0xc2, 0xc6, 0x4c, 0xf8, 0xbe, 0x2f, 0x39, 0xda, 0xe5, 0xfb, 0x5e}; + uint8_t pkt[] = {0x3b, 0x23, 0x0, 0x8, 0xd6, 0x64, 0x29, 0xf6, 0x98, 0xa, 0x2d, 0x66, 0x6b, + 0xc, 0xbb, 0xa7, 0x97, 0xc0, 0x59, 0x59, 0xf4, 0xfc, 0xd8, 0x57, 0xd8, 0xb4, + 0x53, 0xda, 0x41, 0xbb, 0xff, 0x8c, 0x27, 0xac, 0x64, 0x47, 0xbb}; - uint8_t buf[34] = {0}; + uint8_t buf[47] = {0}; - uint8_t topic_bytes[] = {0x79, 0x87, 0xc, 0x1b, 0xaf, 0x49, 0x1e, 0x3d}; + uint8_t topic_bytes[] = {0xd6, 0x64, 0x29, 0xf6, 0x98, 0xa, 0x2d, 0x66}; lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xc6, 0x4c, 0xf8, 0xbe, 0x2f, 0x39, 0xda, 0xe5, 0xfb, 0x5e}; + uint8_t msg_bytes[] = {0xbb, 0xa7, 0x97, 0xc0, 0x59, 0x59, 0xf4, 0xfc, 0xd8, 0x57, 0xd8, 0xb4, + 0x53, 0xda, 0x41, 0xbb, 0xff, 0x8c, 0x27, 0xac, 0x64, 0x47, 0xbb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + msg.payload_len = 23; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3010, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 27404, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\fQ\131\202\NAK\EOTT\204\226\174\189\&72w\136\ETX\142I\166)\137*", _pubPktID = 0, _pubBody = "\148\134\189", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\243i\174@\215\136\140u\b,", +// _pubPktID = 0, _pubBody = "_\166K\178hd\ETX^Q", _pubProps = []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x30, 0x1b, 0x0, 0x16, 0xc, 0x51, 0x83, 0xca, 0x15, 0x4, 0x54, 0xcc, 0xe2, 0xae, 0xbd, - 0x37, 0x32, 0x77, 0x88, 0x3, 0x8e, 0x49, 0xa6, 0x29, 0x89, 0x2a, 0x94, 0x86, 0xbd}; + uint8_t pkt[] = {0x38, 0x15, 0x0, 0xa, 0xf3, 0x69, 0xae, 0x40, 0xd7, 0x88, 0x8c, 0x75, + 0x8, 0x2c, 0x5f, 0xa6, 0x4b, 0xb2, 0x68, 0x64, 0x3, 0x5e, 0x51}; - uint8_t buf[39] = {0}; + uint8_t buf[33] = {0}; - uint8_t topic_bytes[] = {0xc, 0x51, 0x83, 0xca, 0x15, 0x4, 0x54, 0xcc, 0xe2, 0xae, 0xbd, - 0x37, 0x32, 0x77, 0x88, 0x3, 0x8e, 0x49, 0xa6, 0x29, 0x89, 0x2a}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xf3, 0x69, 0xae, 0x40, 0xd7, 0x88, 0x8c, 0x75, 0x8, 0x2c}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x94, 0x86, 0xbd}; + uint8_t msg_bytes[] = {0x5f, 0xa6, 0x4b, 0xb2, 0x68, 0x64, 0x3, 0x5e, 0x51}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 9; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\186\EMG9\192\229\240\204\DC2o", -// _pubPktID = 0, _pubBody = "\166!\209#\147\&1%\222\235\133Gd\174=\SIf\247\215\US^6\b\r", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\n-yh\SO\210\US\ESC\254\242a", +// _pubPktID = 15060, _pubBody = "\DEL\SOH0>\190\215\246)N\183\&0R\194\153\164\140'6\243X", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x38, 0x23, 0x0, 0xa, 0xba, 0x19, 0x47, 0x39, 0xc0, 0xe5, 0xf0, 0xcc, 0x12, - 0x6f, 0xa6, 0x21, 0xd1, 0x23, 0x93, 0x31, 0x25, 0xde, 0xeb, 0x85, 0x47, 0x64, - 0xae, 0x3d, 0xf, 0x66, 0xf7, 0xd7, 0x1f, 0x5e, 0x36, 0x8, 0xd}; + uint8_t pkt[] = {0x3b, 0x23, 0x0, 0xb, 0xa, 0x2d, 0x79, 0x68, 0xe, 0xd2, 0x1f, 0x1b, 0xfe, + 0xf2, 0x61, 0x3a, 0xd4, 0x7f, 0x1, 0x30, 0x3e, 0xbe, 0xd7, 0xf6, 0x29, 0x4e, + 0xb7, 0x30, 0x52, 0xc2, 0x99, 0xa4, 0x8c, 0x27, 0x36, 0xf3, 0x58}; uint8_t buf[47] = {0}; - uint8_t topic_bytes[] = {0xba, 0x19, 0x47, 0x39, 0xc0, 0xe5, 0xf0, 0xcc, 0x12, 0x6f}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa, 0x2d, 0x79, 0x68, 0xe, 0xd2, 0x1f, 0x1b, 0xfe, 0xf2, 0x61}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xa6, 0x21, 0xd1, 0x23, 0x93, 0x31, 0x25, 0xde, 0xeb, 0x85, 0x47, 0x64, - 0xae, 0x3d, 0xf, 0x66, 0xf7, 0xd7, 0x1f, 0x5e, 0x36, 0x8, 0xd}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x7f, 0x1, 0x30, 0x3e, 0xbe, 0xd7, 0xf6, 0x29, 0x4e, 0xb7, + 0x30, 0x52, 0xc2, 0x99, 0xa4, 0x8c, 0x27, 0x36, 0xf3, 0x58}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 20; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 15060, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\249\r\220\v\234\SOH\157\DC1_\145mx\199\189\136\241\241\184\225\ETX\132\GS\231\210\133\RS\r", _pubPktID = 32631, -// _pubBody = "\145\209\172\139\202&x\240\162\148\\U", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "5\132\234\246Z", _pubPktID = 0, +// _pubBody = "+", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x33, 0x2b, 0x0, 0x1b, 0xf9, 0xd, 0xdc, 0xb, 0xea, 0x1, 0x9d, 0x11, 0x5f, 0x91, 0x6d, - 0x78, 0xc7, 0xbd, 0x88, 0xf1, 0xf1, 0xb8, 0xe1, 0x3, 0x84, 0x1d, 0xe7, 0xd2, 0x85, 0x1e, - 0xd, 0x7f, 0x77, 0x91, 0xd1, 0xac, 0x8b, 0xca, 0x26, 0x78, 0xf0, 0xa2, 0x94, 0x5c, 0x55}; + uint8_t pkt[] = {0x31, 0x8, 0x0, 0x5, 0x35, 0x84, 0xea, 0xf6, 0x5a, 0x2b}; - uint8_t buf[55] = {0}; + uint8_t buf[20] = {0}; - uint8_t topic_bytes[] = {0xf9, 0xd, 0xdc, 0xb, 0xea, 0x1, 0x9d, 0x11, 0x5f, 0x91, 0x6d, 0x78, 0xc7, 0xbd, - 0x88, 0xf1, 0xf1, 0xb8, 0xe1, 0x3, 0x84, 0x1d, 0xe7, 0xd2, 0x85, 0x1e, 0xd}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x35, 0x84, 0xea, 0xf6, 0x5a}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x91, 0xd1, 0xac, 0x8b, 0xca, 0x26, 0x78, 0xf0, 0xa2, 0x94, 0x5c, 0x55}; + uint8_t msg_bytes[] = {0x2b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 1; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32631, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "b\213\SO\144\154E1Y", _pubPktID = -// 17459, _pubBody = "\197\176\151_P\DC4\162Y\176\178\tN}p\223\213\213\215\&9\208.dWr", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\212\222", _pubPktID = 0, _pubBody +// = "f", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x35, 0x24, 0x0, 0x8, 0x62, 0xd5, 0xe, 0x90, 0x9a, 0x45, 0x31, 0x59, 0x44, - 0x33, 0xc5, 0xb0, 0x97, 0x5f, 0x50, 0x14, 0xa2, 0x59, 0xb0, 0xb2, 0x9, 0x4e, - 0x7d, 0x70, 0xdf, 0xd5, 0xd5, 0xd7, 0x39, 0xd0, 0x2e, 0x64, 0x57, 0x72}; + uint8_t pkt[] = {0x30, 0x5, 0x0, 0x2, 0xd4, 0xde, 0x66}; - uint8_t buf[48] = {0}; + uint8_t buf[17] = {0}; - uint8_t topic_bytes[] = {0x62, 0xd5, 0xe, 0x90, 0x9a, 0x45, 0x31, 0x59}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xd4, 0xde}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xc5, 0xb0, 0x97, 0x5f, 0x50, 0x14, 0xa2, 0x59, 0xb0, 0xb2, 0x9, 0x4e, - 0x7d, 0x70, 0xdf, 0xd5, 0xd5, 0xd7, 0x39, 0xd0, 0x2e, 0x64, 0x57, 0x72}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x66}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 1; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17459, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\222\129", _pubPktID = 4136, -// _pubBody = "\238\173\129\190\233\254\157\252\185\239@\147\192rs\143\219-\185\140j5\231\226Y\SYN+", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "u\ESC\171:\189\192\SUB\242!\162\203\208Z\212\177\&5\248\255\138k\213\183+\SUB\132\GS#M\192", _pubPktID = 13057, +// _pubBody = "\168\129\191\243\158\250'%~\DEL0\ESC\210%qk\220\ENQ\241\199", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x35, 0x21, 0x0, 0x2, 0xde, 0x81, 0x10, 0x28, 0xee, 0xad, 0x81, 0xbe, - 0xe9, 0xfe, 0x9d, 0xfc, 0xb9, 0xef, 0x40, 0x93, 0xc0, 0x72, 0x73, 0x8f, - 0xdb, 0x2d, 0xb9, 0x8c, 0x6a, 0x35, 0xe7, 0xe2, 0x59, 0x16, 0x2b}; + uint8_t pkt[] = {0x3a, 0x35, 0x0, 0x1d, 0x75, 0x1b, 0xab, 0x3a, 0xbd, 0xc0, 0x1a, 0xf2, 0x21, 0xa2, + 0xcb, 0xd0, 0x5a, 0xd4, 0xb1, 0x35, 0xf8, 0xff, 0x8a, 0x6b, 0xd5, 0xb7, 0x2b, 0x1a, + 0x84, 0x1d, 0x23, 0x4d, 0xc0, 0x33, 0x1, 0xa8, 0x81, 0xbf, 0xf3, 0x9e, 0xfa, 0x27, + 0x25, 0x7e, 0x7f, 0x30, 0x1b, 0xd2, 0x25, 0x71, 0x6b, 0xdc, 0x5, 0xf1, 0xc7}; - uint8_t buf[45] = {0}; + uint8_t buf[65] = {0}; - uint8_t topic_bytes[] = {0xde, 0x81}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x75, 0x1b, 0xab, 0x3a, 0xbd, 0xc0, 0x1a, 0xf2, 0x21, 0xa2, 0xcb, 0xd0, 0x5a, 0xd4, 0xb1, + 0x35, 0xf8, 0xff, 0x8a, 0x6b, 0xd5, 0xb7, 0x2b, 0x1a, 0x84, 0x1d, 0x23, 0x4d, 0xc0}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xee, 0xad, 0x81, 0xbe, 0xe9, 0xfe, 0x9d, 0xfc, 0xb9, 0xef, 0x40, 0x93, 0xc0, 0x72, - 0x73, 0x8f, 0xdb, 0x2d, 0xb9, 0x8c, 0x6a, 0x35, 0xe7, 0xe2, 0x59, 0x16, 0x2b}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xa8, 0x81, 0xbf, 0xf3, 0x9e, 0xfa, 0x27, 0x25, 0x7e, 0x7f, + 0x30, 0x1b, 0xd2, 0x25, 0x71, 0x6b, 0xdc, 0x5, 0xf1, 0xc7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 20; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 4136, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13057, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "]Bpc\184\177\176\&3}-\DC4K", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\186l\242\SOH;D}W:\172\197", +// _pubPktID = 15309, _pubBody = "-\137a\203_YG\210\138\172yL\224>", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x30, 0xe, 0x0, 0x0, 0x5d, 0x42, 0x70, 0x63, 0xb8, 0xb1, 0xb0, 0x33, 0x7d, 0x2d, 0x14, 0x4b}; + uint8_t pkt[] = {0x3d, 0x1e, 0x0, 0xc, 0xfd, 0xba, 0x6c, 0xf2, 0x1, 0x3b, 0x44, 0x7d, 0x57, 0x3a, 0xac, 0xc5, + 0x3b, 0xcd, 0x2d, 0x89, 0x61, 0xcb, 0x5f, 0x59, 0x47, 0xd2, 0x8a, 0xac, 0x79, 0x4c, 0xe0, 0x3e}; - uint8_t buf[26] = {0}; + uint8_t buf[42] = {0}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xfd, 0xba, 0x6c, 0xf2, 0x1, 0x3b, 0x44, 0x7d, 0x57, 0x3a, 0xac, 0xc5}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x5d, 0x42, 0x70, 0x63, 0xb8, 0xb1, 0xb0, 0x33, 0x7d, 0x2d, 0x14, 0x4b}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x2d, 0x89, 0x61, 0xcb, 0x5f, 0x59, 0x47, 0xd2, 0x8a, 0xac, 0x79, 0x4c, 0xe0, 0x3e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 14; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 15309, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "/u\181\175\201\CANO", _pubPktID = 0, -// _pubBody = "\234\204\242\217\131\187\a+\140\DC4NsE\f\166\DC1\206pf\ETB\150\193\138\249\166r\189-S\EOT", _pubProps = -// []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "M\DC3\NAK:\DEL\206\213^_\254\174f\203\221\160U", _pubPktID = 0, _pubBody = "\211\130}", _pubProps = []} TEST(Publish311QCTest, Encode11) { - uint8_t pkt[] = {0x38, 0x27, 0x0, 0x7, 0x2f, 0x75, 0xb5, 0xaf, 0xc9, 0x18, 0x4f, 0xea, 0xcc, 0xf2, - 0xd9, 0x83, 0xbb, 0x7, 0x2b, 0x8c, 0x14, 0x4e, 0x73, 0x45, 0xc, 0xa6, 0x11, 0xce, - 0x70, 0x66, 0x17, 0x96, 0xc1, 0x8a, 0xf9, 0xa6, 0x72, 0xbd, 0x2d, 0x53, 0x4}; + uint8_t pkt[] = {0x30, 0x15, 0x0, 0x10, 0x4d, 0x13, 0x15, 0x3a, 0x7f, 0xce, 0xd5, 0x5e, + 0x5f, 0xfe, 0xae, 0x66, 0xcb, 0xdd, 0xa0, 0x55, 0xd3, 0x82, 0x7d}; - uint8_t buf[51] = {0}; + uint8_t buf[33] = {0}; - uint8_t topic_bytes[] = {0x2f, 0x75, 0xb5, 0xaf, 0xc9, 0x18, 0x4f}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x4d, 0x13, 0x15, 0x3a, 0x7f, 0xce, 0xd5, 0x5e, + 0x5f, 0xfe, 0xae, 0x66, 0xcb, 0xdd, 0xa0, 0x55}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xea, 0xcc, 0xf2, 0xd9, 0x83, 0xbb, 0x7, 0x2b, 0x8c, 0x14, 0x4e, 0x73, 0x45, 0xc, 0xa6, - 0x11, 0xce, 0x70, 0x66, 0x17, 0x96, 0xc1, 0x8a, 0xf9, 0xa6, 0x72, 0xbd, 0x2d, 0x53, 0x4}; + uint8_t msg_bytes[] = {0xd3, 0x82, 0x7d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 3; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "-\243H\202R\162w&\149\233\171\223", -// _pubPktID = 0, _pubBody = "\216\SO\135\ENQ\236\223\tG\203\177\ESC\132\135)\187", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\169|\146E2\GS{\237\&3\166", +// _pubPktID = 0, _pubBody = "#\227\217]\US\238S\163\139\232\165\210\243-", _pubProps = []} TEST(Publish311QCTest, Encode12) { - uint8_t pkt[] = {0x39, 0x1d, 0x0, 0xc, 0x2d, 0xf3, 0x48, 0xca, 0x52, 0xa2, 0x77, 0x26, 0x95, 0xe9, 0xab, 0xdf, - 0xd8, 0xe, 0x87, 0x5, 0xec, 0xdf, 0x9, 0x47, 0xcb, 0xb1, 0x1b, 0x84, 0x87, 0x29, 0xbb}; + uint8_t pkt[] = {0x31, 0x1a, 0x0, 0xa, 0xa9, 0x7c, 0x92, 0x45, 0x32, 0x1d, 0x7b, 0xed, 0x33, 0xa6, + 0x23, 0xe3, 0xd9, 0x5d, 0x1f, 0xee, 0x53, 0xa3, 0x8b, 0xe8, 0xa5, 0xd2, 0xf3, 0x2d}; - uint8_t buf[41] = {0}; + uint8_t buf[38] = {0}; - uint8_t topic_bytes[] = {0x2d, 0xf3, 0x48, 0xca, 0x52, 0xa2, 0x77, 0x26, 0x95, 0xe9, 0xab, 0xdf}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa9, 0x7c, 0x92, 0x45, 0x32, 0x1d, 0x7b, 0xed, 0x33, 0xa6}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xd8, 0xe, 0x87, 0x5, 0xec, 0xdf, 0x9, 0x47, 0xcb, 0xb1, 0x1b, 0x84, 0x87, 0x29, 0xbb}; + uint8_t msg_bytes[] = {0x23, 0xe3, 0xd9, 0x5d, 0x1f, 0xee, 0x53, 0xa3, 0x8b, 0xe8, 0xa5, 0xd2, 0xf3, 0x2d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 14; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "W\133\164\255\227+ -// \229\201\165[q\DC25\225\242\160 >\bi", _pubPktID = 0, _pubBody = "", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\187\253\202u\190\\@\215", _pubPktID +// = 27515, _pubBody = "\146q\173U}?\142kjA\ETX\187\155\EOT#K\207\&8x\224\244\133\241\t\146I\241", _pubProps = []} TEST(Publish311QCTest, Encode13) { - uint8_t pkt[] = {0x30, 0x17, 0x0, 0x15, 0x57, 0x85, 0xa4, 0xff, 0xe3, 0x2b, 0x20, 0xe5, 0xc9, - 0xa5, 0x5b, 0x71, 0x12, 0x35, 0xe1, 0xf2, 0xa0, 0x20, 0x3e, 0x8, 0x69}; + uint8_t pkt[] = {0x3c, 0x27, 0x0, 0x8, 0xbb, 0xfd, 0xca, 0x75, 0xbe, 0x5c, 0x40, 0xd7, 0x6b, 0x7b, + 0x92, 0x71, 0xad, 0x55, 0x7d, 0x3f, 0x8e, 0x6b, 0x6a, 0x41, 0x3, 0xbb, 0x9b, 0x4, + 0x23, 0x4b, 0xcf, 0x38, 0x78, 0xe0, 0xf4, 0x85, 0xf1, 0x9, 0x92, 0x49, 0xf1}; - uint8_t buf[35] = {0}; + uint8_t buf[51] = {0}; - uint8_t topic_bytes[] = {0x57, 0x85, 0xa4, 0xff, 0xe3, 0x2b, 0x20, 0xe5, 0xc9, 0xa5, 0x5b, - 0x71, 0x12, 0x35, 0xe1, 0xf2, 0xa0, 0x20, 0x3e, 0x8, 0x69}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xbb, 0xfd, 0xca, 0x75, 0xbe, 0x5c, 0x40, 0xd7}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0}; + uint8_t msg_bytes[] = {0x92, 0x71, 0xad, 0x55, 0x7d, 0x3f, 0x8e, 0x6b, 0x6a, 0x41, 0x3, 0xbb, 0x9b, 0x4, + 0x23, 0x4b, 0xcf, 0x38, 0x78, 0xe0, 0xf4, 0x85, 0xf1, 0x9, 0x92, 0x49, 0xf1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 27; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 27515, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "R\227\143", _pubPktID = 0, _pubBody -// = "\199\n\253\247[u\151,J\129\t\179\246y0]\143\131\146\&4n*\175\136\&6\181\148Z\ETX", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\163\147\204\140\129\152\150A\187\249", _pubPktID = 15054, _pubBody = "C\207+gu\184\240\&5~z\148f", _pubProps = []} TEST(Publish311QCTest, Encode14) { - uint8_t pkt[] = {0x38, 0x22, 0x0, 0x3, 0x52, 0xe3, 0x8f, 0xc7, 0xa, 0xfd, 0xf7, 0x5b, - 0x75, 0x97, 0x2c, 0x4a, 0x81, 0x9, 0xb3, 0xf6, 0x79, 0x30, 0x5d, 0x8f, - 0x83, 0x92, 0x34, 0x6e, 0x2a, 0xaf, 0x88, 0x36, 0xb5, 0x94, 0x5a, 0x3}; + uint8_t pkt[] = {0x3d, 0x1a, 0x0, 0xa, 0xa3, 0x93, 0xcc, 0x8c, 0x81, 0x98, 0x96, 0x41, 0xbb, 0xf9, + 0x3a, 0xce, 0x43, 0xcf, 0x2b, 0x67, 0x75, 0xb8, 0xf0, 0x35, 0x7e, 0x7a, 0x94, 0x66}; - uint8_t buf[46] = {0}; + uint8_t buf[38] = {0}; - uint8_t topic_bytes[] = {0x52, 0xe3, 0x8f}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa3, 0x93, 0xcc, 0x8c, 0x81, 0x98, 0x96, 0x41, 0xbb, 0xf9}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xc7, 0xa, 0xfd, 0xf7, 0x5b, 0x75, 0x97, 0x2c, 0x4a, 0x81, 0x9, 0xb3, 0xf6, 0x79, 0x30, - 0x5d, 0x8f, 0x83, 0x92, 0x34, 0x6e, 0x2a, 0xaf, 0x88, 0x36, 0xb5, 0x94, 0x5a, 0x3}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x43, 0xcf, 0x2b, 0x67, 0x75, 0xb8, 0xf0, 0x35, 0x7e, 0x7a, 0x94, 0x66}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 12; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 15054, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\DEL-\129\&3\194M2T6\ETBV5_#\188$\131T\222\ESC\137\a.\147%b", _pubPktID = 0, _pubBody = -// "\v]\154\169\138\225f:\202\251\DLEgw{\243\150\155\DELc8", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// ",\210m\249\173\143u\208k\181Kou]5\211\141\204M\133+$\153", _pubPktID = 0, _pubBody = "\154\157s\228", _pubProps = +// []} TEST(Publish311QCTest, Encode15) { - uint8_t pkt[] = {0x30, 0x30, 0x0, 0x1a, 0x7f, 0x2d, 0x81, 0x33, 0xc2, 0x4d, 0x32, 0x54, 0x36, 0x17, 0x56, 0x35, 0x5f, - 0x23, 0xbc, 0x24, 0x83, 0x54, 0xde, 0x1b, 0x89, 0x7, 0x2e, 0x93, 0x25, 0x62, 0xb, 0x5d, 0x9a, 0xa9, - 0x8a, 0xe1, 0x66, 0x3a, 0xca, 0xfb, 0x10, 0x67, 0x77, 0x7b, 0xf3, 0x96, 0x9b, 0x7f, 0x63, 0x38}; + uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x17, 0x2c, 0xd2, 0x6d, 0xf9, 0xad, 0x8f, 0x75, 0xd0, 0x6b, 0xb5, 0x4b, 0x6f, + 0x75, 0x5d, 0x35, 0xd3, 0x8d, 0xcc, 0x4d, 0x85, 0x2b, 0x24, 0x99, 0x9a, 0x9d, 0x73, 0xe4}; - uint8_t buf[60] = {0}; + uint8_t buf[41] = {0}; - uint8_t topic_bytes[] = {0x7f, 0x2d, 0x81, 0x33, 0xc2, 0x4d, 0x32, 0x54, 0x36, 0x17, 0x56, 0x35, 0x5f, - 0x23, 0xbc, 0x24, 0x83, 0x54, 0xde, 0x1b, 0x89, 0x7, 0x2e, 0x93, 0x25, 0x62}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x2c, 0xd2, 0x6d, 0xf9, 0xad, 0x8f, 0x75, 0xd0, 0x6b, 0xb5, 0x4b, 0x6f, + 0x75, 0x5d, 0x35, 0xd3, 0x8d, 0xcc, 0x4d, 0x85, 0x2b, 0x24, 0x99}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xb, 0x5d, 0x9a, 0xa9, 0x8a, 0xe1, 0x66, 0x3a, 0xca, 0xfb, - 0x10, 0x67, 0x77, 0x7b, 0xf3, 0x96, 0x9b, 0x7f, 0x63, 0x38}; + uint8_t msg_bytes[] = {0x9a, 0x9d, 0x73, 0xe4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 4; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\250\181\213\174\156\146\244\243\180\160\170=", _pubPktID = 24114, _pubBody = -// "\GS-\202|\237\STX\ENQ\EM\159\143\130\NAK\242\212\182Cg\172#\193\150v\226", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\NUL\DEL\203\RS\240:\141&\173E\160ge\161\253\204@\CANsE\DC4\250-\170\139\170\173", _pubPktID = 16148, _pubBody = +// "\217\SOH\255\&9\132\DC1ce\133\DLE\176\244\r\ti\207a\239X\210\160\160\224v\216\t", _pubProps = []} TEST(Publish311QCTest, Encode16) { - uint8_t pkt[] = {0x34, 0x27, 0x0, 0xc, 0xfa, 0xb5, 0xd5, 0xae, 0x9c, 0x92, 0xf4, 0xf3, 0xb4, 0xa0, - 0xaa, 0x3d, 0x5e, 0x32, 0x1d, 0x2d, 0xca, 0x7c, 0xed, 0x2, 0x5, 0x19, 0x9f, 0x8f, - 0x82, 0x15, 0xf2, 0xd4, 0xb6, 0x43, 0x67, 0xac, 0x23, 0xc1, 0x96, 0x76, 0xe2}; + uint8_t pkt[] = {0x3a, 0x39, 0x0, 0x1b, 0x0, 0x7f, 0xcb, 0x1e, 0xf0, 0x3a, 0x8d, 0x26, 0xad, 0x45, 0xa0, + 0x67, 0x65, 0xa1, 0xfd, 0xcc, 0x40, 0x18, 0x73, 0x45, 0x14, 0xfa, 0x2d, 0xaa, 0x8b, 0xaa, + 0xad, 0x3f, 0x14, 0xd9, 0x1, 0xff, 0x39, 0x84, 0x11, 0x63, 0x65, 0x85, 0x10, 0xb0, 0xf4, + 0xd, 0x9, 0x69, 0xcf, 0x61, 0xef, 0x58, 0xd2, 0xa0, 0xa0, 0xe0, 0x76, 0xd8, 0x9}; - uint8_t buf[51] = {0}; + uint8_t buf[69] = {0}; - uint8_t topic_bytes[] = {0xfa, 0xb5, 0xd5, 0xae, 0x9c, 0x92, 0xf4, 0xf3, 0xb4, 0xa0, 0xaa, 0x3d}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x0, 0x7f, 0xcb, 0x1e, 0xf0, 0x3a, 0x8d, 0x26, 0xad, 0x45, 0xa0, 0x67, 0x65, 0xa1, + 0xfd, 0xcc, 0x40, 0x18, 0x73, 0x45, 0x14, 0xfa, 0x2d, 0xaa, 0x8b, 0xaa, 0xad}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x1d, 0x2d, 0xca, 0x7c, 0xed, 0x2, 0x5, 0x19, 0x9f, 0x8f, 0x82, 0x15, - 0xf2, 0xd4, 0xb6, 0x43, 0x67, 0xac, 0x23, 0xc1, 0x96, 0x76, 0xe2}; + uint8_t msg_bytes[] = {0xd9, 0x1, 0xff, 0x39, 0x84, 0x11, 0x63, 0x65, 0x85, 0x10, 0xb0, 0xf4, 0xd, + 0x9, 0x69, 0xcf, 0x61, 0xef, 0x58, 0xd2, 0xa0, 0xa0, 0xe0, 0x76, 0xd8, 0x9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 26; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24114, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16148, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "K\128\243a\178\253\219\184\171;*\244\172'5\EMTE\CAN", _pubPktID = 30980, _pubBody = "c\SUB\219{", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\225\180\242F\ENQ\203\138\241\216i%\241\223n\157\150\bT\255", _pubPktID = 0, _pubBody = "'", _pubProps = []} TEST(Publish311QCTest, Encode17) { - uint8_t pkt[] = {0x3b, 0x1b, 0x0, 0x13, 0x4b, 0x80, 0xf3, 0x61, 0xb2, 0xfd, 0xdb, 0xb8, 0xab, 0x3b, 0x2a, - 0xf4, 0xac, 0x27, 0x35, 0x19, 0x54, 0x45, 0x18, 0x79, 0x4, 0x63, 0x1a, 0xdb, 0x7b}; + uint8_t pkt[] = {0x30, 0x16, 0x0, 0x13, 0xe1, 0xb4, 0xf2, 0x46, 0x5, 0xcb, 0x8a, 0xf1, + 0xd8, 0x69, 0x25, 0xf1, 0xdf, 0x6e, 0x9d, 0x96, 0x8, 0x54, 0xff, 0x27}; - uint8_t buf[39] = {0}; + uint8_t buf[34] = {0}; - uint8_t topic_bytes[] = {0x4b, 0x80, 0xf3, 0x61, 0xb2, 0xfd, 0xdb, 0xb8, 0xab, 0x3b, - 0x2a, 0xf4, 0xac, 0x27, 0x35, 0x19, 0x54, 0x45, 0x18}; + uint8_t topic_bytes[] = {0xe1, 0xb4, 0xf2, 0x46, 0x5, 0xcb, 0x8a, 0xf1, 0xd8, 0x69, + 0x25, 0xf1, 0xdf, 0x6e, 0x9d, 0x96, 0x8, 0x54, 0xff}; lwmqtt_string_t topic = {19, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x63, 0x1a, 0xdb, 0x7b}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x27}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 1; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30980, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "q\133\153L\176\219b\169Cy", _pubPktID -// = 0, _pubBody = "R\253\227\&8\219\234\CANi\174R\250\248\234\146G]X\252\NAK\167/\195\SUB:\GS\182-", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\206\166\&9}z\170\226\207\169\157\f{\160_\198\DEL\151\NAK'|\145", _pubPktID = 0, _pubBody = "\178\190\186$\148^\SO +// Y\222\245\255\204\180\166\231cl\175A\164x\152\234W\209\251\249\n`", _pubProps = []} TEST(Publish311QCTest, Encode18) { - uint8_t pkt[] = {0x39, 0x27, 0x0, 0xa, 0x71, 0x85, 0x99, 0x4c, 0xb0, 0xdb, 0x62, 0xa9, 0x43, 0x79, - 0x52, 0xfd, 0xe3, 0x38, 0xdb, 0xea, 0x18, 0x69, 0xae, 0x52, 0xfa, 0xf8, 0xea, 0x92, - 0x47, 0x5d, 0x58, 0xfc, 0x15, 0xa7, 0x2f, 0xc3, 0x1a, 0x3a, 0x1d, 0xb6, 0x2d}; + uint8_t pkt[] = {0x31, 0x35, 0x0, 0x15, 0xce, 0xa6, 0x39, 0x7d, 0x7a, 0xaa, 0xe2, 0xcf, 0xa9, 0x9d, + 0xc, 0x7b, 0xa0, 0x5f, 0xc6, 0x7f, 0x97, 0x15, 0x27, 0x7c, 0x91, 0xb2, 0xbe, 0xba, + 0x24, 0x94, 0x5e, 0xe, 0x20, 0x59, 0xde, 0xf5, 0xff, 0xcc, 0xb4, 0xa6, 0xe7, 0x63, + 0x6c, 0xaf, 0x41, 0xa4, 0x78, 0x98, 0xea, 0x57, 0xd1, 0xfb, 0xf9, 0xa, 0x60}; - uint8_t buf[51] = {0}; + uint8_t buf[65] = {0}; - uint8_t topic_bytes[] = {0x71, 0x85, 0x99, 0x4c, 0xb0, 0xdb, 0x62, 0xa9, 0x43, 0x79}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xce, 0xa6, 0x39, 0x7d, 0x7a, 0xaa, 0xe2, 0xcf, 0xa9, 0x9d, 0xc, + 0x7b, 0xa0, 0x5f, 0xc6, 0x7f, 0x97, 0x15, 0x27, 0x7c, 0x91}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x52, 0xfd, 0xe3, 0x38, 0xdb, 0xea, 0x18, 0x69, 0xae, 0x52, 0xfa, 0xf8, 0xea, 0x92, - 0x47, 0x5d, 0x58, 0xfc, 0x15, 0xa7, 0x2f, 0xc3, 0x1a, 0x3a, 0x1d, 0xb6, 0x2d}; + uint8_t msg_bytes[] = {0xb2, 0xbe, 0xba, 0x24, 0x94, 0x5e, 0xe, 0x20, 0x59, 0xde, 0xf5, 0xff, 0xcc, 0xb4, 0xa6, + 0xe7, 0x63, 0x6c, 0xaf, 0x41, 0xa4, 0x78, 0x98, 0xea, 0x57, 0xd1, 0xfb, 0xf9, 0xa, 0x60}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 30; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\DC2]^:\232\227~//\232\188z\183\183\&6\248\242", _pubPktID = 31614, _pubBody = -// "g\207\142Q\206\&8\FS#f]\154[\195\180\140FW\182\130\168\&6\191\251\b\214\&0\141", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\225\242\168", _pubPktID = 30037, +// _pubBody = "\216-7\221q<\RS\"U\210-\130\232\161\248)\248\169\151", _pubProps = []} TEST(Publish311QCTest, Encode19) { - uint8_t pkt[] = {0x3d, 0x30, 0x0, 0x11, 0x12, 0x5d, 0x5e, 0x3a, 0xe8, 0xe3, 0x7e, 0x2f, 0x2f, 0xe8, 0xbc, 0x7a, 0xb7, - 0xb7, 0x36, 0xf8, 0xf2, 0x7b, 0x7e, 0x67, 0xcf, 0x8e, 0x51, 0xce, 0x38, 0x1c, 0x23, 0x66, 0x5d, 0x9a, - 0x5b, 0xc3, 0xb4, 0x8c, 0x46, 0x57, 0xb6, 0x82, 0xa8, 0x36, 0xbf, 0xfb, 0x8, 0xd6, 0x30, 0x8d}; + uint8_t pkt[] = {0x3a, 0x1a, 0x0, 0x3, 0xe1, 0xf2, 0xa8, 0x75, 0x55, 0xd8, 0x2d, 0x37, 0xdd, 0x71, + 0x3c, 0x1e, 0x22, 0x55, 0xd2, 0x2d, 0x82, 0xe8, 0xa1, 0xf8, 0x29, 0xf8, 0xa9, 0x97}; - uint8_t buf[60] = {0}; + uint8_t buf[38] = {0}; - uint8_t topic_bytes[] = {0x12, 0x5d, 0x5e, 0x3a, 0xe8, 0xe3, 0x7e, 0x2f, 0x2f, - 0xe8, 0xbc, 0x7a, 0xb7, 0xb7, 0x36, 0xf8, 0xf2}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xe1, 0xf2, 0xa8}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x67, 0xcf, 0x8e, 0x51, 0xce, 0x38, 0x1c, 0x23, 0x66, 0x5d, 0x9a, 0x5b, 0xc3, 0xb4, - 0x8c, 0x46, 0x57, 0xb6, 0x82, 0xa8, 0x36, 0xbf, 0xfb, 0x8, 0xd6, 0x30, 0x8d}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xd8, 0x2d, 0x37, 0xdd, 0x71, 0x3c, 0x1e, 0x22, 0x55, 0xd2, + 0x2d, 0x82, 0xe8, 0xa1, 0xf8, 0x29, 0xf8, 0xa9, 0x97}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 19; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 31614, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30037, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "y[U\202v\201A\203\136\164\190[\aZ\201\199", _pubPktID = 0, _pubBody = "`\132\CAN\206_pD[R", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\209\144\244\190\138\251", _pubPktID +// = 1548, _pubBody = "", _pubProps = []} TEST(Publish311QCTest, Encode20) { - uint8_t pkt[] = {0x31, 0x1b, 0x0, 0x10, 0x79, 0x5b, 0x55, 0xca, 0x76, 0xc9, 0x41, 0xcb, 0x88, 0xa4, 0xbe, - 0x5b, 0x7, 0x5a, 0xc9, 0xc7, 0x60, 0x84, 0x18, 0xce, 0x5f, 0x70, 0x44, 0x5b, 0x52}; + uint8_t pkt[] = {0x3c, 0xa, 0x0, 0x6, 0xd1, 0x90, 0xf4, 0xbe, 0x8a, 0xfb, 0x6, 0xc}; - uint8_t buf[39] = {0}; + uint8_t buf[22] = {0}; - uint8_t topic_bytes[] = {0x79, 0x5b, 0x55, 0xca, 0x76, 0xc9, 0x41, 0xcb, - 0x88, 0xa4, 0xbe, 0x5b, 0x7, 0x5a, 0xc9, 0xc7}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xd1, 0x90, 0xf4, 0xbe, 0x8a, 0xfb}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x60, 0x84, 0x18, 0xce, 0x5f, 0x70, 0x44, 0x5b, 0x52}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 0; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1548, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "]\198\"\SUB3J\207\rX", _pubPktID = -// 0, _pubBody = "\132\170$!\216\174\202%\vC\188\240\ETB'b\DC1\134", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\136\140\179}\STX;", _pubPktID = +// 6476, _pubBody = "Jj\SO\241\ENQ\137\DC1", _pubProps = []} TEST(Publish311QCTest, Encode21) { - uint8_t pkt[] = {0x30, 0x1c, 0x0, 0x9, 0x5d, 0xc6, 0x22, 0x1a, 0x33, 0x4a, 0xcf, 0xd, 0x58, 0x84, 0xaa, - 0x24, 0x21, 0xd8, 0xae, 0xca, 0x25, 0xb, 0x43, 0xbc, 0xf0, 0x17, 0x27, 0x62, 0x11, 0x86}; + uint8_t pkt[] = {0x35, 0x12, 0x0, 0x7, 0xfd, 0x88, 0x8c, 0xb3, 0x7d, 0x2, + 0x3b, 0x19, 0x4c, 0x4a, 0x6a, 0xe, 0xf1, 0x5, 0x89, 0x11}; - uint8_t buf[40] = {0}; + uint8_t buf[30] = {0}; - uint8_t topic_bytes[] = {0x5d, 0xc6, 0x22, 0x1a, 0x33, 0x4a, 0xcf, 0xd, 0x58}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xfd, 0x88, 0x8c, 0xb3, 0x7d, 0x2, 0x3b}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x84, 0xaa, 0x24, 0x21, 0xd8, 0xae, 0xca, 0x25, 0xb, - 0x43, 0xbc, 0xf0, 0x17, 0x27, 0x62, 0x11, 0x86}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x4a, 0x6a, 0xe, 0xf1, 0x5, 0x89, 0x11}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 7; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 6476, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O&", _pubPktID = 13252, _pubBody = -// "\169\202l\203dz\202-l\161\226\155\212J@v\179", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\242\232\197\SOHHe\ETX>/ +// \232\220\247\251\tq\198\197nl\247\249", _pubPktID = 2029, _pubBody = "v_\GSO8\202C0\RS\247#\141\209\DEL", _pubProps = +// []} TEST(Publish311QCTest, Encode22) { - uint8_t pkt[] = {0x35, 0x17, 0x0, 0x2, 0x4f, 0x26, 0x33, 0xc4, 0xa9, 0xca, 0x6c, 0xcb, 0x64, - 0x7a, 0xca, 0x2d, 0x6c, 0xa1, 0xe2, 0x9b, 0xd4, 0x4a, 0x40, 0x76, 0xb3}; + uint8_t pkt[] = {0x3a, 0x28, 0x0, 0x16, 0xf2, 0xe8, 0xc5, 0x1, 0x48, 0x65, 0x3, 0x3e, 0x2f, 0x20, + 0xe8, 0xdc, 0xf7, 0xfb, 0x9, 0x71, 0xc6, 0xc5, 0x6e, 0x6c, 0xf7, 0xf9, 0x7, 0xed, + 0x76, 0x5f, 0x1d, 0x4f, 0x38, 0xca, 0x43, 0x30, 0x1e, 0xf7, 0x23, 0x8d, 0xd1, 0x7f}; - uint8_t buf[35] = {0}; + uint8_t buf[52] = {0}; - uint8_t topic_bytes[] = {0x4f, 0x26}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xf2, 0xe8, 0xc5, 0x1, 0x48, 0x65, 0x3, 0x3e, 0x2f, 0x20, 0xe8, + 0xdc, 0xf7, 0xfb, 0x9, 0x71, 0xc6, 0xc5, 0x6e, 0x6c, 0xf7, 0xf9}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa9, 0xca, 0x6c, 0xcb, 0x64, 0x7a, 0xca, 0x2d, 0x6c, - 0xa1, 0xe2, 0x9b, 0xd4, 0x4a, 0x40, 0x76, 0xb3}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x76, 0x5f, 0x1d, 0x4f, 0x38, 0xca, 0x43, 0x30, 0x1e, 0xf7, 0x23, 0x8d, 0xd1, 0x7f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 14; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 13252, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2029, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\v\164J\248\ACKw\168\152\154\236q\RS\ESC\fX\129\180K\FS", _pubPktID = 14693, _pubBody = -// "3MM\195\166\SIw\199E\250\155\253\164\239\US\195\168\222\171\244\206\&7/\SO ?\231\SIK", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "Y\NUL&\156\t\157<\215\152R\173\212.\245\207\197\188\163\208\&2", _pubPktID = 5733, _pubBody = +// "\SOHe\184~\148\245\199\143\205\235\200U", _pubProps = []} TEST(Publish311QCTest, Encode23) { - uint8_t pkt[] = {0x3b, 0x34, 0x0, 0x13, 0xb, 0xa4, 0x4a, 0xf8, 0x6, 0x77, 0xa8, 0x98, 0x9a, 0xec, - 0x71, 0x1e, 0x1b, 0xc, 0x58, 0x81, 0xb4, 0x4b, 0x1c, 0x39, 0x65, 0x33, 0x4d, 0x4d, - 0xc3, 0xa6, 0xf, 0x77, 0xc7, 0x45, 0xfa, 0x9b, 0xfd, 0xa4, 0xef, 0x1f, 0xc3, 0xa8, - 0xde, 0xab, 0xf4, 0xce, 0x37, 0x2f, 0xe, 0x20, 0x3f, 0xe7, 0xf, 0x4b}; + uint8_t pkt[] = {0x3d, 0x24, 0x0, 0x14, 0x59, 0x0, 0x26, 0x9c, 0x9, 0x9d, 0x3c, 0xd7, 0x98, + 0x52, 0xad, 0xd4, 0x2e, 0xf5, 0xcf, 0xc5, 0xbc, 0xa3, 0xd0, 0x32, 0x16, 0x65, + 0x1, 0x65, 0xb8, 0x7e, 0x94, 0xf5, 0xc7, 0x8f, 0xcd, 0xeb, 0xc8, 0x55}; - uint8_t buf[64] = {0}; + uint8_t buf[48] = {0}; - uint8_t topic_bytes[] = {0xb, 0xa4, 0x4a, 0xf8, 0x6, 0x77, 0xa8, 0x98, 0x9a, 0xec, - 0x71, 0x1e, 0x1b, 0xc, 0x58, 0x81, 0xb4, 0x4b, 0x1c}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x59, 0x0, 0x26, 0x9c, 0x9, 0x9d, 0x3c, 0xd7, 0x98, 0x52, + 0xad, 0xd4, 0x2e, 0xf5, 0xcf, 0xc5, 0xbc, 0xa3, 0xd0, 0x32}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x33, 0x4d, 0x4d, 0xc3, 0xa6, 0xf, 0x77, 0xc7, 0x45, 0xfa, 0x9b, 0xfd, 0xa4, 0xef, 0x1f, - 0xc3, 0xa8, 0xde, 0xab, 0xf4, 0xce, 0x37, 0x2f, 0xe, 0x20, 0x3f, 0xe7, 0xf, 0x4b}; + uint8_t msg_bytes[] = {0x1, 0x65, 0xb8, 0x7e, 0x94, 0xf5, 0xc7, 0x8f, 0xcd, 0xeb, 0xc8, 0x55}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 12; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 14693, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5733, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\220\170\237\142", _pubPktID = 6499, -// _pubBody = "l\EOT h\135\217\143\178&\ETB$1\239@\177~BO}3V\"\176\SOH\255", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\224\201\GS?\232\255!\161\220\244B\129\&6\US\205R_8\191\154\217\186?\231\245\224\170", _pubPktID = 14690, _pubBody = +// "\196\183%\243\214\152\&5U;\186\194\206\128[\236B~\144\236\247\187\144Ze\ETX\176", _pubProps = []} TEST(Publish311QCTest, Encode24) { - uint8_t pkt[] = {0x3a, 0x21, 0x0, 0x4, 0xdc, 0xaa, 0xed, 0x8e, 0x19, 0x63, 0x6c, 0x4, - 0x20, 0x68, 0x87, 0xd9, 0x8f, 0xb2, 0x26, 0x17, 0x24, 0x31, 0xef, 0x40, - 0xb1, 0x7e, 0x42, 0x4f, 0x7d, 0x33, 0x56, 0x22, 0xb0, 0x1, 0xff}; + uint8_t pkt[] = {0x35, 0x39, 0x0, 0x1b, 0xe0, 0xc9, 0x1d, 0x3f, 0xe8, 0xff, 0x21, 0xa1, 0xdc, 0xf4, 0x42, + 0x81, 0x36, 0x1f, 0xcd, 0x52, 0x5f, 0x38, 0xbf, 0x9a, 0xd9, 0xba, 0x3f, 0xe7, 0xf5, 0xe0, + 0xaa, 0x39, 0x62, 0xc4, 0xb7, 0x25, 0xf3, 0xd6, 0x98, 0x35, 0x55, 0x3b, 0xba, 0xc2, 0xce, + 0x80, 0x5b, 0xec, 0x42, 0x7e, 0x90, 0xec, 0xf7, 0xbb, 0x90, 0x5a, 0x65, 0x3, 0xb0}; - uint8_t buf[45] = {0}; + uint8_t buf[69] = {0}; - uint8_t topic_bytes[] = {0xdc, 0xaa, 0xed, 0x8e}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xe0, 0xc9, 0x1d, 0x3f, 0xe8, 0xff, 0x21, 0xa1, 0xdc, 0xf4, 0x42, 0x81, 0x36, 0x1f, + 0xcd, 0x52, 0x5f, 0x38, 0xbf, 0x9a, 0xd9, 0xba, 0x3f, 0xe7, 0xf5, 0xe0, 0xaa}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x6c, 0x4, 0x20, 0x68, 0x87, 0xd9, 0x8f, 0xb2, 0x26, 0x17, 0x24, 0x31, 0xef, - 0x40, 0xb1, 0x7e, 0x42, 0x4f, 0x7d, 0x33, 0x56, 0x22, 0xb0, 0x1, 0xff}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xc4, 0xb7, 0x25, 0xf3, 0xd6, 0x98, 0x35, 0x55, 0x3b, 0xba, 0xc2, 0xce, 0x80, + 0x5b, 0xec, 0x42, 0x7e, 0x90, 0xec, 0xf7, 0xbb, 0x90, 0x5a, 0x65, 0x3, 0xb0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 26; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6499, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 14690, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\245Y\170\235\232x1\238Y\148", -// _pubPktID = 0, _pubBody = "\139\217\168\150q\SYN\144\176\SO\NAK\147\237", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\128\EOT^\158\STX\"\210\232\166U\219\154N\225\218\228\153Z\152\250\224\246\211;E\155", _pubPktID = 16370, _pubBody = +// "V", _pubProps = []} TEST(Publish311QCTest, Encode25) { - uint8_t pkt[] = {0x38, 0x18, 0x0, 0xa, 0xf5, 0x59, 0xaa, 0xeb, 0xe8, 0x78, 0x31, 0xee, 0x59, - 0x94, 0x8b, 0xd9, 0xa8, 0x96, 0x71, 0x16, 0x90, 0xb0, 0xe, 0x15, 0x93, 0xed}; + uint8_t pkt[] = {0x3b, 0x1f, 0x0, 0x1a, 0x80, 0x4, 0x5e, 0x9e, 0x2, 0x22, 0xd2, 0xe8, 0xa6, 0x55, 0xdb, 0x9a, 0x4e, + 0xe1, 0xda, 0xe4, 0x99, 0x5a, 0x98, 0xfa, 0xe0, 0xf6, 0xd3, 0x3b, 0x45, 0x9b, 0x3f, 0xf2, 0x56}; - uint8_t buf[36] = {0}; + uint8_t buf[43] = {0}; - uint8_t topic_bytes[] = {0xf5, 0x59, 0xaa, 0xeb, 0xe8, 0x78, 0x31, 0xee, 0x59, 0x94}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x80, 0x4, 0x5e, 0x9e, 0x2, 0x22, 0xd2, 0xe8, 0xa6, 0x55, 0xdb, 0x9a, 0x4e, + 0xe1, 0xda, 0xe4, 0x99, 0x5a, 0x98, 0xfa, 0xe0, 0xf6, 0xd3, 0x3b, 0x45, 0x9b}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x8b, 0xd9, 0xa8, 0x96, 0x71, 0x16, 0x90, 0xb0, 0xe, 0x15, 0x93, 0xed}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x56}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 1; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16370, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\DC4\225[\128A\SUB\229p\254\164'\187\153F\223\219\&3\FS\US~\247\227\SYN(B\177\172", _pubPktID = 927, _pubBody = -// "b\DELS\153v\176m?\201\248\140\EOTe\174\196\EM\253\FS", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "c\215A4\142\182\&2\162\191V\143t$A0\142", _pubPktID = 0, _pubBody = "\221\195:\163\203\239\168%\160", _pubProps = +// []} TEST(Publish311QCTest, Encode26) { - uint8_t pkt[] = {0x34, 0x31, 0x0, 0x1b, 0x14, 0xe1, 0x5b, 0x80, 0x41, 0x1a, 0xe5, 0x70, 0xfe, - 0xa4, 0x27, 0xbb, 0x99, 0x46, 0xdf, 0xdb, 0x33, 0x1c, 0x1f, 0x7e, 0xf7, 0xe3, - 0x16, 0x28, 0x42, 0xb1, 0xac, 0x3, 0x9f, 0x62, 0x7f, 0x53, 0x99, 0x76, 0xb0, - 0x6d, 0x3f, 0xc9, 0xf8, 0x8c, 0x4, 0x65, 0xae, 0xc4, 0x19, 0xfd, 0x1c}; + uint8_t pkt[] = {0x31, 0x1b, 0x0, 0x10, 0x63, 0xd7, 0x41, 0x34, 0x8e, 0xb6, 0x32, 0xa2, 0xbf, 0x56, 0x8f, + 0x74, 0x24, 0x41, 0x30, 0x8e, 0xdd, 0xc3, 0x3a, 0xa3, 0xcb, 0xef, 0xa8, 0x25, 0xa0}; - uint8_t buf[61] = {0}; + uint8_t buf[39] = {0}; - uint8_t topic_bytes[] = {0x14, 0xe1, 0x5b, 0x80, 0x41, 0x1a, 0xe5, 0x70, 0xfe, 0xa4, 0x27, 0xbb, 0x99, 0x46, - 0xdf, 0xdb, 0x33, 0x1c, 0x1f, 0x7e, 0xf7, 0xe3, 0x16, 0x28, 0x42, 0xb1, 0xac}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x63, 0xd7, 0x41, 0x34, 0x8e, 0xb6, 0x32, 0xa2, + 0xbf, 0x56, 0x8f, 0x74, 0x24, 0x41, 0x30, 0x8e}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x62, 0x7f, 0x53, 0x99, 0x76, 0xb0, 0x6d, 0x3f, 0xc9, - 0xf8, 0x8c, 0x4, 0x65, 0xae, 0xc4, 0x19, 0xfd, 0x1c}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xdd, 0xc3, 0x3a, 0xa3, 0xcb, 0xef, 0xa8, 0x25, 0xa0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 9; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 927, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\132\158\245\v\236\159\129\175\159j(", _pubPktID = 19519, _pubBody = -// "\222Ut\223\169\215\ACK\238\228\137\147Z\EM\196", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\161\166\175\235\223\210\143\180\219\210\209\129\230\195\173\&1\t\ENQy\206\250\146\214\205\161\212{?\157", _pubPktID +// = 0, _pubBody = "\206W9\140\ESC6\211\206\212d\US\141\189`a9\182\130,\ETX", _pubProps = []} TEST(Publish311QCTest, Encode27) { - uint8_t pkt[] = {0x33, 0x1d, 0x0, 0xb, 0x84, 0x9e, 0xf5, 0xb, 0xec, 0x9f, 0x81, 0xaf, 0x9f, 0x6a, 0x28, 0x4c, - 0x3f, 0xde, 0x55, 0x74, 0xdf, 0xa9, 0xd7, 0x6, 0xee, 0xe4, 0x89, 0x93, 0x5a, 0x19, 0xc4}; + uint8_t pkt[] = {0x30, 0x33, 0x0, 0x1d, 0xa1, 0xa6, 0xaf, 0xeb, 0xdf, 0xd2, 0x8f, 0xb4, 0xdb, 0xd2, + 0xd1, 0x81, 0xe6, 0xc3, 0xad, 0x31, 0x9, 0x5, 0x79, 0xce, 0xfa, 0x92, 0xd6, 0xcd, + 0xa1, 0xd4, 0x7b, 0x3f, 0x9d, 0xce, 0x57, 0x39, 0x8c, 0x1b, 0x36, 0xd3, 0xce, 0xd4, + 0x64, 0x1f, 0x8d, 0xbd, 0x60, 0x61, 0x39, 0xb6, 0x82, 0x2c, 0x3}; - uint8_t buf[41] = {0}; + uint8_t buf[63] = {0}; - uint8_t topic_bytes[] = {0x84, 0x9e, 0xf5, 0xb, 0xec, 0x9f, 0x81, 0xaf, 0x9f, 0x6a, 0x28}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa1, 0xa6, 0xaf, 0xeb, 0xdf, 0xd2, 0x8f, 0xb4, 0xdb, 0xd2, 0xd1, 0x81, 0xe6, 0xc3, 0xad, + 0x31, 0x9, 0x5, 0x79, 0xce, 0xfa, 0x92, 0xd6, 0xcd, 0xa1, 0xd4, 0x7b, 0x3f, 0x9d}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xde, 0x55, 0x74, 0xdf, 0xa9, 0xd7, 0x6, 0xee, 0xe4, 0x89, 0x93, 0x5a, 0x19, 0xc4}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xce, 0x57, 0x39, 0x8c, 0x1b, 0x36, 0xd3, 0xce, 0xd4, 0x64, + 0x1f, 0x8d, 0xbd, 0x60, 0x61, 0x39, 0xb6, 0x82, 0x2c, 0x3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 20; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19519, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "-\187#\178\187\239\RS\172\ETX\144=\172\185\192\232Q\197:A\171^\SUB\135)", _pubPktID = 18146, _pubBody = "\228\167", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "{\196\184\STXD\DC3\206\DC2E\138\172a\226\203\SYN\241E)", _pubPktID = 6876, _pubBody = +// "\152k\DEL:{\247\144\fs\215\252\234\162HI", _pubProps = []} TEST(Publish311QCTest, Encode28) { - uint8_t pkt[] = {0x32, 0x1e, 0x0, 0x18, 0x2d, 0xbb, 0x23, 0xb2, 0xbb, 0xef, 0x1e, 0xac, 0x3, 0x90, 0x3d, 0xac, - 0xb9, 0xc0, 0xe8, 0x51, 0xc5, 0x3a, 0x41, 0xab, 0x5e, 0x1a, 0x87, 0x29, 0x46, 0xe2, 0xe4, 0xa7}; + uint8_t pkt[] = {0x3c, 0x25, 0x0, 0x12, 0x7b, 0xc4, 0xb8, 0x2, 0x44, 0x13, 0xce, 0x12, 0x45, + 0x8a, 0xac, 0x61, 0xe2, 0xcb, 0x16, 0xf1, 0x45, 0x29, 0x1a, 0xdc, 0x98, 0x6b, + 0x7f, 0x3a, 0x7b, 0xf7, 0x90, 0xc, 0x73, 0xd7, 0xfc, 0xea, 0xa2, 0x48, 0x49}; - uint8_t buf[42] = {0}; + uint8_t buf[49] = {0}; - uint8_t topic_bytes[] = {0x2d, 0xbb, 0x23, 0xb2, 0xbb, 0xef, 0x1e, 0xac, 0x3, 0x90, 0x3d, 0xac, - 0xb9, 0xc0, 0xe8, 0x51, 0xc5, 0x3a, 0x41, 0xab, 0x5e, 0x1a, 0x87, 0x29}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x7b, 0xc4, 0xb8, 0x2, 0x44, 0x13, 0xce, 0x12, 0x45, + 0x8a, 0xac, 0x61, 0xe2, 0xcb, 0x16, 0xf1, 0x45, 0x29}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xe4, 0xa7}; + uint8_t msg_bytes[] = {0x98, 0x6b, 0x7f, 0x3a, 0x7b, 0xf7, 0x90, 0xc, 0x73, 0xd7, 0xfc, 0xea, 0xa2, 0x48, 0x49}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 15; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 18146, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6876, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "]\210f\CAN\144\189+\ETB\v~\235)\166\227\158\211\&9\SOHj\191\242\212T<", _pubPktID = 16544, _pubBody = -// "\210XDU\144\201\&4 \226VBDBmf\138\212\f\195\232", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\STXa7W", _pubPktID = 0, _pubBody = +// "\169#\136\219\142\&7\196\149\&4d\246j\146\254\188ch\168$T\135Q*\170\138\DC3!", _pubProps = []} TEST(Publish311QCTest, Encode29) { - uint8_t pkt[] = {0x3a, 0x30, 0x0, 0x18, 0x5d, 0xd2, 0x66, 0x18, 0x90, 0xbd, 0x2b, 0x17, 0xb, 0x7e, 0xeb, 0x29, 0xa6, - 0xe3, 0x9e, 0xd3, 0x39, 0x1, 0x6a, 0xbf, 0xf2, 0xd4, 0x54, 0x3c, 0x40, 0xa0, 0xd2, 0x58, 0x44, 0x55, - 0x90, 0xc9, 0x34, 0x20, 0xe2, 0x56, 0x42, 0x44, 0x42, 0x6d, 0x66, 0x8a, 0xd4, 0xc, 0xc3, 0xe8}; + uint8_t pkt[] = {0x38, 0x21, 0x0, 0x4, 0x2, 0x61, 0x37, 0x57, 0xa9, 0x23, 0x88, 0xdb, + 0x8e, 0x37, 0xc4, 0x95, 0x34, 0x64, 0xf6, 0x6a, 0x92, 0xfe, 0xbc, 0x63, + 0x68, 0xa8, 0x24, 0x54, 0x87, 0x51, 0x2a, 0xaa, 0x8a, 0x13, 0x21}; - uint8_t buf[60] = {0}; + uint8_t buf[45] = {0}; - uint8_t topic_bytes[] = {0x5d, 0xd2, 0x66, 0x18, 0x90, 0xbd, 0x2b, 0x17, 0xb, 0x7e, 0xeb, 0x29, - 0xa6, 0xe3, 0x9e, 0xd3, 0x39, 0x1, 0x6a, 0xbf, 0xf2, 0xd4, 0x54, 0x3c}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x2, 0x61, 0x37, 0x57}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xd2, 0x58, 0x44, 0x55, 0x90, 0xc9, 0x34, 0x20, 0xe2, 0x56, - 0x42, 0x44, 0x42, 0x6d, 0x66, 0x8a, 0xd4, 0xc, 0xc3, 0xe8}; + uint8_t msg_bytes[] = {0xa9, 0x23, 0x88, 0xdb, 0x8e, 0x37, 0xc4, 0x95, 0x34, 0x64, 0xf6, 0x6a, 0x92, 0xfe, + 0xbc, 0x63, 0x68, 0xa8, 0x24, 0x54, 0x87, 0x51, 0x2a, 0xaa, 0x8a, 0x13, 0x21}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 27; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16544, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "/\151\180C\211\173\172u ", _pubPktID -// = 29329, _pubBody = "J\158~x\US\145@z/7C\157R\221Qm", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "Q\201\132\175[\206\183.\204\200p\224X\173\163MF\ETB\251\223T~\f\bW\241\179\180", _pubPktID = 2085, _pubBody = +// "\240\236\155\SOp\221\217'\225\163K\128", _pubProps = []} TEST(Publish311QCTest, Encode30) { - uint8_t pkt[] = {0x35, 0x1d, 0x0, 0x9, 0x2f, 0x97, 0xb4, 0x43, 0xd3, 0xad, 0xac, 0x75, 0x20, 0x72, 0x91, 0x4a, - 0x9e, 0x7e, 0x78, 0x1f, 0x91, 0x40, 0x7a, 0x2f, 0x37, 0x43, 0x9d, 0x52, 0xdd, 0x51, 0x6d}; + uint8_t pkt[] = {0x3d, 0x2c, 0x0, 0x1c, 0x51, 0xc9, 0x84, 0xaf, 0x5b, 0xce, 0xb7, 0x2e, 0xcc, 0xc8, 0x70, 0xe0, + 0x58, 0xad, 0xa3, 0x4d, 0x46, 0x17, 0xfb, 0xdf, 0x54, 0x7e, 0xc, 0x8, 0x57, 0xf1, 0xb3, 0xb4, + 0x8, 0x25, 0xf0, 0xec, 0x9b, 0xe, 0x70, 0xdd, 0xd9, 0x27, 0xe1, 0xa3, 0x4b, 0x80}; - uint8_t buf[41] = {0}; + uint8_t buf[56] = {0}; - uint8_t topic_bytes[] = {0x2f, 0x97, 0xb4, 0x43, 0xd3, 0xad, 0xac, 0x75, 0x20}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x51, 0xc9, 0x84, 0xaf, 0x5b, 0xce, 0xb7, 0x2e, 0xcc, 0xc8, 0x70, 0xe0, 0x58, 0xad, + 0xa3, 0x4d, 0x46, 0x17, 0xfb, 0xdf, 0x54, 0x7e, 0xc, 0x8, 0x57, 0xf1, 0xb3, 0xb4}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x4a, 0x9e, 0x7e, 0x78, 0x1f, 0x91, 0x40, 0x7a, - 0x2f, 0x37, 0x43, 0x9d, 0x52, 0xdd, 0x51, 0x6d}; + uint8_t msg_bytes[] = {0xf0, 0xec, 0x9b, 0xe, 0x70, 0xdd, 0xd9, 0x27, 0xe1, 0xa3, 0x4b, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 12; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29329, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2085, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "p\197\135\ETX\191\&8\221\RS\229\240\245$_2y\225iz\SYNx", _pubPktID = 12423, _pubBody = -// "\253\147\173\147\169r\130\DLE'\SUB\a\242\DC3/r\237[\213\209\140I\133\196EB\194", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\162\236\175\234}", _pubPktID = +// 21077, _pubBody = "T\207i\212;Q", _pubProps = []} TEST(Publish311QCTest, Encode31) { - uint8_t pkt[] = {0x3c, 0x32, 0x0, 0x14, 0x70, 0xc5, 0x87, 0x3, 0xbf, 0x38, 0xdd, 0x1e, 0xe5, - 0xf0, 0xf5, 0x24, 0x5f, 0x32, 0x79, 0xe1, 0x69, 0x7a, 0x16, 0x78, 0x30, 0x87, - 0xfd, 0x93, 0xad, 0x93, 0xa9, 0x72, 0x82, 0x10, 0x27, 0x1a, 0x7, 0xf2, 0x13, - 0x2f, 0x72, 0xed, 0x5b, 0xd5, 0xd1, 0x8c, 0x49, 0x85, 0xc4, 0x45, 0x42, 0xc2}; + uint8_t pkt[] = {0x33, 0xf, 0x0, 0x5, 0xa2, 0xec, 0xaf, 0xea, 0x7d, 0x52, 0x55, 0x54, 0xcf, 0x69, 0xd4, 0x3b, 0x51}; - uint8_t buf[62] = {0}; + uint8_t buf[27] = {0}; - uint8_t topic_bytes[] = {0x70, 0xc5, 0x87, 0x3, 0xbf, 0x38, 0xdd, 0x1e, 0xe5, 0xf0, - 0xf5, 0x24, 0x5f, 0x32, 0x79, 0xe1, 0x69, 0x7a, 0x16, 0x78}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa2, 0xec, 0xaf, 0xea, 0x7d}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xfd, 0x93, 0xad, 0x93, 0xa9, 0x72, 0x82, 0x10, 0x27, 0x1a, 0x7, 0xf2, 0x13, - 0x2f, 0x72, 0xed, 0x5b, 0xd5, 0xd1, 0x8c, 0x49, 0x85, 0xc4, 0x45, 0x42, 0xc2}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x54, 0xcf, 0x69, 0xd4, 0x3b, 0x51}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 6; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 12423, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 21077, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "W(p\EOT\215,C\167\EOTJ\137\247C\\\183.\131\171\DELD$\195*\211\ETB\181", _pubPktID = 21051, _pubBody = -// "\131\218+\DC3Y.\244=\217J\173h\245\248\238\&8yD\219u\241", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "(E\224", _pubProps = []} TEST(Publish311QCTest, Encode44) { - uint8_t pkt[] = {0x3d, 0x16, 0x0, 0x7, 0xb7, 0xab, 0x19, 0xd9, 0x92, 0x80, 0x4, 0x12, - 0x2d, 0x6e, 0xed, 0x19, 0x4d, 0x57, 0x8a, 0xea, 0x9a, 0xbf, 0x8d, 0x9e}; + uint8_t pkt[] = {0x31, 0x3b, 0x0, 0x1d, 0xa8, 0xcd, 0xeb, 0x39, 0x4c, 0x8, 0xec, 0xbb, 0xb8, 0x7b, 0xc7, 0x87, + 0x47, 0xa5, 0x63, 0xc8, 0x90, 0xe, 0x0, 0xea, 0x75, 0x16, 0x8e, 0x4f, 0xb1, 0x4e, 0x3a, 0xa1, + 0x38, 0x5a, 0x20, 0x7f, 0xc1, 0xc5, 0x37, 0x4b, 0x93, 0x89, 0xc7, 0x62, 0x5d, 0xf3, 0x7d, 0xf8, + 0xa1, 0xf8, 0x2e, 0x59, 0xda, 0x62, 0x62, 0x84, 0x9c, 0x1d, 0x12, 0x3e, 0xe0}; - uint8_t buf[34] = {0}; + uint8_t buf[71] = {0}; - uint8_t topic_bytes[] = {0xb7, 0xab, 0x19, 0xd9, 0x92, 0x80, 0x4}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa8, 0xcd, 0xeb, 0x39, 0x4c, 0x8, 0xec, 0xbb, 0xb8, 0x7b, 0xc7, 0x87, 0x47, 0xa5, 0x63, + 0xc8, 0x90, 0xe, 0x0, 0xea, 0x75, 0x16, 0x8e, 0x4f, 0xb1, 0x4e, 0x3a, 0xa1, 0x38}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x6e, 0xed, 0x19, 0x4d, 0x57, 0x8a, 0xea, 0x9a, 0xbf, 0x8d, 0x9e}; + uint8_t msg_bytes[] = {0x5a, 0x20, 0x7f, 0xc1, 0xc5, 0x37, 0x4b, 0x93, 0x89, 0xc7, 0x62, 0x5d, 0xf3, 0x7d, + 0xf8, 0xa1, 0xf8, 0x2e, 0x59, 0xda, 0x62, 0x62, 0x84, 0x9c, 0x1d, 0x12, 0x3e, 0xe0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 28; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 4653, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\DC4\238q\ACK\ESC\142Z\GS\147\186\v?\208O", _pubPktID = 0, _pubBody = "Q4\149", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\165r\DEL\n\202\133kb\136", +// _pubPktID = 7921, _pubBody = "O\248\206?\215\168\&4\DC1\131\187<1\176\200\EOTW \FSu\ETB3\128\222N\241\193\180", +// _pubProps = []} TEST(Publish311QCTest, Encode45) { - uint8_t pkt[] = {0x30, 0x13, 0x0, 0xe, 0x14, 0xee, 0x71, 0x6, 0x1b, 0x8e, 0x5a, - 0x1d, 0x93, 0xba, 0xb, 0x3f, 0xd0, 0x4f, 0x51, 0x34, 0x95}; + uint8_t pkt[] = {0x3c, 0x28, 0x0, 0x9, 0xa5, 0x72, 0x7f, 0xa, 0xca, 0x85, 0x6b, 0x62, 0x88, 0x1e, + 0xf1, 0x4f, 0xf8, 0xce, 0x3f, 0xd7, 0xa8, 0x34, 0x11, 0x83, 0xbb, 0x3c, 0x31, 0xb0, + 0xc8, 0x4, 0x57, 0x20, 0x1c, 0x75, 0x17, 0x33, 0x80, 0xde, 0x4e, 0xf1, 0xc1, 0xb4}; - uint8_t buf[31] = {0}; + uint8_t buf[52] = {0}; - uint8_t topic_bytes[] = {0x14, 0xee, 0x71, 0x6, 0x1b, 0x8e, 0x5a, 0x1d, 0x93, 0xba, 0xb, 0x3f, 0xd0, 0x4f}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa5, 0x72, 0x7f, 0xa, 0xca, 0x85, 0x6b, 0x62, 0x88}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x51, 0x34, 0x95}; + uint8_t msg_bytes[] = {0x4f, 0xf8, 0xce, 0x3f, 0xd7, 0xa8, 0x34, 0x11, 0x83, 0xbb, 0x3c, 0x31, 0xb0, 0xc8, + 0x4, 0x57, 0x20, 0x1c, 0x75, 0x17, 0x33, 0x80, 0xde, 0x4e, 0xf1, 0xc1, 0xb4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 27; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7921, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\180=\US\SYN\229\232", _pubPktID = -// 28144, _pubBody = "\SYN\238,\186\225\221v\229\138\172", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\228\161\&1\220\142H\211q3\179%~Q\148", _pubPktID = 29868, _pubBody = "nP\243G", _pubProps = []} TEST(Publish311QCTest, Encode46) { - uint8_t pkt[] = {0x35, 0x14, 0x0, 0x6, 0xb4, 0x3d, 0x1f, 0x16, 0xe5, 0xe8, 0x6d, - 0xf0, 0x16, 0xee, 0x2c, 0xba, 0xe1, 0xdd, 0x76, 0xe5, 0x8a, 0xac}; + uint8_t pkt[] = {0x33, 0x16, 0x0, 0xe, 0xe4, 0xa1, 0x31, 0xdc, 0x8e, 0x48, 0xd3, 0x71, + 0x33, 0xb3, 0x25, 0x7e, 0x51, 0x94, 0x74, 0xac, 0x6e, 0x50, 0xf3, 0x47}; - uint8_t buf[32] = {0}; + uint8_t buf[34] = {0}; - uint8_t topic_bytes[] = {0xb4, 0x3d, 0x1f, 0x16, 0xe5, 0xe8}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xe4, 0xa1, 0x31, 0xdc, 0x8e, 0x48, 0xd3, 0x71, 0x33, 0xb3, 0x25, 0x7e, 0x51, 0x94}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x16, 0xee, 0x2c, 0xba, 0xe1, 0xdd, 0x76, 0xe5, 0x8a, 0xac}; + uint8_t msg_bytes[] = {0x6e, 0x50, 0xf3, 0x47}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + msg.payload_len = 4; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 28144, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29868, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\186\182n\166", _pubPktID = 0, -// _pubBody = "\234+5&F\SYN\140C!\209\ACK\141C\138\180\SOH", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\NUL\211nNzt\150\194r\182+\179\199\146", _pubPktID = 0, _pubBody = +// "]8\167\v\179vF\250\130{$\169\150w^\190QS]U\227C\205\189\179[\ENQ\131\SUB\200", _pubProps = []} TEST(Publish311QCTest, Encode47) { - uint8_t pkt[] = {0x39, 0x16, 0x0, 0x4, 0xba, 0xb6, 0x6e, 0xa6, 0xea, 0x2b, 0x35, 0x26, - 0x46, 0x16, 0x8c, 0x43, 0x21, 0xd1, 0x6, 0x8d, 0x43, 0x8a, 0xb4, 0x1}; + uint8_t pkt[] = {0x38, 0x2e, 0x0, 0xe, 0x0, 0xd3, 0x6e, 0x4e, 0x7a, 0x74, 0x96, 0xc2, 0x72, 0xb6, 0x2b, 0xb3, + 0xc7, 0x92, 0x5d, 0x38, 0xa7, 0xb, 0xb3, 0x76, 0x46, 0xfa, 0x82, 0x7b, 0x24, 0xa9, 0x96, 0x77, + 0x5e, 0xbe, 0x51, 0x53, 0x5d, 0x55, 0xe3, 0x43, 0xcd, 0xbd, 0xb3, 0x5b, 0x5, 0x83, 0x1a, 0xc8}; - uint8_t buf[34] = {0}; + uint8_t buf[58] = {0}; - uint8_t topic_bytes[] = {0xba, 0xb6, 0x6e, 0xa6}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x0, 0xd3, 0x6e, 0x4e, 0x7a, 0x74, 0x96, 0xc2, 0x72, 0xb6, 0x2b, 0xb3, 0xc7, 0x92}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xea, 0x2b, 0x35, 0x26, 0x46, 0x16, 0x8c, 0x43, 0x21, 0xd1, 0x6, 0x8d, 0x43, 0x8a, 0xb4, 0x1}; + msg.retained = false; + uint8_t msg_bytes[] = {0x5d, 0x38, 0xa7, 0xb, 0xb3, 0x76, 0x46, 0xfa, 0x82, 0x7b, 0x24, 0xa9, 0x96, 0x77, 0x5e, + 0xbe, 0x51, 0x53, 0x5d, 0x55, 0xe3, 0x43, 0xcd, 0xbd, 0xb3, 0x5b, 0x5, 0x83, 0x1a, 0xc8}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 30; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "3", _pubPktID = 0, _pubBody = -// "\DLE5\164cC\229MU\SYN0\131\230UV\187\196 1\210[2\232", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "'\245\224\138\229\155\&6\241\GS\"t\ETX5%4?\146\ETB", _pubPktID = 0, _pubBody = "\SUB)\222", _pubProps = []} TEST(Publish311QCTest, Encode48) { - uint8_t pkt[] = {0x38, 0x19, 0x0, 0x1, 0x33, 0x10, 0x35, 0xa4, 0x63, 0x43, 0xe5, 0x4d, 0x55, 0x16, - 0x30, 0x83, 0xe6, 0x55, 0x56, 0xbb, 0xc4, 0x20, 0x31, 0xd2, 0x5b, 0x32, 0xe8}; + uint8_t pkt[] = {0x39, 0x17, 0x0, 0x12, 0x27, 0xf5, 0xe0, 0x8a, 0xe5, 0x9b, 0x36, 0xf1, 0x1d, + 0x22, 0x74, 0x3, 0x35, 0x25, 0x34, 0x3f, 0x92, 0x17, 0x1a, 0x29, 0xde}; - uint8_t buf[37] = {0}; + uint8_t buf[35] = {0}; - uint8_t topic_bytes[] = {0x33}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x27, 0xf5, 0xe0, 0x8a, 0xe5, 0x9b, 0x36, 0xf1, 0x1d, + 0x22, 0x74, 0x3, 0x35, 0x25, 0x34, 0x3f, 0x92, 0x17}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x10, 0x35, 0xa4, 0x63, 0x43, 0xe5, 0x4d, 0x55, 0x16, 0x30, 0x83, - 0xe6, 0x55, 0x56, 0xbb, 0xc4, 0x20, 0x31, 0xd2, 0x5b, 0x32, 0xe8}; + msg.retained = true; + uint8_t msg_bytes[] = {0x1a, 0x29, 0xde}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 3; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\147\SUB\NUL\215\&1\153\202&79\r", -// _pubPktID = 0, _pubBody = "c\217\202\193\156\199\202\222\SO\143\145\202\135\136\239\147Z\197\245\196\133\249\191A", +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\200Z\225i^_\STX\231\193\STX", +// _pubPktID = 16826, _pubBody = "\206\193\194\217\177\152\142,\163\145\149Q\237?7\131k\n\177[^\153ti\134sYl\140\174", // _pubProps = []} TEST(Publish311QCTest, Encode49) { - uint8_t pkt[] = {0x31, 0x25, 0x0, 0xb, 0x93, 0x1a, 0x0, 0xd7, 0x31, 0x99, 0xca, 0x26, 0x37, - 0x39, 0xd, 0x63, 0xd9, 0xca, 0xc1, 0x9c, 0xc7, 0xca, 0xde, 0xe, 0x8f, 0x91, - 0xca, 0x87, 0x88, 0xef, 0x93, 0x5a, 0xc5, 0xf5, 0xc4, 0x85, 0xf9, 0xbf, 0x41}; + uint8_t pkt[] = {0x3d, 0x2c, 0x0, 0xa, 0xc8, 0x5a, 0xe1, 0x69, 0x5e, 0x5f, 0x2, 0xe7, 0xc1, 0x2, 0x41, 0xba, + 0xce, 0xc1, 0xc2, 0xd9, 0xb1, 0x98, 0x8e, 0x2c, 0xa3, 0x91, 0x95, 0x51, 0xed, 0x3f, 0x37, 0x83, + 0x6b, 0xa, 0xb1, 0x5b, 0x5e, 0x99, 0x74, 0x69, 0x86, 0x73, 0x59, 0x6c, 0x8c, 0xae}; - uint8_t buf[49] = {0}; + uint8_t buf[56] = {0}; - uint8_t topic_bytes[] = {0x93, 0x1a, 0x0, 0xd7, 0x31, 0x99, 0xca, 0x26, 0x37, 0x39, 0xd}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xc8, 0x5a, 0xe1, 0x69, 0x5e, 0x5f, 0x2, 0xe7, 0xc1, 0x2}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x63, 0xd9, 0xca, 0xc1, 0x9c, 0xc7, 0xca, 0xde, 0xe, 0x8f, 0x91, 0xca, - 0x87, 0x88, 0xef, 0x93, 0x5a, 0xc5, 0xf5, 0xc4, 0x85, 0xf9, 0xbf, 0x41}; + uint8_t msg_bytes[] = {0xce, 0xc1, 0xc2, 0xd9, 0xb1, 0x98, 0x8e, 0x2c, 0xa3, 0x91, 0x95, 0x51, 0xed, 0x3f, 0x37, + 0x83, 0x6b, 0xa, 0xb1, 0x5b, 0x5e, 0x99, 0x74, 0x69, 0x86, 0x73, 0x59, 0x6c, 0x8c, 0xae}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 30; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16826, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\199\220\252\SI\147K\173", _pubPktID -// = 22359, _pubBody = "\179\135\192#+E7,\SO&0\CAN\239\145\190\193\159\161\ETX\v\205~yy\158v\209Tt\143", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\161\178\167\170\164+\151g\137\n", +// _pubPktID = 11219, _pubBody = "R\146a\229\236\247\197\178\199\136\159_\251", _pubProps = []} TEST(Publish311QCTest, Encode50) { - uint8_t pkt[] = {0x35, 0x29, 0x0, 0x7, 0xc7, 0xdc, 0xfc, 0xf, 0x93, 0x4b, 0xad, 0x57, 0x57, 0xb3, 0x87, - 0xc0, 0x23, 0x2b, 0x45, 0x37, 0x2c, 0xe, 0x26, 0x30, 0x18, 0xef, 0x91, 0xbe, 0xc1, 0x9f, - 0xa1, 0x3, 0xb, 0xcd, 0x7e, 0x79, 0x79, 0x9e, 0x76, 0xd1, 0x54, 0x74, 0x8f}; + uint8_t pkt[] = {0x3b, 0x1b, 0x0, 0xa, 0xa1, 0xb2, 0xa7, 0xaa, 0xa4, 0x2b, 0x97, 0x67, 0x89, 0xa, 0x2b, + 0xd3, 0x52, 0x92, 0x61, 0xe5, 0xec, 0xf7, 0xc5, 0xb2, 0xc7, 0x88, 0x9f, 0x5f, 0xfb}; - uint8_t buf[53] = {0}; + uint8_t buf[39] = {0}; - uint8_t topic_bytes[] = {0xc7, 0xdc, 0xfc, 0xf, 0x93, 0x4b, 0xad}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa1, 0xb2, 0xa7, 0xaa, 0xa4, 0x2b, 0x97, 0x67, 0x89, 0xa}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xb3, 0x87, 0xc0, 0x23, 0x2b, 0x45, 0x37, 0x2c, 0xe, 0x26, 0x30, 0x18, 0xef, 0x91, 0xbe, - 0xc1, 0x9f, 0xa1, 0x3, 0xb, 0xcd, 0x7e, 0x79, 0x79, 0x9e, 0x76, 0xd1, 0x54, 0x74, 0x8f}; + uint8_t msg_bytes[] = {0x52, 0x92, 0x61, 0xe5, 0xec, 0xf7, 0xc5, 0xb2, 0xc7, 0x88, 0x9f, 0x5f, 0xfb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 13; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 22359, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 11219, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\225Uc\EM\147>\149\248\SI9\ENQs\211]\179", _pubPktID = 25366, _pubBody = "\165c\155\220\241\175\249\EM\220Bi\224\t", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "R\\\164\224\200+\254\\\233t@\GS\144\&5|\243\244@%\240\170\193\150V\252\133q", _pubPktID = 23768, _pubBody = +// "\RS.\158\236\175|6'\152C\151\NUL\138o\230\242\236\184,\ENQ\201^\185\t", _pubProps = []} TEST(Publish311QCTest, Encode51) { - uint8_t pkt[] = {0x32, 0x20, 0x0, 0xf, 0xe1, 0x55, 0x63, 0x19, 0x93, 0x3e, 0x95, 0xf8, 0xf, 0x39, 0x5, 0x73, 0xd3, - 0x5d, 0xb3, 0x63, 0x16, 0xa5, 0x63, 0x9b, 0xdc, 0xf1, 0xaf, 0xf9, 0x19, 0xdc, 0x42, 0x69, 0xe0, 0x9}; + uint8_t pkt[] = {0x3c, 0x37, 0x0, 0x1b, 0x52, 0x5c, 0xa4, 0xe0, 0xc8, 0x2b, 0xfe, 0x5c, 0xe9, 0x74, 0x40, + 0x1d, 0x90, 0x35, 0x7c, 0xf3, 0xf4, 0x40, 0x25, 0xf0, 0xaa, 0xc1, 0x96, 0x56, 0xfc, 0x85, + 0x71, 0x5c, 0xd8, 0x1e, 0x2e, 0x9e, 0xec, 0xaf, 0x7c, 0x36, 0x27, 0x98, 0x43, 0x97, 0x0, + 0x8a, 0x6f, 0xe6, 0xf2, 0xec, 0xb8, 0x2c, 0x5, 0xc9, 0x5e, 0xb9, 0x9}; - uint8_t buf[44] = {0}; + uint8_t buf[67] = {0}; - uint8_t topic_bytes[] = {0xe1, 0x55, 0x63, 0x19, 0x93, 0x3e, 0x95, 0xf8, 0xf, 0x39, 0x5, 0x73, 0xd3, 0x5d, 0xb3}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x52, 0x5c, 0xa4, 0xe0, 0xc8, 0x2b, 0xfe, 0x5c, 0xe9, 0x74, 0x40, 0x1d, 0x90, 0x35, + 0x7c, 0xf3, 0xf4, 0x40, 0x25, 0xf0, 0xaa, 0xc1, 0x96, 0x56, 0xfc, 0x85, 0x71}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xa5, 0x63, 0x9b, 0xdc, 0xf1, 0xaf, 0xf9, 0x19, 0xdc, 0x42, 0x69, 0xe0, 0x9}; + uint8_t msg_bytes[] = {0x1e, 0x2e, 0x9e, 0xec, 0xaf, 0x7c, 0x36, 0x27, 0x98, 0x43, 0x97, 0x0, + 0x8a, 0x6f, 0xe6, 0xf2, 0xec, 0xb8, 0x2c, 0x5, 0xc9, 0x5e, 0xb9, 0x9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 24; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25366, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 23768, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "sS\f@K\\`9t", _pubPktID = 0, -// _pubBody = "9?\202\215M\ENQvqz\243\164Lg", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\EOT+\243\179\223\201\tb\221\175W<\221L\a", _pubPktID = 32599, _pubBody = +// "\187\221\219\249%\DC1M\195%\227~\ETBcZ\232\f\141\254\253\223", _pubProps = []} TEST(Publish311QCTest, Encode52) { - uint8_t pkt[] = {0x30, 0x18, 0x0, 0x9, 0x73, 0x53, 0xc, 0x40, 0x4b, 0x5c, 0x60, 0x39, 0x74, - 0x39, 0x3f, 0xca, 0xd7, 0x4d, 0x5, 0x76, 0x71, 0x7a, 0xf3, 0xa4, 0x4c, 0x67}; + uint8_t pkt[] = {0x3b, 0x27, 0x0, 0xf, 0x4, 0x2b, 0xf3, 0xb3, 0xdf, 0xc9, 0x9, 0x62, 0xdd, 0xaf, + 0x57, 0x3c, 0xdd, 0x4c, 0x7, 0x7f, 0x57, 0xbb, 0xdd, 0xdb, 0xf9, 0x25, 0x11, 0x4d, + 0xc3, 0x25, 0xe3, 0x7e, 0x17, 0x63, 0x5a, 0xe8, 0xc, 0x8d, 0xfe, 0xfd, 0xdf}; - uint8_t buf[36] = {0}; + uint8_t buf[51] = {0}; - uint8_t topic_bytes[] = {0x73, 0x53, 0xc, 0x40, 0x4b, 0x5c, 0x60, 0x39, 0x74}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x4, 0x2b, 0xf3, 0xb3, 0xdf, 0xc9, 0x9, 0x62, 0xdd, 0xaf, 0x57, 0x3c, 0xdd, 0x4c, 0x7}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x39, 0x3f, 0xca, 0xd7, 0x4d, 0x5, 0x76, 0x71, 0x7a, 0xf3, 0xa4, 0x4c, 0x67}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xbb, 0xdd, 0xdb, 0xf9, 0x25, 0x11, 0x4d, 0xc3, 0x25, 0xe3, + 0x7e, 0x17, 0x63, 0x5a, 0xe8, 0xc, 0x8d, 0xfe, 0xfd, 0xdf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 20; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 32599, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\220", _pubPktID = 0, _pubBody = -// "m>\243z\246\250\139\171?\208F\f\240\232\EOTT`\241\212\SOH\182\b\SI@\228A", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "k6\170c0\139\149-", _pubPktID = +// 24880, _pubBody = "q\181r\196\216Eo\234\"\ENQ\138\207\210-\196\182\157\139\DC2\178?b\a4\250\ETB\168\131", _pubProps = +// []} TEST(Publish311QCTest, Encode53) { - uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x1, 0xdc, 0x6d, 0x3e, 0xf3, 0x7a, 0xf6, 0xfa, 0x8b, 0xab, 0x3f, 0xd0, 0x46, - 0xc, 0xf0, 0xe8, 0x4, 0x54, 0x60, 0xf1, 0xd4, 0x1, 0xb6, 0x8, 0xf, 0x40, 0xe4, 0x41}; + uint8_t pkt[] = {0x32, 0x28, 0x0, 0x8, 0x6b, 0x36, 0xaa, 0x63, 0x30, 0x8b, 0x95, 0x2d, 0x61, 0x30, + 0x71, 0xb5, 0x72, 0xc4, 0xd8, 0x45, 0x6f, 0xea, 0x22, 0x5, 0x8a, 0xcf, 0xd2, 0x2d, + 0xc4, 0xb6, 0x9d, 0x8b, 0x12, 0xb2, 0x3f, 0x62, 0x7, 0x34, 0xfa, 0x17, 0xa8, 0x83}; - uint8_t buf[41] = {0}; + uint8_t buf[52] = {0}; - uint8_t topic_bytes[] = {0xdc}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x6b, 0x36, 0xaa, 0x63, 0x30, 0x8b, 0x95, 0x2d}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x6d, 0x3e, 0xf3, 0x7a, 0xf6, 0xfa, 0x8b, 0xab, 0x3f, 0xd0, 0x46, 0xc, 0xf0, - 0xe8, 0x4, 0x54, 0x60, 0xf1, 0xd4, 0x1, 0xb6, 0x8, 0xf, 0x40, 0xe4, 0x41}; + uint8_t msg_bytes[] = {0x71, 0xb5, 0x72, 0xc4, 0xd8, 0x45, 0x6f, 0xea, 0x22, 0x5, 0x8a, 0xcf, 0xd2, 0x2d, + 0xc4, 0xb6, 0x9d, 0x8b, 0x12, 0xb2, 0x3f, 0x62, 0x7, 0x34, 0xfa, 0x17, 0xa8, 0x83}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 28; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24880, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\f\143\204y\245\248\131\153\248\250\nj\156\173\166\174\GSIv\154\166w\r\136Y", _pubPktID = 0, _pubBody = -// "\177\216D\168\tF\242kx1\247\n", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\164]\137\161\184\189\ETB_L\r+\255\233u\227\NAK\SI\199\CANG\211_\141", _pubPktID = 0, _pubBody = +// "n\169\136j,\137\228\208\162\164aL\186\EOT\241\GS\230d\142\177N\138P", _pubProps = []} TEST(Publish311QCTest, Encode54) { - uint8_t pkt[] = {0x31, 0x27, 0x0, 0x19, 0xc, 0x8f, 0xcc, 0x79, 0xf5, 0xf8, 0x83, 0x99, 0xf8, 0xfa, - 0xa, 0x6a, 0x9c, 0xad, 0xa6, 0xae, 0x1d, 0x49, 0x76, 0x9a, 0xa6, 0x77, 0xd, 0x88, - 0x59, 0xb1, 0xd8, 0x44, 0xa8, 0x9, 0x46, 0xf2, 0x6b, 0x78, 0x31, 0xf7, 0xa}; + uint8_t pkt[] = {0x38, 0x30, 0x0, 0x17, 0xa4, 0x5d, 0x89, 0xa1, 0xb8, 0xbd, 0x17, 0x5f, 0x4c, 0xd, 0x2b, 0xff, 0xe9, + 0x75, 0xe3, 0x15, 0xf, 0xc7, 0x18, 0x47, 0xd3, 0x5f, 0x8d, 0x6e, 0xa9, 0x88, 0x6a, 0x2c, 0x89, 0xe4, + 0xd0, 0xa2, 0xa4, 0x61, 0x4c, 0xba, 0x4, 0xf1, 0x1d, 0xe6, 0x64, 0x8e, 0xb1, 0x4e, 0x8a, 0x50}; - uint8_t buf[51] = {0}; + uint8_t buf[60] = {0}; - uint8_t topic_bytes[] = {0xc, 0x8f, 0xcc, 0x79, 0xf5, 0xf8, 0x83, 0x99, 0xf8, 0xfa, 0xa, 0x6a, 0x9c, - 0xad, 0xa6, 0xae, 0x1d, 0x49, 0x76, 0x9a, 0xa6, 0x77, 0xd, 0x88, 0x59}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa4, 0x5d, 0x89, 0xa1, 0xb8, 0xbd, 0x17, 0x5f, 0x4c, 0xd, 0x2b, 0xff, + 0xe9, 0x75, 0xe3, 0x15, 0xf, 0xc7, 0x18, 0x47, 0xd3, 0x5f, 0x8d}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xb1, 0xd8, 0x44, 0xa8, 0x9, 0x46, 0xf2, 0x6b, 0x78, 0x31, 0xf7, 0xa}; + msg.retained = false; + uint8_t msg_bytes[] = {0x6e, 0xa9, 0x88, 0x6a, 0x2c, 0x89, 0xe4, 0xd0, 0xa2, 0xa4, 0x61, 0x4c, + 0xba, 0x4, 0xf1, 0x1d, 0xe6, 0x64, 0x8e, 0xb1, 0x4e, 0x8a, 0x50}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 23; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "x\141i\235F", _pubPktID = 15511, -// _pubBody = "\174]0.\196?\198\195\202m`\179\253E\v|\204\214P\f\229\NAK\154\130", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "_\225\NAK\164\f\128V", _pubPktID = +// 0, _pubBody = "\146\161JU\174P\208og\201\149\132e\190\182\\!e\203q\201\194\SYN\147O\178\173{\DC2F", _pubProps = []} TEST(Publish311QCTest, Encode55) { - uint8_t pkt[] = {0x32, 0x21, 0x0, 0x5, 0x78, 0x8d, 0x69, 0xeb, 0x46, 0x3c, 0x97, 0xae, - 0x5d, 0x30, 0x2e, 0xc4, 0x3f, 0xc6, 0xc3, 0xca, 0x6d, 0x60, 0xb3, 0xfd, - 0x45, 0xb, 0x7c, 0xcc, 0xd6, 0x50, 0xc, 0xe5, 0x15, 0x9a, 0x82}; + uint8_t pkt[] = {0x30, 0x27, 0x0, 0x7, 0x5f, 0xe1, 0x15, 0xa4, 0xc, 0x80, 0x56, 0x92, 0xa1, 0x4a, + 0x55, 0xae, 0x50, 0xd0, 0x6f, 0x67, 0xc9, 0x95, 0x84, 0x65, 0xbe, 0xb6, 0x5c, 0x21, + 0x65, 0xcb, 0x71, 0xc9, 0xc2, 0x16, 0x93, 0x4f, 0xb2, 0xad, 0x7b, 0x12, 0x46}; - uint8_t buf[45] = {0}; + uint8_t buf[51] = {0}; - uint8_t topic_bytes[] = {0x78, 0x8d, 0x69, 0xeb, 0x46}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x5f, 0xe1, 0x15, 0xa4, 0xc, 0x80, 0x56}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xae, 0x5d, 0x30, 0x2e, 0xc4, 0x3f, 0xc6, 0xc3, 0xca, 0x6d, 0x60, 0xb3, - 0xfd, 0x45, 0xb, 0x7c, 0xcc, 0xd6, 0x50, 0xc, 0xe5, 0x15, 0x9a, 0x82}; + uint8_t msg_bytes[] = {0x92, 0xa1, 0x4a, 0x55, 0xae, 0x50, 0xd0, 0x6f, 0x67, 0xc9, 0x95, 0x84, 0x65, 0xbe, 0xb6, + 0x5c, 0x21, 0x65, 0xcb, 0x71, 0xc9, 0xc2, 0x16, 0x93, 0x4f, 0xb2, 0xad, 0x7b, 0x12, 0x46}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 30; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15511, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\207", _pubPktID = 12437, _pubBody = -// "\209\NAKT\231?\229R\176}\ESC\195\172\146\168\148\188;\237\205\216\134\&4\132\&5w", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\b\240\fA@\206\204-; +// R\nS$\n\194\ESCh\DC1P2\229\135$", _pubPktID = 32117, _pubBody = "[\a", _pubProps = []} TEST(Publish311QCTest, Encode56) { - uint8_t pkt[] = {0x3a, 0x1e, 0x0, 0x1, 0xcf, 0x30, 0x95, 0xd1, 0x15, 0x54, 0xe7, 0x3f, 0xe5, 0x52, 0xb0, 0x7d, - 0x1b, 0xc3, 0xac, 0x92, 0xa8, 0x94, 0xbc, 0x3b, 0xed, 0xcd, 0xd8, 0x86, 0x34, 0x84, 0x35, 0x77}; + uint8_t pkt[] = {0x35, 0x1e, 0x0, 0x18, 0x8, 0xf0, 0xc, 0x41, 0x40, 0xce, 0xcc, 0x2d, 0x3b, 0x20, 0x52, 0xa, + 0x53, 0x24, 0xa, 0xc2, 0x1b, 0x68, 0x11, 0x50, 0x32, 0xe5, 0x87, 0x24, 0x7d, 0x75, 0x5b, 0x7}; uint8_t buf[42] = {0}; - uint8_t topic_bytes[] = {0xcf}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x8, 0xf0, 0xc, 0x41, 0x40, 0xce, 0xcc, 0x2d, 0x3b, 0x20, 0x52, 0xa, + 0x53, 0x24, 0xa, 0xc2, 0x1b, 0x68, 0x11, 0x50, 0x32, 0xe5, 0x87, 0x24}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xd1, 0x15, 0x54, 0xe7, 0x3f, 0xe5, 0x52, 0xb0, 0x7d, 0x1b, 0xc3, 0xac, 0x92, - 0xa8, 0x94, 0xbc, 0x3b, 0xed, 0xcd, 0xd8, 0x86, 0x34, 0x84, 0x35, 0x77}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x5b, 0x7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 2; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 12437, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32117, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\151\157\DC2\191\177A0d\141\181", -// _pubPktID = 0, _pubBody = "(W\SO\vJ\219Q\170]\to\a3\EOT\245X?\r\255\t&i\EM\213", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\169\247+\235\ACK\192\145", +// _pubPktID = 0, _pubBody = "\a\197\204\DEL\222\198\153\205\174\176a\153\233u\246\203~z\166\212\229\207sp\US`\225", +// _pubProps = []} TEST(Publish311QCTest, Encode57) { - uint8_t pkt[] = {0x38, 0x24, 0x0, 0xa, 0x97, 0x9d, 0x12, 0xbf, 0xb1, 0x41, 0x30, 0x64, 0x8d, - 0xb5, 0x28, 0x57, 0xe, 0xb, 0x4a, 0xdb, 0x51, 0xaa, 0x5d, 0x9, 0x6f, 0x7, - 0x33, 0x4, 0xf5, 0x58, 0x3f, 0xd, 0xff, 0x9, 0x26, 0x69, 0x19, 0xd5}; + uint8_t pkt[] = {0x31, 0x24, 0x0, 0x7, 0xa9, 0xf7, 0x2b, 0xeb, 0x6, 0xc0, 0x91, 0x7, 0xc5, + 0xcc, 0x7f, 0xde, 0xc6, 0x99, 0xcd, 0xae, 0xb0, 0x61, 0x99, 0xe9, 0x75, 0xf6, + 0xcb, 0x7e, 0x7a, 0xa6, 0xd4, 0xe5, 0xcf, 0x73, 0x70, 0x1f, 0x60, 0xe1}; uint8_t buf[48] = {0}; - uint8_t topic_bytes[] = {0x97, 0x9d, 0x12, 0xbf, 0xb1, 0x41, 0x30, 0x64, 0x8d, 0xb5}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa9, 0xf7, 0x2b, 0xeb, 0x6, 0xc0, 0x91}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x28, 0x57, 0xe, 0xb, 0x4a, 0xdb, 0x51, 0xaa, 0x5d, 0x9, 0x6f, 0x7, - 0x33, 0x4, 0xf5, 0x58, 0x3f, 0xd, 0xff, 0x9, 0x26, 0x69, 0x19, 0xd5}; + msg.retained = true; + uint8_t msg_bytes[] = {0x7, 0xc5, 0xcc, 0x7f, 0xde, 0xc6, 0x99, 0xcd, 0xae, 0xb0, 0x61, 0x99, 0xe9, 0x75, + 0xf6, 0xcb, 0x7e, 0x7a, 0xa6, 0xd4, 0xe5, 0xcf, 0x73, 0x70, 0x1f, 0x60, 0xe1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 27; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\ETB\133p7\NAK\217\177\185\186:\228-\158\214\255\170", _pubPktID = 5681, _pubBody = -// "\NULT\212\214&\205\222\154\236\130\237_\195\200\186\137\DEL\184\213\&6\192a\241\NUL\231\168\246\180", _pubProps = -// []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\150\251\130\251\166R)\184\\I^\183\212@\189\150\222", _pubPktID = 0, _pubBody = "\139}\228\225\&9", _pubProps = []} TEST(Publish311QCTest, Encode58) { - uint8_t pkt[] = {0x3c, 0x30, 0x0, 0x10, 0x17, 0x85, 0x70, 0x37, 0x15, 0xd9, 0xb1, 0xb9, 0xba, 0x3a, 0xe4, 0x2d, 0x9e, - 0xd6, 0xff, 0xaa, 0x16, 0x31, 0x0, 0x54, 0xd4, 0xd6, 0x26, 0xcd, 0xde, 0x9a, 0xec, 0x82, 0xed, 0x5f, - 0xc3, 0xc8, 0xba, 0x89, 0x7f, 0xb8, 0xd5, 0x36, 0xc0, 0x61, 0xf1, 0x0, 0xe7, 0xa8, 0xf6, 0xb4}; + uint8_t pkt[] = {0x30, 0x18, 0x0, 0x11, 0x96, 0xfb, 0x82, 0xfb, 0xa6, 0x52, 0x29, 0xb8, 0x5c, + 0x49, 0x5e, 0xb7, 0xd4, 0x40, 0xbd, 0x96, 0xde, 0x8b, 0x7d, 0xe4, 0xe1, 0x39}; - uint8_t buf[60] = {0}; + uint8_t buf[36] = {0}; - uint8_t topic_bytes[] = {0x17, 0x85, 0x70, 0x37, 0x15, 0xd9, 0xb1, 0xb9, - 0xba, 0x3a, 0xe4, 0x2d, 0x9e, 0xd6, 0xff, 0xaa}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x96, 0xfb, 0x82, 0xfb, 0xa6, 0x52, 0x29, 0xb8, 0x5c, + 0x49, 0x5e, 0xb7, 0xd4, 0x40, 0xbd, 0x96, 0xde}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x0, 0x54, 0xd4, 0xd6, 0x26, 0xcd, 0xde, 0x9a, 0xec, 0x82, 0xed, 0x5f, 0xc3, 0xc8, - 0xba, 0x89, 0x7f, 0xb8, 0xd5, 0x36, 0xc0, 0x61, 0xf1, 0x0, 0xe7, 0xa8, 0xf6, 0xb4}; + uint8_t msg_bytes[] = {0x8b, 0x7d, 0xe4, 0xe1, 0x39}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 5; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5681, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "K#\aZV,bl\168\131\197N", _pubPktID = -// 29545, _pubBody = "q\152\198\DC3v\US", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\161n\174\237\249", _pubPktID = 0, +// _pubBody = "YFq\199\251\158-\155S\194}\250\NULjMrM\ESC/6f\DC3\140", _pubProps = []} TEST(Publish311QCTest, Encode59) { - uint8_t pkt[] = {0x3b, 0x16, 0x0, 0xc, 0x4b, 0x23, 0x7, 0x5a, 0x56, 0x2c, 0x62, 0x6c, - 0xa8, 0x83, 0xc5, 0x4e, 0x73, 0x69, 0x71, 0x98, 0xc6, 0x13, 0x76, 0x1f}; + uint8_t pkt[] = {0x38, 0x1e, 0x0, 0x5, 0xa1, 0x6e, 0xae, 0xed, 0xf9, 0x59, 0x46, 0x71, 0xc7, 0xfb, 0x9e, 0x2d, + 0x9b, 0x53, 0xc2, 0x7d, 0xfa, 0x0, 0x6a, 0x4d, 0x72, 0x4d, 0x1b, 0x2f, 0x36, 0x66, 0x13, 0x8c}; - uint8_t buf[34] = {0}; + uint8_t buf[42] = {0}; - uint8_t topic_bytes[] = {0x4b, 0x23, 0x7, 0x5a, 0x56, 0x2c, 0x62, 0x6c, 0xa8, 0x83, 0xc5, 0x4e}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa1, 0x6e, 0xae, 0xed, 0xf9}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x71, 0x98, 0xc6, 0x13, 0x76, 0x1f}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x59, 0x46, 0x71, 0xc7, 0xfb, 0x9e, 0x2d, 0x9b, 0x53, 0xc2, 0x7d, 0xfa, + 0x0, 0x6a, 0x4d, 0x72, 0x4d, 0x1b, 0x2f, 0x36, 0x66, 0x13, 0x8c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 23; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29545, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\ETB./iLG\236\218\159\SOH\n\ESC\203\FSs", _pubPktID = 19215, _pubBody = -// "I\157\182\DEL\135\249\197]P>b\248\202r\201\180\226\179\255", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 4694, _pubBody = +// "\137\179ML\236", _pubProps = []} TEST(Publish311QCTest, Encode60) { - uint8_t pkt[] = {0x34, 0x26, 0x0, 0xf, 0x17, 0x2e, 0x2f, 0x69, 0x4c, 0x47, 0xec, 0xda, 0x9f, 0x1, - 0xa, 0x1b, 0xcb, 0x1c, 0x73, 0x4b, 0xf, 0x49, 0x9d, 0xb6, 0x7f, 0x87, 0xf9, 0xc5, - 0x5d, 0x50, 0x3e, 0x62, 0xf8, 0xca, 0x72, 0xc9, 0xb4, 0xe2, 0xb3, 0xff}; + uint8_t pkt[] = {0x3c, 0x9, 0x0, 0x0, 0x12, 0x56, 0x89, 0xb3, 0x4d, 0x4c, 0xec}; - uint8_t buf[50] = {0}; + uint8_t buf[21] = {0}; - uint8_t topic_bytes[] = {0x17, 0x2e, 0x2f, 0x69, 0x4c, 0x47, 0xec, 0xda, 0x9f, 0x1, 0xa, 0x1b, 0xcb, 0x1c, 0x73}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x49, 0x9d, 0xb6, 0x7f, 0x87, 0xf9, 0xc5, 0x5d, 0x50, 0x3e, - 0x62, 0xf8, 0xca, 0x72, 0xc9, 0xb4, 0xe2, 0xb3, 0xff}; + uint8_t msg_bytes[] = {0x89, 0xb3, 0x4d, 0x4c, 0xec}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 5; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19215, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 4694, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\ETXv\161\NUL\132\175\165\CAN2\131", -// _pubPktID = 31455, _pubBody = "P\232c#\237\r A\219\192Z\186\241T\196\154", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\ETB2\218\142q%", _pubPktID = 16088, +// _pubBody = "\251hR\153\SI\f\226", _pubProps = []} TEST(Publish311QCTest, Encode61) { - uint8_t pkt[] = {0x35, 0x1e, 0x0, 0xa, 0x3, 0x76, 0xa1, 0x0, 0x84, 0xaf, 0xa5, 0x18, 0x32, 0x83, 0x7a, 0xdf, - 0x50, 0xe8, 0x63, 0x23, 0xed, 0xd, 0x20, 0x41, 0xdb, 0xc0, 0x5a, 0xba, 0xf1, 0x54, 0xc4, 0x9a}; + uint8_t pkt[] = {0x33, 0x11, 0x0, 0x6, 0x17, 0x32, 0xda, 0x8e, 0x71, 0x25, + 0x3e, 0xd8, 0xfb, 0x68, 0x52, 0x99, 0xf, 0xc, 0xe2}; - uint8_t buf[42] = {0}; + uint8_t buf[29] = {0}; - uint8_t topic_bytes[] = {0x3, 0x76, 0xa1, 0x0, 0x84, 0xaf, 0xa5, 0x18, 0x32, 0x83}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x17, 0x32, 0xda, 0x8e, 0x71, 0x25}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x50, 0xe8, 0x63, 0x23, 0xed, 0xd, 0x20, 0x41, 0xdb, 0xc0, 0x5a, 0xba, 0xf1, 0x54, 0xc4, 0x9a}; + uint8_t msg_bytes[] = {0xfb, 0x68, 0x52, 0x99, 0xf, 0xc, 0xe2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 7; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31455, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16088, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "(\193\NAK\240\&3\174\176\CAN:q$\160F7+\162\164\bNCu\128\&3P\131\130\151\239g7", _pubPktID = 31413, _pubBody = "", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\DC3\188\&0\t6w\FS", _pubPktID = +// 7577, _pubBody = "9\176{\185\134p\216\206\208\GS\EM?", _pubProps = []} TEST(Publish311QCTest, Encode62) { - uint8_t pkt[] = {0x3d, 0x22, 0x0, 0x1e, 0x28, 0xc1, 0x15, 0xf0, 0x33, 0xae, 0xb0, 0x18, - 0x3a, 0x71, 0x24, 0xa0, 0x46, 0x37, 0x2b, 0xa2, 0xa4, 0x8, 0x4e, 0x43, - 0x75, 0x80, 0x33, 0x50, 0x83, 0x82, 0x97, 0xef, 0x67, 0x37, 0x7a, 0xb5}; + uint8_t pkt[] = {0x32, 0x17, 0x0, 0x7, 0x13, 0xbc, 0x30, 0x9, 0x36, 0x77, 0x1c, 0x1d, 0x99, + 0x39, 0xb0, 0x7b, 0xb9, 0x86, 0x70, 0xd8, 0xce, 0xd0, 0x1d, 0x19, 0x3f}; - uint8_t buf[46] = {0}; + uint8_t buf[35] = {0}; - uint8_t topic_bytes[] = {0x28, 0xc1, 0x15, 0xf0, 0x33, 0xae, 0xb0, 0x18, 0x3a, 0x71, 0x24, 0xa0, 0x46, 0x37, 0x2b, - 0xa2, 0xa4, 0x8, 0x4e, 0x43, 0x75, 0x80, 0x33, 0x50, 0x83, 0x82, 0x97, 0xef, 0x67, 0x37}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x13, 0xbc, 0x30, 0x9, 0x36, 0x77, 0x1c}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x39, 0xb0, 0x7b, 0xb9, 0x86, 0x70, 0xd8, 0xce, 0xd0, 0x1d, 0x19, 0x3f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 12; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 31413, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7577, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "u\197\FS\156\226\226\156\fe7\SUBD\251}\132(:k", _pubPktID = 0, _pubBody = -// "=\RS\224\ENQ\"\187\165\211E\156*\f\133Ox\197\162J\168\131\167I\SUB\190)\240\DEL\EM\216\255", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\DC2a\165\SO(\131\154\NAKm\b\STX\243\250\178\197H", _pubPktID = 13200, _pubBody = "\164V\204\140", _pubProps = []} TEST(Publish311QCTest, Encode63) { - uint8_t pkt[] = {0x30, 0x32, 0x0, 0x12, 0x75, 0xc5, 0x1c, 0x9c, 0xe2, 0xe2, 0x9c, 0xc, 0x65, - 0x37, 0x1a, 0x44, 0xfb, 0x7d, 0x84, 0x28, 0x3a, 0x6b, 0x3d, 0x1e, 0xe0, 0x5, - 0x22, 0xbb, 0xa5, 0xd3, 0x45, 0x9c, 0x2a, 0xc, 0x85, 0x4f, 0x78, 0xc5, 0xa2, - 0x4a, 0xa8, 0x83, 0xa7, 0x49, 0x1a, 0xbe, 0x29, 0xf0, 0x7f, 0x19, 0xd8, 0xff}; + uint8_t pkt[] = {0x3c, 0x18, 0x0, 0x10, 0x12, 0x61, 0xa5, 0xe, 0x28, 0x83, 0x9a, 0x15, 0x6d, + 0x8, 0x2, 0xf3, 0xfa, 0xb2, 0xc5, 0x48, 0x33, 0x90, 0xa4, 0x56, 0xcc, 0x8c}; - uint8_t buf[62] = {0}; + uint8_t buf[36] = {0}; - uint8_t topic_bytes[] = {0x75, 0xc5, 0x1c, 0x9c, 0xe2, 0xe2, 0x9c, 0xc, 0x65, - 0x37, 0x1a, 0x44, 0xfb, 0x7d, 0x84, 0x28, 0x3a, 0x6b}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x12, 0x61, 0xa5, 0xe, 0x28, 0x83, 0x9a, 0x15, 0x6d, 0x8, 0x2, 0xf3, 0xfa, 0xb2, 0xc5, 0x48}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x3d, 0x1e, 0xe0, 0x5, 0x22, 0xbb, 0xa5, 0xd3, 0x45, 0x9c, 0x2a, 0xc, 0x85, 0x4f, 0x78, - 0xc5, 0xa2, 0x4a, 0xa8, 0x83, 0xa7, 0x49, 0x1a, 0xbe, 0x29, 0xf0, 0x7f, 0x19, 0xd8, 0xff}; + uint8_t msg_bytes[] = {0xa4, 0x56, 0xcc, 0x8c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 4; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13200, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "s`#B\129\251kP3\n8", _pubPktID = -// 13139, _pubBody = "\SI{\192", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\136\199\135\133\171\252+\211d\DC3\\\170>\250\GS\GS\250\ETX\238", _pubPktID = 15457, _pubBody = +// "f\244\166\DLE\197\195\242\206\199<\FS\ETB$\STX \236\135\235\232\196\229\b`n\216,v\233V\177", _pubProps = []} TEST(Publish311QCTest, Encode64) { - uint8_t pkt[] = {0x3c, 0x12, 0x0, 0xb, 0x73, 0x60, 0x23, 0x42, 0x81, 0xfb, - 0x6b, 0x50, 0x33, 0xa, 0x38, 0x33, 0x53, 0xf, 0x7b, 0xc0}; + uint8_t pkt[] = {0x3b, 0x35, 0x0, 0x13, 0x88, 0xc7, 0x87, 0x85, 0xab, 0xfc, 0x2b, 0xd3, 0x64, 0x13, + 0x5c, 0xaa, 0x3e, 0xfa, 0x1d, 0x1d, 0xfa, 0x3, 0xee, 0x3c, 0x61, 0x66, 0xf4, 0xa6, + 0x10, 0xc5, 0xc3, 0xf2, 0xce, 0xc7, 0x3c, 0x1c, 0x17, 0x24, 0x2, 0x20, 0xec, 0x87, + 0xeb, 0xe8, 0xc4, 0xe5, 0x8, 0x60, 0x6e, 0xd8, 0x2c, 0x76, 0xe9, 0x56, 0xb1}; - uint8_t buf[30] = {0}; + uint8_t buf[65] = {0}; - uint8_t topic_bytes[] = {0x73, 0x60, 0x23, 0x42, 0x81, 0xfb, 0x6b, 0x50, 0x33, 0xa, 0x38}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x88, 0xc7, 0x87, 0x85, 0xab, 0xfc, 0x2b, 0xd3, 0x64, 0x13, + 0x5c, 0xaa, 0x3e, 0xfa, 0x1d, 0x1d, 0xfa, 0x3, 0xee}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xf, 0x7b, 0xc0}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x66, 0xf4, 0xa6, 0x10, 0xc5, 0xc3, 0xf2, 0xce, 0xc7, 0x3c, 0x1c, 0x17, 0x24, 0x2, 0x20, + 0xec, 0x87, 0xeb, 0xe8, 0xc4, 0xe5, 0x8, 0x60, 0x6e, 0xd8, 0x2c, 0x76, 0xe9, 0x56, 0xb1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 30; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13139, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 15457, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163]", _pubPktID = 9229, _pubBody = -// ":,\175v\152}\RS8\178|K\148\f\219\184\129Ep^\n\194\148\SOHv\\\ETB\253^", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 29420, _pubBody = +// "F\146\254\ETB\174Cu^\188$\218\201\215$\253\&7\184\236S\169\243\ETXn\180\US\fC\220\137\SYN", _pubProps = []} TEST(Publish311QCTest, Encode65) { - uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x2, 0xa3, 0x5d, 0x24, 0xd, 0x3a, 0x2c, 0xaf, 0x76, - 0x98, 0x7d, 0x1e, 0x38, 0xb2, 0x7c, 0x4b, 0x94, 0xc, 0xdb, 0xb8, 0x81, - 0x45, 0x70, 0x5e, 0xa, 0xc2, 0x94, 0x1, 0x76, 0x5c, 0x17, 0xfd, 0x5e}; + uint8_t pkt[] = {0x33, 0x22, 0x0, 0x0, 0x72, 0xec, 0x46, 0x92, 0xfe, 0x17, 0xae, 0x43, + 0x75, 0x5e, 0xbc, 0x24, 0xda, 0xc9, 0xd7, 0x24, 0xfd, 0x37, 0xb8, 0xec, + 0x53, 0xa9, 0xf3, 0x3, 0x6e, 0xb4, 0x1f, 0xc, 0x43, 0xdc, 0x89, 0x16}; uint8_t buf[46] = {0}; - uint8_t topic_bytes[] = {0xa3, 0x5d}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x3a, 0x2c, 0xaf, 0x76, 0x98, 0x7d, 0x1e, 0x38, 0xb2, 0x7c, 0x4b, 0x94, 0xc, 0xdb, - 0xb8, 0x81, 0x45, 0x70, 0x5e, 0xa, 0xc2, 0x94, 0x1, 0x76, 0x5c, 0x17, 0xfd, 0x5e}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x46, 0x92, 0xfe, 0x17, 0xae, 0x43, 0x75, 0x5e, 0xbc, 0x24, 0xda, 0xc9, 0xd7, 0x24, 0xfd, + 0x37, 0xb8, 0xec, 0x53, 0xa9, 0xf3, 0x3, 0x6e, 0xb4, 0x1f, 0xc, 0x43, 0xdc, 0x89, 0x16}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 30; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 9229, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29420, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "'\148R\STX\207v\202o[1\154JIl\129\189\&9.\231\220u\233\200G\f \241\196M:", _pubPktID = 0, _pubBody = -// "\239\141wL\FS\241\255ZW8R\f\CAN\ACKT\215)ZZ\200z\239", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\220\DC4\187\155", _pubPktID = +// 28673, _pubBody = "\160\255\248\156YF\148S\164\194~\t\212\134\149`\202l", _pubProps = []} TEST(Publish311QCTest, Encode66) { - uint8_t pkt[] = {0x30, 0x36, 0x0, 0x1e, 0x27, 0x94, 0x52, 0x2, 0xcf, 0x76, 0xca, 0x6f, 0x5b, 0x31, - 0x9a, 0x4a, 0x49, 0x6c, 0x81, 0xbd, 0x39, 0x2e, 0xe7, 0xdc, 0x75, 0xe9, 0xc8, 0x47, - 0xc, 0x20, 0xf1, 0xc4, 0x4d, 0x3a, 0xef, 0x8d, 0x77, 0x4c, 0x1c, 0xf1, 0xff, 0x5a, - 0x57, 0x38, 0x52, 0xc, 0x18, 0x6, 0x54, 0xd7, 0x29, 0x5a, 0x5a, 0xc8, 0x7a, 0xef}; + uint8_t pkt[] = {0x35, 0x1b, 0x0, 0x5, 0xfd, 0xdc, 0x14, 0xbb, 0x9b, 0x70, 0x1, 0xa0, 0xff, 0xf8, 0x9c, + 0x59, 0x46, 0x94, 0x53, 0xa4, 0xc2, 0x7e, 0x9, 0xd4, 0x86, 0x95, 0x60, 0xca, 0x6c}; - uint8_t buf[66] = {0}; + uint8_t buf[39] = {0}; - uint8_t topic_bytes[] = {0x27, 0x94, 0x52, 0x2, 0xcf, 0x76, 0xca, 0x6f, 0x5b, 0x31, 0x9a, 0x4a, 0x49, 0x6c, 0x81, - 0xbd, 0x39, 0x2e, 0xe7, 0xdc, 0x75, 0xe9, 0xc8, 0x47, 0xc, 0x20, 0xf1, 0xc4, 0x4d, 0x3a}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xfd, 0xdc, 0x14, 0xbb, 0x9b}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xef, 0x8d, 0x77, 0x4c, 0x1c, 0xf1, 0xff, 0x5a, 0x57, 0x38, 0x52, - 0xc, 0x18, 0x6, 0x54, 0xd7, 0x29, 0x5a, 0x5a, 0xc8, 0x7a, 0xef}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa0, 0xff, 0xf8, 0x9c, 0x59, 0x46, 0x94, 0x53, 0xa4, + 0xc2, 0x7e, 0x9, 0xd4, 0x86, 0x95, 0x60, 0xca, 0x6c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 18; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 28673, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "9\140\202\235A\137*\ESC\202=k\179\211?\NAK\238", _pubPktID = 0, _pubBody = -// "R\140Q\187\192\240\209=*\152Ov\136\254G\251", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\141\195\131\143\248w\207", +// _pubPktID = 574, _pubBody = "x\\\156a}\224\130S\US%\153\187\181\217\RS\201{", _pubProps = []} TEST(Publish311QCTest, Encode67) { - uint8_t pkt[] = {0x38, 0x22, 0x0, 0x10, 0x39, 0x8c, 0xca, 0xeb, 0x41, 0x89, 0x2a, 0x1b, - 0xca, 0x3d, 0x6b, 0xb3, 0xd3, 0x3f, 0x15, 0xee, 0x52, 0x8c, 0x51, 0xbb, - 0xc0, 0xf0, 0xd1, 0x3d, 0x2a, 0x98, 0x4f, 0x76, 0x88, 0xfe, 0x47, 0xfb}; + uint8_t pkt[] = {0x33, 0x1c, 0x0, 0x7, 0x8d, 0xc3, 0x83, 0x8f, 0xf8, 0x77, 0xcf, 0x2, 0x3e, 0x78, 0x5c, + 0x9c, 0x61, 0x7d, 0xe0, 0x82, 0x53, 0x1f, 0x25, 0x99, 0xbb, 0xb5, 0xd9, 0x1e, 0xc9, 0x7b}; - uint8_t buf[46] = {0}; + uint8_t buf[40] = {0}; - uint8_t topic_bytes[] = {0x39, 0x8c, 0xca, 0xeb, 0x41, 0x89, 0x2a, 0x1b, - 0xca, 0x3d, 0x6b, 0xb3, 0xd3, 0x3f, 0x15, 0xee}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x8d, 0xc3, 0x83, 0x8f, 0xf8, 0x77, 0xcf}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x52, 0x8c, 0x51, 0xbb, 0xc0, 0xf0, 0xd1, 0x3d, - 0x2a, 0x98, 0x4f, 0x76, 0x88, 0xfe, 0x47, 0xfb}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x78, 0x5c, 0x9c, 0x61, 0x7d, 0xe0, 0x82, 0x53, 0x1f, + 0x25, 0x99, 0xbb, 0xb5, 0xd9, 0x1e, 0xc9, 0x7b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 17; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 574, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\255\250\242r^\171,{\253\254\200\128\135\225AG\149\&3", _pubPktID = 19170, _pubBody = "\GS", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "Mq\234\146\239\150W\FS1\177", +// _pubPktID = 0, _pubBody = "0\141\201\&8\139\&4\ETX>\239\RS\238\229t\225\198|\194W\186]\200\244|\171\DLE\163\193", +// _pubProps = []} TEST(Publish311QCTest, Encode68) { - uint8_t pkt[] = {0x35, 0x17, 0x0, 0x12, 0xff, 0xfa, 0xf2, 0x72, 0x5e, 0xab, 0x2c, 0x7b, 0xfd, - 0xfe, 0xc8, 0x80, 0x87, 0xe1, 0x41, 0x47, 0x95, 0x33, 0x4a, 0xe2, 0x1d}; + uint8_t pkt[] = {0x38, 0x27, 0x0, 0xa, 0x4d, 0x71, 0xea, 0x92, 0xef, 0x96, 0x57, 0x1c, 0x31, 0xb1, + 0x30, 0x8d, 0xc9, 0x38, 0x8b, 0x34, 0x3, 0x3e, 0xef, 0x1e, 0xee, 0xe5, 0x74, 0xe1, + 0xc6, 0x7c, 0xc2, 0x57, 0xba, 0x5d, 0xc8, 0xf4, 0x7c, 0xab, 0x10, 0xa3, 0xc1}; - uint8_t buf[35] = {0}; + uint8_t buf[51] = {0}; - uint8_t topic_bytes[] = {0xff, 0xfa, 0xf2, 0x72, 0x5e, 0xab, 0x2c, 0x7b, 0xfd, - 0xfe, 0xc8, 0x80, 0x87, 0xe1, 0x41, 0x47, 0x95, 0x33}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x4d, 0x71, 0xea, 0x92, 0xef, 0x96, 0x57, 0x1c, 0x31, 0xb1}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x1d}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x30, 0x8d, 0xc9, 0x38, 0x8b, 0x34, 0x3, 0x3e, 0xef, 0x1e, 0xee, 0xe5, 0x74, 0xe1, + 0xc6, 0x7c, 0xc2, 0x57, 0xba, 0x5d, 0xc8, 0xf4, 0x7c, 0xab, 0x10, 0xa3, 0xc1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 27; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19170, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\f<\223\175\243\197\227\253.l\204M\219\195\149\202\132\194\182\a\CAN\n9't=\191\DLEb", _pubPktID = 0, _pubBody = "", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "h\155\209\SYNBX\251\201\213\188", +// _pubPktID = 12728, _pubBody = "\SI\140\187\174(F\161\145", _pubProps = []} TEST(Publish311QCTest, Encode69) { - uint8_t pkt[] = {0x31, 0x1f, 0x0, 0x1d, 0xc, 0x3c, 0xdf, 0xaf, 0xf3, 0xc5, 0xe3, 0xfd, 0x2e, 0x6c, 0xcc, 0x4d, 0xdb, - 0xc3, 0x95, 0xca, 0x84, 0xc2, 0xb6, 0x7, 0x18, 0xa, 0x39, 0x27, 0x74, 0x3d, 0xbf, 0x10, 0x62}; + uint8_t pkt[] = {0x3a, 0x16, 0x0, 0xa, 0x68, 0x9b, 0xd1, 0x16, 0x42, 0x58, 0xfb, 0xc9, + 0xd5, 0xbc, 0x31, 0xb8, 0xf, 0x8c, 0xbb, 0xae, 0x28, 0x46, 0xa1, 0x91}; - uint8_t buf[43] = {0}; + uint8_t buf[34] = {0}; - uint8_t topic_bytes[] = {0xc, 0x3c, 0xdf, 0xaf, 0xf3, 0xc5, 0xe3, 0xfd, 0x2e, 0x6c, 0xcc, 0x4d, 0xdb, 0xc3, 0x95, - 0xca, 0x84, 0xc2, 0xb6, 0x7, 0x18, 0xa, 0x39, 0x27, 0x74, 0x3d, 0xbf, 0x10, 0x62}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x68, 0x9b, 0xd1, 0x16, 0x42, 0x58, 0xfb, 0xc9, 0xd5, 0xbc}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xf, 0x8c, 0xbb, 0xae, 0x28, 0x46, 0xa1, 0x91}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 8; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 12728, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "3", _pubPktID = 27883, _pubBody = -// "\246\DC1,I\237\135\&0/\210\164\233\223de\144\250\141\134\&7\190\194\144\206f", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "kH\169\156\ACK\a\235\&2Q\128\148\FS\135\142\FS]\168j\246\208", _pubPktID = 23840, _pubBody = "D\195\164", _pubProps +// = []} TEST(Publish311QCTest, Encode70) { - uint8_t pkt[] = {0x33, 0x1d, 0x0, 0x1, 0x33, 0x6c, 0xeb, 0xf6, 0x11, 0x2c, 0x49, 0xed, 0x87, 0x30, 0x2f, 0xd2, - 0xa4, 0xe9, 0xdf, 0x64, 0x65, 0x90, 0xfa, 0x8d, 0x86, 0x37, 0xbe, 0xc2, 0x90, 0xce, 0x66}; + uint8_t pkt[] = {0x33, 0x1b, 0x0, 0x14, 0x6b, 0x48, 0xa9, 0x9c, 0x6, 0x7, 0xeb, 0x32, 0x51, 0x80, 0x94, + 0x1c, 0x87, 0x8e, 0x1c, 0x5d, 0xa8, 0x6a, 0xf6, 0xd0, 0x5d, 0x20, 0x44, 0xc3, 0xa4}; - uint8_t buf[41] = {0}; + uint8_t buf[39] = {0}; - uint8_t topic_bytes[] = {0x33}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x6b, 0x48, 0xa9, 0x9c, 0x6, 0x7, 0xeb, 0x32, 0x51, 0x80, + 0x94, 0x1c, 0x87, 0x8e, 0x1c, 0x5d, 0xa8, 0x6a, 0xf6, 0xd0}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xf6, 0x11, 0x2c, 0x49, 0xed, 0x87, 0x30, 0x2f, 0xd2, 0xa4, 0xe9, 0xdf, - 0x64, 0x65, 0x90, 0xfa, 0x8d, 0x86, 0x37, 0xbe, 0xc2, 0x90, 0xce, 0x66}; + uint8_t msg_bytes[] = {0x44, 0xc3, 0xa4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 3; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 27883, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 23840, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\210\n\244+\148\225\234\&5U\226r16\207\137\NAK}\GSX\204\250S\144\151b\224\184", _pubPktID = 20202, _pubBody = -// "\191\207\175uEn7\171\238\203\140\210I\200!", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "P\147\149\202g\200\140\&8\251", +// _pubPktID = 0, _pubBody = "\161k\226l\198m\147.\232\136\&3>\222>\138\225{\176s\227!\217C\RS\209_", _pubProps = []} TEST(Publish311QCTest, Encode71) { - uint8_t pkt[] = {0x3b, 0x2e, 0x0, 0x1b, 0xd2, 0xa, 0xf4, 0x2b, 0x94, 0xe1, 0xea, 0x35, 0x55, 0xe2, 0x72, 0x31, - 0x36, 0xcf, 0x89, 0x15, 0x7d, 0x1d, 0x58, 0xcc, 0xfa, 0x53, 0x90, 0x97, 0x62, 0xe0, 0xb8, 0x4e, - 0xea, 0xbf, 0xcf, 0xaf, 0x75, 0x45, 0x6e, 0x37, 0xab, 0xee, 0xcb, 0x8c, 0xd2, 0x49, 0xc8, 0x21}; + uint8_t pkt[] = {0x31, 0x25, 0x0, 0x9, 0x50, 0x93, 0x95, 0xca, 0x67, 0xc8, 0x8c, 0x38, 0xfb, + 0xa1, 0x6b, 0xe2, 0x6c, 0xc6, 0x6d, 0x93, 0x2e, 0xe8, 0x88, 0x33, 0x3e, 0xde, + 0x3e, 0x8a, 0xe1, 0x7b, 0xb0, 0x73, 0xe3, 0x21, 0xd9, 0x43, 0x1e, 0xd1, 0x5f}; - uint8_t buf[58] = {0}; + uint8_t buf[49] = {0}; - uint8_t topic_bytes[] = {0xd2, 0xa, 0xf4, 0x2b, 0x94, 0xe1, 0xea, 0x35, 0x55, 0xe2, 0x72, 0x31, 0x36, 0xcf, - 0x89, 0x15, 0x7d, 0x1d, 0x58, 0xcc, 0xfa, 0x53, 0x90, 0x97, 0x62, 0xe0, 0xb8}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x50, 0x93, 0x95, 0xca, 0x67, 0xc8, 0x8c, 0x38, 0xfb}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xbf, 0xcf, 0xaf, 0x75, 0x45, 0x6e, 0x37, 0xab, 0xee, 0xcb, 0x8c, 0xd2, 0x49, 0xc8, 0x21}; + uint8_t msg_bytes[] = {0xa1, 0x6b, 0xe2, 0x6c, 0xc6, 0x6d, 0x93, 0x2e, 0xe8, 0x88, 0x33, 0x3e, 0xde, + 0x3e, 0x8a, 0xe1, 0x7b, 0xb0, 0x73, 0xe3, 0x21, 0xd9, 0x43, 0x1e, 0xd1, 0x5f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 26; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 20202, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\240\247\161\170\180S\251(.\139\187\RS\199\\\USs\207!7\250\&8&q\ESC\236\153", _pubPktID = 1829, _pubBody = -// ")B\201\179\163\188%[\184\154\EOT\146x7,\DC3\v\180\DLE", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\251\215\CAN[sS\SO\\U", _pubProps = []} TEST(Publish311QCTest, Encode74) { - uint8_t pkt[] = {0x3a, 0x19, 0x0, 0x8, 0x51, 0xc7, 0x1f, 0x40, 0x68, 0x59, 0xba, 0x66, 0x2, 0xac, - 0x11, 0x2f, 0xb3, 0xd1, 0x20, 0x21, 0xe6, 0x2f, 0xbb, 0x20, 0xdc, 0xbf, 0xd4}; + uint8_t pkt[] = {0x32, 0x15, 0x0, 0x2, 0x45, 0xd1, 0x1c, 0xec, 0xeb, 0x3, 0xb9, 0xc0, + 0xd4, 0xb7, 0x6, 0x5c, 0x2b, 0xbc, 0xa5, 0xe6, 0x3e, 0x5c, 0x55}; - uint8_t buf[37] = {0}; + uint8_t buf[33] = {0}; - uint8_t topic_bytes[] = {0x51, 0xc7, 0x1f, 0x40, 0x68, 0x59, 0xba, 0x66}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x45, 0xd1}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x11, 0x2f, 0xb3, 0xd1, 0x20, 0x21, 0xe6, 0x2f, 0xbb, 0x20, 0xdc, 0xbf, 0xd4}; + uint8_t msg_bytes[] = {0xeb, 0x3, 0xb9, 0xc0, 0xd4, 0xb7, 0x6, 0x5c, 0x2b, 0xbc, 0xa5, 0xe6, 0x3e, 0x5c, 0x55}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 15; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 684, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7404, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\142\&2\163\190T\212+\DC4[\234\248w\231\165@\206\&40", _pubPktID = 9582, _pubBody = -// "[(\157B\171\184\156\f\201\EM\160\166\206\199\168\222\153NX$\247\ACK2\183", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\198\225\DC4\245\&5\248\178f[\186\216.\218\247", _pubPktID = 16102, _pubBody = "\213@o\181\227\224\214\214UA", +// _pubProps = []} TEST(Publish311QCTest, Encode75) { - uint8_t pkt[] = {0x3b, 0x2e, 0x0, 0x12, 0x8e, 0x32, 0xa3, 0xbe, 0x54, 0xd4, 0x2b, 0x14, 0x5b, 0xea, 0xf8, 0x77, - 0xe7, 0xa5, 0x40, 0xce, 0x34, 0x30, 0x25, 0x6e, 0x5b, 0x28, 0x9d, 0x42, 0xab, 0xb8, 0x9c, 0xc, - 0xc9, 0x19, 0xa0, 0xa6, 0xce, 0xc7, 0xa8, 0xde, 0x99, 0x4e, 0x58, 0x24, 0xf7, 0x6, 0x32, 0xb7}; + uint8_t pkt[] = {0x32, 0x1c, 0x0, 0xe, 0xc6, 0xe1, 0x14, 0xf5, 0x35, 0xf8, 0xb2, 0x66, 0x5b, 0xba, 0xd8, + 0x2e, 0xda, 0xf7, 0x3e, 0xe6, 0xd5, 0x40, 0x6f, 0xb5, 0xe3, 0xe0, 0xd6, 0xd6, 0x55, 0x41}; - uint8_t buf[58] = {0}; + uint8_t buf[40] = {0}; - uint8_t topic_bytes[] = {0x8e, 0x32, 0xa3, 0xbe, 0x54, 0xd4, 0x2b, 0x14, 0x5b, - 0xea, 0xf8, 0x77, 0xe7, 0xa5, 0x40, 0xce, 0x34, 0x30}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xc6, 0xe1, 0x14, 0xf5, 0x35, 0xf8, 0xb2, 0x66, 0x5b, 0xba, 0xd8, 0x2e, 0xda, 0xf7}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x5b, 0x28, 0x9d, 0x42, 0xab, 0xb8, 0x9c, 0xc, 0xc9, 0x19, 0xa0, 0xa6, - 0xce, 0xc7, 0xa8, 0xde, 0x99, 0x4e, 0x58, 0x24, 0xf7, 0x6, 0x32, 0xb7}; + msg.retained = false; + uint8_t msg_bytes[] = {0xd5, 0x40, 0x6f, 0xb5, 0xe3, 0xe0, 0xd6, 0xd6, 0x55, 0x41}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 10; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 9582, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16102, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "ox\254Qe\203<\176\195ES", _pubPktID -// = 20876, _pubBody = "J\224\148H\132xS\156Aov\199\244wF[\n\185\190;\142o\SOHg", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 19098, _pubBody = +// "\216\241'G\183\&2\SO\NAK\254\130\&1\161\176A=\131x\SUB\190", _pubProps = []} TEST(Publish311QCTest, Encode76) { - uint8_t pkt[] = {0x34, 0x27, 0x0, 0xb, 0x6f, 0x78, 0xfe, 0x51, 0x65, 0xcb, 0x3c, 0xb0, 0xc3, 0x45, - 0x53, 0x51, 0x8c, 0x4a, 0xe0, 0x94, 0x48, 0x84, 0x78, 0x53, 0x9c, 0x41, 0x6f, 0x76, - 0xc7, 0xf4, 0x77, 0x46, 0x5b, 0xa, 0xb9, 0xbe, 0x3b, 0x8e, 0x6f, 0x1, 0x67}; + uint8_t pkt[] = {0x3b, 0x17, 0x0, 0x0, 0x4a, 0x9a, 0xd8, 0xf1, 0x27, 0x47, 0xb7, 0x32, 0xe, + 0x15, 0xfe, 0x82, 0x31, 0xa1, 0xb0, 0x41, 0x3d, 0x83, 0x78, 0x1a, 0xbe}; - uint8_t buf[51] = {0}; + uint8_t buf[35] = {0}; - uint8_t topic_bytes[] = {0x6f, 0x78, 0xfe, 0x51, 0x65, 0xcb, 0x3c, 0xb0, 0xc3, 0x45, 0x53}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x4a, 0xe0, 0x94, 0x48, 0x84, 0x78, 0x53, 0x9c, 0x41, 0x6f, 0x76, 0xc7, - 0xf4, 0x77, 0x46, 0x5b, 0xa, 0xb9, 0xbe, 0x3b, 0x8e, 0x6f, 0x1, 0x67}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xd8, 0xf1, 0x27, 0x47, 0xb7, 0x32, 0xe, 0x15, 0xfe, 0x82, + 0x31, 0xa1, 0xb0, 0x41, 0x3d, 0x83, 0x78, 0x1a, 0xbe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 19; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 20876, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 19098, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = ")\159\249\220\185\252\230\193", -// _pubPktID = 10776, _pubBody = "\144\230\&6K\134\194\176\153\v\145(]\222\255\155\231\225(?\150}\155\FS\173)", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "'\243\208\&5\245\172=e^\165", +// _pubPktID = 6458, _pubBody = "\222#/ q\128\&4\174k'\135\SI:O\193\DC4\153[", _pubProps = []} TEST(Publish311QCTest, Encode77) { - uint8_t pkt[] = {0x34, 0x25, 0x0, 0x8, 0x29, 0x9f, 0xf9, 0xdc, 0xb9, 0xfc, 0xe6, 0xc1, 0x2a, - 0x18, 0x90, 0xe6, 0x36, 0x4b, 0x86, 0xc2, 0xb0, 0x99, 0xb, 0x91, 0x28, 0x5d, - 0xde, 0xff, 0x9b, 0xe7, 0xe1, 0x28, 0x3f, 0x96, 0x7d, 0x9b, 0x1c, 0xad, 0x29}; + uint8_t pkt[] = {0x33, 0x20, 0x0, 0xa, 0x27, 0xf3, 0xd0, 0x35, 0xf5, 0xac, 0x3d, 0x65, + 0x5e, 0xa5, 0x19, 0x3a, 0xde, 0x23, 0x2f, 0x20, 0x71, 0x80, 0x34, 0xae, + 0x6b, 0x27, 0x87, 0xf, 0x3a, 0x4f, 0xc1, 0x14, 0x99, 0x5b}; - uint8_t buf[49] = {0}; + uint8_t buf[44] = {0}; - uint8_t topic_bytes[] = {0x29, 0x9f, 0xf9, 0xdc, 0xb9, 0xfc, 0xe6, 0xc1}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x27, 0xf3, 0xd0, 0x35, 0xf5, 0xac, 0x3d, 0x65, 0x5e, 0xa5}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x90, 0xe6, 0x36, 0x4b, 0x86, 0xc2, 0xb0, 0x99, 0xb, 0x91, 0x28, 0x5d, 0xde, - 0xff, 0x9b, 0xe7, 0xe1, 0x28, 0x3f, 0x96, 0x7d, 0x9b, 0x1c, 0xad, 0x29}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xde, 0x23, 0x2f, 0x20, 0x71, 0x80, 0x34, 0xae, 0x6b, + 0x27, 0x87, 0xf, 0x3a, 0x4f, 0xc1, 0x14, 0x99, 0x5b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 18; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10776, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 6458, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "6:\229<\217\235\180", _pubPktID = -// 21683, _pubBody = "y", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "I\168PH\213\245]<\203\142\255\147\"\251", _pubPktID = 23705, _pubBody = +// "\136\177\214\217\&8;\253\STX\147\206\151\161\183?\r\SUB\151\230c\DLE5h\249\177\236", _pubProps = []} TEST(Publish311QCTest, Encode78) { - uint8_t pkt[] = {0x3c, 0xc, 0x0, 0x7, 0x36, 0x3a, 0xe5, 0x3c, 0xd9, 0xeb, 0xb4, 0x54, 0xb3, 0x79}; + uint8_t pkt[] = {0x33, 0x2b, 0x0, 0xe, 0x49, 0xa8, 0x50, 0x48, 0xd5, 0xf5, 0x5d, 0x3c, 0xcb, 0x8e, 0xff, + 0x93, 0x22, 0xfb, 0x5c, 0x99, 0x88, 0xb1, 0xd6, 0xd9, 0x38, 0x3b, 0xfd, 0x2, 0x93, 0xce, + 0x97, 0xa1, 0xb7, 0x3f, 0xd, 0x1a, 0x97, 0xe6, 0x63, 0x10, 0x35, 0x68, 0xf9, 0xb1, 0xec}; - uint8_t buf[24] = {0}; + uint8_t buf[55] = {0}; - uint8_t topic_bytes[] = {0x36, 0x3a, 0xe5, 0x3c, 0xd9, 0xeb, 0xb4}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x49, 0xa8, 0x50, 0x48, 0xd5, 0xf5, 0x5d, 0x3c, 0xcb, 0x8e, 0xff, 0x93, 0x22, 0xfb}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x79}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x88, 0xb1, 0xd6, 0xd9, 0x38, 0x3b, 0xfd, 0x2, 0x93, 0xce, 0x97, 0xa1, 0xb7, + 0x3f, 0xd, 0x1a, 0x97, 0xe6, 0x63, 0x10, 0x35, 0x68, 0xf9, 0xb1, 0xec}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 25; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 21683, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 23705, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// ",l\239A\255.e\128\238\190\EOT\216\240\231", _pubPktID = 0, _pubBody = -// "\ENQ\DC3z\234.f[;\DC2\214i0\161P\251\171\160\RS\180\222J\202\191\DC2(.", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(cp\130q\251\181\SUB\133\251\228jBh\139\191\SOH\192\213\219Q1", _pubPktID = 14770, _pubBody = +// "\155j|4h\141\198\RS\162\240\168]\208C", _pubProps = []} TEST(Publish311QCTest, Encode79) { - uint8_t pkt[] = {0x31, 0x2a, 0x0, 0xe, 0x2c, 0x6c, 0xef, 0x41, 0xff, 0x2e, 0x65, 0x80, 0xee, 0xbe, 0x4, - 0xd8, 0xf0, 0xe7, 0x5, 0x13, 0x7a, 0xea, 0x2e, 0x66, 0x5b, 0x3b, 0x12, 0xd6, 0x69, 0x30, - 0xa1, 0x50, 0xfb, 0xab, 0xa0, 0x1e, 0xb4, 0xde, 0x4a, 0xca, 0xbf, 0x12, 0x28, 0x2e}; + uint8_t pkt[] = {0x3a, 0x28, 0x0, 0x16, 0x28, 0x63, 0x70, 0x82, 0x71, 0xfb, 0xb5, 0x1a, 0x85, 0xfb, + 0xe4, 0x6a, 0x42, 0x68, 0x8b, 0xbf, 0x1, 0xc0, 0xd5, 0xdb, 0x51, 0x31, 0x39, 0xb2, + 0x9b, 0x6a, 0x7c, 0x34, 0x68, 0x8d, 0xc6, 0x1e, 0xa2, 0xf0, 0xa8, 0x5d, 0xd0, 0x43}; - uint8_t buf[54] = {0}; + uint8_t buf[52] = {0}; - uint8_t topic_bytes[] = {0x2c, 0x6c, 0xef, 0x41, 0xff, 0x2e, 0x65, 0x80, 0xee, 0xbe, 0x4, 0xd8, 0xf0, 0xe7}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x28, 0x63, 0x70, 0x82, 0x71, 0xfb, 0xb5, 0x1a, 0x85, 0xfb, 0xe4, + 0x6a, 0x42, 0x68, 0x8b, 0xbf, 0x1, 0xc0, 0xd5, 0xdb, 0x51, 0x31}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x5, 0x13, 0x7a, 0xea, 0x2e, 0x66, 0x5b, 0x3b, 0x12, 0xd6, 0x69, 0x30, 0xa1, - 0x50, 0xfb, 0xab, 0xa0, 0x1e, 0xb4, 0xde, 0x4a, 0xca, 0xbf, 0x12, 0x28, 0x2e}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x9b, 0x6a, 0x7c, 0x34, 0x68, 0x8d, 0xc6, 0x1e, 0xa2, 0xf0, 0xa8, 0x5d, 0xd0, 0x43}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 14; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 14770, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\179\182\194\v\149\131\&4\177\175cM\153\251\204B\RS\231\170n}y\198\197)\250\203\147\151\211\138", _pubPktID = 1399, -// _pubBody = "\156\228\194pPo\189\&6\255\NAK\245-\151\170\DC3;\191\196\136\241\191\255V\146`\250\183\234>\138", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "4\USH\SYN\210z\160\141\155\238\230\171\a\233\243\192t", _pubPktID = 24524, _pubBody = +// "%\173_\207\173p\210\131\129\ESC\231\SOH\143\255\163\&4\182?LS", _pubProps = []} TEST(Publish311QCTest, Encode80) { - uint8_t pkt[] = {0x3b, 0x40, 0x0, 0x1e, 0xb3, 0xb6, 0xc2, 0xb, 0x95, 0x83, 0x34, 0xb1, 0xaf, 0x63, 0x4d, 0x99, 0xfb, - 0xcc, 0x42, 0x1e, 0xe7, 0xaa, 0x6e, 0x7d, 0x79, 0xc6, 0xc5, 0x29, 0xfa, 0xcb, 0x93, 0x97, 0xd3, 0x8a, - 0x5, 0x77, 0x9c, 0xe4, 0xc2, 0x70, 0x50, 0x6f, 0xbd, 0x36, 0xff, 0x15, 0xf5, 0x2d, 0x97, 0xaa, 0x13, - 0x3b, 0xbf, 0xc4, 0x88, 0xf1, 0xbf, 0xff, 0x56, 0x92, 0x60, 0xfa, 0xb7, 0xea, 0x3e, 0x8a}; + uint8_t pkt[] = {0x3a, 0x29, 0x0, 0x11, 0x34, 0x1f, 0x48, 0x16, 0xd2, 0x7a, 0xa0, 0x8d, 0x9b, 0xee, 0xe6, + 0xab, 0x7, 0xe9, 0xf3, 0xc0, 0x74, 0x5f, 0xcc, 0x25, 0xad, 0x5f, 0xcf, 0xad, 0x70, 0xd2, + 0x83, 0x81, 0x1b, 0xe7, 0x1, 0x8f, 0xff, 0xa3, 0x34, 0xb6, 0x3f, 0x4c, 0x53}; - uint8_t buf[76] = {0}; + uint8_t buf[53] = {0}; - uint8_t topic_bytes[] = {0xb3, 0xb6, 0xc2, 0xb, 0x95, 0x83, 0x34, 0xb1, 0xaf, 0x63, 0x4d, 0x99, 0xfb, 0xcc, 0x42, - 0x1e, 0xe7, 0xaa, 0x6e, 0x7d, 0x79, 0xc6, 0xc5, 0x29, 0xfa, 0xcb, 0x93, 0x97, 0xd3, 0x8a}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x34, 0x1f, 0x48, 0x16, 0xd2, 0x7a, 0xa0, 0x8d, 0x9b, + 0xee, 0xe6, 0xab, 0x7, 0xe9, 0xf3, 0xc0, 0x74}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x9c, 0xe4, 0xc2, 0x70, 0x50, 0x6f, 0xbd, 0x36, 0xff, 0x15, 0xf5, 0x2d, 0x97, 0xaa, 0x13, - 0x3b, 0xbf, 0xc4, 0x88, 0xf1, 0xbf, 0xff, 0x56, 0x92, 0x60, 0xfa, 0xb7, 0xea, 0x3e, 0x8a}; + msg.retained = false; + uint8_t msg_bytes[] = {0x25, 0xad, 0x5f, 0xcf, 0xad, 0x70, 0xd2, 0x83, 0x81, 0x1b, + 0xe7, 0x1, 0x8f, 0xff, 0xa3, 0x34, 0xb6, 0x3f, 0x4c, 0x53}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 20; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1399, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 24524, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\183\185o\230@UI=\142/\201\188\216sZ\ESC\b\"\182\202\NAKU$`\181\rE\194t\f", _pubPktID = 17758, _pubBody = -// "\251~\215\217\SOH\189L!\244\EM\212\246_\154\185\179.\187\EOTE\242\169", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\214u\192\231\177\&7\SYN\253\141i\217\&0\158", _pubPktID = 0, _pubBody = +// "\169\SI\241H\190p\151Qw\209\217/\163\156\&5", _pubProps = []} TEST(Publish311QCTest, Encode81) { - uint8_t pkt[] = {0x33, 0x38, 0x0, 0x1e, 0xb7, 0xb9, 0x6f, 0xe6, 0x40, 0x55, 0x49, 0x3d, 0x8e, 0x2f, 0xc9, - 0xbc, 0xd8, 0x73, 0x5a, 0x1b, 0x8, 0x22, 0xb6, 0xca, 0x15, 0x55, 0x24, 0x60, 0xb5, 0xd, - 0x45, 0xc2, 0x74, 0xc, 0x45, 0x5e, 0xfb, 0x7e, 0xd7, 0xd9, 0x1, 0xbd, 0x4c, 0x21, 0xf4, - 0x19, 0xd4, 0xf6, 0x5f, 0x9a, 0xb9, 0xb3, 0x2e, 0xbb, 0x4, 0x45, 0xf2, 0xa9}; + uint8_t pkt[] = {0x39, 0x1e, 0x0, 0xd, 0xd6, 0x75, 0xc0, 0xe7, 0xb1, 0x37, 0x16, 0xfd, 0x8d, 0x69, 0xd9, 0x30, + 0x9e, 0xa9, 0xf, 0xf1, 0x48, 0xbe, 0x70, 0x97, 0x51, 0x77, 0xd1, 0xd9, 0x2f, 0xa3, 0x9c, 0x35}; - uint8_t buf[68] = {0}; + uint8_t buf[42] = {0}; - uint8_t topic_bytes[] = {0xb7, 0xb9, 0x6f, 0xe6, 0x40, 0x55, 0x49, 0x3d, 0x8e, 0x2f, 0xc9, 0xbc, 0xd8, 0x73, 0x5a, - 0x1b, 0x8, 0x22, 0xb6, 0xca, 0x15, 0x55, 0x24, 0x60, 0xb5, 0xd, 0x45, 0xc2, 0x74, 0xc}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xd6, 0x75, 0xc0, 0xe7, 0xb1, 0x37, 0x16, 0xfd, 0x8d, 0x69, 0xd9, 0x30, 0x9e}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xfb, 0x7e, 0xd7, 0xd9, 0x1, 0xbd, 0x4c, 0x21, 0xf4, 0x19, 0xd4, - 0xf6, 0x5f, 0x9a, 0xb9, 0xb3, 0x2e, 0xbb, 0x4, 0x45, 0xf2, 0xa9}; + uint8_t msg_bytes[] = {0xa9, 0xf, 0xf1, 0x48, 0xbe, 0x70, 0x97, 0x51, 0x77, 0xd1, 0xd9, 0x2f, 0xa3, 0x9c, 0x35}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 15; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17758, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "", _pubPktID = 3165, _pubBody = -// "\168'\DC2\253\238;d\144\231\186\152t\206\166", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NUL%\184|4\245A", _pubPktID = 9669, +// _pubBody = "\170\148\223\170\SOH\189\188m;\173\149\203\NUL_B\STX\209\128\FSH\211\202R*$\DC4\t\241J", _pubProps = []} TEST(Publish311QCTest, Encode82) { - uint8_t pkt[] = {0x3d, 0x12, 0x0, 0x0, 0xc, 0x5d, 0xa8, 0x27, 0x12, 0xfd, - 0xee, 0x3b, 0x64, 0x90, 0xe7, 0xba, 0x98, 0x74, 0xce, 0xa6}; + uint8_t pkt[] = {0x3a, 0x28, 0x0, 0x7, 0x0, 0x25, 0xb8, 0x7c, 0x34, 0xf5, 0x41, 0x25, 0xc5, 0xaa, + 0x94, 0xdf, 0xaa, 0x1, 0xbd, 0xbc, 0x6d, 0x3b, 0xad, 0x95, 0xcb, 0x0, 0x5f, 0x42, + 0x2, 0xd1, 0x80, 0x1c, 0x48, 0xd3, 0xca, 0x52, 0x2a, 0x24, 0x14, 0x9, 0xf1, 0x4a}; - uint8_t buf[30] = {0}; + uint8_t buf[52] = {0}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x0, 0x25, 0xb8, 0x7c, 0x34, 0xf5, 0x41}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa8, 0x27, 0x12, 0xfd, 0xee, 0x3b, 0x64, 0x90, 0xe7, 0xba, 0x98, 0x74, 0xce, 0xa6}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xaa, 0x94, 0xdf, 0xaa, 0x1, 0xbd, 0xbc, 0x6d, 0x3b, 0xad, 0x95, 0xcb, 0x0, 0x5f, 0x42, + 0x2, 0xd1, 0x80, 0x1c, 0x48, 0xd3, 0xca, 0x52, 0x2a, 0x24, 0x14, 0x9, 0xf1, 0x4a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 29; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 3165, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 9669, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\GS\DC2", _pubPktID = 7799, _pubBody -// = "\138\249b\fd \199\239\220\147\235\233\214\152\139\130Q\163v?ZrG\215\139\236\184\230y", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = " +// o\209~\209\242\176\161LlEV\DC1\133\143\237'Y6\212\133H\a\241\&0a", _pubPktID = 1466, _pubBody = +// "0\192\223\GS\205\153\241>N\167\&8l\DC4\151x\170\229\FS\DC3s\128\135\222", _pubProps = []} TEST(Publish311QCTest, Encode83) { - uint8_t pkt[] = {0x3a, 0x23, 0x0, 0x2, 0x1d, 0x12, 0x1e, 0x77, 0x8a, 0xf9, 0x62, 0xc, 0x64, - 0x20, 0xc7, 0xef, 0xdc, 0x93, 0xeb, 0xe9, 0xd6, 0x98, 0x8b, 0x82, 0x51, 0xa3, - 0x76, 0x3f, 0x5a, 0x72, 0x47, 0xd7, 0x8b, 0xec, 0xb8, 0xe6, 0x79}; + uint8_t pkt[] = {0x33, 0x35, 0x0, 0x1a, 0x20, 0x6f, 0xd1, 0x7e, 0xd1, 0xf2, 0xb0, 0xa1, 0x4c, 0x6c, + 0x45, 0x56, 0x11, 0x85, 0x8f, 0xed, 0x27, 0x59, 0x36, 0xd4, 0x85, 0x48, 0x7, 0xf1, + 0x30, 0x61, 0x5, 0xba, 0x30, 0xc0, 0xdf, 0x1d, 0xcd, 0x99, 0xf1, 0x3e, 0x4e, 0xa7, + 0x38, 0x6c, 0x14, 0x97, 0x78, 0xaa, 0xe5, 0x1c, 0x13, 0x73, 0x80, 0x87, 0xde}; - uint8_t buf[47] = {0}; + uint8_t buf[65] = {0}; - uint8_t topic_bytes[] = {0x1d, 0x12}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x20, 0x6f, 0xd1, 0x7e, 0xd1, 0xf2, 0xb0, 0xa1, 0x4c, 0x6c, 0x45, 0x56, 0x11, + 0x85, 0x8f, 0xed, 0x27, 0x59, 0x36, 0xd4, 0x85, 0x48, 0x7, 0xf1, 0x30, 0x61}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x8a, 0xf9, 0x62, 0xc, 0x64, 0x20, 0xc7, 0xef, 0xdc, 0x93, 0xeb, 0xe9, 0xd6, 0x98, 0x8b, - 0x82, 0x51, 0xa3, 0x76, 0x3f, 0x5a, 0x72, 0x47, 0xd7, 0x8b, 0xec, 0xb8, 0xe6, 0x79}; + msg.retained = true; + uint8_t msg_bytes[] = {0x30, 0xc0, 0xdf, 0x1d, 0xcd, 0x99, 0xf1, 0x3e, 0x4e, 0xa7, 0x38, 0x6c, + 0x14, 0x97, 0x78, 0xaa, 0xe5, 0x1c, 0x13, 0x73, 0x80, 0x87, 0xde}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 23; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7799, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1466, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\208\187K.", _pubPktID = 29034, -// _pubBody = "\221\ACK\199\144\EOTv\ACK\217\\", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\201%\197.\f\247\DC3\198kM\237D\184\RS\ENQ<\183\215\RS\217\200", _pubPktID = 0, _pubBody = ">@1E\209$\188\249zd", +// _pubProps = []} TEST(Publish311QCTest, Encode84) { - uint8_t pkt[] = {0x3b, 0x11, 0x0, 0x4, 0xd0, 0xbb, 0x4b, 0x2e, 0x71, 0x6a, - 0xdd, 0x6, 0xc7, 0x90, 0x4, 0x76, 0x6, 0xd9, 0x5c}; + uint8_t pkt[] = {0x30, 0x21, 0x0, 0x15, 0xc9, 0x25, 0xc5, 0x2e, 0xc, 0xf7, 0x13, 0xc6, + 0x6b, 0x4d, 0xed, 0x44, 0xb8, 0x1e, 0x5, 0x3c, 0xb7, 0xd7, 0x1e, 0xd9, + 0xc8, 0x3e, 0x40, 0x31, 0x45, 0xd1, 0x24, 0xbc, 0xf9, 0x7a, 0x64}; - uint8_t buf[29] = {0}; + uint8_t buf[45] = {0}; - uint8_t topic_bytes[] = {0xd0, 0xbb, 0x4b, 0x2e}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xc9, 0x25, 0xc5, 0x2e, 0xc, 0xf7, 0x13, 0xc6, 0x6b, 0x4d, 0xed, + 0x44, 0xb8, 0x1e, 0x5, 0x3c, 0xb7, 0xd7, 0x1e, 0xd9, 0xc8}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xdd, 0x6, 0xc7, 0x90, 0x4, 0x76, 0x6, 0xd9, 0x5c}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x3e, 0x40, 0x31, 0x45, 0xd1, 0x24, 0xbc, 0xf9, 0x7a, 0x64}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 10; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29034, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201y\171\155\184C", _pubPktID = 0, -// _pubBody = "\180\178\&2\194\SUB5Z\254\US\217\144\t:4a\154\203\201\ETX\DC3\246_[<\224", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\ACK\180\\\144\214%\183\192\168\129", +// _pubPktID = 5193, _pubBody = "\SOH\135\136&\\\133\174\132\244\244\"", _pubProps = []} TEST(Publish311QCTest, Encode85) { - uint8_t pkt[] = {0x38, 0x21, 0x0, 0x6, 0xc9, 0x79, 0xab, 0x9b, 0xb8, 0x43, 0xb4, 0xb2, - 0x32, 0xc2, 0x1a, 0x35, 0x5a, 0xfe, 0x1f, 0xd9, 0x90, 0x9, 0x3a, 0x34, - 0x61, 0x9a, 0xcb, 0xc9, 0x3, 0x13, 0xf6, 0x5f, 0x5b, 0x3c, 0xe0}; + uint8_t pkt[] = {0x3b, 0x19, 0x0, 0xa, 0x6, 0xb4, 0x5c, 0x90, 0xd6, 0x25, 0xb7, 0xc0, 0xa8, 0x81, + 0x14, 0x49, 0x1, 0x87, 0x88, 0x26, 0x5c, 0x85, 0xae, 0x84, 0xf4, 0xf4, 0x22}; - uint8_t buf[45] = {0}; + uint8_t buf[37] = {0}; - uint8_t topic_bytes[] = {0xc9, 0x79, 0xab, 0x9b, 0xb8, 0x43}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x6, 0xb4, 0x5c, 0x90, 0xd6, 0x25, 0xb7, 0xc0, 0xa8, 0x81}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xb4, 0xb2, 0x32, 0xc2, 0x1a, 0x35, 0x5a, 0xfe, 0x1f, 0xd9, 0x90, 0x9, 0x3a, - 0x34, 0x61, 0x9a, 0xcb, 0xc9, 0x3, 0x13, 0xf6, 0x5f, 0x5b, 0x3c, 0xe0}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x1, 0x87, 0x88, 0x26, 0x5c, 0x85, 0xae, 0x84, 0xf4, 0xf4, 0x22}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 11; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5193, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "}q\213-\168\195\252$\139j^\DC1o\198\RS\172\159q", _pubPktID = 8388, _pubBody = "\196\&7\f\aA\EOT", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\235c\197\&9\FS\179\195b6\STX\195n\216\&3\213\vpu\137v\147o\200\233", _pubPktID = 40, _pubBody = +// "\150\169\128N}\US\133\146\160\ENQ\253N\247", _pubProps = []} TEST(Publish311QCTest, Encode86) { - uint8_t pkt[] = {0x32, 0x1c, 0x0, 0x12, 0x7d, 0x71, 0xd5, 0x2d, 0xa8, 0xc3, 0xfc, 0x24, 0x8b, 0x6a, 0x5e, - 0x11, 0x6f, 0xc6, 0x1e, 0xac, 0x9f, 0x71, 0x20, 0xc4, 0xc4, 0x37, 0xc, 0x7, 0x41, 0x4}; + uint8_t pkt[] = {0x35, 0x29, 0x0, 0x18, 0xeb, 0x63, 0xc5, 0x39, 0x1c, 0xb3, 0xc3, 0x62, 0x36, 0x2, 0xc3, + 0x6e, 0xd8, 0x33, 0xd5, 0xb, 0x70, 0x75, 0x89, 0x76, 0x93, 0x6f, 0xc8, 0xe9, 0x0, 0x28, + 0x96, 0xa9, 0x80, 0x4e, 0x7d, 0x1f, 0x85, 0x92, 0xa0, 0x5, 0xfd, 0x4e, 0xf7}; - uint8_t buf[40] = {0}; + uint8_t buf[53] = {0}; - uint8_t topic_bytes[] = {0x7d, 0x71, 0xd5, 0x2d, 0xa8, 0xc3, 0xfc, 0x24, 0x8b, - 0x6a, 0x5e, 0x11, 0x6f, 0xc6, 0x1e, 0xac, 0x9f, 0x71}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xeb, 0x63, 0xc5, 0x39, 0x1c, 0xb3, 0xc3, 0x62, 0x36, 0x2, 0xc3, 0x6e, + 0xd8, 0x33, 0xd5, 0xb, 0x70, 0x75, 0x89, 0x76, 0x93, 0x6f, 0xc8, 0xe9}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xc4, 0x37, 0xc, 0x7, 0x41, 0x4}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x96, 0xa9, 0x80, 0x4e, 0x7d, 0x1f, 0x85, 0x92, 0xa0, 0x5, 0xfd, 0x4e, 0xf7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 13; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8388, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 40, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\214\177\ETBL\143\b\216", _pubPktID -// = 466, _pubBody = "sz\183u\DC3:\199\242\216%\137\EM\a\203\242\209\144\194fR6\240\163&\200H", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\SIM;=\ETX\220\ETX\214o\159\228\157\195\144\184+\216gpE\208\DC3\228\211\238W\212\&2", _pubPktID = 0, _pubBody = +// "\ETX\175\STXN\144\216\212\205c\184|\142\&5i", _pubProps = []} TEST(Publish311QCTest, Encode87) { - uint8_t pkt[] = {0x34, 0x25, 0x0, 0x7, 0xd6, 0xb1, 0x17, 0x4c, 0x8f, 0x8, 0xd8, 0x1, 0xd2, - 0x73, 0x7a, 0xb7, 0x75, 0x13, 0x3a, 0xc7, 0xf2, 0xd8, 0x25, 0x89, 0x19, 0x7, - 0xcb, 0xf2, 0xd1, 0x90, 0xc2, 0x66, 0x52, 0x36, 0xf0, 0xa3, 0x26, 0xc8, 0x48}; + uint8_t pkt[] = {0x31, 0x2c, 0x0, 0x1c, 0xf, 0x4d, 0x3b, 0x3d, 0x3, 0xdc, 0x3, 0xd6, 0x6f, 0x9f, 0xe4, 0x9d, + 0xc3, 0x90, 0xb8, 0x2b, 0xd8, 0x67, 0x70, 0x45, 0xd0, 0x13, 0xe4, 0xd3, 0xee, 0x57, 0xd4, 0x32, + 0x3, 0xaf, 0x2, 0x4e, 0x90, 0xd8, 0xd4, 0xcd, 0x63, 0xb8, 0x7c, 0x8e, 0x35, 0x69}; - uint8_t buf[49] = {0}; + uint8_t buf[56] = {0}; - uint8_t topic_bytes[] = {0xd6, 0xb1, 0x17, 0x4c, 0x8f, 0x8, 0xd8}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xf, 0x4d, 0x3b, 0x3d, 0x3, 0xdc, 0x3, 0xd6, 0x6f, 0x9f, 0xe4, 0x9d, 0xc3, 0x90, + 0xb8, 0x2b, 0xd8, 0x67, 0x70, 0x45, 0xd0, 0x13, 0xe4, 0xd3, 0xee, 0x57, 0xd4, 0x32}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x73, 0x7a, 0xb7, 0x75, 0x13, 0x3a, 0xc7, 0xf2, 0xd8, 0x25, 0x89, 0x19, 0x7, - 0xcb, 0xf2, 0xd1, 0x90, 0xc2, 0x66, 0x52, 0x36, 0xf0, 0xa3, 0x26, 0xc8, 0x48}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x3, 0xaf, 0x2, 0x4e, 0x90, 0xd8, 0xd4, 0xcd, 0x63, 0xb8, 0x7c, 0x8e, 0x35, 0x69}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 14; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 466, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\STX\213\240cI\204T-w\154\192|#=\254P\DC24\200\170\228\NUL\186\147/\225\193\b\FS\140", _pubPktID = 26668, _pubBody = -// ".T\237(\238\DELg0 \GS\STX\215*\156\169t\147\b\206\149\172\r\211\RS\205 5\US\t0", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "p\185X\177s\138d\DLE.", _pubPktID = +// 29654, _pubBody = "\195o\ndF\GS\152\131\191\195;\253\248+\187y\251\129 4\244\145", _pubProps = []} TEST(Publish311QCTest, Encode88) { - uint8_t pkt[] = {0x33, 0x40, 0x0, 0x1e, 0x2, 0xd5, 0xf0, 0x63, 0x49, 0xcc, 0x54, 0x2d, 0x77, 0x9a, 0xc0, 0x7c, 0x23, - 0x3d, 0xfe, 0x50, 0x12, 0x34, 0xc8, 0xaa, 0xe4, 0x0, 0xba, 0x93, 0x2f, 0xe1, 0xc1, 0x8, 0x1c, 0x8c, - 0x68, 0x2c, 0x2e, 0x54, 0xed, 0x28, 0xee, 0x7f, 0x67, 0x30, 0x20, 0x1d, 0x2, 0xd7, 0x2a, 0x9c, 0xa9, - 0x74, 0x93, 0x8, 0xce, 0x95, 0xac, 0xd, 0xd3, 0x1e, 0xcd, 0x20, 0x35, 0x1f, 0x9, 0x30}; + uint8_t pkt[] = {0x3c, 0x23, 0x0, 0x9, 0x70, 0xb9, 0x58, 0xb1, 0x73, 0x8a, 0x64, 0x10, 0x2e, + 0x73, 0xd6, 0xc3, 0x6f, 0xa, 0x64, 0x46, 0x1d, 0x98, 0x83, 0xbf, 0xc3, 0x3b, + 0xfd, 0xf8, 0x2b, 0xbb, 0x79, 0xfb, 0x81, 0x20, 0x34, 0xf4, 0x91}; - uint8_t buf[76] = {0}; + uint8_t buf[47] = {0}; - uint8_t topic_bytes[] = {0x2, 0xd5, 0xf0, 0x63, 0x49, 0xcc, 0x54, 0x2d, 0x77, 0x9a, 0xc0, 0x7c, 0x23, 0x3d, 0xfe, - 0x50, 0x12, 0x34, 0xc8, 0xaa, 0xe4, 0x0, 0xba, 0x93, 0x2f, 0xe1, 0xc1, 0x8, 0x1c, 0x8c}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x70, 0xb9, 0x58, 0xb1, 0x73, 0x8a, 0x64, 0x10, 0x2e}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x2e, 0x54, 0xed, 0x28, 0xee, 0x7f, 0x67, 0x30, 0x20, 0x1d, 0x2, 0xd7, 0x2a, 0x9c, 0xa9, - 0x74, 0x93, 0x8, 0xce, 0x95, 0xac, 0xd, 0xd3, 0x1e, 0xcd, 0x20, 0x35, 0x1f, 0x9, 0x30}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xc3, 0x6f, 0xa, 0x64, 0x46, 0x1d, 0x98, 0x83, 0xbf, 0xc3, 0x3b, + 0xfd, 0xf8, 0x2b, 0xbb, 0x79, 0xfb, 0x81, 0x20, 0x34, 0xf4, 0x91}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 22; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 26668, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29654, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\"X\209\155% -// \FS1[\178\SI\134\232\SI\236n\212\r\FS", _pubPktID = 0, _pubBody = -// "`\190\143p\n\134\145\250\152\151,\233\245\224\143\FS\235_/\133\203", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\238\SYN\GSq4\148\154&", _pubPktID +// = 4746, _pubBody = "", _pubProps = []} TEST(Publish311QCTest, Encode89) { - uint8_t pkt[] = {0x39, 0x2a, 0x0, 0x13, 0x22, 0x58, 0xd1, 0x9b, 0x25, 0x20, 0x1c, 0x31, 0x5b, 0xb2, 0xf, - 0x86, 0xe8, 0xf, 0xec, 0x6e, 0xd4, 0xd, 0x1c, 0x60, 0xbe, 0x8f, 0x70, 0xa, 0x86, 0x91, - 0xfa, 0x98, 0x97, 0x2c, 0xe9, 0xf5, 0xe0, 0x8f, 0x1c, 0xeb, 0x5f, 0x2f, 0x85, 0xcb}; + uint8_t pkt[] = {0x32, 0xc, 0x0, 0x8, 0xee, 0x16, 0x1d, 0x71, 0x34, 0x94, 0x9a, 0x26, 0x12, 0x8a}; - uint8_t buf[54] = {0}; + uint8_t buf[24] = {0}; - uint8_t topic_bytes[] = {0x22, 0x58, 0xd1, 0x9b, 0x25, 0x20, 0x1c, 0x31, 0x5b, 0xb2, - 0xf, 0x86, 0xe8, 0xf, 0xec, 0x6e, 0xd4, 0xd, 0x1c}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xee, 0x16, 0x1d, 0x71, 0x34, 0x94, 0x9a, 0x26}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x60, 0xbe, 0x8f, 0x70, 0xa, 0x86, 0x91, 0xfa, 0x98, 0x97, 0x2c, - 0xe9, 0xf5, 0xe0, 0x8f, 0x1c, 0xeb, 0x5f, 0x2f, 0x85, 0xcb}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 0; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 4746, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\175\195\208b[q\226\128\DC4'", -// _pubPktID = 14979, _pubBody = "\US", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(\217\244\EOT\224\136\232\225\248Q\237\240\138\187\152\v<\194\216B\158\SYN\158\203t\205", _pubPktID = 13686, +// _pubBody = "g\t?\199\SOHX\128\158_", _pubProps = []} TEST(Publish311QCTest, Encode90) { - uint8_t pkt[] = {0x3c, 0xf, 0x0, 0xa, 0xaf, 0xc3, 0xd0, 0x62, 0x5b, 0x71, 0xe2, 0x80, 0x14, 0x27, 0x3a, 0x83, 0x1f}; + uint8_t pkt[] = {0x32, 0x27, 0x0, 0x1a, 0x28, 0xd9, 0xf4, 0x4, 0xe0, 0x88, 0xe8, 0xe1, 0xf8, 0x51, + 0xed, 0xf0, 0x8a, 0xbb, 0x98, 0xb, 0x3c, 0xc2, 0xd8, 0x42, 0x9e, 0x16, 0x9e, 0xcb, + 0x74, 0xcd, 0x35, 0x76, 0x67, 0x9, 0x3f, 0xc7, 0x1, 0x58, 0x80, 0x9e, 0x5f}; - uint8_t buf[27] = {0}; + uint8_t buf[51] = {0}; - uint8_t topic_bytes[] = {0xaf, 0xc3, 0xd0, 0x62, 0x5b, 0x71, 0xe2, 0x80, 0x14, 0x27}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x28, 0xd9, 0xf4, 0x4, 0xe0, 0x88, 0xe8, 0xe1, 0xf8, 0x51, 0xed, 0xf0, 0x8a, + 0xbb, 0x98, 0xb, 0x3c, 0xc2, 0xd8, 0x42, 0x9e, 0x16, 0x9e, 0xcb, 0x74, 0xcd}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x1f}; + uint8_t msg_bytes[] = {0x67, 0x9, 0x3f, 0xc7, 0x1, 0x58, 0x80, 0x9e, 0x5f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 9; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 14979, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 13686, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\141\253\128M\210\215vFY\193c\236\174\r\155\SYN\\y", _pubPktID = 16476, _pubBody = "\DEL\250\&0\179-", _pubProps = -// []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "FL\240\156\182\192\&3\212\166\234!\162i#\233\190}'N\176", _pubPktID = 7951, _pubBody = +// "\246\168g\152\239\&8\214\227\217R=w3\173\155\210Y\155@", _pubProps = []} TEST(Publish311QCTest, Encode91) { - uint8_t pkt[] = {0x3b, 0x1b, 0x0, 0x12, 0x8d, 0xfd, 0x80, 0x4d, 0xd2, 0xd7, 0x76, 0x46, 0x59, 0xc1, 0x63, - 0xec, 0xae, 0xd, 0x9b, 0x16, 0x5c, 0x79, 0x40, 0x5c, 0x7f, 0xfa, 0x30, 0xb3, 0x2d}; + uint8_t pkt[] = {0x3c, 0x2b, 0x0, 0x14, 0x46, 0x4c, 0xf0, 0x9c, 0xb6, 0xc0, 0x33, 0xd4, 0xa6, 0xea, 0x21, + 0xa2, 0x69, 0x23, 0xe9, 0xbe, 0x7d, 0x27, 0x4e, 0xb0, 0x1f, 0xf, 0xf6, 0xa8, 0x67, 0x98, + 0xef, 0x38, 0xd6, 0xe3, 0xd9, 0x52, 0x3d, 0x77, 0x33, 0xad, 0x9b, 0xd2, 0x59, 0x9b, 0x40}; - uint8_t buf[39] = {0}; + uint8_t buf[55] = {0}; - uint8_t topic_bytes[] = {0x8d, 0xfd, 0x80, 0x4d, 0xd2, 0xd7, 0x76, 0x46, 0x59, - 0xc1, 0x63, 0xec, 0xae, 0xd, 0x9b, 0x16, 0x5c, 0x79}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x46, 0x4c, 0xf0, 0x9c, 0xb6, 0xc0, 0x33, 0xd4, 0xa6, 0xea, + 0x21, 0xa2, 0x69, 0x23, 0xe9, 0xbe, 0x7d, 0x27, 0x4e, 0xb0}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x7f, 0xfa, 0x30, 0xb3, 0x2d}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xf6, 0xa8, 0x67, 0x98, 0xef, 0x38, 0xd6, 0xe3, 0xd9, 0x52, + 0x3d, 0x77, 0x33, 0xad, 0x9b, 0xd2, 0x59, 0x9b, 0x40}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + msg.payload_len = 19; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16476, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7951, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\172\236 -// #(l]\NAK\197K\GS\156j\151\195\144\235C\\\137\199*\177", _pubPktID = 24115, _pubBody = "\138", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\232\175\EOT\145\DEL\254\166\230\212MM\131\&6R\177A\217", _pubPktID = 26125, _pubBody = "\229\&1", _pubProps = []} TEST(Publish311QCTest, Encode92) { - uint8_t pkt[] = {0x3a, 0x1c, 0x0, 0x17, 0xac, 0xec, 0x20, 0x23, 0x28, 0x6c, 0x5d, 0x15, 0xc5, 0x4b, 0x1d, - 0x9c, 0x6a, 0x97, 0xc3, 0x90, 0xeb, 0x43, 0x5c, 0x89, 0xc7, 0x2a, 0xb1, 0x5e, 0x33, 0x8a}; + uint8_t pkt[] = {0x35, 0x17, 0x0, 0x11, 0xe8, 0xaf, 0x4, 0x91, 0x7f, 0xfe, 0xa6, 0xe6, 0xd4, + 0x4d, 0x4d, 0x83, 0x36, 0x52, 0xb1, 0x41, 0xd9, 0x66, 0xd, 0xe5, 0x31}; - uint8_t buf[40] = {0}; + uint8_t buf[35] = {0}; - uint8_t topic_bytes[] = {0xac, 0xec, 0x20, 0x23, 0x28, 0x6c, 0x5d, 0x15, 0xc5, 0x4b, 0x1d, 0x9c, - 0x6a, 0x97, 0xc3, 0x90, 0xeb, 0x43, 0x5c, 0x89, 0xc7, 0x2a, 0xb1}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xe8, 0xaf, 0x4, 0x91, 0x7f, 0xfe, 0xa6, 0xe6, 0xd4, + 0x4d, 0x4d, 0x83, 0x36, 0x52, 0xb1, 0x41, 0xd9}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x8a}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xe5, 0x31}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 2; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 24115, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 26125, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\SUB\250\FSj@\239n\DEL\t\158:\132\165\249\130\226L", _pubPktID = 159, _pubBody = -// "\131\140\143\172oD6\SIS\196O.\145\141\166\EOT\188\153\251U\SYNJT", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\249\223\224\153M\215\191\241/z\197=\210\196\197T-", _pubPktID = 4023, _pubBody = "\146G", _pubProps = []} TEST(Publish311QCTest, Encode93) { - uint8_t pkt[] = {0x3d, 0x2c, 0x0, 0x11, 0x1a, 0xfa, 0x1c, 0x6a, 0x40, 0xef, 0x6e, 0x7f, 0x9, 0x9e, 0x3a, 0x84, - 0xa5, 0xf9, 0x82, 0xe2, 0x4c, 0x0, 0x9f, 0x83, 0x8c, 0x8f, 0xac, 0x6f, 0x44, 0x36, 0xf, 0x53, - 0xc4, 0x4f, 0x2e, 0x91, 0x8d, 0xa6, 0x4, 0xbc, 0x99, 0xfb, 0x55, 0x16, 0x4a, 0x54}; + uint8_t pkt[] = {0x32, 0x17, 0x0, 0x11, 0xf9, 0xdf, 0xe0, 0x99, 0x4d, 0xd7, 0xbf, 0xf1, 0x2f, + 0x7a, 0xc5, 0x3d, 0xd2, 0xc4, 0xc5, 0x54, 0x2d, 0xf, 0xb7, 0x92, 0x47}; - uint8_t buf[56] = {0}; + uint8_t buf[35] = {0}; - uint8_t topic_bytes[] = {0x1a, 0xfa, 0x1c, 0x6a, 0x40, 0xef, 0x6e, 0x7f, 0x9, - 0x9e, 0x3a, 0x84, 0xa5, 0xf9, 0x82, 0xe2, 0x4c}; + uint8_t topic_bytes[] = {0xf9, 0xdf, 0xe0, 0x99, 0x4d, 0xd7, 0xbf, 0xf1, 0x2f, + 0x7a, 0xc5, 0x3d, 0xd2, 0xc4, 0xc5, 0x54, 0x2d}; lwmqtt_string_t topic = {17, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x83, 0x8c, 0x8f, 0xac, 0x6f, 0x44, 0x36, 0xf, 0x53, 0xc4, 0x4f, 0x2e, - 0x91, 0x8d, 0xa6, 0x4, 0xbc, 0x99, 0xfb, 0x55, 0x16, 0x4a, 0x54}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x92, 0x47}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 2; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 159, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 4023, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\192K\248\134\174}\198-\171\235\SUB\214]\204\&3\177\f", _pubPktID = 0, _pubBody = -// "%\131\215\218\147\225\ENQ\173Wh\129\234\197", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "1\188?\134-\151\130\165\DC3\149\&0\188\151\r\192q\134Wi\255\238\204\193\225\205\231\164", _pubPktID = 3250, _pubBody +// = "\209\151\165\147\252]\131\r\145p\242\&6\155z\255", _pubProps = []} TEST(Publish311QCTest, Encode94) { - uint8_t pkt[] = {0x38, 0x20, 0x0, 0x11, 0xc0, 0x4b, 0xf8, 0x86, 0xae, 0x7d, 0xc6, 0x2d, - 0xab, 0xeb, 0x1a, 0xd6, 0x5d, 0xcc, 0x33, 0xb1, 0xc, 0x25, 0x83, 0xd7, - 0xda, 0x93, 0xe1, 0x5, 0xad, 0x57, 0x68, 0x81, 0xea, 0xc5}; + uint8_t pkt[] = {0x35, 0x2e, 0x0, 0x1b, 0x31, 0xbc, 0x3f, 0x86, 0x2d, 0x97, 0x82, 0xa5, 0x13, 0x95, 0x30, 0xbc, + 0x97, 0xd, 0xc0, 0x71, 0x86, 0x57, 0x69, 0xff, 0xee, 0xcc, 0xc1, 0xe1, 0xcd, 0xe7, 0xa4, 0xc, + 0xb2, 0xd1, 0x97, 0xa5, 0x93, 0xfc, 0x5d, 0x83, 0xd, 0x91, 0x70, 0xf2, 0x36, 0x9b, 0x7a, 0xff}; - uint8_t buf[44] = {0}; + uint8_t buf[58] = {0}; - uint8_t topic_bytes[] = {0xc0, 0x4b, 0xf8, 0x86, 0xae, 0x7d, 0xc6, 0x2d, 0xab, - 0xeb, 0x1a, 0xd6, 0x5d, 0xcc, 0x33, 0xb1, 0xc}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x31, 0xbc, 0x3f, 0x86, 0x2d, 0x97, 0x82, 0xa5, 0x13, 0x95, 0x30, 0xbc, 0x97, 0xd, + 0xc0, 0x71, 0x86, 0x57, 0x69, 0xff, 0xee, 0xcc, 0xc1, 0xe1, 0xcd, 0xe7, 0xa4}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x25, 0x83, 0xd7, 0xda, 0x93, 0xe1, 0x5, 0xad, 0x57, 0x68, 0x81, 0xea, 0xc5}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xd1, 0x97, 0xa5, 0x93, 0xfc, 0x5d, 0x83, 0xd, 0x91, 0x70, 0xf2, 0x36, 0x9b, 0x7a, 0xff}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 15; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3250, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\161&K\GSu\164\DC1W\156\205\DC2e\US\253\SUB\212\GS\146u", _pubPktID = 4938, _pubBody = -// "\197\210\201\164\236`\GSJjyh\252c\GS\185\190\150xY\239>\220\165.", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\149y\148\SOH\133\136\STX\n\242", +// _pubPktID = 27162, _pubBody = +// "\163\212\196\ENQ\196\186w\152\RS\219\243>k~\167\130o^\157\\\197C\128\130\185\247\201\148C\197", _pubProps = []} TEST(Publish311QCTest, Encode95) { - uint8_t pkt[] = {0x3a, 0x2f, 0x0, 0x13, 0xa1, 0x26, 0x4b, 0x1d, 0x75, 0xa4, 0x11, 0x57, 0x9c, 0xcd, 0x12, 0x65, 0x1f, - 0xfd, 0x1a, 0xd4, 0x1d, 0x92, 0x75, 0x13, 0x4a, 0xc5, 0xd2, 0xc9, 0xa4, 0xec, 0x60, 0x1d, 0x4a, 0x6a, - 0x79, 0x68, 0xfc, 0x63, 0x1d, 0xb9, 0xbe, 0x96, 0x78, 0x59, 0xef, 0x3e, 0xdc, 0xa5, 0x2e}; + uint8_t pkt[] = {0x3b, 0x2b, 0x0, 0x9, 0x95, 0x79, 0x94, 0x1, 0x85, 0x88, 0x2, 0xa, 0xf2, 0x6a, 0x1a, + 0xa3, 0xd4, 0xc4, 0x5, 0xc4, 0xba, 0x77, 0x98, 0x1e, 0xdb, 0xf3, 0x3e, 0x6b, 0x7e, 0xa7, + 0x82, 0x6f, 0x5e, 0x9d, 0x5c, 0xc5, 0x43, 0x80, 0x82, 0xb9, 0xf7, 0xc9, 0x94, 0x43, 0xc5}; - uint8_t buf[59] = {0}; + uint8_t buf[55] = {0}; - uint8_t topic_bytes[] = {0xa1, 0x26, 0x4b, 0x1d, 0x75, 0xa4, 0x11, 0x57, 0x9c, 0xcd, - 0x12, 0x65, 0x1f, 0xfd, 0x1a, 0xd4, 0x1d, 0x92, 0x75}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x95, 0x79, 0x94, 0x1, 0x85, 0x88, 0x2, 0xa, 0xf2}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xc5, 0xd2, 0xc9, 0xa4, 0xec, 0x60, 0x1d, 0x4a, 0x6a, 0x79, 0x68, 0xfc, - 0x63, 0x1d, 0xb9, 0xbe, 0x96, 0x78, 0x59, 0xef, 0x3e, 0xdc, 0xa5, 0x2e}; + msg.retained = true; + uint8_t msg_bytes[] = {0xa3, 0xd4, 0xc4, 0x5, 0xc4, 0xba, 0x77, 0x98, 0x1e, 0xdb, 0xf3, 0x3e, 0x6b, 0x7e, 0xa7, + 0x82, 0x6f, 0x5e, 0x9d, 0x5c, 0xc5, 0x43, 0x80, 0x82, 0xb9, 0xf7, 0xc9, 0x94, 0x43, 0xc5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 30; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 4938, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 27162, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\149\203\181S\"+\168\160\141\DEL~e8\150\193\SYN\t1", _pubPktID = 0, _pubBody = "m#Za\252\192\201Y\NAK\221", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\133\236\215", _pubPktID = 29262, +// _pubBody = "\150|7\US\164%\USi\129\ACK\161\142\139\207", _pubProps = []} TEST(Publish311QCTest, Encode96) { - uint8_t pkt[] = {0x38, 0x1e, 0x0, 0x12, 0x95, 0xcb, 0xb5, 0x53, 0x22, 0x2b, 0xa8, 0xa0, 0x8d, 0x7f, 0x7e, 0x65, - 0x38, 0x96, 0xc1, 0x16, 0x9, 0x31, 0x6d, 0x23, 0x5a, 0x61, 0xfc, 0xc0, 0xc9, 0x59, 0x15, 0xdd}; + uint8_t pkt[] = {0x35, 0x15, 0x0, 0x3, 0x85, 0xec, 0xd7, 0x72, 0x4e, 0x96, 0x7c, 0x37, + 0x1f, 0xa4, 0x25, 0x1f, 0x69, 0x81, 0x6, 0xa1, 0x8e, 0x8b, 0xcf}; - uint8_t buf[42] = {0}; + uint8_t buf[33] = {0}; - uint8_t topic_bytes[] = {0x95, 0xcb, 0xb5, 0x53, 0x22, 0x2b, 0xa8, 0xa0, 0x8d, - 0x7f, 0x7e, 0x65, 0x38, 0x96, 0xc1, 0x16, 0x9, 0x31}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x85, 0xec, 0xd7}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x6d, 0x23, 0x5a, 0x61, 0xfc, 0xc0, 0xc9, 0x59, 0x15, 0xdd}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x96, 0x7c, 0x37, 0x1f, 0xa4, 0x25, 0x1f, 0x69, 0x81, 0x6, 0xa1, 0x8e, 0x8b, 0xcf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + msg.payload_len = 14; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29262, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\254\DLE\200m\251\190\157\139\&9=\175\219\238~:ap/{\148", _pubPktID = 0, _pubBody = "\163~rt", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "5b0\195\142R\129\205", _pubPktID = +// 25975, _pubBody = ":\135\203\145\&6\148\180\155\&28\243", _pubProps = []} TEST(Publish311QCTest, Encode97) { - uint8_t pkt[] = {0x38, 0x1a, 0x0, 0x14, 0xfe, 0x10, 0xc8, 0x6d, 0xfb, 0xbe, 0x9d, 0x8b, 0x39, 0x3d, - 0xaf, 0xdb, 0xee, 0x7e, 0x3a, 0x61, 0x70, 0x2f, 0x7b, 0x94, 0xa3, 0x7e, 0x72, 0x74}; + uint8_t pkt[] = {0x33, 0x17, 0x0, 0x8, 0x35, 0x62, 0x30, 0xc3, 0x8e, 0x52, 0x81, 0xcd, 0x65, + 0x77, 0x3a, 0x87, 0xcb, 0x91, 0x36, 0x94, 0xb4, 0x9b, 0x32, 0x38, 0xf3}; - uint8_t buf[38] = {0}; + uint8_t buf[35] = {0}; - uint8_t topic_bytes[] = {0xfe, 0x10, 0xc8, 0x6d, 0xfb, 0xbe, 0x9d, 0x8b, 0x39, 0x3d, - 0xaf, 0xdb, 0xee, 0x7e, 0x3a, 0x61, 0x70, 0x2f, 0x7b, 0x94}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x35, 0x62, 0x30, 0xc3, 0x8e, 0x52, 0x81, 0xcd}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xa3, 0x7e, 0x72, 0x74}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x3a, 0x87, 0xcb, 0x91, 0x36, 0x94, 0xb4, 0x9b, 0x32, 0x38, 0xf3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 11; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25975, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\253a\DC4gD\189tvCr\177\&0w\132", -// _pubPktID = 26, _pubBody = "\188\SOx\169\171\214_\225\142.\SIW\SO\149\GS\184M\199\137\174\128cS\187OBD\139\218", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\213Jr\201\234\223\158\NULA\172F$x\203\226", _pubPktID = 5740, _pubBody = +// "\v\DC4\158\192\171F\249\ESC\192U\254\"\152\151", _pubProps = []} TEST(Publish311QCTest, Encode98) { - uint8_t pkt[] = {0x3a, 0x2f, 0x0, 0xe, 0xfd, 0x61, 0x14, 0x67, 0x44, 0xbd, 0x74, 0x76, 0x43, 0x72, 0xb1, 0x30, 0x77, - 0x84, 0x0, 0x1a, 0xbc, 0xe, 0x78, 0xa9, 0xab, 0xd6, 0x5f, 0xe1, 0x8e, 0x2e, 0xf, 0x57, 0xe, 0x95, - 0x1d, 0xb8, 0x4d, 0xc7, 0x89, 0xae, 0x80, 0x63, 0x53, 0xbb, 0x4f, 0x42, 0x44, 0x8b, 0xda}; + uint8_t pkt[] = {0x3b, 0x21, 0x0, 0xf, 0xd5, 0x4a, 0x72, 0xc9, 0xea, 0xdf, 0x9e, 0x0, + 0x41, 0xac, 0x46, 0x24, 0x78, 0xcb, 0xe2, 0x16, 0x6c, 0xb, 0x14, 0x9e, + 0xc0, 0xab, 0x46, 0xf9, 0x1b, 0xc0, 0x55, 0xfe, 0x22, 0x98, 0x97}; - uint8_t buf[59] = {0}; + uint8_t buf[45] = {0}; - uint8_t topic_bytes[] = {0xfd, 0x61, 0x14, 0x67, 0x44, 0xbd, 0x74, 0x76, 0x43, 0x72, 0xb1, 0x30, 0x77, 0x84}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xd5, 0x4a, 0x72, 0xc9, 0xea, 0xdf, 0x9e, 0x0, 0x41, 0xac, 0x46, 0x24, 0x78, 0xcb, 0xe2}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xbc, 0xe, 0x78, 0xa9, 0xab, 0xd6, 0x5f, 0xe1, 0x8e, 0x2e, 0xf, 0x57, 0xe, 0x95, 0x1d, - 0xb8, 0x4d, 0xc7, 0x89, 0xae, 0x80, 0x63, 0x53, 0xbb, 0x4f, 0x42, 0x44, 0x8b, 0xda}; + msg.retained = true; + uint8_t msg_bytes[] = {0xb, 0x14, 0x9e, 0xc0, 0xab, 0x46, 0xf9, 0x1b, 0xc0, 0x55, 0xfe, 0x22, 0x98, 0x97}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 14; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 26, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5740, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\251\169\245\241\201;\SOH\174B\v\STX\SOH\202\137\ETX\139y\235\139\&8~b&\235", _pubPktID = 0, _pubBody = -// "O\222\143\SO\DC2\DC2\180\DC3\242\226I\151\ACKv\247\150\v\DC4\228", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\t\CAN\145\171\148w\238,P\186\ETBHJo\217H\202\133\175\171.\147\134f\238\240X\231\137", _pubPktID = 1370, _pubBody = +// "`\241\GS\145\216\168\157\253JO\171\208j1]K\RSL<\242\&4", _pubProps = []} TEST(Publish311QCTest, Encode99) { - uint8_t pkt[] = {0x39, 0x2d, 0x0, 0x18, 0xfb, 0xa9, 0xf5, 0xf1, 0xc9, 0x3b, 0x1, 0xae, 0x42, 0xb, 0x2, 0x1, - 0xca, 0x89, 0x3, 0x8b, 0x79, 0xeb, 0x8b, 0x38, 0x7e, 0x62, 0x26, 0xeb, 0x4f, 0xde, 0x8f, 0xe, - 0x12, 0x12, 0xb4, 0x13, 0xf2, 0xe2, 0x49, 0x97, 0x6, 0x76, 0xf7, 0x96, 0xb, 0x14, 0xe4}; + uint8_t pkt[] = {0x32, 0x36, 0x0, 0x1d, 0x9, 0x18, 0x91, 0xab, 0x94, 0x77, 0xee, 0x2c, 0x50, 0xba, + 0x17, 0x48, 0x4a, 0x6f, 0xd9, 0x48, 0xca, 0x85, 0xaf, 0xab, 0x2e, 0x93, 0x86, 0x66, + 0xee, 0xf0, 0x58, 0xe7, 0x89, 0x5, 0x5a, 0x60, 0xf1, 0x1d, 0x91, 0xd8, 0xa8, 0x9d, + 0xfd, 0x4a, 0x4f, 0xab, 0xd0, 0x6a, 0x31, 0x5d, 0x4b, 0x1e, 0x4c, 0x3c, 0xf2, 0x34}; - uint8_t buf[57] = {0}; + uint8_t buf[66] = {0}; - uint8_t topic_bytes[] = {0xfb, 0xa9, 0xf5, 0xf1, 0xc9, 0x3b, 0x1, 0xae, 0x42, 0xb, 0x2, 0x1, - 0xca, 0x89, 0x3, 0x8b, 0x79, 0xeb, 0x8b, 0x38, 0x7e, 0x62, 0x26, 0xeb}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x9, 0x18, 0x91, 0xab, 0x94, 0x77, 0xee, 0x2c, 0x50, 0xba, 0x17, 0x48, 0x4a, 0x6f, 0xd9, + 0x48, 0xca, 0x85, 0xaf, 0xab, 0x2e, 0x93, 0x86, 0x66, 0xee, 0xf0, 0x58, 0xe7, 0x89}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x4f, 0xde, 0x8f, 0xe, 0x12, 0x12, 0xb4, 0x13, 0xf2, 0xe2, - 0x49, 0x97, 0x6, 0x76, 0xf7, 0x96, 0xb, 0x14, 0xe4}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x60, 0xf1, 0x1d, 0x91, 0xd8, 0xa8, 0x9d, 0xfd, 0x4a, 0x4f, 0xab, + 0xd0, 0x6a, 0x31, 0x5d, 0x4b, 0x1e, 0x4c, 0x3c, 0xf2, 0x34}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 21; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1370, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\130\195\DC3\129^;\DC2\222\159\233g\190\156\&9\DC2\149t\138<\191|", _pubPktID = 0, _pubBody = -// "\145m\248\188\208:\172\v\129\EOT\158\139\132\192yQ\206S\252\152\ETBQrEx\t\ENQ^\235\139", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\164.\DC1\135\131x\231n\143\DC3\247\SYN\189D\158\166\166\171\143\129\137\215", _pubPktID = 27834, _pubBody = +// "e8`\SO\145\RS`\179\229\146", _pubProps = []} TEST(Publish311QCTest, Encode100) { - uint8_t pkt[] = {0x30, 0x35, 0x0, 0x15, 0x82, 0xc3, 0x13, 0x81, 0x5e, 0x3b, 0x12, 0xde, 0x9f, 0xe9, - 0x67, 0xbe, 0x9c, 0x39, 0x12, 0x95, 0x74, 0x8a, 0x3c, 0xbf, 0x7c, 0x91, 0x6d, 0xf8, - 0xbc, 0xd0, 0x3a, 0xac, 0xb, 0x81, 0x4, 0x9e, 0x8b, 0x84, 0xc0, 0x79, 0x51, 0xce, - 0x53, 0xfc, 0x98, 0x17, 0x51, 0x72, 0x45, 0x78, 0x9, 0x5, 0x5e, 0xeb, 0x8b}; + uint8_t pkt[] = {0x3b, 0x24, 0x0, 0x16, 0xa4, 0x2e, 0x11, 0x87, 0x83, 0x78, 0xe7, 0x6e, 0x8f, + 0x13, 0xf7, 0x16, 0xbd, 0x44, 0x9e, 0xa6, 0xa6, 0xab, 0x8f, 0x81, 0x89, 0xd7, + 0x6c, 0xba, 0x65, 0x38, 0x60, 0xe, 0x91, 0x1e, 0x60, 0xb3, 0xe5, 0x92}; - uint8_t buf[65] = {0}; + uint8_t buf[48] = {0}; - uint8_t topic_bytes[] = {0x82, 0xc3, 0x13, 0x81, 0x5e, 0x3b, 0x12, 0xde, 0x9f, 0xe9, 0x67, - 0xbe, 0x9c, 0x39, 0x12, 0x95, 0x74, 0x8a, 0x3c, 0xbf, 0x7c}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa4, 0x2e, 0x11, 0x87, 0x83, 0x78, 0xe7, 0x6e, 0x8f, 0x13, 0xf7, + 0x16, 0xbd, 0x44, 0x9e, 0xa6, 0xa6, 0xab, 0x8f, 0x81, 0x89, 0xd7}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x91, 0x6d, 0xf8, 0xbc, 0xd0, 0x3a, 0xac, 0xb, 0x81, 0x4, 0x9e, 0x8b, 0x84, 0xc0, 0x79, - 0x51, 0xce, 0x53, 0xfc, 0x98, 0x17, 0x51, 0x72, 0x45, 0x78, 0x9, 0x5, 0x5e, 0xeb, 0x8b}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x65, 0x38, 0x60, 0xe, 0x91, 0x1e, 0x60, 0xb3, 0xe5, 0x92}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 10; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, empty_props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 27834, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\136Y\192\226{\129\199E\USu\182\215\SUB'\245\DC4\171\139\NAKY", _pubPktID = 15774, _pubBody = "\255", _pubProps = -// [PropServerReference "*\172\"2WGRO\157\160<\211\203yR]\221\FS\167\DLE.\140\167U\132",PropServerReference -// "\NAK5\205\240!\219\r\254\f\198W\RS~\224\RSA",PropContentType -// "3\180K\SUB\225\135\158\b\137\130\239",PropServerReference "\133",PropWildcardSubscriptionAvailable -// 28,PropServerReference "&\t\"\195\v\139\254\232\232Q&X\202\192\196",PropCorrelationData "\187A",PropResponseTopic -// "\171\SUB\CAN\EM1\162\189\254uYT\233A\136'\195\195\v;\138t\194\148\153\nZw\189",PropMaximumPacketSize -// 20297,PropMessageExpiryInterval 28350,PropMessageExpiryInterval 1786,PropContentType -// "\173\235}$\DC4\222\167z\DC3\RS;k\180\ETB=\v2e\229$:t\b\243\243",PropServerKeepAlive 24429,PropWillDelayInterval -// 14881,PropServerKeepAlive 4484,PropRequestProblemInformation 52,PropCorrelationData -// "^\239",PropRequestResponseInformation 213,PropReasonString "\179nh28W",PropSessionExpiryInterval -// 12170,PropResponseTopic "\231\217\178\SYN",PropSessionExpiryInterval 28653,PropMessageExpiryInterval -// 23984,PropMessageExpiryInterval 23557,PropContentType "az\SUB\143\135hS\140Wx5m\SI\210\234?dR",PropRetainAvailable -// 216,PropSubscriptionIdentifier 9,PropWildcardSubscriptionAvailable 35]} -TEST(Publish50QCTest, Encode1) { +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\GS'O\GS\157L:\160!\232\238\251\210\SOH\149\247[\200\206V\228NIF", _pubPktID = 10712, _pubBody = +// "g\175\150\CANu\230<(Z\145\145 g\177\217P7\ENQ`V\167\212k\177\SUB.", _pubProps = [PropReasonString +// "\ACK\206\206\216\&0\SYN\150\147%\197;\149\141\"(\DC2>@\SI\237\215",PropServerReference +// "\153\168\222t9\240\&3\202.p\239\aF.\139i\168\221\251\"\227",PropMaximumPacketSize 27829,PropTopicAlias +// 4075,PropMessageExpiryInterval 10312,PropTopicAlias 19253,PropResponseTopic "\205\177B",PropReasonString +// "\SO\163L\178(\204\242\131\132R\213V*\175|\GS|\STX",PropTopicAlias 10427,PropSubscriptionIdentifierAvailable +// 197,PropRequestResponseInformation 111,PropServerReference +// "\142\226\140\189J\253\DC3p\220\&0F\157\170\142",PropTopicAlias 13732,PropRequestProblemInformation +// 181,PropReceiveMaximum 2850,PropMaximumQoS 66,PropWildcardSubscriptionAvailable 208,PropSharedSubscriptionAvailable +// 255]} +TEST(Publish5QCTest, Encode1) { uint8_t pkt[] = { - 0x32, 0x92, 0x2, 0x0, 0x14, 0x88, 0x59, 0xc0, 0xe2, 0x7b, 0x81, 0xc7, 0x45, 0x1f, 0x75, 0xb6, 0xd7, 0x1a, 0x27, - 0xf5, 0x14, 0xab, 0x8b, 0x15, 0x59, 0x3d, 0x9e, 0xf7, 0x1, 0x1c, 0x0, 0x19, 0x2a, 0xac, 0x22, 0x32, 0x57, 0x47, - 0x52, 0x4f, 0x9d, 0xa0, 0x3c, 0xd3, 0xcb, 0x79, 0x52, 0x5d, 0xdd, 0x1c, 0xa7, 0x10, 0x2e, 0x8c, 0xa7, 0x55, 0x84, - 0x1c, 0x0, 0x10, 0x15, 0x35, 0xcd, 0xf0, 0x21, 0xdb, 0xd, 0xfe, 0xc, 0xc6, 0x57, 0x1e, 0x7e, 0xe0, 0x1e, 0x41, - 0x3, 0x0, 0xb, 0x33, 0xb4, 0x4b, 0x1a, 0xe1, 0x87, 0x9e, 0x8, 0x89, 0x82, 0xef, 0x1c, 0x0, 0x1, 0x85, 0x28, - 0x1c, 0x1c, 0x0, 0xf, 0x26, 0x9, 0x22, 0xc3, 0xb, 0x8b, 0xfe, 0xe8, 0xe8, 0x51, 0x26, 0x58, 0xca, 0xc0, 0xc4, - 0x9, 0x0, 0x2, 0xbb, 0x41, 0x8, 0x0, 0x1c, 0xab, 0x1a, 0x18, 0x19, 0x31, 0xa2, 0xbd, 0xfe, 0x75, 0x59, 0x54, - 0xe9, 0x41, 0x88, 0x27, 0xc3, 0xc3, 0xb, 0x3b, 0x8a, 0x74, 0xc2, 0x94, 0x99, 0xa, 0x5a, 0x77, 0xbd, 0x27, 0x0, - 0x0, 0x4f, 0x49, 0x2, 0x0, 0x0, 0x6e, 0xbe, 0x2, 0x0, 0x0, 0x6, 0xfa, 0x3, 0x0, 0x19, 0xad, 0xeb, 0x7d, - 0x24, 0x14, 0xde, 0xa7, 0x7a, 0x13, 0x1e, 0x3b, 0x6b, 0xb4, 0x17, 0x3d, 0xb, 0x32, 0x65, 0xe5, 0x24, 0x3a, 0x74, - 0x8, 0xf3, 0xf3, 0x13, 0x5f, 0x6d, 0x18, 0x0, 0x0, 0x3a, 0x21, 0x13, 0x11, 0x84, 0x17, 0x34, 0x9, 0x0, 0x2, - 0x5e, 0xef, 0x19, 0xd5, 0x1f, 0x0, 0x6, 0xb3, 0x6e, 0x68, 0x32, 0x38, 0x57, 0x11, 0x0, 0x0, 0x2f, 0x8a, 0x8, - 0x0, 0x4, 0xe7, 0xd9, 0xb2, 0x16, 0x11, 0x0, 0x0, 0x6f, 0xed, 0x2, 0x0, 0x0, 0x5d, 0xb0, 0x2, 0x0, 0x0, - 0x5c, 0x5, 0x3, 0x0, 0x12, 0x61, 0x7a, 0x1a, 0x8f, 0x87, 0x68, 0x53, 0x8c, 0x57, 0x78, 0x35, 0x6d, 0xf, 0xd2, - 0xea, 0x3f, 0x64, 0x52, 0x25, 0xd8, 0xb, 0x9, 0x28, 0x23, 0xff}; - - uint8_t buf[287] = {0}; - - uint8_t topic_bytes[] = {0x88, 0x59, 0xc0, 0xe2, 0x7b, 0x81, 0xc7, 0x45, 0x1f, 0x75, - 0xb6, 0xd7, 0x1a, 0x27, 0xf5, 0x14, 0xab, 0x8b, 0x15, 0x59}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + 0x33, 0xb9, 0x1, 0x0, 0x18, 0x1d, 0x27, 0x4f, 0x1d, 0x9d, 0x4c, 0x3a, 0xa0, 0x21, 0xe8, 0xee, 0xfb, 0xd2, 0x1, + 0x95, 0xf7, 0x5b, 0xc8, 0xce, 0x56, 0xe4, 0x4e, 0x49, 0x46, 0x29, 0xd8, 0x81, 0x1, 0x1f, 0x0, 0x15, 0x6, 0xce, + 0xce, 0xd8, 0x30, 0x16, 0x96, 0x93, 0x25, 0xc5, 0x3b, 0x95, 0x8d, 0x22, 0x28, 0x12, 0x3e, 0x40, 0xf, 0xed, 0xd7, + 0x1c, 0x0, 0x15, 0x99, 0xa8, 0xde, 0x74, 0x39, 0xf0, 0x33, 0xca, 0x2e, 0x70, 0xef, 0x7, 0x46, 0x2e, 0x8b, 0x69, + 0xa8, 0xdd, 0xfb, 0x22, 0xe3, 0x27, 0x0, 0x0, 0x6c, 0xb5, 0x23, 0xf, 0xeb, 0x2, 0x0, 0x0, 0x28, 0x48, 0x23, + 0x4b, 0x35, 0x8, 0x0, 0x3, 0xcd, 0xb1, 0x42, 0x1f, 0x0, 0x12, 0xe, 0xa3, 0x4c, 0xb2, 0x28, 0xcc, 0xf2, 0x83, + 0x84, 0x52, 0xd5, 0x56, 0x2a, 0xaf, 0x7c, 0x1d, 0x7c, 0x2, 0x23, 0x28, 0xbb, 0x29, 0xc5, 0x19, 0x6f, 0x1c, 0x0, + 0xe, 0x8e, 0xe2, 0x8c, 0xbd, 0x4a, 0xfd, 0x13, 0x70, 0xdc, 0x30, 0x46, 0x9d, 0xaa, 0x8e, 0x23, 0x35, 0xa4, 0x17, + 0xb5, 0x21, 0xb, 0x22, 0x24, 0x42, 0x28, 0xd0, 0x2a, 0xff, 0x67, 0xaf, 0x96, 0x18, 0x75, 0xe6, 0x3c, 0x28, 0x5a, + 0x91, 0x91, 0x20, 0x67, 0xb1, 0xd9, 0x50, 0x37, 0x5, 0x60, 0x56, 0xa7, 0xd4, 0x6b, 0xb1, 0x1a, 0x2e}; + + uint8_t buf[198] = {0}; + + uint8_t topic_bytes[] = {0x1d, 0x27, 0x4f, 0x1d, 0x9d, 0x4c, 0x3a, 0xa0, 0x21, 0xe8, 0xee, 0xfb, + 0xd2, 0x1, 0x95, 0xf7, 0x5b, 0xc8, 0xce, 0x56, 0xe4, 0x4e, 0x49, 0x46}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xff}; + msg.retained = true; + uint8_t msg_bytes[] = {0x67, 0xaf, 0x96, 0x18, 0x75, 0xe6, 0x3c, 0x28, 0x5a, 0x91, 0x91, 0x20, 0x67, + 0xb1, 0xd9, 0x50, 0x37, 0x5, 0x60, 0x56, 0xa7, 0xd4, 0x6b, 0xb1, 0x1a, 0x2e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 26; - uint8_t bytes0[] = {0x2a, 0xac, 0x22, 0x32, 0x57, 0x47, 0x52, 0x4f, 0x9d, 0xa0, 0x3c, 0xd3, 0xcb, - 0x79, 0x52, 0x5d, 0xdd, 0x1c, 0xa7, 0x10, 0x2e, 0x8c, 0xa7, 0x55, 0x84}; - uint8_t bytes1[] = {0x15, 0x35, 0xcd, 0xf0, 0x21, 0xdb, 0xd, 0xfe, 0xc, 0xc6, 0x57, 0x1e, 0x7e, 0xe0, 0x1e, 0x41}; - uint8_t bytes2[] = {0x33, 0xb4, 0x4b, 0x1a, 0xe1, 0x87, 0x9e, 0x8, 0x89, 0x82, 0xef}; - uint8_t bytes3[] = {0x85}; - uint8_t bytes4[] = {0x26, 0x9, 0x22, 0xc3, 0xb, 0x8b, 0xfe, 0xe8, 0xe8, 0x51, 0x26, 0x58, 0xca, 0xc0, 0xc4}; - uint8_t bytes5[] = {0xbb, 0x41}; - uint8_t bytes6[] = {0xab, 0x1a, 0x18, 0x19, 0x31, 0xa2, 0xbd, 0xfe, 0x75, 0x59, 0x54, 0xe9, 0x41, 0x88, - 0x27, 0xc3, 0xc3, 0xb, 0x3b, 0x8a, 0x74, 0xc2, 0x94, 0x99, 0xa, 0x5a, 0x77, 0xbd}; - uint8_t bytes7[] = {0xad, 0xeb, 0x7d, 0x24, 0x14, 0xde, 0xa7, 0x7a, 0x13, 0x1e, 0x3b, 0x6b, 0xb4, - 0x17, 0x3d, 0xb, 0x32, 0x65, 0xe5, 0x24, 0x3a, 0x74, 0x8, 0xf3, 0xf3}; - uint8_t bytes8[] = {0x5e, 0xef}; - uint8_t bytes9[] = {0xb3, 0x6e, 0x68, 0x32, 0x38, 0x57}; - uint8_t bytes10[] = {0xe7, 0xd9, 0xb2, 0x16}; - uint8_t bytes11[] = {0x61, 0x7a, 0x1a, 0x8f, 0x87, 0x68, 0x53, 0x8c, 0x57, - 0x78, 0x35, 0x6d, 0xf, 0xd2, 0xea, 0x3f, 0x64, 0x52}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20297}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28350}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1786}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24429}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14881}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4484}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytes8}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytes9}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12170}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytes10}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28653}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23984}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23557}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytes11}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, + uint8_t bytesprops0[] = {0x6, 0xce, 0xce, 0xd8, 0x30, 0x16, 0x96, 0x93, 0x25, 0xc5, 0x3b, + 0x95, 0x8d, 0x22, 0x28, 0x12, 0x3e, 0x40, 0xf, 0xed, 0xd7}; + uint8_t bytesprops1[] = {0x99, 0xa8, 0xde, 0x74, 0x39, 0xf0, 0x33, 0xca, 0x2e, 0x70, 0xef, + 0x7, 0x46, 0x2e, 0x8b, 0x69, 0xa8, 0xdd, 0xfb, 0x22, 0xe3}; + uint8_t bytesprops2[] = {0xcd, 0xb1, 0x42}; + uint8_t bytesprops3[] = {0xe, 0xa3, 0x4c, 0xb2, 0x28, 0xcc, 0xf2, 0x83, 0x84, + 0x52, 0xd5, 0x56, 0x2a, 0xaf, 0x7c, 0x1d, 0x7c, 0x2}; + uint8_t bytesprops4[] = {0x8e, 0xe2, 0x8c, 0xbd, 0x4a, 0xfd, 0x13, 0x70, 0xdc, 0x30, 0x46, 0x9d, 0xaa, 0x8e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27829}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4075}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10312}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19253}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10427}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13732}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2850}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 255}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15774, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10712, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129/gG\151\&6y\225\246\193\230", -// _pubPktID = 31160, _pubBody = "\243\207\138\211\213\183N\154\SOafk\220\SUBT", _pubProps = [PropWillDelayInterval -// 165,PropSubscriptionIdentifier 2,PropSubscriptionIdentifierAvailable 145,PropContentType -// "\168\f\245\DLE\253p\136\145\148\ETX6\DELk\198vc\163S\238\230\202!"]} -TEST(Publish50QCTest, Encode2) { - uint8_t pkt[] = {0x3d, 0x41, 0x0, 0xb, 0x81, 0x2f, 0x67, 0x47, 0x97, 0x36, 0x79, 0xe1, 0xf6, 0xc1, 0xe6, 0x79, 0xb8, - 0x22, 0x18, 0x0, 0x0, 0x0, 0xa5, 0xb, 0x2, 0x29, 0x91, 0x3, 0x0, 0x16, 0xa8, 0xc, 0xf5, 0x10, - 0xfd, 0x70, 0x88, 0x91, 0x94, 0x3, 0x36, 0x7f, 0x6b, 0xc6, 0x76, 0x63, 0xa3, 0x53, 0xee, 0xe6, 0xca, - 0x21, 0xf3, 0xcf, 0x8a, 0xd3, 0xd5, 0xb7, 0x4e, 0x9a, 0xe, 0x61, 0x66, 0x6b, 0xdc, 0x1a, 0x54}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "q\140\EOT\210\163\254Vg\160L\221g\182\231\149f3\239k\200\DC2", _pubPktID = 10731, _pubBody = +// "\229\183\252?\173\165\FS\181?\130", _pubProps = [PropMaximumPacketSize 8227,PropResponseInformation +// "\SUB\179\237\128+i\162P\210\239\&4.\CAN\200\157x",PropAssignedClientIdentifier +// "\ESC\144\133\137\148{\244\242_\166^\246M\156\151\213\170I\129\168\165\217\195\209",PropServerReference +// "G4z\SI\GS@\238U\FSqbh",PropResponseInformation "8\SI3]\CAN"]} +TEST(Publish5QCTest, Encode2) { + uint8_t pkt[] = {0x3c, 0x6e, 0x0, 0x15, 0x71, 0x8c, 0x4, 0xd2, 0xa3, 0xfe, 0x56, 0x67, 0xa0, 0x4c, 0xdd, 0x67, + 0xb6, 0xe7, 0x95, 0x66, 0x33, 0xef, 0x6b, 0xc8, 0x12, 0x29, 0xeb, 0x4a, 0x27, 0x0, 0x0, 0x20, + 0x23, 0x1a, 0x0, 0x10, 0x1a, 0xb3, 0xed, 0x80, 0x2b, 0x69, 0xa2, 0x50, 0xd2, 0xef, 0x34, 0x2e, + 0x18, 0xc8, 0x9d, 0x78, 0x12, 0x0, 0x18, 0x1b, 0x90, 0x85, 0x89, 0x94, 0x7b, 0xf4, 0xf2, 0x5f, + 0xa6, 0x5e, 0xf6, 0x4d, 0x9c, 0x97, 0xd5, 0xaa, 0x49, 0x81, 0xa8, 0xa5, 0xd9, 0xc3, 0xd1, 0x1c, + 0x0, 0xc, 0x47, 0x34, 0x7a, 0xf, 0x1d, 0x40, 0xee, 0x55, 0x1c, 0x71, 0x62, 0x68, 0x1a, 0x0, + 0x5, 0x38, 0xf, 0x33, 0x5d, 0x18, 0xe5, 0xb7, 0xfc, 0x3f, 0xad, 0xa5, 0x1c, 0xb5, 0x3f, 0x82}; - uint8_t buf[77] = {0}; + uint8_t buf[122] = {0}; - uint8_t topic_bytes[] = {0x81, 0x2f, 0x67, 0x47, 0x97, 0x36, 0x79, 0xe1, 0xf6, 0xc1, 0xe6}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x71, 0x8c, 0x4, 0xd2, 0xa3, 0xfe, 0x56, 0x67, 0xa0, 0x4c, 0xdd, + 0x67, 0xb6, 0xe7, 0x95, 0x66, 0x33, 0xef, 0x6b, 0xc8, 0x12}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xf3, 0xcf, 0x8a, 0xd3, 0xd5, 0xb7, 0x4e, 0x9a, 0xe, 0x61, 0x66, 0x6b, 0xdc, 0x1a, 0x54}; + msg.retained = false; + uint8_t msg_bytes[] = {0xe5, 0xb7, 0xfc, 0x3f, 0xad, 0xa5, 0x1c, 0xb5, 0x3f, 0x82}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytes0[] = {0xa8, 0xc, 0xf5, 0x10, 0xfd, 0x70, 0x88, 0x91, 0x94, 0x3, 0x36, - 0x7f, 0x6b, 0xc6, 0x76, 0x63, 0xa3, 0x53, 0xee, 0xe6, 0xca, 0x21}; + msg.payload_len = 10; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 165}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytes0}}}, + uint8_t bytesprops0[] = {0x1a, 0xb3, 0xed, 0x80, 0x2b, 0x69, 0xa2, 0x50, + 0xd2, 0xef, 0x34, 0x2e, 0x18, 0xc8, 0x9d, 0x78}; + uint8_t bytesprops1[] = {0x1b, 0x90, 0x85, 0x89, 0x94, 0x7b, 0xf4, 0xf2, 0x5f, 0xa6, 0x5e, 0xf6, + 0x4d, 0x9c, 0x97, 0xd5, 0xaa, 0x49, 0x81, 0xa8, 0xa5, 0xd9, 0xc3, 0xd1}; + uint8_t bytesprops2[] = {0x47, 0x34, 0x7a, 0xf, 0x1d, 0x40, 0xee, 0x55, 0x1c, 0x71, 0x62, 0x68}; + uint8_t bytesprops3[] = {0x38, 0xf, 0x33, 0x5d, 0x18}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8227}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 31160, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10731, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\173\FS\174\250\f\SYN6\ENQ\218i\199\ETB\213\180 \FS%", _pubPktID = 27531, _pubBody = "\129\232\a\215w\236", -// _pubProps = [PropMessageExpiryInterval 2064,PropAuthenticationMethod -// "5\187MR\NAK#d\135\207",PropSubscriptionIdentifier 13,PropContentType -// "\198\154%(@\179\250\203\246\134\193\194\213@N3\243'\149\DC1\128\163I]\194\138\157{\224",PropSubscriptionIdentifierAvailable -// 172,PropTopicAlias 6079,PropRequestProblemInformation 202,PropWildcardSubscriptionAvailable -// 85,PropSubscriptionIdentifierAvailable 226,PropReasonString "Y\243\204\GS-\161\139n\133",PropSubscriptionIdentifier -// 25,PropSharedSubscriptionAvailable 135,PropTopicAlias 32178,PropMessageExpiryInterval 9754,PropReceiveMaximum -// 27507,PropSubscriptionIdentifierAvailable 136,PropCorrelationData "'Dg",PropMaximumPacketSize 32580,PropContentType -// "\133D\195\150\250#\211ujub\229.P\214`\159ao\154\167.A[\174\132\155P"]} -TEST(Publish50QCTest, Encode3) { - uint8_t pkt[] = {0x35, 0xa2, 0x1, 0x0, 0x11, 0xad, 0x1c, 0xae, 0xfa, 0xc, 0x16, 0x36, 0x5, 0xda, 0x69, 0xc7, 0x17, - 0xd5, 0xb4, 0x20, 0x1c, 0x25, 0x6b, 0x8b, 0x85, 0x1, 0x2, 0x0, 0x0, 0x8, 0x10, 0x15, 0x0, 0x9, - 0x35, 0xbb, 0x4d, 0x52, 0x15, 0x23, 0x64, 0x87, 0xcf, 0xb, 0xd, 0x3, 0x0, 0x1d, 0xc6, 0x9a, 0x25, - 0x28, 0x40, 0xb3, 0xfa, 0xcb, 0xf6, 0x86, 0xc1, 0xc2, 0xd5, 0x40, 0x4e, 0x33, 0xf3, 0x27, 0x95, 0x11, - 0x80, 0xa3, 0x49, 0x5d, 0xc2, 0x8a, 0x9d, 0x7b, 0xe0, 0x29, 0xac, 0x23, 0x17, 0xbf, 0x17, 0xca, 0x28, - 0x55, 0x29, 0xe2, 0x1f, 0x0, 0x9, 0x59, 0xf3, 0xcc, 0x1d, 0x2d, 0xa1, 0x8b, 0x6e, 0x85, 0xb, 0x19, - 0x2a, 0x87, 0x23, 0x7d, 0xb2, 0x2, 0x0, 0x0, 0x26, 0x1a, 0x21, 0x6b, 0x73, 0x29, 0x88, 0x9, 0x0, - 0x3, 0x27, 0x44, 0x67, 0x27, 0x0, 0x0, 0x7f, 0x44, 0x3, 0x0, 0x1c, 0x85, 0x44, 0xc3, 0x96, 0xfa, - 0x23, 0xd3, 0x75, 0x6a, 0x75, 0x62, 0xe5, 0x2e, 0x50, 0xd6, 0x60, 0x9f, 0x61, 0x6f, 0x9a, 0xa7, 0x2e, - 0x41, 0x5b, 0xae, 0x84, 0x9b, 0x50, 0x81, 0xe8, 0x7, 0xd7, 0x77, 0xec}; - - uint8_t buf[175] = {0}; - - uint8_t topic_bytes[] = {0xad, 0x1c, 0xae, 0xfa, 0xc, 0x16, 0x36, 0x5, 0xda, - 0x69, 0xc7, 0x17, 0xd5, 0xb4, 0x20, 0x1c, 0x25}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "I0\v\142\237", _pubPktID = 7560, +// _pubBody = "`\189\255\237\166\235-D\NAK", _pubProps = [PropSubscriptionIdentifier 18,PropRequestResponseInformation +// 149,PropTopicAlias 26028,PropServerKeepAlive 15158,PropResponseInformation +// "f\128\219\163\&6rQ",PropAuthenticationData "\203\ACK_\165\155\220\158\b\178o",PropContentType +// "\241\234\158\227\CANUWN\242\249L\228h\153\167+\129\&6/"]} +TEST(Publish5QCTest, Encode3) { + uint8_t pkt[] = {0x35, 0x4a, 0x0, 0x5, 0x49, 0x30, 0xb, 0x8e, 0xed, 0x1d, 0x88, 0x37, 0xb, 0x12, 0x19, 0x95, + 0x23, 0x65, 0xac, 0x13, 0x3b, 0x36, 0x1a, 0x0, 0x7, 0x66, 0x80, 0xdb, 0xa3, 0x36, 0x72, 0x51, + 0x16, 0x0, 0xa, 0xcb, 0x6, 0x5f, 0xa5, 0x9b, 0xdc, 0x9e, 0x8, 0xb2, 0x6f, 0x3, 0x0, 0x13, + 0xf1, 0xea, 0x9e, 0xe3, 0x18, 0x55, 0x57, 0x4e, 0xf2, 0xf9, 0x4c, 0xe4, 0x68, 0x99, 0xa7, 0x2b, + 0x81, 0x36, 0x2f, 0x60, 0xbd, 0xff, 0xed, 0xa6, 0xeb, 0x2d, 0x44, 0x15}; + + uint8_t buf[86] = {0}; + + uint8_t topic_bytes[] = {0x49, 0x30, 0xb, 0x8e, 0xed}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x81, 0xe8, 0x7, 0xd7, 0x77, 0xec}; + uint8_t msg_bytes[] = {0x60, 0xbd, 0xff, 0xed, 0xa6, 0xeb, 0x2d, 0x44, 0x15}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 9; - uint8_t bytes0[] = {0x35, 0xbb, 0x4d, 0x52, 0x15, 0x23, 0x64, 0x87, 0xcf}; - uint8_t bytes1[] = {0xc6, 0x9a, 0x25, 0x28, 0x40, 0xb3, 0xfa, 0xcb, 0xf6, 0x86, 0xc1, 0xc2, 0xd5, 0x40, 0x4e, - 0x33, 0xf3, 0x27, 0x95, 0x11, 0x80, 0xa3, 0x49, 0x5d, 0xc2, 0x8a, 0x9d, 0x7b, 0xe0}; - uint8_t bytes2[] = {0x59, 0xf3, 0xcc, 0x1d, 0x2d, 0xa1, 0x8b, 0x6e, 0x85}; - uint8_t bytes3[] = {0x27, 0x44, 0x67}; - uint8_t bytes4[] = {0x85, 0x44, 0xc3, 0x96, 0xfa, 0x23, 0xd3, 0x75, 0x6a, 0x75, 0x62, 0xe5, 0x2e, 0x50, - 0xd6, 0x60, 0x9f, 0x61, 0x6f, 0x9a, 0xa7, 0x2e, 0x41, 0x5b, 0xae, 0x84, 0x9b, 0x50}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2064}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6079}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32178}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9754}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27507}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32580}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytes4}}}, + uint8_t bytesprops0[] = {0x66, 0x80, 0xdb, 0xa3, 0x36, 0x72, 0x51}; + uint8_t bytesprops1[] = {0xcb, 0x6, 0x5f, 0xa5, 0x9b, 0xdc, 0x9e, 0x8, 0xb2, 0x6f}; + uint8_t bytesprops2[] = {0xf1, 0xea, 0x9e, 0xe3, 0x18, 0x55, 0x57, 0x4e, 0xf2, 0xf9, + 0x4c, 0xe4, 0x68, 0x99, 0xa7, 0x2b, 0x81, 0x36, 0x2f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26028}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15158}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 27531, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7560, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "y\135\f\ESC\175I\RS=", _pubPktID = -// 3010, _pubBody = "\198L\248\190/9\218\229\251^", _pubProps = [PropSubscriptionIdentifier 28,PropMessageExpiryInterval -// 27639,PropRequestResponseInformation 179]} -TEST(Publish50QCTest, Encode4) { - uint8_t pkt[] = {0x35, 0x20, 0x0, 0x8, 0x79, 0x87, 0xc, 0x1b, 0xaf, 0x49, 0x1e, 0x3d, 0xb, 0xc2, 0x9, 0xb, 0x1c, - 0x2, 0x0, 0x0, 0x6b, 0xf7, 0x19, 0xb3, 0xc6, 0x4c, 0xf8, 0xbe, 0x2f, 0x39, 0xda, 0xe5, 0xfb, 0x5e}; - - uint8_t buf[44] = {0}; - - uint8_t topic_bytes[] = {0x79, 0x87, 0xc, 0x1b, 0xaf, 0x49, 0x1e, 0x3d}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\214d)\246\152\n-f", _pubPktID = +// 27404, _pubBody = "\187\167\151\192YY\244\252\216W\216\180S\218A\187\255\140'\172dG\187", _pubProps = +// [PropSubscriptionIdentifierAvailable 99,PropPayloadFormatIndicator 40,PropTopicAliasMaximum +// 4746,PropSharedSubscriptionAvailable 89,PropServerReference +// "&\b\229+\163\&5\132\203\213J\bW\228\161",PropRequestResponseInformation 65,PropSharedSubscriptionAvailable +// 57,PropContentType +// "\148\136\244\ENQ\154\253\142*\231ac\179\CAN\135-X\213\DC4^\137v\240nL`\187\\.\159",PropWillDelayInterval +// 22673,PropServerReference "\167\163\166\RS\ESC\140h\197\243 F\169I\233\195\226$\ACK\189a",PropMaximumPacketSize +// 19749,PropServerReference +// "H\155\148\ETXS\DEL9\219_\203\128\DLEAV\180\184\160I+t\152#\209\SO\132\220\214\225k\213",PropMaximumPacketSize +// 19964,PropServerKeepAlive 772,PropAuthenticationData +// "\209\209f\208ds%\155T\181\173\148\221\179\205\191G\DLE\213\149\235\237",PropSharedSubscriptionAvailable +// 146,PropResponseInformation "en\DC2\141\SYN!\151\183\166\145,7\147",PropMaximumQoS 12,PropReasonString +// "\225}\172\212\US\153\150&\245\147\EOTL\178^\250sY#wo+\215_/\217\SOH",PropMessageExpiryInterval +// 6189,PropSubscriptionIdentifier 6,PropTopicAlias 16029,PropWillDelayInterval 5712,PropMessageExpiryInterval +// 11452,PropRequestResponseInformation 28,PropRequestResponseInformation 206,PropUserProperty +// "\NAKl\244\164\SOH\179\138S\US\167\\\239sVkE\151\&8P\203u\211\249\239" "",PropTopicAliasMaximum +// 25654,PropWillDelayInterval 28483]} +TEST(Publish5QCTest, Encode4) { + uint8_t pkt[] = { + 0x3b, 0xb4, 0x2, 0x0, 0x8, 0xd6, 0x64, 0x29, 0xf6, 0x98, 0xa, 0x2d, 0x66, 0x6b, 0xc, 0x8f, 0x2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7d, 0xac, 0xd4, 0x1f, 0x99, 0x96, 0x26, + 0xf5, 0x93, 0x4, 0x4c, 0xb2, 0x5e, 0xfa, 0x73, 0x59, 0x23, 0x77, 0x6f, 0x2b, 0xd7, 0x5f, 0x2f, 0xd9, 0x1, 0x2, + 0x0, 0x0, 0x18, 0x2d, 0xb, 0x6, 0x23, 0x3e, 0x9d, 0x18, 0x0, 0x0, 0x16, 0x50, 0x2, 0x0, 0x0, 0x2c, 0xbc, + 0x19, 0x1c, 0x19, 0xce, 0x26, 0x0, 0x18, 0x15, 0x6c, 0xf4, 0xa4, 0x1, 0xb3, 0x8a, 0x53, 0x1f, 0xa7, 0x5c, 0xef, + 0x73, 0x56, 0x6b, 0x45, 0x97, 0x38, 0x50, 0xcb, 0x75, 0xd3, 0xf9, 0xef, 0x0, 0x0, 0x22, 0x64, 0x36, 0x18, 0x0, + 0x0, 0x6f, 0x43, 0xbb, 0xa7, 0x97, 0xc0, 0x59, 0x59, 0xf4, 0xfc, 0xd8, 0x57, 0xd8, 0xb4, 0x53, 0xda, 0x41, 0xbb, + 0xff, 0x8c, 0x27, 0xac, 0x64, 0x47, 0xbb}; + + uint8_t buf[321] = {0}; + + uint8_t topic_bytes[] = {0xd6, 0x64, 0x29, 0xf6, 0x98, 0xa, 0x2d, 0x66}; lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xc6, 0x4c, 0xf8, 0xbe, 0x2f, 0x39, 0xda, 0xe5, 0xfb, 0x5e}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27639}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 179}}, - }; - - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&proplist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 3010, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\fQ\131\202\NAK\EOTT\204\226\174\189\&72w\136\ETX\142I\166)\137*", _pubPktID = 0, _pubBody = "\148\134\189", -// _pubProps = [PropMaximumQoS 95,PropWillDelayInterval 12953,PropSharedSubscriptionAvailable -// 83,PropRequestResponseInformation 165,PropMaximumQoS 203,PropSubscriptionIdentifier 18,PropMessageExpiryInterval -// 22843,PropWildcardSubscriptionAvailable 157,PropAuthenticationMethod "\244\241\213d\201\142\169J\236\165\229 -// \246\133\177\ETX\248\186\174\241e\206\143\143i",PropTopicAlias 24582,PropRequestProblemInformation -// 126,PropWildcardSubscriptionAvailable 45,PropMessageExpiryInterval 2657,PropUserProperty -// "G\207%\tjz\CAN\162O\194\246-\139*O\ta4" "\135\215$\DELp\142B?",PropPayloadFormatIndicator 185,PropTopicAliasMaximum -// 18503,PropAuthenticationMethod "\241!^\f\199\172\144\199\208"]} -TEST(Publish50QCTest, Encode5) { - uint8_t pkt[] = {0x30, 0x8a, 0x1, 0x0, 0x16, 0xc, 0x51, 0x83, 0xca, 0x15, 0x4, 0x54, 0xcc, 0xe2, 0xae, 0xbd, - 0x37, 0x32, 0x77, 0x88, 0x3, 0x8e, 0x49, 0xa6, 0x29, 0x89, 0x2a, 0x6e, 0x24, 0x5f, 0x18, 0x0, - 0x0, 0x32, 0x99, 0x2a, 0x53, 0x19, 0xa5, 0x24, 0xcb, 0xb, 0x12, 0x2, 0x0, 0x0, 0x59, 0x3b, - 0x28, 0x9d, 0x15, 0x0, 0x19, 0xf4, 0xf1, 0xd5, 0x64, 0xc9, 0x8e, 0xa9, 0x4a, 0xec, 0xa5, 0xe5, - 0x20, 0xf6, 0x85, 0xb1, 0x3, 0xf8, 0xba, 0xae, 0xf1, 0x65, 0xce, 0x8f, 0x8f, 0x69, 0x23, 0x60, - 0x6, 0x17, 0x7e, 0x28, 0x2d, 0x2, 0x0, 0x0, 0xa, 0x61, 0x26, 0x0, 0x12, 0x47, 0xcf, 0x25, - 0x9, 0x6a, 0x7a, 0x18, 0xa2, 0x4f, 0xc2, 0xf6, 0x2d, 0x8b, 0x2a, 0x4f, 0x9, 0x61, 0x34, 0x0, - 0x8, 0x87, 0xd7, 0x24, 0x7f, 0x70, 0x8e, 0x42, 0x3f, 0x1, 0xb9, 0x22, 0x48, 0x47, 0x15, 0x0, - 0x9, 0xf1, 0x21, 0x5e, 0xc, 0xc7, 0xac, 0x90, 0xc7, 0xd0, 0x94, 0x86, 0xbd}; - - uint8_t buf[151] = {0}; - - uint8_t topic_bytes[] = {0xc, 0x51, 0x83, 0xca, 0x15, 0x4, 0x54, 0xcc, 0xe2, 0xae, 0xbd, - 0x37, 0x32, 0x77, 0x88, 0x3, 0x8e, 0x49, 0xa6, 0x29, 0x89, 0x2a}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x94, 0x86, 0xbd}; + uint8_t msg_bytes[] = {0xbb, 0xa7, 0x97, 0xc0, 0x59, 0x59, 0xf4, 0xfc, 0xd8, 0x57, 0xd8, 0xb4, + 0x53, 0xda, 0x41, 0xbb, 0xff, 0x8c, 0x27, 0xac, 0x64, 0x47, 0xbb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 23; - uint8_t bytes0[] = {0xf4, 0xf1, 0xd5, 0x64, 0xc9, 0x8e, 0xa9, 0x4a, 0xec, 0xa5, 0xe5, 0x20, 0xf6, - 0x85, 0xb1, 0x3, 0xf8, 0xba, 0xae, 0xf1, 0x65, 0xce, 0x8f, 0x8f, 0x69}; - uint8_t bytes2[] = {0x87, 0xd7, 0x24, 0x7f, 0x70, 0x8e, 0x42, 0x3f}; - uint8_t bytes1[] = {0x47, 0xcf, 0x25, 0x9, 0x6a, 0x7a, 0x18, 0xa2, 0x4f, - 0xc2, 0xf6, 0x2d, 0x8b, 0x2a, 0x4f, 0x9, 0x61, 0x34}; - uint8_t bytes3[] = {0xf1, 0x21, 0x5e, 0xc, 0xc7, 0xac, 0x90, 0xc7, 0xd0}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12953}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22843}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24582}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2657}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytes1}, .v = {8, (char*)&bytes2}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18503}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytes3}}}, + uint8_t bytesprops0[] = {0x26, 0x8, 0xe5, 0x2b, 0xa3, 0x35, 0x84, 0xcb, 0xd5, 0x4a, 0x8, 0x57, 0xe4, 0xa1}; + uint8_t bytesprops1[] = {0x94, 0x88, 0xf4, 0x5, 0x9a, 0xfd, 0x8e, 0x2a, 0xe7, 0x61, 0x63, 0xb3, 0x18, 0x87, 0x2d, + 0x58, 0xd5, 0x14, 0x5e, 0x89, 0x76, 0xf0, 0x6e, 0x4c, 0x60, 0xbb, 0x5c, 0x2e, 0x9f}; + uint8_t bytesprops2[] = {0xa7, 0xa3, 0xa6, 0x1e, 0x1b, 0x8c, 0x68, 0xc5, 0xf3, 0x20, + 0x46, 0xa9, 0x49, 0xe9, 0xc3, 0xe2, 0x24, 0x6, 0xbd, 0x61}; + uint8_t bytesprops3[] = {0x48, 0x9b, 0x94, 0x3, 0x53, 0x7f, 0x39, 0xdb, 0x5f, 0xcb, 0x80, 0x10, 0x41, 0x56, 0xb4, + 0xb8, 0xa0, 0x49, 0x2b, 0x74, 0x98, 0x23, 0xd1, 0xe, 0x84, 0xdc, 0xd6, 0xe1, 0x6b, 0xd5}; + uint8_t bytesprops4[] = {0xd1, 0xd1, 0x66, 0xd0, 0x64, 0x73, 0x25, 0x9b, 0x54, 0xb5, 0xad, + 0x94, 0xdd, 0xb3, 0xcd, 0xbf, 0x47, 0x10, 0xd5, 0x95, 0xeb, 0xed}; + uint8_t bytesprops5[] = {0x65, 0x6e, 0x12, 0x8d, 0x16, 0x21, 0x97, 0xb7, 0xa6, 0x91, 0x2c, 0x37, 0x93}; + uint8_t bytesprops6[] = {0xe1, 0x7d, 0xac, 0xd4, 0x1f, 0x99, 0x96, 0x26, 0xf5, 0x93, 0x4, 0x4c, 0xb2, + 0x5e, 0xfa, 0x73, 0x59, 0x23, 0x77, 0x6f, 0x2b, 0xd7, 0x5f, 0x2f, 0xd9, 0x1}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops7[] = {0x15, 0x6c, 0xf4, 0xa4, 0x1, 0xb3, 0x8a, 0x53, 0x1f, 0xa7, 0x5c, 0xef, + 0x73, 0x56, 0x6b, 0x45, 0x97, 0x38, 0x50, 0xcb, 0x75, 0xd3, 0xf9, 0xef}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4746}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22673}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19749}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19964}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 772}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6189}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16029}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5712}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11452}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops7}, .v = {0, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25654}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28483}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 27404, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\186\EMG9\192\229\240\204\DC2o", -// _pubPktID = 0, _pubBody = "\166!\209#\147\&1%\222\235\133Gd\174=\SIf\247\215\US^6\b\r", _pubProps = -// [PropMaximumPacketSize 14608,PropServerKeepAlive 13002,PropContentType "\228 \ETX\252\187}P",PropTopicAlias -// 30258,PropUserProperty "\219UyW\v\EOT%\"\138{p\208{~\140\168wg\253" " -// Y\130\222\SYN3tx\NUL\232\&1\242\216_",PropServerKeepAlive 12368]} -TEST(Publish50QCTest, Encode6) { - uint8_t pkt[] = {0x38, 0x62, 0x0, 0xa, 0xba, 0x19, 0x47, 0x39, 0xc0, 0xe5, 0xf0, 0xcc, 0x12, 0x6f, 0x3e, 0x27, 0x0, - 0x0, 0x39, 0x10, 0x13, 0x32, 0xca, 0x3, 0x0, 0x7, 0xe4, 0x20, 0x3, 0xfc, 0xbb, 0x7d, 0x50, 0x23, - 0x76, 0x32, 0x26, 0x0, 0x13, 0xdb, 0x55, 0x79, 0x57, 0xb, 0x4, 0x25, 0x22, 0x8a, 0x7b, 0x70, 0xd0, - 0x7b, 0x7e, 0x8c, 0xa8, 0x77, 0x67, 0xfd, 0x0, 0xe, 0x20, 0x59, 0x82, 0xde, 0x16, 0x33, 0x74, 0x78, - 0x0, 0xe8, 0x31, 0xf2, 0xd8, 0x5f, 0x13, 0x30, 0x50, 0xa6, 0x21, 0xd1, 0x23, 0x93, 0x31, 0x25, 0xde, - 0xeb, 0x85, 0x47, 0x64, 0xae, 0x3d, 0xf, 0x66, 0xf7, 0xd7, 0x1f, 0x5e, 0x36, 0x8, 0xd}; - - uint8_t buf[110] = {0}; - - uint8_t topic_bytes[] = {0xba, 0x19, 0x47, 0x39, 0xc0, 0xe5, 0xf0, 0xcc, 0x12, 0x6f}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\243i\174@\215\136\140u\b,", +// _pubPktID = 0, _pubBody = "_\166K\178hd\ETX^Q", _pubProps = [PropTopicAliasMaximum 15843,PropSubscriptionIdentifier +// 31,PropWillDelayInterval 17605,PropPayloadFormatIndicator 133,PropReceiveMaximum 27638,PropRequestResponseInformation +// 74,PropResponseInformation +// "\238f\225\128\220h\182ACyl\154\206\186M\165\225\187\&1?\USW\201",PropAssignedClientIdentifier +// "\167\186/\DC3\196\a\193\249\226\SUB!\NUL\160\&8\ETX\DC4b\FS>&JL(\216\n\ETBZ\235",PropSubscriptionIdentifierAvailable +// 221,PropWillDelayInterval 32718,PropRequestResponseInformation 240,PropRequestResponseInformation +// 83,PropCorrelationData "\168\&6\\\239D\214\220;\245\FS\DC1\ETB-\DC3tE\184\214\161.e\181F\201",PropMaximumPacketSize +// 3242]} +TEST(Publish5QCTest, Encode5) { + uint8_t pkt[] = {0x38, 0x8b, 0x1, 0x0, 0xa, 0xf3, 0x69, 0xae, 0x40, 0xd7, 0x88, 0x8c, 0x75, 0x8, 0x2c, 0x75, + 0x22, 0x3d, 0xe3, 0xb, 0x1f, 0x18, 0x0, 0x0, 0x44, 0xc5, 0x1, 0x85, 0x21, 0x6b, 0xf6, 0x19, + 0x4a, 0x1a, 0x0, 0x17, 0xee, 0x66, 0xe1, 0x80, 0xdc, 0x68, 0xb6, 0x41, 0x43, 0x79, 0x6c, 0x9a, + 0xce, 0xba, 0x4d, 0xa5, 0xe1, 0xbb, 0x31, 0x3f, 0x1f, 0x57, 0xc9, 0x12, 0x0, 0x1c, 0xa7, 0xba, + 0x2f, 0x13, 0xc4, 0x7, 0xc1, 0xf9, 0xe2, 0x1a, 0x21, 0x0, 0xa0, 0x38, 0x3, 0x14, 0x62, 0x1c, + 0x3e, 0x26, 0x4a, 0x4c, 0x28, 0xd8, 0xa, 0x17, 0x5a, 0xeb, 0x29, 0xdd, 0x18, 0x0, 0x0, 0x7f, + 0xce, 0x19, 0xf0, 0x19, 0x53, 0x9, 0x0, 0x18, 0xa8, 0x36, 0x5c, 0xef, 0x44, 0xd6, 0xdc, 0x3b, + 0xf5, 0x1c, 0x11, 0x17, 0x2d, 0x13, 0x74, 0x45, 0xb8, 0xd6, 0xa1, 0x2e, 0x65, 0xb5, 0x46, 0xc9, + 0x27, 0x0, 0x0, 0xc, 0xaa, 0x5f, 0xa6, 0x4b, 0xb2, 0x68, 0x64, 0x3, 0x5e, 0x51}; + + uint8_t buf[152] = {0}; + + uint8_t topic_bytes[] = {0xf3, 0x69, 0xae, 0x40, 0xd7, 0x88, 0x8c, 0x75, 0x8, 0x2c}; lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xa6, 0x21, 0xd1, 0x23, 0x93, 0x31, 0x25, 0xde, 0xeb, 0x85, 0x47, 0x64, - 0xae, 0x3d, 0xf, 0x66, 0xf7, 0xd7, 0x1f, 0x5e, 0x36, 0x8, 0xd}; + uint8_t msg_bytes[] = {0x5f, 0xa6, 0x4b, 0xb2, 0x68, 0x64, 0x3, 0x5e, 0x51}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 9; - uint8_t bytes0[] = {0xe4, 0x20, 0x3, 0xfc, 0xbb, 0x7d, 0x50}; - uint8_t bytes2[] = {0x20, 0x59, 0x82, 0xde, 0x16, 0x33, 0x74, 0x78, 0x0, 0xe8, 0x31, 0xf2, 0xd8, 0x5f}; - uint8_t bytes1[] = {0xdb, 0x55, 0x79, 0x57, 0xb, 0x4, 0x25, 0x22, 0x8a, 0x7b, - 0x70, 0xd0, 0x7b, 0x7e, 0x8c, 0xa8, 0x77, 0x67, 0xfd}; + uint8_t bytesprops0[] = {0xee, 0x66, 0xe1, 0x80, 0xdc, 0x68, 0xb6, 0x41, 0x43, 0x79, 0x6c, 0x9a, + 0xce, 0xba, 0x4d, 0xa5, 0xe1, 0xbb, 0x31, 0x3f, 0x1f, 0x57, 0xc9}; + uint8_t bytesprops1[] = {0xa7, 0xba, 0x2f, 0x13, 0xc4, 0x7, 0xc1, 0xf9, 0xe2, 0x1a, 0x21, 0x0, 0xa0, 0x38, + 0x3, 0x14, 0x62, 0x1c, 0x3e, 0x26, 0x4a, 0x4c, 0x28, 0xd8, 0xa, 0x17, 0x5a, 0xeb}; + uint8_t bytesprops2[] = {0xa8, 0x36, 0x5c, 0xef, 0x44, 0xd6, 0xdc, 0x3b, 0xf5, 0x1c, 0x11, 0x17, + 0x2d, 0x13, 0x74, 0x45, 0xb8, 0xd6, 0xa1, 0x2e, 0x65, 0xb5, 0x46, 0xc9}; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14608}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13002}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30258}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytes1}, .v = {14, (char*)&bytes2}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12368}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15843}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17605}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27638}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32718}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3242}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); @@ -3035,548 +3262,482 @@ TEST(Publish50QCTest, Encode6) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\249\r\220\v\234\SOH\157\DC1_\145mx\199\189\136\241\241\184\225\ETX\132\GS\231\210\133\RS\r", _pubPktID = 32631, -// _pubBody = "\145\209\172\139\202&x\240\162\148\\U", _pubProps = [PropAuthenticationData -// "z\187\227b\SO\153e",PropSubscriptionIdentifier 1,PropContentType -// "\219\250L\140\ETX\177\238\144\157,\130\236\142\252\249\130g\199\246\248#\176\248x\179\161",PropContentType -// "\178c\180s\128I_\202\t9p\131\141\254\151",PropWildcardSubscriptionAvailable 154,PropTopicAliasMaximum -// 18494,PropCorrelationData "\SIc\230\n\143\128\EOT\194\182=\154R",PropSubscriptionIdentifier 30,PropContentType -// "\207TS\133\FS\211%\242\EM\161\EM\183\219",PropWildcardSubscriptionAvailable 9,PropMaximumQoS 120,PropServerKeepAlive -// 6661,PropUserProperty "\189\208X\237]Q\187F\166P8i\156l\138\255\179\237y" "d\154[\167SH",PropReasonString "\172 -// \193V\203\250\230J\151x\209\&9$_\235\150\189O\222\234\129\SYNq",PropRequestResponseInformation -// 71,PropSubscriptionIdentifierAvailable 63,PropResponseInformation -// "\253C\233\219W\193H\130\192\237a\236\254\165\239\ETX\233\248\221\234\231LU\230",PropReasonString -// "\129\209\178\&1\142\RSd",PropMessageExpiryInterval 19943,PropMessageExpiryInterval 21658,PropServerKeepAlive -// 10194,PropMessageExpiryInterval 12759,PropReceiveMaximum 6676,PropResponseTopic -// "\215\&4\214\ETX@A\228\251R\154\254y"]} -TEST(Publish50QCTest, Encode7) { - uint8_t pkt[] = { - 0x33, 0x9a, 0x2, 0x0, 0x1b, 0xf9, 0xd, 0xdc, 0xb, 0xea, 0x1, 0x9d, 0x11, 0x5f, 0x91, 0x6d, 0x78, 0xc7, 0xbd, - 0x88, 0xf1, 0xf1, 0xb8, 0xe1, 0x3, 0x84, 0x1d, 0xe7, 0xd2, 0x85, 0x1e, 0xd, 0x7f, 0x77, 0xed, 0x1, 0x16, 0x0, - 0x7, 0x7a, 0xbb, 0xe3, 0x62, 0xe, 0x99, 0x65, 0xb, 0x1, 0x3, 0x0, 0x1a, 0xdb, 0xfa, 0x4c, 0x8c, 0x3, 0xb1, - 0xee, 0x90, 0x9d, 0x2c, 0x82, 0xec, 0x8e, 0xfc, 0xf9, 0x82, 0x67, 0xc7, 0xf6, 0xf8, 0x23, 0xb0, 0xf8, 0x78, 0xb3, - 0xa1, 0x3, 0x0, 0xf, 0xb2, 0x63, 0xb4, 0x73, 0x80, 0x49, 0x5f, 0xca, 0x9, 0x39, 0x70, 0x83, 0x8d, 0xfe, 0x97, - 0x28, 0x9a, 0x22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uint8_t buf[295] = {0}; - - uint8_t topic_bytes[] = {0xf9, 0xd, 0xdc, 0xb, 0xea, 0x1, 0x9d, 0x11, 0x5f, 0x91, 0x6d, 0x78, 0xc7, 0xbd, - 0x88, 0xf1, 0xf1, 0xb8, 0xe1, 0x3, 0x84, 0x1d, 0xe7, 0xd2, 0x85, 0x1e, 0xd}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\n-yh\SO\210\US\ESC\254\242a", +// _pubPktID = 15060, _pubBody = "\DEL\SOH0>\190\215\246)N\183\&0R\194\153\164\140'6\243X", _pubProps = +// [PropSharedSubscriptionAvailable 195,PropMessageExpiryInterval 17613,PropWildcardSubscriptionAvailable +// 230,PropServerKeepAlive 23700,PropMessageExpiryInterval 25511,PropResponseTopic +// "\232\240e",PropRequestProblemInformation 220,PropResponseInformation +// "\178\215\172\193\&2^\185\240fz[\254\167\138+L\192\\\183",PropMessageExpiryInterval 5480,PropResponseTopic +// "M\190\249\239\234\134\&1j\188\159\r\ENQ\242\232\167\241\144\136D\155\239QM\245G",PropAuthenticationData " +// \242",PropRequestResponseInformation 206,PropAuthenticationData +// "9/\176\STX\253A\217\189\209\217\207\154\RS\228-\169\128\&39r\208",PropContentType +// "\227\NUL+X\248\129L\241\246\SYN\230\129pui*@:\ESCg\241$\f",PropWillDelayInterval +// 29400,PropRequestResponseInformation 197]} +TEST(Publish5QCTest, Encode6) { + uint8_t pkt[] = {0x3b, 0xb5, 0x1, 0x0, 0xb, 0xa, 0x2d, 0x79, 0x68, 0xe, 0xd2, 0x1f, 0x1b, 0xfe, 0xf2, 0x61, 0x3a, + 0xd4, 0x90, 0x1, 0x2a, 0xc3, 0x2, 0x0, 0x0, 0x44, 0xcd, 0x28, 0xe6, 0x13, 0x5c, 0x94, 0x2, 0x0, + 0x0, 0x63, 0xa7, 0x8, 0x0, 0x3, 0xe8, 0xf0, 0x65, 0x17, 0xdc, 0x1a, 0x0, 0x13, 0xb2, 0xd7, 0xac, + 0xc1, 0x32, 0x5e, 0xb9, 0xf0, 0x66, 0x7a, 0x5b, 0xfe, 0xa7, 0x8a, 0x2b, 0x4c, 0xc0, 0x5c, 0xb7, 0x2, + 0x0, 0x0, 0x15, 0x68, 0x8, 0x0, 0x19, 0x4d, 0xbe, 0xf9, 0xef, 0xea, 0x86, 0x31, 0x6a, 0xbc, 0x9f, + 0xd, 0x5, 0xf2, 0xe8, 0xa7, 0xf1, 0x90, 0x88, 0x44, 0x9b, 0xef, 0x51, 0x4d, 0xf5, 0x47, 0x16, 0x0, + 0x2, 0x20, 0xf2, 0x19, 0xce, 0x16, 0x0, 0x15, 0x39, 0x2f, 0xb0, 0x2, 0xfd, 0x41, 0xd9, 0xbd, 0xd1, + 0xd9, 0xcf, 0x9a, 0x1e, 0xe4, 0x2d, 0xa9, 0x80, 0x33, 0x39, 0x72, 0xd0, 0x3, 0x0, 0x17, 0xe3, 0x0, + 0x2b, 0x58, 0xf8, 0x81, 0x4c, 0xf1, 0xf6, 0x16, 0xe6, 0x81, 0x70, 0x75, 0x69, 0x2a, 0x40, 0x3a, 0x1b, + 0x67, 0xf1, 0x24, 0xc, 0x18, 0x0, 0x0, 0x72, 0xd8, 0x19, 0xc5, 0x7f, 0x1, 0x30, 0x3e, 0xbe, 0xd7, + 0xf6, 0x29, 0x4e, 0xb7, 0x30, 0x52, 0xc2, 0x99, 0xa4, 0x8c, 0x27, 0x36, 0xf3, 0x58}; + + uint8_t buf[194] = {0}; + + uint8_t topic_bytes[] = {0xa, 0x2d, 0x79, 0x68, 0xe, 0xd2, 0x1f, 0x1b, 0xfe, 0xf2, 0x61}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x91, 0xd1, 0xac, 0x8b, 0xca, 0x26, 0x78, 0xf0, 0xa2, 0x94, 0x5c, 0x55}; + uint8_t msg_bytes[] = {0x7f, 0x1, 0x30, 0x3e, 0xbe, 0xd7, 0xf6, 0x29, 0x4e, 0xb7, + 0x30, 0x52, 0xc2, 0x99, 0xa4, 0x8c, 0x27, 0x36, 0xf3, 0x58}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 20; - uint8_t bytes0[] = {0x7a, 0xbb, 0xe3, 0x62, 0xe, 0x99, 0x65}; - uint8_t bytes1[] = {0xdb, 0xfa, 0x4c, 0x8c, 0x3, 0xb1, 0xee, 0x90, 0x9d, 0x2c, 0x82, 0xec, 0x8e, - 0xfc, 0xf9, 0x82, 0x67, 0xc7, 0xf6, 0xf8, 0x23, 0xb0, 0xf8, 0x78, 0xb3, 0xa1}; - uint8_t bytes2[] = {0xb2, 0x63, 0xb4, 0x73, 0x80, 0x49, 0x5f, 0xca, 0x9, 0x39, 0x70, 0x83, 0x8d, 0xfe, 0x97}; - uint8_t bytes3[] = {0xf, 0x63, 0xe6, 0xa, 0x8f, 0x80, 0x4, 0xc2, 0xb6, 0x3d, 0x9a, 0x52}; - uint8_t bytes4[] = {0xcf, 0x54, 0x53, 0x85, 0x1c, 0xd3, 0x25, 0xf2, 0x19, 0xa1, 0x19, 0xb7, 0xdb}; - uint8_t bytes6[] = {0x64, 0x9a, 0x5b, 0xa7, 0x53, 0x48}; - uint8_t bytes5[] = {0xbd, 0xd0, 0x58, 0xed, 0x5d, 0x51, 0xbb, 0x46, 0xa6, 0x50, - 0x38, 0x69, 0x9c, 0x6c, 0x8a, 0xff, 0xb3, 0xed, 0x79}; - uint8_t bytes7[] = {0xac, 0x20, 0xc1, 0x56, 0xcb, 0xfa, 0xe6, 0x4a, 0x97, 0x78, 0xd1, 0x39, - 0x24, 0x5f, 0xeb, 0x96, 0xbd, 0x4f, 0xde, 0xea, 0x81, 0x16, 0x71}; - uint8_t bytes8[] = {0xfd, 0x43, 0xe9, 0xdb, 0x57, 0xc1, 0x48, 0x82, 0xc0, 0xed, 0x61, 0xec, - 0xfe, 0xa5, 0xef, 0x3, 0xe9, 0xf8, 0xdd, 0xea, 0xe7, 0x4c, 0x55, 0xe6}; - uint8_t bytes9[] = {0x81, 0xd1, 0xb2, 0x31, 0x8e, 0x1e, 0x64}; - uint8_t bytes10[] = {0xd7, 0x34, 0xd6, 0x3, 0x40, 0x41, 0xe4, 0xfb, 0x52, 0x9a, 0xfe, 0x79}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18494}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6661}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytes5}, .v = {6, (char*)&bytes6}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytes8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytes9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19943}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21658}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10194}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12759}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6676}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytes10}}}, + uint8_t bytesprops0[] = {0xe8, 0xf0, 0x65}; + uint8_t bytesprops1[] = {0xb2, 0xd7, 0xac, 0xc1, 0x32, 0x5e, 0xb9, 0xf0, 0x66, 0x7a, + 0x5b, 0xfe, 0xa7, 0x8a, 0x2b, 0x4c, 0xc0, 0x5c, 0xb7}; + uint8_t bytesprops2[] = {0x4d, 0xbe, 0xf9, 0xef, 0xea, 0x86, 0x31, 0x6a, 0xbc, 0x9f, 0xd, 0x5, 0xf2, + 0xe8, 0xa7, 0xf1, 0x90, 0x88, 0x44, 0x9b, 0xef, 0x51, 0x4d, 0xf5, 0x47}; + uint8_t bytesprops3[] = {0x20, 0xf2}; + uint8_t bytesprops4[] = {0x39, 0x2f, 0xb0, 0x2, 0xfd, 0x41, 0xd9, 0xbd, 0xd1, 0xd9, 0xcf, + 0x9a, 0x1e, 0xe4, 0x2d, 0xa9, 0x80, 0x33, 0x39, 0x72, 0xd0}; + uint8_t bytesprops5[] = {0xe3, 0x0, 0x2b, 0x58, 0xf8, 0x81, 0x4c, 0xf1, 0xf6, 0x16, 0xe6, 0x81, + 0x70, 0x75, 0x69, 0x2a, 0x40, 0x3a, 0x1b, 0x67, 0xf1, 0x24, 0xc}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17613}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23700}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25511}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5480}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29400}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32631, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15060, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "b\213\SO\144\154E1Y", _pubPktID = -// 17459, _pubBody = "\197\176\151_P\DC4\162Y\176\178\tN}p\223\213\213\215\&9\208.dWr", _pubProps = -// [PropRequestProblemInformation 5,PropRequestResponseInformation 145,PropRetainAvailable -// 57,PropAssignedClientIdentifier "\134\178\128F\173\229\ESC\250l(\167\156\201\130\189\187\192}\153>\166\185\219 -// sn\195\207",PropWillDelayInterval 10980,PropPayloadFormatIndicator 112,PropResponseInformation "XsO",PropUserProperty -// "<[\227'\208n\249\170\220\133#L\204\168*\198\155Sl\133\223\236\ENQ\152\RS" "\181\DC4\210):",PropSessionExpiryInterval -// 11656,PropUserProperty "\238<\162\202\&2\201-+J\DC1\225\GSt #*\129" -// "\248\222\212+T\180\FS5\netF\175\SOH\GS",PropRetainAvailable 182,PropResponseInformation -// "\221O|\ESCU\171\144\243\\\213\240\"\172X\250\176T",PropReasonString "\166G",PropTopicAliasMaximum -// 18131,PropRetainAvailable 21,PropReasonString "\178\DC4"]} -TEST(Publish50QCTest, Encode8) { - uint8_t pkt[] = { - 0x35, 0xca, 0x1, 0x0, 0x8, 0x62, 0xd5, 0xe, 0x90, 0x9a, 0x45, 0x31, 0x59, 0x44, 0x33, 0xa4, 0x1, 0x17, 0x5, - 0x19, 0x91, 0x25, 0x39, 0x12, 0x0, 0x1c, 0x86, 0xb2, 0x80, 0x46, 0xad, 0xe5, 0x1b, 0xfa, 0x6c, 0x28, 0xa7, 0x9c, - 0xc9, 0x82, 0xbd, 0xbb, 0xc0, 0x7d, 0x99, 0x3e, 0xa6, 0xb9, 0xdb, 0x20, 0x73, 0x6e, 0xc3, 0xcf, 0x18, 0x0, 0x0, - 0x2a, 0xe4, 0x1, 0x70, 0x1a, 0x0, 0x3, 0x58, 0x73, 0x4f, 0x26, 0x0, 0x19, 0x3c, 0x5b, 0xe3, 0x27, 0xd0, 0x6e, - 0xf9, 0xaa, 0xdc, 0x85, 0x23, 0x4c, 0xcc, 0xa8, 0x2a, 0xc6, 0x9b, 0x53, 0x6c, 0x85, 0xdf, 0xec, 0x5, 0x98, 0x1e, - 0x0, 0x5, 0xb5, 0x14, 0xd2, 0x29, 0x3a, 0x11, 0x0, 0x0, 0x2d, 0x88, 0x26, 0x0, 0x11, 0xee, 0x3c, 0xa2, 0xca, - 0x32, 0xc9, 0x2d, 0x2b, 0x4a, 0x11, 0xe1, 0x1d, 0x74, 0x20, 0x23, 0x2a, 0x81, 0x0, 0xf, 0xf8, 0xde, 0xd4, 0x2b, - 0x54, 0xb4, 0x1c, 0x35, 0xa, 0x65, 0x74, 0x46, 0xaf, 0x1, 0x1d, 0x25, 0xb6, 0x1a, 0x0, 0x11, 0xdd, 0x4f, 0x7c, - 0x1b, 0x55, 0xab, 0x90, 0xf3, 0x5c, 0xd5, 0xf0, 0x22, 0xac, 0x58, 0xfa, 0xb0, 0x54, 0x1f, 0x0, 0x2, 0xa6, 0x47, - 0x22, 0x46, 0xd3, 0x25, 0x15, 0x1f, 0x0, 0x2, 0xb2, 0x14, 0xc5, 0xb0, 0x97, 0x5f, 0x50, 0x14, 0xa2, 0x59, 0xb0, - 0xb2, 0x9, 0x4e, 0x7d, 0x70, 0xdf, 0xd5, 0xd5, 0xd7, 0x39, 0xd0, 0x2e, 0x64, 0x57, 0x72}; - - uint8_t buf[215] = {0}; - - uint8_t topic_bytes[] = {0x62, 0xd5, 0xe, 0x90, 0x9a, 0x45, 0x31, 0x59}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "5\132\234\246Z", _pubPktID = 0, +// _pubBody = "+", _pubProps = [PropResponseTopic +// "\n\201\DC2H\138\247\247\201\217\176&\DC4\211\240\198\206E\185",PropWillDelayInterval +// 30260,PropPayloadFormatIndicator 24,PropWillDelayInterval 12867,PropReceiveMaximum 28350,PropReceiveMaximum +// 7251,PropCorrelationData +// "\173\138\ACK\t\146\EOT{\167\SI\DC4\129\b\SOH\232\SO\"\254\184\210\199\SYN\238",PropSubscriptionIdentifierAvailable +// 191,PropRequestProblemInformation 31,PropRetainAvailable 118,PropContentType "\DEL\183",PropRetainAvailable 188]} +TEST(Publish5QCTest, Encode7) { + uint8_t pkt[] = {0x31, 0x56, 0x0, 0x5, 0x35, 0x84, 0xea, 0xf6, 0x5a, 0x4d, 0x8, 0x0, 0x12, 0xa, 0xc9, + 0x12, 0x48, 0x8a, 0xf7, 0xf7, 0xc9, 0xd9, 0xb0, 0x26, 0x14, 0xd3, 0xf0, 0xc6, 0xce, 0x45, + 0xb9, 0x18, 0x0, 0x0, 0x76, 0x34, 0x1, 0x18, 0x18, 0x0, 0x0, 0x32, 0x43, 0x21, 0x6e, + 0xbe, 0x21, 0x1c, 0x53, 0x9, 0x0, 0x16, 0xad, 0x8a, 0x6, 0x9, 0x92, 0x4, 0x7b, 0xa7, + 0xf, 0x14, 0x81, 0x8, 0x1, 0xe8, 0xe, 0x22, 0xfe, 0xb8, 0xd2, 0xc7, 0x16, 0xee, 0x29, + 0xbf, 0x17, 0x1f, 0x25, 0x76, 0x3, 0x0, 0x2, 0x7f, 0xb7, 0x25, 0xbc, 0x2b}; + + uint8_t buf[98] = {0}; + + uint8_t topic_bytes[] = {0x35, 0x84, 0xea, 0xf6, 0x5a}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xc5, 0xb0, 0x97, 0x5f, 0x50, 0x14, 0xa2, 0x59, 0xb0, 0xb2, 0x9, 0x4e, - 0x7d, 0x70, 0xdf, 0xd5, 0xd5, 0xd7, 0x39, 0xd0, 0x2e, 0x64, 0x57, 0x72}; + uint8_t msg_bytes[] = {0x2b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 1; - uint8_t bytes0[] = {0x86, 0xb2, 0x80, 0x46, 0xad, 0xe5, 0x1b, 0xfa, 0x6c, 0x28, 0xa7, 0x9c, 0xc9, 0x82, - 0xbd, 0xbb, 0xc0, 0x7d, 0x99, 0x3e, 0xa6, 0xb9, 0xdb, 0x20, 0x73, 0x6e, 0xc3, 0xcf}; - uint8_t bytes1[] = {0x58, 0x73, 0x4f}; - uint8_t bytes3[] = {0xb5, 0x14, 0xd2, 0x29, 0x3a}; - uint8_t bytes2[] = {0x3c, 0x5b, 0xe3, 0x27, 0xd0, 0x6e, 0xf9, 0xaa, 0xdc, 0x85, 0x23, 0x4c, 0xcc, - 0xa8, 0x2a, 0xc6, 0x9b, 0x53, 0x6c, 0x85, 0xdf, 0xec, 0x5, 0x98, 0x1e}; - uint8_t bytes5[] = {0xf8, 0xde, 0xd4, 0x2b, 0x54, 0xb4, 0x1c, 0x35, 0xa, 0x65, 0x74, 0x46, 0xaf, 0x1, 0x1d}; - uint8_t bytes4[] = {0xee, 0x3c, 0xa2, 0xca, 0x32, 0xc9, 0x2d, 0x2b, 0x4a, - 0x11, 0xe1, 0x1d, 0x74, 0x20, 0x23, 0x2a, 0x81}; - uint8_t bytes6[] = {0xdd, 0x4f, 0x7c, 0x1b, 0x55, 0xab, 0x90, 0xf3, 0x5c, - 0xd5, 0xf0, 0x22, 0xac, 0x58, 0xfa, 0xb0, 0x54}; - uint8_t bytes7[] = {0xa6, 0x47}; - uint8_t bytes8[] = {0xb2, 0x14}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10980}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytes2}, .v = {5, (char*)&bytes3}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11656}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytes4}, .v = {15, (char*)&bytes5}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18131}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytes8}}}, + uint8_t bytesprops0[] = {0xa, 0xc9, 0x12, 0x48, 0x8a, 0xf7, 0xf7, 0xc9, 0xd9, + 0xb0, 0x26, 0x14, 0xd3, 0xf0, 0xc6, 0xce, 0x45, 0xb9}; + uint8_t bytesprops1[] = {0xad, 0x8a, 0x6, 0x9, 0x92, 0x4, 0x7b, 0xa7, 0xf, 0x14, 0x81, + 0x8, 0x1, 0xe8, 0xe, 0x22, 0xfe, 0xb8, 0xd2, 0xc7, 0x16, 0xee}; + uint8_t bytesprops2[] = {0x7f, 0xb7}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30260}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12867}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28350}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7251}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17459, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\222\129", _pubPktID = 4136, -// _pubBody = "\238\173\129\190\233\254\157\252\185\239@\147\192rs\143\219-\185\140j5\231\226Y\SYN+", _pubProps = -// [PropPayloadFormatIndicator 205,PropSubscriptionIdentifierAvailable 143,PropSharedSubscriptionAvailable -// 37,PropCorrelationData "\203\139a^G\132kL",PropMessageExpiryInterval 3837,PropRequestResponseInformation -// 130,PropRequestResponseInformation 238,PropAssignedClientIdentifier -// "B\DLE\132S\191\218s\135z\187\224\237\130\EOT\ETX\195\US\201\183R>>\SOHvk",PropServerKeepAlive -// 10975,PropTopicAliasMaximum 9324,PropTopicAliasMaximum 30282,PropUserProperty "\221 -// v\t\168c,\173\157F\210\233\246\135" "",PropResponseTopic -// "\CAN\159=\DC2>\NAK\132\164\175\130\246\SO>'\187\218\141iF\204\EOT\232^\236{\154=y\135",PropMessageExpiryInterval -// 20998,PropMaximumPacketSize 30109,PropReceiveMaximum 18125,PropReceiveMaximum 19631,PropAuthenticationMethod -// "\211F`x\211\195`\197\211\198\192j\"\218\249\248\NAK",PropSessionExpiryInterval 4788,PropSessionExpiryInterval -// 10477,PropSubscriptionIdentifier 4,PropMaximumPacketSize 16320,PropAuthenticationData -// "\190.\238\220\NAK\230\180\156\228\134/\144\203\&0\b\231[B\129\197",PropPayloadFormatIndicator -// 44,PropSharedSubscriptionAvailable 141,PropRetainAvailable 213,PropRequestProblemInformation -// 147,PropWildcardSubscriptionAvailable 68]} -TEST(Publish50QCTest, Encode9) { - uint8_t pkt[] = { - 0x35, 0xeb, 0x1, 0x0, 0x2, 0xde, 0x81, 0x10, 0x28, 0xc8, 0x1, 0x1, 0xcd, 0x29, 0x8f, 0x2a, 0x25, 0x9, 0x0, - 0x8, 0xcb, 0x8b, 0x61, 0x5e, 0x47, 0x84, 0x6b, 0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xe9, 0xfe, 0x9d, 0xfc, 0xb9, 0xef, 0x40, 0x93, 0xc0, 0x72, 0x73, 0x8f, 0xdb, - 0x2d, 0xb9, 0x8c, 0x6a, 0x35, 0xe7, 0xe2, 0x59, 0x16, 0x2b}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\212\222", _pubPktID = 0, _pubBody +// = "f", _pubProps = [PropSubscriptionIdentifierAvailable 31,PropCorrelationData +// "\250\232\245Rf\128P\RS\t\195\FS\146\&2x\ESC\222H\SOH\136\NUL\198\228\GS\UShfi\164",PropReasonString +// "\144\215V",PropSubscriptionIdentifierAvailable 51,PropMessageExpiryInterval 16252,PropMessageExpiryInterval +// 9192,PropWildcardSubscriptionAvailable 91,PropRequestProblemInformation 221,PropTopicAliasMaximum +// 21616,PropPayloadFormatIndicator 184,PropSubscriptionIdentifierAvailable 34]} +TEST(Publish5QCTest, Encode8) { + uint8_t pkt[] = {0x30, 0x44, 0x0, 0x2, 0xd4, 0xde, 0x3e, 0x29, 0x1f, 0x9, 0x0, 0x1c, 0xfa, 0xe8, + 0xf5, 0x52, 0x66, 0x80, 0x50, 0x1e, 0x9, 0xc3, 0x1c, 0x92, 0x32, 0x78, 0x1b, 0xde, + 0x48, 0x1, 0x88, 0x0, 0xc6, 0xe4, 0x1d, 0x1f, 0x68, 0x66, 0x69, 0xa4, 0x1f, 0x0, + 0x3, 0x90, 0xd7, 0x56, 0x29, 0x33, 0x2, 0x0, 0x0, 0x3f, 0x7c, 0x2, 0x0, 0x0, + 0x23, 0xe8, 0x28, 0x5b, 0x17, 0xdd, 0x22, 0x54, 0x70, 0x1, 0xb8, 0x29, 0x22, 0x66}; - uint8_t buf[248] = {0}; + uint8_t buf[80] = {0}; - uint8_t topic_bytes[] = {0xde, 0x81}; + uint8_t topic_bytes[] = {0xd4, 0xde}; lwmqtt_string_t topic = {2, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xee, 0xad, 0x81, 0xbe, 0xe9, 0xfe, 0x9d, 0xfc, 0xb9, 0xef, 0x40, 0x93, 0xc0, 0x72, - 0x73, 0x8f, 0xdb, 0x2d, 0xb9, 0x8c, 0x6a, 0x35, 0xe7, 0xe2, 0x59, 0x16, 0x2b}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x66}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 1; - uint8_t bytes0[] = {0xcb, 0x8b, 0x61, 0x5e, 0x47, 0x84, 0x6b, 0x4c}; - uint8_t bytes1[] = {0x42, 0x10, 0x84, 0x53, 0xbf, 0xda, 0x73, 0x87, 0x7a, 0xbb, 0xe0, 0xed, 0x82, - 0x4, 0x3, 0xc3, 0x1f, 0xc9, 0xb7, 0x52, 0x3e, 0x3e, 0x1, 0x76, 0x6b}; - uint8_t bytes3[] = {0}; - uint8_t bytes2[] = {0xdd, 0x20, 0x76, 0x9, 0xa8, 0x63, 0x2c, 0xad, 0x9d, 0x46, 0xd2, 0xe9, 0xf6, 0x87}; - uint8_t bytes4[] = {0x18, 0x9f, 0x3d, 0x12, 0x3e, 0x15, 0x84, 0xa4, 0xaf, 0x82, 0xf6, 0xe, 0x3e, 0x27, 0xbb, - 0xda, 0x8d, 0x69, 0x46, 0xcc, 0x4, 0xe8, 0x5e, 0xec, 0x7b, 0x9a, 0x3d, 0x79, 0x87}; - uint8_t bytes5[] = {0xd3, 0x46, 0x60, 0x78, 0xd3, 0xc3, 0x60, 0xc5, 0xd3, - 0xc6, 0xc0, 0x6a, 0x22, 0xda, 0xf9, 0xf8, 0x15}; - uint8_t bytes6[] = {0xbe, 0x2e, 0xee, 0xdc, 0x15, 0xe6, 0xb4, 0x9c, 0xe4, 0x86, - 0x2f, 0x90, 0xcb, 0x30, 0x8, 0xe7, 0x5b, 0x42, 0x81, 0xc5}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3837}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10975}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9324}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30282}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytes2}, .v = {0, (char*)&bytes3}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20998}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30109}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18125}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19631}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4788}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10477}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16320}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 68}}, + uint8_t bytesprops0[] = {0xfa, 0xe8, 0xf5, 0x52, 0x66, 0x80, 0x50, 0x1e, 0x9, 0xc3, 0x1c, 0x92, 0x32, 0x78, + 0x1b, 0xde, 0x48, 0x1, 0x88, 0x0, 0xc6, 0xe4, 0x1d, 0x1f, 0x68, 0x66, 0x69, 0xa4}; + uint8_t bytesprops1[] = {0x90, 0xd7, 0x56}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16252}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9192}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21616}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 4136, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "]Bpc\184\177\176\&3}-\DC4K", _pubProps = [PropRequestProblemInformation 126,PropAuthenticationMethod -// "\199^\140\147\247\203\131+\DLE\174\144\&8wN\203n\207qb\252\200\\\254\ACK`\220",PropWildcardSubscriptionAvailable -// 131,PropMaximumPacketSize 22048,PropRequestProblemInformation 6,PropTopicAlias 5382]} -TEST(Publish50QCTest, Encode10) { - uint8_t pkt[] = {0x30, 0x3a, 0x0, 0x0, 0x2b, 0x17, 0x7e, 0x15, 0x0, 0x1a, 0xc7, 0x5e, 0x8c, 0x93, 0xf7, - 0xcb, 0x83, 0x2b, 0x10, 0xae, 0x90, 0x38, 0x77, 0x4e, 0xcb, 0x6e, 0xcf, 0x71, 0x62, 0xfc, - 0xc8, 0x5c, 0xfe, 0x6, 0x60, 0xdc, 0x28, 0x83, 0x27, 0x0, 0x0, 0x56, 0x20, 0x17, 0x6, - 0x23, 0x15, 0x6, 0x5d, 0x42, 0x70, 0x63, 0xb8, 0xb1, 0xb0, 0x33, 0x7d, 0x2d, 0x14, 0x4b}; - - uint8_t buf[70] = {0}; - - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "u\ESC\171:\189\192\SUB\242!\162\203\208Z\212\177\&5\248\255\138k\213\183+\SUB\132\GS#M\192", _pubPktID = 13057, +// _pubBody = "\168\129\191\243\158\250'%~\DEL0\ESC\210%qk\220\ENQ\241\199", _pubProps = [PropContentType +// "^XfM'v\226[:l\182\185\146N\223\238\187z\143n",PropPayloadFormatIndicator 91,PropMessageExpiryInterval +// 3229,PropAssignedClientIdentifier +// "\212\197\197\&7\RS\167qC\142\237V\175\171\177\246i\198\227\&9I\222",PropContentType +// "\251OiAP\US\202t\135\147>\245\149\228\ETB\233\&8\142 \150\146Mo",PropAssignedClientIdentifier +// "\241\a\180\n\208\207\147\254\207\170 n\142",PropRetainAvailable 241,PropTopicAliasMaximum 12654,PropServerKeepAlive +// 6608,PropTopicAliasMaximum 31149,PropServerReference +// ">5\217\170\139\151\237i\b\186\197z>\173\&5\230?~m",PropRetainAvailable 112,PropSharedSubscriptionAvailable +// 191,PropPayloadFormatIndicator 134,PropSubscriptionIdentifier 20,PropReceiveMaximum 32298,PropRetainAvailable +// 232,PropMessageExpiryInterval 23304,PropAuthenticationData "\187:n\138\182\FS+3",PropReasonString +// "\134\&3\bh\148E\241\SOH\225\135\221o\210\164\245\148",PropRequestResponseInformation 252,PropTopicAliasMaximum +// 413,PropSubscriptionIdentifierAvailable 212,PropRequestResponseInformation 211,PropSubscriptionIdentifier +// 23,PropResponseTopic "\196<\230r\SYN\221\255",PropRequestProblemInformation 99,PropUserProperty "i\SUB\239*\253#\158" +// "L\NUL,u\234\180~Yk\ENQ\202\226_\139a(\178\ETB\194\144o",PropSessionExpiryInterval 32543,PropResponseInformation +// "\205T\201\163\199\187\135o\NUL.QrO\134\172C"]} +TEST(Publish5QCTest, Encode9) { + uint8_t pkt[] = { + 0x3a, 0xb8, 0x2, 0x0, 0x1d, 0x75, 0x1b, 0xab, 0x3a, 0xbd, 0xc0, 0x1a, 0xf2, 0x21, 0xa2, 0xcb, 0xd0, 0x5a, 0xd4, + 0xb1, 0x35, 0xf8, 0xff, 0x8a, 0x6b, 0xd5, 0xb7, 0x2b, 0x1a, 0x84, 0x1d, 0x23, 0x4d, 0xc0, 0x33, 0x1, 0x81, 0x2, + 0x3, 0x0, 0x14, 0x5e, 0x58, 0x66, 0x4d, 0x27, 0x76, 0xe2, 0x5b, 0x3a, 0x6c, 0xb6, 0xb9, 0x92, 0x4e, 0xdf, 0xee, + 0xbb, 0x7a, 0x8f, 0x6e, 0x1, 0x5b, 0x2, 0x0, 0x0, 0xc, 0x9d, 0x12, 0x0, 0x15, 0xd4, 0xc5, 0xc5, 0x37, 0x1e, + 0xa7, 0x71, 0x43, 0x8e, 0xed, 0x56, 0xaf, 0xab, 0xb1, 0xf6, 0x69, 0xc6, 0xe3, 0x39, 0x49, 0xde, 0x3, 0x0, 0x17, + 0xfb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xa3, 0xc7, 0xbb, + 0x87, 0x6f, 0x0, 0x2e, 0x51, 0x72, 0x4f, 0x86, 0xac, 0x43, 0xa8, 0x81, 0xbf, 0xf3, 0x9e, 0xfa, 0x27, 0x25, 0x7e, + 0x7f, 0x30, 0x1b, 0xd2, 0x25, 0x71, 0x6b, 0xdc, 0x5, 0xf1, 0xc7}; + + uint8_t buf[325] = {0}; + + uint8_t topic_bytes[] = {0x75, 0x1b, 0xab, 0x3a, 0xbd, 0xc0, 0x1a, 0xf2, 0x21, 0xa2, 0xcb, 0xd0, 0x5a, 0xd4, 0xb1, + 0x35, 0xf8, 0xff, 0x8a, 0x6b, 0xd5, 0xb7, 0x2b, 0x1a, 0x84, 0x1d, 0x23, 0x4d, 0xc0}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x5d, 0x42, 0x70, 0x63, 0xb8, 0xb1, 0xb0, 0x33, 0x7d, 0x2d, 0x14, 0x4b}; + uint8_t msg_bytes[] = {0xa8, 0x81, 0xbf, 0xf3, 0x9e, 0xfa, 0x27, 0x25, 0x7e, 0x7f, + 0x30, 0x1b, 0xd2, 0x25, 0x71, 0x6b, 0xdc, 0x5, 0xf1, 0xc7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; - - uint8_t bytes0[] = {0xc7, 0x5e, 0x8c, 0x93, 0xf7, 0xcb, 0x83, 0x2b, 0x10, 0xae, 0x90, 0x38, 0x77, - 0x4e, 0xcb, 0x6e, 0xcf, 0x71, 0x62, 0xfc, 0xc8, 0x5c, 0xfe, 0x6, 0x60, 0xdc}; + msg.payload_len = 20; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22048}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5382}}, + uint8_t bytesprops0[] = {0x5e, 0x58, 0x66, 0x4d, 0x27, 0x76, 0xe2, 0x5b, 0x3a, 0x6c, + 0xb6, 0xb9, 0x92, 0x4e, 0xdf, 0xee, 0xbb, 0x7a, 0x8f, 0x6e}; + uint8_t bytesprops1[] = {0xd4, 0xc5, 0xc5, 0x37, 0x1e, 0xa7, 0x71, 0x43, 0x8e, 0xed, 0x56, + 0xaf, 0xab, 0xb1, 0xf6, 0x69, 0xc6, 0xe3, 0x39, 0x49, 0xde}; + uint8_t bytesprops2[] = {0xfb, 0x4f, 0x69, 0x41, 0x50, 0x1f, 0xca, 0x74, 0x87, 0x93, 0x3e, 0xf5, + 0x95, 0xe4, 0x17, 0xe9, 0x38, 0x8e, 0x20, 0x96, 0x92, 0x4d, 0x6f}; + uint8_t bytesprops3[] = {0xf1, 0x7, 0xb4, 0xa, 0xd0, 0xcf, 0x93, 0xfe, 0xcf, 0xaa, 0x20, 0x6e, 0x8e}; + uint8_t bytesprops4[] = {0x3e, 0x35, 0xd9, 0xaa, 0x8b, 0x97, 0xed, 0x69, 0x8, 0xba, + 0xc5, 0x7a, 0x3e, 0xad, 0x35, 0xe6, 0x3f, 0x7e, 0x6d}; + uint8_t bytesprops5[] = {0xbb, 0x3a, 0x6e, 0x8a, 0xb6, 0x1c, 0x2b, 0x33}; + uint8_t bytesprops6[] = {0x86, 0x33, 0x8, 0x68, 0x94, 0x45, 0xf1, 0x1, + 0xe1, 0x87, 0xdd, 0x6f, 0xd2, 0xa4, 0xf5, 0x94}; + uint8_t bytesprops7[] = {0xc4, 0x3c, 0xe6, 0x72, 0x16, 0xdd, 0xff}; + uint8_t bytesprops9[] = {0x4c, 0x0, 0x2c, 0x75, 0xea, 0xb4, 0x7e, 0x59, 0x6b, 0x5, 0xca, + 0xe2, 0x5f, 0x8b, 0x61, 0x28, 0xb2, 0x17, 0xc2, 0x90, 0x6f}; + uint8_t bytesprops8[] = {0x69, 0x1a, 0xef, 0x2a, 0xfd, 0x23, 0x9e}; + uint8_t bytesprops10[] = {0xcd, 0x54, 0xc9, 0xa3, 0xc7, 0xbb, 0x87, 0x6f, + 0x0, 0x2e, 0x51, 0x72, 0x4f, 0x86, 0xac, 0x43}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3229}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12654}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6608}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31149}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32298}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23304}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 413}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops8}, .v = {21, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32543}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 13057, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "/u\181\175\201\CANO", _pubPktID = 0, -// _pubBody = "\234\204\242\217\131\187\a+\140\DC4NsE\f\166\DC1\206pf\ETB\150\193\138\249\166r\189-S\EOT", _pubProps = -// [PropSessionExpiryInterval 16505,PropUserProperty "h(<\233\b\r\183\168]n\190\204\149" "\228hW",PropTopicAliasMaximum -// 22742,PropWildcardSubscriptionAvailable 240,PropAssignedClientIdentifier -// "\133\169",PropSubscriptionIdentifierAvailable 158,PropPayloadFormatIndicator 141,PropSubscriptionIdentifierAvailable -// 8,PropTopicAlias 10002,PropReasonString "\144\205\ft\129\ETX=\129",PropWillDelayInterval 22357]} -TEST(Publish50QCTest, Encode11) { - uint8_t pkt[] = {0x38, 0x65, 0x0, 0x7, 0x2f, 0x75, 0xb5, 0xaf, 0xc9, 0x18, 0x4f, 0x3d, 0x11, 0x0, 0x0, - 0x40, 0x79, 0x26, 0x0, 0xd, 0x68, 0x28, 0x3c, 0xe9, 0x8, 0xd, 0xb7, 0xa8, 0x5d, 0x6e, - 0xbe, 0xcc, 0x95, 0x0, 0x3, 0xe4, 0x68, 0x57, 0x22, 0x58, 0xd6, 0x28, 0xf0, 0x12, 0x0, - 0x2, 0x85, 0xa9, 0x29, 0x9e, 0x1, 0x8d, 0x29, 0x8, 0x23, 0x27, 0x12, 0x1f, 0x0, 0x8, - 0x90, 0xcd, 0xc, 0x74, 0x81, 0x3, 0x3d, 0x81, 0x18, 0x0, 0x0, 0x57, 0x55, 0xea, 0xcc, - 0xf2, 0xd9, 0x83, 0xbb, 0x7, 0x2b, 0x8c, 0x14, 0x4e, 0x73, 0x45, 0xc, 0xa6, 0x11, 0xce, - 0x70, 0x66, 0x17, 0x96, 0xc1, 0x8a, 0xf9, 0xa6, 0x72, 0xbd, 0x2d, 0x53, 0x4}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\186l\242\SOH;D}W:\172\197", +// _pubPktID = 15309, _pubBody = "-\137a\203_YG\210\138\172yL\224>", _pubProps = [PropResponseInformation +// "7M\191\DC1\154",PropPayloadFormatIndicator 204,PropMaximumQoS 99,PropResponseInformation +// "\173\DLE-z\GS\DC2\130n\179",PropWillDelayInterval 22264,PropMaximumPacketSize 9076,PropAuthenticationMethod +// "`\235xe$J\213a\207\213\va\233\182\248\201m\151rn`z{;T",PropMessageExpiryInterval 12687,PropTopicAliasMaximum 22086]} +TEST(Publish5QCTest, Encode10) { + uint8_t pkt[] = {0x3d, 0x65, 0x0, 0xc, 0xfd, 0xba, 0x6c, 0xf2, 0x1, 0x3b, 0x44, 0x7d, 0x57, 0x3a, 0xac, + 0xc5, 0x3b, 0xcd, 0x46, 0x1a, 0x0, 0x5, 0x37, 0x4d, 0xbf, 0x11, 0x9a, 0x1, 0xcc, 0x24, + 0x63, 0x1a, 0x0, 0x9, 0xad, 0x10, 0x2d, 0x7a, 0x1d, 0x12, 0x82, 0x6e, 0xb3, 0x18, 0x0, + 0x0, 0x56, 0xf8, 0x27, 0x0, 0x0, 0x23, 0x74, 0x15, 0x0, 0x19, 0x60, 0xeb, 0x78, 0x65, + 0x24, 0x4a, 0xd5, 0x61, 0xcf, 0xd5, 0xb, 0x61, 0xe9, 0xb6, 0xf8, 0xc9, 0x6d, 0x97, 0x72, + 0x6e, 0x60, 0x7a, 0x7b, 0x3b, 0x54, 0x2, 0x0, 0x0, 0x31, 0x8f, 0x22, 0x56, 0x46, 0x2d, + 0x89, 0x61, 0xcb, 0x5f, 0x59, 0x47, 0xd2, 0x8a, 0xac, 0x79, 0x4c, 0xe0, 0x3e}; uint8_t buf[113] = {0}; - uint8_t topic_bytes[] = {0x2f, 0x75, 0xb5, 0xaf, 0xc9, 0x18, 0x4f}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xfd, 0xba, 0x6c, 0xf2, 0x1, 0x3b, 0x44, 0x7d, 0x57, 0x3a, 0xac, 0xc5}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xea, 0xcc, 0xf2, 0xd9, 0x83, 0xbb, 0x7, 0x2b, 0x8c, 0x14, 0x4e, 0x73, 0x45, 0xc, 0xa6, - 0x11, 0xce, 0x70, 0x66, 0x17, 0x96, 0xc1, 0x8a, 0xf9, 0xa6, 0x72, 0xbd, 0x2d, 0x53, 0x4}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x2d, 0x89, 0x61, 0xcb, 0x5f, 0x59, 0x47, 0xd2, 0x8a, 0xac, 0x79, 0x4c, 0xe0, 0x3e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 14; - uint8_t bytes1[] = {0xe4, 0x68, 0x57}; - uint8_t bytes0[] = {0x68, 0x28, 0x3c, 0xe9, 0x8, 0xd, 0xb7, 0xa8, 0x5d, 0x6e, 0xbe, 0xcc, 0x95}; - uint8_t bytes2[] = {0x85, 0xa9}; - uint8_t bytes3[] = {0x90, 0xcd, 0xc, 0x74, 0x81, 0x3, 0x3d, 0x81}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16505}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytes0}, .v = {3, (char*)&bytes1}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22742}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10002}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22357}}, + uint8_t bytesprops0[] = {0x37, 0x4d, 0xbf, 0x11, 0x9a}; + uint8_t bytesprops1[] = {0xad, 0x10, 0x2d, 0x7a, 0x1d, 0x12, 0x82, 0x6e, 0xb3}; + uint8_t bytesprops2[] = {0x60, 0xeb, 0x78, 0x65, 0x24, 0x4a, 0xd5, 0x61, 0xcf, 0xd5, 0xb, 0x61, 0xe9, + 0xb6, 0xf8, 0xc9, 0x6d, 0x97, 0x72, 0x6e, 0x60, 0x7a, 0x7b, 0x3b, 0x54}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22264}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9076}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12687}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22086}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15309, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "-\243H\202R\162w&\149\233\171\223", -// _pubPktID = 0, _pubBody = "\216\SO\135\ENQ\236\223\tG\203\177\ESC\132\135)\187", _pubProps = [PropReceiveMaximum -// 18550,PropTopicAlias 22808,PropMessageExpiryInterval 2858,PropTopicAliasMaximum 31551,PropServerReference -// "\209M\US;?\164H\186*",PropAssignedClientIdentifier -// ".\146\v\NUL\221V\216@cX=\149\167\138\178^\220\223\198\205",PropAssignedClientIdentifier -// "`W\160\157\191",PropSharedSubscriptionAvailable 115,PropRequestProblemInformation 221,PropRequestResponseInformation -// 228,PropRequestResponseInformation 219,PropSharedSubscriptionAvailable 151,PropSessionExpiryInterval -// 10566,PropAuthenticationData "\168DW\140&\184E\132\251a0ln\201",PropRequestResponseInformation -// 16,PropRequestResponseInformation 115,PropRetainAvailable 178,PropSubscriptionIdentifier -// 15,PropAssignedClientIdentifier -// "\240\EM\v\232\222\145\242\221\228\229\GS!\156\195\230\SOH@y\222r'n\195\159)\225",PropAuthenticationMethod -// "t\171\232\148",PropContentType "}\136\SUB\ENQ-jNG\137\241\EOT\198j\200>\171\177S\ETB",PropContentType -// "U\205E\175",PropRequestProblemInformation 90,PropSubscriptionIdentifierAvailable 152]} -TEST(Publish50QCTest, Encode12) { - uint8_t pkt[] = {0x39, 0xc5, 0x1, 0x0, 0xc, 0x2d, 0xf3, 0x48, 0xca, 0x52, 0xa2, 0x77, 0x26, 0x95, 0xe9, 0xab, 0xdf, - 0xa6, 0x1, 0x21, 0x48, 0x76, 0x23, 0x59, 0x18, 0x2, 0x0, 0x0, 0xb, 0x2a, 0x22, 0x7b, 0x3f, 0x1c, - 0x0, 0x9, 0xd1, 0x4d, 0x1f, 0x3b, 0x3f, 0xa4, 0x48, 0xba, 0x2a, 0x12, 0x0, 0x14, 0x2e, 0x92, 0xb, - 0x0, 0xdd, 0x56, 0xd8, 0x40, 0x63, 0x58, 0x3d, 0x95, 0xa7, 0x8a, 0xb2, 0x5e, 0xdc, 0xdf, 0xc6, 0xcd, - 0x12, 0x0, 0x5, 0x60, 0x57, 0xa0, 0x9d, 0xbf, 0x2a, 0x73, 0x17, 0xdd, 0x19, 0xe4, 0x19, 0xdb, 0x2a, - 0x97, 0x11, 0x0, 0x0, 0x29, 0x46, 0x16, 0x0, 0xe, 0xa8, 0x44, 0x57, 0x8c, 0x26, 0xb8, 0x45, 0x84, - 0xfb, 0x61, 0x30, 0x6c, 0x6e, 0xc9, 0x19, 0x10, 0x19, 0x73, 0x25, 0xb2, 0xb, 0xf, 0x12, 0x0, 0x1a, - 0xf0, 0x19, 0xb, 0xe8, 0xde, 0x91, 0xf2, 0xdd, 0xe4, 0xe5, 0x1d, 0x21, 0x9c, 0xc3, 0xe6, 0x1, 0x40, - 0x79, 0xde, 0x72, 0x27, 0x6e, 0xc3, 0x9f, 0x29, 0xe1, 0x15, 0x0, 0x4, 0x74, 0xab, 0xe8, 0x94, 0x3, - 0x0, 0x13, 0x7d, 0x88, 0x1a, 0x5, 0x2d, 0x6a, 0x4e, 0x47, 0x89, 0xf1, 0x4, 0xc6, 0x6a, 0xc8, 0x3e, - 0xab, 0xb1, 0x53, 0x17, 0x3, 0x0, 0x4, 0x55, 0xcd, 0x45, 0xaf, 0x17, 0x5a, 0x29, 0x98, 0xd8, 0xe, - 0x87, 0x5, 0xec, 0xdf, 0x9, 0x47, 0xcb, 0xb1, 0x1b, 0x84, 0x87, 0x29, 0xbb}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "M\DC3\NAK:\DEL\206\213^_\254\174f\203\221\160U", _pubPktID = 0, _pubBody = "\211\130}", _pubProps = +// [PropAuthenticationData +// "\140\160J\DLE\230\SOH\191\&6\201j\208\f\136]\FS\229V\174\158b<\ACK|\139\192\FS\202\\\200",PropMessageExpiryInterval +// 24738,PropSubscriptionIdentifierAvailable 9,PropRetainAvailable 74,PropWildcardSubscriptionAvailable +// 189,PropSubscriptionIdentifier 21,PropMaximumQoS 102,PropServerKeepAlive 10663,PropWildcardSubscriptionAvailable +// 130,PropMessageExpiryInterval 28057,PropContentType +// "\253V\243.\248#\199R\178\&8\167\209\245f0\ACK\b\165h\255\175\190",PropReceiveMaximum 10701]} +TEST(Publish5QCTest, Encode11) { + uint8_t pkt[] = {0x30, 0x6b, 0x0, 0x10, 0x4d, 0x13, 0x15, 0x3a, 0x7f, 0xce, 0xd5, 0x5e, 0x5f, 0xfe, 0xae, 0x66, + 0xcb, 0xdd, 0xa0, 0x55, 0x55, 0x16, 0x0, 0x1d, 0x8c, 0xa0, 0x4a, 0x10, 0xe6, 0x1, 0xbf, 0x36, + 0xc9, 0x6a, 0xd0, 0xc, 0x88, 0x5d, 0x1c, 0xe5, 0x56, 0xae, 0x9e, 0x62, 0x3c, 0x6, 0x7c, 0x8b, + 0xc0, 0x1c, 0xca, 0x5c, 0xc8, 0x2, 0x0, 0x0, 0x60, 0xa2, 0x29, 0x9, 0x25, 0x4a, 0x28, 0xbd, + 0xb, 0x15, 0x24, 0x66, 0x13, 0x29, 0xa7, 0x28, 0x82, 0x2, 0x0, 0x0, 0x6d, 0x99, 0x3, 0x0, + 0x16, 0xfd, 0x56, 0xf3, 0x2e, 0xf8, 0x23, 0xc7, 0x52, 0xb2, 0x38, 0xa7, 0xd1, 0xf5, 0x66, 0x30, + 0x6, 0x8, 0xa5, 0x68, 0xff, 0xaf, 0xbe, 0x21, 0x29, 0xcd, 0xd3, 0x82, 0x7d}; - uint8_t buf[210] = {0}; + uint8_t buf[119] = {0}; - uint8_t topic_bytes[] = {0x2d, 0xf3, 0x48, 0xca, 0x52, 0xa2, 0x77, 0x26, 0x95, 0xe9, 0xab, 0xdf}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x4d, 0x13, 0x15, 0x3a, 0x7f, 0xce, 0xd5, 0x5e, + 0x5f, 0xfe, 0xae, 0x66, 0xcb, 0xdd, 0xa0, 0x55}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xd8, 0xe, 0x87, 0x5, 0xec, 0xdf, 0x9, 0x47, 0xcb, 0xb1, 0x1b, 0x84, 0x87, 0x29, 0xbb}; + msg.retained = false; + uint8_t msg_bytes[] = {0xd3, 0x82, 0x7d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 3; - uint8_t bytes0[] = {0xd1, 0x4d, 0x1f, 0x3b, 0x3f, 0xa4, 0x48, 0xba, 0x2a}; - uint8_t bytes1[] = {0x2e, 0x92, 0xb, 0x0, 0xdd, 0x56, 0xd8, 0x40, 0x63, 0x58, - 0x3d, 0x95, 0xa7, 0x8a, 0xb2, 0x5e, 0xdc, 0xdf, 0xc6, 0xcd}; - uint8_t bytes2[] = {0x60, 0x57, 0xa0, 0x9d, 0xbf}; - uint8_t bytes3[] = {0xa8, 0x44, 0x57, 0x8c, 0x26, 0xb8, 0x45, 0x84, 0xfb, 0x61, 0x30, 0x6c, 0x6e, 0xc9}; - uint8_t bytes4[] = {0xf0, 0x19, 0xb, 0xe8, 0xde, 0x91, 0xf2, 0xdd, 0xe4, 0xe5, 0x1d, 0x21, 0x9c, - 0xc3, 0xe6, 0x1, 0x40, 0x79, 0xde, 0x72, 0x27, 0x6e, 0xc3, 0x9f, 0x29, 0xe1}; - uint8_t bytes5[] = {0x74, 0xab, 0xe8, 0x94}; - uint8_t bytes6[] = {0x7d, 0x88, 0x1a, 0x5, 0x2d, 0x6a, 0x4e, 0x47, 0x89, 0xf1, - 0x4, 0xc6, 0x6a, 0xc8, 0x3e, 0xab, 0xb1, 0x53, 0x17}; - uint8_t bytes7[] = {0x55, 0xcd, 0x45, 0xaf}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18550}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22808}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2858}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31551}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10566}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, + uint8_t bytesprops0[] = {0x8c, 0xa0, 0x4a, 0x10, 0xe6, 0x1, 0xbf, 0x36, 0xc9, 0x6a, 0xd0, 0xc, 0x88, 0x5d, 0x1c, + 0xe5, 0x56, 0xae, 0x9e, 0x62, 0x3c, 0x6, 0x7c, 0x8b, 0xc0, 0x1c, 0xca, 0x5c, 0xc8}; + uint8_t bytesprops1[] = {0xfd, 0x56, 0xf3, 0x2e, 0xf8, 0x23, 0xc7, 0x52, 0xb2, 0x38, 0xa7, + 0xd1, 0xf5, 0x66, 0x30, 0x6, 0x8, 0xa5, 0x68, 0xff, 0xaf, 0xbe}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24738}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10663}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28057}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10701}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "W\133\164\255\227+ -// \229\201\165[q\DC25\225\242\160 >\bi", _pubPktID = 0, _pubBody = "", _pubProps = [PropSubscriptionIdentifierAvailable -// 214,PropRetainAvailable 23,PropWildcardSubscriptionAvailable 43,PropAuthenticationData -// "\157<\161\249\233\130",PropUserProperty "n*\177\220\176'\196\135\239a\129\133\166\175\SO#\167\238\SI\217\177" -// "\172K\211\132\226\&2\206\242\179>\244\244\237H\229\244d\247+]\a\177",PropServerReference -// "\ESCW\229\249)\243%\132\SI\136GvI\NAK",PropServerReference -// "\ACKH\235\240\213}\181?1\ACK\184\165\247\179\181\180\209",PropUserProperty -// "^8\DC1*\199/\166\208\172g$\161\210\160\217\\\f\DC2\181\254T" -// "\136o\140\255\237\&74\197\ETB\DEL\137\SO\r\222\US",PropMessageExpiryInterval 30944,PropTopicAlias -// 9769,PropAuthenticationData "\173\245\162\193C\249\t\DEL0#\236\142\175\149Y)\209\161\147\ETB",PropUserProperty -// "\t\148\136\138\241\ETX\198\CAN\130\147\186\148\171]\218I\DEL\158\174\&4\142" -// "Q\235&\DC2\159\DC1>\SYN\194\DC21\NAK\254\177#[\218\218Vb\159\197p<",PropSharedSubscriptionAvailable -// 111,PropMaximumQoS 156,PropAuthenticationData -// "d#p\253\181\237\190\v>&\DC1\150\193bE;\134\ENQ\181\198*]\207i",PropSessionExpiryInterval -// 18301,PropAuthenticationData "\152\168\ETX\\\222v%\252o\185\&9\184\&5\187",PropPayloadFormatIndicator -// 228,PropMaximumQoS 192,PropRetainAvailable 35,PropSubscriptionIdentifierAvailable 215,PropTopicAliasMaximum 19410]} -TEST(Publish50QCTest, Encode13) { +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\169|\146E2\GS{\237\&3\166", +// _pubPktID = 0, _pubBody = "#\227\217]\US\238S\163\139\232\165\210\243-", _pubProps = [PropResponseInformation +// "\ESCo\b\237\EOT\t\235|\197m~*\176\f\245\253\171`6F\133\161Z",PropMaximumQoS 238,PropPayloadFormatIndicator +// 177,PropPayloadFormatIndicator 90,PropPayloadFormatIndicator 72,PropResponseTopic "",PropServerReference +// "\138K\245\149\146\CAN\167\ESC\196\&8\ESC6G\246\205\221\182\199",PropPayloadFormatIndicator 182,PropServerReference +// "\239\&02\SO\128",PropReasonString "",PropSessionExpiryInterval 27592,PropServerReference +// "PvV\183\184c\166\227\SUB\238m\154\DC1`\192\227-\244VRh\226\146\\",PropAuthenticationMethod +// "W\DC2`\164/\150\DLE\186\219[\130\176\&8\SUB\148\CAN]J\151E\CAN7b\220\CAN\137\&0~O",PropMaximumQoS +// 158,PropSubscriptionIdentifier 17,PropSubscriptionIdentifier 9,PropUserProperty +// "\198\195\243\232\200\192\nz\157\SYN\199\140\201\242\242}\226\ENQ\208\168\&3>" +// "\SOH\150\146\145",PropSubscriptionIdentifier 1,PropReceiveMaximum 29802,PropRequestProblemInformation +// 219,PropTopicAlias 19865,PropMessageExpiryInterval 11509,PropSessionExpiryInterval 27755]} +TEST(Publish5QCTest, Encode12) { uint8_t pkt[] =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xf9, 0x9, 0x7f, 0x30, 0x23, - 0xec, 0x8e, 0xaf, 0x95, 0x59, 0x29, 0xd1, 0xa1, 0x93, 0x17, 0x26, 0x0, 0x15, 0x9, 0x94, 0x88, 0x8a, 0xf1, 0x3, - 0xc6, 0x18, 0x82, 0x93, 0xba, 0x94, 0xab, 0x5d, 0xda, 0x49, 0x7f, 0x9e, 0xae, 0x34, 0x8e, 0x0, 0x18, 0x51, 0xeb, - 0x26, 0x12, 0x9f, 0x11, 0x3e, 0x16, 0xc2, 0x12, 0x31, 0x15, 0xfe, 0xb1, 0x23, 0x5b, 0xda, 0xda, 0x56, 0x62, 0x9f, - 0xc5, 0x70, 0x3c, 0x2a, 0x6f, 0x24, 0x9c, 0x16, 0x0, 0x18, 0x64, 0x23, 0x70, 0xfd, 0xb5, 0xed, 0xbe, 0xb, 0x3e, - 0x26, 0x11, 0x96, 0xc1, 0x62, 0x45, 0x3b, 0x86, 0x5, 0xb5, 0xc6, 0x2a, 0x5d, 0xcf, 0x69, 0x11, 0x0, 0x0, 0x47, - 0x7d, 0x16, 0x0, 0xe, 0x98, 0xa8, 0x3, 0x5c, 0xde, 0x76, 0x25, 0xfc, 0x6f, 0xb9, 0x39, 0xb8, 0x35, 0xbb, 0x1, - 0xe4, 0x24, 0xc0, 0x25, 0x23, 0x29, 0xd7, 0x22, 0x4b, 0xd2}; - - uint8_t buf[324] = {0}; - - uint8_t topic_bytes[] = {0x57, 0x85, 0xa4, 0xff, 0xe3, 0x2b, 0x20, 0xe5, 0xc9, 0xa5, 0x5b, - 0x71, 0x12, 0x35, 0xe1, 0xf2, 0xa0, 0x20, 0x3e, 0x8, 0x69}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + 0x31, 0xdc, 0x1, 0x0, 0xa, 0xa9, 0x7c, 0x92, 0x45, 0x32, 0x1d, 0x7b, 0xed, 0x33, 0xa6, 0xc0, 0x1, 0x1a, 0x0, + 0x17, 0x1b, 0x6f, 0x8, 0xed, 0x4, 0x9,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, 0x5d, 0x1f, 0xee, 0x53, 0xa3, 0x8b, 0xe8, 0xa5, 0xd2, 0xf3, 0x2d}; + + uint8_t buf[233] = {0}; + + uint8_t topic_bytes[] = {0xa9, 0x7c, 0x92, 0x45, 0x32, 0x1d, 0x7b, 0xed, 0x33, 0xa6}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0}; + msg.retained = true; + uint8_t msg_bytes[] = {0x23, 0xe3, 0xd9, 0x5d, 0x1f, 0xee, 0x53, 0xa3, 0x8b, 0xe8, 0xa5, 0xd2, 0xf3, 0x2d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 14; - uint8_t bytes0[] = {0x9d, 0x3c, 0xa1, 0xf9, 0xe9, 0x82}; - uint8_t bytes2[] = {0xac, 0x4b, 0xd3, 0x84, 0xe2, 0x32, 0xce, 0xf2, 0xb3, 0x3e, 0xf4, - 0xf4, 0xed, 0x48, 0xe5, 0xf4, 0x64, 0xf7, 0x2b, 0x5d, 0x7, 0xb1}; - uint8_t bytes1[] = {0x6e, 0x2a, 0xb1, 0xdc, 0xb0, 0x27, 0xc4, 0x87, 0xef, 0x61, 0x81, - 0x85, 0xa6, 0xaf, 0xe, 0x23, 0xa7, 0xee, 0xf, 0xd9, 0xb1}; - uint8_t bytes3[] = {0x1b, 0x57, 0xe5, 0xf9, 0x29, 0xf3, 0x25, 0x84, 0xf, 0x88, 0x47, 0x76, 0x49, 0x15}; - uint8_t bytes4[] = {0x6, 0x48, 0xeb, 0xf0, 0xd5, 0x7d, 0xb5, 0x3f, 0x31, - 0x6, 0xb8, 0xa5, 0xf7, 0xb3, 0xb5, 0xb4, 0xd1}; - uint8_t bytes6[] = {0x88, 0x6f, 0x8c, 0xff, 0xed, 0x37, 0x34, 0xc5, 0x17, 0x7f, 0x89, 0xe, 0xd, 0xde, 0x1f}; - uint8_t bytes5[] = {0x5e, 0x38, 0x11, 0x2a, 0xc7, 0x2f, 0xa6, 0xd0, 0xac, 0x67, 0x24, - 0xa1, 0xd2, 0xa0, 0xd9, 0x5c, 0xc, 0x12, 0xb5, 0xfe, 0x54}; - uint8_t bytes7[] = {0xad, 0xf5, 0xa2, 0xc1, 0x43, 0xf9, 0x9, 0x7f, 0x30, 0x23, - 0xec, 0x8e, 0xaf, 0x95, 0x59, 0x29, 0xd1, 0xa1, 0x93, 0x17}; - uint8_t bytes9[] = {0x51, 0xeb, 0x26, 0x12, 0x9f, 0x11, 0x3e, 0x16, 0xc2, 0x12, 0x31, 0x15, - 0xfe, 0xb1, 0x23, 0x5b, 0xda, 0xda, 0x56, 0x62, 0x9f, 0xc5, 0x70, 0x3c}; - uint8_t bytes8[] = {0x9, 0x94, 0x88, 0x8a, 0xf1, 0x3, 0xc6, 0x18, 0x82, 0x93, 0xba, - 0x94, 0xab, 0x5d, 0xda, 0x49, 0x7f, 0x9e, 0xae, 0x34, 0x8e}; - uint8_t bytes10[] = {0x64, 0x23, 0x70, 0xfd, 0xb5, 0xed, 0xbe, 0xb, 0x3e, 0x26, 0x11, 0x96, - 0xc1, 0x62, 0x45, 0x3b, 0x86, 0x5, 0xb5, 0xc6, 0x2a, 0x5d, 0xcf, 0x69}; - uint8_t bytes11[] = {0x98, 0xa8, 0x3, 0x5c, 0xde, 0x76, 0x25, 0xfc, 0x6f, 0xb9, 0x39, 0xb8, 0x35, 0xbb}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes1}, .v = {22, (char*)&bytes2}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes5}, .v = {15, (char*)&bytes6}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30944}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9769}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes8}, .v = {24, (char*)&bytes9}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytes10}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18301}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytes11}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19410}}, + uint8_t bytesprops0[] = {0x1b, 0x6f, 0x8, 0xed, 0x4, 0x9, 0xeb, 0x7c, 0xc5, 0x6d, 0x7e, 0x2a, + 0xb0, 0xc, 0xf5, 0xfd, 0xab, 0x60, 0x36, 0x46, 0x85, 0xa1, 0x5a}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x8a, 0x4b, 0xf5, 0x95, 0x92, 0x18, 0xa7, 0x1b, 0xc4, + 0x38, 0x1b, 0x36, 0x47, 0xf6, 0xcd, 0xdd, 0xb6, 0xc7}; + uint8_t bytesprops3[] = {0xef, 0x30, 0x32, 0xe, 0x80}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0x50, 0x76, 0x56, 0xb7, 0xb8, 0x63, 0xa6, 0xe3, 0x1a, 0xee, 0x6d, 0x9a, + 0x11, 0x60, 0xc0, 0xe3, 0x2d, 0xf4, 0x56, 0x52, 0x68, 0xe2, 0x92, 0x5c}; + uint8_t bytesprops6[] = {0x57, 0x12, 0x60, 0xa4, 0x2f, 0x96, 0x10, 0xba, 0xdb, 0x5b, 0x82, 0xb0, 0x38, 0x1a, 0x94, + 0x18, 0x5d, 0x4a, 0x97, 0x45, 0x18, 0x37, 0x62, 0xdc, 0x18, 0x89, 0x30, 0x7e, 0x4f}; + uint8_t bytesprops8[] = {0x1, 0x96, 0x92, 0x91}; + uint8_t bytesprops7[] = {0xc6, 0xc3, 0xf3, 0xe8, 0xc8, 0xc0, 0xa, 0x7a, 0x9d, 0x16, 0xc7, + 0x8c, 0xc9, 0xf2, 0xf2, 0x7d, 0xe2, 0x5, 0xd0, 0xa8, 0x33, 0x3e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27592}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops7}, .v = {4, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29802}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19865}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11509}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27755}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); @@ -3584,517 +3745,580 @@ TEST(Publish50QCTest, Encode13) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "R\227\143", _pubPktID = 0, _pubBody -// = "\199\n\253\247[u\151,J\129\t\179\246y0]\143\131\146\&4n*\175\136\&6\181\148Z\ETX", _pubProps = -// [PropSubscriptionIdentifier 9,PropWildcardSubscriptionAvailable 205,PropSubscriptionIdentifierAvailable -// 20,PropAuthenticationData "`\215\227\DC3k\194\228\153\&4\r\194\144Q\145\169\131m\DC1\205\213j",PropReasonString -// "=N\196\ETX\FSF\244\&1\160W\203\232|\\,\DC3\172{\254\198\&4Y\170?\156N\NUL",PropReceiveMaximum -// 5394,PropSubscriptionIdentifierAvailable 138,PropSharedSubscriptionAvailable 56,PropServerKeepAlive -// 18116,PropTopicAliasMaximum 27624,PropServerKeepAlive 14050,PropServerKeepAlive -// 27431,PropSubscriptionIdentifierAvailable 88,PropResponseTopic -// "%A\213je\227\&9\143\204\&9u_\162\163\185S\191\177\218",PropWildcardSubscriptionAvailable 46,PropReasonString -// "\186I\218\vN\219\220\201",PropContentType "\194n|\131\DC2c\175\141",PropAuthenticationData -// "/\150\178\178\171\234A\ETX\237\&1w\214\150H",PropSubscriptionIdentifier 21,PropServerKeepAlive -// 7628,PropMessageExpiryInterval 30833]} -TEST(Publish50QCTest, Encode14) { - uint8_t pkt[] = {0x38, 0xbe, 0x1, 0x0, 0x3, 0x52, 0xe3, 0x8f, 0x9a, 0x1, 0xb, 0x9, 0x28, 0xcd, 0x29, 0x14, 0x16, - 0x0, 0x15, 0x60, 0xd7, 0xe3, 0x13, 0x6b, 0xc2, 0xe4, 0x99, 0x34, 0xd, 0xc2, 0x90, 0x51, 0x91, 0xa9, - 0x83, 0x6d, 0x11, 0xcd, 0xd5, 0x6a, 0x1f, 0x0, 0x1b, 0x3d, 0x4e, 0xc4, 0x3, 0x1c, 0x46, 0xf4, 0x31, - 0xa0, 0x57, 0xcb, 0xe8, 0x7c, 0x5c, 0x2c, 0x13, 0xac, 0x7b, 0xfe, 0xc6, 0x34, 0x59, 0xaa, 0x3f, 0x9c, - 0x4e, 0x0, 0x21, 0x15, 0x12, 0x29, 0x8a, 0x2a, 0x38, 0x13, 0x46, 0xc4, 0x22, 0x6b, 0xe8, 0x13, 0x36, - 0xe2, 0x13, 0x6b, 0x27, 0x29, 0x58, 0x8, 0x0, 0x13, 0x25, 0x41, 0xd5, 0x6a, 0x65, 0xe3, 0x39, 0x8f, - 0xcc, 0x39, 0x75, 0x5f, 0xa2, 0xa3, 0xb9, 0x53, 0xbf, 0xb1, 0xda, 0x28, 0x2e, 0x1f, 0x0, 0x8, 0xba, - 0x49, 0xda, 0xb, 0x4e, 0xdb, 0xdc, 0xc9, 0x3, 0x0, 0x8, 0xc2, 0x6e, 0x7c, 0x83, 0x12, 0x63, 0xaf, - 0x8d, 0x16, 0x0, 0xe, 0x2f, 0x96, 0xb2, 0xb2, 0xab, 0xea, 0x41, 0x3, 0xed, 0x31, 0x77, 0xd6, 0x96, - 0x48, 0xb, 0x15, 0x13, 0x1d, 0xcc, 0x2, 0x0, 0x0, 0x78, 0x71, 0xc7, 0xa, 0xfd, 0xf7, 0x5b, 0x75, - 0x97, 0x2c, 0x4a, 0x81, 0x9, 0xb3, 0xf6, 0x79, 0x30, 0x5d, 0x8f, 0x83, 0x92, 0x34, 0x6e, 0x2a, 0xaf, - 0x88, 0x36, 0xb5, 0x94, 0x5a, 0x3}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\187\253\202u\190\\@\215", _pubPktID +// = 27515, _pubBody = "\146q\173U}?\142kjA\ETX\187\155\EOT#K\207\&8x\224\244\133\241\t\146I\241", _pubProps = +// [PropPayloadFormatIndicator 160,PropResponseTopic "\226\202 +// \245S\205Z\129\227_\136\241\"B}\235\&3\NUL\SOHO\213",PropPayloadFormatIndicator 23,PropWillDelayInterval +// 9922,PropTopicAlias 26620,PropResponseInformation +// "\SUB]\213t\222\SUB\162\230\206\"\ESC\236\199{Nq\251",PropRequestProblemInformation 175,PropMaximumQoS +// 94,PropContentType "\NUL\215Y\228q.\ESC\ETB",PropMessageExpiryInterval 26757,PropReceiveMaximum 30209,PropContentType +// "-\f1\223",PropResponseInformation +// "\174\208\149\t\161\194jG\FSz\238\227\242\145\243\194\239B=\229",PropMessageExpiryInterval +// 4476,PropRequestProblemInformation 106,PropCorrelationData +// "h=\216\237\192\192>\223~\140\153\197\193\191\"\170\SOHF\240\131+d\205\252",PropAuthenticationMethod +// "Z(9\177\156\221\ETBe\156\&8\205`\132\132l\f",PropServerReference +// "\130UyI\211\GSr\202\216k^\255\220\NULq\US",PropAuthenticationMethod "\248\"\195K\CAN4r",PropAuthenticationData +// "\135\151\255\231v\246",PropServerReference +// "J\169s\207D\146qo\GS\n\156\151\134\186&\134\SYN\\\243\141\136",PropMessageExpiryInterval 11426]} +TEST(Publish5QCTest, Encode13) { + uint8_t pkt[] = { + 0x3c, 0x8e, 0x2, 0x0, 0x8, 0xbb, 0xfd, 0xca, 0x75, 0xbe, 0x5c, 0x40, 0xd7, 0x6b, 0x7b, 0xe5, 0x1, 0x1, 0xa0, + 0x8, 0x0, 0x15, 0xe2, 0xca, 0x20, 0xf5, 0x53, 0xcd, 0x5a, 0x81, 0xe3, 0x5f, 0x88, 0xf1, 0x22, 0x42, 0x7d, 0xeb, + 0x33, 0x0, 0x1, 0x4f, 0xd5, 0x1, 0x17, 0x18, 0x0, 0x0, 0x26, 0xc2, 0x23, 0x67, 0xfc, 0x1a, 0x0, 0x11, 0x1a, + 0x5d, 0xd5, 0x74, 0xde, 0x1a, 0xa2, 0xe6, 0xce, 0x22, 0x1b, 0xec, 0xc7, 0x7b, 0x4e, 0x71, 0xfb, 0x17, 0xaf, 0x24, + 0x5e, 0x3, 0x0, 0x8, 0x0, 0xd7, 0x59, 0xe4, 0x71, 0x2e, 0x1b, 0x17, 0x2, 0x0, 0x0, 0x68, 0x85, 0x21, 0x76, + 0x1, 0x3, 0x0, 0x4, 0x2d, 0xc, 0x31, 0xdf, 0x1a, 0x0, 0x14, 0xae, 0xd0, 0x95, 0x9, 0xa1, 0xc2, 0x6a, 0x47, + 0x1c, 0x7a, 0xee, 0xe3, 0xf2, 0x91, 0xf3, 0xc2, 0xef, 0x42, 0x3d, 0xe5, 0x2, 0x0, 0x0, 0x11, 0x7c, 0x17, 0x6a, + 0x9, 0x0, 0x18, 0x68, 0x3d, 0xd8, 0xed, 0xc0, 0xc0, 0x3e, 0xdf, 0x7e, 0x8c, 0x99, 0xc5, 0xc1, 0xbf, 0x22, 0xaa, + 0x1, 0x46, 0xf0, 0x83, 0x2b, 0x64, 0xcd, 0xfc, 0x15, 0x0, 0x10, 0x5a, 0x28, 0x39, 0xb1, 0x9c, 0xdd, 0x17, 0x65, + 0x9c, 0x38, 0xcd, 0x60, 0x84, 0x84, 0x6c, 0xc, 0x1c, 0x0, 0x10, 0x82, 0x55, 0x79, 0x49, 0xd3, 0x1d, 0x72, 0xca, + 0xd8, 0x6b, 0x5e, 0xff, 0xdc, 0x0, 0x71, 0x1f, 0x15, 0x0, 0x7, 0xf8, 0x22, 0xc3, 0x4b, 0x18, 0x34, 0x72, 0x16, + 0x0, 0x6, 0x87, 0x97, 0xff, 0xe7, 0x76, 0xf6, 0x1c, 0x0, 0x15, 0x4a, 0xa9, 0x73, 0xcf, 0x44, 0x92, 0x71, 0x6f, + 0x1d, 0xa, 0x9c, 0x97, 0x86, 0xba, 0x26, 0x86, 0x16, 0x5c, 0xf3, 0x8d, 0x88, 0x2, 0x0, 0x0, 0x2c, 0xa2, 0x92, + 0x71, 0xad, 0x55, 0x7d, 0x3f, 0x8e, 0x6b, 0x6a, 0x41, 0x3, 0xbb, 0x9b, 0x4, 0x23, 0x4b, 0xcf, 0x38, 0x78, 0xe0, + 0xf4, 0x85, 0xf1, 0x9, 0x92, 0x49, 0xf1}; - uint8_t buf[203] = {0}; + uint8_t buf[283] = {0}; - uint8_t topic_bytes[] = {0x52, 0xe3, 0x8f}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xbb, 0xfd, 0xca, 0x75, 0xbe, 0x5c, 0x40, 0xd7}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xc7, 0xa, 0xfd, 0xf7, 0x5b, 0x75, 0x97, 0x2c, 0x4a, 0x81, 0x9, 0xb3, 0xf6, 0x79, 0x30, - 0x5d, 0x8f, 0x83, 0x92, 0x34, 0x6e, 0x2a, 0xaf, 0x88, 0x36, 0xb5, 0x94, 0x5a, 0x3}; + uint8_t msg_bytes[] = {0x92, 0x71, 0xad, 0x55, 0x7d, 0x3f, 0x8e, 0x6b, 0x6a, 0x41, 0x3, 0xbb, 0x9b, 0x4, + 0x23, 0x4b, 0xcf, 0x38, 0x78, 0xe0, 0xf4, 0x85, 0xf1, 0x9, 0x92, 0x49, 0xf1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 27; - uint8_t bytes0[] = {0x60, 0xd7, 0xe3, 0x13, 0x6b, 0xc2, 0xe4, 0x99, 0x34, 0xd, 0xc2, - 0x90, 0x51, 0x91, 0xa9, 0x83, 0x6d, 0x11, 0xcd, 0xd5, 0x6a}; - uint8_t bytes1[] = {0x3d, 0x4e, 0xc4, 0x3, 0x1c, 0x46, 0xf4, 0x31, 0xa0, 0x57, 0xcb, 0xe8, 0x7c, 0x5c, - 0x2c, 0x13, 0xac, 0x7b, 0xfe, 0xc6, 0x34, 0x59, 0xaa, 0x3f, 0x9c, 0x4e, 0x0}; - uint8_t bytes2[] = {0x25, 0x41, 0xd5, 0x6a, 0x65, 0xe3, 0x39, 0x8f, 0xcc, 0x39, - 0x75, 0x5f, 0xa2, 0xa3, 0xb9, 0x53, 0xbf, 0xb1, 0xda}; - uint8_t bytes3[] = {0xba, 0x49, 0xda, 0xb, 0x4e, 0xdb, 0xdc, 0xc9}; - uint8_t bytes4[] = {0xc2, 0x6e, 0x7c, 0x83, 0x12, 0x63, 0xaf, 0x8d}; - uint8_t bytes5[] = {0x2f, 0x96, 0xb2, 0xb2, 0xab, 0xea, 0x41, 0x3, 0xed, 0x31, 0x77, 0xd6, 0x96, 0x48}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5394}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18116}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27624}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14050}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27431}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7628}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30833}}, + uint8_t bytesprops0[] = {0xe2, 0xca, 0x20, 0xf5, 0x53, 0xcd, 0x5a, 0x81, 0xe3, 0x5f, 0x88, + 0xf1, 0x22, 0x42, 0x7d, 0xeb, 0x33, 0x0, 0x1, 0x4f, 0xd5}; + uint8_t bytesprops1[] = {0x1a, 0x5d, 0xd5, 0x74, 0xde, 0x1a, 0xa2, 0xe6, 0xce, + 0x22, 0x1b, 0xec, 0xc7, 0x7b, 0x4e, 0x71, 0xfb}; + uint8_t bytesprops2[] = {0x0, 0xd7, 0x59, 0xe4, 0x71, 0x2e, 0x1b, 0x17}; + uint8_t bytesprops3[] = {0x2d, 0xc, 0x31, 0xdf}; + uint8_t bytesprops4[] = {0xae, 0xd0, 0x95, 0x9, 0xa1, 0xc2, 0x6a, 0x47, 0x1c, 0x7a, + 0xee, 0xe3, 0xf2, 0x91, 0xf3, 0xc2, 0xef, 0x42, 0x3d, 0xe5}; + uint8_t bytesprops5[] = {0x68, 0x3d, 0xd8, 0xed, 0xc0, 0xc0, 0x3e, 0xdf, 0x7e, 0x8c, 0x99, 0xc5, + 0xc1, 0xbf, 0x22, 0xaa, 0x1, 0x46, 0xf0, 0x83, 0x2b, 0x64, 0xcd, 0xfc}; + uint8_t bytesprops6[] = {0x5a, 0x28, 0x39, 0xb1, 0x9c, 0xdd, 0x17, 0x65, + 0x9c, 0x38, 0xcd, 0x60, 0x84, 0x84, 0x6c, 0xc}; + uint8_t bytesprops7[] = {0x82, 0x55, 0x79, 0x49, 0xd3, 0x1d, 0x72, 0xca, + 0xd8, 0x6b, 0x5e, 0xff, 0xdc, 0x0, 0x71, 0x1f}; + uint8_t bytesprops8[] = {0xf8, 0x22, 0xc3, 0x4b, 0x18, 0x34, 0x72}; + uint8_t bytesprops9[] = {0x87, 0x97, 0xff, 0xe7, 0x76, 0xf6}; + uint8_t bytesprops10[] = {0x4a, 0xa9, 0x73, 0xcf, 0x44, 0x92, 0x71, 0x6f, 0x1d, 0xa, 0x9c, + 0x97, 0x86, 0xba, 0x26, 0x86, 0x16, 0x5c, 0xf3, 0x8d, 0x88}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9922}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26620}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26757}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30209}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4476}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11426}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 27515, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\DEL-\129\&3\194M2T6\ETBV5_#\188$\131T\222\ESC\137\a.\147%b", _pubPktID = 0, _pubBody = -// "\v]\154\169\138\225f:\202\251\DLEgw{\243\150\155\DELc8", _pubProps = [PropWillDelayInterval 7111,PropReasonString -// "\171",PropReasonString "\200\&4\NAKs\227\170{r\135\203\DEL\148\USeA",PropTopicAliasMaximum -// 27837,PropRequestProblemInformation 228,PropMessageExpiryInterval 2640,PropMessageExpiryInterval -// 21020,PropAssignedClientIdentifier "z\208%_;\f\SO3\US\186[\220\191?A\214\162I\248\200\144\172J",PropServerKeepAlive -// 5972,PropSessionExpiryInterval 2704,PropReasonString -// "\"\242\156\182\173n\198\218\207\249\179\194\138\250\145\162y#",PropTopicAliasMaximum 9402,PropRetainAvailable -// 8,PropAssignedClientIdentifier "\167\175 -// \144*\243/N\240p\139\237rMY^\128E\EM\SO_\151\SYN\208u]\181\212\190",PropSubscriptionIdentifier 5,PropReasonString -// "\155\254\128)\188\243\147\FS\239",PropServerReference -// "\EM(\162\209\GS\231\140\&3x\209\187\199E\144\201\213\154\252\248CF\226\&0\188\174]}",PropMaximumQoS 2]} -TEST(Publish50QCTest, Encode15) { - uint8_t pkt[] = {0x30, 0xe6, 0x1, 0x0, 0x1a, 0x7f, 0x2d, 0x81, 0x33, 0xc2, 0x4d, 0x32, 0x54, 0x36, 0x17, 0x56, 0x35, - 0x5f, 0x23, 0xbc, 0x24, 0x83, 0x54, 0xde, 0x1b, 0x89, 0x7, 0x2e, 0x93, 0x25, 0x62, 0xb4, 0x1, 0x18, - 0x0, 0x0, 0x1b, 0xc7, 0x1f, 0x0, 0x1, 0xab, 0x1f, 0x0, 0xf, 0xc8, 0x34, 0x15, 0x73, 0xe3, 0xaa, - 0x7b, 0x72, 0x87, 0xcb, 0x7f, 0x94, 0x1f, 0x65, 0x41, 0x22, 0x6c, 0xbd, 0x17, 0xe4, 0x2, 0x0, 0x0, - 0xa, 0x50, 0x2, 0x0, 0x0, 0x52, 0x1c, 0x12, 0x0, 0x17, 0x7a, 0xd0, 0x25, 0x5f, 0x3b, 0xc, 0xe, - 0x33, 0x1f, 0xba, 0x5b, 0xdc, 0xbf, 0x3f, 0x41, 0xd6, 0xa2, 0x49, 0xf8, 0xc8, 0x90, 0xac, 0x4a, 0x13, - 0x17, 0x54, 0x11, 0x0, 0x0, 0xa, 0x90, 0x1f, 0x0, 0x12, 0x22, 0xf2, 0x9c, 0xb6, 0xad, 0x6e, 0xc6, - 0xda, 0xcf, 0xf9, 0xb3, 0xc2, 0x8a, 0xfa, 0x91, 0xa2, 0x79, 0x23, 0x22, 0x24, 0xba, 0x25, 0x8, 0x12, - 0x0, 0x1d, 0xa7, 0xaf, 0x20, 0x90, 0x2a, 0xf3, 0x2f, 0x4e, 0xf0, 0x70, 0x8b, 0xed, 0x72, 0x4d, 0x59, - 0x5e, 0x80, 0x45, 0x19, 0xe, 0x5f, 0x97, 0x16, 0xd0, 0x75, 0x5d, 0xb5, 0xd4, 0xbe, 0xb, 0x5, 0x1f, - 0x0, 0x9, 0x9b, 0xfe, 0x80, 0x29, 0xbc, 0xf3, 0x93, 0x1c, 0xef, 0x1c, 0x0, 0x1b, 0x19, 0x28, 0xa2, - 0xd1, 0x1d, 0xe7, 0x8c, 0x33, 0x78, 0xd1, 0xbb, 0xc7, 0x45, 0x90, 0xc9, 0xd5, 0x9a, 0xfc, 0xf8, 0x43, - 0x46, 0xe2, 0x30, 0xbc, 0xae, 0x5d, 0x7d, 0x24, 0x2, 0xb, 0x5d, 0x9a, 0xa9, 0x8a, 0xe1, 0x66, 0x3a, - 0xca, 0xfb, 0x10, 0x67, 0x77, 0x7b, 0xf3, 0x96, 0x9b, 0x7f, 0x63, 0x38}; - - uint8_t buf[243] = {0}; - - uint8_t topic_bytes[] = {0x7f, 0x2d, 0x81, 0x33, 0xc2, 0x4d, 0x32, 0x54, 0x36, 0x17, 0x56, 0x35, 0x5f, - 0x23, 0xbc, 0x24, 0x83, 0x54, 0xde, 0x1b, 0x89, 0x7, 0x2e, 0x93, 0x25, 0x62}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\163\147\204\140\129\152\150A\187\249", _pubPktID = 15054, _pubBody = "C\207+gu\184\240\&5~z\148f", _pubProps = +// [PropWillDelayInterval 13896,PropTopicAliasMaximum 22435,PropAssignedClientIdentifier +// "\145\215\253Ef0y\b\184,1\173r\243\241\194\b\213\184P%",PropSharedSubscriptionAvailable 98,PropSessionExpiryInterval +// 13964,PropTopicAlias 11550,PropMaximumPacketSize 31812,PropSubscriptionIdentifierAvailable 140,PropWillDelayInterval +// 22185,PropTopicAliasMaximum 25699,PropSessionExpiryInterval 4043,PropTopicAliasMaximum 14577,PropUserProperty +// "-:\192\STX\171\252$\215\198)\204" +// "vMG\132s\143\225-\244\136\ETX'\199^O\215\211\181\235u\221=\157~\189\145d",PropSubscriptionIdentifierAvailable +// 172,PropReceiveMaximum 21448,PropWildcardSubscriptionAvailable 18,PropPayloadFormatIndicator +// 210,PropWillDelayInterval 31421,PropAssignedClientIdentifier "j\149\157",PropContentType +// "\211I\142\244\176\ETX\199\223\SUB\245\188l\207o\"\141\174V\237\146x\201",PropResponseInformation +// "\SIo\203\"\176\187\DC1\179I\""]} +TEST(Publish5QCTest, Encode14) { + uint8_t pkt[] = {0x3d, 0xc2, 0x1, 0x0, 0xa, 0xa3, 0x93, 0xcc, 0x8c, 0x81, 0x98, 0x96, 0x41, 0xbb, 0xf9, 0x3a, 0xce, + 0xa6, 0x1, 0x18, 0x0, 0x0, 0x36, 0x48, 0x22, 0x57, 0xa3, 0x12, 0x0, 0x15, 0x91, 0xd7, 0xfd, 0x45, + 0x66, 0x30, 0x79, 0x8, 0xb8, 0x2c, 0x31, 0xad, 0x72, 0xf3, 0xf1, 0xc2, 0x8, 0xd5, 0xb8, 0x50, 0x25, + 0x2a, 0x62, 0x11, 0x0, 0x0, 0x36, 0x8c, 0x23, 0x2d, 0x1e, 0x27, 0x0, 0x0, 0x7c, 0x44, 0x29, 0x8c, + 0x18, 0x0, 0x0, 0x56, 0xa9, 0x22, 0x64, 0x63, 0x11, 0x0, 0x0, 0xf, 0xcb, 0x22, 0x38, 0xf1, 0x26, + 0x0, 0xb, 0x2d, 0x3a, 0xc0, 0x2, 0xab, 0xfc, 0x24, 0xd7, 0xc6, 0x29, 0xcc, 0x0, 0x1b, 0x76, 0x4d, + 0x47, 0x84, 0x73, 0x8f, 0xe1, 0x2d, 0xf4, 0x88, 0x3, 0x27, 0xc7, 0x5e, 0x4f, 0xd7, 0xd3, 0xb5, 0xeb, + 0x75, 0xdd, 0x3d, 0x9d, 0x7e, 0xbd, 0x91, 0x64, 0x29, 0xac, 0x21, 0x53, 0xc8, 0x28, 0x12, 0x1, 0xd2, + 0x18, 0x0, 0x0, 0x7a, 0xbd, 0x12, 0x0, 0x3, 0x6a, 0x95, 0x9d, 0x3, 0x0, 0x16, 0xd3, 0x49, 0x8e, + 0xf4, 0xb0, 0x3, 0xc7, 0xdf, 0x1a, 0xf5, 0xbc, 0x6c, 0xcf, 0x6f, 0x22, 0x8d, 0xae, 0x56, 0xed, 0x92, + 0x78, 0xc9, 0x1a, 0x0, 0xa, 0xf, 0x6f, 0xcb, 0x22, 0xb0, 0xbb, 0x11, 0xb3, 0x49, 0x22, 0x43, 0xcf, + 0x2b, 0x67, 0x75, 0xb8, 0xf0, 0x35, 0x7e, 0x7a, 0x94, 0x66}; + + uint8_t buf[207] = {0}; + + uint8_t topic_bytes[] = {0xa3, 0x93, 0xcc, 0x8c, 0x81, 0x98, 0x96, 0x41, 0xbb, 0xf9}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xb, 0x5d, 0x9a, 0xa9, 0x8a, 0xe1, 0x66, 0x3a, 0xca, 0xfb, - 0x10, 0x67, 0x77, 0x7b, 0xf3, 0x96, 0x9b, 0x7f, 0x63, 0x38}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x43, 0xcf, 0x2b, 0x67, 0x75, 0xb8, 0xf0, 0x35, 0x7e, 0x7a, 0x94, 0x66}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 12; - uint8_t bytes0[] = {0xab}; - uint8_t bytes1[] = {0xc8, 0x34, 0x15, 0x73, 0xe3, 0xaa, 0x7b, 0x72, 0x87, 0xcb, 0x7f, 0x94, 0x1f, 0x65, 0x41}; - uint8_t bytes2[] = {0x7a, 0xd0, 0x25, 0x5f, 0x3b, 0xc, 0xe, 0x33, 0x1f, 0xba, 0x5b, 0xdc, - 0xbf, 0x3f, 0x41, 0xd6, 0xa2, 0x49, 0xf8, 0xc8, 0x90, 0xac, 0x4a}; - uint8_t bytes3[] = {0x22, 0xf2, 0x9c, 0xb6, 0xad, 0x6e, 0xc6, 0xda, 0xcf, - 0xf9, 0xb3, 0xc2, 0x8a, 0xfa, 0x91, 0xa2, 0x79, 0x23}; - uint8_t bytes4[] = {0xa7, 0xaf, 0x20, 0x90, 0x2a, 0xf3, 0x2f, 0x4e, 0xf0, 0x70, 0x8b, 0xed, 0x72, 0x4d, 0x59, - 0x5e, 0x80, 0x45, 0x19, 0xe, 0x5f, 0x97, 0x16, 0xd0, 0x75, 0x5d, 0xb5, 0xd4, 0xbe}; - uint8_t bytes5[] = {0x9b, 0xfe, 0x80, 0x29, 0xbc, 0xf3, 0x93, 0x1c, 0xef}; - uint8_t bytes6[] = {0x19, 0x28, 0xa2, 0xd1, 0x1d, 0xe7, 0x8c, 0x33, 0x78, 0xd1, 0xbb, 0xc7, 0x45, 0x90, - 0xc9, 0xd5, 0x9a, 0xfc, 0xf8, 0x43, 0x46, 0xe2, 0x30, 0xbc, 0xae, 0x5d, 0x7d}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7111}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27837}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2640}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21020}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5972}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2704}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9402}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 2}}, + uint8_t bytesprops0[] = {0x91, 0xd7, 0xfd, 0x45, 0x66, 0x30, 0x79, 0x8, 0xb8, 0x2c, 0x31, + 0xad, 0x72, 0xf3, 0xf1, 0xc2, 0x8, 0xd5, 0xb8, 0x50, 0x25}; + uint8_t bytesprops2[] = {0x76, 0x4d, 0x47, 0x84, 0x73, 0x8f, 0xe1, 0x2d, 0xf4, 0x88, 0x3, 0x27, 0xc7, 0x5e, + 0x4f, 0xd7, 0xd3, 0xb5, 0xeb, 0x75, 0xdd, 0x3d, 0x9d, 0x7e, 0xbd, 0x91, 0x64}; + uint8_t bytesprops1[] = {0x2d, 0x3a, 0xc0, 0x2, 0xab, 0xfc, 0x24, 0xd7, 0xc6, 0x29, 0xcc}; + uint8_t bytesprops3[] = {0x6a, 0x95, 0x9d}; + uint8_t bytesprops4[] = {0xd3, 0x49, 0x8e, 0xf4, 0xb0, 0x3, 0xc7, 0xdf, 0x1a, 0xf5, 0xbc, + 0x6c, 0xcf, 0x6f, 0x22, 0x8d, 0xae, 0x56, 0xed, 0x92, 0x78, 0xc9}; + uint8_t bytesprops5[] = {0xf, 0x6f, 0xcb, 0x22, 0xb0, 0xbb, 0x11, 0xb3, 0x49, 0x22}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13896}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22435}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13964}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11550}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31812}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22185}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25699}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4043}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14577}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {27, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21448}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31421}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15054, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\250\181\213\174\156\146\244\243\180\160\170=", _pubPktID = 24114, _pubBody = -// "\GS-\202|\237\STX\ENQ\EM\159\143\130\NAK\242\212\182Cg\172#\193\150v\226", _pubProps = [PropResponseInformation -// "O\196\178g\200\DEL*\ETX\SOH\203\FS\162\159\147\DC1(\164\128\203\&4Y*",PropServerReference -// "5\159n\242\179\fp\164\at",PropPayloadFormatIndicator 46,PropWillDelayInterval 4675,PropMaximumPacketSize -// 11858,PropCorrelationData "\219\221\206\252\181\220\196#}0\243y\ETB\ETBM7R\155u\197\239\242\198\209",PropMaximumQoS -// 169,PropAuthenticationData -// "\189]0\223\235\224P'\131He\\\STX<\172\192\202m\242\149^\ETX\ACK,\151",PropSubscriptionIdentifier -// 17,PropSubscriptionIdentifier 29,PropMaximumQoS 216,PropMaximumPacketSize 19820,PropServerKeepAlive 21055]} -TEST(Publish50QCTest, Encode16) { - uint8_t pkt[] = {0x34, 0xa1, 0x1, 0x0, 0xc, 0xfa, 0xb5, 0xd5, 0xae, 0x9c, 0x92, 0xf4, 0xf3, 0xb4, 0xa0, 0xaa, 0x3d, - 0x5e, 0x32, 0x79, 0x1a, 0x0, 0x16, 0x4f, 0xc4, 0xb2, 0x67, 0xc8, 0x7f, 0x2a, 0x3, 0x1, 0xcb, 0x1c, - 0xa2, 0x9f, 0x93, 0x11, 0x28, 0xa4, 0x80, 0xcb, 0x34, 0x59, 0x2a, 0x1c, 0x0, 0xa, 0x35, 0x9f, 0x6e, - 0xf2, 0xb3, 0xc, 0x70, 0xa4, 0x7, 0x74, 0x1, 0x2e, 0x18, 0x0, 0x0, 0x12, 0x43, 0x27, 0x0, 0x0, - 0x2e, 0x52, 0x9, 0x0, 0x18, 0xdb, 0xdd, 0xce, 0xfc, 0xb5, 0xdc, 0xc4, 0x23, 0x7d, 0x30, 0xf3, 0x79, - 0x17, 0x17, 0x4d, 0x37, 0x52, 0x9b, 0x75, 0xc5, 0xef, 0xf2, 0xc6, 0xd1, 0x24, 0xa9, 0x16, 0x0, 0x19, - 0xbd, 0x5d, 0x30, 0xdf, 0xeb, 0xe0, 0x50, 0x27, 0x83, 0x48, 0x65, 0x5c, 0x2, 0x3c, 0xac, 0xc0, 0xca, - 0x6d, 0xf2, 0x95, 0x5e, 0x3, 0x6, 0x2c, 0x97, 0xb, 0x11, 0xb, 0x1d, 0x24, 0xd8, 0x27, 0x0, 0x0, - 0x4d, 0x6c, 0x13, 0x52, 0x3f, 0x1d, 0x2d, 0xca, 0x7c, 0xed, 0x2, 0x5, 0x19, 0x9f, 0x8f, 0x82, 0x15, - 0xf2, 0xd4, 0xb6, 0x43, 0x67, 0xac, 0x23, 0xc1, 0x96, 0x76, 0xe2}; - - uint8_t buf[174] = {0}; - - uint8_t topic_bytes[] = {0xfa, 0xb5, 0xd5, 0xae, 0x9c, 0x92, 0xf4, 0xf3, 0xb4, 0xa0, 0xaa, 0x3d}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// ",\210m\249\173\143u\208k\181Kou]5\211\141\204M\133+$\153", _pubPktID = 0, _pubBody = "\154\157s\228", _pubProps = +// [PropSessionExpiryInterval 6761,PropReceiveMaximum 25461,PropSubscriptionIdentifier 29,PropMaximumPacketSize +// 956,PropResponseInformation +// "\DLEL&\177\178\193\134\189\214\131\&9\139\SI\182L\177dH\237\160#\143\178\EM\199$E",PropSubscriptionIdentifierAvailable +// 210,PropAuthenticationData "!/",PropAuthenticationMethod "\ETB<\173\DC20\f7\163 +// \NAK(\195\166\237Wa?W0Wo\US\135\139\ENQ",PropContentType +// "\169\246\SUBA\220\157{Yj\136:m\140#\251\144\&7K\128\219\SO",PropAssignedClientIdentifier +// ">\207",PropAuthenticationMethod "",PropUserProperty "X\211\SIY" +// "Q\203\192\221\167\162U\204\226]X\DC1)4\170+\158\187\&4",PropAuthenticationMethod "8|N\RSd\SYN",PropRetainAvailable +// 86,PropPayloadFormatIndicator 113,PropMessageExpiryInterval 29994,PropTopicAlias 6445,PropSessionExpiryInterval +// 20260,PropMessageExpiryInterval 14963,PropRetainAvailable 23,PropMessageExpiryInterval +// 13983,PropRequestResponseInformation 103,PropMaximumPacketSize 8958,PropTopicAliasMaximum +// 13547,PropMessageExpiryInterval 23419,PropServerReference "\135\195\156Z",PropPayloadFormatIndicator +// 143,PropRequestResponseInformation 0,PropReasonString "\228\233"]} +TEST(Publish5QCTest, Encode15) { + uint8_t pkt[] = { + 0x38, 0xf0, 0x1, 0x0, 0x17, 0x2c, 0xd2, 0x6d, 0xf9, 0xad, 0x8f, 0x75, 0xd0, 0x6b, 0xb5, 0x4b, 0x6f, 0x75, 0x5d, + 0x35, 0xd3, 0x8d, 0xcc, 0x4d, 0x85, 0x2b, 0x24, 0x99, 0xd1, 0x1, 0x11, 0x0, 0x0, 0x1a, 0x69, 0x21, 0x63, 0x75, + 0xb, 0x1d, 0x27, 0x0, 0x0, 0x3, 0xbc, 0x1a, 0x0, 0x1b, 0x10, 0x4c, 0x26, 0xb1, 0xb2, 0xc1, 0x86, 0xbd, 0xd6, + 0x83, 0x39, 0x8b, 0xf, 0xb6, 0x4c, 0xb1, 0x64, 0x48, 0xed, 0xa0, 0x23, 0x8f, 0xb2, 0x19, 0xc7, 0x24, 0x45, 0x29, + 0xd2, 0x16, 0x0, 0x2, 0x21, 0x2f, 0x15, 0x0, 0x19, 0x17, 0x3c, 0xad, 0x12, 0x30, 0xc, 0x37, 0xa3, 0x20, 0x15, + 0x28, 0xc3, 0xa6, 0xed, 0x57, 0x61, 0x3f, 0x57, 0x30, 0x57, 0x6f, 0x1f, 0x87, 0x8b, 0x5, 0x3, 0x0, 0x15, 0xa9, + 0xf6, 0x1a, 0x41, 0xdc, 0x9d, 0x7b, 0x59, 0x6a, 0x88, 0x3a, 0x6d, 0x8c, 0x23, 0xfb, 0x90, 0x37, 0x4b, 0x80, 0xdb, + 0xe, 0x12, 0x0, 0x2, 0x3e, 0xcf, 0x15, 0x0, 0x0, 0x26, 0x0, 0x4, 0x58, 0xd3, 0xf, 0x59, 0x0, 0x13, 0x51, + 0xcb, 0xc0, 0xdd, 0xa7, 0xa2, 0x55, 0xcc, 0xe2, 0x5d, 0x58, 0x11, 0x29, 0x34, 0xaa, 0x2b, 0x9e, 0xbb, 0x34, 0x15, + 0x0, 0x6, 0x38, 0x7c, 0x4e, 0x1e, 0x64, 0x16, 0x25, 0x56, 0x1, 0x71, 0x2, 0x0, 0x0, 0x75, 0x2a, 0x23, 0x19, + 0x2d, 0x11, 0x0, 0x0, 0x4f, 0x24, 0x2, 0x0, 0x0, 0x3a, 0x73, 0x25, 0x17, 0x2, 0x0, 0x0, 0x36, 0x9f, 0x19, + 0x67, 0x27, 0x0, 0x0, 0x22, 0xfe, 0x22, 0x34, 0xeb, 0x2, 0x0, 0x0, 0x5b, 0x7b, 0x1c, 0x0, 0x4, 0x87, 0xc3, + 0x9c, 0x5a, 0x1, 0x8f, 0x19, 0x0, 0x1f, 0x0, 0x2, 0xe4, 0xe9, 0x9a, 0x9d, 0x73, 0xe4}; + + uint8_t buf[253] = {0}; + + uint8_t topic_bytes[] = {0x2c, 0xd2, 0x6d, 0xf9, 0xad, 0x8f, 0x75, 0xd0, 0x6b, 0xb5, 0x4b, 0x6f, + 0x75, 0x5d, 0x35, 0xd3, 0x8d, 0xcc, 0x4d, 0x85, 0x2b, 0x24, 0x99}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x1d, 0x2d, 0xca, 0x7c, 0xed, 0x2, 0x5, 0x19, 0x9f, 0x8f, 0x82, 0x15, - 0xf2, 0xd4, 0xb6, 0x43, 0x67, 0xac, 0x23, 0xc1, 0x96, 0x76, 0xe2}; + uint8_t msg_bytes[] = {0x9a, 0x9d, 0x73, 0xe4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 4; - uint8_t bytes0[] = {0x4f, 0xc4, 0xb2, 0x67, 0xc8, 0x7f, 0x2a, 0x3, 0x1, 0xcb, 0x1c, - 0xa2, 0x9f, 0x93, 0x11, 0x28, 0xa4, 0x80, 0xcb, 0x34, 0x59, 0x2a}; - uint8_t bytes1[] = {0x35, 0x9f, 0x6e, 0xf2, 0xb3, 0xc, 0x70, 0xa4, 0x7, 0x74}; - uint8_t bytes2[] = {0xdb, 0xdd, 0xce, 0xfc, 0xb5, 0xdc, 0xc4, 0x23, 0x7d, 0x30, 0xf3, 0x79, - 0x17, 0x17, 0x4d, 0x37, 0x52, 0x9b, 0x75, 0xc5, 0xef, 0xf2, 0xc6, 0xd1}; - uint8_t bytes3[] = {0xbd, 0x5d, 0x30, 0xdf, 0xeb, 0xe0, 0x50, 0x27, 0x83, 0x48, 0x65, 0x5c, 0x2, - 0x3c, 0xac, 0xc0, 0xca, 0x6d, 0xf2, 0x95, 0x5e, 0x3, 0x6, 0x2c, 0x97}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4675}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11858}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + uint8_t bytesprops0[] = {0x10, 0x4c, 0x26, 0xb1, 0xb2, 0xc1, 0x86, 0xbd, 0xd6, 0x83, 0x39, 0x8b, 0xf, 0xb6, + 0x4c, 0xb1, 0x64, 0x48, 0xed, 0xa0, 0x23, 0x8f, 0xb2, 0x19, 0xc7, 0x24, 0x45}; + uint8_t bytesprops1[] = {0x21, 0x2f}; + uint8_t bytesprops2[] = {0x17, 0x3c, 0xad, 0x12, 0x30, 0xc, 0x37, 0xa3, 0x20, 0x15, 0x28, 0xc3, 0xa6, + 0xed, 0x57, 0x61, 0x3f, 0x57, 0x30, 0x57, 0x6f, 0x1f, 0x87, 0x8b, 0x5}; + uint8_t bytesprops3[] = {0xa9, 0xf6, 0x1a, 0x41, 0xdc, 0x9d, 0x7b, 0x59, 0x6a, 0x88, 0x3a, + 0x6d, 0x8c, 0x23, 0xfb, 0x90, 0x37, 0x4b, 0x80, 0xdb, 0xe}; + uint8_t bytesprops4[] = {0x3e, 0xcf}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops7[] = {0x51, 0xcb, 0xc0, 0xdd, 0xa7, 0xa2, 0x55, 0xcc, 0xe2, 0x5d, + 0x58, 0x11, 0x29, 0x34, 0xaa, 0x2b, 0x9e, 0xbb, 0x34}; + uint8_t bytesprops6[] = {0x58, 0xd3, 0xf, 0x59}; + uint8_t bytesprops8[] = {0x38, 0x7c, 0x4e, 0x1e, 0x64, 0x16}; + uint8_t bytesprops9[] = {0x87, 0xc3, 0x9c, 0x5a}; + uint8_t bytesprops10[] = {0xe4, 0xe9}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6761}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25461}}, {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19820}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21055}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 956}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops6}, .v = {19, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29994}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6445}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20260}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14963}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13983}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8958}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13547}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23419}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24114, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "K\128\243a\178\253\219\184\171;*\244\172'5\EMTE\CAN", _pubPktID = 30980, _pubBody = "c\SUB\219{", _pubProps = -// [PropAuthenticationMethod -// "\199\134\152\&6\187\NAK\133\163\179~@Y[\174&\ty\249X\225w\FS\233I\169",PropAuthenticationMethod -// ">\148\231J\209\131\155\194",PropCorrelationData -// "\187\SYNbg\CAN\237\170\148\218f[\237\223O]d|\DEL\225$J",PropServerKeepAlive 27234,PropAuthenticationMethod -// "q\163e\227C0\SUB",PropTopicAliasMaximum 12959,PropSessionExpiryInterval 4732,PropSessionExpiryInterval -// 30800,PropSubscriptionIdentifierAvailable 78,PropMessageExpiryInterval 29659,PropAuthenticationData -// "\207CIS\172\137X^\145^\ACK\200\"+\200\176\b\225\161\DC2",PropResponseInformation -// "J\213h\132",PropSessionExpiryInterval 16307,PropTopicAliasMaximum 7071,PropSubscriptionIdentifier -// 27,PropAssignedClientIdentifier "\160'\ACK\239\137!\211\CAN{?\133\228j\ETB\ENQkDxZ\131E",PropWillDelayInterval -// 22702,PropMessageExpiryInterval 11660,PropTopicAlias 26640,PropUserProperty -// "\b\SUB\v&'u\133K\210\206o\138d\136\189\&9@)\146u\149\244\&3f\181" -// "\238\227|x\222\246\STX=\DC3w{\SOH\211",PropTopicAlias 29877,PropResponseInformation -// "\200\188\219\154\NAKM\173\191\254I\\S",PropRequestResponseInformation 139,PropRequestResponseInformation -// 199,PropResponseTopic "\DC3\ETXh\253\&0\235g\DC4s\163E\132k\203\190\139\150\232,\169\178\DC3\ETB\215\162&\172\169"]} -TEST(Publish50QCTest, Encode17) { +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\NUL\DEL\203\RS\240:\141&\173E\160ge\161\253\204@\CANsE\DC4\250-\170\139\170\173", _pubPktID = 16148, _pubBody = +// "\217\SOH\255\&9\132\DC1ce\133\DLE\176\244\r\ti\207a\239X\210\160\160\224v\216\t", _pubProps = +// [PropWildcardSubscriptionAvailable 154,PropCorrelationData "\191r\216",PropMessageExpiryInterval +// 24076,PropAuthenticationData "G1\138V\146\SO",PropSubscriptionIdentifierAvailable 148,PropRequestProblemInformation +// 135,PropWillDelayInterval 31841,PropMaximumQoS 13,PropAuthenticationData +// "\151\163B\254\223\172\ETB",PropRequestResponseInformation 190,PropSessionExpiryInterval 4965,PropUserProperty +// "q\131C \NAK\236\142\210\148\230" "\251\226\r\US\196,.\RS`R1}\DC2s\143\n",PropWildcardSubscriptionAvailable +// 0,PropTopicAlias 13696,PropAuthenticationData +// "j\171\243\197\NUL\173&\172\148\176\215Md\174\\\246\ACK1\132",PropMessageExpiryInterval 7797,PropAuthenticationData +// "\\]>\164\143",PropSubscriptionIdentifierAvailable 133,PropRequestResponseInformation 196,PropMessageExpiryInterval +// 8000,PropRetainAvailable 41,PropContentType "\186H\129\176\NAK\238\tB\ENQ3\158n\143\178\175\180\145\t\218\144\222vVl +// -",PropRetainAvailable 95]} +TEST(Publish5QCTest, Encode16) { uint8_t pkt[] = { - 0x3b, 0xaa, 0x2, 0x0, 0x13, 0x4b, 0x80, 0xf3, 0x61, 0xb2, 0xfd, 0xdb, 0xb8, 0xab, 0x3b, 0x2a, 0xf4, 0xac, 0x27, - 0x35, 0x19, 0x54, 0x45, 0x18, 0x79, 0x4, 0x8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 0x64, 0x88, 0xbd, 0x39, 0x40, 0x29, 0x92, 0x75, 0x95, 0xf4, 0x33, 0x66, - 0xb5, 0x0, 0xd, 0xee, 0xe3, 0x7c, 0x78, 0xde, 0xf6, 0x2, 0x3d, 0x13, 0x77, 0x7b, 0x1, 0xd3, 0x23, 0x74, 0xb5, - 0x1a, 0x0, 0xc, 0xc8, 0xbc, 0xdb, 0x9a, 0x15, 0x4d, 0xad, 0xbf, 0xfe, 0x49, 0x5c, 0x53, 0x19, 0x8b, 0x19, 0xc7, - 0x8, 0x0, 0x1c, 0x13, 0x3, 0x68, 0xfd, 0x30, 0xeb, 0x67, 0x14, 0x73, 0xa3, 0x45, 0x84, 0x6b, 0xcb, 0xbe, 0x8b, - 0x96, 0xe8, 0x2c, 0xa9, 0xb2, 0x13, 0x17, 0xd7, 0xa2, 0x26, 0xac, 0xa9, 0x63, 0x1a, 0xdb, 0x7b}; - - uint8_t buf[311] = {0}; - - uint8_t topic_bytes[] = {0x4b, 0x80, 0xf3, 0x61, 0xb2, 0xfd, 0xdb, 0xb8, 0xab, 0x3b, - 0x2a, 0xf4, 0xac, 0x27, 0x35, 0x19, 0x54, 0x45, 0x18}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + 0x3a, 0xde, 0x1, 0x0, 0x1b, 0x0, 0x7f, 0xcb, 0x1e, 0xf0, 0x3a, 0x8d, 0x26, 0xad, 0x45, 0xa0, 0x67, 0x65, 0xa1, + 0xfd, 0xcc, 0x40, 0x18, 0x73, 0x45, 0x14, 0xfa, 0x2d, 0xaa, 0x8b, 0xaa, 0xad, 0x3f, 0x14, 0xa3, 0x1, 0x28, 0x9a, + 0x9, 0x0, 0x3, 0xbf, 0x72, 0xd8, 0x2, 0x0, 0x0, 0x5e, 0xc, 0x16, 0x0, 0x6, 0x47, 0x31, 0x8a, 0x56, 0x92, + 0xe, 0x29, 0x94, 0x17, 0x87, 0x18, 0x0, 0x0, 0x7c, 0x61, 0x24, 0xd, 0x16, 0x0, 0x7, 0x97, 0xa3, 0x42, 0xfe, + 0xdf, 0xac, 0x17, 0x19, 0xbe, 0x11, 0x0, 0x0, 0x13, 0x65, 0x26, 0x0, 0xa, 0x71, 0x83, 0x43, 0x20, 0x15, 0xec, + 0x8e, 0xd2, 0x94, 0xe6, 0x0, 0x10, 0xfb, 0xe2, 0xd, 0x1f, 0xc4, 0x2c, 0x2e, 0x1e, 0x60, 0x52, 0x31, 0x7d, 0x12, + 0x73, 0x8f, 0xa, 0x28, 0x0, 0x23, 0x35, 0x80, 0x16, 0x0, 0x13, 0x6a, 0xab, 0xf3, 0xc5, 0x0, 0xad, 0x26, 0xac, + 0x94, 0xb0, 0xd7, 0x4d, 0x64, 0xae, 0x5c, 0xf6, 0x6, 0x31, 0x84, 0x2, 0x0, 0x0, 0x1e, 0x75, 0x16, 0x0, 0x5, + 0x5c, 0x5d, 0x3e, 0xa4, 0x8f, 0x29, 0x85, 0x19, 0xc4, 0x2, 0x0, 0x0, 0x1f, 0x40, 0x25, 0x29, 0x3, 0x0, 0x1a, + 0xba, 0x48, 0x81, 0xb0, 0x15, 0xee, 0x9, 0x42, 0x5, 0x33, 0x9e, 0x6e, 0x8f, 0xb2, 0xaf, 0xb4, 0x91, 0x9, 0xda, + 0x90, 0xde, 0x76, 0x56, 0x6c, 0x20, 0x2d, 0x25, 0x5f, 0xd9, 0x1, 0xff, 0x39, 0x84, 0x11, 0x63, 0x65, 0x85, 0x10, + 0xb0, 0xf4, 0xd, 0x9, 0x69, 0xcf, 0x61, 0xef, 0x58, 0xd2, 0xa0, 0xa0, 0xe0, 0x76, 0xd8, 0x9}; + + uint8_t buf[235] = {0}; + + uint8_t topic_bytes[] = {0x0, 0x7f, 0xcb, 0x1e, 0xf0, 0x3a, 0x8d, 0x26, 0xad, 0x45, 0xa0, 0x67, 0x65, 0xa1, + 0xfd, 0xcc, 0x40, 0x18, 0x73, 0x45, 0x14, 0xfa, 0x2d, 0xaa, 0x8b, 0xaa, 0xad}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x63, 0x1a, 0xdb, 0x7b}; + msg.retained = false; + uint8_t msg_bytes[] = {0xd9, 0x1, 0xff, 0x39, 0x84, 0x11, 0x63, 0x65, 0x85, 0x10, 0xb0, 0xf4, 0xd, + 0x9, 0x69, 0xcf, 0x61, 0xef, 0x58, 0xd2, 0xa0, 0xa0, 0xe0, 0x76, 0xd8, 0x9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 26; - uint8_t bytes0[] = {0xc7, 0x86, 0x98, 0x36, 0xbb, 0x15, 0x85, 0xa3, 0xb3, 0x7e, 0x40, 0x59, 0x5b, - 0xae, 0x26, 0x9, 0x79, 0xf9, 0x58, 0xe1, 0x77, 0x1c, 0xe9, 0x49, 0xa9}; - uint8_t bytes1[] = {0x3e, 0x94, 0xe7, 0x4a, 0xd1, 0x83, 0x9b, 0xc2}; - uint8_t bytes2[] = {0xbb, 0x16, 0x62, 0x67, 0x18, 0xed, 0xaa, 0x94, 0xda, 0x66, 0x5b, - 0xed, 0xdf, 0x4f, 0x5d, 0x64, 0x7c, 0x7f, 0xe1, 0x24, 0x4a}; - uint8_t bytes3[] = {0x71, 0xa3, 0x65, 0xe3, 0x43, 0x30, 0x1a}; - uint8_t bytes4[] = {0xcf, 0x43, 0x49, 0x53, 0xac, 0x89, 0x58, 0x5e, 0x91, 0x5e, - 0x6, 0xc8, 0x22, 0x2b, 0xc8, 0xb0, 0x8, 0xe1, 0xa1, 0x12}; - uint8_t bytes5[] = {0x4a, 0xd5, 0x68, 0x84}; - uint8_t bytes6[] = {0xa0, 0x27, 0x6, 0xef, 0x89, 0x21, 0xd3, 0x18, 0x7b, 0x3f, 0x85, - 0xe4, 0x6a, 0x17, 0x5, 0x6b, 0x44, 0x78, 0x5a, 0x83, 0x45}; - uint8_t bytes8[] = {0xee, 0xe3, 0x7c, 0x78, 0xde, 0xf6, 0x2, 0x3d, 0x13, 0x77, 0x7b, 0x1, 0xd3}; - uint8_t bytes7[] = {0x8, 0x1a, 0xb, 0x26, 0x27, 0x75, 0x85, 0x4b, 0xd2, 0xce, 0x6f, 0x8a, 0x64, - 0x88, 0xbd, 0x39, 0x40, 0x29, 0x92, 0x75, 0x95, 0xf4, 0x33, 0x66, 0xb5}; - uint8_t bytes9[] = {0xc8, 0xbc, 0xdb, 0x9a, 0x15, 0x4d, 0xad, 0xbf, 0xfe, 0x49, 0x5c, 0x53}; - uint8_t bytes10[] = {0x13, 0x3, 0x68, 0xfd, 0x30, 0xeb, 0x67, 0x14, 0x73, 0xa3, 0x45, 0x84, 0x6b, 0xcb, - 0xbe, 0x8b, 0x96, 0xe8, 0x2c, 0xa9, 0xb2, 0x13, 0x17, 0xd7, 0xa2, 0x26, 0xac, 0xa9}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27234}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12959}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4732}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30800}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29659}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16307}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7071}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22702}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11660}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26640}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytes7}, .v = {13, (char*)&bytes8}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29877}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytes9}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytes10}}}, + uint8_t bytesprops0[] = {0xbf, 0x72, 0xd8}; + uint8_t bytesprops1[] = {0x47, 0x31, 0x8a, 0x56, 0x92, 0xe}; + uint8_t bytesprops2[] = {0x97, 0xa3, 0x42, 0xfe, 0xdf, 0xac, 0x17}; + uint8_t bytesprops4[] = {0xfb, 0xe2, 0xd, 0x1f, 0xc4, 0x2c, 0x2e, 0x1e, + 0x60, 0x52, 0x31, 0x7d, 0x12, 0x73, 0x8f, 0xa}; + uint8_t bytesprops3[] = {0x71, 0x83, 0x43, 0x20, 0x15, 0xec, 0x8e, 0xd2, 0x94, 0xe6}; + uint8_t bytesprops5[] = {0x6a, 0xab, 0xf3, 0xc5, 0x0, 0xad, 0x26, 0xac, 0x94, 0xb0, + 0xd7, 0x4d, 0x64, 0xae, 0x5c, 0xf6, 0x6, 0x31, 0x84}; + uint8_t bytesprops6[] = {0x5c, 0x5d, 0x3e, 0xa4, 0x8f}; + uint8_t bytesprops7[] = {0xba, 0x48, 0x81, 0xb0, 0x15, 0xee, 0x9, 0x42, 0x5, 0x33, 0x9e, 0x6e, 0x8f, + 0xb2, 0xaf, 0xb4, 0x91, 0x9, 0xda, 0x90, 0xde, 0x76, 0x56, 0x6c, 0x20, 0x2d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24076}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31841}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4965}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops3}, .v = {16, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13696}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7797}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8000}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 95}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 30980, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16148, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "q\133\153L\176\219b\169Cy", _pubPktID -// = 0, _pubBody = "R\253\227\&8\219\234\CANi\174R\250\248\234\146G]X\252\NAK\167/\195\SUB:\GS\182-", _pubProps = -// [PropMessageExpiryInterval 19843,PropSubscriptionIdentifier 31,PropAssignedClientIdentifier -// "\142\128v\185Cql\255\206\&9",PropWildcardSubscriptionAvailable 230,PropMessageExpiryInterval -// 16053,PropWillDelayInterval 26161,PropCorrelationData -// "p\159M\SYN$\nt{\197\200~AN^\136",PropRequestResponseInformation 87,PropRequestResponseInformation 37,PropMaximumQoS -// 209]} -TEST(Publish50QCTest, Encode18) { - uint8_t pkt[] = {0x39, 0x60, 0x0, 0xa, 0x71, 0x85, 0x99, 0x4c, 0xb0, 0xdb, 0x62, 0xa9, 0x43, 0x79, 0x38, 0x2, 0x0, - 0x0, 0x4d, 0x83, 0xb, 0x1f, 0x12, 0x0, 0xa, 0x8e, 0x80, 0x76, 0xb9, 0x43, 0x71, 0x6c, 0xff, 0xce, - 0x39, 0x28, 0xe6, 0x2, 0x0, 0x0, 0x3e, 0xb5, 0x18, 0x0, 0x0, 0x66, 0x31, 0x9, 0x0, 0xf, 0x70, - 0x9f, 0x4d, 0x16, 0x24, 0xa, 0x74, 0x7b, 0xc5, 0xc8, 0x7e, 0x41, 0x4e, 0x5e, 0x88, 0x19, 0x57, 0x19, - 0x25, 0x24, 0xd1, 0x52, 0xfd, 0xe3, 0x38, 0xdb, 0xea, 0x18, 0x69, 0xae, 0x52, 0xfa, 0xf8, 0xea, 0x92, - 0x47, 0x5d, 0x58, 0xfc, 0x15, 0xa7, 0x2f, 0xc3, 0x1a, 0x3a, 0x1d, 0xb6, 0x2d}; - - uint8_t buf[108] = {0}; - - uint8_t topic_bytes[] = {0x71, 0x85, 0x99, 0x4c, 0xb0, 0xdb, 0x62, 0xa9, 0x43, 0x79}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\225\180\242F\ENQ\203\138\241\216i%\241\223n\157\150\bT\255", _pubPktID = 0, _pubBody = "'", _pubProps = +// [PropSharedSubscriptionAvailable 118,PropReasonString "$g\220\202=\249}",PropContentType +// "\230\237-\186\DLE\158\ACK(\231\187\136i\194%\238\131\200",PropAuthenticationData +// ">*\NAK9\254W\137i\244@\252:@[",PropCorrelationData "OpE\199\243\"z\164\"\239\216\161{\237e\USH\237",PropUserProperty +// "" "\163T\203\128f",PropReceiveMaximum 10674,PropSubscriptionIdentifier 28,PropSharedSubscriptionAvailable +// 40,PropContentType "7\253\&7\132\134\227\168z\247\176",PropMaximumQoS 81,PropMaximumQoS +// 252,PropAssignedClientIdentifier "i:}k\230\196\190\ETXg\SI",PropTopicAlias 24243,PropReasonString +// "\249\234n\235\146G\210",PropAssignedClientIdentifier "\232~\206\136\FS\244\EOT +// \206\150\251@\140\180\176\192\aca\156",PropMessageExpiryInterval 30666,PropSubscriptionIdentifierAvailable +// 184,PropContentType "\t\209H\246K\b4R\160#\200\223z\SOH&\153\&6i\142\203#\199@C",PropServerKeepAlive +// 5395,PropResponseTopic "\228\251\216Q\207+\163\224\184\252\173",PropMessageExpiryInterval 203,PropResponseInformation +// "",PropServerKeepAlive 2025,PropWillDelayInterval 31464,PropUserProperty +// "\135\194\DC49\149\NAK3\193$\ACK\245\208\&6Y\173\223\214I" "\228\147",PropMessageExpiryInterval +// 4928,PropRetainAvailable 255,PropRetainAvailable 156,PropWillDelayInterval 28241]} +TEST(Publish5QCTest, Encode17) { + uint8_t pkt[] = {0x30, 0x9b, 0x2, 0x0, 0x13, 0xe1, 0xb4, 0xf2, 0x46, 0x5, 0xcb, 0x8a, 0xf1, 0xd8, 0x69, 0x25, 0xf1, + 0xdf, 0x6e, 0x9d, 0x96, 0x8, 0x54, 0xff, 0x83, 0x2, 0x2a, 0x76, 0x1f, 0x0, 0x7, 0x24, 0x67, 0xdc, + 0xca, 0x3d, 0xf9, 0x7d, 0x3, 0x0, 0x11, 0xe6, 0xed, 0x2d, 0xba, 0x10, 0x9e, 0x6, 0x28, 0xe7, 0xbb, + 0x88, 0x69, 0xc2, 0x25, 0xee, 0x83, 0xc8, 0x16, 0x0, 0xe, 0x3e, 0x2a, 0x15, 0x39, 0xfe, 0x57, 0x89, + 0x69, 0xf4, 0x40, 0xfc, 0x3a, 0x40, 0x5b, 0x9, 0x0, 0x12, 0x4f, 0x70, 0x45, 0xc7, 0xf3, 0x22, 0x7a, + 0xa4, 0x22, 0xef, 0xd8, 0xa1, 0x7b, 0xed, 0x65, 0x1f, 0x48, 0xed, 0x26, 0x0, 0x0, 0x0, 0x5, 0xa3, + 0x54, 0xcb, 0x80, 0x66, 0x21, 0x29, 0xb2, 0xb, 0x1c, 0x2a, 0x28, 0x3, 0x0, 0xa, 0x37, 0xfd, 0x37, + 0x84, 0x86, 0xe3, 0xa8, 0x7a, 0xf7, 0xb0, 0x24, 0x51, 0x24, 0xfc, 0x12, 0x0, 0xa, 0x69, 0x3a, 0x7d, + 0x6b, 0xe6, 0xc4, 0xbe, 0x3, 0x67, 0xf, 0x23, 0x5e, 0xb3, 0x1f, 0x0, 0x7, 0xf9, 0xea, 0x6e, 0xeb, + 0x92, 0x47, 0xd2, 0x12, 0x0, 0x14, 0xe8, 0x7e, 0xce, 0x88, 0x1c, 0xf4, 0x4, 0x20, 0xce, 0x96, 0xfb, + 0x40, 0x8c, 0xb4, 0xb0, 0xc0, 0x7, 0x63, 0x61, 0x9c, 0x2, 0x0, 0x0, 0x77, 0xca, 0x29, 0xb8, 0x3, + 0x0, 0x18, 0x9, 0xd1, 0x48, 0xf6, 0x4b, 0x8, 0x34, 0x52, 0xa0, 0x23, 0xc8, 0xdf, 0x7a, 0x1, 0x26, + 0x99, 0x36, 0x69, 0x8e, 0xcb, 0x23, 0xc7, 0x40, 0x43, 0x13, 0x15, 0x13, 0x8, 0x0, 0xb, 0xe4, 0xfb, + 0xd8, 0x51, 0xcf, 0x2b, 0xa3, 0xe0, 0xb8, 0xfc, 0xad, 0x2, 0x0, 0x0, 0x0, 0xcb, 0x1a, 0x0, 0x0, + 0x13, 0x7, 0xe9, 0x18, 0x0, 0x0, 0x7a, 0xe8, 0x26, 0x0, 0x12, 0x87, 0xc2, 0x14, 0x39, 0x95, 0x15, + 0x33, 0xc1, 0x24, 0x6, 0xf5, 0xd0, 0x36, 0x59, 0xad, 0xdf, 0xd6, 0x49, 0x0, 0x2, 0xe4, 0x93, 0x2, + 0x0, 0x0, 0x13, 0x40, 0x25, 0xff, 0x25, 0x9c, 0x18, 0x0, 0x0, 0x6e, 0x51, 0x27}; + + uint8_t buf[296] = {0}; + + uint8_t topic_bytes[] = {0xe1, 0xb4, 0xf2, 0x46, 0x5, 0xcb, 0x8a, 0xf1, 0xd8, 0x69, + 0x25, 0xf1, 0xdf, 0x6e, 0x9d, 0x96, 0x8, 0x54, 0xff}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x52, 0xfd, 0xe3, 0x38, 0xdb, 0xea, 0x18, 0x69, 0xae, 0x52, 0xfa, 0xf8, 0xea, 0x92, - 0x47, 0x5d, 0x58, 0xfc, 0x15, 0xa7, 0x2f, 0xc3, 0x1a, 0x3a, 0x1d, 0xb6, 0x2d}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; - - uint8_t bytes0[] = {0x8e, 0x80, 0x76, 0xb9, 0x43, 0x71, 0x6c, 0xff, 0xce, 0x39}; - uint8_t bytes1[] = {0x70, 0x9f, 0x4d, 0x16, 0x24, 0xa, 0x74, 0x7b, 0xc5, 0xc8, 0x7e, 0x41, 0x4e, 0x5e, 0x88}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19843}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16053}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26161}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 209}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&proplist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\DC2]^:\232\227~//\232\188z\183\183\&6\248\242", _pubPktID = 31614, _pubBody = -// "g\207\142Q\206\&8\FS#f]\154[\195\180\140FW\182\130\168\&6\191\251\b\214\&0\141", _pubProps = [PropReceiveMaximum -// 12957,PropRequestProblemInformation 52,PropSessionExpiryInterval 17481,PropMaximumQoS 8,PropResponseInformation -// "M\164\SUB\195\a\CAN4\193j\EM\RS\DC4\154\&1\129\200\168:\237\254D\NUL'\227",PropResponseTopic "",PropServerReference -// "'r\202\139\192\&0fnM\183\185",PropSharedSubscriptionAvailable 38,PropTopicAlias 13376,PropServerKeepAlive -// 17639,PropPayloadFormatIndicator 64]} -TEST(Publish50QCTest, Encode19) { - uint8_t pkt[] = {0x3d, 0x73, 0x0, 0x11, 0x12, 0x5d, 0x5e, 0x3a, 0xe8, 0xe3, 0x7e, 0x2f, 0x2f, 0xe8, 0xbc, 0x7a, 0xb7, - 0xb7, 0x36, 0xf8, 0xf2, 0x7b, 0x7e, 0x42, 0x21, 0x32, 0x9d, 0x17, 0x34, 0x11, 0x0, 0x0, 0x44, 0x49, - 0x24, 0x8, 0x1a, 0x0, 0x18, 0x4d, 0xa4, 0x1a, 0xc3, 0x7, 0x18, 0x34, 0xc1, 0x6a, 0x19, 0x1e, 0x14, - 0x9a, 0x31, 0x81, 0xc8, 0xa8, 0x3a, 0xed, 0xfe, 0x44, 0x0, 0x27, 0xe3, 0x8, 0x0, 0x0, 0x1c, 0x0, - 0xb, 0x27, 0x72, 0xca, 0x8b, 0xc0, 0x30, 0x66, 0x6e, 0x4d, 0xb7, 0xb9, 0x2a, 0x26, 0x23, 0x34, 0x40, - 0x13, 0x44, 0xe7, 0x1, 0x40, 0x67, 0xcf, 0x8e, 0x51, 0xce, 0x38, 0x1c, 0x23, 0x66, 0x5d, 0x9a, 0x5b, - 0xc3, 0xb4, 0x8c, 0x46, 0x57, 0xb6, 0x82, 0xa8, 0x36, 0xbf, 0xfb, 0x8, 0xd6, 0x30, 0x8d}; - - uint8_t buf[127] = {0}; - - uint8_t topic_bytes[] = {0x12, 0x5d, 0x5e, 0x3a, 0xe8, 0xe3, 0x7e, 0x2f, 0x2f, - 0xe8, 0xbc, 0x7a, 0xb7, 0xb7, 0x36, 0xf8, 0xf2}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x67, 0xcf, 0x8e, 0x51, 0xce, 0x38, 0x1c, 0x23, 0x66, 0x5d, 0x9a, 0x5b, 0xc3, 0xb4, - 0x8c, 0x46, 0x57, 0xb6, 0x82, 0xa8, 0x36, 0xbf, 0xfb, 0x8, 0xd6, 0x30, 0x8d}; + msg.retained = false; + uint8_t msg_bytes[] = {0x27}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; - - uint8_t bytes0[] = {0x4d, 0xa4, 0x1a, 0xc3, 0x7, 0x18, 0x34, 0xc1, 0x6a, 0x19, 0x1e, 0x14, - 0x9a, 0x31, 0x81, 0xc8, 0xa8, 0x3a, 0xed, 0xfe, 0x44, 0x0, 0x27, 0xe3}; - uint8_t bytes1[] = {0}; - uint8_t bytes2[] = {0x27, 0x72, 0xca, 0x8b, 0xc0, 0x30, 0x66, 0x6e, 0x4d, 0xb7, 0xb9}; + msg.payload_len = 1; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12957}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17481}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13376}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17639}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 64}}, + uint8_t bytesprops0[] = {0x24, 0x67, 0xdc, 0xca, 0x3d, 0xf9, 0x7d}; + uint8_t bytesprops1[] = {0xe6, 0xed, 0x2d, 0xba, 0x10, 0x9e, 0x6, 0x28, 0xe7, + 0xbb, 0x88, 0x69, 0xc2, 0x25, 0xee, 0x83, 0xc8}; + uint8_t bytesprops2[] = {0x3e, 0x2a, 0x15, 0x39, 0xfe, 0x57, 0x89, 0x69, 0xf4, 0x40, 0xfc, 0x3a, 0x40, 0x5b}; + uint8_t bytesprops3[] = {0x4f, 0x70, 0x45, 0xc7, 0xf3, 0x22, 0x7a, 0xa4, 0x22, + 0xef, 0xd8, 0xa1, 0x7b, 0xed, 0x65, 0x1f, 0x48, 0xed}; + uint8_t bytesprops5[] = {0xa3, 0x54, 0xcb, 0x80, 0x66}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops6[] = {0x37, 0xfd, 0x37, 0x84, 0x86, 0xe3, 0xa8, 0x7a, 0xf7, 0xb0}; + uint8_t bytesprops7[] = {0x69, 0x3a, 0x7d, 0x6b, 0xe6, 0xc4, 0xbe, 0x3, 0x67, 0xf}; + uint8_t bytesprops8[] = {0xf9, 0xea, 0x6e, 0xeb, 0x92, 0x47, 0xd2}; + uint8_t bytesprops9[] = {0xe8, 0x7e, 0xce, 0x88, 0x1c, 0xf4, 0x4, 0x20, 0xce, 0x96, + 0xfb, 0x40, 0x8c, 0xb4, 0xb0, 0xc0, 0x7, 0x63, 0x61, 0x9c}; + uint8_t bytesprops10[] = {0x9, 0xd1, 0x48, 0xf6, 0x4b, 0x8, 0x34, 0x52, 0xa0, 0x23, 0xc8, 0xdf, + 0x7a, 0x1, 0x26, 0x99, 0x36, 0x69, 0x8e, 0xcb, 0x23, 0xc7, 0x40, 0x43}; + uint8_t bytesprops11[] = {0xe4, 0xfb, 0xd8, 0x51, 0xcf, 0x2b, 0xa3, 0xe0, 0xb8, 0xfc, 0xad}; + uint8_t bytesprops12[] = {0}; + uint8_t bytesprops14[] = {0xe4, 0x93}; + uint8_t bytesprops13[] = {0x87, 0xc2, 0x14, 0x39, 0x95, 0x15, 0x33, 0xc1, 0x24, + 0x6, 0xf5, 0xd0, 0x36, 0x59, 0xad, 0xdf, 0xd6, 0x49}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops4}, .v = {5, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10674}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24243}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30666}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5395}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 203}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2025}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31464}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops13}, .v = {2, (char*)&bytesprops14}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4928}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28241}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 31614, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } // PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "y[U\202v\201A\203\136\164\190[\aZ\201\199", _pubPktID = 0, _pubBody = "`\132\CAN\206_pD[R", _pubProps = -// [PropAuthenticationMethod "",PropSubscriptionIdentifier 26,PropTopicAlias 17476,PropReasonString -// "\203\190Y\181\EM\141\216\248R\202\241Fz\153\US\210\233I9\215\226?\238\138\135\238}.",PropSubscriptionIdentifierAvailable -// 151,PropTopicAliasMaximum 576,PropPayloadFormatIndicator 141,PropServerKeepAlive 14965,PropServerReference -// ":\184\148`\218\f{\241\207=\135\198\NAK\166\ENQ\171\176\ETB7\170\&6\196\223\143\154$\249\v",PropWillDelayInterval -// 21964,PropReceiveMaximum 4625,PropAssignedClientIdentifier -// "R\159>E\186\154\156\&0\134\169\200\249\200G\FS^\248\144pX\215\221\228\STX",PropMessageExpiryInterval -// 14507,PropContentType "\253DY\"i\SOHX",PropTopicAlias 4812,PropResponseInformation -// "\142\147\150\140\167;v\247@\174\183\GS\158\187E\212\223m\RS\137 \US\223\197\EOT\228\245\229\230",PropServerKeepAlive -// 27938,PropRetainAvailable 180,PropResponseInformation "\193\241\144\240F5]\202",PropMaximumPacketSize -// 6869,PropRetainAvailable 172]} -TEST(Publish50QCTest, Encode20) { - uint8_t pkt[] = {0x31, 0xd9, 0x1, 0x0, 0x10, 0x79, 0x5b, 0x55, 0xca, 0x76, 0xc9, 0x41, 0xcb, 0x88, 0xa4, 0xbe, 0x5b, - 0x7, 0x5a, 0xc9, 0xc7, 0xbc, 0x1, 0x15, 0x0, 0x0, 0xb, 0x1a, 0x23, 0x44, 0x44, 0x1f, 0x0, 0x1c, - 0xcb, 0xbe, 0x59, 0xb5, 0x19, 0x8d, 0xd8, 0xf8, 0x52, 0xca, 0xf1, 0x46, 0x7a, 0x99, 0x1f, 0xd2, 0xe9, - 0x49, 0x39, 0xd7, 0xe2, 0x3f, 0xee, 0x8a, 0x87, 0xee, 0x7d, 0x2e, 0x29, 0x97, 0x22, 0x2, 0x40, 0x1, - 0x8d, 0x13, 0x3a, 0x75, 0x1c, 0x0, 0x1c, 0x3a, 0xb8, 0x94, 0x60, 0xda, 0xc, 0x7b, 0xf1, 0xcf, 0x3d, - 0x87, 0xc6, 0x15, 0xa6, 0x5, 0xab, 0xb0, 0x17, 0x37, 0xaa, 0x36, 0xc4, 0xdf, 0x8f, 0x9a, 0x24, 0xf9, - 0xb, 0x18, 0x0, 0x0, 0x55, 0xcc, 0x21, 0x12, 0x11, 0x12, 0x0, 0x18, 0x52, 0x9f, 0x3e, 0x45, 0xba, - 0x9a, 0x9c, 0x30, 0x86, 0xa9, 0xc8, 0xf9, 0xc8, 0x47, 0x1c, 0x5e, 0xf8, 0x90, 0x70, 0x58, 0xd7, 0xdd, - 0xe4, 0x2, 0x2, 0x0, 0x0, 0x38, 0xab, 0x3, 0x0, 0x7, 0xfd, 0x44, 0x59, 0x22, 0x69, 0x1, 0x58, - 0x23, 0x12, 0xcc, 0x1a, 0x0, 0x1d, 0x8e, 0x93, 0x96, 0x8c, 0xa7, 0x3b, 0x76, 0xf7, 0x40, 0xae, 0xb7, - 0x1d, 0x9e, 0xbb, 0x45, 0xd4, 0xdf, 0x6d, 0x1e, 0x89, 0x20, 0x1f, 0xdf, 0xc5, 0x4, 0xe4, 0xf5, 0xe5, - 0xe6, 0x13, 0x6d, 0x22, 0x25, 0xb4, 0x1a, 0x0, 0x8, 0xc1, 0xf1, 0x90, 0xf0, 0x46, 0x35, 0x5d, 0xca, - 0x27, 0x0, 0x0, 0x1a, 0xd5, 0x25, 0xac, 0x60, 0x84, 0x18, 0xce, 0x5f, 0x70, 0x44, 0x5b, 0x52}; - - uint8_t buf[230] = {0}; - - uint8_t topic_bytes[] = {0x79, 0x5b, 0x55, 0xca, 0x76, 0xc9, 0x41, 0xcb, - 0x88, 0xa4, 0xbe, 0x5b, 0x7, 0x5a, 0xc9, 0xc7}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; +// "\206\166\&9}z\170\226\207\169\157\f{\160_\198\DEL\151\NAK'|\145", _pubPktID = 0, _pubBody = "\178\190\186$\148^\SO +// Y\222\245\255\204\180\166\231cl\175A\164x\152\234W\209\251\249\n`", _pubProps = [PropAuthenticationMethod +// "\SYN\201\191\145\165\203",PropContentType +// "4n\152\243)\215\212\204\149\175\DLE\204*}\186\210\NUL\193qY\206\&1L?}>\DC2\216",PropUserProperty "n\227OB\139 +// \195+\a\186F\159C\DC1.H\f\209\168o\252\160O\SUB\220qg\246" +// "\239\DC2F\134\174;\166\144v(pO\252\128\243",PropMaximumPacketSize 19354,PropContentType +// "\141",PropAuthenticationMethod +// "\149(\DELw\\\208\192\232^\232\240\190P\SYN]Y$\179\186\199M!\206\176",PropSubscriptionIdentifierAvailable +// 68,PropResponseTopic "\184\225,\172/G\234u\159[k\232\DLE\169\ne\DC4A\153\246\DLE",PropTopicAlias +// 14033,PropResponseInformation "m11\187\NULN\199^\192CO\237",PropMaximumPacketSize 5887,PropAuthenticationMethod +// "{\143\167\a\180\212\198\230\242\214\254|\222dj\f{\219\140\238x8\150",PropSharedSubscriptionAvailable +// 71,PropWildcardSubscriptionAvailable 139,PropSessionExpiryInterval 24881,PropRequestResponseInformation +// 105,PropMaximumQoS 233,PropWillDelayInterval 32182,PropSessionExpiryInterval 15444,PropAuthenticationMethod +// "\141\RS$",PropWildcardSubscriptionAvailable 69,PropWillDelayInterval 18160,PropReceiveMaximum +// 7546,PropAuthenticationMethod "\215\138g\131\227",PropRequestProblemInformation 32,PropAuthenticationMethod +// "\220\GS\249,~\206NI22b^4S\240\254\137\155\DEL\EOT2\196\SOG\129\149",PropTopicAlias 29532,PropServerReference +// "\194"]} +TEST(Publish5QCTest, Encode18) { + uint8_t pkt[] = { + 0x31, 0xd3, 0x2, 0x0, 0x15, 0xce, 0xa6, 0x39, 0x7d, 0x7a, 0xaa, 0xe2, 0xcf, 0xa9, 0x9d, 0xc, 0x7b, 0xa0, 0x5f, + 0xc6, 0x7f, 0x97, 0x15, 0x27, 0x7c, 0x91, 0x9c, 0x2, 0x15, 0x0, 0x6, 0x16, 0xc9, 0xbf, 0x91, 0xa5, 0xcb, 0x3, + 0x0, 0x1c, 0x34, 0x6e, 0x98, 0xf3, 0x29, 0xd7, 0xd4, 0xcc, 0x95, 0xaf, 0x10, 0xcc, 0x2a, 0x7d, 0xba, 0xd2, 0x0, + 0xc1, 0x71, 0x59, 0xce, 0x31, 0x4c, 0x3f, 0x7d, 0x3e, 0x12, 0xd8, 0x26, 0x0, 0x1c, 0x6e, 0xe3, 0x4f, 0x42, 0x8b, + 0x20, 0xc3, 0x2b, 0x7, 0xba, 0x46, 0x9f, 0x43, 0x11, 0x2e, 0x48, 0xc, 0xd1, 0xa8, 0x6f, 0xfc, 0xa0, 0x4f, 0x1a, + 0xdc, 0x71, 0x67, 0xf6, 0x0, 0xf, 0xef, 0x12, 0x46, 0x86, 0xae, 0x3b, 0xa6, 0x90, 0x76, 0x28, 0x70, 0x4f, 0xfc, + 0x80, 0xf3, 0x27, 0x0, 0x0, 0x4b, 0x9a, 0x3, 0x0, 0x1, 0x8d, 0x15, 0x0, 0x18,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, 0x24, 0x94, 0x5e, 0xe, 0x20, 0x59, 0xde, 0xf5, + 0xff, 0xcc, 0xb4, 0xa6, 0xe7, 0x63, 0x6c, 0xaf, 0x41, 0xa4, 0x78, 0x98, 0xea, 0x57, 0xd1, 0xfb, 0xf9, 0xa, 0x60}; + + uint8_t buf[352] = {0}; + + uint8_t topic_bytes[] = {0xce, 0xa6, 0x39, 0x7d, 0x7a, 0xaa, 0xe2, 0xcf, 0xa9, 0x9d, 0xc, + 0x7b, 0xa0, 0x5f, 0xc6, 0x7f, 0x97, 0x15, 0x27, 0x7c, 0x91}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x60, 0x84, 0x18, 0xce, 0x5f, 0x70, 0x44, 0x5b, 0x52}; + uint8_t msg_bytes[] = {0xb2, 0xbe, 0xba, 0x24, 0x94, 0x5e, 0xe, 0x20, 0x59, 0xde, 0xf5, 0xff, 0xcc, 0xb4, 0xa6, + 0xe7, 0x63, 0x6c, 0xaf, 0x41, 0xa4, 0x78, 0x98, 0xea, 0x57, 0xd1, 0xfb, 0xf9, 0xa, 0x60}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 30; - uint8_t bytes0[] = {0}; - uint8_t bytes1[] = {0xcb, 0xbe, 0x59, 0xb5, 0x19, 0x8d, 0xd8, 0xf8, 0x52, 0xca, 0xf1, 0x46, 0x7a, 0x99, - 0x1f, 0xd2, 0xe9, 0x49, 0x39, 0xd7, 0xe2, 0x3f, 0xee, 0x8a, 0x87, 0xee, 0x7d, 0x2e}; - uint8_t bytes2[] = {0x3a, 0xb8, 0x94, 0x60, 0xda, 0xc, 0x7b, 0xf1, 0xcf, 0x3d, 0x87, 0xc6, 0x15, 0xa6, - 0x5, 0xab, 0xb0, 0x17, 0x37, 0xaa, 0x36, 0xc4, 0xdf, 0x8f, 0x9a, 0x24, 0xf9, 0xb}; - uint8_t bytes3[] = {0x52, 0x9f, 0x3e, 0x45, 0xba, 0x9a, 0x9c, 0x30, 0x86, 0xa9, 0xc8, 0xf9, - 0xc8, 0x47, 0x1c, 0x5e, 0xf8, 0x90, 0x70, 0x58, 0xd7, 0xdd, 0xe4, 0x2}; - uint8_t bytes4[] = {0xfd, 0x44, 0x59, 0x22, 0x69, 0x1, 0x58}; - uint8_t bytes5[] = {0x8e, 0x93, 0x96, 0x8c, 0xa7, 0x3b, 0x76, 0xf7, 0x40, 0xae, 0xb7, 0x1d, 0x9e, 0xbb, 0x45, - 0xd4, 0xdf, 0x6d, 0x1e, 0x89, 0x20, 0x1f, 0xdf, 0xc5, 0x4, 0xe4, 0xf5, 0xe5, 0xe6}; - uint8_t bytes6[] = {0xc1, 0xf1, 0x90, 0xf0, 0x46, 0x35, 0x5d, 0xca}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17476}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 576}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14965}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21964}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4625}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14507}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4812}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27938}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6869}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 172}}, + uint8_t bytesprops0[] = {0x16, 0xc9, 0xbf, 0x91, 0xa5, 0xcb}; + uint8_t bytesprops1[] = {0x34, 0x6e, 0x98, 0xf3, 0x29, 0xd7, 0xd4, 0xcc, 0x95, 0xaf, 0x10, 0xcc, 0x2a, 0x7d, + 0xba, 0xd2, 0x0, 0xc1, 0x71, 0x59, 0xce, 0x31, 0x4c, 0x3f, 0x7d, 0x3e, 0x12, 0xd8}; + uint8_t bytesprops3[] = {0xef, 0x12, 0x46, 0x86, 0xae, 0x3b, 0xa6, 0x90, 0x76, 0x28, 0x70, 0x4f, 0xfc, 0x80, 0xf3}; + uint8_t bytesprops2[] = {0x6e, 0xe3, 0x4f, 0x42, 0x8b, 0x20, 0xc3, 0x2b, 0x7, 0xba, 0x46, 0x9f, 0x43, 0x11, + 0x2e, 0x48, 0xc, 0xd1, 0xa8, 0x6f, 0xfc, 0xa0, 0x4f, 0x1a, 0xdc, 0x71, 0x67, 0xf6}; + uint8_t bytesprops4[] = {0x8d}; + uint8_t bytesprops5[] = {0x95, 0x28, 0x7f, 0x77, 0x5c, 0xd0, 0xc0, 0xe8, 0x5e, 0xe8, 0xf0, 0xbe, + 0x50, 0x16, 0x5d, 0x59, 0x24, 0xb3, 0xba, 0xc7, 0x4d, 0x21, 0xce, 0xb0}; + uint8_t bytesprops6[] = {0xb8, 0xe1, 0x2c, 0xac, 0x2f, 0x47, 0xea, 0x75, 0x9f, 0x5b, 0x6b, + 0xe8, 0x10, 0xa9, 0xa, 0x65, 0x14, 0x41, 0x99, 0xf6, 0x10}; + uint8_t bytesprops7[] = {0x6d, 0x31, 0x31, 0xbb, 0x0, 0x4e, 0xc7, 0x5e, 0xc0, 0x43, 0x4f, 0xed}; + uint8_t bytesprops8[] = {0x7b, 0x8f, 0xa7, 0x7, 0xb4, 0xd4, 0xc6, 0xe6, 0xf2, 0xd6, 0xfe, 0x7c, + 0xde, 0x64, 0x6a, 0xc, 0x7b, 0xdb, 0x8c, 0xee, 0x78, 0x38, 0x96}; + uint8_t bytesprops9[] = {0x8d, 0x1e, 0x24}; + uint8_t bytesprops10[] = {0xd7, 0x8a, 0x67, 0x83, 0xe3}; + uint8_t bytesprops11[] = {0xdc, 0x1d, 0xf9, 0x2c, 0x7e, 0xce, 0x4e, 0x49, 0x32, 0x32, 0x62, 0x5e, 0x34, + 0x53, 0xf0, 0xfe, 0x89, 0x9b, 0x7f, 0x4, 0x32, 0xc4, 0xe, 0x47, 0x81, 0x95}; + uint8_t bytesprops12[] = {0xc2}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops2}, .v = {15, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19354}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14033}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5887}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24881}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32182}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15444}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18160}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7546}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29532}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops12}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); @@ -4102,1629 +4326,1401 @@ TEST(Publish50QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "]\198\"\SUB3J\207\rX", _pubPktID = -// 0, _pubBody = "\132\170$!\216\174\202%\vC\188\240\ETB'b\DC1\134", _pubProps = [PropReasonString -// "\242\150\233\253t\128\ENQQR=\181q\164\&2\138\149x5\183\191i\150\206\SOH\130\202:\220\165",PropServerReference -// "\193\167\&6\DC3\205%\197T\206m\207]$\233f\169\250l\238\ETX\146\186\162\149\b",PropAuthenticationMethod -// "\235D",PropServerKeepAlive 7181]} -TEST(Publish50QCTest, Encode21) { - uint8_t pkt[] = {0x30, 0x61, 0x0, 0x9, 0x5d, 0xc6, 0x22, 0x1a, 0x33, 0x4a, 0xcf, 0xd, 0x58, 0x44, 0x1f, 0x0, 0x1d, - 0xf2, 0x96, 0xe9, 0xfd, 0x74, 0x80, 0x5, 0x51, 0x52, 0x3d, 0xb5, 0x71, 0xa4, 0x32, 0x8a, 0x95, 0x78, - 0x35, 0xb7, 0xbf, 0x69, 0x96, 0xce, 0x1, 0x82, 0xca, 0x3a, 0xdc, 0xa5, 0x1c, 0x0, 0x19, 0xc1, 0xa7, - 0x36, 0x13, 0xcd, 0x25, 0xc5, 0x54, 0xce, 0x6d, 0xcf, 0x5d, 0x24, 0xe9, 0x66, 0xa9, 0xfa, 0x6c, 0xee, - 0x3, 0x92, 0xba, 0xa2, 0x95, 0x8, 0x15, 0x0, 0x2, 0xeb, 0x44, 0x13, 0x1c, 0xd, 0x84, 0xaa, 0x24, - 0x21, 0xd8, 0xae, 0xca, 0x25, 0xb, 0x43, 0xbc, 0xf0, 0x17, 0x27, 0x62, 0x11, 0x86}; - - uint8_t buf[109] = {0}; - - uint8_t topic_bytes[] = {0x5d, 0xc6, 0x22, 0x1a, 0x33, 0x4a, 0xcf, 0xd, 0x58}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\225\242\168", _pubPktID = 30037, +// _pubBody = "\216-7\221q<\RS\"U\210-\130\232\161\248)\248\169\151", _pubProps = [PropRetainAvailable +// 149,PropMaximumQoS 109,PropResponseInformation "\191\207\DLE",PropMessageExpiryInterval +// 32121,PropWildcardSubscriptionAvailable 88,PropResponseTopic +// "\215\FS\"\249\139\186\219\220|\184\230N8'\225()\ESC\193"]} +TEST(Publish5QCTest, Encode19) { + uint8_t pkt[] = {0x3a, 0x42, 0x0, 0x3, 0xe1, 0xf2, 0xa8, 0x75, 0x55, 0x27, 0x25, 0x95, 0x24, 0x6d, + 0x1a, 0x0, 0x3, 0xbf, 0xcf, 0x10, 0x2, 0x0, 0x0, 0x7d, 0x79, 0x28, 0x58, 0x8, + 0x0, 0x13, 0xd7, 0x1c, 0x22, 0xf9, 0x8b, 0xba, 0xdb, 0xdc, 0x7c, 0xb8, 0xe6, 0x4e, + 0x38, 0x27, 0xe1, 0x28, 0x29, 0x1b, 0xc1, 0xd8, 0x2d, 0x37, 0xdd, 0x71, 0x3c, 0x1e, + 0x22, 0x55, 0xd2, 0x2d, 0x82, 0xe8, 0xa1, 0xf8, 0x29, 0xf8, 0xa9, 0x97}; + + uint8_t buf[78] = {0}; + + uint8_t topic_bytes[] = {0xe1, 0xf2, 0xa8}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x84, 0xaa, 0x24, 0x21, 0xd8, 0xae, 0xca, 0x25, 0xb, - 0x43, 0xbc, 0xf0, 0x17, 0x27, 0x62, 0x11, 0x86}; + uint8_t msg_bytes[] = {0xd8, 0x2d, 0x37, 0xdd, 0x71, 0x3c, 0x1e, 0x22, 0x55, 0xd2, + 0x2d, 0x82, 0xe8, 0xa1, 0xf8, 0x29, 0xf8, 0xa9, 0x97}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; - - uint8_t bytes0[] = {0xf2, 0x96, 0xe9, 0xfd, 0x74, 0x80, 0x5, 0x51, 0x52, 0x3d, 0xb5, 0x71, 0xa4, 0x32, 0x8a, - 0x95, 0x78, 0x35, 0xb7, 0xbf, 0x69, 0x96, 0xce, 0x1, 0x82, 0xca, 0x3a, 0xdc, 0xa5}; - uint8_t bytes1[] = {0xc1, 0xa7, 0x36, 0x13, 0xcd, 0x25, 0xc5, 0x54, 0xce, 0x6d, 0xcf, 0x5d, 0x24, - 0xe9, 0x66, 0xa9, 0xfa, 0x6c, 0xee, 0x3, 0x92, 0xba, 0xa2, 0x95, 0x8}; - uint8_t bytes2[] = {0xeb, 0x44}; + msg.payload_len = 19; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7181}}, + uint8_t bytesprops0[] = {0xbf, 0xcf, 0x10}; + uint8_t bytesprops1[] = {0xd7, 0x1c, 0x22, 0xf9, 0x8b, 0xba, 0xdb, 0xdc, 0x7c, 0xb8, + 0xe6, 0x4e, 0x38, 0x27, 0xe1, 0x28, 0x29, 0x1b, 0xc1}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32121}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 30037, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O&", _pubPktID = 13252, _pubBody = -// "\169\202l\203dz\202-l\161\226\155\212J@v\179", _pubProps = [PropTopicAlias 5304,PropContentType -// "\242\198\130%\ACK3\"\CAN\140\130\179\213\244\243'\233\186#\254\190\199\ETX\205_\214~\218\v\169\&7",PropPayloadFormatIndicator -// 145,PropRequestResponseInformation 129,PropMaximumQoS 20,PropSubscriptionIdentifierAvailable -// 213,PropRequestResponseInformation 30,PropReceiveMaximum 3053,PropPayloadFormatIndicator 10,PropResponseTopic -// "$\SYN\186A\163\197",PropServerReference "\180<)\225k\209u\147\175\&8",PropAuthenticationData -// "\195\130\223\198\139w\DEL\ETB\200k\251\254\234\255\174\"o\FS\233\RS\143",PropPayloadFormatIndicator -// 213,PropRequestResponseInformation 54,PropServerKeepAlive 5613,PropContentType -// "\209?}'\254m\153\215\146\243\201\251\144\SOH\RSQ\ESC \131E\163\SOH\227\GSI/\182B ",PropUserProperty -// "`\EOT-\149[m\210Z\160\154\142\f\NAK\138isz2\230^" -// "\178o\215\223\233\202\182\172\233\200K0U\135\143\197T\197{\FSQ\220",PropRequestResponseInformation -// 138,PropAuthenticationMethod -// "\147V\147\139z\NUL9j\DLE\219\225i!\220\143&\171\&8\188wF@]Y|\253`\FS",PropSessionExpiryInterval 2432]} -TEST(Publish50QCTest, Encode22) { - uint8_t pkt[] = {0x35, 0xf6, 0x1, 0x0, 0x2, 0x4f, 0x26, 0x33, 0xc4, 0xdd, 0x1, 0x23, 0x14, 0xb8, 0x3, 0x0, 0x1e, - 0xf2, 0xc6, 0x82, 0x25, 0x6, 0x33, 0x22, 0x18, 0x8c, 0x82, 0xb3, 0xd5, 0xf4, 0xf3, 0x27, 0xe9, 0xba, - 0x23, 0xfe, 0xbe, 0xc7, 0x3, 0xcd, 0x5f, 0xd6, 0x7e, 0xda, 0xb, 0xa9, 0x37, 0x1, 0x91, 0x19, 0x81, - 0x24, 0x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, - 0xca, 0x2d, 0x6c, 0xa1, 0xe2, 0x9b, 0xd4, 0x4a, 0x40, 0x76, 0xb3}; - - uint8_t buf[259] = {0}; - - uint8_t topic_bytes[] = {0x4f, 0x26}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\209\144\244\190\138\251", _pubPktID +// = 1548, _pubBody = "", _pubProps = [PropMaximumPacketSize 10765,PropAssignedClientIdentifier +// "u\161e\154\RS?\SI\212E\NAK\ESCJ\217\172\231\247}\246#\198\231(",PropResponseInformation +// "8\190\199\r`\EM\219\&0`\162{\184\151\197\239\151\137\129",PropResponseTopic "R",PropSessionExpiryInterval +// 22783,PropMessageExpiryInterval 1022,PropCorrelationData "G\207C\USCW",PropUserProperty +// "\221\155S>r\US\202\160W\137y\208\238\195)\GS\238\144\&6" "m\184",PropSessionExpiryInterval 25105,PropCorrelationData +// "\191\vA\CAN\161S\129\255r=ER1\236\157\US\223N\221\n\176\&7_\186\194\245\234"]} +TEST(Publish5QCTest, Encode20) { + uint8_t pkt[] = {0x3c, 0x93, 0x1, 0x0, 0x6, 0xd1, 0x90, 0xf4, 0xbe, 0x8a, 0xfb, 0x6, 0xc, 0x87, 0x1, 0x27, 0x0, + 0x0, 0x2a, 0xd, 0x12, 0x0, 0x16, 0x75, 0xa1, 0x65, 0x9a, 0x1e, 0x3f, 0xf, 0xd4, 0x45, 0x15, 0x1b, + 0x4a, 0xd9, 0xac, 0xe7, 0xf7, 0x7d, 0xf6, 0x23, 0xc6, 0xe7, 0x28, 0x1a, 0x0, 0x12, 0x38, 0xbe, 0xc7, + 0xd, 0x60, 0x19, 0xdb, 0x30, 0x60, 0xa2, 0x7b, 0xb8, 0x97, 0xc5, 0xef, 0x97, 0x89, 0x81, 0x8, 0x0, + 0x1, 0x52, 0x11, 0x0, 0x0, 0x58, 0xff, 0x2, 0x0, 0x0, 0x3, 0xfe, 0x9, 0x0, 0x6, 0x47, 0xcf, + 0x43, 0x1f, 0x43, 0x57, 0x26, 0x0, 0x13, 0xdd, 0x9b, 0x53, 0x3e, 0x72, 0x1f, 0xca, 0xa0, 0x57, 0x89, + 0x79, 0xd0, 0xee, 0xc3, 0x29, 0x1d, 0xee, 0x90, 0x36, 0x0, 0x2, 0x6d, 0xb8, 0x11, 0x0, 0x0, 0x62, + 0x11, 0x9, 0x0, 0x1b, 0xbf, 0xb, 0x41, 0x18, 0xa1, 0x53, 0x81, 0xff, 0x72, 0x3d, 0x45, 0x52, 0x31, + 0xec, 0x9d, 0x1f, 0xdf, 0x4e, 0xdd, 0xa, 0xb0, 0x37, 0x5f, 0xba, 0xc2, 0xf5, 0xea}; + + uint8_t buf[160] = {0}; + + uint8_t topic_bytes[] = {0xd1, 0x90, 0xf4, 0xbe, 0x8a, 0xfb}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa9, 0xca, 0x6c, 0xcb, 0x64, 0x7a, 0xca, 0x2d, 0x6c, - 0xa1, 0xe2, 0x9b, 0xd4, 0x4a, 0x40, 0x76, 0xb3}; + msg.retained = false; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 0; - uint8_t bytes0[] = {0xf2, 0xc6, 0x82, 0x25, 0x6, 0x33, 0x22, 0x18, 0x8c, 0x82, 0xb3, 0xd5, 0xf4, 0xf3, 0x27, - 0xe9, 0xba, 0x23, 0xfe, 0xbe, 0xc7, 0x3, 0xcd, 0x5f, 0xd6, 0x7e, 0xda, 0xb, 0xa9, 0x37}; - uint8_t bytes1[] = {0x24, 0x16, 0xba, 0x41, 0xa3, 0xc5}; - uint8_t bytes2[] = {0xb4, 0x3c, 0x29, 0xe1, 0x6b, 0xd1, 0x75, 0x93, 0xaf, 0x38}; - uint8_t bytes3[] = {0xc3, 0x82, 0xdf, 0xc6, 0x8b, 0x77, 0x7f, 0x17, 0xc8, 0x6b, 0xfb, - 0xfe, 0xea, 0xff, 0xae, 0x22, 0x6f, 0x1c, 0xe9, 0x1e, 0x8f}; - uint8_t bytes4[] = {0xd1, 0x3f, 0x7d, 0x27, 0xfe, 0x6d, 0x99, 0xd7, 0x92, 0xf3, 0xc9, 0xfb, 0x90, 0x1, 0x1e, - 0x51, 0x1b, 0x20, 0x83, 0x45, 0xa3, 0x1, 0xe3, 0x1d, 0x49, 0x2f, 0xb6, 0x42, 0x20}; - uint8_t bytes6[] = {0xb2, 0x6f, 0xd7, 0xdf, 0xe9, 0xca, 0xb6, 0xac, 0xe9, 0xc8, 0x4b, - 0x30, 0x55, 0x87, 0x8f, 0xc5, 0x54, 0xc5, 0x7b, 0x1c, 0x51, 0xdc}; - uint8_t bytes5[] = {0x60, 0x4, 0x2d, 0x95, 0x5b, 0x6d, 0xd2, 0x5a, 0xa0, 0x9a, - 0x8e, 0xc, 0x15, 0x8a, 0x69, 0x73, 0x7a, 0x32, 0xe6, 0x5e}; - uint8_t bytes7[] = {0x93, 0x56, 0x93, 0x8b, 0x7a, 0x0, 0x39, 0x6a, 0x10, 0xdb, 0xe1, 0x69, 0x21, 0xdc, - 0x8f, 0x26, 0xab, 0x38, 0xbc, 0x77, 0x46, 0x40, 0x5d, 0x59, 0x7c, 0xfd, 0x60, 0x1c}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5304}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3053}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5613}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytes5}, .v = {22, (char*)&bytes6}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2432}}, + uint8_t bytesprops0[] = {0x75, 0xa1, 0x65, 0x9a, 0x1e, 0x3f, 0xf, 0xd4, 0x45, 0x15, 0x1b, + 0x4a, 0xd9, 0xac, 0xe7, 0xf7, 0x7d, 0xf6, 0x23, 0xc6, 0xe7, 0x28}; + uint8_t bytesprops1[] = {0x38, 0xbe, 0xc7, 0xd, 0x60, 0x19, 0xdb, 0x30, 0x60, + 0xa2, 0x7b, 0xb8, 0x97, 0xc5, 0xef, 0x97, 0x89, 0x81}; + uint8_t bytesprops2[] = {0x52}; + uint8_t bytesprops3[] = {0x47, 0xcf, 0x43, 0x1f, 0x43, 0x57}; + uint8_t bytesprops5[] = {0x6d, 0xb8}; + uint8_t bytesprops4[] = {0xdd, 0x9b, 0x53, 0x3e, 0x72, 0x1f, 0xca, 0xa0, 0x57, 0x89, + 0x79, 0xd0, 0xee, 0xc3, 0x29, 0x1d, 0xee, 0x90, 0x36}; + uint8_t bytesprops6[] = {0xbf, 0xb, 0x41, 0x18, 0xa1, 0x53, 0x81, 0xff, 0x72, 0x3d, 0x45, 0x52, 0x31, 0xec, + 0x9d, 0x1f, 0xdf, 0x4e, 0xdd, 0xa, 0xb0, 0x37, 0x5f, 0xba, 0xc2, 0xf5, 0xea}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10765}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22783}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1022}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25105}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 13252, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1548, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\v\164J\248\ACKw\168\152\154\236q\RS\ESC\fX\129\180K\FS", _pubPktID = 14693, _pubBody = -// "3MM\195\166\SIw\199E\250\155\253\164\239\US\195\168\222\171\244\206\&7/\SO ?\231\SIK", _pubProps = -// [PropServerKeepAlive 12149,PropMessageExpiryInterval 3682,PropUserProperty "\US" -// "\227\&0RP=\208\227\&6s",PropSubscriptionIdentifier 15,PropSubscriptionIdentifierAvailable -// 12,PropSubscriptionIdentifierAvailable 145,PropRequestResponseInformation 2,PropServerReference -// "\190yV\216\216|\176\DLE\198\\B\131gE\234[\205g\220\252X\US\r\250_\169h]\172",PropPayloadFormatIndicator -// 135,PropResponseTopic "H\142\&67!\178\&8\137c\148\251\172D",PropAuthenticationMethod -// "\222\135\170\SOH\222\221\224\139\130\t\129\ACK",PropAuthenticationMethod -// "\209\192y&\CAN\168\DC3\170m",PropRetainAvailable 19,PropServerKeepAlive 13760,PropSubscriptionIdentifier -// 10,PropWillDelayInterval 3711,PropSubscriptionIdentifier 6]} -TEST(Publish50QCTest, Encode23) { - uint8_t pkt[] = {0x3b, 0xaf, 0x1, 0x0, 0x13, 0xb, 0xa4, 0x4a, 0xf8, 0x6, 0x77, 0xa8, 0x98, 0x9a, 0xec, 0x71, 0x1e, - 0x1b, 0xc, 0x58, 0x81, 0xb4, 0x4b, 0x1c, 0x39, 0x65, 0x7a, 0x13, 0x2f, 0x75, 0x2, 0x0, 0x0, 0xe, - 0x62, 0x26, 0x0, 0x1, 0x1f, 0x0, 0x9, 0xe3, 0x30, 0x52, 0x50, 0x3d, 0xd0, 0xe3, 0x36, 0x73, 0xb, - 0xf, 0x29, 0xc, 0x29, 0x91, 0x19, 0x2, 0x1c, 0x0, 0x1d, 0xbe, 0x79, 0x56, 0xd8, 0xd8, 0x7c, 0xb0, - 0x10, 0xc6, 0x5c, 0x42, 0x83, 0x67, 0x45, 0xea, 0x5b, 0xcd, 0x67, 0xdc, 0xfc, 0x58, 0x1f, 0xd, 0xfa, - 0x5f, 0xa9, 0x68, 0x5d, 0xac, 0x1, 0x87, 0x8, 0x0, 0xd, 0x48, 0x8e, 0x36, 0x37, 0x21, 0xb2, 0x38, - 0x89, 0x63, 0x94, 0xfb, 0xac, 0x44, 0x15, 0x0, 0xc, 0xde, 0x87, 0xaa, 0x1, 0xde, 0xdd, 0xe0, 0x8b, - 0x82, 0x9, 0x81, 0x6, 0x15, 0x0, 0x9, 0xd1, 0xc0, 0x79, 0x26, 0x18, 0xa8, 0x13, 0xaa, 0x6d, 0x25, - 0x13, 0x13, 0x35, 0xc0, 0xb, 0xa, 0x18, 0x0, 0x0, 0xe, 0x7f, 0xb, 0x6, 0x33, 0x4d, 0x4d, 0xc3, - 0xa6, 0xf, 0x77, 0xc7, 0x45, 0xfa, 0x9b, 0xfd, 0xa4, 0xef, 0x1f, 0xc3, 0xa8, 0xde, 0xab, 0xf4, 0xce, - 0x37, 0x2f, 0xe, 0x20, 0x3f, 0xe7, 0xf, 0x4b}; - - uint8_t buf[188] = {0}; - - uint8_t topic_bytes[] = {0xb, 0xa4, 0x4a, 0xf8, 0x6, 0x77, 0xa8, 0x98, 0x9a, 0xec, - 0x71, 0x1e, 0x1b, 0xc, 0x58, 0x81, 0xb4, 0x4b, 0x1c}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\136\140\179}\STX;", _pubPktID = +// 6476, _pubBody = "Jj\SO\241\ENQ\137\DC1", _pubProps = [PropAuthenticationData +// "7\208\172)\143\239",PropMessageExpiryInterval 14862,PropMaximumPacketSize 7271,PropResponseTopic +// "\145\169Bn'",PropCorrelationData "\205\221\229\194\205\195B\162\170\166\248\239>\EOT",PropSubscriptionIdentifier +// 11,PropServerKeepAlive 3502,PropAuthenticationMethod +// "\231\188*I\DC1\211E\139\224\222\DLE\bE\141\f\220\157\&7[P\ETX\130O:\233j\223\207",PropWillDelayInterval +// 25003,PropAuthenticationData "\\g-",PropResponseTopic +// "7\248\"\198\245\216x\144\247\173&8\164&e\SOH\152\226i\225\239\238s",PropRequestResponseInformation +// 142,PropMaximumPacketSize 9884,PropSubscriptionIdentifierAvailable 226,PropResponseTopic "",PropResponseTopic +// "\140W\224\230\217@\176\254\162\161\157\201\135\138\153\GS",PropResponseTopic +// "\177\238\190k\SIb\170",PropReasonString "\239\SOH\204\154\193",PropSharedSubscriptionAvailable 52]} +TEST(Publish5QCTest, Encode21) { + uint8_t pkt[] = {0x35, 0xbc, 0x1, 0x0, 0x7, 0xfd, 0x88, 0x8c, 0xb3, 0x7d, 0x2, 0x3b, 0x19, 0x4c, 0xa8, 0x1, + 0x16, 0x0, 0x6, 0x37, 0xd0, 0xac, 0x29, 0x8f, 0xef, 0x2, 0x0, 0x0, 0x3a, 0xe, 0x27, 0x0, + 0x0, 0x1c, 0x67, 0x8, 0x0, 0x5, 0x91, 0xa9, 0x42, 0x6e, 0x27, 0x9, 0x0, 0xe, 0xcd, 0xdd, + 0xe5, 0xc2, 0xcd, 0xc3, 0x42, 0xa2, 0xaa, 0xa6, 0xf8, 0xef, 0x3e, 0x4, 0xb, 0xb, 0x13, 0xd, + 0xae, 0x15, 0x0, 0x1c, 0xe7, 0xbc, 0x2a, 0x49, 0x11, 0xd3, 0x45, 0x8b, 0xe0, 0xde, 0x10, 0x8, + 0x45, 0x8d, 0xc, 0xdc, 0x9d, 0x37, 0x5b, 0x50, 0x3, 0x82, 0x4f, 0x3a, 0xe9, 0x6a, 0xdf, 0xcf, + 0x18, 0x0, 0x0, 0x61, 0xab, 0x16, 0x0, 0x3, 0x5c, 0x67, 0x2d, 0x8, 0x0, 0x17, 0x37, 0xf8, + 0x22, 0xc6, 0xf5, 0xd8, 0x78, 0x90, 0xf7, 0xad, 0x26, 0x38, 0xa4, 0x26, 0x65, 0x1, 0x98, 0xe2, + 0x69, 0xe1, 0xef, 0xee, 0x73, 0x19, 0x8e, 0x27, 0x0, 0x0, 0x26, 0x9c, 0x29, 0xe2, 0x8, 0x0, + 0x0, 0x8, 0x0, 0x10, 0x8c, 0x57, 0xe0, 0xe6, 0xd9, 0x40, 0xb0, 0xfe, 0xa2, 0xa1, 0x9d, 0xc9, + 0x87, 0x8a, 0x99, 0x1d, 0x8, 0x0, 0x7, 0xb1, 0xee, 0xbe, 0x6b, 0xf, 0x62, 0xaa, 0x1f, 0x0, + 0x5, 0xef, 0x1, 0xcc, 0x9a, 0xc1, 0x2a, 0x34, 0x4a, 0x6a, 0xe, 0xf1, 0x5, 0x89, 0x11}; + + uint8_t buf[201] = {0}; + + uint8_t topic_bytes[] = {0xfd, 0x88, 0x8c, 0xb3, 0x7d, 0x2, 0x3b}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x33, 0x4d, 0x4d, 0xc3, 0xa6, 0xf, 0x77, 0xc7, 0x45, 0xfa, 0x9b, 0xfd, 0xa4, 0xef, 0x1f, - 0xc3, 0xa8, 0xde, 0xab, 0xf4, 0xce, 0x37, 0x2f, 0xe, 0x20, 0x3f, 0xe7, 0xf, 0x4b}; + uint8_t msg_bytes[] = {0x4a, 0x6a, 0xe, 0xf1, 0x5, 0x89, 0x11}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 7; - uint8_t bytes1[] = {0xe3, 0x30, 0x52, 0x50, 0x3d, 0xd0, 0xe3, 0x36, 0x73}; - uint8_t bytes0[] = {0x1f}; - uint8_t bytes2[] = {0xbe, 0x79, 0x56, 0xd8, 0xd8, 0x7c, 0xb0, 0x10, 0xc6, 0x5c, 0x42, 0x83, 0x67, 0x45, 0xea, - 0x5b, 0xcd, 0x67, 0xdc, 0xfc, 0x58, 0x1f, 0xd, 0xfa, 0x5f, 0xa9, 0x68, 0x5d, 0xac}; - uint8_t bytes3[] = {0x48, 0x8e, 0x36, 0x37, 0x21, 0xb2, 0x38, 0x89, 0x63, 0x94, 0xfb, 0xac, 0x44}; - uint8_t bytes4[] = {0xde, 0x87, 0xaa, 0x1, 0xde, 0xdd, 0xe0, 0x8b, 0x82, 0x9, 0x81, 0x6}; - uint8_t bytes5[] = {0xd1, 0xc0, 0x79, 0x26, 0x18, 0xa8, 0x13, 0xaa, 0x6d}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12149}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3682}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytes0}, .v = {9, (char*)&bytes1}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13760}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3711}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + uint8_t bytesprops0[] = {0x37, 0xd0, 0xac, 0x29, 0x8f, 0xef}; + uint8_t bytesprops1[] = {0x91, 0xa9, 0x42, 0x6e, 0x27}; + uint8_t bytesprops2[] = {0xcd, 0xdd, 0xe5, 0xc2, 0xcd, 0xc3, 0x42, 0xa2, 0xaa, 0xa6, 0xf8, 0xef, 0x3e, 0x4}; + uint8_t bytesprops3[] = {0xe7, 0xbc, 0x2a, 0x49, 0x11, 0xd3, 0x45, 0x8b, 0xe0, 0xde, 0x10, 0x8, 0x45, 0x8d, + 0xc, 0xdc, 0x9d, 0x37, 0x5b, 0x50, 0x3, 0x82, 0x4f, 0x3a, 0xe9, 0x6a, 0xdf, 0xcf}; + uint8_t bytesprops4[] = {0x5c, 0x67, 0x2d}; + uint8_t bytesprops5[] = {0x37, 0xf8, 0x22, 0xc6, 0xf5, 0xd8, 0x78, 0x90, 0xf7, 0xad, 0x26, 0x38, + 0xa4, 0x26, 0x65, 0x1, 0x98, 0xe2, 0x69, 0xe1, 0xef, 0xee, 0x73}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops7[] = {0x8c, 0x57, 0xe0, 0xe6, 0xd9, 0x40, 0xb0, 0xfe, + 0xa2, 0xa1, 0x9d, 0xc9, 0x87, 0x8a, 0x99, 0x1d}; + uint8_t bytesprops8[] = {0xb1, 0xee, 0xbe, 0x6b, 0xf, 0x62, 0xaa}; + uint8_t bytesprops9[] = {0xef, 0x1, 0xcc, 0x9a, 0xc1}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14862}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7271}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3502}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25003}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9884}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 52}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 14693, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 6476, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\220\170\237\142", _pubPktID = 6499, -// _pubBody = "l\EOT h\135\217\143\178&\ETB$1\239@\177~BO}3V\"\176\SOH\255", _pubProps = [PropMaximumQoS -// 153,PropWildcardSubscriptionAvailable 243,PropSubscriptionIdentifierAvailable 215,PropServerKeepAlive -// 1489,PropSessionExpiryInterval 3944,PropSubscriptionIdentifier 29,PropTopicAlias -// 29387,PropSharedSubscriptionAvailable 8,PropAuthenticationData "\219\145\n\255'",PropWildcardSubscriptionAvailable -// 44,PropMessageExpiryInterval 13597,PropTopicAliasMaximum 14055,PropAuthenticationMethod -// "%\164coT\195\n\208",PropSessionExpiryInterval 24863,PropWildcardSubscriptionAvailable -// 167,PropAssignedClientIdentifier "+\163n\142\SO\179\FS\RSS\US@\130\164\157\DC4",PropUserProperty -// "i\189h\197\245)\194\147i\134>\205.\196\239Z\ESC@|\177Q\r\221C\155\241n\193\FS\183" "a7N5$\208\151\213\173\"%\209Nu5 -// \141;\188\184\239\166\164\165\133\DC1\247\253@\132"]} -TEST(Publish50QCTest, Encode24) { - uint8_t pkt[] = {0x3a, 0xaf, 0x1, 0x0, 0x4, 0xdc, 0xaa, 0xed, 0x8e, 0x19, 0x63, 0x8c, 0x1, 0x24, 0x99, 0x28, 0xf3, - 0x29, 0xd7, 0x13, 0x5, 0xd1, 0x11, 0x0, 0x0, 0xf, 0x68, 0xb, 0x1d, 0x23, 0x72, 0xcb, 0x2a, 0x8, - 0x16, 0x0, 0x5, 0xdb, 0x91, 0xa, 0xff, 0x27, 0x28, 0x2c, 0x2, 0x0, 0x0, 0x35, 0x1d, 0x22, 0x36, - 0xe7, 0x15, 0x0, 0x8, 0x25, 0xa4, 0x63, 0x6f, 0x54, 0xc3, 0xa, 0xd0, 0x11, 0x0, 0x0, 0x61, 0x1f, - 0x28, 0xa7, 0x12, 0x0, 0xf, 0x2b, 0xa3, 0x6e, 0x8e, 0xe, 0xb3, 0x1c, 0x1e, 0x53, 0x1f, 0x40, 0x82, - 0xa4, 0x9d, 0x14, 0x26, 0x0, 0x1e, 0x69, 0xbd, 0x68, 0xc5, 0xf5, 0x29, 0xc2, 0x93, 0x69, 0x86, 0x3e, - 0xcd, 0x2e, 0xc4, 0xef, 0x5a, 0x1b, 0x40, 0x7c, 0xb1, 0x51, 0xd, 0xdd, 0x43, 0x9b, 0xf1, 0x6e, 0xc1, - 0x1c, 0xb7, 0x0, 0x1e, 0x61, 0x37, 0x4e, 0x35, 0x24, 0xd0, 0x97, 0xd5, 0xad, 0x22, 0x25, 0xd1, 0x4e, - 0x75, 0x35, 0x20, 0x8d, 0x3b, 0xbc, 0xb8, 0xef, 0xa6, 0xa4, 0xa5, 0x85, 0x11, 0xf7, 0xfd, 0x40, 0x84, - 0x6c, 0x4, 0x20, 0x68, 0x87, 0xd9, 0x8f, 0xb2, 0x26, 0x17, 0x24, 0x31, 0xef, 0x40, 0xb1, 0x7e, 0x42, - 0x4f, 0x7d, 0x33, 0x56, 0x22, 0xb0, 0x1, 0xff}; - - uint8_t buf[188] = {0}; - - uint8_t topic_bytes[] = {0xdc, 0xaa, 0xed, 0x8e}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\242\232\197\SOHHe\ETX>/ +// \232\220\247\251\tq\198\197nl\247\249", _pubPktID = 2029, _pubBody = "v_\GSO8\202C0\RS\247#\141\209\DEL", _pubProps = +// [PropUserProperty "\236\FS\154V!\ACK\133n\235\&5\255k\144\242",PropRequestProblemInformation -// 109,PropTopicAlias 26984,PropCorrelationData "=\SYN(\SI\DLE\213\139v\191\214 -// (E\143\213\210\232\DC3",PropServerKeepAlive 16628,PropMaximumPacketSize 29670,PropUserProperty "L\248\199^\157o" -// "`\139\175\"\215A\ESC\195\207\CAN\SUB\195\137\SUBFz\159\&2*\DC33R\174\n=[\246C",PropCorrelationData "&\GS"]} -TEST(Publish50QCTest, Encode32) { - uint8_t pkt[] = { - 0x3a, 0xa5, 0x2, 0x0, 0x1a, 0x57, 0x28, 0x70, 0x4, 0xd7, 0x2c, 0x43, 0xa7, 0x4, 0x4a, 0x89, 0xf7, 0x43, 0x5c, - 0xb7, 0x2e, 0x83, 0xab, 0x7f, 0x44, 0x24, 0xc3, 0x2a, 0xd3, 0x17, 0xb5, 0x52, 0x3b, 0xf0, 0x1, 0x3, 0x0, 0x2, - 0x61, 0xf, 0x2, 0x0, 0x0, 0x6d, 0xb0, 0x1a, 0x0, 0x9, 0x60, 0x24, 0xf3, 0x31, 0xd1, 0x44, 0xe, 0xe5, 0x44, - 0x2a, 0x25, 0x18, 0x0, 0x0, 0x37, 0x45, 0x24, 0x87, 0x1, 0xe9, 0x8, 0x0, 0x8, 0xcc, 0xc6, 0xde, 0xc4, 0xd0, - 0x6c, 0x1d, 0x2e, 0x2a, 0x7d, 0x1, 0x8e, 0x18, 0x0, 0x0, 0x6e, 0x88, 0xb, 0xb, 0x19, 0xbf, 0x28, 0xd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 0x2e, 0xf4, 0x3d, 0xd9, 0x4a, - 0xad, 0x68, 0xf5, 0xf8, 0xee, 0x38, 0x79, 0x44, 0xdb, 0x75, 0xf1}; - - uint8_t buf[306] = {0}; - - uint8_t topic_bytes[] = {0x57, 0x28, 0x70, 0x4, 0xd7, 0x2c, 0x43, 0xa7, 0x4, 0x4a, 0x89, 0xf7, 0x43, - 0x5c, 0xb7, 0x2e, 0x83, 0xab, 0x7f, 0x44, 0x24, 0xc3, 0x2a, 0xd3, 0x17, 0xb5}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\STXa7W", _pubPktID = 0, _pubBody = +// "\169#\136\219\142\&7\196\149\&4d\246j\146\254\188ch\168$T\135Q*\170\138\DC3!", _pubProps = [PropReasonString +// "",PropReasonString "@\t\140\194\183\210\222\194 +// f\243\tX\234\&8k\151O\207\EM\ETBV\197\&4\f\245\203",PropWildcardSubscriptionAvailable 80,PropMaximumPacketSize +// 28790,PropWildcardSubscriptionAvailable 38,PropPayloadFormatIndicator 125,PropTopicAlias 6534,PropTopicAliasMaximum +// 11429,PropPayloadFormatIndicator 157,PropSessionExpiryInterval 24063,PropServerReference +// "\183I\FS!xyu\173\158_\237\173\EOTF\r/\219\b\167O\132\228",PropMaximumPacketSize 23219,PropWillDelayInterval +// 24499,PropServerReference "\240\217*\GS\132=\195H!;\223\225(",PropRequestResponseInformation 169,PropServerKeepAlive +// 6359,PropResponseInformation +// "{\224^\223\DLE:\253zb]>\DC2#\208\DLE\ENQ\168\SO+\148L\244\185\184",PropSharedSubscriptionAvailable +// 254,PropPayloadFormatIndicator 153]} +TEST(Publish5QCTest, Encode29) { + uint8_t pkt[] = {0x38, 0xb3, 0x1, 0x0, 0x4, 0x2, 0x61, 0x37, 0x57, 0x90, 0x1, 0x1f, 0x0, 0x0, 0x1f, 0x0, 0x1b, + 0x40, 0x9, 0x8c, 0xc2, 0xb7, 0xd2, 0xde, 0xc2, 0x20, 0x66, 0xf3, 0x9, 0x58, 0xea, 0x38, 0x6b, 0x97, + 0x4f, 0xcf, 0x19, 0x17, 0x56, 0xc5, 0x34, 0xc, 0xf5, 0xcb, 0x28, 0x50, 0x27, 0x0, 0x0, 0x70, 0x76, + 0x28, 0x26, 0x1, 0x7d, 0x23, 0x19, 0x86, 0x22, 0x2c, 0xa5, 0x1, 0x9d, 0x11, 0x0, 0x0, 0x5d, 0xff, + 0x1c, 0x0, 0x16, 0xb7, 0x49, 0x1c, 0x21, 0x78, 0x79, 0x75, 0xad, 0x9e, 0x5f, 0xed, 0xad, 0x4, 0x46, + 0xd, 0x2f, 0xdb, 0x8, 0xa7, 0x4f, 0x84, 0xe4, 0x27, 0x0, 0x0, 0x5a, 0xb3, 0x18, 0x0, 0x0, 0x5f, + 0xb3, 0x1c, 0x0, 0xd, 0xf0, 0xd9, 0x2a, 0x1d, 0x84, 0x3d, 0xc3, 0x48, 0x21, 0x3b, 0xdf, 0xe1, 0x28, + 0x19, 0xa9, 0x13, 0x18, 0xd7, 0x1a, 0x0, 0x18, 0x7b, 0xe0, 0x5e, 0xdf, 0x10, 0x3a, 0xfd, 0x7a, 0x62, + 0x5d, 0x3e, 0x12, 0x23, 0xd0, 0x10, 0x5, 0xa8, 0xe, 0x2b, 0x94, 0x4c, 0xf4, 0xb9, 0xb8, 0x2a, 0xfe, + 0x1, 0x99, 0xa9, 0x23, 0x88, 0xdb, 0x8e, 0x37, 0xc4, 0x95, 0x34, 0x64, 0xf6, 0x6a, 0x92, 0xfe, 0xbc, + 0x63, 0x68, 0xa8, 0x24, 0x54, 0x87, 0x51, 0x2a, 0xaa, 0x8a, 0x13, 0x21}; + + uint8_t buf[192] = {0}; + + uint8_t topic_bytes[] = {0x2, 0x61, 0x37, 0x57}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x83, 0xda, 0x2b, 0x13, 0x59, 0x2e, 0xf4, 0x3d, 0xd9, 0x4a, 0xad, - 0x68, 0xf5, 0xf8, 0xee, 0x38, 0x79, 0x44, 0xdb, 0x75, 0xf1}; + uint8_t msg_bytes[] = {0xa9, 0x23, 0x88, 0xdb, 0x8e, 0x37, 0xc4, 0x95, 0x34, 0x64, 0xf6, 0x6a, 0x92, 0xfe, + 0xbc, 0x63, 0x68, 0xa8, 0x24, 0x54, 0x87, 0x51, 0x2a, 0xaa, 0x8a, 0x13, 0x21}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 27; - uint8_t bytes0[] = {0x61, 0xf}; - uint8_t bytes1[] = {0x60, 0x24, 0xf3, 0x31, 0xd1, 0x44, 0xe, 0xe5, 0x44}; - uint8_t bytes2[] = {0xcc, 0xc6, 0xde, 0xc4, 0xd0, 0x6c, 0x1d, 0x2e}; - uint8_t bytes3[] = {0x4c, 0x4a, 0xc7, 0x2a, 0x52, 0x94, 0x7c, 0xa}; - uint8_t bytes4[] = {0xf7, 0x8, 0x68, 0xff, 0x44, 0x68, 0x8e, 0xe0, 0xb2, 0x37, 0x95, - 0xff, 0xb7, 0xd2, 0xf1, 0x96, 0xa3, 0xbd, 0x0, 0xab, 0xa8, 0x46}; - uint8_t bytes5[] = {0xbe, 0x93, 0x95, 0xae, 0xa8, 0x7d, 0xb, 0xd3, 0xa8, 0xe1, 0x67, 0x7b, 0x9e, 0xfe, 0x5d}; - uint8_t bytes6[] = {0}; - uint8_t bytes7[] = {0xc1, 0x9d, 0x6b, 0xa7, 0xf3, 0x45, 0x9c, 0x97, 0xee, 0x86, 0xb1}; - uint8_t bytes8[] = {0xfb, 0x7b, 0x4f, 0xd5, 0xb1, 0xf3, 0x69, 0x1d, 0x3e, 0x56, - 0x21, 0x6, 0x85, 0x6e, 0xeb, 0x35, 0xff, 0x6b, 0x90, 0xf2}; - uint8_t bytes9[] = {0x3d, 0x16, 0x28, 0xf, 0x10, 0xd5, 0x8b, 0x76, 0xbf, - 0xd6, 0x20, 0x28, 0x45, 0x8f, 0xd5, 0xd2, 0xe8, 0x13}; - uint8_t bytes11[] = {0x60, 0x8b, 0xaf, 0x22, 0xd7, 0x41, 0x1b, 0xc3, 0xcf, 0x18, 0x1a, 0xc3, 0x89, 0x1a, - 0x46, 0x7a, 0x9f, 0x32, 0x2a, 0x13, 0x33, 0x52, 0xae, 0xa, 0x3d, 0x5b, 0xf6, 0x43}; - uint8_t bytes10[] = {0x4c, 0xf8, 0xc7, 0x5e, 0x9d, 0x6f}; - uint8_t bytes12[] = {0x26, 0x1d}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28080}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14149}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28296}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1889}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytes8}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26984}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytes9}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16628}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29670}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytes10}, .v = {28, (char*)&bytes11}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytes12}}}, + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x40, 0x9, 0x8c, 0xc2, 0xb7, 0xd2, 0xde, 0xc2, 0x20, 0x66, 0xf3, 0x9, 0x58, 0xea, + 0x38, 0x6b, 0x97, 0x4f, 0xcf, 0x19, 0x17, 0x56, 0xc5, 0x34, 0xc, 0xf5, 0xcb}; + uint8_t bytesprops2[] = {0xb7, 0x49, 0x1c, 0x21, 0x78, 0x79, 0x75, 0xad, 0x9e, 0x5f, 0xed, + 0xad, 0x4, 0x46, 0xd, 0x2f, 0xdb, 0x8, 0xa7, 0x4f, 0x84, 0xe4}; + uint8_t bytesprops3[] = {0xf0, 0xd9, 0x2a, 0x1d, 0x84, 0x3d, 0xc3, 0x48, 0x21, 0x3b, 0xdf, 0xe1, 0x28}; + uint8_t bytesprops4[] = {0x7b, 0xe0, 0x5e, 0xdf, 0x10, 0x3a, 0xfd, 0x7a, 0x62, 0x5d, 0x3e, 0x12, + 0x23, 0xd0, 0x10, 0x5, 0xa8, 0xe, 0x2b, 0x94, 0x4c, 0xf4, 0xb9, 0xb8}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28790}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6534}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11429}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24063}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23219}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24499}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6359}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 21051, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\231\ACK\254\SIp\166\135\GS[\235\245\182#\181\186\172xu\EOT", _pubPktID = 0, _pubBody = -// "\170\DC1*\DC3\196\248-\191\212\142:", _pubProps = [PropResponseTopic -// "\180\238>\147\208\SOH\254\251\ESC",PropSubscriptionIdentifier 21]} -TEST(Publish50QCTest, Encode33) { - uint8_t pkt[] = {0x38, 0x2f, 0x0, 0x13, 0xe7, 0x6, 0xfe, 0xf, 0x70, 0xa6, 0x87, 0x1d, 0x5b, 0xeb, 0xf5, 0xb6, 0x23, - 0xb5, 0xba, 0xac, 0x78, 0x75, 0x4, 0xe, 0x8, 0x0, 0x9, 0xb4, 0xee, 0x3e, 0x93, 0xd0, 0x1, 0xfe, - 0xfb, 0x1b, 0xb, 0x15, 0xaa, 0x11, 0x2a, 0x13, 0xc4, 0xf8, 0x2d, 0xbf, 0xd4, 0x8e, 0x3a}; - - uint8_t buf[59] = {0}; - - uint8_t topic_bytes[] = {0xe7, 0x6, 0xfe, 0xf, 0x70, 0xa6, 0x87, 0x1d, 0x5b, 0xeb, - 0xf5, 0xb6, 0x23, 0xb5, 0xba, 0xac, 0x78, 0x75, 0x4}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "Q\201\132\175[\206\183.\204\200p\224X\173\163MF\ETB\251\223T~\f\bW\241\179\180", _pubPktID = 2085, _pubBody = +// "\240\236\155\SOp\221\217'\225\163K\128", _pubProps = [PropSessionExpiryInterval 29496,PropResponseInformation +// "\155\EOTAK\NUL\174\220,K]i\DC1\157\&1\136\251r\168Z]\n\189\240h\152\EOT",PropResponseInformation +// "\189\243\170W\221\129\214\162\202\250d",PropTopicAliasMaximum 19828,PropRequestProblemInformation 123,PropTopicAlias +// 29886,PropSharedSubscriptionAvailable 149,PropTopicAlias 9028,PropAuthenticationMethod +// "\RS\217\243B\169\129\173\239\154",PropServerReference +// "\162\158\238nS\SI.\161\&9\195\179\184\ETB\131\141K3\172\174;y\160\SUBh",PropSubscriptionIdentifier +// 30,PropResponseTopic "\f*\191\179\193\251\132g\150MW\200\138\202",PropUserProperty "\SUB&k" +// "\247R\"\156\151)\150\DC3\156Mn\STX",PropMessageExpiryInterval 25601,PropMaximumPacketSize 30013,PropServerKeepAlive +// 2730,PropRequestProblemInformation 204,PropServerReference "z\169\217\248\202\183)\170",PropResponseTopic +// "~\213\169\&6Q\150\138\DC1\146\189Z\157\230\193\178\152\252\149\218\217",PropTopicAlias 3653,PropMaximumPacketSize +// 11018,PropRequestProblemInformation 73,PropTopicAliasMaximum 20508,PropAuthenticationMethod "\247\STX +// \138YJ\227\NAKF\137",PropSubscriptionIdentifierAvailable 13]} +TEST(Publish5QCTest, Encode30) { + uint8_t pkt[] = { + 0x3d, 0x86, 0x2, 0x0, 0x1c, 0x51, 0xc9, 0x84, 0xaf, 0x5b, 0xce, 0xb7, 0x2e, 0xcc, 0xc8, 0x70, 0xe0, 0x58, 0xad, + 0xa3, 0x4d, 0x46, 0x17, 0xfb, 0xdf, 0x54, 0x7e, 0xc, 0x8, 0x57, 0xf1, 0xb3, 0xb4, 0x8, 0x25, 0xd8, 0x1, 0x11, + 0x0, 0x0, 0x73, 0x38, 0x1a, 0x0, 0x1a, 0x9b, 0x4, 0x41, 0x4b, 0x0, 0xae, 0xdc, 0x2c, 0x4b, 0x5d, 0x69, 0x11, + 0x9d, 0x31, 0x88, 0xfb, 0x72, 0xa8, 0x5a, 0x5d, 0xa, 0xbd, 0xf0, 0x68, 0x98, 0x4, 0x1a, 0x0, 0xb, 0xbd, 0xf3, + 0xaa, 0x57, 0xdd, 0x81, 0xd6, 0xa2, 0xca, 0xfa, 0x64, 0x22, 0x4d, 0x74, 0x17, 0x7b, 0x23, 0x74, 0xbe, 0x2a, 0x95, + 0x23, 0x23, 0x44, 0x15, 0x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 0x4d, 0x46, 0x17, 0xfb, 0xdf, 0x54, 0x7e, 0xc, 0x8, 0x57, 0xf1, 0xb3, 0xb4}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xaa, 0x11, 0x2a, 0x13, 0xc4, 0xf8, 0x2d, 0xbf, 0xd4, 0x8e, 0x3a}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xf0, 0xec, 0x9b, 0xe, 0x70, 0xdd, 0xd9, 0x27, 0xe1, 0xa3, 0x4b, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; - - uint8_t bytes0[] = {0xb4, 0xee, 0x3e, 0x93, 0xd0, 0x1, 0xfe, 0xfb, 0x1b}; + msg.payload_len = 12; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + uint8_t bytesprops0[] = {0x9b, 0x4, 0x41, 0x4b, 0x0, 0xae, 0xdc, 0x2c, 0x4b, 0x5d, 0x69, 0x11, 0x9d, + 0x31, 0x88, 0xfb, 0x72, 0xa8, 0x5a, 0x5d, 0xa, 0xbd, 0xf0, 0x68, 0x98, 0x4}; + uint8_t bytesprops1[] = {0xbd, 0xf3, 0xaa, 0x57, 0xdd, 0x81, 0xd6, 0xa2, 0xca, 0xfa, 0x64}; + uint8_t bytesprops2[] = {0x1e, 0xd9, 0xf3, 0x42, 0xa9, 0x81, 0xad, 0xef, 0x9a}; + uint8_t bytesprops3[] = {0xa2, 0x9e, 0xee, 0x6e, 0x53, 0xf, 0x2e, 0xa1, 0x39, 0xc3, 0xb3, 0xb8, + 0x17, 0x83, 0x8d, 0x4b, 0x33, 0xac, 0xae, 0x3b, 0x79, 0xa0, 0x1a, 0x68}; + uint8_t bytesprops4[] = {0xc, 0x2a, 0xbf, 0xb3, 0xc1, 0xfb, 0x84, 0x67, 0x96, 0x4d, 0x57, 0xc8, 0x8a, 0xca}; + uint8_t bytesprops6[] = {0xf7, 0x52, 0x22, 0x9c, 0x97, 0x29, 0x96, 0x13, 0x9c, 0x4d, 0x6e, 0x2}; + uint8_t bytesprops5[] = {0x1a, 0x26, 0x6b}; + uint8_t bytesprops7[] = {0x7a, 0xa9, 0xd9, 0xf8, 0xca, 0xb7, 0x29, 0xaa}; + uint8_t bytesprops8[] = {0x7e, 0xd5, 0xa9, 0x36, 0x51, 0x96, 0x8a, 0x11, 0x92, 0xbd, + 0x5a, 0x9d, 0xe6, 0xc1, 0xb2, 0x98, 0xfc, 0x95, 0xda, 0xd9}; + uint8_t bytesprops9[] = {0xf7, 0x2, 0x20, 0x8a, 0x59, 0x4a, 0xe3, 0x15, 0x46, 0x89}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29496}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19828}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29886}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9028}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops5}, .v = {12, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25601}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30013}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2730}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3653}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11018}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20508}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2085, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\ESCe\222q\DC1?.N\128}{W\237:\250\ETB\SI\252(g\SIX\130\171\252\158", _pubPktID = 0, _pubBody = "\180v", _pubProps = -// [PropMessageExpiryInterval 24162,PropTopicAlias 24090,PropServerReference "REo48Y9Q\149",PropAuthenticationMethod -// "\188\138\ENQX\201t\192|\160\158A",PropSessionExpiryInterval 25361,PropContentType -// "\142\&9\178i\US\239\&7\189\170\&0\a\"}\227",PropCorrelationData "L",PropResponseTopic -// "\213\193\150\&7Fr_",PropRequestResponseInformation 78,PropRequestResponseInformation 14,PropWillDelayInterval 93]} -TEST(Publish50QCTest, Encode34) { - uint8_t pkt[] = {0x31, 0x6e, 0x0, 0x1a, 0x1b, 0x65, 0xde, 0x71, 0x11, 0x3f, 0x2e, 0x4e, 0x80, 0x7d, 0x7b, 0x57, - 0xed, 0x3a, 0xfa, 0x17, 0xf, 0xfc, 0x28, 0x67, 0xf, 0x58, 0x82, 0xab, 0xfc, 0x9e, 0x4f, 0x2, - 0x0, 0x0, 0x5e, 0x62, 0x23, 0x5e, 0x1a, 0x1c, 0x0, 0x9, 0x52, 0x45, 0x6f, 0x34, 0x38, 0x59, - 0x39, 0x51, 0x95, 0x15, 0x0, 0xb, 0xbc, 0x8a, 0x5, 0x58, 0xc9, 0x74, 0xc0, 0x7c, 0xa0, 0x9e, - 0x41, 0x11, 0x0, 0x0, 0x63, 0x11, 0x3, 0x0, 0xe, 0x8e, 0x39, 0xb2, 0x69, 0x1f, 0xef, 0x37, - 0xbd, 0xaa, 0x30, 0x7, 0x22, 0x7d, 0xe3, 0x9, 0x0, 0x1, 0x4c, 0x8, 0x0, 0x7, 0xd5, 0xc1, - 0x96, 0x37, 0x46, 0x72, 0x5f, 0x19, 0x4e, 0x19, 0xe, 0x18, 0x0, 0x0, 0x0, 0x5d, 0xb4, 0x76}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\162\236\175\234}", _pubPktID = +// 21077, _pubBody = "T\207i\212;Q", _pubProps = [PropResponseTopic ""]} +TEST(Publish5QCTest, Encode31) { + uint8_t pkt[] = {0x33, 0x13, 0x0, 0x5, 0xa2, 0xec, 0xaf, 0xea, 0x7d, 0x52, 0x55, + 0x3, 0x8, 0x0, 0x0, 0x54, 0xcf, 0x69, 0xd4, 0x3b, 0x51}; - uint8_t buf[122] = {0}; + uint8_t buf[31] = {0}; - uint8_t topic_bytes[] = {0x1b, 0x65, 0xde, 0x71, 0x11, 0x3f, 0x2e, 0x4e, 0x80, 0x7d, 0x7b, 0x57, 0xed, - 0x3a, 0xfa, 0x17, 0xf, 0xfc, 0x28, 0x67, 0xf, 0x58, 0x82, 0xab, 0xfc, 0x9e}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa2, 0xec, 0xaf, 0xea, 0x7d}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xb4, 0x76}; + uint8_t msg_bytes[] = {0x54, 0xcf, 0x69, 0xd4, 0x3b, 0x51}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 6; - uint8_t bytes0[] = {0x52, 0x45, 0x6f, 0x34, 0x38, 0x59, 0x39, 0x51, 0x95}; - uint8_t bytes1[] = {0xbc, 0x8a, 0x5, 0x58, 0xc9, 0x74, 0xc0, 0x7c, 0xa0, 0x9e, 0x41}; - uint8_t bytes2[] = {0x8e, 0x39, 0xb2, 0x69, 0x1f, 0xef, 0x37, 0xbd, 0xaa, 0x30, 0x7, 0x22, 0x7d, 0xe3}; - uint8_t bytes3[] = {0x4c}; - uint8_t bytes4[] = {0xd5, 0xc1, 0x96, 0x37, 0x46, 0x72, 0x5f}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24162}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24090}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25361}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 93}}, + uint8_t bytesprops0[] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 21077, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "6\228\247(\SUB\248\195J\179", -// _pubPktID = 16923, _pubBody = "\178", _pubProps = [PropAuthenticationMethod -// "\234\136\193aZ;\148q\168\187I\195\153\248\&5\254\128Q*\180\ACK?\163",PropAuthenticationMethod -// "\ESC'\133^\151\214\151|vvyL\FS4",PropAssignedClientIdentifier -// "\244m\214v5\\\169{\168\167\254",PropMessageExpiryInterval 2708,PropReceiveMaximum 21750,PropReceiveMaximum -// 22454,PropSubscriptionIdentifierAvailable 222,PropSharedSubscriptionAvailable 117,PropServerReference -// "\NUL\"\157p\189\208\177\184d",PropReceiveMaximum 13520,PropSubscriptionIdentifierAvailable 208,PropMaximumQoS -// 87,PropMessageExpiryInterval 14331,PropMaximumPacketSize 15803,PropUserProperty "\247\242\238F\156sz\207\ESC\140" -// "\212\195\252\ACK\242\203\STX\SI\157@\231\157\226J\SOd\136",PropServerKeepAlive 15692,PropMessageExpiryInterval -// 26840,PropSubscriptionIdentifierAvailable 90,PropServerKeepAlive 7831,PropSubscriptionIdentifier 33,PropResponseTopic -// "M4\224\219A\131"]} -TEST(Publish50QCTest, Encode35) { - uint8_t pkt[] = {0x32, 0xad, 0x1, 0x0, 0x9, 0x36, 0xe4, 0xf7, 0x28, 0x1a, 0xf8, 0xc3, 0x4a, 0xb3, 0x42, 0x1b, - 0x9d, 0x1, 0x15, 0x0, 0x17, 0xea, 0x88, 0xc1, 0x61, 0x5a, 0x3b, 0x94, 0x71, 0xa8, 0xbb, 0x49, - 0xc3, 0x99, 0xf8, 0x35, 0xfe, 0x80, 0x51, 0x2a, 0xb4, 0x6, 0x3f, 0xa3, 0x15, 0x0, 0xe, 0x1b, - 0x27, 0x85, 0x5e, 0x97, 0xd6, 0x97, 0x7c, 0x76, 0x76, 0x79, 0x4c, 0x1c, 0x34, 0x12, 0x0, 0xb, - 0xf4, 0x6d, 0xd6, 0x76, 0x35, 0x5c, 0xa9, 0x7b, 0xa8, 0xa7, 0xfe, 0x2, 0x0, 0x0, 0xa, 0x94, - 0x21, 0x54, 0xf6, 0x21, 0x57, 0xb6, 0x29, 0xde, 0x2a, 0x75, 0x1c, 0x0, 0x9, 0x0, 0x22, 0x9d, - 0x70, 0xbd, 0xd0, 0xb1, 0xb8, 0x64, 0x21, 0x34, 0xd0, 0x29, 0xd0, 0x24, 0x57, 0x2, 0x0, 0x0, - 0x37, 0xfb, 0x27, 0x0, 0x0, 0x3d, 0xbb, 0x26, 0x0, 0xa, 0xf7, 0xf2, 0xee, 0x46, 0x9c, 0x73, - 0x7a, 0xcf, 0x1b, 0x8c, 0x0, 0x11, 0xd4, 0xc3, 0xfc, 0x6, 0xf2, 0xcb, 0x2, 0xf, 0x9d, 0x40, - 0xe7, 0x9d, 0xe2, 0x4a, 0xe, 0x64, 0x88, 0x13, 0x3d, 0x4c, 0x2, 0x0, 0x0, 0x68, 0xd8, 0x29, - 0x5a, 0x13, 0x1e, 0x97, 0xb, 0x21, 0x8, 0x0, 0x6, 0x4d, 0x34, 0xe0, 0xdb, 0x41, 0x83, 0xb2}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "(E\170E\165\218\161\206}",PropResponseInformation -// "\174c\DEL\131\149I\139W\243\&1\190\201\141<\184\179%6\172\&3n",PropMessageExpiryInterval 18451,PropMaximumQoS -// 102,PropCorrelationData -// "q\205\161\173\218c\176%\177\223\&6.\t\ETX\ESCm\179\248\217M\255\217",PropRequestProblemInformation -// 33,PropRequestProblemInformation 200,PropServerKeepAlive 13697,PropMaximumQoS 35,PropWillDelayInterval -// 2122,PropAuthenticationData "\GSa\b\236\243o\144\\",PropSessionExpiryInterval 3573,PropResponseTopic -// "\173d\FS\194i\204\194\188P\EOT\DELqi/0\233xAo\167\183\253\169\200\194",PropSessionExpiryInterval -// 11523,PropRequestProblemInformation 52,PropMessageExpiryInterval 13459,PropMessageExpiryInterval -// 10166,PropContentType "\159S\208\157\199\165\199\b\176\178\RS\215\157\209"]} -TEST(Publish50QCTest, Encode36) { - uint8_t pkt[] = { - 0x3a, 0x97, 0x2, 0x0, 0x1a, 0x42, 0xf4, 0xb9, 0xad, 0x87, 0xde, 0xd, 0x2f, 0xc9, 0x26, 0x2, 0xc5, 0x65, 0xc4, - 0x59, 0xb, 0xdd, 0xbf, 0x98, 0x1d, 0x36, 0x72, 0x83, 0xac, 0xbc, 0xc4, 0x1c, 0x63, 0xe9, 0x1, 0x26, 0x0, 0xf, - 0xcb, 0x4e, 0xc6, 0x4b, 0xe0, 0x49, 0x48, 0xcb, 0xc6, 0x10, 0x93, 0x4e, 0xea, 0xdb, 0x4b, 0x0, 0x19, 0xe3, 0x8, - 0x5c, 0x4a, 0x82, 0xeb, 0x3f, 0xb8, 0x8c, 0x96, 0x5f, 0xe8, 0x6d, 0xa2, 0xa5, 0x68, 0x7f, 0x1e, 0xe4, 0x3f, 0xcb, - 0x5b, 0x56, 0xfc, 0xe3, 0x8, 0x0, 0x11, 0xb, 0x72, 0x23, 0x51, 0x23, 0x21, 0xea, 0x7f, 0xfc, 0xc1, 0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, 0x14, 0xe9}; - - uint8_t buf[292] = {0}; - - uint8_t topic_bytes[] = {0x42, 0xf4, 0xb9, 0xad, 0x87, 0xde, 0xd, 0x2f, 0xc9, 0x26, 0x2, 0xc5, 0x65, - 0xc4, 0x59, 0xb, 0xdd, 0xbf, 0x98, 0x1d, 0x36, 0x72, 0x83, 0xac, 0xbc, 0xc4}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\160", _pubPktID = 20635, _pubBody = +// "\220\193\SOH\ESC\150\212\SUB\t\156\222\ETB\160\148h", _pubProps = [PropResponseTopic "\174=\157\128\173"]} +TEST(Publish5QCTest, Encode33) { + uint8_t pkt[] = {0x3d, 0x1c, 0x0, 0x1, 0xa0, 0x50, 0x9b, 0x8, 0x8, 0x0, 0x5, 0xae, 0x3d, 0x9d, 0x80, + 0xad, 0xdc, 0xc1, 0x1, 0x1b, 0x96, 0xd4, 0x1a, 0x9, 0x9c, 0xde, 0x17, 0xa0, 0x94, 0x68}; + + uint8_t buf[40] = {0}; + + uint8_t topic_bytes[] = {0xa0}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x63, 0x68, 0xb7, 0x9c, 0xc3, 0x6c, 0x9f, 0xd2, 0xf2, 0x1c, 0xd8, 0x2f, 0x14, 0xe9}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xdc, 0xc1, 0x1, 0x1b, 0x96, 0xd4, 0x1a, 0x9, 0x9c, 0xde, 0x17, 0xa0, 0x94, 0x68}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 14; - uint8_t bytes1[] = {0xe3, 0x8, 0x5c, 0x4a, 0x82, 0xeb, 0x3f, 0xb8, 0x8c, 0x96, 0x5f, 0xe8, 0x6d, - 0xa2, 0xa5, 0x68, 0x7f, 0x1e, 0xe4, 0x3f, 0xcb, 0x5b, 0x56, 0xfc, 0xe3}; - uint8_t bytes0[] = {0xcb, 0x4e, 0xc6, 0x4b, 0xe0, 0x49, 0x48, 0xcb, 0xc6, 0x10, 0x93, 0x4e, 0xea, 0xdb, 0x4b}; - uint8_t bytes2[] = {0xb, 0x72, 0x23, 0x51, 0x23, 0x21, 0xea, 0x7f, 0xfc, - 0xc1, 0x9a, 0x84, 0x38, 0x60, 0xc3, 0x71, 0xf2}; - uint8_t bytes3[] = {0xc, 0x3c, 0x74, 0x58, 0xfb, 0xc8, 0x3e, 0xaa, 0x45, 0xa5, 0xda, 0xa1, 0xce, 0x7d}; - uint8_t bytes4[] = {0xae, 0x63, 0x7f, 0x83, 0x95, 0x49, 0x8b, 0x57, 0xf3, 0x31, 0xbe, - 0xc9, 0x8d, 0x3c, 0xb8, 0xb3, 0x25, 0x36, 0xac, 0x33, 0x6e}; - uint8_t bytes5[] = {0x71, 0xcd, 0xa1, 0xad, 0xda, 0x63, 0xb0, 0x25, 0xb1, 0xdf, 0x36, - 0x2e, 0x9, 0x3, 0x1b, 0x6d, 0xb3, 0xf8, 0xd9, 0x4d, 0xff, 0xd9}; - uint8_t bytes6[] = {0x1d, 0x61, 0x8, 0xec, 0xf3, 0x6f, 0x90, 0x5c}; - uint8_t bytes7[] = {0xad, 0x64, 0x1c, 0xc2, 0x69, 0xcc, 0xc2, 0xbc, 0x50, 0x4, 0x7f, 0x71, 0x69, - 0x2f, 0x30, 0xe9, 0x78, 0x41, 0x6f, 0xa7, 0xb7, 0xfd, 0xa9, 0xc8, 0xc2}; - uint8_t bytes8[] = {0x9f, 0x53, 0xd0, 0x9d, 0xc7, 0xa5, 0xc7, 0x8, 0xb0, 0xb2, 0x1e, 0xd7, 0x9d, 0xd1}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytes0}, .v = {25, (char*)&bytes1}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25964}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18451}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13697}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2122}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3573}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11523}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13459}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10166}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytes8}}}, + uint8_t bytesprops0[] = {0xae, 0x3d, 0x9d, 0x80, 0xad}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7267, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 20635, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\174N\162+\219#\236%2\208\&5p\160Z\132\133%\ENQ\220", _pubPktID = 16245, _pubBody = "\208\219\197i\234Y\159", -// _pubProps = [PropReceiveMaximum 8564,PropMaximumPacketSize 24665,PropAssignedClientIdentifier -// "\231\155\&5a#\225c\170S\192\213\136\SYN\210\214b",PropMessageExpiryInterval 9468,PropPayloadFormatIndicator -// 29,PropAuthenticationData "",PropRequestResponseInformation 140,PropRetainAvailable 51,PropPayloadFormatIndicator -// 167,PropWillDelayInterval 2112,PropMessageExpiryInterval 6975,PropAuthenticationData "j\205`\214\138\133 -// \193O\GS\245\158\206\t\180\217|\NUL_\SO\ACK\EOT",PropSubscriptionIdentifier 2,PropRequestResponseInformation -// 97,PropSharedSubscriptionAvailable 219,PropPayloadFormatIndicator 171,PropSharedSubscriptionAvailable -// 137,PropPayloadFormatIndicator 33,PropAuthenticationMethod -// "\NAK\175]\246\158zrg\164\182y\223\229",PropSubscriptionIdentifierAvailable 211,PropUserProperty "\184\222\225\157B[" -// "\185\201\177\n",PropSubscriptionIdentifier 2,PropSubscriptionIdentifier 11,PropCorrelationData "\135",PropMaximumQoS -// 89,PropReasonString "\230]\196vs\ETXLp\157\143`\r{\187\238\227\133\215-]\202rg\DC4\208AAT\233L",PropReceiveMaximum -// 15736,PropSharedSubscriptionAvailable 99]} -TEST(Publish50QCTest, Encode37) { - uint8_t pkt[] = { - 0x3a, 0xcb, 0x1, 0x0, 0x13, 0xae, 0x4e, 0xa2, 0x2b, 0xdb, 0x23, 0xec, 0x25, 0x32, 0xd0, 0x35, 0x70, 0xa0, 0x5a, - 0x84, 0x85, 0x25, 0x5, 0xdc, 0x3f, 0x75, 0xab, 0x1, 0x21, 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b, 0x23, 0xec, 0x25, 0x32, 0xd0, - 0x35, 0x70, 0xa0, 0x5a, 0x84, 0x85, 0x25, 0x5, 0xdc}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\196\196\197 +// \157\210\229\244\227\218\220\203\176\251\&4\NUL\171\DLE#\251\&9\174+\EM\197\STXt", _pubPktID = 5923, _pubBody = +// "\US[\n\SI=4\153\142(\NAK", _pubProps = [PropRequestProblemInformation 156,PropCorrelationData +// "`\155\153d\US\178\244\177\&8\195B\197\187v\248\GS\180~\154\140G",PropTopicAlias 14650,PropMaximumPacketSize +// 22984,PropAssignedClientIdentifier +// "5C^\212\n\USz\255\191\"\ETB\247\135\144\166i\134\\7?6?",PropWildcardSubscriptionAvailable 16,PropCorrelationData +// "\176*\EM_j\199\&1",PropServerKeepAlive 3990,PropAssignedClientIdentifier +// "EU4\136:\n\186\239\DC2\241R\160\133\SUB\205C\ACK\135\199\234cYV\226Iw\156\243\&4",PropAssignedClientIdentifier +// "A\243\226\158\SO\186\SI\\F_\v\252\140\180\DC2\250<\165\129\SUB",PropWildcardSubscriptionAvailable 203]} +TEST(Publish5QCTest, Encode34) { + uint8_t pkt[] = {0x34, 0xae, 0x1, 0x0, 0x1b, 0xc4, 0xc4, 0xc5, 0x20, 0x9d, 0xd2, 0xe5, 0xf4, 0xe3, 0xda, 0xdc, 0xcb, + 0xb0, 0xfb, 0x34, 0x0, 0xab, 0x10, 0x23, 0xfb, 0x39, 0xae, 0x2b, 0x19, 0xc5, 0x2, 0x74, 0x17, 0x23, + 0x83, 0x1, 0x17, 0x9c, 0x9, 0x0, 0x15, 0x60, 0x9b, 0x99, 0x64, 0x1f, 0xb2, 0xf4, 0xb1, 0x38, 0xc3, + 0x42, 0xc5, 0xbb, 0x76, 0xf8, 0x1d, 0xb4, 0x7e, 0x9a, 0x8c, 0x47, 0x23, 0x39, 0x3a, 0x27, 0x0, 0x0, + 0x59, 0xc8, 0x12, 0x0, 0x16, 0x35, 0x43, 0x5e, 0xd4, 0xa, 0x1f, 0x7a, 0xff, 0xbf, 0x22, 0x17, 0xf7, + 0x87, 0x90, 0xa6, 0x69, 0x86, 0x5c, 0x37, 0x3f, 0x36, 0x3f, 0x28, 0x10, 0x9, 0x0, 0x7, 0xb0, 0x2a, + 0x19, 0x5f, 0x6a, 0xc7, 0x31, 0x13, 0xf, 0x96, 0x12, 0x0, 0x1d, 0x45, 0x55, 0x34, 0x88, 0x3a, 0xa, + 0xba, 0xef, 0x12, 0xf1, 0x52, 0xa0, 0x85, 0x1a, 0xcd, 0x43, 0x6, 0x87, 0xc7, 0xea, 0x63, 0x59, 0x56, + 0xe2, 0x49, 0x77, 0x9c, 0xf3, 0x34, 0x12, 0x0, 0x14, 0x41, 0xf3, 0xe2, 0x9e, 0xe, 0xba, 0xf, 0x5c, + 0x46, 0x5f, 0xb, 0xfc, 0x8c, 0xb4, 0x12, 0xfa, 0x3c, 0xa5, 0x81, 0x1a, 0x28, 0xcb, 0x1f, 0x5b, 0xa, + 0xf, 0x3d, 0x34, 0x99, 0x8e, 0x28, 0x15}; + + uint8_t buf[187] = {0}; + + uint8_t topic_bytes[] = {0xc4, 0xc4, 0xc5, 0x20, 0x9d, 0xd2, 0xe5, 0xf4, 0xe3, 0xda, 0xdc, 0xcb, 0xb0, 0xfb, + 0x34, 0x0, 0xab, 0x10, 0x23, 0xfb, 0x39, 0xae, 0x2b, 0x19, 0xc5, 0x2, 0x74}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xd0, 0xdb, 0xc5, 0x69, 0xea, 0x59, 0x9f}; + uint8_t msg_bytes[] = {0x1f, 0x5b, 0xa, 0xf, 0x3d, 0x34, 0x99, 0x8e, 0x28, 0x15}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 10; - uint8_t bytes0[] = {0xe7, 0x9b, 0x35, 0x61, 0x23, 0xe1, 0x63, 0xaa, 0x53, 0xc0, 0xd5, 0x88, 0x16, 0xd2, 0xd6, 0x62}; - uint8_t bytes1[] = {0}; - uint8_t bytes2[] = {0x6a, 0xcd, 0x60, 0xd6, 0x8a, 0x85, 0x20, 0xc1, 0x4f, 0x1d, 0xf5, - 0x9e, 0xce, 0x9, 0xb4, 0xd9, 0x7c, 0x0, 0x5f, 0xe, 0x6, 0x4}; - uint8_t bytes3[] = {0x15, 0xaf, 0x5d, 0xf6, 0x9e, 0x7a, 0x72, 0x67, 0xa4, 0xb6, 0x79, 0xdf, 0xe5}; - uint8_t bytes5[] = {0xb9, 0xc9, 0xb1, 0xa}; - uint8_t bytes4[] = {0xb8, 0xde, 0xe1, 0x9d, 0x42, 0x5b}; - uint8_t bytes6[] = {0x87}; - uint8_t bytes7[] = {0xe6, 0x5d, 0xc4, 0x76, 0x73, 0x3, 0x4c, 0x70, 0x9d, 0x8f, 0x60, 0xd, 0x7b, 0xbb, 0xee, - 0xe3, 0x85, 0xd7, 0x2d, 0x5d, 0xca, 0x72, 0x67, 0x14, 0xd0, 0x41, 0x41, 0x54, 0xe9, 0x4c}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8564}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24665}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9468}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2112}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6975}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytes4}, .v = {4, (char*)&bytes5}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15736}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, + uint8_t bytesprops0[] = {0x60, 0x9b, 0x99, 0x64, 0x1f, 0xb2, 0xf4, 0xb1, 0x38, 0xc3, 0x42, + 0xc5, 0xbb, 0x76, 0xf8, 0x1d, 0xb4, 0x7e, 0x9a, 0x8c, 0x47}; + uint8_t bytesprops1[] = {0x35, 0x43, 0x5e, 0xd4, 0xa, 0x1f, 0x7a, 0xff, 0xbf, 0x22, 0x17, + 0xf7, 0x87, 0x90, 0xa6, 0x69, 0x86, 0x5c, 0x37, 0x3f, 0x36, 0x3f}; + uint8_t bytesprops2[] = {0xb0, 0x2a, 0x19, 0x5f, 0x6a, 0xc7, 0x31}; + uint8_t bytesprops3[] = {0x45, 0x55, 0x34, 0x88, 0x3a, 0xa, 0xba, 0xef, 0x12, 0xf1, 0x52, 0xa0, 0x85, 0x1a, 0xcd, + 0x43, 0x6, 0x87, 0xc7, 0xea, 0x63, 0x59, 0x56, 0xe2, 0x49, 0x77, 0x9c, 0xf3, 0x34}; + uint8_t bytesprops4[] = {0x41, 0xf3, 0xe2, 0x9e, 0xe, 0xba, 0xf, 0x5c, 0x46, 0x5f, + 0xb, 0xfc, 0x8c, 0xb4, 0x12, 0xfa, 0x3c, 0xa5, 0x81, 0x1a}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14650}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22984}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3990}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 203}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16245, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 5923, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } // PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "(3\136}\227\211\FS\ETB&\222\219I\US\220}\129\253\151", _pubPktID = 28557, _pubBody = "\187|", _pubProps = -// [PropTopicAlias 10592,PropRequestProblemInformation 176,PropMaximumQoS 205,PropContentType -// "\189\FS\171\DC2\230\253\b\138\209",PropWillDelayInterval 8463,PropAssignedClientIdentifier -// "G\169\190\177\189\188^\DLE\128\FS\225P\195S",PropTopicAlias 9332,PropPayloadFormatIndicator -// 45,PropAuthenticationMethod "\149\180\240 \232\238\178Su*g\152\161\239`\137\128o\177I[\147\209",PropCorrelationData -// "\203\178\143\205\232\129\221f\251L\r",PropSubscriptionIdentifierAvailable 226]} -TEST(Publish50QCTest, Encode38) { - uint8_t pkt[] = {0x3d, 0x71, 0x0, 0x12, 0x28, 0x33, 0x88, 0x7d, 0xe3, 0xd3, 0x1c, 0x17, 0x26, 0xde, 0xdb, 0x49, 0x1f, - 0xdc, 0x7d, 0x81, 0xfd, 0x97, 0x6f, 0x8d, 0x58, 0x23, 0x29, 0x60, 0x17, 0xb0, 0x24, 0xcd, 0x3, 0x0, - 0x9, 0xbd, 0x1c, 0xab, 0x12, 0xe6, 0xfd, 0x8, 0x8a, 0xd1, 0x18, 0x0, 0x0, 0x21, 0xf, 0x12, 0x0, - 0xe, 0x47, 0xa9, 0xbe, 0xb1, 0xbd, 0xbc, 0x5e, 0x10, 0x80, 0x1c, 0xe1, 0x50, 0xc3, 0x53, 0x23, 0x24, - 0x74, 0x1, 0x2d, 0x15, 0x0, 0x17, 0x95, 0xb4, 0xf0, 0x20, 0xe8, 0xee, 0xb2, 0x53, 0x75, 0x2a, 0x67, - 0x98, 0xa1, 0xef, 0x60, 0x89, 0x80, 0x6f, 0xb1, 0x49, 0x5b, 0x93, 0xd1, 0x9, 0x0, 0xb, 0xcb, 0xb2, - 0x8f, 0xcd, 0xe8, 0x81, 0xdd, 0x66, 0xfb, 0x4c, 0xd, 0x29, 0xe2, 0xbb, 0x7c}; +// "\158\"Y{N(\209\&3h\199\152\255\233\186\191", _pubPktID = 26160, _pubBody = +// "\EM\255\ESCWL\245\184\&2\192\185X\214\233t\187 \133\DC4Q", _pubProps = [PropAssignedClientIdentifier +// "\DEL;\188\154\215\\\v\247j\134",PropMaximumQoS 41,PropSharedSubscriptionAvailable 165,PropMessageExpiryInterval +// 27721,PropSubscriptionIdentifier 3,PropAuthenticationData +// "\ACK\242\166\181\172vZ\174\162\US\158\144",PropAssignedClientIdentifier +// "\GS\180_\225\221o",PropSharedSubscriptionAvailable 126,PropSubscriptionIdentifierAvailable 129]} +TEST(Publish5QCTest, Encode35) { + uint8_t pkt[] = {0x3d, 0x5b, 0x0, 0xf, 0x9e, 0x22, 0x59, 0x7b, 0x4e, 0x28, 0xd1, 0x33, 0x68, 0xc7, 0x98, 0xff, + 0xe9, 0xba, 0xbf, 0x66, 0x30, 0x34, 0x12, 0x0, 0xa, 0x7f, 0x3b, 0xbc, 0x9a, 0xd7, 0x5c, 0xb, + 0xf7, 0x6a, 0x86, 0x24, 0x29, 0x2a, 0xa5, 0x2, 0x0, 0x0, 0x6c, 0x49, 0xb, 0x3, 0x16, 0x0, + 0xc, 0x6, 0xf2, 0xa6, 0xb5, 0xac, 0x76, 0x5a, 0xae, 0xa2, 0x1f, 0x9e, 0x90, 0x12, 0x0, 0x6, + 0x1d, 0xb4, 0x5f, 0xe1, 0xdd, 0x6f, 0x2a, 0x7e, 0x29, 0x81, 0x19, 0xff, 0x1b, 0x57, 0x4c, 0xf5, + 0xb8, 0x32, 0xc0, 0xb9, 0x58, 0xd6, 0xe9, 0x74, 0xbb, 0x20, 0x85, 0x14, 0x51}; + + uint8_t buf[103] = {0}; + + uint8_t topic_bytes[] = {0x9e, 0x22, 0x59, 0x7b, 0x4e, 0x28, 0xd1, 0x33, 0x68, 0xc7, 0x98, 0xff, 0xe9, 0xba, 0xbf}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x19, 0xff, 0x1b, 0x57, 0x4c, 0xf5, 0xb8, 0x32, 0xc0, 0xb9, + 0x58, 0xd6, 0xe9, 0x74, 0xbb, 0x20, 0x85, 0x14, 0x51}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 19; - uint8_t buf[125] = {0}; + uint8_t bytesprops0[] = {0x7f, 0x3b, 0xbc, 0x9a, 0xd7, 0x5c, 0xb, 0xf7, 0x6a, 0x86}; + uint8_t bytesprops1[] = {0x6, 0xf2, 0xa6, 0xb5, 0xac, 0x76, 0x5a, 0xae, 0xa2, 0x1f, 0x9e, 0x90}; + uint8_t bytesprops2[] = {0x1d, 0xb4, 0x5f, 0xe1, 0xdd, 0x6f}; - uint8_t topic_bytes[] = {0x28, 0x33, 0x88, 0x7d, 0xe3, 0xd3, 0x1c, 0x17, 0x26, - 0xde, 0xdb, 0x49, 0x1f, 0xdc, 0x7d, 0x81, 0xfd, 0x97}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27721}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 129}}, + }; + + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 26160, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\151", _pubPktID = 0, _pubBody = +// "\216N\144\&7\CAN\136\v\176\152", _pubProps = [PropUserProperty +// "\189\239\214\"\236'\198\247.\STX\r\138U\133\244\&8\SOH\167\216\SI\255eT6\158" "",PropTopicAlias +// 5174,PropReceiveMaximum 15173,PropUserProperty "\208\&6GO\242\248\172\188" +// "\"\233C\148X@F6\128\b\164",PropSubscriptionIdentifier 2,PropTopicAlias 18460,PropSubscriptionIdentifierAvailable +// 89,PropRequestProblemInformation 159,PropResponseTopic "",PropReasonString "\ETX\253\141\&6K\"\241\182l\246\252\208 +// Q\170p\168\167\139}\EOT\220",PropWillDelayInterval 12822,PropUserProperty +// "@\175\167\247\137c\SIi\183\172\248\149m\NAK\SOH\146Y\128\201)\201S\159hP\DC2\251\187kz" +// "o\211\244\255\173\195\219\156,7\189OK\t\218qv\138#\US$\218b\232\132\&3\131\180\163\RS"]} +TEST(Publish5QCTest, Encode36) { + uint8_t pkt[] = {0x39, 0xb5, 0x1, 0x0, 0x1, 0x97, 0xa7, 0x1, 0x26, 0x0, 0x19, 0xbd, 0xef, 0xd6, 0x22, 0xec, 0x27, + 0xc6, 0xf7, 0x2e, 0x2, 0xd, 0x8a, 0x55, 0x85, 0xf4, 0x38, 0x1, 0xa7, 0xd8, 0xf, 0xff, 0x65, 0x54, + 0x36, 0x9e, 0x0, 0x0, 0x23, 0x14, 0x36, 0x21, 0x3b, 0x45, 0x26, 0x0, 0x8, 0xd0, 0x36, 0x47, 0x4f, + 0xf2, 0xf8, 0xac, 0xbc, 0x0, 0xb, 0x22, 0xe9, 0x43, 0x94, 0x58, 0x40, 0x46, 0x36, 0x80, 0x8, 0xa4, + 0xb, 0x2, 0x23, 0x48, 0x1c, 0x29, 0x59, 0x17, 0x9f, 0x8, 0x0, 0x0, 0x1f, 0x0, 0x16, 0x3, 0xfd, + 0x8d, 0x36, 0x4b, 0x22, 0xf1, 0xb6, 0x6c, 0xf6, 0xfc, 0xd0, 0x20, 0x51, 0xaa, 0x70, 0xa8, 0xa7, 0x8b, + 0x7d, 0x4, 0xdc, 0x18, 0x0, 0x0, 0x32, 0x16, 0x26, 0x0, 0x1e, 0x40, 0xaf, 0xa7, 0xf7, 0x89, 0x63, + 0xf, 0x69, 0xb7, 0xac, 0xf8, 0x95, 0x6d, 0x15, 0x1, 0x92, 0x59, 0x80, 0xc9, 0x29, 0xc9, 0x53, 0x9f, + 0x68, 0x50, 0x12, 0xfb, 0xbb, 0x6b, 0x7a, 0x0, 0x1e, 0x6f, 0xd3, 0xf4, 0xff, 0xad, 0xc3, 0xdb, 0x9c, + 0x2c, 0x37, 0xbd, 0x4f, 0x4b, 0x9, 0xda, 0x71, 0x76, 0x8a, 0x23, 0x1f, 0x24, 0xda, 0x62, 0xe8, 0x84, + 0x33, 0x83, 0xb4, 0xa3, 0x1e, 0xd8, 0x4e, 0x90, 0x37, 0x18, 0x88, 0xb, 0xb0, 0x98}; + + uint8_t buf[194] = {0}; + + uint8_t topic_bytes[] = {0x97}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xbb, 0x7c}; + uint8_t msg_bytes[] = {0xd8, 0x4e, 0x90, 0x37, 0x18, 0x88, 0xb, 0xb0, 0x98}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 9; - uint8_t bytes0[] = {0xbd, 0x1c, 0xab, 0x12, 0xe6, 0xfd, 0x8, 0x8a, 0xd1}; - uint8_t bytes1[] = {0x47, 0xa9, 0xbe, 0xb1, 0xbd, 0xbc, 0x5e, 0x10, 0x80, 0x1c, 0xe1, 0x50, 0xc3, 0x53}; - uint8_t bytes2[] = {0x95, 0xb4, 0xf0, 0x20, 0xe8, 0xee, 0xb2, 0x53, 0x75, 0x2a, 0x67, 0x98, - 0xa1, 0xef, 0x60, 0x89, 0x80, 0x6f, 0xb1, 0x49, 0x5b, 0x93, 0xd1}; - uint8_t bytes3[] = {0xcb, 0xb2, 0x8f, 0xcd, 0xe8, 0x81, 0xdd, 0x66, 0xfb, 0x4c, 0xd}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10592}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8463}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9332}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops0[] = {0xbd, 0xef, 0xd6, 0x22, 0xec, 0x27, 0xc6, 0xf7, 0x2e, 0x2, 0xd, 0x8a, 0x55, + 0x85, 0xf4, 0x38, 0x1, 0xa7, 0xd8, 0xf, 0xff, 0x65, 0x54, 0x36, 0x9e}; + uint8_t bytesprops3[] = {0x22, 0xe9, 0x43, 0x94, 0x58, 0x40, 0x46, 0x36, 0x80, 0x8, 0xa4}; + uint8_t bytesprops2[] = {0xd0, 0x36, 0x47, 0x4f, 0xf2, 0xf8, 0xac, 0xbc}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0x3, 0xfd, 0x8d, 0x36, 0x4b, 0x22, 0xf1, 0xb6, 0x6c, 0xf6, 0xfc, + 0xd0, 0x20, 0x51, 0xaa, 0x70, 0xa8, 0xa7, 0x8b, 0x7d, 0x4, 0xdc}; + uint8_t bytesprops7[] = {0x6f, 0xd3, 0xf4, 0xff, 0xad, 0xc3, 0xdb, 0x9c, 0x2c, 0x37, 0xbd, 0x4f, 0x4b, 0x9, 0xda, + 0x71, 0x76, 0x8a, 0x23, 0x1f, 0x24, 0xda, 0x62, 0xe8, 0x84, 0x33, 0x83, 0xb4, 0xa3, 0x1e}; + uint8_t bytesprops6[] = {0x40, 0xaf, 0xa7, 0xf7, 0x89, 0x63, 0xf, 0x69, 0xb7, 0xac, 0xf8, 0x95, 0x6d, 0x15, 0x1, + 0x92, 0x59, 0x80, 0xc9, 0x29, 0xc9, 0x53, 0x9f, 0x68, 0x50, 0x12, 0xfb, 0xbb, 0x6b, 0x7a}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5174}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15173}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18460}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12822}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops6}, .v = {30, (char*)&bytesprops7}}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 28557, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\215\235\&1\174\249\STX", -// _pubPktID = 17754, _pubBody = "\246?w\EM\240\218\fF", _pubProps = [PropSharedSubscriptionAvailable -// 232,PropRequestProblemInformation 84,PropResponseTopic -// "~\240\236\DEL\195\&5\EOT\155\245\199\137w\151",PropSharedSubscriptionAvailable 160,PropSubscriptionIdentifier -// 8,PropResponseInformation -// ")\DC4\248\159\150\218\SOH\151X\221\222\185Ywq(\216tR\193\160",PropWildcardSubscriptionAvailable -// 53,PropPayloadFormatIndicator 189,PropTopicAlias 19435,PropResponseInformation -// "\CAN\184\&5\GS\148\&8<\186\232\138\132Z\ETB\t\SOHG",PropResponseInformation -// "\203w\DEL?W\242\235\137\181;3\132)l\188\ESC\190BKL!D\255\179T\152",PropUserProperty -// "\177\145\187\226:\ENQ\153\235\227\STX!\134xs_\191E-C\155\237" -// "\150L/\224\207\227\177a;*v\212K'\198s\174\144\\\DC4\134\142r\131\217",PropAuthenticationData -// "\202\209\214\199\DC1\147\181\254{j\193\EM\208K\157\162\195\175\250\STX\EOTyt\134\209\195HU\180",PropRetainAvailable -// 137,PropSubscriptionIdentifier 12,PropTopicAliasMaximum 17491,PropTopicAliasMaximum 31162,PropSessionExpiryInterval -// 21546,PropTopicAliasMaximum 29484,PropServerKeepAlive 7974,PropResponseInformation "\170\237",PropCorrelationData -// "\SOH\239\149g\SUB\225nz",PropPayloadFormatIndicator 183,PropReasonString "\226\249\t\229}\131Dp= -// {\181",PropServerReference -// "\242\248\183>\ACK\252_\r\209d/`\199\146\228.\a\253\223i\r\175",PropSubscriptionIdentifierAvailable -// 174,PropRetainAvailable 169,PropMaximumPacketSize 922]} -TEST(Publish50QCTest, Encode39) { +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\f\n|\ACK", _pubPktID = 0, _pubBody +// = "%\192\&0", _pubProps = [PropWildcardSubscriptionAvailable 134,PropResponseTopic +// "e\133\154\181\f\191",PropResponseInformation +// ",\192\238\248\212Sf\212j\DLE/\230\&2\216\241>\198",PropAuthenticationMethod +// "\153\GS\198\252\NUL\231J\172(\157\204J\155-\134\GS\177\217\"}\ESC:\DLE\181\156>\230>\254",PropMessageExpiryInterval +// 10851,PropSharedSubscriptionAvailable 75,PropMessageExpiryInterval 21060,PropRequestProblemInformation +// 25,PropContentType "\GS{",PropContentType ":=1'}\197\212\SOHMJ\DC2\ETX\DC4",PropResponseTopic +// "\128\177\246c?\SO\"V'\214\226\rb\EM\130;H\162\163xY;\173\215\165\SOH",PropCorrelationData +// "\r\215K\166\193\&2\v\216\169.\180$e\240H\212Ky\158\207(E\DLE\158\224\196\187\f",PropAuthenticationData +// "XRgE\190r\131\193\&0\174\181\223x\176.\nEi\250\219\157P!\n\238e",PropReceiveMaximum 11426,PropAuthenticationData +// "\244K:\153\208\210\160\&7B\238\162\158",PropRetainAvailable 20,PropMaximumQoS 9,PropSubscriptionIdentifier 25]} +TEST(Publish5QCTest, Encode37) { uint8_t pkt[] = { - 0x32, 0xa7, 0x2, 0x0, 0x7, 0x15, 0xd7, 0xeb, 0x31, 0xae, 0xf9, 0x2, 0x45, 0x5a, 0x92, 0x2, 0x2a, 0xe8, 0x17, - 0x54, 0x8, 0x0, 0xd, 0x7e, 0xf0, 0xec, 0x7f, 0xc3, 0x35, 0x4, 0x9b, 0xf5, 0xc7, 0x89, 0x77, 0x97,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x26, 0x1a, 0x0, 0x2, 0xaa, 0xed, - 0x9, 0x0, 0x8, 0x1, 0xef, 0x95, 0x67, 0x1a, 0xe1, 0x6e, 0x7a, 0x1, 0xb7, 0x1f, 0x0, 0xc, 0xe2, 0xf9, 0x9, - 0xe5, 0x7d, 0x83, 0x44, 0x70, 0x3d, 0x20, 0x7b, 0xb5, 0x1c, 0x0, 0x16, 0xf2, 0xf8, 0xb7, 0x3e, 0x6, 0xfc, 0x5f, - 0xd, 0xd1, 0x64, 0x2f, 0x60, 0xc7, 0x92, 0xe4, 0x2e, 0x7, 0xfd, 0xdf, 0x69, 0xd, 0xaf, 0x29, 0xae, 0x25, 0xa9, - 0x27, 0x0, 0x0, 0x3, 0x9a, 0xf6, 0x3f, 0x77, 0x19, 0xf0, 0xda, 0xc, 0x46}; - - uint8_t buf[308] = {0}; - - uint8_t topic_bytes[] = {0x15, 0xd7, 0xeb, 0x31, 0xae, 0xf9, 0x2}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + 0x38, 0xde, 0x1, 0x0, 0x4, 0xc, 0xa, 0x7c, 0x6, 0xd3, 0x1, 0x28, 0x86, 0x8, 0x0, 0x6, 0x65, 0x85, 0x9a, + 0xb5, 0xc, 0xbf, 0x1a, 0x0, 0x11, 0x2c, 0xc0, 0xee, 0xf8, 0xd4, 0x53, 0x66, 0xd4, 0x6a, 0x10, 0x2f, 0xe6, 0x32, + 0xd8, 0xf1, 0x3e, 0xc6, 0x15, 0x0, 0x1d, 0x99, 0x1d, 0xc6, 0xfc, 0x0, 0xe7, 0x4a, 0xac, 0x28, 0x9d, 0xcc, 0x4a, + 0x9b, 0x2d, 0x86, 0x1d, 0xb1, 0xd9, 0x22, 0x7d, 0x1b, 0x3a, 0x10, 0xb5, 0x9c, 0x3e, 0xe6, 0x3e, 0xfe, 0x2, 0x0, + 0x0, 0x2a, 0x63, 0x2a, 0x4b, 0x2, 0x0, 0x0, 0x52, 0x44, 0x17, 0x19, 0x3, 0x0, 0x2, 0x1d, 0x7b, 0x3, 0x0, + 0xd, 0x3a, 0x3d, 0x31, 0x27, 0x7d, 0xc5, 0xd4, 0x1, 0x4d, 0x4a, 0x12, 0x3, 0x14, 0x8, 0x0, 0x1a, 0x80, 0xb1, + 0xf6, 0x63, 0x3f, 0xe, 0x22, 0x56, 0x27, 0xd6, 0xe2, 0xd, 0x62, 0x19, 0x82, 0x3b, 0x48, 0xa2, 0xa3, 0x78, 0x59, + 0x3b, 0xad, 0xd7, 0xa5, 0x1, 0x9, 0x0, 0x1c, 0xd, 0xd7, 0x4b, 0xa6, 0xc1, 0x32, 0xb, 0xd8, 0xa9, 0x2e, 0xb4, + 0x24, 0x65, 0xf0, 0x48, 0xd4, 0x4b, 0x79, 0x9e, 0xcf, 0x28, 0x45, 0x10, 0x9e, 0xe0, 0xc4, 0xbb, 0xc, 0x16, 0x0, + 0x1a, 0x58, 0x52, 0x67, 0x45, 0xbe, 0x72, 0x83, 0xc1, 0x30, 0xae, 0xb5, 0xdf, 0x78, 0xb0, 0x2e, 0xa, 0x45, 0x69, + 0xfa, 0xdb, 0x9d, 0x50, 0x21, 0xa, 0xee, 0x65, 0x21, 0x2c, 0xa2, 0x16, 0x0, 0xc, 0xf4, 0x4b, 0x3a, 0x99, 0xd0, + 0xd2, 0xa0, 0x37, 0x42, 0xee, 0xa2, 0x9e, 0x25, 0x14, 0x24, 0x9, 0xb, 0x19, 0x25, 0xc0, 0x30}; + + uint8_t buf[235] = {0}; + + uint8_t topic_bytes[] = {0xc, 0xa, 0x7c, 0x6}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xf6, 0x3f, 0x77, 0x19, 0xf0, 0xda, 0xc, 0x46}; + uint8_t msg_bytes[] = {0x25, 0xc0, 0x30}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 8; + msg.payload_len = 3; - uint8_t bytes0[] = {0x7e, 0xf0, 0xec, 0x7f, 0xc3, 0x35, 0x4, 0x9b, 0xf5, 0xc7, 0x89, 0x77, 0x97}; - uint8_t bytes1[] = {0x29, 0x14, 0xf8, 0x9f, 0x96, 0xda, 0x1, 0x97, 0x58, 0xdd, 0xde, - 0xb9, 0x59, 0x77, 0x71, 0x28, 0xd8, 0x74, 0x52, 0xc1, 0xa0}; - uint8_t bytes2[] = {0x18, 0xb8, 0x35, 0x1d, 0x94, 0x38, 0x3c, 0xba, 0xe8, 0x8a, 0x84, 0x5a, 0x17, 0x9, 0x1, 0x47}; - uint8_t bytes3[] = {0xcb, 0x77, 0x7f, 0x3f, 0x57, 0xf2, 0xeb, 0x89, 0xb5, 0x3b, 0x33, 0x84, 0x29, - 0x6c, 0xbc, 0x1b, 0xbe, 0x42, 0x4b, 0x4c, 0x21, 0x44, 0xff, 0xb3, 0x54, 0x98}; - uint8_t bytes5[] = {0x96, 0x4c, 0x2f, 0xe0, 0xcf, 0xe3, 0xb1, 0x61, 0x3b, 0x2a, 0x76, 0xd4, 0x4b, - 0x27, 0xc6, 0x73, 0xae, 0x90, 0x5c, 0x14, 0x86, 0x8e, 0x72, 0x83, 0xd9}; - uint8_t bytes4[] = {0xb1, 0x91, 0xbb, 0xe2, 0x3a, 0x5, 0x99, 0xeb, 0xe3, 0x2, 0x21, - 0x86, 0x78, 0x73, 0x5f, 0xbf, 0x45, 0x2d, 0x43, 0x9b, 0xed}; - uint8_t bytes6[] = {0xca, 0xd1, 0xd6, 0xc7, 0x11, 0x93, 0xb5, 0xfe, 0x7b, 0x6a, 0xc1, 0x19, 0xd0, 0x4b, 0x9d, - 0xa2, 0xc3, 0xaf, 0xfa, 0x2, 0x4, 0x79, 0x74, 0x86, 0xd1, 0xc3, 0x48, 0x55, 0xb4}; - uint8_t bytes7[] = {0xaa, 0xed}; - uint8_t bytes8[] = {0x1, 0xef, 0x95, 0x67, 0x1a, 0xe1, 0x6e, 0x7a}; - uint8_t bytes9[] = {0xe2, 0xf9, 0x9, 0xe5, 0x7d, 0x83, 0x44, 0x70, 0x3d, 0x20, 0x7b, 0xb5}; - uint8_t bytes10[] = {0xf2, 0xf8, 0xb7, 0x3e, 0x6, 0xfc, 0x5f, 0xd, 0xd1, 0x64, 0x2f, - 0x60, 0xc7, 0x92, 0xe4, 0x2e, 0x7, 0xfd, 0xdf, 0x69, 0xd, 0xaf}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19435}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes4}, .v = {25, (char*)&bytes5}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17491}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31162}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21546}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29484}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7974}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytes8}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytes9}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytes10}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 922}}, + uint8_t bytesprops0[] = {0x65, 0x85, 0x9a, 0xb5, 0xc, 0xbf}; + uint8_t bytesprops1[] = {0x2c, 0xc0, 0xee, 0xf8, 0xd4, 0x53, 0x66, 0xd4, 0x6a, + 0x10, 0x2f, 0xe6, 0x32, 0xd8, 0xf1, 0x3e, 0xc6}; + uint8_t bytesprops2[] = {0x99, 0x1d, 0xc6, 0xfc, 0x0, 0xe7, 0x4a, 0xac, 0x28, 0x9d, 0xcc, 0x4a, 0x9b, 0x2d, 0x86, + 0x1d, 0xb1, 0xd9, 0x22, 0x7d, 0x1b, 0x3a, 0x10, 0xb5, 0x9c, 0x3e, 0xe6, 0x3e, 0xfe}; + uint8_t bytesprops3[] = {0x1d, 0x7b}; + uint8_t bytesprops4[] = {0x3a, 0x3d, 0x31, 0x27, 0x7d, 0xc5, 0xd4, 0x1, 0x4d, 0x4a, 0x12, 0x3, 0x14}; + uint8_t bytesprops5[] = {0x80, 0xb1, 0xf6, 0x63, 0x3f, 0xe, 0x22, 0x56, 0x27, 0xd6, 0xe2, 0xd, 0x62, + 0x19, 0x82, 0x3b, 0x48, 0xa2, 0xa3, 0x78, 0x59, 0x3b, 0xad, 0xd7, 0xa5, 0x1}; + uint8_t bytesprops6[] = {0xd, 0xd7, 0x4b, 0xa6, 0xc1, 0x32, 0xb, 0xd8, 0xa9, 0x2e, 0xb4, 0x24, 0x65, 0xf0, + 0x48, 0xd4, 0x4b, 0x79, 0x9e, 0xcf, 0x28, 0x45, 0x10, 0x9e, 0xe0, 0xc4, 0xbb, 0xc}; + uint8_t bytesprops7[] = {0x58, 0x52, 0x67, 0x45, 0xbe, 0x72, 0x83, 0xc1, 0x30, 0xae, 0xb5, 0xdf, 0x78, + 0xb0, 0x2e, 0xa, 0x45, 0x69, 0xfa, 0xdb, 0x9d, 0x50, 0x21, 0xa, 0xee, 0x65}; + uint8_t bytesprops8[] = {0xf4, 0x4b, 0x3a, 0x99, 0xd0, 0xd2, 0xa0, 0x37, 0x42, 0xee, 0xa2, 0x9e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10851}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21060}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11426}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17754, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "Q\188\GS\173\231\131\DC4\r\151\251\145\171\&2b\222\209\NUL\250\&4,KR", _pubPktID = 27100, _pubBody = -// "T\DC2\SO\244\150V\ENQ\RS\244\135\238\SIU#[M=#h\232\206U", _pubProps = [PropReceiveMaximum 28857,PropContentType -// "\205\239\167\US\242\FS4A\153\190\193\DC3\173$}\137l\145",PropMessageExpiryInterval 7312,PropResponseTopic -// "\166\196\170\238\"\137\\\216\214P8\t1\181\&1\219\156\236^",PropPayloadFormatIndicator 208,PropServerKeepAlive -// 30404,PropSubscriptionIdentifierAvailable 210,PropRetainAvailable 83,PropResponseInformation -// "\169\137\228`\164\182\a",PropMaximumQoS 101,PropMaximumQoS 252,PropSharedSubscriptionAvailable -// 56,PropMaximumPacketSize 16247]} -TEST(Publish50QCTest, Encode40) { - uint8_t pkt[] = {0x35, 0x82, 0x1, 0x0, 0x16, 0x51, 0xbc, 0x1d, 0xad, 0xe7, 0x83, 0x14, 0xd, 0x97, 0xfb, 0x91, 0xab, - 0x32, 0x62, 0xde, 0xd1, 0x0, 0xfa, 0x34, 0x2c, 0x4b, 0x52, 0x69, 0xdc, 0x51, 0x21, 0x70, 0xb9, 0x3, - 0x0, 0x12, 0xcd, 0xef, 0xa7, 0x1f, 0xf2, 0x1c, 0x34, 0x41, 0x99, 0xbe, 0xc1, 0x13, 0xad, 0x24, 0x7d, - 0x89, 0x6c, 0x91, 0x2, 0x0, 0x0, 0x1c, 0x90, 0x8, 0x0, 0x13, 0xa6, 0xc4, 0xaa, 0xee, 0x22, 0x89, - 0x5c, 0xd8, 0xd6, 0x50, 0x38, 0x9, 0x31, 0xb5, 0x31, 0xdb, 0x9c, 0xec, 0x5e, 0x1, 0xd0, 0x13, 0x76, - 0xc4, 0x29, 0xd2, 0x25, 0x53, 0x1a, 0x0, 0x7, 0xa9, 0x89, 0xe4, 0x60, 0xa4, 0xb6, 0x7, 0x24, 0x65, - 0x24, 0xfc, 0x2a, 0x38, 0x27, 0x0, 0x0, 0x3f, 0x77, 0x54, 0x12, 0xe, 0xf4, 0x96, 0x56, 0x5, 0x1e, - 0xf4, 0x87, 0xee, 0xf, 0x55, 0x23, 0x5b, 0x4d, 0x3d, 0x23, 0x68, 0xe8, 0xce, 0x55}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\SUB\161\156|\172\155*2\212e\184\252<\195\a\180C\177\162\130\159\166L\200\SYN_", _pubPktID = 14022, _pubBody = +// "01c\156c\152\DC3@\149/\USy\FS\147\184,n\243\245\134Kc?E\206\131\ESC ;", _pubProps = [PropRequestResponseInformation +// 116,PropAuthenticationData "\RS\160\130\&3\210\DEL\194\EOT\216\176:Rx\175\213\186V\232",PropSessionExpiryInterval +// 23836,PropRetainAvailable 106,PropReceiveMaximum 21264,PropCorrelationData "\235\254M\143\199n +// &NMG(\ACK\221",PropMaximumPacketSize 3816,PropReceiveMaximum 24077,PropTopicAlias +// 11181,PropSubscriptionIdentifierAvailable 210,PropAssignedClientIdentifier "\187Z{\181\148\236\189 "]} +TEST(Publish5QCTest, Encode38) { + uint8_t pkt[] = {0x32, 0x86, 0x1, 0x0, 0x1a, 0x1a, 0xa1, 0x9c, 0x7c, 0xac, 0x9b, 0x2a, 0x32, 0xd4, 0x65, 0xb8, + 0xfc, 0x3c, 0xc3, 0x7, 0xb4, 0x43, 0xb1, 0xa2, 0x82, 0x9f, 0xa6, 0x4c, 0xc8, 0x16, 0x5f, 0x36, + 0xc6, 0x4a, 0x19, 0x74, 0x16, 0x0, 0x12, 0x1e, 0xa0, 0x82, 0x33, 0xd2, 0x7f, 0xc2, 0x4, 0xd8, + 0xb0, 0x3a, 0x52, 0x78, 0xaf, 0xd5, 0xba, 0x56, 0xe8, 0x11, 0x0, 0x0, 0x5d, 0x1c, 0x25, 0x6a, + 0x21, 0x53, 0x10, 0x9, 0x0, 0xe, 0xeb, 0xfe, 0x4d, 0x8f, 0xc7, 0x6e, 0x20, 0x26, 0x4e, 0x4d, + 0x47, 0x28, 0x6, 0xdd, 0x27, 0x0, 0x0, 0xe, 0xe8, 0x21, 0x5e, 0xd, 0x23, 0x2b, 0xad, 0x29, + 0xd2, 0x12, 0x0, 0x8, 0xbb, 0x5a, 0x7b, 0xb5, 0x94, 0xec, 0xbd, 0x20, 0x30, 0x31, 0x63, 0x9c, + 0x63, 0x98, 0x13, 0x40, 0x95, 0x2f, 0x1f, 0x79, 0x1c, 0x93, 0xb8, 0x2c, 0x6e, 0xf3, 0xf5, 0x86, + 0x4b, 0x63, 0x3f, 0x45, 0xce, 0x83, 0x1b, 0x20, 0x3b}; - uint8_t buf[143] = {0}; + uint8_t buf[147] = {0}; - uint8_t topic_bytes[] = {0x51, 0xbc, 0x1d, 0xad, 0xe7, 0x83, 0x14, 0xd, 0x97, 0xfb, 0x91, - 0xab, 0x32, 0x62, 0xde, 0xd1, 0x0, 0xfa, 0x34, 0x2c, 0x4b, 0x52}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x1a, 0xa1, 0x9c, 0x7c, 0xac, 0x9b, 0x2a, 0x32, 0xd4, 0x65, 0xb8, 0xfc, 0x3c, + 0xc3, 0x7, 0xb4, 0x43, 0xb1, 0xa2, 0x82, 0x9f, 0xa6, 0x4c, 0xc8, 0x16, 0x5f}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x54, 0x12, 0xe, 0xf4, 0x96, 0x56, 0x5, 0x1e, 0xf4, 0x87, 0xee, - 0xf, 0x55, 0x23, 0x5b, 0x4d, 0x3d, 0x23, 0x68, 0xe8, 0xce, 0x55}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x30, 0x31, 0x63, 0x9c, 0x63, 0x98, 0x13, 0x40, 0x95, 0x2f, 0x1f, 0x79, 0x1c, 0x93, 0xb8, + 0x2c, 0x6e, 0xf3, 0xf5, 0x86, 0x4b, 0x63, 0x3f, 0x45, 0xce, 0x83, 0x1b, 0x20, 0x3b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 29; - uint8_t bytes0[] = {0xcd, 0xef, 0xa7, 0x1f, 0xf2, 0x1c, 0x34, 0x41, 0x99, - 0xbe, 0xc1, 0x13, 0xad, 0x24, 0x7d, 0x89, 0x6c, 0x91}; - uint8_t bytes1[] = {0xa6, 0xc4, 0xaa, 0xee, 0x22, 0x89, 0x5c, 0xd8, 0xd6, 0x50, - 0x38, 0x9, 0x31, 0xb5, 0x31, 0xdb, 0x9c, 0xec, 0x5e}; - uint8_t bytes2[] = {0xa9, 0x89, 0xe4, 0x60, 0xa4, 0xb6, 0x7}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28857}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7312}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30404}}, + uint8_t bytesprops0[] = {0x1e, 0xa0, 0x82, 0x33, 0xd2, 0x7f, 0xc2, 0x4, 0xd8, + 0xb0, 0x3a, 0x52, 0x78, 0xaf, 0xd5, 0xba, 0x56, 0xe8}; + uint8_t bytesprops1[] = {0xeb, 0xfe, 0x4d, 0x8f, 0xc7, 0x6e, 0x20, 0x26, 0x4e, 0x4d, 0x47, 0x28, 0x6, 0xdd}; + uint8_t bytesprops2[] = {0xbb, 0x5a, 0x7b, 0xb5, 0x94, 0xec, 0xbd, 0x20}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23836}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21264}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3816}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24077}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11181}}, {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16247}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 27100, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14022, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\165\t\199\ESC[\fQ\131\177s\220X\DC1^\151s\198\213/`\162\175,\216o\160h[\ESC", _pubPktID = 0, _pubBody = "\132", -// _pubProps = [PropAssignedClientIdentifier "\150:\SOH\223\195c\DELD",PropContentType -// "",PropWildcardSubscriptionAvailable 127,PropMessageExpiryInterval 1256,PropMaximumQoS 165,PropSubscriptionIdentifier -// 29,PropAssignedClientIdentifier -// "c{\143\174\DC1gN&\201h8\DC1\194\214\207\137\DC3\f\171\160\197\238l\flj\SI\241",PropRetainAvailable -// 246,PropPayloadFormatIndicator 218,PropMaximumQoS 100,PropReceiveMaximum 5446,PropSubscriptionIdentifierAvailable -// 80,PropWildcardSubscriptionAvailable 181,PropUserProperty -// "\164\198R\179r\202K\131`ek\214V\180Nfrk~b\t6\199\r\253\170\174\202\189tz2\243\&5\138\236P\192\200"]} +TEST(Publish5QCTest, Encode40) { + uint8_t pkt[] = {0x30, 0xb1, 0x1, 0x0, 0x1e, 0xfc, 0xab, 0x17, 0x92, 0x0, 0x98, 0x4b, 0x60, 0x29, 0x62, 0x15, 0xb4, + 0x94, 0x76, 0xae, 0x42, 0x25, 0xa0, 0xcb, 0x87, 0xca, 0x1e, 0x2c, 0xa2, 0x61, 0x4b, 0x1b, 0x46, 0xb7, + 0x8c, 0x7d, 0x9, 0x0, 0x8, 0xfa, 0x68, 0x8d, 0xce, 0x53, 0xd6, 0x52, 0x3a, 0xb, 0xe, 0x24, 0xc0, + 0x1, 0x80, 0x18, 0x0, 0x0, 0x2f, 0x81, 0x1a, 0x0, 0xa, 0xa2, 0x2, 0xb6, 0x24, 0x50, 0xde, 0x5e, + 0xc5, 0x5e, 0xa8, 0x2, 0x0, 0x0, 0x5a, 0x6e, 0x19, 0xf6, 0x17, 0x3c, 0x26, 0x0, 0x15, 0x3d, 0x9, + 0x38, 0xbd, 0xf7, 0x97, 0x3f, 0x62, 0xa0, 0x8f, 0xd4, 0xc1, 0xc3, 0x6d, 0xd2, 0x70, 0xbe, 0x89, 0x75, + 0x1e, 0xfa, 0x0, 0xc, 0xe2, 0x15, 0xe9, 0x4a, 0xc5, 0xe0, 0x78, 0x95, 0x7e, 0xde, 0xce, 0x4c, 0x18, + 0x0, 0x0, 0x4f, 0x47, 0x17, 0xde, 0x24, 0xd0, 0x17, 0x46, 0x15, 0x0, 0x1d, 0x50, 0x1a, 0xa5, 0xb6, + 0xfe, 0xe, 0xe0, 0x80, 0x3e, 0x62, 0x9, 0x36, 0xc7, 0xd, 0xfd, 0xaa, 0xae, 0xca, 0xbd, 0x74, 0x7a, + 0x32, 0xf3, 0x35, 0x8a, 0xec, 0x50, 0xc0, 0xc8, 0x20, 0xad, 0x99, 0xd1, 0xdb, 0xea, 0x70, 0x57, 0xcf, + 0x46, 0xdd, 0xca, 0x71, 0x88, 0xe3, 0xbe, 0x22, 0xc7, 0x82}; + + uint8_t buf[190] = {0}; + + uint8_t topic_bytes[] = {0xfc, 0xab, 0x17, 0x92, 0x0, 0x98, 0x4b, 0x60, 0x29, 0x62, 0x15, 0xb4, 0x94, 0x76, 0xae, + 0x42, 0x25, 0xa0, 0xcb, 0x87, 0xca, 0x1e, 0x2c, 0xa2, 0x61, 0x4b, 0x1b, 0x46, 0xb7, 0x8c}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xbb, 0x53, 0x8f, 0xdb, 0xdd, 0x42, 0x5d, 0xb4, 0x85, 0x6b, 0xf7, 0x2, 0x36, - 0xb, 0x27, 0x53, 0x98, 0x9, 0x2, 0x8c, 0x4a, 0x20, 0xb, 0xad, 0x31}; + uint8_t msg_bytes[] = {0x20, 0xad, 0x99, 0xd1, 0xdb, 0xea, 0x70, 0x57, 0xcf, 0x46, + 0xdd, 0xca, 0x71, 0x88, 0xe3, 0xbe, 0x22, 0xc7, 0x82}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 19; - uint8_t bytes0[] = {0xef, 0x19, 0x3c, 0x5d, 0x20, 0x29, 0x62, 0x4a, 0x9c, 0x37, 0x30, 0x57, 0xc0}; - uint8_t bytes1[] = {0xe6, 0x8b, 0x1b, 0x1d, 0x43, 0xe9, 0x56}; - uint8_t bytes2[] = {0xfd, 0x51}; - uint8_t bytes3[] = {0x40, 0xfc, 0x26, 0x47, 0x59}; - uint8_t bytes4[] = {0xd2, 0xd5, 0x68, 0xf7, 0x8e, 0x6c, 0x50, 0x63, 0x20, 0x43, 0x4a, 0x8, 0x45, 0x4a, - 0x7f, 0x5a, 0x15, 0x8b, 0x89, 0x2a, 0x8a, 0x40, 0x84, 0x7e, 0xc9, 0xa3, 0x1a}; - uint8_t bytes5[] = {0x2}; - uint8_t bytes6[] = {0x28, 0xf1}; - uint8_t bytes8[] = {0x85}; - uint8_t bytes7[] = {0x29, 0x36, 0x24, 0x18, 0xb9, 0x28, 0xa5, 0x2d, 0xcd, 0x2, - 0xd4, 0xcb, 0xf5, 0x82, 0x81, 0x30, 0x2b, 0xeb, 0xf7, 0x2d}; - uint8_t bytes10[] = {0xa9, 0x4d, 0xcc, 0xd6, 0xce, 0x58, 0x67, 0x32, 0xbd, 0x6c, 0x62, 0x98, 0x67, 0xd4, 0xca, 0x14}; - uint8_t bytes9[] = {0x8c, 0xc5, 0x81, 0x8, 0xac, 0xff}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14338}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21654}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29457}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21401}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13506}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26072}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytes7}, .v = {1, (char*)&bytes8}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytes9}, .v = {16, (char*)&bytes10}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6561}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 249}}, - }; - - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&proplist}; + uint8_t bytesprops0[] = {0xfa, 0x68, 0x8d, 0xce, 0x53, 0xd6, 0x52, 0x3a}; + uint8_t bytesprops1[] = {0xa2, 0x2, 0xb6, 0x24, 0x50, 0xde, 0x5e, 0xc5, 0x5e, 0xa8}; + uint8_t bytesprops3[] = {0xe2, 0x15, 0xe9, 0x4a, 0xc5, 0xe0, 0x78, 0x95, 0x7e, 0xde, 0xce, 0x4c}; + uint8_t bytesprops2[] = {0x3d, 0x9, 0x38, 0xbd, 0xf7, 0x97, 0x3f, 0x62, 0xa0, 0x8f, 0xd4, + 0xc1, 0xc3, 0x6d, 0xd2, 0x70, 0xbe, 0x89, 0x75, 0x1e, 0xfa}; + uint8_t bytesprops4[] = {0x50, 0x1a, 0xa5, 0xb6, 0xfe, 0xe, 0xe0, 0x80, 0x3e, 0x62, 0x9, 0x36, 0xc7, 0xd, 0xfd, + 0xaa, 0xae, 0xca, 0xbd, 0x74, 0x7a, 0x32, 0xf3, 0x35, 0x8a, 0xec, 0x50, 0xc0, 0xc8}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12161}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23150}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {12, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20295}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops4}}}, + }; + + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); @@ -5732,202 +5728,190 @@ TEST(Publish50QCTest, Encode42) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\DC3puWV\211\161\DC3\DC2\158\213rb\196~o", _pubProps = [PropServerReference -// "N\130\229^\ACK\207\215{\212\CAN\212o\193\163\211",PropMessageExpiryInterval 30623,PropMaximumPacketSize -// 4977,PropResponseTopic -// "\t\210\183h#\218$\204\197*\250$\241\EOT\171j\248\238\208\206\167Q\176\171\214\229\231",PropResponseTopic -// "\221\tm\DLEk\206\&5o\245\176|\248!\NUL\210",PropAuthenticationData -// "\209\&2H`\"\252\228\255l\247\234\&4\193\135\217ikb\244\155\153\214\217}\177\228",PropSubscriptionIdentifier -// 23,PropMessageExpiryInterval 15123,PropResponseInformation -// "\v1`\195\&5\EM\f\192\"\DC1\154\203\FSm\190\167\230\173`\177b\226(\208l\ENQg\239\247",PropReceiveMaximum -// 17738,PropReceiveMaximum 22356,PropContentType -// "Z\DC3\163\&9\177\192\208\SO\210-W\252\&7\198\240\159\SYN\DC1\241\251\247\169",PropMaximumPacketSize -// 26713,PropRequestProblemInformation 65,PropMaximumPacketSize 9092,PropSharedSubscriptionAvailable -// 225,PropAuthenticationMethod "\243\191;\231L\SI\234Q]\214\186w\SO\170\195Z",PropMaximumQoS 231]} -TEST(Publish50QCTest, Encode43) { - uint8_t pkt[] = {0x31, 0xe6, 0x1, 0x0, 0x0, 0xd2, 0x1, 0x1c, 0x0, 0xf, 0x4e, 0x82, 0xe5, 0x5e, 0x6, 0xcf, 0xd7, - 0x7b, 0xd4, 0x18, 0xd4, 0x6f, 0xc1, 0xa3, 0xd3, 0x2, 0x0, 0x0, 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3, 0x5a, 0x24, 0xe7, 0x13, 0x70, 0x75, 0x57, - 0x56, 0xd3, 0xa1, 0x13, 0x12, 0x9e, 0xd5, 0x72, 0x62, 0xc4, 0x7e, 0x6f}; - - uint8_t buf[243] = {0}; - - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\166z\ENQ\171\210s\190J\237\153\219\210", _pubPktID = 15842, _pubBody = "\221-AF\157\205\a\153)\165QYh", _pubProps = +// [PropServerReference "\255R\216}\b\237\189\223\&8\SOH<\231\232<\SOH\142-;\184\212;\193u",PropServerReference +// "@QM\241\217\236\SUB\168a\236\188Y\191\214\189L\192",PropReasonString +// "\US\n\178\DC3\222\SOq\213\ETX\SUB",PropTopicAliasMaximum 23180,PropAssignedClientIdentifier +// "\217\203u\EM0\136\170\141\199\159L\225\207):\233\200\242",PropAuthenticationData "\EM\164(",PropUserProperty +// "o\ENQ9\184Y)\143\210\218/\181<(W\194\&4\146\164\171\174\160Nc\STX\207\249\196\242\169" +// "\128vU\185\186\&0\205\216\171C\148\241\SUB\ESC\235\247\139\137n?\"\233\231\180p\188\165",PropAuthenticationData +// "x\161\189\255#\152\163\214",PropMessageExpiryInterval 10220,PropReasonString "\172\232\145H\188",PropCorrelationData +// "\205ep\159\228O\174\143\ETB(LL\212\191KL\US}\153\235\188'\190\DC2\180\217u\RS%k",PropMaximumPacketSize 19148]} +TEST(Publish5QCTest, Encode41) { + uint8_t pkt[] = { + 0x35, 0xf3, 0x1, 0x0, 0xc, 0xa6, 0x7a, 0x5, 0xab, 0xd2, 0x73, 0xbe, 0x4a, 0xed, 0x99, 0xdb, 0xd2, 0x3d, 0xe2, + 0xd4, 0x1, 0x1c, 0x0, 0x17, 0xff, 0x52, 0xd8, 0x7d, 0x8, 0xed, 0xbd, 0xdf, 0x38, 0x1, 0x3c, 0xe7, 0xe8, 0x3c, + 0x1, 0x8e,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xd9, 0x75, 0x1e, 0x25, 0x6b, + 0x27, 0x0, 0x0, 0x4a, 0xcc, 0xdd, 0x2d, 0x41, 0x46, 0x9d, 0xcd, 0x7, 0x99, 0x29, 0xa5, 0x51, 0x59, 0x68}; + + uint8_t buf[256] = {0}; + + uint8_t topic_bytes[] = {0xa6, 0x7a, 0x5, 0xab, 0xd2, 0x73, 0xbe, 0x4a, 0xed, 0x99, 0xdb, 0xd2}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x13, 0x70, 0x75, 0x57, 0x56, 0xd3, 0xa1, 0x13, - 0x12, 0x9e, 0xd5, 0x72, 0x62, 0xc4, 0x7e, 0x6f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; - - uint8_t bytes0[] = {0x4e, 0x82, 0xe5, 0x5e, 0x6, 0xcf, 0xd7, 0x7b, 0xd4, 0x18, 0xd4, 0x6f, 0xc1, 0xa3, 0xd3}; - uint8_t bytes1[] = {0x9, 0xd2, 0xb7, 0x68, 0x23, 0xda, 0x24, 0xcc, 0xc5, 0x2a, 0xfa, 0x24, 0xf1, 0x4, - 0xab, 0x6a, 0xf8, 0xee, 0xd0, 0xce, 0xa7, 0x51, 0xb0, 0xab, 0xd6, 0xe5, 0xe7}; - uint8_t bytes2[] = {0xdd, 0x9, 0x6d, 0x10, 0x6b, 0xce, 0x35, 0x6f, 0xf5, 0xb0, 0x7c, 0xf8, 0x21, 0x0, 0xd2}; - uint8_t bytes3[] = {0xd1, 0x32, 0x48, 0x60, 0x22, 0xfc, 0xe4, 0xff, 0x6c, 0xf7, 0xea, 0x34, 0xc1, - 0x87, 0xd9, 0x69, 0x6b, 0x62, 0xf4, 0x9b, 0x99, 0xd6, 0xd9, 0x7d, 0xb1, 0xe4}; - uint8_t bytes4[] = {0xb, 0x31, 0x60, 0xc3, 0x35, 0x19, 0xc, 0xc0, 0x22, 0x11, 0x9a, 0xcb, 0x1c, 0x6d, 0xbe, - 0xa7, 0xe6, 0xad, 0x60, 0xb1, 0x62, 0xe2, 0x28, 0xd0, 0x6c, 0x5, 0x67, 0xef, 0xf7}; - uint8_t bytes5[] = {0x5a, 0x13, 0xa3, 0x39, 0xb1, 0xc0, 0xd0, 0xe, 0xd2, 0x2d, 0x57, - 0xfc, 0x37, 0xc6, 0xf0, 0x9f, 0x16, 0x11, 0xf1, 0xfb, 0xf7, 0xa9}; - uint8_t bytes6[] = {0xf3, 0xbf, 0x3b, 0xe7, 0x4c, 0xf, 0xea, 0x51, 0x5d, 0xd6, 0xba, 0x77, 0xe, 0xaa, 0xc3, 0x5a}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30623}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4977}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15123}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17738}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22356}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26713}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9092}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, + uint8_t msg_bytes[] = {0xdd, 0x2d, 0x41, 0x46, 0x9d, 0xcd, 0x7, 0x99, 0x29, 0xa5, 0x51, 0x59, 0x68}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; + + uint8_t bytesprops0[] = {0xff, 0x52, 0xd8, 0x7d, 0x8, 0xed, 0xbd, 0xdf, 0x38, 0x1, 0x3c, 0xe7, + 0xe8, 0x3c, 0x1, 0x8e, 0x2d, 0x3b, 0xb8, 0xd4, 0x3b, 0xc1, 0x75}; + uint8_t bytesprops1[] = {0x40, 0x51, 0x4d, 0xf1, 0xd9, 0xec, 0x1a, 0xa8, 0x61, + 0xec, 0xbc, 0x59, 0xbf, 0xd6, 0xbd, 0x4c, 0xc0}; + uint8_t bytesprops2[] = {0x1f, 0xa, 0xb2, 0x13, 0xde, 0xe, 0x71, 0xd5, 0x3, 0x1a}; + uint8_t bytesprops3[] = {0xd9, 0xcb, 0x75, 0x19, 0x30, 0x88, 0xaa, 0x8d, 0xc7, + 0x9f, 0x4c, 0xe1, 0xcf, 0x29, 0x3a, 0xe9, 0xc8, 0xf2}; + uint8_t bytesprops4[] = {0x19, 0xa4, 0x28}; + uint8_t bytesprops6[] = {0x80, 0x76, 0x55, 0xb9, 0xba, 0x30, 0xcd, 0xd8, 0xab, 0x43, 0x94, 0xf1, 0x1a, 0x1b, + 0xeb, 0xf7, 0x8b, 0x89, 0x6e, 0x3f, 0x22, 0xe9, 0xe7, 0xb4, 0x70, 0xbc, 0xa5}; + uint8_t bytesprops5[] = {0x6f, 0x5, 0x39, 0xb8, 0x59, 0x29, 0x8f, 0xd2, 0xda, 0x2f, 0xb5, 0x3c, 0x28, 0x57, 0xc2, + 0x34, 0x92, 0xa4, 0xab, 0xae, 0xa0, 0x4e, 0x63, 0x2, 0xcf, 0xf9, 0xc4, 0xf2, 0xa9}; + uint8_t bytesprops7[] = {0x78, 0xa1, 0xbd, 0xff, 0x23, 0x98, 0xa3, 0xd6}; + uint8_t bytesprops8[] = {0xac, 0xe8, 0x91, 0x48, 0xbc}; + uint8_t bytesprops9[] = {0xcd, 0x65, 0x70, 0x9f, 0xe4, 0x4f, 0xae, 0x8f, 0x17, 0x28, 0x4c, 0x4c, 0xd4, 0xbf, 0x4b, + 0x4c, 0x1f, 0x7d, 0x99, 0xeb, 0xbc, 0x27, 0xbe, 0x12, 0xb4, 0xd9, 0x75, 0x1e, 0x25, 0x6b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23180}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops5}, .v = {27, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10220}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19148}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15842, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\183\171\EM\217\146\128\EOT", -// _pubPktID = 4653, _pubBody = "n\237\EMMW\138\234\154\191\141\158", _pubProps = [PropPayloadFormatIndicator -// 160,PropCorrelationData "\170\169e}\SUB3%\186\201\169-\167\DC4#\ENQ",PropMessageExpiryInterval -// 12439,PropPayloadFormatIndicator 179,PropContentType "\237\231\SO",PropWildcardSubscriptionAvailable -// 10,PropMessageExpiryInterval 27839,PropMessageExpiryInterval 692,PropTopicAliasMaximum -// 30757,PropRequestResponseInformation 215,PropMaximumQoS 178]} -TEST(Publish50QCTest, Encode44) { - uint8_t pkt[] = {0x3d, 0x4b, 0x0, 0x7, 0xb7, 0xab, 0x19, 0xd9, 0x92, 0x80, 0x4, 0x12, 0x2d, 0x34, 0x1, 0xa0, - 0x9, 0x0, 0xf, 0xaa, 0xa9, 0x65, 0x7d, 0x1a, 0x33, 0x25, 0xba, 0xc9, 0xa9, 0x2d, 0xa7, 0x14, - 0x23, 0x5, 0x2, 0x0, 0x0, 0x30, 0x97, 0x1, 0xb3, 0x3, 0x0, 0x3, 0xed, 0xe7, 0xe, 0x28, - 0xa, 0x2, 0x0, 0x0, 0x6c, 0xbf, 0x2, 0x0, 0x0, 0x2, 0xb4, 0x22, 0x78, 0x25, 0x19, 0xd7, - 0x24, 0xb2, 0x6e, 0xed, 0x19, 0x4d, 0x57, 0x8a, 0xea, 0x9a, 0xbf, 0x8d, 0x9e}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\206v6D\250\210o\GS\204\139H\184\vu\245\236z", _pubPktID = 6705, _pubBody = +// "\f\211\163\197\&3\254\185\161\DC2\198\aX\255", _pubProps = [PropReceiveMaximum 9095,PropReasonString +// ".\200\nrz\149\201\143\162>\209\221\174\158i\161\132IN",PropPayloadFormatIndicator 233]} +TEST(Publish5QCTest, Encode42) { + uint8_t pkt[] = {0x3d, 0x3e, 0x0, 0x11, 0xce, 0x76, 0x36, 0x44, 0xfa, 0xd2, 0x6f, 0x1d, 0xcc, 0x8b, 0x48, 0xb8, + 0xb, 0x75, 0xf5, 0xec, 0x7a, 0x1a, 0x31, 0x1b, 0x21, 0x23, 0x87, 0x1f, 0x0, 0x13, 0x2e, 0xc8, + 0xa, 0x72, 0x7a, 0x95, 0xc9, 0x8f, 0xa2, 0x3e, 0xd1, 0xdd, 0xae, 0x9e, 0x69, 0xa1, 0x84, 0x49, + 0x4e, 0x1, 0xe9, 0xc, 0xd3, 0xa3, 0xc5, 0x33, 0xfe, 0xb9, 0xa1, 0x12, 0xc6, 0x7, 0x58, 0xff}; - uint8_t buf[87] = {0}; + uint8_t buf[74] = {0}; - uint8_t topic_bytes[] = {0xb7, 0xab, 0x19, 0xd9, 0x92, 0x80, 0x4}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xce, 0x76, 0x36, 0x44, 0xfa, 0xd2, 0x6f, 0x1d, 0xcc, + 0x8b, 0x48, 0xb8, 0xb, 0x75, 0xf5, 0xec, 0x7a}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x6e, 0xed, 0x19, 0x4d, 0x57, 0x8a, 0xea, 0x9a, 0xbf, 0x8d, 0x9e}; + uint8_t msg_bytes[] = {0xc, 0xd3, 0xa3, 0xc5, 0x33, 0xfe, 0xb9, 0xa1, 0x12, 0xc6, 0x7, 0x58, 0xff}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 13; - uint8_t bytes0[] = {0xaa, 0xa9, 0x65, 0x7d, 0x1a, 0x33, 0x25, 0xba, 0xc9, 0xa9, 0x2d, 0xa7, 0x14, 0x23, 0x5}; - uint8_t bytes1[] = {0xed, 0xe7, 0xe}; + uint8_t bytesprops0[] = {0x2e, 0xc8, 0xa, 0x72, 0x7a, 0x95, 0xc9, 0x8f, 0xa2, 0x3e, + 0xd1, 0xdd, 0xae, 0x9e, 0x69, 0xa1, 0x84, 0x49, 0x4e}; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12439}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27839}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 692}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30757}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9095}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 233}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 4653, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6705, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\DC4\238q\ACK\ESC\142Z\GS\147\186\v?\208O", _pubPktID = 0, _pubBody = "Q4\149", _pubProps = -// [PropMessageExpiryInterval 27768,PropReceiveMaximum 25021,PropServerKeepAlive 3033,PropSessionExpiryInterval -// 32101,PropTopicAlias 8081,PropServerReference "}\ESC\227\161{\148K,\162\240",PropSubscriptionIdentifierAvailable -// 199,PropSessionExpiryInterval 26243,PropServerKeepAlive 23252,PropWildcardSubscriptionAvailable -// 242,PropPayloadFormatIndicator 228,PropMessageExpiryInterval 642,PropSharedSubscriptionAvailable -// 78,PropSharedSubscriptionAvailable 4,PropReceiveMaximum 2802,PropAssignedClientIdentifier -// "*jt\210\138@w\SYN|\USy",PropAuthenticationMethod -// "\180\SOHa\177\182\218\&7$\EM3\218\131\249\171d\GSoLA",PropRetainAvailable 173,PropMessageExpiryInterval -// 17814,PropSessionExpiryInterval 27345,PropSharedSubscriptionAvailable 40,PropReceiveMaximum 26257,PropServerKeepAlive -// 13725]} -TEST(Publish50QCTest, Encode45) { - uint8_t pkt[] = {0x30, 0x86, 0x1, 0x0, 0xe, 0x14, 0xee, 0x71, 0x6, 0x1b, 0x8e, 0x5a, 0x1d, 0x93, 0xba, 0xb, - 0x3f, 0xd0, 0x4f, 0x72, 0x2, 0x0, 0x0, 0x6c, 0x78, 0x21, 0x61, 0xbd, 0x13, 0xb, 0xd9, 0x11, - 0x0, 0x0, 0x7d, 0x65, 0x23, 0x1f, 0x91, 0x1c, 0x0, 0xa, 0x7d, 0x1b, 0xe3, 0xa1, 0x7b, 0x94, - 0x4b, 0x2c, 0xa2, 0xf0, 0x29, 0xc7, 0x11, 0x0, 0x0, 0x66, 0x83, 0x13, 0x5a, 0xd4, 0x28, 0xf2, - 0x1, 0xe4, 0x2, 0x0, 0x0, 0x2, 0x82, 0x2a, 0x4e, 0x2a, 0x4, 0x21, 0xa, 0xf2, 0x12, 0x0, - 0xb, 0x2a, 0x6a, 0x74, 0xd2, 0x8a, 0x40, 0x77, 0x16, 0x7c, 0x1f, 0x79, 0x15, 0x0, 0x13, 0xb4, - 0x1, 0x61, 0xb1, 0xb6, 0xda, 0x37, 0x24, 0x19, 0x33, 0xda, 0x83, 0xf9, 0xab, 0x64, 0x1d, 0x6f, - 0x4c, 0x41, 0x25, 0xad, 0x2, 0x0, 0x0, 0x45, 0x96, 0x11, 0x0, 0x0, 0x6a, 0xd1, 0x2a, 0x28, - 0x21, 0x66, 0x91, 0x13, 0x35, 0x9d, 0x51, 0x34, 0x95}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\146n\207\252s\SOHt\253N\US(M?\NAK&\NAKR\139\193\&4\SOH\152\179\v", _pubPktID = 0, _pubBody = +// "\139b\185\b\186\&5\RS\EOT\166\STXV\149\135/\DEL$\167\144u", _pubProps = [PropContentType +// "\210\147A\224\DC4&\222\175_ l\189${",PropWildcardSubscriptionAvailable 216,PropTopicAliasMaximum +// 7359,PropSubscriptionIdentifierAvailable 158,PropTopicAliasMaximum 2955,PropAuthenticationMethod +// "\247\157\221\203\228B\EM\170\209\236\176\&6\DEL\208",PropReasonString +// "\SUB\177n\245\222`\165@\185\205\253m\146X\231\131W\181\238\232\203",PropSessionExpiryInterval +// 24406,PropTopicAliasMaximum 25543,PropMessageExpiryInterval 21136,PropTopicAlias 21657,PropSessionExpiryInterval +// 11033,PropAuthenticationData "\128pR\231\225\221>A\224",PropSharedSubscriptionAvailable +// 110,PropWildcardSubscriptionAvailable 106,PropResponseInformation +// "\221>%\139L\205\b\142\f\215\134|\172\147*\228\b\229\140\194(\SO\226\186\b",PropContentType "\SOHN!\156M\188"]} +TEST(Publish5QCTest, Encode43) { + uint8_t pkt[] = {0x31, 0xbd, 0x1, 0x0, 0x18, 0x92, 0x6e, 0xcf, 0xfc, 0x73, 0x1, 0x74, 0xfd, 0x4e, 0x1f, 0x28, + 0x4d, 0x3f, 0x15, 0x26, 0x15, 0x52, 0x8b, 0xc1, 0x34, 0x1, 0x98, 0xb3, 0xb, 0x8e, 0x1, 0x3, + 0x0, 0xe, 0xd2, 0x93, 0x41, 0xe0, 0x14, 0x26, 0xde, 0xaf, 0x5f, 0x20, 0x6c, 0xbd, 0x24, 0x7b, + 0x28, 0xd8, 0x22, 0x1c, 0xbf, 0x29, 0x9e, 0x22, 0xb, 0x8b, 0x15, 0x0, 0xe, 0xf7, 0x9d, 0xdd, + 0xcb, 0xe4, 0x42, 0x19, 0xaa, 0xd1, 0xec, 0xb0, 0x36, 0x7f, 0xd0, 0x1f, 0x0, 0x15, 0x1a, 0xb1, + 0x6e, 0xf5, 0xde, 0x60, 0xa5, 0x40, 0xb9, 0xcd, 0xfd, 0x6d, 0x92, 0x58, 0xe7, 0x83, 0x57, 0xb5, + 0xee, 0xe8, 0xcb, 0x11, 0x0, 0x0, 0x5f, 0x56, 0x22, 0x63, 0xc7, 0x2, 0x0, 0x0, 0x52, 0x90, + 0x23, 0x54, 0x99, 0x11, 0x0, 0x0, 0x2b, 0x19, 0x16, 0x0, 0x9, 0x80, 0x70, 0x52, 0xe7, 0xe1, + 0xdd, 0x3e, 0x41, 0xe0, 0x2a, 0x6e, 0x28, 0x6a, 0x1a, 0x0, 0x19, 0xdd, 0x3e, 0x25, 0x8b, 0x4c, + 0xcd, 0x8, 0x8e, 0xc, 0xd7, 0x86, 0x7c, 0xac, 0x93, 0x2a, 0xe4, 0x8, 0xe5, 0x8c, 0xc2, 0x28, + 0xe, 0xe2, 0xba, 0x8, 0x3, 0x0, 0x6, 0x1, 0x4e, 0x21, 0x9c, 0x4d, 0xbc, 0x8b, 0x62, 0xb9, + 0x8, 0xba, 0x35, 0x1e, 0x4, 0xa6, 0x2, 0x56, 0x95, 0x87, 0x2f, 0x7f, 0x24, 0xa7, 0x90, 0x75}; - uint8_t buf[147] = {0}; + uint8_t buf[202] = {0}; - uint8_t topic_bytes[] = {0x14, 0xee, 0x71, 0x6, 0x1b, 0x8e, 0x5a, 0x1d, 0x93, 0xba, 0xb, 0x3f, 0xd0, 0x4f}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x92, 0x6e, 0xcf, 0xfc, 0x73, 0x1, 0x74, 0xfd, 0x4e, 0x1f, 0x28, 0x4d, + 0x3f, 0x15, 0x26, 0x15, 0x52, 0x8b, 0xc1, 0x34, 0x1, 0x98, 0xb3, 0xb}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x51, 0x34, 0x95}; + msg.retained = true; + uint8_t msg_bytes[] = {0x8b, 0x62, 0xb9, 0x8, 0xba, 0x35, 0x1e, 0x4, 0xa6, 0x2, + 0x56, 0x95, 0x87, 0x2f, 0x7f, 0x24, 0xa7, 0x90, 0x75}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 19; - uint8_t bytes0[] = {0x7d, 0x1b, 0xe3, 0xa1, 0x7b, 0x94, 0x4b, 0x2c, 0xa2, 0xf0}; - uint8_t bytes1[] = {0x2a, 0x6a, 0x74, 0xd2, 0x8a, 0x40, 0x77, 0x16, 0x7c, 0x1f, 0x79}; - uint8_t bytes2[] = {0xb4, 0x1, 0x61, 0xb1, 0xb6, 0xda, 0x37, 0x24, 0x19, 0x33, - 0xda, 0x83, 0xf9, 0xab, 0x64, 0x1d, 0x6f, 0x4c, 0x41}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27768}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25021}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3033}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32101}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8081}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26243}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23252}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 642}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2802}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17814}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27345}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26257}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13725}}, + uint8_t bytesprops0[] = {0xd2, 0x93, 0x41, 0xe0, 0x14, 0x26, 0xde, 0xaf, 0x5f, 0x20, 0x6c, 0xbd, 0x24, 0x7b}; + uint8_t bytesprops1[] = {0xf7, 0x9d, 0xdd, 0xcb, 0xe4, 0x42, 0x19, 0xaa, 0xd1, 0xec, 0xb0, 0x36, 0x7f, 0xd0}; + uint8_t bytesprops2[] = {0x1a, 0xb1, 0x6e, 0xf5, 0xde, 0x60, 0xa5, 0x40, 0xb9, 0xcd, 0xfd, + 0x6d, 0x92, 0x58, 0xe7, 0x83, 0x57, 0xb5, 0xee, 0xe8, 0xcb}; + uint8_t bytesprops3[] = {0x80, 0x70, 0x52, 0xe7, 0xe1, 0xdd, 0x3e, 0x41, 0xe0}; + uint8_t bytesprops4[] = {0xdd, 0x3e, 0x25, 0x8b, 0x4c, 0xcd, 0x8, 0x8e, 0xc, 0xd7, 0x86, 0x7c, 0xac, + 0x93, 0x2a, 0xe4, 0x8, 0xe5, 0x8c, 0xc2, 0x28, 0xe, 0xe2, 0xba, 0x8}; + uint8_t bytesprops5[] = {0x1, 0x4e, 0x21, 0x9c, 0x4d, 0xbc}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7359}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2955}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24406}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25543}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21136}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21657}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11033}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); @@ -5935,220 +5919,222 @@ TEST(Publish50QCTest, Encode45) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\180=\US\SYN\229\232", _pubPktID = -// 28144, _pubBody = "\SYN\238,\186\225\221v\229\138\172", _pubProps = [PropServerReference -// "\ETB\194\214\169Hf-6U\198\241",PropAuthenticationData "\147\252\ACK\DLE\193\150LS\133\247\159\187",PropResponseTopic -// "{\255\195\STX\152#\182\174\161\186\157\165\SOH\\n\204l\235\235'\144\SYN\251@\166\&5\r5z",PropAuthenticationData -// "\214\135\147e;\152\128\v\139\204\&7h_\190\CAN",PropUserProperty -// "L\213\140\220L\184\129\190\251\205\144\NAK\168\156d" "\224\172",PropMaximumQoS 19,PropAuthenticationMethod -// "\245\130C\228\v\143o\195\184\SYN\FS\131\162\DC4\253(W\149\169",PropAssignedClientIdentifier -// "X\ESC",PropMessageExpiryInterval 4167,PropSessionExpiryInterval 11631,PropCorrelationData -// "\DLE\US\208Q",PropServerKeepAlive 17776,PropAuthenticationMethod "\143g\170\RSu\174\185\238e\\*i",PropReceiveMaximum -// 1155,PropReceiveMaximum 10234]} -TEST(Publish50QCTest, Encode46) { - uint8_t pkt[] = {0x35, 0xc1, 0x1, 0x0, 0x6, 0xb4, 0x3d, 0x1f, 0x16, 0xe5, 0xe8, 0x6d, 0xf0, 0xab, 0x1, 0x1c, 0x0, - 0xb, 0x17, 0xc2, 0xd6, 0xa9, 0x48, 0x66, 0x2d, 0x36, 0x55, 0xc6, 0xf1, 0x16, 0x0, 0xc, 0x93, 0xfc, - 0x6, 0x10, 0xc1, 0x96, 0x4c, 0x53, 0x85, 0xf7, 0x9f, 0xbb, 0x8, 0x0, 0x1d, 0x7b, 0xff, 0xc3, 0x2, - 0x98, 0x23, 0xb6, 0xae, 0xa1, 0xba, 0x9d, 0xa5, 0x1, 0x5c, 0x6e, 0xcc, 0x6c, 0xeb, 0xeb, 0x27, 0x90, - 0x16, 0xfb, 0x40, 0xa6, 0x35, 0xd, 0x35, 0x7a, 0x16, 0x0, 0xf, 0xd6, 0x87, 0x93, 0x65, 0x3b, 0x98, - 0x80, 0xb, 0x8b, 0xcc, 0x37, 0x68, 0x5f, 0xbe, 0x18, 0x26, 0x0, 0xf, 0x4c, 0xd5, 0x8c, 0xdc, 0x4c, - 0xb8, 0x81, 0xbe, 0xfb, 0xcd, 0x90, 0x15, 0xa8, 0x9c, 0x64, 0x0, 0x2, 0xe0, 0xac, 0x24, 0x13, 0x15, - 0x0, 0x13, 0xf5, 0x82, 0x43, 0xe4, 0xb, 0x8f, 0x6f, 0xc3, 0xb8, 0x16, 0x1c, 0x83, 0xa2, 0x14, 0xfd, - 0x28, 0x57, 0x95, 0xa9, 0x12, 0x0, 0x2, 0x58, 0x1b, 0x2, 0x0, 0x0, 0x10, 0x47, 0x11, 0x0, 0x0, - 0x2d, 0x6f, 0x9, 0x0, 0x4, 0x10, 0x1f, 0xd0, 0x51, 0x13, 0x45, 0x70, 0x15, 0x0, 0xc, 0x8f, 0x67, - 0xaa, 0x1e, 0x75, 0xae, 0xb9, 0xee, 0x65, 0x5c, 0x2a, 0x69, 0x21, 0x4, 0x83, 0x21, 0x27, 0xfa, 0x16, - 0xee, 0x2c, 0xba, 0xe1, 0xdd, 0x76, 0xe5, 0x8a, 0xac}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\168\205\235\&9L\b\236\187\184{\199\135G\165c\200\144\SO\NUL\234u\SYN\142O\177N:\161\&8", _pubPktID = 0, _pubBody = +// "Z \DEL\193\197\&7K\147\137\199b]\243}\248\161\248.Y\218bb\132\156\GS\DC2>\224", _pubProps = +// [PropSharedSubscriptionAvailable 130,PropTopicAlias 27548,PropSubscriptionIdentifier 11,PropAssignedClientIdentifier +// "\192#\158\221\154Z\129\236\235",PropServerReference "\216",PropServerKeepAlive 15984]} +TEST(Publish5QCTest, Encode44) { + uint8_t pkt[] = {0x31, 0x56, 0x0, 0x1d, 0xa8, 0xcd, 0xeb, 0x39, 0x4c, 0x8, 0xec, 0xbb, 0xb8, 0x7b, 0xc7, + 0x87, 0x47, 0xa5, 0x63, 0xc8, 0x90, 0xe, 0x0, 0xea, 0x75, 0x16, 0x8e, 0x4f, 0xb1, 0x4e, + 0x3a, 0xa1, 0x38, 0x1a, 0x2a, 0x82, 0x23, 0x6b, 0x9c, 0xb, 0xb, 0x12, 0x0, 0x9, 0xc0, + 0x23, 0x9e, 0xdd, 0x9a, 0x5a, 0x81, 0xec, 0xeb, 0x1c, 0x0, 0x1, 0xd8, 0x13, 0x3e, 0x70, + 0x5a, 0x20, 0x7f, 0xc1, 0xc5, 0x37, 0x4b, 0x93, 0x89, 0xc7, 0x62, 0x5d, 0xf3, 0x7d, 0xf8, + 0xa1, 0xf8, 0x2e, 0x59, 0xda, 0x62, 0x62, 0x84, 0x9c, 0x1d, 0x12, 0x3e, 0xe0}; + + uint8_t buf[98] = {0}; + + uint8_t topic_bytes[] = {0xa8, 0xcd, 0xeb, 0x39, 0x4c, 0x8, 0xec, 0xbb, 0xb8, 0x7b, 0xc7, 0x87, 0x47, 0xa5, 0x63, + 0xc8, 0x90, 0xe, 0x0, 0xea, 0x75, 0x16, 0x8e, 0x4f, 0xb1, 0x4e, 0x3a, 0xa1, 0x38}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x5a, 0x20, 0x7f, 0xc1, 0xc5, 0x37, 0x4b, 0x93, 0x89, 0xc7, 0x62, 0x5d, 0xf3, 0x7d, + 0xf8, 0xa1, 0xf8, 0x2e, 0x59, 0xda, 0x62, 0x62, 0x84, 0x9c, 0x1d, 0x12, 0x3e, 0xe0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 28; - uint8_t buf[206] = {0}; + uint8_t bytesprops0[] = {0xc0, 0x23, 0x9e, 0xdd, 0x9a, 0x5a, 0x81, 0xec, 0xeb}; + uint8_t bytesprops1[] = {0xd8}; - uint8_t topic_bytes[] = {0xb4, 0x3d, 0x1f, 0x16, 0xe5, 0xe8}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27548}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15984}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\165r\DEL\n\202\133kb\136", +// _pubPktID = 7921, _pubBody = "O\248\206?\215\168\&4\DC1\131\187<1\176\200\EOTW \FSu\ETB3\128\222N\241\193\180", +// _pubProps = [PropCorrelationData +// "\230\STX\158\128\DC1\131or\DC3\252\217\177\229\&1\166\252w\EOT*\US",PropServerKeepAlive 21189,PropAuthenticationData +// "H\135\248\221\220@\NUL\229\RS\153\224",PropAuthenticationMethod +// "\135\ESC\251\189<\EM\"(b\158\211\250\ETXX",PropSubscriptionIdentifier 12,PropRetainAvailable +// 59,PropTopicAliasMaximum 27318,PropServerKeepAlive 18157,PropCorrelationData "~\254\CAN\SYN",PropCorrelationData +// "v\137\254\DC2\200a",PropWillDelayInterval 19675,PropResponseInformation +// "P\190\205z'E\151/\229]8,\215\244\&9e}F_",PropWillDelayInterval 4361]} +TEST(Publish5QCTest, Encode45) { + uint8_t pkt[] = {0x3c, 0x9c, 0x1, 0x0, 0x9, 0xa5, 0x72, 0x7f, 0xa, 0xca, 0x85, 0x6b, 0x62, 0x88, 0x1e, 0xf1, + 0x73, 0x9, 0x0, 0x14, 0xe6, 0x2, 0x9e, 0x80, 0x11, 0x83, 0x6f, 0x72, 0x13, 0xfc, 0xd9, 0xb1, + 0xe5, 0x31, 0xa6, 0xfc, 0x77, 0x4, 0x2a, 0x1f, 0x13, 0x52, 0xc5, 0x16, 0x0, 0xb, 0x48, 0x87, + 0xf8, 0xdd, 0xdc, 0x40, 0x0, 0xe5, 0x1e, 0x99, 0xe0, 0x15, 0x0, 0xe, 0x87, 0x1b, 0xfb, 0xbd, + 0x3c, 0x19, 0x22, 0x28, 0x62, 0x9e, 0xd3, 0xfa, 0x3, 0x58, 0xb, 0xc, 0x25, 0x3b, 0x22, 0x6a, + 0xb6, 0x13, 0x46, 0xed, 0x9, 0x0, 0x4, 0x7e, 0xfe, 0x18, 0x16, 0x9, 0x0, 0x6, 0x76, 0x89, + 0xfe, 0x12, 0xc8, 0x61, 0x18, 0x0, 0x0, 0x4c, 0xdb, 0x1a, 0x0, 0x13, 0x50, 0xbe, 0xcd, 0x7a, + 0x27, 0x45, 0x97, 0x2f, 0xe5, 0x5d, 0x38, 0x2c, 0xd7, 0xf4, 0x39, 0x65, 0x7d, 0x46, 0x5f, 0x18, + 0x0, 0x0, 0x11, 0x9, 0x4f, 0xf8, 0xce, 0x3f, 0xd7, 0xa8, 0x34, 0x11, 0x83, 0xbb, 0x3c, 0x31, + 0xb0, 0xc8, 0x4, 0x57, 0x20, 0x1c, 0x75, 0x17, 0x33, 0x80, 0xde, 0x4e, 0xf1, 0xc1, 0xb4}; + + uint8_t buf[169] = {0}; + + uint8_t topic_bytes[] = {0xa5, 0x72, 0x7f, 0xa, 0xca, 0x85, 0x6b, 0x62, 0x88}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x16, 0xee, 0x2c, 0xba, 0xe1, 0xdd, 0x76, 0xe5, 0x8a, 0xac}; + msg.retained = false; + uint8_t msg_bytes[] = {0x4f, 0xf8, 0xce, 0x3f, 0xd7, 0xa8, 0x34, 0x11, 0x83, 0xbb, 0x3c, 0x31, 0xb0, 0xc8, + 0x4, 0x57, 0x20, 0x1c, 0x75, 0x17, 0x33, 0x80, 0xde, 0x4e, 0xf1, 0xc1, 0xb4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + msg.payload_len = 27; - uint8_t bytes0[] = {0x17, 0xc2, 0xd6, 0xa9, 0x48, 0x66, 0x2d, 0x36, 0x55, 0xc6, 0xf1}; - uint8_t bytes1[] = {0x93, 0xfc, 0x6, 0x10, 0xc1, 0x96, 0x4c, 0x53, 0x85, 0xf7, 0x9f, 0xbb}; - uint8_t bytes2[] = {0x7b, 0xff, 0xc3, 0x2, 0x98, 0x23, 0xb6, 0xae, 0xa1, 0xba, 0x9d, 0xa5, 0x1, 0x5c, 0x6e, - 0xcc, 0x6c, 0xeb, 0xeb, 0x27, 0x90, 0x16, 0xfb, 0x40, 0xa6, 0x35, 0xd, 0x35, 0x7a}; - uint8_t bytes3[] = {0xd6, 0x87, 0x93, 0x65, 0x3b, 0x98, 0x80, 0xb, 0x8b, 0xcc, 0x37, 0x68, 0x5f, 0xbe, 0x18}; - uint8_t bytes5[] = {0xe0, 0xac}; - uint8_t bytes4[] = {0x4c, 0xd5, 0x8c, 0xdc, 0x4c, 0xb8, 0x81, 0xbe, 0xfb, 0xcd, 0x90, 0x15, 0xa8, 0x9c, 0x64}; - uint8_t bytes6[] = {0xf5, 0x82, 0x43, 0xe4, 0xb, 0x8f, 0x6f, 0xc3, 0xb8, 0x16, - 0x1c, 0x83, 0xa2, 0x14, 0xfd, 0x28, 0x57, 0x95, 0xa9}; - uint8_t bytes7[] = {0x58, 0x1b}; - uint8_t bytes8[] = {0x10, 0x1f, 0xd0, 0x51}; - uint8_t bytes9[] = {0x8f, 0x67, 0xaa, 0x1e, 0x75, 0xae, 0xb9, 0xee, 0x65, 0x5c, 0x2a, 0x69}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytes4}, .v = {2, (char*)&bytes5}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4167}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11631}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytes8}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17776}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytes9}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1155}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10234}}, + uint8_t bytesprops0[] = {0xe6, 0x2, 0x9e, 0x80, 0x11, 0x83, 0x6f, 0x72, 0x13, 0xfc, + 0xd9, 0xb1, 0xe5, 0x31, 0xa6, 0xfc, 0x77, 0x4, 0x2a, 0x1f}; + uint8_t bytesprops1[] = {0x48, 0x87, 0xf8, 0xdd, 0xdc, 0x40, 0x0, 0xe5, 0x1e, 0x99, 0xe0}; + uint8_t bytesprops2[] = {0x87, 0x1b, 0xfb, 0xbd, 0x3c, 0x19, 0x22, 0x28, 0x62, 0x9e, 0xd3, 0xfa, 0x3, 0x58}; + uint8_t bytesprops3[] = {0x7e, 0xfe, 0x18, 0x16}; + uint8_t bytesprops4[] = {0x76, 0x89, 0xfe, 0x12, 0xc8, 0x61}; + uint8_t bytesprops5[] = {0x50, 0xbe, 0xcd, 0x7a, 0x27, 0x45, 0x97, 0x2f, 0xe5, 0x5d, + 0x38, 0x2c, 0xd7, 0xf4, 0x39, 0x65, 0x7d, 0x46, 0x5f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21189}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27318}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18157}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19675}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4361}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 28144, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7921, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\186\182n\166", _pubPktID = 0, -// _pubBody = "\234+5&F\SYN\140C!\209\ACK\141C\138\180\SOH", _pubProps = [PropTopicAliasMaximum 25404,PropReceiveMaximum -// 6654,PropMaximumQoS 8,PropMaximumQoS 62,PropTopicAliasMaximum 9154,PropResponseInformation -// "f\246\228\213\ENQ\179\DEL^\a\175r\148\154\168\DLE\CAN\170\193\r\254\&5\v\147;",PropMessageExpiryInterval -// 32152,PropPayloadFormatIndicator 23,PropTopicAlias 24375,PropAssignedClientIdentifier -// "\183\220\131\158&\199C\135\SInK_j\211K:F\129\220\229\181\193,\255\246",PropSharedSubscriptionAvailable -// 89,PropServerKeepAlive 9806,PropMaximumQoS 145,PropWillDelayInterval 5362]} -TEST(Publish50QCTest, Encode47) { - uint8_t pkt[] = {0x39, 0x71, 0x0, 0x4, 0xba, 0xb6, 0x6e, 0xa6, 0x5a, 0x22, 0x63, 0x3c, 0x21, 0x19, 0xfe, 0x24, 0x8, - 0x24, 0x3e, 0x22, 0x23, 0xc2, 0x1a, 0x0, 0x18, 0x66, 0xf6, 0xe4, 0xd5, 0x5, 0xb3, 0x7f, 0x5e, 0x7, - 0xaf, 0x72, 0x94, 0x9a, 0xa8, 0x10, 0x18, 0xaa, 0xc1, 0xd, 0xfe, 0x35, 0xb, 0x93, 0x3b, 0x2, 0x0, - 0x0, 0x7d, 0x98, 0x1, 0x17, 0x23, 0x5f, 0x37, 0x12, 0x0, 0x19, 0xb7, 0xdc, 0x83, 0x9e, 0x26, 0xc7, - 0x43, 0x87, 0xf, 0x6e, 0x4b, 0x5f, 0x6a, 0xd3, 0x4b, 0x3a, 0x46, 0x81, 0xdc, 0xe5, 0xb5, 0xc1, 0x2c, - 0xff, 0xf6, 0x2a, 0x59, 0x13, 0x26, 0x4e, 0x24, 0x91, 0x18, 0x0, 0x0, 0x14, 0xf2, 0xea, 0x2b, 0x35, - 0x26, 0x46, 0x16, 0x8c, 0x43, 0x21, 0xd1, 0x6, 0x8d, 0x43, 0x8a, 0xb4, 0x1}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\228\161\&1\220\142H\211q3\179%~Q\148", _pubPktID = 29868, _pubBody = "nP\243G", _pubProps = [PropMaximumQoS +// 80,PropRequestResponseInformation 5,PropTopicAliasMaximum 5247,PropAssignedClientIdentifier +// "?\ESC\SOP\ETB",PropAuthenticationMethod +// "\200F7\169sZ\200\254\158/R\203\134O\206\STX\218\ACK\245",PropSharedSubscriptionAvailable 68,PropRetainAvailable 26]} +TEST(Publish5QCTest, Encode46) { + uint8_t pkt[] = {0x33, 0x40, 0x0, 0xe, 0xe4, 0xa1, 0x31, 0xdc, 0x8e, 0x48, 0xd3, 0x71, 0x33, 0xb3, 0x25, 0x7e, 0x51, + 0x94, 0x74, 0xac, 0x29, 0x24, 0x50, 0x19, 0x5, 0x22, 0x14, 0x7f, 0x12, 0x0, 0x5, 0x3f, 0x1b, 0xe, + 0x50, 0x17, 0x15, 0x0, 0x13, 0xc8, 0x46, 0x37, 0xa9, 0x73, 0x5a, 0xc8, 0xfe, 0x9e, 0x2f, 0x52, 0xcb, + 0x86, 0x4f, 0xce, 0x2, 0xda, 0x6, 0xf5, 0x2a, 0x44, 0x25, 0x1a, 0x6e, 0x50, 0xf3, 0x47}; - uint8_t buf[125] = {0}; + uint8_t buf[76] = {0}; - uint8_t topic_bytes[] = {0xba, 0xb6, 0x6e, 0xa6}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xe4, 0xa1, 0x31, 0xdc, 0x8e, 0x48, 0xd3, 0x71, 0x33, 0xb3, 0x25, 0x7e, 0x51, 0x94}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xea, 0x2b, 0x35, 0x26, 0x46, 0x16, 0x8c, 0x43, 0x21, 0xd1, 0x6, 0x8d, 0x43, 0x8a, 0xb4, 0x1}; + uint8_t msg_bytes[] = {0x6e, 0x50, 0xf3, 0x47}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; - - uint8_t bytes0[] = {0x66, 0xf6, 0xe4, 0xd5, 0x5, 0xb3, 0x7f, 0x5e, 0x7, 0xaf, 0x72, 0x94, - 0x9a, 0xa8, 0x10, 0x18, 0xaa, 0xc1, 0xd, 0xfe, 0x35, 0xb, 0x93, 0x3b}; - uint8_t bytes1[] = {0xb7, 0xdc, 0x83, 0x9e, 0x26, 0xc7, 0x43, 0x87, 0xf, 0x6e, 0x4b, 0x5f, 0x6a, - 0xd3, 0x4b, 0x3a, 0x46, 0x81, 0xdc, 0xe5, 0xb5, 0xc1, 0x2c, 0xff, 0xf6}; + msg.payload_len = 4; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25404}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6654}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9154}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32152}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24375}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9806}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5362}}, + uint8_t bytesprops0[] = {0x3f, 0x1b, 0xe, 0x50, 0x17}; + uint8_t bytesprops1[] = {0xc8, 0x46, 0x37, 0xa9, 0x73, 0x5a, 0xc8, 0xfe, 0x9e, 0x2f, + 0x52, 0xcb, 0x86, 0x4f, 0xce, 0x2, 0xda, 0x6, 0xf5}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5247}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29868, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "3", _pubPktID = 0, _pubBody = -// "\DLE5\164cC\229MU\SYN0\131\230UV\187\196 1\210[2\232", _pubProps = [PropReceiveMaximum 11051,PropResponseInformation -// "\237\DC1\140F\SO\185\201\227\173.\211\163\133_~\170e\216\SOS\195\220oN\183\SOH/N\207",PropWildcardSubscriptionAvailable -// 149,PropServerReference "\150\193",PropMessageExpiryInterval 9974,PropWillDelayInterval 9412,PropResponseTopic -// "\171\149)g\242\ENQ\253f",PropAuthenticationData -// "u?\194aH/\233'\182\151\210\150\194c0\201\249\220\EM\163:d\132\140\135\233\179V\DC1\EOT",PropMessageExpiryInterval -// 11961,PropMessageExpiryInterval 11754,PropMaximumPacketSize 9547,PropServerReference -// "\161\234\240j",PropWillDelayInterval -// 18837,PropMaximumPacketSize 6933,PropWillDelayInterval 1171,PropRequestProblemInformation 103,PropTopicAliasMaximum -// 27814,PropPayloadFormatIndicator 5,PropRequestResponseInformation 211,PropCorrelationData "\129\&6:\159OC\247"]} -TEST(Publish50QCTest, Encode49) { - uint8_t pkt[] = {0x31, 0x71, 0x0, 0xb, 0x93, 0x1a, 0x0, 0xd7, 0x31, 0x99, 0xca, 0x26, 0x37, 0x39, 0xd, 0x4b, 0x1, - 0x3b, 0x17, 0x9c, 0x28, 0x9b, 0x11, 0x0, 0x0, 0x2c, 0xaa, 0x27, 0x0, 0x0, 0x26, 0x99, 0x8, 0x0, - 0x11, 0xd0, 0x9e, 0xf6, 0x7b, 0x3f, 0xfe, 0x47, 0xa0, 0x7d, 0x86, 0x96, 0x35, 0x9f, 0x9e, 0xdb, 0x98, - 0xc9, 0x1c, 0x0, 0x2, 0x3e, 0x6a, 0x18, 0x0, 0x0, 0x49, 0x95, 0x27, 0x0, 0x0, 0x1b, 0x15, 0x18, - 0x0, 0x0, 0x4, 0x93, 0x17, 0x67, 0x22, 0x6c, 0xa6, 0x1, 0x5, 0x19, 0xd3, 0x9, 0x0, 0x7, 0x81, - 0x36, 0x3a, 0x9f, 0x4f, 0x43, 0xf7, 0x63, 0xd9, 0xca, 0xc1, 0x9c, 0xc7, 0xca, 0xde, 0xe, 0x8f, 0x91, - 0xca, 0x87, 0x88, 0xef, 0x93, 0x5a, 0xc5, 0xf5, 0xc4, 0x85, 0xf9, 0xbf, 0x41}; - - uint8_t buf[125] = {0}; - - uint8_t topic_bytes[] = {0x93, 0x1a, 0x0, 0xd7, 0x31, 0x99, 0xca, 0x26, 0x37, 0x39, 0xd}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "'\245\224\138\229\155\&6\241\GS\"t\ETX5%4?\146\ETB", _pubPktID = 0, _pubBody = "\SUB)\222", _pubProps = +// [PropWildcardSubscriptionAvailable 255,PropSessionExpiryInterval 647,PropRequestResponseInformation +// 228,PropTopicAliasMaximum 30065,PropAssignedClientIdentifier +// "\250_\139\fO\183\233\217\212\218~\194,p\159\&5\226\198\145\DC1\131]",PropWillDelayInterval 18202,PropMaximumQoS +// 132,PropUserProperty "\197WY\US\250\217\138\GSy\ACKa@\240R\RS\ETX\182\195t\175G\161\GS\151\r\185\151\216\247" +// "&tr\176\249\201\233\RS\DLE\209\239\194*\148",PropAuthenticationMethod "\161",PropReceiveMaximum +// 12170,PropAssignedClientIdentifier "H\168\154\242j{\n\128{\"v",PropTopicAliasMaximum 18145,PropResponseTopic +// "\148\129q\206\189\205\191\254\150.\247\STX\142\151\162d>\141\228\SOH\181\"\178\ACK\248\136E\181\US",PropServerKeepAlive +// 29047,PropServerKeepAlive 21427,PropContentType "\246\\\183\&6gu\251\ETBq\151\165[c",PropSubscriptionIdentifier +// 23,PropTopicAliasMaximum 24626,PropPayloadFormatIndicator 144,PropResponseInformation +// "\DC1\143/\171\ETB\202\r+\238\254#\206G\138\139\231h\177\210aB*\210m\252\239\236\152",PropRequestProblemInformation +// 26,PropAssignedClientIdentifier "\237\171\195\186\160H\223\131\128a:",PropAuthenticationData +// "\ESC\178\249\EOT\201\224\234C?\ESC\139\147k\174\158\STX\SUB6\193",PropPayloadFormatIndicator +// 18,PropSharedSubscriptionAvailable 65]} +TEST(Publish5QCTest, Encode48) { + uint8_t pkt[] = { + 0x39, 0x93, 0x2, 0x0, 0x12, 0x27, 0xf5, 0xe0, 0x8a, 0xe5, 0x9b, 0x36, 0xf1, 0x1d, 0x22, 0x74, 0x3, 0x35, 0x25, + 0x34, 0x3f, 0x92, 0x17, 0xfa, 0x1, 0x28, 0xff, 0x11, 0x0, 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23, 0xce, 0x47, 0x8a, 0x8b, 0xe7, 0x68, 0xb1, 0xd2, 0x61, 0x42, 0x2a, 0xd2, + 0x6d, 0xfc, 0xef, 0xec, 0x98, 0x17, 0x1a, 0x12, 0x0, 0xb, 0xed, 0xab, 0xc3, 0xba, 0xa0, 0x48, 0xdf, 0x83, 0x80, + 0x61, 0x3a, 0x16, 0x0, 0x13, 0x1b, 0xb2, 0xf9, 0x4, 0xc9, 0xe0, 0xea, 0x43, 0x3f, 0x1b, 0x8b, 0x93, 0x6b, 0xae, + 0x9e, 0x2, 0x1a, 0x36, 0xc1, 0x1, 0x12, 0x2a, 0x41, 0x1a, 0x29, 0xde}; + + uint8_t buf[288] = {0}; + + uint8_t topic_bytes[] = {0x27, 0xf5, 0xe0, 0x8a, 0xe5, 0x9b, 0x36, 0xf1, 0x1d, + 0x22, 0x74, 0x3, 0x35, 0x25, 0x34, 0x3f, 0x92, 0x17}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x63, 0xd9, 0xca, 0xc1, 0x9c, 0xc7, 0xca, 0xde, 0xe, 0x8f, 0x91, 0xca, - 0x87, 0x88, 0xef, 0x93, 0x5a, 0xc5, 0xf5, 0xc4, 0x85, 0xf9, 0xbf, 0x41}; + uint8_t msg_bytes[] = {0x1a, 0x29, 0xde}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; - - uint8_t bytes0[] = {0xd0, 0x9e, 0xf6, 0x7b, 0x3f, 0xfe, 0x47, 0xa0, 0x7d, - 0x86, 0x96, 0x35, 0x9f, 0x9e, 0xdb, 0x98, 0xc9}; - uint8_t bytes1[] = {0x3e, 0x6a}; - uint8_t bytes2[] = {0x81, 0x36, 0x3a, 0x9f, 0x4f, 0x43, 0xf7}; + msg.payload_len = 3; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11434}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9881}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18837}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6933}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1171}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27814}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytes2}}}, + uint8_t bytesprops0[] = {0xfa, 0x5f, 0x8b, 0xc, 0x4f, 0xb7, 0xe9, 0xd9, 0xd4, 0xda, 0x7e, + 0xc2, 0x2c, 0x70, 0x9f, 0x35, 0xe2, 0xc6, 0x91, 0x11, 0x83, 0x5d}; + uint8_t bytesprops2[] = {0x26, 0x74, 0x72, 0xb0, 0xf9, 0xc9, 0xe9, 0x1e, 0x10, 0xd1, 0xef, 0xc2, 0x2a, 0x94}; + uint8_t bytesprops1[] = {0xc5, 0x57, 0x59, 0x1f, 0xfa, 0xd9, 0x8a, 0x1d, 0x79, 0x6, 0x61, 0x40, 0xf0, 0x52, 0x1e, + 0x3, 0xb6, 0xc3, 0x74, 0xaf, 0x47, 0xa1, 0x1d, 0x97, 0xd, 0xb9, 0x97, 0xd8, 0xf7}; + uint8_t bytesprops3[] = {0xa1}; + uint8_t bytesprops4[] = {0x48, 0xa8, 0x9a, 0xf2, 0x6a, 0x7b, 0xa, 0x80, 0x7b, 0x22, 0x76}; + uint8_t bytesprops5[] = {0x94, 0x81, 0x71, 0xce, 0xbd, 0xcd, 0xbf, 0xfe, 0x96, 0x2e, 0xf7, 0x2, 0x8e, 0x97, 0xa2, + 0x64, 0x3e, 0x8d, 0xe4, 0x1, 0xb5, 0x22, 0xb2, 0x6, 0xf8, 0x88, 0x45, 0xb5, 0x1f}; + uint8_t bytesprops6[] = {0xf6, 0x5c, 0xb7, 0x36, 0x67, 0x75, 0xfb, 0x17, 0x71, 0x97, 0xa5, 0x5b, 0x63}; + uint8_t bytesprops7[] = {0x11, 0x8f, 0x2f, 0xab, 0x17, 0xca, 0xd, 0x2b, 0xee, 0xfe, 0x23, 0xce, 0x47, 0x8a, + 0x8b, 0xe7, 0x68, 0xb1, 0xd2, 0x61, 0x42, 0x2a, 0xd2, 0x6d, 0xfc, 0xef, 0xec, 0x98}; + uint8_t bytesprops8[] = {0xed, 0xab, 0xc3, 0xba, 0xa0, 0x48, 0xdf, 0x83, 0x80, 0x61, 0x3a}; + uint8_t bytesprops9[] = {0x1b, 0xb2, 0xf9, 0x4, 0xc9, 0xe0, 0xea, 0x43, 0x3f, 0x1b, + 0x8b, 0x93, 0x6b, 0xae, 0x9e, 0x2, 0x1a, 0x36, 0xc1}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 647}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30065}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18202}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {14, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12170}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18145}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29047}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21427}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24626}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 65}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\199\220\252\SI\147K\173", _pubPktID -// = 22359, _pubBody = "\179\135\192#+E7,\SO&0\CAN\239\145\190\193\159\161\ETX\v\205~yy\158v\209Tt\143", _pubProps = -// [PropSharedSubscriptionAvailable 148,PropAuthenticationData "",PropRequestProblemInformation -// 0,PropMessageExpiryInterval 7957,PropAuthenticationData -// "\146p\161Z\171\190\138j\133\135G\205\t\248\243\204\ETB\228\171\US\150\188\223\&4\f_\ESC",PropReceiveMaximum -// 26413,PropMaximumPacketSize 19648,PropCorrelationData "\219>\138\164.\130",PropSubscriptionIdentifierAvailable -// 113,PropPayloadFormatIndicator 27,PropReasonString "w\233j\150#\243\USpoz\183",PropSubscriptionIdentifier -// 27,PropSubscriptionIdentifier 3]} -TEST(Publish50QCTest, Encode50) { - uint8_t pkt[] = {0x35, 0x7b, 0x0, 0x7, 0xc7, 0xdc, 0xfc, 0xf, 0x93, 0x4b, 0xad, 0x57, 0x57, 0x51, 0x2a, 0x94, - 0x16, 0x0, 0x0, 0x17, 0x0, 0x2, 0x0, 0x0, 0x1f, 0x15, 0x16, 0x0, 0x1b, 0x92, 0x70, 0xa1, - 0x5a, 0xab, 0xbe, 0x8a, 0x6a, 0x85, 0x87, 0x47, 0xcd, 0x9, 0xf8, 0xf3, 0xcc, 0x17, 0xe4, 0xab, - 0x1f, 0x96, 0xbc, 0xdf, 0x34, 0xc, 0x5f, 0x1b, 0x21, 0x67, 0x2d, 0x27, 0x0, 0x0, 0x4c, 0xc0, - 0x9, 0x0, 0x6, 0xdb, 0x3e, 0x8a, 0xa4, 0x2e, 0x82, 0x29, 0x71, 0x1, 0x1b, 0x1f, 0x0, 0xb, - 0x77, 0xe9, 0x6a, 0x96, 0x23, 0xf3, 0x1f, 0x70, 0x6f, 0x7a, 0xb7, 0xb, 0x1b, 0xb, 0x3, 0xb3, - 0x87, 0xc0, 0x23, 0x2b, 0x45, 0x37, 0x2c, 0xe, 0x26, 0x30, 0x18, 0xef, 0x91, 0xbe, 0xc1, 0x9f, - 0xa1, 0x3, 0xb, 0xcd, 0x7e, 0x79, 0x79, 0x9e, 0x76, 0xd1, 0x54, 0x74, 0x8f}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\200Z\225i^_\STX\231\193\STX", +// _pubPktID = 16826, _pubBody = "\206\193\194\217\177\152\142,\163\145\149Q\237?7\131k\n\177[^\153ti\134sYl\140\174", +// _pubProps = [PropMaximumQoS 178,PropAuthenticationMethod "",PropSessionExpiryInterval 27303,PropMessageExpiryInterval +// 30007,PropWillDelayInterval 3447,PropMaximumQoS 79,PropCorrelationData "\228\150"]} +TEST(Publish5QCTest, Encode49) { + uint8_t pkt[] = {0x3d, 0x48, 0x0, 0xa, 0xc8, 0x5a, 0xe1, 0x69, 0x5e, 0x5f, 0x2, 0xe7, 0xc1, 0x2, 0x41, + 0xba, 0x1b, 0x24, 0xb2, 0x15, 0x0, 0x0, 0x11, 0x0, 0x0, 0x6a, 0xa7, 0x2, 0x0, 0x0, + 0x75, 0x37, 0x18, 0x0, 0x0, 0xd, 0x77, 0x24, 0x4f, 0x9, 0x0, 0x2, 0xe4, 0x96, 0xce, + 0xc1, 0xc2, 0xd9, 0xb1, 0x98, 0x8e, 0x2c, 0xa3, 0x91, 0x95, 0x51, 0xed, 0x3f, 0x37, 0x83, + 0x6b, 0xa, 0xb1, 0x5b, 0x5e, 0x99, 0x74, 0x69, 0x86, 0x73, 0x59, 0x6c, 0x8c, 0xae}; - uint8_t buf[135] = {0}; + uint8_t buf[84] = {0}; - uint8_t topic_bytes[] = {0xc7, 0xdc, 0xfc, 0xf, 0x93, 0x4b, 0xad}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xc8, 0x5a, 0xe1, 0x69, 0x5e, 0x5f, 0x2, 0xe7, 0xc1, 0x2}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0xb3, 0x87, 0xc0, 0x23, 0x2b, 0x45, 0x37, 0x2c, 0xe, 0x26, 0x30, 0x18, 0xef, 0x91, 0xbe, - 0xc1, 0x9f, 0xa1, 0x3, 0xb, 0xcd, 0x7e, 0x79, 0x79, 0x9e, 0x76, 0xd1, 0x54, 0x74, 0x8f}; + uint8_t msg_bytes[] = {0xce, 0xc1, 0xc2, 0xd9, 0xb1, 0x98, 0x8e, 0x2c, 0xa3, 0x91, 0x95, 0x51, 0xed, 0x3f, 0x37, + 0x83, 0x6b, 0xa, 0xb1, 0x5b, 0x5e, 0x99, 0x74, 0x69, 0x86, 0x73, 0x59, 0x6c, 0x8c, 0xae}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 30; - uint8_t bytes0[] = {0}; - uint8_t bytes1[] = {0x92, 0x70, 0xa1, 0x5a, 0xab, 0xbe, 0x8a, 0x6a, 0x85, 0x87, 0x47, 0xcd, 0x9, 0xf8, - 0xf3, 0xcc, 0x17, 0xe4, 0xab, 0x1f, 0x96, 0xbc, 0xdf, 0x34, 0xc, 0x5f, 0x1b}; - uint8_t bytes2[] = {0xdb, 0x3e, 0x8a, 0xa4, 0x2e, 0x82}; - uint8_t bytes3[] = {0x77, 0xe9, 0x6a, 0x96, 0x23, 0xf3, 0x1f, 0x70, 0x6f, 0x7a, 0xb7}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xe4, 0x96}; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7957}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26413}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19648}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27303}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30007}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3447}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 22359, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16826, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\225Uc\EM\147>\149\248\SI9\ENQs\211]\179", _pubPktID = 25366, _pubBody = "\165c\155\220\241\175\249\EM\220Bi\224\t", -// _pubProps = [PropMaximumQoS 251,PropSubscriptionIdentifier 23,PropPayloadFormatIndicator 215,PropAuthenticationMethod -// "B1\DC41\FS&,Tt\255\134\153>D\195@",PropMaximumPacketSize 24117,PropRequestProblemInformation -// 232,PropRequestProblemInformation 103,PropRetainAvailable 52,PropMaximumQoS 28,PropSharedSubscriptionAvailable -// 192,PropSubscriptionIdentifierAvailable 18,PropSessionExpiryInterval 4955,PropContentType -// "\187\208",PropResponseInformation "\FS\176\183G\252\230\n\141P\184>\DEL&\190",PropMaximumQoS 222,PropContentType -// "\212\r\243\182\226(\"\232\t\226\168\166\132\\\DC3s\242OY\175\207\195\234\188\163",PropResponseInformation -// "\197\197\&8\161\152\243\146\&4\t\164\237"]} -TEST(Publish50QCTest, Encode51) { - uint8_t pkt[] = {0x32, 0x92, 0x1, 0x0, 0xf, 0xe1, 0x55, 0x63, 0x19, 0x93, 0x3e, 0x95, 0xf8, 0xf, 0x39, 0x5, 0x73, - 0xd3, 0x5d, 0xb3, 0x63, 0x16, 0x71, 0x24, 0xfb, 0xb, 0x17, 0x1, 0xd7, 0x15, 0x0, 0x10, 0x42, 0x31, - 0x14, 0x31, 0x1c, 0x26, 0x2c, 0x54, 0x74, 0xff, 0x86, 0x99, 0x3e, 0x44, 0xc3, 0x40, 0x27, 0x0, 0x0, - 0x5e, 0x35, 0x17, 0xe8, 0x17, 0x67, 0x25, 0x34, 0x24, 0x1c, 0x2a, 0xc0, 0x29, 0x12, 0x11, 0x0, 0x0, - 0x13, 0x5b, 0x3, 0x0, 0x2, 0xbb, 0xd0, 0x1a, 0x0, 0xe, 0x1c, 0xb0, 0xb7, 0x47, 0xfc, 0xe6, 0xa, - 0x8d, 0x50, 0xb8, 0x3e, 0x7f, 0x26, 0xbe, 0x24, 0xde, 0x3, 0x0, 0x19, 0xd4, 0xd, 0xf3, 0xb6, 0xe2, - 0x28, 0x22, 0xe8, 0x9, 0xe2, 0xa8, 0xa6, 0x84, 0x5c, 0x13, 0x73, 0xf2, 0x4f, 0x59, 0xaf, 0xcf, 0xc3, - 0xea, 0xbc, 0xa3, 0x1a, 0x0, 0xb, 0xc5, 0xc5, 0x38, 0xa1, 0x98, 0xf3, 0x92, 0x34, 0x9, 0xa4, 0xed, - 0xa5, 0x63, 0x9b, 0xdc, 0xf1, 0xaf, 0xf9, 0x19, 0xdc, 0x42, 0x69, 0xe0, 0x9}; - - uint8_t buf[159] = {0}; - - uint8_t topic_bytes[] = {0xe1, 0x55, 0x63, 0x19, 0x93, 0x3e, 0x95, 0xf8, 0xf, 0x39, 0x5, 0x73, 0xd3, 0x5d, 0xb3}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\161\178\167\170\164+\151g\137\n", +// _pubPktID = 11219, _pubBody = "R\146a\229\236\247\197\178\199\136\159_\251", _pubProps = [PropWillDelayInterval +// 18228,PropServerReference "\RS\193\246;\172",PropRequestProblemInformation 24,PropTopicAliasMaximum +// 9254,PropSharedSubscriptionAvailable 218,PropUserProperty +// "r\SYN\215\149,\139\187r\155c\FS\144E\241\201\143\180\DC4J\211v\223L\198\DLE" +// "\244\&3\218\205\193M\209\STX\203\ETX>!e\148\212\165QY'\162)\160\141\178\204\186",PropMaximumQoS +// 37,PropSubscriptionIdentifierAvailable 146,PropSharedSubscriptionAvailable 166,PropSubscriptionIdentifierAvailable +// 56,PropPayloadFormatIndicator 133,PropPayloadFormatIndicator 41,PropMaximumQoS 35,PropSessionExpiryInterval +// 20605,PropAssignedClientIdentifier +// "\206|\235a\173\199\152\211\169\DC3\208(*\164\197\ETX\154s\217\232@PP\247",PropTopicAlias +// 28005,PropRequestProblemInformation 192,PropSubscriptionIdentifierAvailable 108,PropSessionExpiryInterval +// 24769,PropRequestResponseInformation 91,PropSubscriptionIdentifierAvailable 67,PropServerReference +// "\193",PropPayloadFormatIndicator 5,PropWillDelayInterval 20234,PropTopicAliasMaximum +// 21992,PropSubscriptionIdentifier 24,PropContentType "\131#\246#\254]\246\246",PropMessageExpiryInterval 19685]} +TEST(Publish5QCTest, Encode50) { + uint8_t pkt[] = {0x3b, 0xc7, 0x1, 0x0, 0xa, 0xa1, 0xb2, 0xa7, 0xaa, 0xa4, 0x2b, 0x97, 0x67, 0x89, 0xa, 0x2b, 0xd3, + 0xaa, 0x1, 0x18, 0x0, 0x0, 0x47, 0x34, 0x1c, 0x0, 0x5, 0x1e, 0xc1, 0xf6, 0x3b, 0xac, 0x17, 0x18, + 0x22, 0x24, 0x26, 0x2a, 0xda, 0x26, 0x0, 0x19, 0x72, 0x16, 0xd7, 0x95, 0x2c, 0x8b, 0xbb, 0x72, 0x9b, + 0x63, 0x1c, 0x90, 0x45, 0xf1, 0xc9, 0x8f, 0xb4, 0x14, 0x4a, 0xd3, 0x76, 0xdf, 0x4c, 0xc6, 0x10, 0x0, + 0x1a, 0xf4, 0x33, 0xda, 0xcd, 0xc1, 0x4d, 0xd1, 0x2, 0xcb, 0x3, 0x3e, 0x21, 0x65, 0x94, 0xd4, 0xa5, + 0x51, 0x59, 0x27, 0xa2, 0x29, 0xa0, 0x8d, 0xb2, 0xcc, 0xba, 0x24, 0x25, 0x29, 0x92, 0x2a, 0xa6, 0x29, + 0x38, 0x1, 0x85, 0x1, 0x29, 0x24, 0x23, 0x11, 0x0, 0x0, 0x50, 0x7d, 0x12, 0x0, 0x18, 0xce, 0x7c, + 0xeb, 0x61, 0xad, 0xc7, 0x98, 0xd3, 0xa9, 0x13, 0xd0, 0x28, 0x2a, 0xa4, 0xc5, 0x3, 0x9a, 0x73, 0xd9, + 0xe8, 0x40, 0x50, 0x50, 0xf7, 0x23, 0x6d, 0x65, 0x17, 0xc0, 0x29, 0x6c, 0x11, 0x0, 0x0, 0x60, 0xc1, + 0x19, 0x5b, 0x29, 0x43, 0x1c, 0x0, 0x1, 0xc1, 0x1, 0x5, 0x18, 0x0, 0x0, 0x4f, 0xa, 0x22, 0x55, + 0xe8, 0xb, 0x18, 0x3, 0x0, 0x8, 0x83, 0x23, 0xf6, 0x23, 0xfe, 0x5d, 0xf6, 0xf6, 0x2, 0x0, 0x0, + 0x4c, 0xe5, 0x52, 0x92, 0x61, 0xe5, 0xec, 0xf7, 0xc5, 0xb2, 0xc7, 0x88, 0x9f, 0x5f, 0xfb}; + + uint8_t buf[212] = {0}; + + uint8_t topic_bytes[] = {0xa1, 0xb2, 0xa7, 0xaa, 0xa4, 0x2b, 0x97, 0x67, 0x89, 0xa}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xa5, 0x63, 0x9b, 0xdc, 0xf1, 0xaf, 0xf9, 0x19, 0xdc, 0x42, 0x69, 0xe0, 0x9}; + msg.retained = true; + uint8_t msg_bytes[] = {0x52, 0x92, 0x61, 0xe5, 0xec, 0xf7, 0xc5, 0xb2, 0xc7, 0x88, 0x9f, 0x5f, 0xfb}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 13; - uint8_t bytes0[] = {0x42, 0x31, 0x14, 0x31, 0x1c, 0x26, 0x2c, 0x54, 0x74, 0xff, 0x86, 0x99, 0x3e, 0x44, 0xc3, 0x40}; - uint8_t bytes1[] = {0xbb, 0xd0}; - uint8_t bytes2[] = {0x1c, 0xb0, 0xb7, 0x47, 0xfc, 0xe6, 0xa, 0x8d, 0x50, 0xb8, 0x3e, 0x7f, 0x26, 0xbe}; - uint8_t bytes3[] = {0xd4, 0xd, 0xf3, 0xb6, 0xe2, 0x28, 0x22, 0xe8, 0x9, 0xe2, 0xa8, 0xa6, 0x84, - 0x5c, 0x13, 0x73, 0xf2, 0x4f, 0x59, 0xaf, 0xcf, 0xc3, 0xea, 0xbc, 0xa3}; - uint8_t bytes4[] = {0xc5, 0xc5, 0x38, 0xa1, 0x98, 0xf3, 0x92, 0x34, 0x9, 0xa4, 0xed}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24117}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4955}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytes4}}}, + uint8_t bytesprops0[] = {0x1e, 0xc1, 0xf6, 0x3b, 0xac}; + uint8_t bytesprops2[] = {0xf4, 0x33, 0xda, 0xcd, 0xc1, 0x4d, 0xd1, 0x2, 0xcb, 0x3, 0x3e, 0x21, 0x65, + 0x94, 0xd4, 0xa5, 0x51, 0x59, 0x27, 0xa2, 0x29, 0xa0, 0x8d, 0xb2, 0xcc, 0xba}; + uint8_t bytesprops1[] = {0x72, 0x16, 0xd7, 0x95, 0x2c, 0x8b, 0xbb, 0x72, 0x9b, 0x63, 0x1c, 0x90, 0x45, + 0xf1, 0xc9, 0x8f, 0xb4, 0x14, 0x4a, 0xd3, 0x76, 0xdf, 0x4c, 0xc6, 0x10}; + uint8_t bytesprops3[] = {0xce, 0x7c, 0xeb, 0x61, 0xad, 0xc7, 0x98, 0xd3, 0xa9, 0x13, 0xd0, 0x28, + 0x2a, 0xa4, 0xc5, 0x3, 0x9a, 0x73, 0xd9, 0xe8, 0x40, 0x50, 0x50, 0xf7}; + uint8_t bytesprops4[] = {0xc1}; + uint8_t bytesprops5[] = {0x83, 0x23, 0xf6, 0x23, 0xfe, 0x5d, 0xf6, 0xf6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18228}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9254}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops1}, .v = {26, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20605}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28005}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24769}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20234}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21992}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19685}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 25366, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 11219, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "sS\f@K\\`9t", _pubPktID = 0, -// _pubBody = "9?\202\215M\ENQvqz\243\164Lg", _pubProps = [PropAssignedClientIdentifier -// "\179\&2\149\157\157\190gRR\140K\EOT\\\161\t\DC2\202`\DEL\200\240\\\a",PropMessageExpiryInterval -// 11207,PropServerReference "\185b+\252\250c\238\250\NAK\193\162Q\252\174\153\203",PropRetainAvailable -// 30,PropTopicAlias 23226,PropContentType "\v\132",PropResponseTopic -// "]U\132\DLE6\131mu\165\ACK\177\254qA?Y!%",PropReceiveMaximum 29851,PropWildcardSubscriptionAvailable -// 64,PropPayloadFormatIndicator 193,PropRetainAvailable 96]} -TEST(Publish50QCTest, Encode52) { - uint8_t pkt[] = {0x30, 0x73, 0x0, 0x9, 0x73, 0x53, 0xc, 0x40, 0x4b, 0x5c, 0x60, 0x39, 0x74, 0x5a, 0x12, 0x0, 0x17, - 0xb3, 0x32, 0x95, 0x9d, 0x9d, 0xbe, 0x67, 0x52, 0x52, 0x8c, 0x4b, 0x4, 0x5c, 0xa1, 0x9, 0x12, 0xca, - 0x60, 0x7f, 0xc8, 0xf0, 0x5c, 0x7, 0x2, 0x0, 0x0, 0x2b, 0xc7, 0x1c, 0x0, 0x10, 0xb9, 0x62, 0x2b, - 0xfc, 0xfa, 0x63, 0xee, 0xfa, 0x15, 0xc1, 0xa2, 0x51, 0xfc, 0xae, 0x99, 0xcb, 0x25, 0x1e, 0x23, 0x5a, - 0xba, 0x3, 0x0, 0x2, 0xb, 0x84, 0x8, 0x0, 0x12, 0x5d, 0x55, 0x84, 0x10, 0x36, 0x83, 0x6d, 0x75, - 0xa5, 0x6, 0xb1, 0xfe, 0x71, 0x41, 0x3f, 0x59, 0x21, 0x25, 0x21, 0x74, 0x9b, 0x28, 0x40, 0x1, 0xc1, - 0x25, 0x60, 0x39, 0x3f, 0xca, 0xd7, 0x4d, 0x5, 0x76, 0x71, 0x7a, 0xf3, 0xa4, 0x4c, 0x67}; - - uint8_t buf[127] = {0}; - - uint8_t topic_bytes[] = {0x73, 0x53, 0xc, 0x40, 0x4b, 0x5c, 0x60, 0x39, 0x74}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "R\\\164\224\200+\254\\\233t@\GS\144\&5|\243\244@%\240\170\193\150V\252\133q", _pubPktID = 23768, _pubBody = +// "\RS.\158\236\175|6'\152C\151\NUL\138o\230\242\236\184,\ENQ\201^\185\t", _pubProps = [PropSubscriptionIdentifier +// 13,PropUserProperty "\160!\152E\225\161\241#\ETXS\211\SYN\SYN\206\128\130\207$o" +// "Shx\SI\ETBGtG\164\FS\206\175o\231\&1",PropAuthenticationMethod +// "\143\ETB\235^\196\180\226\235\226\246\&3\226D6\bV*1\163P\211\233#53FFZ",PropUserProperty "?|\177\NAK\169{sj" +// "J\224n\163\190uG\169`\f)\228c_b",PropContentType +// "h\176p\SUB\181)\215\192P\239\228\v^ijNZ(rw\GS",PropTopicAliasMaximum 26777,PropResponseInformation +// "\DLEq\200\174\&9z\181X\172\254i\SUBs\207\145\208\217\135\233\SYN]"]} +TEST(Publish5QCTest, Encode51) { + uint8_t pkt[] = {0x3c, 0xd0, 0x1, 0x0, 0x1b, 0x52, 0x5c, 0xa4, 0xe0, 0xc8, 0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x43, 0x97, 0x0, 0x8a, 0x6f, 0xe6, 0xf2, 0xec, + 0xb8, 0x2c, 0x5, 0xc9, 0x5e, 0xb9, 0x9}; + + uint8_t buf[221] = {0}; + + uint8_t topic_bytes[] = {0x52, 0x5c, 0xa4, 0xe0, 0xc8, 0x2b, 0xfe, 0x5c, 0xe9, 0x74, 0x40, 0x1d, 0x90, 0x35, + 0x7c, 0xf3, 0xf4, 0x40, 0x25, 0xf0, 0xaa, 0xc1, 0x96, 0x56, 0xfc, 0x85, 0x71}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x39, 0x3f, 0xca, 0xd7, 0x4d, 0x5, 0x76, 0x71, 0x7a, 0xf3, 0xa4, 0x4c, 0x67}; + uint8_t msg_bytes[] = {0x1e, 0x2e, 0x9e, 0xec, 0xaf, 0x7c, 0x36, 0x27, 0x98, 0x43, 0x97, 0x0, + 0x8a, 0x6f, 0xe6, 0xf2, 0xec, 0xb8, 0x2c, 0x5, 0xc9, 0x5e, 0xb9, 0x9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 24; - uint8_t bytes0[] = {0xb3, 0x32, 0x95, 0x9d, 0x9d, 0xbe, 0x67, 0x52, 0x52, 0x8c, 0x4b, 0x4, - 0x5c, 0xa1, 0x9, 0x12, 0xca, 0x60, 0x7f, 0xc8, 0xf0, 0x5c, 0x7}; - uint8_t bytes1[] = {0xb9, 0x62, 0x2b, 0xfc, 0xfa, 0x63, 0xee, 0xfa, 0x15, 0xc1, 0xa2, 0x51, 0xfc, 0xae, 0x99, 0xcb}; - uint8_t bytes2[] = {0xb, 0x84}; - uint8_t bytes3[] = {0x5d, 0x55, 0x84, 0x10, 0x36, 0x83, 0x6d, 0x75, 0xa5, - 0x6, 0xb1, 0xfe, 0x71, 0x41, 0x3f, 0x59, 0x21, 0x25}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11207}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23226}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29851}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 96}}, + uint8_t bytesprops1[] = {0x53, 0x68, 0x78, 0xf, 0x17, 0x47, 0x74, 0x47, 0xa4, 0x1c, 0xce, 0xaf, 0x6f, 0xe7, 0x31}; + uint8_t bytesprops0[] = {0xa0, 0x21, 0x98, 0x45, 0xe1, 0xa1, 0xf1, 0x23, 0x3, 0x53, + 0xd3, 0x16, 0x16, 0xce, 0x80, 0x82, 0xcf, 0x24, 0x6f}; + uint8_t bytesprops2[] = {0x8f, 0x17, 0xeb, 0x5e, 0xc4, 0xb4, 0xe2, 0xeb, 0xe2, 0xf6, 0x33, 0xe2, 0x44, 0x36, + 0x8, 0x56, 0x2a, 0x31, 0xa3, 0x50, 0xd3, 0xe9, 0x23, 0x35, 0x33, 0x46, 0x46, 0x5a}; + uint8_t bytesprops4[] = {0x4a, 0xe0, 0x6e, 0xa3, 0xbe, 0x75, 0x47, 0xa9, 0x60, 0xc, 0x29, 0xe4, 0x63, 0x5f, 0x62}; + uint8_t bytesprops3[] = {0x3f, 0x7c, 0xb1, 0x15, 0xa9, 0x7b, 0x73, 0x6a}; + uint8_t bytesprops5[] = {0x68, 0xb0, 0x70, 0x1a, 0xb5, 0x29, 0xd7, 0xc0, 0x50, 0xef, 0xe4, + 0xb, 0x5e, 0x69, 0x6a, 0x4e, 0x5a, 0x28, 0x72, 0x77, 0x1d}; + uint8_t bytesprops6[] = {0x10, 0x71, 0xc8, 0xae, 0x39, 0x7a, 0xb5, 0x58, 0xac, 0xfe, 0x69, + 0x1a, 0x73, 0xcf, 0x91, 0xd0, 0xd9, 0x87, 0xe9, 0x16, 0x5d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops0}, .v = {15, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops3}, .v = {15, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26777}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 23768, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\220", _pubPktID = 0, _pubBody = -// "m>\243z\246\250\139\171?\208F\f\240\232\EOTT`\241\212\SOH\182\b\SI@\228A", _pubProps = [PropSessionExpiryInterval -// 9445,PropCorrelationData "\235\250\159t\140\135\170\166\245a\r\NAK\138",PropSessionExpiryInterval -// 9422,PropPayloadFormatIndicator 100,PropSubscriptionIdentifier 25,PropSharedSubscriptionAvailable -// 182,PropResponseInformation "\221\146\181f\212\187\134\205"]} -TEST(Publish50QCTest, Encode53) { - uint8_t pkt[] = {0x38, 0x49, 0x0, 0x1, 0xdc, 0x2b, 0x11, 0x0, 0x0, 0x24, 0xe5, 0x9, 0x0, 0xd, 0xeb, - 0xfa, 0x9f, 0x74, 0x8c, 0x87, 0xaa, 0xa6, 0xf5, 0x61, 0xd, 0x15, 0x8a, 0x11, 0x0, 0x0, - 0x24, 0xce, 0x1, 0x64, 0xb, 0x19, 0x2a, 0xb6, 0x1a, 0x0, 0x8, 0xdd, 0x92, 0xb5, 0x66, - 0xd4, 0xbb, 0x86, 0xcd, 0x6d, 0x3e, 0xf3, 0x7a, 0xf6, 0xfa, 0x8b, 0xab, 0x3f, 0xd0, 0x46, - 0xc, 0xf0, 0xe8, 0x4, 0x54, 0x60, 0xf1, 0xd4, 0x1, 0xb6, 0x8, 0xf, 0x40, 0xe4, 0x41}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\EOT+\243\179\223\201\tb\221\175W<\221L\a", _pubPktID = 32599, _pubBody = +// "\187\221\219\249%\DC1M\195%\227~\ETBcZ\232\f\141\254\253\223", _pubProps = [PropRequestResponseInformation +// 75,PropRequestResponseInformation 72,PropServerReference +// "W\v\250p^\151{p_\169\224\131\EOT{\219\131%\207$\192+",PropAssignedClientIdentifier +// "L\216\&8\134\146\254\201\DELm\138~YZ\233|\244S\131\213Nt\254Bl\208\149",PropRequestProblemInformation 238]} +TEST(Publish5QCTest, Encode52) { + uint8_t pkt[] = {0x3b, 0x63, 0x0, 0xf, 0x4, 0x2b, 0xf3, 0xb3, 0xdf, 0xc9, 0x9, 0x62, 0xdd, 0xaf, 0x57, 0x3c, 0xdd, + 0x4c, 0x7, 0x7f, 0x57, 0x3b, 0x19, 0x4b, 0x19, 0x48, 0x1c, 0x0, 0x15, 0x57, 0xb, 0xfa, 0x70, 0x5e, + 0x97, 0x7b, 0x70, 0x5f, 0xa9, 0xe0, 0x83, 0x4, 0x7b, 0xdb, 0x83, 0x25, 0xcf, 0x24, 0xc0, 0x2b, 0x12, + 0x0, 0x1a, 0x4c, 0xd8, 0x38, 0x86, 0x92, 0xfe, 0xc9, 0x7f, 0x6d, 0x8a, 0x7e, 0x59, 0x5a, 0xe9, 0x7c, + 0xf4, 0x53, 0x83, 0xd5, 0x4e, 0x74, 0xfe, 0x42, 0x6c, 0xd0, 0x95, 0x17, 0xee, 0xbb, 0xdd, 0xdb, 0xf9, + 0x25, 0x11, 0x4d, 0xc3, 0x25, 0xe3, 0x7e, 0x17, 0x63, 0x5a, 0xe8, 0xc, 0x8d, 0xfe, 0xfd, 0xdf}; + + uint8_t buf[111] = {0}; + + uint8_t topic_bytes[] = {0x4, 0x2b, 0xf3, 0xb3, 0xdf, 0xc9, 0x9, 0x62, 0xdd, 0xaf, 0x57, 0x3c, 0xdd, 0x4c, 0x7}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xbb, 0xdd, 0xdb, 0xf9, 0x25, 0x11, 0x4d, 0xc3, 0x25, 0xe3, + 0x7e, 0x17, 0x63, 0x5a, 0xe8, 0xc, 0x8d, 0xfe, 0xfd, 0xdf}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 20; + + uint8_t bytesprops0[] = {0x57, 0xb, 0xfa, 0x70, 0x5e, 0x97, 0x7b, 0x70, 0x5f, 0xa9, 0xe0, + 0x83, 0x4, 0x7b, 0xdb, 0x83, 0x25, 0xcf, 0x24, 0xc0, 0x2b}; + uint8_t bytesprops1[] = {0x4c, 0xd8, 0x38, 0x86, 0x92, 0xfe, 0xc9, 0x7f, 0x6d, 0x8a, 0x7e, 0x59, 0x5a, + 0xe9, 0x7c, 0xf4, 0x53, 0x83, 0xd5, 0x4e, 0x74, 0xfe, 0x42, 0x6c, 0xd0, 0x95}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 238}}, + }; - uint8_t buf[85] = {0}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 32599, topic, msg, props); - uint8_t topic_bytes[] = {0xdc}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "k6\170c0\139\149-", _pubPktID = +// 24880, _pubBody = "q\181r\196\216Eo\234\"\ENQ\138\207\210-\196\182\157\139\DC2\178?b\a4\250\ETB\168\131", _pubProps = +// [PropResponseTopic "\194\253P1\177\165\ETB\236\228\\;",PropResponseInformation +// "\143\DEL\169\206\155\248\193\163\&6\181\NUL\v5\180",PropRetainAvailable 58,PropSubscriptionIdentifier +// 26,PropSubscriptionIdentifierAvailable 200,PropSubscriptionIdentifier 28,PropSubscriptionIdentifier +// 27,PropAuthenticationData "\197\DC2#",PropAuthenticationMethod "H",PropAuthenticationData +// "\204\226Q\174\&9\190\172\174\135\&6\255\130\203\152\216\201|\180?\234\DC1\175\169\181\&7X",PropMaximumQoS +// 208,PropMaximumPacketSize 31599,PropMaximumQoS 143,PropServerKeepAlive 4529]} +TEST(Publish5QCTest, Encode53) { + uint8_t pkt[] = {0x32, 0x85, 0x1, 0x0, 0x8, 0x6b, 0x36, 0xaa, 0x63, 0x30, 0x8b, 0x95, 0x2d, 0x61, 0x30, 0x5c, + 0x8, 0x0, 0xb, 0xc2, 0xfd, 0x50, 0x31, 0xb1, 0xa5, 0x17, 0xec, 0xe4, 0x5c, 0x3b, 0x1a, 0x0, + 0xe, 0x8f, 0x7f, 0xa9, 0xce, 0x9b, 0xf8, 0xc1, 0xa3, 0x36, 0xb5, 0x0, 0xb, 0x35, 0xb4, 0x25, + 0x3a, 0xb, 0x1a, 0x29, 0xc8, 0xb, 0x1c, 0xb, 0x1b, 0x16, 0x0, 0x3, 0xc5, 0x12, 0x23, 0x15, + 0x0, 0x1, 0x48, 0x16, 0x0, 0x1a, 0xcc, 0xe2, 0x51, 0xae, 0x39, 0xbe, 0xac, 0xae, 0x87, 0x36, + 0xff, 0x82, 0xcb, 0x98, 0xd8, 0xc9, 0x7c, 0xb4, 0x3f, 0xea, 0x11, 0xaf, 0xa9, 0xb5, 0x37, 0x58, + 0x24, 0xd0, 0x27, 0x0, 0x0, 0x7b, 0x6f, 0x24, 0x8f, 0x13, 0x11, 0xb1, 0x71, 0xb5, 0x72, 0xc4, + 0xd8, 0x45, 0x6f, 0xea, 0x22, 0x5, 0x8a, 0xcf, 0xd2, 0x2d, 0xc4, 0xb6, 0x9d, 0x8b, 0x12, 0xb2, + 0x3f, 0x62, 0x7, 0x34, 0xfa, 0x17, 0xa8, 0x83}; + + uint8_t buf[146] = {0}; + + uint8_t topic_bytes[] = {0x6b, 0x36, 0xaa, 0x63, 0x30, 0x8b, 0x95, 0x2d}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x6d, 0x3e, 0xf3, 0x7a, 0xf6, 0xfa, 0x8b, 0xab, 0x3f, 0xd0, 0x46, 0xc, 0xf0, - 0xe8, 0x4, 0x54, 0x60, 0xf1, 0xd4, 0x1, 0xb6, 0x8, 0xf, 0x40, 0xe4, 0x41}; + uint8_t msg_bytes[] = {0x71, 0xb5, 0x72, 0xc4, 0xd8, 0x45, 0x6f, 0xea, 0x22, 0x5, 0x8a, 0xcf, 0xd2, 0x2d, + 0xc4, 0xb6, 0x9d, 0x8b, 0x12, 0xb2, 0x3f, 0x62, 0x7, 0x34, 0xfa, 0x17, 0xa8, 0x83}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; - - uint8_t bytes0[] = {0xeb, 0xfa, 0x9f, 0x74, 0x8c, 0x87, 0xaa, 0xa6, 0xf5, 0x61, 0xd, 0x15, 0x8a}; - uint8_t bytes1[] = {0xdd, 0x92, 0xb5, 0x66, 0xd4, 0xbb, 0x86, 0xcd}; + msg.payload_len = 28; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9445}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9422}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytes1}}}, + uint8_t bytesprops0[] = {0xc2, 0xfd, 0x50, 0x31, 0xb1, 0xa5, 0x17, 0xec, 0xe4, 0x5c, 0x3b}; + uint8_t bytesprops1[] = {0x8f, 0x7f, 0xa9, 0xce, 0x9b, 0xf8, 0xc1, 0xa3, 0x36, 0xb5, 0x0, 0xb, 0x35, 0xb4}; + uint8_t bytesprops2[] = {0xc5, 0x12, 0x23}; + uint8_t bytesprops3[] = {0x48}; + uint8_t bytesprops4[] = {0xcc, 0xe2, 0x51, 0xae, 0x39, 0xbe, 0xac, 0xae, 0x87, 0x36, 0xff, 0x82, 0xcb, + 0x98, 0xd8, 0xc9, 0x7c, 0xb4, 0x3f, 0xea, 0x11, 0xaf, 0xa9, 0xb5, 0x37, 0x58}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31599}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4529}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24880, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\f\143\204y\245\248\131\153\248\250\nj\156\173\166\174\GSIv\154\166w\r\136Y", _pubPktID = 0, _pubBody = -// "\177\216D\168\tF\242kx1\247\n", _pubProps = [PropMaximumPacketSize 6251,PropSubscriptionIdentifierAvailable -// 225,PropAuthenticationMethod "\fw\226B\SYN9\175O\182\203\229",PropMessageExpiryInterval -// 1651,PropSubscriptionIdentifier 9,PropResponseTopic -// "\142\234\130\217\SI\206\129\148*I\220\223\172\250yR\180ul\220B\147w\136\213",PropWillDelayInterval -// 23126,PropWildcardSubscriptionAvailable 183]} -TEST(Publish50QCTest, Encode54) { - uint8_t pkt[] = {0x31, 0x67, 0x0, 0x19, 0xc, 0x8f, 0xcc, 0x79, 0xf5, 0xf8, 0x83, 0x99, 0xf8, 0xfa, 0xa, - 0x6a, 0x9c, 0xad, 0xa6, 0xae, 0x1d, 0x49, 0x76, 0x9a, 0xa6, 0x77, 0xd, 0x88, 0x59, 0x3f, - 0x27, 0x0, 0x0, 0x18, 0x6b, 0x29, 0xe1, 0x15, 0x0, 0xb, 0xc, 0x77, 0xe2, 0x42, 0x16, - 0x39, 0xaf, 0x4f, 0xb6, 0xcb, 0xe5, 0x2, 0x0, 0x0, 0x6, 0x73, 0xb, 0x9, 0x8, 0x0, - 0x19, 0x8e, 0xea, 0x82, 0xd9, 0xf, 0xce, 0x81, 0x94, 0x2a, 0x49, 0xdc, 0xdf, 0xac, 0xfa, - 0x79, 0x52, 0xb4, 0x75, 0x6c, 0xdc, 0x42, 0x93, 0x77, 0x88, 0xd5, 0x18, 0x0, 0x0, 0x5a, - 0x56, 0x28, 0xb7, 0xb1, 0xd8, 0x44, 0xa8, 0x9, 0x46, 0xf2, 0x6b, 0x78, 0x31, 0xf7, 0xa}; - - uint8_t buf[115] = {0}; - - uint8_t topic_bytes[] = {0xc, 0x8f, 0xcc, 0x79, 0xf5, 0xf8, 0x83, 0x99, 0xf8, 0xfa, 0xa, 0x6a, 0x9c, - 0xad, 0xa6, 0xae, 0x1d, 0x49, 0x76, 0x9a, 0xa6, 0x77, 0xd, 0x88, 0x59}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\164]\137\161\184\189\ETB_L\r+\255\233u\227\NAK\SI\199\CANG\211_\141", _pubPktID = 0, _pubBody = +// "n\169\136j,\137\228\208\162\164aL\186\EOT\241\GS\230d\142\177N\138P", _pubProps = [PropAuthenticationMethod +// "\150\NULS\SUB\129",PropSubscriptionIdentifierAvailable 115,PropMessageExpiryInterval +// 16352,PropRequestProblemInformation 184,PropAssignedClientIdentifier "\t",PropAuthenticationMethod +// "\152\247\214J\179\245\255\166\STX\252\255\130\243\141L`",PropTopicAliasMaximum 17674]} +TEST(Publish5QCTest, Encode54) { + uint8_t pkt[] = {0x38, 0x5c, 0x0, 0x17, 0xa4, 0x5d, 0x89, 0xa1, 0xb8, 0xbd, 0x17, 0x5f, 0x4c, 0xd, 0x2b, 0xff, + 0xe9, 0x75, 0xe3, 0x15, 0xf, 0xc7, 0x18, 0x47, 0xd3, 0x5f, 0x8d, 0x2b, 0x15, 0x0, 0x5, 0x96, + 0x0, 0x53, 0x1a, 0x81, 0x29, 0x73, 0x2, 0x0, 0x0, 0x3f, 0xe0, 0x17, 0xb8, 0x12, 0x0, 0x1, + 0x9, 0x15, 0x0, 0x10, 0x98, 0xf7, 0xd6, 0x4a, 0xb3, 0xf5, 0xff, 0xa6, 0x2, 0xfc, 0xff, 0x82, + 0xf3, 0x8d, 0x4c, 0x60, 0x22, 0x45, 0xa, 0x6e, 0xa9, 0x88, 0x6a, 0x2c, 0x89, 0xe4, 0xd0, 0xa2, + 0xa4, 0x61, 0x4c, 0xba, 0x4, 0xf1, 0x1d, 0xe6, 0x64, 0x8e, 0xb1, 0x4e, 0x8a, 0x50}; + + uint8_t buf[104] = {0}; + + uint8_t topic_bytes[] = {0xa4, 0x5d, 0x89, 0xa1, 0xb8, 0xbd, 0x17, 0x5f, 0x4c, 0xd, 0x2b, 0xff, + 0xe9, 0x75, 0xe3, 0x15, 0xf, 0xc7, 0x18, 0x47, 0xd3, 0x5f, 0x8d}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xb1, 0xd8, 0x44, 0xa8, 0x9, 0x46, 0xf2, 0x6b, 0x78, 0x31, 0xf7, 0xa}; + msg.retained = false; + uint8_t msg_bytes[] = {0x6e, 0xa9, 0x88, 0x6a, 0x2c, 0x89, 0xe4, 0xd0, 0xa2, 0xa4, 0x61, 0x4c, + 0xba, 0x4, 0xf1, 0x1d, 0xe6, 0x64, 0x8e, 0xb1, 0x4e, 0x8a, 0x50}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; - - uint8_t bytes0[] = {0xc, 0x77, 0xe2, 0x42, 0x16, 0x39, 0xaf, 0x4f, 0xb6, 0xcb, 0xe5}; - uint8_t bytes1[] = {0x8e, 0xea, 0x82, 0xd9, 0xf, 0xce, 0x81, 0x94, 0x2a, 0x49, 0xdc, 0xdf, 0xac, - 0xfa, 0x79, 0x52, 0xb4, 0x75, 0x6c, 0xdc, 0x42, 0x93, 0x77, 0x88, 0xd5}; + msg.payload_len = 23; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6251}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1651}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23126}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, + uint8_t bytesprops0[] = {0x96, 0x0, 0x53, 0x1a, 0x81}; + uint8_t bytesprops1[] = {0x9}; + uint8_t bytesprops2[] = {0x98, 0xf7, 0xd6, 0x4a, 0xb3, 0xf5, 0xff, 0xa6, + 0x2, 0xfc, 0xff, 0x82, 0xf3, 0x8d, 0x4c, 0x60}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16352}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17674}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "x\141i\235F", _pubPktID = 15511, -// _pubBody = "\174]0.\196?\198\195\202m`\179\253E\v|\204\214P\f\229\NAK\154\130", _pubProps = -// [PropSubscriptionIdentifier 21,PropResponseTopic -// "\221P\183\212\158\183\132\176\213\128wK\"\163\&8\137{B\173\192\186\130",PropResponseTopic -// "e\r:`\149\240\185)g\174M\137\DC4\232C",PropMessageExpiryInterval 16546,PropContentType -// "\231J\190\176\154\213\148$\190\210\r\133",PropRequestProblemInformation 23,PropServerReference -// "\226\&3M1(\147\241|.\129\183\&3Hb\211c\192,\207\EOT"]} -TEST(Publish50QCTest, Encode55) { - uint8_t pkt[] = {0x32, 0x7c, 0x0, 0x5, 0x78, 0x8d, 0x69, 0xeb, 0x46, 0x3c, 0x97, 0x5a, 0xb, 0x15, 0x8, 0x0, - 0x16, 0xdd, 0x50, 0xb7, 0xd4, 0x9e, 0xb7, 0x84, 0xb0, 0xd5, 0x80, 0x77, 0x4b, 0x22, 0xa3, 0x38, - 0x89, 0x7b, 0x42, 0xad, 0xc0, 0xba, 0x82, 0x8, 0x0, 0xf, 0x65, 0xd, 0x3a, 0x60, 0x95, 0xf0, - 0xb9, 0x29, 0x67, 0xae, 0x4d, 0x89, 0x14, 0xe8, 0x43, 0x2, 0x0, 0x0, 0x40, 0xa2, 0x3, 0x0, - 0xc, 0xe7, 0x4a, 0xbe, 0xb0, 0x9a, 0xd5, 0x94, 0x24, 0xbe, 0xd2, 0xd, 0x85, 0x17, 0x17, 0x1c, - 0x0, 0x14, 0xe2, 0x33, 0x4d, 0x31, 0x28, 0x93, 0xf1, 0x7c, 0x2e, 0x81, 0xb7, 0x33, 0x48, 0x62, - 0xd3, 0x63, 0xc0, 0x2c, 0xcf, 0x4, 0xae, 0x5d, 0x30, 0x2e, 0xc4, 0x3f, 0xc6, 0xc3, 0xca, 0x6d, - 0x60, 0xb3, 0xfd, 0x45, 0xb, 0x7c, 0xcc, 0xd6, 0x50, 0xc, 0xe5, 0x15, 0x9a, 0x82}; - - uint8_t buf[136] = {0}; - - uint8_t topic_bytes[] = {0x78, 0x8d, 0x69, 0xeb, 0x46}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "_\225\NAK\164\f\128V", _pubPktID = +// 0, _pubBody = "\146\161JU\174P\208og\201\149\132e\190\182\\!e\203q\201\194\SYN\147O\178\173{\DC2F", _pubProps = +// [PropTopicAliasMaximum 23589,PropSubscriptionIdentifier 23,PropResponseTopic +// "\251\131\ESC\ESC\140\241u\a\144\132r\t\144",PropSubscriptionIdentifier 7,PropAuthenticationData +// "\250\GS\208\170\DC1\r\163\251\DC1\230\240\212uC"]} +TEST(Publish5QCTest, Encode55) { + uint8_t pkt[] = {0x30, 0x50, 0x0, 0x7, 0x5f, 0xe1, 0x15, 0xa4, 0xc, 0x80, 0x56, 0x28, 0x22, 0x5c, 0x25, 0xb, 0x17, + 0x8, 0x0, 0xd, 0xfb, 0x83, 0x1b, 0x1b, 0x8c, 0xf1, 0x75, 0x7, 0x90, 0x84, 0x72, 0x9, 0x90, 0xb, + 0x7, 0x16, 0x0, 0xe, 0xfa, 0x1d, 0xd0, 0xaa, 0x11, 0xd, 0xa3, 0xfb, 0x11, 0xe6, 0xf0, 0xd4, 0x75, + 0x43, 0x92, 0xa1, 0x4a, 0x55, 0xae, 0x50, 0xd0, 0x6f, 0x67, 0xc9, 0x95, 0x84, 0x65, 0xbe, 0xb6, 0x5c, + 0x21, 0x65, 0xcb, 0x71, 0xc9, 0xc2, 0x16, 0x93, 0x4f, 0xb2, 0xad, 0x7b, 0x12, 0x46}; + + uint8_t buf[92] = {0}; + + uint8_t topic_bytes[] = {0x5f, 0xe1, 0x15, 0xa4, 0xc, 0x80, 0x56}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xae, 0x5d, 0x30, 0x2e, 0xc4, 0x3f, 0xc6, 0xc3, 0xca, 0x6d, 0x60, 0xb3, - 0xfd, 0x45, 0xb, 0x7c, 0xcc, 0xd6, 0x50, 0xc, 0xe5, 0x15, 0x9a, 0x82}; + uint8_t msg_bytes[] = {0x92, 0xa1, 0x4a, 0x55, 0xae, 0x50, 0xd0, 0x6f, 0x67, 0xc9, 0x95, 0x84, 0x65, 0xbe, 0xb6, + 0x5c, 0x21, 0x65, 0xcb, 0x71, 0xc9, 0xc2, 0x16, 0x93, 0x4f, 0xb2, 0xad, 0x7b, 0x12, 0x46}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 30; - uint8_t bytes0[] = {0xdd, 0x50, 0xb7, 0xd4, 0x9e, 0xb7, 0x84, 0xb0, 0xd5, 0x80, 0x77, - 0x4b, 0x22, 0xa3, 0x38, 0x89, 0x7b, 0x42, 0xad, 0xc0, 0xba, 0x82}; - uint8_t bytes1[] = {0x65, 0xd, 0x3a, 0x60, 0x95, 0xf0, 0xb9, 0x29, 0x67, 0xae, 0x4d, 0x89, 0x14, 0xe8, 0x43}; - uint8_t bytes2[] = {0xe7, 0x4a, 0xbe, 0xb0, 0x9a, 0xd5, 0x94, 0x24, 0xbe, 0xd2, 0xd, 0x85}; - uint8_t bytes3[] = {0xe2, 0x33, 0x4d, 0x31, 0x28, 0x93, 0xf1, 0x7c, 0x2e, 0x81, - 0xb7, 0x33, 0x48, 0x62, 0xd3, 0x63, 0xc0, 0x2c, 0xcf, 0x4}; + uint8_t bytesprops0[] = {0xfb, 0x83, 0x1b, 0x1b, 0x8c, 0xf1, 0x75, 0x7, 0x90, 0x84, 0x72, 0x9, 0x90}; + uint8_t bytesprops1[] = {0xfa, 0x1d, 0xd0, 0xaa, 0x11, 0xd, 0xa3, 0xfb, 0x11, 0xe6, 0xf0, 0xd4, 0x75, 0x43}; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16546}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytes3}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23589}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15511, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\207", _pubPktID = 12437, _pubBody = -// "\209\NAKT\231?\229R\176}\ESC\195\172\146\168\148\188;\237\205\216\134\&4\132\&5w", _pubProps = -// [PropTopicAliasMaximum 9499,PropAuthenticationMethod "\166\ENQ\132mo\129\187\154%\158\EOT",PropTopicAliasMaximum -// 30051,PropTopicAliasMaximum 8839]} -TEST(Publish50QCTest, Encode56) { - uint8_t pkt[] = {0x3a, 0x36, 0x0, 0x1, 0xcf, 0x30, 0x95, 0x17, 0x22, 0x25, 0x1b, 0x15, 0x0, 0xb, - 0xa6, 0x5, 0x84, 0x6d, 0x6f, 0x81, 0xbb, 0x9a, 0x25, 0x9e, 0x4, 0x22, 0x75, 0x63, - 0x22, 0x22, 0x87, 0xd1, 0x15, 0x54, 0xe7, 0x3f, 0xe5, 0x52, 0xb0, 0x7d, 0x1b, 0xc3, - 0xac, 0x92, 0xa8, 0x94, 0xbc, 0x3b, 0xed, 0xcd, 0xd8, 0x86, 0x34, 0x84, 0x35, 0x77}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\b\240\fA@\206\204-; +// R\nS$\n\194\ESCh\DC1P2\229\135$", _pubPktID = 32117, _pubBody = "[\a", _pubProps = [PropAuthenticationMethod +// "\245\213H\ACK\ETB\r(\216&\154",PropAuthenticationMethod "\EOT\250\167n;@\194V\250",PropRequestResponseInformation +// 56,PropResponseInformation "",PropMaximumQoS 212,PropAuthenticationMethod +// "\ETB\213\236\r/\SI\147\243\249i\147\246+@\137\157\139\211",PropSessionExpiryInterval 120,PropReceiveMaximum +// 5986,PropRequestProblemInformation 16,PropMessageExpiryInterval 30265,PropResponseInformation +// "\USA\218\200\232\ETB\ETB\142\184^`\253\227\247\243\143b\255\149\167\183\&15$[\211\228Q\200",PropCorrelationData +// "\144\236\151",PropSubscriptionIdentifier 22,PropResponseTopic "",PropSubscriptionIdentifier 23,PropWillDelayInterval +// 3333,PropMessageExpiryInterval 11209,PropMessageExpiryInterval 5188,PropTopicAliasMaximum 1410,PropReasonString +// "",PropResponseInformation "\129y\251\136",PropWillDelayInterval 13435,PropMaximumPacketSize 30116,PropReceiveMaximum +// 22947,PropSharedSubscriptionAvailable 223]} +TEST(Publish5QCTest, Encode56) { + uint8_t pkt[] = {0x35, 0xbc, 0x1, 0x0, 0x18, 0x8, 0xf0, 0xc, 0x41, 0x40, 0xce, 0xcc, 0x2d, 0x3b, 0x20, 0x52, + 0xa, 0x53, 0x24, 0xa, 0xc2, 0x1b, 0x68, 0x11, 0x50, 0x32, 0xe5, 0x87, 0x24, 0x7d, 0x75, 0x9c, + 0x1, 0x15, 0x0, 0xa, 0xf5, 0xd5, 0x48, 0x6, 0x17, 0xd, 0x28, 0xd8, 0x26, 0x9a, 0x15, 0x0, + 0x9, 0x4, 0xfa, 0xa7, 0x6e, 0x3b, 0x40, 0xc2, 0x56, 0xfa, 0x19, 0x38, 0x1a, 0x0, 0x0, 0x24, + 0xd4, 0x15, 0x0, 0x12, 0x17, 0xd5, 0xec, 0xd, 0x2f, 0xf, 0x93, 0xf3, 0xf9, 0x69, 0x93, 0xf6, + 0x2b, 0x40, 0x89, 0x9d, 0x8b, 0xd3, 0x11, 0x0, 0x0, 0x0, 0x78, 0x21, 0x17, 0x62, 0x17, 0x10, + 0x2, 0x0, 0x0, 0x76, 0x39, 0x1a, 0x0, 0x1d, 0x1f, 0x41, 0xda, 0xc8, 0xe8, 0x17, 0x17, 0x8e, + 0xb8, 0x5e, 0x60, 0xfd, 0xe3, 0xf7, 0xf3, 0x8f, 0x62, 0xff, 0x95, 0xa7, 0xb7, 0x31, 0x35, 0x24, + 0x5b, 0xd3, 0xe4, 0x51, 0xc8, 0x9, 0x0, 0x3, 0x90, 0xec, 0x97, 0xb, 0x16, 0x8, 0x0, 0x0, + 0xb, 0x17, 0x18, 0x0, 0x0, 0xd, 0x5, 0x2, 0x0, 0x0, 0x2b, 0xc9, 0x2, 0x0, 0x0, 0x14, + 0x44, 0x22, 0x5, 0x82, 0x1f, 0x0, 0x0, 0x1a, 0x0, 0x4, 0x81, 0x79, 0xfb, 0x88, 0x18, 0x0, + 0x0, 0x34, 0x7b, 0x27, 0x0, 0x0, 0x75, 0xa4, 0x21, 0x59, 0xa3, 0x2a, 0xdf, 0x5b, 0x7}; - uint8_t buf[66] = {0}; + uint8_t buf[201] = {0}; - uint8_t topic_bytes[] = {0xcf}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x8, 0xf0, 0xc, 0x41, 0x40, 0xce, 0xcc, 0x2d, 0x3b, 0x20, 0x52, 0xa, + 0x53, 0x24, 0xa, 0xc2, 0x1b, 0x68, 0x11, 0x50, 0x32, 0xe5, 0x87, 0x24}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xd1, 0x15, 0x54, 0xe7, 0x3f, 0xe5, 0x52, 0xb0, 0x7d, 0x1b, 0xc3, 0xac, 0x92, - 0xa8, 0x94, 0xbc, 0x3b, 0xed, 0xcd, 0xd8, 0x86, 0x34, 0x84, 0x35, 0x77}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x5b, 0x7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; - - uint8_t bytes0[] = {0xa6, 0x5, 0x84, 0x6d, 0x6f, 0x81, 0xbb, 0x9a, 0x25, 0x9e, 0x4}; + msg.payload_len = 2; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9499}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30051}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8839}}, + uint8_t bytesprops0[] = {0xf5, 0xd5, 0x48, 0x6, 0x17, 0xd, 0x28, 0xd8, 0x26, 0x9a}; + uint8_t bytesprops1[] = {0x4, 0xfa, 0xa7, 0x6e, 0x3b, 0x40, 0xc2, 0x56, 0xfa}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x17, 0xd5, 0xec, 0xd, 0x2f, 0xf, 0x93, 0xf3, 0xf9, + 0x69, 0x93, 0xf6, 0x2b, 0x40, 0x89, 0x9d, 0x8b, 0xd3}; + uint8_t bytesprops4[] = {0x1f, 0x41, 0xda, 0xc8, 0xe8, 0x17, 0x17, 0x8e, 0xb8, 0x5e, 0x60, 0xfd, 0xe3, 0xf7, 0xf3, + 0x8f, 0x62, 0xff, 0x95, 0xa7, 0xb7, 0x31, 0x35, 0x24, 0x5b, 0xd3, 0xe4, 0x51, 0xc8}; + uint8_t bytesprops5[] = {0x90, 0xec, 0x97}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops8[] = {0x81, 0x79, 0xfb, 0x88}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 120}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5986}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30265}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3333}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11209}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5188}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1410}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13435}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30116}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22947}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 223}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 12437, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32117, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\151\157\DC2\191\177A0d\141\181", -// _pubPktID = 0, _pubBody = "(W\SO\vJ\219Q\170]\to\a3\EOT\245X?\r\255\t&i\EM\213", _pubProps = -// [PropAuthenticationMethod "\DC3\DLEHQ",PropMessageExpiryInterval 4440,PropPayloadFormatIndicator -// 234,PropServerKeepAlive 28079,PropTopicAliasMaximum 11882,PropSessionExpiryInterval 357]} -TEST(Publish50QCTest, Encode57) { - uint8_t pkt[] = {0x38, 0x3e, 0x0, 0xa, 0x97, 0x9d, 0x12, 0xbf, 0xb1, 0x41, 0x30, 0x64, 0x8d, 0xb5, 0x19, 0x15, - 0x0, 0x4, 0x13, 0x10, 0x48, 0x51, 0x2, 0x0, 0x0, 0x11, 0x58, 0x1, 0xea, 0x13, 0x6d, 0xaf, - 0x22, 0x2e, 0x6a, 0x11, 0x0, 0x0, 0x1, 0x65, 0x28, 0x57, 0xe, 0xb, 0x4a, 0xdb, 0x51, 0xaa, - 0x5d, 0x9, 0x6f, 0x7, 0x33, 0x4, 0xf5, 0x58, 0x3f, 0xd, 0xff, 0x9, 0x26, 0x69, 0x19, 0xd5}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\169\247+\235\ACK\192\145", +// _pubPktID = 0, _pubBody = "\a\197\204\DEL\222\198\153\205\174\176a\153\233u\246\203~z\166\212\229\207sp\US`\225", +// _pubProps = [PropReasonString "",PropAuthenticationMethod "\SIo{\154@\229\196\DEL\129EZ\159C",PropResponseInformation +// "\238\&9",PropTopicAliasMaximum 31169,PropResponseTopic +// "\131Xsu\250\206l\231\160WT\167\135\151\231\128\248\148\GS8p\189",PropRetainAvailable 70,PropResponseTopic +// "\238X\170{zo\223\233e\239\216y,\212\bt[\255\226\&3w\242",PropUserProperty "\162\ACKX" +// "\220\STX\197\249w\RS\160\244I&+\153\214\216\240fG\222\228\132",PropRequestResponseInformation 69,PropRetainAvailable +// 52,PropMaximumQoS 226,PropContentType "e\186\147\165\221\149\235`\244J\DC1\129\246",PropTopicAlias +// 28871,PropReceiveMaximum 22463]} +TEST(Publish5QCTest, Encode57) { + uint8_t pkt[] = {0x31, 0xad, 0x1, 0x0, 0x7, 0xa9, 0xf7, 0x2b, 0xeb, 0x6, 0xc0, 0x91, 0x87, 0x1, 0x1f, 0x0, + 0x0, 0x15, 0x0, 0xd, 0xf, 0x6f, 0x7b, 0x9a, 0x40, 0xe5, 0xc4, 0x7f, 0x81, 0x45, 0x5a, 0x9f, + 0x43, 0x1a, 0x0, 0x2, 0xee, 0x39, 0x22, 0x79, 0xc1, 0x8, 0x0, 0x16, 0x83, 0x58, 0x73, 0x75, + 0xfa, 0xce, 0x6c, 0xe7, 0xa0, 0x57, 0x54, 0xa7, 0x87, 0x97, 0xe7, 0x80, 0xf8, 0x94, 0x1d, 0x38, + 0x70, 0xbd, 0x25, 0x46, 0x8, 0x0, 0x16, 0xee, 0x58, 0xaa, 0x7b, 0x7a, 0x6f, 0xdf, 0xe9, 0x65, + 0xef, 0xd8, 0x79, 0x2c, 0xd4, 0x8, 0x74, 0x5b, 0xff, 0xe2, 0x33, 0x77, 0xf2, 0x26, 0x0, 0x3, + 0xa2, 0x6, 0x58, 0x0, 0x14, 0xdc, 0x2, 0xc5, 0xf9, 0x77, 0x1e, 0xa0, 0xf4, 0x49, 0x26, 0x2b, + 0x99, 0xd6, 0xd8, 0xf0, 0x66, 0x47, 0xde, 0xe4, 0x84, 0x19, 0x45, 0x25, 0x34, 0x24, 0xe2, 0x3, + 0x0, 0xd, 0x65, 0xba, 0x93, 0xa5, 0xdd, 0x95, 0xeb, 0x60, 0xf4, 0x4a, 0x11, 0x81, 0xf6, 0x23, + 0x70, 0xc7, 0x21, 0x57, 0xbf, 0x7, 0xc5, 0xcc, 0x7f, 0xde, 0xc6, 0x99, 0xcd, 0xae, 0xb0, 0x61, + 0x99, 0xe9, 0x75, 0xf6, 0xcb, 0x7e, 0x7a, 0xa6, 0xd4, 0xe5, 0xcf, 0x73, 0x70, 0x1f, 0x60, 0xe1}; - uint8_t buf[74] = {0}; + uint8_t buf[186] = {0}; - uint8_t topic_bytes[] = {0x97, 0x9d, 0x12, 0xbf, 0xb1, 0x41, 0x30, 0x64, 0x8d, 0xb5}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa9, 0xf7, 0x2b, 0xeb, 0x6, 0xc0, 0x91}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x28, 0x57, 0xe, 0xb, 0x4a, 0xdb, 0x51, 0xaa, 0x5d, 0x9, 0x6f, 0x7, - 0x33, 0x4, 0xf5, 0x58, 0x3f, 0xd, 0xff, 0x9, 0x26, 0x69, 0x19, 0xd5}; + msg.retained = true; + uint8_t msg_bytes[] = {0x7, 0xc5, 0xcc, 0x7f, 0xde, 0xc6, 0x99, 0xcd, 0xae, 0xb0, 0x61, 0x99, 0xe9, 0x75, + 0xf6, 0xcb, 0x7e, 0x7a, 0xa6, 0xd4, 0xe5, 0xcf, 0x73, 0x70, 0x1f, 0x60, 0xe1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; - - uint8_t bytes0[] = {0x13, 0x10, 0x48, 0x51}; + msg.payload_len = 27; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4440}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28079}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11882}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 357}}, + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xf, 0x6f, 0x7b, 0x9a, 0x40, 0xe5, 0xc4, 0x7f, 0x81, 0x45, 0x5a, 0x9f, 0x43}; + uint8_t bytesprops2[] = {0xee, 0x39}; + uint8_t bytesprops3[] = {0x83, 0x58, 0x73, 0x75, 0xfa, 0xce, 0x6c, 0xe7, 0xa0, 0x57, 0x54, + 0xa7, 0x87, 0x97, 0xe7, 0x80, 0xf8, 0x94, 0x1d, 0x38, 0x70, 0xbd}; + uint8_t bytesprops4[] = {0xee, 0x58, 0xaa, 0x7b, 0x7a, 0x6f, 0xdf, 0xe9, 0x65, 0xef, 0xd8, + 0x79, 0x2c, 0xd4, 0x8, 0x74, 0x5b, 0xff, 0xe2, 0x33, 0x77, 0xf2}; + uint8_t bytesprops6[] = {0xdc, 0x2, 0xc5, 0xf9, 0x77, 0x1e, 0xa0, 0xf4, 0x49, 0x26, + 0x2b, 0x99, 0xd6, 0xd8, 0xf0, 0x66, 0x47, 0xde, 0xe4, 0x84}; + uint8_t bytesprops5[] = {0xa2, 0x6, 0x58}; + uint8_t bytesprops7[] = {0x65, 0xba, 0x93, 0xa5, 0xdd, 0x95, 0xeb, 0x60, 0xf4, 0x4a, 0x11, 0x81, 0xf6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31169}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops5}, .v = {20, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28871}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22463}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\ETB\133p7\NAK\217\177\185\186:\228-\158\214\255\170", _pubPktID = 5681, _pubBody = -// "\NULT\212\214&\205\222\154\236\130\237_\195\200\186\137\DEL\184\213\&6\192a\241\NUL\231\168\246\180", _pubProps = -// [PropMessageExpiryInterval 6752,PropResponseInformation "\DC2\DELf\202eTw\149\239",PropMaximumPacketSize -// 16265,PropRetainAvailable 229,PropReasonString "v5*\215u",PropRequestProblemInformation 220]} -TEST(Publish50QCTest, Encode58) { - uint8_t pkt[] = {0x3c, 0x53, 0x0, 0x10, 0x17, 0x85, 0x70, 0x37, 0x15, 0xd9, 0xb1, 0xb9, 0xba, 0x3a, 0xe4, - 0x2d, 0x9e, 0xd6, 0xff, 0xaa, 0x16, 0x31, 0x22, 0x2, 0x0, 0x0, 0x1a, 0x60, 0x1a, 0x0, - 0x9, 0x12, 0x7f, 0x66, 0xca, 0x65, 0x54, 0x77, 0x95, 0xef, 0x27, 0x0, 0x0, 0x3f, 0x89, - 0x25, 0xe5, 0x1f, 0x0, 0x5, 0x76, 0x35, 0x2a, 0xd7, 0x75, 0x17, 0xdc, 0x0, 0x54, 0xd4, - 0xd6, 0x26, 0xcd, 0xde, 0x9a, 0xec, 0x82, 0xed, 0x5f, 0xc3, 0xc8, 0xba, 0x89, 0x7f, 0xb8, - 0xd5, 0x36, 0xc0, 0x61, 0xf1, 0x0, 0xe7, 0xa8, 0xf6, 0xb4}; - - uint8_t buf[95] = {0}; - - uint8_t topic_bytes[] = {0x17, 0x85, 0x70, 0x37, 0x15, 0xd9, 0xb1, 0xb9, - 0xba, 0x3a, 0xe4, 0x2d, 0x9e, 0xd6, 0xff, 0xaa}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\150\251\130\251\166R)\184\\I^\183\212@\189\150\222", _pubPktID = 0, _pubBody = "\139}\228\225\&9", _pubProps = +// [PropCorrelationData "\170\SUB",PropWildcardSubscriptionAvailable 102,PropSharedSubscriptionAvailable +// 236,PropSubscriptionIdentifierAvailable 89,PropServerReference +// "n\142\NAK\184TnXQ!f~Y\SO\b\CAN\ESC\138\178\197\243\SOHg\ACK\178eH<",PropReceiveMaximum +// 22935,PropSubscriptionIdentifierAvailable 136,PropServerKeepAlive 3204]} +TEST(Publish5QCTest, Encode58) { + uint8_t pkt[] = {0x30, 0x4a, 0x0, 0x11, 0x96, 0xfb, 0x82, 0xfb, 0xa6, 0x52, 0x29, 0xb8, 0x5c, 0x49, 0x5e, 0xb7, + 0xd4, 0x40, 0xbd, 0x96, 0xde, 0x31, 0x9, 0x0, 0x2, 0xaa, 0x1a, 0x28, 0x66, 0x2a, 0xec, 0x29, + 0x59, 0x1c, 0x0, 0x1b, 0x6e, 0x8e, 0x15, 0xb8, 0x54, 0x6e, 0x58, 0x51, 0x21, 0x66, 0x7e, 0x59, + 0xe, 0x8, 0x18, 0x1b, 0x8a, 0xb2, 0xc5, 0xf3, 0x1, 0x67, 0x6, 0xb2, 0x65, 0x48, 0x3c, 0x21, + 0x59, 0x97, 0x29, 0x88, 0x13, 0xc, 0x84, 0x8b, 0x7d, 0xe4, 0xe1, 0x39}; + + uint8_t buf[86] = {0}; + + uint8_t topic_bytes[] = {0x96, 0xfb, 0x82, 0xfb, 0xa6, 0x52, 0x29, 0xb8, 0x5c, + 0x49, 0x5e, 0xb7, 0xd4, 0x40, 0xbd, 0x96, 0xde}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x0, 0x54, 0xd4, 0xd6, 0x26, 0xcd, 0xde, 0x9a, 0xec, 0x82, 0xed, 0x5f, 0xc3, 0xc8, - 0xba, 0x89, 0x7f, 0xb8, 0xd5, 0x36, 0xc0, 0x61, 0xf1, 0x0, 0xe7, 0xa8, 0xf6, 0xb4}; + uint8_t msg_bytes[] = {0x8b, 0x7d, 0xe4, 0xe1, 0x39}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 5; - uint8_t bytes0[] = {0x12, 0x7f, 0x66, 0xca, 0x65, 0x54, 0x77, 0x95, 0xef}; - uint8_t bytes1[] = {0x76, 0x35, 0x2a, 0xd7, 0x75}; + uint8_t bytesprops0[] = {0xaa, 0x1a}; + uint8_t bytesprops1[] = {0x6e, 0x8e, 0x15, 0xb8, 0x54, 0x6e, 0x58, 0x51, 0x21, 0x66, 0x7e, 0x59, 0xe, 0x8, + 0x18, 0x1b, 0x8a, 0xb2, 0xc5, 0xf3, 0x1, 0x67, 0x6, 0xb2, 0x65, 0x48, 0x3c}; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6752}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16265}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22935}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3204}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5681, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "K#\aZV,bl\168\131\197N", _pubPktID = -// 29545, _pubBody = "q\152\198\DC3v\US", _pubProps = [PropServerReference "\253\161\253",PropCorrelationData -// "\SI\241\169\229\186\174\ETX\EM\n\193\189>\237\214U\ESC\128",PropContentType "\220",PropSharedSubscriptionAvailable -// 10,PropRequestResponseInformation 112,PropSubscriptionIdentifier 22,PropUserProperty -// "\DC2\227j\196\236X8\252*\170Z\b\181\251\&2" -// "\178\140\222\163\ACK\215\&7\183\251\242\251[G\ETX\183\EOTH\SIwD=\141\180j.",PropCorrelationData -// "z\193\213\200\146PY\156\&9m?\166\134\a\206\144!",PropResponseTopic -// "3\248\238\SOu\145=\226+Z,\SO\199E\143\229\220\250iH\145\235)\168y\129,E8\n",PropMessageExpiryInterval -// 12141,PropTopicAlias 4176,PropResponseTopic "gT\208c!\224\151",PropSubscriptionIdentifierAvailable -// 61,PropRequestResponseInformation 138]} -TEST(Publish50QCTest, Encode59) { - uint8_t pkt[] = {0x3b, 0xb4, 0x1, 0x0, 0xc, 0x4b, 0x23, 0x7, 0x5a, 0x56, 0x2c, 0x62, 0x6c, 0xa8, 0x83, 0xc5, 0x4e, - 0x73, 0x69, 0x9c, 0x1, 0x1c, 0x0, 0x3, 0xfd, 0xa1, 0xfd, 0x9, 0x0, 0x11, 0xf, 0xf1, 0xa9, 0xe5, - 0xba, 0xae, 0x3, 0x19, 0xa, 0xc1, 0xbd, 0x3e, 0xed, 0xd6, 0x55, 0x1b, 0x80, 0x3, 0x0, 0x1, 0xdc, - 0x2a, 0xa, 0x19, 0x70, 0xb, 0x16, 0x26, 0x0, 0xf, 0x12, 0xe3, 0x6a, 0xc4, 0xec, 0x58, 0x38, 0xfc, - 0x2a, 0xaa, 0x5a, 0x8, 0xb5, 0xfb, 0x32, 0x0, 0x19, 0xb2, 0x8c, 0xde, 0xa3, 0x6, 0xd7, 0x37, 0xb7, - 0xfb, 0xf2, 0xfb, 0x5b, 0x47, 0x3, 0xb7, 0x4, 0x48, 0xf, 0x77, 0x44, 0x3d, 0x8d, 0xb4, 0x6a, 0x2e, - 0x9, 0x0, 0x11, 0x7a, 0xc1, 0xd5, 0xc8, 0x92, 0x50, 0x59, 0x9c, 0x39, 0x6d, 0x3f, 0xa6, 0x86, 0x7, - 0xce, 0x90, 0x21, 0x8, 0x0, 0x1e, 0x33, 0xf8, 0xee, 0xe, 0x75, 0x91, 0x3d, 0xe2, 0x2b, 0x5a, 0x2c, - 0xe, 0xc7, 0x45, 0x8f, 0xe5, 0xdc, 0xfa, 0x69, 0x48, 0x91, 0xeb, 0x29, 0xa8, 0x79, 0x81, 0x2c, 0x45, - 0x38, 0xa, 0x2, 0x0, 0x0, 0x2f, 0x6d, 0x23, 0x10, 0x50, 0x8, 0x0, 0x7, 0x67, 0x54, 0xd0, 0x63, - 0x21, 0xe0, 0x97, 0x29, 0x3d, 0x19, 0x8a, 0x71, 0x98, 0xc6, 0x13, 0x76, 0x1f}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\161n\174\237\249", _pubPktID = 0, +// _pubBody = "YFq\199\251\158-\155S\194}\250\NULjMrM\ESC/6f\DC3\140", _pubProps = [PropMaximumQoS +// 255,PropAuthenticationData +// "!\241\DC4%K\DC1\226\&2\DLE\162\189\&7\190x\249\140\196\218$kI\167P\207\155\166x\132x\201",PropSubscriptionIdentifier +// 7,PropAuthenticationMethod +// "\"j_\212zR\159\CAN\207\248\207+b\159\DEL\EOT\163\225\203\192\NAK\129\240#\215\ACK'\185\155",PropServerReference +// "\SYNa{q&\206\\\245\177\195Mk",PropTopicAlias 14546,PropUserProperty +// "\237\STX\247\154?l\fK\189\242\234B\224\f\DC3\233\212\158\219\183\157\163\200\202\EOT" +// "\ACK\174",PropMessageExpiryInterval 18572,PropResponseInformation +// "\160\ACK\142\179\155\168\252(\235\128n2\249t\\=EiQ\202\SOH\ACK.\135\131\194",PropRequestProblemInformation +// 27,PropReceiveMaximum 31642,PropCorrelationData "~\143Y\242\NAK\FS\202\180\SO\137+\226\GS\205|\229",PropTopicAlias +// 1761,PropTopicAlias 14795,PropMessageExpiryInterval 9727]} +TEST(Publish5QCTest, Encode59) { + uint8_t pkt[] = { + 0x38, 0xdc, 0x1, 0x0, 0x5, 0xa1, 0x6e, 0xae, 0xed, 0xf9, 0xbc, 0x1, 0x24, 0xff, 0x16, 0x0, 0x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, 0x46, 0x71, 0xc7, 0xfb, 0x9e, 0x2d, 0x9b, 0x53, + 0xc2, 0x7d, 0xfa, 0x0, 0x6a, 0x4d, 0x72, 0x4d, 0x1b, 0x2f, 0x36, 0x66, 0x13, 0x8c}; - uint8_t buf[193] = {0}; + uint8_t buf[233] = {0}; - uint8_t topic_bytes[] = {0x4b, 0x23, 0x7, 0x5a, 0x56, 0x2c, 0x62, 0x6c, 0xa8, 0x83, 0xc5, 0x4e}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa1, 0x6e, 0xae, 0xed, 0xf9}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x71, 0x98, 0xc6, 0x13, 0x76, 0x1f}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x59, 0x46, 0x71, 0xc7, 0xfb, 0x9e, 0x2d, 0x9b, 0x53, 0xc2, 0x7d, 0xfa, + 0x0, 0x6a, 0x4d, 0x72, 0x4d, 0x1b, 0x2f, 0x36, 0x66, 0x13, 0x8c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 23; - uint8_t bytes0[] = {0xfd, 0xa1, 0xfd}; - uint8_t bytes1[] = {0xf, 0xf1, 0xa9, 0xe5, 0xba, 0xae, 0x3, 0x19, 0xa, - 0xc1, 0xbd, 0x3e, 0xed, 0xd6, 0x55, 0x1b, 0x80}; - uint8_t bytes2[] = {0xdc}; - uint8_t bytes4[] = {0xb2, 0x8c, 0xde, 0xa3, 0x6, 0xd7, 0x37, 0xb7, 0xfb, 0xf2, 0xfb, 0x5b, 0x47, - 0x3, 0xb7, 0x4, 0x48, 0xf, 0x77, 0x44, 0x3d, 0x8d, 0xb4, 0x6a, 0x2e}; - uint8_t bytes3[] = {0x12, 0xe3, 0x6a, 0xc4, 0xec, 0x58, 0x38, 0xfc, 0x2a, 0xaa, 0x5a, 0x8, 0xb5, 0xfb, 0x32}; - uint8_t bytes5[] = {0x7a, 0xc1, 0xd5, 0xc8, 0x92, 0x50, 0x59, 0x9c, 0x39, - 0x6d, 0x3f, 0xa6, 0x86, 0x7, 0xce, 0x90, 0x21}; - uint8_t bytes6[] = {0x33, 0xf8, 0xee, 0xe, 0x75, 0x91, 0x3d, 0xe2, 0x2b, 0x5a, 0x2c, 0xe, 0xc7, 0x45, 0x8f, - 0xe5, 0xdc, 0xfa, 0x69, 0x48, 0x91, 0xeb, 0x29, 0xa8, 0x79, 0x81, 0x2c, 0x45, 0x38, 0xa}; - uint8_t bytes7[] = {0x67, 0x54, 0xd0, 0x63, 0x21, 0xe0, 0x97}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytes3}, .v = {25, (char*)&bytes4}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12141}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4176}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, + uint8_t bytesprops0[] = {0x21, 0xf1, 0x14, 0x25, 0x4b, 0x11, 0xe2, 0x32, 0x10, 0xa2, 0xbd, 0x37, 0xbe, 0x78, 0xf9, + 0x8c, 0xc4, 0xda, 0x24, 0x6b, 0x49, 0xa7, 0x50, 0xcf, 0x9b, 0xa6, 0x78, 0x84, 0x78, 0xc9}; + uint8_t bytesprops1[] = {0x22, 0x6a, 0x5f, 0xd4, 0x7a, 0x52, 0x9f, 0x18, 0xcf, 0xf8, 0xcf, 0x2b, 0x62, 0x9f, 0x7f, + 0x4, 0xa3, 0xe1, 0xcb, 0xc0, 0x15, 0x81, 0xf0, 0x23, 0xd7, 0x6, 0x27, 0xb9, 0x9b}; + uint8_t bytesprops2[] = {0x16, 0x61, 0x7b, 0x71, 0x26, 0xce, 0x5c, 0xf5, 0xb1, 0xc3, 0x4d, 0x6b}; + uint8_t bytesprops4[] = {0x6, 0xae}; + uint8_t bytesprops3[] = {0xed, 0x2, 0xf7, 0x9a, 0x3f, 0x6c, 0xc, 0x4b, 0xbd, 0xf2, 0xea, 0x42, 0xe0, + 0xc, 0x13, 0xe9, 0xd4, 0x9e, 0xdb, 0xb7, 0x9d, 0xa3, 0xc8, 0xca, 0x4}; + uint8_t bytesprops5[] = {0xa0, 0x6, 0x8e, 0xb3, 0x9b, 0xa8, 0xfc, 0x28, 0xeb, 0x80, 0x6e, 0x32, 0xf9, + 0x74, 0x5c, 0x3d, 0x45, 0x69, 0x51, 0xca, 0x1, 0x6, 0x2e, 0x87, 0x83, 0xc2}; + uint8_t bytesprops6[] = {0x7e, 0x8f, 0x59, 0xf2, 0x15, 0x1c, 0xca, 0xb4, + 0xe, 0x89, 0x2b, 0xe2, 0x1d, 0xcd, 0x7c, 0xe5}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14546}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops3}, .v = {2, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18572}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31642}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1761}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14795}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9727}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29545, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\ETB./iLG\236\218\159\SOH\n\ESC\203\FSs", _pubPktID = 19215, _pubBody = -// "I\157\182\DEL\135\249\197]P>b\248\202r\201\180\226\179\255", _pubProps = [PropReasonString -// "\184\168\186\240\234w\SIjs2\217\133r&0Z\DC3-X",PropResponseTopic -// "\221\141\186A\131\ETX\SI\CAN\b\145c\222\DC1\EM",PropRequestResponseInformation 190,PropUserProperty -// "\132\175a9\148\t\220k\EOT\251\161" "\147\133\237C\234C\150\GS\SO\204\245",PropAuthenticationMethod -// "\ETX\251\177?\243\192/\156\149\253\164\205\191\234%\231\223O\184kK%\201\&1\139\211d",PropMessageExpiryInterval -// 20507,PropReasonString "w\132\228[\230\221g\234",PropRequestProblemInformation 10]} -TEST(Publish50QCTest, Encode60) { - uint8_t pkt[] = {0x34, 0x9b, 0x1, 0x0, 0xf, 0x17, 0x2e, 0x2f, 0x69, 0x4c, 0x47, 0xec, 0xda, 0x9f, 0x1, 0xa, - 0x1b, 0xcb, 0x1c, 0x73, 0x4b, 0xf, 0x74, 0x1f, 0x0, 0x13, 0xb8, 0xa8, 0xba, 0xf0, 0xea, 0x77, - 0xf, 0x6a, 0x73, 0x32, 0xd9, 0x85, 0x72, 0x26, 0x30, 0x5a, 0x13, 0x2d, 0x58, 0x8, 0x0, 0xe, - 0xdd, 0x8d, 0xba, 0x41, 0x83, 0x3, 0xf, 0x18, 0x8, 0x91, 0x63, 0xde, 0x11, 0x19, 0x19, 0xbe, - 0x26, 0x0, 0xb, 0x84, 0xaf, 0x61, 0x39, 0x94, 0x9, 0xdc, 0x6b, 0x4, 0xfb, 0xa1, 0x0, 0xb, - 0x93, 0x85, 0xed, 0x43, 0xea, 0x43, 0x96, 0x1d, 0xe, 0xcc, 0xf5, 0x15, 0x0, 0x1b, 0x3, 0xfb, - 0xb1, 0x3f, 0xf3, 0xc0, 0x2f, 0x9c, 0x95, 0xfd, 0xa4, 0xcd, 0xbf, 0xea, 0x25, 0xe7, 0xdf, 0x4f, - 0xb8, 0x6b, 0x4b, 0x25, 0xc9, 0x31, 0x8b, 0xd3, 0x64, 0x2, 0x0, 0x0, 0x50, 0x1b, 0x1f, 0x0, - 0x8, 0x77, 0x84, 0xe4, 0x5b, 0xe6, 0xdd, 0x67, 0xea, 0x17, 0xa, 0x49, 0x9d, 0xb6, 0x7f, 0x87, - 0xf9, 0xc5, 0x5d, 0x50, 0x3e, 0x62, 0xf8, 0xca, 0x72, 0xc9, 0xb4, 0xe2, 0xb3, 0xff}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 4694, _pubBody = +// "\137\179ML\236", _pubProps = [PropAssignedClientIdentifier "\206\DC4\RS\153\211c,\210UO\209R{o@{\184\147\195\183 +// \197(\129\129\232\250\GS\GS\250\ETX\238", _pubPktID = 15457, _pubBody = +// "f\244\166\DLE\197\195\242\206\199<\FS\ETB$\STX \236\135\235\232\196\229\b`n\216,v\233V\177", _pubProps = +// [PropServerReference +// "\189|\165\GS`\199\151O\183$\228Y\158(%Ym\176\229\241d\233\196\196\138\209\146\142",PropAuthenticationData +// "\153\167\232\&2",PropSharedSubscriptionAvailable 174,PropAuthenticationMethod "}/",PropWildcardSubscriptionAvailable +// 206,PropTopicAlias 32469,PropWillDelayInterval 18902,PropReasonString +// "\217\251\241\147@`\v-\a\253\209\184",PropWildcardSubscriptionAvailable 200,PropRequestResponseInformation +// 100,PropCorrelationData +// "{\185a\t\EM\234\142{oa\ESC\b?\209\t\138\"\194{dDx\157\SOH",PropSubscriptionIdentifierAvailable +// 97,PropCorrelationData "\232)BS\179l\175\196\GS",PropSubscriptionIdentifierAvailable 226,PropResponseInformation +// "\164\rp\193\236\186u\224\t\168q\230\166\153ngOL\"\USA\191\131\&2\\\252\142)\147\219",PropMessageExpiryInterval +// 3303,PropSharedSubscriptionAvailable 214,PropAuthenticationData +// "\249w\"\132\217[\255E\189\DLE^\a\197?\141%\224\RSJ\207\188Fd1\240v",PropSubscriptionIdentifierAvailable +// 177,PropResponseInformation "\160e\210P\218\248\ESC}\225\146\SUB\245$A\246\&3B\171\146\255Vk\ENQsZK"]} +TEST(Publish5QCTest, Encode64) { + uint8_t pkt[] = { + 0x3b, 0x90, 0x2, 0x0, 0x13, 0x88, 0xc7, 0x87, 0x85, 0xab, 0xfc, 0x2b, 0xd3, 0x64, 0x13, 0x5c, 0xaa, 0x3e, 0xfa, + 0x1d, 0x1d, 0xfa, 0x3, 0xee, 0x3c, 0x61, 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64, 0x31, 0xf0, 0x76, 0x29, 0xb1, 0x1a, 0x0, 0x1a, 0xa0, 0x65, 0xd2, 0x50, 0xda, 0xf8, 0x1b, 0x7d, 0xe1, + 0x92, 0x1a, 0xf5, 0x24, 0x41, 0xf6, 0x33, 0x42, 0xab, 0x92, 0xff, 0x56, 0x6b, 0x5, 0x73, 0x5a, 0x4b, 0x66, 0xf4, + 0xa6, 0x10, 0xc5, 0xc3, 0xf2, 0xce, 0xc7, 0x3c, 0x1c, 0x17, 0x24, 0x2, 0x20, 0xec, 0x87, 0xeb, 0xe8, 0xc4, 0xe5, + 0x8, 0x60, 0x6e, 0xd8, 0x2c, 0x76, 0xe9, 0x56, 0xb1}; + + uint8_t buf[285] = {0}; + + uint8_t topic_bytes[] = {0x88, 0xc7, 0x87, 0x85, 0xab, 0xfc, 0x2b, 0xd3, 0x64, 0x13, + 0x5c, 0xaa, 0x3e, 0xfa, 0x1d, 0x1d, 0xfa, 0x3, 0xee}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xf, 0x7b, 0xc0}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x66, 0xf4, 0xa6, 0x10, 0xc5, 0xc3, 0xf2, 0xce, 0xc7, 0x3c, 0x1c, 0x17, 0x24, 0x2, 0x20, + 0xec, 0x87, 0xeb, 0xe8, 0xc4, 0xe5, 0x8, 0x60, 0x6e, 0xd8, 0x2c, 0x76, 0xe9, 0x56, 0xb1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 30; - uint8_t bytes0[] = {0x6e, 0xf5, 0x0, 0x8, 0x84, 0xf3, 0x93, 0xab, 0x1f, 0x3a, 0xfc, 0xae, - 0x6a, 0xfc, 0xee, 0xe3, 0x1f, 0x88, 0xde, 0x50, 0x2a, 0xcc, 0xe}; - uint8_t bytes2[] = {0x8a}; - uint8_t bytes1[] = {0xe, 0x35, 0xbd, 0x98, 0x72, 0xff, 0x82, 0x53, 0xf1, - 0x69, 0x8, 0x57, 0xb6, 0x85, 0x47, 0x5, 0xa4}; - uint8_t bytes3[] = {0xb9, 0x5e, 0x11, 0xa}; - uint8_t bytes4[] = {0xc3, 0xf1, 0xff, 0x9, 0x13, 0x9a, 0xe8, 0x4, 0x43, 0x97, 0xf7, 0x9f, 0x29}; - uint8_t bytes5[] = {0x2a, 0x7f, 0x8f, 0x19, 0xb6, 0x41, 0x8c, 0xa9, 0x62, 0x1, 0x8c, 0xdc, 0x54}; - uint8_t bytes6[] = {0xe, 0xaa, 0x8b, 0x9c, 0x76, 0x51, 0xa1, 0x95, 0x1b, 0x62, 0xc8, 0xe8}; - uint8_t bytes7[] = {0x4c, 0xa1, 0xe1, 0xde, 0x45, 0xad, 0x26, 0xcf, 0x35, 0x4d, 0xb1, 0xd1, - 0x4e, 0xc3, 0x73, 0xa1, 0xb5, 0x2f, 0x3c, 0x95, 0x93, 0x38, 0x9f, 0x2e}; - uint8_t bytes8[] = {0x16, 0xe7, 0x6c, 0x8c, 0xa, 0xe6, 0xfe, 0x77, 0xe4, 0xc3, 0x90, 0xf4, 0x81, - 0x18, 0x6f, 0xfa, 0x6a, 0x16, 0xb1, 0x76, 0xbe, 0x5c, 0x67, 0x88, 0x7b, 0x2e}; - uint8_t bytes9[] = {0x80, 0xfd, 0x88, 0x41}; - uint8_t bytes10[] = {0xb0}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20038}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16799}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytes1}, .v = {1, (char*)&bytes2}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10939}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29097}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26989}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10597}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3410}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6859}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytes8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytes9}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytes10}}}, + uint8_t bytesprops0[] = {0xbd, 0x7c, 0xa5, 0x1d, 0x60, 0xc7, 0x97, 0x4f, 0xb7, 0x24, 0xe4, 0x59, 0x9e, 0x28, + 0x25, 0x59, 0x6d, 0xb0, 0xe5, 0xf1, 0x64, 0xe9, 0xc4, 0xc4, 0x8a, 0xd1, 0x92, 0x8e}; + uint8_t bytesprops1[] = {0x99, 0xa7, 0xe8, 0x32}; + uint8_t bytesprops2[] = {0x7d, 0x2f}; + uint8_t bytesprops3[] = {0xd9, 0xfb, 0xf1, 0x93, 0x40, 0x60, 0xb, 0x2d, 0x7, 0xfd, 0xd1, 0xb8}; + uint8_t bytesprops4[] = {0x7b, 0xb9, 0x61, 0x9, 0x19, 0xea, 0x8e, 0x7b, 0x6f, 0x61, 0x1b, 0x8, + 0x3f, 0xd1, 0x9, 0x8a, 0x22, 0xc2, 0x7b, 0x64, 0x44, 0x78, 0x9d, 0x1}; + uint8_t bytesprops5[] = {0xe8, 0x29, 0x42, 0x53, 0xb3, 0x6c, 0xaf, 0xc4, 0x1d}; + uint8_t bytesprops6[] = {0xa4, 0xd, 0x70, 0xc1, 0xec, 0xba, 0x75, 0xe0, 0x9, 0xa8, 0x71, 0xe6, 0xa6, 0x99, 0x6e, + 0x67, 0x4f, 0x4c, 0x22, 0x1f, 0x41, 0xbf, 0x83, 0x32, 0x5c, 0xfc, 0x8e, 0x29, 0x93, 0xdb}; + uint8_t bytesprops7[] = {0xf9, 0x77, 0x22, 0x84, 0xd9, 0x5b, 0xff, 0x45, 0xbd, 0x10, 0x5e, 0x7, 0xc5, + 0x3f, 0x8d, 0x25, 0xe0, 0x1e, 0x4a, 0xcf, 0xbc, 0x46, 0x64, 0x31, 0xf0, 0x76}; + uint8_t bytesprops8[] = {0xa0, 0x65, 0xd2, 0x50, 0xda, 0xf8, 0x1b, 0x7d, 0xe1, 0x92, 0x1a, 0xf5, 0x24, + 0x41, 0xf6, 0x33, 0x42, 0xab, 0x92, 0xff, 0x56, 0x6b, 0x5, 0x73, 0x5a, 0x4b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32469}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18902}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3303}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 13139, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15457, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163]", _pubPktID = 9229, _pubBody = -// ":,\175v\152}\RS8\178|K\148\f\219\184\129Ep^\n\194\148\SOHv\\\ETB\253^", _pubProps = [PropRequestProblemInformation -// 195]} -TEST(Publish50QCTest, Encode65) { - uint8_t pkt[] = {0x3c, 0x25, 0x0, 0x2, 0xa3, 0x5d, 0x24, 0xd, 0x2, 0x17, 0xc3, 0x3a, 0x2c, - 0xaf, 0x76, 0x98, 0x7d, 0x1e, 0x38, 0xb2, 0x7c, 0x4b, 0x94, 0xc, 0xdb, 0xb8, - 0x81, 0x45, 0x70, 0x5e, 0xa, 0xc2, 0x94, 0x1, 0x76, 0x5c, 0x17, 0xfd, 0x5e}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 29420, _pubBody = +// "F\146\254\ETB\174Cu^\188$\218\201\215$\253\&7\184\236S\169\243\ETXn\180\US\fC\220\137\SYN", _pubProps = +// [PropSessionExpiryInterval 27347,PropServerKeepAlive 18294,PropTopicAliasMaximum 11531,PropAuthenticationMethod +// "\254\189\195{",PropResponseTopic +// "\CAN\139\240<\247\132\164F\228\&9w\DC3\139\221P'Y$\140\230\223S\247\149\206",PropMessageExpiryInterval +// 30913,PropSubscriptionIdentifier 6,PropAuthenticationMethod +// "\148\195\136\v\131\176\171\141\150@\f\f1\201",PropRetainAvailable 184,PropContentType "\158\bQU\201"]} +TEST(Publish5QCTest, Encode65) { + uint8_t pkt[] = {0x33, 0x73, 0x0, 0x0, 0x72, 0xec, 0x50, 0x11, 0x0, 0x0, 0x6a, 0xd3, 0x13, 0x47, 0x76, 0x22, 0x2d, + 0xb, 0x15, 0x0, 0x4, 0xfe, 0xbd, 0xc3, 0x7b, 0x8, 0x0, 0x19, 0x18, 0x8b, 0xf0, 0x3c, 0xf7, 0x84, + 0xa4, 0x46, 0xe4, 0x39, 0x77, 0x13, 0x8b, 0xdd, 0x50, 0x27, 0x59, 0x24, 0x8c, 0xe6, 0xdf, 0x53, 0xf7, + 0x95, 0xce, 0x2, 0x0, 0x0, 0x78, 0xc1, 0xb, 0x6, 0x15, 0x0, 0xe, 0x94, 0xc3, 0x88, 0xb, 0x83, + 0xb0, 0xab, 0x8d, 0x96, 0x40, 0xc, 0xc, 0x31, 0xc9, 0x25, 0xb8, 0x3, 0x0, 0x5, 0x9e, 0x8, 0x51, + 0x55, 0xc9, 0x46, 0x92, 0xfe, 0x17, 0xae, 0x43, 0x75, 0x5e, 0xbc, 0x24, 0xda, 0xc9, 0xd7, 0x24, 0xfd, + 0x37, 0xb8, 0xec, 0x53, 0xa9, 0xf3, 0x3, 0x6e, 0xb4, 0x1f, 0xc, 0x43, 0xdc, 0x89, 0x16}; - uint8_t buf[49] = {0}; + uint8_t buf[127] = {0}; - uint8_t topic_bytes[] = {0xa3, 0x5d}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x3a, 0x2c, 0xaf, 0x76, 0x98, 0x7d, 0x1e, 0x38, 0xb2, 0x7c, 0x4b, 0x94, 0xc, 0xdb, - 0xb8, 0x81, 0x45, 0x70, 0x5e, 0xa, 0xc2, 0x94, 0x1, 0x76, 0x5c, 0x17, 0xfd, 0x5e}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x46, 0x92, 0xfe, 0x17, 0xae, 0x43, 0x75, 0x5e, 0xbc, 0x24, 0xda, 0xc9, 0xd7, 0x24, 0xfd, + 0x37, 0xb8, 0xec, 0x53, 0xa9, 0xf3, 0x3, 0x6e, 0xb4, 0x1f, 0xc, 0x43, 0xdc, 0x89, 0x16}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 30; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, + uint8_t bytesprops0[] = {0xfe, 0xbd, 0xc3, 0x7b}; + uint8_t bytesprops1[] = {0x18, 0x8b, 0xf0, 0x3c, 0xf7, 0x84, 0xa4, 0x46, 0xe4, 0x39, 0x77, 0x13, 0x8b, + 0xdd, 0x50, 0x27, 0x59, 0x24, 0x8c, 0xe6, 0xdf, 0x53, 0xf7, 0x95, 0xce}; + uint8_t bytesprops2[] = {0x94, 0xc3, 0x88, 0xb, 0x83, 0xb0, 0xab, 0x8d, 0x96, 0x40, 0xc, 0xc, 0x31, 0xc9}; + uint8_t bytesprops3[] = {0x9e, 0x8, 0x51, 0x55, 0xc9}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27347}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18294}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11531}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30913}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 9229, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29420, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "'\148R\STX\207v\202o[1\154JIl\129\189\&9.\231\220u\233\200G\f \241\196M:", _pubPktID = 0, _pubBody = -// "\239\141wL\FS\241\255ZW8R\f\CAN\ACKT\215)ZZ\200z\239", _pubProps = []} -TEST(Publish50QCTest, Encode66) { - uint8_t pkt[] = {0x30, 0x37, 0x0, 0x1e, 0x27, 0x94, 0x52, 0x2, 0xcf, 0x76, 0xca, 0x6f, 0x5b, 0x31, 0x9a, - 0x4a, 0x49, 0x6c, 0x81, 0xbd, 0x39, 0x2e, 0xe7, 0xdc, 0x75, 0xe9, 0xc8, 0x47, 0xc, 0x20, - 0xf1, 0xc4, 0x4d, 0x3a, 0x0, 0xef, 0x8d, 0x77, 0x4c, 0x1c, 0xf1, 0xff, 0x5a, 0x57, 0x38, - 0x52, 0xc, 0x18, 0x6, 0x54, 0xd7, 0x29, 0x5a, 0x5a, 0xc8, 0x7a, 0xef}; - - uint8_t buf[67] = {0}; - - uint8_t topic_bytes[] = {0x27, 0x94, 0x52, 0x2, 0xcf, 0x76, 0xca, 0x6f, 0x5b, 0x31, 0x9a, 0x4a, 0x49, 0x6c, 0x81, - 0xbd, 0x39, 0x2e, 0xe7, 0xdc, 0x75, 0xe9, 0xc8, 0x47, 0xc, 0x20, 0xf1, 0xc4, 0x4d, 0x3a}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\220\DC4\187\155", _pubPktID = +// 28673, _pubBody = "\160\255\248\156YF\148S\164\194~\t\212\134\149`\202l", _pubProps = [PropPayloadFormatIndicator +// 176,PropWillDelayInterval 3215,PropReceiveMaximum 13425,PropReasonString +// "\216\221Ld\140\&1\193\179\163\NULN\204\151\ETB9\SO\143\153\216\ENQ\130\209()\139i\251\171",PropPayloadFormatIndicator +// 115,PropRequestProblemInformation 180,PropUserProperty +// "\241\SI\145\166\164v\239*\151\181.C?\198f\252\224\153O\190@Q\"\226r\239u\152\194\249" +// "\222\r\236IU\t\175M\165F\168zy\202\SYN2\172\228\253\250\SI\178M\130\bSj\180",PropUserProperty +// "\229Sk\DELQ\173\163\FS7\142\131\NAKU\204\132\180" +// "\232\155\&6&\185Z\178\DC4\231i'$\185\132\SOH$Qf\ETBPp\249\250",PropResponseTopic +// "\150^\217u\190\b\a\SO\139\250\&6\NAK\199|/\164`\147\164\247\&5gU\214\185",PropSharedSubscriptionAvailable +// 227,PropMaximumQoS 172,PropMaximumQoS 108,PropWillDelayInterval 7918,PropMaximumPacketSize 10821]} +TEST(Publish5QCTest, Encode66) { + uint8_t pkt[] = { + 0x35, 0xe1, 0x1, 0x0, 0x5, 0xfd, 0xdc, 0x14, 0xbb, 0x9b, 0x70, 0x1, 0xc4, 0x1, 0x1, 0xb0, 0x18, 0x0, 0x0, + 0xc, 0x8f, 0x21, 0x34, 0x71, 0x1f, 0x0, 0x1c, 0xd8, 0xdd, 0x4c, 0x64, 0x8c, 0x31, 0xc1, 0xb3, 0xa3, 0x0, 0x4e, + 0xcc, 0x97, 0x17, 0x39, 0xe, 0x8f, 0x99, 0xd8, 0x5, 0x82, 0xd1, 0x28, 0x29, 0x8b, 0x69, 0xfb, 0xab, 0x1, 0x73, + 0x17, 0xb4, 0x26, 0x0, 0x1e, 0xf1, 0xf, 0x91, 0xa6, 0xa4, 0x76, 0xef, 0x2a, 0x97, 0xb5, 0x2e, 0x43, 0x3f, 0xc6, + 0x66, 0xfc, 0xe0, 0x99, 0x4f, 0xbe, 0x40, 0x51, 0x22, 0xe2, 0x72, 0xef, 0x75, 0x98, 0xc2, 0xf9, 0x0, 0x1c, 0xde, + 0xd, 0xec, 0x49, 0x55, 0x9, 0xaf, 0x4d, 0xa5, 0x46, 0xa8, 0x7a, 0x79, 0xca, 0x16, 0x32, 0xac, 0xe4, 0xfd, 0xfa, + 0xf, 0xb2, 0x4d, 0x82, 0x8, 0x53, 0x6a, 0xb4, 0x26, 0x0, 0x10, 0xe5, 0x53, 0x6b, 0x7f, 0x51, 0xad, 0xa3, 0x1c, + 0x37, 0x8e, 0x83, 0x15, 0x55, 0xcc, 0x84, 0xb4, 0x0, 0x17, 0xe8, 0x9b, 0x36, 0x26, 0xb9, 0x5a, 0xb2, 0x14, 0xe7, + 0x69, 0x27, 0x24, 0xb9, 0x84, 0x1, 0x24, 0x51, 0x66, 0x17, 0x50, 0x70, 0xf9, 0xfa, 0x8, 0x0, 0x19, 0x96, 0x5e, + 0xd9, 0x75, 0xbe, 0x8, 0x7, 0xe, 0x8b, 0xfa, 0x36, 0x15, 0xc7, 0x7c, 0x2f, 0xa4, 0x60, 0x93, 0xa4, 0xf7, 0x35, + 0x67, 0x55, 0xd6, 0xb9, 0x2a, 0xe3, 0x24, 0xac, 0x24, 0x6c, 0x18, 0x0, 0x0, 0x1e, 0xee, 0x27, 0x0, 0x0, 0x2a, + 0x45, 0xa0, 0xff, 0xf8, 0x9c, 0x59, 0x46, 0x94, 0x53, 0xa4, 0xc2, 0x7e, 0x9, 0xd4, 0x86, 0x95, 0x60, 0xca, 0x6c}; + + uint8_t buf[238] = {0}; + + uint8_t topic_bytes[] = {0xfd, 0xdc, 0x14, 0xbb, 0x9b}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xef, 0x8d, 0x77, 0x4c, 0x1c, 0xf1, 0xff, 0x5a, 0x57, 0x38, 0x52, - 0xc, 0x18, 0x6, 0x54, 0xd7, 0x29, 0x5a, 0x5a, 0xc8, 0x7a, 0xef}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa0, 0xff, 0xf8, 0x9c, 0x59, 0x46, 0x94, 0x53, 0xa4, + 0xc2, 0x7e, 0x9, 0xd4, 0x86, 0x95, 0x60, 0xca, 0x6c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 18; - lwmqtt_property_t proplist[] = {}; + uint8_t bytesprops0[] = {0xd8, 0xdd, 0x4c, 0x64, 0x8c, 0x31, 0xc1, 0xb3, 0xa3, 0x0, 0x4e, 0xcc, 0x97, 0x17, + 0x39, 0xe, 0x8f, 0x99, 0xd8, 0x5, 0x82, 0xd1, 0x28, 0x29, 0x8b, 0x69, 0xfb, 0xab}; + uint8_t bytesprops2[] = {0xde, 0xd, 0xec, 0x49, 0x55, 0x9, 0xaf, 0x4d, 0xa5, 0x46, 0xa8, 0x7a, 0x79, 0xca, + 0x16, 0x32, 0xac, 0xe4, 0xfd, 0xfa, 0xf, 0xb2, 0x4d, 0x82, 0x8, 0x53, 0x6a, 0xb4}; + uint8_t bytesprops1[] = {0xf1, 0xf, 0x91, 0xa6, 0xa4, 0x76, 0xef, 0x2a, 0x97, 0xb5, 0x2e, 0x43, 0x3f, 0xc6, 0x66, + 0xfc, 0xe0, 0x99, 0x4f, 0xbe, 0x40, 0x51, 0x22, 0xe2, 0x72, 0xef, 0x75, 0x98, 0xc2, 0xf9}; + uint8_t bytesprops4[] = {0xe8, 0x9b, 0x36, 0x26, 0xb9, 0x5a, 0xb2, 0x14, 0xe7, 0x69, 0x27, 0x24, + 0xb9, 0x84, 0x1, 0x24, 0x51, 0x66, 0x17, 0x50, 0x70, 0xf9, 0xfa}; + uint8_t bytesprops3[] = {0xe5, 0x53, 0x6b, 0x7f, 0x51, 0xad, 0xa3, 0x1c, + 0x37, 0x8e, 0x83, 0x15, 0x55, 0xcc, 0x84, 0xb4}; + uint8_t bytesprops5[] = {0x96, 0x5e, 0xd9, 0x75, 0xbe, 0x8, 0x7, 0xe, 0x8b, 0xfa, 0x36, 0x15, 0xc7, + 0x7c, 0x2f, 0xa4, 0x60, 0x93, 0xa4, 0xf7, 0x35, 0x67, 0x55, 0xd6, 0xb9}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3215}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13425}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops1}, .v = {28, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {23, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7918}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10821}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 28673, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "9\140\202\235A\137*\ESC\202=k\179\211?\NAK\238", _pubPktID = 0, _pubBody = -// "R\140Q\187\192\240\209=*\152Ov\136\254G\251", _pubProps = [PropSessionExpiryInterval 12836,PropReasonString -// "\212\&7L\201\&2RS\250\130\218\228X\171\197",PropPayloadFormatIndicator 191,PropAssignedClientIdentifier -// "\132Z\DC2^H\ti\DC2b{VW\DLE\237\193\236y\207\132\236\133\&2\247\230\185j\233",PropMessageExpiryInterval -// 20000,PropAssignedClientIdentifier "\235\132",PropSubscriptionIdentifierAvailable 255,PropAssignedClientIdentifier -// "\\!\192"]} -TEST(Publish50QCTest, Encode67) { - uint8_t pkt[] = {0x38, 0x6b, 0x0, 0x10, 0x39, 0x8c, 0xca, 0xeb, 0x41, 0x89, 0x2a, 0x1b, 0xca, 0x3d, 0x6b, 0xb3, - 0xd3, 0x3f, 0x15, 0xee, 0x48, 0x11, 0x0, 0x0, 0x32, 0x24, 0x1f, 0x0, 0xe, 0xd4, 0x37, 0x4c, - 0xc9, 0x32, 0x52, 0x53, 0xfa, 0x82, 0xda, 0xe4, 0x58, 0xab, 0xc5, 0x1, 0xbf, 0x12, 0x0, 0x1b, - 0x84, 0x5a, 0x12, 0x5e, 0x48, 0x9, 0x69, 0x12, 0x62, 0x7b, 0x56, 0x57, 0x10, 0xed, 0xc1, 0xec, - 0x79, 0xcf, 0x84, 0xec, 0x85, 0x32, 0xf7, 0xe6, 0xb9, 0x6a, 0xe9, 0x2, 0x0, 0x0, 0x4e, 0x20, - 0x12, 0x0, 0x2, 0xeb, 0x84, 0x29, 0xff, 0x12, 0x0, 0x3, 0x5c, 0x21, 0xc0, 0x52, 0x8c, 0x51, - 0xbb, 0xc0, 0xf0, 0xd1, 0x3d, 0x2a, 0x98, 0x4f, 0x76, 0x88, 0xfe, 0x47, 0xfb}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\141\195\131\143\248w\207", +// _pubPktID = 574, _pubBody = "x\\\156a}\224\130S\US%\153\187\181\217\RS\201{", _pubProps = [PropMaximumQoS +// 87,PropRequestProblemInformation 231,PropUserProperty "\171\248\247\215S\157" "1\GS\241wj\178\191_\130\240[Z\ACK"]} +TEST(Publish5QCTest, Encode67) { + uint8_t pkt[] = {0x33, 0x39, 0x0, 0x7, 0x8d, 0xc3, 0x83, 0x8f, 0xf8, 0x77, 0xcf, 0x2, 0x3e, 0x1c, 0x24, + 0x57, 0x17, 0xe7, 0x26, 0x0, 0x6, 0xab, 0xf8, 0xf7, 0xd7, 0x53, 0x9d, 0x0, 0xd, 0x31, + 0x1d, 0xf1, 0x77, 0x6a, 0xb2, 0xbf, 0x5f, 0x82, 0xf0, 0x5b, 0x5a, 0x6, 0x78, 0x5c, 0x9c, + 0x61, 0x7d, 0xe0, 0x82, 0x53, 0x1f, 0x25, 0x99, 0xbb, 0xb5, 0xd9, 0x1e, 0xc9, 0x7b}; - uint8_t buf[119] = {0}; + uint8_t buf[69] = {0}; - uint8_t topic_bytes[] = {0x39, 0x8c, 0xca, 0xeb, 0x41, 0x89, 0x2a, 0x1b, - 0xca, 0x3d, 0x6b, 0xb3, 0xd3, 0x3f, 0x15, 0xee}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x8d, 0xc3, 0x83, 0x8f, 0xf8, 0x77, 0xcf}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x52, 0x8c, 0x51, 0xbb, 0xc0, 0xf0, 0xd1, 0x3d, - 0x2a, 0x98, 0x4f, 0x76, 0x88, 0xfe, 0x47, 0xfb}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x78, 0x5c, 0x9c, 0x61, 0x7d, 0xe0, 0x82, 0x53, 0x1f, + 0x25, 0x99, 0xbb, 0xb5, 0xd9, 0x1e, 0xc9, 0x7b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 17; - uint8_t bytes0[] = {0xd4, 0x37, 0x4c, 0xc9, 0x32, 0x52, 0x53, 0xfa, 0x82, 0xda, 0xe4, 0x58, 0xab, 0xc5}; - uint8_t bytes1[] = {0x84, 0x5a, 0x12, 0x5e, 0x48, 0x9, 0x69, 0x12, 0x62, 0x7b, 0x56, 0x57, 0x10, 0xed, - 0xc1, 0xec, 0x79, 0xcf, 0x84, 0xec, 0x85, 0x32, 0xf7, 0xe6, 0xb9, 0x6a, 0xe9}; - uint8_t bytes2[] = {0xeb, 0x84}; - uint8_t bytes3[] = {0x5c, 0x21, 0xc0}; + uint8_t bytesprops1[] = {0x31, 0x1d, 0xf1, 0x77, 0x6a, 0xb2, 0xbf, 0x5f, 0x82, 0xf0, 0x5b, 0x5a, 0x6}; + uint8_t bytesprops0[] = {0xab, 0xf8, 0xf7, 0xd7, 0x53, 0x9d}; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12836}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20000}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytes3}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 574, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\255\250\242r^\171,{\253\254\200\128\135\225AG\149\&3", _pubPktID = 19170, _pubBody = "\GS", _pubProps = -// [PropSharedSubscriptionAvailable 230,PropSubscriptionIdentifier 28,PropSessionExpiryInterval -// 9477,PropRequestResponseInformation 163,PropMessageExpiryInterval 21809,PropSessionExpiryInterval -// 8934,PropResponseTopic "\199<",PropUserProperty -// "\129\ETX\208\ETB\196\158Qu\159\148\214\188\150\178\245\221\132'\211\210Y3P?\213\203>\FS\CAN\254" -// "\163Q\173\EM\170\129!C\233Q\SYN\222A\247\188\DLEi\212Q&\DC3f\210\EOT)\247|",PropMaximumPacketSize -// 16084,PropReasonString -// "\178qh\NUL\211\202\136\v{\236\\\230\164^\174A\145]\225\172f\226\&6\180\&2\153",PropServerKeepAlive -// 25512,PropMaximumPacketSize 3094,PropSessionExpiryInterval 15014,PropAssignedClientIdentifier -// "G\195%\131\199\242(\164v\GSB\v<\196\189\157\239\176\212\&5",PropRequestProblemInformation 144,PropRetainAvailable -// 71,PropWillDelayInterval 2627,PropReceiveMaximum 5184,PropPayloadFormatIndicator 224,PropMaximumPacketSize -// 19270,PropResponseTopic "\129-",PropResponseTopic -// "\185\237\209\&5,!n\140\229\238\NUL\134\185\187&\156\NUL\146\218\154",PropCorrelationData -// "l\248\NUL\229\&1\216\236\166i\253\ETX\n\171if1\180\130\DC4\192\209\198\146",PropRequestResponseInformation 61]} -TEST(Publish50QCTest, Encode68) { - uint8_t pkt[] = { - 0x35, 0x82, 0x2, 0x0, 0x12, 0xff, 0xfa, 0xf2, 0x72, 0x5e, 0xab, 0x2c, 0x7b, 0xfd, 0xfe, 0xc8, 0x80, 0x87, 0xe1, - 0x41, 0x47, 0x95, 0x33, 0x4a, 0xe2, 0xe9, 0x1, 0x2a, 0xe6, 0xb, 0x1c, 0x11, 0x0, 0x0, 0x25, 0x5, 0x19, 0xa3, - 0x2, 0x0, 0x0, 0x55, 0x31, 0x11, 0x0, 0x0, 0x22, 0xe6, 0x8, 0x0, 0x2, 0xc7, 0x3c, 0x26, 0x0, 0x1e, 0x81, - 0x3, 0xd0, 0x17, 0xc4, 0x9e, 0x51, 0x75, 0x9f, 0x94, 0xd6, 0xbc, 0x96, 0xb2, 0xf5, 0xdd, 0x84, 0x27, 0xd3, 0xd2, - 0x59, 0x33, 0x50, 0x3f, 0xd5, 0xcb, 0x3e, 0x1c, 0x18, 0xfe, 0x0, 0x1b, 0xa3, 0x51, 0xad, 0x19, 0xaa, 0x81, 0x21, - 0x43, 0xe9, 0x51, 0x16, 0xde, 0x41, 0xf7, 0xbc, 0x10, 0x69, 0xd4, 0x51, 0x26, 0x13, 0x66, 0xd2, 0x4, 0x29, 0xf7, - 0x7c, 0x27, 0x0, 0x0, 0x3e, 0xd4, 0x1f, 0x0, 0x1a, 0xb2, 0x71, 0x68, 0x0, 0xd3, 0xca, 0x88, 0xb, 0x7b, 0xec, - 0x5c, 0xe6, 0xa4, 0x5e, 0xae, 0x41, 0x91, 0x5d, 0xe1, 0xac, 0x66, 0xe2, 0x36, 0xb4, 0x32, 0x99, 0x13, 0x63, 0xa8, - 0x27, 0x0, 0x0, 0xc, 0x16, 0x11, 0x0, 0x0, 0x3a, 0xa6, 0x12, 0x0, 0x14, 0x47, 0xc3, 0x25, 0x83, 0xc7, 0xf2, - 0x28, 0xa4, 0x76, 0x1d, 0x42, 0xb, 0x3c, 0xc4, 0xbd, 0x9d, 0xef, 0xb0, 0xd4, 0x35, 0x17, 0x90, 0x25, 0x47, 0x18, - 0x0, 0x0, 0xa, 0x43, 0x21, 0x14, 0x40, 0x1, 0xe0, 0x27, 0x0, 0x0, 0x4b, 0x46, 0x8, 0x0, 0x2, 0x81, 0x2d, - 0x8, 0x0, 0x14, 0xb9, 0xed, 0xd1, 0x35, 0x2c, 0x21, 0x6e, 0x8c, 0xe5, 0xee, 0x0, 0x86, 0xb9, 0xbb, 0x26, 0x9c, - 0x0, 0x92, 0xda, 0x9a, 0x9, 0x0, 0x17, 0x6c, 0xf8, 0x0, 0xe5, 0x31, 0xd8, 0xec, 0xa6, 0x69, 0xfd, 0x3, 0xa, - 0xab, 0x69, 0x66, 0x31, 0xb4, 0x82, 0x14, 0xc0, 0xd1, 0xc6, 0x92, 0x19, 0x3d, 0x1d}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "Mq\234\146\239\150W\FS1\177", +// _pubPktID = 0, _pubBody = "0\141\201\&8\139\&4\ETX>\239\RS\238\229t\225\198|\194W\186]\200\244|\171\DLE\163\193", +// _pubProps = [PropMaximumPacketSize 8091,PropTopicAliasMaximum 14682,PropUserProperty +// "\170`[\143\144<\181\138\154\150\&2[" "\197\171U(\DC1\249:aYH\248\175\t:\209 hc\210\222",PropCorrelationData +// "\169\207;\130S!n\178\ESC\247-\218\220w\225\176\140\252",PropRequestProblemInformation +// 89,PropSubscriptionIdentifierAvailable 119,PropAssignedClientIdentifier ">n\204\133\&0q",PropRetainAvailable +// 145,PropRequestResponseInformation 157]} +TEST(Publish5QCTest, Encode68) { + uint8_t pkt[] = {0x38, 0x7b, 0x0, 0xa, 0x4d, 0x71, 0xea, 0x92, 0xef, 0x96, 0x57, 0x1c, 0x31, 0xb1, 0x53, 0x27, + 0x0, 0x0, 0x1f, 0x9b, 0x22, 0x39, 0x5a, 0x26, 0x0, 0xc, 0xaa, 0x60, 0x5b, 0x8f, 0x90, 0x3c, + 0xb5, 0x8a, 0x9a, 0x96, 0x32, 0x5b, 0x0, 0x14, 0xc5, 0xab, 0x55, 0x28, 0x11, 0xf9, 0x3a, 0x61, + 0x59, 0x48, 0xf8, 0xaf, 0x9, 0x3a, 0xd1, 0x20, 0x68, 0x63, 0xd2, 0xde, 0x9, 0x0, 0x12, 0xa9, + 0xcf, 0x3b, 0x82, 0x53, 0x21, 0x6e, 0xb2, 0x1b, 0xf7, 0x2d, 0xda, 0xdc, 0x77, 0xe1, 0xb0, 0x8c, + 0xfc, 0x17, 0x59, 0x29, 0x77, 0x12, 0x0, 0x6, 0x3e, 0x6e, 0xcc, 0x85, 0x30, 0x71, 0x25, 0x91, + 0x19, 0x9d, 0x30, 0x8d, 0xc9, 0x38, 0x8b, 0x34, 0x3, 0x3e, 0xef, 0x1e, 0xee, 0xe5, 0x74, 0xe1, + 0xc6, 0x7c, 0xc2, 0x57, 0xba, 0x5d, 0xc8, 0xf4, 0x7c, 0xab, 0x10, 0xa3, 0xc1}; - uint8_t buf[271] = {0}; + uint8_t buf[135] = {0}; - uint8_t topic_bytes[] = {0xff, 0xfa, 0xf2, 0x72, 0x5e, 0xab, 0x2c, 0x7b, 0xfd, - 0xfe, 0xc8, 0x80, 0x87, 0xe1, 0x41, 0x47, 0x95, 0x33}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x4d, 0x71, 0xea, 0x92, 0xef, 0x96, 0x57, 0x1c, 0x31, 0xb1}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x1d}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x30, 0x8d, 0xc9, 0x38, 0x8b, 0x34, 0x3, 0x3e, 0xef, 0x1e, 0xee, 0xe5, 0x74, 0xe1, + 0xc6, 0x7c, 0xc2, 0x57, 0xba, 0x5d, 0xc8, 0xf4, 0x7c, 0xab, 0x10, 0xa3, 0xc1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 27; - uint8_t bytes0[] = {0xc7, 0x3c}; - uint8_t bytes2[] = {0xa3, 0x51, 0xad, 0x19, 0xaa, 0x81, 0x21, 0x43, 0xe9, 0x51, 0x16, 0xde, 0x41, 0xf7, - 0xbc, 0x10, 0x69, 0xd4, 0x51, 0x26, 0x13, 0x66, 0xd2, 0x4, 0x29, 0xf7, 0x7c}; - uint8_t bytes1[] = {0x81, 0x3, 0xd0, 0x17, 0xc4, 0x9e, 0x51, 0x75, 0x9f, 0x94, 0xd6, 0xbc, 0x96, 0xb2, 0xf5, - 0xdd, 0x84, 0x27, 0xd3, 0xd2, 0x59, 0x33, 0x50, 0x3f, 0xd5, 0xcb, 0x3e, 0x1c, 0x18, 0xfe}; - uint8_t bytes3[] = {0xb2, 0x71, 0x68, 0x0, 0xd3, 0xca, 0x88, 0xb, 0x7b, 0xec, 0x5c, 0xe6, 0xa4, - 0x5e, 0xae, 0x41, 0x91, 0x5d, 0xe1, 0xac, 0x66, 0xe2, 0x36, 0xb4, 0x32, 0x99}; - uint8_t bytes4[] = {0x47, 0xc3, 0x25, 0x83, 0xc7, 0xf2, 0x28, 0xa4, 0x76, 0x1d, - 0x42, 0xb, 0x3c, 0xc4, 0xbd, 0x9d, 0xef, 0xb0, 0xd4, 0x35}; - uint8_t bytes5[] = {0x81, 0x2d}; - uint8_t bytes6[] = {0xb9, 0xed, 0xd1, 0x35, 0x2c, 0x21, 0x6e, 0x8c, 0xe5, 0xee, - 0x0, 0x86, 0xb9, 0xbb, 0x26, 0x9c, 0x0, 0x92, 0xda, 0x9a}; - uint8_t bytes7[] = {0x6c, 0xf8, 0x0, 0xe5, 0x31, 0xd8, 0xec, 0xa6, 0x69, 0xfd, 0x3, 0xa, - 0xab, 0x69, 0x66, 0x31, 0xb4, 0x82, 0x14, 0xc0, 0xd1, 0xc6, 0x92}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9477}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21809}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8934}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytes1}, .v = {27, (char*)&bytes2}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16084}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25512}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3094}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15014}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2627}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5184}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19270}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 61}}, + uint8_t bytesprops1[] = {0xc5, 0xab, 0x55, 0x28, 0x11, 0xf9, 0x3a, 0x61, 0x59, 0x48, + 0xf8, 0xaf, 0x9, 0x3a, 0xd1, 0x20, 0x68, 0x63, 0xd2, 0xde}; + uint8_t bytesprops0[] = {0xaa, 0x60, 0x5b, 0x8f, 0x90, 0x3c, 0xb5, 0x8a, 0x9a, 0x96, 0x32, 0x5b}; + uint8_t bytesprops2[] = {0xa9, 0xcf, 0x3b, 0x82, 0x53, 0x21, 0x6e, 0xb2, 0x1b, + 0xf7, 0x2d, 0xda, 0xdc, 0x77, 0xe1, 0xb0, 0x8c, 0xfc}; + uint8_t bytesprops3[] = {0x3e, 0x6e, 0xcc, 0x85, 0x30, 0x71}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8091}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14682}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19170, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\f<\223\175\243\197\227\253.l\204M\219\195\149\202\132\194\182\a\CAN\n9't=\191\DLEb", _pubPktID = 0, _pubBody = "", -// _pubProps = [PropTopicAlias 334,PropWildcardSubscriptionAvailable 17,PropSubscriptionIdentifier -// 0,PropMaximumPacketSize 32749,PropTopicAlias 3598,PropCorrelationData "",PropRetainAvailable -// 42,PropSessionExpiryInterval 32318,PropReasonString -// "\b\ENQ\138(U2\245\US\160X+l\225\b;\245\194\235\215",PropMessageExpiryInterval 21429,PropMessageExpiryInterval -// 13732,PropContentType "\195\&1\"",PropReceiveMaximum 17292,PropPayloadFormatIndicator 73,PropServerReference -// "X\CAN",PropSessionExpiryInterval 11644,PropMaximumPacketSize 8238,PropSubscriptionIdentifier -// 1,PropAuthenticationMethod "\246\190\168y\189\fU\139%\150w\236\255\134bw$#\156J",PropTopicAliasMaximum 15559]} -TEST(Publish50QCTest, Encode69) { - uint8_t pkt[] = {0x31, 0x8f, 0x1, 0x0, 0x1d, 0xc, 0x3c, 0xdf, 0xaf, 0xf3, 0xc5, 0xe3, 0xfd, 0x2e, 0x6c, 0xcc, 0x4d, - 0xdb, 0xc3, 0x95, 0xca, 0x84, 0xc2, 0xb6, 0x7, 0x18, 0xa, 0x39, 0x27, 0x74, 0x3d, 0xbf, 0x10, 0x62, - 0x6f, 0x23, 0x1, 0x4e, 0x28, 0x11, 0xb, 0x0, 0x27, 0x0, 0x0, 0x7f, 0xed, 0x23, 0xe, 0xe, 0x9, - 0x0, 0x0, 0x25, 0x2a, 0x11, 0x0, 0x0, 0x7e, 0x3e, 0x1f, 0x0, 0x13, 0x8, 0x5, 0x8a, 0x28, 0x55, - 0x32, 0xf5, 0x1f, 0xa0, 0x58, 0x2b, 0x6c, 0xe1, 0x8, 0x3b, 0xf5, 0xc2, 0xeb, 0xd7, 0x2, 0x0, 0x0, - 0x53, 0xb5, 0x2, 0x0, 0x0, 0x35, 0xa4, 0x3, 0x0, 0x3, 0xc3, 0x31, 0x22, 0x21, 0x43, 0x8c, 0x1, - 0x49, 0x1c, 0x0, 0x2, 0x58, 0x18, 0x11, 0x0, 0x0, 0x2d, 0x7c, 0x27, 0x0, 0x0, 0x20, 0x2e, 0xb, - 0x1, 0x15, 0x0, 0x14, 0xf6, 0xbe, 0xa8, 0x79, 0xbd, 0xc, 0x55, 0x8b, 0x25, 0x96, 0x77, 0xec, 0xff, - 0x86, 0x62, 0x77, 0x24, 0x23, 0x9c, 0x4a, 0x22, 0x3c, 0xc7}; - - uint8_t buf[156] = {0}; - - uint8_t topic_bytes[] = {0xc, 0x3c, 0xdf, 0xaf, 0xf3, 0xc5, 0xe3, 0xfd, 0x2e, 0x6c, 0xcc, 0x4d, 0xdb, 0xc3, 0x95, - 0xca, 0x84, 0xc2, 0xb6, 0x7, 0x18, 0xa, 0x39, 0x27, 0x74, 0x3d, 0xbf, 0x10, 0x62}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; - - uint8_t bytes0[] = {0}; - uint8_t bytes1[] = {0x8, 0x5, 0x8a, 0x28, 0x55, 0x32, 0xf5, 0x1f, 0xa0, 0x58, - 0x2b, 0x6c, 0xe1, 0x8, 0x3b, 0xf5, 0xc2, 0xeb, 0xd7}; - uint8_t bytes2[] = {0xc3, 0x31, 0x22}; - uint8_t bytes3[] = {0x58, 0x18}; - uint8_t bytes4[] = {0xf6, 0xbe, 0xa8, 0x79, 0xbd, 0xc, 0x55, 0x8b, 0x25, 0x96, - 0x77, 0xec, 0xff, 0x86, 0x62, 0x77, 0x24, 0x23, 0x9c, 0x4a}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 334}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32749}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3598}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32318}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21429}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13732}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17292}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11644}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8238}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15559}}, - }; - - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&proplist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "h\155\209\SYNBX\251\201\213\188", +// _pubPktID = 12728, _pubBody = "\SI\140\187\174(F\161\145", _pubProps = [PropWildcardSubscriptionAvailable +// 108,PropWildcardSubscriptionAvailable 247,PropMessageExpiryInterval 30096,PropCorrelationData +// "\138\254J\"~fp\SO\165\170\187\"\204'\182\RS"]} +TEST(Publish5QCTest, Encode69) { + uint8_t pkt[] = {0x3a, 0x33, 0x0, 0xa, 0x68, 0x9b, 0xd1, 0x16, 0x42, 0x58, 0xfb, 0xc9, 0xd5, 0xbc, + 0x31, 0xb8, 0x1c, 0x28, 0x6c, 0x28, 0xf7, 0x2, 0x0, 0x0, 0x75, 0x90, 0x9, 0x0, + 0x10, 0x8a, 0xfe, 0x4a, 0x22, 0x7e, 0x66, 0x70, 0xe, 0xa5, 0xaa, 0xbb, 0x22, 0xcc, + 0x27, 0xb6, 0x1e, 0xf, 0x8c, 0xbb, 0xae, 0x28, 0x46, 0xa1, 0x91}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[63] = {0}; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "3", _pubPktID = 27883, _pubBody = -// "\246\DC1,I\237\135\&0/\210\164\233\223de\144\250\141\134\&7\190\194\144\206f", _pubProps = [PropAuthenticationMethod -// "\195\194\210\230\229\150\219\249U\138\166",PropWillDelayInterval 14395,PropCorrelationData -// "\158\CAN\204\138JY\200L<\DLE\222\EM)\226\187\231\135\210b\213\210M\138",PropSharedSubscriptionAvailable -// 79,PropWildcardSubscriptionAvailable 151,PropSubscriptionIdentifier 14,PropRequestProblemInformation -// 161,PropMaximumPacketSize 1060,PropUserProperty "\DC3\DC4" -// "\194\228\135J\132\STX\142\240\151\232\&61\SUB\209\&9\196\239>\164\199\135*\DC4i\209U\249\141`",PropCorrelationData -// "\DEL\147\DC4\151\240\167\160",PropAuthenticationMethod ")\144K\213\b\184g\198\155\130\129\226\228",PropMaximumQoS -// 81,PropReceiveMaximum 31610,PropRetainAvailable 169,PropUserProperty "" -// "\STX3{\205\249\CAN\163\249\STX\163[\234w\171y\204\137\132LG\220o\136\232'\139",PropRequestProblemInformation -// 16,PropAuthenticationMethod "Mr\191c\DC3Cu\146",PropMessageExpiryInterval 9582,PropSubscriptionIdentifier -// 30,PropTopicAlias 11509,PropRetainAvailable 152,PropServerReference -// "\202\180om\130\155\ACK\SOH\132\133\GS60\180\192p\134\165XD\141",PropMaximumPacketSize 16715,PropServerKeepAlive -// 20089,PropRequestProblemInformation 33,PropAuthenticationMethod "[\147\255\210\188L\234",PropAuthenticationData -// "\245/\232\f\183\r\203n\143z\223<\DC3\169\173\183\253h\143\247\134b\129H\234",PropSubscriptionIdentifierAvailable -// 150,PropSubscriptionIdentifierAvailable 209,PropMessageExpiryInterval 29310]} -TEST(Publish50QCTest, Encode70) { - uint8_t pkt[] = { - 0x33, 0xa7, 0x2, 0x0, 0x1, 0x33, 0x6c, 0xeb, 0x88, 0x2, 0x15, 0x0, 0xb, 0xc3, 0xc2, 0xd2, 0xe6, 0xe5, 0x96, - 0xdb, 0xf9, 0x55, 0x8a, 0xa6, 0x18, 0x0, 0x0, 0x38, 0x3b, 0x9, 0x0, 0x17, 0x9e, 0x18, 0xcc, 0x8a, 0x4a, 0x59, - 0xc8, 0x4c, 0x3c, 0x10, 0xde, 0x19, 0x29, 0xe2, 0xbb, 0xe7, 0x87, 0xd2, 0x62, 0xd5, 0xd2,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0x2f, 0xe8, 0xc, 0xb7, 0xd, 0xcb, - 0x6e, 0x8f, 0x7a, 0xdf, 0x3c, 0x13, 0xa9, 0xad, 0xb7, 0xfd, 0x68, 0x8f, 0xf7, 0x86, 0x62, 0x81, 0x48, 0xea, 0x29, - 0x96, 0x29, 0xd1, 0x2, 0x0, 0x0, 0x72, 0x7e, 0xf6, 0x11, 0x2c, 0x49, 0xed, 0x87, 0x30, 0x2f, 0xd2, 0xa4, 0xe9, - 0xdf, 0x64, 0x65, 0x90, 0xfa, 0x8d, 0x86, 0x37, 0xbe, 0xc2, 0x90, 0xce, 0x66}; - - uint8_t buf[308] = {0}; - - uint8_t topic_bytes[] = {0x33}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x68, 0x9b, 0xd1, 0x16, 0x42, 0x58, 0xfb, 0xc9, 0xd5, 0xbc}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xf6, 0x11, 0x2c, 0x49, 0xed, 0x87, 0x30, 0x2f, 0xd2, 0xa4, 0xe9, 0xdf, - 0x64, 0x65, 0x90, 0xfa, 0x8d, 0x86, 0x37, 0xbe, 0xc2, 0x90, 0xce, 0x66}; + msg.retained = false; + uint8_t msg_bytes[] = {0xf, 0x8c, 0xbb, 0xae, 0x28, 0x46, 0xa1, 0x91}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 8; - uint8_t bytes0[] = {0xc3, 0xc2, 0xd2, 0xe6, 0xe5, 0x96, 0xdb, 0xf9, 0x55, 0x8a, 0xa6}; - uint8_t bytes1[] = {0x9e, 0x18, 0xcc, 0x8a, 0x4a, 0x59, 0xc8, 0x4c, 0x3c, 0x10, 0xde, 0x19, - 0x29, 0xe2, 0xbb, 0xe7, 0x87, 0xd2, 0x62, 0xd5, 0xd2, 0x4d, 0x8a}; - uint8_t bytes3[] = {0xc2, 0xe4, 0x87, 0x4a, 0x84, 0x2, 0x8e, 0xf0, 0x97, 0xe8, 0x36, 0x31, 0x1a, 0xd1, 0x39, - 0xc4, 0xef, 0x3e, 0xa4, 0xc7, 0x87, 0x2a, 0x14, 0x69, 0xd1, 0x55, 0xf9, 0x8d, 0x60}; - uint8_t bytes2[] = {0x13, 0x14}; - uint8_t bytes4[] = {0x7f, 0x93, 0x14, 0x97, 0xf0, 0xa7, 0xa0}; - uint8_t bytes5[] = {0x29, 0x90, 0x4b, 0xd5, 0x8, 0xb8, 0x67, 0xc6, 0x9b, 0x82, 0x81, 0xe2, 0xe4}; - uint8_t bytes7[] = {0x2, 0x33, 0x7b, 0xcd, 0xf9, 0x18, 0xa3, 0xf9, 0x2, 0xa3, 0x5b, 0xea, 0x77, - 0xab, 0x79, 0xcc, 0x89, 0x84, 0x4c, 0x47, 0xdc, 0x6f, 0x88, 0xe8, 0x27, 0x8b}; - uint8_t bytes6[] = {0}; - uint8_t bytes8[] = {0x4d, 0x72, 0xbf, 0x63, 0x13, 0x43, 0x75, 0x92}; - uint8_t bytes9[] = {0xca, 0xb4, 0x6f, 0x6d, 0x82, 0x9b, 0x6, 0x1, 0x84, 0x85, 0x1d, - 0x36, 0x30, 0xb4, 0xc0, 0x70, 0x86, 0xa5, 0x58, 0x44, 0x8d}; - uint8_t bytes10[] = {0x5b, 0x93, 0xff, 0xd2, 0xbc, 0x4c, 0xea}; - uint8_t bytes11[] = {0xf5, 0x2f, 0xe8, 0xc, 0xb7, 0xd, 0xcb, 0x6e, 0x8f, 0x7a, 0xdf, 0x3c, 0x13, - 0xa9, 0xad, 0xb7, 0xfd, 0x68, 0x8f, 0xf7, 0x86, 0x62, 0x81, 0x48, 0xea}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14395}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1060}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytes2}, .v = {29, (char*)&bytes3}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31610}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytes6}, .v = {26, (char*)&bytes7}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytes8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9582}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11509}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytes9}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16715}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20089}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytes10}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytes11}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29310}}, + uint8_t bytesprops0[] = {0x8a, 0xfe, 0x4a, 0x22, 0x7e, 0x66, 0x70, 0xe, + 0xa5, 0xaa, 0xbb, 0x22, 0xcc, 0x27, 0xb6, 0x1e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30096}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 27883, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 12728, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\210\n\244+\148\225\234\&5U\226r16\207\137\NAK}\GSX\204\250S\144\151b\224\184", _pubPktID = 20202, _pubBody = -// "\191\207\175uEn7\171\238\203\140\210I\200!", _pubProps = [PropPayloadFormatIndicator 182,PropMaximumPacketSize -// 28588,PropServerReference "j\171\148\SI\US\208\ENQ`Y;\139\177\US",PropContentType -// "<\SYNI\ACK\SYN\215\212\SUB\196.\133\r\240J\211"]} -TEST(Publish50QCTest, Encode71) { - uint8_t pkt[] = {0x3b, 0x58, 0x0, 0x1b, 0xd2, 0xa, 0xf4, 0x2b, 0x94, 0xe1, 0xea, 0x35, 0x55, 0xe2, 0x72, - 0x31, 0x36, 0xcf, 0x89, 0x15, 0x7d, 0x1d, 0x58, 0xcc, 0xfa, 0x53, 0x90, 0x97, 0x62, 0xe0, - 0xb8, 0x4e, 0xea, 0x29, 0x1, 0xb6, 0x27, 0x0, 0x0, 0x6f, 0xac, 0x1c, 0x0, 0xd, 0x6a, - 0xab, 0x94, 0xf, 0x1f, 0xd0, 0x5, 0x60, 0x59, 0x3b, 0x8b, 0xb1, 0x1f, 0x3, 0x0, 0xf, - 0x3c, 0x16, 0x49, 0x6, 0x16, 0xd7, 0xd4, 0x1a, 0xc4, 0x2e, 0x85, 0xd, 0xf0, 0x4a, 0xd3, - 0xbf, 0xcf, 0xaf, 0x75, 0x45, 0x6e, 0x37, 0xab, 0xee, 0xcb, 0x8c, 0xd2, 0x49, 0xc8, 0x21}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "kH\169\156\ACK\a\235\&2Q\128\148\FS\135\142\FS]\168j\246\208", _pubPktID = 23840, _pubBody = "D\195\164", _pubProps +// = [PropCorrelationData +// "\135\165\202T\199\STX\150\US&\171b\171\147\234\NUL*{(\215\227\252\218\246\168|:\154<\DC1",PropTopicAliasMaximum +// 16471,PropReasonString "'\135\228(\156\&3:\US3\186e\DC4",PropMaximumPacketSize 22772,PropAssignedClientIdentifier +// "5",PropServerReference "\173}\150\243\255\t\161\&0#\234",PropReceiveMaximum 5843,PropAuthenticationData +// "\219h\207s\DC37Y",PropMaximumPacketSize 14127,PropAssignedClientIdentifier +// "vn=}\185\245Z\DC3\201\170\ACK\171\212\210\157\NUL:\140\229g\SI1\ENQL",PropWildcardSubscriptionAvailable +// 204,PropCorrelationData +// ">\NAK\183\160ii\247\191\206\222j((\US6D6M\174\196g\212\223\222\234\166",PropMessageExpiryInterval +// 25815,PropRequestResponseInformation 149,PropSubscriptionIdentifierAvailable 115,PropMessageExpiryInterval +// 9063,PropRequestProblemInformation 12,PropMaximumPacketSize 4463,PropAuthenticationMethod +// "\ACK\205+\179\a&\224\183\200\146\142yk\181\r\GSJ\192:\236\&1\ETB\183",PropSharedSubscriptionAvailable +// 125,PropResponseTopic +// "\200\130\NUL\213\EM\208h\239\171D\202\134\178\ETBY\\\212(\157\&3c\173P9(",PropSubscriptionIdentifier +// 28,PropAuthenticationData "\135\183\NAK\DEL\245\189\162J\223\ESC",PropMaximumPacketSize 28065]} +TEST(Publish5QCTest, Encode70) { + uint8_t pkt[] = { + 0x33, 0x92, 0x2, 0x0, 0x14, 0x6b, 0x48, 0xa9, 0x9c, 0x6, 0x7, 0xeb, 0x32, 0x51, 0x80, 0x94, 0x1c, 0x87, 0x8e, + 0x1c, 0x5d, 0xa8, 0x6a, 0xf6, 0xd0, 0x5d, 0x20, 0xf5, 0x1, 0x9, 0x0, 0x1d, 0x87, 0xa5, 0xca, 0x54, 0xc7, 0x2, + 0x96, 0x1f, 0x26, 0xab, 0x62, 0xab, 0x93, 0xea, 0x0, 0x2a, 0x7b, 0x28, 0xd7, 0xe3, 0xfc, 0xda, 0xf6, 0xa8, 0x7c, + 0x3a, 0x9a, 0x3c, 0x11, 0x22, 0x40, 0x57, 0x1f, 0x0, 0xc, 0x27, 0x87, 0xe4, 0x28, 0x9c, 0x33, 0x3a, 0x1f, 0x33, + 0xba, 0x65, 0x14, 0x27, 0x0, 0x0, 0x58, 0xf4, 0x12, 0x0, 0x1, 0x35, 0x1c, 0x0, 0xa, 0xad, 0x7d, 0x96, 0xf3, + 0xff, 0x9, 0xa1, 0x30, 0x23, 0xea, 0x21, 0x16, 0xd3, 0x16, 0x0, 0x7, 0xdb, 0x68, 0xcf, 0x73, 0x13, 0x37, 0x59, + 0x27, 0x0, 0x0, 0x37, 0x2f, 0x12, 0x0, 0x18, 0x76, 0x6e, 0x3d, 0x7d, 0xb9, 0xf5, 0x5a, 0x13, 0xc9, 0xaa, 0x6, + 0xab, 0xd4, 0xd2, 0x9d, 0x0, 0x3a, 0x8c, 0xe5, 0x67, 0xf, 0x31, 0x5, 0x4c, 0x28, 0xcc, 0x9, 0x0, 0x1a, 0x3e, + 0x15, 0xb7, 0xa0, 0x69, 0x69, 0xf7, 0xbf, 0xce, 0xde, 0x6a, 0x28, 0x28, 0x1f, 0x36, 0x44, 0x36, 0x4d, 0xae, 0xc4, + 0x67, 0xd4, 0xdf, 0xde, 0xea, 0xa6, 0x2, 0x0, 0x0, 0x64, 0xd7, 0x19, 0x95, 0x29, 0x73, 0x2, 0x0, 0x0, 0x23, + 0x67, 0x17, 0xc, 0x27, 0x0, 0x0, 0x11, 0x6f, 0x15, 0x0, 0x17, 0x6, 0xcd, 0x2b, 0xb3, 0x7, 0x26, 0xe0, 0xb7, + 0xc8, 0x92, 0x8e, 0x79, 0x6b, 0xb5, 0xd, 0x1d, 0x4a, 0xc0, 0x3a, 0xec, 0x31, 0x17, 0xb7, 0x2a, 0x7d, 0x8, 0x0, + 0x19, 0xc8, 0x82, 0x0, 0xd5, 0x19, 0xd0, 0x68, 0xef, 0xab, 0x44, 0xca, 0x86, 0xb2, 0x17, 0x59, 0x5c, 0xd4, 0x28, + 0x9d, 0x33, 0x63, 0xad, 0x50, 0x39, 0x28, 0xb, 0x1c, 0x16, 0x0, 0xa, 0x87, 0xb7, 0x15, 0x7f, 0xf5, 0xbd, 0xa2, + 0x4a, 0xdf, 0x1b, 0x27, 0x0, 0x0, 0x6d, 0xa1, 0x44, 0xc3, 0xa4}; - uint8_t buf[100] = {0}; + uint8_t buf[287] = {0}; - uint8_t topic_bytes[] = {0xd2, 0xa, 0xf4, 0x2b, 0x94, 0xe1, 0xea, 0x35, 0x55, 0xe2, 0x72, 0x31, 0x36, 0xcf, - 0x89, 0x15, 0x7d, 0x1d, 0x58, 0xcc, 0xfa, 0x53, 0x90, 0x97, 0x62, 0xe0, 0xb8}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x6b, 0x48, 0xa9, 0x9c, 0x6, 0x7, 0xeb, 0x32, 0x51, 0x80, + 0x94, 0x1c, 0x87, 0x8e, 0x1c, 0x5d, 0xa8, 0x6a, 0xf6, 0xd0}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xbf, 0xcf, 0xaf, 0x75, 0x45, 0x6e, 0x37, 0xab, 0xee, 0xcb, 0x8c, 0xd2, 0x49, 0xc8, 0x21}; + uint8_t msg_bytes[] = {0x44, 0xc3, 0xa4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytes0[] = {0x6a, 0xab, 0x94, 0xf, 0x1f, 0xd0, 0x5, 0x60, 0x59, 0x3b, 0x8b, 0xb1, 0x1f}; - uint8_t bytes1[] = {0x3c, 0x16, 0x49, 0x6, 0x16, 0xd7, 0xd4, 0x1a, 0xc4, 0x2e, 0x85, 0xd, 0xf0, 0x4a, 0xd3}; + msg.payload_len = 3; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28588}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytes1}}}, + uint8_t bytesprops0[] = {0x87, 0xa5, 0xca, 0x54, 0xc7, 0x2, 0x96, 0x1f, 0x26, 0xab, 0x62, 0xab, 0x93, 0xea, 0x0, + 0x2a, 0x7b, 0x28, 0xd7, 0xe3, 0xfc, 0xda, 0xf6, 0xa8, 0x7c, 0x3a, 0x9a, 0x3c, 0x11}; + uint8_t bytesprops1[] = {0x27, 0x87, 0xe4, 0x28, 0x9c, 0x33, 0x3a, 0x1f, 0x33, 0xba, 0x65, 0x14}; + uint8_t bytesprops2[] = {0x35}; + uint8_t bytesprops3[] = {0xad, 0x7d, 0x96, 0xf3, 0xff, 0x9, 0xa1, 0x30, 0x23, 0xea}; + uint8_t bytesprops4[] = {0xdb, 0x68, 0xcf, 0x73, 0x13, 0x37, 0x59}; + uint8_t bytesprops5[] = {0x76, 0x6e, 0x3d, 0x7d, 0xb9, 0xf5, 0x5a, 0x13, 0xc9, 0xaa, 0x6, 0xab, + 0xd4, 0xd2, 0x9d, 0x0, 0x3a, 0x8c, 0xe5, 0x67, 0xf, 0x31, 0x5, 0x4c}; + uint8_t bytesprops6[] = {0x3e, 0x15, 0xb7, 0xa0, 0x69, 0x69, 0xf7, 0xbf, 0xce, 0xde, 0x6a, 0x28, 0x28, + 0x1f, 0x36, 0x44, 0x36, 0x4d, 0xae, 0xc4, 0x67, 0xd4, 0xdf, 0xde, 0xea, 0xa6}; + uint8_t bytesprops7[] = {0x6, 0xcd, 0x2b, 0xb3, 0x7, 0x26, 0xe0, 0xb7, 0xc8, 0x92, 0x8e, 0x79, + 0x6b, 0xb5, 0xd, 0x1d, 0x4a, 0xc0, 0x3a, 0xec, 0x31, 0x17, 0xb7}; + uint8_t bytesprops8[] = {0xc8, 0x82, 0x0, 0xd5, 0x19, 0xd0, 0x68, 0xef, 0xab, 0x44, 0xca, 0x86, 0xb2, + 0x17, 0x59, 0x5c, 0xd4, 0x28, 0x9d, 0x33, 0x63, 0xad, 0x50, 0x39, 0x28}; + uint8_t bytesprops9[] = {0x87, 0xb7, 0x15, 0x7f, 0xf5, 0xbd, 0xa2, 0x4a, 0xdf, 0x1b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16471}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22772}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5843}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14127}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25815}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9063}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4463}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28065}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 20202, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 23840, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\240\247\161\170\180S\251(.\139\187\RS\199\\\USs\207!7\250\&8&q\ESC\236\153", _pubPktID = 1829, _pubBody = -// ")B\201\179\163\188%[\184\154\EOT\146x7,\DC3\v\180\DLE", _pubProps = []} -TEST(Publish50QCTest, Encode72) { - uint8_t pkt[] = {0x3b, 0x32, 0x0, 0x1a, 0xf0, 0xf7, 0xa1, 0xaa, 0xb4, 0x53, 0xfb, 0x28, 0x2e, - 0x8b, 0xbb, 0x1e, 0xc7, 0x5c, 0x1f, 0x73, 0xcf, 0x21, 0x37, 0xfa, 0x38, 0x26, - 0x71, 0x1b, 0xec, 0x99, 0x7, 0x25, 0x0, 0x29, 0x42, 0xc9, 0xb3, 0xa3, 0xbc, - 0x25, 0x5b, 0xb8, 0x9a, 0x4, 0x92, 0x78, 0x37, 0x2c, 0x13, 0xb, 0xb4, 0x10}; - - uint8_t buf[62] = {0}; - - uint8_t topic_bytes[] = {0xf0, 0xf7, 0xa1, 0xaa, 0xb4, 0x53, 0xfb, 0x28, 0x2e, 0x8b, 0xbb, 0x1e, 0xc7, - 0x5c, 0x1f, 0x73, 0xcf, 0x21, 0x37, 0xfa, 0x38, 0x26, 0x71, 0x1b, 0xec, 0x99}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "P\147\149\202g\200\140\&8\251", +// _pubPktID = 0, _pubBody = "\161k\226l\198m\147.\232\136\&3>\222>\138\225{\176s\227!\217C\RS\209_", _pubProps = +// [PropSubscriptionIdentifier 13,PropAuthenticationMethod "\234\v +// \227;i\206\135\130\220\158q{\216\161\246",PropMaximumQoS 236,PropServerReference +// "\ETXdV\185\248\140\206\132\190\165\195\147\128\"\DLE\147",PropReceiveMaximum 97,PropTopicAlias 16366]} +TEST(Publish5QCTest, Encode71) { + uint8_t pkt[] = {0x31, 0x56, 0x0, 0x9, 0x50, 0x93, 0x95, 0xca, 0x67, 0xc8, 0x8c, 0x38, 0xfb, 0x30, 0xb, + 0xd, 0x15, 0x0, 0x10, 0xea, 0xb, 0x20, 0xe3, 0x3b, 0x69, 0xce, 0x87, 0x82, 0xdc, 0x9e, + 0x71, 0x7b, 0xd8, 0xa1, 0xf6, 0x24, 0xec, 0x1c, 0x0, 0x10, 0x3, 0x64, 0x56, 0xb9, 0xf8, + 0x8c, 0xce, 0x84, 0xbe, 0xa5, 0xc3, 0x93, 0x80, 0x22, 0x10, 0x93, 0x21, 0x0, 0x61, 0x23, + 0x3f, 0xee, 0xa1, 0x6b, 0xe2, 0x6c, 0xc6, 0x6d, 0x93, 0x2e, 0xe8, 0x88, 0x33, 0x3e, 0xde, + 0x3e, 0x8a, 0xe1, 0x7b, 0xb0, 0x73, 0xe3, 0x21, 0xd9, 0x43, 0x1e, 0xd1, 0x5f}; + + uint8_t buf[98] = {0}; + + uint8_t topic_bytes[] = {0x50, 0x93, 0x95, 0xca, 0x67, 0xc8, 0x8c, 0x38, 0xfb}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x29, 0x42, 0xc9, 0xb3, 0xa3, 0xbc, 0x25, 0x5b, 0xb8, 0x9a, - 0x4, 0x92, 0x78, 0x37, 0x2c, 0x13, 0xb, 0xb4, 0x10}; + uint8_t msg_bytes[] = {0xa1, 0x6b, 0xe2, 0x6c, 0xc6, 0x6d, 0x93, 0x2e, 0xe8, 0x88, 0x33, 0x3e, 0xde, + 0x3e, 0x8a, 0xe1, 0x7b, 0xb0, 0x73, 0xe3, 0x21, 0xd9, 0x43, 0x1e, 0xd1, 0x5f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 26; - lwmqtt_property_t proplist[] = {}; + uint8_t bytesprops0[] = {0xea, 0xb, 0x20, 0xe3, 0x3b, 0x69, 0xce, 0x87, + 0x82, 0xdc, 0x9e, 0x71, 0x7b, 0xd8, 0xa1, 0xf6}; + uint8_t bytesprops1[] = {0x3, 0x64, 0x56, 0xb9, 0xf8, 0x8c, 0xce, 0x84, + 0xbe, 0xa5, 0xc3, 0x93, 0x80, 0x22, 0x10, 0x93}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&proplist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 97}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16366}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1829, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "2k\146\244f\164\212\DC4o\197\186", -// _pubPktID = 0, _pubBody = "\216C\204\149", _pubProps = [PropResponseInformation -// "\189\143\&7\208\157']\n\207h\170\135\185",PropTopicAlias 905,PropResponseInformation -// "(S#\129:\175\&6\\j\f\184",PropRetainAvailable 68,PropMessageExpiryInterval 2801,PropSubscriptionIdentifier -// 20,PropTopicAliasMaximum 11510,PropAuthenticationData "\149\174\219\206\t",PropResponseInformation -// "\241\162\172\ESCY\144\ESCi\173\161\226Ik~\223\241\156x:\146\189M\204\179l(\170\DC4\ESC\177",PropAuthenticationData -// "\228\198\249\US\SYN\174$s\190%\147l\STX\171\225",PropWillDelayInterval 23982,PropTopicAlias -// 22742,PropWillDelayInterval 9688,PropMaximumPacketSize 11022,PropMaximumPacketSize 529,PropContentType -// "\208\ENQ\139\200\190L[\NAK/\159J\166\253\&8\246\US=,\132F\\\">",PropRetainAvailable 140,PropAssignedClientIdentifier -// ".\205\221\172{\ESC\207\246\129",PropReceiveMaximum 15742]} -TEST(Publish50QCTest, Encode73) { - uint8_t pkt[] = {0x39, 0xbd, 0x1, 0x0, 0xb, 0x32, 0x6b, 0x92, 0xf4, 0x66, 0xa4, 0xd4, 0x14, 0x6f, 0xc5, 0xba, - 0xaa, 0x1, 0x1a, 0x0, 0xd, 0xbd, 0x8f, 0x37, 0xd0, 0x9d, 0x27, 0x5d, 0xa, 0xcf, 0x68, 0xaa, - 0x87, 0xb9, 0x23, 0x3, 0x89, 0x1a, 0x0, 0xb, 0x28, 0x53, 0x23, 0x81, 0x3a, 0xaf, 0x36, 0x5c, - 0x6a, 0xc, 0xb8, 0x25, 0x44, 0x2, 0x0, 0x0, 0xa, 0xf1, 0xb, 0x14, 0x22, 0x2c, 0xf6, 0x16, - 0x0, 0x5, 0x95, 0xae, 0xdb, 0xce, 0x9, 0x1a, 0x0, 0x1e, 0xf1, 0xa2, 0xac, 0x1b, 0x59, 0x90, - 0x1b, 0x69, 0xad, 0xa1, 0xe2, 0x49, 0x6b, 0x7e, 0xdf, 0xf1, 0x9c, 0x78, 0x3a, 0x92, 0xbd, 0x4d, - 0xcc, 0xb3, 0x6c, 0x28, 0xaa, 0x14, 0x1b, 0xb1, 0x16, 0x0, 0xf, 0xe4, 0xc6, 0xf9, 0x1f, 0x16, - 0xae, 0x24, 0x73, 0xbe, 0x25, 0x93, 0x6c, 0x2, 0xab, 0xe1, 0x18, 0x0, 0x0, 0x5d, 0xae, 0x23, - 0x58, 0xd6, 0x18, 0x0, 0x0, 0x25, 0xd8, 0x27, 0x0, 0x0, 0x2b, 0xe, 0x27, 0x0, 0x0, 0x2, - 0x11, 0x3, 0x0, 0x17, 0xd0, 0x5, 0x8b, 0xc8, 0xbe, 0x4c, 0x5b, 0x15, 0x2f, 0x9f, 0x4a, 0xa6, - 0xfd, 0x38, 0xf6, 0x1f, 0x3d, 0x2c, 0x84, 0x46, 0x5c, 0x22, 0x3e, 0x25, 0x8c, 0x12, 0x0, 0x9, - 0x2e, 0xcd, 0xdd, 0xac, 0x7b, 0x1b, 0xcf, 0xf6, 0x81, 0x21, 0x3d, 0x7e, 0xd8, 0x43, 0xcc, 0x95}; - - uint8_t buf[202] = {0}; - - uint8_t topic_bytes[] = {0x32, 0x6b, 0x92, 0xf4, 0x66, 0xa4, 0xd4, 0x14, 0x6f, 0xc5, 0xba}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\251\215\CAN[sS\SOf75^!\161\178\EM\198Ir\ACK*\ETXO\202\255",PropMessageExpiryInterval 3225,PropRequestProblemInformation +// 186,PropSharedSubscriptionAvailable 215,PropRetainAvailable 131,PropResponseTopic +// "P\137\NAK\DC1\165v\243\148\DC29\219-\159\145\239 \NUL\174\254\157\&62\RS\250\144)\"\238$\226",PropCorrelationData +// "\197\146\f\170\ETX\151N\212^",PropRetainAvailable 42,PropSessionExpiryInterval 15247]} +TEST(Publish5QCTest, Encode72) { + uint8_t pkt[] = { + 0x30, 0x8f, 0x2, 0x0, 0x18, 0xfb, 0xd7, 0x18, 0x5b, 0x73, 0x53, 0xe, 0x3c, 0x6e, 0x18, 0x32, 0xb1, 0x47, 0x6, + 0xb7, 0x99, 0xc7, 0xde, 0x8c, 0x60, 0x63, 0xb2, 0x40, 0x97, 0xde, 0x1, 0x25, 0xc9, 0x17, 0x3e, 0x17, 0xab, 0x1f, + 0x0, 0xf, 0xe0, 0x2b, 0x2f, 0xa0, 0xdb, 0x24, 0x22, 0xc2, 0x6f, 0x80, 0xe, 0x13, 0x59, 0xa7, 0x42, 0xb, 0x1f, + 0x15, 0x0, 0xc, 0x9a, 0x67, 0xe3, 0xb0, 0x33, 0xd7, 0x5d, 0x98, 0x4, 0xb, 0xdd, 0x75, 0x16, 0x0, 0xe, 0x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0x2c, 0x7f, + 0xf4, 0x24, 0x50, 0xc4, 0x6, 0xe9, 0x72, 0x63}; + + uint8_t buf[284] = {0}; + + uint8_t topic_bytes[] = {0xfb, 0xd7, 0x18, 0x5b, 0x73, 0x53, 0xe, 0x3c, 0x6e, 0x18, 0x32, 0xb1, + 0x47, 0x6, 0xb7, 0x99, 0xc7, 0xde, 0x8c, 0x60, 0x63, 0xb2, 0x40, 0x97}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xd8, 0x43, 0xcc, 0x95}; + msg.retained = false; + uint8_t msg_bytes[] = {0xa5, 0xa8, 0x8a, 0x4f, 0xe4, 0x4e, 0x39, 0x65, 0x74, 0xbf, 0xc7, + 0x2c, 0x7f, 0xf4, 0x24, 0x50, 0xc4, 0x6, 0xe9, 0x72, 0x63}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 21; - uint8_t bytes0[] = {0xbd, 0x8f, 0x37, 0xd0, 0x9d, 0x27, 0x5d, 0xa, 0xcf, 0x68, 0xaa, 0x87, 0xb9}; - uint8_t bytes1[] = {0x28, 0x53, 0x23, 0x81, 0x3a, 0xaf, 0x36, 0x5c, 0x6a, 0xc, 0xb8}; - uint8_t bytes2[] = {0x95, 0xae, 0xdb, 0xce, 0x9}; - uint8_t bytes3[] = {0xf1, 0xa2, 0xac, 0x1b, 0x59, 0x90, 0x1b, 0x69, 0xad, 0xa1, 0xe2, 0x49, 0x6b, 0x7e, 0xdf, - 0xf1, 0x9c, 0x78, 0x3a, 0x92, 0xbd, 0x4d, 0xcc, 0xb3, 0x6c, 0x28, 0xaa, 0x14, 0x1b, 0xb1}; - uint8_t bytes4[] = {0xe4, 0xc6, 0xf9, 0x1f, 0x16, 0xae, 0x24, 0x73, 0xbe, 0x25, 0x93, 0x6c, 0x2, 0xab, 0xe1}; - uint8_t bytes5[] = {0xd0, 0x5, 0x8b, 0xc8, 0xbe, 0x4c, 0x5b, 0x15, 0x2f, 0x9f, 0x4a, 0xa6, - 0xfd, 0x38, 0xf6, 0x1f, 0x3d, 0x2c, 0x84, 0x46, 0x5c, 0x22, 0x3e}; - uint8_t bytes6[] = {0x2e, 0xcd, 0xdd, 0xac, 0x7b, 0x1b, 0xcf, 0xf6, 0x81}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 905}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2801}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11510}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23982}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22742}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9688}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11022}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 529}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15742}}, + uint8_t bytesprops0[] = {0xe0, 0x2b, 0x2f, 0xa0, 0xdb, 0x24, 0x22, 0xc2, 0x6f, 0x80, 0xe, 0x13, 0x59, 0xa7, 0x42}; + uint8_t bytesprops1[] = {0x9a, 0x67, 0xe3, 0xb0, 0x33, 0xd7, 0x5d, 0x98, 0x4, 0xb, 0xdd, 0x75}; + uint8_t bytesprops2[] = {0x63, 0xbd, 0xce, 0xfd, 0x73, 0x92, 0x54, 0x70, 0xff, 0x94, 0x84, 0xd4, 0xb1, 0x7e}; + uint8_t bytesprops3[] = {0xd5, 0xb8, 0x8f, 0xa1, 0xd4, 0x68, 0xcf, 0x26, 0x9c, 0xa5, + 0xc3, 0x21, 0xcc, 0xfa, 0x62, 0x16, 0x7a, 0xd6, 0x46}; + uint8_t bytesprops4[] = {0xa0, 0x22, 0x4a, 0x92, 0xfc, 0xef, 0xd1, 0x4e, 0x70, 0x58, 0x8a, 0xee, 0xbf, 0x89}; + uint8_t bytesprops5[] = {0xbc, 0x65, 0xa, 0x86}; + uint8_t bytesprops6[] = {0x79, 0xb6, 0x27, 0x43, 0x50, 0x3e, 0x66, 0x37, 0x35, 0x5e, 0x21, 0xa1, + 0xb2, 0x19, 0xc6, 0x49, 0x72, 0x6, 0x2a, 0x3, 0x4f, 0xca, 0xff}; + uint8_t bytesprops7[] = {0x50, 0x89, 0x15, 0x11, 0xa5, 0x76, 0xf3, 0x94, 0x12, 0x39, 0xdb, 0x2d, 0x9f, 0x91, 0xef, + 0x20, 0x0, 0xae, 0xfe, 0x9d, 0x36, 0x32, 0x1e, 0xfa, 0x90, 0x29, 0x22, 0xee, 0x24, 0xe2}; + uint8_t bytesprops8[] = {0xc5, 0x92, 0xc, 0xaa, 0x3, 0x97, 0x4e, 0xd4, 0x5e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4337}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3677}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15052}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32355}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16275}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3225}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15247}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "Q\199\US@hY\186f", _pubPktID = 684, -// _pubBody = "\DC1/\179\209 !\230/\187 \220\191\212", _pubProps = [PropMessageExpiryInterval 7888,PropWillDelayInterval -// 17341,PropResponseInformation "\232fp5\196\NUL",PropServerKeepAlive 17171,PropSharedSubscriptionAvailable -// 63,PropSessionExpiryInterval 30264,PropSharedSubscriptionAvailable 216,PropMaximumQoS 204,PropUserProperty -// "j\212e\SI\142oh\223\173\193z\253\DEL\248\201Ich\ENQ\207k\196\242\191\184T\231\156\222V" -// "\197O\DC1F\226\213\DC2!\CAN\\U", _pubProps = [PropMaximumPacketSize +// 18479,PropAuthenticationMethod +// "O\166\166e\146\135mG+\NAK\SUB\247\190\242\FS\180X&J\250)\SI\a=\249",PropServerKeepAlive 28420,PropReceiveMaximum +// 1572,PropAuthenticationMethod "\150\DC4ior`r\248m",PropPayloadFormatIndicator 10,PropMaximumPacketSize +// 17799,PropPayloadFormatIndicator 90,PropRequestProblemInformation 236,PropRetainAvailable +// 72,PropPayloadFormatIndicator 83,PropSessionExpiryInterval 12274,PropSubscriptionIdentifierAvailable 121]} +TEST(Publish5QCTest, Encode74) { + uint8_t pkt[] = {0x32, 0x5f, 0x0, 0x2, 0x45, 0xd1, 0x1c, 0xec, 0x49, 0x27, 0x0, 0x0, 0x48, 0x2f, 0x15, 0x0, 0x19, + 0x4f, 0xa6, 0xa6, 0x65, 0x92, 0x87, 0x6d, 0x47, 0x2b, 0x15, 0x1a, 0xf7, 0xbe, 0xf2, 0x1c, 0xb4, 0x58, + 0x26, 0x4a, 0xfa, 0x29, 0xf, 0x7, 0x3d, 0xf9, 0x13, 0x6f, 0x4, 0x21, 0x6, 0x24, 0x15, 0x0, 0x9, + 0x96, 0x14, 0x69, 0x6f, 0x72, 0x60, 0x72, 0xf8, 0x6d, 0x1, 0xa, 0x27, 0x0, 0x0, 0x45, 0x87, 0x1, + 0x5a, 0x17, 0xec, 0x25, 0x48, 0x1, 0x53, 0x11, 0x0, 0x0, 0x2f, 0xf2, 0x29, 0x79, 0xeb, 0x3, 0xb9, + 0xc0, 0xd4, 0xb7, 0x6, 0x5c, 0x2b, 0xbc, 0xa5, 0xe6, 0x3e, 0x5c, 0x55}; + + uint8_t buf[107] = {0}; + + uint8_t topic_bytes[] = {0x45, 0xd1}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x5b, 0x28, 0x9d, 0x42, 0xab, 0xb8, 0x9c, 0xc, 0xc9, 0x19, 0xa0, 0xa6, - 0xce, 0xc7, 0xa8, 0xde, 0x99, 0x4e, 0x58, 0x24, 0xf7, 0x6, 0x32, 0xb7}; + msg.retained = false; + uint8_t msg_bytes[] = {0xeb, 0x3, 0xb9, 0xc0, 0xd4, 0xb7, 0x6, 0x5c, 0x2b, 0xbc, 0xa5, 0xe6, 0x3e, 0x5c, 0x55}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 15; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 99}}, {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23092}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 180}}, {.prop = (lwmqtt_prop_t)36, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 156}}, {.prop = (lwmqtt_prop_t)23, .value = {.byte = 85}}, + uint8_t bytesprops0[] = {0x4f, 0xa6, 0xa6, 0x65, 0x92, 0x87, 0x6d, 0x47, 0x2b, 0x15, 0x1a, 0xf7, 0xbe, + 0xf2, 0x1c, 0xb4, 0x58, 0x26, 0x4a, 0xfa, 0x29, 0xf, 0x7, 0x3d, 0xf9}; + uint8_t bytesprops1[] = {0x96, 0x14, 0x69, 0x6f, 0x72, 0x60, 0x72, 0xf8, 0x6d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18479}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28420}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1572}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17799}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12274}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 121}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 9582, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7404, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "ox\254Qe\203<\176\195ES", _pubPktID -// = 20876, _pubBody = "J\224\148H\132xS\156Aov\199\244wF[\n\185\190;\142o\SOHg", _pubProps = [PropResponseTopic -// "\149\NAK\154\213\173\&8\179\SOHD\198=\DEL&\245",PropServerKeepAlive 29491,PropAuthenticationData -// "a\182v\DC1\253",PropTopicAlias 30924,PropSubscriptionIdentifierAvailable 89,PropSubscriptionIdentifierAvailable -// 183,PropReceiveMaximum 4234,PropPayloadFormatIndicator 153,PropWildcardSubscriptionAvailable 17,PropRetainAvailable -// 160,PropAuthenticationData -// "\EM\206d\235w\234\255\225z\a\ENQ\210\231\174>\207\191\167#\164s\SUB\176\130",PropResponseInformation -// "Iy\EM]\189",PropSessionExpiryInterval 7138,PropSubscriptionIdentifierAvailable 233,PropWillDelayInterval 14012]} -TEST(Publish50QCTest, Encode76) { - uint8_t pkt[] = {0x34, 0x83, 0x1, 0x0, 0xb, 0x6f, 0x78, 0xfe, 0x51, 0x65, 0xcb, 0x3c, 0xb0, 0xc3, 0x45, 0x53, 0x51, - 0x8c, 0x5b, 0x8, 0x0, 0xe, 0x95, 0x15, 0x9a, 0xd5, 0xad, 0x38, 0xb3, 0x1, 0x44, 0xc6, 0x3d, 0x7f, - 0x26, 0xf5, 0x13, 0x73, 0x33, 0x16, 0x0, 0x5, 0x61, 0xb6, 0x76, 0x11, 0xfd, 0x23, 0x78, 0xcc, 0x29, - 0x59, 0x29, 0xb7, 0x21, 0x10, 0x8a, 0x1, 0x99, 0x28, 0x11, 0x25, 0xa0, 0x16, 0x0, 0x18, 0x19, 0xce, - 0x64, 0xeb, 0x77, 0xea, 0xff, 0xe1, 0x7a, 0x7, 0x5, 0xd2, 0xe7, 0xae, 0x3e, 0xcf, 0xbf, 0xa7, 0x23, - 0xa4, 0x73, 0x1a, 0xb0, 0x82, 0x1a, 0x0, 0x5, 0x49, 0x79, 0x19, 0x5d, 0xbd, 0x11, 0x0, 0x0, 0x1b, - 0xe2, 0x29, 0xe9, 0x18, 0x0, 0x0, 0x36, 0xbc, 0x4a, 0xe0, 0x94, 0x48, 0x84, 0x78, 0x53, 0x9c, 0x41, - 0x6f, 0x76, 0xc7, 0xf4, 0x77, 0x46, 0x5b, 0xa, 0xb9, 0xbe, 0x3b, 0x8e, 0x6f, 0x1, 0x67}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\198\225\DC4\245\&5\248\178f[\186\216.\218\247", _pubPktID = 16102, _pubBody = "\213@o\181\227\224\214\214UA", +// _pubProps = [PropMaximumQoS 70,PropServerReference "F\230yxn{S\217\FS\250\193\172\225f\SYN\158"]} +TEST(Publish5QCTest, Encode75) { + uint8_t pkt[] = {0x32, 0x32, 0x0, 0xe, 0xc6, 0xe1, 0x14, 0xf5, 0x35, 0xf8, 0xb2, 0x66, 0x5b, + 0xba, 0xd8, 0x2e, 0xda, 0xf7, 0x3e, 0xe6, 0x15, 0x24, 0x46, 0x1c, 0x0, 0x10, + 0x46, 0xe6, 0x79, 0x78, 0x6e, 0x7b, 0x53, 0xd9, 0x1c, 0xfa, 0xc1, 0xac, 0xe1, + 0x66, 0x16, 0x9e, 0xd5, 0x40, 0x6f, 0xb5, 0xe3, 0xe0, 0xd6, 0xd6, 0x55, 0x41}; - uint8_t buf[144] = {0}; + uint8_t buf[62] = {0}; - uint8_t topic_bytes[] = {0x6f, 0x78, 0xfe, 0x51, 0x65, 0xcb, 0x3c, 0xb0, 0xc3, 0x45, 0x53}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xc6, 0xe1, 0x14, 0xf5, 0x35, 0xf8, 0xb2, 0x66, 0x5b, 0xba, 0xd8, 0x2e, 0xda, 0xf7}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x4a, 0xe0, 0x94, 0x48, 0x84, 0x78, 0x53, 0x9c, 0x41, 0x6f, 0x76, 0xc7, - 0xf4, 0x77, 0x46, 0x5b, 0xa, 0xb9, 0xbe, 0x3b, 0x8e, 0x6f, 0x1, 0x67}; + uint8_t msg_bytes[] = {0xd5, 0x40, 0x6f, 0xb5, 0xe3, 0xe0, 0xd6, 0xd6, 0x55, 0x41}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 10; - uint8_t bytes0[] = {0x95, 0x15, 0x9a, 0xd5, 0xad, 0x38, 0xb3, 0x1, 0x44, 0xc6, 0x3d, 0x7f, 0x26, 0xf5}; - uint8_t bytes1[] = {0x61, 0xb6, 0x76, 0x11, 0xfd}; - uint8_t bytes2[] = {0x19, 0xce, 0x64, 0xeb, 0x77, 0xea, 0xff, 0xe1, 0x7a, 0x7, 0x5, 0xd2, - 0xe7, 0xae, 0x3e, 0xcf, 0xbf, 0xa7, 0x23, 0xa4, 0x73, 0x1a, 0xb0, 0x82}; - uint8_t bytes3[] = {0x49, 0x79, 0x19, 0x5d, 0xbd}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29491}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30924}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4234}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7138}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14012}}, + uint8_t bytesprops0[] = {0x46, 0xe6, 0x79, 0x78, 0x6e, 0x7b, 0x53, 0xd9, + 0x1c, 0xfa, 0xc1, 0xac, 0xe1, 0x66, 0x16, 0x9e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 20876, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16102, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = ")\159\249\220\185\252\230\193", -// _pubPktID = 10776, _pubBody = "\144\230\&6K\134\194\176\153\v\145(]\222\255\155\231\225(?\150}\155\FS\173)", -// _pubProps = [PropMessageExpiryInterval 5760,PropSubscriptionIdentifierAvailable 195,PropAuthenticationData -// "\177S",PropServerReference "\158\&4\205\186\200\244\209$u\152\218\202r\162oH\163$\\\212\&4",PropMaximumQoS -// 206,PropCorrelationData "\229\235$;",PropSubscriptionIdentifier 30,PropWildcardSubscriptionAvailable -// 188,PropSharedSubscriptionAvailable 208,PropMessageExpiryInterval 15481,PropResponseInformation -// "n\142\&4\206\224\227*\166N\229\253J\192\206aK\132[\186\143\vh\156",PropPayloadFormatIndicator 86,PropServerReference -// "9@",PropSubscriptionIdentifierAvailable 10,PropWillDelayInterval 10019,PropContentType "u"]} -TEST(Publish50QCTest, Encode77) { - uint8_t pkt[] = {0x34, 0x8a, 0x1, 0x0, 0x8, 0x29, 0x9f, 0xf9, 0xdc, 0xb9, 0xfc, 0xe6, 0xc1, 0x2a, 0x18, 0x64, - 0x2, 0x0, 0x0, 0x16, 0x80, 0x29, 0xc3, 0x16, 0x0, 0x2, 0xb1, 0x53, 0x1c, 0x0, 0x15, 0x9e, - 0x34, 0xcd, 0xba, 0xc8, 0xf4, 0xd1, 0x24, 0x75, 0x98, 0xda, 0xca, 0x72, 0xa2, 0x6f, 0x48, 0xa3, - 0x24, 0x5c, 0xd4, 0x34, 0x24, 0xce, 0x9, 0x0, 0x4, 0xe5, 0xeb, 0x24, 0x3b, 0xb, 0x1e, 0x28, - 0xbc, 0x2a, 0xd0, 0x2, 0x0, 0x0, 0x3c, 0x79, 0x1a, 0x0, 0x17, 0x6e, 0x8e, 0x34, 0xce, 0xe0, - 0xe3, 0x2a, 0xa6, 0x4e, 0xe5, 0xfd, 0x4a, 0xc0, 0xce, 0x61, 0x4b, 0x84, 0x5b, 0xba, 0x8f, 0xb, - 0x68, 0x9c, 0x1, 0x56, 0x1c, 0x0, 0x2, 0x39, 0x40, 0x29, 0xa, 0x18, 0x0, 0x0, 0x27, 0x23, - 0x3, 0x0, 0x1, 0x75, 0x90, 0xe6, 0x36, 0x4b, 0x86, 0xc2, 0xb0, 0x99, 0xb, 0x91, 0x28, 0x5d, - 0xde, 0xff, 0x9b, 0xe7, 0xe1, 0x28, 0x3f, 0x96, 0x7d, 0x9b, 0x1c, 0xad, 0x29}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 19098, _pubBody = +// "\216\241'G\183\&2\SO\NAK\254\130\&1\161\176A=\131x\SUB\190", _pubProps = [PropWildcardSubscriptionAvailable +// 221,PropSharedSubscriptionAvailable 221,PropReceiveMaximum 23497,PropSessionExpiryInterval 18379,PropTopicAlias +// 21052,PropWildcardSubscriptionAvailable 53,PropResponseTopic +// "\232\203\230\130T\137t\149Y\153\204\STX\148",PropSessionExpiryInterval 27272,PropRequestResponseInformation +// 206,PropWillDelayInterval 31,PropAuthenticationData +// "@\199\n7]\241\t\ESC\159\159\230k]\206#\232I\129Gs",PropRequestResponseInformation 120,PropResponseTopic +// "^\142\168r\238\161p\161\255\185\ESC\USd\182\&4\213",PropSubscriptionIdentifier 9]} +TEST(Publish5QCTest, Encode76) { + uint8_t pkt[] = {0x3b, 0x73, 0x0, 0x0, 0x4a, 0x9a, 0x5b, 0x28, 0xdd, 0x2a, 0xdd, 0x21, 0x5b, 0xc9, 0x11, 0x0, 0x0, + 0x47, 0xcb, 0x23, 0x52, 0x3c, 0x28, 0x35, 0x8, 0x0, 0xd, 0xe8, 0xcb, 0xe6, 0x82, 0x54, 0x89, 0x74, + 0x95, 0x59, 0x99, 0xcc, 0x2, 0x94, 0x11, 0x0, 0x0, 0x6a, 0x88, 0x19, 0xce, 0x18, 0x0, 0x0, 0x0, + 0x1f, 0x16, 0x0, 0x14, 0x40, 0xc7, 0xa, 0x37, 0x5d, 0xf1, 0x9, 0x1b, 0x9f, 0x9f, 0xe6, 0x6b, 0x5d, + 0xce, 0x23, 0xe8, 0x49, 0x81, 0x47, 0x73, 0x19, 0x78, 0x8, 0x0, 0x10, 0x5e, 0x8e, 0xa8, 0x72, 0xee, + 0xa1, 0x70, 0xa1, 0xff, 0xb9, 0x1b, 0x1f, 0x64, 0xb6, 0x34, 0xd5, 0xb, 0x9, 0xd8, 0xf1, 0x27, 0x47, + 0xb7, 0x32, 0xe, 0x15, 0xfe, 0x82, 0x31, 0xa1, 0xb0, 0x41, 0x3d, 0x83, 0x78, 0x1a, 0xbe}; - uint8_t buf[151] = {0}; + uint8_t buf[127] = {0}; - uint8_t topic_bytes[] = {0x29, 0x9f, 0xf9, 0xdc, 0xb9, 0xfc, 0xe6, 0xc1}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x90, 0xe6, 0x36, 0x4b, 0x86, 0xc2, 0xb0, 0x99, 0xb, 0x91, 0x28, 0x5d, 0xde, - 0xff, 0x9b, 0xe7, 0xe1, 0x28, 0x3f, 0x96, 0x7d, 0x9b, 0x1c, 0xad, 0x29}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xd8, 0xf1, 0x27, 0x47, 0xb7, 0x32, 0xe, 0x15, 0xfe, 0x82, + 0x31, 0xa1, 0xb0, 0x41, 0x3d, 0x83, 0x78, 0x1a, 0xbe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 19; - uint8_t bytes0[] = {0xb1, 0x53}; - uint8_t bytes1[] = {0x9e, 0x34, 0xcd, 0xba, 0xc8, 0xf4, 0xd1, 0x24, 0x75, 0x98, 0xda, - 0xca, 0x72, 0xa2, 0x6f, 0x48, 0xa3, 0x24, 0x5c, 0xd4, 0x34}; - uint8_t bytes2[] = {0xe5, 0xeb, 0x24, 0x3b}; - uint8_t bytes3[] = {0x6e, 0x8e, 0x34, 0xce, 0xe0, 0xe3, 0x2a, 0xa6, 0x4e, 0xe5, 0xfd, 0x4a, - 0xc0, 0xce, 0x61, 0x4b, 0x84, 0x5b, 0xba, 0x8f, 0xb, 0x68, 0x9c}; - uint8_t bytes4[] = {0x39, 0x40}; - uint8_t bytes5[] = {0x75}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5760}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15481}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10019}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytes5}}}, + uint8_t bytesprops0[] = {0xe8, 0xcb, 0xe6, 0x82, 0x54, 0x89, 0x74, 0x95, 0x59, 0x99, 0xcc, 0x2, 0x94}; + uint8_t bytesprops1[] = {0x40, 0xc7, 0xa, 0x37, 0x5d, 0xf1, 0x9, 0x1b, 0x9f, 0x9f, + 0xe6, 0x6b, 0x5d, 0xce, 0x23, 0xe8, 0x49, 0x81, 0x47, 0x73}; + uint8_t bytesprops2[] = {0x5e, 0x8e, 0xa8, 0x72, 0xee, 0xa1, 0x70, 0xa1, + 0xff, 0xb9, 0x1b, 0x1f, 0x64, 0xb6, 0x34, 0xd5}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23497}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18379}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21052}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27272}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10776, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 19098, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "6:\229<\217\235\180", _pubPktID = -// 21683, _pubBody = "y", _pubProps = [PropWillDelayInterval 11318,PropAssignedClientIdentifier -// "7%\147o\ETB\248\231",PropTopicAliasMaximum 5541,PropAuthenticationMethod -// "\153>\209\255L\217",PropPayloadFormatIndicator 24,PropServerKeepAlive 2352,PropSharedSubscriptionAvailable -// 244,PropServerReference "\198!\248h\187y\161\239X",PropServerReference -// "6jm\232\b;\159xm\142\183\216N",PropSubscriptionIdentifier 2,PropWildcardSubscriptionAvailable 204,PropResponseTopic -// "\144\246\212\237\132",PropReceiveMaximum 27177,PropMessageExpiryInterval 2103,PropReasonString -// "\DLEq<\a\178",PropResponseTopic -// "a.\139m\207\184\FS]x\254\DC3\159\208\150\160\179\&3\184\157\189~75Z7\252\202\133",PropCorrelationData -// "\242\228>|&T5\209\178\185\222]\210\198\208\&0\f^\190\238-\NAKf\133\143\231\234,\197\STX",PropContentType -// "i\226)\144\194\SUBH8\159\212\131|\"z\147\135?\214S\"\145\176\ENQ\DEL7"]} -TEST(Publish50QC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9f, 0xd4, 0x83, 0x7c, 0x22, 0x7a, - 0x93, 0x87, 0x3f, 0xd6, 0x53, 0x22, 0x91, 0xb0, 0x5, 0x7f, 0x37, 0x79}; - - uint8_t buf[209] = {0}; - - uint8_t topic_bytes[] = {0x36, 0x3a, 0xe5, 0x3c, 0xd9, 0xeb, 0xb4}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "'\243\208\&5\245\172=e^\165", +// _pubPktID = 6458, _pubBody = "\222#/ q\128\&4\174k'\135\SI:O\193\DC4\153[", _pubProps = +// [PropRequestResponseInformation 83,PropWillDelayInterval 25748,PropSharedSubscriptionAvailable +// 74,PropSessionExpiryInterval 11787,PropWildcardSubscriptionAvailable 45,PropSessionExpiryInterval +// 19470,PropTopicAliasMaximum 8721,PropSubscriptionIdentifier 19,PropServerKeepAlive 18440,PropRetainAvailable +// 171,PropSessionExpiryInterval 10776,PropAuthenticationMethod "\138",PropRetainAvailable 45,PropReceiveMaximum +// 31306,PropResponseTopic ";t\NUL\182\143\NUL\131+P",PropServerKeepAlive 26319,PropWillDelayInterval +// 31656,PropAuthenticationData "\159\189\DC4\142\220\169\173\246\135\206\227Q\245\197|",PropMaximumPacketSize +// 7616,PropMessageExpiryInterval 15526,PropSessionExpiryInterval 12963,PropRequestResponseInformation 185]} +TEST(Publish5QCTest, Encode77) { + uint8_t pkt[] = {0x33, 0x85, 0x1, 0x0, 0xa, 0x27, 0xf3, 0xd0, 0x35, 0xf5, 0xac, 0x3d, 0x65, 0x5e, 0xa5, 0x19, + 0x3a, 0x64, 0x19, 0x53, 0x18, 0x0, 0x0, 0x64, 0x94, 0x2a, 0x4a, 0x11, 0x0, 0x0, 0x2e, 0xb, + 0x28, 0x2d, 0x11, 0x0, 0x0, 0x4c, 0xe, 0x22, 0x22, 0x11, 0xb, 0x13, 0x13, 0x48, 0x8, 0x25, + 0xab, 0x11, 0x0, 0x0, 0x2a, 0x18, 0x15, 0x0, 0x1, 0x8a, 0x25, 0x2d, 0x21, 0x7a, 0x4a, 0x8, + 0x0, 0x9, 0x3b, 0x74, 0x0, 0xb6, 0x8f, 0x0, 0x83, 0x2b, 0x50, 0x13, 0x66, 0xcf, 0x18, 0x0, + 0x0, 0x7b, 0xa8, 0x16, 0x0, 0xf, 0x9f, 0xbd, 0x14, 0x8e, 0xdc, 0xa9, 0xad, 0xf6, 0x87, 0xce, + 0xe3, 0x51, 0xf5, 0xc5, 0x7c, 0x27, 0x0, 0x0, 0x1d, 0xc0, 0x2, 0x0, 0x0, 0x3c, 0xa6, 0x11, + 0x0, 0x0, 0x32, 0xa3, 0x19, 0xb9, 0xde, 0x23, 0x2f, 0x20, 0x71, 0x80, 0x34, 0xae, 0x6b, 0x27, + 0x87, 0xf, 0x3a, 0x4f, 0xc1, 0x14, 0x99, 0x5b}; + + uint8_t buf[146] = {0}; + + uint8_t topic_bytes[] = {0x27, 0xf3, 0xd0, 0x35, 0xf5, 0xac, 0x3d, 0x65, 0x5e, 0xa5}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x79}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xde, 0x23, 0x2f, 0x20, 0x71, 0x80, 0x34, 0xae, 0x6b, + 0x27, 0x87, 0xf, 0x3a, 0x4f, 0xc1, 0x14, 0x99, 0x5b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 18; - uint8_t bytes0[] = {0x37, 0x25, 0x93, 0x6f, 0x17, 0xf8, 0xe7}; - uint8_t bytes1[] = {0x99, 0x3e, 0xd1, 0xff, 0x4c, 0xd9}; - uint8_t bytes2[] = {0xc6, 0x21, 0xf8, 0x68, 0xbb, 0x79, 0xa1, 0xef, 0x58}; - uint8_t bytes3[] = {0x36, 0x6a, 0x6d, 0xe8, 0x8, 0x3b, 0x9f, 0x78, 0x6d, 0x8e, 0xb7, 0xd8, 0x4e}; - uint8_t bytes4[] = {0x90, 0xf6, 0xd4, 0xed, 0x84}; - uint8_t bytes5[] = {0x10, 0x71, 0x3c, 0x7, 0xb2}; - uint8_t bytes6[] = {0x61, 0x2e, 0x8b, 0x6d, 0xcf, 0xb8, 0x1c, 0x5d, 0x78, 0xfe, 0x13, 0x9f, 0xd0, 0x96, - 0xa0, 0xb3, 0x33, 0xb8, 0x9d, 0xbd, 0x7e, 0x37, 0x35, 0x5a, 0x37, 0xfc, 0xca, 0x85}; - uint8_t bytes7[] = {0xf2, 0xe4, 0x3e, 0x7c, 0x26, 0x54, 0x35, 0xd1, 0xb2, 0xb9, 0xde, 0x5d, 0xd2, 0xc6, 0xd0, - 0x30, 0xc, 0x5e, 0xbe, 0xee, 0x2d, 0x15, 0x66, 0x85, 0x8f, 0xe7, 0xea, 0x2c, 0xc5, 0x2}; - uint8_t bytes8[] = {0x69, 0xe2, 0x29, 0x90, 0xc2, 0x1a, 0x48, 0x38, 0x9f, 0xd4, 0x83, 0x7c, 0x22, - 0x7a, 0x93, 0x87, 0x3f, 0xd6, 0x53, 0x22, 0x91, 0xb0, 0x5, 0x7f, 0x37}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11318}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5541}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2352}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27177}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2103}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytes8}}}, + uint8_t bytesprops0[] = {0x8a}; + uint8_t bytesprops1[] = {0x3b, 0x74, 0x0, 0xb6, 0x8f, 0x0, 0x83, 0x2b, 0x50}; + uint8_t bytesprops2[] = {0x9f, 0xbd, 0x14, 0x8e, 0xdc, 0xa9, 0xad, 0xf6, 0x87, 0xce, 0xe3, 0x51, 0xf5, 0xc5, 0x7c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25748}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11787}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19470}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8721}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18440}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10776}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31306}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26319}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31656}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7616}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15526}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12963}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 185}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 21683, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 6458, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// ",l\239A\255.e\128\238\190\EOT\216\240\231", _pubPktID = 0, _pubBody = -// "\ENQ\DC3z\234.f[;\DC2\214i0\161P\251\171\160\RS\180\222J\202\191\DC2(.", _pubProps = [PropRetainAvailable -// 162,PropAssignedClientIdentifier " \206\r\200\RS\221\EMmd-\178\238(\138\&1G\ESC%\GS",PropResponseTopic -// "o\146\164\247\DLE\168m\130",PropWildcardSubscriptionAvailable 143,PropRequestProblemInformation -// 24,PropServerReference -// "@CxY\197\198\&2\149:B\212\128\US\154\135\234\218p\a\209\178\SUB\SO\128",PropRequestProblemInformation -// 9,PropRequestProblemInformation 127,PropSharedSubscriptionAvailable 106,PropAssignedClientIdentifier -// "",PropMaximumPacketSize 1555,PropResponseTopic "1\150\191\229\249LK\174\148\142~\251<|U\239\205\226\n\134\218 -// 3}\SYNH\169",PropServerReference -// "\128k\199{\194\245`\158\194\246?\168\221\140Z\222/X\200x\165-\254\160f\250",PropSessionExpiryInterval 1631]} -TEST(Publish50QCTest, Encode79) { - uint8_t pkt[] = {0x31, 0xbc, 0x1, 0x0, 0xe, 0x2c, 0x6c, 0xef, 0x41, 0xff, 0x2e, 0x65, 0x80, 0xee, 0xbe, 0x4, - 0xd8, 0xf0, 0xe7, 0x90, 0x1, 0x25, 0xa2, 0x12, 0x0, 0x13, 0x20, 0xce, 0xd, 0xc8, 0x1e, 0xdd, - 0x19, 0x6d, 0x64, 0x2d, 0xb2, 0xee, 0x28, 0x8a, 0x31, 0x47, 0x1b, 0x25, 0x1d, 0x8, 0x0, 0x8, - 0x6f, 0x92, 0xa4, 0xf7, 0x10, 0xa8, 0x6d, 0x82, 0x28, 0x8f, 0x17, 0x18, 0x1c, 0x0, 0x18, 0x40, - 0x43, 0x78, 0x59, 0xc5, 0xc6, 0x32, 0x95, 0x3a, 0x42, 0xd4, 0x80, 0x1f, 0x9a, 0x87, 0xea, 0xda, - 0x70, 0x7, 0xd1, 0xb2, 0x1a, 0xe, 0x80, 0x17, 0x9, 0x17, 0x7f, 0x2a, 0x6a, 0x12, 0x0, 0x0, - 0x27, 0x0, 0x0, 0x6, 0x13, 0x8, 0x0, 0x1b, 0x31, 0x96, 0xbf, 0xe5, 0xf9, 0x4c, 0x4b, 0xae, - 0x94, 0x8e, 0x7e, 0xfb, 0x3c, 0x7c, 0x55, 0xef, 0xcd, 0xe2, 0xa, 0x86, 0xda, 0x20, 0x33, 0x7d, - 0x16, 0x48, 0xa9, 0x1c, 0x0, 0x1a, 0x80, 0x6b, 0xc7, 0x7b, 0xc2, 0xf5, 0x60, 0x9e, 0xc2, 0xf6, - 0x3f, 0xa8, 0xdd, 0x8c, 0x5a, 0xde, 0x2f, 0x58, 0xc8, 0x78, 0xa5, 0x2d, 0xfe, 0xa0, 0x66, 0xfa, - 0x11, 0x0, 0x0, 0x6, 0x5f, 0x5, 0x13, 0x7a, 0xea, 0x2e, 0x66, 0x5b, 0x3b, 0x12, 0xd6, 0x69, - 0x30, 0xa1, 0x50, 0xfb, 0xab, 0xa0, 0x1e, 0xb4, 0xde, 0x4a, 0xca, 0xbf, 0x12, 0x28, 0x2e}; - - uint8_t buf[201] = {0}; - - uint8_t topic_bytes[] = {0x2c, 0x6c, 0xef, 0x41, 0xff, 0x2e, 0x65, 0x80, 0xee, 0xbe, 0x4, 0xd8, 0xf0, 0xe7}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "I\168PH\213\245]<\203\142\255\147\"\251", _pubPktID = 23705, _pubBody = +// "\136\177\214\217\&8;\253\STX\147\206\151\161\183?\r\SUB\151\230c\DLE5h\249\177\236", _pubProps = +// [PropMaximumPacketSize 12446,PropPayloadFormatIndicator 141,PropMaximumPacketSize 17105,PropMessageExpiryInterval +// 25409,PropPayloadFormatIndicator 219,PropPayloadFormatIndicator 187,PropWillDelayInterval +// 2545,PropAssignedClientIdentifier "\fA\150\166\183\170\SYN",PropMaximumQoS 249,PropMessageExpiryInterval +// 27889,PropContentType "\254\248[\251Z\ACK\171\136@z]\250\240\149\161\GS\176\SUBjM\176\183",PropResponseInformation +// "\222\f\255\239\209\159\171=v$\174\t_r\190\ACK\150u\139\198\193\225\162Qm",PropSessionExpiryInterval +// 18095,PropUserProperty "~q\143z\SI\248k\DC4\149" +// "H\237\247q]1r\f\160\142\150\149g6\246\DC4\203\190\DC3\176\209",PropSubscriptionIdentifier +// 15,PropRequestResponseInformation 74,PropSessionExpiryInterval 5607,PropRetainAvailable +// 195,PropSharedSubscriptionAvailable 217,PropContentType "\146\204\243\219\177",PropMessageExpiryInterval +// 12779,PropReasonString "f\181\t\190\137\152\128\172\226l\132\215\252q",PropServerKeepAlive +// 9876,PropSharedSubscriptionAvailable 170,PropRetainAvailable 140,PropSharedSubscriptionAvailable 79]} +TEST(Publish5QCTest, Encode78) { + uint8_t pkt[] = {0x33, 0xe9, 0x1, 0x0, 0xe, 0x49, 0xa8, 0x50, 0x48, 0xd5, 0xf5, 0x5d, 0x3c, 0xcb, 0x8e, 0xff, 0x93, + 0x22, 0xfb, 0x5c, 0x99, 0xbc, 0x1, 0x27, 0x0, 0x0, 0x30, 0x9e, 0x1, 0x8d, 0x27, 0x0, 0x0, 0x42, + 0xd1, 0x2, 0x0, 0x0, 0x63, 0x41, 0x1, 0xdb, 0x1, 0xbb, 0x18, 0x0, 0x0, 0x9, 0xf1, 0x12, 0x0, + 0x7, 0xc, 0x41, 0x96, 0xa6, 0xb7, 0xaa, 0x16, 0x24, 0xf9, 0x2, 0x0, 0x0, 0x6c, 0xf1, 0x3, 0x0, + 0x16, 0xfe, 0xf8, 0x5b, 0xfb, 0x5a, 0x6, 0xab, 0x88, 0x40, 0x7a, 0x5d, 0xfa, 0xf0, 0x95, 0xa1, 0x1d, + 0xb0, 0x1a, 0x6a, 0x4d, 0xb0, 0xb7, 0x1a, 0x0, 0x19, 0xde, 0xc, 0xff, 0xef, 0xd1, 0x9f, 0xab, 0x3d, + 0x76, 0x24, 0xae, 0x9, 0x5f, 0x72, 0xbe, 0x6, 0x96, 0x75, 0x8b, 0xc6, 0xc1, 0xe1, 0xa2, 0x51, 0x6d, + 0x11, 0x0, 0x0, 0x46, 0xaf, 0x26, 0x0, 0x9, 0x7e, 0x71, 0x8f, 0x7a, 0xf, 0xf8, 0x6b, 0x14, 0x95, + 0x0, 0x15, 0x48, 0xed, 0xf7, 0x71, 0x5d, 0x31, 0x72, 0xc, 0xa0, 0x8e, 0x96, 0x95, 0x67, 0x36, 0xf6, + 0x14, 0xcb, 0xbe, 0x13, 0xb0, 0xd1, 0xb, 0xf, 0x19, 0x4a, 0x11, 0x0, 0x0, 0x15, 0xe7, 0x25, 0xc3, + 0x2a, 0xd9, 0x3, 0x0, 0x5, 0x92, 0xcc, 0xf3, 0xdb, 0xb1, 0x2, 0x0, 0x0, 0x31, 0xeb, 0x1f, 0x0, + 0xe, 0x66, 0xb5, 0x9, 0xbe, 0x89, 0x98, 0x80, 0xac, 0xe2, 0x6c, 0x84, 0xd7, 0xfc, 0x71, 0x13, 0x26, + 0x94, 0x2a, 0xaa, 0x25, 0x8c, 0x2a, 0x4f, 0x88, 0xb1, 0xd6, 0xd9, 0x38, 0x3b, 0xfd, 0x2, 0x93, 0xce, + 0x97, 0xa1, 0xb7, 0x3f, 0xd, 0x1a, 0x97, 0xe6, 0x63, 0x10, 0x35, 0x68, 0xf9, 0xb1, 0xec}; + + uint8_t buf[246] = {0}; + + uint8_t topic_bytes[] = {0x49, 0xa8, 0x50, 0x48, 0xd5, 0xf5, 0x5d, 0x3c, 0xcb, 0x8e, 0xff, 0x93, 0x22, 0xfb}; lwmqtt_string_t topic = {14, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x5, 0x13, 0x7a, 0xea, 0x2e, 0x66, 0x5b, 0x3b, 0x12, 0xd6, 0x69, 0x30, 0xa1, - 0x50, 0xfb, 0xab, 0xa0, 0x1e, 0xb4, 0xde, 0x4a, 0xca, 0xbf, 0x12, 0x28, 0x2e}; + uint8_t msg_bytes[] = {0x88, 0xb1, 0xd6, 0xd9, 0x38, 0x3b, 0xfd, 0x2, 0x93, 0xce, 0x97, 0xa1, 0xb7, + 0x3f, 0xd, 0x1a, 0x97, 0xe6, 0x63, 0x10, 0x35, 0x68, 0xf9, 0xb1, 0xec}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 25; - uint8_t bytes0[] = {0x20, 0xce, 0xd, 0xc8, 0x1e, 0xdd, 0x19, 0x6d, 0x64, 0x2d, - 0xb2, 0xee, 0x28, 0x8a, 0x31, 0x47, 0x1b, 0x25, 0x1d}; - uint8_t bytes1[] = {0x6f, 0x92, 0xa4, 0xf7, 0x10, 0xa8, 0x6d, 0x82}; - uint8_t bytes2[] = {0x40, 0x43, 0x78, 0x59, 0xc5, 0xc6, 0x32, 0x95, 0x3a, 0x42, 0xd4, 0x80, - 0x1f, 0x9a, 0x87, 0xea, 0xda, 0x70, 0x7, 0xd1, 0xb2, 0x1a, 0xe, 0x80}; - uint8_t bytes3[] = {0}; - uint8_t bytes4[] = {0x31, 0x96, 0xbf, 0xe5, 0xf9, 0x4c, 0x4b, 0xae, 0x94, 0x8e, 0x7e, 0xfb, 0x3c, 0x7c, - 0x55, 0xef, 0xcd, 0xe2, 0xa, 0x86, 0xda, 0x20, 0x33, 0x7d, 0x16, 0x48, 0xa9}; - uint8_t bytes5[] = {0x80, 0x6b, 0xc7, 0x7b, 0xc2, 0xf5, 0x60, 0x9e, 0xc2, 0xf6, 0x3f, 0xa8, 0xdd, - 0x8c, 0x5a, 0xde, 0x2f, 0x58, 0xc8, 0x78, 0xa5, 0x2d, 0xfe, 0xa0, 0x66, 0xfa}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1555}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1631}}, + uint8_t bytesprops0[] = {0xc, 0x41, 0x96, 0xa6, 0xb7, 0xaa, 0x16}; + uint8_t bytesprops1[] = {0xfe, 0xf8, 0x5b, 0xfb, 0x5a, 0x6, 0xab, 0x88, 0x40, 0x7a, 0x5d, + 0xfa, 0xf0, 0x95, 0xa1, 0x1d, 0xb0, 0x1a, 0x6a, 0x4d, 0xb0, 0xb7}; + uint8_t bytesprops2[] = {0xde, 0xc, 0xff, 0xef, 0xd1, 0x9f, 0xab, 0x3d, 0x76, 0x24, 0xae, 0x9, 0x5f, + 0x72, 0xbe, 0x6, 0x96, 0x75, 0x8b, 0xc6, 0xc1, 0xe1, 0xa2, 0x51, 0x6d}; + uint8_t bytesprops4[] = {0x48, 0xed, 0xf7, 0x71, 0x5d, 0x31, 0x72, 0xc, 0xa0, 0x8e, 0x96, + 0x95, 0x67, 0x36, 0xf6, 0x14, 0xcb, 0xbe, 0x13, 0xb0, 0xd1}; + uint8_t bytesprops3[] = {0x7e, 0x71, 0x8f, 0x7a, 0xf, 0xf8, 0x6b, 0x14, 0x95}; + uint8_t bytesprops5[] = {0x92, 0xcc, 0xf3, 0xdb, 0xb1}; + uint8_t bytesprops6[] = {0x66, 0xb5, 0x9, 0xbe, 0x89, 0x98, 0x80, 0xac, 0xe2, 0x6c, 0x84, 0xd7, 0xfc, 0x71}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12446}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17105}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25409}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2545}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27889}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18095}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops3}, .v = {21, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5607}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12779}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9876}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 23705, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\179\182\194\v\149\131\&4\177\175cM\153\251\204B\RS\231\170n}y\198\197)\250\203\147\151\211\138", _pubPktID = 1399, -// _pubBody = "\156\228\194pPo\189\&6\255\NAK\245-\151\170\DC3;\191\196\136\241\191\255V\146`\250\183\234>\138", -// _pubProps = [PropTopicAlias 10172]} -TEST(Publish50QCTest, Encode80) { - uint8_t pkt[] = {0x3b, 0x44, 0x0, 0x1e, 0xb3, 0xb6, 0xc2, 0xb, 0x95, 0x83, 0x34, 0xb1, 0xaf, 0x63, - 0x4d, 0x99, 0xfb, 0xcc, 0x42, 0x1e, 0xe7, 0xaa, 0x6e, 0x7d, 0x79, 0xc6, 0xc5, 0x29, - 0xfa, 0xcb, 0x93, 0x97, 0xd3, 0x8a, 0x5, 0x77, 0x3, 0x23, 0x27, 0xbc, 0x9c, 0xe4, - 0xc2, 0x70, 0x50, 0x6f, 0xbd, 0x36, 0xff, 0x15, 0xf5, 0x2d, 0x97, 0xaa, 0x13, 0x3b, - 0xbf, 0xc4, 0x88, 0xf1, 0xbf, 0xff, 0x56, 0x92, 0x60, 0xfa, 0xb7, 0xea, 0x3e, 0x8a}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(cp\130q\251\181\SUB\133\251\228jBh\139\191\SOH\192\213\219Q1", _pubPktID = 14770, _pubBody = +// "\155j|4h\141\198\RS\162\240\168]\208C", _pubProps = [PropServerReference +// "\249\133\222O\138\161\&1\255\f\205\134\250\254\191"]} +TEST(Publish5QCTest, Encode79) { + uint8_t pkt[] = {0x3a, 0x3a, 0x0, 0x16, 0x28, 0x63, 0x70, 0x82, 0x71, 0xfb, 0xb5, 0x1a, 0x85, 0xfb, 0xe4, + 0x6a, 0x42, 0x68, 0x8b, 0xbf, 0x1, 0xc0, 0xd5, 0xdb, 0x51, 0x31, 0x39, 0xb2, 0x11, 0x1c, + 0x0, 0xe, 0xf9, 0x85, 0xde, 0x4f, 0x8a, 0xa1, 0x31, 0xff, 0xc, 0xcd, 0x86, 0xfa, 0xfe, + 0xbf, 0x9b, 0x6a, 0x7c, 0x34, 0x68, 0x8d, 0xc6, 0x1e, 0xa2, 0xf0, 0xa8, 0x5d, 0xd0, 0x43}; - uint8_t buf[80] = {0}; + uint8_t buf[70] = {0}; - uint8_t topic_bytes[] = {0xb3, 0xb6, 0xc2, 0xb, 0x95, 0x83, 0x34, 0xb1, 0xaf, 0x63, 0x4d, 0x99, 0xfb, 0xcc, 0x42, - 0x1e, 0xe7, 0xaa, 0x6e, 0x7d, 0x79, 0xc6, 0xc5, 0x29, 0xfa, 0xcb, 0x93, 0x97, 0xd3, 0x8a}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x28, 0x63, 0x70, 0x82, 0x71, 0xfb, 0xb5, 0x1a, 0x85, 0xfb, 0xe4, + 0x6a, 0x42, 0x68, 0x8b, 0xbf, 0x1, 0xc0, 0xd5, 0xdb, 0x51, 0x31}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x9c, 0xe4, 0xc2, 0x70, 0x50, 0x6f, 0xbd, 0x36, 0xff, 0x15, 0xf5, 0x2d, 0x97, 0xaa, 0x13, - 0x3b, 0xbf, 0xc4, 0x88, 0xf1, 0xbf, 0xff, 0x56, 0x92, 0x60, 0xfa, 0xb7, 0xea, 0x3e, 0x8a}; + msg.retained = false; + uint8_t msg_bytes[] = {0x9b, 0x6a, 0x7c, 0x34, 0x68, 0x8d, 0xc6, 0x1e, 0xa2, 0xf0, 0xa8, 0x5d, 0xd0, 0x43}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 14; + + uint8_t bytesprops0[] = {0xf9, 0x85, 0xde, 0x4f, 0x8a, 0xa1, 0x31, 0xff, 0xc, 0xcd, 0x86, 0xfa, 0xfe, 0xbf}; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10172}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1399, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 14770, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\183\185o\230@UI=\142/\201\188\216sZ\ESC\b\"\182\202\NAKU$`\181\rE\194t\f", _pubPktID = 17758, _pubBody = -// "\251~\215\217\SOH\189L!\244\EM\212\246_\154\185\179.\187\EOTE\242\169", _pubProps = [PropAuthenticationMethod -// "\230$\159\147\SUB]\144\SUB\221\202P\170\179\154G\210E\219\255\134\132\191\158\133\219q\240\189",PropTopicAliasMaximum -// 24228,PropPayloadFormatIndicator 214,PropSharedSubscriptionAvailable 148,PropPayloadFormatIndicator -// 197,PropWillDelayInterval 5533,PropPayloadFormatIndicator 8,PropServerKeepAlive 5558,PropWillDelayInterval -// 9585,PropServerKeepAlive 27517,PropResponseInformation "\244\135\DC2\245}w\234\135",PropReasonString -// "\n\212NL\t\226\177\238\ESC\175\197\148V\141\194\162\164\190]e'",PropWildcardSubscriptionAvailable -// 226,PropWildcardSubscriptionAvailable 74,PropMessageExpiryInterval 26648,PropMaximumQoS -// 193,PropSubscriptionIdentifier 18,PropSessionExpiryInterval 1981,PropServerReference -// "O\ESCAo\223\174\DELGQ\173\231=\149t\129PE\NAK\201\181\163=I\133",PropServerReference -// "\154\ENQ\214S\202\212\ETXf\192\169\ETB",PropSessionExpiryInterval 23038,PropMaximumQoS 51,PropServerKeepAlive 1930]} -TEST(Publish50QCTest, Encode81) { - uint8_t pkt[] = { - 0x33, 0xdc, 0x1, 0x0, 0x1e, 0xb7, 0xb9, 0x6f, 0xe6, 0x40, 0x55, 0x49, 0x3d, 0x8e, 0x2f, 0xc9, 0xbc, 0xd8, 0x73, - 0x5a, 0x1b, 0x8, 0x22, 0xb6, 0xca, 0x15, 0x55, 0x24, 0x60, 0xb5, 0xd, 0x45, 0xc2, 0x74, 0xc, 0x45, 0x5e, 0xa2, - 0x1, 0x15, 0x0, 0x1c, 0xe6, 0x24, 0x9f, 0x93, 0x1a, 0x5d, 0x90, 0x1a, 0xdd, 0xca, 0x50, 0xaa, 0xb3, 0x9a, 0x47, - 0xd2, 0x45, 0xdb, 0xff, 0x86, 0x84, 0xbf, 0x9e, 0x85, 0xdb, 0x71, 0xf0, 0xbd, 0x22, 0x5e, 0xa4, 0x1, 0xd6, 0x2a, - 0x94, 0x1, 0xc5, 0x18, 0x0, 0x0, 0x15, 0x9d, 0x1, 0x8, 0x13, 0x15, 0xb6, 0x18, 0x0, 0x0, 0x25, 0x71, 0x13, - 0x6b, 0x7d, 0x1a, 0x0, 0x8, 0xf4, 0x87, 0x12, 0xf5, 0x7d, 0x77, 0xea, 0x87, 0x1f, 0x0, 0x15, 0xa, 0xd4, 0x4e, - 0x4c, 0x9, 0xe2, 0xb1, 0xee, 0x1b, 0xaf, 0xc5, 0x94, 0x56, 0x8d, 0xc2, 0xa2, 0xa4, 0xbe, 0x5d, 0x65, 0x27, 0x28, - 0xe2, 0x28, 0x4a, 0x2, 0x0, 0x0, 0x68, 0x18, 0x24, 0xc1, 0xb, 0x12, 0x11, 0x0, 0x0, 0x7, 0xbd, 0x1c, 0x0, - 0x18, 0x4f, 0x1b, 0x41, 0x6f, 0xdf, 0xae, 0x7f, 0x47, 0x51, 0xad, 0xe7, 0x3d, 0x95, 0x74, 0x81, 0x50, 0x45, 0x15, - 0xc9, 0xb5, 0xa3, 0x3d, 0x49, 0x85, 0x1c, 0x0, 0xb, 0x9a, 0x5, 0xd6, 0x53, 0xca, 0xd4, 0x3, 0x66, 0xc0, 0xa9, - 0x17, 0x11, 0x0, 0x0, 0x59, 0xfe, 0x24, 0x33, 0x13, 0x7, 0x8a, 0xfb, 0x7e, 0xd7, 0xd9, 0x1, 0xbd, 0x4c, 0x21, - 0xf4, 0x19, 0xd4, 0xf6, 0x5f, 0x9a, 0xb9, 0xb3, 0x2e, 0xbb, 0x4, 0x45, 0xf2, 0xa9}; - - uint8_t buf[233] = {0}; - - uint8_t topic_bytes[] = {0xb7, 0xb9, 0x6f, 0xe6, 0x40, 0x55, 0x49, 0x3d, 0x8e, 0x2f, 0xc9, 0xbc, 0xd8, 0x73, 0x5a, - 0x1b, 0x8, 0x22, 0xb6, 0xca, 0x15, 0x55, 0x24, 0x60, 0xb5, 0xd, 0x45, 0xc2, 0x74, 0xc}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "4\USH\SYN\210z\160\141\155\238\230\171\a\233\243\192t", _pubPktID = 24524, _pubBody = +// "%\173_\207\173p\210\131\129\ESC\231\SOH\143\255\163\&4\182?LS", _pubProps = [PropCorrelationData +// "\172\&8\220\180\205\ETX\181\228\&0\DEL:_\135\211\163K\191\174\252\142\139\ENQ\185\192\181y\ETXo!",PropSubscriptionIdentifier +// 5,PropAssignedClientIdentifier +// "vc\194\156h\DC4\131]\SOH+\128uX\133S\251V\220\170\132\141:\RS\DC1~{P\SOH\142",PropWillDelayInterval +// 22759,PropRetainAvailable 19,PropWillDelayInterval 9648,PropAuthenticationData +// "\158\US\170\131\158\238\172",PropAuthenticationMethod "\228B\221\t\"\222Wk\186\189\&20",PropMessageExpiryInterval +// 21169,PropMessageExpiryInterval 20864,PropResponseInformation +// "\223\206$\bO?}\142\&7\251\167\n\234\FS\140\138\SOH^\NAKO",PropMessageExpiryInterval +// 25217,PropRequestProblemInformation 19,PropTopicAlias 22170,PropRequestResponseInformation 205,PropMaximumQoS +// 211,PropAuthenticationData "\232\217x\ETX\DLE\230B~",PropServerKeepAlive 4487,PropSessionExpiryInterval +// 17004,PropAssignedClientIdentifier ""]} +TEST(Publish5QCTest, Encode80) { + uint8_t pkt[] = {0x3a, 0xd7, 0x1, 0x0, 0x11, 0x34, 0x1f, 0x48, 0x16, 0xd2, 0x7a, 0xa0, 0x8d, 0x9b, 0xee, 0xe6, 0xab, + 0x7, 0xe9, 0xf3, 0xc0, 0x74, 0x5f, 0xcc, 0xac, 0x1, 0x9, 0x0, 0x1d, 0xac, 0x38, 0xdc, 0xb4, 0xcd, + 0x3, 0xb5, 0xe4, 0x30, 0x7f, 0x3a, 0x5f, 0x87, 0xd3, 0xa3, 0x4b, 0xbf, 0xae, 0xfc, 0x8e, 0x8b, 0x5, + 0xb9, 0xc0, 0xb5, 0x79, 0x3, 0x6f, 0x21, 0xb, 0x5, 0x12, 0x0, 0x1d, 0x76, 0x63, 0xc2, 0x9c, 0x68, + 0x14, 0x83, 0x5d, 0x1, 0x2b, 0x80, 0x75, 0x58, 0x85, 0x53, 0xfb, 0x56, 0xdc, 0xaa, 0x84, 0x8d, 0x3a, + 0x1e, 0x11, 0x7e, 0x7b, 0x50, 0x1, 0x8e, 0x18, 0x0, 0x0, 0x58, 0xe7, 0x25, 0x13, 0x18, 0x0, 0x0, + 0x25, 0xb0, 0x16, 0x0, 0x7, 0x9e, 0x1f, 0xaa, 0x83, 0x9e, 0xee, 0xac, 0x15, 0x0, 0xc, 0xe4, 0x42, + 0xdd, 0x9, 0x22, 0xde, 0x57, 0x6b, 0xba, 0xbd, 0x32, 0x30, 0x2, 0x0, 0x0, 0x52, 0xb1, 0x2, 0x0, + 0x0, 0x51, 0x80, 0x1a, 0x0, 0x14, 0xdf, 0xce, 0x24, 0x8, 0x4f, 0x3f, 0x7d, 0x8e, 0x37, 0xfb, 0xa7, + 0xa, 0xea, 0x1c, 0x8c, 0x8a, 0x1, 0x5e, 0x15, 0x4f, 0x2, 0x0, 0x0, 0x62, 0x81, 0x17, 0x13, 0x23, + 0x56, 0x9a, 0x19, 0xcd, 0x24, 0xd3, 0x16, 0x0, 0x8, 0xe8, 0xd9, 0x78, 0x3, 0x10, 0xe6, 0x42, 0x7e, + 0x13, 0x11, 0x87, 0x11, 0x0, 0x0, 0x42, 0x6c, 0x12, 0x0, 0x0, 0x25, 0xad, 0x5f, 0xcf, 0xad, 0x70, + 0xd2, 0x83, 0x81, 0x1b, 0xe7, 0x1, 0x8f, 0xff, 0xa3, 0x34, 0xb6, 0x3f, 0x4c, 0x53}; + + uint8_t buf[228] = {0}; + + uint8_t topic_bytes[] = {0x34, 0x1f, 0x48, 0x16, 0xd2, 0x7a, 0xa0, 0x8d, 0x9b, + 0xee, 0xe6, 0xab, 0x7, 0xe9, 0xf3, 0xc0, 0x74}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xfb, 0x7e, 0xd7, 0xd9, 0x1, 0xbd, 0x4c, 0x21, 0xf4, 0x19, 0xd4, - 0xf6, 0x5f, 0x9a, 0xb9, 0xb3, 0x2e, 0xbb, 0x4, 0x45, 0xf2, 0xa9}; + msg.retained = false; + uint8_t msg_bytes[] = {0x25, 0xad, 0x5f, 0xcf, 0xad, 0x70, 0xd2, 0x83, 0x81, 0x1b, + 0xe7, 0x1, 0x8f, 0xff, 0xa3, 0x34, 0xb6, 0x3f, 0x4c, 0x53}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 20; - uint8_t bytes0[] = {0xe6, 0x24, 0x9f, 0x93, 0x1a, 0x5d, 0x90, 0x1a, 0xdd, 0xca, 0x50, 0xaa, 0xb3, 0x9a, - 0x47, 0xd2, 0x45, 0xdb, 0xff, 0x86, 0x84, 0xbf, 0x9e, 0x85, 0xdb, 0x71, 0xf0, 0xbd}; - uint8_t bytes1[] = {0xf4, 0x87, 0x12, 0xf5, 0x7d, 0x77, 0xea, 0x87}; - uint8_t bytes2[] = {0xa, 0xd4, 0x4e, 0x4c, 0x9, 0xe2, 0xb1, 0xee, 0x1b, 0xaf, 0xc5, - 0x94, 0x56, 0x8d, 0xc2, 0xa2, 0xa4, 0xbe, 0x5d, 0x65, 0x27}; - uint8_t bytes3[] = {0x4f, 0x1b, 0x41, 0x6f, 0xdf, 0xae, 0x7f, 0x47, 0x51, 0xad, 0xe7, 0x3d, - 0x95, 0x74, 0x81, 0x50, 0x45, 0x15, 0xc9, 0xb5, 0xa3, 0x3d, 0x49, 0x85}; - uint8_t bytes4[] = {0x9a, 0x5, 0xd6, 0x53, 0xca, 0xd4, 0x3, 0x66, 0xc0, 0xa9, 0x17}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24228}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5533}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5558}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9585}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27517}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26648}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1981}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23038}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1930}}, + uint8_t bytesprops0[] = {0xac, 0x38, 0xdc, 0xb4, 0xcd, 0x3, 0xb5, 0xe4, 0x30, 0x7f, 0x3a, 0x5f, 0x87, 0xd3, 0xa3, + 0x4b, 0xbf, 0xae, 0xfc, 0x8e, 0x8b, 0x5, 0xb9, 0xc0, 0xb5, 0x79, 0x3, 0x6f, 0x21}; + uint8_t bytesprops1[] = {0x76, 0x63, 0xc2, 0x9c, 0x68, 0x14, 0x83, 0x5d, 0x1, 0x2b, 0x80, 0x75, 0x58, 0x85, 0x53, + 0xfb, 0x56, 0xdc, 0xaa, 0x84, 0x8d, 0x3a, 0x1e, 0x11, 0x7e, 0x7b, 0x50, 0x1, 0x8e}; + uint8_t bytesprops2[] = {0x9e, 0x1f, 0xaa, 0x83, 0x9e, 0xee, 0xac}; + uint8_t bytesprops3[] = {0xe4, 0x42, 0xdd, 0x9, 0x22, 0xde, 0x57, 0x6b, 0xba, 0xbd, 0x32, 0x30}; + uint8_t bytesprops4[] = {0xdf, 0xce, 0x24, 0x8, 0x4f, 0x3f, 0x7d, 0x8e, 0x37, 0xfb, + 0xa7, 0xa, 0xea, 0x1c, 0x8c, 0x8a, 0x1, 0x5e, 0x15, 0x4f}; + uint8_t bytesprops5[] = {0xe8, 0xd9, 0x78, 0x3, 0x10, 0xe6, 0x42, 0x7e}; + uint8_t bytesprops6[] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22759}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9648}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21169}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20864}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25217}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22170}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4487}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17004}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17758, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 24524, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "", _pubPktID = 3165, _pubBody = -// "\168'\DC2\253\238;d\144\231\186\152t\206\166", _pubProps = [PropContentType -// "[\236<\152\128\186\169\221\182\180d\214\171d\227>\137\180\ETXQ",PropReceiveMaximum 22525,PropContentType -// "v\166\207e\200_\199\213\250\&4=l$\240,m)\EOT\ETB\171\133\222\ACK\162$\210\158",PropMessageExpiryInterval -// 13876,PropTopicAlias 9953,PropAuthenticationData -// "w\NUL\ACKf\196\178\193Ml}\159\213^\ACK9%\168\158\233r\171\134\223r\140"]} -TEST(Publish50QCTest, Encode82) { - uint8_t pkt[] = {0x3d, 0x6f, 0x0, 0x0, 0xc, 0x5d, 0x5c, 0x3, 0x0, 0x14, 0x5b, 0xec, 0x3c, 0x98, 0x80, 0xba, 0xa9, - 0xdd, 0xb6, 0xb4, 0x64, 0xd6, 0xab, 0x64, 0xe3, 0x3e, 0x89, 0xb4, 0x3, 0x51, 0x21, 0x57, 0xfd, 0x3, - 0x0, 0x1b, 0x76, 0xa6, 0xcf, 0x65, 0xc8, 0x5f, 0xc7, 0xd5, 0xfa, 0x34, 0x3d, 0x6c, 0x24, 0xf0, 0x2c, - 0x6d, 0x29, 0x4, 0x17, 0xab, 0x85, 0xde, 0x6, 0xa2, 0x24, 0xd2, 0x9e, 0x2, 0x0, 0x0, 0x36, 0x34, - 0x23, 0x26, 0xe1, 0x16, 0x0, 0x19, 0x77, 0x0, 0x6, 0x66, 0xc4, 0xb2, 0xc1, 0x4d, 0x6c, 0x7d, 0x9f, - 0xd5, 0x5e, 0x6, 0x39, 0x25, 0xa8, 0x9e, 0xe9, 0x72, 0xab, 0x86, 0xdf, 0x72, 0x8c, 0xa8, 0x27, 0x12, - 0xfd, 0xee, 0x3b, 0x64, 0x90, 0xe7, 0xba, 0x98, 0x74, 0xce, 0xa6}; - - uint8_t buf[123] = {0}; - - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\214u\192\231\177\&7\SYN\253\141i\217\&0\158", _pubPktID = 0, _pubBody = +// "\169\SI\241H\190p\151Qw\209\217/\163\156\&5", _pubProps = [PropSubscriptionIdentifier +// 21,PropWildcardSubscriptionAvailable 137,PropCorrelationData "PZXh\248\181\246\177j-\EM",PropAuthenticationMethod +// "\185\170\217",PropRequestResponseInformation 181,PropTopicAliasMaximum 16439,PropAuthenticationMethod +// "+\208\209X\155[b\255\157<,N",PropMaximumPacketSize 2703,PropTopicAliasMaximum 12373,PropUserProperty +// "\175,\192kC\221\220\&6\251co.\177\154\166\132\225k\248=n\150\229S\241\183\198\a" +// "\NAKC\232\185\187\244\DC43t\232\210Z\236\240\ESC\199",PropSharedSubscriptionAvailable 84,PropAuthenticationData +// "\157H(\211,\248\171\202\207\NUL\187\242\SI",PropAssignedClientIdentifier "\GS\221\156",PropMessageExpiryInterval +// 20204,PropContentType "`\138\aF\r\\\184I:c\144M\221x4\226\161J\139\&4\DC4\157",PropRequestProblemInformation +// 35,PropReasonString "/t\233\ENQ\198Z \197\200\218h\197\146\147M\DC1\220|dN\195\SYNG",PropTopicAliasMaximum +// 32647,PropResponseInformation +// "\151\\;Jx\150\255\225\252\132\145\187n\206\&7\STXl\172\196[\204\180",PropSubscriptionIdentifier +// 21,PropCorrelationData "51\167\168 \218"]} +TEST(Publish5QCTest, Encode81) { + uint8_t pkt[] = { + 0x39, 0xfe, 0x1, 0x0, 0xd, 0xd6, 0x75, 0xc0, 0xe7, 0xb1, 0x37, 0x16, 0xfd, 0x8d, 0x69, 0xd9, 0x30, 0x9e, 0xde, + 0x1, 0xb, 0x15, 0x28, 0x89, 0x9, 0x0, 0xb, 0x50, 0x5a, 0x58, 0x68, 0xf8, 0xb5, 0xf6, 0xb1, 0x6a, 0x2d, 0x19, + 0x15, 0x0, 0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0x6c, 0xac, 0xc4, + 0x5b, 0xcc, 0xb4, 0xb, 0x15, 0x9, 0x0, 0x6, 0x35, 0x31, 0xa7, 0xa8, 0x20, 0xda, 0xa9, 0xf, 0xf1, 0x48, 0xbe, + 0x70, 0x97, 0x51, 0x77, 0xd1, 0xd9, 0x2f, 0xa3, 0x9c, 0x35}; + + uint8_t buf[267] = {0}; + + uint8_t topic_bytes[] = {0xd6, 0x75, 0xc0, 0xe7, 0xb1, 0x37, 0x16, 0xfd, 0x8d, 0x69, 0xd9, 0x30, 0x9e}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xa8, 0x27, 0x12, 0xfd, 0xee, 0x3b, 0x64, 0x90, 0xe7, 0xba, 0x98, 0x74, 0xce, 0xa6}; + uint8_t msg_bytes[] = {0xa9, 0xf, 0xf1, 0x48, 0xbe, 0x70, 0x97, 0x51, 0x77, 0xd1, 0xd9, 0x2f, 0xa3, 0x9c, 0x35}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; - - uint8_t bytes0[] = {0x5b, 0xec, 0x3c, 0x98, 0x80, 0xba, 0xa9, 0xdd, 0xb6, 0xb4, - 0x64, 0xd6, 0xab, 0x64, 0xe3, 0x3e, 0x89, 0xb4, 0x3, 0x51}; - uint8_t bytes1[] = {0x76, 0xa6, 0xcf, 0x65, 0xc8, 0x5f, 0xc7, 0xd5, 0xfa, 0x34, 0x3d, 0x6c, 0x24, 0xf0, - 0x2c, 0x6d, 0x29, 0x4, 0x17, 0xab, 0x85, 0xde, 0x6, 0xa2, 0x24, 0xd2, 0x9e}; - uint8_t bytes2[] = {0x77, 0x0, 0x6, 0x66, 0xc4, 0xb2, 0xc1, 0x4d, 0x6c, 0x7d, 0x9f, 0xd5, 0x5e, - 0x6, 0x39, 0x25, 0xa8, 0x9e, 0xe9, 0x72, 0xab, 0x86, 0xdf, 0x72, 0x8c}; + msg.payload_len = 15; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22525}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13876}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9953}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytes2}}}, + uint8_t bytesprops0[] = {0x50, 0x5a, 0x58, 0x68, 0xf8, 0xb5, 0xf6, 0xb1, 0x6a, 0x2d, 0x19}; + uint8_t bytesprops1[] = {0xb9, 0xaa, 0xd9}; + uint8_t bytesprops2[] = {0x2b, 0xd0, 0xd1, 0x58, 0x9b, 0x5b, 0x62, 0xff, 0x9d, 0x3c, 0x2c, 0x4e}; + uint8_t bytesprops4[] = {0x15, 0x43, 0xe8, 0xb9, 0xbb, 0xf4, 0x14, 0x33, + 0x74, 0xe8, 0xd2, 0x5a, 0xec, 0xf0, 0x1b, 0xc7}; + uint8_t bytesprops3[] = {0xaf, 0x2c, 0xc0, 0x6b, 0x43, 0xdd, 0xdc, 0x36, 0xfb, 0x63, 0x6f, 0x2e, 0xb1, 0x9a, + 0xa6, 0x84, 0xe1, 0x6b, 0xf8, 0x3d, 0x6e, 0x96, 0xe5, 0x53, 0xf1, 0xb7, 0xc6, 0x7}; + uint8_t bytesprops5[] = {0x9d, 0x48, 0x28, 0xd3, 0x2c, 0xf8, 0xab, 0xca, 0xcf, 0x0, 0xbb, 0xf2, 0xf}; + uint8_t bytesprops6[] = {0x1d, 0xdd, 0x9c}; + uint8_t bytesprops7[] = {0x60, 0x8a, 0x7, 0x46, 0xd, 0x5c, 0xb8, 0x49, 0x3a, 0x63, 0x90, + 0x4d, 0xdd, 0x78, 0x34, 0xe2, 0xa1, 0x4a, 0x8b, 0x34, 0x14, 0x9d}; + uint8_t bytesprops8[] = {0x2f, 0x74, 0xe9, 0x5, 0xc6, 0x5a, 0x20, 0xc5, 0xc8, 0xda, 0x68, 0xc5, + 0x92, 0x93, 0x4d, 0x11, 0xdc, 0x7c, 0x64, 0x4e, 0xc3, 0x16, 0x47}; + uint8_t bytesprops9[] = {0x97, 0x5c, 0x3b, 0x4a, 0x78, 0x96, 0xff, 0xe1, 0xfc, 0x84, 0x91, + 0xbb, 0x6e, 0xce, 0x37, 0x2, 0x6c, 0xac, 0xc4, 0x5b, 0xcc, 0xb4}; + uint8_t bytesprops10[] = {0x35, 0x31, 0xa7, 0xa8, 0x20, 0xda}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16439}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2703}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12373}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops3}, .v = {16, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20204}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32647}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 3165, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\GS\DC2", _pubPktID = 7799, _pubBody -// = "\138\249b\fd \199\239\220\147\235\233\214\152\139\130Q\163v?ZrG\215\139\236\184\230y", _pubProps = -// [PropSubscriptionIdentifierAvailable 186,PropServerReference -// "u\171O\192\245i;\DC1\DEL\SI\143f\146\b\237i\242\250h\147\171\244\CAN\226n",PropSubscriptionIdentifier -// 19,PropResponseInformation "",PropCorrelationData "\197vg\238\248\222\160\219\187\243\b\219\135Ds\218\229C\195'\252h -// 4",PropWildcardSubscriptionAvailable 146]} -TEST(Publish50QCTest, Encode83) { - uint8_t pkt[] = {0x3a, 0x64, 0x0, 0x2, 0x1d, 0x12, 0x1e, 0x77, 0x40, 0x29, 0xba, 0x1c, 0x0, 0x19, 0x75, - 0xab, 0x4f, 0xc0, 0xf5, 0x69, 0x3b, 0x11, 0x7f, 0xf, 0x8f, 0x66, 0x92, 0x8, 0xed, 0x69, - 0xf2, 0xfa, 0x68, 0x93, 0xab, 0xf4, 0x18, 0xe2, 0x6e, 0xb, 0x13, 0x1a, 0x0, 0x0, 0x9, - 0x0, 0x18, 0xc5, 0x76, 0x67, 0xee, 0xf8, 0xde, 0xa0, 0xdb, 0xbb, 0xf3, 0x8, 0xdb, 0x87, - 0x44, 0x73, 0xda, 0xe5, 0x43, 0xc3, 0x27, 0xfc, 0x68, 0x20, 0x34, 0x28, 0x92, 0x8a, 0xf9, - 0x62, 0xc, 0x64, 0x20, 0xc7, 0xef, 0xdc, 0x93, 0xeb, 0xe9, 0xd6, 0x98, 0x8b, 0x82, 0x51, - 0xa3, 0x76, 0x3f, 0x5a, 0x72, 0x47, 0xd7, 0x8b, 0xec, 0xb8, 0xe6, 0x79}; - - uint8_t buf[112] = {0}; - - uint8_t topic_bytes[] = {0x1d, 0x12}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NUL%\184|4\245A", _pubPktID = 9669, +// _pubBody = "\170\148\223\170\SOH\189\188m;\173\149\203\NUL_B\STX\209\128\FSH\211\202R*$\DC4\t\241J", _pubProps = +// [PropAuthenticationMethod "\133\130\171\253DL)v@\199j\228\134\212\250\224\134\EMe)\DC3\242\DC1\231",PropMaximumQoS +// 121,PropMaximumPacketSize 26562,PropRequestProblemInformation 233,PropTopicAliasMaximum +// 21040,PropSubscriptionIdentifierAvailable 223,PropMessageExpiryInterval 4754,PropSubscriptionIdentifier +// 30,PropReasonString "2<\152\236\226\DC1\220.\NAKkZW\US\t\169",PropSharedSubscriptionAvailable +// 24,PropAuthenticationData "\217A3&_FD\140x\150m}z_\253\SUB\151'\EOT\249c\252]\129",PropRequestProblemInformation +// 168,PropPayloadFormatIndicator 156,PropMaximumQoS 149,PropPayloadFormatIndicator 71,PropSharedSubscriptionAvailable +// 243,PropResponseInformation "\r\150&\179E\ENQ,",PropMaximumQoS 6,PropServerKeepAlive 12988,PropMessageExpiryInterval +// 450,PropMaximumPacketSize 13232,PropSharedSubscriptionAvailable 1]} +TEST(Publish5QCTest, Encode82) { + uint8_t pkt[] = {0x3a, 0xae, 0x1, 0x0, 0x7, 0x0, 0x25, 0xb8, 0x7c, 0x34, 0xf5, 0x41, 0x25, 0xc5, 0x84, 0x1, 0x15, + 0x0, 0x18, 0x85, 0x82, 0xab, 0xfd, 0x44, 0x4c, 0x29, 0x76, 0x40, 0xc7, 0x6a, 0xe4, 0x86, 0xd4, 0xfa, + 0xe0, 0x86, 0x19, 0x65, 0x29, 0x13, 0xf2, 0x11, 0xe7, 0x24, 0x79, 0x27, 0x0, 0x0, 0x67, 0xc2, 0x17, + 0xe9, 0x22, 0x52, 0x30, 0x29, 0xdf, 0x2, 0x0, 0x0, 0x12, 0x92, 0xb, 0x1e, 0x1f, 0x0, 0xf, 0x32, + 0x3c, 0x98, 0xec, 0xe2, 0x11, 0xdc, 0x2e, 0x15, 0x6b, 0x5a, 0x57, 0x1f, 0x9, 0xa9, 0x2a, 0x18, 0x16, + 0x0, 0x18, 0xd9, 0x41, 0x33, 0x26, 0x5f, 0x46, 0x44, 0x8c, 0x78, 0x96, 0x6d, 0x7d, 0x7a, 0x5f, 0xfd, + 0x1a, 0x97, 0x27, 0x4, 0xf9, 0x63, 0xfc, 0x5d, 0x81, 0x17, 0xa8, 0x1, 0x9c, 0x24, 0x95, 0x1, 0x47, + 0x2a, 0xf3, 0x1a, 0x0, 0x7, 0xd, 0x96, 0x26, 0xb3, 0x45, 0x5, 0x2c, 0x24, 0x6, 0x13, 0x32, 0xbc, + 0x2, 0x0, 0x0, 0x1, 0xc2, 0x27, 0x0, 0x0, 0x33, 0xb0, 0x2a, 0x1, 0xaa, 0x94, 0xdf, 0xaa, 0x1, + 0xbd, 0xbc, 0x6d, 0x3b, 0xad, 0x95, 0xcb, 0x0, 0x5f, 0x42, 0x2, 0xd1, 0x80, 0x1c, 0x48, 0xd3, 0xca, + 0x52, 0x2a, 0x24, 0x14, 0x9, 0xf1, 0x4a}; + + uint8_t buf[187] = {0}; + + uint8_t topic_bytes[] = {0x0, 0x25, 0xb8, 0x7c, 0x34, 0xf5, 0x41}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x8a, 0xf9, 0x62, 0xc, 0x64, 0x20, 0xc7, 0xef, 0xdc, 0x93, 0xeb, 0xe9, 0xd6, 0x98, 0x8b, - 0x82, 0x51, 0xa3, 0x76, 0x3f, 0x5a, 0x72, 0x47, 0xd7, 0x8b, 0xec, 0xb8, 0xe6, 0x79}; + uint8_t msg_bytes[] = {0xaa, 0x94, 0xdf, 0xaa, 0x1, 0xbd, 0xbc, 0x6d, 0x3b, 0xad, 0x95, 0xcb, 0x0, 0x5f, 0x42, + 0x2, 0xd1, 0x80, 0x1c, 0x48, 0xd3, 0xca, 0x52, 0x2a, 0x24, 0x14, 0x9, 0xf1, 0x4a}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 29; - uint8_t bytes0[] = {0x75, 0xab, 0x4f, 0xc0, 0xf5, 0x69, 0x3b, 0x11, 0x7f, 0xf, 0x8f, 0x66, 0x92, - 0x8, 0xed, 0x69, 0xf2, 0xfa, 0x68, 0x93, 0xab, 0xf4, 0x18, 0xe2, 0x6e}; - uint8_t bytes1[] = {0}; - uint8_t bytes2[] = {0xc5, 0x76, 0x67, 0xee, 0xf8, 0xde, 0xa0, 0xdb, 0xbb, 0xf3, 0x8, 0xdb, - 0x87, 0x44, 0x73, 0xda, 0xe5, 0x43, 0xc3, 0x27, 0xfc, 0x68, 0x20, 0x34}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 146}}, + uint8_t bytesprops0[] = {0x85, 0x82, 0xab, 0xfd, 0x44, 0x4c, 0x29, 0x76, 0x40, 0xc7, 0x6a, 0xe4, + 0x86, 0xd4, 0xfa, 0xe0, 0x86, 0x19, 0x65, 0x29, 0x13, 0xf2, 0x11, 0xe7}; + uint8_t bytesprops1[] = {0x32, 0x3c, 0x98, 0xec, 0xe2, 0x11, 0xdc, 0x2e, 0x15, 0x6b, 0x5a, 0x57, 0x1f, 0x9, 0xa9}; + uint8_t bytesprops2[] = {0xd9, 0x41, 0x33, 0x26, 0x5f, 0x46, 0x44, 0x8c, 0x78, 0x96, 0x6d, 0x7d, + 0x7a, 0x5f, 0xfd, 0x1a, 0x97, 0x27, 0x4, 0xf9, 0x63, 0xfc, 0x5d, 0x81}; + uint8_t bytesprops3[] = {0xd, 0x96, 0x26, 0xb3, 0x45, 0x5, 0x2c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26562}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21040}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4754}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12988}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 450}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13232}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 1}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7799, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 9669, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\208\187K.", _pubPktID = 29034, -// _pubBody = "\221\ACK\199\144\EOTv\ACK\217\\", _pubProps = [PropServerKeepAlive 3513,PropUserProperty -// "e\141\b\252'\183N\167\&8l\DC4\151x\170\229\FS\DC3s\128\135\222", _pubProps = [PropResponseInformation +// "d\230\222_\235\DC3\t\249\239\214^z\190\212\146;\183Y_\251",PropAuthenticationMethod +// "/\161\143;\FSB\160E\NAK9er\154\151HQ\254\169R",PropAuthenticationMethod "\248\SOH\169 +// %\148\181\248[<\128\247k",PropResponseInformation +// "\196qU2Lz\146\223yZ\ENQ\253\&2\DC2h\136\155c;\201\DEL",PropSharedSubscriptionAvailable 231,PropMaximumQoS +// 182,PropUserProperty "T\166\248\237\150\n\218\ENQ\NAK%\242\187\217\166&/}\163\DEL\243\DEL\253\152\148\159" +// "\213A",PropReasonString "y\170\226\DC42$n!\237F\136\FS9\180\158\&4zG\130|\GS!\132",PropServerKeepAlive +// 19917,PropRequestProblemInformation 106,PropSharedSubscriptionAvailable 200,PropRequestResponseInformation +// 126,PropRequestProblemInformation 139,PropWildcardSubscriptionAvailable 178,PropSessionExpiryInterval +// 21423,PropRequestProblemInformation 122,PropRetainAvailable 170,PropContentType +// "\235\191^1\239\207{\139f\195",PropReceiveMaximum 2421,PropPayloadFormatIndicator 171,PropAuthenticationMethod +// "n\USj\187\ACK\142\213\NAK\220",PropRetainAvailable 210,PropAuthenticationMethod +// "K\173\189o3'\DC1\EM\197\181\144\152.\157",PropAuthenticationMethod "\242/\152\208",PropAuthenticationData +// "\DC4\141bJ\171o\SUBlv\220\DC3\233\203\ETX4\NUL\241\195S\182\145\n\240"]} +TEST(Publish5QCTest, Encode83) { + uint8_t pkt[] = { + 0x33, 0xb2, 0x2, 0x0, 0x1a, 0x20, 0x6f, 0xd1, 0x7e, 0xd1, 0xf2, 0xb0, 0xa1, 0x4c, 0x6c, 0x45, 0x56, 0x11, 0x85, + 0x8f, 0xed, 0x27, 0x59, 0x36, 0xd4, 0x85, 0x48, 0x7, 0xf1, 0x30, 0x61, 0x5, 0xba, 0xfb, 0x1, 0x1a, 0x0, 0x14, + 0x64, 0xe6, 0xde, 0x5f, 0xeb, 0x13, 0x9, 0xf9, 0xef, 0xd6, 0x5e, 0x7a, 0xbe, 0xd4, 0x92, 0x3b, 0xb7, 0x59, 0x5f, + 0xfb, 0x15, 0x0, 0x13, 0x2f, 0xa1, 0x8f, 0x3b, 0x1c, 0x42, 0xa0, 0x45, 0x15, 0x39, 0x65, 0x72, 0x9a, 0x97, 0x48, + 0x51, 0xfe, 0xa9, 0x52, 0x15, 0x0, 0xd, 0xf8, 0x1, 0xa9, 0x20, 0x25, 0x94, 0xb5, 0xf8, 0x5b, 0x3c, 0x80, 0xf7, + 0x6b, 0x1a, 0x0, 0x15, 0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0xf0, 0x30, 0xc0, 0xdf, 0x1d, 0xcd, 0x99, 0xf1, 0x3e, 0x4e, 0xa7, 0x38, 0x6c, 0x14, 0x97, 0x78, 0xaa, 0xe5, 0x1c, + 0x13, 0x73, 0x80, 0x87, 0xde}; + + uint8_t buf[319] = {0}; + + uint8_t topic_bytes[] = {0x20, 0x6f, 0xd1, 0x7e, 0xd1, 0xf2, 0xb0, 0xa1, 0x4c, 0x6c, 0x45, 0x56, 0x11, + 0x85, 0x8f, 0xed, 0x27, 0x59, 0x36, 0xd4, 0x85, 0x48, 0x7, 0xf1, 0x30, 0x61}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xdd, 0x6, 0xc7, 0x90, 0x4, 0x76, 0x6, 0xd9, 0x5c}; + uint8_t msg_bytes[] = {0x30, 0xc0, 0xdf, 0x1d, 0xcd, 0x99, 0xf1, 0x3e, 0x4e, 0xa7, 0x38, 0x6c, + 0x14, 0x97, 0x78, 0xaa, 0xe5, 0x1c, 0x13, 0x73, 0x80, 0x87, 0xde}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; - - uint8_t bytes1[] = {0xd7, 0x8e, 0xf7, 0xaa, 0x2e, 0xa6, 0xe3, 0x84, 0xb7, 0x3d, 0x60}; - uint8_t bytes0[] = {0x65, 0x8d, 0x8, 0xfc, 0x27, 0xb7, 0x3c, 0x68, 0x80, 0x8b, 0x56, - 0x2d, 0x70, 0x46, 0x46, 0x20, 0x10, 0x66, 0x9, 0x8b, 0x55}; - uint8_t bytes2[] = {0xb, 0xee, 0x87, 0x6b, 0xf1, 0xa8, 0xda, 0xc9, 0x0, 0xca, 0xf9, 0xed, 0x81, 0xb3, 0xc4, - 0xc2, 0xb8, 0xfc, 0x2a, 0x67, 0x9f, 0xf8, 0x2d, 0x7, 0xe0, 0xa5, 0x9d, 0x88, 0x8c, 0x2e}; - uint8_t bytes3[] = {0x23, 0x3}; + msg.payload_len = 23; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3513}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes0}, .v = {11, (char*)&bytes1}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9225}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30207}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytes3}}}, + uint8_t bytesprops0[] = {0x64, 0xe6, 0xde, 0x5f, 0xeb, 0x13, 0x9, 0xf9, 0xef, 0xd6, + 0x5e, 0x7a, 0xbe, 0xd4, 0x92, 0x3b, 0xb7, 0x59, 0x5f, 0xfb}; + uint8_t bytesprops1[] = {0x2f, 0xa1, 0x8f, 0x3b, 0x1c, 0x42, 0xa0, 0x45, 0x15, 0x39, + 0x65, 0x72, 0x9a, 0x97, 0x48, 0x51, 0xfe, 0xa9, 0x52}; + uint8_t bytesprops2[] = {0xf8, 0x1, 0xa9, 0x20, 0x25, 0x94, 0xb5, 0xf8, 0x5b, 0x3c, 0x80, 0xf7, 0x6b}; + uint8_t bytesprops3[] = {0xc4, 0x71, 0x55, 0x32, 0x4c, 0x7a, 0x92, 0xdf, 0x79, 0x5a, 0x5, + 0xfd, 0x32, 0x12, 0x68, 0x88, 0x9b, 0x63, 0x3b, 0xc9, 0x7f}; + uint8_t bytesprops5[] = {0xd5, 0x41}; + uint8_t bytesprops4[] = {0x54, 0xa6, 0xf8, 0xed, 0x96, 0xa, 0xda, 0x5, 0x15, 0x25, 0xf2, 0xbb, 0xd9, + 0xa6, 0x26, 0x2f, 0x7d, 0xa3, 0x7f, 0xf3, 0x7f, 0xfd, 0x98, 0x94, 0x9f}; + uint8_t bytesprops6[] = {0x79, 0xaa, 0xe2, 0x14, 0x32, 0x24, 0x6e, 0x21, 0xed, 0x46, 0x88, 0x1c, + 0x39, 0xb4, 0x9e, 0x34, 0x7a, 0x47, 0x82, 0x7c, 0x1d, 0x21, 0x84}; + uint8_t bytesprops7[] = {0xeb, 0xbf, 0x5e, 0x31, 0xef, 0xcf, 0x7b, 0x8b, 0x66, 0xc3}; + uint8_t bytesprops8[] = {0x6e, 0x1f, 0x6a, 0xbb, 0x6, 0x8e, 0xd5, 0x15, 0xdc}; + uint8_t bytesprops9[] = {0x4b, 0xad, 0xbd, 0x6f, 0x33, 0x27, 0x11, 0x19, 0xc5, 0xb5, 0x90, 0x98, 0x2e, 0x9d}; + uint8_t bytesprops10[] = {0xf2, 0x2f, 0x98, 0xd0}; + uint8_t bytesprops11[] = {0x14, 0x8d, 0x62, 0x4a, 0xab, 0x6f, 0x1a, 0x6c, 0x76, 0xdc, 0x13, 0xe9, + 0xcb, 0x3, 0x34, 0x0, 0xf1, 0xc3, 0x53, 0xb6, 0x91, 0xa, 0xf0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19917}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21423}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2421}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29034, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1466, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201y\171\155\184C", _pubPktID = 0, -// _pubBody = "\180\178\&2\194\SUB5Z\254\US\217\144\t:4a\154\203\201\ETX\DC3\246_[<\224", _pubProps = -// [PropServerReference ">\204\&0",PropWildcardSubscriptionAvailable 133,PropRequestProblemInformation -// 134,PropTopicAliasMaximum 26123,PropMessageExpiryInterval 31900,PropPayloadFormatIndicator 100,PropMaximumQoS -// 25,PropSubscriptionIdentifier 24]} -TEST(Publish50QCTest, Encode85) { - uint8_t pkt[] = {0x38, 0x3a, 0x0, 0x6, 0xc9, 0x79, 0xab, 0x9b, 0xb8, 0x43, 0x18, 0x1c, 0x0, 0x3, 0x3e, - 0xcc, 0x30, 0x28, 0x85, 0x17, 0x86, 0x22, 0x66, 0xb, 0x2, 0x0, 0x0, 0x7c, 0x9c, 0x1, - 0x64, 0x24, 0x19, 0xb, 0x18, 0xb4, 0xb2, 0x32, 0xc2, 0x1a, 0x35, 0x5a, 0xfe, 0x1f, 0xd9, - 0x90, 0x9, 0x3a, 0x34, 0x61, 0x9a, 0xcb, 0xc9, 0x3, 0x13, 0xf6, 0x5f, 0x5b, 0x3c, 0xe0}; - - uint8_t buf[70] = {0}; - - uint8_t topic_bytes[] = {0xc9, 0x79, 0xab, 0x9b, 0xb8, 0x43}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\201%\197.\f\247\DC3\198kM\237D\184\RS\ENQ<\183\215\RS\217\200", _pubPktID = 0, _pubBody = ">@1E\209$\188\249zd", +// _pubProps = [PropServerReference "\ETX-_",PropMessageExpiryInterval 25845,PropMaximumQoS +// 144,PropMessageExpiryInterval 5141,PropSessionExpiryInterval 28057,PropContentType +// "y\DC3b\131#\DC3\EOT\205\ETB-\226\223\247",PropContentType "}%\ETX\t",PropReasonString "D\ENQ",PropServerKeepAlive +// 23556,PropMessageExpiryInterval 5144,PropAssignedClientIdentifier +// "\191\136'\152\SO\194\SUB\175\214\149",PropAuthenticationMethod +// "\185G1\255!\218\NULt\212\230(\221,\214`5\252)@\217<\234\161\194\190\128#\135\227v",PropReceiveMaximum +// 20953,PropCorrelationData "\197I\b\242,\220\160\207b3\188\n\SIo\185",PropContentType +// "\SOH;K\129\173\&7^\218\205P\191HC\USK",PropRequestProblemInformation 89]} +TEST(Publish5QCTest, Encode84) { + uint8_t pkt[]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_t topic_bytes[] = {0xc9, 0x25, 0xc5, 0x2e, 0xc, 0xf7, 0x13, 0xc6, 0x6b, 0x4d, 0xed, + 0x44, 0xb8, 0x1e, 0x5, 0x3c, 0xb7, 0xd7, 0x1e, 0xd9, 0xc8}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xb4, 0xb2, 0x32, 0xc2, 0x1a, 0x35, 0x5a, 0xfe, 0x1f, 0xd9, 0x90, 0x9, 0x3a, - 0x34, 0x61, 0x9a, 0xcb, 0xc9, 0x3, 0x13, 0xf6, 0x5f, 0x5b, 0x3c, 0xe0}; + uint8_t msg_bytes[] = {0x3e, 0x40, 0x31, 0x45, 0xd1, 0x24, 0xbc, 0xf9, 0x7a, 0x64}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; - - uint8_t bytes0[] = {0x3e, 0xcc, 0x30}; + msg.payload_len = 10; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26123}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31900}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + uint8_t bytesprops0[] = {0x3, 0x2d, 0x5f}; + uint8_t bytesprops1[] = {0x79, 0x13, 0x62, 0x83, 0x23, 0x13, 0x4, 0xcd, 0x17, 0x2d, 0xe2, 0xdf, 0xf7}; + uint8_t bytesprops2[] = {0x7d, 0x25, 0x3, 0x9}; + uint8_t bytesprops3[] = {0x44, 0x5}; + uint8_t bytesprops4[] = {0xbf, 0x88, 0x27, 0x98, 0xe, 0xc2, 0x1a, 0xaf, 0xd6, 0x95}; + uint8_t bytesprops5[] = {0xb9, 0x47, 0x31, 0xff, 0x21, 0xda, 0x0, 0x74, 0xd4, 0xe6, 0x28, 0xdd, 0x2c, 0xd6, 0x60, + 0x35, 0xfc, 0x29, 0x40, 0xd9, 0x3c, 0xea, 0xa1, 0xc2, 0xbe, 0x80, 0x23, 0x87, 0xe3, 0x76}; + uint8_t bytesprops6[] = {0xc5, 0x49, 0x8, 0xf2, 0x2c, 0xdc, 0xa0, 0xcf, 0x62, 0x33, 0xbc, 0xa, 0xf, 0x6f, 0xb9}; + uint8_t bytesprops7[] = {0x1, 0x3b, 0x4b, 0x81, 0xad, 0x37, 0x5e, 0xda, 0xcd, 0x50, 0xbf, 0x48, 0x43, 0x1f, 0x4b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25845}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5141}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28057}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23556}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5144}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20953}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 89}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "}q\213-\168\195\252$\139j^\DC1o\198\RS\172\159q", _pubPktID = 8388, _pubBody = "\196\&7\f\aA\EOT", _pubProps = -// [PropTopicAlias 5216]} -TEST(Publish50QCTest, Encode86) { - uint8_t pkt[] = {0x32, 0x20, 0x0, 0x12, 0x7d, 0x71, 0xd5, 0x2d, 0xa8, 0xc3, 0xfc, 0x24, 0x8b, 0x6a, 0x5e, 0x11, 0x6f, - 0xc6, 0x1e, 0xac, 0x9f, 0x71, 0x20, 0xc4, 0x3, 0x23, 0x14, 0x60, 0xc4, 0x37, 0xc, 0x7, 0x41, 0x4}; - - uint8_t buf[44] = {0}; - - uint8_t topic_bytes[] = {0x7d, 0x71, 0xd5, 0x2d, 0xa8, 0xc3, 0xfc, 0x24, 0x8b, - 0x6a, 0x5e, 0x11, 0x6f, 0xc6, 0x1e, 0xac, 0x9f, 0x71}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\ACK\180\\\144\214%\183\192\168\129", +// _pubPktID = 5193, _pubBody = "\SOH\135\136&\\\133\174\132\244\244\"", _pubProps = [PropContentType +// "o\175\134\150\199\168V!\a\193\243v\192\DC2\226l",PropReceiveMaximum 26703,PropMessageExpiryInterval +// 25645,PropMessageExpiryInterval 13097,PropServerKeepAlive 22523,PropWildcardSubscriptionAvailable 183,PropContentType +// "\241\&0\251P$\221\223\&8#",PropWillDelayInterval 13818,PropSessionExpiryInterval 9707,PropRetainAvailable +// 49,PropRequestProblemInformation 189,PropContentType +// "\209jJ\151`E\239\220m\184T4$f9\200\STX\CAN?#\196\201)\151\225\196",PropMessageExpiryInterval +// 26226,PropMessageExpiryInterval 28825,PropSubscriptionIdentifier 0,PropReceiveMaximum 23784,PropWillDelayInterval +// 23963,PropResponseTopic "\152UD\222\149Uk",PropWildcardSubscriptionAvailable 60,PropReceiveMaximum +// 19669,PropMaximumQoS 175,PropResponseInformation "'\229!\138\183\&1*\173",PropReceiveMaximum 13680,PropResponseTopic +// "\163\233\152\FSt\200\157\154H\246\SO"]} +TEST(Publish5QCTest, Encode85) { + uint8_t pkt[] = { + 0x3b, 0xb8, 0x1, 0x0, 0xa, 0x6, 0xb4, 0x5c, 0x90, 0xd6, 0x25, 0xb7, 0xc0, 0xa8, 0x81, 0x14, 0x49, 0x9d, 0x1, + 0x3, 0x0, 0x10, 0x6f, 0xaf, 0x86, 0x96, 0xc7, 0xa8, 0x56, 0x21, 0x7, 0xc1, 0xf3, 0x76, 0xc0, 0x12, 0xe2, 0x6c, + 0x21, 0x68, 0x4f, 0x2, 0x0, 0x0, 0x64, 0x2d, 0x2, 0x0, 0x0, 0x33, 0x29, 0x13, 0x57, 0xfb, 0x28, 0xb7, 0x3, + 0x0, 0x9, 0xf1, 0x30, 0xfb, 0x50, 0x24, 0xdd, 0xdf, 0x38, 0x23, 0x18, 0x0, 0x0, 0x35, 0xfa, 0x11, 0x0, 0x0, + 0x25, 0xeb, 0x25, 0x31, 0x17, 0xbd, 0x3, 0x0, 0x1a, 0xd1, 0x6a, 0x4a, 0x97, 0x60, 0x45, 0xef, 0xdc, 0x6d, 0xb8, + 0x54, 0x34, 0x24, 0x66, 0x39, 0xc8, 0x2, 0x18, 0x3f, 0x23, 0xc4, 0xc9, 0x29, 0x97, 0xe1, 0xc4, 0x2, 0x0, 0x0, + 0x66, 0x72, 0x2, 0x0, 0x0, 0x70, 0x99, 0xb, 0x0, 0x21, 0x5c, 0xe8, 0x18, 0x0, 0x0, 0x5d, 0x9b, 0x8, 0x0, + 0x7, 0x98, 0x55, 0x44, 0xde, 0x95, 0x55, 0x6b, 0x28, 0x3c, 0x21, 0x4c, 0xd5, 0x24, 0xaf, 0x1a, 0x0, 0x8, 0x27, + 0xe5, 0x21, 0x8a, 0xb7, 0x31, 0x2a, 0xad, 0x21, 0x35, 0x70, 0x8, 0x0, 0xb, 0xa3, 0xe9, 0x98, 0x1c, 0x74, 0xc8, + 0x9d, 0x9a, 0x48, 0xf6, 0xe, 0x1, 0x87, 0x88, 0x26, 0x5c, 0x85, 0xae, 0x84, 0xf4, 0xf4, 0x22}; + + uint8_t buf[197] = {0}; + + uint8_t topic_bytes[] = {0x6, 0xb4, 0x5c, 0x90, 0xd6, 0x25, 0xb7, 0xc0, 0xa8, 0x81}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xc4, 0x37, 0xc, 0x7, 0x41, 0x4}; + msg.retained = true; + uint8_t msg_bytes[] = {0x1, 0x87, 0x88, 0x26, 0x5c, 0x85, 0xae, 0x84, 0xf4, 0xf4, 0x22}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 11; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5216}}, + uint8_t bytesprops0[] = {0x6f, 0xaf, 0x86, 0x96, 0xc7, 0xa8, 0x56, 0x21, + 0x7, 0xc1, 0xf3, 0x76, 0xc0, 0x12, 0xe2, 0x6c}; + uint8_t bytesprops1[] = {0xf1, 0x30, 0xfb, 0x50, 0x24, 0xdd, 0xdf, 0x38, 0x23}; + uint8_t bytesprops2[] = {0xd1, 0x6a, 0x4a, 0x97, 0x60, 0x45, 0xef, 0xdc, 0x6d, 0xb8, 0x54, 0x34, 0x24, + 0x66, 0x39, 0xc8, 0x2, 0x18, 0x3f, 0x23, 0xc4, 0xc9, 0x29, 0x97, 0xe1, 0xc4}; + uint8_t bytesprops3[] = {0x98, 0x55, 0x44, 0xde, 0x95, 0x55, 0x6b}; + uint8_t bytesprops4[] = {0x27, 0xe5, 0x21, 0x8a, 0xb7, 0x31, 0x2a, 0xad}; + uint8_t bytesprops5[] = {0xa3, 0xe9, 0x98, 0x1c, 0x74, 0xc8, 0x9d, 0x9a, 0x48, 0xf6, 0xe}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26703}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25645}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13097}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22523}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13818}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9707}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26226}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28825}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23784}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23963}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19669}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13680}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 8388, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5193, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\214\177\ETBL\143\b\216", _pubPktID -// = 466, _pubBody = "sz\183u\DC3:\199\242\216%\137\EM\a\203\242\209\144\194fR6\240\163&\200H", _pubProps = -// [PropSharedSubscriptionAvailable 47,PropRequestProblemInformation 51,PropPayloadFormatIndicator -// 185,PropServerReference "\207\205\ACK\148\196'\225\159\ENQG0\238`r4\135\ENQ\136\149\190",PropMaximumPacketSize -// 612,PropReasonString -// "\181\203E\b\225?8745\236\172$\f\228\247\153\186\163\214\DLE\176\205\b\164\248",PropServerKeepAlive -// 22517,PropAuthenticationMethod "",PropAuthenticationData -// "\a\DC4b7A>\249\247\239>\a\162\216\195",PropMaximumPacketSize 21926,PropAssignedClientIdentifier -// "U\a\203K\156\203\198bi\193\144\143\246XZ\133X",PropAuthenticationData -// "w(2\212\162^R\186\b\CAN\226o/;\155C\184\174\157S~\224Y\DC3\CAN\154r",PropAuthenticationMethod -// ">\254\169\246\252\233\&5\198\noB\228\129tT\237\204",PropMessageExpiryInterval 826,PropMessageExpiryInterval -// 29414,PropTopicAlias 6110,PropMaximumPacketSize 29501,PropMessageExpiryInterval 15604,PropServerReference -// "v\DC2\EOT$\195\182\146\252\207XI\FSF\197\217Sw\207I0e\201\205oj\196\129",PropPayloadFormatIndicator -// 53,PropReceiveMaximum 26780,PropRequestProblemInformation 218]} -TEST(Publish50QCTest, Encode87) { - uint8_t pkt[] = { - 0x34, 0x84, 0x2, 0x0, 0x7, 0xd6, 0xb1, 0x17, 0x4c, 0x8f, 0x8, 0xd8, 0x1, 0xd2, 0xdd, 0x1, 0x2a, 0x2f, 0x17, - 0x33, 0x1, 0xb9, 0x1c, 0x0, 0x14, 0xcf, 0xcd, 0x6, 0x94, 0xc4, 0x27, 0xe1, 0x9f, 0x5, 0x47, 0x30, 0xee, 0x60, - 0x72, 0x34, 0x87, 0x5, 0x88, 0x95, 0xbe, 0x27, 0x0, 0x0, 0x2, 0x64, 0x1f, 0x0, 0x1a, 0xb5, 0xcb, 0x45, 0x8, - 0xe1, 0x3f, 0x38, 0x37, 0x34, 0x35, 0xec, 0xac, 0x24, 0xc, 0xe4, 0xf7, 0x99, 0xba, 0xa3, 0xd6, 0x10, 0xb0, 0xcd, - 0x8, 0xa4, 0xf8, 0x13, 0x57, 0xf5, 0x15, 0x0, 0x0, 0x16, 0x0, 0xe, 0x7, 0x14, 0x62, 0x37, 0x41, 0x3e, 0xf9, - 0xf7, 0xef, 0x3e, 0x7, 0xa2, 0xd8, 0xc3, 0x27, 0x0, 0x0, 0x55, 0xa6, 0x12, 0x0, 0x11, 0x55, 0x7, 0xcb, 0x4b, - 0x9c, 0xcb, 0xc6, 0x62, 0x69, 0xc1, 0x90, 0x8f, 0xf6, 0x58, 0x5a, 0x85, 0x58, 0x16, 0x0, 0x1b, 0x77, 0x28, 0x32, - 0xd4, 0xa2, 0x5e, 0x52, 0xba, 0x8, 0x18, 0xe2, 0x6f, 0x2f, 0x3b, 0x9b, 0x43, 0xb8, 0xae, 0x9d, 0x53, 0x7e, 0xe0, - 0x59, 0x13, 0x18, 0x9a, 0x72, 0x15, 0x0, 0x11, 0x3e, 0xfe, 0xa9, 0xf6, 0xfc, 0xe9, 0x35, 0xc6, 0xa, 0x6f, 0x42, - 0xe4, 0x81, 0x74, 0x54, 0xed, 0xcc, 0x2, 0x0, 0x0, 0x3, 0x3a, 0x2, 0x0, 0x0, 0x72, 0xe6, 0x23, 0x17, 0xde, - 0x27, 0x0, 0x0, 0x73, 0x3d, 0x2, 0x0, 0x0, 0x3c, 0xf4, 0x1c, 0x0, 0x1b, 0x76, 0x12, 0x4, 0x24, 0xc3, 0xb6, - 0x92, 0xfc, 0xcf, 0x58, 0x49, 0x1c, 0x46, 0xc5, 0xd9, 0x53, 0x77, 0xcf, 0x49, 0x30, 0x65, 0xc9, 0xcd, 0x6f, 0x6a, - 0xc4, 0x81, 0x1, 0x35, 0x21, 0x68, 0x9c, 0x17, 0xda, 0x73, 0x7a, 0xb7, 0x75, 0x13, 0x3a, 0xc7, 0xf2, 0xd8, 0x25, - 0x89, 0x19, 0x7, 0xcb, 0xf2, 0xd1, 0x90, 0xc2, 0x66, 0x52, 0x36, 0xf0, 0xa3, 0x26, 0xc8, 0x48}; - - uint8_t buf[273] = {0}; - - uint8_t topic_bytes[] = {0xd6, 0xb1, 0x17, 0x4c, 0x8f, 0x8, 0xd8}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\235c\197\&9\FS\179\195b6\STX\195n\216\&3\213\vpu\137v\147o\200\233", _pubPktID = 40, _pubBody = +// "\150\169\128N}\US\133\146\160\ENQ\253N\247", _pubProps = [PropWildcardSubscriptionAvailable +// 17,PropAssignedClientIdentifier "a\176\US",PropTopicAlias 25003,PropServerReference +// "\198~d\245\202w\CAN\SO\157\149~s=\254",PropUserProperty "\SUB&\223\DC3i\242\249\&5\\\144" +// "\135\DC2;>H\187\234\ENQ`\162\160\168`\141\134\209\156\146D\229\133\255\219\243\196`\DC3\217",PropServerKeepAlive +// 9027,PropWillDelayInterval 14049,PropUserProperty +// "x|I\173\&9\165av\NAKz\168%\EOT\192\RS\244\243$\240\NAKn\190\220a\171\172\DEL\135" +// "\234\192:",PropMessageExpiryInterval 17923]} +TEST(Publish5QCTest, Encode86) { + uint8_t pkt[] = {0x35, 0xa2, 0x1, 0x0, 0x18, 0xeb, 0x63, 0xc5, 0x39, 0x1c, 0xb3, 0xc3, 0x62, 0x36, 0x2, 0xc3, 0x6e, + 0xd8, 0x33, 0xd5, 0xb, 0x70, 0x75, 0x89, 0x76, 0x93, 0x6f, 0xc8, 0xe9, 0x0, 0x28, 0x78, 0x28, 0x11, + 0x12, 0x0, 0x3, 0x61, 0xb0, 0x1f, 0x23, 0x61, 0xab, 0x1c, 0x0, 0xe, 0xc6, 0x7e, 0x64, 0xf5, 0xca, + 0x77, 0x18, 0xe, 0x9d, 0x95, 0x7e, 0x73, 0x3d, 0xfe, 0x26, 0x0, 0xa, 0x1a, 0x26, 0xdf, 0x13, 0x69, + 0xf2, 0xf9, 0x35, 0x5c, 0x90, 0x0, 0x1c, 0x87, 0x12, 0x3b, 0x3e, 0x48, 0xbb, 0xea, 0x5, 0x60, 0xa2, + 0xa0, 0xa8, 0x60, 0x8d, 0x86, 0xd1, 0x9c, 0x92, 0x44, 0xe5, 0x85, 0xff, 0xdb, 0xf3, 0xc4, 0x60, 0x13, + 0xd9, 0x13, 0x23, 0x43, 0x18, 0x0, 0x0, 0x36, 0xe1, 0x26, 0x0, 0x1c, 0x78, 0x7c, 0x49, 0xad, 0x39, + 0xa5, 0x61, 0x76, 0x15, 0x7a, 0xa8, 0x25, 0x4, 0xc0, 0x1e, 0xf4, 0xf3, 0x24, 0xf0, 0x15, 0x6e, 0xbe, + 0xdc, 0x61, 0xab, 0xac, 0x7f, 0x87, 0x0, 0x3, 0xea, 0xc0, 0x3a, 0x2, 0x0, 0x0, 0x46, 0x3, 0x96, + 0xa9, 0x80, 0x4e, 0x7d, 0x1f, 0x85, 0x92, 0xa0, 0x5, 0xfd, 0x4e, 0xf7}; + + uint8_t buf[175] = {0}; + + uint8_t topic_bytes[] = {0xeb, 0x63, 0xc5, 0x39, 0x1c, 0xb3, 0xc3, 0x62, 0x36, 0x2, 0xc3, 0x6e, + 0xd8, 0x33, 0xd5, 0xb, 0x70, 0x75, 0x89, 0x76, 0x93, 0x6f, 0xc8, 0xe9}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x73, 0x7a, 0xb7, 0x75, 0x13, 0x3a, 0xc7, 0xf2, 0xd8, 0x25, 0x89, 0x19, 0x7, - 0xcb, 0xf2, 0xd1, 0x90, 0xc2, 0x66, 0x52, 0x36, 0xf0, 0xa3, 0x26, 0xc8, 0x48}; + msg.retained = true; + uint8_t msg_bytes[] = {0x96, 0xa9, 0x80, 0x4e, 0x7d, 0x1f, 0x85, 0x92, 0xa0, 0x5, 0xfd, 0x4e, 0xf7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 13; - uint8_t bytes0[] = {0xcf, 0xcd, 0x6, 0x94, 0xc4, 0x27, 0xe1, 0x9f, 0x5, 0x47, - 0x30, 0xee, 0x60, 0x72, 0x34, 0x87, 0x5, 0x88, 0x95, 0xbe}; - uint8_t bytes1[] = {0xb5, 0xcb, 0x45, 0x8, 0xe1, 0x3f, 0x38, 0x37, 0x34, 0x35, 0xec, 0xac, 0x24, - 0xc, 0xe4, 0xf7, 0x99, 0xba, 0xa3, 0xd6, 0x10, 0xb0, 0xcd, 0x8, 0xa4, 0xf8}; - uint8_t bytes2[] = {0}; - uint8_t bytes3[] = {0x7, 0x14, 0x62, 0x37, 0x41, 0x3e, 0xf9, 0xf7, 0xef, 0x3e, 0x7, 0xa2, 0xd8, 0xc3}; - uint8_t bytes4[] = {0x55, 0x7, 0xcb, 0x4b, 0x9c, 0xcb, 0xc6, 0x62, 0x69, - 0xc1, 0x90, 0x8f, 0xf6, 0x58, 0x5a, 0x85, 0x58}; - uint8_t bytes5[] = {0x77, 0x28, 0x32, 0xd4, 0xa2, 0x5e, 0x52, 0xba, 0x8, 0x18, 0xe2, 0x6f, 0x2f, 0x3b, - 0x9b, 0x43, 0xb8, 0xae, 0x9d, 0x53, 0x7e, 0xe0, 0x59, 0x13, 0x18, 0x9a, 0x72}; - uint8_t bytes6[] = {0x3e, 0xfe, 0xa9, 0xf6, 0xfc, 0xe9, 0x35, 0xc6, 0xa, - 0x6f, 0x42, 0xe4, 0x81, 0x74, 0x54, 0xed, 0xcc}; - uint8_t bytes7[] = {0x76, 0x12, 0x4, 0x24, 0xc3, 0xb6, 0x92, 0xfc, 0xcf, 0x58, 0x49, 0x1c, 0x46, 0xc5, - 0xd9, 0x53, 0x77, 0xcf, 0x49, 0x30, 0x65, 0xc9, 0xcd, 0x6f, 0x6a, 0xc4, 0x81}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 612}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22517}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21926}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 826}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29414}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6110}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29501}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15604}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26780}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 218}}, + uint8_t bytesprops0[] = {0x61, 0xb0, 0x1f}; + uint8_t bytesprops1[] = {0xc6, 0x7e, 0x64, 0xf5, 0xca, 0x77, 0x18, 0xe, 0x9d, 0x95, 0x7e, 0x73, 0x3d, 0xfe}; + uint8_t bytesprops3[] = {0x87, 0x12, 0x3b, 0x3e, 0x48, 0xbb, 0xea, 0x5, 0x60, 0xa2, 0xa0, 0xa8, 0x60, 0x8d, + 0x86, 0xd1, 0x9c, 0x92, 0x44, 0xe5, 0x85, 0xff, 0xdb, 0xf3, 0xc4, 0x60, 0x13, 0xd9}; + uint8_t bytesprops2[] = {0x1a, 0x26, 0xdf, 0x13, 0x69, 0xf2, 0xf9, 0x35, 0x5c, 0x90}; + uint8_t bytesprops5[] = {0xea, 0xc0, 0x3a}; + uint8_t bytesprops4[] = {0x78, 0x7c, 0x49, 0xad, 0x39, 0xa5, 0x61, 0x76, 0x15, 0x7a, 0xa8, 0x25, 0x4, 0xc0, + 0x1e, 0xf4, 0xf3, 0x24, 0xf0, 0x15, 0x6e, 0xbe, 0xdc, 0x61, 0xab, 0xac, 0x7f, 0x87}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25003}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {28, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9027}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14049}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops4}, .v = {3, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17923}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 466, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 40, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\STX\213\240cI\204T-w\154\192|#=\254P\DC24\200\170\228\NUL\186\147/\225\193\b\FS\140", _pubPktID = 26668, _pubBody = -// ".T\237(\238\DELg0 \GS\STX\215*\156\169t\147\b\206\149\172\r\211\RS\205 5\US\t0", _pubProps = [PropContentType -// "6\198\194G\158_",PropReasonString "\249\167\172\RS/z\220\228",PropPayloadFormatIndicator 170,PropTopicAlias -// 21820,PropAuthenticationMethod "z\139\GS\152\133kU\143",PropResponseInformation -// "\189\218Yv\197\231\179q\216\219\DC2q'\131\227\DLEs}\NUL\200\203o\247y\202\177",PropServerReference -// "H\154\225&\139\196}.\aM~\218",PropWildcardSubscriptionAvailable 175,PropSharedSubscriptionAvailable -// 51,PropRequestProblemInformation 186,PropUserProperty -// "\SUB\200\198\242\189\161\v\242K\145C\155\168\162\204\213Kq\224\180n" -// "k\141Bq@^\DC3\210\226\163\222\211\254\214\211\253",PropTopicAlias 6507]} -TEST(Publish50QCTest, Encode88) { - uint8_t pkt[] = {0x33, 0xc5, 0x1, 0x0, 0x1e, 0x2, 0xd5, 0xf0, 0x63, 0x49, 0xcc, 0x54, 0x2d, 0x77, 0x9a, 0xc0, 0x7c, - 0x23, 0x3d, 0xfe, 0x50, 0x12, 0x34, 0xc8, 0xaa, 0xe4, 0x0, 0xba, 0x93, 0x2f, 0xe1, 0xc1, 0x8, 0x1c, - 0x8c, 0x68, 0x2c, 0x83, 0x1, 0x3, 0x0, 0x6, 0x36, 0xc6, 0xc2, 0x47, 0x9e, 0x5f, 0x1f, 0x0, 0x8, - 0xf9, 0xa7, 0xac, 0x1e, 0x2f, 0x7a, 0xdc, 0xe4, 0x1, 0xaa, 0x23, 0x55, 0x3c, 0x15, 0x0, 0x8, 0x7a, - 0x8b, 0x1d, 0x98, 0x85, 0x6b, 0x55, 0x8f, 0x1a, 0x0, 0x1a, 0xbd, 0xda, 0x59, 0x76, 0xc5, 0xe7, 0xb3, - 0x71, 0xd8, 0xdb, 0x12, 0x71, 0x27, 0x83, 0xe3, 0x10, 0x73, 0x7d, 0x0, 0xc8, 0xcb, 0x6f, 0xf7, 0x79, - 0xca, 0xb1, 0x1c, 0x0, 0xc, 0x48, 0x9a, 0xe1, 0x26, 0x8b, 0xc4, 0x7d, 0x2e, 0x7, 0x4d, 0x7e, 0xda, - 0x28, 0xaf, 0x2a, 0x33, 0x17, 0xba, 0x26, 0x0, 0x15, 0x1a, 0xc8, 0xc6, 0xf2, 0xbd, 0xa1, 0xb, 0xf2, - 0x4b, 0x91, 0x43, 0x9b, 0xa8, 0xa2, 0xcc, 0xd5, 0x4b, 0x71, 0xe0, 0xb4, 0x6e, 0x0, 0x10, 0x6b, 0x8d, - 0x42, 0x71, 0x40, 0x5e, 0x13, 0xd2, 0xe2, 0xa3, 0xde, 0xd3, 0xfe, 0xd6, 0xd3, 0xfd, 0x23, 0x19, 0x6b, - 0x2e, 0x54, 0xed, 0x28, 0xee, 0x7f, 0x67, 0x30, 0x20, 0x1d, 0x2, 0xd7, 0x2a, 0x9c, 0xa9, 0x74, 0x93, - 0x8, 0xce, 0x95, 0xac, 0xd, 0xd3, 0x1e, 0xcd, 0x20, 0x35, 0x1f, 0x9, 0x30}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\SIM;=\ETX\220\ETX\214o\159\228\157\195\144\184+\216gpE\208\DC3\228\211\238W\212\&2", _pubPktID = 0, _pubBody = +// "\ETX\175\STXN\144\216\212\205c\184|\142\&5i", _pubProps = [PropSubscriptionIdentifier 10,PropResponseTopic +// "O\193\137\GS_&gG\144\252#^Z\EM\200>\151j\136\253w\DC3x{\ETB(",PropMessageExpiryInterval 23659,PropMaximumQoS 14]} +TEST(Publish5QCTest, Encode87) { + uint8_t pkt[] = {0x31, 0x53, 0x0, 0x1c, 0xf, 0x4d, 0x3b, 0x3d, 0x3, 0xdc, 0x3, 0xd6, 0x6f, 0x9f, 0xe4, + 0x9d, 0xc3, 0x90, 0xb8, 0x2b, 0xd8, 0x67, 0x70, 0x45, 0xd0, 0x13, 0xe4, 0xd3, 0xee, 0x57, + 0xd4, 0x32, 0x26, 0xb, 0xa, 0x8, 0x0, 0x1a, 0x4f, 0xc1, 0x89, 0x1d, 0x5f, 0x26, 0x67, + 0x47, 0x90, 0xfc, 0x23, 0x5e, 0x5a, 0x19, 0xc8, 0x3e, 0x97, 0x6a, 0x88, 0xfd, 0x77, 0x13, + 0x78, 0x7b, 0x17, 0x28, 0x2, 0x0, 0x0, 0x5c, 0x6b, 0x24, 0xe, 0x3, 0xaf, 0x2, 0x4e, + 0x90, 0xd8, 0xd4, 0xcd, 0x63, 0xb8, 0x7c, 0x8e, 0x35, 0x69}; - uint8_t buf[210] = {0}; + uint8_t buf[95] = {0}; - uint8_t topic_bytes[] = {0x2, 0xd5, 0xf0, 0x63, 0x49, 0xcc, 0x54, 0x2d, 0x77, 0x9a, 0xc0, 0x7c, 0x23, 0x3d, 0xfe, - 0x50, 0x12, 0x34, 0xc8, 0xaa, 0xe4, 0x0, 0xba, 0x93, 0x2f, 0xe1, 0xc1, 0x8, 0x1c, 0x8c}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xf, 0x4d, 0x3b, 0x3d, 0x3, 0xdc, 0x3, 0xd6, 0x6f, 0x9f, 0xe4, 0x9d, 0xc3, 0x90, + 0xb8, 0x2b, 0xd8, 0x67, 0x70, 0x45, 0xd0, 0x13, 0xe4, 0xd3, 0xee, 0x57, 0xd4, 0x32}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x2e, 0x54, 0xed, 0x28, 0xee, 0x7f, 0x67, 0x30, 0x20, 0x1d, 0x2, 0xd7, 0x2a, 0x9c, 0xa9, - 0x74, 0x93, 0x8, 0xce, 0x95, 0xac, 0xd, 0xd3, 0x1e, 0xcd, 0x20, 0x35, 0x1f, 0x9, 0x30}; + uint8_t msg_bytes[] = {0x3, 0xaf, 0x2, 0x4e, 0x90, 0xd8, 0xd4, 0xcd, 0x63, 0xb8, 0x7c, 0x8e, 0x35, 0x69}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 14; - uint8_t bytes0[] = {0x36, 0xc6, 0xc2, 0x47, 0x9e, 0x5f}; - uint8_t bytes1[] = {0xf9, 0xa7, 0xac, 0x1e, 0x2f, 0x7a, 0xdc, 0xe4}; - uint8_t bytes2[] = {0x7a, 0x8b, 0x1d, 0x98, 0x85, 0x6b, 0x55, 0x8f}; - uint8_t bytes3[] = {0xbd, 0xda, 0x59, 0x76, 0xc5, 0xe7, 0xb3, 0x71, 0xd8, 0xdb, 0x12, 0x71, 0x27, - 0x83, 0xe3, 0x10, 0x73, 0x7d, 0x0, 0xc8, 0xcb, 0x6f, 0xf7, 0x79, 0xca, 0xb1}; - uint8_t bytes4[] = {0x48, 0x9a, 0xe1, 0x26, 0x8b, 0xc4, 0x7d, 0x2e, 0x7, 0x4d, 0x7e, 0xda}; - uint8_t bytes6[] = {0x6b, 0x8d, 0x42, 0x71, 0x40, 0x5e, 0x13, 0xd2, 0xe2, 0xa3, 0xde, 0xd3, 0xfe, 0xd6, 0xd3, 0xfd}; - uint8_t bytes5[] = {0x1a, 0xc8, 0xc6, 0xf2, 0xbd, 0xa1, 0xb, 0xf2, 0x4b, 0x91, 0x43, - 0x9b, 0xa8, 0xa2, 0xcc, 0xd5, 0x4b, 0x71, 0xe0, 0xb4, 0x6e}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21820}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytes5}, .v = {16, (char*)&bytes6}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6507}}, + uint8_t bytesprops0[] = {0x4f, 0xc1, 0x89, 0x1d, 0x5f, 0x26, 0x67, 0x47, 0x90, 0xfc, 0x23, 0x5e, 0x5a, + 0x19, 0xc8, 0x3e, 0x97, 0x6a, 0x88, 0xfd, 0x77, 0x13, 0x78, 0x7b, 0x17, 0x28}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23659}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 14}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 26668, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\"X\209\155% -// \FS1[\178\SI\134\232\SI\236n\212\r\FS", _pubPktID = 0, _pubBody = -// "`\190\143p\n\134\145\250\152\151,\233\245\224\143\FS\235_/\133\203", _pubProps = []} -TEST(Publish50QCTest, Encode89) { - uint8_t pkt[] = {0x39, 0x2b, 0x0, 0x13, 0x22, 0x58, 0xd1, 0x9b, 0x25, 0x20, 0x1c, 0x31, 0x5b, 0xb2, 0xf, - 0x86, 0xe8, 0xf, 0xec, 0x6e, 0xd4, 0xd, 0x1c, 0x0, 0x60, 0xbe, 0x8f, 0x70, 0xa, 0x86, - 0x91, 0xfa, 0x98, 0x97, 0x2c, 0xe9, 0xf5, 0xe0, 0x8f, 0x1c, 0xeb, 0x5f, 0x2f, 0x85, 0xcb}; - - uint8_t buf[55] = {0}; - - uint8_t topic_bytes[] = {0x22, 0x58, 0xd1, 0x9b, 0x25, 0x20, 0x1c, 0x31, 0x5b, 0xb2, - 0xf, 0x86, 0xe8, 0xf, 0xec, 0x6e, 0xd4, 0xd, 0x1c}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "p\185X\177s\138d\DLE.", _pubPktID = +// 29654, _pubBody = "\195o\ndF\GS\152\131\191\195;\253\248+\187y\251\129 4\244\145", _pubProps = [PropServerKeepAlive +// 26757,PropCorrelationData "\208l\212\236\139+\158\156Y\SUBdY\148\193\198\137\210*\205\208S\208D\209",PropUserProperty +// "\FS\203\241o\n" "@B\187\ETB!\214\DLE_\189P\205",PropAuthenticationData +// "\187\US\232\141\aQ",PropMessageExpiryInterval 30502,PropMessageExpiryInterval 11882,PropContentType +// "7I:b\193\246s\173\214\&7\t\f_\v"]} +TEST(Publish5QCTest, Encode88) { + uint8_t pkt[] = {0x3c, 0xa0, 0x1, 0x0, 0x9, 0x70, 0xb9, 0x58, 0xb1, 0x73, 0x8a, 0x64, 0x10, 0x2e, 0x73, 0xd6, 0x7c, + 0x13, 0x68, 0x85, 0x9, 0x0, 0x18, 0xd0, 0x6c, 0xd4, 0xec, 0x8b, 0x2b, 0x9e, 0x9c, 0x59, 0x1a, 0x64, + 0x59, 0x94, 0xc1, 0xc6, 0x89, 0xd2, 0x2a, 0xcd, 0xd0, 0x53, 0xd0, 0x44, 0xd1, 0x26, 0x0, 0x5, 0x1c, + 0xcb, 0xf1, 0x6f, 0xa, 0x0, 0xe, 0x40, 0x42, 0xbb, 0x17, 0x21, 0xd6, 0x10, 0x3c, 0x21, 0x53, 0x5a, + 0x5b, 0xad, 0xcd, 0x1c, 0x0, 0x9, 0xd4, 0x61, 0x5a, 0x20, 0xa7, 0x46, 0xeb, 0xe4, 0xd3, 0x17, 0x62, + 0x2a, 0xac, 0x2, 0x0, 0x0, 0x2c, 0xfe, 0xb, 0x12, 0x12, 0x0, 0x8, 0xf5, 0xf4, 0xa3, 0x3e, 0x5f, + 0xbd, 0x50, 0xcd, 0x16, 0x0, 0x6, 0xbb, 0x1f, 0xe8, 0x8d, 0x7, 0x51, 0x2, 0x0, 0x0, 0x77, 0x26, + 0x2, 0x0, 0x0, 0x2e, 0x6a, 0x3, 0x0, 0xe, 0x37, 0x49, 0x3a, 0x62, 0xc1, 0xf6, 0x73, 0xad, 0xd6, + 0x37, 0x9, 0xc, 0x5f, 0xb, 0xc3, 0x6f, 0xa, 0x64, 0x46, 0x1d, 0x98, 0x83, 0xbf, 0xc3, 0x3b, 0xfd, + 0xf8, 0x2b, 0xbb, 0x79, 0xfb, 0x81, 0x20, 0x34, 0xf4, 0x91}; + + uint8_t buf[173] = {0}; + + uint8_t topic_bytes[] = {0x70, 0xb9, 0x58, 0xb1, 0x73, 0x8a, 0x64, 0x10, 0x2e}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x60, 0xbe, 0x8f, 0x70, 0xa, 0x86, 0x91, 0xfa, 0x98, 0x97, 0x2c, - 0xe9, 0xf5, 0xe0, 0x8f, 0x1c, 0xeb, 0x5f, 0x2f, 0x85, 0xcb}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xc3, 0x6f, 0xa, 0x64, 0x46, 0x1d, 0x98, 0x83, 0xbf, 0xc3, 0x3b, + 0xfd, 0xf8, 0x2b, 0xbb, 0x79, 0xfb, 0x81, 0x20, 0x34, 0xf4, 0x91}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 22; - lwmqtt_property_t proplist[] = {}; + uint8_t bytesprops0[] = {0xd0, 0x6c, 0xd4, 0xec, 0x8b, 0x2b, 0x9e, 0x9c, 0x59, 0x1a, 0x64, 0x59, + 0x94, 0xc1, 0xc6, 0x89, 0xd2, 0x2a, 0xcd, 0xd0, 0x53, 0xd0, 0x44, 0xd1}; + uint8_t bytesprops2[] = {0x40, 0x42, 0xbb, 0x17, 0x21, 0xd6, 0x10, 0x3c, 0x21, 0x53, 0x5a, 0x5b, 0xad, 0xcd}; + uint8_t bytesprops1[] = {0x1c, 0xcb, 0xf1, 0x6f, 0xa}; + uint8_t bytesprops3[] = {0xd4, 0x61, 0x5a, 0x20, 0xa7, 0x46, 0xeb, 0xe4, 0xd3}; + uint8_t bytesprops4[] = {0xf5, 0xf4, 0xa3, 0x3e, 0x5f, 0xbd, 0x50, 0xcd}; + uint8_t bytesprops5[] = {0xbb, 0x1f, 0xe8, 0x8d, 0x7, 0x51}; + uint8_t bytesprops6[] = {0x37, 0x49, 0x3a, 0x62, 0xc1, 0xf6, 0x73, 0xad, 0xd6, 0x37, 0x9, 0xc, 0x5f, 0xb}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26757}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops1}, .v = {14, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11518}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30502}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11882}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops6}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29654, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\175\195\208b[q\226\128\DC4'", -// _pubPktID = 14979, _pubBody = "\US", _pubProps = [PropRetainAvailable 166,PropWildcardSubscriptionAvailable -// 171,PropReceiveMaximum 11631,PropSessionExpiryInterval 20049,PropAuthenticationMethod -// "i\191\170\DC3\254\220\DEL\172\235I\238\185\220~?\217\US$\251`R\NAK"]} -TEST(Publish50QCTest, Encode90) { - uint8_t pkt[] = {0x3c, 0x35, 0x0, 0xa, 0xaf, 0xc3, 0xd0, 0x62, 0x5b, 0x71, 0xe2, 0x80, 0x14, 0x27, - 0x3a, 0x83, 0x25, 0x25, 0xa6, 0x28, 0xab, 0x21, 0x2d, 0x6f, 0x11, 0x0, 0x0, 0x4e, - 0x51, 0x15, 0x0, 0x16, 0x69, 0xbf, 0xaa, 0x13, 0xfe, 0xdc, 0x7f, 0xac, 0xeb, 0x49, - 0xee, 0xb9, 0xdc, 0x7e, 0x3f, 0xd9, 0x1f, 0x24, 0xfb, 0x60, 0x52, 0x15, 0x1f}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\238\SYN\GSq4\148\154&", _pubPktID +// = 4746, _pubBody = "", _pubProps = [PropPayloadFormatIndicator 218,PropReasonString "p\t\158\r\134",PropMaximumQoS +// 42,PropPayloadFormatIndicator 36,PropUserProperty "\196" "\n|\204\152\233\210\153\140",PropResponseTopic +// "\149\218V+OX[",PropServerKeepAlive 8879,PropTopicAlias 12682,PropTopicAlias 1639,PropAuthenticationMethod +// "\219\214\231\236u\217\140\215NsP\184\191\\\229\NAK\236\144\CAN4\225\239",PropMaximumQoS +// 252,PropMessageExpiryInterval 24151,PropServerKeepAlive 13405,PropPayloadFormatIndicator 119,PropMaximumQoS +// 37,PropAuthenticationData +// "So\173>T\"\221J\RS\230\185\128\252\172$\ACK\DC1\177\157\159n>\219\DC2",PropMessageExpiryInterval +// 19289,PropServerReference "J\DC2\204R\191\147\146\231\227\212\189H\238K\136\187\v/",PropTopicAliasMaximum +// 21397,PropAuthenticationMethod "\184c\168\130^\153\201\225\245lG",PropAuthenticationMethod +// "\231\206e\135\134S\250y\227",PropTopicAlias 2018,PropRequestResponseInformation 95,PropMaximumPacketSize +// 20599,PropSharedSubscriptionAvailable 167,PropTopicAliasMaximum 10330]} +TEST(Publish5QCTest, Encode89) { + uint8_t pkt[] = {0x32, 0xc5, 0x1, 0x0, 0x8, 0xee, 0x16, 0x1d, 0x71, 0x34, 0x94, 0x9a, 0x26, 0x12, 0x8a, 0xb7, 0x1, + 0x1, 0xda, 0x1f, 0x0, 0x5, 0x70, 0x9, 0x9e, 0xd, 0x86, 0x24, 0x2a, 0x1, 0x24, 0x26, 0x0, 0x1, + 0xc4, 0x0, 0x8, 0xa, 0x7c, 0xcc, 0x98, 0xe9, 0xd2, 0x99, 0x8c, 0x8, 0x0, 0x7, 0x95, 0xda, 0x56, + 0x2b, 0x4f, 0x58, 0x5b, 0x13, 0x22, 0xaf, 0x23, 0x31, 0x8a, 0x23, 0x6, 0x67, 0x15, 0x0, 0x16, 0xdb, + 0xd6, 0xe7, 0xec, 0x75, 0xd9, 0x8c, 0xd7, 0x4e, 0x73, 0x50, 0xb8, 0xbf, 0x5c, 0xe5, 0x15, 0xec, 0x90, + 0x18, 0x34, 0xe1, 0xef, 0x24, 0xfc, 0x2, 0x0, 0x0, 0x5e, 0x57, 0x13, 0x34, 0x5d, 0x1, 0x77, 0x24, + 0x25, 0x16, 0x0, 0x18, 0x53, 0x6f, 0xad, 0x3e, 0x54, 0x22, 0xdd, 0x4a, 0x1e, 0xe6, 0xb9, 0x80, 0xfc, + 0xac, 0x24, 0x6, 0x11, 0xb1, 0x9d, 0x9f, 0x6e, 0x3e, 0xdb, 0x12, 0x2, 0x0, 0x0, 0x4b, 0x59, 0x1c, + 0x0, 0x12, 0x4a, 0x12, 0xcc, 0x52, 0xbf, 0x93, 0x92, 0xe7, 0xe3, 0xd4, 0xbd, 0x48, 0xee, 0x4b, 0x88, + 0xbb, 0xb, 0x2f, 0x22, 0x53, 0x95, 0x15, 0x0, 0xb, 0xb8, 0x63, 0xa8, 0x82, 0x5e, 0x99, 0xc9, 0xe1, + 0xf5, 0x6c, 0x47, 0x15, 0x0, 0x9, 0xe7, 0xce, 0x65, 0x87, 0x86, 0x53, 0xfa, 0x79, 0xe3, 0x23, 0x7, + 0xe2, 0x19, 0x5f, 0x27, 0x0, 0x0, 0x50, 0x77, 0x2a, 0xa7, 0x22, 0x28, 0x5a}; - uint8_t buf[65] = {0}; + uint8_t buf[210] = {0}; - uint8_t topic_bytes[] = {0xaf, 0xc3, 0xd0, 0x62, 0x5b, 0x71, 0xe2, 0x80, 0x14, 0x27}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xee, 0x16, 0x1d, 0x71, 0x34, 0x94, 0x9a, 0x26}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x1f}; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; - - uint8_t bytes0[] = {0x69, 0xbf, 0xaa, 0x13, 0xfe, 0xdc, 0x7f, 0xac, 0xeb, 0x49, 0xee, - 0xb9, 0xdc, 0x7e, 0x3f, 0xd9, 0x1f, 0x24, 0xfb, 0x60, 0x52, 0x15}; + msg.payload_len = 0; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11631}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20049}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytes0}}}, + uint8_t bytesprops0[] = {0x70, 0x9, 0x9e, 0xd, 0x86}; + uint8_t bytesprops2[] = {0xa, 0x7c, 0xcc, 0x98, 0xe9, 0xd2, 0x99, 0x8c}; + uint8_t bytesprops1[] = {0xc4}; + uint8_t bytesprops3[] = {0x95, 0xda, 0x56, 0x2b, 0x4f, 0x58, 0x5b}; + uint8_t bytesprops4[] = {0xdb, 0xd6, 0xe7, 0xec, 0x75, 0xd9, 0x8c, 0xd7, 0x4e, 0x73, 0x50, + 0xb8, 0xbf, 0x5c, 0xe5, 0x15, 0xec, 0x90, 0x18, 0x34, 0xe1, 0xef}; + uint8_t bytesprops5[] = {0x53, 0x6f, 0xad, 0x3e, 0x54, 0x22, 0xdd, 0x4a, 0x1e, 0xe6, 0xb9, 0x80, + 0xfc, 0xac, 0x24, 0x6, 0x11, 0xb1, 0x9d, 0x9f, 0x6e, 0x3e, 0xdb, 0x12}; + uint8_t bytesprops6[] = {0x4a, 0x12, 0xcc, 0x52, 0xbf, 0x93, 0x92, 0xe7, 0xe3, + 0xd4, 0xbd, 0x48, 0xee, 0x4b, 0x88, 0xbb, 0xb, 0x2f}; + uint8_t bytesprops7[] = {0xb8, 0x63, 0xa8, 0x82, 0x5e, 0x99, 0xc9, 0xe1, 0xf5, 0x6c, 0x47}; + uint8_t bytesprops8[] = {0xe7, 0xce, 0x65, 0x87, 0x86, 0x53, 0xfa, 0x79, 0xe3}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8879}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12682}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1639}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24151}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13405}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19289}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21397}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2018}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20599}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10330}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 14979, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 4746, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\141\253\128M\210\215vFY\193c\236\174\r\155\SYN\\y", _pubPktID = 16476, _pubBody = "\DEL\250\&0\179-", _pubProps = -// [PropAssignedClientIdentifier -// "\216\241+/\207\161\145\DC1\206E/\SO\214\200\165s\SO\188{$/4W-s",PropSubscriptionIdentifierAvailable -// 190,PropTopicAlias 6411,PropRequestResponseInformation 34,PropRequestResponseInformation -// 121,PropMessageExpiryInterval 20715,PropMessageExpiryInterval 12396,PropMaximumQoS -// 106,PropWildcardSubscriptionAvailable 0,PropMessageExpiryInterval 9349,PropMaximumPacketSize -// 8829,PropPayloadFormatIndicator 161,PropMessageExpiryInterval 11310,PropAuthenticationMethod -// "\221\182\153\SYN\195",PropMessageExpiryInterval 3614,PropResponseTopic -// "\248\f\189\DC2_",PropRequestProblemInformation 3,PropWillDelayInterval 19200,PropRetainAvailable -// 72,PropAuthenticationData "I\219D\NUL\130)\131\178",PropTopicAlias 20261,PropReasonString -// "i\130\206\161",PropSharedSubscriptionAvailable 91]} -TEST(Publish50QCTest, Encode91) { - uint8_t pkt[] = {0x3b, 0x95, 0x1, 0x0, 0x12, 0x8d, 0xfd, 0x80, 0x4d, 0xd2, 0xd7, 0x76, 0x46, 0x59, 0xc1, 0x63, 0xec, - 0xae, 0xd, 0x9b, 0x16, 0x5c, 0x79, 0x40, 0x5c, 0x79, 0x12, 0x0, 0x19, 0xd8, 0xf1, 0x2b, 0x2f, 0xcf, - 0xa1, 0x91, 0x11, 0xce, 0x45, 0x2f, 0xe, 0xd6, 0xc8, 0xa5, 0x73, 0xe, 0xbc, 0x7b, 0x24, 0x2f, 0x34, - 0x57, 0x2d, 0x73, 0x29, 0xbe, 0x23, 0x19, 0xb, 0x19, 0x22, 0x19, 0x79, 0x2, 0x0, 0x0, 0x50, 0xeb, - 0x2, 0x0, 0x0, 0x30, 0x6c, 0x24, 0x6a, 0x28, 0x0, 0x2, 0x0, 0x0, 0x24, 0x85, 0x27, 0x0, 0x0, - 0x22, 0x7d, 0x1, 0xa1, 0x2, 0x0, 0x0, 0x2c, 0x2e, 0x15, 0x0, 0x5, 0xdd, 0xb6, 0x99, 0x16, 0xc3, - 0x2, 0x0, 0x0, 0xe, 0x1e, 0x8, 0x0, 0x5, 0xf8, 0xc, 0xbd, 0x12, 0x5f, 0x17, 0x3, 0x18, 0x0, - 0x0, 0x4b, 0x0, 0x25, 0x48, 0x16, 0x0, 0x8, 0x49, 0xdb, 0x44, 0x0, 0x82, 0x29, 0x83, 0xb2, 0x23, - 0x4f, 0x25, 0x1f, 0x0, 0x4, 0x69, 0x82, 0xce, 0xa1, 0x2a, 0x5b, 0x7f, 0xfa, 0x30, 0xb3, 0x2d}; - - uint8_t buf[162] = {0}; - - uint8_t topic_bytes[] = {0x8d, 0xfd, 0x80, 0x4d, 0xd2, 0xd7, 0x76, 0x46, 0x59, - 0xc1, 0x63, 0xec, 0xae, 0xd, 0x9b, 0x16, 0x5c, 0x79}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(\217\244\EOT\224\136\232\225\248Q\237\240\138\187\152\v<\194\216B\158\SYN\158\203t\205", _pubPktID = 13686, +// _pubBody = "g\t?\199\SOHX\128\158_", _pubProps = [PropSharedSubscriptionAvailable 137,PropUserProperty +// "p\DC4\158\167\&1u\200\FS\145q\ETB\179\217m\178K\STXP\169\216N" "\182\253",PropServerKeepAlive +// 32094,PropSubscriptionIdentifierAvailable 163,PropServerKeepAlive 30000,PropSessionExpiryInterval +// 25741,PropWildcardSubscriptionAvailable 223,PropTopicAliasMaximum 22073,PropServerKeepAlive +// 20239,PropSharedSubscriptionAvailable 136,PropMaximumPacketSize 30256,PropWillDelayInterval +// 10219,PropSubscriptionIdentifier 2,PropAuthenticationMethod +// "\242\201Pp6=\b?L\232\206\a\DC47\168&\130\167\SUB\234\237\143"]} +TEST(Publish5QCTest, Encode90) { + uint8_t pkt[] = {0x32, 0x82, 0x1, 0x0, 0x1a, 0x28, 0xd9, 0xf4, 0x4, 0xe0, 0x88, 0xe8, 0xe1, 0xf8, 0x51, 0xed, 0xf0, + 0x8a, 0xbb, 0x98, 0xb, 0x3c, 0xc2, 0xd8, 0x42, 0x9e, 0x16, 0x9e, 0xcb, 0x74, 0xcd, 0x35, 0x76, 0x5a, + 0x2a, 0x89, 0x26, 0x0, 0x15, 0x70, 0x14, 0x9e, 0xa7, 0x31, 0x75, 0xc8, 0x1c, 0x91, 0x71, 0x17, 0xb3, + 0xd9, 0x6d, 0xb2, 0x4b, 0x2, 0x50, 0xa9, 0xd8, 0x4e, 0x0, 0x2, 0xb6, 0xfd, 0x13, 0x7d, 0x5e, 0x29, + 0xa3, 0x13, 0x75, 0x30, 0x11, 0x0, 0x0, 0x64, 0x8d, 0x28, 0xdf, 0x22, 0x56, 0x39, 0x13, 0x4f, 0xf, + 0x2a, 0x88, 0x27, 0x0, 0x0, 0x76, 0x30, 0x18, 0x0, 0x0, 0x27, 0xeb, 0xb, 0x2, 0x15, 0x0, 0x16, + 0xf2, 0xc9, 0x50, 0x70, 0x36, 0x3d, 0x8, 0x3f, 0x4c, 0xe8, 0xce, 0x7, 0x14, 0x37, 0xa8, 0x26, 0x82, + 0xa7, 0x1a, 0xea, 0xed, 0x8f, 0x67, 0x9, 0x3f, 0xc7, 0x1, 0x58, 0x80, 0x9e, 0x5f}; + + uint8_t buf[143] = {0}; + + uint8_t topic_bytes[] = {0x28, 0xd9, 0xf4, 0x4, 0xe0, 0x88, 0xe8, 0xe1, 0xf8, 0x51, 0xed, 0xf0, 0x8a, + 0xbb, 0x98, 0xb, 0x3c, 0xc2, 0xd8, 0x42, 0x9e, 0x16, 0x9e, 0xcb, 0x74, 0xcd}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x7f, 0xfa, 0x30, 0xb3, 0x2d}; + msg.retained = false; + uint8_t msg_bytes[] = {0x67, 0x9, 0x3f, 0xc7, 0x1, 0x58, 0x80, 0x9e, 0x5f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + msg.payload_len = 9; - uint8_t bytes0[] = {0xd8, 0xf1, 0x2b, 0x2f, 0xcf, 0xa1, 0x91, 0x11, 0xce, 0x45, 0x2f, 0xe, 0xd6, - 0xc8, 0xa5, 0x73, 0xe, 0xbc, 0x7b, 0x24, 0x2f, 0x34, 0x57, 0x2d, 0x73}; - uint8_t bytes1[] = {0xdd, 0xb6, 0x99, 0x16, 0xc3}; - uint8_t bytes2[] = {0xf8, 0xc, 0xbd, 0x12, 0x5f}; - uint8_t bytes3[] = {0x49, 0xdb, 0x44, 0x0, 0x82, 0x29, 0x83, 0xb2}; - uint8_t bytes4[] = {0x69, 0x82, 0xce, 0xa1}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6411}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20715}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12396}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9349}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8829}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11310}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3614}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19200}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20261}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 91}}, + uint8_t bytesprops1[] = {0xb6, 0xfd}; + uint8_t bytesprops0[] = {0x70, 0x14, 0x9e, 0xa7, 0x31, 0x75, 0xc8, 0x1c, 0x91, 0x71, 0x17, + 0xb3, 0xd9, 0x6d, 0xb2, 0x4b, 0x2, 0x50, 0xa9, 0xd8, 0x4e}; + uint8_t bytesprops2[] = {0xf2, 0xc9, 0x50, 0x70, 0x36, 0x3d, 0x8, 0x3f, 0x4c, 0xe8, 0xce, + 0x7, 0x14, 0x37, 0xa8, 0x26, 0x82, 0xa7, 0x1a, 0xea, 0xed, 0x8f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops0}, .v = {2, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32094}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30000}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25741}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22073}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20239}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30256}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10219}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16476, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 13686, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\172\236 -// #(l]\NAK\197K\GS\156j\151\195\144\235C\\\137\199*\177", _pubPktID = 24115, _pubBody = "\138", _pubProps = -// [PropAssignedClientIdentifier "\129a+n\170\188!\135\USlf\EM\248\247\227\155\206{&6",PropUserProperty "\214s\138\221" -// "\203\RSqhCk}E\DC1=C\227VW\189Payz\157",PropRetainAvailable 88,PropAssignedClientIdentifier -// "\243\206\165Q\DC2\210\220\244\f\237\128\185D\173\ETB\170U\DC3A>\230\237x\128N.\SYN:\251\202",PropAssignedClientIdentifier +// "\153\EOT\231\185\244",PropContentType +// "\251\DC3T\201\219(ozL\219g\201\166S\205\144=\f\n\194A\USQ(\219\161\162E\244\228",PropAuthenticationMethod +// "",PropTopicAlias 20730,PropAssignedClientIdentifier "R\242\197\138Z\246x\140\161\203",PropServerKeepAlive +// 7460,PropUserProperty "-m\162\172\254F\156\234&v\142\166\RS_\141\217\201\164C\152\DC3\212\224\154" +// "2\153M\249\129",PropSessionExpiryInterval 20348,PropCorrelationData +// "\184z\132\132\173\239\168\SO\194\153wk\211P\179;\246OS\ETB",PropAuthenticationData "",PropContentType +// "\213\&2\RS",PropSessionExpiryInterval 31013,PropReceiveMaximum 10571,PropResponseInformation +// "\168\239\b\253\212\129]\158\154\SI\143\ESC\242\245\163\211\205\185\203\175s\142\181rX\225\240",PropReceiveMaximum +// 11056,PropMaximumPacketSize 22864,PropReasonString +// "\209m\142\246+L\157\ETB\151\201b.\ETX\239\163\140\bhD\202\NAK\255\139j\214\199"]} +TEST(Publish5QCTest, Encode92) { + uint8_t pkt[] = { + 0x35, 0x94, 0x2, 0x0, 0x11, 0xe8, 0xaf, 0x4, 0x91, 0x7f, 0xfe, 0xa6, 0xe6, 0xd4, 0x4d, 0x4d, 0x83, 0x36, 0x52, + 0xb1, 0x41, 0xd9, 0x66, 0xd, 0xfb, 0x1, 0x2a, 0x2e, 0x24, 0x85, 0x29, 0xd4, 0x1c, 0x0, 0x1, 0x82, 0x1f, 0x0, + 0x1d, 0x37, 0x85, 0x41, 0x3e, 0xd2, 0xdc, 0xf4, 0xc, 0xed, 0x80, 0xb9, 0x44, 0xad, 0x17, 0xaa, 0x55, 0x13, 0x41, + 0x3e, 0xe6, 0xed, 0x78, 0x80, 0x4e, 0x2e, 0x16, 0x3a, 0xfb, 0xca, 0x12, 0x0, 0x5, 0x99, 0x4, 0xe7, 0xb9, 0xf4, + 0x3, 0x0, 0x1e, 0xfb, 0x13, 0x54, 0xc9, 0xdb, 0x28, 0x6f, 0x7a, 0x4c, 0xdb, 0x67, 0xc9, 0xa6, 0x53, 0xcd, 0x90, + 0x3d, 0xc, 0xa, 0xc2, 0x41, 0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] = {0xe8, 0xaf, 0x4, 0x91, 0x7f, 0xfe, 0xa6, 0xe6, 0xd4, + 0x4d, 0x4d, 0x83, 0x36, 0x52, 0xb1, 0x41, 0xd9}; lwmqtt_string_t topic = {17, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x83, 0x8c, 0x8f, 0xac, 0x6f, 0x44, 0x36, 0xf, 0x53, 0xc4, 0x4f, 0x2e, - 0x91, 0x8d, 0xa6, 0x4, 0xbc, 0x99, 0xfb, 0x55, 0x16, 0x4a, 0x54}; + uint8_t msg_bytes[] = {0xe5, 0x31}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; - - uint8_t bytes1[] = {0x8, 0xff, 0xbb, 0x15, 0x37, 0x7d, 0x53, 0x2, 0xc2, 0x62, 0xbe, 0xbb, 0xdf, 0xc9, - 0x5, 0xa4, 0xd7, 0x46, 0x85, 0xb1, 0x88, 0x11, 0x14, 0x2c, 0x1e, 0xd5, 0x3c}; - uint8_t bytes0[] = {0x84, 0xe8, 0x7f, 0xa1, 0xd2, 0x2f, 0xbb, 0x56, 0x32, 0xec, 0xd6, - 0xf6, 0xdf, 0xe5, 0x31, 0xc3, 0xd4, 0xc1, 0xd, 0x85, 0xc7, 0x5f}; - uint8_t bytes2[] = {0xbe, 0x82, 0xfd, 0x69, 0x4d, 0x9b, 0xa9, 0xd0, 0xdd, 0x6f, 0xc4, 0x1, 0x2d, 0xb3}; + msg.payload_len = 2; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytes0}, .v = {27, (char*)&bytes1}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 671}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytes2}}}, + uint8_t bytesprops0[] = {0x82}; + uint8_t bytesprops1[] = {0x37, 0x85, 0x41, 0x3e, 0xd2, 0xdc, 0xf4, 0xc, 0xed, 0x80, 0xb9, 0x44, 0xad, 0x17, 0xaa, + 0x55, 0x13, 0x41, 0x3e, 0xe6, 0xed, 0x78, 0x80, 0x4e, 0x2e, 0x16, 0x3a, 0xfb, 0xca}; + uint8_t bytesprops2[] = {0x99, 0x4, 0xe7, 0xb9, 0xf4}; + uint8_t bytesprops3[] = {0xfb, 0x13, 0x54, 0xc9, 0xdb, 0x28, 0x6f, 0x7a, 0x4c, 0xdb, 0x67, 0xc9, 0xa6, 0x53, 0xcd, + 0x90, 0x3d, 0xc, 0xa, 0xc2, 0x41, 0x1f, 0x51, 0x28, 0xdb, 0xa1, 0xa2, 0x45, 0xf4, 0xe4}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0x52, 0xf2, 0xc5, 0x8a, 0x5a, 0xf6, 0x78, 0x8c, 0xa1, 0xcb}; + uint8_t bytesprops7[] = {0x32, 0x99, 0x4d, 0xf9, 0x81}; + uint8_t bytesprops6[] = {0x2d, 0x6d, 0xa2, 0xac, 0xfe, 0x46, 0x9c, 0xea, 0x26, 0x76, 0x8e, 0xa6, + 0x1e, 0x5f, 0x8d, 0xd9, 0xc9, 0xa4, 0x43, 0x98, 0x13, 0xd4, 0xe0, 0x9a}; + uint8_t bytesprops8[] = {0xb8, 0x7a, 0x84, 0x84, 0xad, 0xef, 0xa8, 0xe, 0xc2, 0x99, + 0x77, 0x6b, 0xd3, 0x50, 0xb3, 0x3b, 0xf6, 0x4f, 0x53, 0x17}; + uint8_t bytesprops9[] = {0}; + uint8_t bytesprops10[] = {0xd5, 0x32, 0x1e}; + uint8_t bytesprops11[] = {0xa8, 0xef, 0x8, 0xfd, 0xd4, 0x81, 0x5d, 0x9e, 0x9a, 0xf, 0x8f, 0x1b, 0xf2, 0xf5, + 0xa3, 0xd3, 0xcd, 0xb9, 0xcb, 0xaf, 0x73, 0x8e, 0xb5, 0x72, 0x58, 0xe1, 0xf0}; + uint8_t bytesprops12[] = {0xd1, 0x6d, 0x8e, 0xf6, 0x2b, 0x4c, 0x9d, 0x17, 0x97, 0xc9, 0x62, 0x2e, 0x3, + 0xef, 0xa3, 0x8c, 0x8, 0x68, 0x44, 0xca, 0x15, 0xff, 0x8b, 0x6a, 0xd6, 0xc7}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20730}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7460}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops6}, .v = {5, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20348}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31013}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10571}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11056}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22864}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops12}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 159, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 26125, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\192K\248\134\174}\198-\171\235\SUB\214]\204\&3\177\f", _pubPktID = 0, _pubBody = -// "%\131\215\218\147\225\ENQ\173Wh\129\234\197", _pubProps = [PropTopicAliasMaximum 15959,PropCorrelationData -// "\183\229\218\174\208|K\NAK\b\235",PropSharedSubscriptionAvailable 248,PropSubscriptionIdentifierAvailable -// 251,PropSubscriptionIdentifier 24,PropAuthenticationMethod "b\205\196\b$7\213Q\242 -// \179\242]\154\177\163+_\n\153\177\152\132\182\237\141",PropMaximumQoS 85,PropSharedSubscriptionAvailable -// 59,PropServerKeepAlive 25781,PropAuthenticationMethod -// "\198\140+,\192\191g\215\198\&0\135f\234\RS\DEL\DC3X\253\"\254vq\235U\133\136co\146",PropReasonString -// "\204\FSb\221\176\140jj\196\EM\DC2",PropPayloadFormatIndicator 185,PropTopicAliasMaximum -// 30828,PropSubscriptionIdentifierAvailable 0,PropSessionExpiryInterval 22607,PropSharedSubscriptionAvailable -// 176,PropReasonString "\132\132\249\SI{\190\157\241\rZI\205\195.\130^",PropRetainAvailable 81,PropWillDelayInterval -// 8848]} -TEST(Publish50QCTest, Encode94) { - uint8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}; - - uint8_t topic_bytes[] = {0xc0, 0x4b, 0xf8, 0x86, 0xae, 0x7d, 0xc6, 0x2d, 0xab, - 0xeb, 0x1a, 0xd6, 0x5d, 0xcc, 0x33, 0xb1, 0xc}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\249\223\224\153M\215\191\241/z\197=\210\196\197T-", _pubPktID = 4023, _pubBody = "\146G", _pubProps = +// [PropRetainAvailable 91,PropMessageExpiryInterval 9270,PropReceiveMaximum 4788]} +TEST(Publish5QCTest, Encode93) { + uint8_t pkt[] = {0x32, 0x22, 0x0, 0x11, 0xf9, 0xdf, 0xe0, 0x99, 0x4d, 0xd7, 0xbf, 0xf1, + 0x2f, 0x7a, 0xc5, 0x3d, 0xd2, 0xc4, 0xc5, 0x54, 0x2d, 0xf, 0xb7, 0xa, + 0x25, 0x5b, 0x2, 0x0, 0x0, 0x24, 0x36, 0x21, 0x12, 0xb4, 0x92, 0x47}; + + uint8_t buf[46] = {0}; + + uint8_t topic_bytes[] = {0xf9, 0xdf, 0xe0, 0x99, 0x4d, 0xd7, 0xbf, 0xf1, 0x2f, + 0x7a, 0xc5, 0x3d, 0xd2, 0xc4, 0xc5, 0x54, 0x2d}; lwmqtt_string_t topic = {17, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x25, 0x83, 0xd7, 0xda, 0x93, 0xe1, 0x5, 0xad, 0x57, 0x68, 0x81, 0xea, 0xc5}; + uint8_t msg_bytes[] = {0x92, 0x47}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 2; - uint8_t bytes0[] = {0xb7, 0xe5, 0xda, 0xae, 0xd0, 0x7c, 0x4b, 0x15, 0x8, 0xeb}; - uint8_t bytes1[] = {0x62, 0xcd, 0xc4, 0x8, 0x24, 0x37, 0xd5, 0x51, 0xf2, 0x20, 0xb3, 0xf2, 0x5d, - 0x9a, 0xb1, 0xa3, 0x2b, 0x5f, 0xa, 0x99, 0xb1, 0x98, 0x84, 0xb6, 0xed, 0x8d}; - uint8_t bytes2[] = {0xc6, 0x8c, 0x2b, 0x2c, 0xc0, 0xbf, 0x67, 0xd7, 0xc6, 0x30, 0x87, 0x66, 0xea, 0x1e, 0x7f, - 0x13, 0x58, 0xfd, 0x22, 0xfe, 0x76, 0x71, 0xeb, 0x55, 0x85, 0x88, 0x63, 0x6f, 0x92}; - uint8_t bytes3[] = {0xcc, 0x1c, 0x62, 0xdd, 0xb0, 0x8c, 0x6a, 0x6a, 0xc4, 0x19, 0x12}; - uint8_t bytes4[] = {0x84, 0x84, 0xf9, 0xf, 0x7b, 0xbe, 0x9d, 0xf1, 0xd, 0x5a, 0x49, 0xcd, 0xc3, 0x2e, 0x82, 0x5e}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15959}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25781}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30828}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22607}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8848}}, - }; - - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&proplist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9270}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4788}}, + }; + + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 4023, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\161&K\GSu\164\DC1W\156\205\DC2e\US\253\SUB\212\GS\146u", _pubPktID = 4938, _pubBody = -// "\197\210\201\164\236`\GSJjyh\252c\GS\185\190\150xY\239>\220\165.", _pubProps = [PropUserProperty -// "\168=bnK\172\191t`\165\224\186\165" -// "\184r\211Q.9\174\239\243g\SYN\143\242\138\167\r\253LvD)\212\173:~\249\239w",PropSharedSubscriptionAvailable -// 159,PropMessageExpiryInterval 23375,PropPayloadFormatIndicator 235,PropResponseInformation "+\193=])\213+\RSj\226"]} -TEST(Publish50QCTest, Encode95) { - uint8_t pkt[] = {0x3a, 0x74, 0x0, 0x13, 0xa1, 0x26, 0x4b, 0x1d, 0x75, 0xa4, 0x11, 0x57, 0x9c, 0xcd, 0x12, 0x65, 0x1f, - 0xfd, 0x1a, 0xd4, 0x1d, 0x92, 0x75, 0x13, 0x4a, 0x44, 0x26, 0x0, 0xd, 0xa8, 0x3d, 0x62, 0x6e, 0x4b, - 0xac, 0xbf, 0x74, 0x60, 0xa5, 0xe0, 0xba, 0xa5, 0x0, 0x1c, 0xb8, 0x72, 0xd3, 0x51, 0x2e, 0x39, 0xae, - 0xef, 0xf3, 0x67, 0x16, 0x8f, 0xf2, 0x8a, 0xa7, 0xd, 0xfd, 0x4c, 0x76, 0x44, 0x29, 0xd4, 0xad, 0x3a, - 0x7e, 0xf9, 0xef, 0x77, 0x2a, 0x9f, 0x2, 0x0, 0x0, 0x5b, 0x4f, 0x1, 0xeb, 0x1a, 0x0, 0xa, 0x2b, - 0xc1, 0x3d, 0x5d, 0x29, 0xd5, 0x2b, 0x1e, 0x6a, 0xe2, 0xc5, 0xd2, 0xc9, 0xa4, 0xec, 0x60, 0x1d, 0x4a, - 0x6a, 0x79, 0x68, 0xfc, 0x63, 0x1d, 0xb9, 0xbe, 0x96, 0x78, 0x59, 0xef, 0x3e, 0xdc, 0xa5, 0x2e}; - - uint8_t buf[128] = {0}; - - uint8_t topic_bytes[] = {0xa1, 0x26, 0x4b, 0x1d, 0x75, 0xa4, 0x11, 0x57, 0x9c, 0xcd, - 0x12, 0x65, 0x1f, 0xfd, 0x1a, 0xd4, 0x1d, 0x92, 0x75}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "1\188?\134-\151\130\165\DC3\149\&0\188\151\r\192q\134Wi\255\238\204\193\225\205\231\164", _pubPktID = 3250, _pubBody +// = "\209\151\165\147\252]\131\r\145p\242\&6\155z\255", _pubProps = [PropMaximumQoS 34,PropSubscriptionIdentifier +// 27,PropContentType "\218\230\197\bgVnD#\155\136\193\208\141\230x\174\130>\196\179v\239r]",PropMessageExpiryInterval +// 32234,PropResponseTopic "bA\ACKy\246\186\239\153X6`\155\SYNi",PropAuthenticationMethod +// "\an|$3\239\231\240R",PropMaximumPacketSize 14841]} +TEST(Publish5QCTest, Encode94) { + uint8_t pkt[] = {0x35, 0x76, 0x0, 0x1b, 0x31, 0xbc, 0x3f, 0x86, 0x2d, 0x97, 0x82, 0xa5, 0x13, 0x95, 0x30, + 0xbc, 0x97, 0xd, 0xc0, 0x71, 0x86, 0x57, 0x69, 0xff, 0xee, 0xcc, 0xc1, 0xe1, 0xcd, 0xe7, + 0xa4, 0xc, 0xb2, 0x47, 0x24, 0x22, 0xb, 0x1b, 0x3, 0x0, 0x19, 0xda, 0xe6, 0xc5, 0x8, + 0x67, 0x56, 0x6e, 0x44, 0x23, 0x9b, 0x88, 0xc1, 0xd0, 0x8d, 0xe6, 0x78, 0xae, 0x82, 0x3e, + 0xc4, 0xb3, 0x76, 0xef, 0x72, 0x5d, 0x2, 0x0, 0x0, 0x7d, 0xea, 0x8, 0x0, 0xe, 0x62, + 0x41, 0x6, 0x79, 0xf6, 0xba, 0xef, 0x99, 0x58, 0x36, 0x60, 0x9b, 0x16, 0x69, 0x15, 0x0, + 0x9, 0x7, 0x6e, 0x7c, 0x24, 0x33, 0xef, 0xe7, 0xf0, 0x52, 0x27, 0x0, 0x0, 0x39, 0xf9, + 0xd1, 0x97, 0xa5, 0x93, 0xfc, 0x5d, 0x83, 0xd, 0x91, 0x70, 0xf2, 0x36, 0x9b, 0x7a, 0xff}; + + uint8_t buf[130] = {0}; + + uint8_t topic_bytes[] = {0x31, 0xbc, 0x3f, 0x86, 0x2d, 0x97, 0x82, 0xa5, 0x13, 0x95, 0x30, 0xbc, 0x97, 0xd, + 0xc0, 0x71, 0x86, 0x57, 0x69, 0xff, 0xee, 0xcc, 0xc1, 0xe1, 0xcd, 0xe7, 0xa4}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xc5, 0xd2, 0xc9, 0xa4, 0xec, 0x60, 0x1d, 0x4a, 0x6a, 0x79, 0x68, 0xfc, - 0x63, 0x1d, 0xb9, 0xbe, 0x96, 0x78, 0x59, 0xef, 0x3e, 0xdc, 0xa5, 0x2e}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xd1, 0x97, 0xa5, 0x93, 0xfc, 0x5d, 0x83, 0xd, 0x91, 0x70, 0xf2, 0x36, 0x9b, 0x7a, 0xff}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 15; - uint8_t bytes1[] = {0xb8, 0x72, 0xd3, 0x51, 0x2e, 0x39, 0xae, 0xef, 0xf3, 0x67, 0x16, 0x8f, 0xf2, 0x8a, - 0xa7, 0xd, 0xfd, 0x4c, 0x76, 0x44, 0x29, 0xd4, 0xad, 0x3a, 0x7e, 0xf9, 0xef, 0x77}; - uint8_t bytes0[] = {0xa8, 0x3d, 0x62, 0x6e, 0x4b, 0xac, 0xbf, 0x74, 0x60, 0xa5, 0xe0, 0xba, 0xa5}; - uint8_t bytes2[] = {0x2b, 0xc1, 0x3d, 0x5d, 0x29, 0xd5, 0x2b, 0x1e, 0x6a, 0xe2}; + uint8_t bytesprops0[] = {0xda, 0xe6, 0xc5, 0x8, 0x67, 0x56, 0x6e, 0x44, 0x23, 0x9b, 0x88, 0xc1, 0xd0, + 0x8d, 0xe6, 0x78, 0xae, 0x82, 0x3e, 0xc4, 0xb3, 0x76, 0xef, 0x72, 0x5d}; + uint8_t bytesprops1[] = {0x62, 0x41, 0x6, 0x79, 0xf6, 0xba, 0xef, 0x99, 0x58, 0x36, 0x60, 0x9b, 0x16, 0x69}; + uint8_t bytesprops2[] = {0x7, 0x6e, 0x7c, 0x24, 0x33, 0xef, 0xe7, 0xf0, 0x52}; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytes0}, .v = {28, (char*)&bytes1}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23375}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytes2}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32234}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14841}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 4938, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 3250, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\149\203\181S\"+\168\160\141\DEL~e8\150\193\SYN\t1", _pubPktID = 0, _pubBody = "m#Za\252\192\201Y\NAK\221", -// _pubProps = [PropAuthenticationMethod "\239\NAK Ne\152\241\151\247rn\164\185\146\&1u -// m\132\171O",PropWildcardSubscriptionAvailable 249,PropServerKeepAlive 18975]} -TEST(Publish50QCTest, Encode96) { - uint8_t pkt[] = {0x38, 0x3c, 0x0, 0x12, 0x95, 0xcb, 0xb5, 0x53, 0x22, 0x2b, 0xa8, 0xa0, 0x8d, 0x7f, 0x7e, 0x65, - 0x38, 0x96, 0xc1, 0x16, 0x9, 0x31, 0x1d, 0x15, 0x0, 0x15, 0xef, 0x15, 0x20, 0x4e, 0x65, 0x98, - 0xf1, 0x97, 0xf7, 0x72, 0x6e, 0xa4, 0xb9, 0x92, 0x31, 0x75, 0x20, 0x6d, 0x84, 0xab, 0x4f, 0x28, - 0xf9, 0x13, 0x4a, 0x1f, 0x6d, 0x23, 0x5a, 0x61, 0xfc, 0xc0, 0xc9, 0x59, 0x15, 0xdd}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\149y\148\SOH\133\136\STX\n\242", +// _pubPktID = 27162, _pubBody = +// "\163\212\196\ENQ\196\186w\152\RS\219\243>k~\167\130o^\157\\\197C\128\130\185\247\201\148C\197", _pubProps = +// [PropTopicAlias 16230,PropWillDelayInterval 28392,PropAuthenticationData +// "\194\t7\142\236\197<\157\209\220\232\r\142\ETB[\239\183\144\179\SYN\140\f\246\255\&8",PropWildcardSubscriptionAvailable +// 163,PropSharedSubscriptionAvailable 254,PropResponseInformation +// "\200\228\&8e;V\178p^\188I\\<={t\234n\154,\230\253\CAN#/\197\236\174\246",PropSessionExpiryInterval +// 4151,PropMaximumQoS 240]} +TEST(Publish5QCTest, Encode95) { + uint8_t pkt[] = {0x3b, 0x7b, 0x0, 0x9, 0x95, 0x79, 0x94, 0x1, 0x85, 0x88, 0x2, 0xa, 0xf2, 0x6a, 0x1a, 0x4f, + 0x23, 0x3f, 0x66, 0x18, 0x0, 0x0, 0x6e, 0xe8, 0x16, 0x0, 0x19, 0xc2, 0x9, 0x37, 0x8e, 0xec, + 0xc5, 0x3c, 0x9d, 0xd1, 0xdc, 0xe8, 0xd, 0x8e, 0x17, 0x5b, 0xef, 0xb7, 0x90, 0xb3, 0x16, 0x8c, + 0xc, 0xf6, 0xff, 0x38, 0x28, 0xa3, 0x2a, 0xfe, 0x1a, 0x0, 0x1d, 0xc8, 0xe4, 0x38, 0x65, 0x3b, + 0x56, 0xb2, 0x70, 0x5e, 0xbc, 0x49, 0x5c, 0x3c, 0x3d, 0x7b, 0x74, 0xea, 0x6e, 0x9a, 0x2c, 0xe6, + 0xfd, 0x18, 0x23, 0x2f, 0xc5, 0xec, 0xae, 0xf6, 0x11, 0x0, 0x0, 0x10, 0x37, 0x24, 0xf0, 0xa3, + 0xd4, 0xc4, 0x5, 0xc4, 0xba, 0x77, 0x98, 0x1e, 0xdb, 0xf3, 0x3e, 0x6b, 0x7e, 0xa7, 0x82, 0x6f, + 0x5e, 0x9d, 0x5c, 0xc5, 0x43, 0x80, 0x82, 0xb9, 0xf7, 0xc9, 0x94, 0x43, 0xc5}; - uint8_t buf[72] = {0}; + uint8_t buf[135] = {0}; - uint8_t topic_bytes[] = {0x95, 0xcb, 0xb5, 0x53, 0x22, 0x2b, 0xa8, 0xa0, 0x8d, - 0x7f, 0x7e, 0x65, 0x38, 0x96, 0xc1, 0x16, 0x9, 0x31}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x95, 0x79, 0x94, 0x1, 0x85, 0x88, 0x2, 0xa, 0xf2}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x6d, 0x23, 0x5a, 0x61, 0xfc, 0xc0, 0xc9, 0x59, 0x15, 0xdd}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xa3, 0xd4, 0xc4, 0x5, 0xc4, 0xba, 0x77, 0x98, 0x1e, 0xdb, 0xf3, 0x3e, 0x6b, 0x7e, 0xa7, + 0x82, 0x6f, 0x5e, 0x9d, 0x5c, 0xc5, 0x43, 0x80, 0x82, 0xb9, 0xf7, 0xc9, 0x94, 0x43, 0xc5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; - - uint8_t bytes0[] = {0xef, 0x15, 0x20, 0x4e, 0x65, 0x98, 0xf1, 0x97, 0xf7, 0x72, 0x6e, - 0xa4, 0xb9, 0x92, 0x31, 0x75, 0x20, 0x6d, 0x84, 0xab, 0x4f}; + msg.payload_len = 30; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18975}}, + uint8_t bytesprops0[] = {0xc2, 0x9, 0x37, 0x8e, 0xec, 0xc5, 0x3c, 0x9d, 0xd1, 0xdc, 0xe8, 0xd, 0x8e, + 0x17, 0x5b, 0xef, 0xb7, 0x90, 0xb3, 0x16, 0x8c, 0xc, 0xf6, 0xff, 0x38}; + uint8_t bytesprops1[] = {0xc8, 0xe4, 0x38, 0x65, 0x3b, 0x56, 0xb2, 0x70, 0x5e, 0xbc, 0x49, 0x5c, 0x3c, 0x3d, 0x7b, + 0x74, 0xea, 0x6e, 0x9a, 0x2c, 0xe6, 0xfd, 0x18, 0x23, 0x2f, 0xc5, 0xec, 0xae, 0xf6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16230}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28392}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4151}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 240}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 27162, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\254\DLE\200m\251\190\157\139\&9=\175\219\238~:ap/{\148", _pubPktID = 0, _pubBody = "\163~rt", _pubProps = -// [PropReasonString "\vi\205g&\ENQ\169\&0X\187\&6\214~\131\185\EOT\DLE\140G\203.A\NUL\160\165\FS -// ZkV",PropCorrelationData "\STX",PropSessionExpiryInterval 9141,PropTopicAlias 2629,PropAssignedClientIdentifier -// "\172M)%\189\217zZ\194dR+\177\\Pl\212\201vL\DELs\242\182q",PropMaximumPacketSize 13928,PropMessageExpiryInterval -// 7205,PropRetainAvailable 115,PropReasonString -// "\CAN\180\ETXG~\197N\246%\202\178H\244\r\STXA\241re\225`%s\214l",PropWillDelayInterval -// 319,PropAssignedClientIdentifier "G\221\200e\243\191\v=\221C\177\b\241\227\139\157\213\&4H\187PH\235\222\DLE\ACK -// ",PropServerKeepAlive 3982,PropAuthenticationData -// "\246:\252\141\t\DC2\129p\254{\248\188\255\ESC)}\152\143\245",PropMaximumQoS 212,PropMaximumPacketSize -// 7512,PropCorrelationData "1\238\145\190\242\&3\174\\E\FS\144",PropReasonString -// "p\163{\STXc\219\223O\252\GS\242@|ujA\EOT\179\&7.",PropMessageExpiryInterval 27783,PropMessageExpiryInterval -// 17888,PropUserProperty "\204j\240k\180\&3\197\178\191\&3\137\193\216 \134~,\137k.Rt\129\205p4\249\244\226\241" -// "J\250\201\156*pD\156\248Q\212\212\165\245bf6\140\179\RS\ETB\202\136\238\249\&4^c#",PropTopicAlias -// 8403,PropReceiveMaximum 32198,PropSharedSubscriptionAvailable 103,PropUserProperty "\t'qd1#\255\248\160." -// "\215g\DC2\254\160F\247d\153\130\EM\EOT\\\163\236\189\148\US\154$\150\211\bQ\202\DC1",PropMessageExpiryInterval -// 1577,PropResponseInformation -// "\SUB\252\168\174\204\218\&2\233X\DC3\223,\195\ENQ9\n\DC1\152\239\RS\EM3\250\&6\by[\225\235\152",PropUserProperty -// "r\163\213\CAN\b3\197\201\CAN\DC1\194\211\211\201" "\225~",PropPayloadFormatIndicator 240,PropPayloadFormatIndicator -// 61]} -TEST(Publish50QCTest, Encode97) { - uint8_t pkt[] = { - 0x38, 0xaf, 0x3, 0x0, 0x14, 0xfe, 0x10, 0xc8, 0x6d, 0xfb, 0xbe, 0x9d, 0x8b, 0x39, 0x3d, 0xaf, 0xdb, 0xee, 0x7e, - 0x3a, 0x61, 0x70, 0x2f, 0x7b, 0x94, 0x93, 0x3, 0x1f, 0x0, 0x1e, 0xb, 0x69, 0xcd, 0x67, 0x26, 0x5, 0xa9, 0x30, - 0x58, 0xbb, 0x36, 0xd6, 0x7e, 0x83, 0xb9, 0x4, 0x10, 0x8c, 0x47, 0xcb, 0x2e, 0x41, 0x0, 0xa0, 0xa5, 0x1c, 0x20, - 0x5a, 0x6b, 0x56, 0x9, 0x0, 0x1, 0x2, 0x11, 0x0, 0x0, 0x23, 0xb5, 0x23, 0xa, 0x45, 0x12, 0x0, 0x19, 0xac, - 0x4d, 0x29, 0x25, 0xbd, 0xd9, 0x7a, 0x5a, 0xc2, 0x64, 0x52, 0x2b, 0xb1, 0x5c, 0x50, 0x6c, 0xd4, 0xc9, 0x76, 0x4c, - 0x7f, 0x73, 0xf2, 0xb6, 0x71, 0x27, 0x0, 0x0, 0x36, 0x68, 0x2, 0x0, 0x0, 0x1c, 0x25, 0x25, 0x73, 0x1f, 0x0, - 0x19, 0x18, 0xb4, 0x3, 0x47, 0x7e, 0xc5, 0x4e, 0xf6, 0x25, 0xca, 0xb2, 0x48, 0xf4, 0xd, 0x2, 0x41, 0xf1, 0x72, - 0x65, 0xe1, 0x60, 0x25, 0x73, 0xd6, 0x6c, 0x18, 0x0, 0x0, 0x1, 0x3f, 0x12, 0x0, 0x1b, 0x47, 0x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23, 0xff, 0xf8, 0xa0, 0x2e, 0x0, 0x1a, 0xd7, - 0x67, 0x12, 0xfe, 0xa0, 0x46, 0xf7, 0x64, 0x99, 0x82, 0x19, 0x4, 0x5c, 0xa3, 0xec, 0xbd, 0x94, 0x1f, 0x9a, 0x24, - 0x96, 0xd3, 0x8, 0x51, 0xca, 0x11, 0x2, 0x0, 0x0, 0x6, 0x29, 0x1a, 0x0, 0x1e, 0x1a, 0xfc, 0xa8, 0xae, 0xcc, - 0xda, 0x32, 0xe9, 0x58, 0x13, 0xdf, 0x2c, 0xc3, 0x5, 0x39, 0xa, 0x11, 0x98, 0xef, 0x1e, 0x19, 0x33, 0xfa, 0x36, - 0x8, 0x79, 0x5b, 0xe1, 0xeb, 0x98, 0x26, 0x0, 0xe, 0x72, 0xa3, 0xd5, 0x18, 0x8, 0x33, 0xc5, 0xc9, 0x18, 0x11, - 0xc2, 0xd3, 0xd3, 0xc9, 0x0, 0x2, 0xe1, 0x7e, 0x1, 0xf0, 0x1, 0x3d, 0xa3, 0x7e, 0x72, 0x74}; - - uint8_t buf[444] = {0}; - - uint8_t topic_bytes[] = {0xfe, 0x10, 0xc8, 0x6d, 0xfb, 0xbe, 0x9d, 0x8b, 0x39, 0x3d, - 0xaf, 0xdb, 0xee, 0x7e, 0x3a, 0x61, 0x70, 0x2f, 0x7b, 0x94}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\133\236\215", _pubPktID = 29262, +// _pubBody = "\150|7\US\164%\USi\129\ACK\161\142\139\207", _pubProps = [PropContentType +// "\220\b<+\DC3\245\ENQ\200\DEL0s\138b\223\245\&6\GS\190\149\182\DC3m\180\142<\181",PropMaximumQoS +// 238,PropWillDelayInterval 4046,PropAssignedClientIdentifier "\150\174\238\247^",PropMessageExpiryInterval +// 19374,PropServerKeepAlive 30717,PropMaximumPacketSize 22891,PropSharedSubscriptionAvailable +// 29,PropPayloadFormatIndicator 133,PropServerKeepAlive 16285,PropRequestResponseInformation 123,PropReasonString +// "",PropRequestProblemInformation 107,PropSharedSubscriptionAvailable 60,PropSharedSubscriptionAvailable +// 98,PropTopicAlias 27866,PropServerReference "\235-\158\236\241\n"]} +TEST(Publish5QCTest, Encode96) { + uint8_t pkt[] = {0x35, 0xa1, 0x1, 0x0, 0x3, 0x85, 0xec, 0xd7, 0x72, 0x4e, 0x8a, 0x1, 0x3, 0x0, 0x1a, 0xdc, 0x8, + 0x3c, 0x2b, 0x13, 0xf5, 0x5, 0xc8, 0x7f, 0x30, 0x73, 0x8a, 0x62, 0xdf, 0xf5, 0x36, 0x1d, 0xbe, 0x95, + 0xb6, 0x13, 0x6d, 0xb4, 0x8e, 0x3c, 0xb5, 0x24, 0xee, 0x18, 0x0, 0x0, 0xf, 0xce, 0x12, 0x0, 0x5, + 0x96, 0xae, 0xee, 0xf7, 0x5e, 0x2, 0x0, 0x0, 0x4b, 0xae, 0x13, 0x77, 0xfd, 0x27, 0x0, 0x0, 0x59, + 0x6b, 0x2a, 0x1d, 0x1, 0x85, 0x13, 0x3f, 0x9d, 0x19, 0x7b, 0x1f, 0x0, 0x0, 0x17, 0x6b, 0x2a, 0x3c, + 0x2a, 0x62, 0x23, 0x6c, 0xda, 0x1c, 0x0, 0x6, 0xeb, 0x2d, 0x9e, 0xec, 0x3c, 0x5a, 0x29, 0x90, 0x26, + 0x0, 0x18, 0x6b, 0xb4, 0xec, 0x46, 0x4e, 0xf5, 0x48, 0xf0, 0xd8, 0xed, 0xfe, 0x58, 0x32, 0x59, 0x74, + 0x5c, 0x56, 0x6d, 0xcd, 0x1c, 0x76, 0x54, 0xb2, 0x7b, 0x0, 0x5, 0xf0, 0x72, 0xe3, 0x44, 0xa3, 0x1, + 0xfb, 0x28, 0x59, 0x12, 0x0, 0x8, 0x65, 0xfb, 0xc, 0xc8, 0xed, 0x3e, 0xf1, 0xa, 0x96, 0x7c, 0x37, + 0x1f, 0xa4, 0x25, 0x1f, 0x69, 0x81, 0x6, 0xa1, 0x8e, 0x8b, 0xcf}; + + uint8_t buf[174] = {0}; + + uint8_t topic_bytes[] = {0x85, 0xec, 0xd7}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xa3, 0x7e, 0x72, 0x74}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x96, 0x7c, 0x37, 0x1f, 0xa4, 0x25, 0x1f, 0x69, 0x81, 0x6, 0xa1, 0x8e, 0x8b, 0xcf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 14; - uint8_t bytes0[] = {0xb, 0x69, 0xcd, 0x67, 0x26, 0x5, 0xa9, 0x30, 0x58, 0xbb, 0x36, 0xd6, 0x7e, 0x83, 0xb9, - 0x4, 0x10, 0x8c, 0x47, 0xcb, 0x2e, 0x41, 0x0, 0xa0, 0xa5, 0x1c, 0x20, 0x5a, 0x6b, 0x56}; - uint8_t bytes1[] = {0x2}; - uint8_t bytes2[] = {0xac, 0x4d, 0x29, 0x25, 0xbd, 0xd9, 0x7a, 0x5a, 0xc2, 0x64, 0x52, 0x2b, 0xb1, - 0x5c, 0x50, 0x6c, 0xd4, 0xc9, 0x76, 0x4c, 0x7f, 0x73, 0xf2, 0xb6, 0x71}; - uint8_t bytes3[] = {0x18, 0xb4, 0x3, 0x47, 0x7e, 0xc5, 0x4e, 0xf6, 0x25, 0xca, 0xb2, 0x48, 0xf4, - 0xd, 0x2, 0x41, 0xf1, 0x72, 0x65, 0xe1, 0x60, 0x25, 0x73, 0xd6, 0x6c}; - uint8_t bytes4[] = {0x47, 0xdd, 0xc8, 0x65, 0xf3, 0xbf, 0xb, 0x3d, 0xdd, 0x43, 0xb1, 0x8, 0xf1, 0xe3, - 0x8b, 0x9d, 0xd5, 0x34, 0x48, 0xbb, 0x50, 0x48, 0xeb, 0xde, 0x10, 0x6, 0x20}; - uint8_t bytes5[] = {0xf6, 0x3a, 0xfc, 0x8d, 0x9, 0x12, 0x81, 0x70, 0xfe, 0x7b, - 0xf8, 0xbc, 0xff, 0x1b, 0x29, 0x7d, 0x98, 0x8f, 0xf5}; - uint8_t bytes6[] = {0x31, 0xee, 0x91, 0xbe, 0xf2, 0x33, 0xae, 0x5c, 0x45, 0x1c, 0x90}; - uint8_t bytes7[] = {0x70, 0xa3, 0x7b, 0x2, 0x63, 0xdb, 0xdf, 0x4f, 0xfc, 0x1d, - 0xf2, 0x40, 0x7c, 0x75, 0x6a, 0x41, 0x4, 0xb3, 0x37, 0x2e}; - uint8_t bytes9[] = {0x4a, 0xfa, 0xc9, 0x9c, 0x2a, 0x70, 0x44, 0x9c, 0xf8, 0x51, 0xd4, 0xd4, 0xa5, 0xf5, 0x62, - 0x66, 0x36, 0x8c, 0xb3, 0x1e, 0x17, 0xca, 0x88, 0xee, 0xf9, 0x34, 0x5e, 0x63, 0x23}; - uint8_t bytes8[] = {0xcc, 0x6a, 0xf0, 0x6b, 0xb4, 0x33, 0xc5, 0xb2, 0xbf, 0x33, 0x89, 0xc1, 0xd8, 0x20, 0x86, - 0x7e, 0x2c, 0x89, 0x6b, 0x2e, 0x52, 0x74, 0x81, 0xcd, 0x70, 0x34, 0xf9, 0xf4, 0xe2, 0xf1}; - uint8_t bytes11[] = {0xd7, 0x67, 0x12, 0xfe, 0xa0, 0x46, 0xf7, 0x64, 0x99, 0x82, 0x19, 0x4, 0x5c, - 0xa3, 0xec, 0xbd, 0x94, 0x1f, 0x9a, 0x24, 0x96, 0xd3, 0x8, 0x51, 0xca, 0x11}; - uint8_t bytes10[] = {0x9, 0x27, 0x71, 0x64, 0x31, 0x23, 0xff, 0xf8, 0xa0, 0x2e}; - uint8_t bytes12[] = {0x1a, 0xfc, 0xa8, 0xae, 0xcc, 0xda, 0x32, 0xe9, 0x58, 0x13, 0xdf, 0x2c, 0xc3, 0x5, 0x39, - 0xa, 0x11, 0x98, 0xef, 0x1e, 0x19, 0x33, 0xfa, 0x36, 0x8, 0x79, 0x5b, 0xe1, 0xeb, 0x98}; - uint8_t bytes14[] = {0xe1, 0x7e}; - uint8_t bytes13[] = {0x72, 0xa3, 0xd5, 0x18, 0x8, 0x33, 0xc5, 0xc9, 0x18, 0x11, 0xc2, 0xd3, 0xd3, 0xc9}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9141}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2629}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13928}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7205}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 319}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3982}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7512}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytes7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27783}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17888}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytes8}, .v = {29, (char*)&bytes9}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8403}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32198}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytes10}, .v = {26, (char*)&bytes11}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1577}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytes12}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytes13}, .v = {2, (char*)&bytes14}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 61}}, + uint8_t bytesprops0[] = {0xdc, 0x8, 0x3c, 0x2b, 0x13, 0xf5, 0x5, 0xc8, 0x7f, 0x30, 0x73, 0x8a, 0x62, + 0xdf, 0xf5, 0x36, 0x1d, 0xbe, 0x95, 0xb6, 0x13, 0x6d, 0xb4, 0x8e, 0x3c, 0xb5}; + uint8_t bytesprops1[] = {0x96, 0xae, 0xee, 0xf7, 0x5e}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0xeb, 0x2d, 0x9e, 0xec, 0x3c, 0x5a}; + uint8_t bytesprops5[] = {0xf0, 0x72, 0xe3, 0x44, 0xa3}; + uint8_t bytesprops4[] = {0x6b, 0xb4, 0xec, 0x46, 0x4e, 0xf5, 0x48, 0xf0, 0xd8, 0xed, 0xfe, 0x58, + 0x32, 0x59, 0x74, 0x5c, 0x56, 0x6d, 0xcd, 0x1c, 0x76, 0x54, 0xb2, 0x7b}; + uint8_t bytesprops6[] = {0x65, 0xfb, 0xc, 0xc8, 0xed, 0x3e, 0xf1, 0xa}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4046}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19374}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30717}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22891}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16285}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27866}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops4}, .v = {5, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29262, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\253a\DC4gD\189tvCr\177\&0w\132", -// _pubPktID = 26, _pubBody = "\188\SOx\169\171\214_\225\142.\SIW\SO\149\GS\184M\199\137\174\128cS\187OBD\139\218", -// _pubProps = [PropAuthenticationData "\226\204/{?\249a\ro\SUB\DEL\SO",PropRetainAvailable 219,PropResponseTopic -// "\234\222\203\USD\DC1N\154B\SOHg\155\148\154\SYN\136\164\b#",PropCorrelationData -// "6\181\218\186\233`7IK\158\241P\191\157^\196\242&\178\ACK\RS\246\r\241h\189b\211",PropResponseInformation -// "Q|\255J\246:",PropMaximumPacketSize 32759,PropTopicAliasMaximum 7804,PropServerReference -// "\178\&2]^r\252qQ",PropPayloadFormatIndicator 84,PropServerReference -// "\216B\204\195\251\NAK\ETBE\179",PropSubscriptionIdentifier 19,PropServerKeepAlive -// 27535,PropWildcardSubscriptionAvailable 84,PropTopicAlias 29554,PropResponseTopic -// "\183\170\178\171",PropMessageExpiryInterval 6362,PropTopicAlias 5792,PropSubscriptionIdentifierAvailable 252]} -TEST(Publish50QCTest, Encode98) { - uint8_t pkt[] = {0x3a, 0xbc, 0x1, 0x0, 0xe, 0xfd, 0x61, 0x14, 0x67, 0x44, 0xbd, 0x74, 0x76, 0x43, 0x72, 0xb1, - 0x30, 0x77, 0x84, 0x0, 0x1a, 0x8b, 0x1, 0x16, 0x0, 0xc, 0xe2, 0xcc, 0x2f, 0x7b, 0x3f, 0xf9, - 0x61, 0xd, 0x6f, 0x1a, 0x7f, 0xe, 0x25, 0xdb, 0x8, 0x0, 0x13, 0xea, 0xde, 0xcb, 0x1f, 0x44, - 0x11, 0x4e, 0x9a, 0x42, 0x1, 0x67, 0x9b, 0x94, 0x9a, 0x16, 0x88, 0xa4, 0x8, 0x23, 0x9, 0x0, - 0x1c, 0x36, 0xb5, 0xda, 0xba, 0xe9, 0x60, 0x37, 0x49, 0x4b, 0x9e, 0xf1, 0x50, 0xbf, 0x9d, 0x5e, - 0xc4, 0xf2, 0x26, 0xb2, 0x6, 0x1e, 0xf6, 0xd, 0xf1, 0x68, 0xbd, 0x62, 0xd3, 0x1a, 0x0, 0x6, - 0x51, 0x7c, 0xff, 0x4a, 0xf6, 0x3a, 0x27, 0x0, 0x0, 0x7f, 0xf7, 0x22, 0x1e, 0x7c, 0x1c, 0x0, - 0x8, 0xb2, 0x32, 0x5d, 0x5e, 0x72, 0xfc, 0x71, 0x51, 0x1, 0x54, 0x1c, 0x0, 0x9, 0xd8, 0x42, - 0xcc, 0xc3, 0xfb, 0x15, 0x17, 0x45, 0xb3, 0xb, 0x13, 0x13, 0x6b, 0x8f, 0x28, 0x54, 0x23, 0x73, - 0x72, 0x8, 0x0, 0x4, 0xb7, 0xaa, 0xb2, 0xab, 0x2, 0x0, 0x0, 0x18, 0xda, 0x23, 0x16, 0xa0, - 0x29, 0xfc, 0xbc, 0xe, 0x78, 0xa9, 0xab, 0xd6, 0x5f, 0xe1, 0x8e, 0x2e, 0xf, 0x57, 0xe, 0x95, - 0x1d, 0xb8, 0x4d, 0xc7, 0x89, 0xae, 0x80, 0x63, 0x53, 0xbb, 0x4f, 0x42, 0x44, 0x8b, 0xda}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "5b0\195\142R\129\205", _pubPktID = +// 25975, _pubBody = ":\135\203\145\&6\148\180\155\&28\243", _pubProps = [PropSubscriptionIdentifier 1]} +TEST(Publish5QCTest, Encode97) { + uint8_t pkt[] = {0x33, 0x1a, 0x0, 0x8, 0x35, 0x62, 0x30, 0xc3, 0x8e, 0x52, 0x81, 0xcd, 0x65, 0x77, + 0x2, 0xb, 0x1, 0x3a, 0x87, 0xcb, 0x91, 0x36, 0x94, 0xb4, 0x9b, 0x32, 0x38, 0xf3}; - uint8_t buf[201] = {0}; + uint8_t buf[38] = {0}; - uint8_t topic_bytes[] = {0xfd, 0x61, 0x14, 0x67, 0x44, 0xbd, 0x74, 0x76, 0x43, 0x72, 0xb1, 0x30, 0x77, 0x84}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x35, 0x62, 0x30, 0xc3, 0x8e, 0x52, 0x81, 0xcd}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xbc, 0xe, 0x78, 0xa9, 0xab, 0xd6, 0x5f, 0xe1, 0x8e, 0x2e, 0xf, 0x57, 0xe, 0x95, 0x1d, - 0xb8, 0x4d, 0xc7, 0x89, 0xae, 0x80, 0x63, 0x53, 0xbb, 0x4f, 0x42, 0x44, 0x8b, 0xda}; + msg.retained = true; + uint8_t msg_bytes[] = {0x3a, 0x87, 0xcb, 0x91, 0x36, 0x94, 0xb4, 0x9b, 0x32, 0x38, 0xf3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 11; - uint8_t bytes0[] = {0xe2, 0xcc, 0x2f, 0x7b, 0x3f, 0xf9, 0x61, 0xd, 0x6f, 0x1a, 0x7f, 0xe}; - uint8_t bytes1[] = {0xea, 0xde, 0xcb, 0x1f, 0x44, 0x11, 0x4e, 0x9a, 0x42, 0x1, - 0x67, 0x9b, 0x94, 0x9a, 0x16, 0x88, 0xa4, 0x8, 0x23}; - uint8_t bytes2[] = {0x36, 0xb5, 0xda, 0xba, 0xe9, 0x60, 0x37, 0x49, 0x4b, 0x9e, 0xf1, 0x50, 0xbf, 0x9d, - 0x5e, 0xc4, 0xf2, 0x26, 0xb2, 0x6, 0x1e, 0xf6, 0xd, 0xf1, 0x68, 0xbd, 0x62, 0xd3}; - uint8_t bytes3[] = {0x51, 0x7c, 0xff, 0x4a, 0xf6, 0x3a}; - uint8_t bytes4[] = {0xb2, 0x32, 0x5d, 0x5e, 0x72, 0xfc, 0x71, 0x51}; - uint8_t bytes5[] = {0xd8, 0x42, 0xcc, 0xc3, 0xfb, 0x15, 0x17, 0x45, 0xb3}; - uint8_t bytes6[] = {0xb7, 0xaa, 0xb2, 0xab}; - - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytes2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytes3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32759}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7804}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytes4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytes5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27535}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29554}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytes6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6362}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5792}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 252}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 26, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 25975, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\251\169\245\241\201;\SOH\174B\v\STX\SOH\202\137\ETX\139y\235\139\&8~b&\235", _pubPktID = 0, _pubBody = -// "O\222\143\SO\DC2\DC2\180\DC3\242\226I\151\ACKv\247\150\v\DC4\228", _pubProps = [PropMaximumQoS 201]} -TEST(Publish50QCTest, Encode99) { - uint8_t pkt[] = {0x39, 0x30, 0x0, 0x18, 0xfb, 0xa9, 0xf5, 0xf1, 0xc9, 0x3b, 0x1, 0xae, 0x42, 0xb, 0x2, 0x1, 0xca, - 0x89, 0x3, 0x8b, 0x79, 0xeb, 0x8b, 0x38, 0x7e, 0x62, 0x26, 0xeb, 0x2, 0x24, 0xc9, 0x4f, 0xde, 0x8f, - 0xe, 0x12, 0x12, 0xb4, 0x13, 0xf2, 0xe2, 0x49, 0x97, 0x6, 0x76, 0xf7, 0x96, 0xb, 0x14, 0xe4}; - - uint8_t buf[60] = {0}; - - uint8_t topic_bytes[] = {0xfb, 0xa9, 0xf5, 0xf1, 0xc9, 0x3b, 0x1, 0xae, 0x42, 0xb, 0x2, 0x1, - 0xca, 0x89, 0x3, 0x8b, 0x79, 0xeb, 0x8b, 0x38, 0x7e, 0x62, 0x26, 0xeb}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\213Jr\201\234\223\158\NULA\172F$x\203\226", _pubPktID = 5740, _pubBody = +// "\v\DC4\158\192\171F\249\ESC\192U\254\"\152\151", _pubProps = [PropTopicAliasMaximum 31021,PropPayloadFormatIndicator +// 129,PropWildcardSubscriptionAvailable 110,PropAuthenticationMethod +// "\165\200\f\130\b\178\175\170\160d\253\186g\214L\t\181\NUL\152",PropMaximumPacketSize 18785,PropRetainAvailable +// 128,PropTopicAliasMaximum 8682,PropWildcardSubscriptionAvailable 123,PropAuthenticationMethod +// "\170\169\r\206<\NAKs\FS98\163\187\DC1Mx6\183M\238'\SINNHu\164",PropPayloadFormatIndicator +// 120,PropSubscriptionIdentifier 7,PropAssignedClientIdentifier "\SUBf\240.[8-c\173\240\&8\EOT\EM\n",PropResponseTopic +// "\224\198",PropServerReference +// "\200\132\249\200\203\DC4\239D\205\172\185P\173\210,c\159\137IC\224M.e\159\253\225",PropSessionExpiryInterval +// 27500,PropRequestProblemInformation 55,PropResponseTopic +// "\161\168\&9\SYN\215\203A\129\143_\183\204u\NUL#M\142\CAN\ap\167",PropAuthenticationMethod "",PropCorrelationData +// "\159\NAK=\"ew\SYN3\246\164b|\ETB\NUL{\139\190\200\182\ETX\251Nq\144\129\SYN\212Q",PropUserProperty +// "\DC1\190\247\SI\225" "z\fT\SUB[\229\135xjol\223\DLE\195\189\158\SYN\DC3\191{q\190\f^^\227<\243",PropMaximumQoS +// 49,PropServerKeepAlive 14505,PropRetainAvailable 171,PropResponseTopic +// "\240\EOT\255\SO\251\&3B\213",PropServerKeepAlive 26936,PropServerKeepAlive 24077,PropResponseTopic +// "P\206\198\253\163 \185\184\ENQ\207\188\189\141cf1",PropContentType "\189\168j~b\168",PropSharedSubscriptionAvailable +// 178,PropWildcardSubscriptionAvailable 218]} +TEST(Publish5QCTest, Encode98) { + uint8_t pkt[] = { + 0x3b, 0xc0, 0x2, 0x0, 0xf, 0xd5, 0x4a, 0x72, 0xc9, 0xea, 0xdf, 0x9e, 0x0, 0x41, 0xac, 0x46, 0x24, 0x78, 0xcb, + 0xe2, 0x16, 0x6c, 0x9d, 0x2, 0x22, 0x79, 0x2d, 0x1, 0x81, 0x28, 0x6e, 0x15, 0x0, 0x13, 0xa5, 0xc8, 0xc, 0x82, + 0x8, 0xb2, 0xaf, 0xaa, 0xa0, 0x64, 0xfd, 0xba, 0x67, 0xd6, 0x4c, 0x9, 0xb5, 0x0, 0x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bd, 0x9e, 0x16, 0x13, 0xbf, 0x7b, 0x71, 0xbe, + 0xc, 0x5e, 0x5e, 0xe3, 0x3c, 0xf3, 0x24, 0x31, 0x13, 0x38, 0xa9, 0x25, 0xab, 0x8, 0x0, 0x8, 0xf0, 0x4, 0xff, + 0xe, 0xfb, 0x33, 0x42, 0xd5, 0x13, 0x69, 0x38, 0x13, 0x5e, 0xd, 0x8, 0x0, 0x10, 0x50, 0xce, 0xc6, 0xfd, 0xa3, + 0x20, 0xb9, 0xb8, 0x5, 0xcf, 0xbc, 0xbd, 0x8d, 0x63, 0x66, 0x31, 0x3, 0x0, 0x6, 0xbd, 0xa8, 0x6a, 0x7e, 0x62, + 0xa8, 0x2a, 0xb2, 0x28, 0xda, 0xb, 0x14, 0x9e, 0xc0, 0xab, 0x46, 0xf9, 0x1b, 0xc0, 0x55, 0xfe, 0x22, 0x98, 0x97}; + + uint8_t buf[333] = {0}; + + uint8_t topic_bytes[] = {0xd5, 0x4a, 0x72, 0xc9, 0xea, 0xdf, 0x9e, 0x0, 0x41, 0xac, 0x46, 0x24, 0x78, 0xcb, 0xe2}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x4f, 0xde, 0x8f, 0xe, 0x12, 0x12, 0xb4, 0x13, 0xf2, 0xe2, - 0x49, 0x97, 0x6, 0x76, 0xf7, 0x96, 0xb, 0x14, 0xe4}; + uint8_t msg_bytes[] = {0xb, 0x14, 0x9e, 0xc0, 0xab, 0x46, 0xf9, 0x1b, 0xc0, 0x55, 0xfe, 0x22, 0x98, 0x97}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 14; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 201}}, + uint8_t bytesprops0[] = {0xa5, 0xc8, 0xc, 0x82, 0x8, 0xb2, 0xaf, 0xaa, 0xa0, 0x64, + 0xfd, 0xba, 0x67, 0xd6, 0x4c, 0x9, 0xb5, 0x0, 0x98}; + uint8_t bytesprops1[] = {0xaa, 0xa9, 0xd, 0xce, 0x3c, 0x15, 0x73, 0x1c, 0x39, 0x38, 0xa3, 0xbb, 0x11, + 0x4d, 0x78, 0x36, 0xb7, 0x4d, 0xee, 0x27, 0xf, 0x4e, 0x4e, 0x48, 0x75, 0xa4}; + uint8_t bytesprops2[] = {0x1a, 0x66, 0xf0, 0x2e, 0x5b, 0x38, 0x2d, 0x63, 0xad, 0xf0, 0x38, 0x4, 0x19, 0xa}; + uint8_t bytesprops3[] = {0xe0, 0xc6}; + uint8_t bytesprops4[] = {0xc8, 0x84, 0xf9, 0xc8, 0xcb, 0x14, 0xef, 0x44, 0xcd, 0xac, 0xb9, 0x50, 0xad, 0xd2, + 0x2c, 0x63, 0x9f, 0x89, 0x49, 0x43, 0xe0, 0x4d, 0x2e, 0x65, 0x9f, 0xfd, 0xe1}; + uint8_t bytesprops5[] = {0xa1, 0xa8, 0x39, 0x16, 0xd7, 0xcb, 0x41, 0x81, 0x8f, 0x5f, 0xb7, + 0xcc, 0x75, 0x0, 0x23, 0x4d, 0x8e, 0x18, 0x7, 0x70, 0xa7}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops7[] = {0x9f, 0x15, 0x3d, 0x22, 0x65, 0x77, 0x16, 0x33, 0xf6, 0xa4, 0x62, 0x7c, 0x17, 0x0, + 0x7b, 0x8b, 0xbe, 0xc8, 0xb6, 0x3, 0xfb, 0x4e, 0x71, 0x90, 0x81, 0x16, 0xd4, 0x51}; + uint8_t bytesprops9[] = {0x7a, 0xc, 0x54, 0x1a, 0x5b, 0xe5, 0x87, 0x78, 0x6a, 0x6f, 0x6c, 0xdf, 0x10, 0xc3, + 0xbd, 0x9e, 0x16, 0x13, 0xbf, 0x7b, 0x71, 0xbe, 0xc, 0x5e, 0x5e, 0xe3, 0x3c, 0xf3}; + uint8_t bytesprops8[] = {0x11, 0xbe, 0xf7, 0xf, 0xe1}; + uint8_t bytesprops10[] = {0xf0, 0x4, 0xff, 0xe, 0xfb, 0x33, 0x42, 0xd5}; + uint8_t bytesprops11[] = {0x50, 0xce, 0xc6, 0xfd, 0xa3, 0x20, 0xb9, 0xb8, + 0x5, 0xcf, 0xbc, 0xbd, 0x8d, 0x63, 0x66, 0x31}; + uint8_t bytesprops12[] = {0xbd, 0xa8, 0x6a, 0x7e, 0x62, 0xa8}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31021}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18785}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8682}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27500}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops8}, .v = {28, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14505}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26936}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24077}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 218}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5740, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\130\195\DC3\129^;\DC2\222\159\233g\190\156\&9\DC2\149t\138<\191|", _pubPktID = 0, _pubBody = -// "\145m\248\188\208:\172\v\129\EOT\158\139\132\192yQ\206S\252\152\ETBQrEx\t\ENQ^\235\139", _pubProps = -// [PropServerReference "\168\163\168\138\bJ+*K|I\236\ESC\EOTQ{\129\141\217Oqj\184\219",PropRequestResponseInformation -// 17,PropRequestProblemInformation 13,PropTopicAlias 11748,PropContentType -// "\220\183\162\rn\131\195\155",PropMessageExpiryInterval 13181,PropWillDelayInterval 21300,PropCorrelationData -// "\130S\"\217G\SI\SYN\GS\188&n\184\194,\163\190Tx\159\141\218e\216\222\RS"]} -TEST(Publish50QCTest, Encode100) { - uint8_t pkt[] = {0x30, 0x89, 0x1, 0x0, 0x15, 0x82, 0xc3, 0x13, 0x81, 0x5e, 0x3b, 0x12, 0xde, 0x9f, 0xe9, 0x67, - 0xbe, 0x9c, 0x39, 0x12, 0x95, 0x74, 0x8a, 0x3c, 0xbf, 0x7c, 0x53, 0x1c, 0x0, 0x18, 0xa8, 0xa3, - 0xa8, 0x8a, 0x8, 0x4a, 0x2b, 0x2a, 0x4b, 0x7c, 0x49, 0xec, 0x1b, 0x4, 0x51, 0x7b, 0x81, 0x8d, - 0xd9, 0x4f, 0x71, 0x6a, 0xb8, 0xdb, 0x19, 0x11, 0x17, 0xd, 0x23, 0x2d, 0xe4, 0x3, 0x0, 0x8, - 0xdc, 0xb7, 0xa2, 0xd, 0x6e, 0x83, 0xc3, 0x9b, 0x2, 0x0, 0x0, 0x33, 0x7d, 0x18, 0x0, 0x0, - 0x53, 0x34, 0x9, 0x0, 0x19, 0x82, 0x53, 0x22, 0xd9, 0x47, 0xf, 0x16, 0x1d, 0xbc, 0x26, 0x6e, - 0xb8, 0xc2, 0x2c, 0xa3, 0xbe, 0x54, 0x78, 0x9f, 0x8d, 0xda, 0x65, 0xd8, 0xde, 0x1e, 0x91, 0x6d, - 0xf8, 0xbc, 0xd0, 0x3a, 0xac, 0xb, 0x81, 0x4, 0x9e, 0x8b, 0x84, 0xc0, 0x79, 0x51, 0xce, 0x53, - 0xfc, 0x98, 0x17, 0x51, 0x72, 0x45, 0x78, 0x9, 0x5, 0x5e, 0xeb, 0x8b}; - - uint8_t buf[150] = {0}; - - uint8_t topic_bytes[] = {0x82, 0xc3, 0x13, 0x81, 0x5e, 0x3b, 0x12, 0xde, 0x9f, 0xe9, 0x67, - 0xbe, 0x9c, 0x39, 0x12, 0x95, 0x74, 0x8a, 0x3c, 0xbf, 0x7c}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\t\CAN\145\171\148w\238,P\186\ETBHJo\217H\202\133\175\171.\147\134f\238\240X\231\137", _pubPktID = 1370, _pubBody = +// "`\241\GS\145\216\168\157\253JO\171\208j1]K\RSL<\242\&4", _pubProps = [PropCorrelationData +// "~\SO\252\191",PropTopicAliasMaximum 29794,PropTopicAlias 18581,PropSubscriptionIdentifier 28,PropTopicAliasMaximum +// 24754,PropAssignedClientIdentifier "",PropMessageExpiryInterval 19074,PropSessionExpiryInterval +// 19069,PropCorrelationData "\176\187'QX\\\183\&7\243\230\237",PropRequestResponseInformation 117,PropServerKeepAlive +// 809,PropReasonString "",PropResponseInformation "\227'\148#\197\&8N\193\242\159",PropMessageExpiryInterval +// 9394,PropRequestResponseInformation 20,PropAuthenticationData "=\170\v@\229\161o\202Q\134\184q\165\157n\205"]} +TEST(Publish5QCTest, Encode99) { + uint8_t pkt[] = {0x32, 0x93, 0x1, 0x0, 0x1d, 0x9, 0x18, 0x91, 0xab, 0x94, 0x77, 0xee, 0x2c, 0x50, 0xba, 0x17, 0x48, + 0x4a, 0x6f, 0xd9, 0x48, 0xca, 0x85, 0xaf, 0xab, 0x2e, 0x93, 0x86, 0x66, 0xee, 0xf0, 0x58, 0xe7, 0x89, + 0x5, 0x5a, 0x5c, 0x9, 0x0, 0x4, 0x7e, 0xe, 0xfc, 0xbf, 0x22, 0x74, 0x62, 0x23, 0x48, 0x95, 0xb, + 0x1c, 0x22, 0x60, 0xb2, 0x12, 0x0, 0x0, 0x2, 0x0, 0x0, 0x4a, 0x82, 0x11, 0x0, 0x0, 0x4a, 0x7d, + 0x9, 0x0, 0xb, 0xb0, 0xbb, 0x27, 0x51, 0x58, 0x5c, 0xb7, 0x37, 0xf3, 0xe6, 0xed, 0x19, 0x75, 0x13, + 0x3, 0x29, 0x1f, 0x0, 0x0, 0x1a, 0x0, 0xa, 0xe3, 0x27, 0x94, 0x23, 0xc5, 0x38, 0x4e, 0xc1, 0xf2, + 0x9f, 0x2, 0x0, 0x0, 0x24, 0xb2, 0x19, 0x14, 0x16, 0x0, 0x10, 0x3d, 0xaa, 0xb, 0x40, 0xe5, 0xa1, + 0x6f, 0xca, 0x51, 0x86, 0xb8, 0x71, 0xa5, 0x9d, 0x6e, 0xcd, 0x60, 0xf1, 0x1d, 0x91, 0xd8, 0xa8, 0x9d, + 0xfd, 0x4a, 0x4f, 0xab, 0xd0, 0x6a, 0x31, 0x5d, 0x4b, 0x1e, 0x4c, 0x3c, 0xf2, 0x34}; + + uint8_t buf[160] = {0}; + + uint8_t topic_bytes[] = {0x9, 0x18, 0x91, 0xab, 0x94, 0x77, 0xee, 0x2c, 0x50, 0xba, 0x17, 0x48, 0x4a, 0x6f, 0xd9, + 0x48, 0xca, 0x85, 0xaf, 0xab, 0x2e, 0x93, 0x86, 0x66, 0xee, 0xf0, 0x58, 0xe7, 0x89}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x91, 0x6d, 0xf8, 0xbc, 0xd0, 0x3a, 0xac, 0xb, 0x81, 0x4, 0x9e, 0x8b, 0x84, 0xc0, 0x79, - 0x51, 0xce, 0x53, 0xfc, 0x98, 0x17, 0x51, 0x72, 0x45, 0x78, 0x9, 0x5, 0x5e, 0xeb, 0x8b}; + uint8_t msg_bytes[] = {0x60, 0xf1, 0x1d, 0x91, 0xd8, 0xa8, 0x9d, 0xfd, 0x4a, 0x4f, 0xab, + 0xd0, 0x6a, 0x31, 0x5d, 0x4b, 0x1e, 0x4c, 0x3c, 0xf2, 0x34}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; - - uint8_t bytes0[] = {0xa8, 0xa3, 0xa8, 0x8a, 0x8, 0x4a, 0x2b, 0x2a, 0x4b, 0x7c, 0x49, 0xec, - 0x1b, 0x4, 0x51, 0x7b, 0x81, 0x8d, 0xd9, 0x4f, 0x71, 0x6a, 0xb8, 0xdb}; - uint8_t bytes1[] = {0xdc, 0xb7, 0xa2, 0xd, 0x6e, 0x83, 0xc3, 0x9b}; - uint8_t bytes2[] = {0x82, 0x53, 0x22, 0xd9, 0x47, 0xf, 0x16, 0x1d, 0xbc, 0x26, 0x6e, 0xb8, 0xc2, - 0x2c, 0xa3, 0xbe, 0x54, 0x78, 0x9f, 0x8d, 0xda, 0x65, 0xd8, 0xde, 0x1e}; + msg.payload_len = 21; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytes0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11748}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytes1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13181}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21300}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytes2}}}, + uint8_t bytesprops0[] = {0x7e, 0xe, 0xfc, 0xbf}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0xb0, 0xbb, 0x27, 0x51, 0x58, 0x5c, 0xb7, 0x37, 0xf3, 0xe6, 0xed}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0xe3, 0x27, 0x94, 0x23, 0xc5, 0x38, 0x4e, 0xc1, 0xf2, 0x9f}; + uint8_t bytesprops5[] = {0x3d, 0xaa, 0xb, 0x40, 0xe5, 0xa1, 0x6f, 0xca, + 0x51, 0x86, 0xb8, 0x71, 0xa5, 0x9d, 0x6e, 0xcd}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29794}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18581}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24754}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19074}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19069}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 809}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9394}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1370, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "surgemq", _pubPktID = 0, _pubBody = -// "send me home", _pubProps = [PropMessageExpiryInterval 33,PropReasonString "a reason"]} -TEST(Publish50QCTest, Encode0) { - uint8_t pkt[] = {0x33, 0x28, 0x0, 0x7, 0x73, 0x75, 0x72, 0x67, 0x65, 0x6d, 0x71, 0x0, 0x0, 0x10, - 0x2, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x0, 0x8, 0x61, 0x20, 0x72, 0x65, 0x61, 0x73, - 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x64, 0x20, 0x6d, 0x65, 0x20, 0x68, 0x6f, 0x6d, 0x65}; - - uint8_t buf[52] = {0}; - - uint8_t topic_bytes[] = {0x73, 0x75, 0x72, 0x67, 0x65, 0x6d, 0x71}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\164.\DC1\135\131x\231n\143\DC3\247\SYN\189D\158\166\166\171\143\129\137\215", _pubPktID = 27834, _pubBody = +// "e8`\SO\145\RS`\179\229\146", _pubProps = [PropMessageExpiryInterval 10598,PropAuthenticationData +// "\n",PropUserProperty "S\201\134$>\130W\199K\133/\196\210\&5L\ESC,\230W\134" +// "?\245\DLE\245\254\164\162)\238Hbc",PropReasonString "\196\&5\176mF=\\",PropCorrelationData +// ";%\255=\149.A\207\233\235&m]\182->=r<@\139\252\vD<",PropResponseInformation +// "\137\155\145\173\231\SI]2z\219c\194\166\DEL{g",PropAuthenticationMethod +// "P\193G\237]\163jl\206\229\&6m\250C*:\141>7\157\139\128\161\EM\128?,a=\168",PropCorrelationData +// "\155\137\206\235\179\166\196'y\DC2:P\133l\SUB\171",PropReceiveMaximum 18094,PropRequestProblemInformation +// 7,PropTopicAlias 25296,PropSessionExpiryInterval 22146,PropPayloadFormatIndicator 34,PropRetainAvailable +// 111,PropContentType "\170\208\249OW\147"]} +TEST(Publish5QCTest, Encode100) { + uint8_t pkt[] = { + 0x3b, 0xdb, 0x1, 0x0, 0x16, 0xa4, 0x2e, 0x11, 0x87, 0x83, 0x78, 0xe7, 0x6e, 0x8f, 0x13, 0xf7, 0x16, 0xbd, 0x44, + 0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0x6, 0xaa, 0xd0, 0xf9, + 0x4f, 0x57, 0x93, 0x65, 0x38, 0x60, 0xe, 0x91, 0x1e, 0x60, 0xb3, 0xe5, 0x92}; + + uint8_t buf[232] = {0}; + + uint8_t topic_bytes[] = {0xa4, 0x2e, 0x11, 0x87, 0x83, 0x78, 0xe7, 0x6e, 0x8f, 0x13, 0xf7, + 0x16, 0xbd, 0x44, 0x9e, 0xa6, 0xa6, 0xab, 0x8f, 0x81, 0x89, 0xd7}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x73, 0x65, 0x6e, 0x64, 0x20, 0x6d, 0x65, 0x20, 0x68, 0x6f, 0x6d, 0x65}; + uint8_t msg_bytes[] = {0x65, 0x38, 0x60, 0xe, 0x91, 0x1e, 0x60, 0xb3, 0xe5, 0x92}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; - - uint8_t bytes0[] = {0x61, 0x20, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e}; + msg.payload_len = 10; - lwmqtt_property_t proplist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 33}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytes0}}}, + uint8_t bytesprops0[] = {0xa}; + uint8_t bytesprops2[] = {0x3f, 0xf5, 0x10, 0xf5, 0xfe, 0xa4, 0xa2, 0x29, 0xee, 0x48, 0x62, 0x63}; + uint8_t bytesprops1[] = {0x53, 0xc9, 0x86, 0x24, 0x3e, 0x82, 0x57, 0xc7, 0x4b, 0x85, + 0x2f, 0xc4, 0xd2, 0x35, 0x4c, 0x1b, 0x2c, 0xe6, 0x57, 0x86}; + uint8_t bytesprops3[] = {0xc4, 0x35, 0xb0, 0x6d, 0x46, 0x3d, 0x5c}; + uint8_t bytesprops4[] = {0x3b, 0x25, 0xff, 0x3d, 0x95, 0x2e, 0x41, 0xcf, 0xe9, 0xeb, 0x26, 0x6d, 0x5d, + 0xb6, 0x2d, 0x3e, 0x3d, 0x72, 0x3c, 0x40, 0x8b, 0xfc, 0xb, 0x44, 0x3c}; + uint8_t bytesprops5[] = {0x89, 0x9b, 0x91, 0xad, 0xe7, 0xf, 0x5d, 0x32, + 0x7a, 0xdb, 0x63, 0xc2, 0xa6, 0x7f, 0x7b, 0x67}; + uint8_t bytesprops6[] = {0x50, 0xc1, 0x47, 0xed, 0x5d, 0xa3, 0x6a, 0x6c, 0xce, 0xe5, 0x36, 0x6d, 0xfa, 0x43, 0x2a, + 0x3a, 0x8d, 0x3e, 0x37, 0x9d, 0x8b, 0x80, 0xa1, 0x19, 0x80, 0x3f, 0x2c, 0x61, 0x3d, 0xa8}; + uint8_t bytesprops7[] = {0x9b, 0x89, 0xce, 0xeb, 0xb3, 0xa6, 0xc4, 0x27, + 0x79, 0x12, 0x3a, 0x50, 0x85, 0x6c, 0x1a, 0xab}; + uint8_t bytesprops8[] = {0xaa, 0xd0, 0xf9, 0x4f, 0x57, 0x93}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10598}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops1}, .v = {12, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18094}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25296}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22146}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&proplist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 27834, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "F\171\131\SI\DC4\132\f\236\247\252", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\246\240", _willMsg = +// "\169\154\b\180\t3\183\199\&9\250\194", _willProps = []}), _cleanSession = True, _keepAlive = 3250, _connID = " +// \241\DC2\ACK\157\190\v\161\205=\\\156dS\184{", _properties = []} +TEST(Connect311QCTest, Encode1) { + uint8_t pkt[] = {0x10, 0x2d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0xc, 0xb2, 0x0, 0x10, 0x20, 0xf1, + 0x12, 0x6, 0x9d, 0xbe, 0xb, 0xa1, 0xcd, 0x3d, 0x5c, 0x9c, 0x64, 0x53, 0xb8, 0x7b, 0x0, 0x2, + 0xf6, 0xf0, 0x0, 0xb, 0xa9, 0x9a, 0x8, 0xb4, 0x9, 0x33, 0xb7, 0xc7, 0x39, 0xfa, 0xc2}; + + uint8_t buf[57] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf6, 0xf0}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa9, 0x9a, 0x8, 0xb4, 0x9, 0x33, 0xb7, 0xc7, 0x39, 0xfa, 0xc2}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 3250; + uint8_t client_id_bytes[] = {0x20, 0xf1, 0x12, 0x6, 0x9d, 0xbe, 0xb, 0xa1, + 0xcd, 0x3d, 0x5c, 0x9c, 0x64, 0x53, 0xb8, 0x7b}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x46, 0xab, 0x83, 0xf, 0x14, 0x84, 0xc, 0xec, 0xf7, 0xfc}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\185\211\STX\225\EOT\134\DC4\DC2", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "y\133\f\222\RS\142", _willMsg = +// "\252\142\185\165\252\211e|\US\228\205\SYN\193\227\255\173\EOT$", _willProps = []}), _cleanSession = False, +// _keepAlive = 15842, _connID = "", _properties = []} +TEST(Connect311QCTest, Encode2) { + uint8_t pkt[] = {0x10, 0x32, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x84, 0x3d, 0xe2, 0x0, + 0x0, 0x0, 0x6, 0x79, 0x85, 0xc, 0xde, 0x1e, 0x8e, 0x0, 0x12, 0xfc, 0x8e, + 0xb9, 0xa5, 0xfc, 0xd3, 0x65, 0x7c, 0x1f, 0xe4, 0xcd, 0x16, 0xc1, 0xe3, 0xff, + 0xad, 0x4, 0x24, 0x0, 0x8, 0xb9, 0xd3, 0x2, 0xe1, 0x4, 0x86, 0x14, 0x12}; + + uint8_t buf[62] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x79, 0x85, 0xc, 0xde, 0x1e, 0x8e}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfc, 0x8e, 0xb9, 0xa5, 0xfc, 0xd3, 0x65, 0x7c, 0x1f, + 0xe4, 0xcd, 0x16, 0xc1, 0xe3, 0xff, 0xad, 0x4, 0x24}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 15842; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xb9, 0xd3, 0x2, 0xe1, 0x4, 0x86, 0x14, 0x12}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "eb:\159\169fA~\133\\\r6A7\139\&2\174\229Ue", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\255\245V\194\148\209\GS\f\218\140\201\EM/;H\146\135\176\253}\184\207V7.", _willMsg = +// "\SOH11\t\238\217?\210\\\EOT\223k\192\250?\156\178<\236+\SIQ\209\ACK\177\204\163", _willProps = []}), _cleanSession = +// False, _keepAlive = 29642, _connID = "\212eR", _properties = []} +TEST(Connect311QCTest, Encode3) { + uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2c, 0x73, 0xca, 0x0, 0x3, 0xd4, + 0x65, 0x52, 0x0, 0x19, 0xff, 0xf5, 0x56, 0xc2, 0x94, 0xd1, 0x1d, 0xc, 0xda, 0x8c, 0xc9, + 0x19, 0x2f, 0x3b, 0x48, 0x92, 0x87, 0xb0, 0xfd, 0x7d, 0xb8, 0xcf, 0x56, 0x37, 0x2e, 0x0, + 0x1b, 0x1, 0x31, 0x31, 0x9, 0xee, 0xd9, 0x3f, 0xd2, 0x5c, 0x4, 0xdf, 0x6b, 0xc0, 0xfa, + 0x3f, 0x9c, 0xb2, 0x3c, 0xec, 0x2b, 0xf, 0x51, 0xd1, 0x6, 0xb1, 0xcc, 0xa3}; + + uint8_t buf[83] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xff, 0xf5, 0x56, 0xc2, 0x94, 0xd1, 0x1d, 0xc, 0xda, 0x8c, 0xc9, 0x19, 0x2f, + 0x3b, 0x48, 0x92, 0x87, 0xb0, 0xfd, 0x7d, 0xb8, 0xcf, 0x56, 0x37, 0x2e}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1, 0x31, 0x31, 0x9, 0xee, 0xd9, 0x3f, 0xd2, 0x5c, 0x4, 0xdf, 0x6b, 0xc0, 0xfa, + 0x3f, 0x9c, 0xb2, 0x3c, 0xec, 0x2b, 0xf, 0x51, 0xd1, 0x6, 0xb1, 0xcc, 0xa3}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 29642; + uint8_t client_id_bytes[] = {0xd4, 0x65, 0x52}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x65, 0x62, 0x3a, 0x9f, 0xa9, 0x66, 0x41, 0x7e, 0x85, 0x5c, + 0xd, 0x36, 0x41, 0x37, 0x8b, 0x32, 0xae, 0xe5, 0x55, 0x65}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "\197\244\208\172eI\158\208\&4\a\235\DC4\182d\132\GS\189\130O\128\228\192 ", _willMsg = +// "\162T\168%T\161[\138\\\156~t\191\154\206\ETX", _willProps = []}), _cleanSession = False, _keepAlive = 5339, _connID +// = "\194\163\154\203\EOTLMG`#\161l", _properties = []} +TEST(Connect311QCTest, Encode4) { + uint8_t pkt[] = {0x10, 0x43, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0x14, 0xdb, 0x0, 0xc, + 0xc2, 0xa3, 0x9a, 0xcb, 0x4, 0x4c, 0x4d, 0x47, 0x60, 0x23, 0xa1, 0x6c, 0x0, 0x17, + 0xc5, 0xf4, 0xd0, 0xac, 0x65, 0x49, 0x9e, 0xd0, 0x34, 0x7, 0xeb, 0x14, 0xb6, 0x64, + 0x84, 0x1d, 0xbd, 0x82, 0x4f, 0x80, 0xe4, 0xc0, 0x20, 0x0, 0x10, 0xa2, 0x54, 0xa8, + 0x25, 0x54, 0xa1, 0x5b, 0x8a, 0x5c, 0x9c, 0x7e, 0x74, 0xbf, 0x9a, 0xce, 0x3}; + + uint8_t buf[79] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc5, 0xf4, 0xd0, 0xac, 0x65, 0x49, 0x9e, 0xd0, 0x34, 0x7, 0xeb, 0x14, + 0xb6, 0x64, 0x84, 0x1d, 0xbd, 0x82, 0x4f, 0x80, 0xe4, 0xc0, 0x20}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa2, 0x54, 0xa8, 0x25, 0x54, 0xa1, 0x5b, 0x8a, + 0x5c, 0x9c, 0x7e, 0x74, 0xbf, 0x9a, 0xce, 0x3}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 5339; + uint8_t client_id_bytes[] = {0xc2, 0xa3, 0x9a, 0xcb, 0x4, 0x4c, 0x4d, 0x47, 0x60, 0x23, 0xa1, 0x6c}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\185\GSc\246\205\210\\\233\183w\EOT\252|-\224", _password = Nothing, _lastWill = +// Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\154\135@Q", _willMsg = +// "=\135\DEL\152\&4.\238\216\245h\157\130\aq\223\150:WI\169k\RS\149", _willProps = []}), _cleanSession = False, +// _keepAlive = 23142, _connID = "J\242", _properties = []} +TEST(Connect311QCTest, Encode5) { + uint8_t pkt[] = {0x10, 0x3e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb4, 0x5a, 0x66, 0x0, 0x2, 0x4a, 0xf2, + 0x0, 0x4, 0x9a, 0x87, 0x40, 0x51, 0x0, 0x17, 0x3d, 0x87, 0x7f, 0x98, 0x34, 0x2e, 0xee, 0xd8, + 0xf5, 0x68, 0x9d, 0x82, 0x7, 0x71, 0xdf, 0x96, 0x3a, 0x57, 0x49, 0xa9, 0x6b, 0x1e, 0x95, 0x0, + 0xf, 0xb9, 0x1d, 0x63, 0xf6, 0xcd, 0xd2, 0x5c, 0xe9, 0xb7, 0x77, 0x4, 0xfc, 0x7c, 0x2d, 0xe0}; + + uint8_t buf[74] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9a, 0x87, 0x40, 0x51}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3d, 0x87, 0x7f, 0x98, 0x34, 0x2e, 0xee, 0xd8, 0xf5, 0x68, 0x9d, 0x82, + 0x7, 0x71, 0xdf, 0x96, 0x3a, 0x57, 0x49, 0xa9, 0x6b, 0x1e, 0x95}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 23142; + uint8_t client_id_bytes[] = {0x4a, 0xf2}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xb9, 0x1d, 0x63, 0xf6, 0xcd, 0xd2, 0x5c, 0xe9, 0xb7, 0x77, 0x4, 0xfc, 0x7c, 0x2d, 0xe0}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "\240\223\219|\165/\216\169G\212Ta\158=\151\215\242\164\220\199\164\236\142\249\194\194\EMU\245\214", _password = +// Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 11621, _connID = "Y", _properties = []} +TEST(Connect311QCTest, Encode6) { + uint8_t pkt[] = {0x10, 0x2d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x2d, 0x65, 0x0, 0x1, 0x59, 0x0, + 0x1e, 0xf0, 0xdf, 0xdb, 0x7c, 0xa5, 0x2f, 0xd8, 0xa9, 0x47, 0xd4, 0x54, 0x61, 0x9e, 0x3d, 0x97, + 0xd7, 0xf2, 0xa4, 0xdc, 0xc7, 0xa4, 0xec, 0x8e, 0xf9, 0xc2, 0xc2, 0x19, 0x55, 0xf5, 0xd6}; + + uint8_t buf[57] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 11621; + uint8_t client_id_bytes[] = {0x59}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xf0, 0xdf, 0xdb, 0x7c, 0xa5, 0x2f, 0xd8, 0xa9, 0x47, 0xd4, 0x54, 0x61, 0x9e, 0x3d, 0x97, + 0xd7, 0xf2, 0xa4, 0xdc, 0xc7, 0xa4, 0xec, 0x8e, 0xf9, 0xc2, 0xc2, 0x19, 0x55, 0xf5, 0xd6}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "]\218\DC2\160G\231\&5\185\137ZQ", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 32745, _connID = "\248\163cDx\241\168\&8\140/\228\161\192\&3o\168\223", +// _properties = []} +TEST(Connect311QCTest, Encode7) { + uint8_t pkt[] = {0x10, 0x1d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x7f, 0xe9, 0x0, 0x11, 0xf8, 0xa3, + 0x63, 0x44, 0x78, 0xf1, 0xa8, 0x38, 0x8c, 0x2f, 0xe4, 0xa1, 0xc0, 0x33, 0x6f, 0xa8, 0xdf}; + + uint8_t buf[41] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32745; + uint8_t client_id_bytes[] = {0xf8, 0xa3, 0x63, 0x44, 0x78, 0xf1, 0xa8, 0x38, 0x8c, + 0x2f, 0xe4, 0xa1, 0xc0, 0x33, 0x6f, 0xa8, 0xdf}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x5d, 0xda, 0x12, 0xa0, 0x47, 0xe7, 0x35, 0xb9, 0x89, 0x5a, 0x51}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\NUL\136\181", _password = Just +// "d%\139\252\SUB\v\232)\218\ESC\DC3\212F\DC1\238\243j\SO\251\168", _lastWill = Nothing, _cleanSession = False, +// _keepAlive = 14321, _connID = "\SOHH\187\196\DEL\173\132\&0wH\SI\210C\131\DC4", _properties = []} +TEST(Connect311QCTest, Encode8) { + uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x37, 0xf1, 0x0, 0xf, + 0x1, 0x48, 0xbb, 0xc4, 0x7f, 0xad, 0x84, 0x30, 0x77, 0x48, 0xf, 0xd2, 0x43, 0x83, + 0x14, 0x0, 0x3, 0x0, 0x88, 0xb5, 0x0, 0x14, 0x64, 0x25, 0x8b, 0xfc, 0x1a, 0xb, + 0xe8, 0x29, 0xda, 0x1b, 0x13, 0xd4, 0x46, 0x11, 0xee, 0xf3, 0x6a, 0xe, 0xfb, 0xa8}; + + uint8_t buf[66] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 14321; + uint8_t client_id_bytes[] = {0x1, 0x48, 0xbb, 0xc4, 0x7f, 0xad, 0x84, 0x30, 0x77, 0x48, 0xf, 0xd2, 0x43, 0x83, 0x14}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x0, 0x88, 0xb5}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x64, 0x25, 0x8b, 0xfc, 0x1a, 0xb, 0xe8, 0x29, 0xda, 0x1b, + 0x13, 0xd4, 0x46, 0x11, 0xee, 0xf3, 0x6a, 0xe, 0xfb, 0xa8}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\142\224!;+'mV", _password = Just +// "{h\173\&5]\vz\\P\196\181X.\"B~\207\241\156]f\195X\DC1\203u\149\151\249", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS1, _willTopic = "S]\n\ETB[\ACK)\233\177\225N\218\162\EM\240p\239O", _willMsg = "\183", +// _willProps = []}), _cleanSession = False, _keepAlive = 24734, _connID = "gYE\207\225\215\192", _properties = []} +TEST(Connect311QCTest, Encode9) { + uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x60, 0x9e, 0x0, 0x7, 0x67, + 0x59, 0x45, 0xcf, 0xe1, 0xd7, 0xc0, 0x0, 0x12, 0x53, 0x5d, 0xa, 0x17, 0x5b, 0x6, 0x29, + 0xe9, 0xb1, 0xe1, 0x4e, 0xda, 0xa2, 0x19, 0xf0, 0x70, 0xef, 0x4f, 0x0, 0x1, 0xb7, 0x0, + 0x8, 0x8e, 0xe0, 0x21, 0x3b, 0x2b, 0x27, 0x6d, 0x56, 0x0, 0x1d, 0x7b, 0x68, 0xad, 0x35, + 0x5d, 0xb, 0x7a, 0x5c, 0x50, 0xc4, 0xb5, 0x58, 0x2e, 0x22, 0x42, 0x7e, 0xcf, 0xf1, 0x9c, + 0x5d, 0x66, 0xc3, 0x58, 0x11, 0xcb, 0x75, 0x95, 0x97, 0xf9}; + + uint8_t buf[95] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x53, 0x5d, 0xa, 0x17, 0x5b, 0x6, 0x29, 0xe9, 0xb1, + 0xe1, 0x4e, 0xda, 0xa2, 0x19, 0xf0, 0x70, 0xef, 0x4f}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb7}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 24734; + uint8_t client_id_bytes[] = {0x67, 0x59, 0x45, 0xcf, 0xe1, 0xd7, 0xc0}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x8e, 0xe0, 0x21, 0x3b, 0x2b, 0x27, 0x6d, 0x56}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x7b, 0x68, 0xad, 0x35, 0x5d, 0xb, 0x7a, 0x5c, 0x50, 0xc4, 0xb5, 0x58, 0x2e, 0x22, 0x42, + 0x7e, 0xcf, 0xf1, 0x9c, 0x5d, 0x66, 0xc3, 0x58, 0x11, 0xcb, 0x75, 0x95, 0x97, 0xf9}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\r7\"\154\EOT", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS1, _willTopic = "\\\131\211\214\209\183\242\162", _willMsg = ")&", _willProps = []}), +// _cleanSession = False, _keepAlive = 17778, _connID = "\160\202\220\&9^\188\ENQ\223w\149\158\233", _properties = []} +TEST(Connect311QCTest, Encode10) { + uint8_t pkt[] = {0x10, 0x2d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8c, 0x45, 0x72, 0x0, 0xc, 0xa0, 0xca, + 0xdc, 0x39, 0x5e, 0xbc, 0x5, 0xdf, 0x77, 0x95, 0x9e, 0xe9, 0x0, 0x8, 0x5c, 0x83, 0xd3, 0xd6, + 0xd1, 0xb7, 0xf2, 0xa2, 0x0, 0x2, 0x29, 0x26, 0x0, 0x5, 0xd, 0x37, 0x22, 0x9a, 0x4}; + + uint8_t buf[57] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5c, 0x83, 0xd3, 0xd6, 0xd1, 0xb7, 0xf2, 0xa2}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x29, 0x26}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 17778; + uint8_t client_id_bytes[] = {0xa0, 0xca, 0xdc, 0x39, 0x5e, 0xbc, 0x5, 0xdf, 0x77, 0x95, 0x9e, 0xe9}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xd, 0x37, 0x22, 0x9a, 0x4}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\181\bX\195\NULZ\169\250\173\230E\239g\209\226\145:pJ ^\SO\192\SYN,V\138\226", +// _password = Just "b\129\SOH\222>\130\229h\251\208QM\146\255\&3 \190\166T%QC\v\RS\n\183 &\205&Em", _willProps = []}), _cleanSession = True, _keepAlive = 8661, _connID = +// "\213\183*l\161!\168\252p\153\208\254\DC1<\235", _properties = []} +TEST(Connect311QCTest, Encode17) { + uint8_t pkt[] = {0x10, 0x4c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x21, 0xd5, 0x0, 0xf, 0xd5, 0xb7, + 0x2a, 0x6c, 0xa1, 0x21, 0xa8, 0xfc, 0x70, 0x99, 0xd0, 0xfe, 0x11, 0x3c, 0xeb, 0x0, 0x1d, 0x9, + 0xde, 0x9f, 0x53, 0xa5, 0x9d, 0x2e, 0x4c, 0xbf, 0xdb, 0x1a, 0xf9, 0x1d, 0x46, 0x40, 0xeb, 0xf1, + 0x74, 0x5c, 0xd, 0x82, 0x34, 0xff, 0xd8, 0x4b, 0xcc, 0xf6, 0x5a, 0xff, 0x0, 0x10, 0x99, 0x2a, + 0x3e, 0x25, 0x51, 0x43, 0xb, 0x1e, 0xa, 0xb7, 0x20, 0x26, 0xcd, 0x26, 0x45, 0x6d}; + + uint8_t buf[88] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9, 0xde, 0x9f, 0x53, 0xa5, 0x9d, 0x2e, 0x4c, 0xbf, 0xdb, + 0x1a, 0xf9, 0x1d, 0x46, 0x40, 0xeb, 0xf1, 0x74, 0x5c, 0xd, + 0x82, 0x34, 0xff, 0xd8, 0x4b, 0xcc, 0xf6, 0x5a, 0xff}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x99, 0x2a, 0x3e, 0x25, 0x51, 0x43, 0xb, 0x1e, + 0xa, 0xb7, 0x20, 0x26, 0xcd, 0x26, 0x45, 0x6d}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 8661; + uint8_t client_id_bytes[] = {0xd5, 0xb7, 0x2a, 0x6c, 0xa1, 0x21, 0xa8, 0xfc, + 0x70, 0x99, 0xd0, 0xfe, 0x11, 0x3c, 0xeb}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS1, _willTopic = +// "\\\255\246\RS<\212+\220\248\199\236\132\185\US]D\137\186\&5\193\r\n\237\181\231\246\&6\238\211\221", _willMsg = +// "#%`lDh\222\147\201\155e\153\136\131 [9l\GS\225\NUL^", _willProps = []}), _cleanSession = True, _keepAlive = 1275, +// _connID = "^\232\215\163\208\190\139\233T\239\SI\139\vz6}", _properties = []} +TEST(Connect311QCTest, Encode18) { + uint8_t pkt[] = {0x10, 0x54, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2e, 0x4, 0xfb, 0x0, 0x10, 0x5e, + 0xe8, 0xd7, 0xa3, 0xd0, 0xbe, 0x8b, 0xe9, 0x54, 0xef, 0xf, 0x8b, 0xb, 0x7a, 0x36, 0x7d, + 0x0, 0x1e, 0x5c, 0xff, 0xf6, 0x1e, 0x3c, 0xd4, 0x2b, 0xdc, 0xf8, 0xc7, 0xec, 0x84, 0xb9, + 0x1f, 0x5d, 0x44, 0x89, 0xba, 0x35, 0xc1, 0xd, 0xa, 0xed, 0xb5, 0xe7, 0xf6, 0x36, 0xee, + 0xd3, 0xdd, 0x0, 0x16, 0x23, 0x25, 0x60, 0x6c, 0x44, 0x68, 0xde, 0x93, 0xc9, 0x9b, 0x65, + 0x99, 0x88, 0x83, 0x20, 0x5b, 0x39, 0x6c, 0x1d, 0xe1, 0x0, 0x5e}; + + uint8_t buf[96] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5c, 0xff, 0xf6, 0x1e, 0x3c, 0xd4, 0x2b, 0xdc, 0xf8, 0xc7, + 0xec, 0x84, 0xb9, 0x1f, 0x5d, 0x44, 0x89, 0xba, 0x35, 0xc1, + 0xd, 0xa, 0xed, 0xb5, 0xe7, 0xf6, 0x36, 0xee, 0xd3, 0xdd}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x23, 0x25, 0x60, 0x6c, 0x44, 0x68, 0xde, 0x93, 0xc9, 0x9b, 0x65, + 0x99, 0x88, 0x83, 0x20, 0x5b, 0x39, 0x6c, 0x1d, 0xe1, 0x0, 0x5e}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1275; + uint8_t client_id_bytes[] = {0x5e, 0xe8, 0xd7, 0xa3, 0xd0, 0xbe, 0x8b, 0xe9, + 0x54, 0xef, 0xf, 0x8b, 0xb, 0x7a, 0x36, 0x7d}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// "\212\226\154\ACK\136\237\149\159E\153\b\253\235\250\216\160\201\EM3P\152^\232", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS0, _willTopic = "\128\194\131j\171v\201pWuH\170{=\145O\211\DC3'", _willMsg = +// "\190\132\174 \"\169\179\253\204\&5T\243\160\140^\179\204\131\218H\"6\191lW\184\171d\161K", _willProps = []}), +// _cleanSession = True, _keepAlive = 30712, _connID = "6", _properties = []} +TEST(Connect311QCTest, Encode19) { + uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x77, 0xf8, 0x0, 0x1, + 0x36, 0x0, 0x13, 0x80, 0xc2, 0x83, 0x6a, 0xab, 0x76, 0xc9, 0x70, 0x57, 0x75, 0x48, + 0xaa, 0x7b, 0x3d, 0x91, 0x4f, 0xd3, 0x13, 0x27, 0x0, 0x1e, 0xbe, 0x84, 0xae, 0x20, + 0x22, 0xa9, 0xb3, 0xfd, 0xcc, 0x35, 0x54, 0xf3, 0xa0, 0x8c, 0x5e, 0xb3, 0xcc, 0x83, + 0xda, 0x48, 0x22, 0x36, 0xbf, 0x6c, 0x57, 0xb8, 0xab, 0x64, 0xa1, 0x4b}; + + uint8_t buf[78] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x80, 0xc2, 0x83, 0x6a, 0xab, 0x76, 0xc9, 0x70, 0x57, 0x75, + 0x48, 0xaa, 0x7b, 0x3d, 0x91, 0x4f, 0xd3, 0x13, 0x27}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xbe, 0x84, 0xae, 0x20, 0x22, 0xa9, 0xb3, 0xfd, 0xcc, 0x35, + 0x54, 0xf3, 0xa0, 0x8c, 0x5e, 0xb3, 0xcc, 0x83, 0xda, 0x48, + 0x22, 0x36, 0xbf, 0x6c, 0x57, 0xb8, 0xab, 0x64, 0xa1, 0x4b}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 30712; + uint8_t client_id_bytes[] = {0x36}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xd4, 0xe2, 0x9a, 0x6, 0x88, 0xed, 0x95, 0x9f, 0x45, 0x99, 0x8, 0xfd, + 0xeb, 0xfa, 0xd8, 0xa0, 0xc9, 0x19, 0x33, 0x50, 0x98, 0x5e, 0xe8}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "J\RSd\"\EOT.m'\DLE%\174\130S\229\172\198\176\&1\140&\228\RS\149\248\232\234", +// _password = Just "\216\183u\FS\184\187\239\148\140X\251\143\153s\176\218\&3s\168", _lastWill = Nothing, _cleanSession +// = True, _keepAlive = 24465, _connID = "\145\244\189\239z\131f", _properties = []} +TEST(Connect311QCTest, Encode20) { + uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x5f, 0x91, 0x0, 0x7, + 0x91, 0xf4, 0xbd, 0xef, 0x7a, 0x83, 0x66, 0x0, 0x1a, 0x4a, 0x1e, 0x64, 0x22, 0x4, + 0x2e, 0x6d, 0x27, 0x10, 0x25, 0xae, 0x82, 0x53, 0xe5, 0xac, 0xc6, 0xb0, 0x31, 0x8c, + 0x26, 0xe4, 0x1e, 0x95, 0xf8, 0xe8, 0xea, 0x0, 0x13, 0xd8, 0xb7, 0x75, 0x1c, 0xb8, + 0xbb, 0xef, 0x94, 0x8c, 0x58, 0xfb, 0x8f, 0x99, 0x73, 0xb0, 0xda, 0x33, 0x73, 0xa8}; + + uint8_t buf[80] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 24465; + uint8_t client_id_bytes[] = {0x91, 0xf4, 0xbd, 0xef, 0x7a, 0x83, 0x66}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x4a, 0x1e, 0x64, 0x22, 0x4, 0x2e, 0x6d, 0x27, 0x10, 0x25, 0xae, 0x82, 0x53, + 0xe5, 0xac, 0xc6, 0xb0, 0x31, 0x8c, 0x26, 0xe4, 0x1e, 0x95, 0xf8, 0xe8, 0xea}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xd8, 0xb7, 0x75, 0x1c, 0xb8, 0xbb, 0xef, 0x94, 0x8c, 0x58, + 0xfb, 0x8f, 0x99, 0x73, 0xb0, 0xda, 0x33, 0x73, 0xa8}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\168\152\190:\152\"\217OGs\207_\233\129\248**\131N\190\167q;\253\ETB", _password = +// Just "hq\130\190\144\NUL\227\253\208\215\224\167\FS\203\EOT(\169\158\166\134)g\184\233\145\138*u", _lastWill = +// Nothing, _cleanSession = True, _keepAlive = 147, _connID = "\198@\194\222\146s", _properties = []} +TEST(Connect311QCTest, Encode21) { + uint8_t pkt[] = {0x10, 0x4b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x0, 0x93, 0x0, 0x6, 0xc6, 0x40, + 0xc2, 0xde, 0x92, 0x73, 0x0, 0x19, 0xa8, 0x98, 0xbe, 0x3a, 0x98, 0x22, 0xd9, 0x4f, 0x47, 0x73, + 0xcf, 0x5f, 0xe9, 0x81, 0xf8, 0x2a, 0x2a, 0x83, 0x4e, 0xbe, 0xa7, 0x71, 0x3b, 0xfd, 0x17, 0x0, + 0x1c, 0x68, 0x71, 0x82, 0xbe, 0x90, 0x0, 0xe3, 0xfd, 0xd0, 0xd7, 0xe0, 0xa7, 0x1c, 0xcb, 0x4, + 0x28, 0xa9, 0x9e, 0xa6, 0x86, 0x29, 0x67, 0xb8, 0xe9, 0x91, 0x8a, 0x2a, 0x75}; + + uint8_t buf[87] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 147; + uint8_t client_id_bytes[] = {0xc6, 0x40, 0xc2, 0xde, 0x92, 0x73}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa8, 0x98, 0xbe, 0x3a, 0x98, 0x22, 0xd9, 0x4f, 0x47, 0x73, 0xcf, 0x5f, 0xe9, + 0x81, 0xf8, 0x2a, 0x2a, 0x83, 0x4e, 0xbe, 0xa7, 0x71, 0x3b, 0xfd, 0x17}; + lwmqtt_string_t username = {25, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x68, 0x71, 0x82, 0xbe, 0x90, 0x0, 0xe3, 0xfd, 0xd0, 0xd7, 0xe0, 0xa7, 0x1c, 0xcb, + 0x4, 0x28, 0xa9, 0x9e, 0xa6, 0x86, 0x29, 0x67, 0xb8, 0xe9, 0x91, 0x8a, 0x2a, 0x75}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "9?\213\ESC\211\DLE", _lastWill = Nothing, _cleanSession = +// False, _keepAlive = 13768, _connID = +// "x\172\tI\199\244\238\243\130\&9.\206\172\ETB\SYN\164\GS\EM\128\142S\217\184\NAK]Q\209;\SUBN", _properties = []} +TEST(Connect311QCTest, Encode22) { + uint8_t pkt[] = {0x10, 0x2a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x35, 0xc8, 0x0, 0x1e, 0x78, + 0xac, 0x9, 0x49, 0xc7, 0xf4, 0xee, 0xf3, 0x82, 0x39, 0x2e, 0xce, 0xac, 0x17, 0x16, 0xa4, + 0x1d, 0x19, 0x80, 0x8e, 0x53, 0xd9, 0xb8, 0x15, 0x5d, 0x51, 0xd1, 0x3b, 0x1a, 0x4e}; + + uint8_t buf[54] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 13768; + uint8_t client_id_bytes[] = {0x78, 0xac, 0x9, 0x49, 0xc7, 0xf4, 0xee, 0xf3, 0x82, 0x39, + 0x2e, 0xce, 0xac, 0x17, 0x16, 0xa4, 0x1d, 0x19, 0x80, 0x8e, + 0x53, 0xd9, 0xb8, 0x15, 0x5d, 0x51, 0xd1, 0x3b, 0x1a, 0x4e}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x39, 0x3f, 0xd5, 0x1b, 0xd3, 0x10}; + lwmqtt_string_t password = {6, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// ";\152\206s\182\199\197\227\135\ACK\251\"Z\DLE\203\162ab\203\169\203\208\172\230\&6\EOT8eS`", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "", _willMsg = "\157\160\156\193A", _willProps = []}), +// _cleanSession = False, _keepAlive = 23561, _connID = "\228\240", _properties = []} +TEST(Connect311QCTest, Encode23) { + uint8_t pkt[] = {0x10, 0x17, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2c, 0x5c, 0x9, 0x0, + 0x2, 0xe4, 0xf0, 0x0, 0x0, 0x0, 0x5, 0x9d, 0xa0, 0x9c, 0xc1, 0x41}; + + uint8_t buf[35] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x9d, 0xa0, 0x9c, 0xc1, 0x41}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 23561; + uint8_t client_id_bytes[] = {0xe4, 0xf0}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x3b, 0x98, 0xce, 0x73, 0xb6, 0xc7, 0xc5, 0xe3, 0x87, 0x6, 0xfb, 0x22, 0x5a, 0x10, 0xcb, + 0xa2, 0x61, 0x62, 0xcb, 0xa9, 0xcb, 0xd0, 0xac, 0xe6, 0x36, 0x4, 0x38, 0x65, 0x53, 0x60}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\254\245:\136]\202n\222\DC3n\218\215\210", _password = Just +// "6\234}\152\181\DC2\ACKM\245:\DC2\ENQ\249\205q+", _lastWill = Nothing, _cleanSession = True, _keepAlive = 2628, +// _connID = "\131/w\176\163", _properties = []} +TEST(Connect311QCTest, Encode24) { + uint8_t pkt[] = {0x10, 0x32, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0xa, 0x44, 0x0, + 0x5, 0x83, 0x2f, 0x77, 0xb0, 0xa3, 0x0, 0xd, 0xfe, 0xf5, 0x3a, 0x88, 0x5d, + 0xca, 0x6e, 0xde, 0x13, 0x6e, 0xda, 0xd7, 0xd2, 0x0, 0x10, 0x36, 0xea, 0x7d, + 0x98, 0xb5, 0x12, 0x6, 0x4d, 0xf5, 0x3a, 0x12, 0x5, 0xf9, 0xcd, 0x71, 0x2b}; + + uint8_t buf[62] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 2628; + uint8_t client_id_bytes[] = {0x83, 0x2f, 0x77, 0xb0, 0xa3}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xfe, 0xf5, 0x3a, 0x88, 0x5d, 0xca, 0x6e, 0xde, 0x13, 0x6e, 0xda, 0xd7, 0xd2}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x36, 0xea, 0x7d, 0x98, 0xb5, 0x12, 0x6, 0x4d, + 0xf5, 0x3a, 0x12, 0x5, 0xf9, 0xcd, 0x71, 0x2b}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\155\217\NUL\219N>c\218$.jM\158\CAN\213\ENQA;\185\148\147T\180\244", _password = +// Just "\167\228\243\219\223\142\140\SUB-\206\&0\STXF\ACK\146\186V\DC1\167&Nk\SOH8\132", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 23808, _connID = +// "\240\217\175\155|O\226\&49\201\243L\176\239f\233\177`\130\154\221", _properties = []} +TEST(Connect311QCTest, Encode25) { + uint8_t pkt[] = {0x10, 0x56, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x5d, 0x0, 0x0, 0x15, 0xf0, + 0xd9, 0xaf, 0x9b, 0x7c, 0x4f, 0xe2, 0x34, 0x39, 0xc9, 0xf3, 0x4c, 0xb0, 0xef, 0x66, 0xe9, + 0xb1, 0x60, 0x82, 0x9a, 0xdd, 0x0, 0x18, 0x9b, 0xd9, 0x0, 0xdb, 0x4e, 0x3e, 0x63, 0xda, + 0x24, 0x2e, 0x6a, 0x4d, 0x9e, 0x18, 0xd5, 0x5, 0x41, 0x3b, 0xb9, 0x94, 0x93, 0x54, 0xb4, + 0xf4, 0x0, 0x19, 0xa7, 0xe4, 0xf3, 0xdb, 0xdf, 0x8e, 0x8c, 0x1a, 0x2d, 0xce, 0x30, 0x2, + 0x46, 0x6, 0x92, 0xba, 0x56, 0x11, 0xa7, 0x26, 0x4e, 0x6b, 0x1, 0x38, 0x84}; + + uint8_t buf[98] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 23808; + uint8_t client_id_bytes[] = {0xf0, 0xd9, 0xaf, 0x9b, 0x7c, 0x4f, 0xe2, 0x34, 0x39, 0xc9, 0xf3, + 0x4c, 0xb0, 0xef, 0x66, 0xe9, 0xb1, 0x60, 0x82, 0x9a, 0xdd}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x9b, 0xd9, 0x0, 0xdb, 0x4e, 0x3e, 0x63, 0xda, 0x24, 0x2e, 0x6a, 0x4d, + 0x9e, 0x18, 0xd5, 0x5, 0x41, 0x3b, 0xb9, 0x94, 0x93, 0x54, 0xb4, 0xf4}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xa7, 0xe4, 0xf3, 0xdb, 0xdf, 0x8e, 0x8c, 0x1a, 0x2d, 0xce, 0x30, 0x2, 0x46, + 0x6, 0x92, 0xba, 0x56, 0x11, 0xa7, 0x26, 0x4e, 0x6b, 0x1, 0x38, 0x84}; + lwmqtt_string_t password = {25, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\147\ENQI\173\FS\139y\171U\167\&2\200\241\231_S\207A\193.'\DC3-\t", _password = +// Just "\224M\229\196\155\f", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "4g\167(\247", _willMsg = "e\SYNy\187{\214", _willProps = []}), _cleanSession = False, _keepAlive = 32591, _connID = +// "5\226G\145\159\238\225\NAK\DC2\SUB\RSc\ENQ\ACKr\238+\128\191\218\DC2\230\143X", _properties = []} +TEST(Connect311QCTest, Encode26) { + uint8_t pkt[] = {0x10, 0x55, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x7f, 0x4f, 0x0, 0x18, 0x35, + 0xe2, 0x47, 0x91, 0x9f, 0xee, 0xe1, 0x15, 0x12, 0x1a, 0x1e, 0x63, 0x5, 0x6, 0x72, 0xee, + 0x2b, 0x80, 0xbf, 0xda, 0x12, 0xe6, 0x8f, 0x58, 0x0, 0x5, 0x34, 0x67, 0xa7, 0x28, 0xf7, + 0x0, 0x6, 0x65, 0x16, 0x79, 0xbb, 0x7b, 0xd6, 0x0, 0x18, 0x93, 0x5, 0x49, 0xad, 0x1c, + 0x8b, 0x79, 0xab, 0x55, 0xa7, 0x32, 0xc8, 0xf1, 0xe7, 0x5f, 0x53, 0xcf, 0x41, 0xc1, 0x2e, + 0x27, 0x13, 0x2d, 0x9, 0x0, 0x6, 0xe0, 0x4d, 0xe5, 0xc4, 0x9b, 0xc}; + + uint8_t buf[97] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x34, 0x67, 0xa7, 0x28, 0xf7}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x65, 0x16, 0x79, 0xbb, 0x7b, 0xd6}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32591; + uint8_t client_id_bytes[] = {0x35, 0xe2, 0x47, 0x91, 0x9f, 0xee, 0xe1, 0x15, 0x12, 0x1a, 0x1e, 0x63, + 0x5, 0x6, 0x72, 0xee, 0x2b, 0x80, 0xbf, 0xda, 0x12, 0xe6, 0x8f, 0x58}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x93, 0x5, 0x49, 0xad, 0x1c, 0x8b, 0x79, 0xab, 0x55, 0xa7, 0x32, 0xc8, + 0xf1, 0xe7, 0x5f, 0x53, 0xcf, 0x41, 0xc1, 0x2e, 0x27, 0x13, 0x2d, 0x9}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xe0, 0x4d, 0xe5, 0xc4, 0x9b, 0xc}; + lwmqtt_string_t password = {6, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\135n\ACK\DEL\252\NAKj", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "\227\242\SOH2\209\GS\241P\197$1", _willMsg = +// "\203\232{\205\152\239\158\DEL\251r\EOTy\\e\148\159p\ETX8Kg", _willProps = []}), _cleanSession = True, _keepAlive = +// 27175, _connID = "\CAN\SYN\222\163\&6J<\227\240.\181\138\158\223b_\ETB\234\SYN\232\223", _properties = []} +TEST(Connect311QCTest, Encode27) { + uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x86, 0x6a, 0x27, 0x0, 0x15, 0x18, 0x16, + 0xde, 0xa3, 0x36, 0x4a, 0x3c, 0xe3, 0xf0, 0x2e, 0xb5, 0x8a, 0x9e, 0xdf, 0x62, 0x5f, 0x17, 0xea, + 0x16, 0xe8, 0xdf, 0x0, 0xb, 0xe3, 0xf2, 0x1, 0x32, 0xd1, 0x1d, 0xf1, 0x50, 0xc5, 0x24, 0x31, + 0x0, 0x15, 0xcb, 0xe8, 0x7b, 0xcd, 0x98, 0xef, 0x9e, 0x7f, 0xfb, 0x72, 0x4, 0x79, 0x5c, 0x65, + 0x94, 0x9f, 0x70, 0x3, 0x38, 0x4b, 0x67, 0x0, 0x7, 0x87, 0x6e, 0x6, 0x7f, 0xfc, 0x15, 0x6a}; + + uint8_t buf[90] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe3, 0xf2, 0x1, 0x32, 0xd1, 0x1d, 0xf1, 0x50, 0xc5, 0x24, 0x31}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xcb, 0xe8, 0x7b, 0xcd, 0x98, 0xef, 0x9e, 0x7f, 0xfb, 0x72, 0x4, + 0x79, 0x5c, 0x65, 0x94, 0x9f, 0x70, 0x3, 0x38, 0x4b, 0x67}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 27175; + uint8_t client_id_bytes[] = {0x18, 0x16, 0xde, 0xa3, 0x36, 0x4a, 0x3c, 0xe3, 0xf0, 0x2e, 0xb5, + 0x8a, 0x9e, 0xdf, 0x62, 0x5f, 0x17, 0xea, 0x16, 0xe8, 0xdf}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x87, 0x6e, 0x6, 0x7f, 0xfc, 0x15, 0x6a}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\206\232\167N\216a\154\199\224\218QM\240^\233", _password = Just +// "\192/:\231\250i\229m\149\209\226\189\247\RS", _lastWill = Nothing, _cleanSession = True, _keepAlive = 19539, _connID +// = "\243\a_w\224\230\220\172\186\STX\157\251\SUB\221\132\ACK1\230\148", _properties = []} +TEST(Connect311QCTest, Encode28) { + uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x4c, 0x53, 0x0, 0x13, 0xf3, 0x7, 0x5f, + 0x77, 0xe0, 0xe6, 0xdc, 0xac, 0xba, 0x2, 0x9d, 0xfb, 0x1a, 0xdd, 0x84, 0x6, 0x31, 0xe6, 0x94, 0x0, + 0xf, 0xce, 0xe8, 0xa7, 0x4e, 0xd8, 0x61, 0x9a, 0xc7, 0xe0, 0xda, 0x51, 0x4d, 0xf0, 0x5e, 0xe9, 0x0, + 0xe, 0xc0, 0x2f, 0x3a, 0xe7, 0xfa, 0x69, 0xe5, 0x6d, 0x95, 0xd1, 0xe2, 0xbd, 0xf7, 0x1e}; + + uint8_t buf[76] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 19539; + uint8_t client_id_bytes[] = {0xf3, 0x7, 0x5f, 0x77, 0xe0, 0xe6, 0xdc, 0xac, 0xba, 0x2, + 0x9d, 0xfb, 0x1a, 0xdd, 0x84, 0x6, 0x31, 0xe6, 0x94}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xce, 0xe8, 0xa7, 0x4e, 0xd8, 0x61, 0x9a, 0xc7, 0xe0, 0xda, 0x51, 0x4d, 0xf0, 0x5e, 0xe9}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xc0, 0x2f, 0x3a, 0xe7, 0xfa, 0x69, 0xe5, 0x6d, 0x95, 0xd1, 0xe2, 0xbd, 0xf7, 0x1e}; + lwmqtt_string_t password = {14, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "m\215\134\182\200\&4", _password = Just +// ">\213T\DC4\232\214\180e\168@Q\130\234\201\227#\248\153`\161\244\138\218\201/xr\DEL", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "k\208\247&\US\224\153\252\216", _willMsg = "\v\157\214H\186", +// _willProps = []}), _cleanSession = False, _keepAlive = 24596, _connID = "\198\140\ETX", _properties = []} +TEST(Connect311QCTest, Encode29) { + uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x60, 0x14, 0x0, 0x3, 0xc6, + 0x8c, 0x3, 0x0, 0x9, 0x6b, 0xd0, 0xf7, 0x26, 0x1f, 0xe0, 0x99, 0xfc, 0xd8, 0x0, 0x5, + 0xb, 0x9d, 0xd6, 0x48, 0xba, 0x0, 0x6, 0x6d, 0xd7, 0x86, 0xb6, 0xc8, 0x34, 0x0, 0x1c, + 0x3e, 0xd5, 0x54, 0x14, 0xe8, 0xd6, 0xb4, 0x65, 0xa8, 0x40, 0x51, 0x82, 0xea, 0xc9, 0xe3, + 0x23, 0xf8, 0x99, 0x60, 0xa1, 0xf4, 0x8a, 0xda, 0xc9, 0x2f, 0x78, 0x72, 0x7f}; + + uint8_t buf[83] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x6b, 0xd0, 0xf7, 0x26, 0x1f, 0xe0, 0x99, 0xfc, 0xd8}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb, 0x9d, 0xd6, 0x48, 0xba}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 24596; + uint8_t client_id_bytes[] = {0xc6, 0x8c, 0x3}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x6d, 0xd7, 0x86, 0xb6, 0xc8, 0x34}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x3e, 0xd5, 0x54, 0x14, 0xe8, 0xd6, 0xb4, 0x65, 0xa8, 0x40, 0x51, 0x82, 0xea, 0xc9, + 0xe3, 0x23, 0xf8, 0x99, 0x60, 0xa1, 0xf4, 0x8a, 0xda, 0xc9, 0x2f, 0x78, 0x72, 0x7f}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "e\ESCs", _password = Just "\183mF\183H", _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 16377, _connID = "Ky\SOj\t\188i\157\233_I\201\187\143\DELY\175_\140}\230\&5\206\SUBqb+P0", _properties = +// []} +TEST(Connect311QCTest, Encode30) { + uint8_t pkt[] = {0x10, 0x35, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x3f, 0xf9, 0x0, 0x1d, + 0x4b, 0x79, 0xe, 0x6a, 0x9, 0xbc, 0x69, 0x9d, 0xe9, 0x5f, 0x49, 0xc9, 0xbb, 0x8f, + 0x7f, 0x59, 0xaf, 0x5f, 0x8c, 0x7d, 0xe6, 0x35, 0xce, 0x1a, 0x71, 0x62, 0x2b, 0x50, + 0x30, 0x0, 0x3, 0x65, 0x1b, 0x73, 0x0, 0x5, 0xb7, 0x6d, 0x46, 0xb7, 0x48}; + + uint8_t buf[65] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 16377; + uint8_t client_id_bytes[] = {0x4b, 0x79, 0xe, 0x6a, 0x9, 0xbc, 0x69, 0x9d, 0xe9, 0x5f, 0x49, 0xc9, 0xbb, 0x8f, 0x7f, + 0x59, 0xaf, 0x5f, 0x8c, 0x7d, 0xe6, 0x35, 0xce, 0x1a, 0x71, 0x62, 0x2b, 0x50, 0x30}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x65, 0x1b, 0x73}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xb7, 0x6d, 0x46, 0xb7, 0x48}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\238zO", _password = Just +// "\183xW\149\225\255\ACK\160\227\147\208\185\174P\148l\216\&6B\183J\152", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS2, _willTopic = "\192G3\202\231\255\195\177\168\239\233\234\161\DC3\186Q\230\"\t\146\ACK", +// _willMsg = "\GS\230a\199\205<}", _willProps = []}), _cleanSession = True, _keepAlive = 18523, _connID = +// "\232\204\f\212 \185\241-\229\183\230\160\202i\225\DC1_2\224\152\198v[\219md\170", _properties = []} +TEST(Connect311QCTest, Encode31) { + uint8_t pkt[] = {0x10, 0x64, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x48, 0x5b, 0x0, 0x1b, 0xe8, + 0xcc, 0xc, 0xd4, 0x20, 0xb9, 0xf1, 0x2d, 0xe5, 0xb7, 0xe6, 0xa0, 0xca, 0x69, 0xe1, 0x11, + 0x5f, 0x32, 0xe0, 0x98, 0xc6, 0x76, 0x5b, 0xdb, 0x6d, 0x64, 0xaa, 0x0, 0x15, 0xc0, 0x47, + 0x33, 0xca, 0xe7, 0xff, 0xc3, 0xb1, 0xa8, 0xef, 0xe9, 0xea, 0xa1, 0x13, 0xba, 0x51, 0xe6, + 0x22, 0x9, 0x92, 0x6, 0x0, 0x7, 0x1d, 0xe6, 0x61, 0xc7, 0xcd, 0x3c, 0x7d, 0x0, 0x3, + 0xee, 0x7a, 0x4f, 0x0, 0x16, 0xb7, 0x78, 0x57, 0x95, 0xe1, 0xff, 0x6, 0xa0, 0xe3, 0x93, + 0xd0, 0xb9, 0xae, 0x50, 0x94, 0x6c, 0xd8, 0x36, 0x42, 0xb7, 0x4a, 0x98}; + + uint8_t buf[112] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc0, 0x47, 0x33, 0xca, 0xe7, 0xff, 0xc3, 0xb1, 0xa8, 0xef, 0xe9, + 0xea, 0xa1, 0x13, 0xba, 0x51, 0xe6, 0x22, 0x9, 0x92, 0x6}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1d, 0xe6, 0x61, 0xc7, 0xcd, 0x3c, 0x7d}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 18523; + uint8_t client_id_bytes[] = {0xe8, 0xcc, 0xc, 0xd4, 0x20, 0xb9, 0xf1, 0x2d, 0xe5, 0xb7, 0xe6, 0xa0, 0xca, 0x69, + 0xe1, 0x11, 0x5f, 0x32, 0xe0, 0x98, 0xc6, 0x76, 0x5b, 0xdb, 0x6d, 0x64, 0xaa}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xee, 0x7a, 0x4f}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xb7, 0x78, 0x57, 0x95, 0xe1, 0xff, 0x6, 0xa0, 0xe3, 0x93, 0xd0, + 0xb9, 0xae, 0x50, 0x94, 0x6c, 0xd8, 0x36, 0x42, 0xb7, 0x4a, 0x98}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Ae\200\161\175\235\ETX\154", _password = Just +// "\ESCm\NULa\222\180jD\243e\212[\t7\DC1\143\247~\DC4=\196NJ\FS<\201\150\171\151", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\FS;\251\141\v\199\239\NUL\196T{\DC3x?\154\217\156_", _willMsg = +// "_'9\US\219\b\147\&0\133+-\148\&7G\249\172\205[\147\208\DC3\ESCC", _willProps = []}), _cleanSession = False, +// _keepAlive = 11629, _connID = "\\X\222", _properties = []} +TEST(Connect311QCTest, Encode32) { + uint8_t pkt[] = {0x10, 0x65, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x2d, 0x6d, 0x0, 0x3, 0x5c, + 0x58, 0xde, 0x0, 0x12, 0x1c, 0x3b, 0xfb, 0x8d, 0xb, 0xc7, 0xef, 0x0, 0xc4, 0x54, 0x7b, + 0x13, 0x78, 0x3f, 0x9a, 0xd9, 0x9c, 0x5f, 0x0, 0x17, 0x5f, 0x27, 0x39, 0x1f, 0xdb, 0x8, + 0x93, 0x30, 0x85, 0x2b, 0x2d, 0x94, 0x37, 0x47, 0xf9, 0xac, 0xcd, 0x5b, 0x93, 0xd0, 0x13, + 0x1b, 0x43, 0x0, 0x8, 0x41, 0x65, 0xc8, 0xa1, 0xaf, 0xeb, 0x3, 0x9a, 0x0, 0x1d, 0x1b, + 0x6d, 0x0, 0x61, 0xde, 0xb4, 0x6a, 0x44, 0xf3, 0x65, 0xd4, 0x5b, 0x9, 0x37, 0x11, 0x8f, + 0xf7, 0x7e, 0x14, 0x3d, 0xc4, 0x4e, 0x4a, 0x1c, 0x3c, 0xc9, 0x96, 0xab, 0x97}; + + uint8_t buf[113] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1c, 0x3b, 0xfb, 0x8d, 0xb, 0xc7, 0xef, 0x0, 0xc4, + 0x54, 0x7b, 0x13, 0x78, 0x3f, 0x9a, 0xd9, 0x9c, 0x5f}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5f, 0x27, 0x39, 0x1f, 0xdb, 0x8, 0x93, 0x30, 0x85, 0x2b, 0x2d, 0x94, + 0x37, 0x47, 0xf9, 0xac, 0xcd, 0x5b, 0x93, 0xd0, 0x13, 0x1b, 0x43}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 11629; + uint8_t client_id_bytes[] = {0x5c, 0x58, 0xde}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x41, 0x65, 0xc8, 0xa1, 0xaf, 0xeb, 0x3, 0x9a}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x1b, 0x6d, 0x0, 0x61, 0xde, 0xb4, 0x6a, 0x44, 0xf3, 0x65, 0xd4, 0x5b, 0x9, 0x37, 0x11, + 0x8f, 0xf7, 0x7e, 0x14, 0x3d, 0xc4, 0x4e, 0x4a, 0x1c, 0x3c, 0xc9, 0x96, 0xab, 0x97}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\150\147\177\160\218r%'C\139\159\&6\178", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\158/9\141", _willMsg = +// "\189\DC4a\NUL\243\231@W\178\194\&7\212\\\150W\244\244\226Y=\164\138\228\154qi\129(\SOH}", _willProps = []}), +// _cleanSession = True, _keepAlive = 6008, _connID = "3\252\rE\195\SYNO^\160\182\243\US\166\254\183 +// \NAK\SUB\159\173\196\\\150\179D\245", _properties = []} +TEST(Connect311QCTest, Encode33) { + uint8_t pkt[] = {0x10, 0x4c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x17, 0x78, 0x0, 0x1a, 0x33, 0xfc, + 0xd, 0x45, 0xc3, 0x16, 0x4f, 0x5e, 0xa0, 0xb6, 0xf3, 0x1f, 0xa6, 0xfe, 0xb7, 0x20, 0x15, 0x1a, + 0x9f, 0xad, 0xc4, 0x5c, 0x96, 0xb3, 0x44, 0xf5, 0x0, 0x4, 0x9e, 0x2f, 0x39, 0x8d, 0x0, 0x1e, + 0xbd, 0x14, 0x61, 0x0, 0xf3, 0xe7, 0x40, 0x57, 0xb2, 0xc2, 0x37, 0xd4, 0x5c, 0x96, 0x57, 0xf4, + 0xf4, 0xe2, 0x59, 0x3d, 0xa4, 0x8a, 0xe4, 0x9a, 0x71, 0x69, 0x81, 0x28, 0x1, 0x7d}; + + uint8_t buf[88] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9e, 0x2f, 0x39, 0x8d}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xbd, 0x14, 0x61, 0x0, 0xf3, 0xe7, 0x40, 0x57, 0xb2, 0xc2, + 0x37, 0xd4, 0x5c, 0x96, 0x57, 0xf4, 0xf4, 0xe2, 0x59, 0x3d, + 0xa4, 0x8a, 0xe4, 0x9a, 0x71, 0x69, 0x81, 0x28, 0x1, 0x7d}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 6008; + uint8_t client_id_bytes[] = {0x33, 0xfc, 0xd, 0x45, 0xc3, 0x16, 0x4f, 0x5e, 0xa0, 0xb6, 0xf3, 0x1f, 0xa6, + 0xfe, 0xb7, 0x20, 0x15, 0x1a, 0x9f, 0xad, 0xc4, 0x5c, 0x96, 0xb3, 0x44, 0xf5}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x96, 0x93, 0xb1, 0xa0, 0xda, 0x72, 0x25, 0x27, 0x43, 0x8b, 0x9f, 0x36, 0xb2}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Y\v>5Bm\227", _password = Just "\138\203", _lastWill = Just (LastWill {_willRetain +// = False, _willQoS = QoS2, _willTopic = "\206v\171\156\146%.\249$W", _willMsg = "\bH\DC4H", _willProps = []}), +// _cleanSession = True, _keepAlive = 23415, _connID = +// "\204wCr\148\250tb\RS\139\204\142\r\206\180\231\DC26Cv\254+\STX\ETX\250\t", _properties = []} +TEST(Connect311QCTest, Encode34) { + uint8_t pkt[] = {0x10, 0x45, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x5b, 0x77, 0x0, 0x1a, 0xcc, + 0x77, 0x43, 0x72, 0x94, 0xfa, 0x74, 0x62, 0x1e, 0x8b, 0xcc, 0x8e, 0xd, 0xce, 0xb4, 0xe7, + 0x12, 0x36, 0x43, 0x76, 0xfe, 0x2b, 0x2, 0x3, 0xfa, 0x9, 0x0, 0xa, 0xce, 0x76, 0xab, + 0x9c, 0x92, 0x25, 0x2e, 0xf9, 0x24, 0x57, 0x0, 0x4, 0x8, 0x48, 0x14, 0x48, 0x0, 0x7, + 0x59, 0xb, 0x3e, 0x35, 0x42, 0x6d, 0xe3, 0x0, 0x2, 0x8a, 0xcb}; + + uint8_t buf[81] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xce, 0x76, 0xab, 0x9c, 0x92, 0x25, 0x2e, 0xf9, 0x24, 0x57}; + lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x8, 0x48, 0x14, 0x48}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23415; + uint8_t client_id_bytes[] = {0xcc, 0x77, 0x43, 0x72, 0x94, 0xfa, 0x74, 0x62, 0x1e, 0x8b, 0xcc, 0x8e, 0xd, + 0xce, 0xb4, 0xe7, 0x12, 0x36, 0x43, 0x76, 0xfe, 0x2b, 0x2, 0x3, 0xfa, 0x9}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x59, 0xb, 0x3e, 0x35, 0x42, 0x6d, 0xe3}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x8a, 0xcb}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "]\153\135\145US\141\240H\229\241g\ETX", _willMsg = "S\147\227\222\204\171\172K", _willProps = +// []}), _cleanSession = True, _keepAlive = 12605, _connID = "\213?\SO\227\212\225\234\193\164'\SYN0,6\152", _properties +// = []} +TEST(Connect311QCTest, Encode35) { + uint8_t pkt[] = {0x10, 0x34, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x31, 0x3d, 0x0, 0xf, + 0xd5, 0x3f, 0xe, 0xe3, 0xd4, 0xe1, 0xea, 0xc1, 0xa4, 0x27, 0x16, 0x30, 0x2c, 0x36, + 0x98, 0x0, 0xd, 0x5d, 0x99, 0x87, 0x91, 0x55, 0x53, 0x8d, 0xf0, 0x48, 0xe5, 0xf1, + 0x67, 0x3, 0x0, 0x8, 0x53, 0x93, 0xe3, 0xde, 0xcc, 0xab, 0xac, 0x4b}; + + uint8_t buf[64] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5d, 0x99, 0x87, 0x91, 0x55, 0x53, 0x8d, 0xf0, 0x48, 0xe5, 0xf1, 0x67, 0x3}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x53, 0x93, 0xe3, 0xde, 0xcc, 0xab, 0xac, 0x4b}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 12605; + uint8_t client_id_bytes[] = {0xd5, 0x3f, 0xe, 0xe3, 0xd4, 0xe1, 0xea, 0xc1, 0xa4, 0x27, 0x16, 0x30, 0x2c, 0x36, 0x98}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "&\ETX\DC1tJ\204\211Q`", _password = Just "\128c\191.\162\253\GS\162q\130\138\188Y", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\245\221o", _willMsg = +// "\235\SOH,nQ&\DC1bJ\DC4\177\178\194\181\239\243I\167\232\150\179|^\185\241\164Wv\211", _willProps = []}), +// _cleanSession = True, _keepAlive = 6922, _connID = "\132\211\DC4\175\183\DC4\ETB\170Y", _properties = []} +TEST(Connect311QCTest, Encode36) { + uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x1b, 0xa, 0x0, 0x9, 0x84, + 0xd3, 0x14, 0xaf, 0xb7, 0x14, 0x17, 0xaa, 0x59, 0x0, 0x3, 0xf5, 0xdd, 0x6f, 0x0, 0x1d, + 0xeb, 0x1, 0x2c, 0x6e, 0x51, 0x26, 0x11, 0x62, 0x4a, 0x14, 0xb1, 0xb2, 0xc2, 0xb5, 0xef, + 0xf3, 0x49, 0xa7, 0xe8, 0x96, 0xb3, 0x7c, 0x5e, 0xb9, 0xf1, 0xa4, 0x57, 0x76, 0xd3, 0x0, + 0x9, 0x26, 0x3, 0x11, 0x74, 0x4a, 0xcc, 0xd3, 0x51, 0x60, 0x0, 0xd, 0x80, 0x63, 0xbf, + 0x2e, 0xa2, 0xfd, 0x1d, 0xa2, 0x71, 0x82, 0x8a, 0xbc, 0x59}; + + uint8_t buf[95] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf5, 0xdd, 0x6f}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xeb, 0x1, 0x2c, 0x6e, 0x51, 0x26, 0x11, 0x62, 0x4a, 0x14, + 0xb1, 0xb2, 0xc2, 0xb5, 0xef, 0xf3, 0x49, 0xa7, 0xe8, 0x96, + 0xb3, 0x7c, 0x5e, 0xb9, 0xf1, 0xa4, 0x57, 0x76, 0xd3}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 6922; + uint8_t client_id_bytes[] = {0x84, 0xd3, 0x14, 0xaf, 0xb7, 0x14, 0x17, 0xaa, 0x59}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x26, 0x3, 0x11, 0x74, 0x4a, 0xcc, 0xd3, 0x51, 0x60}; + lwmqtt_string_t username = {9, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x80, 0x63, 0xbf, 0x2e, 0xa2, 0xfd, 0x1d, 0xa2, 0x71, 0x82, 0x8a, 0xbc, 0x59}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\169\"\142.S\145\159\133VvX<\209\161", _password = Nothing, _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\136Rv", _willMsg = +// "v\SUB58p+]s\v\SYN\DC3!\220\199\192'K\140d\n@\133\188\CAN\174\209\SYNK", _willProps = []}), _cleanSession = False, +// _keepAlive = 25116, _connID = "\SOR\"\166}\168\197\211\153\NAK\249\165\138\211", _properties = []} +TEST(Connect311QCTest, Encode37) { + uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x94, 0x62, 0x1c, 0x0, 0xe, 0xe, 0x52, + 0x22, 0xa6, 0x7d, 0xa8, 0xc5, 0xd3, 0x99, 0x15, 0xf9, 0xa5, 0x8a, 0xd3, 0x0, 0x3, 0x88, 0x52, + 0x76, 0x0, 0x1c, 0x76, 0x1a, 0x35, 0x38, 0x70, 0x2b, 0x5d, 0x73, 0xb, 0x16, 0x13, 0x21, 0xdc, + 0xc7, 0xc0, 0x27, 0x4b, 0x8c, 0x64, 0xa, 0x40, 0x85, 0xbc, 0x18, 0xae, 0xd1, 0x16, 0x4b, 0x0, + 0xe, 0xa9, 0x22, 0x8e, 0x2e, 0x53, 0x91, 0x9f, 0x85, 0x56, 0x76, 0x58, 0x3c, 0xd1, 0xa1}; + + uint8_t buf[89] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x88, 0x52, 0x76}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x76, 0x1a, 0x35, 0x38, 0x70, 0x2b, 0x5d, 0x73, 0xb, 0x16, 0x13, 0x21, 0xdc, 0xc7, + 0xc0, 0x27, 0x4b, 0x8c, 0x64, 0xa, 0x40, 0x85, 0xbc, 0x18, 0xae, 0xd1, 0x16, 0x4b}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 25116; + uint8_t client_id_bytes[] = {0xe, 0x52, 0x22, 0xa6, 0x7d, 0xa8, 0xc5, 0xd3, 0x99, 0x15, 0xf9, 0xa5, 0x8a, 0xd3}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa9, 0x22, 0x8e, 0x2e, 0x53, 0x91, 0x9f, 0x85, 0x56, 0x76, 0x58, 0x3c, 0xd1, 0xa1}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "j3`=\194\212\200O\134\155v\212", _password = Just "\SI\FS=Y\232J\158\196\230\170", +// _lastWill = Nothing, _cleanSession = True, _keepAlive = 1881, _connID = "c\207n(N\155H\154,\158u\205*\f\182\SO", +// _properties = []} +TEST(Connect311QCTest, Encode38) { + uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x7, 0x59, 0x0, 0x10, + 0x63, 0xcf, 0x6e, 0x28, 0x4e, 0x9b, 0x48, 0x9a, 0x2c, 0x9e, 0x75, 0xcd, 0x2a, 0xc, + 0xb6, 0xe, 0x0, 0xc, 0x6a, 0x33, 0x60, 0x3d, 0xc2, 0xd4, 0xc8, 0x4f, 0x86, 0x9b, + 0x76, 0xd4, 0x0, 0xa, 0xf, 0x1c, 0x3d, 0x59, 0xe8, 0x4a, 0x9e, 0xc4, 0xe6, 0xaa}; + + uint8_t buf[66] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1881; + uint8_t client_id_bytes[] = {0x63, 0xcf, 0x6e, 0x28, 0x4e, 0x9b, 0x48, 0x9a, + 0x2c, 0x9e, 0x75, 0xcd, 0x2a, 0xc, 0xb6, 0xe}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x6a, 0x33, 0x60, 0x3d, 0xc2, 0xd4, 0xc8, 0x4f, 0x86, 0x9b, 0x76, 0xd4}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf, 0x1c, 0x3d, 0x59, 0xe8, 0x4a, 0x9e, 0xc4, 0xe6, 0xaa}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\ETXp\147\149\&7", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS1, _willTopic = "\218G\228", _willMsg = +// "\133\141;\199\135\145\&1\NAK\215\162H\224\199q\ft\156F\STX\178\162\152\147f\SI\229\248", _willProps = []}), +// _cleanSession = False, _keepAlive = 3338, _connID = +// "\244\164\&6\SYN\146\249\SOHR|b\175e~\146x\233H\240C\208\249M\233v\234\194\203\189\230\222", _properties = []} +TEST(Connect311QCTest, Encode39) { + uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0xd, 0xa, 0x0, 0x1e, 0xf4, + 0xa4, 0x36, 0x16, 0x92, 0xf9, 0x1, 0x52, 0x7c, 0x62, 0xaf, 0x65, 0x7e, 0x92, 0x78, 0xe9, + 0x48, 0xf0, 0x43, 0xd0, 0xf9, 0x4d, 0xe9, 0x76, 0xea, 0xc2, 0xcb, 0xbd, 0xe6, 0xde, 0x0, + 0x3, 0xda, 0x47, 0xe4, 0x0, 0x1b, 0x85, 0x8d, 0x3b, 0xc7, 0x87, 0x91, 0x31, 0x15, 0xd7, + 0xa2, 0x48, 0xe0, 0xc7, 0x71, 0xc, 0x74, 0x9c, 0x46, 0x2, 0xb2, 0xa2, 0x98, 0x93, 0x66, + 0xf, 0xe5, 0xf8, 0x0, 0x5, 0x3, 0x70, 0x93, 0x95, 0x37}; + + uint8_t buf[95] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xda, 0x47, 0xe4}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x85, 0x8d, 0x3b, 0xc7, 0x87, 0x91, 0x31, 0x15, 0xd7, 0xa2, 0x48, 0xe0, 0xc7, 0x71, + 0xc, 0x74, 0x9c, 0x46, 0x2, 0xb2, 0xa2, 0x98, 0x93, 0x66, 0xf, 0xe5, 0xf8}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3338; + uint8_t client_id_bytes[] = {0xf4, 0xa4, 0x36, 0x16, 0x92, 0xf9, 0x1, 0x52, 0x7c, 0x62, + 0xaf, 0x65, 0x7e, 0x92, 0x78, 0xe9, 0x48, 0xf0, 0x43, 0xd0, + 0xf9, 0x4d, 0xe9, 0x76, 0xea, 0xc2, 0xcb, 0xbd, 0xe6, 0xde}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x3, 0x70, 0x93, 0x95, 0x37}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "%s%1", _password = Just "JZ\188v\194\151\206\232\FS8\227", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "<3\134\&3\210\ai\247\172", _willMsg = +// "\195Z\ACK\163\170\202", _willProps = []}), _cleanSession = False, _keepAlive = 21786, _connID = +// "$\218\249\238\250,\NUL\129\DC2\162H\219_\168K\DC1\212\231\195p\167\157\177D\149", _properties = []} +TEST(Connect311QCTest, Encode40) { + uint8_t pkt[] = {0x10, 0x4b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x55, 0x1a, 0x0, 0x19, 0x24, 0xda, + 0xf9, 0xee, 0xfa, 0x2c, 0x0, 0x81, 0x12, 0xa2, 0x48, 0xdb, 0x5f, 0xa8, 0x4b, 0x11, 0xd4, 0xe7, + 0xc3, 0x70, 0xa7, 0x9d, 0xb1, 0x44, 0x95, 0x0, 0x9, 0x3c, 0x33, 0x86, 0x33, 0xd2, 0x7, 0x69, + 0xf7, 0xac, 0x0, 0x6, 0xc3, 0x5a, 0x6, 0xa3, 0xaa, 0xca, 0x0, 0x4, 0x25, 0x73, 0x25, 0x31, + 0x0, 0xb, 0x4a, 0x5a, 0xbc, 0x76, 0xc2, 0x97, 0xce, 0xe8, 0x1c, 0x38, 0xe3}; + + uint8_t buf[87] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x3c, 0x33, 0x86, 0x33, 0xd2, 0x7, 0x69, 0xf7, 0xac}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc3, 0x5a, 0x6, 0xa3, 0xaa, 0xca}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 21786; + uint8_t client_id_bytes[] = {0x24, 0xda, 0xf9, 0xee, 0xfa, 0x2c, 0x0, 0x81, 0x12, 0xa2, 0x48, 0xdb, 0x5f, + 0xa8, 0x4b, 0x11, 0xd4, 0xe7, 0xc3, 0x70, 0xa7, 0x9d, 0xb1, 0x44, 0x95}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x25, 0x73, 0x25, 0x31}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x4a, 0x5a, 0xbc, 0x76, 0xc2, 0x97, 0xce, 0xe8, 0x1c, 0x38, 0xe3}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\"\192-\143\173\214\ETXL\182X\SOHQ", _password = Just +// "\210\SI4\163\NUL>\DC1}2x\SOHq\134\ETX\245\&0\169\180", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS1, _willTopic = "\227\NAK\133\240\173\&0\r", _willMsg = "\197 \US\DEL\147\243\248\SI9\198\187\\\219\146\152\229\214\233", _lastWill = +// Nothing, _cleanSession = False, _keepAlive = 30703, _connID = "3\193)\173", _properties = []} +TEST(Connect311QCTest, Encode45) { + uint8_t pkt[] = {0x10, 0x10, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, + 0x0, 0x77, 0xef, 0x0, 0x4, 0x33, 0xc1, 0x29, 0xad}; + + uint8_t buf[28] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 30703; + uint8_t client_id_bytes[] = {0x33, 0xc1, 0x29, 0xad}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x25, 0xcc, 0xb9, 0x33, 0x17, 0x26, 0xae, 0xa3, 0xc, 0xc3, 0x25, 0xcd, 0x33, 0x5b, 0x3e, + 0x7f, 0x93, 0xf3, 0xf8, 0xf, 0x39, 0xc6, 0xbb, 0x5c, 0xdb, 0x92, 0x98, 0xe5, 0xd6, 0xe9}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "]\193c\STX\r\223\249r\ETXZ\v\aN1\DEL\172q\RS\210\169\176i\147\FS\191\181\200Vk%", +// _password = Just "\150\212\ESC\162~(\188%\191\133\243l", _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 9661, _connID = "l\v\146\230\194\DC4X\149\219\171 \169y\188\176\&4\144O", _properties = []} +TEST(Connect311QCTest, Encode46) { + uint8_t pkt[] = {0x10, 0x4c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x25, 0xbd, 0x0, 0x12, 0x6c, 0xb, + 0x92, 0xe6, 0xc2, 0x14, 0x58, 0x95, 0xdb, 0xab, 0x20, 0xa9, 0x79, 0xbc, 0xb0, 0x34, 0x90, 0x4f, + 0x0, 0x1e, 0x5d, 0xc1, 0x63, 0x2, 0xd, 0xdf, 0xf9, 0x72, 0x3, 0x5a, 0xb, 0x7, 0x4e, 0x31, + 0x7f, 0xac, 0x71, 0x1e, 0xd2, 0xa9, 0xb0, 0x69, 0x93, 0x1c, 0xbf, 0xb5, 0xc8, 0x56, 0x6b, 0x25, + 0x0, 0xc, 0x96, 0xd4, 0x1b, 0xa2, 0x7e, 0x28, 0xbc, 0x25, 0xbf, 0x85, 0xf3, 0x6c}; + + uint8_t buf[88] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 9661; + uint8_t client_id_bytes[] = {0x6c, 0xb, 0x92, 0xe6, 0xc2, 0x14, 0x58, 0x95, 0xdb, + 0xab, 0x20, 0xa9, 0x79, 0xbc, 0xb0, 0x34, 0x90, 0x4f}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x5d, 0xc1, 0x63, 0x2, 0xd, 0xdf, 0xf9, 0x72, 0x3, 0x5a, 0xb, 0x7, 0x4e, 0x31, 0x7f, + 0xac, 0x71, 0x1e, 0xd2, 0xa9, 0xb0, 0x69, 0x93, 0x1c, 0xbf, 0xb5, 0xc8, 0x56, 0x6b, 0x25}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x96, 0xd4, 0x1b, 0xa2, 0x7e, 0x28, 0xbc, 0x25, 0xbf, 0x85, 0xf3, 0x6c}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "HK\160A\236!\215\217", _password = Just "\172", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = "_#", _willMsg = "}\199!\254\224\b\154\&2\232\184\163\213?\186", +// _willProps = []}), _cleanSession = True, _keepAlive = 8375, _connID = "{iE\207H\USn\DLE\193\b\245\216JK", _properties +// = []} +TEST(Connect311QCTest, Encode47) { + uint8_t pkt[] = {0x10, 0x3b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x20, 0xb7, 0x0, 0xe, 0x7b, 0x69, + 0x45, 0xcf, 0x48, 0x1f, 0x6e, 0x10, 0xc1, 0x8, 0xf5, 0xd8, 0x4a, 0x4b, 0x0, 0x2, 0x5f, 0x23, + 0x0, 0xe, 0x7d, 0xc7, 0x21, 0xfe, 0xe0, 0x8, 0x9a, 0x32, 0xe8, 0xb8, 0xa3, 0xd5, 0x3f, 0xba, + 0x0, 0x8, 0x48, 0x4b, 0xa0, 0x41, 0xec, 0x21, 0xd7, 0xd9, 0x0, 0x1, 0xac}; + + uint8_t buf[71] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5f, 0x23}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7d, 0xc7, 0x21, 0xfe, 0xe0, 0x8, 0x9a, 0x32, 0xe8, 0xb8, 0xa3, 0xd5, 0x3f, 0xba}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 8375; + uint8_t client_id_bytes[] = {0x7b, 0x69, 0x45, 0xcf, 0x48, 0x1f, 0x6e, 0x10, 0xc1, 0x8, 0xf5, 0xd8, 0x4a, 0x4b}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x48, 0x4b, 0xa0, 0x41, 0xec, 0x21, 0xd7, 0xd9}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xac}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "s\249\NAK\192\197\&1\198#\180\SOH2\136\150\183B\199\209W@\DC3a\DLE\246\148\187\246\"", _password = Just +// "\224\236\147\252C\148\166\DEL\185\157\241m\242\132\SO\\q", _lastWill = Just (LastWill {_willRetain = True, _willQoS +// = QoS1, _willTopic = "\tqP", _willMsg = "o\SO.\159", _willProps = []}), _cleanSession = False, _keepAlive = 1422, +// _connID = "\184\233(\195\247\\\DC28i\FSj\135", _properties = []} +TEST(Connect311QCTest, Encode48) { + uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x5, 0x8e, 0x0, 0xc, 0xb8, + 0xe9, 0x28, 0xc3, 0xf7, 0x5c, 0x12, 0x38, 0x69, 0x1c, 0x6a, 0x87, 0x0, 0x3, 0x9, 0x71, + 0x50, 0x0, 0x4, 0x6f, 0xe, 0x2e, 0x9f, 0x0, 0x1b, 0x73, 0xf9, 0x15, 0xc0, 0xc5, 0x31, + 0xc6, 0x23, 0xb4, 0x1, 0x32, 0x88, 0x96, 0xb7, 0x42, 0xc7, 0xd1, 0x57, 0x40, 0x13, 0x61, + 0x10, 0xf6, 0x94, 0xbb, 0xf6, 0x22, 0x0, 0x11, 0xe0, 0xec, 0x93, 0xfc, 0x43, 0x94, 0xa6, + 0x7f, 0xb9, 0x9d, 0xf1, 0x6d, 0xf2, 0x84, 0xe, 0x5c, 0x71}; + + uint8_t buf[95] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9, 0x71, 0x50}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6f, 0xe, 0x2e, 0x9f}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 1422; + uint8_t client_id_bytes[] = {0xb8, 0xe9, 0x28, 0xc3, 0xf7, 0x5c, 0x12, 0x38, 0x69, 0x1c, 0x6a, 0x87}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x73, 0xf9, 0x15, 0xc0, 0xc5, 0x31, 0xc6, 0x23, 0xb4, 0x1, 0x32, 0x88, 0x96, 0xb7, + 0x42, 0xc7, 0xd1, 0x57, 0x40, 0x13, 0x61, 0x10, 0xf6, 0x94, 0xbb, 0xf6, 0x22}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xe0, 0xec, 0x93, 0xfc, 0x43, 0x94, 0xa6, 0x7f, 0xb9, + 0x9d, 0xf1, 0x6d, 0xf2, 0x84, 0xe, 0x5c, 0x71}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\204\ESC-v\215\228\195+\251.F6\r\221\213nfx\221", _password = Just "\193\152", +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 20170, _connID = +// "9\b4\231\247\150H\ETB\GS\236t\185o\189\144\173\203P\207z\173", _properties = []} +TEST(Connect311QCTest, Encode49) { + uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x4e, 0xca, 0x0, 0x15, 0x39, + 0x8, 0x34, 0xe7, 0xf7, 0x96, 0x48, 0x17, 0x1d, 0xec, 0x74, 0xb9, 0x6f, 0xbd, 0x90, 0xad, + 0xcb, 0x50, 0xcf, 0x7a, 0xad, 0x0, 0x13, 0xcc, 0x1b, 0x2d, 0x76, 0xd7, 0xe4, 0xc3, 0x2b, + 0xfb, 0x2e, 0x46, 0x36, 0xd, 0xdd, 0xd5, 0x6e, 0x66, 0x78, 0xdd, 0x0, 0x2, 0xc1, 0x98}; + + uint8_t buf[70] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 20170; + uint8_t client_id_bytes[] = {0x39, 0x8, 0x34, 0xe7, 0xf7, 0x96, 0x48, 0x17, 0x1d, 0xec, 0x74, + 0xb9, 0x6f, 0xbd, 0x90, 0xad, 0xcb, 0x50, 0xcf, 0x7a, 0xad}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xcc, 0x1b, 0x2d, 0x76, 0xd7, 0xe4, 0xc3, 0x2b, 0xfb, 0x2e, + 0x46, 0x36, 0xd, 0xdd, 0xd5, 0x6e, 0x66, 0x78, 0xdd}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xc1, 0x98}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "t\239", _password = Just "\r%\148", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "\r\226_c,\248", _willMsg = "\151\168\141\183G\198", _willProps = []}), _cleanSession = +// False, _keepAlive = 29236, _connID = "\202\219", _properties = []} +TEST(Connect311QCTest, Encode50) { + uint8_t pkt[] = {0x10, 0x27, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x72, 0x34, 0x0, 0x2, + 0xca, 0xdb, 0x0, 0x6, 0xd, 0xe2, 0x5f, 0x63, 0x2c, 0xf8, 0x0, 0x6, 0x97, 0xa8, + 0x8d, 0xb7, 0x47, 0xc6, 0x0, 0x2, 0x74, 0xef, 0x0, 0x3, 0xd, 0x25, 0x94}; + + uint8_t buf[51] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd, 0xe2, 0x5f, 0x63, 0x2c, 0xf8}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x97, 0xa8, 0x8d, 0xb7, 0x47, 0xc6}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 29236; + uint8_t client_id_bytes[] = {0xca, 0xdb}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x74, 0xef}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xd, 0x25, 0x94}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\144:3}\185E\246k\210Hp\221\197\245\&6\148\135m\216\143p\136\185\STX\ENQ\186\149?", +// _password = Just "\DC3\NAK\168)\SUB\234>\CAN\168\155\253RB\142?\137D\181y\170\&3O!+", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = +// "\227\205\234\251\"J\133\178\154\154[\STX\135\DC4[\a@\245[e\SUBR1\234\201\192'\vam", _willMsg = "\CAN\230\GS", +// _willProps = []}), _cleanSession = False, _keepAlive = 542, _connID = +// ")\ESC\193I>\"[\SO\187G\\\182\199yj\DC4o\204\229yV\"n+\138u\223", _properties = []} +TEST(Connect311QCTest, Encode51) { + uint8_t pkt[] = {0x10, 0x84, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x2, 0x1e, 0x0, 0x1b, 0x29, 0x1b, + 0xc1, 0x49, 0x3e, 0x22, 0x5b, 0xe, 0xbb, 0x47, 0x5c, 0xb6, 0xc7, 0x79, 0x6a, 0x14, 0x6f, 0xcc, 0xe5, + 0x79, 0x56, 0x22, 0x6e, 0x2b, 0x8a, 0x75, 0xdf, 0x0, 0x1e, 0xe3, 0xcd, 0xea, 0xfb, 0x22, 0x4a, 0x85, + 0xb2, 0x9a, 0x9a, 0x5b, 0x2, 0x87, 0x14, 0x5b, 0x7, 0x40, 0xf5, 0x5b, 0x65, 0x1a, 0x52, 0x31, 0xea, + 0xc9, 0xc0, 0x27, 0xb, 0x61, 0x6d, 0x0, 0x3, 0x18, 0xe6, 0x1d, 0x0, 0x1c, 0x90, 0x3a, 0x33, 0x7d, + 0xb9, 0x45, 0xf6, 0x6b, 0xd2, 0x48, 0x70, 0xdd, 0xc5, 0xf5, 0x36, 0x94, 0x87, 0x6d, 0xd8, 0x8f, 0x70, + 0x88, 0xb9, 0x2, 0x5, 0xba, 0x95, 0x3f, 0x0, 0x18, 0x13, 0x15, 0xa8, 0x29, 0x1a, 0xea, 0x3e, 0x18, + 0xa8, 0x9b, 0xfd, 0x52, 0x42, 0x8e, 0x3f, 0x89, 0x44, 0xb5, 0x79, 0xaa, 0x33, 0x4f, 0x21, 0x2b}; + + uint8_t buf[145] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe3, 0xcd, 0xea, 0xfb, 0x22, 0x4a, 0x85, 0xb2, 0x9a, 0x9a, + 0x5b, 0x2, 0x87, 0x14, 0x5b, 0x7, 0x40, 0xf5, 0x5b, 0x65, + 0x1a, 0x52, 0x31, 0xea, 0xc9, 0xc0, 0x27, 0xb, 0x61, 0x6d}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x18, 0xe6, 0x1d}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 542; + uint8_t client_id_bytes[] = {0x29, 0x1b, 0xc1, 0x49, 0x3e, 0x22, 0x5b, 0xe, 0xbb, 0x47, 0x5c, 0xb6, 0xc7, 0x79, + 0x6a, 0x14, 0x6f, 0xcc, 0xe5, 0x79, 0x56, 0x22, 0x6e, 0x2b, 0x8a, 0x75, 0xdf}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x90, 0x3a, 0x33, 0x7d, 0xb9, 0x45, 0xf6, 0x6b, 0xd2, 0x48, 0x70, 0xdd, 0xc5, 0xf5, + 0x36, 0x94, 0x87, 0x6d, 0xd8, 0x8f, 0x70, 0x88, 0xb9, 0x2, 0x5, 0xba, 0x95, 0x3f}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x13, 0x15, 0xa8, 0x29, 0x1a, 0xea, 0x3e, 0x18, 0xa8, 0x9b, 0xfd, 0x52, + 0x42, 0x8e, 0x3f, 0x89, 0x44, 0xb5, 0x79, 0xaa, 0x33, 0x4f, 0x21, 0x2b}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "LW\149,C?\222\163x\147\176\166e\163!\187}@2\213\n", _password = Just +// "\166\&1Vn<\147O\v\178i\245g:\SUB", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "\243\244O\221\ETX\229\192\137;\183\197D/\221!m\211\162", _willMsg = +// "\239M(\237\209\235\215\"\SI\220v\217\205\n\228\156\205s\250\244\167K\185\SI-\ETB\SOq\r", _willProps = []}), +// _cleanSession = False, _keepAlive = 32428, _connID = +// "\SYN\217\207Z5\137\241\224\174\144\248\192*\233\218Z\230\DEL\198I9", _properties = []} +TEST(Connect311QCTest, Encode52) { + uint8_t pkt[] = {0x10, 0x7b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x7e, 0xac, 0x0, 0x15, 0x16, 0xd9, + 0xcf, 0x5a, 0x35, 0x89, 0xf1, 0xe0, 0xae, 0x90, 0xf8, 0xc0, 0x2a, 0xe9, 0xda, 0x5a, 0xe6, 0x7f, + 0xc6, 0x49, 0x39, 0x0, 0x12, 0xf3, 0xf4, 0x4f, 0xdd, 0x3, 0xe5, 0xc0, 0x89, 0x3b, 0xb7, 0xc5, + 0x44, 0x2f, 0xdd, 0x21, 0x6d, 0xd3, 0xa2, 0x0, 0x1d, 0xef, 0x4d, 0x28, 0xed, 0xd1, 0xeb, 0xd7, + 0x22, 0xf, 0xdc, 0x76, 0xd9, 0xcd, 0xa, 0xe4, 0x9c, 0xcd, 0x73, 0xfa, 0xf4, 0xa7, 0x4b, 0xb9, + 0xf, 0x2d, 0x17, 0xe, 0x71, 0xd, 0x0, 0x15, 0x4c, 0x57, 0x95, 0x2c, 0x43, 0x3f, 0xde, 0xa3, + 0x78, 0x93, 0xb0, 0xa6, 0x65, 0xa3, 0x21, 0xbb, 0x7d, 0x40, 0x32, 0xd5, 0xa, 0x0, 0xe, 0xa6, + 0x31, 0x56, 0x6e, 0x3c, 0x93, 0x4f, 0xb, 0xb2, 0x69, 0xf5, 0x67, 0x3a, 0x1a}; + + uint8_t buf[135] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf3, 0xf4, 0x4f, 0xdd, 0x3, 0xe5, 0xc0, 0x89, 0x3b, + 0xb7, 0xc5, 0x44, 0x2f, 0xdd, 0x21, 0x6d, 0xd3, 0xa2}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xef, 0x4d, 0x28, 0xed, 0xd1, 0xeb, 0xd7, 0x22, 0xf, 0xdc, + 0x76, 0xd9, 0xcd, 0xa, 0xe4, 0x9c, 0xcd, 0x73, 0xfa, 0xf4, + 0xa7, 0x4b, 0xb9, 0xf, 0x2d, 0x17, 0xe, 0x71, 0xd}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32428; + uint8_t client_id_bytes[] = {0x16, 0xd9, 0xcf, 0x5a, 0x35, 0x89, 0xf1, 0xe0, 0xae, 0x90, 0xf8, + 0xc0, 0x2a, 0xe9, 0xda, 0x5a, 0xe6, 0x7f, 0xc6, 0x49, 0x39}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x4c, 0x57, 0x95, 0x2c, 0x43, 0x3f, 0xde, 0xa3, 0x78, 0x93, 0xb0, + 0xa6, 0x65, 0xa3, 0x21, 0xbb, 0x7d, 0x40, 0x32, 0xd5, 0xa}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xa6, 0x31, 0x56, 0x6e, 0x3c, 0x93, 0x4f, 0xb, 0xb2, 0x69, 0xf5, 0x67, 0x3a, 0x1a}; + lwmqtt_string_t password = {14, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\230\206\252H\237\141\SIb\136w \172Y\159\155sC\141\159\"s\246{\DEL\254\208~\130", +// _password = Just "o\191Q<34\244\255\186\STXo\235,\210\v\SYN_\234\"x\219X\242\159.D\231", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\204\DC4\226:25\172", _willMsg = "\NAK\232\175\221\193,", +// _willProps = []}), _cleanSession = False, _keepAlive = 4766, _connID = +// "p\205\137>X(\171\175\246\NAKr\254\223H\232\252\254\236\198<", _properties = []} +TEST(Connect311QCTest, Encode53) { + uint8_t pkt[] = {0x10, 0x6c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x12, 0x9e, 0x0, 0x14, 0x70, 0xcd, + 0x89, 0x3e, 0x58, 0x28, 0xab, 0xaf, 0xf6, 0x15, 0x72, 0xfe, 0xdf, 0x48, 0xe8, 0xfc, 0xfe, 0xec, + 0xc6, 0x3c, 0x0, 0x7, 0xcc, 0x14, 0xe2, 0x3a, 0x32, 0x35, 0xac, 0x0, 0x6, 0x15, 0xe8, 0xaf, + 0xdd, 0xc1, 0x2c, 0x0, 0x1c, 0xe6, 0xce, 0xfc, 0x48, 0xed, 0x8d, 0xf, 0x62, 0x88, 0x77, 0x20, + 0xac, 0x59, 0x9f, 0x9b, 0x73, 0x43, 0x8d, 0x9f, 0x22, 0x73, 0xf6, 0x7b, 0x7f, 0xfe, 0xd0, 0x7e, + 0x82, 0x0, 0x1b, 0x6f, 0xbf, 0x51, 0x3c, 0x33, 0x34, 0xf4, 0xff, 0xba, 0x2, 0x6f, 0xeb, 0x2c, + 0xd2, 0xb, 0x16, 0x5f, 0xea, 0x22, 0x78, 0xdb, 0x58, 0xf2, 0x9f, 0x2e, 0x44, 0xe7}; + + uint8_t buf[120] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xcc, 0x14, 0xe2, 0x3a, 0x32, 0x35, 0xac}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x15, 0xe8, 0xaf, 0xdd, 0xc1, 0x2c}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 4766; + uint8_t client_id_bytes[] = {0x70, 0xcd, 0x89, 0x3e, 0x58, 0x28, 0xab, 0xaf, 0xf6, 0x15, + 0x72, 0xfe, 0xdf, 0x48, 0xe8, 0xfc, 0xfe, 0xec, 0xc6, 0x3c}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xe6, 0xce, 0xfc, 0x48, 0xed, 0x8d, 0xf, 0x62, 0x88, 0x77, 0x20, 0xac, 0x59, 0x9f, + 0x9b, 0x73, 0x43, 0x8d, 0x9f, 0x22, 0x73, 0xf6, 0x7b, 0x7f, 0xfe, 0xd0, 0x7e, 0x82}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x6f, 0xbf, 0x51, 0x3c, 0x33, 0x34, 0xf4, 0xff, 0xba, 0x2, 0x6f, 0xeb, 0x2c, 0xd2, + 0xb, 0x16, 0x5f, 0xea, 0x22, 0x78, 0xdb, 0x58, 0xf2, 0x9f, 0x2e, 0x44, 0xe7}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "<\n\149R0\\\216K\NAK\157\239\187b\243\172\NAKU", _lastWill = +// Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\n", _willMsg = +// "w9\217yM\186\161\166g\136\140\154\178\SYN5\150\228\212\FSHP\235\202\224\242D;", _willProps = []}), _cleanSession = +// False, _keepAlive = 6302, _connID = "5\175\175\181'H\173\161[\157\&8\175BY\182|\179", _properties = []} +TEST(Connect311QCTest, Encode54) { + uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x18, 0x9e, 0x0, 0x11, 0x35, 0xaf, + 0xaf, 0xb5, 0x27, 0x48, 0xad, 0xa1, 0x5b, 0x9d, 0x38, 0xaf, 0x42, 0x59, 0xb6, 0x7c, 0xb3, 0x0, + 0x1, 0xa, 0x0, 0x1b, 0x77, 0x39, 0xd9, 0x79, 0x4d, 0xba, 0xa1, 0xa6, 0x67, 0x88, 0x8c, 0x9a, + 0xb2, 0x16, 0x35, 0x96, 0xe4, 0xd4, 0x1c, 0x48, 0x50, 0xeb, 0xca, 0xe0, 0xf2, 0x44, 0x3b}; + + uint8_t buf[73] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x77, 0x39, 0xd9, 0x79, 0x4d, 0xba, 0xa1, 0xa6, 0x67, 0x88, 0x8c, 0x9a, 0xb2, 0x16, + 0x35, 0x96, 0xe4, 0xd4, 0x1c, 0x48, 0x50, 0xeb, 0xca, 0xe0, 0xf2, 0x44, 0x3b}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 6302; + uint8_t client_id_bytes[] = {0x35, 0xaf, 0xaf, 0xb5, 0x27, 0x48, 0xad, 0xa1, 0x5b, + 0x9d, 0x38, 0xaf, 0x42, 0x59, 0xb6, 0x7c, 0xb3}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x3c, 0xa, 0x95, 0x52, 0x30, 0x5c, 0xd8, 0x4b, 0x15, + 0x9d, 0xef, 0xbb, 0x62, 0xf3, 0xac, 0x15, 0x55}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "7x\204\136o\US\ESC\232\vI\211", _password = Just "m", _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 16891, _connID = "\152\237\162\129\182]", _properties = []} +TEST(Connect311QCTest, Encode55) { + uint8_t pkt[] = {0x10, 0x22, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x41, 0xfb, + 0x0, 0x6, 0x98, 0xed, 0xa2, 0x81, 0xb6, 0x5d, 0x0, 0xb, 0x37, 0x78, + 0xcc, 0x88, 0x6f, 0x1f, 0x1b, 0xe8, 0xb, 0x49, 0xd3, 0x0, 0x1, 0x6d}; + + uint8_t buf[46] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 16891; + uint8_t client_id_bytes[] = {0x98, 0xed, 0xa2, 0x81, 0xb6, 0x5d}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x37, 0x78, 0xcc, 0x88, 0x6f, 0x1f, 0x1b, 0xe8, 0xb, 0x49, 0xd3}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x6d}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\189J\246\DC4Ep\136e]\182\253\DEL\n\DC2\"\\\134&\162\252D\144", _password = +// Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 32242, _connID = +// "\218P?\172\167\243\&3_s\246\DC4\EOT\EM\139\169\186?", _properties = []} +TEST(Connect311QCTest, Encode56) { + uint8_t pkt[] = {0x10, 0x35, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x7d, 0xf2, 0x0, 0x11, + 0xda, 0x50, 0x3f, 0xac, 0xa7, 0xf3, 0x33, 0x5f, 0x73, 0xf6, 0x14, 0x4, 0x19, 0x8b, + 0xa9, 0xba, 0x3f, 0x0, 0x16, 0xbd, 0x4a, 0xf6, 0x14, 0x45, 0x70, 0x88, 0x65, 0x5d, + 0xb6, 0xfd, 0x7f, 0xa, 0x12, 0x22, 0x5c, 0x86, 0x26, 0xa2, 0xfc, 0x44, 0x90}; + + uint8_t buf[65] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32242; + uint8_t client_id_bytes[] = {0xda, 0x50, 0x3f, 0xac, 0xa7, 0xf3, 0x33, 0x5f, 0x73, + 0xf6, 0x14, 0x4, 0x19, 0x8b, 0xa9, 0xba, 0x3f}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xbd, 0x4a, 0xf6, 0x14, 0x45, 0x70, 0x88, 0x65, 0x5d, 0xb6, 0xfd, + 0x7f, 0xa, 0x12, 0x22, 0x5c, 0x86, 0x26, 0xa2, 0xfc, 0x44, 0x90}; + lwmqtt_string_t username = {22, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Au`\168A\188\232\r\137)\223\STX\199%\136", _password = Just +// "d\160\254\DEL\EOT\147\231-\152", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\199M\"\227Xv\NUL", _willMsg = "\201Z\208~\134\159\213", _willProps = []}), _cleanSession = True, _keepAlive = +// 16538, _connID = "\ENQ\184\173\135\NAK", _properties = []} +TEST(Connect311QCTest, Encode57) { + uint8_t pkt[] = {0x10, 0x3f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x40, 0x9a, 0x0, 0x5, 0x5, 0xb8, 0xad, + 0x87, 0x15, 0x0, 0x7, 0xc7, 0x4d, 0x22, 0xe3, 0x58, 0x76, 0x0, 0x0, 0x7, 0xc9, 0x5a, 0xd0, 0x7e, + 0x86, 0x9f, 0xd5, 0x0, 0xf, 0x41, 0x75, 0x60, 0xa8, 0x41, 0xbc, 0xe8, 0xd, 0x89, 0x29, 0xdf, 0x2, + 0xc7, 0x25, 0x88, 0x0, 0x9, 0x64, 0xa0, 0xfe, 0x7f, 0x4, 0x93, 0xe7, 0x2d, 0x98}; + + uint8_t buf[75] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc7, 0x4d, 0x22, 0xe3, 0x58, 0x76, 0x0}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc9, 0x5a, 0xd0, 0x7e, 0x86, 0x9f, 0xd5}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 16538; + uint8_t client_id_bytes[] = {0x5, 0xb8, 0xad, 0x87, 0x15}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x41, 0x75, 0x60, 0xa8, 0x41, 0xbc, 0xe8, 0xd, 0x89, 0x29, 0xdf, 0x2, 0xc7, 0x25, 0x88}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x64, 0xa0, 0xfe, 0x7f, 0x4, 0x93, 0xe7, 0x2d, 0x98}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "I", _password = Just +// "\187\133u\SYN\172\178^\135<\224\244\171\211k\255\158\148\EOT\255\STX1\SI\184", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = +// "s\241\244i\ETX6\STXo?H<\137\172\RS\203\US\236\ESC\214\218\&9\SIg.", _willMsg = +// "\242en\210E\149\254\131\167\&8\178\242\SOH@#)\215\245\175\160\206e\EMy", _willProps = []}), _cleanSession = True, +// _keepAlive = 29587, _connID = "\192\178\157\213%\235i\USou\STX\245\201\145\\>J", _properties = []} +TEST(Connect311QCTest, Encode58) { + uint8_t pkt[] = {0x10, 0x6d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x73, 0x93, 0x0, 0x11, 0xc0, 0xb2, + 0x9d, 0xd5, 0x25, 0xeb, 0x69, 0x1f, 0x6f, 0x75, 0x2, 0xf5, 0xc9, 0x91, 0x5c, 0x3e, 0x4a, 0x0, + 0x18, 0x73, 0xf1, 0xf4, 0x69, 0x3, 0x36, 0x2, 0x6f, 0x3f, 0x48, 0x3c, 0x89, 0xac, 0x1e, 0xcb, + 0x1f, 0xec, 0x1b, 0xd6, 0xda, 0x39, 0xf, 0x67, 0x2e, 0x0, 0x18, 0xf2, 0x65, 0x6e, 0xd2, 0x45, + 0x95, 0xfe, 0x83, 0xa7, 0x38, 0xb2, 0xf2, 0x1, 0x40, 0x23, 0x29, 0xd7, 0xf5, 0xaf, 0xa0, 0xce, + 0x65, 0x19, 0x79, 0x0, 0x1, 0x49, 0x0, 0x17, 0xbb, 0x85, 0x75, 0x16, 0xac, 0xb2, 0x5e, 0x87, + 0x3c, 0xe0, 0xf4, 0xab, 0xd3, 0x6b, 0xff, 0x9e, 0x94, 0x4, 0xff, 0x2, 0x31, 0xf, 0xb8}; + + uint8_t buf[121] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x73, 0xf1, 0xf4, 0x69, 0x3, 0x36, 0x2, 0x6f, 0x3f, 0x48, 0x3c, 0x89, + 0xac, 0x1e, 0xcb, 0x1f, 0xec, 0x1b, 0xd6, 0xda, 0x39, 0xf, 0x67, 0x2e}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf2, 0x65, 0x6e, 0xd2, 0x45, 0x95, 0xfe, 0x83, 0xa7, 0x38, 0xb2, 0xf2, + 0x1, 0x40, 0x23, 0x29, 0xd7, 0xf5, 0xaf, 0xa0, 0xce, 0x65, 0x19, 0x79}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 29587; + uint8_t client_id_bytes[] = {0xc0, 0xb2, 0x9d, 0xd5, 0x25, 0xeb, 0x69, 0x1f, 0x6f, + 0x75, 0x2, 0xf5, 0xc9, 0x91, 0x5c, 0x3e, 0x4a}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x49}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xbb, 0x85, 0x75, 0x16, 0xac, 0xb2, 0x5e, 0x87, 0x3c, 0xe0, 0xf4, 0xab, + 0xd3, 0x6b, 0xff, 0x9e, 0x94, 0x4, 0xff, 0x2, 0x31, 0xf, 0xb8}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = +// 12978, _connID = "\160X\221W2^\230o\163\&7\179s\156", _properties = []} +TEST(Connect311QCTest, Encode59) { + uint8_t pkt[] = {0x10, 0x19, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x32, 0xb2, 0x0, 0xd, + 0xa0, 0x58, 0xdd, 0x57, 0x32, 0x5e, 0xe6, 0x6f, 0xa3, 0x37, 0xb3, 0x73, 0x9c}; + + uint8_t buf[37] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 12978; + uint8_t client_id_bytes[] = {0xa0, 0x58, 0xdd, 0x57, 0x32, 0x5e, 0xe6, 0x6f, 0xa3, 0x37, 0xb3, 0x73, 0x9c}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "^\134", _lastWill = Nothing, _cleanSession = False, _keepAlive +// = 22655, _connID = "\134^\vF\DC1{\207R", _properties = []} +TEST(Connect311QCTest, Encode60) { + uint8_t pkt[] = {0x10, 0x14, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x58, + 0x7f, 0x0, 0x8, 0x86, 0x5e, 0xb, 0x46, 0x11, 0x7b, 0xcf, 0x52}; + + uint8_t buf[32] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 22655; + uint8_t client_id_bytes[] = {0x86, 0x5e, 0xb, 0x46, 0x11, 0x7b, 0xcf, 0x52}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x5e, 0x86}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 30398, _connID = "\GSv\DC4zn\ETX\185\219i\199/\131\157\245", _properties = []} +TEST(Connect311QCTest, Encode61) { + uint8_t pkt[] = {0x10, 0x1a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x76, 0xbe, 0x0, 0xe, + 0x1d, 0x76, 0x14, 0x7a, 0x6e, 0x3, 0xb9, 0xdb, 0x69, 0xc7, 0x2f, 0x83, 0x9d, 0xf5}; + + uint8_t buf[38] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 30398; + uint8_t client_id_bytes[] = {0x1d, 0x76, 0x14, 0x7a, 0x6e, 0x3, 0xb9, 0xdb, 0x69, 0xc7, 0x2f, 0x83, 0x9d, 0xf5}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\142\168\DC2Z\a\229\255\250\192\177\&6\172\240D2", _password = Just +// "\r\137\ETBtR\130C*\DC1\223\202\169\147\197\232", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, +// _willTopic = "\209\194%\251R\ETX%3\CAN\136\174\167\169\139\167\186C)\184*n\154\ETBmG\209T\186\DC1", _willMsg = +// "#yp(#!>\196O\247\DC1\176\253\150\238\214\216\212f\161Xl\t", _willProps = []}), _cleanSession = True, _keepAlive = +// 1871, _connID = "s\ETXN", _properties = []} +TEST(Connect311QCTest, Encode62) { + uint8_t pkt[] = {0x10, 0x69, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x7, 0x4f, 0x0, 0x3, 0x73, 0x3, + 0x4e, 0x0, 0x1d, 0xd1, 0xc2, 0x25, 0xfb, 0x52, 0x3, 0x25, 0x33, 0x18, 0x88, 0xae, 0xa7, 0xa9, + 0x8b, 0xa7, 0xba, 0x43, 0x29, 0xb8, 0x2a, 0x6e, 0x9a, 0x17, 0x6d, 0x47, 0xd1, 0x54, 0xba, 0x11, + 0x0, 0x17, 0x23, 0x79, 0x70, 0x28, 0x23, 0x21, 0x3e, 0xc4, 0x4f, 0xf7, 0x11, 0xb0, 0xfd, 0x96, + 0xee, 0xd6, 0xd8, 0xd4, 0x66, 0xa1, 0x58, 0x6c, 0x9, 0x0, 0xf, 0x8e, 0xa8, 0x12, 0x5a, 0x7, + 0xe5, 0xff, 0xfa, 0xc0, 0xb1, 0x36, 0xac, 0xf0, 0x44, 0x32, 0x0, 0xf, 0xd, 0x89, 0x17, 0x74, + 0x52, 0x82, 0x43, 0x2a, 0x11, 0xdf, 0xca, 0xa9, 0x93, 0xc5, 0xe8}; + + uint8_t buf[117] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd1, 0xc2, 0x25, 0xfb, 0x52, 0x3, 0x25, 0x33, 0x18, 0x88, + 0xae, 0xa7, 0xa9, 0x8b, 0xa7, 0xba, 0x43, 0x29, 0xb8, 0x2a, + 0x6e, 0x9a, 0x17, 0x6d, 0x47, 0xd1, 0x54, 0xba, 0x11}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x23, 0x79, 0x70, 0x28, 0x23, 0x21, 0x3e, 0xc4, 0x4f, 0xf7, 0x11, 0xb0, + 0xfd, 0x96, 0xee, 0xd6, 0xd8, 0xd4, 0x66, 0xa1, 0x58, 0x6c, 0x9}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1871; + uint8_t client_id_bytes[] = {0x73, 0x3, 0x4e}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x8e, 0xa8, 0x12, 0x5a, 0x7, 0xe5, 0xff, 0xfa, 0xc0, 0xb1, 0x36, 0xac, 0xf0, 0x44, 0x32}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xd, 0x89, 0x17, 0x74, 0x52, 0x82, 0x43, 0x2a, 0x11, 0xdf, 0xca, 0xa9, 0x93, 0xc5, 0xe8}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "^t\USER\139\244\152'\220\244", _willMsg = +// "\199\STX\191\&2ISE$\SOH}\221O\DC3,P\242\185\245\181\192\\\237\251p\237\247\198\203", _willProps = []}), +// _cleanSession = False, _keepAlive = 13191, _connID = "\152G\DC3\220\161\183\214\153L\231", _properties = []} +TEST(Connect311QCTest, Encode63) { + uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x33, 0x87, 0x0, 0xa, 0x98, 0x47, 0x13, + 0xdc, 0xa1, 0xb7, 0xd6, 0x99, 0x4c, 0xe7, 0x0, 0xb, 0x5e, 0x74, 0x1f, 0x45, 0x52, 0x8b, 0xf4, 0x98, + 0x27, 0xdc, 0xf4, 0x0, 0x1c, 0xc7, 0x2, 0xbf, 0x32, 0x49, 0x53, 0x45, 0x24, 0x1, 0x7d, 0xdd, 0x4f, + 0x13, 0x2c, 0x50, 0xf2, 0xb9, 0xf5, 0xb5, 0xc0, 0x5c, 0xed, 0xfb, 0x70, 0xed, 0xf7, 0xc6, 0xcb}; + + uint8_t buf[77] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5e, 0x74, 0x1f, 0x45, 0x52, 0x8b, 0xf4, 0x98, 0x27, 0xdc, 0xf4}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc7, 0x2, 0xbf, 0x32, 0x49, 0x53, 0x45, 0x24, 0x1, 0x7d, 0xdd, 0x4f, 0x13, 0x2c, + 0x50, 0xf2, 0xb9, 0xf5, 0xb5, 0xc0, 0x5c, 0xed, 0xfb, 0x70, 0xed, 0xf7, 0xc6, 0xcb}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 13191; + uint8_t client_id_bytes[] = {0x98, 0x47, 0x13, 0xdc, 0xa1, 0xb7, 0xd6, 0x99, 0x4c, 0xe7}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "4\159\162&\FS(\185Vz\159#", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\178\222\199o\DLE`0%\253\145qK;\128\218", _willMsg = +// "\130\&9Pt\tC\201\176\147", _willProps = []}), _cleanSession = False, _keepAlive = 3727, _connID = "\DEL\250\165", +// _properties = []} +TEST(Connect311QCTest, Encode64) { + uint8_t pkt[] = {0x10, 0x2b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0xe, 0x8f, 0x0, 0x3, 0x7f, + 0xfa, 0xa5, 0x0, 0xf, 0xb2, 0xde, 0xc7, 0x6f, 0x10, 0x60, 0x30, 0x25, 0xfd, 0x91, 0x71, + 0x4b, 0x3b, 0x80, 0xda, 0x0, 0x9, 0x82, 0x39, 0x50, 0x74, 0x9, 0x43, 0xc9, 0xb0, 0x93}; + + uint8_t buf[55] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb2, 0xde, 0xc7, 0x6f, 0x10, 0x60, 0x30, 0x25, + 0xfd, 0x91, 0x71, 0x4b, 0x3b, 0x80, 0xda}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x82, 0x39, 0x50, 0x74, 0x9, 0x43, 0xc9, 0xb0, 0x93}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3727; + uint8_t client_id_bytes[] = {0x7f, 0xfa, 0xa5}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x34, 0x9f, 0xa2, 0x26, 0x1c, 0x28, 0xb9, 0x56, 0x7a, 0x9f, 0x23}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\RSt\221\140\178\180\155#r\255\&3\212\203w\206\137L\202\190\SUB G\227\FS", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "~^x\SYN6\181\252#\192\a\231\220>\DC2e\NAK", _willMsg = +// "\202S\US{\160\165\GS\f\165\SUB\183D\191\212\150\157\f\SUBwj\204\SYN\167\237\251\161\189", _willProps = []}), +// _cleanSession = False, _keepAlive = 3670, _connID = "H\SI\178\231o\172\&9\153", _properties = []} +TEST(Connect311QCTest, Encode65) { + uint8_t pkt[] = {0x10, 0x5d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0xe, 0x56, 0x0, 0x8, 0x48, 0xf, + 0xb2, 0xe7, 0x6f, 0xac, 0x39, 0x99, 0x0, 0x10, 0x7e, 0x5e, 0x78, 0x16, 0x36, 0xb5, 0xfc, 0x23, + 0xc0, 0x7, 0xe7, 0xdc, 0x3e, 0x12, 0x65, 0x15, 0x0, 0x1b, 0xca, 0x53, 0x1f, 0x7b, 0xa0, 0xa5, + 0x1d, 0xc, 0xa5, 0x1a, 0xb7, 0x44, 0xbf, 0xd4, 0x96, 0x9d, 0xc, 0x1a, 0x77, 0x6a, 0xcc, 0x16, + 0xa7, 0xed, 0xfb, 0xa1, 0xbd, 0x0, 0x18, 0x1e, 0x74, 0xdd, 0x8c, 0xb2, 0xb4, 0x9b, 0x23, 0x72, + 0xff, 0x33, 0xd4, 0xcb, 0x77, 0xce, 0x89, 0x4c, 0xca, 0xbe, 0x1a, 0x20, 0x47, 0xe3, 0x1c}; + + uint8_t buf[105] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x7e, 0x5e, 0x78, 0x16, 0x36, 0xb5, 0xfc, 0x23, + 0xc0, 0x7, 0xe7, 0xdc, 0x3e, 0x12, 0x65, 0x15}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xca, 0x53, 0x1f, 0x7b, 0xa0, 0xa5, 0x1d, 0xc, 0xa5, 0x1a, 0xb7, 0x44, 0xbf, 0xd4, + 0x96, 0x9d, 0xc, 0x1a, 0x77, 0x6a, 0xcc, 0x16, 0xa7, 0xed, 0xfb, 0xa1, 0xbd}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3670; + uint8_t client_id_bytes[] = {0x48, 0xf, 0xb2, 0xe7, 0x6f, 0xac, 0x39, 0x99}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x1e, 0x74, 0xdd, 0x8c, 0xb2, 0xb4, 0x9b, 0x23, 0x72, 0xff, 0x33, 0xd4, + 0xcb, 0x77, 0xce, 0x89, 0x4c, 0xca, 0xbe, 0x1a, 0x20, 0x47, 0xe3, 0x1c}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\DC1M\180\r\a\252wp^bZ\135\DEL2@Z\253\165\DC2y\209\226r]\164", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "a\214\153~t\218\159\237r\222\195'\246(\175", _willMsg = "\224\207\248\\\EM\EM/u\n7rM\210", _willProps = []}), +// _cleanSession = True, _keepAlive = 15606, _connID = +// "\DC2O:m\245\197\216\200\\\t\162\221\172w\235d1\138\240\144\RSX%\208C\SOPC\199", _properties = []} +TEST(Connect311QCTest, Encode66) { + uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x3c, 0xf6, 0x0, 0x1d, 0x12, + 0x4f, 0x3a, 0x6d, 0xf5, 0xc5, 0xd8, 0xc8, 0x5c, 0x9, 0xa2, 0xdd, 0xac, 0x77, 0xeb, 0x64, + 0x31, 0x8a, 0xf0, 0x90, 0x1e, 0x58, 0x25, 0xd0, 0x43, 0xe, 0x50, 0x43, 0xc7, 0x0, 0xf, + 0x61, 0xd6, 0x99, 0x7e, 0x74, 0xda, 0x9f, 0xed, 0x72, 0xde, 0xc3, 0x27, 0xf6, 0x28, 0xaf, + 0x0, 0xd, 0xe0, 0xcf, 0xf8, 0x5c, 0x19, 0x19, 0x2f, 0x75, 0xa, 0x37, 0x72, 0x4d, 0xd2}; + + uint8_t buf[85] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x61, 0xd6, 0x99, 0x7e, 0x74, 0xda, 0x9f, 0xed, + 0x72, 0xde, 0xc3, 0x27, 0xf6, 0x28, 0xaf}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe0, 0xcf, 0xf8, 0x5c, 0x19, 0x19, 0x2f, 0x75, 0xa, 0x37, 0x72, 0x4d, 0xd2}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 15606; + uint8_t client_id_bytes[] = {0x12, 0x4f, 0x3a, 0x6d, 0xf5, 0xc5, 0xd8, 0xc8, 0x5c, 0x9, 0xa2, 0xdd, 0xac, 0x77, 0xeb, + 0x64, 0x31, 0x8a, 0xf0, 0x90, 0x1e, 0x58, 0x25, 0xd0, 0x43, 0xe, 0x50, 0x43, 0xc7}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x11, 0x4d, 0xb4, 0xd, 0x7, 0xfc, 0x77, 0x70, 0x5e, 0x62, 0x5a, 0x87, 0x7f, + 0x32, 0x40, 0x5a, 0xfd, 0xa5, 0x12, 0x79, 0xd1, 0xe2, 0x72, 0x5d, 0xa4}; + lwmqtt_string_t password = {25, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "7y&\a\226\163R-*\143C\172?T4\174\227\&4$\202\150\&2\DLE\231\243", _password = +// Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = 6271, _connID = +// "\193=\232\&0\251\248\&3\179\238?E\142", _properties = []} +TEST(Connect311QCTest, Encode67) { + uint8_t pkt[] = {0x10, 0x33, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x82, 0x18, 0x7f, 0x0, 0xc, + 0xc1, 0x3d, 0xe8, 0x30, 0xfb, 0xf8, 0x33, 0xb3, 0xee, 0x3f, 0x45, 0x8e, 0x0, 0x19, + 0x37, 0x79, 0x26, 0x7, 0xe2, 0xa3, 0x52, 0x2d, 0x2a, 0x8f, 0x43, 0xac, 0x3f, 0x54, + 0x34, 0xae, 0xe3, 0x34, 0x24, 0xca, 0x96, 0x32, 0x10, 0xe7, 0xf3}; + + uint8_t buf[63] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 6271; + uint8_t client_id_bytes[] = {0xc1, 0x3d, 0xe8, 0x30, 0xfb, 0xf8, 0x33, 0xb3, 0xee, 0x3f, 0x45, 0x8e}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x37, 0x79, 0x26, 0x7, 0xe2, 0xa3, 0x52, 0x2d, 0x2a, 0x8f, 0x43, 0xac, 0x3f, + 0x54, 0x34, 0xae, 0xe3, 0x34, 0x24, 0xca, 0x96, 0x32, 0x10, 0xe7, 0xf3}; + lwmqtt_string_t username = {25, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\NAK=\230S\192\217KW\211\176\174\190\213\179a\138\ENQR\222", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "\218\251\CAN\137\184\196\247\&0u\SYNZ", _willMsg = "\140\162\226\246\\\158,\b\141\157Z$+", _willProps = []}), +// _cleanSession = False, _keepAlive = 18470, _connID = +// "\145\177\179\193o\203\219\238Y:\131\b\140\246\195\211\214\210p\177", _properties = []} +TEST(Connect311QCTest, Encode68) { + uint8_t pkt[] = {0x10, 0x3c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0x48, 0x26, 0x0, 0x14, 0x91, 0xb1, + 0xb3, 0xc1, 0x6f, 0xcb, 0xdb, 0xee, 0x59, 0x3a, 0x83, 0x8, 0x8c, 0xf6, 0xc3, 0xd3, 0xd6, 0xd2, + 0x70, 0xb1, 0x0, 0xb, 0xda, 0xfb, 0x18, 0x89, 0xb8, 0xc4, 0xf7, 0x30, 0x75, 0x16, 0x5a, 0x0, + 0xd, 0x8c, 0xa2, 0xe2, 0xf6, 0x5c, 0x9e, 0x2c, 0x8, 0x8d, 0x9d, 0x5a, 0x24, 0x2b}; + + uint8_t buf[72] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xda, 0xfb, 0x18, 0x89, 0xb8, 0xc4, 0xf7, 0x30, 0x75, 0x16, 0x5a}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x8c, 0xa2, 0xe2, 0xf6, 0x5c, 0x9e, 0x2c, 0x8, 0x8d, 0x9d, 0x5a, 0x24, 0x2b}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 18470; + uint8_t client_id_bytes[] = {0x91, 0xb1, 0xb3, 0xc1, 0x6f, 0xcb, 0xdb, 0xee, 0x59, 0x3a, + 0x83, 0x8, 0x8c, 0xf6, 0xc3, 0xd3, 0xd6, 0xd2, 0x70, 0xb1}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x15, 0x3d, 0xe6, 0x53, 0xc0, 0xd9, 0x4b, 0x57, 0xd3, 0xb0, + 0xae, 0xbe, 0xd5, 0xb3, 0x61, 0x8a, 0x5, 0x52, 0xde}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\SOH\253\128h\214\136>\244<\255\153", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "n\221.g\231\209[a*n'\214al\147\241$\175'-J\140\217\175\152\130\155\232", _willMsg = +// "\US\161\236\DC2\138\211_\ESC\244", _willProps = []}), _cleanSession = True, _keepAlive = 9181, _connID = +// "M\156\DC4\133Z\205\NAK&", _properties = []} +TEST(Connect311QCTest, Encode69) { + uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x23, 0xdd, 0x0, 0x8, 0x4d, 0x9c, + 0x14, 0x85, 0x5a, 0xcd, 0x15, 0x26, 0x0, 0x1c, 0x6e, 0xdd, 0x2e, 0x67, 0xe7, 0xd1, 0x5b, 0x61, + 0x2a, 0x6e, 0x27, 0xd6, 0x61, 0x6c, 0x93, 0xf1, 0x24, 0xaf, 0x27, 0x2d, 0x4a, 0x8c, 0xd9, 0xaf, + 0x98, 0x82, 0x9b, 0xe8, 0x0, 0x9, 0x1f, 0xa1, 0xec, 0x12, 0x8a, 0xd3, 0x5f, 0x1b, 0xf4}; + + uint8_t buf[73] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x6e, 0xdd, 0x2e, 0x67, 0xe7, 0xd1, 0x5b, 0x61, 0x2a, 0x6e, 0x27, 0xd6, 0x61, 0x6c, + 0x93, 0xf1, 0x24, 0xaf, 0x27, 0x2d, 0x4a, 0x8c, 0xd9, 0xaf, 0x98, 0x82, 0x9b, 0xe8}; + lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1f, 0xa1, 0xec, 0x12, 0x8a, 0xd3, 0x5f, 0x1b, 0xf4}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 9181; + uint8_t client_id_bytes[] = {0x4d, 0x9c, 0x14, 0x85, 0x5a, 0xcd, 0x15, 0x26}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x1, 0xfd, 0x80, 0x68, 0xd6, 0x88, 0x3e, 0xf4, 0x3c, 0xff, 0x99}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\227\ESCQ", _password = Just "\231\239\188\247\236\FSU\172\t\232D", _lastWill = +// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "(7<,XJ9\ETB\231t\245\245\214\208\FSj\131", +// _willMsg = "", _willProps = []}), _cleanSession = False, _keepAlive = 70, _connID = +// "\226\&9\142F\US\236\161\186\252\236\147\229\210E\130\EMh\128\129\DC3axe\165\179\238Vi\169\245", _properties = []} +TEST(Connect311QCTest, Encode70) { + uint8_t pkt[] = {0x10, 0x51, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x0, 0x46, 0x0, 0x1e, 0xe2, 0x39, 0x8e, + 0x46, 0x1f, 0xec, 0xa1, 0xba, 0xfc, 0xec, 0x93, 0xe5, 0xd2, 0x45, 0x82, 0x19, 0x68, 0x80, 0x81, 0x13, + 0x61, 0x78, 0x65, 0xa5, 0xb3, 0xee, 0x56, 0x69, 0xa9, 0xf5, 0x0, 0x11, 0x28, 0x37, 0x3c, 0x2c, 0x58, + 0x4a, 0x39, 0x17, 0xe7, 0x74, 0xf5, 0xf5, 0xd6, 0xd0, 0x1c, 0x6a, 0x83, 0x0, 0x0, 0x0, 0x3, 0xe3, + 0x1b, 0x51, 0x0, 0xb, 0xe7, 0xef, 0xbc, 0xf7, 0xec, 0x1c, 0x55, 0xac, 0x9, 0xe8, 0x44}; + + uint8_t buf[93] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x28, 0x37, 0x3c, 0x2c, 0x58, 0x4a, 0x39, 0x17, 0xe7, + 0x74, 0xf5, 0xf5, 0xd6, 0xd0, 0x1c, 0x6a, 0x83}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 70; + uint8_t client_id_bytes[] = {0xe2, 0x39, 0x8e, 0x46, 0x1f, 0xec, 0xa1, 0xba, 0xfc, 0xec, + 0x93, 0xe5, 0xd2, 0x45, 0x82, 0x19, 0x68, 0x80, 0x81, 0x13, + 0x61, 0x78, 0x65, 0xa5, 0xb3, 0xee, 0x56, 0x69, 0xa9, 0xf5}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xe3, 0x1b, 0x51}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xe7, 0xef, 0xbc, 0xf7, 0xec, 0x1c, 0x55, 0xac, 0x9, 0xe8, 0x44}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\a.\173\189\187\192\&5\DC1\242@\ETXGI\174r\189\191\213\CAN4\233\SOH\196", _password +// = Just "i\DC1lU\210\253\204\211\224\DC4\228", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, +// _willTopic = "\CAN\228\137ea\b\DC1\230\188B\b\185\161\213\250:\214\RSLYL\193\157K\189R~", _willMsg = +// "^\188x\173\231\249S\128\&9\STX%\133l\173s\135{F\221\169T\254", _willProps = []}), _cleanSession = False, _keepAlive +// = 3405, _connID = "\229sD\131\227v\232^4n0", _properties = []} +TEST(Connect311QCTest, Encode71) { + uint8_t pkt[] = {0x10, 0x72, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0xd, 0x4d, 0x0, 0xb, 0xe5, 0x73, 0x44, + 0x83, 0xe3, 0x76, 0xe8, 0x5e, 0x34, 0x6e, 0x30, 0x0, 0x1b, 0x18, 0xe4, 0x89, 0x65, 0x61, 0x8, 0x11, + 0xe6, 0xbc, 0x42, 0x8, 0xb9, 0xa1, 0xd5, 0xfa, 0x3a, 0xd6, 0x1e, 0x4c, 0x59, 0x4c, 0xc1, 0x9d, 0x4b, + 0xbd, 0x52, 0x7e, 0x0, 0x16, 0x5e, 0xbc, 0x78, 0xad, 0xe7, 0xf9, 0x53, 0x80, 0x39, 0x2, 0x25, 0x85, + 0x6c, 0xad, 0x73, 0x87, 0x7b, 0x46, 0xdd, 0xa9, 0x54, 0xfe, 0x0, 0x17, 0x7, 0x2e, 0xad, 0xbd, 0xbb, + 0xc0, 0x35, 0x11, 0xf2, 0x40, 0x3, 0x47, 0x49, 0xae, 0x72, 0xbd, 0xbf, 0xd5, 0x18, 0x34, 0xe9, 0x1, + 0xc4, 0x0, 0xb, 0x69, 0x11, 0x6c, 0x55, 0xd2, 0xfd, 0xcc, 0xd3, 0xe0, 0x14, 0xe4}; + + uint8_t buf[126] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x18, 0xe4, 0x89, 0x65, 0x61, 0x8, 0x11, 0xe6, 0xbc, 0x42, 0x8, 0xb9, 0xa1, 0xd5, + 0xfa, 0x3a, 0xd6, 0x1e, 0x4c, 0x59, 0x4c, 0xc1, 0x9d, 0x4b, 0xbd, 0x52, 0x7e}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5e, 0xbc, 0x78, 0xad, 0xe7, 0xf9, 0x53, 0x80, 0x39, 0x2, 0x25, + 0x85, 0x6c, 0xad, 0x73, 0x87, 0x7b, 0x46, 0xdd, 0xa9, 0x54, 0xfe}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3405; + uint8_t client_id_bytes[] = {0xe5, 0x73, 0x44, 0x83, 0xe3, 0x76, 0xe8, 0x5e, 0x34, 0x6e, 0x30}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x7, 0x2e, 0xad, 0xbd, 0xbb, 0xc0, 0x35, 0x11, 0xf2, 0x40, 0x3, 0x47, + 0x49, 0xae, 0x72, 0xbd, 0xbf, 0xd5, 0x18, 0x34, 0xe9, 0x1, 0xc4}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x69, 0x11, 0x6c, 0x55, 0xd2, 0xfd, 0xcc, 0xd3, 0xe0, 0x14, 0xe4}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "a", _password = Just "@\CAN\194hS*r\ESC'\162\SUB\222P\218g\250\&5\aN\nf\ETX\246", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\135!\172j\177\193\187\202+&FH\SO", +// _willMsg = "g\144@\161F\215\147>\217\b\228\146\186\ETB\234\252\208\201", _willProps = []}), _cleanSession = True, +// _keepAlive = 19693, _connID = "\140\204\191\171.BtU+cj", _properties = []} +TEST(Connect311QCTest, Encode72) { + uint8_t pkt[] = {0x10, 0x56, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x4c, 0xed, 0x0, 0xb, 0x8c, + 0xcc, 0xbf, 0xab, 0x2e, 0x42, 0x74, 0x55, 0x2b, 0x63, 0x6a, 0x0, 0xd, 0x87, 0x21, 0xac, + 0x6a, 0xb1, 0xc1, 0xbb, 0xca, 0x2b, 0x26, 0x46, 0x48, 0xe, 0x0, 0x12, 0x67, 0x90, 0x40, + 0xa1, 0x46, 0xd7, 0x93, 0x3e, 0xd9, 0x8, 0xe4, 0x92, 0xba, 0x17, 0xea, 0xfc, 0xd0, 0xc9, + 0x0, 0x1, 0x61, 0x0, 0x17, 0x40, 0x18, 0xc2, 0x68, 0x53, 0x2a, 0x72, 0x1b, 0x27, 0xa2, + 0x1a, 0xde, 0x50, 0xda, 0x67, 0xfa, 0x35, 0x7, 0x4e, 0xa, 0x66, 0x3, 0xf6}; + + uint8_t buf[98] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x87, 0x21, 0xac, 0x6a, 0xb1, 0xc1, 0xbb, 0xca, 0x2b, 0x26, 0x46, 0x48, 0xe}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x67, 0x90, 0x40, 0xa1, 0x46, 0xd7, 0x93, 0x3e, 0xd9, + 0x8, 0xe4, 0x92, 0xba, 0x17, 0xea, 0xfc, 0xd0, 0xc9}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 19693; + uint8_t client_id_bytes[] = {0x8c, 0xcc, 0xbf, 0xab, 0x2e, 0x42, 0x74, 0x55, 0x2b, 0x63, 0x6a}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x61}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x40, 0x18, 0xc2, 0x68, 0x53, 0x2a, 0x72, 0x1b, 0x27, 0xa2, 0x1a, 0xde, + 0x50, 0xda, 0x67, 0xfa, 0x35, 0x7, 0x4e, 0xa, 0x66, 0x3, 0xf6}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\172\219m,\215\&1j\218 +// $\179\198q\177c\172\251|\145\151)\ACKk\199\226\192\131\161\SO", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS1, _willTopic = "\253X\142\n\160\NUL\146\171ng\\\NAK\186Q\142\165\NUL\ETX6\212\255d\134|\252\181!av)", +// _willMsg = "}1\182T-u\251\128", _willProps = []}), _cleanSession = False, _keepAlive = 12479, _connID = +// "\160\198\DC2f\138Q\188Q\138!y\131\141\&4\255\149\228$=Tx\SOHa\231", _properties = []} +TEST(Connect311QCTest, Encode73) { + uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x30, 0xbf, 0x0, 0x18, 0xa0, 0xc6, + 0x12, 0x66, 0x8a, 0x51, 0xbc, 0x51, 0x8a, 0x21, 0x79, 0x83, 0x8d, 0x34, 0xff, 0x95, 0xe4, 0x24, + 0x3d, 0x54, 0x78, 0x1, 0x61, 0xe7, 0x0, 0x1e, 0xfd, 0x58, 0x8e, 0xa, 0xa0, 0x0, 0x92, 0xab, + 0x6e, 0x67, 0x5c, 0x15, 0xba, 0x51, 0x8e, 0xa5, 0x0, 0x3, 0x36, 0xd4, 0xff, 0x64, 0x86, 0x7c, + 0xfc, 0xb5, 0x21, 0x61, 0x76, 0x29, 0x0, 0x8, 0x7d, 0x31, 0xb6, 0x54, 0x2d, 0x75, 0xfb, 0x80}; + + uint8_t buf[90] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xfd, 0x58, 0x8e, 0xa, 0xa0, 0x0, 0x92, 0xab, 0x6e, 0x67, + 0x5c, 0x15, 0xba, 0x51, 0x8e, 0xa5, 0x0, 0x3, 0x36, 0xd4, + 0xff, 0x64, 0x86, 0x7c, 0xfc, 0xb5, 0x21, 0x61, 0x76, 0x29}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7d, 0x31, 0xb6, 0x54, 0x2d, 0x75, 0xfb, 0x80}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 12479; + uint8_t client_id_bytes[] = {0xa0, 0xc6, 0x12, 0x66, 0x8a, 0x51, 0xbc, 0x51, 0x8a, 0x21, 0x79, 0x83, + 0x8d, 0x34, 0xff, 0x95, 0xe4, 0x24, 0x3d, 0x54, 0x78, 0x1, 0x61, 0xe7}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xac, 0xdb, 0x6d, 0x2c, 0xd7, 0x31, 0x6a, 0xda, 0x20, 0x24, 0xb3, 0xc6, 0x71, 0xb1, 0x63, + 0xac, 0xfb, 0x7c, 0x91, 0x97, 0x29, 0x6, 0x6b, 0xc7, 0xe2, 0xc0, 0x83, 0xa1, 0xe}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\186>\208\176\160\b\130H\DC3\FS\nw@\180M\223\f}~\163s\234_", _password = Nothing, +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "h ", _willMsg = +// "\136Jb\133\241\194\237\174\234.J\DEL\213\CAN\189A\167\182", _willProps = []}), _cleanSession = False, _keepAlive = +// 15269, _connID = "\151O\SUBd\191\216\184\130k$\237[9\159\\\STX\130\196~\DLE\222\ESC\198}\157\129w\n", _properties = +// []} +TEST(Connect311QCTest, Encode74) { + uint8_t pkt[] = {0x10, 0x59, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x94, 0x3b, 0xa5, 0x0, 0x1c, 0x97, 0x4f, + 0x1a, 0x64, 0xbf, 0xd8, 0xb8, 0x82, 0x6b, 0x24, 0xed, 0x5b, 0x39, 0x9f, 0x5c, 0x2, 0x82, 0xc4, + 0x7e, 0x10, 0xde, 0x1b, 0xc6, 0x7d, 0x9d, 0x81, 0x77, 0xa, 0x0, 0x2, 0x68, 0x20, 0x0, 0x12, + 0x88, 0x4a, 0x62, 0x85, 0xf1, 0xc2, 0xed, 0xae, 0xea, 0x2e, 0x4a, 0x7f, 0xd5, 0x18, 0xbd, 0x41, + 0xa7, 0xb6, 0x0, 0x17, 0xba, 0x3e, 0xd0, 0xb0, 0xa0, 0x8, 0x82, 0x48, 0x13, 0x1c, 0xa, 0x77, + 0x40, 0xb4, 0x4d, 0xdf, 0xc, 0x7d, 0x7e, 0xa3, 0x73, 0xea, 0x5f}; + + uint8_t buf[101] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x68, 0x20}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x88, 0x4a, 0x62, 0x85, 0xf1, 0xc2, 0xed, 0xae, 0xea, + 0x2e, 0x4a, 0x7f, 0xd5, 0x18, 0xbd, 0x41, 0xa7, 0xb6}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 15269; + uint8_t client_id_bytes[] = {0x97, 0x4f, 0x1a, 0x64, 0xbf, 0xd8, 0xb8, 0x82, 0x6b, 0x24, 0xed, 0x5b, 0x39, 0x9f, + 0x5c, 0x2, 0x82, 0xc4, 0x7e, 0x10, 0xde, 0x1b, 0xc6, 0x7d, 0x9d, 0x81, 0x77, 0xa}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xba, 0x3e, 0xd0, 0xb0, 0xa0, 0x8, 0x82, 0x48, 0x13, 0x1c, 0xa, 0x77, + 0x40, 0xb4, 0x4d, 0xdf, 0xc, 0x7d, 0x7e, 0xa3, 0x73, 0xea, 0x5f}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "%_f0P\185\133\159\152\SOH\185\161\133\186\242\&0'", _password = Just +// "\166\165\148d\NAKy%\142\222\189,", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\222\254\185A\161\232i\ACK\180Z\146\192\254\182-\206\&8H\211\132", _willMsg = +// "\218\212\ACK\ESC\DC2_y\169\196A\228\195N\209;\219\138G\r\GS", _willProps = []}), _cleanSession = True, _keepAlive = +// 20166, _connID = "\ETBG\233\139e\tY\235MPwMH\208", _properties = []} +TEST(Connect311QCTest, Encode75) { + uint8_t pkt[] = {0x10, 0x66, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x4e, 0xc6, 0x0, 0xe, 0x17, + 0x47, 0xe9, 0x8b, 0x65, 0x9, 0x59, 0xeb, 0x4d, 0x50, 0x77, 0x4d, 0x48, 0xd0, 0x0, 0x14, + 0xde, 0xfe, 0xb9, 0x41, 0xa1, 0xe8, 0x69, 0x6, 0xb4, 0x5a, 0x92, 0xc0, 0xfe, 0xb6, 0x2d, + 0xce, 0x38, 0x48, 0xd3, 0x84, 0x0, 0x14, 0xda, 0xd4, 0x6, 0x1b, 0x12, 0x5f, 0x79, 0xa9, + 0xc4, 0x41, 0xe4, 0xc3, 0x4e, 0xd1, 0x3b, 0xdb, 0x8a, 0x47, 0xd, 0x1d, 0x0, 0x11, 0x25, + 0x5f, 0x66, 0x30, 0x50, 0xb9, 0x85, 0x9f, 0x98, 0x1, 0xb9, 0xa1, 0x85, 0xba, 0xf2, 0x30, + 0x27, 0x0, 0xb, 0xa6, 0xa5, 0x94, 0x64, 0x15, 0x79, 0x25, 0x8e, 0xde, 0xbd, 0x2c}; + + uint8_t buf[114] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xde, 0xfe, 0xb9, 0x41, 0xa1, 0xe8, 0x69, 0x6, 0xb4, 0x5a, + 0x92, 0xc0, 0xfe, 0xb6, 0x2d, 0xce, 0x38, 0x48, 0xd3, 0x84}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xda, 0xd4, 0x6, 0x1b, 0x12, 0x5f, 0x79, 0xa9, 0xc4, 0x41, + 0xe4, 0xc3, 0x4e, 0xd1, 0x3b, 0xdb, 0x8a, 0x47, 0xd, 0x1d}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 20166; + uint8_t client_id_bytes[] = {0x17, 0x47, 0xe9, 0x8b, 0x65, 0x9, 0x59, 0xeb, 0x4d, 0x50, 0x77, 0x4d, 0x48, 0xd0}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x25, 0x5f, 0x66, 0x30, 0x50, 0xb9, 0x85, 0x9f, 0x98, + 0x1, 0xb9, 0xa1, 0x85, 0xba, 0xf2, 0x30, 0x27}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xa6, 0xa5, 0x94, 0x64, 0x15, 0x79, 0x25, 0x8e, 0xde, 0xbd, 0x2c}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\172\206\237\DLE\254_Q2\226B'S\147k\177*D!\230\185<\130", _password = Just +// ".\STX\240p\196\191\165l\140\230\214\188\253\220\166\224I\197\241\153&3;\249", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS0, _willTopic = "\DC1o\221b\189\141f\242\228\CAN\219\141,e\230\221\166\&7Ar\GS", +// _willMsg = "", _willProps = []}), _cleanSession = False, _keepAlive = 20633, _connID = +// "x]*\241\253\180\253\181\DC4%\n\245\187\"\138\DLE\212b\182\171\131J\193\&0\176C", _properties = []} +TEST(Connect311QCTest, Encode76) { + uint8_t pkt[] = {0x10, 0x71, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x50, 0x99, 0x0, 0x1a, 0x78, 0x5d, 0x2a, + 0xf1, 0xfd, 0xb4, 0xfd, 0xb5, 0x14, 0x25, 0xa, 0xf5, 0xbb, 0x22, 0x8a, 0x10, 0xd4, 0x62, 0xb6, 0xab, + 0x83, 0x4a, 0xc1, 0x30, 0xb0, 0x43, 0x0, 0x15, 0x11, 0x6f, 0xdd, 0x62, 0xbd, 0x8d, 0x66, 0xf2, 0xe4, + 0x18, 0xdb, 0x8d, 0x2c, 0x65, 0xe6, 0xdd, 0xa6, 0x37, 0x41, 0x72, 0x1d, 0x0, 0x0, 0x0, 0x16, 0xac, + 0xce, 0xed, 0x10, 0xfe, 0x5f, 0x51, 0x32, 0xe2, 0x42, 0x27, 0x53, 0x93, 0x6b, 0xb1, 0x2a, 0x44, 0x21, + 0xe6, 0xb9, 0x3c, 0x82, 0x0, 0x18, 0x2e, 0x2, 0xf0, 0x70, 0xc4, 0xbf, 0xa5, 0x6c, 0x8c, 0xe6, 0xd6, + 0xbc, 0xfd, 0xdc, 0xa6, 0xe0, 0x49, 0xc5, 0xf1, 0x99, 0x26, 0x33, 0x3b, 0xf9}; + + uint8_t buf[125] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x11, 0x6f, 0xdd, 0x62, 0xbd, 0x8d, 0x66, 0xf2, 0xe4, 0x18, 0xdb, + 0x8d, 0x2c, 0x65, 0xe6, 0xdd, 0xa6, 0x37, 0x41, 0x72, 0x1d}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 20633; + uint8_t client_id_bytes[] = {0x78, 0x5d, 0x2a, 0xf1, 0xfd, 0xb4, 0xfd, 0xb5, 0x14, 0x25, 0xa, 0xf5, 0xbb, + 0x22, 0x8a, 0x10, 0xd4, 0x62, 0xb6, 0xab, 0x83, 0x4a, 0xc1, 0x30, 0xb0, 0x43}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xac, 0xce, 0xed, 0x10, 0xfe, 0x5f, 0x51, 0x32, 0xe2, 0x42, 0x27, + 0x53, 0x93, 0x6b, 0xb1, 0x2a, 0x44, 0x21, 0xe6, 0xb9, 0x3c, 0x82}; + lwmqtt_string_t username = {22, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x2e, 0x2, 0xf0, 0x70, 0xc4, 0xbf, 0xa5, 0x6c, 0x8c, 0xe6, 0xd6, 0xbc, + 0xfd, 0xdc, 0xa6, 0xe0, 0x49, 0xc5, 0xf1, 0x99, 0x26, 0x33, 0x3b, 0xf9}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "z@\a", _password = Just "\253\197(\t}\238J\253\251\192\135j", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\129B\175B", _willMsg = "S\233k'\183[ryq\189X\218", +// _willProps = []}), _cleanSession = False, _keepAlive = 32764, _connID = "d\173\189", _properties = []} +TEST(Connect311QCTest, Encode77) { + uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x7f, 0xfc, 0x0, 0x3, + 0x64, 0xad, 0xbd, 0x0, 0x4, 0x81, 0x42, 0xaf, 0x42, 0x0, 0xc, 0x53, 0xe9, 0x6b, + 0x27, 0xb7, 0x5b, 0x72, 0x79, 0x71, 0xbd, 0x58, 0xda, 0x0, 0x3, 0x7a, 0x40, 0x7, + 0x0, 0xc, 0xfd, 0xc5, 0x28, 0x9, 0x7d, 0xee, 0x4a, 0xfd, 0xfb, 0xc0, 0x87, 0x6a}; + + uint8_t buf[66] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x81, 0x42, 0xaf, 0x42}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x53, 0xe9, 0x6b, 0x27, 0xb7, 0x5b, 0x72, 0x79, 0x71, 0xbd, 0x58, 0xda}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32764; + uint8_t client_id_bytes[] = {0x64, 0xad, 0xbd}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x7a, 0x40, 0x7}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xfd, 0xc5, 0x28, 0x9, 0x7d, 0xee, 0x4a, 0xfd, 0xfb, 0xc0, 0x87, 0x6a}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "vo\255\134\EM\214ra~\221QTH]\236\&1\203\133f\193%", _password = Nothing, _lastWill +// = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\143\219\228T\SIP\210\NULp\216b\230\191\b\DC1\190\218\139\178\174\179\138\176z", _willMsg = +// "\\\196Q\224Q\138\232\DC4\230u\194\&6\147\197\138o\202\247&\180\179\RSB,\244\153h\STX", _willProps = []}), +// _cleanSession = False, _keepAlive = 18519, _connID = "cX\140\&9\221\ETXY\131\GS", _properties = []} +TEST(Connect311QCTest, Encode78) { + uint8_t pkt[] = {0x10, 0x64, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0x48, 0x57, 0x0, 0x9, 0x63, + 0x58, 0x8c, 0x39, 0xdd, 0x3, 0x59, 0x83, 0x1d, 0x0, 0x18, 0x8f, 0xdb, 0xe4, 0x54, 0xf, + 0x50, 0xd2, 0x0, 0x70, 0xd8, 0x62, 0xe6, 0xbf, 0x8, 0x11, 0xbe, 0xda, 0x8b, 0xb2, 0xae, + 0xb3, 0x8a, 0xb0, 0x7a, 0x0, 0x1c, 0x5c, 0xc4, 0x51, 0xe0, 0x51, 0x8a, 0xe8, 0x14, 0xe6, + 0x75, 0xc2, 0x36, 0x93, 0xc5, 0x8a, 0x6f, 0xca, 0xf7, 0x26, 0xb4, 0xb3, 0x1e, 0x42, 0x2c, + 0xf4, 0x99, 0x68, 0x2, 0x0, 0x15, 0x76, 0x6f, 0xff, 0x86, 0x19, 0xd6, 0x72, 0x61, 0x7e, + 0xdd, 0x51, 0x54, 0x48, 0x5d, 0xec, 0x31, 0xcb, 0x85, 0x66, 0xc1, 0x25}; + + uint8_t buf[112] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8f, 0xdb, 0xe4, 0x54, 0xf, 0x50, 0xd2, 0x0, 0x70, 0xd8, 0x62, 0xe6, + 0xbf, 0x8, 0x11, 0xbe, 0xda, 0x8b, 0xb2, 0xae, 0xb3, 0x8a, 0xb0, 0x7a}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5c, 0xc4, 0x51, 0xe0, 0x51, 0x8a, 0xe8, 0x14, 0xe6, 0x75, 0xc2, 0x36, 0x93, 0xc5, + 0x8a, 0x6f, 0xca, 0xf7, 0x26, 0xb4, 0xb3, 0x1e, 0x42, 0x2c, 0xf4, 0x99, 0x68, 0x2}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 18519; + uint8_t client_id_bytes[] = {0x63, 0x58, 0x8c, 0x39, 0xdd, 0x3, 0x59, 0x83, 0x1d}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x76, 0x6f, 0xff, 0x86, 0x19, 0xd6, 0x72, 0x61, 0x7e, 0xdd, 0x51, + 0x54, 0x48, 0x5d, 0xec, 0x31, 0xcb, 0x85, 0x66, 0xc1, 0x25}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// "\157\ETB\161\194\193\144\143\222H\bK\137S\211\183P\248e#\158\140\132\232~", _lastWill = Just (LastWill {_willRetain +// = True, _willQoS = QoS0, _willTopic = "\234\218\131\206!/\185r4\200\241\199\174\200\229", _willMsg = +// "?\198\253\173(", _willProps = []}), _cleanSession = True, _keepAlive = 5462, _connID = +// "~Zt\220\FS\b\166{\135\185\244Q\248@\a^", _properties = []} +TEST(Connect311QCTest, Encode79) { + uint8_t pkt[] = {0x10, 0x34, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x15, 0x56, 0x0, 0x10, + 0x7e, 0x5a, 0x74, 0xdc, 0x1c, 0x8, 0xa6, 0x7b, 0x87, 0xb9, 0xf4, 0x51, 0xf8, 0x40, + 0x7, 0x5e, 0x0, 0xf, 0xea, 0xda, 0x83, 0xce, 0x21, 0x2f, 0xb9, 0x72, 0x34, 0xc8, + 0xf1, 0xc7, 0xae, 0xc8, 0xe5, 0x0, 0x5, 0x3f, 0xc6, 0xfd, 0xad, 0x28}; + + uint8_t buf[64] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xea, 0xda, 0x83, 0xce, 0x21, 0x2f, 0xb9, 0x72, + 0x34, 0xc8, 0xf1, 0xc7, 0xae, 0xc8, 0xe5}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3f, 0xc6, 0xfd, 0xad, 0x28}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 5462; + uint8_t client_id_bytes[] = {0x7e, 0x5a, 0x74, 0xdc, 0x1c, 0x8, 0xa6, 0x7b, + 0x87, 0xb9, 0xf4, 0x51, 0xf8, 0x40, 0x7, 0x5e}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x9d, 0x17, 0xa1, 0xc2, 0xc1, 0x90, 0x8f, 0xde, 0x48, 0x8, 0x4b, 0x89, + 0x53, 0xd3, 0xb7, 0x50, 0xf8, 0x65, 0x23, 0x9e, 0x8c, 0x84, 0xe8, 0x7e}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\147{'Z\192?r8#\DLEU\192\236\160\237v\192p\NUL\171;\EOT", _password = Just +// "\160J\202\185\172\&2\153\200\SYN\a\130n\179\133f\207\&5\n8\245\n\144\220", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS0, _willTopic = "\145K\248\242\218\139\203", _willMsg = +// "\166\252\SI\215\181\NUL\150dX7\178\210", _willProps = []}), _cleanSession = True, _keepAlive = 25664, _connID = +// "\GS\225\&4\DC4\182", _properties = []} +TEST(Connect311QCTest, Encode80) { + uint8_t pkt[] = {0x10, 0x59, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x64, 0x40, 0x0, 0x5, 0x1d, 0xe1, + 0x34, 0x14, 0xb6, 0x0, 0x7, 0x91, 0x4b, 0xf8, 0xf2, 0xda, 0x8b, 0xcb, 0x0, 0xc, 0xa6, 0xfc, + 0xf, 0xd7, 0xb5, 0x0, 0x96, 0x64, 0x58, 0x37, 0xb2, 0xd2, 0x0, 0x16, 0x93, 0x7b, 0x27, 0x5a, + 0xc0, 0x3f, 0x72, 0x38, 0x23, 0x10, 0x55, 0xc0, 0xec, 0xa0, 0xed, 0x76, 0xc0, 0x70, 0x0, 0xab, + 0x3b, 0x4, 0x0, 0x17, 0xa0, 0x4a, 0xca, 0xb9, 0xac, 0x32, 0x99, 0xc8, 0x16, 0x7, 0x82, 0x6e, + 0xb3, 0x85, 0x66, 0xcf, 0x35, 0xa, 0x38, 0xf5, 0xa, 0x90, 0xdc}; + + uint8_t buf[101] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x91, 0x4b, 0xf8, 0xf2, 0xda, 0x8b, 0xcb}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa6, 0xfc, 0xf, 0xd7, 0xb5, 0x0, 0x96, 0x64, 0x58, 0x37, 0xb2, 0xd2}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 25664; + uint8_t client_id_bytes[] = {0x1d, 0xe1, 0x34, 0x14, 0xb6}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x93, 0x7b, 0x27, 0x5a, 0xc0, 0x3f, 0x72, 0x38, 0x23, 0x10, 0x55, + 0xc0, 0xec, 0xa0, 0xed, 0x76, 0xc0, 0x70, 0x0, 0xab, 0x3b, 0x4}; + lwmqtt_string_t username = {22, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xa0, 0x4a, 0xca, 0xb9, 0xac, 0x32, 0x99, 0xc8, 0x16, 0x7, 0x82, 0x6e, + 0xb3, 0x85, 0x66, 0xcf, 0x35, 0xa, 0x38, 0xf5, 0xa, 0x90, 0xdc}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "P\178\243\183\172\137\232\212\r~N\252\145\212h\230\DC1\144z}\209\&6\247\DLE\192iq", +// _password = Just "mU", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "A\148M\202\195\195\r\GS\240\235\193_b)\178\176\218-Z\176`\186\164\FSk\134\175", _willMsg = +// "4|gQ1\225\226&\214N\213\135\232\220Gm\242\172", _willProps = []}), _cleanSession = True, _keepAlive = 1343, _connID +// = "\162\&4og*T\SYN\194c\EOT\129~z\215\170\t\a\172\172xu", _properties = []} +TEST(Connect311QCTest, Encode81) { + uint8_t pkt[] = {0x10, 0x73, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x5, 0x3f, 0x0, 0x15, 0xa2, 0x34, 0x6f, + 0x67, 0x2a, 0x54, 0x16, 0xc2, 0x63, 0x4, 0x81, 0x7e, 0x7a, 0xd7, 0xaa, 0x9, 0x7, 0xac, 0xac, 0x78, + 0x75, 0x0, 0x1b, 0x41, 0x94, 0x4d, 0xca, 0xc3, 0xc3, 0xd, 0x1d, 0xf0, 0xeb, 0xc1, 0x5f, 0x62, 0x29, + 0xb2, 0xb0, 0xda, 0x2d, 0x5a, 0xb0, 0x60, 0xba, 0xa4, 0x1c, 0x6b, 0x86, 0xaf, 0x0, 0x12, 0x34, 0x7c, + 0x67, 0x51, 0x31, 0xe1, 0xe2, 0x26, 0xd6, 0x4e, 0xd5, 0x87, 0xe8, 0xdc, 0x47, 0x6d, 0xf2, 0xac, 0x0, + 0x1b, 0x50, 0xb2, 0xf3, 0xb7, 0xac, 0x89, 0xe8, 0xd4, 0xd, 0x7e, 0x4e, 0xfc, 0x91, 0xd4, 0x68, 0xe6, + 0x11, 0x90, 0x7a, 0x7d, 0xd1, 0x36, 0xf7, 0x10, 0xc0, 0x69, 0x71, 0x0, 0x2, 0x6d, 0x55}; + + uint8_t buf[127] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x41, 0x94, 0x4d, 0xca, 0xc3, 0xc3, 0xd, 0x1d, 0xf0, 0xeb, 0xc1, 0x5f, 0x62, 0x29, + 0xb2, 0xb0, 0xda, 0x2d, 0x5a, 0xb0, 0x60, 0xba, 0xa4, 0x1c, 0x6b, 0x86, 0xaf}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x34, 0x7c, 0x67, 0x51, 0x31, 0xe1, 0xe2, 0x26, 0xd6, + 0x4e, 0xd5, 0x87, 0xe8, 0xdc, 0x47, 0x6d, 0xf2, 0xac}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1343; + uint8_t client_id_bytes[] = {0xa2, 0x34, 0x6f, 0x67, 0x2a, 0x54, 0x16, 0xc2, 0x63, 0x4, 0x81, + 0x7e, 0x7a, 0xd7, 0xaa, 0x9, 0x7, 0xac, 0xac, 0x78, 0x75}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x50, 0xb2, 0xf3, 0xb7, 0xac, 0x89, 0xe8, 0xd4, 0xd, 0x7e, 0x4e, 0xfc, 0x91, 0xd4, + 0x68, 0xe6, 0x11, 0x90, 0x7a, 0x7d, 0xd1, 0x36, 0xf7, 0x10, 0xc0, 0x69, 0x71}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x6d, 0x55}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\r)\190_\138\DC4\SO\163\226j\189 +// ~*BN\SI\EOT-\217\128\232\223\239\129m\a\DLEG\254", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, +// _willTopic = "+\177\246\187~\133", _willMsg = "\151\189\&3\RS\175\198\166j", _willProps = []}), _cleanSession = +// False, _keepAlive = 4479, _connID = +// "\148\233\210e\EM\168\130\133\253\SOH\232\207f\173\220\238\167\166vG\v\141\190\";", _properties = []} +TEST(Connect311QCTest, Encode82) { + uint8_t pkt[] = {0x10, 0x37, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x11, 0x7f, 0x0, 0x19, 0x94, + 0xe9, 0xd2, 0x65, 0x19, 0xa8, 0x82, 0x85, 0xfd, 0x1, 0xe8, 0xcf, 0x66, 0xad, 0xdc, 0xee, + 0xa7, 0xa6, 0x76, 0x47, 0xb, 0x8d, 0xbe, 0x22, 0x3b, 0x0, 0x6, 0x2b, 0xb1, 0xf6, 0xbb, + 0x7e, 0x85, 0x0, 0x8, 0x97, 0xbd, 0x33, 0x1e, 0xaf, 0xc6, 0xa6, 0x6a}; + + uint8_t buf[67] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2b, 0xb1, 0xf6, 0xbb, 0x7e, 0x85}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x97, 0xbd, 0x33, 0x1e, 0xaf, 0xc6, 0xa6, 0x6a}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 4479; + uint8_t client_id_bytes[] = {0x94, 0xe9, 0xd2, 0x65, 0x19, 0xa8, 0x82, 0x85, 0xfd, 0x1, 0xe8, 0xcf, 0x66, + 0xad, 0xdc, 0xee, 0xa7, 0xa6, 0x76, 0x47, 0xb, 0x8d, 0xbe, 0x22, 0x3b}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xd, 0x29, 0xbe, 0x5f, 0x8a, 0x14, 0xe, 0xa3, 0xe2, 0x6a, 0xbd, 0x20, 0x7e, 0x2a, 0x42, + 0x4e, 0xf, 0x4, 0x2d, 0xd9, 0x80, 0xe8, 0xdf, 0xef, 0x81, 0x6d, 0x7, 0x10, 0x47, 0xfe}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\193=\216", _password = Nothing, _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 20616, _connID = "H\197jy\150\206eUf&\224\&9\ACK", _properties = []} +TEST(Connect311QCTest, Encode83) { + uint8_t pkt[] = {0x10, 0x1e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x82, 0x50, 0x88, 0x0, 0xd, 0x48, 0xc5, + 0x6a, 0x79, 0x96, 0xce, 0x65, 0x55, 0x66, 0x26, 0xe0, 0x39, 0x6, 0x0, 0x3, 0xc1, 0x3d, 0xd8}; + + uint8_t buf[42] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 20616; + uint8_t client_id_bytes[] = {0x48, 0xc5, 0x6a, 0x79, 0x96, 0xce, 0x65, 0x55, 0x66, 0x26, 0xe0, 0x39, 0x6}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xc1, 0x3d, 0xd8}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "\DLE\162\233\185\169\148\163\FS\DLE\DLE\EM\128\172$0\v\163\NAK\171\178o\152\247\162", _password = Just +// "\SYN)'\EMZ{&\170*\141\175\195\166\136\153%P\165\171Q\221Ps\200", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS1, _willTopic = +// "\179j\234\186\173`\r5\139\224\166\231v\170\206~\241\ENQ7\249\230\240\135\&2\249\173ou\130", _willMsg = +// "\184\198C\184", _willProps = []}), _cleanSession = True, _keepAlive = 23215, _connID = "'\ESC", _properties = []} +TEST(Connect311QCTest, Encode84) { + uint8_t pkt[] = {0x10, 0x67, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x5a, 0xaf, 0x0, 0x2, 0x27, + 0x1b, 0x0, 0x1d, 0xb3, 0x6a, 0xea, 0xba, 0xad, 0x60, 0xd, 0x35, 0x8b, 0xe0, 0xa6, 0xe7, + 0x76, 0xaa, 0xce, 0x7e, 0xf1, 0x5, 0x37, 0xf9, 0xe6, 0xf0, 0x87, 0x32, 0xf9, 0xad, 0x6f, + 0x75, 0x82, 0x0, 0x4, 0xb8, 0xc6, 0x43, 0xb8, 0x0, 0x18, 0x10, 0xa2, 0xe9, 0xb9, 0xa9, + 0x94, 0xa3, 0x1c, 0x10, 0x10, 0x19, 0x80, 0xac, 0x24, 0x30, 0xb, 0xa3, 0x15, 0xab, 0xb2, + 0x6f, 0x98, 0xf7, 0xa2, 0x0, 0x18, 0x16, 0x29, 0x27, 0x19, 0x5a, 0x7b, 0x26, 0xaa, 0x2a, + 0x8d, 0xaf, 0xc3, 0xa6, 0x88, 0x99, 0x25, 0x50, 0xa5, 0xab, 0x51, 0xdd, 0x50, 0x73, 0xc8}; + + uint8_t buf[115] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb3, 0x6a, 0xea, 0xba, 0xad, 0x60, 0xd, 0x35, 0x8b, 0xe0, + 0xa6, 0xe7, 0x76, 0xaa, 0xce, 0x7e, 0xf1, 0x5, 0x37, 0xf9, + 0xe6, 0xf0, 0x87, 0x32, 0xf9, 0xad, 0x6f, 0x75, 0x82}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb8, 0xc6, 0x43, 0xb8}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23215; + uint8_t client_id_bytes[] = {0x27, 0x1b}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x10, 0xa2, 0xe9, 0xb9, 0xa9, 0x94, 0xa3, 0x1c, 0x10, 0x10, 0x19, 0x80, + 0xac, 0x24, 0x30, 0xb, 0xa3, 0x15, 0xab, 0xb2, 0x6f, 0x98, 0xf7, 0xa2}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x16, 0x29, 0x27, 0x19, 0x5a, 0x7b, 0x26, 0xaa, 0x2a, 0x8d, 0xaf, 0xc3, + 0xa6, 0x88, 0x99, 0x25, 0x50, 0xa5, 0xab, 0x51, 0xdd, 0x50, 0x73, 0xc8}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\214", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS0, _willTopic = "\162\190\DC4\DC4\rt\172-\134\146\171Y\SUB\181GJ\232\223", _willMsg = "", _willProps = +// []}), _cleanSession = False, _keepAlive = 3268, _connID = +// "X\ENQ\249\146\ti\193j\128\159\242\ACK\200\143\vTWH]\156\DEL", _properties = []} +TEST(Connect311QCTest, Encode85) { + uint8_t pkt[] = {0x10, 0x37, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0xc, 0xc4, 0x0, 0x15, 0x58, + 0x5, 0xf9, 0x92, 0x9, 0x69, 0xc1, 0x6a, 0x80, 0x9f, 0xf2, 0x6, 0xc8, 0x8f, 0xb, 0x54, + 0x57, 0x48, 0x5d, 0x9c, 0x7f, 0x0, 0x12, 0xa2, 0xbe, 0x14, 0x14, 0xd, 0x74, 0xac, 0x2d, + 0x86, 0x92, 0xab, 0x59, 0x1a, 0xb5, 0x47, 0x4a, 0xe8, 0xdf, 0x0, 0x0}; + + uint8_t buf[67] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa2, 0xbe, 0x14, 0x14, 0xd, 0x74, 0xac, 0x2d, 0x86, + 0x92, 0xab, 0x59, 0x1a, 0xb5, 0x47, 0x4a, 0xe8, 0xdf}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3268; + uint8_t client_id_bytes[] = {0x58, 0x5, 0xf9, 0x92, 0x9, 0x69, 0xc1, 0x6a, 0x80, 0x9f, 0xf2, + 0x6, 0xc8, 0x8f, 0xb, 0x54, 0x57, 0x48, 0x5d, 0x9c, 0x7f}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xd6}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// ")\156AQ\231\191\SYN\185h\225\178\137\238\&3\EOT\138\248\&7R\EM,*\SYN=\n\224\DC2", _lastWill = Nothing, _cleanSession +// = True, _keepAlive = 28678, _connID = +// "\189\132\188/]\224s+\NULTF\196\233U\GS\250L\167\176\EM\133\NUL\254\161Ol\136\162\209", _properties = []} +TEST(Connect311QCTest, Encode86) { + uint8_t pkt[] = {0x10, 0x29, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x70, 0x6, 0x0, 0x1d, 0xbd, + 0x84, 0xbc, 0x2f, 0x5d, 0xe0, 0x73, 0x2b, 0x0, 0x54, 0x46, 0xc4, 0xe9, 0x55, 0x1d, 0xfa, + 0x4c, 0xa7, 0xb0, 0x19, 0x85, 0x0, 0xfe, 0xa1, 0x4f, 0x6c, 0x88, 0xa2, 0xd1}; + + uint8_t buf[53] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 28678; + uint8_t client_id_bytes[] = {0xbd, 0x84, 0xbc, 0x2f, 0x5d, 0xe0, 0x73, 0x2b, 0x0, 0x54, 0x46, 0xc4, 0xe9, 0x55, 0x1d, + 0xfa, 0x4c, 0xa7, 0xb0, 0x19, 0x85, 0x0, 0xfe, 0xa1, 0x4f, 0x6c, 0x88, 0xa2, 0xd1}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x29, 0x9c, 0x41, 0x51, 0xe7, 0xbf, 0x16, 0xb9, 0x68, 0xe1, 0xb2, 0x89, 0xee, 0x33, + 0x4, 0x8a, 0xf8, 0x37, 0x52, 0x19, 0x2c, 0x2a, 0x16, 0x3d, 0xa, 0xe0, 0x12}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\231\136\157", _password = Nothing, _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 27015, _connID = "c\202.c\142W#U\130p\148q(O\219m", _properties = []} +TEST(Connect311QCTest, Encode87) { + uint8_t pkt[] = {0x10, 0x21, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x82, 0x69, 0x87, + 0x0, 0x10, 0x63, 0xca, 0x2e, 0x63, 0x8e, 0x57, 0x23, 0x55, 0x82, 0x70, + 0x94, 0x71, 0x28, 0x4f, 0xdb, 0x6d, 0x0, 0x3, 0xe7, 0x88, 0x9d}; + + uint8_t buf[45] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 27015; + uint8_t client_id_bytes[] = {0x63, 0xca, 0x2e, 0x63, 0x8e, 0x57, 0x23, 0x55, + 0x82, 0x70, 0x94, 0x71, 0x28, 0x4f, 0xdb, 0x6d}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xe7, 0x88, 0x9d}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "U\185M\196", _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 28907, _connID = ";&\203q}", _properties = []} +TEST(Connect311QCTest, Encode88) { + uint8_t pkt[] = {0x10, 0x11, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, + 0x70, 0xeb, 0x0, 0x5, 0x3b, 0x26, 0xcb, 0x71, 0x7d}; + + uint8_t buf[29] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 28907; + uint8_t client_id_bytes[] = {0x3b, 0x26, 0xcb, 0x71, 0x7d}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x55, 0xb9, 0x4d, 0xc4}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "t\171o\168\ETB\EOT\EOT\226\b\SI\205\166J\SOj\164\ETB\SUB\166\245\US\SUB", _password +// = Just "\NAK\169_\251\NAK\186\DLE\215\169kW3J\b\199", _lastWill = Nothing, _cleanSession = False, _keepAlive = 28413, +// _connID = "\215\188:\SYN]?\n\214\176\&2i", _properties = []} +TEST(Connect311QCTest, Encode89) { + uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x6e, 0xfd, 0x0, 0xb, 0xd7, 0xbc, 0x3a, + 0x16, 0x5d, 0x3f, 0xa, 0xd6, 0xb0, 0x32, 0x69, 0x0, 0x16, 0x74, 0xab, 0x6f, 0xa8, 0x17, 0x4, 0x4, + 0xe2, 0x8, 0xf, 0xcd, 0xa6, 0x4a, 0xe, 0x6a, 0xa4, 0x17, 0x1a, 0xa6, 0xf5, 0x1f, 0x1a, 0x0, 0xf, + 0x15, 0xa9, 0x5f, 0xfb, 0x15, 0xba, 0x10, 0xd7, 0xa9, 0x6b, 0x57, 0x33, 0x4a, 0x8, 0xc7}; + + uint8_t buf[76] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 28413; + uint8_t client_id_bytes[] = {0xd7, 0xbc, 0x3a, 0x16, 0x5d, 0x3f, 0xa, 0xd6, 0xb0, 0x32, 0x69}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x74, 0xab, 0x6f, 0xa8, 0x17, 0x4, 0x4, 0xe2, 0x8, 0xf, 0xcd, + 0xa6, 0x4a, 0xe, 0x6a, 0xa4, 0x17, 0x1a, 0xa6, 0xf5, 0x1f, 0x1a}; + lwmqtt_string_t username = {22, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x15, 0xa9, 0x5f, 0xfb, 0x15, 0xba, 0x10, 0xd7, 0xa9, 0x6b, 0x57, 0x33, 0x4a, 0x8, 0xc7}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "M", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS1, _willTopic = "", _willMsg = "\163\147\EOT\177\219J\221\FSm_\STX\RS\rK\130D\159\n}", _willProps = []}), +// _cleanSession = True, _keepAlive = 6707, _connID = +// "\248\222\190\&6\US\171Z\135\192\253\DEL\205\US\238\ETXR\201|\SUB", _properties = []} +TEST(Connect311QCTest, Encode90) { + uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2e, 0x1a, 0x33, 0x0, 0x13, + 0xf8, 0xde, 0xbe, 0x36, 0x1f, 0xab, 0x5a, 0x87, 0xc0, 0xfd, 0x7f, 0xcd, 0x1f, 0xee, + 0x3, 0x52, 0xc9, 0x7c, 0x1a, 0x0, 0x0, 0x0, 0x13, 0xa3, 0x93, 0x4, 0xb1, 0xdb, + 0x4a, 0xdd, 0x1c, 0x6d, 0x5f, 0x2, 0x1e, 0xd, 0x4b, 0x82, 0x44, 0x9f, 0xa, 0x7d}; + + uint8_t buf[66] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa3, 0x93, 0x4, 0xb1, 0xdb, 0x4a, 0xdd, 0x1c, 0x6d, 0x5f, + 0x2, 0x1e, 0xd, 0x4b, 0x82, 0x44, 0x9f, 0xa, 0x7d}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 6707; + uint8_t client_id_bytes[] = {0xf8, 0xde, 0xbe, 0x36, 0x1f, 0xab, 0x5a, 0x87, 0xc0, 0xfd, + 0x7f, 0xcd, 0x1f, 0xee, 0x3, 0x52, 0xc9, 0x7c, 0x1a}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x4d}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\135\167", _password = Just "do\ETX\170V\239N\235\129|\168G\SO\218O\245SW\228", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\198\149\RSL\143\254\166!", _willMsg = +// ":\215\\\152\141^\ETXb\198", _willProps = []}), _cleanSession = True, _keepAlive = 1501, _connID = +// "\234YO\DC3;\148\207\&0\153n\199\142\146\206\254\155:", _properties = []} +TEST(Connect311QCTest, Encode91) { + uint8_t pkt[] = {0x10, 0x4b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x5, 0xdd, 0x0, 0x11, 0xea, 0x59, + 0x4f, 0x13, 0x3b, 0x94, 0xcf, 0x30, 0x99, 0x6e, 0xc7, 0x8e, 0x92, 0xce, 0xfe, 0x9b, 0x3a, 0x0, + 0x8, 0xc6, 0x95, 0x1e, 0x4c, 0x8f, 0xfe, 0xa6, 0x21, 0x0, 0x9, 0x3a, 0xd7, 0x5c, 0x98, 0x8d, + 0x5e, 0x3, 0x62, 0xc6, 0x0, 0x2, 0x87, 0xa7, 0x0, 0x13, 0x64, 0x6f, 0x3, 0xaa, 0x56, 0xef, + 0x4e, 0xeb, 0x81, 0x7c, 0xa8, 0x47, 0xe, 0xda, 0x4f, 0xf5, 0x53, 0x57, 0xe4}; + + uint8_t buf[87] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc6, 0x95, 0x1e, 0x4c, 0x8f, 0xfe, 0xa6, 0x21}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3a, 0xd7, 0x5c, 0x98, 0x8d, 0x5e, 0x3, 0x62, 0xc6}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1501; + uint8_t client_id_bytes[] = {0xea, 0x59, 0x4f, 0x13, 0x3b, 0x94, 0xcf, 0x30, 0x99, + 0x6e, 0xc7, 0x8e, 0x92, 0xce, 0xfe, 0x9b, 0x3a}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x87, 0xa7}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x64, 0x6f, 0x3, 0xaa, 0x56, 0xef, 0x4e, 0xeb, 0x81, 0x7c, + 0xa8, 0x47, 0xe, 0xda, 0x4f, 0xf5, 0x53, 0x57, 0xe4}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "J3\245R\234g\199\SUBe\f]Y\184\155\252O\131", _password = Just +// "N\130Z\162\174\221xV\181", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "L\149\222\209\ETB6\200tmGe\184\245\DLEg\135|\138v", _willMsg = +// "\240S\t;\152\130\197\DEL\227\191\221\138y|D\US\188\DC2\\\198@\207\&5\174\DC4w\GS1", _willProps = []}), _cleanSession +// = True, _keepAlive = 7620, _connID = "\180X\169B\252{L\217vd\b\249L\137\219\253\249W\166\245\152\SOnJJE\131\213", +// _properties = []} +TEST(Connect311QCTest, Encode92) { + uint8_t pkt[] = {0x10, 0x79, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x1d, 0xc4, 0x0, 0x1c, 0xb4, 0x58, + 0xa9, 0x42, 0xfc, 0x7b, 0x4c, 0xd9, 0x76, 0x64, 0x8, 0xf9, 0x4c, 0x89, 0xdb, 0xfd, 0xf9, 0x57, + 0xa6, 0xf5, 0x98, 0xe, 0x6e, 0x4a, 0x4a, 0x45, 0x83, 0xd5, 0x0, 0x13, 0x4c, 0x95, 0xde, 0xd1, + 0x17, 0x36, 0xc8, 0x74, 0x6d, 0x47, 0x65, 0xb8, 0xf5, 0x10, 0x67, 0x87, 0x7c, 0x8a, 0x76, 0x0, + 0x1c, 0xf0, 0x53, 0x9, 0x3b, 0x98, 0x82, 0xc5, 0x7f, 0xe3, 0xbf, 0xdd, 0x8a, 0x79, 0x7c, 0x44, + 0x1f, 0xbc, 0x12, 0x5c, 0xc6, 0x40, 0xcf, 0x35, 0xae, 0x14, 0x77, 0x1d, 0x31, 0x0, 0x11, 0x4a, + 0x33, 0xf5, 0x52, 0xea, 0x67, 0xc7, 0x1a, 0x65, 0xc, 0x5d, 0x59, 0xb8, 0x9b, 0xfc, 0x4f, 0x83, + 0x0, 0x9, 0x4e, 0x82, 0x5a, 0xa2, 0xae, 0xdd, 0x78, 0x56, 0xb5}; + + uint8_t buf[133] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4c, 0x95, 0xde, 0xd1, 0x17, 0x36, 0xc8, 0x74, 0x6d, 0x47, + 0x65, 0xb8, 0xf5, 0x10, 0x67, 0x87, 0x7c, 0x8a, 0x76}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf0, 0x53, 0x9, 0x3b, 0x98, 0x82, 0xc5, 0x7f, 0xe3, 0xbf, 0xdd, 0x8a, 0x79, 0x7c, + 0x44, 0x1f, 0xbc, 0x12, 0x5c, 0xc6, 0x40, 0xcf, 0x35, 0xae, 0x14, 0x77, 0x1d, 0x31}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 7620; + uint8_t client_id_bytes[] = {0xb4, 0x58, 0xa9, 0x42, 0xfc, 0x7b, 0x4c, 0xd9, 0x76, 0x64, 0x8, 0xf9, 0x4c, 0x89, + 0xdb, 0xfd, 0xf9, 0x57, 0xa6, 0xf5, 0x98, 0xe, 0x6e, 0x4a, 0x4a, 0x45, 0x83, 0xd5}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x4a, 0x33, 0xf5, 0x52, 0xea, 0x67, 0xc7, 0x1a, 0x65, + 0xc, 0x5d, 0x59, 0xb8, 0x9b, 0xfc, 0x4f, 0x83}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x4e, 0x82, 0x5a, 0xa2, 0xae, 0xdd, 0x78, 0x56, 0xb5}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\DC2\145\228\152*\178X", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\143\&2Gc]\253N\249\243\153\145\225\185\215sp\SOHs\192\221\&7{", +// _willMsg = "\NUL\211NA\197", _willProps = []}), _cleanSession = True, _keepAlive = 29972, _connID = +// "\ETB8\187\183q0\214H5\201\SI\199\183B\212u[\143\253\152\199W\EOT\206\149", _properties = []} +TEST(Connect311QCTest, Encode93) { + uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x75, 0x14, 0x0, 0x19, + 0x17, 0x38, 0xbb, 0xb7, 0x71, 0x30, 0xd6, 0x48, 0x35, 0xc9, 0xf, 0xc7, 0xb7, 0x42, + 0xd4, 0x75, 0x5b, 0x8f, 0xfd, 0x98, 0xc7, 0x57, 0x4, 0xce, 0x95, 0x0, 0x16, 0x8f, + 0x32, 0x47, 0x63, 0x5d, 0xfd, 0x4e, 0xf9, 0xf3, 0x99, 0x91, 0xe1, 0xb9, 0xd7, 0x73, + 0x70, 0x1, 0x73, 0xc0, 0xdd, 0x37, 0x7b, 0x0, 0x5, 0x0, 0xd3, 0x4e, 0x41, 0xc5}; + + uint8_t buf[80] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8f, 0x32, 0x47, 0x63, 0x5d, 0xfd, 0x4e, 0xf9, 0xf3, 0x99, 0x91, + 0xe1, 0xb9, 0xd7, 0x73, 0x70, 0x1, 0x73, 0xc0, 0xdd, 0x37, 0x7b}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x0, 0xd3, 0x4e, 0x41, 0xc5}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 29972; + uint8_t client_id_bytes[] = {0x17, 0x38, 0xbb, 0xb7, 0x71, 0x30, 0xd6, 0x48, 0x35, 0xc9, 0xf, 0xc7, 0xb7, + 0x42, 0xd4, 0x75, 0x5b, 0x8f, 0xfd, 0x98, 0xc7, 0x57, 0x4, 0xce, 0x95}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x12, 0x91, 0xe4, 0x98, 0x2a, 0xb2, 0x58}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just ",dA\164\202\NUL\161\212\169\183\&0", _password = Just "\CAN\SUB\238\&0", _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\GS\187\&5\157[*n\166\233S\168\&8\155\DC4\177$\168q\204\218\r\rJ", _willMsg = +// "\236[s\ESCz\217dW\STX\222\151\&0\SYNB\149\b\189fKjA", _willProps = []}), _cleanSession = True, _keepAlive = 488, +// _connID = "/\152\131mx1\208\&5", _properties = []} +TEST(Connect311QCTest, Encode94) { + uint8_t pkt[] = {0x10, 0x57, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x1, 0xe8, 0x0, 0x8, 0x2f, + 0x98, 0x83, 0x6d, 0x78, 0x31, 0xd0, 0x35, 0x0, 0x17, 0x1d, 0xbb, 0x35, 0x9d, 0x5b, 0x2a, + 0x6e, 0xa6, 0xe9, 0x53, 0xa8, 0x38, 0x9b, 0x14, 0xb1, 0x24, 0xa8, 0x71, 0xcc, 0xda, 0xd, + 0xd, 0x4a, 0x0, 0x15, 0xec, 0x5b, 0x73, 0x1b, 0x7a, 0xd9, 0x64, 0x57, 0x2, 0xde, 0x97, + 0x30, 0x16, 0x42, 0x95, 0x8, 0xbd, 0x66, 0x4b, 0x6a, 0x41, 0x0, 0xb, 0x2c, 0x64, 0x41, + 0xa4, 0xca, 0x0, 0xa1, 0xd4, 0xa9, 0xb7, 0x30, 0x0, 0x4, 0x18, 0x1a, 0xee, 0x30}; + + uint8_t buf[99] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1d, 0xbb, 0x35, 0x9d, 0x5b, 0x2a, 0x6e, 0xa6, 0xe9, 0x53, 0xa8, 0x38, + 0x9b, 0x14, 0xb1, 0x24, 0xa8, 0x71, 0xcc, 0xda, 0xd, 0xd, 0x4a}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xec, 0x5b, 0x73, 0x1b, 0x7a, 0xd9, 0x64, 0x57, 0x2, 0xde, 0x97, + 0x30, 0x16, 0x42, 0x95, 0x8, 0xbd, 0x66, 0x4b, 0x6a, 0x41}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 488; + uint8_t client_id_bytes[] = {0x2f, 0x98, 0x83, 0x6d, 0x78, 0x31, 0xd0, 0x35}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x2c, 0x64, 0x41, 0xa4, 0xca, 0x0, 0xa1, 0xd4, 0xa9, 0xb7, 0x30}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x18, 0x1a, 0xee, 0x30}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "ox\192\209\133\220~\DC29B\182\239=\196Sa[R\ETB\NUL\US\248E", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\214ht\202Q:u\DC3\190\SYN\SYN\246\225\130\232X\196k%\RSV*\144\154\215\184\227", _willMsg = "t +// \164\CAN)\191\132\223\226\201\230\149\253N\189\218\215\&4\182Gy\247y\201", _willProps = []}), _cleanSession = True, +// _keepAlive = 24570, _connID = "K\"%j\DLE\STXu~\ESC\236\178\204S\151(?\245\214w;\r\255\&5!", _properties = []} +TEST(Connect311QCTest, Encode95) { + uint8_t pkt[] = {0x10, 0x5b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x5f, 0xfa, 0x0, 0x18, 0x4b, 0x22, + 0x25, 0x6a, 0x10, 0x2, 0x75, 0x7e, 0x1b, 0xec, 0xb2, 0xcc, 0x53, 0x97, 0x28, 0x3f, 0xf5, 0xd6, + 0x77, 0x3b, 0xd, 0xff, 0x35, 0x21, 0x0, 0x1b, 0xd6, 0x68, 0x74, 0xca, 0x51, 0x3a, 0x75, 0x13, + 0xbe, 0x16, 0x16, 0xf6, 0xe1, 0x82, 0xe8, 0x58, 0xc4, 0x6b, 0x25, 0x1e, 0x56, 0x2a, 0x90, 0x9a, + 0xd7, 0xb8, 0xe3, 0x0, 0x18, 0x74, 0x20, 0xa4, 0x18, 0x29, 0xbf, 0x84, 0xdf, 0xe2, 0xc9, 0xe6, + 0x95, 0xfd, 0x4e, 0xbd, 0xda, 0xd7, 0x34, 0xb6, 0x47, 0x79, 0xf7, 0x79, 0xc9}; + + uint8_t buf[103] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd6, 0x68, 0x74, 0xca, 0x51, 0x3a, 0x75, 0x13, 0xbe, 0x16, 0x16, 0xf6, 0xe1, 0x82, + 0xe8, 0x58, 0xc4, 0x6b, 0x25, 0x1e, 0x56, 0x2a, 0x90, 0x9a, 0xd7, 0xb8, 0xe3}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x74, 0x20, 0xa4, 0x18, 0x29, 0xbf, 0x84, 0xdf, 0xe2, 0xc9, 0xe6, 0x95, + 0xfd, 0x4e, 0xbd, 0xda, 0xd7, 0x34, 0xb6, 0x47, 0x79, 0xf7, 0x79, 0xc9}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 24570; + uint8_t client_id_bytes[] = {0x4b, 0x22, 0x25, 0x6a, 0x10, 0x2, 0x75, 0x7e, 0x1b, 0xec, 0xb2, 0xcc, + 0x53, 0x97, 0x28, 0x3f, 0xf5, 0xd6, 0x77, 0x3b, 0xd, 0xff, 0x35, 0x21}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x6f, 0x78, 0xc0, 0xd1, 0x85, 0xdc, 0x7e, 0x12, 0x39, 0x42, 0xb6, 0xef, + 0x3d, 0xc4, 0x53, 0x61, 0x5b, 0x52, 0x17, 0x0, 0x1f, 0xf8, 0x45}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\157LD\210\143*\189\134\&0\231\250\253\DC3\210\ETXh\178", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "|\157\175oRO\236\200|s\252\165x\155\f\205{\227\229\134\251u\146\144\248.", _willMsg = +// "R\242;\DC1D\209@\146\213\194Qz\230\DC3\213\RSk`\189a5\DLE\245", _willProps = []}), _cleanSession = False, _keepAlive +// = 10064, _connID = "\192u\185\&3\177\222-3\142\DLE\172\172\163\242\228P\178\180\ETB\198]c\131", _properties = []} +TEST(Connect311QCTest, Encode96) { + uint8_t pkt[] = {0x10, 0x58, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x27, 0x50, 0x0, 0x17, 0xc0, + 0x75, 0xb9, 0x33, 0xb1, 0xde, 0x2d, 0x33, 0x8e, 0x10, 0xac, 0xac, 0xa3, 0xf2, 0xe4, 0x50, + 0xb2, 0xb4, 0x17, 0xc6, 0x5d, 0x63, 0x83, 0x0, 0x1a, 0x7c, 0x9d, 0xaf, 0x6f, 0x52, 0x4f, + 0xec, 0xc8, 0x7c, 0x73, 0xfc, 0xa5, 0x78, 0x9b, 0xc, 0xcd, 0x7b, 0xe3, 0xe5, 0x86, 0xfb, + 0x75, 0x92, 0x90, 0xf8, 0x2e, 0x0, 0x17, 0x52, 0xf2, 0x3b, 0x11, 0x44, 0xd1, 0x40, 0x92, + 0xd5, 0xc2, 0x51, 0x7a, 0xe6, 0x13, 0xd5, 0x1e, 0x6b, 0x60, 0xbd, 0x61, 0x35, 0x10, 0xf5}; + + uint8_t buf[100] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x7c, 0x9d, 0xaf, 0x6f, 0x52, 0x4f, 0xec, 0xc8, 0x7c, 0x73, 0xfc, 0xa5, 0x78, + 0x9b, 0xc, 0xcd, 0x7b, 0xe3, 0xe5, 0x86, 0xfb, 0x75, 0x92, 0x90, 0xf8, 0x2e}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x52, 0xf2, 0x3b, 0x11, 0x44, 0xd1, 0x40, 0x92, 0xd5, 0xc2, 0x51, 0x7a, + 0xe6, 0x13, 0xd5, 0x1e, 0x6b, 0x60, 0xbd, 0x61, 0x35, 0x10, 0xf5}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 10064; + uint8_t client_id_bytes[] = {0xc0, 0x75, 0xb9, 0x33, 0xb1, 0xde, 0x2d, 0x33, 0x8e, 0x10, 0xac, 0xac, + 0xa3, 0xf2, 0xe4, 0x50, 0xb2, 0xb4, 0x17, 0xc6, 0x5d, 0x63, 0x83}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x9d, 0x4c, 0x44, 0xd2, 0x8f, 0x2a, 0xbd, 0x86, 0x30, + 0xe7, 0xfa, 0xfd, 0x13, 0xd2, 0x3, 0x68, 0xb2}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\136a6\248", _password = Just "aW\205\150\ACK*\208", _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 27816, _connID = "\200\194\195y\163\178", _properties = []} +TEST(Connect311QCTest, Encode97) { + uint8_t pkt[] = {0x10, 0x21, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x6c, 0xa8, + 0x0, 0x6, 0xc8, 0xc2, 0xc3, 0x79, 0xa3, 0xb2, 0x0, 0x4, 0x88, 0x61, + 0x36, 0xf8, 0x0, 0x7, 0x61, 0x57, 0xcd, 0x96, 0x6, 0x2a, 0xd0}; + + uint8_t buf[45] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 27816; + uint8_t client_id_bytes[] = {0xc8, 0xc2, 0xc3, 0x79, 0xa3, 0xb2}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x88, 0x61, 0x36, 0xf8}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x61, 0x57, 0xcd, 0x96, 0x6, 0x2a, 0xd0}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Y2\vz\196.", _password = Just +// "Z+\195-\233*,\232\192\178w\"\201\188X\DELI\165\144\170\n\161bdTr", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = ":\152<\197\228\170\235[\NUL\207I\169=\149\NAK\225$\r\224\220\173\133EX", _willMsg = +// "E\225^YZ\STX\161\CANS\130>\215e\rU", _willProps = []}), _cleanSession = False, _keepAlive = 12906, _connID = +// "e\161\220F\196\187*\\H\151\188i\177\188\172\240", _properties = []} +TEST(Connect311QCTest, Encode98) { + uint8_t pkt[] = {0x10, 0x6b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x32, 0x6a, 0x0, 0x10, 0x65, 0xa1, + 0xdc, 0x46, 0xc4, 0xbb, 0x2a, 0x5c, 0x48, 0x97, 0xbc, 0x69, 0xb1, 0xbc, 0xac, 0xf0, 0x0, 0x18, + 0x3a, 0x98, 0x3c, 0xc5, 0xe4, 0xaa, 0xeb, 0x5b, 0x0, 0xcf, 0x49, 0xa9, 0x3d, 0x95, 0x15, 0xe1, + 0x24, 0xd, 0xe0, 0xdc, 0xad, 0x85, 0x45, 0x58, 0x0, 0xf, 0x45, 0xe1, 0x5e, 0x59, 0x5a, 0x2, + 0xa1, 0x18, 0x53, 0x82, 0x3e, 0xd7, 0x65, 0xd, 0x55, 0x0, 0x6, 0x59, 0x32, 0xb, 0x7a, 0xc4, + 0x2e, 0x0, 0x1a, 0x5a, 0x2b, 0xc3, 0x2d, 0xe9, 0x2a, 0x2c, 0xe8, 0xc0, 0xb2, 0x77, 0x22, 0xc9, + 0xbc, 0x58, 0x7f, 0x49, 0xa5, 0x90, 0xaa, 0xa, 0xa1, 0x62, 0x64, 0x54, 0x72}; + + uint8_t buf[119] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x3a, 0x98, 0x3c, 0xc5, 0xe4, 0xaa, 0xeb, 0x5b, 0x0, 0xcf, 0x49, 0xa9, + 0x3d, 0x95, 0x15, 0xe1, 0x24, 0xd, 0xe0, 0xdc, 0xad, 0x85, 0x45, 0x58}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x45, 0xe1, 0x5e, 0x59, 0x5a, 0x2, 0xa1, 0x18, + 0x53, 0x82, 0x3e, 0xd7, 0x65, 0xd, 0x55}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 12906; + uint8_t client_id_bytes[] = {0x65, 0xa1, 0xdc, 0x46, 0xc4, 0xbb, 0x2a, 0x5c, + 0x48, 0x97, 0xbc, 0x69, 0xb1, 0xbc, 0xac, 0xf0}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x59, 0x32, 0xb, 0x7a, 0xc4, 0x2e}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x5a, 0x2b, 0xc3, 0x2d, 0xe9, 0x2a, 0x2c, 0xe8, 0xc0, 0xb2, 0x77, 0x22, 0xc9, + 0xbc, 0x58, 0x7f, 0x49, 0xa5, 0x90, 0xaa, 0xa, 0xa1, 0x62, 0x64, 0x54, 0x72}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 19412, _connID = "\188=\183\NAK\DLE~\SYN\241", _properties = []} +TEST(Connect311QCTest, Encode99) { + uint8_t pkt[] = {0x10, 0x14, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x4b, + 0xd4, 0x0, 0x8, 0xbc, 0x3d, 0xb7, 0x15, 0x10, 0x7e, 0x16, 0xf1}; + + uint8_t buf[32] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 19412; + uint8_t client_id_bytes[] = {0xbc, 0x3d, 0xb7, 0x15, 0x10, 0x7e, 0x16, 0xf1}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\213Z6\DC4\128\136\188%", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = "|\RS\164\178\193a", _willMsg = +// "O\197\240\214\DC1$j5y^\EM\222\253+\DC1\147}", _willProps = []}), _cleanSession = True, _keepAlive = 19592, _connID = +// "\132\175\ETX\n\219\137\SI\183V\196\219\251\145t\244\200AZ[\156\a\212\252\177\154\245%@\249", _properties = []} +TEST(Connect311QCTest, Encode100) { + uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xae, 0x4c, 0x88, 0x0, 0x1d, 0x84, 0xaf, + 0x3, 0xa, 0xdb, 0x89, 0xf, 0xb7, 0x56, 0xc4, 0xdb, 0xfb, 0x91, 0x74, 0xf4, 0xc8, 0x41, 0x5a, + 0x5b, 0x9c, 0x7, 0xd4, 0xfc, 0xb1, 0x9a, 0xf5, 0x25, 0x40, 0xf9, 0x0, 0x6, 0x7c, 0x1e, 0xa4, + 0xb2, 0xc1, 0x61, 0x0, 0x11, 0x4f, 0xc5, 0xf0, 0xd6, 0x11, 0x24, 0x6a, 0x35, 0x79, 0x5e, 0x19, + 0xde, 0xfd, 0x2b, 0x11, 0x93, 0x7d, 0x0, 0x8, 0xd5, 0x5a, 0x36, 0x14, 0x80, 0x88, 0xbc, 0x25}; + + uint8_t buf[90] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x7c, 0x1e, 0xa4, 0xb2, 0xc1, 0x61}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4f, 0xc5, 0xf0, 0xd6, 0x11, 0x24, 0x6a, 0x35, 0x79, + 0x5e, 0x19, 0xde, 0xfd, 0x2b, 0x11, 0x93, 0x7d}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 19592; + uint8_t client_id_bytes[] = {0x84, 0xaf, 0x3, 0xa, 0xdb, 0x89, 0xf, 0xb7, 0x56, 0xc4, 0xdb, 0xfb, 0x91, 0x74, 0xf4, + 0xc8, 0x41, 0x5a, 0x5b, 0x9c, 0x7, 0xd4, 0xfc, 0xb1, 0x9a, 0xf5, 0x25, 0x40, 0xf9}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xd5, 0x5a, 0x36, 0x14, 0x80, 0x88, 0xbc, 0x25}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "F\171\131\SI\DC4\132\f\236\247\252", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\246\240", _willMsg = +// "\169\154\b\180\t3\183\199\&9\250\194", _willProps = [PropServerKeepAlive 10579,PropTopicAliasMaximum +// 32315,PropPayloadFormatIndicator 155,PropTopicAliasMaximum 4930,PropServerKeepAlive 17639,PropServerReference +// "u3\DC3~\157\133\235\254\208\177\SI\224>\ESCqM\155-\252\233F\CAN\GS\216&\EOT\235\&1z",PropWildcardSubscriptionAvailable +// 229,PropServerReference "\252NS\232\153\255\US\NAK\171\168\227\232\n\208\208\200",PropSubscriptionIdentifierAvailable +// 182,PropResponseInformation "\191",PropWildcardSubscriptionAvailable 52,PropAssignedClientIdentifier +// "\DLE\227\&8T\182J\"m;",PropReasonString +// "g\167i\254\232\166\198#\179\185Z\r\128\247\251hd\243\170\&7",PropRetainAvailable 68,PropReceiveMaximum +// 13425,PropWildcardSubscriptionAvailable 85,PropResponseInformation +// "3\212\219\SOH\201v5+\SUB\150\STX",PropRequestResponseInformation 166,PropReceiveMaximum 21964]}), _cleanSession = +// True, _keepAlive = 3250, _connID = " \241\DC2\ACK\157\190\v\161\205=\\\156dS\184{", _properties = []} +TEST(Connect5QCTest, Encode1) { + uint8_t pkt[] = { + 0x10, 0xb8, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0xc, 0xb2, 0x0, 0x0, 0x10, 0x20, 0xf1, 0x12, + 0x6, 0x9d, 0xbe, 0xb, 0xa1, 0xcd, 0x3d, 0x5c, 0x9c, 0x64, 0x53, 0xb8, 0x7b, 0x88, 0x1, 0x13, 0x29, 0x53, 0x22, + 0x7e, 0x3b, 0x1, 0x9b, 0x22, 0x13, 0x42, 0x13, 0x44, 0xe7, 0x1c, 0x0, 0x1d, 0x75, 0x33, 0x13, 0x7e, 0x9d, 0x85, + 0xeb, 0xfe, 0xd0, 0xb1, 0xf, 0xe0, 0x3e, 0x1b, 0x71, 0x4d, 0x9b, 0x2d, 0xfc, 0xe9, 0x46, 0x18, 0x1d, 0xd8, 0x26, + 0x4, 0xeb, 0x31, 0x7a, 0x28, 0xe5, 0x1c, 0x0, 0x10, 0xfc, 0x4e, 0x53, 0xe8, 0x99, 0xff, 0x1f, 0x15, 0xab, 0xa8, + 0xe3, 0xe8, 0xa, 0xd0, 0xd0, 0xc8, 0x29, 0xb6, 0x1a, 0x0, 0x1, 0xbf, 0x28, 0x34, 0x12, 0x0, 0x9, 0x10, 0xe3, + 0x38, 0x54, 0xb6, 0x4a, 0x22, 0x6d, 0x3b, 0x1f, 0x0, 0x14, 0x67, 0xa7, 0x69, 0xfe, 0xe8, 0xa6, 0xc6, 0x23, 0xb3, + 0xb9, 0x5a, 0xd, 0x80, 0xf7, 0xfb, 0x68, 0x64, 0xf3, 0xaa, 0x37, 0x25, 0x44, 0x21, 0x34, 0x71, 0x28, 0x55, 0x1a, + 0x0, 0xb, 0x33, 0xd4, 0xdb, 0x1, 0xc9, 0x76, 0x35, 0x2b, 0x1a, 0x96, 0x2, 0x19, 0xa6, 0x21, 0x55, 0xcc, 0x0, + 0x2, 0xf6, 0xf0, 0x0, 0xb, 0xa9, 0x9a, 0x8, 0xb4, 0x9, 0x33, 0xb7, 0xc7, 0x39, 0xfa, 0xc2}; + + uint8_t buf[197] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x75, 0x33, 0x13, 0x7e, 0x9d, 0x85, 0xeb, 0xfe, 0xd0, 0xb1, 0xf, 0xe0, 0x3e, 0x1b, 0x71, + 0x4d, 0x9b, 0x2d, 0xfc, 0xe9, 0x46, 0x18, 0x1d, 0xd8, 0x26, 0x4, 0xeb, 0x31, 0x7a}; + uint8_t byteswillprops1[] = {0xfc, 0x4e, 0x53, 0xe8, 0x99, 0xff, 0x1f, 0x15, + 0xab, 0xa8, 0xe3, 0xe8, 0xa, 0xd0, 0xd0, 0xc8}; + uint8_t byteswillprops2[] = {0xbf}; + uint8_t byteswillprops3[] = {0x10, 0xe3, 0x38, 0x54, 0xb6, 0x4a, 0x22, 0x6d, 0x3b}; + uint8_t byteswillprops4[] = {0x67, 0xa7, 0x69, 0xfe, 0xe8, 0xa6, 0xc6, 0x23, 0xb3, 0xb9, + 0x5a, 0xd, 0x80, 0xf7, 0xfb, 0x68, 0x64, 0xf3, 0xaa, 0x37}; + uint8_t byteswillprops5[] = {0x33, 0xd4, 0xdb, 0x1, 0xc9, 0x76, 0x35, 0x2b, 0x1a, 0x96, 0x2}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10579}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32315}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4930}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17639}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13425}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21964}}, + }; + + lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf6, 0xf0}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa9, 0x9a, 0x8, 0xb4, 0x9, 0x33, 0xb7, 0xc7, 0x39, 0xfa, 0xc2}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 3250; + uint8_t client_id_bytes[] = {0x20, 0xf1, 0x12, 0x6, 0x9d, 0xbe, 0xb, 0xa1, + 0xcd, 0x3d, 0x5c, 0x9c, 0x64, 0x53, 0xb8, 0x7b}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x46, 0xab, 0x83, 0xf, 0x14, 0x84, 0xc, 0xec, 0xf7, 0xfc}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\185\211\STX\225\EOT\134\DC4\DC2", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "y\133\f\222\RS\142", _willMsg = +// "\252\142\185\165\252\211e|\US\228\205\SYN\193\227\255\173\EOT$", _willProps = [PropTopicAliasMaximum +// 13488,PropPayloadFormatIndicator 204,PropSessionExpiryInterval 32098,PropMaximumQoS 149,PropResponseTopic +// "\161#\151O\188\187",PropResponseTopic "\ENQ\f\SO\ETX\200\NUL\196\137V\173HO\170R<",PropSharedSubscriptionAvailable +// 177,PropContentType "",PropSubscriptionIdentifier 6,PropRetainAvailable 121,PropMaximumQoS 0,PropReceiveMaximum +// 18726,PropAuthenticationData +// "\194\DLE\239U\170\b\197\234[\210\b\141\156\242\136,%:\245\212\ETX8",PropMaximumPacketSize 16300,PropServerKeepAlive +// 29904,PropMaximumPacketSize 3698,PropTopicAlias 6587,PropWildcardSubscriptionAvailable 175,PropMaximumPacketSize +// 20654,PropReceiveMaximum 20352,PropRetainAvailable 170,PropSubscriptionIdentifier 7,PropPayloadFormatIndicator +// 143,PropResponseTopic "\252H\151s\248=\209\175>\128\133\186\150eq1g\224ht\SOH\223\168>\DC2",PropTopicAliasMaximum +// 30495,PropSubscriptionIdentifierAvailable 49,PropSubscriptionIdentifierAvailable 126]}), _cleanSession = False, +// _keepAlive = 15842, _connID = "", _properties = [PropSubscriptionIdentifierAvailable 221,PropResponseInformation +// "\197\158\218\225\175\251\166\207\156_Dq\238*\223",PropReceiveMaximum 28123,PropSubscriptionIdentifier +// 22,PropWildcardSubscriptionAvailable 143,PropMessageExpiryInterval 25705,PropAssignedClientIdentifier +// "\236\ETXO",PropRequestResponseInformation 187,PropTopicAlias 10652,PropPayloadFormatIndicator 166,PropReceiveMaximum +// 4455,PropMessageExpiryInterval 9441,PropMessageExpiryInterval 27038,PropMessageExpiryInterval +// 19854,PropRequestProblemInformation 43,PropTopicAlias 1994,PropContentType +// "0K\218\NAK\187\180\213",PropServerKeepAlive 4973,PropSessionExpiryInterval 30803,PropRequestResponseInformation +// 104,PropResponseTopic "\203\US\230\154\176\FS?\138\235\226\ACK\141&i\161\250",PropPayloadFormatIndicator +// 69,PropContentType +// "n\DC2\201<\143K\205\EM\139\252h\223\171\250\174\161~*vBw:\DC1\255\135\FS\159",PropAssignedClientIdentifier +// "\171%\176q\186\&0\225\247\&8q\ACK\144\ESC0\211wC\167\r\ACK",PropTopicAlias 11156,PropContentType +// "\204&\217~cc\185\212zoU\220\156\201\234m\243[,\158\131W\223\236",PropMaximumQoS 255,PropAuthenticationData +// ">\f7j\201\186\146d_\224\212\192\163\183\141'\SOH\242\EOT\132\226\243l\232?T",PropMaximumPacketSize +// 12789,PropPayloadFormatIndicator 23]} +TEST(Connect5QCTest, Encode2) { + uint8_t pkt[] = { + 0x10, 0xad, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x84, 0x3d, 0xe2, 0xe6, 0x1, 0x29, 0xdd, 0x1a, 0x0, + 0xf, 0xc5, 0x9e, 0xda, 0xe1, 0xaf, 0xfb, 0xa6, 0xcf, 0x9c, 0x5f, 0x44, 0x71, 0xee, 0x2a, 0xdf, 0x21, 0x6d, 0xdb, + 0xb, 0x16, 0x28, 0x8f, 0x2, 0x0, 0x0, 0x64, 0x69, 0x12, 0x0, 0x3, 0xec, 0x3, 0x4f, 0x19, 0xbb, 0x23, 0x29, + 0x9c, 0x1, 0xa6, 0x21, 0x11, 0x67, 0x2, 0x0, 0x0, 0x24, 0xe1, 0x2, 0x0, 0x0, 0x69, 0x9e, 0x2, 0x0, 0x0, + 0x4d, 0x8e, 0x17, 0x2b, 0x23, 0x7, 0xca, 0x3, 0x0, 0x7, 0x30, 0x4b, 0xda, 0x15, 0xbb, 0xb4, 0xd5, 0x13, 0x13, + 0x6d, 0x11, 0x0, 0x0, 0x78, 0x53, 0x19, 0x68, 0x8, 0x0, 0x10, 0xcb, 0x1f, 0xe6, 0x9a, 0xb0, 0x1c, 0x3f, 0x8a, + 0xeb, 0xe2, 0x6, 0x8d, 0x26, 0x69, 0xa1, 0xfa, 0x1, 0x45, 0x3, 0x0, 0x1b, 0x6e, 0x12, 0xc9, 0x3c, 0x8f, 0x4b, + 0xcd, 0x19, 0x8b, 0xfc, 0x68, 0xdf, 0xab, 0xfa, 0xae, 0xa1, 0x7e, 0x2a, 0x76, 0x42, 0x77, 0x3a, 0x11, 0xff, 0x87, + 0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0x19, + 0xbb, 0x28, 0xaf, 0x27, 0x0, 0x0, 0x50, 0xae, 0x21, 0x4f, 0x80, 0x25, 0xaa, 0xb, 0x7, 0x1, 0x8f, 0x8, 0x0, + 0x19, 0xfc, 0x48, 0x97, 0x73, 0xf8, 0x3d, 0xd1, 0xaf, 0x3e, 0x80, 0x85, 0xba, 0x96, 0x65, 0x71, 0x31, 0x67, 0xe0, + 0x68, 0x74, 0x1, 0xdf, 0xa8, 0x3e, 0x12, 0x22, 0x77, 0x1f, 0x29, 0x31, 0x29, 0x7e, 0x0, 0x6, 0x79, 0x85, 0xc, + 0xde, 0x1e, 0x8e, 0x0, 0x12, 0xfc, 0x8e, 0xb9, 0xa5, 0xfc, 0xd3, 0x65, 0x7c, 0x1f, 0xe4, 0xcd, 0x16, 0xc1, 0xe3, + 0xff, 0xad, 0x4, 0x24, 0x0, 0x8, 0xb9, 0xd3, 0x2, 0xe1, 0x4, 0x86, 0x14, 0x12}; + + uint8_t buf[442] = {0}; + + uint8_t bytesprops0[] = {0xc5, 0x9e, 0xda, 0xe1, 0xaf, 0xfb, 0xa6, 0xcf, 0x9c, 0x5f, 0x44, 0x71, 0xee, 0x2a, 0xdf}; + uint8_t bytesprops1[] = {0xec, 0x3, 0x4f}; + uint8_t bytesprops2[] = {0x30, 0x4b, 0xda, 0x15, 0xbb, 0xb4, 0xd5}; + uint8_t bytesprops3[] = {0xcb, 0x1f, 0xe6, 0x9a, 0xb0, 0x1c, 0x3f, 0x8a, + 0xeb, 0xe2, 0x6, 0x8d, 0x26, 0x69, 0xa1, 0xfa}; + uint8_t bytesprops4[] = {0x6e, 0x12, 0xc9, 0x3c, 0x8f, 0x4b, 0xcd, 0x19, 0x8b, 0xfc, 0x68, 0xdf, 0xab, 0xfa, + 0xae, 0xa1, 0x7e, 0x2a, 0x76, 0x42, 0x77, 0x3a, 0x11, 0xff, 0x87, 0x1c, 0x9f}; + uint8_t bytesprops5[] = {0xab, 0x25, 0xb0, 0x71, 0xba, 0x30, 0xe1, 0xf7, 0x38, 0x71, + 0x6, 0x90, 0x1b, 0x30, 0xd3, 0x77, 0x43, 0xa7, 0xd, 0x6}; + uint8_t bytesprops6[] = {0xcc, 0x26, 0xd9, 0x7e, 0x63, 0x63, 0xb9, 0xd4, 0x7a, 0x6f, 0x55, 0xdc, + 0x9c, 0xc9, 0xea, 0x6d, 0xf3, 0x5b, 0x2c, 0x9e, 0x83, 0x57, 0xdf, 0xec}; + uint8_t bytesprops7[] = {0x3e, 0xc, 0x37, 0x6a, 0xc9, 0xba, 0x92, 0x64, 0x5f, 0xe0, 0xd4, 0xc0, 0xa3, + 0xb7, 0x8d, 0x27, 0x1, 0xf2, 0x4, 0x84, 0xe2, 0xf3, 0x6c, 0xe8, 0x3f, 0x54}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28123}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25705}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10652}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4455}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9441}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27038}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19854}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1994}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4973}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30803}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11156}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12789}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, + }; + + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xa1, 0x23, 0x97, 0x4f, 0xbc, 0xbb}; + uint8_t byteswillprops1[] = {0x5, 0xc, 0xe, 0x3, 0xc8, 0x0, 0xc4, 0x89, 0x56, 0xad, 0x48, 0x4f, 0xaa, 0x52, 0x3c}; + uint8_t byteswillprops2[] = {0}; + uint8_t byteswillprops3[] = {0xc2, 0x10, 0xef, 0x55, 0xaa, 0x8, 0xc5, 0xea, 0x5b, 0xd2, 0x8, + 0x8d, 0x9c, 0xf2, 0x88, 0x2c, 0x25, 0x3a, 0xf5, 0xd4, 0x3, 0x38}; + uint8_t byteswillprops4[] = {0xfc, 0x48, 0x97, 0x73, 0xf8, 0x3d, 0xd1, 0xaf, 0x3e, 0x80, 0x85, 0xba, 0x96, + 0x65, 0x71, 0x31, 0x67, 0xe0, 0x68, 0x74, 0x1, 0xdf, 0xa8, 0x3e, 0x12}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13488}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32098}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18726}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16300}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29904}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3698}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6587}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20654}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20352}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30495}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, + }; + + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x79, 0x85, 0xc, 0xde, 0x1e, 0x8e}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfc, 0x8e, 0xb9, 0xa5, 0xfc, 0xd3, 0x65, 0x7c, 0x1f, + 0xe4, 0xcd, 0x16, 0xc1, 0xe3, 0xff, 0xad, 0x4, 0x24}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 15842; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xb9, 0xd3, 0x2, 0xe1, 0x4, 0x86, 0x14, 0x12}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "eb:\159\169fA~\133\\\r6A7\139\&2\174\229Ue", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\255\245V\194\148\209\GS\f\218\140\201\EM/;H\146\135\176\253}\184\207V7.", _willMsg = +// "\SOH11\t\238\217?\210\\\EOT\223k\192\250?\156\178<\236+\SIQ\209\ACK\177\204\163", _willProps = +// [PropSessionExpiryInterval 26338,PropMessageExpiryInterval 482,PropWillDelayInterval +// 26497,PropRequestResponseInformation 255,PropSharedSubscriptionAvailable 121,PropMessageExpiryInterval +// 31822,PropRetainAvailable 10,PropAuthenticationData +// "\194\224\156f}\240\RSe\228\233JE\177s\133\ETB6\233P\NAK\n",PropRetainAvailable 150,PropSessionExpiryInterval +// 52,PropMaximumPacketSize 1043,PropReasonString "=(Q6\153\153H\167\151Q\217;\189\188F",PropResponseInformation +// "\196Z\175:\252\193Jd^]",PropTopicAliasMaximum 13915,PropAssignedClientIdentifier +// "\n\ETB\185z",PropResponseInformation "\144\SYN\182\ESC`\186\ETB\SO\137A\SO9Ix\SO\164yG",PropResponseInformation +// "F*O\232\147HTs\b\146?\146\EOT-\216\NAK\249\176\196\170\134s\248\&4\136\225\249\226\&2\134",PropWillDelayInterval +// 19003,PropResponseInformation "Z\143#\189\213V\174J\vn\SUB\228\186\230N\149A\165\156\&3",PropRetainAvailable +// 144,PropAssignedClientIdentifier "\161T\206\166%~+B\137B\SYN6\ACK\234"]}), _cleanSession = False, _keepAlive = 29642, +// _connID = "\212eR", _properties = [PropReceiveMaximum 17349]} +TEST(Connect5QCTest, Encode3) { + uint8_t pkt[] = { + 0x10, 0x99, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2c, 0x73, 0xca, 0x3, 0x21, 0x43, 0xc5, 0x0, 0x3, + 0xd4, 0x65, 0x52, 0xcc, 0x1, 0x11, 0x0, 0x0, 0x66, 0xe2, 0x2, 0x0, 0x0, 0x1, 0xe2, 0x18, 0x0, 0x0, 0x67, + 0x81, 0x19, 0xff, 0x2a, 0x79, 0x2, 0x0, 0x0, 0x7c, 0x4e, 0x25, 0xa, 0x16, 0x0, 0x15, 0xc2, 0xe0, 0x9c, 0x66, + 0x7d, 0xf0, 0x1e, 0x65, 0xe4, 0xe9, 0x4a, 0x45, 0xb1, 0x73, 0x85, 0x17, 0x36, 0xe9, 0x50, 0x15, 0xa, 0x25, 0x96, + 0x11, 0x0, 0x0, 0x0, 0x34, 0x27, 0x0, 0x0, 0x4, 0x13, 0x1f, 0x0, 0xf, 0x3d, 0x28, 0x51, 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 0x51, 0xd1, 0x6, 0xb1, 0xcc, 0xa3}; + + uint8_t buf[294] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17349}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xc2, 0xe0, 0x9c, 0x66, 0x7d, 0xf0, 0x1e, 0x65, 0xe4, 0xe9, 0x4a, + 0x45, 0xb1, 0x73, 0x85, 0x17, 0x36, 0xe9, 0x50, 0x15, 0xa}; + uint8_t byteswillprops1[] = {0x3d, 0x28, 0x51, 0x36, 0x99, 0x99, 0x48, 0xa7, + 0x97, 0x51, 0xd9, 0x3b, 0xbd, 0xbc, 0x46}; + uint8_t byteswillprops2[] = {0xc4, 0x5a, 0xaf, 0x3a, 0xfc, 0xc1, 0x4a, 0x64, 0x5e, 0x5d}; + uint8_t byteswillprops3[] = {0xa, 0x17, 0xb9, 0x7a}; + uint8_t byteswillprops4[] = {0x90, 0x16, 0xb6, 0x1b, 0x60, 0xba, 0x17, 0xe, 0x89, + 0x41, 0xe, 0x39, 0x49, 0x78, 0xe, 0xa4, 0x79, 0x47}; + uint8_t byteswillprops5[] = {0x46, 0x2a, 0x4f, 0xe8, 0x93, 0x48, 0x54, 0x73, 0x8, 0x92, + 0x3f, 0x92, 0x4, 0x2d, 0xd8, 0x15, 0xf9, 0xb0, 0xc4, 0xaa, + 0x86, 0x73, 0xf8, 0x34, 0x88, 0xe1, 0xf9, 0xe2, 0x32, 0x86}; + uint8_t byteswillprops6[] = {0x5a, 0x8f, 0x23, 0xbd, 0xd5, 0x56, 0xae, 0x4a, 0xb, 0x6e, + 0x1a, 0xe4, 0xba, 0xe6, 0x4e, 0x95, 0x41, 0xa5, 0x9c, 0x33}; + uint8_t byteswillprops7[] = {0xa1, 0x54, 0xce, 0xa6, 0x25, 0x7e, 0x2b, 0x42, 0x89, 0x42, 0x16, 0x36, 0x6, 0xea}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26338}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 482}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26497}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31822}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 52}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1043}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13915}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19003}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops7}}}, + }; + + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xff, 0xf5, 0x56, 0xc2, 0x94, 0xd1, 0x1d, 0xc, 0xda, 0x8c, 0xc9, 0x19, 0x2f, + 0x3b, 0x48, 0x92, 0x87, 0xb0, 0xfd, 0x7d, 0xb8, 0xcf, 0x56, 0x37, 0x2e}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1, 0x31, 0x31, 0x9, 0xee, 0xd9, 0x3f, 0xd2, 0x5c, 0x4, 0xdf, 0x6b, 0xc0, 0xfa, + 0x3f, 0x9c, 0xb2, 0x3c, 0xec, 0x2b, 0xf, 0x51, 0xd1, 0x6, 0xb1, 0xcc, 0xa3}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 29642; + uint8_t client_id_bytes[] = {0xd4, 0x65, 0x52}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x65, 0x62, 0x3a, 0x9f, 0xa9, 0x66, 0x41, 0x7e, 0x85, 0x5c, + 0xd, 0x36, 0x41, 0x37, 0x8b, 0x32, 0xae, 0xe5, 0x55, 0x65}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "\197\244\208\172eI\158\208\&4\a\235\DC4\182d\132\GS\189\130O\128\228\192 ", _willMsg = +// "\162T\168%T\161[\138\\\156~t\191\154\206\ETX", _willProps = [PropSharedSubscriptionAvailable +// 43,PropAssignedClientIdentifier +// "\151_\230h\aq}\US\DC1\150\190&\233\165y<\233\227\149\235\\!\DC1\186\254\208~\210",PropAuthenticationMethod +// "\128\\\158v\216}\183)\RS?\227\216\178D\ETB\US\246\153\a^za\202\152@",PropTopicAliasMaximum 14418,PropCorrelationData +// "[\188\234?\ETX\\",PropReceiveMaximum 29737,PropAuthenticationMethod +// "\207\157\198U\DC23\FS\137D\168\194\178\197,V\DC3\222Y\219\251\133.\SYN",PropPayloadFormatIndicator +// 164,PropTopicAlias 845,PropReceiveMaximum 23247,PropServerKeepAlive 6641,PropServerReference +// "\223\144\143=",PropServerKeepAlive 8003,PropAuthenticationMethod "\DC4\255\223i\148",PropWillDelayInterval +// 19857,PropContentType "\GS\v*,\184P\242-",PropUserProperty "\139[" "",PropMessageExpiryInterval 4340]}), +// _cleanSession = False, _keepAlive = 5339, _connID = "\194\163\154\203\EOTLMG`#\161l", _properties = [PropReasonString +// "\FS\203\156\EM\157nb\215\ETB\220\178\218\167\DC2\237\DC2\183\\b\CANR+g ",PropServerReference +// "\171\155\234\219?T\NUL\149o\192\234",PropAssignedClientIdentifier +// "i\210\&6\233\216\228\NAKf|\197\245",PropResponseInformation +// "'\185\237C\232g\163\183}\155'\198*%\204r\131",PropSubscriptionIdentifier 20,PropWildcardSubscriptionAvailable +// 62,PropResponseTopic "\225VS\179\DEL\"f\181O\149\164=\SOH\145",PropTopicAlias 28388,PropRequestResponseInformation +// 169,PropReceiveMaximum 20392,PropRequestProblemInformation 88,PropMessageExpiryInterval +// 9798,PropRequestProblemInformation 72,PropRetainAvailable 245,PropAuthenticationMethod " +// \136\205\&2\249\147\234\SOH(\185\183\SO\174\214V\132",PropUserProperty "\217\182dn\209j~\215\FS\211\203\205\192" +// "\DC1j\245x\NAK\176\206\188\192\251\149;\180}\DC3\195\NAK",PropTopicAliasMaximum 14104,PropTopicAliasMaximum +// 3973,PropReceiveMaximum 14160,PropWildcardSubscriptionAvailable 78,PropSubscriptionIdentifierAvailable +// 175,PropSessionExpiryInterval 31059,PropReceiveMaximum 29504,PropSessionExpiryInterval +// 27510,PropAssignedClientIdentifier ".\251M+0\162\fT\227\&8\"\141E&\186\t",PropResponseTopic +// "\158\DC2\160$\SUB\244\214"]} +TEST(Connect5QCTest, Encode4) { + uint8_t pkt[] = { + 0x10, 0xc6, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x24, 0x14, 0xdb, 0xe0, 0x1, 0x1f, 0x0, 0x18, 0x1c, + 0xcb, 0x9c, 0x19, 0x9d, 0x6e, 0x62, 0xd7, 0x17, 0xdc, 0xb2, 0xda, 0xa7, 0x12, 0xed, 0x12, 0xb7, 0x5c, 0x62, 0x18, + 0x52, 0x2b, 0x67, 0x20, 0x1c, 0x0, 0xb, 0xab, 0x9b, 0xea, 0xdb, 0x3f, 0x54, 0x0, 0x95, 0x6f, 0xc0, 0xea, 0x12, + 0x0, 0xb, 0x69, 0xd2, 0x36, 0xe9, 0xd8, 0xe4, 0x15, 0x66, 0x7c, 0xc5, 0xf5, 0x1a, 0x0, 0x11, 0x27, 0xb9, 0xed, + 0x43, 0xe8, 0x67, 0xa3, 0xb7, 0x7d, 0x9b, 0x27, 0xc6, 0x2a, 0x25, 0xcc, 0x72, 0x83, 0xb, 0x14, 0x28, 0x3e, 0x8, + 0x0, 0xe, 0xe1, 0x56, 0x53, 0xb3, 0x7f, 0x22, 0x66, 0xb5, 0x4f, 0x95, 0xa4, 0x3d, 0x1, 0x91, 0x23, 0x6e, 0xe4, + 0x19, 0xa9, 0x21, 0x4f, 0xa8, 0x17, 0x58, 0x2, 0x0, 0x0, 0x26, 0x46, 0x17, 0x48, 0x25, 0xf5, 0x15, 0x0, 0x10, + 0x20, 0x88, 0xcd, 0x32, 0xf9, 0x93, 0xea, 0x1, 0x28, 0xb9, 0xb7, 0xe, 0xae, 0xd6, 0x56, 0x84, 0x26, 0x0, 0xd, + 0xd9, 0xb6, 0x64, 0x6e, 0xd1, 0x6a, 0x7e, 0xd7, 0x1c, 0xd3, 0xcb, 0xcd, 0xc0, 0x0, 0x11, 0x11, 0x6a, 0xf5, 0x78, + 0x15, 0xb0, 0xce, 0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 0x4d, 0x21, 0x5a, 0xcf, 0x13, 0x19, 0xf1, 0x1c, 0x0, 0x4, 0xdf, 0x90, 0x8f, 0x3d, 0x13, 0x1f, 0x43, 0x15, 0x0, + 0x5, 0x14, 0xff, 0xdf, 0x69, 0x94, 0x18, 0x0, 0x0, 0x4d, 0x91, 0x3, 0x0, 0x8, 0x1d, 0xb, 0x2a, 0x2c, 0xb8, + 0x50, 0xf2, 0x2d, 0x26, 0x0, 0x2, 0x8b, 0x5b, 0x0, 0x0, 0x2, 0x0, 0x0, 0x10, 0xf4, 0x0, 0x17, 0xc5, 0xf4, + 0xd0, 0xac, 0x65, 0x49, 0x9e, 0xd0, 0x34, 0x7, 0xeb, 0x14, 0xb6, 0x64, 0x84, 0x1d, 0xbd, 0x82, 0x4f, 0x80, 0xe4, + 0xc0, 0x20, 0x0, 0x10, 0xa2, 0x54, 0xa8, 0x25, 0x54, 0xa1, 0x5b, 0x8a, 0x5c, 0x9c, 0x7e, 0x74, 0xbf, 0x9a, 0xce, + 0x3}; + + uint8_t buf[467] = {0}; + + uint8_t bytesprops0[] = {0x1c, 0xcb, 0x9c, 0x19, 0x9d, 0x6e, 0x62, 0xd7, 0x17, 0xdc, 0xb2, 0xda, + 0xa7, 0x12, 0xed, 0x12, 0xb7, 0x5c, 0x62, 0x18, 0x52, 0x2b, 0x67, 0x20}; + uint8_t bytesprops1[] = {0xab, 0x9b, 0xea, 0xdb, 0x3f, 0x54, 0x0, 0x95, 0x6f, 0xc0, 0xea}; + uint8_t bytesprops2[] = {0x69, 0xd2, 0x36, 0xe9, 0xd8, 0xe4, 0x15, 0x66, 0x7c, 0xc5, 0xf5}; + uint8_t bytesprops3[] = {0x27, 0xb9, 0xed, 0x43, 0xe8, 0x67, 0xa3, 0xb7, 0x7d, + 0x9b, 0x27, 0xc6, 0x2a, 0x25, 0xcc, 0x72, 0x83}; + uint8_t bytesprops4[] = {0xe1, 0x56, 0x53, 0xb3, 0x7f, 0x22, 0x66, 0xb5, 0x4f, 0x95, 0xa4, 0x3d, 0x1, 0x91}; + uint8_t bytesprops5[] = {0x20, 0x88, 0xcd, 0x32, 0xf9, 0x93, 0xea, 0x1, + 0x28, 0xb9, 0xb7, 0xe, 0xae, 0xd6, 0x56, 0x84}; + uint8_t bytesprops7[] = {0x11, 0x6a, 0xf5, 0x78, 0x15, 0xb0, 0xce, 0xbc, 0xc0, + 0xfb, 0x95, 0x3b, 0xb4, 0x7d, 0x13, 0xc3, 0x15}; + uint8_t bytesprops6[] = {0xd9, 0xb6, 0x64, 0x6e, 0xd1, 0x6a, 0x7e, 0xd7, 0x1c, 0xd3, 0xcb, 0xcd, 0xc0}; + uint8_t bytesprops8[] = {0x2e, 0xfb, 0x4d, 0x2b, 0x30, 0xa2, 0xc, 0x54, + 0xe3, 0x38, 0x22, 0x8d, 0x45, 0x26, 0xba, 0x9}; + uint8_t bytesprops9[] = {0x9e, 0x12, 0xa0, 0x24, 0x1a, 0xf4, 0xd6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28388}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20392}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9798}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops6}, .v = {17, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14104}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3973}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14160}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31059}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29504}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27510}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops9}}}, + }; + + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x97, 0x5f, 0xe6, 0x68, 0x7, 0x71, 0x7d, 0x1f, 0x11, 0x96, 0xbe, 0x26, 0xe9, 0xa5, + 0x79, 0x3c, 0xe9, 0xe3, 0x95, 0xeb, 0x5c, 0x21, 0x11, 0xba, 0xfe, 0xd0, 0x7e, 0xd2}; + uint8_t byteswillprops1[] = {0x80, 0x5c, 0x9e, 0x76, 0xd8, 0x7d, 0xb7, 0x29, 0x1e, 0x3f, 0xe3, 0xd8, 0xb2, + 0x44, 0x17, 0x1f, 0xf6, 0x99, 0x7, 0x5e, 0x7a, 0x61, 0xca, 0x98, 0x40}; + uint8_t byteswillprops2[] = {0x5b, 0xbc, 0xea, 0x3f, 0x3, 0x5c}; + uint8_t byteswillprops3[] = {0xcf, 0x9d, 0xc6, 0x55, 0x12, 0x33, 0x1c, 0x89, 0x44, 0xa8, 0xc2, 0xb2, + 0xc5, 0x2c, 0x56, 0x13, 0xde, 0x59, 0xdb, 0xfb, 0x85, 0x2e, 0x16}; + uint8_t byteswillprops4[] = {0xdf, 0x90, 0x8f, 0x3d}; + uint8_t byteswillprops5[] = {0x14, 0xff, 0xdf, 0x69, 0x94}; + uint8_t byteswillprops6[] = {0x1d, 0xb, 0x2a, 0x2c, 0xb8, 0x50, 0xf2, 0x2d}; + uint8_t byteswillprops8[] = {0}; + uint8_t byteswillprops7[] = {0x8b, 0x5b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14418}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29737}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 845}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23247}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6641}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8003}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19857}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {2, (char*)&byteswillprops7}, .v = {0, (char*)&byteswillprops8}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4340}}, + }; + + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc5, 0xf4, 0xd0, 0xac, 0x65, 0x49, 0x9e, 0xd0, 0x34, 0x7, 0xeb, 0x14, + 0xb6, 0x64, 0x84, 0x1d, 0xbd, 0x82, 0x4f, 0x80, 0xe4, 0xc0, 0x20}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa2, 0x54, 0xa8, 0x25, 0x54, 0xa1, 0x5b, 0x8a, + 0x5c, 0x9c, 0x7e, 0x74, 0xbf, 0x9a, 0xce, 0x3}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 5339; + uint8_t client_id_bytes[] = {0xc2, 0xa3, 0x9a, 0xcb, 0x4, 0x4c, 0x4d, 0x47, 0x60, 0x23, 0xa1, 0x6c}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\185\GSc\246\205\210\\\233\183w\EOT\252|-\224", _password = Nothing, _lastWill = +// Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\154\135@Q", _willMsg = +// "=\135\DEL\152\&4.\238\216\245h\157\130\aq\223\150:WI\169k\RS\149", _willProps = [PropTopicAlias +// 766,PropMaximumPacketSize 7651,PropSubscriptionIdentifierAvailable 2,PropReasonString +// "{\149\\\157P\181\&1<\n\145\166\249\142 \191\209\241\182Y\138r\204L5"]}), _cleanSession = False, _keepAlive = 23142, +// _connID = "J\242", _properties = [PropServerReference +// "\184\193\167\129\163u\196>\231\155Pzu8\SI\189\\JU\198\239,=\239P\222\DLE",PropAuthenticationMethod +// "",PropRequestResponseInformation 98,PropContentType +// "9d?:bS\182\t\n\220\152\254\RS\189v\252\189\199\210\196C\183\138\STX",PropRequestResponseInformation +// 232,PropSubscriptionIdentifier 12,PropMaximumPacketSize 23762,PropCorrelationData +// "\161\166!\166",PropSubscriptionIdentifier 30,PropRequestProblemInformation 91,PropRetainAvailable +// 79,PropAuthenticationData "_\ESC\156\&4\146/:",PropWildcardSubscriptionAvailable 233,PropTopicAliasMaximum +// 17503,PropSubscriptionIdentifierAvailable 181,PropMessageExpiryInterval 1386,PropPayloadFormatIndicator +// 179,PropServerKeepAlive 31777,PropRequestResponseInformation 171,PropWildcardSubscriptionAvailable +// 29,PropReasonString "\250m\RS\183;\183o\202g(\246\194\\#1\166\186\157\209\147\215\204\USZ\227S\156"]} +TEST(Connect5QCTest, Encode5) { + uint8_t pkt[] = {0x10, 0xf7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb4, 0x5a, 0x66, 0x91, 0x1, 0x1c, 0x0, + 0x1b, 0xb8, 0xc1, 0xa7, 0x81, 0xa3, 0x75, 0xc4, 0x3e, 0xe7, 0x9b, 0x50, 0x7a, 0x75, 0x38, 0xf, 0xbd, + 0x5c, 0x4a, 0x55, 0xc6, 0xef, 0x2c, 0x3d, 0xef, 0x50, 0xde, 0x10, 0x15, 0x0, 0x0, 0x19, 0x62, 0x3, + 0x0, 0x18, 0x39, 0x64, 0x3f, 0x3a, 0x62, 0x53, 0xb6, 0x9, 0xa, 0xdc, 0x98, 0xfe, 0x1e, 0xbd, 0x76, + 0xfc, 0xbd, 0xc7, 0xd2, 0xc4, 0x43, 0xb7, 0x8a, 0x2, 0x19, 0xe8, 0xb, 0xc, 0x27, 0x0, 0x0, 0x5c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 0x75, 0x38, + 0xf, 0xbd, 0x5c, 0x4a, 0x55, 0xc6, 0xef, 0x2c, 0x3d, 0xef, 0x50, 0xde, 0x10}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x39, 0x64, 0x3f, 0x3a, 0x62, 0x53, 0xb6, 0x9, 0xa, 0xdc, 0x98, 0xfe, + 0x1e, 0xbd, 0x76, 0xfc, 0xbd, 0xc7, 0xd2, 0xc4, 0x43, 0xb7, 0x8a, 0x2}; + uint8_t bytesprops3[] = {0xa1, 0xa6, 0x21, 0xa6}; + uint8_t bytesprops4[] = {0x5f, 0x1b, 0x9c, 0x34, 0x92, 0x2f, 0x3a}; + uint8_t bytesprops5[] = {0xfa, 0x6d, 0x1e, 0xb7, 0x3b, 0xb7, 0x6f, 0xca, 0x67, 0x28, 0xf6, 0xc2, 0x5c, 0x23, + 0x31, 0xa6, 0xba, 0x9d, 0xd1, 0x93, 0xd7, 0xcc, 0x1f, 0x5a, 0xe3, 0x53, 0x9c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23762}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17503}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1386}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31777}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops5}}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x7b, 0x95, 0x5c, 0x9d, 0x50, 0xb5, 0x31, 0x3c, 0xa, 0x91, 0xa6, 0xf9, + 0x8e, 0x20, 0xbf, 0xd1, 0xf1, 0xb6, 0x59, 0x8a, 0x72, 0xcc, 0x4c, 0x35}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 766}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7651}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops0}}}, + }; + + lwmqtt_properties_t willprops = {4, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9a, 0x87, 0x40, 0x51}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3d, 0x87, 0x7f, 0x98, 0x34, 0x2e, 0xee, 0xd8, 0xf5, 0x68, 0x9d, 0x82, + 0x7, 0x71, 0xdf, 0x96, 0x3a, 0x57, 0x49, 0xa9, 0x6b, 0x1e, 0x95}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 23142; + uint8_t client_id_bytes[] = {0x4a, 0xf2}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xb9, 0x1d, 0x63, 0xf6, 0xcd, 0xd2, 0x5c, 0xe9, 0xb7, 0x77, 0x4, 0xfc, 0x7c, 0x2d, 0xe0}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "\240\223\219|\165/\216\169G\212Ta\158=\151\215\242\164\220\199\164\236\142\249\194\194\EMU\245\214", _password = +// Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 11621, _connID = "Y", _properties = +// [PropRequestProblemInformation 243,PropSharedSubscriptionAvailable 87,PropTopicAliasMaximum 3301,PropResponseTopic +// "\209\151\221A\147\217+j\220\EM"]} +TEST(Connect5QCTest, Encode6) { + uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x80, 0x2d, 0x65, 0x14, 0x17, + 0xf3, 0x2a, 0x57, 0x22, 0xc, 0xe5, 0x8, 0x0, 0xa, 0xd1, 0x97, 0xdd, 0x41, 0x93, + 0xd9, 0x2b, 0x6a, 0xdc, 0x19, 0x0, 0x1, 0x59, 0x0, 0x1e, 0xf0, 0xdf, 0xdb, 0x7c, + 0xa5, 0x2f, 0xd8, 0xa9, 0x47, 0xd4, 0x54, 0x61, 0x9e, 0x3d, 0x97, 0xd7, 0xf2, 0xa4, + 0xdc, 0xc7, 0xa4, 0xec, 0x8e, 0xf9, 0xc2, 0xc2, 0x19, 0x55, 0xf5, 0xd6}; + + uint8_t buf[78] = {0}; + + uint8_t bytesprops0[] = {0xd1, 0x97, 0xdd, 0x41, 0x93, 0xd9, 0x2b, 0x6a, 0xdc, 0x19}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3301}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops0}}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 11621; + uint8_t client_id_bytes[] = {0x59}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xf0, 0xdf, 0xdb, 0x7c, 0xa5, 0x2f, 0xd8, 0xa9, 0x47, 0xd4, 0x54, 0x61, 0x9e, 0x3d, 0x97, + 0xd7, 0xf2, 0xa4, 0xdc, 0xc7, 0xa4, 0xec, 0x8e, 0xf9, 0xc2, 0xc2, 0x19, 0x55, 0xf5, 0xd6}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "]\218\DC2\160G\231\&5\185\137ZQ", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 32745, _connID = "\248\163cDx\241\168\&8\140/\228\161\192\&3o\168\223", +// _properties = [PropRetainAvailable 32,PropMessageExpiryInterval 31926,PropReceiveMaximum 835,PropResponseTopic +// "F\175=`\156q.\NAK)\232\201\167@\DEL\234",PropAssignedClientIdentifier +// "\133P\247\137J9.6\205\237\134\136\158\182\201\199\220\129\a\SO/\152!\GS",PropUserProperty +// "\214!]X\162\196I\230oq:\201" "\255tEC\CAN\234`\218",PropReceiveMaximum 18678,PropMaximumQoS +// 69,PropPayloadFormatIndicator 124,PropReasonString "\NAK\196-\173\244\231VI\164\f\215\202\147\166`_5fJ +// \230Fr\DC4\220\SUB\159",PropSubscriptionIdentifierAvailable 239,PropReasonString +// "\253\148\186\179\148",PropPayloadFormatIndicator 188,PropUserProperty "W\165jy" "{",PropCorrelationData +// "\128\&3\135\137\254\188\196\203",PropUserProperty "\ESC\b.Z\203\247#-\184/G" +// "\220]\241@z%\230!qy\FS\204J\153\218",PropMessageExpiryInterval 5765,PropReasonString +// "\ENQ7\184\f\153\254d\212",PropReceiveMaximum 10985]} +TEST(Connect5QCTest, Encode7) { + uint8_t pkt[] = {0x10, 0xe7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x7f, 0xe9, 0xc8, 0x1, 0x25, 0x20, + 0x2, 0x0, 0x0, 0x7c, 0xb6, 0x21, 0x3, 0x43, 0x8, 0x0, 0xf, 0x46, 0xaf, 0x3d, 0x60, 0x9c, 0x71, + 0x2e, 0x15, 0x29, 0xe8, 0xc9, 0xa7, 0x40, 0x7f, 0xea, 0x12, 0x0, 0x18, 0x85, 0x50, 0xf7, 0x89, 0x4a, + 0x39, 0x2e, 0x36, 0xcd, 0xed, 0x86, 0x88, 0x9e, 0xb6, 0xc9, 0xc7, 0xdc, 0x81, 0x7, 0xe, 0x2f, 0x98, + 0x21, 0x1d, 0x26, 0x0, 0xc, 0xd6, 0x21, 0x5d, 0x58, 0xa2, 0xc4, 0x49, 0xe6, 0x6f, 0x71, 0x3a, 0xc9, + 0x0, 0x8, 0xff, 0x74, 0x45, 0x43, 0x18, 0xea, 0x60, 0xda, 0x21, 0x48, 0xf6, 0x24, 0x45, 0x1, 0x7c, + 0x1f, 0x0, 0x1b, 0x15, 0xc4, 0x2d, 0xad, 0xf4, 0xe7, 0x56, 0x49, 0xa4, 0xc, 0xd7, 0xca, 0x93, 0xa6, + 0x60, 0x5f, 0x35, 0x66, 0x4a, 0x20, 0xe6, 0x46, 0x72, 0x14, 0xdc, 0x1a, 0x9f, 0x29, 0xef, 0x1f, 0x0, + 0x5, 0xfd, 0x94, 0xba, 0xb3, 0x94, 0x1, 0xbc, 0x26, 0x0, 0x4, 0x57, 0xa5, 0x6a, 0x79, 0x0, 0x1, + 0x7b, 0x9, 0x0, 0x8, 0x80, 0x33, 0x87, 0x89, 0xfe, 0xbc, 0xc4, 0xcb, 0x26, 0x0, 0xb, 0x1b, 0x8, + 0x2e, 0x5a, 0xcb, 0xf7, 0x23, 0x2d, 0xb8, 0x2f, 0x47, 0x0, 0xf, 0xdc, 0x5d, 0xf1, 0x40, 0x7a, 0x25, + 0xe6, 0x21, 0x71, 0x79, 0x1c, 0xcc, 0x4a, 0x99, 0xda, 0x2, 0x0, 0x0, 0x16, 0x85, 0x1f, 0x0, 0x8, + 0x5, 0x37, 0xb8, 0xc, 0x99, 0xfe, 0x64, 0xd4, 0x21, 0x2a, 0xe9, 0x0, 0x11, 0xf8, 0xa3, 0x63, 0x44, + 0x78, 0xf1, 0xa8, 0x38, 0x8c, 0x2f, 0xe4, 0xa1, 0xc0, 0x33, 0x6f, 0xa8, 0xdf}; + + uint8_t buf[244] = {0}; + + uint8_t bytesprops0[] = {0x46, 0xaf, 0x3d, 0x60, 0x9c, 0x71, 0x2e, 0x15, 0x29, 0xe8, 0xc9, 0xa7, 0x40, 0x7f, 0xea}; + uint8_t bytesprops1[] = {0x85, 0x50, 0xf7, 0x89, 0x4a, 0x39, 0x2e, 0x36, 0xcd, 0xed, 0x86, 0x88, + 0x9e, 0xb6, 0xc9, 0xc7, 0xdc, 0x81, 0x7, 0xe, 0x2f, 0x98, 0x21, 0x1d}; + uint8_t bytesprops3[] = {0xff, 0x74, 0x45, 0x43, 0x18, 0xea, 0x60, 0xda}; + uint8_t bytesprops2[] = {0xd6, 0x21, 0x5d, 0x58, 0xa2, 0xc4, 0x49, 0xe6, 0x6f, 0x71, 0x3a, 0xc9}; + uint8_t bytesprops4[] = {0x15, 0xc4, 0x2d, 0xad, 0xf4, 0xe7, 0x56, 0x49, 0xa4, 0xc, 0xd7, 0xca, 0x93, 0xa6, + 0x60, 0x5f, 0x35, 0x66, 0x4a, 0x20, 0xe6, 0x46, 0x72, 0x14, 0xdc, 0x1a, 0x9f}; + uint8_t bytesprops5[] = {0xfd, 0x94, 0xba, 0xb3, 0x94}; + uint8_t bytesprops7[] = {0x7b}; + uint8_t bytesprops6[] = {0x57, 0xa5, 0x6a, 0x79}; + uint8_t bytesprops8[] = {0x80, 0x33, 0x87, 0x89, 0xfe, 0xbc, 0xc4, 0xcb}; + uint8_t bytesprops10[] = {0xdc, 0x5d, 0xf1, 0x40, 0x7a, 0x25, 0xe6, 0x21, 0x71, 0x79, 0x1c, 0xcc, 0x4a, 0x99, 0xda}; + uint8_t bytesprops9[] = {0x1b, 0x8, 0x2e, 0x5a, 0xcb, 0xf7, 0x23, 0x2d, 0xb8, 0x2f, 0x47}; + uint8_t bytesprops11[] = {0x5, 0x37, 0xb8, 0xc, 0x99, 0xfe, 0x64, 0xd4}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31926}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 835}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops2}, .v = {8, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18678}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops6}, .v = {1, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops9}, .v = {15, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5765}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10985}}, + }; + + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32745; + uint8_t client_id_bytes[] = {0xf8, 0xa3, 0x63, 0x44, 0x78, 0xf1, 0xa8, 0x38, 0x8c, + 0x2f, 0xe4, 0xa1, 0xc0, 0x33, 0x6f, 0xa8, 0xdf}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x5d, 0xda, 0x12, 0xa0, 0x47, 0xe7, 0x35, 0xb9, 0x89, 0x5a, 0x51}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\NUL\136\181", _password = Just +// "d%\139\252\SUB\v\232)\218\ESC\DC3\212F\DC1\238\243j\SO\251\168", _lastWill = Nothing, _cleanSession = False, +// _keepAlive = 14321, _connID = "\SOHH\187\196\DEL\173\132\&0wH\SI\210C\131\DC4", _properties = [PropMaximumPacketSize +// 18542,PropSubscriptionIdentifier 6,PropSessionExpiryInterval 28295,PropReasonString +// "\254\161\194\f\176\DLE\252\GS",PropMessageExpiryInterval 16473,PropSubscriptionIdentifierAvailable +// 217,PropServerKeepAlive 3242,PropMessageExpiryInterval 15053,PropTopicAlias 18566,PropReceiveMaximum +// 5338,PropMaximumPacketSize 7337,PropPayloadFormatIndicator 60,PropSharedSubscriptionAvailable +// 252,PropAuthenticationData +// "\193\229\138L`\212\245\245\207Y\151s\130\184\EOTm\178D\254\EOT\150k\219J\164;\153w\156",PropSharedSubscriptionAvailable +// 36,PropWillDelayInterval 23076,PropMessageExpiryInterval 5605,PropMaximumPacketSize 11005]} +TEST(Connect5QCTest, Encode8) { + uint8_t pkt[] = {0x10, 0x9d, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x37, 0xf1, 0x66, 0x27, 0x0, + 0x0, 0x48, 0x6e, 0xb, 0x6, 0x11, 0x0, 0x0, 0x6e, 0x87, 0x1f, 0x0, 0x8, 0xfe, 0xa1, 0xc2, + 0xc, 0xb0, 0x10, 0xfc, 0x1d, 0x2, 0x0, 0x0, 0x40, 0x59, 0x29, 0xd9, 0x13, 0xc, 0xaa, 0x2, + 0x0, 0x0, 0x3a, 0xcd, 0x23, 0x48, 0x86, 0x21, 0x14, 0xda, 0x27, 0x0, 0x0, 0x1c, 0xa9, 0x1, + 0x3c, 0x2a, 0xfc, 0x16, 0x0, 0x1d, 0xc1, 0xe5, 0x8a, 0x4c, 0x60, 0xd4, 0xf5, 0xf5, 0xcf, 0x59, + 0x97, 0x73, 0x82, 0xb8, 0x4, 0x6d, 0xb2, 0x44, 0xfe, 0x4, 0x96, 0x6b, 0xdb, 0x4a, 0xa4, 0x3b, + 0x99, 0x77, 0x9c, 0x2a, 0x24, 0x18, 0x0, 0x0, 0x5a, 0x24, 0x2, 0x0, 0x0, 0x15, 0xe5, 0x27, + 0x0, 0x0, 0x2a, 0xfd, 0x0, 0xf, 0x1, 0x48, 0xbb, 0xc4, 0x7f, 0xad, 0x84, 0x30, 0x77, 0x48, + 0xf, 0xd2, 0x43, 0x83, 0x14, 0x0, 0x3, 0x0, 0x88, 0xb5, 0x0, 0x14, 0x64, 0x25, 0x8b, 0xfc, + 0x1a, 0xb, 0xe8, 0x29, 0xda, 0x1b, 0x13, 0xd4, 0x46, 0x11, 0xee, 0xf3, 0x6a, 0xe, 0xfb, 0xa8}; + + uint8_t buf[170] = {0}; + + uint8_t bytesprops0[] = {0xfe, 0xa1, 0xc2, 0xc, 0xb0, 0x10, 0xfc, 0x1d}; + uint8_t bytesprops1[] = {0xc1, 0xe5, 0x8a, 0x4c, 0x60, 0xd4, 0xf5, 0xf5, 0xcf, 0x59, 0x97, 0x73, 0x82, 0xb8, 0x4, + 0x6d, 0xb2, 0x44, 0xfe, 0x4, 0x96, 0x6b, 0xdb, 0x4a, 0xa4, 0x3b, 0x99, 0x77, 0x9c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18542}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28295}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16473}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3242}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15053}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18566}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5338}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7337}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23076}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5605}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11005}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 14321; + uint8_t client_id_bytes[] = {0x1, 0x48, 0xbb, 0xc4, 0x7f, 0xad, 0x84, 0x30, 0x77, 0x48, 0xf, 0xd2, 0x43, 0x83, 0x14}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x0, 0x88, 0xb5}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x64, 0x25, 0x8b, 0xfc, 0x1a, 0xb, 0xe8, 0x29, 0xda, 0x1b, + 0x13, 0xd4, 0x46, 0x11, 0xee, 0xf3, 0x6a, 0xe, 0xfb, 0xa8}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\142\224!;+'mV", _password = Just +// "{h\173\&5]\vz\\P\196\181X.\"B~\207\241\156]f\195X\DC1\203u\149\151\249", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS1, _willTopic = "S]\n\ETB[\ACK)\233\177\225N\218\162\EM\240p\239O", _willMsg = "\183", +// _willProps = [PropUserProperty "\214\RS\197\&8\179\187^NZ\DC4\196`\202s" +// "\a\172\216\SUB\230\244\162\"\220\186\184mt",PropMessageExpiryInterval 13266]}), _cleanSession = False, _keepAlive = +// 24734, _connID = "gYE\207\225\215\192", _properties = [PropSessionExpiryInterval +// 27757,PropSharedSubscriptionAvailable 215,PropSubscriptionIdentifierAvailable 2,PropWildcardSubscriptionAvailable +// 117,PropAssignedClientIdentifier +// "r\183\186\190\&2`\DC1\236\240\235:\DC2~|a^\162\b\165\224\168'\133G\136C\"",PropServerReference +// "P\148I\166\&6%\170\216n\212 \DLE\DEL>\204B\247\133\211ef/\232\140)",PropResponseTopic +// "\233",PropWildcardSubscriptionAvailable 19,PropWillDelayInterval 3899,PropAuthenticationMethod +// "\"\166\238\NAK\193\SO\213\160\&5~\244g\b]\233.X\230\228P",PropContentType +// "RS\255\241s3",PropWildcardSubscriptionAvailable 86,PropTopicAlias 8716,PropAuthenticationMethod +// "\189u\STXY\136\242\DC4\228\228'\167\199\DC3\218gc\253",PropSessionExpiryInterval 13590,PropRequestProblemInformation +// 199,PropTopicAliasMaximum 19507,PropServerKeepAlive 11841,PropRequestResponseInformation +// 173,PropRequestProblemInformation 35,PropRetainAvailable 16,PropMaximumQoS 13,PropResponseInformation +// "8!\227\DC2=+\169dj\138\150)]\137",PropWildcardSubscriptionAvailable 16,PropMessageExpiryInterval +// 16226,PropRequestResponseInformation 221,PropResponseTopic +// "\b\172\fp\133\221\200\138\242\239\128\"i?q\170\DC4\216\226\189\234\CANYi?\199",PropResponseInformation +// "",PropWildcardSubscriptionAvailable 12]} +TEST(Connect5QCTest, Encode9) { + uint8_t pkt[] = { + 0x10, 0xd5, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x60, 0x9e, 0xda, 0x1, 0x11, 0x0, 0x0, 0x6c, + 0x6d, 0x2a, 0xd7, 0x29, 0x2, 0x28, 0x75, 0x12, 0x0, 0x1b, 0x72, 0xb7, 0xba, 0xbe, 0x32,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0x18, 0x59, 0x69, 0x3f, 0xc7, + 0x1a, 0x0, 0x0, 0x28, 0xc, 0x0, 0x7, 0x67, 0x59, 0x45, 0xcf, 0xe1, 0xd7, 0xc0, 0x25, 0x26, 0x0, 0xe, 0xd6, + 0x1e, 0xc5, 0x38, 0xb3, 0xbb, 0x5e, 0x4e, 0x5a, 0x14, 0xc4, 0x60, 0xca, 0x73, 0x0, 0xd, 0x7, 0xac, 0xd8, 0x1a, + 0xe6, 0xf4, 0xa2, 0x22, 0xdc, 0xba, 0xb8, 0x6d, 0x74, 0x2, 0x0, 0x0, 0x33, 0xd2, 0x0, 0x12, 0x53, 0x5d, 0xa, + 0x17, 0x5b, 0x6, 0x29, 0xe9, 0xb1, 0xe1, 0x4e, 0xda, 0xa2, 0x19, 0xf0, 0x70, 0xef, 0x4f, 0x0, 0x1, 0xb7, 0x0, + 0x8, 0x8e, 0xe0, 0x21, 0x3b, 0x2b, 0x27, 0x6d, 0x56, 0x0, 0x1d, 0x7b, 0x68, 0xad, 0x35, 0x5d, 0xb, 0x7a, 0x5c, + 0x50, 0xc4, 0xb5, 0x58, 0x2e, 0x22, 0x42, 0x7e, 0xcf, 0xf1, 0x9c, 0x5d, 0x66, 0xc3, 0x58, 0x11, 0xcb, 0x75, 0x95, + 0x97, 0xf9}; + + uint8_t buf[354] = {0}; + + uint8_t bytesprops0[] = {0x72, 0xb7, 0xba, 0xbe, 0x32, 0x60, 0x11, 0xec, 0xf0, 0xeb, 0x3a, 0x12, 0x7e, 0x7c, + 0x61, 0x5e, 0xa2, 0x8, 0xa5, 0xe0, 0xa8, 0x27, 0x85, 0x47, 0x88, 0x43, 0x22}; + uint8_t bytesprops1[] = {0x50, 0x94, 0x49, 0xa6, 0x36, 0x25, 0xaa, 0xd8, 0x6e, 0xd4, 0x20, 0x10, 0x7f, + 0x3e, 0xcc, 0x42, 0xf7, 0x85, 0xd3, 0x65, 0x66, 0x2f, 0xe8, 0x8c, 0x29}; + uint8_t bytesprops2[] = {0xe9}; + uint8_t bytesprops3[] = {0x22, 0xa6, 0xee, 0x15, 0xc1, 0xe, 0xd5, 0xa0, 0x35, 0x7e, + 0xf4, 0x67, 0x8, 0x5d, 0xe9, 0x2e, 0x58, 0xe6, 0xe4, 0x50}; + uint8_t bytesprops4[] = {0x52, 0x53, 0xff, 0xf1, 0x73, 0x33}; + uint8_t bytesprops5[] = {0xbd, 0x75, 0x2, 0x59, 0x88, 0xf2, 0x14, 0xe4, 0xe4, + 0x27, 0xa7, 0xc7, 0x13, 0xda, 0x67, 0x63, 0xfd}; + uint8_t bytesprops6[] = {0x38, 0x21, 0xe3, 0x12, 0x3d, 0x2b, 0xa9, 0x64, 0x6a, 0x8a, 0x96, 0x29, 0x5d, 0x89}; + uint8_t bytesprops7[] = {0x8, 0xac, 0xc, 0x70, 0x85, 0xdd, 0xc8, 0x8a, 0xf2, 0xef, 0x80, 0x22, 0x69, + 0x3f, 0x71, 0xaa, 0x14, 0xd8, 0xe2, 0xbd, 0xea, 0x18, 0x59, 0x69, 0x3f, 0xc7}; + uint8_t bytesprops8[] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27757}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3899}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8716}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13590}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19507}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11841}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16226}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 12}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x7, 0xac, 0xd8, 0x1a, 0xe6, 0xf4, 0xa2, 0x22, 0xdc, 0xba, 0xb8, 0x6d, 0x74}; + uint8_t byteswillprops0[] = {0xd6, 0x1e, 0xc5, 0x38, 0xb3, 0xbb, 0x5e, 0x4e, 0x5a, 0x14, 0xc4, 0x60, 0xca, 0x73}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {14, (char*)&byteswillprops0}, .v = {13, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13266}}, + }; + + lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x53, 0x5d, 0xa, 0x17, 0x5b, 0x6, 0x29, 0xe9, 0xb1, + 0xe1, 0x4e, 0xda, 0xa2, 0x19, 0xf0, 0x70, 0xef, 0x4f}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb7}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 24734; + uint8_t client_id_bytes[] = {0x67, 0x59, 0x45, 0xcf, 0xe1, 0xd7, 0xc0}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x8e, 0xe0, 0x21, 0x3b, 0x2b, 0x27, 0x6d, 0x56}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x7b, 0x68, 0xad, 0x35, 0x5d, 0xb, 0x7a, 0x5c, 0x50, 0xc4, 0xb5, 0x58, 0x2e, 0x22, 0x42, + 0x7e, 0xcf, 0xf1, 0x9c, 0x5d, 0x66, 0xc3, 0x58, 0x11, 0xcb, 0x75, 0x95, 0x97, 0xf9}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\r7\"\154\EOT", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS1, _willTopic = "\\\131\211\214\209\183\242\162", _willMsg = ")&", _willProps = +// [PropAuthenticationMethod "$\252\SUB,\144>",PropSessionExpiryInterval 30269,PropAssignedClientIdentifier +// "S\129\b\221\156\a\132\&2\234\244\246",PropSubscriptionIdentifierAvailable 97,PropServerKeepAlive 5359]}), +// _cleanSession = False, _keepAlive = 17778, _connID = "\160\202\220\&9^\188\ENQ\223w\149\158\233", _properties = +// [PropContentType +// "\157~\235\155\148a\137\217\224\a\133XA\162>\149\131\b\240\249[z\234Qr\184",PropWildcardSubscriptionAvailable +// 175,PropRetainAvailable 178,PropSubscriptionIdentifierAvailable 1,PropAuthenticationMethod +// "\167\222\132q]P\252\198\FS\185\EOT\240\ESC\129\227?\208\191K\217",PropSubscriptionIdentifierAvailable +// 161,PropReceiveMaximum 28268,PropMaximumPacketSize 10703,PropSessionExpiryInterval 6418,PropMessageExpiryInterval +// 30728,PropRequestProblemInformation 91,PropTopicAliasMaximum 27090,PropSubscriptionIdentifier +// 30,PropSubscriptionIdentifier 27,PropSessionExpiryInterval 20709,PropContentType +// "$\251|\ENQ.IC\148\139\228]8[\190E\183zm|\155Cz",PropRetainAvailable 235,PropResponseTopic +// "@\181\230\n\167P\194\163S\DEL\244\181'\227",PropReceiveMaximum 6854,PropMaximumPacketSize 2644,PropCorrelationData +// "\191\188L\252\216q\190\182\182\132j\194\USx\f\143\FS\241\161\SI\STX\GS[",PropMaximumPacketSize +// 20784,PropMessageExpiryInterval 30567,PropReasonString +// "\RSJ\181\235\172\ESC\208\157\f\252\147\&5\181\168p\183\222.\156\164\180\139B~\FS\a\DC4Q",PropServerKeepAlive +// 31825,PropMaximumPacketSize 21098]} +TEST(Connect5QCTest, Encode10) { + uint8_t pkt[] = { + 0x10, 0xac, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8c, 0x45, 0x72, 0xdb, 0x1, 0x3, 0x0, 0x1a, 0x9d, + 0x7e, 0xeb, 0x9b, 0x94, 0x61, 0x89, 0xd9, 0xe0, 0x7, 0x85, 0x58, 0x41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, 0x9c, 0xa4, 0xb4, 0x8b, 0x42, 0x7e, 0x1c, 0x7, 0x14, 0x51, 0x13, 0x7c, + 0x51, 0x27, 0x0, 0x0, 0x52, 0x6a, 0x0, 0xc, 0xa0, 0xca, 0xdc, 0x39, 0x5e, 0xbc, 0x5, 0xdf, 0x77, 0x95, 0x9e, + 0xe9, 0x21, 0x15, 0x0, 0x6, 0x24, 0xfc, 0x1a, 0x2c, 0x90, 0x3e, 0x11, 0x0, 0x0, 0x76, 0x3d, 0x12, 0x0, 0xb, + 0x53, 0x81, 0x8, 0xdd, 0x9c, 0x7, 0x84, 0x32, 0xea, 0xf4, 0xf6, 0x29, 0x61, 0x13, 0x14, 0xef, 0x0, 0x8, 0x5c, + 0x83, 0xd3, 0xd6, 0xd1, 0xb7, 0xf2, 0xa2, 0x0, 0x2, 0x29, 0x26, 0x0, 0x5, 0xd, 0x37, 0x22, 0x9a, 0x4}; + + uint8_t buf[313] = {0}; + + uint8_t bytesprops0[] = {0x9d, 0x7e, 0xeb, 0x9b, 0x94, 0x61, 0x89, 0xd9, 0xe0, 0x7, 0x85, 0x58, 0x41, + 0xa2, 0x3e, 0x95, 0x83, 0x8, 0xf0, 0xf9, 0x5b, 0x7a, 0xea, 0x51, 0x72, 0xb8}; + uint8_t bytesprops1[] = {0xa7, 0xde, 0x84, 0x71, 0x5d, 0x50, 0xfc, 0xc6, 0x1c, 0xb9, + 0x4, 0xf0, 0x1b, 0x81, 0xe3, 0x3f, 0xd0, 0xbf, 0x4b, 0xd9}; + uint8_t bytesprops2[] = {0x24, 0xfb, 0x7c, 0x5, 0x2e, 0x49, 0x43, 0x94, 0x8b, 0xe4, 0x5d, + 0x38, 0x5b, 0xbe, 0x45, 0xb7, 0x7a, 0x6d, 0x7c, 0x9b, 0x43, 0x7a}; + uint8_t bytesprops3[] = {0x40, 0xb5, 0xe6, 0xa, 0xa7, 0x50, 0xc2, 0xa3, 0x53, 0x7f, 0xf4, 0xb5, 0x27, 0xe3}; + uint8_t bytesprops4[] = {0xbf, 0xbc, 0x4c, 0xfc, 0xd8, 0x71, 0xbe, 0xb6, 0xb6, 0x84, 0x6a, 0xc2, + 0x1f, 0x78, 0xc, 0x8f, 0x1c, 0xf1, 0xa1, 0xf, 0x2, 0x1d, 0x5b}; + uint8_t bytesprops5[] = {0x1e, 0x4a, 0xb5, 0xeb, 0xac, 0x1b, 0xd0, 0x9d, 0xc, 0xfc, 0x93, 0x35, 0xb5, 0xa8, + 0x70, 0xb7, 0xde, 0x2e, 0x9c, 0xa4, 0xb4, 0x8b, 0x42, 0x7e, 0x1c, 0x7, 0x14, 0x51}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28268}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10703}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6418}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30728}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27090}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20709}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6854}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2644}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20784}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30567}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31825}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21098}}, + }; + + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x24, 0xfc, 0x1a, 0x2c, 0x90, 0x3e}; + uint8_t byteswillprops1[] = {0x53, 0x81, 0x8, 0xdd, 0x9c, 0x7, 0x84, 0x32, 0xea, 0xf4, 0xf6}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30269}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5359}}, + }; + + lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5c, 0x83, 0xd3, 0xd6, 0xd1, 0xb7, 0xf2, 0xa2}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x29, 0x26}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 17778; + uint8_t client_id_bytes[] = {0xa0, 0xca, 0xdc, 0x39, 0x5e, 0xbc, 0x5, 0xdf, 0x77, 0x95, 0x9e, 0xe9}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xd, 0x37, 0x22, 0x9a, 0x4}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\181\bX\195\NULZ\169\250\173\230E\239g\209\226\145:pJ ^\SO\192\SYN,V\138\226", +// _password = Just "b\129\SOH\222>\130\229h\251\208QM\146\255\&3 \190\166Ty\CAN\211\154\208\148hWO\146P\DC2\208r\209\180\253\215F\211\223,\ESC",PropSharedSubscriptionAvailable +// 34,PropMaximumPacketSize 24332,PropAuthenticationMethod +// "\rt\ETX8\130\135Y\209L\236J!\253\&4\213\250\243\184\134\190T\aC\236",PropMaximumQoS 126,PropAuthenticationMethod +// "\212h\236h",PropPayloadFormatIndicator 139,PropWildcardSubscriptionAvailable 99,PropTopicAliasMaximum +// 31936,PropTopicAliasMaximum 21507,PropContentType "\FS\252\206\173j\a$\200\133H\rM\n\241\215\SI?]"]}), _cleanSession +// = False, _keepAlive = 3108, _connID = "\211\250\245_\185\238\&6\147\133\144c\168\US\246\SUB\175\170|HZ\184\nE", +// _properties = [PropWildcardSubscriptionAvailable 245,PropResponseTopic "\157\196\226\SYNr",PropServerReference +// "#:\150",PropMaximumPacketSize 24216,PropSessionExpiryInterval 26003,PropReceiveMaximum 6740,PropTopicAliasMaximum +// 16967]} +TEST(Connect5QCTest, Encode14) { + uint8_t pkt[] = { + 0x10, 0xb5, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x84, 0xc, 0x24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x2c, 0x1b, 0x2a, 0x22, 0x27, 0x0, 0x0, 0x5f, 0xc, + 0x15, 0x0, 0x18, 0xd, 0x74, 0x3, 0x38, 0x82, 0x87, 0x59, 0xd1, 0x4c, 0xec, 0x4a, 0x21, 0xfd, 0x34, 0xd5, 0xfa, + 0xf3, 0xb8, 0x86, 0xbe, 0x54, 0x7, 0x43, 0xec, 0x24, 0x7e, 0x15, 0x0, 0x4, 0xd4, 0x68, 0xec, 0x68, 0x1, 0x8b, + 0x28, 0x63, 0x22, 0x7c, 0xc0, 0x22, 0x54, 0x3, 0x3, 0x0, 0x12, 0x1c, 0xfc, 0xce, 0xad, 0x6a, 0x7, 0x24, 0xc8, + 0x85, 0x48, 0xd, 0x4d, 0xa, 0xf1, 0xd7, 0xf, 0x3f, 0x5d, 0x0, 0x12, 0x2a, 0xd3, 0x2c, 0xef, 0x28, 0x8c, 0xd9, + 0x3c, 0x51, 0xcd, 0xdb, 0x80, 0x68, 0xc9, 0xe4, 0xe6, 0xa1, 0xe9, 0x0, 0x9, 0xe9, 0x7, 0x5e, 0x5f, 0xa6, 0x9d, + 0x76, 0x25, 0x2b, 0x0, 0x3, 0xd9, 0x86, 0xb6}; + + uint8_t buf[322] = {0}; + + uint8_t bytesprops0[] = {0x9d, 0xc4, 0xe2, 0x16, 0x72}; + uint8_t bytesprops1[] = {0x23, 0x3a, 0x96}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24216}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26003}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6740}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16967}}, + }; + + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x31, 0x19, 0xdb, 0x14, 0xfc, 0x0, 0x90, 0x24, 0xe7, 0x28, 0xbf, 0x48, 0x8, + 0x2e, 0xa2, 0x99, 0xed, 0x13, 0xfb, 0x23, 0x4e, 0xe3, 0x5d, 0xff, 0x7, 0x28}; + uint8_t byteswillprops1[] = {0x8d, 0x0, 0x26}; + uint8_t byteswillprops2[] = {0xfd, 0x22, 0x4e}; + uint8_t byteswillprops3[] = {0x85, 0x60, 0xd6, 0x83, 0xc0, 0x43, 0x1b, 0x6d, 0xfd, 0x11, 0xeb, 0x37, 0x4b, + 0xf5, 0x53, 0x99, 0x32, 0xb2, 0xb9, 0x28, 0x2d, 0xdd, 0x91, 0x9a, 0x8, 0x83}; + uint8_t byteswillprops4[] = {0x9, 0xbb, 0xb, 0x9a, 0x55, 0x43, 0x3b, 0xea, 0x44}; + uint8_t byteswillprops5[] = {0x8b, 0x25, 0x2a, 0x35, 0x5f, 0x44, 0x3e, 0x79, 0x18, 0xd3, + 0x9a, 0xd0, 0x94, 0x68, 0x57, 0x4f, 0x92, 0x50, 0x12, 0xd0, + 0x72, 0xd1, 0xb4, 0xfd, 0xd7, 0x46, 0xd3, 0xdf, 0x2c, 0x1b}; + uint8_t byteswillprops6[] = {0xd, 0x74, 0x3, 0x38, 0x82, 0x87, 0x59, 0xd1, 0x4c, 0xec, 0x4a, 0x21, + 0xfd, 0x34, 0xd5, 0xfa, 0xf3, 0xb8, 0x86, 0xbe, 0x54, 0x7, 0x43, 0xec}; + uint8_t byteswillprops7[] = {0xd4, 0x68, 0xec, 0x68}; + uint8_t byteswillprops8[] = {0x1c, 0xfc, 0xce, 0xad, 0x6a, 0x7, 0x24, 0xc8, 0x85, + 0x48, 0xd, 0x4d, 0xa, 0xf1, 0xd7, 0xf, 0x3f, 0x5d}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13764}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9290}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24332}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31936}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21507}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops8}}}, + }; + + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2a, 0xd3, 0x2c, 0xef, 0x28, 0x8c, 0xd9, 0x3c, 0x51, + 0xcd, 0xdb, 0x80, 0x68, 0xc9, 0xe4, 0xe6, 0xa1, 0xe9}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe9, 0x7, 0x5e, 0x5f, 0xa6, 0x9d, 0x76, 0x25, 0x2b}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3108; + uint8_t client_id_bytes[] = {0xd3, 0xfa, 0xf5, 0x5f, 0xb9, 0xee, 0x36, 0x93, 0x85, 0x90, 0x63, 0xa8, + 0x1f, 0xf6, 0x1a, 0xaf, 0xaa, 0x7c, 0x48, 0x5a, 0xb8, 0xa, 0x45}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xd9, 0x86, 0xb6}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "]*\250E|\140H\246\144\236\ACK\196\152\216@\SO\EOTK\248 +// \199\&6\n\STX=\149s\235\206R", _password = Just "o\197\204\215\153\171tJ\230U\196K\209xYvu\252\206a\129\\", _lastWill +// = Nothing, _cleanSession = False, _keepAlive = 2582, _connID = +// "Zj\DC2\237\243_-\201=\176\154\233\163\196\234\210\176!", _properties = [PropReceiveMaximum 18664,PropServerKeepAlive +// 6658,PropServerKeepAlive 18381,PropMessageExpiryInterval 15208,PropWillDelayInterval 29547,PropUserProperty +// "\150Z\132\248Y\f\170\138.Dl" "&\203u",PropPayloadFormatIndicator 224,PropTopicAlias 26630,PropUserProperty +// "\232M\139\142\SOH5\130\220v\153\146\163\149\238\185\140\242H\226\ETX\RS\DEL" +// "\158\189\210`Pr\255i\198Z9\175\156\220E\STX\131\167(W\170\f\161\192\239\DEL\179",PropServerReference +// "\144\USc\179\&9\222\FS\vJ/\168\236\180u\240\167.=,\SOHNJ@)\ETX",PropRequestProblemInformation 212]} +TEST(Connect5QCTest, Encode15) { + uint8_t pkt[] = {0x10, 0xd6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0xa, 0x16, 0x7f, 0x21, 0x48, 0xe8, + 0x13, 0x1a, 0x2, 0x13, 0x47, 0xcd, 0x2, 0x0, 0x0, 0x3b, 0x68, 0x18, 0x0, 0x0, 0x73, 0x6b, 0x26, + 0x0, 0xb, 0x96, 0x5a, 0x84, 0xf8, 0x59, 0xc, 0xaa, 0x8a, 0x2e, 0x44, 0x6c, 0x0, 0x3, 0x26, 0xcb, + 0x75, 0x1, 0xe0, 0x23, 0x68, 0x6, 0x26, 0x0, 0x16, 0xe8, 0x4d, 0x8b, 0x8e, 0x1, 0x35, 0x82, 0xdc, + 0x76, 0x99, 0x92, 0xa3, 0x95, 0xee, 0xb9, 0x8c, 0xf2, 0x48, 0xe2, 0x3, 0x1e, 0x7f, 0x0, 0x1b, 0x9e, + 0xbd, 0xd2, 0x60, 0x50, 0x72, 0xff, 0x69, 0xc6, 0x5a, 0x39, 0xaf, 0x9c, 0xdc, 0x45, 0x2, 0x83, 0xa7, + 0x28, 0x57, 0xaa, 0xc, 0xa1, 0xc0, 0xef, 0x7f, 0xb3, 0x1c, 0x0, 0x19, 0x90, 0x1f, 0x63, 0xb3, 0x39, + 0xde, 0x1c, 0xb, 0x4a, 0x2f, 0xa8, 0xec, 0xb4, 0x75, 0xf0, 0xa7, 0x2e, 0x3d, 0x2c, 0x1, 0x4e, 0x4a, + 0x40, 0x29, 0x3, 0x17, 0xd4, 0x0, 0x12, 0x5a, 0x6a, 0x12, 0xed, 0xf3, 0x5f, 0x2d, 0xc9, 0x3d, 0xb0, + 0x9a, 0xe9, 0xa3, 0xc4, 0xea, 0xd2, 0xb0, 0x21, 0x0, 0x1e, 0x5d, 0x2a, 0xfa, 0x45, 0x7c, 0x8c, 0x48, + 0xf6, 0x90, 0xec, 0x6, 0xc4, 0x98, 0xd8, 0x40, 0xe, 0x4, 0x4b, 0xf8, 0x20, 0xc7, 0x36, 0xa, 0x2, + 0x3d, 0x95, 0x73, 0xeb, 0xce, 0x52, 0x0, 0x16, 0x6f, 0xc5, 0xcc, 0xd7, 0x99, 0xab, 0x74, 0x4a, 0xe6, + 0x55, 0xc4, 0x4b, 0xd1, 0x78, 0x59, 0x76, 0x75, 0xfc, 0xce, 0x61, 0x81, 0x5c}; + + uint8_t buf[227] = {0}; + + uint8_t bytesprops1[] = {0x26, 0xcb, 0x75}; + uint8_t bytesprops0[] = {0x96, 0x5a, 0x84, 0xf8, 0x59, 0xc, 0xaa, 0x8a, 0x2e, 0x44, 0x6c}; + uint8_t bytesprops3[] = {0x9e, 0xbd, 0xd2, 0x60, 0x50, 0x72, 0xff, 0x69, 0xc6, 0x5a, 0x39, 0xaf, 0x9c, 0xdc, + 0x45, 0x2, 0x83, 0xa7, 0x28, 0x57, 0xaa, 0xc, 0xa1, 0xc0, 0xef, 0x7f, 0xb3}; + uint8_t bytesprops2[] = {0xe8, 0x4d, 0x8b, 0x8e, 0x1, 0x35, 0x82, 0xdc, 0x76, 0x99, 0x92, + 0xa3, 0x95, 0xee, 0xb9, 0x8c, 0xf2, 0x48, 0xe2, 0x3, 0x1e, 0x7f}; + uint8_t bytesprops4[] = {0x90, 0x1f, 0x63, 0xb3, 0x39, 0xde, 0x1c, 0xb, 0x4a, 0x2f, 0xa8, 0xec, 0xb4, + 0x75, 0xf0, 0xa7, 0x2e, 0x3d, 0x2c, 0x1, 0x4e, 0x4a, 0x40, 0x29, 0x3}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18664}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6658}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18381}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15208}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29547}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {3, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26630}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops2}, .v = {27, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 2582; + uint8_t client_id_bytes[] = {0x5a, 0x6a, 0x12, 0xed, 0xf3, 0x5f, 0x2d, 0xc9, 0x3d, + 0xb0, 0x9a, 0xe9, 0xa3, 0xc4, 0xea, 0xd2, 0xb0, 0x21}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x5d, 0x2a, 0xfa, 0x45, 0x7c, 0x8c, 0x48, 0xf6, 0x90, 0xec, 0x6, 0xc4, 0x98, 0xd8, 0x40, + 0xe, 0x4, 0x4b, 0xf8, 0x20, 0xc7, 0x36, 0xa, 0x2, 0x3d, 0x95, 0x73, 0xeb, 0xce, 0x52}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x6f, 0xc5, 0xcc, 0xd7, 0x99, 0xab, 0x74, 0x4a, 0xe6, 0x55, 0xc4, + 0x4b, 0xd1, 0x78, 0x59, 0x76, 0x75, 0xfc, 0xce, 0x61, 0x81, 0x5c}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\EOTG\170Y\132\235\193\STX\132\236", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 14063, _connID = "\253gc\224:\148 v\185T^gmf\158Z\DC1#\211\SYN#[~", _properties = +// [PropWildcardSubscriptionAvailable 153,PropAuthenticationMethod +// "%*V\246\139\252A\250\140\210\SI\218\213\190\164kEI\252",PropTopicAliasMaximum 20364,PropSharedSubscriptionAvailable +// 45,PropSessionExpiryInterval 19290,PropPayloadFormatIndicator 17,PropResponseInformation +// "d\SOQ\254X\189\247V\190\140\144\173\&5\214\241\160\164-\231",PropContentType "f\v\240",PropAuthenticationData +// "\141u\201X\250\ESC7`\"`\DC45\234\144m\211\135\209\199N\158\199\214\244\165\162\131",PropSharedSubscriptionAvailable +// 226,PropSubscriptionIdentifierAvailable 5,PropMessageExpiryInterval 251,PropMessageExpiryInterval +// 20049,PropResponseInformation +// "A\145\SOH\194\135\168HK\GS\NAK\f\161\US\192\231\NUL\199\"q\211M\204v\ETX\187\n",PropRequestProblemInformation +// 143,PropSharedSubscriptionAvailable 100,PropWildcardSubscriptionAvailable 44,PropRequestResponseInformation +// 218,PropTopicAliasMaximum 23440,PropPayloadFormatIndicator 71,PropAssignedClientIdentifier ":0",PropReceiveMaximum +// 12681]} +TEST(Connect5QCTest, Encode16) { + uint8_t pkt[] = {0x10, 0xc3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x36, 0xef, 0x9e, 0x1, 0x28, 0x99, + 0x15, 0x0, 0x13, 0x25, 0x2a, 0x56, 0xf6, 0x8b, 0xfc, 0x41, 0xfa, 0x8c, 0xd2, 0xf, 0xda, 0xd5, 0xbe, + 0xa4, 0x6b, 0x45, 0x49, 0xfc, 0x22, 0x4f, 0x8c, 0x2a, 0x2d, 0x11, 0x0, 0x0, 0x4b, 0x5a, 0x1, 0x11, + 0x1a, 0x0, 0x13, 0x64, 0xe, 0x51, 0xfe, 0x58, 0xbd, 0xf7, 0x56, 0xbe, 0x8c, 0x90, 0xad, 0x35, 0xd6, + 0xf1, 0xa0, 0xa4, 0x2d, 0xe7, 0x3, 0x0, 0x3, 0x66, 0xb, 0xf0, 0x16, 0x0, 0x1b, 0x8d, 0x75, 0xc9, + 0x58, 0xfa, 0x1b, 0x37, 0x60, 0x22, 0x60, 0x14, 0x35, 0xea, 0x90, 0x6d, 0xd3, 0x87, 0xd1, 0xc7, 0x4e, + 0x9e, 0xc7, 0xd6, 0xf4, 0xa5, 0xa2, 0x83, 0x2a, 0xe2, 0x29, 0x5, 0x2, 0x0, 0x0, 0x0, 0xfb, 0x2, + 0x0, 0x0, 0x4e, 0x51, 0x1a, 0x0, 0x1a, 0x41, 0x91, 0x1, 0xc2, 0x87, 0xa8, 0x48, 0x4b, 0x1d, 0x15, + 0xc, 0xa1, 0x1f, 0xc0, 0xe7, 0x0, 0xc7, 0x22, 0x71, 0xd3, 0x4d, 0xcc, 0x76, 0x3, 0xbb, 0xa, 0x17, + 0x8f, 0x2a, 0x64, 0x28, 0x2c, 0x19, 0xda, 0x22, 0x5b, 0x90, 0x1, 0x47, 0x12, 0x0, 0x2, 0x3a, 0x30, + 0x21, 0x31, 0x89, 0x0, 0x17, 0xfd, 0x67, 0x63, 0xe0, 0x3a, 0x94, 0x20, 0x76, 0xb9, 0x54, 0x5e, 0x67, + 0x6d, 0x66, 0x9e, 0x5a, 0x11, 0x23, 0xd3, 0x16, 0x23, 0x5b, 0x7e}; + + uint8_t buf[208] = {0}; + + uint8_t bytesprops0[] = {0x25, 0x2a, 0x56, 0xf6, 0x8b, 0xfc, 0x41, 0xfa, 0x8c, 0xd2, + 0xf, 0xda, 0xd5, 0xbe, 0xa4, 0x6b, 0x45, 0x49, 0xfc}; + uint8_t bytesprops1[] = {0x64, 0xe, 0x51, 0xfe, 0x58, 0xbd, 0xf7, 0x56, 0xbe, 0x8c, + 0x90, 0xad, 0x35, 0xd6, 0xf1, 0xa0, 0xa4, 0x2d, 0xe7}; + uint8_t bytesprops2[] = {0x66, 0xb, 0xf0}; + uint8_t bytesprops3[] = {0x8d, 0x75, 0xc9, 0x58, 0xfa, 0x1b, 0x37, 0x60, 0x22, 0x60, 0x14, 0x35, 0xea, 0x90, + 0x6d, 0xd3, 0x87, 0xd1, 0xc7, 0x4e, 0x9e, 0xc7, 0xd6, 0xf4, 0xa5, 0xa2, 0x83}; + uint8_t bytesprops4[] = {0x41, 0x91, 0x1, 0xc2, 0x87, 0xa8, 0x48, 0x4b, 0x1d, 0x15, 0xc, 0xa1, 0x1f, + 0xc0, 0xe7, 0x0, 0xc7, 0x22, 0x71, 0xd3, 0x4d, 0xcc, 0x76, 0x3, 0xbb, 0xa}; + uint8_t bytesprops5[] = {0x3a, 0x30}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20364}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19290}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 251}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20049}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23440}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12681}}, + }; + + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 14063; + uint8_t client_id_bytes[] = {0xfd, 0x67, 0x63, 0xe0, 0x3a, 0x94, 0x20, 0x76, 0xb9, 0x54, 0x5e, 0x67, + 0x6d, 0x66, 0x9e, 0x5a, 0x11, 0x23, 0xd3, 0x16, 0x23, 0x5b, 0x7e}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x4, 0x47, 0xaa, 0x59, 0x84, 0xeb, 0xc1, 0x2, 0x84, 0xec}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "\t\222\159S\165\157.L\191\219\SUB\249\GSF@\235\241t\\\r\130\&4\255\216K\204\246Z\255", _willMsg = +// "\153*>%QC\v\RS\n\183 &\205&Em", _willProps = [PropSessionExpiryInterval 29828,PropUserProperty "c0g\225\157+P" +// "\187\138\&1y\183o\128\&5\133\196t\198\177*_W\203\205\&6\223 b&",PropTopicAliasMaximum 5227,PropMaximumPacketSize +// 7849,PropSubscriptionIdentifierAvailable 157,PropTopicAliasMaximum 27560,PropTopicAliasMaximum +// 2575,PropSubscriptionIdentifier 20,PropMessageExpiryInterval 11317,PropMaximumPacketSize 28505,PropCorrelationData +// "\161\194\180Ejo\168#\153\ESC\184\145\178\GS\254\240S\t\229d\DLEI\243\198",PropRequestProblemInformation +// 194,PropAssignedClientIdentifier "\"\"{28\241r+\182\198\146",PropAuthenticationMethod "\142&\147\255\153c\237'"]}), +// _cleanSession = True, _keepAlive = 8661, _connID = "\213\183*l\161!\168\252p\153\208\254\DC1<\235", _properties = +// [PropResponseInformation "",PropRequestProblemInformation 241,PropMessageExpiryInterval 13783,PropReceiveMaximum +// 29834,PropAuthenticationData +// "\200C\132\EMx*f\241\218lN\ACK\215\183\236\248\222\&5\151\n\141\146\172o\154",PropMessageExpiryInterval +// 23078,PropAuthenticationData +// "\DC3!\149(eo\146,\ETBHn3c\136\209\213\SI\226PZ\166&'\213\198\DC2\229+",PropSharedSubscriptionAvailable +// 231,PropRequestResponseInformation 108,PropSubscriptionIdentifier 25,PropWildcardSubscriptionAvailable +// 232,PropWildcardSubscriptionAvailable 89,PropPayloadFormatIndicator 156,PropWillDelayInterval 30760,PropUserProperty +// "2y\231\136\182E\176\DC1h\148Q\132\b\CAN" +// "\176-yt\234\219\176@\SYNx\b\191S\150\f\ENQk[\v|\199\SUB\"y\ENQX\EOTrH",PropWillDelayInterval 25980]} +TEST(Connect5QCTest, Encode17) { + uint8_t pkt[] = { + 0x10, 0xdc, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x21, 0xd5, 0x93, 0x1, 0x1a, 0x0, 0x0, 0x17, + 0xf1, 0x2, 0x0, 0x0, 0x35, 0xd7, 0x21, 0x74, 0x8a, 0x16, 0x0, 0x19, 0xc8, 0x43, 0x84, 0x19,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x27, 0x0, 0x0, 0x1e, 0xa9, + 0x29, 0x9d, 0x22, 0x6b, 0xa8, 0x22, 0xa, 0xf, 0xb, 0x14, 0x2, 0x0, 0x0, 0x2c, 0x35, 0x27, 0x0, 0x0, 0x6f, + 0x59, 0x9, 0x0, 0x18, 0xa1, 0xc2, 0xb4, 0x45, 0x6a, 0x6f, 0xa8, 0x23, 0x99, 0x1b, 0xb8, 0x91, 0xb2, 0x1d, 0xfe, + 0xf0, 0x53, 0x9, 0xe5, 0x64, 0x10, 0x49, 0xf3, 0xc6, 0x17, 0xc2, 0x12, 0x0, 0xb, 0x22, 0x22, 0x7b, 0x32, 0x38, + 0xf1, 0x72, 0x2b, 0xb6, 0xc6, 0x92, 0x15, 0x0, 0x8, 0x8e, 0x26, 0x93, 0xff, 0x99, 0x63, 0xed, 0x27, 0x0, 0x1d, + 0x9, 0xde, 0x9f, 0x53, 0xa5, 0x9d, 0x2e, 0x4c, 0xbf, 0xdb, 0x1a, 0xf9, 0x1d, 0x46, 0x40, 0xeb, 0xf1, 0x74, 0x5c, + 0xd, 0x82, 0x34, 0xff, 0xd8, 0x4b, 0xcc, 0xf6, 0x5a, 0xff, 0x0, 0x10, 0x99, 0x2a, 0x3e, 0x25, 0x51, 0x43, 0xb, + 0x1e, 0xa, 0xb7, 0x20, 0x26, 0xcd, 0x26, 0x45, 0x6d}; + + uint8_t buf[361] = {0}; + + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xc8, 0x43, 0x84, 0x19, 0x78, 0x2a, 0x66, 0xf1, 0xda, 0x6c, 0x4e, 0x6, 0xd7, + 0xb7, 0xec, 0xf8, 0xde, 0x35, 0x97, 0xa, 0x8d, 0x92, 0xac, 0x6f, 0x9a}; + uint8_t bytesprops2[] = {0x13, 0x21, 0x95, 0x28, 0x65, 0x6f, 0x92, 0x2c, 0x17, 0x48, 0x6e, 0x33, 0x63, 0x88, + 0xd1, 0xd5, 0xf, 0xe2, 0x50, 0x5a, 0xa6, 0x26, 0x27, 0xd5, 0xc6, 0x12, 0xe5, 0x2b}; + uint8_t bytesprops4[] = {0xb0, 0x2d, 0x79, 0x74, 0xea, 0xdb, 0xb0, 0x40, 0x16, 0x78, 0x8, 0xbf, 0x53, 0x96, 0xc, + 0x5, 0x6b, 0x5b, 0xb, 0x7c, 0xc7, 0x1a, 0x22, 0x79, 0x5, 0x58, 0x4, 0x72, 0x48}; + uint8_t bytesprops3[] = {0x32, 0x79, 0xe7, 0x88, 0xb6, 0x45, 0xb0, 0x11, 0x68, 0x94, 0x51, 0x84, 0x8, 0x18}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13783}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29834}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23078}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30760}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops3}, .v = {29, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25980}}, + }; + + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xbb, 0x8a, 0x31, 0x79, 0xb7, 0x6f, 0x80, 0x35, 0x85, 0xc4, 0x74, 0xc6, + 0xb1, 0x2a, 0x5f, 0x57, 0xcb, 0xcd, 0x36, 0xdf, 0x20, 0x62, 0x26}; + uint8_t byteswillprops0[] = {0x63, 0x30, 0x67, 0xe1, 0x9d, 0x2b, 0x50}; + uint8_t byteswillprops2[] = {0xa1, 0xc2, 0xb4, 0x45, 0x6a, 0x6f, 0xa8, 0x23, 0x99, 0x1b, 0xb8, 0x91, + 0xb2, 0x1d, 0xfe, 0xf0, 0x53, 0x9, 0xe5, 0x64, 0x10, 0x49, 0xf3, 0xc6}; + uint8_t byteswillprops3[] = {0x22, 0x22, 0x7b, 0x32, 0x38, 0xf1, 0x72, 0x2b, 0xb6, 0xc6, 0x92}; + uint8_t byteswillprops4[] = {0x8e, 0x26, 0x93, 0xff, 0x99, 0x63, 0xed, 0x27}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29828}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {7, (char*)&byteswillprops0}, .v = {23, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5227}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7849}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27560}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2575}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11317}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28505}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops4}}}, + }; + + lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9, 0xde, 0x9f, 0x53, 0xa5, 0x9d, 0x2e, 0x4c, 0xbf, 0xdb, + 0x1a, 0xf9, 0x1d, 0x46, 0x40, 0xeb, 0xf1, 0x74, 0x5c, 0xd, + 0x82, 0x34, 0xff, 0xd8, 0x4b, 0xcc, 0xf6, 0x5a, 0xff}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x99, 0x2a, 0x3e, 0x25, 0x51, 0x43, 0xb, 0x1e, + 0xa, 0xb7, 0x20, 0x26, 0xcd, 0x26, 0x45, 0x6d}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 8661; + uint8_t client_id_bytes[] = {0xd5, 0xb7, 0x2a, 0x6c, 0xa1, 0x21, 0xa8, 0xfc, + 0x70, 0x99, 0xd0, 0xfe, 0x11, 0x3c, 0xeb}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS1, _willTopic = +// "\\\255\246\RS<\212+\220\248\199\236\132\185\US]D\137\186\&5\193\r\n\237\181\231\246\&6\238\211\221", _willMsg = +// "#%`lDh\222\147\201\155e\153\136\131 [9l\GS\225\NUL^", _willProps = [PropSubscriptionIdentifierAvailable 171]}), +// _cleanSession = True, _keepAlive = 1275, _connID = "^\232\215\163\208\190\139\233T\239\SI\139\vz6}", _properties = +// [PropServerKeepAlive 25090,PropRequestResponseInformation 194,PropAuthenticationMethod +// "\153\225h\DC3dj\SOH\211\159\136e\151X",PropAssignedClientIdentifier +// "\145M\ESC\149d53dKi}",PropSubscriptionIdentifier 9,PropSharedSubscriptionAvailable 42,PropPayloadFormatIndicator +// 229,PropResponseInformation "u\219C\233\206\200\SOH\129r\172\NAK\DC3\214W",PropWillDelayInterval +// 9633,PropResponseTopic "\ENQ\199\203o\171\ESC9\156\250\253\252v\243\253\172\222\171",PropResponseInformation +// "\250",PropSharedSubscriptionAvailable 116,PropRequestResponseInformation 100,PropRequestResponseInformation +// 88,PropResponseTopic "\130\185\189\255\216\159\223\245\210h\159\225\DC4`am\193\FS\201\&7 +// iq\148\DLE\220\205\NAK",PropAuthenticationData +// "WX\180\215\FS\DC2/\252\238\172\243\159\245\&1\241",PropAuthenticationMethod "\167\200Tv\140\211\a&/",PropMaximumQoS +// 72,PropServerKeepAlive 17275,PropMessageExpiryInterval 21530,PropRequestResponseInformation 16,PropTopicAliasMaximum +// 28029,PropServerKeepAlive 12384,PropWillDelayInterval 11964,PropMessageExpiryInterval +// 28696,PropSubscriptionIdentifier 15,PropTopicAlias 13015]} +TEST(Connect5QCTest, Encode18) { + uint8_t pkt[] = { + 0x10, 0x94, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2e, 0x4, 0xfb, 0xbb, 0x1, 0x13, 0x62, 0x2, 0x19, + 0xc2, 0x15, 0x0, 0xd, 0x99, 0xe1, 0x68, 0x13, 0x64, 0x6a, 0x1, 0xd3, 0x9f, 0x88, 0x65, 0x97, 0x58, 0x12, 0x0, + 0xb, 0x91, 0x4d, 0x1b, 0x95, 0x64, 0x35, 0x33, 0x64, 0x4b, 0x69, 0x7d, 0xb, 0x9, 0x2a, 0x2a, 0x1, 0xe5, 0x1a, + 0x0, 0xe,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 0xa, + 0xed, 0xb5, 0xe7, 0xf6, 0x36, 0xee, 0xd3, 0xdd, 0x0, 0x16, 0x23, 0x25, 0x60, 0x6c, 0x44, 0x68, 0xde, 0x93, 0xc9, + 0x9b, 0x65, 0x99, 0x88, 0x83, 0x20, 0x5b, 0x39, 0x6c, 0x1d, 0xe1, 0x0, 0x5e}; + + uint8_t buf[289] = {0}; + + uint8_t bytesprops0[] = {0x99, 0xe1, 0x68, 0x13, 0x64, 0x6a, 0x1, 0xd3, 0x9f, 0x88, 0x65, 0x97, 0x58}; + uint8_t bytesprops1[] = {0x91, 0x4d, 0x1b, 0x95, 0x64, 0x35, 0x33, 0x64, 0x4b, 0x69, 0x7d}; + uint8_t bytesprops2[] = {0x75, 0xdb, 0x43, 0xe9, 0xce, 0xc8, 0x1, 0x81, 0x72, 0xac, 0x15, 0x13, 0xd6, 0x57}; + uint8_t bytesprops3[] = {0x5, 0xc7, 0xcb, 0x6f, 0xab, 0x1b, 0x39, 0x9c, 0xfa, + 0xfd, 0xfc, 0x76, 0xf3, 0xfd, 0xac, 0xde, 0xab}; + uint8_t bytesprops4[] = {0xfa}; + uint8_t bytesprops5[] = {0x82, 0xb9, 0xbd, 0xff, 0xd8, 0x9f, 0xdf, 0xf5, 0xd2, 0x68, 0x9f, 0xe1, 0x14, 0x60, + 0x61, 0x6d, 0xc1, 0x1c, 0xc9, 0x37, 0x20, 0x69, 0x71, 0x94, 0x10, 0xdc, 0xcd, 0x15}; + uint8_t bytesprops6[] = {0x57, 0x58, 0xb4, 0xd7, 0x1c, 0x12, 0x2f, 0xfc, 0xee, 0xac, 0xf3, 0x9f, 0xf5, 0x31, 0xf1}; + uint8_t bytesprops7[] = {0xa7, 0xc8, 0x54, 0x76, 0x8c, 0xd3, 0x7, 0x26, 0x2f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25090}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9633}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17275}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21530}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28029}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12384}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11964}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28696}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13015}}, + }; + + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 171}}, + }; + + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5c, 0xff, 0xf6, 0x1e, 0x3c, 0xd4, 0x2b, 0xdc, 0xf8, 0xc7, + 0xec, 0x84, 0xb9, 0x1f, 0x5d, 0x44, 0x89, 0xba, 0x35, 0xc1, + 0xd, 0xa, 0xed, 0xb5, 0xe7, 0xf6, 0x36, 0xee, 0xd3, 0xdd}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x23, 0x25, 0x60, 0x6c, 0x44, 0x68, 0xde, 0x93, 0xc9, 0x9b, 0x65, + 0x99, 0x88, 0x83, 0x20, 0x5b, 0x39, 0x6c, 0x1d, 0xe1, 0x0, 0x5e}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1275; + uint8_t client_id_bytes[] = {0x5e, 0xe8, 0xd7, 0xa3, 0xd0, 0xbe, 0x8b, 0xe9, + 0x54, 0xef, 0xf, 0x8b, 0xb, 0x7a, 0x36, 0x7d}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// "\212\226\154\ACK\136\237\149\159E\153\b\253\235\250\216\160\201\EM3P\152^\232", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS0, _willTopic = "\128\194\131j\171v\201pWuH\170{=\145O\211\DC3'", _willMsg = +// "\190\132\174 \"\169\179\253\204\&5T\243\160\140^\179\204\131\218H\"6\191lW\184\171d\161K", _willProps = +// [PropResponseInformation +// "\213\250\210\174\160\213\174\236\&4XZ\192\GS\212\\\202\186zvdg\195~\202\240\ESC",PropSubscriptionIdentifierAvailable +// 165,PropTopicAliasMaximum 5284,PropAuthenticationData "|$\183\205\224\&9",PropResponseInformation +// "2T*T\212\251\231\188\240\131\203|\180\168",PropMaximumPacketSize 16,PropTopicAlias 3988,PropMaximumQoS +// 190,PropMessageExpiryInterval 32549,PropPayloadFormatIndicator 165]}), _cleanSession = True, _keepAlive = 30712, +// _connID = "6", _properties = [PropAuthenticationData "\159\212\&4\r\184\DLE",PropResponseTopic +// "\SO\183\148",PropTopicAliasMaximum 25003,PropRequestResponseInformation 220,PropAssignedClientIdentifier +// "\US\185\191\147S\242)\DC3\169@YO\146^\219?\EM",PropUserProperty "\141r\141-\164)n\205U\237d\158\162w^7" +// "\200\167m+\194v\244\142\176\135F \206\154\&2m\EOTsZ&TD+z\185\161",PropAuthenticationData +// "9Vn\235|\n\193\149\206\241r-u",PropAssignedClientIdentifier +// "\RS\145\188\r\241\EOTA\237\v(",PropMessageExpiryInterval 27528,PropWildcardSubscriptionAvailable +// 106,PropMessageExpiryInterval 26165,PropMessageExpiryInterval 16789,PropSubscriptionIdentifierAvailable +// 89,PropRetainAvailable 196,PropSessionExpiryInterval 520,PropAuthenticationMethod +// ",\171\239\149\170",PropResponseInformation "\a3\ACKq\234",PropRequestProblemInformation +// 197,PropSharedSubscriptionAvailable 146,PropResponseInformation +// "t]k\155\178}jP\179",PropWildcardSubscriptionAvailable 93,PropUserProperty "Jh\DC2\RS\202\217\254\163\230\\" +// "Cq\212Y3s\186::B\145\171\146\131\f"]} +TEST(Connect5QCTest, Encode19) { + uint8_t pkt[] = { + 0x10, 0xe0, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x77, 0xf8, 0xce, 0x1, 0x16, 0x0, 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f, 0x43, 0x71, 0xd4, + 0x59, 0x33, 0x73, 0xba, 0x3a, 0x3a, 0x42, 0x91, 0xab, 0x92, 0x83, 0xc, 0x0, 0x1, 0x36, 0x4d, 0x1a, 0x0, 0x1a, + 0xd5, 0xfa, 0xd2, 0xae, 0xa0, 0xd5, 0xae, 0xec, 0x34, 0x58, 0x5a, 0xc0, 0x1d, 0xd4, 0x5c, 0xca, 0xba, 0x7a, 0x76, + 0x64, 0x67, 0xc3, 0x7e, 0xca, 0xf0, 0x1b, 0x29, 0xa5, 0x22, 0x14, 0xa4, 0x16, 0x0, 0x6, 0x7c, 0x24, 0xb7, 0xcd, + 0xe0, 0x39, 0x1a, 0x0, 0xe, 0x32, 0x54, 0x2a, 0x54, 0xd4, 0xfb, 0xe7, 0xbc, 0xf0, 0x83, 0xcb, 0x7c, 0xb4, 0xa8, + 0x27, 0x0, 0x0, 0x0, 0x10, 0x23, 0xf, 0x94, 0x24, 0xbe, 0x2, 0x0, 0x0, 0x7f, 0x25, 0x1, 0xa5, 0x0, 0x13, + 0x80, 0xc2, 0x83, 0x6a, 0xab, 0x76, 0xc9, 0x70, 0x57, 0x75, 0x48, 0xaa, 0x7b, 0x3d, 0x91, 0x4f, 0xd3, 0x13, 0x27, + 0x0, 0x1e, 0xbe, 0x84, 0xae, 0x20, 0x22, 0xa9, 0xb3, 0xfd, 0xcc, 0x35, 0x54, 0xf3, 0xa0, 0x8c, 0x5e, 0xb3, 0xcc, + 0x83, 0xda, 0x48, 0x22, 0x36, 0xbf, 0x6c, 0x57, 0xb8, 0xab, 0x64, 0xa1, 0x4b}; + + uint8_t buf[365] = {0}; + + uint8_t bytesprops0[] = {0x9f, 0xd4, 0x34, 0xd, 0xb8, 0x10}; + uint8_t bytesprops1[] = {0xe, 0xb7, 0x94}; + uint8_t bytesprops2[] = {0x1f, 0xb9, 0xbf, 0x93, 0x53, 0xf2, 0x29, 0x13, 0xa9, + 0x40, 0x59, 0x4f, 0x92, 0x5e, 0xdb, 0x3f, 0x19}; + uint8_t bytesprops4[] = {0xc8, 0xa7, 0x6d, 0x2b, 0xc2, 0x76, 0xf4, 0x8e, 0xb0, 0x87, 0x46, 0x20, 0xce, + 0x9a, 0x32, 0x6d, 0x4, 0x73, 0x5a, 0x26, 0x54, 0x44, 0x2b, 0x7a, 0xb9, 0xa1}; + uint8_t bytesprops3[] = {0x8d, 0x72, 0x8d, 0x2d, 0xa4, 0x29, 0x6e, 0xcd, + 0x55, 0xed, 0x64, 0x9e, 0xa2, 0x77, 0x5e, 0x37}; + uint8_t bytesprops5[] = {0x39, 0x56, 0x6e, 0xeb, 0x7c, 0xa, 0xc1, 0x95, 0xce, 0xf1, 0x72, 0x2d, 0x75}; + uint8_t bytesprops6[] = {0x1e, 0x91, 0xbc, 0xd, 0xf1, 0x4, 0x41, 0xed, 0xb, 0x28}; + uint8_t bytesprops7[] = {0x2c, 0xab, 0xef, 0x95, 0xaa}; + uint8_t bytesprops8[] = {0x7, 0x33, 0x6, 0x71, 0xea}; + uint8_t bytesprops9[] = {0x74, 0x5d, 0x6b, 0x9b, 0xb2, 0x7d, 0x6a, 0x50, 0xb3}; + uint8_t bytesprops11[] = {0x43, 0x71, 0xd4, 0x59, 0x33, 0x73, 0xba, 0x3a, 0x3a, 0x42, 0x91, 0xab, 0x92, 0x83, 0xc}; + uint8_t bytesprops10[] = {0x4a, 0x68, 0x12, 0x1e, 0xca, 0xd9, 0xfe, 0xa3, 0xe6, 0x5c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25003}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {26, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27528}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26165}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16789}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 520}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {10, (char*)&bytesprops10}, .v = {15, (char*)&bytesprops11}}}}, + }; + + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xd5, 0xfa, 0xd2, 0xae, 0xa0, 0xd5, 0xae, 0xec, 0x34, 0x58, 0x5a, 0xc0, 0x1d, + 0xd4, 0x5c, 0xca, 0xba, 0x7a, 0x76, 0x64, 0x67, 0xc3, 0x7e, 0xca, 0xf0, 0x1b}; + uint8_t byteswillprops1[] = {0x7c, 0x24, 0xb7, 0xcd, 0xe0, 0x39}; + uint8_t byteswillprops2[] = {0x32, 0x54, 0x2a, 0x54, 0xd4, 0xfb, 0xe7, 0xbc, 0xf0, 0x83, 0xcb, 0x7c, 0xb4, 0xa8}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5284}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3988}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32549}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 165}}, + }; + + lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x80, 0xc2, 0x83, 0x6a, 0xab, 0x76, 0xc9, 0x70, 0x57, 0x75, + 0x48, 0xaa, 0x7b, 0x3d, 0x91, 0x4f, 0xd3, 0x13, 0x27}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xbe, 0x84, 0xae, 0x20, 0x22, 0xa9, 0xb3, 0xfd, 0xcc, 0x35, + 0x54, 0xf3, 0xa0, 0x8c, 0x5e, 0xb3, 0xcc, 0x83, 0xda, 0x48, + 0x22, 0x36, 0xbf, 0x6c, 0x57, 0xb8, 0xab, 0x64, 0xa1, 0x4b}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 30712; + uint8_t client_id_bytes[] = {0x36}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xd4, 0xe2, 0x9a, 0x6, 0x88, 0xed, 0x95, 0x9f, 0x45, 0x99, 0x8, 0xfd, + 0xeb, 0xfa, 0xd8, 0xa0, 0xc9, 0x19, 0x33, 0x50, 0x98, 0x5e, 0xe8}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "J\RSd\"\EOT.m'\DLE%\174\130S\229\172\198\176\&1\140&\228\RS\149\248\232\234", +// _password = Just "\216\183u\FS\184\187\239\148\140X\251\143\153s\176\218\&3s\168", _lastWill = Nothing, _cleanSession +// = True, _keepAlive = 24465, _connID = "\145\244\189\239z\131f", _properties = [PropMessageExpiryInterval +// 25911,PropMessageExpiryInterval 26152,PropRetainAvailable 109,PropWillDelayInterval 1298,PropMaximumPacketSize +// 1990,PropAssignedClientIdentifier "\227\191\148\NUL\ETB\SYNnU",PropWildcardSubscriptionAvailable 81,PropUserProperty +// "\183Z\214\198\215v\254ar\128\v\178\DC2\203mj" "",PropSessionExpiryInterval 6212,PropReceiveMaximum +// 1155,PropTopicAlias 10564,PropResponseTopic +// "\171#\144\222\DC2\195y\220#\183V?y\144\145\187#\219\159",PropAssignedClientIdentifier +// "\230l\250\137/\224\215\n\248n\252\t\194\&9",PropSharedSubscriptionAvailable 20,PropCorrelationData +// "",PropResponseTopic "Lq\184\226\204\158Y\207g\250\136\NAK\128",PropSubscriptionIdentifierAvailable +// 197,PropRetainAvailable 146]} +TEST(Connect5QCTest, Encode20) { + uint8_t pkt[] = { + 0x10, 0xc9, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x5f, 0x91, 0x83, 0x1, 0x2, 0x0, 0x0, 0x65, + 0x37, 0x2, 0x0, 0x0, 0x66, 0x28, 0x25, 0x6d, 0x18, 0x0, 0x0, 0x5, 0x12, 0x27, 0x0, 0x0, 0x7, 0xc6, 0x12, + 0x0, 0x8, 0xe3, 0xbf, 0x94, 0x0, 0x17, 0x16, 0x6e, 0x55, 0x28, 0x51, 0x26, 0x0, 0x10, 0xb7, 0x5a, 0xd6, 0xc6, + 0xd7, 0x76, 0xfe, 0x61, 0x72, 0x80, 0xb, 0xb2, 0x12, 0xcb, 0x6d, 0x6a, 0x0, 0x0, 0x11, 0x0, 0x0, 0x18, 0x44, + 0x21, 0x4, 0x83, 0x23, 0x29, 0x44, 0x8, 0x0, 0x13, 0xab, 0x23, 0x90, 0xde, 0x12, 0xc3, 0x79, 0xdc, 0x23, 0xb7, + 0x56, 0x3f, 0x79, 0x90, 0x91, 0xbb, 0x23, 0xdb, 0x9f, 0x12, 0x0, 0xe, 0xe6, 0x6c, 0xfa, 0x89, 0x2f, 0xe0, 0xd7, + 0xa, 0xf8, 0x6e, 0xfc, 0x9, 0xc2, 0x39, 0x2a, 0x14, 0x9, 0x0, 0x0, 0x8, 0x0, 0xd, 0x4c, 0x71, 0xb8, 0xe2, + 0xcc, 0x9e, 0x59, 0xcf, 0x67, 0xfa, 0x88, 0x15, 0x80, 0x29, 0xc5, 0x25, 0x92, 0x0, 0x7, 0x91, 0xf4, 0xbd, 0xef, + 0x7a, 0x83, 0x66, 0x0, 0x1a, 0x4a, 0x1e, 0x64, 0x22, 0x4, 0x2e, 0x6d, 0x27, 0x10, 0x25, 0xae, 0x82, 0x53, 0xe5, + 0xac, 0xc6, 0xb0, 0x31, 0x8c, 0x26, 0xe4, 0x1e, 0x95, 0xf8, 0xe8, 0xea, 0x0, 0x13, 0xd8, 0xb7, 0x75, 0x1c, 0xb8, + 0xbb, 0xef, 0x94, 0x8c, 0x58, 0xfb, 0x8f, 0x99, 0x73, 0xb0, 0xda, 0x33, 0x73, 0xa8}; + + uint8_t buf[214] = {0}; + + uint8_t bytesprops0[] = {0xe3, 0xbf, 0x94, 0x0, 0x17, 0x16, 0x6e, 0x55}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops1[] = {0xb7, 0x5a, 0xd6, 0xc6, 0xd7, 0x76, 0xfe, 0x61, + 0x72, 0x80, 0xb, 0xb2, 0x12, 0xcb, 0x6d, 0x6a}; + uint8_t bytesprops3[] = {0xab, 0x23, 0x90, 0xde, 0x12, 0xc3, 0x79, 0xdc, 0x23, 0xb7, + 0x56, 0x3f, 0x79, 0x90, 0x91, 0xbb, 0x23, 0xdb, 0x9f}; + uint8_t bytesprops4[] = {0xe6, 0x6c, 0xfa, 0x89, 0x2f, 0xe0, 0xd7, 0xa, 0xf8, 0x6e, 0xfc, 0x9, 0xc2, 0x39}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0x4c, 0x71, 0xb8, 0xe2, 0xcc, 0x9e, 0x59, 0xcf, 0x67, 0xfa, 0x88, 0x15, 0x80}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25911}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26152}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1298}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1990}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {0, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6212}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1155}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10564}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 24465; + uint8_t client_id_bytes[] = {0x91, 0xf4, 0xbd, 0xef, 0x7a, 0x83, 0x66}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x4a, 0x1e, 0x64, 0x22, 0x4, 0x2e, 0x6d, 0x27, 0x10, 0x25, 0xae, 0x82, 0x53, + 0xe5, 0xac, 0xc6, 0xb0, 0x31, 0x8c, 0x26, 0xe4, 0x1e, 0x95, 0xf8, 0xe8, 0xea}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xd8, 0xb7, 0x75, 0x1c, 0xb8, 0xbb, 0xef, 0x94, 0x8c, 0x58, + 0xfb, 0x8f, 0x99, 0x73, 0xb0, 0xda, 0x33, 0x73, 0xa8}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\168\152\190:\152\"\217OGs\207_\233\129\248**\131N\190\167q;\253\ETB", _password = +// Just "hq\130\190\144\NUL\227\253\208\215\224\167\FS\203\EOT(\169\158\166\134)g\184\233\145\138*u", _lastWill = +// Nothing, _cleanSession = True, _keepAlive = 147, _connID = "\198@\194\222\146s", _properties = +// [PropPayloadFormatIndicator 143,PropCorrelationData +// "\157Ea4\197\&8\202\EOTAd\US\151\142\&9sC\163O\232\150\239\&0-\176\201\143?\217(",PropMaximumQoS +// 147,PropWildcardSubscriptionAvailable 91,PropAuthenticationData +// "\148\ENQ\ETX\197UL\188Q\232\221S\245\172",PropWillDelayInterval 29870,PropSubscriptionIdentifier +// 11,PropPayloadFormatIndicator 220,PropResponseInformation +// "\DC4\DEL\STX\158\SUB\DLE\ACK\DLE\154\204\223\161\DC4\249\212:\245D\174:\147sA\247\147H\240",PropReasonString +// "\DC1\146\254\142\222\171xo\159%\SO/",PropAssignedClientIdentifier "l",PropPayloadFormatIndicator +// 86,PropRequestResponseInformation 19,PropReasonString +// "\174\167r\166\217>\NUL}Z\154eu\252\234\136#Q\199\221\253\185\227\245\253",PropRequestResponseInformation +// 241,PropContentType "\191\251O\179\DC2\163\&9$\162\190&\144;~)\191Q\251",PropSubscriptionIdentifier +// 10,PropUserProperty "\144\193k\172\172\"\STX\162" "U\215\EOT\204\214\255\DC2dk\198\250\160",PropContentType +// "\190\156:6\145\195\186\167\144X\221Zq\224\228n\131P\240\171\172:\GSc",PropContentType +// "J\FS\180\187\130\&9\249\188&\215\a\244\SUBw\ao\215\203\171\199uCb",PropSharedSubscriptionAvailable +// 255,PropAssignedClientIdentifier "\138\133\203?"]} +TEST(Connect5QCTest, Encode21) { + uint8_t pkt[] = { + 0x10, 0xcc, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x0, 0x93, 0xff, 0x1, 0x1, 0x8f, 0x9, 0x0, + 0x1d, 0x9d, 0x45, 0x61, 0x34, 0xc5, 0x38, 0xca, 0x4, 0x41, 0x64, 0x1f, 0x97, 0x8e, 0x39, 0x73, 0x43, 0xa3, 0x4f, + 0xe8, 0x96, 0xef, 0x30, 0x2d, 0xb0, 0xc9, 0x8f, 0x3f, 0x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, 0x63, 0x3, 0x0, 0x17, 0x4a, 0x1c, 0xb4, 0xbb, 0x82, 0x39, 0xf9, 0xbc, 0x26, + 0xd7, 0x7, 0xf4, 0x1a, 0x77, 0x7, 0x6f, 0xd7, 0xcb, 0xab, 0xc7, 0x75, 0x43, 0x62, 0x2a, 0xff, 0x12, 0x0, 0x4, + 0x8a, 0x85, 0xcb, 0x3f, 0x0, 0x6, 0xc6, 0x40, 0xc2, 0xde, 0x92, 0x73, 0x0, 0x19, 0xa8, 0x98, 0xbe, 0x3a, 0x98, + 0x22, 0xd9, 0x4f, 0x47, 0x73, 0xcf, 0x5f, 0xe9, 0x81, 0xf8, 0x2a, 0x2a, 0x83, 0x4e, 0xbe, 0xa7, 0x71, 0x3b, 0xfd, + 0x17, 0x0, 0x1c, 0x68, 0x71, 0x82, 0xbe, 0x90, 0x0, 0xe3, 0xfd, 0xd0, 0xd7, 0xe0, 0xa7, 0x1c, 0xcb, 0x4, 0x28, + 0xa9, 0x9e, 0xa6, 0x86, 0x29, 0x67, 0xb8, 0xe9, 0x91, 0x8a, 0x2a, 0x75}; + + uint8_t buf[345] = {0}; + + uint8_t bytesprops0[] = {0x9d, 0x45, 0x61, 0x34, 0xc5, 0x38, 0xca, 0x4, 0x41, 0x64, 0x1f, 0x97, 0x8e, 0x39, 0x73, + 0x43, 0xa3, 0x4f, 0xe8, 0x96, 0xef, 0x30, 0x2d, 0xb0, 0xc9, 0x8f, 0x3f, 0xd9, 0x28}; + uint8_t bytesprops1[] = {0x94, 0x5, 0x3, 0xc5, 0x55, 0x4c, 0xbc, 0x51, 0xe8, 0xdd, 0x53, 0xf5, 0xac}; + uint8_t bytesprops2[] = {0x14, 0x7f, 0x2, 0x9e, 0x1a, 0x10, 0x6, 0x10, 0x9a, 0xcc, 0xdf, 0xa1, 0x14, 0xf9, + 0xd4, 0x3a, 0xf5, 0x44, 0xae, 0x3a, 0x93, 0x73, 0x41, 0xf7, 0x93, 0x48, 0xf0}; + uint8_t bytesprops3[] = {0x11, 0x92, 0xfe, 0x8e, 0xde, 0xab, 0x78, 0x6f, 0x9f, 0x25, 0xe, 0x2f}; + uint8_t bytesprops4[] = {0x6c}; + uint8_t bytesprops5[] = {0xae, 0xa7, 0x72, 0xa6, 0xd9, 0x3e, 0x0, 0x7d, 0x5a, 0x9a, 0x65, 0x75, + 0xfc, 0xea, 0x88, 0x23, 0x51, 0xc7, 0xdd, 0xfd, 0xb9, 0xe3, 0xf5, 0xfd}; + uint8_t bytesprops6[] = {0xbf, 0xfb, 0x4f, 0xb3, 0x12, 0xa3, 0x39, 0x24, 0xa2, + 0xbe, 0x26, 0x90, 0x3b, 0x7e, 0x29, 0xbf, 0x51, 0xfb}; + uint8_t bytesprops8[] = {0x55, 0xd7, 0x4, 0xcc, 0xd6, 0xff, 0x12, 0x64, 0x6b, 0xc6, 0xfa, 0xa0}; + uint8_t bytesprops7[] = {0x90, 0xc1, 0x6b, 0xac, 0xac, 0x22, 0x2, 0xa2}; + uint8_t bytesprops9[] = {0xbe, 0x9c, 0x3a, 0x36, 0x91, 0xc3, 0xba, 0xa7, 0x90, 0x58, 0xdd, 0x5a, + 0x71, 0xe0, 0xe4, 0x6e, 0x83, 0x50, 0xf0, 0xab, 0xac, 0x3a, 0x1d, 0x63}; + uint8_t bytesprops10[] = {0x4a, 0x1c, 0xb4, 0xbb, 0x82, 0x39, 0xf9, 0xbc, 0x26, 0xd7, 0x7, 0xf4, + 0x1a, 0x77, 0x7, 0x6f, 0xd7, 0xcb, 0xab, 0xc7, 0x75, 0x43, 0x62}; + uint8_t bytesprops11[] = {0x8a, 0x85, 0xcb, 0x3f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29870}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops7}, .v = {12, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops11}}}, + }; + + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 147; + uint8_t client_id_bytes[] = {0xc6, 0x40, 0xc2, 0xde, 0x92, 0x73}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa8, 0x98, 0xbe, 0x3a, 0x98, 0x22, 0xd9, 0x4f, 0x47, 0x73, 0xcf, 0x5f, 0xe9, + 0x81, 0xf8, 0x2a, 0x2a, 0x83, 0x4e, 0xbe, 0xa7, 0x71, 0x3b, 0xfd, 0x17}; + lwmqtt_string_t username = {25, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x68, 0x71, 0x82, 0xbe, 0x90, 0x0, 0xe3, 0xfd, 0xd0, 0xd7, 0xe0, 0xa7, 0x1c, 0xcb, + 0x4, 0x28, 0xa9, 0x9e, 0xa6, 0x86, 0x29, 0x67, 0xb8, 0xe9, 0x91, 0x8a, 0x2a, 0x75}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "9?\213\ESC\211\DLE", _lastWill = Nothing, _cleanSession = +// False, _keepAlive = 13768, _connID = +// "x\172\tI\199\244\238\243\130\&9.\206\172\ETB\SYN\164\GS\EM\128\142S\217\184\NAK]Q\209;\SUBN", _properties = +// [PropWillDelayInterval 17575,PropUserProperty "\216u|\131\168\247\t\188\DEL\140M\183\253\195\192" +// "5\t",PropMessageExpiryInterval 10754,PropSubscriptionIdentifierAvailable 60,PropWildcardSubscriptionAvailable +// 90,PropTopicAliasMaximum 8351,PropContentType "\128}|D\139\190\235G\129\173R\DC299",PropRetainAvailable +// 39,PropWillDelayInterval 5356,PropMessageExpiryInterval 12914,PropMessageExpiryInterval 5103,PropResponseInformation +// "+\195l\250&\EOTQ\235\200\245g\189\180\246jF:\175",PropResponseInformation +// "\130\205;q\203gs\ESC\\slL\EM)4}\177\163\f~\251D2E;9\SI[\176",PropSubscriptionIdentifierAvailable +// 84,PropRetainAvailable 95,PropSubscriptionIdentifier 15,PropCorrelationData +// "\232\190\241\128\239\254\240\238\189oI\204@qq\133\128\211\133\&1\153D\221",PropReceiveMaximum 19357]} +TEST(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, 0xf4, 0xee, 0xf3, 0x82, 0x39, 0x2e, 0xce, + 0xac, 0x17, 0x16, 0xa4, 0x1d, 0x19, 0x80, 0x8e, 0x53, 0xd9, 0xb8, 0x15, 0x5d, 0x51, 0xd1, 0x3b, 0x1a, 0x4e}; + + uint8_t buf[218] = {0}; + + uint8_t bytesprops1[] = {0x35, 0x9}; + uint8_t bytesprops0[] = {0xd8, 0x75, 0x7c, 0x83, 0xa8, 0xf7, 0x9, 0xbc, 0x7f, 0x8c, 0x4d, 0xb7, 0xfd, 0xc3, 0xc0}; + uint8_t bytesprops2[] = {0x80, 0x7d, 0x7c, 0x44, 0x8b, 0xbe, 0xeb, 0x47, 0x81, 0xad, 0x52, 0x12, 0x39, 0x39}; + uint8_t bytesprops3[] = {0x2b, 0xc3, 0x6c, 0xfa, 0x26, 0x4, 0x51, 0xeb, 0xc8, + 0xf5, 0x67, 0xbd, 0xb4, 0xf6, 0x6a, 0x46, 0x3a, 0xaf}; + uint8_t bytesprops4[] = {0x82, 0xcd, 0x3b, 0x71, 0xcb, 0x67, 0x73, 0x1b, 0x5c, 0x73, 0x6c, 0x4c, 0x19, 0x29, 0x34, + 0x7d, 0xb1, 0xa3, 0xc, 0x7e, 0xfb, 0x44, 0x32, 0x45, 0x3b, 0x39, 0xf, 0x5b, 0xb0}; + uint8_t bytesprops5[] = {0xe8, 0xbe, 0xf1, 0x80, 0xef, 0xfe, 0xf0, 0xee, 0xbd, 0x6f, 0x49, 0xcc, + 0x40, 0x71, 0x71, 0x85, 0x80, 0xd3, 0x85, 0x31, 0x99, 0x44, 0xdd}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17575}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {2, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10754}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8351}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5356}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12914}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5103}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19357}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 13768; + uint8_t client_id_bytes[] = {0x78, 0xac, 0x9, 0x49, 0xc7, 0xf4, 0xee, 0xf3, 0x82, 0x39, + 0x2e, 0xce, 0xac, 0x17, 0x16, 0xa4, 0x1d, 0x19, 0x80, 0x8e, + 0x53, 0xd9, 0xb8, 0x15, 0x5d, 0x51, 0xd1, 0x3b, 0x1a, 0x4e}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x39, 0x3f, 0xd5, 0x1b, 0xd3, 0x10}; + lwmqtt_string_t password = {6, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// ";\152\206s\182\199\197\227\135\ACK\251\"Z\DLE\203\162ab\203\169\203\208\172\230\&6\EOT8eS`", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "", _willMsg = "\157\160\156\193A", _willProps = +// [PropRetainAvailable 238,PropMessageExpiryInterval 5930,PropAuthenticationMethod +// "\177\238/\141%\149i\155\170\a\204",PropRequestResponseInformation 202,PropPayloadFormatIndicator +// 52,PropRequestResponseInformation 250,PropAuthenticationMethod "?\133\191\230\140x*Q\172",PropSubscriptionIdentifier +// 14,PropReceiveMaximum 30728,PropAssignedClientIdentifier "_\EM\196\215",PropAssignedClientIdentifier +// "\192>E\160Z\211'\218\196\ENQ",PropCorrelationData "%\247(6\170",PropSubscriptionIdentifierAvailable 149]}), +// _cleanSession = False, _keepAlive = 23561, _connID = "\228\240", _properties = [PropMessageExpiryInterval +// 22985,PropAssignedClientIdentifier "\142P\178\230\194\176[\ETB\182\&5\163\230c\SYNB",PropWillDelayInterval +// 27154,PropWillDelayInterval 26341]} +TEST(Connect5QCTest, Encode23) { + uint8_t pkt[] = {0x10, 0x84, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2c, 0x5c, 0x9, 0x21, 0x2, 0x0, 0x0, + 0x59, 0xc9, 0x12, 0x0, 0xf, 0x8e, 0x50, 0xb2, 0xe6, 0xc2, 0xb0, 0x5b, 0x17, 0xb6, 0x35, 0xa3, 0xe6, + 0x63, 0x16, 0x42, 0x18, 0x0, 0x0, 0x6a, 0x12, 0x18, 0x0, 0x0, 0x66, 0xe5, 0x0, 0x2, 0xe4, 0xf0, + 0x4a, 0x25, 0xee, 0x2, 0x0, 0x0, 0x17, 0x2a, 0x15, 0x0, 0xb, 0xb1, 0xee, 0x2f, 0x8d, 0x25, 0x95, + 0x69, 0x9b, 0xaa, 0x7, 0xcc, 0x19, 0xca, 0x1, 0x34, 0x19, 0xfa, 0x15, 0x0, 0x9, 0x3f, 0x85, 0xbf, + 0xe6, 0x8c, 0x78, 0x2a, 0x51, 0xac, 0xb, 0xe, 0x21, 0x78, 0x8, 0x12, 0x0, 0x4, 0x5f, 0x19, 0xc4, + 0xd7, 0x12, 0x0, 0xa, 0xc0, 0x3e, 0x45, 0xa0, 0x5a, 0xd3, 0x27, 0xda, 0xc4, 0x5, 0x9, 0x0, 0x5, + 0x25, 0xf7, 0x28, 0x36, 0xaa, 0x29, 0x95, 0x0, 0x0, 0x0, 0x5, 0x9d, 0xa0, 0x9c, 0xc1, 0x41}; + + uint8_t buf[145] = {0}; + + uint8_t bytesprops0[] = {0x8e, 0x50, 0xb2, 0xe6, 0xc2, 0xb0, 0x5b, 0x17, 0xb6, 0x35, 0xa3, 0xe6, 0x63, 0x16, 0x42}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22985}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27154}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26341}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xb1, 0xee, 0x2f, 0x8d, 0x25, 0x95, 0x69, 0x9b, 0xaa, 0x7, 0xcc}; + uint8_t byteswillprops1[] = {0x3f, 0x85, 0xbf, 0xe6, 0x8c, 0x78, 0x2a, 0x51, 0xac}; + uint8_t byteswillprops2[] = {0x5f, 0x19, 0xc4, 0xd7}; + uint8_t byteswillprops3[] = {0xc0, 0x3e, 0x45, 0xa0, 0x5a, 0xd3, 0x27, 0xda, 0xc4, 0x5}; + uint8_t byteswillprops4[] = {0x25, 0xf7, 0x28, 0x36, 0xaa}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5930}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30728}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 149}}, + }; + + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x9d, 0xa0, 0x9c, 0xc1, 0x41}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 23561; + uint8_t client_id_bytes[] = {0xe4, 0xf0}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x3b, 0x98, 0xce, 0x73, 0xb6, 0xc7, 0xc5, 0xe3, 0x87, 0x6, 0xfb, 0x22, 0x5a, 0x10, 0xcb, + 0xa2, 0x61, 0x62, 0xcb, 0xa9, 0xcb, 0xd0, 0xac, 0xe6, 0x36, 0x4, 0x38, 0x65, 0x53, 0x60}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\254\245:\136]\202n\222\DC3n\218\215\210", _password = Just +// "6\234}\152\181\DC2\ACKM\245:\DC2\ENQ\249\205q+", _lastWill = Nothing, _cleanSession = True, _keepAlive = 2628, +// _connID = "\131/w\176\163", _properties = [PropResponseTopic "f\173jnbG\135\200\&5)\226B<\137&Z",PropSubscriptionIdentifier 9,PropSharedSubscriptionAvailable +// 223,PropPayloadFormatIndicator 104,PropResponseInformation +// "\DLE\242\&5\231K\158\147o-\230\140\230u\246\206\211\250\225.G1H",PropSubscriptionIdentifierAvailable +// 29,PropAuthenticationData "!f\179a\254&k\SOH\222\149\&6\168\196v\158qD\ETB\159\RS\f\232\172s"]} +TEST(Connect5QCTest, Encode24) { + uint8_t pkt[] = {0x10, 0xc1, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0xa, 0x44, 0x8d, 0x1, 0x8, 0x0, + 0xb, 0x66, 0xad, 0x6a, 0x6e, 0x62, 0x47, 0x3c, 0x7a, 0xe9, 0x74, 0x84, 0x19, 0x95, 0x1, 0x1c, 0x16, + 0x0, 0x6, 0x2e, 0xff, 0xc1, 0x1, 0x7d, 0x8d, 0x11, 0x0, 0x0, 0x16, 0xe3, 0x2a, 0xf5, 0x18, 0x0, + 0x0, 0x10, 0x2e, 0x26, 0x0, 0x15, 0xa2, 0x42, 0x72, 0x51, 0xb5, 0xad, 0x58, 0xf8, 0x7c, 0x1a, 0x3b, + 0x3, 0x27, 0xfd, 0x4c, 0xaf, 0x12, 0xc1, 0x97, 0xfd, 0x8e, 0x0, 0x2, 0xba, 0x63, 0x1c, 0x0, 0xb, + 0x3e, 0x87, 0xc8, 0x35, 0x29, 0xe2, 0x42, 0x3c, 0x89, 0x26, 0x5a, 0xb, 0x9, 0x2a, 0xdf, 0x1, 0x68, + 0x1a, 0x0, 0x16, 0x10, 0xf2, 0x35, 0xe7, 0x4b, 0x9e, 0x93, 0x6f, 0x2d, 0xe6, 0x8c, 0xe6, 0x75, 0xf6, + 0xce, 0xd3, 0xfa, 0xe1, 0x2e, 0x47, 0x31, 0x48, 0x29, 0x1d, 0x16, 0x0, 0x18, 0x21, 0x66, 0xb3, 0x61, + 0xfe, 0x26, 0x6b, 0x1, 0xde, 0x95, 0x36, 0xa8, 0xc4, 0x76, 0x9e, 0x71, 0x44, 0x17, 0x9f, 0x1e, 0xc, + 0xe8, 0xac, 0x73, 0x0, 0x5, 0x83, 0x2f, 0x77, 0xb0, 0xa3, 0x0, 0xd, 0xfe, 0xf5, 0x3a, 0x88, 0x5d, + 0xca, 0x6e, 0xde, 0x13, 0x6e, 0xda, 0xd7, 0xd2, 0x0, 0x10, 0x36, 0xea, 0x7d, 0x98, 0xb5, 0x12, 0x6, + 0x4d, 0xf5, 0x3a, 0x12, 0x5, 0xf9, 0xcd, 0x71, 0x2b}; + + uint8_t buf[206] = {0}; + + uint8_t bytesprops0[] = {0x66, 0xad, 0x6a, 0x6e, 0x62, 0x47, 0x3c, 0x7a, 0xe9, 0x74, 0x84}; + uint8_t bytesprops1[] = {0x2e, 0xff, 0xc1, 0x1, 0x7d, 0x8d}; + uint8_t bytesprops3[] = {0xba, 0x63}; + uint8_t bytesprops2[] = {0xa2, 0x42, 0x72, 0x51, 0xb5, 0xad, 0x58, 0xf8, 0x7c, 0x1a, 0x3b, + 0x3, 0x27, 0xfd, 0x4c, 0xaf, 0x12, 0xc1, 0x97, 0xfd, 0x8e}; + uint8_t bytesprops4[] = {0x3e, 0x87, 0xc8, 0x35, 0x29, 0xe2, 0x42, 0x3c, 0x89, 0x26, 0x5a}; + uint8_t bytesprops5[] = {0x10, 0xf2, 0x35, 0xe7, 0x4b, 0x9e, 0x93, 0x6f, 0x2d, 0xe6, 0x8c, + 0xe6, 0x75, 0xf6, 0xce, 0xd3, 0xfa, 0xe1, 0x2e, 0x47, 0x31, 0x48}; + uint8_t bytesprops6[] = {0x21, 0x66, 0xb3, 0x61, 0xfe, 0x26, 0x6b, 0x1, 0xde, 0x95, 0x36, 0xa8, + 0xc4, 0x76, 0x9e, 0x71, 0x44, 0x17, 0x9f, 0x1e, 0xc, 0xe8, 0xac, 0x73}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5859}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4142}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {2, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops6}}}, + }; + + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 2628; + uint8_t client_id_bytes[] = {0x83, 0x2f, 0x77, 0xb0, 0xa3}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xfe, 0xf5, 0x3a, 0x88, 0x5d, 0xca, 0x6e, 0xde, 0x13, 0x6e, 0xda, 0xd7, 0xd2}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x36, 0xea, 0x7d, 0x98, 0xb5, 0x12, 0x6, 0x4d, + 0xf5, 0x3a, 0x12, 0x5, 0xf9, 0xcd, 0x71, 0x2b}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\155\217\NUL\219N>c\218$.jM\158\CAN\213\ENQA;\185\148\147T\180\244", _password = +// Just "\167\228\243\219\223\142\140\SUB-\206\&0\STXF\ACK\146\186V\DC1\167&Nk\SOH8\132", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 23808, _connID = +// "\240\217\175\155|O\226\&49\201\243L\176\239f\233\177`\130\154\221", _properties = [PropReasonString +// "\134\NAKW\244",PropAssignedClientIdentifier +// "\RS\227\154\160~\164\235\211H\170\160C\203\155\191\v",PropRequestProblemInformation 24,PropAuthenticationData +// "fe&\fTpK\CAN\197ZQ}\240(\r\141\251\255\SOHJ\ENQG\173",PropResponseTopic +// "\187\DLEh\154\191\152\180",PropServerKeepAlive 19082,PropSubscriptionIdentifier 4,PropMaximumQoS +// 151,PropUserProperty "t\167\209S\253;3[\179Er\nHE\142\f\v" "\146\129\186p\143Hk",PropMaximumPacketSize 2628]} +TEST(Connect5QCTest, Encode25) { + uint8_t pkt[] = {0x10, 0xc0, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x5d, 0x0, 0x69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props0[] = {0x86, 0x15, 0x57, 0xf4}; + uint8_t bytesprops1[] = {0x1e, 0xe3, 0x9a, 0xa0, 0x7e, 0xa4, 0xeb, 0xd3, + 0x48, 0xaa, 0xa0, 0x43, 0xcb, 0x9b, 0xbf, 0xb}; + uint8_t bytesprops2[] = {0x66, 0x65, 0x26, 0xc, 0x54, 0x70, 0x4b, 0x18, 0xc5, 0x5a, 0x51, 0x7d, + 0xf0, 0x28, 0xd, 0x8d, 0xfb, 0xff, 0x1, 0x4a, 0x5, 0x47, 0xad}; + uint8_t bytesprops3[] = {0xbb, 0x10, 0x68, 0x9a, 0xbf, 0x98, 0xb4}; + uint8_t bytesprops5[] = {0x92, 0x81, 0xba, 0x70, 0x8f, 0x48, 0x6b}; + uint8_t bytesprops4[] = {0x74, 0xa7, 0xd1, 0x53, 0xfd, 0x3b, 0x33, 0x5b, 0xb3, + 0x45, 0x72, 0xa, 0x48, 0x45, 0x8e, 0xc, 0xb}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19082}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops4}, .v = {7, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2628}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 23808; + uint8_t client_id_bytes[] = {0xf0, 0xd9, 0xaf, 0x9b, 0x7c, 0x4f, 0xe2, 0x34, 0x39, 0xc9, 0xf3, + 0x4c, 0xb0, 0xef, 0x66, 0xe9, 0xb1, 0x60, 0x82, 0x9a, 0xdd}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x9b, 0xd9, 0x0, 0xdb, 0x4e, 0x3e, 0x63, 0xda, 0x24, 0x2e, 0x6a, 0x4d, + 0x9e, 0x18, 0xd5, 0x5, 0x41, 0x3b, 0xb9, 0x94, 0x93, 0x54, 0xb4, 0xf4}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xa7, 0xe4, 0xf3, 0xdb, 0xdf, 0x8e, 0x8c, 0x1a, 0x2d, 0xce, 0x30, 0x2, 0x46, + 0x6, 0x92, 0xba, 0x56, 0x11, 0xa7, 0x26, 0x4e, 0x6b, 0x1, 0x38, 0x84}; + lwmqtt_string_t password = {25, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\147\ENQI\173\FS\139y\171U\167\&2\200\241\231_S\207A\193.'\DC3-\t", _password = +// Just "\224M\229\196\155\f", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "4g\167(\247", _willMsg = "e\SYNy\187{\214", _willProps = [PropResponseInformation +// "\232\174\152\213f\144\240r",PropSubscriptionIdentifier 17,PropContentType +// "\190Y\ESCU\254\253\248>V\128\v=\166\166\192\188\DC2\200\227\192\187\231\157\RS\252Rv\196\155",PropMessageExpiryInterval +// 12137,PropMaximumQoS 175,PropCorrelationData "`\185\255\158\151\205\221\141=-\236P\140\130\135Iu",PropResponseTopic +// "\215\203\r\176\215\133\DC1\189\131$\238e1O/\203\223\207\149H?R\132YZ\195Q",PropAuthenticationData +// "IJ\CAN\166\GS+\137\EM8",PropReasonString +// "\FS\ENQ\221an\136\130\169\EM\245~\228Oy\195\SOH;9\160[\170\&6*c\166\188\206\228",PropReceiveMaximum +// 4886,PropRequestProblemInformation 47,PropAuthenticationMethod +// "\242\&7/\159S\215}y\135$+\136\ETB\221y6\192g|\SUBn\141#MH\187\166\244",PropReasonString +// "\254\154\181\216m\175\193ic\255\210T\139\172\133",PropSessionExpiryInterval 28988,PropCorrelationData +// "aw,\209\179\n0\243Z\153\DC4\181B\190\SO\235\209\178$\246\\",PropServerReference +// "\154<\EOT\199+\252\147\189EV]h\RS\v",PropReceiveMaximum 31344,PropMessageExpiryInterval +// 1883,PropAuthenticationMethod "\208\232\151U\195\178\174X\144\213]\168\EOT\176",PropRequestResponseInformation +// 134,PropSessionExpiryInterval 14426,PropServerReference +// "\GS\152\253\STX\221\FSt\195\134\197\254\204)E+\128,",PropAuthenticationMethod +// "\206%\164\DLE`\196Vn\ETX\136E\DC2s\156\228]]\205B\223\248\a<<\228\ETX",PropReasonString +// "\234l\DC2\155C\162\158\ACK\EM\252\174R",PropContentType "\245\182.t",PropReasonString +// "@\204:N\f\129\243\170\128\157\192\212\130\248z\US\178\ENQ",PropWillDelayInterval 4586,PropTopicAlias 4212]}), +// _cleanSession = False, _keepAlive = 32591, _connID = +// "5\226G\145\159\238\225\NAK\DC2\SUB\RSc\ENQ\ACKr\238+\128\191\218\DC2\230\143X", _properties = +// [PropAssignedClientIdentifier +// "\146\146\202\208n\208X\160\ETXc\bu'\243h\146\152F\SUBw\145\205/\188RT\148S]",PropWildcardSubscriptionAvailable +// 201,PropRequestProblemInformation 25,PropRequestResponseInformation 117,PropServerKeepAlive +// 27326,PropMaximumPacketSize 13373,PropReasonString +// "\ETB\NUL}\250\131\161\bX>\GS?\212\150\&5?,\226",PropSubscriptionIdentifier 9,PropCorrelationData +// "\181x{",PropServerKeepAlive 10603,PropRetainAvailable 59,PropSessionExpiryInterval 16761,PropWillDelayInterval +// 31394,PropUserProperty "\ACKP\220c*\253`I\aP\174\173\SYNG\202\SUB\142\&5~\\\EM\145" +// "\222\208\ACKwE\241r\f\148\162\130\SI\186\249\224!\198`\215;\183\160\ETB*o\200\130\156",PropResponseTopic +// "\STX\204\207\142]\226\163\254\CAN\169\139\222\219\"\167)&k42\207\201\146\&9%\a\174",PropResponseInformation +// "P",PropSharedSubscriptionAvailable 186,PropResponseInformation +// "F\GS\tvkF,\221\247'M<\SO.P%-\129%\133f?\NAK\153\212\213",PropTopicAliasMaximum 17345,PropSharedSubscriptionAvailable +// 242,PropResponseInformation "e\EM\ENQ\147j",PropContentType +// "\171$\GS\151\&1\169&\176\255\201~c\130",PropRequestResponseInformation 23,PropAssignedClientIdentifier +// "\178\189\219\145a\142\159\136\136\246\171\164\v\CANn",PropContentType "\200\142\228\241\129oX\228l"]} +TEST(Connect5QCTest, Encode26) { + uint8_t pkt[] = { + 0x10, 0xe0, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x7f, 0x4f, 0x8e, 0x2, 0x12, 0x0, 0x1d, 0x92, + 0x92, 0xca, 0xd0, 0x6e, 0xd0, 0x58, 0xa0, 0x3, 0x63, 0x8, 0x75, 0x27, 0xf3, 0x68, 0x92, 0x98, 0x46, 0x1a, 0x77, + 0x91, 0xcd, 0x2f, 0xbc, 0x52, 0x54, 0x94, 0x53, 0x5d, 0x28, 0xc9, 0x17, 0x19, 0x19, 0x75, 0x13, 0x6a, 0xbe, 0x27, + 0x0, 0x0, 0x34, 0x3d, 0x1f, 0x0, 0x11, 0x17, 0x0, 0x7d, 0xfa, 0x83, 0xa1, 0x8, 0x58, 0x3e, 0x1d, 0x3f, 0xd4, + 0x96, 0x35, 0x3f, 0x2c, 0xe2, 0xb, 0x9, 0x9, 0x0, 0x3, 0xb5, 0x78, 0x7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0x43, 0xa2, 0x9e, 0x6, 0x19, 0xfc, 0xae, 0x52, 0x3, 0x0, 0x4, 0xf5, 0xb6, 0x2e, 0x74, 0x1f, 0x0, 0x12, 0x40, + 0xcc, 0x3a, 0x4e, 0xc, 0x81, 0xf3, 0xaa, 0x80, 0x9d, 0xc0, 0xd4, 0x82, 0xf8, 0x7a, 0x1f, 0xb2, 0x5, 0x18, 0x0, + 0x0, 0x11, 0xea, 0x23, 0x10, 0x74, 0x0, 0x5, 0x34, 0x67, 0xa7, 0x28, 0xf7, 0x0, 0x6, 0x65, 0x16, 0x79, 0xbb, + 0x7b, 0xd6, 0x0, 0x18, 0x93, 0x5, 0x49, 0xad, 0x1c, 0x8b, 0x79, 0xab, 0x55, 0xa7, 0x32, 0xc8, 0xf1, 0xe7, 0x5f, + 0x53, 0xcf, 0x41, 0xc1, 0x2e, 0x27, 0x13, 0x2d, 0x9, 0x0, 0x6, 0xe0, 0x4d, 0xe5, 0xc4, 0x9b, 0xc}; + + uint8_t buf[749] = {0}; + + uint8_t bytesprops0[] = {0x92, 0x92, 0xca, 0xd0, 0x6e, 0xd0, 0x58, 0xa0, 0x3, 0x63, 0x8, 0x75, 0x27, 0xf3, 0x68, + 0x92, 0x98, 0x46, 0x1a, 0x77, 0x91, 0xcd, 0x2f, 0xbc, 0x52, 0x54, 0x94, 0x53, 0x5d}; + uint8_t bytesprops1[] = {0x17, 0x0, 0x7d, 0xfa, 0x83, 0xa1, 0x8, 0x58, 0x3e, + 0x1d, 0x3f, 0xd4, 0x96, 0x35, 0x3f, 0x2c, 0xe2}; + uint8_t bytesprops2[] = {0xb5, 0x78, 0x7b}; + uint8_t bytesprops4[] = {0xde, 0xd0, 0x6, 0x77, 0x45, 0xf1, 0x72, 0xc, 0x94, 0xa2, 0x82, 0xf, 0xba, 0xf9, + 0xe0, 0x21, 0xc6, 0x60, 0xd7, 0x3b, 0xb7, 0xa0, 0x17, 0x2a, 0x6f, 0xc8, 0x82, 0x9c}; + uint8_t bytesprops3[] = {0x6, 0x50, 0xdc, 0x63, 0x2a, 0xfd, 0x60, 0x49, 0x7, 0x50, 0xae, + 0xad, 0x16, 0x47, 0xca, 0x1a, 0x8e, 0x35, 0x7e, 0x5c, 0x19, 0x91}; + uint8_t bytesprops5[] = {0x2, 0xcc, 0xcf, 0x8e, 0x5d, 0xe2, 0xa3, 0xfe, 0x18, 0xa9, 0x8b, 0xde, 0xdb, 0x22, + 0xa7, 0x29, 0x26, 0x6b, 0x34, 0x32, 0xcf, 0xc9, 0x92, 0x39, 0x25, 0x7, 0xae}; + uint8_t bytesprops6[] = {0x50}; + uint8_t bytesprops7[] = {0x46, 0x1d, 0x9, 0x76, 0x6b, 0x46, 0x2c, 0xdd, 0xf7, 0x27, 0x4d, 0x3c, 0xe, + 0x2e, 0x50, 0x25, 0x2d, 0x81, 0x25, 0x85, 0x66, 0x3f, 0x15, 0x99, 0xd4, 0xd5}; + uint8_t bytesprops8[] = {0x65, 0x19, 0x5, 0x93, 0x6a}; + uint8_t bytesprops9[] = {0xab, 0x24, 0x1d, 0x97, 0x31, 0xa9, 0x26, 0xb0, 0xff, 0xc9, 0x7e, 0x63, 0x82}; + uint8_t bytesprops10[] = {0xb2, 0xbd, 0xdb, 0x91, 0x61, 0x8e, 0x9f, 0x88, 0x88, 0xf6, 0xab, 0xa4, 0xb, 0x18, 0x6e}; + uint8_t bytesprops11[] = {0xc8, 0x8e, 0xe4, 0xf1, 0x81, 0x6f, 0x58, 0xe4, 0x6c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27326}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13373}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10603}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16761}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31394}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17345}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops11}}}, + }; + + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xe8, 0xae, 0x98, 0xd5, 0x66, 0x90, 0xf0, 0x72}; + uint8_t byteswillprops1[] = {0xbe, 0x59, 0x1b, 0x55, 0xfe, 0xfd, 0xf8, 0x3e, 0x56, 0x80, 0xb, 0x3d, 0xa6, 0xa6, 0xc0, + 0xbc, 0x12, 0xc8, 0xe3, 0xc0, 0xbb, 0xe7, 0x9d, 0x1e, 0xfc, 0x52, 0x76, 0xc4, 0x9b}; + uint8_t byteswillprops2[] = {0x60, 0xb9, 0xff, 0x9e, 0x97, 0xcd, 0xdd, 0x8d, 0x3d, + 0x2d, 0xec, 0x50, 0x8c, 0x82, 0x87, 0x49, 0x75}; + uint8_t byteswillprops3[] = {0xd7, 0xcb, 0xd, 0xb0, 0xd7, 0x85, 0x11, 0xbd, 0x83, 0x24, 0xee, 0x65, 0x31, 0x4f, + 0x2f, 0xcb, 0xdf, 0xcf, 0x95, 0x48, 0x3f, 0x52, 0x84, 0x59, 0x5a, 0xc3, 0x51}; + uint8_t byteswillprops4[] = {0x49, 0x4a, 0x18, 0xa6, 0x1d, 0x2b, 0x89, 0x19, 0x38}; + uint8_t byteswillprops5[] = {0x1c, 0x5, 0xdd, 0x61, 0x6e, 0x88, 0x82, 0xa9, 0x19, 0xf5, 0x7e, 0xe4, 0x4f, 0x79, + 0xc3, 0x1, 0x3b, 0x39, 0xa0, 0x5b, 0xaa, 0x36, 0x2a, 0x63, 0xa6, 0xbc, 0xce, 0xe4}; + uint8_t byteswillprops6[] = {0xf2, 0x37, 0x2f, 0x9f, 0x53, 0xd7, 0x7d, 0x79, 0x87, 0x24, 0x2b, 0x88, 0x17, 0xdd, + 0x79, 0x36, 0xc0, 0x67, 0x7c, 0x1a, 0x6e, 0x8d, 0x23, 0x4d, 0x48, 0xbb, 0xa6, 0xf4}; + uint8_t byteswillprops7[] = {0xfe, 0x9a, 0xb5, 0xd8, 0x6d, 0xaf, 0xc1, 0x69, + 0x63, 0xff, 0xd2, 0x54, 0x8b, 0xac, 0x85}; + uint8_t byteswillprops8[] = {0x61, 0x77, 0x2c, 0xd1, 0xb3, 0xa, 0x30, 0xf3, 0x5a, 0x99, 0x14, + 0xb5, 0x42, 0xbe, 0xe, 0xeb, 0xd1, 0xb2, 0x24, 0xf6, 0x5c}; + uint8_t byteswillprops9[] = {0x9a, 0x3c, 0x4, 0xc7, 0x2b, 0xfc, 0x93, 0xbd, 0x45, 0x56, 0x5d, 0x68, 0x1e, 0xb}; + uint8_t byteswillprops10[] = {0xd0, 0xe8, 0x97, 0x55, 0xc3, 0xb2, 0xae, 0x58, 0x90, 0xd5, 0x5d, 0xa8, 0x4, 0xb0}; + uint8_t byteswillprops11[] = {0x1d, 0x98, 0xfd, 0x2, 0xdd, 0x1c, 0x74, 0xc3, 0x86, + 0xc5, 0xfe, 0xcc, 0x29, 0x45, 0x2b, 0x80, 0x2c}; + uint8_t byteswillprops12[] = {0xce, 0x25, 0xa4, 0x10, 0x60, 0xc4, 0x56, 0x6e, 0x3, 0x88, 0x45, 0x12, 0x73, + 0x9c, 0xe4, 0x5d, 0x5d, 0xcd, 0x42, 0xdf, 0xf8, 0x7, 0x3c, 0x3c, 0xe4, 0x3}; + uint8_t byteswillprops13[] = {0xea, 0x6c, 0x12, 0x9b, 0x43, 0xa2, 0x9e, 0x6, 0x19, 0xfc, 0xae, 0x52}; + uint8_t byteswillprops14[] = {0xf5, 0xb6, 0x2e, 0x74}; + uint8_t byteswillprops15[] = {0x40, 0xcc, 0x3a, 0x4e, 0xc, 0x81, 0xf3, 0xaa, 0x80, + 0x9d, 0xc0, 0xd4, 0x82, 0xf8, 0x7a, 0x1f, 0xb2, 0x5}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12137}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4886}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28988}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31344}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1883}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14426}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&byteswillprops12}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&byteswillprops13}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&byteswillprops14}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&byteswillprops15}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4586}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4212}}, + }; + + lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x34, 0x67, 0xa7, 0x28, 0xf7}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x65, 0x16, 0x79, 0xbb, 0x7b, 0xd6}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32591; + uint8_t client_id_bytes[] = {0x35, 0xe2, 0x47, 0x91, 0x9f, 0xee, 0xe1, 0x15, 0x12, 0x1a, 0x1e, 0x63, + 0x5, 0x6, 0x72, 0xee, 0x2b, 0x80, 0xbf, 0xda, 0x12, 0xe6, 0x8f, 0x58}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x93, 0x5, 0x49, 0xad, 0x1c, 0x8b, 0x79, 0xab, 0x55, 0xa7, 0x32, 0xc8, + 0xf1, 0xe7, 0x5f, 0x53, 0xcf, 0x41, 0xc1, 0x2e, 0x27, 0x13, 0x2d, 0x9}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xe0, 0x4d, 0xe5, 0xc4, 0x9b, 0xc}; + lwmqtt_string_t password = {6, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\135n\ACK\DEL\252\NAKj", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "\227\242\SOH2\209\GS\241P\197$1", _willMsg = +// "\203\232{\205\152\239\158\DEL\251r\EOTy\\e\148\159p\ETX8Kg", _willProps = [PropResponseTopic +// "\212\ETB\EOT\132M\"^\\(\254\171\ACK\188\&5\174\NAK?I\181\221\221B\246\226\233\210?\232",PropMaximumQoS +// 142,PropCorrelationData "<'\194\DC45\216\200p\216)\175G\NUL",PropServerReference +// "f\150\160\131/\ETX\216_\157\202\142\t\136\&8;\178\143\177,3+\148",PropWildcardSubscriptionAvailable +// 231,PropWildcardSubscriptionAvailable 103,PropWildcardSubscriptionAvailable 67,PropRequestResponseInformation +// 151,PropSharedSubscriptionAvailable 197,PropWildcardSubscriptionAvailable 192,PropRetainAvailable +// 167,PropSubscriptionIdentifier 8,PropServerReference "\182\213\155\213\v\r\DC2\181",PropAuthenticationData +// "\199xmb\245",PropWildcardSubscriptionAvailable 177,PropResponseInformation +// "k5\245)\203y+\223*\202\252,\251u\240\176\195Y",PropSharedSubscriptionAvailable 66,PropRetainAvailable +// 186,PropAuthenticationMethod "\152>\128\158\235\150\182N8F\223\200\SYN\154.\161",PropTopicAlias +// 25938,PropMessageExpiryInterval 9743,PropResponseTopic +// "\150\145\&9\168\134\228\&9\SO\210\200O\230r\SYN\209\RS\SO\214"]}), _cleanSession = True, _keepAlive = 27175, _connID +// = "\CAN\SYN\222\163\&6J<\227\240.\181\138\158\223b_\ETB\234\SYN\232\223", _properties = [PropMessageExpiryInterval +// 2882,PropCorrelationData "7\176\229\218\&9\SYN\227#]#\200a\DC1\205}\223\ETBs<\205r$[",PropTopicAliasMaximum +// 19033,PropSharedSubscriptionAvailable 238,PropServerReference "\199y\243\b",PropSharedSubscriptionAvailable +// 200,PropMessageExpiryInterval 25291,PropUserProperty "" +// "\228\197\r\232\193\nW4kl\SOH\t\\\DC4",PropSubscriptionIdentifierAvailable 101,PropUserProperty +// "!\n0`*\161b\147\188u" +// "#\146\139\&4sy\207Q\255En\n'<\248\&6\232\253-\196\ETXKz\137\ETX\164^\230",PropMessageExpiryInterval +// 11776,PropSubscriptionIdentifierAvailable 107,PropPayloadFormatIndicator 174]} +TEST(Connect5QCTest, Encode27) { + uint8_t pkt[] = { + 0x10, 0x84, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x86, 0x6a, 0x27, 0x7b, 0x2, 0x0, 0x0, 0xb, 0x42, + 0x9, 0x0, 0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}; + + uint8_t bytesprops0[] = {0x37, 0xb0, 0xe5, 0xda, 0x39, 0x16, 0xe3, 0x23, 0x5d, 0x23, 0xc8, 0x61, + 0x11, 0xcd, 0x7d, 0xdf, 0x17, 0x73, 0x3c, 0xcd, 0x72, 0x24, 0x5b}; + uint8_t bytesprops1[] = {0xc7, 0x79, 0xf3, 0x8}; + uint8_t bytesprops3[] = {0xe4, 0xc5, 0xd, 0xe8, 0xc1, 0xa, 0x57, 0x34, 0x6b, 0x6c, 0x1, 0x9, 0x5c, 0x14}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops5[] = {0x23, 0x92, 0x8b, 0x34, 0x73, 0x79, 0xcf, 0x51, 0xff, 0x45, 0x6e, 0xa, 0x27, 0x3c, + 0xf8, 0x36, 0xe8, 0xfd, 0x2d, 0xc4, 0x3, 0x4b, 0x7a, 0x89, 0x3, 0xa4, 0x5e, 0xe6}; + uint8_t bytesprops4[] = {0x21, 0xa, 0x30, 0x60, 0x2a, 0xa1, 0x62, 0x93, 0xbc, 0x75}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2882}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19033}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25291}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops2}, .v = {14, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops4}, .v = {28, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11776}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 174}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xd4, 0x17, 0x4, 0x84, 0x4d, 0x22, 0x5e, 0x5c, 0x28, 0xfe, 0xab, 0x6, 0xbc, 0x35, + 0xae, 0x15, 0x3f, 0x49, 0xb5, 0xdd, 0xdd, 0x42, 0xf6, 0xe2, 0xe9, 0xd2, 0x3f, 0xe8}; + uint8_t byteswillprops1[] = {0x3c, 0x27, 0xc2, 0x14, 0x35, 0xd8, 0xc8, 0x70, 0xd8, 0x29, 0xaf, 0x47, 0x0}; + uint8_t byteswillprops2[] = {0x66, 0x96, 0xa0, 0x83, 0x2f, 0x3, 0xd8, 0x5f, 0x9d, 0xca, 0x8e, + 0x9, 0x88, 0x38, 0x3b, 0xb2, 0x8f, 0xb1, 0x2c, 0x33, 0x2b, 0x94}; + uint8_t byteswillprops3[] = {0xb6, 0xd5, 0x9b, 0xd5, 0xb, 0xd, 0x12, 0xb5}; + uint8_t byteswillprops4[] = {0xc7, 0x78, 0x6d, 0x62, 0xf5}; + uint8_t byteswillprops5[] = {0x6b, 0x35, 0xf5, 0x29, 0xcb, 0x79, 0x2b, 0xdf, 0x2a, + 0xca, 0xfc, 0x2c, 0xfb, 0x75, 0xf0, 0xb0, 0xc3, 0x59}; + uint8_t byteswillprops6[] = {0x98, 0x3e, 0x80, 0x9e, 0xeb, 0x96, 0xb6, 0x4e, + 0x38, 0x46, 0xdf, 0xc8, 0x16, 0x9a, 0x2e, 0xa1}; + uint8_t byteswillprops7[] = {0x96, 0x91, 0x39, 0xa8, 0x86, 0xe4, 0x39, 0xe, 0xd2, + 0xc8, 0x4f, 0xe6, 0x72, 0x16, 0xd1, 0x1e, 0xe, 0xd6}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25938}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9743}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops7}}}, + }; + + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe3, 0xf2, 0x1, 0x32, 0xd1, 0x1d, 0xf1, 0x50, 0xc5, 0x24, 0x31}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xcb, 0xe8, 0x7b, 0xcd, 0x98, 0xef, 0x9e, 0x7f, 0xfb, 0x72, 0x4, + 0x79, 0x5c, 0x65, 0x94, 0x9f, 0x70, 0x3, 0x38, 0x4b, 0x67}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 27175; + uint8_t client_id_bytes[] = {0x18, 0x16, 0xde, 0xa3, 0x36, 0x4a, 0x3c, 0xe3, 0xf0, 0x2e, 0xb5, + 0x8a, 0x9e, 0xdf, 0x62, 0x5f, 0x17, 0xea, 0x16, 0xe8, 0xdf}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x87, 0x6e, 0x6, 0x7f, 0xfc, 0x15, 0x6a}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\206\232\167N\216a\154\199\224\218QM\240^\233", _password = Just +// "\192/:\231\250i\229m\149\209\226\189\247\RS", _lastWill = Nothing, _cleanSession = True, _keepAlive = 19539, _connID +// = "\243\a_w\224\230\220\172\186\STX\157\251\SUB\221\132\ACK1\230\148", _properties = [PropContentType +// "QH\133\ETX\204\nCa\145\182\179",PropPayloadFormatIndicator 127,PropAuthenticationData +// "u\230\227\235K\130\148\217M\150\172p\251\145\DC2\v\ETB\DC2O\181g?\198\253",PropResponseInformation +// "l\219\199)\200Q\215\128\219\GS\161o)\254\US\RS\212\186aR$S\ENQ_C\SOHvQEv",PropAssignedClientIdentifier +// "\186.\\\159\184\222\213\237\199\179\208e\221rn\224H\191\143\CAN\134\194\183*",PropRequestResponseInformation +// 219,PropPayloadFormatIndicator 221,PropReceiveMaximum 19233,PropResponseTopic "H\196\238",PropRetainAvailable +// 172,PropMaximumQoS 154,PropMessageExpiryInterval 9718]} +TEST(Connect5QCTest, Encode28) { + uint8_t pkt[] = {0x10, 0xbe, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x4c, 0x53, 0x7d, 0x3, 0x0, 0xb, + 0x51, 0x48, 0x85, 0x3, 0xcc, 0xa, 0x43, 0x61, 0x91, 0xb6, 0xb3, 0x1, 0x7f, 0x16, 0x0, 0x18, 0x75, + 0xe6, 0xe3, 0xeb, 0x4b, 0x82, 0x94, 0xd9, 0x4d, 0x96, 0xac, 0x70, 0xfb, 0x91, 0x12, 0xb, 0x17, 0x12, + 0x4f, 0xb5, 0x67, 0x3f, 0xc6, 0xfd, 0x1a, 0x0, 0x1e, 0x6c, 0xdb, 0xc7, 0x29, 0xc8, 0x51, 0xd7, 0x80, + 0xdb, 0x1d, 0xa1, 0x6f, 0x29, 0xfe, 0x1f, 0x1e, 0xd4, 0xba, 0x61, 0x52, 0x24, 0x53, 0x5, 0x5f, 0x43, + 0x1, 0x76, 0x51, 0x45, 0x76, 0x12, 0x0, 0x18, 0xba, 0x2e, 0x5c, 0x9f, 0xb8, 0xde, 0xd5, 0xed, 0xc7, + 0xb3, 0xd0, 0x65, 0xdd, 0x72, 0x6e, 0xe0, 0x48, 0xbf, 0x8f, 0x18, 0x86, 0xc2, 0xb7, 0x2a, 0x19, 0xdb, + 0x1, 0xdd, 0x21, 0x4b, 0x21, 0x8, 0x0, 0x3, 0x48, 0xc4, 0xee, 0x25, 0xac, 0x24, 0x9a, 0x2, 0x0, + 0x0, 0x25, 0xf6, 0x0, 0x13, 0xf3, 0x7, 0x5f, 0x77, 0xe0, 0xe6, 0xdc, 0xac, 0xba, 0x2, 0x9d, 0xfb, + 0x1a, 0xdd, 0x84, 0x6, 0x31, 0xe6, 0x94, 0x0, 0xf, 0xce, 0xe8, 0xa7, 0x4e, 0xd8, 0x61, 0x9a, 0xc7, + 0xe0, 0xda, 0x51, 0x4d, 0xf0, 0x5e, 0xe9, 0x0, 0xe, 0xc0, 0x2f, 0x3a, 0xe7, 0xfa, 0x69, 0xe5, 0x6d, + 0x95, 0xd1, 0xe2, 0xbd, 0xf7, 0x1e}; + + uint8_t buf[203] = {0}; + + uint8_t bytesprops0[] = {0x51, 0x48, 0x85, 0x3, 0xcc, 0xa, 0x43, 0x61, 0x91, 0xb6, 0xb3}; + uint8_t bytesprops1[] = {0x75, 0xe6, 0xe3, 0xeb, 0x4b, 0x82, 0x94, 0xd9, 0x4d, 0x96, 0xac, 0x70, + 0xfb, 0x91, 0x12, 0xb, 0x17, 0x12, 0x4f, 0xb5, 0x67, 0x3f, 0xc6, 0xfd}; + uint8_t bytesprops2[] = {0x6c, 0xdb, 0xc7, 0x29, 0xc8, 0x51, 0xd7, 0x80, 0xdb, 0x1d, 0xa1, 0x6f, 0x29, 0xfe, 0x1f, + 0x1e, 0xd4, 0xba, 0x61, 0x52, 0x24, 0x53, 0x5, 0x5f, 0x43, 0x1, 0x76, 0x51, 0x45, 0x76}; + uint8_t bytesprops3[] = {0xba, 0x2e, 0x5c, 0x9f, 0xb8, 0xde, 0xd5, 0xed, 0xc7, 0xb3, 0xd0, 0x65, + 0xdd, 0x72, 0x6e, 0xe0, 0x48, 0xbf, 0x8f, 0x18, 0x86, 0xc2, 0xb7, 0x2a}; + uint8_t bytesprops4[] = {0x48, 0xc4, 0xee}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19233}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9718}}, + }; + + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 19539; + uint8_t client_id_bytes[] = {0xf3, 0x7, 0x5f, 0x77, 0xe0, 0xe6, 0xdc, 0xac, 0xba, 0x2, + 0x9d, 0xfb, 0x1a, 0xdd, 0x84, 0x6, 0x31, 0xe6, 0x94}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xce, 0xe8, 0xa7, 0x4e, 0xd8, 0x61, 0x9a, 0xc7, 0xe0, 0xda, 0x51, 0x4d, 0xf0, 0x5e, 0xe9}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xc0, 0x2f, 0x3a, 0xe7, 0xfa, 0x69, 0xe5, 0x6d, 0x95, 0xd1, 0xe2, 0xbd, 0xf7, 0x1e}; + lwmqtt_string_t password = {14, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "m\215\134\182\200\&4", _password = Just +// ">\213T\DC4\232\214\180e\168@Q\130\234\201\227#\248\153`\161\244\138\218\201/xr\DEL", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "k\208\247&\US\224\153\252\216", _willMsg = "\v\157\214H\186", +// _willProps = [PropPayloadFormatIndicator 187,PropTopicAliasMaximum 32718,PropServerReference +// "\vh\247\147\223\169\132\211K\249\160E\141W\140\167\GS\166\220\201",PropServerKeepAlive +// 17111,PropAssignedClientIdentifier "f\176G\ENQ#'\177\239G\164\176\247\236\240\202",PropSessionExpiryInterval +// 14845,PropReceiveMaximum 32716,PropWillDelayInterval 5765,PropPayloadFormatIndicator 200,PropResponseInformation +// "pf\STX6",PropSharedSubscriptionAvailable 198,PropTopicAlias 20010,PropWillDelayInterval 26929,PropCorrelationData +// "6k;\183\248\ENQ\148\245\199w=",PropRetainAvailable 174,PropAuthenticationMethod +// "\206\NAK\182\182}\216\249\159\140:\238\202\139\248",PropAuthenticationMethod "\205\135\ETX",PropTopicAliasMaximum +// 14663,PropWildcardSubscriptionAvailable 87,PropCorrelationData +// "\248U\149\192\173\230\SO\143\215KL*j\154\239t\140\249j\150",PropRequestResponseInformation 164,PropReceiveMaximum +// 22648,PropMessageExpiryInterval 22675,PropWillDelayInterval 29136]}), _cleanSession = False, _keepAlive = 24596, +// _connID = "\198\140\ETX", _properties = [PropSessionExpiryInterval 14824,PropMessageExpiryInterval +// 21140,PropTopicAlias 28394,PropCorrelationData +// "\135\237\f\236\165d\248\137\DEL\218c\230\168\192\235u|'\237}|\"\187\DEL\DEL",PropRetainAvailable +// 236,PropMessageExpiryInterval 3189,PropSubscriptionIdentifierAvailable 13,PropWillDelayInterval +// 17060,PropReceiveMaximum 25160,PropCorrelationData "\233",PropRequestResponseInformation 160,PropMaximumQoS +// 131,PropMaximumPacketSize 16528,PropSharedSubscriptionAvailable 89,PropAssignedClientIdentifier +// "\ACK*4\n\241\234^&n\232\213ED\ACK\229\252\232\&6",PropMessageExpiryInterval 11067,PropWildcardSubscriptionAvailable +// 39,PropResponseInformation "0\148\NAK\212h\200\132\219\&9",PropServerReference +// "|\DC2\n\DC2\159\144%\221\248\137\160\230^\SI\a\154\147u",PropServerReference +// "\238\137\251\a\229{\202\153\210\ENQ\194\240\GS<\223\183\208\241\179{\NAKS\236\140\234f",PropAuthenticationData +// "\130\200\243",PropRetainAvailable 200,PropSubscriptionIdentifier 13,PropMessageExpiryInterval +// 6275,PropRequestProblemInformation 236,PropMessageExpiryInterval 10831,PropCorrelationData +// "y\214",PropWillDelayInterval 13007,PropWildcardSubscriptionAvailable 14]} +TEST(Connect5QCTest, Encode29) { + uint8_t pkt[] = { + 0x10, 0xb3, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x60, 0x14, 0xc5, 0x1, 0x11, 0x0, 0x0, 0x39, + 0xe8, 0x2, 0x0, 0x0, 0x52, 0x94, 0x23, 0x6e, 0xea, 0x9, 0x0, 0x19, 0x87, 0xed, 0xc, 0xec, 0xa5, 0x64, 0xf8, + 0x89, 0x7f, 0xda, 0x63, 0xe6, 0xa8, 0xc0, 0xeb, 0x75, 0x7c, 0x27, 0xed, 0x7d, 0x7c, 0x22, 0xbb, 0x7f, 0x7f, 0x25, + 0xec, 0x2, 0x0, 0x0, 0xc, 0x75, 0x29, 0xd, 0x18, 0x0, 0x0, 0x42, 0xa4, 0x21, 0x62, 0x48, 0x9, 0x0, 0x1, + 0xe9, 0x19, 0xa0, 0x24, 0x83, 0x27, 0x0, 0x0, 0x40, 0x90, 0x2a, 0x59, 0x12, 0x0, 0x12, 0x6, 0x2a, 0x34, 0xa, + 0xf1, 0xea, 0x5e, 0x26, 0x6e, 0xe8, 0xd5, 0x45, 0x44, 0x6, 0xe5, 0xfc, 0xe8, 0x36, 0x2, 0x0, 0x0, 0x2b, 0x3b, + 0x28, 0x27, 0x1a, 0x0, 0x9, 0x30, 0x94, 0x15, 0xd4, 0x68, 0xc8, 0x84, 0xdb, 0x39, 0x1c, 0x0, 0x12, 0x7c, 0x12, + 0xa, 0x12, 0x9f, 0x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0xd8, 0xf9, 0x9f, 0x8c, 0x3a, 0xee, 0xca, 0x8b, 0xf8, 0x15, 0x0, 0x3, 0xcd, 0x87, 0x3, 0x22, 0x39, 0x47, + 0x28, 0x57, 0x9, 0x0, 0x14, 0xf8, 0x55, 0x95, 0xc0, 0xad, 0xe6, 0xe, 0x8f, 0xd7, 0x4b, 0x4c, 0x2a, 0x6a, 0x9a, + 0xef, 0x74, 0x8c, 0xf9, 0x6a, 0x96, 0x19, 0xa4, 0x21, 0x58, 0x78, 0x2, 0x0, 0x0, 0x58, 0x93, 0x18, 0x0, 0x0, + 0x71, 0xd0, 0x0, 0x9, 0x6b, 0xd0, 0xf7, 0x26, 0x1f, 0xe0, 0x99, 0xfc, 0xd8, 0x0, 0x5, 0xb, 0x9d, 0xd6, 0x48, + 0xba, 0x0, 0x6, 0x6d, 0xd7, 0x86, 0xb6, 0xc8, 0x34, 0x0, 0x1c, 0x3e, 0xd5, 0x54, 0x14, 0xe8, 0xd6, 0xb4, 0x65, + 0xa8, 0x40, 0x51, 0x82, 0xea, 0xc9, 0xe3, 0x23, 0xf8, 0x99, 0x60, 0xa1, 0xf4, 0x8a, 0xda, 0xc9, 0x2f, 0x78, 0x72, + 0x7f}; + + uint8_t buf[448] = {0}; + + uint8_t bytesprops0[] = {0x87, 0xed, 0xc, 0xec, 0xa5, 0x64, 0xf8, 0x89, 0x7f, 0xda, 0x63, 0xe6, 0xa8, + 0xc0, 0xeb, 0x75, 0x7c, 0x27, 0xed, 0x7d, 0x7c, 0x22, 0xbb, 0x7f, 0x7f}; + uint8_t bytesprops1[] = {0xe9}; + uint8_t bytesprops2[] = {0x6, 0x2a, 0x34, 0xa, 0xf1, 0xea, 0x5e, 0x26, 0x6e, + 0xe8, 0xd5, 0x45, 0x44, 0x6, 0xe5, 0xfc, 0xe8, 0x36}; + uint8_t bytesprops3[] = {0x30, 0x94, 0x15, 0xd4, 0x68, 0xc8, 0x84, 0xdb, 0x39}; + uint8_t bytesprops4[] = {0x7c, 0x12, 0xa, 0x12, 0x9f, 0x90, 0x25, 0xdd, 0xf8, + 0x89, 0xa0, 0xe6, 0x5e, 0xf, 0x7, 0x9a, 0x93, 0x75}; + uint8_t bytesprops5[] = {0xee, 0x89, 0xfb, 0x7, 0xe5, 0x7b, 0xca, 0x99, 0xd2, 0x5, 0xc2, 0xf0, 0x1d, + 0x3c, 0xdf, 0xb7, 0xd0, 0xf1, 0xb3, 0x7b, 0x15, 0x53, 0xec, 0x8c, 0xea, 0x66}; + uint8_t bytesprops6[] = {0x82, 0xc8, 0xf3}; + uint8_t bytesprops7[] = {0x79, 0xd6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14824}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21140}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28394}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3189}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17060}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25160}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16528}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11067}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6275}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10831}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13007}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 14}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xb, 0x68, 0xf7, 0x93, 0xdf, 0xa9, 0x84, 0xd3, 0x4b, 0xf9, + 0xa0, 0x45, 0x8d, 0x57, 0x8c, 0xa7, 0x1d, 0xa6, 0xdc, 0xc9}; + uint8_t byteswillprops1[] = {0x66, 0xb0, 0x47, 0x5, 0x23, 0x27, 0xb1, 0xef, 0x47, 0xa4, 0xb0, 0xf7, 0xec, 0xf0, 0xca}; + uint8_t byteswillprops2[] = {0x70, 0x66, 0x2, 0x36}; + uint8_t byteswillprops3[] = {0x36, 0x6b, 0x3b, 0xb7, 0xf8, 0x5, 0x94, 0xf5, 0xc7, 0x77, 0x3d}; + uint8_t byteswillprops4[] = {0xce, 0x15, 0xb6, 0xb6, 0x7d, 0xd8, 0xf9, 0x9f, 0x8c, 0x3a, 0xee, 0xca, 0x8b, 0xf8}; + uint8_t byteswillprops5[] = {0xcd, 0x87, 0x3}; + uint8_t byteswillprops6[] = {0xf8, 0x55, 0x95, 0xc0, 0xad, 0xe6, 0xe, 0x8f, 0xd7, 0x4b, + 0x4c, 0x2a, 0x6a, 0x9a, 0xef, 0x74, 0x8c, 0xf9, 0x6a, 0x96}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32718}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17111}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14845}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32716}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5765}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20010}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26929}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14663}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22648}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22675}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29136}}, + }; + + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x6b, 0xd0, 0xf7, 0x26, 0x1f, 0xe0, 0x99, 0xfc, 0xd8}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb, 0x9d, 0xd6, 0x48, 0xba}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 24596; + uint8_t client_id_bytes[] = {0xc6, 0x8c, 0x3}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x6d, 0xd7, 0x86, 0xb6, 0xc8, 0x34}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x3e, 0xd5, 0x54, 0x14, 0xe8, 0xd6, 0xb4, 0x65, 0xa8, 0x40, 0x51, 0x82, 0xea, 0xc9, + 0xe3, 0x23, 0xf8, 0x99, 0x60, 0xa1, 0xf4, 0x8a, 0xda, 0xc9, 0x2f, 0x78, 0x72, 0x7f}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "e\ESCs", _password = Just "\183mF\183H", _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 16377, _connID = "Ky\SOj\t\188i\157\233_I\201\187\143\DELY\175_\140}\230\&5\206\SUBqb+P0", _properties = +// [PropMessageExpiryInterval 12557,PropResponseInformation +// "\\\146\EM\EOT\170]y\131\188\DLE\201~\128\v\207\199\166\131\253\224*\133\EOT[A\214\197\"",PropAuthenticationMethod +// "\189\140T\249\247u\STX\138\151\197G",PropMaximumQoS 2,PropContentType +// "\STX\197\139@O\230\165\DEL\tcVj)eh\241-\STX\245\171\DLE\SOH\198\237\ETBc\239\DC3\ACK",PropAssignedClientIdentifier +// "Q\136\161\f\132x\203C\234\232\248\208x\246S\180\136I6\200\216b\239q",PropSubscriptionIdentifier +// 0,PropMaximumPacketSize 28632,PropSharedSubscriptionAvailable 164,PropTopicAliasMaximum +// 26012,PropSessionExpiryInterval 1199,PropTopicAliasMaximum 10320,PropUserProperty +// "\SOV\245\128\205z>\131\146v[\239\t4)O\141\198\226\r\t\SYN\189g&\171\202\166O" "\150l-h",PropUserProperty "\ETXO" +// "\ETB\148\188",PropPayloadFormatIndicator 169,PropAssignedClientIdentifier +// "\156\132aO\182\147iE\198y\rY\SI0",PropTopicAliasMaximum 28032,PropUserProperty +// "\187_VoL\CANwj\137(l\129\236<\209z\220FGI\237c\171\187\150'\215h" +// "2\128f\220\132\v\215\245cO\US\207\136",PropTopicAliasMaximum 29924,PropReceiveMaximum 32359,PropCorrelationData +// "\138\143\159:",PropAuthenticationData "\168\156\219\195\143\129",PropAssignedClientIdentifier "\142",PropTopicAlias +// 8611]} +TEST(Connect5QCTest, Encode30) { + uint8_t pkt[] = { + 0x10, 0xcb, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x3f, 0xf9, 0x94, 0x2, 0x2, 0x0, 0x0, 0x31, + 0xd, 0x1a, 0x0, 0x1c, 0x5c, 0x92, 0x19, 0x4, 0xaa, 0x5d, 0x79, 0x83, 0xbc, 0x10, 0xc9, 0x7e, 0x80, 0xb, 0xcf, + 0xc7, 0xa6, 0x83, 0xfd, 0xe0, 0x2a, 0x85, 0x4, 0x5b, 0x41, 0xd6, 0xc5, 0x22, 0x15, 0x0, 0xb, 0xbd, 0x8c, 0x54, + 0xf9, 0xf7, 0x75, 0x2, 0x8a, 0x97, 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 0x84, 0xb, 0xd7, 0xf5, 0x63, 0x4f, 0x1f, 0xcf, 0x88, 0x22, 0x74, 0xe4, 0x21, + 0x7e, 0x67, 0x9, 0x0, 0x4, 0x8a, 0x8f, 0x9f, 0x3a, 0x16, 0x0, 0x6, 0xa8, 0x9c, 0xdb, 0xc3, 0x8f, 0x81, 0x12, + 0x0, 0x1, 0x8e, 0x23, 0x21, 0xa3, 0x0, 0x1d, 0x4b, 0x79, 0xe, 0x6a, 0x9, 0xbc, 0x69, 0x9d, 0xe9, 0x5f, 0x49, + 0xc9, 0xbb, 0x8f, 0x7f, 0x59, 0xaf, 0x5f, 0x8c, 0x7d, 0xe6, 0x35, 0xce, 0x1a, 0x71, 0x62, 0x2b, 0x50, 0x30, 0x0, + 0x3, 0x65, 0x1b, 0x73, 0x0, 0x5, 0xb7, 0x6d, 0x46, 0xb7, 0x48}; + + uint8_t buf[344] = {0}; + + uint8_t bytesprops0[] = {0x5c, 0x92, 0x19, 0x4, 0xaa, 0x5d, 0x79, 0x83, 0xbc, 0x10, 0xc9, 0x7e, 0x80, 0xb, + 0xcf, 0xc7, 0xa6, 0x83, 0xfd, 0xe0, 0x2a, 0x85, 0x4, 0x5b, 0x41, 0xd6, 0xc5, 0x22}; + uint8_t bytesprops1[] = {0xbd, 0x8c, 0x54, 0xf9, 0xf7, 0x75, 0x2, 0x8a, 0x97, 0xc5, 0x47}; + uint8_t bytesprops2[] = {0x2, 0xc5, 0x8b, 0x40, 0x4f, 0xe6, 0xa5, 0x7f, 0x9, 0x63, 0x56, 0x6a, 0x29, 0x65, 0x68, + 0xf1, 0x2d, 0x2, 0xf5, 0xab, 0x10, 0x1, 0xc6, 0xed, 0x17, 0x63, 0xef, 0x13, 0x6}; + uint8_t bytesprops3[] = {0x51, 0x88, 0xa1, 0xc, 0x84, 0x78, 0xcb, 0x43, 0xea, 0xe8, 0xf8, 0xd0, + 0x78, 0xf6, 0x53, 0xb4, 0x88, 0x49, 0x36, 0xc8, 0xd8, 0x62, 0xef, 0x71}; + uint8_t bytesprops5[] = {0x96, 0x6c, 0x2d, 0x68}; + uint8_t bytesprops4[] = {0xe, 0x56, 0xf5, 0x80, 0xcd, 0x7a, 0x3e, 0x83, 0x92, 0x76, 0x5b, 0xef, 0x9, 0x34, 0x29, + 0x4f, 0x8d, 0xc6, 0xe2, 0xd, 0x9, 0x16, 0xbd, 0x67, 0x26, 0xab, 0xca, 0xa6, 0x4f}; + uint8_t bytesprops7[] = {0x17, 0x94, 0xbc}; + uint8_t bytesprops6[] = {0x3, 0x4f}; + uint8_t bytesprops8[] = {0x9c, 0x84, 0x61, 0x4f, 0xb6, 0x93, 0x69, 0x45, 0xc6, 0x79, 0xd, 0x59, 0xf, 0x30}; + uint8_t bytesprops10[] = {0x32, 0x80, 0x66, 0xdc, 0x84, 0xb, 0xd7, 0xf5, 0x63, 0x4f, 0x1f, 0xcf, 0x88}; + uint8_t bytesprops9[] = {0xbb, 0x5f, 0x56, 0x6f, 0x4c, 0x18, 0x77, 0x6a, 0x89, 0x28, 0x6c, 0x81, 0xec, 0x3c, + 0xd1, 0x7a, 0xdc, 0x46, 0x47, 0x49, 0xed, 0x63, 0xab, 0xbb, 0x96, 0x27, 0xd7, 0x68}; + uint8_t bytesprops11[] = {0x8a, 0x8f, 0x9f, 0x3a}; + uint8_t bytesprops12[] = {0xa8, 0x9c, 0xdb, 0xc3, 0x8f, 0x81}; + uint8_t bytesprops13[] = {0x8e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12557}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28632}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26012}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1199}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10320}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {4, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops6}, .v = {3, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28032}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops9}, .v = {13, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29924}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32359}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8611}}, + }; + + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 16377; + uint8_t client_id_bytes[] = {0x4b, 0x79, 0xe, 0x6a, 0x9, 0xbc, 0x69, 0x9d, 0xe9, 0x5f, 0x49, 0xc9, 0xbb, 0x8f, 0x7f, + 0x59, 0xaf, 0x5f, 0x8c, 0x7d, 0xe6, 0x35, 0xce, 0x1a, 0x71, 0x62, 0x2b, 0x50, 0x30}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x65, 0x1b, 0x73}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xb7, 0x6d, 0x46, 0xb7, 0x48}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\238zO", _password = Just +// "\183xW\149\225\255\ACK\160\227\147\208\185\174P\148l\216\&6B\183J\152", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS2, _willTopic = "\192G3\202\231\255\195\177\168\239\233\234\161\DC3\186Q\230\"\t\146\ACK", +// _willMsg = "\GS\230a\199\205<}", _willProps = [PropResponseTopic +// "o%\204\217\EOT\DC2\197\131\CAN\r\241\134\247\215Ag0\135",PropAssignedClientIdentifier "\162w\t[",PropCorrelationData +// "\144",PropReceiveMaximum 976,PropRequestProblemInformation 134,PropContentType "\204\245",PropTopicAlias +// 32453,PropMaximumPacketSize 30765,PropWillDelayInterval 25398,PropPayloadFormatIndicator +// 110,PropRequestProblemInformation 6,PropReasonString "\223\236s\137\161",PropRequestResponseInformation +// 221,PropSharedSubscriptionAvailable 75,PropMaximumQoS 153,PropSharedSubscriptionAvailable 16,PropTopicAlias +// 14248,PropServerKeepAlive 32227,PropRequestProblemInformation 248]}), _cleanSession = True, _keepAlive = 18523, +// _connID = "\232\204\f\212 \185\241-\229\183\230\160\202i\225\DC1_2\224\152\198v[\219md\170", _properties = +// [PropServerKeepAlive 12674,PropServerKeepAlive 10216,PropReasonString +// "\136\181\GS\135\130^\"\216\136\&5",PropTopicAlias 20600,PropSubscriptionIdentifier 3,PropResponseTopic +// "\b\163W\\\226\ACKd\131\213\163",PropServerKeepAlive 21705,PropResponseTopic +// "\252\185R\160\"2\DLE$\f|\FS\178\205\197\188\254D7\185z\189%M",PropTopicAlias 22536,PropPayloadFormatIndicator +// 71,PropTopicAliasMaximum 12012,PropSessionExpiryInterval 14012,PropUserProperty +// "\175\254Q\166P<\228\a\141-|@\181\241\&2e\142\231\212\173\255\&7\131\194\195\154/7" +// "`\252\221Z'-\130\238\ETX\216&B\246\&8F9\ACK\ENQ\201\DC4\154S@)\198\183\132",PropRequestProblemInformation +// 71,PropWildcardSubscriptionAvailable 107,PropMessageExpiryInterval 7104,PropServerReference +// "\224\FS\STX",PropReceiveMaximum 12644,PropRetainAvailable 27,PropWildcardSubscriptionAvailable +// 226,PropSharedSubscriptionAvailable 163,PropSubscriptionIdentifier 13,PropPayloadFormatIndicator 171,PropTopicAlias +// 25711,PropTopicAliasMaximum 16376,PropUserProperty "r\NAK\206(7\198\CAN\DC4[!O\141\176\EMu\SO\199Mz$\151\156;" +// "sc\255-y"]} +TEST(Connect5QCTest, Encode31) { + uint8_t pkt[] = { + 0x10, 0x88, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x48, 0x5b, 0xce, 0x1, 0x13, 0x31, 0x82, 0x13, + 0x27, 0xe8, 0x1f, 0x0, 0xa, 0x88, 0xb5, 0x1d, 0x87, 0x82, 0x5e, 0x22, 0xd8, 0x88, 0x35, 0x23, 0x50, 0x78, 0xb, + 0x3, 0x8, 0x0, 0xa, 0x8, 0xa3, 0x57, 0x5c, 0xe2, 0x6, 0x64, 0x83, 0xd5, 0xa3, 0x13, 0x54, 0xc9, 0x8, 0x0, + 0x17, 0xfc, 0xb9, 0x52, 0xa0, 0x22, 0x32, 0x10, 0x24, 0xc, 0x7c, 0x1c, 0xb2, 0xcd, 0xc5, 0xbc, 0xfe, 0x44, 0x37, + 0xb9, 0x7a, 0xbd, 0x25, 0x4d, 0x23, 0x58,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67, 0x30, 0x87, 0x12, 0x0, 0x4, 0xa2, 0x77, 0x9, 0x5b, 0x9, 0x0, 0x1, 0x90, 0x21, 0x3, + 0xd0, 0x17, 0x86, 0x3, 0x0, 0x2, 0xcc, 0xf5, 0x23, 0x7e, 0xc5, 0x27, 0x0, 0x0, 0x78, 0x2d, 0x18, 0x0, 0x0, + 0x63, 0x36, 0x1, 0x6e, 0x17, 0x6, 0x1f, 0x0, 0x5, 0xdf, 0xec, 0x73, 0x89, 0xa1, 0x19, 0xdd, 0x2a, 0x4b, 0x24, + 0x99, 0x2a, 0x10, 0x23, 0x37, 0xa8, 0x13, 0x7d, 0xe3, 0x17, 0xf8, 0x0, 0x15, 0xc0, 0x47, 0x33, 0xca, 0xe7, 0xff, + 0xc3, 0xb1, 0xa8, 0xef, 0xe9, 0xea, 0xa1, 0x13, 0xba, 0x51, 0xe6, 0x22, 0x9, 0x92, 0x6, 0x0, 0x7, 0x1d, 0xe6, + 0x61, 0xc7, 0xcd, 0x3c, 0x7d, 0x0, 0x3, 0xee, 0x7a, 0x4f, 0x0, 0x16, 0xb7, 0x78, 0x57, 0x95, 0xe1, 0xff, 0x6, + 0xa0, 0xe3, 0x93, 0xd0, 0xb9, 0xae, 0x50, 0x94, 0x6c, 0xd8, 0x36, 0x42, 0xb7, 0x4a, 0x98}; + + uint8_t buf[405] = {0}; + + uint8_t bytesprops0[] = {0x88, 0xb5, 0x1d, 0x87, 0x82, 0x5e, 0x22, 0xd8, 0x88, 0x35}; + uint8_t bytesprops1[] = {0x8, 0xa3, 0x57, 0x5c, 0xe2, 0x6, 0x64, 0x83, 0xd5, 0xa3}; + uint8_t bytesprops2[] = {0xfc, 0xb9, 0x52, 0xa0, 0x22, 0x32, 0x10, 0x24, 0xc, 0x7c, 0x1c, 0xb2, + 0xcd, 0xc5, 0xbc, 0xfe, 0x44, 0x37, 0xb9, 0x7a, 0xbd, 0x25, 0x4d}; + uint8_t bytesprops4[] = {0x60, 0xfc, 0xdd, 0x5a, 0x27, 0x2d, 0x82, 0xee, 0x3, 0xd8, 0x26, 0x42, 0xf6, 0x38, + 0x46, 0x39, 0x6, 0x5, 0xc9, 0x14, 0x9a, 0x53, 0x40, 0x29, 0xc6, 0xb7, 0x84}; + uint8_t bytesprops3[] = {0xaf, 0xfe, 0x51, 0xa6, 0x50, 0x3c, 0xe4, 0x7, 0x8d, 0x2d, 0x7c, 0x40, 0xb5, 0xf1, + 0x32, 0x65, 0x8e, 0xe7, 0xd4, 0xad, 0xff, 0x37, 0x83, 0xc2, 0xc3, 0x9a, 0x2f, 0x37}; + uint8_t bytesprops5[] = {0xe0, 0x1c, 0x2}; + uint8_t bytesprops7[] = {0x73, 0x63, 0xff, 0x2d, 0x79}; + uint8_t bytesprops6[] = {0x72, 0x15, 0xce, 0x28, 0x37, 0xc6, 0x18, 0x14, 0x5b, 0x21, 0x4f, 0x8d, + 0xb0, 0x19, 0x75, 0xe, 0xc7, 0x4d, 0x7a, 0x24, 0x97, 0x9c, 0x3b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12674}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10216}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20600}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21705}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22536}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12012}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14012}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops3}, .v = {27, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7104}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12644}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25711}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16376}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops6}, .v = {5, (char*)&bytesprops7}}}}, + }; + + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x6f, 0x25, 0xcc, 0xd9, 0x4, 0x12, 0xc5, 0x83, 0x18, + 0xd, 0xf1, 0x86, 0xf7, 0xd7, 0x41, 0x67, 0x30, 0x87}; + uint8_t byteswillprops1[] = {0xa2, 0x77, 0x9, 0x5b}; + uint8_t byteswillprops2[] = {0x90}; + uint8_t byteswillprops3[] = {0xcc, 0xf5}; + uint8_t byteswillprops4[] = {0xdf, 0xec, 0x73, 0x89, 0xa1}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 976}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32453}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30765}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25398}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14248}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32227}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 248}}, + }; + + lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc0, 0x47, 0x33, 0xca, 0xe7, 0xff, 0xc3, 0xb1, 0xa8, 0xef, 0xe9, + 0xea, 0xa1, 0x13, 0xba, 0x51, 0xe6, 0x22, 0x9, 0x92, 0x6}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1d, 0xe6, 0x61, 0xc7, 0xcd, 0x3c, 0x7d}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 18523; + uint8_t client_id_bytes[] = {0xe8, 0xcc, 0xc, 0xd4, 0x20, 0xb9, 0xf1, 0x2d, 0xe5, 0xb7, 0xe6, 0xa0, 0xca, 0x69, + 0xe1, 0x11, 0x5f, 0x32, 0xe0, 0x98, 0xc6, 0x76, 0x5b, 0xdb, 0x6d, 0x64, 0xaa}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xee, 0x7a, 0x4f}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xb7, 0x78, 0x57, 0x95, 0xe1, 0xff, 0x6, 0xa0, 0xe3, 0x93, 0xd0, + 0xb9, 0xae, 0x50, 0x94, 0x6c, 0xd8, 0x36, 0x42, 0xb7, 0x4a, 0x98}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Ae\200\161\175\235\ETX\154", _password = Just +// "\ESCm\NULa\222\180jD\243e\212[\t7\DC1\143\247~\DC4=\196NJ\FS<\201\150\171\151", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\FS;\251\141\v\199\239\NUL\196T{\DC3x?\154\217\156_", _willMsg = +// "_'9\US\219\b\147\&0\133+-\148\&7G\249\172\205[\147\208\DC3\ESCC", _willProps = [PropMaximumPacketSize +// 17904,PropMessageExpiryInterval 1141,PropReasonString +// ";\"B\177\185\\n\DC3uxPC\v{\185?S\223j\146\190\vWg\158cE\"\151A",PropMessageExpiryInterval +// 29326,PropMaximumPacketSize 25000,PropWildcardSubscriptionAvailable 77,PropSubscriptionIdentifierAvailable +// 224,PropServerKeepAlive 7466,PropCorrelationData +// "\228\209\212?\135S`&\NAK\204\ENQ\200\215\161~V\220\224O\243-\213\131R9_\198\207\174",PropResponseInformation +// "c\197f\227_\NUL\246\228",PropCorrelationData "\140\153@\RS\176\212\128\237K(\ACK\218\223\&1\168\185p\DC1\171\146\198:\171\218",PropRequestProblemInformation +// 168,PropMaximumQoS 86,PropSharedSubscriptionAvailable 69,PropSharedSubscriptionAvailable 78,PropContentType +// "\196/?\150\169&\134\128 H\176r\DLE!\152\&8\168\174\252\133\218\DC2\203\181s.",PropReceiveMaximum +// 11980,PropSubscriptionIdentifier 7,PropWillDelayInterval 21313,PropContentType +// "\226\136\254\152\227\198;",PropWillDelayInterval 21790]}), _cleanSession = False, _keepAlive = 11629, _connID = +// "\\X\222", _properties = [PropSubscriptionIdentifier 13,PropUserProperty "\251\234vxH\143\177\&2\183M\180w\180\NULV" +// "\NAK\132\212&",PropSessionExpiryInterval 6175,PropAuthenticationData "\226\205",PropCorrelationData +// "",PropRequestProblemInformation 154,PropServerReference +// "\v\163\&7\160\145\221V\228\227\186\215*9\220\244\\\195\142\199M\229\207\246\&0",PropReasonString "\203"]} +TEST(Connect5QCTest, Encode32) { + uint8_t pkt[] = { + 0x10, 0xdb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x2d, 0x6d, 0x48, 0xb, 0xd, 0x26, 0x0, 0xf, + 0xfb, 0xea, 0x76, 0x78, 0x48, 0x8f, 0xb1, 0x32, 0xb7, 0x4d, 0xb4, 0x77, 0xb4, 0x0, 0x56, 0x0, 0x4, 0x15, 0x84, + 0xd4, 0x26, 0x11, 0x0, 0x0, 0x18, 0x1f, 0x16, 0x0, 0x2, 0xe2, 0xcd, 0x9, 0x0, 0x0, 0x17, 0x9a, 0x1c, 0x0, + 0x18, 0xb, 0xa3, 0x37, 0xa0, 0x91, 0xdd, 0x56, 0xe4, 0xe3, 0xba, 0xd7, 0x2a, 0x39, 0xdc, 0xf4, 0x5c, 0xc3, 0x8e, + 0xc7, 0x4d, 0xe5, 0xcf, 0xf6, 0x30, 0x1f, 0x0, 0x1, 0xcb, 0x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5b, 0x9, 0x37, 0x11, 0x8f, 0xf7, 0x7e, 0x14, 0x3d, 0xc4, 0x4e, 0x4a, 0x1c, 0x3c, 0xc9, + 0x96, 0xab, 0x97}; + + uint8_t buf[488] = {0}; + + uint8_t bytesprops1[] = {0x15, 0x84, 0xd4, 0x26}; + uint8_t bytesprops0[] = {0xfb, 0xea, 0x76, 0x78, 0x48, 0x8f, 0xb1, 0x32, 0xb7, 0x4d, 0xb4, 0x77, 0xb4, 0x0, 0x56}; + uint8_t bytesprops2[] = {0xe2, 0xcd}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0xb, 0xa3, 0x37, 0xa0, 0x91, 0xdd, 0x56, 0xe4, 0xe3, 0xba, 0xd7, 0x2a, + 0x39, 0xdc, 0xf4, 0x5c, 0xc3, 0x8e, 0xc7, 0x4d, 0xe5, 0xcf, 0xf6, 0x30}; + uint8_t bytesprops5[] = {0xcb}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {4, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6175}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops5}}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x3b, 0x22, 0x42, 0xb1, 0xb9, 0x5c, 0x6e, 0x13, 0x75, 0x78, + 0x50, 0x43, 0xb, 0x7b, 0xb9, 0x3f, 0x53, 0xdf, 0x6a, 0x92, + 0xbe, 0xb, 0x57, 0x67, 0x9e, 0x63, 0x45, 0x22, 0x97, 0x41}; + uint8_t byteswillprops1[] = {0xe4, 0xd1, 0xd4, 0x3f, 0x87, 0x53, 0x60, 0x26, 0x15, 0xcc, 0x5, 0xc8, 0xd7, 0xa1, 0x7e, + 0x56, 0xdc, 0xe0, 0x4f, 0xf3, 0x2d, 0xd5, 0x83, 0x52, 0x39, 0x5f, 0xc6, 0xcf, 0xae}; + uint8_t byteswillprops2[] = {0x63, 0xc5, 0x66, 0xe3, 0x5f, 0x0, 0xf6, 0xe4}; + uint8_t byteswillprops3[] = {0x8c, 0x99, 0x40, 0x1e, 0x3c, 0x51, 0xce, 0x49, 0x7e, 0xb4, 0x92, 0xe7, 0xfc, 0x97}; + uint8_t byteswillprops4[] = {0x7b, 0x74, 0xad, 0x14, 0xcc, 0x5, 0xc3, 0x94, 0x67, 0x4, 0xbc, 0x1b, 0x42, 0xfe}; + uint8_t byteswillprops5[] = {0xe5, 0x2e, 0xbc, 0x65, 0x57, 0x2e, 0xce, 0x8}; + uint8_t byteswillprops6[] = {0x50, 0x88, 0xaf, 0x34, 0x5b, 0x29, 0x36, 0x81, + 0x61, 0x3c, 0xa1, 0xe1, 0xdd, 0xe3, 0x99, 0x5f}; + uint8_t byteswillprops8[] = {0x6e, 0x64, 0x6f, 0xc, 0xbd, 0x44, 0x36, 0x7c, 0x3e, 0xb0, 0xd4, 0x80, 0xed, 0x4b, 0x28, + 0x6, 0xda, 0xdf, 0x31, 0xa8, 0xb9, 0x70, 0x11, 0xab, 0x92, 0xc6, 0x3a, 0xab, 0xda}; + uint8_t byteswillprops7[] = {0x8e, 0x5a, 0x2d, 0x8a, 0x24, 0xb8, 0x3d, 0x5b, 0x2d, 0x39, + 0x7, 0xc6, 0xef, 0xda, 0xd0, 0x42, 0xba, 0x12, 0x32}; + uint8_t byteswillprops9[] = {0xc4, 0x2f, 0x3f, 0x96, 0xa9, 0x26, 0x86, 0x80, 0x20, 0x48, 0xb0, 0x72, 0x10, + 0x21, 0x98, 0x38, 0xa8, 0xae, 0xfc, 0x85, 0xda, 0x12, 0xcb, 0xb5, 0x73, 0x2e}; + uint8_t byteswillprops10[] = {0xe2, 0x88, 0xfe, 0x98, 0xe3, 0xc6, 0x3b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17904}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1141}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29326}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25000}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7466}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4866}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27714}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19961}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {19, (char*)&byteswillprops7}, .v = {29, (char*)&byteswillprops8}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11980}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21313}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21790}}, + }; + + lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1c, 0x3b, 0xfb, 0x8d, 0xb, 0xc7, 0xef, 0x0, 0xc4, + 0x54, 0x7b, 0x13, 0x78, 0x3f, 0x9a, 0xd9, 0x9c, 0x5f}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5f, 0x27, 0x39, 0x1f, 0xdb, 0x8, 0x93, 0x30, 0x85, 0x2b, 0x2d, 0x94, + 0x37, 0x47, 0xf9, 0xac, 0xcd, 0x5b, 0x93, 0xd0, 0x13, 0x1b, 0x43}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 11629; + uint8_t client_id_bytes[] = {0x5c, 0x58, 0xde}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x41, 0x65, 0xc8, 0xa1, 0xaf, 0xeb, 0x3, 0x9a}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x1b, 0x6d, 0x0, 0x61, 0xde, 0xb4, 0x6a, 0x44, 0xf3, 0x65, 0xd4, 0x5b, 0x9, 0x37, 0x11, + 0x8f, 0xf7, 0x7e, 0x14, 0x3d, 0xc4, 0x4e, 0x4a, 0x1c, 0x3c, 0xc9, 0x96, 0xab, 0x97}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\150\147\177\160\218r%'C\139\159\&6\178", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\158/9\141", _willMsg = +// "\189\DC4a\NUL\243\231@W\178\194\&7\212\\\150W\244\244\226Y=\164\138\228\154qi\129(\SOH}", _willProps = +// [PropSharedSubscriptionAvailable 219,PropTopicAlias 23920,PropResponseTopic +// "2\181Q\254\DC1\192\172N\186",PropWildcardSubscriptionAvailable 247,PropRetainAvailable 33,PropUserProperty +// "\ESC6\160\DEL\193\145\ENQ\r\208\&7\201\253t" "\189O\235\NAK'm\186\SO\\i",PropSharedSubscriptionAvailable +// 244,PropAssignedClientIdentifier +// "\195\&5\163\191#\236;\252\SYN;\178\165~\194\203\229z\GS\250\DELW\v\230\155\DC1'm",PropRequestResponseInformation +// 26,PropPayloadFormatIndicator 192,PropWillDelayInterval 16423,PropAssignedClientIdentifier +// "Q\195\v\253",PropReasonString "\ENQ\161\133\237_\215\184\184&CW",PropCorrelationData +// "~\167\239\141\208\215g",PropServerKeepAlive 10841,PropAssignedClientIdentifier +// "~\186\176\176h\NAKv",PropWildcardSubscriptionAvailable 29,PropMessageExpiryInterval +// 26220,PropRequestResponseInformation 54,PropWillDelayInterval 16152,PropSubscriptionIdentifier +// 14,PropWildcardSubscriptionAvailable 90,PropReasonString "\211\172\247",PropContentType "\246",PropAuthenticationData +// "\DC3U\193ldY\254\253)\192`\216>\199\"\219\207\217",PropAuthenticationData +// "\131\v\174\206\161\CAN\ETB\n\132\&4s@\a",PropResponseTopic ""]}), _cleanSession = True, _keepAlive = 6008, _connID = +// "3\252\rE\195\SYNO^\160\182\243\US\166\254\183 \NAK\SUB\159\173\196\\\150\179D\245", _properties = +// [PropMaximumPacketSize 5391,PropAssignedClientIdentifier +// "kU[\143\214o\252\200\233\166bT\SI\218\247\147\152\226\n",PropAssignedClientIdentifier +// "\207\157[\245RG8\193",PropPayloadFormatIndicator 2,PropMaximumPacketSize 32093,PropSessionExpiryInterval +// 16956,PropPayloadFormatIndicator 157,PropReceiveMaximum 28710,PropReceiveMaximum 15106,PropResponseTopic +// "",PropAssignedClientIdentifier "\CAN\140%\214",PropTopicAlias 2832,PropMessageExpiryInterval 27101,PropTopicAlias +// 4406,PropSubscriptionIdentifierAvailable 181,PropRequestProblemInformation 154,PropAuthenticationData +// "i~\230\224bT\129\209\137\182",PropSessionExpiryInterval 21237,PropTopicAlias 25576]} +TEST(Connect5QCTest, Encode33) { + uint8_t pkt[] = { + 0x10, 0x81, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe, 0x17, 0x78, 0x68, 0x27, 0x0, 0x0, 0x15, 0xf, + 0x12, 0x0, 0x13, 0x6b, 0x55, 0x5b, 0x8f, 0xd6, 0x6f, 0xfc, 0xc8, 0xe9, 0xa6, 0x62, 0x54, 0xf, 0xda, 0xf7, 0x93, + 0x98, 0xe2, 0xa, 0x12, 0x0, 0x8, 0xcf, 0x9d, 0x5b, 0xf5, 0x52, 0x47, 0x38, 0xc1, 0x1, 0x2, 0x27, 0x0, 0x0, + 0x7d, 0x5d, 0x11, 0x0, 0x0, 0x42, 0x3c, 0x1, 0x9d, 0x21, 0x70, 0x26, 0x21, 0x3b, 0x2, 0x8, 0x0, 0x0, 0x12, + 0x0, 0x4, 0x18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 0x8d, + 0xd0, 0xd7, 0x67, 0x13, 0x2a, 0x59, 0x12, 0x0, 0x7, 0x7e, 0xba, 0xb0, 0xb0, 0x68, 0x15, 0x76, 0x28, 0x1d, 0x2, + 0x0, 0x0, 0x66, 0x6c, 0x19, 0x36, 0x18, 0x0, 0x0, 0x3f, 0x18, 0xb, 0xe, 0x28, 0x5a, 0x1f, 0x0, 0x3, 0xd3, + 0xac, 0xf7, 0x3, 0x0, 0x1, 0xf6, 0x16, 0x0, 0x12, 0x13, 0x55, 0xc1, 0x6c, 0x64, 0x59, 0xfe, 0xfd, 0x29, 0xc0, + 0x60, 0xd8, 0x3e, 0xc7, 0x22, 0xdb, 0xcf, 0xd9, 0x16, 0x0, 0xd, 0x83, 0xb, 0xae, 0xce, 0xa1, 0x18, 0x17, 0xa, + 0x84, 0x34, 0x73, 0x40, 0x7, 0x8, 0x0, 0x0, 0x0, 0x4, 0x9e, 0x2f, 0x39, 0x8d, 0x0, 0x1e, 0xbd, 0x14, 0x61, + 0x0, 0xf3, 0xe7, 0x40, 0x57, 0xb2, 0xc2, 0x37, 0xd4, 0x5c, 0x96, 0x57, 0xf4, 0xf4, 0xe2, 0x59, 0x3d, 0xa4, 0x8a, + 0xe4, 0x9a, 0x71, 0x69, 0x81, 0x28, 0x1, 0x7d}; + + uint8_t buf[398] = {0}; + + uint8_t bytesprops0[] = {0x6b, 0x55, 0x5b, 0x8f, 0xd6, 0x6f, 0xfc, 0xc8, 0xe9, 0xa6, + 0x62, 0x54, 0xf, 0xda, 0xf7, 0x93, 0x98, 0xe2, 0xa}; + uint8_t bytesprops1[] = {0xcf, 0x9d, 0x5b, 0xf5, 0x52, 0x47, 0x38, 0xc1}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x18, 0x8c, 0x25, 0xd6}; + uint8_t bytesprops4[] = {0x69, 0x7e, 0xe6, 0xe0, 0x62, 0x54, 0x81, 0xd1, 0x89, 0xb6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5391}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32093}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16956}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28710}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15106}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2832}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27101}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4406}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21237}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25576}}, + }; + + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x32, 0xb5, 0x51, 0xfe, 0x11, 0xc0, 0xac, 0x4e, 0xba}; + uint8_t byteswillprops2[] = {0xbd, 0x4f, 0xeb, 0x15, 0x27, 0x6d, 0xba, 0xe, 0x5c, 0x69}; + uint8_t byteswillprops1[] = {0x1b, 0x36, 0xa0, 0x7f, 0xc1, 0x91, 0x5, 0xd, 0xd0, 0x37, 0xc9, 0xfd, 0x74}; + uint8_t byteswillprops3[] = {0xc3, 0x35, 0xa3, 0xbf, 0x23, 0xec, 0x3b, 0xfc, 0x16, 0x3b, 0xb2, 0xa5, 0x7e, 0xc2, + 0xcb, 0xe5, 0x7a, 0x1d, 0xfa, 0x7f, 0x57, 0xb, 0xe6, 0x9b, 0x11, 0x27, 0x6d}; + uint8_t byteswillprops4[] = {0x51, 0xc3, 0xb, 0xfd}; + uint8_t byteswillprops5[] = {0x5, 0xa1, 0x85, 0xed, 0x5f, 0xd7, 0xb8, 0xb8, 0x26, 0x43, 0x57}; + uint8_t byteswillprops6[] = {0x7e, 0xa7, 0xef, 0x8d, 0xd0, 0xd7, 0x67}; + uint8_t byteswillprops7[] = {0x7e, 0xba, 0xb0, 0xb0, 0x68, 0x15, 0x76}; + uint8_t byteswillprops8[] = {0xd3, 0xac, 0xf7}; + uint8_t byteswillprops9[] = {0xf6}; + uint8_t byteswillprops10[] = {0x13, 0x55, 0xc1, 0x6c, 0x64, 0x59, 0xfe, 0xfd, 0x29, + 0xc0, 0x60, 0xd8, 0x3e, 0xc7, 0x22, 0xdb, 0xcf, 0xd9}; + uint8_t byteswillprops11[] = {0x83, 0xb, 0xae, 0xce, 0xa1, 0x18, 0x17, 0xa, 0x84, 0x34, 0x73, 0x40, 0x7}; + uint8_t byteswillprops12[] = {0}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23920}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {13, (char*)&byteswillprops1}, .v = {10, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16423}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10841}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26220}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16152}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&byteswillprops12}}}, + }; + + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9e, 0x2f, 0x39, 0x8d}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xbd, 0x14, 0x61, 0x0, 0xf3, 0xe7, 0x40, 0x57, 0xb2, 0xc2, + 0x37, 0xd4, 0x5c, 0x96, 0x57, 0xf4, 0xf4, 0xe2, 0x59, 0x3d, + 0xa4, 0x8a, 0xe4, 0x9a, 0x71, 0x69, 0x81, 0x28, 0x1, 0x7d}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 6008; + uint8_t client_id_bytes[] = {0x33, 0xfc, 0xd, 0x45, 0xc3, 0x16, 0x4f, 0x5e, 0xa0, 0xb6, 0xf3, 0x1f, 0xa6, + 0xfe, 0xb7, 0x20, 0x15, 0x1a, 0x9f, 0xad, 0xc4, 0x5c, 0x96, 0xb3, 0x44, 0xf5}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x96, 0x93, 0xb1, 0xa0, 0xda, 0x72, 0x25, 0x27, 0x43, 0x8b, 0x9f, 0x36, 0xb2}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Y\v>5Bm\227", _password = Just "\138\203", _lastWill = Just (LastWill {_willRetain +// = False, _willQoS = QoS2, _willTopic = "\206v\171\156\146%.\249$W", _willMsg = "\bH\DC4H", _willProps = +// [PropRetainAvailable 199,PropMessageExpiryInterval 29826,PropRequestResponseInformation +// 144,PropRequestProblemInformation 175,PropSubscriptionIdentifier 23,PropSharedSubscriptionAvailable +// 242,PropCorrelationData +// "_\181\173j\250\161\156\248\135\161D\ETB\199\142\228\159\251\148/\SOH\202\225",PropCorrelationData +// "\r*\r\212yag\218[_\151k\225\191\136\186\216\232\230\182\223\160\GS",PropServerKeepAlive 11815]}), _cleanSession = +// True, _keepAlive = 23415, _connID = "\204wCr\148\250tb\RS\139\204\142\r\206\180\231\DC26Cv\254+\STX\ETX\250\t", +// _properties = [PropCorrelationData +// "S\SUB,\146\197/J\FS\145.\a\147L\155\167\230+U&\151S\DLE\254\167t\167Ve\200\180",PropRetainAvailable +// 197,PropPayloadFormatIndicator 175,PropTopicAliasMaximum 2854,PropReasonString +// "\179\NAK\154\a;Na%\128\234Q\141x\248<\178\254r\232o\147/\252r\179\229\230",PropMessageExpiryInterval +// 12863,PropTopicAlias 5178,PropRetainAvailable 17,PropMessageExpiryInterval 31630,PropUserProperty +// "V\136v\182\196(4\146\145P" "W\206\210\196\185Z)o\240\130C\248X\219R\202\153\b\221",PropMessageExpiryInterval +// 11401,PropUserProperty "\ETBf" "}\v}\248\167\EM\217\154\139K\231h\253\173fa\209\240",PropAuthenticationData +// "\EMSz\229\231W\246f\US\238\228%\192}\210\173\185t\205",PropMessageExpiryInterval +// 3915,PropSubscriptionIdentifierAvailable 223,PropWillDelayInterval 7999,PropMessageExpiryInterval +// 21248,PropRetainAvailable 63,PropTopicAliasMaximum 30995,PropServerKeepAlive 5186,PropReasonString " +// .\246$\145\200?|\236m\175D",PropTopicAliasMaximum 31289,PropRetainAvailable 46]} +TEST(Connect5QCTest, Encode34) { + uint8_t pkt[] = { + 0x10, 0xe5, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x5b, 0x77, 0xd8, 0x1, 0x9, 0x0, 0x1e, 0x53, + 0x1a, 0x2c, 0x92, 0xc5, 0x2f, 0x4a, 0x1c, 0x91, 0x2e, 0x7, 0x93, 0x4c, 0x9b, 0xa7, 0xe6, 0x2b, 0x55, 0x26, 0x97, + 0x53, 0x10, 0xfe, 0xa7, 0x74, 0xa7, 0x56, 0x65, 0xc8, 0xb4, 0x25, 0xc5, 0x1, 0xaf, 0x22, 0xb, 0x26, 0x1f, 0x0, + 0x1b, 0xb3, 0x15, 0x9a, 0x7, 0x3b, 0x4e, 0x61, 0x25, 0x80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x2b, 0x2, 0x3, 0xfa, 0x9, 0x45, 0x25, 0xc7, 0x2, 0x0, 0x0, 0x74, + 0x82, 0x19, 0x90, 0x17, 0xaf, 0xb, 0x17, 0x2a, 0xf2, 0x9, 0x0, 0x16, 0x5f, 0xb5, 0xad, 0x6a, 0xfa, 0xa1, 0x9c, + 0xf8, 0x87, 0xa1, 0x44, 0x17, 0xc7, 0x8e, 0xe4, 0x9f, 0xfb, 0x94, 0x2f, 0x1, 0xca, 0xe1, 0x9, 0x0, 0x17, 0xd, + 0x2a, 0xd, 0xd4, 0x79, 0x61, 0x67, 0xda, 0x5b, 0x5f, 0x97, 0x6b, 0xe1, 0xbf, 0x88, 0xba, 0xd8, 0xe8, 0xe6, 0xb6, + 0xdf, 0xa0, 0x1d, 0x13, 0x2e, 0x27, 0x0, 0xa, 0xce, 0x76, 0xab, 0x9c, 0x92, 0x25, 0x2e, 0xf9, 0x24, 0x57, 0x0, + 0x4, 0x8, 0x48, 0x14, 0x48, 0x0, 0x7, 0x59, 0xb, 0x3e, 0x35, 0x42, 0x6d, 0xe3, 0x0, 0x2, 0x8a, 0xcb}; + + uint8_t buf[370] = {0}; + + uint8_t bytesprops0[] = {0x53, 0x1a, 0x2c, 0x92, 0xc5, 0x2f, 0x4a, 0x1c, 0x91, 0x2e, 0x7, 0x93, 0x4c, 0x9b, 0xa7, + 0xe6, 0x2b, 0x55, 0x26, 0x97, 0x53, 0x10, 0xfe, 0xa7, 0x74, 0xa7, 0x56, 0x65, 0xc8, 0xb4}; + uint8_t bytesprops1[] = {0xb3, 0x15, 0x9a, 0x7, 0x3b, 0x4e, 0x61, 0x25, 0x80, 0xea, 0x51, 0x8d, 0x78, 0xf8, + 0x3c, 0xb2, 0xfe, 0x72, 0xe8, 0x6f, 0x93, 0x2f, 0xfc, 0x72, 0xb3, 0xe5, 0xe6}; + uint8_t bytesprops3[] = {0x57, 0xce, 0xd2, 0xc4, 0xb9, 0x5a, 0x29, 0x6f, 0xf0, 0x82, + 0x43, 0xf8, 0x58, 0xdb, 0x52, 0xca, 0x99, 0x8, 0xdd}; + uint8_t bytesprops2[] = {0x56, 0x88, 0x76, 0xb6, 0xc4, 0x28, 0x34, 0x92, 0x91, 0x50}; + uint8_t bytesprops5[] = {0x7d, 0xb, 0x7d, 0xf8, 0xa7, 0x19, 0xd9, 0x9a, 0x8b, + 0x4b, 0xe7, 0x68, 0xfd, 0xad, 0x66, 0x61, 0xd1, 0xf0}; + uint8_t bytesprops4[] = {0x17, 0x66}; + uint8_t bytesprops6[] = {0x19, 0x53, 0x7a, 0xe5, 0xe7, 0x57, 0xf6, 0x66, 0x1f, 0xee, + 0xe4, 0x25, 0xc0, 0x7d, 0xd2, 0xad, 0xb9, 0x74, 0xcd}; + uint8_t bytesprops7[] = {0x20, 0x2e, 0xf6, 0x24, 0x91, 0xc8, 0x3f, 0x7c, 0xec, 0x6d, 0xaf, 0x44}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2854}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12863}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5178}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31630}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {19, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11401}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops4}, .v = {18, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3915}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7999}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21248}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30995}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5186}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31289}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 46}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x5f, 0xb5, 0xad, 0x6a, 0xfa, 0xa1, 0x9c, 0xf8, 0x87, 0xa1, 0x44, + 0x17, 0xc7, 0x8e, 0xe4, 0x9f, 0xfb, 0x94, 0x2f, 0x1, 0xca, 0xe1}; + uint8_t byteswillprops1[] = {0xd, 0x2a, 0xd, 0xd4, 0x79, 0x61, 0x67, 0xda, 0x5b, 0x5f, 0x97, 0x6b, + 0xe1, 0xbf, 0x88, 0xba, 0xd8, 0xe8, 0xe6, 0xb6, 0xdf, 0xa0, 0x1d}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29826}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11815}}, + }; + + lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xce, 0x76, 0xab, 0x9c, 0x92, 0x25, 0x2e, 0xf9, 0x24, 0x57}; + lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x8, 0x48, 0x14, 0x48}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23415; + uint8_t client_id_bytes[] = {0xcc, 0x77, 0x43, 0x72, 0x94, 0xfa, 0x74, 0x62, 0x1e, 0x8b, 0xcc, 0x8e, 0xd, + 0xce, 0xb4, 0xe7, 0x12, 0x36, 0x43, 0x76, 0xfe, 0x2b, 0x2, 0x3, 0xfa, 0x9}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x59, 0xb, 0x3e, 0x35, 0x42, 0x6d, 0xe3}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x8a, 0xcb}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "]\153\135\145US\141\240H\229\241g\ETX", _willMsg = "S\147\227\222\204\171\172K", _willProps = +// [PropServerKeepAlive 1944,PropReasonString +// "0\239\168\&5<\ETX\140\235I\244\173\138z\ESC{\129\197\207\143\220M\195\150\a\155oC",PropPayloadFormatIndicator +// 130,PropMessageExpiryInterval 8409,PropWildcardSubscriptionAvailable 23,PropWillDelayInterval +// 14617,PropCorrelationData +// "\167t\142\149G\RS#\158\136\243\220Ok\210\DC4\205\155(\137\n\239\141&\215<\174\169",PropRetainAvailable +// 166,PropContentType +// "5\FS\177TN@\249.\151b\245\216&\147\128\212I$\236\v\238\221\237\200\204\212\149\NUL\ETB\154\155\209\134\224f\224M\176\ETX\254\FS\252\150",PropMessageExpiryInterval +// 11960,PropRequestResponseInformation 48,PropMaximumQoS 34,PropRetainAvailable 88,PropWildcardSubscriptionAvailable +// 149]}), _cleanSession = True, _keepAlive = 6922, _connID = "\132\211\DC4\175\183\DC4\ETB\170Y", _properties = []} +TEST(Connect5QCTest, Encode36) { + uint8_t pkt[] = { + 0x10, 0x91, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x1b, 0xa, 0x0, 0x0, 0x9, 0x84, 0xd3, 0x14, + 0xaf, 0xb7, 0x14, 0x17, 0xaa, 0x59, 0xbb, 0x1, 0x8, 0x0, 0x8, 0x67, 0x4, 0xe4, 0xda, 0x51, 0x7, 0xa3, 0x2b, + 0x11, 0x0, 0x0, 0x39, 0x93, 0x1c, 0x0, 0x11, 0x54, 0xf9, 0x58, 0xd5, 0xf4, 0xb1, 0xfa, 0xc9, 0x18, 0x24, 0x12, + 0x16, 0x75, 0x23, 0xc7, 0x50, 0xeb, 0x24, 0xbb, 0x1c, 0x0, 0x2, 0xe9, 0x12, 0x25, 0xb4, 0x24, 0x97, 0x13, 0x52, + 0xaa, 0x1f, 0x0, 0x12, 0x93, 0xec, 0xd9, 0xd7, 0x2f, 0x14, 0xbc, 0x4b, 0xa9, 0x61, 0xa1, 0x90, 0x85, 0xaa, 0x1b, + 0xe3, 0x65, 0x43, 0x22, 0x53, 0x96, 0x17, 0x28, 0x25, 0xdb, 0x27, 0x0, 0x0, 0x66, 0xa7, 0x21, 0x44, 0x75, 0x21, + 0x7e, 0xbb, 0x2a, 0x54, 0x25, 0x7d, 0x2, 0x0, 0x0, 0x2d, 0xae, 0x3, 0x0, 0x1c, 0xc1, 0x1b, 0x9c, 0x4f, 0x15, + 0x15, 0xd7, 0x3b, 0x81, 0xb7, 0x31, 0x6, 0xf, 0xbf, 0x51, 0x74, 0x33, 0x3f, 0xc1, 0x96, 0x45, 0x99, 0xd, 0x3a, + 0x84, 0x2a, 0x1b, 0x24, 0x2a, 0xf, 0xb, 0x2, 0x2, 0x0, 0x0, 0x1c, 0x72, 0x23, 0x1, 0x32, 0x15, 0x0, 0x1e, + 0xfa, 0x57, 0x39, 0x1d, 0x1b, 0xfc, 0xfb, 0x86, 0x3e, 0xed, 0xc8, 0xcc, 0xd4, 0x95, 0x0, 0x17, 0x9a, 0x9b, 0xd1, + 0x86, 0xe0, 0x66, 0xe0, 0x4d, 0xb0, 0x3, 0xfe, 0x1c, 0xfc, 0x96, 0x2, 0x0, 0x0, 0x2e, 0xb8, 0x19, 0x30, 0x24, + 0x22, 0x25, 0x58, 0x28, 0x95, 0x0, 0x3, 0xf5, 0xdd, 0x6f, 0x0, 0x1d, 0xeb, 0x1, 0x2c, 0x6e, 0x51, 0x26, 0x11, + 0x62, 0x4a, 0x14, 0xb1, 0xb2, 0xc2, 0xb5, 0xef, 0xf3, 0x49, 0xa7, 0xe8, 0x96, 0xb3, 0x7c, 0x5e, 0xb9, 0xf1, 0xa4, + 0x57, 0x76, 0xd3, 0x0, 0x9, 0x26, 0x3, 0x11, 0x74, 0x4a, 0xcc, 0xd3, 0x51, 0x60, 0x0, 0xd, 0x80, 0x63, 0xbf, + 0x2e, 0xa2, 0xfd, 0x1d, 0xa2, 0x71, 0x82, 0x8a, 0xbc, 0x59}; + + uint8_t buf[286] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x67, 0x4, 0xe4, 0xda, 0x51, 0x7, 0xa3, 0x2b}; + uint8_t byteswillprops1[] = {0x54, 0xf9, 0x58, 0xd5, 0xf4, 0xb1, 0xfa, 0xc9, 0x18, + 0x24, 0x12, 0x16, 0x75, 0x23, 0xc7, 0x50, 0xeb}; + uint8_t byteswillprops2[] = {0xe9, 0x12}; + uint8_t byteswillprops3[] = {0x93, 0xec, 0xd9, 0xd7, 0x2f, 0x14, 0xbc, 0x4b, 0xa9, + 0x61, 0xa1, 0x90, 0x85, 0xaa, 0x1b, 0xe3, 0x65, 0x43}; + uint8_t byteswillprops4[] = {0xc1, 0x1b, 0x9c, 0x4f, 0x15, 0x15, 0xd7, 0x3b, 0x81, 0xb7, 0x31, 0x6, 0xf, 0xbf, + 0x51, 0x74, 0x33, 0x3f, 0xc1, 0x96, 0x45, 0x99, 0xd, 0x3a, 0x84, 0x2a, 0x1b, 0x24}; + uint8_t byteswillprops5[] = {0xfa, 0x57, 0x39, 0x1d, 0x1b, 0xfc, 0xfb, 0x86, 0x3e, 0xed, + 0xc8, 0xcc, 0xd4, 0x95, 0x0, 0x17, 0x9a, 0x9b, 0xd1, 0x86, + 0xe0, 0x66, 0xe0, 0x4d, 0xb0, 0x3, 0xfe, 0x1c, 0xfc, 0x96}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14739}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21162}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21398}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26279}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17525}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32443}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11694}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7282}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 306}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11960}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 149}}, + }; + + lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf5, 0xdd, 0x6f}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xeb, 0x1, 0x2c, 0x6e, 0x51, 0x26, 0x11, 0x62, 0x4a, 0x14, + 0xb1, 0xb2, 0xc2, 0xb5, 0xef, 0xf3, 0x49, 0xa7, 0xe8, 0x96, + 0xb3, 0x7c, 0x5e, 0xb9, 0xf1, 0xa4, 0x57, 0x76, 0xd3}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 6922; + uint8_t client_id_bytes[] = {0x84, 0xd3, 0x14, 0xaf, 0xb7, 0x14, 0x17, 0xaa, 0x59}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x26, 0x3, 0x11, 0x74, 0x4a, 0xcc, 0xd3, 0x51, 0x60}; + lwmqtt_string_t username = {9, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x80, 0x63, 0xbf, 0x2e, 0xa2, 0xfd, 0x1d, 0xa2, 0x71, 0x82, 0x8a, 0xbc, 0x59}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\169\"\142.S\145\159\133VvX<\209\161", _password = Nothing, _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\136Rv", _willMsg = +// "v\SUB58p+]s\v\SYN\DC3!\220\199\192'K\140d\n@\133\188\CAN\174\209\SYNK", _willProps = [PropAuthenticationMethod +// "\136\131\t\134\DEL\b\146\224)H\168\SOH^\ACK\138\191\f",PropResponseInformation +// "\n\"4Y\CAN\144r\DC3\249;\194\155\183\211\188\139\189\195\212\198\218.",PropResponseInformation +// "\239\242p\150\NUL\ve\FS\129\248&K<\DEL\155&6\218\155u\200\233v\195\157S",PropResponseInformation +// "GsM\185DI&\220,\199\225}\232\210\230",PropServerKeepAlive 5331,PropMessageExpiryInterval +// 8248,PropSubscriptionIdentifierAvailable 138,PropTopicAlias 10808,PropWillDelayInterval 18139,PropServerReference +// "\245\191P\171\128W\137\254\153\201\a\144@;`\STXD\192}\240\174A\a\140\ETXK\195\196",PropContentType +// "2\227\200\218\239@\146\CANu\165C\218C\160\213*\248A\184:2\137 \EM\201\177]\241\133)",PropMessageExpiryInterval +// 20966,PropTopicAlias 3704,PropAuthenticationMethod +// "\FS\SYN;-\219^\ACK\tN\200\227\r\198Z\139\178*.\166\238",PropReasonString "s\204",PropUserProperty "\SI\225\229\135" +// "\169\r9\219!\164W\149w]w\160\151^",PropRequestResponseInformation 226,PropUserProperty +// "\199$\141b\191m\222\150\234\&9p\FS2A\EM\207\\\187\STX\244Y!?L\v" "\255\153\214"]}), _cleanSession = False, +// _keepAlive = 25116, _connID = "\SOR\"\166}\168\197\211\153\NAK\249\165\138\211", _properties = +// [PropMessageExpiryInterval 15040]} +TEST(Connect5QCTest, Encode37) { + uint8_t pkt[] = { + 0x10, 0xe1, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x94, 0x62, 0x1c, 0x5, 0x2, 0x0, 0x0, 0x3a, 0xc0, + 0x0, 0xe, 0xe, 0x52, 0x22, 0xa6, 0x7d, 0xa8, 0xc5, 0xd3, 0x99, 0x15, 0xf9, 0xa5, 0x8a, 0xd3, 0x8c, 0x2, 0x15, + 0x0, 0x11, 0x88, 0x83, 0x9, 0x86, 0x7f, 0x8, 0x92, 0xe0, 0x29, 0x48, 0xa8, 0x1, 0x5e, 0x6, 0x8a, 0xbf, 0xc, + 0x1a, 0x0, 0x16, 0xa, 0x22, 0x34, 0x59, 0x18, 0x90, 0x72, 0x13, 0xf9, 0x3b, 0xc2, 0x9b, 0xb7, 0xd3, 0xbc, 0x8b, + 0xbd, 0xc3, 0xd4, 0xc6, 0xda, 0x2e, 0x1a, 0x0, 0x1a, 0xef, 0xf2, 0x70, 0x96, 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7, 0x24, 0x8d, 0x62, 0xbf, 0x6d, 0xde, 0x96, 0xea, 0x39, + 0x70, 0x1c, 0x32, 0x41, 0x19, 0xcf, 0x5c, 0xbb, 0x2, 0xf4, 0x59, 0x21, 0x3f, 0x4c, 0xb, 0x0, 0x3, 0xff, 0x99, + 0xd6, 0x0, 0x3, 0x88, 0x52, 0x76, 0x0, 0x1c, 0x76, 0x1a, 0x35, 0x38, 0x70, 0x2b, 0x5d, 0x73, 0xb, 0x16, 0x13, + 0x21, 0xdc, 0xc7, 0xc0, 0x27, 0x4b, 0x8c, 0x64, 0xa, 0x40, 0x85, 0xbc, 0x18, 0xae, 0xd1, 0x16, 0x4b, 0x0, 0xe, + 0xa9, 0x22, 0x8e, 0x2e, 0x53, 0x91, 0x9f, 0x85, 0x56, 0x76, 0x58, 0x3c, 0xd1, 0xa1}; + + uint8_t buf[366] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15040}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x88, 0x83, 0x9, 0x86, 0x7f, 0x8, 0x92, 0xe0, 0x29, + 0x48, 0xa8, 0x1, 0x5e, 0x6, 0x8a, 0xbf, 0xc}; + uint8_t byteswillprops1[] = {0xa, 0x22, 0x34, 0x59, 0x18, 0x90, 0x72, 0x13, 0xf9, 0x3b, 0xc2, + 0x9b, 0xb7, 0xd3, 0xbc, 0x8b, 0xbd, 0xc3, 0xd4, 0xc6, 0xda, 0x2e}; + uint8_t byteswillprops2[] = {0xef, 0xf2, 0x70, 0x96, 0x0, 0xb, 0x65, 0x1c, 0x81, 0xf8, 0x26, 0x4b, 0x3c, + 0x7f, 0x9b, 0x26, 0x36, 0xda, 0x9b, 0x75, 0xc8, 0xe9, 0x76, 0xc3, 0x9d, 0x53}; + uint8_t byteswillprops3[] = {0x47, 0x73, 0x4d, 0xb9, 0x44, 0x49, 0x26, 0xdc, + 0x2c, 0xc7, 0xe1, 0x7d, 0xe8, 0xd2, 0xe6}; + uint8_t byteswillprops4[] = {0xf5, 0xbf, 0x50, 0xab, 0x80, 0x57, 0x89, 0xfe, 0x99, 0xc9, 0x7, 0x90, 0x40, 0x3b, + 0x60, 0x2, 0x44, 0xc0, 0x7d, 0xf0, 0xae, 0x41, 0x7, 0x8c, 0x3, 0x4b, 0xc3, 0xc4}; + uint8_t byteswillprops5[] = {0x32, 0xe3, 0xc8, 0xda, 0xef, 0x40, 0x92, 0x18, 0x75, 0xa5, + 0x43, 0xda, 0x43, 0xa0, 0xd5, 0x2a, 0xf8, 0x41, 0xb8, 0x3a, + 0x32, 0x89, 0x20, 0x19, 0xc9, 0xb1, 0x5d, 0xf1, 0x85, 0x29}; + uint8_t byteswillprops6[] = {0x1c, 0x16, 0x3b, 0x2d, 0xdb, 0x5e, 0x6, 0x9, 0x4e, 0xc8, + 0xe3, 0xd, 0xc6, 0x5a, 0x8b, 0xb2, 0x2a, 0x2e, 0xa6, 0xee}; + uint8_t byteswillprops7[] = {0x73, 0xcc}; + uint8_t byteswillprops9[] = {0xa9, 0xd, 0x39, 0xdb, 0x21, 0xa4, 0x57, 0x95, 0x77, 0x5d, 0x77, 0xa0, 0x97, 0x5e}; + uint8_t byteswillprops8[] = {0xf, 0xe1, 0xe5, 0x87}; + uint8_t byteswillprops11[] = {0xff, 0x99, 0xd6}; + uint8_t byteswillprops10[] = {0xc7, 0x24, 0x8d, 0x62, 0xbf, 0x6d, 0xde, 0x96, 0xea, 0x39, 0x70, 0x1c, 0x32, + 0x41, 0x19, 0xcf, 0x5c, 0xbb, 0x2, 0xf4, 0x59, 0x21, 0x3f, 0x4c, 0xb}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5331}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8248}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10808}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18139}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20966}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3704}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {4, (char*)&byteswillprops8}, .v = {14, (char*)&byteswillprops9}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {25, (char*)&byteswillprops10}, .v = {3, (char*)&byteswillprops11}}}}, + }; + + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x88, 0x52, 0x76}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x76, 0x1a, 0x35, 0x38, 0x70, 0x2b, 0x5d, 0x73, 0xb, 0x16, 0x13, 0x21, 0xdc, 0xc7, + 0xc0, 0x27, 0x4b, 0x8c, 0x64, 0xa, 0x40, 0x85, 0xbc, 0x18, 0xae, 0xd1, 0x16, 0x4b}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 25116; + uint8_t client_id_bytes[] = {0xe, 0x52, 0x22, 0xa6, 0x7d, 0xa8, 0xc5, 0xd3, 0x99, 0x15, 0xf9, 0xa5, 0x8a, 0xd3}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa9, 0x22, 0x8e, 0x2e, 0x53, 0x91, 0x9f, 0x85, 0x56, 0x76, 0x58, 0x3c, 0xd1, 0xa1}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "j3`=\194\212\200O\134\155v\212", _password = Just "\SI\FS=Y\232J\158\196\230\170", +// _lastWill = Nothing, _cleanSession = True, _keepAlive = 1881, _connID = "c\207n(N\155H\154,\158u\205*\f\182\SO", +// _properties = [PropSharedSubscriptionAvailable 242,PropMaximumPacketSize 12669,PropCorrelationData +// "\171&qocN\205\158\212\&9\DC1\187\DLE\193\132D\241\&6\140",PropResponseTopic +// "\164p\153\DEL\159\222]~\r\239\227\248~#\212\195",PropReasonString +// "\236\166\EOT\r\251\153,\128\229\206k8>\227\CAN\201Rv\181\174\225\138EL\128;wLi",PropCorrelationData +// "6\234\236G\GS-w\210\ENQLG\STX\243\197",PropTopicAliasMaximum 9001,PropAuthenticationMethod +// "/\174!\180\165x\158S\247\165@3\253\249\\}\SYN\208\\\"\139\167\192\204\225)\163v",PropAuthenticationData +// "E\174\255`s\170\198\249A#\ACK\206J\ACK\STX\CANC6U\229\152\SI\CANfoe\\\139\254k",PropRequestResponseInformation +// 139,PropRequestResponseInformation 12,PropMessageExpiryInterval 29570,PropAuthenticationMethod +// "\193\ACK\198\207v\195\144w\162\191\DC4\176\142PZ\203\192o\EOTL\ETX\128N\155\175\174o(\197",PropUserProperty +// "\254\141k,`q\209e\DC4\"K\253\224Z\SOH'\246" +// "\164\204\139\NUL>Vr\166&\SYN\192\150r\191\141",PropSessionExpiryInterval 28694,PropAuthenticationMethod +// "\174%\178\170H\191\151b3X\219\219\194\140\ESC\197I\136\229.FO\198J",PropSharedSubscriptionAvailable +// 198,PropAuthenticationMethod "\144\145GA;\DC4{\198\221\129\253e \172\206\v\"\146v23\178\203qp"]} +TEST(Connect5QCTest, Encode38) { + uint8_t pkt[] = { + 0x10, 0xe8, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x7, 0x59, 0xb0, 0x2, 0x2a, 0xf2, 0x27, 0x0, + 0x0, 0x31, 0x7d, 0x9, 0x0, 0x13, 0xab, 0x26, 0x71, 0x6f, 0x63, 0x4e, 0xcd, 0x9e, 0xd4, 0x39, 0x11, 0xbb, 0x10, + 0xc1, 0x84, 0x44, 0xf1, 0x36, 0x8c, 0x8, 0x0, 0x10, 0xa4, 0x70, 0x99, 0x7f, 0x9f, 0xde, 0x5d, 0x7e, 0xd, 0xef, + 0xe3, 0xf8, 0x7e, 0x23, 0xd4, 0xc3, 0x1f, 0x0, 0x1d, 0xec, 0xa6, 0x4, 0xd, 0xfb, 0x99, 0x2c, 0x80, 0xe5, 0xce, + 0x6b, 0x38, 0x3e, 0xe3, 0x18, 0xc9, 0x52, 0x76, 0xb5, 0xae, 0xe1, 0x8a, 0x45, 0x4c, 0x80, 0x3b, 0x77, 0x4c, 0x69, + 0x9, 0x0, 0xe, 0x36, 0xea, 0xec, 0x47, 0x1d, 0x2d, 0x77, 0xd2, 0x5, 0x4c, 0x47, 0x2, 0xf3, 0xc5, 0x22, 0x23, + 0x29, 0x15, 0x0, 0x1c, 0x2f, 0xae, 0x21, 0xb4, 0xa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xce, 0xb, 0x22, 0x92, 0x76, 0x32, 0x33, 0xb2, 0xcb, 0x71, 0x70, 0x0, 0x10, 0x63, 0xcf, + 0x6e, 0x28, 0x4e, 0x9b, 0x48, 0x9a, 0x2c, 0x9e, 0x75, 0xcd, 0x2a, 0xc, 0xb6, 0xe, 0x0, 0xc, 0x6a, 0x33, 0x60, + 0x3d, 0xc2, 0xd4, 0xc8, 0x4f, 0x86, 0x9b, 0x76, 0xd4, 0x0, 0xa, 0xf, 0x1c, 0x3d, 0x59, 0xe8, 0x4a, 0x9e, 0xc4, + 0xe6, 0xaa}; + + uint8_t buf[373] = {0}; + + uint8_t bytesprops0[] = {0xab, 0x26, 0x71, 0x6f, 0x63, 0x4e, 0xcd, 0x9e, 0xd4, 0x39, + 0x11, 0xbb, 0x10, 0xc1, 0x84, 0x44, 0xf1, 0x36, 0x8c}; + uint8_t bytesprops1[] = {0xa4, 0x70, 0x99, 0x7f, 0x9f, 0xde, 0x5d, 0x7e, + 0xd, 0xef, 0xe3, 0xf8, 0x7e, 0x23, 0xd4, 0xc3}; + uint8_t bytesprops2[] = {0xec, 0xa6, 0x4, 0xd, 0xfb, 0x99, 0x2c, 0x80, 0xe5, 0xce, 0x6b, 0x38, 0x3e, 0xe3, 0x18, + 0xc9, 0x52, 0x76, 0xb5, 0xae, 0xe1, 0x8a, 0x45, 0x4c, 0x80, 0x3b, 0x77, 0x4c, 0x69}; + uint8_t bytesprops3[] = {0x36, 0xea, 0xec, 0x47, 0x1d, 0x2d, 0x77, 0xd2, 0x5, 0x4c, 0x47, 0x2, 0xf3, 0xc5}; + uint8_t bytesprops4[] = {0x2f, 0xae, 0x21, 0xb4, 0xa5, 0x78, 0x9e, 0x53, 0xf7, 0xa5, 0x40, 0x33, 0xfd, 0xf9, + 0x5c, 0x7d, 0x16, 0xd0, 0x5c, 0x22, 0x8b, 0xa7, 0xc0, 0xcc, 0xe1, 0x29, 0xa3, 0x76}; + uint8_t bytesprops5[] = {0x45, 0xae, 0xff, 0x60, 0x73, 0xaa, 0xc6, 0xf9, 0x41, 0x23, 0x6, 0xce, 0x4a, 0x6, 0x2, + 0x18, 0x43, 0x36, 0x55, 0xe5, 0x98, 0xf, 0x18, 0x66, 0x6f, 0x65, 0x5c, 0x8b, 0xfe, 0x6b}; + uint8_t bytesprops6[] = {0xc1, 0x6, 0xc6, 0xcf, 0x76, 0xc3, 0x90, 0x77, 0xa2, 0xbf, 0x14, 0xb0, 0x8e, 0x50, 0x5a, + 0xcb, 0xc0, 0x6f, 0x4, 0x4c, 0x3, 0x80, 0x4e, 0x9b, 0xaf, 0xae, 0x6f, 0x28, 0xc5}; + uint8_t bytesprops8[] = {0xa4, 0xcc, 0x8b, 0x0, 0x3e, 0x56, 0x72, 0xa6, 0x26, 0x16, 0xc0, 0x96, 0x72, 0xbf, 0x8d}; + uint8_t bytesprops7[] = {0xfe, 0x8d, 0x6b, 0x2c, 0x60, 0x71, 0xd1, 0x65, 0x14, + 0x22, 0x4b, 0xfd, 0xe0, 0x5a, 0x1, 0x27, 0xf6}; + uint8_t bytesprops9[] = {0xae, 0x25, 0xb2, 0xaa, 0x48, 0xbf, 0x97, 0x62, 0x33, 0x58, 0xdb, 0xdb, + 0xc2, 0x8c, 0x1b, 0xc5, 0x49, 0x88, 0xe5, 0x2e, 0x46, 0x4f, 0xc6, 0x4a}; + uint8_t bytesprops10[] = {0x90, 0x91, 0x47, 0x41, 0x3b, 0x14, 0x7b, 0xc6, 0xdd, 0x81, 0xfd, 0x65, 0x20, + 0xac, 0xce, 0xb, 0x22, 0x92, 0x76, 0x32, 0x33, 0xb2, 0xcb, 0x71, 0x70}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12669}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9001}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29570}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops7}, .v = {15, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28694}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops10}}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1881; + uint8_t client_id_bytes[] = {0x63, 0xcf, 0x6e, 0x28, 0x4e, 0x9b, 0x48, 0x9a, + 0x2c, 0x9e, 0x75, 0xcd, 0x2a, 0xc, 0xb6, 0xe}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x6a, 0x33, 0x60, 0x3d, 0xc2, 0xd4, 0xc8, 0x4f, 0x86, 0x9b, 0x76, 0xd4}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf, 0x1c, 0x3d, 0x59, 0xe8, 0x4a, 0x9e, 0xc4, 0xe6, 0xaa}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\ETXp\147\149\&7", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS1, _willTopic = "\218G\228", _willMsg = +// "\133\141;\199\135\145\&1\NAK\215\162H\224\199q\ft\156F\STX\178\162\152\147f\SI\229\248", _willProps = +// [PropAuthenticationMethod "\"G\166\181(C\175\&1\210\"\158Y\SYN\ETB\ESCa\156\190\US\245-o\227",PropServerReference +// ">\159\208\132\v\243N\233\179o,*B\148\210~(\192\DC4\255\SOH\244\149\133\ETB:\187m>",PropServerKeepAlive +// 2146,PropMessageExpiryInterval 25696,PropSessionExpiryInterval 27600,PropAuthenticationData +// "\130\CAN\165P/\148\165\149\&3\192\143\148n>$\141\242\224\231\&0\145{\230f\RS\178\189",PropMessageExpiryInterval +// 31786,PropRetainAvailable 93,PropCorrelationData "\198",PropSubscriptionIdentifierAvailable +// 106,PropPayloadFormatIndicator 124,PropRetainAvailable 138,PropWillDelayInterval 27628,PropRequestProblemInformation +// 210]}), _cleanSession = False, _keepAlive = 3338, _connID = +// "\244\164\&6\SYN\146\249\SOHR|b\175e~\146x\233H\240C\208\249M\233v\234\194\203\189\230\222", _properties = []} +TEST(Connect5QCTest, Encode39) { + uint8_t pkt[] = {0x10, 0xd2, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xac, 0xd, 0xa, 0x0, 0x0, 0x1e, 0xf4, + 0xa4, 0x36, 0x16, 0x92, 0xf9, 0x1, 0x52, 0x7c, 0x62, 0xaf, 0x65, 0x7e, 0x92, 0x78, 0xe9, 0x48, 0xf0, + 0x43, 0xd0, 0xf9, 0x4d, 0xe9, 0x76, 0xea, 0xc2, 0xcb, 0xbd, 0xe6, 0xde, 0x7d, 0x15, 0x0, 0x17, 0x22, + 0x47, 0xa6, 0xb5, 0x28, 0x43, 0xaf, 0x31, 0xd2, 0x22, 0x9e, 0x59, 0x16, 0x17, 0x1b, 0x61, 0x9c, 0xbe, + 0x1f, 0xf5, 0x2d, 0x6f, 0xe3, 0x1c, 0x0, 0x1d, 0x3e, 0x9f, 0xd0, 0x84, 0xb, 0xf3, 0x4e, 0xe9, 0xb3, + 0x6f, 0x2c, 0x2a, 0x42, 0x94, 0xd2, 0x7e, 0x28, 0xc0, 0x14, 0xff, 0x1, 0xf4, 0x95, 0x85, 0x17, 0x3a, + 0xbb, 0x6d, 0x3e, 0x13, 0x8, 0x62, 0x2, 0x0, 0x0, 0x64, 0x60, 0x11, 0x0, 0x0, 0x6b, 0xd0, 0x16, + 0x0, 0x1b, 0x82, 0x18, 0xa5, 0x50, 0x2f, 0x94, 0xa5, 0x95, 0x33, 0xc0, 0x8f, 0x94, 0x6e, 0x3e, 0x24, + 0x8d, 0xf2, 0xe0, 0xe7, 0x30, 0x91, 0x7b, 0xe6, 0x66, 0x1e, 0xb2, 0xbd, 0x2, 0x0, 0x0, 0x7c, 0x2a, + 0x25, 0x5d, 0x9, 0x0, 0x1, 0xc6, 0x29, 0x6a, 0x1, 0x7c, 0x25, 0x8a, 0x18, 0x0, 0x0, 0x6b, 0xec, + 0x17, 0xd2, 0x0, 0x3, 0xda, 0x47, 0xe4, 0x0, 0x1b, 0x85, 0x8d, 0x3b, 0xc7, 0x87, 0x91, 0x31, 0x15, + 0xd7, 0xa2, 0x48, 0xe0, 0xc7, 0x71, 0xc, 0x74, 0x9c, 0x46, 0x2, 0xb2, 0xa2, 0x98, 0x93, 0x66, 0xf, + 0xe5, 0xf8, 0x0, 0x5, 0x3, 0x70, 0x93, 0x95, 0x37}; + + uint8_t buf[223] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x22, 0x47, 0xa6, 0xb5, 0x28, 0x43, 0xaf, 0x31, 0xd2, 0x22, 0x9e, 0x59, + 0x16, 0x17, 0x1b, 0x61, 0x9c, 0xbe, 0x1f, 0xf5, 0x2d, 0x6f, 0xe3}; + uint8_t byteswillprops1[] = {0x3e, 0x9f, 0xd0, 0x84, 0xb, 0xf3, 0x4e, 0xe9, 0xb3, 0x6f, 0x2c, 0x2a, 0x42, 0x94, 0xd2, + 0x7e, 0x28, 0xc0, 0x14, 0xff, 0x1, 0xf4, 0x95, 0x85, 0x17, 0x3a, 0xbb, 0x6d, 0x3e}; + uint8_t byteswillprops2[] = {0x82, 0x18, 0xa5, 0x50, 0x2f, 0x94, 0xa5, 0x95, 0x33, 0xc0, 0x8f, 0x94, 0x6e, 0x3e, + 0x24, 0x8d, 0xf2, 0xe0, 0xe7, 0x30, 0x91, 0x7b, 0xe6, 0x66, 0x1e, 0xb2, 0xbd}; + uint8_t byteswillprops3[] = {0xc6}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2146}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25696}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27600}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31786}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27628}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, + }; + + lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xda, 0x47, 0xe4}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x85, 0x8d, 0x3b, 0xc7, 0x87, 0x91, 0x31, 0x15, 0xd7, 0xa2, 0x48, 0xe0, 0xc7, 0x71, + 0xc, 0x74, 0x9c, 0x46, 0x2, 0xb2, 0xa2, 0x98, 0x93, 0x66, 0xf, 0xe5, 0xf8}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3338; + uint8_t client_id_bytes[] = {0xf4, 0xa4, 0x36, 0x16, 0x92, 0xf9, 0x1, 0x52, 0x7c, 0x62, + 0xaf, 0x65, 0x7e, 0x92, 0x78, 0xe9, 0x48, 0xf0, 0x43, 0xd0, + 0xf9, 0x4d, 0xe9, 0x76, 0xea, 0xc2, 0xcb, 0xbd, 0xe6, 0xde}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x3, 0x70, 0x93, 0x95, 0x37}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "%s%1", _password = Just "JZ\188v\194\151\206\232\FS8\227", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "<3\134\&3\210\ai\247\172", _willMsg = +// "\195Z\ACK\163\170\202", _willProps = [PropCorrelationData "\a\217q",PropAuthenticationData +// "/\157\198\206R\DC4\242S\164@\164\228A",PropMaximumQoS 158,PropRequestResponseInformation +// 204,PropWildcardSubscriptionAvailable 143,PropSharedSubscriptionAvailable 230,PropAssignedClientIdentifier +// "\207\249\164\SYN3\EM'\185\247\252\153\ESC\153\229\218\157\aiSb",PropAuthenticationMethod +// "\239\ETB",PropSubscriptionIdentifier 19,PropResponseTopic +// "q\197\&33\137\f\201\253T~\229i.\147\SUB\221\170",PropReceiveMaximum 4184,PropReceiveMaximum +// 15100,PropRequestProblemInformation 182,PropPayloadFormatIndicator 133,PropAssignedClientIdentifier +// "\DC1\152C\221\192\182\USj\134>4\191\160\210}\171",PropSubscriptionIdentifier 4,PropSharedSubscriptionAvailable +// 15,PropContentType "a\160\237w\210k"]}), _cleanSession = False, _keepAlive = 21786, _connID = +// "$\218\249\238\250,\NUL\129\DC2\162H\219_\168K\DC1\212\231\195p\167\157\177D\149", _properties = []} +TEST(Connect5QCTest, Encode40) { + uint8_t pkt[] = {0x10, 0xc7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x55, 0x1a, 0x0, 0x0, 0x19, 0x24, + 0xda, 0xf9, 0xee, 0xfa, 0x2c, 0x0, 0x81, 0x12, 0xa2, 0x48, 0xdb, 0x5f, 0xa8, 0x4b, 0x11, 0xd4, 0xe7, + 0xc3, 0x70, 0xa7, 0x9d, 0xb1, 0x44, 0x95, 0x7a, 0x9, 0x0, 0x3, 0x7, 0xd9, 0x71, 0x16, 0x0, 0xd, + 0x2f, 0x9d, 0xc6, 0xce, 0x52, 0x14, 0xf2, 0x53, 0xa4, 0x40, 0xa4, 0xe4, 0x41, 0x24, 0x9e, 0x19, 0xcc, + 0x28, 0x8f, 0x2a, 0xe6, 0x12, 0x0, 0x14, 0xcf, 0xf9, 0xa4, 0x16, 0x33, 0x19, 0x27, 0xb9, 0xf7, 0xfc, + 0x99, 0x1b, 0x99, 0xe5, 0xda, 0x9d, 0x7, 0x69, 0x53, 0x62, 0x15, 0x0, 0x2, 0xef, 0x17, 0xb, 0x13, + 0x8, 0x0, 0x11, 0x71, 0xc5, 0x33, 0x33, 0x89, 0xc, 0xc9, 0xfd, 0x54, 0x7e, 0xe5, 0x69, 0x2e, 0x93, + 0x1a, 0xdd, 0xaa, 0x21, 0x10, 0x58, 0x21, 0x3a, 0xfc, 0x17, 0xb6, 0x1, 0x85, 0x12, 0x0, 0x10, 0x11, + 0x98, 0x43, 0xdd, 0xc0, 0xb6, 0x1f, 0x6a, 0x86, 0x3e, 0x34, 0xbf, 0xa0, 0xd2, 0x7d, 0xab, 0xb, 0x4, + 0x2a, 0xf, 0x3, 0x0, 0x6, 0x61, 0xa0, 0xed, 0x77, 0xd2, 0x6b, 0x0, 0x9, 0x3c, 0x33, 0x86, 0x33, + 0xd2, 0x7, 0x69, 0xf7, 0xac, 0x0, 0x6, 0xc3, 0x5a, 0x6, 0xa3, 0xaa, 0xca, 0x0, 0x4, 0x25, 0x73, + 0x25, 0x31, 0x0, 0xb, 0x4a, 0x5a, 0xbc, 0x76, 0xc2, 0x97, 0xce, 0xe8, 0x1c, 0x38, 0xe3}; + + uint8_t buf[212] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x7, 0xd9, 0x71}; + uint8_t byteswillprops1[] = {0x2f, 0x9d, 0xc6, 0xce, 0x52, 0x14, 0xf2, 0x53, 0xa4, 0x40, 0xa4, 0xe4, 0x41}; + uint8_t byteswillprops2[] = {0xcf, 0xf9, 0xa4, 0x16, 0x33, 0x19, 0x27, 0xb9, 0xf7, 0xfc, + 0x99, 0x1b, 0x99, 0xe5, 0xda, 0x9d, 0x7, 0x69, 0x53, 0x62}; + uint8_t byteswillprops3[] = {0xef, 0x17}; + uint8_t byteswillprops4[] = {0x71, 0xc5, 0x33, 0x33, 0x89, 0xc, 0xc9, 0xfd, 0x54, + 0x7e, 0xe5, 0x69, 0x2e, 0x93, 0x1a, 0xdd, 0xaa}; + uint8_t byteswillprops5[] = {0x11, 0x98, 0x43, 0xdd, 0xc0, 0xb6, 0x1f, 0x6a, + 0x86, 0x3e, 0x34, 0xbf, 0xa0, 0xd2, 0x7d, 0xab}; + uint8_t byteswillprops6[] = {0x61, 0xa0, 0xed, 0x77, 0xd2, 0x6b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4184}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15100}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops6}}}, + }; + + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x3c, 0x33, 0x86, 0x33, 0xd2, 0x7, 0x69, 0xf7, 0xac}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc3, 0x5a, 0x6, 0xa3, 0xaa, 0xca}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 21786; + uint8_t client_id_bytes[] = {0x24, 0xda, 0xf9, 0xee, 0xfa, 0x2c, 0x0, 0x81, 0x12, 0xa2, 0x48, 0xdb, 0x5f, + 0xa8, 0x4b, 0x11, 0xd4, 0xe7, 0xc3, 0x70, 0xa7, 0x9d, 0xb1, 0x44, 0x95}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x25, 0x73, 0x25, 0x31}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x4a, 0x5a, 0xbc, 0x76, 0xc2, 0x97, 0xce, 0xe8, 0x1c, 0x38, 0xe3}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\"\192-\143\173\214\ETXL\182X\SOHQ", _password = Just +// "\210\SI4\163\NUL>\DC1}2x\SOHq\134\ETX\245\&0\169\180", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS1, _willTopic = "\227\NAK\133\240\173\&0\r", _willMsg = "\197 \US\DEL\147\243\248\SI9\198\187\\\219\146\152\229\214\233", _lastWill = +// Nothing, _cleanSession = False, _keepAlive = 30703, _connID = "3\193)\173", _properties = [PropMaximumQoS +// 61,PropWildcardSubscriptionAvailable 121,PropResponseInformation "x\147;\224\240\232&\186",PropMessageExpiryInterval +// 8287,PropSharedSubscriptionAvailable 248,PropRequestResponseInformation 39,PropMessageExpiryInterval +// 18350,PropAssignedClientIdentifier "\192[\a",PropServerKeepAlive 6307,PropServerKeepAlive 24378,PropTopicAlias +// 5418,PropCorrelationData "\205\252\196\192\199P\163\199{xH\165e\229\152\141\143\DLE\148",PropAuthenticationMethod +// "\ETXeI\135\250\180",PropReasonString "N)\DC1|\218X>\247p $k\174a\STX\130\227{\178\RSJ\128",PropUserProperty +// "\216\157\182\181\250\DC1/\201L\169l\148\SOu\141\&1\FS)\229\253\150%\141" +// "I\228\DC4j\246]&\233\194\164",PropWillDelayInterval 15403,PropWildcardSubscriptionAvailable +// 171,PropResponseInformation "n\DC3\SOr\179",PropWillDelayInterval 4719,PropPayloadFormatIndicator +// 90,PropAssignedClientIdentifier "\133P"]} +TEST(Connect5QCTest, Encode45) { + uint8_t pkt[] = {0x10, 0xb7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x77, 0xef, 0xa5, 0x1, 0x24, 0x3d, + 0x28, 0x79, 0x1a, 0x0, 0x8, 0x78, 0x93, 0x3b, 0xe0, 0xf0, 0xe8, 0x26, 0xba, 0x2, 0x0, 0x0, 0x20, + 0x5f, 0x2a, 0xf8, 0x19, 0x27, 0x2, 0x0, 0x0, 0x47, 0xae, 0x12, 0x0, 0x3, 0xc0, 0x5b, 0x7, 0x13, + 0x18, 0xa3, 0x13, 0x5f, 0x3a, 0x23, 0x15, 0x2a, 0x9, 0x0, 0x13, 0xcd, 0xfc, 0xc4, 0xc0, 0xc7, 0x50, + 0xa3, 0xc7, 0x7b, 0x78, 0x48, 0xa5, 0x65, 0xe5, 0x98, 0x8d, 0x8f, 0x10, 0x94, 0x15, 0x0, 0x6, 0x3, + 0x65, 0x49, 0x87, 0xfa, 0xb4, 0x1f, 0x0, 0x16, 0x4e, 0x29, 0x11, 0x7c, 0xda, 0x58, 0x3e, 0xf7, 0x70, + 0x20, 0x24, 0x6b, 0xae, 0x61, 0x2, 0x82, 0xe3, 0x7b, 0xb2, 0x1e, 0x4a, 0x80, 0x26, 0x0, 0x17, 0xd8, + 0x9d, 0xb6, 0xb5, 0xfa, 0x11, 0x2f, 0xc9, 0x4c, 0xa9, 0x6c, 0x94, 0xe, 0x75, 0x8d, 0x31, 0x1c, 0x29, + 0xe5, 0xfd, 0x96, 0x25, 0x8d, 0x0, 0xa, 0x49, 0xe4, 0x14, 0x6a, 0xf6, 0x5d, 0x26, 0xe9, 0xc2, 0xa4, + 0x18, 0x0, 0x0, 0x3c, 0x2b, 0x28, 0xab, 0x1a, 0x0, 0x5, 0x6e, 0x13, 0xe, 0x72, 0xb3, 0x18, 0x0, + 0x0, 0x12, 0x6f, 0x1, 0x5a, 0x12, 0x0, 0x2, 0x85, 0x50, 0x0, 0x4, 0x33, 0xc1, 0x29, 0xad}; + + uint8_t buf[196] = {0}; + + uint8_t bytesprops0[] = {0x78, 0x93, 0x3b, 0xe0, 0xf0, 0xe8, 0x26, 0xba}; + uint8_t bytesprops1[] = {0xc0, 0x5b, 0x7}; + uint8_t bytesprops2[] = {0xcd, 0xfc, 0xc4, 0xc0, 0xc7, 0x50, 0xa3, 0xc7, 0x7b, 0x78, + 0x48, 0xa5, 0x65, 0xe5, 0x98, 0x8d, 0x8f, 0x10, 0x94}; + uint8_t bytesprops3[] = {0x3, 0x65, 0x49, 0x87, 0xfa, 0xb4}; + uint8_t bytesprops4[] = {0x4e, 0x29, 0x11, 0x7c, 0xda, 0x58, 0x3e, 0xf7, 0x70, 0x20, 0x24, + 0x6b, 0xae, 0x61, 0x2, 0x82, 0xe3, 0x7b, 0xb2, 0x1e, 0x4a, 0x80}; + uint8_t bytesprops6[] = {0x49, 0xe4, 0x14, 0x6a, 0xf6, 0x5d, 0x26, 0xe9, 0xc2, 0xa4}; + uint8_t bytesprops5[] = {0xd8, 0x9d, 0xb6, 0xb5, 0xfa, 0x11, 0x2f, 0xc9, 0x4c, 0xa9, 0x6c, 0x94, + 0xe, 0x75, 0x8d, 0x31, 0x1c, 0x29, 0xe5, 0xfd, 0x96, 0x25, 0x8d}; + uint8_t bytesprops7[] = {0x6e, 0x13, 0xe, 0x72, 0xb3}; + uint8_t bytesprops8[] = {0x85, 0x50}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8287}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18350}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6307}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24378}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5418}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops5}, .v = {10, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15403}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4719}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops8}}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 30703; + uint8_t client_id_bytes[] = {0x33, 0xc1, 0x29, 0xad}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x25, 0xcc, 0xb9, 0x33, 0x17, 0x26, 0xae, 0xa3, 0xc, 0xc3, 0x25, 0xcd, 0x33, 0x5b, 0x3e, + 0x7f, 0x93, 0xf3, 0xf8, 0xf, 0x39, 0xc6, 0xbb, 0x5c, 0xdb, 0x92, 0x98, 0xe5, 0xd6, 0xe9}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "]\193c\STX\r\223\249r\ETXZ\v\aN1\DEL\172q\RS\210\169\176i\147\FS\191\181\200Vk%", +// _password = Just "\150\212\ESC\162~(\188%\191\133\243l", _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 9661, _connID = "l\v\146\230\194\DC4X\149\219\171 \169y\188\176\&4\144O", _properties = [PropPayloadFormatIndicator +// 189,PropReasonString "M\159k\191]\152\DC3\243f\228_\149",PropRequestResponseInformation 79,PropServerReference +// "B\153\206\149l\229\147\&5\129}\188}=\238\161-\215\129\145\209G\254\234\190\205A\206\&9h",PropTopicAlias +// 21199,PropMaximumPacketSize 7621,PropMessageExpiryInterval 13332,PropSubscriptionIdentifierAvailable +// 210,PropServerKeepAlive 11594,PropTopicAlias 3010,PropAuthenticationData +// "\183J\162f.\243/\ETB?\156E\195",PropTopicAlias 14998,PropMaximumQoS 58,PropMessageExpiryInterval +// 12903,PropSubscriptionIdentifier 6,PropReceiveMaximum 9744,PropUserProperty "pW\173~e" +// "\239\200U]\144\250n\239",PropServerKeepAlive 17303,PropWildcardSubscriptionAvailable 253,PropMaximumPacketSize +// 17305,PropWildcardSubscriptionAvailable 226,PropAssignedClientIdentifier +// "p\235\135\211\138\NUL\179L\187Z\240\152\227\190\222\f\237\SOH\CAN\135\n\213q\251/\223\219"]} +TEST(Connect5QCTest, Encode46) { + uint8_t pkt[] = { + 0x10, 0xf0, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x25, 0xbd, 0xa2, 0x1, 0x1, 0xbd, 0x1f, 0x0, + 0xc, 0x4d, 0x9f, 0x6b, 0xbf, 0x5d, 0x98, 0x13, 0xf3, 0x66, 0xe4, 0x5f, 0x95, 0x19, 0x4f, 0x1c, 0x0, 0x1d, 0x42, + 0x99, 0xce, 0x95, 0x6c, 0xe5, 0x93, 0x35, 0x81, 0x7d, 0xbc, 0x7d, 0x3d, 0xee, 0xa1, 0x2d, 0xd7, 0x81, 0x91, 0xd1, + 0x47, 0xfe, 0xea, 0xbe, 0xcd, 0x41, 0xce, 0x39, 0x68, 0x23, 0x52, 0xcf, 0x27, 0x0, 0x0, 0x1d, 0xc5, 0x2, 0x0, + 0x0, 0x34, 0x14, 0x29, 0xd2, 0x13, 0x2d, 0x4a, 0x23, 0xb, 0xc2, 0x16, 0x0, 0xc, 0xb7, 0x4a, 0xa2, 0x66, 0x2e, + 0xf3, 0x2f, 0x17, 0x3f, 0x9c, 0x45, 0xc3, 0x23, 0x3a, 0x96, 0x24, 0x3a, 0x2, 0x0, 0x0, 0x32, 0x67, 0xb, 0x6, + 0x21, 0x26, 0x10, 0x26, 0x0, 0x5, 0x70, 0x57, 0xad, 0x7e, 0x65, 0x0, 0x8, 0xef, 0xc8, 0x55, 0x5d, 0x90, 0xfa, + 0x6e, 0xef, 0x13, 0x43, 0x97, 0x28, 0xfd, 0x27, 0x0, 0x0, 0x43, 0x99, 0x28, 0xe2, 0x12, 0x0, 0x1b, 0x70, 0xeb, + 0x87, 0xd3, 0x8a, 0x0, 0xb3, 0x4c, 0xbb, 0x5a, 0xf0, 0x98, 0xe3, 0xbe, 0xde, 0xc, 0xed, 0x1, 0x18, 0x87, 0xa, + 0xd5, 0x71, 0xfb, 0x2f, 0xdf, 0xdb, 0x0, 0x12, 0x6c, 0xb, 0x92, 0xe6, 0xc2, 0x14, 0x58, 0x95, 0xdb, 0xab, 0x20, + 0xa9, 0x79, 0xbc, 0xb0, 0x34, 0x90, 0x4f, 0x0, 0x1e, 0x5d, 0xc1, 0x63, 0x2, 0xd, 0xdf, 0xf9, 0x72, 0x3, 0x5a, + 0xb, 0x7, 0x4e, 0x31, 0x7f, 0xac, 0x71, 0x1e, 0xd2, 0xa9, 0xb0, 0x69, 0x93, 0x1c, 0xbf, 0xb5, 0xc8, 0x56, 0x6b, + 0x25, 0x0, 0xc, 0x96, 0xd4, 0x1b, 0xa2, 0x7e, 0x28, 0xbc, 0x25, 0xbf, 0x85, 0xf3, 0x6c}; + + uint8_t buf[253] = {0}; + + uint8_t bytesprops0[] = {0x4d, 0x9f, 0x6b, 0xbf, 0x5d, 0x98, 0x13, 0xf3, 0x66, 0xe4, 0x5f, 0x95}; + uint8_t bytesprops1[] = {0x42, 0x99, 0xce, 0x95, 0x6c, 0xe5, 0x93, 0x35, 0x81, 0x7d, 0xbc, 0x7d, 0x3d, 0xee, 0xa1, + 0x2d, 0xd7, 0x81, 0x91, 0xd1, 0x47, 0xfe, 0xea, 0xbe, 0xcd, 0x41, 0xce, 0x39, 0x68}; + uint8_t bytesprops2[] = {0xb7, 0x4a, 0xa2, 0x66, 0x2e, 0xf3, 0x2f, 0x17, 0x3f, 0x9c, 0x45, 0xc3}; + uint8_t bytesprops4[] = {0xef, 0xc8, 0x55, 0x5d, 0x90, 0xfa, 0x6e, 0xef}; + uint8_t bytesprops3[] = {0x70, 0x57, 0xad, 0x7e, 0x65}; + uint8_t bytesprops5[] = {0x70, 0xeb, 0x87, 0xd3, 0x8a, 0x0, 0xb3, 0x4c, 0xbb, 0x5a, 0xf0, 0x98, 0xe3, 0xbe, + 0xde, 0xc, 0xed, 0x1, 0x18, 0x87, 0xa, 0xd5, 0x71, 0xfb, 0x2f, 0xdf, 0xdb}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21199}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7621}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13332}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11594}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3010}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14998}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12903}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9744}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops3}, .v = {8, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17303}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17305}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops5}}}, + }; + + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 9661; + uint8_t client_id_bytes[] = {0x6c, 0xb, 0x92, 0xe6, 0xc2, 0x14, 0x58, 0x95, 0xdb, + 0xab, 0x20, 0xa9, 0x79, 0xbc, 0xb0, 0x34, 0x90, 0x4f}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x5d, 0xc1, 0x63, 0x2, 0xd, 0xdf, 0xf9, 0x72, 0x3, 0x5a, 0xb, 0x7, 0x4e, 0x31, 0x7f, + 0xac, 0x71, 0x1e, 0xd2, 0xa9, 0xb0, 0x69, 0x93, 0x1c, 0xbf, 0xb5, 0xc8, 0x56, 0x6b, 0x25}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x96, 0xd4, 0x1b, 0xa2, 0x7e, 0x28, 0xbc, 0x25, 0xbf, 0x85, 0xf3, 0x6c}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "HK\160A\236!\215\217", _password = Just "\172", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = "_#", _willMsg = "}\199!\254\224\b\154\&2\232\184\163\213?\186", +// _willProps = [PropMaximumPacketSize 11544,PropReasonString +// "\231e\251\t\139\&1\227z\t5}\242Y\188\ENQ\255\189\200\241\216e\227\223",PropWillDelayInterval +// 27907,PropAuthenticationMethod "\253Uz>\225\f",PropContentType +// "\148\161\201\DEL$\165\167<:\208AZx%\246\255\133\231\173\193\ENQ\181\169\208\US\182\136\215\196",PropSubscriptionIdentifier +// 30,PropReasonString "u\241\SOO\DC1\153\199Z",PropRequestProblemInformation 103,PropPayloadFormatIndicator +// 43,PropRequestResponseInformation 227,PropPayloadFormatIndicator 40,PropResponseTopic +// "e{M\164\STX\240\225$\188\202\145\149\133p<\203\241\168o\133s\130\CAN\154\r\220\178\227\194",PropTopicAlias +// 7,PropTopicAlias 23134,PropRetainAvailable 141,PropTopicAlias 30201,PropTopicAliasMaximum 1945,PropTopicAlias +// 7974,PropUserProperty "\DLE\219\236\SI\253\233\rA" +// "\143&{H\171\&0q\SUBc\139\t6\US\231Hp\186\228\182",PropAuthenticationData +// "\196g\208\248\n",PropRequestResponseInformation 36,PropServerKeepAlive 10008,PropTopicAlias 13108]}), _cleanSession +// = True, _keepAlive = 8375, _connID = "{iE\207H\USn\DLE\193\b\245\216JK", _properties = [PropSessionExpiryInterval +// 19323,PropMessageExpiryInterval 30707,PropTopicAliasMaximum 25463,PropAuthenticationMethod +// "\157\190\201\186\DLE/\142\ESC\\\197\235\173\244\130\176\152"]} +TEST(Connect5QCTest, Encode47) { + uint8_t pkt[] = { + 0x10, 0xa1, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x20, 0xb7, 0x20, 0x11, 0x0, 0x0, 0x4b, 0x7b, + 0x2, 0x0, 0x0, 0x77, 0xf3, 0x22, 0x63, 0x77, 0x15, 0x0, 0x10, 0x9d, 0xbe, 0xc9, 0xba, 0x10, 0x2f, 0x8e, 0x1b, + 0x5c, 0xc5, 0xeb, 0xad, 0xf4, 0x82, 0xb0, 0x98, 0x0, 0xe, 0x7b, 0x69, 0x45, 0xcf, 0x48, 0x1f, 0x6e, 0x10, 0xc1, + 0x8, 0xf5, 0xd8, 0x4a, 0x4b, 0xc3, 0x1, 0x27, 0x0, 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 0x24, 0x13, 0x27, 0x18, 0x23, 0x33, 0x34, 0x0, 0x2, 0x5f, 0x23, 0x0, 0xe, 0x7d, + 0xc7, 0x21, 0xfe, 0xe0, 0x8, 0x9a, 0x32, 0xe8, 0xb8, 0xa3, 0xd5, 0x3f, 0xba, 0x0, 0x8, 0x48, 0x4b, 0xa0, 0x41, + 0xec, 0x21, 0xd7, 0xd9, 0x0, 0x1, 0xac}; + + uint8_t buf[302] = {0}; + + uint8_t bytesprops0[] = {0x9d, 0xbe, 0xc9, 0xba, 0x10, 0x2f, 0x8e, 0x1b, + 0x5c, 0xc5, 0xeb, 0xad, 0xf4, 0x82, 0xb0, 0x98}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19323}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30707}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25463}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xe7, 0x65, 0xfb, 0x9, 0x8b, 0x31, 0xe3, 0x7a, 0x9, 0x35, 0x7d, 0xf2, + 0x59, 0xbc, 0x5, 0xff, 0xbd, 0xc8, 0xf1, 0xd8, 0x65, 0xe3, 0xdf}; + uint8_t byteswillprops1[] = {0xfd, 0x55, 0x7a, 0x3e, 0xe1, 0xc}; + uint8_t byteswillprops2[] = {0x94, 0xa1, 0xc9, 0x7f, 0x24, 0xa5, 0xa7, 0x3c, 0x3a, 0xd0, 0x41, 0x5a, 0x78, 0x25, 0xf6, + 0xff, 0x85, 0xe7, 0xad, 0xc1, 0x5, 0xb5, 0xa9, 0xd0, 0x1f, 0xb6, 0x88, 0xd7, 0xc4}; + uint8_t byteswillprops3[] = {0x75, 0xf1, 0xe, 0x4f, 0x11, 0x99, 0xc7, 0x5a}; + uint8_t byteswillprops4[] = {0x65, 0x7b, 0x4d, 0xa4, 0x2, 0xf0, 0xe1, 0x24, 0xbc, 0xca, 0x91, 0x95, 0x85, 0x70, 0x3c, + 0xcb, 0xf1, 0xa8, 0x6f, 0x85, 0x73, 0x82, 0x18, 0x9a, 0xd, 0xdc, 0xb2, 0xe3, 0xc2}; + uint8_t byteswillprops6[] = {0x8f, 0x26, 0x7b, 0x48, 0xab, 0x30, 0x71, 0x1a, 0x63, 0x8b, + 0x9, 0x36, 0x1f, 0xe7, 0x48, 0x70, 0xba, 0xe4, 0xb6}; + uint8_t byteswillprops5[] = {0x10, 0xdb, 0xec, 0xf, 0xfd, 0xe9, 0xd, 0x41}; + uint8_t byteswillprops7[] = {0xc4, 0x67, 0xd0, 0xf8, 0xa}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11544}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27907}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23134}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30201}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1945}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7974}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {8, (char*)&byteswillprops5}, .v = {19, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10008}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13108}}, + }; + + lwmqtt_properties_t willprops = {23, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5f, 0x23}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7d, 0xc7, 0x21, 0xfe, 0xe0, 0x8, 0x9a, 0x32, 0xe8, 0xb8, 0xa3, 0xd5, 0x3f, 0xba}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 8375; + uint8_t client_id_bytes[] = {0x7b, 0x69, 0x45, 0xcf, 0x48, 0x1f, 0x6e, 0x10, 0xc1, 0x8, 0xf5, 0xd8, 0x4a, 0x4b}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x48, 0x4b, 0xa0, 0x41, 0xec, 0x21, 0xd7, 0xd9}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xac}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "s\249\NAK\192\197\&1\198#\180\SOH2\136\150\183B\199\209W@\DC3a\DLE\246\148\187\246\"", _password = Just +// "\224\236\147\252C\148\166\DEL\185\157\241m\242\132\SO\\q", _lastWill = Just (LastWill {_willRetain = True, _willQoS +// = QoS1, _willTopic = "\tqP", _willMsg = "o\SO.\159", _willProps = [PropMessageExpiryInterval +// 21061,PropAuthenticationData "\178\US",PropSessionExpiryInterval 26010,PropResponseInformation +// "\DC3\243?$s\DC1\135`\155.k\DC48\210\194F\244",PropSubscriptionIdentifierAvailable +// 219,PropSharedSubscriptionAvailable 247,PropTopicAlias 13806,PropWildcardSubscriptionAvailable 35,PropUserProperty +// "\157\239@x2\153?" +// "Q\167\227\&6\140Vgv\217\143\141\192D\225\201d\SI,o-\ESC\129[\182J\NAK;\146\222l",PropAuthenticationData +// "m7\245\161\140\163\139mF\188B\206\FS]\229\236u<\175 ",PropRetainAvailable 189,PropCorrelationData +// "\254y5AEL\136+\160\141\158\US\\\154\EOT}4;\207\156 \182\161M\216\172\160u\f\206",PropRequestResponseInformation +// 247,PropResponseTopic "\166\228s+W\165\ACK\243W\217s\a\189",PropWildcardSubscriptionAvailable 143,PropReceiveMaximum +// 11329,PropTopicAlias 5333,PropPayloadFormatIndicator 101,PropAssignedClientIdentifier +// "6\NAK\233\154",PropSessionExpiryInterval 5547,PropRetainAvailable 76,PropResponseTopic +// "\240\200uo\250\ESC\209\n\198\r\230\ETB\DC13\137\209\EMj?\227\179",PropResponseTopic +// "\215\153\GS\224\140\ACKr3Y\204.kT9\255\&0\150\134uQY\NUL\211\198\r\v\tzt\164",PropRetainAvailable +// 69,PropAuthenticationMethod "0\254\&7",PropAuthenticationData +// "]\202&\165\174\&4\184\&0\STX\DC4\151\GS\135\170\154\213\151&",PropContentType +// "\242\DC2\DLE\219\211\187\195\175\254n{K\ENQ\238\168\186\DEL\212IL\163Y\138"]}), _cleanSession = False, _keepAlive = +// 1422, _connID = "\184\233(\195\247\\\DC28i\FSj\135", _properties = [PropSessionExpiryInterval +// 19012,PropCorrelationData "}${\157\222to\135\t\DLE=]\213\219 \n\244LBsV",PropPayloadFormatIndicator +// 171,PropSubscriptionIdentifierAvailable 85,PropSharedSubscriptionAvailable 79,PropCorrelationData +// "sO{\173\150\226~\250\213\168\\;\216ST",PropAuthenticationMethod "K",PropWillDelayInterval +// 18157,PropAuthenticationData "\SYN\EM\141\150<\ETX\250\231\DEL",PropRequestResponseInformation +// 56,PropMaximumPacketSize 28986,PropSharedSubscriptionAvailable 227,PropMaximumPacketSize 9042,PropResponseInformation +// "\212\FS\STXB\210 (\182\251\a*\238*V~\199`\214\248\GS\198\170\FS\246\234)\253"]} +TEST(Connect5QCTest, Encode48) { + uint8_t pkt[] = { + 0x10, 0xf6, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x5, 0x8e, 0x76, 0x11, 0x0, 0x0, 0x4a, 0x44, + 0x9, 0x0, 0x15, 0x7d, 0x24, 0x7b, 0x9d, 0xde, 0x74, 0x6f, 0x87, 0x9, 0x10, 0x3d, 0x5d, 0xd5, 0xdb, 0x20, 0xa, + 0xf4, 0x4c, 0x42, 0x73, 0x56, 0x1, 0xab, 0x29, 0x55, 0x2a, 0x4f, 0x9, 0x0, 0xf, 0x73, 0x4f, 0x7b, 0xad, 0x96, + 0xe2, 0x7e, 0xfa, 0xd5, 0xa8, 0x5c, 0x3b, 0xd8, 0x53, 0x54, 0x15, 0x0, 0x1, 0x4b, 0x18, 0x0, 0x0, 0x46, 0xed, + 0x16, 0x0, 0x9, 0x16, 0x19, 0x8d, 0x96, 0x3c, 0x3, 0xfa, 0xe7, 0x7f, 0x19, 0x38, 0x27, 0x0, 0x0, 0x71, 0x3a, + 0x2a, 0xe3, 0x27, 0x0, 0x0, 0x23, 0x52, 0x1a, 0x0, 0x1b, 0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0x40, 0x13, 0x61, 0x10, 0xf6, 0x94, 0xbb, 0xf6, 0x22, 0x0, 0x11, 0xe0, 0xec, 0x93, 0xfc, 0x43, 0x94, + 0xa6, 0x7f, 0xb9, 0x9d, 0xf1, 0x6d, 0xf2, 0x84, 0xe, 0x5c, 0x71}; + + uint8_t buf[515] = {0}; + + uint8_t bytesprops0[] = {0x7d, 0x24, 0x7b, 0x9d, 0xde, 0x74, 0x6f, 0x87, 0x9, 0x10, 0x3d, + 0x5d, 0xd5, 0xdb, 0x20, 0xa, 0xf4, 0x4c, 0x42, 0x73, 0x56}; + uint8_t bytesprops1[] = {0x73, 0x4f, 0x7b, 0xad, 0x96, 0xe2, 0x7e, 0xfa, 0xd5, 0xa8, 0x5c, 0x3b, 0xd8, 0x53, 0x54}; + uint8_t bytesprops2[] = {0x4b}; + uint8_t bytesprops3[] = {0x16, 0x19, 0x8d, 0x96, 0x3c, 0x3, 0xfa, 0xe7, 0x7f}; + uint8_t bytesprops4[] = {0xd4, 0x1c, 0x2, 0x42, 0xd2, 0x20, 0x28, 0xb6, 0xfb, 0x7, 0x2a, 0xee, 0x2a, 0x56, + 0x7e, 0xc7, 0x60, 0xd6, 0xf8, 0x1d, 0xc6, 0xaa, 0x1c, 0xf6, 0xea, 0x29, 0xfd}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19012}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18157}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28986}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9042}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops4}}}, + }; + + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xb2, 0x1f}; + uint8_t byteswillprops1[] = {0x13, 0xf3, 0x3f, 0x24, 0x73, 0x11, 0x87, 0x60, 0x9b, + 0x2e, 0x6b, 0x14, 0x38, 0xd2, 0xc2, 0x46, 0xf4}; + uint8_t byteswillprops3[] = {0x51, 0xa7, 0xe3, 0x36, 0x8c, 0x56, 0x67, 0x76, 0xd9, 0x8f, + 0x8d, 0xc0, 0x44, 0xe1, 0xc9, 0x64, 0xf, 0x2c, 0x6f, 0x2d, + 0x1b, 0x81, 0x5b, 0xb6, 0x4a, 0x15, 0x3b, 0x92, 0xde, 0x6c}; + uint8_t byteswillprops2[] = {0x9d, 0xef, 0x40, 0x78, 0x32, 0x99, 0x3f}; + uint8_t byteswillprops4[] = {0x6d, 0x37, 0xf5, 0xa1, 0x8c, 0xa3, 0x8b, 0x6d, 0x46, 0xbc, + 0x42, 0xce, 0x1c, 0x5d, 0xe5, 0xec, 0x75, 0x3c, 0xaf, 0x20}; + uint8_t byteswillprops5[] = {0xfe, 0x79, 0x35, 0x41, 0x45, 0x4c, 0x88, 0x2b, 0xa0, 0x8d, + 0x9e, 0x1f, 0x5c, 0x9a, 0x4, 0x7d, 0x34, 0x3b, 0xcf, 0x9c, + 0x20, 0xb6, 0xa1, 0x4d, 0xd8, 0xac, 0xa0, 0x75, 0xc, 0xce}; + uint8_t byteswillprops6[] = {0xa6, 0xe4, 0x73, 0x2b, 0x57, 0xa5, 0x6, 0xf3, 0x57, 0xd9, 0x73, 0x7, 0xbd}; + uint8_t byteswillprops7[] = {0x36, 0x15, 0xe9, 0x9a}; + uint8_t byteswillprops8[] = {0xf0, 0xc8, 0x75, 0x6f, 0xfa, 0x1b, 0xd1, 0xa, 0xc6, 0xd, 0xe6, + 0x17, 0x11, 0x33, 0x89, 0xd1, 0x19, 0x6a, 0x3f, 0xe3, 0xb3}; + uint8_t byteswillprops9[] = {0xd7, 0x99, 0x1d, 0xe0, 0x8c, 0x6, 0x72, 0x33, 0x59, 0xcc, + 0x2e, 0x6b, 0x54, 0x39, 0xff, 0x30, 0x96, 0x86, 0x75, 0x51, + 0x59, 0x0, 0xd3, 0xc6, 0xd, 0xb, 0x9, 0x7a, 0x74, 0xa4}; + uint8_t byteswillprops10[] = {0x30, 0xfe, 0x37}; + uint8_t byteswillprops11[] = {0x5d, 0xca, 0x26, 0xa5, 0xae, 0x34, 0xb8, 0x30, 0x2, + 0x14, 0x97, 0x1d, 0x87, 0xaa, 0x9a, 0xd5, 0x97, 0x26}; + uint8_t byteswillprops12[] = {0xf2, 0x12, 0x10, 0xdb, 0xd3, 0xbb, 0xc3, 0xaf, 0xfe, 0x6e, 0x7b, 0x4b, + 0x5, 0xee, 0xa8, 0xba, 0x7f, 0xd4, 0x49, 0x4c, 0xa3, 0x59, 0x8a}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21061}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26010}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13806}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {7, (char*)&byteswillprops2}, .v = {30, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11329}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5333}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5547}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops12}}}, + }; + + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9, 0x71, 0x50}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6f, 0xe, 0x2e, 0x9f}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 1422; + uint8_t client_id_bytes[] = {0xb8, 0xe9, 0x28, 0xc3, 0xf7, 0x5c, 0x12, 0x38, 0x69, 0x1c, 0x6a, 0x87}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x73, 0xf9, 0x15, 0xc0, 0xc5, 0x31, 0xc6, 0x23, 0xb4, 0x1, 0x32, 0x88, 0x96, 0xb7, + 0x42, 0xc7, 0xd1, 0x57, 0x40, 0x13, 0x61, 0x10, 0xf6, 0x94, 0xbb, 0xf6, 0x22}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xe0, 0xec, 0x93, 0xfc, 0x43, 0x94, 0xa6, 0x7f, 0xb9, + 0x9d, 0xf1, 0x6d, 0xf2, 0x84, 0xe, 0x5c, 0x71}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\204\ESC-v\215\228\195+\251.F6\r\221\213nfx\221", _password = Just "\193\152", +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 20170, _connID = +// "9\b4\231\247\150H\ETB\GS\236t\185o\189\144\173\203P\207z\173", _properties = [PropCorrelationData +// "F\236\180\232z\241\217\234\140\167;!48\149a\223",PropAuthenticationMethod +// "\t\181U",PropSubscriptionIdentifierAvailable 40,PropRequestProblemInformation 170,PropAuthenticationData +// "\142\ACK\147",PropRetainAvailable 16,PropMaximumPacketSize 20456,PropResponseTopic "\183",PropReceiveMaximum +// 30861,PropUserProperty "U!\207\165\163?\140e\168=\245\200cQ\234\229\197\194\160\CAN\169" +// "\159_)h;\197\250G\189\223OS\EOT\153\160\209\200\153",PropMaximumPacketSize 27921,PropWillDelayInterval +// 24764,PropTopicAlias 621,PropMaximumPacketSize 8044,PropResponseTopic "",PropMaximumQoS 234,PropUserProperty +// "\231d\ESCy\SYN\254<@&\209\\\188j\236I\179\182m\154" +// "@\RS9cX\252\v\243\167?U9V\235o\248\224]\SO\194\237\228N\218\&6\ACK\DC2\US\224\207",PropUserProperty +// "R\163U\EOT\159\EM\b?\207?\ESC\222\DELl\249\DC1\172j" +// "\213\f\186V\199\t\240g\133\170\249\153\181\t`x<\254\153\198~\184\FS\200",PropAuthenticationMethod +// "",PropSubscriptionIdentifier 26,PropAuthenticationMethod "\191\226",PropWildcardSubscriptionAvailable +// 154,PropServerReference "",PropResponseTopic "(\139B\250\208T<\179\DC11*@\130\253\207",PropServerReference +// "+P\254\NUL6\161nD\240l*\144\208\237|\NAK.r\167\&1A\187\FS\210\240\DC4",PropWildcardSubscriptionAvailable +// 163,PropResponseInformation +// "\SUB^?\210\183\138\ESC\ACK\196:\175\181'\215(2\DC1\147\134~@\195\252\DC3xA.",PropServerReference ";\242\218"]} +TEST(Connect5QCTest, Encode50) { + uint8_t pkt[] = { + 0x10, 0x85, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x72, 0x34, 0x8c, 0x1, 0x3, 0x0, 0x6, 0xd6, + 0x98, 0xa9, 0x47, 0xdc, 0xf4, 0x1f, 0x0, 0x1c, 0x46, 0xf2, 0x47, 0xc3, 0x7a, 0x5d, 0xcb, 0xea, 0x6b, 0x9d, 0x2d, + 0x2e, 0x90, 0x60, 0x79, 0x1e, 0xcb, 0x1c, 0x23, 0xd5, 0x56, 0x73, 0x99, 0x6b, 0x3e, 0xb8, 0x1c, 0xc8, 0x15, 0x0, + 0x0, 0xb, 0x1a, 0x15, 0x0, 0x2, 0xbf, 0xe2, 0x28, 0x9a, 0x1c, 0x0, 0x0, 0x8, 0x0, 0xf, 0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xef, 0x0, 0x3, 0xd, 0x25, 0x94}; + + uint8_t buf[274] = {0}; + + uint8_t bytesprops0[] = {0xd6, 0x98, 0xa9, 0x47, 0xdc, 0xf4}; + uint8_t bytesprops1[] = {0x46, 0xf2, 0x47, 0xc3, 0x7a, 0x5d, 0xcb, 0xea, 0x6b, 0x9d, 0x2d, 0x2e, 0x90, 0x60, + 0x79, 0x1e, 0xcb, 0x1c, 0x23, 0xd5, 0x56, 0x73, 0x99, 0x6b, 0x3e, 0xb8, 0x1c, 0xc8}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0xbf, 0xe2}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0x28, 0x8b, 0x42, 0xfa, 0xd0, 0x54, 0x3c, 0xb3, 0x11, 0x31, 0x2a, 0x40, 0x82, 0xfd, 0xcf}; + uint8_t bytesprops6[] = {0x2b, 0x50, 0xfe, 0x0, 0x36, 0xa1, 0x6e, 0x44, 0xf0, 0x6c, 0x2a, 0x90, 0xd0, + 0xed, 0x7c, 0x15, 0x2e, 0x72, 0xa7, 0x31, 0x41, 0xbb, 0x1c, 0xd2, 0xf0, 0x14}; + uint8_t bytesprops7[] = {0x1a, 0x5e, 0x3f, 0xd2, 0xb7, 0x8a, 0x1b, 0x6, 0xc4, 0x3a, 0xaf, 0xb5, 0x27, 0xd7, + 0x28, 0x32, 0x11, 0x93, 0x86, 0x7e, 0x40, 0xc3, 0xfc, 0x13, 0x78, 0x41, 0x2e}; + uint8_t bytesprops8[] = {0x3b, 0xf2, 0xda}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops8}}}, + }; + + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xa1, 0xa1, 0x29, 0xc4, 0x21, 0x8a, 0xf8, 0xbc, 0x29, 0x31, 0x54, 0x3c, 0x5f, + 0xc8, 0x4, 0x70, 0xd2, 0x28, 0xb8, 0xcf, 0x7b, 0xa9, 0xe0, 0xa6, 0xed, 0x3c}; + uint8_t byteswillprops1[] = {0x6f, 0x48, 0xff, 0x68, 0x47, 0x82, 0xc0, 0xfc, 0xb, 0x96, 0x10, 0x26, + 0xca, 0x50, 0xcb, 0x98, 0x8e, 0x9e, 0x72, 0x6b, 0x49, 0xc7, 0x3b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23303}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13748}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21210}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31986}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25715}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23018}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + }; + + lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd, 0xe2, 0x5f, 0x63, 0x2c, 0xf8}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x97, 0xa8, 0x8d, 0xb7, 0x47, 0xc6}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 29236; + uint8_t client_id_bytes[] = {0xca, 0xdb}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x74, 0xef}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xd, 0x25, 0x94}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\144:3}\185E\246k\210Hp\221\197\245\&6\148\135m\216\143p\136\185\STX\ENQ\186\149?", +// _password = Just "\DC3\NAK\168)\SUB\234>\CAN\168\155\253RB\142?\137D\181y\170\&3O!+", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = +// "\227\205\234\251\"J\133\178\154\154[\STX\135\DC4[\a@\245[e\SUBR1\234\201\192'\vam", _willMsg = "\CAN\230\GS", +// _willProps = [PropSubscriptionIdentifierAvailable 23,PropSharedSubscriptionAvailable +// 192,PropSharedSubscriptionAvailable 231,PropSubscriptionIdentifier 17,PropTopicAliasMaximum +// 30146,PropMessageExpiryInterval 32008,PropRetainAvailable 255,PropServerKeepAlive 14818]}), _cleanSession = False, +// _keepAlive = 542, _connID = ")\ESC\193I>\"[\SO\187G\\\182\199yj\DC4o\204\229yV\"n+\138u\223", _properties = +// [PropWildcardSubscriptionAvailable 38,PropReasonString +// "\183\205\145\166@S!\178\&9\236\f",PropSharedSubscriptionAvailable 86]} +TEST(Connect5QCTest, Encode51) { + uint8_t pkt[] = {0x10, 0xad, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x2, 0x1e, 0x12, 0x28, 0x26, + 0x1f, 0x0, 0xb, 0xb7, 0xcd, 0x91, 0xa6, 0x40, 0x53, 0x21, 0xb2, 0x39, 0xec, 0xc, 0x2a, 0x56, + 0x0, 0x1b, 0x29, 0x1b, 0xc1, 0x49, 0x3e, 0x22, 0x5b, 0xe, 0xbb, 0x47, 0x5c, 0xb6, 0xc7, 0x79, + 0x6a, 0x14, 0x6f, 0xcc, 0xe5, 0x79, 0x56, 0x22, 0x6e, 0x2b, 0x8a, 0x75, 0xdf, 0x15, 0x29, 0x17, + 0x2a, 0xc0, 0x2a, 0xe7, 0xb, 0x11, 0x22, 0x75, 0xc2, 0x2, 0x0, 0x0, 0x7d, 0x8, 0x25, 0xff, + 0x13, 0x39, 0xe2, 0x0, 0x1e, 0xe3, 0xcd, 0xea, 0xfb, 0x22, 0x4a, 0x85, 0xb2, 0x9a, 0x9a, 0x5b, + 0x2, 0x87, 0x14, 0x5b, 0x7, 0x40, 0xf5, 0x5b, 0x65, 0x1a, 0x52, 0x31, 0xea, 0xc9, 0xc0, 0x27, + 0xb, 0x61, 0x6d, 0x0, 0x3, 0x18, 0xe6, 0x1d, 0x0, 0x1c, 0x90, 0x3a, 0x33, 0x7d, 0xb9, 0x45, + 0xf6, 0x6b, 0xd2, 0x48, 0x70, 0xdd, 0xc5, 0xf5, 0x36, 0x94, 0x87, 0x6d, 0xd8, 0x8f, 0x70, 0x88, + 0xb9, 0x2, 0x5, 0xba, 0x95, 0x3f, 0x0, 0x18, 0x13, 0x15, 0xa8, 0x29, 0x1a, 0xea, 0x3e, 0x18, + 0xa8, 0x9b, 0xfd, 0x52, 0x42, 0x8e, 0x3f, 0x89, 0x44, 0xb5, 0x79, 0xaa, 0x33, 0x4f, 0x21, 0x2b}; + + uint8_t buf[186] = {0}; + + uint8_t bytesprops0[] = {0xb7, 0xcd, 0x91, 0xa6, 0x40, 0x53, 0x21, 0xb2, 0x39, 0xec, 0xc}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 86}}, + }; + + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 23}}, {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 231}}, {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30146}}, {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32008}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 255}}, {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14818}}, + }; + + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe3, 0xcd, 0xea, 0xfb, 0x22, 0x4a, 0x85, 0xb2, 0x9a, 0x9a, + 0x5b, 0x2, 0x87, 0x14, 0x5b, 0x7, 0x40, 0xf5, 0x5b, 0x65, + 0x1a, 0x52, 0x31, 0xea, 0xc9, 0xc0, 0x27, 0xb, 0x61, 0x6d}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x18, 0xe6, 0x1d}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 542; + uint8_t client_id_bytes[] = {0x29, 0x1b, 0xc1, 0x49, 0x3e, 0x22, 0x5b, 0xe, 0xbb, 0x47, 0x5c, 0xb6, 0xc7, 0x79, + 0x6a, 0x14, 0x6f, 0xcc, 0xe5, 0x79, 0x56, 0x22, 0x6e, 0x2b, 0x8a, 0x75, 0xdf}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x90, 0x3a, 0x33, 0x7d, 0xb9, 0x45, 0xf6, 0x6b, 0xd2, 0x48, 0x70, 0xdd, 0xc5, 0xf5, + 0x36, 0x94, 0x87, 0x6d, 0xd8, 0x8f, 0x70, 0x88, 0xb9, 0x2, 0x5, 0xba, 0x95, 0x3f}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x13, 0x15, 0xa8, 0x29, 0x1a, 0xea, 0x3e, 0x18, 0xa8, 0x9b, 0xfd, 0x52, + 0x42, 0x8e, 0x3f, 0x89, 0x44, 0xb5, 0x79, 0xaa, 0x33, 0x4f, 0x21, 0x2b}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "LW\149,C?\222\163x\147\176\166e\163!\187}@2\213\n", _password = Just +// "\166\&1Vn<\147O\v\178i\245g:\SUB", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "\243\244O\221\ETX\229\192\137;\183\197D/\221!m\211\162", _willMsg = +// "\239M(\237\209\235\215\"\SI\220v\217\205\n\228\156\205s\250\244\167K\185\SI-\ETB\SOq\r", _willProps = +// [PropPayloadFormatIndicator 179,PropUserProperty +// "R\245\138t\142U\US\129U\179R\254\254\191\139E\171\189\157\219\144\185]Po]" "z",PropAssignedClientIdentifier +// "\182u\130\176\&6",PropAuthenticationMethod "&\154\EMEW\186",PropResponseInformation +// "\132\189q0\142\247\196G\196\198\&70\NUL\ETX$f\139\DLE\CANw\144\r$\155",PropPayloadFormatIndicator +// 19,PropRequestProblemInformation 215,PropMaximumQoS 170,PropRequestProblemInformation 100,PropAuthenticationData +// "\160",PropAssignedClientIdentifier "R\137\217\168",PropRequestResponseInformation 99,PropServerReference +// "h\147\144\EMT\f\190\170\224\157\167\205\223\174S\215\DC3\222\b\ENQ\DLE\208\202\248\141i\SOH",PropAssignedClientIdentifier +// "\140",PropResponseTopic "\168\251\179\150\162\aO)?\160U\135\202$\147\188\182",PropResponseTopic +// "\SOH\232T\188\r]jZ^\235e\224\SUB\135GdI=\166",PropSubscriptionIdentifier 17,PropRetainAvailable +// 103,PropAuthenticationMethod "\143\211\213\153\230\242",PropRequestProblemInformation +// 23,PropWildcardSubscriptionAvailable 104]}), _cleanSession = False, _keepAlive = 32428, _connID = +// "\SYN\217\207Z5\137\241\224\174\144\248\192*\233\218Z\230\DEL\198I9", _properties = [PropSubscriptionIdentifier +// 13,PropMaximumQoS 96,PropTopicAlias 32544,PropAuthenticationMethod ")6U",PropTopicAliasMaximum +// 26085,PropServerKeepAlive 12645,PropResponseInformation "\165\229\230B\r.ib\141\&6E\240n\EM\157 +// \208\160\201\221\131\231'\244\SINb\159+Q",PropPayloadFormatIndicator 147,PropRetainAvailable 90,PropRetainAvailable +// 197,PropTopicAliasMaximum 5288,PropMaximumQoS 8,PropResponseTopic +// "\204\228\FS\199\&4\160v\173\186\131\147\DC2`^\217\162\&4\244U\243<\SUB\208",PropReasonString "'\143\157YG"]} +TEST(Connect5QCTest, Encode52) { + uint8_t pkt[] = { + 0x10, 0x9f, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x7e, 0xac, 0x61, 0xb, 0xd, 0x24, 0x60, 0x23, + 0x7f, 0x20, 0x15, 0x0, 0x3, 0x29, 0x36, 0x55, 0x22, 0x65, 0xe5, 0x13, 0x31, 0x65, 0x1a, 0x0, 0x1e, 0xa5, 0xe5, + 0xe6, 0x42, 0xd, 0x2e, 0x69, 0x62, 0x8d, 0x36, 0x45, 0xf0, 0x6e, 0x19, 0x9d, 0x20, 0xd0, 0xa0, 0xc9, 0xdd, 0x83, + 0xe7, 0x27, 0xf4, 0xf, 0x4e, 0x62, 0x9f, 0x2b, 0x51, 0x1, 0x93, 0x25, 0x5a, 0x25, 0xc5, 0x22, 0x14, 0xa8, 0x24, + 0x8, 0x8, 0x0, 0x17, 0xcc, 0xe4, 0x1c, 0xc7, 0x34, 0xa0, 0x76, 0xad, 0xba, 0x83, 0x93, 0x12, 0x60, 0x5e, 0xd9, + 0xa2, 0x34, 0xf4, 0x55, 0xf3, 0x3c, 0x1a, 0xd0, 0x1f, 0x0, 0x5, 0x27, 0x8f, 0x9d, 0x59, 0x47, 0x0, 0x15, 0x16, + 0xd9, 0xcf, 0x5a, 0x35, 0x89, 0xf1, 0xe0, 0xae, 0x90, 0xf8, 0xc0, 0x2a, 0xe9, 0xda, 0x5a, 0xe6, 0x7f, 0xc6, 0x49, + 0x39, 0xc0, 0x1, 0x1, 0xb3, 0x26, 0x0, 0x1a, 0x52, 0xf5, 0x8a, 0x74, 0x8e, 0x55, 0x1f, 0x81, 0x55, 0xb3, 0x52, + 0xfe, 0xfe, 0xbf, 0x8b, 0x45, 0xab, 0xbd, 0x9d, 0xdb, 0x90, 0xb9, 0x5d, 0x50, 0x6f, 0x5d, 0x0, 0x1, 0x7a, 0x12, + 0x0, 0x5, 0xb6, 0x75, 0x82, 0xb0, 0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, 0x9c, 0xcd, 0x73, 0xfa, 0xf4, 0xa7, 0x4b, 0xb9, 0xf, 0x2d, 0x17, 0xe, 0x71, 0xd, 0x0, + 0x15, 0x4c, 0x57, 0x95, 0x2c, 0x43, 0x3f, 0xde, 0xa3, 0x78, 0x93, 0xb0, 0xa6, 0x65, 0xa3, 0x21, 0xbb, 0x7d, 0x40, + 0x32, 0xd5, 0xa, 0x0, 0xe, 0xa6, 0x31, 0x56, 0x6e, 0x3c, 0x93, 0x4f, 0xb, 0xb2, 0x69, 0xf5, 0x67, 0x3a, 0x1a}; + + uint8_t buf[428] = {0}; + + uint8_t bytesprops0[] = {0x29, 0x36, 0x55}; + uint8_t bytesprops1[] = {0xa5, 0xe5, 0xe6, 0x42, 0xd, 0x2e, 0x69, 0x62, 0x8d, 0x36, 0x45, 0xf0, 0x6e, 0x19, 0x9d, + 0x20, 0xd0, 0xa0, 0xc9, 0xdd, 0x83, 0xe7, 0x27, 0xf4, 0xf, 0x4e, 0x62, 0x9f, 0x2b, 0x51}; + uint8_t bytesprops2[] = {0xcc, 0xe4, 0x1c, 0xc7, 0x34, 0xa0, 0x76, 0xad, 0xba, 0x83, 0x93, 0x12, + 0x60, 0x5e, 0xd9, 0xa2, 0x34, 0xf4, 0x55, 0xf3, 0x3c, 0x1a, 0xd0}; + uint8_t bytesprops3[] = {0x27, 0x8f, 0x9d, 0x59, 0x47}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32544}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26085}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12645}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5288}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops3}}}, + }; + + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x7a}; + uint8_t byteswillprops0[] = {0x52, 0xf5, 0x8a, 0x74, 0x8e, 0x55, 0x1f, 0x81, 0x55, 0xb3, 0x52, 0xfe, 0xfe, + 0xbf, 0x8b, 0x45, 0xab, 0xbd, 0x9d, 0xdb, 0x90, 0xb9, 0x5d, 0x50, 0x6f, 0x5d}; + uint8_t byteswillprops2[] = {0xb6, 0x75, 0x82, 0xb0, 0x36}; + uint8_t byteswillprops3[] = {0x26, 0x9a, 0x19, 0x45, 0x57, 0xba}; + uint8_t byteswillprops4[] = {0x84, 0xbd, 0x71, 0x30, 0x8e, 0xf7, 0xc4, 0x47, 0xc4, 0xc6, 0x37, 0x30, + 0x0, 0x3, 0x24, 0x66, 0x8b, 0x10, 0x18, 0x77, 0x90, 0xd, 0x24, 0x9b}; + uint8_t byteswillprops5[] = {0xa0}; + uint8_t byteswillprops6[] = {0x52, 0x89, 0xd9, 0xa8}; + uint8_t byteswillprops7[] = {0x68, 0x93, 0x90, 0x19, 0x54, 0xc, 0xbe, 0xaa, 0xe0, 0x9d, 0xa7, 0xcd, 0xdf, 0xae, + 0x53, 0xd7, 0x13, 0xde, 0x8, 0x5, 0x10, 0xd0, 0xca, 0xf8, 0x8d, 0x69, 0x1}; + uint8_t byteswillprops8[] = {0x8c}; + uint8_t byteswillprops9[] = {0xa8, 0xfb, 0xb3, 0x96, 0xa2, 0x7, 0x4f, 0x29, 0x3f, + 0xa0, 0x55, 0x87, 0xca, 0x24, 0x93, 0xbc, 0xb6}; + uint8_t byteswillprops10[] = {0x1, 0xe8, 0x54, 0xbc, 0xd, 0x5d, 0x6a, 0x5a, 0x5e, 0xeb, + 0x65, 0xe0, 0x1a, 0x87, 0x47, 0x64, 0x49, 0x3d, 0xa6}; + uint8_t byteswillprops11[] = {0x8f, 0xd3, 0xd5, 0x99, 0xe6, 0xf2}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {26, (char*)&byteswillprops0}, .v = {1, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 104}}, + }; + + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf3, 0xf4, 0x4f, 0xdd, 0x3, 0xe5, 0xc0, 0x89, 0x3b, + 0xb7, 0xc5, 0x44, 0x2f, 0xdd, 0x21, 0x6d, 0xd3, 0xa2}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xef, 0x4d, 0x28, 0xed, 0xd1, 0xeb, 0xd7, 0x22, 0xf, 0xdc, + 0x76, 0xd9, 0xcd, 0xa, 0xe4, 0x9c, 0xcd, 0x73, 0xfa, 0xf4, + 0xa7, 0x4b, 0xb9, 0xf, 0x2d, 0x17, 0xe, 0x71, 0xd}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32428; + uint8_t client_id_bytes[] = {0x16, 0xd9, 0xcf, 0x5a, 0x35, 0x89, 0xf1, 0xe0, 0xae, 0x90, 0xf8, + 0xc0, 0x2a, 0xe9, 0xda, 0x5a, 0xe6, 0x7f, 0xc6, 0x49, 0x39}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x4c, 0x57, 0x95, 0x2c, 0x43, 0x3f, 0xde, 0xa3, 0x78, 0x93, 0xb0, + 0xa6, 0x65, 0xa3, 0x21, 0xbb, 0x7d, 0x40, 0x32, 0xd5, 0xa}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xa6, 0x31, 0x56, 0x6e, 0x3c, 0x93, 0x4f, 0xb, 0xb2, 0x69, 0xf5, 0x67, 0x3a, 0x1a}; + lwmqtt_string_t password = {14, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\230\206\252H\237\141\SIb\136w \172Y\159\155sC\141\159\"s\246{\DEL\254\208~\130", +// _password = Just "o\191Q<34\244\255\186\STXo\235,\210\v\SYN_\234\"x\219X\242\159.D\231", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\204\DC4\226:25\172", _willMsg = "\NAK\232\175\221\193,", +// _willProps = [PropWildcardSubscriptionAvailable 151,PropRetainAvailable 219,PropReasonString +// ":\226\&5#\STX\167\SO%\181\176\210sv\135\SO\129Kq5\224\131\205\ACK8L*\129\205\224P",PropTopicAlias +// 23946,PropServerReference "\166\135\216=",PropRequestProblemInformation 50,PropRequestProblemInformation +// 106,PropMessageExpiryInterval 29679,PropSubscriptionIdentifierAvailable 10,PropContentType +// "\182\218\232\231m\SOH\240\198\227\252\f\231\132ED",PropAssignedClientIdentifier "\DC3~\157\240\238"]}), +// _cleanSession = False, _keepAlive = 4766, _connID = "p\205\137>X(\171\175\246\NAKr\254\223H\232\252\254\236\198<", +// _properties = [PropMaximumPacketSize 32218,PropMaximumQoS 136,PropAssignedClientIdentifier +// "\250\131@\212H6\158\179\249\165",PropResponseInformation +// "\201\180t\DC1gN\208\176\200x\252\173\201\234\US\154\t\202\188u\SI",PropReasonString +// "w\168\188\221\159\EOT[\SYN\219\222\239\229({@3\171\200\CAN\147\197\"{\195C\148B\211'",PropWillDelayInterval +// 23335,PropPayloadFormatIndicator 34,PropWildcardSubscriptionAvailable 162,PropRetainAvailable 117,PropResponseTopic +// "\248s\223\159\170\220G\247\166",PropMessageExpiryInterval 19508,PropReceiveMaximum 26213,PropResponseTopic +// "\177H\134\133",PropSharedSubscriptionAvailable 185,PropResponseInformation +// "\DC3\245\235s\US\246\226\205G\159nd\220\248g-\195c\222\185\163\178g",PropTopicAlias +// 12131,PropWildcardSubscriptionAvailable 179,PropAuthenticationData +// "8\230\178jp\243\153\227\235\154\&4-2\214#\145X\153\185\175\199\"\166s\DC2\207@",PropCorrelationData +// "\SUBg>\\\vz\206\247\fL\189\176\202\129\EOT\211\&7\134\r",PropResponseTopic +// "8\169\DEL\205\233\153\131\192\191\132\230\165\252l\DC1\157",PropAssignedClientIdentifier +// "\201YwF$%\137\NUL\230\ENQUM\219\220s",PropSubscriptionIdentifier 27,PropSharedSubscriptionAvailable +// 87,PropUserProperty +// "\169\149\215\197\129~\186\194\237&\DC3\180\130\179\248\233\215`\194\173\167\164\157\148\209\f\155s\ETB" +// "\202\"\255\210\225",PropAuthenticationMethod "\205\191i:\180",PropUserProperty +// "\136\129\247>\NULS\230\&8^\171r\237\213mk" "\226\178",PropSubscriptionIdentifier 3,PropTopicAliasMaximum +// 2449,PropRequestResponseInformation 14]}), _cleanSession = False, _keepAlive = 6302, _connID = +// "5\175\175\181'H\173\161[\157\&8\175BY\182|\179", _properties = [PropServerReference +// "YP\224~\225A!",PropServerKeepAlive 2913,PropWillDelayInterval 20651]} +TEST(Connect5QCTest, Encode54) { + uint8_t pkt[] = { + 0x10, 0xe0, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x34, 0x18, 0x9e, 0x12, 0x1c, 0x0, 0x7, 0x59, 0x50, + 0xe0, 0x7e, 0xe1, 0x41, 0x21, 0x13, 0xb, 0x61, 0x18, 0x0, 0x0, 0x50, 0xab, 0x0, 0x11, 0x35, 0xaf, 0xaf, 0xb5, + 0x27, 0x48, 0xad, 0xa1, 0x5b, 0x9d, 0x38, 0xaf, 0x42, 0x59, 0xb6, 0x7c, 0xb3, 0x8e, 0x2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x4d, 0xdb, 0xdc, 0x73, 0xb, 0x1b, 0x2a, 0x57, + 0x26, 0x0, 0x1d, 0xa9, 0x95, 0xd7, 0xc5, 0x81, 0x7e, 0xba, 0xc2, 0xed, 0x26, 0x13, 0xb4, 0x82, 0xb3, 0xf8, 0xe9, + 0xd7, 0x60, 0xc2, 0xad, 0xa7, 0xa4, 0x9d, 0x94, 0xd1, 0xc, 0x9b, 0x73, 0x17, 0x0, 0x5, 0xca, 0x22, 0xff, 0xd2, + 0xe1, 0x15, 0x0, 0x5, 0xcd, 0xbf, 0x69, 0x3a, 0xb4, 0x26, 0x0, 0xf, 0x88, 0x81, 0xf7, 0x3e, 0x0, 0x53, 0xe6, + 0x38, 0x5e, 0xab, 0x72, 0xed, 0xd5, 0x6d, 0x6b, 0x0, 0x2, 0xe2, 0xb2, 0xb, 0x3, 0x22, 0x9, 0x91, 0x19, 0xe, + 0x0, 0x1, 0xa, 0x0, 0x1b, 0x77, 0x39, 0xd9, 0x79, 0x4d, 0xba, 0xa1, 0xa6, 0x67, 0x88, 0x8c, 0x9a, 0xb2, 0x16, + 0x35, 0x96, 0xe4, 0xd4, 0x1c, 0x48, 0x50, 0xeb, 0xca, 0xe0, 0xf2, 0x44, 0x3b}; + + uint8_t buf[365] = {0}; + + uint8_t bytesprops0[] = {0x59, 0x50, 0xe0, 0x7e, 0xe1, 0x41, 0x21}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2913}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20651}}, + }; + + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x65, 0xb0, 0x46, 0xb3, 0x27, 0x73, 0x35}; + uint8_t byteswillprops1[] = {0xb3, 0xa5, 0x64, 0xd9, 0x9d, 0x3a, 0xce, 0x2c, 0xe6, 0xa, 0xd4, 0x57, + 0xb2, 0xae, 0x64, 0x9f, 0x38, 0x49, 0xe0, 0x97, 0x66, 0xc1, 0x93, 0xdc}; + uint8_t byteswillprops2[] = {0x75, 0xf0, 0x3f, 0x3e, 0xf7, 0xa6}; + uint8_t byteswillprops3[] = {0xb1, 0x48, 0x86, 0x85}; + uint8_t byteswillprops4[] = {0x13, 0xf5, 0xeb, 0x73, 0x1f, 0xf6, 0xe2, 0xcd, 0x47, 0x9f, 0x6e, 0x64, + 0xdc, 0xf8, 0x67, 0x2d, 0xc3, 0x63, 0xde, 0xb9, 0xa3, 0xb2, 0x67}; + uint8_t byteswillprops5[] = {0x38, 0xe6, 0xb2, 0x6a, 0x70, 0xf3, 0x99, 0xe3, 0xeb, 0x9a, 0x34, 0x2d, 0x32, 0xd6, + 0x23, 0x91, 0x58, 0x99, 0xb9, 0xaf, 0xc7, 0x22, 0xa6, 0x73, 0x12, 0xcf, 0x40}; + uint8_t byteswillprops6[] = {0x1a, 0x67, 0x3e, 0x5c, 0xb, 0x7a, 0xce, 0xf7, 0xc, 0x4c, + 0xbd, 0xb0, 0xca, 0x81, 0x4, 0xd3, 0x37, 0x86, 0xd}; + uint8_t byteswillprops7[] = {0x38, 0xa9, 0x7f, 0xcd, 0xe9, 0x99, 0x83, 0xc0, + 0xbf, 0x84, 0xe6, 0xa5, 0xfc, 0x6c, 0x11, 0x9d}; + uint8_t byteswillprops8[] = {0xc9, 0x59, 0x77, 0x46, 0x24, 0x25, 0x89, 0x0, 0xe6, 0x5, 0x55, 0x4d, 0xdb, 0xdc, 0x73}; + uint8_t byteswillprops10[] = {0xca, 0x22, 0xff, 0xd2, 0xe1}; + uint8_t byteswillprops9[] = {0xa9, 0x95, 0xd7, 0xc5, 0x81, 0x7e, 0xba, 0xc2, 0xed, 0x26, 0x13, 0xb4, 0x82, 0xb3, 0xf8, + 0xe9, 0xd7, 0x60, 0xc2, 0xad, 0xa7, 0xa4, 0x9d, 0x94, 0xd1, 0xc, 0x9b, 0x73, 0x17}; + uint8_t byteswillprops11[] = {0xcd, 0xbf, 0x69, 0x3a, 0xb4}; + uint8_t byteswillprops13[] = {0xe2, 0xb2}; + uint8_t byteswillprops12[] = {0x88, 0x81, 0xf7, 0x3e, 0x0, 0x53, 0xe6, 0x38, + 0x5e, 0xab, 0x72, 0xed, 0xd5, 0x6d, 0x6b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12776}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19508}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26213}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12131}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {29, (char*)&byteswillprops9}, .v = {5, (char*)&byteswillprops10}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {15, (char*)&byteswillprops12}, .v = {2, (char*)&byteswillprops13}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2449}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 14}}, + }; + + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x77, 0x39, 0xd9, 0x79, 0x4d, 0xba, 0xa1, 0xa6, 0x67, 0x88, 0x8c, 0x9a, 0xb2, 0x16, + 0x35, 0x96, 0xe4, 0xd4, 0x1c, 0x48, 0x50, 0xeb, 0xca, 0xe0, 0xf2, 0x44, 0x3b}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 6302; + uint8_t client_id_bytes[] = {0x35, 0xaf, 0xaf, 0xb5, 0x27, 0x48, 0xad, 0xa1, 0x5b, + 0x9d, 0x38, 0xaf, 0x42, 0x59, 0xb6, 0x7c, 0xb3}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x3c, 0xa, 0x95, 0x52, 0x30, 0x5c, 0xd8, 0x4b, 0x15, + 0x9d, 0xef, 0xbb, 0x62, 0xf3, 0xac, 0x15, 0x55}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "7x\204\136o\US\ESC\232\vI\211", _password = Just "m", _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 16891, _connID = "\152\237\162\129\182]", _properties = [PropSessionExpiryInterval +// 9597,PropTopicAliasMaximum 2865,PropWildcardSubscriptionAvailable 99,PropRequestProblemInformation +// 104,PropAuthenticationMethod +// "\STX\212\ESCFo\170a\162\220\143\177\131\218\144\ENQ\239R\RS\215\138\DLEJ\200B\237\166\168",PropAuthenticationMethod +// "\160\209\173T\ETX\140\184\247\137\213\DLEp9'y2\147",PropWildcardSubscriptionAvailable 84,PropSubscriptionIdentifier +// 28,PropRequestProblemInformation 6,PropTopicAliasMaximum 3045,PropResponseTopic "",PropCorrelationData +// "\250\196O\247\DC1\176\253\150\238\214\216\212f\161Xl\t", _willProps = [PropSubscriptionIdentifier 20]}), +// _cleanSession = True, _keepAlive = 1871, _connID = "s\ETXN", _properties = [PropResponseInformation +// "\252\192\196\"\230/",PropWillDelayInterval 16667,PropReceiveMaximum 30002,PropSubscriptionIdentifier +// 18,PropMessageExpiryInterval 21381,PropWillDelayInterval 24570,PropAuthenticationData +// "\189\175R\137\130\r\203\SUB\r\EOT",PropTopicAliasMaximum 26398,PropMaximumPacketSize 25296,PropTopicAliasMaximum +// 22383,PropAssignedClientIdentifier "\236\161TO>\"\144\233|",PropResponseInformation +// "\194\199-i\151\v\220\GS\234l\189\176\155\148\240*\"\237j\165+\212\rU",PropRequestResponseInformation +// 128,PropCorrelationData "\227k>\160\SOy\157\251\243;0\199\242\237]\155\ETX2\"x\140\173\149\152",PropWillDelayInterval +// 11756,PropMaximumPacketSize 6416,PropUserProperty "" "8\t\180",PropResponseTopic "\135",PropTopicAlias +// 8174,PropPayloadFormatIndicator 236,PropWildcardSubscriptionAvailable 243,PropTopicAlias 26948,PropTopicAliasMaximum +// 23415,PropSubscriptionIdentifier 6,PropSubscriptionIdentifierAvailable 137,PropServerReference +// "\209\DC1\233\230O",PropTopicAlias 13735]} +TEST(Connect5QCTest, Encode62) { + uint8_t pkt[] = { + 0x10, 0x99, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x7, 0x4f, 0xab, 0x1, 0x1a, 0x0, 0x6, 0xfc, + 0xc0, 0xc4, 0x22, 0xe6, 0x2f, 0x18, 0x0, 0x0, 0x41, 0x1b, 0x21, 0x75, 0x32, 0xb, 0x12, 0x2, 0x0, 0x0, 0x53, + 0x85, 0x18, 0x0, 0x0, 0x5f, 0xfa, 0x16, 0x0, 0xa, 0xbd, 0xaf, 0x52, 0x89, 0x82, 0xd, 0xcb, 0x1a, 0xd, 0x4, + 0x22, 0x67, 0x1e, 0x27, 0x0, 0x0, 0x62, 0xd0, 0x22, 0x57, 0x6f, 0x12, 0x0, 0x9, 0xec, 0xa1, 0x54, 0x4f, 0x3e, + 0x22, 0x90, 0xe9, 0x7c, 0x1a, 0x0, 0x18, 0xc2, 0xc7, 0x2d, 0x69, 0x97, 0xb, 0xdc, 0x1d, 0xea, 0x6c, 0xbd, 0xb0, + 0x9b, 0x94, 0xf0, 0x2a, 0x22, 0xed, 0x6a, 0xa5, 0x2b, 0xd4, 0xd, 0x55, 0x19, 0x80, 0x9, 0x0, 0x18, 0xe3, 0x6b, + 0x3e, 0xa0, 0xe, 0x79, 0x9d, 0xfb, 0xf3, 0x3b, 0x30, 0xc7, 0xf2, 0xed, 0x5d, 0x9b, 0x3, 0x32, 0x22, 0x78, 0x8c, + 0xad, 0x95, 0x98, 0x18, 0x0, 0x0, 0x2d, 0xec, 0x27, 0x0, 0x0, 0x19, 0x10, 0x26, 0x0, 0x0, 0x0, 0x3, 0x38, + 0x9, 0xb4, 0x8, 0x0, 0x1, 0x87, 0x23, 0x1f, 0xee, 0x1, 0xec, 0x28, 0xf3, 0x23, 0x69, 0x44, 0x22, 0x5b, 0x77, + 0xb, 0x6, 0x29, 0x89, 0x1c, 0x0, 0x5, 0xd1, 0x11, 0xe9, 0xe6, 0x4f, 0x23, 0x35, 0xa7, 0x0, 0x3, 0x73, 0x3, + 0x4e, 0x2, 0xb, 0x14, 0x0, 0x1d, 0xd1, 0xc2, 0x25, 0xfb, 0x52, 0x3, 0x25, 0x33, 0x18, 0x88, 0xae, 0xa7, 0xa9, + 0x8b, 0xa7, 0xba, 0x43, 0x29, 0xb8, 0x2a, 0x6e, 0x9a, 0x17, 0x6d, 0x47, 0xd1, 0x54, 0xba, 0x11, 0x0, 0x17, 0x23, + 0x79, 0x70, 0x28, 0x23, 0x21, 0x3e, 0xc4, 0x4f, 0xf7, 0x11, 0xb0, 0xfd, 0x96, 0xee, 0xd6, 0xd8, 0xd4, 0x66, 0xa1, + 0x58, 0x6c, 0x9, 0x0, 0xf, 0x8e, 0xa8, 0x12, 0x5a, 0x7, 0xe5, 0xff, 0xfa, 0xc0, 0xb1, 0x36, 0xac, 0xf0, 0x44, + 0x32, 0x0, 0xf, 0xd, 0x89, 0x17, 0x74, 0x52, 0x82, 0x43, 0x2a, 0x11, 0xdf, 0xca, 0xa9, 0x93, 0xc5, 0xe8}; + + uint8_t buf[294] = {0}; + + uint8_t bytesprops0[] = {0xfc, 0xc0, 0xc4, 0x22, 0xe6, 0x2f}; + uint8_t bytesprops1[] = {0xbd, 0xaf, 0x52, 0x89, 0x82, 0xd, 0xcb, 0x1a, 0xd, 0x4}; + uint8_t bytesprops2[] = {0xec, 0xa1, 0x54, 0x4f, 0x3e, 0x22, 0x90, 0xe9, 0x7c}; + uint8_t bytesprops3[] = {0xc2, 0xc7, 0x2d, 0x69, 0x97, 0xb, 0xdc, 0x1d, 0xea, 0x6c, 0xbd, 0xb0, + 0x9b, 0x94, 0xf0, 0x2a, 0x22, 0xed, 0x6a, 0xa5, 0x2b, 0xd4, 0xd, 0x55}; + uint8_t bytesprops4[] = {0xe3, 0x6b, 0x3e, 0xa0, 0xe, 0x79, 0x9d, 0xfb, 0xf3, 0x3b, 0x30, 0xc7, + 0xf2, 0xed, 0x5d, 0x9b, 0x3, 0x32, 0x22, 0x78, 0x8c, 0xad, 0x95, 0x98}; + uint8_t bytesprops6[] = {0x38, 0x9, 0xb4}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops7[] = {0x87}; + uint8_t bytesprops8[] = {0xd1, 0x11, 0xe9, 0xe6, 0x4f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16667}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30002}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21381}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24570}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26398}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25296}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22383}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11756}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6416}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops5}, .v = {3, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8174}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26948}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23415}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13735}}, + }; + + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + }; + + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd1, 0xc2, 0x25, 0xfb, 0x52, 0x3, 0x25, 0x33, 0x18, 0x88, + 0xae, 0xa7, 0xa9, 0x8b, 0xa7, 0xba, 0x43, 0x29, 0xb8, 0x2a, + 0x6e, 0x9a, 0x17, 0x6d, 0x47, 0xd1, 0x54, 0xba, 0x11}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x23, 0x79, 0x70, 0x28, 0x23, 0x21, 0x3e, 0xc4, 0x4f, 0xf7, 0x11, 0xb0, + 0xfd, 0x96, 0xee, 0xd6, 0xd8, 0xd4, 0x66, 0xa1, 0x58, 0x6c, 0x9}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1871; + uint8_t client_id_bytes[] = {0x73, 0x3, 0x4e}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x8e, 0xa8, 0x12, 0x5a, 0x7, 0xe5, 0xff, 0xfa, 0xc0, 0xb1, 0x36, 0xac, 0xf0, 0x44, 0x32}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xd, 0x89, 0x17, 0x74, 0x52, 0x82, 0x43, 0x2a, 0x11, 0xdf, 0xca, 0xa9, 0x93, 0xc5, 0xe8}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "^t\USER\139\244\152'\220\244", _willMsg = +// "\199\STX\191\&2ISE$\SOH}\221O\DC3,P\242\185\245\181\192\\\237\251p\237\247\198\203", _willProps = [PropUserProperty +// "qR" "\217)\202\185n\ESC\224\146p\176\128C\202E\EOT\135",PropAuthenticationData +// "\200\250\191\184\228\224\234\149\NULCz,\175\251\SOH}G\187",PropMaximumPacketSize 30947]}), _cleanSession = False, +// _keepAlive = 13191, _connID = "\152G\DC3\220\161\183\214\153L\231", _properties = [PropWildcardSubscriptionAvailable +// 209,PropMaximumPacketSize 10805,PropMaximumQoS 99,PropAssignedClientIdentifier +// "\EOT\221\142]!)\188\DEL\191\178\218",PropResponseInformation +// "\134j.\213,\200\203\248\133q\249E{\191\240,\146N\166",PropAuthenticationMethod +// "\156\ETX",PropAssignedClientIdentifier "\175\214",PropTopicAliasMaximum 1901,PropCorrelationData +// "\150D\SI\160\&8\ENQ"]} +TEST(Connect5QCTest, Encode63) { + uint8_t pkt[] = {0x10, 0xb7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc, 0x33, 0x87, 0x43, 0x28, 0xd1, 0x27, + 0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; + uint8_t bytesprops1[] = {0x86, 0x6a, 0x2e, 0xd5, 0x2c, 0xc8, 0xcb, 0xf8, 0x85, 0x71, + 0xf9, 0x45, 0x7b, 0xbf, 0xf0, 0x2c, 0x92, 0x4e, 0xa6}; + uint8_t bytesprops2[] = {0x9c, 0x3}; + uint8_t bytesprops3[] = {0xaf, 0xd6}; + uint8_t bytesprops4[] = {0x96, 0x44, 0xf, 0xa0, 0x38, 0x5}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10805}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1901}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops4}}}, + }; + + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xd9, 0x29, 0xca, 0xb9, 0x6e, 0x1b, 0xe0, 0x92, + 0x70, 0xb0, 0x80, 0x43, 0xca, 0x45, 0x4, 0x87}; + uint8_t byteswillprops0[] = {0x71, 0x52}; + uint8_t byteswillprops2[] = {0xc8, 0xfa, 0xbf, 0xb8, 0xe4, 0xe0, 0xea, 0x95, 0x0, + 0x43, 0x7a, 0x2c, 0xaf, 0xfb, 0x1, 0x7d, 0x47, 0xbb}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {2, (char*)&byteswillprops0}, .v = {16, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30947}}, + }; + + lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5e, 0x74, 0x1f, 0x45, 0x52, 0x8b, 0xf4, 0x98, 0x27, 0xdc, 0xf4}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc7, 0x2, 0xbf, 0x32, 0x49, 0x53, 0x45, 0x24, 0x1, 0x7d, 0xdd, 0x4f, 0x13, 0x2c, + 0x50, 0xf2, 0xb9, 0xf5, 0xb5, 0xc0, 0x5c, 0xed, 0xfb, 0x70, 0xed, 0xf7, 0xc6, 0xcb}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 13191; + uint8_t client_id_bytes[] = {0x98, 0x47, 0x13, 0xdc, 0xa1, 0xb7, 0xd6, 0x99, 0x4c, 0xe7}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "4\159\162&\FS(\185Vz\159#", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\178\222\199o\DLE`0%\253\145qK;\128\218", _willMsg = +// "\130\&9Pt\tC\201\176\147", _willProps = [PropRetainAvailable 148,PropServerKeepAlive +// 2497,PropWildcardSubscriptionAvailable 254,PropRetainAvailable 116,PropMaximumQoS 37,PropAuthenticationMethod +// "\137{\FS\CAN",PropTopicAlias 3471,PropTopicAliasMaximum 29487,PropCorrelationData +// "\ESC\130/\145\130\&0\206\198N",PropTopicAliasMaximum 2890,PropServerReference +// "J\NUL`\250\238\230\160\210B",PropSessionExpiryInterval 17715,PropCorrelationData +// "\\\192\197\&6\245\181h\147+\205\228s\248\229\EOTI\243P\175\185",PropAuthenticationData +// ";{F\167\DC4%F\222\DC4\170\204\217\SYNj\206h\ACK\141\235\198$\193\DEL\209)~-",PropAssignedClientIdentifier +// "\151\136\RS",PropTopicAlias 9534,PropMaximumQoS 98,PropResponseTopic +// "\ACKvI\186\202\141\176#\199\218\DC3\223R\189\220\208\&6\180QR\231\148\189\182",PropSharedSubscriptionAvailable +// 238,PropContentType "\RS.\n\EM;\187:\223Y\210D5[\171\171",PropResponseTopic +// "_x\a:\235?\174\248\146\154\CAN\131\255\&4"]}), _cleanSession = False, _keepAlive = 3727, _connID = "\DEL\250\165", +// _properties = [PropReceiveMaximum 2641,PropRetainAvailable 87,PropRetainAvailable 235,PropMessageExpiryInterval +// 9273,PropSubscriptionIdentifierAvailable 25,PropSubscriptionIdentifierAvailable 10,PropSharedSubscriptionAvailable +// 20,PropMessageExpiryInterval 6127,PropSubscriptionIdentifierAvailable 248,PropServerReference "\184\231\164\139"]} +TEST(Connect5QCTest, Encode64) { + uint8_t pkt[] = { + 0x10, 0x86, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x34, 0xe, 0x8f, 0x20, 0x21, 0xa, 0x51, 0x25, 0x57, + 0x25, 0xeb, 0x2, 0x0, 0x0, 0x24, 0x39, 0x29, 0x19, 0x29, 0xa, 0x2a, 0x14, 0x2, 0x0, 0x0, 0x17, 0xef, 0x29, + 0xf8, 0x1c, 0x0, 0x4, 0xb8, 0xe7, 0xa4, 0x8b, 0x0, 0x3, 0x7f, 0xfa, 0xa5, 0xb8, 0x1, 0x25, 0x94, 0x13, 0x9, + 0xc1, 0x28, 0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 0xfd, 0x91, 0x71, 0x4b, 0x3b, 0x80, 0xda, 0x0, 0x9, 0x82, 0x39, 0x50, 0x74, 0x9, 0x43, 0xc9, 0xb0, 0x93}; + + uint8_t buf[275] = {0}; + + uint8_t bytesprops0[] = {0xb8, 0xe7, 0xa4, 0x8b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2641}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9273}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6127}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops0}}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x89, 0x7b, 0x1c, 0x18}; + uint8_t byteswillprops1[] = {0x1b, 0x82, 0x2f, 0x91, 0x82, 0x30, 0xce, 0xc6, 0x4e}; + uint8_t byteswillprops2[] = {0x4a, 0x0, 0x60, 0xfa, 0xee, 0xe6, 0xa0, 0xd2, 0x42}; + uint8_t byteswillprops3[] = {0x5c, 0xc0, 0xc5, 0x36, 0xf5, 0xb5, 0x68, 0x93, 0x2b, 0xcd, + 0xe4, 0x73, 0xf8, 0xe5, 0x4, 0x49, 0xf3, 0x50, 0xaf, 0xb9}; + uint8_t byteswillprops4[] = {0x3b, 0x7b, 0x46, 0xa7, 0x14, 0x25, 0x46, 0xde, 0x14, 0xaa, 0xcc, 0xd9, 0x16, 0x6a, + 0xce, 0x68, 0x6, 0x8d, 0xeb, 0xc6, 0x24, 0xc1, 0x7f, 0xd1, 0x29, 0x7e, 0x2d}; + uint8_t byteswillprops5[] = {0x97, 0x88, 0x1e}; + uint8_t byteswillprops6[] = {0x6, 0x76, 0x49, 0xba, 0xca, 0x8d, 0xb0, 0x23, 0xc7, 0xda, 0x13, 0xdf, + 0x52, 0xbd, 0xdc, 0xd0, 0x36, 0xb4, 0x51, 0x52, 0xe7, 0x94, 0xbd, 0xb6}; + uint8_t byteswillprops7[] = {0x1e, 0x2e, 0xa, 0x19, 0x3b, 0xbb, 0x3a, 0xdf, 0x59, 0xd2, 0x44, 0x35, 0x5b, 0xab, 0xab}; + uint8_t byteswillprops8[] = {0x5f, 0x78, 0x7, 0x3a, 0xeb, 0x3f, 0xae, 0xf8, 0x92, 0x9a, 0x18, 0x83, 0xff, 0x34}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2497}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3471}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29487}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2890}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17715}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9534}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&byteswillprops8}}}, + }; + + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb2, 0xde, 0xc7, 0x6f, 0x10, 0x60, 0x30, 0x25, + 0xfd, 0x91, 0x71, 0x4b, 0x3b, 0x80, 0xda}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x82, 0x39, 0x50, 0x74, 0x9, 0x43, 0xc9, 0xb0, 0x93}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3727; + uint8_t client_id_bytes[] = {0x7f, 0xfa, 0xa5}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x34, 0x9f, 0xa2, 0x26, 0x1c, 0x28, 0xb9, 0x56, 0x7a, 0x9f, 0x23}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\RSt\221\140\178\180\155#r\255\&3\212\203w\206\137L\202\190\SUB G\227\FS", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "~^x\SYN6\181\252#\192\a\231\220>\DC2e\NAK", _willMsg = +// "\202S\US{\160\165\GS\f\165\SUB\183D\191\212\150\157\f\SUBwj\204\SYN\167\237\251\161\189", _willProps = +// [PropMaximumPacketSize 31654,PropMaximumPacketSize 2463,PropUserProperty +// "W\171\240\137+\250\199\243\137\ACKQ\177\143\216=\"\DEL\138T5\204E" +// "7\162\169\173\246QV\ENQ\245\239gw\207z\201\180\142RW+\219|i\180\194\b\194",PropTopicAlias +// 20921,PropWillDelayInterval 24817,PropReasonString +// "R\219s\190JX\ESC\164w\148~\CAN\226Bi<\228\EM\232P\135o'\171\178\143\DEL\\",PropReceiveMaximum +// 26593,PropCorrelationData ":A\187\149\178\&7\145\220\DC2\166)U}7\252F\130\151\208T\183s",PropMessageExpiryInterval +// 29335,PropPayloadFormatIndicator 77,PropSharedSubscriptionAvailable 25,PropWildcardSubscriptionAvailable +// 26,PropServerReference +// "\FS\190\152\209\&0\SO\SOH\176\241\fj\244\DEL\155\172\STX\n\t\149\180G\SOH:xj\254\&5\237k",PropCorrelationData +// "\194\238\209\SI\190\238R\138\236\240\175z",PropServerReference "v\146v",PropMessageExpiryInterval +// 22045,PropRequestResponseInformation 214,PropTopicAliasMaximum 29161,PropRequestResponseInformation +// 180,PropWildcardSubscriptionAvailable 170,PropSessionExpiryInterval 27399]}), _cleanSession = False, _keepAlive = +// 3670, _connID = "H\SI\178\231o\172\&9\153", _properties = [PropResponseInformation +// "H\179p8\ETX\137zM\223\202\250\177\v\ETB=\197\201-\r\225\185",PropMaximumPacketSize 15938,PropServerReference +// "\DC2\227\184\137\232-\210\151\&5\163\171\201\v\207|:\DLE\223\183\243%",PropTopicAliasMaximum +// 14229,PropWillDelayInterval 13002,PropMaximumPacketSize 6555,PropRequestProblemInformation 143,PropAuthenticationData +// "",PropRetainAvailable 54]} +TEST(Connect5QCTest, Encode65) { + uint8_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, 0x33, 0xd4, 0xcb, 0x77, 0xce, 0x89, 0x4c, 0xca, + 0xbe, 0x1a, 0x20, 0x47, 0xe3, 0x1c}; + + uint8_t buf[396] = {0}; + + uint8_t bytesprops0[] = {0x48, 0xb3, 0x70, 0x38, 0x3, 0x89, 0x7a, 0x4d, 0xdf, 0xca, 0xfa, + 0xb1, 0xb, 0x17, 0x3d, 0xc5, 0xc9, 0x2d, 0xd, 0xe1, 0xb9}; + uint8_t bytesprops1[] = {0x12, 0xe3, 0xb8, 0x89, 0xe8, 0x2d, 0xd2, 0x97, 0x35, 0xa3, 0xab, + 0xc9, 0xb, 0xcf, 0x7c, 0x3a, 0x10, 0xdf, 0xb7, 0xf3, 0x25}; + uint8_t bytesprops2[] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15938}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14229}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13002}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6555}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 54}}, + }; + + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x37, 0xa2, 0xa9, 0xad, 0xf6, 0x51, 0x56, 0x5, 0xf5, 0xef, 0x67, 0x77, 0xcf, 0x7a, + 0xc9, 0xb4, 0x8e, 0x52, 0x57, 0x2b, 0xdb, 0x7c, 0x69, 0xb4, 0xc2, 0x8, 0xc2}; + uint8_t byteswillprops0[] = {0x57, 0xab, 0xf0, 0x89, 0x2b, 0xfa, 0xc7, 0xf3, 0x89, 0x6, 0x51, + 0xb1, 0x8f, 0xd8, 0x3d, 0x22, 0x7f, 0x8a, 0x54, 0x35, 0xcc, 0x45}; + uint8_t byteswillprops2[] = {0x52, 0xdb, 0x73, 0xbe, 0x4a, 0x58, 0x1b, 0xa4, 0x77, 0x94, 0x7e, 0x18, 0xe2, 0x42, + 0x69, 0x3c, 0xe4, 0x19, 0xe8, 0x50, 0x87, 0x6f, 0x27, 0xab, 0xb2, 0x8f, 0x7f, 0x5c}; + uint8_t byteswillprops3[] = {0x3a, 0x41, 0xbb, 0x95, 0xb2, 0x37, 0x91, 0xdc, 0x12, 0xa6, 0x29, + 0x55, 0x7d, 0x37, 0xfc, 0x46, 0x82, 0x97, 0xd0, 0x54, 0xb7, 0x73}; + uint8_t byteswillprops4[] = {0x1c, 0xbe, 0x98, 0xd1, 0x30, 0xe, 0x1, 0xb0, 0xf1, 0xc, 0x6a, 0xf4, 0x7f, 0x9b, 0xac, + 0x2, 0xa, 0x9, 0x95, 0xb4, 0x47, 0x1, 0x3a, 0x78, 0x6a, 0xfe, 0x35, 0xed, 0x6b}; + uint8_t byteswillprops5[] = {0xc2, 0xee, 0xd1, 0xf, 0xbe, 0xee, 0x52, 0x8a, 0xec, 0xf0, 0xaf, 0x7a}; + uint8_t byteswillprops6[] = {0x76, 0x92, 0x76}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31654}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2463}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {22, (char*)&byteswillprops0}, .v = {27, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20921}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24817}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26593}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29335}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22045}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29161}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27399}}, + }; + + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x7e, 0x5e, 0x78, 0x16, 0x36, 0xb5, 0xfc, 0x23, + 0xc0, 0x7, 0xe7, 0xdc, 0x3e, 0x12, 0x65, 0x15}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xca, 0x53, 0x1f, 0x7b, 0xa0, 0xa5, 0x1d, 0xc, 0xa5, 0x1a, 0xb7, 0x44, 0xbf, 0xd4, + 0x96, 0x9d, 0xc, 0x1a, 0x77, 0x6a, 0xcc, 0x16, 0xa7, 0xed, 0xfb, 0xa1, 0xbd}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3670; + uint8_t client_id_bytes[] = {0x48, 0xf, 0xb2, 0xe7, 0x6f, 0xac, 0x39, 0x99}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x1e, 0x74, 0xdd, 0x8c, 0xb2, 0xb4, 0x9b, 0x23, 0x72, 0xff, 0x33, 0xd4, + 0xcb, 0x77, 0xce, 0x89, 0x4c, 0xca, 0xbe, 0x1a, 0x20, 0x47, 0xe3, 0x1c}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\DC1M\180\r\a\252wp^bZ\135\DEL2@Z\253\165\DC2y\209\226r]\164", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "a\214\153~t\218\159\237r\222\195'\246(\175", _willMsg = "\224\207\248\\\EM\EM/u\n7rM\210", _willProps = +// [PropAuthenticationData "\182",PropMessageExpiryInterval 20665,PropAuthenticationData +// "\162DZ&_\160\142eRK(\236L\156\147\183\&7\224\rhZg",PropRequestResponseInformation 71,PropMessageExpiryInterval +// 20758,PropRequestResponseInformation 117,PropMessageExpiryInterval 10617,PropSharedSubscriptionAvailable +// 90,PropAuthenticationData "o.\150\152\253T\249\&0\201 +// H\210\211\198\185l\CAN\174Jpw\173\171\DC1r",PropAuthenticationData +// "CY\207w\154\136\231/",PropAssignedClientIdentifier +// "\211ImG\228\194\183\212D\143\180V\180`b\203\229",PropMessageExpiryInterval 26735]}), _cleanSession = True, +// _keepAlive = 15606, _connID = "\DC2O:m\245\197\216\200\\\t\162\221\172w\235d1\138\240\144\RSX%\208C\SOPC\199", +// _properties = [PropServerKeepAlive 13066,PropRetainAvailable 173,PropUserProperty +// "\203\219\190\n\207\189\160\151Gg>\225\159|\DC1\ETX\204\151\140\233\244" +// "\\\226\242\209\RS\255\191\182\218\241\SI<\168\216",PropTopicAliasMaximum 18576,PropContentType +// "z\r\252\147\233",PropContentType "|\241\151\190\134H\192T|;\v",PropMessageExpiryInterval 15714,PropReasonString +// "9\177\218w\243\US\202z\207\&3\135\&9\216\255\200l\ESCsT\246\133zf",PropTopicAlias 31604,PropRetainAvailable +// 206,PropWillDelayInterval 22587,PropReceiveMaximum 697,PropSubscriptionIdentifierAvailable 85,PropWillDelayInterval +// 15540]} +TEST(Connect5QCTest, Encode66) { + uint8_t pkt[] = { + 0x10, 0xb6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0x3c, 0xf6, 0x79, 0x13, 0x33, 0xa, 0x25, 0xad, + 0x26, 0x0, 0x15, 0xcb, 0xdb, 0xbe, 0xa, 0xcf, 0xbd, 0xa0, 0x97, 0x47, 0x67, 0x3e, 0xe1, 0x9f, 0x7c, 0x11, 0x3, + 0xcc, 0x97, 0x8c, 0xe9, 0xf4, 0x0, 0xe, 0x5c, 0xe2, 0xf2, 0xd1, 0x1e, 0xff, 0xbf, 0xb6, 0xda, 0xf1, 0xf, 0x3c, + 0xa8, 0xd8, 0x22, 0x48, 0x90, 0x3, 0x0, 0x5, 0x7a, 0xd, 0xfc, 0x93, 0xe9, 0x3, 0x0, 0xb, 0x7c, 0xf1, 0x97, + 0xbe, 0x86, 0x48, 0xc0, 0x54, 0x7c, 0x3b, 0xb, 0x2, 0x0, 0x0, 0x3d, 0x62, 0x1f, 0x0, 0x17, 0x39, 0xb1, 0xda, + 0x77, 0xf3, 0x1f, 0xca, 0x7a, 0xcf, 0x33, 0x87, 0x39, 0xd8, 0xff, 0xc8, 0x6c, 0x1b, 0x73, 0x54, 0xf6, 0x85, 0x7a, + 0x66, 0x23, 0x7b, 0x74, 0x25, 0xce, 0x18, 0x0, 0x0, 0x58,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, 0xd2}; + + uint8_t buf[323] = {0}; + + uint8_t bytesprops1[] = {0x5c, 0xe2, 0xf2, 0xd1, 0x1e, 0xff, 0xbf, 0xb6, 0xda, 0xf1, 0xf, 0x3c, 0xa8, 0xd8}; + uint8_t bytesprops0[] = {0xcb, 0xdb, 0xbe, 0xa, 0xcf, 0xbd, 0xa0, 0x97, 0x47, 0x67, 0x3e, + 0xe1, 0x9f, 0x7c, 0x11, 0x3, 0xcc, 0x97, 0x8c, 0xe9, 0xf4}; + uint8_t bytesprops2[] = {0x7a, 0xd, 0xfc, 0x93, 0xe9}; + uint8_t bytesprops3[] = {0x7c, 0xf1, 0x97, 0xbe, 0x86, 0x48, 0xc0, 0x54, 0x7c, 0x3b, 0xb}; + uint8_t bytesprops4[] = {0x39, 0xb1, 0xda, 0x77, 0xf3, 0x1f, 0xca, 0x7a, 0xcf, 0x33, 0x87, 0x39, + 0xd8, 0xff, 0xc8, 0x6c, 0x1b, 0x73, 0x54, 0xf6, 0x85, 0x7a, 0x66}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13066}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops0}, .v = {14, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18576}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15714}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31604}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22587}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 697}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15540}}, + }; + + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xb6}; + uint8_t byteswillprops1[] = {0xa2, 0x44, 0x5a, 0x26, 0x5f, 0xa0, 0x8e, 0x65, 0x52, 0x4b, 0x28, + 0xec, 0x4c, 0x9c, 0x93, 0xb7, 0x37, 0xe0, 0xd, 0x68, 0x5a, 0x67}; + uint8_t byteswillprops2[] = {0x6f, 0x2e, 0x96, 0x98, 0xfd, 0x54, 0xf9, 0x30, 0xc9, 0x20, 0x48, 0xd2, 0xd3, + 0xc6, 0xb9, 0x6c, 0x18, 0xae, 0x4a, 0x70, 0x77, 0xad, 0xab, 0x11, 0x72}; + uint8_t byteswillprops3[] = {0x43, 0x59, 0xcf, 0x77, 0x9a, 0x88, 0xe7, 0x2f}; + uint8_t byteswillprops4[] = {0xd3, 0x49, 0x6d, 0x47, 0xe4, 0xc2, 0xb7, 0xd4, 0x44, + 0x8f, 0xb4, 0x56, 0xb4, 0x60, 0x62, 0xcb, 0xe5}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20665}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20758}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10617}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26735}}, + }; + + lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x61, 0xd6, 0x99, 0x7e, 0x74, 0xda, 0x9f, 0xed, + 0x72, 0xde, 0xc3, 0x27, 0xf6, 0x28, 0xaf}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe0, 0xcf, 0xf8, 0x5c, 0x19, 0x19, 0x2f, 0x75, 0xa, 0x37, 0x72, 0x4d, 0xd2}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 15606; + uint8_t client_id_bytes[] = {0x12, 0x4f, 0x3a, 0x6d, 0xf5, 0xc5, 0xd8, 0xc8, 0x5c, 0x9, 0xa2, 0xdd, 0xac, 0x77, 0xeb, + 0x64, 0x31, 0x8a, 0xf0, 0x90, 0x1e, 0x58, 0x25, 0xd0, 0x43, 0xe, 0x50, 0x43, 0xc7}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x11, 0x4d, 0xb4, 0xd, 0x7, 0xfc, 0x77, 0x70, 0x5e, 0x62, 0x5a, 0x87, 0x7f, + 0x32, 0x40, 0x5a, 0xfd, 0xa5, 0x12, 0x79, 0xd1, 0xe2, 0x72, 0x5d, 0xa4}; + lwmqtt_string_t password = {25, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "7y&\a\226\163R-*\143C\172?T4\174\227\&4$\202\150\&2\DLE\231\243", _password = +// Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = 6271, _connID = +// "\193=\232\&0\251\248\&3\179\238?E\142", _properties = [PropTopicAlias 12909,PropAssignedClientIdentifier +// "\DC2\244KT\188\SYN\203\b\224\233\EMB\158e\174",PropTopicAliasMaximum 26424,PropSubscriptionIdentifier +// 24,PropAuthenticationData "\177#C\232E\164\208\147\247Y\186\172*m",PropCorrelationData "\192\219@\GS\208?\213 +// Td7a",PropRetainAvailable 9,PropSessionExpiryInterval 13511,PropSessionExpiryInterval 7047,PropPayloadFormatIndicator +// 58,PropMaximumQoS 42,PropMessageExpiryInterval 20638,PropSharedSubscriptionAvailable 173,PropResponseInformation +// "\130\249\156\145\DC1FY\137\192\f\134\231\179\ACK\216\EM\237\217#\DC2L\251\DLE\161WA",PropWildcardSubscriptionAvailable +// 121,PropWillDelayInterval 7128,PropServerReference +// "\136\203\131\142xEw\179J\202Yg\218\231HT\249\180\GS\140\229C\DC3\233",PropCorrelationData +// "\143m\143\"\220\142",PropRequestResponseInformation 127,PropAuthenticationMethod "",PropResponseInformation +// "",PropRequestProblemInformation 149,PropServerKeepAlive 1854,PropServerReference +// "\159\152)\128\STXxK\140\153uC\225Y^o\254",PropAssignedClientIdentifier +// "\bLg\183\252w\212o\212\164V\203\EOT*y\145D$\211\DC3\183\238\185[h\167M\SYN",PropSharedSubscriptionAvailable +// 99,PropCorrelationData "\146\&1\"\157\143#|\135\237\179( +// E\DEL\203\199\163ae\172\162\130l\209\218c|\226\a",PropMaximumPacketSize 13527,PropTopicAlias +// 20115,PropSubscriptionIdentifierAvailable 130]} +TEST(Connect5QCTest, Encode67) { + uint8_t pkt[] = { + 0x10, 0xb9, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x82, 0x18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12, 0x0, 0x1c, 0x8, 0x4c, 0x67, 0xb7, 0xfc, 0x77, + 0xd4, 0x6f, 0xd4, 0xa4, 0x56, 0xcb, 0x4, 0x2a, 0x79, 0x91, 0x44, 0x24, 0xd3, 0x13, 0xb7, 0xee, 0xb9, 0x5b, 0x68, + 0xa7, 0x4d, 0x16, 0x2a, 0x63, 0x9, 0x0, 0x1d, 0x92, 0x31, 0x22, 0x9d, 0x8f, 0x23, 0x7c, 0x87, 0xed, 0xb3, 0x28, + 0x20, 0x45, 0x7f, 0xcb, 0xc7, 0xa3, 0x61, 0x65, 0xac, 0xa2, 0x82, 0x6c, 0xd1, 0xda, 0x63, 0x7c, 0xe2, 0x7, 0x27, + 0x0, 0x0, 0x34, 0xd7, 0x23, 0x4e, 0x93, 0x29, 0x82, 0x0, 0xc, 0xc1, 0x3d, 0xe8, 0x30, 0xfb, 0xf8, 0x33, 0xb3, + 0xee, 0x3f, 0x45, 0x8e, 0x0, 0x19, 0x37, 0x79, 0x26, 0x7, 0xe2, 0xa3, 0x52, 0x2d, 0x2a, 0x8f, 0x43, 0xac, 0x3f, + 0x54, 0x34, 0xae, 0xe3, 0x34, 0x24, 0xca, 0x96, 0x32, 0x10, 0xe7, 0xf3}; + + uint8_t buf[326] = {0}; + + uint8_t bytesprops0[] = {0x12, 0xf4, 0x4b, 0x54, 0xbc, 0x16, 0xcb, 0x8, 0xe0, 0xe9, 0x19, 0x42, 0x9e, 0x65, 0xae}; + uint8_t bytesprops1[] = {0xb1, 0x23, 0x43, 0xe8, 0x45, 0xa4, 0xd0, 0x93, 0xf7, 0x59, 0xba, 0xac, 0x2a, 0x6d}; + uint8_t bytesprops2[] = {0xc0, 0xdb, 0x40, 0x1d, 0xd0, 0x3f, 0xd5, 0x20, 0x54, 0x64, 0x37, 0x61}; + uint8_t bytesprops3[] = {0x82, 0xf9, 0x9c, 0x91, 0x11, 0x46, 0x59, 0x89, 0xc0, 0xc, 0x86, 0xe7, 0xb3, + 0x6, 0xd8, 0x19, 0xed, 0xd9, 0x23, 0x12, 0x4c, 0xfb, 0x10, 0xa1, 0x57, 0x41}; + uint8_t bytesprops4[] = {0x88, 0xcb, 0x83, 0x8e, 0x78, 0x45, 0x77, 0xb3, 0x4a, 0xca, 0x59, 0x67, + 0xda, 0xe7, 0x48, 0x54, 0xf9, 0xb4, 0x1d, 0x8c, 0xe5, 0x43, 0x13, 0xe9}; + uint8_t bytesprops5[] = {0x8f, 0x6d, 0x8f, 0x22, 0xdc, 0x8e}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops8[] = {0x9f, 0x98, 0x29, 0x80, 0x2, 0x78, 0x4b, 0x8c, + 0x99, 0x75, 0x43, 0xe1, 0x59, 0x5e, 0x6f, 0xfe}; + uint8_t bytesprops9[] = {0x8, 0x4c, 0x67, 0xb7, 0xfc, 0x77, 0xd4, 0x6f, 0xd4, 0xa4, 0x56, 0xcb, 0x4, 0x2a, + 0x79, 0x91, 0x44, 0x24, 0xd3, 0x13, 0xb7, 0xee, 0xb9, 0x5b, 0x68, 0xa7, 0x4d, 0x16}; + uint8_t bytesprops10[] = {0x92, 0x31, 0x22, 0x9d, 0x8f, 0x23, 0x7c, 0x87, 0xed, 0xb3, 0x28, 0x20, 0x45, 0x7f, 0xcb, + 0xc7, 0xa3, 0x61, 0x65, 0xac, 0xa2, 0x82, 0x6c, 0xd1, 0xda, 0x63, 0x7c, 0xe2, 0x7}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12909}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26424}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13511}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7047}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20638}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7128}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1854}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13527}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20115}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, + }; + + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 6271; + uint8_t client_id_bytes[] = {0xc1, 0x3d, 0xe8, 0x30, 0xfb, 0xf8, 0x33, 0xb3, 0xee, 0x3f, 0x45, 0x8e}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x37, 0x79, 0x26, 0x7, 0xe2, 0xa3, 0x52, 0x2d, 0x2a, 0x8f, 0x43, 0xac, 0x3f, + 0x54, 0x34, 0xae, 0xe3, 0x34, 0x24, 0xca, 0x96, 0x32, 0x10, 0xe7, 0xf3}; + lwmqtt_string_t username = {25, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\NAK=\230S\192\217KW\211\176\174\190\213\179a\138\ENQR\222", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "\218\251\CAN\137\184\196\247\&0u\SYNZ", _willMsg = "\140\162\226\246\\\158,\b\141\157Z$+", _willProps = +// [PropAuthenticationMethod "!Y\246\135\136\194 \233\208om\171[$\131TI\CANr\227",PropSessionExpiryInterval +// 15018,PropRetainAvailable 75,PropPayloadFormatIndicator 193,PropReceiveMaximum 24624,PropTopicAlias +// 1393,PropCorrelationData "\153 <\241\DC1\244\177=]\157\218\NUL(\EOTC",PropCorrelationData +// "sn\RS'\227\b/\141\210DO?\230\171\NAK%\162\195\220B\253",PropAuthenticationData +// "1\ETX2\154\237\146\183\217\158\163",PropAssignedClientIdentifier +// "\196\ENQ\128\254\153\169",PropRequestResponseInformation 65,PropReasonString "\203\183",PropAssignedClientIdentifier +// "",PropServerKeepAlive 7567,PropMessageExpiryInterval 10027,PropWillDelayInterval 4878,PropContentType +// "@/\NUL\169",PropRequestResponseInformation 210,PropResponseTopic +// "\218\ETB\204\254\207u\132\229\144\133\213\134}DDsl",PropCorrelationData +// "\196\240U\248",PropWildcardSubscriptionAvailable 42,PropTopicAlias 28909,PropSubscriptionIdentifierAvailable +// 10,PropCorrelationData "\184\&8Z\163\\\t\154\160D\ACK\190\133\154\151",PropAuthenticationMethod +// "S\175V\175\191\181\226\206\186\DC4\254\155\134W\178\255",PropResponseInformation +// "\238+&\227\235eg\189\133Q7D\CAN\DC1\147\188\158\170\251\159x\236\234\&8N\146n"]}), _cleanSession = False, _keepAlive +// = 18470, _connID = "\145\177\179\193o\203\219\238Y:\131\b\140\246\195\211\214\210p\177", _properties = +// [PropAssignedClientIdentifier ""]} +TEST(Connect5QCTest, Encode68) { + uint8_t pkt[] = { + 0x10, 0xac, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x24, 0x48, 0x26, 0x3, 0x12, 0x0, 0x0, 0x0, 0x14, + 0x91, 0xb1, 0xb3, 0xc1, 0x6f, 0xcb, 0xdb, 0xee, 0x59, 0x3a, 0x83, 0x8, 0x8c, 0xf6, 0xc3, 0xd3, 0xd6, 0xd2, 0x70, + 0xb1, 0xea, 0x1, 0x15, 0x0, 0x14, 0x21, 0x59, 0xf6, 0x87, 0x88, 0xc2, 0x20, 0xe9, 0xd0, 0x6f, 0x6d, 0xab, 0x5b, + 0x24, 0x83, 0x54, 0x49, 0x18, 0x72, 0xe3, 0x11, 0x0, 0x0, 0x3a, 0xaa, 0x25, 0x4b, 0x1, 0xc1, 0x21, 0x60, 0x30, + 0x23, 0x5, 0x71, 0x9, 0x0, 0xf, 0x99, 0x20, 0x3c, 0xf1, 0x11, 0xf4, 0xb1, 0x3d, 0x5d, 0x9d, 0xda, 0x0, 0x28, + 0x4, 0x43, 0x9, 0x0, 0x15, 0x73, 0x6e, 0x1e, 0x27, 0xe3, 0x8, 0x2f, 0x8d, 0xd2, 0x44, 0x4f, 0x3f, 0xe6, 0xab, + 0x15, 0x25, 0xa2, 0xc3, 0xdc, 0x42, 0xfd, 0x16, 0x0, 0xa, 0x31, 0x3, 0x32, 0x9a, 0xed, 0x92, 0xb7, 0xd9, 0x9e, + 0xa3, 0x12, 0x0, 0x6, 0xc4, 0x5, 0x80, 0xfe, 0x99, 0xa9, 0x19, 0x41, 0x1f, 0x0, 0x2, 0xcb, 0xb7, 0x12, 0x0, + 0x0, 0x13, 0x1d, 0x8f, 0x2, 0x0, 0x0, 0x27, 0x2b, 0x18, 0x0, 0x0, 0x13, 0xe, 0x3, 0x0, 0x4, 0x40, 0x2f, + 0x0, 0xa9, 0x19, 0xd2, 0x8, 0x0, 0x11, 0xda, 0x17, 0xcc, 0xfe, 0xcf, 0x75, 0x84, 0xe5, 0x90, 0x85, 0xd5, 0x86, + 0x7d, 0x44, 0x44, 0x73, 0x6c, 0x9, 0x0, 0x4, 0xc4, 0xf0, 0x55, 0xf8, 0x28, 0x2a, 0x23, 0x70, 0xed, 0x29, 0xa, + 0x9, 0x0, 0xe, 0xb8, 0x38, 0x5a, 0xa3, 0x5c, 0x9, 0x9a, 0xa0, 0x44, 0x6, 0xbe, 0x85, 0x9a, 0x97, 0x15, 0x0, + 0x10, 0x53, 0xaf, 0x56, 0xaf, 0xbf, 0xb5, 0xe2, 0xce, 0xba, 0x14, 0xfe, 0x9b, 0x86, 0x57, 0xb2, 0xff, 0x1a, 0x0, + 0x1b, 0xee, 0x2b, 0x26, 0xe3, 0xeb, 0x65, 0x67, 0xbd, 0x85, 0x51, 0x37, 0x44, 0x18, 0x11, 0x93, 0xbc, 0x9e, 0xaa, + 0xfb, 0x9f, 0x78, 0xec, 0xea, 0x38, 0x4e, 0x92, 0x6e, 0x0, 0xb, 0xda, 0xfb, 0x18, 0x89, 0xb8, 0xc4, 0xf7, 0x30, + 0x75, 0x16, 0x5a, 0x0, 0xd, 0x8c, 0xa2, 0xe2, 0xf6, 0x5c, 0x9e, 0x2c, 0x8, 0x8d, 0x9d, 0x5a, 0x24, 0x2b}; + + uint8_t buf[313] = {0}; + + uint8_t bytesprops0[] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x21, 0x59, 0xf6, 0x87, 0x88, 0xc2, 0x20, 0xe9, 0xd0, 0x6f, + 0x6d, 0xab, 0x5b, 0x24, 0x83, 0x54, 0x49, 0x18, 0x72, 0xe3}; + uint8_t byteswillprops1[] = {0x99, 0x20, 0x3c, 0xf1, 0x11, 0xf4, 0xb1, 0x3d, 0x5d, 0x9d, 0xda, 0x0, 0x28, 0x4, 0x43}; + uint8_t byteswillprops2[] = {0x73, 0x6e, 0x1e, 0x27, 0xe3, 0x8, 0x2f, 0x8d, 0xd2, 0x44, 0x4f, + 0x3f, 0xe6, 0xab, 0x15, 0x25, 0xa2, 0xc3, 0xdc, 0x42, 0xfd}; + uint8_t byteswillprops3[] = {0x31, 0x3, 0x32, 0x9a, 0xed, 0x92, 0xb7, 0xd9, 0x9e, 0xa3}; + uint8_t byteswillprops4[] = {0xc4, 0x5, 0x80, 0xfe, 0x99, 0xa9}; + uint8_t byteswillprops5[] = {0xcb, 0xb7}; + uint8_t byteswillprops6[] = {0}; + uint8_t byteswillprops7[] = {0x40, 0x2f, 0x0, 0xa9}; + uint8_t byteswillprops8[] = {0xda, 0x17, 0xcc, 0xfe, 0xcf, 0x75, 0x84, 0xe5, 0x90, + 0x85, 0xd5, 0x86, 0x7d, 0x44, 0x44, 0x73, 0x6c}; + uint8_t byteswillprops9[] = {0xc4, 0xf0, 0x55, 0xf8}; + uint8_t byteswillprops10[] = {0xb8, 0x38, 0x5a, 0xa3, 0x5c, 0x9, 0x9a, 0xa0, 0x44, 0x6, 0xbe, 0x85, 0x9a, 0x97}; + uint8_t byteswillprops11[] = {0x53, 0xaf, 0x56, 0xaf, 0xbf, 0xb5, 0xe2, 0xce, + 0xba, 0x14, 0xfe, 0x9b, 0x86, 0x57, 0xb2, 0xff}; + uint8_t byteswillprops12[] = {0xee, 0x2b, 0x26, 0xe3, 0xeb, 0x65, 0x67, 0xbd, 0x85, 0x51, 0x37, 0x44, 0x18, 0x11, + 0x93, 0xbc, 0x9e, 0xaa, 0xfb, 0x9f, 0x78, 0xec, 0xea, 0x38, 0x4e, 0x92, 0x6e}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15018}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24624}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1393}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7567}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10027}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4878}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28909}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops12}}}, + }; + + lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xda, 0xfb, 0x18, 0x89, 0xb8, 0xc4, 0xf7, 0x30, 0x75, 0x16, 0x5a}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x8c, 0xa2, 0xe2, 0xf6, 0x5c, 0x9e, 0x2c, 0x8, 0x8d, 0x9d, 0x5a, 0x24, 0x2b}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 18470; + uint8_t client_id_bytes[] = {0x91, 0xb1, 0xb3, 0xc1, 0x6f, 0xcb, 0xdb, 0xee, 0x59, 0x3a, + 0x83, 0x8, 0x8c, 0xf6, 0xc3, 0xd3, 0xd6, 0xd2, 0x70, 0xb1}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x15, 0x3d, 0xe6, 0x53, 0xc0, 0xd9, 0x4b, 0x57, 0xd3, 0xb0, + 0xae, 0xbe, 0xd5, 0xb3, 0x61, 0x8a, 0x5, 0x52, 0xde}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\SOH\253\128h\214\136>\244<\255\153", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "n\221.g\231\209[a*n'\214al\147\241$\175'-J\140\217\175\152\130\155\232", _willMsg = +// "\US\161\236\DC2\138\211_\ESC\244", _willProps = [PropTopicAlias 27954,PropSubscriptionIdentifier +// 12,PropAuthenticationData "\186(J",PropUserProperty "" ";\235\\\DC1\146\255\185\ACK",PropTopicAliasMaximum +// 18528,PropReasonString +// "\167G\198\a\249\150\184\195\210\130\249\SUB\206\DEL\249m\185:\182\224\177\254",PropUserProperty "i4\n\232iz\191\GS" +// ">\232)\SOv\v\rF\199G\DC1l9\224.\251",PropRequestResponseInformation 102,PropCorrelationData +// "\210\223\183\209\SYNz(i\164\159 ym\206\170\224\175\233:/\165\172Y\183X\r&}0",PropTopicAlias +// 4523,PropMessageExpiryInterval 15484,PropResponseTopic +// "B\SUB\181\202\154-\165\157\239`\150(\166\201\146",PropCorrelationData "\207\220\167\172\FS",PropUserProperty +// "\235\209\255\154C\DC1\155K/\DLE\183d7Ib\167J\128\&9" "\192\190\DC3\237\199",PropServerReference +// "\n$\GS\184g#",PropPayloadFormatIndicator 230,PropServerKeepAlive 2306,PropSharedSubscriptionAvailable 103]}), +// _cleanSession = True, _keepAlive = 9181, _connID = "M\156\DC4\133Z\205\NAK&", _properties = [PropResponseInformation +// "qg\170\DEL\192\194V\130<\226U\139\166\&5\"Qp",PropSubscriptionIdentifierAvailable 60,PropServerKeepAlive +// 2214,PropMaximumQoS 109,PropSubscriptionIdentifierAvailable 83,PropReceiveMaximum 5805,PropServerKeepAlive +// 15509,PropWildcardSubscriptionAvailable 66,PropTopicAliasMaximum 29709,PropResponseTopic +// "\STXE1\231\136\190e\190\192\232\225",PropWildcardSubscriptionAvailable 0,PropTopicAlias +// 10103,PropSubscriptionIdentifierAvailable 198,PropRequestProblemInformation 61,PropServerKeepAlive +// 11863,PropSubscriptionIdentifierAvailable 153,PropSubscriptionIdentifierAvailable 33,PropWillDelayInterval +// 13860,PropAuthenticationData "\233\\\148",PropContentType +// ">\CAN\EM\173\EM\200\138\155\153\SUB\134=\DC114\229\172\162w\DC2\141q\186\188\171",PropAssignedClientIdentifier +// "&\240/\167E\150\238A\190o\252\131\139\&3",PropAssignedClientIdentifier +// "\128\144\253\244e\238\158U~\139\EOTU\"n\164\v\229\&0",PropRetainAvailable 146,PropWildcardSubscriptionAvailable +// 188,PropSharedSubscriptionAvailable 162,PropRequestProblemInformation 102,PropWildcardSubscriptionAvailable 223]} +TEST(Connect5QCTest, Encode69) { + uint8_t pkt[] = { + 0x10, 0xa0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6, 0x23, 0xdd, 0x9d, 0x1, 0x1a, 0x0, 0x11, 0x71, + 0x67, 0xaa, 0x7f, 0xc0, 0xc2, 0x56, 0x82, 0x3c, 0xe2, 0x55, 0x8b, 0xa6, 0x35, 0x22, 0x51, 0x70, 0x29, 0x3c, 0x13, + 0x8, 0xa6, 0x24, 0x6d, 0x29, 0x53, 0x21, 0x16, 0xad, 0x13, 0x3c, 0x95, 0x28, 0x42, 0x22, 0x74, 0xd, 0x8, 0x0, + 0xb, 0x2, 0x45, 0x31, 0xe7, 0x88, 0xbe, 0x65, 0xbe, 0xc0, 0xe8, 0xe1, 0x28, 0x0, 0x23, 0x27, 0x77, 0x29, 0xc6, + 0x17, 0x3d, 0x13, 0x2e, 0x57, 0x29, 0x99, 0x29, 0x21, 0x18, 0x0, 0x0, 0x36, 0x24, 0x16, 0x0, 0x3, 0xe9, 0x5c, + 0x94, 0x3, 0x0, 0x19, 0x3e, 0x18, 0x19, 0xad, 0x19, 0xc8, 0x8a, 0x9b, 0x99, 0x1a, 0x86, 0x3d, 0x11, 0x31, 0x34, + 0x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xab, 0x2, 0x0, + 0x0, 0x3c, 0x7c, 0x8, 0x0, 0xf, 0x42, 0x1a, 0xb5, 0xca, 0x9a, 0x2d, 0xa5, 0x9d, 0xef, 0x60, 0x96, 0x28, 0xa6, + 0xc9, 0x92, 0x9, 0x0, 0x5, 0xcf, 0xdc, 0xa7, 0xac, 0x1c, 0x26, 0x0, 0x13, 0xeb, 0xd1, 0xff, 0x9a, 0x43, 0x11, + 0x9b, 0x4b, 0x2f, 0x10, 0xb7, 0x64, 0x37, 0x49, 0x62, 0xa7, 0x4a, 0x80, 0x39, 0x0, 0x5, 0xc0, 0xbe, 0x13, 0xed, + 0xc7, 0x1c, 0x0, 0x6, 0xa, 0x24, 0x1d, 0xb8, 0x67, 0x23, 0x1, 0xe6, 0x13, 0x9, 0x2, 0x2a, 0x67, 0x0, 0x1c, + 0x6e, 0xdd, 0x2e, 0x67, 0xe7, 0xd1, 0x5b, 0x61, 0x2a, 0x6e, 0x27, 0xd6, 0x61, 0x6c, 0x93, 0xf1, 0x24, 0xaf, 0x27, + 0x2d, 0x4a, 0x8c, 0xd9, 0xaf, 0x98, 0x82, 0x9b, 0xe8, 0x0, 0x9, 0x1f, 0xa1, 0xec, 0x12, 0x8a, 0xd3, 0x5f, 0x1b, + 0xf4}; + + uint8_t buf[429] = {0}; + + uint8_t bytesprops0[] = {0x71, 0x67, 0xaa, 0x7f, 0xc0, 0xc2, 0x56, 0x82, 0x3c, + 0xe2, 0x55, 0x8b, 0xa6, 0x35, 0x22, 0x51, 0x70}; + uint8_t bytesprops1[] = {0x2, 0x45, 0x31, 0xe7, 0x88, 0xbe, 0x65, 0xbe, 0xc0, 0xe8, 0xe1}; + uint8_t bytesprops2[] = {0xe9, 0x5c, 0x94}; + uint8_t bytesprops3[] = {0x3e, 0x18, 0x19, 0xad, 0x19, 0xc8, 0x8a, 0x9b, 0x99, 0x1a, 0x86, 0x3d, 0x11, + 0x31, 0x34, 0xe5, 0xac, 0xa2, 0x77, 0x12, 0x8d, 0x71, 0xba, 0xbc, 0xab}; + uint8_t bytesprops4[] = {0x26, 0xf0, 0x2f, 0xa7, 0x45, 0x96, 0xee, 0x41, 0xbe, 0x6f, 0xfc, 0x83, 0x8b, 0x33}; + uint8_t bytesprops5[] = {0x80, 0x90, 0xfd, 0xf4, 0x65, 0xee, 0x9e, 0x55, 0x7e, + 0x8b, 0x4, 0x55, 0x22, 0x6e, 0xa4, 0xb, 0xe5, 0x30}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2214}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5805}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15509}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29709}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10103}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11863}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13860}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 223}}, + }; + + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xba, 0x28, 0x4a}; + uint8_t byteswillprops2[] = {0x3b, 0xeb, 0x5c, 0x11, 0x92, 0xff, 0xb9, 0x6}; + uint8_t byteswillprops1[] = {0}; + uint8_t byteswillprops3[] = {0xa7, 0x47, 0xc6, 0x7, 0xf9, 0x96, 0xb8, 0xc3, 0xd2, 0x82, 0xf9, + 0x1a, 0xce, 0x7f, 0xf9, 0x6d, 0xb9, 0x3a, 0xb6, 0xe0, 0xb1, 0xfe}; + uint8_t byteswillprops5[] = {0x3e, 0xe8, 0x29, 0xe, 0x76, 0xb, 0xd, 0x46, + 0xc7, 0x47, 0x11, 0x6c, 0x39, 0xe0, 0x2e, 0xfb}; + uint8_t byteswillprops4[] = {0x69, 0x34, 0xa, 0xe8, 0x69, 0x7a, 0xbf, 0x1d}; + uint8_t byteswillprops6[] = {0xd2, 0xdf, 0xb7, 0xd1, 0x16, 0x7a, 0x28, 0x69, 0xa4, 0x9f, 0x20, 0x79, 0x6d, 0xce, 0xaa, + 0xe0, 0xaf, 0xe9, 0x3a, 0x2f, 0xa5, 0xac, 0x59, 0xb7, 0x58, 0xd, 0x26, 0x7d, 0x30}; + uint8_t byteswillprops7[] = {0x42, 0x1a, 0xb5, 0xca, 0x9a, 0x2d, 0xa5, 0x9d, + 0xef, 0x60, 0x96, 0x28, 0xa6, 0xc9, 0x92}; + uint8_t byteswillprops8[] = {0xcf, 0xdc, 0xa7, 0xac, 0x1c}; + uint8_t byteswillprops10[] = {0xc0, 0xbe, 0x13, 0xed, 0xc7}; + uint8_t byteswillprops9[] = {0xeb, 0xd1, 0xff, 0x9a, 0x43, 0x11, 0x9b, 0x4b, 0x2f, 0x10, + 0xb7, 0x64, 0x37, 0x49, 0x62, 0xa7, 0x4a, 0x80, 0x39}; + uint8_t byteswillprops11[] = {0xa, 0x24, 0x1d, 0xb8, 0x67, 0x23}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27954}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {0, (char*)&byteswillprops1}, .v = {8, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18528}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {8, (char*)&byteswillprops4}, .v = {16, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4523}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15484}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {19, (char*)&byteswillprops9}, .v = {5, (char*)&byteswillprops10}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2306}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, + }; + + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x6e, 0xdd, 0x2e, 0x67, 0xe7, 0xd1, 0x5b, 0x61, 0x2a, 0x6e, 0x27, 0xd6, 0x61, 0x6c, + 0x93, 0xf1, 0x24, 0xaf, 0x27, 0x2d, 0x4a, 0x8c, 0xd9, 0xaf, 0x98, 0x82, 0x9b, 0xe8}; + lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1f, 0xa1, 0xec, 0x12, 0x8a, 0xd3, 0x5f, 0x1b, 0xf4}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 9181; + uint8_t client_id_bytes[] = {0x4d, 0x9c, 0x14, 0x85, 0x5a, 0xcd, 0x15, 0x26}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x1, 0xfd, 0x80, 0x68, 0xd6, 0x88, 0x3e, 0xf4, 0x3c, 0xff, 0x99}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\227\ESCQ", _password = Just "\231\239\188\247\236\FSU\172\t\232D", _lastWill = +// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "(7<,XJ9\ETB\231t\245\245\214\208\FSj\131", +// _willMsg = "", _willProps = [PropMaximumPacketSize 13992,PropUserProperty "\165\145\192A\164~wb\153\252\SYN" +// "e\167\ETX\STX|j\a\160\185\229o\155\176\168\167\b",PropSharedSubscriptionAvailable 66,PropContentType +// "'\SOH\196\&9,5\209",PropWillDelayInterval 17285,PropSessionExpiryInterval 8449,PropSessionExpiryInterval +// 18445,PropReceiveMaximum 5075,PropSubscriptionIdentifierAvailable 202,PropResponseInformation "",PropResponseTopic +// "\214^\190c\RS\171nC)O",PropTopicAliasMaximum 21628,PropAuthenticationMethod +// "\176mT\ETX\141\236\172$[>)\207\&5\144",PropServerReference +// "\188\153\146\SI\218\197c\ACK0l\f\160\245y1<\235\146\130\135v\bfs\250",PropSubscriptionIdentifier +// 29,PropMaximumPacketSize 31692]}), _cleanSession = False, _keepAlive = 3405, _connID = "\229sD\131\227v\232^4n0", +// _properties = [PropTopicAlias 29021,PropSharedSubscriptionAvailable 181,PropServerReference +// "\224?\161\230\151;\255\216\204^\158\151\SYNL\175\128",PropWildcardSubscriptionAvailable +// 226,PropAssignedClientIdentifier +// "\176^iwh\SO\EOTV\250\249\220\247@\228i}c\DLE\207\246\131\218\135\215*",PropAuthenticationMethod +// "g\152\CAN{N\183d#\152\192\151",PropPayloadFormatIndicator 186,PropSubscriptionIdentifierAvailable +// 90,PropRetainAvailable 227,PropReasonString "",PropRequestResponseInformation 124,PropReasonString +// "\NAK\142\"\242#\198\214\220+k\144\147\GS\210\152",PropReceiveMaximum 12762,PropServerKeepAlive +// 16767,PropAssignedClientIdentifier "\245\230; R\FSU\247\236\149x\ENQsxqD\158\144;",PropMessageExpiryInterval +// 21735,PropAuthenticationMethod "q\139\236*O\a\179",PropSubscriptionIdentifier 2,PropReasonString +// "",PropSubscriptionIdentifierAvailable 103,PropAuthenticationData +// "\194\&76\250\253\ETX0\179q\218\162\138",PropReceiveMaximum 30578,PropMaximumPacketSize +// 21991,PropAssignedClientIdentifier "z\135,\185\191?\201\160:",PropResponseInformation +// "\DELP0`\209\168\tT\\L\DC2\a\134\254[\ACK$d#\DC4|c\226\167Md\t\177\217U",PropReasonString +// "\252\135\192\DC2\192\172,\RS\228\252\r&\139\191\235 A\DC1"]} +TEST(Connect5QCTest, Encode71) { + uint8_t pkt[] = { + 0x10, 0xca, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0xd, 0x4d, 0xec, 0x1, 0x23, 0x71, 0x5d, 0x2a, + 0xb5, 0x1c, 0x0, 0x10, 0xe0, 0x3f, 0xa1, 0xe6, 0x97, 0x3b, 0xff, 0xd8, 0xcc, 0x5e, 0x9e, 0x97, 0x16, 0x4c, 0xaf, + 0x80, 0x28, 0xe2, 0x12, 0x0, 0x19, 0xb0, 0x5e, 0x69, 0x77, 0x68, 0xe, 0x4, 0x56, 0xfa, 0xf9, 0xdc, 0xf7, 0x40, + 0xe4, 0x69, 0x7d, 0x63, 0x10, 0xcf, 0xf6, 0x83, 0xda, 0x87, 0xd7, 0x2a, 0x15, 0x0, 0xb, 0x67, 0x98, 0x18, 0x7b, + 0x4e, 0xb7, 0x64, 0x23, 0x98, 0xc0, 0x97, 0x1, 0xba, 0x29, 0x5a, 0x25, 0xe3, 0x1f, 0x0, 0x0, 0x19, 0x7c, 0x1f, + 0x0, 0xf, 0x15, 0x8e, 0x22, 0xf2, 0x23, 0xc6, 0xd6, 0xdc, 0x2b, 0x6b, 0x90, 0x93, 0x1d, 0xd2, 0x98, 0x21, 0x31, + 0xda, 0x13, 0x41, 0x7f, 0x12, 0x0, 0x13, 0xf5, 0xe6, 0x3b, 0x20, 0x52, 0x1c, 0x55, 0xf7, 0xec, 0x95, 0x78, 0x5, + 0x73, 0x78, 0x71, 0x44, 0x9e, 0x90, 0x3b, 0x2, 0x0, 0x0, 0x54, 0xe7, 0x15, 0x0, 0x7, 0x71, 0x8b, 0xec, 0x2a, + 0x4f, 0x7, 0xb3, 0xb, 0x2, 0x1f, 0x0, 0x0, 0x29, 0x67, 0x16, 0x0, 0xc, 0xc2, 0x37, 0x36, 0xfa, 0xfd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x87, 0x76, 0x8, 0x66, + 0x73, 0xfa, 0xb, 0x1d, 0x27, 0x0, 0x0, 0x7b, 0xcc, 0x0, 0x1b, 0x18, 0xe4, 0x89, 0x65, 0x61, 0x8, 0x11, 0xe6, + 0xbc, 0x42, 0x8, 0xb9, 0xa1, 0xd5, 0xfa, 0x3a, 0xd6, 0x1e, 0x4c, 0x59, 0x4c, 0xc1, 0x9d, 0x4b, 0xbd, 0x52, 0x7e, + 0x0, 0x16, 0x5e, 0xbc, 0x78, 0xad, 0xe7, 0xf9, 0x53, 0x80, 0x39, 0x2, 0x25, 0x85, 0x6c, 0xad, 0x73, 0x87, 0x7b, + 0x46, 0xdd, 0xa9, 0x54, 0xfe, 0x0, 0x17, 0x7, 0x2e, 0xad, 0xbd, 0xbb, 0xc0, 0x35, 0x11, 0xf2, 0x40, 0x3, 0x47, + 0x49, 0xae, 0x72, 0xbd, 0xbf, 0xd5, 0x18, 0x34, 0xe9, 0x1, 0xc4, 0x0, 0xb, 0x69, 0x11, 0x6c, 0x55, 0xd2, 0xfd, + 0xcc, 0xd3, 0xe0, 0x14, 0xe4}; + + uint8_t buf[471] = {0}; + + uint8_t bytesprops0[] = {0xe0, 0x3f, 0xa1, 0xe6, 0x97, 0x3b, 0xff, 0xd8, + 0xcc, 0x5e, 0x9e, 0x97, 0x16, 0x4c, 0xaf, 0x80}; + uint8_t bytesprops1[] = {0xb0, 0x5e, 0x69, 0x77, 0x68, 0xe, 0x4, 0x56, 0xfa, 0xf9, 0xdc, 0xf7, 0x40, + 0xe4, 0x69, 0x7d, 0x63, 0x10, 0xcf, 0xf6, 0x83, 0xda, 0x87, 0xd7, 0x2a}; + uint8_t bytesprops2[] = {0x67, 0x98, 0x18, 0x7b, 0x4e, 0xb7, 0x64, 0x23, 0x98, 0xc0, 0x97}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x15, 0x8e, 0x22, 0xf2, 0x23, 0xc6, 0xd6, 0xdc, 0x2b, 0x6b, 0x90, 0x93, 0x1d, 0xd2, 0x98}; + uint8_t bytesprops5[] = {0xf5, 0xe6, 0x3b, 0x20, 0x52, 0x1c, 0x55, 0xf7, 0xec, 0x95, + 0x78, 0x5, 0x73, 0x78, 0x71, 0x44, 0x9e, 0x90, 0x3b}; + uint8_t bytesprops6[] = {0x71, 0x8b, 0xec, 0x2a, 0x4f, 0x7, 0xb3}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops8[] = {0xc2, 0x37, 0x36, 0xfa, 0xfd, 0x3, 0x30, 0xb3, 0x71, 0xda, 0xa2, 0x8a}; + uint8_t bytesprops9[] = {0x7a, 0x87, 0x2c, 0xb9, 0xbf, 0x3f, 0xc9, 0xa0, 0x3a}; + uint8_t bytesprops10[] = {0x7f, 0x50, 0x30, 0x60, 0xd1, 0xa8, 0x9, 0x54, 0x5c, 0x4c, 0x12, 0x7, 0x86, 0xfe, 0x5b, + 0x6, 0x24, 0x64, 0x23, 0x14, 0x7c, 0x63, 0xe2, 0xa7, 0x4d, 0x64, 0x9, 0xb1, 0xd9, 0x55}; + uint8_t bytesprops11[] = {0xfc, 0x87, 0xc0, 0x12, 0xc0, 0xac, 0x2c, 0x1e, 0xe4, + 0xfc, 0xd, 0x26, 0x8b, 0xbf, 0xeb, 0x20, 0x41, 0x11}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29021}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12762}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16767}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21735}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30578}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21991}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops11}}}, + }; + + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x37, 0x98, 0x15, 0xf6, 0x6c, 0x32, 0x8f, 0xb7, 0xab, 0x41}; + uint8_t byteswillprops1[] = {0xb5, 0x41}; + uint8_t byteswillprops2[] = {0x6b, 0x98, 0x14, 0x18, 0x3, 0x4c, 0xbb, 0x70, 0xd5, 0x5f, 0x12, + 0x3e, 0x5e, 0xbe, 0x63, 0x1e, 0xab, 0x6e, 0x43, 0x29, 0x4f}; + uint8_t byteswillprops3[] = {0xb0, 0x6d, 0x54, 0x3, 0x8d, 0xec, 0xac, 0x24, 0x5b, 0x3e, 0x29, 0xcf, 0x35, 0x90}; + uint8_t byteswillprops4[] = {0xbc, 0x99, 0x92, 0xf, 0xda, 0xc5, 0x63, 0x6, 0x30, 0x6c, 0xc, 0xa0, 0xf5, + 0x79, 0x31, 0x3c, 0xeb, 0x92, 0x82, 0x87, 0x76, 0x8, 0x66, 0x73, 0xfa}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21628}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31692}}, + }; + + lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x18, 0xe4, 0x89, 0x65, 0x61, 0x8, 0x11, 0xe6, 0xbc, 0x42, 0x8, 0xb9, 0xa1, 0xd5, + 0xfa, 0x3a, 0xd6, 0x1e, 0x4c, 0x59, 0x4c, 0xc1, 0x9d, 0x4b, 0xbd, 0x52, 0x7e}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5e, 0xbc, 0x78, 0xad, 0xe7, 0xf9, 0x53, 0x80, 0x39, 0x2, 0x25, + 0x85, 0x6c, 0xad, 0x73, 0x87, 0x7b, 0x46, 0xdd, 0xa9, 0x54, 0xfe}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3405; + uint8_t client_id_bytes[] = {0xe5, 0x73, 0x44, 0x83, 0xe3, 0x76, 0xe8, 0x5e, 0x34, 0x6e, 0x30}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x7, 0x2e, 0xad, 0xbd, 0xbb, 0xc0, 0x35, 0x11, 0xf2, 0x40, 0x3, 0x47, + 0x49, 0xae, 0x72, 0xbd, 0xbf, 0xd5, 0x18, 0x34, 0xe9, 0x1, 0xc4}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x69, 0x11, 0x6c, 0x55, 0xd2, 0xfd, 0xcc, 0xd3, 0xe0, 0x14, 0xe4}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "a", _password = Just "@\CAN\194hS*r\ESC'\162\SUB\222P\218g\250\&5\aN\nf\ETX\246", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\135!\172j\177\193\187\202+&FH\SO", +// _willMsg = "g\144@\161F\215\147>\217\b\228\146\186\ETB\234\252\208\201", _willProps = +// [PropSharedSubscriptionAvailable 52,PropUserProperty +// "\206\154\130\229\136\166~:\EOTZ\136\253\164\184\134RS8~\212a\161\&6h\185\202\tG\229" +// "\198Z\148b4\167\246\209\193V\ACK",PropAuthenticationData +// "\224\132\219*[8\SUB\209\&8\232c\DC1\152L\ETX\174\191y\NUL\210KOz\137\197\243Q",PropContentType +// "?os\201e$\226F\169u\242\242d\137/\233\254",PropSessionExpiryInterval 22845,PropMaximumQoS 56,PropRetainAvailable +// 185,PropAssignedClientIdentifier "P\162\CAN\136\137NK]~\179\205F\176",PropContentType +// "H\218\179\&2\193]$\191\SUB\220\236x\211k\254\231\142\DLE\222\243\DC4F\DEL:\ENQ",PropRequestResponseInformation +// 55,PropMessageExpiryInterval 15612,PropCorrelationData +// "\SOH!.\194G~\DC4g\136z\131\229\255O\245\211\226\171(\243u\174j#",PropRequestResponseInformation +// 140,PropAuthenticationMethod "\197",PropAuthenticationMethod "\225\195~m\249\DC1\a\f +// \214\203\234C",PropWildcardSubscriptionAvailable 45,PropMessageExpiryInterval 13177,PropUserProperty +// "t.Pc\ENQ\250\200\CAN\198}Fp4g\205D\185\249" "\ACK\CANtZ\DC4\133\182c5h\161;J +// \215\154D0r",PropSharedSubscriptionAvailable 171,PropRetainAvailable 36,PropSessionExpiryInterval +// 32065,PropReceiveMaximum 16540,PropCorrelationData +// "\230C\153\&3\179\255\\\166\209$\158\223@\160",PropResponseInformation "\176s\227jL'U\133a\233\144\228\215\254"]}), +// _cleanSession = True, _keepAlive = 19693, _connID = "\140\204\191\171.BtU+cj", _properties = [PropRetainAvailable +// 22,PropSessionExpiryInterval 8887,PropSharedSubscriptionAvailable 25,PropWildcardSubscriptionAvailable +// 185,PropServerReference +// "\142\223\SUB\ETX\242\ETX\172\232\248\232\\\189\171\212\141\DC4x\216\162\229\140\GS\158\151\235",PropRetainAvailable +// 182,PropResponseInformation "=\226\238\222\247\204\141\218Z2\STX\131\147\&3FE\200C\217\198",PropRetainAvailable +// 193,PropWildcardSubscriptionAvailable 79,PropServerReference +// "\190\DC32\237\&6\133\211\236\215\218\134\f\164%-\193\214\161Vs"]} +TEST(Connect5QCTest, Enc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20, 0xd7, 0x9a, 0x44, 0x30, 0x72, 0x2a, 0xab, 0x25, 0x24, 0x11, + 0x0, 0x0, 0x7d, 0x41, 0x21, 0x40, 0x9c, 0x9, 0x0, 0xe, 0xe6, 0x43, 0x99, 0x33, 0xb3, 0xff, 0x5c, 0xa6, 0xd1, + 0x24, 0x9e, 0xdf, 0x40, 0xa0, 0x1a, 0x0, 0xe, 0xb0, 0x73, 0xe3, 0x6a, 0x4c, 0x27, 0x55, 0x85, 0x61, 0xe9, 0x90, + 0xe4, 0xd7, 0xfe, 0x0, 0xd, 0x87, 0x21, 0xac, 0x6a, 0xb1, 0xc1, 0xbb, 0xca, 0x2b, 0x26, 0x46, 0x48, 0xe, 0x0, + 0x12, 0x67, 0x90, 0x40, 0xa1, 0x46, 0xd7, 0x93, 0x3e, 0xd9, 0x8, 0xe4, 0x92, 0xba, 0x17, 0xea, 0xfc, 0xd0, 0xc9, + 0x0, 0x1, 0x61, 0x0, 0x17, 0x40, 0x18, 0xc2, 0x68, 0x53, 0x2a, 0x72, 0x1b, 0x27, 0xa2, 0x1a, 0xde, 0x50, 0xda, + 0x67, 0xfa, 0x35, 0x7, 0x4e, 0xa, 0x66, 0x3, 0xf6}; + + uint8_t buf[494] = {0}; + + uint8_t bytesprops0[] = {0x8e, 0xdf, 0x1a, 0x3, 0xf2, 0x3, 0xac, 0xe8, 0xf8, 0xe8, 0x5c, 0xbd, 0xab, + 0xd4, 0x8d, 0x14, 0x78, 0xd8, 0xa2, 0xe5, 0x8c, 0x1d, 0x9e, 0x97, 0xeb}; + uint8_t bytesprops1[] = {0x3d, 0xe2, 0xee, 0xde, 0xf7, 0xcc, 0x8d, 0xda, 0x5a, 0x32, + 0x2, 0x83, 0x93, 0x33, 0x46, 0x45, 0xc8, 0x43, 0xd9, 0xc6}; + uint8_t bytesprops2[] = {0xbe, 0x13, 0x32, 0xed, 0x36, 0x85, 0xd3, 0xec, 0xd7, 0xda, + 0x86, 0xc, 0xa4, 0x25, 0x2d, 0xc1, 0xd6, 0xa1, 0x56, 0x73}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8887}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops2}}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xc6, 0x5a, 0x94, 0x62, 0x34, 0xa7, 0xf6, 0xd1, 0xc1, 0x56, 0x6}; + uint8_t byteswillprops0[] = {0xce, 0x9a, 0x82, 0xe5, 0x88, 0xa6, 0x7e, 0x3a, 0x4, 0x5a, 0x88, 0xfd, 0xa4, 0xb8, 0x86, + 0x52, 0x53, 0x38, 0x7e, 0xd4, 0x61, 0xa1, 0x36, 0x68, 0xb9, 0xca, 0x9, 0x47, 0xe5}; + uint8_t byteswillprops2[] = {0xe0, 0x84, 0xdb, 0x2a, 0x5b, 0x38, 0x1a, 0xd1, 0x38, 0xe8, 0x63, 0x11, 0x98, 0x4c, + 0x3, 0xae, 0xbf, 0x79, 0x0, 0xd2, 0x4b, 0x4f, 0x7a, 0x89, 0xc5, 0xf3, 0x51}; + uint8_t byteswillprops3[] = {0x3f, 0x6f, 0x73, 0xc9, 0x65, 0x24, 0xe2, 0x46, 0xa9, + 0x75, 0xf2, 0xf2, 0x64, 0x89, 0x2f, 0xe9, 0xfe}; + uint8_t byteswillprops4[] = {0x50, 0xa2, 0x18, 0x88, 0x89, 0x4e, 0x4b, 0x5d, 0x7e, 0xb3, 0xcd, 0x46, 0xb0}; + uint8_t byteswillprops5[] = {0x48, 0xda, 0xb3, 0x32, 0xc1, 0x5d, 0x24, 0xbf, 0x1a, 0xdc, 0xec, 0x78, 0xd3, + 0x6b, 0xfe, 0xe7, 0x8e, 0x10, 0xde, 0xf3, 0x14, 0x46, 0x7f, 0x3a, 0x5}; + uint8_t byteswillprops6[] = {0x1, 0x21, 0x2e, 0xc2, 0x47, 0x7e, 0x14, 0x67, 0x88, 0x7a, 0x83, 0xe5, + 0xff, 0x4f, 0xf5, 0xd3, 0xe2, 0xab, 0x28, 0xf3, 0x75, 0xae, 0x6a, 0x23}; + uint8_t byteswillprops7[] = {0xc5}; + uint8_t byteswillprops8[] = {0xe1, 0xc3, 0x7e, 0x6d, 0xf9, 0x11, 0x7, 0xc, 0x20, 0xd6, 0xcb, 0xea, 0x43}; + uint8_t byteswillprops10[] = {0x6, 0x18, 0x74, 0x5a, 0x14, 0x85, 0xb6, 0x63, 0x35, 0x68, + 0xa1, 0x3b, 0x4a, 0x20, 0xd7, 0x9a, 0x44, 0x30, 0x72}; + uint8_t byteswillprops9[] = {0x74, 0x2e, 0x50, 0x63, 0x5, 0xfa, 0xc8, 0x18, 0xc6, + 0x7d, 0x46, 0x70, 0x34, 0x67, 0xcd, 0x44, 0xb9, 0xf9}; + uint8_t byteswillprops11[] = {0xe6, 0x43, 0x99, 0x33, 0xb3, 0xff, 0x5c, 0xa6, 0xd1, 0x24, 0x9e, 0xdf, 0x40, 0xa0}; + uint8_t byteswillprops12[] = {0xb0, 0x73, 0xe3, 0x6a, 0x4c, 0x27, 0x55, 0x85, 0x61, 0xe9, 0x90, 0xe4, 0xd7, 0xfe}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {29, (char*)&byteswillprops0}, .v = {11, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22845}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15612}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13177}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {18, (char*)&byteswillprops9}, .v = {19, (char*)&byteswillprops10}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32065}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16540}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&byteswillprops12}}}, + }; + + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x87, 0x21, 0xac, 0x6a, 0xb1, 0xc1, 0xbb, 0xca, 0x2b, 0x26, 0x46, 0x48, 0xe}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x67, 0x90, 0x40, 0xa1, 0x46, 0xd7, 0x93, 0x3e, 0xd9, + 0x8, 0xe4, 0x92, 0xba, 0x17, 0xea, 0xfc, 0xd0, 0xc9}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 19693; + uint8_t client_id_bytes[] = {0x8c, 0xcc, 0xbf, 0xab, 0x2e, 0x42, 0x74, 0x55, 0x2b, 0x63, 0x6a}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x61}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x40, 0x18, 0xc2, 0x68, 0x53, 0x2a, 0x72, 0x1b, 0x27, 0xa2, 0x1a, 0xde, + 0x50, 0xda, 0x67, 0xfa, 0x35, 0x7, 0x4e, 0xa, 0x66, 0x3, 0xf6}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\172\219m,\215\&1j\218 +// $\179\198q\177c\172\251|\145\151)\ACKk\199\226\192\131\161\SO", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS1, _willTopic = "\253X\142\n\160\NUL\146\171ng\\\NAK\186Q\142\165\NUL\ETX6\212\255d\134|\252\181!av)", +// _willMsg = "}1\182T-u\251\128", _willProps = [PropPayloadFormatIndicator 6,PropResponseInformation +// "\179Q$t\211=\DC4\219.\223A\STX\CAN\EM\f\150"]}), _cleanSession = False, _keepAlive = 12479, _connID = +// "\160\198\DC2f\138Q\188Q\138!y\131\141\&4\255\149\228$=Tx\SOHa\231", _properties = [PropMessageExpiryInterval +// 31115,PropResponseTopic "\206v\205\SI*.o\153\156S\221*\SUBd\131B\229\EM\DLEb!\205",PropAuthenticationMethod +// "\197'\183\128\201\\\179\204\202\222",PropPayloadFormatIndicator 249,PropUserProperty +// "\171X\SO|:\t\164\164e\220\SOHna\243\194\195\168\191\209?j\149 \v" +// "u\188\217\EM\217\175{L|\188\v\STXx+\253\STX\ESC\207",PropRequestProblemInformation 50,PropResponseTopic +// "lg\ACKZ'\182\206\137\&2(*\247^\214\145\146\184\US\202m]\SYN\221f\243",PropRequestProblemInformation +// 107,PropTopicAliasMaximum 25143,PropRetainAvailable 27,PropPayloadFormatIndicator 20,PropServerReference "\r\200m +// \247\155\198\ETX\240\223\137X\220\242\230\SOH\193a\SOHQC\232\247d",PropPayloadFormatIndicator +// 235,PropResponseInformation +// "\NUL\186\170\145\&2\DC3\243\ENQ_\FS\188\133}a\148\132\bu\241\136\213{\227\&1",PropAuthenticationMethod +// "\194\148'\236\DC4\196\EOT\249\128\144\&0\b\239\235W0\172\&1\207\170Pv\243.\RS\241%\226P\208",PropSessionExpiryInterval +// 27855]} +TEST(Connect5QCTest, Encode73) { + uint8_t pkt[] = { + 0x10, 0xc7, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc, 0x30, 0xbf, 0xe1, 0x1, 0x2, 0x0, 0x0, 0x79, + 0x8b, 0x8, 0x0, 0x16, 0xce, 0x76, 0xcd, 0xf, 0x2a, 0x2e, 0x6f, 0x99, 0x9c, 0x53, 0xdd, 0x2a, 0x1a, 0x64, 0x83, + 0x42, 0xe5, 0x19, 0x10, 0x62, 0x21, 0xcd, 0x15, 0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0xe2, 0x50, 0xd0, 0x11, 0x0, 0x0, 0x6c, 0xcf, 0x0, 0x18, 0xa0, 0xc6, 0x12, 0x66, 0x8a, + 0x51, 0xbc, 0x51, 0x8a, 0x21, 0x79, 0x83, 0x8d, 0x34, 0xff, 0x95, 0xe4, 0x24, 0x3d, 0x54, 0x78, 0x1, 0x61, 0xe7, + 0x15, 0x1, 0x6, 0x1a, 0x0, 0x10, 0xb3, 0x51, 0x24, 0x74, 0xd3, 0x3d, 0x14, 0xdb, 0x2e, 0xdf, 0x41, 0x2, 0x18, + 0x19, 0xc, 0x96, 0x0, 0x1e, 0xfd, 0x58, 0x8e, 0xa, 0xa0, 0x0, 0x92, 0xab, 0x6e, 0x67, 0x5c, 0x15, 0xba, 0x51, + 0x8e, 0xa5, 0x0, 0x3, 0x36, 0xd4, 0xff, 0x64, 0x86, 0x7c, 0xfc, 0xb5, 0x21, 0x61, 0x76, 0x29, 0x0, 0x8, 0x7d, + 0x31, 0xb6, 0x54, 0x2d, 0x75, 0xfb, 0x80}; + + uint8_t buf[340] = {0}; + + uint8_t bytesprops0[] = {0xce, 0x76, 0xcd, 0xf, 0x2a, 0x2e, 0x6f, 0x99, 0x9c, 0x53, 0xdd, + 0x2a, 0x1a, 0x64, 0x83, 0x42, 0xe5, 0x19, 0x10, 0x62, 0x21, 0xcd}; + uint8_t bytesprops1[] = {0xc5, 0x27, 0xb7, 0x80, 0xc9, 0x5c, 0xb3, 0xcc, 0xca, 0xde}; + uint8_t bytesprops3[] = {0x75, 0xbc, 0xd9, 0x19, 0xd9, 0xaf, 0x7b, 0x4c, 0x7c, + 0xbc, 0xb, 0x2, 0x78, 0x2b, 0xfd, 0x2, 0x1b, 0xcf}; + uint8_t bytesprops2[] = {0xab, 0x58, 0xe, 0x7c, 0x3a, 0x9, 0xa4, 0xa4, 0x65, 0xdc, 0x1, 0x6e, + 0x61, 0xf3, 0xc2, 0xc3, 0xa8, 0xbf, 0xd1, 0x3f, 0x6a, 0x95, 0x20, 0xb}; + uint8_t bytesprops4[] = {0x6c, 0x67, 0x6, 0x5a, 0x27, 0xb6, 0xce, 0x89, 0x32, 0x28, 0x2a, 0xf7, 0x5e, + 0xd6, 0x91, 0x92, 0xb8, 0x1f, 0xca, 0x6d, 0x5d, 0x16, 0xdd, 0x66, 0xf3}; + uint8_t bytesprops5[] = {0xd, 0xc8, 0x6d, 0x20, 0xf7, 0x9b, 0xc6, 0x3, 0xf0, 0xdf, 0x89, 0x58, + 0xdc, 0xf2, 0xe6, 0x1, 0xc1, 0x61, 0x1, 0x51, 0x43, 0xe8, 0xf7, 0x64}; + uint8_t bytesprops6[] = {0x0, 0xba, 0xaa, 0x91, 0x32, 0x13, 0xf3, 0x5, 0x5f, 0x1c, 0xbc, 0x85, + 0x7d, 0x61, 0x94, 0x84, 0x8, 0x75, 0xf1, 0x88, 0xd5, 0x7b, 0xe3, 0x31}; + uint8_t bytesprops7[] = {0xc2, 0x94, 0x27, 0xec, 0x14, 0xc4, 0x4, 0xf9, 0x80, 0x90, 0x30, 0x8, 0xef, 0xeb, 0x57, + 0x30, 0xac, 0x31, 0xcf, 0xaa, 0x50, 0x76, 0xf3, 0x2e, 0x1e, 0xf1, 0x25, 0xe2, 0x50, 0xd0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31115}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops2}, .v = {18, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25143}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27855}}, + }; + + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xb3, 0x51, 0x24, 0x74, 0xd3, 0x3d, 0x14, 0xdb, + 0x2e, 0xdf, 0x41, 0x2, 0x18, 0x19, 0xc, 0x96}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops0}}}, + }; + + lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xfd, 0x58, 0x8e, 0xa, 0xa0, 0x0, 0x92, 0xab, 0x6e, 0x67, + 0x5c, 0x15, 0xba, 0x51, 0x8e, 0xa5, 0x0, 0x3, 0x36, 0xd4, + 0xff, 0x64, 0x86, 0x7c, 0xfc, 0xb5, 0x21, 0x61, 0x76, 0x29}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7d, 0x31, 0xb6, 0x54, 0x2d, 0x75, 0xfb, 0x80}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 12479; + uint8_t client_id_bytes[] = {0xa0, 0xc6, 0x12, 0x66, 0x8a, 0x51, 0xbc, 0x51, 0x8a, 0x21, 0x79, 0x83, + 0x8d, 0x34, 0xff, 0x95, 0xe4, 0x24, 0x3d, 0x54, 0x78, 0x1, 0x61, 0xe7}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xac, 0xdb, 0x6d, 0x2c, 0xd7, 0x31, 0x6a, 0xda, 0x20, 0x24, 0xb3, 0xc6, 0x71, 0xb1, 0x63, + 0xac, 0xfb, 0x7c, 0x91, 0x97, 0x29, 0x6, 0x6b, 0xc7, 0xe2, 0xc0, 0x83, 0xa1, 0xe}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\186>\208\176\160\b\130H\DC3\FS\nw@\180M\223\f}~\163s\234_", _password = Nothing, +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "h ", _willMsg = +// "\136Jb\133\241\194\237\174\234.J\DEL\213\CAN\189A\167\182", _willProps = [PropResponseInformation +// "\242r\139q\200\EM\r5",PropServerReference "\144H\212\165\186+\t\159\228U\SOH[D\141",PropSessionExpiryInterval +// 29968,PropTopicAliasMaximum 19634,PropMessageExpiryInterval 32147,PropReasonString +// "(\250\142\167A?\214\252c\245\153",PropAuthenticationData +// "\188\179\192\210\RS\178\133\197\\\212\RS\245\213{j\154\b\DEL\130\247\166",PropRetainAvailable +// 227,PropTopicAliasMaximum 627,PropAuthenticationMethod "",PropAuthenticationData "",PropMessageExpiryInterval +// 26962,PropReasonString "\b\251-|\132EL\aX",PropResponseInformation "\134\SYN8",PropAuthenticationData +// "\194\241{\172Br\STX\156\153\195Y\200\167\144AJV\229P\135\155"]}), _cleanSession = False, _keepAlive = 15269, _connID +// = "\151O\SUBd\191\216\184\130k$\237[9\159\\\STX\130\196~\DLE\222\ESC\198}\157\129w\n", _properties = +// [PropAssignedClientIdentifier "\NUL\230W\EOTdV\160\232",PropMessageExpiryInterval 22106,PropTopicAliasMaximum +// 25843,PropTopicAliasMaximum 12574,PropReasonString "\241K\130\208",PropResponseInformation +// "M>\216\ETB\205\223\186",PropMessageExpiryInterval 5857,PropAuthenticationData "\NULZ\231\157",PropReceiveMaximum +// 13735,PropTopicAlias 8358,PropTopicAliasMaximum 21535,PropServerReference "\227\238^E\154\141\FS\153\ACK9}\134\238 +// \240hT",PropAuthenticationMethod +// "\196L\182\ETBgp\253D\129\131\223\210m\140B\210\182)\181`y\251\147\192\197Z\246P\217",PropTopicAlias +// 3384,PropRequestProblemInformation 175,PropSessionExpiryInterval 23888,PropServerReference +// "\152\135\180\234\193\200f\209\183U\173;\r\246\203D\194\174_\SO\170ox\160\190+\135\195",PropSubscriptionIdentifier +// 27,PropResponseInformation +// "\164\212\147\148$s*C\195\202\n\148\DLE0\221\SYN\156\146=\DEL\EOT\192\CAN\203X",PropAuthenticationData +// "Xv\139S\153\219\160\ESC}J",PropWillDelayInterval 12717,PropMaximumQoS 193,PropSessionExpiryInterval +// 1719,PropWildcardSubscriptionAvailable 149,PropMaximumQoS 132,PropMaximumPacketSize +// 19992,PropSubscriptionIdentifierAvailable 154]} +TEST(Connect5QCTest, Encode74) { + uint8_t pkt[] = { + 0x10, 0xc1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x94, 0x3b, 0xa5, 0xdb, 0x1, 0x12, 0x0, 0x8, 0x0, + 0xe6, 0x57, 0x4, 0x64, 0x56, 0xa0, 0xe8, 0x2, 0x0, 0x0, 0x56, 0x5a, 0x22, 0x64, 0xf3, 0x22, 0x31, 0x1e, 0x1f, + 0x0, 0x4, 0xf1, 0x4b, 0x82, 0xd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, + 0x2e, 0x4a, 0x7f, 0xd5, 0x18, 0xbd, 0x41, 0xa7, 0xb6, 0x0, 0x17, 0xba, 0x3e, 0xd0, 0xb0, 0xa0, 0x8, 0x82, 0x48, + 0x13, 0x1c, 0xa, 0x77, 0x40, 0xb4, 0x4d, 0xdf, 0xc, 0x7d, 0x7e, 0xa3, 0x73, 0xea, 0x5f}; + + uint8_t buf[462] = {0}; + + uint8_t bytesprops0[] = {0x0, 0xe6, 0x57, 0x4, 0x64, 0x56, 0xa0, 0xe8}; + uint8_t bytesprops1[] = {0xf1, 0x4b, 0x82, 0xd0}; + uint8_t bytesprops2[] = {0x4d, 0x3e, 0xd8, 0x17, 0xcd, 0xdf, 0xba}; + uint8_t bytesprops3[] = {0x0, 0x5a, 0xe7, 0x9d}; + uint8_t bytesprops4[] = {0xe3, 0xee, 0x5e, 0x45, 0x9a, 0x8d, 0x1c, 0x99, 0x6, + 0x39, 0x7d, 0x86, 0xee, 0x20, 0xf0, 0x68, 0x54}; + uint8_t bytesprops5[] = {0xc4, 0x4c, 0xb6, 0x17, 0x67, 0x70, 0xfd, 0x44, 0x81, 0x83, 0xdf, 0xd2, 0x6d, 0x8c, 0x42, + 0xd2, 0xb6, 0x29, 0xb5, 0x60, 0x79, 0xfb, 0x93, 0xc0, 0xc5, 0x5a, 0xf6, 0x50, 0xd9}; + uint8_t bytesprops6[] = {0x98, 0x87, 0xb4, 0xea, 0xc1, 0xc8, 0x66, 0xd1, 0xb7, 0x55, 0xad, 0x3b, 0xd, 0xf6, + 0xcb, 0x44, 0xc2, 0xae, 0x5f, 0xe, 0xaa, 0x6f, 0x78, 0xa0, 0xbe, 0x2b, 0x87, 0xc3}; + uint8_t bytesprops7[] = {0xa4, 0xd4, 0x93, 0x94, 0x24, 0x73, 0x2a, 0x43, 0xc3, 0xca, 0xa, 0x94, 0x10, + 0x30, 0xdd, 0x16, 0x9c, 0x92, 0x3d, 0x7f, 0x4, 0xc0, 0x18, 0xcb, 0x58}; + uint8_t bytesprops8[] = {0x58, 0x76, 0x8b, 0x53, 0x99, 0xdb, 0xa0, 0x1b, 0x7d, 0x4a}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22106}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25843}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12574}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5857}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13735}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8358}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21535}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3384}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23888}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12717}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1719}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19992}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 154}}, + }; + + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xf2, 0x72, 0x8b, 0x71, 0xc8, 0x19, 0xd, 0x35}; + uint8_t byteswillprops1[] = {0x90, 0x48, 0xd4, 0xa5, 0xba, 0x2b, 0x9, 0x9f, 0xe4, 0x55, 0x1, 0x5b, 0x44, 0x8d}; + uint8_t byteswillprops2[] = {0x28, 0xfa, 0x8e, 0xa7, 0x41, 0x3f, 0xd6, 0xfc, 0x63, 0xf5, 0x99}; + uint8_t byteswillprops3[] = {0xbc, 0xb3, 0xc0, 0xd2, 0x1e, 0xb2, 0x85, 0xc5, 0x5c, 0xd4, 0x1e, + 0xf5, 0xd5, 0x7b, 0x6a, 0x9a, 0x8, 0x7f, 0x82, 0xf7, 0xa6}; + uint8_t byteswillprops4[] = {0}; + uint8_t byteswillprops5[] = {0}; + uint8_t byteswillprops6[] = {0x8, 0xfb, 0x2d, 0x7c, 0x84, 0x45, 0x4c, 0x7, 0x58}; + uint8_t byteswillprops7[] = {0x86, 0x16, 0x38}; + uint8_t byteswillprops8[] = {0xc2, 0xf1, 0x7b, 0xac, 0x42, 0x72, 0x2, 0x9c, 0x99, 0xc3, 0x59, + 0xc8, 0xa7, 0x90, 0x41, 0x4a, 0x56, 0xe5, 0x50, 0x87, 0x9b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29968}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19634}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32147}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 627}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26962}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops8}}}, + }; + + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x68, 0x20}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x88, 0x4a, 0x62, 0x85, 0xf1, 0xc2, 0xed, 0xae, 0xea, + 0x2e, 0x4a, 0x7f, 0xd5, 0x18, 0xbd, 0x41, 0xa7, 0xb6}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 15269; + uint8_t client_id_bytes[] = {0x97, 0x4f, 0x1a, 0x64, 0xbf, 0xd8, 0xb8, 0x82, 0x6b, 0x24, 0xed, 0x5b, 0x39, 0x9f, + 0x5c, 0x2, 0x82, 0xc4, 0x7e, 0x10, 0xde, 0x1b, 0xc6, 0x7d, 0x9d, 0x81, 0x77, 0xa}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xba, 0x3e, 0xd0, 0xb0, 0xa0, 0x8, 0x82, 0x48, 0x13, 0x1c, 0xa, 0x77, + 0x40, 0xb4, 0x4d, 0xdf, 0xc, 0x7d, 0x7e, 0xa3, 0x73, 0xea, 0x5f}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "%_f0P\185\133\159\152\SOH\185\161\133\186\242\&0'", _password = Just +// "\166\165\148d\NAKy%\142\222\189,", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\222\254\185A\161\232i\ACK\180Z\146\192\254\182-\206\&8H\211\132", _willMsg = +// "\218\212\ACK\ESC\DC2_y\169\196A\228\195N\209;\219\138G\r\GS", _willProps = [PropRequestProblemInformation +// 77,PropSharedSubscriptionAvailable 90,PropSubscriptionIdentifierAvailable 75,PropServerReference +// "+\STX8v^n00@\142\165\ENQ\176\209\134%\180\139k_ #\220R"]}), _cleanSession = True, _keepAlive = 20166, _connID = +// "\ETBG\233\139e\tY\235MPwMH\208", _properties = [PropUserProperty "\234\253bJ+" "$",PropAssignedClientIdentifier +// ",\241\206f\241\RSJ2\DC3\NAK\136i\SOHDK!\237\136",PropSubscriptionIdentifierAvailable 138,PropReceiveMaximum +// 13275,PropSubscriptionIdentifierAvailable 32,PropRequestProblemInformation 72,PropTopicAliasMaximum +// 19915,PropWillDelayInterval 22210,PropAssignedClientIdentifier +// "8Vs*\191\200\128\ACKt\237\142\217\218",PropMaximumPacketSize 14118,PropRetainAvailable 34,PropResponseTopic +// "\205h\227\148",PropAssignedClientIdentifier "\176[\ESC\183\196\228\129+\202\174\vO",PropMaximumQoS +// 254,PropResponseInformation "T\180\202\170t\n\"\250\CAN",PropCorrelationData "9\161\239"]} +TEST(Connect5QCTest, Encode75) { + uint8_t pkt[] = {0x10, 0xfb, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x4e, 0xc6, 0x72, 0x26, 0x0, 0x5, + 0xea, 0xfd, 0x62, 0x4a, 0x2b, 0x0, 0x1, 0x24, 0x12, 0x0, 0x12, 0x2c, 0xf1, 0xce, 0x66, 0xf1, 0x1e, + 0x4a, 0x32, 0x13, 0x15, 0x88, 0x69, 0x1, 0x44, 0x4b, 0x21, 0xed, 0x88, 0x29, 0x8a, 0x21, 0x33, 0xdb, + 0x29, 0x20, 0x17, 0x48, 0x22, 0x4d, 0xcb, 0x18, 0x0, 0x0, 0x56, 0xc2, 0x12, 0x0, 0xd, 0x38, 0x56, + 0x73, 0x2a, 0xbf, 0xc8, 0x80, 0x6, 0x74, 0xed, 0x8e, 0xd9, 0xda, 0x27, 0x0, 0x0, 0x37, 0x26, 0x25, + 0x22, 0x8, 0x0, 0x4, 0xcd, 0x68, 0xe3, 0x94, 0x12, 0x0, 0xc, 0xb0, 0x5b, 0x1b, 0xb7, 0xc4, 0xe4, + 0x81, 0x2b, 0xca, 0xae, 0xb, 0x4f, 0x24, 0xfe, 0x1a, 0x0, 0x9, 0x54, 0xb4, 0xca, 0xaa, 0x74, 0xa, + 0x22, 0xfa, 0x18, 0x9, 0x0, 0x3, 0x39, 0xa1, 0xef, 0x0, 0xe, 0x17, 0x47, 0xe9, 0x8b, 0x65, 0x9, + 0x59, 0xeb, 0x4d, 0x50, 0x77, 0x4d, 0x48, 0xd0, 0x21, 0x17, 0x4d, 0x2a, 0x5a, 0x29, 0x4b, 0x1c, 0x0, + 0x18, 0x2b, 0x2, 0x38, 0x76, 0x5e, 0x6e, 0x30, 0x30, 0x40, 0x8e, 0xa5, 0x5, 0xb0, 0xd1, 0x86, 0x25, + 0xb4, 0x8b, 0x6b, 0x5f, 0x20, 0x23, 0xdc, 0x52, 0x0, 0x14, 0xde, 0xfe, 0xb9, 0x41, 0xa1, 0xe8, 0x69, + 0x6, 0xb4, 0x5a, 0x92, 0xc0, 0xfe, 0xb6, 0x2d, 0xce, 0x38, 0x48, 0xd3, 0x84, 0x0, 0x14, 0xda, 0xd4, + 0x6, 0x1b, 0x12, 0x5f, 0x79, 0xa9, 0xc4, 0x41, 0xe4, 0xc3, 0x4e, 0xd1, 0x3b, 0xdb, 0x8a, 0x47, 0xd, + 0x1d, 0x0, 0x11, 0x25, 0x5f, 0x66, 0x30, 0x50, 0xb9, 0x85, 0x9f, 0x98, 0x1, 0xb9, 0xa1, 0x85, 0xba, + 0xf2, 0x30, 0x27, 0x0, 0xb, 0xa6, 0xa5, 0x94, 0x64, 0x15, 0x79, 0x25, 0x8e, 0xde, 0xbd, 0x2c}; + + uint8_t buf[264] = {0}; + + uint8_t bytesprops1[] = {0x24}; + uint8_t bytesprops0[] = {0xea, 0xfd, 0x62, 0x4a, 0x2b}; + uint8_t bytesprops2[] = {0x2c, 0xf1, 0xce, 0x66, 0xf1, 0x1e, 0x4a, 0x32, 0x13, + 0x15, 0x88, 0x69, 0x1, 0x44, 0x4b, 0x21, 0xed, 0x88}; + uint8_t bytesprops3[] = {0x38, 0x56, 0x73, 0x2a, 0xbf, 0xc8, 0x80, 0x6, 0x74, 0xed, 0x8e, 0xd9, 0xda}; + uint8_t bytesprops4[] = {0xcd, 0x68, 0xe3, 0x94}; + uint8_t bytesprops5[] = {0xb0, 0x5b, 0x1b, 0xb7, 0xc4, 0xe4, 0x81, 0x2b, 0xca, 0xae, 0xb, 0x4f}; + uint8_t bytesprops6[] = {0x54, 0xb4, 0xca, 0xaa, 0x74, 0xa, 0x22, 0xfa, 0x18}; + uint8_t bytesprops7[] = {0x39, 0xa1, 0xef}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops0}, .v = {1, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13275}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19915}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22210}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14118}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops7}}}, + }; + + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x2b, 0x2, 0x38, 0x76, 0x5e, 0x6e, 0x30, 0x30, 0x40, 0x8e, 0xa5, 0x5, + 0xb0, 0xd1, 0x86, 0x25, 0xb4, 0x8b, 0x6b, 0x5f, 0x20, 0x23, 0xdc, 0x52}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops0}}}, + }; + + lwmqtt_properties_t willprops = {4, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xde, 0xfe, 0xb9, 0x41, 0xa1, 0xe8, 0x69, 0x6, 0xb4, 0x5a, + 0x92, 0xc0, 0xfe, 0xb6, 0x2d, 0xce, 0x38, 0x48, 0xd3, 0x84}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xda, 0xd4, 0x6, 0x1b, 0x12, 0x5f, 0x79, 0xa9, 0xc4, 0x41, + 0xe4, 0xc3, 0x4e, 0xd1, 0x3b, 0xdb, 0x8a, 0x47, 0xd, 0x1d}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 20166; + uint8_t client_id_bytes[] = {0x17, 0x47, 0xe9, 0x8b, 0x65, 0x9, 0x59, 0xeb, 0x4d, 0x50, 0x77, 0x4d, 0x48, 0xd0}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x25, 0x5f, 0x66, 0x30, 0x50, 0xb9, 0x85, 0x9f, 0x98, + 0x1, 0xb9, 0xa1, 0x85, 0xba, 0xf2, 0x30, 0x27}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xa6, 0xa5, 0x94, 0x64, 0x15, 0x79, 0x25, 0x8e, 0xde, 0xbd, 0x2c}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\172\206\237\DLE\254_Q2\226B'S\147k\177*D!\230\185<\130", _password = Just +// ".\STX\240p\196\191\165l\140\230\214\188\253\220\166\224I\197\241\153&3;\249", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS0, _willTopic = "\DC1o\221b\189\141f\242\228\CAN\219\141,e\230\221\166\&7Ar\GS", +// _willMsg = "", _willProps = []}), _cleanSession = False, _keepAlive = 20633, _connID = +// "x]*\241\253\180\253\181\DC4%\n\245\187\"\138\DLE\212b\182\171\131J\193\&0\176C", _properties = +// [PropRequestResponseInformation 254,PropAuthenticationMethod +// "\178\217\228\159;\DC4\209\143\165J\180\232\132\FSW",PropAuthenticationMethod +// "\170(\184H\158\183\236\197\134\157\DC1\RS\246\177\215mC",PropRequestProblemInformation 95,PropReasonString +// "\255Z\n>",PropSubscriptionIdentifierAvailable 56,PropUserProperty +// "\209\221\ACK+\SO\142\168\219\202\141\194C\169\167\SYN\253D\180\161\224\191\147-\226v,\DC27\140" +// "|\150p",PropWildcardSubscriptionAvailable 116,PropContentType +// "`0Y0\204\145\131\229\160\220mI\RS\170t\180*iw\188Hz\163\&8*\ESC,,\178",PropSharedSubscriptionAvailable +// 123,PropServerReference "\162V +// ,\235\164\DC4\207\152Uut\228\187\248\215s\214(\196u\243\b\bS\223t\151",PropResponseInformation +// "",PropPayloadFormatIndicator 83,PropSessionExpiryInterval 24887,PropCorrelationData "",PropRetainAvailable +// 95,PropMessageExpiryInterval 9307,PropSessionExpiryInterval 3503,PropResponseInformation +// "tR\NUL\248!\173\197p<\183\SYN\f\177=x\210\164a7=\SI\230d\\\149\157\232",PropUserProperty +// "\139\252S\156\149\134k\213\195\137^" "a\238\&5\222\160\192OaG{\251\231\SO\184\SI",PropTopicAliasMaximum +// 31387,PropUserProperty "''%\241k\158l\148\EM" "o\206\156(\ACK\142\204\&5\176\207Dx",PropMessageExpiryInterval +// 6104,PropSubscriptionIdentifier 15,PropContentType "\144\168\174\250\ETB\155\156",PropMessageExpiryInterval 18880]} +TEST(Connect5QCTest, Encode76) { + uint8_t pkt[] = { + 0x10, 0x98, 0x3, 0x0, 0x4, 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, 0xb1, 0x2a, 0x44, + 0x21, 0xe6, 0xb9, 0x3c, 0x82, 0x0, 0x18, 0x2e, 0x2, 0xf0, 0x70, 0xc4, 0xbf, 0xa5, 0x6c, 0x8c, 0xe6, 0xd6, 0xbc, + 0xfd, 0xdc, 0xa6, 0xe0, 0x49, 0xc5, 0xf1, 0x99, 0x26, 0x33, 0x3b, 0xf9}; + + uint8_t buf[421] = {0}; + + uint8_t bytesprops0[] = {0xb2, 0xd9, 0xe4, 0x9f, 0x3b, 0x14, 0xd1, 0x8f, 0xa5, 0x4a, 0xb4, 0xe8, 0x84, 0x1c, 0x57}; + uint8_t bytesprops1[] = {0xaa, 0x28, 0xb8, 0x48, 0x9e, 0xb7, 0xec, 0xc5, 0x86, + 0x9d, 0x11, 0x1e, 0xf6, 0xb1, 0xd7, 0x6d, 0x43}; + uint8_t bytesprops2[] = {0xff, 0x5a, 0xa, 0x3e}; + uint8_t bytesprops4[] = {0x7c, 0x96, 0x70}; + uint8_t bytesprops3[] = {0xd1, 0xdd, 0x6, 0x2b, 0xe, 0x8e, 0xa8, 0xdb, 0xca, 0x8d, 0xc2, 0x43, 0xa9, 0xa7, 0x16, + 0xfd, 0x44, 0xb4, 0xa1, 0xe0, 0xbf, 0x93, 0x2d, 0xe2, 0x76, 0x2c, 0x12, 0x37, 0x8c}; + uint8_t bytesprops5[] = {0x60, 0x30, 0x59, 0x30, 0xcc, 0x91, 0x83, 0xe5, 0xa0, 0xdc, 0x6d, 0x49, 0x1e, 0xaa, 0x74, + 0xb4, 0x2a, 0x69, 0x77, 0xbc, 0x48, 0x7a, 0xa3, 0x38, 0x2a, 0x1b, 0x2c, 0x2c, 0xb2}; + uint8_t bytesprops6[] = {0xa2, 0x56, 0x20, 0x2c, 0xeb, 0xa4, 0x14, 0xcf, 0x98, 0x55, 0x75, 0x74, 0xe4, 0xbb, + 0xf8, 0xd7, 0x73, 0xd6, 0x28, 0xc4, 0x75, 0xf3, 0x8, 0x8, 0x53, 0xdf, 0x74, 0x97}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0x74, 0x52, 0x0, 0xf8, 0x21, 0xad, 0xc5, 0x70, 0x3c, 0xb7, 0x16, 0xc, 0xb1, 0x3d, + 0x78, 0xd2, 0xa4, 0x61, 0x37, 0x3d, 0xf, 0xe6, 0x64, 0x5c, 0x95, 0x9d, 0xe8}; + uint8_t bytesprops11[] = {0x61, 0xee, 0x35, 0xde, 0xa0, 0xc0, 0x4f, 0x61, 0x47, 0x7b, 0xfb, 0xe7, 0xe, 0xb8, 0xf}; + uint8_t bytesprops10[] = {0x8b, 0xfc, 0x53, 0x9c, 0x95, 0x86, 0x6b, 0xd5, 0xc3, 0x89, 0x5e}; + uint8_t bytesprops13[] = {0x6f, 0xce, 0x9c, 0x28, 0x6, 0x8e, 0xcc, 0x35, 0xb0, 0xcf, 0x44, 0x78}; + uint8_t bytesprops12[] = {0x27, 0x27, 0x25, 0xf1, 0x6b, 0x9e, 0x6c, 0x94, 0x19}; + uint8_t bytesprops14[] = {0x90, 0xa8, 0xae, 0xfa, 0x17, 0x9b, 0x9c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops3}, .v = {3, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24887}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9307}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3503}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {11, (char*)&bytesprops10}, .v = {15, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31387}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops12}, .v = {12, (char*)&bytesprops13}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6104}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18880}}, + }; + + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x11, 0x6f, 0xdd, 0x62, 0xbd, 0x8d, 0x66, 0xf2, 0xe4, 0x18, 0xdb, + 0x8d, 0x2c, 0x65, 0xe6, 0xdd, 0xa6, 0x37, 0x41, 0x72, 0x1d}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 20633; + uint8_t client_id_bytes[] = {0x78, 0x5d, 0x2a, 0xf1, 0xfd, 0xb4, 0xfd, 0xb5, 0x14, 0x25, 0xa, 0xf5, 0xbb, + 0x22, 0x8a, 0x10, 0xd4, 0x62, 0xb6, 0xab, 0x83, 0x4a, 0xc1, 0x30, 0xb0, 0x43}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xac, 0xce, 0xed, 0x10, 0xfe, 0x5f, 0x51, 0x32, 0xe2, 0x42, 0x27, + 0x53, 0x93, 0x6b, 0xb1, 0x2a, 0x44, 0x21, 0xe6, 0xb9, 0x3c, 0x82}; + lwmqtt_string_t username = {22, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x2e, 0x2, 0xf0, 0x70, 0xc4, 0xbf, 0xa5, 0x6c, 0x8c, 0xe6, 0xd6, 0xbc, + 0xfd, 0xdc, 0xa6, 0xe0, 0x49, 0xc5, 0xf1, 0x99, 0x26, 0x33, 0x3b, 0xf9}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "z@\a", _password = Just "\253\197(\t}\238J\253\251\192\135j", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\129B\175B", _willMsg = "S\233k'\183[ryq\189X\218", +// _willProps = [PropSubscriptionIdentifierAvailable 59,PropRequestProblemInformation 184,PropTopicAlias +// 11545,PropResponseTopic "\\0\128\214\&2`\162x\179\176))\207D\255S\134\224X\DC2\b\159",PropSessionExpiryInterval +// 32591,PropSessionExpiryInterval 6459,PropRequestProblemInformation 129,PropSharedSubscriptionAvailable +// 184,PropAssignedClientIdentifier +// "\145\248\128|\178\150\242\235d\NAK\190R\137t\169\217n\174E\156Y\SUB6\SYN\151XH",PropRetainAvailable 204]}), +// _cleanSession = False, _keepAlive = 32764, _connID = "d\173\189", _properties = [PropMessageExpiryInterval +// 19357,PropContentType "{fW\192\248\DC4\206\191\235",PropAuthenticationMethod "\DC2l1",PropAuthenticationData +// "\198\159$\188\RS\196\222O\217\225R\191\212d>\241W\131\191BF)O\180\227v\145i",PropSessionExpiryInterval +// 20981,PropSessionExpiryInterval 18282,PropAssignedClientIdentifier +// "\185\249\196\187\a\247\161\214_|\166\229\&2k\179\151ak\151\151%=O\132\246\144*6>",PropAssignedClientIdentifier +// "\223m\v\197\233X/\NUL\NAK\166C\132\f\135c&\231$j\206",PropPayloadFormatIndicator 5,PropWildcardSubscriptionAvailable +// 184,PropAuthenticationMethod "\210n|<\132\243?\193\251\DC3a\EOT\169\171\"n^\161\RS",PropUserProperty +// "\165K\198\SOBe\170'3m\220\211\185\SId\168\154\SYN~\247v\208\197\231\153" +// "\140\210\128\139\DLE\238W\240\138G\164AE\155\173\255$\138\r\201\235\&3w\134\&0`6\245s"]} +TEST(Connect5QCTest, Encode77) { + uint8_t pkt[] = { + 0x10, 0xd3, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x7f, 0xfc, 0xcc, 0x1, 0x2, 0x0, 0x0, 0x4b, + 0x9d, 0x3, 0x0, 0x9, 0x7b, 0x66, 0x57, 0xc0, 0xf8, 0x14, 0xce, 0xbf, 0xeb, 0x15, 0x0, 0x3, 0x12, 0x6c, 0x31, + 0x16, 0x0, 0x1c, 0xc6, 0x9f, 0x24, 0xbc, 0x1e, 0xc4, 0xde, 0x4f, 0xd9, 0xe1, 0x52, 0xbf, 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 0x32, 0x60, 0xa2, 0x78, 0xb3, 0xb0, 0x29, 0x29, + 0xcf, 0x44, 0xff, 0x53, 0x86, 0xe0, 0x58, 0x12, 0x8, 0x9f, 0x11, 0x0, 0x0, 0x7f, 0x4f, 0x11, 0x0, 0x0, 0x19, + 0x3b, 0x17, 0x81, 0x2a, 0xb8, 0x12, 0x0, 0x1b, 0x91, 0xf8, 0x80, 0x7c, 0xb2, 0x96, 0xf2, 0xeb, 0x64, 0x15, 0xbe, + 0x52, 0x89, 0x74, 0xa9, 0xd9, 0x6e, 0xae, 0x45, 0x9c, 0x59, 0x1a, 0x36, 0x16, 0x97, 0x58, 0x48, 0x25, 0xcc, 0x0, + 0x4, 0x81, 0x42, 0xaf, 0x42, 0x0, 0xc, 0x53, 0xe9, 0x6b, 0x27, 0xb7, 0x5b, 0x72, 0x79, 0x71, 0xbd, 0x58, 0xda, + 0x0, 0x3, 0x7a, 0x40, 0x7, 0x0, 0xc, 0xfd, 0xc5, 0x28, 0x9, 0x7d, 0xee, 0x4a, 0xfd, 0xfb, 0xc0, 0x87, 0x6a}; + + uint8_t buf[352] = {0}; + + uint8_t bytesprops0[] = {0x7b, 0x66, 0x57, 0xc0, 0xf8, 0x14, 0xce, 0xbf, 0xeb}; + uint8_t bytesprops1[] = {0x12, 0x6c, 0x31}; + uint8_t bytesprops2[] = {0xc6, 0x9f, 0x24, 0xbc, 0x1e, 0xc4, 0xde, 0x4f, 0xd9, 0xe1, 0x52, 0xbf, 0xd4, 0x64, + 0x3e, 0xf1, 0x57, 0x83, 0xbf, 0x42, 0x46, 0x29, 0x4f, 0xb4, 0xe3, 0x76, 0x91, 0x69}; + uint8_t bytesprops3[] = {0xb9, 0xf9, 0xc4, 0xbb, 0x7, 0xf7, 0xa1, 0xd6, 0x5f, 0x7c, 0xa6, 0xe5, 0x32, 0x6b, 0xb3, + 0x97, 0x61, 0x6b, 0x97, 0x97, 0x25, 0x3d, 0x4f, 0x84, 0xf6, 0x90, 0x2a, 0x36, 0x3e}; + uint8_t bytesprops4[] = {0xdf, 0x6d, 0xb, 0xc5, 0xe9, 0x58, 0x2f, 0x0, 0x15, 0xa6, + 0x43, 0x84, 0xc, 0x87, 0x63, 0x26, 0xe7, 0x24, 0x6a, 0xce}; + uint8_t bytesprops5[] = {0xd2, 0x6e, 0x7c, 0x3c, 0x84, 0xf3, 0x3f, 0xc1, 0xfb, 0x13, + 0x61, 0x4, 0xa9, 0xab, 0x22, 0x6e, 0x5e, 0xa1, 0x1e}; + uint8_t bytesprops7[] = {0x8c, 0xd2, 0x80, 0x8b, 0x10, 0xee, 0x57, 0xf0, 0x8a, 0x47, 0xa4, 0x41, 0x45, 0x9b, 0xad, + 0xff, 0x24, 0x8a, 0xd, 0xc9, 0xeb, 0x33, 0x77, 0x86, 0x30, 0x60, 0x36, 0xf5, 0x73}; + uint8_t bytesprops6[] = {0xa5, 0x4b, 0xc6, 0xe, 0x42, 0x65, 0xaa, 0x27, 0x33, 0x6d, 0xdc, 0xd3, 0xb9, + 0xf, 0x64, 0xa8, 0x9a, 0x16, 0x7e, 0xf7, 0x76, 0xd0, 0xc5, 0xe7, 0x99}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19357}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20981}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18282}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops6}, .v = {29, (char*)&bytesprops7}}}}, + }; + + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x5c, 0x30, 0x80, 0xd6, 0x32, 0x60, 0xa2, 0x78, 0xb3, 0xb0, 0x29, + 0x29, 0xcf, 0x44, 0xff, 0x53, 0x86, 0xe0, 0x58, 0x12, 0x8, 0x9f}; + uint8_t byteswillprops1[] = {0x91, 0xf8, 0x80, 0x7c, 0xb2, 0x96, 0xf2, 0xeb, 0x64, 0x15, 0xbe, 0x52, 0x89, 0x74, + 0xa9, 0xd9, 0x6e, 0xae, 0x45, 0x9c, 0x59, 0x1a, 0x36, 0x16, 0x97, 0x58, 0x48}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11545}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32591}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6459}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, + }; + + lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x81, 0x42, 0xaf, 0x42}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x53, 0xe9, 0x6b, 0x27, 0xb7, 0x5b, 0x72, 0x79, 0x71, 0xbd, 0x58, 0xda}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32764; + uint8_t client_id_bytes[] = {0x64, 0xad, 0xbd}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x7a, 0x40, 0x7}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xfd, 0xc5, 0x28, 0x9, 0x7d, 0xee, 0x4a, 0xfd, 0xfb, 0xc0, 0x87, 0x6a}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "vo\255\134\EM\214ra~\221QTH]\236\&1\203\133f\193%", _password = Nothing, _lastWill +// = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\143\219\228T\SIP\210\NULp\216b\230\191\b\DC1\190\218\139\178\174\179\138\176z", _willMsg = +// "\\\196Q\224Q\138\232\DC4\230u\194\&6\147\197\138o\202\247&\180\179\RSB,\244\153h\STX", _willProps = +// [PropRequestResponseInformation 5]}), _cleanSession = False, _keepAlive = 18519, _connID = +// "cX\140\&9\221\ETXY\131\GS", _properties = [PropCorrelationData +// "cD\152\188\136\&0\ETB\178Ya6",PropSharedSubscriptionAvailable 108,PropMessageExpiryInterval 17865]} +TEST(Connect5QCTest, Encode78) { + uint8_t pkt[] = {0x10, 0x7d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xac, 0x48, 0x57, 0x15, 0x9, 0x0, 0xb, + 0x63, 0x44, 0x98, 0xbc, 0x88, 0x30, 0x17, 0xb2, 0x59, 0x61, 0x36, 0x2a, 0x6c, 0x2, 0x0, 0x0, + 0x45, 0xc9, 0x0, 0x9, 0x63, 0x58, 0x8c, 0x39, 0xdd, 0x3, 0x59, 0x83, 0x1d, 0x2, 0x19, 0x5, + 0x0, 0x18, 0x8f, 0xdb, 0xe4, 0x54, 0xf, 0x50, 0xd2, 0x0, 0x70, 0xd8, 0x62, 0xe6, 0xbf, 0x8, + 0x11, 0xbe, 0xda, 0x8b, 0xb2, 0xae, 0xb3, 0x8a, 0xb0, 0x7a, 0x0, 0x1c, 0x5c, 0xc4, 0x51, 0xe0, + 0x51, 0x8a, 0xe8, 0x14, 0xe6, 0x75, 0xc2, 0x36, 0x93, 0xc5, 0x8a, 0x6f, 0xca, 0xf7, 0x26, 0xb4, + 0xb3, 0x1e, 0x42, 0x2c, 0xf4, 0x99, 0x68, 0x2, 0x0, 0x15, 0x76, 0x6f, 0xff, 0x86, 0x19, 0xd6, + 0x72, 0x61, 0x7e, 0xdd, 0x51, 0x54, 0x48, 0x5d, 0xec, 0x31, 0xcb, 0x85, 0x66, 0xc1, 0x25}; + + uint8_t buf[137] = {0}; + + uint8_t bytesprops0[] = {0x63, 0x44, 0x98, 0xbc, 0x88, 0x30, 0x17, 0xb2, 0x59, 0x61, 0x36}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17865}}, + }; + + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 5}}, + }; + + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8f, 0xdb, 0xe4, 0x54, 0xf, 0x50, 0xd2, 0x0, 0x70, 0xd8, 0x62, 0xe6, + 0xbf, 0x8, 0x11, 0xbe, 0xda, 0x8b, 0xb2, 0xae, 0xb3, 0x8a, 0xb0, 0x7a}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5c, 0xc4, 0x51, 0xe0, 0x51, 0x8a, 0xe8, 0x14, 0xe6, 0x75, 0xc2, 0x36, 0x93, 0xc5, + 0x8a, 0x6f, 0xca, 0xf7, 0x26, 0xb4, 0xb3, 0x1e, 0x42, 0x2c, 0xf4, 0x99, 0x68, 0x2}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 18519; + uint8_t client_id_bytes[] = {0x63, 0x58, 0x8c, 0x39, 0xdd, 0x3, 0x59, 0x83, 0x1d}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x76, 0x6f, 0xff, 0x86, 0x19, 0xd6, 0x72, 0x61, 0x7e, 0xdd, 0x51, + 0x54, 0x48, 0x5d, 0xec, 0x31, 0xcb, 0x85, 0x66, 0xc1, 0x25}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// "\157\ETB\161\194\193\144\143\222H\bK\137S\211\183P\248e#\158\140\132\232~", _lastWill = Just (LastWill {_willRetain +// = True, _willQoS = QoS0, _willTopic = "\234\218\131\206!/\185r4\200\241\199\174\200\229", _willMsg = +// "?\198\253\173(", _willProps = [PropServerKeepAlive 29962,PropReceiveMaximum 19631,PropMaximumPacketSize +// 17084,PropTopicAlias 21494,PropMaximumPacketSize 20387,PropSessionExpiryInterval 10289,PropServerKeepAlive 23645]}), +// _cleanSession = True, _keepAlive = 5462, _connID = "~Zt\220\FS\b\166{\135\185\244Q\248@\a^", _properties = +// [PropWillDelayInterval 7867,PropServerReference "cS\248\169\DLE\189Q\207\170gE\239\146\231szjp\137",PropReasonString +// "F7\v\177l\189\191\DEL\198\162[\162\146\SUB\180\t\228\156y\171F\218-\246\156\169\229'",PropServerKeepAlive +// 30499,PropWillDelayInterval 18658,PropAssignedClientIdentifier "\174\209g",PropMaximumPacketSize 22566,PropMaximumQoS +// 204,PropAuthenticationData "L\133}qW\235\165r\183\195'\ny\148;7Ja",PropServerKeepAlive 21943,PropReasonString +// "\255\189\230TO\231\f\235\148\SOH\192\205\f\234\250\176\202r\197\214\t\199\252\230\167:\228\175\147",PropAssignedClientIdentifier +// "-$\ETX\200\r\255Id\GS\\C\238&\SI=\b<\194\167\&9O\197\164\245\236+\250\159\209\167",PropAssignedClientIdentifier +// "\252\f",PropWillDelayInterval 31642,PropSessionExpiryInterval 30092,PropAssignedClientIdentifier +// "\149\213\139\STX\SOHD\209!\184\251)\235fj\146\184\216\206\140$",PropAssignedClientIdentifier +// "\251\DC2\255j\235\236\&2\169\226\151l\136\CAN\155\205\220:\171\147W5`\224",PropRetainAvailable 210]} +TEST(Connect5QCTest, Encode79) { + uint8_t pkt[] = { + 0x10, 0xbc, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x15, 0x56, 0xea, 0x1, 0x18, 0x0, 0x0, 0x1e, + 0xbb, 0x1c, 0x0, 0x13, 0x63, 0x53, 0xf8, 0xa9, 0x10, 0xbd, 0x51, 0xcf, 0xaa, 0x67, 0x45, 0xef, 0x92, 0xe7, 0x73, + 0x7a, 0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0x12, 0xff, 0x6a, + 0xeb, 0xec, 0x32, 0xa9, 0xe2, 0x97, 0x6c, 0x88, 0x18, 0x9b, 0xcd, 0xdc, 0x3a, 0xab, 0x93, 0x57, 0x35, 0x60, 0xe0, + 0x25, 0xd2, 0x0, 0x10, 0x7e, 0x5a, 0x74, 0xdc, 0x1c, 0x8, 0xa6, 0x7b, 0x87, 0xb9, 0xf4, 0x51, 0xf8, 0x40, 0x7, + 0x5e, 0x1b, 0x13, 0x75, 0xa, 0x21, 0x4c, 0xaf, 0x27, 0x0, 0x0, 0x42, 0xbc, 0x23, 0x53, 0xf6, 0x27, 0x0, 0x0, + 0x4f, 0xa3, 0x11, 0x0, 0x0, 0x28, 0x31, 0x13, 0x5c, 0x5d, 0x0, 0xf, 0xea, 0xda, 0x83, 0xce, 0x21, 0x2f, 0xb9, + 0x72, 0x34, 0xc8, 0xf1, 0xc7, 0xae, 0xc8, 0xe5, 0x0, 0x5, 0x3f, 0xc6, 0xfd, 0xad, 0x28}; + + uint8_t buf[329] = {0}; + + uint8_t bytesprops0[] = {0x63, 0x53, 0xf8, 0xa9, 0x10, 0xbd, 0x51, 0xcf, 0xaa, 0x67, + 0x45, 0xef, 0x92, 0xe7, 0x73, 0x7a, 0x6a, 0x70, 0x89}; + uint8_t bytesprops1[] = {0x46, 0x37, 0xb, 0xb1, 0x6c, 0xbd, 0xbf, 0x7f, 0xc6, 0xa2, 0x5b, 0xa2, 0x92, 0x1a, + 0xb4, 0x9, 0xe4, 0x9c, 0x79, 0xab, 0x46, 0xda, 0x2d, 0xf6, 0x9c, 0xa9, 0xe5, 0x27}; + uint8_t bytesprops2[] = {0xae, 0xd1, 0x67}; + uint8_t bytesprops3[] = {0x4c, 0x85, 0x7d, 0x71, 0x57, 0xeb, 0xa5, 0x72, 0xb7, + 0xc3, 0x27, 0xa, 0x79, 0x94, 0x3b, 0x37, 0x4a, 0x61}; + uint8_t bytesprops4[] = {0xff, 0xbd, 0xe6, 0x54, 0x4f, 0xe7, 0xc, 0xeb, 0x94, 0x1, 0xc0, 0xcd, 0xc, 0xea, 0xfa, + 0xb0, 0xca, 0x72, 0xc5, 0xd6, 0x9, 0xc7, 0xfc, 0xe6, 0xa7, 0x3a, 0xe4, 0xaf, 0x93}; + uint8_t bytesprops5[] = {0x2d, 0x24, 0x3, 0xc8, 0xd, 0xff, 0x49, 0x64, 0x1d, 0x5c, 0x43, 0xee, 0x26, 0xf, 0x3d, + 0x8, 0x3c, 0xc2, 0xa7, 0x39, 0x4f, 0xc5, 0xa4, 0xf5, 0xec, 0x2b, 0xfa, 0x9f, 0xd1, 0xa7}; + uint8_t bytesprops6[] = {0xfc, 0xc}; + uint8_t bytesprops7[] = {0x95, 0xd5, 0x8b, 0x2, 0x1, 0x44, 0xd1, 0x21, 0xb8, 0xfb, + 0x29, 0xeb, 0x66, 0x6a, 0x92, 0xb8, 0xd8, 0xce, 0x8c, 0x24}; + uint8_t bytesprops8[] = {0xfb, 0x12, 0xff, 0x6a, 0xeb, 0xec, 0x32, 0xa9, 0xe2, 0x97, 0x6c, 0x88, + 0x18, 0x9b, 0xcd, 0xdc, 0x3a, 0xab, 0x93, 0x57, 0x35, 0x60, 0xe0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7867}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30499}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18658}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22566}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21943}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31642}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30092}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29962}}, {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19631}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17084}}, {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21494}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20387}}, {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10289}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23645}}, + }; + + lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xea, 0xda, 0x83, 0xce, 0x21, 0x2f, 0xb9, 0x72, + 0x34, 0xc8, 0xf1, 0xc7, 0xae, 0xc8, 0xe5}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3f, 0xc6, 0xfd, 0xad, 0x28}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 5462; + uint8_t client_id_bytes[] = {0x7e, 0x5a, 0x74, 0xdc, 0x1c, 0x8, 0xa6, 0x7b, + 0x87, 0xb9, 0xf4, 0x51, 0xf8, 0x40, 0x7, 0x5e}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x9d, 0x17, 0xa1, 0xc2, 0xc1, 0x90, 0x8f, 0xde, 0x48, 0x8, 0x4b, 0x89, + 0x53, 0xd3, 0xb7, 0x50, 0xf8, 0x65, 0x23, 0x9e, 0x8c, 0x84, 0xe8, 0x7e}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\147{'Z\192?r8#\DLEU\192\236\160\237v\192p\NUL\171;\EOT", _password = Just +// "\160J\202\185\172\&2\153\200\SYN\a\130n\179\133f\207\&5\n8\245\n\144\220", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS0, _willTopic = "\145K\248\242\218\139\203", _willMsg = +// "\166\252\SI\215\181\NUL\150dX7\178\210", _willProps = [PropSubscriptionIdentifierAvailable 128,PropTopicAliasMaximum +// 24138,PropReceiveMaximum 13075,PropResponseTopic +// "\178\236j\DEL\154Z\251\STXs\196\164M\171\140\&9G\210\212\187",PropMaximumQoS 54,PropReasonString +// "\SI\ACKc;n\160k\a\SUB\218r\171*\236\168",PropAssignedClientIdentifier "p$\150Q\174\199",PropAssignedClientIdentifier +// "\ACK\DLE\EOTC\146\161\130\145<\139hM\ETX\147\180\166\165\r\147\a\165t\254\156\178\188",PropMaximumPacketSize +// 29686,PropRetainAvailable 253,PropResponseTopic "*\135Z\155\139*H\NUL\152n\GS\EM\ETX\196\217"]}), _cleanSession = +// True, _keepAlive = 25664, _connID = "\GS\225\&4\DC4\182", _properties = [PropResponseInformation +// "\178\132\159",PropRequestResponseInformation 123,PropResponseTopic +// "\129\182\170\SOH\225l\227\163\169&\211\b\131|\216\182\234\168\&6\186\DC2\146",PropPayloadFormatIndicator +// 135,PropTopicAliasMaximum 18172,PropMaximumPacketSize 4275,PropReasonString +// "\179\187\181$DQ\SI5\246\185\130L",PropAuthenticationMethod ",\235\RS=f8\239\160",PropCorrelationData +// "\156\213L:8\192\216\174\228V\217\229\255i",PropSubscriptionIdentifier 25,PropUserProperty "\CAN\n\147\196\221" +// ">\193\151Y\177\f\248\DC1\191O",PropWildcardSubscriptionAvailable 198,PropTopicAliasMaximum +// 1330,PropSharedSubscriptionAvailable 56,PropTopicAliasMaximum 3080,PropSubscriptionIdentifier 29,PropReasonString +// "k\v\180x\237\SYN=\246w\248!D%",PropResponseTopic +// "\DC2\219\NUL\154\179O\174\136\r\175+\ENQ\196\244yf\\\180\183[",PropServerReference +// "\197",PropContentType "^P\DLE',\232\240\&6\185\&9H\167\185\140\204_Oa5\174I\164\239\FS",PropUserProperty +// "\232\159\167FWQ\135\EM\148\193\143\a\187{\243\SYN\DC4\DEL\182\248" "\178/\227\250\209\206T",PropWillDelayInterval +// 17881,PropAuthenticationData "&\219\245^\244R\236d-?0\169\156\EOTp\US\190\227w",PropAssignedClientIdentifier +// "h",PropContentType "\200",PropReasonString +// "*\US\143\194$P\\\208\186^\193\v\f{\ENQ\ETB%\194",PropAssignedClientIdentifier "NLF\218\&7",PropServerKeepAlive +// 21484,PropMaximumPacketSize 12647,PropMaximumPacketSize 5652]} +TEST(Connect5QCTest, Encode81) { + uint8_t pkt[] = { + 0x10, 0x87, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x5, 0x3f, 0xc0, 0x1, 0x26, 0x0, 0x1a, 0x4c, + 0xde, 0x6a, 0xef, 0x22, 0x99, 0x12, 0xbb, 0x77, 0xea, 0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xd, 0x7d, 0x2a, 0xbf, 0x88, 0x4a, 0xea, 0x4c, 0xc7, 0xe6, 0x8e, 0xf7, 0x9, 0x0, 0xa, + 0x20, 0xc1, 0x71, 0x97, 0x7e, 0x71, 0x2d, 0x3d, 0x34, 0x2, 0x2a, 0xd7, 0x12, 0x0, 0x7, 0xc8, 0xc0, 0x74, 0xfd, + 0xcd, 0xa4, 0x69, 0x0, 0x1b, 0x41, 0x94, 0x4d, 0xca, 0xc3, 0xc3, 0xd, 0x1d, 0xf0, 0xeb, 0xc1, 0x5f, 0x62, 0x29, + 0xb2, 0xb0, 0xda, 0x2d, 0x5a, 0xb0, 0x60, 0xba, 0xa4, 0x1c, 0x6b, 0x86, 0xaf, 0x0, 0x12, 0x34, 0x7c, 0x67, 0x51, + 0x31, 0xe1, 0xe2, 0x26, 0xd6, 0x4e, 0xd5, 0x87, 0xe8, 0xdc, 0x47, 0x6d, 0xf2, 0xac, 0x0, 0x1b, 0x50, 0xb2, 0xf3, + 0xb7, 0xac, 0x89, 0xe8, 0xd4, 0xd, 0x7e, 0x4e, 0xfc, 0x91, 0xd4, 0x68, 0xe6, 0x11, 0x90, 0x7a, 0x7d, 0xd1, 0x36, + 0xf7, 0x10, 0xc0, 0x69, 0x71, 0x0, 0x2, 0x6d, 0x55}; + + uint8_t buf[532] = {0}; + + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops0[] = {0x4c, 0xde, 0x6a, 0xef, 0x22, 0x99, 0x12, 0xbb, 0x77, 0xea, 0x20, 0x4c, 0x7f, + 0x1, 0x9c, 0xce, 0x90, 0x92, 0x72, 0x7b, 0x7c, 0x31, 0x19, 0xb3, 0x6c, 0x3b}; + uint8_t bytesprops2[] = {0xa1, 0x81, 0xe1, 0xe0}; + uint8_t bytesprops3[] = {0xa6, 0xa7, 0xd0, 0x3e}; + uint8_t bytesprops4[] = {0x5e, 0x50, 0x10, 0x27, 0x2c, 0xe8, 0xf0, 0x36, 0xb9, 0x39, 0x48, 0xa7, + 0xb9, 0x8c, 0xcc, 0x5f, 0x4f, 0x61, 0x35, 0xae, 0x49, 0xa4, 0xef, 0x1c}; + uint8_t bytesprops6[] = {0xb2, 0x2f, 0xe3, 0xfa, 0xd1, 0xce, 0x54}; + uint8_t bytesprops5[] = {0xe8, 0x9f, 0xa7, 0x46, 0x57, 0x51, 0x87, 0x19, 0x94, 0xc1, + 0x8f, 0x7, 0xbb, 0x7b, 0xf3, 0x16, 0x14, 0x7f, 0xb6, 0xf8}; + uint8_t bytesprops7[] = {0x26, 0xdb, 0xf5, 0x5e, 0xf4, 0x52, 0xec, 0x64, 0x2d, 0x3f, + 0x30, 0xa9, 0x9c, 0x4, 0x70, 0x1f, 0xbe, 0xe3, 0x77}; + uint8_t bytesprops8[] = {0x68}; + uint8_t bytesprops9[] = {0xc8}; + uint8_t bytesprops10[] = {0x2a, 0x1f, 0x8f, 0xc2, 0x24, 0x50, 0x5c, 0xd0, 0xba, + 0x5e, 0xc1, 0xb, 0xc, 0x7b, 0x5, 0x17, 0x25, 0xc2}; + uint8_t bytesprops11[] = {0x4e, 0x4c, 0x46, 0xda, 0x37}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1766}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops5}, .v = {7, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17881}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21484}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12647}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5652}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x9, 0x8d, 0x8e, 0x3, 0xa9, 0x68, 0x25, 0x9d, 0x76, 0x6a, 0x96, 0x70, + 0xc8, 0x82, 0xb0, 0x6e, 0x69, 0xcc, 0x45, 0xde, 0xc1, 0xa0, 0xf7, 0x3c}; + uint8_t byteswillprops1[] = {0xdf, 0xbd, 0xb8, 0x99, 0x5, 0xe5, 0xdf, 0xab, 0x51}; + uint8_t byteswillprops2[] = {0x4f, 0xd7, 0xdb, 0x77, 0x70, 0x2a, 0x93, 0x4a, 0xc, 0x9d}; + uint8_t byteswillprops3[] = {0x37, 0x9d, 0x73, 0x21, 0xdd, 0x26, 0x7, 0x96, 0xa, 0x8d, 0xcc, 0x46, 0xd8, 0x71, + 0x29, 0x48, 0x89, 0xf3, 0xd0, 0xa1, 0xd5, 0x3, 0x46, 0x41, 0xc6, 0xd9, 0x8f}; + uint8_t byteswillprops4[] = {0x2, 0xbc, 0x6b, 0xc8, 0x84, 0x19, 0x13, 0xc9, 0x20, + 0x43, 0x4d, 0xaf, 0x5b, 0x95, 0xf, 0x84, 0xd5, 0x82}; + uint8_t byteswillprops5[] = {0x57, 0x57, 0x42, 0xe7, 0x2e, 0xd5, 0x94, 0xba, 0x36, 0x45, 0x54, 0xff, + 0x4a, 0xa3, 0x93, 0xc6, 0xa6, 0x4a, 0xa1, 0x1f, 0xb0, 0xd3, 0xe1}; + uint8_t byteswillprops6[] = {0x28, 0x42, 0xc9}; + uint8_t byteswillprops7[] = {0x15, 0xd1, 0x9a, 0xc9, 0x91, 0xd, 0x7d, 0x2a, 0xbf, + 0x88, 0x4a, 0xea, 0x4c, 0xc7, 0xe6, 0x8e, 0xf7}; + uint8_t byteswillprops8[] = {0x20, 0xc1, 0x71, 0x97, 0x7e, 0x71, 0x2d, 0x3d, 0x34, 0x2}; + uint8_t byteswillprops9[] = {0xc8, 0xc0, 0x74, 0xfd, 0xcd, 0xa4, 0x69}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15844}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16158}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21310}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18603}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops9}}}, + }; + + lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x41, 0x94, 0x4d, 0xca, 0xc3, 0xc3, 0xd, 0x1d, 0xf0, 0xeb, 0xc1, 0x5f, 0x62, 0x29, + 0xb2, 0xb0, 0xda, 0x2d, 0x5a, 0xb0, 0x60, 0xba, 0xa4, 0x1c, 0x6b, 0x86, 0xaf}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x34, 0x7c, 0x67, 0x51, 0x31, 0xe1, 0xe2, 0x26, 0xd6, + 0x4e, 0xd5, 0x87, 0xe8, 0xdc, 0x47, 0x6d, 0xf2, 0xac}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1343; + uint8_t client_id_bytes[] = {0xa2, 0x34, 0x6f, 0x67, 0x2a, 0x54, 0x16, 0xc2, 0x63, 0x4, 0x81, + 0x7e, 0x7a, 0xd7, 0xaa, 0x9, 0x7, 0xac, 0xac, 0x78, 0x75}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x50, 0xb2, 0xf3, 0xb7, 0xac, 0x89, 0xe8, 0xd4, 0xd, 0x7e, 0x4e, 0xfc, 0x91, 0xd4, + 0x68, 0xe6, 0x11, 0x90, 0x7a, 0x7d, 0xd1, 0x36, 0xf7, 0x10, 0xc0, 0x69, 0x71}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x6d, 0x55}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\r)\190_\138\DC4\SO\163\226j\189 +// ~*BN\SI\EOT-\217\128\232\223\239\129m\a\DLEG\254", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, +// _willTopic = "+\177\246\187~\133", _willMsg = "\151\189\&3\RS\175\198\166j", _willProps = [PropMaximumQoS +// 180,PropTopicAliasMaximum 20703,PropWildcardSubscriptionAvailable 142,PropSessionExpiryInterval +// 30839,PropWillDelayInterval 31512,PropRetainAvailable 43,PropRetainAvailable 77,PropUserProperty +// "e4\213\v\167\ENQ\152\201\168c\173\vu>Zz\181\157\198d|\DC4" +// "\241\252\163\163\EOTrjN\250\160\168\161A\SYN\RS4#\240\156\185\164a\US\186",PropAssignedClientIdentifier +// "\160m\187",PropServerReference +// "\SI\199\200\139H\210)\223\223\146G\\\139\220\130\a~\192\EOT\ESC!\ENQ\172\234fW\249\129\GS",PropResponseTopic +// "\DC1M9\139\229\177\178\212\&83.LM{L\221\216\&5a\142\245\140",PropSharedSubscriptionAvailable 249,PropContentType +// "\201\190\ACK\ENQ\212\209T\247\178\&9p"]}), _cleanSession = False, _keepAlive = 4479, _connID = +// "\148\233\210e\EM\168\130\133\253\SOH\232\207f\173\220\238\167\166vG\v\141\190\";", _properties = +// [PropMessageExpiryInterval 8357,PropResponseInformation "\n>\141\228\180\153",PropMaximumQoS +// 233,PropSubscriptionIdentifierAvailable 51]} +TEST(Connect5QCTest, Encode82) { + uint8_t pkt[] = {0x10, 0xe3, 0x1, 0x0, 0x4, 0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, 0x35, 0x61, 0x8e, 0xf5, 0x8c, 0x2a, 0xf9, 0x3, 0x0, 0xb, 0xc9, 0xbe, 0x6, + 0x5, 0xd4, 0xd1, 0x54, 0xf7, 0xb2, 0x39, 0x70, 0x0, 0x6, 0x2b, 0xb1, 0xf6, 0xbb, 0x7e, 0x85, 0x0, + 0x8, 0x97, 0xbd, 0x33, 0x1e, 0xaf, 0xc6, 0xa6, 0x6a}; + + uint8_t buf[240] = {0}; + + uint8_t bytesprops0[] = {0xa, 0x3e, 0x8d, 0xe4, 0xb4, 0x99}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8357}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 51}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xf1, 0xfc, 0xa3, 0xa3, 0x4, 0x72, 0x6a, 0x4e, 0xfa, 0xa0, 0xa8, 0xa1, + 0x41, 0x16, 0x1e, 0x34, 0x23, 0xf0, 0x9c, 0xb9, 0xa4, 0x61, 0x1f, 0xba}; + uint8_t byteswillprops0[] = {0x65, 0x34, 0xd5, 0xb, 0xa7, 0x5, 0x98, 0xc9, 0xa8, 0x63, 0xad, + 0xb, 0x75, 0x3e, 0x5a, 0x7a, 0xb5, 0x9d, 0xc6, 0x64, 0x7c, 0x14}; + uint8_t byteswillprops2[] = {0xa0, 0x6d, 0xbb}; + uint8_t byteswillprops3[] = {0xf, 0xc7, 0xc8, 0x8b, 0x48, 0xd2, 0x29, 0xdf, 0xdf, 0x92, 0x47, 0x5c, 0x8b, 0xdc, 0x82, + 0x7, 0x7e, 0xc0, 0x4, 0x1b, 0x21, 0x5, 0xac, 0xea, 0x66, 0x57, 0xf9, 0x81, 0x1d}; + uint8_t byteswillprops4[] = {0x11, 0x4d, 0x39, 0x8b, 0xe5, 0xb1, 0xb2, 0xd4, 0x38, 0x33, 0x2e, + 0x4c, 0x4d, 0x7b, 0x4c, 0xdd, 0xd8, 0x35, 0x61, 0x8e, 0xf5, 0x8c}; + uint8_t byteswillprops5[] = {0xc9, 0xbe, 0x6, 0x5, 0xd4, 0xd1, 0x54, 0xf7, 0xb2, 0x39, 0x70}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20703}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30839}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31512}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {22, (char*)&byteswillprops0}, .v = {24, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&byteswillprops5}}}, + }; + + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2b, 0xb1, 0xf6, 0xbb, 0x7e, 0x85}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x97, 0xbd, 0x33, 0x1e, 0xaf, 0xc6, 0xa6, 0x6a}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 4479; + uint8_t client_id_bytes[] = {0x94, 0xe9, 0xd2, 0x65, 0x19, 0xa8, 0x82, 0x85, 0xfd, 0x1, 0xe8, 0xcf, 0x66, + 0xad, 0xdc, 0xee, 0xa7, 0xa6, 0x76, 0x47, 0xb, 0x8d, 0xbe, 0x22, 0x3b}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xd, 0x29, 0xbe, 0x5f, 0x8a, 0x14, 0xe, 0xa3, 0xe2, 0x6a, 0xbd, 0x20, 0x7e, 0x2a, 0x42, + 0x4e, 0xf, 0x4, 0x2d, 0xd9, 0x80, 0xe8, 0xdf, 0xef, 0x81, 0x6d, 0x7, 0x10, 0x47, 0xfe}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\193=\216", _password = Nothing, _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 20616, _connID = "H\197jy\150\206eUf&\224\&9\ACK", _properties = [PropMessageExpiryInterval +// 29488,PropSessionExpiryInterval 29737,PropResponseTopic +// "Ls5x<+3\252\&4\144\174\CAN6'\ENQ\239Ahs?\DLE[",PropSessionExpiryInterval 5430,PropSubscriptionIdentifierAvailable +// 227,PropReasonString "yKY\251\167me\234W\197M\201 +// c\166\159\DC4\218\206/\132\151\203\DC1\238l\tF\192",PropSharedSubscriptionAvailable 99,PropResponseInformation +// "",PropSessionExpiryInterval 17158,PropContentType "N\220",PropTopicAlias 12265,PropSharedSubscriptionAvailable +// 66,PropRequestResponseInformation 71,PropContentType +// "\153\250\142\165\205PH\235\SOH\152\128o",PropResponseInformation +// "|\222\"SX\r\FS\153$\213\&5\ESCt=\235\143\SOcj\192\162\187j",PropMaximumQoS 134,PropMessageExpiryInterval +// 30799,PropServerKeepAlive 31360,PropAuthenticationMethod "\140\150\CAN\178\188\220\&5\r-\175",PropCorrelationData +// "\DC3\226",PropReceiveMaximum 31509]} +TEST(Connect5QCTest, Encode83) { + uint8_t pkt[] = {0x10, 0xc8, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x82, 0x50, 0x88, 0xa8, 0x1, 0x2, 0x0, + 0x0, 0x73, 0x30, 0x11, 0x0, 0x0, 0x74, 0x29, 0x8, 0x0, 0x16, 0x4c, 0x73, 0x35, 0x78, 0x3c, 0x2b, + 0x33, 0xfc, 0x34, 0x90, 0xae, 0x18, 0x36, 0x27, 0x5, 0xef, 0x41, 0x68, 0x73, 0x3f, 0x10, 0x5b, 0x11, + 0x0, 0x0, 0x15, 0x36, 0x29, 0xe3, 0x1f, 0x0, 0x1d, 0x79, 0x4b, 0x59, 0xfb, 0xa7, 0x6d, 0x65, 0xea, + 0x57, 0xc5, 0x4d, 0xc9, 0x20, 0x63, 0xa6, 0x9f, 0x14, 0xda, 0xce, 0x2f, 0x84, 0x97, 0xcb, 0x11, 0xee, + 0x6c, 0x9, 0x46, 0xc0, 0x2a, 0x63, 0x1a, 0x0, 0x0, 0x11, 0x0, 0x0, 0x43, 0x6, 0x3, 0x0, 0x2, + 0x4e, 0xdc, 0x23, 0x2f, 0xe9, 0x2a, 0x42, 0x19, 0x47, 0x3, 0x0, 0xc, 0x99, 0xfa, 0x8e, 0xa5, 0xcd, + 0x50, 0x48, 0xeb, 0x1, 0x98, 0x80, 0x6f, 0x1a, 0x0, 0x17, 0x7c, 0xde, 0x22, 0x53, 0x58, 0xd, 0x1c, + 0x99, 0x24, 0xd5, 0x35, 0x1b, 0x74, 0x3d, 0xeb, 0x8f, 0xe, 0x63, 0x6a, 0xc0, 0xa2, 0xbb, 0x6a, 0x24, + 0x86, 0x2, 0x0, 0x0, 0x78, 0x4f, 0x13, 0x7a, 0x80, 0x15, 0x0, 0xa, 0x8c, 0x96, 0x18, 0xb2, 0xbc, + 0xdc, 0x35, 0xd, 0x2d, 0xaf, 0x9, 0x0, 0x2, 0x13, 0xe2, 0x21, 0x7b, 0x15, 0x0, 0xd, 0x48, 0xc5, + 0x6a, 0x79, 0x96, 0xce, 0x65, 0x55, 0x66, 0x26, 0xe0, 0x39, 0x6, 0x0, 0x3, 0xc1, 0x3d, 0xd8}; + + uint8_t buf[213] = {0}; + + uint8_t bytesprops0[] = {0x4c, 0x73, 0x35, 0x78, 0x3c, 0x2b, 0x33, 0xfc, 0x34, 0x90, 0xae, + 0x18, 0x36, 0x27, 0x5, 0xef, 0x41, 0x68, 0x73, 0x3f, 0x10, 0x5b}; + uint8_t bytesprops1[] = {0x79, 0x4b, 0x59, 0xfb, 0xa7, 0x6d, 0x65, 0xea, 0x57, 0xc5, 0x4d, 0xc9, 0x20, 0x63, 0xa6, + 0x9f, 0x14, 0xda, 0xce, 0x2f, 0x84, 0x97, 0xcb, 0x11, 0xee, 0x6c, 0x9, 0x46, 0xc0}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x4e, 0xdc}; + uint8_t bytesprops4[] = {0x99, 0xfa, 0x8e, 0xa5, 0xcd, 0x50, 0x48, 0xeb, 0x1, 0x98, 0x80, 0x6f}; + uint8_t bytesprops5[] = {0x7c, 0xde, 0x22, 0x53, 0x58, 0xd, 0x1c, 0x99, 0x24, 0xd5, 0x35, 0x1b, + 0x74, 0x3d, 0xeb, 0x8f, 0xe, 0x63, 0x6a, 0xc0, 0xa2, 0xbb, 0x6a}; + uint8_t bytesprops6[] = {0x8c, 0x96, 0x18, 0xb2, 0xbc, 0xdc, 0x35, 0xd, 0x2d, 0xaf}; + uint8_t bytesprops7[] = {0x13, 0xe2}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29488}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29737}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5430}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17158}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12265}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30799}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31360}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31509}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 20616; + uint8_t client_id_bytes[] = {0x48, 0xc5, 0x6a, 0x79, 0x96, 0xce, 0x65, 0x55, 0x66, 0x26, 0xe0, 0x39, 0x6}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xc1, 0x3d, 0xd8}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "\DLE\162\233\185\169\148\163\FS\DLE\DLE\EM\128\172$0\v\163\NAK\171\178o\152\247\162", _password = Just +// "\SYN)'\EMZ{&\170*\141\175\195\166\136\153%P\165\171Q\221Ps\200", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS1, _willTopic = +// "\179j\234\186\173`\r5\139\224\166\231v\170\206~\241\ENQ7\249\230\240\135\&2\249\173ou\130", _willMsg = +// "\184\198C\184", _willProps = [PropSharedSubscriptionAvailable 97,PropReasonString +// "Qx\242(`\168?L\196\NUL\GS\199\&80\131\207*\205\155\&9%5",PropAuthenticationData "",PropTopicAlias +// 8045,PropServerKeepAlive 6785,PropResponseTopic +// "\165\244\r\164\209\238&\148\238\ETX\222}z\174\144\154@\203[\157\222",PropMaximumPacketSize +// 9028,PropPayloadFormatIndicator 201,PropTopicAliasMaximum 26182,PropSessionExpiryInterval +// 10590,PropSessionExpiryInterval 14802,PropAuthenticationData +// "HE\197Ob\t\129\189>\237\230.\185m\SUB3-\211G",PropRequestProblemInformation 135,PropReasonString +// "\219\255\142",PropReasonString "\t%UZ",PropUserProperty "\226" "",PropSessionExpiryInterval +// 18513,PropWildcardSubscriptionAvailable 239,PropMaximumPacketSize 21805]}), _cleanSession = True, _keepAlive = 23215, +// _connID = "'\ESC", _properties = [PropAuthenticationMethod +// "\198^NL]\DLEA(\NAKG+\195-\NAK\219h",PropRequestResponseInformation 124,PropWillDelayInterval +// 1971,PropWildcardSubscriptionAvailable 130,PropMaximumPacketSize 1315,PropSubscriptionIdentifier +// 22,PropAuthenticationData "\163\244\181\255\217\157\198`\DC4\144",PropMaximumQoS 80,PropTopicAliasMaximum +// 9708,PropSessionExpiryInterval 9993,PropReasonString "\DC1",PropMaximumPacketSize 26296,PropSessionExpiryInterval +// 6407,PropSharedSubscriptionAvailable 177,PropCorrelationData +// "\151\193\187\168\"W\163\128\169\SUBx\FS\148k{\176",PropReceiveMaximum 30173,PropReasonString +// "\199\186",PropResponseInformation "]-\182\240\167\SUB\153\174<\CAN\FS\NAK\136+H\204\128#",PropServerReference +// "\187>\224\253\SOH\SOH\140\218\f\ACK",PropTopicAliasMaximum 32410,PropResponseInformation +// ":G\150\STX",PropSharedSubscriptionAvailable 32,PropMaximumPacketSize 3674,PropMessageExpiryInterval 7003]} +TEST(Connect5QCTest, Encode84) { + uint8_t pkt[] = { + 0x10, 0x8f, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x5a, 0xaf, 0x9d, 0x1, 0x15, 0x0, 0x10, 0xc6, + 0x5e, 0x4e, 0x4c, 0x5d, 0x10, 0x41, 0x28, 0x15, 0x47, 0x2b, 0xc3, 0x2d, 0x15, 0xdb, 0x68, 0x19, 0x7c, 0x18, 0x0, + 0x0, 0x7, 0xb3, 0x28, 0x82, 0x27, 0x0, 0x0, 0x5, 0x23, 0xb, 0x16, 0x16, 0x0, 0xa, 0xa3, 0xf4, 0xb5, 0xff, + 0xd9, 0x9d, 0xc6, 0x60, 0x14, 0x90, 0x24, 0x50, 0x22, 0x25, 0xec, 0x11, 0x0, 0x0, 0x27, 0x9, 0x1f, 0x0, 0x1, + 0x11, 0x27, 0x0, 0x0, 0x66, 0xb8, 0x11, 0x0, 0x0, 0x19, 0x7, 0x2a, 0xb1, 0x9, 0x0, 0x10, 0x97, 0xc1, 0xbb, + 0xa8, 0x22, 0x57, 0xa3, 0x80, 0xa9, 0x1a, 0x78, 0x1c, 0x94, 0x6b, 0x7b, 0xb0, 0x21, 0x75, 0xdd, 0x1f, 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x0, 0x11, 0x0, 0x0, + 0x48, 0x51, 0x28, 0xef, 0x27, 0x0, 0x0, 0x55, 0x2d, 0x0, 0x1d, 0xb3, 0x6a, 0xea, 0xba, 0xad, 0x60, 0xd, 0x35, + 0x8b, 0xe0, 0xa6, 0xe7, 0x76, 0xaa, 0xce, 0x7e, 0xf1, 0x5, 0x37, 0xf9, 0xe6, 0xf0, 0x87, 0x32, 0xf9, 0xad, 0x6f, + 0x75, 0x82, 0x0, 0x4, 0xb8, 0xc6, 0x43, 0xb8, 0x0, 0x18, 0x10, 0xa2, 0xe9, 0xb9, 0xa9, 0x94, 0xa3, 0x1c, 0x10, + 0x10, 0x19, 0x80, 0xac, 0x24, 0x30, 0xb, 0xa3, 0x15, 0xab, 0xb2, 0x6f, 0x98, 0xf7, 0xa2, 0x0, 0x18, 0x16, 0x29, + 0x27, 0x19, 0x5a, 0x7b, 0x26, 0xaa, 0x2a, 0x8d, 0xaf, 0xc3, 0xa6, 0x88, 0x99, 0x25, 0x50, 0xa5, 0xab, 0x51, 0xdd, + 0x50, 0x73, 0xc8}; + + uint8_t buf[412] = {0}; + + uint8_t bytesprops0[] = {0xc6, 0x5e, 0x4e, 0x4c, 0x5d, 0x10, 0x41, 0x28, + 0x15, 0x47, 0x2b, 0xc3, 0x2d, 0x15, 0xdb, 0x68}; + uint8_t bytesprops1[] = {0xa3, 0xf4, 0xb5, 0xff, 0xd9, 0x9d, 0xc6, 0x60, 0x14, 0x90}; + uint8_t bytesprops2[] = {0x11}; + uint8_t bytesprops3[] = {0x97, 0xc1, 0xbb, 0xa8, 0x22, 0x57, 0xa3, 0x80, + 0xa9, 0x1a, 0x78, 0x1c, 0x94, 0x6b, 0x7b, 0xb0}; + uint8_t bytesprops4[] = {0xc7, 0xba}; + uint8_t bytesprops5[] = {0x5d, 0x2d, 0xb6, 0xf0, 0xa7, 0x1a, 0x99, 0xae, 0x3c, + 0x18, 0x1c, 0x15, 0x88, 0x2b, 0x48, 0xcc, 0x80, 0x23}; + uint8_t bytesprops6[] = {0xbb, 0x3e, 0xe0, 0xfd, 0x1, 0x1, 0x8c, 0xda, 0xc, 0x6}; + uint8_t bytesprops7[] = {0x3a, 0x47, 0x96, 0x2}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1971}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1315}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9708}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9993}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26296}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6407}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30173}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32410}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3674}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7003}}, + }; + + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x51, 0x78, 0xf2, 0x28, 0x60, 0xa8, 0x3f, 0x4c, 0xc4, 0x0, 0x1d, + 0xc7, 0x38, 0x30, 0x83, 0xcf, 0x2a, 0xcd, 0x9b, 0x39, 0x25, 0x35}; + uint8_t byteswillprops1[] = {0}; + uint8_t byteswillprops2[] = {0xa5, 0xf4, 0xd, 0xa4, 0xd1, 0xee, 0x26, 0x94, 0xee, 0x3, 0xde, + 0x7d, 0x7a, 0xae, 0x90, 0x9a, 0x40, 0xcb, 0x5b, 0x9d, 0xde}; + uint8_t byteswillprops3[] = {0x48, 0x45, 0xc5, 0x4f, 0x62, 0x9, 0x81, 0xbd, 0x3e, 0xed, + 0xe6, 0x2e, 0xb9, 0x6d, 0x1a, 0x33, 0x2d, 0xd3, 0x47}; + uint8_t byteswillprops4[] = {0xdb, 0xff, 0x8e}; + uint8_t byteswillprops5[] = {0x9, 0x25, 0x55, 0x5a}; + uint8_t byteswillprops7[] = {0}; + uint8_t byteswillprops6[] = {0xe2}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8045}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6785}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9028}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26182}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10590}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14802}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {1, (char*)&byteswillprops6}, .v = {0, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18513}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21805}}, + }; + + lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb3, 0x6a, 0xea, 0xba, 0xad, 0x60, 0xd, 0x35, 0x8b, 0xe0, + 0xa6, 0xe7, 0x76, 0xaa, 0xce, 0x7e, 0xf1, 0x5, 0x37, 0xf9, + 0xe6, 0xf0, 0x87, 0x32, 0xf9, 0xad, 0x6f, 0x75, 0x82}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb8, 0xc6, 0x43, 0xb8}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23215; + uint8_t client_id_bytes[] = {0x27, 0x1b}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x10, 0xa2, 0xe9, 0xb9, 0xa9, 0x94, 0xa3, 0x1c, 0x10, 0x10, 0x19, 0x80, + 0xac, 0x24, 0x30, 0xb, 0xa3, 0x15, 0xab, 0xb2, 0x6f, 0x98, 0xf7, 0xa2}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x16, 0x29, 0x27, 0x19, 0x5a, 0x7b, 0x26, 0xaa, 0x2a, 0x8d, 0xaf, 0xc3, + 0xa6, 0x88, 0x99, 0x25, 0x50, 0xa5, 0xab, 0x51, 0xdd, 0x50, 0x73, 0xc8}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\214", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS0, _willTopic = "\162\190\DC4\DC4\rt\172-\134\146\171Y\SUB\181GJ\232\223", _willMsg = "", _willProps = +// [PropMessageExpiryInterval 2668,PropContentType +// "a\250\155\193\222\253\221\130d\151\&2\195;-\128G\DC4\231\ACK^-\232w\194\236\DEL\212",PropRequestResponseInformation +// 218,PropMessageExpiryInterval 20814,PropMaximumPacketSize 24455,PropWildcardSubscriptionAvailable +// 17,PropMessageExpiryInterval 27712]}), _cleanSession = False, _keepAlive = 3268, _connID = +// "X\ENQ\249\146\ti\193j\128\159\242\ACK\200\143\vTWH]\156\DEL", _properties = [PropServerKeepAlive +// 13392,PropResponseInformation +// "\185C\227'\DEL\ACK\b$\244\219\252\254\STX\191\209Hs\EOT\STX^5\132",PropSessionExpiryInterval 7071,PropMaximumQoS +// 91,PropRequestProblemInformation 198,PropContentType +// "\133^6\183^\198\143l\rrA\DC4\SOC\130t+\SYN9",PropTopicAliasMaximum 24597,PropSessionExpiryInterval +// 25612,PropTopicAliasMaximum 13004,PropWildcardSubscriptionAvailable 179,PropCorrelationData +// "\144\244l\RSl]\206\134\RS\156}6Aq\197\197\SIp\188\249\173B\223w\141\142\DC4\219\199\178",PropReceiveMaximum +// 31787,PropMessageExpiryInterval 6868,PropWildcardSubscriptionAvailable 8,PropAuthenticationData +// "@\236\171\225\232L\159e\157\a\250[\192\230\167\r\140\128\137sY\138\t9a3\EM",PropSessionExpiryInterval +// 23555,PropMessageExpiryInterval 25043,PropResponseTopic "\251T4=\145",PropAssignedClientIdentifier +// "\133\141\166\f\137\"\214\212\156\GS#cD\235j\229$\251\228\FS",PropRetainAvailable +// 151,PropSubscriptionIdentifierAvailable 152,PropServerReference +// "7t\213$V\174\208\143\143.\197\156@\SUB\247\233,3[L\NUL\236\152",PropCorrelationData "",PropMessageExpiryInterval +// 12365,PropRequestProblemInformation 44]} +TEST(Connect5QCTest, Encode85) { + uint8_t pkt[] = { + 0x10, 0xd2, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x24, 0xc, 0xc4, 0xe2, 0x1, 0x13, 0x34, 0x50, 0x1a, + 0x0, 0x16, 0xb9, 0x43, 0xe3, 0x27, 0x7f, 0x6, 0x8, 0x24, 0xf4, 0xdb, 0xfc, 0xfe, 0x2, 0xbf, 0xd1, 0x48, 0x73, + 0x4, 0x2, 0x5e, 0x35, 0x84, 0x11, 0x0, 0x0, 0x1b, 0x9f, 0x24, 0x5b, 0x17, 0xc6, 0x3, 0x0, 0x13, 0x85, 0x5e, + 0x36, 0xb7, 0x5e, 0xc6, 0x8f, 0x6c, 0xd, 0x72, 0x41, 0x14, 0xe, 0x43, 0x82, 0x74, 0x2b, 0x16, 0x39, 0x22, 0x60, + 0x15, 0x11, 0x0, 0x0, 0x64, 0xc, 0x22, 0x32, 0xcc, 0x28, 0xb3, 0x9, 0x0, 0x1e, 0x90, 0xf4, 0x6c, 0x1e, 0x6c, + 0x5d, 0xce, 0x86, 0x1e, 0x9c, 0x7d, 0x36, 0x41, 0x71, 0xc5, 0xc5, 0xf, 0x70, 0xbc, 0xf9, 0xad, 0x42, 0xdf, 0x77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x19, 0xda, 0x2, 0x0, + 0x0, 0x51, 0x4e, 0x27, 0x0, 0x0, 0x5f, 0x87, 0x28, 0x11, 0x2, 0x0, 0x0, 0x6c, 0x40, 0x0, 0x12, 0xa2, 0xbe, + 0x14, 0x14, 0xd, 0x74, 0xac, 0x2d, 0x86, 0x92, 0xab, 0x59, 0x1a, 0xb5, 0x47, 0x4a, 0xe8, 0xdf, 0x0, 0x0}; + + uint8_t buf[351] = {0}; + + uint8_t bytesprops0[] = {0xb9, 0x43, 0xe3, 0x27, 0x7f, 0x6, 0x8, 0x24, 0xf4, 0xdb, 0xfc, + 0xfe, 0x2, 0xbf, 0xd1, 0x48, 0x73, 0x4, 0x2, 0x5e, 0x35, 0x84}; + uint8_t bytesprops1[] = {0x85, 0x5e, 0x36, 0xb7, 0x5e, 0xc6, 0x8f, 0x6c, 0xd, 0x72, + 0x41, 0x14, 0xe, 0x43, 0x82, 0x74, 0x2b, 0x16, 0x39}; + uint8_t bytesprops2[] = {0x90, 0xf4, 0x6c, 0x1e, 0x6c, 0x5d, 0xce, 0x86, 0x1e, 0x9c, 0x7d, 0x36, 0x41, 0x71, 0xc5, + 0xc5, 0xf, 0x70, 0xbc, 0xf9, 0xad, 0x42, 0xdf, 0x77, 0x8d, 0x8e, 0x14, 0xdb, 0xc7, 0xb2}; + uint8_t bytesprops3[] = {0x40, 0xec, 0xab, 0xe1, 0xe8, 0x4c, 0x9f, 0x65, 0x9d, 0x7, 0xfa, 0x5b, 0xc0, 0xe6, + 0xa7, 0xd, 0x8c, 0x80, 0x89, 0x73, 0x59, 0x8a, 0x9, 0x39, 0x61, 0x33, 0x19}; + uint8_t bytesprops4[] = {0xfb, 0x54, 0x34, 0x3d, 0x91}; + uint8_t bytesprops5[] = {0x85, 0x8d, 0xa6, 0xc, 0x89, 0x22, 0xd6, 0xd4, 0x9c, 0x1d, + 0x23, 0x63, 0x44, 0xeb, 0x6a, 0xe5, 0x24, 0xfb, 0xe4, 0x1c}; + uint8_t bytesprops6[] = {0x37, 0x74, 0xd5, 0x24, 0x56, 0xae, 0xd0, 0x8f, 0x8f, 0x2e, 0xc5, 0x9c, + 0x40, 0x1a, 0xf7, 0xe9, 0x2c, 0x33, 0x5b, 0x4c, 0x0, 0xec, 0x98}; + uint8_t bytesprops7[] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13392}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7071}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24597}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25612}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13004}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31787}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6868}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23555}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25043}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12365}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 44}}, + }; + + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x61, 0xfa, 0x9b, 0xc1, 0xde, 0xfd, 0xdd, 0x82, 0x64, 0x97, 0x32, 0xc3, 0x3b, 0x2d, + 0x80, 0x47, 0x14, 0xe7, 0x6, 0x5e, 0x2d, 0xe8, 0x77, 0xc2, 0xec, 0x7f, 0xd4}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2668}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20814}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24455}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27712}}, + }; + + lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa2, 0xbe, 0x14, 0x14, 0xd, 0x74, 0xac, 0x2d, 0x86, + 0x92, 0xab, 0x59, 0x1a, 0xb5, 0x47, 0x4a, 0xe8, 0xdf}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3268; + uint8_t client_id_bytes[] = {0x58, 0x5, 0xf9, 0x92, 0x9, 0x69, 0xc1, 0x6a, 0x80, 0x9f, 0xf2, + 0x6, 0xc8, 0x8f, 0xb, 0x54, 0x57, 0x48, 0x5d, 0x9c, 0x7f}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xd6}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// ")\156AQ\231\191\SYN\185h\225\178\137\238\&3\EOT\138\248\&7R\EM,*\SYN=\n\224\DC2", _lastWill = Nothing, _cleanSession +// = True, _keepAlive = 28678, _connID = +// "\189\132\188/]\224s+\NULTF\196\233U\GS\250L\167\176\EM\133\NUL\254\161Ol\136\162\209", _properties = +// [PropReceiveMaximum 15858,PropServerReference "",PropAuthenticationData +// "\207\177<\220\196Y\170\EM\208\204o",PropCorrelationData +// "J\DEL\175\233\219\227\204\&3\175\CANF\246\182\146\163Y\214\133\\\SI\190\226\234\f\135`Ey",PropResponseInformation +// "k\SYN\188t\231\r;\221\142.\137\DLE\NAK \197E\181\248\178",PropPayloadFormatIndicator 44,PropUserProperty +// "\t\182\149\164B\132;\187\215\201\SO\ACK\194j" "0b",PropTopicAliasMaximum 19404,PropMessageExpiryInterval +// 32432,PropTopicAliasMaximum 21496,PropSharedSubscriptionAvailable 216,PropWillDelayInterval +// 24641,PropAuthenticationMethod "\145\217\155\157",PropResponseTopic +// "\SYN/\143\DC1(l#\187\242\242\DC4P0",PropAuthenticationData "\190\235-",PropMaximumPacketSize +// 19451,PropServerReference "\175\207\a.\NAK\246",PropResponseTopic +// "\SUB\NAK\211\161f\DC2\179\238H6\157\145\247\130OgP*\NULw\212.\199&\224\145\242\231\145\205"]} +TEST(Connect5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3, 0xee, 0x48, 0x36, 0x9d, 0x91, + 0xf7, 0x82, 0x4f, 0x67, 0x50, 0x2a, 0x0, 0x77, 0xd4, 0x2e, 0xc7, 0x26, 0xe0, 0x91, 0xf2, 0xe7, 0x91, + 0xcd, 0x0, 0x1d, 0xbd, 0x84, 0xbc, 0x2f, 0x5d, 0xe0, 0x73, 0x2b, 0x0, 0x54, 0x46, 0xc4, 0xe9, 0x55, + 0x1d, 0xfa, 0x4c, 0xa7, 0xb0, 0x19, 0x85, 0x0, 0xfe, 0xa1, 0x4f, 0x6c, 0x88, 0xa2, 0xd1}; + + uint8_t buf[246] = {0}; + + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xcf, 0xb1, 0x3c, 0xdc, 0xc4, 0x59, 0xaa, 0x19, 0xd0, 0xcc, 0x6f}; + uint8_t bytesprops2[] = {0x4a, 0x7f, 0xaf, 0xe9, 0xdb, 0xe3, 0xcc, 0x33, 0xaf, 0x18, 0x46, 0xf6, 0xb6, 0x92, + 0xa3, 0x59, 0xd6, 0x85, 0x5c, 0xf, 0xbe, 0xe2, 0xea, 0xc, 0x87, 0x60, 0x45, 0x79}; + uint8_t bytesprops3[] = {0x6b, 0x16, 0xbc, 0x74, 0xe7, 0xd, 0x3b, 0xdd, 0x8e, 0x2e, + 0x89, 0x10, 0x15, 0x20, 0xc5, 0x45, 0xb5, 0xf8, 0xb2}; + uint8_t bytesprops5[] = {0x30, 0x62}; + uint8_t bytesprops4[] = {0x9, 0xb6, 0x95, 0xa4, 0x42, 0x84, 0x3b, 0xbb, 0xd7, 0xc9, 0xe, 0x6, 0xc2, 0x6a}; + uint8_t bytesprops6[] = {0x91, 0xd9, 0x9b, 0x9d}; + uint8_t bytesprops7[] = {0x16, 0x2f, 0x8f, 0x11, 0x28, 0x6c, 0x23, 0xbb, 0xf2, 0xf2, 0x14, 0x50, 0x30}; + uint8_t bytesprops8[] = {0xbe, 0xeb, 0x2d}; + uint8_t bytesprops9[] = {0xaf, 0xcf, 0x7, 0x2e, 0x15, 0xf6}; + uint8_t bytesprops10[] = {0x1a, 0x15, 0xd3, 0xa1, 0x66, 0x12, 0xb3, 0xee, 0x48, 0x36, 0x9d, 0x91, 0xf7, 0x82, 0x4f, + 0x67, 0x50, 0x2a, 0x0, 0x77, 0xd4, 0x2e, 0xc7, 0x26, 0xe0, 0x91, 0xf2, 0xe7, 0x91, 0xcd}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15858}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19404}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32432}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21496}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24641}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19451}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops10}}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 28678; + uint8_t client_id_bytes[] = {0xbd, 0x84, 0xbc, 0x2f, 0x5d, 0xe0, 0x73, 0x2b, 0x0, 0x54, 0x46, 0xc4, 0xe9, 0x55, 0x1d, + 0xfa, 0x4c, 0xa7, 0xb0, 0x19, 0x85, 0x0, 0xfe, 0xa1, 0x4f, 0x6c, 0x88, 0xa2, 0xd1}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x29, 0x9c, 0x41, 0x51, 0xe7, 0xbf, 0x16, 0xb9, 0x68, 0xe1, 0xb2, 0x89, 0xee, 0x33, + 0x4, 0x8a, 0xf8, 0x37, 0x52, 0x19, 0x2c, 0x2a, 0x16, 0x3d, 0xa, 0xe0, 0x12}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\231\136\157", _password = Nothing, _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 27015, _connID = "c\202.c\142W#U\130p\148q(O\219m", _properties = [PropTopicAliasMaximum +// 1328,PropSharedSubscriptionAvailable 102,PropTopicAliasMaximum 18059,PropTopicAlias 15044,PropContentType +// "\t\138k\190\169",PropMaximumPacketSize 20110,PropAuthenticationData +// "2q\166o\171\206aJ$t\141\139Q{\DEL",PropMessageExpiryInterval 11401,PropReasonString +// "\160aNz\178e<\175lb\208\231\255\192\&0\199k\254\NAK\ry\"8gA\238",PropCorrelationData +// "\190XDv\SOH\195\197\228k~\210\SId\167\211\129[\198\247\197Q",PropAuthenticationMethod +// "\173\156\134\169\DC3IN\231H\225`\DLE\238\135\133\241\253G\170\145]\189\139\201\223",PropAssignedClientIdentifier +// "\128\133l\161\206?\144\215\145m\160\221",PropResponseInformation +// "Y\147\224X\192\238=\b\EOT\147UT9\148\239\252\NUL",PropMessageExpiryInterval 15590,PropRequestProblemInformation +// 15,PropSharedSubscriptionAvailable 43,PropSubscriptionIdentifier 3,PropReceiveMaximum 3169,PropMaximumQoS +// 110,PropMessageExpiryInterval 27843,PropSessionExpiryInterval 17032,PropUserProperty +// "\213R,\DLE\160j\238\b\238\173\243`t,\STX\SO\FS\135\150\180\DC2vct\137p\135w" ">\253\202\194\245\219j",PropTopicAlias +// 27026]} +TEST(Connect5QCTest, Encode87) { + uint8_t pkt[] = {0x10, 0x8b, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x82, 0x69, 0x87, 0xe8, 0x1, 0x22, 0x5, + 0x30, 0x2a, 0x66, 0x22, 0x46, 0x8b, 0x23, 0x3a, 0xc4, 0x3, 0x0, 0x5, 0x9, 0x8a, 0x6b, 0xbe, 0xa9, + 0x27, 0x0, 0x0, 0x4e, 0x8e, 0x16, 0x0, 0xf, 0x32, 0x71, 0xa6, 0x6f, 0xab, 0xce, 0x61, 0x4a, 0x24, + 0x74, 0x8d, 0x8b, 0x51, 0x7b, 0x7f, 0x2, 0x0, 0x0, 0x2c, 0x89, 0x1f, 0x0, 0x1a, 0xa0, 0x61, 0x4e, + 0x7a, 0xb2, 0x65, 0x3c, 0xaf, 0x6c, 0x62, 0xd0, 0xe7, 0xff, 0xc0, 0x30, 0xc7, 0x6b, 0xfe, 0x15, 0xd, + 0x79, 0x22, 0x38, 0x67, 0x41, 0xee, 0x9, 0x0, 0x15, 0xbe, 0x58, 0x44, 0x76, 0x1, 0xc3, 0xc5, 0xe4, + 0x6b, 0x7e, 0xd2, 0xf, 0x64, 0xa7, 0xd3, 0x81, 0x5b, 0xc6, 0xf7, 0xc5, 0x51, 0x15, 0x0, 0x19, 0xad, + 0x9c, 0x86, 0xa9, 0x13, 0x49, 0x4e, 0xe7, 0x48, 0xe1, 0x60, 0x10, 0xee, 0x87, 0x85, 0xf1, 0xfd, 0x47, + 0xaa, 0x91, 0x5d, 0xbd, 0x8b, 0xc9, 0xdf, 0x12, 0x0, 0xc, 0x80, 0x85, 0x6c, 0xa1, 0xce, 0x3f, 0x90, + 0xd7, 0x91, 0x6d, 0xa0, 0xdd, 0x1a, 0x0, 0x11, 0x59, 0x93, 0xe0, 0x58, 0xc0, 0xee, 0x3d, 0x8, 0x4, + 0x93, 0x55, 0x54, 0x39, 0x94, 0xef, 0xfc, 0x0, 0x2, 0x0, 0x0, 0x3c, 0xe6, 0x17, 0xf, 0x2a, 0x2b, + 0xb, 0x3, 0x21, 0xc, 0x61, 0x24, 0x6e, 0x2, 0x0, 0x0, 0x6c, 0xc3, 0x11, 0x0, 0x0, 0x42, 0x88, + 0x26, 0x0, 0x1c, 0xd5, 0x52, 0x2c, 0x10, 0xa0, 0x6a, 0xee, 0x8, 0xee, 0xad, 0xf3, 0x60, 0x74, 0x2c, + 0x2, 0xe, 0x1c, 0x87, 0x96, 0xb4, 0x12, 0x76, 0x63, 0x74, 0x89, 0x70, 0x87, 0x77, 0x0, 0x7, 0x3e, + 0xfd, 0xca, 0xc2, 0xf5, 0xdb, 0x6a, 0x23, 0x69, 0x92, 0x0, 0x10, 0x63, 0xca, 0x2e, 0x63, 0x8e, 0x57, + 0x23, 0x55, 0x82, 0x70, 0x94, 0x71, 0x28, 0x4f, 0xdb, 0x6d, 0x0, 0x3, 0xe7, 0x88, 0x9d}; + + uint8_t buf[280] = {0}; + + uint8_t bytesprops0[] = {0x9, 0x8a, 0x6b, 0xbe, 0xa9}; + uint8_t bytesprops1[] = {0x32, 0x71, 0xa6, 0x6f, 0xab, 0xce, 0x61, 0x4a, 0x24, 0x74, 0x8d, 0x8b, 0x51, 0x7b, 0x7f}; + uint8_t bytesprops2[] = {0xa0, 0x61, 0x4e, 0x7a, 0xb2, 0x65, 0x3c, 0xaf, 0x6c, 0x62, 0xd0, 0xe7, 0xff, + 0xc0, 0x30, 0xc7, 0x6b, 0xfe, 0x15, 0xd, 0x79, 0x22, 0x38, 0x67, 0x41, 0xee}; + uint8_t bytesprops3[] = {0xbe, 0x58, 0x44, 0x76, 0x1, 0xc3, 0xc5, 0xe4, 0x6b, 0x7e, 0xd2, + 0xf, 0x64, 0xa7, 0xd3, 0x81, 0x5b, 0xc6, 0xf7, 0xc5, 0x51}; + uint8_t bytesprops4[] = {0xad, 0x9c, 0x86, 0xa9, 0x13, 0x49, 0x4e, 0xe7, 0x48, 0xe1, 0x60, 0x10, 0xee, + 0x87, 0x85, 0xf1, 0xfd, 0x47, 0xaa, 0x91, 0x5d, 0xbd, 0x8b, 0xc9, 0xdf}; + uint8_t bytesprops5[] = {0x80, 0x85, 0x6c, 0xa1, 0xce, 0x3f, 0x90, 0xd7, 0x91, 0x6d, 0xa0, 0xdd}; + uint8_t bytesprops6[] = {0x59, 0x93, 0xe0, 0x58, 0xc0, 0xee, 0x3d, 0x8, 0x4, + 0x93, 0x55, 0x54, 0x39, 0x94, 0xef, 0xfc, 0x0}; + uint8_t bytesprops8[] = {0x3e, 0xfd, 0xca, 0xc2, 0xf5, 0xdb, 0x6a}; + uint8_t bytesprops7[] = {0xd5, 0x52, 0x2c, 0x10, 0xa0, 0x6a, 0xee, 0x8, 0xee, 0xad, 0xf3, 0x60, 0x74, 0x2c, + 0x2, 0xe, 0x1c, 0x87, 0x96, 0xb4, 0x12, 0x76, 0x63, 0x74, 0x89, 0x70, 0x87, 0x77}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1328}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18059}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15044}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20110}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11401}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15590}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3169}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27843}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17032}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops7}, .v = {7, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27026}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 27015; + uint8_t client_id_bytes[] = {0x63, 0xca, 0x2e, 0x63, 0x8e, 0x57, 0x23, 0x55, + 0x82, 0x70, 0x94, 0x71, 0x28, 0x4f, 0xdb, 0x6d}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xe7, 0x88, 0x9d}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "U\185M\196", _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 28907, _connID = ";&\203q}", _properties = [PropSubscriptionIdentifierAvailable 203,PropUserProperty +// "\227as\202\169c~\DC2\202h\254X\SYNUz" "\181FH",PropSubscriptionIdentifier 28,PropReceiveMaximum +// 26196,PropReceiveMaximum 25509,PropCorrelationData "|\181\ACK\178\NUL\229\190\140",PropCorrelationData +// "@U\165\f\205\147\&8M\241\r\226\159\214P\186\tz\248\201\a\146\215\255<\DEL",PropMaximumQoS 197,PropReceiveMaximum +// 912,PropWildcardSubscriptionAvailable 16,PropResponseTopic "\154",PropResponseInformation +// "\231o\246\171",PropPayloadFormatIndicator 166,PropRetainAvailable 111,PropTopicAliasMaximum +// 4682,PropMaximumPacketSize 13367,PropReasonString +// "\f\n9\151I(\222\136\&1$\144\135PA\210\132\183\148\&0d'",PropResponseTopic +// "\235Z\208h\168F\147G\183\213\FS@~\223\240g\aY\134\203\143p\181\&8\143",PropRequestResponseInformation +// 190,PropMessageExpiryInterval 12716,PropSharedSubscriptionAvailable 133,PropSessionExpiryInterval +// 24785,PropServerKeepAlive 16193,PropSharedSubscriptionAvailable 100,PropTopicAlias 9013,PropSessionExpiryInterval +// 32590,PropCorrelationData "\153\222\159%\157x3\216\US\250\248\231l\DC1\212\162",PropWillDelayInterval +// 11170,PropMessageExpiryInterval 23686]} +TEST(Connect5QCTest, Encode88) { + uint8_t pkt[] = {0x10, 0xe5, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2, 0x70, 0xeb, 0xd2, 0x1, 0x29, 0xcb, + 0x26, 0x0, 0xf, 0xe3, 0x61, 0x73, 0xca, 0xa9, 0x63, 0x7e, 0x12, 0xca,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0x2b, 0xa2, 0x2, + 0x0, 0x0, 0x5c, 0x86, 0x0, 0x5, 0x3b, 0x26, 0xcb, 0x71, 0x7d}; + + uint8_t buf[242] = {0}; + + uint8_t bytesprops1[] = {0xb5, 0x46, 0x48}; + uint8_t bytesprops0[] = {0xe3, 0x61, 0x73, 0xca, 0xa9, 0x63, 0x7e, 0x12, 0xca, 0x68, 0xfe, 0x58, 0x16, 0x55, 0x7a}; + uint8_t bytesprops2[] = {0x7c, 0xb5, 0x6, 0xb2, 0x0, 0xe5, 0xbe, 0x8c}; + uint8_t bytesprops3[] = {0x40, 0x55, 0xa5, 0xc, 0xcd, 0x93, 0x38, 0x4d, 0xf1, 0xd, 0xe2, 0x9f, 0xd6, + 0x50, 0xba, 0x9, 0x7a, 0xf8, 0xc9, 0x7, 0x92, 0xd7, 0xff, 0x3c, 0x7f}; + uint8_t bytesprops4[] = {0x9a}; + uint8_t bytesprops5[] = {0xe7, 0x6f, 0xf6, 0xab}; + uint8_t bytesprops6[] = {0xc, 0xa, 0x39, 0x97, 0x49, 0x28, 0xde, 0x88, 0x31, 0x24, 0x90, + 0x87, 0x50, 0x41, 0xd2, 0x84, 0xb7, 0x94, 0x30, 0x64, 0x27}; + uint8_t bytesprops7[] = {0xeb, 0x5a, 0xd0, 0x68, 0xa8, 0x46, 0x93, 0x47, 0xb7, 0xd5, 0x1c, 0x40, 0x7e, + 0xdf, 0xf0, 0x67, 0x7, 0x59, 0x86, 0xcb, 0x8f, 0x70, 0xb5, 0x38, 0x8f}; + uint8_t bytesprops8[] = {0x99, 0xde, 0x9f, 0x25, 0x9d, 0x78, 0x33, 0xd8, + 0x1f, 0xfa, 0xf8, 0xe7, 0x6c, 0x11, 0xd4, 0xa2}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {3, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26196}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25509}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 912}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4682}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13367}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12716}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24785}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16193}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9013}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32590}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11170}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23686}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 28907; + uint8_t client_id_bytes[] = {0x3b, 0x26, 0xcb, 0x71, 0x7d}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x55, 0xb9, 0x4d, 0xc4}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "t\171o\168\ETB\EOT\EOT\226\b\SI\205\166J\SOj\164\ETB\SUB\166\245\US\SUB", _password +// = Just "\NAK\169_\251\NAK\186\DLE\215\169kW3J\b\199", _lastWill = Nothing, _cleanSession = False, _keepAlive = 28413, +// _connID = "\215\188:\SYN]?\n\214\176\&2i", _properties = [PropUserProperty "Dsn\191;\139\245)]\214 \STX\189\206Q\176" +// "\231\242\&5{\SUB\179\227\180\221\209:\135\128\188\ACK\177e\NUL",PropResponseInformation +// "a\132\238\194Ge\198\204@xC@%in\RS\138!\SIl@\241"]} +TEST(Connect5QCTest, Encode89) { + uint8_t pkt[] = {0x10, 0x81, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x6e, 0xfd, 0x40, 0x26, 0x0, 0x10, + 0x44, 0x73, 0x6e, 0xbf, 0x3b, 0x8b, 0xf5, 0x29, 0x5d, 0xd6, 0x20, 0x2, 0xbd, 0xce, 0x51, 0xb0, 0x0, + 0x12, 0xe7, 0xf2, 0x35, 0x7b, 0x1a, 0xb3, 0xe3, 0xb4, 0xdd, 0xd1, 0x3a, 0x87, 0x80, 0xbc, 0x6, 0xb1, + 0x65, 0x0, 0x1a, 0x0, 0x16, 0x61, 0x84, 0xee, 0xc2, 0x47, 0x65, 0xc6, 0xcc, 0x40, 0x78, 0x43, 0x40, + 0x25, 0x69, 0x6e, 0x1e, 0x8a, 0x21, 0xf, 0x6c, 0x40, 0xf1, 0x0, 0xb, 0xd7, 0xbc, 0x3a, 0x16, 0x5d, + 0x3f, 0xa, 0xd6, 0xb0, 0x32, 0x69, 0x0, 0x16, 0x74, 0xab, 0x6f, 0xa8, 0x17, 0x4, 0x4, 0xe2, 0x8, + 0xf, 0xcd, 0xa6, 0x4a, 0xe, 0x6a, 0xa4, 0x17, 0x1a, 0xa6, 0xf5, 0x1f, 0x1a, 0x0, 0xf, 0x15, 0xa9, + 0x5f, 0xfb, 0x15, 0xba, 0x10, 0xd7, 0xa9, 0x6b, 0x57, 0x33, 0x4a, 0x8, 0xc7}; + + uint8_t buf[142] = {0}; + + uint8_t bytesprops1[] = {0xe7, 0xf2, 0x35, 0x7b, 0x1a, 0xb3, 0xe3, 0xb4, 0xdd, + 0xd1, 0x3a, 0x87, 0x80, 0xbc, 0x6, 0xb1, 0x65, 0x0}; + uint8_t bytesprops0[] = {0x44, 0x73, 0x6e, 0xbf, 0x3b, 0x8b, 0xf5, 0x29, + 0x5d, 0xd6, 0x20, 0x2, 0xbd, 0xce, 0x51, 0xb0}; + uint8_t bytesprops2[] = {0x61, 0x84, 0xee, 0xc2, 0x47, 0x65, 0xc6, 0xcc, 0x40, 0x78, 0x43, + 0x40, 0x25, 0x69, 0x6e, 0x1e, 0x8a, 0x21, 0xf, 0x6c, 0x40, 0xf1}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops0}, .v = {18, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops2}}}, + }; + + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 28413; + uint8_t client_id_bytes[] = {0xd7, 0xbc, 0x3a, 0x16, 0x5d, 0x3f, 0xa, 0xd6, 0xb0, 0x32, 0x69}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x74, 0xab, 0x6f, 0xa8, 0x17, 0x4, 0x4, 0xe2, 0x8, 0xf, 0xcd, + 0xa6, 0x4a, 0xe, 0x6a, 0xa4, 0x17, 0x1a, 0xa6, 0xf5, 0x1f, 0x1a}; + lwmqtt_string_t username = {22, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x15, 0xa9, 0x5f, 0xfb, 0x15, 0xba, 0x10, 0xd7, 0xa9, 0x6b, 0x57, 0x33, 0x4a, 0x8, 0xc7}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "M", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS1, _willTopic = "", _willMsg = "\163\147\EOT\177\219J\221\FSm_\STX\RS\rK\130D\159\n}", _willProps = +// [PropRequestResponseInformation 142,PropCorrelationData "}d\US\205\128\232tmf",PropContentType +// "\NULS\DC4\225_2M\USZA\218`,b\216\f\250\SI\157",PropResponseInformation +// "\171L8M\DC21\CAN\147\DLE\ETXR\229\151\159\EOT ",PropMaximumQoS 249,PropResponseTopic +// "\EOTu\DC2\225\176\241\146\161",PropAuthenticationMethod +// "!\143\DC2vB\188G\RS\213FH\140\129\137J\223\227\NAK",PropRequestProblemInformation 18,PropMessageExpiryInterval +// 31057,PropUserProperty "\f\231\205b\SO?\v'q_\205<\168i\210\130\238\146" "\t%\202Zl\253\153 +// \143a\EOT\237w",PropRetainAvailable 151]}), _cleanSession = True, _keepAlive = 6707, _connID = +// "\248\222\190\&6\US\171Z\135\192\253\DEL\205\US\238\ETXR\201|\SUB", _properties = [PropResponseTopic +// "\138\ESC\135\164\v\250\216z\\\154\161\203",PropMaximumPacketSize 17854,PropServerReference +// "\142\246\245\211K\171^\SI\238\171\140C\241\248C\FS\218]",PropSubscriptionIdentifierAvailable +// 167,PropMessageExpiryInterval 18201,PropMessageExpiryInterval 31288,PropCorrelationData +// "8\US,\247\193\189\207\226\251\233\DEL4\255&A\229\182l\DC4\209@\150?g",PropRequestProblemInformation +// 245,PropUserProperty "\193\168" "\207\180\179\155",PropSessionExpiryInterval 7300,PropMaximumQoS 101,PropMaximumQoS +// 160,PropCorrelationData "\200\207\189\253u~~b",PropRequestResponseInformation 107,PropSubscriptionIdentifier 18]} +TEST(Connect5QCTest, Encode90) { + uint8_t pkt[] = { + 0x10, 0xb4, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2e, 0x1a, 0x33, 0x75, 0x8, 0x0, 0xc, 0x8a, 0x1b, + 0x87, 0xa4, 0xb, 0xfa, 0xd8, 0x7a, 0x5c, 0x9a, 0xa1, 0xcb, 0x27, 0x0, 0x0, 0x45, 0xbe, 0x1c, 0x0, 0x12, 0x8e, + 0xf6, 0xf5, 0xd3, 0x4b, 0xab, 0x5e, 0xf, 0xee, 0xab, 0x8c, 0x43, 0xf1, 0xf8, 0x43, 0x1c, 0xda, 0x5d, 0x29, 0xa7, + 0x2, 0x0, 0x0, 0x47, 0x19, 0x2, 0x0, 0x0, 0x7a, 0x38, 0x9, 0x0, 0x18, 0x38, 0x1f, 0x2c, 0xf7, 0xc1, 0xbd, + 0xcf, 0xe2, 0xfb, 0xe9, 0x7f, 0x34, 0xff, 0x26, 0x41, 0xe5, 0xb6, 0x6c, 0x14, 0xd1, 0x40, 0x96, 0x3f, 0x67, 0x17, + 0xf5, 0x26, 0x0, 0x2, 0xc1, 0xa8, 0x0, 0x4, 0xcf, 0xb4, 0xb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, 0xb1, 0xdb, 0x4a, 0xdd, 0x1c, 0x6d, 0x5f, 0x2, 0x1e, + 0xd, 0x4b, 0x82, 0x44, 0x9f, 0xa, 0x7d}; + + uint8_t buf[321] = {0}; + + uint8_t bytesprops0[] = {0x8a, 0x1b, 0x87, 0xa4, 0xb, 0xfa, 0xd8, 0x7a, 0x5c, 0x9a, 0xa1, 0xcb}; + uint8_t bytesprops1[] = {0x8e, 0xf6, 0xf5, 0xd3, 0x4b, 0xab, 0x5e, 0xf, 0xee, + 0xab, 0x8c, 0x43, 0xf1, 0xf8, 0x43, 0x1c, 0xda, 0x5d}; + uint8_t bytesprops2[] = {0x38, 0x1f, 0x2c, 0xf7, 0xc1, 0xbd, 0xcf, 0xe2, 0xfb, 0xe9, 0x7f, 0x34, + 0xff, 0x26, 0x41, 0xe5, 0xb6, 0x6c, 0x14, 0xd1, 0x40, 0x96, 0x3f, 0x67}; + uint8_t bytesprops4[] = {0xcf, 0xb4, 0xb3, 0x9b}; + uint8_t bytesprops3[] = {0xc1, 0xa8}; + uint8_t bytesprops5[] = {0xc8, 0xcf, 0xbd, 0xfd, 0x75, 0x7e, 0x7e, 0x62}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17854}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18201}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31288}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops3}, .v = {4, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7300}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + }; + + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x7d, 0x64, 0x1f, 0xcd, 0x80, 0xe8, 0x74, 0x6d, 0x66}; + uint8_t byteswillprops1[] = {0x0, 0x53, 0x14, 0xe1, 0x5f, 0x32, 0x4d, 0x1f, 0x5a, 0x41, + 0xda, 0x60, 0x2c, 0x62, 0xd8, 0xc, 0xfa, 0xf, 0x9d}; + uint8_t byteswillprops2[] = {0xab, 0x4c, 0x38, 0x4d, 0x12, 0x31, 0x18, 0x93, + 0x10, 0x3, 0x52, 0xe5, 0x97, 0x9f, 0x4, 0x20}; + uint8_t byteswillprops3[] = {0x4, 0x75, 0x12, 0xe1, 0xb0, 0xf1, 0x92, 0xa1}; + uint8_t byteswillprops4[] = {0x21, 0x8f, 0x12, 0x76, 0x42, 0xbc, 0x47, 0x1e, 0xd5, + 0x46, 0x48, 0x8c, 0x81, 0x89, 0x4a, 0xdf, 0xe3, 0x15}; + uint8_t byteswillprops6[] = {0x9, 0x25, 0xca, 0x5a, 0x6c, 0xfd, 0x99, 0x20, 0x8f, 0x61, 0x4, 0xed, 0x77}; + uint8_t byteswillprops5[] = {0xc, 0xe7, 0xcd, 0x62, 0xe, 0x3f, 0xb, 0x27, 0x71, + 0x5f, 0xcd, 0x3c, 0xa8, 0x69, 0xd2, 0x82, 0xee, 0x92}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31057}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {18, (char*)&byteswillprops5}, .v = {13, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, + }; + + lwmqtt_properties_t willprops = {11, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa3, 0x93, 0x4, 0xb1, 0xdb, 0x4a, 0xdd, 0x1c, 0x6d, 0x5f, + 0x2, 0x1e, 0xd, 0x4b, 0x82, 0x44, 0x9f, 0xa, 0x7d}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 6707; + uint8_t client_id_bytes[] = {0xf8, 0xde, 0xbe, 0x36, 0x1f, 0xab, 0x5a, 0x87, 0xc0, 0xfd, + 0x7f, 0xcd, 0x1f, 0xee, 0x3, 0x52, 0xc9, 0x7c, 0x1a}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x4d}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\135\167", _password = Just "do\ETX\170V\239N\235\129|\168G\SO\218O\245SW\228", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\198\149\RSL\143\254\166!", _willMsg = +// ":\215\\\152\141^\ETXb\198", _willProps = [PropServerReference "\138",PropSubscriptionIdentifier +// 30,PropRetainAvailable 153,PropReceiveMaximum 18956,PropMessageExpiryInterval +// 23816,PropSubscriptionIdentifierAvailable 147,PropResponseInformation +// "\250Z\151[\183\193d\144E](P\181\239g\172\251\240q\180\189k\165,\b",PropSubscriptionIdentifierAvailable +// 34,PropCorrelationData "\133\220\130\235\214\244\246W\202\ACK +// @\218$\199\211\235uzSf\215fF!\160\255V\151",PropMessageExpiryInterval 19228,PropReceiveMaximum +// 15862,PropCorrelationData "89\160U\196\207,\164\221;\US7\f\220\128\145\&6c&\158R",PropServerReference +// "%\n\NAK@tW?\141\228\214\254\&8\GS\DC4J\SUB\197;?",PropTopicAlias 12803,PropRequestResponseInformation +// 24,PropWillDelayInterval 23550,PropSubscriptionIdentifierAvailable 114,PropResponseInformation +// "\155N!U\136\DC3\155y\245\139f(]0\211\SUBV\229",PropAssignedClientIdentifier +// "W]\166\225_&\137\&5\208\192",PropSessionExpiryInterval 5122,PropMessageExpiryInterval 8890,PropContentType +// "\229Q"]}), _cleanSession = True, _keepAlive = 1501, _connID = +// "\234YO\DC3;\148\207\&0\153n\199\142\146\206\254\155:", _properties = [PropResponseInformation +// "\204\143",PropRequestResponseInformation 158,PropSubscriptionIdentifierAvailable 8,PropPayloadFormatIndicator +// 12,PropCorrelationData "\211\132\206M\223\171\159\226pm",PropWildcardSubscriptionAvailable 46,PropReceiveMaximum +// 12964,PropSharedSubscriptionAvailable 216,PropAuthenticationMethod +// "\SI\vG\189?\EOT\222\162\137\190\181D?d",PropTopicAlias 20345,PropTopicAlias 8272,PropUserProperty +// "\234e\223\137\155\SYN\t\221i\219>" "\241",PropPayloadFormatIndicator 200,PropReasonString +// "C\141\208\229\CAN[\166\140\149",PropSessionExpiryInterval 26063,PropAuthenticationMethod +// "\255U\155a\213\202/\170\235\144\RS:\156\138\ETB|(\169n\192\250m"]} +TEST(Connect5QCTest, Encode91) { + uint8_t pkt[] = { + 0x10, 0x84, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x5, 0xdd, 0x73, 0x1a, 0x0, 0x2, 0xcc, 0x8f, + 0x19, 0x9e, 0x29, 0x8, 0x1, 0xc, 0x9, 0x0, 0xa, 0xd3, 0x84, 0xce, 0x4d, 0xdf, 0xab, 0x9f, 0xe2, 0x70, 0x6d, + 0x28, 0x2e, 0x21, 0x32, 0xa4, 0x2a, 0xd8, 0x15, 0x0, 0xe, 0xf, 0xb, 0x47, 0xbd, 0x3f, 0x4, 0xde, 0xa2, 0x89, + 0xbe, 0xb5, 0x44, 0x3f, 0x64, 0x23, 0x4f, 0x79, 0x23, 0x20, 0x50, 0x26, 0x0, 0xb, 0xea, 0x65, 0xdf, 0x89, 0x9b, + 0x16, 0x9, 0xdd, 0x69, 0xdb, 0x3e, 0x0, 0x1, 0xf1, 0x1, 0xc8, 0x1f, 0x0, 0x9, 0x43, 0x8d, 0xd0, 0xe5, 0x18, + 0x5b, 0xa6, 0x8c, 0x95, 0x11, 0x0, 0x0, 0x65, 0xcf, 0x15, 0x0, 0x16, 0xff, 0x55, 0x9b, 0x61, 0xd5, 0xca, 0x2f, + 0xaa, 0xeb, 0x90, 0x1e, 0x3a, 0x9c, 0x8a, 0x17, 0x7c, 0x28, 0xa9, 0x6e, 0xc0, 0xfa, 0x6d, 0x0, 0x11, 0xea, 0x59, + 0x4f, 0x13, 0x3b, 0x94, 0xcf, 0x30, 0x99, 0x6e, 0xc7, 0x8e, 0x92, 0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0x0, 0x0, 0x14, 0x2, 0x2, 0x0, 0x0, 0x22, 0xba, 0x3, 0x0, + 0x2, 0xe5, 0x51, 0x0, 0x8, 0xc6, 0x95, 0x1e, 0x4c, 0x8f, 0xfe, 0xa6, 0x21, 0x0, 0x9, 0x3a, 0xd7, 0x5c, 0x98, + 0x8d, 0x5e, 0x3, 0x62, 0xc6, 0x0, 0x2, 0x87, 0xa7, 0x0, 0x13, 0x64, 0x6f, 0x3, 0xaa, 0x56, 0xef, 0x4e, 0xeb, + 0x81, 0x7c, 0xa8, 0x47, 0xe, 0xda, 0x4f, 0xf5, 0x53, 0x57, 0xe4}; + + uint8_t buf[401] = {0}; + + uint8_t bytesprops0[] = {0xcc, 0x8f}; + uint8_t bytesprops1[] = {0xd3, 0x84, 0xce, 0x4d, 0xdf, 0xab, 0x9f, 0xe2, 0x70, 0x6d}; + uint8_t bytesprops2[] = {0xf, 0xb, 0x47, 0xbd, 0x3f, 0x4, 0xde, 0xa2, 0x89, 0xbe, 0xb5, 0x44, 0x3f, 0x64}; + uint8_t bytesprops4[] = {0xf1}; + uint8_t bytesprops3[] = {0xea, 0x65, 0xdf, 0x89, 0x9b, 0x16, 0x9, 0xdd, 0x69, 0xdb, 0x3e}; + uint8_t bytesprops5[] = {0x43, 0x8d, 0xd0, 0xe5, 0x18, 0x5b, 0xa6, 0x8c, 0x95}; + uint8_t bytesprops6[] = {0xff, 0x55, 0x9b, 0x61, 0xd5, 0xca, 0x2f, 0xaa, 0xeb, 0x90, 0x1e, + 0x3a, 0x9c, 0x8a, 0x17, 0x7c, 0x28, 0xa9, 0x6e, 0xc0, 0xfa, 0x6d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12964}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20345}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8272}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops3}, .v = {1, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26063}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops6}}}, + }; + + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x8a}; + uint8_t byteswillprops1[] = {0xfa, 0x5a, 0x97, 0x5b, 0xb7, 0xc1, 0x64, 0x90, 0x45, 0x5d, 0x28, 0x50, 0xb5, + 0xef, 0x67, 0xac, 0xfb, 0xf0, 0x71, 0xb4, 0xbd, 0x6b, 0xa5, 0x2c, 0x8}; + uint8_t byteswillprops2[] = {0x85, 0xdc, 0x82, 0xeb, 0xd6, 0xf4, 0xf6, 0x57, 0xca, 0x6, 0x20, 0x40, 0xda, 0x24, 0xc7, + 0xd3, 0xeb, 0x75, 0x7a, 0x53, 0x66, 0xd7, 0x66, 0x46, 0x21, 0xa0, 0xff, 0x56, 0x97}; + uint8_t byteswillprops3[] = {0x38, 0x39, 0xa0, 0x55, 0xc4, 0xcf, 0x2c, 0xa4, 0xdd, 0x3b, 0x1f, + 0x37, 0xc, 0xdc, 0x80, 0x91, 0x36, 0x63, 0x26, 0x9e, 0x52}; + uint8_t byteswillprops4[] = {0x25, 0xa, 0x15, 0x40, 0x74, 0x57, 0x3f, 0x8d, 0xe4, 0xd6, + 0xfe, 0x38, 0x1d, 0x14, 0x4a, 0x1a, 0xc5, 0x3b, 0x3f}; + uint8_t byteswillprops5[] = {0x9b, 0x4e, 0x21, 0x55, 0x88, 0x13, 0x9b, 0x79, 0xf5, + 0x8b, 0x66, 0x28, 0x5d, 0x30, 0xd3, 0x1a, 0x56, 0xe5}; + uint8_t byteswillprops6[] = {0x57, 0x5d, 0xa6, 0xe1, 0x5f, 0x26, 0x89, 0x35, 0xd0, 0xc0}; + uint8_t byteswillprops7[] = {0xe5, 0x51}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18956}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23816}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19228}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15862}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12803}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23550}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5122}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8890}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&byteswillprops7}}}, + }; + + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc6, 0x95, 0x1e, 0x4c, 0x8f, 0xfe, 0xa6, 0x21}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3a, 0xd7, 0x5c, 0x98, 0x8d, 0x5e, 0x3, 0x62, 0xc6}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1501; + uint8_t client_id_bytes[] = {0xea, 0x59, 0x4f, 0x13, 0x3b, 0x94, 0xcf, 0x30, 0x99, + 0x6e, 0xc7, 0x8e, 0x92, 0xce, 0xfe, 0x9b, 0x3a}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x87, 0xa7}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x64, 0x6f, 0x3, 0xaa, 0x56, 0xef, 0x4e, 0xeb, 0x81, 0x7c, + 0xa8, 0x47, 0xe, 0xda, 0x4f, 0xf5, 0x53, 0x57, 0xe4}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "J3\245R\234g\199\SUBe\f]Y\184\155\252O\131", _password = Just +// "N\130Z\162\174\221xV\181", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "L\149\222\209\ETB6\200tmGe\184\245\DLEg\135|\138v", _willMsg = +// "\240S\t;\152\130\197\DEL\227\191\221\138y|D\US\188\DC2\\\198@\207\&5\174\DC4w\GS1", _willProps = +// [PropSubscriptionIdentifier 3,PropRequestProblemInformation 225,PropRequestProblemInformation 27,PropUserProperty "" +// "9\239\SO:\222\213\150Y+X",PropMaximumPacketSize 14754,PropReasonString +// "b\DEL\t\176\128\r\242\201;\219n\242\144}\ETX\214\ETB\142\246\157n\162C1\201",PropMessageExpiryInterval +// 22587,PropAssignedClientIdentifier "\169]\148\nA\v\243\199\&1\NUL\SIU\228",PropServerReference +// "*\181R+jA\ETB\184\&7\243,3\215\152\145\182l",PropWildcardSubscriptionAvailable 163,PropUserProperty ">s" +// "\a\202\CAN\177@\197\210BLSH\202\228\220!Q\GS\211\160\158",PropReceiveMaximum 26684,PropAssignedClientIdentifier +// "\FS7\EOT\220J\220\196f\251k\179\174\SUBu\203\207\189\145\130\204@\146\DC4",PropSubscriptionIdentifier +// 0,PropUserProperty "\NAK\240Tn\ESC\210\EM\178\183\SI\195\251gt\190\248\158\211Q\SO_m*\186._j\137\198\DC3" +// "\164mE\b\156`",PropSessionExpiryInterval 12603,PropResponseInformation +// "\128\194\170\151\&1",PropWildcardSubscriptionAvailable 88,PropContentType +// "q\DLE\149\136\v\ESCS\234\132\ENQ",PropWildcardSubscriptionAvailable 84,PropSessionExpiryInterval +// 17195,PropSubscriptionIdentifierAvailable 83]}), _cleanSession = True, _keepAlive = 7620, _connID = +// "\180X\169B\252{L\217vd\b\249L\137\219\253\249W\166\245\152\SOnJJE\131\213", _properties = +// [PropPayloadFormatIndicator 252,PropRequestProblemInformation 223,PropSubscriptionIdentifierAvailable +// 195,PropSharedSubscriptionAvailable 91,PropSubscriptionIdentifier 5,PropRetainAvailable 80,PropSubscriptionIdentifier +// 0,PropContentType "\163O\195\187\207\n2\178\239TS"]} +TEST(Connect5QCTest, Encode92) { + uint8_t pkt[] = { + 0x10, 0x81, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x1d, 0xc4, 0x1c, 0x1, 0xfc, 0x17, 0xdf, 0x29, + 0xc3, 0x2a, 0x5b, 0xb, 0x5, 0x25, 0x50, 0xb, 0x0, 0x3, 0x0, 0xb, 0xa3, 0x4f, 0xc3, 0xbb, 0xcf, 0xa, 0x32, + 0xb2, 0xef, 0x54, 0x53, 0x0, 0x1c, 0xb4, 0x58, 0xa9, 0x42, 0xfc, 0x7b, 0x4c, 0xd9, 0x76, 0x64, 0x8, 0xf9, 0x4c, + 0x89, 0xdb, 0xfd, 0xf9, 0x57, 0xa6, 0xf5, 0x98, 0xe, 0x6e, 0x4a, 0x4a, 0x45, 0x83, 0xd5, 0xe9, 0x1, 0xb, 0x3, + 0x17, 0xe1, 0x17, 0x1b, 0x26, 0x0, 0x0, 0x0, 0xa, 0x39, 0xef, 0xe, 0x3a, 0xde, 0xd5, 0x96, 0x59, 0x2b, 0x58, + 0x27, 0x0, 0x0, 0x39, 0xa2, 0x1f, 0x0, 0x19, 0x62, 0x7f, 0x9, 0xb0, 0x80, 0xd, 0xf2, 0xc9, 0x3b, 0xdb, 0x6e, + 0xf2, 0x90, 0x7d, 0x3, 0xd6, 0x17, 0x8e, 0xf6, 0x9d, 0x6e, 0xa2, 0x43, 0x31, 0xc9, 0x2, 0x0, 0x0, 0x58, 0x3b, + 0x12, 0x0, 0xd, 0xa9, 0x5d, 0x94, 0xa, 0x41, 0xb, 0xf3, 0xc7, 0x31, 0x0, 0xf, 0x55, 0xe4, 0x1c, 0x0, 0x11, + 0x2a, 0xb5, 0x52, 0x2b, 0x6a, 0x41,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 0x1f, 0xbc, 0x12, 0x5c, 0xc6, 0x40, 0xcf, 0x35, 0xae, 0x14, 0x77, 0x1d, 0x31, 0x0, 0x11, 0x4a, + 0x33, 0xf5, 0x52, 0xea, 0x67, 0xc7, 0x1a, 0x65, 0xc, 0x5d, 0x59, 0xb8, 0x9b, 0xfc, 0x4f, 0x83, 0x0, 0x9, 0x4e, + 0x82, 0x5a, 0xa2, 0xae, 0xdd, 0x78, 0x56, 0xb5}; + + uint8_t buf[398] = {0}; + + uint8_t bytesprops0[] = {0xa3, 0x4f, 0xc3, 0xbb, 0xcf, 0xa, 0x32, 0xb2, 0xef, 0x54, 0x53}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x39, 0xef, 0xe, 0x3a, 0xde, 0xd5, 0x96, 0x59, 0x2b, 0x58}; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops2[] = {0x62, 0x7f, 0x9, 0xb0, 0x80, 0xd, 0xf2, 0xc9, 0x3b, 0xdb, 0x6e, 0xf2, 0x90, + 0x7d, 0x3, 0xd6, 0x17, 0x8e, 0xf6, 0x9d, 0x6e, 0xa2, 0x43, 0x31, 0xc9}; + uint8_t byteswillprops3[] = {0xa9, 0x5d, 0x94, 0xa, 0x41, 0xb, 0xf3, 0xc7, 0x31, 0x0, 0xf, 0x55, 0xe4}; + uint8_t byteswillprops4[] = {0x2a, 0xb5, 0x52, 0x2b, 0x6a, 0x41, 0x17, 0xb8, 0x37, + 0xf3, 0x2c, 0x33, 0xd7, 0x98, 0x91, 0xb6, 0x6c}; + uint8_t byteswillprops6[] = {0x7, 0xca, 0x18, 0xb1, 0x40, 0xc5, 0xd2, 0x42, 0x4c, 0x53, + 0x48, 0xca, 0xe4, 0xdc, 0x21, 0x51, 0x1d, 0xd3, 0xa0, 0x9e}; + uint8_t byteswillprops5[] = {0x3e, 0x73}; + uint8_t byteswillprops7[] = {0x1c, 0x37, 0x4, 0xdc, 0x4a, 0xdc, 0xc4, 0x66, 0xfb, 0x6b, 0xb3, 0xae, + 0x1a, 0x75, 0xcb, 0xcf, 0xbd, 0x91, 0x82, 0xcc, 0x40, 0x92, 0x14}; + uint8_t byteswillprops9[] = {0xa4, 0x6d, 0x45, 0x8, 0x9c, 0x60}; + uint8_t byteswillprops8[] = {0x15, 0xf0, 0x54, 0x6e, 0x1b, 0xd2, 0x19, 0xb2, 0xb7, 0xf, + 0xc3, 0xfb, 0x67, 0x74, 0xbe, 0xf8, 0x9e, 0xd3, 0x51, 0xe, + 0x5f, 0x6d, 0x2a, 0xba, 0x2e, 0x5f, 0x6a, 0x89, 0xc6, 0x13}; + uint8_t byteswillprops10[] = {0x80, 0xc2, 0xaa, 0x97, 0x31}; + uint8_t byteswillprops11[] = {0x71, 0x10, 0x95, 0x88, 0xb, 0x1b, 0x53, 0xea, 0x84, 0x5}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {0, (char*)&byteswillprops0}, .v = {10, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14754}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22587}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {2, (char*)&byteswillprops5}, .v = {20, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26684}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {30, (char*)&byteswillprops8}, .v = {6, (char*)&byteswillprops9}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12603}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17195}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 83}}, + }; + + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4c, 0x95, 0xde, 0xd1, 0x17, 0x36, 0xc8, 0x74, 0x6d, 0x47, + 0x65, 0xb8, 0xf5, 0x10, 0x67, 0x87, 0x7c, 0x8a, 0x76}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf0, 0x53, 0x9, 0x3b, 0x98, 0x82, 0xc5, 0x7f, 0xe3, 0xbf, 0xdd, 0x8a, 0x79, 0x7c, + 0x44, 0x1f, 0xbc, 0x12, 0x5c, 0xc6, 0x40, 0xcf, 0x35, 0xae, 0x14, 0x77, 0x1d, 0x31}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 7620; + uint8_t client_id_bytes[] = {0xb4, 0x58, 0xa9, 0x42, 0xfc, 0x7b, 0x4c, 0xd9, 0x76, 0x64, 0x8, 0xf9, 0x4c, 0x89, + 0xdb, 0xfd, 0xf9, 0x57, 0xa6, 0xf5, 0x98, 0xe, 0x6e, 0x4a, 0x4a, 0x45, 0x83, 0xd5}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x4a, 0x33, 0xf5, 0x52, 0xea, 0x67, 0xc7, 0x1a, 0x65, + 0xc, 0x5d, 0x59, 0xb8, 0x9b, 0xfc, 0x4f, 0x83}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x4e, 0x82, 0x5a, 0xa2, 0xae, 0xdd, 0x78, 0x56, 0xb5}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\DC2\145\228\152*\178X", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\143\&2Gc]\253N\249\243\153\145\225\185\215sp\SOHs\192\221\&7{", +// _willMsg = "\NUL\211NA\197", _willProps = [PropSubscriptionIdentifierAvailable 9,PropRequestResponseInformation +// 70,PropServerReference "\194x\EOT\249\241\183\&4\210t\184IU\240\224\174\213\223M",PropPayloadFormatIndicator +// 234,PropAuthenticationData +// "J\DC4M\227\211\160\165\201\ESC\159\169]|\244x.\214\DELc\199\147\154\ESC",PropSubscriptionIdentifier +// 7,PropSubscriptionIdentifier 31,PropReceiveMaximum 9626,PropAuthenticationMethod +// "o\155,\201\SI\192\179\ACK\219\131\214\148\246\CANv;R\239",PropRequestProblemInformation +// 195,PropWildcardSubscriptionAvailable 144,PropMaximumQoS 238,PropCorrelationData +// "<\ENQ\253\SYN\133*6\219\237a\SI\244\RS\\\188",PropServerKeepAlive 26333,PropServerKeepAlive 28853]}), _cleanSession +// = True, _keepAlive = 29972, _connID = "\ETB8\187\183q0\214H5\201\SI\199\183B\212u[\143\253\152\199W\EOT\206\149", +// _properties = [PropSubscriptionIdentifierAvailable 197,PropSessionExpiryInterval 6618,PropPayloadFormatIndicator +// 17,PropUserProperty "Xh\249\187$?^z\168p" "&\133\152G\NAK\206\181}'(n\NAK\136\173\238g,\NAK",PropResponseTopic +// "\155\&6\DEL/\176\244C\176k0\233",PropMessageExpiryInterval 7269,PropWillDelayInterval 21711,PropMaximumQoS +// 137,PropSharedSubscriptionAvailable 86,PropMaximumPacketSize 4793,PropSessionExpiryInterval +// 26648,PropSharedSubscriptionAvailable 205,PropRetainAvailable 231,PropCorrelationData +// "\224\177",PropSharedSubscriptionAvailable 66]} +TEST(Connect5QCTest, Encode93) { + uint8_t pkt[] = { + 0x10, 0x90, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x36, 0x75, 0x14, 0x5b, 0x29, 0xc5, 0x11, 0x0, 0x0, + 0x19, 0xda, 0x1, 0x11, 0x26, 0x0, 0xa, 0x58, 0x68, 0xf9, 0xbb, 0x24, 0x3f, 0x5e, 0x7a, 0xa8, 0x70, 0x0, 0x12, + 0x26, 0x85, 0x98, 0x47, 0x15, 0xce, 0xb5, 0x7d, 0x27, 0x28, 0x6e, 0x15, 0x88, 0xad, 0xee, 0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66, 0xdd, 0x13, 0x70, 0xb5, 0x0, 0x16, 0x8f, + 0x32, 0x47, 0x63, 0x5d, 0xfd, 0x4e, 0xf9, 0xf3, 0x99, 0x91, 0xe1, 0xb9, 0xd7, 0x73, 0x70, 0x1, 0x73, 0xc0, 0xdd, + 0x37, 0x7b, 0x0, 0x5, 0x0, 0xd3, 0x4e, 0x41, 0xc5}; + + uint8_t buf[285] = {0}; + + uint8_t bytesprops1[] = {0x26, 0x85, 0x98, 0x47, 0x15, 0xce, 0xb5, 0x7d, 0x27, + 0x28, 0x6e, 0x15, 0x88, 0xad, 0xee, 0x67, 0x2c, 0x15}; + uint8_t bytesprops0[] = {0x58, 0x68, 0xf9, 0xbb, 0x24, 0x3f, 0x5e, 0x7a, 0xa8, 0x70}; + uint8_t bytesprops2[] = {0x9b, 0x36, 0x7f, 0x2f, 0xb0, 0xf4, 0x43, 0xb0, 0x6b, 0x30, 0xe9}; + uint8_t bytesprops3[] = {0xe0, 0xb1}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6618}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {18, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7269}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21711}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4793}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26648}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, + }; + + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xc2, 0x78, 0x4, 0xf9, 0xf1, 0xb7, 0x34, 0xd2, 0x74, + 0xb8, 0x49, 0x55, 0xf0, 0xe0, 0xae, 0xd5, 0xdf, 0x4d}; + uint8_t byteswillprops1[] = {0x4a, 0x14, 0x4d, 0xe3, 0xd3, 0xa0, 0xa5, 0xc9, 0x1b, 0x9f, 0xa9, 0x5d, + 0x7c, 0xf4, 0x78, 0x2e, 0xd6, 0x7f, 0x63, 0xc7, 0x93, 0x9a, 0x1b}; + uint8_t byteswillprops2[] = {0x6f, 0x9b, 0x2c, 0xc9, 0xf, 0xc0, 0xb3, 0x6, 0xdb, + 0x83, 0xd6, 0x94, 0xf6, 0x18, 0x76, 0x3b, 0x52, 0xef}; + uint8_t byteswillprops3[] = {0x3c, 0x5, 0xfd, 0x16, 0x85, 0x2a, 0x36, 0xdb, 0xed, 0x61, 0xf, 0xf4, 0x1e, 0x5c, 0xbc}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9626}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26333}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28853}}, + }; + + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8f, 0x32, 0x47, 0x63, 0x5d, 0xfd, 0x4e, 0xf9, 0xf3, 0x99, 0x91, + 0xe1, 0xb9, 0xd7, 0x73, 0x70, 0x1, 0x73, 0xc0, 0xdd, 0x37, 0x7b}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x0, 0xd3, 0x4e, 0x41, 0xc5}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 29972; + uint8_t client_id_bytes[] = {0x17, 0x38, 0xbb, 0xb7, 0x71, 0x30, 0xd6, 0x48, 0x35, 0xc9, 0xf, 0xc7, 0xb7, + 0x42, 0xd4, 0x75, 0x5b, 0x8f, 0xfd, 0x98, 0xc7, 0x57, 0x4, 0xce, 0x95}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x12, 0x91, 0xe4, 0x98, 0x2a, 0xb2, 0x58}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just ",dA\164\202\NUL\161\212\169\183\&0", _password = Just "\CAN\SUB\238\&0", _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\GS\187\&5\157[*n\166\233S\168\&8\155\DC4\177$\168q\204\218\r\rJ", _willMsg = +// "\236[s\ESCz\217dW\STX\222\151\&0\SYNB\149\b\189fKjA", _willProps = [PropSubscriptionIdentifier 18,PropReasonString +// "\208##+\v\198l\138\152l\STX\229\221\249r\240\174g\152^\FSW:)\219\&9\155\181",PropResponseInformation +// "\161d4\184\130\ETB\SUB\238\253\FS\141m\204a\bh\171I\EM\241\&8",PropWildcardSubscriptionAvailable +// 113,PropServerReference "A$\254|R\222\136\251\&6\247\223\132\158\248\213\161",PropMaximumPacketSize +// 18104,PropResponseInformation "\247\167-\SYN\170\136T1\FS\183x",PropSubscriptionIdentifierAvailable +// 245,PropSessionExpiryInterval 11538,PropMaximumPacketSize 16358,PropWildcardSubscriptionAvailable +// 192,PropReceiveMaximum 19034,PropResponseInformation "\164\r +// \201h\t\211\&0_\226'\DC2;;1\211\SOH\NUL",PropAuthenticationData "8RJ#\\Ko*J&\NUL\NUL nKj\188",PropReceiveMaximum +// 12561,PropContentType "\248\230\230=\129v \163z\247\167\222\253\245\187\255j\ETX\183",PropContentType +// "\192j%\162\231\223\136\189\CAN!N\171\"\128#\139\153\b\227\&9f\157\FS\244\242e\134\DLE",PropRequestProblemInformation +// 94,PropUserProperty "\EOTN\199>J\223G\201" +// "\191+P\245\199\181P\215\236\238\&2X\197\ACK\166)\173D,J\235",PropWildcardSubscriptionAvailable 98,PropTopicAlias +// 23734,PropMaximumPacketSize 10399,PropResponseInformation +// "m\DC2o{\ENQ\176D\241\173F\230\DEL\203\235\139\128\rc\SI\161PWV\195\t\150\236",PropUserProperty +// "\141g1\198\ESC\174D\155\153\254\128\SYN\GS" "\DC3\239%\204\134\236c\180\247V\206\SO\200\208\SO",PropServerReference +// "\230yf\EMo\140\234\"\139"]}), _cleanSession = True, _keepAlive = 488, _connID = "/\152\131mx1\208\&5", _properties = +// [PropTopicAliasMaximum 16695,PropTopicAlias 17555,PropServerReference "",PropWillDelayInterval +// 2609,PropMessageExpiryInterval 14470]} +TEST(Connect5QCTest, Encode94) { + uint8_t pkt[] = { + 0x10, 0xb9, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x1, 0xe8, 0x13, 0x22, 0x41, 0x37, 0x23, 0x44, + 0x93, 0x1c, 0x0, 0x0, 0x18, 0x0, 0x0, 0xa, 0x31, 0x2, 0x0, 0x0, 0x38, 0x86, 0x0, 0x8, 0x2f, 0x98, 0x83, + 0x6d, 0x78, 0x31, 0xd0, 0x35, 0xcc, 0x2, 0xb, 0x12, 0x1f, 0x0, 0x1c, 0xd0, 0x23, 0x23, 0x2b, 0xb, 0xc6, 0x6c, + 0x8a, 0x98, 0x6c, 0x2, 0xe5, 0xdd, 0xf9, 0x72, 0xf0, 0xae, 0x67, 0x98, 0x5e, 0x1c, 0x57, 0x3a, 0x29, 0xdb, 0x39, + 0x9b, 0xb5, 0x1a, 0x0, 0x15, 0xa1, 0x64, 0x34, 0xb8, 0x82, 0x17, 0x1a, 0xee, 0xfd, 0x1c, 0x8d, 0x6d, 0xcc, 0x61, + 0x8, 0x68, 0xab, 0x49, 0x19, 0xf1, 0x38, 0x28, 0x71, 0x1c, 0x0, 0x10, 0x41, 0x24, 0xfe, 0x7c, 0x52, 0xde, 0x88, + 0xfb, 0x36, 0xf7, 0xdf, 0x84, 0x9e, 0xf8, 0xd5, 0xa1, 0x27, 0x0, 0x0, 0x46, 0xb8, 0x1a, 0x0, 0xb, 0xf7, 0xa7, + 0x2d, 0x16, 0xaa, 0x88, 0x54, 0x31, 0x1c, 0xb7, 0x78, 0x29, 0xf5, 0x11, 0x0, 0x0, 0x2d, 0x12, 0x27, 0x0, 0x0, + 0x3f, 0xe6, 0x28, 0xc0, 0x21, 0x4a, 0x5a, 0x1a, 0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0x16, 0x1d, 0x0, 0xf, 0x13, 0xef, 0x25, 0xcc, 0x86, 0xec, 0x63, 0xb4, 0xf7, 0x56, 0xce, + 0xe, 0xc8, 0xd0, 0xe, 0x1c, 0x0, 0x9, 0xe6, 0x79, 0x66, 0x19, 0x6f, 0x8c, 0xea, 0x22, 0x8b, 0x0, 0x17, 0x1d, + 0xbb, 0x35, 0x9d, 0x5b, 0x2a, 0x6e, 0xa6, 0xe9, 0x53, 0xa8, 0x38, 0x9b, 0x14, 0xb1, 0x24, 0xa8, 0x71, 0xcc, 0xda, + 0xd, 0xd, 0x4a, 0x0, 0x15, 0xec, 0x5b, 0x73, 0x1b, 0x7a, 0xd9, 0x64, 0x57, 0x2, 0xde, 0x97, 0x30, 0x16, 0x42, + 0x95, 0x8, 0xbd, 0x66, 0x4b, 0x6a, 0x41, 0x0, 0xb, 0x2c, 0x64, 0x41, 0xa4, 0xca, 0x0, 0xa1, 0xd4, 0xa9, 0xb7, + 0x30, 0x0, 0x4, 0x18, 0x1a, 0xee, 0x30}; + + uint8_t buf[454] = {0}; + + uint8_t bytesprops0[] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16695}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17555}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2609}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14470}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xd0, 0x23, 0x23, 0x2b, 0xb, 0xc6, 0x6c, 0x8a, 0x98, 0x6c, 0x2, 0xe5, 0xdd, 0xf9, + 0x72, 0xf0, 0xae, 0x67, 0x98, 0x5e, 0x1c, 0x57, 0x3a, 0x29, 0xdb, 0x39, 0x9b, 0xb5}; + uint8_t byteswillprops1[] = {0xa1, 0x64, 0x34, 0xb8, 0x82, 0x17, 0x1a, 0xee, 0xfd, 0x1c, 0x8d, + 0x6d, 0xcc, 0x61, 0x8, 0x68, 0xab, 0x49, 0x19, 0xf1, 0x38}; + uint8_t byteswillprops2[] = {0x41, 0x24, 0xfe, 0x7c, 0x52, 0xde, 0x88, 0xfb, + 0x36, 0xf7, 0xdf, 0x84, 0x9e, 0xf8, 0xd5, 0xa1}; + uint8_t byteswillprops3[] = {0xf7, 0xa7, 0x2d, 0x16, 0xaa, 0x88, 0x54, 0x31, 0x1c, 0xb7, 0x78}; + uint8_t byteswillprops4[] = {0xa4, 0xd, 0x20, 0xc9, 0x68, 0x9, 0xd3, 0x30, 0x5f, + 0xe2, 0x27, 0x12, 0x3b, 0x3b, 0x31, 0xd3, 0x1, 0x0}; + uint8_t byteswillprops5[] = {0x38, 0x52, 0x4a, 0x23, 0x5c, 0x4b, 0x6f, 0x2a, 0x4a, + 0x26, 0x0, 0x0, 0x20, 0x6e, 0x4b, 0x6a, 0xbc}; + uint8_t byteswillprops6[] = {0xf8, 0xe6, 0xe6, 0x3d, 0x81, 0x76, 0x20, 0xa3, 0x7a, 0xf7, + 0xa7, 0xde, 0xfd, 0xf5, 0xbb, 0xff, 0x6a, 0x3, 0xb7}; + uint8_t byteswillprops7[] = {0xc0, 0x6a, 0x25, 0xa2, 0xe7, 0xdf, 0x88, 0xbd, 0x18, 0x21, 0x4e, 0xab, 0x22, 0x80, + 0x23, 0x8b, 0x99, 0x8, 0xe3, 0x39, 0x66, 0x9d, 0x1c, 0xf4, 0xf2, 0x65, 0x86, 0x10}; + uint8_t byteswillprops9[] = {0xbf, 0x2b, 0x50, 0xf5, 0xc7, 0xb5, 0x50, 0xd7, 0xec, 0xee, 0x32, + 0x58, 0xc5, 0x6, 0xa6, 0x29, 0xad, 0x44, 0x2c, 0x4a, 0xeb}; + uint8_t byteswillprops8[] = {0x4, 0x4e, 0xc7, 0x3e, 0x4a, 0xdf, 0x47, 0xc9}; + uint8_t byteswillprops10[] = {0x6d, 0x12, 0x6f, 0x7b, 0x5, 0xb0, 0x44, 0xf1, 0xad, 0x46, 0xe6, 0x7f, 0xcb, 0xeb, + 0x8b, 0x80, 0xd, 0x63, 0xf, 0xa1, 0x50, 0x57, 0x56, 0xc3, 0x9, 0x96, 0xec}; + uint8_t byteswillprops12[] = {0x13, 0xef, 0x25, 0xcc, 0x86, 0xec, 0x63, 0xb4, 0xf7, 0x56, 0xce, 0xe, 0xc8, 0xd0, 0xe}; + uint8_t byteswillprops11[] = {0x8d, 0x67, 0x31, 0xc6, 0x1b, 0xae, 0x44, 0x9b, 0x99, 0xfe, 0x80, 0x16, 0x1d}; + uint8_t byteswillprops13[] = {0xe6, 0x79, 0x66, 0x19, 0x6f, 0x8c, 0xea, 0x22, 0x8b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18104}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11538}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16358}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19034}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12561}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {8, (char*)&byteswillprops8}, .v = {21, (char*)&byteswillprops9}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23734}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10399}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {13, (char*)&byteswillprops11}, .v = {15, (char*)&byteswillprops12}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops13}}}, + }; + + lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1d, 0xbb, 0x35, 0x9d, 0x5b, 0x2a, 0x6e, 0xa6, 0xe9, 0x53, 0xa8, 0x38, + 0x9b, 0x14, 0xb1, 0x24, 0xa8, 0x71, 0xcc, 0xda, 0xd, 0xd, 0x4a}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xec, 0x5b, 0x73, 0x1b, 0x7a, 0xd9, 0x64, 0x57, 0x2, 0xde, 0x97, + 0x30, 0x16, 0x42, 0x95, 0x8, 0xbd, 0x66, 0x4b, 0x6a, 0x41}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 488; + uint8_t client_id_bytes[] = {0x2f, 0x98, 0x83, 0x6d, 0x78, 0x31, 0xd0, 0x35}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x2c, 0x64, 0x41, 0xa4, 0xca, 0x0, 0xa1, 0xd4, 0xa9, 0xb7, 0x30}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x18, 0x1a, 0xee, 0x30}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "ox\192\209\133\220~\DC29B\182\239=\196Sa[R\ETB\NUL\US\248E", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\214ht\202Q:u\DC3\190\SYN\SYN\246\225\130\232X\196k%\RSV*\144\154\215\184\227", _willMsg = "t +// \164\CAN)\191\132\223\226\201\230\149\253N\189\218\215\&4\182Gy\247y\201", _willProps = [PropTopicAlias +// 18598,PropUserProperty "5" "i\194)\SI\220OI\r\208\155Z\192]ExD\230\240\167\&4",PropServerReference +// "\135\a\r\161\&18\230(u4cB5?.0\144\198\130g\184",PropReasonString "\129\206\194F\CANuN +// \216u\223/I\173\209\244\247\&1T\DEL\135<\187\FS\FSI\157\223\129\184",PropServerKeepAlive 30447]}), _cleanSession = +// True, _keepAlive = 24570, _connID = "K\"%j\DLE\STXu~\ESC\236\178\204S\151(?\245\214w;\r\255\&5!", _properties = +// [PropResponseTopic "\DC3P\229\204EU\190O\n\164\131\&7\188%",PropReceiveMaximum 26323,PropAuthenticationData +// "\199\251\129\STX\236\199\193\159\184yd\DC2\233\237\204\241\221\208l]\135\"\237\229uk\236\183\137\213"]} +TEST(Connect5QCTest, Encode95) { + uint8_t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, 0x68, 0x74, 0xca, 0x51, + 0x3a, 0x75, 0x13, 0xbe, 0x16, 0x16, 0xf6, 0xe1, 0x82, 0xe8, 0x58, 0xc4, 0x6b, 0x25, 0x1e, 0x56, 0x2a, 0x90, 0x9a, + 0xd7, 0xb8, 0xe3, 0x0, 0x18, 0x74, 0x20, 0xa4, 0x18, 0x29, 0xbf, 0x84, 0xdf, 0xe2, 0xc9, 0xe6, 0x95, 0xfd, 0x4e, + 0xbd, 0xda, 0xd7, 0x34, 0xb6, 0x47, 0x79, 0xf7, 0x79, 0xc9}; + + uint8_t buf[248] = {0}; + + uint8_t bytesprops0[] = {0x13, 0x50, 0xe5, 0xcc, 0x45, 0x55, 0xbe, 0x4f, 0xa, 0xa4, 0x83, 0x37, 0xbc, 0x25}; + uint8_t bytesprops1[] = {0xc7, 0xfb, 0x81, 0x2, 0xec, 0xc7, 0xc1, 0x9f, 0xb8, 0x79, 0x64, 0x12, 0xe9, 0xed, 0xcc, + 0xf1, 0xdd, 0xd0, 0x6c, 0x5d, 0x87, 0x22, 0xed, 0xe5, 0x75, 0x6b, 0xec, 0xb7, 0x89, 0xd5}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26323}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops1}}}, + }; + + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x69, 0xc2, 0x29, 0xf, 0xdc, 0x4f, 0x49, 0xd, 0xd0, 0x9b, + 0x5a, 0xc0, 0x5d, 0x45, 0x78, 0x44, 0xe6, 0xf0, 0xa7, 0x34}; + uint8_t byteswillprops0[] = {0x35}; + uint8_t byteswillprops2[] = {0x87, 0x7, 0xd, 0xa1, 0x31, 0x38, 0xe6, 0x28, 0x75, 0x34, 0x63, + 0x42, 0x35, 0x3f, 0x2e, 0x30, 0x90, 0xc6, 0x82, 0x67, 0xb8}; + uint8_t byteswillprops3[] = {0x81, 0xce, 0xc2, 0x46, 0x18, 0x75, 0x4e, 0x20, 0xd8, 0x75, + 0xdf, 0x2f, 0x49, 0xad, 0xd1, 0xf4, 0xf7, 0x31, 0x54, 0x7f, + 0x87, 0x3c, 0xbb, 0x1c, 0x1c, 0x49, 0x9d, 0xdf, 0x81, 0xb8}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18598}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {1, (char*)&byteswillprops0}, .v = {20, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30447}}, + }; + + lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd6, 0x68, 0x74, 0xca, 0x51, 0x3a, 0x75, 0x13, 0xbe, 0x16, 0x16, 0xf6, 0xe1, 0x82, + 0xe8, 0x58, 0xc4, 0x6b, 0x25, 0x1e, 0x56, 0x2a, 0x90, 0x9a, 0xd7, 0xb8, 0xe3}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x74, 0x20, 0xa4, 0x18, 0x29, 0xbf, 0x84, 0xdf, 0xe2, 0xc9, 0xe6, 0x95, + 0xfd, 0x4e, 0xbd, 0xda, 0xd7, 0x34, 0xb6, 0x47, 0x79, 0xf7, 0x79, 0xc9}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 24570; + uint8_t client_id_bytes[] = {0x4b, 0x22, 0x25, 0x6a, 0x10, 0x2, 0x75, 0x7e, 0x1b, 0xec, 0xb2, 0xcc, + 0x53, 0x97, 0x28, 0x3f, 0xf5, 0xd6, 0x77, 0x3b, 0xd, 0xff, 0x35, 0x21}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x6f, 0x78, 0xc0, 0xd1, 0x85, 0xdc, 0x7e, 0x12, 0x39, 0x42, 0xb6, 0xef, + 0x3d, 0xc4, 0x53, 0x61, 0x5b, 0x52, 0x17, 0x0, 0x1f, 0xf8, 0x45}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\157LD\210\143*\189\134\&0\231\250\253\DC3\210\ETXh\178", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "|\157\175oRO\236\200|s\252\165x\155\f\205{\227\229\134\251u\146\144\248.", _willMsg = +// "R\242;\DC1D\209@\146\213\194Qz\230\DC3\213\RSk`\189a5\DLE\245", _willProps = [PropSubscriptionIdentifierAvailable +// 218,PropMaximumPacketSize 24888,PropAssignedClientIdentifier "\132\148\178\238\227 +// \SYN\186x`\172\158h",PropSubscriptionIdentifierAvailable 246,PropSharedSubscriptionAvailable +// 110,PropPayloadFormatIndicator 59,PropAuthenticationData +// "\133\164!\202V\175\202\208\f/n\NUL\206W\242Y\237\160\238\236Y",PropSessionExpiryInterval +// 1237,PropSubscriptionIdentifierAvailable 196,PropSharedSubscriptionAvailable 232,PropMaximumQoS +// 79,PropMessageExpiryInterval 5045,PropUserProperty "\129K\209~I\DC1\rl\144\176F~4\131Wn3c\220\170\135]o\207(\164k" +// "\EOT\160",PropContentType +// "\159\SYNC\t\245\152\217|\167\242{l\186o\251\203\170\&5\GS\STX\169",PropSubscriptionIdentifierAvailable +// 5,PropReasonString "\155\133\&6\153\132o4\143O\RS\220q\DC3\RS\143",PropReceiveMaximum 26389,PropResponseTopic +// "Jq\184\229\146\180^L~\147}\241GW#\v\149\138\194\230\202",PropMessageExpiryInterval 22509,PropMaximumQoS +// 6,PropMaximumPacketSize 29831,PropMessageExpiryInterval 4338,PropMessageExpiryInterval 3098,PropAuthenticationMethod +// "\172\171;4\204XG\215\239\185\131={"]}), _cleanSession = False, _keepAlive = 10064, _connID = +// "\192u\185\&3\177\222-3\142\DLE\172\172\163\242\228P\178\180\ETB\198]c\131", _properties = [PropRetainAvailable +// 158,PropRetainAvailable 154,PropTopicAliasMaximum 25958,PropRetainAvailable 43,PropAuthenticationData +// "e\135\139z\130\a\172\207\197\175\SOH\200'\SOH\165\181",PropUserProperty "f)\"\242X\153" +// "\STX\219",PropMessageExpiryInterval 24476,PropReasonString +// "\242\159\212\245\211\SYNY\171;\134\174",PropWillDelayInterval 942,PropWildcardSubscriptionAvailable +// 122,PropResponseTopic "m%\226\241\247\193\211\ESC\150\226H0_\226iJa\208\155\226~\DC3\202\192",PropTopicAlias +// 21751,PropAuthenticationMethod "\209^\194",PropServerReference "\ETX\223\235\193+\138Mr\239\142",PropUserProperty +// "q;\184\240\150\ACKD\219M\193,5\170\155N\172\137\DC3\234N\154\176{\174\199\202v\134" +// "\179anxx\178\204\205\187\184\131H4\US7\163%f\250O\241/\222$\141\174",PropWillDelayInterval +// 288,PropAssignedClientIdentifier "\159\EOT3'\rw\231\213?",PropContentType +// "\GS[aW\t2\192\USBN\128\186\198+>\243\155\186O?\143",PropReceiveMaximum 24840,PropReceiveMaximum +// 22186,PropMessageExpiryInterval 27150,PropServerReference ".mL\SO\146K\188\159\157.\248c.\178",PropTopicAlias +// 14699,PropContentType "?\ESC\157\170\195T~\153\155\181\239\a\207_\156e\SYNw\130\219",PropTopicAliasMaximum +// 32514,PropRequestProblemInformation 70,PropResponseTopic "\212\181\RS\157a\224\247",PropServerReference +// "\187\208\173{u.=\200\DC4wgJ~\253\152S\DC1s\ACK\209",PropSubscriptionIdentifier 22]} +TEST(Connect5QCTest, Encode96) { + uint8_t pkt[] = { + 0x10, 0xe6, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x34, 0x27, 0x50, 0xb6, 0x2, 0x25, 0x9e, 0x25, 0x9a, + 0x22, 0x65, 0x66, 0x25, 0x2b, 0x16, 0x0, 0x10, 0x65, 0x87, 0x8b, 0x7a, 0x82, 0x7, 0xac, 0xcf, 0xc5, 0xaf, 0x1, + 0xc8, 0x27, 0x1, 0xa5, 0xb5, 0x26, 0x0, 0x6, 0x66, 0x29, 0x22, 0xf2, 0x58, 0x99, 0x0, 0x2, 0x2, 0xdb, 0x2, + 0x0, 0x0, 0x5f, 0x9c, 0x1f, 0x0, 0xb, 0xf2, 0x9f, 0xd4, 0xf5, 0xd3, 0x16, 0x59, 0xab, 0x3b, 0x86, 0xae, 0x18, + 0x0, 0x0, 0x3, 0xae, 0x28, 0x7a, 0x8, 0x0, 0x18, 0x6d, 0x25, 0xe2, 0xf1, 0xf7, 0xc1, 0xd3, 0x1b, 0x96, 0xe2, + 0x48, 0x30, 0x5f, 0xe2, 0x69, 0x4a, 0x61, 0xd0, 0x9b, 0xe2, 0x7e, 0x13, 0xca, 0xc0, 0x23, 0x54, 0xf7, 0x15, 0x0, + 0x3, 0xd1, 0x5e, 0xc2, 0x1c, 0x0, 0xa, 0x3, 0xdf, 0xeb, 0xc1, 0x2b, 0x8a, 0x4d, 0x72, 0xef, 0x8e, 0x26, 0x0, + 0x1c, 0x71, 0x3b, 0xb8, 0xf0, 0x96, 0x6, 0x44, 0xdb, 0x4d, 0xc1, 0x2c, 0x35, 0xaa, 0x9b, 0x4e, 0xac, 0x89, 0x13, + 0xea, 0x4e, 0x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x0, 0x0, 0x57, 0xed, 0x24, + 0x6, 0x27, 0x0, 0x0, 0x74, 0x87, 0x2, 0x0, 0x0, 0x10, 0xf2, 0x2, 0x0, 0x0, 0xc, 0x1a, 0x15, 0x0, 0xd, + 0xac, 0xab, 0x3b, 0x34, 0xcc, 0x58, 0x47, 0xd7, 0xef, 0xb9, 0x83, 0x3d, 0x7b, 0x0, 0x1a, 0x7c, 0x9d, 0xaf, 0x6f, + 0x52, 0x4f, 0xec, 0xc8, 0x7c, 0x73, 0xfc, 0xa5, 0x78, 0x9b, 0xc, 0xcd, 0x7b, 0xe3, 0xe5, 0x86, 0xfb, 0x75, 0x92, + 0x90, 0xf8, 0x2e, 0x0, 0x17, 0x52, 0xf2, 0x3b, 0x11, 0x44, 0xd1, 0x40, 0x92, 0xd5, 0xc2, 0x51, 0x7a, 0xe6, 0x13, + 0xd5, 0x1e, 0x6b, 0x60, 0xbd, 0x61, 0x35, 0x10, 0xf5}; + + uint8_t buf[627] = {0}; + + uint8_t bytesprops0[] = {0x65, 0x87, 0x8b, 0x7a, 0x82, 0x7, 0xac, 0xcf, 0xc5, 0xaf, 0x1, 0xc8, 0x27, 0x1, 0xa5, 0xb5}; + uint8_t bytesprops2[] = {0x2, 0xdb}; + uint8_t bytesprops1[] = {0x66, 0x29, 0x22, 0xf2, 0x58, 0x99}; + uint8_t bytesprops3[] = {0xf2, 0x9f, 0xd4, 0xf5, 0xd3, 0x16, 0x59, 0xab, 0x3b, 0x86, 0xae}; + uint8_t bytesprops4[] = {0x6d, 0x25, 0xe2, 0xf1, 0xf7, 0xc1, 0xd3, 0x1b, 0x96, 0xe2, 0x48, 0x30, + 0x5f, 0xe2, 0x69, 0x4a, 0x61, 0xd0, 0x9b, 0xe2, 0x7e, 0x13, 0xca, 0xc0}; + uint8_t bytesprops5[] = {0xd1, 0x5e, 0xc2}; + uint8_t bytesprops6[] = {0x3, 0xdf, 0xeb, 0xc1, 0x2b, 0x8a, 0x4d, 0x72, 0xef, 0x8e}; + uint8_t bytesprops8[] = {0xb3, 0x61, 0x6e, 0x78, 0x78, 0xb2, 0xcc, 0xcd, 0xbb, 0xb8, 0x83, 0x48, 0x34, + 0x1f, 0x37, 0xa3, 0x25, 0x66, 0xfa, 0x4f, 0xf1, 0x2f, 0xde, 0x24, 0x8d, 0xae}; + uint8_t bytesprops7[] = {0x71, 0x3b, 0xb8, 0xf0, 0x96, 0x6, 0x44, 0xdb, 0x4d, 0xc1, 0x2c, 0x35, 0xaa, 0x9b, + 0x4e, 0xac, 0x89, 0x13, 0xea, 0x4e, 0x9a, 0xb0, 0x7b, 0xae, 0xc7, 0xca, 0x76, 0x86}; + uint8_t bytesprops9[] = {0x9f, 0x4, 0x33, 0x27, 0xd, 0x77, 0xe7, 0xd5, 0x3f}; + uint8_t bytesprops10[] = {0x1d, 0x5b, 0x61, 0x57, 0x9, 0x32, 0xc0, 0x1f, 0x42, 0x4e, 0x80, + 0xba, 0xc6, 0x2b, 0x3e, 0xf3, 0x9b, 0xba, 0x4f, 0x3f, 0x8f}; + uint8_t bytesprops11[] = {0x2e, 0x6d, 0x4c, 0xe, 0x92, 0x4b, 0xbc, 0x9f, 0x9d, 0x2e, 0xf8, 0x63, 0x2e, 0xb2}; + uint8_t bytesprops12[] = {0x3f, 0x1b, 0x9d, 0xaa, 0xc3, 0x54, 0x7e, 0x99, 0x9b, 0xb5, + 0xef, 0x7, 0xcf, 0x5f, 0x9c, 0x65, 0x16, 0x77, 0x82, 0xdb}; + uint8_t bytesprops13[] = {0xd4, 0xb5, 0x1e, 0x9d, 0x61, 0xe0, 0xf7}; + uint8_t bytesprops14[] = {0xbb, 0xd0, 0xad, 0x7b, 0x75, 0x2e, 0x3d, 0xc8, 0x14, 0x77, + 0x67, 0x4a, 0x7e, 0xfd, 0x98, 0x53, 0x11, 0x73, 0x6, 0xd1}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25958}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {2, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24476}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 942}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21751}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops7}, .v = {26, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 288}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24840}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22186}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27150}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14699}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32514}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x84, 0x94, 0xb2, 0xee, 0xe3, 0x20, 0x16, 0xba, 0x78, 0x60, 0xac, 0x9e, 0x68}; + uint8_t byteswillprops1[] = {0x85, 0xa4, 0x21, 0xca, 0x56, 0xaf, 0xca, 0xd0, 0xc, 0x2f, 0x6e, + 0x0, 0xce, 0x57, 0xf2, 0x59, 0xed, 0xa0, 0xee, 0xec, 0x59}; + uint8_t byteswillprops3[] = {0x4, 0xa0}; + uint8_t byteswillprops2[] = {0x81, 0x4b, 0xd1, 0x7e, 0x49, 0x11, 0xd, 0x6c, 0x90, 0xb0, 0x46, 0x7e, 0x34, 0x83, + 0x57, 0x6e, 0x33, 0x63, 0xdc, 0xaa, 0x87, 0x5d, 0x6f, 0xcf, 0x28, 0xa4, 0x6b}; + uint8_t byteswillprops4[] = {0x9f, 0x16, 0x43, 0x9, 0xf5, 0x98, 0xd9, 0x7c, 0xa7, 0xf2, 0x7b, + 0x6c, 0xba, 0x6f, 0xfb, 0xcb, 0xaa, 0x35, 0x1d, 0x2, 0xa9}; + uint8_t byteswillprops5[] = {0x9b, 0x85, 0x36, 0x99, 0x84, 0x6f, 0x34, 0x8f, + 0x4f, 0x1e, 0xdc, 0x71, 0x13, 0x1e, 0x8f}; + uint8_t byteswillprops6[] = {0x4a, 0x71, 0xb8, 0xe5, 0x92, 0xb4, 0x5e, 0x4c, 0x7e, 0x93, 0x7d, + 0xf1, 0x47, 0x57, 0x23, 0xb, 0x95, 0x8a, 0xc2, 0xe6, 0xca}; + uint8_t byteswillprops7[] = {0xac, 0xab, 0x3b, 0x34, 0xcc, 0x58, 0x47, 0xd7, 0xef, 0xb9, 0x83, 0x3d, 0x7b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24888}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1237}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5045}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {27, (char*)&byteswillprops2}, .v = {2, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26389}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22509}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29831}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4338}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3098}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops7}}}, + }; + + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x7c, 0x9d, 0xaf, 0x6f, 0x52, 0x4f, 0xec, 0xc8, 0x7c, 0x73, 0xfc, 0xa5, 0x78, + 0x9b, 0xc, 0xcd, 0x7b, 0xe3, 0xe5, 0x86, 0xfb, 0x75, 0x92, 0x90, 0xf8, 0x2e}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x52, 0xf2, 0x3b, 0x11, 0x44, 0xd1, 0x40, 0x92, 0xd5, 0xc2, 0x51, 0x7a, + 0xe6, 0x13, 0xd5, 0x1e, 0x6b, 0x60, 0xbd, 0x61, 0x35, 0x10, 0xf5}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 10064; + uint8_t client_id_bytes[] = {0xc0, 0x75, 0xb9, 0x33, 0xb1, 0xde, 0x2d, 0x33, 0x8e, 0x10, 0xac, 0xac, + 0xa3, 0xf2, 0xe4, 0x50, 0xb2, 0xb4, 0x17, 0xc6, 0x5d, 0x63, 0x83}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x9d, 0x4c, 0x44, 0xd2, 0x8f, 0x2a, 0xbd, 0x86, 0x30, + 0xe7, 0xfa, 0xfd, 0x13, 0xd2, 0x3, 0x68, 0xb2}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\136a6\248", _password = Just "aW\205\150\ACK*\208", _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 27816, _connID = "\200\194\195y\163\178", _properties = [PropWillDelayInterval +// 4578,PropRequestProblemInformation 132,PropSharedSubscriptionAvailable 114,PropWildcardSubscriptionAvailable +// 89,PropAssignedClientIdentifier "\DELK9 \219\148ag\184\229d\164~\232\133\156\237\243\218\NAK9\221\nFy"]} +TEST(Connect5QCTest, Encode97) { + uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x6c, 0xa8, 0x27, 0x18, 0x0, + 0x0, 0x11, 0xe2, 0x17, 0x84, 0x2a, 0x72, 0x28, 0x59, 0x12, 0x0, 0x19, 0x7f, 0x4b, 0x39, + 0x20, 0xdb, 0x94, 0x61, 0x67, 0xb8, 0xe5, 0x64, 0xa4, 0x7e, 0xe8, 0x85, 0x9c, 0xed, 0xf3, + 0xda, 0x15, 0x39, 0xdd, 0xa, 0x46, 0x79, 0x0, 0x6, 0xc8, 0xc2, 0xc3, 0x79, 0xa3, 0xb2, + 0x0, 0x4, 0x88, 0x61, 0x36, 0xf8, 0x0, 0x7, 0x61, 0x57, 0xcd, 0x96, 0x6, 0x2a, 0xd0}; + + uint8_t buf[85] = {0}; + + uint8_t bytesprops0[] = {0x7f, 0x4b, 0x39, 0x20, 0xdb, 0x94, 0x61, 0x67, 0xb8, 0xe5, 0x64, 0xa4, 0x7e, + 0xe8, 0x85, 0x9c, 0xed, 0xf3, 0xda, 0x15, 0x39, 0xdd, 0xa, 0x46, 0x79}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4578}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops0}}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 27816; + uint8_t client_id_bytes[] = {0xc8, 0xc2, 0xc3, 0x79, 0xa3, 0xb2}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x88, 0x61, 0x36, 0xf8}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x61, 0x57, 0xcd, 0x96, 0x6, 0x2a, 0xd0}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Y2\vz\196.", _password = Just +// "Z+\195-\233*,\232\192\178w\"\201\188X\DELI\165\144\170\n\161bdTr", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = ":\152<\197\228\170\235[\NUL\207I\169=\149\NAK\225$\r\224\220\173\133EX", _willMsg = +// "E\225^YZ\STX\161\CANS\130>\215e\rU", _willProps = [PropServerKeepAlive 5351,PropSharedSubscriptionAvailable +// 40,PropWillDelayInterval 16062,PropPayloadFormatIndicator 215,PropAssignedClientIdentifier +// "\204m",PropServerReference "\RS\142U\199\244z\133x^y",PropContentType "\ETB\219\GS",PropContentType " +// \235\223\ETX:u\211\230\166 \r[\166\253~}\138\201G1\147",PropServerKeepAlive 32098,PropMaximumPacketSize +// 8075,PropRequestProblemInformation 143,PropWildcardSubscriptionAvailable 233,PropMaximumPacketSize +// 21067,PropServerKeepAlive 12021,PropMessageExpiryInterval 3499,PropContentType +// "V\157\r\167\136A\228\204\176\173V4\239E\138\129\184\189\249\208\203[\132\248/",PropMaximumPacketSize +// 13183,PropWillDelayInterval 18332,PropResponseTopic "\193\213\187J",PropPayloadFormatIndicator +// 137,PropPayloadFormatIndicator 88,PropRequestProblemInformation 95,PropRetainAvailable +// 117,PropRequestProblemInformation 107]}), _cleanSession = False, _keepAlive = 12906, _connID = +// "e\161\220F\196\187*\\H\151\188i\177\188\172\240", _properties = []} +TEST(Connect5QCTest, Encode98) { + uint8_t pkt[] = {0x10, 0xfa, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x32, 0x6a, 0x0, 0x0, 0x10, 0x65, + 0xa1, 0xdc, 0x46, 0xc4, 0xbb, 0x2a, 0x5c, 0x48, 0x97, 0xbc, 0x69, 0xb1, 0xbc, 0xac, 0xf0, 0x8c, 0x1, + 0x13, 0x14, 0xe7, 0x2a, 0x28, 0x18, 0x0, 0x0, 0x3e, 0xbe, 0x1, 0xd7, 0x12, 0x0, 0x2, 0xcc, 0x6d, + 0x1c, 0x0, 0xa, 0x1e, 0x8e, 0x55, 0xc7, 0xf4, 0x7a, 0x85, 0x78, 0x5e, 0x79, 0x3, 0x0, 0x3, 0x17, + 0xdb, 0x1d, 0x3, 0x0, 0x15, 0x20, 0xeb, 0xdf, 0x3, 0x3a, 0x75, 0xd3, 0xe6, 0xa6, 0x20, 0xd, 0x5b, + 0xa6, 0xfd, 0x7e, 0x7d, 0x8a, 0xc9, 0x47, 0x31, 0x93, 0x13, 0x7d, 0x62, 0x27, 0x0, 0x0, 0x1f, 0x8b, + 0x17, 0x8f, 0x28, 0xe9, 0x27, 0x0, 0x0, 0x52, 0x4b, 0x13, 0x2e, 0xf5, 0x2, 0x0, 0x0, 0xd, 0xab, + 0x3, 0x0, 0x19, 0x56, 0x9d, 0xd, 0xa7, 0x88, 0x41, 0xe4, 0xcc, 0xb0, 0xad, 0x56, 0x34, 0xef, 0x45, + 0x8a, 0x81, 0xb8, 0xbd, 0xf9, 0xd0, 0xcb, 0x5b, 0x84, 0xf8, 0x2f, 0x27, 0x0, 0x0, 0x33, 0x7f, 0x18, + 0x0, 0x0, 0x47, 0x9c, 0x8, 0x0, 0x4, 0xc1, 0xd5, 0xbb, 0x4a, 0x1, 0x89, 0x1, 0x58, 0x17, 0x5f, + 0x25, 0x75, 0x17, 0x6b, 0x0, 0x18, 0x3a, 0x98, 0x3c, 0xc5, 0xe4, 0xaa, 0xeb, 0x5b, 0x0, 0xcf, 0x49, + 0xa9, 0x3d, 0x95, 0x15, 0xe1, 0x24, 0xd, 0xe0, 0xdc, 0xad, 0x85, 0x45, 0x58, 0x0, 0xf, 0x45, 0xe1, + 0x5e, 0x59, 0x5a, 0x2, 0xa1, 0x18, 0x53, 0x82, 0x3e, 0xd7, 0x65, 0xd, 0x55, 0x0, 0x6, 0x59, 0x32, + 0xb, 0x7a, 0xc4, 0x2e, 0x0, 0x1a, 0x5a, 0x2b, 0xc3, 0x2d, 0xe9, 0x2a, 0x2c, 0xe8, 0xc0, 0xb2, 0x77, + 0x22, 0xc9, 0xbc, 0x58, 0x7f, 0x49, 0xa5, 0x90, 0xaa, 0xa, 0xa1, 0x62, 0x64, 0x54, 0x72}; + + uint8_t buf[263] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xcc, 0x6d}; + uint8_t byteswillprops1[] = {0x1e, 0x8e, 0x55, 0xc7, 0xf4, 0x7a, 0x85, 0x78, 0x5e, 0x79}; + uint8_t byteswillprops2[] = {0x17, 0xdb, 0x1d}; + uint8_t byteswillprops3[] = {0x20, 0xeb, 0xdf, 0x3, 0x3a, 0x75, 0xd3, 0xe6, 0xa6, 0x20, 0xd, + 0x5b, 0xa6, 0xfd, 0x7e, 0x7d, 0x8a, 0xc9, 0x47, 0x31, 0x93}; + uint8_t byteswillprops4[] = {0x56, 0x9d, 0xd, 0xa7, 0x88, 0x41, 0xe4, 0xcc, 0xb0, 0xad, 0x56, 0x34, 0xef, + 0x45, 0x8a, 0x81, 0xb8, 0xbd, 0xf9, 0xd0, 0xcb, 0x5b, 0x84, 0xf8, 0x2f}; + uint8_t byteswillprops5[] = {0xc1, 0xd5, 0xbb, 0x4a}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5351}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16062}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32098}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8075}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21067}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12021}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3499}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13183}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18332}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, + }; + + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x3a, 0x98, 0x3c, 0xc5, 0xe4, 0xaa, 0xeb, 0x5b, 0x0, 0xcf, 0x49, 0xa9, + 0x3d, 0x95, 0x15, 0xe1, 0x24, 0xd, 0xe0, 0xdc, 0xad, 0x85, 0x45, 0x58}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x45, 0xe1, 0x5e, 0x59, 0x5a, 0x2, 0xa1, 0x18, + 0x53, 0x82, 0x3e, 0xd7, 0x65, 0xd, 0x55}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 12906; + uint8_t client_id_bytes[] = {0x65, 0xa1, 0xdc, 0x46, 0xc4, 0xbb, 0x2a, 0x5c, + 0x48, 0x97, 0xbc, 0x69, 0xb1, 0xbc, 0xac, 0xf0}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x59, 0x32, 0xb, 0x7a, 0xc4, 0x2e}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x5a, 0x2b, 0xc3, 0x2d, 0xe9, 0x2a, 0x2c, 0xe8, 0xc0, 0xb2, 0x77, 0x22, 0xc9, + 0xbc, 0x58, 0x7f, 0x49, 0xa5, 0x90, 0xaa, 0xa, 0xa1, 0x62, 0x64, 0x54, 0x72}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 19412, _connID = "\188=\183\NAK\DLE~\SYN\241", _properties = [PropMessageExpiryInterval 21066,PropAuthenticationData +// "C\203*\185*\211\218,\157F;\222",PropAuthenticationData "\RSB\229B\239u\205g\211\204",PropContentType +// "",PropMaximumQoS 61,PropSubscriptionIdentifier 12,PropMessageExpiryInterval 7641,PropResponseInformation +// "\157,\237\241\NUL\SYN\248=o\186_\140\209\134c\t",PropServerKeepAlive 7496,PropResponseInformation +// "K\GS\133\238+\182\ETX\150|l-6(\168\&1\187s~Ly~\GS\v\143",PropSharedSubscriptionAvailable +// 218,PropWildcardSubscriptionAvailable 151,PropAuthenticationData +// "\SUB[\ACK\GS\216\v\244\218\&9q\ETX!\252/\202\186\167E}!Ih\137\196\238L\152V(\156",PropAuthenticationData +// "\202q\166\144\190H\234(",PropResponseTopic "\134\142\212\228",PropTopicAlias 17133,PropAuthenticationData +// "f\DC3\NUL\187l",PropReceiveMaximum 28577,PropAuthenticationData "\f\210\227\234&",PropRequestResponseInformation +// 13,PropWildcardSubscriptionAvailable 114,PropSubscriptionIdentifier 31,PropRequestProblemInformation +// 252,PropResponseTopic "\215\178M\205\b\144\&4$\164Q\170)\246\210\RS",PropSessionExpiryInterval +// 12656,PropPayloadFormatIndicator 71,PropMessageExpiryInterval 22660,PropServerKeepAlive 29280,PropMaximumPacketSize +// 13910,PropAuthenticationData "\170L$\217\168\225\216N\250\130@\179\STX\NULo\223"]} +TEST(Connect5QCTest, Encode99) { + uint8_t pkt[] = { + 0x10, 0x82, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x4b, 0xd4, 0xec, 0x1, 0x2, 0x0, 0x0, 0x52, + 0x4a, 0x16, 0x0, 0xc, 0x43, 0xcb, 0x2a, 0xb9, 0x2a, 0xd3, 0xda, 0x2c, 0x9d, 0x46, 0x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0x58, 0x84, 0x13, 0x72, 0x60, 0x27, + 0x0, 0x0, 0x36, 0x56, 0x16, 0x0, 0x10, 0xaa, 0x4c, 0x24, 0xd9, 0xa8, 0xe1, 0xd8, 0x4e, 0xfa, 0x82, 0x40, 0xb3, + 0x2, 0x0, 0x6f, 0xdf, 0x0, 0x8, 0xbc, 0x3d, 0xb7, 0x15, 0x10, 0x7e, 0x16, 0xf1}; + + uint8_t buf[271] = {0}; + + uint8_t bytesprops0[] = {0x43, 0xcb, 0x2a, 0xb9, 0x2a, 0xd3, 0xda, 0x2c, 0x9d, 0x46, 0x3b, 0xde}; + uint8_t bytesprops1[] = {0x1e, 0x42, 0xe5, 0x42, 0xef, 0x75, 0xcd, 0x67, 0xd3, 0xcc}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x9d, 0x2c, 0xed, 0xf1, 0x0, 0x16, 0xf8, 0x3d, + 0x6f, 0xba, 0x5f, 0x8c, 0xd1, 0x86, 0x63, 0x9}; + uint8_t bytesprops4[] = {0x4b, 0x1d, 0x85, 0xee, 0x2b, 0xb6, 0x3, 0x96, 0x7c, 0x6c, 0x2d, 0x36, + 0x28, 0xa8, 0x31, 0xbb, 0x73, 0x7e, 0x4c, 0x79, 0x7e, 0x1d, 0xb, 0x8f}; + uint8_t bytesprops5[] = {0x1a, 0x5b, 0x6, 0x1d, 0xd8, 0xb, 0xf4, 0xda, 0x39, 0x71, 0x3, 0x21, 0xfc, 0x2f, 0xca, + 0xba, 0xa7, 0x45, 0x7d, 0x21, 0x49, 0x68, 0x89, 0xc4, 0xee, 0x4c, 0x98, 0x56, 0x28, 0x9c}; + uint8_t bytesprops6[] = {0xca, 0x71, 0xa6, 0x90, 0xbe, 0x48, 0xea, 0x28}; + uint8_t bytesprops7[] = {0x86, 0x8e, 0xd4, 0xe4}; + uint8_t bytesprops8[] = {0x66, 0x13, 0x0, 0xbb, 0x6c}; + uint8_t bytesprops9[] = {0xc, 0xd2, 0xe3, 0xea, 0x26}; + uint8_t bytesprops10[] = {0xd7, 0xb2, 0x4d, 0xcd, 0x8, 0x90, 0x34, 0x24, 0xa4, 0x51, 0xaa, 0x29, 0xf6, 0xd2, 0x1e}; + uint8_t bytesprops11[] = {0xaa, 0x4c, 0x24, 0xd9, 0xa8, 0xe1, 0xd8, 0x4e, + 0xfa, 0x82, 0x40, 0xb3, 0x2, 0x0, 0x6f, 0xdf}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21066}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7641}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7496}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17133}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28577}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12656}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22660}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29280}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13910}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops11}}}, + }; + + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 19412; + uint8_t client_id_bytes[] = {0xbc, 0x3d, 0xb7, 0x15, 0x10, 0x7e, 0x16, 0xf1}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\213Z6\DC4\128\136\188%", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = "|\RS\164\178\193a", _willMsg = +// "O\197\240\214\DC1$j5y^\EM\222\253+\DC1\147}", _willProps = [PropWillDelayInterval 26708,PropAuthenticationData +// "\164\209\149\&8Y\185',W\171#\230\224\131\re\178\249r",PropReasonString "\217|\nd\175&\237\183",PropContentType +// "3)\ESCM\v\US\201|3\154\135%\GS\144i\194\"\229\255\203l:\230\t\ETB\131\198\233\162",PropMessageExpiryInterval +// 19690,PropAuthenticationMethod "\183\212\249\182\191\138V\253H\t\188X\\",PropReceiveMaximum 27145,PropServerKeepAlive +// 9680,PropReceiveMaximum 22519,PropWillDelayInterval 32057,PropMessageExpiryInterval 18312,PropAuthenticationData +// ",N*\192\229RA\\\129\&7",PropReceiveMaximum 3747,PropRequestResponseInformation 58,PropPayloadFormatIndicator +// 70,PropServerKeepAlive 6129,PropMaximumQoS 105,PropRequestResponseInformation 93,PropReasonString +// "A\147s~\181s\231\213@\169\186\203~\243\188\149T\174q",PropTopicAlias 32116,PropServerKeepAlive +// 25356,PropMaximumPacketSize 1804,PropReasonString "\170Xs"]}), _cleanSession = True, _keepAlive = 19592, _connID = +// "\132\175\ETX\n\219\137\SI\183V\196\219\251\145t\244\200AZ[\156\a\212\252\177\154\245%@\249", _properties = +// [PropAuthenticationData "\149\182P\130\208\190\201\136x",PropMaximumQoS 132,PropAuthenticationData +// "\156I\184p\248\220al8{\255\216c\230L?\215\212\DC3\183<\191\141\128",PropSubscriptionIdentifierAvailable +// 87,PropRetainAvailable 169,PropMaximumPacketSize 25664,PropMessageExpiryInterval 20874,PropRequestResponseInformation +// 27,PropWildcardSubscriptionAvailable 209,PropSubscriptionIdentifierAvailable 223,PropReasonString +// "G\215\RS@\134e\DC3\230\234\225\229\&7",PropMessageExpiryInterval 10633,PropAssignedClientIdentifier +// "k\144~\242\234l2\254\207\148\230>\SYN",PropContentType "\185\233\214\129K\170\211\SO\STX\135\&0u\244 +// ",PropRequestResponseInformation 171,PropMaximumQoS 31]} +TEST(Connect5QCTest, Encode100) { + uint8_t pkt[] = { + 0x10, 0xf7, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xae, 0x4c, 0x88, 0x76, 0x16, 0x0, 0x9, 0x95, 0xb6, + 0x50, 0x82, 0xd0, 0xbe, 0xc9, 0x88, 0x78, 0x24, 0x84, 0x16, 0x0, 0x18, 0x9c, 0x49, 0xb8, 0x70, 0xf8, 0xdc, 0x61, + 0x6c, 0x38, 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, 0x3a, + 0xe6, 0x9, 0x17, 0x83, 0xc6, 0xe9, 0xa2, 0x2, 0x0, 0x0, 0x4c, 0xea, 0x15, 0x0, 0xd, 0xb7, 0xd4, 0xf9, 0xb6, + 0xbf, 0x8a, 0x56, 0xfd, 0x48, 0x9, 0xbc, 0x58, 0x5c, 0x21, 0x6a, 0x9, 0x13, 0x25, 0xd0, 0x21, 0x57, 0xf7, 0x18, + 0x0, 0x0, 0x7d, 0x39, 0x2, 0x0, 0x0, 0x47, 0x88, 0x16, 0x0, 0xa, 0x2c, 0x4e, 0x2a, 0xc0, 0xe5, 0x52, 0x41, + 0x5c, 0x81, 0x37, 0x21, 0xe, 0xa3, 0x19, 0x3a, 0x1, 0x46, 0x13, 0x17, 0xf1, 0x24, 0x69, 0x19, 0x5d, 0x1f, 0x0, + 0x13, 0x41, 0x93, 0x73, 0x7e, 0xb5, 0x73, 0xe7, 0xd5, 0x40, 0xa9, 0xba, 0xcb, 0x7e, 0xf3, 0xbc, 0x95, 0x54, 0xae, + 0x71, 0x23, 0x7d, 0x74, 0x13, 0x63, 0xc, 0x27, 0x0, 0x0, 0x7, 0xc, 0x1f, 0x0, 0x3, 0xaa, 0x58, 0x73, 0x0, + 0x6, 0x7c, 0x1e, 0xa4, 0xb2, 0xc1, 0x61, 0x0, 0x11, 0x4f, 0xc5, 0xf0, 0xd6, 0x11, 0x24, 0x6a, 0x35, 0x79, 0x5e, + 0x19, 0xde, 0xfd, 0x2b, 0x11, 0x93, 0x7d, 0x0, 0x8, 0xd5, 0x5a, 0x36, 0x14, 0x80, 0x88, 0xbc, 0x25}; + + uint8_t buf[388] = {0}; + + uint8_t bytesprops0[] = {0x95, 0xb6, 0x50, 0x82, 0xd0, 0xbe, 0xc9, 0x88, 0x78}; + uint8_t bytesprops1[] = {0x9c, 0x49, 0xb8, 0x70, 0xf8, 0xdc, 0x61, 0x6c, 0x38, 0x7b, 0xff, 0xd8, + 0x63, 0xe6, 0x4c, 0x3f, 0xd7, 0xd4, 0x13, 0xb7, 0x3c, 0xbf, 0x8d, 0x80}; + uint8_t bytesprops2[] = {0x47, 0xd7, 0x1e, 0x40, 0x86, 0x65, 0x13, 0xe6, 0xea, 0xe1, 0xe5, 0x37}; + uint8_t bytesprops3[] = {0x6b, 0x90, 0x7e, 0xf2, 0xea, 0x6c, 0x32, 0xfe, 0xcf, 0x94, 0xe6, 0x3e, 0x16}; + uint8_t bytesprops4[] = {0xb9, 0xe9, 0xd6, 0x81, 0x4b, 0xaa, 0xd3, 0xe, 0x2, 0x87, 0x30, 0x75, 0xf4, 0x20}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25664}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20874}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10633}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 31}}, + }; + + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xa4, 0xd1, 0x95, 0x38, 0x59, 0xb9, 0x27, 0x2c, 0x57, 0xab, + 0x23, 0xe6, 0xe0, 0x83, 0xd, 0x65, 0xb2, 0xf9, 0x72}; + uint8_t byteswillprops1[] = {0xd9, 0x7c, 0xa, 0x64, 0xaf, 0x26, 0xed, 0xb7}; + uint8_t byteswillprops2[] = {0x33, 0x29, 0x1b, 0x4d, 0xb, 0x1f, 0xc9, 0x7c, 0x33, 0x9a, 0x87, 0x25, 0x1d, 0x90, 0x69, + 0xc2, 0x22, 0xe5, 0xff, 0xcb, 0x6c, 0x3a, 0xe6, 0x9, 0x17, 0x83, 0xc6, 0xe9, 0xa2}; + uint8_t byteswillprops3[] = {0xb7, 0xd4, 0xf9, 0xb6, 0xbf, 0x8a, 0x56, 0xfd, 0x48, 0x9, 0xbc, 0x58, 0x5c}; + uint8_t byteswillprops4[] = {0x2c, 0x4e, 0x2a, 0xc0, 0xe5, 0x52, 0x41, 0x5c, 0x81, 0x37}; + uint8_t byteswillprops5[] = {0x41, 0x93, 0x73, 0x7e, 0xb5, 0x73, 0xe7, 0xd5, 0x40, 0xa9, + 0xba, 0xcb, 0x7e, 0xf3, 0xbc, 0x95, 0x54, 0xae, 0x71}; + uint8_t byteswillprops6[] = {0xaa, 0x58, 0x73}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26708}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19690}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27145}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9680}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22519}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32057}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18312}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3747}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6129}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32116}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25356}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1804}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops6}}}, + }; + + lwmqtt_properties_t willprops = {23, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x7c, 0x1e, 0xa4, 0xb2, 0xc1, 0x61}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4f, 0xc5, 0xf0, 0xd6, 0x11, 0x24, 0x6a, 0x35, 0x79, + 0x5e, 0x19, 0xde, 0xfd, 0x2b, 0x11, 0x93, 0x7d}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 19592; + uint8_t client_id_bytes[] = {0x84, 0xaf, 0x3, 0xa, 0xdb, 0x89, 0xf, 0xb7, 0x56, 0xc4, 0xdb, 0xfb, 0x91, 0x74, 0xf4, + 0xc8, 0x41, 0x5a, 0x5b, 0x9c, 0x7, 0xd4, 0xfc, 0xb1, 0x9a, 0xf5, 0x25, 0x40, 0xf9}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xd5, 0x5a, 0x36, 0x14, 0x80, 0x88, 0xbc, 0x25}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); From be377fc2ef0cdb16e703649d71c4316511df4217 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 18 Sep 2019 11:21:50 -0700 Subject: [PATCH 09/26] Generate subscribe requests. Note that new subscribe options are not covered. --- gentests/app/Main.hs | 54 +- tests/generated.cpp | 40196 +++++++++++++++++------------------------ 2 files changed, 16366 insertions(+), 23884 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 089c7a6..cab4906 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -40,9 +40,17 @@ shortprot Protocol50 = "5" v311PubReq :: PublishRequest -> PublishRequest v311PubReq p50 = let (PublishPkt p) = v311mask (PublishPkt p50) in p +v311SubReq :: SubscribeRequest -> SubscribeRequest +v311SubReq p50 = let (SubscribePkt p) = v311mask (SubscribePkt p50) in p + v311ConnReq :: ConnectRequest -> ConnectRequest v311ConnReq p50 = let (ConnPkt p) = v311mask (ConnPkt p50) in p +-- Not currently supporting most of the options. +simplifySubOptions :: SubscribeRequest -> SubscribeRequest +simplifySubOptions (SubscribeRequest w subs props) = SubscribeRequest w ssubs props + where ssubs = map (\(x,o@SubOptions{..}) -> (x,subOptions{_subQoS=_subQoS})) subs + userFix :: ConnectRequest -> ConnectRequest userFix = ufix . pfix where @@ -168,6 +176,42 @@ genPublishTest prot i p@PublishRequest{..} = do ] putStrLn "}\n" +genSubTest :: ProtocolLevel -> Int -> SubscribeRequest -> IO () +genSubTest prot i p@(SubscribeRequest pid subs props) = do + let e = toByteString prot p + + putStrLn $ "// " <> show p + putStrLn $ "TEST(Subscribe" <> shortprot prot <> "QCTest, Encode" <> show i <> ") {" + putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" + + putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" + + putStrLn . mconcat $ [ + encodeFilters, + encodeQos, + genProperties "props" props, + " size_t len = 0;\n", + " lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, ", protlvl prot, ", ", + show pid, ", ", show (length subs), ", topic_filters, qos_levels, props);\n\n", + " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + " EXPECT_ARRAY_EQ(pkt, buf, len);" + ] + putStrLn "}\n" + + where + encodeFilters = "lwmqtt_string_t topic_filters[" <> show (length subs) <> "];\n" <> + (concatMap aSub $ zip [0..] subs) + where + aSub :: (Int, (BL.ByteString, SubOptions)) -> String + aSub (i, (s,_)) = mconcat [ + encodeString ("topic_filter_s" <> show i) s, + "topic_filters[", show i, "] = topic_filter_s", show i, ";\n" + ] + + encodeQos = "lwmqtt_qos_t qos_levels[] = {" <> intercalate ", " (map aQ $ zip [0..] subs) <> "};\n" + where + aQ (i, (_,SubOptions{..})) = qos _subQoS + genConnectTest :: ProtocolLevel -> Int -> ConnectRequest -> IO () genConnectTest prot i p@ConnectRequest{..} = do let e = toByteString prot p @@ -246,10 +290,16 @@ extern "C" { } \ } |] - pubs <- replicateM 100 $ generate arbitrary + let numTests = 10 + + pubs <- replicateM numTests $ generate arbitrary mapM_ (uncurry $ genPublishTest Protocol311) $ zip [1..] (v311PubReq <$> pubs) mapM_ (uncurry $ genPublishTest Protocol50) $ zip [1..] pubs - conns <- replicateM 100 $ generate arbitrary + conns <- replicateM numTests $ generate arbitrary mapM_ (uncurry $ genConnectTest Protocol311) $ zip [1..] (userFix . v311ConnReq <$> conns) mapM_ (uncurry $ genConnectTest Protocol50) $ zip [1..] (userFix <$> conns) + + subs <- replicateM 100 $ generate arbitrary + mapM_ (uncurry $ genSubTest Protocol311) $ zip [1..] (v311SubReq <$> subs) + mapM_ (uncurry $ genSubTest Protocol50) $ zip [1..] (simplifySubOptions <$> subs) diff --git a/tests/generated.cpp b/tests/generated.cpp index 577ad5d..218a2f5 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,195 +21,195 @@ extern "C" { } \ } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\GS'O\GS\157L:\160!\232\238\251\210\SOH\149\247[\200\206V\228NIF", _pubPktID = 10712, _pubBody = -// "g\175\150\CANu\230<(Z\145\145 g\177\217P7\ENQ`V\167\212k\177\SUB.", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\164\&3g\145", _pubPktID = 25063, +// _pubBody = "s\178\237\US", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x33, 0x36, 0x0, 0x18, 0x1d, 0x27, 0x4f, 0x1d, 0x9d, 0x4c, 0x3a, 0xa0, 0x21, 0xe8, - 0xee, 0xfb, 0xd2, 0x1, 0x95, 0xf7, 0x5b, 0xc8, 0xce, 0x56, 0xe4, 0x4e, 0x49, 0x46, - 0x29, 0xd8, 0x67, 0xaf, 0x96, 0x18, 0x75, 0xe6, 0x3c, 0x28, 0x5a, 0x91, 0x91, 0x20, - 0x67, 0xb1, 0xd9, 0x50, 0x37, 0x5, 0x60, 0x56, 0xa7, 0xd4, 0x6b, 0xb1, 0x1a, 0x2e}; + uint8_t pkt[] = {0x3c, 0xc, 0x0, 0x4, 0xa4, 0x33, 0x67, 0x91, 0x61, 0xe7, 0x73, 0xb2, 0xed, 0x1f}; - uint8_t buf[66] = {0}; + uint8_t buf[24] = {0}; - uint8_t topic_bytes[] = {0x1d, 0x27, 0x4f, 0x1d, 0x9d, 0x4c, 0x3a, 0xa0, 0x21, 0xe8, 0xee, 0xfb, - 0xd2, 0x1, 0x95, 0xf7, 0x5b, 0xc8, 0xce, 0x56, 0xe4, 0x4e, 0x49, 0x46}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa4, 0x33, 0x67, 0x91}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x67, 0xaf, 0x96, 0x18, 0x75, 0xe6, 0x3c, 0x28, 0x5a, 0x91, 0x91, 0x20, 0x67, - 0xb1, 0xd9, 0x50, 0x37, 0x5, 0x60, 0x56, 0xa7, 0xd4, 0x6b, 0xb1, 0x1a, 0x2e}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x73, 0xb2, 0xed, 0x1f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 4; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10712, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25063, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "q\140\EOT\210\163\254Vg\160L\221g\182\231\149f3\239k\200\DC2", _pubPktID = 10731, _pubBody = -// "\229\183\252?\173\165\FS\181?\130", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\213\SUB", _pubPktID = 13464, +// _pubBody = "o\ETBQD}\r\r\192J-\226\"\219Q\SO\244\182!", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x3c, 0x23, 0x0, 0x15, 0x71, 0x8c, 0x4, 0xd2, 0xa3, 0xfe, 0x56, 0x67, 0xa0, - 0x4c, 0xdd, 0x67, 0xb6, 0xe7, 0x95, 0x66, 0x33, 0xef, 0x6b, 0xc8, 0x12, 0x29, - 0xeb, 0xe5, 0xb7, 0xfc, 0x3f, 0xad, 0xa5, 0x1c, 0xb5, 0x3f, 0x82}; + uint8_t pkt[] = {0x3a, 0x18, 0x0, 0x2, 0xd5, 0x1a, 0x34, 0x98, 0x6f, 0x17, 0x51, 0x44, 0x7d, + 0xd, 0xd, 0xc0, 0x4a, 0x2d, 0xe2, 0x22, 0xdb, 0x51, 0xe, 0xf4, 0xb6, 0x21}; - uint8_t buf[47] = {0}; + uint8_t buf[36] = {0}; - uint8_t topic_bytes[] = {0x71, 0x8c, 0x4, 0xd2, 0xa3, 0xfe, 0x56, 0x67, 0xa0, 0x4c, 0xdd, - 0x67, 0xb6, 0xe7, 0x95, 0x66, 0x33, 0xef, 0x6b, 0xc8, 0x12}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xd5, 0x1a}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xe5, 0xb7, 0xfc, 0x3f, 0xad, 0xa5, 0x1c, 0xb5, 0x3f, 0x82}; + uint8_t msg_bytes[] = {0x6f, 0x17, 0x51, 0x44, 0x7d, 0xd, 0xd, 0xc0, 0x4a, + 0x2d, 0xe2, 0x22, 0xdb, 0x51, 0xe, 0xf4, 0xb6, 0x21}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + msg.payload_len = 18; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10731, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13464, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "I0\v\142\237", _pubPktID = 7560, -// _pubBody = "`\189\255\237\166\235-D\NAK", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "^\128\189\159\\k\153Q\222\207%\t\157-\238\240l\DLE&\ESC\220\&5\201yk\184\SO", _pubPktID = 18950, _pubBody = +// "\186\231\&1`\228\223^\203\149L\134\175o\ENQ-b\212\170\128\244\t}", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x35, 0x12, 0x0, 0x5, 0x49, 0x30, 0xb, 0x8e, 0xed, 0x1d, - 0x88, 0x60, 0xbd, 0xff, 0xed, 0xa6, 0xeb, 0x2d, 0x44, 0x15}; + uint8_t pkt[] = {0x3c, 0x35, 0x0, 0x1b, 0x5e, 0x80, 0xbd, 0x9f, 0x5c, 0x6b, 0x99, 0x51, 0xde, 0xcf, + 0x25, 0x9, 0x9d, 0x2d, 0xee, 0xf0, 0x6c, 0x10, 0x26, 0x1b, 0xdc, 0x35, 0xc9, 0x79, + 0x6b, 0xb8, 0xe, 0x4a, 0x6, 0xba, 0xe7, 0x31, 0x60, 0xe4, 0xdf, 0x5e, 0xcb, 0x95, + 0x4c, 0x86, 0xaf, 0x6f, 0x5, 0x2d, 0x62, 0xd4, 0xaa, 0x80, 0xf4, 0x9, 0x7d}; - uint8_t buf[30] = {0}; + uint8_t buf[65] = {0}; - uint8_t topic_bytes[] = {0x49, 0x30, 0xb, 0x8e, 0xed}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x5e, 0x80, 0xbd, 0x9f, 0x5c, 0x6b, 0x99, 0x51, 0xde, 0xcf, 0x25, 0x9, 0x9d, 0x2d, + 0xee, 0xf0, 0x6c, 0x10, 0x26, 0x1b, 0xdc, 0x35, 0xc9, 0x79, 0x6b, 0xb8, 0xe}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x60, 0xbd, 0xff, 0xed, 0xa6, 0xeb, 0x2d, 0x44, 0x15}; + msg.retained = false; + uint8_t msg_bytes[] = {0xba, 0xe7, 0x31, 0x60, 0xe4, 0xdf, 0x5e, 0xcb, 0x95, 0x4c, 0x86, + 0xaf, 0x6f, 0x5, 0x2d, 0x62, 0xd4, 0xaa, 0x80, 0xf4, 0x9, 0x7d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7560, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 18950, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\214d)\246\152\n-f", _pubPktID = -// 27404, _pubBody = "\187\167\151\192YY\244\252\216W\216\180S\218A\187\255\140'\172dG\187", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\152\SUBq2\SOH\150", _pubPktID = +// 6631, _pubBody = "p\177\185\198Z\188\203\EOT\\\211>c\165\219\215U\r,", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x3b, 0x23, 0x0, 0x8, 0xd6, 0x64, 0x29, 0xf6, 0x98, 0xa, 0x2d, 0x66, 0x6b, - 0xc, 0xbb, 0xa7, 0x97, 0xc0, 0x59, 0x59, 0xf4, 0xfc, 0xd8, 0x57, 0xd8, 0xb4, - 0x53, 0xda, 0x41, 0xbb, 0xff, 0x8c, 0x27, 0xac, 0x64, 0x47, 0xbb}; + uint8_t pkt[] = {0x3a, 0x1c, 0x0, 0x6, 0x98, 0x1a, 0x71, 0x32, 0x1, 0x96, 0x19, 0xe7, 0x70, 0xb1, 0xb9, + 0xc6, 0x5a, 0xbc, 0xcb, 0x4, 0x5c, 0xd3, 0x3e, 0x63, 0xa5, 0xdb, 0xd7, 0x55, 0xd, 0x2c}; - uint8_t buf[47] = {0}; + uint8_t buf[40] = {0}; - uint8_t topic_bytes[] = {0xd6, 0x64, 0x29, 0xf6, 0x98, 0xa, 0x2d, 0x66}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x98, 0x1a, 0x71, 0x32, 0x1, 0x96}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xbb, 0xa7, 0x97, 0xc0, 0x59, 0x59, 0xf4, 0xfc, 0xd8, 0x57, 0xd8, 0xb4, - 0x53, 0xda, 0x41, 0xbb, 0xff, 0x8c, 0x27, 0xac, 0x64, 0x47, 0xbb}; + msg.retained = false; + uint8_t msg_bytes[] = {0x70, 0xb1, 0xb9, 0xc6, 0x5a, 0xbc, 0xcb, 0x4, 0x5c, + 0xd3, 0x3e, 0x63, 0xa5, 0xdb, 0xd7, 0x55, 0xd, 0x2c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 18; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 27404, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6631, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\243i\174@\215\136\140u\b,", -// _pubPktID = 0, _pubBody = "_\166K\178hd\ETX^Q", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// ",=;\135\178\237\227\194~\130\190\147}\190\249wf\151\200\SI\170fO", _pubPktID = 22051, _pubBody = +// "\fJ\139u\132\RS\170\170\v\DC3\148\&2\213!,\174A\170\235~\144/\200", _pubProps = []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x38, 0x15, 0x0, 0xa, 0xf3, 0x69, 0xae, 0x40, 0xd7, 0x88, 0x8c, 0x75, - 0x8, 0x2c, 0x5f, 0xa6, 0x4b, 0xb2, 0x68, 0x64, 0x3, 0x5e, 0x51}; + uint8_t pkt[] = {0x3b, 0x32, 0x0, 0x17, 0x2c, 0x3d, 0x3b, 0x87, 0xb2, 0xed, 0xe3, 0xc2, 0x7e, + 0x82, 0xbe, 0x93, 0x7d, 0xbe, 0xf9, 0x77, 0x66, 0x97, 0xc8, 0xf, 0xaa, 0x66, + 0x4f, 0x56, 0x23, 0xc, 0x4a, 0x8b, 0x75, 0x84, 0x1e, 0xaa, 0xaa, 0xb, 0x13, + 0x94, 0x32, 0xd5, 0x21, 0x2c, 0xae, 0x41, 0xaa, 0xeb, 0x7e, 0x90, 0x2f, 0xc8}; - uint8_t buf[33] = {0}; + uint8_t buf[62] = {0}; - uint8_t topic_bytes[] = {0xf3, 0x69, 0xae, 0x40, 0xd7, 0x88, 0x8c, 0x75, 0x8, 0x2c}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x2c, 0x3d, 0x3b, 0x87, 0xb2, 0xed, 0xe3, 0xc2, 0x7e, 0x82, 0xbe, 0x93, + 0x7d, 0xbe, 0xf9, 0x77, 0x66, 0x97, 0xc8, 0xf, 0xaa, 0x66, 0x4f}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x5f, 0xa6, 0x4b, 0xb2, 0x68, 0x64, 0x3, 0x5e, 0x51}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xc, 0x4a, 0x8b, 0x75, 0x84, 0x1e, 0xaa, 0xaa, 0xb, 0x13, 0x94, 0x32, + 0xd5, 0x21, 0x2c, 0xae, 0x41, 0xaa, 0xeb, 0x7e, 0x90, 0x2f, 0xc8}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 23; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 22051, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\n-yh\SO\210\US\ESC\254\242a", -// _pubPktID = 15060, _pubBody = "\DEL\SOH0>\190\215\246)N\183\&0R\194\153\164\140'6\243X", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\STXO\147", _pubPktID = 12656, +// _pubBody = "\b\213$\145\229\187z\252G t\147N", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x3b, 0x23, 0x0, 0xb, 0xa, 0x2d, 0x79, 0x68, 0xe, 0xd2, 0x1f, 0x1b, 0xfe, - 0xf2, 0x61, 0x3a, 0xd4, 0x7f, 0x1, 0x30, 0x3e, 0xbe, 0xd7, 0xf6, 0x29, 0x4e, - 0xb7, 0x30, 0x52, 0xc2, 0x99, 0xa4, 0x8c, 0x27, 0x36, 0xf3, 0x58}; + uint8_t pkt[] = {0x35, 0x14, 0x0, 0x3, 0x2, 0x4f, 0x93, 0x31, 0x70, 0x8, 0xd5, + 0x24, 0x91, 0xe5, 0xbb, 0x7a, 0xfc, 0x47, 0x20, 0x74, 0x93, 0x4e}; - uint8_t buf[47] = {0}; + uint8_t buf[32] = {0}; - uint8_t topic_bytes[] = {0xa, 0x2d, 0x79, 0x68, 0xe, 0xd2, 0x1f, 0x1b, 0xfe, 0xf2, 0x61}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x2, 0x4f, 0x93}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x7f, 0x1, 0x30, 0x3e, 0xbe, 0xd7, 0xf6, 0x29, 0x4e, 0xb7, - 0x30, 0x52, 0xc2, 0x99, 0xa4, 0x8c, 0x27, 0x36, 0xf3, 0x58}; + uint8_t msg_bytes[] = {0x8, 0xd5, 0x24, 0x91, 0xe5, 0xbb, 0x7a, 0xfc, 0x47, 0x20, 0x74, 0x93, 0x4e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 13; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 15060, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 12656, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "5\132\234\246Z", _pubPktID = 0, -// _pubBody = "+", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "a \154R\188d2\n\193\213a_`\215\209", +// _pubPktID = 0, _pubBody = "\223\f\232\t\237\211\234\248", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x31, 0x8, 0x0, 0x5, 0x35, 0x84, 0xea, 0xf6, 0x5a, 0x2b}; + uint8_t pkt[] = {0x31, 0x19, 0x0, 0xf, 0x61, 0x20, 0x9a, 0x52, 0xbc, 0x64, 0x32, 0xa, 0xc1, 0xd5, + 0x61, 0x5f, 0x60, 0xd7, 0xd1, 0xdf, 0xc, 0xe8, 0x9, 0xed, 0xd3, 0xea, 0xf8}; - uint8_t buf[20] = {0}; + uint8_t buf[37] = {0}; - uint8_t topic_bytes[] = {0x35, 0x84, 0xea, 0xf6, 0x5a}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x61, 0x20, 0x9a, 0x52, 0xbc, 0x64, 0x32, 0xa, 0xc1, 0xd5, 0x61, 0x5f, 0x60, 0xd7, 0xd1}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x2b}; + uint8_t msg_bytes[] = {0xdf, 0xc, 0xe8, 0x9, 0xed, 0xd3, 0xea, 0xf8}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 8; lwmqtt_property_t propslist[] = {}; @@ -221,51 +221,52 @@ TEST(Publish311QCTest, Encode7) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\212\222", _pubPktID = 0, _pubBody -// = "f", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "e\144}\187\204\234\r\DLE\238\SOHC\168\198\137\151;\170\232", _pubPktID = 0, _pubBody = +// "u\221\241\212\194^\n\142\246\204\133\216\SOH\232\215\139\249)", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x30, 0x5, 0x0, 0x2, 0xd4, 0xde, 0x66}; + uint8_t pkt[] = {0x39, 0x26, 0x0, 0x12, 0x65, 0x90, 0x7d, 0xbb, 0xcc, 0xea, 0xd, 0x10, 0xee, 0x1, + 0x43, 0xa8, 0xc6, 0x89, 0x97, 0x3b, 0xaa, 0xe8, 0x75, 0xdd, 0xf1, 0xd4, 0xc2, 0x5e, + 0xa, 0x8e, 0xf6, 0xcc, 0x85, 0xd8, 0x1, 0xe8, 0xd7, 0x8b, 0xf9, 0x29}; - uint8_t buf[17] = {0}; + uint8_t buf[50] = {0}; - uint8_t topic_bytes[] = {0xd4, 0xde}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x65, 0x90, 0x7d, 0xbb, 0xcc, 0xea, 0xd, 0x10, 0xee, + 0x1, 0x43, 0xa8, 0xc6, 0x89, 0x97, 0x3b, 0xaa, 0xe8}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x66}; + msg.retained = true; + uint8_t msg_bytes[] = {0x75, 0xdd, 0xf1, 0xd4, 0xc2, 0x5e, 0xa, 0x8e, 0xf6, + 0xcc, 0x85, 0xd8, 0x1, 0xe8, 0xd7, 0x8b, 0xf9, 0x29}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 18; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "u\ESC\171:\189\192\SUB\242!\162\203\208Z\212\177\&5\248\255\138k\213\183+\SUB\132\GS#M\192", _pubPktID = 13057, -// _pubBody = "\168\129\191\243\158\250'%~\DEL0\ESC\210%qk\220\ENQ\241\199", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "", _pubPktID = 2526, _pubBody = +// "\230r\220N\f\196\206\176_\178\199 P\193-;\128\182%[", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x3a, 0x35, 0x0, 0x1d, 0x75, 0x1b, 0xab, 0x3a, 0xbd, 0xc0, 0x1a, 0xf2, 0x21, 0xa2, - 0xcb, 0xd0, 0x5a, 0xd4, 0xb1, 0x35, 0xf8, 0xff, 0x8a, 0x6b, 0xd5, 0xb7, 0x2b, 0x1a, - 0x84, 0x1d, 0x23, 0x4d, 0xc0, 0x33, 0x1, 0xa8, 0x81, 0xbf, 0xf3, 0x9e, 0xfa, 0x27, - 0x25, 0x7e, 0x7f, 0x30, 0x1b, 0xd2, 0x25, 0x71, 0x6b, 0xdc, 0x5, 0xf1, 0xc7}; + uint8_t pkt[] = {0x3a, 0x18, 0x0, 0x0, 0x9, 0xde, 0xe6, 0x72, 0xdc, 0x4e, 0xc, 0xc4, 0xce, + 0xb0, 0x5f, 0xb2, 0xc7, 0x20, 0x50, 0xc1, 0x2d, 0x3b, 0x80, 0xb6, 0x25, 0x5b}; - uint8_t buf[65] = {0}; + uint8_t buf[36] = {0}; - uint8_t topic_bytes[] = {0x75, 0x1b, 0xab, 0x3a, 0xbd, 0xc0, 0x1a, 0xf2, 0x21, 0xa2, 0xcb, 0xd0, 0x5a, 0xd4, 0xb1, - 0x35, 0xf8, 0xff, 0x8a, 0x6b, 0xd5, 0xb7, 0x2b, 0x1a, 0x84, 0x1d, 0x23, 0x4d, 0xc0}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xa8, 0x81, 0xbf, 0xf3, 0x9e, 0xfa, 0x27, 0x25, 0x7e, 0x7f, - 0x30, 0x1b, 0xd2, 0x25, 0x71, 0x6b, 0xdc, 0x5, 0xf1, 0xc7}; + uint8_t msg_bytes[] = {0xe6, 0x72, 0xdc, 0x4e, 0xc, 0xc4, 0xce, 0xb0, 0x5f, 0xb2, + 0xc7, 0x20, 0x50, 0xc1, 0x2d, 0x3b, 0x80, 0xb6, 0x25, 0x5b}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 20; @@ -273,25550 +274,17981 @@ TEST(Publish311QCTest, Encode9) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13057, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2526, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\186l\242\SOH;D}W:\172\197", -// _pubPktID = 15309, _pubBody = "-\137a\203_YG\210\138\172yL\224>", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = +// "}5\238\204\DC2\254\162n\196-\172U\\\169\162\FS\RS\"\189v\148\229\\\223\144|\223\NUL\203", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x3d, 0x1e, 0x0, 0xc, 0xfd, 0xba, 0x6c, 0xf2, 0x1, 0x3b, 0x44, 0x7d, 0x57, 0x3a, 0xac, 0xc5, - 0x3b, 0xcd, 0x2d, 0x89, 0x61, 0xcb, 0x5f, 0x59, 0x47, 0xd2, 0x8a, 0xac, 0x79, 0x4c, 0xe0, 0x3e}; + uint8_t pkt[] = {0x30, 0x1f, 0x0, 0x0, 0x7d, 0x35, 0xee, 0xcc, 0x12, 0xfe, 0xa2, 0x6e, 0xc4, 0x2d, 0xac, 0x55, 0x5c, + 0xa9, 0xa2, 0x1c, 0x1e, 0x22, 0xbd, 0x76, 0x94, 0xe5, 0x5c, 0xdf, 0x90, 0x7c, 0xdf, 0x0, 0xcb}; - uint8_t buf[42] = {0}; + uint8_t buf[43] = {0}; - uint8_t topic_bytes[] = {0xfd, 0xba, 0x6c, 0xf2, 0x1, 0x3b, 0x44, 0x7d, 0x57, 0x3a, 0xac, 0xc5}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x2d, 0x89, 0x61, 0xcb, 0x5f, 0x59, 0x47, 0xd2, 0x8a, 0xac, 0x79, 0x4c, 0xe0, 0x3e}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x7d, 0x35, 0xee, 0xcc, 0x12, 0xfe, 0xa2, 0x6e, 0xc4, 0x2d, 0xac, 0x55, 0x5c, 0xa9, 0xa2, + 0x1c, 0x1e, 0x22, 0xbd, 0x76, 0x94, 0xe5, 0x5c, 0xdf, 0x90, 0x7c, 0xdf, 0x0, 0xcb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 29; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 15309, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "M\DC3\NAK:\DEL\206\213^_\254\174f\203\221\160U", _pubPktID = 0, _pubBody = "\211\130}", _pubProps = []} -TEST(Publish311QCTest, Encode11) { - uint8_t pkt[] = {0x30, 0x15, 0x0, 0x10, 0x4d, 0x13, 0x15, 0x3a, 0x7f, 0xce, 0xd5, 0x5e, - 0x5f, 0xfe, 0xae, 0x66, 0xcb, 0xdd, 0xa0, 0x55, 0xd3, 0x82, 0x7d}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\164\&3g\145", _pubPktID = 25063, +// _pubBody = "s\178\237\US", _pubProps = [PropResponseInformation +// "L!\184\215\210_\255\ETB\163\229\EOT\141\214\173ES\136\224[\a\231Un",PropTopicAlias 28899,PropResponseInformation +// "\SUB\244>k\235hg\149[[&\157\218\EM\n]>\173\255\"*\DC4km\167'\166\176\135:",PropSessionExpiryInterval +// 1026,PropContentType "\195\170\244Y\SI\160\NAK\188\131",PropSessionExpiryInterval 1608,PropTopicAlias +// 15486,PropServerKeepAlive 2825,PropReasonString +// "\162o6_+a\190\216\144sk-\233\240}`\190\136",PropWildcardSubscriptionAvailable 165,PropServerKeepAlive +// 1630,PropResponseInformation "\157\230b\252P\221E\172\156^aK[\224",PropAuthenticationMethod +// "\r~\DC4\137\ETBK\250\235J]=\205\204]",PropResponseInformation +// ",\EM0\156%$=\228\DC44\180W\213\162,",PropTopicAliasMaximum 21055,PropTopicAliasMaximum +// 21339,PropMessageExpiryInterval 8748,PropReceiveMaximum 28723,PropRetainAvailable 108,PropSessionExpiryInterval +// 18854]} +TEST(Publish5QCTest, Encode1) { + uint8_t pkt[] = { + 0x3c, 0xcb, 0x1, 0x0, 0x4, 0xa4, 0x33, 0x67, 0x91, 0x61, 0xe7, 0xbd, 0x1, 0x1a, 0x0, 0x17, 0x4c, 0x21, 0xb8, + 0xd7, 0xd2, 0x5f, 0xff, 0x17, 0xa3, 0xe5, 0x4, 0x8d, 0xd6, 0xad, 0x45, 0x53, 0x88, 0xe0, 0x5b, 0x7, 0xe7, 0x55, + 0x6e, 0x23, 0x70, 0xe3, 0x1a, 0x0, 0x1e, 0x1a, 0xf4, 0x3e, 0x6b, 0xeb, 0x68, 0x67, 0x95, 0x5b, 0x5b, 0x26, 0x9d, + 0xda, 0x19, 0xa, 0x5d, 0x3e, 0xad, 0xff, 0x22, 0x2a, 0x14, 0x6b, 0x6d, 0xa7, 0x27, 0xa6, 0xb0, 0x87, 0x3a, 0x11, + 0x0, 0x0, 0x4, 0x2, 0x3, 0x0, 0x9, 0xc3, 0xaa, 0xf4, 0x59, 0xf, 0xa0, 0x15, 0xbc, 0x83, 0x11, 0x0, 0x0, + 0x6, 0x48, 0x23, 0x3c, 0x7e, 0x13, 0xb, 0x9, 0x1f, 0x0, 0x12, 0xa2, 0x6f, 0x36, 0x5f, 0x2b, 0x61, 0xbe, 0xd8, + 0x90, 0x73, 0x6b, 0x2d, 0xe9, 0xf0, 0x7d, 0x60, 0xbe, 0x88, 0x28, 0xa5, 0x13, 0x6, 0x5e, 0x1a, 0x0, 0xe, 0x9d, + 0xe6, 0x62, 0xfc, 0x50, 0xdd, 0x45, 0xac, 0x9c, 0x5e, 0x61, 0x4b, 0x5b, 0xe0, 0x15, 0x0, 0xe, 0xd, 0x7e, 0x14, + 0x89, 0x17, 0x4b, 0xfa, 0xeb, 0x4a, 0x5d, 0x3d, 0xcd, 0xcc, 0x5d, 0x1a, 0x0, 0xf, 0x2c, 0x19, 0x30, 0x9c, 0x25, + 0x24, 0x3d, 0xe4, 0x14, 0x34, 0xb4, 0x57, 0xd5, 0xa2, 0x2c, 0x22, 0x52, 0x3f, 0x22, 0x53, 0x5b, 0x2, 0x0, 0x0, + 0x22, 0x2c, 0x21, 0x70, 0x33, 0x25, 0x6c, 0x11, 0x0, 0x0, 0x49, 0xa6, 0x73, 0xb2, 0xed, 0x1f}; - uint8_t buf[33] = {0}; + uint8_t buf[216] = {0}; - uint8_t topic_bytes[] = {0x4d, 0x13, 0x15, 0x3a, 0x7f, 0xce, 0xd5, 0x5e, - 0x5f, 0xfe, 0xae, 0x66, 0xcb, 0xdd, 0xa0, 0x55}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xa4, 0x33, 0x67, 0x91}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xd3, 0x82, 0x7d}; + uint8_t msg_bytes[] = {0x73, 0xb2, 0xed, 0x1f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 4; - lwmqtt_property_t propslist[] = {}; + uint8_t bytesprops0[] = {0x4c, 0x21, 0xb8, 0xd7, 0xd2, 0x5f, 0xff, 0x17, 0xa3, 0xe5, 0x4, 0x8d, + 0xd6, 0xad, 0x45, 0x53, 0x88, 0xe0, 0x5b, 0x7, 0xe7, 0x55, 0x6e}; + uint8_t bytesprops1[] = {0x1a, 0xf4, 0x3e, 0x6b, 0xeb, 0x68, 0x67, 0x95, 0x5b, 0x5b, 0x26, 0x9d, 0xda, 0x19, 0xa, + 0x5d, 0x3e, 0xad, 0xff, 0x22, 0x2a, 0x14, 0x6b, 0x6d, 0xa7, 0x27, 0xa6, 0xb0, 0x87, 0x3a}; + uint8_t bytesprops2[] = {0xc3, 0xaa, 0xf4, 0x59, 0xf, 0xa0, 0x15, 0xbc, 0x83}; + uint8_t bytesprops3[] = {0xa2, 0x6f, 0x36, 0x5f, 0x2b, 0x61, 0xbe, 0xd8, 0x90, + 0x73, 0x6b, 0x2d, 0xe9, 0xf0, 0x7d, 0x60, 0xbe, 0x88}; + uint8_t bytesprops4[] = {0x9d, 0xe6, 0x62, 0xfc, 0x50, 0xdd, 0x45, 0xac, 0x9c, 0x5e, 0x61, 0x4b, 0x5b, 0xe0}; + uint8_t bytesprops5[] = {0xd, 0x7e, 0x14, 0x89, 0x17, 0x4b, 0xfa, 0xeb, 0x4a, 0x5d, 0x3d, 0xcd, 0xcc, 0x5d}; + uint8_t bytesprops6[] = {0x2c, 0x19, 0x30, 0x9c, 0x25, 0x24, 0x3d, 0xe4, 0x14, 0x34, 0xb4, 0x57, 0xd5, 0xa2, 0x2c}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28899}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1026}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1608}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15486}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2825}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1630}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21055}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21339}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8748}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28723}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18854}}, + }; + + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25063, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\169|\146E2\GS{\237\&3\166", -// _pubPktID = 0, _pubBody = "#\227\217]\US\238S\163\139\232\165\210\243-", _pubProps = []} -TEST(Publish311QCTest, Encode12) { - uint8_t pkt[] = {0x31, 0x1a, 0x0, 0xa, 0xa9, 0x7c, 0x92, 0x45, 0x32, 0x1d, 0x7b, 0xed, 0x33, 0xa6, - 0x23, 0xe3, 0xd9, 0x5d, 0x1f, 0xee, 0x53, 0xa3, 0x8b, 0xe8, 0xa5, 0xd2, 0xf3, 0x2d}; - - uint8_t buf[38] = {0}; - - uint8_t topic_bytes[] = {0xa9, 0x7c, 0x92, 0x45, 0x32, 0x1d, 0x7b, 0xed, 0x33, 0xa6}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\213\SUB", _pubPktID = 13464, +// _pubBody = "o\ETBQD}\r\r\192J-\226\"\219Q\SO\244\182!", _pubProps = [PropResponseInformation +// "\194\135h\173\237}\162\160!b\215\197&\246}%\178\245\&9\170\GS",PropRetainAvailable 76,PropContentType +// ":\218W\DC37\181\243\164a\188i\DC3\198\193#^37\240\DC4\GSB0'C\228\169 9",PropReasonString +// "\248\139\145\ETX\170\&1\194\EM!\128]\US\182\182\203q\231\151T\180)",PropResponseInformation +// "\ETB\225\223\174M?f\214\128+wQ\US\246\156\238v\143ym[F",PropPayloadFormatIndicator 42,PropRequestResponseInformation +// 223,PropWildcardSubscriptionAvailable 32,PropPayloadFormatIndicator 79,PropRequestResponseInformation +// 125,PropResponseInformation +// "\170\220\ETXb\156\232\251\&8\199\250\153\255\203\186]" +// "uhX\173\171\223\&7\248\223\US1ODw4\203\177\ESC\EOT1\246]3\168\131\129N\EM\207\238",PropCorrelationData +// "\139\210\185\155\SUB\r\191"]} +TEST(Publish5QCTest, Encode9) { + uint8_t pkt[] = {0x3a, 0x7b, 0x0, 0x0, 0x9, 0xde, 0x62, 0x23, 0x38, 0x27, 0x26, 0x0, 0x0, 0x0, 0x19, 0x18, + 0xa8, 0x5b, 0x6a, 0xec, 0xec, 0xcc, 0x6, 0xd6, 0xd, 0x70, 0x6b, 0x10, 0xf2, 0x61, 0x90, 0xd9, + 0xb5, 0xd0, 0x1, 0x9, 0x7c, 0x92, 0x3a, 0xf9, 0x26, 0x0, 0x14, 0x97, 0xd, 0x80, 0x46, 0x6f, + 0x90, 0xd3, 0x11, 0x3c, 0x19, 0x99, 0xbe, 0x4e, 0x55, 0x36, 0x86, 0x27, 0x3e, 0xba, 0x5d, 0x0, + 0x1e, 0x75, 0x68, 0x58, 0xad, 0xab, 0xdf, 0x37, 0xf8, 0xdf, 0x1f, 0x31, 0x4f, 0x44, 0x77, 0x34, + 0xcb, 0xb1, 0x1b, 0x4, 0x31, 0xf6, 0x5d, 0x33, 0xa8, 0x83, 0x81, 0x4e, 0x19, 0xcf, 0xee, 0x9, + 0x0, 0x7, 0x8b, 0xd2, 0xb9, 0x9b, 0x1a, 0xd, 0xbf, 0xe6, 0x72, 0xdc, 0x4e, 0xc, 0xc4, 0xce, + 0xb0, 0x5f, 0xb2, 0xc7, 0x20, 0x50, 0xc1, 0x2d, 0x3b, 0x80, 0xb6, 0x25, 0x5b}; - uint8_t buf[38] = {0}; + uint8_t buf[135] = {0}; - uint8_t topic_bytes[] = {0xe1, 0xf2, 0xa8}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xd8, 0x2d, 0x37, 0xdd, 0x71, 0x3c, 0x1e, 0x22, 0x55, 0xd2, - 0x2d, 0x82, 0xe8, 0xa1, 0xf8, 0x29, 0xf8, 0xa9, 0x97}; + uint8_t msg_bytes[] = {0xe6, 0x72, 0xdc, 0x4e, 0xc, 0xc4, 0xce, 0xb0, 0x5f, 0xb2, + 0xc7, 0x20, 0x50, 0xc1, 0x2d, 0x3b, 0x80, 0xb6, 0x25, 0x5b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 20; - lwmqtt_property_t propslist[] = {}; + uint8_t bytesprops1[] = {0x18, 0xa8, 0x5b, 0x6a, 0xec, 0xec, 0xcc, 0x6, 0xd6, 0xd, 0x70, 0x6b, 0x10, + 0xf2, 0x61, 0x90, 0xd9, 0xb5, 0xd0, 0x1, 0x9, 0x7c, 0x92, 0x3a, 0xf9}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops3[] = {0x75, 0x68, 0x58, 0xad, 0xab, 0xdf, 0x37, 0xf8, 0xdf, 0x1f, 0x31, 0x4f, 0x44, 0x77, 0x34, + 0xcb, 0xb1, 0x1b, 0x4, 0x31, 0xf6, 0x5d, 0x33, 0xa8, 0x83, 0x81, 0x4e, 0x19, 0xcf, 0xee}; + uint8_t bytesprops2[] = {0x97, 0xd, 0x80, 0x46, 0x6f, 0x90, 0xd3, 0x11, 0x3c, 0x19, + 0x99, 0xbe, 0x4e, 0x55, 0x36, 0x86, 0x27, 0x3e, 0xba, 0x5d}; + uint8_t bytesprops4[] = {0x8b, 0xd2, 0xb9, 0x9b, 0x1a, 0xd, 0xbf}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14375}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops2}, .v = {30, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops4}}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30037, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2526, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\209\144\244\190\138\251", _pubPktID -// = 1548, _pubBody = "", _pubProps = []} -TEST(Publish311QCTest, Encode20) { - uint8_t pkt[] = {0x3c, 0xa, 0x0, 0x6, 0xd1, 0x90, 0xf4, 0xbe, 0x8a, 0xfb, 0x6, 0xc}; - - uint8_t buf[22] = {0}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = +// "}5\238\204\DC2\254\162n\196-\172U\\\169\162\FS\RS\"\189v\148\229\\\223\144|\223\NUL\203", _pubProps = +// [PropResponseTopic "f\145\140\205",PropSharedSubscriptionAvailable 213,PropReceiveMaximum +// 32116,PropSubscriptionIdentifierAvailable 232,PropCorrelationData +// "\178:4~\ESCW\197\185\219\NAK8\235\ETX\249\DEL4!\170",PropMaximumQoS 107,PropRequestProblemInformation +// 183,PropAuthenticationMethod "\214\218>\166\211\140\225\198\162\252\225\195\139\SOH\200,\222",PropServerKeepAlive +// 24310,PropWillDelayInterval 24774,PropMaximumQoS 165,PropResponseTopic +// "\FS\199k\197\227\NAK\183\135\ENQ\145\183*\190\255zg^\220&n\217r.\159",PropRequestProblemInformation +// 131,PropSharedSubscriptionAvailable 206,PropCorrelationData +// "@?m1T\SI\228\207\&2\160c\194\&0S\194\191\223\222",PropSubscriptionIdentifierAvailable 51]} +TEST(Publish5QCTest, Encode10) { + uint8_t pkt[] = {0x30, 0x9b, 0x1, 0x0, 0x0, 0x7b, 0x8, 0x0, 0x4, 0x66, 0x91, 0x8c, 0xcd, 0x2a, 0xd5, 0x21, + 0x7d, 0x74, 0x29, 0xe8, 0x9, 0x0, 0x12, 0xb2, 0x3a, 0x34, 0x7e, 0x1b, 0x57, 0xc5, 0xb9, 0xdb, + 0x15, 0x38, 0xeb, 0x3, 0xf9, 0x7f, 0x34, 0x21, 0xaa, 0x24, 0x6b, 0x17, 0xb7, 0x15, 0x0, 0x11, + 0xd6, 0xda, 0x3e, 0xa6, 0xd3, 0x8c, 0xe1, 0xc6, 0xa2, 0xfc, 0xe1, 0xc3, 0x8b, 0x1, 0xc8, 0x2c, + 0xde, 0x13, 0x5e, 0xf6, 0x18, 0x0, 0x0, 0x60, 0xc6, 0x24, 0xa5, 0x8, 0x0, 0x18, 0x1c, 0xc7, + 0x6b, 0xc5, 0xe3, 0x15, 0xb7, 0x87, 0x5, 0x91, 0xb7, 0x2a, 0xbe, 0xff, 0x7a, 0x67, 0x5e, 0xdc, + 0x26, 0x6e, 0xd9, 0x72, 0x2e, 0x9f, 0x17, 0x83, 0x2a, 0xce, 0x9, 0x0, 0x12, 0x40, 0x3f, 0x6d, + 0x31, 0x54, 0xf, 0xe4, 0xcf, 0x32, 0xa0, 0x63, 0xc2, 0x30, 0x53, 0xc2, 0xbf, 0xdf, 0xde, 0x29, + 0x33, 0x7d, 0x35, 0xee, 0xcc, 0x12, 0xfe, 0xa2, 0x6e, 0xc4, 0x2d, 0xac, 0x55, 0x5c, 0xa9, 0xa2, + 0x1c, 0x1e, 0x22, 0xbd, 0x76, 0x94, 0xe5, 0x5c, 0xdf, 0x90, 0x7c, 0xdf, 0x0, 0xcb}; + + uint8_t buf[168] = {0}; - uint8_t topic_bytes[] = {0xd1, 0x90, 0xf4, 0xbe, 0x8a, 0xfb}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0}; + uint8_t msg_bytes[] = {0x7d, 0x35, 0xee, 0xcc, 0x12, 0xfe, 0xa2, 0x6e, 0xc4, 0x2d, 0xac, 0x55, 0x5c, 0xa9, 0xa2, + 0x1c, 0x1e, 0x22, 0xbd, 0x76, 0x94, 0xe5, 0x5c, 0xdf, 0x90, 0x7c, 0xdf, 0x0, 0xcb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 29; - lwmqtt_property_t propslist[] = {}; + uint8_t bytesprops0[] = {0x66, 0x91, 0x8c, 0xcd}; + uint8_t bytesprops1[] = {0xb2, 0x3a, 0x34, 0x7e, 0x1b, 0x57, 0xc5, 0xb9, 0xdb, + 0x15, 0x38, 0xeb, 0x3, 0xf9, 0x7f, 0x34, 0x21, 0xaa}; + uint8_t bytesprops2[] = {0xd6, 0xda, 0x3e, 0xa6, 0xd3, 0x8c, 0xe1, 0xc6, 0xa2, + 0xfc, 0xe1, 0xc3, 0x8b, 0x1, 0xc8, 0x2c, 0xde}; + uint8_t bytesprops3[] = {0x1c, 0xc7, 0x6b, 0xc5, 0xe3, 0x15, 0xb7, 0x87, 0x5, 0x91, 0xb7, 0x2a, + 0xbe, 0xff, 0x7a, 0x67, 0x5e, 0xdc, 0x26, 0x6e, 0xd9, 0x72, 0x2e, 0x9f}; + uint8_t bytesprops4[] = {0x40, 0x3f, 0x6d, 0x31, 0x54, 0xf, 0xe4, 0xcf, 0x32, + 0xa0, 0x63, 0xc2, 0x30, 0x53, 0xc2, 0xbf, 0xdf, 0xde}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32116}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24310}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24774}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 51}}, + }; + + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1548, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\136\140\179}\STX;", _pubPktID = -// 6476, _pubBody = "Jj\SO\241\ENQ\137\DC1", _pubProps = []} -TEST(Publish311QCTest, Encode21) { - uint8_t pkt[] = {0x35, 0x12, 0x0, 0x7, 0xfd, 0x88, 0x8c, 0xb3, 0x7d, 0x2, - 0x3b, 0x19, 0x4c, 0x4a, 0x6a, 0xe, 0xf1, 0x5, 0x89, 0x11}; +// ConnectRequest {_username = Just ",\186\SUB\f\DC3\188\204KRj<%\n2x", _password = Just +// "\158A=\ETB\b\254\145\215X\242\128\192\ETB\DELE\ENQp\169\139;s~\SYN\135\CAN\209\EOT\226", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 22937, _connID = "\148<+X\194\247d\187\STXi\DLE\171\DC1\RS!:dW", _properties = +// []} +TEST(Connect311QCTest, Encode1) { + uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x59, 0x99, 0x0, 0x12, 0x94, 0x3c, + 0x2b, 0x58, 0xc2, 0xf7, 0x64, 0xbb, 0x2, 0x69, 0x10, 0xab, 0x11, 0x1e, 0x21, 0x3a, 0x64, 0x57, + 0x0, 0xf, 0x2c, 0xba, 0x1a, 0xc, 0x13, 0xbc, 0xcc, 0x4b, 0x52, 0x6a, 0x3c, 0x25, 0xa, 0x32, + 0x78, 0x0, 0x1c, 0x9e, 0x41, 0x3d, 0x17, 0x8, 0xfe, 0x91, 0xd7, 0x58, 0xf2, 0x80, 0xc0, 0x17, + 0x7f, 0x45, 0x5, 0x70, 0xa9, 0x8b, 0x3b, 0x73, 0x7e, 0x16, 0x87, 0x18, 0xd1, 0x4, 0xe2}; - uint8_t buf[30] = {0}; - - uint8_t topic_bytes[] = {0xfd, 0x88, 0x8c, 0xb3, 0x7d, 0x2, 0x3b}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x4a, 0x6a, 0xe, 0xf1, 0x5, 0x89, 0x11}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + uint8_t buf[89] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 22937; + uint8_t client_id_bytes[] = {0x94, 0x3c, 0x2b, 0x58, 0xc2, 0xf7, 0x64, 0xbb, 0x2, + 0x69, 0x10, 0xab, 0x11, 0x1e, 0x21, 0x3a, 0x64, 0x57}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x2c, 0xba, 0x1a, 0xc, 0x13, 0xbc, 0xcc, 0x4b, 0x52, 0x6a, 0x3c, 0x25, 0xa, 0x32, 0x78}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x9e, 0x41, 0x3d, 0x17, 0x8, 0xfe, 0x91, 0xd7, 0x58, 0xf2, 0x80, 0xc0, 0x17, 0x7f, + 0x45, 0x5, 0x70, 0xa9, 0x8b, 0x3b, 0x73, 0x7e, 0x16, 0x87, 0x18, 0xd1, 0x4, 0xe2}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 6476, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\242\232\197\SOHHe\ETX>/ -// \232\220\247\251\tq\198\197nl\247\249", _pubPktID = 2029, _pubBody = "v_\GSO8\202C0\RS\247#\141\209\DEL", _pubProps = +// ConnectRequest {_username = Just "\164\SYNT\228'W\255\244\187\193\237\180\r\238d\151m\191\n\183", _password = +// Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "2\RS", _willMsg = +// "C\US\226G\191\RS\225\238\241\187U\183Nx\ESC\165\135\147\181\SO|\ESC\236\155\198\&6\255\195", _willProps = []}), +// _cleanSession = True, _keepAlive = 23276, _connID = "\131={\SYN\158\175']\FS\233\139mf\131#\146\252M3", _properties = // []} -TEST(Publish311QCTest, Encode22) { - uint8_t pkt[] = {0x3a, 0x28, 0x0, 0x16, 0xf2, 0xe8, 0xc5, 0x1, 0x48, 0x65, 0x3, 0x3e, 0x2f, 0x20, - 0xe8, 0xdc, 0xf7, 0xfb, 0x9, 0x71, 0xc6, 0xc5, 0x6e, 0x6c, 0xf7, 0xf9, 0x7, 0xed, - 0x76, 0x5f, 0x1d, 0x4f, 0x38, 0xca, 0x43, 0x30, 0x1e, 0xf7, 0x23, 0x8d, 0xd1, 0x7f}; - - uint8_t buf[52] = {0}; +TEST(Connect311QCTest, Encode2) { + uint8_t pkt[] = {0x10, 0x57, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa6, 0x5a, 0xec, 0x0, 0x13, 0x83, + 0x3d, 0x7b, 0x16, 0x9e, 0xaf, 0x27, 0x5d, 0x1c, 0xe9, 0x8b, 0x6d, 0x66, 0x83, 0x23, 0x92, + 0xfc, 0x4d, 0x33, 0x0, 0x2, 0x32, 0x1e, 0x0, 0x1c, 0x43, 0x1f, 0xe2, 0x47, 0xbf, 0x1e, + 0xe1, 0xee, 0xf1, 0xbb, 0x55, 0xb7, 0x4e, 0x78, 0x1b, 0xa5, 0x87, 0x93, 0xb5, 0xe, 0x7c, + 0x1b, 0xec, 0x9b, 0xc6, 0x36, 0xff, 0xc3, 0x0, 0x14, 0xa4, 0x16, 0x54, 0xe4, 0x27, 0x57, + 0xff, 0xf4, 0xbb, 0xc1, 0xed, 0xb4, 0xd, 0xee, 0x64, 0x97, 0x6d, 0xbf, 0xa, 0xb7}; - uint8_t topic_bytes[] = {0xf2, 0xe8, 0xc5, 0x1, 0x48, 0x65, 0x3, 0x3e, 0x2f, 0x20, 0xe8, - 0xdc, 0xf7, 0xfb, 0x9, 0x71, 0xc6, 0xc5, 0x6e, 0x6c, 0xf7, 0xf9}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x76, 0x5f, 0x1d, 0x4f, 0x38, 0xca, 0x43, 0x30, 0x1e, 0xf7, 0x23, 0x8d, 0xd1, 0x7f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + uint8_t buf[99] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x32, 0x1e}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x43, 0x1f, 0xe2, 0x47, 0xbf, 0x1e, 0xe1, 0xee, 0xf1, 0xbb, 0x55, 0xb7, 0x4e, 0x78, + 0x1b, 0xa5, 0x87, 0x93, 0xb5, 0xe, 0x7c, 0x1b, 0xec, 0x9b, 0xc6, 0x36, 0xff, 0xc3}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23276; + uint8_t client_id_bytes[] = {0x83, 0x3d, 0x7b, 0x16, 0x9e, 0xaf, 0x27, 0x5d, 0x1c, 0xe9, + 0x8b, 0x6d, 0x66, 0x83, 0x23, 0x92, 0xfc, 0x4d, 0x33}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa4, 0x16, 0x54, 0xe4, 0x27, 0x57, 0xff, 0xf4, 0xbb, 0xc1, + 0xed, 0xb4, 0xd, 0xee, 0x64, 0x97, 0x6d, 0xbf, 0xa, 0xb7}; + lwmqtt_string_t username = {20, (char*)&username_bytes}; + opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2029, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "Y\NUL&\156\t\157<\215\152R\173\212.\245\207\197\188\163\208\&2", _pubPktID = 5733, _pubBody = -// "\SOHe\184~\148\245\199\143\205\235\200U", _pubProps = []} -TEST(Publish311QCTest, Encode23) { - uint8_t pkt[] = {0x3d, 0x24, 0x0, 0x14, 0x59, 0x0, 0x26, 0x9c, 0x9, 0x9d, 0x3c, 0xd7, 0x98, - 0x52, 0xad, 0xd4, 0x2e, 0xf5, 0xcf, 0xc5, 0xbc, 0xa3, 0xd0, 0x32, 0x16, 0x65, - 0x1, 0x65, 0xb8, 0x7e, 0x94, 0xf5, 0xc7, 0x8f, 0xcd, 0xeb, 0xc8, 0x55}; - - uint8_t buf[48] = {0}; +// ConnectRequest {_username = Just "\237TI=\140\157[R\161\178\154\138\249", _password = Just "\156\221\243", _lastWill +// = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "q\252\157\161\146\222\a\NAK2\173\167\152X\152\NAK", _willMsg = +// "\172\197<*\246\137\ESC\188\RS;\ENQ",PropAuthenticationMethod +// "s\224\226\217",PropRequestProblemInformation 110,PropAssignedClientIdentifier +// "\162\178\&6\\\164v\202\137\&70\DEL\150;<;We>\183",PropReceiveMaximum 1866,PropSharedSubscriptionAvailable +// 78,PropRetainAvailable 14,PropMessageExpiryInterval 2378,PropTopicAlias 8222,PropMessageExpiryInterval +// 24111,PropWillDelayInterval 8276,PropServerKeepAlive 18954,PropRequestProblemInformation 76,PropReasonString +// "x\240|",PropMessageExpiryInterval 13256]}), _cleanSession = True, _keepAlive = 7844, _connID = +// "\DC3\182\162\243D\231aQ<\184p\138\206\248T\248E\205\216S", _properties = [PropTopicAlias +// 27783,PropSubscriptionIdentifier 23,PropCorrelationData "(+\145\222*\206\250\207f!\172\&9",PropMessageExpiryInterval +// 14693,PropRetainAvailable 22,PropSharedSubscriptionAvailable 157,PropSharedSubscriptionAvailable +// 196,PropPayloadFormatIndicator 140,PropServerKeepAlive 26053,PropRetainAvailable 25]} +TEST(Connect5QCTest, Encode3) { + uint8_t pkt[] = {0x10, 0xe6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x1e, 0xa4, 0x26, 0x23, 0x6c, 0x87, + 0xb, 0x17, 0x9, 0x0, 0xc, 0x28, 0x2b, 0x91, 0xde, 0x2a, 0xce, 0xfa, 0xcf, 0x66, 0x21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, 0x8c, 0x9d, + 0x5b, 0x52, 0xa1, 0xb2, 0x9a, 0x8a, 0xf9, 0x0, 0x3, 0x9c, 0xdd, 0xf3}; + + uint8_t buf[243] = {0}; + + uint8_t bytesprops0[] = {0x28, 0x2b, 0x91, 0xde, 0x2a, 0xce, 0xfa, 0xcf, 0x66, 0x21, 0xac, 0x39}; - uint8_t buf[50] = {0}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27783}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14693}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26053}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 25}}, + }; - uint8_t topic_bytes[] = {0x9e, 0x22, 0x59, 0x7b, 0x4e, 0x28, 0xd1, 0x33, 0x68, 0xc7, 0x98, 0xff, 0xe9, 0xba, 0xbf}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x19, 0xff, 0x1b, 0x57, 0x4c, 0xf5, 0xb8, 0x32, 0xc0, 0xb9, - 0x58, 0xd6, 0xe9, 0x74, 0xbb, 0x20, 0x85, 0x14, 0x51}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x49, 0xbd, 0xc0, 0xfb, 0xe2, 0xb6, 0x43, 0x82, 0x3a, 0xec, + 0x3e, 0x3c, 0x2a, 0xf6, 0x89, 0x1b, 0xbc, 0x1e, 0x3b, 0x5}; + uint8_t byteswillprops1[] = {0x73, 0xe0, 0xe2, 0xd9}; + uint8_t byteswillprops2[] = {0xa2, 0xb2, 0x36, 0x5c, 0xa4, 0x76, 0xca, 0x89, 0x37, 0x30, + 0x7f, 0x96, 0x3b, 0x3c, 0x3b, 0x57, 0x65, 0x3e, 0xb7}; + uint8_t byteswillprops3[] = {0x78, 0xf0, 0x7c}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1866}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2378}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8222}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24111}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8276}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18954}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13256}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x71, 0xfc, 0x9d, 0xa1, 0x92, 0xde, 0x7, 0x15, + 0x32, 0xad, 0xa7, 0x98, 0x58, 0x98, 0x15}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xac, 0xc5, 0x3c, 0x65, 0x41, 0x55, 0x1e, 0x90, 0xf2, 0xe9, 0x41, 0x3, + 0x64, 0x13, 0xeb, 0xf1, 0xb7, 0xc4, 0xc5, 0xe6, 0x21, 0x1a, 0x9f, 0x70}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 7844; + uint8_t client_id_bytes[] = {0x13, 0xb6, 0xa2, 0xf3, 0x44, 0xe7, 0x61, 0x51, 0x3c, 0xb8, + 0x70, 0x8a, 0xce, 0xf8, 0x54, 0xf8, 0x45, 0xcd, 0xd8, 0x53}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xed, 0x54, 0x49, 0x3d, 0x8c, 0x9d, 0x5b, 0x52, 0xa1, 0xb2, 0x9a, 0x8a, 0xf9}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x9c, 0xdd, 0xf3}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 26160, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\151", _pubPktID = 0, _pubBody = -// "\216N\144\&7\CAN\136\v\176\152", _pubProps = []} -TEST(Publish311QCTest, Encode36) { - uint8_t pkt[] = {0x39, 0xc, 0x0, 0x1, 0x97, 0xd8, 0x4e, 0x90, 0x37, 0x18, 0x88, 0xb, 0xb0, 0x98}; - - uint8_t buf[24] = {0}; - - uint8_t topic_bytes[] = {0x97}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xd8, 0x4e, 0x90, 0x37, 0x18, 0x88, 0xb, 0xb0, 0x98}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); +// ConnectRequest {_username = Just "\224i\DLEM\214\247\187\191\DEL\211\139G\208\177\241\223\240\254Q\187\238", +// _password = Just "\214t\171wJ\205+", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\201\&2\STXO\162\178*\207.", _willMsg = "\130sO\246\224\216\186Y^\142PH\235zMe+\247P:~\151\243", _willProps = +// [PropSharedSubscriptionAvailable 234,PropMaximumPacketSize 13128,PropSharedSubscriptionAvailable +// 26,PropTopicAliasMaximum 30233,PropContentType +// "\210\206\"\ENQ_J\STX28\252At\252V|x\233\153\145b9\160\n\192\209\247I\197\DC4_",PropAssignedClientIdentifier +// "\162\RS\214y\233\129\212\162\239",PropMessageExpiryInterval 3560,PropSubscriptionIdentifierAvailable +// 237,PropTopicAliasMaximum 10546,PropContentType +// "\ESCN\DC2\156\134|o\183\183k\219\DC2e\222{\197]",PropMaximumPacketSize 12592,PropSubscriptionIdentifierAvailable +// 202,PropWildcardSubscriptionAvailable 238,PropSubscriptionIdentifier 11,PropMaximumPacketSize +// 27524,PropSubscriptionIdentifierAvailable 195,PropResponseInformation +// "q\SUB\169\EOT\245]\169\CAN\SI\b\b\218U\220\238\247\156\STX\213B\130M\231\190\EM\255",PropReceiveMaximum +// 30498,PropTopicAlias 13431,PropAuthenticationData "\129z\243*~",PropAuthenticationData +// ">W3\237\160\SYN\r_\139\248HFF",PropCorrelationData "zP\EM\229\CAN\NAK",PropMaximumQoS 133,PropMessageExpiryInterval +// 3956]}), _cleanSession = True, _keepAlive = 27556, _connID = +// "\SYN=D\DC23R\135\142|\151\t7\226\201\228\239\224\189\DC4a\198\210\FSA\189", _properties = [PropMessageExpiryInterval +// 23978,PropResponseInformation "\EOTa\156N\222\CAN\224\198\171\RSq6\194)\NAK\223\137"]} +TEST(Connect5QCTest, Encode4) { + uint8_t pkt[] = { + 0x10, 0xb9, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x6b, 0xa4, 0x19, 0x2, 0x0, 0x0, 0x5d, 0xaa, + 0x1a, 0x0, 0x11, 0x4, 0x61, 0x9c, 0x4e, 0xde, 0x18, 0xe0, 0xc6, 0xab, 0x1e, 0x71, 0x36, 0xc2, 0x29, 0x15, 0xdf, + 0x89, 0x0, 0x19, 0x16, 0x3d, 0x44, 0x12, 0x33, 0x52, 0x87, 0x8e, 0x7c, 0x97, 0x9, 0x37, 0xe2, 0xc9, 0xe4, 0xef, + 0xe0, 0xbd, 0x14, 0x61, 0xc6, 0xd2, 0x1c, 0x41, 0xbd, 0xb4, 0x1, 0x2a, 0xea, 0x27, 0x0, 0x0, 0x33, 0x48, 0x2a, + 0x1a, 0x22, 0x76, 0x19, 0x3, 0x0, 0x1e, 0xd2, 0xce, 0x22, 0x5, 0x5f, 0x4a, 0x2, 0x32, 0x38, 0xfc, 0x41, 0x74, + 0xfc, 0x56, 0x7c, 0x78, 0xe9, 0x99, 0x91, 0x62, 0x39, 0xa0, 0xa, 0xc0, 0xd1, 0xf7, 0x49, 0xc5, 0x14, 0x5f, 0x12, + 0x0, 0x9, 0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0xfe, + 0x51, 0xbb, 0xee, 0x0, 0x7, 0xd6, 0x74, 0xab, 0x77, 0x4a, 0xcd, 0x2b}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[326] = {0}; -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\f\n|\ACK", _pubPktID = 0, _pubBody -// = "%\192\&0", _pubProps = []} -TEST(Publish311QCTest, Encode37) { - uint8_t pkt[] = {0x38, 0x9, 0x0, 0x4, 0xc, 0xa, 0x7c, 0x6, 0x25, 0xc0, 0x30}; + uint8_t bytesprops0[] = {0x4, 0x61, 0x9c, 0x4e, 0xde, 0x18, 0xe0, 0xc6, 0xab, + 0x1e, 0x71, 0x36, 0xc2, 0x29, 0x15, 0xdf, 0x89}; - uint8_t buf[21] = {0}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23978}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, + }; - uint8_t topic_bytes[] = {0xc, 0xa, 0x7c, 0x6}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x25, 0xc0, 0x30}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xd2, 0xce, 0x22, 0x5, 0x5f, 0x4a, 0x2, 0x32, 0x38, 0xfc, + 0x41, 0x74, 0xfc, 0x56, 0x7c, 0x78, 0xe9, 0x99, 0x91, 0x62, + 0x39, 0xa0, 0xa, 0xc0, 0xd1, 0xf7, 0x49, 0xc5, 0x14, 0x5f}; + uint8_t byteswillprops1[] = {0xa2, 0x1e, 0xd6, 0x79, 0xe9, 0x81, 0xd4, 0xa2, 0xef}; + uint8_t byteswillprops2[] = {0x1b, 0x4e, 0x12, 0x9c, 0x86, 0x7c, 0x6f, 0xb7, 0xb7, + 0x6b, 0xdb, 0x12, 0x65, 0xde, 0x7b, 0xc5, 0x5d}; + uint8_t byteswillprops3[] = {0x71, 0x1a, 0xa9, 0x4, 0xf5, 0x5d, 0xa9, 0x18, 0xf, 0x8, 0x8, 0xda, 0x55, + 0xdc, 0xee, 0xf7, 0x9c, 0x2, 0xd5, 0x42, 0x82, 0x4d, 0xe7, 0xbe, 0x19, 0xff}; + uint8_t byteswillprops4[] = {0x81, 0x7a, 0xf3, 0x2a, 0x7e}; + uint8_t byteswillprops5[] = {0x3e, 0x57, 0x33, 0xed, 0xa0, 0x16, 0xd, 0x5f, 0x8b, 0xf8, 0x48, 0x46, 0x46}; + uint8_t byteswillprops6[] = {0x7a, 0x50, 0x19, 0xe5, 0x18, 0x15}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13128}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30233}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3560}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10546}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12592}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27524}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30498}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13431}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3956}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc9, 0x32, 0x2, 0x4f, 0xa2, 0xb2, 0x2a, 0xcf, 0x2e}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x82, 0x73, 0x4f, 0xf6, 0xe0, 0xd8, 0xba, 0x59, 0x5e, 0x8e, 0x50, 0x48, + 0xeb, 0x7a, 0x4d, 0x65, 0x2b, 0xf7, 0x50, 0x3a, 0x7e, 0x97, 0xf3}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 27556; + uint8_t client_id_bytes[] = {0x16, 0x3d, 0x44, 0x12, 0x33, 0x52, 0x87, 0x8e, 0x7c, 0x97, 0x9, 0x37, 0xe2, + 0xc9, 0xe4, 0xef, 0xe0, 0xbd, 0x14, 0x61, 0xc6, 0xd2, 0x1c, 0x41, 0xbd}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xe0, 0x69, 0x10, 0x4d, 0xd6, 0xf7, 0xbb, 0xbf, 0x7f, 0xd3, 0x8b, + 0x47, 0xd0, 0xb1, 0xf1, 0xdf, 0xf0, 0xfe, 0x51, 0xbb, 0xee}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xd6, 0x74, 0xab, 0x77, 0x4a, 0xcd, 0x2b}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\SUB\161\156|\172\155*2\212e\184\252<\195\a\180C\177\162\130\159\166L\200\SYN_", _pubPktID = 14022, _pubBody = -// "01c\156c\152\DC3@\149/\USy\FS\147\184,n\243\245\134Kc?E\206\131\ESC ;", _pubProps = []} -TEST(Publish311QCTest, Encode38) { - uint8_t pkt[] = {0x32, 0x3b, 0x0, 0x1a, 0x1a, 0xa1, 0x9c, 0x7c, 0xac, 0x9b, 0x2a, 0x32, 0xd4, 0x65, 0xb8, 0xfc, - 0x3c, 0xc3, 0x7, 0xb4, 0x43, 0xb1, 0xa2, 0x82, 0x9f, 0xa6, 0x4c, 0xc8, 0x16, 0x5f, 0x36, 0xc6, - 0x30, 0x31, 0x63, 0x9c, 0x63, 0x98, 0x13, 0x40, 0x95, 0x2f, 0x1f, 0x79, 0x1c, 0x93, 0xb8, 0x2c, - 0x6e, 0xf3, 0xf5, 0x86, 0x4b, 0x63, 0x3f, 0x45, 0xce, 0x83, 0x1b, 0x20, 0x3b}; +// ConnectRequest {_username = Just "`\158g", _password = Just "\232\SI\164\182", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "\228\209\134\&8\254\183", _willMsg = +// "u`\185\164|=O\ACK\216nx\132", _willProps = [PropMessageExpiryInterval 15261,PropTopicAliasMaximum +// 29836,PropRequestProblemInformation 20,PropRetainAvailable 102,PropRequestResponseInformation 129,PropRetainAvailable +// 104,PropUserProperty "\234\&8x\EMW" "\230\149\DC2;^\DLE\165\STX\245\151@V\211\149A\178S",PropUserProperty +// "\225p\154\210" "\131J\SI\129g\189\DC3\170\143RS\234\129\245\252X\228\171\215\&0",PropWildcardSubscriptionAvailable +// 78,PropAuthenticationMethod "f\141\254\185\233#",PropServerReference +// "[u\253\220\RS\235\188\183\155\202\CAN\186\229\185hV_\130\172)A\210%\ETX",PropUserProperty +// "f\161)F\206\248o\174\212\rf\169\241\164\223U-\214\186!\169\162\163\198\152" +// "\189Mi\200\EOT&1\203\221\182\SUB\194\222e\199\ACK\130U%\"",PropAssignedClientIdentifier +// "\GS_\206V\SUBy\174Q\STX\187b\161F.\141s\235{\DC3\251",PropMessageExpiryInterval 28877,PropResponseInformation +// "\CANP\ENQN8>\229D*",PropMessageExpiryInterval 19314,PropRequestResponseInformation 24,PropResponseInformation +// "]\147J\178\146&\158l\177\153\238\161\a\192",PropMessageExpiryInterval +// 5878,PropSessionExpiryInterval 18096,PropReceiveMaximum 27639,PropWildcardSubscriptionAvailable 151]}), _cleanSession +// = True, _keepAlive = 1272, _connID = "v=A\216\191\162\"ul\165(\217\182\151@.q", _properties = +// [PropSubscriptionIdentifier 22,PropPayloadFormatIndicator 172,PropContentType "\247\129",PropReceiveMaximum +// 14439,PropUserProperty "a\142 \153\240G" "\\\202\249\165\251\134/\v",PropSessionExpiryInterval +// 24192,PropWildcardSubscriptionAvailable 11,PropSubscriptionIdentifier 29,PropReceiveMaximum +// 8508,PropWildcardSubscriptionAvailable 28,PropMessageExpiryInterval 22152,PropReasonString +// "w\n0.",PropMessageExpiryInterval 18385,PropContentType "N\146\217\145fE\231\231\248\201\149\"u\212\139"]} +TEST(Connect5QCTest, Encode5) { + uint8_t pkt[] = { + 0x10, 0x8e, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x4, 0xf8, 0x50, 0xb, 0x16, 0x1, 0xac, 0x3, + 0x0, 0x2, 0xf7, 0x81, 0x21, 0x38, 0x67, 0x26, 0x0, 0x6, 0x61, 0x8e, 0x20, 0x99, 0xf0, 0x47, 0x0, 0x8, 0x5c, + 0xca, 0xf9, 0xa5, 0xfb, 0x86, 0x2f, 0xb, 0x11, 0x0, 0x0, 0x5e, 0x80, 0x28, 0xb, 0xb, 0x1d, 0x21, 0x21, 0x3c, + 0x28, 0x1c, 0x2, 0x0, 0x0, 0x56, 0x88, 0x1f, 0x0, 0x4, 0x77, 0xa, 0x30, 0x2e, 0x2, 0x0, 0x0, 0x47, 0xd1, + 0x3, 0x0, 0xf, 0x4e, 0x92, 0xd9, 0x91, 0x66, 0x45, 0xe7, 0xe7, 0xf8, 0xc9, 0x95, 0x22, 0x75, 0xd4, 0x8b, 0x0, + 0x11, 0x76, 0x3d, 0x41, 0xd8, 0xbf, 0xa2, 0x22, 0x75, 0x6c, 0xa5, 0x28, 0xd9, 0xb6, 0x97, 0x40, 0x2e, 0x71, 0xfd, + 0x1, 0x2, 0x0, 0x0, 0x3b, 0x9d, 0x22, 0x74, 0x8c, 0x17, 0x14, 0x25, 0x66, 0x19, 0x81, 0x25, 0x68, 0x26, 0x0, + 0x5, 0xea, 0x38, 0x78, 0x19, 0x57, 0x0, 0x11, 0xe6, 0x95, 0x12, 0x3b, 0x5e, 0x10, 0xa5, 0x2, 0xf5, 0x97, 0x40, + 0x56, 0xd3, 0x95, 0x41, 0xb2, 0x53, 0x26, 0x0, 0x4, 0xe1, 0x70, 0x9a, 0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a1, 0x7, 0xc0, 0x2, 0x0, 0x0, 0x16, 0xf6, 0x11, 0x0, 0x0, + 0x46, 0xb0, 0x21, 0x6b, 0xf7, 0x28, 0x97, 0x0, 0x6, 0xe4, 0xd1, 0x86, 0x38, 0xfe, 0xb7, 0x0, 0xc, 0x75, 0x60, + 0xb9, 0xa4, 0x7c, 0x3d, 0x4f, 0x6, 0xd8, 0x6e, 0x78, 0x84, 0x0, 0x3, 0x60, 0x9e, 0x67, 0x0, 0x4, 0xe8, 0xf, + 0xa4, 0xb6}; + + uint8_t buf[411] = {0}; + + uint8_t bytesprops0[] = {0xf7, 0x81}; + uint8_t bytesprops2[] = {0x5c, 0xca, 0xf9, 0xa5, 0xfb, 0x86, 0x2f, 0xb}; + uint8_t bytesprops1[] = {0x61, 0x8e, 0x20, 0x99, 0xf0, 0x47}; + uint8_t bytesprops3[] = {0x77, 0xa, 0x30, 0x2e}; + uint8_t bytesprops4[] = {0x4e, 0x92, 0xd9, 0x91, 0x66, 0x45, 0xe7, 0xe7, 0xf8, 0xc9, 0x95, 0x22, 0x75, 0xd4, 0x8b}; - uint8_t buf[71] = {0}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14439}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24192}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8508}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22152}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18385}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops4}}}, + }; - uint8_t topic_bytes[] = {0x1a, 0xa1, 0x9c, 0x7c, 0xac, 0x9b, 0x2a, 0x32, 0xd4, 0x65, 0xb8, 0xfc, 0x3c, - 0xc3, 0x7, 0xb4, 0x43, 0xb1, 0xa2, 0x82, 0x9f, 0xa6, 0x4c, 0xc8, 0x16, 0x5f}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x30, 0x31, 0x63, 0x9c, 0x63, 0x98, 0x13, 0x40, 0x95, 0x2f, 0x1f, 0x79, 0x1c, 0x93, 0xb8, - 0x2c, 0x6e, 0xf3, 0xf5, 0x86, 0x4b, 0x63, 0x3f, 0x45, 0xce, 0x83, 0x1b, 0x20, 0x3b}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xe6, 0x95, 0x12, 0x3b, 0x5e, 0x10, 0xa5, 0x2, 0xf5, + 0x97, 0x40, 0x56, 0xd3, 0x95, 0x41, 0xb2, 0x53}; + uint8_t byteswillprops0[] = {0xea, 0x38, 0x78, 0x19, 0x57}; + uint8_t byteswillprops3[] = {0x83, 0x4a, 0xf, 0x81, 0x67, 0xbd, 0x13, 0xaa, 0x8f, 0x52, + 0x53, 0xea, 0x81, 0xf5, 0xfc, 0x58, 0xe4, 0xab, 0xd7, 0x30}; + uint8_t byteswillprops2[] = {0xe1, 0x70, 0x9a, 0xd2}; + uint8_t byteswillprops4[] = {0x66, 0x8d, 0xfe, 0xb9, 0xe9, 0x23}; + uint8_t byteswillprops5[] = {0x5b, 0x75, 0xfd, 0xdc, 0x1e, 0xeb, 0xbc, 0xb7, 0x9b, 0xca, 0x18, 0xba, + 0xe5, 0xb9, 0x68, 0x56, 0x5f, 0x82, 0xac, 0x29, 0x41, 0xd2, 0x25, 0x3}; + uint8_t byteswillprops7[] = {0xbd, 0x4d, 0x69, 0xc8, 0x4, 0x26, 0x31, 0xcb, 0xdd, 0xb6, + 0x1a, 0xc2, 0xde, 0x65, 0xc7, 0x6, 0x82, 0x55, 0x25, 0x22}; + uint8_t byteswillprops6[] = {0x66, 0xa1, 0x29, 0x46, 0xce, 0xf8, 0x6f, 0xae, 0xd4, 0xd, 0x66, 0xa9, 0xf1, + 0xa4, 0xdf, 0x55, 0x2d, 0xd6, 0xba, 0x21, 0xa9, 0xa2, 0xa3, 0xc6, 0x98}; + uint8_t byteswillprops8[] = {0x1d, 0x5f, 0xce, 0x56, 0x1a, 0x79, 0xae, 0x51, 0x2, 0xbb, + 0x62, 0xa1, 0x46, 0x2e, 0x8d, 0x73, 0xeb, 0x7b, 0x13, 0xfb}; + uint8_t byteswillprops9[] = {0x18, 0x50, 0x5, 0x4e, 0x38, 0x3e, 0xe5, 0x44, 0x2a}; + uint8_t byteswillprops10[] = {0x5d, 0x93, 0x4a, 0xb2, 0x92, 0x26, 0x9e, 0x3c, 0x74, 0xf0, 0x9c, 0x64, 0xfb, 0xbc, + 0x18, 0x30, 0x92, 0x11, 0x1d, 0xcc, 0x3e, 0x6c, 0xb1, 0x99, 0xee, 0xa1, 0x7, 0xc0}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15261}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29836}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {5, (char*)&byteswillprops0}, .v = {17, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {4, (char*)&byteswillprops2}, .v = {20, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {25, (char*)&byteswillprops6}, .v = {20, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28877}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19314}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5878}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18096}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27639}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe4, 0xd1, 0x86, 0x38, 0xfe, 0xb7}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x75, 0x60, 0xb9, 0xa4, 0x7c, 0x3d, 0x4f, 0x6, 0xd8, 0x6e, 0x78, 0x84}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1272; + uint8_t client_id_bytes[] = {0x76, 0x3d, 0x41, 0xd8, 0xbf, 0xa2, 0x22, 0x75, 0x6c, + 0xa5, 0x28, 0xd9, 0xb6, 0x97, 0x40, 0x2e, 0x71}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x60, 0x9e, 0x67}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xe8, 0xf, 0xa4, 0xb6}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 14022, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\186Kx\255\202i[\182\SUBu\242L\148\153\157\182\GSY)", _pubPktID = 16446, _pubBody = -// "\STX\188u\179*\236\174\253@\ACK\219x\192d\168\200\210\177-\181\250\207\176\230", _pubProps = []} -TEST(Publish311QCTest, Encode39) { - uint8_t pkt[] = {0x35, 0x2f, 0x0, 0x13, 0xba, 0x4b, 0x78, 0xff, 0xca, 0x69, 0x5b, 0xb6, 0x1a, 0x75, 0xf2, 0x4c, 0x94, - 0x99, 0x9d, 0xb6, 0x1d, 0x59, 0x29, 0x40, 0x3e, 0x2, 0xbc, 0x75, 0xb3, 0x2a, 0xec, 0xae, 0xfd, 0x40, - 0x6, 0xdb, 0x78, 0xc0, 0x64, 0xa8, 0xc8, 0xd2, 0xb1, 0x2d, 0xb5, 0xfa, 0xcf, 0xb0, 0xe6}; +// ConnectRequest {_username = Just "|\ENQ\ETXN\196/!2\EOT\150wV\ETB\205R\NUL", _password = Just +// "\171\176x\189\&3I\250!\207\139J\139\160x\SYN", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, +// _willTopic = "9~,\236\224~@\247G|] \153\191\142\DC3\DEL\ETBcx\a\192\211\EOT\138IF", _willMsg = +// "\143q\200<\208LHV\222HO1\181U\229\173\158\255", _willProps = [PropMessageExpiryInterval 22676,PropUserProperty +// "t\GS\172\&3\213\181\221\140" "\242\191K\211F\247{\232\&31q`dJ",PropWillDelayInterval 18062,PropMaximumPacketSize +// 5758,PropContentType "\181\&9d\177\196@$a\155\132E\247\177\DEL\209\155\SYN\SOHZ\SI\167\156\r",PropMaximumPacketSize +// 32395,PropRequestResponseInformation 230,PropResponseTopic +// "\231%-\195\204\160\230\130\238S\176\187\128\214\247*fN.)k\146C\DC43\180!O;",PropMaximumPacketSize +// 8412,PropMessageExpiryInterval 20741,PropSubscriptionIdentifier 34,PropMessageExpiryInterval +// 3727,PropAuthenticationData +// "\208\182P\212\"bl\174\233\177+\249\EOT\230\173\a\194w\156\251\165\244\192\224\DC2\242\180\CAN",PropRequestProblemInformation +// 140,PropReceiveMaximum 31448,PropContentType "\SYN\168Tq\255\&4\226\237",PropServerKeepAlive 12597,PropReceiveMaximum +// 26906,PropWillDelayInterval 20356,PropCorrelationData "+p\240\GS\180\STX\235b$",PropResponseInformation +// "GT\ACKV",PropAssignedClientIdentifier +// "\160\&3!\SI\208GJ\233\153\130\163\169\f\CAN\221",PropWildcardSubscriptionAvailable 219,PropMaximumPacketSize +// 29532,PropReasonString +// "\169\RST\156~+\254\NAKF\208\195J\US\ESC$\177\190]\247\v\162\153D.\ENQ\175\136\214",PropTopicAliasMaximum +// 17359,PropReasonString +// "\DC1\SUB2\179\235\196U\SIi\196\&3\n_\234\DC3\EM\US\t(\ETB\226\&3\226\215\132\&6\222\NUL",PropMessageExpiryInterval +// 15547,PropMaximumPacketSize 435,PropServerReference "\SOHA"]}), _cleanSession = True, _keepAlive = 22109, _connID = +// "\DC4\170\162a\211\176\131\ETX\208", _properties = [PropServerReference "",PropRequestProblemInformation +// 9,PropCorrelationData "r\163\FS\131^\203\171\228\251",PropTopicAliasMaximum 30892,PropRequestResponseInformation +// 40,PropResponseTopic "\"gmj\239\211\&9\223\171\175\RS I0\136\154\233&\155\163",PropAuthenticationData +// "Y\FS\ENQZ\249s\147&H\188|q'3\236\193?!\178\184~Y\160\148\227",PropSubscriptionIdentifier 3,PropTopicAliasMaximum +// 13591,PropRequestProblemInformation 67,PropServerReference "\151\FSZ\189\161\249ha\DC1l\ETX\208\&6e\203r(\213 +// \240\&9\172\130@\181\131\fI\152",PropPayloadFormatIndicator 88,PropCorrelationData "\195%",PropWillDelayInterval +// 25823,PropRequestProblemInformation 234,PropRetainAvailable 166,PropPayloadFormatIndicator 99,PropUserProperty +// "\164\SI\183\198'\153l\223" +// "\US\204\185\164\243\228\209\ACKC\156\247{\143\241\145\135\180\131\138\178\188\DEL>\160\\\SYN1\139",PropSubscriptionIdentifierAvailable +// 7,PropSubscriptionIdentifier 9,PropServerReference "s\172\218\206K\156i\GS\154$\133O\174\160 +// \199i\205\247_$%Ux\170L\205",PropMaximumPacketSize 18119,PropCorrelationData +// "\227\157\235\193\139&\"L\231\133",PropWillDelayInterval 24104,PropResponseInformation +// "\227\254\251\227\145\RS\164OH\r\200\204\158",PropContentType +// "\134\224\147\203\ETX\189\185\189\179\189jT\148|\165~#",PropReasonString +// "a\229\206\164\193K\NUL\ETB8\148\DLE\191\245",PropReceiveMaximum 30786,PropSubscriptionIdentifierAvailable 109]} +TEST(Connect5QCTest, Encode6) { + uint8_t pkt[] = { + 0x10, 0xbc, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x56, 0x5d, 0x9d, 0x2, 0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0, 0x1c, 0x11, 0x1a, 0x32, 0xb3, 0xeb, 0xc4, 0x55, 0xf, 0x69, 0xc4, 0x33, 0xa, 0x5f, + 0xea, 0x13, 0x19, 0x1f, 0x9, 0x28, 0x17, 0xe2, 0x33, 0xe2, 0xd7, 0x84, 0x36, 0xde, 0x0, 0x2, 0x0, 0x0, 0x3c, + 0xbb, 0x27, 0x0, 0x0, 0x1, 0xb3, 0x1c, 0x0, 0x2, 0x1, 0x41, 0x0, 0x1b, 0x39, 0x7e, 0x2c, 0xec, 0xe0, 0x7e, + 0x40, 0xf7, 0x47, 0x7c, 0x5d, 0x20, 0x99, 0xbf, 0x8e, 0x13, 0x7f, 0x17, 0x63, 0x78, 0x7, 0xc0, 0xd3, 0x4, 0x8a, + 0x49, 0x46, 0x0, 0x12, 0x8f, 0x71, 0xc8, 0x3c, 0xd0, 0x4c, 0x48, 0x56, 0xde, 0x48, 0x4f, 0x31, 0xb5, 0x55, 0xe5, + 0xad, 0x9e, 0xff, 0x0, 0x10, 0x7c, 0x5, 0x3, 0x4e, 0xc4, 0x2f, 0x21, 0x32, 0x4, 0x96, 0x77, 0x56, 0x17, 0xcd, + 0x52, 0x0, 0x0, 0xf, 0xab, 0xb0, 0x78, 0xbd, 0x33, 0x49, 0xfa, 0x21, 0xcf, 0x8b, 0x4a, 0x8b, 0xa0, 0x78, 0x16}; + + uint8_t buf[713] = {0}; - uint8_t buf[59] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x72, 0xa3, 0x1c, 0x83, 0x5e, 0xcb, 0xab, 0xe4, 0xfb}; + uint8_t bytesprops2[] = {0x22, 0x67, 0x6d, 0x6a, 0xef, 0xd3, 0x39, 0xdf, 0xab, 0xaf, + 0x1e, 0x20, 0x49, 0x30, 0x88, 0x9a, 0xe9, 0x26, 0x9b, 0xa3}; + uint8_t bytesprops3[] = {0x59, 0x1c, 0x5, 0x5a, 0xf9, 0x73, 0x93, 0x26, 0x48, 0xbc, 0x7c, 0x71, 0x27, + 0x33, 0xec, 0xc1, 0x3f, 0x21, 0xb2, 0xb8, 0x7e, 0x59, 0xa0, 0x94, 0xe3}; + uint8_t bytesprops4[] = {0x97, 0x1c, 0x5a, 0xbd, 0xa1, 0xf9, 0x68, 0x61, 0x11, 0x6c, 0x3, 0xd0, 0x36, 0x65, 0xcb, + 0x72, 0x28, 0xd5, 0x20, 0xf0, 0x39, 0xac, 0x82, 0x40, 0xb5, 0x83, 0xc, 0x49, 0x98}; + uint8_t bytesprops5[] = {0xc3, 0x25}; + uint8_t bytesprops7[] = {0x1f, 0xcc, 0xb9, 0xa4, 0xf3, 0xe4, 0xd1, 0x6, 0x43, 0x9c, 0xf7, 0x7b, 0x8f, 0xf1, + 0x91, 0x87, 0xb4, 0x83, 0x8a, 0xb2, 0xbc, 0x7f, 0x3e, 0xa0, 0x5c, 0x16, 0x31, 0x8b}; + uint8_t bytesprops6[] = {0xa4, 0xf, 0xb7, 0xc6, 0x27, 0x99, 0x6c, 0xdf}; + uint8_t bytesprops8[] = {0x73, 0xac, 0xda, 0xce, 0x4b, 0x9c, 0x69, 0x1d, 0x9a, 0x24, 0x85, 0x4f, 0xae, 0xa0, + 0x20, 0xc7, 0x69, 0xcd, 0xf7, 0x5f, 0x24, 0x25, 0x55, 0x78, 0xaa, 0x4c, 0xcd}; + uint8_t bytesprops9[] = {0xe3, 0x9d, 0xeb, 0xc1, 0x8b, 0x26, 0x22, 0x4c, 0xe7, 0x85}; + uint8_t bytesprops10[] = {0xe3, 0xfe, 0xfb, 0xe3, 0x91, 0x1e, 0xa4, 0x4f, 0x48, 0xd, 0xc8, 0xcc, 0x9e}; + uint8_t bytesprops11[] = {0x86, 0xe0, 0x93, 0xcb, 0x3, 0xbd, 0xb9, 0xbd, 0xb3, + 0xbd, 0x6a, 0x54, 0x94, 0x7c, 0xa5, 0x7e, 0x23}; + uint8_t bytesprops12[] = {0x61, 0xe5, 0xce, 0xa4, 0xc1, 0x4b, 0x0, 0x17, 0x38, 0x94, 0x10, 0xbf, 0xf5}; - uint8_t topic_bytes[] = {0xba, 0x4b, 0x78, 0xff, 0xca, 0x69, 0x5b, 0xb6, 0x1a, 0x75, - 0xf2, 0x4c, 0x94, 0x99, 0x9d, 0xb6, 0x1d, 0x59, 0x29}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x2, 0xbc, 0x75, 0xb3, 0x2a, 0xec, 0xae, 0xfd, 0x40, 0x6, 0xdb, 0x78, - 0xc0, 0x64, 0xa8, 0xc8, 0xd2, 0xb1, 0x2d, 0xb5, 0xfa, 0xcf, 0xb0, 0xe6}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30892}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13591}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25823}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops6}, .v = {28, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18119}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24104}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30786}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 109}}, + }; - lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xf2, 0xbf, 0x4b, 0xd3, 0x46, 0xf7, 0x7b, 0xe8, 0x33, 0x31, 0x71, 0x60, 0x64, 0x4a}; + uint8_t byteswillprops0[] = {0x74, 0x1d, 0xac, 0x33, 0xd5, 0xb5, 0xdd, 0x8c}; + uint8_t byteswillprops2[] = {0xb5, 0x39, 0x64, 0xb1, 0xc4, 0x40, 0x24, 0x61, 0x9b, 0x84, 0x45, 0xf7, + 0xb1, 0x7f, 0xd1, 0x9b, 0x16, 0x1, 0x5a, 0xf, 0xa7, 0x9c, 0xd}; + uint8_t byteswillprops3[] = {0xe7, 0x25, 0x2d, 0xc3, 0xcc, 0xa0, 0xe6, 0x82, 0xee, 0x53, 0xb0, 0xbb, 0x80, 0xd6, 0xf7, + 0x2a, 0x66, 0x4e, 0x2e, 0x29, 0x6b, 0x92, 0x43, 0x14, 0x33, 0xb4, 0x21, 0x4f, 0x3b}; + uint8_t byteswillprops4[] = {0xd0, 0xb6, 0x50, 0xd4, 0x22, 0x62, 0x6c, 0xae, 0xe9, 0xb1, 0x2b, 0xf9, 0x4, 0xe6, + 0xad, 0x7, 0xc2, 0x77, 0x9c, 0xfb, 0xa5, 0xf4, 0xc0, 0xe0, 0x12, 0xf2, 0xb4, 0x18}; + uint8_t byteswillprops5[] = {0x16, 0xa8, 0x54, 0x71, 0xff, 0x34, 0xe2, 0xed}; + uint8_t byteswillprops6[] = {0x2b, 0x70, 0xf0, 0x1d, 0xb4, 0x2, 0xeb, 0x62, 0x24}; + uint8_t byteswillprops7[] = {0x47, 0x54, 0x6, 0x56}; + uint8_t byteswillprops8[] = {0xa0, 0x33, 0x21, 0xf, 0xd0, 0x47, 0x4a, 0xe9, 0x99, 0x82, 0xa3, 0xa9, 0xc, 0x18, 0xdd}; + uint8_t byteswillprops9[] = {0xa9, 0x1e, 0x54, 0x9c, 0x7e, 0x2b, 0xfe, 0x15, 0x46, 0xd0, 0xc3, 0x4a, 0x1f, 0x1b, + 0x24, 0xb1, 0xbe, 0x5d, 0xf7, 0xb, 0xa2, 0x99, 0x44, 0x2e, 0x5, 0xaf, 0x88, 0xd6}; + uint8_t byteswillprops10[] = {0x11, 0x1a, 0x32, 0xb3, 0xeb, 0xc4, 0x55, 0xf, 0x69, 0xc4, 0x33, 0xa, 0x5f, 0xea, + 0x13, 0x19, 0x1f, 0x9, 0x28, 0x17, 0xe2, 0x33, 0xe2, 0xd7, 0x84, 0x36, 0xde, 0x0}; + uint8_t byteswillprops11[] = {0x1, 0x41}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22676}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {8, (char*)&byteswillprops0}, .v = {14, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18062}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5758}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32395}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8412}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20741}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 34}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3727}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31448}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12597}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26906}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20356}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29532}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17359}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15547}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 435}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops11}}}, + }; + + lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x39, 0x7e, 0x2c, 0xec, 0xe0, 0x7e, 0x40, 0xf7, 0x47, 0x7c, 0x5d, 0x20, 0x99, 0xbf, + 0x8e, 0x13, 0x7f, 0x17, 0x63, 0x78, 0x7, 0xc0, 0xd3, 0x4, 0x8a, 0x49, 0x46}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x8f, 0x71, 0xc8, 0x3c, 0xd0, 0x4c, 0x48, 0x56, 0xde, + 0x48, 0x4f, 0x31, 0xb5, 0x55, 0xe5, 0xad, 0x9e, 0xff}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 22109; + uint8_t client_id_bytes[] = {0x14, 0xaa, 0xa2, 0x61, 0xd3, 0xb0, 0x83, 0x3, 0xd0}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x7c, 0x5, 0x3, 0x4e, 0xc4, 0x2f, 0x21, 0x32, + 0x4, 0x96, 0x77, 0x56, 0x17, 0xcd, 0x52, 0x0}; + lwmqtt_string_t username = {16, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xab, 0xb0, 0x78, 0xbd, 0x33, 0x49, 0xfa, 0x21, 0xcf, 0x8b, 0x4a, 0x8b, 0xa0, 0x78, 0x16}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16446, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\252\171\ETB\146\NUL\152K`)b\NAK\180\148v\174B%\160\203\135\202\RS,\162aK\ESCF\183\140", _pubPktID = 0, _pubBody = " -// \173\153\209\219\234pW\207F\221\202q\136\227\190\"\199\130", _pubProps = []} -TEST(Publish311QCTest, Encode40) { - uint8_t pkt[] = {0x30, 0x33, 0x0, 0x1e, 0xfc, 0xab, 0x17, 0x92, 0x0, 0x98, 0x4b, 0x60, 0x29, 0x62, - 0x15, 0xb4, 0x94, 0x76, 0xae, 0x42, 0x25, 0xa0, 0xcb, 0x87, 0xca, 0x1e, 0x2c, 0xa2, - 0x61, 0x4b, 0x1b, 0x46, 0xb7, 0x8c, 0x20, 0xad, 0x99, 0xd1, 0xdb, 0xea, 0x70, 0x57, - 0xcf, 0x46, 0xdd, 0xca, 0x71, 0x88, 0xe3, 0xbe, 0x22, 0xc7, 0x82}; +// ConnectRequest {_username = Just "$\EM\165\160\SUBJ\a\172X\237g2\r\233#\197H\209G\165\171\255\DEL", _password = Just +// "\EM\190|\164\130", _lastWill = Nothing, _cleanSession = False, _keepAlive = 10212, _connID = "\"{\179:\181", +// _properties = [PropRequestResponseInformation 114,PropCorrelationData "L\166\133\n]g/`\244"]} +TEST(Connect5QCTest, Encode7) { + uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x27, 0xe4, 0xe, 0x19, 0x72, 0x9, 0x0, + 0x9, 0x4c, 0xa6, 0x85, 0xa, 0x5d, 0x67, 0x2f, 0x60, 0xf4, 0x0, 0x5, 0x22, 0x7b, 0xb3, 0x3a, 0xb5, + 0x0, 0x17, 0x24, 0x19, 0xa5, 0xa0, 0x1a, 0x4a, 0x7, 0xac, 0x58, 0xed, 0x67, 0x32, 0xd, 0xe9, 0x23, + 0xc5, 0x48, 0xd1, 0x47, 0xa5, 0xab, 0xff, 0x7f, 0x0, 0x5, 0x19, 0xbe, 0x7c, 0xa4, 0x82}; - uint8_t buf[63] = {0}; + uint8_t buf[76] = {0}; - uint8_t topic_bytes[] = {0xfc, 0xab, 0x17, 0x92, 0x0, 0x98, 0x4b, 0x60, 0x29, 0x62, 0x15, 0xb4, 0x94, 0x76, 0xae, - 0x42, 0x25, 0xa0, 0xcb, 0x87, 0xca, 0x1e, 0x2c, 0xa2, 0x61, 0x4b, 0x1b, 0x46, 0xb7, 0x8c}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x20, 0xad, 0x99, 0xd1, 0xdb, 0xea, 0x70, 0x57, 0xcf, 0x46, - 0xdd, 0xca, 0x71, 0x88, 0xe3, 0xbe, 0x22, 0xc7, 0x82}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + uint8_t bytesprops0[] = {0x4c, 0xa6, 0x85, 0xa, 0x5d, 0x67, 0x2f, 0x60, 0xf4}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops0}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 10212; + uint8_t client_id_bytes[] = {0x22, 0x7b, 0xb3, 0x3a, 0xb5}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x24, 0x19, 0xa5, 0xa0, 0x1a, 0x4a, 0x7, 0xac, 0x58, 0xed, 0x67, 0x32, + 0xd, 0xe9, 0x23, 0xc5, 0x48, 0xd1, 0x47, 0xa5, 0xab, 0xff, 0x7f}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x19, 0xbe, 0x7c, 0xa4, 0x82}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\166z\ENQ\171\210s\190J\237\153\219\210", _pubPktID = 15842, _pubBody = "\221-AF\157\205\a\153)\165QYh", _pubProps = -// []} -TEST(Publish311QCTest, Encode41) { - uint8_t pkt[] = {0x35, 0x1d, 0x0, 0xc, 0xa6, 0x7a, 0x5, 0xab, 0xd2, 0x73, 0xbe, 0x4a, 0xed, 0x99, 0xdb, 0xd2, - 0x3d, 0xe2, 0xdd, 0x2d, 0x41, 0x46, 0x9d, 0xcd, 0x7, 0x99, 0x29, 0xa5, 0x51, 0x59, 0x68}; +// ConnectRequest {_username = Just "\152\195~\228&V\199\194\ESC\206\154", _password = Just +// "ve\174\255\183:\192\165\&3\171\241\187+\DEL\209\"\248\224\186\154", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS1, _willTopic = "\162\193N\246G", _willMsg = "\193\226\183\237\166\202\233", _willProps = +// [PropServerReference "%P\DC3\242\SI \147\v\164\140:=\246\178$",PropReceiveMaximum +// 23397,PropWildcardSubscriptionAvailable 190,PropSessionExpiryInterval 31340,PropRetainAvailable +// 201,PropWildcardSubscriptionAvailable 101,PropAssignedClientIdentifier +// "\180\140\GS\EM\189\227\242v\200\CAN\201\152\243\144\141\158\&2\143\155t\206\&8{|"]}), _cleanSession = False, +// _keepAlive = 16879, _connID = "", _properties = [PropTopicAliasMaximum 26905,PropResponseTopic +// "\ETXr\195\163#\207C\193\194\249\&7\239\160\155\STX\138\182\141nl\138\224",PropAuthenticationMethod +// "v\200\207\&5\ACK%\203\225^\DLE\DC1?R\186\t\209i",PropPayloadFormatIndicator 12,PropMaximumQoS +// 27,PropAuthenticationData "\255r\171bm0q8>\ESCQ\128\193\243\236\198K\221\152",PropSessionExpiryInterval +// 18432,PropRetainAvailable 60,PropSharedSubscriptionAvailable 200,PropSubscriptionIdentifier 20,PropMaximumPacketSize +// 19861,PropMaximumQoS 189,PropServerKeepAlive 18916,PropResponseTopic +// "\153\189\238U\240f\201\251\130\RS\247\167\152.?\RSz\241\164g'[c\181!\140\&2\133",PropResponseInformation +// "W-=I\247(\235 8X\209\224\239o\196M\134\157\232\SYN\145\153\141ri\130PI\158a",PropSessionExpiryInterval +// 29328,PropUserProperty "" "\230",PropAuthenticationMethod +// "\\\253\\\152\SI\194\ESC\218\207\182l\ENQ\193.\248K",PropMaximumQoS 134,PropMaximumPacketSize +// 22187,PropRetainAvailable 16,PropMessageExpiryInterval 23463,PropRequestResponseInformation +// 242,PropResponseInformation "E\208\DC4\160\137\135\v3\197\181\130\GS\SYN\b8\ENQ\n",PropReceiveMaximum +// 14612,PropWildcardSubscriptionAvailable 72,PropReceiveMaximum 8504]} +TEST(Connect5QCTest, Encode8) { + uint8_t pkt[] = { + 0x10, 0xe6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x41, 0xef, 0xe9, 0x1, 0x22, 0x69, 0x19, 0x8, + 0x0, 0x16, 0x3, 0x72, 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56, 0xab, 0x25, 0x10, 0x2, 0x0, 0x0, 0x5b, 0xa7, 0x19, 0xf2, 0x1a, 0x0, 0x11, 0x45, 0xd0, 0x14, 0xa0, 0x89, + 0x87, 0xb, 0x33, 0xc5, 0xb5, 0x82, 0x1d, 0x16, 0x8, 0x38, 0x5, 0xa, 0x21, 0x39, 0x14, 0x28, 0x48, 0x21, 0x21, + 0x38, 0x0, 0x0, 0x3b, 0x1c, 0x0, 0xf, 0x25, 0x50, 0x13, 0xf2, 0xf, 0x20, 0x93, 0xb, 0xa4, 0x8c, 0x3a, 0x3d, + 0xf6, 0xb2, 0x24, 0x21, 0x5b, 0x65, 0x28, 0xbe, 0x11, 0x0, 0x0, 0x7a, 0x6c, 0x25, 0xc9, 0x28, 0x65, 0x12, 0x0, + 0x18, 0xb4, 0x8c, 0x1d, 0x19, 0xbd, 0xe3, 0xf2, 0x76, 0xc8, 0x18, 0xc9, 0x98, 0xf3, 0x90, 0x8d, 0x9e, 0x32, 0x8f, + 0x9b, 0x74, 0xce, 0x38, 0x7b, 0x7c, 0x0, 0x5, 0xa2, 0xc1, 0x4e, 0xf6, 0x47, 0x0, 0x7, 0xc1, 0xe2, 0xb7, 0xed, + 0xa6, 0xca, 0xe9, 0x0, 0xb, 0x98, 0xc3, 0x7e, 0xe4, 0x26, 0x56, 0xc7, 0xc2, 0x1b, 0xce, 0x9a, 0x0, 0x14, 0x76, + 0x65, 0xae, 0xff, 0xb7, 0x3a, 0xc0, 0xa5, 0x33, 0xab, 0xf1, 0xbb, 0x2b, 0x7f, 0xd1, 0x22, 0xf8, 0xe0, 0xba, 0x9a}; + + uint8_t buf[371] = {0}; + + uint8_t bytesprops0[] = {0x3, 0x72, 0xc3, 0xa3, 0x23, 0xcf, 0x43, 0xc1, 0xc2, 0xf9, 0x37, + 0xef, 0xa0, 0x9b, 0x2, 0x8a, 0xb6, 0x8d, 0x6e, 0x6c, 0x8a, 0xe0}; + uint8_t bytesprops1[] = {0x76, 0xc8, 0xcf, 0x35, 0x6, 0x25, 0xcb, 0xe1, 0x5e, + 0x10, 0x11, 0x3f, 0x52, 0xba, 0x9, 0xd1, 0x69}; + uint8_t bytesprops2[] = {0xff, 0x72, 0xab, 0x62, 0x6d, 0x30, 0x71, 0x38, 0x3e, 0x1b, + 0x51, 0x80, 0xc1, 0xf3, 0xec, 0xc6, 0x4b, 0xdd, 0x98}; + uint8_t bytesprops3[] = {0x99, 0xbd, 0xee, 0x55, 0xf0, 0x66, 0xc9, 0xfb, 0x82, 0x1e, 0xf7, 0xa7, 0x98, 0x2e, + 0x3f, 0x1e, 0x7a, 0xf1, 0xa4, 0x67, 0x27, 0x5b, 0x63, 0xb5, 0x21, 0x8c, 0x32, 0x85}; + uint8_t bytesprops4[] = {0x57, 0x2d, 0x3d, 0x49, 0xf7, 0x28, 0xeb, 0x20, 0x38, 0x58, 0xd1, 0xe0, 0xef, 0x6f, 0xc4, + 0x4d, 0x86, 0x9d, 0xe8, 0x16, 0x91, 0x99, 0x8d, 0x72, 0x69, 0x82, 0x50, 0x49, 0x9e, 0x61}; + uint8_t bytesprops6[] = {0xe6}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops7[] = {0x5c, 0xfd, 0x5c, 0x98, 0xf, 0xc2, 0x1b, 0xda, + 0xcf, 0xb6, 0x6c, 0x5, 0xc1, 0x2e, 0xf8, 0x4b}; + uint8_t bytesprops8[] = {0x45, 0xd0, 0x14, 0xa0, 0x89, 0x87, 0xb, 0x33, 0xc5, + 0xb5, 0x82, 0x1d, 0x16, 0x8, 0x38, 0x5, 0xa}; - uint8_t buf[41] = {0}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26905}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18432}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19861}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18916}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29328}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops5}, .v = {1, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22187}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23463}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14612}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8504}}, + }; - uint8_t topic_bytes[] = {0xa6, 0x7a, 0x5, 0xab, 0xd2, 0x73, 0xbe, 0x4a, 0xed, 0x99, 0xdb, 0xd2}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xdd, 0x2d, 0x41, 0x46, 0x9d, 0xcd, 0x7, 0x99, 0x29, 0xa5, 0x51, 0x59, 0x68}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x25, 0x50, 0x13, 0xf2, 0xf, 0x20, 0x93, 0xb, 0xa4, 0x8c, 0x3a, 0x3d, 0xf6, 0xb2, 0x24}; + uint8_t byteswillprops1[] = {0xb4, 0x8c, 0x1d, 0x19, 0xbd, 0xe3, 0xf2, 0x76, 0xc8, 0x18, 0xc9, 0x98, + 0xf3, 0x90, 0x8d, 0x9e, 0x32, 0x8f, 0x9b, 0x74, 0xce, 0x38, 0x7b, 0x7c}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23397}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31340}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops1}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa2, 0xc1, 0x4e, 0xf6, 0x47}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc1, 0xe2, 0xb7, 0xed, 0xa6, 0xca, 0xe9}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 16879; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x98, 0xc3, 0x7e, 0xe4, 0x26, 0x56, 0xc7, 0xc2, 0x1b, 0xce, 0x9a}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x76, 0x65, 0xae, 0xff, 0xb7, 0x3a, 0xc0, 0xa5, 0x33, 0xab, + 0xf1, 0xbb, 0x2b, 0x7f, 0xd1, 0x22, 0xf8, 0xe0, 0xba, 0x9a}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15842, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\206v6D\250\210o\GS\204\139H\184\vu\245\236z", _pubPktID = 6705, _pubBody = -// "\f\211\163\197\&3\254\185\161\DC2\198\aX\255", _pubProps = []} -TEST(Publish311QCTest, Encode42) { - uint8_t pkt[] = {0x3d, 0x22, 0x0, 0x11, 0xce, 0x76, 0x36, 0x44, 0xfa, 0xd2, 0x6f, 0x1d, - 0xcc, 0x8b, 0x48, 0xb8, 0xb, 0x75, 0xf5, 0xec, 0x7a, 0x1a, 0x31, 0xc, - 0xd3, 0xa3, 0xc5, 0x33, 0xfe, 0xb9, 0xa1, 0x12, 0xc6, 0x7, 0x58, 0xff}; +// ConnectRequest {_username = Just +// "\242\220\SUB\204\v-\136\211/\218\DC2\243\158]\190\165\251\150H\238\200\DC2\152\245U\202\NULf\153", _password = Just +// "\161\v@\t\155\233WB", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "\222v\195\252\243\159p\129\STX\218r\STX\ESCm\242\201\193\&6X\191h\206\233\210x\134d\170\f", _willMsg = +// "\DC2Bm\152\DLE\140\SO\236*\150\134\134m\195I\140\tMpG\v\199\138'\230\242\227\247m\202", _willProps = +// [PropReceiveMaximum 23059,PropWillDelayInterval 22019,PropContentType +// "\250\"\SI\252\ETX!s\bqK\197g2\204\142~M2\155F\NAK",PropWillDelayInterval 21909,PropRequestProblemInformation +// 21,PropAuthenticationData "\STX@R\EOT\150#m\SO\184\245B\196=O",PropMessageExpiryInterval 17248,PropCorrelationData +// "\195G\209x\242o\204pR%\152\243'\244\210MF\nd+U\183I",PropAuthenticationData +// "\221\214+\237\ETX\"\198\217\DC2\231\183\156\210\CANi\228:\137\EOT\233wn\208\ACK\207\ETX8,",PropWildcardSubscriptionAvailable +// 191,PropMaximumQoS 176,PropAuthenticationData +// "\186\210\159\\A\140\212)h\190\240\205dTF\190\\B\228\ETB\139\173\244\132\168\n(\143c",PropSubscriptionIdentifierAvailable +// 178,PropMessageExpiryInterval 30219,PropTopicAliasMaximum 938]}), _cleanSession = True, _keepAlive = 9102, _connID = +// "\234B\EOT\247\247W\194\222\nP\131)&?\226\&0X\209p\ESC\177z\201\SOt\131g(\215W", _properties = +// [PropPayloadFormatIndicator 87,PropContentType "\ETX\136\218.\199\146\ACK\"\154.a\247>VX",PropCorrelationData +// "\SOH\213\167\169\140\SOH\ESC\209\191\199g\174D\197\252\183o\SUB\143\227Nn\r!b\182",PropTopicAliasMaximum +// 4141,PropSubscriptionIdentifier 2,PropMaximumQoS 103,PropMaximumPacketSize 26526,PropSharedSubscriptionAvailable +// 64,PropTopicAlias 530,PropAssignedClientIdentifier "\NUL\218g\RS",PropSubscriptionIdentifierAvailable +// 120,PropSessionExpiryInterval 18660,PropAuthenticationData +// "4\208\STX\247Z\226w\182\132",PropSubscriptionIdentifierAvailable 190,PropSessionExpiryInterval +// 8586,PropResponseTopic +// "\183\&4\169K*U\SO{\155\181.\137\215j\154\\\203\179\252\&042g\SUB\f\a\153",PropMaximumPacketSize +// 364,PropRetainAvailable 110,PropResponseTopic "\230\ENQyA\t\128\221+",PropAuthenticationData +// "kRr\164\251\193\203\251c\244{P\ENQ\182\238\206~\179\238\US\159",PropCorrelationData +// "\207\222\198\DC2\163r\129&\145\244\197]\156\192\215!",PropRetainAvailable 87,PropReasonString "o +// \US0\204\136~\188\vl1\a\237",PropAuthenticationData +// "\249\SO\189\DC1Z\DELL\235\161\191\220|\222/\219kL\156n+\CAN\230\162l\231^s\207",PropCorrelationData +// "\246Tp\163&O\201\224TS\151\SUBU/P\227\ETB\152\234\255.5\148\235\&1\138\220\156\172\154",PropServerReference +// "\152\153q2X\ENQ\200\218\221X\217}\212\246\227\&0<@\217\SI\142",PropResponseInformation +// "d6\219d1\159\DC3\202GyEn",PropRequestProblemInformation 234,PropUserProperty "\213]&\138\232ID\159\238o\178#k%P\151" +// "%\132\DC2y\142\216\171%\248~\252\165~\r\171\RSp\229\192-\225\236\SYN&X\US"]} +TEST(Connect5QCTest, Encode9) { + uint8_t pkt[] = { + 0x10, 0xa2, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x23, 0x8e, 0xe8, 0x2, 0x1, 0x57, 0x3, 0x0, + 0xf, 0x3, 0x88, 0xda, 0x2e, 0xc7, 0x92, 0x6, 0x22, 0x9a, 0x2e, 0x61, 0xf7, 0x3e, 0x56, 0x58, 0x9, 0x0, 0x1a, + 0x1, 0xd5, 0xa7, 0xa9, 0x8c, 0x1, 0x1b, 0xd1, 0xbf, 0xc7, 0x67, 0xae, 0x44, 0xc5, 0xfc, 0xb7, 0x6f, 0x1a, 0x8f, + 0xe3, 0x4e, 0x6e, 0xd, 0x21, 0x62, 0xb6, 0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x47, 0xb, + 0xc7, 0x8a, 0x27, 0xe6, 0xf2, 0xe3, 0xf7, 0x6d, 0xca, 0x0, 0x1d, 0xf2, 0xdc, 0x1a, 0xcc, 0xb, 0x2d, 0x88, 0xd3, + 0x2f, 0xda, 0x12, 0xf3, 0x9e, 0x5d, 0xbe, 0xa5, 0xfb, 0x96, 0x48, 0xee, 0xc8, 0x12, 0x98, 0xf5, 0x55, 0xca, 0x0, + 0x66, 0x99, 0x0, 0x8, 0xa1, 0xb, 0x40, 0x9, 0x9b, 0xe9, 0x57, 0x42}; + + uint8_t buf[687] = {0}; + + uint8_t bytesprops0[] = {0x3, 0x88, 0xda, 0x2e, 0xc7, 0x92, 0x6, 0x22, 0x9a, 0x2e, 0x61, 0xf7, 0x3e, 0x56, 0x58}; + uint8_t bytesprops1[] = {0x1, 0xd5, 0xa7, 0xa9, 0x8c, 0x1, 0x1b, 0xd1, 0xbf, 0xc7, 0x67, 0xae, 0x44, + 0xc5, 0xfc, 0xb7, 0x6f, 0x1a, 0x8f, 0xe3, 0x4e, 0x6e, 0xd, 0x21, 0x62, 0xb6}; + uint8_t bytesprops2[] = {0x0, 0xda, 0x67, 0x1e}; + uint8_t bytesprops3[] = {0x34, 0xd0, 0x2, 0xf7, 0x5a, 0xe2, 0x77, 0xb6, 0x84}; + uint8_t bytesprops4[] = {0xb7, 0x34, 0xa9, 0x4b, 0x2a, 0x55, 0xe, 0x7b, 0x9b, 0xb5, 0x2e, 0x89, 0xd7, 0x6a, + 0x9a, 0x5c, 0xcb, 0xb3, 0xfc, 0x30, 0x34, 0x32, 0x67, 0x1a, 0xc, 0x7, 0x99}; + uint8_t bytesprops5[] = {0xe6, 0x5, 0x79, 0x41, 0x9, 0x80, 0xdd, 0x2b}; + uint8_t bytesprops6[] = {0x6b, 0x52, 0x72, 0xa4, 0xfb, 0xc1, 0xcb, 0xfb, 0x63, 0xf4, 0x7b, + 0x50, 0x5, 0xb6, 0xee, 0xce, 0x7e, 0xb3, 0xee, 0x1f, 0x9f}; + uint8_t bytesprops7[] = {0xcf, 0xde, 0xc6, 0x12, 0xa3, 0x72, 0x81, 0x26, + 0x91, 0xf4, 0xc5, 0x5d, 0x9c, 0xc0, 0xd7, 0x21}; + uint8_t bytesprops8[] = {0x6f, 0x20, 0x1f, 0x30, 0xcc, 0x88, 0x7e, 0xbc, 0xb, 0x6c, 0x31, 0x7, 0xed}; + uint8_t bytesprops9[] = {0xf9, 0xe, 0xbd, 0x11, 0x5a, 0x7f, 0x4c, 0xeb, 0xa1, 0xbf, 0xdc, 0x7c, 0xde, 0x2f, + 0xdb, 0x6b, 0x4c, 0x9c, 0x6e, 0x2b, 0x18, 0xe6, 0xa2, 0x6c, 0xe7, 0x5e, 0x73, 0xcf}; + uint8_t bytesprops10[] = {0xf6, 0x54, 0x70, 0xa3, 0x26, 0x4f, 0xc9, 0xe0, 0x54, 0x53, 0x97, 0x1a, 0x55, 0x2f, 0x50, + 0xe3, 0x17, 0x98, 0xea, 0xff, 0x2e, 0x35, 0x94, 0xeb, 0x31, 0x8a, 0xdc, 0x9c, 0xac, 0x9a}; + uint8_t bytesprops11[] = {0x98, 0x99, 0x71, 0x32, 0x58, 0x5, 0xc8, 0xda, 0xdd, 0x58, 0xd9, + 0x7d, 0xd4, 0xf6, 0xe3, 0x30, 0x3c, 0x40, 0xd9, 0xf, 0x8e}; + uint8_t bytesprops12[] = {0x64, 0x36, 0xdb, 0x64, 0x31, 0x9f, 0x13, 0xca, 0x47, 0x79, 0x45, 0x6e}; + uint8_t bytesprops14[] = {0x25, 0x84, 0x12, 0x79, 0x8e, 0xd8, 0xab, 0x25, 0xf8, 0x7e, 0xfc, 0xa5, 0x7e, + 0xd, 0xab, 0x1e, 0x70, 0xe5, 0xc0, 0x2d, 0xe1, 0xec, 0x16, 0x26, 0x58, 0x1f}; + uint8_t bytesprops13[] = {0xd5, 0x5d, 0x26, 0x8a, 0xe8, 0x49, 0x44, 0x9f, + 0xee, 0x6f, 0xb2, 0x23, 0x6b, 0x25, 0x50, 0x97}; - uint8_t buf[46] = {0}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4141}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26526}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 530}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18660}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8586}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 364}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {16, (char*)&bytesprops13}, .v = {26, (char*)&bytesprops14}}}}, + }; - uint8_t topic_bytes[] = {0xce, 0x76, 0x36, 0x44, 0xfa, 0xd2, 0x6f, 0x1d, 0xcc, - 0x8b, 0x48, 0xb8, 0xb, 0x75, 0xf5, 0xec, 0x7a}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xc, 0xd3, 0xa3, 0xc5, 0x33, 0xfe, 0xb9, 0xa1, 0x12, 0xc6, 0x7, 0x58, 0xff}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xfa, 0x22, 0xf, 0xfc, 0x3, 0x21, 0x73, 0x8, 0x71, 0x4b, 0xc5, + 0x67, 0x32, 0xcc, 0x8e, 0x7e, 0x4d, 0x32, 0x9b, 0x46, 0x15}; + uint8_t byteswillprops1[] = {0x2, 0x40, 0x52, 0x4, 0x96, 0x23, 0x6d, 0xe, 0xb8, 0xf5, 0x42, 0xc4, 0x3d, 0x4f}; + uint8_t byteswillprops2[] = {0xc3, 0x47, 0xd1, 0x78, 0xf2, 0x6f, 0xcc, 0x70, 0x52, 0x25, 0x98, 0xf3, + 0x27, 0xf4, 0xd2, 0x4d, 0x46, 0xa, 0x64, 0x2b, 0x55, 0xb7, 0x49}; + uint8_t byteswillprops3[] = {0xdd, 0xd6, 0x2b, 0xed, 0x3, 0x22, 0xc6, 0xd9, 0x12, 0xe7, 0xb7, 0x9c, 0xd2, 0x18, + 0x69, 0xe4, 0x3a, 0x89, 0x4, 0xe9, 0x77, 0x6e, 0xd0, 0x6, 0xcf, 0x3, 0x38, 0x2c}; + uint8_t byteswillprops4[] = {0xba, 0xd2, 0x9f, 0x5c, 0x41, 0x8c, 0xd4, 0x29, 0x68, 0xbe, 0xf0, 0xcd, 0x64, 0x54, 0x46, + 0xbe, 0x5c, 0x42, 0xe4, 0x17, 0x8b, 0xad, 0xf4, 0x84, 0xa8, 0xa, 0x28, 0x8f, 0x63}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23059}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22019}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21909}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17248}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30219}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 938}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xde, 0x76, 0xc3, 0xfc, 0xf3, 0x9f, 0x70, 0x81, 0x2, 0xda, + 0x72, 0x2, 0x1b, 0x6d, 0xf2, 0xc9, 0xc1, 0x36, 0x58, 0xbf, + 0x68, 0xce, 0xe9, 0xd2, 0x78, 0x86, 0x64, 0xaa, 0xc}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x12, 0x42, 0x6d, 0x98, 0x10, 0x8c, 0xe, 0xec, 0x2a, 0x96, + 0x86, 0x86, 0x6d, 0xc3, 0x49, 0x8c, 0x9, 0x4d, 0x70, 0x47, + 0xb, 0xc7, 0x8a, 0x27, 0xe6, 0xf2, 0xe3, 0xf7, 0x6d, 0xca}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 9102; + uint8_t client_id_bytes[] = {0xea, 0x42, 0x4, 0xf7, 0xf7, 0x57, 0xc2, 0xde, 0xa, 0x50, 0x83, 0x29, 0x26, 0x3f, 0xe2, + 0x30, 0x58, 0xd1, 0x70, 0x1b, 0xb1, 0x7a, 0xc9, 0xe, 0x74, 0x83, 0x67, 0x28, 0xd7, 0x57}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xf2, 0xdc, 0x1a, 0xcc, 0xb, 0x2d, 0x88, 0xd3, 0x2f, 0xda, 0x12, 0xf3, 0x9e, 0x5d, 0xbe, + 0xa5, 0xfb, 0x96, 0x48, 0xee, 0xc8, 0x12, 0x98, 0xf5, 0x55, 0xca, 0x0, 0x66, 0x99}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xa1, 0xb, 0x40, 0x9, 0x9b, 0xe9, 0x57, 0x42}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6705, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\146n\207\252s\SOHt\253N\US(M?\NAK&\NAKR\139\193\&4\SOH\152\179\v", _pubPktID = 0, _pubBody = -// "\139b\185\b\186\&5\RS\EOT\166\STXV\149\135/\DEL$\167\144u", _pubProps = []} -TEST(Publish311QCTest, Encode43) { - uint8_t pkt[] = {0x31, 0x2d, 0x0, 0x18, 0x92, 0x6e, 0xcf, 0xfc, 0x73, 0x1, 0x74, 0xfd, 0x4e, 0x1f, 0x28, 0x4d, - 0x3f, 0x15, 0x26, 0x15, 0x52, 0x8b, 0xc1, 0x34, 0x1, 0x98, 0xb3, 0xb, 0x8b, 0x62, 0xb9, 0x8, - 0xba, 0x35, 0x1e, 0x4, 0xa6, 0x2, 0x56, 0x95, 0x87, 0x2f, 0x7f, 0x24, 0xa7, 0x90, 0x75}; +// ConnectRequest {_username = Just "\174\237\224:\154\243X\224`\199", _password = Just +// "%\185W1f}\195\140\153\169\181\238\243\236\EM,V\216\ESC\151\168", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "\162\219\EM\161\228\128\255m", _willMsg = "", _willProps = [PropAuthenticationData +// "",PropUserProperty "\241\182\DELW\185\FSV\203\254!\191e\184\173v" +// "5\186\170\159J\173\138LGd\DC2",PropSubscriptionIdentifier 30,PropAuthenticationData +// "\DC4\203\EOT\t\137/l\252\129(\211\187\225",PropTopicAliasMaximum 31859,PropMaximumPacketSize 5092,PropResponseTopic +// "",PropRequestResponseInformation 63,PropWildcardSubscriptionAvailable 50,PropSessionExpiryInterval +// 28357,PropSubscriptionIdentifierAvailable 244,PropTopicAliasMaximum 4424,PropAuthenticationMethod +// ",\DC3\161\192\DLE\137\&7",PropSharedSubscriptionAvailable 33,PropCorrelationData +// "\234+\178+\DLE?o\137\164\210\145\238<\193Ci\148\233\b\251\FS\DLE\217\145\238\164",PropMaximumPacketSize +// 21984,PropSubscriptionIdentifierAvailable 55,PropAuthenticationData "US\224/\189"]}), _cleanSession = True, +// _keepAlive = 17212, _connID = "\203o\140\199r\n\144n\FS\211\223\147\152?\GS\152/\v\245r\"\250", _properties = +// [PropAuthenticationMethod "\188\249MP\236w3\210\146\"\141m\208E\204\148",PropReasonString +// "\178\&1\131\&3=h\198\GS'\231\140\148\253\194\169a\134#P(\249\196\b\174\174/\214\"\149",PropTopicAlias +// 29058,PropSubscriptionIdentifier 10,PropWildcardSubscriptionAvailable 243]} +TEST(Connect5QCTest, Encode10) { + uint8_t pkt[] = { + 0x10, 0x93, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x43, 0x3c, 0x3a, 0x15, 0x0, 0x10, 0xbc, 0xf9, + 0x4d, 0x50, 0xec, 0x77, 0x33, 0xd2, 0x92, 0x22, 0x8d, 0x6d, 0xd0, 0x45, 0xcc, 0x94, 0x1f, 0x0, 0x1d, 0xb2, 0x31, + 0x83, 0x33, 0x3d, 0x68, 0xc6, 0x1d, 0x27, 0xe7, 0x8c, 0x94, 0xfd, 0xc2, 0xa9, 0x61, 0x86, 0x23, 0x50, 0x28, 0xf9, + 0xc4, 0x8, 0xae, 0xae, 0x2f, 0xd6, 0x22, 0x95, 0x23, 0x71, 0x82, 0xb, 0xa, 0x28, 0xf3, 0x0, 0x16, 0xcb, 0x6f, + 0x8c, 0xc7, 0x72, 0xa, 0x90, 0x6e, 0x1c, 0xd3, 0xdf, 0x93, 0x98, 0x3f, 0x1d, 0x98, 0x2f, 0xb, 0xf5, 0x72, 0x22, + 0xfa, 0x85, 0x1, 0x16, 0x0, 0x0, 0x26, 0x0, 0xf, 0xf1, 0xb6, 0x7f, 0x57, 0xb9, 0x1c, 0x56, 0xcb, 0xfe, 0x21, + 0xbf, 0x65, 0xb8, 0xad, 0x76, 0x0, 0xb, 0x35, 0xba, 0xaa, 0x9f, 0x4a, 0xad, 0x8a, 0x4c, 0x47, 0x64, 0x12, 0xb, + 0x1e, 0x16, 0x0, 0xd, 0x14, 0xcb, 0x4, 0x9, 0x89, 0x2f, 0x6c, 0xfc, 0x81, 0x28, 0xd3, 0xbb, 0xe1, 0x22, 0x7c, + 0x73, 0x27, 0x0, 0x0, 0x13, 0xe4, 0x8, 0x0, 0x0, 0x19, 0x3f, 0x28, 0x32, 0x11, 0x0, 0x0, 0x6e, 0xc5, 0x29, + 0xf4, 0x22, 0x11, 0x48, 0x15, 0x0, 0x7, 0x2c, 0x13, 0xa1, 0xc0, 0x10, 0x89, 0x37, 0x2a, 0x21, 0x9, 0x0, 0x1a, + 0xea, 0x2b, 0xb2, 0x2b, 0x10, 0x3f, 0x6f, 0x89, 0xa4, 0xd2, 0x91, 0xee, 0x3c, 0xc1, 0x43, 0x69, 0x94, 0xe9, 0x8, + 0xfb, 0x1c, 0x10, 0xd9, 0x91, 0xee, 0xa4, 0x27, 0x0, 0x0, 0x55, 0xe0, 0x29, 0x37, 0x16, 0x0, 0x5, 0x55, 0x53, + 0xe0, 0x2f, 0xbd, 0x0, 0x8, 0xa2, 0xdb, 0x19, 0xa1, 0xe4, 0x80, 0xff, 0x6d, 0x0, 0x0, 0x0, 0xa, 0xae, 0xed, + 0xe0, 0x3a, 0x9a, 0xf3, 0x58, 0xe0, 0x60, 0xc7, 0x0, 0x15, 0x25, 0xb9, 0x57, 0x31, 0x66, 0x7d, 0xc3, 0x8c, 0x99, + 0xa9, 0xb5, 0xee, 0xf3, 0xec, 0x19, 0x2c, 0x56, 0xd8, 0x1b, 0x97, 0xa8}; - uint8_t buf[57] = {0}; + uint8_t buf[288] = {0}; - uint8_t topic_bytes[] = {0x92, 0x6e, 0xcf, 0xfc, 0x73, 0x1, 0x74, 0xfd, 0x4e, 0x1f, 0x28, 0x4d, - 0x3f, 0x15, 0x26, 0x15, 0x52, 0x8b, 0xc1, 0x34, 0x1, 0x98, 0xb3, 0xb}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x8b, 0x62, 0xb9, 0x8, 0xba, 0x35, 0x1e, 0x4, 0xa6, 0x2, - 0x56, 0x95, 0x87, 0x2f, 0x7f, 0x24, 0xa7, 0x90, 0x75}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + uint8_t bytesprops0[] = {0xbc, 0xf9, 0x4d, 0x50, 0xec, 0x77, 0x33, 0xd2, + 0x92, 0x22, 0x8d, 0x6d, 0xd0, 0x45, 0xcc, 0x94}; + uint8_t bytesprops1[] = {0xb2, 0x31, 0x83, 0x33, 0x3d, 0x68, 0xc6, 0x1d, 0x27, 0xe7, 0x8c, 0x94, 0xfd, 0xc2, 0xa9, + 0x61, 0x86, 0x23, 0x50, 0x28, 0xf9, 0xc4, 0x8, 0xae, 0xae, 0x2f, 0xd6, 0x22, 0x95}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29058}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 243}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops2[] = {0x35, 0xba, 0xaa, 0x9f, 0x4a, 0xad, 0x8a, 0x4c, 0x47, 0x64, 0x12}; + uint8_t byteswillprops1[] = {0xf1, 0xb6, 0x7f, 0x57, 0xb9, 0x1c, 0x56, 0xcb, + 0xfe, 0x21, 0xbf, 0x65, 0xb8, 0xad, 0x76}; + uint8_t byteswillprops3[] = {0x14, 0xcb, 0x4, 0x9, 0x89, 0x2f, 0x6c, 0xfc, 0x81, 0x28, 0xd3, 0xbb, 0xe1}; + uint8_t byteswillprops4[] = {0}; + uint8_t byteswillprops5[] = {0x2c, 0x13, 0xa1, 0xc0, 0x10, 0x89, 0x37}; + uint8_t byteswillprops6[] = {0xea, 0x2b, 0xb2, 0x2b, 0x10, 0x3f, 0x6f, 0x89, 0xa4, 0xd2, 0x91, 0xee, 0x3c, + 0xc1, 0x43, 0x69, 0x94, 0xe9, 0x8, 0xfb, 0x1c, 0x10, 0xd9, 0x91, 0xee, 0xa4}; + uint8_t byteswillprops7[] = {0x55, 0x53, 0xe0, 0x2f, 0xbd}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {15, (char*)&byteswillprops1}, .v = {11, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31859}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5092}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28357}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4424}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21984}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&byteswillprops7}}}, + }; + + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa2, 0xdb, 0x19, 0xa1, 0xe4, 0x80, 0xff, 0x6d}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 17212; + uint8_t client_id_bytes[] = {0xcb, 0x6f, 0x8c, 0xc7, 0x72, 0xa, 0x90, 0x6e, 0x1c, 0xd3, 0xdf, + 0x93, 0x98, 0x3f, 0x1d, 0x98, 0x2f, 0xb, 0xf5, 0x72, 0x22, 0xfa}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xae, 0xed, 0xe0, 0x3a, 0x9a, 0xf3, 0x58, 0xe0, 0x60, 0xc7}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x25, 0xb9, 0x57, 0x31, 0x66, 0x7d, 0xc3, 0x8c, 0x99, 0xa9, 0xb5, + 0xee, 0xf3, 0xec, 0x19, 0x2c, 0x56, 0xd8, 0x1b, 0x97, 0xa8}; + lwmqtt_string_t password = {21, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\168\205\235\&9L\b\236\187\184{\199\135G\165c\200\144\SO\NUL\234u\SYN\142O\177N:\161\&8", _pubPktID = 0, _pubBody = -// "Z \DEL\193\197\&7K\147\137\199b]\243}\248\161\248.Y\218bb\132\156\GS\DC2>\224", _pubProps = []} -TEST(Publish311QCTest, Encode44) { - uint8_t pkt[] = {0x31, 0x3b, 0x0, 0x1d, 0xa8, 0xcd, 0xeb, 0x39, 0x4c, 0x8, 0xec, 0xbb, 0xb8, 0x7b, 0xc7, 0x87, - 0x47, 0xa5, 0x63, 0xc8, 0x90, 0xe, 0x0, 0xea, 0x75, 0x16, 0x8e, 0x4f, 0xb1, 0x4e, 0x3a, 0xa1, - 0x38, 0x5a, 0x20, 0x7f, 0xc1, 0xc5, 0x37, 0x4b, 0x93, 0x89, 0xc7, 0x62, 0x5d, 0xf3, 0x7d, 0xf8, - 0xa1, 0xf8, 0x2e, 0x59, 0xda, 0x62, 0x62, 0x84, 0x9c, 0x1d, 0x12, 0x3e, 0xe0}; +// SubscribeRequest 31688 [("\134Q\r\137U\191\DEL\166>c<~\234\229\251\206\249tYv\161\\\154OeS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\220\254\200+\222G\NUL\254\179r\136{N\185N\151rL\147\ETX\251\145p\202\177\129\244\220",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),(";\154\220$\161c\EM\CAN\187~\EM\131+\SYN\242\172q\CAN(\214",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\199G9%\137ER:\132\252\SUB\145)\DC1\238\243q\SI",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\151\228-h2E\145\155\RS[\a\180\192{W\249\DC2k\241\246&L\189\146\SI\227P\233(",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\188\128\150\245A\241\232\247\246K\242\221E\146@\166n\144\178VMY",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("]!b\157\132\190\207K\CAN\240\196\ENQ\CAN\224\246\SOR9CcF\242\206\r\248\GSj",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode1) { + uint8_t pkt[] = { + 0x82, 0xce, 0x1, 0x7b, 0xc8, 0x0, 0x1a, 0x86, 0x51, 0xd, 0x89, 0x55, 0xbf, 0x7f, 0xa6, 0x3e, 0x63, 0x3c, 0x7e, + 0xea, 0xe5, 0xfb, 0xce, 0xf9, 0x74, 0x59, 0x76, 0xa1, 0x5c, 0x9a, 0x4f, 0x65, 0x53, 0x0, 0x0, 0x1c, 0xdc, 0xfe, + 0xc8, 0x2b, 0xde, 0x47, 0x0, 0xfe, 0xb3, 0x72, 0x88, 0x7b, 0x4e, 0xb9, 0x4e, 0x97, 0x72, 0x4c, 0x93, 0x3, 0xfb, + 0x91, 0x70, 0xca, 0xb1, 0x81, 0xf4, 0xdc, 0x1, 0x0, 0x14, 0x3b, 0x9a, 0xdc, 0x24, 0xa1, 0x63, 0x19, 0x18, 0xbb, + 0x7e, 0x19, 0x83, 0x2b, 0x16, 0xf2, 0xac, 0x71, 0x18, 0x28, 0xd6, 0x1, 0x0, 0x12, 0xc7, 0x47, 0x39, 0x25, 0x89, + 0x45, 0x52, 0x3a, 0x84, 0xfc, 0x1a, 0x91, 0x29, 0x11, 0xee, 0xf3, 0x71, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, + 0x6b, 0x1, 0x0, 0x1d, 0x97, 0xe4, 0x2d, 0x68, 0x32, 0x45, 0x91, 0x9b, 0x1e, 0x5b, 0x7, 0xb4, 0xc0, 0x7b, 0x57, + 0xf9, 0x12, 0x6b, 0xf1, 0xf6, 0x26, 0x4c, 0xbd, 0x92, 0xf, 0xe3, 0x50, 0xe9, 0x28, 0x1, 0x0, 0x0, 0x1, 0x0, + 0x0, 0x2, 0x0, 0x16, 0xbc, 0x80, 0x96, 0xf5, 0x41, 0xf1, 0xe8, 0xf7, 0xf6, 0x4b, 0xf2, 0xdd, 0x45, 0x92, 0x40, + 0xa6, 0x6e, 0x90, 0xb2, 0x56, 0x4d, 0x59, 0x1, 0x0, 0x1b, 0x5d, 0x21, 0x62, 0x9d, 0x84, 0xbe, 0xcf, 0x4b, 0x18, + 0xf0, 0xc4, 0x5, 0x18, 0xe0, 0xf6, 0xe, 0x52, 0x39, 0x43, 0x63, 0x46, 0xf2, 0xce, 0xd, 0xf8, 0x1d, 0x6a, 0x2}; - uint8_t buf[71] = {0}; + uint8_t buf[219] = {0}; - uint8_t topic_bytes[] = {0xa8, 0xcd, 0xeb, 0x39, 0x4c, 0x8, 0xec, 0xbb, 0xb8, 0x7b, 0xc7, 0x87, 0x47, 0xa5, 0x63, - 0xc8, 0x90, 0xe, 0x0, 0xea, 0x75, 0x16, 0x8e, 0x4f, 0xb1, 0x4e, 0x3a, 0xa1, 0x38}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x5a, 0x20, 0x7f, 0xc1, 0xc5, 0x37, 0x4b, 0x93, 0x89, 0xc7, 0x62, 0x5d, 0xf3, 0x7d, - 0xf8, 0xa1, 0xf8, 0x2e, 0x59, 0xda, 0x62, 0x62, 0x84, 0x9c, 0x1d, 0x12, 0x3e, 0xe0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x86, 0x51, 0xd, 0x89, 0x55, 0xbf, 0x7f, 0xa6, 0x3e, 0x63, 0x3c, 0x7e, 0xea, + 0xe5, 0xfb, 0xce, 0xf9, 0x74, 0x59, 0x76, 0xa1, 0x5c, 0x9a, 0x4f, 0x65, 0x53}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xdc, 0xfe, 0xc8, 0x2b, 0xde, 0x47, 0x0, 0xfe, 0xb3, 0x72, + 0x88, 0x7b, 0x4e, 0xb9, 0x4e, 0x97, 0x72, 0x4c, 0x93, 0x3, + 0xfb, 0x91, 0x70, 0xca, 0xb1, 0x81, 0xf4, 0xdc}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x3b, 0x9a, 0xdc, 0x24, 0xa1, 0x63, 0x19, 0x18, 0xbb, 0x7e, + 0x19, 0x83, 0x2b, 0x16, 0xf2, 0xac, 0x71, 0x18, 0x28, 0xd6}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc7, 0x47, 0x39, 0x25, 0x89, 0x45, 0x52, 0x3a, 0x84, + 0xfc, 0x1a, 0x91, 0x29, 0x11, 0xee, 0xf3, 0x71, 0xf}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6b}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x97, 0xe4, 0x2d, 0x68, 0x32, 0x45, 0x91, 0x9b, 0x1e, 0x5b, + 0x7, 0xb4, 0xc0, 0x7b, 0x57, 0xf9, 0x12, 0x6b, 0xf1, 0xf6, + 0x26, 0x4c, 0xbd, 0x92, 0xf, 0xe3, 0x50, 0xe9, 0x28}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0}; + lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xbc, 0x80, 0x96, 0xf5, 0x41, 0xf1, 0xe8, 0xf7, 0xf6, 0x4b, 0xf2, + 0xdd, 0x45, 0x92, 0x40, 0xa6, 0x6e, 0x90, 0xb2, 0x56, 0x4d, 0x59}; + lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x5d, 0x21, 0x62, 0x9d, 0x84, 0xbe, 0xcf, 0x4b, 0x18, + 0xf0, 0xc4, 0x5, 0x18, 0xe0, 0xf6, 0xe, 0x52, 0x39, + 0x43, 0x63, 0x46, 0xf2, 0xce, 0xd, 0xf8, 0x1d, 0x6a}; + lwmqtt_string_t topic_filter_s10 = {27, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31688, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\165r\DEL\n\202\133kb\136", -// _pubPktID = 7921, _pubBody = "O\248\206?\215\168\&4\DC1\131\187<1\176\200\EOTW \FSu\ETB3\128\222N\241\193\180", -// _pubProps = []} -TEST(Publish311QCTest, Encode45) { - uint8_t pkt[] = {0x3c, 0x28, 0x0, 0x9, 0xa5, 0x72, 0x7f, 0xa, 0xca, 0x85, 0x6b, 0x62, 0x88, 0x1e, - 0xf1, 0x4f, 0xf8, 0xce, 0x3f, 0xd7, 0xa8, 0x34, 0x11, 0x83, 0xbb, 0x3c, 0x31, 0xb0, - 0xc8, 0x4, 0x57, 0x20, 0x1c, 0x75, 0x17, 0x33, 0x80, 0xde, 0x4e, 0xf1, 0xc1, 0xb4}; +// SubscribeRequest 25984 +// [("1\GS\194\RS\CAND\173\140\252\160\207\178\215*q\172o\165\DC3\n\250\129\USa\128\ETB\183\171",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\175\195N\144p\188x@x\190\233.LbP!\f{\DLEez\153\bs\DC3",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\246\&9\f\n\v\143znf!\192pb2",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Vw\169\NUL\222V\237}\DLE\240t\249",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode2) { + uint8_t pkt[] = {0x82, 0x5d, 0x65, 0x80, 0x0, 0x1c, 0x31, 0x1d, 0xc2, 0x1e, 0x18, 0x44, 0xad, 0x8c, 0xfc, 0xa0, + 0xcf, 0xb2, 0xd7, 0x2a, 0x71, 0xac, 0x6f, 0xa5, 0x13, 0xa, 0xfa, 0x81, 0x1f, 0x61, 0x80, 0x17, + 0xb7, 0xab, 0x1, 0x0, 0x19, 0xaf, 0xc3, 0x4e, 0x90, 0x70, 0xbc, 0x78, 0x40, 0x78, 0xbe, 0xe9, + 0x2e, 0x4c, 0x62, 0x50, 0x21, 0xc, 0x7b, 0x10, 0x65, 0x7a, 0x99, 0x8, 0x73, 0x13, 0x2, 0x0, + 0xe, 0xf6, 0x39, 0xc, 0xa, 0xb, 0x8f, 0x7a, 0x6e, 0x66, 0x21, 0xc0, 0x70, 0x62, 0x32, 0x2, + 0x0, 0xc, 0x56, 0x77, 0xa9, 0x0, 0xde, 0x56, 0xed, 0x7d, 0x10, 0xf0, 0x74, 0xf9, 0x1}; - uint8_t buf[52] = {0}; + uint8_t buf[105] = {0}; - uint8_t topic_bytes[] = {0xa5, 0x72, 0x7f, 0xa, 0xca, 0x85, 0x6b, 0x62, 0x88}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x4f, 0xf8, 0xce, 0x3f, 0xd7, 0xa8, 0x34, 0x11, 0x83, 0xbb, 0x3c, 0x31, 0xb0, 0xc8, - 0x4, 0x57, 0x20, 0x1c, 0x75, 0x17, 0x33, 0x80, 0xde, 0x4e, 0xf1, 0xc1, 0xb4}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x31, 0x1d, 0xc2, 0x1e, 0x18, 0x44, 0xad, 0x8c, 0xfc, 0xa0, + 0xcf, 0xb2, 0xd7, 0x2a, 0x71, 0xac, 0x6f, 0xa5, 0x13, 0xa, + 0xfa, 0x81, 0x1f, 0x61, 0x80, 0x17, 0xb7, 0xab}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xaf, 0xc3, 0x4e, 0x90, 0x70, 0xbc, 0x78, 0x40, 0x78, 0xbe, 0xe9, 0x2e, 0x4c, + 0x62, 0x50, 0x21, 0xc, 0x7b, 0x10, 0x65, 0x7a, 0x99, 0x8, 0x73, 0x13}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf6, 0x39, 0xc, 0xa, 0xb, 0x8f, 0x7a, 0x6e, 0x66, 0x21, 0xc0, 0x70, 0x62, 0x32}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x56, 0x77, 0xa9, 0x0, 0xde, 0x56, 0xed, 0x7d, 0x10, 0xf0, 0x74, 0xf9}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25984, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 15464 +// [("\SOC\155\217\ESC\vJ\139\SOW\183\RS]\STX&\SUB\184\NUL\242J\186\165\165\204\&5\160\209\156\&9",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\248\143P2v\177\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("n\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2}),("X\159\CAN\143\245\n\206y\DC4\135\DC4i\232`",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\DLEA\227\&5x\234\US\171",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\164\177\152\ETBhD\152\251\180\"\244\239\191\241\149\227}\183\&0",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\r@\174C\FSM$\180\212'\253\157\173\SOI9\204b",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("C\226\169\230)",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\145Tu\NUL\b\ESC\227",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode3) { + uint8_t pkt[] = {0x82, 0x8a, 0x1, 0x3c, 0x68, 0x0, 0x1d, 0xe, 0x43, 0x9b, 0xd9, 0x1b, 0xb, 0x4a, 0x8b, 0xe, + 0x57, 0xb7, 0x1e, 0x5d, 0x2, 0x26, 0x1a, 0xb8, 0x0, 0xf2, 0x4a, 0xba, 0xa5, 0xa5, 0xcc, 0x35, + 0xa0, 0xd1, 0x9c, 0x39, 0x0, 0x0, 0x7, 0xf8, 0x8f, 0x50, 0x32, 0x76, 0xb1, 0x32, 0x2, 0x0, + 0x2, 0x6e, 0xd2, 0x2, 0x0, 0xe, 0x58, 0x9f, 0x18, 0x8f, 0xf5, 0xa, 0xce, 0x79, 0x14, 0x87, + 0x14, 0x69, 0xe8, 0x60, 0x2, 0x0, 0x8, 0x10, 0x41, 0xe3, 0x35, 0x78, 0xea, 0x1f, 0xab, 0x0, + 0x0, 0x13, 0xa4, 0xb1, 0x98, 0x17, 0x68, 0x44, 0x98, 0xfb, 0xb4, 0x22, 0xf4, 0xef, 0xbf, 0xf1, + 0x95, 0xe3, 0x7d, 0xb7, 0x30, 0x0, 0x0, 0x12, 0xd, 0x40, 0xae, 0x43, 0x1c, 0x4d, 0x24, 0xb4, + 0xd4, 0x27, 0xfd, 0x9d, 0xad, 0xe, 0x49, 0x39, 0xcc, 0x62, 0x0, 0x0, 0x5, 0x43, 0xe2, 0xa9, + 0xe6, 0x29, 0x0, 0x0, 0x7, 0x91, 0x54, 0x75, 0x0, 0x8, 0x1b, 0xe3, 0x1}; + + uint8_t buf[151] = {0}; + + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xe, 0x43, 0x9b, 0xd9, 0x1b, 0xb, 0x4a, 0x8b, 0xe, 0x57, + 0xb7, 0x1e, 0x5d, 0x2, 0x26, 0x1a, 0xb8, 0x0, 0xf2, 0x4a, + 0xba, 0xa5, 0xa5, 0xcc, 0x35, 0xa0, 0xd1, 0x9c, 0x39}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf8, 0x8f, 0x50, 0x32, 0x76, 0xb1, 0x32}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x6e, 0xd2}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x58, 0x9f, 0x18, 0x8f, 0xf5, 0xa, 0xce, 0x79, 0x14, 0x87, 0x14, 0x69, 0xe8, 0x60}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x10, 0x41, 0xe3, 0x35, 0x78, 0xea, 0x1f, 0xab}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa4, 0xb1, 0x98, 0x17, 0x68, 0x44, 0x98, 0xfb, 0xb4, 0x22, + 0xf4, 0xef, 0xbf, 0xf1, 0x95, 0xe3, 0x7d, 0xb7, 0x30}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xd, 0x40, 0xae, 0x43, 0x1c, 0x4d, 0x24, 0xb4, 0xd4, + 0x27, 0xfd, 0x9d, 0xad, 0xe, 0x49, 0x39, 0xcc, 0x62}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x43, 0xe2, 0xa9, 0xe6, 0x29}; + lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x91, 0x54, 0x75, 0x0, 0x8, 0x1b, 0xe3}; + lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7921, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15464, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\228\161\&1\220\142H\211q3\179%~Q\148", _pubPktID = 29868, _pubBody = "nP\243G", _pubProps = []} -TEST(Publish311QCTest, Encode46) { - uint8_t pkt[] = {0x33, 0x16, 0x0, 0xe, 0xe4, 0xa1, 0x31, 0xdc, 0x8e, 0x48, 0xd3, 0x71, - 0x33, 0xb3, 0x25, 0x7e, 0x51, 0x94, 0x74, 0xac, 0x6e, 0x50, 0xf3, 0x47}; +// SubscribeRequest 838 [("$-\227\252n\140N\241\225\146S\213\231(\193\150\248\177u\194",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode4) { + uint8_t pkt[] = {0x82, 0x19, 0x3, 0x46, 0x0, 0x14, 0x24, 0x2d, 0xe3, 0xfc, 0x6e, 0x8c, 0x4e, 0xf1, + 0xe1, 0x92, 0x53, 0xd5, 0xe7, 0x28, 0xc1, 0x96, 0xf8, 0xb1, 0x75, 0xc2, 0x1}; - uint8_t buf[34] = {0}; + uint8_t buf[37] = {0}; - uint8_t topic_bytes[] = {0xe4, 0xa1, 0x31, 0xdc, 0x8e, 0x48, 0xd3, 0x71, 0x33, 0xb3, 0x25, 0x7e, 0x51, 0x94}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x6e, 0x50, 0xf3, 0x47}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x24, 0x2d, 0xe3, 0xfc, 0x6e, 0x8c, 0x4e, 0xf1, 0xe1, 0x92, + 0x53, 0xd5, 0xe7, 0x28, 0xc1, 0x96, 0xf8, 0xb1, 0x75, 0xc2}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29868, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 838, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 16617 [("*\213.\SOH{\207\165\GS\FS\150\148]qq=A\239\234\252\189\STX;",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\210<\215\&2\177\181\232\211j\199\228\159~/\181X\SYN\136\205\\\253#",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\223[\223\187\180|\210;\149\229\164E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\133\253\223\167\156+\246\156\162\137\SYN\187I\v\233\SUB-\204P\169\233",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("1\b?\185o\135\176\195\173\ETB\161\156'\128M",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("6\129\247\STX\251H6",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("#`\225\150-e~\189\179c\212Qv\226U\171q\201\244\186i\219\169\234\t\175",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\NUL\136\CANO\SI\DEL\DC3\SYN\162\134\176\241\190eb\210\155",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\129>",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode5) { + uint8_t pkt[] = {0x82, 0xad, 0x1, 0x40, 0xe9, 0x0, 0x16, 0x2a, 0xd5, 0x2e, 0x1, 0x7b, 0xcf, 0xa5, 0x1d, 0x1c, + 0x96, 0x94, 0x5d, 0x71, 0x71, 0x3d, 0x41, 0xef, 0xea, 0xfc, 0xbd, 0x2, 0x3b, 0x2, 0x0, 0x16, + 0xd2, 0x3c, 0xd7, 0x32, 0xb1, 0xb5, 0xe8, 0xd3, 0x6a, 0xc7, 0xe4, 0x9f, 0x7e, 0x2f, 0xb5, 0x58, + 0x16, 0x88, 0xcd, 0x5c, 0xfd, 0x23, 0x1, 0x0, 0xc, 0xdf, 0x5b, 0xdf, 0xbb, 0xb4, 0x7c, 0xd2, + 0x3b, 0x95, 0xe5, 0xa4, 0x45, 0x0, 0x0, 0x15, 0x85, 0xfd, 0xdf, 0xa7, 0x9c, 0x2b, 0xf6, 0x9c, + 0xa2, 0x89, 0x16, 0xbb, 0x49, 0xb, 0xe9, 0x1a, 0x2d, 0xcc, 0x50, 0xa9, 0xe9, 0x0, 0x0, 0xf, + 0x31, 0x8, 0x3f, 0xb9, 0x6f, 0x87, 0xb0, 0xc3, 0xad, 0x17, 0xa1, 0x9c, 0x27, 0x80, 0x4d, 0x2, + 0x0, 0x7, 0x36, 0x81, 0xf7, 0x2, 0xfb, 0x48, 0x36, 0x0, 0x0, 0x1a, 0x23, 0x60, 0xe1, 0x96, + 0x2d, 0x65, 0x7e, 0xbd, 0xb3, 0x63, 0xd4, 0x51, 0x76, 0xe2, 0x55, 0xab, 0x71, 0xc9, 0xf4, 0xba, + 0x69, 0xdb, 0xa9, 0xea, 0x9, 0xaf, 0x0, 0x0, 0x11, 0x0, 0x88, 0x18, 0x4f, 0xf, 0x7f, 0x13, + 0x16, 0xa2, 0x86, 0xb0, 0xf1, 0xbe, 0x65, 0x62, 0xd2, 0x9b, 0x1, 0x0, 0x2, 0x81, 0x3e, 0x1}; -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\NUL\211nNzt\150\194r\182+\179\199\146", _pubPktID = 0, _pubBody = -// "]8\167\v\179vF\250\130{$\169\150w^\190QS]U\227C\205\189\179[\ENQ\131\SUB\200", _pubProps = []} -TEST(Publish311QCTest, Encode47) { - uint8_t pkt[] = {0x38, 0x2e, 0x0, 0xe, 0x0, 0xd3, 0x6e, 0x4e, 0x7a, 0x74, 0x96, 0xc2, 0x72, 0xb6, 0x2b, 0xb3, - 0xc7, 0x92, 0x5d, 0x38, 0xa7, 0xb, 0xb3, 0x76, 0x46, 0xfa, 0x82, 0x7b, 0x24, 0xa9, 0x96, 0x77, - 0x5e, 0xbe, 0x51, 0x53, 0x5d, 0x55, 0xe3, 0x43, 0xcd, 0xbd, 0xb3, 0x5b, 0x5, 0x83, 0x1a, 0xc8}; - - uint8_t buf[58] = {0}; + uint8_t buf[186] = {0}; - uint8_t topic_bytes[] = {0x0, 0xd3, 0x6e, 0x4e, 0x7a, 0x74, 0x96, 0xc2, 0x72, 0xb6, 0x2b, 0xb3, 0xc7, 0x92}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x5d, 0x38, 0xa7, 0xb, 0xb3, 0x76, 0x46, 0xfa, 0x82, 0x7b, 0x24, 0xa9, 0x96, 0x77, 0x5e, - 0xbe, 0x51, 0x53, 0x5d, 0x55, 0xe3, 0x43, 0xcd, 0xbd, 0xb3, 0x5b, 0x5, 0x83, 0x1a, 0xc8}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x2a, 0xd5, 0x2e, 0x1, 0x7b, 0xcf, 0xa5, 0x1d, 0x1c, 0x96, 0x94, + 0x5d, 0x71, 0x71, 0x3d, 0x41, 0xef, 0xea, 0xfc, 0xbd, 0x2, 0x3b}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd2, 0x3c, 0xd7, 0x32, 0xb1, 0xb5, 0xe8, 0xd3, 0x6a, 0xc7, 0xe4, + 0x9f, 0x7e, 0x2f, 0xb5, 0x58, 0x16, 0x88, 0xcd, 0x5c, 0xfd, 0x23}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xdf, 0x5b, 0xdf, 0xbb, 0xb4, 0x7c, 0xd2, 0x3b, 0x95, 0xe5, 0xa4, 0x45}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x85, 0xfd, 0xdf, 0xa7, 0x9c, 0x2b, 0xf6, 0x9c, 0xa2, 0x89, 0x16, + 0xbb, 0x49, 0xb, 0xe9, 0x1a, 0x2d, 0xcc, 0x50, 0xa9, 0xe9}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x8, 0x3f, 0xb9, 0x6f, 0x87, 0xb0, 0xc3, + 0xad, 0x17, 0xa1, 0x9c, 0x27, 0x80, 0x4d}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x36, 0x81, 0xf7, 0x2, 0xfb, 0x48, 0x36}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x23, 0x60, 0xe1, 0x96, 0x2d, 0x65, 0x7e, 0xbd, 0xb3, 0x63, 0xd4, 0x51, 0x76, + 0xe2, 0x55, 0xab, 0x71, 0xc9, 0xf4, 0xba, 0x69, 0xdb, 0xa9, 0xea, 0x9, 0xaf}; + lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x0, 0x88, 0x18, 0x4f, 0xf, 0x7f, 0x13, 0x16, 0xa2, + 0x86, 0xb0, 0xf1, 0xbe, 0x65, 0x62, 0xd2, 0x9b}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x81, 0x3e}; + lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16617, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "'\245\224\138\229\155\&6\241\GS\"t\ETX5%4?\146\ETB", _pubPktID = 0, _pubBody = "\SUB)\222", _pubProps = []} -TEST(Publish311QCTest, Encode48) { - uint8_t pkt[] = {0x39, 0x17, 0x0, 0x12, 0x27, 0xf5, 0xe0, 0x8a, 0xe5, 0x9b, 0x36, 0xf1, 0x1d, - 0x22, 0x74, 0x3, 0x35, 0x25, 0x34, 0x3f, 0x92, 0x17, 0x1a, 0x29, 0xde}; +// SubscribeRequest 4070 [("\v\136/\233\EOT\FS\240\255\227\DC3q9\SI\SOH\\",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\170\176\237\215\202\131\&2\ESCK\136h\184\178\226\178}.\242",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode6) { + uint8_t pkt[] = {0x82, 0x29, 0xf, 0xe6, 0x0, 0xf, 0xb, 0x88, 0x2f, 0xe9, 0x4, 0x1c, 0xf0, 0xff, 0xe3, + 0x13, 0x71, 0x39, 0xf, 0x1, 0x5c, 0x1, 0x0, 0x12, 0xaa, 0xb0, 0xed, 0xd7, 0xca, 0x83, + 0x32, 0x1b, 0x4b, 0x88, 0x68, 0xb8, 0xb2, 0xe2, 0xb2, 0x7d, 0x2e, 0xf2, 0x0}; - uint8_t buf[35] = {0}; + uint8_t buf[53] = {0}; - uint8_t topic_bytes[] = {0x27, 0xf5, 0xe0, 0x8a, 0xe5, 0x9b, 0x36, 0xf1, 0x1d, - 0x22, 0x74, 0x3, 0x35, 0x25, 0x34, 0x3f, 0x92, 0x17}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x1a, 0x29, 0xde}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xb, 0x88, 0x2f, 0xe9, 0x4, 0x1c, 0xf0, 0xff, + 0xe3, 0x13, 0x71, 0x39, 0xf, 0x1, 0x5c}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xaa, 0xb0, 0xed, 0xd7, 0xca, 0x83, 0x32, 0x1b, 0x4b, + 0x88, 0x68, 0xb8, 0xb2, 0xe2, 0xb2, 0x7d, 0x2e, 0xf2}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4070, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 1318 [("\141",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("(\232l\147\231\ETB\129\188\&6\207\SO\182\244\225\193S\228\&7\179\DEL\220",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\241\168\NUL\143\233m\184\163\STX\218\&8\156\252\250i\184C\188B\167\197\224A",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\177s\170{`\"e\RSr\DC3\r[\215\130\150\199q\253\216\221\231;\SYN",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\254*\164\NUL.\198\237\227\&3\143\SUB\248\248\162\t\167\n\146\232\250AK\234\220\178f\205\210\226",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\159}A_\221B\190\143\&5\n\NUL\186z)\143",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\r0\DC1\n\226K\201\177\128\US:\237o\241I\186d|",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Q\EM\214h\"_\196\253z\ACK\211F7\211D\144\NUL",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(")\213\149\ACK",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode7) { + uint8_t pkt[] = {0x82, 0xb4, 0x1, 0x5, 0x26, 0x0, 0x1, 0x8d, 0x2, 0x0, 0x15, 0x28, 0xe8, 0x6c, 0x93, 0xe7, 0x17, + 0x81, 0xbc, 0x36, 0xcf, 0xe, 0xb6, 0xf4, 0xe1, 0xc1, 0x53, 0xe4, 0x37, 0xb3, 0x7f, 0xdc, 0x2, 0x0, + 0x17, 0xf1, 0xa8, 0x0, 0x8f, 0xe9, 0x6d, 0xb8, 0xa3, 0x2, 0xda, 0x38, 0x9c, 0xfc, 0xfa, 0x69, 0xb8, + 0x43, 0xbc, 0x42, 0xa7, 0xc5, 0xe0, 0x41, 0x2, 0x0, 0x17, 0xb1, 0x73, 0xaa, 0x7b, 0x60, 0x22, 0x65, + 0x1e, 0x72, 0x13, 0xd, 0x5b, 0xd7, 0x82, 0x96, 0xc7, 0x71, 0xfd, 0xd8, 0xdd, 0xe7, 0x3b, 0x16, 0x2, + 0x0, 0x1d, 0xfe, 0x2a, 0xa4, 0x0, 0x2e, 0xc6, 0xed, 0xe3, 0x33, 0x8f, 0x1a, 0xf8, 0xf8, 0xa2, 0x9, + 0xa7, 0xa, 0x92, 0xe8, 0xfa, 0x41, 0x4b, 0xea, 0xdc, 0xb2, 0x66, 0xcd, 0xd2, 0xe2, 0x2, 0x0, 0xf, + 0x9f, 0x7d, 0x41, 0x5f, 0xdd, 0x42, 0xbe, 0x8f, 0x35, 0xa, 0x0, 0xba, 0x7a, 0x29, 0x8f, 0x0, 0x0, + 0x12, 0xd, 0x30, 0x11, 0xa, 0xe2, 0x4b, 0xc9, 0xb1, 0x80, 0x1f, 0x3a, 0xed, 0x6f, 0xf1, 0x49, 0xba, + 0x64, 0x7c, 0x2, 0x0, 0x11, 0x51, 0x19, 0xd6, 0x68, 0x22, 0x5f, 0xc4, 0xfd, 0x7a, 0x6, 0xd3, 0x46, + 0x37, 0xd3, 0x44, 0x90, 0x0, 0x1, 0x0, 0x4, 0x29, 0xd5, 0x95, 0x6, 0x2}; + + uint8_t buf[193] = {0}; + + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x8d}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x28, 0xe8, 0x6c, 0x93, 0xe7, 0x17, 0x81, 0xbc, 0x36, 0xcf, 0xe, + 0xb6, 0xf4, 0xe1, 0xc1, 0x53, 0xe4, 0x37, 0xb3, 0x7f, 0xdc}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf1, 0xa8, 0x0, 0x8f, 0xe9, 0x6d, 0xb8, 0xa3, 0x2, 0xda, 0x38, 0x9c, + 0xfc, 0xfa, 0x69, 0xb8, 0x43, 0xbc, 0x42, 0xa7, 0xc5, 0xe0, 0x41}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb1, 0x73, 0xaa, 0x7b, 0x60, 0x22, 0x65, 0x1e, 0x72, 0x13, 0xd, 0x5b, + 0xd7, 0x82, 0x96, 0xc7, 0x71, 0xfd, 0xd8, 0xdd, 0xe7, 0x3b, 0x16}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xfe, 0x2a, 0xa4, 0x0, 0x2e, 0xc6, 0xed, 0xe3, 0x33, 0x8f, + 0x1a, 0xf8, 0xf8, 0xa2, 0x9, 0xa7, 0xa, 0x92, 0xe8, 0xfa, + 0x41, 0x4b, 0xea, 0xdc, 0xb2, 0x66, 0xcd, 0xd2, 0xe2}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x9f, 0x7d, 0x41, 0x5f, 0xdd, 0x42, 0xbe, 0x8f, + 0x35, 0xa, 0x0, 0xba, 0x7a, 0x29, 0x8f}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xd, 0x30, 0x11, 0xa, 0xe2, 0x4b, 0xc9, 0xb1, 0x80, + 0x1f, 0x3a, 0xed, 0x6f, 0xf1, 0x49, 0xba, 0x64, 0x7c}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x51, 0x19, 0xd6, 0x68, 0x22, 0x5f, 0xc4, 0xfd, 0x7a, + 0x6, 0xd3, 0x46, 0x37, 0xd3, 0x44, 0x90, 0x0}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x29, 0xd5, 0x95, 0x6}; + lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1318, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\200Z\225i^_\STX\231\193\STX", -// _pubPktID = 16826, _pubBody = "\206\193\194\217\177\152\142,\163\145\149Q\237?7\131k\n\177[^\153ti\134sYl\140\174", -// _pubProps = []} -TEST(Publish311QCTest, Encode49) { - uint8_t pkt[] = {0x3d, 0x2c, 0x0, 0xa, 0xc8, 0x5a, 0xe1, 0x69, 0x5e, 0x5f, 0x2, 0xe7, 0xc1, 0x2, 0x41, 0xba, - 0xce, 0xc1, 0xc2, 0xd9, 0xb1, 0x98, 0x8e, 0x2c, 0xa3, 0x91, 0x95, 0x51, 0xed, 0x3f, 0x37, 0x83, - 0x6b, 0xa, 0xb1, 0x5b, 0x5e, 0x99, 0x74, 0x69, 0x86, 0x73, 0x59, 0x6c, 0x8c, 0xae}; +// SubscribeRequest 4255 +// [("\180\179\158\152\140\184\134\243\150\253\DELV\188\SIa\US\207\DEL\234C\tl\186p*M\209\246\162",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("/\140^\ESC#\181^Ia%o\229mJ\166XA\DELA\183l;S_l\133^",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\159\&8\162\SYN\188\181",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\253\&9-\SOH\n\189\207\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode8) { + uint8_t pkt[] = {0x82, 0x54, 0x10, 0x9f, 0x0, 0x1d, 0xb4, 0xb3, 0x9e, 0x98, 0x8c, 0xb8, 0x86, 0xf3, 0x96, + 0xfd, 0x7f, 0x56, 0xbc, 0xf, 0x61, 0x1f, 0xcf, 0x7f, 0xea, 0x43, 0x9, 0x6c, 0xba, 0x70, + 0x2a, 0x4d, 0xd1, 0xf6, 0xa2, 0x0, 0x0, 0x1b, 0x2f, 0x8c, 0x5e, 0x1b, 0x23, 0xb5, 0x5e, + 0x49, 0x61, 0x25, 0x6f, 0xe5, 0x6d, 0x4a, 0xa6, 0x58, 0x41, 0x7f, 0x41, 0xb7, 0x6c, 0x3b, + 0x53, 0x5f, 0x6c, 0x85, 0x5e, 0x0, 0x0, 0x6, 0x9f, 0x38, 0xa2, 0x16, 0xbc, 0xb5, 0x1, + 0x0, 0x8, 0xfd, 0x39, 0x2d, 0x1, 0xa, 0xbd, 0xcf, 0xdb, 0x1}; - uint8_t buf[56] = {0}; + uint8_t buf[96] = {0}; - uint8_t topic_bytes[] = {0xc8, 0x5a, 0xe1, 0x69, 0x5e, 0x5f, 0x2, 0xe7, 0xc1, 0x2}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xce, 0xc1, 0xc2, 0xd9, 0xb1, 0x98, 0x8e, 0x2c, 0xa3, 0x91, 0x95, 0x51, 0xed, 0x3f, 0x37, - 0x83, 0x6b, 0xa, 0xb1, 0x5b, 0x5e, 0x99, 0x74, 0x69, 0x86, 0x73, 0x59, 0x6c, 0x8c, 0xae}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xb4, 0xb3, 0x9e, 0x98, 0x8c, 0xb8, 0x86, 0xf3, 0x96, 0xfd, + 0x7f, 0x56, 0xbc, 0xf, 0x61, 0x1f, 0xcf, 0x7f, 0xea, 0x43, + 0x9, 0x6c, 0xba, 0x70, 0x2a, 0x4d, 0xd1, 0xf6, 0xa2}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2f, 0x8c, 0x5e, 0x1b, 0x23, 0xb5, 0x5e, 0x49, 0x61, 0x25, 0x6f, 0xe5, 0x6d, 0x4a, + 0xa6, 0x58, 0x41, 0x7f, 0x41, 0xb7, 0x6c, 0x3b, 0x53, 0x5f, 0x6c, 0x85, 0x5e}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x9f, 0x38, 0xa2, 0x16, 0xbc, 0xb5}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xfd, 0x39, 0x2d, 0x1, 0xa, 0xbd, 0xcf, 0xdb}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4255, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 8790 [("BZ_)",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\244x\187\186\255\245oy\163<\181\242J3\202-",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("'8\171[\231\210\133\201\GSP\238\199\163'\182bO@\226\RS?\SO@\244uRA\SI2",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("W\239\192\&2\217\184?\141\&7\FSL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\200h\214",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\187\DC2\tI\174\251I\ETB\FS\NAK\148\DC4\136Je\193|\216V)j",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode9) { + uint8_t pkt[] = {0x82, 0x68, 0x22, 0x56, 0x0, 0x4, 0x42, 0x5a, 0x5f, 0x29, 0x0, 0x0, 0x10, 0xf4, 0x78, 0xbb, + 0xba, 0xff, 0xf5, 0x6f, 0x79, 0xa3, 0x3c, 0xb5, 0xf2, 0x4a, 0x33, 0xca, 0x2d, 0x0, 0x0, 0x1d, + 0x27, 0x38, 0xab, 0x5b, 0xe7, 0xd2, 0x85, 0xc9, 0x1d, 0x50, 0xee, 0xc7, 0xa3, 0x27, 0xb6, 0x62, + 0x4f, 0x40, 0xe2, 0x1e, 0x3f, 0xe, 0x40, 0xf4, 0x75, 0x52, 0x41, 0xf, 0x32, 0x2, 0x0, 0xb, + 0x57, 0xef, 0xc0, 0x32, 0xd9, 0xb8, 0x3f, 0x8d, 0x37, 0x1c, 0x4c, 0x2, 0x0, 0x3, 0xc8, 0x68, + 0xd6, 0x0, 0x0, 0x15, 0xbb, 0x12, 0x9, 0x49, 0xae, 0xfb, 0x49, 0x17, 0x1c, 0x15, 0x94, 0x14, + 0x88, 0x4a, 0x65, 0xc1, 0x7c, 0xd8, 0x56, 0x29, 0x6a, 0x0}; + + uint8_t buf[116] = {0}; + + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x42, 0x5a, 0x5f, 0x29}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf4, 0x78, 0xbb, 0xba, 0xff, 0xf5, 0x6f, 0x79, + 0xa3, 0x3c, 0xb5, 0xf2, 0x4a, 0x33, 0xca, 0x2d}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x27, 0x38, 0xab, 0x5b, 0xe7, 0xd2, 0x85, 0xc9, 0x1d, 0x50, + 0xee, 0xc7, 0xa3, 0x27, 0xb6, 0x62, 0x4f, 0x40, 0xe2, 0x1e, + 0x3f, 0xe, 0x40, 0xf4, 0x75, 0x52, 0x41, 0xf, 0x32}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x57, 0xef, 0xc0, 0x32, 0xd9, 0xb8, 0x3f, 0x8d, 0x37, 0x1c, 0x4c}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xc8, 0x68, 0xd6}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xbb, 0x12, 0x9, 0x49, 0xae, 0xfb, 0x49, 0x17, 0x1c, 0x15, 0x94, + 0x14, 0x88, 0x4a, 0x65, 0xc1, 0x7c, 0xd8, 0x56, 0x29, 0x6a}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16826, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8790, 6, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\161\178\167\170\164+\151g\137\n", -// _pubPktID = 11219, _pubBody = "R\146a\229\236\247\197\178\199\136\159_\251", _pubProps = []} -TEST(Publish311QCTest, Encode50) { - uint8_t pkt[] = {0x3b, 0x1b, 0x0, 0xa, 0xa1, 0xb2, 0xa7, 0xaa, 0xa4, 0x2b, 0x97, 0x67, 0x89, 0xa, 0x2b, - 0xd3, 0x52, 0x92, 0x61, 0xe5, 0xec, 0xf7, 0xc5, 0xb2, 0xc7, 0x88, 0x9f, 0x5f, 0xfb}; +// SubscribeRequest 28419 [("\172\146\187b\165\234\194\249&",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("&\154ju i",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\196\DC4\v\a\177\139Fn\195",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("m\205\237M\200/\184hq79.3\134,\188\154\r\211\201\143\CAN\223\SYN +// \200v\164<",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\ENQ\241`\255\207+~",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode10) { + uint8_t pkt[] = {0x82, 0x4d, 0x6f, 0x3, 0x0, 0x9, 0xac, 0x92, 0xbb, 0x62, 0xa5, 0xea, 0xc2, 0xf9, 0x26, 0x0, + 0x0, 0x6, 0x26, 0x9a, 0x6a, 0x75, 0x20, 0x69, 0x1, 0x0, 0x9, 0xc4, 0x14, 0xb, 0x7, 0xb1, + 0x8b, 0x46, 0x6e, 0xc3, 0x1, 0x0, 0x1d, 0x6d, 0xcd, 0xed, 0x4d, 0xc8, 0x2f, 0xb8, 0x68, 0x71, + 0x37, 0x39, 0x2e, 0x33, 0x86, 0x2c, 0xbc, 0x9a, 0xd, 0xd3, 0xc9, 0x8f, 0x18, 0xdf, 0x16, 0x20, + 0xc8, 0x76, 0xa4, 0x3c, 0x1, 0x0, 0x7, 0x5, 0xf1, 0x60, 0xff, 0xcf, 0x2b, 0x7e, 0x1}; - uint8_t buf[39] = {0}; + uint8_t buf[89] = {0}; - uint8_t topic_bytes[] = {0xa1, 0xb2, 0xa7, 0xaa, 0xa4, 0x2b, 0x97, 0x67, 0x89, 0xa}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x52, 0x92, 0x61, 0xe5, 0xec, 0xf7, 0xc5, 0xb2, 0xc7, 0x88, 0x9f, 0x5f, 0xfb}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xac, 0x92, 0xbb, 0x62, 0xa5, 0xea, 0xc2, 0xf9, 0x26}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x26, 0x9a, 0x6a, 0x75, 0x20, 0x69}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc4, 0x14, 0xb, 0x7, 0xb1, 0x8b, 0x46, 0x6e, 0xc3}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6d, 0xcd, 0xed, 0x4d, 0xc8, 0x2f, 0xb8, 0x68, 0x71, 0x37, + 0x39, 0x2e, 0x33, 0x86, 0x2c, 0xbc, 0x9a, 0xd, 0xd3, 0xc9, + 0x8f, 0x18, 0xdf, 0x16, 0x20, 0xc8, 0x76, 0xa4, 0x3c}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x5, 0xf1, 0x60, 0xff, 0xcf, 0x2b, 0x7e}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 11219, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "R\\\164\224\200+\254\\\233t@\GS\144\&5|\243\244@%\240\170\193\150V\252\133q", _pubPktID = 23768, _pubBody = -// "\RS.\158\236\175|6'\152C\151\NUL\138o\230\242\236\184,\ENQ\201^\185\t", _pubProps = []} -TEST(Publish311QCTest, Encode51) { - uint8_t pkt[] = {0x3c, 0x37, 0x0, 0x1b, 0x52, 0x5c, 0xa4, 0xe0, 0xc8, 0x2b, 0xfe, 0x5c, 0xe9, 0x74, 0x40, - 0x1d, 0x90, 0x35, 0x7c, 0xf3, 0xf4, 0x40, 0x25, 0xf0, 0xaa, 0xc1, 0x96, 0x56, 0xfc, 0x85, - 0x71, 0x5c, 0xd8, 0x1e, 0x2e, 0x9e, 0xec, 0xaf, 0x7c, 0x36, 0x27, 0x98, 0x43, 0x97, 0x0, - 0x8a, 0x6f, 0xe6, 0xf2, 0xec, 0xb8, 0x2c, 0x5, 0xc9, 0x5e, 0xb9, 0x9}; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28419, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 5081 [("Zq\ETB\209",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("\254\248\251$\238\158f\176\218\152\154A\147\STX^\184'w\188\&2{\US\165I\vF\139",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\164\143V*3\253\171\214\141x.\184\242l\217\&2\255\ENQ",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\171E\173\162L\158>9\a\202\138\223Jb{\170Y8\RS\137\226\166I\177J",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\185\188",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode11) { + uint8_t pkt[] = {0x82, 0x60, 0x13, 0xd9, 0x0, 0x4, 0x5a, 0x71, 0x17, 0xd1, 0x0, 0x0, 0x1b, 0xfe, 0xf8, 0xfb, 0x24, + 0xee, 0x9e, 0x66, 0xb0, 0xda, 0x98, 0x9a, 0x41, 0x93, 0x2, 0x5e, 0xb8, 0x27, 0x77, 0xbc, 0x32, 0x7b, + 0x1f, 0xa5, 0x49, 0xb, 0x46, 0x8b, 0x1, 0x0, 0x12, 0xa4, 0x8f, 0x56, 0x2a, 0x33, 0xfd, 0xab, 0xd6, + 0x8d, 0x78, 0x2e, 0xb8, 0xf2, 0x6c, 0xd9, 0x32, 0xff, 0x5, 0x1, 0x0, 0x19, 0xab, 0x45, 0xad, 0xa2, + 0x4c, 0x9e, 0x3e, 0x39, 0x7, 0xca, 0x8a, 0xdf, 0x4a, 0x62, 0x7b, 0xaa, 0x59, 0x38, 0x1e, 0x89, 0xe2, + 0xa6, 0x49, 0xb1, 0x4a, 0x2, 0x0, 0x2, 0xb9, 0xbc, 0x2, 0x0, 0x0, 0x1}; + + uint8_t buf[108] = {0}; + + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x5a, 0x71, 0x17, 0xd1}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xfe, 0xf8, 0xfb, 0x24, 0xee, 0x9e, 0x66, 0xb0, 0xda, 0x98, 0x9a, 0x41, 0x93, 0x2, + 0x5e, 0xb8, 0x27, 0x77, 0xbc, 0x32, 0x7b, 0x1f, 0xa5, 0x49, 0xb, 0x46, 0x8b}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa4, 0x8f, 0x56, 0x2a, 0x33, 0xfd, 0xab, 0xd6, 0x8d, + 0x78, 0x2e, 0xb8, 0xf2, 0x6c, 0xd9, 0x32, 0xff, 0x5}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xab, 0x45, 0xad, 0xa2, 0x4c, 0x9e, 0x3e, 0x39, 0x7, 0xca, 0x8a, 0xdf, 0x4a, + 0x62, 0x7b, 0xaa, 0x59, 0x38, 0x1e, 0x89, 0xe2, 0xa6, 0x49, 0xb1, 0x4a}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xb9, 0xbc}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t buf[67] = {0}; + lwmqtt_property_t propslist[] = {}; - uint8_t topic_bytes[] = {0x52, 0x5c, 0xa4, 0xe0, 0xc8, 0x2b, 0xfe, 0x5c, 0xe9, 0x74, 0x40, 0x1d, 0x90, 0x35, - 0x7c, 0xf3, 0xf4, 0x40, 0x25, 0xf0, 0xaa, 0xc1, 0x96, 0x56, 0xfc, 0x85, 0x71}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x1e, 0x2e, 0x9e, 0xec, 0xaf, 0x7c, 0x36, 0x27, 0x98, 0x43, 0x97, 0x0, - 0x8a, 0x6f, 0xe6, 0xf2, 0xec, 0xb8, 0x2c, 0x5, 0xc9, 0x5e, 0xb9, 0x9}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5081, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 25469 [("\196\234\233C\245\STX\229\154\t\US\r\b&>F\213\130\&4",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("}\ENQ\233z\235\223\134Z\220y\220\255\ACK\f8\r\211\178\171\145=\183\148\DC4\187{S:\215\247",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("SL0j\ENQ\STX\v\178\243,\155\168-3\RS*R\246\NAK\134f)\183\196",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\t\185T\132Z\205GI\DC2\146\156\233\201\134k\142\168\247\201=\179\134\&1",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\200\160\129\198|>\238\159\254\255\CANc\149\154\139\167#\234n",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\169\216=\154v",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("9\254'\139~\175N\ETX\172\240\223\&5^\171\"\163\222\225*\182\&2,\254\&6\174\EM2\f\227",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("o\SOH\195\158\&0R\138\250",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\EM\SYN\174\218\152k\247\&5i_\205`,\fm*\131_",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\163n)\179A=<\NUL\US\199\129\163\137+u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode12) { + uint8_t pkt[] = { + 0x82, 0xe0, 0x1, 0x63, 0x7d, 0x0, 0x12, 0xc4, 0xea, 0xe9, 0x43, 0xf5, 0x2, 0xe5, 0x9a, 0x9, 0x1f, 0xd, 0x8, + 0x26, 0x3e, 0x46, 0xd5, 0x82, 0x34, 0x1, 0x0, 0x1e, 0x7d, 0x5, 0xe9, 0x7a, 0xeb, 0xdf, 0x86, 0x5a, 0xdc, 0x79, + 0xdc, 0xff, 0x6, 0xc, 0x38, 0xd, 0xd3, 0xb2, 0xab, 0x91, 0x3d, 0xb7, 0x94, 0x14, 0xbb, 0x7b, 0x53, 0x3a, 0xd7, + 0xf7, 0x2, 0x0, 0x18, 0x53, 0x4c, 0x30, 0x6a, 0x5, 0x2, 0xb, 0xb2, 0xf3, 0x2c, 0x9b, 0xa8, 0x2d, 0x33, 0x1e, + 0x2a, 0x52, 0xf6, 0x15, 0x86, 0x66, 0x29, 0xb7, 0xc4, 0x2, 0x0, 0x17, 0x9, 0xb9, 0x54, 0x84, 0x5a, 0xcd, 0x47, + 0x49, 0x12, 0x92, 0x9c, 0xe9, 0xc9, 0x86, 0x6b, 0x8e, 0xa8, 0xf7, 0xc9, 0x3d, 0xb3, 0x86, 0x31, 0x1, 0x0, 0x13, + 0xc8, 0xa0, 0x81, 0xc6, 0x7c, 0x3e, 0xee, 0x9f, 0xfe, 0xff, 0x18, 0x63, 0x95, 0x9a, 0x8b, 0xa7, 0x23, 0xea, 0x6e, + 0x2, 0x0, 0x5, 0xa9, 0xd8, 0x3d, 0x9a, 0x76, 0x1, 0x0, 0x1d, 0x39, 0xfe, 0x27, 0x8b, 0x7e, 0xaf, 0x4e, 0x3, + 0xac, 0xf0, 0xdf, 0x35, 0x5e, 0xab, 0x22, 0xa3, 0xde, 0xe1, 0x2a, 0xb6, 0x32, 0x2c, 0xfe, 0x36, 0xae, 0x19, 0x32, + 0xc, 0xe3, 0x2, 0x0, 0x8, 0x6f, 0x1, 0xc3, 0x9e, 0x30, 0x52, 0x8a, 0xfa, 0x0, 0x0, 0x12, 0x19, 0x16, 0xae, + 0xda, 0x98, 0x6b, 0xf7, 0x35, 0x69, 0x5f, 0xcd, 0x60, 0x2c, 0xc, 0x6d, 0x2a, 0x83, 0x5f, 0x2, 0x0, 0xf, 0xa3, + 0x6e, 0x29, 0xb3, 0x41, 0x3d, 0x3c, 0x0, 0x1f, 0xc7, 0x81, 0xa3, 0x89, 0x2b, 0x75, 0x0, 0x0, 0x0, 0x2}; + + uint8_t buf[237] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xc4, 0xea, 0xe9, 0x43, 0xf5, 0x2, 0xe5, 0x9a, 0x9, + 0x1f, 0xd, 0x8, 0x26, 0x3e, 0x46, 0xd5, 0x82, 0x34}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7d, 0x5, 0xe9, 0x7a, 0xeb, 0xdf, 0x86, 0x5a, 0xdc, 0x79, + 0xdc, 0xff, 0x6, 0xc, 0x38, 0xd, 0xd3, 0xb2, 0xab, 0x91, + 0x3d, 0xb7, 0x94, 0x14, 0xbb, 0x7b, 0x53, 0x3a, 0xd7, 0xf7}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x53, 0x4c, 0x30, 0x6a, 0x5, 0x2, 0xb, 0xb2, 0xf3, 0x2c, 0x9b, 0xa8, + 0x2d, 0x33, 0x1e, 0x2a, 0x52, 0xf6, 0x15, 0x86, 0x66, 0x29, 0xb7, 0xc4}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x9, 0xb9, 0x54, 0x84, 0x5a, 0xcd, 0x47, 0x49, 0x12, 0x92, 0x9c, 0xe9, + 0xc9, 0x86, 0x6b, 0x8e, 0xa8, 0xf7, 0xc9, 0x3d, 0xb3, 0x86, 0x31}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xc8, 0xa0, 0x81, 0xc6, 0x7c, 0x3e, 0xee, 0x9f, 0xfe, 0xff, + 0x18, 0x63, 0x95, 0x9a, 0x8b, 0xa7, 0x23, 0xea, 0x6e}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa9, 0xd8, 0x3d, 0x9a, 0x76}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x39, 0xfe, 0x27, 0x8b, 0x7e, 0xaf, 0x4e, 0x3, 0xac, 0xf0, + 0xdf, 0x35, 0x5e, 0xab, 0x22, 0xa3, 0xde, 0xe1, 0x2a, 0xb6, + 0x32, 0x2c, 0xfe, 0x36, 0xae, 0x19, 0x32, 0xc, 0xe3}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6f, 0x1, 0xc3, 0x9e, 0x30, 0x52, 0x8a, 0xfa}; + lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x19, 0x16, 0xae, 0xda, 0x98, 0x6b, 0xf7, 0x35, 0x69, + 0x5f, 0xcd, 0x60, 0x2c, 0xc, 0x6d, 0x2a, 0x83, 0x5f}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa3, 0x6e, 0x29, 0xb3, 0x41, 0x3d, 0x3c, 0x0, + 0x1f, 0xc7, 0x81, 0xa3, 0x89, 0x2b, 0x75}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 23768, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25469, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\EOT+\243\179\223\201\tb\221\175W<\221L\a", _pubPktID = 32599, _pubBody = -// "\187\221\219\249%\DC1M\195%\227~\ETBcZ\232\f\141\254\253\223", _pubProps = []} -TEST(Publish311QCTest, Encode52) { - uint8_t pkt[] = {0x3b, 0x27, 0x0, 0xf, 0x4, 0x2b, 0xf3, 0xb3, 0xdf, 0xc9, 0x9, 0x62, 0xdd, 0xaf, - 0x57, 0x3c, 0xdd, 0x4c, 0x7, 0x7f, 0x57, 0xbb, 0xdd, 0xdb, 0xf9, 0x25, 0x11, 0x4d, - 0xc3, 0x25, 0xe3, 0x7e, 0x17, 0x63, 0x5a, 0xe8, 0xc, 0x8d, 0xfe, 0xfd, 0xdf}; +// SubscribeRequest 14214 [("96\SIk\238a\SI\ETX\203\216\176fgS\149\148\229\206$",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\242\218\225YA\243\153\247\189I",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("1\141\ENQ\206\182U",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode13) { + uint8_t pkt[] = {0x82, 0x32, 0x37, 0x86, 0x0, 0x13, 0x39, 0x36, 0xf, 0x6b, 0xee, 0x61, 0xf, + 0x3, 0xcb, 0xd8, 0xb0, 0x66, 0x67, 0x53, 0x95, 0x94, 0xe5, 0xce, 0x24, 0x2, + 0x0, 0xa, 0xf2, 0xda, 0xe1, 0x59, 0x41, 0xf3, 0x99, 0xf7, 0xbd, 0x49, 0x1, + 0x0, 0x1, 0xeb, 0x0, 0x0, 0x6, 0x31, 0x8d, 0x5, 0xce, 0xb6, 0x55, 0x0}; - uint8_t buf[51] = {0}; + uint8_t buf[62] = {0}; - uint8_t topic_bytes[] = {0x4, 0x2b, 0xf3, 0xb3, 0xdf, 0xc9, 0x9, 0x62, 0xdd, 0xaf, 0x57, 0x3c, 0xdd, 0x4c, 0x7}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xbb, 0xdd, 0xdb, 0xf9, 0x25, 0x11, 0x4d, 0xc3, 0x25, 0xe3, - 0x7e, 0x17, 0x63, 0x5a, 0xe8, 0xc, 0x8d, 0xfe, 0xfd, 0xdf}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x39, 0x36, 0xf, 0x6b, 0xee, 0x61, 0xf, 0x3, 0xcb, 0xd8, + 0xb0, 0x66, 0x67, 0x53, 0x95, 0x94, 0xe5, 0xce, 0x24}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf2, 0xda, 0xe1, 0x59, 0x41, 0xf3, 0x99, 0xf7, 0xbd, 0x49}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xeb}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x31, 0x8d, 0x5, 0xce, 0xb6, 0x55}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 32599, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14214, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "k6\170c0\139\149-", _pubPktID = -// 24880, _pubBody = "q\181r\196\216Eo\234\"\ENQ\138\207\210-\196\182\157\139\DC2\178?b\a4\250\ETB\168\131", _pubProps = -// []} -TEST(Publish311QCTest, Encode53) { - uint8_t pkt[] = {0x32, 0x28, 0x0, 0x8, 0x6b, 0x36, 0xaa, 0x63, 0x30, 0x8b, 0x95, 0x2d, 0x61, 0x30, - 0x71, 0xb5, 0x72, 0xc4, 0xd8, 0x45, 0x6f, 0xea, 0x22, 0x5, 0x8a, 0xcf, 0xd2, 0x2d, - 0xc4, 0xb6, 0x9d, 0x8b, 0x12, 0xb2, 0x3f, 0x62, 0x7, 0x34, 0xfa, 0x17, 0xa8, 0x83}; +// SubscribeRequest 26235 [("\DLE",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("m;1\220gk`\169\152\251",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\SIj6\144\200ar\STX",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\241c\229\NULx\190Q\SYN",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode14) { + uint8_t pkt[] = {0x82, 0x29, 0x66, 0x7b, 0x0, 0x1, 0x10, 0x1, 0x0, 0xa, 0x6d, 0x3b, 0x31, 0xdc, 0x67, + 0x6b, 0x60, 0xa9, 0x98, 0xfb, 0x1, 0x0, 0x8, 0xf, 0x6a, 0x36, 0x90, 0xc8, 0x61, 0x72, + 0x2, 0x0, 0x0, 0x8, 0xf1, 0x63, 0xe5, 0x0, 0x78, 0xbe, 0x51, 0x16, 0x0}; - uint8_t buf[52] = {0}; + uint8_t buf[53] = {0}; - uint8_t topic_bytes[] = {0x6b, 0x36, 0xaa, 0x63, 0x30, 0x8b, 0x95, 0x2d}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x71, 0xb5, 0x72, 0xc4, 0xd8, 0x45, 0x6f, 0xea, 0x22, 0x5, 0x8a, 0xcf, 0xd2, 0x2d, - 0xc4, 0xb6, 0x9d, 0x8b, 0x12, 0xb2, 0x3f, 0x62, 0x7, 0x34, 0xfa, 0x17, 0xa8, 0x83}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x10}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6d, 0x3b, 0x31, 0xdc, 0x67, 0x6b, 0x60, 0xa9, 0x98, 0xfb}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf, 0x6a, 0x36, 0x90, 0xc8, 0x61, 0x72, 0x2}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf1, 0x63, 0xe5, 0x0, 0x78, 0xbe, 0x51, 0x16}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24880, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26235, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\164]\137\161\184\189\ETB_L\r+\255\233u\227\NAK\SI\199\CANG\211_\141", _pubPktID = 0, _pubBody = -// "n\169\136j,\137\228\208\162\164aL\186\EOT\241\GS\230d\142\177N\138P", _pubProps = []} -TEST(Publish311QCTest, Encode54) { - uint8_t pkt[] = {0x38, 0x30, 0x0, 0x17, 0xa4, 0x5d, 0x89, 0xa1, 0xb8, 0xbd, 0x17, 0x5f, 0x4c, 0xd, 0x2b, 0xff, 0xe9, - 0x75, 0xe3, 0x15, 0xf, 0xc7, 0x18, 0x47, 0xd3, 0x5f, 0x8d, 0x6e, 0xa9, 0x88, 0x6a, 0x2c, 0x89, 0xe4, - 0xd0, 0xa2, 0xa4, 0x61, 0x4c, 0xba, 0x4, 0xf1, 0x1d, 0xe6, 0x64, 0x8e, 0xb1, 0x4e, 0x8a, 0x50}; - - uint8_t buf[60] = {0}; - - uint8_t topic_bytes[] = {0xa4, 0x5d, 0x89, 0xa1, 0xb8, 0xbd, 0x17, 0x5f, 0x4c, 0xd, 0x2b, 0xff, - 0xe9, 0x75, 0xe3, 0x15, 0xf, 0xc7, 0x18, 0x47, 0xd3, 0x5f, 0x8d}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x6e, 0xa9, 0x88, 0x6a, 0x2c, 0x89, 0xe4, 0xd0, 0xa2, 0xa4, 0x61, 0x4c, - 0xba, 0x4, 0xf1, 0x1d, 0xe6, 0x64, 0x8e, 0xb1, 0x4e, 0x8a, 0x50}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; +// SubscribeRequest 10474 [("\ACK\214li.\ESC\US;\201}3\165",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\152\173{\218\168a\184Y_y\149\241F:y\188",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\147\ESC\141H\166\226\230G\180\252\198\196\GS",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\236\183\RSM\169v\254\179TT7\211\194\132\161fbQ\218\US\135\202\f\149E\197\197\SOHuK",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("3\179|)\222p\245\SUB\197\v\182\RSnw#\225\157t\ETX\DC2E",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\233\213\221\219\SUB0\164J\162\185\156\230\230\&5\156\244\133",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("d\NULN\129\242u`\152\ACK\DEL_\164\207\168\191T\132\177\"\FS*",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\136f7w\182\132'",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\220w'\179\FSxy\194[@\163;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("9H\134H\191\242[\206S\129\162\243\244Kw$",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode15) { + uint8_t pkt[] = { + 0x82, 0xca, 0x1, 0x28, 0xea, 0x0, 0x11, 0x6, 0xd6, 0x6c, 0x69, 0x2e, 0x1b, 0x1f, 0x3b, 0x3c, 0x4f, 0x5d, 0x74, + 0x3e, 0xc9, 0x7d, 0x33, 0xa5, 0x0, 0x0, 0x10, 0x98, 0xad, 0x7b, 0xda, 0xa8, 0x61, 0xb8, 0x59, 0x5f, 0x79, 0x95, + 0xf1, 0x46, 0x3a, 0x79, 0xbc, 0x2, 0x0, 0xd, 0x93, 0x1b, 0x8d, 0x48, 0xa6, 0xe2, 0xe6, 0x47, 0xb4, 0xfc, 0xc6, + 0xc4, 0x1d, 0x2, 0x0, 0x1e, 0xec, 0xb7, 0x1e, 0x4d, 0xa9, 0x76, 0xfe, 0xb3, 0x54, 0x54, 0x37, 0xd3, 0xc2, 0x84, + 0xa1, 0x66, 0x62, 0x51, 0xda, 0x1f, 0x87, 0xca, 0xc, 0x95, 0x45, 0xc5, 0xc5, 0x1, 0x75, 0x4b, 0x0, 0x0, 0x15, + 0x33, 0xb3, 0x7c, 0x29, 0xde, 0x70, 0xf5, 0x1a, 0xc5, 0xb, 0xb6, 0x1e, 0x6e, 0x77, 0x23, 0xe1, 0x9d, 0x74, 0x3, + 0x12, 0x45, 0x1, 0x0, 0x11, 0xe9, 0xd5, 0xdd, 0xdb, 0x1a, 0x30, 0xa4, 0x4a, 0xa2, 0xb9, 0x9c, 0xe6, 0xe6, 0x35, + 0x9c, 0xf4, 0x85, 0x2, 0x0, 0x15, 0x64, 0x0, 0x4e, 0x81, 0xf2, 0x75, 0x60, 0x98, 0x6, 0x7f, 0x5f, 0xa4, 0xcf, + 0xa8, 0xbf, 0x54, 0x84, 0xb1, 0x22, 0x1c, 0x2a, 0x2, 0x0, 0x7, 0x88, 0x66, 0x37, 0x77, 0xb6, 0x84, 0x27, 0x2, + 0x0, 0xc, 0xdc, 0x77, 0x27, 0xb3, 0x1c, 0x78, 0x79, 0xc2, 0x5b, 0x40, 0xa3, 0x3b, 0x2, 0x0, 0x10, 0x39, 0x48, + 0x86, 0x48, 0xbf, 0xf2, 0x5b, 0xce, 0x53, 0x81, 0xa2, 0xf3, 0xf4, 0x4b, 0x77, 0x24, 0x1}; + + uint8_t buf[215] = {0}; + + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x6, 0xd6, 0x6c, 0x69, 0x2e, 0x1b, 0x1f, 0x3b, 0x3c, + 0x4f, 0x5d, 0x74, 0x3e, 0xc9, 0x7d, 0x33, 0xa5}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x98, 0xad, 0x7b, 0xda, 0xa8, 0x61, 0xb8, 0x59, + 0x5f, 0x79, 0x95, 0xf1, 0x46, 0x3a, 0x79, 0xbc}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x93, 0x1b, 0x8d, 0x48, 0xa6, 0xe2, 0xe6, 0x47, 0xb4, 0xfc, 0xc6, 0xc4, 0x1d}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xec, 0xb7, 0x1e, 0x4d, 0xa9, 0x76, 0xfe, 0xb3, 0x54, 0x54, + 0x37, 0xd3, 0xc2, 0x84, 0xa1, 0x66, 0x62, 0x51, 0xda, 0x1f, + 0x87, 0xca, 0xc, 0x95, 0x45, 0xc5, 0xc5, 0x1, 0x75, 0x4b}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x33, 0xb3, 0x7c, 0x29, 0xde, 0x70, 0xf5, 0x1a, 0xc5, 0xb, 0xb6, + 0x1e, 0x6e, 0x77, 0x23, 0xe1, 0x9d, 0x74, 0x3, 0x12, 0x45}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe9, 0xd5, 0xdd, 0xdb, 0x1a, 0x30, 0xa4, 0x4a, 0xa2, + 0xb9, 0x9c, 0xe6, 0xe6, 0x35, 0x9c, 0xf4, 0x85}; + lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x64, 0x0, 0x4e, 0x81, 0xf2, 0x75, 0x60, 0x98, 0x6, 0x7f, 0x5f, + 0xa4, 0xcf, 0xa8, 0xbf, 0x54, 0x84, 0xb1, 0x22, 0x1c, 0x2a}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x88, 0x66, 0x37, 0x77, 0xb6, 0x84, 0x27}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xdc, 0x77, 0x27, 0xb3, 0x1c, 0x78, 0x79, 0xc2, 0x5b, 0x40, 0xa3, 0x3b}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x39, 0x48, 0x86, 0x48, 0xbf, 0xf2, 0x5b, 0xce, + 0x53, 0x81, 0xa2, 0xf3, 0xf4, 0x4b, 0x77, 0x24}; + lwmqtt_string_t topic_filter_s9 = {16, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10474, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "_\225\NAK\164\f\128V", _pubPktID = -// 0, _pubBody = "\146\161JU\174P\208og\201\149\132e\190\182\\!e\203q\201\194\SYN\147O\178\173{\DC2F", _pubProps = []} -TEST(Publish311QCTest, Encode55) { - uint8_t pkt[] = {0x30, 0x27, 0x0, 0x7, 0x5f, 0xe1, 0x15, 0xa4, 0xc, 0x80, 0x56, 0x92, 0xa1, 0x4a, - 0x55, 0xae, 0x50, 0xd0, 0x6f, 0x67, 0xc9, 0x95, 0x84, 0x65, 0xbe, 0xb6, 0x5c, 0x21, - 0x65, 0xcb, 0x71, 0xc9, 0xc2, 0x16, 0x93, 0x4f, 0xb2, 0xad, 0x7b, 0x12, 0x46}; +// SubscribeRequest 3250 [("x\215}:\240\130\FS\DC3r\185\253t\214\&4\231\195dG<\187\f",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\ETB\236&\173\154\233\&7\EOT~",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("!\CAN\STX\GSG;\179\203\n\224\213",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\208d*\128\&7+\217w\"\f\250\ENQ\189\159\234\236\247\238\ACK0\195",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\155\218X\182O\200\175-#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\219\217L\214\219",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("A\235\201\159~{C\168\132nu\ETB",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\159jI\215+\216\176`\223\230\169\155\239\249q6",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode16) { + uint8_t pkt[] = {0x82, 0x82, 0x1, 0xc, 0xb2, 0x0, 0x15, 0x78, 0xd7, 0x7d, 0x3a, 0xf0, 0x82, 0x1c, 0x13, 0x72, 0xb9, + 0xfd, 0x74, 0xd6, 0x34, 0xe7, 0xc3, 0x64, 0x47, 0x3c, 0xbb, 0xc, 0x0, 0x0, 0x9, 0x17, 0xec, 0x26, + 0xad, 0x9a, 0xe9, 0x37, 0x4, 0x7e, 0x2, 0x0, 0xb, 0x21, 0x18, 0x2, 0x1d, 0x47, 0x3b, 0xb3, 0xcb, + 0xa, 0xe0, 0xd5, 0x0, 0x0, 0x15, 0xd0, 0x64, 0x2a, 0x80, 0x37, 0x2b, 0xd9, 0x77, 0x22, 0xc, 0xfa, + 0x5, 0xbd, 0x9f, 0xea, 0xec, 0xf7, 0xee, 0x6, 0x30, 0xc3, 0x0, 0x0, 0x9, 0x9b, 0xda, 0x58, 0xb6, + 0x4f, 0xc8, 0xaf, 0x2d, 0x23, 0x1, 0x0, 0x5, 0xdb, 0xd9, 0x4c, 0xd6, 0xdb, 0x1, 0x0, 0xc, 0x41, + 0xeb, 0xc9, 0x9f, 0x7e, 0x7b, 0x43, 0xa8, 0x84, 0x6e, 0x75, 0x17, 0x1, 0x0, 0x10, 0x9f, 0x6a, 0x49, + 0xd7, 0x2b, 0xd8, 0xb0, 0x60, 0xdf, 0xe6, 0xa9, 0x9b, 0xef, 0xf9, 0x71, 0x36, 0x1}; - uint8_t buf[51] = {0}; + uint8_t buf[143] = {0}; - uint8_t topic_bytes[] = {0x5f, 0xe1, 0x15, 0xa4, 0xc, 0x80, 0x56}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x92, 0xa1, 0x4a, 0x55, 0xae, 0x50, 0xd0, 0x6f, 0x67, 0xc9, 0x95, 0x84, 0x65, 0xbe, 0xb6, - 0x5c, 0x21, 0x65, 0xcb, 0x71, 0xc9, 0xc2, 0x16, 0x93, 0x4f, 0xb2, 0xad, 0x7b, 0x12, 0x46}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x78, 0xd7, 0x7d, 0x3a, 0xf0, 0x82, 0x1c, 0x13, 0x72, 0xb9, 0xfd, + 0x74, 0xd6, 0x34, 0xe7, 0xc3, 0x64, 0x47, 0x3c, 0xbb, 0xc}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x17, 0xec, 0x26, 0xad, 0x9a, 0xe9, 0x37, 0x4, 0x7e}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x21, 0x18, 0x2, 0x1d, 0x47, 0x3b, 0xb3, 0xcb, 0xa, 0xe0, 0xd5}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd0, 0x64, 0x2a, 0x80, 0x37, 0x2b, 0xd9, 0x77, 0x22, 0xc, 0xfa, + 0x5, 0xbd, 0x9f, 0xea, 0xec, 0xf7, 0xee, 0x6, 0x30, 0xc3}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9b, 0xda, 0x58, 0xb6, 0x4f, 0xc8, 0xaf, 0x2d, 0x23}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xdb, 0xd9, 0x4c, 0xd6, 0xdb}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x41, 0xeb, 0xc9, 0x9f, 0x7e, 0x7b, 0x43, 0xa8, 0x84, 0x6e, 0x75, 0x17}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x9f, 0x6a, 0x49, 0xd7, 0x2b, 0xd8, 0xb0, 0x60, + 0xdf, 0xe6, 0xa9, 0x9b, 0xef, 0xf9, 0x71, 0x36}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3250, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\b\240\fA@\206\204-; -// R\nS$\n\194\ESCh\DC1P2\229\135$", _pubPktID = 32117, _pubBody = "[\a", _pubProps = []} -TEST(Publish311QCTest, Encode56) { - uint8_t pkt[] = {0x35, 0x1e, 0x0, 0x18, 0x8, 0xf0, 0xc, 0x41, 0x40, 0xce, 0xcc, 0x2d, 0x3b, 0x20, 0x52, 0xa, - 0x53, 0x24, 0xa, 0xc2, 0x1b, 0x68, 0x11, 0x50, 0x32, 0xe5, 0x87, 0x24, 0x7d, 0x75, 0x5b, 0x7}; +// SubscribeRequest 12034 +// [("\128.\143\172\255%\203\247\222\207O\146%X\169\204g\245\223\SUB\150#\190tM\173Fw9",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode17) { + uint8_t pkt[] = {0x82, 0x22, 0x2f, 0x2, 0x0, 0x1d, 0x80, 0x2e, 0x8f, 0xac, 0xff, 0x25, + 0xcb, 0xf7, 0xde, 0xcf, 0x4f, 0x92, 0x25, 0x58, 0xa9, 0xcc, 0x67, 0xf5, + 0xdf, 0x1a, 0x96, 0x23, 0xbe, 0x74, 0x4d, 0xad, 0x46, 0x77, 0x39, 0x0}; - uint8_t buf[42] = {0}; + uint8_t buf[46] = {0}; - uint8_t topic_bytes[] = {0x8, 0xf0, 0xc, 0x41, 0x40, 0xce, 0xcc, 0x2d, 0x3b, 0x20, 0x52, 0xa, - 0x53, 0x24, 0xa, 0xc2, 0x1b, 0x68, 0x11, 0x50, 0x32, 0xe5, 0x87, 0x24}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x5b, 0x7}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x80, 0x2e, 0x8f, 0xac, 0xff, 0x25, 0xcb, 0xf7, 0xde, 0xcf, + 0x4f, 0x92, 0x25, 0x58, 0xa9, 0xcc, 0x67, 0xf5, 0xdf, 0x1a, + 0x96, 0x23, 0xbe, 0x74, 0x4d, 0xad, 0x46, 0x77, 0x39}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32117, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12034, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 4596 [("7\239\237\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\201\SI~\174\182\156;o{\142",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\219\b\DLE\SYN\228sb\177\143\195\230o<\196\246f=B",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\135\224?\NUL\161\188\134E\172\&4>1",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),(".\233\181Y\146\&6\140\157\t\205\161Mo\215\&5\186\RSB_\ACK\219\186\f\238",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("1\174\&9\253\135o\201\235\GS\243\240\SYN\177jUy\141\218\158\251\232Pg\161\SYN\SO\162",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\137\&5u\EOT\209\DC4e\177\194H\NAKp;Q\228\b\149\178\182\140\217>!\",\FS\154\163\&1",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\189r\185K\155\247:&\129\FS}\SUB\136\205\198gm\202\183|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode18) { + uint8_t pkt[] = {0x82, 0xb1, 0x1, 0x11, 0xf4, 0x0, 0x4, 0x37, 0xef, 0xed, 0x94, 0x2, 0x0, 0x0, 0x1, 0x0, 0x1, + 0xce, 0x2, 0x0, 0xa, 0xc9, 0xf, 0x7e, 0xae, 0xb6, 0x9c, 0x3b, 0x6f, 0x7b, 0x8e, 0x1, 0x0, 0x12, + 0xdb, 0x8, 0x10, 0x16, 0xe4, 0x73, 0x62, 0xb1, 0x8f, 0xc3, 0xe6, 0x6f, 0x3c, 0xc4, 0xf6, 0x66, 0x3d, + 0x42, 0x2, 0x0, 0xc, 0x87, 0xe0, 0x3f, 0x0, 0xa1, 0xbc, 0x86, 0x45, 0xac, 0x34, 0x3e, 0x31, 0x2, + 0x0, 0x18, 0x2e, 0xe9, 0xb5, 0x59, 0x92, 0x36, 0x8c, 0x9d, 0x9, 0xcd, 0xa1, 0x4d, 0x6f, 0xd7, 0x35, + 0xba, 0x1e, 0x42, 0x5f, 0x6, 0xdb, 0xba, 0xc, 0xee, 0x2, 0x0, 0x1b, 0x31, 0xae, 0x39, 0xfd, 0x87, + 0x6f, 0xc9, 0xeb, 0x1d, 0xf3, 0xf0, 0x16, 0xb1, 0x6a, 0x55, 0x79, 0x8d, 0xda, 0x9e, 0xfb, 0xe8, 0x50, + 0x67, 0xa1, 0x16, 0xe, 0xa2, 0x2, 0x0, 0x1d, 0x89, 0x35, 0x75, 0x4, 0xd1, 0x14, 0x65, 0xb1, 0xc2, + 0x48, 0x15, 0x70, 0x3b, 0x51, 0xe4, 0x8, 0x95, 0xb2, 0xb6, 0x8c, 0xd9, 0x3e, 0x21, 0x22, 0x2c, 0x1c, + 0x9a, 0xa3, 0x31, 0x2, 0x0, 0x14, 0xbd, 0x72, 0xb9, 0x4b, 0x9b, 0xf7, 0x3a, 0x26, 0x81, 0x1c, 0x7d, + 0x1a, 0x88, 0xcd, 0xc6, 0x67, 0x6d, 0xca, 0xb7, 0x7c, 0x0}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[190] = {0}; -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\169\247+\235\ACK\192\145", -// _pubPktID = 0, _pubBody = "\a\197\204\DEL\222\198\153\205\174\176a\153\233u\246\203~z\166\212\229\207sp\US`\225", -// _pubProps = []} -TEST(Publish311QCTest, Encode57) { - uint8_t pkt[] = {0x31, 0x24, 0x0, 0x7, 0xa9, 0xf7, 0x2b, 0xeb, 0x6, 0xc0, 0x91, 0x7, 0xc5, - 0xcc, 0x7f, 0xde, 0xc6, 0x99, 0xcd, 0xae, 0xb0, 0x61, 0x99, 0xe9, 0x75, 0xf6, - 0xcb, 0x7e, 0x7a, 0xa6, 0xd4, 0xe5, 0xcf, 0x73, 0x70, 0x1f, 0x60, 0xe1}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x37, 0xef, 0xed, 0x94}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xce}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc9, 0xf, 0x7e, 0xae, 0xb6, 0x9c, 0x3b, 0x6f, 0x7b, 0x8e}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xdb, 0x8, 0x10, 0x16, 0xe4, 0x73, 0x62, 0xb1, 0x8f, + 0xc3, 0xe6, 0x6f, 0x3c, 0xc4, 0xf6, 0x66, 0x3d, 0x42}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x87, 0xe0, 0x3f, 0x0, 0xa1, 0xbc, 0x86, 0x45, 0xac, 0x34, 0x3e, 0x31}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x2e, 0xe9, 0xb5, 0x59, 0x92, 0x36, 0x8c, 0x9d, 0x9, 0xcd, 0xa1, 0x4d, + 0x6f, 0xd7, 0x35, 0xba, 0x1e, 0x42, 0x5f, 0x6, 0xdb, 0xba, 0xc, 0xee}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x31, 0xae, 0x39, 0xfd, 0x87, 0x6f, 0xc9, 0xeb, 0x1d, 0xf3, 0xf0, 0x16, 0xb1, 0x6a, + 0x55, 0x79, 0x8d, 0xda, 0x9e, 0xfb, 0xe8, 0x50, 0x67, 0xa1, 0x16, 0xe, 0xa2}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x89, 0x35, 0x75, 0x4, 0xd1, 0x14, 0x65, 0xb1, 0xc2, 0x48, + 0x15, 0x70, 0x3b, 0x51, 0xe4, 0x8, 0x95, 0xb2, 0xb6, 0x8c, + 0xd9, 0x3e, 0x21, 0x22, 0x2c, 0x1c, 0x9a, 0xa3, 0x31}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xbd, 0x72, 0xb9, 0x4b, 0x9b, 0xf7, 0x3a, 0x26, 0x81, 0x1c, + 0x7d, 0x1a, 0x88, 0xcd, 0xc6, 0x67, 0x6d, 0xca, 0xb7, 0x7c}; + lwmqtt_string_t topic_filter_s9 = {20, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; - uint8_t buf[48] = {0}; + lwmqtt_property_t propslist[] = {}; - uint8_t topic_bytes[] = {0xa9, 0xf7, 0x2b, 0xeb, 0x6, 0xc0, 0x91}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x7, 0xc5, 0xcc, 0x7f, 0xde, 0xc6, 0x99, 0xcd, 0xae, 0xb0, 0x61, 0x99, 0xe9, 0x75, - 0xf6, 0xcb, 0x7e, 0x7a, 0xa6, 0xd4, 0xe5, 0xcf, 0x73, 0x70, 0x1f, 0x60, 0xe1}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4596, 10, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12163 [("\r\156\"+\229.^L8\n\226%&\152\200\143De",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\233=P\128\f\151\147O\193\209\230l\183\&7Z\153\201\152z:\237\&8\STX\176Z\187\245\253",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\154\238U\255\128\128\129\222",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\178\STX7\173\221\210\128$\v\SOHQ\223\172\129",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("J\179\253\197\215CRg\185\217\STX1\223\&5\213\&17\245y\\h\154\DC4Jz\238\168\243\DC3!",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("G-\208\165h?\SO\131[\DC1",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\193\175\185E?\229\197iQ\ETX\234\174%\176\197\223\197\DLE\233M\211\250X\185wU",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode19) { + uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x2f, 0x83, 0x0, 0x12, 0xd, 0x9c, 0x22, 0x2b, 0xe5, 0x2e, 0x5e, 0x4c, 0x38, + 0xa, 0xe2, 0x25, 0x26, 0x98, 0xc8, 0x8f, 0x44, 0x65, 0x0, 0x0, 0x1c, 0xe9, 0x3d, 0x50, 0x80, + 0xc, 0x97, 0x93, 0x4f, 0xc1, 0xd1, 0xe6, 0x6c, 0xb7, 0x37, 0x5a, 0x99, 0xc9, 0x98, 0x7a, 0x3a, + 0xed, 0x38, 0x2, 0xb0, 0x5a, 0xbb, 0xf5, 0xfd, 0x2, 0x0, 0x8, 0x9a, 0xee, 0x55, 0xff, 0x80, + 0x80, 0x81, 0xde, 0x2, 0x0, 0xe, 0xb2, 0x2, 0x37, 0xad, 0xdd, 0xd2, 0x80, 0x24, 0xb, 0x1, + 0x51, 0xdf, 0xac, 0x81, 0x2, 0x0, 0x1e, 0x4a, 0xb3, 0xfd, 0xc5, 0xd7, 0x43, 0x52, 0x67, 0xb9, + 0xd9, 0x2, 0x31, 0xdf, 0x35, 0xd5, 0x31, 0x37, 0xf5, 0x79, 0x5c, 0x68, 0x9a, 0x14, 0x4a, 0x7a, + 0xee, 0xa8, 0xf3, 0x13, 0x21, 0x0, 0x0, 0xa, 0x47, 0x2d, 0xd0, 0xa5, 0x68, 0x3f, 0xe, 0x83, + 0x5b, 0x11, 0x2, 0x0, 0x1a, 0xc1, 0xaf, 0xb9, 0x45, 0x3f, 0xe5, 0xc5, 0x69, 0x51, 0x3, 0xea, + 0xae, 0x25, 0xb0, 0xc5, 0xdf, 0xc5, 0x10, 0xe9, 0x4d, 0xd3, 0xfa, 0x58, 0xb9, 0x77, 0x55, 0x2}; + + uint8_t buf[170] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xd, 0x9c, 0x22, 0x2b, 0xe5, 0x2e, 0x5e, 0x4c, 0x38, + 0xa, 0xe2, 0x25, 0x26, 0x98, 0xc8, 0x8f, 0x44, 0x65}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xe9, 0x3d, 0x50, 0x80, 0xc, 0x97, 0x93, 0x4f, 0xc1, 0xd1, + 0xe6, 0x6c, 0xb7, 0x37, 0x5a, 0x99, 0xc9, 0x98, 0x7a, 0x3a, + 0xed, 0x38, 0x2, 0xb0, 0x5a, 0xbb, 0xf5, 0xfd}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x9a, 0xee, 0x55, 0xff, 0x80, 0x80, 0x81, 0xde}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb2, 0x2, 0x37, 0xad, 0xdd, 0xd2, 0x80, 0x24, 0xb, 0x1, 0x51, 0xdf, 0xac, 0x81}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x4a, 0xb3, 0xfd, 0xc5, 0xd7, 0x43, 0x52, 0x67, 0xb9, 0xd9, + 0x2, 0x31, 0xdf, 0x35, 0xd5, 0x31, 0x37, 0xf5, 0x79, 0x5c, + 0x68, 0x9a, 0x14, 0x4a, 0x7a, 0xee, 0xa8, 0xf3, 0x13, 0x21}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x47, 0x2d, 0xd0, 0xa5, 0x68, 0x3f, 0xe, 0x83, 0x5b, 0x11}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc1, 0xaf, 0xb9, 0x45, 0x3f, 0xe5, 0xc5, 0x69, 0x51, 0x3, 0xea, 0xae, 0x25, + 0xb0, 0xc5, 0xdf, 0xc5, 0x10, 0xe9, 0x4d, 0xd3, 0xfa, 0x58, 0xb9, 0x77, 0x55}; + lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12163, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\150\251\130\251\166R)\184\\I^\183\212@\189\150\222", _pubPktID = 0, _pubBody = "\139}\228\225\&9", _pubProps = []} -TEST(Publish311QCTest, Encode58) { - uint8_t pkt[] = {0x30, 0x18, 0x0, 0x11, 0x96, 0xfb, 0x82, 0xfb, 0xa6, 0x52, 0x29, 0xb8, 0x5c, - 0x49, 0x5e, 0xb7, 0xd4, 0x40, 0xbd, 0x96, 0xde, 0x8b, 0x7d, 0xe4, 0xe1, 0x39}; +// SubscribeRequest 21672 [(":f\201\245\150t\153",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("g^\195\215\\\138\194\147\188\181W\136",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\163\181\241IK\nA\212\254d\216",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode20) { + uint8_t pkt[] = {0x82, 0x29, 0x54, 0xa8, 0x0, 0x7, 0x3a, 0x66, 0xc9, 0xf5, 0x96, 0x74, 0x99, 0x1, 0x0, + 0xc, 0x67, 0x5e, 0xc3, 0xd7, 0x5c, 0x8a, 0xc2, 0x93, 0xbc, 0xb5, 0x57, 0x88, 0x0, 0x0, + 0xb, 0xa3, 0xb5, 0xf1, 0x49, 0x4b, 0xa, 0x41, 0xd4, 0xfe, 0x64, 0xd8, 0x0}; - uint8_t buf[36] = {0}; + uint8_t buf[53] = {0}; - uint8_t topic_bytes[] = {0x96, 0xfb, 0x82, 0xfb, 0xa6, 0x52, 0x29, 0xb8, 0x5c, - 0x49, 0x5e, 0xb7, 0xd4, 0x40, 0xbd, 0x96, 0xde}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x8b, 0x7d, 0xe4, 0xe1, 0x39}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x3a, 0x66, 0xc9, 0xf5, 0x96, 0x74, 0x99}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x67, 0x5e, 0xc3, 0xd7, 0x5c, 0x8a, 0xc2, 0x93, 0xbc, 0xb5, 0x57, 0x88}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa3, 0xb5, 0xf1, 0x49, 0x4b, 0xa, 0x41, 0xd4, 0xfe, 0x64, 0xd8}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21672, 3, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\161n\174\237\249", _pubPktID = 0, -// _pubBody = "YFq\199\251\158-\155S\194}\250\NULjMrM\ESC/6f\DC3\140", _pubProps = []} -TEST(Publish311QCTest, Encode59) { - uint8_t pkt[] = {0x38, 0x1e, 0x0, 0x5, 0xa1, 0x6e, 0xae, 0xed, 0xf9, 0x59, 0x46, 0x71, 0xc7, 0xfb, 0x9e, 0x2d, - 0x9b, 0x53, 0xc2, 0x7d, 0xfa, 0x0, 0x6a, 0x4d, 0x72, 0x4d, 0x1b, 0x2f, 0x36, 0x66, 0x13, 0x8c}; +// SubscribeRequest 2811 [("\232\155/\190\204\180\EOT\185\187J",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\204\150\224\190\140\164\182\211\159\f`\DC1",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\246te&\248u\229%^L\158\FSG\SYNQPL\237b\SOH\240\185",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k\ETX\f\tX\164\ETX",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode21) { + uint8_t pkt[] = {0x82, 0x41, 0xa, 0xfb, 0x0, 0xa, 0xe8, 0x9b, 0x2f, 0xbe, 0xcc, 0xb4, 0x4, 0xb9, 0xbb, 0x4a, 0x1, + 0x0, 0xc, 0xcc, 0x96, 0xe0, 0xbe, 0x8c, 0xa4, 0xb6, 0xd3, 0x9f, 0xc, 0x60, 0x11, 0x2, 0x0, 0x16, + 0xf6, 0x74, 0x65, 0x26, 0xf8, 0x75, 0xe5, 0x25, 0x5e, 0x4c, 0x9e, 0x1c, 0x47, 0x16, 0x51, 0x50, 0x4c, + 0xed, 0x62, 0x1, 0xf0, 0xb9, 0x0, 0x0, 0x7, 0x6b, 0x3, 0xc, 0x9, 0x58, 0xa4, 0x3, 0x1}; - uint8_t buf[42] = {0}; + uint8_t buf[77] = {0}; - uint8_t topic_bytes[] = {0xa1, 0x6e, 0xae, 0xed, 0xf9}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x59, 0x46, 0x71, 0xc7, 0xfb, 0x9e, 0x2d, 0x9b, 0x53, 0xc2, 0x7d, 0xfa, - 0x0, 0x6a, 0x4d, 0x72, 0x4d, 0x1b, 0x2f, 0x36, 0x66, 0x13, 0x8c}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xe8, 0x9b, 0x2f, 0xbe, 0xcc, 0xb4, 0x4, 0xb9, 0xbb, 0x4a}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xcc, 0x96, 0xe0, 0xbe, 0x8c, 0xa4, 0xb6, 0xd3, 0x9f, 0xc, 0x60, 0x11}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf6, 0x74, 0x65, 0x26, 0xf8, 0x75, 0xe5, 0x25, 0x5e, 0x4c, 0x9e, + 0x1c, 0x47, 0x16, 0x51, 0x50, 0x4c, 0xed, 0x62, 0x1, 0xf0, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6b, 0x3, 0xc, 0x9, 0x58, 0xa4, 0x3}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2811, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 27615 [("\NAK\134\219\&6;\150\&1UX\155\237e\170\221",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("D\188\171\141\181i\189E\145\165\209^\172\DC3\184\&4\DC3\GS\221\USd\169UZ\156]\218",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("U\197\163\225\242\DELe\225y\183n'_\168\130\EOTv\134DS\164\148\vc=\226\240\215",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("%\220\143Z\STX\254s5\230\248\161\215\251k\222j2\132\174X\243\199\DC1\147\231",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\230\199yn\147I\171\f\206\152\247\ACK\246\205\&7i>7\137\ETXi",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("YLH\ETXb\224\237\198\151j\195\234\238",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\NUL4\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode22) { + uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x6b, 0xdf, 0x0, 0xe, 0x15, 0x86, 0xdb, 0x36, 0x3b, 0x96, 0x31, 0x55, 0x58, + 0x9b, 0xed, 0x65, 0xaa, 0xdd, 0x2, 0x0, 0x0, 0x2, 0x0, 0x1b, 0x44, 0xbc, 0xab, 0x8d, 0xb5, + 0x69, 0xbd, 0x45, 0x91, 0xa5, 0xd1, 0x5e, 0xac, 0x13, 0xb8, 0x34, 0x13, 0x1d, 0xdd, 0x1f, 0x64, + 0xa9, 0x55, 0x5a, 0x9c, 0x5d, 0xda, 0x2, 0x0, 0x1c, 0x55, 0xc5, 0xa3, 0xe1, 0xf2, 0x7f, 0x65, + 0xe1, 0x79, 0xb7, 0x6e, 0x27, 0x5f, 0xa8, 0x82, 0x4, 0x76, 0x86, 0x44, 0x53, 0xa4, 0x94, 0xb, + 0x63, 0x3d, 0xe2, 0xf0, 0xd7, 0x2, 0x0, 0x19, 0x25, 0xdc, 0x8f, 0x5a, 0x2, 0xfe, 0x73, 0x35, + 0xe6, 0xf8, 0xa1, 0xd7, 0xfb, 0x6b, 0xde, 0x6a, 0x32, 0x84, 0xae, 0x58, 0xf3, 0xc7, 0x11, 0x93, + 0xe7, 0x1, 0x0, 0x15, 0xe6, 0xc7, 0x79, 0x6e, 0x93, 0x49, 0xab, 0xc, 0xce, 0x98, 0xf7, 0x6, + 0xf6, 0xcd, 0x37, 0x69, 0x3e, 0x37, 0x89, 0x3, 0x69, 0x1, 0x0, 0xd, 0x59, 0x4c, 0x48, 0x3, + 0x62, 0xe0, 0xed, 0xc6, 0x97, 0x6a, 0xc3, 0xea, 0xee, 0x0, 0x0, 0x3, 0x0, 0x34, 0xe8, 0x1}; -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 4694, _pubBody = -// "\137\179ML\236", _pubProps = []} -TEST(Publish311QCTest, Encode60) { - uint8_t pkt[] = {0x3c, 0x9, 0x0, 0x0, 0x12, 0x56, 0x89, 0xb3, 0x4d, 0x4c, 0xec}; - - uint8_t buf[21] = {0}; + uint8_t buf[170] = {0}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x89, 0xb3, 0x4d, 0x4c, 0xec}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x15, 0x86, 0xdb, 0x36, 0x3b, 0x96, 0x31, + 0x55, 0x58, 0x9b, 0xed, 0x65, 0xaa, 0xdd}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x44, 0xbc, 0xab, 0x8d, 0xb5, 0x69, 0xbd, 0x45, 0x91, 0xa5, 0xd1, 0x5e, 0xac, 0x13, + 0xb8, 0x34, 0x13, 0x1d, 0xdd, 0x1f, 0x64, 0xa9, 0x55, 0x5a, 0x9c, 0x5d, 0xda}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x55, 0xc5, 0xa3, 0xe1, 0xf2, 0x7f, 0x65, 0xe1, 0x79, 0xb7, + 0x6e, 0x27, 0x5f, 0xa8, 0x82, 0x4, 0x76, 0x86, 0x44, 0x53, + 0xa4, 0x94, 0xb, 0x63, 0x3d, 0xe2, 0xf0, 0xd7}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x25, 0xdc, 0x8f, 0x5a, 0x2, 0xfe, 0x73, 0x35, 0xe6, 0xf8, 0xa1, 0xd7, 0xfb, + 0x6b, 0xde, 0x6a, 0x32, 0x84, 0xae, 0x58, 0xf3, 0xc7, 0x11, 0x93, 0xe7}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe6, 0xc7, 0x79, 0x6e, 0x93, 0x49, 0xab, 0xc, 0xce, 0x98, 0xf7, + 0x6, 0xf6, 0xcd, 0x37, 0x69, 0x3e, 0x37, 0x89, 0x3, 0x69}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x59, 0x4c, 0x48, 0x3, 0x62, 0xe0, 0xed, 0xc6, 0x97, 0x6a, 0xc3, 0xea, 0xee}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x0, 0x34, 0xe8}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 4694, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27615, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\ETB2\218\142q%", _pubPktID = 16088, -// _pubBody = "\251hR\153\SI\f\226", _pubProps = []} -TEST(Publish311QCTest, Encode61) { - uint8_t pkt[] = {0x33, 0x11, 0x0, 0x6, 0x17, 0x32, 0xda, 0x8e, 0x71, 0x25, - 0x3e, 0xd8, 0xfb, 0x68, 0x52, 0x99, 0xf, 0xc, 0xe2}; +// SubscribeRequest 14083 [("\135\234\FS",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("n\183\&9\DC1f\NUL@\185\255\185qq\STX\"\173\fJ\218\SUB",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\128p\197\DC1\162\160\171\171K\149\206 \ACK\145\202\142",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0x31, 0x37, 0x3, 0x0, 0x3, 0x87, 0xea, 0x1c, 0x2, 0x0, 0x13, 0x6e, 0xb7, 0x39, 0x11, 0x66, + 0x0, 0x40, 0xb9, 0xff, 0xb9, 0x71, 0x71, 0x2, 0x22, 0xad, 0xc, 0x4a, 0xda, 0x1a, 0x1, 0x0, 0x10, + 0x80, 0x70, 0xc5, 0x11, 0xa2, 0xa0, 0xab, 0xab, 0x4b, 0x95, 0xce, 0x20, 0x6, 0x91, 0xca, 0x8e, 0x0}; - uint8_t buf[29] = {0}; + uint8_t buf[61] = {0}; - uint8_t topic_bytes[] = {0x17, 0x32, 0xda, 0x8e, 0x71, 0x25}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xfb, 0x68, 0x52, 0x99, 0xf, 0xc, 0xe2}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x87, 0xea, 0x1c}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6e, 0xb7, 0x39, 0x11, 0x66, 0x0, 0x40, 0xb9, 0xff, 0xb9, + 0x71, 0x71, 0x2, 0x22, 0xad, 0xc, 0x4a, 0xda, 0x1a}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x80, 0x70, 0xc5, 0x11, 0xa2, 0xa0, 0xab, 0xab, + 0x4b, 0x95, 0xce, 0x20, 0x6, 0x91, 0xca, 0x8e}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16088, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14083, 3, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 16713 [("\141D\238n\154\164\246$)\214WR\f v\189\185*\139\r\DLE\ESC\135\SOH\164\132",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\185\139@\EM\a\ETX\186\130\FS\DC4\149\129",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS1}),("\139\211\225\252\160\193\136\130\164\243{3h\210\157/\220\156Eg\147l52",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\254\153c\253\205\198H\213\STX\SYN\139d#\249ON\143{\v\NAK3Iwz\EOT|\GS\ESC:^",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode24) { + uint8_t pkt[] = {0x82, 0x6a, 0x41, 0x49, 0x0, 0x1a, 0x8d, 0x44, 0xee, 0x6e, 0x9a, 0xa4, 0xf6, 0x24, 0x29, 0xd6, + 0x57, 0x52, 0xc, 0x20, 0x76, 0xbd, 0xb9, 0x2a, 0x8b, 0xd, 0x10, 0x1b, 0x87, 0x1, 0xa4, 0x84, + 0x2, 0x0, 0xc, 0xb9, 0x8b, 0x40, 0x19, 0x7, 0x3, 0xba, 0x82, 0x1c, 0x14, 0x95, 0x81, 0x1, + 0x0, 0x18, 0x8b, 0xd3, 0xe1, 0xfc, 0xa0, 0xc1, 0x88, 0x82, 0xa4, 0xf3, 0x7b, 0x33, 0x68, 0xd2, + 0x9d, 0x2f, 0xdc, 0x9c, 0x45, 0x67, 0x93, 0x6c, 0x35, 0x32, 0x1, 0x0, 0x1e, 0xfe, 0x99, 0x63, + 0xfd, 0xcd, 0xc6, 0x48, 0xd5, 0x2, 0x16, 0x8b, 0x64, 0x23, 0xf9, 0x4f, 0x4e, 0x8f, 0x7b, 0xb, + 0x15, 0x33, 0x49, 0x77, 0x7a, 0x4, 0x7c, 0x1d, 0x1b, 0x3a, 0x5e, 0x2}; + + uint8_t buf[118] = {0}; + + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x8d, 0x44, 0xee, 0x6e, 0x9a, 0xa4, 0xf6, 0x24, 0x29, 0xd6, 0x57, 0x52, 0xc, + 0x20, 0x76, 0xbd, 0xb9, 0x2a, 0x8b, 0xd, 0x10, 0x1b, 0x87, 0x1, 0xa4, 0x84}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb9, 0x8b, 0x40, 0x19, 0x7, 0x3, 0xba, 0x82, 0x1c, 0x14, 0x95, 0x81}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x8b, 0xd3, 0xe1, 0xfc, 0xa0, 0xc1, 0x88, 0x82, 0xa4, 0xf3, 0x7b, 0x33, + 0x68, 0xd2, 0x9d, 0x2f, 0xdc, 0x9c, 0x45, 0x67, 0x93, 0x6c, 0x35, 0x32}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xfe, 0x99, 0x63, 0xfd, 0xcd, 0xc6, 0x48, 0xd5, 0x2, 0x16, + 0x8b, 0x64, 0x23, 0xf9, 0x4f, 0x4e, 0x8f, 0x7b, 0xb, 0x15, + 0x33, 0x49, 0x77, 0x7a, 0x4, 0x7c, 0x1d, 0x1b, 0x3a, 0x5e}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = {}; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\DC3\188\&0\t6w\FS", _pubPktID = -// 7577, _pubBody = "9\176{\185\134p\216\206\208\GS\EM?", _pubProps = []} -TEST(Publish311QCTest, Encode62) { - uint8_t pkt[] = {0x32, 0x17, 0x0, 0x7, 0x13, 0xbc, 0x30, 0x9, 0x36, 0x77, 0x1c, 0x1d, 0x99, - 0x39, 0xb0, 0x7b, 0xb9, 0x86, 0x70, 0xd8, 0xce, 0xd0, 0x1d, 0x19, 0x3f}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16713, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 25471 [(" +// g\199\217\146\253&\DC3\235\b\186\200\t\171\254\172\FS\140m\DC3\CAN\238F\224\187\190\171\242",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\179hw\206r\aC\GS\159\n\206\SUB\255$mE\EOTm]\210A\224",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("Vd\170\246\&2\v",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\230\130+\153\214\164\236\ENQas\251\192}h)\SOH\ESC{\189=\190\235'w\202\225\&4\223\ACK",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\221\&8F\142\&7\197\DC4\193\151\193@\EOT\151\ACK\146\157\239\149\STX\181\220\148\157\STX\224",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("l\160\229\230\146",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode25) { + uint8_t pkt[] = {0x82, 0x8a, 0x1, 0x63, 0x7f, 0x0, 0x1c, 0x20, 0x67, 0xc7, 0xd9, 0x92, 0xfd, 0x26, 0x13, 0xeb, + 0x8, 0xba, 0xc8, 0x9, 0xab, 0xfe, 0xac, 0x1c, 0x8c, 0x6d, 0x13, 0x18, 0xee, 0x46, 0xe0, 0xbb, + 0xbe, 0xab, 0xf2, 0x0, 0x0, 0x0, 0x1, 0x0, 0x16, 0xb3, 0x68, 0x77, 0xce, 0x72, 0x7, 0x43, + 0x1d, 0x9f, 0xa, 0xce, 0x1a, 0xff, 0x24, 0x6d, 0x45, 0x4, 0x6d, 0x5d, 0xd2, 0x41, 0xe0, 0x0, + 0x0, 0x6, 0x56, 0x64, 0xaa, 0xf6, 0x32, 0xb, 0x1, 0x0, 0x1d, 0xe6, 0x82, 0x2b, 0x99, 0xd6, + 0xa4, 0xec, 0x5, 0x61, 0x73, 0xfb, 0xc0, 0x7d, 0x68, 0x29, 0x1, 0x1b, 0x7b, 0xbd, 0x3d, 0xbe, + 0xeb, 0x27, 0x77, 0xca, 0xe1, 0x34, 0xdf, 0x6, 0x1, 0x0, 0x19, 0xdd, 0x38, 0x46, 0x8e, 0x37, + 0xc5, 0x14, 0xc1, 0x97, 0xc1, 0x40, 0x4, 0x97, 0x6, 0x92, 0x9d, 0xef, 0x95, 0x2, 0xb5, 0xdc, + 0x94, 0x9d, 0x2, 0xe0, 0x1, 0x0, 0x5, 0x6c, 0xa0, 0xe5, 0xe6, 0x92, 0x0}; + + uint8_t buf[151] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x20, 0x67, 0xc7, 0xd9, 0x92, 0xfd, 0x26, 0x13, 0xeb, 0x8, + 0xba, 0xc8, 0x9, 0xab, 0xfe, 0xac, 0x1c, 0x8c, 0x6d, 0x13, + 0x18, 0xee, 0x46, 0xe0, 0xbb, 0xbe, 0xab, 0xf2}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb3, 0x68, 0x77, 0xce, 0x72, 0x7, 0x43, 0x1d, 0x9f, 0xa, 0xce, + 0x1a, 0xff, 0x24, 0x6d, 0x45, 0x4, 0x6d, 0x5d, 0xd2, 0x41, 0xe0}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x56, 0x64, 0xaa, 0xf6, 0x32, 0xb}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe6, 0x82, 0x2b, 0x99, 0xd6, 0xa4, 0xec, 0x5, 0x61, 0x73, + 0xfb, 0xc0, 0x7d, 0x68, 0x29, 0x1, 0x1b, 0x7b, 0xbd, 0x3d, + 0xbe, 0xeb, 0x27, 0x77, 0xca, 0xe1, 0x34, 0xdf, 0x6}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xdd, 0x38, 0x46, 0x8e, 0x37, 0xc5, 0x14, 0xc1, 0x97, 0xc1, 0x40, 0x4, 0x97, + 0x6, 0x92, 0x9d, 0xef, 0x95, 0x2, 0xb5, 0xdc, 0x94, 0x9d, 0x2, 0xe0}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x6c, 0xa0, 0xe5, 0xe6, 0x92}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; - uint8_t buf[35] = {0}; + lwmqtt_property_t propslist[] = {}; - uint8_t topic_bytes[] = {0x13, 0xbc, 0x30, 0x9, 0x36, 0x77, 0x1c}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x39, 0xb0, 0x7b, 0xb9, 0x86, 0x70, 0xd8, 0xce, 0xd0, 0x1d, 0x19, 0x3f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25471, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 10657 [("\ENQ4\f\143\197\ENQ\145\193\247\141\221i\199\192\173\223",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\188\156\DC3\177\134%\161",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\\\222\217\&5\226r",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\176c\ESCP\163\GSx\DC3",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("G\ENQ\204\136\fTN\163\214\228\254eHG\166\CAN\210\146>",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\172\144=\175\\\ESC\f\226\179v\175\164D$R9\211",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("S\242\171\242\STX\221\188uJ\199l\155\137\232\\\135\187\141\SYN\217",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\NAK\205\STX\156\ENQ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\161\200eM1\161*\234\207\198\169\252.\DC2nE\230\227HE8\135\164\244",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("al}\149\EOT(\233\DLE\STX\233\208\183ui-F\t",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode26) { + uint8_t pkt[] = {0x82, 0xab, 0x1, 0x29, 0xa1, 0x0, 0x10, 0x5, 0x34, 0xc, 0x8f, 0xc5, 0x5, 0x91, 0xc1, 0xf7, + 0x8d, 0xdd, 0x69, 0xc7, 0xc0, 0xad, 0xdf, 0x2, 0x0, 0x7, 0xbc, 0x9c, 0x13, 0xb1, 0x86, 0x25, + 0xa1, 0x0, 0x0, 0x6, 0x5c, 0xde, 0xd9, 0x35, 0xe2, 0x72, 0x2, 0x0, 0x8, 0xb0, 0x63, 0x1b, + 0x50, 0xa3, 0x1d, 0x78, 0x13, 0x1, 0x0, 0x13, 0x47, 0x5, 0xcc, 0x88, 0xc, 0x54, 0x4e, 0xa3, + 0xd6, 0xe4, 0xfe, 0x65, 0x48, 0x47, 0xa6, 0x18, 0xd2, 0x92, 0x3e, 0x1, 0x0, 0x11, 0xac, 0x90, + 0x3d, 0xaf, 0x5c, 0x1b, 0xc, 0xe2, 0xb3, 0x76, 0xaf, 0xa4, 0x44, 0x24, 0x52, 0x39, 0xd3, 0x1, + 0x0, 0x14, 0x53, 0xf2, 0xab, 0xf2, 0x2, 0xdd, 0xbc, 0x75, 0x4a, 0xc7, 0x6c, 0x9b, 0x89, 0xe8, + 0x5c, 0x87, 0xbb, 0x8d, 0x16, 0xd9, 0x1, 0x0, 0x5, 0x15, 0xcd, 0x2, 0x9c, 0x5, 0x1, 0x0, + 0x18, 0xa1, 0xc8, 0x65, 0x4d, 0x31, 0xa1, 0x2a, 0xea, 0xcf, 0xc6, 0xa9, 0xfc, 0x2e, 0x12, 0x6e, + 0x45, 0xe6, 0xe3, 0x48, 0x45, 0x38, 0x87, 0xa4, 0xf4, 0x1, 0x0, 0x11, 0x61, 0x6c, 0x7d, 0x95, + 0x4, 0x28, 0xe9, 0x10, 0x2, 0xe9, 0xd0, 0xb7, 0x75, 0x69, 0x2d, 0x46, 0x9, 0x2}; + + uint8_t buf[184] = {0}; + + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x5, 0x34, 0xc, 0x8f, 0xc5, 0x5, 0x91, 0xc1, + 0xf7, 0x8d, 0xdd, 0x69, 0xc7, 0xc0, 0xad, 0xdf}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xbc, 0x9c, 0x13, 0xb1, 0x86, 0x25, 0xa1}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5c, 0xde, 0xd9, 0x35, 0xe2, 0x72}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb0, 0x63, 0x1b, 0x50, 0xa3, 0x1d, 0x78, 0x13}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x47, 0x5, 0xcc, 0x88, 0xc, 0x54, 0x4e, 0xa3, 0xd6, 0xe4, + 0xfe, 0x65, 0x48, 0x47, 0xa6, 0x18, 0xd2, 0x92, 0x3e}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xac, 0x90, 0x3d, 0xaf, 0x5c, 0x1b, 0xc, 0xe2, 0xb3, + 0x76, 0xaf, 0xa4, 0x44, 0x24, 0x52, 0x39, 0xd3}; + lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x53, 0xf2, 0xab, 0xf2, 0x2, 0xdd, 0xbc, 0x75, 0x4a, 0xc7, + 0x6c, 0x9b, 0x89, 0xe8, 0x5c, 0x87, 0xbb, 0x8d, 0x16, 0xd9}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x15, 0xcd, 0x2, 0x9c, 0x5}; + lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa1, 0xc8, 0x65, 0x4d, 0x31, 0xa1, 0x2a, 0xea, 0xcf, 0xc6, 0xa9, 0xfc, + 0x2e, 0x12, 0x6e, 0x45, 0xe6, 0xe3, 0x48, 0x45, 0x38, 0x87, 0xa4, 0xf4}; + lwmqtt_string_t topic_filter_s8 = {24, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x61, 0x6c, 0x7d, 0x95, 0x4, 0x28, 0xe9, 0x10, 0x2, + 0xe9, 0xd0, 0xb7, 0x75, 0x69, 0x2d, 0x46, 0x9}; + lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7577, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10657, 10, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 15036 [("\ETB\177\238\199$\NUL\128\209",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("3r:\DC1c[upm\234_c`\195V\252C\vu\153\196",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("g\238\250",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("\183\236\166\159+\v\b\SI\149\DC2\247\&1",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\ESCd\242\134N\161i\169\135\230\198m\163\166\229\247e\211E",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("Y\216\242f(\ETX=\152\ESC\208?B|\197\n\198Z\148\153\199\f\r\\n5\137#4",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode27) { + uint8_t pkt[] = {0x82, 0x6f, 0x3a, 0xbc, 0x0, 0x8, 0x17, 0xb1, 0xee, 0xc7, 0x24, 0x0, 0x80, 0xd1, 0x0, 0x0, 0x15, + 0x33, 0x72, 0x3a, 0x11, 0x63, 0x5b, 0x75, 0x70, 0x6d, 0xea, 0x5f, 0x63, 0x60, 0xc3, 0x56, 0xfc, 0x43, + 0xb, 0x75, 0x99, 0xc4, 0x1, 0x0, 0x3, 0x67, 0xee, 0xfa, 0x0, 0x0, 0xc, 0xb7, 0xec, 0xa6, 0x9f, + 0x2b, 0xb, 0x8, 0xf, 0x95, 0x12, 0xf7, 0x31, 0x2, 0x0, 0x13, 0x1b, 0x64, 0xf2, 0x86, 0x4e, 0xa1, + 0x69, 0xa9, 0x87, 0xe6, 0xc6, 0x6d, 0xa3, 0xa6, 0xe5, 0xf7, 0x65, 0xd3, 0x45, 0x0, 0x0, 0x1c, 0x59, + 0xd8, 0xf2, 0x66, 0x28, 0x3, 0x3d, 0x98, 0x1b, 0xd0, 0x3f, 0x42, 0x7c, 0xc5, 0xa, 0xc6, 0x5a, 0x94, + 0x99, 0xc7, 0xc, 0xd, 0x5c, 0x6e, 0x35, 0x89, 0x23, 0x34, 0x1}; + + uint8_t buf[123] = {0}; + + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x17, 0xb1, 0xee, 0xc7, 0x24, 0x0, 0x80, 0xd1}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x33, 0x72, 0x3a, 0x11, 0x63, 0x5b, 0x75, 0x70, 0x6d, 0xea, 0x5f, + 0x63, 0x60, 0xc3, 0x56, 0xfc, 0x43, 0xb, 0x75, 0x99, 0xc4}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x67, 0xee, 0xfa}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb7, 0xec, 0xa6, 0x9f, 0x2b, 0xb, 0x8, 0xf, 0x95, 0x12, 0xf7, 0x31}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x1b, 0x64, 0xf2, 0x86, 0x4e, 0xa1, 0x69, 0xa9, 0x87, 0xe6, + 0xc6, 0x6d, 0xa3, 0xa6, 0xe5, 0xf7, 0x65, 0xd3, 0x45}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x59, 0xd8, 0xf2, 0x66, 0x28, 0x3, 0x3d, 0x98, 0x1b, 0xd0, + 0x3f, 0x42, 0x7c, 0xc5, 0xa, 0xc6, 0x5a, 0x94, 0x99, 0xc7, + 0xc, 0xd, 0x5c, 0x6e, 0x35, 0x89, 0x23, 0x34}; + lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = {}; -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\DC2a\165\SO(\131\154\NAKm\b\STX\243\250\178\197H", _pubPktID = 13200, _pubBody = "\164V\204\140", _pubProps = []} -TEST(Publish311QCTest, Encode63) { - uint8_t pkt[] = {0x3c, 0x18, 0x0, 0x10, 0x12, 0x61, 0xa5, 0xe, 0x28, 0x83, 0x9a, 0x15, 0x6d, - 0x8, 0x2, 0xf3, 0xfa, 0xb2, 0xc5, 0x48, 0x33, 0x90, 0xa4, 0x56, 0xcc, 0x8c}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15036, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 2876 [("\143\161\221\224\191",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("rT\145\ay\160\215s,\146c\129\150>@!/\217\141",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\r\184\142p\151\204\170\249\180/\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\235\167\DLE\217\198\169\175\SI\182\ESC",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("G\130\214\&0\b\EM/\194\249\193\148`\222\217\ETXQZ\251\&7\n\147k\254\158t\249\130\219-E",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\SO\205\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("\175\GS\210~\190\GS\178\&9\230=\236|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\213\RSA\148\250i2Cbmo\147D\254\170\&33p\218\CAN\232\206\SO\142\&7",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\169\DEL\233~\135W\168q\226\158\197\227\151}9",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode28) { + uint8_t pkt[] = {0x82, 0xa2, 0x1, 0xb, 0x3c, 0x0, 0x5, 0x8f, 0xa1, 0xdd, 0xe0, 0xbf, 0x1, 0x0, 0x13, 0x72, 0x54, + 0x91, 0x7, 0x79, 0xa0, 0xd7, 0x73, 0x2c, 0x92, 0x63, 0x81, 0x96, 0x3e, 0x40, 0x21, 0x2f, 0xd9, 0x8d, + 0x0, 0x0, 0x0, 0x0, 0x0, 0xb, 0xd, 0xb8, 0x8e, 0x70, 0x97, 0xcc, 0xaa, 0xf9, 0xb4, 0x2f, 0xd2, + 0x1, 0x0, 0xa, 0xeb, 0xa7, 0x10, 0xd9, 0xc6, 0xa9, 0xaf, 0xf, 0xb6, 0x1b, 0x1, 0x0, 0x1e, 0x47, + 0x82, 0xd6, 0x30, 0x8, 0x19, 0x2f, 0xc2, 0xf9, 0xc1, 0x94, 0x60, 0xde, 0xd9, 0x3, 0x51, 0x5a, 0xfb, + 0x37, 0xa, 0x93, 0x6b, 0xfe, 0x9e, 0x74, 0xf9, 0x82, 0xdb, 0x2d, 0x45, 0x0, 0x0, 0x3, 0xe, 0xcd, + 0xce, 0x2, 0x0, 0xc, 0xaf, 0x1d, 0xd2, 0x7e, 0xbe, 0x1d, 0xb2, 0x39, 0xe6, 0x3d, 0xec, 0x7c, 0x2, + 0x0, 0x19, 0xd5, 0x1e, 0x41, 0x94, 0xfa, 0x69, 0x32, 0x43, 0x62, 0x6d, 0x6f, 0x93, 0x44, 0xfe, 0xaa, + 0x33, 0x33, 0x70, 0xda, 0x18, 0xe8, 0xce, 0xe, 0x8e, 0x37, 0x1, 0x0, 0xf, 0xa9, 0x7f, 0xe9, 0x7e, + 0x87, 0x57, 0xa8, 0x71, 0xe2, 0x9e, 0xc5, 0xe3, 0x97, 0x7d, 0x39, 0x2}; - uint8_t buf[36] = {0}; + uint8_t buf[175] = {0}; - uint8_t topic_bytes[] = {0x12, 0x61, 0xa5, 0xe, 0x28, 0x83, 0x9a, 0x15, 0x6d, 0x8, 0x2, 0xf3, 0xfa, 0xb2, 0xc5, 0x48}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xa4, 0x56, 0xcc, 0x8c}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x8f, 0xa1, 0xdd, 0xe0, 0xbf}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x72, 0x54, 0x91, 0x7, 0x79, 0xa0, 0xd7, 0x73, 0x2c, 0x92, + 0x63, 0x81, 0x96, 0x3e, 0x40, 0x21, 0x2f, 0xd9, 0x8d}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd, 0xb8, 0x8e, 0x70, 0x97, 0xcc, 0xaa, 0xf9, 0xb4, 0x2f, 0xd2}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xeb, 0xa7, 0x10, 0xd9, 0xc6, 0xa9, 0xaf, 0xf, 0xb6, 0x1b}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x47, 0x82, 0xd6, 0x30, 0x8, 0x19, 0x2f, 0xc2, 0xf9, 0xc1, + 0x94, 0x60, 0xde, 0xd9, 0x3, 0x51, 0x5a, 0xfb, 0x37, 0xa, + 0x93, 0x6b, 0xfe, 0x9e, 0x74, 0xf9, 0x82, 0xdb, 0x2d, 0x45}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xe, 0xcd, 0xce}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xaf, 0x1d, 0xd2, 0x7e, 0xbe, 0x1d, 0xb2, 0x39, 0xe6, 0x3d, 0xec, 0x7c}; + lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd5, 0x1e, 0x41, 0x94, 0xfa, 0x69, 0x32, 0x43, 0x62, 0x6d, 0x6f, 0x93, 0x44, + 0xfe, 0xaa, 0x33, 0x33, 0x70, 0xda, 0x18, 0xe8, 0xce, 0xe, 0x8e, 0x37}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa9, 0x7f, 0xe9, 0x7e, 0x87, 0x57, 0xa8, 0x71, + 0xe2, 0x9e, 0xc5, 0xe3, 0x97, 0x7d, 0x39}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13200, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2876, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\136\199\135\133\171\252+\211d\DC3\\\170>\250\GS\GS\250\ETX\238", _pubPktID = 15457, _pubBody = -// "f\244\166\DLE\197\195\242\206\199<\FS\ETB$\STX \236\135\235\232\196\229\b`n\216,v\233V\177", _pubProps = []} -TEST(Publish311QCTest, Encode64) { - uint8_t pkt[] = {0x3b, 0x35, 0x0, 0x13, 0x88, 0xc7, 0x87, 0x85, 0xab, 0xfc, 0x2b, 0xd3, 0x64, 0x13, - 0x5c, 0xaa, 0x3e, 0xfa, 0x1d, 0x1d, 0xfa, 0x3, 0xee, 0x3c, 0x61, 0x66, 0xf4, 0xa6, - 0x10, 0xc5, 0xc3, 0xf2, 0xce, 0xc7, 0x3c, 0x1c, 0x17, 0x24, 0x2, 0x20, 0xec, 0x87, - 0xeb, 0xe8, 0xc4, 0xe5, 0x8, 0x60, 0x6e, 0xd8, 0x2c, 0x76, 0xe9, 0x56, 0xb1}; +// SubscribeRequest 30960 [("\185\236\245\223\167kV\209\203\206v",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("`\208\168\173\228W\128\NUL\ESC\220\215\244'8\132 +// \151\&8\151\138\SO\228g",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\196b\128&>\147\253\195D\218\SI\NAK\EOT\ETBV\195\140\"s\215\166Z:9",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("=|\155\128\168\238V\248\201^w7\200+\247\FS\194\185\218\184",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode29) { + uint8_t pkt[] = {0x82, 0x5f, 0x78, 0xf0, 0x0, 0xb, 0xb9, 0xec, 0xf5, 0xdf, 0xa7, 0x6b, 0x56, 0xd1, 0xcb, 0xce, 0x76, + 0x1, 0x0, 0x0, 0x2, 0x0, 0x17, 0x60, 0xd0, 0xa8, 0xad, 0xe4, 0x57, 0x80, 0x0, 0x1b, 0xdc, 0xd7, + 0xf4, 0x27, 0x38, 0x84, 0x20, 0x97, 0x38, 0x97, 0x8a, 0xe, 0xe4, 0x67, 0x1, 0x0, 0x18, 0xc4, 0x62, + 0x80, 0x26, 0x3e, 0x93, 0xfd, 0xc3, 0x44, 0xda, 0xf, 0x15, 0x4, 0x17, 0x56, 0xc3, 0x8c, 0x22, 0x73, + 0xd7, 0xa6, 0x5a, 0x3a, 0x39, 0x2, 0x0, 0x14, 0x3d, 0x7c, 0x9b, 0x80, 0xa8, 0xee, 0x56, 0xf8, 0xc9, + 0x5e, 0x77, 0x37, 0xc8, 0x2b, 0xf7, 0x1c, 0xc2, 0xb9, 0xda, 0xb8, 0x1}; - uint8_t buf[65] = {0}; + uint8_t buf[107] = {0}; - uint8_t topic_bytes[] = {0x88, 0xc7, 0x87, 0x85, 0xab, 0xfc, 0x2b, 0xd3, 0x64, 0x13, - 0x5c, 0xaa, 0x3e, 0xfa, 0x1d, 0x1d, 0xfa, 0x3, 0xee}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x66, 0xf4, 0xa6, 0x10, 0xc5, 0xc3, 0xf2, 0xce, 0xc7, 0x3c, 0x1c, 0x17, 0x24, 0x2, 0x20, - 0xec, 0x87, 0xeb, 0xe8, 0xc4, 0xe5, 0x8, 0x60, 0x6e, 0xd8, 0x2c, 0x76, 0xe9, 0x56, 0xb1}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xb9, 0xec, 0xf5, 0xdf, 0xa7, 0x6b, 0x56, 0xd1, 0xcb, 0xce, 0x76}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x60, 0xd0, 0xa8, 0xad, 0xe4, 0x57, 0x80, 0x0, 0x1b, 0xdc, 0xd7, 0xf4, + 0x27, 0x38, 0x84, 0x20, 0x97, 0x38, 0x97, 0x8a, 0xe, 0xe4, 0x67}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc4, 0x62, 0x80, 0x26, 0x3e, 0x93, 0xfd, 0xc3, 0x44, 0xda, 0xf, 0x15, + 0x4, 0x17, 0x56, 0xc3, 0x8c, 0x22, 0x73, 0xd7, 0xa6, 0x5a, 0x3a, 0x39}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x3d, 0x7c, 0x9b, 0x80, 0xa8, 0xee, 0x56, 0xf8, 0xc9, 0x5e, + 0x77, 0x37, 0xc8, 0x2b, 0xf7, 0x1c, 0xc2, 0xb9, 0xda, 0xb8}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 15457, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30960, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 29420, _pubBody = -// "F\146\254\ETB\174Cu^\188$\218\201\215$\253\&7\184\236S\169\243\ETXn\180\US\fC\220\137\SYN", _pubProps = []} -TEST(Publish311QCTest, Encode65) { - uint8_t pkt[] = {0x33, 0x22, 0x0, 0x0, 0x72, 0xec, 0x46, 0x92, 0xfe, 0x17, 0xae, 0x43, - 0x75, 0x5e, 0xbc, 0x24, 0xda, 0xc9, 0xd7, 0x24, 0xfd, 0x37, 0xb8, 0xec, - 0x53, 0xa9, 0xf3, 0x3, 0x6e, 0xb4, 0x1f, 0xc, 0x43, 0xdc, 0x89, 0x16}; +// SubscribeRequest 19821 [("\162",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\200\151\208c\FS\228\171\229\143c\210\no\DC1F(\147w\158",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("w\206\216e\255h\237\252\178.",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\196)\168x0\242\199\SI\251\223L\150\183\234\205\197\137`\215'\aD\164\EOT5\148\ETB\189",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode30) { + uint8_t pkt[] = {0x82, 0x48, 0x4d, 0x6d, 0x0, 0x1, 0xa2, 0x2, 0x0, 0x13, 0xc8, 0x97, 0xd0, 0x63, 0x1c, + 0xe4, 0xab, 0xe5, 0x8f, 0x63, 0xd2, 0xa, 0x6f, 0x11, 0x46, 0x28, 0x93, 0x77, 0x9e, 0x1, + 0x0, 0xa, 0x77, 0xce, 0xd8, 0x65, 0xff, 0x68, 0xed, 0xfc, 0xb2, 0x2e, 0x2, 0x0, 0x1c, + 0xc4, 0x29, 0xa8, 0x78, 0x30, 0xf2, 0xc7, 0xf, 0xfb, 0xdf, 0x4c, 0x96, 0xb7, 0xea, 0xcd, + 0xc5, 0x89, 0x60, 0xd7, 0x27, 0x7, 0x44, 0xa4, 0x4, 0x35, 0x94, 0x17, 0xbd, 0x2}; - uint8_t buf[46] = {0}; + uint8_t buf[84] = {0}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x46, 0x92, 0xfe, 0x17, 0xae, 0x43, 0x75, 0x5e, 0xbc, 0x24, 0xda, 0xc9, 0xd7, 0x24, 0xfd, - 0x37, 0xb8, 0xec, 0x53, 0xa9, 0xf3, 0x3, 0x6e, 0xb4, 0x1f, 0xc, 0x43, 0xdc, 0x89, 0x16}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xa2}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc8, 0x97, 0xd0, 0x63, 0x1c, 0xe4, 0xab, 0xe5, 0x8f, 0x63, + 0xd2, 0xa, 0x6f, 0x11, 0x46, 0x28, 0x93, 0x77, 0x9e}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x77, 0xce, 0xd8, 0x65, 0xff, 0x68, 0xed, 0xfc, 0xb2, 0x2e}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc4, 0x29, 0xa8, 0x78, 0x30, 0xf2, 0xc7, 0xf, 0xfb, 0xdf, + 0x4c, 0x96, 0xb7, 0xea, 0xcd, 0xc5, 0x89, 0x60, 0xd7, 0x27, + 0x7, 0x44, 0xa4, 0x4, 0x35, 0x94, 0x17, 0xbd}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29420, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19821, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 21770 +// [("\139=b\145p\157\223b|\STX[\197\203\167e^\171\235\151}k\149\EOT\132\SO\239\218\159\152",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\ACK\227+\134\ETB\170\253\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\148-\198\ACKO:X\191\162",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\128\150\&7\b\f^g\182Dr\t8k\240\170\&7",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("jBu\DC1!5\207\193K6\164\a\EOT\189m\169\154}\186\220\246\141\&8\167\GS\184\RS\192",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("s\207#\r\188b4B|f>\135\234\142\&7\202\154\186",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode31) { + uint8_t pkt[] = {0x82, 0x80, 0x1, 0x55, 0xa, 0x0, 0x1d, 0x8b, 0x3d, 0x62, 0x91, 0x70, 0x9d, 0xdf, 0x62, 0x7c, 0x2, + 0x5b, 0xc5, 0xcb, 0xa7, 0x65, 0x5e, 0xab, 0xeb, 0x97, 0x7d, 0x6b, 0x95, 0x4, 0x84, 0xe, 0xef, 0xda, + 0x9f, 0x98, 0x1, 0x0, 0x8, 0x6, 0xe3, 0x2b, 0x86, 0x17, 0xaa, 0xfd, 0xa6, 0x2, 0x0, 0x9, 0x94, + 0x2d, 0xc6, 0x6, 0x4f, 0x3a, 0x58, 0xbf, 0xa2, 0x2, 0x0, 0x10, 0x80, 0x96, 0x37, 0x8, 0xc, 0x5e, + 0x67, 0xb6, 0x44, 0x72, 0x9, 0x38, 0x6b, 0xf0, 0xaa, 0x37, 0x1, 0x0, 0x1c, 0x6a, 0x42, 0x75, 0x11, + 0x21, 0x35, 0xcf, 0xc1, 0x4b, 0x36, 0xa4, 0x7, 0x4, 0xbd, 0x6d, 0xa9, 0x9a, 0x7d, 0xba, 0xdc, 0xf6, + 0x8d, 0x38, 0xa7, 0x1d, 0xb8, 0x1e, 0xc0, 0x2, 0x0, 0x12, 0x73, 0xcf, 0x23, 0xd, 0xbc, 0x62, 0x34, + 0x42, 0x7c, 0x66, 0x3e, 0x87, 0xea, 0x8e, 0x37, 0xca, 0x9a, 0xba, 0x1}; + + uint8_t buf[141] = {0}; + + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x8b, 0x3d, 0x62, 0x91, 0x70, 0x9d, 0xdf, 0x62, 0x7c, 0x2, + 0x5b, 0xc5, 0xcb, 0xa7, 0x65, 0x5e, 0xab, 0xeb, 0x97, 0x7d, + 0x6b, 0x95, 0x4, 0x84, 0xe, 0xef, 0xda, 0x9f, 0x98}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6, 0xe3, 0x2b, 0x86, 0x17, 0xaa, 0xfd, 0xa6}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x94, 0x2d, 0xc6, 0x6, 0x4f, 0x3a, 0x58, 0xbf, 0xa2}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x80, 0x96, 0x37, 0x8, 0xc, 0x5e, 0x67, 0xb6, + 0x44, 0x72, 0x9, 0x38, 0x6b, 0xf0, 0xaa, 0x37}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x6a, 0x42, 0x75, 0x11, 0x21, 0x35, 0xcf, 0xc1, 0x4b, 0x36, + 0xa4, 0x7, 0x4, 0xbd, 0x6d, 0xa9, 0x9a, 0x7d, 0xba, 0xdc, + 0xf6, 0x8d, 0x38, 0xa7, 0x1d, 0xb8, 0x1e, 0xc0}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x73, 0xcf, 0x23, 0xd, 0xbc, 0x62, 0x34, 0x42, 0x7c, + 0x66, 0x3e, 0x87, 0xea, 0x8e, 0x37, 0xca, 0x9a, 0xba}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\220\DC4\187\155", _pubPktID = -// 28673, _pubBody = "\160\255\248\156YF\148S\164\194~\t\212\134\149`\202l", _pubProps = []} -TEST(Publish311QCTest, Encode66) { - uint8_t pkt[] = {0x35, 0x1b, 0x0, 0x5, 0xfd, 0xdc, 0x14, 0xbb, 0x9b, 0x70, 0x1, 0xa0, 0xff, 0xf8, 0x9c, - 0x59, 0x46, 0x94, 0x53, 0xa4, 0xc2, 0x7e, 0x9, 0xd4, 0x86, 0x95, 0x60, 0xca, 0x6c}; - - uint8_t buf[39] = {0}; + lwmqtt_property_t propslist[] = {}; - uint8_t topic_bytes[] = {0xfd, 0xdc, 0x14, 0xbb, 0x9b}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa0, 0xff, 0xf8, 0x9c, 0x59, 0x46, 0x94, 0x53, 0xa4, - 0xc2, 0x7e, 0x9, 0xd4, 0x86, 0x95, 0x60, 0xca, 0x6c}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21770, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 24232 +// [("\228\219\211\ENQ\144\&1\EMRC\252<\249\191\134\214I\149\ENQ\204~\DC4\165\182\150\219\180^\DC2",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("js\191\171\SYN\189\226K\172j8\255\165\172\234R\174`\205\174\r)\ESCN\b\166\150\&6\151",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\195\230#0b={P\147",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = +// QoS1}),("\b\181\152j\EMo\228\134\219\174\179~\246\170>\175\209\193\138D\129\150K\v\163.\223@",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("F\212\150u\137\212\165\227\t\252\203'8\195\187\205~",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\232\133xTT\221\207\NUL",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ETX}\171pE",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("@$\166\244=%&\CANS\tx2\215\"\DLE\204\197\147\DC4nU\ENQ]\229>\EM`\246H",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\153\175\GS\173\ETB\160a\b\FS\195\152\193\STX\139\242\129\254{",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\244\&6\\v\143b\181\188\130\153t\237\185>\130",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\161g3\193\181G;",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode32) { + uint8_t pkt[] = {0x82, 0xe4, 0x1, 0x5e, 0xa8, 0x0, 0x1c, 0xe4, 0xdb, 0xd3, 0x5, 0x90, 0x31, 0x19, 0x52, 0x43, 0xfc, + 0x3c, 0xf9, 0xbf, 0x86, 0xd6, 0x49, 0x95, 0x5, 0xcc, 0x7e, 0x14, 0xa5, 0xb6, 0x96, 0xdb, 0xb4, 0x5e, + 0x12, 0x0, 0x0, 0x1d, 0x6a, 0x73, 0xbf, 0xab, 0x16, 0xbd, 0xe2, 0x4b, 0xac, 0x6a, 0x38, 0xff, 0xa5, + 0xac, 0xea, 0x52, 0xae, 0x60, 0xcd, 0xae, 0xd, 0x29, 0x1b, 0x4e, 0x8, 0xa6, 0x96, 0x36, 0x97, 0x0, + 0x0, 0x9, 0xc3, 0xe6, 0x23, 0x30, 0x62, 0x3d, 0x7b, 0x50, 0x93, 0x1, 0x0, 0x1c, 0x8, 0xb5, 0x98, + 0x6a, 0x19, 0x6f, 0xe4, 0x86, 0xdb, 0xae, 0xb3, 0x7e, 0xf6, 0xaa, 0x3e, 0xaf, 0xd1, 0xc1, 0x8a, 0x44, + 0x81, 0x96, 0x4b, 0xb, 0xa3, 0x2e, 0xdf, 0x40, 0x1, 0x0, 0x11, 0x46, 0xd4, 0x96, 0x75, 0x89, 0xd4, + 0xa5, 0xe3, 0x9, 0xfc, 0xcb, 0x27, 0x38, 0xc3, 0xbb, 0xcd, 0x7e, 0x1, 0x0, 0x8, 0xe8, 0x85, 0x78, + 0x54, 0x54, 0xdd, 0xcf, 0x0, 0x0, 0x0, 0x5, 0x3, 0x7d, 0xab, 0x70, 0x45, 0x1, 0x0, 0x1d, 0x40, + 0x24, 0xa6, 0xf4, 0x3d, 0x25, 0x26, 0x18, 0x53, 0x9, 0x78, 0x32, 0xd7, 0x22, 0x10, 0xcc, 0xc5, 0x93, + 0x14, 0x6e, 0x55, 0x5, 0x5d, 0xe5, 0x3e, 0x19, 0x60, 0xf6, 0x48, 0x0, 0x0, 0x12, 0x99, 0xaf, 0x1d, + 0xad, 0x17, 0xa0, 0x61, 0x8, 0x1c, 0xc3, 0x98, 0xc1, 0x2, 0x8b, 0xf2, 0x81, 0xfe, 0x7b, 0x0, 0x0, + 0xf, 0xf4, 0x36, 0x5c, 0x76, 0x8f, 0x62, 0xb5, 0xbc, 0x82, 0x99, 0x74, 0xed, 0xb9, 0x3e, 0x82, 0x2, + 0x0, 0x7, 0xa1, 0x67, 0x33, 0xc1, 0xb5, 0x47, 0x3b, 0x1}; + + uint8_t buf[241] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xe4, 0xdb, 0xd3, 0x5, 0x90, 0x31, 0x19, 0x52, 0x43, 0xfc, 0x3c, 0xf9, 0xbf, 0x86, + 0xd6, 0x49, 0x95, 0x5, 0xcc, 0x7e, 0x14, 0xa5, 0xb6, 0x96, 0xdb, 0xb4, 0x5e, 0x12}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6a, 0x73, 0xbf, 0xab, 0x16, 0xbd, 0xe2, 0x4b, 0xac, 0x6a, + 0x38, 0xff, 0xa5, 0xac, 0xea, 0x52, 0xae, 0x60, 0xcd, 0xae, + 0xd, 0x29, 0x1b, 0x4e, 0x8, 0xa6, 0x96, 0x36, 0x97}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc3, 0xe6, 0x23, 0x30, 0x62, 0x3d, 0x7b, 0x50, 0x93}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8, 0xb5, 0x98, 0x6a, 0x19, 0x6f, 0xe4, 0x86, 0xdb, 0xae, + 0xb3, 0x7e, 0xf6, 0xaa, 0x3e, 0xaf, 0xd1, 0xc1, 0x8a, 0x44, + 0x81, 0x96, 0x4b, 0xb, 0xa3, 0x2e, 0xdf, 0x40}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x46, 0xd4, 0x96, 0x75, 0x89, 0xd4, 0xa5, 0xe3, 0x9, + 0xfc, 0xcb, 0x27, 0x38, 0xc3, 0xbb, 0xcd, 0x7e}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe8, 0x85, 0x78, 0x54, 0x54, 0xdd, 0xcf, 0x0}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3, 0x7d, 0xab, 0x70, 0x45}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x40, 0x24, 0xa6, 0xf4, 0x3d, 0x25, 0x26, 0x18, 0x53, 0x9, + 0x78, 0x32, 0xd7, 0x22, 0x10, 0xcc, 0xc5, 0x93, 0x14, 0x6e, + 0x55, 0x5, 0x5d, 0xe5, 0x3e, 0x19, 0x60, 0xf6, 0x48}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x99, 0xaf, 0x1d, 0xad, 0x17, 0xa0, 0x61, 0x8, 0x1c, + 0xc3, 0x98, 0xc1, 0x2, 0x8b, 0xf2, 0x81, 0xfe, 0x7b}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xf4, 0x36, 0x5c, 0x76, 0x8f, 0x62, 0xb5, 0xbc, + 0x82, 0x99, 0x74, 0xed, 0xb9, 0x3e, 0x82}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xa1, 0x67, 0x33, 0xc1, 0xb5, 0x47, 0x3b}; + lwmqtt_string_t topic_filter_s10 = {7, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 28673, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24232, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\141\195\131\143\248w\207", -// _pubPktID = 574, _pubBody = "x\\\156a}\224\130S\US%\153\187\181\217\RS\201{", _pubProps = []} -TEST(Publish311QCTest, Encode67) { - uint8_t pkt[] = {0x33, 0x1c, 0x0, 0x7, 0x8d, 0xc3, 0x83, 0x8f, 0xf8, 0x77, 0xcf, 0x2, 0x3e, 0x78, 0x5c, - 0x9c, 0x61, 0x7d, 0xe0, 0x82, 0x53, 0x1f, 0x25, 0x99, 0xbb, 0xb5, 0xd9, 0x1e, 0xc9, 0x7b}; +// SubscribeRequest 1966 [("\202jY\229%\180?VjcM\232\215\146\SYNs\253\SYNW\162\170\244Y",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("6\r\249\236N\201*c",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("K\131A\193\166$\USc,N\221\254\172\242\137\232s\"l\ETB\DC4;S\198(",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("r\129\"\198\151\161\183\159\156\156\202\DC1\GS\153\EOT\ETX\146",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\202aP!\RSH\210E\130Q\ETX\r\161r +// \168u\216\145\SYN\157G\204\148\180\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("]wv2\143\149\148\159\RS\157",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\158\DC4\161$H\248\233\&7q\130-\225\219em\181\DC4nH\v\228=G#0\243O\f\DC4{",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(";\232\243\148t\249g\EM\247\&4 +// \198\130\228\f\ACK\203\199\250\215\&6\RS\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("I\191\225\be\SO\193\210\CAN=z\199$i\\a\157\145\132\&7\137\174\GS\148\ESC\245\194\193\134J",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\189\225\230\152\147\154q\DC2\158\197\187\194\178\146&\GSl\235\157\248\246\"\232\253\204\253I\DC2\143<",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode33) { + uint8_t pkt[] = { + 0x82, 0xfe, 0x1, 0x7, 0xae, 0x0, 0x17, 0xca, 0x6a, 0x59, 0xe5, 0x25, 0xb4, 0x3f, 0x56, 0x6a, 0x63, 0x4d, 0xe8, + 0xd7, 0x92, 0x16, 0x73, 0xfd, 0x16, 0x57, 0xa2, 0xaa, 0xf4, 0x59, 0x2, 0x0, 0x8, 0x36, 0xd, 0xf9, 0xec, 0x4e, + 0xc9, 0x2a, 0x63, 0x0, 0x0, 0x19, 0x4b, 0x83, 0x41, 0xc1, 0xa6, 0x24, 0x1f, 0x63, 0x2c, 0x4e, 0xdd, 0xfe, 0xac, + 0xf2, 0x89, 0xe8, 0x73, 0x22, 0x6c, 0x17, 0x14, 0x3b, 0x53, 0xc6, 0x28, 0x2, 0x0, 0x11, 0x72, 0x81, 0x22, 0xc6, + 0x97, 0xa1, 0xb7, 0x9f, 0x9c, 0x9c, 0xca, 0x11, 0x1d, 0x99, 0x4, 0x3, 0x92, 0x0, 0x0, 0x1a, 0xca, 0x61, 0x50, + 0x21, 0x1e, 0x48, 0xd2, 0x45, 0x82, 0x51, 0x3, 0xd, 0xa1, 0x72, 0x20, 0xa8, 0x75, 0xd8, 0x91, 0x16, 0x9d, 0x47, + 0xcc, 0x94, 0xb4, 0x2, 0x0, 0x0, 0xa, 0x5d, 0x77, 0x76, 0x32, 0x8f, 0x95, 0x94, 0x9f, 0x1e, 0x9d, 0x2, 0x0, + 0x1e, 0x9e, 0x14, 0xa1, 0x24, 0x48, 0xf8, 0xe9, 0x37, 0x71, 0x82, 0x2d, 0xe1, 0xdb, 0x65, 0x6d, 0xb5, 0x14, 0x6e, + 0x48, 0xb, 0xe4, 0x3d, 0x47, 0x23, 0x30, 0xf3, 0x4f, 0xc, 0x14, 0x7b, 0x1, 0x0, 0x17, 0x3b, 0xe8, 0xf3, 0x94, + 0x74, 0xf9, 0x67, 0x19, 0xf7, 0x34, 0x20, 0xc6, 0x82, 0xe4, 0xc, 0x6, 0xcb, 0xc7, 0xfa, 0xd7, 0x36, 0x1e, 0x94, + 0x0, 0x0, 0x1e, 0x49, 0xbf, 0xe1, 0x8, 0x65, 0xe, 0xc1, 0xd2, 0x18, 0x3d, 0x7a, 0xc7, 0x24, 0x69, 0x5c, 0x61, + 0x9d, 0x91, 0x84, 0x37, 0x89, 0xae, 0x1d, 0x94, 0x1b, 0xf5, 0xc2, 0xc1, 0x86, 0x4a, 0x0, 0x0, 0x1e, 0xbd, 0xe1, + 0xe6, 0x98, 0x93, 0x9a, 0x71, 0x12, 0x9e, 0xc5, 0xbb, 0xc2, 0xb2, 0x92, 0x26, 0x1d, 0x6c, 0xeb, 0x9d, 0xf8, 0xf6, + 0x22, 0xe8, 0xfd, 0xcc, 0xfd, 0x49, 0x12, 0x8f, 0x3c, 0x2}; - uint8_t buf[40] = {0}; + uint8_t buf[267] = {0}; - uint8_t topic_bytes[] = {0x8d, 0xc3, 0x83, 0x8f, 0xf8, 0x77, 0xcf}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x78, 0x5c, 0x9c, 0x61, 0x7d, 0xe0, 0x82, 0x53, 0x1f, - 0x25, 0x99, 0xbb, 0xb5, 0xd9, 0x1e, 0xc9, 0x7b}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xca, 0x6a, 0x59, 0xe5, 0x25, 0xb4, 0x3f, 0x56, 0x6a, 0x63, 0x4d, 0xe8, + 0xd7, 0x92, 0x16, 0x73, 0xfd, 0x16, 0x57, 0xa2, 0xaa, 0xf4, 0x59}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x36, 0xd, 0xf9, 0xec, 0x4e, 0xc9, 0x2a, 0x63}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4b, 0x83, 0x41, 0xc1, 0xa6, 0x24, 0x1f, 0x63, 0x2c, 0x4e, 0xdd, 0xfe, 0xac, + 0xf2, 0x89, 0xe8, 0x73, 0x22, 0x6c, 0x17, 0x14, 0x3b, 0x53, 0xc6, 0x28}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x72, 0x81, 0x22, 0xc6, 0x97, 0xa1, 0xb7, 0x9f, 0x9c, + 0x9c, 0xca, 0x11, 0x1d, 0x99, 0x4, 0x3, 0x92}; + lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xca, 0x61, 0x50, 0x21, 0x1e, 0x48, 0xd2, 0x45, 0x82, 0x51, 0x3, 0xd, 0xa1, + 0x72, 0x20, 0xa8, 0x75, 0xd8, 0x91, 0x16, 0x9d, 0x47, 0xcc, 0x94, 0xb4, 0x2}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x5d, 0x77, 0x76, 0x32, 0x8f, 0x95, 0x94, 0x9f, 0x1e, 0x9d}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x9e, 0x14, 0xa1, 0x24, 0x48, 0xf8, 0xe9, 0x37, 0x71, 0x82, + 0x2d, 0xe1, 0xdb, 0x65, 0x6d, 0xb5, 0x14, 0x6e, 0x48, 0xb, + 0xe4, 0x3d, 0x47, 0x23, 0x30, 0xf3, 0x4f, 0xc, 0x14, 0x7b}; + lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x3b, 0xe8, 0xf3, 0x94, 0x74, 0xf9, 0x67, 0x19, 0xf7, 0x34, 0x20, 0xc6, + 0x82, 0xe4, 0xc, 0x6, 0xcb, 0xc7, 0xfa, 0xd7, 0x36, 0x1e, 0x94}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x49, 0xbf, 0xe1, 0x8, 0x65, 0xe, 0xc1, 0xd2, 0x18, 0x3d, + 0x7a, 0xc7, 0x24, 0x69, 0x5c, 0x61, 0x9d, 0x91, 0x84, 0x37, + 0x89, 0xae, 0x1d, 0x94, 0x1b, 0xf5, 0xc2, 0xc1, 0x86, 0x4a}; + lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xbd, 0xe1, 0xe6, 0x98, 0x93, 0x9a, 0x71, 0x12, 0x9e, 0xc5, + 0xbb, 0xc2, 0xb2, 0x92, 0x26, 0x1d, 0x6c, 0xeb, 0x9d, 0xf8, + 0xf6, 0x22, 0xe8, 0xfd, 0xcc, 0xfd, 0x49, 0x12, 0x8f, 0x3c}; + lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 574, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1966, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "Mq\234\146\239\150W\FS1\177", -// _pubPktID = 0, _pubBody = "0\141\201\&8\139\&4\ETX>\239\RS\238\229t\225\198|\194W\186]\200\244|\171\DLE\163\193", -// _pubProps = []} -TEST(Publish311QCTest, Encode68) { - uint8_t pkt[] = {0x38, 0x27, 0x0, 0xa, 0x4d, 0x71, 0xea, 0x92, 0xef, 0x96, 0x57, 0x1c, 0x31, 0xb1, - 0x30, 0x8d, 0xc9, 0x38, 0x8b, 0x34, 0x3, 0x3e, 0xef, 0x1e, 0xee, 0xe5, 0x74, 0xe1, - 0xc6, 0x7c, 0xc2, 0x57, 0xba, 0x5d, 0xc8, 0xf4, 0x7c, 0xab, 0x10, 0xa3, 0xc1}; +// SubscribeRequest 11595 [("\157Y\254\b\253\241E\158M\CAN\255\215Q\ENQ\217\131\177",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\171\DC1\150\DLE\ETBSSi\198{\213\206\249t\216\rt\218\236\161\143\&8\145",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\181\FS]\249\210A:\189\185\DC1\ENQ\175]\150\218\169\SOH\193\SOH`\150\169\182l",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\233/\143\172\SIn:m\212Pf\177&\234\165\181\226\DEL3\153\SI\241l\144\242",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode34) { + uint8_t pkt[] = {0x82, 0x67, 0x2d, 0x4b, 0x0, 0x11, 0x9d, 0x59, 0xfe, 0x8, 0xfd, 0xf1, 0x45, 0x9e, 0x4d, + 0x18, 0xff, 0xd7, 0x51, 0x5, 0xd9, 0x83, 0xb1, 0x2, 0x0, 0x17, 0xab, 0x11, 0x96, 0x10, + 0x17, 0x53, 0x53, 0x69, 0xc6, 0x7b, 0xd5, 0xce, 0xf9, 0x74, 0xd8, 0xd, 0x74, 0xda, 0xec, + 0xa1, 0x8f, 0x38, 0x91, 0x2, 0x0, 0x18, 0xb5, 0x1c, 0x5d, 0xf9, 0xd2, 0x41, 0x3a, 0xbd, + 0xb9, 0x11, 0x5, 0xaf, 0x5d, 0x96, 0xda, 0xa9, 0x1, 0xc1, 0x1, 0x60, 0x96, 0xa9, 0xb6, + 0x6c, 0x2, 0x0, 0x19, 0xe9, 0x2f, 0x8f, 0xac, 0xf, 0x6e, 0x3a, 0x6d, 0xd4, 0x50, 0x66, + 0xb1, 0x26, 0xea, 0xa5, 0xb5, 0xe2, 0x7f, 0x33, 0x99, 0xf, 0xf1, 0x6c, 0x90, 0xf2, 0x1}; - uint8_t buf[51] = {0}; + uint8_t buf[115] = {0}; - uint8_t topic_bytes[] = {0x4d, 0x71, 0xea, 0x92, 0xef, 0x96, 0x57, 0x1c, 0x31, 0xb1}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x30, 0x8d, 0xc9, 0x38, 0x8b, 0x34, 0x3, 0x3e, 0xef, 0x1e, 0xee, 0xe5, 0x74, 0xe1, - 0xc6, 0x7c, 0xc2, 0x57, 0xba, 0x5d, 0xc8, 0xf4, 0x7c, 0xab, 0x10, 0xa3, 0xc1}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x9d, 0x59, 0xfe, 0x8, 0xfd, 0xf1, 0x45, 0x9e, 0x4d, + 0x18, 0xff, 0xd7, 0x51, 0x5, 0xd9, 0x83, 0xb1}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xab, 0x11, 0x96, 0x10, 0x17, 0x53, 0x53, 0x69, 0xc6, 0x7b, 0xd5, 0xce, + 0xf9, 0x74, 0xd8, 0xd, 0x74, 0xda, 0xec, 0xa1, 0x8f, 0x38, 0x91}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb5, 0x1c, 0x5d, 0xf9, 0xd2, 0x41, 0x3a, 0xbd, 0xb9, 0x11, 0x5, 0xaf, + 0x5d, 0x96, 0xda, 0xa9, 0x1, 0xc1, 0x1, 0x60, 0x96, 0xa9, 0xb6, 0x6c}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe9, 0x2f, 0x8f, 0xac, 0xf, 0x6e, 0x3a, 0x6d, 0xd4, 0x50, 0x66, 0xb1, 0x26, + 0xea, 0xa5, 0xb5, 0xe2, 0x7f, 0x33, 0x99, 0xf, 0xf1, 0x6c, 0x90, 0xf2}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11595, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "h\155\209\SYNBX\251\201\213\188", -// _pubPktID = 12728, _pubBody = "\SI\140\187\174(F\161\145", _pubProps = []} -TEST(Publish311QCTest, Encode69) { - uint8_t pkt[] = {0x3a, 0x16, 0x0, 0xa, 0x68, 0x9b, 0xd1, 0x16, 0x42, 0x58, 0xfb, 0xc9, - 0xd5, 0xbc, 0x31, 0xb8, 0xf, 0x8c, 0xbb, 0xae, 0x28, 0x46, 0xa1, 0x91}; +// SubscribeRequest 3561 [("\SI\230\235\135\157\175%\128",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\174\n|v\146#k\154\224-R\219\SUB\245k\186\207: +// \r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\DC2\181\156\155\180{\234\ETX\GS\223\168\199u\168N\218w\246\&3\DC3z\168y\249",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\170\211",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("R\230\221\&6\239O\211\146vM3YD\140\129+\194B\160\200\163\189",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode35) { + uint8_t pkt[] = {0x82, 0x5d, 0xd, 0xe9, 0x0, 0x8, 0xf, 0xe6, 0xeb, 0x87, 0x9d, 0xaf, 0x25, 0x80, 0x0, 0x0, + 0x14, 0xae, 0xa, 0x7c, 0x76, 0x92, 0x23, 0x6b, 0x9a, 0xe0, 0x2d, 0x52, 0xdb, 0x1a, 0xf5, 0x6b, + 0xba, 0xcf, 0x3a, 0x20, 0xd, 0x0, 0x0, 0x18, 0x12, 0xb5, 0x9c, 0x9b, 0xb4, 0x7b, 0xea, 0x3, + 0x1d, 0xdf, 0xa8, 0xc7, 0x75, 0xa8, 0x4e, 0xda, 0x77, 0xf6, 0x33, 0x13, 0x7a, 0xa8, 0x79, 0xf9, + 0x1, 0x0, 0x2, 0xaa, 0xd3, 0x2, 0x0, 0x16, 0x52, 0xe6, 0xdd, 0x36, 0xef, 0x4f, 0xd3, 0x92, + 0x76, 0x4d, 0x33, 0x59, 0x44, 0x8c, 0x81, 0x2b, 0xc2, 0x42, 0xa0, 0xc8, 0xa3, 0xbd, 0x0}; - uint8_t buf[34] = {0}; + uint8_t buf[105] = {0}; - uint8_t topic_bytes[] = {0x68, 0x9b, 0xd1, 0x16, 0x42, 0x58, 0xfb, 0xc9, 0xd5, 0xbc}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xf, 0x8c, 0xbb, 0xae, 0x28, 0x46, 0xa1, 0x91}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 8; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xf, 0xe6, 0xeb, 0x87, 0x9d, 0xaf, 0x25, 0x80}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xae, 0xa, 0x7c, 0x76, 0x92, 0x23, 0x6b, 0x9a, 0xe0, 0x2d, + 0x52, 0xdb, 0x1a, 0xf5, 0x6b, 0xba, 0xcf, 0x3a, 0x20, 0xd}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x12, 0xb5, 0x9c, 0x9b, 0xb4, 0x7b, 0xea, 0x3, 0x1d, 0xdf, 0xa8, 0xc7, + 0x75, 0xa8, 0x4e, 0xda, 0x77, 0xf6, 0x33, 0x13, 0x7a, 0xa8, 0x79, 0xf9}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xaa, 0xd3}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x52, 0xe6, 0xdd, 0x36, 0xef, 0x4f, 0xd3, 0x92, 0x76, 0x4d, 0x33, + 0x59, 0x44, 0x8c, 0x81, 0x2b, 0xc2, 0x42, 0xa0, 0xc8, 0xa3, 0xbd}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3561, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 27717 [("\241m\204\194)1\\\134\EOTj\252\251\183\169o~+",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\165\223\t",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\ETX)\192\ETXE\164\158\181\239\216\SOH\131\171\196\207",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\182bC|\240!\219\DC4Q\200\161",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\160\162\&7\226\196(\141G\165\139\207\SI\255\171\251J\DC2\ETX\168q'1\240-^\185\192\191]",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("}$%\168\155\130\v\149v!\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\167o\ETX\243\&6\210\&8\STX\199\236h\129H1M\147\GS\241\143S\246B\130\234\160\215\223\184",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\SUBq\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("]g\181\SUBP\232h\172\GS\180\247\RS\203\236",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\201\158",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("C\229\189\187\171\185\NAKjA!\129\253",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode36) { + uint8_t pkt[] = {0x82, 0xb4, 0x1, 0x6c, 0x45, 0x0, 0x11, 0xf1, 0x6d, 0xcc, 0xc2, 0x29, 0x31, 0x5c, 0x86, 0x4, 0x6a, + 0xfc, 0xfb, 0xb7, 0xa9, 0x6f, 0x7e, 0x2b, 0x1, 0x0, 0x3, 0xa5, 0xdf, 0x9, 0x1, 0x0, 0xf, 0x3, + 0x29, 0xc0, 0x3, 0x45, 0xa4, 0x9e, 0xb5, 0xef, 0xd8, 0x1, 0x83, 0xab, 0xc4, 0xcf, 0x2, 0x0, 0xb, + 0xb6, 0x62, 0x43, 0x7c, 0xf0, 0x21, 0xdb, 0x14, 0x51, 0xc8, 0xa1, 0x1, 0x0, 0x1d, 0xa0, 0xa2, 0x37, + 0xe2, 0xc4, 0x28, 0x8d, 0x47, 0xa5, 0x8b, 0xcf, 0xf, 0xff, 0xab, 0xfb, 0x4a, 0x12, 0x3, 0xa8, 0x71, + 0x27, 0x31, 0xf0, 0x2d, 0x5e, 0xb9, 0xc0, 0xbf, 0x5d, 0x1, 0x0, 0xb, 0x7d, 0x24, 0x25, 0xa8, 0x9b, + 0x82, 0xb, 0x95, 0x76, 0x21, 0xa6, 0x2, 0x0, 0x1c, 0xa7, 0x6f, 0x3, 0xf3, 0x36, 0xd2, 0x38, 0x2, + 0xc7, 0xec, 0x68, 0x81, 0x48, 0x31, 0x4d, 0x93, 0x1d, 0xf1, 0x8f, 0x53, 0xf6, 0x42, 0x82, 0xea, 0xa0, + 0xd7, 0xdf, 0xb8, 0x2, 0x0, 0x3, 0x1a, 0x71, 0xeb, 0x0, 0x0, 0xe, 0x5d, 0x67, 0xb5, 0x1a, 0x50, + 0xe8, 0x68, 0xac, 0x1d, 0xb4, 0xf7, 0x1e, 0xcb, 0xec, 0x1, 0x0, 0x2, 0xc9, 0x9e, 0x1, 0x0, 0xc, + 0x43, 0xe5, 0xbd, 0xbb, 0xab, 0xb9, 0x15, 0x6a, 0x41, 0x21, 0x81, 0xfd, 0x2}; + + uint8_t buf[193] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xf1, 0x6d, 0xcc, 0xc2, 0x29, 0x31, 0x5c, 0x86, 0x4, + 0x6a, 0xfc, 0xfb, 0xb7, 0xa9, 0x6f, 0x7e, 0x2b}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa5, 0xdf, 0x9}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x3, 0x29, 0xc0, 0x3, 0x45, 0xa4, 0x9e, 0xb5, + 0xef, 0xd8, 0x1, 0x83, 0xab, 0xc4, 0xcf}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb6, 0x62, 0x43, 0x7c, 0xf0, 0x21, 0xdb, 0x14, 0x51, 0xc8, 0xa1}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa0, 0xa2, 0x37, 0xe2, 0xc4, 0x28, 0x8d, 0x47, 0xa5, 0x8b, + 0xcf, 0xf, 0xff, 0xab, 0xfb, 0x4a, 0x12, 0x3, 0xa8, 0x71, + 0x27, 0x31, 0xf0, 0x2d, 0x5e, 0xb9, 0xc0, 0xbf, 0x5d}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x7d, 0x24, 0x25, 0xa8, 0x9b, 0x82, 0xb, 0x95, 0x76, 0x21, 0xa6}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa7, 0x6f, 0x3, 0xf3, 0x36, 0xd2, 0x38, 0x2, 0xc7, 0xec, + 0x68, 0x81, 0x48, 0x31, 0x4d, 0x93, 0x1d, 0xf1, 0x8f, 0x53, + 0xf6, 0x42, 0x82, 0xea, 0xa0, 0xd7, 0xdf, 0xb8}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x1a, 0x71, 0xeb}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x5d, 0x67, 0xb5, 0x1a, 0x50, 0xe8, 0x68, + 0xac, 0x1d, 0xb4, 0xf7, 0x1e, 0xcb, 0xec}; + lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xc9, 0x9e}; + lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x43, 0xe5, 0xbd, 0xbb, 0xab, 0xb9, 0x15, 0x6a, 0x41, 0x21, 0x81, 0xfd}; + lwmqtt_string_t topic_filter_s10 = {12, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 12728, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27717, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "kH\169\156\ACK\a\235\&2Q\128\148\FS\135\142\FS]\168j\246\208", _pubPktID = 23840, _pubBody = "D\195\164", _pubProps -// = []} -TEST(Publish311QCTest, Encode70) { - uint8_t pkt[] = {0x33, 0x1b, 0x0, 0x14, 0x6b, 0x48, 0xa9, 0x9c, 0x6, 0x7, 0xeb, 0x32, 0x51, 0x80, 0x94, - 0x1c, 0x87, 0x8e, 0x1c, 0x5d, 0xa8, 0x6a, 0xf6, 0xd0, 0x5d, 0x20, 0x44, 0xc3, 0xa4}; +// SubscribeRequest 10081 [("\254\182\236\b\134\175Afy\149p\146)\CAN\196]\172",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\140\141\202Y\140aB-\ENQx\198i\168\DEL\ESC\244\250-",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode37) { + uint8_t pkt[] = {0x82, 0x2b, 0x27, 0x61, 0x0, 0x11, 0xfe, 0xb6, 0xec, 0x8, 0x86, 0xaf, 0x41, 0x66, 0x79, + 0x95, 0x70, 0x92, 0x29, 0x18, 0xc4, 0x5d, 0xac, 0x0, 0x0, 0x12, 0x8c, 0x8d, 0xca, 0x59, + 0x8c, 0x61, 0x42, 0x2d, 0x5, 0x78, 0xc6, 0x69, 0xa8, 0x7f, 0x1b, 0xf4, 0xfa, 0x2d, 0x1}; - uint8_t buf[39] = {0}; + uint8_t buf[55] = {0}; - uint8_t topic_bytes[] = {0x6b, 0x48, 0xa9, 0x9c, 0x6, 0x7, 0xeb, 0x32, 0x51, 0x80, - 0x94, 0x1c, 0x87, 0x8e, 0x1c, 0x5d, 0xa8, 0x6a, 0xf6, 0xd0}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x44, 0xc3, 0xa4}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xfe, 0xb6, 0xec, 0x8, 0x86, 0xaf, 0x41, 0x66, 0x79, + 0x95, 0x70, 0x92, 0x29, 0x18, 0xc4, 0x5d, 0xac}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x8c, 0x8d, 0xca, 0x59, 0x8c, 0x61, 0x42, 0x2d, 0x5, + 0x78, 0xc6, 0x69, 0xa8, 0x7f, 0x1b, 0xf4, 0xfa, 0x2d}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10081, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12277 [("Qa\142\154\DC1\250'%d\167",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\251-\198\134\225\144X\220\STXN\142\199g*\SYN\128\238\209\135\238\166\183Q\232K)",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\173\&7va\196^-\248\&9\223;d\152(1\217u\154X\206\246\247\129o\211Z",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("8\207\165@\ESC\201\ri\241",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\141{KJ$\219&c3\196\b3,W\232`\131~\\\165\243\175\201\199E\240\SO6",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode38) { + uint8_t pkt[] = {0x82, 0x74, 0x2f, 0xf5, 0x0, 0xa, 0x51, 0x61, 0x8e, 0x9a, 0x11, 0xfa, 0x27, 0x25, 0x64, 0xa7, 0x1, + 0x0, 0x1a, 0xfb, 0x2d, 0xc6, 0x86, 0xe1, 0x90, 0x58, 0xdc, 0x2, 0x4e, 0x8e, 0xc7, 0x67, 0x2a, 0x16, + 0x80, 0xee, 0xd1, 0x87, 0xee, 0xa6, 0xb7, 0x51, 0xe8, 0x4b, 0x29, 0x1, 0x0, 0x1a, 0xad, 0x37, 0x76, + 0x61, 0xc4, 0x5e, 0x2d, 0xf8, 0x39, 0xdf, 0x3b, 0x64, 0x98, 0x28, 0x31, 0xd9, 0x75, 0x9a, 0x58, 0xce, + 0xf6, 0xf7, 0x81, 0x6f, 0xd3, 0x5a, 0x1, 0x0, 0x9, 0x38, 0xcf, 0xa5, 0x40, 0x1b, 0xc9, 0xd, 0x69, + 0xf1, 0x2, 0x0, 0x1c, 0x8d, 0x7b, 0x4b, 0x4a, 0x24, 0xdb, 0x26, 0x63, 0x33, 0xc4, 0x8, 0x33, 0x2c, + 0x57, 0xe8, 0x60, 0x83, 0x7e, 0x5c, 0xa5, 0xf3, 0xaf, 0xc9, 0xc7, 0x45, 0xf0, 0xe, 0x36, 0x0}; + + uint8_t buf[128] = {0}; + + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x51, 0x61, 0x8e, 0x9a, 0x11, 0xfa, 0x27, 0x25, 0x64, 0xa7}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xfb, 0x2d, 0xc6, 0x86, 0xe1, 0x90, 0x58, 0xdc, 0x2, 0x4e, 0x8e, 0xc7, 0x67, + 0x2a, 0x16, 0x80, 0xee, 0xd1, 0x87, 0xee, 0xa6, 0xb7, 0x51, 0xe8, 0x4b, 0x29}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xad, 0x37, 0x76, 0x61, 0xc4, 0x5e, 0x2d, 0xf8, 0x39, 0xdf, 0x3b, 0x64, 0x98, + 0x28, 0x31, 0xd9, 0x75, 0x9a, 0x58, 0xce, 0xf6, 0xf7, 0x81, 0x6f, 0xd3, 0x5a}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x38, 0xcf, 0xa5, 0x40, 0x1b, 0xc9, 0xd, 0x69, 0xf1}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x8d, 0x7b, 0x4b, 0x4a, 0x24, 0xdb, 0x26, 0x63, 0x33, 0xc4, + 0x8, 0x33, 0x2c, 0x57, 0xe8, 0x60, 0x83, 0x7e, 0x5c, 0xa5, + 0xf3, 0xaf, 0xc9, 0xc7, 0x45, 0xf0, 0xe, 0x36}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 23840, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12277, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "P\147\149\202g\200\140\&8\251", -// _pubPktID = 0, _pubBody = "\161k\226l\198m\147.\232\136\&3>\222>\138\225{\176s\227!\217C\RS\209_", _pubProps = []} -TEST(Publish311QCTest, Encode71) { - uint8_t pkt[] = {0x31, 0x25, 0x0, 0x9, 0x50, 0x93, 0x95, 0xca, 0x67, 0xc8, 0x8c, 0x38, 0xfb, - 0xa1, 0x6b, 0xe2, 0x6c, 0xc6, 0x6d, 0x93, 0x2e, 0xe8, 0x88, 0x33, 0x3e, 0xde, - 0x3e, 0x8a, 0xe1, 0x7b, 0xb0, 0x73, 0xe3, 0x21, 0xd9, 0x43, 0x1e, 0xd1, 0x5f}; +// SubscribeRequest 518 [("\139\STXE:n\137b\f\184\166\168\143a\150+/\136,\154\148\190k\196u\189n\n",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode39) { + uint8_t pkt[] = {0x82, 0x20, 0x2, 0x6, 0x0, 0x1b, 0x8b, 0x2, 0x45, 0x3a, 0x6e, 0x89, 0x62, 0xc, 0xb8, 0xa6, 0xa8, + 0x8f, 0x61, 0x96, 0x2b, 0x2f, 0x88, 0x2c, 0x9a, 0x94, 0xbe, 0x6b, 0xc4, 0x75, 0xbd, 0x6e, 0xa, 0x2}; - uint8_t buf[49] = {0}; + uint8_t buf[44] = {0}; - uint8_t topic_bytes[] = {0x50, 0x93, 0x95, 0xca, 0x67, 0xc8, 0x8c, 0x38, 0xfb}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xa1, 0x6b, 0xe2, 0x6c, 0xc6, 0x6d, 0x93, 0x2e, 0xe8, 0x88, 0x33, 0x3e, 0xde, - 0x3e, 0x8a, 0xe1, 0x7b, 0xb0, 0x73, 0xe3, 0x21, 0xd9, 0x43, 0x1e, 0xd1, 0x5f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x8b, 0x2, 0x45, 0x3a, 0x6e, 0x89, 0x62, 0xc, 0xb8, 0xa6, 0xa8, 0x8f, 0x61, 0x96, + 0x2b, 0x2f, 0x88, 0x2c, 0x9a, 0x94, 0xbe, 0x6b, 0xc4, 0x75, 0xbd, 0x6e, 0xa}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 518, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\251\215\CAN[sS\SO\167\STX",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\140\134n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode41) { + uint8_t pkt[] = {0x82, 0x48, 0x33, 0x7b, 0x0, 0xc, 0x59, 0x52, 0xd4, 0xab, 0xd1, 0x4, 0x78, 0xa4, 0xd1, + 0xc5, 0x1f, 0x9b, 0x1, 0x0, 0x1, 0xeb, 0x1, 0x0, 0x3, 0xac, 0xfa, 0x47, 0x2, 0x0, + 0x0, 0x2, 0x0, 0x14, 0xd, 0x95, 0xf6, 0x23, 0x6d, 0xed, 0x84, 0x69, 0xa2, 0x25, 0x63, + 0x1b, 0x90, 0x9f, 0x46, 0x60, 0xe5, 0xfe, 0x5, 0x47, 0x1, 0x0, 0xa, 0x7d, 0x4f, 0x36, + 0x2, 0x19, 0xfa, 0x44, 0x3e, 0xa7, 0x2, 0x0, 0x0, 0x3, 0x8c, 0x86, 0x6e, 0x2}; - uint8_t buf[43] = {0}; + uint8_t buf[84] = {0}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x6c, 0x2d, 0xc6, 0x90, 0x25, 0xc8, 0x3a, 0x7d, 0xd7, 0xa7, 0xa8, 0xd5, 0x26, 0x21, - 0x84, 0x60, 0xdd, 0x1c, 0x6c, 0x5c, 0x9d, 0x3f, 0x40, 0x2d, 0x84, 0x26, 0x88}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x59, 0x52, 0xd4, 0xab, 0xd1, 0x4, 0x78, 0xa4, 0xd1, 0xc5, 0x1f, 0x9b}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xeb}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xac, 0xfa, 0x47}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd, 0x95, 0xf6, 0x23, 0x6d, 0xed, 0x84, 0x69, 0xa2, 0x25, + 0x63, 0x1b, 0x90, 0x9f, 0x46, 0x60, 0xe5, 0xfe, 0x5, 0x47}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x7d, 0x4f, 0x36, 0x2, 0x19, 0xfa, 0x44, 0x3e, 0xa7, 0x2}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8c, 0x86, 0x6e}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29047, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13179, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "E\209", _pubPktID = 7404, _pubBody -// = "\235\ETX\185\192\212\183\ACK\\+\188\165\230>\\U", _pubProps = []} -TEST(Publish311QCTest, Encode74) { - uint8_t pkt[] = {0x32, 0x15, 0x0, 0x2, 0x45, 0xd1, 0x1c, 0xec, 0xeb, 0x3, 0xb9, 0xc0, - 0xd4, 0xb7, 0x6, 0x5c, 0x2b, 0xbc, 0xa5, 0xe6, 0x3e, 0x5c, 0x55}; +// SubscribeRequest 2708 [("\128\SUB\143\242\FS\143\181\142tg\159H\SI\193<",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\STX\194;\241\194\228a\t\191u0o\203O|\SUBV\174x\171\235\159\149\&6",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("4\173\128\155%\a\234\DLE\166\&1\188\EOT@\142qQuA\154N",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\169p4\162\139:?",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\130)\226\134",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode42) { + uint8_t pkt[] = {0x82, 0x57, 0xa, 0x94, 0x0, 0xf, 0x80, 0x1a, 0x8f, 0xf2, 0x1c, 0x8f, 0xb5, 0x8e, 0x74, + 0x67, 0x9f, 0x48, 0xf, 0xc1, 0x3c, 0x1, 0x0, 0x18, 0x2, 0xc2, 0x3b, 0xf1, 0xc2, 0xe4, + 0x61, 0x9, 0xbf, 0x75, 0x30, 0x6f, 0xcb, 0x4f, 0x7c, 0x1a, 0x56, 0xae, 0x78, 0xab, 0xeb, + 0x9f, 0x95, 0x36, 0x2, 0x0, 0x14, 0x34, 0xad, 0x80, 0x9b, 0x25, 0x7, 0xea, 0x10, 0xa6, + 0x31, 0xbc, 0x4, 0x40, 0x8e, 0x71, 0x51, 0x75, 0x41, 0x9a, 0x4e, 0x1, 0x0, 0x7, 0xa9, + 0x70, 0x34, 0xa2, 0x8b, 0x3a, 0x3f, 0x1, 0x0, 0x4, 0x82, 0x29, 0xe2, 0x86, 0x0}; - uint8_t buf[33] = {0}; + uint8_t buf[99] = {0}; - uint8_t topic_bytes[] = {0x45, 0xd1}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xeb, 0x3, 0xb9, 0xc0, 0xd4, 0xb7, 0x6, 0x5c, 0x2b, 0xbc, 0xa5, 0xe6, 0x3e, 0x5c, 0x55}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x80, 0x1a, 0x8f, 0xf2, 0x1c, 0x8f, 0xb5, 0x8e, + 0x74, 0x67, 0x9f, 0x48, 0xf, 0xc1, 0x3c}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2, 0xc2, 0x3b, 0xf1, 0xc2, 0xe4, 0x61, 0x9, 0xbf, 0x75, 0x30, 0x6f, + 0xcb, 0x4f, 0x7c, 0x1a, 0x56, 0xae, 0x78, 0xab, 0xeb, 0x9f, 0x95, 0x36}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x34, 0xad, 0x80, 0x9b, 0x25, 0x7, 0xea, 0x10, 0xa6, 0x31, + 0xbc, 0x4, 0x40, 0x8e, 0x71, 0x51, 0x75, 0x41, 0x9a, 0x4e}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa9, 0x70, 0x34, 0xa2, 0x8b, 0x3a, 0x3f}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x82, 0x29, 0xe2, 0x86}; + lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7404, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2708, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\198\225\DC4\245\&5\248\178f[\186\216.\218\247", _pubPktID = 16102, _pubBody = "\213@o\181\227\224\214\214UA", -// _pubProps = []} -TEST(Publish311QCTest, Encode75) { - uint8_t pkt[] = {0x32, 0x1c, 0x0, 0xe, 0xc6, 0xe1, 0x14, 0xf5, 0x35, 0xf8, 0xb2, 0x66, 0x5b, 0xba, 0xd8, - 0x2e, 0xda, 0xf7, 0x3e, 0xe6, 0xd5, 0x40, 0x6f, 0xb5, 0xe3, 0xe0, 0xd6, 0xd6, 0x55, 0x41}; +// SubscribeRequest 22393 [("4\151\147%\225\205\145\214",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\170\240\162w`E\254\232 +// \143\DC2x\209h3\148\197\DEL\195~\165h\DLE\232\201Bm",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\248\158\234\227[R.\240VV'\227@\DC3)\DLE\242\199\US\199\221H\199",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode43) { + uint8_t pkt[] = {0x82, 0x45, 0x57, 0x79, 0x0, 0x8, 0x34, 0x97, 0x93, 0x25, 0xe1, 0xcd, 0x91, 0xd6, 0x2, + 0x0, 0x1b, 0xaa, 0xf0, 0xa2, 0x77, 0x60, 0x45, 0xfe, 0xe8, 0x20, 0x8f, 0x12, 0x78, 0xd1, + 0x68, 0x33, 0x94, 0xc5, 0x7f, 0xc3, 0x7e, 0xa5, 0x68, 0x10, 0xe8, 0xc9, 0x42, 0x6d, 0x2, + 0x0, 0x17, 0xf8, 0x9e, 0xea, 0xe3, 0x5b, 0x52, 0x2e, 0xf0, 0x56, 0x56, 0x27, 0xe3, 0x40, + 0x13, 0x29, 0x10, 0xf2, 0xc7, 0x1f, 0xc7, 0xdd, 0x48, 0xc7, 0x0}; - uint8_t buf[40] = {0}; + uint8_t buf[81] = {0}; - uint8_t topic_bytes[] = {0xc6, 0xe1, 0x14, 0xf5, 0x35, 0xf8, 0xb2, 0x66, 0x5b, 0xba, 0xd8, 0x2e, 0xda, 0xf7}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xd5, 0x40, 0x6f, 0xb5, 0xe3, 0xe0, 0xd6, 0xd6, 0x55, 0x41}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x34, 0x97, 0x93, 0x25, 0xe1, 0xcd, 0x91, 0xd6}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xaa, 0xf0, 0xa2, 0x77, 0x60, 0x45, 0xfe, 0xe8, 0x20, 0x8f, 0x12, 0x78, 0xd1, 0x68, + 0x33, 0x94, 0xc5, 0x7f, 0xc3, 0x7e, 0xa5, 0x68, 0x10, 0xe8, 0xc9, 0x42, 0x6d}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf8, 0x9e, 0xea, 0xe3, 0x5b, 0x52, 0x2e, 0xf0, 0x56, 0x56, 0x27, 0xe3, + 0x40, 0x13, 0x29, 0x10, 0xf2, 0xc7, 0x1f, 0xc7, 0xdd, 0x48, 0xc7}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16102, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22393, 3, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 19098, _pubBody = -// "\216\241'G\183\&2\SO\NAK\254\130\&1\161\176A=\131x\SUB\190", _pubProps = []} -TEST(Publish311QCTest, Encode76) { - uint8_t pkt[] = {0x3b, 0x17, 0x0, 0x0, 0x4a, 0x9a, 0xd8, 0xf1, 0x27, 0x47, 0xb7, 0x32, 0xe, - 0x15, 0xfe, 0x82, 0x31, 0xa1, 0xb0, 0x41, 0x3d, 0x83, 0x78, 0x1a, 0xbe}; +// SubscribeRequest 16009 [("\v\252$!\153S\184\231\225\247\182w\185\196\179\251-)D\130W\129\222\SYNQ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Bn\211\153\\\EOT\238\190\196\180C1\146B\199\236h\DC1\210\&9,\147I",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\EOT;7\159\130c%\243\CAN\148\213\v\247'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\220\225\t\132\131\223\183",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode44) { + uint8_t pkt[] = {0x82, 0x53, 0x3e, 0x89, 0x0, 0x19, 0xb, 0xfc, 0x24, 0x21, 0x99, 0x53, 0xb8, 0xe7, 0xe1, 0xf7, 0xb6, + 0x77, 0xb9, 0xc4, 0xb3, 0xfb, 0x2d, 0x29, 0x44, 0x82, 0x57, 0x81, 0xde, 0x16, 0x51, 0x2, 0x0, 0x17, + 0x42, 0x6e, 0xd3, 0x99, 0x5c, 0x4, 0xee, 0xbe, 0xc4, 0xb4, 0x43, 0x31, 0x92, 0x42, 0xc7, 0xec, 0x68, + 0x11, 0xd2, 0x39, 0x2c, 0x93, 0x49, 0x1, 0x0, 0xe, 0x4, 0x3b, 0x37, 0x9f, 0x82, 0x63, 0x25, 0xf3, + 0x18, 0x94, 0xd5, 0xb, 0xf7, 0x27, 0x1, 0x0, 0x7, 0xdc, 0xe1, 0x9, 0x84, 0x83, 0xdf, 0xb7, 0x1}; - uint8_t buf[35] = {0}; + uint8_t buf[95] = {0}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xd8, 0xf1, 0x27, 0x47, 0xb7, 0x32, 0xe, 0x15, 0xfe, 0x82, - 0x31, 0xa1, 0xb0, 0x41, 0x3d, 0x83, 0x78, 0x1a, 0xbe}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xb, 0xfc, 0x24, 0x21, 0x99, 0x53, 0xb8, 0xe7, 0xe1, 0xf7, 0xb6, 0x77, 0xb9, + 0xc4, 0xb3, 0xfb, 0x2d, 0x29, 0x44, 0x82, 0x57, 0x81, 0xde, 0x16, 0x51}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x42, 0x6e, 0xd3, 0x99, 0x5c, 0x4, 0xee, 0xbe, 0xc4, 0xb4, 0x43, 0x31, + 0x92, 0x42, 0xc7, 0xec, 0x68, 0x11, 0xd2, 0x39, 0x2c, 0x93, 0x49}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4, 0x3b, 0x37, 0x9f, 0x82, 0x63, 0x25, 0xf3, 0x18, 0x94, 0xd5, 0xb, 0xf7, 0x27}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xdc, 0xe1, 0x9, 0x84, 0x83, 0xdf, 0xb7}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 19098, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16009, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "'\243\208\&5\245\172=e^\165", -// _pubPktID = 6458, _pubBody = "\222#/ q\128\&4\174k'\135\SI:O\193\DC4\153[", _pubProps = []} -TEST(Publish311QCTest, Encode77) { - uint8_t pkt[] = {0x33, 0x20, 0x0, 0xa, 0x27, 0xf3, 0xd0, 0x35, 0xf5, 0xac, 0x3d, 0x65, - 0x5e, 0xa5, 0x19, 0x3a, 0xde, 0x23, 0x2f, 0x20, 0x71, 0x80, 0x34, 0xae, - 0x6b, 0x27, 0x87, 0xf, 0x3a, 0x4f, 0xc1, 0x14, 0x99, 0x5b}; +// SubscribeRequest 14676 [("\219\215v\249b\191\208\&8H\181\rI&\210",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode45) { + uint8_t pkt[] = {0x82, 0x13, 0x39, 0x54, 0x0, 0xe, 0xdb, 0xd7, 0x76, 0xf9, 0x62, + 0xbf, 0xd0, 0x38, 0x48, 0xb5, 0xd, 0x49, 0x26, 0xd2, 0x1}; - uint8_t buf[44] = {0}; + uint8_t buf[31] = {0}; - uint8_t topic_bytes[] = {0x27, 0xf3, 0xd0, 0x35, 0xf5, 0xac, 0x3d, 0x65, 0x5e, 0xa5}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xde, 0x23, 0x2f, 0x20, 0x71, 0x80, 0x34, 0xae, 0x6b, - 0x27, 0x87, 0xf, 0x3a, 0x4f, 0xc1, 0x14, 0x99, 0x5b}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xdb, 0xd7, 0x76, 0xf9, 0x62, 0xbf, 0xd0, 0x38, 0x48, 0xb5, 0xd, 0x49, 0x26, 0xd2}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 6458, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14676, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "I\168PH\213\245]<\203\142\255\147\"\251", _pubPktID = 23705, _pubBody = -// "\136\177\214\217\&8;\253\STX\147\206\151\161\183?\r\SUB\151\230c\DLE5h\249\177\236", _pubProps = []} -TEST(Publish311QCTest, Encode78) { - uint8_t pkt[] = {0x33, 0x2b, 0x0, 0xe, 0x49, 0xa8, 0x50, 0x48, 0xd5, 0xf5, 0x5d, 0x3c, 0xcb, 0x8e, 0xff, - 0x93, 0x22, 0xfb, 0x5c, 0x99, 0x88, 0xb1, 0xd6, 0xd9, 0x38, 0x3b, 0xfd, 0x2, 0x93, 0xce, - 0x97, 0xa1, 0xb7, 0x3f, 0xd, 0x1a, 0x97, 0xe6, 0x63, 0x10, 0x35, 0x68, 0xf9, 0xb1, 0xec}; +// SubscribeRequest 2406 +// [("\154wi\237\149\207\222\244\234fa?\209A\DEL\205\221\&5\DLE\224@\211\160\208\239\&0\134\SO\NUL",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("L|I\231\128\172e\STX@\198x",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("Sa \169\184R\183\199\225\251\153%v6\228H\"\244J\193",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(";\"\b\143\221\r",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\210\147\237\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\141\237\229\157\173\ETXX/\224\174,\\\236\228",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\219\SOH\f)\241\252",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode46) { + uint8_t pkt[] = {0x82, 0x71, 0x9, 0x66, 0x0, 0x1d, 0x9a, 0x77, 0x69, 0xed, 0x95, 0xcf, 0xde, 0xf4, 0xea, 0x66, 0x61, + 0x3f, 0xd1, 0x41, 0x7f, 0xcd, 0xdd, 0x35, 0x10, 0xe0, 0x40, 0xd3, 0xa0, 0xd0, 0xef, 0x30, 0x86, 0xe, + 0x0, 0x0, 0x0, 0xb, 0x4c, 0x7c, 0x49, 0xe7, 0x80, 0xac, 0x65, 0x2, 0x40, 0xc6, 0x78, 0x0, 0x0, + 0x14, 0x53, 0x61, 0x20, 0xa9, 0xb8, 0x52, 0xb7, 0xc7, 0xe1, 0xfb, 0x99, 0x25, 0x76, 0x36, 0xe4, 0x48, + 0x22, 0xf4, 0x4a, 0xc1, 0x0, 0x0, 0x6, 0x3b, 0x22, 0x8, 0x8f, 0xdd, 0xd, 0x0, 0x0, 0x4, 0xd2, + 0x93, 0xed, 0x19, 0x2, 0x0, 0xe, 0x8d, 0xed, 0xe5, 0x9d, 0xad, 0x3, 0x58, 0x2f, 0xe0, 0xae, 0x2c, + 0x5c, 0xec, 0xe4, 0x2, 0x0, 0x6, 0xdb, 0x1, 0xc, 0x29, 0xf1, 0xfc, 0x1}; - uint8_t buf[55] = {0}; + uint8_t buf[125] = {0}; - uint8_t topic_bytes[] = {0x49, 0xa8, 0x50, 0x48, 0xd5, 0xf5, 0x5d, 0x3c, 0xcb, 0x8e, 0xff, 0x93, 0x22, 0xfb}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x88, 0xb1, 0xd6, 0xd9, 0x38, 0x3b, 0xfd, 0x2, 0x93, 0xce, 0x97, 0xa1, 0xb7, - 0x3f, 0xd, 0x1a, 0x97, 0xe6, 0x63, 0x10, 0x35, 0x68, 0xf9, 0xb1, 0xec}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x9a, 0x77, 0x69, 0xed, 0x95, 0xcf, 0xde, 0xf4, 0xea, 0x66, + 0x61, 0x3f, 0xd1, 0x41, 0x7f, 0xcd, 0xdd, 0x35, 0x10, 0xe0, + 0x40, 0xd3, 0xa0, 0xd0, 0xef, 0x30, 0x86, 0xe, 0x0}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x4c, 0x7c, 0x49, 0xe7, 0x80, 0xac, 0x65, 0x2, 0x40, 0xc6, 0x78}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x53, 0x61, 0x20, 0xa9, 0xb8, 0x52, 0xb7, 0xc7, 0xe1, 0xfb, + 0x99, 0x25, 0x76, 0x36, 0xe4, 0x48, 0x22, 0xf4, 0x4a, 0xc1}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x3b, 0x22, 0x8, 0x8f, 0xdd, 0xd}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd2, 0x93, 0xed, 0x19}; + lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8d, 0xed, 0xe5, 0x9d, 0xad, 0x3, 0x58, 0x2f, 0xe0, 0xae, 0x2c, 0x5c, 0xec, 0xe4}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xdb, 0x1, 0xc, 0x29, 0xf1, 0xfc}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 23705, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2406, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "(cp\130q\251\181\SUB\133\251\228jBh\139\191\SOH\192\213\219Q1", _pubPktID = 14770, _pubBody = -// "\155j|4h\141\198\RS\162\240\168]\208C", _pubProps = []} -TEST(Publish311QCTest, Encode79) { - uint8_t pkt[] = {0x3a, 0x28, 0x0, 0x16, 0x28, 0x63, 0x70, 0x82, 0x71, 0xfb, 0xb5, 0x1a, 0x85, 0xfb, - 0xe4, 0x6a, 0x42, 0x68, 0x8b, 0xbf, 0x1, 0xc0, 0xd5, 0xdb, 0x51, 0x31, 0x39, 0xb2, - 0x9b, 0x6a, 0x7c, 0x34, 0x68, 0x8d, 0xc6, 0x1e, 0xa2, 0xf0, 0xa8, 0x5d, 0xd0, 0x43}; +// SubscribeRequest 4955 [("\ENQ\139D6\149b\234\144\205\249k\207\248\b5\137\DC1\211*i\214\212Z\197\232\EM",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\193\&7\178\197`\133\195'\217\NAK\245\130i",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\vU\DEL\193\165\247\239O\244\220",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode47) { + uint8_t pkt[] = {0x82, 0x3c, 0x13, 0x5b, 0x0, 0x1a, 0x5, 0x8b, 0x44, 0x36, 0x95, 0x62, 0xea, 0x90, 0xcd, 0xf9, + 0x6b, 0xcf, 0xf8, 0x8, 0x35, 0x89, 0x11, 0xd3, 0x2a, 0x69, 0xd6, 0xd4, 0x5a, 0xc5, 0xe8, 0x19, + 0x0, 0x0, 0xd, 0xc1, 0x37, 0xb2, 0xc5, 0x60, 0x85, 0xc3, 0x27, 0xd9, 0x15, 0xf5, 0x82, 0x69, + 0x1, 0x0, 0xa, 0xb, 0x55, 0x7f, 0xc1, 0xa5, 0xf7, 0xef, 0x4f, 0xf4, 0xdc, 0x1}; - uint8_t buf[52] = {0}; + uint8_t buf[72] = {0}; - uint8_t topic_bytes[] = {0x28, 0x63, 0x70, 0x82, 0x71, 0xfb, 0xb5, 0x1a, 0x85, 0xfb, 0xe4, - 0x6a, 0x42, 0x68, 0x8b, 0xbf, 0x1, 0xc0, 0xd5, 0xdb, 0x51, 0x31}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x9b, 0x6a, 0x7c, 0x34, 0x68, 0x8d, 0xc6, 0x1e, 0xa2, 0xf0, 0xa8, 0x5d, 0xd0, 0x43}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x5, 0x8b, 0x44, 0x36, 0x95, 0x62, 0xea, 0x90, 0xcd, 0xf9, 0x6b, 0xcf, 0xf8, + 0x8, 0x35, 0x89, 0x11, 0xd3, 0x2a, 0x69, 0xd6, 0xd4, 0x5a, 0xc5, 0xe8, 0x19}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc1, 0x37, 0xb2, 0xc5, 0x60, 0x85, 0xc3, 0x27, 0xd9, 0x15, 0xf5, 0x82, 0x69}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb, 0x55, 0x7f, 0xc1, 0xa5, 0xf7, 0xef, 0x4f, 0xf4, 0xdc}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 14770, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4955, 3, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 11203 [("\204\DC2P\234<\186\CANVS(\203F\SO\243\v\199\215\190\165-j\243",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\131\130\210u\174\253S\151\142FR\139\135\186\209\232\170\138\156\&1\NAKf\158E\186\167",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("#\151\&7\NULk\190\232\&6\DEL\DC4H\212\161\&6:\225",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\198\255$N$\183E\246\148\&8\242:\214\128\&2\178\149v/\140",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("O:\185)_;T{\187\198[\166&\148\153\147\203\\YB+Z\169fv\133\rL",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\182\ESC\138\244\250D\150\219B\SI\149\ENQ\172]i\166&\153\190~\228\193>\209",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\143\&6\\:",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode48) { + uint8_t pkt[] = {0x82, 0xa3, 0x1, 0x2b, 0xc3, 0x0, 0x16, 0xcc, 0x12, 0x50, 0xea, 0x3c, 0xba, 0x18, 0x56, 0x53, 0x28, + 0xcb, 0x46, 0xe, 0xf3, 0xb, 0xc7, 0xd7, 0xbe, 0xa5, 0x2d, 0x6a, 0xf3, 0x0, 0x0, 0x1a, 0x83, 0x82, + 0xd2, 0x75, 0xae, 0xfd, 0x53, 0x97, 0x8e, 0x46, 0x52, 0x8b, 0x87, 0xba, 0xd1, 0xe8, 0xaa, 0x8a, 0x9c, + 0x31, 0x15, 0x66, 0x9e, 0x45, 0xba, 0xa7, 0x2, 0x0, 0x10, 0x23, 0x97, 0x37, 0x0, 0x6b, 0xbe, 0xe8, + 0x36, 0x7f, 0x14, 0x48, 0xd4, 0xa1, 0x36, 0x3a, 0xe1, 0x0, 0x0, 0x14, 0xc6, 0xff, 0x24, 0x4e, 0x24, + 0xb7, 0x45, 0xf6, 0x94, 0x38, 0xf2, 0x3a, 0xd6, 0x80, 0x32, 0xb2, 0x95, 0x76, 0x2f, 0x8c, 0x0, 0x0, + 0x1c, 0x4f, 0x3a, 0xb9, 0x29, 0x5f, 0x3b, 0x54, 0x7b, 0xbb, 0xc6, 0x5b, 0xa6, 0x26, 0x94, 0x99, 0x93, + 0xcb, 0x5c, 0x59, 0x42, 0x2b, 0x5a, 0xa9, 0x66, 0x76, 0x85, 0xd, 0x4c, 0x0, 0x0, 0x18, 0xb6, 0x1b, + 0x8a, 0xf4, 0xfa, 0x44, 0x96, 0xdb, 0x42, 0xf, 0x95, 0x5, 0xac, 0x5d, 0x69, 0xa6, 0x26, 0x99, 0xbe, + 0x7e, 0xe4, 0xc1, 0x3e, 0xd1, 0x1, 0x0, 0x4, 0x8f, 0x36, 0x5c, 0x3a, 0x1}; + + uint8_t buf[176] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xcc, 0x12, 0x50, 0xea, 0x3c, 0xba, 0x18, 0x56, 0x53, 0x28, 0xcb, + 0x46, 0xe, 0xf3, 0xb, 0xc7, 0xd7, 0xbe, 0xa5, 0x2d, 0x6a, 0xf3}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x83, 0x82, 0xd2, 0x75, 0xae, 0xfd, 0x53, 0x97, 0x8e, 0x46, 0x52, 0x8b, 0x87, + 0xba, 0xd1, 0xe8, 0xaa, 0x8a, 0x9c, 0x31, 0x15, 0x66, 0x9e, 0x45, 0xba, 0xa7}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x23, 0x97, 0x37, 0x0, 0x6b, 0xbe, 0xe8, 0x36, + 0x7f, 0x14, 0x48, 0xd4, 0xa1, 0x36, 0x3a, 0xe1}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc6, 0xff, 0x24, 0x4e, 0x24, 0xb7, 0x45, 0xf6, 0x94, 0x38, + 0xf2, 0x3a, 0xd6, 0x80, 0x32, 0xb2, 0x95, 0x76, 0x2f, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x4f, 0x3a, 0xb9, 0x29, 0x5f, 0x3b, 0x54, 0x7b, 0xbb, 0xc6, + 0x5b, 0xa6, 0x26, 0x94, 0x99, 0x93, 0xcb, 0x5c, 0x59, 0x42, + 0x2b, 0x5a, 0xa9, 0x66, 0x76, 0x85, 0xd, 0x4c}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb6, 0x1b, 0x8a, 0xf4, 0xfa, 0x44, 0x96, 0xdb, 0x42, 0xf, 0x95, 0x5, + 0xac, 0x5d, 0x69, 0xa6, 0x26, 0x99, 0xbe, 0x7e, 0xe4, 0xc1, 0x3e, 0xd1}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8f, 0x36, 0x5c, 0x3a}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11203, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "4\USH\SYN\210z\160\141\155\238\230\171\a\233\243\192t", _pubPktID = 24524, _pubBody = -// "%\173_\207\173p\210\131\129\ESC\231\SOH\143\255\163\&4\182?LS", _pubProps = []} -TEST(Publish311QCTest, Encode80) { - uint8_t pkt[] = {0x3a, 0x29, 0x0, 0x11, 0x34, 0x1f, 0x48, 0x16, 0xd2, 0x7a, 0xa0, 0x8d, 0x9b, 0xee, 0xe6, - 0xab, 0x7, 0xe9, 0xf3, 0xc0, 0x74, 0x5f, 0xcc, 0x25, 0xad, 0x5f, 0xcf, 0xad, 0x70, 0xd2, - 0x83, 0x81, 0x1b, 0xe7, 0x1, 0x8f, 0xff, 0xa3, 0x34, 0xb6, 0x3f, 0x4c, 0x53}; +// SubscribeRequest 30275 [("\NAK\ENQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode49) { + uint8_t pkt[] = {0x82, 0x7, 0x76, 0x43, 0x0, 0x2, 0x15, 0x5, 0x2}; - uint8_t buf[53] = {0}; + uint8_t buf[19] = {0}; - uint8_t topic_bytes[] = {0x34, 0x1f, 0x48, 0x16, 0xd2, 0x7a, 0xa0, 0x8d, 0x9b, - 0xee, 0xe6, 0xab, 0x7, 0xe9, 0xf3, 0xc0, 0x74}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x25, 0xad, 0x5f, 0xcf, 0xad, 0x70, 0xd2, 0x83, 0x81, 0x1b, - 0xe7, 0x1, 0x8f, 0xff, 0xa3, 0x34, 0xb6, 0x3f, 0x4c, 0x53}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x15, 0x5}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 24524, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30275, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\214u\192\231\177\&7\SYN\253\141i\217\&0\158", _pubPktID = 0, _pubBody = -// "\169\SI\241H\190p\151Qw\209\217/\163\156\&5", _pubProps = []} -TEST(Publish311QCTest, Encode81) { - uint8_t pkt[] = {0x39, 0x1e, 0x0, 0xd, 0xd6, 0x75, 0xc0, 0xe7, 0xb1, 0x37, 0x16, 0xfd, 0x8d, 0x69, 0xd9, 0x30, - 0x9e, 0xa9, 0xf, 0xf1, 0x48, 0xbe, 0x70, 0x97, 0x51, 0x77, 0xd1, 0xd9, 0x2f, 0xa3, 0x9c, 0x35}; +// SubscribeRequest 16095 [("\NAK;\166\150$",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("~U\133\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\187m\GS\SOH\205\135\128<\RS\242\204^T\DC1]\f'\v\166\151\218v\STX\FS\131>\NUL",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("n\134\188wS\138\128\229\&1w*\244&",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode50) { + uint8_t pkt[] = {0x82, 0x3f, 0x3e, 0xdf, 0x0, 0x5, 0x15, 0x3b, 0xa6, 0x96, 0x24, 0x1, 0x0, 0x4, 0x7e, 0x55, 0x85, + 0x19, 0x1, 0x0, 0x1b, 0xbb, 0x6d, 0x1d, 0x1, 0xcd, 0x87, 0x80, 0x3c, 0x1e, 0xf2, 0xcc, 0x5e, 0x54, + 0x11, 0x5d, 0xc, 0x27, 0xb, 0xa6, 0x97, 0xda, 0x76, 0x2, 0x1c, 0x83, 0x3e, 0x0, 0x0, 0x0, 0xd, + 0x6e, 0x86, 0xbc, 0x77, 0x53, 0x8a, 0x80, 0xe5, 0x31, 0x77, 0x2a, 0xf4, 0x26, 0x2}; - uint8_t buf[42] = {0}; + uint8_t buf[75] = {0}; - uint8_t topic_bytes[] = {0xd6, 0x75, 0xc0, 0xe7, 0xb1, 0x37, 0x16, 0xfd, 0x8d, 0x69, 0xd9, 0x30, 0x9e}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xa9, 0xf, 0xf1, 0x48, 0xbe, 0x70, 0x97, 0x51, 0x77, 0xd1, 0xd9, 0x2f, 0xa3, 0x9c, 0x35}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x15, 0x3b, 0xa6, 0x96, 0x24}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7e, 0x55, 0x85, 0x19}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xbb, 0x6d, 0x1d, 0x1, 0xcd, 0x87, 0x80, 0x3c, 0x1e, 0xf2, 0xcc, 0x5e, 0x54, 0x11, + 0x5d, 0xc, 0x27, 0xb, 0xa6, 0x97, 0xda, 0x76, 0x2, 0x1c, 0x83, 0x3e, 0x0}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6e, 0x86, 0xbc, 0x77, 0x53, 0x8a, 0x80, 0xe5, 0x31, 0x77, 0x2a, 0xf4, 0x26}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16095, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NUL%\184|4\245A", _pubPktID = 9669, -// _pubBody = "\170\148\223\170\SOH\189\188m;\173\149\203\NUL_B\STX\209\128\FSH\211\202R*$\DC4\t\241J", _pubProps = []} -TEST(Publish311QCTest, Encode82) { - uint8_t pkt[] = {0x3a, 0x28, 0x0, 0x7, 0x0, 0x25, 0xb8, 0x7c, 0x34, 0xf5, 0x41, 0x25, 0xc5, 0xaa, - 0x94, 0xdf, 0xaa, 0x1, 0xbd, 0xbc, 0x6d, 0x3b, 0xad, 0x95, 0xcb, 0x0, 0x5f, 0x42, - 0x2, 0xd1, 0x80, 0x1c, 0x48, 0xd3, 0xca, 0x52, 0x2a, 0x24, 0x14, 0x9, 0xf1, 0x4a}; +// SubscribeRequest 27116 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode51) { + uint8_t pkt[] = {0x82, 0x5, 0x69, 0xec, 0x0, 0x0, 0x1}; - uint8_t buf[52] = {0}; + uint8_t buf[17] = {0}; - uint8_t topic_bytes[] = {0x0, 0x25, 0xb8, 0x7c, 0x34, 0xf5, 0x41}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xaa, 0x94, 0xdf, 0xaa, 0x1, 0xbd, 0xbc, 0x6d, 0x3b, 0xad, 0x95, 0xcb, 0x0, 0x5f, 0x42, - 0x2, 0xd1, 0x80, 0x1c, 0x48, 0xd3, 0xca, 0x52, 0x2a, 0x24, 0x14, 0x9, 0xf1, 0x4a}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 9669, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27116, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = " -// o\209~\209\242\176\161LlEV\DC1\133\143\237'Y6\212\133H\a\241\&0a", _pubPktID = 1466, _pubBody = -// "0\192\223\GS\205\153\241>N\167\&8l\DC4\151x\170\229\FS\DC3s\128\135\222", _pubProps = []} -TEST(Publish311QCTest, Encode83) { - uint8_t pkt[] = {0x33, 0x35, 0x0, 0x1a, 0x20, 0x6f, 0xd1, 0x7e, 0xd1, 0xf2, 0xb0, 0xa1, 0x4c, 0x6c, - 0x45, 0x56, 0x11, 0x85, 0x8f, 0xed, 0x27, 0x59, 0x36, 0xd4, 0x85, 0x48, 0x7, 0xf1, - 0x30, 0x61, 0x5, 0xba, 0x30, 0xc0, 0xdf, 0x1d, 0xcd, 0x99, 0xf1, 0x3e, 0x4e, 0xa7, - 0x38, 0x6c, 0x14, 0x97, 0x78, 0xaa, 0xe5, 0x1c, 0x13, 0x73, 0x80, 0x87, 0xde}; +// SubscribeRequest 21718 [("1\174I~\249\CAN\ETB\DC1\225r>\134\n\208\t\160\184\206T\DC3\207L:\206C\137\158",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\207\SI\180J\RSA\SYN\212",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\b\176\222\185\206Sp\170\133",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode52) { + uint8_t pkt[] = {0x82, 0x37, 0x54, 0xd6, 0x0, 0x1b, 0x31, 0xae, 0x49, 0x7e, 0xf9, 0x18, 0x17, 0x11, 0xe1, + 0x72, 0x3e, 0x86, 0xa, 0xd0, 0x9, 0xa0, 0xb8, 0xce, 0x54, 0x13, 0xcf, 0x4c, 0x3a, 0xce, + 0x43, 0x89, 0x9e, 0x2, 0x0, 0x8, 0xcf, 0xf, 0xb4, 0x4a, 0x1e, 0x41, 0x16, 0xd4, 0x1, + 0x0, 0x9, 0x8, 0xb0, 0xde, 0xb9, 0xce, 0x53, 0x70, 0xaa, 0x85, 0x0}; - uint8_t buf[65] = {0}; + uint8_t buf[67] = {0}; - uint8_t topic_bytes[] = {0x20, 0x6f, 0xd1, 0x7e, 0xd1, 0xf2, 0xb0, 0xa1, 0x4c, 0x6c, 0x45, 0x56, 0x11, - 0x85, 0x8f, 0xed, 0x27, 0x59, 0x36, 0xd4, 0x85, 0x48, 0x7, 0xf1, 0x30, 0x61}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x30, 0xc0, 0xdf, 0x1d, 0xcd, 0x99, 0xf1, 0x3e, 0x4e, 0xa7, 0x38, 0x6c, - 0x14, 0x97, 0x78, 0xaa, 0xe5, 0x1c, 0x13, 0x73, 0x80, 0x87, 0xde}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x31, 0xae, 0x49, 0x7e, 0xf9, 0x18, 0x17, 0x11, 0xe1, 0x72, 0x3e, 0x86, 0xa, 0xd0, + 0x9, 0xa0, 0xb8, 0xce, 0x54, 0x13, 0xcf, 0x4c, 0x3a, 0xce, 0x43, 0x89, 0x9e}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xcf, 0xf, 0xb4, 0x4a, 0x1e, 0x41, 0x16, 0xd4}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x8, 0xb0, 0xde, 0xb9, 0xce, 0x53, 0x70, 0xaa, 0x85}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1466, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21718, 3, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\201%\197.\f\247\DC3\198kM\237D\184\RS\ENQ<\183\215\RS\217\200", _pubPktID = 0, _pubBody = ">@1E\209$\188\249zd", -// _pubProps = []} -TEST(Publish311QCTest, Encode84) { - uint8_t pkt[] = {0x30, 0x21, 0x0, 0x15, 0xc9, 0x25, 0xc5, 0x2e, 0xc, 0xf7, 0x13, 0xc6, - 0x6b, 0x4d, 0xed, 0x44, 0xb8, 0x1e, 0x5, 0x3c, 0xb7, 0xd7, 0x1e, 0xd9, - 0xc8, 0x3e, 0x40, 0x31, 0x45, 0xd1, 0x24, 0xbc, 0xf9, 0x7a, 0x64}; +// SubscribeRequest 32713 [("2\214\247\243(1\182\&4\130\248PZ\198\183\251=\\\128w\163\165~o\202",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("Z\195\171vhT\212\152\tmFk\v\159",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("v[g\156",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode57) { + uint8_t pkt[] = {0x82, 0x24, 0x19, 0xff, 0x0, 0x18, 0x78, 0x95, 0x92, 0xf2, 0x44, 0xcf, 0xfe, + 0x44, 0xd0, 0xda, 0xe3, 0x68, 0x8d, 0x3e, 0x68, 0x54, 0xd4, 0x98, 0x9, 0x6d, + 0x46, 0x6b, 0xb, 0x9f, 0x2, 0x0, 0x4, 0x76, 0x5b, 0x67, 0x9c, 0x0}; - uint8_t buf[56] = {0}; + uint8_t buf[48] = {0}; - uint8_t topic_bytes[] = {0xf, 0x4d, 0x3b, 0x3d, 0x3, 0xdc, 0x3, 0xd6, 0x6f, 0x9f, 0xe4, 0x9d, 0xc3, 0x90, - 0xb8, 0x2b, 0xd8, 0x67, 0x70, 0x45, 0xd0, 0x13, 0xe4, 0xd3, 0xee, 0x57, 0xd4, 0x32}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x3, 0xaf, 0x2, 0x4e, 0x90, 0xd8, 0xd4, 0xcd, 0x63, 0xb8, 0x7c, 0x8e, 0x35, 0x69}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x78, 0x95, 0x92, 0xf2, 0x44, 0xcf, 0xfe, 0x44, 0xd0, 0xda, 0xe3, 0x68, + 0x8d, 0x3e, 0x68, 0x54, 0xd4, 0x98, 0x9, 0x6d, 0x46, 0x6b, 0xb, 0x9f}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x76, 0x5b, 0x67, 0x9c}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6655, 2, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "p\185X\177s\138d\DLE.", _pubPktID = -// 29654, _pubBody = "\195o\ndF\GS\152\131\191\195;\253\248+\187y\251\129 4\244\145", _pubProps = []} -TEST(Publish311QCTest, Encode88) { - uint8_t pkt[] = {0x3c, 0x23, 0x0, 0x9, 0x70, 0xb9, 0x58, 0xb1, 0x73, 0x8a, 0x64, 0x10, 0x2e, - 0x73, 0xd6, 0xc3, 0x6f, 0xa, 0x64, 0x46, 0x1d, 0x98, 0x83, 0xbf, 0xc3, 0x3b, - 0xfd, 0xf8, 0x2b, 0xbb, 0x79, 0xfb, 0x81, 0x20, 0x34, 0xf4, 0x91}; +// SubscribeRequest 2977 [("\137K3uf\128\132\202\FS\FS\224`z\196\144d\197\197\158\200y\233\ACK\184\220",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\171c\189\177zn\130)$\236\168",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\204\230!\136BX\135:J\204\170O\186\244\SO\140L2\187\"\132",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\185TD=\248\202\150\235L\245\DC4\184\200\145\EM\255\170\192\203\233\178\205\230\"w",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\138\215!n9\139\196\249\192\194\244\135Z'\136\194",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("S\170L\DC2\175\154u\143\228\222\"p8\148\148\170\224\213\161\189\147",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode58) { + uint8_t pkt[] = {0x82, 0x8b, 0x1, 0xb, 0xa1, 0x0, 0x19, 0x89, 0x4b, 0x33, 0x75, 0x66, 0x80, 0x84, 0xca, 0x1c, + 0x1c, 0xe0, 0x60, 0x7a, 0xc4, 0x90, 0x64, 0xc5, 0xc5, 0x9e, 0xc8, 0x79, 0xe9, 0x6, 0xb8, 0xdc, + 0x2, 0x0, 0xb, 0xab, 0x63, 0xbd, 0xb1, 0x7a, 0x6e, 0x82, 0x29, 0x24, 0xec, 0xa8, 0x1, 0x0, + 0x15, 0xcc, 0xe6, 0x21, 0x88, 0x42, 0x58, 0x87, 0x3a, 0x4a, 0xcc, 0xaa, 0x4f, 0xba, 0xf4, 0xe, + 0x8c, 0x4c, 0x32, 0xbb, 0x22, 0x84, 0x1, 0x0, 0x19, 0xb9, 0x54, 0x44, 0x3d, 0xf8, 0xca, 0x96, + 0xeb, 0x4c, 0xf5, 0x14, 0xb8, 0xc8, 0x91, 0x19, 0xff, 0xaa, 0xc0, 0xcb, 0xe9, 0xb2, 0xcd, 0xe6, + 0x22, 0x77, 0x1, 0x0, 0x10, 0x8a, 0xd7, 0x21, 0x6e, 0x39, 0x8b, 0xc4, 0xf9, 0xc0, 0xc2, 0xf4, + 0x87, 0x5a, 0x27, 0x88, 0xc2, 0x0, 0x0, 0x15, 0x53, 0xaa, 0x4c, 0x12, 0xaf, 0x9a, 0x75, 0x8f, + 0xe4, 0xde, 0x22, 0x70, 0x38, 0x94, 0x94, 0xaa, 0xe0, 0xd5, 0xa1, 0xbd, 0x93, 0x0}; - uint8_t buf[47] = {0}; + uint8_t buf[152] = {0}; - uint8_t topic_bytes[] = {0x70, 0xb9, 0x58, 0xb1, 0x73, 0x8a, 0x64, 0x10, 0x2e}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xc3, 0x6f, 0xa, 0x64, 0x46, 0x1d, 0x98, 0x83, 0xbf, 0xc3, 0x3b, - 0xfd, 0xf8, 0x2b, 0xbb, 0x79, 0xfb, 0x81, 0x20, 0x34, 0xf4, 0x91}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x89, 0x4b, 0x33, 0x75, 0x66, 0x80, 0x84, 0xca, 0x1c, 0x1c, 0xe0, 0x60, 0x7a, + 0xc4, 0x90, 0x64, 0xc5, 0xc5, 0x9e, 0xc8, 0x79, 0xe9, 0x6, 0xb8, 0xdc}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xab, 0x63, 0xbd, 0xb1, 0x7a, 0x6e, 0x82, 0x29, 0x24, 0xec, 0xa8}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xcc, 0xe6, 0x21, 0x88, 0x42, 0x58, 0x87, 0x3a, 0x4a, 0xcc, 0xaa, + 0x4f, 0xba, 0xf4, 0xe, 0x8c, 0x4c, 0x32, 0xbb, 0x22, 0x84}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb9, 0x54, 0x44, 0x3d, 0xf8, 0xca, 0x96, 0xeb, 0x4c, 0xf5, 0x14, 0xb8, 0xc8, + 0x91, 0x19, 0xff, 0xaa, 0xc0, 0xcb, 0xe9, 0xb2, 0xcd, 0xe6, 0x22, 0x77}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x8a, 0xd7, 0x21, 0x6e, 0x39, 0x8b, 0xc4, 0xf9, + 0xc0, 0xc2, 0xf4, 0x87, 0x5a, 0x27, 0x88, 0xc2}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x53, 0xaa, 0x4c, 0x12, 0xaf, 0x9a, 0x75, 0x8f, 0xe4, 0xde, 0x22, + 0x70, 0x38, 0x94, 0x94, 0xaa, 0xe0, 0xd5, 0xa1, 0xbd, 0x93}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29654, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2977, 6, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\238\SYN\GSq4\148\154&", _pubPktID -// = 4746, _pubBody = "", _pubProps = []} -TEST(Publish311QCTest, Encode89) { - uint8_t pkt[] = {0x32, 0xc, 0x0, 0x8, 0xee, 0x16, 0x1d, 0x71, 0x34, 0x94, 0x9a, 0x26, 0x12, 0x8a}; +// SubscribeRequest 14796 [("dL\223\173OD1\b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\194\241\150\GS\SYN\239\&9\227\136c\138\225ItdFP",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode59) { + uint8_t pkt[] = {0x82, 0x21, 0x39, 0xcc, 0x0, 0x8, 0x64, 0x4c, 0xdf, 0xad, 0x4f, 0x44, + 0x31, 0x8, 0x1, 0x0, 0x11, 0xc2, 0xf1, 0x96, 0x1d, 0x16, 0xef, 0x39, + 0xe3, 0x88, 0x63, 0x8a, 0xe1, 0x49, 0x74, 0x64, 0x46, 0x50, 0x1}; - uint8_t buf[24] = {0}; + uint8_t buf[45] = {0}; - uint8_t topic_bytes[] = {0xee, 0x16, 0x1d, 0x71, 0x34, 0x94, 0x9a, 0x26}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x64, 0x4c, 0xdf, 0xad, 0x4f, 0x44, 0x31, 0x8}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc2, 0xf1, 0x96, 0x1d, 0x16, 0xef, 0x39, 0xe3, 0x88, + 0x63, 0x8a, 0xe1, 0x49, 0x74, 0x64, 0x46, 0x50}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 4746, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14796, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12164 [("\215\191",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\183\&1\149d|\172\187\170\n\253\&0\247d\147\189",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\"-\141\168\ESCz\249\US;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\248\206\134zY'gO\232M\144X\242\ESC\196\210\242Ka",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\155\&9\136\225\249<@6\DC2C8VS\170\237\208=1\161t\156e\198R'\149\183",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\138h\162\"\239\145\&1Q\212\182\ETB\132\178T\203\211\181\250\190\ETX\US\154\132c\168\205\218\139\176\171",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\165\160\138\189\b1fH\233\ACK_\\\a\250\137\DEL\130\251\NUL\US\166\145[\162J",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\193\ETX\186T\206c}8/>H\163\255\173\&4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("<\STX\246d\230",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("e\229|n.\CAN\FS\177\249\229Y\"Fe\193\209\"\225+\217x\190ub\253|",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\170R!*\191)5\154\202|,\DEL};bb\224\&1\233\194M\DC4`&\NUL\131",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode60) { + uint8_t pkt[] = {0x82, 0xea, 0x1, 0x2f, 0x84, 0x0, 0x2, 0xd7, 0xbf, 0x1, 0x0, 0xf, 0xb7, 0x31, 0x95, 0x64, 0x7c, + 0xac, 0xbb, 0xaa, 0xa, 0xfd, 0x30, 0xf7, 0x64, 0x93, 0xbd, 0x2, 0x0, 0x9, 0x22, 0x2d, 0x8d, 0xa8, + 0x1b, 0x7a, 0xf9, 0x1f, 0x3b, 0x0, 0x0, 0x13, 0xf8, 0xce, 0x86, 0x7a, 0x59, 0x27, 0x67, 0x4f, 0xe8, + 0x4d, 0x90, 0x58, 0xf2, 0x1b, 0xc4, 0xd2, 0xf2, 0x4b, 0x61, 0x2, 0x0, 0x1b, 0x9b, 0x39, 0x88, 0xe1, + 0xf9, 0x3c, 0x40, 0x36, 0x12, 0x43, 0x38, 0x56, 0x53, 0xaa, 0xed, 0xd0, 0x3d, 0x31, 0xa1, 0x74, 0x9c, + 0x65, 0xc6, 0x52, 0x27, 0x95, 0xb7, 0x0, 0x0, 0x1e, 0x8a, 0x68, 0xa2, 0x22, 0xef, 0x91, 0x31, 0x51, + 0xd4, 0xb6, 0x17, 0x84, 0xb2, 0x54, 0xcb, 0xd3, 0xb5, 0xfa, 0xbe, 0x3, 0x1f, 0x9a, 0x84, 0x63, 0xa8, + 0xcd, 0xda, 0x8b, 0xb0, 0xab, 0x2, 0x0, 0x19, 0xa5, 0xa0, 0x8a, 0xbd, 0x8, 0x31, 0x66, 0x48, 0xe9, + 0x6, 0x5f, 0x5c, 0x7, 0xfa, 0x89, 0x7f, 0x82, 0xfb, 0x0, 0x1f, 0xa6, 0x91, 0x5b, 0xa2, 0x4a, 0x2, + 0x0, 0xf, 0xc1, 0x3, 0xba, 0x54, 0xce, 0x63, 0x7d, 0x38, 0x2f, 0x3e, 0x48, 0xa3, 0xff, 0xad, 0x34, + 0x0, 0x0, 0x5, 0x3c, 0x2, 0xf6, 0x64, 0xe6, 0x1, 0x0, 0x1a, 0x65, 0xe5, 0x7c, 0x6e, 0x2e, 0x18, + 0x1c, 0xb1, 0xf9, 0xe5, 0x59, 0x22, 0x46, 0x65, 0xc1, 0xd1, 0x22, 0xe1, 0x2b, 0xd9, 0x78, 0xbe, 0x75, + 0x62, 0xfd, 0x7c, 0x2, 0x0, 0x1a, 0xaa, 0x52, 0x21, 0x2a, 0xbf, 0x29, 0x35, 0x9a, 0xca, 0x7c, 0x2c, + 0x7f, 0x7d, 0x3b, 0x62, 0x62, 0xe0, 0x31, 0xe9, 0xc2, 0x4d, 0x14, 0x60, 0x26, 0x0, 0x83, 0x2}; + + uint8_t buf[247] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xd7, 0xbf}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb7, 0x31, 0x95, 0x64, 0x7c, 0xac, 0xbb, 0xaa, + 0xa, 0xfd, 0x30, 0xf7, 0x64, 0x93, 0xbd}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x22, 0x2d, 0x8d, 0xa8, 0x1b, 0x7a, 0xf9, 0x1f, 0x3b}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf8, 0xce, 0x86, 0x7a, 0x59, 0x27, 0x67, 0x4f, 0xe8, 0x4d, + 0x90, 0x58, 0xf2, 0x1b, 0xc4, 0xd2, 0xf2, 0x4b, 0x61}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9b, 0x39, 0x88, 0xe1, 0xf9, 0x3c, 0x40, 0x36, 0x12, 0x43, 0x38, 0x56, 0x53, 0xaa, + 0xed, 0xd0, 0x3d, 0x31, 0xa1, 0x74, 0x9c, 0x65, 0xc6, 0x52, 0x27, 0x95, 0xb7}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8a, 0x68, 0xa2, 0x22, 0xef, 0x91, 0x31, 0x51, 0xd4, 0xb6, + 0x17, 0x84, 0xb2, 0x54, 0xcb, 0xd3, 0xb5, 0xfa, 0xbe, 0x3, + 0x1f, 0x9a, 0x84, 0x63, 0xa8, 0xcd, 0xda, 0x8b, 0xb0, 0xab}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa5, 0xa0, 0x8a, 0xbd, 0x8, 0x31, 0x66, 0x48, 0xe9, 0x6, 0x5f, 0x5c, 0x7, + 0xfa, 0x89, 0x7f, 0x82, 0xfb, 0x0, 0x1f, 0xa6, 0x91, 0x5b, 0xa2, 0x4a}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xc1, 0x3, 0xba, 0x54, 0xce, 0x63, 0x7d, 0x38, + 0x2f, 0x3e, 0x48, 0xa3, 0xff, 0xad, 0x34}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x3c, 0x2, 0xf6, 0x64, 0xe6}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x65, 0xe5, 0x7c, 0x6e, 0x2e, 0x18, 0x1c, 0xb1, 0xf9, 0xe5, 0x59, 0x22, 0x46, + 0x65, 0xc1, 0xd1, 0x22, 0xe1, 0x2b, 0xd9, 0x78, 0xbe, 0x75, 0x62, 0xfd, 0x7c}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xaa, 0x52, 0x21, 0x2a, 0xbf, 0x29, 0x35, 0x9a, 0xca, 0x7c, 0x2c, 0x7f, 0x7d, + 0x3b, 0x62, 0x62, 0xe0, 0x31, 0xe9, 0xc2, 0x4d, 0x14, 0x60, 0x26, 0x0, 0x83}; + lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = {}; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "(\217\244\EOT\224\136\232\225\248Q\237\240\138\187\152\v<\194\216B\158\SYN\158\203t\205", _pubPktID = 13686, -// _pubBody = "g\t?\199\SOHX\128\158_", _pubProps = []} -TEST(Publish311QCTest, Encode90) { - uint8_t pkt[] = {0x32, 0x27, 0x0, 0x1a, 0x28, 0xd9, 0xf4, 0x4, 0xe0, 0x88, 0xe8, 0xe1, 0xf8, 0x51, - 0xed, 0xf0, 0x8a, 0xbb, 0x98, 0xb, 0x3c, 0xc2, 0xd8, 0x42, 0x9e, 0x16, 0x9e, 0xcb, - 0x74, 0xcd, 0x35, 0x76, 0x67, 0x9, 0x3f, 0xc7, 0x1, 0x58, 0x80, 0x9e, 0x5f}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12164, 11, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12633 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\142\241\204\138,\174\131\149\199\160o\205\146",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("r\146\242\132\DC1\212\252\ETX\DC3\192\195\&3\169\231!",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\225\238p\223\135rJ\134'\ETB\DEL\137\131\NUL\223h\DC4\171\ESC\248",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("l1\185\139a\217\DEL7?\r\EM?",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("?\226!\129{\254Q",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\FSG=\NUL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\142gv\133\156\SYN\162\216C",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\152\212\158(t\138F\128{&?'-\194\239p\DC2H\132\131\SYNd\169\128\215\NAKa\217",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\179\212\228\145\130\161\198\&5\236H\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0}),("\196\&6?\162\212TA\205\USkt\b\208",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode62) { + uint8_t pkt[] = {0x82, 0x70, 0x54, 0x8a, 0x0, 0xd, 0xd9, 0xc1, 0x92, 0x85, 0xe9, 0xed, 0x38, 0x34, 0x2, 0x7c, 0x39, + 0xf, 0x5e, 0x1, 0x0, 0xb, 0x21, 0xbf, 0xfa, 0x54, 0x3e, 0xe2, 0x21, 0x81, 0x7b, 0xfe, 0x51, 0x1, + 0x0, 0x4, 0x1c, 0x47, 0x3d, 0x0, 0x1, 0x0, 0x9, 0x8e, 0x67, 0x76, 0x85, 0x9c, 0x16, 0xa2, 0xd8, + 0x43, 0x1, 0x0, 0x1c, 0x98, 0xd4, 0x9e, 0x28, 0x74, 0x8a, 0x46, 0x80, 0x7b, 0x26, 0x3f, 0x27, 0x2d, + 0xc2, 0xef, 0x70, 0x12, 0x48, 0x84, 0x83, 0x16, 0x64, 0xa9, 0x80, 0xd7, 0x15, 0x61, 0xd9, 0x2, 0x0, + 0xb, 0xb3, 0xd4, 0xe4, 0x91, 0x82, 0xa1, 0xc6, 0x35, 0xec, 0x48, 0x98, 0x0, 0x0, 0xd, 0xc4, 0x36, + 0x3f, 0xa2, 0xd4, 0x54, 0x41, 0xcd, 0x1f, 0x6b, 0x74, 0x8, 0xd0, 0x2}; + + uint8_t buf[124] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xd9, 0xc1, 0x92, 0x85, 0xe9, 0xed, 0x38, 0x34, 0x2, 0x7c, 0x39, 0xf, 0x5e}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x21, 0xbf, 0xfa, 0x54, 0x3e, 0xe2, 0x21, 0x81, 0x7b, 0xfe, 0x51}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1c, 0x47, 0x3d, 0x0}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8e, 0x67, 0x76, 0x85, 0x9c, 0x16, 0xa2, 0xd8, 0x43}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x98, 0xd4, 0x9e, 0x28, 0x74, 0x8a, 0x46, 0x80, 0x7b, 0x26, + 0x3f, 0x27, 0x2d, 0xc2, 0xef, 0x70, 0x12, 0x48, 0x84, 0x83, + 0x16, 0x64, 0xa9, 0x80, 0xd7, 0x15, 0x61, 0xd9}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb3, 0xd4, 0xe4, 0x91, 0x82, 0xa1, 0xc6, 0x35, 0xec, 0x48, 0x98}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc4, 0x36, 0x3f, 0xa2, 0xd4, 0x54, 0x41, 0xcd, 0x1f, 0x6b, 0x74, 0x8, 0xd0}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 13686, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21642, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "FL\240\156\182\192\&3\212\166\234!\162i#\233\190}'N\176", _pubPktID = 7951, _pubBody = -// "\246\168g\152\239\&8\214\227\217R=w3\173\155\210Y\155@", _pubProps = []} -TEST(Publish311QCTest, Encode91) { - uint8_t pkt[] = {0x3c, 0x2b, 0x0, 0x14, 0x46, 0x4c, 0xf0, 0x9c, 0xb6, 0xc0, 0x33, 0xd4, 0xa6, 0xea, 0x21, - 0xa2, 0x69, 0x23, 0xe9, 0xbe, 0x7d, 0x27, 0x4e, 0xb0, 0x1f, 0xf, 0xf6, 0xa8, 0x67, 0x98, - 0xef, 0x38, 0xd6, 0xe3, 0xd9, 0x52, 0x3d, 0x77, 0x33, 0xad, 0x9b, 0xd2, 0x59, 0x9b, 0x40}; +// SubscribeRequest 17671 [("u\219]\165\215\137\250\193O\129\136\181\180\tG@\188t",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\250\141\FS\155\a\192Q}\186\203\ACK\DEL\246\233\SUB\206\&2/\240\137\189'F$\189dq\159\142h",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\SYN\189~\178VN\200\201\v\165\218\230\166\ETB",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("L\136+\152\143",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\139\202\184\152g\f\231`",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode63) { + uint8_t pkt[] = {0x82, 0x63, 0x45, 0x7, 0x0, 0x12, 0x75, 0xdb, 0x5d, 0xa5, 0xd7, 0x89, 0xfa, 0xc1, 0x4f, 0x81, 0x88, + 0xb5, 0xb4, 0x9, 0x47, 0x40, 0xbc, 0x74, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1e, 0xfa, 0x8d, 0x1c, 0x9b, + 0x7, 0xc0, 0x51, 0x7d, 0xba, 0xcb, 0x6, 0x7f, 0xf6, 0xe9, 0x1a, 0xce, 0x32, 0x2f, 0xf0, 0x89, 0xbd, + 0x27, 0x46, 0x24, 0xbd, 0x64, 0x71, 0x9f, 0x8e, 0x68, 0x0, 0x0, 0xe, 0x16, 0xbd, 0x7e, 0xb2, 0x56, + 0x4e, 0xc8, 0xc9, 0xb, 0xa5, 0xda, 0xe6, 0xa6, 0x17, 0x1, 0x0, 0x5, 0x4c, 0x88, 0x2b, 0x98, 0x8f, + 0x2, 0x0, 0x8, 0x8b, 0xca, 0xb8, 0x98, 0x67, 0xc, 0xe7, 0x60, 0x1, 0x0, 0x1, 0x5c, 0x2}; - uint8_t buf[55] = {0}; + uint8_t buf[111] = {0}; - uint8_t topic_bytes[] = {0x46, 0x4c, 0xf0, 0x9c, 0xb6, 0xc0, 0x33, 0xd4, 0xa6, 0xea, - 0x21, 0xa2, 0x69, 0x23, 0xe9, 0xbe, 0x7d, 0x27, 0x4e, 0xb0}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xf6, 0xa8, 0x67, 0x98, 0xef, 0x38, 0xd6, 0xe3, 0xd9, 0x52, - 0x3d, 0x77, 0x33, 0xad, 0x9b, 0xd2, 0x59, 0x9b, 0x40}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x75, 0xdb, 0x5d, 0xa5, 0xd7, 0x89, 0xfa, 0xc1, 0x4f, + 0x81, 0x88, 0xb5, 0xb4, 0x9, 0x47, 0x40, 0xbc, 0x74}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xfa, 0x8d, 0x1c, 0x9b, 0x7, 0xc0, 0x51, 0x7d, 0xba, 0xcb, + 0x6, 0x7f, 0xf6, 0xe9, 0x1a, 0xce, 0x32, 0x2f, 0xf0, 0x89, + 0xbd, 0x27, 0x46, 0x24, 0xbd, 0x64, 0x71, 0x9f, 0x8e, 0x68}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x16, 0xbd, 0x7e, 0xb2, 0x56, 0x4e, 0xc8, 0xc9, 0xb, 0xa5, 0xda, 0xe6, 0xa6, 0x17}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x4c, 0x88, 0x2b, 0x98, 0x8f}; + lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8b, 0xca, 0xb8, 0x98, 0x67, 0xc, 0xe7, 0x60}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x5c}; + lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7951, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17671, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\232\175\EOT\145\DEL\254\166\230\212MM\131\&6R\177A\217", _pubPktID = 26125, _pubBody = "\229\&1", _pubProps = []} -TEST(Publish311QCTest, Encode92) { - uint8_t pkt[] = {0x35, 0x17, 0x0, 0x11, 0xe8, 0xaf, 0x4, 0x91, 0x7f, 0xfe, 0xa6, 0xe6, 0xd4, - 0x4d, 0x4d, 0x83, 0x36, 0x52, 0xb1, 0x41, 0xd9, 0x66, 0xd, 0xe5, 0x31}; +// SubscribeRequest 18903 [("\245\147\176",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("sQ\169h\ACK\237\155\fg\232\206\138",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode64) { + uint8_t pkt[] = {0x82, 0x17, 0x49, 0xd7, 0x0, 0x3, 0xf5, 0x93, 0xb0, 0x0, 0x0, 0xc, 0x73, + 0x51, 0xa9, 0x68, 0x6, 0xed, 0x9b, 0xc, 0x67, 0xe8, 0xce, 0x8a, 0x2}; uint8_t buf[35] = {0}; - uint8_t topic_bytes[] = {0xe8, 0xaf, 0x4, 0x91, 0x7f, 0xfe, 0xa6, 0xe6, 0xd4, - 0x4d, 0x4d, 0x83, 0x36, 0x52, 0xb1, 0x41, 0xd9}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xe5, 0x31}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xf5, 0x93, 0xb0}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x73, 0x51, 0xa9, 0x68, 0x6, 0xed, 0x9b, 0xc, 0x67, 0xe8, 0xce, 0x8a}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 26125, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18903, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 187 [("5>j",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\134/\US\STX\249\130\n\159\"\235\ETB\FS\163\USR\194\156d>\213\144=\161/*'\231\"",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\DEL\250Oc\141\225\&8\234B\179",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\141\218\241\136\246\183d\251\&3\182\235#\208\bPH\170Y\194",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\215N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS +// = QoS1}),("}'\141;\170\&26H\213Yh\130\RS\178\DLEuL\155\134\229\210\138\DLEi\GS~S",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\220\&6\DC2a\245\161\nd\210\tR\238\159Z1\236\207\215\181\204\ACKb}\252\217",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("f\245\230\190d\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("\SYN\233\177\236i\130\128\129L\208\174U\146\138F\247\182\212.\225y\DC2R\230s`9\178X_",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("C\183z\254h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\232t\GS\132\129\184f\CAN\CAN>\141:L\216\DC3{\191Y\213\232\SYN|\212\146k\195",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\SO]\228\162\189*ST\168t\ACK\143\216r\249\178\199\&0(\200[}\173\235\206\159F",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\STX\148\192L*\157`\179\224=e\224\228\&6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("\232J\211\179\136\130\218\157A\177\157j!\157\237\a\248\213\SUB\155",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode68) { + uint8_t pkt[] = {0x82, 0xb2, 0x1, 0x2a, 0xa7, 0x0, 0x10, 0x74, 0x1a, 0x39, 0xbc, 0x36, 0xf6, 0x91, 0x8b, 0xb3, 0x5a, + 0xdb, 0xc9, 0xc3, 0x5f, 0x45, 0xfb, 0x1, 0x0, 0xe, 0xc1, 0x69, 0x61, 0xff, 0xe8, 0x35, 0x8a, 0xc7, + 0x3e, 0xf5, 0xe6, 0xbe, 0x64, 0xa, 0x0, 0x0, 0x1e, 0x16, 0xe9, 0xb1, 0xec, 0x69, 0x82, 0x80, 0x81, + 0x4c, 0xd0, 0xae, 0x55, 0x92, 0x8a, 0x46, 0xf7, 0xb6, 0xd4, 0x2e, 0xe1, 0x79, 0x12, 0x52, 0xe6, 0x73, + 0x60, 0x39, 0xb2, 0x58, 0x5f, 0x0, 0x0, 0x5, 0x43, 0xb7, 0x7a, 0xfe, 0x68, 0x1, 0x0, 0x1a, 0xe8, + 0x74, 0x1d, 0x84, 0x81, 0xb8, 0x66, 0x18, 0x18, 0x3e, 0x8d, 0x3a, 0x4c, 0xd8, 0x13, 0x7b, 0xbf, 0x59, + 0xd5, 0xe8, 0x16, 0x7c, 0xd4, 0x92, 0x6b, 0xc3, 0x1, 0x0, 0x1b, 0xe, 0x5d, 0xe4, 0xa2, 0xbd, 0x2a, + 0x53, 0x54, 0xa8, 0x74, 0x6, 0x8f, 0xd8, 0x72, 0xf9, 0xb2, 0xc7, 0x30, 0x28, 0xc8, 0x5b, 0x7d, 0xad, + 0xeb, 0xce, 0x9f, 0x46, 0x1, 0x0, 0xe, 0x2, 0x94, 0xc0, 0x4c, 0x2a, 0x9d, 0x60, 0xb3, 0xe0, 0x3d, + 0x65, 0xe0, 0xe4, 0x36, 0x0, 0x0, 0x14, 0xe8, 0x4a, 0xd3, 0xb3, 0x88, 0x82, 0xda, 0x9d, 0x41, 0xb1, + 0x9d, 0x6a, 0x21, 0x9d, 0xed, 0x7, 0xf8, 0xd5, 0x1a, 0x9b, 0x0}; + + uint8_t buf[191] = {0}; + + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x74, 0x1a, 0x39, 0xbc, 0x36, 0xf6, 0x91, 0x8b, + 0xb3, 0x5a, 0xdb, 0xc9, 0xc3, 0x5f, 0x45, 0xfb}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc1, 0x69, 0x61, 0xff, 0xe8, 0x35, 0x8a, 0xc7, 0x3e, 0xf5, 0xe6, 0xbe, 0x64, 0xa}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x16, 0xe9, 0xb1, 0xec, 0x69, 0x82, 0x80, 0x81, 0x4c, 0xd0, + 0xae, 0x55, 0x92, 0x8a, 0x46, 0xf7, 0xb6, 0xd4, 0x2e, 0xe1, + 0x79, 0x12, 0x52, 0xe6, 0x73, 0x60, 0x39, 0xb2, 0x58, 0x5f}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x43, 0xb7, 0x7a, 0xfe, 0x68}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe8, 0x74, 0x1d, 0x84, 0x81, 0xb8, 0x66, 0x18, 0x18, 0x3e, 0x8d, 0x3a, 0x4c, + 0xd8, 0x13, 0x7b, 0xbf, 0x59, 0xd5, 0xe8, 0x16, 0x7c, 0xd4, 0x92, 0x6b, 0xc3}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe, 0x5d, 0xe4, 0xa2, 0xbd, 0x2a, 0x53, 0x54, 0xa8, 0x74, 0x6, 0x8f, 0xd8, 0x72, + 0xf9, 0xb2, 0xc7, 0x30, 0x28, 0xc8, 0x5b, 0x7d, 0xad, 0xeb, 0xce, 0x9f, 0x46}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x2, 0x94, 0xc0, 0x4c, 0x2a, 0x9d, 0x60, 0xb3, 0xe0, 0x3d, 0x65, 0xe0, 0xe4, 0x36}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe8, 0x4a, 0xd3, 0xb3, 0x88, 0x82, 0xda, 0x9d, 0x41, 0xb1, + 0x9d, 0x6a, 0x21, 0x9d, 0xed, 0x7, 0xf8, 0xd5, 0x1a, 0x9b}; + lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = {}; -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\149y\148\SOH\133\136\STX\n\242", -// _pubPktID = 27162, _pubBody = -// "\163\212\196\ENQ\196\186w\152\RS\219\243>k~\167\130o^\157\\\197C\128\130\185\247\201\148C\197", _pubProps = []} -TEST(Publish311QCTest, Encode95) { - uint8_t pkt[] = {0x3b, 0x2b, 0x0, 0x9, 0x95, 0x79, 0x94, 0x1, 0x85, 0x88, 0x2, 0xa, 0xf2, 0x6a, 0x1a, - 0xa3, 0xd4, 0xc4, 0x5, 0xc4, 0xba, 0x77, 0x98, 0x1e, 0xdb, 0xf3, 0x3e, 0x6b, 0x7e, 0xa7, - 0x82, 0x6f, 0x5e, 0x9d, 0x5c, 0xc5, 0x43, 0x80, 0x82, 0xb9, 0xf7, 0xc9, 0x94, 0x43, 0xc5}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10919, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 692 [("\151\140>\206\207\NUL\208\139\194L\251\227\220\170\163\153*~?,w\245u",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\227\154\215d\192;_\237G\128o\235Q\218rV\202\SOHr\DEL\144\155",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("S'\141\229\&7]\"\179\212\174\r\185\176",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\137\202Y\ENQ\254#\197\FS(R\208\234n0x\ACK\141\210i\227$0\182H%",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("0\237\190\218C6",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\247/{\nv\233V\144\198e\158",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\247\194\142\228\247\186\227\&8",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("J",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\200\183{SW\236\248y\197\224\172K\STX\184W\v~\211",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\247\146\ETB\254\241\SYN\199\197\175\237\\\220\213\154\178\214\136k\147S\SI\228\EM\219\129.\240",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\249h\135(AF",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode69) { + uint8_t pkt[] = {0x82, 0xc3, 0x1, 0x2, 0xb4, 0x0, 0x17, 0x97, 0x8c, 0x3e, 0xce, 0xcf, 0x0, 0xd0, 0x8b, 0xc2, 0x4c, + 0xfb, 0xe3, 0xdc, 0xaa, 0xa3, 0x99, 0x2a, 0x7e, 0x3f, 0x2c, 0x77, 0xf5, 0x75, 0x2, 0x0, 0x16, 0xe3, + 0x9a, 0xd7, 0x64, 0xc0, 0x3b, 0x5f, 0xed, 0x47, 0x80, 0x6f, 0xeb, 0x51, 0xda, 0x72, 0x56, 0xca, 0x1, + 0x72, 0x7f, 0x90, 0x9b, 0x0, 0x0, 0xd, 0x53, 0x27, 0x8d, 0xe5, 0x37, 0x5d, 0x22, 0xb3, 0xd4, 0xae, + 0xd, 0xb9, 0xb0, 0x1, 0x0, 0x19, 0x89, 0xca, 0x59, 0x5, 0xfe, 0x23, 0xc5, 0x1c, 0x28, 0x52, 0xd0, + 0xea, 0x6e, 0x30, 0x78, 0x6, 0x8d, 0xd2, 0x69, 0xe3, 0x24, 0x30, 0xb6, 0x48, 0x25, 0x1, 0x0, 0x6, + 0x30, 0xed, 0xbe, 0xda, 0x43, 0x36, 0x1, 0x0, 0xb, 0xf7, 0x2f, 0x7b, 0xa, 0x76, 0xe9, 0x56, 0x90, + 0xc6, 0x65, 0x9e, 0x0, 0x0, 0x8, 0xf7, 0xc2, 0x8e, 0xe4, 0xf7, 0xba, 0xe3, 0x38, 0x0, 0x0, 0x1, + 0x4a, 0x2, 0x0, 0x12, 0xc8, 0xb7, 0x7b, 0x53, 0x57, 0xec, 0xf8, 0x79, 0xc5, 0xe0, 0xac, 0x4b, 0x2, + 0xb8, 0x57, 0xb, 0x7e, 0xd3, 0x0, 0x0, 0x1b, 0xf7, 0x92, 0x17, 0xfe, 0xf1, 0x16, 0xc7, 0xc5, 0xaf, + 0xed, 0x5c, 0xdc, 0xd5, 0x9a, 0xb2, 0xd6, 0x88, 0x6b, 0x93, 0x53, 0xf, 0xe4, 0x19, 0xdb, 0x81, 0x2e, + 0xf0, 0x2, 0x0, 0x6, 0xf9, 0x68, 0x87, 0x28, 0x41, 0x46, 0x1}; - uint8_t buf[55] = {0}; + uint8_t buf[208] = {0}; - uint8_t topic_bytes[] = {0x95, 0x79, 0x94, 0x1, 0x85, 0x88, 0x2, 0xa, 0xf2}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xa3, 0xd4, 0xc4, 0x5, 0xc4, 0xba, 0x77, 0x98, 0x1e, 0xdb, 0xf3, 0x3e, 0x6b, 0x7e, 0xa7, - 0x82, 0x6f, 0x5e, 0x9d, 0x5c, 0xc5, 0x43, 0x80, 0x82, 0xb9, 0xf7, 0xc9, 0x94, 0x43, 0xc5}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x97, 0x8c, 0x3e, 0xce, 0xcf, 0x0, 0xd0, 0x8b, 0xc2, 0x4c, 0xfb, 0xe3, + 0xdc, 0xaa, 0xa3, 0x99, 0x2a, 0x7e, 0x3f, 0x2c, 0x77, 0xf5, 0x75}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xe3, 0x9a, 0xd7, 0x64, 0xc0, 0x3b, 0x5f, 0xed, 0x47, 0x80, 0x6f, + 0xeb, 0x51, 0xda, 0x72, 0x56, 0xca, 0x1, 0x72, 0x7f, 0x90, 0x9b}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x53, 0x27, 0x8d, 0xe5, 0x37, 0x5d, 0x22, 0xb3, 0xd4, 0xae, 0xd, 0xb9, 0xb0}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x89, 0xca, 0x59, 0x5, 0xfe, 0x23, 0xc5, 0x1c, 0x28, 0x52, 0xd0, 0xea, 0x6e, + 0x30, 0x78, 0x6, 0x8d, 0xd2, 0x69, 0xe3, 0x24, 0x30, 0xb6, 0x48, 0x25}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x30, 0xed, 0xbe, 0xda, 0x43, 0x36}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf7, 0x2f, 0x7b, 0xa, 0x76, 0xe9, 0x56, 0x90, 0xc6, 0x65, 0x9e}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xf7, 0xc2, 0x8e, 0xe4, 0xf7, 0xba, 0xe3, 0x38}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x4a}; + lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xc8, 0xb7, 0x7b, 0x53, 0x57, 0xec, 0xf8, 0x79, 0xc5, + 0xe0, 0xac, 0x4b, 0x2, 0xb8, 0x57, 0xb, 0x7e, 0xd3}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xf7, 0x92, 0x17, 0xfe, 0xf1, 0x16, 0xc7, 0xc5, 0xaf, 0xed, 0x5c, 0xdc, 0xd5, 0x9a, + 0xb2, 0xd6, 0x88, 0x6b, 0x93, 0x53, 0xf, 0xe4, 0x19, 0xdb, 0x81, 0x2e, 0xf0}; + lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xf9, 0x68, 0x87, 0x28, 0x41, 0x46}; + lwmqtt_string_t topic_filter_s10 = {6, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 27162, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 692, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\133\236\215", _pubPktID = 29262, -// _pubBody = "\150|7\US\164%\USi\129\ACK\161\142\139\207", _pubProps = []} -TEST(Publish311QCTest, Encode96) { - uint8_t pkt[] = {0x35, 0x15, 0x0, 0x3, 0x85, 0xec, 0xd7, 0x72, 0x4e, 0x96, 0x7c, 0x37, - 0x1f, 0xa4, 0x25, 0x1f, 0x69, 0x81, 0x6, 0xa1, 0x8e, 0x8b, 0xcf}; +// SubscribeRequest 1184 [("\170g\\2\a\FS\243\&2\134#\245<\232\v!E",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\163/?",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS +// = QoS1}),("_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\\\158\228\223\ETB:\150)dY|!\236\205\164s\139\v\167>\221\EM",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\232\208\185f\157\247N\190\191\ETX\212\t\213\229\SOH +// \206\v\178@\162^",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("m\137\v\f7\141&\216@\158!\GS\192\191\189",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\EOTg\241\167",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode71) { + uint8_t pkt[] = {0x82, 0x75, 0x6e, 0xae, 0x0, 0x1b, 0xc4, 0xd0, 0x78, 0x91, 0x7, 0xc5, 0xec, 0xa6, 0xed, 0xc6, 0x5c, + 0x2d, 0xde, 0x61, 0xd, 0x8c, 0x9e, 0x4e, 0xc7, 0x37, 0xb2, 0x1e, 0x60, 0x3d, 0x3e, 0x21, 0x45, 0x0, + 0x0, 0x3, 0xa3, 0x2f, 0x3f, 0x1, 0x0, 0x1, 0x5f, 0x2, 0x0, 0x16, 0x5c, 0x9e, 0xe4, 0xdf, 0x17, + 0x3a, 0x96, 0x29, 0x64, 0x59, 0x7c, 0x21, 0xec, 0xcd, 0xa4, 0x73, 0x8b, 0xb, 0xa7, 0x3e, 0xdd, 0x19, + 0x2, 0x0, 0x16, 0xe8, 0xd0, 0xb9, 0x66, 0x9d, 0xf7, 0x4e, 0xbe, 0xbf, 0x3, 0xd4, 0x9, 0xd5, 0xe5, + 0x1, 0x20, 0xce, 0xb, 0xb2, 0x40, 0xa2, 0x5e, 0x1, 0x0, 0xf, 0x6d, 0x89, 0xb, 0xc, 0x37, 0x8d, + 0x26, 0xd8, 0x40, 0x9e, 0x21, 0x1d, 0xc0, 0xbf, 0xbd, 0x1, 0x0, 0x4, 0x4, 0x67, 0xf1, 0xa7, 0x1}; + + uint8_t buf[129] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xc4, 0xd0, 0x78, 0x91, 0x7, 0xc5, 0xec, 0xa6, 0xed, 0xc6, 0x5c, 0x2d, 0xde, 0x61, + 0xd, 0x8c, 0x9e, 0x4e, 0xc7, 0x37, 0xb2, 0x1e, 0x60, 0x3d, 0x3e, 0x21, 0x45}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa3, 0x2f, 0x3f}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5f}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x5c, 0x9e, 0xe4, 0xdf, 0x17, 0x3a, 0x96, 0x29, 0x64, 0x59, 0x7c, + 0x21, 0xec, 0xcd, 0xa4, 0x73, 0x8b, 0xb, 0xa7, 0x3e, 0xdd, 0x19}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe8, 0xd0, 0xb9, 0x66, 0x9d, 0xf7, 0x4e, 0xbe, 0xbf, 0x3, 0xd4, + 0x9, 0xd5, 0xe5, 0x1, 0x20, 0xce, 0xb, 0xb2, 0x40, 0xa2, 0x5e}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6d, 0x89, 0xb, 0xc, 0x37, 0x8d, 0x26, 0xd8, + 0x40, 0x9e, 0x21, 0x1d, 0xc0, 0xbf, 0xbd}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x4, 0x67, 0xf1, 0xa7}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28334, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 26598 [("=\225\250g\177\216\249\&8\252='RyD\192\199@\SOh\247\158\236\151\&4d\199\247",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("#\151\183Z\151O\182\172\150*i\\\161\230\221\176\251\180\217H;]\215\250\196L\201\228\DC3\244",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\243\152\219Kk\182Q,eE \RS*/\SYN\134V\DC3FyOS[",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\139\SOH\t\179g\DC3&n'\158C\223Y\254",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\205$\145XN\129y\188+2W2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode72) { + uint8_t pkt[] = {0x82, 0x7e, 0x67, 0xe6, 0x0, 0x1b, 0x3d, 0xe1, 0xfa, 0x67, 0xb1, 0xd8, 0xf9, 0x38, 0xfc, 0x3d, + 0x27, 0x52, 0x79, 0x44, 0xc0, 0xc7, 0x40, 0xe, 0x68, 0xf7, 0x9e, 0xec, 0x97, 0x34, 0x64, 0xc7, + 0xf7, 0x2, 0x0, 0x0, 0x1, 0x0, 0x1e, 0x23, 0x97, 0xb7, 0x5a, 0x97, 0x4f, 0xb6, 0xac, 0x96, + 0x2a, 0x69, 0x5c, 0xa1, 0xe6, 0xdd, 0xb0, 0xfb, 0xb4, 0xd9, 0x48, 0x3b, 0x5d, 0xd7, 0xfa, 0xc4, + 0x4c, 0xc9, 0xe4, 0x13, 0xf4, 0x0, 0x0, 0x17, 0xf3, 0x98, 0xdb, 0x4b, 0x6b, 0xb6, 0x51, 0x2c, + 0x65, 0x45, 0x20, 0x1e, 0x2a, 0x2f, 0x16, 0x86, 0x56, 0x13, 0x46, 0x79, 0x4f, 0x53, 0x5b, 0x1, + 0x0, 0xe, 0x8b, 0x1, 0x9, 0xb3, 0x67, 0x13, 0x26, 0x6e, 0x27, 0x9e, 0x43, 0xdf, 0x59, 0xfe, + 0x0, 0x0, 0xc, 0xcd, 0x24, 0x91, 0x58, 0x4e, 0x81, 0x79, 0xbc, 0x2b, 0x32, 0x57, 0x32, 0x1}; + + uint8_t buf[138] = {0}; + + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x3d, 0xe1, 0xfa, 0x67, 0xb1, 0xd8, 0xf9, 0x38, 0xfc, 0x3d, 0x27, 0x52, 0x79, 0x44, + 0xc0, 0xc7, 0x40, 0xe, 0x68, 0xf7, 0x9e, 0xec, 0x97, 0x34, 0x64, 0xc7, 0xf7}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x23, 0x97, 0xb7, 0x5a, 0x97, 0x4f, 0xb6, 0xac, 0x96, 0x2a, + 0x69, 0x5c, 0xa1, 0xe6, 0xdd, 0xb0, 0xfb, 0xb4, 0xd9, 0x48, + 0x3b, 0x5d, 0xd7, 0xfa, 0xc4, 0x4c, 0xc9, 0xe4, 0x13, 0xf4}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf3, 0x98, 0xdb, 0x4b, 0x6b, 0xb6, 0x51, 0x2c, 0x65, 0x45, 0x20, 0x1e, + 0x2a, 0x2f, 0x16, 0x86, 0x56, 0x13, 0x46, 0x79, 0x4f, 0x53, 0x5b}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x8b, 0x1, 0x9, 0xb3, 0x67, 0x13, 0x26, 0x6e, 0x27, 0x9e, 0x43, 0xdf, 0x59, 0xfe}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xcd, 0x24, 0x91, 0x58, 0x4e, 0x81, 0x79, 0xbc, 0x2b, 0x32, 0x57, 0x32}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "5b0\195\142R\129\205", _pubPktID = -// 25975, _pubBody = ":\135\203\145\&6\148\180\155\&28\243", _pubProps = []} -TEST(Publish311QCTest, Encode97) { - uint8_t pkt[] = {0x33, 0x17, 0x0, 0x8, 0x35, 0x62, 0x30, 0xc3, 0x8e, 0x52, 0x81, 0xcd, 0x65, - 0x77, 0x3a, 0x87, 0xcb, 0x91, 0x36, 0x94, 0xb4, 0x9b, 0x32, 0x38, 0xf3}; + lwmqtt_property_t propslist[] = {}; - uint8_t buf[35] = {0}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26598, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 8075 [("\153\219wC\224\141\212\158d\179\204\165\177\194fH\170\138^",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\163{\DC4\190\210\150W\162\228}\131*;\DC1\208;\155n\214I\147\176\137\176",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\v\244\209y\179\242\230\161\147:u\140\228\&5k\177\179\250",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\184\211O\228\212N\251O\183\208V\241\211\t\209\244\RS\186",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode74) { + uint8_t pkt[] = {0x82, 0xb1, 0x1, 0x46, 0x1b, 0x0, 0x1, 0x45, 0x0, 0x0, 0x7, 0x8, 0xc2, 0xb3, 0x87, 0x7f, 0x99, + 0x5c, 0x1, 0x0, 0x1c, 0x43, 0x6b, 0xef, 0x35, 0xd, 0x27, 0xdf, 0x64, 0xcd, 0x43, 0xee, 0xbc, 0x95, + 0xb3, 0xc6, 0x83, 0x8b, 0x87, 0xc8, 0x6a, 0x98, 0x87, 0xa1, 0x61, 0x5a, 0x35, 0x72, 0xb2, 0x0, 0x0, + 0x6, 0x50, 0x9d, 0xb5, 0x85, 0xb4, 0x7b, 0x1, 0x0, 0x14, 0x68, 0x73, 0x5f, 0x4b, 0xe7, 0x37, 0x5, + 0x8e, 0x9d, 0xc2, 0xc4, 0xfc, 0xf0, 0x88, 0x29, 0x9d, 0x9f, 0xa7, 0xff, 0x47, 0x0, 0x0, 0xb, 0x74, + 0x80, 0x68, 0x86, 0x54, 0xa0, 0xb2, 0x72, 0x61, 0x92, 0xc9, 0x2, 0x0, 0x4, 0x32, 0x88, 0xeb, 0xe1, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x19, 0x74, 0xc8, 0x1, 0x90, 0xf3, 0xb, 0x9f, 0x46, 0x26, 0xfd, 0xba, + 0x2a, 0xa3, 0x88, 0x64, 0xd, 0x41, 0x11, 0x6, 0xd1, 0x22, 0x11, 0xc1, 0x56, 0x11, 0x2, 0x0, 0xe, + 0xe8, 0xa9, 0xcd, 0x93, 0x16, 0x81, 0x91, 0xc4, 0x23, 0x21, 0x6, 0xab, 0x49, 0xe1, 0x1, 0x0, 0x1a, + 0xd7, 0xdd, 0x19, 0xfe, 0x2f, 0xa4, 0x64, 0x3e, 0xb8, 0xd3, 0x4f, 0xe4, 0xd4, 0x4e, 0xfb, 0x4f, 0xb7, + 0xd0, 0x56, 0xf1, 0xd3, 0x9, 0xd1, 0xf4, 0x1e, 0xba, 0x1}; + + uint8_t buf[190] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x45}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x8, 0xc2, 0xb3, 0x87, 0x7f, 0x99, 0x5c}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x43, 0x6b, 0xef, 0x35, 0xd, 0x27, 0xdf, 0x64, 0xcd, 0x43, + 0xee, 0xbc, 0x95, 0xb3, 0xc6, 0x83, 0x8b, 0x87, 0xc8, 0x6a, + 0x98, 0x87, 0xa1, 0x61, 0x5a, 0x35, 0x72, 0xb2}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x50, 0x9d, 0xb5, 0x85, 0xb4, 0x7b}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x68, 0x73, 0x5f, 0x4b, 0xe7, 0x37, 0x5, 0x8e, 0x9d, 0xc2, + 0xc4, 0xfc, 0xf0, 0x88, 0x29, 0x9d, 0x9f, 0xa7, 0xff, 0x47}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x74, 0x80, 0x68, 0x86, 0x54, 0xa0, 0xb2, 0x72, 0x61, 0x92, 0xc9}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x32, 0x88, 0xeb, 0xe1}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x74, 0xc8, 0x1, 0x90, 0xf3, 0xb, 0x9f, 0x46, 0x26, 0xfd, 0xba, 0x2a, 0xa3, + 0x88, 0x64, 0xd, 0x41, 0x11, 0x6, 0xd1, 0x22, 0x11, 0xc1, 0x56, 0x11}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe8, 0xa9, 0xcd, 0x93, 0x16, 0x81, 0x91, 0xc4, 0x23, 0x21, 0x6, 0xab, 0x49, 0xe1}; + lwmqtt_string_t topic_filter_s9 = {14, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xd7, 0xdd, 0x19, 0xfe, 0x2f, 0xa4, 0x64, 0x3e, 0xb8, 0xd3, 0x4f, 0xe4, 0xd4, + 0x4e, 0xfb, 0x4f, 0xb7, 0xd0, 0x56, 0xf1, 0xd3, 0x9, 0xd1, 0xf4, 0x1e, 0xba}; + lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17947, 11, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 167 [("\231\169\150\t\250\191\150<\142\244\175\168\192\184\179",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\212\vx}\a\239:\\|\164~\165\239\172\b\182j\"e\244",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\199\200~",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\US97\178\208\r#N\n\150nm+6\213\NUL\171\252\t",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\137\ETX\197\217\NUL\223\232\207\253\202\144V#\158k\156DSE2\145\ENQ\158\234\133\150",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("#\149\222<\ETXQ\182,\188$Y~(\178|T\176_\145\151'",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\175\ENQ\GS\245\242)\153\DC2\129\190\DC4\n\235\129\160 \190\233",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("DJ\236\247\\fp\240\131\213\DLEP\133\CAN\133",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\188n\248-\193\248\138\147\SI\181\to\137\t\148\230\233=",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode75) { + uint8_t pkt[] = {0x82, 0xb8, 0x1, 0x0, 0xa7, 0x0, 0xf, 0xe7, 0xa9, 0x96, 0x9, 0xfa, 0xbf, 0x96, 0x3c, 0x8e, 0xf4, + 0xaf, 0xa8, 0xc0, 0xb8, 0xb3, 0x2, 0x0, 0x14, 0xd4, 0xb, 0x78, 0x7d, 0x7, 0xef, 0x3a, 0x5c, 0x7c, + 0xa4, 0x7e, 0xa5, 0xef, 0xac, 0x8, 0xb6, 0x6a, 0x22, 0x65, 0xf4, 0x2, 0x0, 0x3, 0xc7, 0xc8, 0x7e, + 0x0, 0x0, 0x13, 0x1f, 0x39, 0x37, 0xb2, 0xd0, 0xd, 0x23, 0x4e, 0xa, 0x96, 0x6e, 0x6d, 0x2b, 0x36, + 0xd5, 0x0, 0xab, 0xfc, 0x9, 0x2, 0x0, 0x1a, 0x89, 0x3, 0xc5, 0xd9, 0x0, 0xdf, 0xe8, 0xcf, 0xfd, + 0xca, 0x90, 0x56, 0x23, 0x9e, 0x6b, 0x9c, 0x44, 0x53, 0x45, 0x32, 0x91, 0x5, 0x9e, 0xea, 0x85, 0x96, + 0x1, 0x0, 0x15, 0x23, 0x95, 0xde, 0x3c, 0x3, 0x51, 0xb6, 0x2c, 0xbc, 0x24, 0x59, 0x7e, 0x28, 0xb2, + 0x7c, 0x54, 0xb0, 0x5f, 0x91, 0x97, 0x27, 0x0, 0x0, 0x12, 0xaf, 0x5, 0x1d, 0xf5, 0xf2, 0x29, 0x99, + 0x12, 0x81, 0xbe, 0x14, 0xa, 0xeb, 0x81, 0xa0, 0x20, 0xbe, 0xe9, 0x2, 0x0, 0xf, 0x44, 0x4a, 0xec, + 0xf7, 0x5c, 0x66, 0x70, 0xf0, 0x83, 0xd5, 0x10, 0x50, 0x85, 0x18, 0x85, 0x1, 0x0, 0x12, 0xbc, 0x6e, + 0xf8, 0x2d, 0xc1, 0xf8, 0x8a, 0x93, 0xf, 0xb5, 0x9, 0x6f, 0x89, 0x9, 0x94, 0xe6, 0xe9, 0x3d, 0x1}; + + uint8_t buf[197] = {0}; + + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xe7, 0xa9, 0x96, 0x9, 0xfa, 0xbf, 0x96, 0x3c, + 0x8e, 0xf4, 0xaf, 0xa8, 0xc0, 0xb8, 0xb3}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd4, 0xb, 0x78, 0x7d, 0x7, 0xef, 0x3a, 0x5c, 0x7c, 0xa4, + 0x7e, 0xa5, 0xef, 0xac, 0x8, 0xb6, 0x6a, 0x22, 0x65, 0xf4}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc7, 0xc8, 0x7e}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x1f, 0x39, 0x37, 0xb2, 0xd0, 0xd, 0x23, 0x4e, 0xa, 0x96, + 0x6e, 0x6d, 0x2b, 0x36, 0xd5, 0x0, 0xab, 0xfc, 0x9}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x89, 0x3, 0xc5, 0xd9, 0x0, 0xdf, 0xe8, 0xcf, 0xfd, 0xca, 0x90, 0x56, 0x23, + 0x9e, 0x6b, 0x9c, 0x44, 0x53, 0x45, 0x32, 0x91, 0x5, 0x9e, 0xea, 0x85, 0x96}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x23, 0x95, 0xde, 0x3c, 0x3, 0x51, 0xb6, 0x2c, 0xbc, 0x24, 0x59, + 0x7e, 0x28, 0xb2, 0x7c, 0x54, 0xb0, 0x5f, 0x91, 0x97, 0x27}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xaf, 0x5, 0x1d, 0xf5, 0xf2, 0x29, 0x99, 0x12, 0x81, + 0xbe, 0x14, 0xa, 0xeb, 0x81, 0xa0, 0x20, 0xbe, 0xe9}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x44, 0x4a, 0xec, 0xf7, 0x5c, 0x66, 0x70, 0xf0, + 0x83, 0xd5, 0x10, 0x50, 0x85, 0x18, 0x85}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xbc, 0x6e, 0xf8, 0x2d, 0xc1, 0xf8, 0x8a, 0x93, 0xf, + 0xb5, 0x9, 0x6f, 0x89, 0x9, 0x94, 0xe6, 0xe9, 0x3d}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25975, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 167, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\213Jr\201\234\223\158\NULA\172F$x\203\226", _pubPktID = 5740, _pubBody = -// "\v\DC4\158\192\171F\249\ESC\192U\254\"\152\151", _pubProps = []} -TEST(Publish311QCTest, Encode98) { - uint8_t pkt[] = {0x3b, 0x21, 0x0, 0xf, 0xd5, 0x4a, 0x72, 0xc9, 0xea, 0xdf, 0x9e, 0x0, - 0x41, 0xac, 0x46, 0x24, 0x78, 0xcb, 0xe2, 0x16, 0x6c, 0xb, 0x14, 0x9e, - 0xc0, 0xab, 0x46, 0xf9, 0x1b, 0xc0, 0x55, 0xfe, 0x22, 0x98, 0x97}; +// SubscribeRequest 3223 [("U#\128\166r\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\198l]6!\158\151\NUL\255\155|\156\254",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode76) { + uint8_t pkt[] = {0x82, 0x1b, 0xc, 0x97, 0x0, 0x6, 0x55, 0x23, 0x80, 0xa6, 0x72, 0xd9, 0x0, 0x0, 0xd, + 0xc6, 0x6c, 0x5d, 0x36, 0x21, 0x9e, 0x97, 0x0, 0xff, 0x9b, 0x7c, 0x9c, 0xfe, 0x1}; - uint8_t buf[45] = {0}; + uint8_t buf[39] = {0}; - uint8_t topic_bytes[] = {0xd5, 0x4a, 0x72, 0xc9, 0xea, 0xdf, 0x9e, 0x0, 0x41, 0xac, 0x46, 0x24, 0x78, 0xcb, 0xe2}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xb, 0x14, 0x9e, 0xc0, 0xab, 0x46, 0xf9, 0x1b, 0xc0, 0x55, 0xfe, 0x22, 0x98, 0x97}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x55, 0x23, 0x80, 0xa6, 0x72, 0xd9}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc6, 0x6c, 0x5d, 0x36, 0x21, 0x9e, 0x97, 0x0, 0xff, 0x9b, 0x7c, 0x9c, 0xfe}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3223, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 1845 [("\196\128\&4\163O\255",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("f\255\128\199\ETXD\164B\184\249 \251\243\158TM\242\130",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("d@V!\249\199\168\166\194\241\244\243y\202\222\203\132\164\184\145\196\164",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SYN\197\232MQ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\242W\198\204\146t\ESC\192'\177\DC49>\166`{\152Q\247v\213\133\EM \160~@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\229\252\136\170\181]\155\129\151\157\222\219P\163\177\130\146F\205",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\234\196[a\EOTi\137\214",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\232\&4\187\230\144aj3\ETB\EM\162%t\228",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\STXv\213",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\"=\211\194\176",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode77) { + uint8_t pkt[] = {0x82, 0xa2, 0x1, 0x7, 0x35, 0x0, 0x6, 0xc4, 0x80, 0x34, 0xa3, 0x4f, 0xff, 0x2, 0x0, 0x12, 0x66, + 0xff, 0x80, 0xc7, 0x3, 0x44, 0xa4, 0x42, 0xb8, 0xf9, 0x20, 0xfb, 0xf3, 0x9e, 0x54, 0x4d, 0xf2, 0x82, + 0x0, 0x0, 0x16, 0x64, 0x40, 0x56, 0x21, 0xf9, 0xc7, 0xa8, 0xa6, 0xc2, 0xf1, 0xf4, 0xf3, 0x79, 0xca, + 0xde, 0xcb, 0x84, 0xa4, 0xb8, 0x91, 0xc4, 0xa4, 0x0, 0x0, 0x5, 0x16, 0xc5, 0xe8, 0x4d, 0x51, 0x1, + 0x0, 0x1b, 0xf2, 0x57, 0xc6, 0xcc, 0x92, 0x74, 0x1b, 0xc0, 0x27, 0xb1, 0x14, 0x39, 0x3e, 0xa6, 0x60, + 0x7b, 0x98, 0x51, 0xf7, 0x76, 0xd5, 0x85, 0x19, 0x20, 0xa0, 0x7e, 0x40, 0x0, 0x0, 0x13, 0xe5, 0xfc, + 0x88, 0xaa, 0xb5, 0x5d, 0x9b, 0x81, 0x97, 0x9d, 0xde, 0xdb, 0x50, 0xa3, 0xb1, 0x82, 0x92, 0x46, 0xcd, + 0x1, 0x0, 0x0, 0x0, 0x0, 0x8, 0xea, 0xc4, 0x5b, 0x61, 0x4, 0x69, 0x89, 0xd6, 0x2, 0x0, 0xe, + 0xe8, 0x34, 0xbb, 0xe6, 0x90, 0x61, 0x6a, 0x33, 0x17, 0x19, 0xa2, 0x25, 0x74, 0xe4, 0x0, 0x0, 0x3, + 0x2, 0x76, 0xd5, 0x2, 0x0, 0x5, 0x22, 0x3d, 0xd3, 0xc2, 0xb0, 0x2}; + + uint8_t buf[175] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xc4, 0x80, 0x34, 0xa3, 0x4f, 0xff}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x66, 0xff, 0x80, 0xc7, 0x3, 0x44, 0xa4, 0x42, 0xb8, + 0xf9, 0x20, 0xfb, 0xf3, 0x9e, 0x54, 0x4d, 0xf2, 0x82}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x64, 0x40, 0x56, 0x21, 0xf9, 0xc7, 0xa8, 0xa6, 0xc2, 0xf1, 0xf4, + 0xf3, 0x79, 0xca, 0xde, 0xcb, 0x84, 0xa4, 0xb8, 0x91, 0xc4, 0xa4}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x16, 0xc5, 0xe8, 0x4d, 0x51}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xf2, 0x57, 0xc6, 0xcc, 0x92, 0x74, 0x1b, 0xc0, 0x27, 0xb1, 0x14, 0x39, 0x3e, 0xa6, + 0x60, 0x7b, 0x98, 0x51, 0xf7, 0x76, 0xd5, 0x85, 0x19, 0x20, 0xa0, 0x7e, 0x40}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe5, 0xfc, 0x88, 0xaa, 0xb5, 0x5d, 0x9b, 0x81, 0x97, 0x9d, + 0xde, 0xdb, 0x50, 0xa3, 0xb1, 0x82, 0x92, 0x46, 0xcd}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xea, 0xc4, 0x5b, 0x61, 0x4, 0x69, 0x89, 0xd6}; + lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe8, 0x34, 0xbb, 0xe6, 0x90, 0x61, 0x6a, + 0x33, 0x17, 0x19, 0xa2, 0x25, 0x74, 0xe4}; + lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x2, 0x76, 0xd5}; + lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x22, 0x3d, 0xd3, 0xc2, 0xb0}; + lwmqtt_string_t topic_filter_s10 = {5, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5740, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1845, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\t\CAN\145\171\148w\238,P\186\ETBHJo\217H\202\133\175\171.\147\134f\238\240X\231\137", _pubPktID = 1370, _pubBody = -// "`\241\GS\145\216\168\157\253JO\171\208j1]K\RSL<\242\&4", _pubProps = []} -TEST(Publish311QCTest, Encode99) { - uint8_t pkt[] = {0x32, 0x36, 0x0, 0x1d, 0x9, 0x18, 0x91, 0xab, 0x94, 0x77, 0xee, 0x2c, 0x50, 0xba, - 0x17, 0x48, 0x4a, 0x6f, 0xd9, 0x48, 0xca, 0x85, 0xaf, 0xab, 0x2e, 0x93, 0x86, 0x66, - 0xee, 0xf0, 0x58, 0xe7, 0x89, 0x5, 0x5a, 0x60, 0xf1, 0x1d, 0x91, 0xd8, 0xa8, 0x9d, - 0xfd, 0x4a, 0x4f, 0xab, 0xd0, 0x6a, 0x31, 0x5d, 0x4b, 0x1e, 0x4c, 0x3c, 0xf2, 0x34}; +// SubscribeRequest 12377 [("\156\222Z\207\145\DC1\171\133j\149\210Dr\137\&1\130\219\182 2H\210\203s",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode78) { + uint8_t pkt[] = {0x82, 0x1d, 0x30, 0x59, 0x0, 0x18, 0x9c, 0xde, 0x5a, 0xcf, 0x91, 0x11, 0xab, 0x85, 0x6a, 0x95, + 0xd2, 0x44, 0x72, 0x89, 0x31, 0x82, 0xdb, 0xb6, 0x20, 0x32, 0x48, 0xd2, 0xcb, 0x73, 0x1}; - uint8_t buf[66] = {0}; + uint8_t buf[41] = {0}; - uint8_t topic_bytes[] = {0x9, 0x18, 0x91, 0xab, 0x94, 0x77, 0xee, 0x2c, 0x50, 0xba, 0x17, 0x48, 0x4a, 0x6f, 0xd9, - 0x48, 0xca, 0x85, 0xaf, 0xab, 0x2e, 0x93, 0x86, 0x66, 0xee, 0xf0, 0x58, 0xe7, 0x89}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x60, 0xf1, 0x1d, 0x91, 0xd8, 0xa8, 0x9d, 0xfd, 0x4a, 0x4f, 0xab, - 0xd0, 0x6a, 0x31, 0x5d, 0x4b, 0x1e, 0x4c, 0x3c, 0xf2, 0x34}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x9c, 0xde, 0x5a, 0xcf, 0x91, 0x11, 0xab, 0x85, 0x6a, 0x95, 0xd2, 0x44, + 0x72, 0x89, 0x31, 0x82, 0xdb, 0xb6, 0x20, 0x32, 0x48, 0xd2, 0xcb, 0x73}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12377, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 290 [("-\CAN\FSe\144\STXP\243wu\191%\250\176\&5\250\204V\239\137}",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\128&U[\222\&1,\232\&9\137\194\vD\146\155m\DLE\213\249\229d\FSI+\v]",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\232g?\215\156\STXD\132\NUL\197\ACK(\234:\DC1\153C\148\b/\180^",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\176\160\178:&\NUL\182\\\173\RS\138\144\138@\148U\ENQA>\191\&1t",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),(".\162!\217\216*\155\205\236\RSc\tEWe2\159'\216\149\193\235\DC1[\200\188\233\230\215",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\187\152j\248\219\&2\152\&3\SO\GS\135",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\176\144m\168\226",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\227\202\180@6a",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("|\129\183e\162\160X\243e\238E\183\184\128SY\157\EM6\253",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode79) { + uint8_t pkt[] = {0x82, 0xbf, 0x1, 0x1, 0x22, 0x0, 0x15, 0x2d, 0x18, 0x1c, 0x65, 0x90, 0x2, 0x50, 0xf3, 0x77, 0x75, + 0xbf, 0x25, 0xfa, 0xb0, 0x35, 0xfa, 0xcc, 0x56, 0xef, 0x89, 0x7d, 0x1, 0x0, 0x1a, 0x80, 0x26, 0x55, + 0x5b, 0xde, 0x31, 0x2c, 0xe8, 0x39, 0x89, 0xc2, 0xb, 0x44, 0x92, 0x9b, 0x6d, 0x10, 0xd5, 0xf9, 0xe5, + 0x64, 0x1c, 0x49, 0x2b, 0xb, 0x5d, 0x0, 0x0, 0x16, 0xe8, 0x67, 0x3f, 0xd7, 0x9c, 0x2, 0x44, 0x84, + 0x0, 0xc5, 0x6, 0x28, 0xea, 0x3a, 0x11, 0x99, 0x43, 0x94, 0x8, 0x2f, 0xb4, 0x5e, 0x1, 0x0, 0x16, + 0xb0, 0xa0, 0xb2, 0x3a, 0x26, 0x0, 0xb6, 0x5c, 0xad, 0x1e, 0x8a, 0x90, 0x8a, 0x40, 0x94, 0x55, 0x5, + 0x41, 0x3e, 0xbf, 0x31, 0x74, 0x1, 0x0, 0x1d, 0x2e, 0xa2, 0x21, 0xd9, 0xd8, 0x2a, 0x9b, 0xcd, 0xec, + 0x1e, 0x63, 0x9, 0x45, 0x57, 0x65, 0x32, 0x9f, 0x27, 0xd8, 0x95, 0xc1, 0xeb, 0x11, 0x5b, 0xc8, 0xbc, + 0xe9, 0xe6, 0xd7, 0x2, 0x0, 0xb, 0xbb, 0x98, 0x6a, 0xf8, 0xdb, 0x32, 0x98, 0x33, 0xe, 0x1d, 0x87, + 0x2, 0x0, 0x5, 0xb0, 0x90, 0x6d, 0xa8, 0xe2, 0x1, 0x0, 0x6, 0xe3, 0xca, 0xb4, 0x40, 0x36, 0x61, + 0x2, 0x0, 0x14, 0x7c, 0x81, 0xb7, 0x65, 0xa2, 0xa0, 0x58, 0xf3, 0x65, 0xee, 0x45, 0xb7, 0xb8, 0x80, + 0x53, 0x59, 0x9d, 0x19, 0x36, 0xfd, 0x1}; + + uint8_t buf[204] = {0}; + + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x2d, 0x18, 0x1c, 0x65, 0x90, 0x2, 0x50, 0xf3, 0x77, 0x75, 0xbf, + 0x25, 0xfa, 0xb0, 0x35, 0xfa, 0xcc, 0x56, 0xef, 0x89, 0x7d}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x80, 0x26, 0x55, 0x5b, 0xde, 0x31, 0x2c, 0xe8, 0x39, 0x89, 0xc2, 0xb, 0x44, + 0x92, 0x9b, 0x6d, 0x10, 0xd5, 0xf9, 0xe5, 0x64, 0x1c, 0x49, 0x2b, 0xb, 0x5d}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe8, 0x67, 0x3f, 0xd7, 0x9c, 0x2, 0x44, 0x84, 0x0, 0xc5, 0x6, + 0x28, 0xea, 0x3a, 0x11, 0x99, 0x43, 0x94, 0x8, 0x2f, 0xb4, 0x5e}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb0, 0xa0, 0xb2, 0x3a, 0x26, 0x0, 0xb6, 0x5c, 0xad, 0x1e, 0x8a, + 0x90, 0x8a, 0x40, 0x94, 0x55, 0x5, 0x41, 0x3e, 0xbf, 0x31, 0x74}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x2e, 0xa2, 0x21, 0xd9, 0xd8, 0x2a, 0x9b, 0xcd, 0xec, 0x1e, + 0x63, 0x9, 0x45, 0x57, 0x65, 0x32, 0x9f, 0x27, 0xd8, 0x95, + 0xc1, 0xeb, 0x11, 0x5b, 0xc8, 0xbc, 0xe9, 0xe6, 0xd7}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xbb, 0x98, 0x6a, 0xf8, 0xdb, 0x32, 0x98, 0x33, 0xe, 0x1d, 0x87}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xb0, 0x90, 0x6d, 0xa8, 0xe2}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe3, 0xca, 0xb4, 0x40, 0x36, 0x61}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x7c, 0x81, 0xb7, 0x65, 0xa2, 0xa0, 0x58, 0xf3, 0x65, 0xee, + 0x45, 0xb7, 0xb8, 0x80, 0x53, 0x59, 0x9d, 0x19, 0x36, 0xfd}; + lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1370, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 290, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\164.\DC1\135\131x\231n\143\DC3\247\SYN\189D\158\166\166\171\143\129\137\215", _pubPktID = 27834, _pubBody = -// "e8`\SO\145\RS`\179\229\146", _pubProps = []} -TEST(Publish311QCTest, Encode100) { - uint8_t pkt[] = {0x3b, 0x24, 0x0, 0x16, 0xa4, 0x2e, 0x11, 0x87, 0x83, 0x78, 0xe7, 0x6e, 0x8f, - 0x13, 0xf7, 0x16, 0xbd, 0x44, 0x9e, 0xa6, 0xa6, 0xab, 0x8f, 0x81, 0x89, 0xd7, - 0x6c, 0xba, 0x65, 0x38, 0x60, 0xe, 0x91, 0x1e, 0x60, 0xb3, 0xe5, 0x92}; +// SubscribeRequest 28088 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),(":\193@\178\186\219\136\180",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\254\238]\245\184?\239",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("W'\132<\DC3\nUBMC\159\172b\NUL\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode80) { + uint8_t pkt[] = {0x82, 0x2c, 0x6d, 0xb8, 0x0, 0x0, 0x2, 0x0, 0x8, 0x3a, 0xc1, 0x40, 0xb2, 0xba, 0xdb, 0x88, + 0xb4, 0x2, 0x0, 0x7, 0xfe, 0xee, 0x5d, 0xf5, 0xb8, 0x3f, 0xef, 0x0, 0x0, 0xf, 0x57, 0x27, + 0x84, 0x3c, 0x13, 0xa, 0x55, 0x42, 0x4d, 0x43, 0x9f, 0xac, 0x62, 0x0, 0xb9, 0x1}; - uint8_t buf[48] = {0}; + uint8_t buf[56] = {0}; - uint8_t topic_bytes[] = {0xa4, 0x2e, 0x11, 0x87, 0x83, 0x78, 0xe7, 0x6e, 0x8f, 0x13, 0xf7, - 0x16, 0xbd, 0x44, 0x9e, 0xa6, 0xa6, 0xab, 0x8f, 0x81, 0x89, 0xd7}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x65, 0x38, 0x60, 0xe, 0x91, 0x1e, 0x60, 0xb3, 0xe5, 0x92}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x3a, 0xc1, 0x40, 0xb2, 0xba, 0xdb, 0x88, 0xb4}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xfe, 0xee, 0x5d, 0xf5, 0xb8, 0x3f, 0xef}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x57, 0x27, 0x84, 0x3c, 0x13, 0xa, 0x55, 0x42, + 0x4d, 0x43, 0x9f, 0xac, 0x62, 0x0, 0xb9}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 27834, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28088, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\GS'O\GS\157L:\160!\232\238\251\210\SOH\149\247[\200\206V\228NIF", _pubPktID = 10712, _pubBody = -// "g\175\150\CANu\230<(Z\145\145 g\177\217P7\ENQ`V\167\212k\177\SUB.", _pubProps = [PropReasonString -// "\ACK\206\206\216\&0\SYN\150\147%\197;\149\141\"(\DC2>@\SI\237\215",PropServerReference -// "\153\168\222t9\240\&3\202.p\239\aF.\139i\168\221\251\"\227",PropMaximumPacketSize 27829,PropTopicAlias -// 4075,PropMessageExpiryInterval 10312,PropTopicAlias 19253,PropResponseTopic "\205\177B",PropReasonString -// "\SO\163L\178(\204\242\131\132R\213V*\175|\GS|\STX",PropTopicAlias 10427,PropSubscriptionIdentifierAvailable -// 197,PropRequestResponseInformation 111,PropServerReference -// "\142\226\140\189J\253\DC3p\220\&0F\157\170\142",PropTopicAlias 13732,PropRequestProblemInformation -// 181,PropReceiveMaximum 2850,PropMaximumQoS 66,PropWildcardSubscriptionAvailable 208,PropSharedSubscriptionAvailable -// 255]} -TEST(Publish5QCTest, Encode1) { - uint8_t pkt[] = { - 0x33, 0xb9, 0x1, 0x0, 0x18, 0x1d, 0x27, 0x4f, 0x1d, 0x9d, 0x4c, 0x3a, 0xa0, 0x21, 0xe8, 0xee, 0xfb, 0xd2, 0x1, - 0x95, 0xf7, 0x5b, 0xc8, 0xce, 0x56, 0xe4, 0x4e, 0x49, 0x46, 0x29, 0xd8, 0x81, 0x1, 0x1f, 0x0, 0x15, 0x6, 0xce, - 0xce, 0xd8, 0x30, 0x16, 0x96, 0x93, 0x25, 0xc5, 0x3b, 0x95, 0x8d, 0x22, 0x28, 0x12, 0x3e, 0x40, 0xf, 0xed, 0xd7, - 0x1c, 0x0, 0x15, 0x99, 0xa8, 0xde, 0x74, 0x39, 0xf0, 0x33, 0xca, 0x2e, 0x70, 0xef, 0x7, 0x46, 0x2e, 0x8b, 0x69, - 0xa8, 0xdd, 0xfb, 0x22, 0xe3, 0x27, 0x0, 0x0, 0x6c, 0xb5, 0x23, 0xf, 0xeb, 0x2, 0x0, 0x0, 0x28, 0x48, 0x23, - 0x4b, 0x35, 0x8, 0x0, 0x3, 0xcd, 0xb1, 0x42, 0x1f, 0x0, 0x12, 0xe, 0xa3, 0x4c, 0xb2, 0x28, 0xcc, 0xf2, 0x83, - 0x84, 0x52, 0xd5, 0x56, 0x2a, 0xaf, 0x7c, 0x1d, 0x7c, 0x2, 0x23, 0x28, 0xbb, 0x29, 0xc5, 0x19, 0x6f, 0x1c, 0x0, - 0xe, 0x8e, 0xe2, 0x8c, 0xbd, 0x4a, 0xfd, 0x13, 0x70, 0xdc, 0x30, 0x46, 0x9d, 0xaa, 0x8e, 0x23, 0x35, 0xa4, 0x17, - 0xb5, 0x21, 0xb, 0x22, 0x24, 0x42, 0x28, 0xd0, 0x2a, 0xff, 0x67, 0xaf, 0x96, 0x18, 0x75, 0xe6, 0x3c, 0x28, 0x5a, - 0x91, 0x91, 0x20, 0x67, 0xb1, 0xd9, 0x50, 0x37, 0x5, 0x60, 0x56, 0xa7, 0xd4, 0x6b, 0xb1, 0x1a, 0x2e}; - - uint8_t buf[198] = {0}; - - uint8_t topic_bytes[] = {0x1d, 0x27, 0x4f, 0x1d, 0x9d, 0x4c, 0x3a, 0xa0, 0x21, 0xe8, 0xee, 0xfb, - 0xd2, 0x1, 0x95, 0xf7, 0x5b, 0xc8, 0xce, 0x56, 0xe4, 0x4e, 0x49, 0x46}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x67, 0xaf, 0x96, 0x18, 0x75, 0xe6, 0x3c, 0x28, 0x5a, 0x91, 0x91, 0x20, 0x67, - 0xb1, 0xd9, 0x50, 0x37, 0x5, 0x60, 0x56, 0xa7, 0xd4, 0x6b, 0xb1, 0x1a, 0x2e}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; +// SubscribeRequest 4272 [("\":\159\"\202S\RS\ACK\244z5",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\242\235\190\253wC6\EMH\250\232\247\131u\172\a=\132\224\&9\192 \GS",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\222!bl\193ck\202\&8K",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\162\190\167\211\FS\232\161;\130{%\ENQ\ACK\200\DC1\153\206\DC2\172b\193r\138",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("!",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode81) { + uint8_t pkt[] = {0x82, 0x55, 0x10, 0xb0, 0x0, 0xb, 0x22, 0x3a, 0x9f, 0x22, 0xca, 0x53, 0x1e, 0x6, 0xf4, + 0x7a, 0x35, 0x2, 0x0, 0x17, 0xf2, 0xeb, 0xbe, 0xfd, 0x77, 0x43, 0x36, 0x19, 0x48, 0xfa, + 0xe8, 0xf7, 0x83, 0x75, 0xac, 0x7, 0x3d, 0x84, 0xe0, 0x39, 0xc0, 0x20, 0x1d, 0x0, 0x0, + 0xa, 0xde, 0x21, 0x62, 0x6c, 0xc1, 0x63, 0x6b, 0xca, 0x38, 0x4b, 0x0, 0x0, 0x17, 0xa2, + 0xbe, 0xa7, 0xd3, 0x1c, 0xe8, 0xa1, 0x3b, 0x82, 0x7b, 0x25, 0x5, 0x6, 0xc8, 0x11, 0x99, + 0xce, 0x12, 0xac, 0x62, 0xc1, 0x72, 0x8a, 0x2, 0x0, 0x1, 0x21, 0x2}; - uint8_t bytesprops0[] = {0x6, 0xce, 0xce, 0xd8, 0x30, 0x16, 0x96, 0x93, 0x25, 0xc5, 0x3b, - 0x95, 0x8d, 0x22, 0x28, 0x12, 0x3e, 0x40, 0xf, 0xed, 0xd7}; - uint8_t bytesprops1[] = {0x99, 0xa8, 0xde, 0x74, 0x39, 0xf0, 0x33, 0xca, 0x2e, 0x70, 0xef, - 0x7, 0x46, 0x2e, 0x8b, 0x69, 0xa8, 0xdd, 0xfb, 0x22, 0xe3}; - uint8_t bytesprops2[] = {0xcd, 0xb1, 0x42}; - uint8_t bytesprops3[] = {0xe, 0xa3, 0x4c, 0xb2, 0x28, 0xcc, 0xf2, 0x83, 0x84, - 0x52, 0xd5, 0x56, 0x2a, 0xaf, 0x7c, 0x1d, 0x7c, 0x2}; - uint8_t bytesprops4[] = {0x8e, 0xe2, 0x8c, 0xbd, 0x4a, 0xfd, 0x13, 0x70, 0xdc, 0x30, 0x46, 0x9d, 0xaa, 0x8e}; + uint8_t buf[97] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27829}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4075}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10312}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19253}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10427}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13732}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2850}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 255}}, - }; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x22, 0x3a, 0x9f, 0x22, 0xca, 0x53, 0x1e, 0x6, 0xf4, 0x7a, 0x35}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf2, 0xeb, 0xbe, 0xfd, 0x77, 0x43, 0x36, 0x19, 0x48, 0xfa, 0xe8, 0xf7, + 0x83, 0x75, 0xac, 0x7, 0x3d, 0x84, 0xe0, 0x39, 0xc0, 0x20, 0x1d}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xde, 0x21, 0x62, 0x6c, 0xc1, 0x63, 0x6b, 0xca, 0x38, 0x4b}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa2, 0xbe, 0xa7, 0xd3, 0x1c, 0xe8, 0xa1, 0x3b, 0x82, 0x7b, 0x25, 0x5, + 0x6, 0xc8, 0x11, 0x99, 0xce, 0x12, 0xac, 0x62, 0xc1, 0x72, 0x8a}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x21}; + lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10712, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4272, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "q\140\EOT\210\163\254Vg\160L\221g\182\231\149f3\239k\200\DC2", _pubPktID = 10731, _pubBody = -// "\229\183\252?\173\165\FS\181?\130", _pubProps = [PropMaximumPacketSize 8227,PropResponseInformation -// "\SUB\179\237\128+i\162P\210\239\&4.\CAN\200\157x",PropAssignedClientIdentifier -// "\ESC\144\133\137\148{\244\242_\166^\246M\156\151\213\170I\129\168\165\217\195\209",PropServerReference -// "G4z\SI\GS@\238U\FSqbh",PropResponseInformation "8\SI3]\CAN"]} -TEST(Publish5QCTest, Encode2) { - uint8_t pkt[] = {0x3c, 0x6e, 0x0, 0x15, 0x71, 0x8c, 0x4, 0xd2, 0xa3, 0xfe, 0x56, 0x67, 0xa0, 0x4c, 0xdd, 0x67, - 0xb6, 0xe7, 0x95, 0x66, 0x33, 0xef, 0x6b, 0xc8, 0x12, 0x29, 0xeb, 0x4a, 0x27, 0x0, 0x0, 0x20, - 0x23, 0x1a, 0x0, 0x10, 0x1a, 0xb3, 0xed, 0x80, 0x2b, 0x69, 0xa2, 0x50, 0xd2, 0xef, 0x34, 0x2e, - 0x18, 0xc8, 0x9d, 0x78, 0x12, 0x0, 0x18, 0x1b, 0x90, 0x85, 0x89, 0x94, 0x7b, 0xf4, 0xf2, 0x5f, - 0xa6, 0x5e, 0xf6, 0x4d, 0x9c, 0x97, 0xd5, 0xaa, 0x49, 0x81, 0xa8, 0xa5, 0xd9, 0xc3, 0xd1, 0x1c, - 0x0, 0xc, 0x47, 0x34, 0x7a, 0xf, 0x1d, 0x40, 0xee, 0x55, 0x1c, 0x71, 0x62, 0x68, 0x1a, 0x0, - 0x5, 0x38, 0xf, 0x33, 0x5d, 0x18, 0xe5, 0xb7, 0xfc, 0x3f, 0xad, 0xa5, 0x1c, 0xb5, 0x3f, 0x82}; - - uint8_t buf[122] = {0}; +// SubscribeRequest 14420 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\193\143\248\171\SUBB\US\162U`\238\207",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\230\138\SIF\159~gN\227\241|",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("'\194\SUB\DC1\143+,\"\128\209\SUB\220\162\DC1\240\196\DC3\226\NUL\146\226:\STX\189J*~&\200",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("~3\195L&]\160\184\161\STX\168\181#Em!\205\252K\253",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("dI\177g\202Vp4k\ENQ\178\255z\171x\212\STX\224\RSS\FS\169\144\180\151\182\201",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("6\NAK\EOT\145\216\229B\EM\247\242\&1b\223\131\141",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode82) { + uint8_t pkt[] = {0x82, 0x89, 0x1, 0x38, 0x54, 0x0, 0x0, 0x0, 0x0, 0xc, 0xc1, 0x8f, 0xf8, 0xab, 0x1a, 0x42, + 0x1f, 0xa2, 0x55, 0x60, 0xee, 0xcf, 0x0, 0x0, 0xb, 0xe6, 0x8a, 0xf, 0x46, 0x9f, 0x7e, 0x67, + 0x4e, 0xe3, 0xf1, 0x7c, 0x0, 0x0, 0x1d, 0x27, 0xc2, 0x1a, 0x11, 0x8f, 0x2b, 0x2c, 0x22, 0x80, + 0xd1, 0x1a, 0xdc, 0xa2, 0x11, 0xf0, 0xc4, 0x13, 0xe2, 0x0, 0x92, 0xe2, 0x3a, 0x2, 0xbd, 0x4a, + 0x2a, 0x7e, 0x26, 0xc8, 0x2, 0x0, 0x14, 0x7e, 0x33, 0xc3, 0x4c, 0x26, 0x5d, 0xa0, 0xb8, 0xa1, + 0x2, 0xa8, 0xb5, 0x23, 0x45, 0x6d, 0x21, 0xcd, 0xfc, 0x4b, 0xfd, 0x2, 0x0, 0x1b, 0x64, 0x49, + 0xb1, 0x67, 0xca, 0x56, 0x70, 0x34, 0x6b, 0x5, 0xb2, 0xff, 0x7a, 0xab, 0x78, 0xd4, 0x2, 0xe0, + 0x1e, 0x53, 0x1c, 0xa9, 0x90, 0xb4, 0x97, 0xb6, 0xc9, 0x2, 0x0, 0xf, 0x36, 0x15, 0x4, 0x91, + 0xd8, 0xe5, 0x42, 0x19, 0xf7, 0xf2, 0x31, 0x62, 0xdf, 0x83, 0x8d, 0x2}; - uint8_t topic_bytes[] = {0x71, 0x8c, 0x4, 0xd2, 0xa3, 0xfe, 0x56, 0x67, 0xa0, 0x4c, 0xdd, - 0x67, 0xb6, 0xe7, 0x95, 0x66, 0x33, 0xef, 0x6b, 0xc8, 0x12}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xe5, 0xb7, 0xfc, 0x3f, 0xad, 0xa5, 0x1c, 0xb5, 0x3f, 0x82}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + uint8_t buf[150] = {0}; - uint8_t bytesprops0[] = {0x1a, 0xb3, 0xed, 0x80, 0x2b, 0x69, 0xa2, 0x50, - 0xd2, 0xef, 0x34, 0x2e, 0x18, 0xc8, 0x9d, 0x78}; - uint8_t bytesprops1[] = {0x1b, 0x90, 0x85, 0x89, 0x94, 0x7b, 0xf4, 0xf2, 0x5f, 0xa6, 0x5e, 0xf6, - 0x4d, 0x9c, 0x97, 0xd5, 0xaa, 0x49, 0x81, 0xa8, 0xa5, 0xd9, 0xc3, 0xd1}; - uint8_t bytesprops2[] = {0x47, 0x34, 0x7a, 0xf, 0x1d, 0x40, 0xee, 0x55, 0x1c, 0x71, 0x62, 0x68}; - uint8_t bytesprops3[] = {0x38, 0xf, 0x33, 0x5d, 0x18}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc1, 0x8f, 0xf8, 0xab, 0x1a, 0x42, 0x1f, 0xa2, 0x55, 0x60, 0xee, 0xcf}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe6, 0x8a, 0xf, 0x46, 0x9f, 0x7e, 0x67, 0x4e, 0xe3, 0xf1, 0x7c}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x27, 0xc2, 0x1a, 0x11, 0x8f, 0x2b, 0x2c, 0x22, 0x80, 0xd1, + 0x1a, 0xdc, 0xa2, 0x11, 0xf0, 0xc4, 0x13, 0xe2, 0x0, 0x92, + 0xe2, 0x3a, 0x2, 0xbd, 0x4a, 0x2a, 0x7e, 0x26, 0xc8}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x7e, 0x33, 0xc3, 0x4c, 0x26, 0x5d, 0xa0, 0xb8, 0xa1, 0x2, + 0xa8, 0xb5, 0x23, 0x45, 0x6d, 0x21, 0xcd, 0xfc, 0x4b, 0xfd}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x64, 0x49, 0xb1, 0x67, 0xca, 0x56, 0x70, 0x34, 0x6b, 0x5, 0xb2, 0xff, 0x7a, 0xab, + 0x78, 0xd4, 0x2, 0xe0, 0x1e, 0x53, 0x1c, 0xa9, 0x90, 0xb4, 0x97, 0xb6, 0xc9}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x36, 0x15, 0x4, 0x91, 0xd8, 0xe5, 0x42, 0x19, + 0xf7, 0xf2, 0x31, 0x62, 0xdf, 0x83, 0x8d}; + lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8227}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops3}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10731, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14420, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "I0\v\142\237", _pubPktID = 7560, -// _pubBody = "`\189\255\237\166\235-D\NAK", _pubProps = [PropSubscriptionIdentifier 18,PropRequestResponseInformation -// 149,PropTopicAlias 26028,PropServerKeepAlive 15158,PropResponseInformation -// "f\128\219\163\&6rQ",PropAuthenticationData "\203\ACK_\165\155\220\158\b\178o",PropContentType -// "\241\234\158\227\CANUWN\242\249L\228h\153\167+\129\&6/"]} -TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = {0x35, 0x4a, 0x0, 0x5, 0x49, 0x30, 0xb, 0x8e, 0xed, 0x1d, 0x88, 0x37, 0xb, 0x12, 0x19, 0x95, - 0x23, 0x65, 0xac, 0x13, 0x3b, 0x36, 0x1a, 0x0, 0x7, 0x66, 0x80, 0xdb, 0xa3, 0x36, 0x72, 0x51, - 0x16, 0x0, 0xa, 0xcb, 0x6, 0x5f, 0xa5, 0x9b, 0xdc, 0x9e, 0x8, 0xb2, 0x6f, 0x3, 0x0, 0x13, - 0xf1, 0xea, 0x9e, 0xe3, 0x18, 0x55, 0x57, 0x4e, 0xf2, 0xf9, 0x4c, 0xe4, 0x68, 0x99, 0xa7, 0x2b, - 0x81, 0x36, 0x2f, 0x60, 0xbd, 0xff, 0xed, 0xa6, 0xeb, 0x2d, 0x44, 0x15}; - - uint8_t buf[86] = {0}; +// SubscribeRequest 27160 [("\162D\159",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\195_\131\NULo|\DC3\153\204\130Z\129\a\148$\133jPw\238<\201\&1X\151F\133\248\217l",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\168\&1\255\241I\162\173v\254uZ*\140G",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\US=\184j\\AA\155\156@\178\229r'K0i\204\ESC\168Q'\196\226\234\233",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode83) { + uint8_t pkt[] = {0x82, 0x57, 0x6a, 0x18, 0x0, 0x3, 0xa2, 0x44, 0x9f, 0x2, 0x0, 0x1e, 0xc3, 0x5f, 0x83, + 0x0, 0x6f, 0x7c, 0x13, 0x99, 0xcc, 0x82, 0x5a, 0x81, 0x7, 0x94, 0x24, 0x85, 0x6a, 0x50, + 0x77, 0xee, 0x3c, 0xc9, 0x31, 0x58, 0x97, 0x46, 0x85, 0xf8, 0xd9, 0x6c, 0x2, 0x0, 0xe, + 0xa8, 0x31, 0xff, 0xf1, 0x49, 0xa2, 0xad, 0x76, 0xfe, 0x75, 0x5a, 0x2a, 0x8c, 0x47, 0x1, + 0x0, 0x1a, 0x1f, 0x3d, 0xb8, 0x6a, 0x5c, 0x41, 0x41, 0x9b, 0x9c, 0x40, 0xb2, 0xe5, 0x72, + 0x27, 0x4b, 0x30, 0x69, 0xcc, 0x1b, 0xa8, 0x51, 0x27, 0xc4, 0xe2, 0xea, 0xe9, 0x2}; - uint8_t topic_bytes[] = {0x49, 0x30, 0xb, 0x8e, 0xed}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x60, 0xbd, 0xff, 0xed, 0xa6, 0xeb, 0x2d, 0x44, 0x15}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + uint8_t buf[99] = {0}; - uint8_t bytesprops0[] = {0x66, 0x80, 0xdb, 0xa3, 0x36, 0x72, 0x51}; - uint8_t bytesprops1[] = {0xcb, 0x6, 0x5f, 0xa5, 0x9b, 0xdc, 0x9e, 0x8, 0xb2, 0x6f}; - uint8_t bytesprops2[] = {0xf1, 0xea, 0x9e, 0xe3, 0x18, 0x55, 0x57, 0x4e, 0xf2, 0xf9, - 0x4c, 0xe4, 0x68, 0x99, 0xa7, 0x2b, 0x81, 0x36, 0x2f}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xa2, 0x44, 0x9f}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc3, 0x5f, 0x83, 0x0, 0x6f, 0x7c, 0x13, 0x99, 0xcc, 0x82, + 0x5a, 0x81, 0x7, 0x94, 0x24, 0x85, 0x6a, 0x50, 0x77, 0xee, + 0x3c, 0xc9, 0x31, 0x58, 0x97, 0x46, 0x85, 0xf8, 0xd9, 0x6c}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa8, 0x31, 0xff, 0xf1, 0x49, 0xa2, 0xad, + 0x76, 0xfe, 0x75, 0x5a, 0x2a, 0x8c, 0x47}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x1f, 0x3d, 0xb8, 0x6a, 0x5c, 0x41, 0x41, 0x9b, 0x9c, 0x40, 0xb2, 0xe5, 0x72, + 0x27, 0x4b, 0x30, 0x69, 0xcc, 0x1b, 0xa8, 0x51, 0x27, 0xc4, 0xe2, 0xea, 0xe9}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26028}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15158}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7560, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27160, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\214d)\246\152\n-f", _pubPktID = -// 27404, _pubBody = "\187\167\151\192YY\244\252\216W\216\180S\218A\187\255\140'\172dG\187", _pubProps = -// [PropSubscriptionIdentifierAvailable 99,PropPayloadFormatIndicator 40,PropTopicAliasMaximum -// 4746,PropSharedSubscriptionAvailable 89,PropServerReference -// "&\b\229+\163\&5\132\203\213J\bW\228\161",PropRequestResponseInformation 65,PropSharedSubscriptionAvailable -// 57,PropContentType -// "\148\136\244\ENQ\154\253\142*\231ac\179\CAN\135-X\213\DC4^\137v\240nL`\187\\.\159",PropWillDelayInterval -// 22673,PropServerReference "\167\163\166\RS\ESC\140h\197\243 F\169I\233\195\226$\ACK\189a",PropMaximumPacketSize -// 19749,PropServerReference -// "H\155\148\ETXS\DEL9\219_\203\128\DLEAV\180\184\160I+t\152#\209\SO\132\220\214\225k\213",PropMaximumPacketSize -// 19964,PropServerKeepAlive 772,PropAuthenticationData -// "\209\209f\208ds%\155T\181\173\148\221\179\205\191G\DLE\213\149\235\237",PropSharedSubscriptionAvailable -// 146,PropResponseInformation "en\DC2\141\SYN!\151\183\166\145,7\147",PropMaximumQoS 12,PropReasonString -// "\225}\172\212\US\153\150&\245\147\EOTL\178^\250sY#wo+\215_/\217\SOH",PropMessageExpiryInterval -// 6189,PropSubscriptionIdentifier 6,PropTopicAlias 16029,PropWillDelayInterval 5712,PropMessageExpiryInterval -// 11452,PropRequestResponseInformation 28,PropRequestResponseInformation 206,PropUserProperty -// "\NAKl\244\164\SOH\179\138S\US\167\\\239sVkE\151\&8P\203u\211\249\239" "",PropTopicAliasMaximum -// 25654,PropWillDelayInterval 28483]} -TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = { - 0x3b, 0xb4, 0x2, 0x0, 0x8, 0xd6, 0x64, 0x29, 0xf6, 0x98, 0xa, 0x2d, 0x66, 0x6b, 0xc, 0x8f, 0x2, 0x29, 0x63, - 0x1, 0x28, 0x22, 0x12, 0x8a, 0x2a, 0x59, 0x1c, 0x0, 0xe, 0x26, 0x8, 0xe5, 0x2b, 0xa3, 0x35, 0x84, 0xcb, 0xd5, - 0x4a, 0x8, 0x57, 0xe4, 0xa1, 0x19, 0x41, 0x2a, 0x39, 0x3, 0x0, 0x1d, 0x94, 0x88, 0xf4, 0x5, 0x9a, 0xfd, 0x8e, - 0x2a, 0xe7, 0x61, 0x63, 0xb3, 0x18, 0x87, 0x2d, 0x58, 0xd5, 0x14, 0x5e, 0x89, 0x76, 0xf0, 0x6e, 0x4c, 0x60, 0xbb, - 0x5c, 0x2e, 0x9f, 0x18, 0x0, 0x0, 0x58, 0x91, 0x1c, 0x0, 0x14, 0xa7, 0xa3, 0xa6, 0x1e, 0x1b, 0x8c, 0x68, 0xc5, - 0xf3, 0x20, 0x46, 0xa9, 0x49, 0xe9, 0xc3, 0xe2, 0x24, 0x6, 0xbd, 0x61, 0x27, 0x0, 0x0, 0x4d, 0x25, 0x1c, 0x0, - 0x1e, 0x48, 0x9b, 0x94, 0x3, 0x53, 0x7f, 0x39, 0xdb, 0x5f, 0xcb, 0x80, 0x10, 0x41, 0x56, 0xb4, 0xb8, 0xa0, 0x49, - 0x2b, 0x74, 0x98, 0x23, 0xd1, 0xe, 0x84, 0xdc, 0xd6, 0xe1, 0x6b, 0xd5, 0x27, 0x0, 0x0, 0x4d, 0xfc, 0x13, 0x3, - 0x4, 0x16, 0x0, 0x16, 0xd1, 0xd1, 0x66, 0xd0, 0x64, 0x73, 0x25, 0x9b, 0x54, 0xb5, 0xad, 0x94, 0xdd, 0xb3, 0xcd, - 0xbf, 0x47, 0x10, 0xd5, 0x95, 0xeb, 0xed, 0x2a, 0x92, 0x1a, 0x0, 0xd, 0x65, 0x6e, 0x12, 0x8d, 0x16, 0x21, 0x97, - 0xb7, 0xa6, 0x91, 0x2c, 0x37, 0x93, 0x24, 0xc, 0x1f, 0x0, 0x1a, 0xe1, 0x7d, 0xac, 0xd4, 0x1f, 0x99, 0x96, 0x26, - 0xf5, 0x93, 0x4, 0x4c, 0xb2, 0x5e, 0xfa, 0x73, 0x59, 0x23, 0x77, 0x6f, 0x2b, 0xd7, 0x5f, 0x2f, 0xd9, 0x1, 0x2, - 0x0, 0x0, 0x18, 0x2d, 0xb, 0x6, 0x23, 0x3e, 0x9d, 0x18, 0x0, 0x0, 0x16, 0x50, 0x2, 0x0, 0x0, 0x2c, 0xbc, - 0x19, 0x1c, 0x19, 0xce, 0x26, 0x0, 0x18, 0x15, 0x6c, 0xf4, 0xa4, 0x1, 0xb3, 0x8a, 0x53, 0x1f, 0xa7, 0x5c, 0xef, - 0x73, 0x56, 0x6b, 0x45, 0x97, 0x38, 0x50, 0xcb, 0x75, 0xd3, 0xf9, 0xef, 0x0, 0x0, 0x22, 0x64, 0x36, 0x18, 0x0, - 0x0, 0x6f, 0x43, 0xbb, 0xa7, 0x97, 0xc0, 0x59, 0x59, 0xf4, 0xfc, 0xd8, 0x57, 0xd8, 0xb4, 0x53, 0xda, 0x41, 0xbb, - 0xff, 0x8c, 0x27, 0xac, 0x64, 0x47, 0xbb}; +// SubscribeRequest 22660 +// [("k\215\&6o4\168\148\NAKl|\DC2eLi\r\203\ETX\152\158\131\197\142\143\248\134l\CAN\243\SYN",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("!m\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS +// = QoS1}),("t\a\155\243\134r\ETB)\244Y:",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\144",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("Dy",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("\169p\197\187\137\SUBA\138\224\242\167\174\rh\b\143\210f\225\220\STX\200\t",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\rw\214#2r\221~\249",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode84) { + uint8_t pkt[] = {0x82, 0x65, 0x58, 0x84, 0x0, 0x1d, 0x6b, 0xd7, 0x36, 0x6f, 0x34, 0xa8, 0x94, 0x15, 0x6c, + 0x7c, 0x12, 0x65, 0x4c, 0x69, 0xd, 0xcb, 0x3, 0x98, 0x9e, 0x83, 0xc5, 0x8e, 0x8f, 0xf8, + 0x86, 0x6c, 0x18, 0xf3, 0x16, 0x0, 0x0, 0x3, 0x21, 0x6d, 0xb9, 0x1, 0x0, 0xb, 0x74, + 0x7, 0x9b, 0xf3, 0x86, 0x72, 0x17, 0x29, 0xf4, 0x59, 0x3a, 0x2, 0x0, 0x1, 0x90, 0x1, + 0x0, 0x2, 0x44, 0x79, 0x0, 0x0, 0x17, 0xa9, 0x70, 0xc5, 0xbb, 0x89, 0x1a, 0x41, 0x8a, + 0xe0, 0xf2, 0xa7, 0xae, 0xd, 0x68, 0x8, 0x8f, 0xd2, 0x66, 0xe1, 0xdc, 0x2, 0xc8, 0x9, + 0x1, 0x0, 0x9, 0xd, 0x77, 0xd6, 0x23, 0x32, 0x72, 0xdd, 0x7e, 0xf9, 0x2}; - uint8_t buf[321] = {0}; + uint8_t buf[113] = {0}; - uint8_t topic_bytes[] = {0xd6, 0x64, 0x29, 0xf6, 0x98, 0xa, 0x2d, 0x66}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xbb, 0xa7, 0x97, 0xc0, 0x59, 0x59, 0xf4, 0xfc, 0xd8, 0x57, 0xd8, 0xb4, - 0x53, 0xda, 0x41, 0xbb, 0xff, 0x8c, 0x27, 0xac, 0x64, 0x47, 0xbb}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x6b, 0xd7, 0x36, 0x6f, 0x34, 0xa8, 0x94, 0x15, 0x6c, 0x7c, + 0x12, 0x65, 0x4c, 0x69, 0xd, 0xcb, 0x3, 0x98, 0x9e, 0x83, + 0xc5, 0x8e, 0x8f, 0xf8, 0x86, 0x6c, 0x18, 0xf3, 0x16}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x21, 0x6d, 0xb9}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x74, 0x7, 0x9b, 0xf3, 0x86, 0x72, 0x17, 0x29, 0xf4, 0x59, 0x3a}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x90}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x44, 0x79}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa9, 0x70, 0xc5, 0xbb, 0x89, 0x1a, 0x41, 0x8a, 0xe0, 0xf2, 0xa7, 0xae, + 0xd, 0x68, 0x8, 0x8f, 0xd2, 0x66, 0xe1, 0xdc, 0x2, 0xc8, 0x9}; + lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xd, 0x77, 0xd6, 0x23, 0x32, 0x72, 0xdd, 0x7e, 0xf9}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x26, 0x8, 0xe5, 0x2b, 0xa3, 0x35, 0x84, 0xcb, 0xd5, 0x4a, 0x8, 0x57, 0xe4, 0xa1}; - uint8_t bytesprops1[] = {0x94, 0x88, 0xf4, 0x5, 0x9a, 0xfd, 0x8e, 0x2a, 0xe7, 0x61, 0x63, 0xb3, 0x18, 0x87, 0x2d, - 0x58, 0xd5, 0x14, 0x5e, 0x89, 0x76, 0xf0, 0x6e, 0x4c, 0x60, 0xbb, 0x5c, 0x2e, 0x9f}; - uint8_t bytesprops2[] = {0xa7, 0xa3, 0xa6, 0x1e, 0x1b, 0x8c, 0x68, 0xc5, 0xf3, 0x20, - 0x46, 0xa9, 0x49, 0xe9, 0xc3, 0xe2, 0x24, 0x6, 0xbd, 0x61}; - uint8_t bytesprops3[] = {0x48, 0x9b, 0x94, 0x3, 0x53, 0x7f, 0x39, 0xdb, 0x5f, 0xcb, 0x80, 0x10, 0x41, 0x56, 0xb4, - 0xb8, 0xa0, 0x49, 0x2b, 0x74, 0x98, 0x23, 0xd1, 0xe, 0x84, 0xdc, 0xd6, 0xe1, 0x6b, 0xd5}; - uint8_t bytesprops4[] = {0xd1, 0xd1, 0x66, 0xd0, 0x64, 0x73, 0x25, 0x9b, 0x54, 0xb5, 0xad, - 0x94, 0xdd, 0xb3, 0xcd, 0xbf, 0x47, 0x10, 0xd5, 0x95, 0xeb, 0xed}; - uint8_t bytesprops5[] = {0x65, 0x6e, 0x12, 0x8d, 0x16, 0x21, 0x97, 0xb7, 0xa6, 0x91, 0x2c, 0x37, 0x93}; - uint8_t bytesprops6[] = {0xe1, 0x7d, 0xac, 0xd4, 0x1f, 0x99, 0x96, 0x26, 0xf5, 0x93, 0x4, 0x4c, 0xb2, - 0x5e, 0xfa, 0x73, 0x59, 0x23, 0x77, 0x6f, 0x2b, 0xd7, 0x5f, 0x2f, 0xd9, 0x1}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops7[] = {0x15, 0x6c, 0xf4, 0xa4, 0x1, 0xb3, 0x8a, 0x53, 0x1f, 0xa7, 0x5c, 0xef, - 0x73, 0x56, 0x6b, 0x45, 0x97, 0x38, 0x50, 0xcb, 0x75, 0xd3, 0xf9, 0xef}; + lwmqtt_property_t propslist[] = {}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4746}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22673}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19749}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19964}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 772}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6189}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16029}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5712}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11452}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops7}, .v = {0, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25654}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28483}}, - }; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22660, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 13206 [("\134\245\ft\GS\160Zb\214\NAK\247^\170\162\CAN\201D\147\244$\SUB\DC2\130d\170",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\134",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\190\142\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\NAKe\ETB\156>o\252\206\DC2F\DLE\224\224\183\231O\254`K\185\191\202",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\246\204EG\236x\DC3\172\243\168+\175\196v@#\DEL\188\&4\205M\226p1\165\174",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\ETX;\137\191}\SOdq\196\DC1\234\160\DEL1\173\155Rr8(\241S\132\173\129",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode85) { + uint8_t pkt[] = {0x82, 0x7e, 0x33, 0x96, 0x0, 0x19, 0x86, 0xf5, 0xc, 0x74, 0x1d, 0xa0, 0x5a, 0x62, 0xd6, 0x15, + 0xf7, 0x5e, 0xaa, 0xa2, 0x18, 0xc9, 0x44, 0x93, 0xf4, 0x24, 0x1a, 0x12, 0x82, 0x64, 0xaa, 0x1, + 0x0, 0x1, 0x86, 0x1, 0x0, 0x3, 0xbe, 0x8e, 0xd2, 0x2, 0x0, 0x1, 0x39, 0x1, 0x0, 0x16, + 0x15, 0x65, 0x17, 0x9c, 0x3e, 0x6f, 0xfc, 0xce, 0x12, 0x46, 0x10, 0xe0, 0xe0, 0xb7, 0xe7, 0x4f, + 0xfe, 0x60, 0x4b, 0xb9, 0xbf, 0xca, 0x2, 0x0, 0x1a, 0xf6, 0xcc, 0x45, 0x47, 0xec, 0x78, 0x13, + 0xac, 0xf3, 0xa8, 0x2b, 0xaf, 0xc4, 0x76, 0x40, 0x23, 0x7f, 0xbc, 0x34, 0xcd, 0x4d, 0xe2, 0x70, + 0x31, 0xa5, 0xae, 0x0, 0x0, 0x19, 0x3, 0x3b, 0x89, 0xbf, 0x7d, 0xe, 0x64, 0x71, 0xc4, 0x11, + 0xea, 0xa0, 0x7f, 0x31, 0xad, 0x9b, 0x52, 0x72, 0x38, 0x28, 0xf1, 0x53, 0x84, 0xad, 0x81, 0x1}; + + uint8_t buf[138] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x86, 0xf5, 0xc, 0x74, 0x1d, 0xa0, 0x5a, 0x62, 0xd6, 0x15, 0xf7, 0x5e, 0xaa, + 0xa2, 0x18, 0xc9, 0x44, 0x93, 0xf4, 0x24, 0x1a, 0x12, 0x82, 0x64, 0xaa}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x86}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xbe, 0x8e, 0xd2}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x39}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x15, 0x65, 0x17, 0x9c, 0x3e, 0x6f, 0xfc, 0xce, 0x12, 0x46, 0x10, + 0xe0, 0xe0, 0xb7, 0xe7, 0x4f, 0xfe, 0x60, 0x4b, 0xb9, 0xbf, 0xca}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf6, 0xcc, 0x45, 0x47, 0xec, 0x78, 0x13, 0xac, 0xf3, 0xa8, 0x2b, 0xaf, 0xc4, + 0x76, 0x40, 0x23, 0x7f, 0xbc, 0x34, 0xcd, 0x4d, 0xe2, 0x70, 0x31, 0xa5, 0xae}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3, 0x3b, 0x89, 0xbf, 0x7d, 0xe, 0x64, 0x71, 0xc4, 0x11, 0xea, 0xa0, 0x7f, + 0x31, 0xad, 0x9b, 0x52, 0x72, 0x38, 0x28, 0xf1, 0x53, 0x84, 0xad, 0x81}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 27404, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13206, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\243i\174@\215\136\140u\b,", -// _pubPktID = 0, _pubBody = "_\166K\178hd\ETX^Q", _pubProps = [PropTopicAliasMaximum 15843,PropSubscriptionIdentifier -// 31,PropWillDelayInterval 17605,PropPayloadFormatIndicator 133,PropReceiveMaximum 27638,PropRequestResponseInformation -// 74,PropResponseInformation -// "\238f\225\128\220h\182ACyl\154\206\186M\165\225\187\&1?\USW\201",PropAssignedClientIdentifier -// "\167\186/\DC3\196\a\193\249\226\SUB!\NUL\160\&8\ETX\DC4b\FS>&JL(\216\n\ETBZ\235",PropSubscriptionIdentifierAvailable -// 221,PropWillDelayInterval 32718,PropRequestResponseInformation 240,PropRequestResponseInformation -// 83,PropCorrelationData "\168\&6\\\239D\214\220;\245\FS\DC1\ETB-\DC3tE\184\214\161.e\181F\201",PropMaximumPacketSize -// 3242]} -TEST(Publish5QCTest, Encode5) { - uint8_t pkt[] = {0x38, 0x8b, 0x1, 0x0, 0xa, 0xf3, 0x69, 0xae, 0x40, 0xd7, 0x88, 0x8c, 0x75, 0x8, 0x2c, 0x75, - 0x22, 0x3d, 0xe3, 0xb, 0x1f, 0x18, 0x0, 0x0, 0x44, 0xc5, 0x1, 0x85, 0x21, 0x6b, 0xf6, 0x19, - 0x4a, 0x1a, 0x0, 0x17, 0xee, 0x66, 0xe1, 0x80, 0xdc, 0x68, 0xb6, 0x41, 0x43, 0x79, 0x6c, 0x9a, - 0xce, 0xba, 0x4d, 0xa5, 0xe1, 0xbb, 0x31, 0x3f, 0x1f, 0x57, 0xc9, 0x12, 0x0, 0x1c, 0xa7, 0xba, - 0x2f, 0x13, 0xc4, 0x7, 0xc1, 0xf9, 0xe2, 0x1a, 0x21, 0x0, 0xa0, 0x38, 0x3, 0x14, 0x62, 0x1c, - 0x3e, 0x26, 0x4a, 0x4c, 0x28, 0xd8, 0xa, 0x17, 0x5a, 0xeb, 0x29, 0xdd, 0x18, 0x0, 0x0, 0x7f, - 0xce, 0x19, 0xf0, 0x19, 0x53, 0x9, 0x0, 0x18, 0xa8, 0x36, 0x5c, 0xef, 0x44, 0xd6, 0xdc, 0x3b, - 0xf5, 0x1c, 0x11, 0x17, 0x2d, 0x13, 0x74, 0x45, 0xb8, 0xd6, 0xa1, 0x2e, 0x65, 0xb5, 0x46, 0xc9, - 0x27, 0x0, 0x0, 0xc, 0xaa, 0x5f, 0xa6, 0x4b, 0xb2, 0x68, 0x64, 0x3, 0x5e, 0x51}; - - uint8_t buf[152] = {0}; +// SubscribeRequest 8501 [("\203p\176B\229Ul'\142n\159\GS\221",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode86) { + uint8_t pkt[] = {0x82, 0x12, 0x21, 0x35, 0x0, 0xd, 0xcb, 0x70, 0xb0, 0x42, + 0xe5, 0x55, 0x6c, 0x27, 0x8e, 0x6e, 0x9f, 0x1d, 0xdd, 0x2}; - uint8_t topic_bytes[] = {0xf3, 0x69, 0xae, 0x40, 0xd7, 0x88, 0x8c, 0x75, 0x8, 0x2c}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x5f, 0xa6, 0x4b, 0xb2, 0x68, 0x64, 0x3, 0x5e, 0x51}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + uint8_t buf[30] = {0}; - uint8_t bytesprops0[] = {0xee, 0x66, 0xe1, 0x80, 0xdc, 0x68, 0xb6, 0x41, 0x43, 0x79, 0x6c, 0x9a, - 0xce, 0xba, 0x4d, 0xa5, 0xe1, 0xbb, 0x31, 0x3f, 0x1f, 0x57, 0xc9}; - uint8_t bytesprops1[] = {0xa7, 0xba, 0x2f, 0x13, 0xc4, 0x7, 0xc1, 0xf9, 0xe2, 0x1a, 0x21, 0x0, 0xa0, 0x38, - 0x3, 0x14, 0x62, 0x1c, 0x3e, 0x26, 0x4a, 0x4c, 0x28, 0xd8, 0xa, 0x17, 0x5a, 0xeb}; - uint8_t bytesprops2[] = {0xa8, 0x36, 0x5c, 0xef, 0x44, 0xd6, 0xdc, 0x3b, 0xf5, 0x1c, 0x11, 0x17, - 0x2d, 0x13, 0x74, 0x45, 0xb8, 0xd6, 0xa1, 0x2e, 0x65, 0xb5, 0x46, 0xc9}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xcb, 0x70, 0xb0, 0x42, 0xe5, 0x55, 0x6c, 0x27, 0x8e, 0x6e, 0x9f, 0x1d, 0xdd}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15843}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17605}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27638}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32718}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3242}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8501, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\n-yh\SO\210\US\ESC\254\242a", -// _pubPktID = 15060, _pubBody = "\DEL\SOH0>\190\215\246)N\183\&0R\194\153\164\140'6\243X", _pubProps = -// [PropSharedSubscriptionAvailable 195,PropMessageExpiryInterval 17613,PropWildcardSubscriptionAvailable -// 230,PropServerKeepAlive 23700,PropMessageExpiryInterval 25511,PropResponseTopic -// "\232\240e",PropRequestProblemInformation 220,PropResponseInformation -// "\178\215\172\193\&2^\185\240fz[\254\167\138+L\192\\\183",PropMessageExpiryInterval 5480,PropResponseTopic -// "M\190\249\239\234\134\&1j\188\159\r\ENQ\242\232\167\241\144\136D\155\239QM\245G",PropAuthenticationData " -// \242",PropRequestResponseInformation 206,PropAuthenticationData -// "9/\176\STX\253A\217\189\209\217\207\154\RS\228-\169\128\&39r\208",PropContentType -// "\227\NUL+X\248\129L\241\246\SYN\230\129pui*@:\ESCg\241$\f",PropWillDelayInterval -// 29400,PropRequestResponseInformation 197]} -TEST(Publish5QCTest, Encode6) { - uint8_t pkt[] = {0x3b, 0xb5, 0x1, 0x0, 0xb, 0xa, 0x2d, 0x79, 0x68, 0xe, 0xd2, 0x1f, 0x1b, 0xfe, 0xf2, 0x61, 0x3a, - 0xd4, 0x90, 0x1, 0x2a, 0xc3, 0x2, 0x0, 0x0, 0x44, 0xcd, 0x28, 0xe6, 0x13, 0x5c, 0x94, 0x2, 0x0, - 0x0, 0x63, 0xa7, 0x8, 0x0, 0x3, 0xe8, 0xf0, 0x65, 0x17, 0xdc, 0x1a, 0x0, 0x13, 0xb2, 0xd7, 0xac, - 0xc1, 0x32, 0x5e, 0xb9, 0xf0, 0x66, 0x7a, 0x5b, 0xfe, 0xa7, 0x8a, 0x2b, 0x4c, 0xc0, 0x5c, 0xb7, 0x2, - 0x0, 0x0, 0x15, 0x68, 0x8, 0x0, 0x19, 0x4d, 0xbe, 0xf9, 0xef, 0xea, 0x86, 0x31, 0x6a, 0xbc, 0x9f, - 0xd, 0x5, 0xf2, 0xe8, 0xa7, 0xf1, 0x90, 0x88, 0x44, 0x9b, 0xef, 0x51, 0x4d, 0xf5, 0x47, 0x16, 0x0, - 0x2, 0x20, 0xf2, 0x19, 0xce, 0x16, 0x0, 0x15, 0x39, 0x2f, 0xb0, 0x2, 0xfd, 0x41, 0xd9, 0xbd, 0xd1, - 0xd9, 0xcf, 0x9a, 0x1e, 0xe4, 0x2d, 0xa9, 0x80, 0x33, 0x39, 0x72, 0xd0, 0x3, 0x0, 0x17, 0xe3, 0x0, - 0x2b, 0x58, 0xf8, 0x81, 0x4c, 0xf1, 0xf6, 0x16, 0xe6, 0x81, 0x70, 0x75, 0x69, 0x2a, 0x40, 0x3a, 0x1b, - 0x67, 0xf1, 0x24, 0xc, 0x18, 0x0, 0x0, 0x72, 0xd8, 0x19, 0xc5, 0x7f, 0x1, 0x30, 0x3e, 0xbe, 0xd7, - 0xf6, 0x29, 0x4e, 0xb7, 0x30, 0x52, 0xc2, 0x99, 0xa4, 0x8c, 0x27, 0x36, 0xf3, 0x58}; - - uint8_t buf[194] = {0}; +// SubscribeRequest 25153 [("\132f\153\132\244w'\154\220S",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\249\167\241%",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\142\244",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\151NI\219\241\129\216N\187\248`\189\"G}\165\133)7R\135\154\ETX~\175",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("/;\227\164B+\151W!\206\238\128\136\GS\vz\163\244:G\172V",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("5\145\185{#B\152\236",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("<\131\162\143,2\130\130\159\151\150\CAN2\223\208\ESC\181\218\201\149\&6",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode87) { + uint8_t pkt[] = {0x82, 0x76, 0x62, 0x41, 0x0, 0xa, 0x84, 0x66, 0x99, 0x84, 0xf4, 0x77, 0x27, 0x9a, 0xdc, + 0x53, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0xf9, 0xa7, 0xf1, 0x25, 0x2, 0x0, 0x2, 0x8e, + 0xf4, 0x1, 0x0, 0x19, 0x97, 0x4e, 0x49, 0xdb, 0xf1, 0x81, 0xd8, 0x4e, 0xbb, 0xf8, 0x60, + 0xbd, 0x22, 0x47, 0x7d, 0xa5, 0x85, 0x29, 0x37, 0x52, 0x87, 0x9a, 0x3, 0x7e, 0xaf, 0x0, + 0x0, 0x16, 0x2f, 0x3b, 0xe3, 0xa4, 0x42, 0x2b, 0x97, 0x57, 0x21, 0xce, 0xee, 0x80, 0x88, + 0x1d, 0xb, 0x7a, 0xa3, 0xf4, 0x3a, 0x47, 0xac, 0x56, 0x0, 0x0, 0x8, 0x35, 0x91, 0xb9, + 0x7b, 0x23, 0x42, 0x98, 0xec, 0x0, 0x0, 0x15, 0x3c, 0x83, 0xa2, 0x8f, 0x2c, 0x32, 0x82, + 0x82, 0x9f, 0x97, 0x96, 0x18, 0x32, 0xdf, 0xd0, 0x1b, 0xb5, 0xda, 0xc9, 0x95, 0x36, 0x0}; - uint8_t topic_bytes[] = {0xa, 0x2d, 0x79, 0x68, 0xe, 0xd2, 0x1f, 0x1b, 0xfe, 0xf2, 0x61}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x7f, 0x1, 0x30, 0x3e, 0xbe, 0xd7, 0xf6, 0x29, 0x4e, 0xb7, - 0x30, 0x52, 0xc2, 0x99, 0xa4, 0x8c, 0x27, 0x36, 0xf3, 0x58}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + uint8_t buf[130] = {0}; - uint8_t bytesprops0[] = {0xe8, 0xf0, 0x65}; - uint8_t bytesprops1[] = {0xb2, 0xd7, 0xac, 0xc1, 0x32, 0x5e, 0xb9, 0xf0, 0x66, 0x7a, - 0x5b, 0xfe, 0xa7, 0x8a, 0x2b, 0x4c, 0xc0, 0x5c, 0xb7}; - uint8_t bytesprops2[] = {0x4d, 0xbe, 0xf9, 0xef, 0xea, 0x86, 0x31, 0x6a, 0xbc, 0x9f, 0xd, 0x5, 0xf2, - 0xe8, 0xa7, 0xf1, 0x90, 0x88, 0x44, 0x9b, 0xef, 0x51, 0x4d, 0xf5, 0x47}; - uint8_t bytesprops3[] = {0x20, 0xf2}; - uint8_t bytesprops4[] = {0x39, 0x2f, 0xb0, 0x2, 0xfd, 0x41, 0xd9, 0xbd, 0xd1, 0xd9, 0xcf, - 0x9a, 0x1e, 0xe4, 0x2d, 0xa9, 0x80, 0x33, 0x39, 0x72, 0xd0}; - uint8_t bytesprops5[] = {0xe3, 0x0, 0x2b, 0x58, 0xf8, 0x81, 0x4c, 0xf1, 0xf6, 0x16, 0xe6, 0x81, - 0x70, 0x75, 0x69, 0x2a, 0x40, 0x3a, 0x1b, 0x67, 0xf1, 0x24, 0xc}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x84, 0x66, 0x99, 0x84, 0xf4, 0x77, 0x27, 0x9a, 0xdc, 0x53}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf9, 0xa7, 0xf1, 0x25}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8e, 0xf4}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x97, 0x4e, 0x49, 0xdb, 0xf1, 0x81, 0xd8, 0x4e, 0xbb, 0xf8, 0x60, 0xbd, 0x22, + 0x47, 0x7d, 0xa5, 0x85, 0x29, 0x37, 0x52, 0x87, 0x9a, 0x3, 0x7e, 0xaf}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x2f, 0x3b, 0xe3, 0xa4, 0x42, 0x2b, 0x97, 0x57, 0x21, 0xce, 0xee, + 0x80, 0x88, 0x1d, 0xb, 0x7a, 0xa3, 0xf4, 0x3a, 0x47, 0xac, 0x56}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x35, 0x91, 0xb9, 0x7b, 0x23, 0x42, 0x98, 0xec}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x3c, 0x83, 0xa2, 0x8f, 0x2c, 0x32, 0x82, 0x82, 0x9f, 0x97, 0x96, + 0x18, 0x32, 0xdf, 0xd0, 0x1b, 0xb5, 0xda, 0xc9, 0x95, 0x36}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17613}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23700}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25511}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5480}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29400}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15060, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25153, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "5\132\234\246Z", _pubPktID = 0, -// _pubBody = "+", _pubProps = [PropResponseTopic -// "\n\201\DC2H\138\247\247\201\217\176&\DC4\211\240\198\206E\185",PropWillDelayInterval -// 30260,PropPayloadFormatIndicator 24,PropWillDelayInterval 12867,PropReceiveMaximum 28350,PropReceiveMaximum -// 7251,PropCorrelationData -// "\173\138\ACK\t\146\EOT{\167\SI\DC4\129\b\SOH\232\SO\"\254\184\210\199\SYN\238",PropSubscriptionIdentifierAvailable -// 191,PropRequestProblemInformation 31,PropRetainAvailable 118,PropContentType "\DEL\183",PropRetainAvailable 188]} -TEST(Publish5QCTest, Encode7) { - uint8_t pkt[] = {0x31, 0x56, 0x0, 0x5, 0x35, 0x84, 0xea, 0xf6, 0x5a, 0x4d, 0x8, 0x0, 0x12, 0xa, 0xc9, - 0x12, 0x48, 0x8a, 0xf7, 0xf7, 0xc9, 0xd9, 0xb0, 0x26, 0x14, 0xd3, 0xf0, 0xc6, 0xce, 0x45, - 0xb9, 0x18, 0x0, 0x0, 0x76, 0x34, 0x1, 0x18, 0x18, 0x0, 0x0, 0x32, 0x43, 0x21, 0x6e, - 0xbe, 0x21, 0x1c, 0x53, 0x9, 0x0, 0x16, 0xad, 0x8a, 0x6, 0x9, 0x92, 0x4, 0x7b, 0xa7, - 0xf, 0x14, 0x81, 0x8, 0x1, 0xe8, 0xe, 0x22, 0xfe, 0xb8, 0xd2, 0xc7, 0x16, 0xee, 0x29, - 0xbf, 0x17, 0x1f, 0x25, 0x76, 0x3, 0x0, 0x2, 0x7f, 0xb7, 0x25, 0xbc, 0x2b}; - - uint8_t buf[98] = {0}; +// SubscribeRequest 10517 [("\252",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode88) { + uint8_t pkt[] = {0x82, 0x6, 0x29, 0x15, 0x0, 0x1, 0xfc, 0x1}; - uint8_t topic_bytes[] = {0x35, 0x84, 0xea, 0xf6, 0x5a}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x2b}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + uint8_t buf[18] = {0}; - uint8_t bytesprops0[] = {0xa, 0xc9, 0x12, 0x48, 0x8a, 0xf7, 0xf7, 0xc9, 0xd9, - 0xb0, 0x26, 0x14, 0xd3, 0xf0, 0xc6, 0xce, 0x45, 0xb9}; - uint8_t bytesprops1[] = {0xad, 0x8a, 0x6, 0x9, 0x92, 0x4, 0x7b, 0xa7, 0xf, 0x14, 0x81, - 0x8, 0x1, 0xe8, 0xe, 0x22, 0xfe, 0xb8, 0xd2, 0xc7, 0x16, 0xee}; - uint8_t bytesprops2[] = {0x7f, 0xb7}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xfc}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30260}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12867}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28350}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7251}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10517, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\212\222", _pubPktID = 0, _pubBody -// = "f", _pubProps = [PropSubscriptionIdentifierAvailable 31,PropCorrelationData -// "\250\232\245Rf\128P\RS\t\195\FS\146\&2x\ESC\222H\SOH\136\NUL\198\228\GS\UShfi\164",PropReasonString -// "\144\215V",PropSubscriptionIdentifierAvailable 51,PropMessageExpiryInterval 16252,PropMessageExpiryInterval -// 9192,PropWildcardSubscriptionAvailable 91,PropRequestProblemInformation 221,PropTopicAliasMaximum -// 21616,PropPayloadFormatIndicator 184,PropSubscriptionIdentifierAvailable 34]} -TEST(Publish5QCTest, Encode8) { - uint8_t pkt[] = {0x30, 0x44, 0x0, 0x2, 0xd4, 0xde, 0x3e, 0x29, 0x1f, 0x9, 0x0, 0x1c, 0xfa, 0xe8, - 0xf5, 0x52, 0x66, 0x80, 0x50, 0x1e, 0x9, 0xc3, 0x1c, 0x92, 0x32, 0x78, 0x1b, 0xde, - 0x48, 0x1, 0x88, 0x0, 0xc6, 0xe4, 0x1d, 0x1f, 0x68, 0x66, 0x69, 0xa4, 0x1f, 0x0, - 0x3, 0x90, 0xd7, 0x56, 0x29, 0x33, 0x2, 0x0, 0x0, 0x3f, 0x7c, 0x2, 0x0, 0x0, - 0x23, 0xe8, 0x28, 0x5b, 0x17, 0xdd, 0x22, 0x54, 0x70, 0x1, 0xb8, 0x29, 0x22, 0x66}; - - uint8_t buf[80] = {0}; +// SubscribeRequest 24618 [("\162\&7a\196\249\&0\135*\143\198O\209\148nI",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode89) { + uint8_t pkt[] = {0x82, 0x14, 0x60, 0x2a, 0x0, 0xf, 0xa2, 0x37, 0x61, 0xc4, 0xf9, + 0x30, 0x87, 0x2a, 0x8f, 0xc6, 0x4f, 0xd1, 0x94, 0x6e, 0x49, 0x0}; - uint8_t topic_bytes[] = {0xd4, 0xde}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x66}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + uint8_t buf[32] = {0}; - uint8_t bytesprops0[] = {0xfa, 0xe8, 0xf5, 0x52, 0x66, 0x80, 0x50, 0x1e, 0x9, 0xc3, 0x1c, 0x92, 0x32, 0x78, - 0x1b, 0xde, 0x48, 0x1, 0x88, 0x0, 0xc6, 0xe4, 0x1d, 0x1f, 0x68, 0x66, 0x69, 0xa4}; - uint8_t bytesprops1[] = {0x90, 0xd7, 0x56}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xa2, 0x37, 0x61, 0xc4, 0xf9, 0x30, 0x87, 0x2a, + 0x8f, 0xc6, 0x4f, 0xd1, 0x94, 0x6e, 0x49}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16252}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9192}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21616}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24618, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "u\ESC\171:\189\192\SUB\242!\162\203\208Z\212\177\&5\248\255\138k\213\183+\SUB\132\GS#M\192", _pubPktID = 13057, -// _pubBody = "\168\129\191\243\158\250'%~\DEL0\ESC\210%qk\220\ENQ\241\199", _pubProps = [PropContentType -// "^XfM'v\226[:l\182\185\146N\223\238\187z\143n",PropPayloadFormatIndicator 91,PropMessageExpiryInterval -// 3229,PropAssignedClientIdentifier -// "\212\197\197\&7\RS\167qC\142\237V\175\171\177\246i\198\227\&9I\222",PropContentType -// "\251OiAP\US\202t\135\147>\245\149\228\ETB\233\&8\142 \150\146Mo",PropAssignedClientIdentifier -// "\241\a\180\n\208\207\147\254\207\170 n\142",PropRetainAvailable 241,PropTopicAliasMaximum 12654,PropServerKeepAlive -// 6608,PropTopicAliasMaximum 31149,PropServerReference -// ">5\217\170\139\151\237i\b\186\197z>\173\&5\230?~m",PropRetainAvailable 112,PropSharedSubscriptionAvailable -// 191,PropPayloadFormatIndicator 134,PropSubscriptionIdentifier 20,PropReceiveMaximum 32298,PropRetainAvailable -// 232,PropMessageExpiryInterval 23304,PropAuthenticationData "\187:n\138\182\FS+3",PropReasonString -// "\134\&3\bh\148E\241\SOH\225\135\221o\210\164\245\148",PropRequestResponseInformation 252,PropTopicAliasMaximum -// 413,PropSubscriptionIdentifierAvailable 212,PropRequestResponseInformation 211,PropSubscriptionIdentifier -// 23,PropResponseTopic "\196<\230r\SYN\221\255",PropRequestProblemInformation 99,PropUserProperty "i\SUB\239*\253#\158" -// "L\NUL,u\234\180~Yk\ENQ\202\226_\139a(\178\ETB\194\144o",PropSessionExpiryInterval 32543,PropResponseInformation -// "\205T\201\163\199\187\135o\NUL.QrO\134\172C"]} -TEST(Publish5QCTest, Encode9) { - uint8_t pkt[] = { - 0x3a, 0xb8, 0x2, 0x0, 0x1d, 0x75, 0x1b, 0xab, 0x3a, 0xbd, 0xc0, 0x1a, 0xf2, 0x21, 0xa2, 0xcb, 0xd0, 0x5a, 0xd4, - 0xb1, 0x35, 0xf8, 0xff, 0x8a, 0x6b, 0xd5, 0xb7, 0x2b, 0x1a, 0x84, 0x1d, 0x23, 0x4d, 0xc0, 0x33, 0x1, 0x81, 0x2, - 0x3, 0x0, 0x14, 0x5e, 0x58, 0x66, 0x4d, 0x27, 0x76, 0xe2, 0x5b, 0x3a, 0x6c, 0xb6, 0xb9, 0x92, 0x4e, 0xdf, 0xee, - 0xbb, 0x7a, 0x8f, 0x6e, 0x1, 0x5b, 0x2, 0x0, 0x0, 0xc, 0x9d, 0x12, 0x0, 0x15, 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59, 0x6b, 0x5, 0xca, 0xe2, 0x5f, 0x8b, 0x61, 0x28, - 0xb2, 0x17, 0xc2, 0x90, 0x6f, 0x11, 0x0, 0x0, 0x7f, 0x1f, 0x1a, 0x0, 0x10, 0xcd, 0x54, 0xc9, 0xa3, 0xc7, 0xbb, - 0x87, 0x6f, 0x0, 0x2e, 0x51, 0x72, 0x4f, 0x86, 0xac, 0x43, 0xa8, 0x81, 0xbf, 0xf3, 0x9e, 0xfa, 0x27, 0x25, 0x7e, - 0x7f, 0x30, 0x1b, 0xd2, 0x25, 0x71, 0x6b, 0xdc, 0x5, 0xf1, 0xc7}; - - uint8_t buf[325] = {0}; - - uint8_t topic_bytes[] = {0x75, 0x1b, 0xab, 0x3a, 0xbd, 0xc0, 0x1a, 0xf2, 0x21, 0xa2, 0xcb, 0xd0, 0x5a, 0xd4, 0xb1, - 0x35, 0xf8, 0xff, 0x8a, 0x6b, 0xd5, 0xb7, 0x2b, 0x1a, 0x84, 0x1d, 0x23, 0x4d, 0xc0}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xa8, 0x81, 0xbf, 0xf3, 0x9e, 0xfa, 0x27, 0x25, 0x7e, 0x7f, - 0x30, 0x1b, 0xd2, 0x25, 0x71, 0x6b, 0xdc, 0x5, 0xf1, 0xc7}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; +// SubscribeRequest 32265 [("\188Z\ESCD\172\&2\GSO\235_\175N*$\243\136\224 =\137\169\155\DEL\227\&1",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\203\232q4\EM\v\220\158X\173l\SUB\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode90) { + uint8_t pkt[] = {0x82, 0x2e, 0x7e, 0x9, 0x0, 0x19, 0xbc, 0x5a, 0x1b, 0x44, 0xac, 0x32, 0x1d, 0x4f, 0xeb, 0x5f, + 0xaf, 0x4e, 0x2a, 0x24, 0xf3, 0x88, 0xe0, 0x20, 0x3d, 0x89, 0xa9, 0x9b, 0x7f, 0xe3, 0x31, 0x0, + 0x0, 0xd, 0xcb, 0xe8, 0x71, 0x34, 0x19, 0xb, 0xdc, 0x9e, 0x58, 0xad, 0x6c, 0x1a, 0xae, 0x2}; - uint8_t bytesprops0[] = {0x5e, 0x58, 0x66, 0x4d, 0x27, 0x76, 0xe2, 0x5b, 0x3a, 0x6c, - 0xb6, 0xb9, 0x92, 0x4e, 0xdf, 0xee, 0xbb, 0x7a, 0x8f, 0x6e}; - uint8_t bytesprops1[] = {0xd4, 0xc5, 0xc5, 0x37, 0x1e, 0xa7, 0x71, 0x43, 0x8e, 0xed, 0x56, - 0xaf, 0xab, 0xb1, 0xf6, 0x69, 0xc6, 0xe3, 0x39, 0x49, 0xde}; - uint8_t bytesprops2[] = {0xfb, 0x4f, 0x69, 0x41, 0x50, 0x1f, 0xca, 0x74, 0x87, 0x93, 0x3e, 0xf5, - 0x95, 0xe4, 0x17, 0xe9, 0x38, 0x8e, 0x20, 0x96, 0x92, 0x4d, 0x6f}; - uint8_t bytesprops3[] = {0xf1, 0x7, 0xb4, 0xa, 0xd0, 0xcf, 0x93, 0xfe, 0xcf, 0xaa, 0x20, 0x6e, 0x8e}; - uint8_t bytesprops4[] = {0x3e, 0x35, 0xd9, 0xaa, 0x8b, 0x97, 0xed, 0x69, 0x8, 0xba, - 0xc5, 0x7a, 0x3e, 0xad, 0x35, 0xe6, 0x3f, 0x7e, 0x6d}; - uint8_t bytesprops5[] = {0xbb, 0x3a, 0x6e, 0x8a, 0xb6, 0x1c, 0x2b, 0x33}; - uint8_t bytesprops6[] = {0x86, 0x33, 0x8, 0x68, 0x94, 0x45, 0xf1, 0x1, - 0xe1, 0x87, 0xdd, 0x6f, 0xd2, 0xa4, 0xf5, 0x94}; - uint8_t bytesprops7[] = {0xc4, 0x3c, 0xe6, 0x72, 0x16, 0xdd, 0xff}; - uint8_t bytesprops9[] = {0x4c, 0x0, 0x2c, 0x75, 0xea, 0xb4, 0x7e, 0x59, 0x6b, 0x5, 0xca, - 0xe2, 0x5f, 0x8b, 0x61, 0x28, 0xb2, 0x17, 0xc2, 0x90, 0x6f}; - uint8_t bytesprops8[] = {0x69, 0x1a, 0xef, 0x2a, 0xfd, 0x23, 0x9e}; - uint8_t bytesprops10[] = {0xcd, 0x54, 0xc9, 0xa3, 0xc7, 0xbb, 0x87, 0x6f, - 0x0, 0x2e, 0x51, 0x72, 0x4f, 0x86, 0xac, 0x43}; + uint8_t buf[58] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3229}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12654}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6608}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31149}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32298}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23304}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 413}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops8}, .v = {21, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32543}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops10}}}, - }; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xbc, 0x5a, 0x1b, 0x44, 0xac, 0x32, 0x1d, 0x4f, 0xeb, 0x5f, 0xaf, 0x4e, 0x2a, + 0x24, 0xf3, 0x88, 0xe0, 0x20, 0x3d, 0x89, 0xa9, 0x9b, 0x7f, 0xe3, 0x31}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xcb, 0xe8, 0x71, 0x34, 0x19, 0xb, 0xdc, 0x9e, 0x58, 0xad, 0x6c, 0x1a, 0xae}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2}; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32265, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 7342 [("\RS8\172\211YnUe\216\&6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("~\\\198\&7Ty\GS\206{}\244\164c@{",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("j\227\vg\167<\\S\255\151",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("$S\172",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\174\RS\128=\161\254b\152\&4 \209\226m\237`\SOHcY\162",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\210\179\&8\244\FS\DC2\219W\171\&8!\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("Z\202\&4E\179\143\226E\151\146!\135\216",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\150\&5\226T\150\145THQ\tM\156\165\146Y\245\"\ESC\152YF\252\180\142\222\181\171\175D",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\220\144\&8\247r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("G=\164\r\202\193\181\145:\160V\n7F/\251\199)\224\DLE\197\239\r",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode91) { + uint8_t pkt[] = {0x82, 0xab, 0x1, 0x1c, 0xae, 0x0, 0xa, 0x1e, 0x38, 0xac, 0xd3, 0x59, 0x6e, 0x55, 0x65, 0xd8, + 0x36, 0x2, 0x0, 0xf, 0x7e, 0x5c, 0xc6, 0x37, 0x54, 0x79, 0x1d, 0xce, 0x7b, 0x7d, 0xf4, 0xa4, + 0x63, 0x40, 0x7b, 0x2, 0x0, 0xa, 0x6a, 0xe3, 0xb, 0x67, 0xa7, 0x3c, 0x5c, 0x53, 0xff, 0x97, + 0x0, 0x0, 0x3, 0x24, 0x53, 0xac, 0x0, 0x0, 0x13, 0xae, 0x1e, 0x80, 0x3d, 0xa1, 0xfe, 0x62, + 0x98, 0x34, 0x20, 0xd1, 0xe2, 0x6d, 0xed, 0x60, 0x1, 0x63, 0x59, 0xa2, 0x1, 0x0, 0xc, 0xd2, + 0xb3, 0x38, 0xf4, 0x1c, 0x12, 0xdb, 0x57, 0xab, 0x38, 0x21, 0xba, 0x1, 0x0, 0xd, 0x5a, 0xca, + 0x34, 0x45, 0xb3, 0x8f, 0xe2, 0x45, 0x97, 0x92, 0x21, 0x87, 0xd8, 0x1, 0x0, 0x1d, 0x96, 0x35, + 0xe2, 0x54, 0x96, 0x91, 0x54, 0x48, 0x51, 0x9, 0x4d, 0x9c, 0xa5, 0x92, 0x59, 0xf5, 0x22, 0x1b, + 0x98, 0x59, 0x46, 0xfc, 0xb4, 0x8e, 0xde, 0xb5, 0xab, 0xaf, 0x44, 0x1, 0x0, 0x5, 0xdc, 0x90, + 0x38, 0xf7, 0x72, 0x1, 0x0, 0x17, 0x47, 0x3d, 0xa4, 0xd, 0xca, 0xc1, 0xb5, 0x91, 0x3a, 0xa0, + 0x56, 0xa, 0x37, 0x46, 0x2f, 0xfb, 0xc7, 0x29, 0xe0, 0x10, 0xc5, 0xef, 0xd, 0x2}; + + uint8_t buf[184] = {0}; + + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x1e, 0x38, 0xac, 0xd3, 0x59, 0x6e, 0x55, 0x65, 0xd8, 0x36}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7e, 0x5c, 0xc6, 0x37, 0x54, 0x79, 0x1d, 0xce, + 0x7b, 0x7d, 0xf4, 0xa4, 0x63, 0x40, 0x7b}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x6a, 0xe3, 0xb, 0x67, 0xa7, 0x3c, 0x5c, 0x53, 0xff, 0x97}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x24, 0x53, 0xac}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xae, 0x1e, 0x80, 0x3d, 0xa1, 0xfe, 0x62, 0x98, 0x34, 0x20, + 0xd1, 0xe2, 0x6d, 0xed, 0x60, 0x1, 0x63, 0x59, 0xa2}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xd2, 0xb3, 0x38, 0xf4, 0x1c, 0x12, 0xdb, 0x57, 0xab, 0x38, 0x21, 0xba}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x5a, 0xca, 0x34, 0x45, 0xb3, 0x8f, 0xe2, 0x45, 0x97, 0x92, 0x21, 0x87, 0xd8}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x96, 0x35, 0xe2, 0x54, 0x96, 0x91, 0x54, 0x48, 0x51, 0x9, + 0x4d, 0x9c, 0xa5, 0x92, 0x59, 0xf5, 0x22, 0x1b, 0x98, 0x59, + 0x46, 0xfc, 0xb4, 0x8e, 0xde, 0xb5, 0xab, 0xaf, 0x44}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xdc, 0x90, 0x38, 0xf7, 0x72}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x47, 0x3d, 0xa4, 0xd, 0xca, 0xc1, 0xb5, 0x91, 0x3a, 0xa0, 0x56, 0xa, + 0x37, 0x46, 0x2f, 0xfb, 0xc7, 0x29, 0xe0, 0x10, 0xc5, 0xef, 0xd}; + lwmqtt_string_t topic_filter_s9 = {23, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7342, 10, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 25785 [("4\DC1\131\219{\253\160\n\151f\226{\218\179",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("F\173\174\178\252\144\161\193\&0H\130c\170,\160\167-)\162",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\230\216\219R\ACK\203\\\EM\206|\151\250\&7",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("7!\245\132~\DC2(\164\v\167p\249O]\EOTx*&\173pP\249\209",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\213\FS\146i\223\DC4\233\DC1\SI\208*_B\198EP\ACK[\226\182)\255",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\247P\157\US\255e\250\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode92) { + uint8_t pkt[] = {0x82, 0x77, 0x64, 0xb9, 0x0, 0xe, 0x34, 0x11, 0x83, 0xdb, 0x7b, 0xfd, 0xa0, 0xa, 0x97, 0x66, + 0xe2, 0x7b, 0xda, 0xb3, 0x0, 0x0, 0x13, 0x46, 0xad, 0xae, 0xb2, 0xfc, 0x90, 0xa1, 0xc1, 0x30, + 0x48, 0x82, 0x63, 0xaa, 0x2c, 0xa0, 0xa7, 0x2d, 0x29, 0xa2, 0x0, 0x0, 0xd, 0xe6, 0xd8, 0xdb, + 0x52, 0x6, 0xcb, 0x5c, 0x19, 0xce, 0x7c, 0x97, 0xfa, 0x37, 0x1, 0x0, 0x17, 0x37, 0x21, 0xf5, + 0x84, 0x7e, 0x12, 0x28, 0xa4, 0xb, 0xa7, 0x70, 0xf9, 0x4f, 0x5d, 0x4, 0x78, 0x2a, 0x26, 0xad, + 0x70, 0x50, 0xf9, 0xd1, 0x1, 0x0, 0x16, 0xd5, 0x1c, 0x92, 0x69, 0xdf, 0x14, 0xe9, 0x11, 0xf, + 0xd0, 0x2a, 0x5f, 0x42, 0xc6, 0x45, 0x50, 0x6, 0x5b, 0xe2, 0xb6, 0x29, 0xff, 0x2, 0x0, 0x8, + 0xf7, 0x50, 0x9d, 0x1f, 0xff, 0x65, 0xfa, 0xb4, 0x0}; + + uint8_t buf[131] = {0}; + + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x34, 0x11, 0x83, 0xdb, 0x7b, 0xfd, 0xa0, 0xa, 0x97, 0x66, 0xe2, 0x7b, 0xda, 0xb3}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x46, 0xad, 0xae, 0xb2, 0xfc, 0x90, 0xa1, 0xc1, 0x30, 0x48, + 0x82, 0x63, 0xaa, 0x2c, 0xa0, 0xa7, 0x2d, 0x29, 0xa2}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe6, 0xd8, 0xdb, 0x52, 0x6, 0xcb, 0x5c, 0x19, 0xce, 0x7c, 0x97, 0xfa, 0x37}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x37, 0x21, 0xf5, 0x84, 0x7e, 0x12, 0x28, 0xa4, 0xb, 0xa7, 0x70, 0xf9, + 0x4f, 0x5d, 0x4, 0x78, 0x2a, 0x26, 0xad, 0x70, 0x50, 0xf9, 0xd1}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd5, 0x1c, 0x92, 0x69, 0xdf, 0x14, 0xe9, 0x11, 0xf, 0xd0, 0x2a, + 0x5f, 0x42, 0xc6, 0x45, 0x50, 0x6, 0x5b, 0xe2, 0xb6, 0x29, 0xff}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf7, 0x50, 0x9d, 0x1f, 0xff, 0x65, 0xfa, 0xb4}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 13057, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25785, 6, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\186l\242\SOH;D}W:\172\197", -// _pubPktID = 15309, _pubBody = "-\137a\203_YG\210\138\172yL\224>", _pubProps = [PropResponseInformation -// "7M\191\DC1\154",PropPayloadFormatIndicator 204,PropMaximumQoS 99,PropResponseInformation -// "\173\DLE-z\GS\DC2\130n\179",PropWillDelayInterval 22264,PropMaximumPacketSize 9076,PropAuthenticationMethod -// "`\235xe$J\213a\207\213\va\233\182\248\201m\151rn`z{;T",PropMessageExpiryInterval 12687,PropTopicAliasMaximum 22086]} -TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = {0x3d, 0x65, 0x0, 0xc, 0xfd, 0xba, 0x6c, 0xf2, 0x1, 0x3b, 0x44, 0x7d, 0x57, 0x3a, 0xac, - 0xc5, 0x3b, 0xcd, 0x46, 0x1a, 0x0, 0x5, 0x37, 0x4d, 0xbf, 0x11, 0x9a, 0x1, 0xcc, 0x24, - 0x63, 0x1a, 0x0, 0x9, 0xad, 0x10, 0x2d, 0x7a, 0x1d, 0x12, 0x82, 0x6e, 0xb3, 0x18, 0x0, - 0x0, 0x56, 0xf8, 0x27, 0x0, 0x0, 0x23, 0x74, 0x15, 0x0, 0x19, 0x60, 0xeb, 0x78, 0x65, - 0x24, 0x4a, 0xd5, 0x61, 0xcf, 0xd5, 0xb, 0x61, 0xe9, 0xb6, 0xf8, 0xc9, 0x6d, 0x97, 0x72, - 0x6e, 0x60, 0x7a, 0x7b, 0x3b, 0x54, 0x2, 0x0, 0x0, 0x31, 0x8f, 0x22, 0x56, 0x46, 0x2d, - 0x89, 0x61, 0xcb, 0x5f, 0x59, 0x47, 0xd2, 0x8a, 0xac, 0x79, 0x4c, 0xe0, 0x3e}; - - uint8_t buf[113] = {0}; +// SubscribeRequest 8081 [("\247\197\143\CANr(\SO\230",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0}),("\183\151u\251Or\149\230`\218\133\NUL\ETX\f",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("%\232\ACKq\200;\197\192\155\162\245|\t(\206\172\a\DELe\148\253\227\200\253\187s\219\179y",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("rp\156\133\138@\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\STX\f\202\217I\195/\218#\168^" -// "\SOH\150\146\145",PropSubscriptionIdentifier 1,PropReceiveMaximum 29802,PropRequestProblemInformation -// 219,PropTopicAlias 19865,PropMessageExpiryInterval 11509,PropSessionExpiryInterval 27755]} -TEST(Publish5QCTest, Encode12) { - uint8_t pkt[] = { - 0x31, 0xdc, 0x1, 0x0, 0xa, 0xa9, 0x7c, 0x92, 0x45, 0x32, 0x1d, 0x7b, 0xed, 0x33, 0xa6, 0xc0, 0x1, 0x1a, 0x0, - 0x17, 0x1b, 0x6f, 0x8, 0xed, 0x4, 0x9, 0xeb, 0x7c, 0xc5, 0x6d, 0x7e, 0x2a, 0xb0, 0xc, 0xf5, 0xfd, 0xab, 0x60, - 0x36, 0x46, 0x85, 0xa1, 0x5a, 0x24, 0xee, 0x1, 0xb1, 0x1, 0x5a, 0x1, 0x48, 0x8, 0x0, 0x0, 0x1c, 0x0, 0x12, - 0x8a, 0x4b, 0xf5, 0x95, 0x92, 0x18, 0xa7, 0x1b, 0xc4, 0x38, 0x1b, 0x36, 0x47, 0xf6, 0xcd, 0xdd, 0xb6, 0xc7, 0x1, - 0xb6, 0x1c, 0x0, 0x5, 0xef, 0x30, 0x32, 0xe, 0x80, 0x1f, 0x0, 0x0, 0x11, 0x0, 0x0, 0x6b, 0xc8, 0x1c, 0x0, - 0x18, 0x50, 0x76, 0x56, 0xb7, 0xb8, 0x63, 0xa6, 0xe3, 0x1a, 0xee, 0x6d, 0x9a, 0x11, 0x60, 0xc0, 0xe3, 0x2d, 0xf4, - 0x56, 0x52, 0x68, 0xe2, 0x92, 0x5c, 0x15, 0x0, 0x1d, 0x57, 0x12, 0x60, 0xa4, 0x2f, 0x96, 0x10, 0xba, 0xdb, 0x5b, - 0x82, 0xb0, 0x38, 0x1a, 0x94, 0x18, 0x5d, 0x4a, 0x97, 0x45, 0x18, 0x37, 0x62, 0xdc, 0x18, 0x89, 0x30, 0x7e, 0x4f, - 0x24, 0x9e, 0xb, 0x11, 0xb, 0x9, 0x26, 0x0, 0x16, 0xc6, 0xc3, 0xf3, 0xe8, 0xc8, 0xc0, 0xa, 0x7a, 0x9d, 0x16, - 0xc7, 0x8c, 0xc9, 0xf2, 0xf2, 0x7d, 0xe2, 0x5, 0xd0, 0xa8, 0x33, 0x3e, 0x0, 0x4, 0x1, 0x96, 0x92, 0x91, 0xb, - 0x1, 0x21, 0x74, 0x6a, 0x17, 0xdb, 0x23, 0x4d, 0x99, 0x2, 0x0, 0x0, 0x2c, 0xf5, 0x11, 0x0, 0x0, 0x6c, 0x6b, - 0x23, 0xe3, 0xd9, 0x5d, 0x1f, 0xee, 0x53, 0xa3, 0x8b, 0xe8, 0xa5, 0xd2, 0xf3, 0x2d}; - - uint8_t buf[233] = {0}; - - uint8_t topic_bytes[] = {0xa9, 0x7c, 0x92, 0x45, 0x32, 0x1d, 0x7b, 0xed, 0x33, 0xa6}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x23, 0xe3, 0xd9, 0x5d, 0x1f, 0xee, 0x53, 0xa3, 0x8b, 0xe8, 0xa5, 0xd2, 0xf3, 0x2d}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; +// SubscribeRequest 25983 [("\NULh]\172\248\158\GS:.\SOH<\\0\204q",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\CAN?\208\234\166~,\246\198\198\RS\128\a\167#\ESC\USb\161\FS",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\160\US\153\210\&2\243#\154\167",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\129\CAN\203\191Y5\132\246\162\129\192XU\"\172S",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode96) { + uint8_t pkt[] = {0x82, 0x4a, 0x65, 0x7f, 0x0, 0xf, 0x0, 0x68, 0x5d, 0xac, 0xf8, 0x9e, 0x1d, 0x3a, 0x2e, 0x1, + 0x3c, 0x5c, 0x30, 0xcc, 0x71, 0x2, 0x0, 0x14, 0x18, 0x3f, 0xd0, 0xea, 0xa6, 0x7e, 0x2c, 0xf6, + 0xc6, 0xc6, 0x1e, 0x80, 0x7, 0xa7, 0x23, 0x1b, 0x1f, 0x62, 0xa1, 0x1c, 0x1, 0x0, 0x9, 0xa0, + 0x1f, 0x99, 0xd2, 0x32, 0xf3, 0x23, 0x9a, 0xa7, 0x0, 0x0, 0x10, 0x81, 0x18, 0xcb, 0xbf, 0x59, + 0x35, 0x84, 0xf6, 0xa2, 0x81, 0xc0, 0x58, 0x55, 0x22, 0xac, 0x53, 0x1}; - uint8_t bytesprops0[] = {0x1b, 0x6f, 0x8, 0xed, 0x4, 0x9, 0xeb, 0x7c, 0xc5, 0x6d, 0x7e, 0x2a, - 0xb0, 0xc, 0xf5, 0xfd, 0xab, 0x60, 0x36, 0x46, 0x85, 0xa1, 0x5a}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x8a, 0x4b, 0xf5, 0x95, 0x92, 0x18, 0xa7, 0x1b, 0xc4, - 0x38, 0x1b, 0x36, 0x47, 0xf6, 0xcd, 0xdd, 0xb6, 0xc7}; - uint8_t bytesprops3[] = {0xef, 0x30, 0x32, 0xe, 0x80}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0x50, 0x76, 0x56, 0xb7, 0xb8, 0x63, 0xa6, 0xe3, 0x1a, 0xee, 0x6d, 0x9a, - 0x11, 0x60, 0xc0, 0xe3, 0x2d, 0xf4, 0x56, 0x52, 0x68, 0xe2, 0x92, 0x5c}; - uint8_t bytesprops6[] = {0x57, 0x12, 0x60, 0xa4, 0x2f, 0x96, 0x10, 0xba, 0xdb, 0x5b, 0x82, 0xb0, 0x38, 0x1a, 0x94, - 0x18, 0x5d, 0x4a, 0x97, 0x45, 0x18, 0x37, 0x62, 0xdc, 0x18, 0x89, 0x30, 0x7e, 0x4f}; - uint8_t bytesprops8[] = {0x1, 0x96, 0x92, 0x91}; - uint8_t bytesprops7[] = {0xc6, 0xc3, 0xf3, 0xe8, 0xc8, 0xc0, 0xa, 0x7a, 0x9d, 0x16, 0xc7, - 0x8c, 0xc9, 0xf2, 0xf2, 0x7d, 0xe2, 0x5, 0xd0, 0xa8, 0x33, 0x3e}; + uint8_t buf[86] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27592}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops7}, .v = {4, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29802}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19865}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11509}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27755}}, - }; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x0, 0x68, 0x5d, 0xac, 0xf8, 0x9e, 0x1d, 0x3a, + 0x2e, 0x1, 0x3c, 0x5c, 0x30, 0xcc, 0x71}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x18, 0x3f, 0xd0, 0xea, 0xa6, 0x7e, 0x2c, 0xf6, 0xc6, 0xc6, + 0x1e, 0x80, 0x7, 0xa7, 0x23, 0x1b, 0x1f, 0x62, 0xa1, 0x1c}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa0, 0x1f, 0x99, 0xd2, 0x32, 0xf3, 0x23, 0x9a, 0xa7}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x81, 0x18, 0xcb, 0xbf, 0x59, 0x35, 0x84, 0xf6, + 0xa2, 0x81, 0xc0, 0x58, 0x55, 0x22, 0xac, 0x53}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25983, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\187\253\202u\190\\@\215", _pubPktID -// = 27515, _pubBody = "\146q\173U}?\142kjA\ETX\187\155\EOT#K\207\&8x\224\244\133\241\t\146I\241", _pubProps = -// [PropPayloadFormatIndicator 160,PropResponseTopic "\226\202 -// \245S\205Z\129\227_\136\241\"B}\235\&3\NUL\SOHO\213",PropPayloadFormatIndicator 23,PropWillDelayInterval -// 9922,PropTopicAlias 26620,PropResponseInformation -// "\SUB]\213t\222\SUB\162\230\206\"\ESC\236\199{Nq\251",PropRequestProblemInformation 175,PropMaximumQoS -// 94,PropContentType "\NUL\215Y\228q.\ESC\ETB",PropMessageExpiryInterval 26757,PropReceiveMaximum 30209,PropContentType -// "-\f1\223",PropResponseInformation -// "\174\208\149\t\161\194jG\FSz\238\227\242\145\243\194\239B=\229",PropMessageExpiryInterval -// 4476,PropRequestProblemInformation 106,PropCorrelationData -// "h=\216\237\192\192>\223~\140\153\197\193\191\"\170\SOHF\240\131+d\205\252",PropAuthenticationMethod -// "Z(9\177\156\221\ETBe\156\&8\205`\132\132l\f",PropServerReference -// "\130UyI\211\GSr\202\216k^\255\220\NULq\US",PropAuthenticationMethod "\248\"\195K\CAN4r",PropAuthenticationData -// "\135\151\255\231v\246",PropServerReference -// "J\169s\207D\146qo\GS\n\156\151\134\186&\134\SYN\\\243\141\136",PropMessageExpiryInterval 11426]} -TEST(Publish5QCTest, Encode13) { - uint8_t pkt[] = { - 0x3c, 0x8e, 0x2, 0x0, 0x8, 0xbb, 0xfd, 0xca, 0x75, 0xbe, 0x5c, 0x40, 0xd7, 0x6b, 0x7b, 0xe5, 0x1, 0x1, 0xa0, - 0x8, 0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 0x72, 0x16, - 0x0, 0x6, 0x87, 0x97, 0xff, 0xe7, 0x76, 0xf6, 0x1c, 0x0, 0x15, 0x4a, 0xa9, 0x73, 0xcf, 0x44, 0x92, 0x71, 0x6f, - 0x1d, 0xa, 0x9c, 0x97, 0x86, 0xba, 0x26, 0x86, 0x16, 0x5c, 0xf3, 0x8d, 0x88, 0x2, 0x0, 0x0, 0x2c, 0xa2, 0x92, - 0x71, 0xad, 0x55, 0x7d, 0x3f, 0x8e, 0x6b, 0x6a, 0x41, 0x3, 0xbb, 0x9b, 0x4, 0x23, 0x4b, 0xcf, 0x38, 0x78, 0xe0, - 0xf4, 0x85, 0xf1, 0x9, 0x92, 0x49, 0xf1}; +// SubscribeRequest 14533 [("\207u\229\191Dm6]U\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\159\195\128\SOHK\243\248gf\DEL",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("[{\199\214\EMb\b\140H/\140\146\DC3\SYN\141\SOh\251\148\a\145\SOH*\160\190\145\130D\SO/",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\v6\STX\"\b% +// \211\241\184\238\234b\247\174\178w",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\158\143\t\131\211\229\129,\234\193GG\206r\191\150\176\DC2",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("6\195\241\184/\168\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS0}),("\140\DC3M\195\237\DLEO\231",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode97) { + uint8_t pkt[] = {0x82, 0x7b, 0x38, 0xc5, 0x0, 0xa, 0xcf, 0x75, 0xe5, 0xbf, 0x44, 0x6d, 0x36, 0x5d, 0x55, 0x98, + 0x2, 0x0, 0xa, 0x9f, 0xc3, 0x80, 0x1, 0x4b, 0xf3, 0xf8, 0x67, 0x66, 0x7f, 0x0, 0x0, 0x1e, + 0x5b, 0x7b, 0xc7, 0xd6, 0x19, 0x62, 0x8, 0x8c, 0x48, 0x2f, 0x8c, 0x92, 0x13, 0x16, 0x8d, 0xe, + 0x68, 0xfb, 0x94, 0x7, 0x91, 0x1, 0x2a, 0xa0, 0xbe, 0x91, 0x82, 0x44, 0xe, 0x2f, 0x2, 0x0, + 0x11, 0xb, 0x36, 0x2, 0x22, 0x8, 0x25, 0x20, 0xd3, 0xf1, 0xb8, 0xee, 0xea, 0x62, 0xf7, 0xae, + 0xb2, 0x77, 0x2, 0x0, 0x12, 0x9e, 0x8f, 0x9, 0x83, 0xd3, 0xe5, 0x81, 0x2c, 0xea, 0xc1, 0x47, + 0x47, 0xce, 0x72, 0xbf, 0x96, 0xb0, 0x12, 0x0, 0x0, 0x7, 0x36, 0xc3, 0xf1, 0xb8, 0x2f, 0xa8, + 0xce, 0x0, 0x0, 0x8, 0x8c, 0x13, 0x4d, 0xc3, 0xed, 0x10, 0x4f, 0xe7, 0x1}; - uint8_t buf[283] = {0}; + uint8_t buf[135] = {0}; - uint8_t topic_bytes[] = {0xbb, 0xfd, 0xca, 0x75, 0xbe, 0x5c, 0x40, 0xd7}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x92, 0x71, 0xad, 0x55, 0x7d, 0x3f, 0x8e, 0x6b, 0x6a, 0x41, 0x3, 0xbb, 0x9b, 0x4, - 0x23, 0x4b, 0xcf, 0x38, 0x78, 0xe0, 0xf4, 0x85, 0xf1, 0x9, 0x92, 0x49, 0xf1}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; - - uint8_t bytesprops0[] = {0xe2, 0xca, 0x20, 0xf5, 0x53, 0xcd, 0x5a, 0x81, 0xe3, 0x5f, 0x88, - 0xf1, 0x22, 0x42, 0x7d, 0xeb, 0x33, 0x0, 0x1, 0x4f, 0xd5}; - uint8_t bytesprops1[] = {0x1a, 0x5d, 0xd5, 0x74, 0xde, 0x1a, 0xa2, 0xe6, 0xce, - 0x22, 0x1b, 0xec, 0xc7, 0x7b, 0x4e, 0x71, 0xfb}; - uint8_t bytesprops2[] = {0x0, 0xd7, 0x59, 0xe4, 0x71, 0x2e, 0x1b, 0x17}; - uint8_t bytesprops3[] = {0x2d, 0xc, 0x31, 0xdf}; - uint8_t bytesprops4[] = {0xae, 0xd0, 0x95, 0x9, 0xa1, 0xc2, 0x6a, 0x47, 0x1c, 0x7a, - 0xee, 0xe3, 0xf2, 0x91, 0xf3, 0xc2, 0xef, 0x42, 0x3d, 0xe5}; - uint8_t bytesprops5[] = {0x68, 0x3d, 0xd8, 0xed, 0xc0, 0xc0, 0x3e, 0xdf, 0x7e, 0x8c, 0x99, 0xc5, - 0xc1, 0xbf, 0x22, 0xaa, 0x1, 0x46, 0xf0, 0x83, 0x2b, 0x64, 0xcd, 0xfc}; - uint8_t bytesprops6[] = {0x5a, 0x28, 0x39, 0xb1, 0x9c, 0xdd, 0x17, 0x65, - 0x9c, 0x38, 0xcd, 0x60, 0x84, 0x84, 0x6c, 0xc}; - uint8_t bytesprops7[] = {0x82, 0x55, 0x79, 0x49, 0xd3, 0x1d, 0x72, 0xca, - 0xd8, 0x6b, 0x5e, 0xff, 0xdc, 0x0, 0x71, 0x1f}; - uint8_t bytesprops8[] = {0xf8, 0x22, 0xc3, 0x4b, 0x18, 0x34, 0x72}; - uint8_t bytesprops9[] = {0x87, 0x97, 0xff, 0xe7, 0x76, 0xf6}; - uint8_t bytesprops10[] = {0x4a, 0xa9, 0x73, 0xcf, 0x44, 0x92, 0x71, 0x6f, 0x1d, 0xa, 0x9c, - 0x97, 0x86, 0xba, 0x26, 0x86, 0x16, 0x5c, 0xf3, 0x8d, 0x88}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xcf, 0x75, 0xe5, 0xbf, 0x44, 0x6d, 0x36, 0x5d, 0x55, 0x98}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x9f, 0xc3, 0x80, 0x1, 0x4b, 0xf3, 0xf8, 0x67, 0x66, 0x7f}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5b, 0x7b, 0xc7, 0xd6, 0x19, 0x62, 0x8, 0x8c, 0x48, 0x2f, + 0x8c, 0x92, 0x13, 0x16, 0x8d, 0xe, 0x68, 0xfb, 0x94, 0x7, + 0x91, 0x1, 0x2a, 0xa0, 0xbe, 0x91, 0x82, 0x44, 0xe, 0x2f}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb, 0x36, 0x2, 0x22, 0x8, 0x25, 0x20, 0xd3, 0xf1, + 0xb8, 0xee, 0xea, 0x62, 0xf7, 0xae, 0xb2, 0x77}; + lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9e, 0x8f, 0x9, 0x83, 0xd3, 0xe5, 0x81, 0x2c, 0xea, + 0xc1, 0x47, 0x47, 0xce, 0x72, 0xbf, 0x96, 0xb0, 0x12}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x36, 0xc3, 0xf1, 0xb8, 0x2f, 0xa8, 0xce}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8c, 0x13, 0x4d, 0xc3, 0xed, 0x10, 0x4f, 0xe7}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9922}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26620}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26757}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30209}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4476}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11426}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 27515, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14533, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\163\147\204\140\129\152\150A\187\249", _pubPktID = 15054, _pubBody = "C\207+gu\184\240\&5~z\148f", _pubProps = -// [PropWillDelayInterval 13896,PropTopicAliasMaximum 22435,PropAssignedClientIdentifier -// "\145\215\253Ef0y\b\184,1\173r\243\241\194\b\213\184P%",PropSharedSubscriptionAvailable 98,PropSessionExpiryInterval -// 13964,PropTopicAlias 11550,PropMaximumPacketSize 31812,PropSubscriptionIdentifierAvailable 140,PropWillDelayInterval -// 22185,PropTopicAliasMaximum 25699,PropSessionExpiryInterval 4043,PropTopicAliasMaximum 14577,PropUserProperty -// "-:\192\STX\171\252$\215\198)\204" -// "vMG\132s\143\225-\244\136\ETX'\199^O\215\211\181\235u\221=\157~\189\145d",PropSubscriptionIdentifierAvailable -// 172,PropReceiveMaximum 21448,PropWildcardSubscriptionAvailable 18,PropPayloadFormatIndicator -// 210,PropWillDelayInterval 31421,PropAssignedClientIdentifier "j\149\157",PropContentType -// "\211I\142\244\176\ETX\199\223\SUB\245\188l\207o\"\141\174V\237\146x\201",PropResponseInformation -// "\SIo\203\"\176\187\DC1\179I\""]} -TEST(Publish5QCTest, Encode14) { - uint8_t pkt[] = {0x3d, 0xc2, 0x1, 0x0, 0xa, 0xa3, 0x93, 0xcc, 0x8c, 0x81, 0x98, 0x96, 0x41, 0xbb, 0xf9, 0x3a, 0xce, - 0xa6, 0x1, 0x18, 0x0, 0x0, 0x36, 0x48, 0x22, 0x57, 0xa3, 0x12, 0x0, 0x15, 0x91, 0xd7, 0xfd, 0x45, - 0x66, 0x30, 0x79, 0x8, 0xb8, 0x2c, 0x31, 0xad, 0x72, 0xf3, 0xf1, 0xc2, 0x8, 0xd5, 0xb8, 0x50, 0x25, - 0x2a, 0x62, 0x11, 0x0, 0x0, 0x36, 0x8c, 0x23, 0x2d, 0x1e, 0x27, 0x0, 0x0, 0x7c, 0x44, 0x29, 0x8c, - 0x18, 0x0, 0x0, 0x56, 0xa9, 0x22, 0x64, 0x63, 0x11, 0x0, 0x0, 0xf, 0xcb, 0x22, 0x38, 0xf1, 0x26, - 0x0, 0xb, 0x2d, 0x3a, 0xc0, 0x2, 0xab, 0xfc, 0x24, 0xd7, 0xc6, 0x29, 0xcc, 0x0, 0x1b, 0x76, 0x4d, - 0x47, 0x84, 0x73, 0x8f, 0xe1, 0x2d, 0xf4, 0x88, 0x3, 0x27, 0xc7, 0x5e, 0x4f, 0xd7, 0xd3, 0xb5, 0xeb, - 0x75, 0xdd, 0x3d, 0x9d, 0x7e, 0xbd, 0x91, 0x64, 0x29, 0xac, 0x21, 0x53, 0xc8, 0x28, 0x12, 0x1, 0xd2, - 0x18, 0x0, 0x0, 0x7a, 0xbd, 0x12, 0x0, 0x3, 0x6a, 0x95, 0x9d, 0x3, 0x0, 0x16, 0xd3, 0x49, 0x8e, - 0xf4, 0xb0, 0x3, 0xc7, 0xdf, 0x1a, 0xf5, 0xbc, 0x6c, 0xcf, 0x6f, 0x22, 0x8d, 0xae, 0x56, 0xed, 0x92, - 0x78, 0xc9, 0x1a, 0x0, 0xa, 0xf, 0x6f, 0xcb, 0x22, 0xb0, 0xbb, 0x11, 0xb3, 0x49, 0x22, 0x43, 0xcf, - 0x2b, 0x67, 0x75, 0xb8, 0xf0, 0x35, 0x7e, 0x7a, 0x94, 0x66}; - - uint8_t buf[207] = {0}; - - uint8_t topic_bytes[] = {0xa3, 0x93, 0xcc, 0x8c, 0x81, 0x98, 0x96, 0x41, 0xbb, 0xf9}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x43, 0xcf, 0x2b, 0x67, 0x75, 0xb8, 0xf0, 0x35, 0x7e, 0x7a, 0x94, 0x66}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; - - uint8_t bytesprops0[] = {0x91, 0xd7, 0xfd, 0x45, 0x66, 0x30, 0x79, 0x8, 0xb8, 0x2c, 0x31, - 0xad, 0x72, 0xf3, 0xf1, 0xc2, 0x8, 0xd5, 0xb8, 0x50, 0x25}; - uint8_t bytesprops2[] = {0x76, 0x4d, 0x47, 0x84, 0x73, 0x8f, 0xe1, 0x2d, 0xf4, 0x88, 0x3, 0x27, 0xc7, 0x5e, - 0x4f, 0xd7, 0xd3, 0xb5, 0xeb, 0x75, 0xdd, 0x3d, 0x9d, 0x7e, 0xbd, 0x91, 0x64}; - uint8_t bytesprops1[] = {0x2d, 0x3a, 0xc0, 0x2, 0xab, 0xfc, 0x24, 0xd7, 0xc6, 0x29, 0xcc}; - uint8_t bytesprops3[] = {0x6a, 0x95, 0x9d}; - uint8_t bytesprops4[] = {0xd3, 0x49, 0x8e, 0xf4, 0xb0, 0x3, 0xc7, 0xdf, 0x1a, 0xf5, 0xbc, - 0x6c, 0xcf, 0x6f, 0x22, 0x8d, 0xae, 0x56, 0xed, 0x92, 0x78, 0xc9}; - uint8_t bytesprops5[] = {0xf, 0x6f, 0xcb, 0x22, 0xb0, 0xbb, 0x11, 0xb3, 0x49, 0x22}; +// SubscribeRequest 1538 +// [("\136v9\252\152\153\179\197P\132F\ETX\176\STX\166RR\222\t\216\163\143\252n\ETB\212",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode98) { + uint8_t pkt[] = {0x82, 0x1f, 0x6, 0x2, 0x0, 0x1a, 0x88, 0x76, 0x39, 0xfc, 0x98, 0x99, 0xb3, 0xc5, 0x50, 0x84, 0x46, + 0x3, 0xb0, 0x2, 0xa6, 0x52, 0x52, 0xde, 0x9, 0xd8, 0xa3, 0x8f, 0xfc, 0x6e, 0x17, 0xd4, 0x1}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13896}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22435}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13964}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11550}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31812}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22185}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25699}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4043}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14577}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {27, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21448}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31421}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops5}}}, - }; + uint8_t buf[43] = {0}; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x88, 0x76, 0x39, 0xfc, 0x98, 0x99, 0xb3, 0xc5, 0x50, 0x84, 0x46, 0x3, 0xb0, + 0x2, 0xa6, 0x52, 0x52, 0xde, 0x9, 0xd8, 0xa3, 0x8f, 0xfc, 0x6e, 0x17, 0xd4}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15054, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1538, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 22336 [("\239\178\194.\198\235(\167c\190\ETX\155\184\185\245\170}\US\231$\149\255\212",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("3\STXm\179%\DLE\247O\NULI\CAN\t\180\147\136\133\176\195[r\158\131\b\SOE\SYN\139\163\154",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\225\235\137\207",PropAuthenticationMethod "",PropUserProperty "X\211\SIY" -// "Q\203\192\221\167\162U\204\226]X\DC1)4\170+\158\187\&4",PropAuthenticationMethod "8|N\RSd\SYN",PropRetainAvailable -// 86,PropPayloadFormatIndicator 113,PropMessageExpiryInterval 29994,PropTopicAlias 6445,PropSessionExpiryInterval -// 20260,PropMessageExpiryInterval 14963,PropRetainAvailable 23,PropMessageExpiryInterval -// 13983,PropRequestResponseInformation 103,PropMaximumPacketSize 8958,PropTopicAliasMaximum -// 13547,PropMessageExpiryInterval 23419,PropServerReference "\135\195\156Z",PropPayloadFormatIndicator -// 143,PropRequestResponseInformation 0,PropReasonString "\228\233"]} -TEST(Publish5QCTest, Encode15) { - uint8_t pkt[] = { - 0x38, 0xf0, 0x1, 0x0, 0x17, 0x2c, 0xd2, 0x6d, 0xf9, 0xad, 0x8f, 0x75, 0xd0, 0x6b, 0xb5, 0x4b, 0x6f, 0x75, 0x5d, - 0x35, 0xd3, 0x8d, 0xcc, 0x4d, 0x85, 0x2b, 0x24, 0x99, 0xd1, 0x1, 0x11, 0x0, 0x0, 0x1a, 0x69, 0x21, 0x63, 0x75, - 0xb, 0x1d, 0x27, 0x0, 0x0, 0x3, 0xbc, 0x1a, 0x0, 0x1b, 0x10, 0x4c, 0x26, 0xb1, 0xb2, 0xc1, 0x86, 0xbd, 0xd6, - 0x83, 0x39, 0x8b, 0xf, 0xb6, 0x4c, 0xb1, 0x64, 0x48, 0xed, 0xa0, 0x23, 0x8f, 0xb2, 0x19, 0xc7, 0x24, 0x45, 0x29, - 0xd2, 0x16, 0x0, 0x2, 0x21, 0x2f, 0x15, 0x0, 0x19, 0x17, 0x3c, 0xad, 0x12, 0x30, 0xc, 0x37, 0xa3, 0x20, 0x15, - 0x28, 0xc3, 0xa6, 0xed, 0x57, 0x61, 0x3f, 0x57, 0x30, 0x57, 0x6f, 0x1f, 0x87, 0x8b, 0x5, 0x3, 0x0, 0x15, 0xa9, - 0xf6, 0x1a, 0x41, 0xdc, 0x9d, 0x7b, 0x59, 0x6a, 0x88, 0x3a, 0x6d, 0x8c, 0x23, 0xfb, 0x90, 0x37, 0x4b, 0x80, 0xdb, - 0xe, 0x12, 0x0, 0x2, 0x3e, 0xcf, 0x15, 0x0, 0x0, 0x26, 0x0, 0x4, 0x58, 0xd3, 0xf, 0x59, 0x0, 0x13, 0x51, - 0xcb, 0xc0, 0xdd, 0xa7, 0xa2, 0x55, 0xcc, 0xe2, 0x5d, 0x58, 0x11, 0x29, 0x34, 0xaa, 0x2b, 0x9e, 0xbb, 0x34, 0x15, - 0x0, 0x6, 0x38, 0x7c, 0x4e, 0x1e, 0x64, 0x16, 0x25, 0x56, 0x1, 0x71, 0x2, 0x0, 0x0, 0x75, 0x2a, 0x23, 0x19, - 0x2d, 0x11, 0x0, 0x0, 0x4f, 0x24, 0x2, 0x0, 0x0, 0x3a, 0x73, 0x25, 0x17, 0x2, 0x0, 0x0, 0x36, 0x9f, 0x19, - 0x67, 0x27, 0x0, 0x0, 0x22, 0xfe, 0x22, 0x34, 0xeb, 0x2, 0x0, 0x0, 0x5b, 0x7b, 0x1c, 0x0, 0x4, 0x87, 0xc3, - 0x9c, 0x5a, 0x1, 0x8f, 0x19, 0x0, 0x1f, 0x0, 0x2, 0xe4, 0xe9, 0x9a, 0x9d, 0x73, 0xe4}; - - uint8_t buf[253] = {0}; - - uint8_t topic_bytes[] = {0x2c, 0xd2, 0x6d, 0xf9, 0xad, 0x8f, 0x75, 0xd0, 0x6b, 0xb5, 0x4b, 0x6f, - 0x75, 0x5d, 0x35, 0xd3, 0x8d, 0xcc, 0x4d, 0x85, 0x2b, 0x24, 0x99}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x9a, 0x9d, 0x73, 0xe4}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22336, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 13807 [("wL\191\189\221|G\238\226$\136\tIp\SO\n\STX\165, \246K\185U\237\\",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("T\FS\235=\v;\128q\152\153}\"U[\178",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\184\150",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\190\236)\ENQ@h\184\224\&0",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("j\178B\166\172b\202\203P\STX,'\174\145\243o>\197\223\157\229|5\SOH\220\&94\241",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("BR\DLEz\176\178\218\206\141\160\252]Y\170\218\142\167\ETX\204\229=\r\255UWG",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\144\229\227)\143\168?\194\171\204\212\138\180\ETX\176\GS+\SO\254C>bp\150\184\247\144\231 ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\222CJ\178\&0\215~\186\&5\STX/\241\178\136H\207\"",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode100) { + uint8_t pkt[] = {0x82, 0xb2, 0x1, 0x35, 0xef, 0x0, 0x1a, 0x77, 0x4c, 0xbf, 0xbd, 0xdd, 0x7c, 0x47, 0xee, 0xe2, 0x24, + 0x88, 0x9, 0x49, 0x70, 0xe, 0xa, 0x2, 0xa5, 0x2c, 0x20, 0xf6, 0x4b, 0xb9, 0x55, 0xed, 0x5c, 0x0, + 0x0, 0xf, 0x54, 0x1c, 0xeb, 0x3d, 0xb, 0x3b, 0x80, 0x71, 0x98, 0x99, 0x7d, 0x22, 0x55, 0x5b, 0xb2, + 0x1, 0x0, 0x2, 0xb8, 0x96, 0x1, 0x0, 0x9, 0xbe, 0xec, 0x29, 0x5, 0x40, 0x68, 0xb8, 0xe0, 0x30, + 0x1, 0x0, 0x1c, 0x6a, 0xb2, 0x42, 0xa6, 0xac, 0x62, 0xca, 0xcb, 0x50, 0x2, 0x2c, 0x27, 0xae, 0x91, + 0xf3, 0x6f, 0x3e, 0xc5, 0xdf, 0x9d, 0xe5, 0x7c, 0x35, 0x1, 0xdc, 0x39, 0x34, 0xf1, 0x2, 0x0, 0x1a, + 0x42, 0x52, 0x10, 0x7a, 0xb0, 0xb2, 0xda, 0xce, 0x8d, 0xa0, 0xfc, 0x5d, 0x59, 0xaa, 0xda, 0x8e, 0xa7, + 0x3, 0xcc, 0xe5, 0x3d, 0xd, 0xff, 0x55, 0x57, 0x47, 0x1, 0x0, 0x1d, 0x90, 0xe5, 0xe3, 0x29, 0x8f, + 0xa8, 0x3f, 0xc2, 0xab, 0xcc, 0xd4, 0x8a, 0xb4, 0x3, 0xb0, 0x1d, 0x2b, 0xe, 0xfe, 0x43, 0x3e, 0x62, + 0x70, 0x96, 0xb8, 0xf7, 0x90, 0xe7, 0x20, 0x2, 0x0, 0x11, 0xde, 0x43, 0x4a, 0xb2, 0x30, 0xd7, 0x7e, + 0xba, 0x35, 0x2, 0x2f, 0xf1, 0xb2, 0x88, 0x48, 0xcf, 0x22, 0x1}; + + uint8_t buf[191] = {0}; + + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x77, 0x4c, 0xbf, 0xbd, 0xdd, 0x7c, 0x47, 0xee, 0xe2, 0x24, 0x88, 0x9, 0x49, + 0x70, 0xe, 0xa, 0x2, 0xa5, 0x2c, 0x20, 0xf6, 0x4b, 0xb9, 0x55, 0xed, 0x5c}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x54, 0x1c, 0xeb, 0x3d, 0xb, 0x3b, 0x80, 0x71, + 0x98, 0x99, 0x7d, 0x22, 0x55, 0x5b, 0xb2}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb8, 0x96}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xbe, 0xec, 0x29, 0x5, 0x40, 0x68, 0xb8, 0xe0, 0x30}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x6a, 0xb2, 0x42, 0xa6, 0xac, 0x62, 0xca, 0xcb, 0x50, 0x2, 0x2c, 0x27, 0xae, 0x91, + 0xf3, 0x6f, 0x3e, 0xc5, 0xdf, 0x9d, 0xe5, 0x7c, 0x35, 0x1, 0xdc, 0x39, 0x34, 0xf1}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x42, 0x52, 0x10, 0x7a, 0xb0, 0xb2, 0xda, 0xce, 0x8d, 0xa0, 0xfc, 0x5d, 0x59, + 0xaa, 0xda, 0x8e, 0xa7, 0x3, 0xcc, 0xe5, 0x3d, 0xd, 0xff, 0x55, 0x57, 0x47}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x90, 0xe5, 0xe3, 0x29, 0x8f, 0xa8, 0x3f, 0xc2, 0xab, 0xcc, + 0xd4, 0x8a, 0xb4, 0x3, 0xb0, 0x1d, 0x2b, 0xe, 0xfe, 0x43, + 0x3e, 0x62, 0x70, 0x96, 0xb8, 0xf7, 0x90, 0xe7, 0x20}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xde, 0x43, 0x4a, 0xb2, 0x30, 0xd7, 0x7e, 0xba, 0x35, + 0x2, 0x2f, 0xf1, 0xb2, 0x88, 0x48, 0xcf, 0x22}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x10, 0x4c, 0x26, 0xb1, 0xb2, 0xc1, 0x86, 0xbd, 0xd6, 0x83, 0x39, 0x8b, 0xf, 0xb6, - 0x4c, 0xb1, 0x64, 0x48, 0xed, 0xa0, 0x23, 0x8f, 0xb2, 0x19, 0xc7, 0x24, 0x45}; - uint8_t bytesprops1[] = {0x21, 0x2f}; - uint8_t bytesprops2[] = {0x17, 0x3c, 0xad, 0x12, 0x30, 0xc, 0x37, 0xa3, 0x20, 0x15, 0x28, 0xc3, 0xa6, - 0xed, 0x57, 0x61, 0x3f, 0x57, 0x30, 0x57, 0x6f, 0x1f, 0x87, 0x8b, 0x5}; - uint8_t bytesprops3[] = {0xa9, 0xf6, 0x1a, 0x41, 0xdc, 0x9d, 0x7b, 0x59, 0x6a, 0x88, 0x3a, - 0x6d, 0x8c, 0x23, 0xfb, 0x90, 0x37, 0x4b, 0x80, 0xdb, 0xe}; - uint8_t bytesprops4[] = {0x3e, 0xcf}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops7[] = {0x51, 0xcb, 0xc0, 0xdd, 0xa7, 0xa2, 0x55, 0xcc, 0xe2, 0x5d, - 0x58, 0x11, 0x29, 0x34, 0xaa, 0x2b, 0x9e, 0xbb, 0x34}; - uint8_t bytesprops6[] = {0x58, 0xd3, 0xf, 0x59}; - uint8_t bytesprops8[] = {0x38, 0x7c, 0x4e, 0x1e, 0x64, 0x16}; - uint8_t bytesprops9[] = {0x87, 0xc3, 0x9c, 0x5a}; - uint8_t bytesprops10[] = {0xe4, 0xe9}; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13807, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 31688 [("\134Q\r\137U\191\DEL\166>c<~\234\229\251\206\249tYv\161\\\154OeS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\220\254\200+\222G\NUL\254\179r\136{N\185N\151rL\147\ETX\251\145p\202\177\129\244\220",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),(";\154\220$\161c\EM\CAN\187~\EM\131+\SYN\242\172q\CAN(\214",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\199G9%\137ER:\132\252\SUB\145)\DC1\238\243q\SI",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\151\228-h2E\145\155\RS[\a\180\192{W\249\DC2k\241\246&L\189\146\SI\227P\233(",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\188\128\150\245A\241\232\247\246K\242\221E\146@\166n\144\178VMY",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("]!b\157\132\190\207K\CAN\240\196\ENQ\CAN\224\246\SOR9CcF\242\206\r\248\GSj",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropResponseInformation +// "\141\230\237\153\196\150\138\175jF)\162\152\&39\138v\253\CAN\176\&9\164",PropContentType "\142 +// |\228q\150TQt\NAK\147",PropResponseInformation "4FN\ENQU\207\&3\137\NUL\240B[K\239\140e/\206\143W\214\229\234L\191 +// ",PropRequestResponseInformation 228,PropResponseTopic "\246\&33\DLE\183\160\165\247",PropMaximumPacketSize +// 10572,PropServerKeepAlive 5009,PropCorrelationData +// "\GS/\140\160\220\135\188\242\235j\EOT\223\aH\242\191\183\a\135\&8",PropSubscriptionIdentifierAvailable +// 113,PropMessageExpiryInterval 31499,PropAuthenticationData +// "\195\f\174r\145\DEL\a\254\194B\228\\^\234z\222\CANyXwm",PropResponseTopic "",PropReceiveMaximum +// 29806,PropTopicAliasMaximum 6132,PropReceiveMaximum 6074,PropSubscriptionIdentifier 23,PropTopicAlias +// 25692,PropReasonString "\US\250\199\&6\251q\STX\138\f`_\RSE&JIG\247\v8\242\EOT",PropContentType +// "\223Y&\254\134\151\NAK\SUB\ETX\174\223"] +TEST(Subscribe5QCTest, Encode1) { + uint8_t pkt[] = { + 0x82, 0x97, 0x3, 0x7b, 0xc8, 0xc7, 0x1, 0x1a, 0x0, 0x16, 0x8d, 0xe6, 0xed, 0x99, 0xc4, 0x96, 0x8a, 0xaf, 0x6a, + 0x46, 0x29, 0xa2, 0x98, 0x33, 0x39, 0x8a, 0x76, 0xfd, 0x18, 0xb0, 0x39, 0xa4, 0x3, 0x0, 0xb, 0x8e, 0x20, 0x7c, + 0xe4, 0x71, 0x96, 0x54, 0x51, 0x74, 0x15, 0x93, 0x1a, 0x0, 0x1a, 0x34, 0x46, 0x4e, 0x5, 0x55, 0xcf, 0x33, 0x89, + 0x0, 0xf0, 0x42, 0x5b, 0x4b, 0xef, 0x8c, 0x65, 0x2f, 0xce, 0x8f, 0x57, 0xd6, 0xe5, 0xea, 0x4c, 0xbf, 0x20, 0x19, + 0xe4, 0x8, 0x0, 0x8, 0xf6, 0x33, 0x33, 0x10, 0xb7, 0xa0, 0xa5, 0xf7, 0x27, 0x0, 0x0, 0x29, 0x4c, 0x13, 0x13, + 0x91, 0x9, 0x0, 0x14, 0x1d, 0x2f, 0x8c, 0xa0, 0xdc, 0x87, 0xbc, 0xf2, 0xeb, 0x6a, 0x4, 0xdf, 0x7, 0x48, 0xf2, + 0xbf, 0xb7, 0x7, 0x87, 0x38, 0x29, 0x71, 0x2, 0x0, 0x0, 0x7b, 0xb, 0x16, 0x0, 0x15, 0xc3, 0xc, 0xae, 0x72, + 0x91, 0x7f, 0x7, 0xfe, 0xc2, 0x42, 0xe4, 0x5c, 0x5e, 0xea, 0x7a, 0xde, 0x18, 0x79, 0x58, 0x77, 0x6d, 0x8, 0x0, + 0x0, 0x21, 0x74, 0x6e, 0x22, 0x17, 0xf4, 0x21, 0x17, 0xba, 0xb, 0x17, 0x23, 0x64, 0x5c, 0x1f, 0x0, 0x16, 0x1f, + 0xfa, 0xc7, 0x36, 0xfb, 0x71, 0x2, 0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, 0xf6, 0x4b, 0xf2, 0xdd, 0x45, 0x92, 0x40, 0xa6, 0x6e, 0x90, 0xb2, 0x56, 0x4d, 0x59, 0x1, + 0x0, 0x1b, 0x5d, 0x21, 0x62, 0x9d, 0x84, 0xbe, 0xcf, 0x4b, 0x18, 0xf0, 0xc4, 0x5, 0x18, 0xe0, 0xf6, 0xe, 0x52, + 0x39, 0x43, 0x63, 0x46, 0xf2, 0xce, 0xd, 0xf8, 0x1d, 0x6a, 0x2}; + + uint8_t buf[420] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x86, 0x51, 0xd, 0x89, 0x55, 0xbf, 0x7f, 0xa6, 0x3e, 0x63, 0x3c, 0x7e, 0xea, + 0xe5, 0xfb, 0xce, 0xf9, 0x74, 0x59, 0x76, 0xa1, 0x5c, 0x9a, 0x4f, 0x65, 0x53}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xdc, 0xfe, 0xc8, 0x2b, 0xde, 0x47, 0x0, 0xfe, 0xb3, 0x72, + 0x88, 0x7b, 0x4e, 0xb9, 0x4e, 0x97, 0x72, 0x4c, 0x93, 0x3, + 0xfb, 0x91, 0x70, 0xca, 0xb1, 0x81, 0xf4, 0xdc}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x3b, 0x9a, 0xdc, 0x24, 0xa1, 0x63, 0x19, 0x18, 0xbb, 0x7e, + 0x19, 0x83, 0x2b, 0x16, 0xf2, 0xac, 0x71, 0x18, 0x28, 0xd6}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc7, 0x47, 0x39, 0x25, 0x89, 0x45, 0x52, 0x3a, 0x84, + 0xfc, 0x1a, 0x91, 0x29, 0x11, 0xee, 0xf3, 0x71, 0xf}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6b}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x97, 0xe4, 0x2d, 0x68, 0x32, 0x45, 0x91, 0x9b, 0x1e, 0x5b, + 0x7, 0xb4, 0xc0, 0x7b, 0x57, 0xf9, 0x12, 0x6b, 0xf1, 0xf6, + 0x26, 0x4c, 0xbd, 0x92, 0xf, 0xe3, 0x50, 0xe9, 0x28}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0}; + lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xbc, 0x80, 0x96, 0xf5, 0x41, 0xf1, 0xe8, 0xf7, 0xf6, 0x4b, 0xf2, + 0xdd, 0x45, 0x92, 0x40, 0xa6, 0x6e, 0x90, 0xb2, 0x56, 0x4d, 0x59}; + lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x5d, 0x21, 0x62, 0x9d, 0x84, 0xbe, 0xcf, 0x4b, 0x18, + 0xf0, 0xc4, 0x5, 0x18, 0xe0, 0xf6, 0xe, 0x52, 0x39, + 0x43, 0x63, 0x46, 0xf2, 0xce, 0xd, 0xf8, 0x1d, 0x6a}; + lwmqtt_string_t topic_filter_s10 = {27, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x8d, 0xe6, 0xed, 0x99, 0xc4, 0x96, 0x8a, 0xaf, 0x6a, 0x46, 0x29, + 0xa2, 0x98, 0x33, 0x39, 0x8a, 0x76, 0xfd, 0x18, 0xb0, 0x39, 0xa4}; + uint8_t bytesprops1[] = {0x8e, 0x20, 0x7c, 0xe4, 0x71, 0x96, 0x54, 0x51, 0x74, 0x15, 0x93}; + uint8_t bytesprops2[] = {0x34, 0x46, 0x4e, 0x5, 0x55, 0xcf, 0x33, 0x89, 0x0, 0xf0, 0x42, 0x5b, 0x4b, + 0xef, 0x8c, 0x65, 0x2f, 0xce, 0x8f, 0x57, 0xd6, 0xe5, 0xea, 0x4c, 0xbf, 0x20}; + uint8_t bytesprops3[] = {0xf6, 0x33, 0x33, 0x10, 0xb7, 0xa0, 0xa5, 0xf7}; + uint8_t bytesprops4[] = {0x1d, 0x2f, 0x8c, 0xa0, 0xdc, 0x87, 0xbc, 0xf2, 0xeb, 0x6a, + 0x4, 0xdf, 0x7, 0x48, 0xf2, 0xbf, 0xb7, 0x7, 0x87, 0x38}; + uint8_t bytesprops5[] = {0xc3, 0xc, 0xae, 0x72, 0x91, 0x7f, 0x7, 0xfe, 0xc2, 0x42, 0xe4, + 0x5c, 0x5e, 0xea, 0x7a, 0xde, 0x18, 0x79, 0x58, 0x77, 0x6d}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops7[] = {0x1f, 0xfa, 0xc7, 0x36, 0xfb, 0x71, 0x2, 0x8a, 0xc, 0x60, 0x5f, + 0x1e, 0x45, 0x26, 0x4a, 0x49, 0x47, 0xf7, 0xb, 0x38, 0xf2, 0x4}; + uint8_t bytesprops8[] = {0xdf, 0x59, 0x26, 0xfe, 0x86, 0x97, 0x15, 0x1a, 0x3, 0xae, 0xdf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6761}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25461}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 956}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops6}, .v = {19, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29994}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6445}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20260}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14963}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13983}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8958}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13547}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23419}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10572}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5009}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31499}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29806}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6132}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6074}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25692}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31688, 11, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 25984 +// [("1\GS\194\RS\CAND\173\140\252\160\207\178\215*q\172o\165\DC3\n\250\129\USa\128\ETB\183\171",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\175\195N\144p\188x@x\190\233.LbP!\f{\DLEez\153\bs\DC3",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\246\&9\f\n\v\143znf!\192pb2",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Vw\169\NUL\222V\237}\DLE\240t\249",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [PropPayloadFormatIndicator 130,PropMessageExpiryInterval +// 14472,PropAuthenticationData +// "\156?\131\151\US\207_\177\246\228\153?\205\&0V\253\ETX\r\SI2\236\\\214\rV\136=z7\153",PropWildcardSubscriptionAvailable +// 90,PropMessageExpiryInterval 12708,PropReceiveMaximum 13332,PropResponseTopic +// "\222>$",PropSharedSubscriptionAvailable 122,PropSessionExpiryInterval 7520,PropAuthenticationData +// "\161\231\137_\217\166\204]\192\233\175\246P$\DEL\189\147",PropRequestResponseInformation 212,PropReasonString +// "\155A5\164+$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9, 0x0, 0xde, 0x56, 0xed, 0x7d, 0x10, 0xf0, 0x74, 0xf9, 0x1}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[201] = {0}; -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\NUL\DEL\203\RS\240:\141&\173E\160ge\161\253\204@\CANsE\DC4\250-\170\139\170\173", _pubPktID = 16148, _pubBody = -// "\217\SOH\255\&9\132\DC1ce\133\DLE\176\244\r\ti\207a\239X\210\160\160\224v\216\t", _pubProps = -// [PropWildcardSubscriptionAvailable 154,PropCorrelationData "\191r\216",PropMessageExpiryInterval -// 24076,PropAuthenticationData "G1\138V\146\SO",PropSubscriptionIdentifierAvailable 148,PropRequestProblemInformation -// 135,PropWillDelayInterval 31841,PropMaximumQoS 13,PropAuthenticationData -// "\151\163B\254\223\172\ETB",PropRequestResponseInformation 190,PropSessionExpiryInterval 4965,PropUserProperty -// "q\131C \NAK\236\142\210\148\230" "\251\226\r\US\196,.\RS`R1}\DC2s\143\n",PropWildcardSubscriptionAvailable -// 0,PropTopicAlias 13696,PropAuthenticationData -// "j\171\243\197\NUL\173&\172\148\176\215Md\174\\\246\ACK1\132",PropMessageExpiryInterval 7797,PropAuthenticationData -// "\\]>\164\143",PropSubscriptionIdentifierAvailable 133,PropRequestResponseInformation 196,PropMessageExpiryInterval -// 8000,PropRetainAvailable 41,PropContentType "\186H\129\176\NAK\238\tB\ENQ3\158n\143\178\175\180\145\t\218\144\222vVl -// -",PropRetainAvailable 95]} -TEST(Publish5QCTest, Encode16) { - uint8_t pkt[] = { - 0x3a, 0xde, 0x1, 0x0, 0x1b, 0x0, 0x7f, 0xcb, 0x1e, 0xf0, 0x3a, 0x8d, 0x26, 0xad, 0x45, 0xa0, 0x67, 0x65, 0xa1, - 0xfd, 0xcc, 0x40, 0x18, 0x73, 0x45, 0x14, 0xfa, 0x2d, 0xaa, 0x8b, 0xaa,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 0x76, 0xd8, 0x9}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x31, 0x1d, 0xc2, 0x1e, 0x18, 0x44, 0xad, 0x8c, 0xfc, 0xa0, + 0xcf, 0xb2, 0xd7, 0x2a, 0x71, 0xac, 0x6f, 0xa5, 0x13, 0xa, + 0xfa, 0x81, 0x1f, 0x61, 0x80, 0x17, 0xb7, 0xab}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xaf, 0xc3, 0x4e, 0x90, 0x70, 0xbc, 0x78, 0x40, 0x78, 0xbe, 0xe9, 0x2e, 0x4c, + 0x62, 0x50, 0x21, 0xc, 0x7b, 0x10, 0x65, 0x7a, 0x99, 0x8, 0x73, 0x13}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf6, 0x39, 0xc, 0xa, 0xb, 0x8f, 0x7a, 0x6e, 0x66, 0x21, 0xc0, 0x70, 0x62, 0x32}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x56, 0x77, 0xa9, 0x0, 0xde, 0x56, 0xed, 0x7d, 0x10, 0xf0, 0x74, 0xf9}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x9c, 0x3f, 0x83, 0x97, 0x1f, 0xcf, 0x5f, 0xb1, 0xf6, 0xe4, 0x99, 0x3f, 0xcd, 0x30, 0x56, + 0xfd, 0x3, 0xd, 0xf, 0x32, 0xec, 0x5c, 0xd6, 0xd, 0x56, 0x88, 0x3d, 0x7a, 0x37, 0x99}; + uint8_t bytesprops1[] = {0xde, 0x3e, 0x24}; + uint8_t bytesprops2[] = {0xa1, 0xe7, 0x89, 0x5f, 0xd9, 0xa6, 0xcc, 0x5d, 0xc0, + 0xe9, 0xaf, 0xf6, 0x50, 0x24, 0x7f, 0xbd, 0x93}; + uint8_t bytesprops3[] = {0x9b, 0x41, 0x35, 0xa4, 0x2b, 0x24}; - uint8_t buf[235] = {0}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14472}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12708}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13332}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7520}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops3}}}, + }; - uint8_t topic_bytes[] = {0x0, 0x7f, 0xcb, 0x1e, 0xf0, 0x3a, 0x8d, 0x26, 0xad, 0x45, 0xa0, 0x67, 0x65, 0xa1, - 0xfd, 0xcc, 0x40, 0x18, 0x73, 0x45, 0x14, 0xfa, 0x2d, 0xaa, 0x8b, 0xaa, 0xad}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xd9, 0x1, 0xff, 0x39, 0x84, 0x11, 0x63, 0x65, 0x85, 0x10, 0xb0, 0xf4, 0xd, - 0x9, 0x69, 0xcf, 0x61, 0xef, 0x58, 0xd2, 0xa0, 0xa0, 0xe0, 0x76, 0xd8, 0x9}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; - - uint8_t bytesprops0[] = {0xbf, 0x72, 0xd8}; - uint8_t bytesprops1[] = {0x47, 0x31, 0x8a, 0x56, 0x92, 0xe}; - uint8_t bytesprops2[] = {0x97, 0xa3, 0x42, 0xfe, 0xdf, 0xac, 0x17}; - uint8_t bytesprops4[] = {0xfb, 0xe2, 0xd, 0x1f, 0xc4, 0x2c, 0x2e, 0x1e, - 0x60, 0x52, 0x31, 0x7d, 0x12, 0x73, 0x8f, 0xa}; - uint8_t bytesprops3[] = {0x71, 0x83, 0x43, 0x20, 0x15, 0xec, 0x8e, 0xd2, 0x94, 0xe6}; - uint8_t bytesprops5[] = {0x6a, 0xab, 0xf3, 0xc5, 0x0, 0xad, 0x26, 0xac, 0x94, 0xb0, - 0xd7, 0x4d, 0x64, 0xae, 0x5c, 0xf6, 0x6, 0x31, 0x84}; - uint8_t bytesprops6[] = {0x5c, 0x5d, 0x3e, 0xa4, 0x8f}; - uint8_t bytesprops7[] = {0xba, 0x48, 0x81, 0xb0, 0x15, 0xee, 0x9, 0x42, 0x5, 0x33, 0x9e, 0x6e, 0x8f, - 0xb2, 0xaf, 0xb4, 0x91, 0x9, 0xda, 0x90, 0xde, 0x76, 0x56, 0x6c, 0x20, 0x2d}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25984, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 15464 +// [("\SOC\155\217\ESC\vJ\139\SOW\183\RS]\STX&\SUB\184\NUL\242J\186\165\165\204\&5\160\209\156\&9",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\248\143P2v\177\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("n\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2}),("X\159\CAN\143\245\n\206y\DC4\135\DC4i\232`",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\DLEA\227\&5x\234\US\171",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\164\177\152\ETBhD\152\251\180\"\244\239\191\241\149\227}\183\&0",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\r@\174C\FSM$\180\212'\253\157\173\SOI9\204b",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("C\226\169\230)",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\145Tu\NUL\b\ESC\227",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] +// [PropTopicAliasMaximum 18730,PropSessionExpiryInterval 5052,PropSubscriptionIdentifierAvailable +// 10,PropCorrelationData "\EOT\160_\129\199h\241\244\158Di\130\128A\157*\n\199",PropMessageExpiryInterval +// 9252,PropRetainAvailable 152,PropContentType "X\170",PropMaximumQoS 200,PropAuthenticationMethod +// "\133\&0\230d\240#\198\167\152[\t\141\162\&5\f\182\174\222J\238\141\223Q\210\&9;",PropServerReference +// "\246\243'\142\140gr\158\229/\220\198\&8e\217\221\&5\195\239\164\237\200\t\189\t\n\177\FS\193\b",PropCorrelationData +// "b@M\135U=@X",PropReceiveMaximum 13606,PropPayloadFormatIndicator 76,PropReceiveMaximum 21293,PropReasonString +// "\178\ETB\135\DEL\141.p\US\146mg\v%b\210\147;_8\252\231_\191\242K\v\246*d\230",PropSubscriptionIdentifierAvailable +// 140] +TEST(Subscribe5QCTest, Encode3) { + uint8_t pkt[] = { + 0x82, 0xad, 0x2, 0x3c, 0x68, 0xa1, 0x1, 0x22, 0x49, 0x2a, 0x11, 0x0, 0x0, 0x13, 0xbc, 0x29, 0xa, 0x9, 0x0, + 0x12, 0x4, 0xa0, 0x5f, 0x81, 0xc7, 0x68, 0xf1, 0xf4, 0x9e, 0x44, 0x69, 0x82, 0x80, 0x41, 0x9d, 0x2a, 0xa, 0xc7, + 0x2, 0x0, 0x0, 0x24, 0x24, 0x25, 0x98, 0x3, 0x0, 0x2, 0x58, 0xaa, 0x24, 0xc8, 0x15, 0x0, 0x1a, 0x85, 0x30, + 0xe6, 0x64, 0xf0, 0x23, 0xc6, 0xa7, 0x98, 0x5b, 0x9, 0x8d, 0xa2, 0x35, 0xc, 0xb6, 0xae, 0xde, 0x4a, 0xee, 0x8d, + 0xdf, 0x51, 0xd2, 0x39, 0x3b, 0x1c, 0x0, 0x1e, 0xf6, 0xf3, 0x27, 0x8e, 0x8c, 0x67, 0x72, 0x9e, 0xe5, 0x2f, 0xdc, + 0xc6, 0x38, 0x65, 0xd9, 0xdd, 0x35, 0xc3, 0xef, 0xa4, 0xed, 0xc8, 0x9, 0xbd, 0x9, 0xa, 0xb1, 0x1c, 0xc1, 0x8, + 0x9, 0x0, 0x8, 0x62, 0x40, 0x4d, 0x87, 0x55, 0x3d, 0x40, 0x58, 0x21, 0x35, 0x26, 0x1, 0x4c, 0x21, 0x53, 0x2d, + 0x1f, 0x0, 0x1e, 0xb2, 0x17, 0x87, 0x7f, 0x8d, 0x2e, 0x70, 0x1f, 0x92, 0x6d, 0x67, 0xb, 0x25, 0x62, 0xd2, 0x93, + 0x3b, 0x5f, 0x38, 0xfc, 0xe7, 0x5f, 0xbf, 0xf2, 0x4b, 0xb, 0xf6, 0x2a, 0x64, 0xe6, 0x29, 0x8c, 0x0, 0x1d, 0xe, + 0x43, 0x9b, 0xd9, 0x1b, 0xb, 0x4a, 0x8b, 0xe, 0x57, 0xb7, 0x1e, 0x5d, 0x2, 0x26, 0x1a, 0xb8, 0x0, 0xf2, 0x4a, + 0xba, 0xa5, 0xa5, 0xcc, 0x35, 0xa0, 0xd1, 0x9c, 0x39, 0x0, 0x0, 0x7, 0xf8, 0x8f, 0x50, 0x32, 0x76, 0xb1, 0x32, + 0x2, 0x0, 0x2, 0x6e, 0xd2, 0x2, 0x0, 0xe, 0x58, 0x9f, 0x18, 0x8f, 0xf5, 0xa, 0xce, 0x79, 0x14, 0x87, 0x14, + 0x69, 0xe8, 0x60, 0x2, 0x0, 0x8, 0x10, 0x41, 0xe3, 0x35, 0x78, 0xea, 0x1f, 0xab, 0x0, 0x0, 0x13, 0xa4, 0xb1, + 0x98, 0x17, 0x68, 0x44, 0x98, 0xfb, 0xb4, 0x22, 0xf4, 0xef, 0xbf, 0xf1, 0x95, 0xe3, 0x7d, 0xb7, 0x30, 0x0, 0x0, + 0x12, 0xd, 0x40, 0xae, 0x43, 0x1c, 0x4d, 0x24, 0xb4, 0xd4, 0x27, 0xfd, 0x9d, 0xad, 0xe, 0x49, 0x39, 0xcc, 0x62, + 0x0, 0x0, 0x5, 0x43, 0xe2, 0xa9, 0xe6, 0x29, 0x0, 0x0, 0x7, 0x91, 0x54, 0x75, 0x0, 0x8, 0x1b, 0xe3, 0x1}; + + uint8_t buf[314] = {0}; + + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xe, 0x43, 0x9b, 0xd9, 0x1b, 0xb, 0x4a, 0x8b, 0xe, 0x57, + 0xb7, 0x1e, 0x5d, 0x2, 0x26, 0x1a, 0xb8, 0x0, 0xf2, 0x4a, + 0xba, 0xa5, 0xa5, 0xcc, 0x35, 0xa0, 0xd1, 0x9c, 0x39}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf8, 0x8f, 0x50, 0x32, 0x76, 0xb1, 0x32}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x6e, 0xd2}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x58, 0x9f, 0x18, 0x8f, 0xf5, 0xa, 0xce, 0x79, 0x14, 0x87, 0x14, 0x69, 0xe8, 0x60}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x10, 0x41, 0xe3, 0x35, 0x78, 0xea, 0x1f, 0xab}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa4, 0xb1, 0x98, 0x17, 0x68, 0x44, 0x98, 0xfb, 0xb4, 0x22, + 0xf4, 0xef, 0xbf, 0xf1, 0x95, 0xe3, 0x7d, 0xb7, 0x30}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xd, 0x40, 0xae, 0x43, 0x1c, 0x4d, 0x24, 0xb4, 0xd4, + 0x27, 0xfd, 0x9d, 0xad, 0xe, 0x49, 0x39, 0xcc, 0x62}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x43, 0xe2, 0xa9, 0xe6, 0x29}; + lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x91, 0x54, 0x75, 0x0, 0x8, 0x1b, 0xe3}; + lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x4, 0xa0, 0x5f, 0x81, 0xc7, 0x68, 0xf1, 0xf4, 0x9e, + 0x44, 0x69, 0x82, 0x80, 0x41, 0x9d, 0x2a, 0xa, 0xc7}; + uint8_t bytesprops1[] = {0x58, 0xaa}; + uint8_t bytesprops2[] = {0x85, 0x30, 0xe6, 0x64, 0xf0, 0x23, 0xc6, 0xa7, 0x98, 0x5b, 0x9, 0x8d, 0xa2, + 0x35, 0xc, 0xb6, 0xae, 0xde, 0x4a, 0xee, 0x8d, 0xdf, 0x51, 0xd2, 0x39, 0x3b}; + uint8_t bytesprops3[] = {0xf6, 0xf3, 0x27, 0x8e, 0x8c, 0x67, 0x72, 0x9e, 0xe5, 0x2f, 0xdc, 0xc6, 0x38, 0x65, 0xd9, + 0xdd, 0x35, 0xc3, 0xef, 0xa4, 0xed, 0xc8, 0x9, 0xbd, 0x9, 0xa, 0xb1, 0x1c, 0xc1, 0x8}; + uint8_t bytesprops4[] = {0x62, 0x40, 0x4d, 0x87, 0x55, 0x3d, 0x40, 0x58}; + uint8_t bytesprops5[] = {0xb2, 0x17, 0x87, 0x7f, 0x8d, 0x2e, 0x70, 0x1f, 0x92, 0x6d, 0x67, 0xb, 0x25, 0x62, 0xd2, + 0x93, 0x3b, 0x5f, 0x38, 0xfc, 0xe7, 0x5f, 0xbf, 0xf2, 0x4b, 0xb, 0xf6, 0x2a, 0x64, 0xe6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24076}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31841}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4965}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops3}, .v = {16, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13696}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7797}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8000}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18730}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5052}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9252}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13606}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21293}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 140}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16148, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15464, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\225\180\242F\ENQ\203\138\241\216i%\241\223n\157\150\bT\255", _pubPktID = 0, _pubBody = "'", _pubProps = -// [PropSharedSubscriptionAvailable 118,PropReasonString "$g\220\202=\249}",PropContentType -// "\230\237-\186\DLE\158\ACK(\231\187\136i\194%\238\131\200",PropAuthenticationData -// ">*\NAK9\254W\137i\244@\252:@[",PropCorrelationData "OpE\199\243\"z\164\"\239\216\161{\237e\USH\237",PropUserProperty -// "" "\163T\203\128f",PropReceiveMaximum 10674,PropSubscriptionIdentifier 28,PropSharedSubscriptionAvailable -// 40,PropContentType "7\253\&7\132\134\227\168z\247\176",PropMaximumQoS 81,PropMaximumQoS -// 252,PropAssignedClientIdentifier "i:}k\230\196\190\ETXg\SI",PropTopicAlias 24243,PropReasonString -// "\249\234n\235\146G\210",PropAssignedClientIdentifier "\232~\206\136\FS\244\EOT -// \206\150\251@\140\180\176\192\aca\156",PropMessageExpiryInterval 30666,PropSubscriptionIdentifierAvailable -// 184,PropContentType "\t\209H\246K\b4R\160#\200\223z\SOH&\153\&6i\142\203#\199@C",PropServerKeepAlive -// 5395,PropResponseTopic "\228\251\216Q\207+\163\224\184\252\173",PropMessageExpiryInterval 203,PropResponseInformation -// "",PropServerKeepAlive 2025,PropWillDelayInterval 31464,PropUserProperty -// "\135\194\DC49\149\NAK3\193$\ACK\245\208\&6Y\173\223\214I" "\228\147",PropMessageExpiryInterval -// 4928,PropRetainAvailable 255,PropRetainAvailable 156,PropWillDelayInterval 28241]} -TEST(Publish5QCTest, Encode17) { - uint8_t pkt[] = {0x30, 0x9b, 0x2, 0x0, 0x13, 0xe1, 0xb4, 0xf2, 0x46, 0x5, 0xcb, 0x8a, 0xf1, 0xd8, 0x69, 0x25, 0xf1, - 0xdf, 0x6e, 0x9d, 0x96, 0x8, 0x54, 0xff, 0x83, 0x2, 0x2a, 0x76, 0x1f, 0x0, 0x7, 0x24, 0x67, 0xdc, - 0xca, 0x3d, 0xf9, 0x7d, 0x3, 0x0, 0x11, 0xe6, 0xed, 0x2d, 0xba, 0x10, 0x9e, 0x6, 0x28, 0xe7, 0xbb, - 0x88, 0x69, 0xc2, 0x25, 0xee, 0x83, 0xc8, 0x16, 0x0, 0xe, 0x3e, 0x2a, 0x15, 0x39, 0xfe, 0x57, 0x89, - 0x69, 0xf4, 0x40, 0xfc, 0x3a, 0x40, 0x5b, 0x9, 0x0, 0x12, 0x4f, 0x70, 0x45, 0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0xe4, 0x93, 0x2, - 0x0, 0x0, 0x13, 0x40, 0x25, 0xff, 0x25, 0x9c, 0x18, 0x0, 0x0, 0x6e, 0x51, 0x27}; - - uint8_t buf[296] = {0}; - - uint8_t topic_bytes[] = {0xe1, 0xb4, 0xf2, 0x46, 0x5, 0xcb, 0x8a, 0xf1, 0xd8, 0x69, - 0x25, 0xf1, 0xdf, 0x6e, 0x9d, 0x96, 0x8, 0x54, 0xff}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x27}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; - - uint8_t bytesprops0[] = {0x24, 0x67, 0xdc, 0xca, 0x3d, 0xf9, 0x7d}; - uint8_t bytesprops1[] = {0xe6, 0xed, 0x2d, 0xba, 0x10, 0x9e, 0x6, 0x28, 0xe7, - 0xbb, 0x88, 0x69, 0xc2, 0x25, 0xee, 0x83, 0xc8}; - uint8_t bytesprops2[] = {0x3e, 0x2a, 0x15, 0x39, 0xfe, 0x57, 0x89, 0x69, 0xf4, 0x40, 0xfc, 0x3a, 0x40, 0x5b}; - uint8_t bytesprops3[] = {0x4f, 0x70, 0x45, 0xc7, 0xf3, 0x22, 0x7a, 0xa4, 0x22, - 0xef, 0xd8, 0xa1, 0x7b, 0xed, 0x65, 0x1f, 0x48, 0xed}; - uint8_t bytesprops5[] = {0xa3, 0x54, 0xcb, 0x80, 0x66}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops6[] = {0x37, 0xfd, 0x37, 0x84, 0x86, 0xe3, 0xa8, 0x7a, 0xf7, 0xb0}; - uint8_t bytesprops7[] = {0x69, 0x3a, 0x7d, 0x6b, 0xe6, 0xc4, 0xbe, 0x3, 0x67, 0xf}; - uint8_t bytesprops8[] = {0xf9, 0xea, 0x6e, 0xeb, 0x92, 0x47, 0xd2}; - uint8_t bytesprops9[] = {0xe8, 0x7e, 0xce, 0x88, 0x1c, 0xf4, 0x4, 0x20, 0xce, 0x96, - 0xfb, 0x40, 0x8c, 0xb4, 0xb0, 0xc0, 0x7, 0x63, 0x61, 0x9c}; - uint8_t bytesprops10[] = {0x9, 0xd1, 0x48, 0xf6, 0x4b, 0x8, 0x34, 0x52, 0xa0, 0x23, 0xc8, 0xdf, - 0x7a, 0x1, 0x26, 0x99, 0x36, 0x69, 0x8e, 0xcb, 0x23, 0xc7, 0x40, 0x43}; - uint8_t bytesprops11[] = {0xe4, 0xfb, 0xd8, 0x51, 0xcf, 0x2b, 0xa3, 0xe0, 0xb8, 0xfc, 0xad}; - uint8_t bytesprops12[] = {0}; - uint8_t bytesprops14[] = {0xe4, 0x93}; - uint8_t bytesprops13[] = {0x87, 0xc2, 0x14, 0x39, 0x95, 0x15, 0x33, 0xc1, 0x24, - 0x6, 0xf5, 0xd0, 0x36, 0x59, 0xad, 0xdf, 0xd6, 0x49}; +// SubscribeRequest 838 [("$-\227\252n\140N\241\225\146S\213\231(\193\150\248\177u\194",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval +// 9616,PropPayloadFormatIndicator 152,PropAssignedClientIdentifier "\237\248\176\172\135H\154s\242\197|\140 +// &\209\rQh#e\171\234",PropAssignedClientIdentifier "\t",PropAuthenticationMethod +// "\214\255_\213g\182\&5m\217\n\"",PropUserProperty "\224<\159\154\193\174\207\166" +// "BL;3R\187j\225\246mD\222\239\153\230\146\240\233\149\175\189"] +TEST(Subscribe5QCTest, Encode4) { + uint8_t pkt[] = {0x82, 0x6e, 0x3, 0x46, 0x54, 0x2, 0x0, 0x0, 0x25, 0x90, 0x1, 0x98, 0x12, 0x0, 0x16, 0xed, + 0xf8, 0xb0, 0xac, 0x87, 0x48, 0x9a, 0x73, 0xf2, 0xc5, 0x7c, 0x8c, 0x20, 0x26, 0xd1, 0xd, 0x51, + 0x68, 0x23, 0x65, 0xab, 0xea, 0x12, 0x0, 0x1, 0x9, 0x15, 0x0, 0xb, 0xd6, 0xff, 0x5f, 0xd5, + 0x67, 0xb6, 0x35, 0x6d, 0xd9, 0xa, 0x22, 0x26, 0x0, 0x8, 0xe0, 0x3c, 0x9f, 0x9a, 0xc1, 0xae, + 0xcf, 0xa6, 0x0, 0x15, 0x42, 0x4c, 0x3b, 0x33, 0x52, 0xbb, 0x6a, 0xe1, 0xf6, 0x6d, 0x44, 0xde, + 0xef, 0x99, 0xe6, 0x92, 0xf0, 0xe9, 0x95, 0xaf, 0xbd, 0x0, 0x14, 0x24, 0x2d, 0xe3, 0xfc, 0x6e, + 0x8c, 0x4e, 0xf1, 0xe1, 0x92, 0x53, 0xd5, 0xe7, 0x28, 0xc1, 0x96, 0xf8, 0xb1, 0x75, 0xc2, 0x1}; + + uint8_t buf[122] = {0}; + + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x24, 0x2d, 0xe3, 0xfc, 0x6e, 0x8c, 0x4e, 0xf1, 0xe1, 0x92, + 0x53, 0xd5, 0xe7, 0x28, 0xc1, 0x96, 0xf8, 0xb1, 0x75, 0xc2}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xed, 0xf8, 0xb0, 0xac, 0x87, 0x48, 0x9a, 0x73, 0xf2, 0xc5, 0x7c, + 0x8c, 0x20, 0x26, 0xd1, 0xd, 0x51, 0x68, 0x23, 0x65, 0xab, 0xea}; + uint8_t bytesprops1[] = {0x9}; + uint8_t bytesprops2[] = {0xd6, 0xff, 0x5f, 0xd5, 0x67, 0xb6, 0x35, 0x6d, 0xd9, 0xa, 0x22}; + uint8_t bytesprops4[] = {0x42, 0x4c, 0x3b, 0x33, 0x52, 0xbb, 0x6a, 0xe1, 0xf6, 0x6d, 0x44, + 0xde, 0xef, 0x99, 0xe6, 0x92, 0xf0, 0xe9, 0x95, 0xaf, 0xbd}; + uint8_t bytesprops3[] = {0xe0, 0x3c, 0x9f, 0x9a, 0xc1, 0xae, 0xcf, 0xa6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops4}, .v = {5, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10674}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24243}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30666}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5395}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 203}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2025}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31464}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops13}, .v = {2, (char*)&bytesprops14}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4928}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28241}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9616}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops3}, .v = {21, (char*)&bytesprops4}}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 838, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 16617 [("*\213.\SOH{\207\165\GS\FS\150\148]qq=A\239\234\252\189\STX;",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\210<\215\&2\177\181\232\211j\199\228\159~/\181X\SYN\136\205\\\253#",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\223[\223\187\180|\210;\149\229\164E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\133\253\223\167\156+\246\156\162\137\SYN\187I\v\233\SUB-\204P\169\233",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("1\b?\185o\135\176\195\173\ETB\161\156'\128M",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("6\129\247\STX\251H6",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("#`\225\150-e~\189\179c\212Qv\226U\171q\201\244\186i\219\169\234\t\175",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\NUL\136\CANO\SI\DEL\DC3\SYN\162\134\176\241\190eb\210\155",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\129>",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerReference +// "4\241{\135)\177\156\182\DC2|\186'?\161\224\&3",PropUserProperty +// "=G\147\136\ETX\169_\SOH\232\143\197\218\191\DC3d\238E\157\v7\ETXlP" +// "P~\254\155\151\194",PropSharedSubscriptionAvailable 185,PropAuthenticationData +// "\170\172\181:\178\228\255I\b\159\147\172\ETX\137'#\215a\144",PropRequestResponseInformation +// 207,PropMessageExpiryInterval 5495,PropWillDelayInterval 605,PropAssignedClientIdentifier +// "v\183\b\142\195\244\240\130\161\254\&6x\FSJ",PropMessageExpiryInterval 15712,PropServerKeepAlive +// 1894,PropTopicAliasMaximum 13651,PropAuthenticationMethod "\235T}\CAN",PropUserProperty "K\249\DC2|" +// "\237\n\158OC\182\178\242\255\238\179\248\a\253",PropResponseTopic +// "\DC4\f\160\215\192Yp;\221\172\ENQHf^\185u\207\&0\EM\203\133!\ACKs_\214q",PropSubscriptionIdentifier +// 1,PropMaximumPacketSize 25076,PropRequestProblemInformation 68] +TEST(Subscribe5QCTest, Encode5) { + uint8_t pkt[] = { + 0x82, 0xe9, 0x2, 0x40, 0xe9, 0xba, 0x1, 0x1c, 0x0, 0x10, 0x34, 0xf1, 0x7b, 0x87, 0x29, 0xb1, 0x9c, 0xb6, 0x12, + 0x7c, 0xba, 0x27, 0x3f, 0xa1, 0xe0, 0x33, 0x26, 0x0, 0x17, 0x3d, 0x47, 0x93, 0x88, 0x3, 0xa9, 0x5f, 0x1, 0xe8, + 0x8f, 0xc5, 0xda, 0xbf, 0x13, 0x64, 0xee, 0x45, 0x9d, 0xb, 0x37, 0x3, 0x6c, 0x50, 0x0, 0x6, 0x50, 0x7e, 0xfe, + 0x9b, 0x97, 0xc2, 0x2a, 0xb9, 0x16, 0x0, 0x13, 0xaa, 0xac, 0xb5, 0x3a, 0xb2, 0xe4, 0xff, 0x49, 0x8, 0x9f, 0x93, + 0xac, 0x3, 0x89, 0x27, 0x23, 0xd7, 0x61, 0x90, 0x19, 0xcf, 0x2, 0x0, 0x0, 0x15, 0x77, 0x18, 0x0, 0x0, 0x2, + 0x5d, 0x12, 0x0, 0xe, 0x76, 0xb7, 0x8, 0x8e, 0xc3, 0xf4, 0xf0, 0x82, 0xa1, 0xfe, 0x36, 0x78, 0x1c, 0x4a, 0x2, + 0x0, 0x0, 0x3d, 0x60, 0x13, 0x7, 0x66, 0x22, 0x35, 0x53, 0x15, 0x0, 0x4, 0xeb, 0x54, 0x7d, 0x18, 0x26, 0x0, + 0x4, 0x4b, 0xf9, 0x12, 0x7c, 0x0, 0xe, 0xed, 0xa, 0x9e, 0x4f, 0x43, 0xb6, 0xb2, 0xf2, 0xff, 0xee, 0xb3, 0xf8, + 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 0xaf, 0x0, 0x0, 0x11, 0x0, + 0x88, 0x18, 0x4f, 0xf, 0x7f, 0x13, 0x16, 0xa2, 0x86, 0xb0, 0xf1, 0xbe, 0x65, 0x62, 0xd2, 0x9b, 0x1, 0x0, 0x2, + 0x81, 0x3e, 0x1}; + + uint8_t buf[374] = {0}; + + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x2a, 0xd5, 0x2e, 0x1, 0x7b, 0xcf, 0xa5, 0x1d, 0x1c, 0x96, 0x94, + 0x5d, 0x71, 0x71, 0x3d, 0x41, 0xef, 0xea, 0xfc, 0xbd, 0x2, 0x3b}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd2, 0x3c, 0xd7, 0x32, 0xb1, 0xb5, 0xe8, 0xd3, 0x6a, 0xc7, 0xe4, + 0x9f, 0x7e, 0x2f, 0xb5, 0x58, 0x16, 0x88, 0xcd, 0x5c, 0xfd, 0x23}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xdf, 0x5b, 0xdf, 0xbb, 0xb4, 0x7c, 0xd2, 0x3b, 0x95, 0xe5, 0xa4, 0x45}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x85, 0xfd, 0xdf, 0xa7, 0x9c, 0x2b, 0xf6, 0x9c, 0xa2, 0x89, 0x16, + 0xbb, 0x49, 0xb, 0xe9, 0x1a, 0x2d, 0xcc, 0x50, 0xa9, 0xe9}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x8, 0x3f, 0xb9, 0x6f, 0x87, 0xb0, 0xc3, + 0xad, 0x17, 0xa1, 0x9c, 0x27, 0x80, 0x4d}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x36, 0x81, 0xf7, 0x2, 0xfb, 0x48, 0x36}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x23, 0x60, 0xe1, 0x96, 0x2d, 0x65, 0x7e, 0xbd, 0xb3, 0x63, 0xd4, 0x51, 0x76, + 0xe2, 0x55, 0xab, 0x71, 0xc9, 0xf4, 0xba, 0x69, 0xdb, 0xa9, 0xea, 0x9, 0xaf}; + lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x0, 0x88, 0x18, 0x4f, 0xf, 0x7f, 0x13, 0x16, 0xa2, + 0x86, 0xb0, 0xf1, 0xbe, 0x65, 0x62, 0xd2, 0x9b}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x81, 0x3e}; + lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x34, 0xf1, 0x7b, 0x87, 0x29, 0xb1, 0x9c, 0xb6, + 0x12, 0x7c, 0xba, 0x27, 0x3f, 0xa1, 0xe0, 0x33}; + uint8_t bytesprops2[] = {0x50, 0x7e, 0xfe, 0x9b, 0x97, 0xc2}; + uint8_t bytesprops1[] = {0x3d, 0x47, 0x93, 0x88, 0x3, 0xa9, 0x5f, 0x1, 0xe8, 0x8f, 0xc5, 0xda, + 0xbf, 0x13, 0x64, 0xee, 0x45, 0x9d, 0xb, 0x37, 0x3, 0x6c, 0x50}; + uint8_t bytesprops3[] = {0xaa, 0xac, 0xb5, 0x3a, 0xb2, 0xe4, 0xff, 0x49, 0x8, 0x9f, + 0x93, 0xac, 0x3, 0x89, 0x27, 0x23, 0xd7, 0x61, 0x90}; + uint8_t bytesprops4[] = {0x76, 0xb7, 0x8, 0x8e, 0xc3, 0xf4, 0xf0, 0x82, 0xa1, 0xfe, 0x36, 0x78, 0x1c, 0x4a}; + uint8_t bytesprops5[] = {0xeb, 0x54, 0x7d, 0x18}; + uint8_t bytesprops7[] = {0xed, 0xa, 0x9e, 0x4f, 0x43, 0xb6, 0xb2, 0xf2, 0xff, 0xee, 0xb3, 0xf8, 0x7, 0xfd}; + uint8_t bytesprops6[] = {0x4b, 0xf9, 0x12, 0x7c}; + uint8_t bytesprops8[] = {0x14, 0xc, 0xa0, 0xd7, 0xc0, 0x59, 0x70, 0x3b, 0xdd, 0xac, 0x5, 0x48, 0x66, 0x5e, + 0xb9, 0x75, 0xcf, 0x30, 0x19, 0xcb, 0x85, 0x21, 0x6, 0x73, 0x5f, 0xd6, 0x71}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5495}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 605}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15712}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1894}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13651}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops6}, .v = {14, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25076}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, + }; + + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16617, 9, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 4070 [("\v\136/\233\EOT\FS\240\255\227\DC3q9\SI\SOH\\",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\170\176\237\215\202\131\&2\ESCK\136h\184\178\226\178}.\242",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropMessageExpiryInterval +// 23503,PropSessionExpiryInterval 6089,PropMaximumPacketSize 7148,PropUserProperty "[\DC2\234\153\CAN'\ETX\152d\186" +// "\208\na\201\165\173p\232",PropAuthenticationData "\240h5\143\128\179:\131|\140Z",PropMessageExpiryInterval +// 23070,PropWillDelayInterval 1219,PropSubscriptionIdentifierAvailable 72,PropWillDelayInterval +// 20808,PropCorrelationData "U\rh\144",PropServerKeepAlive 3568,PropRequestResponseInformation +// 236,PropPayloadFormatIndicator 46,PropMessageExpiryInterval 14380,PropWildcardSubscriptionAvailable +// 95,PropAuthenticationData "\137\189l\153\160\233\ETX\237\r"] +TEST(Subscribe5QCTest, Encode6) { + uint8_t pkt[] = {0x82, 0x90, 0x1, 0xf, 0xe6, 0x66, 0x2, 0x0, 0x0, 0x5b, 0xcf, 0x11, 0x0, 0x0, 0x17, 0xc9, 0x27, + 0x0, 0x0, 0x1b, 0xec, 0x26, 0x0, 0xa, 0x5b, 0x12, 0xea, 0x99, 0x18, 0x27, 0x3, 0x98, 0x64, 0xba, + 0x0, 0x8, 0xd0, 0xa, 0x61, 0xc9, 0xa5, 0xad, 0x70, 0xe8, 0x16, 0x0, 0xb, 0xf0, 0x68, 0x35, 0x8f, + 0x80, 0xb3, 0x3a, 0x83, 0x7c, 0x8c, 0x5a, 0x2, 0x0, 0x0, 0x5a, 0x1e, 0x18, 0x0, 0x0, 0x4, 0xc3, + 0x29, 0x48, 0x18, 0x0, 0x0, 0x51, 0x48, 0x9, 0x0, 0x4, 0x55, 0xd, 0x68, 0x90, 0x13, 0xd, 0xf0, + 0x19, 0xec, 0x1, 0x2e, 0x2, 0x0, 0x0, 0x38, 0x2c, 0x28, 0x5f, 0x16, 0x0, 0x9, 0x89, 0xbd, 0x6c, + 0x99, 0xa0, 0xe9, 0x3, 0xed, 0xd, 0x0, 0xf, 0xb, 0x88, 0x2f, 0xe9, 0x4, 0x1c, 0xf0, 0xff, 0xe3, + 0x13, 0x71, 0x39, 0xf, 0x1, 0x5c, 0x1, 0x0, 0x12, 0xaa, 0xb0, 0xed, 0xd7, 0xca, 0x83, 0x32, 0x1b, + 0x4b, 0x88, 0x68, 0xb8, 0xb2, 0xe2, 0xb2, 0x7d, 0x2e, 0xf2, 0x0}; + + uint8_t buf[157] = {0}; + + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xb, 0x88, 0x2f, 0xe9, 0x4, 0x1c, 0xf0, 0xff, + 0xe3, 0x13, 0x71, 0x39, 0xf, 0x1, 0x5c}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xaa, 0xb0, 0xed, 0xd7, 0xca, 0x83, 0x32, 0x1b, 0x4b, + 0x88, 0x68, 0xb8, 0xb2, 0xe2, 0xb2, 0x7d, 0x2e, 0xf2}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0}; + uint8_t bytesprops1[] = {0xd0, 0xa, 0x61, 0xc9, 0xa5, 0xad, 0x70, 0xe8}; + uint8_t bytesprops0[] = {0x5b, 0x12, 0xea, 0x99, 0x18, 0x27, 0x3, 0x98, 0x64, 0xba}; + uint8_t bytesprops2[] = {0xf0, 0x68, 0x35, 0x8f, 0x80, 0xb3, 0x3a, 0x83, 0x7c, 0x8c, 0x5a}; + uint8_t bytesprops3[] = {0x55, 0xd, 0x68, 0x90}; + uint8_t bytesprops4[] = {0x89, 0xbd, 0x6c, 0x99, 0xa0, 0xe9, 0x3, 0xed, 0xd}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23503}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6089}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7148}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23070}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1219}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20808}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3568}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14380}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops4}}}, + }; -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\206\166\&9}z\170\226\207\169\157\f{\160_\198\DEL\151\NAK'|\145", _pubPktID = 0, _pubBody = "\178\190\186$\148^\SO -// Y\222\245\255\204\180\166\231cl\175A\164x\152\234W\209\251\249\n`", _pubProps = [PropAuthenticationMethod -// "\SYN\201\191\145\165\203",PropContentType -// "4n\152\243)\215\212\204\149\175\DLE\204*}\186\210\NUL\193qY\206\&1L?}>\DC2\216",PropUserProperty "n\227OB\139 -// \195+\a\186F\159C\DC1.H\f\209\168o\252\160O\SUB\220qg\246" -// "\239\DC2F\134\174;\166\144v(pO\252\128\243",PropMaximumPacketSize 19354,PropContentType -// "\141",PropAuthenticationMethod -// "\149(\DELw\\\208\192\232^\232\240\190P\SYN]Y$\179\186\199M!\206\176",PropSubscriptionIdentifierAvailable -// 68,PropResponseTopic "\184\225,\172/G\234u\159[k\232\DLE\169\ne\DC4A\153\246\DLE",PropTopicAlias -// 14033,PropResponseInformation "m11\187\NULN\199^\192CO\237",PropMaximumPacketSize 5887,PropAuthenticationMethod -// "{\143\167\a\180\212\198\230\242\214\254|\222dj\f{\219\140\238x8\150",PropSharedSubscriptionAvailable -// 71,PropWildcardSubscriptionAvailable 139,PropSessionExpiryInterval 24881,PropRequestResponseInformation -// 105,PropMaximumQoS 233,PropWillDelayInterval 32182,PropSessionExpiryInterval 15444,PropAuthenticationMethod -// "\141\RS$",PropWildcardSubscriptionAvailable 69,PropWillDelayInterval 18160,PropReceiveMaximum -// 7546,PropAuthenticationMethod "\215\138g\131\227",PropRequestProblemInformation 32,PropAuthenticationMethod -// "\220\GS\249,~\206NI22b^4S\240\254\137\155\DEL\EOT2\196\SOG\129\149",PropTopicAlias 29532,PropServerReference -// "\194"]} -TEST(Publish5QCTest, Encode18) { + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4070, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 1318 [("\141",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("(\232l\147\231\ETB\129\188\&6\207\SO\182\244\225\193S\228\&7\179\DEL\220",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\241\168\NUL\143\233m\184\163\STX\218\&8\156\252\250i\184C\188B\167\197\224A",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\177s\170{`\"e\RSr\DC3\r[\215\130\150\199q\253\216\221\231;\SYN",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\254*\164\NUL.\198\237\227\&3\143\SUB\248\248\162\t\167\n\146\232\250AK\234\220\178f\205\210\226",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\159}A_\221B\190\143\&5\n\NUL\186z)\143",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\r0\DC1\n\226K\201\177\128\US:\237o\241I\186d|",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Q\EM\214h\"_\196\253z\ACK\211F7\211D\144\NUL",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(")\213\149\ACK",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropContentType +// "\130\ENQm\151\150mh\225Hc\184\187\247",PropResponseTopic "S51\GS\134\178\187V@\221",PropResponseInformation +// "\204\196\n$a-\EOT\243\SYNJ\190",PropAuthenticationMethod +// "j\131\232\175\144\213p2\166\179\218\167\130\153\195\242\204J\142Ti\179pM\164",PropAuthenticationData +// "\143\NUL\253\152\190\179\v\184\n\143\&9\170\162\138\230\a\254",PropTopicAlias 25408,PropSharedSubscriptionAvailable +// 253,PropTopicAlias 9479,PropSessionExpiryInterval 28451,PropWildcardSubscriptionAvailable 200,PropResponseInformation +// "\161\165\SO\189\173\EOT\175\&4\\jwc\177\193\SYNJ\186\235\223(#v",PropSessionExpiryInterval +// 14824,PropMaximumPacketSize 4374,PropSubscriptionIdentifier 12,PropMaximumPacketSize 2638,PropMaximumQoS +// 100,PropCorrelationData "\249\&3\\\211\147",PropRequestResponseInformation 8,PropReasonString +// "#",PropWildcardSubscriptionAvailable 248,PropPayloadFormatIndicator 146,PropAuthenticationMethod +// "\218`\167",PropRequestProblemInformation 80,PropAuthenticationMethod +// "o\170\235\155\200^(\171(\SYN\216\214\b\227\163DV\211\163",PropMessageExpiryInterval 17106,PropAuthenticationData +// "v\253\DC2\198\a\EMO\188\176\213\FS\159\202\RS\b\248g\170\243\234\140\DC4\v\EOTb\242\205\135\&0\141",PropReasonString +// "\DC4\154\ENQ\239\170\178\203\153U\208\153\DLE\230\146\226$\178\NUL\"\198;9\175MY\150\211Im",PropMessageExpiryInterval +// 21474,PropReasonString "A^\155er\157"] +TEST(Subscribe5QCTest, Encode7) {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0, 0xc, 0x6d, 0x31, 0x31, 0xbb, 0x0, 0x4e, - 0xc7, 0x5e, 0xc0, 0x43, 0x4f, 0xed, 0x27, 0x0, 0x0, 0x16, 0xff, 0x15, 0x0, 0x17, 0x7b, 0x8f, 0xa7, 0x7, 0xb4, - 0xd4, 0xc6, 0xe6, 0xf2, 0xd6, 0xfe, 0x7c, 0xde, 0x64, 0x6a, 0xc, 0x7b, 0xdb, 0x8c, 0xee, 0x78, 0x38, 0x96, 0x2a, - 0x47, 0x28, 0x8b, 0x11, 0x0, 0x0, 0x61, 0x31, 0x19, 0x69, 0x24, 0xe9, 0x18, 0x0, 0x0, 0x7d, 0xb6, 0x11, 0x0, - 0x0, 0x3c, 0x54, 0x15, 0x0, 0x3, 0x8d, 0x1e, 0x24, 0x28, 0x45, 0x18, 0x0, 0x0, 0x46, 0xf0, 0x21, 0x1d, 0x7a, - 0x15, 0x0, 0x5, 0xd7, 0x8a, 0x67, 0x83, 0xe3, 0x17, 0x20, 0x15, 0x0, 0x1a, 0xdc, 0x1d, 0xf9, 0x2c, 0x7e, 0xce, - 0x4e, 0x49, 0x32, 0x32, 0x62, 0x5e, 0x34, 0x53, 0xf0, 0xfe, 0x89, 0x9b, 0x7f, 0x4, 0x32, 0xc4, 0xe, 0x47, 0x81, - 0x95, 0x23, 0x73, 0x5c, 0x1c, 0x0, 0x1, 0xc2, 0xb2, 0xbe, 0xba, 0x24, 0x94, 0x5e, 0xe, 0x20, 0x59, 0xde, 0xf5, - 0xff, 0xcc, 0xb4, 0xa6, 0xe7, 0x63, 0x6c, 0xaf, 0x41, 0xa4, 0x78, 0x98, 0xea, 0x57, 0xd1, 0xfb, 0xf9, 0xa, 0x60}; - - uint8_t buf[352] = {0}; - - uint8_t topic_bytes[] = {0xce, 0xa6, 0x39, 0x7d, 0x7a, 0xaa, 0xe2, 0xcf, 0xa9, 0x9d, 0xc, - 0x7b, 0xa0, 0x5f, 0xc6, 0x7f, 0x97, 0x15, 0x27, 0x7c, 0x91}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xb2, 0xbe, 0xba, 0x24, 0x94, 0x5e, 0xe, 0x20, 0x59, 0xde, 0xf5, 0xff, 0xcc, 0xb4, 0xa6, - 0xe7, 0x63, 0x6c, 0xaf, 0x41, 0xa4, 0x78, 0x98, 0xea, 0x57, 0xd1, 0xfb, 0xf9, 0xa, 0x60}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; - - uint8_t bytesprops0[] = {0x16, 0xc9, 0xbf, 0x91, 0xa5, 0xcb}; - uint8_t bytesprops1[] = {0x34, 0x6e, 0x98, 0xf3, 0x29, 0xd7, 0xd4, 0xcc, 0x95, 0xaf, 0x10, 0xcc, 0x2a, 0x7d, - 0xba, 0xd2, 0x0, 0xc1, 0x71, 0x59, 0xce, 0x31, 0x4c, 0x3f, 0x7d, 0x3e, 0x12, 0xd8}; - uint8_t bytesprops3[] = {0xef, 0x12, 0x46, 0x86, 0xae, 0x3b, 0xa6, 0x90, 0x76, 0x28, 0x70, 0x4f, 0xfc, 0x80, 0xf3}; - uint8_t bytesprops2[] = {0x6e, 0xe3, 0x4f, 0x42, 0x8b, 0x20, 0xc3, 0x2b, 0x7, 0xba, 0x46, 0x9f, 0x43, 0x11, - 0x2e, 0x48, 0xc, 0xd1, 0xa8, 0x6f, 0xfc, 0xa0, 0x4f, 0x1a, 0xdc, 0x71, 0x67, 0xf6}; - uint8_t bytesprops4[] = {0x8d}; - uint8_t bytesprops5[] = {0x95, 0x28, 0x7f, 0x77, 0x5c, 0xd0, 0xc0, 0xe8, 0x5e, 0xe8, 0xf0, 0xbe, - 0x50, 0x16, 0x5d, 0x59, 0x24, 0xb3, 0xba, 0xc7, 0x4d, 0x21, 0xce, 0xb0}; - uint8_t bytesprops6[] = {0xb8, 0xe1, 0x2c, 0xac, 0x2f, 0x47, 0xea, 0x75, 0x9f, 0x5b, 0x6b, - 0xe8, 0x10, 0xa9, 0xa, 0x65, 0x14, 0x41, 0x99, 0xf6, 0x10}; - uint8_t bytesprops7[] = {0x6d, 0x31, 0x31, 0xbb, 0x0, 0x4e, 0xc7, 0x5e, 0xc0, 0x43, 0x4f, 0xed}; - uint8_t bytesprops8[] = {0x7b, 0x8f, 0xa7, 0x7, 0xb4, 0xd4, 0xc6, 0xe6, 0xf2, 0xd6, 0xfe, 0x7c, - 0xde, 0x64, 0x6a, 0xc, 0x7b, 0xdb, 0x8c, 0xee, 0x78, 0x38, 0x96}; - uint8_t bytesprops9[] = {0x8d, 0x1e, 0x24}; - uint8_t bytesprops10[] = {0xd7, 0x8a, 0x67, 0x83, 0xe3}; - uint8_t bytesprops11[] = {0xdc, 0x1d, 0xf9, 0x2c, 0x7e, 0xce, 0x4e, 0x49, 0x32, 0x32, 0x62, 0x5e, 0x34, - 0x53, 0xf0, 0xfe, 0x89, 0x9b, 0x7f, 0x4, 0x32, 0xc4, 0xe, 0x47, 0x81, 0x95}; - uint8_t bytesprops12[] = {0xc2}; + 0x82, 0xd0, 0x3, 0x5, 0x26, 0x9a, 0x2, 0x3, 0x0, 0xd, 0x82, 0x5, 0x6d, 0x97, 0x96, 0x6d, 0x68, 0xe1, 0x48, + 0x63, 0xb8, 0xbb, 0xf7, 0x8, 0x0, 0xa, 0x53, 0x35, 0x31, 0x1d, 0x86, 0xb2, 0xbb, 0x56, 0x40, 0xdd, 0x1a, 0x0, + 0xb, 0xcc, 0xc4, 0xa, 0x24, 0x61, 0x2d, 0x4, 0xf3, 0x16, 0x4a, 0xbe, 0x15, 0x0, 0x19, 0x6a, 0x83, 0xe8, 0xaf, + 0x90, 0xd5, 0x70, 0x32, 0xa6, 0xb3, 0xda, 0xa7, 0x82, 0x99, 0xc3, 0xf2, 0xcc, 0x4a, 0x8e, 0x54, 0x69, 0xb3, 0x70, + 0x4d, 0xa4, 0x16, 0x0, 0x11, 0x8f, 0x0, 0xfd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3, + 0x44, 0x90, 0x0, 0x1, 0x0, 0x4, 0x29, 0xd5, 0x95, 0x6, 0x2}; + + uint8_t buf[477] = {0}; + + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x8d}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x28, 0xe8, 0x6c, 0x93, 0xe7, 0x17, 0x81, 0xbc, 0x36, 0xcf, 0xe, + 0xb6, 0xf4, 0xe1, 0xc1, 0x53, 0xe4, 0x37, 0xb3, 0x7f, 0xdc}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf1, 0xa8, 0x0, 0x8f, 0xe9, 0x6d, 0xb8, 0xa3, 0x2, 0xda, 0x38, 0x9c, + 0xfc, 0xfa, 0x69, 0xb8, 0x43, 0xbc, 0x42, 0xa7, 0xc5, 0xe0, 0x41}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb1, 0x73, 0xaa, 0x7b, 0x60, 0x22, 0x65, 0x1e, 0x72, 0x13, 0xd, 0x5b, + 0xd7, 0x82, 0x96, 0xc7, 0x71, 0xfd, 0xd8, 0xdd, 0xe7, 0x3b, 0x16}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xfe, 0x2a, 0xa4, 0x0, 0x2e, 0xc6, 0xed, 0xe3, 0x33, 0x8f, + 0x1a, 0xf8, 0xf8, 0xa2, 0x9, 0xa7, 0xa, 0x92, 0xe8, 0xfa, + 0x41, 0x4b, 0xea, 0xdc, 0xb2, 0x66, 0xcd, 0xd2, 0xe2}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x9f, 0x7d, 0x41, 0x5f, 0xdd, 0x42, 0xbe, 0x8f, + 0x35, 0xa, 0x0, 0xba, 0x7a, 0x29, 0x8f}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xd, 0x30, 0x11, 0xa, 0xe2, 0x4b, 0xc9, 0xb1, 0x80, + 0x1f, 0x3a, 0xed, 0x6f, 0xf1, 0x49, 0xba, 0x64, 0x7c}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x51, 0x19, 0xd6, 0x68, 0x22, 0x5f, 0xc4, 0xfd, 0x7a, + 0x6, 0xd3, 0x46, 0x37, 0xd3, 0x44, 0x90, 0x0}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x29, 0xd5, 0x95, 0x6}; + lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x82, 0x5, 0x6d, 0x97, 0x96, 0x6d, 0x68, 0xe1, 0x48, 0x63, 0xb8, 0xbb, 0xf7}; + uint8_t bytesprops1[] = {0x53, 0x35, 0x31, 0x1d, 0x86, 0xb2, 0xbb, 0x56, 0x40, 0xdd}; + uint8_t bytesprops2[] = {0xcc, 0xc4, 0xa, 0x24, 0x61, 0x2d, 0x4, 0xf3, 0x16, 0x4a, 0xbe}; + uint8_t bytesprops3[] = {0x6a, 0x83, 0xe8, 0xaf, 0x90, 0xd5, 0x70, 0x32, 0xa6, 0xb3, 0xda, 0xa7, 0x82, + 0x99, 0xc3, 0xf2, 0xcc, 0x4a, 0x8e, 0x54, 0x69, 0xb3, 0x70, 0x4d, 0xa4}; + uint8_t bytesprops4[] = {0x8f, 0x0, 0xfd, 0x98, 0xbe, 0xb3, 0xb, 0xb8, 0xa, + 0x8f, 0x39, 0xaa, 0xa2, 0x8a, 0xe6, 0x7, 0xfe}; + uint8_t bytesprops5[] = {0xa1, 0xa5, 0xe, 0xbd, 0xad, 0x4, 0xaf, 0x34, 0x5c, 0x6a, 0x77, + 0x63, 0xb1, 0xc1, 0x16, 0x4a, 0xba, 0xeb, 0xdf, 0x28, 0x23, 0x76}; + uint8_t bytesprops6[] = {0xf9, 0x33, 0x5c, 0xd3, 0x93}; + uint8_t bytesprops7[] = {0x23}; + uint8_t bytesprops8[] = {0xda, 0x60, 0xa7}; + uint8_t bytesprops9[] = {0x6f, 0xaa, 0xeb, 0x9b, 0xc8, 0x5e, 0x28, 0xab, 0x28, 0x16, + 0xd8, 0xd6, 0x8, 0xe3, 0xa3, 0x44, 0x56, 0xd3, 0xa3}; + uint8_t bytesprops10[] = {0x76, 0xfd, 0x12, 0xc6, 0x7, 0x19, 0x4f, 0xbc, 0xb0, 0xd5, 0x1c, 0x9f, 0xca, 0x1e, 0x8, + 0xf8, 0x67, 0xaa, 0xf3, 0xea, 0x8c, 0x14, 0xb, 0x4, 0x62, 0xf2, 0xcd, 0x87, 0x30, 0x8d}; + uint8_t bytesprops11[] = {0x14, 0x9a, 0x5, 0xef, 0xaa, 0xb2, 0xcb, 0x99, 0x55, 0xd0, 0x99, 0x10, 0xe6, 0x92, 0xe2, + 0x24, 0xb2, 0x0, 0x22, 0xc6, 0x3b, 0x39, 0xaf, 0x4d, 0x59, 0x96, 0xd3, 0x49, 0x6d}; + uint8_t bytesprops12[] = {0x41, 0x5e, 0x9b, 0x65, 0x72, 0x9d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops2}, .v = {15, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19354}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14033}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5887}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24881}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32182}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15444}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18160}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7546}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29532}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25408}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9479}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28451}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14824}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4374}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2638}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17106}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21474}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops12}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1318, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\225\242\168", _pubPktID = 30037, -// _pubBody = "\216-7\221q<\RS\"U\210-\130\232\161\248)\248\169\151", _pubProps = [PropRetainAvailable -// 149,PropMaximumQoS 109,PropResponseInformation "\191\207\DLE",PropMessageExpiryInterval -// 32121,PropWildcardSubscriptionAvailable 88,PropResponseTopic -// "\215\FS\"\249\139\186\219\220|\184\230N8'\225()\ESC\193"]} -TEST(Publish5QCTest, Encode19) { - uint8_t pkt[] = {0x3a, 0x42, 0x0, 0x3, 0xe1, 0xf2, 0xa8, 0x75, 0x55, 0x27, 0x25, 0x95, 0x24, 0x6d, - 0x1a, 0x0, 0x3, 0xbf, 0xcf, 0x10, 0x2, 0x0, 0x0, 0x7d, 0x79, 0x28, 0x58, 0x8, - 0x0, 0x13, 0xd7, 0x1c, 0x22, 0xf9, 0x8b, 0xba, 0xdb, 0xdc, 0x7c, 0xb8, 0xe6, 0x4e, - 0x38, 0x27, 0xe1, 0x28, 0x29, 0x1b, 0xc1, 0xd8, 0x2d, 0x37, 0xdd, 0x71, 0x3c, 0x1e, - 0x22, 0x55, 0xd2, 0x2d, 0x82, 0xe8, 0xa1, 0xf8, 0x29, 0xf8, 0xa9, 0x97}; - - uint8_t buf[78] = {0}; +// SubscribeRequest 4255 +// [("\180\179\158\152\140\184\134\243\150\253\DELV\188\SIa\US\207\DEL\234C\tl\186p*M\209\246\162",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("/\140^\ESC#\181^Ia%o\229mJ\166XA\DELA\183l;S_l\133^",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\159\&8\162\SYN\188\181",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\253\&9-\SOH\n\189\207\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [PropServerKeepAlive 10210,PropServerReference "",PropAuthenticationMethod +// "\210A\184>i:\DC3X\235\203\ESC\ESC]\SO\254\a\249\137\150\195[\176\136D\161\254u~",PropServerReference +// "\234\166'\198\222\235\EM\232\216\167\174\156\&4\182b7\r2\ETB\\\231JPj\DC4\ACK\194K",PropResponseTopic +// "\131L\NAK\157\240)\SI\FS\241\234\184\146m",PropSharedSubscriptionAvailable 213,PropRequestResponseInformation +// 75,PropAuthenticationMethod "\USjH\219\193\175",PropReceiveMaximum 4502,PropSubscriptionIdentifier 20,PropTopicAlias +// 4861,PropCorrelationData "\226=\243Q\226\154\204/`0",PropResponseInformation "<\195u",PropSharedSubscriptionAvailable +// 229,PropSubscriptionIdentifierAvailable 37,PropSubscriptionIdentifierAvailable 148,PropAuthenticationMethod +// "\145r.\DC4\164\219\&4\133\170\150\NUL",PropSessionExpiryInterval 1927,PropTopicAliasMaximum 12840,PropResponseTopic +// "\251$4\141ye\202\216",PropReceiveMaximum 29338,PropSubscriptionIdentifierAvailable 0,PropSessionExpiryInterval +// 9070,PropRetainAvailable 159,PropCorrelationData "\US\251\187R{\203\133B\146\206"] +TEST(Subscribe5QCTest, Encode8) { + uint8_t pkt[] = { + 0x82, 0x92, 0x2, 0x10, 0x9f, 0xbc, 0x1, 0x13, 0x27, 0xe2, 0x1c, 0x0, 0x0, 0x15, 0x0, 0x1c, 0xd2, 0x41, 0xb8, + 0x3e, 0x69, 0x3a, 0x13, 0x58, 0xeb, 0xcb, 0x1b, 0x1b, 0x5d, 0xe, 0xfe, 0x7, 0xf9, 0x89, 0x96, 0xc3, 0x5b, 0xb0, + 0x88, 0x44, 0xa1, 0xfe, 0x75, 0x7e, 0x1c, 0x0, 0x1c, 0xea, 0xa6, 0x27, 0xc6, 0xde, 0xeb, 0x19, 0xe8, 0xd8, 0xa7, + 0xae, 0x9c, 0x34, 0xb6, 0x62, 0x37, 0xd, 0x32, 0x17, 0x5c, 0xe7, 0x4a, 0x50, 0x6a, 0x14, 0x6, 0xc2, 0x4b, 0x8, + 0x0, 0xd, 0x83, 0x4c, 0x15, 0x9d, 0xf0, 0x29, 0xf, 0x1c, 0xf1, 0xea, 0xb8, 0x92, 0x6d, 0x2a, 0xd5, 0x19, 0x4b, + 0x15, 0x0, 0x6, 0x1f, 0x6a, 0x48, 0xdb, 0xc1, 0xaf, 0x21, 0x11, 0x96, 0xb, 0x14, 0x23, 0x12, 0xfd, 0x9, 0x0, + 0xa, 0xe2, 0x3d, 0xf3, 0x51, 0xe2, 0x9a, 0xcc, 0x2f, 0x60, 0x30, 0x1a, 0x0, 0x3, 0x3c, 0xc3, 0x75, 0x2a, 0xe5, + 0x29, 0x25, 0x29, 0x94, 0x15, 0x0, 0xb, 0x91, 0x72, 0x2e, 0x14, 0xa4, 0xdb, 0x34, 0x85, 0xaa, 0x96, 0x0, 0x11, + 0x0, 0x0, 0x7, 0x87, 0x22, 0x32, 0x28, 0x8, 0x0, 0x8, 0xfb, 0x24, 0x34, 0x8d, 0x79, 0x65, 0xca, 0xd8, 0x21, + 0x72, 0x9a, 0x29, 0x0, 0x11, 0x0, 0x0, 0x23, 0x6e, 0x25, 0x9f, 0x9, 0x0, 0xa, 0x1f, 0xfb, 0xbb, 0x52, 0x7b, + 0xcb, 0x85, 0x42, 0x92, 0xce, 0x0, 0x1d, 0xb4, 0xb3, 0x9e, 0x98, 0x8c, 0xb8, 0x86, 0xf3, 0x96, 0xfd, 0x7f, 0x56, + 0xbc, 0xf, 0x61, 0x1f, 0xcf, 0x7f, 0xea, 0x43, 0x9, 0x6c, 0xba, 0x70, 0x2a, 0x4d, 0xd1, 0xf6, 0xa2, 0x0, 0x0, + 0x1b, 0x2f, 0x8c, 0x5e, 0x1b, 0x23, 0xb5, 0x5e, 0x49, 0x61, 0x25, 0x6f, 0xe5, 0x6d, 0x4a, 0xa6, 0x58, 0x41, 0x7f, + 0x41, 0xb7, 0x6c, 0x3b, 0x53, 0x5f, 0x6c, 0x85, 0x5e, 0x0, 0x0, 0x6, 0x9f, 0x38, 0xa2, 0x16, 0xbc, 0xb5, 0x1, + 0x0, 0x8, 0xfd, 0x39, 0x2d, 0x1, 0xa, 0xbd, 0xcf, 0xdb, 0x1}; - uint8_t topic_bytes[] = {0xe1, 0xf2, 0xa8}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xd8, 0x2d, 0x37, 0xdd, 0x71, 0x3c, 0x1e, 0x22, 0x55, 0xd2, - 0x2d, 0x82, 0xe8, 0xa1, 0xf8, 0x29, 0xf8, 0xa9, 0x97}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + uint8_t buf[287] = {0}; - uint8_t bytesprops0[] = {0xbf, 0xcf, 0x10}; - uint8_t bytesprops1[] = {0xd7, 0x1c, 0x22, 0xf9, 0x8b, 0xba, 0xdb, 0xdc, 0x7c, 0xb8, - 0xe6, 0x4e, 0x38, 0x27, 0xe1, 0x28, 0x29, 0x1b, 0xc1}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xb4, 0xb3, 0x9e, 0x98, 0x8c, 0xb8, 0x86, 0xf3, 0x96, 0xfd, + 0x7f, 0x56, 0xbc, 0xf, 0x61, 0x1f, 0xcf, 0x7f, 0xea, 0x43, + 0x9, 0x6c, 0xba, 0x70, 0x2a, 0x4d, 0xd1, 0xf6, 0xa2}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2f, 0x8c, 0x5e, 0x1b, 0x23, 0xb5, 0x5e, 0x49, 0x61, 0x25, 0x6f, 0xe5, 0x6d, 0x4a, + 0xa6, 0x58, 0x41, 0x7f, 0x41, 0xb7, 0x6c, 0x3b, 0x53, 0x5f, 0x6c, 0x85, 0x5e}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x9f, 0x38, 0xa2, 0x16, 0xbc, 0xb5}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xfd, 0x39, 0x2d, 0x1, 0xa, 0xbd, 0xcf, 0xdb}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xd2, 0x41, 0xb8, 0x3e, 0x69, 0x3a, 0x13, 0x58, 0xeb, 0xcb, 0x1b, 0x1b, 0x5d, 0xe, + 0xfe, 0x7, 0xf9, 0x89, 0x96, 0xc3, 0x5b, 0xb0, 0x88, 0x44, 0xa1, 0xfe, 0x75, 0x7e}; + uint8_t bytesprops2[] = {0xea, 0xa6, 0x27, 0xc6, 0xde, 0xeb, 0x19, 0xe8, 0xd8, 0xa7, 0xae, 0x9c, 0x34, 0xb6, + 0x62, 0x37, 0xd, 0x32, 0x17, 0x5c, 0xe7, 0x4a, 0x50, 0x6a, 0x14, 0x6, 0xc2, 0x4b}; + uint8_t bytesprops3[] = {0x83, 0x4c, 0x15, 0x9d, 0xf0, 0x29, 0xf, 0x1c, 0xf1, 0xea, 0xb8, 0x92, 0x6d}; + uint8_t bytesprops4[] = {0x1f, 0x6a, 0x48, 0xdb, 0xc1, 0xaf}; + uint8_t bytesprops5[] = {0xe2, 0x3d, 0xf3, 0x51, 0xe2, 0x9a, 0xcc, 0x2f, 0x60, 0x30}; + uint8_t bytesprops6[] = {0x3c, 0xc3, 0x75}; + uint8_t bytesprops7[] = {0x91, 0x72, 0x2e, 0x14, 0xa4, 0xdb, 0x34, 0x85, 0xaa, 0x96, 0x0}; + uint8_t bytesprops8[] = {0xfb, 0x24, 0x34, 0x8d, 0x79, 0x65, 0xca, 0xd8}; + uint8_t bytesprops9[] = {0x1f, 0xfb, 0xbb, 0x52, 0x7b, 0xcb, 0x85, 0x42, 0x92, 0xce}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32121}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10210}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4502}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4861}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1927}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12840}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29338}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9070}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 30037, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4255, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 8790 [("BZ_)",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\244x\187\186\255\245oy\163<\181\242J3\202-",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("'8\171[\231\210\133\201\GSP\238\199\163'\182bO@\226\RS?\SO@\244uRA\SI2",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("W\239\192\&2\217\184?\141\&7\FSL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\200h\214",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\187\DC2\tI\174\251I\ETB\FS\NAK\148\DC4\136Je\193|\216V)j",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropResponseTopic "\"k\179G\190w1\150\208\185\FS\155S\250i\146\220\EMR",PropAuthenticationMethod +// "w\199\142\212\ACK$\129l\156\143\206\245\134r\144o\176\204\228\169",PropReceiveMaximum +// 28238,PropPayloadFormatIndicator 218,PropAuthenticationMethod "\172\160\143\182\169q\221",PropTopicAlias +// 7951,PropServerReference +// "\168\160*\DC3\152=L|\151\136A\f\ESCz\153NKJ!\133W\178H\241\167\174",PropSubscriptionIdentifierAvailable +// 83,PropCorrelationData "",PropWildcardSubscriptionAvailable 184,PropWillDelayInterval +// 30166,PropPayloadFormatIndicator 91,PropAssignedClientIdentifier +// "\162@\168\DC3\137#\DC1\136`I\183",PropWildcardSubscriptionAvailable 60,PropResponseInformation +// "`<\231\128f\183i\149bUp\EMt\\ \147W\222\220\234\aYq>\217\192\159\161",PropReceiveMaximum +// 8969,PropRequestProblemInformation 202,PropUserProperty "\r\128\DLE\254ts\\3\US\CAN\197\196\241\200" +// "l\RS\145\143,\147\224\245\ESCT\CAN\174\DC2k7\r\SOH\146\247\173\DC3\221-",PropCorrelationData +// "\r\DC3\233\240s\DC2\227\ETBf\RS\142\"\189\161\173\226\&1T\173\199\138\171\243\217\179\213\206",PropUserProperty +// "\192-\SI9\243t\224\&7\130\156{\222\144\179\247\199JZT\176" "\149",PropTopicAlias 26691,PropAssignedClientIdentifier +// "\218u\205H9pV%\142\163M\NUL\233\129\184\139*\138jk!\ESC\192a",PropWillDelayInterval 24054,PropWillDelayInterval +// 8523,PropAuthenticationData "\145\GS\RS\238\DC4\228t\243\225\217\v\f",PropAuthenticationData +// "?\239\197\219mF[\215.\228\236\158\250\NAKT~\SOH&\235\159\DC3"] +TEST(Subscribe5QCTest, Encode9) { + uint8_t pkt[] = { + 0x82, 0xb9, 0x3, 0x22, 0x56, 0xcf, 0x2, 0x8, 0x0, 0x13, 0x22, 0x6b, 0xb3, 0x47, 0xbe, 0x77, 0x31, 0x96, 0xd0, + 0xb9, 0x1c, 0x9b, 0x53, 0xfa, 0x69, 0x92, 0xdc, 0x19, 0x52, 0x15, 0x0, 0x14, 0x77, 0xc7, 0x8e, 0xd4, 0x6, 0x24, + 0x81, 0x6c, 0x9c, 0x8f, 0xce, 0xf5, 0x86, 0x72, 0x90, 0x6f, 0xb0, 0xcc, 0xe4, 0xa9, 0x21, 0x6e, 0x4e, 0x1, 0xda, + 0x15, 0x0, 0x7, 0xac, 0xa0, 0x8f, 0xb6, 0xa9, 0x71, 0xdd, 0x23, 0x1f, 0xf, 0x1c, 0x0, 0x1a, 0xa8, 0xa0, 0x2a, + 0x13, 0x98,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kt, buf, len); -} + uint8_t buf[454] = {0}; -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\209\144\244\190\138\251", _pubPktID -// = 1548, _pubBody = "", _pubProps = [PropMaximumPacketSize 10765,PropAssignedClientIdentifier -// "u\161e\154\RS?\SI\212E\NAK\ESCJ\217\172\231\247}\246#\198\231(",PropResponseInformation -// "8\190\199\r`\EM\219\&0`\162{\184\151\197\239\151\137\129",PropResponseTopic "R",PropSessionExpiryInterval -// 22783,PropMessageExpiryInterval 1022,PropCorrelationData "G\207C\USCW",PropUserProperty -// "\221\155S>r\US\202\160W\137y\208\238\195)\GS\238\144\&6" "m\184",PropSessionExpiryInterval 25105,PropCorrelationData -// "\191\vA\CAN\161S\129\255r=ER1\236\157\US\223N\221\n\176\&7_\186\194\245\234"]} -TEST(Publish5QCTest, Encode20) { - uint8_t pkt[] = {0x3c, 0x93, 0x1, 0x0, 0x6, 0xd1, 0x90, 0xf4, 0xbe, 0x8a, 0xfb, 0x6, 0xc, 0x87, 0x1, 0x27, 0x0, - 0x0, 0x2a, 0xd, 0x12, 0x0, 0x16, 0x75, 0xa1, 0x65, 0x9a, 0x1e, 0x3f, 0xf, 0xd4, 0x45, 0x15, 0x1b, - 0x4a, 0xd9, 0xac, 0xe7, 0xf7, 0x7d, 0xf6, 0x23, 0xc6, 0xe7, 0x28, 0x1a, 0x0, 0x12, 0x38, 0xbe, 0xc7, - 0xd, 0x60, 0x19, 0xdb, 0x30, 0x60, 0xa2, 0x7b, 0xb8, 0x97, 0xc5, 0xef, 0x97, 0x89, 0x81, 0x8, 0x0, - 0x1, 0x52, 0x11, 0x0, 0x0, 0x58, 0xff, 0x2, 0x0, 0x0, 0x3, 0xfe, 0x9, 0x0, 0x6, 0x47, 0xcf, - 0x43, 0x1f, 0x43, 0x57, 0x26, 0x0, 0x13, 0xdd, 0x9b, 0x53, 0x3e, 0x72, 0x1f, 0xca, 0xa0, 0x57, 0x89, - 0x79, 0xd0, 0xee, 0xc3, 0x29, 0x1d, 0xee, 0x90, 0x36, 0x0, 0x2, 0x6d, 0xb8, 0x11, 0x0, 0x0, 0x62, - 0x11, 0x9, 0x0, 0x1b, 0xbf, 0xb, 0x41, 0x18, 0xa1, 0x53, 0x81, 0xff, 0x72, 0x3d, 0x45, 0x52, 0x31, - 0xec, 0x9d, 0x1f, 0xdf, 0x4e, 0xdd, 0xa, 0xb0, 0x37, 0x5f, 0xba, 0xc2, 0xf5, 0xea}; - - uint8_t buf[160] = {0}; - - uint8_t topic_bytes[] = {0xd1, 0x90, 0xf4, 0xbe, 0x8a, 0xfb}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; - - uint8_t bytesprops0[] = {0x75, 0xa1, 0x65, 0x9a, 0x1e, 0x3f, 0xf, 0xd4, 0x45, 0x15, 0x1b, - 0x4a, 0xd9, 0xac, 0xe7, 0xf7, 0x7d, 0xf6, 0x23, 0xc6, 0xe7, 0x28}; - uint8_t bytesprops1[] = {0x38, 0xbe, 0xc7, 0xd, 0x60, 0x19, 0xdb, 0x30, 0x60, - 0xa2, 0x7b, 0xb8, 0x97, 0xc5, 0xef, 0x97, 0x89, 0x81}; - uint8_t bytesprops2[] = {0x52}; - uint8_t bytesprops3[] = {0x47, 0xcf, 0x43, 0x1f, 0x43, 0x57}; - uint8_t bytesprops5[] = {0x6d, 0xb8}; - uint8_t bytesprops4[] = {0xdd, 0x9b, 0x53, 0x3e, 0x72, 0x1f, 0xca, 0xa0, 0x57, 0x89, - 0x79, 0xd0, 0xee, 0xc3, 0x29, 0x1d, 0xee, 0x90, 0x36}; - uint8_t bytesprops6[] = {0xbf, 0xb, 0x41, 0x18, 0xa1, 0x53, 0x81, 0xff, 0x72, 0x3d, 0x45, 0x52, 0x31, 0xec, - 0x9d, 0x1f, 0xdf, 0x4e, 0xdd, 0xa, 0xb0, 0x37, 0x5f, 0xba, 0xc2, 0xf5, 0xea}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x42, 0x5a, 0x5f, 0x29}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf4, 0x78, 0xbb, 0xba, 0xff, 0xf5, 0x6f, 0x79, + 0xa3, 0x3c, 0xb5, 0xf2, 0x4a, 0x33, 0xca, 0x2d}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x27, 0x38, 0xab, 0x5b, 0xe7, 0xd2, 0x85, 0xc9, 0x1d, 0x50, + 0xee, 0xc7, 0xa3, 0x27, 0xb6, 0x62, 0x4f, 0x40, 0xe2, 0x1e, + 0x3f, 0xe, 0x40, 0xf4, 0x75, 0x52, 0x41, 0xf, 0x32}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x57, 0xef, 0xc0, 0x32, 0xd9, 0xb8, 0x3f, 0x8d, 0x37, 0x1c, 0x4c}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xc8, 0x68, 0xd6}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xbb, 0x12, 0x9, 0x49, 0xae, 0xfb, 0x49, 0x17, 0x1c, 0x15, 0x94, + 0x14, 0x88, 0x4a, 0x65, 0xc1, 0x7c, 0xd8, 0x56, 0x29, 0x6a}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x22, 0x6b, 0xb3, 0x47, 0xbe, 0x77, 0x31, 0x96, 0xd0, 0xb9, + 0x1c, 0x9b, 0x53, 0xfa, 0x69, 0x92, 0xdc, 0x19, 0x52}; + uint8_t bytesprops1[] = {0x77, 0xc7, 0x8e, 0xd4, 0x6, 0x24, 0x81, 0x6c, 0x9c, 0x8f, + 0xce, 0xf5, 0x86, 0x72, 0x90, 0x6f, 0xb0, 0xcc, 0xe4, 0xa9}; + uint8_t bytesprops2[] = {0xac, 0xa0, 0x8f, 0xb6, 0xa9, 0x71, 0xdd}; + uint8_t bytesprops3[] = {0xa8, 0xa0, 0x2a, 0x13, 0x98, 0x3d, 0x4c, 0x7c, 0x97, 0x88, 0x41, 0xc, 0x1b, + 0x7a, 0x99, 0x4e, 0x4b, 0x4a, 0x21, 0x85, 0x57, 0xb2, 0x48, 0xf1, 0xa7, 0xae}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0xa2, 0x40, 0xa8, 0x13, 0x89, 0x23, 0x11, 0x88, 0x60, 0x49, 0xb7}; + uint8_t bytesprops6[] = {0x60, 0x3c, 0xe7, 0x80, 0x66, 0xb7, 0x69, 0x95, 0x62, 0x55, 0x70, 0x19, 0x74, 0x5c, + 0x20, 0x93, 0x57, 0xde, 0xdc, 0xea, 0x7, 0x59, 0x71, 0x3e, 0xd9, 0xc0, 0x9f, 0xa1}; + uint8_t bytesprops8[] = {0x6c, 0x1e, 0x91, 0x8f, 0x2c, 0x93, 0xe0, 0xf5, 0x1b, 0x54, 0x18, 0xae, + 0x12, 0x6b, 0x37, 0xd, 0x1, 0x92, 0xf7, 0xad, 0x13, 0xdd, 0x2d}; + uint8_t bytesprops7[] = {0xd, 0x80, 0x10, 0xfe, 0x74, 0x73, 0x5c, 0x33, 0x1f, 0x18, 0xc5, 0xc4, 0xf1, 0xc8}; + uint8_t bytesprops9[] = {0xd, 0x13, 0xe9, 0xf0, 0x73, 0x12, 0xe3, 0x17, 0x66, 0x1e, 0x8e, 0x22, 0xbd, 0xa1, + 0xad, 0xe2, 0x31, 0x54, 0xad, 0xc7, 0x8a, 0xab, 0xf3, 0xd9, 0xb3, 0xd5, 0xce}; + uint8_t bytesprops11[] = {0x95}; + uint8_t bytesprops10[] = {0xc0, 0x2d, 0xf, 0x39, 0xf3, 0x74, 0xe0, 0x37, 0x82, 0x9c, + 0x7b, 0xde, 0x90, 0xb3, 0xf7, 0xc7, 0x4a, 0x5a, 0x54, 0xb0}; + uint8_t bytesprops12[] = {0xda, 0x75, 0xcd, 0x48, 0x39, 0x70, 0x56, 0x25, 0x8e, 0xa3, 0x4d, 0x0, + 0xe9, 0x81, 0xb8, 0x8b, 0x2a, 0x8a, 0x6a, 0x6b, 0x21, 0x1b, 0xc0, 0x61}; + uint8_t bytesprops13[] = {0x91, 0x1d, 0x1e, 0xee, 0x14, 0xe4, 0x74, 0xf3, 0xe1, 0xd9, 0xb, 0xc}; + uint8_t bytesprops14[] = {0x3f, 0xef, 0xc5, 0xdb, 0x6d, 0x46, 0x5b, 0xd7, 0x2e, 0xe4, 0xec, + 0x9e, 0xfa, 0x15, 0x54, 0x7e, 0x1, 0x26, 0xeb, 0x9f, 0x13}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10765}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22783}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1022}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25105}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28238}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7951}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30166}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8969}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops7}, .v = {23, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops10}, .v = {1, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26691}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24054}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8523}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops14}}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1548, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8790, 6, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\136\140\179}\STX;", _pubPktID = -// 6476, _pubBody = "Jj\SO\241\ENQ\137\DC1", _pubProps = [PropAuthenticationData -// "7\208\172)\143\239",PropMessageExpiryInterval 14862,PropMaximumPacketSize 7271,PropResponseTopic -// "\145\169Bn'",PropCorrelationData "\205\221\229\194\205\195B\162\170\166\248\239>\EOT",PropSubscriptionIdentifier -// 11,PropServerKeepAlive 3502,PropAuthenticationMethod -// "\231\188*I\DC1\211E\139\224\222\DLE\bE\141\f\220\157\&7[P\ETX\130O:\233j\223\207",PropWillDelayInterval -// 25003,PropAuthenticationData "\\g-",PropResponseTopic -// "7\248\"\198\245\216x\144\247\173&8\164&e\SOH\152\226i\225\239\238s",PropRequestResponseInformation -// 142,PropMaximumPacketSize 9884,PropSubscriptionIdentifierAvailable 226,PropResponseTopic "",PropResponseTopic -// "\140W\224\230\217@\176\254\162\161\157\201\135\138\153\GS",PropResponseTopic -// "\177\238\190k\SIb\170",PropReasonString "\239\SOH\204\154\193",PropSharedSubscriptionAvailable 52]} -TEST(Publish5QCTest, Encode21) { - uint8_t pkt[] = {0x35, 0xbc, 0x1, 0x0, 0x7, 0xfd, 0x88, 0x8c, 0xb3, 0x7d, 0x2, 0x3b, 0x19, 0x4c, 0xa8, 0x1, - 0x16, 0x0, 0x6, 0x37, 0xd0, 0xac, 0x29, 0x8f, 0xef, 0x2, 0x0, 0x0, 0x3a, 0xe, 0x27, 0x0, - 0x0, 0x1c, 0x67, 0x8, 0x0, 0x5, 0x91, 0xa9, 0x42, 0x6e, 0x27, 0x9, 0x0, 0xe, 0xcd, 0xdd, - 0xe5, 0xc2, 0xcd, 0xc3, 0x42, 0xa2, 0xaa, 0xa6, 0xf8, 0xef, 0x3e, 0x4, 0xb, 0xb, 0x13, 0xd, - 0xae, 0x15, 0x0, 0x1c, 0xe7, 0xbc, 0x2a, 0x49, 0x11, 0xd3, 0x45, 0x8b, 0xe0, 0xde, 0x10, 0x8, - 0x45, 0x8d, 0xc, 0xdc, 0x9d, 0x37, 0x5b, 0x50, 0x3, 0x82, 0x4f, 0x3a, 0xe9, 0x6a, 0xdf, 0xcf, - 0x18, 0x0, 0x0, 0x61, 0xab, 0x16, 0x0, 0x3, 0x5c, 0x67, 0x2d, 0x8, 0x0, 0x17, 0x37, 0xf8, - 0x22, 0xc6, 0xf5, 0xd8, 0x78, 0x90, 0xf7, 0xad, 0x26, 0x38, 0xa4, 0x26, 0x65, 0x1, 0x98, 0xe2, - 0x69, 0xe1, 0xef, 0xee, 0x73, 0x19, 0x8e, 0x27, 0x0, 0x0, 0x26, 0x9c, 0x29, 0xe2, 0x8, 0x0, - 0x0, 0x8, 0x0, 0x10, 0x8c, 0x57, 0xe0, 0xe6, 0xd9, 0x40, 0xb0, 0xfe, 0xa2, 0xa1, 0x9d, 0xc9, - 0x87, 0x8a, 0x99, 0x1d, 0x8, 0x0, 0x7, 0xb1, 0xee, 0xbe, 0x6b, 0xf, 0x62, 0xaa, 0x1f, 0x0, - 0x5, 0xef, 0x1, 0xcc, 0x9a, 0xc1, 0x2a, 0x34, 0x4a, 0x6a, 0xe, 0xf1, 0x5, 0x89, 0x11}; +// SubscribeRequest 28419 [("\172\146\187b\165\234\194\249&",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("&\154ju i",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\196\DC4\v\a\177\139Fn\195",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("m\205\237M\200/\184hq79.3\134,\188\154\r\211\201\143\CAN\223\SYN +// \200v\164<",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\ENQ\241`\255\207+~",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1})] [PropReasonString "G\DLE#\178\SUB\\W\139\169\&3\ENQl\EOT\206\193\201\181yl",PropMaximumQoS +// 233,PropWillDelayInterval 7767,PropSubscriptionIdentifier 19,PropMaximumQoS 119,PropWillDelayInterval +// 5694,PropWillDelayInterval 9243,PropAssignedClientIdentifier +// "l\183\"\142Ss\NAKwH#\210\254\211\132\210\229\143\198\190\246\241\229",PropRetainAvailable 16,PropUserProperty +// "\155pJ\\'M/@\EOT\NUL\207\216\DC1.\214\&0" "<)X\219'T{\"_#\206",PropTopicAliasMaximum 8705,PropMaximumPacketSize +// 18115,PropRequestResponseInformation 36,PropCorrelationData "Q\n\n\229\&6\193\169\140X^\191y",PropMaximumPacketSize +// 10019,PropRequestResponseInformation 189,PropServerKeepAlive 28101,PropTopicAliasMaximum 32452] +TEST(Subscribe5QCTest, Encode10) { + uint8_t pkt[] = { + 0x82, 0xdb, 0x1, 0x6f, 0x3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 0x2e, 0x33, 0x86, 0x2c, 0xbc, 0x9a, 0xd, 0xd3, 0xc9, 0x8f, 0x18, 0xdf, 0x16, 0x20, 0xc8, 0x76, + 0xa4, 0x3c, 0x1, 0x0, 0x7, 0x5, 0xf1, 0x60, 0xff, 0xcf, 0x2b, 0x7e, 0x1}; - uint8_t buf[201] = {0}; + uint8_t buf[232] = {0}; - uint8_t topic_bytes[] = {0xfd, 0x88, 0x8c, 0xb3, 0x7d, 0x2, 0x3b}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x4a, 0x6a, 0xe, 0xf1, 0x5, 0x89, 0x11}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; - - uint8_t bytesprops0[] = {0x37, 0xd0, 0xac, 0x29, 0x8f, 0xef}; - uint8_t bytesprops1[] = {0x91, 0xa9, 0x42, 0x6e, 0x27}; - uint8_t bytesprops2[] = {0xcd, 0xdd, 0xe5, 0xc2, 0xcd, 0xc3, 0x42, 0xa2, 0xaa, 0xa6, 0xf8, 0xef, 0x3e, 0x4}; - uint8_t bytesprops3[] = {0xe7, 0xbc, 0x2a, 0x49, 0x11, 0xd3, 0x45, 0x8b, 0xe0, 0xde, 0x10, 0x8, 0x45, 0x8d, - 0xc, 0xdc, 0x9d, 0x37, 0x5b, 0x50, 0x3, 0x82, 0x4f, 0x3a, 0xe9, 0x6a, 0xdf, 0xcf}; - uint8_t bytesprops4[] = {0x5c, 0x67, 0x2d}; - uint8_t bytesprops5[] = {0x37, 0xf8, 0x22, 0xc6, 0xf5, 0xd8, 0x78, 0x90, 0xf7, 0xad, 0x26, 0x38, - 0xa4, 0x26, 0x65, 0x1, 0x98, 0xe2, 0x69, 0xe1, 0xef, 0xee, 0x73}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops7[] = {0x8c, 0x57, 0xe0, 0xe6, 0xd9, 0x40, 0xb0, 0xfe, - 0xa2, 0xa1, 0x9d, 0xc9, 0x87, 0x8a, 0x99, 0x1d}; - uint8_t bytesprops8[] = {0xb1, 0xee, 0xbe, 0x6b, 0xf, 0x62, 0xaa}; - uint8_t bytesprops9[] = {0xef, 0x1, 0xcc, 0x9a, 0xc1}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xac, 0x92, 0xbb, 0x62, 0xa5, 0xea, 0xc2, 0xf9, 0x26}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x26, 0x9a, 0x6a, 0x75, 0x20, 0x69}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc4, 0x14, 0xb, 0x7, 0xb1, 0x8b, 0x46, 0x6e, 0xc3}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6d, 0xcd, 0xed, 0x4d, 0xc8, 0x2f, 0xb8, 0x68, 0x71, 0x37, + 0x39, 0x2e, 0x33, 0x86, 0x2c, 0xbc, 0x9a, 0xd, 0xd3, 0xc9, + 0x8f, 0x18, 0xdf, 0x16, 0x20, 0xc8, 0x76, 0xa4, 0x3c}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x5, 0xf1, 0x60, 0xff, 0xcf, 0x2b, 0x7e}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x47, 0x10, 0x23, 0xb2, 0x1a, 0x5c, 0x57, 0x8b, 0xa9, 0x33, + 0x5, 0x6c, 0x4, 0xce, 0xc1, 0xc9, 0xb5, 0x79, 0x6c}; + uint8_t bytesprops1[] = {0x6c, 0xb7, 0x22, 0x8e, 0x53, 0x73, 0x15, 0x77, 0x48, 0x23, 0xd2, + 0xfe, 0xd3, 0x84, 0xd2, 0xe5, 0x8f, 0xc6, 0xbe, 0xf6, 0xf1, 0xe5}; + uint8_t bytesprops3[] = {0x3c, 0x29, 0x58, 0xdb, 0x27, 0x54, 0x7b, 0x22, 0x5f, 0x23, 0xce}; + uint8_t bytesprops2[] = {0x9b, 0x70, 0x4a, 0x5c, 0x27, 0x4d, 0x2f, 0x40, + 0x4, 0x0, 0xcf, 0xd8, 0x11, 0x2e, 0xd6, 0x30}; + uint8_t bytesprops4[] = {0x51, 0xa, 0xa, 0xe5, 0x36, 0xc1, 0xa9, 0x8c, 0x58, 0x5e, 0xbf, 0x79}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14862}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7271}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3502}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25003}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9884}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7767}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5694}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9243}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8705}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18115}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10019}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28101}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32452}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 6476, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28419, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 5081 [("Zq\ETB\209",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("\254\248\251$\238\158f\176\218\152\154A\147\STX^\184'w\188\&2{\US\165I\vF\139",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\164\143V*3\253\171\214\141x.\184\242l\217\&2\255\ENQ",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\171E\173\162L\158>9\a\202\138\223Jb{\170Y8\RS\137\226\166I\177J",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\185\188",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropTopicAlias +// 10841,PropContentType "c\166;3\224\143\205\145s/~\212\185K",PropReasonString +// "\182m\218-L\210\146\166\GS|\DC1\165)8\238\192\172g\184\137\167z\168\248\211U",PropServerReference +// "\133\129\239\146",PropRequestResponseInformation 196,PropCorrelationData +// ",kk\NUL\234\211\CAN\159Y\185\&5\164R\162",PropRetainAvailable 165,PropResponseTopic +// "\179\215\177\DEL\r\249\170\tI\253b@\184\195\246\143\193\194<`\EM8r\ENQ\160",PropSharedSubscriptionAvailable +// 69,PropSharedSubscriptionAvailable 119,PropRequestResponseInformation 58,PropMessageExpiryInterval +// 12503,PropReasonString "\133\131\212\&7\153\246\&0",PropContentType +// "\167E'Z\209*\144\ETXC",PropPayloadFormatIndicator 38,PropContentType +// "\145^\201(0\SYN\174\188\198A\SUBfl,\139\&2_\230\233NRy\205\255\249b\160\155\176",PropTopicAlias +// 1094,PropRequestResponseInformation 213,PropReasonString "vwj%+ +// \140\150\NAK\231\248\187+\130\210\&2j\NAK\168\b\189y",PropWildcardSubscriptionAvailable 155,PropMessageExpiryInterval +// 31491] +TEST(Subscribe5QCTest, Encode11) { + uint8_t pkt[] = { + 0x82, 0xb3, 0x2, 0x13, 0xd9, 0xd1, 0x1, 0x23, 0x2a, 0x59, 0x3, 0x0, 0xe, 0x63, 0xa6, 0x3b, 0x33, 0xe0, 0x8f, + 0xcd, 0x91, 0x73, 0x2f, 0x7e, 0xd4, 0xb9, 0x4b, 0x1f, 0x0, 0x1a, 0xb6, 0x6d, 0xda, 0x2d, 0x4c, 0xd2, 0x92, 0xa6, + 0x1d, 0x7c, 0x11, 0xa5, 0x29, 0x38, 0xee, 0xc0, 0xac, 0x67, 0xb8, 0x89, 0xa7, 0x7a, 0xa8, 0xf8, 0xd3, 0x55, 0x1c, + 0x0, 0x4, 0x85, 0x81, 0xef, 0x92, 0x19, 0xc4, 0x9, 0x0, 0xe, 0x2c, 0x6b, 0x6b, 0x0, 0xea, 0xd3, 0x18, 0x9f, + 0x59, 0xb9, 0x35, 0xa4, 0x52, 0xa2, 0x25, 0xa5, 0x8, 0x0, 0x19, 0xb3, 0xd7, 0xb1, 0x7f, 0xd, 0xf9, 0xaa, 0x9, + 0x49, 0xfd, 0x62, 0x40, 0xb8, 0xc3, 0xf6, 0x8f, 0xc1, 0xc2, 0x3c, 0x60, 0x19, 0x38, 0x72, 0x5, 0xa0, 0x2a, 0x45, + 0x2a, 0x77, 0x19, 0x3a, 0x2, 0x0, 0x0, 0x30, 0xd7, 0x1f, 0x0, 0x7, 0x85, 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+ + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x5a, 0x71, 0x17, 0xd1}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xfe, 0xf8, 0xfb, 0x24, 0xee, 0x9e, 0x66, 0xb0, 0xda, 0x98, 0x9a, 0x41, 0x93, 0x2, + 0x5e, 0xb8, 0x27, 0x77, 0xbc, 0x32, 0x7b, 0x1f, 0xa5, 0x49, 0xb, 0x46, 0x8b}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa4, 0x8f, 0x56, 0x2a, 0x33, 0xfd, 0xab, 0xd6, 0x8d, + 0x78, 0x2e, 0xb8, 0xf2, 0x6c, 0xd9, 0x32, 0xff, 0x5}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xab, 0x45, 0xad, 0xa2, 0x4c, 0x9e, 0x3e, 0x39, 0x7, 0xca, 0x8a, 0xdf, 0x4a, + 0x62, 0x7b, 0xaa, 0x59, 0x38, 0x1e, 0x89, 0xe2, 0xa6, 0x49, 0xb1, 0x4a}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xb9, 0xbc}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x63, 0xa6, 0x3b, 0x33, 0xe0, 0x8f, 0xcd, 0x91, 0x73, 0x2f, 0x7e, 0xd4, 0xb9, 0x4b}; + uint8_t bytesprops1[] = {0xb6, 0x6d, 0xda, 0x2d, 0x4c, 0xd2, 0x92, 0xa6, 0x1d, 0x7c, 0x11, 0xa5, 0x29, + 0x38, 0xee, 0xc0, 0xac, 0x67, 0xb8, 0x89, 0xa7, 0x7a, 0xa8, 0xf8, 0xd3, 0x55}; + uint8_t bytesprops2[] = {0x85, 0x81, 0xef, 0x92}; + uint8_t bytesprops3[] = {0x2c, 0x6b, 0x6b, 0x0, 0xea, 0xd3, 0x18, 0x9f, 0x59, 0xb9, 0x35, 0xa4, 0x52, 0xa2}; + uint8_t bytesprops4[] = {0xb3, 0xd7, 0xb1, 0x7f, 0xd, 0xf9, 0xaa, 0x9, 0x49, 0xfd, 0x62, 0x40, 0xb8, + 0xc3, 0xf6, 0x8f, 0xc1, 0xc2, 0x3c, 0x60, 0x19, 0x38, 0x72, 0x5, 0xa0}; + uint8_t bytesprops5[] = {0x85, 0x83, 0xd4, 0x37, 0x99, 0xf6, 0x30}; + uint8_t bytesprops6[] = {0xa7, 0x45, 0x27, 0x5a, 0xd1, 0x2a, 0x90, 0x3, 0x43}; + uint8_t bytesprops7[] = {0x91, 0x5e, 0xc9, 0x28, 0x30, 0x16, 0xae, 0xbc, 0xc6, 0x41, 0x1a, 0x66, 0x6c, 0x2c, 0x8b, + 0x32, 0x5f, 0xe6, 0xe9, 0x4e, 0x52, 0x79, 0xcd, 0xff, 0xf9, 0x62, 0xa0, 0x9b, 0xb0}; + uint8_t bytesprops8[] = {0x76, 0x77, 0x6a, 0x25, 0x2b, 0x20, 0x8c, 0x96, 0x15, 0xe7, 0xf8, + 0xbb, 0x2b, 0x82, 0xd2, 0x32, 0x6a, 0x15, 0xa8, 0x8, 0xbd, 0x79}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10841}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12503}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1094}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31491}}, + }; -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\242\232\197\SOHHe\ETX>/ -// \232\220\247\251\tq\198\197nl\247\249", _pubPktID = 2029, _pubBody = "v_\GSO8\202C0\RS\247#\141\209\DEL", _pubProps = -// [PropUserProperty "\236\FS\154F\213\130\&4",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("}\ENQ\233z\235\223\134Z\220y\220\255\ACK\f8\r\211\178\171\145=\183\148\DC4\187{S:\215\247",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("SL0j\ENQ\STX\v\178\243,\155\168-3\RS*R\246\NAK\134f)\183\196",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\t\185T\132Z\205GI\DC2\146\156\233\201\134k\142\168\247\201=\179\134\&1",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\200\160\129\198|>\238\159\254\255\CANc\149\154\139\167#\234n",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\169\216=\154v",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("9\254'\139~\175N\ETX\172\240\223\&5^\171\"\163\222\225*\182\&2,\254\&6\174\EM2\f\227",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("o\SOH\195\158\&0R\138\250",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\EM\SYN\174\218\152k\247\&5i_\205`,\fm*\131_",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\163n)\179A=<\NUL\US\199\129\163\137+u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [PropContentType "\155\244\a\DC1\198\244J +// \146\r5\f\201\DC23\204",PropReceiveMaximum 31257,PropResponseInformation +// "$9\154\216\&7\238\DC2\204\252\254Z\209",PropTopicAlias 4733,PropRequestProblemInformation 43,PropResponseInformation +// "x\191S\255\152\DC3\a\139n\175\SOH*]\195\EOT\136\222\177\214:\NUL\130\GS\202",PropAssignedClientIdentifier +// "\253F?\STX?\172\167R\212(\206\213\200\227w\135\204\215\229\235",PropSubscriptionIdentifierAvailable +// 102,PropSessionExpiryInterval 19209,PropMaximumPacketSize 4183,PropContentType "\131\216\229\138",PropRetainAvailable +// 88,PropMaximumQoS 160,PropUserProperty "\210U\EOTm\128" +// "\151\146\212\169\159D}\154n\211x\vYOp\132`M_9\236\216M\221$L",PropWillDelayInterval 13355,PropResponseInformation +// "\199X\SYNK*",PropMessageExpiryInterval 6044,PropPayloadFormatIndicator 175,PropAssignedClientIdentifier +// "\243G\138\f\220\234W\182"] +TEST(Subscribe5QCTest, Encode12) { uint8_t pkt[] = { - 0x3a, 0xce, 0x1, 0x0, 0x16, 0xf2, 0xe8, 0xc5, 0x1, 0x48, 0x65, 0x3, 0x3e, 0x2f, 0x20, 0xe8, 0xdc, 0xf7, 0xfb, - 0x9, 0x71, 0xc6, 0xc5, 0x6e, 0x6c, 0xf7, 0xf9, 0x7, 0xed, 0xa4, 0x1, 0x26, 0x0, 0x14, 0xec, 0x1c, 0x9a, 0x3c, - 0x72, 0x91, 0x23, 0x49, 0xc6, 0xd, 0x9f, 0x49, 0x30, 0x17, 0x65, 0xe7, 0x6a, 0x7a, 0x3, 0x28, 0x0, 0x1, 0x9d, - 0x17, 0x78, 0x2a, 0xe0, 0x1f, 0x0, 0x1c, 0x80, 0x7b, 0xbc, 0x88, 0xf9, 0xb3, 0x9b, 0x92, 0x9b, 0xfc, 0x37, 0x36, - 0x88, 0xd3, 0x49, 0x98, 0x3, 0x49, 0x81, 0xbd, 0x1b, 0xc3, 0x6d, 0x3d, 0x6d, 0xab, 0x1, 0x61, 0x2, 0x0, 0x0, - 0x10, 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a, 0x52, 0xf6, 0x15, 0x86, 0x66, + 0x29, 0xb7, 0xc4, 0x2, 0x0, 0x17, 0x9, 0xb9, 0x54, 0x84, 0x5a, 0xcd, 0x47, 0x49, 0x12, 0x92, 0x9c, 0xe9, 0xc9, + 0x86, 0x6b, 0x8e, 0xa8, 0xf7, 0xc9, 0x3d, 0xb3, 0x86, 0x31, 0x1, 0x0, 0x13, 0xc8, 0xa0, 0x81, 0xc6, 0x7c, 0x3e, + 0xee, 0x9f, 0xfe, 0xff, 0x18, 0x63, 0x95, 0x9a, 0x8b, 0xa7, 0x23, 0xea, 0x6e, 0x2, 0x0, 0x5, 0xa9, 0xd8, 0x3d, + 0x9a, 0x76, 0x1, 0x0, 0x1d, 0x39, 0xfe, 0x27, 0x8b, 0x7e, 0xaf, 0x4e, 0x3, 0xac, 0xf0, 0xdf, 0x35, 0x5e, 0xab, + 0x22, 0xa3, 0xde, 0xe1, 0x2a, 0xb6, 0x32, 0x2c, 0xfe, 0x36, 0xae, 0x19, 0x32, 0xc, 0xe3, 0x2, 0x0, 0x8, 0x6f, + 0x1, 0xc3, 0x9e, 0x30, 0x52, 0x8a, 0xfa, 0x0, 0x0, 0x12, 0x19, 0x16, 0xae, 0xda, 0x98, 0x6b, 0xf7, 0x35, 0x69, + 0x5f, 0xcd, 0x60, 0x2c, 0xc, 0x6d, 0x2a, 0x83, 0x5f, 0x2, 0x0, 0xf, 0xa3, 0x6e, 0x29, 0xb3, 0x41, 0x3d, 0x3c, + 0x0, 0x1f, 0xc7, 0x81, 0xa3, 0x89, 0x2b, 0x75, 0x0, 0x0, 0x0, 0x2}; - uint8_t buf[219] = {0}; + uint8_t buf[421] = {0}; - uint8_t topic_bytes[] = {0xf2, 0xe8, 0xc5, 0x1, 0x48, 0x65, 0x3, 0x3e, 0x2f, 0x20, 0xe8, - 0xdc, 0xf7, 0xfb, 0x9, 0x71, 0xc6, 0xc5, 0x6e, 0x6c, 0xf7, 0xf9}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x76, 0x5f, 0x1d, 0x4f, 0x38, 0xca, 0x43, 0x30, 0x1e, 0xf7, 0x23, 0x8d, 0xd1, 0x7f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; - - uint8_t bytesprops1[] = {0x9d}; - uint8_t bytesprops0[] = {0xec, 0x1c, 0x9a, 0x3c, 0x72, 0x91, 0x23, 0x49, 0xc6, 0xd, - 0x9f, 0x49, 0x30, 0x17, 0x65, 0xe7, 0x6a, 0x7a, 0x3, 0x28}; - uint8_t bytesprops2[] = {0x80, 0x7b, 0xbc, 0x88, 0xf9, 0xb3, 0x9b, 0x92, 0x9b, 0xfc, 0x37, 0x36, 0x88, 0xd3, - 0x49, 0x98, 0x3, 0x49, 0x81, 0xbd, 0x1b, 0xc3, 0x6d, 0x3d, 0x6d, 0xab, 0x1, 0x61}; - uint8_t bytesprops3[] = {0x77, 0x49, 0xbc, 0x23, 0x7c, 0x86, 0x3b, 0xd1, 0x85, 0x38}; - uint8_t bytesprops4[] = {0x88, 0x8e, 0xb1, 0x1, 0x77, 0x14, 0x7f, 0xa0, 0x2f, 0xe8, 0xff, 0x50, - 0x91, 0x38, 0x87, 0x7f, 0x7, 0xf1, 0xb7, 0x81, 0xf1, 0x78, 0xf2, 0x81}; - uint8_t bytesprops5[] = {0x4b, 0xec, 0xbf, 0x25, 0x1d, 0x77, 0x1c, 0xde, 0xc7, 0xee, 0x69, 0xb, 0x4c, - 0x40, 0xc7, 0xd4, 0x49, 0x98, 0xcb, 0xf0, 0x8a, 0xc7, 0xd7, 0x54, 0x2a, 0x53}; - uint8_t bytesprops6[] = {0xfe, 0x96, 0x20, 0x1d, 0x76, 0xc7, 0xd7, 0x36, 0x8b, 0xa2}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xc4, 0xea, 0xe9, 0x43, 0xf5, 0x2, 0xe5, 0x9a, 0x9, + 0x1f, 0xd, 0x8, 0x26, 0x3e, 0x46, 0xd5, 0x82, 0x34}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7d, 0x5, 0xe9, 0x7a, 0xeb, 0xdf, 0x86, 0x5a, 0xdc, 0x79, + 0xdc, 0xff, 0x6, 0xc, 0x38, 0xd, 0xd3, 0xb2, 0xab, 0x91, + 0x3d, 0xb7, 0x94, 0x14, 0xbb, 0x7b, 0x53, 0x3a, 0xd7, 0xf7}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x53, 0x4c, 0x30, 0x6a, 0x5, 0x2, 0xb, 0xb2, 0xf3, 0x2c, 0x9b, 0xa8, + 0x2d, 0x33, 0x1e, 0x2a, 0x52, 0xf6, 0x15, 0x86, 0x66, 0x29, 0xb7, 0xc4}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x9, 0xb9, 0x54, 0x84, 0x5a, 0xcd, 0x47, 0x49, 0x12, 0x92, 0x9c, 0xe9, + 0xc9, 0x86, 0x6b, 0x8e, 0xa8, 0xf7, 0xc9, 0x3d, 0xb3, 0x86, 0x31}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xc8, 0xa0, 0x81, 0xc6, 0x7c, 0x3e, 0xee, 0x9f, 0xfe, 0xff, + 0x18, 0x63, 0x95, 0x9a, 0x8b, 0xa7, 0x23, 0xea, 0x6e}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa9, 0xd8, 0x3d, 0x9a, 0x76}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x39, 0xfe, 0x27, 0x8b, 0x7e, 0xaf, 0x4e, 0x3, 0xac, 0xf0, + 0xdf, 0x35, 0x5e, 0xab, 0x22, 0xa3, 0xde, 0xe1, 0x2a, 0xb6, + 0x32, 0x2c, 0xfe, 0x36, 0xae, 0x19, 0x32, 0xc, 0xe3}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6f, 0x1, 0xc3, 0x9e, 0x30, 0x52, 0x8a, 0xfa}; + lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x19, 0x16, 0xae, 0xda, 0x98, 0x6b, 0xf7, 0x35, 0x69, + 0x5f, 0xcd, 0x60, 0x2c, 0xc, 0x6d, 0x2a, 0x83, 0x5f}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa3, 0x6e, 0x29, 0xb3, 0x41, 0x3d, 0x3c, 0x0, + 0x1f, 0xc7, 0x81, 0xa3, 0x89, 0x2b, 0x75}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x9b, 0xf4, 0x7, 0x11, 0xc6, 0xf4, 0x4a, 0x20, 0x92, 0xd, 0x35, 0xc, 0xc9, 0x12, 0x33, 0xcc}; + uint8_t bytesprops1[] = {0x24, 0x39, 0x9a, 0xd8, 0x37, 0xee, 0x12, 0xcc, 0xfc, 0xfe, 0x5a, 0xd1}; + uint8_t bytesprops2[] = {0x78, 0xbf, 0x53, 0xff, 0x98, 0x13, 0x7, 0x8b, 0x6e, 0xaf, 0x1, 0x2a, + 0x5d, 0xc3, 0x4, 0x88, 0xde, 0xb1, 0xd6, 0x3a, 0x0, 0x82, 0x1d, 0xca}; + uint8_t bytesprops3[] = {0xfd, 0x46, 0x3f, 0x2, 0x3f, 0xac, 0xa7, 0x52, 0xd4, 0x28, + 0xce, 0xd5, 0xc8, 0xe3, 0x77, 0x87, 0xcc, 0xd7, 0xe5, 0xeb}; + uint8_t bytesprops4[] = {0x83, 0xd8, 0xe5, 0x8a}; + uint8_t bytesprops6[] = {0x97, 0x92, 0xd4, 0xa9, 0x9f, 0x44, 0x7d, 0x9a, 0x6e, 0xd3, 0x78, 0xb, 0x59, + 0x4f, 0x70, 0x84, 0x60, 0x4d, 0x5f, 0x39, 0xec, 0xd8, 0x4d, 0xdd, 0x24, 0x4c}; + uint8_t bytesprops5[] = {0xd2, 0x55, 0x4, 0x6d, 0x80}; + uint8_t bytesprops7[] = {0xc7, 0x58, 0x16, 0x4b, 0x2a}; + uint8_t bytesprops8[] = {0xf3, 0x47, 0x8a, 0xc, 0xdc, 0xea, 0x57, 0xb6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops0}, .v = {1, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4306}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21270}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14803}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31257}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4733}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19209}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4183}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops5}, .v = {26, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13355}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6044}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2029, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25469, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "Y\NUL&\156\t\157<\215\152R\173\212.\245\207\197\188\163\208\&2", _pubPktID = 5733, _pubBody = -// "\SOHe\184~\148\245\199\143\205\235\200U", _pubProps = [PropRetainAvailable 142,PropResponseTopic -// "\185D9Jn,\b%\165\252\236n\fl\209J\211\212\182\218\251y",PropSessionExpiryInterval 13312,PropServerKeepAlive -// 14391,PropMaximumQoS 75,PropRetainAvailable 18,PropRequestProblemInformation 240,PropSessionExpiryInterval -// 27873,PropRetainAvailable 61,PropSessionExpiryInterval 9987,PropAssignedClientIdentifier -// "aw\152\253\239\185\237W\155|\198",PropAuthenticationData ""]} -TEST(Publish5QCTest, Encode23) { - uint8_t pkt[] = {0x3d, 0x6b, 0x0, 0x14, 0x59, 0x0, 0x26, 0x9c, 0x9, 0x9d, 0x3c, 0xd7, 0x98, 0x52, 0xad, 0xd4, - 0x2e, 0xf5, 0xcf, 0xc5, 0xbc, 0xa3, 0xd0, 0x32, 0x16, 0x65, 0x46, 0x25, 0x8e, 0x8, 0x0, 0x16, - 0xb9, 0x44, 0x39, 0x4a, 0x6e, 0x2c, 0x8, 0x25, 0xa5, 0xfc, 0xec, 0x6e, 0xc, 0x6c, 0xd1, 0x4a, - 0xd3, 0xd4, 0xb6, 0xda, 0xfb, 0x79, 0x11, 0x0, 0x0, 0x34, 0x0, 0x13, 0x38, 0x37, 0x24, 0x4b, - 0x25, 0x12, 0x17, 0xf0, 0x11, 0x0, 0x0, 0x6c, 0xe1, 0x25, 0x3d, 0x11, 0x0, 0x0, 0x27, 0x3, - 0x12, 0x0, 0xb, 0x61, 0x77, 0x98, 0xfd, 0xef, 0xb9, 0xed, 0x57, 0x9b, 0x7c, 0xc6, 0x16, 0x0, - 0x0, 0x1, 0x65, 0xb8, 0x7e, 0x94, 0xf5, 0xc7, 0x8f, 0xcd, 0xeb, 0xc8, 0x55}; - - uint8_t buf[119] = {0}; +// SubscribeRequest 14214 [("96\SIk\238a\SI\ETX\203\216\176fgS\149\148\229\206$",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\242\218\225YA\243\153\247\189I",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("1\141\ENQ\206\182U",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationData +// "\155\207z\253\172\191\&9\211\156I\234\244Gl\212\210\a\134\ENQ\ACK\255\r\206\228\230/\229",PropContentType +// "\231\148>\255\162QmDX\176#\\D\191\202\251\194\&8\t\205t",PropMaximumQoS 27,PropCorrelationData +// ")T\204\185\r",PropUserProperty "\DEL\137R_I\GSqE\226\238\NAK\204\187\250\bj])U\EM\200\SO\195B" +// "a=[bS\189\r\144\161\155@Bs\ESC\EOT\253",PropMaximumPacketSize 20849] +TEST(Subscribe5QCTest, Encode13) { + uint8_t pkt[] = {0x82, 0xa5, 0x1, 0x37, 0x86, 0x72, 0x16, 0x0, 0x1b, 0x9b, 0xcf, 0x7a, 0xfd, 0xac, 0xbf, 0x39, 0xd3, + 0x9c, 0x49, 0xea, 0xf4, 0x47, 0x6c, 0xd4, 0xd2, 0x7, 0x86, 0x5, 0x6, 0xff, 0xd, 0xce, 0xe4, 0xe6, + 0x2f, 0xe5, 0x3, 0x0, 0x15, 0xe7, 0x94, 0x3e, 0xff, 0xa2, 0x51, 0x6d, 0x44, 0x58, 0xb0, 0x23, 0x5c, + 0x44, 0xbf, 0xca, 0xfb, 0xc2, 0x38, 0x9, 0xcd, 0x74, 0x24, 0x1b, 0x9, 0x0, 0x5, 0x29, 0x54, 0xcc, + 0xb9, 0xd, 0x26, 0x0, 0x18, 0x7f, 0x89, 0x52, 0x5f, 0x49, 0x1d, 0x71, 0x45, 0xe2, 0xee, 0x15, 0xcc, + 0xbb, 0xfa, 0x8, 0x6a, 0x5d, 0x29, 0x55, 0x19, 0xc8, 0xe, 0xc3, 0x42, 0x0, 0x10, 0x61, 0x3d, 0x5b, + 0x62, 0x53, 0xbd, 0xd, 0x90, 0xa1, 0x9b, 0x40, 0x42, 0x73, 0x1b, 0x4, 0xfd, 0x27, 0x0, 0x0, 0x51, + 0x71, 0x0, 0x13, 0x39, 0x36, 0xf, 0x6b, 0xee, 0x61, 0xf, 0x3, 0xcb, 0xd8, 0xb0, 0x66, 0x67, 0x53, + 0x95, 0x94, 0xe5, 0xce, 0x24, 0x2, 0x0, 0xa, 0xf2, 0xda, 0xe1, 0x59, 0x41, 0xf3, 0x99, 0xf7, 0xbd, + 0x49, 0x1, 0x0, 0x1, 0xeb, 0x0, 0x0, 0x6, 0x31, 0x8d, 0x5, 0xce, 0xb6, 0x55, 0x0}; - uint8_t topic_bytes[] = {0x59, 0x0, 0x26, 0x9c, 0x9, 0x9d, 0x3c, 0xd7, 0x98, 0x52, - 0xad, 0xd4, 0x2e, 0xf5, 0xcf, 0xc5, 0xbc, 0xa3, 0xd0, 0x32}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x1, 0x65, 0xb8, 0x7e, 0x94, 0xf5, 0xc7, 0x8f, 0xcd, 0xeb, 0xc8, 0x55}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + uint8_t buf[178] = {0}; - uint8_t bytesprops0[] = {0xb9, 0x44, 0x39, 0x4a, 0x6e, 0x2c, 0x8, 0x25, 0xa5, 0xfc, 0xec, - 0x6e, 0xc, 0x6c, 0xd1, 0x4a, 0xd3, 0xd4, 0xb6, 0xda, 0xfb, 0x79}; - uint8_t bytesprops1[] = {0x61, 0x77, 0x98, 0xfd, 0xef, 0xb9, 0xed, 0x57, 0x9b, 0x7c, 0xc6}; - uint8_t bytesprops2[] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x39, 0x36, 0xf, 0x6b, 0xee, 0x61, 0xf, 0x3, 0xcb, 0xd8, + 0xb0, 0x66, 0x67, 0x53, 0x95, 0x94, 0xe5, 0xce, 0x24}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf2, 0xda, 0xe1, 0x59, 0x41, 0xf3, 0x99, 0xf7, 0xbd, 0x49}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xeb}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x31, 0x8d, 0x5, 0xce, 0xb6, 0x55}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x9b, 0xcf, 0x7a, 0xfd, 0xac, 0xbf, 0x39, 0xd3, 0x9c, 0x49, 0xea, 0xf4, 0x47, 0x6c, + 0xd4, 0xd2, 0x7, 0x86, 0x5, 0x6, 0xff, 0xd, 0xce, 0xe4, 0xe6, 0x2f, 0xe5}; + uint8_t bytesprops1[] = {0xe7, 0x94, 0x3e, 0xff, 0xa2, 0x51, 0x6d, 0x44, 0x58, 0xb0, 0x23, + 0x5c, 0x44, 0xbf, 0xca, 0xfb, 0xc2, 0x38, 0x9, 0xcd, 0x74}; + uint8_t bytesprops2[] = {0x29, 0x54, 0xcc, 0xb9, 0xd}; + uint8_t bytesprops4[] = {0x61, 0x3d, 0x5b, 0x62, 0x53, 0xbd, 0xd, 0x90, + 0xa1, 0x9b, 0x40, 0x42, 0x73, 0x1b, 0x4, 0xfd}; + uint8_t bytesprops3[] = {0x7f, 0x89, 0x52, 0x5f, 0x49, 0x1d, 0x71, 0x45, 0xe2, 0xee, 0x15, 0xcc, + 0xbb, 0xfa, 0x8, 0x6a, 0x5d, 0x29, 0x55, 0x19, 0xc8, 0xe, 0xc3, 0x42}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13312}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14391}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27873}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9987}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops3}, .v = {16, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20849}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5733, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\224\201\GS?\232\255!\161\220\244B\129\&6\US\205R_8\191\154\217\186?\231\245\224\170", _pubPktID = 14690, _pubBody = -// "\196\183%\243\214\152\&5U;\186\194\206\128[\236B~\144\236\247\187\144Ze\ETX\176", _pubProps = -// [PropResponseInformation "\148\GSf\FSj\NAK\SI\148\ETB\137\190\194\201}\170\150c\232\&7\SI\t\169\DC3",PropMaximumQoS -// 12,PropUserProperty "\185\DC2tlZ*~@TG\177\204o\226\217z.\135" "\171\196\151\249\180!\SUBg\ESC\218\240\r\172 -// bB\188\167"]} -TEST(Publish5QCTest, Encode24) { - uint8_t pkt[] = {0x35, 0x7f, 0x0, 0x1b, 0xe0, 0xc9, 0x1d, 0x3f, 0xe8, 0xff, 0x21, 0xa1, 0xdc, 0xf4, 0x42, 0x81, 0x36, - 0x1f, 0xcd, 0x52, 0x5f, 0x38, 0xbf, 0x9a, 0xd9, 0xba, 0x3f, 0xe7, 0xf5, 0xe0, 0xaa, 0x39, 0x62, 0x45, - 0x1a, 0x0, 0x17, 0x94, 0x1d, 0x66, 0x1c, 0x6a, 0x15, 0xf, 0x94, 0x17, 0x89, 0xbe, 0xc2, 0xc9, 0x7d, - 0xaa, 0x96, 0x63, 0xe8, 0x37, 0xf, 0x9, 0xa9, 0x13, 0x24, 0xc, 0x26, 0x0, 0x12, 0xb9, 0x12, 0x74, - 0x6c, 0x5a, 0x2a, 0x7e, 0x40, 0x54, 0x47, 0xb1, 0xcc, 0x6f, 0xe2, 0xd9, 0x7a, 0x2e, 0x87, 0x0, 0x12, - 0xab, 0xc4, 0x97, 0xf9, 0xb4, 0x21, 0x1a, 0x67, 0x1b, 0xda, 0xf0, 0xd, 0xac, 0x20, 0x62, 0x42, 0xbc, - 0xa7, 0xc4, 0xb7, 0x25, 0xf3, 0xd6, 0x98, 0x35, 0x55, 0x3b, 0xba, 0xc2, 0xce, 0x80, 0x5b, 0xec, 0x42, - 0x7e, 0x90, 0xec, 0xf7, 0xbb, 0x90, 0x5a, 0x65, 0x3, 0xb0}; - - uint8_t buf[139] = {0}; - - uint8_t topic_bytes[] = {0xe0, 0xc9, 0x1d, 0x3f, 0xe8, 0xff, 0x21, 0xa1, 0xdc, 0xf4, 0x42, 0x81, 0x36, 0x1f, - 0xcd, 0x52, 0x5f, 0x38, 0xbf, 0x9a, 0xd9, 0xba, 0x3f, 0xe7, 0xf5, 0xe0, 0xaa}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xc4, 0xb7, 0x25, 0xf3, 0xd6, 0x98, 0x35, 0x55, 0x3b, 0xba, 0xc2, 0xce, 0x80, - 0x5b, 0xec, 0x42, 0x7e, 0x90, 0xec, 0xf7, 0xbb, 0x90, 0x5a, 0x65, 0x3, 0xb0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; - - uint8_t bytesprops0[] = {0x94, 0x1d, 0x66, 0x1c, 0x6a, 0x15, 0xf, 0x94, 0x17, 0x89, 0xbe, 0xc2, - 0xc9, 0x7d, 0xaa, 0x96, 0x63, 0xe8, 0x37, 0xf, 0x9, 0xa9, 0x13}; - uint8_t bytesprops2[] = {0xab, 0xc4, 0x97, 0xf9, 0xb4, 0x21, 0x1a, 0x67, 0x1b, - 0xda, 0xf0, 0xd, 0xac, 0x20, 0x62, 0x42, 0xbc, 0xa7}; - uint8_t bytesprops1[] = {0xb9, 0x12, 0x74, 0x6c, 0x5a, 0x2a, 0x7e, 0x40, 0x54, - 0x47, 0xb1, 0xcc, 0x6f, 0xe2, 0xd9, 0x7a, 0x2e, 0x87}; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14214, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 26235 [("\DLE",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("m;1\220gk`\169\152\251",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\SIj6\144\200ar\STX",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\241c\229\NULx\190Q\SYN",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropResponseInformation +// "\168\DC3\ETX",PropCorrelationData +// "Z{\175\133\a\247\182Sh\158\140\141\141\186J\f\183\ENQ\167\238\200\242}Ii\200",PropRequestProblemInformation +// 109,PropResponseInformation "\199\212\227\135:",PropResponseInformation +// "\SI6x~\198A\EOT.\138\197\193\138/\v\EM--6\f\ACK\191\v\STX",PropSubscriptionIdentifier 26,PropSessionExpiryInterval +// 19031,PropMessageExpiryInterval 30136,PropMaximumPacketSize 18409,PropSubscriptionIdentifier +// 6,PropRequestResponseInformation 8,PropRetainAvailable 55,PropRequestResponseInformation 81] +TEST(Subscribe5QCTest, Encode14) { + uint8_t pkt[] = {0x82, 0x8a, 0x1, 0x66, 0x7b, 0x60, 0x1a, 0x0, 0x3, 0xa8, 0x13, 0x3, 0x9, 0x0, 0x1a, 0x5a, + 0x7b, 0xaf, 0x85, 0x7, 0xf7, 0xb6, 0x53, 0x68, 0x9e, 0x8c, 0x8d, 0x8d, 0xba, 0x4a, 0xc, 0xb7, + 0x5, 0xa7, 0xee, 0xc8, 0xf2, 0x7d, 0x49, 0x69, 0xc8, 0x17, 0x6d, 0x1a, 0x0, 0x5, 0xc7, 0xd4, + 0xe3, 0x87, 0x3a, 0x1a, 0x0, 0x17, 0xf, 0x36, 0x78, 0x7e, 0xc6, 0x41, 0x4, 0x2e, 0x8a, 0xc5, + 0xc1, 0x8a, 0x2f, 0xb, 0x19, 0x2d, 0x2d, 0x36, 0xc, 0x6, 0xbf, 0xb, 0x2, 0xb, 0x1a, 0x11, + 0x0, 0x0, 0x4a, 0x57, 0x2, 0x0, 0x0, 0x75, 0xb8, 0x27, 0x0, 0x0, 0x47, 0xe9, 0xb, 0x6, + 0x19, 0x8, 0x25, 0x37, 0x19, 0x51, 0x0, 0x1, 0x10, 0x1, 0x0, 0xa, 0x6d, 0x3b, 0x31, 0xdc, + 0x67, 0x6b, 0x60, 0xa9, 0x98, 0xfb, 0x1, 0x0, 0x8, 0xf, 0x6a, 0x36, 0x90, 0xc8, 0x61, 0x72, + 0x2, 0x0, 0x0, 0x8, 0xf1, 0x63, 0xe5, 0x0, 0x78, 0xbe, 0x51, 0x16, 0x0}; + + uint8_t buf[151] = {0}; + + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x10}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6d, 0x3b, 0x31, 0xdc, 0x67, 0x6b, 0x60, 0xa9, 0x98, 0xfb}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf, 0x6a, 0x36, 0x90, 0xc8, 0x61, 0x72, 0x2}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf1, 0x63, 0xe5, 0x0, 0x78, 0xbe, 0x51, 0x16}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0xa8, 0x13, 0x3}; + uint8_t bytesprops1[] = {0x5a, 0x7b, 0xaf, 0x85, 0x7, 0xf7, 0xb6, 0x53, 0x68, 0x9e, 0x8c, 0x8d, 0x8d, + 0xba, 0x4a, 0xc, 0xb7, 0x5, 0xa7, 0xee, 0xc8, 0xf2, 0x7d, 0x49, 0x69, 0xc8}; + uint8_t bytesprops2[] = {0xc7, 0xd4, 0xe3, 0x87, 0x3a}; + uint8_t bytesprops3[] = {0xf, 0x36, 0x78, 0x7e, 0xc6, 0x41, 0x4, 0x2e, 0x8a, 0xc5, 0xc1, 0x8a, + 0x2f, 0xb, 0x19, 0x2d, 0x2d, 0x36, 0xc, 0x6, 0xbf, 0xb, 0x2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19031}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30136}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18409}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14690, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\128\EOT^\158\STX\"\210\232\166U\219\154N\225\218\228\153Z\152\250\224\246\211;E\155", _pubPktID = 16370, _pubBody = -// "V", _pubProps = [PropContentType "\202G\166-\168#\170\148\175\DLE\192\140\141\&54\206\217]",PropWillDelayInterval -// 23790,PropSubscriptionIdentifierAvailable 17,PropMessageExpiryInterval 27141,PropServerKeepAlive -// 11447,PropCorrelationData "d\147\235\165\&2\197C\185\143?\245\b3\185'\SO\205\240",PropMaximumQoS -// 121,PropTopicAliasMaximum 22069,PropReceiveMaximum 28169,PropReceiveMaximum 6265,PropCorrelationData "sx\t\165 -// !\DC2k\134C\SUBf\191\250\141\f)\168\246\186\204d\139#\160\230",PropServerReference -// "",PropSubscriptionIdentifierAvailable 221,PropWillDelayInterval 20730,PropAssignedClientIdentifier -// "w\135=\234f\243T\DC1\251\154\ESC;k\227\157|\190\SOH!",PropMaximumPacketSize 28283,PropPayloadFormatIndicator 165]} -TEST(Publish5QCTest, Encode25) { - uint8_t pkt[] = {0x3b, 0xa9, 0x1, 0x0, 0x1a, 0x80, 0x4, 0x5e, 0x9e, 0x2, 0x22, 0xd2, 0xe8, 0xa6, 0x55, 0xdb, - 0x9a, 0x4e, 0xe1, 0xda, 0xe4, 0x99, 0x5a, 0x98, 0xfa, 0xe0, 0xf6, 0xd3, 0x3b, 0x45, 0x9b, 0x3f, - 0xf2, 0x88, 0x1, 0x3, 0x0, 0x12, 0xca, 0x47, 0xa6, 0x2d, 0xa8, 0x23, 0xaa, 0x94, 0xaf, 0x10, - 0xc0, 0x8c, 0x8d, 0x35, 0x34, 0xce, 0xd9, 0x5d, 0x18, 0x0, 0x0, 0x5c, 0xee, 0x29, 0x11, 0x2, - 0x0, 0x0, 0x6a, 0x5, 0x13, 0x2c, 0xb7, 0x9, 0x0, 0x12, 0x64, 0x93, 0xeb, 0xa5, 0x32, 0xc5, - 0x43, 0xb9, 0x8f, 0x3f, 0xf5, 0x8, 0x33, 0xb9, 0x27, 0xe, 0xcd, 0xf0, 0x24, 0x79, 0x22, 0x56, - 0x35, 0x21, 0x6e, 0x9, 0x21, 0x18, 0x79, 0x9, 0x0, 0x1a, 0x73, 0x78, 0x9, 0xa5, 0x20, 0x21, - 0x12, 0x6b, 0x86, 0x43, 0x1a, 0x66, 0xbf, 0xfa, 0x8d, 0xc, 0x29, 0xa8, 0xf6, 0xba, 0xcc, 0x64, - 0x8b, 0x23, 0xa0, 0xe6, 0x1c, 0x0, 0x0, 0x29, 0xdd, 0x18, 0x0, 0x0, 0x50, 0xfa, 0x12, 0x0, - 0x13, 0x77, 0x87, 0x3d, 0xea, 0x66, 0xf3, 0x54, 0x11, 0xfb, 0x9a, 0x1b, 0x3b, 0x6b, 0xe3, 0x9d, - 0x7c, 0xbe, 0x1, 0x21, 0x27, 0x0, 0x0, 0x6e, 0x7b, 0x1, 0xa5, 0x56}; - - uint8_t buf[182] = {0}; - - uint8_t topic_bytes[] = {0x80, 0x4, 0x5e, 0x9e, 0x2, 0x22, 0xd2, 0xe8, 0xa6, 0x55, 0xdb, 0x9a, 0x4e, - 0xe1, 0xda, 0xe4, 0x99, 0x5a, 0x98, 0xfa, 0xe0, 0xf6, 0xd3, 0x3b, 0x45, 0x9b}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x56}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; - - uint8_t bytesprops0[] = {0xca, 0x47, 0xa6, 0x2d, 0xa8, 0x23, 0xaa, 0x94, 0xaf, - 0x10, 0xc0, 0x8c, 0x8d, 0x35, 0x34, 0xce, 0xd9, 0x5d}; - uint8_t bytesprops1[] = {0x64, 0x93, 0xeb, 0xa5, 0x32, 0xc5, 0x43, 0xb9, 0x8f, - 0x3f, 0xf5, 0x8, 0x33, 0xb9, 0x27, 0xe, 0xcd, 0xf0}; - uint8_t bytesprops2[] = {0x73, 0x78, 0x9, 0xa5, 0x20, 0x21, 0x12, 0x6b, 0x86, 0x43, 0x1a, 0x66, 0xbf, - 0xfa, 0x8d, 0xc, 0x29, 0xa8, 0xf6, 0xba, 0xcc, 0x64, 0x8b, 0x23, 0xa0, 0xe6}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x77, 0x87, 0x3d, 0xea, 0x66, 0xf3, 0x54, 0x11, 0xfb, 0x9a, - 0x1b, 0x3b, 0x6b, 0xe3, 0x9d, 0x7c, 0xbe, 0x1, 0x21}; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26235, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 10474 [("\ACK\214li.\ESC\US;\201}3\165",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\152\173{\218\168a\184Y_y\149\241F:y\188",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\147\ESC\141H\166\226\230G\180\252\198\196\GS",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\236\183\RSM\169v\254\179TT7\211\194\132\161fbQ\218\US\135\202\f\149E\197\197\SOHuK",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("3\179|)\222p\245\SUB\197\v\182\RSnw#\225\157t\ETX\DC2E",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\233\213\221\219\SUB0\164J\162\185\156\230\230\&5\156\244\133",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("d\NULN\129\242u`\152\ACK\DEL_\164\207\168\191T\132\177\"\FS*",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\136f7w\182\132'",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\220w'\179\FSxy\194[@\163;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("9H\134H\191\242[\206S\129\162\243\244Kw$",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropResponseInformation +// "\240\203\GS\183\250\137l\224\235\250'\249}\SO\206|\144\162",PropResponseTopic +// "o6j\209\186\192\221<\139\204\253`\186\220\ETB?\213-?\239\132G",PropSharedSubscriptionAvailable 35,PropReasonString +// "X\DELS\248\184G\255+\194\169",PropMessageExpiryInterval 18569,PropTopicAlias 4449,PropReceiveMaximum +// 7814,PropTopicAlias 30892,PropUserProperty "e\a8\208\CAN\131b\134N\160\228\163\189y$\151a\130\169\244{\198\141\177" +// "\163\195M\241ue-\211\212\174\ACK\b\204\255\SYN\208\188+N\196\237\171\129R\129\226\ETX\163w",PropRetainAvailable +// 199,PropCorrelationData "}\165\223L\181\EOTt\CAN\253\176\210\209",PropServerKeepAlive +// 2300,PropWildcardSubscriptionAvailable 187] +TEST(Subscribe5QCTest, Encode15) { + uint8_t pkt[] = { + 0x82, 0xe7, 0x2, 0x28, 0xea, 0x9b, 0x1, 0x1a, 0x0, 0x12, 0xf0, 0xcb, 0x1d, 0xb7, 0xfa, 0x89, 0x6c, 0xe0, 0xeb, + 0xfa, 0x27, 0xf9, 0x7d, 0xe, 0xce, 0x7c, 0x90, 0xa2, 0x8, 0x0, 0x16, 0x6f, 0x36, 0x6a, 0xd1, 0xba, 0xc0, 0xdd, + 0x3c, 0x8b, 0xcc, 0xfd, 0x60, 0xba, 0xdc, 0x17, 0x3f, 0xd5, 0x2d, 0x3f, 0xef, 0x84, 0x47, 0x2a, 0x23, 0x1f, 0x0, + 0xa, 0x58, 0x7f, 0x53, 0xf8, 0xb8, 0x47, 0xff, 0x2b, 0xc2, 0xa9, 0x2, 0x0, 0x0, 0x48, 0x89, 0x23, 0x11, 0x61, + 0x21, 0x1e, 0x86, 0x23, 0x78, 0xac, 0x26, 0x0, 0x18, 0x65, 0x7, 0x38, 0xd0, 0x18, 0x83, 0x62, 0x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9, 0xd5, 0xdd, 0xdb, 0x1a, 0x30, 0xa4, 0x4a, 0xa2, + 0xb9, 0x9c, 0xe6, 0xe6, 0x35, 0x9c, 0xf4, 0x85, 0x2, 0x0, 0x15, 0x64, 0x0, 0x4e, 0x81, 0xf2, 0x75, 0x60, 0x98, + 0x6, 0x7f, 0x5f, 0xa4, 0xcf, 0xa8, 0xbf, 0x54, 0x84, 0xb1, 0x22, 0x1c, 0x2a, 0x2, 0x0, 0x7, 0x88, 0x66, 0x37, + 0x77, 0xb6, 0x84, 0x27, 0x2, 0x0, 0xc, 0xdc, 0x77, 0x27, 0xb3, 0x1c, 0x78, 0x79, 0xc2, 0x5b, 0x40, 0xa3, 0x3b, + 0x2, 0x0, 0x10, 0x39, 0x48, 0x86, 0x48, 0xbf, 0xf2, 0x5b, 0xce, 0x53, 0x81, 0xa2, 0xf3, 0xf4, 0x4b, 0x77, 0x24, + 0x1}; + + uint8_t buf[372] = {0}; + + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x6, 0xd6, 0x6c, 0x69, 0x2e, 0x1b, 0x1f, 0x3b, 0x3c, + 0x4f, 0x5d, 0x74, 0x3e, 0xc9, 0x7d, 0x33, 0xa5}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x98, 0xad, 0x7b, 0xda, 0xa8, 0x61, 0xb8, 0x59, + 0x5f, 0x79, 0x95, 0xf1, 0x46, 0x3a, 0x79, 0xbc}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x93, 0x1b, 0x8d, 0x48, 0xa6, 0xe2, 0xe6, 0x47, 0xb4, 0xfc, 0xc6, 0xc4, 0x1d}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xec, 0xb7, 0x1e, 0x4d, 0xa9, 0x76, 0xfe, 0xb3, 0x54, 0x54, + 0x37, 0xd3, 0xc2, 0x84, 0xa1, 0x66, 0x62, 0x51, 0xda, 0x1f, + 0x87, 0xca, 0xc, 0x95, 0x45, 0xc5, 0xc5, 0x1, 0x75, 0x4b}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x33, 0xb3, 0x7c, 0x29, 0xde, 0x70, 0xf5, 0x1a, 0xc5, 0xb, 0xb6, + 0x1e, 0x6e, 0x77, 0x23, 0xe1, 0x9d, 0x74, 0x3, 0x12, 0x45}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe9, 0xd5, 0xdd, 0xdb, 0x1a, 0x30, 0xa4, 0x4a, 0xa2, + 0xb9, 0x9c, 0xe6, 0xe6, 0x35, 0x9c, 0xf4, 0x85}; + lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x64, 0x0, 0x4e, 0x81, 0xf2, 0x75, 0x60, 0x98, 0x6, 0x7f, 0x5f, + 0xa4, 0xcf, 0xa8, 0xbf, 0x54, 0x84, 0xb1, 0x22, 0x1c, 0x2a}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x88, 0x66, 0x37, 0x77, 0xb6, 0x84, 0x27}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xdc, 0x77, 0x27, 0xb3, 0x1c, 0x78, 0x79, 0xc2, 0x5b, 0x40, 0xa3, 0x3b}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x39, 0x48, 0x86, 0x48, 0xbf, 0xf2, 0x5b, 0xce, + 0x53, 0x81, 0xa2, 0xf3, 0xf4, 0x4b, 0x77, 0x24}; + lwmqtt_string_t topic_filter_s9 = {16, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xf0, 0xcb, 0x1d, 0xb7, 0xfa, 0x89, 0x6c, 0xe0, 0xeb, + 0xfa, 0x27, 0xf9, 0x7d, 0xe, 0xce, 0x7c, 0x90, 0xa2}; + uint8_t bytesprops1[] = {0x6f, 0x36, 0x6a, 0xd1, 0xba, 0xc0, 0xdd, 0x3c, 0x8b, 0xcc, 0xfd, + 0x60, 0xba, 0xdc, 0x17, 0x3f, 0xd5, 0x2d, 0x3f, 0xef, 0x84, 0x47}; + uint8_t bytesprops2[] = {0x58, 0x7f, 0x53, 0xf8, 0xb8, 0x47, 0xff, 0x2b, 0xc2, 0xa9}; + uint8_t bytesprops4[] = {0xa3, 0xc3, 0x4d, 0xf1, 0x75, 0x65, 0x2d, 0xd3, 0xd4, 0xae, 0x6, 0x8, 0xcc, 0xff, 0x16, + 0xd0, 0xbc, 0x2b, 0x4e, 0xc4, 0xed, 0xab, 0x81, 0x52, 0x81, 0xe2, 0x3, 0xa3, 0x77}; + uint8_t bytesprops3[] = {0x65, 0x7, 0x38, 0xd0, 0x18, 0x83, 0x62, 0x86, 0x4e, 0xa0, 0xe4, 0xa3, + 0xbd, 0x79, 0x24, 0x97, 0x61, 0x82, 0xa9, 0xf4, 0x7b, 0xc6, 0x8d, 0xb1}; + uint8_t bytesprops5[] = {0x7d, 0xa5, 0xdf, 0x4c, 0xb5, 0x4, 0x74, 0x18, 0xfd, 0xb0, 0xd2, 0xd1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23790}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27141}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11447}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22069}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28169}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6265}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20730}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28283}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18569}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4449}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7814}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30892}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops3}, .v = {29, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2300}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 187}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16370, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "c\215A4\142\182\&2\162\191V\143t$A0\142", _pubPktID = 0, _pubBody = "\221\195:\163\203\239\168%\160", _pubProps = -// [PropWildcardSubscriptionAvailable 147,PropTopicAliasMaximum 24199,PropWildcardSubscriptionAvailable -// 160,PropCorrelationData "n6/\211,\146\245\206jJ\n\DELUD\ACK\b",PropResponseTopic -// "%nfm\223X\DLE\210\210\199\239\135D\160\&24Fj\232\230\147\199\&8\159J\233\EOT\128",PropMaximumQoS -// 189,PropResponseTopic "|O\178\204U\155\139W\165y\SUBKP#u?\DEL\151nl{\247\230B",PropResponseTopic -// "",PropSharedSubscriptionAvailable 12,PropUserProperty -// "\209,\153V\198\200\208\&5;\231\196IQv\152\230\SO&U\216]S\a\229\216" -// "\221\242\ACK\239\132\EOT\219AM\134~\251I\254)+(\245#\129\255_\ETB",PropSharedSubscriptionAvailable 44,PropMaximumQoS -// 37,PropMaximumPacketSize 19948,PropMaximumQoS 126,PropContentType -// "\DC4\194\190%\SOH\201\218\203\147\134\255f-X.\252T",PropCorrelationData "\241\&6_\152\230Z,V\157",PropUserProperty -// "\184\137Qr\222\NAK\179\144/\a\233\139\196-\241\NUL\SO\DC2\ETX\254\233\160/\172\197\179\157I" -// "s\205\154\CAN\206Q\227\254#\DLE\188\169\131.\129OE\220\242\&0n\172\149YD",PropWildcardSubscriptionAvailable -// 197,PropPayloadFormatIndicator 186,PropAuthenticationMethod "\196\RS",PropReceiveMaximum -// 22903,PropMessageExpiryInterval 9152,PropSubscriptionIdentifierAvailable 229,PropSubscriptionIdentifier -// 7,PropContentType "#<\ACKH\197\135U2{n\135\247\236Hb~\134\134",PropReceiveMaximum 10637,PropPayloadFormatIndicator -// 84]} -TEST(Publish5QCTest, Encode26) { + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10474, 10, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 3250 [("x\215}:\240\130\FS\DC3r\185\253t\214\&4\231\195dG<\187\f",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\ETB\236&\173\154\233\&7\EOT~",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("!\CAN\STX\GSG;\179\203\n\224\213",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\208d*\128\&7+\217w\"\f\250\ENQ\189\159\234\236\247\238\ACK0\195",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\155\218X\182O\200\175-#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\219\217L\214\219",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("A\235\201\159~{C\168\132nu\ETB",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\159jI\215+\216\176`\223\230\169\155\239\249q6",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAssignedClientIdentifier +// "\199es!\\\EOT\210\170\134",PropAuthenticationMethod "\219\135",PropTopicAlias 24882,PropResponseTopic +// "g\146\RSP",PropContentType "\\\188\201\153\183\157\226\172\219\vb\224\217\157\&9\162\SOH",PropAuthenticationMethod +// "\162\t\209c\229\&4Mr{\"E\229\223\183\r\EMq\ENQUBD",PropReasonString +// "\222\140\b\153\&4L\244\147A|L\EMd\163\US\156\&4\244\137\156",PropAssignedClientIdentifier +// "v\EM\186\129\USkJ\162",PropTopicAliasMaximum 17487,PropServerReference +// "!\136\189\242%\245\SO\184\204\203",PropSubscriptionIdentifier 27,PropServerReference "=\175\132",PropCorrelationData +// "\172\206\t\b\143\167\&7|5~",PropCorrelationData "y\229\234D\199",PropTopicAliasMaximum 9292,PropMaximumQoS +// 48,PropContentType "\237\207\183\254\EM`\201,Y\ETX\232\n\246\166\179\198\227-",PropSubscriptionIdentifier 4] +TEST(Subscribe5QCTest, Encode16) { uint8_t pkt[] = { - 0x31, 0xc1, 0x2, 0x0, 0x10, 0x63, 0xd7, 0x41, 0x34, 0x8e, 0xb6, 0x32, 0xa2, 0xbf, 0x56, 0x8f, 0x74, 0x24, - 0x41, 0x30, 0x8e, 0xa4, 0x2, 0x28, 0x93, 0x22, 0x5e, 0x87, 0x28, 0xa0, 0x9, 0x0, 0x10, 0x6e, 0x36, 0x2f, - 0xd3, 0x2c, 0x92, 0xf5, 0xce, 0x6a, 0x4a, 0xa, 0x7f, 0x55, 0x44, 0x6, 0x8, 0x8, 0x0, 0x1c, 0x25, 0x6e, - 0x66, 0x6d, 0xdf, 0x58, 0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0xcd, 0x9a, 0x18, 0xce, 0x51, 0xe3, 0xfe, 0x23, - 0x10, 0xbc, 0xa9, 0x83, 0x2e, 0x81, 0x4f, 0x45, 0xdc, 0xf2, 0x30, 0x6e, 0xac, 0x95, 0x59, 0x44, 0x28, 0xc5, - 0x1, 0xba, 0x15, 0x0, 0x2, 0xc4, 0x1e, 0x21, 0x59, 0x77, 0x2, 0x0, 0x0, 0x23, 0xc0, 0x29, 0xe5, 0xb, - 0x7, 0x3, 0x0, 0x12, 0x23, 0x3c, 0x6, 0x48, 0xc5, 0x87, 0x55, 0x32, 0x7b, 0x6e, 0x87, 0xf7, 0xec, 0x48, - 0x62, 0x7e, 0x86, 0x86, 0x21, 0x29, 0x8d, 0x1, 0x54, 0xdd, 0xc3, 0x3a, 0xa3, 0xcb, 0xef, 0xa8, 0x25, 0xa0}; - - uint8_t buf[334] = {0}; - - uint8_t topic_bytes[] = {0x63, 0xd7, 0x41, 0x34, 0x8e, 0xb6, 0x32, 0xa2, - 0xbf, 0x56, 0x8f, 0x74, 0x24, 0x41, 0x30, 0x8e}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xdd, 0xc3, 0x3a, 0xa3, 0xcb, 0xef, 0xa8, 0x25, 0xa0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + 0x82, 0xb6, 0x2, 0xc, 0xb2, 0xb2, 0x1, 0x12, 0x0, 0x9, 0xc7, 0x65, 0x73, 0x21, 0x5c, 0x4, 0xd2, 0xaa, 0x86, + 0x15, 0x0, 0x2, 0xdb, 0x87, 0x23, 0x61, 0x32, 0x8, 0x0, 0x4, 0x67, 0x92, 0x1e, 0x50, 0x3, 0x0, 0x11, 0x5c, + 0xbc, 0xc9, 0x99, 0xb7, 0x9d, 0xe2, 0xac, 0xdb, 0xb, 0x62, 0xe0, 0xd9, 0x9d, 0x39,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x2a, 0x80, 0x37, 0x2b, 0xd9, 0x77, 0x22, 0xc, + 0xfa, 0x5, 0xbd, 0x9f, 0xea, 0xec, 0xf7, 0xee, 0x6, 0x30, 0xc3, 0x0, 0x0, 0x9, 0x9b, 0xda, 0x58, 0xb6, 0x4f, + 0xc8, 0xaf, 0x2d, 0x23, 0x1, 0x0, 0x5, 0xdb, 0xd9, 0x4c, 0xd6, 0xdb, 0x1, 0x0, 0xc, 0x41, 0xeb, 0xc9, 0x9f, + 0x7e, 0x7b, 0x43, 0xa8, 0x84, 0x6e, 0x75, 0x17, 0x1, 0x0, 0x10, 0x9f, 0x6a, 0x49, 0xd7, 0x2b, 0xd8, 0xb0, 0x60, + 0xdf, 0xe6, 0xa9, 0x9b, 0xef, 0xf9, 0x71, 0x36, 0x1}; - uint8_t bytesprops0[] = {0x6e, 0x36, 0x2f, 0xd3, 0x2c, 0x92, 0xf5, 0xce, 0x6a, 0x4a, 0xa, 0x7f, 0x55, 0x44, 0x6, 0x8}; - uint8_t bytesprops1[] = {0x25, 0x6e, 0x66, 0x6d, 0xdf, 0x58, 0x10, 0xd2, 0xd2, 0xc7, 0xef, 0x87, 0x44, 0xa0, - 0x32, 0x34, 0x46, 0x6a, 0xe8, 0xe6, 0x93, 0xc7, 0x38, 0x9f, 0x4a, 0xe9, 0x4, 0x80}; - uint8_t bytesprops2[] = {0x7c, 0x4f, 0xb2, 0xcc, 0x55, 0x9b, 0x8b, 0x57, 0xa5, 0x79, 0x1a, 0x4b, - 0x50, 0x23, 0x75, 0x3f, 0x7f, 0x97, 0x6e, 0x6c, 0x7b, 0xf7, 0xe6, 0x42}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops5[] = {0xdd, 0xf2, 0x6, 0xef, 0x84, 0x4, 0xdb, 0x41, 0x4d, 0x86, 0x7e, 0xfb, - 0x49, 0xfe, 0x29, 0x2b, 0x28, 0xf5, 0x23, 0x81, 0xff, 0x5f, 0x17}; - uint8_t bytesprops4[] = {0xd1, 0x2c, 0x99, 0x56, 0xc6, 0xc8, 0xd0, 0x35, 0x3b, 0xe7, 0xc4, 0x49, 0x51, - 0x76, 0x98, 0xe6, 0xe, 0x26, 0x55, 0xd8, 0x5d, 0x53, 0x7, 0xe5, 0xd8}; - uint8_t bytesprops6[] = {0x14, 0xc2, 0xbe, 0x25, 0x1, 0xc9, 0xda, 0xcb, 0x93, - 0x86, 0xff, 0x66, 0x2d, 0x58, 0x2e, 0xfc, 0x54}; - uint8_t bytesprops7[] = {0xf1, 0x36, 0x5f, 0x98, 0xe6, 0x5a, 0x2c, 0x56, 0x9d}; - uint8_t bytesprops9[] = {0x73, 0xcd, 0x9a, 0x18, 0xce, 0x51, 0xe3, 0xfe, 0x23, 0x10, 0xbc, 0xa9, 0x83, - 0x2e, 0x81, 0x4f, 0x45, 0xdc, 0xf2, 0x30, 0x6e, 0xac, 0x95, 0x59, 0x44}; - uint8_t bytesprops8[] = {0xb8, 0x89, 0x51, 0x72, 0xde, 0x15, 0xb3, 0x90, 0x2f, 0x7, 0xe9, 0x8b, 0xc4, 0x2d, - 0xf1, 0x0, 0xe, 0x12, 0x3, 0xfe, 0xe9, 0xa0, 0x2f, 0xac, 0xc5, 0xb3, 0x9d, 0x49}; - uint8_t bytesprops10[] = {0xc4, 0x1e}; - uint8_t bytesprops11[] = {0x23, 0x3c, 0x6, 0x48, 0xc5, 0x87, 0x55, 0x32, 0x7b, - 0x6e, 0x87, 0xf7, 0xec, 0x48, 0x62, 0x7e, 0x86, 0x86}; + uint8_t buf[323] = {0}; + + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x78, 0xd7, 0x7d, 0x3a, 0xf0, 0x82, 0x1c, 0x13, 0x72, 0xb9, 0xfd, + 0x74, 0xd6, 0x34, 0xe7, 0xc3, 0x64, 0x47, 0x3c, 0xbb, 0xc}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x17, 0xec, 0x26, 0xad, 0x9a, 0xe9, 0x37, 0x4, 0x7e}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x21, 0x18, 0x2, 0x1d, 0x47, 0x3b, 0xb3, 0xcb, 0xa, 0xe0, 0xd5}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd0, 0x64, 0x2a, 0x80, 0x37, 0x2b, 0xd9, 0x77, 0x22, 0xc, 0xfa, + 0x5, 0xbd, 0x9f, 0xea, 0xec, 0xf7, 0xee, 0x6, 0x30, 0xc3}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9b, 0xda, 0x58, 0xb6, 0x4f, 0xc8, 0xaf, 0x2d, 0x23}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xdb, 0xd9, 0x4c, 0xd6, 0xdb}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x41, 0xeb, 0xc9, 0x9f, 0x7e, 0x7b, 0x43, 0xa8, 0x84, 0x6e, 0x75, 0x17}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x9f, 0x6a, 0x49, 0xd7, 0x2b, 0xd8, 0xb0, 0x60, + 0xdf, 0xe6, 0xa9, 0x9b, 0xef, 0xf9, 0x71, 0x36}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xc7, 0x65, 0x73, 0x21, 0x5c, 0x4, 0xd2, 0xaa, 0x86}; + uint8_t bytesprops1[] = {0xdb, 0x87}; + uint8_t bytesprops2[] = {0x67, 0x92, 0x1e, 0x50}; + uint8_t bytesprops3[] = {0x5c, 0xbc, 0xc9, 0x99, 0xb7, 0x9d, 0xe2, 0xac, 0xdb, + 0xb, 0x62, 0xe0, 0xd9, 0x9d, 0x39, 0xa2, 0x1}; + uint8_t bytesprops4[] = {0xa2, 0x9, 0xd1, 0x63, 0xe5, 0x34, 0x4d, 0x72, 0x7b, 0x22, 0x45, + 0xe5, 0xdf, 0xb7, 0xd, 0x19, 0x71, 0x5, 0x55, 0x42, 0x44}; + uint8_t bytesprops5[] = {0xde, 0x8c, 0x8, 0x99, 0x34, 0x4c, 0xf4, 0x93, 0x41, 0x7c, + 0x4c, 0x19, 0x64, 0xa3, 0x1f, 0x9c, 0x34, 0xf4, 0x89, 0x9c}; + uint8_t bytesprops6[] = {0x76, 0x19, 0xba, 0x81, 0x1f, 0x6b, 0x4a, 0xa2}; + uint8_t bytesprops7[] = {0x21, 0x88, 0xbd, 0xf2, 0x25, 0xf5, 0xe, 0xb8, 0xcc, 0xcb}; + uint8_t bytesprops8[] = {0x3d, 0xaf, 0x84}; + uint8_t bytesprops9[] = {0xac, 0xce, 0x9, 0x8, 0x8f, 0xa7, 0x37, 0x7c, 0x35, 0x7e}; + uint8_t bytesprops10[] = {0x79, 0xe5, 0xea, 0x44, 0xc7}; + uint8_t bytesprops11[] = {0xed, 0xcf, 0xb7, 0xfe, 0x19, 0x60, 0xc9, 0x2c, 0x59, + 0x3, 0xe8, 0xa, 0xf6, 0xa6, 0xb3, 0xc6, 0xe3, 0x2d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24199}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops4}, .v = {23, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19948}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops8}, .v = {25, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22903}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9152}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24882}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17487}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9292}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 48}}, {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10637}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3250, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\161\166\175\235\223\210\143\180\219\210\209\129\230\195\173\&1\t\ENQy\206\250\146\214\205\161\212{?\157", _pubPktID -// = 0, _pubBody = "\206W9\140\ESC6\211\206\212d\US\141\189`a9\182\130,\ETX", _pubProps = [PropRequestProblemInformation -// 98,PropMaximumQoS 10]} -TEST(Publish5QCTest, Encode27) { - uint8_t pkt[] = {0x30, 0x38, 0x0, 0x1d, 0xa1, 0xa6, 0xaf, 0xeb, 0xdf, 0xd2, 0x8f, 0xb4, 0xdb, 0xd2, 0xd1, - 0x81, 0xe6, 0xc3, 0xad, 0x31, 0x9, 0x5, 0x79, 0xce, 0xfa, 0x92, 0xd6, 0xcd, 0xa1, 0xd4, - 0x7b, 0x3f, 0x9d, 0x4, 0x17, 0x62, 0x24, 0xa, 0xce, 0x57, 0x39, 0x8c, 0x1b, 0x36, 0xd3, - 0xce, 0xd4, 0x64, 0x1f, 0x8d, 0xbd, 0x60, 0x61, 0x39, 0xb6, 0x82, 0x2c, 0x3}; +// SubscribeRequest 12034 +// [("\128.\143\172\255%\203\247\222\207O\146%X\169\204g\245\223\SUB\150#\190tM\173Fw9",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropServerKeepAlive +// 4778,PropWillDelayInterval 10353,PropMessageExpiryInterval 18887,PropSharedSubscriptionAvailable 75,PropTopicAlias +// 8848,PropRetainAvailable 170,PropAuthenticationMethod "{\ETXs\233\138\SO*",PropWillDelayInterval +// 29469,PropMaximumPacketSize 4282,PropSharedSubscriptionAvailable 241,PropServerReference +// "",PropRequestProblemInformation 234,PropSubscriptionIdentifier 14,PropReceiveMaximum 24890,PropServerReference +// "\184}Wx\223M\202\NUL0\220E\249\247\n\191\202",PropSharedSubscriptionAvailable 112,PropRequestResponseInformation +// 142,PropSharedSubscriptionAvailable 65,PropSubscriptionIdentifier 12,PropReceiveMaximum 25373,PropServerKeepAlive +// 9978,PropReceiveMaximum 970] +TEST(Subscribe5QCTest, Encode17) { + uint8_t pkt[] = {0x82, 0x7b, 0x2f, 0x2, 0x58, 0x13, 0x12, 0xaa, 0x18, 0x0, 0x0, 0x28, 0x71, 0x2, 0x0, 0x0, + 0x49, 0xc7, 0x2a, 0x4b, 0x23, 0x22, 0x90, 0x25, 0xaa, 0x15, 0x0, 0x7, 0x7b, 0x3, 0x73, 0xe9, + 0x8a, 0xe, 0x2a, 0x18, 0x0, 0x0, 0x73, 0x1d, 0x27, 0x0, 0x0, 0x10, 0xba, 0x2a, 0xf1, 0x1c, + 0x0, 0x0, 0x17, 0xea, 0xb, 0xe, 0x21, 0x61, 0x3a, 0x1c, 0x0, 0x10, 0xb8, 0x7d, 0x57, 0x78, + 0xdf, 0x4d, 0xca, 0x0, 0x30, 0xdc, 0x45, 0xf9, 0xf7, 0xa, 0xbf, 0xca, 0x2a, 0x70, 0x19, 0x8e, + 0x2a, 0x41, 0xb, 0xc, 0x21, 0x63, 0x1d, 0x13, 0x26, 0xfa, 0x21, 0x3, 0xca, 0x0, 0x1d, 0x80, + 0x2e, 0x8f, 0xac, 0xff, 0x25, 0xcb, 0xf7, 0xde, 0xcf, 0x4f, 0x92, 0x25, 0x58, 0xa9, 0xcc, 0x67, + 0xf5, 0xdf, 0x1a, 0x96, 0x23, 0xbe, 0x74, 0x4d, 0xad, 0x46, 0x77, 0x39, 0x0}; - uint8_t buf[68] = {0}; + uint8_t buf[135] = {0}; - uint8_t topic_bytes[] = {0xa1, 0xa6, 0xaf, 0xeb, 0xdf, 0xd2, 0x8f, 0xb4, 0xdb, 0xd2, 0xd1, 0x81, 0xe6, 0xc3, 0xad, - 0x31, 0x9, 0x5, 0x79, 0xce, 0xfa, 0x92, 0xd6, 0xcd, 0xa1, 0xd4, 0x7b, 0x3f, 0x9d}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xce, 0x57, 0x39, 0x8c, 0x1b, 0x36, 0xd3, 0xce, 0xd4, 0x64, - 0x1f, 0x8d, 0xbd, 0x60, 0x61, 0x39, 0xb6, 0x82, 0x2c, 0x3}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x80, 0x2e, 0x8f, 0xac, 0xff, 0x25, 0xcb, 0xf7, 0xde, 0xcf, + 0x4f, 0x92, 0x25, 0x58, 0xa9, 0xcc, 0x67, 0xf5, 0xdf, 0x1a, + 0x96, 0x23, 0xbe, 0x74, 0x4d, 0xad, 0x46, 0x77, 0x39}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x7b, 0x3, 0x73, 0xe9, 0x8a, 0xe, 0x2a}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0xb8, 0x7d, 0x57, 0x78, 0xdf, 0x4d, 0xca, 0x0, + 0x30, 0xdc, 0x45, 0xf9, 0xf7, 0xa, 0xbf, 0xca}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4778}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10353}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18887}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8848}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29469}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4282}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24890}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25373}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9978}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 970}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12034, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 4596 [("7\239\237\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\201\SI~\174\182\156;o{\142",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\219\b\DLE\SYN\228sb\177\143\195\230o<\196\246f=B",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\135\224?\NUL\161\188\134E\172\&4>1",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),(".\233\181Y\146\&6\140\157\t\205\161Mo\215\&5\186\RSB_\ACK\219\186\f\238",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("1\174\&9\253\135o\201\235\GS\243\240\SYN\177jUy\141\218\158\251\232Pg\161\SYN\SO\162",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\137\&5u\EOT\209\DC4e\177\194H\NAKp;Q\228\b\149\178\182\140\217>!\",\FS\154\163\&1",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\189r\185K\155\247:&\129\FS}\SUB\136\205\198gm\202\183|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAssignedClientIdentifier +// "\DC1\200\ta\151ad%\149\206\235\139-\ETX\224\&7j\168ZE\ACK*",PropTopicAlias 26951,PropSessionExpiryInterval +// 19408,PropServerKeepAlive 13738,PropAssignedClientIdentifier +// "K\177Yq\"\199\190\168\a\160\DC3Q6o\221\134\168\206\254\\.*9",PropServerKeepAlive 22953,PropMessageExpiryInterval +// 20380,PropRetainAvailable 82,PropPayloadFormatIndicator 101,PropSubscriptionIdentifierAvailable +// 35,PropWillDelayInterval 26378,PropSessionExpiryInterval 6332,PropMessageExpiryInterval 18541,PropAuthenticationData +// "J\130;\242\RS\213\230\152\169\243",PropWildcardSubscriptionAvailable 38,PropSessionExpiryInterval +// 12922,PropServerReference "Cv\165\&7\219\228\t,\ETX/\159\176\200(\227H\\f +// \178\FS&o\142\172'D\250\SYN",PropCorrelationData "\131\ESC\DC1nr\DEL\237\235\FS\ACK\220\238",PropReasonString +// "\251\194\163\212`F\160\FS5.\207d\241D\138\240n\ESC^*\ESC\174",PropServerReference +// "\233\v\244\185\DEL!6\131\243\232;\173\129a\242\176\147\b\161\209\156Z\169\DLE/"] +TEST(Subscribe5QCTest, Encode18) { + uint8_t pkt[] = { + 0x82, 0x86, 0x3, 0x11, 0xf4, 0xd3, 0x1, 0x12, 0x0, 0x16, 0x11, 0xc8, 0x9, 0x61, 0x97, 0x61, 0x64, 0x25, 0x95, + 0xce, 0xeb, 0x8b, 0x2d, 0x3, 0xe0, 0x37, 0x6a, 0xa8, 0x5a, 0x45, 0x6, 0x2a, 0x23, 0x69, 0x47, 0x11, 0x0, 0x0, + 0x4b, 0xd0, 0x13, 0x35, 0xaa, 0x12, 0x0, 0x17, 0x4b, 0xb1, 0x59, 0x71, 0x22, 0xc7, 0xbe, 0xa8, 0x7, 0xa0, 0x13, + 0x51, 0x36, 0x6f, 0xdd, 0x86, 0xa8, 0xce, 0xfe, 0x5c, 0x2e, 0x2a, 0x39, 0x13, 0x59, 0xa9, 0x2, 0x0, 0x0, 0x4f, + 0x9c, 0x25, 0x52, 0x1, 0x65, 0x29, 0x23, 0x18, 0x0, 0x0, 0x67, 0xa, 0x11, 0x0, 0x0, 0x18, 0xbc, 0x2, 0x0, + 0x0, 0x48, 0x6d, 0x16, 0x0, 0xa, 0x4a, 0x82, 0x3b, 0xf2, 0x1e, 0xd5, 0xe6, 0x98, 0xa9, 0xf3, 0x28, 0x26, 0x11, + 0x0, 0x0, 0x32, 0x7a, 0x1c, 0x0, 0x1d, 0x43, 0x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0x2, 0x0, 0x1b, 0x31, 0xae, 0x39, 0xfd, 0x87, 0x6f, 0xc9, 0xeb, 0x1d, 0xf3, 0xf0, 0x16, 0xb1, + 0x6a, 0x55, 0x79, 0x8d, 0xda, 0x9e, 0xfb, 0xe8, 0x50, 0x67, 0xa1, 0x16, 0xe, 0xa2, 0x2, 0x0, 0x1d, 0x89, 0x35, + 0x75, 0x4, 0xd1, 0x14, 0x65, 0xb1, 0xc2, 0x48, 0x15, 0x70, 0x3b, 0x51, 0xe4, 0x8, 0x95, 0xb2, 0xb6, 0x8c, 0xd9, + 0x3e, 0x21, 0x22, 0x2c, 0x1c, 0x9a, 0xa3, 0x31, 0x2, 0x0, 0x14, 0xbd, 0x72, 0xb9, 0x4b, 0x9b, 0xf7, 0x3a, 0x26, + 0x81, 0x1c, 0x7d, 0x1a, 0x88, 0xcd, 0xc6, 0x67, 0x6d, 0xca, 0xb7, 0x7c, 0x0}; + + uint8_t buf[403] = {0}; + + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x37, 0xef, 0xed, 0x94}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xce}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc9, 0xf, 0x7e, 0xae, 0xb6, 0x9c, 0x3b, 0x6f, 0x7b, 0x8e}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xdb, 0x8, 0x10, 0x16, 0xe4, 0x73, 0x62, 0xb1, 0x8f, + 0xc3, 0xe6, 0x6f, 0x3c, 0xc4, 0xf6, 0x66, 0x3d, 0x42}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x87, 0xe0, 0x3f, 0x0, 0xa1, 0xbc, 0x86, 0x45, 0xac, 0x34, 0x3e, 0x31}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x2e, 0xe9, 0xb5, 0x59, 0x92, 0x36, 0x8c, 0x9d, 0x9, 0xcd, 0xa1, 0x4d, + 0x6f, 0xd7, 0x35, 0xba, 0x1e, 0x42, 0x5f, 0x6, 0xdb, 0xba, 0xc, 0xee}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x31, 0xae, 0x39, 0xfd, 0x87, 0x6f, 0xc9, 0xeb, 0x1d, 0xf3, 0xf0, 0x16, 0xb1, 0x6a, + 0x55, 0x79, 0x8d, 0xda, 0x9e, 0xfb, 0xe8, 0x50, 0x67, 0xa1, 0x16, 0xe, 0xa2}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x89, 0x35, 0x75, 0x4, 0xd1, 0x14, 0x65, 0xb1, 0xc2, 0x48, + 0x15, 0x70, 0x3b, 0x51, 0xe4, 0x8, 0x95, 0xb2, 0xb6, 0x8c, + 0xd9, 0x3e, 0x21, 0x22, 0x2c, 0x1c, 0x9a, 0xa3, 0x31}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xbd, 0x72, 0xb9, 0x4b, 0x9b, 0xf7, 0x3a, 0x26, 0x81, 0x1c, + 0x7d, 0x1a, 0x88, 0xcd, 0xc6, 0x67, 0x6d, 0xca, 0xb7, 0x7c}; + lwmqtt_string_t topic_filter_s9 = {20, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x11, 0xc8, 0x9, 0x61, 0x97, 0x61, 0x64, 0x25, 0x95, 0xce, 0xeb, + 0x8b, 0x2d, 0x3, 0xe0, 0x37, 0x6a, 0xa8, 0x5a, 0x45, 0x6, 0x2a}; + uint8_t bytesprops1[] = {0x4b, 0xb1, 0x59, 0x71, 0x22, 0xc7, 0xbe, 0xa8, 0x7, 0xa0, 0x13, 0x51, + 0x36, 0x6f, 0xdd, 0x86, 0xa8, 0xce, 0xfe, 0x5c, 0x2e, 0x2a, 0x39}; + uint8_t bytesprops2[] = {0x4a, 0x82, 0x3b, 0xf2, 0x1e, 0xd5, 0xe6, 0x98, 0xa9, 0xf3}; + uint8_t bytesprops3[] = {0x43, 0x76, 0xa5, 0x37, 0xdb, 0xe4, 0x9, 0x2c, 0x3, 0x2f, 0x9f, 0xb0, 0xc8, 0x28, 0xe3, + 0x48, 0x5c, 0x66, 0x20, 0xb2, 0x1c, 0x26, 0x6f, 0x8e, 0xac, 0x27, 0x44, 0xfa, 0x16}; + uint8_t bytesprops4[] = {0x83, 0x1b, 0x11, 0x6e, 0x72, 0x7f, 0xed, 0xeb, 0x1c, 0x6, 0xdc, 0xee}; + uint8_t bytesprops5[] = {0xfb, 0xc2, 0xa3, 0xd4, 0x60, 0x46, 0xa0, 0x1c, 0x35, 0x2e, 0xcf, + 0x64, 0xf1, 0x44, 0x8a, 0xf0, 0x6e, 0x1b, 0x5e, 0x2a, 0x1b, 0xae}; + uint8_t bytesprops6[] = {0xe9, 0xb, 0xf4, 0xb9, 0x7f, 0x21, 0x36, 0x83, 0xf3, 0xe8, 0x3b, 0xad, 0x81, + 0x61, 0xf2, 0xb0, 0x93, 0x8, 0xa1, 0xd1, 0x9c, 0x5a, 0xa9, 0x10, 0x2f}; -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "{\196\184\STXD\DC3\206\DC2E\138\172a\226\203\SYN\241E)", _pubPktID = 6876, _pubBody = -// "\152k\DEL:{\247\144\fs\215\252\234\162HI", _pubProps = [PropRequestProblemInformation 43,PropResponseInformation -// "\145;\DC3\221^\224\DC2\211\213\178mp\167\184-\216h",PropServerReference -// "\228\202\ACK4\177\156a\162\ETX\231j\150h\194_\220\GS\161\204E\147\245|",PropWildcardSubscriptionAvailable -// 205,PropWillDelayInterval 11586,PropSubscriptionIdentifierAvailable 90,PropRequestResponseInformation -// 157,PropRequestResponseInformation 193,PropPayloadFormatIndicator 104,PropPayloadFormatIndicator 24]} -TEST(Publish5QCTest, Encode28) { - uint8_t pkt[] = {0x3c, 0x67, 0x0, 0x12, 0x7b, 0xc4, 0xb8, 0x2, 0x44, 0x13, 0xce, 0x12, 0x45, 0x8a, 0xac, - 0x61, 0xe2, 0xcb, 0x16, 0xf1, 0x45, 0x29, 0x1a, 0xdc, 0x41, 0x17, 0x2b, 0x1a, 0x0, 0x11, - 0x91, 0x3b, 0x13, 0xdd, 0x5e, 0xe0, 0x12, 0xd3, 0xd5, 0xb2, 0x6d, 0x70, 0xa7, 0xb8, 0x2d, - 0xd8, 0x68, 0x1c, 0x0, 0x17, 0xe4, 0xca, 0x6, 0x34, 0xb1, 0x9c, 0x61, 0xa2, 0x3, 0xe7, - 0x6a, 0x96, 0x68, 0xc2, 0x5f, 0xdc, 0x1d, 0xa1, 0xcc, 0x45, 0x93, 0xf5, 0x7c, 0x28, 0xcd, - 0x18, 0x0, 0x0, 0x2d, 0x42, 0x29, 0x5a, 0x19, 0x9d, 0x19, 0xc1, 0x1, 0x68, 0x1, 0x18, - 0x98, 0x6b, 0x7f, 0x3a, 0x7b, 0xf7, 0x90, 0xc, 0x73, 0xd7, 0xfc, 0xea, 0xa2, 0x48, 0x49}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26951}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19408}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13738}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22953}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20380}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26378}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6332}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18541}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12922}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops6}}}, + }; - uint8_t buf[115] = {0}; - - uint8_t topic_bytes[] = {0x7b, 0xc4, 0xb8, 0x2, 0x44, 0x13, 0xce, 0x12, 0x45, - 0x8a, 0xac, 0x61, 0xe2, 0xcb, 0x16, 0xf1, 0x45, 0x29}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x98, 0x6b, 0x7f, 0x3a, 0x7b, 0xf7, 0x90, 0xc, 0x73, 0xd7, 0xfc, 0xea, 0xa2, 0x48, 0x49}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0x91, 0x3b, 0x13, 0xdd, 0x5e, 0xe0, 0x12, 0xd3, 0xd5, - 0xb2, 0x6d, 0x70, 0xa7, 0xb8, 0x2d, 0xd8, 0x68}; - uint8_t bytesprops1[] = {0xe4, 0xca, 0x6, 0x34, 0xb1, 0x9c, 0x61, 0xa2, 0x3, 0xe7, 0x6a, 0x96, - 0x68, 0xc2, 0x5f, 0xdc, 0x1d, 0xa1, 0xcc, 0x45, 0x93, 0xf5, 0x7c}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4596, 10, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12163 [("\r\156\"+\229.^L8\n\226%&\152\200\143De",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\233=P\128\f\151\147O\193\209\230l\183\&7Z\153\201\152z:\237\&8\STX\176Z\187\245\253",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\154\238U\255\128\128\129\222",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\178\STX7\173\221\210\128$\v\SOHQ\223\172\129",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("J\179\253\197\215CRg\185\217\STX1\223\&5\213\&17\245y\\h\154\DC4Jz\238\168\243\DC3!",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("G-\208\165h?\SO\131[\DC1",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\193\175\185E?\229\197iQ\ETX\234\174%\176\197\223\197\DLE\233M\211\250X\185wU",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropUserProperty +// "\199\SOH\DC4\"W\246\183`Q\194\223\255\154\197K\148\241o#B\212\156\133\203\193\248`\"" +// "x\ESC\ETX4\207\FS\NAK\208\RSy",PropMaximumQoS 201,PropWillDelayInterval 10233,PropServerKeepAlive +// 20327,PropRequestProblemInformation 208,PropServerReference +// "\171\ETX\253Y\160\DC2\DC3n",PropRequestProblemInformation 23,PropSessionExpiryInterval +// 11687,PropMessageExpiryInterval 21409,PropContentType +// "\136\199\FSr\187\&1\187\225\&2Wu#",PropAssignedClientIdentifier +// "\SO\b\183\194\136\ENQW!\DC2\DC3\202\216[\200\148\168",PropMaximumPacketSize 20756,PropReceiveMaximum +// 23959,PropReceiveMaximum 15319,PropSubscriptionIdentifier 22,PropSubscriptionIdentifier +// 2,PropWildcardSubscriptionAvailable 114,PropReceiveMaximum 5175,PropAssignedClientIdentifier +// "a:\164\135\SYNk\182m\USl=\252\201\&8O\183\244p7\205pN\197\STX\188e\164\160\211",PropWildcardSubscriptionAvailable +// 0,PropMaximumQoS 212,PropSubscriptionIdentifierAvailable 170,PropRequestProblemInformation 179,PropWillDelayInterval +// 2439,PropRetainAvailable 181,PropServerReference "'\252\ACK\177",PropResponseInformation +// "\133\243",PropWildcardSubscriptionAvailable 194,PropMessageExpiryInterval 30882,PropAuthenticationMethod +// "\175\DC1\SUB\181\187=Q\225\SYN\135\&3wYc"] +TEST(Subscribe5QCTest, Encode19) { + uint8_t pkt[] = { + 0x82, 0xf6, 0x2, 0x2f, 0x83, 0xd7, 0x1, 0x26, 0x0, 0x1c, 0xc7, 0x1, 0x14, 0x22, 0x57, 0xf6, 0xb7, 0x60, 0x51, + 0xc2, 0xdf, 0xff, 0x9a, 0xc5, 0x4b, 0x94, 0xf1, 0x6f, 0x23, 0x42, 0xd4, 0x9c, 0x85, 0xcb, 0xc1, 0xf8, 0x60, 0x22, + 0x0, 0xa, 0x78, 0x1b, 0x3, 0x34, 0xcf, 0x1c, 0x15, 0xd0, 0x1e, 0x79, 0x24, 0xc9, 0x18, 0x0, 0x0, 0x27, 0xf9, + 0x13, 0x4f, 0x67, 0x17, 0xd0, 0x1c, 0x0, 0x8, 0xab, 0x3, 0xfd, 0x59, 0xa0, 0x12, 0x13, 0x6e, 0x17, 0x17, 0x11, + 0x0, 0x0, 0x2d, 0xa7, 0x2, 0x0, 0x0, 0x53, 0xa1, 0x3, 0x0, 0xc, 0x88, 0xc7, 0x1c, 0x72, 0xbb, 0x31, 0xbb, + 0xe1, 0x32, 0x57, 0x75, 0x23, 0x12, 0x0, 0x10, 0xe, 0x8, 0xb7, 0xc2, 0x88, 0x5, 0x57, 0x21, 0x12, 0x13, 0xca, + 0xd8, 0x5b, 0xc8, 0x94, 0xa8, 0x27, 0x0, 0x0, 0x51, 0x14, 0x21, 0x5d, 0x97, 0x21, 0x3b, 0xd7, 0xb, 0x16, 0xb, + 0x2, 0x28, 0x72, 0x21, 0x14, 0x37, 0x12, 0x0, 0x1d, 0x61, 0x3a, 0xa4, 0x87, 0x16, 0x6b, 0xb6, 0x6d, 0x1f, 0x6c, + 0x3d, 0xfc, 0xc9, 0x38, 0x4f, 0xb7, 0xf4, 0x70, 0x37, 0xcd, 0x70, 0x4e, 0xc5, 0x2, 0xbc, 0x65, 0xa4, 0xa0, 0xd3, + 0x28, 0x0, 0x24, 0xd4, 0x29, 0xaa, 0x17,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0xdf, 0xc5, 0x10, 0xe9, 0x4d, 0xd3, 0xfa, 0x58, 0xb9, 0x77, 0x55, 0x2}; + + uint8_t buf[387] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xd, 0x9c, 0x22, 0x2b, 0xe5, 0x2e, 0x5e, 0x4c, 0x38, + 0xa, 0xe2, 0x25, 0x26, 0x98, 0xc8, 0x8f, 0x44, 0x65}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xe9, 0x3d, 0x50, 0x80, 0xc, 0x97, 0x93, 0x4f, 0xc1, 0xd1, + 0xe6, 0x6c, 0xb7, 0x37, 0x5a, 0x99, 0xc9, 0x98, 0x7a, 0x3a, + 0xed, 0x38, 0x2, 0xb0, 0x5a, 0xbb, 0xf5, 0xfd}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x9a, 0xee, 0x55, 0xff, 0x80, 0x80, 0x81, 0xde}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb2, 0x2, 0x37, 0xad, 0xdd, 0xd2, 0x80, 0x24, 0xb, 0x1, 0x51, 0xdf, 0xac, 0x81}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x4a, 0xb3, 0xfd, 0xc5, 0xd7, 0x43, 0x52, 0x67, 0xb9, 0xd9, + 0x2, 0x31, 0xdf, 0x35, 0xd5, 0x31, 0x37, 0xf5, 0x79, 0x5c, + 0x68, 0x9a, 0x14, 0x4a, 0x7a, 0xee, 0xa8, 0xf3, 0x13, 0x21}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x47, 0x2d, 0xd0, 0xa5, 0x68, 0x3f, 0xe, 0x83, 0x5b, 0x11}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc1, 0xaf, 0xb9, 0x45, 0x3f, 0xe5, 0xc5, 0x69, 0x51, 0x3, 0xea, 0xae, 0x25, + 0xb0, 0xc5, 0xdf, 0xc5, 0x10, 0xe9, 0x4d, 0xd3, 0xfa, 0x58, 0xb9, 0x77, 0x55}; + lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t bytesprops1[] = {0x78, 0x1b, 0x3, 0x34, 0xcf, 0x1c, 0x15, 0xd0, 0x1e, 0x79}; + uint8_t bytesprops0[] = {0xc7, 0x1, 0x14, 0x22, 0x57, 0xf6, 0xb7, 0x60, 0x51, 0xc2, 0xdf, 0xff, 0x9a, 0xc5, + 0x4b, 0x94, 0xf1, 0x6f, 0x23, 0x42, 0xd4, 0x9c, 0x85, 0xcb, 0xc1, 0xf8, 0x60, 0x22}; + uint8_t bytesprops2[] = {0xab, 0x3, 0xfd, 0x59, 0xa0, 0x12, 0x13, 0x6e}; + uint8_t bytesprops3[] = {0x88, 0xc7, 0x1c, 0x72, 0xbb, 0x31, 0xbb, 0xe1, 0x32, 0x57, 0x75, 0x23}; + uint8_t bytesprops4[] = {0xe, 0x8, 0xb7, 0xc2, 0x88, 0x5, 0x57, 0x21, 0x12, 0x13, 0xca, 0xd8, 0x5b, 0xc8, 0x94, 0xa8}; + uint8_t bytesprops5[] = {0x61, 0x3a, 0xa4, 0x87, 0x16, 0x6b, 0xb6, 0x6d, 0x1f, 0x6c, 0x3d, 0xfc, 0xc9, 0x38, 0x4f, + 0xb7, 0xf4, 0x70, 0x37, 0xcd, 0x70, 0x4e, 0xc5, 0x2, 0xbc, 0x65, 0xa4, 0xa0, 0xd3}; + uint8_t bytesprops6[] = {0x27, 0xfc, 0x6, 0xb1}; + uint8_t bytesprops7[] = {0x85, 0xf3}; + uint8_t bytesprops8[] = {0xaf, 0x11, 0x1a, 0xb5, 0xbb, 0x3d, 0x51, 0xe1, 0x16, 0x87, 0x33, 0x77, 0x59, 0x63}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11586}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10233}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20327}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11687}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21409}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20756}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23959}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15319}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5175}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2439}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30882}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6876, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12163, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 21672 [(":f\201\245\150t\153",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("g^\195\215\\\138\194\147\188\181W\136",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\163\181\241IK\nA\212\254d\216",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [PropCorrelationData "\US\225\249\235f=\176\228\234.",PropReasonString +// "-A\ACKM\206",PropRequestResponseInformation 8,PropUserProperty +// "h\r\185e\243\196\159\a\191\"!\160\193\DC46\128A\185,)gx\190" +// "\146,\136=~\194G\ri\ESC\ENQE\132\SYN\242\242G",PropMessageExpiryInterval 32206,PropMessageExpiryInterval +// 11439,PropUserProperty "t\252\251\235\172\255\234\204\b\SYN\170\148'\184z\t\139\212&\150H\\\184\223" +// "jS\144\130\ESCx\140\GS\221O\182\EM\ESCX\156",PropReceiveMaximum 19536,PropAssignedClientIdentifier +// "ij\232z+\133\ETB]]\148-,Ai\129\205\172\195d\175W$\236O",PropUserProperty +// "\239\192\\\153\166\ACK\ENQ_\224\131^k3\221\137\137\251B" +// "\203\NAK\180\150\USWn\\\235NF@\220\228\206=*",PropTopicAliasMaximum 13940,PropAssignedClientIdentifier +// "N0~\ETX;\185!S\STX\210M\148\186\206\SUB_",PropRequestResponseInformation 88,PropTopicAliasMaximum +// 12386,PropMaximumPacketSize 7196,PropAuthenticationMethod +// "\166\231p\217\241\205&\167Os\240\US.\151\197",PropTopicAliasMaximum 16731,PropAuthenticationMethod +// "+\175\&7c\141[\EM\204\202\222",PropSubscriptionIdentifierAvailable 86,PropAuthenticationData +// "S\214\FS\243\b\139Qt\130\132\ENQ\206\144\STX\142v\STX\DC1\197o\220E\131",PropCorrelationData +// "\244H\174",PropMaximumPacketSize 4306,PropMessageExpiryInterval 10977,PropMessageExpiryInterval +// 14925,PropRequestProblemInformation 220] +TEST(Subscribe5QCTest, Encode20) { + uint8_t pkt[] = { + 0x82, 0xe0, 0x2, 0x54, 0xa8, 0xb5, 0x2, 0x9, 0x0, 0xa, 0x1f, 0xe1, 0xf9, 0xeb, 0x66, 0x3d, 0xb0, 0xe4, 0xea, + 0x2e, 0x1f, 0x0, 0x5, 0x2d, 0x41, 0x6, 0x4d, 0xce, 0x19, 0x8, 0x26, 0x0, 0x17, 0x68, 0xd, 0xb9, 0x65, 0xf3, + 0xc4, 0x9f, 0x7, 0xbf, 0x22, 0x21, 0xa0, 0xc1, 0x14, 0x36, 0x80, 0x41, 0xb9, 0x2c, 0x29, 0x67, 0x78, 0xbe, 0x0, + 0x11, 0x92, 0x2c, 0x88, 0x3d, 0x7e, 0xc2, 0x47, 0xd, 0x69, 0x1b, 0x5, 0x45, 0x84, 0x16, 0xf2, 0xf2, 0x47, 0x2, + 0x0, 0x0, 0x7d, 0xce, 0x2, 0x0, 0x0, 0x2c, 0xaf, 0x26, 0x0, 0x18, 0x74, 0xfc, 0xfb, 0xeb, 0xac, 0xff, 0xea, + 0xcc, 0x8, 0x16, 0xaa, 0x94, 0x27, 0xb8, 0x7a, 0x9, 0x8b, 0xd4, 0x26, 0x96, 0x48, 0x5c, 0xb8, 0xdf, 0x0, 0xf, + 0x6a, 0x53, 0x90, 0x82, 0x1b, 0x78, 0x8c, 0x1d, 0xdd, 0x4f, 0xb6, 0x19, 0x1b, 0x58, 0x9c, 0x21, 0x4c, 0x50, 0x12, + 0x0, 0x18, 0x69, 0x6a, 0xe8, 0x7a, 0x2b, 0x85, 0x17, 0x5d, 0x5d, 0x94, 0x2d, 0x2c, 0x41, 0x69, 0x81, 0xcd, 0xac, + 0xc3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, 0x0, + 0xb, 0xa3, 0xb5, 0xf1, 0x49, 0x4b, 0xa, 0x41, 0xd4, 0xfe, 0x64, 0xd8, 0x0}; -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\STXa7W", _pubPktID = 0, _pubBody = -// "\169#\136\219\142\&7\196\149\&4d\246j\146\254\188ch\168$T\135Q*\170\138\DC3!", _pubProps = [PropReasonString -// "",PropReasonString "@\t\140\194\183\210\222\194 -// f\243\tX\234\&8k\151O\207\EM\ETBV\197\&4\f\245\203",PropWildcardSubscriptionAvailable 80,PropMaximumPacketSize -// 28790,PropWildcardSubscriptionAvailable 38,PropPayloadFormatIndicator 125,PropTopicAlias 6534,PropTopicAliasMaximum -// 11429,PropPayloadFormatIndicator 157,PropSessionExpiryInterval 24063,PropServerReference -// "\183I\FS!xyu\173\158_\237\173\EOTF\r/\219\b\167O\132\228",PropMaximumPacketSize 23219,PropWillDelayInterval -// 24499,PropServerReference "\240\217*\GS\132=\195H!;\223\225(",PropRequestResponseInformation 169,PropServerKeepAlive -// 6359,PropResponseInformation -// "{\224^\223\DLE:\253zb]>\DC2#\208\DLE\ENQ\168\SO+\148L\244\185\184",PropSharedSubscriptionAvailable -// 254,PropPayloadFormatIndicator 153]} -TEST(Publish5QCTest, Encode29) { - uint8_t pkt[] = {0x38, 0xb3, 0x1, 0x0, 0x4, 0x2, 0x61, 0x37, 0x57, 0x90, 0x1, 0x1f, 0x0, 0x0, 0x1f, 0x0, 0x1b, - 0x40, 0x9, 0x8c, 0xc2, 0xb7, 0xd2, 0xde, 0xc2, 0x20, 0x66, 0xf3, 0x9, 0x58, 0xea, 0x38, 0x6b, 0x97, - 0x4f, 0xcf, 0x19, 0x17, 0x56, 0xc5, 0x34, 0xc, 0xf5, 0xcb, 0x28, 0x50, 0x27, 0x0, 0x0, 0x70, 0x76, - 0x28, 0x26, 0x1, 0x7d, 0x23, 0x19, 0x86, 0x22, 0x2c, 0xa5, 0x1, 0x9d, 0x11, 0x0, 0x0, 0x5d, 0xff, - 0x1c, 0x0, 0x16, 0xb7, 0x49, 0x1c, 0x21, 0x78, 0x79, 0x75, 0xad, 0x9e, 0x5f, 0xed, 0xad, 0x4, 0x46, - 0xd, 0x2f, 0xdb, 0x8, 0xa7, 0x4f, 0x84, 0xe4, 0x27, 0x0, 0x0, 0x5a, 0xb3, 0x18, 0x0, 0x0, 0x5f, - 0xb3, 0x1c, 0x0, 0xd, 0xf0, 0xd9, 0x2a, 0x1d, 0x84, 0x3d, 0xc3, 0x48, 0x21, 0x3b, 0xdf, 0xe1, 0x28, - 0x19, 0xa9, 0x13, 0x18, 0xd7, 0x1a, 0x0, 0x18, 0x7b, 0xe0, 0x5e, 0xdf, 0x10, 0x3a, 0xfd, 0x7a, 0x62, - 0x5d, 0x3e, 0x12, 0x23, 0xd0, 0x10, 0x5, 0xa8, 0xe, 0x2b, 0x94, 0x4c, 0xf4, 0xb9, 0xb8, 0x2a, 0xfe, - 0x1, 0x99, 0xa9, 0x23, 0x88, 0xdb, 0x8e, 0x37, 0xc4, 0x95, 0x34, 0x64, 0xf6, 0x6a, 0x92, 0xfe, 0xbc, - 0x63, 0x68, 0xa8, 0x24, 0x54, 0x87, 0x51, 0x2a, 0xaa, 0x8a, 0x13, 0x21}; - - uint8_t buf[192] = {0}; - - uint8_t topic_bytes[] = {0x2, 0x61, 0x37, 0x57}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xa9, 0x23, 0x88, 0xdb, 0x8e, 0x37, 0xc4, 0x95, 0x34, 0x64, 0xf6, 0x6a, 0x92, 0xfe, - 0xbc, 0x63, 0x68, 0xa8, 0x24, 0x54, 0x87, 0x51, 0x2a, 0xaa, 0x8a, 0x13, 0x21}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + uint8_t buf[365] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x40, 0x9, 0x8c, 0xc2, 0xb7, 0xd2, 0xde, 0xc2, 0x20, 0x66, 0xf3, 0x9, 0x58, 0xea, - 0x38, 0x6b, 0x97, 0x4f, 0xcf, 0x19, 0x17, 0x56, 0xc5, 0x34, 0xc, 0xf5, 0xcb}; - uint8_t bytesprops2[] = {0xb7, 0x49, 0x1c, 0x21, 0x78, 0x79, 0x75, 0xad, 0x9e, 0x5f, 0xed, - 0xad, 0x4, 0x46, 0xd, 0x2f, 0xdb, 0x8, 0xa7, 0x4f, 0x84, 0xe4}; - uint8_t bytesprops3[] = {0xf0, 0xd9, 0x2a, 0x1d, 0x84, 0x3d, 0xc3, 0x48, 0x21, 0x3b, 0xdf, 0xe1, 0x28}; - uint8_t bytesprops4[] = {0x7b, 0xe0, 0x5e, 0xdf, 0x10, 0x3a, 0xfd, 0x7a, 0x62, 0x5d, 0x3e, 0x12, - 0x23, 0xd0, 0x10, 0x5, 0xa8, 0xe, 0x2b, 0x94, 0x4c, 0xf4, 0xb9, 0xb8}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x3a, 0x66, 0xc9, 0xf5, 0x96, 0x74, 0x99}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x67, 0x5e, 0xc3, 0xd7, 0x5c, 0x8a, 0xc2, 0x93, 0xbc, 0xb5, 0x57, 0x88}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa3, 0xb5, 0xf1, 0x49, 0x4b, 0xa, 0x41, 0xd4, 0xfe, 0x64, 0xd8}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x1f, 0xe1, 0xf9, 0xeb, 0x66, 0x3d, 0xb0, 0xe4, 0xea, 0x2e}; + uint8_t bytesprops1[] = {0x2d, 0x41, 0x6, 0x4d, 0xce}; + uint8_t bytesprops3[] = {0x92, 0x2c, 0x88, 0x3d, 0x7e, 0xc2, 0x47, 0xd, 0x69, + 0x1b, 0x5, 0x45, 0x84, 0x16, 0xf2, 0xf2, 0x47}; + uint8_t bytesprops2[] = {0x68, 0xd, 0xb9, 0x65, 0xf3, 0xc4, 0x9f, 0x7, 0xbf, 0x22, 0x21, 0xa0, + 0xc1, 0x14, 0x36, 0x80, 0x41, 0xb9, 0x2c, 0x29, 0x67, 0x78, 0xbe}; + uint8_t bytesprops5[] = {0x6a, 0x53, 0x90, 0x82, 0x1b, 0x78, 0x8c, 0x1d, 0xdd, 0x4f, 0xb6, 0x19, 0x1b, 0x58, 0x9c}; + uint8_t bytesprops4[] = {0x74, 0xfc, 0xfb, 0xeb, 0xac, 0xff, 0xea, 0xcc, 0x8, 0x16, 0xaa, 0x94, + 0x27, 0xb8, 0x7a, 0x9, 0x8b, 0xd4, 0x26, 0x96, 0x48, 0x5c, 0xb8, 0xdf}; + uint8_t bytesprops6[] = {0x69, 0x6a, 0xe8, 0x7a, 0x2b, 0x85, 0x17, 0x5d, 0x5d, 0x94, 0x2d, 0x2c, + 0x41, 0x69, 0x81, 0xcd, 0xac, 0xc3, 0x64, 0xaf, 0x57, 0x24, 0xec, 0x4f}; + uint8_t bytesprops8[] = {0xcb, 0x15, 0xb4, 0x96, 0x1f, 0x57, 0x6e, 0x5c, 0xeb, + 0x4e, 0x46, 0x40, 0xdc, 0xe4, 0xce, 0x3d, 0x2a}; + uint8_t bytesprops7[] = {0xef, 0xc0, 0x5c, 0x99, 0xa6, 0x6, 0x5, 0x5f, 0xe0, + 0x83, 0x5e, 0x6b, 0x33, 0xdd, 0x89, 0x89, 0xfb, 0x42}; + uint8_t bytesprops9[] = {0x4e, 0x30, 0x7e, 0x3, 0x3b, 0xb9, 0x21, 0x53, + 0x2, 0xd2, 0x4d, 0x94, 0xba, 0xce, 0x1a, 0x5f}; + uint8_t bytesprops10[] = {0xa6, 0xe7, 0x70, 0xd9, 0xf1, 0xcd, 0x26, 0xa7, 0x4f, 0x73, 0xf0, 0x1f, 0x2e, 0x97, 0xc5}; + uint8_t bytesprops11[] = {0x2b, 0xaf, 0x37, 0x63, 0x8d, 0x5b, 0x19, 0xcc, 0xca, 0xde}; + uint8_t bytesprops12[] = {0x53, 0xd6, 0x1c, 0xf3, 0x8, 0x8b, 0x51, 0x74, 0x82, 0x84, 0x5, 0xce, + 0x90, 0x2, 0x8e, 0x76, 0x2, 0x11, 0xc5, 0x6f, 0xdc, 0x45, 0x83}; + uint8_t bytesprops13[] = {0xf4, 0x48, 0xae}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28790}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6534}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11429}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24063}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23219}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24499}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6359}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops2}, .v = {17, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32206}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11439}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops4}, .v = {15, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19536}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops7}, .v = {17, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13940}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12386}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7196}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16731}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4306}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10977}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14925}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21672, 3, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 2811 [("\232\155/\190\204\180\EOT\185\187J",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\204\150\224\190\140\164\182\211\159\f`\DC1",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\246te&\248u\229%^L\158\FSG\SYNQPL\237b\SOH\240\185",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k\ETX\f\tX\164\ETX",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerKeepAlive +// 22588,PropServerReference "",PropResponseTopic "\SO\214\\kc",PropRequestProblemInformation 203,PropServerReference +// "u\190\167\137\DC2\205v\US\145 \215\181h\f",PropResponseInformation "\236ri\GS\150\151g1\194i\199 +// \252\140H9\174\204L\176\210tH\226\&4\213\147",PropMaximumPacketSize 17747,PropAuthenticationData +// "\139\f\232/3`\181\213`\253",PropAuthenticationData +// "20^\232]\215\251\227\&1\197_P5\"\144\SI\240#3RT\143\USj\202\DC1\174\250",PropAuthenticationMethod +// "3\185_\193\138\156\205\142=(k",PropSubscriptionIdentifierAvailable 30,PropResponseInformation +// "BE\229\205:\193",PropAssignedClientIdentifier +// "\129R\153C!\133}\220\131z\173m\ESC\239\201\EOT\255\239\ETXi\n\233",PropCorrelationData +// "\152-\152~\157\\",PropRequestResponseInformation 213,PropAuthenticationMethod +// "l\217\159r\ETXY\161\211\145\203\244\138\164\177%tv\203\&6\136\ETX\209\228\216\136\221Xy\179",PropAuthenticationMethod +// "\205#\141\&9\185\152\DLEm\RS\RS\231\239\STXZ\227O9t\167}\136\212\227>\191\128\EMC\196!",PropMessageExpiryInterval +// 7170,PropMaximumQoS 100,PropMessageExpiryInterval 3938,PropRequestResponseInformation 12] +TEST(Subscribe5QCTest, Encode21) { + uint8_t pkt[] = { + 0x82, 0xbf, 0x2, 0xa, 0xfb, 0xfc, 0x1, 0x13, 0x58, 0x3c, 0x1c, 0x0, 0x0, 0x8, 0x0, 0x5, 0xe, 0xd6, 0x5c, + 0x6b, 0x63, 0x17, 0xcb, 0x1c, 0x0, 0xe, 0x75, 0xbe, 0xa7, 0x89, 0x12, 0xcd, 0x76, 0x1f, 0x91, 0x20, 0xd7, 0xb5, + 0x68, 0xc, 0x1a, 0x0, 0x1b, 0xec, 0x72, 0x69, 0x1d, 0x96, 0x97, 0x67, 0x31, 0xc2, 0x69, 0xc7, 0x20, 0xfc, 0x8c, + 0x48, 0x39, 0xae, 0xcc, 0x4c, 0xb0, 0xd2, 0x74, 0x48, 0xe2, 0x34, 0xd5, 0x93, 0x27, 0x0, 0x0, 0x45, 0x53, 0x16, + 0x0, 0xa, 0x8b, 0xc, 0xe8, 0x2f, 0x33, 0x60, 0xb5, 0xd5, 0x60, 0xfd, 0x16, 0x0, 0x1c, 0x32, 0x30, 0x5e, 0xe8, + 0x5d, 0xd7, 0xfb, 0xe3, 0x31,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x11, 0x2, 0x0, 0x16, 0xf6, 0x74, 0x65, 0x26, 0xf8, 0x75, 0xe5, 0x25, 0x5e, 0x4c, 0x9e, 0x1c, 0x47, 0x16, 0x51, + 0x50, 0x4c, 0xed, 0x62, 0x1, 0xf0, 0xb9, 0x0, 0x0, 0x7, 0x6b, 0x3, 0xc, 0x9, 0x58, 0xa4, 0x3, 0x1}; + + uint8_t buf[332] = {0}; + + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xe8, 0x9b, 0x2f, 0xbe, 0xcc, 0xb4, 0x4, 0xb9, 0xbb, 0x4a}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xcc, 0x96, 0xe0, 0xbe, 0x8c, 0xa4, 0xb6, 0xd3, 0x9f, 0xc, 0x60, 0x11}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf6, 0x74, 0x65, 0x26, 0xf8, 0x75, 0xe5, 0x25, 0x5e, 0x4c, 0x9e, + 0x1c, 0x47, 0x16, 0x51, 0x50, 0x4c, 0xed, 0x62, 0x1, 0xf0, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6b, 0x3, 0xc, 0x9, 0x58, 0xa4, 0x3}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xe, 0xd6, 0x5c, 0x6b, 0x63}; + uint8_t bytesprops2[] = {0x75, 0xbe, 0xa7, 0x89, 0x12, 0xcd, 0x76, 0x1f, 0x91, 0x20, 0xd7, 0xb5, 0x68, 0xc}; + uint8_t bytesprops3[] = {0xec, 0x72, 0x69, 0x1d, 0x96, 0x97, 0x67, 0x31, 0xc2, 0x69, 0xc7, 0x20, 0xfc, 0x8c, + 0x48, 0x39, 0xae, 0xcc, 0x4c, 0xb0, 0xd2, 0x74, 0x48, 0xe2, 0x34, 0xd5, 0x93}; + uint8_t bytesprops4[] = {0x8b, 0xc, 0xe8, 0x2f, 0x33, 0x60, 0xb5, 0xd5, 0x60, 0xfd}; + uint8_t bytesprops5[] = {0x32, 0x30, 0x5e, 0xe8, 0x5d, 0xd7, 0xfb, 0xe3, 0x31, 0xc5, 0x5f, 0x50, 0x35, 0x22, + 0x90, 0xf, 0xf0, 0x23, 0x33, 0x52, 0x54, 0x8f, 0x1f, 0x6a, 0xca, 0x11, 0xae, 0xfa}; + uint8_t bytesprops6[] = {0x33, 0xb9, 0x5f, 0xc1, 0x8a, 0x9c, 0xcd, 0x8e, 0x3d, 0x28, 0x6b}; + uint8_t bytesprops7[] = {0x42, 0x45, 0xe5, 0xcd, 0x3a, 0xc1}; + uint8_t bytesprops8[] = {0x81, 0x52, 0x99, 0x43, 0x21, 0x85, 0x7d, 0xdc, 0x83, 0x7a, 0xad, + 0x6d, 0x1b, 0xef, 0xc9, 0x4, 0xff, 0xef, 0x3, 0x69, 0xa, 0xe9}; + uint8_t bytesprops9[] = {0x98, 0x2d, 0x98, 0x7e, 0x9d, 0x5c}; + uint8_t bytesprops10[] = {0x6c, 0xd9, 0x9f, 0x72, 0x3, 0x59, 0xa1, 0xd3, 0x91, 0xcb, 0xf4, 0x8a, 0xa4, 0xb1, 0x25, + 0x74, 0x76, 0xcb, 0x36, 0x88, 0x3, 0xd1, 0xe4, 0xd8, 0x88, 0xdd, 0x58, 0x79, 0xb3}; + uint8_t bytesprops11[] = {0xcd, 0x23, 0x8d, 0x39, 0xb9, 0x98, 0x10, 0x6d, 0x1e, 0x1e, 0xe7, 0xef, 0x2, 0x5a, 0xe3, + 0x4f, 0x39, 0x74, 0xa7, 0x7d, 0x88, 0xd4, 0xe3, 0x3e, 0xbf, 0x80, 0x19, 0x43, 0xc4, 0x21}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22588}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17747}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7170}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3938}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 12}}, + }; -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "Q\201\132\175[\206\183.\204\200p\224X\173\163MF\ETB\251\223T~\f\bW\241\179\180", _pubPktID = 2085, _pubBody = -// "\240\236\155\SOp\221\217'\225\163K\128", _pubProps = [PropSessionExpiryInterval 29496,PropResponseInformation -// "\155\EOTAK\NUL\174\220,K]i\DC1\157\&1\136\251r\168Z]\n\189\240h\152\EOT",PropResponseInformation -// "\189\243\170W\221\129\214\162\202\250d",PropTopicAliasMaximum 19828,PropRequestProblemInformation 123,PropTopicAlias -// 29886,PropSharedSubscriptionAvailable 149,PropTopicAlias 9028,PropAuthenticationMethod -// "\RS\217\243B\169\129\173\239\154",PropServerReference -// "\162\158\238nS\SI.\161\&9\195\179\184\ETB\131\141K3\172\174;y\160\SUBh",PropSubscriptionIdentifier -// 30,PropResponseTopic "\f*\191\179\193\251\132g\150MW\200\138\202",PropUserProperty "\SUB&k" -// "\247R\"\156\151)\150\DC3\156Mn\STX",PropMessageExpiryInterval 25601,PropMaximumPacketSize 30013,PropServerKeepAlive -// 2730,PropRequestProblemInformation 204,PropServerReference "z\169\217\248\202\183)\170",PropResponseTopic -// "~\213\169\&6Q\150\138\DC1\146\189Z\157\230\193\178\152\252\149\218\217",PropTopicAlias 3653,PropMaximumPacketSize -// 11018,PropRequestProblemInformation 73,PropTopicAliasMaximum 20508,PropAuthenticationMethod "\247\STX -// \138YJ\227\NAKF\137",PropSubscriptionIdentifierAvailable 13]} -TEST(Publish5QCTest, Encode30) { + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2811, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 27615 [("\NAK\134\219\&6;\150\&1UX\155\237e\170\221",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("D\188\171\141\181i\189E\145\165\209^\172\DC3\184\&4\DC3\GS\221\USd\169UZ\156]\218",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("U\197\163\225\242\DELe\225y\183n'_\168\130\EOTv\134DS\164\148\vc=\226\240\215",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("%\220\143Z\STX\254s5\230\248\161\215\251k\222j2\132\174X\243\199\DC1\147\231",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\230\199yn\147I\171\f\206\152\247\ACK\246\205\&7i>7\137\ETXi",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("YLH\ETXb\224\237\198\151j\195\234\238",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\NUL4\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1})] [PropReceiveMaximum 3944,PropResponseTopic "y`\151\a\136\219Y0x\163\134\148\250 +// \209}\231",PropRequestProblemInformation 237,PropCorrelationData +// "\139\170\209\162\177n\149\NUL\DC4\ETB\142\183\175\202\234\169m\138\167a0\204\147\161\242\200\185\250\146\204",PropTopicAliasMaximum +// 32369,PropWildcardSubscriptionAvailable 198,PropMaximumPacketSize 19095,PropAssignedClientIdentifier +// "8L",PropServerReference +// "\225\SOH\ESC\NAK\167\162h?[\tfo\130F\251\227\214\&7J\EOT_\184\ENQ\136\193\223\157+",PropSubscriptionIdentifierAvailable +// 244,PropReasonString "\170V\146\DEL\147R}}\129\193\164\143\197\165[\225.%\156\&5R\213\194",PropUserProperty +// "\190\196\144y\243\201\161I\NULy\GS\234\251_(\242\US\221q2@\222\186\189x\189\129" "\201X\n +// \182\220P",PropWillDelayInterval 4591,PropSubscriptionIdentifierAvailable 212,PropResponseInformation +// "\ETXdcIt\a\GS\GSsp_BO",PropRequestProblemInformation 141,PropWillDelayInterval 26969,PropRequestProblemInformation +// 7,PropCorrelationData "\162\137+6\186\161V\133(\158\156\US\DC2`\207FQ\166\233>\224S\NUL\218R",PropServerReference +// "\SOH\184O_\237\167=\f\223\243Q\ETB\252\154\FSu\ETB>\151\219\131N\239l",PropRetainAvailable 116,PropServerKeepAlive +// 14370,PropTopicAlias 352,PropServerReference +// "\NUL\NUL8d\145\245\148\161\DC1\153N\183\129\172_\SYN\214.\200*=\189\142\DC1\150kL4",PropCorrelationData +// "\179{g0\EOT\195\129t\169_2\202y\255~-\239\254G\DC1+\EOT",PropWillDelayInterval 23938,PropMaximumQoS +// 131,PropWildcardSubscriptionAvailable 137,PropServerReference +// "?\SI\151S\130\GS$>(\140~\DLE\158$f(A\210'\132\&6",PropTopicAlias 20026] +TEST(Subscribe5QCTest, Encode22) { uint8_t pkt[] = { - 0x3d, 0x86, 0x2, 0x0, 0x1c, 0x51, 0xc9, 0x84, 0xaf, 0x5b, 0xce, 0xb7, 0x2e, 0xcc, 0xc8, 0x70, 0xe0, 0x58, 0xad, - 0xa3, 0x4d, 0x46, 0x17, 0xfb, 0xdf, 0x54, 0x7e, 0xc, 0x8, 0x57, 0xf1, 0xb3, 0xb4, 0x8, 0x25, 0xd8, 0x1, 0x11, - 0x0, 0x0, 0x73, 0x38, 0x1a, 0x0, 0x1a, 0x9b, 0x4, 0x41, 0x4b, 0x0, 0xae, 0xdc, 0x2c, 0x4b, 0x5d, 0x69, 0x11, - 0x9d, 0x31, 0x88, 0xfb, 0x72, 0xa8, 0x5a, 0x5d, 0xa, 0xbd, 0xf0, 0x68, 0x98, 0x4,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xdd, 0xd9, 0x27, 0xe1, 0xa3, 0x4b, 0x80}; - - uint8_t buf[275] = {0}; - - uint8_t topic_bytes[] = {0x51, 0xc9, 0x84, 0xaf, 0x5b, 0xce, 0xb7, 0x2e, 0xcc, 0xc8, 0x70, 0xe0, 0x58, 0xad, - 0xa3, 0x4d, 0x46, 0x17, 0xfb, 0xdf, 0x54, 0x7e, 0xc, 0x8, 0x57, 0xf1, 0xb3, 0xb4}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xf0, 0xec, 0x9b, 0xe, 0x70, 0xdd, 0xd9, 0x27, 0xe1, 0xa3, 0x4b, 0x80}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; - - uint8_t bytesprops0[] = {0x9b, 0x4, 0x41, 0x4b, 0x0, 0xae, 0xdc, 0x2c, 0x4b, 0x5d, 0x69, 0x11, 0x9d, - 0x31, 0x88, 0xfb, 0x72, 0xa8, 0x5a, 0x5d, 0xa, 0xbd, 0xf0, 0x68, 0x98, 0x4}; - uint8_t bytesprops1[] = {0xbd, 0xf3, 0xaa, 0x57, 0xdd, 0x81, 0xd6, 0xa2, 0xca, 0xfa, 0x64}; - uint8_t bytesprops2[] = {0x1e, 0xd9, 0xf3, 0x42, 0xa9, 0x81, 0xad, 0xef, 0x9a}; - uint8_t bytesprops3[] = {0xa2, 0x9e, 0xee, 0x6e, 0x53, 0xf, 0x2e, 0xa1, 0x39, 0xc3, 0xb3, 0xb8, - 0x17, 0x83, 0x8d, 0x4b, 0x33, 0xac, 0xae, 0x3b, 0x79, 0xa0, 0x1a, 0x68}; - uint8_t bytesprops4[] = {0xc, 0x2a, 0xbf, 0xb3, 0xc1, 0xfb, 0x84, 0x67, 0x96, 0x4d, 0x57, 0xc8, 0x8a, 0xca}; - uint8_t bytesprops6[] = {0xf7, 0x52, 0x22, 0x9c, 0x97, 0x29, 0x96, 0x13, 0x9c, 0x4d, 0x6e, 0x2}; - uint8_t bytesprops5[] = {0x1a, 0x26, 0x6b}; - uint8_t bytesprops7[] = {0x7a, 0xa9, 0xd9, 0xf8, 0xca, 0xb7, 0x29, 0xaa}; - uint8_t bytesprops8[] = {0x7e, 0xd5, 0xa9, 0x36, 0x51, 0x96, 0x8a, 0x11, 0x92, 0xbd, - 0x5a, 0x9d, 0xe6, 0xc1, 0xb2, 0x98, 0xfc, 0x95, 0xda, 0xd9}; - uint8_t bytesprops9[] = {0xf7, 0x2, 0x20, 0x8a, 0x59, 0x4a, 0xe3, 0x15, 0x46, 0x89}; + 0x82, 0x85, 0x4, 0x6b, 0xdf, 0xe6, 0x2, 0x21, 0xf, 0x68, 0x8, 0x0, 0x11, 0x79, 0x60, 0x97, 0x7, 0x88, 0xdb, + 0x59, 0x30, 0x78, 0xa3, 0x86, 0x94, 0xfa, 0x20, 0xd1, 0x7d, 0xe7, 0x17, 0xed, 0x9, 0x0, 0x1e, 0x8b, 0xaa, 0xd1, + 0xa2, 0xb1, 0x6e, 0x95, 0x0, 0x14, 0x17, 0x8e, 0xb7, 0xaf, 0xca, 0xea, 0xa9, 0x6d, 0x8a, 0xa7, 0x61, 0x30, 0xcc, + 0x93, 0xa1, 0xf2, 0xc8, 0xb9, 0xfa, 0x92, 0xcc, 0x22, 0x7e, 0x71, 0x28, 0xc6, 0x27, 0x0, 0x0, 0x4a, 0x97, 0x12, + 0x0, 0x2, 0x38, 0x4c, 0x1c, 0x0, 0x1c, 0xe1, 0x1, 0x1b, 0x15, 0xa7, 0xa2, 0x68, 0x3f, 0x5b, 0x9, 0x66, 0x6f, + 0x82, 0x46, 0xfb, 0xe3, 0xd6, 0x37, 0x4a, 0x4, 0x5f, 0xb8, 0x5, 0x88, 0xc1, 0xdf, 0x9d, 0x2b, 0x29, 0xf4, 0x1f, + 0x0, 0x17, 0xaa, 0x56, 0x92, 0x7f, 0x93, 0x52, 0x7d, 0x7d, 0x81, 0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 0x59, 0x4c, 0x48, 0x3, 0x62, 0xe0, 0xed, 0xc6, 0x97, 0x6a, 0xc3, 0xea, 0xee, + 0x0, 0x0, 0x3, 0x0, 0x34, 0xe8, 0x1}; + + uint8_t buf[530] = {0}; + + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x15, 0x86, 0xdb, 0x36, 0x3b, 0x96, 0x31, + 0x55, 0x58, 0x9b, 0xed, 0x65, 0xaa, 0xdd}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x44, 0xbc, 0xab, 0x8d, 0xb5, 0x69, 0xbd, 0x45, 0x91, 0xa5, 0xd1, 0x5e, 0xac, 0x13, + 0xb8, 0x34, 0x13, 0x1d, 0xdd, 0x1f, 0x64, 0xa9, 0x55, 0x5a, 0x9c, 0x5d, 0xda}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x55, 0xc5, 0xa3, 0xe1, 0xf2, 0x7f, 0x65, 0xe1, 0x79, 0xb7, + 0x6e, 0x27, 0x5f, 0xa8, 0x82, 0x4, 0x76, 0x86, 0x44, 0x53, + 0xa4, 0x94, 0xb, 0x63, 0x3d, 0xe2, 0xf0, 0xd7}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x25, 0xdc, 0x8f, 0x5a, 0x2, 0xfe, 0x73, 0x35, 0xe6, 0xf8, 0xa1, 0xd7, 0xfb, + 0x6b, 0xde, 0x6a, 0x32, 0x84, 0xae, 0x58, 0xf3, 0xc7, 0x11, 0x93, 0xe7}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe6, 0xc7, 0x79, 0x6e, 0x93, 0x49, 0xab, 0xc, 0xce, 0x98, 0xf7, + 0x6, 0xf6, 0xcd, 0x37, 0x69, 0x3e, 0x37, 0x89, 0x3, 0x69}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x59, 0x4c, 0x48, 0x3, 0x62, 0xe0, 0xed, 0xc6, 0x97, 0x6a, 0xc3, 0xea, 0xee}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x0, 0x34, 0xe8}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x79, 0x60, 0x97, 0x7, 0x88, 0xdb, 0x59, 0x30, 0x78, + 0xa3, 0x86, 0x94, 0xfa, 0x20, 0xd1, 0x7d, 0xe7}; + uint8_t bytesprops1[] = {0x8b, 0xaa, 0xd1, 0xa2, 0xb1, 0x6e, 0x95, 0x0, 0x14, 0x17, 0x8e, 0xb7, 0xaf, 0xca, 0xea, + 0xa9, 0x6d, 0x8a, 0xa7, 0x61, 0x30, 0xcc, 0x93, 0xa1, 0xf2, 0xc8, 0xb9, 0xfa, 0x92, 0xcc}; + uint8_t bytesprops2[] = {0x38, 0x4c}; + uint8_t bytesprops3[] = {0xe1, 0x1, 0x1b, 0x15, 0xa7, 0xa2, 0x68, 0x3f, 0x5b, 0x9, 0x66, 0x6f, 0x82, 0x46, + 0xfb, 0xe3, 0xd6, 0x37, 0x4a, 0x4, 0x5f, 0xb8, 0x5, 0x88, 0xc1, 0xdf, 0x9d, 0x2b}; + uint8_t bytesprops4[] = {0xaa, 0x56, 0x92, 0x7f, 0x93, 0x52, 0x7d, 0x7d, 0x81, 0xc1, 0xa4, 0x8f, + 0xc5, 0xa5, 0x5b, 0xe1, 0x2e, 0x25, 0x9c, 0x35, 0x52, 0xd5, 0xc2}; + uint8_t bytesprops6[] = {0xc9, 0x58, 0xa, 0x20, 0xb6, 0xdc, 0x50}; + uint8_t bytesprops5[] = {0xbe, 0xc4, 0x90, 0x79, 0xf3, 0xc9, 0xa1, 0x49, 0x0, 0x79, 0x1d, 0xea, 0xfb, 0x5f, + 0x28, 0xf2, 0x1f, 0xdd, 0x71, 0x32, 0x40, 0xde, 0xba, 0xbd, 0x78, 0xbd, 0x81}; + uint8_t bytesprops7[] = {0x3, 0x64, 0x63, 0x49, 0x74, 0x7, 0x1d, 0x1d, 0x73, 0x70, 0x5f, 0x42, 0x4f}; + uint8_t bytesprops8[] = {0xa2, 0x89, 0x2b, 0x36, 0xba, 0xa1, 0x56, 0x85, 0x28, 0x9e, 0x9c, 0x1f, 0x12, + 0x60, 0xcf, 0x46, 0x51, 0xa6, 0xe9, 0x3e, 0xe0, 0x53, 0x0, 0xda, 0x52}; + uint8_t bytesprops9[] = {0x1, 0xb8, 0x4f, 0x5f, 0xed, 0xa7, 0x3d, 0xc, 0xdf, 0xf3, 0x51, 0x17, + 0xfc, 0x9a, 0x1c, 0x75, 0x17, 0x3e, 0x97, 0xdb, 0x83, 0x4e, 0xef, 0x6c}; + uint8_t bytesprops10[] = {0x0, 0x0, 0x38, 0x64, 0x91, 0xf5, 0x94, 0xa1, 0x11, 0x99, 0x4e, 0xb7, 0x81, 0xac, + 0x5f, 0x16, 0xd6, 0x2e, 0xc8, 0x2a, 0x3d, 0xbd, 0x8e, 0x11, 0x96, 0x6b, 0x4c, 0x34}; + uint8_t bytesprops11[] = {0xb3, 0x7b, 0x67, 0x30, 0x4, 0xc3, 0x81, 0x74, 0xa9, 0x5f, 0x32, + 0xca, 0x79, 0xff, 0x7e, 0x2d, 0xef, 0xfe, 0x47, 0x11, 0x2b, 0x4}; + uint8_t bytesprops12[] = {0x3f, 0xf, 0x97, 0x53, 0x82, 0x1d, 0x24, 0x3e, 0x28, 0x8c, 0x7e, + 0x10, 0x9e, 0x24, 0x66, 0x28, 0x41, 0xd2, 0x27, 0x84, 0x36}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29496}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19828}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29886}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9028}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops5}, .v = {12, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25601}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30013}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2730}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3653}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11018}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20508}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3944}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32369}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19095}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops5}, .v = {7, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4591}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26969}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14370}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 352}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23938}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20026}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2085, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27615, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 14083 [("\135\234\FS",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("n\183\&9\DC1f\NUL@\185\255\185qq\STX\"\173\fJ\218\SUB",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\128p\197\DC1\162\160\171\171K\149\206 \ACK\145\202\142",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropUserProperty "\196" +// "\178\189\SOH\171\CAN\DLEf\EM\139\r\193\188\201\DC1x\244/\EOT}\151\&1\ETB\204\172",PropCorrelationData +// "\198\247%\146\202'\172",PropWildcardSubscriptionAvailable 255,PropServerReference "I@",PropTopicAliasMaximum +// 29613,PropAuthenticationMethod "\177\DC2P\ESC",PropAuthenticationMethod +// "\ENQ\167\214\183J\159u",PropWillDelayInterval 17943] +TEST(Subscribe5QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0x7a, 0x37, 0x3, 0x48, 0x26, 0x0, 0x1, 0xc4, 0x0, 0x18, 0xb2, 0xbd, 0x1, 0xab, 0x18, + 0x10, 0x66, 0x19, 0x8b, 0xd, 0xc1, 0xbc, 0xc9, 0x11, 0x78, 0xf4, 0x2f, 0x4, 0x7d, 0x97, 0x31, + 0x17, 0xcc, 0xac, 0x9, 0x0, 0x7, 0xc6, 0xf7, 0x25, 0x92, 0xca, 0x27, 0xac, 0x28, 0xff, 0x1c, + 0x0, 0x2, 0x49, 0x40, 0x22, 0x73, 0xad, 0x15, 0x0, 0x4, 0xb1, 0x12, 0x50, 0x1b, 0x15, 0x0, + 0x7, 0x5, 0xa7, 0xd6, 0xb7, 0x4a, 0x9f, 0x75, 0x18, 0x0, 0x0, 0x46, 0x17, 0x0, 0x3, 0x87, + 0xea, 0x1c, 0x2, 0x0, 0x13, 0x6e, 0xb7, 0x39, 0x11, 0x66, 0x0, 0x40, 0xb9, 0xff, 0xb9, 0x71, + 0x71, 0x2, 0x22, 0xad, 0xc, 0x4a, 0xda, 0x1a, 0x1, 0x0, 0x10, 0x80, 0x70, 0xc5, 0x11, 0xa2, + 0xa0, 0xab, 0xab, 0x4b, 0x95, 0xce, 0x20, 0x6, 0x91, 0xca, 0x8e, 0x0}; + + uint8_t buf[134] = {0}; + + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x87, 0xea, 0x1c}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6e, 0xb7, 0x39, 0x11, 0x66, 0x0, 0x40, 0xb9, 0xff, 0xb9, + 0x71, 0x71, 0x2, 0x22, 0xad, 0xc, 0x4a, 0xda, 0x1a}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x80, 0x70, 0xc5, 0x11, 0xa2, 0xa0, 0xab, 0xab, + 0x4b, 0x95, 0xce, 0x20, 0x6, 0x91, 0xca, 0x8e}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0}; + uint8_t bytesprops1[] = {0xb2, 0xbd, 0x1, 0xab, 0x18, 0x10, 0x66, 0x19, 0x8b, 0xd, 0xc1, 0xbc, + 0xc9, 0x11, 0x78, 0xf4, 0x2f, 0x4, 0x7d, 0x97, 0x31, 0x17, 0xcc, 0xac}; + uint8_t bytesprops0[] = {0xc4}; + uint8_t bytesprops2[] = {0xc6, 0xf7, 0x25, 0x92, 0xca, 0x27, 0xac}; + uint8_t bytesprops3[] = {0x49, 0x40}; + uint8_t bytesprops4[] = {0xb1, 0x12, 0x50, 0x1b}; + uint8_t bytesprops5[] = {0x5, 0xa7, 0xd6, 0xb7, 0x4a, 0x9f, 0x75}; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\162\236\175\234}", _pubPktID = -// 21077, _pubBody = "T\207i\212;Q", _pubProps = [PropResponseTopic ""]} -TEST(Publish5QCTest, Encode31) { - uint8_t pkt[] = {0x33, 0x13, 0x0, 0x5, 0xa2, 0xec, 0xaf, 0xea, 0x7d, 0x52, 0x55, - 0x3, 0x8, 0x0, 0x0, 0x54, 0xcf, 0x69, 0xd4, 0x3b, 0x51}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29613}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17943}}, + }; - uint8_t buf[31] = {0}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14083, 3, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 16713 [("\141D\238n\154\164\246$)\214WR\f v\189\185*\139\r\DLE\ESC\135\SOH\164\132",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\185\139@\EM\a\ETX\186\130\FS\DC4\149\129",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS1}),("\139\211\225\252\160\193\136\130\164\243{3h\210\157/\220\156Eg\147l52",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\254\153c\253\205\198H\213\STX\SYN\139d#\249ON\143{\v\NAK3Iwz\EOT|\GS\ESC:^",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSubscriptionIdentifier +// 27,PropSessionExpiryInterval 19874,PropTopicAlias 16501,PropSharedSubscriptionAvailable +// 94,PropAssignedClientIdentifier +// "\135\RS\176~j\DC13G\224\SO6\160\254\v\159\253\169\130\198",PropRequestProblemInformation 64,PropServerReference +// "1b\148\133\SUB\134\165\248\131",PropSharedSubscriptionAvailable 53,PropAuthenticationData +// "I6\144\178w\185\190\n7Y\195\230T",PropSessionExpiryInterval 54,PropTopicAlias 17109] +TEST(Subscribe5QCTest, Encode24) { + uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x41, 0x49, 0x4a, 0xb, 0x1b, 0x11, 0x0, 0x0, 0x4d, 0xa2, 0x23, 0x40, 0x75, 0x2a, + 0x5e, 0x12, 0x0, 0x13, 0x87, 0x1e, 0xb0, 0x7e, 0x6a, 0x11, 0x33, 0x47, 0xe0, 0xe, 0x36, 0xa0, 0xfe, + 0xb, 0x9f, 0xfd, 0xa9, 0x82, 0xc6, 0x17, 0x40, 0x1c, 0x0, 0x9, 0x31, 0x62, 0x94, 0x85, 0x1a, 0x86, + 0xa5, 0xf8, 0x83, 0x2a, 0x35, 0x16, 0x0, 0xd, 0x49, 0x36, 0x90, 0xb2, 0x77, 0xb9, 0xbe, 0xa, 0x37, + 0x59, 0xc3, 0xe6, 0x54, 0x11, 0x0, 0x0, 0x0, 0x36, 0x23, 0x42, 0xd5, 0x0, 0x1a, 0x8d, 0x44, 0xee, + 0x6e, 0x9a, 0xa4, 0xf6, 0x24, 0x29, 0xd6, 0x57, 0x52, 0xc, 0x20, 0x76, 0xbd, 0xb9, 0x2a, 0x8b, 0xd, + 0x10, 0x1b, 0x87, 0x1, 0xa4, 0x84, 0x2, 0x0, 0xc, 0xb9, 0x8b, 0x40, 0x19, 0x7, 0x3, 0xba, 0x82, + 0x1c, 0x14, 0x95, 0x81, 0x1, 0x0, 0x18, 0x8b, 0xd3, 0xe1, 0xfc, 0xa0, 0xc1, 0x88, 0x82, 0xa4, 0xf3, + 0x7b, 0x33, 0x68, 0xd2, 0x9d, 0x2f, 0xdc, 0x9c, 0x45, 0x67, 0x93, 0x6c, 0x35, 0x32, 0x1, 0x0, 0x1e, + 0xfe, 0x99, 0x63, 0xfd, 0xcd, 0xc6, 0x48, 0xd5, 0x2, 0x16, 0x8b, 0x64, 0x23, 0xf9, 0x4f, 0x4e, 0x8f, + 0x7b, 0xb, 0x15, 0x33, 0x49, 0x77, 0x7a, 0x4, 0x7c, 0x1d, 0x1b, 0x3a, 0x5e, 0x2}; - uint8_t topic_bytes[] = {0xa2, 0xec, 0xaf, 0xea, 0x7d}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x54, 0xcf, 0x69, 0xd4, 0x3b, 0x51}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + uint8_t buf[194] = {0}; - uint8_t bytesprops0[] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x8d, 0x44, 0xee, 0x6e, 0x9a, 0xa4, 0xf6, 0x24, 0x29, 0xd6, 0x57, 0x52, 0xc, + 0x20, 0x76, 0xbd, 0xb9, 0x2a, 0x8b, 0xd, 0x10, 0x1b, 0x87, 0x1, 0xa4, 0x84}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb9, 0x8b, 0x40, 0x19, 0x7, 0x3, 0xba, 0x82, 0x1c, 0x14, 0x95, 0x81}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x8b, 0xd3, 0xe1, 0xfc, 0xa0, 0xc1, 0x88, 0x82, 0xa4, 0xf3, 0x7b, 0x33, + 0x68, 0xd2, 0x9d, 0x2f, 0xdc, 0x9c, 0x45, 0x67, 0x93, 0x6c, 0x35, 0x32}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xfe, 0x99, 0x63, 0xfd, 0xcd, 0xc6, 0x48, 0xd5, 0x2, 0x16, + 0x8b, 0x64, 0x23, 0xf9, 0x4f, 0x4e, 0x8f, 0x7b, 0xb, 0x15, + 0x33, 0x49, 0x77, 0x7a, 0x4, 0x7c, 0x1d, 0x1b, 0x3a, 0x5e}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x87, 0x1e, 0xb0, 0x7e, 0x6a, 0x11, 0x33, 0x47, 0xe0, 0xe, + 0x36, 0xa0, 0xfe, 0xb, 0x9f, 0xfd, 0xa9, 0x82, 0xc6}; + uint8_t bytesprops1[] = {0x31, 0x62, 0x94, 0x85, 0x1a, 0x86, 0xa5, 0xf8, 0x83}; + uint8_t bytesprops2[] = {0x49, 0x36, 0x90, 0xb2, 0x77, 0xb9, 0xbe, 0xa, 0x37, 0x59, 0xc3, 0xe6, 0x54}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19874}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16501}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 54}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17109}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 21077, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16713, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "(E\169\142\223\199$\202\NUL\146\142\SOH\163_",PropSessionExpiryInterval 6247,PropTopicAlias +// 31335,PropAuthenticationData +// "S\244(!\a\EM\137\142\155=9p<\DEL\DC4\SYN\140V\STX\STX\159\198",PropSharedSubscriptionAvailable 146] +TEST(Subscribe5QCTest, Encode25) { + uint8_t pkt[] = { + 0x82, 0xcc, 0x1, 0x63, 0x7f, 0x41, 0x13, 0x43, 0x53, 0x2a, 0x7e, 0x29, 0x4a, 0x16, 0x0, 0x14, 0x6f, 0xc6, 0xdd, + 0x12, 0x48, 0x34, 0x95, 0x3e, 0xa9, 0x8e, 0xdf, 0xc7, 0x24, 0xca, 0x0, 0x92, 0x8e, 0x1, 0xa3, 0x5f, 0x11, 0x0, + 0x0, 0x18, 0x67, 0x23, 0x7a, 0x67, 0x16, 0x0, 0x16, 0x53, 0xf4, 0x28, 0x21, 0x7, 0x19, 0x89, 0x8e, 0x9b, 0x3d, + 0x39, 0x70, 0x3c, 0x7f, 0x14, 0x16, 0x8c, 0x56, 0x2, 0x2, 0x9f, 0xc6, 0x2a, 0x92, 0x0, 0x1c, 0x20, 0x67, 0xc7, + 0xd9, 0x92, 0xfd, 0x26, 0x13, 0xeb, 0x8, 0xba, 0xc8, 0x9, 0xab, 0xfe, 0xac, 0x1c, 0x8c, 0x6d, 0x13, 0x18, 0xee, + 0x46, 0xe0, 0xbb, 0xbe, 0xab, 0xf2, 0x0, 0x0, 0x0, 0x1, 0x0, 0x16, 0xb3, 0x68, 0x77, 0xce, 0x72, 0x7, 0x43, + 0x1d, 0x9f, 0xa, 0xce, 0x1a, 0xff, 0x24, 0x6d, 0x45, 0x4, 0x6d, 0x5d, 0xd2, 0x41, 0xe0, 0x0, 0x0, 0x6, 0x56, + 0x64, 0xaa, 0xf6, 0x32, 0xb, 0x1, 0x0, 0x1d, 0xe6, 0x82, 0x2b, 0x99, 0xd6, 0xa4, 0xec, 0x5, 0x61, 0x73, 0xfb, + 0xc0, 0x7d, 0x68, 0x29, 0x1, 0x1b, 0x7b, 0xbd, 0x3d, 0xbe, 0xeb, 0x27, 0x77, 0xca, 0xe1, 0x34, 0xdf, 0x6, 0x1, + 0x0, 0x19, 0xdd, 0x38, 0x46, 0x8e, 0x37, 0xc5, 0x14, 0xc1, 0x97, 0xc1, 0x40, 0x4, 0x97, 0x6, 0x92, 0x9d, 0xef, + 0x95, 0x2, 0xb5, 0xdc, 0x94, 0x9d, 0x2, 0xe0, 0x1, 0x0, 0x5, 0x6c, 0xa0, 0xe5, 0xe6, 0x92, 0x0}; + + uint8_t buf[217] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x20, 0x67, 0xc7, 0xd9, 0x92, 0xfd, 0x26, 0x13, 0xeb, 0x8, + 0xba, 0xc8, 0x9, 0xab, 0xfe, 0xac, 0x1c, 0x8c, 0x6d, 0x13, + 0x18, 0xee, 0x46, 0xe0, 0xbb, 0xbe, 0xab, 0xf2}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb3, 0x68, 0x77, 0xce, 0x72, 0x7, 0x43, 0x1d, 0x9f, 0xa, 0xce, + 0x1a, 0xff, 0x24, 0x6d, 0x45, 0x4, 0x6d, 0x5d, 0xd2, 0x41, 0xe0}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x56, 0x64, 0xaa, 0xf6, 0x32, 0xb}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe6, 0x82, 0x2b, 0x99, 0xd6, 0xa4, 0xec, 0x5, 0x61, 0x73, + 0xfb, 0xc0, 0x7d, 0x68, 0x29, 0x1, 0x1b, 0x7b, 0xbd, 0x3d, + 0xbe, 0xeb, 0x27, 0x77, 0xca, 0xe1, 0x34, 0xdf, 0x6}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xdd, 0x38, 0x46, 0x8e, 0x37, 0xc5, 0x14, 0xc1, 0x97, 0xc1, 0x40, 0x4, 0x97, + 0x6, 0x92, 0x9d, 0xef, 0x95, 0x2, 0xb5, 0xdc, 0x94, 0x9d, 0x2, 0xe0}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x6c, 0xa0, 0xe5, 0xe6, 0x92}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x6f, 0xc6, 0xdd, 0x12, 0x48, 0x34, 0x95, 0x3e, 0xa9, 0x8e, + 0xdf, 0xc7, 0x24, 0xca, 0x0, 0x92, 0x8e, 0x1, 0xa3, 0x5f}; + uint8_t bytesprops1[] = {0x53, 0xf4, 0x28, 0x21, 0x7, 0x19, 0x89, 0x8e, 0x9b, 0x3d, 0x39, + 0x70, 0x3c, 0x7f, 0x14, 0x16, 0x8c, 0x56, 0x2, 0x2, 0x9f, 0xc6}; - uint8_t bytesprops1[] = {0x97}; - uint8_t bytesprops0[] = {0x27, 0x15, 0x9d}; - uint8_t bytesprops2[] = {0xbc, 0x6d, 0xad, 0xdd}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops5[] = {0x78, 0xc9, 0xac, 0x40, 0x2b, 0xb3, 0x3, 0x35, 0xeb, 0xa9, 0xc0, - 0xd1, 0xb7, 0xae, 0xd6, 0xce, 0xa9, 0xd6, 0xe5, 0x82, 0x89}; - uint8_t bytesprops4[] = {0x34, 0x9b, 0xa, 0xad, 0x9d, 0xa5, 0x57, 0x2d, 0xf7, 0xe1, 0xfd, 0x10}; - uint8_t bytesprops6[] = {0x32, 0x7a, 0xd6, 0x11, 0x5b, 0x2d, 0xf7, 0xa8, 0x1a}; - uint8_t bytesprops7[] = {0xf3, 0x8f}; - uint8_t bytesprops8[] = {0x14, 0x89, 0x7b}; - uint8_t bytesprops9[] = {0xf8, 0x4b, 0xe2, 0xf4, 0x58, 0xd5, 0x65, 0x7a, 0xb4, 0xd9, 0x98, 0x3b, 0x56, 0x53, 0x1e, - 0xa, 0x10, 0xe5, 0x5b, 0x59, 0xc1, 0x3c, 0x2c, 0x50, 0x65, 0x51, 0x42, 0x1b, 0xe3}; - uint8_t bytesprops10[] = {0xf4, 0x5c}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17235}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6247}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31335}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 146}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25471, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 10657 [("\ENQ4\f\143\197\ENQ\145\193\247\141\221i\199\192\173\223",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\188\156\DC3\177\134%\161",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\\\222\217\&5\226r",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\176c\ESCP\163\GSx\DC3",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("G\ENQ\204\136\fTN\163\214\228\254eHG\166\CAN\210\146>",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\172\144=\175\\\ESC\f\226\179v\175\164D$R9\211",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("S\242\171\242\STX\221\188uJ\199l\155\137\232\\\135\187\141\SYN\217",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\NAK\205\STX\156\ENQ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\161\200eM1\161*\234\207\198\169\252.\DC2nE\230\227HE8\135\164\244",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("al}\149\EOT(\233\DLE\STX\233\208\183ui-F\t",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropTopicAliasMaximum 29858,PropServerReference +// "]9\CAN\DC3\197\217E\197_g\206\202.pF\203k\211",PropPayloadFormatIndicator 191,PropTopicAliasMaximum +// 6452,PropServerReference "t\216\160\150~",PropTopicAlias 5241,PropTopicAlias 29173,PropSharedSubscriptionAvailable +// 168,PropMaximumPacketSize 3240,PropSubscriptionIdentifierAvailable 206,PropUserProperty +// ":\232\199\223v'\194\209\SUB\253\171" "Ek\GS\169\133\ACK\DC4\v\176~E",PropAssignedClientIdentifier +// "\NAK\NAK\190.v\156\229\136\FSN\249\212T\134\231\218\152#K",PropReasonString "\NAK\DELI",PropResponseInformation +// "\ESC\251\217,\228\a\183N\194\132\&4\154\226y\NUL\133\192L)#M\ENQ\140xX\SYN4\212\204",PropMaximumPacketSize +// 27146,PropTopicAlias 1220,PropMessageExpiryInterval 612,PropContentType +// "Bf\GS\207\180\DC4\US\201\229o\232\212\209\251\251$U)\DLE\134\SYN\DC3\227\149W@\STX",PropSessionExpiryInterval +// 13945,PropAuthenticationMethod +// "^\139B\228L\STXt\142R\228a\197\194\137\160\&2\177\181\192\tjY\190\148\SI",PropMaximumPacketSize +// 10669,PropUserProperty "\158\201H\153\198\246Q" +// "\a\245\233\150\t\t\NUL\155\219\159[\240\140\226\n",PropAuthenticationData "S"] +TEST(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0x8d, 0x16, 0xd9, 0x1, 0x0, 0x5, 0x15, 0xcd, 0x2, 0x9c, 0x5, 0x1, + 0x0, 0x18, 0xa1, 0xc8, 0x65, 0x4d, 0x31, 0xa1, 0x2a, 0xea, 0xcf, 0xc6, 0xa9, 0xfc, 0x2e, 0x12, 0x6e, 0x45, 0xe6, + 0xe3, 0x48, 0x45, 0x38, 0x87, 0xa4, 0xf4, 0x1, 0x0, 0x11, 0x61, 0x6c, 0x7d, 0x95, 0x4, 0x28, 0xe9, 0x10, 0x2, + 0xe9, 0xd0, 0xb7, 0x75, 0x69, 0x2d, 0x46, 0x9, 0x2}; + + uint8_t buf[437] = {0}; + + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x5, 0x34, 0xc, 0x8f, 0xc5, 0x5, 0x91, 0xc1, + 0xf7, 0x8d, 0xdd, 0x69, 0xc7, 0xc0, 0xad, 0xdf}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xbc, 0x9c, 0x13, 0xb1, 0x86, 0x25, 0xa1}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5c, 0xde, 0xd9, 0x35, 0xe2, 0x72}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb0, 0x63, 0x1b, 0x50, 0xa3, 0x1d, 0x78, 0x13}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x47, 0x5, 0xcc, 0x88, 0xc, 0x54, 0x4e, 0xa3, 0xd6, 0xe4, + 0xfe, 0x65, 0x48, 0x47, 0xa6, 0x18, 0xd2, 0x92, 0x3e}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xac, 0x90, 0x3d, 0xaf, 0x5c, 0x1b, 0xc, 0xe2, 0xb3, + 0x76, 0xaf, 0xa4, 0x44, 0x24, 0x52, 0x39, 0xd3}; + lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x53, 0xf2, 0xab, 0xf2, 0x2, 0xdd, 0xbc, 0x75, 0x4a, 0xc7, + 0x6c, 0x9b, 0x89, 0xe8, 0x5c, 0x87, 0xbb, 0x8d, 0x16, 0xd9}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x15, 0xcd, 0x2, 0x9c, 0x5}; + lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa1, 0xc8, 0x65, 0x4d, 0x31, 0xa1, 0x2a, 0xea, 0xcf, 0xc6, 0xa9, 0xfc, + 0x2e, 0x12, 0x6e, 0x45, 0xe6, 0xe3, 0x48, 0x45, 0x38, 0x87, 0xa4, 0xf4}; + lwmqtt_string_t topic_filter_s8 = {24, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x61, 0x6c, 0x7d, 0x95, 0x4, 0x28, 0xe9, 0x10, 0x2, + 0xe9, 0xd0, 0xb7, 0x75, 0x69, 0x2d, 0x46, 0x9}; + lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x5d, 0x39, 0x18, 0x13, 0xc5, 0xd9, 0x45, 0xc5, 0x5f, + 0x67, 0xce, 0xca, 0x2e, 0x70, 0x46, 0xcb, 0x6b, 0xd3}; + uint8_t bytesprops1[] = {0x74, 0xd8, 0xa0, 0x96, 0x7e}; + uint8_t bytesprops3[] = {0x45, 0x6b, 0x1d, 0xa9, 0x85, 0x6, 0x14, 0xb, 0xb0, 0x7e, 0x45}; + uint8_t bytesprops2[] = {0x3a, 0xe8, 0xc7, 0xdf, 0x76, 0x27, 0xc2, 0xd1, 0x1a, 0xfd, 0xab}; + uint8_t bytesprops4[] = {0x15, 0x15, 0xbe, 0x2e, 0x76, 0x9c, 0xe5, 0x88, 0x1c, 0x4e, + 0xf9, 0xd4, 0x54, 0x86, 0xe7, 0xda, 0x98, 0x23, 0x4b}; + uint8_t bytesprops5[] = {0x15, 0x7f, 0x49}; + uint8_t bytesprops6[] = {0x1b, 0xfb, 0xd9, 0x2c, 0xe4, 0x7, 0xb7, 0x4e, 0xc2, 0x84, 0x34, 0x9a, 0xe2, 0x79, 0x0, + 0x85, 0xc0, 0x4c, 0x29, 0x23, 0x4d, 0x5, 0x8c, 0x78, 0x58, 0x16, 0x34, 0xd4, 0xcc}; + uint8_t bytesprops7[] = {0x42, 0x66, 0x1d, 0xcf, 0xb4, 0x14, 0x1f, 0xc9, 0xe5, 0x6f, 0xe8, 0xd4, 0xd1, 0xfb, + 0xfb, 0x24, 0x55, 0x29, 0x10, 0x86, 0x16, 0x13, 0xe3, 0x95, 0x57, 0x40, 0x2}; + uint8_t bytesprops8[] = {0x5e, 0x8b, 0x42, 0xe4, 0x4c, 0x2, 0x74, 0x8e, 0x52, 0xe4, 0x61, 0xc5, 0xc2, + 0x89, 0xa0, 0x32, 0xb1, 0xb5, 0xc0, 0x9, 0x6a, 0x59, 0xbe, 0x94, 0xf}; + uint8_t bytesprops10[] = {0x7, 0xf5, 0xe9, 0x96, 0x9, 0x9, 0x0, 0x9b, 0xdb, 0x9f, 0x5b, 0xf0, 0x8c, 0xe2, 0xa}; + uint8_t bytesprops9[] = {0x9e, 0xc9, 0x48, 0x99, 0xc6, 0xf6, 0x51}; + uint8_t bytesprops11[] = {0x53}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17295}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops0}, .v = {1, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11623}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6795}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4317}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops4}, .v = {21, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22445}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11205}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17287}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7806}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2764}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7341}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24078}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17035}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29858}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6452}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5241}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29173}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3240}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27146}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1220}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 612}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13945}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10669}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops9}, .v = {15, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 9852, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10657, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\160", _pubPktID = 20635, _pubBody = -// "\220\193\SOH\ESC\150\212\SUB\t\156\222\ETB\160\148h", _pubProps = [PropResponseTopic "\174=\157\128\173"]} -TEST(Publish5QCTest, Encode33) { - uint8_t pkt[] = {0x3d, 0x1c, 0x0, 0x1, 0xa0, 0x50, 0x9b, 0x8, 0x8, 0x0, 0x5, 0xae, 0x3d, 0x9d, 0x80, - 0xad, 0xdc, 0xc1, 0x1, 0x1b, 0x96, 0xd4, 0x1a, 0x9, 0x9c, 0xde, 0x17, 0xa0, 0x94, 0x68}; +// SubscribeRequest 15036 [("\ETB\177\238\199$\NUL\128\209",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("3r:\DC1c[upm\234_c`\195V\252C\vu\153\196",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("g\238\250",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("\183\236\166\159+\v\b\SI\149\DC2\247\&1",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\ESCd\242\134N\161i\169\135\230\198m\163\166\229\247e\211E",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("Y\216\242f(\ETX=\152\ESC\208?B|\197\n\198Z\148\153\199\f\r\\n5\137#4",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty "\DLE\DLE\177\184 +// \237{\223\SUBR\b\153=j;" "\\\172\155\241c]\132g`_\227aO\SO1\167\"\238\RSy",PropPayloadFormatIndicator +// 213,PropSessionExpiryInterval 24785,PropMaximumQoS 239,PropMaximumQoS 27,PropSubscriptionIdentifier +// 28,PropMaximumPacketSize 7341,PropRequestResponseInformation 196,PropMessageExpiryInterval +// 25044,PropAssignedClientIdentifier +// "\129\225=\207.UC\165*)\160\184\197\a\r\213H\EOT\202\&2\163\249u*",PropUserProperty +// "\138Z&\167\EM\219\DEL\218\234\243\FS\231\224\248z" +// "\FS\152\&8\US\230\153\150\175\238`\211\161R\DLE\DC1\"\209\&4\209wm\174k\239V",PropWildcardSubscriptionAvailable +// 234,PropResponseInformation ""] +TEST(Subscribe5QCTest, Encode27) { + uint8_t pkt[] = { + 0x82, 0xff, 0x1, 0x3a, 0xbc, 0x8e, 0x1, 0x26, 0x0, 0xf, 0x10, 0x10, 0xb1, 0xb8, 0x20, 0xed, 0x7b, 0xdf, 0x1a, + 0x52, 0x8, 0x99, 0x3d, 0x6a, 0x3b, 0x0, 0x14, 0x5c, 0xac, 0x9b, 0xf1, 0x63, 0x5d, 0x84, 0x67, 0x60, 0x5f, 0xe3, + 0x61, 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x0, + 0x1c, 0x59, 0xd8, 0xf2, 0x66, 0x28, 0x3, 0x3d, 0x98, 0x1b, 0xd0, 0x3f, 0x42, 0x7c, 0xc5, 0xa, 0xc6, 0x5a, 0x94, + 0x99, 0xc7, 0xc, 0xd, 0x5c, 0x6e, 0x35, 0x89, 0x23, 0x34, 0x1}; + + uint8_t buf[268] = {0}; + + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x17, 0xb1, 0xee, 0xc7, 0x24, 0x0, 0x80, 0xd1}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x33, 0x72, 0x3a, 0x11, 0x63, 0x5b, 0x75, 0x70, 0x6d, 0xea, 0x5f, + 0x63, 0x60, 0xc3, 0x56, 0xfc, 0x43, 0xb, 0x75, 0x99, 0xc4}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x67, 0xee, 0xfa}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb7, 0xec, 0xa6, 0x9f, 0x2b, 0xb, 0x8, 0xf, 0x95, 0x12, 0xf7, 0x31}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x1b, 0x64, 0xf2, 0x86, 0x4e, 0xa1, 0x69, 0xa9, 0x87, 0xe6, + 0xc6, 0x6d, 0xa3, 0xa6, 0xe5, 0xf7, 0x65, 0xd3, 0x45}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x59, 0xd8, 0xf2, 0x66, 0x28, 0x3, 0x3d, 0x98, 0x1b, 0xd0, + 0x3f, 0x42, 0x7c, 0xc5, 0xa, 0xc6, 0x5a, 0x94, 0x99, 0xc7, + 0xc, 0xd, 0x5c, 0x6e, 0x35, 0x89, 0x23, 0x34}; + lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops1[] = {0x5c, 0xac, 0x9b, 0xf1, 0x63, 0x5d, 0x84, 0x67, 0x60, 0x5f, + 0xe3, 0x61, 0x4f, 0xe, 0x31, 0xa7, 0x22, 0xee, 0x1e, 0x79}; + uint8_t bytesprops0[] = {0x10, 0x10, 0xb1, 0xb8, 0x20, 0xed, 0x7b, 0xdf, 0x1a, 0x52, 0x8, 0x99, 0x3d, 0x6a, 0x3b}; + uint8_t bytesprops2[] = {0x81, 0xe1, 0x3d, 0xcf, 0x2e, 0x55, 0x43, 0xa5, 0x2a, 0x29, 0xa0, 0xb8, + 0xc5, 0x7, 0xd, 0xd5, 0x48, 0x4, 0xca, 0x32, 0xa3, 0xf9, 0x75, 0x2a}; + uint8_t bytesprops4[] = {0x1c, 0x98, 0x38, 0x1f, 0xe6, 0x99, 0x96, 0xaf, 0xee, 0x60, 0xd3, 0xa1, 0x52, + 0x10, 0x11, 0x22, 0xd1, 0x34, 0xd1, 0x77, 0x6d, 0xae, 0x6b, 0xef, 0x56}; + uint8_t bytesprops3[] = {0x8a, 0x5a, 0x26, 0xa7, 0x19, 0xdb, 0x7f, 0xda, 0xea, 0xf3, 0x1c, 0xe7, 0xe0, 0xf8, 0x7a}; + uint8_t bytesprops5[] = {0}; - uint8_t buf[40] = {0}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24785}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7341}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25044}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops3}, .v = {25, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops5}}}, + }; - uint8_t topic_bytes[] = {0xa0}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xdc, 0xc1, 0x1, 0x1b, 0x96, 0xd4, 0x1a, 0x9, 0x9c, 0xde, 0x17, 0xa0, 0x94, 0x68}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15036, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 2876 [("\143\161\221\224\191",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("rT\145\ay\160\215s,\146c\129\150>@!/\217\141",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\r\184\142p\151\204\170\249\180/\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\235\167\DLE\217\198\169\175\SI\182\ESC",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("G\130\214\&0\b\EM/\194\249\193\148`\222\217\ETXQZ\251\&7\n\147k\254\158t\249\130\219-E",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\SO\205\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("\175\GS\210~\190\GS\178\&9\230=\236|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\213\RSA\148\250i2Cbmo\147D\254\170\&33p\218\CAN\232\206\SO\142\&7",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\169\DEL\233~\135W\168q\226\158\197\227\151}9",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropCorrelationData +// "\177\207\186!\SUB\162\215\147X\144",PropWildcardSubscriptionAvailable 78,PropResponseInformation +// "[\NAK\229M",PropSubscriptionIdentifierAvailable 176,PropTopicAlias 10740,PropPayloadFormatIndicator +// 225,PropWildcardSubscriptionAvailable 1,PropSharedSubscriptionAvailable 127,PropResponseInformation +// "\ENQ\229\169\159Q\161\r6\245\220\&4",PropRequestResponseInformation 127] +TEST(Subscribe5QCTest, Encode28) { + uint8_t pkt[] = {0x82, 0xd4, 0x1, 0xb, 0x3c, 0x31, 0x9, 0x0, 0xa, 0xb1,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37, 0x1, 0x0, 0xf, 0xa9, 0x7f, 0xe9, 0x7e, 0x87, + 0x57, 0xa8, 0x71, 0xe2, 0x9e, 0xc5, 0xe3, 0x97, 0x7d, 0x39, 0x2}; + + uint8_t buf[225] = {0}; + + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x8f, 0xa1, 0xdd, 0xe0, 0xbf}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x72, 0x54, 0x91, 0x7, 0x79, 0xa0, 0xd7, 0x73, 0x2c, 0x92, + 0x63, 0x81, 0x96, 0x3e, 0x40, 0x21, 0x2f, 0xd9, 0x8d}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd, 0xb8, 0x8e, 0x70, 0x97, 0xcc, 0xaa, 0xf9, 0xb4, 0x2f, 0xd2}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xeb, 0xa7, 0x10, 0xd9, 0xc6, 0xa9, 0xaf, 0xf, 0xb6, 0x1b}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x47, 0x82, 0xd6, 0x30, 0x8, 0x19, 0x2f, 0xc2, 0xf9, 0xc1, + 0x94, 0x60, 0xde, 0xd9, 0x3, 0x51, 0x5a, 0xfb, 0x37, 0xa, + 0x93, 0x6b, 0xfe, 0x9e, 0x74, 0xf9, 0x82, 0xdb, 0x2d, 0x45}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xe, 0xcd, 0xce}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xaf, 0x1d, 0xd2, 0x7e, 0xbe, 0x1d, 0xb2, 0x39, 0xe6, 0x3d, 0xec, 0x7c}; + lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd5, 0x1e, 0x41, 0x94, 0xfa, 0x69, 0x32, 0x43, 0x62, 0x6d, 0x6f, 0x93, 0x44, + 0xfe, 0xaa, 0x33, 0x33, 0x70, 0xda, 0x18, 0xe8, 0xce, 0xe, 0x8e, 0x37}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa9, 0x7f, 0xe9, 0x7e, 0x87, 0x57, 0xa8, 0x71, + 0xe2, 0x9e, 0xc5, 0xe3, 0x97, 0x7d, 0x39}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0xb1, 0xcf, 0xba, 0x21, 0x1a, 0xa2, 0xd7, 0x93, 0x58, 0x90}; + uint8_t bytesprops1[] = {0x5b, 0x15, 0xe5, 0x4d}; + uint8_t bytesprops2[] = {0x5, 0xe5, 0xa9, 0x9f, 0x51, 0xa1, 0xd, 0x36, 0xf5, 0xdc, 0x34}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10740}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 127}}, + }; - uint8_t bytesprops0[] = {0xae, 0x3d, 0x9d, 0x80, 0xad}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2876, 10, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 30960 [("\185\236\245\223\167kV\209\203\206v",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("`\208\168\173\228W\128\NUL\ESC\220\215\244'8\132 +// \151\&8\151\138\SO\228g",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\196b\128&>\147\253\195D\218\SI\NAK\EOT\ETBV\195\140\"s\215\166Z:9",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("=|\155\128\168\238V\248\201^w7\200+\247\FS\194\185\218\184",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty "\149" +// "\247\196\167(\a8\153M\220l\USq\252R\182[",PropWildcardSubscriptionAvailable 231,PropTopicAlias 32292,PropContentType +// "i\CANt\218\SIGE\189\158\211`\130\195\240M15.a\250\135$",PropAuthenticationData +// "\131\239B\132\161W\226\&88\187\228\191\DC4\200\209\NAKr\249",PropPayloadFormatIndicator 255,PropUserProperty +// "\175\231\176\254\238\r\145\SIDk\CAN[\157\153l\185\146\254\184\238\218\SI\134\244\ETXM" +// "\253\140\167H\b",PropAuthenticationMethod "\182\190\172\245k)\163PB\253",PropWillDelayInterval +// 27287,PropRetainAvailable 119,PropServerReference +// "l\r\149\216\138\253\166\209z\f\230\DEL[\195\236\169\FS\250",PropSharedSubscriptionAvailable +// 23,PropRequestProblemInformation 121,PropResponseTopic +// "|81`lO\243\&8d\227\SI\169\176`\248\246\239:-7\193?\137B8\CAN\172p\205",PropSubscriptionIdentifier +// 14,PropPayloadFormatIndicator 208,PropMessageExpiryInterval 26592,PropContentType +// "%]\187\SI\207\153\181\169",PropMessageExpiryInterval 19734,PropAuthenticationMethod +// "\RS\231\216\STXEz\172\208Le\188\&2\RS\132He\185",PropCorrelationData +// "|d<\DC44\161uC\143\209\248\DEL5)\225V\251@\235\160\240\210m<>a\166\&5F",PropMessageExpiryInterval +// 27232,PropAuthenticationData +// "\226\166a\147E\132S\247\128\205_\247\169\152\&68\131\171\DC4\DC3\ACKng=\169L\230\&1\161",PropMaximumPacketSize +// 22761,PropMessageExpiryInterval 11220] +TEST(Subscribe5QCTest, Encode29) { + uint8_t pkt[] = { + 0x82, 0x99, 0x3, 0x78, 0xf0, 0xb8, 0x2, 0x26, 0x0, 0x1, 0x95, 0x0, 0x10, 0xf7, 0xc4, 0xa7, 0x28, 0x7, 0x38, + 0x99, 0x4d, 0xdc, 0x6c, 0x1f, 0x71, 0xfc, 0x52, 0xb6, 0x5b, 0x28, 0xe7, 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, 0xf7, 0x1c, 0xc2, 0xb9, 0xda, 0xb8, 0x1}; + + uint8_t buf[422] = {0}; + + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xb9, 0xec, 0xf5, 0xdf, 0xa7, 0x6b, 0x56, 0xd1, 0xcb, 0xce, 0x76}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x60, 0xd0, 0xa8, 0xad, 0xe4, 0x57, 0x80, 0x0, 0x1b, 0xdc, 0xd7, 0xf4, + 0x27, 0x38, 0x84, 0x20, 0x97, 0x38, 0x97, 0x8a, 0xe, 0xe4, 0x67}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc4, 0x62, 0x80, 0x26, 0x3e, 0x93, 0xfd, 0xc3, 0x44, 0xda, 0xf, 0x15, + 0x4, 0x17, 0x56, 0xc3, 0x8c, 0x22, 0x73, 0xd7, 0xa6, 0x5a, 0x3a, 0x39}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x3d, 0x7c, 0x9b, 0x80, 0xa8, 0xee, 0x56, 0xf8, 0xc9, 0x5e, + 0x77, 0x37, 0xc8, 0x2b, 0xf7, 0x1c, 0xc2, 0xb9, 0xda, 0xb8}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops1[] = {0xf7, 0xc4, 0xa7, 0x28, 0x7, 0x38, 0x99, 0x4d, + 0xdc, 0x6c, 0x1f, 0x71, 0xfc, 0x52, 0xb6, 0x5b}; + uint8_t bytesprops0[] = {0x95}; + uint8_t bytesprops2[] = {0x69, 0x18, 0x74, 0xda, 0xf, 0x47, 0x45, 0xbd, 0x9e, 0xd3, 0x60, + 0x82, 0xc3, 0xf0, 0x4d, 0x31, 0x35, 0x2e, 0x61, 0xfa, 0x87, 0x24}; + uint8_t bytesprops3[] = {0x83, 0xef, 0x42, 0x84, 0xa1, 0x57, 0xe2, 0x38, 0x38, + 0xbb, 0xe4, 0xbf, 0x14, 0xc8, 0xd1, 0x15, 0x72, 0xf9}; + uint8_t bytesprops5[] = {0xfd, 0x8c, 0xa7, 0x48, 0x8}; + uint8_t bytesprops4[] = {0xaf, 0xe7, 0xb0, 0xfe, 0xee, 0xd, 0x91, 0xf, 0x44, 0x6b, 0x18, 0x5b, 0x9d, + 0x99, 0x6c, 0xb9, 0x92, 0xfe, 0xb8, 0xee, 0xda, 0xf, 0x86, 0xf4, 0x3, 0x4d}; + uint8_t bytesprops6[] = {0xb6, 0xbe, 0xac, 0xf5, 0x6b, 0x29, 0xa3, 0x50, 0x42, 0xfd}; + uint8_t bytesprops7[] = {0x6c, 0xd, 0x95, 0xd8, 0x8a, 0xfd, 0xa6, 0xd1, 0x7a, + 0xc, 0xe6, 0x7f, 0x5b, 0xc3, 0xec, 0xa9, 0x1c, 0xfa}; + uint8_t bytesprops8[] = {0x7c, 0x38, 0x31, 0x60, 0x6c, 0x4f, 0xf3, 0x38, 0x64, 0xe3, 0xf, 0xa9, 0xb0, 0x60, 0xf8, + 0xf6, 0xef, 0x3a, 0x2d, 0x37, 0xc1, 0x3f, 0x89, 0x42, 0x38, 0x18, 0xac, 0x70, 0xcd}; + uint8_t bytesprops9[] = {0x25, 0x5d, 0xbb, 0xf, 0xcf, 0x99, 0xb5, 0xa9}; + uint8_t bytesprops10[] = {0x1e, 0xe7, 0xd8, 0x2, 0x45, 0x7a, 0xac, 0xd0, 0x4c, + 0x65, 0xbc, 0x32, 0x1e, 0x84, 0x48, 0x65, 0xb9}; + uint8_t bytesprops11[] = {0x7c, 0x64, 0x3c, 0x14, 0x34, 0xa1, 0x75, 0x43, 0x8f, 0xd1, 0xf8, 0x7f, 0x35, 0x29, 0xe1, + 0x56, 0xfb, 0x40, 0xeb, 0xa0, 0xf0, 0xd2, 0x6d, 0x3c, 0x3e, 0x61, 0xa6, 0x35, 0x46}; + uint8_t bytesprops12[] = {0xe2, 0xa6, 0x61, 0x93, 0x45, 0x84, 0x53, 0xf7, 0x80, 0xcd, 0x5f, 0xf7, 0xa9, 0x98, 0x36, + 0x38, 0x83, 0xab, 0x14, 0x13, 0x6, 0x6e, 0x67, 0x3d, 0xa9, 0x4c, 0xe6, 0x31, 0xa1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32292}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops4}, .v = {5, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27287}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26592}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19734}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27232}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22761}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11220}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 20635, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30960, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 19821 [("\162",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\200\151\208c\FS\228\171\229\143c\210\no\DC1F(\147w\158",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("w\206\216e\255h\237\252\178.",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\196)\168x0\242\199\SI\251\223L\150\183\234\205\197\137`\215'\aD\164\EOT5\148\ETB\189",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropAuthenticationMethod +// "x\205\226K\169ZM\228\155,w\FS\a\193n\192\225N\251\166\241\230\159\172\249\144",PropSharedSubscriptionAvailable +// 169,PropWildcardSubscriptionAvailable 229,PropReceiveMaximum 27247,PropSharedSubscriptionAvailable 7,PropTopicAlias +// 6098,PropWillDelayInterval 7011,PropResponseTopic "\ENQR]\202\145\167\246\253\199",PropAssignedClientIdentifier +// "\196\163>\154q<\245\182\NAK\155\254,\137MQ\234\190h\SYN",PropServerKeepAlive 28601] +TEST(Subscribe5QCTest, Encode30) { + uint8_t pkt[] = {0x82, 0x9c, 0x1, 0x4d, 0x6d, 0x53, 0x15, 0x0, 0x1a, 0x78, 0xcd, 0xe2, 0x4b, 0xa9, 0x5a, 0x4d, + 0xe4, 0x9b, 0x2c, 0x77, 0x1c, 0x7, 0xc1, 0x6e, 0xc0, 0xe1, 0x4e, 0xfb, 0xa6, 0xf1, 0xe6, 0x9f, + 0xac, 0xf9, 0x90, 0x2a, 0xa9, 0x28, 0xe5, 0x21, 0x6a, 0x6f, 0x2a, 0x7, 0x23, 0x17, 0xd2, 0x18, + 0x0, 0x0, 0x1b, 0x63, 0x8, 0x0, 0x9, 0x5, 0x52, 0x5d, 0xca, 0x91, 0xa7, 0xf6, 0xfd, 0xc7, + 0x12, 0x0, 0x13, 0xc4, 0xa3, 0x3e, 0x9a, 0x71, 0x3c, 0xf5, 0xb6, 0x15, 0x9b, 0xfe, 0x2c, 0x89, + 0x4d, 0x51, 0xea, 0xbe, 0x68, 0x16, 0x13, 0x6f, 0xb9, 0x0, 0x1, 0xa2, 0x2, 0x0, 0x13, 0xc8, + 0x97, 0xd0, 0x63, 0x1c, 0xe4, 0xab, 0xe5, 0x8f, 0x63, 0xd2, 0xa, 0x6f, 0x11, 0x46, 0x28, 0x93, + 0x77, 0x9e, 0x1, 0x0, 0xa, 0x77, 0xce, 0xd8, 0x65, 0xff, 0x68, 0xed, 0xfc, 0xb2, 0x2e, 0x2, + 0x0, 0x1c, 0xc4, 0x29, 0xa8, 0x78, 0x30, 0xf2, 0xc7, 0xf, 0xfb, 0xdf, 0x4c, 0x96, 0xb7, 0xea, + 0xcd, 0xc5, 0x89, 0x60, 0xd7, 0x27, 0x7, 0x44, 0xa4, 0x4, 0x35, 0x94, 0x17, 0xbd, 0x2}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[169] = {0}; -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\196\196\197 -// \157\210\229\244\227\218\220\203\176\251\&4\NUL\171\DLE#\251\&9\174+\EM\197\STXt", _pubPktID = 5923, _pubBody = -// "\US[\n\SI=4\153\142(\NAK", _pubProps = [PropRequestProblemInformation 156,PropCorrelationData -// "`\155\153d\US\178\244\177\&8\195B\197\187v\248\GS\180~\154\140G",PropTopicAlias 14650,PropMaximumPacketSize -// 22984,PropAssignedClientIdentifier -// "5C^\212\n\USz\255\191\"\ETB\247\135\144\166i\134\\7?6?",PropWildcardSubscriptionAvailable 16,PropCorrelationData -// "\176*\EM_j\199\&1",PropServerKeepAlive 3990,PropAssignedClientIdentifier -// "EU4\136:\n\186\239\DC2\241R\160\133\SUB\205C\ACK\135\199\234cYV\226Iw\156\243\&4",PropAssignedClientIdentifier -// "A\243\226\158\SO\186\SI\\F_\v\252\140\180\DC2\250<\165\129\SUB",PropWildcardSubscriptionAvailable 203]} -TEST(Publish5QCTest, Encode34) { - uint8_t pkt[] = {0x34, 0xae, 0x1, 0x0, 0x1b, 0xc4, 0xc4, 0xc5, 0x20, 0x9d, 0xd2, 0xe5, 0xf4, 0xe3, 0xda, 0xdc, 0xcb, - 0xb0, 0xfb, 0x34, 0x0, 0xab, 0x10, 0x23, 0xfb, 0x39, 0xae, 0x2b, 0x19, 0xc5, 0x2, 0x74, 0x17, 0x23, - 0x83, 0x1, 0x17, 0x9c, 0x9, 0x0, 0x15, 0x60, 0x9b, 0x99, 0x64, 0x1f, 0xb2, 0xf4, 0xb1, 0x38, 0xc3, - 0x42, 0xc5, 0xbb, 0x76, 0xf8, 0x1d, 0xb4, 0x7e, 0x9a, 0x8c, 0x47, 0x23, 0x39, 0x3a, 0x27, 0x0, 0x0, - 0x59, 0xc8, 0x12, 0x0, 0x16, 0x35, 0x43, 0x5e, 0xd4, 0xa, 0x1f, 0x7a, 0xff, 0xbf, 0x22, 0x17, 0xf7, - 0x87, 0x90, 0xa6, 0x69, 0x86, 0x5c, 0x37, 0x3f, 0x36, 0x3f, 0x28, 0x10, 0x9, 0x0, 0x7, 0xb0, 0x2a, - 0x19, 0x5f, 0x6a, 0xc7, 0x31, 0x13, 0xf, 0x96, 0x12, 0x0, 0x1d, 0x45, 0x55, 0x34, 0x88, 0x3a, 0xa, - 0xba, 0xef, 0x12, 0xf1, 0x52, 0xa0, 0x85, 0x1a, 0xcd, 0x43, 0x6, 0x87, 0xc7, 0xea, 0x63, 0x59, 0x56, - 0xe2, 0x49, 0x77, 0x9c, 0xf3, 0x34, 0x12, 0x0, 0x14, 0x41, 0xf3, 0xe2, 0x9e, 0xe, 0xba, 0xf, 0x5c, - 0x46, 0x5f, 0xb, 0xfc, 0x8c, 0xb4, 0x12, 0xfa, 0x3c, 0xa5, 0x81, 0x1a, 0x28, 0xcb, 0x1f, 0x5b, 0xa, - 0xf, 0x3d, 0x34, 0x99, 0x8e, 0x28, 0x15}; - - uint8_t buf[187] = {0}; - - uint8_t topic_bytes[] = {0xc4, 0xc4, 0xc5, 0x20, 0x9d, 0xd2, 0xe5, 0xf4, 0xe3, 0xda, 0xdc, 0xcb, 0xb0, 0xfb, - 0x34, 0x0, 0xab, 0x10, 0x23, 0xfb, 0x39, 0xae, 0x2b, 0x19, 0xc5, 0x2, 0x74}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x1f, 0x5b, 0xa, 0xf, 0x3d, 0x34, 0x99, 0x8e, 0x28, 0x15}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; - - uint8_t bytesprops0[] = {0x60, 0x9b, 0x99, 0x64, 0x1f, 0xb2, 0xf4, 0xb1, 0x38, 0xc3, 0x42, - 0xc5, 0xbb, 0x76, 0xf8, 0x1d, 0xb4, 0x7e, 0x9a, 0x8c, 0x47}; - uint8_t bytesprops1[] = {0x35, 0x43, 0x5e, 0xd4, 0xa, 0x1f, 0x7a, 0xff, 0xbf, 0x22, 0x17, - 0xf7, 0x87, 0x90, 0xa6, 0x69, 0x86, 0x5c, 0x37, 0x3f, 0x36, 0x3f}; - uint8_t bytesprops2[] = {0xb0, 0x2a, 0x19, 0x5f, 0x6a, 0xc7, 0x31}; - uint8_t bytesprops3[] = {0x45, 0x55, 0x34, 0x88, 0x3a, 0xa, 0xba, 0xef, 0x12, 0xf1, 0x52, 0xa0, 0x85, 0x1a, 0xcd, - 0x43, 0x6, 0x87, 0xc7, 0xea, 0x63, 0x59, 0x56, 0xe2, 0x49, 0x77, 0x9c, 0xf3, 0x34}; - uint8_t bytesprops4[] = {0x41, 0xf3, 0xe2, 0x9e, 0xe, 0xba, 0xf, 0x5c, 0x46, 0x5f, - 0xb, 0xfc, 0x8c, 0xb4, 0x12, 0xfa, 0x3c, 0xa5, 0x81, 0x1a}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xa2}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc8, 0x97, 0xd0, 0x63, 0x1c, 0xe4, 0xab, 0xe5, 0x8f, 0x63, + 0xd2, 0xa, 0x6f, 0x11, 0x46, 0x28, 0x93, 0x77, 0x9e}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x77, 0xce, 0xd8, 0x65, 0xff, 0x68, 0xed, 0xfc, 0xb2, 0x2e}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc4, 0x29, 0xa8, 0x78, 0x30, 0xf2, 0xc7, 0xf, 0xfb, 0xdf, + 0x4c, 0x96, 0xb7, 0xea, 0xcd, 0xc5, 0x89, 0x60, 0xd7, 0x27, + 0x7, 0x44, 0xa4, 0x4, 0x35, 0x94, 0x17, 0xbd}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x78, 0xcd, 0xe2, 0x4b, 0xa9, 0x5a, 0x4d, 0xe4, 0x9b, 0x2c, 0x77, 0x1c, 0x7, + 0xc1, 0x6e, 0xc0, 0xe1, 0x4e, 0xfb, 0xa6, 0xf1, 0xe6, 0x9f, 0xac, 0xf9, 0x90}; + uint8_t bytesprops1[] = {0x5, 0x52, 0x5d, 0xca, 0x91, 0xa7, 0xf6, 0xfd, 0xc7}; + uint8_t bytesprops2[] = {0xc4, 0xa3, 0x3e, 0x9a, 0x71, 0x3c, 0xf5, 0xb6, 0x15, 0x9b, + 0xfe, 0x2c, 0x89, 0x4d, 0x51, 0xea, 0xbe, 0x68, 0x16}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14650}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22984}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3990}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27247}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6098}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7011}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28601}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 5923, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19821, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 21770 +// [("\139=b\145p\157\223b|\STX[\197\203\167e^\171\235\151}k\149\EOT\132\SO\239\218\159\152",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\ACK\227+\134\ETB\170\253\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\148-\198\ACKO:X\191\162",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\128\150\&7\b\f^g\182Dr\t8k\240\170\&7",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("jBu\DC1!5\207\193K6\164\a\EOT\189m\169\154}\186\220\246\141\&8\167\GS\184\RS\192",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("s\207#\r\188b4B|f>\135\234\142\&7\202\154\186",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropSubscriptionIdentifierAvailable +// 66,PropContentType ",Gd\165.?\DC2b\148H\244]\NAK\179\b\230\199\162\249/\168\255",PropContentType +// "\161\128\&7\169\SI\STX\132\142\241\r\DC3\234e\153\180\193j\164\DC2\230\220a\194H\154\217z?",PropSubscriptionIdentifier +// 20,PropServerKeepAlive 27818,PropWildcardSubscriptionAvailable 207,PropAuthenticationMethod +// "0\248\178\173\199\STX\t5\251\236 /FAy\158\174\230\SYN\152\151",PropPayloadFormatIndicator 0,PropCorrelationData +// "&\250\151Y",PropAuthenticationData +// "e\191\149m\242\ACKN\208\EOTu\GS\STX\142\155\b\225\243\154\172Z~O\250\165\157",PropRequestProblemInformation +// 85,PropMessageExpiryInterval 32539,PropRetainAvailable 248,PropWillDelayInterval 17574,PropRequestResponseInformation +// 127,PropSharedSubscriptionAvailable 69,PropTopicAlias 32610,PropTopicAliasMaximum 1124,PropRequestProblemInformation +// 52,PropServerKeepAlive 14995,PropSubscriptionIdentifier 22,PropWildcardSubscriptionAvailable +// 199,PropMaximumPacketSize 31108,PropRetainAvailable 211,PropCorrelationData "6\247\174\209",PropTopicAlias 25422] +TEST(Subscribe5QCTest, Encode31) { + uint8_t pkt[] = { + 0x82, 0xb2, 0x2, 0x55, 0xa, 0xb0, 0x1, 0x29, 0x42, 0x3, 0x0, 0x16, 0x2c, 0x47, 0x64, 0xa5, 0x2e, 0x3f, 0x12, + 0x62, 0x94, 0x48, 0xf4, 0x5d, 0x15, 0xb3, 0x8, 0xe6, 0xc7, 0xa2, 0xf9, 0x2f, 0xa8, 0xff, 0x3, 0x0, 0x1c, 0xa1, + 0x80, 0x37, 0xa9, 0xf, 0x2, 0x84, 0x8e, 0xf1, 0xd, 0x13, 0xea, 0x65, 0x99, 0xb4, 0xc1, 0x6a, 0xa4, 0x12, 0xe6, + 0xdc, 0x61, 0xc2, 0x48, 0x9a, 0xd9, 0x7a, 0x3f, 0xb, 0x14, 0x13, 0x6c, 0xaa, 0x28, 0xcf, 0x15, 0x0, 0x15, 0x30, + 0xf8, 0xb2, 0xad, 0xc7, 0x2, 0x9, 0x35, 0xfb, 0xec, 0x20, 0x2f, 0x46, 0x41, 0x79, 0x9e, 0xae, 0xe6, 0x16, 0x98, + 0x97, 0x1, 0x0, 0x9, 0x0, 0x4, 0x26, 0xfa, 0x97, 0x59, 0x16, 0x0, 0x19, 0x65, 0xbf, 0x95, 0x6d, 0xf2, 0x6, + 0x4e, 0xd0, 0x4, 0x75, 0x1d, 0x2, 0x8e, 0x9b, 0x8, 0xe1, 0xf3, 0x9a, 0xac, 0x5a, 0x7e, 0x4f, 0xfa, 0xa5, 0x9d, + 0x17, 0x55, 0x2, 0x0, 0x0, 0x7f, 0x1b, 0x25, 0xf8, 0x18, 0x0, 0x0, 0x44, 0xa6, 0x19, 0x7f, 0x2a, 0x45, 0x23, + 0x7f, 0x62, 0x22, 0x4, 0x64, 0x17, 0x34, 0x13, 0x3a, 0x93, 0xb, 0x16, 0x28, 0xc7, 0x27, 0x0, 0x0, 0x79, 0x84, + 0x25, 0xd3, 0x9, 0x0, 0x4, 0x36, 0xf7, 0xae, 0xd1, 0x23, 0x63, 0x4e, 0x0, 0x1d, 0x8b, 0x3d, 0x62, 0x91, 0x70, + 0x9d, 0xdf, 0x62, 0x7c, 0x2, 0x5b, 0xc5, 0xcb, 0xa7, 0x65, 0x5e, 0xab, 0xeb, 0x97, 0x7d, 0x6b, 0x95, 0x4, 0x84, + 0xe, 0xef, 0xda, 0x9f, 0x98, 0x1, 0x0, 0x8, 0x6, 0xe3, 0x2b, 0x86, 0x17, 0xaa, 0xfd, 0xa6, 0x2, 0x0, 0x9, + 0x94, 0x2d, 0xc6, 0x6, 0x4f, 0x3a, 0x58, 0xbf, 0xa2, 0x2, 0x0, 0x10, 0x80, 0x96, 0x37, 0x8, 0xc, 0x5e, 0x67, + 0xb6, 0x44, 0x72, 0x9, 0x38, 0x6b, 0xf0, 0xaa, 0x37, 0x1, 0x0, 0x1c, 0x6a, 0x42, 0x75, 0x11, 0x21, 0x35, 0xcf, + 0xc1, 0x4b, 0x36, 0xa4, 0x7, 0x4, 0xbd, 0x6d, 0xa9, 0x9a, 0x7d, 0xba, 0xdc, 0xf6, 0x8d, 0x38, 0xa7, 0x1d, 0xb8, + 0x1e, 0xc0, 0x2, 0x0, 0x12, 0x73, 0xcf, 0x23, 0xd, 0xbc, 0x62, 0x34, 0x42, 0x7c, 0x66, 0x3e, 0x87, 0xea, 0x8e, + 0x37, 0xca, 0x9a, 0xba, 0x1}; -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\158\"Y{N(\209\&3h\199\152\255\233\186\191", _pubPktID = 26160, _pubBody = -// "\EM\255\ESCWL\245\184\&2\192\185X\214\233t\187 \133\DC4Q", _pubProps = [PropAssignedClientIdentifier -// "\DEL;\188\154\215\\\v\247j\134",PropMaximumQoS 41,PropSharedSubscriptionAvailable 165,PropMessageExpiryInterval -// 27721,PropSubscriptionIdentifier 3,PropAuthenticationData -// "\ACK\242\166\181\172vZ\174\162\US\158\144",PropAssignedClientIdentifier -// "\GS\180_\225\221o",PropSharedSubscriptionAvailable 126,PropSubscriptionIdentifierAvailable 129]} -TEST(Publish5QCTest, Encode35) { - uint8_t pkt[] = {0x3d, 0x5b, 0x0, 0xf, 0x9e, 0x22, 0x59, 0x7b, 0x4e, 0x28, 0xd1, 0x33, 0x68, 0xc7, 0x98, 0xff, - 0xe9, 0xba, 0xbf, 0x66, 0x30, 0x34, 0x12, 0x0, 0xa, 0x7f, 0x3b, 0xbc, 0x9a, 0xd7, 0x5c, 0xb, - 0xf7, 0x6a, 0x86, 0x24, 0x29, 0x2a, 0xa5, 0x2, 0x0, 0x0, 0x6c, 0x49, 0xb, 0x3, 0x16, 0x0, - 0xc, 0x6, 0xf2, 0xa6, 0xb5, 0xac, 0x76, 0x5a, 0xae, 0xa2, 0x1f, 0x9e, 0x90, 0x12, 0x0, 0x6, - 0x1d, 0xb4, 0x5f, 0xe1, 0xdd, 0x6f, 0x2a, 0x7e, 0x29, 0x81, 0x19, 0xff, 0x1b, 0x57, 0x4c, 0xf5, - 0xb8, 0x32, 0xc0, 0xb9, 0x58, 0xd6, 0xe9, 0x74, 0xbb, 0x20, 0x85, 0x14, 0x51}; - - uint8_t buf[103] = {0}; - - uint8_t topic_bytes[] = {0x9e, 0x22, 0x59, 0x7b, 0x4e, 0x28, 0xd1, 0x33, 0x68, 0xc7, 0x98, 0xff, 0xe9, 0xba, 0xbf}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x19, 0xff, 0x1b, 0x57, 0x4c, 0xf5, 0xb8, 0x32, 0xc0, 0xb9, - 0x58, 0xd6, 0xe9, 0x74, 0xbb, 0x20, 0x85, 0x14, 0x51}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + uint8_t buf[319] = {0}; - uint8_t bytesprops0[] = {0x7f, 0x3b, 0xbc, 0x9a, 0xd7, 0x5c, 0xb, 0xf7, 0x6a, 0x86}; - uint8_t bytesprops1[] = {0x6, 0xf2, 0xa6, 0xb5, 0xac, 0x76, 0x5a, 0xae, 0xa2, 0x1f, 0x9e, 0x90}; - uint8_t bytesprops2[] = {0x1d, 0xb4, 0x5f, 0xe1, 0xdd, 0x6f}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x8b, 0x3d, 0x62, 0x91, 0x70, 0x9d, 0xdf, 0x62, 0x7c, 0x2, + 0x5b, 0xc5, 0xcb, 0xa7, 0x65, 0x5e, 0xab, 0xeb, 0x97, 0x7d, + 0x6b, 0x95, 0x4, 0x84, 0xe, 0xef, 0xda, 0x9f, 0x98}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6, 0xe3, 0x2b, 0x86, 0x17, 0xaa, 0xfd, 0xa6}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x94, 0x2d, 0xc6, 0x6, 0x4f, 0x3a, 0x58, 0xbf, 0xa2}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x80, 0x96, 0x37, 0x8, 0xc, 0x5e, 0x67, 0xb6, + 0x44, 0x72, 0x9, 0x38, 0x6b, 0xf0, 0xaa, 0x37}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x6a, 0x42, 0x75, 0x11, 0x21, 0x35, 0xcf, 0xc1, 0x4b, 0x36, + 0xa4, 0x7, 0x4, 0xbd, 0x6d, 0xa9, 0x9a, 0x7d, 0xba, 0xdc, + 0xf6, 0x8d, 0x38, 0xa7, 0x1d, 0xb8, 0x1e, 0xc0}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x73, 0xcf, 0x23, 0xd, 0xbc, 0x62, 0x34, 0x42, 0x7c, + 0x66, 0x3e, 0x87, 0xea, 0x8e, 0x37, 0xca, 0x9a, 0xba}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x2c, 0x47, 0x64, 0xa5, 0x2e, 0x3f, 0x12, 0x62, 0x94, 0x48, 0xf4, + 0x5d, 0x15, 0xb3, 0x8, 0xe6, 0xc7, 0xa2, 0xf9, 0x2f, 0xa8, 0xff}; + uint8_t bytesprops1[] = {0xa1, 0x80, 0x37, 0xa9, 0xf, 0x2, 0x84, 0x8e, 0xf1, 0xd, 0x13, 0xea, 0x65, 0x99, + 0xb4, 0xc1, 0x6a, 0xa4, 0x12, 0xe6, 0xdc, 0x61, 0xc2, 0x48, 0x9a, 0xd9, 0x7a, 0x3f}; + uint8_t bytesprops2[] = {0x30, 0xf8, 0xb2, 0xad, 0xc7, 0x2, 0x9, 0x35, 0xfb, 0xec, 0x20, + 0x2f, 0x46, 0x41, 0x79, 0x9e, 0xae, 0xe6, 0x16, 0x98, 0x97}; + uint8_t bytesprops3[] = {0x26, 0xfa, 0x97, 0x59}; + uint8_t bytesprops4[] = {0x65, 0xbf, 0x95, 0x6d, 0xf2, 0x6, 0x4e, 0xd0, 0x4, 0x75, 0x1d, 0x2, 0x8e, + 0x9b, 0x8, 0xe1, 0xf3, 0x9a, 0xac, 0x5a, 0x7e, 0x4f, 0xfa, 0xa5, 0x9d}; + uint8_t bytesprops5[] = {0x36, 0xf7, 0xae, 0xd1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27721}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27818}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32539}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17574}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32610}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1124}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14995}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31108}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25422}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 26160, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21770, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 24232 +// [("\228\219\211\ENQ\144\&1\EMRC\252<\249\191\134\214I\149\ENQ\204~\DC4\165\182\150\219\180^\DC2",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("js\191\171\SYN\189\226K\172j8\255\165\172\234R\174`\205\174\r)\ESCN\b\166\150\&6\151",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\195\230#0b={P\147",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = +// QoS1}),("\b\181\152j\EMo\228\134\219\174\179~\246\170>\175\209\193\138D\129\150K\v\163.\223@",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("F\212\150u\137\212\165\227\t\252\203'8\195\187\205~",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\232\133xTT\221\207\NUL",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ETX}\171pE",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("@$\166\244=%&\CANS\tx2\215\"\DLE\204\197\147\DC4nU\ENQ]\229>\EM`\246H",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\153\175\GS\173\ETB\160a\b\FS\195\152\193\STX\139\242\129\254{",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\244\&6\\v\143b\181\188\130\153t\237\185>\130",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\161g3\193\181G;",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMaximumPacketSize +// 3126,PropCorrelationData "\204\133\131*K.8\158\&1\DEL:\174yq\GS\SUB",PropMessageExpiryInterval +// 6930,PropRequestResponseInformation 253,PropContentType "\204\186%\178\187",PropTopicAliasMaximum +// 24459,PropTopicAlias 21845,PropContentType "lM\v>",PropResponseTopic +// "\199\a\138\137\&1_\135/\203/\141\153q\194\153\245B\177\156",PropAuthenticationMethod +// "",PropRequestProblemInformation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xc1, 0x8a, 0x44, 0x81, 0x96, 0x4b, 0xb, 0xa3, 0x2e, 0xdf, 0x40, + 0x1, 0x0, 0x11, 0x46, 0xd4, 0x96, 0x75, 0x89, 0xd4, 0xa5, 0xe3, 0x9, 0xfc, 0xcb, 0x27, 0x38, 0xc3, 0xbb, 0xcd, + 0x7e, 0x1, 0x0, 0x8, 0xe8, 0x85, 0x78, 0x54, 0x54, 0xdd, 0xcf, 0x0, 0x0, 0x0, 0x5, 0x3, 0x7d, 0xab, 0x70, + 0x45, 0x1, 0x0, 0x1d, 0x40, 0x24, 0xa6, 0xf4, 0x3d, 0x25, 0x26, 0x18, 0x53, 0x9, 0x78, 0x32, 0xd7, 0x22, 0x10, + 0xcc, 0xc5, 0x93, 0x14, 0x6e, 0x55, 0x5, 0x5d, 0xe5, 0x3e, 0x19, 0x60, 0xf6, 0x48, 0x0, 0x0, 0x12, 0x99, 0xaf, + 0x1d, 0xad, 0x17, 0xa0, 0x61, 0x8, 0x1c, 0xc3, 0x98, 0xc1, 0x2, 0x8b, 0xf2, 0x81, 0xfe, 0x7b, 0x0, 0x0, 0xf, + 0xf4, 0x36, 0x5c, 0x76, 0x8f, 0x62, 0xb5, 0xbc, 0x82, 0x99, 0x74, 0xed, 0xb9, 0x3e, 0x82, 0x2, 0x0, 0x7, 0xa1, + 0x67, 0x33, 0xc1, 0xb5, 0x47, 0x3b, 0x1}; -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\151", _pubPktID = 0, _pubBody = -// "\216N\144\&7\CAN\136\v\176\152", _pubProps = [PropUserProperty -// "\189\239\214\"\236'\198\247.\STX\r\138U\133\244\&8\SOH\167\216\SI\255eT6\158" "",PropTopicAlias -// 5174,PropReceiveMaximum 15173,PropUserProperty "\208\&6GO\242\248\172\188" -// "\"\233C\148X@F6\128\b\164",PropSubscriptionIdentifier 2,PropTopicAlias 18460,PropSubscriptionIdentifierAvailable -// 89,PropRequestProblemInformation 159,PropResponseTopic "",PropReasonString "\ETX\253\141\&6K\"\241\182l\246\252\208 -// Q\170p\168\167\139}\EOT\220",PropWillDelayInterval 12822,PropUserProperty -// "@\175\167\247\137c\SIi\183\172\248\149m\NAK\SOH\146Y\128\201)\201S\159hP\DC2\251\187kz" -// "o\211\244\255\173\195\219\156,7\189OK\t\218qv\138#\US$\218b\232\132\&3\131\180\163\RS"]} -TEST(Publish5QCTest, Encode36) { - uint8_t pkt[] = {0x39, 0xb5, 0x1, 0x0, 0x1, 0x97, 0xa7, 0x1, 0x26, 0x0, 0x19, 0xbd, 0xef, 0xd6, 0x22, 0xec, 0x27, - 0xc6, 0xf7, 0x2e, 0x2, 0xd, 0x8a, 0x55, 0x85, 0xf4, 0x38, 0x1, 0xa7, 0xd8, 0xf, 0xff, 0x65, 0x54, - 0x36, 0x9e, 0x0, 0x0, 0x23, 0x14, 0x36, 0x21, 0x3b, 0x45, 0x26, 0x0, 0x8, 0xd0, 0x36, 0x47, 0x4f, - 0xf2, 0xf8, 0xac, 0xbc, 0x0, 0xb, 0x22, 0xe9, 0x43, 0x94, 0x58, 0x40, 0x46, 0x36, 0x80, 0x8, 0xa4, - 0xb, 0x2, 0x23, 0x48, 0x1c, 0x29, 0x59, 0x17, 0x9f, 0x8, 0x0, 0x0, 0x1f, 0x0, 0x16, 0x3, 0xfd, - 0x8d, 0x36, 0x4b, 0x22, 0xf1, 0xb6, 0x6c, 0xf6, 0xfc, 0xd0, 0x20, 0x51, 0xaa, 0x70, 0xa8, 0xa7, 0x8b, - 0x7d, 0x4, 0xdc, 0x18, 0x0, 0x0, 0x32, 0x16, 0x26, 0x0, 0x1e, 0x40, 0xaf, 0xa7, 0xf7, 0x89, 0x63, - 0xf, 0x69, 0xb7, 0xac, 0xf8, 0x95, 0x6d, 0x15, 0x1, 0x92, 0x59, 0x80, 0xc9, 0x29, 0xc9, 0x53, 0x9f, - 0x68, 0x50, 0x12, 0xfb, 0xbb, 0x6b, 0x7a, 0x0, 0x1e, 0x6f, 0xd3, 0xf4, 0xff, 0xad, 0xc3, 0xdb, 0x9c, - 0x2c, 0x37, 0xbd, 0x4f, 0x4b, 0x9, 0xda, 0x71, 0x76, 0x8a, 0x23, 0x1f, 0x24, 0xda, 0x62, 0xe8, 0x84, - 0x33, 0x83, 0xb4, 0xa3, 0x1e, 0xd8, 0x4e, 0x90, 0x37, 0x18, 0x88, 0xb, 0xb0, 0x98}; + uint8_t buf[321] = {0}; - uint8_t buf[194] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xe4, 0xdb, 0xd3, 0x5, 0x90, 0x31, 0x19, 0x52, 0x43, 0xfc, 0x3c, 0xf9, 0xbf, 0x86, + 0xd6, 0x49, 0x95, 0x5, 0xcc, 0x7e, 0x14, 0xa5, 0xb6, 0x96, 0xdb, 0xb4, 0x5e, 0x12}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6a, 0x73, 0xbf, 0xab, 0x16, 0xbd, 0xe2, 0x4b, 0xac, 0x6a, + 0x38, 0xff, 0xa5, 0xac, 0xea, 0x52, 0xae, 0x60, 0xcd, 0xae, + 0xd, 0x29, 0x1b, 0x4e, 0x8, 0xa6, 0x96, 0x36, 0x97}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc3, 0xe6, 0x23, 0x30, 0x62, 0x3d, 0x7b, 0x50, 0x93}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8, 0xb5, 0x98, 0x6a, 0x19, 0x6f, 0xe4, 0x86, 0xdb, 0xae, + 0xb3, 0x7e, 0xf6, 0xaa, 0x3e, 0xaf, 0xd1, 0xc1, 0x8a, 0x44, + 0x81, 0x96, 0x4b, 0xb, 0xa3, 0x2e, 0xdf, 0x40}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x46, 0xd4, 0x96, 0x75, 0x89, 0xd4, 0xa5, 0xe3, 0x9, + 0xfc, 0xcb, 0x27, 0x38, 0xc3, 0xbb, 0xcd, 0x7e}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe8, 0x85, 0x78, 0x54, 0x54, 0xdd, 0xcf, 0x0}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3, 0x7d, 0xab, 0x70, 0x45}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x40, 0x24, 0xa6, 0xf4, 0x3d, 0x25, 0x26, 0x18, 0x53, 0x9, + 0x78, 0x32, 0xd7, 0x22, 0x10, 0xcc, 0xc5, 0x93, 0x14, 0x6e, + 0x55, 0x5, 0x5d, 0xe5, 0x3e, 0x19, 0x60, 0xf6, 0x48}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x99, 0xaf, 0x1d, 0xad, 0x17, 0xa0, 0x61, 0x8, 0x1c, + 0xc3, 0x98, 0xc1, 0x2, 0x8b, 0xf2, 0x81, 0xfe, 0x7b}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xf4, 0x36, 0x5c, 0x76, 0x8f, 0x62, 0xb5, 0xbc, + 0x82, 0x99, 0x74, 0xed, 0xb9, 0x3e, 0x82}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xa1, 0x67, 0x33, 0xc1, 0xb5, 0x47, 0x3b}; + lwmqtt_string_t topic_filter_s10 = {7, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xcc, 0x85, 0x83, 0x2a, 0x4b, 0x2e, 0x38, 0x9e, + 0x31, 0x7f, 0x3a, 0xae, 0x79, 0x71, 0x1d, 0x1a}; + uint8_t bytesprops1[] = {0xcc, 0xba, 0x25, 0xb2, 0xbb}; + uint8_t bytesprops2[] = {0x6c, 0x4d, 0xb, 0x3e}; + uint8_t bytesprops3[] = {0xc7, 0x7, 0x8a, 0x89, 0x31, 0x5f, 0x87, 0x2f, 0xcb, 0x2f, + 0x8d, 0x99, 0x71, 0xc2, 0x99, 0xf5, 0x42, 0xb1, 0x9c}; + uint8_t bytesprops4[] = {0}; - uint8_t topic_bytes[] = {0x97}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xd8, 0x4e, 0x90, 0x37, 0x18, 0x88, 0xb, 0xb0, 0x98}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3126}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6930}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24459}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21845}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 137}}, + }; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops0[] = {0xbd, 0xef, 0xd6, 0x22, 0xec, 0x27, 0xc6, 0xf7, 0x2e, 0x2, 0xd, 0x8a, 0x55, - 0x85, 0xf4, 0x38, 0x1, 0xa7, 0xd8, 0xf, 0xff, 0x65, 0x54, 0x36, 0x9e}; - uint8_t bytesprops3[] = {0x22, 0xe9, 0x43, 0x94, 0x58, 0x40, 0x46, 0x36, 0x80, 0x8, 0xa4}; - uint8_t bytesprops2[] = {0xd0, 0x36, 0x47, 0x4f, 0xf2, 0xf8, 0xac, 0xbc}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0x3, 0xfd, 0x8d, 0x36, 0x4b, 0x22, 0xf1, 0xb6, 0x6c, 0xf6, 0xfc, - 0xd0, 0x20, 0x51, 0xaa, 0x70, 0xa8, 0xa7, 0x8b, 0x7d, 0x4, 0xdc}; - uint8_t bytesprops7[] = {0x6f, 0xd3, 0xf4, 0xff, 0xad, 0xc3, 0xdb, 0x9c, 0x2c, 0x37, 0xbd, 0x4f, 0x4b, 0x9, 0xda, - 0x71, 0x76, 0x8a, 0x23, 0x1f, 0x24, 0xda, 0x62, 0xe8, 0x84, 0x33, 0x83, 0xb4, 0xa3, 0x1e}; - uint8_t bytesprops6[] = {0x40, 0xaf, 0xa7, 0xf7, 0x89, 0x63, 0xf, 0x69, 0xb7, 0xac, 0xf8, 0x95, 0x6d, 0x15, 0x1, - 0x92, 0x59, 0x80, 0xc9, 0x29, 0xc9, 0x53, 0x9f, 0x68, 0x50, 0x12, 0xfb, 0xbb, 0x6b, 0x7a}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24232, 11, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 1966 [("\202jY\229%\180?VjcM\232\215\146\SYNs\253\SYNW\162\170\244Y",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("6\r\249\236N\201*c",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("K\131A\193\166$\USc,N\221\254\172\242\137\232s\"l\ETB\DC4;S\198(",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("r\129\"\198\151\161\183\159\156\156\202\DC1\GS\153\EOT\ETX\146",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\202aP!\RSH\210E\130Q\ETX\r\161r +// \168u\216\145\SYN\157G\204\148\180\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("]wv2\143\149\148\159\RS\157",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\158\DC4\161$H\248\233\&7q\130-\225\219em\181\DC4nH\v\228=G#0\243O\f\DC4{",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(";\232\243\148t\249g\EM\247\&4 +// \198\130\228\f\ACK\203\199\250\215\&6\RS\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("I\191\225\be\SO\193\210\CAN=z\199$i\\a\157\145\132\&7\137\174\GS\148\ESC\245\194\193\134J",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\189\225\230\152\147\154q\DC2\158\197\187\194\178\146&\GSl\235\157\248\246\"\232\253\204\253I\DC2\143<",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropAuthenticationMethod "D\199\188\STX\SO9\\\155M\171\CAN\241u\223\237\253'",PropTopicAliasMaximum +// 29564,PropServerReference "\153}\CAN\241\237\175w\139,\197\252",PropServerKeepAlive +// 32502,PropSharedSubscriptionAvailable 2,PropMaximumQoS 21,PropMaximumPacketSize 11144,PropTopicAlias +// 22858,PropSharedSubscriptionAvailable 196,PropServerReference "\230\&66\242M]h\193\160",PropMaximumQoS +// 22,PropTopicAliasMaximum 32231,PropUserProperty +// "&\168\228\236\146'\185A\US\234\137\DLEA\215hp]\196\129\t{\167\161\STX\217sK\214C" +// "*+\DELc4\ESCR\155S\196>7\159\159\142\141\137|O;8\163j\148\251\167\250!P",PropTopicAlias +// 4591,PropRequestResponseInformation 66,PropCorrelationData +// "\EOTj\198\r\rd\207\129c4\200\SOH\EM\152]\254Vq",PropTopicAlias 13262,PropRetainAvailable 146,PropTopicAliasMaximum +// 12396,PropRequestResponseInformation 210,PropAuthenticationData +// "\240\166T\CAN;\CAN\SI\DC2\NUL;\209H",PropResponseTopic +// "\195\170\142tsHK*8eDw\165&\EMX]\240\&24\154\138\254",PropContentType +// "\SOH.X\215\150\130\&6+\165\132\197\DELSf\130x\192\CAN&\ENQ\157",PropRequestResponseInformation +// 87,PropRequestProblemInformation 55,PropAuthenticationMethod +// "\217\178-3\238(\224\166\233&\b\159\252\238J\194\207\DEL\161*\168\238{\232g\139\ETB\133",PropPayloadFormatIndicator +// 63,PropContentType "qG\237'\210\159\168^o)\RS",PropUserProperty "\244;\233\139\207\213\237-wS\STX\168y\244" +// "\134\156\223\b\r\RS\240\181I8\183.\235T\188\165-o\190"] +TEST(Subscribe5QCTest, Encode33) { + uint8_t pkt[] = { + 0x82, 0xc4, 0x4, 0x7, 0xae, 0xc4, 0x2, 0x15, 0x0, 0x11, 0x44, 0xc7, 0xbc, 0x2, 0xe, 0x39, 0x5c, 0x9b, 0x4d, + 0xab, 0x18, 0xf1, 0x75, 0xdf, 0xed, 0xfd, 0x27, 0x22, 0x73, 0x7c, 0x1c, 0x0, 0xb, 0x99, 0x7d, 0x18, 0xf1, 0xed, + 0xaf, 0x77, 0x8b, 0x2c, 0xc5, 0xfc, 0x13, 0x7e, 0xf6, 0x2a, 0x2, 0x24, 0x15, 0x27, 0x0, 0x0, 0x2b, 0x88, 0x23, + 0x59, 0x4a, 0x2a, 0xc4, 0x1c, 0x0, 0x9, 0xe6, 0x36, 0x36, 0xf2, 0x4d, 0x5d, 0x68, 0xc1, 0xa0, 0x24, 0x16, 0x22, + 0x7d, 0xe7, 0x26, 0x0, 0x1d, 0x26, 0xa8, 0xe4, 0xec, 0x92, 0x27, 0xb9, 0x41, 0x1f, 0xea, 0x89, 0x10, 0x41, 0xd7, + 0x68, 0x70, 0x5d, 0xc4, 0x81, 0x9, 0x7b, 0xa7, 0xa1, 0x2, 0xd9, 0x73, 0x4b, 0xd6, 0x43, 0x0, 0x1d, 0x2a, 0x2b, + 0x7f, 0x63, 0x34, 0x1b, 0x52, 0x9b, 0x53, 0xc4, 0x3e, 0x37, 0x9f, 0x9f, 0x8e, 0x8d, 0x89, 0x7c, 0x4f, 0x3b, 0x38, + 0xa3, 0x6a, 0x94, 0xfb, 0xa7, 0xfa, 0x21, 0x50, 0x23, 0x11, 0xef, 0x19, 0x42, 0x9, 0x0, 0x12, 0x4, 0x6a, 0xc6, + 0xd, 0xd, 0x64, 0xcf, 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a, 0xc7, 0x24, + 0x69, 0x5c, 0x61, 0x9d, 0x91, 0x84, 0x37, 0x89, 0xae, 0x1d, 0x94, 0x1b, 0xf5, 0xc2, 0xc1, 0x86, 0x4a, 0x0, 0x0, + 0x1e, 0xbd, 0xe1, 0xe6, 0x98, 0x93, 0x9a, 0x71, 0x12, 0x9e, 0xc5, 0xbb, 0xc2, 0xb2, 0x92, 0x26, 0x1d, 0x6c, 0xeb, + 0x9d, 0xf8, 0xf6, 0x22, 0xe8, 0xfd, 0xcc, 0xfd, 0x49, 0x12, 0x8f, 0x3c, 0x2}; + + uint8_t buf[593] = {0}; + + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xca, 0x6a, 0x59, 0xe5, 0x25, 0xb4, 0x3f, 0x56, 0x6a, 0x63, 0x4d, 0xe8, + 0xd7, 0x92, 0x16, 0x73, 0xfd, 0x16, 0x57, 0xa2, 0xaa, 0xf4, 0x59}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x36, 0xd, 0xf9, 0xec, 0x4e, 0xc9, 0x2a, 0x63}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4b, 0x83, 0x41, 0xc1, 0xa6, 0x24, 0x1f, 0x63, 0x2c, 0x4e, 0xdd, 0xfe, 0xac, + 0xf2, 0x89, 0xe8, 0x73, 0x22, 0x6c, 0x17, 0x14, 0x3b, 0x53, 0xc6, 0x28}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x72, 0x81, 0x22, 0xc6, 0x97, 0xa1, 0xb7, 0x9f, 0x9c, + 0x9c, 0xca, 0x11, 0x1d, 0x99, 0x4, 0x3, 0x92}; + lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xca, 0x61, 0x50, 0x21, 0x1e, 0x48, 0xd2, 0x45, 0x82, 0x51, 0x3, 0xd, 0xa1, + 0x72, 0x20, 0xa8, 0x75, 0xd8, 0x91, 0x16, 0x9d, 0x47, 0xcc, 0x94, 0xb4, 0x2}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x5d, 0x77, 0x76, 0x32, 0x8f, 0x95, 0x94, 0x9f, 0x1e, 0x9d}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x9e, 0x14, 0xa1, 0x24, 0x48, 0xf8, 0xe9, 0x37, 0x71, 0x82, + 0x2d, 0xe1, 0xdb, 0x65, 0x6d, 0xb5, 0x14, 0x6e, 0x48, 0xb, + 0xe4, 0x3d, 0x47, 0x23, 0x30, 0xf3, 0x4f, 0xc, 0x14, 0x7b}; + lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x3b, 0xe8, 0xf3, 0x94, 0x74, 0xf9, 0x67, 0x19, 0xf7, 0x34, 0x20, 0xc6, + 0x82, 0xe4, 0xc, 0x6, 0xcb, 0xc7, 0xfa, 0xd7, 0x36, 0x1e, 0x94}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x49, 0xbf, 0xe1, 0x8, 0x65, 0xe, 0xc1, 0xd2, 0x18, 0x3d, + 0x7a, 0xc7, 0x24, 0x69, 0x5c, 0x61, 0x9d, 0x91, 0x84, 0x37, + 0x89, 0xae, 0x1d, 0x94, 0x1b, 0xf5, 0xc2, 0xc1, 0x86, 0x4a}; + lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xbd, 0xe1, 0xe6, 0x98, 0x93, 0x9a, 0x71, 0x12, 0x9e, 0xc5, + 0xbb, 0xc2, 0xb2, 0x92, 0x26, 0x1d, 0x6c, 0xeb, 0x9d, 0xf8, + 0xf6, 0x22, 0xe8, 0xfd, 0xcc, 0xfd, 0x49, 0x12, 0x8f, 0x3c}; + lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x44, 0xc7, 0xbc, 0x2, 0xe, 0x39, 0x5c, 0x9b, 0x4d, + 0xab, 0x18, 0xf1, 0x75, 0xdf, 0xed, 0xfd, 0x27}; + uint8_t bytesprops1[] = {0x99, 0x7d, 0x18, 0xf1, 0xed, 0xaf, 0x77, 0x8b, 0x2c, 0xc5, 0xfc}; + uint8_t bytesprops2[] = {0xe6, 0x36, 0x36, 0xf2, 0x4d, 0x5d, 0x68, 0xc1, 0xa0}; + uint8_t bytesprops4[] = {0x2a, 0x2b, 0x7f, 0x63, 0x34, 0x1b, 0x52, 0x9b, 0x53, 0xc4, 0x3e, 0x37, 0x9f, 0x9f, 0x8e, + 0x8d, 0x89, 0x7c, 0x4f, 0x3b, 0x38, 0xa3, 0x6a, 0x94, 0xfb, 0xa7, 0xfa, 0x21, 0x50}; + uint8_t bytesprops3[] = {0x26, 0xa8, 0xe4, 0xec, 0x92, 0x27, 0xb9, 0x41, 0x1f, 0xea, 0x89, 0x10, 0x41, 0xd7, 0x68, + 0x70, 0x5d, 0xc4, 0x81, 0x9, 0x7b, 0xa7, 0xa1, 0x2, 0xd9, 0x73, 0x4b, 0xd6, 0x43}; + uint8_t bytesprops5[] = {0x4, 0x6a, 0xc6, 0xd, 0xd, 0x64, 0xcf, 0x81, 0x63, + 0x34, 0xc8, 0x1, 0x19, 0x98, 0x5d, 0xfe, 0x56, 0x71}; + uint8_t bytesprops6[] = {0xf0, 0xa6, 0x54, 0x18, 0x3b, 0x18, 0xf, 0x12, 0x0, 0x3b, 0xd1, 0x48}; + uint8_t bytesprops7[] = {0xc3, 0xaa, 0x8e, 0x74, 0x73, 0x48, 0x4b, 0x2a, 0x38, 0x65, 0x44, 0x77, + 0xa5, 0x26, 0x19, 0x58, 0x5d, 0xf0, 0x32, 0x34, 0x9a, 0x8a, 0xfe}; + uint8_t bytesprops8[] = {0x1, 0x2e, 0x58, 0xd7, 0x96, 0x82, 0x36, 0x2b, 0xa5, 0x84, 0xc5, + 0x7f, 0x53, 0x66, 0x82, 0x78, 0xc0, 0x18, 0x26, 0x5, 0x9d}; + uint8_t bytesprops9[] = {0xd9, 0xb2, 0x2d, 0x33, 0xee, 0x28, 0xe0, 0xa6, 0xe9, 0x26, 0x8, 0x9f, 0xfc, 0xee, + 0x4a, 0xc2, 0xcf, 0x7f, 0xa1, 0x2a, 0xa8, 0xee, 0x7b, 0xe8, 0x67, 0x8b, 0x17, 0x85}; + uint8_t bytesprops10[] = {0x71, 0x47, 0xed, 0x27, 0xd2, 0x9f, 0xa8, 0x5e, 0x6f, 0x29, 0x1e}; + uint8_t bytesprops12[] = {0x86, 0x9c, 0xdf, 0x8, 0xd, 0x1e, 0xf0, 0xb5, 0x49, 0x38, + 0xb7, 0x2e, 0xeb, 0x54, 0xbc, 0xa5, 0x2d, 0x6f, 0xbe}; + uint8_t bytesprops11[] = {0xf4, 0x3b, 0xe9, 0x8b, 0xcf, 0xd5, 0xed, 0x2d, 0x77, 0x53, 0x2, 0xa8, 0x79, 0xf4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5174}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15173}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18460}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12822}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops6}, .v = {30, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29564}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32502}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11144}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22858}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32231}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops3}, .v = {29, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4591}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13262}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12396}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {14, (char*)&bytesprops11}, .v = {19, (char*)&bytesprops12}}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1966, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\f\n|\ACK", _pubPktID = 0, _pubBody -// = "%\192\&0", _pubProps = [PropWildcardSubscriptionAvailable 134,PropResponseTopic -// "e\133\154\181\f\191",PropResponseInformation -// ",\192\238\248\212Sf\212j\DLE/\230\&2\216\241>\198",PropAuthenticationMethod -// "\153\GS\198\252\NUL\231J\172(\157\204J\155-\134\GS\177\217\"}\ESC:\DLE\181\156>\230>\254",PropMessageExpiryInterval -// 10851,PropSharedSubscriptionAvailable 75,PropMessageExpiryInterval 21060,PropRequestProblemInformation -// 25,PropContentType "\GS{",PropContentType ":=1'}\197\212\SOHMJ\DC2\ETX\DC4",PropResponseTopic -// "\128\177\246c?\SO\"V'\214\226\rb\EM\130;H\162\163xY;\173\215\165\SOH",PropCorrelationData -// "\r\215K\166\193\&2\v\216\169.\180$e\240H\212Ky\158\207(E\DLE\158\224\196\187\f",PropAuthenticationData -// "XRgE\190r\131\193\&0\174\181\223x\176.\nEi\250\219\157P!\n\238e",PropReceiveMaximum 11426,PropAuthenticationData -// "\244K:\153\208\210\160\&7B\238\162\158",PropRetainAvailable 20,PropMaximumQoS 9,PropSubscriptionIdentifier 25]} -TEST(Publish5QCTest, Encode37) { +// SubscribeRequest 11595 [("\157Y\254\b\253\241E\158M\CAN\255\215Q\ENQ\217\131\177",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\171\DC1\150\DLE\ETBSSi\198{\213\206\249t\216\rt\218\236\161\143\&8\145",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\181\FS]\249\210A:\189\185\DC1\ENQ\175]\150\218\169\SOH\193\SOH`\150\169\182l",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\233/\143\172\SIn:m\212Pf\177&\234\165\181\226\DEL3\153\SI\241l\144\242",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReceiveMaximum +// 4658,PropMaximumQoS 249,PropServerKeepAlive 13,PropResponseTopic +// "\156\163\169,\213\&3\131\186\DC1K\128\162\&2\222{\170\152y\164\DC1\255\180\137\142\237",PropCorrelationData +// "\254",PropTopicAliasMaximum 27561,PropSharedSubscriptionAvailable 233,PropMessageExpiryInterval +// 27068,PropResponseTopic "\186\196h\154\211<\n\180\\9@il`\149a~\246|\220\226\ESC\204",PropMessageExpiryInterval +// 23693,PropSubscriptionIdentifier 16,PropTopicAlias 18385,PropSharedSubscriptionAvailable 18,PropContentType +// "\SOH\138o\228\229B\206\136B\ESCX\147\EOT\FSa",PropAuthenticationData +// "y\129H;\ENQ4\237\v\183\182yn\ACK.\SO\132n\205,\187\DC4`\239>\188",PropResponseInformation +// "\FS\205\250\DC3\134\193\b\SO\239\&2HM",PropSubscriptionIdentifier 27,PropMaximumQoS 122] +TEST(Subscribe5QCTest, Encode34) { uint8_t pkt[] = { - 0x38, 0xde, 0x1, 0x0, 0x4, 0xc, 0xa, 0x7c, 0x6, 0xd3, 0x1, 0x28, 0x86, 0x8, 0x0, 0x6, 0x65, 0x85, 0x9a, - 0xb5, 0xc, 0xbf, 0x1a, 0x0, 0x11, 0x2c, 0xc0, 0xee, 0xf8, 0xd4, 0x53, 0x66, 0xd4, 0x6a, 0x10, 0x2f, 0xe6, 0x32, - 0xd8, 0xf1, 0x3e, 0xc6, 0x15, 0x0, 0x1d, 0x99, 0x1d, 0xc6, 0xfc, 0x0, 0xe7, 0x4a, 0xac, 0x28, 0x9d, 0xcc, 0x4a, - 0x9b, 0x2d, 0x86, 0x1d, 0xb1, 0xd9, 0x22, 0x7d, 0x1b, 0x3a, 0x10, 0xb5, 0x9c, 0x3e, 0xe6, 0x3e, 0xfe, 0x2, 0x0, - 0x0, 0x2a, 0x63, 0x2a, 0x4b, 0x2, 0x0, 0x0, 0x52, 0x44, 0x17, 0x19,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 0x8f, 0xac, 0xf, 0x6e, 0x3a, 0x6d, 0xd4, 0x50, 0x66, 0xb1, + 0x26, 0xea, 0xa5, 0xb5, 0xe2, 0x7f, 0x33, 0x99, 0xf, 0xf1, 0x6c, 0x90, 0xf2, 0x1}; - uint8_t buf[235] = {0}; + uint8_t buf[271] = {0}; - uint8_t topic_bytes[] = {0xc, 0xa, 0x7c, 0x6}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x25, 0xc0, 0x30}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; - - uint8_t bytesprops0[] = {0x65, 0x85, 0x9a, 0xb5, 0xc, 0xbf}; - uint8_t bytesprops1[] = {0x2c, 0xc0, 0xee, 0xf8, 0xd4, 0x53, 0x66, 0xd4, 0x6a, - 0x10, 0x2f, 0xe6, 0x32, 0xd8, 0xf1, 0x3e, 0xc6}; - uint8_t bytesprops2[] = {0x99, 0x1d, 0xc6, 0xfc, 0x0, 0xe7, 0x4a, 0xac, 0x28, 0x9d, 0xcc, 0x4a, 0x9b, 0x2d, 0x86, - 0x1d, 0xb1, 0xd9, 0x22, 0x7d, 0x1b, 0x3a, 0x10, 0xb5, 0x9c, 0x3e, 0xe6, 0x3e, 0xfe}; - uint8_t bytesprops3[] = {0x1d, 0x7b}; - uint8_t bytesprops4[] = {0x3a, 0x3d, 0x31, 0x27, 0x7d, 0xc5, 0xd4, 0x1, 0x4d, 0x4a, 0x12, 0x3, 0x14}; - uint8_t bytesprops5[] = {0x80, 0xb1, 0xf6, 0x63, 0x3f, 0xe, 0x22, 0x56, 0x27, 0xd6, 0xe2, 0xd, 0x62, - 0x19, 0x82, 0x3b, 0x48, 0xa2, 0xa3, 0x78, 0x59, 0x3b, 0xad, 0xd7, 0xa5, 0x1}; - uint8_t bytesprops6[] = {0xd, 0xd7, 0x4b, 0xa6, 0xc1, 0x32, 0xb, 0xd8, 0xa9, 0x2e, 0xb4, 0x24, 0x65, 0xf0, - 0x48, 0xd4, 0x4b, 0x79, 0x9e, 0xcf, 0x28, 0x45, 0x10, 0x9e, 0xe0, 0xc4, 0xbb, 0xc}; - uint8_t bytesprops7[] = {0x58, 0x52, 0x67, 0x45, 0xbe, 0x72, 0x83, 0xc1, 0x30, 0xae, 0xb5, 0xdf, 0x78, - 0xb0, 0x2e, 0xa, 0x45, 0x69, 0xfa, 0xdb, 0x9d, 0x50, 0x21, 0xa, 0xee, 0x65}; - uint8_t bytesprops8[] = {0xf4, 0x4b, 0x3a, 0x99, 0xd0, 0xd2, 0xa0, 0x37, 0x42, 0xee, 0xa2, 0x9e}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x9d, 0x59, 0xfe, 0x8, 0xfd, 0xf1, 0x45, 0x9e, 0x4d, + 0x18, 0xff, 0xd7, 0x51, 0x5, 0xd9, 0x83, 0xb1}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xab, 0x11, 0x96, 0x10, 0x17, 0x53, 0x53, 0x69, 0xc6, 0x7b, 0xd5, 0xce, + 0xf9, 0x74, 0xd8, 0xd, 0x74, 0xda, 0xec, 0xa1, 0x8f, 0x38, 0x91}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb5, 0x1c, 0x5d, 0xf9, 0xd2, 0x41, 0x3a, 0xbd, 0xb9, 0x11, 0x5, 0xaf, + 0x5d, 0x96, 0xda, 0xa9, 0x1, 0xc1, 0x1, 0x60, 0x96, 0xa9, 0xb6, 0x6c}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe9, 0x2f, 0x8f, 0xac, 0xf, 0x6e, 0x3a, 0x6d, 0xd4, 0x50, 0x66, 0xb1, 0x26, + 0xea, 0xa5, 0xb5, 0xe2, 0x7f, 0x33, 0x99, 0xf, 0xf1, 0x6c, 0x90, 0xf2}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x9c, 0xa3, 0xa9, 0x2c, 0xd5, 0x33, 0x83, 0xba, 0x11, 0x4b, 0x80, 0xa2, 0x32, + 0xde, 0x7b, 0xaa, 0x98, 0x79, 0xa4, 0x11, 0xff, 0xb4, 0x89, 0x8e, 0xed}; + uint8_t bytesprops1[] = {0xfe}; + uint8_t bytesprops2[] = {0xba, 0xc4, 0x68, 0x9a, 0xd3, 0x3c, 0xa, 0xb4, 0x5c, 0x39, 0x40, 0x69, + 0x6c, 0x60, 0x95, 0x61, 0x7e, 0xf6, 0x7c, 0xdc, 0xe2, 0x1b, 0xcc}; + uint8_t bytesprops3[] = {0x1, 0x8a, 0x6f, 0xe4, 0xe5, 0x42, 0xce, 0x88, 0x42, 0x1b, 0x58, 0x93, 0x4, 0x1c, 0x61}; + uint8_t bytesprops4[] = {0x79, 0x81, 0x48, 0x3b, 0x5, 0x34, 0xed, 0xb, 0xb7, 0xb6, 0x79, 0x6e, 0x6, + 0x2e, 0xe, 0x84, 0x6e, 0xcd, 0x2c, 0xbb, 0x14, 0x60, 0xef, 0x3e, 0xbc}; + uint8_t bytesprops5[] = {0x1c, 0xcd, 0xfa, 0x13, 0x86, 0xc1, 0x8, 0xe, 0xef, 0x32, 0x48, 0x4d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10851}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21060}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11426}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4658}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27561}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27068}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23693}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18385}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 122}}, }; lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11595, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 3561 [("\SI\230\235\135\157\175%\128",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\174\n|v\146#k\154\224-R\219\SUB\245k\186\207: +// \r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\DC2\181\156\155\180{\234\ETX\GS\223\168\199u\168N\218w\246\&3\DC3z\168y\249",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\170\211",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("R\230\221\&6\239O\211\146vM3YD\140\129+\194B\160\200\163\189",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropServerReference "i",PropCorrelationData +// "&\244t\193\&3o\f\193\186g\SUB\143\225\215",PropResponseTopic "q=\170\168R\167",PropMaximumQoS +// 195,PropSharedSubscriptionAvailable 84,PropResponseInformation +// "\186\207\146\n\"\201\&9\160m;B\GS\208\201\179\132\205.\131n\221C",PropSessionExpiryInterval +// 31601,PropServerKeepAlive 20698,PropServerReference +// "\132\216\221)\172\160\SI\SUB\a\US*=\SYN\GS\185F\141Y>P\194",PropAuthenticationData +// "\201\209\189\193\GS\193\235\143\USD\FS\193\r\231\t\142\221\132\166\184s\192\157\GSS",PropUserProperty "" +// "I^z\212\224#\235UQ\188\224\244\SYN\USq$\166",PropRequestProblemInformation 35,PropPayloadFormatIndicator +// 73,PropServerKeepAlive 15730,PropTopicAliasMaximum 6340,PropMessageExpiryInterval 27016,PropUserProperty "\149\245" +// "M\169\168\ETXu\FS\185_\156",PropReceiveMaximum 29452,PropMessageExpiryInterval 31914,PropMaximumPacketSize +// 30557,PropCorrelationData "",PropServerReference "}",PropResponseTopic +// "\214\197\244\128\222fq",PropAuthenticationMethod +// "O\170i\240\179\136\207b\206g\222\r\242\221\234^_\140u9i\201\222\173e",PropMaximumQoS 166,PropMessageExpiryInterval +// 9383,PropRequestProblemInformation 42,PropMaximumQoS 173,PropSessionExpiryInterval 20164,PropResponseTopic +// "\186I\232\SUB"] +TEST(Subscribe5QCTest, Encode35) { + uint8_t pkt[] = { + 0x82, 0xdc, 0x2, 0xd, 0xe9, 0xfd, 0x1, 0x1c, 0x0, 0x1, 0x69, 0x9, 0x0, 0xe, 0x26, 0xf4, 0x74, 0xc1, 0x33, + 0x6f, 0xc, 0xc1, 0xba, 0x67, 0x1a, 0x8f, 0xe1, 0xd7, 0x8, 0x0, 0x6, 0x71, 0x3d, 0xaa, 0xa8, 0x52, 0xa7, 0x24, + 0xc3, 0x2a, 0x54, 0x1a, 0x0, 0x16, 0xba, 0xcf, 0x92, 0xa, 0x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de, 0xad, 0x65, 0x24, 0xa6, 0x2, 0x0, 0x0, 0x24, 0xa7, 0x17, 0x2a, 0x24, + 0xad, 0x11, 0x0, 0x0, 0x4e, 0xc4, 0x8, 0x0, 0x4, 0xba, 0x49, 0xe8, 0x1a, 0x0, 0x8, 0xf, 0xe6, 0xeb, 0x87, + 0x9d, 0xaf, 0x25, 0x80, 0x0, 0x0, 0x14, 0xae, 0xa, 0x7c, 0x76, 0x92, 0x23, 0x6b, 0x9a, 0xe0, 0x2d, 0x52, 0xdb, + 0x1a, 0xf5, 0x6b, 0xba, 0xcf, 0x3a, 0x20, 0xd, 0x0, 0x0, 0x18, 0x12, 0xb5, 0x9c, 0x9b, 0xb4, 0x7b, 0xea, 0x3, + 0x1d, 0xdf, 0xa8, 0xc7, 0x75, 0xa8, 0x4e, 0xda, 0x77, 0xf6, 0x33, 0x13, 0x7a, 0xa8, 0x79, 0xf9, 0x1, 0x0, 0x2, + 0xaa, 0xd3, 0x2, 0x0, 0x16, 0x52, 0xe6, 0xdd, 0x36, 0xef, 0x4f, 0xd3, 0x92, 0x76, 0x4d, 0x33, 0x59, 0x44, 0x8c, + 0x81, 0x2b, 0xc2, 0x42, 0xa0, 0xc8, 0xa3, 0xbd, 0x0}; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\SUB\161\156|\172\155*2\212e\184\252<\195\a\180C\177\162\130\159\166L\200\SYN_", _pubPktID = 14022, _pubBody = -// "01c\156c\152\DC3@\149/\USy\FS\147\184,n\243\245\134Kc?E\206\131\ESC ;", _pubProps = [PropRequestResponseInformation -// 116,PropAuthenticationData "\RS\160\130\&3\210\DEL\194\EOT\216\176:Rx\175\213\186V\232",PropSessionExpiryInterval -// 23836,PropRetainAvailable 106,PropReceiveMaximum 21264,PropCorrelationData "\235\254M\143\199n -// &NMG(\ACK\221",PropMaximumPacketSize 3816,PropReceiveMaximum 24077,PropTopicAlias -// 11181,PropSubscriptionIdentifierAvailable 210,PropAssignedClientIdentifier "\187Z{\181\148\236\189 "]} -TEST(Publish5QCTest, Encode38) { - uint8_t pkt[] = {0x32, 0x86, 0x1, 0x0, 0x1a, 0x1a, 0xa1, 0x9c, 0x7c, 0xac, 0x9b, 0x2a, 0x32, 0xd4, 0x65, 0xb8, - 0xfc, 0x3c, 0xc3, 0x7, 0xb4, 0x43, 0xb1, 0xa2, 0x82, 0x9f, 0xa6, 0x4c, 0xc8, 0x16, 0x5f, 0x36, - 0xc6, 0x4a, 0x19, 0x74, 0x16, 0x0, 0x12, 0x1e, 0xa0, 0x82, 0x33, 0xd2, 0x7f, 0xc2, 0x4, 0xd8, - 0xb0, 0x3a, 0x52, 0x78, 0xaf, 0xd5, 0xba, 0x56, 0xe8, 0x11, 0x0, 0x0, 0x5d, 0x1c, 0x25, 0x6a, - 0x21, 0x53, 0x10, 0x9, 0x0, 0xe, 0xeb, 0xfe, 0x4d, 0x8f, 0xc7, 0x6e, 0x20, 0x26, 0x4e, 0x4d, - 0x47, 0x28, 0x6, 0xdd, 0x27, 0x0, 0x0, 0xe, 0xe8, 0x21, 0x5e, 0xd, 0x23, 0x2b, 0xad, 0x29, - 0xd2, 0x12, 0x0, 0x8, 0xbb, 0x5a, 0x7b, 0xb5, 0x94, 0xec, 0xbd, 0x20, 0x30, 0x31, 0x63, 0x9c, - 0x63, 0x98, 0x13, 0x40, 0x95, 0x2f, 0x1f, 0x79, 0x1c, 0x93, 0xb8, 0x2c, 0x6e, 0xf3, 0xf5, 0x86, - 0x4b, 0x63, 0x3f, 0x45, 0xce, 0x83, 0x1b, 0x20, 0x3b}; - - uint8_t buf[147] = {0}; - - uint8_t topic_bytes[] = {0x1a, 0xa1, 0x9c, 0x7c, 0xac, 0x9b, 0x2a, 0x32, 0xd4, 0x65, 0xb8, 0xfc, 0x3c, - 0xc3, 0x7, 0xb4, 0x43, 0xb1, 0xa2, 0x82, 0x9f, 0xa6, 0x4c, 0xc8, 0x16, 0x5f}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x30, 0x31, 0x63, 0x9c, 0x63, 0x98, 0x13, 0x40, 0x95, 0x2f, 0x1f, 0x79, 0x1c, 0x93, 0xb8, - 0x2c, 0x6e, 0xf3, 0xf5, 0x86, 0x4b, 0x63, 0x3f, 0x45, 0xce, 0x83, 0x1b, 0x20, 0x3b}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + uint8_t buf[361] = {0}; - uint8_t bytesprops0[] = {0x1e, 0xa0, 0x82, 0x33, 0xd2, 0x7f, 0xc2, 0x4, 0xd8, - 0xb0, 0x3a, 0x52, 0x78, 0xaf, 0xd5, 0xba, 0x56, 0xe8}; - uint8_t bytesprops1[] = {0xeb, 0xfe, 0x4d, 0x8f, 0xc7, 0x6e, 0x20, 0x26, 0x4e, 0x4d, 0x47, 0x28, 0x6, 0xdd}; - uint8_t bytesprops2[] = {0xbb, 0x5a, 0x7b, 0xb5, 0x94, 0xec, 0xbd, 0x20}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xf, 0xe6, 0xeb, 0x87, 0x9d, 0xaf, 0x25, 0x80}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xae, 0xa, 0x7c, 0x76, 0x92, 0x23, 0x6b, 0x9a, 0xe0, 0x2d, + 0x52, 0xdb, 0x1a, 0xf5, 0x6b, 0xba, 0xcf, 0x3a, 0x20, 0xd}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x12, 0xb5, 0x9c, 0x9b, 0xb4, 0x7b, 0xea, 0x3, 0x1d, 0xdf, 0xa8, 0xc7, + 0x75, 0xa8, 0x4e, 0xda, 0x77, 0xf6, 0x33, 0x13, 0x7a, 0xa8, 0x79, 0xf9}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xaa, 0xd3}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x52, 0xe6, 0xdd, 0x36, 0xef, 0x4f, 0xd3, 0x92, 0x76, 0x4d, 0x33, + 0x59, 0x44, 0x8c, 0x81, 0x2b, 0xc2, 0x42, 0xa0, 0xc8, 0xa3, 0xbd}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x69}; + uint8_t bytesprops1[] = {0x26, 0xf4, 0x74, 0xc1, 0x33, 0x6f, 0xc, 0xc1, 0xba, 0x67, 0x1a, 0x8f, 0xe1, 0xd7}; + uint8_t bytesprops2[] = {0x71, 0x3d, 0xaa, 0xa8, 0x52, 0xa7}; + uint8_t bytesprops3[] = {0xba, 0xcf, 0x92, 0xa, 0x22, 0xc9, 0x39, 0xa0, 0x6d, 0x3b, 0x42, + 0x1d, 0xd0, 0xc9, 0xb3, 0x84, 0xcd, 0x2e, 0x83, 0x6e, 0xdd, 0x43}; + uint8_t bytesprops4[] = {0x84, 0xd8, 0xdd, 0x29, 0xac, 0xa0, 0xf, 0x1a, 0x7, 0x1f, 0x2a, + 0x3d, 0x16, 0x1d, 0xb9, 0x46, 0x8d, 0x59, 0x3e, 0x50, 0xc2}; + uint8_t bytesprops5[] = {0xc9, 0xd1, 0xbd, 0xc1, 0x1d, 0xc1, 0xeb, 0x8f, 0x1f, 0x44, 0x1c, 0xc1, 0xd, + 0xe7, 0x9, 0x8e, 0xdd, 0x84, 0xa6, 0xb8, 0x73, 0xc0, 0x9d, 0x1d, 0x53}; + uint8_t bytesprops7[] = {0x49, 0x5e, 0x7a, 0xd4, 0xe0, 0x23, 0xeb, 0x55, 0x51, + 0xbc, 0xe0, 0xf4, 0x16, 0x1f, 0x71, 0x24, 0xa6}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops9[] = {0x4d, 0xa9, 0xa8, 0x3, 0x75, 0x1c, 0xb9, 0x5f, 0x9c}; + uint8_t bytesprops8[] = {0x95, 0xf5}; + uint8_t bytesprops10[] = {0}; + uint8_t bytesprops11[] = {0x7d}; + uint8_t bytesprops12[] = {0xd6, 0xc5, 0xf4, 0x80, 0xde, 0x66, 0x71}; + uint8_t bytesprops13[] = {0x4f, 0xaa, 0x69, 0xf0, 0xb3, 0x88, 0xcf, 0x62, 0xce, 0x67, 0xde, 0xd, 0xf2, + 0xdd, 0xea, 0x5e, 0x5f, 0x8c, 0x75, 0x39, 0x69, 0xc9, 0xde, 0xad, 0x65}; + uint8_t bytesprops14[] = {0xba, 0x49, 0xe8, 0x1a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23836}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21264}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops0}}}, {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3816}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24077}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11181}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31601}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20698}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops6}, .v = {17, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15730}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6340}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27016}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops8}, .v = {9, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29452}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31914}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30557}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9383}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20164}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops14}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14022, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\186Kx\255\202i[\182\SUBu\242L\148\153\157\182\GSY)", _pubPktID = 16446, _pubBody = -// "\STX\188u\179*\236\174\253@\ACK\219x\192d\168\200\210\177-\181\250\207\176\230", _pubProps = [PropResponseTopic -// "",PropAssignedClientIdentifier "\193\144\&4\243\214\158\&0\222pH\139\128\&7}\ENQ\230",PropUserProperty "\185" -// "Uh\191\185\223\151\247M\r\ACK",PropMessageExpiryInterval 18691]} -TEST(Publish5QCTest, Encode39) { - uint8_t pkt[] = {0x35, 0x5b, 0x0, 0x13, 0xba, 0x4b, 0x78, 0xff, 0xca, 0x69, 0x5b, 0xb6, 0x1a, 0x75, 0xf2, 0x4c, - 0x94, 0x99, 0x9d, 0xb6, 0x1d, 0x59, 0x29, 0x40, 0x3e, 0x2b, 0x8, 0x0, 0x0, 0x12, 0x0, 0x10, - 0xc1, 0x90, 0x34, 0xf3, 0xd6, 0x9e, 0x30, 0xde, 0x70, 0x48, 0x8b, 0x80, 0x37, 0x7d, 0x5, 0xe6, - 0x26, 0x0, 0x1, 0xb9, 0x0, 0xa, 0x55, 0x68, 0xbf, 0xb9, 0xdf, 0x97, 0xf7, 0x4d, 0xd, 0x6, - 0x2, 0x0, 0x0, 0x49, 0x3, 0x2, 0xbc, 0x75, 0xb3, 0x2a, 0xec, 0xae, 0xfd, 0x40, 0x6, 0xdb, - 0x78, 0xc0, 0x64, 0xa8, 0xc8, 0xd2, 0xb1, 0x2d, 0xb5, 0xfa, 0xcf, 0xb0, 0xe6}; - - uint8_t buf[103] = {0}; - - uint8_t topic_bytes[] = {0xba, 0x4b, 0x78, 0xff, 0xca, 0x69, 0x5b, 0xb6, 0x1a, 0x75, - 0xf2, 0x4c, 0x94, 0x99, 0x9d, 0xb6, 0x1d, 0x59, 0x29}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x2, 0xbc, 0x75, 0xb3, 0x2a, 0xec, 0xae, 0xfd, 0x40, 0x6, 0xdb, 0x78, - 0xc0, 0x64, 0xa8, 0xc8, 0xd2, 0xb1, 0x2d, 0xb5, 0xfa, 0xcf, 0xb0, 0xe6}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; - - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xc1, 0x90, 0x34, 0xf3, 0xd6, 0x9e, 0x30, 0xde, - 0x70, 0x48, 0x8b, 0x80, 0x37, 0x7d, 0x5, 0xe6}; - uint8_t bytesprops3[] = {0x55, 0x68, 0xbf, 0xb9, 0xdf, 0x97, 0xf7, 0x4d, 0xd, 0x6}; - uint8_t bytesprops2[] = {0xb9}; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3561, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 27717 [("\241m\204\194)1\\\134\EOTj\252\251\183\169o~+",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\165\223\t",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\ETX)\192\ETXE\164\158\181\239\216\SOH\131\171\196\207",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\182bC|\240!\219\DC4Q\200\161",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\160\162\&7\226\196(\141G\165\139\207\SI\255\171\251J\DC2\ETX\168q'1\240-^\185\192\191]",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("}$%\168\155\130\v\149v!\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\167o\ETX\243\&6\210\&8\STX\199\236h\129H1M\147\GS\241\143S\246B\130\234\160\215\223\184",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\SUBq\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("]g\181\SUBP\232h\172\GS\180\247\RS\203\236",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\201\158",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("C\229\189\187\171\185\NAKjA!\129\253",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [PropUserProperty "\172\&7\175\206\210_" +// "\164\129\&4\176\STX\153\214\v2\200\"\144i\216\&1\236\251\147\164m\230\151Z\245",PropWildcardSubscriptionAvailable +// 179] +TEST(Subscribe5QCTest, Encode36) { + uint8_t pkt[] = {0x82, 0xda, 0x1, 0x6c, 0x45, 0x25, 0x26, 0x0, 0x6, 0xac, 0x37, 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 0xf7, 0x1e, 0xcb, 0xec, 0x1, 0x0, 0x2, 0xc9, + 0x9e, 0x1, 0x0, 0xc, 0x43, 0xe5, 0xbd, 0xbb, 0xab, 0xb9, 0x15, 0x6a, 0x41, 0x21, 0x81, 0xfd, 0x2}; + + uint8_t buf[231] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xf1, 0x6d, 0xcc, 0xc2, 0x29, 0x31, 0x5c, 0x86, 0x4, + 0x6a, 0xfc, 0xfb, 0xb7, 0xa9, 0x6f, 0x7e, 0x2b}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa5, 0xdf, 0x9}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x3, 0x29, 0xc0, 0x3, 0x45, 0xa4, 0x9e, 0xb5, + 0xef, 0xd8, 0x1, 0x83, 0xab, 0xc4, 0xcf}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb6, 0x62, 0x43, 0x7c, 0xf0, 0x21, 0xdb, 0x14, 0x51, 0xc8, 0xa1}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa0, 0xa2, 0x37, 0xe2, 0xc4, 0x28, 0x8d, 0x47, 0xa5, 0x8b, + 0xcf, 0xf, 0xff, 0xab, 0xfb, 0x4a, 0x12, 0x3, 0xa8, 0x71, + 0x27, 0x31, 0xf0, 0x2d, 0x5e, 0xb9, 0xc0, 0xbf, 0x5d}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x7d, 0x24, 0x25, 0xa8, 0x9b, 0x82, 0xb, 0x95, 0x76, 0x21, 0xa6}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa7, 0x6f, 0x3, 0xf3, 0x36, 0xd2, 0x38, 0x2, 0xc7, 0xec, + 0x68, 0x81, 0x48, 0x31, 0x4d, 0x93, 0x1d, 0xf1, 0x8f, 0x53, + 0xf6, 0x42, 0x82, 0xea, 0xa0, 0xd7, 0xdf, 0xb8}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x1a, 0x71, 0xeb}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x5d, 0x67, 0xb5, 0x1a, 0x50, 0xe8, 0x68, + 0xac, 0x1d, 0xb4, 0xf7, 0x1e, 0xcb, 0xec}; + lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xc9, 0x9e}; + lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x43, 0xe5, 0xbd, 0xbb, 0xab, 0xb9, 0x15, 0x6a, 0x41, 0x21, 0x81, 0xfd}; + lwmqtt_string_t topic_filter_s10 = {12, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops1[] = {0xa4, 0x81, 0x34, 0xb0, 0x2, 0x99, 0xd6, 0xb, 0x32, 0xc8, 0x22, 0x90, + 0x69, 0xd8, 0x31, 0xec, 0xfb, 0x93, 0xa4, 0x6d, 0xe6, 0x97, 0x5a, 0xf5}; + uint8_t bytesprops0[] = {0xac, 0x37, 0xaf, 0xce, 0xd2, 0x5f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops2}, .v = {10, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18691}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16446, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27717, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\252\171\ETB\146\NUL\152K`)b\NAK\180\148v\174B%\160\203\135\202\RS,\162aK\ESCF\183\140", _pubPktID = 0, _pubBody = " -// \173\153\209\219\234pW\207F\221\202q\136\227\190\"\199\130", _pubProps = [PropCorrelationData -// "\250h\141\206S\214R:",PropSubscriptionIdentifier 14,PropMaximumQoS 192,PropPayloadFormatIndicator -// 128,PropWillDelayInterval 12161,PropResponseInformation "\162\STX\182$P\222^\197^\168",PropMessageExpiryInterval -// 23150,PropRequestResponseInformation 246,PropRequestProblemInformation 60,PropUserProperty -// "=\t8\189\247\151?b\160\143\212\193\195m\210p\190\137u\RS\250" -// "\226\NAK\233J\197\224x\149~\222\206L",PropWillDelayInterval 20295,PropRequestProblemInformation 222,PropMaximumQoS -// 208,PropRequestProblemInformation 70,PropAuthenticationMethod -// "P\SUB\165\182\254\SO\224\128>b\t6\199\r\253\170\174\202\189tz2\243\&5\138\236P\192\200"]} -TEST(Publish5QCTest, Encode40) { - uint8_t pkt[] = {0x30, 0xb1, 0x1, 0x0, 0x1e, 0xfc, 0xab, 0x17, 0x92, 0x0, 0x98, 0x4b, 0x60, 0x29, 0x62, 0x15, 0xb4, - 0x94, 0x76, 0xae, 0x42, 0x25, 0xa0, 0xcb, 0x87, 0xca, 0x1e, 0x2c, 0xa2, 0x61, 0x4b, 0x1b, 0x46, 0xb7, - 0x8c, 0x7d, 0x9, 0x0, 0x8, 0xfa, 0x68, 0x8d, 0xce, 0x53, 0xd6, 0x52, 0x3a, 0xb, 0xe, 0x24, 0xc0, - 0x1, 0x80, 0x18, 0x0, 0x0, 0x2f, 0x81, 0x1a, 0x0, 0xa, 0xa2, 0x2, 0xb6, 0x24, 0x50, 0xde, 0x5e, - 0xc5, 0x5e, 0xa8, 0x2, 0x0, 0x0, 0x5a, 0x6e, 0x19, 0xf6, 0x17, 0x3c, 0x26, 0x0, 0x15, 0x3d, 0x9, - 0x38, 0xbd, 0xf7, 0x97, 0x3f, 0x62, 0xa0, 0x8f, 0xd4, 0xc1, 0xc3, 0x6d, 0xd2, 0x70, 0xbe, 0x89, 0x75, - 0x1e, 0xfa, 0x0, 0xc, 0xe2, 0x15, 0xe9, 0x4a, 0xc5, 0xe0, 0x78, 0x95, 0x7e, 0xde, 0xce, 0x4c, 0x18, - 0x0, 0x0, 0x4f, 0x47, 0x17, 0xde, 0x24, 0xd0, 0x17, 0x46, 0x15, 0x0, 0x1d, 0x50, 0x1a, 0xa5, 0xb6, - 0xfe, 0xe, 0xe0, 0x80, 0x3e, 0x62, 0x9, 0x36, 0xc7, 0xd, 0xfd, 0xaa, 0xae, 0xca, 0xbd, 0x74, 0x7a, - 0x32, 0xf3, 0x35, 0x8a, 0xec, 0x50, 0xc0, 0xc8, 0x20, 0xad, 0x99, 0xd1, 0xdb, 0xea, 0x70, 0x57, 0xcf, - 0x46, 0xdd, 0xca, 0x71, 0x88, 0xe3, 0xbe, 0x22, 0xc7, 0x82}; +// SubscribeRequest 10081 [("\254\182\236\b\134\175Afy\149p\146)\CAN\196]\172",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\140\141\202Y\140aB-\ENQx\198i\168\DEL\ESC\244\250-",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReasonString +// "\214\243\154\153\177c\229p\198\168\n+{\251\199",PropMessageExpiryInterval 30022,PropPayloadFormatIndicator +// 179,PropWildcardSubscriptionAvailable 40,PropUserProperty ",@a\201\ACK'\244\221" +// "@\b\255\217Z\154T}\216",PropSubscriptionIdentifierAvailable 130,PropPayloadFormatIndicator +// 96,PropAssignedClientIdentifier "MR\166\195\176/xo )x\n0\251\SYN+\140\234\160}"] +TEST(Subscribe5QCTest, Encode37) { + uint8_t pkt[] = {0x82, 0x78, 0x27, 0x61, 0x4c, 0x1f, 0x0, 0xf, 0xd6, 0xf3, 0x9a, 0x99, 0xb1, 0x63, 0xe5, 0x70, + 0xc6, 0xa8, 0xa, 0x2b, 0x7b, 0xfb, 0xc7, 0x2, 0x0, 0x0, 0x75, 0x46, 0x1, 0xb3, 0x28, 0x28, + 0x26, 0x0, 0x8, 0x2c, 0x40, 0x61, 0xc9, 0x6, 0x27, 0xf4, 0xdd, 0x0, 0x9, 0x40, 0x8, 0xff, + 0xd9, 0x5a, 0x9a, 0x54, 0x7d, 0xd8, 0x29, 0x82, 0x1, 0x60, 0x12, 0x0, 0x14, 0x4d, 0x52, 0xa6, + 0xc3, 0xb0, 0x2f, 0x78, 0x6f, 0x20, 0x29, 0x78, 0xa, 0x30, 0xfb, 0x16, 0x2b, 0x8c, 0xea, 0xa0, + 0x7d, 0x0, 0x11, 0xfe, 0xb6, 0xec, 0x8, 0x86, 0xaf, 0x41, 0x66, 0x79, 0x95, 0x70, 0x92, 0x29, + 0x18, 0xc4, 0x5d, 0xac, 0x0, 0x0, 0x12, 0x8c, 0x8d, 0xca, 0x59, 0x8c, 0x61, 0x42, 0x2d, 0x5, + 0x78, 0xc6, 0x69, 0xa8, 0x7f, 0x1b, 0xf4, 0xfa, 0x2d, 0x1}; - uint8_t buf[190] = {0}; + uint8_t buf[132] = {0}; - uint8_t topic_bytes[] = {0xfc, 0xab, 0x17, 0x92, 0x0, 0x98, 0x4b, 0x60, 0x29, 0x62, 0x15, 0xb4, 0x94, 0x76, 0xae, - 0x42, 0x25, 0xa0, 0xcb, 0x87, 0xca, 0x1e, 0x2c, 0xa2, 0x61, 0x4b, 0x1b, 0x46, 0xb7, 0x8c}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x20, 0xad, 0x99, 0xd1, 0xdb, 0xea, 0x70, 0x57, 0xcf, 0x46, - 0xdd, 0xca, 0x71, 0x88, 0xe3, 0xbe, 0x22, 0xc7, 0x82}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xfe, 0xb6, 0xec, 0x8, 0x86, 0xaf, 0x41, 0x66, 0x79, + 0x95, 0x70, 0x92, 0x29, 0x18, 0xc4, 0x5d, 0xac}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x8c, 0x8d, 0xca, 0x59, 0x8c, 0x61, 0x42, 0x2d, 0x5, + 0x78, 0xc6, 0x69, 0xa8, 0x7f, 0x1b, 0xf4, 0xfa, 0x2d}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xd6, 0xf3, 0x9a, 0x99, 0xb1, 0x63, 0xe5, 0x70, 0xc6, 0xa8, 0xa, 0x2b, 0x7b, 0xfb, 0xc7}; + uint8_t bytesprops2[] = {0x40, 0x8, 0xff, 0xd9, 0x5a, 0x9a, 0x54, 0x7d, 0xd8}; + uint8_t bytesprops1[] = {0x2c, 0x40, 0x61, 0xc9, 0x6, 0x27, 0xf4, 0xdd}; + uint8_t bytesprops3[] = {0x4d, 0x52, 0xa6, 0xc3, 0xb0, 0x2f, 0x78, 0x6f, 0x20, 0x29, + 0x78, 0xa, 0x30, 0xfb, 0x16, 0x2b, 0x8c, 0xea, 0xa0, 0x7d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30022}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops1}, .v = {9, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10081, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12277 [("Qa\142\154\DC1\250'%d\167",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\251-\198\134\225\144X\220\STXN\142\199g*\SYN\128\238\209\135\238\166\183Q\232K)",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\173\&7va\196^-\248\&9\223;d\152(1\217u\154X\206\246\247\129o\211Z",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("8\207\165@\ESC\201\ri\241",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\141{KJ$\219&c3\196\b3,W\232`\131~\\\165\243\175\201\199E\240\SO6",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe5QCTest, Encode38) { + uint8_t pkt[] = {0x82, 0x75, 0x2f, 0xf5, 0x0, 0x0, 0xa, 0x51, 0x61, 0x8e, 0x9a, 0x11, 0xfa, 0x27, 0x25, 0x64, 0xa7, + 0x1, 0x0, 0x1a, 0xfb, 0x2d, 0xc6, 0x86, 0xe1, 0x90, 0x58, 0xdc, 0x2, 0x4e, 0x8e, 0xc7, 0x67, 0x2a, + 0x16, 0x80, 0xee, 0xd1, 0x87, 0xee, 0xa6, 0xb7, 0x51, 0xe8, 0x4b, 0x29, 0x1, 0x0, 0x1a, 0xad, 0x37, + 0x76, 0x61, 0xc4, 0x5e, 0x2d, 0xf8, 0x39, 0xdf, 0x3b, 0x64, 0x98, 0x28, 0x31, 0xd9, 0x75, 0x9a, 0x58, + 0xce, 0xf6, 0xf7, 0x81, 0x6f, 0xd3, 0x5a, 0x1, 0x0, 0x9, 0x38, 0xcf, 0xa5, 0x40, 0x1b, 0xc9, 0xd, + 0x69, 0xf1, 0x2, 0x0, 0x1c, 0x8d, 0x7b, 0x4b, 0x4a, 0x24, 0xdb, 0x26, 0x63, 0x33, 0xc4, 0x8, 0x33, + 0x2c, 0x57, 0xe8, 0x60, 0x83, 0x7e, 0x5c, 0xa5, 0xf3, 0xaf, 0xc9, 0xc7, 0x45, 0xf0, 0xe, 0x36, 0x0}; + + uint8_t buf[129] = {0}; + + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x51, 0x61, 0x8e, 0x9a, 0x11, 0xfa, 0x27, 0x25, 0x64, 0xa7}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xfb, 0x2d, 0xc6, 0x86, 0xe1, 0x90, 0x58, 0xdc, 0x2, 0x4e, 0x8e, 0xc7, 0x67, + 0x2a, 0x16, 0x80, 0xee, 0xd1, 0x87, 0xee, 0xa6, 0xb7, 0x51, 0xe8, 0x4b, 0x29}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xad, 0x37, 0x76, 0x61, 0xc4, 0x5e, 0x2d, 0xf8, 0x39, 0xdf, 0x3b, 0x64, 0x98, + 0x28, 0x31, 0xd9, 0x75, 0x9a, 0x58, 0xce, 0xf6, 0xf7, 0x81, 0x6f, 0xd3, 0x5a}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x38, 0xcf, 0xa5, 0x40, 0x1b, 0xc9, 0xd, 0x69, 0xf1}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x8d, 0x7b, 0x4b, 0x4a, 0x24, 0xdb, 0x26, 0x63, 0x33, 0xc4, + 0x8, 0x33, 0x2c, 0x57, 0xe8, 0x60, 0x83, 0x7e, 0x5c, 0xa5, + 0xf3, 0xaf, 0xc9, 0xc7, 0x45, 0xf0, 0xe, 0x36}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; + + lwmqtt_property_t propslist[] = {}; - uint8_t bytesprops0[] = {0xfa, 0x68, 0x8d, 0xce, 0x53, 0xd6, 0x52, 0x3a}; - uint8_t bytesprops1[] = {0xa2, 0x2, 0xb6, 0x24, 0x50, 0xde, 0x5e, 0xc5, 0x5e, 0xa8}; - uint8_t bytesprops3[] = {0xe2, 0x15, 0xe9, 0x4a, 0xc5, 0xe0, 0x78, 0x95, 0x7e, 0xde, 0xce, 0x4c}; - uint8_t bytesprops2[] = {0x3d, 0x9, 0x38, 0xbd, 0xf7, 0x97, 0x3f, 0x62, 0xa0, 0x8f, 0xd4, - 0xc1, 0xc3, 0x6d, 0xd2, 0x70, 0xbe, 0x89, 0x75, 0x1e, 0xfa}; - uint8_t bytesprops4[] = {0x50, 0x1a, 0xa5, 0xb6, 0xfe, 0xe, 0xe0, 0x80, 0x3e, 0x62, 0x9, 0x36, 0xc7, 0xd, 0xfd, - 0xaa, 0xae, 0xca, 0xbd, 0x74, 0x7a, 0x32, 0xf3, 0x35, 0x8a, 0xec, 0x50, 0xc0, 0xc8}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12277, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 518 [("\139\STXE:n\137b\f\184\166\168\143a\150+/\136,\154\148\190k\196u\189n\n",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropSubscriptionIdentifierAvailable 150,PropReasonString +// "b\253\SO\253\138\136t\232\141\182\SI\198O",PropMessageExpiryInterval 4658,PropWildcardSubscriptionAvailable +// 197,PropResponseTopic "\247!\184Y\240\b.\142\226l\195",PropAuthenticationMethod +// "\173\154u\SOHo#&H\213\207\162\253\203\237",PropMessageExpiryInterval 31275,PropSubscriptionIdentifierAvailable +// 128,PropAssignedClientIdentifier "",PropMessageExpiryInterval 10976,PropSubscriptionIdentifierAvailable +// 167,PropResponseTopic "\ESC\242EU\158I\242\FSB\205(#u\138\216\DLE\SIQ\\\171\227ae\206\&3",PropRetainAvailable +// 215,PropPayloadFormatIndicator 160,PropTopicAliasMaximum 10006,PropMaximumQoS 198] +TEST(Subscribe5QCTest, Encode39) { + uint8_t pkt[] = {0x82, 0x8f, 0x1, 0x2, 0x6, 0x6e, 0x29, 0x96, 0x1f, 0x0, 0xd, 0x62, 0xfd, 0xe, 0xfd, 0x8a, 0x88, + 0x74, 0xe8, 0x8d, 0xb6, 0xf, 0xc6, 0x4f, 0x2, 0x0, 0x0, 0x12, 0x32, 0x28, 0xc5, 0x8, 0x0, 0xb, + 0xf7, 0x21, 0xb8, 0x59, 0xf0, 0x8, 0x2e, 0x8e, 0xe2, 0x6c, 0xc3, 0x15, 0x0, 0xe, 0xad, 0x9a, 0x75, + 0x1, 0x6f, 0x23, 0x26, 0x48, 0xd5, 0xcf, 0xa2, 0xfd, 0xcb, 0xed, 0x2, 0x0, 0x0, 0x7a, 0x2b, 0x29, + 0x80, 0x12, 0x0, 0x0, 0x2, 0x0, 0x0, 0x2a, 0xe0, 0x29, 0xa7, 0x8, 0x0, 0x19, 0x1b, 0xf2, 0x45, + 0x55, 0x9e, 0x49, 0xf2, 0x1c, 0x42, 0xcd, 0x28, 0x23, 0x75, 0x8a, 0xd8, 0x10, 0xf, 0x51, 0x5c, 0xab, + 0xe3, 0x61, 0x65, 0xce, 0x33, 0x25, 0xd7, 0x1, 0xa0, 0x22, 0x27, 0x16, 0x24, 0xc6, 0x0, 0x1b, 0x8b, + 0x2, 0x45, 0x3a, 0x6e, 0x89, 0x62, 0xc, 0xb8, 0xa6, 0xa8, 0x8f, 0x61, 0x96, 0x2b, 0x2f, 0x88, 0x2c, + 0x9a, 0x94, 0xbe, 0x6b, 0xc4, 0x75, 0xbd, 0x6e, 0xa, 0x2}; + + uint8_t buf[156] = {0}; + + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x8b, 0x2, 0x45, 0x3a, 0x6e, 0x89, 0x62, 0xc, 0xb8, 0xa6, 0xa8, 0x8f, 0x61, 0x96, + 0x2b, 0x2f, 0x88, 0x2c, 0x9a, 0x94, 0xbe, 0x6b, 0xc4, 0x75, 0xbd, 0x6e, 0xa}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x62, 0xfd, 0xe, 0xfd, 0x8a, 0x88, 0x74, 0xe8, 0x8d, 0xb6, 0xf, 0xc6, 0x4f}; + uint8_t bytesprops1[] = {0xf7, 0x21, 0xb8, 0x59, 0xf0, 0x8, 0x2e, 0x8e, 0xe2, 0x6c, 0xc3}; + uint8_t bytesprops2[] = {0xad, 0x9a, 0x75, 0x1, 0x6f, 0x23, 0x26, 0x48, 0xd5, 0xcf, 0xa2, 0xfd, 0xcb, 0xed}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x1b, 0xf2, 0x45, 0x55, 0x9e, 0x49, 0xf2, 0x1c, 0x42, 0xcd, 0x28, 0x23, 0x75, + 0x8a, 0xd8, 0x10, 0xf, 0x51, 0x5c, 0xab, 0xe3, 0x61, 0x65, 0xce, 0x33}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12161}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23150}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {12, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20295}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4658}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31275}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10976}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10006}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 198}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 518, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\166z\ENQ\171\210s\190J\237\153\219\210", _pubPktID = 15842, _pubBody = "\221-AF\157\205\a\153)\165QYh", _pubProps = -// [PropServerReference "\255R\216}\b\237\189\223\&8\SOH<\231\232<\SOH\142-;\184\212;\193u",PropServerReference -// "@QM\241\217\236\SUB\168a\236\188Y\191\214\189L\192",PropReasonString -// "\US\n\178\DC3\222\SOq\213\ETX\SUB",PropTopicAliasMaximum 23180,PropAssignedClientIdentifier -// "\217\203u\EM0\136\170\141\199\159L\225\207):\233\200\242",PropAuthenticationData "\EM\164(",PropUserProperty -// "o\ENQ9\184Y)\143\210\218/\181<(W\194\&4\146\164\171\174\160Nc\STX\207\249\196\242\169" -// "\128vU\185\186\&0\205\216\171C\148\241\SUB\ESC\235\247\139\137n?\"\233\231\180p\188\165",PropAuthenticationData -// "x\161\189\255#\152\163\214",PropMessageExpiryInterval 10220,PropReasonString "\172\232\145H\188",PropCorrelationData -// "\205ep\159\228O\174\143\ETB(LL\212\191KL\US}\153\235\188'\190\DC2\180\217u\RS%k",PropMaximumPacketSize 19148]} -TEST(Publish5QCTest, Encode41) { +// SubscribeRequest 20513 [("\246\249y9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\174\158\&9I\236",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\234)\247\155]i\178i\160:\ENQ\162\186\204\194v^KTS.P\233&\189",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval +// 4904,PropRequestProblemInformation 22,PropMessageExpiryInterval 8007,PropMaximumQoS +// 78,PropWildcardSubscriptionAvailable 176,PropTopicAlias 11429,PropResponseTopic +// "V\180\210\236\&4\253U\210C\179\244bq",PropSharedSubscriptionAvailable 151,PropSharedSubscriptionAvailable +// 145,PropContentType "\167\237$\a\200\203\156\180\138\250\a\237@",PropServerKeepAlive 20621,PropCorrelationData +// "\129*~\205L\n\192_Q\207\167N8~\132rB\140\140z|+\223\128\238\218",PropSubscriptionIdentifier 3,PropTopicAliasMaximum +// 14322,PropResponseInformation "/?!\CAN-?w\249\223\207",PropRetainAvailable 126,PropMessageExpiryInterval +// 25279,PropMessageExpiryInterval 2138,PropRetainAvailable 215,PropServerReference +// "q,\210\STX\151b\139A",PropResponseTopic "$\177\175\161",PropServerKeepAlive 31943,PropSharedSubscriptionAvailable +// 237,PropPayloadFormatIndicator 39,PropSubscriptionIdentifierAvailable 194,PropResponseTopic +// "\169a\243Y",PropCorrelationData "\206S\135R\226:\157\245\247~\218\159\203\136",PropTopicAliasMaximum +// 6865,PropSubscriptionIdentifierAvailable 165] +TEST(Subscribe5QCTest, Encode40) { uint8_t pkt[] = { - 0x35, 0xf3, 0x1, 0x0, 0xc, 0xa6, 0x7a, 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0, 0x8, 0x71, 0x2c, 0xd2, 0x2, + 0x97, 0x62, 0x8b, 0x41, 0x8, 0x0, 0x4, 0x24, 0xb1, 0xaf, 0xa1, 0x13, 0x7c, 0xc7, 0x2a, 0xed, 0x1, 0x27, 0x29, + 0xc2, 0x8, 0x0, 0x4, 0xa9, 0x61, 0xf3, 0x59, 0x9, 0x0, 0xe, 0xce, 0x53, 0x87, 0x52, 0xe2, 0x3a, 0x9d, 0xf5, + 0xf7, 0x7e, 0xda, 0x9f, 0xcb, 0x88, 0x22, 0x1a, 0xd1, 0x29, 0xa5, 0x0, 0x4, 0xf6, 0xf9, 0x79, 0x39, 0x0, 0x0, + 0x5, 0xae, 0x9e, 0x39, 0x49, 0xec, 0x1, 0x0, 0x19, 0xea, 0x29, 0xf7, 0x9b, 0x5d, 0x69, 0xb2, 0x69, 0xa0, 0x3a, + 0x5, 0xa2, 0xba, 0xcc, 0xc2, 0x76, 0x5e, 0x4b, 0x54, 0x53, 0x2e, 0x50, 0xe9, 0x26, 0xbd, 0x1}; - uint8_t topic_bytes[] = {0xa6, 0x7a, 0x5, 0xab, 0xd2, 0x73, 0xbe, 0x4a, 0xed, 0x99, 0xdb, 0xd2}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xdd, 0x2d, 0x41, 0x46, 0x9d, 0xcd, 0x7, 0x99, 0x29, 0xa5, 0x51, 0x59, 0x68}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + uint8_t buf[235] = {0}; - uint8_t bytesprops0[] = {0xff, 0x52, 0xd8, 0x7d, 0x8, 0xed, 0xbd, 0xdf, 0x38, 0x1, 0x3c, 0xe7, - 0xe8, 0x3c, 0x1, 0x8e, 0x2d, 0x3b, 0xb8, 0xd4, 0x3b, 0xc1, 0x75}; - uint8_t bytesprops1[] = {0x40, 0x51, 0x4d, 0xf1, 0xd9, 0xec, 0x1a, 0xa8, 0x61, - 0xec, 0xbc, 0x59, 0xbf, 0xd6, 0xbd, 0x4c, 0xc0}; - uint8_t bytesprops2[] = {0x1f, 0xa, 0xb2, 0x13, 0xde, 0xe, 0x71, 0xd5, 0x3, 0x1a}; - uint8_t bytesprops3[] = {0xd9, 0xcb, 0x75, 0x19, 0x30, 0x88, 0xaa, 0x8d, 0xc7, - 0x9f, 0x4c, 0xe1, 0xcf, 0x29, 0x3a, 0xe9, 0xc8, 0xf2}; - uint8_t bytesprops4[] = {0x19, 0xa4, 0x28}; - uint8_t bytesprops6[] = {0x80, 0x76, 0x55, 0xb9, 0xba, 0x30, 0xcd, 0xd8, 0xab, 0x43, 0x94, 0xf1, 0x1a, 0x1b, - 0xeb, 0xf7, 0x8b, 0x89, 0x6e, 0x3f, 0x22, 0xe9, 0xe7, 0xb4, 0x70, 0xbc, 0xa5}; - uint8_t bytesprops5[] = {0x6f, 0x5, 0x39, 0xb8, 0x59, 0x29, 0x8f, 0xd2, 0xda, 0x2f, 0xb5, 0x3c, 0x28, 0x57, 0xc2, - 0x34, 0x92, 0xa4, 0xab, 0xae, 0xa0, 0x4e, 0x63, 0x2, 0xcf, 0xf9, 0xc4, 0xf2, 0xa9}; - uint8_t bytesprops7[] = {0x78, 0xa1, 0xbd, 0xff, 0x23, 0x98, 0xa3, 0xd6}; - uint8_t bytesprops8[] = {0xac, 0xe8, 0x91, 0x48, 0xbc}; - uint8_t bytesprops9[] = {0xcd, 0x65, 0x70, 0x9f, 0xe4, 0x4f, 0xae, 0x8f, 0x17, 0x28, 0x4c, 0x4c, 0xd4, 0xbf, 0x4b, - 0x4c, 0x1f, 0x7d, 0x99, 0xeb, 0xbc, 0x27, 0xbe, 0x12, 0xb4, 0xd9, 0x75, 0x1e, 0x25, 0x6b}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xf6, 0xf9, 0x79, 0x39}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xae, 0x9e, 0x39, 0x49, 0xec}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xea, 0x29, 0xf7, 0x9b, 0x5d, 0x69, 0xb2, 0x69, 0xa0, 0x3a, 0x5, 0xa2, 0xba, + 0xcc, 0xc2, 0x76, 0x5e, 0x4b, 0x54, 0x53, 0x2e, 0x50, 0xe9, 0x26, 0xbd}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x56, 0xb4, 0xd2, 0xec, 0x34, 0xfd, 0x55, 0xd2, 0x43, 0xb3, 0xf4, 0x62, 0x71}; + uint8_t bytesprops1[] = {0xa7, 0xed, 0x24, 0x7, 0xc8, 0xcb, 0x9c, 0xb4, 0x8a, 0xfa, 0x7, 0xed, 0x40}; + uint8_t bytesprops2[] = {0x81, 0x2a, 0x7e, 0xcd, 0x4c, 0xa, 0xc0, 0x5f, 0x51, 0xcf, 0xa7, 0x4e, 0x38, + 0x7e, 0x84, 0x72, 0x42, 0x8c, 0x8c, 0x7a, 0x7c, 0x2b, 0xdf, 0x80, 0xee, 0xda}; + uint8_t bytesprops3[] = {0x2f, 0x3f, 0x21, 0x18, 0x2d, 0x3f, 0x77, 0xf9, 0xdf, 0xcf}; + uint8_t bytesprops4[] = {0x71, 0x2c, 0xd2, 0x2, 0x97, 0x62, 0x8b, 0x41}; + uint8_t bytesprops5[] = {0x24, 0xb1, 0xaf, 0xa1}; + uint8_t bytesprops6[] = {0xa9, 0x61, 0xf3, 0x59}; + uint8_t bytesprops7[] = {0xce, 0x53, 0x87, 0x52, 0xe2, 0x3a, 0x9d, 0xf5, 0xf7, 0x7e, 0xda, 0x9f, 0xcb, 0x88}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23180}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops5}, .v = {27, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10220}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19148}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4904}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8007}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11429}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20621}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14322}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25279}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2138}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31943}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6865}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15842, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20513, 3, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 13179 [("YR\212\171\209\EOTx\164\209\197\US\155",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\235",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\172\250G",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\r\149\246#m\237\132i\162%c\ESC\144\159F`\229\254\ENQG",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("}O6\STX\EM\250D>\167\STX",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\140\134n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2})] [PropResponseTopic +// "<\185t\174\203e\SUBL\235\232\154\CAN_\199\217\164\&4R\161\ACK\239\v\211",PropTopicAlias 2853,PropServerKeepAlive +// 20997,PropResponseTopic ";\213",PropMaximumQoS 53,PropWillDelayInterval 19196,PropCorrelationData +// "\188\134\175\158\211}Z\208\157\137\SYN\130\US",PropPayloadFormatIndicator 46,PropAuthenticationData +// "\154\251",PropUserProperty "\243:\176T\161*\195\213\SOH" "\159",PropSubscriptionIdentifier 17,PropTopicAliasMaximum +// 19238,PropServerReference "",PropMessageExpiryInterval 20733,PropSubscriptionIdentifierAvailable 57,PropResponseTopic +// "\206\v\206_\179\190t",PropResponseInformation "l\219\230\175\255\171",PropServerKeepAlive 16101,PropTopicAlias +// 5826,PropSharedSubscriptionAvailable 113,PropRequestProblemInformation 166,PropReceiveMaximum 6526,PropTopicAlias +// 21054,PropSessionExpiryInterval 21021,PropSubscriptionIdentifierAvailable 245,PropMessageExpiryInterval +// 26743,PropReasonString "f\"w]\\\v\b\237U\227\144\r\216\137.kl\130X/\DC16+\ESC{\ETBD]X",PropSessionExpiryInterval +// 9739,PropSubscriptionIdentifier 3,PropTopicAlias 22499] +TEST(Subscribe5QCTest, Encode41) { + uint8_t pkt[] = { + 0x82, 0x84, 0x2, 0x33, 0x7b, 0xba, 0x1, 0x8, 0x0, 0x17, 0x3c, 0xb9, 0x74, 0xae, 0xcb, 0x65, 0x1a, 0x4c, 0xeb, + 0xe8, 0x9a, 0x18, 0x5f, 0xc7, 0xd9, 0xa4, 0x34, 0x52, 0xa1, 0x6, 0xef, 0xb, 0xd3, 0x23, 0xb, 0x25, 0x13, 0x52, + 0x5, 0x8, 0x0, 0x2, 0x3b, 0xd5, 0x24, 0x35, 0x18, 0x0, 0x0, 0x4a, 0xfc, 0x9, 0x0, 0xd, 0xbc, 0x86, 0xaf, + 0x9e, 0xd3, 0x7d, 0x5a, 0xd0, 0x9d, 0x89, 0x16, 0x82, 0x1f, 0x1, 0x2e, 0x16, 0x0, 0x2, 0x9a, 0xfb, 0x26, 0x0, + 0x9, 0xf3, 0x3a, 0xb0, 0x54, 0xa1, 0x2a, 0xc3, 0xd5, 0x1, 0x0, 0x1, 0x9f, 0xb, 0x11, 0x22, 0x4b, 0x26, 0x1c, + 0x0, 0x0, 0x2, 0x0, 0x0, 0x50, 0xfd, 0x29, 0x39, 0x8, 0x0, 0x7, 0xce, 0xb, 0xce, 0x5f, 0xb3, 0xbe, 0x74, + 0x1a, 0x0, 0x6, 0x6c, 0xdb, 0xe6, 0xaf, 0xff, 0xab, 0x13, 0x3e, 0xe5, 0x23, 0x16, 0xc2, 0x2a, 0x71, 0x17, 0xa6, + 0x21, 0x19, 0x7e, 0x23, 0x52, 0x3e, 0x11, 0x0, 0x0, 0x52, 0x1d, 0x29, 0xf5, 0x2, 0x0, 0x0, 0x68, 0x77, 0x1f, + 0x0, 0x1d, 0x66, 0x22, 0x77, 0x5d, 0x5c, 0xb, 0x8, 0xed, 0x55, 0xe3, 0x90, 0xd, 0xd8, 0x89, 0x2e, 0x6b, 0x6c, + 0x82, 0x58, 0x2f, 0x11, 0x36, 0x2b, 0x1b, 0x7b, 0x17, 0x44, 0x5d, 0x58, 0x11, 0x0, 0x0, 0x26, 0xb, 0xb, 0x3, + 0x23, 0x57, 0xe3, 0x0, 0xc, 0x59, 0x52, 0xd4, 0xab, 0xd1, 0x4, 0x78, 0xa4, 0xd1, 0xc5, 0x1f, 0x9b, 0x1, 0x0, + 0x1, 0xeb, 0x1, 0x0, 0x3, 0xac, 0xfa, 0x47, 0x2, 0x0, 0x0, 0x2, 0x0, 0x14, 0xd, 0x95, 0xf6, 0x23, 0x6d, + 0xed, 0x84, 0x69, 0xa2, 0x25, 0x63, 0x1b, 0x90, 0x9f, 0x46, 0x60, 0xe5, 0xfe, 0x5, 0x47, 0x1, 0x0, 0xa, 0x7d, + 0x4f, 0x36, 0x2, 0x19, 0xfa, 0x44, 0x3e, 0xa7, 0x2, 0x0, 0x0, 0x3, 0x8c, 0x86, 0x6e, 0x2}; + + uint8_t buf[273] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x59, 0x52, 0xd4, 0xab, 0xd1, 0x4, 0x78, 0xa4, 0xd1, 0xc5, 0x1f, 0x9b}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xeb}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xac, 0xfa, 0x47}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd, 0x95, 0xf6, 0x23, 0x6d, 0xed, 0x84, 0x69, 0xa2, 0x25, + 0x63, 0x1b, 0x90, 0x9f, 0x46, 0x60, 0xe5, 0xfe, 0x5, 0x47}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x7d, 0x4f, 0x36, 0x2, 0x19, 0xfa, 0x44, 0x3e, 0xa7, 0x2}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8c, 0x86, 0x6e}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x3c, 0xb9, 0x74, 0xae, 0xcb, 0x65, 0x1a, 0x4c, 0xeb, 0xe8, 0x9a, 0x18, + 0x5f, 0xc7, 0xd9, 0xa4, 0x34, 0x52, 0xa1, 0x6, 0xef, 0xb, 0xd3}; + uint8_t bytesprops1[] = {0x3b, 0xd5}; + uint8_t bytesprops2[] = {0xbc, 0x86, 0xaf, 0x9e, 0xd3, 0x7d, 0x5a, 0xd0, 0x9d, 0x89, 0x16, 0x82, 0x1f}; + uint8_t bytesprops3[] = {0x9a, 0xfb}; + uint8_t bytesprops5[] = {0x9f}; + uint8_t bytesprops4[] = {0xf3, 0x3a, 0xb0, 0x54, 0xa1, 0x2a, 0xc3, 0xd5, 0x1}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops7[] = {0xce, 0xb, 0xce, 0x5f, 0xb3, 0xbe, 0x74}; + uint8_t bytesprops8[] = {0x6c, 0xdb, 0xe6, 0xaf, 0xff, 0xab}; + uint8_t bytesprops9[] = {0x66, 0x22, 0x77, 0x5d, 0x5c, 0xb, 0x8, 0xed, 0x55, 0xe3, 0x90, 0xd, 0xd8, 0x89, 0x2e, + 0x6b, 0x6c, 0x82, 0x58, 0x2f, 0x11, 0x36, 0x2b, 0x1b, 0x7b, 0x17, 0x44, 0x5d, 0x58}; -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\206v6D\250\210o\GS\204\139H\184\vu\245\236z", _pubPktID = 6705, _pubBody = -// "\f\211\163\197\&3\254\185\161\DC2\198\aX\255", _pubProps = [PropReceiveMaximum 9095,PropReasonString -// ".\200\nrz\149\201\143\162>\209\221\174\158i\161\132IN",PropPayloadFormatIndicator 233]} -TEST(Publish5QCTest, Encode42) { - uint8_t pkt[] = {0x3d, 0x3e, 0x0, 0x11, 0xce, 0x76, 0x36, 0x44, 0xfa, 0xd2, 0x6f, 0x1d, 0xcc, 0x8b, 0x48, 0xb8, - 0xb, 0x75, 0xf5, 0xec, 0x7a, 0x1a, 0x31, 0x1b, 0x21, 0x23, 0x87, 0x1f, 0x0, 0x13, 0x2e, 0xc8, - 0xa, 0x72, 0x7a, 0x95, 0xc9, 0x8f, 0xa2, 0x3e, 0xd1, 0xdd, 0xae, 0x9e, 0x69, 0xa1, 0x84, 0x49, - 0x4e, 0x1, 0xe9, 0xc, 0xd3, 0xa3, 0xc5, 0x33, 0xfe, 0xb9, 0xa1, 0x12, 0xc6, 0x7, 0x58, 0xff}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2853}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20997}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19196}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops4}, .v = {1, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19238}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20733}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16101}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5826}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6526}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21054}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21021}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26743}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9739}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22499}}, + }; - uint8_t buf[74] = {0}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13179, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 2708 [("\128\SUB\143\242\FS\143\181\142tg\159H\SI\193<",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\STX\194;\241\194\228a\t\191u0o\203O|\SUBV\174x\171\235\159\149\&6",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("4\173\128\155%\a\234\DLE\166\&1\188\EOT@\142qQuA\154N",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\169p4\162\139:?",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\130)\226\134",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropReasonString +// "J=\154\157t\176\185\252\239`r~j=",PropServerReference "\207\220\145R",PropServerKeepAlive 4925,PropContentType +// "\170\212\219I_\147\151uT\216~\248\200\240u\rU\DLE\148P\252'\180\207\RS\177",PropTopicAlias +// 1012,PropSharedSubscriptionAvailable 102,PropMessageExpiryInterval 4429,PropReasonString +// "\SOH\NUL\DC2\156\138\243\242i\182",PropContentType +// "\217\229\179\184v(\170\228\197\128\EM\184",PropSessionExpiryInterval 751,PropMessageExpiryInterval +// 2764,PropPayloadFormatIndicator 141,PropUserProperty "aef\RS\177" +// "\227\151\225\SOH~i\DC1ri\252\151\131\192\a\250\220\182`\174",PropTopicAliasMaximum 23948,PropMaximumPacketSize +// 15730] +TEST(Subscribe5QCTest, Encode42) { + uint8_t pkt[] = {0x82, 0xe7, 0x1, 0xa, 0x94, 0x8e, 0x1, 0x1f, 0x0, 0xe, 0x4a, 0x3d, 0x9a, 0x9d, 0x74, 0xb0, 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, 0x10, + 0xa6, 0x31, 0xbc, 0x4, 0x40, 0x8e, 0x71, 0x51, 0x75, 0x41, 0x9a, 0x4e, 0x1, 0x0, 0x7, 0xa9, 0x70, + 0x34, 0xa2, 0x8b, 0x3a, 0x3f, 0x1, 0x0, 0x4, 0x82, 0x29, 0xe2, 0x86, 0x0}; - uint8_t topic_bytes[] = {0xce, 0x76, 0x36, 0x44, 0xfa, 0xd2, 0x6f, 0x1d, 0xcc, - 0x8b, 0x48, 0xb8, 0xb, 0x75, 0xf5, 0xec, 0x7a}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xc, 0xd3, 0xa3, 0xc5, 0x33, 0xfe, 0xb9, 0xa1, 0x12, 0xc6, 0x7, 0x58, 0xff}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + uint8_t buf[244] = {0}; - uint8_t bytesprops0[] = {0x2e, 0xc8, 0xa, 0x72, 0x7a, 0x95, 0xc9, 0x8f, 0xa2, 0x3e, - 0xd1, 0xdd, 0xae, 0x9e, 0x69, 0xa1, 0x84, 0x49, 0x4e}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x80, 0x1a, 0x8f, 0xf2, 0x1c, 0x8f, 0xb5, 0x8e, + 0x74, 0x67, 0x9f, 0x48, 0xf, 0xc1, 0x3c}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2, 0xc2, 0x3b, 0xf1, 0xc2, 0xe4, 0x61, 0x9, 0xbf, 0x75, 0x30, 0x6f, + 0xcb, 0x4f, 0x7c, 0x1a, 0x56, 0xae, 0x78, 0xab, 0xeb, 0x9f, 0x95, 0x36}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x34, 0xad, 0x80, 0x9b, 0x25, 0x7, 0xea, 0x10, 0xa6, 0x31, + 0xbc, 0x4, 0x40, 0x8e, 0x71, 0x51, 0x75, 0x41, 0x9a, 0x4e}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa9, 0x70, 0x34, 0xa2, 0x8b, 0x3a, 0x3f}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x82, 0x29, 0xe2, 0x86}; + lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x4a, 0x3d, 0x9a, 0x9d, 0x74, 0xb0, 0xb9, 0xfc, 0xef, 0x60, 0x72, 0x7e, 0x6a, 0x3d}; + uint8_t bytesprops1[] = {0xcf, 0xdc, 0x91, 0x52}; + uint8_t bytesprops2[] = {0xaa, 0xd4, 0xdb, 0x49, 0x5f, 0x93, 0x97, 0x75, 0x54, 0xd8, 0x7e, 0xf8, 0xc8, + 0xf0, 0x75, 0xd, 0x55, 0x10, 0x94, 0x50, 0xfc, 0x27, 0xb4, 0xcf, 0x1e, 0xb1}; + uint8_t bytesprops3[] = {0x1, 0x0, 0x12, 0x9c, 0x8a, 0xf3, 0xf2, 0x69, 0xb6}; + uint8_t bytesprops4[] = {0xd9, 0xe5, 0xb3, 0xb8, 0x76, 0x28, 0xaa, 0xe4, 0xc5, 0x80, 0x19, 0xb8}; + uint8_t bytesprops6[] = {0xe3, 0x97, 0xe1, 0x1, 0x7e, 0x69, 0x11, 0x72, 0x69, 0xfc, + 0x97, 0x83, 0xc0, 0x7, 0xfa, 0xdc, 0xb6, 0x60, 0xae}; + uint8_t bytesprops5[] = {0x61, 0x65, 0x66, 0x1e, 0xb1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9095}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4925}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1012}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4429}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 751}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2764}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops5}, .v = {19, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23948}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15730}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6705, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2708, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 22393 [("4\151\147%\225\205\145\214",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\170\240\162w`E\254\232 +// \143\DC2x\209h3\148\197\DEL\195~\165h\DLE\232\201Bm",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\248\158\234\227[R.\240VV'\227@\DC3)\DLE\242\199\US\199\221H\199",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationData +// "",PropContentType "\206o\195\135\253\250\246\193\205\200\172\238|VO\rv\158\&4",PropServerKeepAlive +// 16840,PropSharedSubscriptionAvailable 14,PropResponseInformation +// ":E-\170:\ESC\232\GS\196A\166\168\238\182\220",PropAuthenticationMethod "b\STX4#\201",PropServerReference +// "\205\208\156\255a5A0\144<_\148\SIs\SI\152\130\137'\203",PropTopicAlias 19282,PropRequestResponseInformation +// 145,PropAssignedClientIdentifier +// "\161\193;\174\250\190\142Z\209Q\157\DC1'\210o\252\161g\a\132\141|\176p\FSh\173\186#D",PropCorrelationData +// "\147{\164A$\149\204ln\162]\220\162\&9NY",PropAssignedClientIdentifier "4\215\137cz\DC16&]",PropContentType +// "[`\147=\ETB\185\136\221\252\200\US\DC2\f\236\&9\198\205rkz\SI\171\&9\164\EM\227",PropUserProperty +// "\DC1\144\DLE\EMV|h\226\230u\205\194B\236\ETB/\220&\US\216s\EM\EOT4\177\a\178\175S\a" +// "\255\197\253\226\";\213\241S\225\194Y\169\SI1\133\180\140\240$Yo",PropAuthenticationData +// "*\130\DC3\239\&6\SI\206\252\156\223\\oS\NUL\216\164\NUL,\SOH\a",PropMaximumPacketSize 1890,PropUserProperty +// "\131\252\204\242\138\241\154\145\184\216\142\&9\187F\NAKU/\148a\179\205\DC3" +// "gQ\206\227\230\216\240\b\DEL|\144\135`\197\217Vx=\234\178i\244",PropRequestResponseInformation 81,PropUserProperty +// "\240{G" "",PropMaximumPacketSize 2959,PropWillDelayInterval 10548,PropReceiveMaximum +// 30850,PropSubscriptionIdentifierAvailable 177,PropMaximumQoS 0,PropWillDelayInterval 17382,PropCorrelationData +// "k'\188)\161\143",PropPayloadFormatIndicator 3,PropTopicAlias 7431,PropMaximumQoS 180] +TEST(Subscribe5QCTest, Encode43) { + uint8_t pkt[] = { + 0x82, 0xae, 0x3, 0x57, 0x79, 0xe7, 0x2, 0x16, 0x0, 0x0, 0x3, 0x0, 0x13, 0xce, 0x6f, 0xc3, 0x87, 0xfd, 0xfa, + 0xf6, 0xc1, 0xcd, 0xc8, 0xac, 0xee, 0x7c, 0x56, 0x4f, 0xd, 0x76, 0x9e, 0x34, 0x13, 0x41, 0xc8, 0x2a, 0xe, 0x1a, + 0x0, 0xf, 0x3a, 0x45, 0x2d, 0xaa, 0x3a, 0x1b, 0xe8, 0x1d, 0xc4, 0x41, 0xa6, 0xa8, 0xee, 0xb6, 0xdc, 0x15, 0x0, + 0x5, 0x62, 0x2, 0x34, 0x23, 0xc9, 0x1c, 0x0, 0x14, 0xcd, 0xd0, 0x9c, 0xff, 0x61, 0x35, 0x41, 0x30, 0x90, 0x3c, + 0x5f, 0x94, 0xf, 0x73, 0xf, 0x98, 0x82, 0x89, 0x27, 0xcb, 0x23, 0x4b, 0x52, 0x19, 0x91, 0x12, 0x0, 0x1e, 0xa1, + 0xc1, 0x3b, 0xae, 0xfa, 0xbe, 0x8e, 0x5a, 0xd1, 0x51, 0x9d, 0x11, 0x27, 0xd2, 0x6f, 0xfc, 0xa1, 0x67, 0x7, 0x84, + 0x8d, 0x7c, 0xb0, 0x70, 0x1c, 0x68, 0xad, 0xba, 0x23, 0x44, 0x9, 0x0, 0x10, 0x93, 0x7b, 0xa4, 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x69, 0xf4, 0x19, 0x51, 0x26, 0x0, 0x3, + 0xf0, 0x7b, 0x47, 0x0, 0x0, 0x27, 0x0, 0x0, 0xb, 0x8f, 0x18, 0x0, 0x0, 0x29, 0x34, 0x21, 0x78, 0x82, 0x29, + 0xb1, 0x24, 0x0, 0x18, 0x0, 0x0, 0x43, 0xe6, 0x9, 0x0, 0x6, 0x6b, 0x27, 0xbc, 0x29, 0xa1, 0x8f, 0x1, 0x3, + 0x23, 0x1d, 0x7, 0x24, 0xb4, 0x0, 0x8, 0x34, 0x97, 0x93, 0x25, 0xe1, 0xcd, 0x91, 0xd6, 0x2, 0x0, 0x1b, 0xaa, + 0xf0, 0xa2, 0x77, 0x60, 0x45, 0xfe, 0xe8, 0x20, 0x8f, 0x12, 0x78, 0xd1, 0x68, 0x33, 0x94, 0xc5, 0x7f, 0xc3, 0x7e, + 0xa5, 0x68, 0x10, 0xe8, 0xc9, 0x42, 0x6d, 0x2, 0x0, 0x17, 0xf8, 0x9e, 0xea, 0xe3, 0x5b, 0x52, 0x2e, 0xf0, 0x56, + 0x56, 0x27, 0xe3, 0x40, 0x13, 0x29, 0x10, 0xf2, 0xc7, 0x1f, 0xc7, 0xdd, 0x48, 0xc7, 0x0}; + + uint8_t buf[443] = {0}; + + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x34, 0x97, 0x93, 0x25, 0xe1, 0xcd, 0x91, 0xd6}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xaa, 0xf0, 0xa2, 0x77, 0x60, 0x45, 0xfe, 0xe8, 0x20, 0x8f, 0x12, 0x78, 0xd1, 0x68, + 0x33, 0x94, 0xc5, 0x7f, 0xc3, 0x7e, 0xa5, 0x68, 0x10, 0xe8, 0xc9, 0x42, 0x6d}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf8, 0x9e, 0xea, 0xe3, 0x5b, 0x52, 0x2e, 0xf0, 0x56, 0x56, 0x27, 0xe3, + 0x40, 0x13, 0x29, 0x10, 0xf2, 0xc7, 0x1f, 0xc7, 0xdd, 0x48, 0xc7}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xce, 0x6f, 0xc3, 0x87, 0xfd, 0xfa, 0xf6, 0xc1, 0xcd, 0xc8, + 0xac, 0xee, 0x7c, 0x56, 0x4f, 0xd, 0x76, 0x9e, 0x34}; + uint8_t bytesprops2[] = {0x3a, 0x45, 0x2d, 0xaa, 0x3a, 0x1b, 0xe8, 0x1d, 0xc4, 0x41, 0xa6, 0xa8, 0xee, 0xb6, 0xdc}; + uint8_t bytesprops3[] = {0x62, 0x2, 0x34, 0x23, 0xc9}; + uint8_t bytesprops4[] = {0xcd, 0xd0, 0x9c, 0xff, 0x61, 0x35, 0x41, 0x30, 0x90, 0x3c, + 0x5f, 0x94, 0xf, 0x73, 0xf, 0x98, 0x82, 0x89, 0x27, 0xcb}; + uint8_t bytesprops5[] = {0xa1, 0xc1, 0x3b, 0xae, 0xfa, 0xbe, 0x8e, 0x5a, 0xd1, 0x51, 0x9d, 0x11, 0x27, 0xd2, 0x6f, + 0xfc, 0xa1, 0x67, 0x7, 0x84, 0x8d, 0x7c, 0xb0, 0x70, 0x1c, 0x68, 0xad, 0xba, 0x23, 0x44}; + uint8_t bytesprops6[] = {0x93, 0x7b, 0xa4, 0x41, 0x24, 0x95, 0xcc, 0x6c, + 0x6e, 0xa2, 0x5d, 0xdc, 0xa2, 0x39, 0x4e, 0x59}; + uint8_t bytesprops7[] = {0x34, 0xd7, 0x89, 0x63, 0x7a, 0x11, 0x36, 0x26, 0x5d}; + uint8_t bytesprops8[] = {0x5b, 0x60, 0x93, 0x3d, 0x17, 0xb9, 0x88, 0xdd, 0xfc, 0xc8, 0x1f, 0x12, 0xc, + 0xec, 0x39, 0xc6, 0xcd, 0x72, 0x6b, 0x7a, 0xf, 0xab, 0x39, 0xa4, 0x19, 0xe3}; + uint8_t bytesprops10[] = {0xff, 0xc5, 0xfd, 0xe2, 0x22, 0x3b, 0xd5, 0xf1, 0x53, 0xe1, 0xc2, + 0x59, 0xa9, 0xf, 0x31, 0x85, 0xb4, 0x8c, 0xf0, 0x24, 0x59, 0x6f}; + uint8_t bytesprops9[] = {0x11, 0x90, 0x10, 0x19, 0x56, 0x7c, 0x68, 0xe2, 0xe6, 0x75, 0xcd, 0xc2, 0x42, 0xec, 0x17, + 0x2f, 0xdc, 0x26, 0x1f, 0xd8, 0x73, 0x19, 0x4, 0x34, 0xb1, 0x7, 0xb2, 0xaf, 0x53, 0x7}; + uint8_t bytesprops11[] = {0x2a, 0x82, 0x13, 0xef, 0x36, 0xf, 0xce, 0xfc, 0x9c, 0xdf, + 0x5c, 0x6f, 0x53, 0x0, 0xd8, 0xa4, 0x0, 0x2c, 0x1, 0x7}; + uint8_t bytesprops13[] = {0x67, 0x51, 0xce, 0xe3, 0xe6, 0xd8, 0xf0, 0x8, 0x7f, 0x7c, 0x90, + 0x87, 0x60, 0xc5, 0xd9, 0x56, 0x78, 0x3d, 0xea, 0xb2, 0x69, 0xf4}; + uint8_t bytesprops12[] = {0x83, 0xfc, 0xcc, 0xf2, 0x8a, 0xf1, 0x9a, 0x91, 0xb8, 0xd8, 0x8e, + 0x39, 0xbb, 0x46, 0x15, 0x55, 0x2f, 0x94, 0x61, 0xb3, 0xcd, 0x13}; + uint8_t bytesprops15[] = {0}; + uint8_t bytesprops14[] = {0xf0, 0x7b, 0x47}; + uint8_t bytesprops16[] = {0x6b, 0x27, 0xbc, 0x29, 0xa1, 0x8f}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16840}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19282}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops9}, .v = {22, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1890}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {22, (char*)&bytesprops12}, .v = {22, (char*)&bytesprops13}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops14}, .v = {0, (char*)&bytesprops15}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2959}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10548}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30850}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17382}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops16}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7431}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 180}}, + }; -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\146n\207\252s\SOHt\253N\US(M?\NAK&\NAKR\139\193\&4\SOH\152\179\v", _pubPktID = 0, _pubBody = -// "\139b\185\b\186\&5\RS\EOT\166\STXV\149\135/\DEL$\167\144u", _pubProps = [PropContentType -// "\210\147A\224\DC4&\222\175_ l\189${",PropWildcardSubscriptionAvailable 216,PropTopicAliasMaximum -// 7359,PropSubscriptionIdentifierAvailable 158,PropTopicAliasMaximum 2955,PropAuthenticationMethod -// "\247\157\221\203\228B\EM\170\209\236\176\&6\DEL\208",PropReasonString -// "\SUB\177n\245\222`\165@\185\205\253m\146X\231\131W\181\238\232\203",PropSessionExpiryInterval -// 24406,PropTopicAliasMaximum 25543,PropMessageExpiryInterval 21136,PropTopicAlias 21657,PropSessionExpiryInterval -// 11033,PropAuthenticationData "\128pR\231\225\221>A\224",PropSharedSubscriptionAvailable -// 110,PropWildcardSubscriptionAvailable 106,PropResponseInformation -// "\221>%\139L\205\b\142\f\215\134|\172\147*\228\b\229\140\194(\SO\226\186\b",PropContentType "\SOHN!\156M\188"]} -TEST(Publish5QCTest, Encode43) { - uint8_t pkt[] = {0x31, 0xbd, 0x1, 0x0, 0x18, 0x92, 0x6e, 0xcf, 0xfc, 0x73, 0x1, 0x74, 0xfd, 0x4e, 0x1f, 0x28, - 0x4d, 0x3f, 0x15, 0x26, 0x15, 0x52, 0x8b, 0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 0x4d, - 0x3f, 0x15, 0x26, 0x15, 0x52, 0x8b, 0xc1, 0x34, 0x1, 0x98, 0xb3, 0xb}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x8b, 0x62, 0xb9, 0x8, 0xba, 0x35, 0x1e, 0x4, 0xa6, 0x2, - 0x56, 0x95, 0x87, 0x2f, 0x7f, 0x24, 0xa7, 0x90, 0x75}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22393, 3, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 16009 [("\v\252$!\153S\184\231\225\247\182w\185\196\179\251-)D\130W\129\222\SYNQ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Bn\211\153\\\EOT\238\190\196\180C1\146B\199\236h\DC1\210\&9,\147I",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\EOT;7\159\130c%\243\CAN\148\213\v\247'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\220\225\t\132\131\223\183",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropTopicAliasMaximum +// 20116,PropWildcardSubscriptionAvailable 84,PropWildcardSubscriptionAvailable 215,PropRetainAvailable +// 70,PropResponseTopic "\"?~\SI\178\156\215b\173`\235\DC2\243\ACK\165Q\157",PropRetainAvailable +// 7,PropRequestResponseInformation 91,PropReceiveMaximum 2391,PropTopicAliasMaximum +// 28497,PropSharedSubscriptionAvailable 22,PropRequestResponseInformation 239,PropAuthenticationData +// "A(\159\209\179$o\137>",PropReasonString "\202P +// \219\129\206D\\\214\165\237\195\SOH\209,\244\215t\DELg^\SOH\167\135",PropAuthenticationData +// "#\253T\223(8\215o\244cA\162\252\EM\DC2\160P\148\r>1\215\136\164!",PropTopicAlias 15751] +TEST(Subscribe5QCTest, Encode44) { + uint8_t pkt[] = {0x82, 0xc5, 0x1, 0x3e, 0x89, 0x71, 0x22, 0x4e, 0x94, 0x28, 0x54, 0x28, 0xd7, 0x25, 0x46, 0x8, 0x0, + 0x11, 0x22, 0x3f, 0x7e, 0xf, 0xb2, 0x9c, 0xd7, 0x62, 0xad, 0x60, 0xeb, 0x12, 0xf3, 0x6, 0xa5, 0x51, + 0x9d, 0x25, 0x7, 0x19, 0x5b, 0x21, 0x9, 0x57, 0x22, 0x6f, 0x51, 0x2a, 0x16, 0x19, 0xef, 0x16, 0x0, + 0x9, 0x41, 0x28, 0x9f, 0xd1, 0xb3, 0x24, 0x6f, 0x89, 0x3e, 0x1f, 0x0, 0x18, 0xca, 0x50, 0x20, 0xdb, + 0x81, 0xce, 0x44, 0x5c, 0xd6, 0xa5, 0xed, 0xc3, 0x1, 0xd1, 0x2c, 0xf4, 0xd7, 0x74, 0x7f, 0x67, 0x5e, + 0x1, 0xa7, 0x87, 0x16, 0x0, 0x19, 0x23, 0xfd, 0x54, 0xdf, 0x28, 0x38, 0xd7, 0x6f, 0xf4, 0x63, 0x41, + 0xa2, 0xfc, 0x19, 0x12, 0xa0, 0x50, 0x94, 0xd, 0x3e, 0x31, 0xd7, 0x88, 0xa4, 0x21, 0x23, 0x3d, 0x87, + 0x0, 0x19, 0xb, 0xfc, 0x24, 0x21, 0x99, 0x53, 0xb8, 0xe7, 0xe1, 0xf7, 0xb6, 0x77, 0xb9, 0xc4, 0xb3, + 0xfb, 0x2d, 0x29, 0x44, 0x82, 0x57, 0x81, 0xde, 0x16, 0x51, 0x2, 0x0, 0x17, 0x42, 0x6e, 0xd3, 0x99, + 0x5c, 0x4, 0xee, 0xbe, 0xc4, 0xb4, 0x43, 0x31, 0x92, 0x42, 0xc7, 0xec, 0x68, 0x11, 0xd2, 0x39, 0x2c, + 0x93, 0x49, 0x1, 0x0, 0xe, 0x4, 0x3b, 0x37, 0x9f, 0x82, 0x63, 0x25, 0xf3, 0x18, 0x94, 0xd5, 0xb, + 0xf7, 0x27, 0x1, 0x0, 0x7, 0xdc, 0xe1, 0x9, 0x84, 0x83, 0xdf, 0xb7, 0x1}; + + uint8_t buf[210] = {0}; - uint8_t bytesprops0[] = {0xd2, 0x93, 0x41, 0xe0, 0x14, 0x26, 0xde, 0xaf, 0x5f, 0x20, 0x6c, 0xbd, 0x24, 0x7b}; - uint8_t bytesprops1[] = {0xf7, 0x9d, 0xdd, 0xcb, 0xe4, 0x42, 0x19, 0xaa, 0xd1, 0xec, 0xb0, 0x36, 0x7f, 0xd0}; - uint8_t bytesprops2[] = {0x1a, 0xb1, 0x6e, 0xf5, 0xde, 0x60, 0xa5, 0x40, 0xb9, 0xcd, 0xfd, - 0x6d, 0x92, 0x58, 0xe7, 0x83, 0x57, 0xb5, 0xee, 0xe8, 0xcb}; - uint8_t bytesprops3[] = {0x80, 0x70, 0x52, 0xe7, 0xe1, 0xdd, 0x3e, 0x41, 0xe0}; - uint8_t bytesprops4[] = {0xdd, 0x3e, 0x25, 0x8b, 0x4c, 0xcd, 0x8, 0x8e, 0xc, 0xd7, 0x86, 0x7c, 0xac, - 0x93, 0x2a, 0xe4, 0x8, 0xe5, 0x8c, 0xc2, 0x28, 0xe, 0xe2, 0xba, 0x8}; - uint8_t bytesprops5[] = {0x1, 0x4e, 0x21, 0x9c, 0x4d, 0xbc}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xb, 0xfc, 0x24, 0x21, 0x99, 0x53, 0xb8, 0xe7, 0xe1, 0xf7, 0xb6, 0x77, 0xb9, + 0xc4, 0xb3, 0xfb, 0x2d, 0x29, 0x44, 0x82, 0x57, 0x81, 0xde, 0x16, 0x51}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x42, 0x6e, 0xd3, 0x99, 0x5c, 0x4, 0xee, 0xbe, 0xc4, 0xb4, 0x43, 0x31, + 0x92, 0x42, 0xc7, 0xec, 0x68, 0x11, 0xd2, 0x39, 0x2c, 0x93, 0x49}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4, 0x3b, 0x37, 0x9f, 0x82, 0x63, 0x25, 0xf3, 0x18, 0x94, 0xd5, 0xb, 0xf7, 0x27}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xdc, 0xe1, 0x9, 0x84, 0x83, 0xdf, 0xb7}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x22, 0x3f, 0x7e, 0xf, 0xb2, 0x9c, 0xd7, 0x62, 0xad, + 0x60, 0xeb, 0x12, 0xf3, 0x6, 0xa5, 0x51, 0x9d}; + uint8_t bytesprops1[] = {0x41, 0x28, 0x9f, 0xd1, 0xb3, 0x24, 0x6f, 0x89, 0x3e}; + uint8_t bytesprops2[] = {0xca, 0x50, 0x20, 0xdb, 0x81, 0xce, 0x44, 0x5c, 0xd6, 0xa5, 0xed, 0xc3, + 0x1, 0xd1, 0x2c, 0xf4, 0xd7, 0x74, 0x7f, 0x67, 0x5e, 0x1, 0xa7, 0x87}; + uint8_t bytesprops3[] = {0x23, 0xfd, 0x54, 0xdf, 0x28, 0x38, 0xd7, 0x6f, 0xf4, 0x63, 0x41, 0xa2, 0xfc, + 0x19, 0x12, 0xa0, 0x50, 0x94, 0xd, 0x3e, 0x31, 0xd7, 0x88, 0xa4, 0x21}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7359}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2955}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24406}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25543}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21136}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21657}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11033}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20116}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2391}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28497}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15751}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16009, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\168\205\235\&9L\b\236\187\184{\199\135G\165c\200\144\SO\NUL\234u\SYN\142O\177N:\161\&8", _pubPktID = 0, _pubBody = -// "Z \DEL\193\197\&7K\147\137\199b]\243}\248\161\248.Y\218bb\132\156\GS\DC2>\224", _pubProps = -// [PropSharedSubscriptionAvailable 130,PropTopicAlias 27548,PropSubscriptionIdentifier 11,PropAssignedClientIdentifier -// "\192#\158\221\154Z\129\236\235",PropServerReference "\216",PropServerKeepAlive 15984]} -TEST(Publish5QCTest, Encode44) { - uint8_t pkt[] = {0x31, 0x56, 0x0, 0x1d, 0xa8, 0xcd, 0xeb, 0x39, 0x4c, 0x8, 0xec, 0xbb, 0xb8, 0x7b, 0xc7, - 0x87, 0x47, 0xa5, 0x63, 0xc8, 0x90, 0xe, 0x0, 0xea, 0x75, 0x16, 0x8e, 0x4f, 0xb1, 0x4e, - 0x3a, 0xa1, 0x38, 0x1a, 0x2a, 0x82, 0x23, 0x6b, 0x9c, 0xb, 0xb, 0x12, 0x0, 0x9, 0xc0, - 0x23, 0x9e, 0xdd, 0x9a, 0x5a, 0x81, 0xec, 0xeb, 0x1c, 0x0, 0x1, 0xd8, 0x13, 0x3e, 0x70, - 0x5a, 0x20, 0x7f, 0xc1, 0xc5, 0x37, 0x4b, 0x93, 0x89, 0xc7, 0x62, 0x5d, 0xf3, 0x7d, 0xf8, - 0xa1, 0xf8, 0x2e, 0x59, 0xda, 0x62, 0x62, 0x84, 0x9c, 0x1d, 0x12, 0x3e, 0xe0}; - - uint8_t buf[98] = {0}; - - uint8_t topic_bytes[] = {0xa8, 0xcd, 0xeb, 0x39, 0x4c, 0x8, 0xec, 0xbb, 0xb8, 0x7b, 0xc7, 0x87, 0x47, 0xa5, 0x63, - 0xc8, 0x90, 0xe, 0x0, 0xea, 0x75, 0x16, 0x8e, 0x4f, 0xb1, 0x4e, 0x3a, 0xa1, 0x38}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x5a, 0x20, 0x7f, 0xc1, 0xc5, 0x37, 0x4b, 0x93, 0x89, 0xc7, 0x62, 0x5d, 0xf3, 0x7d, - 0xf8, 0xa1, 0xf8, 0x2e, 0x59, 0xda, 0x62, 0x62, 0x84, 0x9c, 0x1d, 0x12, 0x3e, 0xe0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; +// SubscribeRequest 14676 [("\219\215v\249b\191\208\&8H\181\rI&\210",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAssignedClientIdentifier +// "",PropResponseInformation "\SOMU\195",PropServerKeepAlive 9648,PropUserProperty "0 +// \"\229\155\171a\226\215\CAN\219\135\212\175P\202\172\179\251'q" +// "\187e\228\130\212>\155\230,`5\DC3\159\182\177\DC1\b\ESCT\135\GS\CAN\239\b\177\203\248",PropReasonString +// "I\237\USN\131\238C\177C",PropResponseInformation "xr\130a\v\244\180q*+\200\209\159\206\188\244\148["] +TEST(Subscribe5QCTest, Encode45) { + uint8_t pkt[] = {0x82, 0x77, 0x39, 0x54, 0x63, 0x12, 0x0, 0x0, 0x1a, 0x0, 0x4, 0xe, 0x4d, 0x55, 0xc3, 0x13, + 0x25, 0xb0, 0x26, 0x0, 0x15, 0x30, 0x20, 0x22, 0xe5, 0x9b, 0xab, 0x61, 0xe2, 0xd7, 0x18, 0xdb, + 0x87, 0xd4, 0xaf, 0x50, 0xca, 0xac, 0xb3, 0xfb, 0x27, 0x71, 0x0, 0x1b, 0xbb, 0x65, 0xe4, 0x82, + 0xd4, 0x3e, 0x9b, 0xe6, 0x2c, 0x60, 0x35, 0x13, 0x9f, 0xb6, 0xb1, 0x11, 0x8, 0x1b, 0x54, 0x87, + 0x1d, 0x18, 0xef, 0x8, 0xb1, 0xcb, 0xf8, 0x1f, 0x0, 0x9, 0x49, 0xed, 0x1f, 0x4e, 0x83, 0xee, + 0x43, 0xb1, 0x43, 0x1a, 0x0, 0x12, 0x78, 0x72, 0x82, 0x61, 0xb, 0xf4, 0xb4, 0x71, 0x2a, 0x2b, + 0xc8, 0xd1, 0x9f, 0xce, 0xbc, 0xf4, 0x94, 0x5b, 0x0, 0xe, 0xdb, 0xd7, 0x76, 0xf9, 0x62, 0xbf, + 0xd0, 0x38, 0x48, 0xb5, 0xd, 0x49, 0x26, 0xd2, 0x1}; + + uint8_t buf[131] = {0}; - uint8_t bytesprops0[] = {0xc0, 0x23, 0x9e, 0xdd, 0x9a, 0x5a, 0x81, 0xec, 0xeb}; - uint8_t bytesprops1[] = {0xd8}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xdb, 0xd7, 0x76, 0xf9, 0x62, 0xbf, 0xd0, 0x38, 0x48, 0xb5, 0xd, 0x49, 0x26, 0xd2}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xe, 0x4d, 0x55, 0xc3}; + uint8_t bytesprops3[] = {0xbb, 0x65, 0xe4, 0x82, 0xd4, 0x3e, 0x9b, 0xe6, 0x2c, 0x60, 0x35, 0x13, 0x9f, 0xb6, + 0xb1, 0x11, 0x8, 0x1b, 0x54, 0x87, 0x1d, 0x18, 0xef, 0x8, 0xb1, 0xcb, 0xf8}; + uint8_t bytesprops2[] = {0x30, 0x20, 0x22, 0xe5, 0x9b, 0xab, 0x61, 0xe2, 0xd7, 0x18, 0xdb, + 0x87, 0xd4, 0xaf, 0x50, 0xca, 0xac, 0xb3, 0xfb, 0x27, 0x71}; + uint8_t bytesprops4[] = {0x49, 0xed, 0x1f, 0x4e, 0x83, 0xee, 0x43, 0xb1, 0x43}; + uint8_t bytesprops5[] = {0x78, 0x72, 0x82, 0x61, 0xb, 0xf4, 0xb4, 0x71, 0x2a, + 0x2b, 0xc8, 0xd1, 0x9f, 0xce, 0xbc, 0xf4, 0x94, 0x5b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27548}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15984}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9648}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {27, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops5}}}, }; lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\165r\DEL\n\202\133kb\136", -// _pubPktID = 7921, _pubBody = "O\248\206?\215\168\&4\DC1\131\187<1\176\200\EOTW \FSu\ETB3\128\222N\241\193\180", -// _pubProps = [PropCorrelationData -// "\230\STX\158\128\DC1\131or\DC3\252\217\177\229\&1\166\252w\EOT*\US",PropServerKeepAlive 21189,PropAuthenticationData -// "H\135\248\221\220@\NUL\229\RS\153\224",PropAuthenticationMethod -// "\135\ESC\251\189<\EM\"(b\158\211\250\ETXX",PropSubscriptionIdentifier 12,PropRetainAvailable -// 59,PropTopicAliasMaximum 27318,PropServerKeepAlive 18157,PropCorrelationData "~\254\CAN\SYN",PropCorrelationData -// "v\137\254\DC2\200a",PropWillDelayInterval 19675,PropResponseInformation -// "P\190\205z'E\151/\229]8,\215\244\&9e}F_",PropWillDelayInterval 4361]} -TEST(Publish5QCTest, Encode45) { - uint8_t pkt[] = {0x3c, 0x9c, 0x1, 0x0, 0x9, 0xa5, 0x72, 0x7f, 0xa, 0xca, 0x85, 0x6b, 0x62, 0x88, 0x1e, 0xf1, - 0x73, 0x9, 0x0, 0x14, 0xe6, 0x2, 0x9e, 0x80, 0x11, 0x83, 0x6f, 0x72, 0x13, 0xfc, 0xd9, 0xb1, - 0xe5, 0x31, 0xa6, 0xfc, 0x77, 0x4, 0x2a, 0x1f, 0x13, 0x52, 0xc5, 0x16, 0x0, 0xb, 0x48, 0x87, - 0xf8, 0xdd, 0xdc, 0x40, 0x0, 0xe5, 0x1e, 0x99, 0xe0, 0x15, 0x0, 0xe, 0x87, 0x1b, 0xfb, 0xbd, - 0x3c, 0x19, 0x22, 0x28, 0x62, 0x9e, 0xd3, 0xfa, 0x3, 0x58, 0xb, 0xc, 0x25, 0x3b, 0x22, 0x6a, - 0xb6, 0x13, 0x46, 0xed, 0x9, 0x0, 0x4, 0x7e, 0xfe, 0x18, 0x16, 0x9, 0x0, 0x6, 0x76, 0x89, - 0xfe, 0x12, 0xc8, 0x61, 0x18, 0x0, 0x0, 0x4c, 0xdb, 0x1a, 0x0, 0x13, 0x50, 0xbe, 0xcd, 0x7a, - 0x27, 0x45, 0x97, 0x2f, 0xe5, 0x5d, 0x38, 0x2c, 0xd7, 0xf4, 0x39, 0x65, 0x7d, 0x46, 0x5f, 0x18, - 0x0, 0x0, 0x11, 0x9, 0x4f, 0xf8, 0xce, 0x3f, 0xd7, 0xa8, 0x34, 0x11, 0x83, 0xbb, 0x3c, 0x31, - 0xb0, 0xc8, 0x4, 0x57, 0x20, 0x1c, 0x75, 0x17, 0x33, 0x80, 0xde, 0x4e, 0xf1, 0xc1, 0xb4}; - - uint8_t buf[169] = {0}; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14676, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 2406 +// [("\154wi\237\149\207\222\244\234fa?\209A\DEL\205\221\&5\DLE\224@\211\160\208\239\&0\134\SO\NUL",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("L|I\231\128\172e\STX@\198x",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("Sa \169\184R\183\199\225\251\153%v6\228H\"\244J\193",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(";\"\b\143\221\r",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\210\147\237\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\141\237\229\157\173\ETXX/\224\174,\\\236\228",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\219\SOH\f)\241\252",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] +// [PropMaximumPacketSize 29740,PropRequestResponseInformation 178,PropMessageExpiryInterval 17484,PropMaximumQoS +// 17,PropMaximumPacketSize 22624,PropSessionExpiryInterval 7138,PropResponseTopic +// "\180\242\156{\131p\177\222",PropResponseInformation +// "\139\227\221\&7\213\177'78/\186\215\133\GS\155\\Jy\143\a\217\239\181\247=~\NUL,j",PropSessionExpiryInterval +// 22972,PropWillDelayInterval 18526,PropReceiveMaximum 11707,PropReasonString "\157\147)\155)\USKX\185}|\DELt"] +TEST(Subscribe5QCTest, Encode46) { + uint8_t pkt[] = {0x82, 0xd2, 0x1, 0x9, 0x66, 0x60, 0x27, 0x0, 0x0, 0x74, 0x2c, 0x19, 0xb2, 0x2, 0x0, 0x0, 0x44, + 0x4c, 0x24, 0x11, 0x27, 0x0, 0x0, 0x58, 0x60, 0x11, 0x0, 0x0, 0x1b, 0xe2, 0x8, 0x0, 0x8, 0xb4, + 0xf2, 0x9c, 0x7b, 0x83, 0x70, 0xb1, 0xde, 0x1a, 0x0, 0x1d, 0x8b, 0xe3, 0xdd, 0x37, 0xd5, 0xb1, 0x27, + 0x37, 0x38, 0x2f, 0xba, 0xd7, 0x85, 0x1d, 0x9b, 0x5c, 0x4a, 0x79, 0x8f, 0x7, 0xd9, 0xef, 0xb5, 0xf7, + 0x3d, 0x7e, 0x0, 0x2c, 0x6a, 0x11, 0x0, 0x0, 0x59, 0xbc, 0x18, 0x0, 0x0, 0x48, 0x5e, 0x21, 0x2d, + 0xbb, 0x1f, 0x0, 0xd, 0x9d, 0x93, 0x29, 0x9b, 0x29, 0x1f, 0x4b, 0x58, 0xb9, 0x7d, 0x7c, 0x7f, 0x74, + 0x0, 0x1d, 0x9a, 0x77, 0x69, 0xed, 0x95, 0xcf, 0xde, 0xf4, 0xea, 0x66, 0x61, 0x3f, 0xd1, 0x41, 0x7f, + 0xcd, 0xdd, 0x35, 0x10, 0xe0, 0x40, 0xd3, 0xa0, 0xd0, 0xef, 0x30, 0x86, 0xe, 0x0, 0x0, 0x0, 0xb, + 0x4c, 0x7c, 0x49, 0xe7, 0x80, 0xac, 0x65, 0x2, 0x40, 0xc6, 0x78, 0x0, 0x0, 0x14, 0x53, 0x61, 0x20, + 0xa9, 0xb8, 0x52, 0xb7, 0xc7, 0xe1, 0xfb, 0x99, 0x25, 0x76, 0x36, 0xe4, 0x48, 0x22, 0xf4, 0x4a, 0xc1, + 0x0, 0x0, 0x6, 0x3b, 0x22, 0x8, 0x8f, 0xdd, 0xd, 0x0, 0x0, 0x4, 0xd2, 0x93, 0xed, 0x19, 0x2, + 0x0, 0xe, 0x8d, 0xed, 0xe5, 0x9d, 0xad, 0x3, 0x58, 0x2f, 0xe0, 0xae, 0x2c, 0x5c, 0xec, 0xe4, 0x2, + 0x0, 0x6, 0xdb, 0x1, 0xc, 0x29, 0xf1, 0xfc, 0x1}; - uint8_t topic_bytes[] = {0xa5, 0x72, 0x7f, 0xa, 0xca, 0x85, 0x6b, 0x62, 0x88}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x4f, 0xf8, 0xce, 0x3f, 0xd7, 0xa8, 0x34, 0x11, 0x83, 0xbb, 0x3c, 0x31, 0xb0, 0xc8, - 0x4, 0x57, 0x20, 0x1c, 0x75, 0x17, 0x33, 0x80, 0xde, 0x4e, 0xf1, 0xc1, 0xb4}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + uint8_t buf[223] = {0}; - uint8_t bytesprops0[] = {0xe6, 0x2, 0x9e, 0x80, 0x11, 0x83, 0x6f, 0x72, 0x13, 0xfc, - 0xd9, 0xb1, 0xe5, 0x31, 0xa6, 0xfc, 0x77, 0x4, 0x2a, 0x1f}; - uint8_t bytesprops1[] = {0x48, 0x87, 0xf8, 0xdd, 0xdc, 0x40, 0x0, 0xe5, 0x1e, 0x99, 0xe0}; - uint8_t bytesprops2[] = {0x87, 0x1b, 0xfb, 0xbd, 0x3c, 0x19, 0x22, 0x28, 0x62, 0x9e, 0xd3, 0xfa, 0x3, 0x58}; - uint8_t bytesprops3[] = {0x7e, 0xfe, 0x18, 0x16}; - uint8_t bytesprops4[] = {0x76, 0x89, 0xfe, 0x12, 0xc8, 0x61}; - uint8_t bytesprops5[] = {0x50, 0xbe, 0xcd, 0x7a, 0x27, 0x45, 0x97, 0x2f, 0xe5, 0x5d, - 0x38, 0x2c, 0xd7, 0xf4, 0x39, 0x65, 0x7d, 0x46, 0x5f}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x9a, 0x77, 0x69, 0xed, 0x95, 0xcf, 0xde, 0xf4, 0xea, 0x66, + 0x61, 0x3f, 0xd1, 0x41, 0x7f, 0xcd, 0xdd, 0x35, 0x10, 0xe0, + 0x40, 0xd3, 0xa0, 0xd0, 0xef, 0x30, 0x86, 0xe, 0x0}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x4c, 0x7c, 0x49, 0xe7, 0x80, 0xac, 0x65, 0x2, 0x40, 0xc6, 0x78}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x53, 0x61, 0x20, 0xa9, 0xb8, 0x52, 0xb7, 0xc7, 0xe1, 0xfb, + 0x99, 0x25, 0x76, 0x36, 0xe4, 0x48, 0x22, 0xf4, 0x4a, 0xc1}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x3b, 0x22, 0x8, 0x8f, 0xdd, 0xd}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd2, 0x93, 0xed, 0x19}; + lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8d, 0xed, 0xe5, 0x9d, 0xad, 0x3, 0x58, 0x2f, 0xe0, 0xae, 0x2c, 0x5c, 0xec, 0xe4}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xdb, 0x1, 0xc, 0x29, 0xf1, 0xfc}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xb4, 0xf2, 0x9c, 0x7b, 0x83, 0x70, 0xb1, 0xde}; + uint8_t bytesprops1[] = {0x8b, 0xe3, 0xdd, 0x37, 0xd5, 0xb1, 0x27, 0x37, 0x38, 0x2f, 0xba, 0xd7, 0x85, 0x1d, 0x9b, + 0x5c, 0x4a, 0x79, 0x8f, 0x7, 0xd9, 0xef, 0xb5, 0xf7, 0x3d, 0x7e, 0x0, 0x2c, 0x6a}; + uint8_t bytesprops2[] = {0x9d, 0x93, 0x29, 0x9b, 0x29, 0x1f, 0x4b, 0x58, 0xb9, 0x7d, 0x7c, 0x7f, 0x74}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21189}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27318}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18157}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19675}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4361}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29740}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17484}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22624}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7138}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22972}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18526}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11707}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7921, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2406, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 4955 [("\ENQ\139D6\149b\234\144\205\249k\207\248\b5\137\DC1\211*i\214\212Z\197\232\EM",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\193\&7\178\197`\133\195'\217\NAK\245\130i",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\vU\DEL\193\165\247\239O\244\220",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] +// [PropCorrelationData "K",PropResponseInformation "\130\207\148~\RS[c",PropTopicAliasMaximum +// 13446,PropRequestResponseInformation 118,PropCorrelationData +// "\254\148Ng\143$\CANm\189x]J\242\175\211\183\SI5\242\227U\214o\NUL\245I\150\173 +// j",PropSubscriptionIdentifierAvailable 163,PropRetainAvailable 40,PropMaximumQoS 150,PropContentType +// "\143\159h<\131*3\130\129\184\DC4\221,\141\254\139\ETX\235\131'x\187\158\EOT\157\219L\186\146\243",PropServerReference +// "\196s\218\CAN\217\SYNq\199\&8",PropAuthenticationData "P\151\251\167<.R\228\ETB\NAK\DLE",PropContentType +// "\156\173\156\174\161\138RF1\184y-3",PropResponseTopic +// "Z\241\196\229\168b\ESC[[0\"\185\192\t\225\&3SY\DEL",PropWildcardSubscriptionAvailable +// 75,PropWildcardSubscriptionAvailable 2,PropSessionExpiryInterval 28657,PropMaximumPacketSize +// 15747,PropSubscriptionIdentifierAvailable 219,PropServerReference +// "\193~UU\191a#\254\&8\196\236\181,i\136\217\202\161\231\144\160",PropSubscriptionIdentifier 6,PropServerKeepAlive +// 25297,PropSharedSubscriptionAvailable 104,PropRetainAvailable 181,PropSessionExpiryInterval 15689,PropCorrelationData +// "\151\144\230\192\241\&4\163tL\164e\179\210\178\232\v\ACK\242\151\173\191(\SYN'\221\181\202h",PropMaximumQoS +// 43,PropRequestResponseInformation 10] +TEST(Subscribe5QCTest, Encode47) { + uint8_t pkt[] = { + 0x82, 0xb2, 0x2, 0x13, 0x5b, 0xf4, 0x1, 0x9, 0x0, 0x1, 0x4b, 0x1a, 0x0, 0x7, 0x82, 0xcf, 0x94, 0x7e, 0x1e, + 0x5b, 0x63, 0x22, 0x34, 0x86, 0x19, 0x76, 0x9, 0x0, 0x1e, 0xfe, 0x94, 0x4e, 0x67, 0x8f, 0x24, 0x18, 0x6d, 0xbd, + 0x78, 0x5d, 0x4a, 0xf2, 0xaf, 0xd3, 0xb7, 0xf, 0x35, 0xf2, 0xe3, 0x55, 0xd6, 0x6f, 0x0, 0xf5, 0x49, 0x96, 0xad, + 0x20, 0x6a, 0x29, 0xa3, 0x25, 0x28, 0x24, 0x96, 0x3, 0x0, 0x1e, 0x8f, 0x9f, 0x68, 0x3c, 0x83, 0x2a, 0x33, 0x82, + 0x81, 0xb8, 0x14,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f8, + 0x8, 0x35, 0x89, 0x11, 0xd3, 0x2a, 0x69, 0xd6, 0xd4, 0x5a, 0xc5, 0xe8, 0x19, 0x0, 0x0, 0xd, 0xc1, 0x37, 0xb2, + 0xc5, 0x60, 0x85, 0xc3, 0x27, 0xd9, 0x15, 0xf5, 0x82, 0x69, 0x1, 0x0, 0xa, 0xb, 0x55, 0x7f, 0xc1, 0xa5, 0xf7, + 0xef, 0x4f, 0xf4, 0xdc, 0x1}; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\228\161\&1\220\142H\211q3\179%~Q\148", _pubPktID = 29868, _pubBody = "nP\243G", _pubProps = [PropMaximumQoS -// 80,PropRequestResponseInformation 5,PropTopicAliasMaximum 5247,PropAssignedClientIdentifier -// "?\ESC\SOP\ETB",PropAuthenticationMethod -// "\200F7\169sZ\200\254\158/R\203\134O\206\STX\218\ACK\245",PropSharedSubscriptionAvailable 68,PropRetainAvailable 26]} -TEST(Publish5QCTest, Encode46) { - uint8_t pkt[] = {0x33, 0x40, 0x0, 0xe, 0xe4, 0xa1, 0x31, 0xdc, 0x8e, 0x48, 0xd3, 0x71, 0x33, 0xb3, 0x25, 0x7e, 0x51, - 0x94, 0x74, 0xac, 0x29, 0x24, 0x50, 0x19, 0x5, 0x22, 0x14, 0x7f, 0x12, 0x0, 0x5, 0x3f, 0x1b, 0xe, - 0x50, 0x17, 0x15, 0x0, 0x13, 0xc8, 0x46, 0x37, 0xa9, 0x73, 0x5a, 0xc8, 0xfe, 0x9e, 0x2f, 0x52, 0xcb, - 0x86, 0x4f, 0xce, 0x2, 0xda, 0x6, 0xf5, 0x2a, 0x44, 0x25, 0x1a, 0x6e, 0x50, 0xf3, 0x47}; + uint8_t buf[319] = {0}; - uint8_t buf[76] = {0}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x5, 0x8b, 0x44, 0x36, 0x95, 0x62, 0xea, 0x90, 0xcd, 0xf9, 0x6b, 0xcf, 0xf8, + 0x8, 0x35, 0x89, 0x11, 0xd3, 0x2a, 0x69, 0xd6, 0xd4, 0x5a, 0xc5, 0xe8, 0x19}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc1, 0x37, 0xb2, 0xc5, 0x60, 0x85, 0xc3, 0x27, 0xd9, 0x15, 0xf5, 0x82, 0x69}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb, 0x55, 0x7f, 0xc1, 0xa5, 0xf7, 0xef, 0x4f, 0xf4, 0xdc}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x4b}; + uint8_t bytesprops1[] = {0x82, 0xcf, 0x94, 0x7e, 0x1e, 0x5b, 0x63}; + uint8_t bytesprops2[] = {0xfe, 0x94, 0x4e, 0x67, 0x8f, 0x24, 0x18, 0x6d, 0xbd, 0x78, 0x5d, 0x4a, 0xf2, 0xaf, 0xd3, + 0xb7, 0xf, 0x35, 0xf2, 0xe3, 0x55, 0xd6, 0x6f, 0x0, 0xf5, 0x49, 0x96, 0xad, 0x20, 0x6a}; + uint8_t bytesprops3[] = {0x8f, 0x9f, 0x68, 0x3c, 0x83, 0x2a, 0x33, 0x82, 0x81, 0xb8, 0x14, 0xdd, 0x2c, 0x8d, 0xfe, + 0x8b, 0x3, 0xeb, 0x83, 0x27, 0x78, 0xbb, 0x9e, 0x4, 0x9d, 0xdb, 0x4c, 0xba, 0x92, 0xf3}; + uint8_t bytesprops4[] = {0xc4, 0x73, 0xda, 0x18, 0xd9, 0x16, 0x71, 0xc7, 0x38}; + uint8_t bytesprops5[] = {0x50, 0x97, 0xfb, 0xa7, 0x3c, 0x2e, 0x52, 0xe4, 0x17, 0x15, 0x10}; + uint8_t bytesprops6[] = {0x9c, 0xad, 0x9c, 0xae, 0xa1, 0x8a, 0x52, 0x46, 0x31, 0xb8, 0x79, 0x2d, 0x33}; + uint8_t bytesprops7[] = {0x5a, 0xf1, 0xc4, 0xe5, 0xa8, 0x62, 0x1b, 0x5b, 0x5b, 0x30, + 0x22, 0xb9, 0xc0, 0x9, 0xe1, 0x33, 0x53, 0x59, 0x7f}; + uint8_t bytesprops8[] = {0xc1, 0x7e, 0x55, 0x55, 0xbf, 0x61, 0x23, 0xfe, 0x38, 0xc4, 0xec, + 0xb5, 0x2c, 0x69, 0x88, 0xd9, 0xca, 0xa1, 0xe7, 0x90, 0xa0}; + uint8_t bytesprops9[] = {0x97, 0x90, 0xe6, 0xc0, 0xf1, 0x34, 0xa3, 0x74, 0x4c, 0xa4, 0x65, 0xb3, 0xd2, 0xb2, + 0xe8, 0xb, 0x6, 0xf2, 0x97, 0xad, 0xbf, 0x28, 0x16, 0x27, 0xdd, 0xb5, 0xca, 0x68}; - uint8_t topic_bytes[] = {0xe4, 0xa1, 0x31, 0xdc, 0x8e, 0x48, 0xd3, 0x71, 0x33, 0xb3, 0x25, 0x7e, 0x51, 0x94}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x6e, 0x50, 0xf3, 0x47}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13446}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28657}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15747}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25297}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15689}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 10}}, + }; - uint8_t bytesprops0[] = {0x3f, 0x1b, 0xe, 0x50, 0x17}; - uint8_t bytesprops1[] = {0xc8, 0x46, 0x37, 0xa9, 0x73, 0x5a, 0xc8, 0xfe, 0x9e, 0x2f, - 0x52, 0xcb, 0x86, 0x4f, 0xce, 0x2, 0xda, 0x6, 0xf5}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4955, 3, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 11203 [("\204\DC2P\234<\186\CANVS(\203F\SO\243\v\199\215\190\165-j\243",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\131\130\210u\174\253S\151\142FR\139\135\186\209\232\170\138\156\&1\NAKf\158E\186\167",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("#\151\&7\NULk\190\232\&6\DEL\DC4H\212\161\&6:\225",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\198\255$N$\183E\246\148\&8\242:\214\128\&2\178\149v/\140",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("O:\185)_;T{\187\198[\166&\148\153\147\203\\YB+Z\169fv\133\rL",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\182\ESC\138\244\250D\150\219B\SI\149\ENQ\172]i\166&\153\190~\228\193>\209",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\143\&6\\:",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] +// [PropTopicAliasMaximum 5455,PropResponseTopic "\187\253\SUB\196\DC2",PropSubscriptionIdentifierAvailable +// 243,PropRequestProblemInformation 201,PropAuthenticationData +// "\161\182\235/\188\SYN\134\204\193\157\DC4\216",PropRequestProblemInformation 193,PropRetainAvailable +// 208,PropWillDelayInterval 24782,PropMessageExpiryInterval 9486,PropSharedSubscriptionAvailable 185,PropContentType +// "\230\200i\248\225\227\227\207\153\DC3\225<+'\f\154\174\133b\185\189A\205)\197\226l\168",PropMessageExpiryInterval +// 16144,PropSharedSubscriptionAvailable 132,PropWildcardSubscriptionAvailable 11,PropTopicAlias +// 24962,PropCorrelationData "\240='\222\206\181\SOHN\175\&0x",PropSubscriptionIdentifierAvailable 86] +TEST(Subscribe5QCTest, Encode48) { + uint8_t pkt[] = {0x82, 0x8d, 0x2, 0x2b, 0xc3, 0x69, 0x22, 0x15, 0x4f, 0x8, 0x0, 0x5, 0xbb, 0xfd, 0x1a, 0xc4, 0x12, + 0x29, 0xf3, 0x17, 0xc9, 0x16, 0x0, 0xc, 0xa1, 0xb6, 0xeb, 0x2f, 0xbc, 0x16, 0x86, 0xcc, 0xc1, 0x9d, + 0x14, 0xd8, 0x17, 0xc1, 0x25, 0xd0, 0x18, 0x0, 0x0, 0x60, 0xce, 0x2, 0x0, 0x0, 0x25, 0xe, 0x2a, + 0xb9, 0x3, 0x0, 0x1c, 0xe6, 0xc8, 0x69, 0xf8, 0xe1, 0xe3, 0xe3, 0xcf, 0x99, 0x13, 0xe1, 0x3c, 0x2b, + 0x27, 0xc, 0x9a, 0xae, 0x85, 0x62, 0xb9, 0xbd, 0x41, 0xcd, 0x29, 0xc5, 0xe2, 0x6c, 0xa8, 0x2, 0x0, + 0x0, 0x3f, 0x10, 0x2a, 0x84, 0x28, 0xb, 0x23, 0x61, 0x82, 0x9, 0x0, 0xb, 0xf0, 0x3d, 0x27, 0xde, + 0xce, 0xb5, 0x1, 0x4e, 0xaf, 0x30, 0x78, 0x29, 0x56, 0x0, 0x16, 0xcc, 0x12, 0x50, 0xea, 0x3c, 0xba, + 0x18, 0x56, 0x53, 0x28, 0xcb, 0x46, 0xe, 0xf3, 0xb, 0xc7, 0xd7, 0xbe, 0xa5, 0x2d, 0x6a, 0xf3, 0x0, + 0x0, 0x1a, 0x83, 0x82, 0xd2, 0x75, 0xae, 0xfd, 0x53, 0x97, 0x8e, 0x46, 0x52, 0x8b, 0x87, 0xba, 0xd1, + 0xe8, 0xaa, 0x8a, 0x9c, 0x31, 0x15, 0x66, 0x9e, 0x45, 0xba, 0xa7, 0x2, 0x0, 0x10, 0x23, 0x97, 0x37, + 0x0, 0x6b, 0xbe, 0xe8, 0x36, 0x7f, 0x14, 0x48, 0xd4, 0xa1, 0x36, 0x3a, 0xe1, 0x0, 0x0, 0x14, 0xc6, + 0xff, 0x24, 0x4e, 0x24, 0xb7, 0x45, 0xf6, 0x94, 0x38, 0xf2, 0x3a, 0xd6, 0x80, 0x32, 0xb2, 0x95, 0x76, + 0x2f, 0x8c, 0x0, 0x0, 0x1c, 0x4f, 0x3a, 0xb9, 0x29, 0x5f, 0x3b, 0x54, 0x7b, 0xbb, 0xc6, 0x5b, 0xa6, + 0x26, 0x94, 0x99, 0x93, 0xcb, 0x5c, 0x59, 0x42, 0x2b, 0x5a, 0xa9, 0x66, 0x76, 0x85, 0xd, 0x4c, 0x0, + 0x0, 0x18, 0xb6, 0x1b, 0x8a, 0xf4, 0xfa, 0x44, 0x96, 0xdb, 0x42, 0xf, 0x95, 0x5, 0xac, 0x5d, 0x69, + 0xa6, 0x26, 0x99, 0xbe, 0x7e, 0xe4, 0xc1, 0x3e, 0xd1, 0x1, 0x0, 0x4, 0x8f, 0x36, 0x5c, 0x3a, 0x1}; + + uint8_t buf[282] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xcc, 0x12, 0x50, 0xea, 0x3c, 0xba, 0x18, 0x56, 0x53, 0x28, 0xcb, + 0x46, 0xe, 0xf3, 0xb, 0xc7, 0xd7, 0xbe, 0xa5, 0x2d, 0x6a, 0xf3}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x83, 0x82, 0xd2, 0x75, 0xae, 0xfd, 0x53, 0x97, 0x8e, 0x46, 0x52, 0x8b, 0x87, + 0xba, 0xd1, 0xe8, 0xaa, 0x8a, 0x9c, 0x31, 0x15, 0x66, 0x9e, 0x45, 0xba, 0xa7}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x23, 0x97, 0x37, 0x0, 0x6b, 0xbe, 0xe8, 0x36, + 0x7f, 0x14, 0x48, 0xd4, 0xa1, 0x36, 0x3a, 0xe1}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc6, 0xff, 0x24, 0x4e, 0x24, 0xb7, 0x45, 0xf6, 0x94, 0x38, + 0xf2, 0x3a, 0xd6, 0x80, 0x32, 0xb2, 0x95, 0x76, 0x2f, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x4f, 0x3a, 0xb9, 0x29, 0x5f, 0x3b, 0x54, 0x7b, 0xbb, 0xc6, + 0x5b, 0xa6, 0x26, 0x94, 0x99, 0x93, 0xcb, 0x5c, 0x59, 0x42, + 0x2b, 0x5a, 0xa9, 0x66, 0x76, 0x85, 0xd, 0x4c}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb6, 0x1b, 0x8a, 0xf4, 0xfa, 0x44, 0x96, 0xdb, 0x42, 0xf, 0x95, 0x5, + 0xac, 0x5d, 0x69, 0xa6, 0x26, 0x99, 0xbe, 0x7e, 0xe4, 0xc1, 0x3e, 0xd1}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8f, 0x36, 0x5c, 0x3a}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xbb, 0xfd, 0x1a, 0xc4, 0x12}; + uint8_t bytesprops1[] = {0xa1, 0xb6, 0xeb, 0x2f, 0xbc, 0x16, 0x86, 0xcc, 0xc1, 0x9d, 0x14, 0xd8}; + uint8_t bytesprops2[] = {0xe6, 0xc8, 0x69, 0xf8, 0xe1, 0xe3, 0xe3, 0xcf, 0x99, 0x13, 0xe1, 0x3c, 0x2b, 0x27, + 0xc, 0x9a, 0xae, 0x85, 0x62, 0xb9, 0xbd, 0x41, 0xcd, 0x29, 0xc5, 0xe2, 0x6c, 0xa8}; + uint8_t bytesprops3[] = {0xf0, 0x3d, 0x27, 0xde, 0xce, 0xb5, 0x1, 0x4e, 0xaf, 0x30, 0x78}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5247}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5455}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24782}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9486}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16144}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24962}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 86}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29868, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11203, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\NUL\211nNzt\150\194r\182+\179\199\146", _pubPktID = 0, _pubBody = -// "]8\167\v\179vF\250\130{$\169\150w^\190QS]U\227C\205\189\179[\ENQ\131\SUB\200", _pubProps = [PropContentType -// "\242q\192\128\132ia{",PropRetainAvailable 127,PropRequestResponseInformation 135,PropReasonString -// "",PropResponseInformation "\185oz7|\184\129\146",PropServerKeepAlive 7156,PropRequestProblemInformation -// 81,PropMaximumQoS 92,PropPayloadFormatIndicator 243,PropMessageExpiryInterval 16726,PropRequestResponseInformation -// 54,PropResponseTopic "\199UC\206\132\STX\130\&47z\147",PropSubscriptionIdentifierAvailable -// 238,PropWildcardSubscriptionAvailable 239,PropServerKeepAlive 1245,PropSubscriptionIdentifierAvailable -// 57,PropAuthenticationData "\218\245\DC3\r\167\241n8xP\250\207v,;\169\&5n\r"]} -TEST(Publish5QCTest, Encode47) { - uint8_t pkt[] = {0x38, 0x89, 0x1, 0x0, 0xe, 0x0, 0xd3, 0x6e, 0x4e, 0x7a, 0x74, 0x96, 0xc2, 0x72, 0xb6, 0x2b, - 0xb3, 0xc7, 0x92, 0x5a, 0x3, 0x0, 0x8, 0xf2, 0x71, 0xc0, 0x80, 0x84, 0x69, 0x61, 0x7b, 0x25, - 0x7f, 0x19, 0x87, 0x1f, 0x0, 0x0, 0x1a, 0x0, 0x8, 0xb9, 0x6f, 0x7a, 0x37, 0x7c, 0xb8, 0x81, - 0x92, 0x13, 0x1b, 0xf4, 0x17, 0x51, 0x24, 0x5c, 0x1, 0xf3, 0x2, 0x0, 0x0, 0x41, 0x56, 0x19, - 0x36, 0x8, 0x0, 0xb, 0xc7, 0x55, 0x43, 0xce, 0x84, 0x2, 0x82, 0x34, 0x37, 0x7a, 0x93, 0x29, - 0xee, 0x28, 0xef, 0x13, 0x4, 0xdd, 0x29, 0x39, 0x16, 0x0, 0x13, 0xda, 0xf5, 0x13, 0xd, 0xa7, - 0xf1, 0x6e, 0x38, 0x78, 0x50, 0xfa, 0xcf, 0x76, 0x2c, 0x3b, 0xa9, 0x35, 0x6e, 0xd, 0x5d, 0x38, - 0xa7, 0xb, 0xb3, 0x76, 0x46, 0xfa, 0x82, 0x7b, 0x24, 0xa9, 0x96, 0x77, 0x5e, 0xbe, 0x51, 0x53, - 0x5d, 0x55, 0xe3, 0x43, 0xcd, 0xbd, 0xb3, 0x5b, 0x5, 0x83, 0x1a, 0xc8}; +// SubscribeRequest 30275 [("\NAK\ENQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [PropServerKeepAlive 25108,PropMessageExpiryInterval 5293,PropResponseInformation +// "\132C\ACK>\207\166\158\244\153 \161\STX\246\192\246\254]H\FS!\219\&5\199\ETX~\135\195",PropTopicAliasMaximum +// 17913,PropAuthenticationData "\131\191\164\132\ETB\154\243`%\240",PropReceiveMaximum 28062,PropTopicAliasMaximum +// 15030] +TEST(Subscribe5QCTest, Encode49) { + uint8_t pkt[] = {0x82, 0x44, 0x76, 0x43, 0x3c, 0x13, 0x62, 0x14, 0x2, 0x0, 0x0, 0x14, 0xad, 0x1a, + 0x0, 0x1b, 0x84, 0x43, 0x6, 0x3e, 0xcf, 0xa6, 0x9e, 0xf4, 0x99, 0x20, 0xa1, 0x2, + 0xf6, 0xc0, 0xf6, 0xfe, 0x5d, 0x48, 0x1c, 0x21, 0xdb, 0x35, 0xc7, 0x3, 0x7e, 0x87, + 0xc3, 0x22, 0x45, 0xf9, 0x16, 0x0, 0xa, 0x83, 0xbf, 0xa4, 0x84, 0x17, 0x9a, 0xf3, + 0x60, 0x25, 0xf0, 0x21, 0x6d, 0x9e, 0x22, 0x3a, 0xb6, 0x0, 0x2, 0x15, 0x5, 0x2}; - uint8_t buf[150] = {0}; - - uint8_t topic_bytes[] = {0x0, 0xd3, 0x6e, 0x4e, 0x7a, 0x74, 0x96, 0xc2, 0x72, 0xb6, 0x2b, 0xb3, 0xc7, 0x92}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x5d, 0x38, 0xa7, 0xb, 0xb3, 0x76, 0x46, 0xfa, 0x82, 0x7b, 0x24, 0xa9, 0x96, 0x77, 0x5e, - 0xbe, 0x51, 0x53, 0x5d, 0x55, 0xe3, 0x43, 0xcd, 0xbd, 0xb3, 0x5b, 0x5, 0x83, 0x1a, 0xc8}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + uint8_t buf[80] = {0}; - uint8_t bytesprops0[] = {0xf2, 0x71, 0xc0, 0x80, 0x84, 0x69, 0x61, 0x7b}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0xb9, 0x6f, 0x7a, 0x37, 0x7c, 0xb8, 0x81, 0x92}; - uint8_t bytesprops3[] = {0xc7, 0x55, 0x43, 0xce, 0x84, 0x2, 0x82, 0x34, 0x37, 0x7a, 0x93}; - uint8_t bytesprops4[] = {0xda, 0xf5, 0x13, 0xd, 0xa7, 0xf1, 0x6e, 0x38, 0x78, 0x50, - 0xfa, 0xcf, 0x76, 0x2c, 0x3b, 0xa9, 0x35, 0x6e, 0xd}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x15, 0x5}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x84, 0x43, 0x6, 0x3e, 0xcf, 0xa6, 0x9e, 0xf4, 0x99, 0x20, 0xa1, 0x2, 0xf6, 0xc0, + 0xf6, 0xfe, 0x5d, 0x48, 0x1c, 0x21, 0xdb, 0x35, 0xc7, 0x3, 0x7e, 0x87, 0xc3}; + uint8_t bytesprops1[] = {0x83, 0xbf, 0xa4, 0x84, 0x17, 0x9a, 0xf3, 0x60, 0x25, 0xf0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7156}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16726}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1245}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25108}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5293}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17913}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28062}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15030}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30275, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "'\245\224\138\229\155\&6\241\GS\"t\ETX5%4?\146\ETB", _pubPktID = 0, _pubBody = "\SUB)\222", _pubProps = -// [PropWildcardSubscriptionAvailable 255,PropSessionExpiryInterval 647,PropRequestResponseInformation -// 228,PropTopicAliasMaximum 30065,PropAssignedClientIdentifier -// "\250_\139\fO\183\233\217\212\218~\194,p\159\&5\226\198\145\DC1\131]",PropWillDelayInterval 18202,PropMaximumQoS -// 132,PropUserProperty "\197WY\US\250\217\138\GSy\ACKa@\240R\RS\ETX\182\195t\175G\161\GS\151\r\185\151\216\247" -// "&tr\176\249\201\233\RS\DLE\209\239\194*\148",PropAuthenticationMethod "\161",PropReceiveMaximum -// 12170,PropAssignedClientIdentifier "H\168\154\242j{\n\128{\"v",PropTopicAliasMaximum 18145,PropResponseTopic -// "\148\129q\206\189\205\191\254\150.\247\STX\142\151\162d>\141\228\SOH\181\"\178\ACK\248\136E\181\US",PropServerKeepAlive -// 29047,PropServerKeepAlive 21427,PropContentType "\246\\\183\&6gu\251\ETBq\151\165[c",PropSubscriptionIdentifier -// 23,PropTopicAliasMaximum 24626,PropPayloadFormatIndicator 144,PropResponseInformation -// "\DC1\143/\171\ETB\202\r+\238\254#\206G\138\139\231h\177\210aB*\210m\252\239\236\152",PropRequestProblemInformation -// 26,PropAssignedClientIdentifier "\237\171\195\186\160H\223\131\128a:",PropAuthenticationData -// "\ESC\178\249\EOT\201\224\234C?\ESC\139\147k\174\158\STX\SUB6\193",PropPayloadFormatIndicator -// 18,PropSharedSubscriptionAvailable 65]} -TEST(Publish5QCTest, Encode48) { - uint8_t pkt[] = { - 0x39, 0x93, 0x2, 0x0, 0x12, 0x27, 0xf5, 0xe0, 0x8a, 0xe5, 0x9b, 0x36, 0xf1, 0x1d, 0x22, 0x74, 0x3, 0x35, 0x25, - 0x34, 0x3f, 0x92, 0x17, 0xfa, 0x1, 0x28, 0xff, 0x11, 0x0, 0x0, 0x2, 0x87, 0x19, 0xe4, 0x22, 0x75, 0x71, 0x12, - 0x0, 0x16, 0xfa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a, 0xd2, - 0x6d, 0xfc, 0xef, 0xec, 0x98, 0x17, 0x1a, 0x12, 0x0, 0xb, 0xed, 0xab, 0xc3, 0xba, 0xa0, 0x48, 0xdf, 0x83, 0x80, - 0x61, 0x3a, 0x16, 0x0, 0x13, 0x1b, 0xb2, 0xf9, 0x4, 0xc9, 0xe0, 0xea, 0x43, 0x3f, 0x1b, 0x8b, 0x93, 0x6b, 0xae, - 0x9e, 0x2, 0x1a, 0x36, 0xc1, 0x1, 0x12, 0x2a, 0x41, 0x1a, 0x29, 0xde}; +// SubscribeRequest 16095 [("\NAK;\166\150$",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("~U\133\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\187m\GS\SOH\205\135\128<\RS\242\204^T\DC1]\f'\v\166\151\218v\STX\FS\131>\NUL",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("n\134\188wS\138\128\229\&1w*\244&",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe5QCTest, Encode50) { + uint8_t pkt[] = {0x82, 0x40, 0x3e, 0xdf, 0x0, 0x0, 0x5, 0x15, 0x3b, 0xa6, 0x96, 0x24, 0x1, 0x0, 0x4, 0x7e, 0x55, + 0x85, 0x19, 0x1, 0x0, 0x1b, 0xbb, 0x6d, 0x1d, 0x1, 0xcd, 0x87, 0x80, 0x3c, 0x1e, 0xf2, 0xcc, 0x5e, + 0x54, 0x11, 0x5d, 0xc, 0x27, 0xb, 0xa6, 0x97, 0xda, 0x76, 0x2, 0x1c, 0x83, 0x3e, 0x0, 0x0, 0x0, + 0xd, 0x6e, 0x86, 0xbc, 0x77, 0x53, 0x8a, 0x80, 0xe5, 0x31, 0x77, 0x2a, 0xf4, 0x26, 0x2}; - uint8_t buf[288] = {0}; + uint8_t buf[76] = {0}; - uint8_t topic_bytes[] = {0x27, 0xf5, 0xe0, 0x8a, 0xe5, 0x9b, 0x36, 0xf1, 0x1d, - 0x22, 0x74, 0x3, 0x35, 0x25, 0x34, 0x3f, 0x92, 0x17}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x1a, 0x29, 0xde}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; - - uint8_t bytesprops0[] = {0xfa, 0x5f, 0x8b, 0xc, 0x4f, 0xb7, 0xe9, 0xd9, 0xd4, 0xda, 0x7e, - 0xc2, 0x2c, 0x70, 0x9f, 0x35, 0xe2, 0xc6, 0x91, 0x11, 0x83, 0x5d}; - uint8_t bytesprops2[] = {0x26, 0x74, 0x72, 0xb0, 0xf9, 0xc9, 0xe9, 0x1e, 0x10, 0xd1, 0xef, 0xc2, 0x2a, 0x94}; - uint8_t bytesprops1[] = {0xc5, 0x57, 0x59, 0x1f, 0xfa, 0xd9, 0x8a, 0x1d, 0x79, 0x6, 0x61, 0x40, 0xf0, 0x52, 0x1e, - 0x3, 0xb6, 0xc3, 0x74, 0xaf, 0x47, 0xa1, 0x1d, 0x97, 0xd, 0xb9, 0x97, 0xd8, 0xf7}; - uint8_t bytesprops3[] = {0xa1}; - uint8_t bytesprops4[] = {0x48, 0xa8, 0x9a, 0xf2, 0x6a, 0x7b, 0xa, 0x80, 0x7b, 0x22, 0x76}; - uint8_t bytesprops5[] = {0x94, 0x81, 0x71, 0xce, 0xbd, 0xcd, 0xbf, 0xfe, 0x96, 0x2e, 0xf7, 0x2, 0x8e, 0x97, 0xa2, - 0x64, 0x3e, 0x8d, 0xe4, 0x1, 0xb5, 0x22, 0xb2, 0x6, 0xf8, 0x88, 0x45, 0xb5, 0x1f}; - uint8_t bytesprops6[] = {0xf6, 0x5c, 0xb7, 0x36, 0x67, 0x75, 0xfb, 0x17, 0x71, 0x97, 0xa5, 0x5b, 0x63}; - uint8_t bytesprops7[] = {0x11, 0x8f, 0x2f, 0xab, 0x17, 0xca, 0xd, 0x2b, 0xee, 0xfe, 0x23, 0xce, 0x47, 0x8a, - 0x8b, 0xe7, 0x68, 0xb1, 0xd2, 0x61, 0x42, 0x2a, 0xd2, 0x6d, 0xfc, 0xef, 0xec, 0x98}; - uint8_t bytesprops8[] = {0xed, 0xab, 0xc3, 0xba, 0xa0, 0x48, 0xdf, 0x83, 0x80, 0x61, 0x3a}; - uint8_t bytesprops9[] = {0x1b, 0xb2, 0xf9, 0x4, 0xc9, 0xe0, 0xea, 0x43, 0x3f, 0x1b, - 0x8b, 0x93, 0x6b, 0xae, 0x9e, 0x2, 0x1a, 0x36, 0xc1}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x15, 0x3b, 0xa6, 0x96, 0x24}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7e, 0x55, 0x85, 0x19}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xbb, 0x6d, 0x1d, 0x1, 0xcd, 0x87, 0x80, 0x3c, 0x1e, 0xf2, 0xcc, 0x5e, 0x54, 0x11, + 0x5d, 0xc, 0x27, 0xb, 0xa6, 0x97, 0xda, 0x76, 0x2, 0x1c, 0x83, 0x3e, 0x0}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6e, 0x86, 0xbc, 0x77, 0x53, 0x8a, 0x80, 0xe5, 0x31, 0x77, 0x2a, 0xf4, 0x26}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 647}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30065}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18202}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {14, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12170}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18145}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29047}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21427}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24626}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 65}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16095, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\200Z\225i^_\STX\231\193\STX", -// _pubPktID = 16826, _pubBody = "\206\193\194\217\177\152\142,\163\145\149Q\237?7\131k\n\177[^\153ti\134sYl\140\174", -// _pubProps = [PropMaximumQoS 178,PropAuthenticationMethod "",PropSessionExpiryInterval 27303,PropMessageExpiryInterval -// 30007,PropWillDelayInterval 3447,PropMaximumQoS 79,PropCorrelationData "\228\150"]} -TEST(Publish5QCTest, Encode49) { - uint8_t pkt[] = {0x3d, 0x48, 0x0, 0xa, 0xc8, 0x5a, 0xe1, 0x69, 0x5e, 0x5f, 0x2, 0xe7, 0xc1, 0x2, 0x41, - 0xba, 0x1b, 0x24, 0xb2, 0x15, 0x0, 0x0, 0x11, 0x0, 0x0, 0x6a, 0xa7, 0x2, 0x0, 0x0, - 0x75, 0x37, 0x18, 0x0, 0x0, 0xd, 0x77, 0x24, 0x4f, 0x9, 0x0, 0x2, 0xe4, 0x96, 0xce, - 0xc1, 0xc2, 0xd9, 0xb1, 0x98, 0x8e, 0x2c, 0xa3, 0x91, 0x95, 0x51, 0xed, 0x3f, 0x37, 0x83, - 0x6b, 0xa, 0xb1, 0x5b, 0x5e, 0x99, 0x74, 0x69, 0x86, 0x73, 0x59, 0x6c, 0x8c, 0xae}; +// SubscribeRequest 27116 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1})] [PropWildcardSubscriptionAvailable 131,PropTopicAliasMaximum 17943,PropResponseTopic +// "\NAK\134\198\&7K\241^\149\187:T\161\191\226l%\145\178\164\178\188\230\227\159\v",PropSharedSubscriptionAvailable +// 187,PropReasonString "\156\"\EMl\255\242]\GSy\223",PropRequestResponseInformation +// 144,PropSubscriptionIdentifierAvailable 48,PropContentType "\142\170\147!\223",PropMaximumPacketSize 32259] +TEST(Subscribe5QCTest, Encode51) { + uint8_t pkt[] = {0x82, 0x47, 0x69, 0xec, 0x41, 0x28, 0x83, 0x22, 0x46, 0x17, 0x8, 0x0, 0x19, 0x15, 0x86, + 0xc6, 0x37, 0x4b, 0xf1, 0x5e, 0x95, 0xbb, 0x3a, 0x54, 0xa1, 0xbf, 0xe2, 0x6c, 0x25, 0x91, + 0xb2, 0xa4, 0xb2, 0xbc, 0xe6, 0xe3, 0x9f, 0xb, 0x2a, 0xbb, 0x1f, 0x0, 0xa, 0x9c, 0x22, + 0x19, 0x6c, 0xff, 0xf2, 0x5d, 0x1d, 0x79, 0xdf, 0x19, 0x90, 0x29, 0x30, 0x3, 0x0, 0x5, + 0x8e, 0xaa, 0x93, 0x21, 0xdf, 0x27, 0x0, 0x0, 0x7e, 0x3, 0x0, 0x0, 0x1}; - uint8_t buf[84] = {0}; - - uint8_t topic_bytes[] = {0xc8, 0x5a, 0xe1, 0x69, 0x5e, 0x5f, 0x2, 0xe7, 0xc1, 0x2}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xce, 0xc1, 0xc2, 0xd9, 0xb1, 0x98, 0x8e, 0x2c, 0xa3, 0x91, 0x95, 0x51, 0xed, 0x3f, 0x37, - 0x83, 0x6b, 0xa, 0xb1, 0x5b, 0x5e, 0x99, 0x74, 0x69, 0x86, 0x73, 0x59, 0x6c, 0x8c, 0xae}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + uint8_t buf[83] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xe4, 0x96}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x15, 0x86, 0xc6, 0x37, 0x4b, 0xf1, 0x5e, 0x95, 0xbb, 0x3a, 0x54, 0xa1, 0xbf, + 0xe2, 0x6c, 0x25, 0x91, 0xb2, 0xa4, 0xb2, 0xbc, 0xe6, 0xe3, 0x9f, 0xb}; + uint8_t bytesprops1[] = {0x9c, 0x22, 0x19, 0x6c, 0xff, 0xf2, 0x5d, 0x1d, 0x79, 0xdf}; + uint8_t bytesprops2[] = {0x8e, 0xaa, 0x93, 0x21, 0xdf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27303}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30007}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3447}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17943}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32259}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16826, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27116, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\161\178\167\170\164+\151g\137\n", -// _pubPktID = 11219, _pubBody = "R\146a\229\236\247\197\178\199\136\159_\251", _pubProps = [PropWillDelayInterval -// 18228,PropServerReference "\RS\193\246;\172",PropRequestProblemInformation 24,PropTopicAliasMaximum -// 9254,PropSharedSubscriptionAvailable 218,PropUserProperty -// "r\SYN\215\149,\139\187r\155c\FS\144E\241\201\143\180\DC4J\211v\223L\198\DLE" -// "\244\&3\218\205\193M\209\STX\203\ETX>!e\148\212\165QY'\162)\160\141\178\204\186",PropMaximumQoS -// 37,PropSubscriptionIdentifierAvailable 146,PropSharedSubscriptionAvailable 166,PropSubscriptionIdentifierAvailable -// 56,PropPayloadFormatIndicator 133,PropPayloadFormatIndicator 41,PropMaximumQoS 35,PropSessionExpiryInterval -// 20605,PropAssignedClientIdentifier -// "\206|\235a\173\199\152\211\169\DC3\208(*\164\197\ETX\154s\217\232@PP\247",PropTopicAlias -// 28005,PropRequestProblemInformation 192,PropSubscriptionIdentifierAvailable 108,PropSessionExpiryInterval -// 24769,PropRequestResponseInformation 91,PropSubscriptionIdentifierAvailable 67,PropServerReference -// "\193",PropPayloadFormatIndicator 5,PropWillDelayInterval 20234,PropTopicAliasMaximum -// 21992,PropSubscriptionIdentifier 24,PropContentType "\131#\246#\254]\246\246",PropMessageExpiryInterval 19685]} -TEST(Publish5QCTest, Encode50) { - uint8_t pkt[] = {0x3b, 0xc7, 0x1, 0x0, 0xa, 0xa1, 0xb2, 0xa7, 0xaa, 0xa4, 0x2b, 0x97, 0x67, 0x89, 0xa, 0x2b, 0xd3, - 0xaa, 0x1, 0x18, 0x0, 0x0, 0x47, 0x34, 0x1c, 0x0, 0x5, 0x1e, 0xc1, 0xf6, 0x3b, 0xac, 0x17, 0x18, - 0x22, 0x24, 0x26, 0x2a, 0xda, 0x26, 0x0, 0x19, 0x72, 0x16, 0xd7, 0x95, 0x2c, 0x8b, 0xbb, 0x72, 0x9b, - 0x63, 0x1c, 0x90, 0x45, 0xf1, 0xc9, 0x8f, 0xb4, 0x14, 0x4a, 0xd3, 0x76, 0xdf, 0x4c, 0xc6, 0x10, 0x0, - 0x1a, 0xf4, 0x33, 0xda, 0xcd, 0xc1, 0x4d, 0xd1, 0x2, 0xcb, 0x3, 0x3e, 0x21, 0x65, 0x94, 0xd4, 0xa5, - 0x51, 0x59, 0x27, 0xa2, 0x29, 0xa0, 0x8d, 0xb2, 0xcc, 0xba, 0x24, 0x25, 0x29, 0x92, 0x2a, 0xa6, 0x29, - 0x38, 0x1, 0x85, 0x1, 0x29, 0x24, 0x23, 0x11, 0x0, 0x0, 0x50, 0x7d, 0x12, 0x0, 0x18, 0xce, 0x7c, - 0xeb, 0x61, 0xad, 0xc7, 0x98, 0xd3, 0xa9, 0x13, 0xd0, 0x28, 0x2a, 0xa4, 0xc5, 0x3, 0x9a, 0x73, 0xd9, - 0xe8, 0x40, 0x50, 0x50, 0xf7, 0x23, 0x6d, 0x65, 0x17, 0xc0, 0x29, 0x6c, 0x11, 0x0, 0x0, 0x60, 0xc1, - 0x19, 0x5b, 0x29, 0x43, 0x1c, 0x0, 0x1, 0xc1, 0x1, 0x5, 0x18, 0x0, 0x0, 0x4f, 0xa, 0x22, 0x55, - 0xe8, 0xb, 0x18, 0x3, 0x0, 0x8, 0x83, 0x23, 0xf6, 0x23, 0xfe, 0x5d, 0xf6, 0xf6, 0x2, 0x0, 0x0, - 0x4c, 0xe5, 0x52, 0x92, 0x61, 0xe5, 0xec, 0xf7, 0xc5, 0xb2, 0xc7, 0x88, 0x9f, 0x5f, 0xfb}; +// SubscribeRequest 21718 [("1\174I~\249\CAN\ETB\DC1\225r>\134\n\208\t\160\184\206T\DC3\207L:\206C\137\158",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\207\SI\180J\RSA\SYN\212",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\b\176\222\185\206Sp\170\133",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe5QCTest, Encode52) { + uint8_t pkt[] = {0x82, 0x38, 0x54, 0xd6, 0x0, 0x0, 0x1b, 0x31, 0xae, 0x49, 0x7e, 0xf9, 0x18, 0x17, 0x11, + 0xe1, 0x72, 0x3e, 0x86, 0xa, 0xd0, 0x9, 0xa0, 0xb8, 0xce, 0x54, 0x13, 0xcf, 0x4c, 0x3a, + 0xce, 0x43, 0x89, 0x9e, 0x2, 0x0, 0x8, 0xcf, 0xf, 0xb4, 0x4a, 0x1e, 0x41, 0x16, 0xd4, + 0x1, 0x0, 0x9, 0x8, 0xb0, 0xde, 0xb9, 0xce, 0x53, 0x70, 0xaa, 0x85, 0x0}; - uint8_t buf[212] = {0}; + uint8_t buf[68] = {0}; - uint8_t topic_bytes[] = {0xa1, 0xb2, 0xa7, 0xaa, 0xa4, 0x2b, 0x97, 0x67, 0x89, 0xa}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x52, 0x92, 0x61, 0xe5, 0xec, 0xf7, 0xc5, 0xb2, 0xc7, 0x88, 0x9f, 0x5f, 0xfb}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x31, 0xae, 0x49, 0x7e, 0xf9, 0x18, 0x17, 0x11, 0xe1, 0x72, 0x3e, 0x86, 0xa, 0xd0, + 0x9, 0xa0, 0xb8, 0xce, 0x54, 0x13, 0xcf, 0x4c, 0x3a, 0xce, 0x43, 0x89, 0x9e}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xcf, 0xf, 0xb4, 0x4a, 0x1e, 0x41, 0x16, 0xd4}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x8, 0xb0, 0xde, 0xb9, 0xce, 0x53, 0x70, 0xaa, 0x85}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0}; + + lwmqtt_property_t propslist[] = {}; - uint8_t bytesprops0[] = {0x1e, 0xc1, 0xf6, 0x3b, 0xac}; - uint8_t bytesprops2[] = {0xf4, 0x33, 0xda, 0xcd, 0xc1, 0x4d, 0xd1, 0x2, 0xcb, 0x3, 0x3e, 0x21, 0x65, - 0x94, 0xd4, 0xa5, 0x51, 0x59, 0x27, 0xa2, 0x29, 0xa0, 0x8d, 0xb2, 0xcc, 0xba}; - uint8_t bytesprops1[] = {0x72, 0x16, 0xd7, 0x95, 0x2c, 0x8b, 0xbb, 0x72, 0x9b, 0x63, 0x1c, 0x90, 0x45, - 0xf1, 0xc9, 0x8f, 0xb4, 0x14, 0x4a, 0xd3, 0x76, 0xdf, 0x4c, 0xc6, 0x10}; - uint8_t bytesprops3[] = {0xce, 0x7c, 0xeb, 0x61, 0xad, 0xc7, 0x98, 0xd3, 0xa9, 0x13, 0xd0, 0x28, - 0x2a, 0xa4, 0xc5, 0x3, 0x9a, 0x73, 0xd9, 0xe8, 0x40, 0x50, 0x50, 0xf7}; - uint8_t bytesprops4[] = {0xc1}; - uint8_t bytesprops5[] = {0x83, 0x23, 0xf6, 0x23, 0xfe, 0x5d, 0xf6, 0xf6}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21718, 3, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 32713 [("2\214\247\243(1\182\&4\130\248PZ\198\183\251=\\\128w\163\165~o\202",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("Z\195\171v\219\&5=\227\f\227X1\\\178\172\251\165\154\161\194",PropWillDelayInterval +// 11579,PropMessageExpiryInterval 12043,PropSessionExpiryInterval 14813,PropTopicAliasMaximum 32111,PropMaximumQoS +// 129,PropCorrelationData "\198\187(",PropRequestResponseInformation 47,PropRetainAvailable 92,PropMaximumPacketSize +// 1709,PropContentType "\230\SUB\157\r\174'Z|Z\250pC\148\168\138\163\225\193Q\164\250J",PropMessageExpiryInterval +// 5711,PropRequestProblemInformation 109,PropPayloadFormatIndicator 229,PropAuthenticationMethod +// "\131\161\181M\203!\164\145-\161,\ACKq",PropServerReference +// "B\231W\171\175\ETB\138\140\230",PropMessageExpiryInterval 5530,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 0xf8, 0x2, 0x0, 0xa, 0x8c, 0xb7, 0x9a, 0x8, 0xac, 0x6e, 0x8, 0x29, + 0x3, 0x64, 0x1, 0x0, 0x16, 0x3d, 0x88, 0x4, 0x5a, 0x6d, 0x14, 0x85, 0x96, 0xf7, 0x56, 0xb7, 0xaf, 0xd5, 0xa8, + 0x4d, 0x50, 0x45, 0xcf, 0x61, 0xbd, 0xab, 0xe9, 0x0, 0x0, 0x1d, 0x55, 0x4c, 0x7, 0xa1, 0xa8, 0x55, 0x30, 0x17, + 0x9b, 0x1b, 0x6e, 0x2f, 0xc3, 0xc7, 0xef, 0x3a, 0xaa, 0xb9, 0x3f, 0xcd, 0x9d, 0xf6, 0xa1, 0x78, 0xda, 0xf2, 0x28, + 0x8c, 0xbb, 0x0, 0x0, 0xa, 0xfb, 0x89, 0x2c, 0x8e, 0xf1, 0xbe, 0xf8, 0xce, 0xd1, 0xf2, 0x1, 0x0, 0x7, 0xbb, + 0x85, 0xcc, 0xfc, 0x13, 0xaa, 0x80, 0x0, 0x0, 0x14, 0x6b, 0x9, 0x11, 0x49, 0x28, 0x1b, 0xc1, 0x5a, 0x6f, 0xae, + 0x11, 0x44, 0x99, 0xd5, 0xa6, 0xa, 0x8d, 0x9e, 0x5, 0xc8, 0x0}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[306] = {0}; -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "R\\\164\224\200+\254\\\233t@\GS\144\&5|\243\244@%\240\170\193\150V\252\133q", _pubPktID = 23768, _pubBody = -// "\RS.\158\236\175|6'\152C\151\NUL\138o\230\242\236\184,\ENQ\201^\185\t", _pubProps = [PropSubscriptionIdentifier -// 13,PropUserProperty "\160!\152E\225\161\241#\ETXS\211\SYN\SYN\206\128\130\207$o" -// "Shx\SI\ETBGtG\164\FS\206\175o\231\&1",PropAuthenticationMethod -// "\143\ETB\235^\196\180\226\235\226\246\&3\226D6\bV*1\163P\211\233#53FFZ",PropUserProperty "?|\177\NAK\169{sj" -// "J\224n\163\190uG\169`\f)\228c_b",PropContentType -// "h\176p\SUB\181)\215\192P\239\228\v^ijNZ(rw\GS",PropTopicAliasMaximum 26777,PropResponseInformation -// "\DLEq\200\174\&9z\181X\172\254i\SUBs\207\145\208\217\135\233\SYN]"]} -TEST(Publish5QCTest, Encode51) { - uint8_t pkt[] = {0x3c, 0xd0, 0x1, 0x0, 0x1b, 0x52, 0x5c, 0xa4, 0xe0, 0xc8, 0x2b, 0xfe, 0x5c, 0xe9, 0x74, 0x40, 0x1d, - 0x90, 0x35, 0x7c, 0xf3, 0xf4, 0x40, 0x25, 0xf0, 0xaa, 0xc1, 0x96, 0x56, 0xfc, 0x85, 0x71, 0x5c, 0xd8, - 0x97, 0x1, 0xb, 0xd, 0x26, 0x0, 0x13, 0xa0, 0x21, 0x98, 0x45, 0xe1, 0xa1, 0xf1, 0x23, 0x3, 0x53, - 0xd3, 0x16, 0x16, 0xce, 0x80, 0x82, 0xcf, 0x24, 0x6f, 0x0, 0xf, 0x53, 0x68, 0x78, 0xf, 0x17, 0x47, - 0x74, 0x47, 0xa4, 0x1c, 0xce, 0xaf, 0x6f, 0xe7, 0x31, 0x15, 0x0, 0x1c, 0x8f, 0x17, 0xeb, 0x5e, 0xc4, - 0xb4, 0xe2, 0xeb, 0xe2, 0xf6, 0x33, 0xe2, 0x44, 0x36, 0x8, 0x56, 0x2a, 0x31, 0xa3, 0x50, 0xd3, 0xe9, - 0x23, 0x35, 0x33, 0x46, 0x46, 0x5a, 0x26, 0x0, 0x8, 0x3f, 0x7c, 0xb1, 0x15, 0xa9, 0x7b, 0x73, 0x6a, - 0x0, 0xf, 0x4a, 0xe0, 0x6e, 0xa3, 0xbe, 0x75, 0x47, 0xa9, 0x60, 0xc, 0x29, 0xe4, 0x63, 0x5f, 0x62, - 0x3, 0x0, 0x15, 0x68, 0xb0, 0x70, 0x1a, 0xb5, 0x29, 0xd7, 0xc0, 0x50, 0xef, 0xe4, 0xb, 0x5e, 0x69, - 0x6a, 0x4e, 0x5a, 0x28, 0x72, 0x77, 0x1d, 0x22, 0x68, 0x99, 0x1a, 0x0, 0x15, 0x10, 0x71, 0xc8, 0xae, - 0x39, 0x7a, 0xb5, 0x58, 0xac, 0xfe, 0x69, 0x1a, 0x73, 0xcf, 0x91, 0xd0, 0xd9, 0x87, 0xe9, 0x16, 0x5d, - 0x1e, 0x2e, 0x9e, 0xec, 0xaf, 0x7c, 0x36, 0x27, 0x98, 0x43, 0x97, 0x0, 0x8a, 0x6f, 0xe6, 0xf2, 0xec, - 0xb8, 0x2c, 0x5, 0xc9, 0x5e, 0xb9, 0x9}; - - uint8_t buf[221] = {0}; - - uint8_t topic_bytes[] = {0x52, 0x5c, 0xa4, 0xe0, 0xc8, 0x2b, 0xfe, 0x5c, 0xe9, 0x74, 0x40, 0x1d, 0x90, 0x35, - 0x7c, 0xf3, 0xf4, 0x40, 0x25, 0xf0, 0xaa, 0xc1, 0x96, 0x56, 0xfc, 0x85, 0x71}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x1e, 0x2e, 0x9e, 0xec, 0xaf, 0x7c, 0x36, 0x27, 0x98, 0x43, 0x97, 0x0, - 0x8a, 0x6f, 0xe6, 0xf2, 0xec, 0xb8, 0x2c, 0x5, 0xc9, 0x5e, 0xb9, 0x9}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; - - uint8_t bytesprops1[] = {0x53, 0x68, 0x78, 0xf, 0x17, 0x47, 0x74, 0x47, 0xa4, 0x1c, 0xce, 0xaf, 0x6f, 0xe7, 0x31}; - uint8_t bytesprops0[] = {0xa0, 0x21, 0x98, 0x45, 0xe1, 0xa1, 0xf1, 0x23, 0x3, 0x53, - 0xd3, 0x16, 0x16, 0xce, 0x80, 0x82, 0xcf, 0x24, 0x6f}; - uint8_t bytesprops2[] = {0x8f, 0x17, 0xeb, 0x5e, 0xc4, 0xb4, 0xe2, 0xeb, 0xe2, 0xf6, 0x33, 0xe2, 0x44, 0x36, - 0x8, 0x56, 0x2a, 0x31, 0xa3, 0x50, 0xd3, 0xe9, 0x23, 0x35, 0x33, 0x46, 0x46, 0x5a}; - uint8_t bytesprops4[] = {0x4a, 0xe0, 0x6e, 0xa3, 0xbe, 0x75, 0x47, 0xa9, 0x60, 0xc, 0x29, 0xe4, 0x63, 0x5f, 0x62}; - uint8_t bytesprops3[] = {0x3f, 0x7c, 0xb1, 0x15, 0xa9, 0x7b, 0x73, 0x6a}; - uint8_t bytesprops5[] = {0x68, 0xb0, 0x70, 0x1a, 0xb5, 0x29, 0xd7, 0xc0, 0x50, 0xef, 0xe4, - 0xb, 0x5e, 0x69, 0x6a, 0x4e, 0x5a, 0x28, 0x72, 0x77, 0x1d}; - uint8_t bytesprops6[] = {0x10, 0x71, 0xc8, 0xae, 0x39, 0x7a, 0xb5, 0x58, 0xac, 0xfe, 0x69, - 0x1a, 0x73, 0xcf, 0x91, 0xd0, 0xd9, 0x87, 0xe9, 0x16, 0x5d}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xed, 0x61, 0x80, 0x30, 0x1c, 0xa2, 0x34, 0x87, 0x61, 0x86, + 0x2d, 0x2e, 0xf3, 0x3d, 0x5a, 0x83, 0xff, 0x66, 0x5e}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x57, 0x6a, 0x6e, 0xed, 0xf8}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x8c, 0xb7, 0x9a, 0x8, 0xac, 0x6e, 0x8, 0x29, 0x3, 0x64}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x3d, 0x88, 0x4, 0x5a, 0x6d, 0x14, 0x85, 0x96, 0xf7, 0x56, 0xb7, + 0xaf, 0xd5, 0xa8, 0x4d, 0x50, 0x45, 0xcf, 0x61, 0xbd, 0xab, 0xe9}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x55, 0x4c, 0x7, 0xa1, 0xa8, 0x55, 0x30, 0x17, 0x9b, 0x1b, + 0x6e, 0x2f, 0xc3, 0xc7, 0xef, 0x3a, 0xaa, 0xb9, 0x3f, 0xcd, + 0x9d, 0xf6, 0xa1, 0x78, 0xda, 0xf2, 0x28, 0x8c, 0xbb}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xfb, 0x89, 0x2c, 0x8e, 0xf1, 0xbe, 0xf8, 0xce, 0xd1, 0xf2}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xbb, 0x85, 0xcc, 0xfc, 0x13, 0xaa, 0x80}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6b, 0x9, 0x11, 0x49, 0x28, 0x1b, 0xc1, 0x5a, 0x6f, 0xae, + 0x11, 0x44, 0x99, 0xd5, 0xa6, 0xa, 0x8d, 0x9e, 0x5, 0xc8}; + lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0xa, 0xf3}; + uint8_t bytesprops1[] = {0x9a, 0xf1, 0x86, 0x60, 0x9e, 0x3, 0x5e, 0xe5, 0x3, 0x27, 0x53, 0x36, 0x3e, 0xdb, 0x35, + 0x3d, 0xe3, 0xc, 0xe3, 0x58, 0x31, 0x5c, 0xb2, 0xac, 0xfb, 0xa5, 0x9a, 0xa1, 0xc2}; + uint8_t bytesprops2[] = {0xc6, 0xbb, 0x28}; + uint8_t bytesprops3[] = {0xe6, 0x1a, 0x9d, 0xd, 0xae, 0x27, 0x5a, 0x7c, 0x5a, 0xfa, 0x70, + 0x43, 0x94, 0xa8, 0x8a, 0xa3, 0xe1, 0xc1, 0x51, 0xa4, 0xfa, 0x4a}; + uint8_t bytesprops4[] = {0x83, 0xa1, 0xb5, 0x4d, 0xcb, 0x21, 0xa4, 0x91, 0x2d, 0xa1, 0x2c, 0x6, 0x71}; + uint8_t bytesprops5[] = {0x42, 0xe7, 0x57, 0xab, 0xaf, 0x17, 0x8a, 0x8c, 0xe6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops0}, .v = {15, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops3}, .v = {15, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26777}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11579}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12043}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14813}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32111}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1709}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5711}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5530}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 23768, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\EOT+\243\179\223\201\tb\221\175W<\221L\a", _pubPktID = 32599, _pubBody = -// "\187\221\219\249%\DC1M\195%\227~\ETBcZ\232\f\141\254\253\223", _pubProps = [PropRequestResponseInformation -// 75,PropRequestResponseInformation 72,PropServerReference -// "W\v\250p^\151{p_\169\224\131\EOT{\219\131%\207$\192+",PropAssignedClientIdentifier -// "L\216\&8\134\146\254\201\DELm\138~YZ\233|\244S\131\213Nt\254Bl\208\149",PropRequestProblemInformation 238]} -TEST(Publish5QCTest, Encode52) { - uint8_t pkt[] = {0x3b, 0x63, 0x0, 0xf, 0x4, 0x2b, 0xf3, 0xb3, 0xdf, 0xc9, 0x9, 0x62, 0xdd, 0xaf, 0x57, 0x3c, 0xdd, - 0x4c, 0x7, 0x7f, 0x57, 0x3b, 0x19, 0x4b, 0x19, 0x48, 0x1c, 0x0, 0x15, 0x57, 0xb, 0xfa, 0x70, 0x5e, - 0x97, 0x7b, 0x70, 0x5f, 0xa9, 0xe0, 0x83, 0x4, 0x7b, 0xdb, 0x83, 0x25, 0xcf, 0x24, 0xc0, 0x2b, 0x12, - 0x0, 0x1a, 0x4c, 0xd8, 0x38, 0x86, 0x92, 0xfe, 0xc9, 0x7f, 0x6d, 0x8a, 0x7e, 0x59, 0x5a, 0xe9, 0x7c, - 0xf4, 0x53, 0x83, 0xd5, 0x4e, 0x74, 0xfe, 0x42, 0x6c, 0xd0, 0x95, 0x17, 0xee, 0xbb, 0xdd, 0xdb, 0xf9, - 0x25, 0x11, 0x4d, 0xc3, 0x25, 0xe3, 0x7e, 0x17, 0x63, 0x5a, 0xe8, 0xc, 0x8d, 0xfe, 0xfd, 0xdf}; - - uint8_t buf[111] = {0}; - - uint8_t topic_bytes[] = {0x4, 0x2b, 0xf3, 0xb3, 0xdf, 0xc9, 0x9, 0x62, 0xdd, 0xaf, 0x57, 0x3c, 0xdd, 0x4c, 0x7}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xbb, 0xdd, 0xdb, 0xf9, 0x25, 0x11, 0x4d, 0xc3, 0x25, 0xe3, - 0x7e, 0x17, 0x63, 0x5a, 0xe8, 0xc, 0x8d, 0xfe, 0xfd, 0xdf}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; - - uint8_t bytesprops0[] = {0x57, 0xb, 0xfa, 0x70, 0x5e, 0x97, 0x7b, 0x70, 0x5f, 0xa9, 0xe0, - 0x83, 0x4, 0x7b, 0xdb, 0x83, 0x25, 0xcf, 0x24, 0xc0, 0x2b}; - uint8_t bytesprops1[] = {0x4c, 0xd8, 0x38, 0x86, 0x92, 0xfe, 0xc9, 0x7f, 0x6d, 0x8a, 0x7e, 0x59, 0x5a, - 0xe9, 0x7c, 0xf4, 0x53, 0x83, 0xd5, 0x4e, 0x74, 0xfe, 0x42, 0x6c, 0xd0, 0x95}; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29246, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 2039 [("\134\204K\176hu :\174\236V\DC1u\178\203",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\US\NULy38e\DC4\186\218\247&\r\202\247\214\221\158\tO:\146?c\221\188\174\202\241\206",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropServerReference "KXv\\y\228\248\185\228\&3\166\245\t\249=\STX)\173\182",PropRequestProblemInformation +// 175,PropRequestResponseInformation 131,PropCorrelationData +// "Yx\141(\159D6\176!.\181b\225.\145\r\206\ETB\163\234\243\175\180f\191\214\128",PropServerKeepAlive +// 27540,PropReceiveMaximum 20437,PropResponseInformation "\193\209\DC4:B\FSx\163\140\198\v",PropUserProperty +// "\a|\174\EOT3\136" "\147\134\143\DC3,",PropWillDelayInterval 22556,PropSessionExpiryInterval +// 11928,PropAuthenticationMethod "-\187\143\206\141Y\194\249\DC2\138\249\219k\158"] +TEST(Subscribe5QCTest, Encode55) { + uint8_t pkt[] = {0x82, 0xac, 0x1, 0x7, 0xf7, 0x77, 0x1c, 0x0, 0x13, 0x4b, 0x58, 0x76, 0x5c, 0x79, 0xe4, 0xf8, + 0xb9, 0xe4, 0x33, 0xa6, 0xf5, 0x9, 0xf9, 0x3d, 0x2, 0x29, 0xad, 0xb6, 0x17, 0xaf, 0x19, 0x83, + 0x9, 0x0, 0x1b, 0x59, 0x78, 0x8d, 0x28, 0x9f, 0x44, 0x36, 0xb0, 0x21, 0x2e, 0xb5, 0x62, 0xe1, + 0x2e, 0x91, 0xd, 0xce, 0x17, 0xa3, 0xea, 0xf3, 0xaf, 0xb4, 0x66, 0xbf, 0xd6, 0x80, 0x13, 0x6b, + 0x94, 0x21, 0x4f, 0xd5, 0x1a, 0x0, 0xb, 0xc1, 0xd1, 0x14, 0x3a, 0x42, 0x1c, 0x78, 0xa3, 0x8c, + 0xc6, 0xb, 0x26, 0x0, 0x6, 0x7, 0x7c, 0xae, 0x4, 0x33, 0x88, 0x0, 0x5, 0x93, 0x86, 0x8f, + 0x13, 0x2c, 0x18, 0x0, 0x0, 0x58, 0x1c, 0x11, 0x0, 0x0, 0x2e, 0x98, 0x15, 0x0, 0xe, 0x2d, + 0xbb, 0x8f, 0xce, 0x8d, 0x59, 0xc2, 0xf9, 0x12, 0x8a, 0xf9, 0xdb, 0x6b, 0x9e, 0x0, 0xf, 0x86, + 0xcc, 0x4b, 0xb0, 0x68, 0x75, 0x20, 0x3a, 0xae, 0xec, 0x56, 0x11, 0x75, 0xb2, 0xcb, 0x1, 0x0, + 0x1d, 0x1f, 0x0, 0x79, 0x33, 0x38, 0x65, 0x14, 0xba, 0xda, 0xf7, 0x26, 0xd, 0xca, 0xf7, 0xd6, + 0xdd, 0x9e, 0x9, 0x4f, 0x3a, 0x92, 0x3f, 0x63, 0xdd, 0xbc, 0xae, 0xca, 0xf1, 0xce, 0x2}; + + uint8_t buf[185] = {0}; + + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x86, 0xcc, 0x4b, 0xb0, 0x68, 0x75, 0x20, 0x3a, + 0xae, 0xec, 0x56, 0x11, 0x75, 0xb2, 0xcb}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x1f, 0x0, 0x79, 0x33, 0x38, 0x65, 0x14, 0xba, 0xda, 0xf7, + 0x26, 0xd, 0xca, 0xf7, 0xd6, 0xdd, 0x9e, 0x9, 0x4f, 0x3a, + 0x92, 0x3f, 0x63, 0xdd, 0xbc, 0xae, 0xca, 0xf1, 0xce}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x4b, 0x58, 0x76, 0x5c, 0x79, 0xe4, 0xf8, 0xb9, 0xe4, 0x33, + 0xa6, 0xf5, 0x9, 0xf9, 0x3d, 0x2, 0x29, 0xad, 0xb6}; + uint8_t bytesprops1[] = {0x59, 0x78, 0x8d, 0x28, 0x9f, 0x44, 0x36, 0xb0, 0x21, 0x2e, 0xb5, 0x62, 0xe1, 0x2e, + 0x91, 0xd, 0xce, 0x17, 0xa3, 0xea, 0xf3, 0xaf, 0xb4, 0x66, 0xbf, 0xd6, 0x80}; + uint8_t bytesprops2[] = {0xc1, 0xd1, 0x14, 0x3a, 0x42, 0x1c, 0x78, 0xa3, 0x8c, 0xc6, 0xb}; + uint8_t bytesprops4[] = {0x93, 0x86, 0x8f, 0x13, 0x2c}; + uint8_t bytesprops3[] = {0x7, 0x7c, 0xae, 0x4, 0x33, 0x88}; + uint8_t bytesprops5[] = {0x2d, 0xbb, 0x8f, 0xce, 0x8d, 0x59, 0xc2, 0xf9, 0x12, 0x8a, 0xf9, 0xdb, 0x6b, 0x9e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27540}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20437}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22556}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11928}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 32599, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2039, 2, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "k6\170c0\139\149-", _pubPktID = -// 24880, _pubBody = "q\181r\196\216Eo\234\"\ENQ\138\207\210-\196\182\157\139\DC2\178?b\a4\250\ETB\168\131", _pubProps = -// [PropResponseTopic "\194\253P1\177\165\ETB\236\228\\;",PropResponseInformation -// "\143\DEL\169\206\155\248\193\163\&6\181\NUL\v5\180",PropRetainAvailable 58,PropSubscriptionIdentifier -// 26,PropSubscriptionIdentifierAvailable 200,PropSubscriptionIdentifier 28,PropSubscriptionIdentifier -// 27,PropAuthenticationData "\197\DC2#",PropAuthenticationMethod "H",PropAuthenticationData -// "\204\226Q\174\&9\190\172\174\135\&6\255\130\203\152\216\201|\180?\234\DC1\175\169\181\&7X",PropMaximumQoS -// 208,PropMaximumPacketSize 31599,PropMaximumQoS 143,PropServerKeepAlive 4529]} -TEST(Publish5QCTest, Encode53) { - uint8_t pkt[] = {0x32, 0x85, 0x1, 0x0, 0x8, 0x6b, 0x36, 0xaa, 0x63, 0x30, 0x8b, 0x95, 0x2d, 0x61, 0x30, 0x5c, - 0x8, 0x0, 0xb, 0xc2, 0xfd, 0x50, 0x31, 0xb1, 0xa5, 0x17, 0xec, 0xe4, 0x5c, 0x3b, 0x1a, 0x0, - 0xe, 0x8f, 0x7f, 0xa9, 0xce, 0x9b, 0xf8, 0xc1, 0xa3, 0x36, 0xb5, 0x0, 0xb, 0x35, 0xb4, 0x25, - 0x3a, 0xb, 0x1a, 0x29, 0xc8, 0xb, 0x1c, 0xb, 0x1b, 0x16, 0x0, 0x3, 0xc5, 0x12, 0x23, 0x15, - 0x0, 0x1, 0x48, 0x16, 0x0, 0x1a, 0xcc, 0xe2, 0x51, 0xae, 0x39, 0xbe, 0xac, 0xae, 0x87, 0x36, - 0xff, 0x82, 0xcb, 0x98, 0xd8, 0xc9, 0x7c, 0xb4, 0x3f, 0xea, 0x11, 0xaf, 0xa9, 0xb5, 0x37, 0x58, - 0x24, 0xd0, 0x27, 0x0, 0x0, 0x7b, 0x6f, 0x24, 0x8f, 0x13, 0x11, 0xb1, 0x71, 0xb5, 0x72, 0xc4, - 0xd8, 0x45, 0x6f, 0xea, 0x22, 0x5, 0x8a, 0xcf, 0xd2, 0x2d, 0xc4, 0xb6, 0x9d, 0x8b, 0x12, 0xb2, - 0x3f, 0x62, 0x7, 0x34, 0xfa, 0x17, 0xa8, 0x83}; - - uint8_t buf[146] = {0}; - - uint8_t topic_bytes[] = {0x6b, 0x36, 0xaa, 0x63, 0x30, 0x8b, 0x95, 0x2d}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x71, 0xb5, 0x72, 0xc4, 0xd8, 0x45, 0x6f, 0xea, 0x22, 0x5, 0x8a, 0xcf, 0xd2, 0x2d, - 0xc4, 0xb6, 0x9d, 0x8b, 0x12, 0xb2, 0x3f, 0x62, 0x7, 0x34, 0xfa, 0x17, 0xa8, 0x83}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; - - uint8_t bytesprops0[] = {0xc2, 0xfd, 0x50, 0x31, 0xb1, 0xa5, 0x17, 0xec, 0xe4, 0x5c, 0x3b}; - uint8_t bytesprops1[] = {0x8f, 0x7f, 0xa9, 0xce, 0x9b, 0xf8, 0xc1, 0xa3, 0x36, 0xb5, 0x0, 0xb, 0x35, 0xb4}; - uint8_t bytesprops2[] = {0xc5, 0x12, 0x23}; - uint8_t bytesprops3[] = {0x48}; - uint8_t bytesprops4[] = {0xcc, 0xe2, 0x51, 0xae, 0x39, 0xbe, 0xac, 0xae, 0x87, 0x36, 0xff, 0x82, 0xcb, - 0x98, 0xd8, 0xc9, 0x7c, 0xb4, 0x3f, 0xea, 0x11, 0xaf, 0xa9, 0xb5, 0x37, 0x58}; +// SubscribeRequest 29065 +// [("^Q\224\196\169V\128\198eL\204\194\202.?\DEL\NAK\206Z\162;V\t\163\214\DLE\156\232",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\216\186a\141",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\173\DC4j\205\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2})] [PropMessageExpiryInterval 19729,PropSubscriptionIdentifier 11,PropContentType +// "{\213\222x#\147\160\190}\SYN\145\164\n[",PropResponseTopic "w\150\179\171\228\153E\f\216",PropContentType +// ";\208a\239\144y)tB'\DC2",PropMessageExpiryInterval 29087,PropServerReference "\181Fb +// \185\229\NUL\RS\158\150\n2\130",PropWillDelayInterval 4042,PropServerReference "w",PropContentType +// "\160\164\191\240\237Y\147\&9\182\193\ACK{B<\172\238\238u\161N\164V7\NAK%\241\214\192\200",PropReceiveMaximum +// 22724,PropResponseTopic "\EM\236\NUL<\146z\205\131\168%\186\&2",PropAssignedClientIdentifier +// "F\246\DC2\133\171\151\RS\129'2\254\162M\206\232\181`\f\209\148M",PropMaximumQoS 157,PropReceiveMaximum +// 26184,PropResponseTopic +// "\t_\236\130j\182\199\DC3Cl-\201\218\165a*\ENQ@\234\241\241\187\f\243\215\184\238\163",PropCorrelationData +// "\232\234:\223\164\218X\213\246y\SUB\143\244\175\209\&0l\176\211",PropAuthenticationData "\226\195\ACK\218 +// A\136M\193)O3\255q~e'\154\242\190\136\147\176d\DC4d\231",PropSessionExpiryInterval 21583,PropAuthenticationMethod +// "\144\204\169x!^\213",PropServerKeepAlive 20138,PropMaximumQoS 108,PropContentType "\148\193\210F\163@\129\242"] +TEST(Subscribe5QCTest, Encode56) { + uint8_t pkt[] = { + 0x82, 0xc3, 0x2, 0x71, 0x89, 0x91, 0x2, 0x2, 0x0, 0x0, 0x4d, 0x11, 0xb, 0xb, 0x3, 0x0, 0xe, 0x7b, 0xd5, + 0xde, 0x78, 0x23, 0x93, 0xa0, 0xbe, 0x7d, 0x16, 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0x30, 0x6c, 0xb0, 0xd3, 0x16, 0x0, 0x1b, 0xe2, 0xc3, 0x6, 0xda, 0x20, 0x41, + 0x88, 0x4d, 0xc1, 0x29, 0x4f, 0x33, 0xff, 0x71, 0x7e, 0x65, 0x27, 0x9a, 0xf2, 0xbe, 0x88, 0x93, 0xb0, 0x64, 0x14, + 0x64, 0xe7, 0x11, 0x0, 0x0, 0x54, 0x4f, 0x15, 0x0, 0x7, 0x90, 0xcc, 0xa9, 0x78, 0x21, 0x5e, 0xd5, 0x13, 0x4e, + 0xaa, 0x24, 0x6c, 0x3, 0x0, 0x8, 0x94, 0xc1, 0xd2, 0x46, 0xa3, 0x40, 0x81, 0xf2, 0x0, 0x1c, 0x5e, 0x51, 0xe0, + 0xc4, 0xa9, 0x56, 0x80, 0xc6, 0x65, 0x4c, 0xcc, 0xc2, 0xca, 0x2e, 0x3f, 0x7f, 0x15, 0xce, 0x5a, 0xa2, 0x3b, 0x56, + 0x9, 0xa3, 0xd6, 0x10, 0x9c, 0xe8, 0x1, 0x0, 0x4, 0xd8, 0xba, 0x61, 0x8d, 0x1, 0x0, 0x5, 0xad, 0x14, 0x6a, + 0xcd, 0xeb, 0x2}; + + uint8_t buf[336] = {0}; + + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x5e, 0x51, 0xe0, 0xc4, 0xa9, 0x56, 0x80, 0xc6, 0x65, 0x4c, + 0xcc, 0xc2, 0xca, 0x2e, 0x3f, 0x7f, 0x15, 0xce, 0x5a, 0xa2, + 0x3b, 0x56, 0x9, 0xa3, 0xd6, 0x10, 0x9c, 0xe8}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd8, 0xba, 0x61, 0x8d}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xad, 0x14, 0x6a, 0xcd, 0xeb}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x7b, 0xd5, 0xde, 0x78, 0x23, 0x93, 0xa0, 0xbe, 0x7d, 0x16, 0x91, 0xa4, 0xa, 0x5b}; + uint8_t bytesprops1[] = {0x77, 0x96, 0xb3, 0xab, 0xe4, 0x99, 0x45, 0xc, 0xd8}; + uint8_t bytesprops2[] = {0x3b, 0xd0, 0x61, 0xef, 0x90, 0x79, 0x29, 0x74, 0x42, 0x27, 0x12}; + uint8_t bytesprops3[] = {0xb5, 0x46, 0x62, 0x20, 0xb9, 0xe5, 0x0, 0x1e, 0x9e, 0x96, 0xa, 0x32, 0x82}; + uint8_t bytesprops4[] = {0x77}; + uint8_t bytesprops5[] = {0xa0, 0xa4, 0xbf, 0xf0, 0xed, 0x59, 0x93, 0x39, 0xb6, 0xc1, 0x6, 0x7b, 0x42, 0x3c, 0xac, + 0xee, 0xee, 0x75, 0xa1, 0x4e, 0xa4, 0x56, 0x37, 0x15, 0x25, 0xf1, 0xd6, 0xc0, 0xc8}; + uint8_t bytesprops6[] = {0x19, 0xec, 0x0, 0x3c, 0x92, 0x7a, 0xcd, 0x83, 0xa8, 0x25, 0xba, 0x32}; + uint8_t bytesprops7[] = {0x46, 0xf6, 0x12, 0x85, 0xab, 0x97, 0x1e, 0x81, 0x27, 0x32, 0xfe, + 0xa2, 0x4d, 0xce, 0xe8, 0xb5, 0x60, 0xc, 0xd1, 0x94, 0x4d}; + uint8_t bytesprops8[] = {0x9, 0x5f, 0xec, 0x82, 0x6a, 0xb6, 0xc7, 0x13, 0x43, 0x6c, 0x2d, 0xc9, 0xda, 0xa5, + 0x61, 0x2a, 0x5, 0x40, 0xea, 0xf1, 0xf1, 0xbb, 0xc, 0xf3, 0xd7, 0xb8, 0xee, 0xa3}; + uint8_t bytesprops9[] = {0xe8, 0xea, 0x3a, 0xdf, 0xa4, 0xda, 0x58, 0xd5, 0xf6, 0x79, + 0x1a, 0x8f, 0xf4, 0xaf, 0xd1, 0x30, 0x6c, 0xb0, 0xd3}; + uint8_t bytesprops10[] = {0xe2, 0xc3, 0x6, 0xda, 0x20, 0x41, 0x88, 0x4d, 0xc1, 0x29, 0x4f, 0x33, 0xff, 0x71, + 0x7e, 0x65, 0x27, 0x9a, 0xf2, 0xbe, 0x88, 0x93, 0xb0, 0x64, 0x14, 0x64, 0xe7}; + uint8_t bytesprops11[] = {0x90, 0xcc, 0xa9, 0x78, 0x21, 0x5e, 0xd5}; + uint8_t bytesprops12[] = {0x94, 0xc1, 0xd2, 0x46, 0xa3, 0x40, 0x81, 0xf2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31599}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4529}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19729}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29087}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4042}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22724}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26184}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21583}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20138}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops12}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24880, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29065, 3, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\164]\137\161\184\189\ETB_L\r+\255\233u\227\NAK\SI\199\CANG\211_\141", _pubPktID = 0, _pubBody = -// "n\169\136j,\137\228\208\162\164aL\186\EOT\241\GS\230d\142\177N\138P", _pubProps = [PropAuthenticationMethod -// "\150\NULS\SUB\129",PropSubscriptionIdentifierAvailable 115,PropMessageExpiryInterval -// 16352,PropRequestProblemInformation 184,PropAssignedClientIdentifier "\t",PropAuthenticationMethod -// "\152\247\214J\179\245\255\166\STX\252\255\130\243\141L`",PropTopicAliasMaximum 17674]} -TEST(Publish5QCTest, Encode54) { - uint8_t pkt[] = {0x38, 0x5c, 0x0, 0x17, 0xa4, 0x5d, 0x89, 0xa1, 0xb8, 0xbd, 0x17, 0x5f, 0x4c, 0xd, 0x2b, 0xff, - 0xe9, 0x75, 0xe3, 0x15, 0xf, 0xc7, 0x18, 0x47, 0xd3, 0x5f, 0x8d, 0x2b, 0x15, 0x0, 0x5, 0x96, - 0x0, 0x53, 0x1a, 0x81, 0x29, 0x73, 0x2, 0x0, 0x0, 0x3f, 0xe0, 0x17, 0xb8, 0x12, 0x0, 0x1, - 0x9, 0x15, 0x0, 0x10, 0x98, 0xf7, 0xd6, 0x4a, 0xb3, 0xf5, 0xff, 0xa6, 0x2, 0xfc, 0xff, 0x82, - 0xf3, 0x8d, 0x4c, 0x60, 0x22, 0x45, 0xa, 0x6e, 0xa9, 0x88, 0x6a, 0x2c, 0x89, 0xe4, 0xd0, 0xa2, - 0xa4, 0x61, 0x4c, 0xba, 0x4, 0xf1, 0x1d, 0xe6, 0x64, 0x8e, 0xb1, 0x4e, 0x8a, 0x50}; +// SubscribeRequest 6655 [("x\149\146\242D\207\254D\208\218\227h\141>hT\212\152\tmFk\v\159",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("v[g\156",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropMessageExpiryInterval 19764,PropAssignedClientIdentifier +// "\ACK\139Q\243#\155\166*\151\227\159\189\237w\185\EM",PropResponseTopic +// "\212F_\151B\237\207\186G07\r\153",PropWildcardSubscriptionAvailable 108,PropContentType +// "\192\225\STX\218\161\143\v\DC4:d;%\194\153\216\&7\ETB\235j\136",PropMaximumQoS 69,PropMessageExpiryInterval +// 4203,PropResponseInformation "",PropSubscriptionIdentifierAvailable 158,PropRequestProblemInformation +// 80,PropWildcardSubscriptionAvailable 181] +TEST(Subscribe5QCTest, Encode57) { + uint8_t pkt[] = {0x82, 0x76, 0x19, 0xff, 0x51, 0x2, 0x0, 0x0, 0x4d, 0x34, 0x12, 0x0, 0x10, 0x6, 0x8b, + 0x51, 0xf3, 0x23, 0x9b, 0xa6, 0x2a, 0x97, 0xe3, 0x9f, 0xbd, 0xed, 0x77, 0xb9, 0x19, 0x8, + 0x0, 0xd, 0xd4, 0x46, 0x5f, 0x97, 0x42, 0xed, 0xcf, 0xba, 0x47, 0x30, 0x37, 0xd, 0x99, + 0x28, 0x6c, 0x3, 0x0, 0x14, 0xc0, 0xe1, 0x2, 0xda, 0xa1, 0x8f, 0xb, 0x14, 0x3a, 0x64, + 0x3b, 0x25, 0xc2, 0x99, 0xd8, 0x37, 0x17, 0xeb, 0x6a, 0x88, 0x24, 0x45, 0x2, 0x0, 0x0, + 0x10, 0x6b, 0x1a, 0x0, 0x0, 0x29, 0x9e, 0x17, 0x50, 0x28, 0xb5, 0x0, 0x18, 0x78, 0x95, + 0x92, 0xf2, 0x44, 0xcf, 0xfe, 0x44, 0xd0, 0xda, 0xe3, 0x68, 0x8d, 0x3e, 0x68, 0x54, 0xd4, + 0x98, 0x9, 0x6d, 0x46, 0x6b, 0xb, 0x9f, 0x2, 0x0, 0x4, 0x76, 0x5b, 0x67, 0x9c, 0x0}; - uint8_t buf[104] = {0}; - - uint8_t topic_bytes[] = {0xa4, 0x5d, 0x89, 0xa1, 0xb8, 0xbd, 0x17, 0x5f, 0x4c, 0xd, 0x2b, 0xff, - 0xe9, 0x75, 0xe3, 0x15, 0xf, 0xc7, 0x18, 0x47, 0xd3, 0x5f, 0x8d}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x6e, 0xa9, 0x88, 0x6a, 0x2c, 0x89, 0xe4, 0xd0, 0xa2, 0xa4, 0x61, 0x4c, - 0xba, 0x4, 0xf1, 0x1d, 0xe6, 0x64, 0x8e, 0xb1, 0x4e, 0x8a, 0x50}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + uint8_t buf[130] = {0}; - uint8_t bytesprops0[] = {0x96, 0x0, 0x53, 0x1a, 0x81}; - uint8_t bytesprops1[] = {0x9}; - uint8_t bytesprops2[] = {0x98, 0xf7, 0xd6, 0x4a, 0xb3, 0xf5, 0xff, 0xa6, - 0x2, 0xfc, 0xff, 0x82, 0xf3, 0x8d, 0x4c, 0x60}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x78, 0x95, 0x92, 0xf2, 0x44, 0xcf, 0xfe, 0x44, 0xd0, 0xda, 0xe3, 0x68, + 0x8d, 0x3e, 0x68, 0x54, 0xd4, 0x98, 0x9, 0x6d, 0x46, 0x6b, 0xb, 0x9f}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x76, 0x5b, 0x67, 0x9c}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x6, 0x8b, 0x51, 0xf3, 0x23, 0x9b, 0xa6, 0x2a, + 0x97, 0xe3, 0x9f, 0xbd, 0xed, 0x77, 0xb9, 0x19}; + uint8_t bytesprops1[] = {0xd4, 0x46, 0x5f, 0x97, 0x42, 0xed, 0xcf, 0xba, 0x47, 0x30, 0x37, 0xd, 0x99}; + uint8_t bytesprops2[] = {0xc0, 0xe1, 0x2, 0xda, 0xa1, 0x8f, 0xb, 0x14, 0x3a, 0x64, + 0x3b, 0x25, 0xc2, 0x99, 0xd8, 0x37, 0x17, 0xeb, 0x6a, 0x88}; + uint8_t bytesprops3[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16352}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17674}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19764}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4203}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 181}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "_\225\NAK\164\f\128V", _pubPktID = -// 0, _pubBody = "\146\161JU\174P\208og\201\149\132e\190\182\\!e\203q\201\194\SYN\147O\178\173{\DC2F", _pubProps = -// [PropTopicAliasMaximum 23589,PropSubscriptionIdentifier 23,PropResponseTopic -// "\251\131\ESC\ESC\140\241u\a\144\132r\t\144",PropSubscriptionIdentifier 7,PropAuthenticationData -// "\250\GS\208\170\DC1\r\163\251\DC1\230\240\212uC"]} -TEST(Publish5QCTest, Encode55) { - uint8_t pkt[] = {0x30, 0x50, 0x0, 0x7, 0x5f, 0xe1, 0x15, 0xa4, 0xc, 0x80, 0x56, 0x28, 0x22, 0x5c, 0x25, 0xb, 0x17, - 0x8, 0x0, 0xd, 0xfb, 0x83, 0x1b, 0x1b, 0x8c, 0xf1, 0x75, 0x7, 0x90, 0x84, 0x72, 0x9, 0x90, 0xb, - 0x7, 0x16, 0x0, 0xe, 0xfa, 0x1d, 0xd0, 0xaa, 0x11, 0xd, 0xa3, 0xfb, 0x11, 0xe6, 0xf0, 0xd4, 0x75, - 0x43, 0x92, 0xa1, 0x4a, 0x55, 0xae, 0x50, 0xd0, 0x6f, 0x67, 0xc9, 0x95, 0x84, 0x65, 0xbe, 0xb6, 0x5c, - 0x21, 0x65, 0xcb, 0x71, 0xc9, 0xc2, 0x16, 0x93, 0x4f, 0xb2, 0xad, 0x7b, 0x12, 0x46}; - - uint8_t buf[92] = {0}; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6655, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 2977 [("\137K3uf\128\132\202\FS\FS\224`z\196\144d\197\197\158\200y\233\ACK\184\220",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\171c\189\177zn\130)$\236\168",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\204\230!\136BX\135:J\204\170O\186\244\SO\140L2\187\"\132",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\185TD=\248\202\150\235L\245\DC4\184\200\145\EM\255\170\192\203\233\178\205\230\"w",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\138\215!n9\139\196\249\192\194\244\135Z'\136\194",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("S\170L\DC2\175\154u\143\228\222\"p8\148\148\170\224\213\161\189\147",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropSubscriptionIdentifier +// 29,PropResponseTopic "\171\193\SI\168\&5\FS\254\250",PropResponseInformation +// "\146\161\176w\ENQ\DC1\206\167\237\DLE\ACK\231@k\233\208g\154&:\132\217\148\240B",PropRetainAvailable +// 111,PropTopicAliasMaximum 4497,PropServerReference "f\234%l\243\128PT4\198",PropWildcardSubscriptionAvailable 55] +TEST(Subscribe5QCTest, Encode58) { + uint8_t pkt[] = {0x82, 0xc9, 0x1,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, 0x8f, 0xe4, 0xde, 0x22, 0x70, 0x38, 0x94, 0x94, 0xaa, 0xe0, 0xd5, 0xa1, 0xbd, 0x93, 0x0}; - uint8_t topic_bytes[] = {0x5f, 0xe1, 0x15, 0xa4, 0xc, 0x80, 0x56}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x92, 0xa1, 0x4a, 0x55, 0xae, 0x50, 0xd0, 0x6f, 0x67, 0xc9, 0x95, 0x84, 0x65, 0xbe, 0xb6, - 0x5c, 0x21, 0x65, 0xcb, 0x71, 0xc9, 0xc2, 0x16, 0x93, 0x4f, 0xb2, 0xad, 0x7b, 0x12, 0x46}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + uint8_t buf[214] = {0}; - uint8_t bytesprops0[] = {0xfb, 0x83, 0x1b, 0x1b, 0x8c, 0xf1, 0x75, 0x7, 0x90, 0x84, 0x72, 0x9, 0x90}; - uint8_t bytesprops1[] = {0xfa, 0x1d, 0xd0, 0xaa, 0x11, 0xd, 0xa3, 0xfb, 0x11, 0xe6, 0xf0, 0xd4, 0x75, 0x43}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x89, 0x4b, 0x33, 0x75, 0x66, 0x80, 0x84, 0xca, 0x1c, 0x1c, 0xe0, 0x60, 0x7a, + 0xc4, 0x90, 0x64, 0xc5, 0xc5, 0x9e, 0xc8, 0x79, 0xe9, 0x6, 0xb8, 0xdc}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xab, 0x63, 0xbd, 0xb1, 0x7a, 0x6e, 0x82, 0x29, 0x24, 0xec, 0xa8}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xcc, 0xe6, 0x21, 0x88, 0x42, 0x58, 0x87, 0x3a, 0x4a, 0xcc, 0xaa, + 0x4f, 0xba, 0xf4, 0xe, 0x8c, 0x4c, 0x32, 0xbb, 0x22, 0x84}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb9, 0x54, 0x44, 0x3d, 0xf8, 0xca, 0x96, 0xeb, 0x4c, 0xf5, 0x14, 0xb8, 0xc8, + 0x91, 0x19, 0xff, 0xaa, 0xc0, 0xcb, 0xe9, 0xb2, 0xcd, 0xe6, 0x22, 0x77}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x8a, 0xd7, 0x21, 0x6e, 0x39, 0x8b, 0xc4, 0xf9, + 0xc0, 0xc2, 0xf4, 0x87, 0x5a, 0x27, 0x88, 0xc2}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x53, 0xaa, 0x4c, 0x12, 0xaf, 0x9a, 0x75, 0x8f, 0xe4, 0xde, 0x22, + 0x70, 0x38, 0x94, 0x94, 0xaa, 0xe0, 0xd5, 0xa1, 0xbd, 0x93}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0xab, 0xc1, 0xf, 0xa8, 0x35, 0x1c, 0xfe, 0xfa}; + uint8_t bytesprops1[] = {0x92, 0xa1, 0xb0, 0x77, 0x5, 0x11, 0xce, 0xa7, 0xed, 0x10, 0x6, 0xe7, 0x40, + 0x6b, 0xe9, 0xd0, 0x67, 0x9a, 0x26, 0x3a, 0x84, 0xd9, 0x94, 0xf0, 0x42}; + uint8_t bytesprops2[] = {0x66, 0xea, 0x25, 0x6c, 0xf3, 0x80, 0x50, 0x54, 0x34, 0xc6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23589}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4497}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 55}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2977, 6, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\b\240\fA@\206\204-; -// R\nS$\n\194\ESCh\DC1P2\229\135$", _pubPktID = 32117, _pubBody = "[\a", _pubProps = [PropAuthenticationMethod -// "\245\213H\ACK\ETB\r(\216&\154",PropAuthenticationMethod "\EOT\250\167n;@\194V\250",PropRequestResponseInformation -// 56,PropResponseInformation "",PropMaximumQoS 212,PropAuthenticationMethod -// "\ETB\213\236\r/\SI\147\243\249i\147\246+@\137\157\139\211",PropSessionExpiryInterval 120,PropReceiveMaximum -// 5986,PropRequestProblemInformation 16,PropMessageExpiryInterval 30265,PropResponseInformation -// "\USA\218\200\232\ETB\ETB\142\184^`\253\227\247\243\143b\255\149\167\183\&15$[\211\228Q\200",PropCorrelationData -// "\144\236\151",PropSubscriptionIdentifier 22,PropResponseTopic "",PropSubscriptionIdentifier 23,PropWillDelayInterval -// 3333,PropMessageExpiryInterval 11209,PropMessageExpiryInterval 5188,PropTopicAliasMaximum 1410,PropReasonString -// "",PropResponseInformation "\129y\251\136",PropWillDelayInterval 13435,PropMaximumPacketSize 30116,PropReceiveMaximum -// 22947,PropSharedSubscriptionAvailable 223]} -TEST(Publish5QCTest, Encode56) { - uint8_t pkt[] = {0x35, 0xbc, 0x1, 0x0, 0x18, 0x8, 0xf0, 0xc, 0x41, 0x40, 0xce, 0xcc, 0x2d, 0x3b, 0x20, 0x52, - 0xa, 0x53, 0x24, 0xa, 0xc2, 0x1b, 0x68, 0x11, 0x50, 0x32, 0xe5, 0x87, 0x24, 0x7d, 0x75, 0x9c, - 0x1, 0x15, 0x0, 0xa, 0xf5, 0xd5, 0x48, 0x6, 0x17, 0xd, 0x28, 0xd8, 0x26, 0x9a, 0x15, 0x0, - 0x9, 0x4, 0xfa, 0xa7, 0x6e, 0x3b, 0x40, 0xc2, 0x56, 0xfa, 0x19, 0x38, 0x1a, 0x0, 0x0, 0x24, - 0xd4, 0x15, 0x0, 0x12, 0x17, 0xd5, 0xec, 0xd, 0x2f, 0xf, 0x93, 0xf3, 0xf9, 0x69, 0x93, 0xf6, - 0x2b, 0x40, 0x89, 0x9d, 0x8b, 0xd3, 0x11, 0x0, 0x0, 0x0, 0x78, 0x21, 0x17, 0x62, 0x17, 0x10, - 0x2, 0x0, 0x0, 0x76, 0x39, 0x1a, 0x0, 0x1d, 0x1f, 0x41, 0xda, 0xc8, 0xe8, 0x17, 0x17, 0x8e, - 0xb8, 0x5e, 0x60, 0xfd, 0xe3, 0xf7, 0xf3, 0x8f, 0x62, 0xff, 0x95, 0xa7, 0xb7, 0x31, 0x35, 0x24, - 0x5b, 0xd3, 0xe4, 0x51, 0xc8, 0x9, 0x0, 0x3, 0x90, 0xec, 0x97, 0xb, 0x16, 0x8, 0x0, 0x0, - 0xb, 0x17, 0x18, 0x0, 0x0, 0xd, 0x5, 0x2, 0x0, 0x0, 0x2b, 0xc9, 0x2, 0x0, 0x0, 0x14, - 0x44, 0x22, 0x5, 0x82, 0x1f, 0x0, 0x0, 0x1a, 0x0, 0x4, 0x81, 0x79, 0xfb, 0x88, 0x18, 0x0, - 0x0, 0x34, 0x7b, 0x27, 0x0, 0x0, 0x75, 0xa4, 0x21, 0x59, 0xa3, 0x2a, 0xdf, 0x5b, 0x7}; - - uint8_t buf[201] = {0}; +// SubscribeRequest 14796 [("dL\223\173OD1\b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\194\241\150\GS\SYN\239\&9\227\136c\138\225ItdFP",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropSubscriptionIdentifier +// 0,PropWillDelayInterval 9891,PropTopicAliasMaximum 19892,PropMessageExpiryInterval 10256,PropServerReference +// "\236gE\STX\NUL\193\149\249\&7lh\154~\198",PropServerKeepAlive 4439,PropTopicAlias +// 19774,PropRequestResponseInformation 33,PropMessageExpiryInterval 1725] +TEST(Subscribe5QCTest, Encode59) { + uint8_t pkt[] = {0x82, 0x4f, 0x39, 0xcc, 0x2d, 0xb, 0x0, 0x18, 0x0, 0x0, 0x26, 0xa3, 0x22, 0x4d, 0xb4, 0x2, 0x0, + 0x0, 0x28, 0x10, 0x1c, 0x0, 0xe, 0xec, 0x67, 0x45, 0x2, 0x0, 0xc1, 0x95, 0xf9, 0x37, 0x6c, 0x68, + 0x9a, 0x7e, 0xc6, 0x13, 0x11, 0x57, 0x23, 0x4d, 0x3e, 0x19, 0x21, 0x2, 0x0, 0x0, 0x6, 0xbd, 0x0, + 0x8, 0x64, 0x4c, 0xdf, 0xad, 0x4f, 0x44, 0x31, 0x8, 0x1, 0x0, 0x11, 0xc2, 0xf1, 0x96, 0x1d, 0x16, + 0xef, 0x39, 0xe3, 0x88, 0x63, 0x8a, 0xe1, 0x49, 0x74, 0x64, 0x46, 0x50, 0x1}; - uint8_t topic_bytes[] = {0x8, 0xf0, 0xc, 0x41, 0x40, 0xce, 0xcc, 0x2d, 0x3b, 0x20, 0x52, 0xa, - 0x53, 0x24, 0xa, 0xc2, 0x1b, 0x68, 0x11, 0x50, 0x32, 0xe5, 0x87, 0x24}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x5b, 0x7}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + uint8_t buf[91] = {0}; - uint8_t bytesprops0[] = {0xf5, 0xd5, 0x48, 0x6, 0x17, 0xd, 0x28, 0xd8, 0x26, 0x9a}; - uint8_t bytesprops1[] = {0x4, 0xfa, 0xa7, 0x6e, 0x3b, 0x40, 0xc2, 0x56, 0xfa}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x17, 0xd5, 0xec, 0xd, 0x2f, 0xf, 0x93, 0xf3, 0xf9, - 0x69, 0x93, 0xf6, 0x2b, 0x40, 0x89, 0x9d, 0x8b, 0xd3}; - uint8_t bytesprops4[] = {0x1f, 0x41, 0xda, 0xc8, 0xe8, 0x17, 0x17, 0x8e, 0xb8, 0x5e, 0x60, 0xfd, 0xe3, 0xf7, 0xf3, - 0x8f, 0x62, 0xff, 0x95, 0xa7, 0xb7, 0x31, 0x35, 0x24, 0x5b, 0xd3, 0xe4, 0x51, 0xc8}; - uint8_t bytesprops5[] = {0x90, 0xec, 0x97}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops8[] = {0x81, 0x79, 0xfb, 0x88}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x64, 0x4c, 0xdf, 0xad, 0x4f, 0x44, 0x31, 0x8}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc2, 0xf1, 0x96, 0x1d, 0x16, 0xef, 0x39, 0xe3, 0x88, + 0x63, 0x8a, 0xe1, 0x49, 0x74, 0x64, 0x46, 0x50}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xec, 0x67, 0x45, 0x2, 0x0, 0xc1, 0x95, 0xf9, 0x37, 0x6c, 0x68, 0x9a, 0x7e, 0xc6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 120}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5986}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30265}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3333}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11209}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5188}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1410}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13435}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30116}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22947}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9891}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19892}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10256}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4439}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19774}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1725}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32117, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14796, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12164 [("\215\191",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\183\&1\149d|\172\187\170\n\253\&0\247d\147\189",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\"-\141\168\ESCz\249\US;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\248\206\134zY'gO\232M\144X\242\ESC\196\210\242Ka",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\155\&9\136\225\249<@6\DC2C8VS\170\237\208=1\161t\156e\198R'\149\183",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\138h\162\"\239\145\&1Q\212\182\ETB\132\178T\203\211\181\250\190\ETX\US\154\132c\168\205\218\139\176\171",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\165\160\138\189\b1fH\233\ACK_\\\a\250\137\DEL\130\251\NUL\US\166\145[\162J",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\193\ETX\186T\206c}8/>H\163\255\173\&4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("<\STX\246d\230",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("e\229|n.\CAN\FS\177\249\229Y\"Fe\193\209\"\225+\217x\190ub\253|",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\170R!*\191)5\154\202|,\DEL};bb\224\&1\233\194M\DC4`&\NUL\131",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropServerReference +// "\141\160\211*\222\198\STX\229\139\DC4\160B`\DC18\246/\192C\212\195\149]i\221\149D\242I\142",PropReasonString +// "?\255z\246\231\"\163\DLE\218i%O\209\246\224\217U\EOT\235\151\159\222",PropServerKeepAlive 9806,PropServerReference +// ".\230\&2(m\254\178u=R\151\227g\188KW_\182\216\222]\"P\fz",PropRetainAvailable 41,PropRequestProblemInformation +// 13,PropRetainAvailable 59,PropResponseInformation +// "k\216\247\&2|,\152Z\206\152\188\129-(\208\DLE\EM\164\f\146\202\234",PropServerReference +// "2\217\RS\141\&6U\190b",PropMaximumQoS 153,PropMaximumPacketSize 20414,PropAuthenticationData +// "\201\226\193\CANS\"\CAN\FS",PropAuthenticationData ")Ag\208\v\n\241\229\176\171u\217"] +TEST(Subscribe5QCTest, Encode60) { + uint8_t pkt[] = { + 0x82, 0x90, 0x3, 0x2f, 0x84, 0xa4, 0x1, 0x1c, 0x0, 0x1e, 0x8d, 0xa0, 0xd3, 0x2a, 0xde, 0xc6, 0x2, 0xe5, 0x8b, + 0x14, 0xa0, 0x42, 0x60, 0x11, 0x38, 0xf6, 0x2f, 0xc0, 0x43, 0xd4, 0xc3, 0x95, 0x5d, 0x69, 0xdd, 0x95, 0x44, 0xf2, + 0x49, 0x8e, 0x1f, 0x0, 0x16, 0x3f, 0xff, 0x7a, 0xf6, 0xe7, 0x22, 0xa3, 0x10, 0xda, 0x69, 0x25, 0x4f, 0xd1, 0xf6, + 0xe0, 0xd9, 0x55, 0x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 0x31, 0xa1, 0x74, 0x9c, 0x65, 0xc6, 0x52, 0x27, 0x95, 0xb7, 0x0, 0x0, 0x1e, 0x8a, 0x68, 0xa2, 0x22, 0xef, 0x91, + 0x31, 0x51, 0xd4, 0xb6, 0x17, 0x84, 0xb2, 0x54, 0xcb, 0xd3, 0xb5, 0xfa, 0xbe, 0x3, 0x1f, 0x9a, 0x84, 0x63, 0xa8, + 0xcd, 0xda, 0x8b, 0xb0, 0xab, 0x2, 0x0, 0x19, 0xa5, 0xa0, 0x8a, 0xbd, 0x8, 0x31, 0x66, 0x48, 0xe9, 0x6, 0x5f, + 0x5c, 0x7, 0xfa, 0x89, 0x7f, 0x82, 0xfb, 0x0, 0x1f, 0xa6, 0x91, 0x5b, 0xa2, 0x4a, 0x2, 0x0, 0xf, 0xc1, 0x3, + 0xba, 0x54, 0xce, 0x63, 0x7d, 0x38, 0x2f, 0x3e, 0x48, 0xa3, 0xff, 0xad, 0x34, 0x0, 0x0, 0x5, 0x3c, 0x2, 0xf6, + 0x64, 0xe6, 0x1, 0x0, 0x1a, 0x65, 0xe5, 0x7c, 0x6e, 0x2e, 0x18, 0x1c, 0xb1, 0xf9, 0xe5, 0x59, 0x22, 0x46, 0x65, + 0xc1, 0xd1, 0x22, 0xe1, 0x2b, 0xd9, 0x78, 0xbe, 0x75, 0x62, 0xfd, 0x7c, 0x2, 0x0, 0x1a, 0xaa, 0x52, 0x21, 0x2a, + 0xbf, 0x29, 0x35, 0x9a, 0xca, 0x7c, 0x2c, 0x7f, 0x7d, 0x3b, 0x62, 0x62, 0xe0, 0x31, 0xe9, 0xc2, 0x4d, 0x14, 0x60, + 0x26, 0x0, 0x83, 0x2}; + + uint8_t buf[413] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xd7, 0xbf}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb7, 0x31, 0x95, 0x64, 0x7c, 0xac, 0xbb, 0xaa, + 0xa, 0xfd, 0x30, 0xf7, 0x64, 0x93, 0xbd}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x22, 0x2d, 0x8d, 0xa8, 0x1b, 0x7a, 0xf9, 0x1f, 0x3b}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf8, 0xce, 0x86, 0x7a, 0x59, 0x27, 0x67, 0x4f, 0xe8, 0x4d, + 0x90, 0x58, 0xf2, 0x1b, 0xc4, 0xd2, 0xf2, 0x4b, 0x61}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9b, 0x39, 0x88, 0xe1, 0xf9, 0x3c, 0x40, 0x36, 0x12, 0x43, 0x38, 0x56, 0x53, 0xaa, + 0xed, 0xd0, 0x3d, 0x31, 0xa1, 0x74, 0x9c, 0x65, 0xc6, 0x52, 0x27, 0x95, 0xb7}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8a, 0x68, 0xa2, 0x22, 0xef, 0x91, 0x31, 0x51, 0xd4, 0xb6, + 0x17, 0x84, 0xb2, 0x54, 0xcb, 0xd3, 0xb5, 0xfa, 0xbe, 0x3, + 0x1f, 0x9a, 0x84, 0x63, 0xa8, 0xcd, 0xda, 0x8b, 0xb0, 0xab}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa5, 0xa0, 0x8a, 0xbd, 0x8, 0x31, 0x66, 0x48, 0xe9, 0x6, 0x5f, 0x5c, 0x7, + 0xfa, 0x89, 0x7f, 0x82, 0xfb, 0x0, 0x1f, 0xa6, 0x91, 0x5b, 0xa2, 0x4a}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xc1, 0x3, 0xba, 0x54, 0xce, 0x63, 0x7d, 0x38, + 0x2f, 0x3e, 0x48, 0xa3, 0xff, 0xad, 0x34}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x3c, 0x2, 0xf6, 0x64, 0xe6}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x65, 0xe5, 0x7c, 0x6e, 0x2e, 0x18, 0x1c, 0xb1, 0xf9, 0xe5, 0x59, 0x22, 0x46, + 0x65, 0xc1, 0xd1, 0x22, 0xe1, 0x2b, 0xd9, 0x78, 0xbe, 0x75, 0x62, 0xfd, 0x7c}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xaa, 0x52, 0x21, 0x2a, 0xbf, 0x29, 0x35, 0x9a, 0xca, 0x7c, 0x2c, 0x7f, 0x7d, + 0x3b, 0x62, 0x62, 0xe0, 0x31, 0xe9, 0xc2, 0x4d, 0x14, 0x60, 0x26, 0x0, 0x83}; + lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x8d, 0xa0, 0xd3, 0x2a, 0xde, 0xc6, 0x2, 0xe5, 0x8b, 0x14, 0xa0, 0x42, 0x60, 0x11, 0x38, + 0xf6, 0x2f, 0xc0, 0x43, 0xd4, 0xc3, 0x95, 0x5d, 0x69, 0xdd, 0x95, 0x44, 0xf2, 0x49, 0x8e}; + uint8_t bytesprops1[] = {0x3f, 0xff, 0x7a, 0xf6, 0xe7, 0x22, 0xa3, 0x10, 0xda, 0x69, 0x25, + 0x4f, 0xd1, 0xf6, 0xe0, 0xd9, 0x55, 0x4, 0xeb, 0x97, 0x9f, 0xde}; + uint8_t bytesprops2[] = {0x2e, 0xe6, 0x32, 0x28, 0x6d, 0xfe, 0xb2, 0x75, 0x3d, 0x52, 0x97, 0xe3, 0x67, + 0xbc, 0x4b, 0x57, 0x5f, 0xb6, 0xd8, 0xde, 0x5d, 0x22, 0x50, 0xc, 0x7a}; + uint8_t bytesprops3[] = {0x6b, 0xd8, 0xf7, 0x32, 0x7c, 0x2c, 0x98, 0x5a, 0xce, 0x98, 0xbc, + 0x81, 0x2d, 0x28, 0xd0, 0x10, 0x19, 0xa4, 0xc, 0x92, 0xca, 0xea}; + uint8_t bytesprops4[] = {0x32, 0xd9, 0x1e, 0x8d, 0x36, 0x55, 0xbe, 0x62}; + uint8_t bytesprops5[] = {0xc9, 0xe2, 0xc1, 0x18, 0x53, 0x22, 0x18, 0x1c}; + uint8_t bytesprops6[] = {0x29, 0x41, 0x67, 0xd0, 0xb, 0xa, 0xf1, 0xe5, 0xb0, 0xab, 0x75, 0xd9}; -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\169\247+\235\ACK\192\145", -// _pubPktID = 0, _pubBody = "\a\197\204\DEL\222\198\153\205\174\176a\153\233u\246\203~z\166\212\229\207sp\US`\225", -// _pubProps = [PropReasonString "",PropAuthenticationMethod "\SIo{\154@\229\196\DEL\129EZ\159C",PropResponseInformation -// "\238\&9",PropTopicAliasMaximum 31169,PropResponseTopic -// "\131Xsu\250\206l\231\160WT\167\135\151\231\128\248\148\GS8p\189",PropRetainAvailable 70,PropResponseTopic -// "\238X\170{zo\223\233e\239\216y,\212\bt[\255\226\&3w\242",PropUserProperty "\162\ACKX" -// "\220\STX\197\249w\RS\160\244I&+\153\214\216\240fG\222\228\132",PropRequestResponseInformation 69,PropRetainAvailable -// 52,PropMaximumQoS 226,PropContentType "e\186\147\165\221\149\235`\244J\DC1\129\246",PropTopicAlias -// 28871,PropReceiveMaximum 22463]} -TEST(Publish5QCTest, Encode57) { - uint8_t pkt[] = {0x31, 0xad, 0x1, 0x0, 0x7, 0xa9, 0xf7, 0x2b, 0xeb, 0x6, 0xc0, 0x91, 0x87, 0x1, 0x1f, 0x0, - 0x0, 0x15, 0x0, 0xd, 0xf, 0x6f, 0x7b, 0x9a, 0x40, 0xe5, 0xc4, 0x7f, 0x81, 0x45, 0x5a, 0x9f, - 0x43, 0x1a, 0x0, 0x2, 0xee, 0x39, 0x22, 0x79, 0xc1, 0x8, 0x0, 0x16, 0x83, 0x58, 0x73, 0x75, - 0xfa, 0xce, 0x6c, 0xe7, 0xa0, 0x57, 0x54, 0xa7, 0x87, 0x97, 0xe7, 0x80, 0xf8, 0x94, 0x1d, 0x38, - 0x70, 0xbd, 0x25, 0x46, 0x8, 0x0, 0x16, 0xee, 0x58, 0xaa, 0x7b, 0x7a, 0x6f, 0xdf, 0xe9, 0x65, - 0xef, 0xd8, 0x79, 0x2c, 0xd4, 0x8, 0x74, 0x5b, 0xff, 0xe2, 0x33, 0x77, 0xf2, 0x26, 0x0, 0x3, - 0xa2, 0x6, 0x58, 0x0, 0x14, 0xdc, 0x2, 0xc5, 0xf9, 0x77, 0x1e, 0xa0, 0xf4, 0x49, 0x26, 0x2b, - 0x99, 0xd6, 0xd8, 0xf0, 0x66, 0x47, 0xde, 0xe4, 0x84, 0x19, 0x45, 0x25, 0x34, 0x24, 0xe2, 0x3, - 0x0, 0xd, 0x65, 0xba, 0x93, 0xa5, 0xdd, 0x95, 0xeb, 0x60, 0xf4, 0x4a, 0x11, 0x81, 0xf6, 0x23, - 0x70, 0xc7, 0x21, 0x57, 0xbf, 0x7, 0xc5, 0xcc, 0x7f, 0xde, 0xc6, 0x99, 0xcd, 0xae, 0xb0, 0x61, - 0x99, 0xe9, 0x75, 0xf6, 0xcb, 0x7e, 0x7a, 0xa6, 0xd4, 0xe5, 0xcf, 0x73, 0x70, 0x1f, 0x60, 0xe1}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9806}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20414}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops6}}}, + }; - uint8_t buf[186] = {0}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12164, 11, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12633 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\142\241\204\138,\174\131\149\199\160o\205\146",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("r\146\242\132\DC1\212\252\ETX\DC3\192\195\&3\169\231!",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\225\238p\223\135rJ\134'\ETB\DEL\137\131\NUL\223h\DC4\171\ESC\248",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("l1\185\139a\217\DEL7?\r\EM?",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("?\226!\129{\254Q",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\FSG=\NUL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\142gv\133\156\SYN\162\216C",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\152\212\158(t\138F\128{&?'-\194\239p\DC2H\132\131\SYNd\169\128\215\NAKa\217",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\179\212\228\145\130\161\198\&5\236H\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0}),("\196\&6?\162\212TA\205\USkt\b\208",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropRequestResponseInformation +// 215,PropResponseInformation "\238w\DC3_W$!\151P1\237xy\158\140!~~\EMl\240",PropAuthenticationMethod +// "'\151b\\\162\166\174\GSV\248>\144",PropRetainAvailable 182,PropRetainAvailable 38,PropCorrelationData +// "2\148\238\164i\145\156(\245U\SO"] +TEST(Subscribe5QCTest, Encode62) { + uint8_t pkt[] = {0x82, 0xac, 0x1, 0x54, 0x8a, 0x3b, 0x19, 0xd7, 0x1a, 0x0, 0x15, 0xee, 0x77, 0x13, 0x5f, 0x57, + 0x24, 0x21, 0x97, 0x50, 0x31, 0xed, 0x78, 0x79, 0x9e, 0x8c, 0x21, 0x7e, 0x7e, 0x19, 0x6c, 0xf0, + 0x15, 0x0, 0xc, 0x27, 0x97, 0x62, 0x5c, 0xa2, 0xa6, 0xae, 0x1d, 0x56, 0xf8, 0x3e, 0x90, 0x25, + 0xb6, 0x25, 0x26, 0x9, 0x0, 0xb, 0x32, 0x94, 0xee, 0xa4, 0x69, 0x91, 0x9c, 0x28, 0xf5, 0x55, + 0xe, 0x0, 0xd, 0xd9, 0xc1, 0x92, 0x85, 0xe9, 0xed, 0x38, 0x34, 0x2, 0x7c, 0x39, 0xf, 0x5e, + 0x1, 0x0, 0xb, 0x21, 0xbf, 0xfa, 0x54, 0x3e, 0xe2, 0x21, 0x81, 0x7b, 0xfe, 0x51, 0x1, 0x0, + 0x4, 0x1c, 0x47, 0x3d, 0x0, 0x1, 0x0, 0x9, 0x8e, 0x67, 0x76, 0x85, 0x9c, 0x16, 0xa2, 0xd8, + 0x43, 0x1, 0x0, 0x1c, 0x98, 0xd4, 0x9e, 0x28, 0x74, 0x8a, 0x46, 0x80, 0x7b, 0x26, 0x3f, 0x27, + 0x2d, 0xc2, 0xef, 0x70, 0x12, 0x48, 0x84, 0x83, 0x16, 0x64, 0xa9, 0x80, 0xd7, 0x15, 0x61, 0xd9, + 0x2, 0x0, 0xb, 0xb3, 0xd4, 0xe4, 0x91, 0x82, 0xa1, 0xc6, 0x35, 0xec, 0x48, 0x98, 0x0, 0x0, + 0xd, 0xc4, 0x36, 0x3f, 0xa2, 0xd4, 0x54, 0x41, 0xcd, 0x1f, 0x6b, 0x74, 0x8, 0xd0, 0x2}; + + uint8_t buf[185] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xd9, 0xc1, 0x92, 0x85, 0xe9, 0xed, 0x38, 0x34, 0x2, 0x7c, 0x39, 0xf, 0x5e}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x21, 0xbf, 0xfa, 0x54, 0x3e, 0xe2, 0x21, 0x81, 0x7b, 0xfe, 0x51}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1c, 0x47, 0x3d, 0x0}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8e, 0x67, 0x76, 0x85, 0x9c, 0x16, 0xa2, 0xd8, 0x43}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x98, 0xd4, 0x9e, 0x28, 0x74, 0x8a, 0x46, 0x80, 0x7b, 0x26, + 0x3f, 0x27, 0x2d, 0xc2, 0xef, 0x70, 0x12, 0x48, 0x84, 0x83, + 0x16, 0x64, 0xa9, 0x80, 0xd7, 0x15, 0x61, 0xd9}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb3, 0xd4, 0xe4, 0x91, 0x82, 0xa1, 0xc6, 0x35, 0xec, 0x48, 0x98}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc4, 0x36, 0x3f, 0xa2, 0xd4, 0x54, 0x41, 0xcd, 0x1f, 0x6b, 0x74, 0x8, 0xd0}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0xee, 0x77, 0x13, 0x5f, 0x57, 0x24, 0x21, 0x97, 0x50, 0x31, 0xed, + 0x78, 0x79, 0x9e, 0x8c, 0x21, 0x7e, 0x7e, 0x19, 0x6c, 0xf0}; + uint8_t bytesprops1[] = {0x27, 0x97, 0x62, 0x5c, 0xa2, 0xa6, 0xae, 0x1d, 0x56, 0xf8, 0x3e, 0x90}; + uint8_t bytesprops2[] = {0x32, 0x94, 0xee, 0xa4, 0x69, 0x91, 0x9c, 0x28, 0xf5, 0x55, 0xe}; -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\150\251\130\251\166R)\184\\I^\183\212@\189\150\222", _pubPktID = 0, _pubBody = "\139}\228\225\&9", _pubProps = -// [PropCorrelationData "\170\SUB",PropWildcardSubscriptionAvailable 102,PropSharedSubscriptionAvailable -// 236,PropSubscriptionIdentifierAvailable 89,PropServerReference -// "n\142\NAK\184TnXQ!f~Y\SO\b\CAN\ESC\138\178\197\243\SOHg\ACK\178eH<",PropReceiveMaximum -// 22935,PropSubscriptionIdentifierAvailable 136,PropServerKeepAlive 3204]} -TEST(Publish5QCTest, Encode58) { - uint8_t pkt[] = {0x30, 0x4a, 0x0, 0x11, 0x96, 0xfb, 0x82, 0xfb, 0xa6, 0x52, 0x29, 0xb8, 0x5c, 0x49, 0x5e, 0xb7, - 0xd4, 0x40, 0xbd, 0x96, 0xde, 0x31, 0x9, 0x0, 0x2, 0xaa, 0x1a, 0x28, 0x66, 0x2a, 0xec, 0x29, - 0x59, 0x1c, 0x0, 0x1b, 0x6e, 0x8e, 0x15, 0xb8, 0x54, 0x6e, 0x58, 0x51, 0x21, 0x66, 0x7e, 0x59, - 0xe, 0x8, 0x18, 0x1b, 0x8a, 0xb2, 0xc5, 0xf3, 0x1, 0x67, 0x6, 0xb2, 0x65, 0x48, 0x3c, 0x21, - 0x59, 0x97, 0x29, 0x88, 0x13, 0xc, 0x84, 0x8b, 0x7d, 0xe4, 0xe1, 0x39}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops2}}}, + }; - uint8_t buf[86] = {0}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21642, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 17671 [("u\219]\165\215\137\250\193O\129\136\181\180\tG@\188t",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\250\141\FS\155\a\192Q}\186\203\ACK\DEL\246\233\SUB\206\&2/\240\137\189'F$\189dq\159\142h",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\SYN\189~\178VN\200\201\v\165\218\230\166\ETB",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("L\136+\152\143",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\139\202\184\152g\f\231`",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [PropResponseInformation +// "\146V\195\218\217\DC4H\209q\GS",PropPayloadFormatIndicator 34,PropContentType +// "6\a0\fVG^\148\132\138.\137\220\DC4\187\"=\188.",PropSubscriptionIdentifierAvailable 205,PropResponseTopic +// "\180\154\201r7N\146\195\"\175\198A)\171\250\155\133\t\228J\STX\172[\172",PropAssignedClientIdentifier +// "",PropServerKeepAlive 12008,PropReasonString "\198S\163,(\242\243",PropAuthenticationData +// "\253\131\189\&2\190*\208\DC4\DC2\149\220\184",PropSubscriptionIdentifier 28,PropRequestResponseInformation +// 174,PropCorrelationData "j\DLE\152\248\171'Y\147\DEL\233 \139\196\253b?\"\r\FS\191\163\159y"] +TEST(Subscribe5QCTest, Encode63) { + uint8_t pkt[] = {0x82, 0xe3, 0x1, 0x45, 0x7, 0x7f, 0x1a, 0x0, 0xa, 0x92, 0x56, 0xc3, 0xda, 0xd9, 0x14, 0x48, 0xd1, + 0x71, 0x1d, 0x1, 0x22, 0x3, 0x0, 0x13, 0x36, 0x7, 0x30, 0xc, 0x56, 0x47, 0x5e, 0x94, 0x84, 0x8a, + 0x2e, 0x89, 0xdc, 0x14, 0xbb, 0x22, 0x3d, 0xbc, 0x2e, 0x29, 0xcd, 0x8, 0x0, 0x18, 0xb4, 0x9a, 0xc9, + 0x72, 0x37, 0x4e, 0x92, 0xc3, 0x22, 0xaf, 0xc6, 0x41, 0x29, 0xab, 0xfa, 0x9b, 0x85, 0x9, 0xe4, 0x4a, + 0x2, 0xac, 0x5b, 0xac, 0x12, 0x0, 0x0, 0x13, 0x2e, 0xe8, 0x1f, 0x0, 0x7, 0xc6, 0x53, 0xa3, 0x2c, + 0x28, 0xf2, 0xf3, 0x16, 0x0, 0xc, 0xfd, 0x83, 0xbd, 0x32, 0xbe, 0x2a, 0xd0, 0x14, 0x12, 0x95, 0xdc, + 0xb8, 0xb, 0x1c, 0x19, 0xae, 0x9, 0x0, 0x17, 0x6a, 0x10, 0x98, 0xf8, 0xab, 0x27, 0x59, 0x93, 0x7f, + 0xe9, 0x20, 0x8b, 0xc4, 0xfd, 0x62, 0x3f, 0x22, 0xd, 0x1c, 0xbf, 0xa3, 0x9f, 0x79, 0x0, 0x12, 0x75, + 0xdb, 0x5d, 0xa5, 0xd7, 0x89, 0xfa, 0xc1, 0x4f, 0x81, 0x88, 0xb5, 0xb4, 0x9, 0x47, 0x40, 0xbc, 0x74, + 0x1, 0x0, 0x0, 0x1, 0x0, 0x1e, 0xfa, 0x8d, 0x1c, 0x9b, 0x7, 0xc0, 0x51, 0x7d, 0xba, 0xcb, 0x6, + 0x7f, 0xf6, 0xe9, 0x1a, 0xce, 0x32, 0x2f, 0xf0, 0x89, 0xbd, 0x27, 0x46, 0x24, 0xbd, 0x64, 0x71, 0x9f, + 0x8e, 0x68, 0x0, 0x0, 0xe, 0x16, 0xbd, 0x7e, 0xb2, 0x56, 0x4e, 0xc8, 0xc9, 0xb, 0xa5, 0xda, 0xe6, + 0xa6, 0x17, 0x1, 0x0, 0x5, 0x4c, 0x88, 0x2b, 0x98, 0x8f, 0x2, 0x0, 0x8, 0x8b, 0xca, 0xb8, 0x98, + 0x67, 0xc, 0xe7, 0x60, 0x1, 0x0, 0x1, 0x5c, 0x2}; - uint8_t topic_bytes[] = {0x96, 0xfb, 0x82, 0xfb, 0xa6, 0x52, 0x29, 0xb8, 0x5c, - 0x49, 0x5e, 0xb7, 0xd4, 0x40, 0xbd, 0x96, 0xde}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x8b, 0x7d, 0xe4, 0xe1, 0x39}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + uint8_t buf[240] = {0}; - uint8_t bytesprops0[] = {0xaa, 0x1a}; - uint8_t bytesprops1[] = {0x6e, 0x8e, 0x15, 0xb8, 0x54, 0x6e, 0x58, 0x51, 0x21, 0x66, 0x7e, 0x59, 0xe, 0x8, - 0x18, 0x1b, 0x8a, 0xb2, 0xc5, 0xf3, 0x1, 0x67, 0x6, 0xb2, 0x65, 0x48, 0x3c}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x75, 0xdb, 0x5d, 0xa5, 0xd7, 0x89, 0xfa, 0xc1, 0x4f, + 0x81, 0x88, 0xb5, 0xb4, 0x9, 0x47, 0x40, 0xbc, 0x74}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xfa, 0x8d, 0x1c, 0x9b, 0x7, 0xc0, 0x51, 0x7d, 0xba, 0xcb, + 0x6, 0x7f, 0xf6, 0xe9, 0x1a, 0xce, 0x32, 0x2f, 0xf0, 0x89, + 0xbd, 0x27, 0x46, 0x24, 0xbd, 0x64, 0x71, 0x9f, 0x8e, 0x68}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x16, 0xbd, 0x7e, 0xb2, 0x56, 0x4e, 0xc8, 0xc9, 0xb, 0xa5, 0xda, 0xe6, 0xa6, 0x17}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x4c, 0x88, 0x2b, 0x98, 0x8f}; + lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8b, 0xca, 0xb8, 0x98, 0x67, 0xc, 0xe7, 0x60}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x5c}; + lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x92, 0x56, 0xc3, 0xda, 0xd9, 0x14, 0x48, 0xd1, 0x71, 0x1d}; + uint8_t bytesprops1[] = {0x36, 0x7, 0x30, 0xc, 0x56, 0x47, 0x5e, 0x94, 0x84, 0x8a, + 0x2e, 0x89, 0xdc, 0x14, 0xbb, 0x22, 0x3d, 0xbc, 0x2e}; + uint8_t bytesprops2[] = {0xb4, 0x9a, 0xc9, 0x72, 0x37, 0x4e, 0x92, 0xc3, 0x22, 0xaf, 0xc6, 0x41, + 0x29, 0xab, 0xfa, 0x9b, 0x85, 0x9, 0xe4, 0x4a, 0x2, 0xac, 0x5b, 0xac}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0xc6, 0x53, 0xa3, 0x2c, 0x28, 0xf2, 0xf3}; + uint8_t bytesprops5[] = {0xfd, 0x83, 0xbd, 0x32, 0xbe, 0x2a, 0xd0, 0x14, 0x12, 0x95, 0xdc, 0xb8}; + uint8_t bytesprops6[] = {0x6a, 0x10, 0x98, 0xf8, 0xab, 0x27, 0x59, 0x93, 0x7f, 0xe9, 0x20, 0x8b, + 0xc4, 0xfd, 0x62, 0x3f, 0x22, 0xd, 0x1c, 0xbf, 0xa3, 0x9f, 0x79}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22935}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3204}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12008}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\161n\174\237\249", _pubPktID = 0, -// _pubBody = "YFq\199\251\158-\155S\194}\250\NULjMrM\ESC/6f\DC3\140", _pubProps = [PropMaximumQoS -// 255,PropAuthenticationData -// "!\241\DC4%K\DC1\226\&2\DLE\162\189\&7\190x\249\140\196\218$kI\167P\207\155\166x\132x\201",PropSubscriptionIdentifier -// 7,PropAuthenticationMethod -// "\"j_\212zR\159\CAN\207\248\207+b\159\DEL\EOT\163\225\203\192\NAK\129\240#\215\ACK'\185\155",PropServerReference -// "\SYNa{q&\206\\\245\177\195Mk",PropTopicAlias 14546,PropUserProperty -// "\237\STX\247\154?l\fK\189\242\234B\224\f\DC3\233\212\158\219\183\157\163\200\202\EOT" -// "\ACK\174",PropMessageExpiryInterval 18572,PropResponseInformation -// "\160\ACK\142\179\155\168\252(\235\128n2\249t\\=EiQ\202\SOH\ACK.\135\131\194",PropRequestProblemInformation -// 27,PropReceiveMaximum 31642,PropCorrelationData "~\143Y\242\NAK\FS\202\180\SO\137+\226\GS\205|\229",PropTopicAlias -// 1761,PropTopicAlias 14795,PropMessageExpiryInterval 9727]} -TEST(Publish5QCTest, Encode59) { + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17671, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 18903 [("\245\147\176",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("sQ\169h\ACK\237\155\fg\232\206\138",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSubscriptionIdentifier +// 7,PropTopicAliasMaximum 1496,PropResponseInformation "]\177\198?\210\a",PropRetainAvailable +// 103,PropMessageExpiryInterval 4264,PropMaximumPacketSize 17108,PropSessionExpiryInterval +// 13290,PropAuthenticationMethod "\139\169\181\186(]\220\a",PropAuthenticationMethod +// "\251vk\EM<8\157\SYN\172\&2\185\171\143\228\243\&0r\132B\251\&26\151\217-\225",PropContentType +// "X\147\161u\230\184\171\226\184[S\b\129ru\234\138\169",PropResponseTopic "\214*\r\155\154",PropServerKeepAlive +// 21747,PropMaximumPacketSize 31882,PropMessageExpiryInterval 2727,PropReasonString +// ":\193#\154|(8\182\185!\v0\240\148\147R\248C\146\205\US\STX\168\247\205\242\243\179",PropReasonString +// "\246\157'\205\&1\ETBS",PropWildcardSubscriptionAvailable 213,PropRetainAvailable +// 20,PropSubscriptionIdentifierAvailable 73,PropAssignedClientIdentifier +// "\ENQ.\158\SOHZK\228\173\138\202d&3\249\219\233*\229b:\236\DLE\CANQ\232\211DS",PropReasonString +// "y\209l\SO\152\198y/\132\251\251~\t\DC2\246\ETXj",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\134/\US\STX\249\130\n\159\"\235\ETB\FS\163\USR\194\156d>\213\144=\161/*'\231\"",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\DEL\250Oc\141\225\&8\234B\179",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\141\218\241\136\246\183d\251\&3\182\235#\208\bPH\170Y\194",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\215N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS +// = QoS1}),("}'\141;\170\&26H\213Yh\130\RS\178\DLEuL\155\134\229\210\138\DLEi\GS~S",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\220\&6\DC2a\245\161\nd\210\tR\238\159Z1\236\207\215\181\204\ACKb}\252\217",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("f\DLE\USF\DC2\210D\237A\172\246;\FS"] +TEST(Subscribe5QCTest, Encode66) { + uint8_t pkt[] = { + 0x82, 0x9f, 0x3, 0x12, 0x7c, 0xfe, 0x1, 0x8, 0x0, 0xf, 0x7d, 0xd9, 0x43, 0xc7, 0x90, 0x77, 0xcd, 0xa3, 0xa4, + 0xfa, 0x2a, 0x51, 0xd, 0xbc, 0x88, 0x27, 0x0, 0x0, 0xa, 0x53, 0x12, 0x0, 0xb, 0xf0, 0x73, 0xca, 0xd0, 0xfa, + 0x5b, 0x62, 0x63, 0x84, 0x73, 0x50, 0xb, 0x8, 0x26, 0x0, 0x19, 0x95, 0x6d, 0x2b, 0xa6, 0xa2, 0x7d, 0xa, 0x5b, + 0x6f, 0xfc, 0xa9, 0x97, 0xa8, 0x12, 0x14, 0xd9, 0xb8, 0x95, 0x95, 0x1f, 0x34, 0x13, 0x93, 0xf1, 0x6, 0x0, 0xc, + 0x8f, 0x24, 0xc3, 0x7b, 0xaf, 0xad, 0x7e, 0x95, 0xf9, 0xb8, 0xea, 0x86, 0x23, 0x62, 0x3a, 0xb, 0x19, 0x19, 0x61, + 0x17, 0xd9, 0x3, 0x0, 0x18, 0x58, 0xff, 0x8d, 0x5c, 0xc2, 0x9b, 0x1c, 0xa0, 0x14, 0x82, 0x5a, 0x59, 0xdf, 0x4e, + 0xe, 0x7e, 0xec, 0xce, 0x54, 0x58, 0x87, 0xf, 0x12, 0x39, 0x29, 0x10, 0x1a, 0x0, 0x18, 0xc7, 0x12, 0x1a, 0x9a, + 0xd5, 0x9f, 0xd1, 0x9, 0xa3, 0xaa, 0xf4, 0xee, 0x59, 0x16, 0x5b, 0x8d, 0x68, 0x47, 0xb, 0x48, 0x82, 0x29, 0xe, + 0xa1, 0x1f, 0x0, 0xe, 0x96, 0xf2, 0x9c, 0x29, 0x72, 0x41, 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, 0xf3, 0xc1, 0x4d, 0x7a, 0x26, 0x97, 0xf0, 0x69, 0x8a, 0xab, 0x3d, 0xde, + 0xe2, 0xa9, 0x28, 0xfb, 0x92, 0x95, 0x6b, 0x33, 0xb0, 0x74, 0xce, 0xa1, 0x4e, 0x7e, 0xa5, 0x0, 0x0, 0x16, 0xb1, + 0xd1, 0xf2, 0xad, 0x55, 0xe8, 0x3, 0x2a, 0xd9, 0x69, 0xfa, 0xa7, 0x4a, 0x68, 0xf0, 0x1, 0xd2, 0xe6, 0x19, 0x96, + 0x7a, 0xcd, 0x2, 0x0, 0xd, 0xb7, 0xbd, 0x9f, 0x3f, 0x2c, 0xfb, 0xf6, 0x7f, 0x1c, 0x24, 0x86, 0x86, 0x7d, 0x1}; - uint8_t buf[190] = {0}; + uint8_t buf[428] = {0}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x89, 0xb3, 0x4d, 0x4c, 0xec}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; - - uint8_t bytesprops0[] = {0xce, 0x14, 0x1e, 0x99, 0xd3, 0x63, 0x2c, 0xd2, 0x55, 0x4f, 0xd1, 0x52, 0x7b, 0x6f, - 0x40, 0x7b, 0xb8, 0x93, 0xc3, 0xb7, 0x20, 0xc5, 0x28, 0x81, 0x81, 0xe8, 0x3c, 0x6b}; - uint8_t bytesprops1[] = {0xdc, 0x9, 0x6d, 0x30, 0xbe, 0x5c, 0x1e, 0x5, 0x91, 0xfa, 0x38, 0xe0}; - uint8_t bytesprops2[] = {0x68, 0xd4, 0x4}; - uint8_t bytesprops4[] = {0xdf, 0xee, 0xb1, 0xce, 0xa3, 0xd5, 0x5b, 0xcb, 0x26, 0x7, 0xf0, 0x13, 0x6f, - 0x67, 0x48, 0x70, 0x5, 0xa9, 0x97, 0x50, 0x8f, 0x31, 0xc9, 0xc0, 0xbb}; - uint8_t bytesprops3[] = {0xb9, 0x86, 0xf2, 0xb, 0x15, 0xe7, 0x40, 0x2d, 0x49, 0x47}; - uint8_t bytesprops5[] = {0xa1, 0x3b, 0x15, 0xa9}; - uint8_t bytesprops6[] = {0x19, 0x9f, 0xd8, 0x47, 0x1f, 0xf7}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops8[] = {0x7, 0xa6, 0x75, 0xd9, 0x39, 0xef, 0x6d, 0xf9, 0x4e, 0x51, 0x25, 0x92, 0xfc, - 0xbc, 0x79, 0x4a, 0x57, 0x4, 0xce, 0x23, 0xba, 0x4, 0x9d, 0x79, 0xa4}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x6a, 0xa0, 0x90, 0x83, 0xc7, 0x95, 0x89, 0xcd, 0xb4, 0x20, + 0x30, 0x5c, 0xee, 0x27, 0xb, 0xef, 0x25, 0x8c, 0x79, 0x82, + 0xa6, 0x10, 0x46, 0x57, 0xc4, 0x2b, 0x2f, 0x1a, 0xaf, 0x6b}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa5, 0xd0, 0x44, 0x52, 0xba, 0xa4, 0xa9, 0x2c, 0xf7, + 0xb9, 0x1d, 0x38, 0x2e, 0xfb, 0x2c, 0x6a, 0x39, 0x5}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xec, 0x31, 0xb4, 0x65, 0x9f, 0x78, 0xbe, 0x7b, 0x6, 0x65, 0xde, 0x35, 0x96}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa9, 0x1b, 0xa4, 0x2a, 0x77, 0x33, 0x58}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x88, 0xb, 0x89}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf3, 0xc1, 0x4d, 0x7a, 0x26, 0x97, 0xf0, 0x69, 0x8a, 0xab, 0x3d, 0xde, 0xe2, 0xa9, + 0x28, 0xfb, 0x92, 0x95, 0x6b, 0x33, 0xb0, 0x74, 0xce, 0xa1, 0x4e, 0x7e, 0xa5}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xb1, 0xd1, 0xf2, 0xad, 0x55, 0xe8, 0x3, 0x2a, 0xd9, 0x69, 0xfa, + 0xa7, 0x4a, 0x68, 0xf0, 0x1, 0xd2, 0xe6, 0x19, 0x96, 0x7a, 0xcd}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xb7, 0xbd, 0x9f, 0x3f, 0x2c, 0xfb, 0xf6, 0x7f, 0x1c, 0x24, 0x86, 0x86, 0x7d}; + lwmqtt_string_t topic_filter_s7 = {13, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x7d, 0xd9, 0x43, 0xc7, 0x90, 0x77, 0xcd, 0xa3, 0xa4, 0xfa, 0x2a, 0x51, 0xd, 0xbc, 0x88}; + uint8_t bytesprops1[] = {0xf0, 0x73, 0xca, 0xd0, 0xfa, 0x5b, 0x62, 0x63, 0x84, 0x73, 0x50}; + uint8_t bytesprops3[] = {0x8f, 0x24, 0xc3, 0x7b, 0xaf, 0xad, 0x7e, 0x95, 0xf9, 0xb8, 0xea, 0x86}; + uint8_t bytesprops2[] = {0x95, 0x6d, 0x2b, 0xa6, 0xa2, 0x7d, 0xa, 0x5b, 0x6f, 0xfc, 0xa9, 0x97, 0xa8, + 0x12, 0x14, 0xd9, 0xb8, 0x95, 0x95, 0x1f, 0x34, 0x13, 0x93, 0xf1, 0x6}; + uint8_t bytesprops4[] = {0x58, 0xff, 0x8d, 0x5c, 0xc2, 0x9b, 0x1c, 0xa0, 0x14, 0x82, 0x5a, 0x59, + 0xdf, 0x4e, 0xe, 0x7e, 0xec, 0xce, 0x54, 0x58, 0x87, 0xf, 0x12, 0x39}; + uint8_t bytesprops5[] = {0xc7, 0x12, 0x1a, 0x9a, 0xd5, 0x9f, 0xd1, 0x9, 0xa3, 0xaa, 0xf4, 0xee, + 0x59, 0x16, 0x5b, 0x8d, 0x68, 0x47, 0xb, 0x48, 0x82, 0x29, 0xe, 0xa1}; + uint8_t bytesprops6[] = {0x96, 0xf2, 0x9c, 0x29, 0x72, 0x41, 0x31, 0x90, 0x21, 0xe6, 0x10, 0xdb, 0x1e, 0x1e}; + uint8_t bytesprops7[] = {0x5d, 0x23, 0x1, 0x92, 0x6f, 0x65, 0x8c, 0x50, 0x59, 0x2a, 0xf5, 0x41, 0x47, 0xe5, 0xf3}; + uint8_t bytesprops8[] = {0xb0, 0x8d, 0x79, 0x63, 0xaf, 0x44, 0xed, 0xe7, 0xf7, 0x38, 0x5b}; + uint8_t bytesprops9[] = {0x12, 0xdc, 0x70, 0x3f, 0xf1, 0xd4, 0xfb, 0xc5, 0x3d, 0xd3, + 0x37, 0x90, 0xdb, 0x73, 0x5d, 0x83, 0x49, 0x8d, 0xf}; + uint8_t bytesprops10[] = {0x2d, 0xf9, 0x91, 0xe5, 0xa7, 0x8c, 0xb2, 0xdf, 0xed, 0xbb, 0x3e, 0x10, + 0x1f, 0x46, 0x12, 0xd2, 0x44, 0xed, 0x41, 0xac, 0xf6, 0x3b, 0x1c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14480}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26531}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23124}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops3}, .v = {25, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 115}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26127}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2643}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops2}, .v = {12, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25146}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24261}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 4694, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\ETB2\218\142q%", _pubPktID = 16088, -// _pubBody = "\251hR\153\SI\f\226", _pubProps = [PropAuthenticationData -// "oo\241\145\181\245\143-\161x6\246.L\172\172\US&\140Ab\222^\222K\SO\136",PropContentType -// "\172\190\FSD_\DLEP\f\140M\133\213\212Y\145U#\247\170",PropContentType "\CAN -// ES:\196\200\173\155\187Ro",PropUserProperty "0" "\233\248\DC4\211\167\211\&5\230\177\v\143",PropMaximumQoS -// 229,PropWildcardSubscriptionAvailable 16,PropRequestProblemInformation 71,PropMessageExpiryInterval -// 20628,PropUserProperty "eyX!+\220o" "\"\167\173\154ue\STXA",PropAssignedClientIdentifier -// ":\167\208R\vsQ^\EOTa:?\231&z",PropAssignedClientIdentifier "\201\243i\243\137\ENQ\ENQ\165\181",PropContentType -// "\149",PropResponseInformation "\246\ESC~,\238\215\&8$",PropMaximumQoS 172,PropMessageExpiryInterval -// 26351,PropRequestResponseInformation 138,PropRequestProblemInformation 224,PropContentType -// "\225\160'7j\US\228\ETB\163\204\198#\227\RS\DLE\179\141\SI\166",PropUserProperty -// "\255\215\b\189E\128@\RS\169\138\132\232\DC2Vot\165\174\209\177\237\ETX\179\205iI-\251s\210" -// "\195/\184\193\DC4\142\216",PropPayloadFormatIndicator 253,PropSubscriptionIdentifier 24,PropWillDelayInterval -// 23656,PropServerKeepAlive 11331,PropSubscriptionIdentifierAvailable 5,PropTopicAlias 16169,PropMaximumQoS 126]} -TEST(Publish5QCTest, Encode61) { - uint8_t pkt[] = { - 0x33, 0x91, 0x2, 0x0, 0x6, 0x17, 0x32, 0xda, 0x8e, 0x71, 0x25, 0x3e, 0xd8, 0xfe, 0x1, 0x16, 0x0, 0x1b, 0x6f, - 0x6f, 0xf1, 0x91, 0xb5, 0xf5, 0x8f, 0x2d, 0xa1, 0x78, 0x36, 0xf6, 0x2e, 0x4c, 0xac, 0xac, 0x1f, 0x26, 0x8c, 0x41, - 0x62, 0xde, 0x5e, 0xde, 0x4b, 0xe, 0x88, 0x3, 0x0, 0x13, 0xac, 0xbe, 0x1c, 0x44, 0x5f, 0x10, 0x50, 0xc, 0x8c, - 0x4d, 0x85, 0xd5, 0xd4, 0x59, 0x91, 0x55, 0x23, 0xf7, 0xaa, 0x3, 0x0, 0xc, 0x18, 0x20, 0x45, 0x53, 0x3a, 0xc4, -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5, 0x23, 0x3f, - 0x29, 0x24, 0x7e, 0xfb, 0x68, 0x52, 0x99, 0xf, 0xc, 0xe2}; - - uint8_t buf[286] = {0}; - - uint8_t topic_bytes[] = {0x17, 0x32, 0xda, 0x8e, 0x71, 0x25}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xfb, 0x68, 0x52, 0x99, 0xf, 0xc, 0xe2}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; - - uint8_t bytesprops0[] = {0x6f, 0x6f, 0xf1, 0x91, 0xb5, 0xf5, 0x8f, 0x2d, 0xa1, 0x78, 0x36, 0xf6, 0x2e, 0x4c, - 0xac, 0xac, 0x1f, 0x26, 0x8c, 0x41, 0x62, 0xde, 0x5e, 0xde, 0x4b, 0xe, 0x88}; - uint8_t bytesprops1[] = {0xac, 0xbe, 0x1c, 0x44, 0x5f, 0x10, 0x50, 0xc, 0x8c, 0x4d, - 0x85, 0xd5, 0xd4, 0x59, 0x91, 0x55, 0x23, 0xf7, 0xaa}; - uint8_t bytesprops2[] = {0x18, 0x20, 0x45, 0x53, 0x3a, 0xc4, 0xc8, 0xad, 0x9b, 0xbb, 0x52, 0x6f}; - uint8_t bytesprops4[] = {0xe9, 0xf8, 0x14, 0xd3, 0xa7, 0xd3, 0x35, 0xe6, 0xb1, 0xb, 0x8f}; - uint8_t bytesprops3[] = {0x30}; - uint8_t bytesprops6[] = {0x22, 0xa7, 0xad, 0x9a, 0x75, 0x65, 0x2, 0x41}; - uint8_t bytesprops5[] = {0x65, 0x79, 0x58, 0x21, 0x2b, 0xdc, 0x6f}; - uint8_t bytesprops7[] = {0x3a, 0xa7, 0xd0, 0x52, 0xb, 0x73, 0x51, 0x5e, 0x4, 0x61, 0x3a, 0x3f, 0xe7, 0x26, 0x7a}; - uint8_t bytesprops8[] = {0xc9, 0xf3, 0x69, 0xf3, 0x89, 0x5, 0x5, 0xa5, 0xb5}; - uint8_t bytesprops9[] = {0x95}; - uint8_t bytesprops10[] = {0xf6, 0x1b, 0x7e, 0x2c, 0xee, 0xd7, 0x38, 0x24}; - uint8_t bytesprops11[] = {0xe1, 0xa0, 0x27, 0x37, 0x6a, 0x1f, 0xe4, 0x17, 0xa3, 0xcc, - 0xc6, 0x23, 0xe3, 0x1e, 0x10, 0xb3, 0x8d, 0xf, 0xa6}; - uint8_t bytesprops13[] = {0xc3, 0x2f, 0xb8, 0xc1, 0x14, 0x8e, 0xd8}; - uint8_t bytesprops12[] = {0xff, 0xd7, 0x8, 0xbd, 0x45, 0x80, 0x40, 0x1e, 0xa9, 0x8a, 0x84, 0xe8, 0x12, 0x56, 0x6f, - 0x74, 0xa5, 0xae, 0xd1, 0xb1, 0xed, 0x3, 0xb3, 0xcd, 0x69, 0x49, 0x2d, 0xfb, 0x73, 0xd2}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops3}, .v = {11, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20628}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops5}, .v = {8, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26351}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops12}, .v = {7, (char*)&bytesprops13}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23656}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11331}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16169}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 126}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16088, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\DC3\188\&0\t6w\FS", _pubPktID = -// 7577, _pubBody = "9\176{\185\134p\216\206\208\GS\EM?", _pubProps = [PropTopicAlias 9405,PropResponseInformation -// "y\233\208\212\193\SO\201",PropCorrelationData "\EM\ESCrbQ\251\DC1\159W\160\177@i",PropRequestProblemInformation -// 166,PropSharedSubscriptionAvailable 26,PropMessageExpiryInterval 18671,PropServerKeepAlive -// 13351,PropSubscriptionIdentifier 29]} -TEST(Publish5QCTest, Encode62) { - uint8_t pkt[] = {0x32, 0x43, 0x0, 0x7, 0x13, 0xbc, 0x30, 0x9, 0x36, 0x77, 0x1c, 0x1d, 0x99, 0x2b, - 0x23, 0x24, 0xbd, 0x1a, 0x0, 0x7, 0x79, 0xe9, 0xd0, 0xd4, 0xc1, 0xe, 0xc9, 0x9, - 0x0, 0xd, 0x19, 0x1b, 0x72, 0x62, 0x51, 0xfb, 0x11, 0x9f, 0x57, 0xa0, 0xb1, 0x40, - 0x69, 0x17, 0xa6, 0x2a, 0x1a, 0x2, 0x0, 0x0, 0x48, 0xef, 0x13, 0x34, 0x27, 0xb, - 0x1d, 0x39, 0xb0, 0x7b, 0xb9, 0x86, 0x70, 0xd8, 0xce, 0xd0, 0x1d, 0x19, 0x3f}; - - uint8_t buf[79] = {0}; - - uint8_t topic_bytes[] = {0x13, 0xbc, 0x30, 0x9, 0x36, 0x77, 0x1c}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x39, 0xb0, 0x7b, 0xb9, 0x86, 0x70, 0xd8, 0xce, 0xd0, 0x1d, 0x19, 0x3f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; - - uint8_t bytesprops0[] = {0x79, 0xe9, 0xd0, 0xd4, 0xc1, 0xe, 0xc9}; - uint8_t bytesprops1[] = {0x19, 0x1b, 0x72, 0x62, 0x51, 0xfb, 0x11, 0x9f, 0x57, 0xa0, 0xb1, 0x40, 0x69}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9405}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18671}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13351}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - }; - - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7577, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\DC2a\165\SO(\131\154\NAKm\b\STX\243\250\178\197H", _pubPktID = 13200, _pubBody = "\164V\204\140", _pubProps = -// [PropAssignedClientIdentifier "\137\145\227\SOH\NULW\159\162",PropMessageExpiryInterval -// 3339,PropSubscriptionIdentifierAvailable 23,PropRequestResponseInformation 192,PropWillDelayInterval -// 22813,PropMaximumQoS 26,PropRequestResponseInformation 5,PropCorrelationData "\232\164%\154'",PropServerReference -// "\228W\253R\139E^\vA)",PropServerKeepAlive 15699,PropWildcardSubscriptionAvailable 48,PropMessageExpiryInterval -// 5022,PropPayloadFormatIndicator 55,PropRequestProblemInformation 204,PropRequestResponseInformation -// 118,PropSubscriptionIdentifier 7,PropServerReference "\197",PropSessionExpiryInterval 11778,PropServerKeepAlive -// 14548,PropServerKeepAlive 24117,PropRequestProblemInformation 242,PropSubscriptionIdentifier 30,PropTopicAlias -// 5877,PropWillDelayInterval 7490]} -TEST(Publish5QCTest, Encode63) { - uint8_t pkt[] = {0x3c, 0x78, 0x0, 0x10, 0x12, 0x61, 0xa5, 0xe, 0x28, 0x83, 0x9a, 0x15, 0x6d, 0x8, 0x2, 0xf3, - 0xfa, 0xb2, 0xc5, 0x48, 0x33, 0x90, 0x5f, 0x12, 0x0, 0x8, 0x89, 0x91, 0xe3, 0x1, 0x0, 0x57, - 0x9f, 0xa2, 0x2, 0x0, 0x0, 0xd, 0xb, 0x29, 0x17, 0x19, 0xc0, 0x18, 0x0, 0x0, 0x59, 0x1d, - 0x24, 0x1a, 0x19, 0x5, 0x9, 0x0, 0x5, 0xe8, 0xa4, 0x25, 0x9a, 0x27, 0x1c, 0x0, 0xa, 0xe4, - 0x57, 0xfd, 0x52, 0x8b, 0x45, 0x5e, 0xb, 0x41, 0x29, 0x13, 0x3d, 0x53, 0x28, 0x30, 0x2, 0x0, - 0x0, 0x13, 0x9e, 0x1, 0x37, 0x17, 0xcc, 0x19, 0x76, 0xb, 0x7, 0x1c, 0x0, 0x1, 0xc5, 0x11, - 0x0, 0x0, 0x2e, 0x2, 0x13, 0x38, 0xd4, 0x13, 0x5e, 0x35, 0x17, 0xf2, 0xb, 0x1e, 0x23, 0x16, - 0xf5, 0x18, 0x0, 0x0, 0x1d, 0x42, 0xa4, 0x56, 0xcc, 0x8c}; - - uint8_t buf[132] = {0}; - - uint8_t topic_bytes[] = {0x12, 0x61, 0xa5, 0xe, 0x28, 0x83, 0x9a, 0x15, 0x6d, 0x8, 0x2, 0xf3, 0xfa, 0xb2, 0xc5, 0x48}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xa4, 0x56, 0xcc, 0x8c}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; - - uint8_t bytesprops0[] = {0x89, 0x91, 0xe3, 0x1, 0x0, 0x57, 0x9f, 0xa2}; - uint8_t bytesprops1[] = {0xe8, 0xa4, 0x25, 0x9a, 0x27}; - uint8_t bytesprops2[] = {0xe4, 0x57, 0xfd, 0x52, 0x8b, 0x45, 0x5e, 0xb, 0x41, 0x29}; - uint8_t bytesprops3[] = {0xc5}; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4732, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 14957 +// [("J\147\230\135V\211\184\205\203c\167\216Fb\245\187\165\175\&7\175Zh\224\EOT\247\147&#",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\134n\153\177\133\152\145aTM\141\223#\220\167X\138\DLE\143JK\148\201\ETX\251\138\229",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] +// [PropMessageExpiryInterval 6325,PropRequestResponseInformation 164,PropWildcardSubscriptionAvailable +// 61,PropContentType "&\138\128\202\\\208\172\237e\250\GS\GS\250\ETX\238", _pubPktID = 15457, _pubBody = -// "f\244\166\DLE\197\195\242\206\199<\FS\ETB$\STX \236\135\235\232\196\229\b`n\216,v\233V\177", _pubProps = -// [PropServerReference -// "\189|\165\GS`\199\151O\183$\228Y\158(%Ym\176\229\241d\233\196\196\138\209\146\142",PropAuthenticationData -// "\153\167\232\&2",PropSharedSubscriptionAvailable 174,PropAuthenticationMethod "}/",PropWildcardSubscriptionAvailable -// 206,PropTopicAlias 32469,PropWillDelayInterval 18902,PropReasonString -// "\217\251\241\147@`\v-\a\253\209\184",PropWildcardSubscriptionAvailable 200,PropRequestResponseInformation -// 100,PropCorrelationData -// "{\185a\t\EM\234\142{oa\ESC\b?\209\t\138\"\194{dDx\157\SOH",PropSubscriptionIdentifierAvailable -// 97,PropCorrelationData "\232)BS\179l\175\196\GS",PropSubscriptionIdentifierAvailable 226,PropResponseInformation -// "\164\rp\193\236\186u\224\t\168q\230\166\153ngOL\"\USA\191\131\&2\\\252\142)\147\219",PropMessageExpiryInterval -// 3303,PropSharedSubscriptionAvailable 214,PropAuthenticationData -// "\249w\"\132\217[\255E\189\DLE^\a\197?\141%\224\RSJ\207\188Fd1\240v",PropSubscriptionIdentifierAvailable -// 177,PropResponseInformation "\160e\210P\218\248\ESC}\225\146\SUB\245$A\246\&3B\171\146\255Vk\ENQsZK"]} -TEST(Publish5QCTest, Encode64) { + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14957, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 10919 [("t\SUB9\188\&6\246\145\139\179Z\219\201\195_E\251",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\193ia\255\232\&5\138\199>\245\230\190d\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("\SYN\233\177\236i\130\128\129L\208\174U\146\138F\247\182\212.\225y\DC2R\230s`9\178X_",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("C\183z\254h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\232t\GS\132\129\184f\CAN\CAN>\141:L\216\DC3{\191Y\213\232\SYN|\212\146k\195",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\SO]\228\162\189*ST\168t\ACK\143\216r\249\178\199\&0(\200[}\173\235\206\159F",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\STX\148\192L*\157`\179\224=e\224\228\&6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("\232J\211\179\136\130\218\157A\177\157j!\157\237\a\248\213\SUB\155",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropResponseInformation +// "\141\218\fB",PropMaximumQoS 48,PropUserProperty "8\STX\171\212E" +// "\205.\225\DC2)S\236\SO\221\ENQb\205\162\227G\206\194\171",PropWildcardSubscriptionAvailable 97,PropServerReference +// "",PropSharedSubscriptionAvailable 231,PropMessageExpiryInterval 8639,PropTopicAlias 18302,PropSubscriptionIdentifier +// 24,PropResponseTopic "N\232",PropRetainAvailable 16,PropServerReference +// "eR\198\190}\129\&0\DC4\130\133&\n\200\232q\197v\217\231|\236\&9\177",PropPayloadFormatIndicator +// 91,PropRequestResponseInformation 218,PropSubscriptionIdentifier 19,PropResponseTopic "\231\212A",PropContentType +// "\170\220\180\147\DC3\b\128\EOTD\166\220\EOTTr.\156\143es\186\f\SI\223",PropSubscriptionIdentifierAvailable +// 46,PropCorrelationData +// "\204s\151Y\143\185\163\219}\202\&3\197\DEL\230\162\201\223\"1\SUB\254s\246];\142ll\235",PropReceiveMaximum +// 11098,PropResponseInformation "\237)\FS.?~N",PropReasonString "t\239\236\164\&7\216]\131\205",PropUserProperty "@?l'" +// ">\215\168\185\215\198\234\247\182F\220\215\171\185\200\155\235\NUL7\133\128\n\v\146\183n+\214 +// \249",PropMessageExpiryInterval 23401,PropPayloadFormatIndicator 155,PropMessageExpiryInterval +// 15350,PropMessageExpiryInterval 15537,PropRequestProblemInformation 205,PropMaximumPacketSize +// 25844,PropSessionExpiryInterval 9076] +TEST(Subscribe5QCTest, Encode68) { uint8_t pkt[] = { - 0x3b, 0x90, 0x2, 0x0, 0x13, 0x88, 0xc7, 0x87, 0x85, 0xab, 0xfc, 0x2b, 0xd3, 0x64, 0x13, 0x5c, 0xaa, 0x3e, 0xfa, - 0x1d, 0x1d, 0xfa, 0x3, 0xee, 0x3c, 0x61, 0xd9, 0x1, 0x1c, 0x0, 0x1c, 0xbd, 0x7c, 0xa5, 0x1d, 0x60, 0xc7, 0x97, - 0x4f, 0xb7, 0x24, 0xe4, 0x59, 0x9e, 0x28, 0x25, 0x59, 0x6d, 0xb0, 0xe5, 0xf1, 0x64, 0xe9, 0xc4, 0xc4, 0x8a, 0xd1, - 0x92, 0x8e, 0x16, 0x0, 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, - 0xa6, 0x10, 0xc5, 0xc3, 0xf2, 0xce, 0xc7, 0x3c, 0x1c, 0x17, 0x24, 0x2, 0x20, 0xec, 0x87, 0xeb, 0xe8, 0xc4, 0xe5, - 0x8, 0x60, 0x6e, 0xd8, 0x2c, 0x76, 0xe9, 0x56, 0xb1}; - - uint8_t buf[285] = {0}; - - uint8_t topic_bytes[] = {0x88, 0xc7, 0x87, 0x85, 0xab, 0xfc, 0x2b, 0xd3, 0x64, 0x13, - 0x5c, 0xaa, 0x3e, 0xfa, 0x1d, 0x1d, 0xfa, 0x3, 0xee}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x66, 0xf4, 0xa6, 0x10, 0xc5, 0xc3, 0xf2, 0xce, 0xc7, 0x3c, 0x1c, 0x17, 0x24, 0x2, 0x20, - 0xec, 0x87, 0xeb, 0xe8, 0xc4, 0xe5, 0x8, 0x60, 0x6e, 0xd8, 0x2c, 0x76, 0xe9, 0x56, 0xb1}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; - - uint8_t bytesprops0[] = {0xbd, 0x7c, 0xa5, 0x1d, 0x60, 0xc7, 0x97, 0x4f, 0xb7, 0x24, 0xe4, 0x59, 0x9e, 0x28, - 0x25, 0x59, 0x6d, 0xb0, 0xe5, 0xf1, 0x64, 0xe9, 0xc4, 0xc4, 0x8a, 0xd1, 0x92, 0x8e}; - uint8_t bytesprops1[] = {0x99, 0xa7, 0xe8, 0x32}; - uint8_t bytesprops2[] = {0x7d, 0x2f}; - uint8_t bytesprops3[] = {0xd9, 0xfb, 0xf1, 0x93, 0x40, 0x60, 0xb, 0x2d, 0x7, 0xfd, 0xd1, 0xb8}; - uint8_t bytesprops4[] = {0x7b, 0xb9, 0x61, 0x9, 0x19, 0xea, 0x8e, 0x7b, 0x6f, 0x61, 0x1b, 0x8, - 0x3f, 0xd1, 0x9, 0x8a, 0x22, 0xc2, 0x7b, 0x64, 0x44, 0x78, 0x9d, 0x1}; - uint8_t bytesprops5[] = {0xe8, 0x29, 0x42, 0x53, 0xb3, 0x6c, 0xaf, 0xc4, 0x1d}; - uint8_t bytesprops6[] = {0xa4, 0xd, 0x70, 0xc1, 0xec, 0xba, 0x75, 0xe0, 0x9, 0xa8, 0x71, 0xe6, 0xa6, 0x99, 0x6e, - 0x67, 0x4f, 0x4c, 0x22, 0x1f, 0x41, 0xbf, 0x83, 0x32, 0x5c, 0xfc, 0x8e, 0x29, 0x93, 0xdb}; - uint8_t bytesprops7[] = {0xf9, 0x77, 0x22, 0x84, 0xd9, 0x5b, 0xff, 0x45, 0xbd, 0x10, 0x5e, 0x7, 0xc5, - 0x3f, 0x8d, 0x25, 0xe0, 0x1e, 0x4a, 0xcf, 0xbc, 0x46, 0x64, 0x31, 0xf0, 0x76}; - uint8_t bytesprops8[] = {0xa0, 0x65, 0xd2, 0x50, 0xda, 0xf8, 0x1b, 0x7d, 0xe1, 0x92, 0x1a, 0xf5, 0x24, - 0x41, 0xf6, 0x33, 0x42, 0xab, 0x92, 0xff, 0x56, 0x6b, 0x5, 0x73, 0x5a, 0x4b}; + 0x82, 0xb0, 0x3, 0x2a, 0xa7, 0xfc, 0x1, 0x1a, 0x0, 0x4, 0x8d, 0xda, 0xc, 0x42, 0x24, 0x30, 0x26, 0x0, 0x5, + 0x38, 0x2, 0xab, 0xd4, 0x45, 0x0, 0x12, 0xcd, 0x2e, 0xe1, 0x12, 0x29, 0x53, 0xec, 0xe, 0xdd, 0x5, 0x62, 0xcd, + 0xa2, 0xe3, 0x47, 0xce, 0xc2, 0xab, 0x28, 0x61, 0x1c, 0x0, 0x0, 0x2a, 0xe7, 0x2, 0x0, 0x0, 0x21, 0xbf, 0x23, + 0x47, 0x7e, 0xb, 0x18, 0x8, 0x0, 0x2, 0x4e, 0xe8, 0x25, 0x10, 0x1c, 0x0, 0x17, 0x65, 0x52, 0xc6, 0x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 0x10, 0x74, 0x1a, 0x39, 0xbc, 0x36, + 0xf6, 0x91, 0x8b, 0xb3, 0x5a, 0xdb, 0xc9, 0xc3, 0x5f, 0x45, 0xfb, 0x1, 0x0, 0xe, 0xc1, 0x69, 0x61, 0xff, 0xe8, + 0x35, 0x8a, 0xc7, 0x3e, 0xf5, 0xe6, 0xbe, 0x64, 0xa, 0x0, 0x0, 0x1e, 0x16, 0xe9, 0xb1, 0xec, 0x69, 0x82, 0x80, + 0x81, 0x4c, 0xd0, 0xae, 0x55, 0x92, 0x8a, 0x46, 0xf7, 0xb6, 0xd4, 0x2e, 0xe1, 0x79, 0x12, 0x52, 0xe6, 0x73, 0x60, + 0x39, 0xb2, 0x58, 0x5f, 0x0, 0x0, 0x5, 0x43, 0xb7, 0x7a, 0xfe, 0x68, 0x1, 0x0, 0x1a, 0xe8, 0x74, 0x1d, 0x84, + 0x81, 0xb8, 0x66, 0x18, 0x18, 0x3e, 0x8d, 0x3a, 0x4c, 0xd8, 0x13, 0x7b, 0xbf, 0x59, 0xd5, 0xe8, 0x16, 0x7c, 0xd4, + 0x92, 0x6b, 0xc3, 0x1, 0x0, 0x1b, 0xe, 0x5d, 0xe4, 0xa2, 0xbd, 0x2a, 0x53, 0x54, 0xa8, 0x74, 0x6, 0x8f, 0xd8, + 0x72, 0xf9, 0xb2, 0xc7, 0x30, 0x28, 0xc8, 0x5b, 0x7d, 0xad, 0xeb, 0xce, 0x9f, 0x46, 0x1, 0x0, 0xe, 0x2, 0x94, + 0xc0, 0x4c, 0x2a, 0x9d, 0x60, 0xb3, 0xe0, 0x3d, 0x65, 0xe0, 0xe4, 0x36, 0x0, 0x0, 0x14, 0xe8, 0x4a, 0xd3, 0xb3, + 0x88, 0x82, 0xda, 0x9d, 0x41, 0xb1, 0x9d, 0x6a, 0x21, 0x9d, 0xed, 0x7, 0xf8, 0xd5, 0x1a, 0x9b, 0x0}; + + uint8_t buf[445] = {0}; + + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x74, 0x1a, 0x39, 0xbc, 0x36, 0xf6, 0x91, 0x8b, + 0xb3, 0x5a, 0xdb, 0xc9, 0xc3, 0x5f, 0x45, 0xfb}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc1, 0x69, 0x61, 0xff, 0xe8, 0x35, 0x8a, 0xc7, 0x3e, 0xf5, 0xe6, 0xbe, 0x64, 0xa}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x16, 0xe9, 0xb1, 0xec, 0x69, 0x82, 0x80, 0x81, 0x4c, 0xd0, + 0xae, 0x55, 0x92, 0x8a, 0x46, 0xf7, 0xb6, 0xd4, 0x2e, 0xe1, + 0x79, 0x12, 0x52, 0xe6, 0x73, 0x60, 0x39, 0xb2, 0x58, 0x5f}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x43, 0xb7, 0x7a, 0xfe, 0x68}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe8, 0x74, 0x1d, 0x84, 0x81, 0xb8, 0x66, 0x18, 0x18, 0x3e, 0x8d, 0x3a, 0x4c, + 0xd8, 0x13, 0x7b, 0xbf, 0x59, 0xd5, 0xe8, 0x16, 0x7c, 0xd4, 0x92, 0x6b, 0xc3}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe, 0x5d, 0xe4, 0xa2, 0xbd, 0x2a, 0x53, 0x54, 0xa8, 0x74, 0x6, 0x8f, 0xd8, 0x72, + 0xf9, 0xb2, 0xc7, 0x30, 0x28, 0xc8, 0x5b, 0x7d, 0xad, 0xeb, 0xce, 0x9f, 0x46}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x2, 0x94, 0xc0, 0x4c, 0x2a, 0x9d, 0x60, 0xb3, 0xe0, 0x3d, 0x65, 0xe0, 0xe4, 0x36}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe8, 0x4a, 0xd3, 0xb3, 0x88, 0x82, 0xda, 0x9d, 0x41, 0xb1, + 0x9d, 0x6a, 0x21, 0x9d, 0xed, 0x7, 0xf8, 0xd5, 0x1a, 0x9b}; + lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x8d, 0xda, 0xc, 0x42}; + uint8_t bytesprops2[] = {0xcd, 0x2e, 0xe1, 0x12, 0x29, 0x53, 0xec, 0xe, 0xdd, + 0x5, 0x62, 0xcd, 0xa2, 0xe3, 0x47, 0xce, 0xc2, 0xab}; + uint8_t bytesprops1[] = {0x38, 0x2, 0xab, 0xd4, 0x45}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x4e, 0xe8}; + uint8_t bytesprops5[] = {0x65, 0x52, 0xc6, 0xbe, 0x7d, 0x81, 0x30, 0x14, 0x82, 0x85, 0x26, 0xa, + 0xc8, 0xe8, 0x71, 0xc5, 0x76, 0xd9, 0xe7, 0x7c, 0xec, 0x39, 0xb1}; + uint8_t bytesprops6[] = {0xe7, 0xd4, 0x41}; + uint8_t bytesprops7[] = {0xaa, 0xdc, 0xb4, 0x93, 0x13, 0x8, 0x80, 0x4, 0x44, 0xa6, 0xdc, 0x4, + 0x54, 0x72, 0x2e, 0x9c, 0x8f, 0x65, 0x73, 0xba, 0xc, 0xf, 0xdf}; + uint8_t bytesprops8[] = {0xcc, 0x73, 0x97, 0x59, 0x8f, 0xb9, 0xa3, 0xdb, 0x7d, 0xca, 0x33, 0xc5, 0x7f, 0xe6, 0xa2, + 0xc9, 0xdf, 0x22, 0x31, 0x1a, 0xfe, 0x73, 0xf6, 0x5d, 0x3b, 0x8e, 0x6c, 0x6c, 0xeb}; + uint8_t bytesprops9[] = {0xed, 0x29, 0x1c, 0x2e, 0x3f, 0x7e, 0x4e}; + uint8_t bytesprops10[] = {0x74, 0xef, 0xec, 0xa4, 0x37, 0xd8, 0x5d, 0x83, 0xcd}; + uint8_t bytesprops12[] = {0x3e, 0xd7, 0xa8, 0xb9, 0xd7, 0xc6, 0xea, 0xf7, 0xb6, 0x46, 0xdc, 0xd7, 0xab, 0xb9, 0xc8, + 0x9b, 0xeb, 0x0, 0x37, 0x85, 0x80, 0xa, 0xb, 0x92, 0xb7, 0x6e, 0x2b, 0xd6, 0x20, 0xf9}; + uint8_t bytesprops11[] = {0x40, 0x3f, 0x6c, 0x27}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32469}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18902}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3303}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8639}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18302}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11098}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops11}, .v = {30, (char*)&bytesprops12}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23401}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15350}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15537}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25844}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9076}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15457, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 29420, _pubBody = -// "F\146\254\ETB\174Cu^\188$\218\201\215$\253\&7\184\236S\169\243\ETXn\180\US\fC\220\137\SYN", _pubProps = -// [PropSessionExpiryInterval 27347,PropServerKeepAlive 18294,PropTopicAliasMaximum 11531,PropAuthenticationMethod -// "\254\189\195{",PropResponseTopic -// "\CAN\139\240<\247\132\164F\228\&9w\DC3\139\221P'Y$\140\230\223S\247\149\206",PropMessageExpiryInterval -// 30913,PropSubscriptionIdentifier 6,PropAuthenticationMethod -// "\148\195\136\v\131\176\171\141\150@\f\f1\201",PropRetainAvailable 184,PropContentType "\158\bQU\201"]} -TEST(Publish5QCTest, Encode65) { - uint8_t pkt[] = {0x33, 0x73, 0x0, 0x0, 0x72, 0xec, 0x50, 0x11, 0x0, 0x0, 0x6a, 0xd3, 0x13, 0x47, 0x76, 0x22, 0x2d, - 0xb, 0x15, 0x0, 0x4, 0xfe, 0xbd, 0xc3, 0x7b, 0x8, 0x0, 0x19, 0x18, 0x8b, 0xf0, 0x3c, 0xf7, 0x84, - 0xa4, 0x46, 0xe4, 0x39, 0x77, 0x13, 0x8b, 0xdd, 0x50, 0x27, 0x59, 0x24, 0x8c, 0xe6, 0xdf, 0x53, 0xf7, - 0x95, 0xce, 0x2, 0x0, 0x0, 0x78, 0xc1, 0xb, 0x6, 0x15, 0x0, 0xe, 0x94, 0xc3, 0x88, 0xb, 0x83, - 0xb0, 0xab, 0x8d, 0x96, 0x40, 0xc, 0xc, 0x31, 0xc9, 0x25, 0xb8, 0x3, 0x0, 0x5, 0x9e, 0x8, 0x51, - 0x55, 0xc9, 0x46, 0x92, 0xfe, 0x17, 0xae, 0x43, 0x75, 0x5e, 0xbc, 0x24, 0xda, 0xc9, 0xd7, 0x24, 0xfd, - 0x37, 0xb8, 0xec, 0x53, 0xa9, 0xf3, 0x3, 0x6e, 0xb4, 0x1f, 0xc, 0x43, 0xdc, 0x89, 0x16}; - - uint8_t buf[127] = {0}; - - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x46, 0x92, 0xfe, 0x17, 0xae, 0x43, 0x75, 0x5e, 0xbc, 0x24, 0xda, 0xc9, 0xd7, 0x24, 0xfd, - 0x37, 0xb8, 0xec, 0x53, 0xa9, 0xf3, 0x3, 0x6e, 0xb4, 0x1f, 0xc, 0x43, 0xdc, 0x89, 0x16}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; - - uint8_t bytesprops0[] = {0xfe, 0xbd, 0xc3, 0x7b}; - uint8_t bytesprops1[] = {0x18, 0x8b, 0xf0, 0x3c, 0xf7, 0x84, 0xa4, 0x46, 0xe4, 0x39, 0x77, 0x13, 0x8b, - 0xdd, 0x50, 0x27, 0x59, 0x24, 0x8c, 0xe6, 0xdf, 0x53, 0xf7, 0x95, 0xce}; - uint8_t bytesprops2[] = {0x94, 0xc3, 0x88, 0xb, 0x83, 0xb0, 0xab, 0x8d, 0x96, 0x40, 0xc, 0xc, 0x31, 0xc9}; - uint8_t bytesprops3[] = {0x9e, 0x8, 0x51, 0x55, 0xc9}; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10919, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 692 [("\151\140>\206\207\NUL\208\139\194L\251\227\220\170\163\153*~?,w\245u",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\227\154\215d\192;_\237G\128o\235Q\218rV\202\SOHr\DEL\144\155",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("S'\141\229\&7]\"\179\212\174\r\185\176",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\137\202Y\ENQ\254#\197\FS(R\208\234n0x\ACK\141\210i\227$0\182H%",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("0\237\190\218C6",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\247/{\nv\233V\144\198e\158",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\247\194\142\228\247\186\227\&8",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("J",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\200\183{SW\236\248y\197\224\172K\STX\184W\v~\211",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\247\146\ETB\254\241\SYN\199\197\175\237\\\220\213\154\178\214\136k\147S\SI\228\EM\219\129.\240",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\249h\135(AF",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1})] [PropPayloadFormatIndicator 98,PropSubscriptionIdentifierAvailable 91,PropAssignedClientIdentifier +// "",PropReceiveMaximum 7702,PropReasonString +// "\DEL\212\RS\209\138\vV\203\176\167\GSh\166\241a\174\223\134i\ACK\180\141\167\143\GS*W",PropResponseInformation +// "S\n\222\138\232",PropSubscriptionIdentifierAvailable 17,PropRequestResponseInformation 229,PropMessageExpiryInterval +// 357,PropUserProperty "\194\165\224\b\149\&0\226KTy\175\187\RSC5" "\177W]>\200NI6gJ\199\&4\148{\129Y\202 +// [1\244\223\141\240S"] +TEST(Subscribe5QCTest, Encode69) { + uint8_t pkt[] = { + 0x82, 0xaa, 0x2, 0x2, 0xb4, 0x66, 0x1, 0x62, 0x29, 0x5b, 0x12, 0x0, 0x0, 0x21, 0x1e, 0x16, 0x1f, 0x0, 0x1b, + 0x7f, 0xd4, 0x1e, 0xd1, 0x8a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0x36, 0x1, 0x0, 0xb, 0xf7, 0x2f, 0x7b, 0xa, 0x76, 0xe9, 0x56, 0x90, 0xc6, 0x65, 0x9e, 0x0, 0x0, 0x8, + 0xf7, 0xc2, 0x8e, 0xe4, 0xf7, 0xba, 0xe3, 0x38, 0x0, 0x0, 0x1, 0x4a, 0x2, 0x0, 0x12, 0xc8, 0xb7, 0x7b, 0x53, + 0x57, 0xec, 0xf8, 0x79, 0xc5, 0xe0, 0xac, 0x4b, 0x2, 0xb8, 0x57, 0xb, 0x7e, 0xd3, 0x0, 0x0, 0x1b, 0xf7, 0x92, + 0x17, 0xfe, 0xf1, 0x16, 0xc7, 0xc5, 0xaf, 0xed, 0x5c, 0xdc, 0xd5, 0x9a, 0xb2, 0xd6, 0x88, 0x6b, 0x93, 0x53, 0xf, + 0xe4, 0x19, 0xdb, 0x81, 0x2e, 0xf0, 0x2, 0x0, 0x6, 0xf9, 0x68, 0x87, 0x28, 0x41, 0x46, 0x1}; + + uint8_t buf[311] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x97, 0x8c, 0x3e, 0xce, 0xcf, 0x0, 0xd0, 0x8b, 0xc2, 0x4c, 0xfb, 0xe3, + 0xdc, 0xaa, 0xa3, 0x99, 0x2a, 0x7e, 0x3f, 0x2c, 0x77, 0xf5, 0x75}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xe3, 0x9a, 0xd7, 0x64, 0xc0, 0x3b, 0x5f, 0xed, 0x47, 0x80, 0x6f, + 0xeb, 0x51, 0xda, 0x72, 0x56, 0xca, 0x1, 0x72, 0x7f, 0x90, 0x9b}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x53, 0x27, 0x8d, 0xe5, 0x37, 0x5d, 0x22, 0xb3, 0xd4, 0xae, 0xd, 0xb9, 0xb0}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x89, 0xca, 0x59, 0x5, 0xfe, 0x23, 0xc5, 0x1c, 0x28, 0x52, 0xd0, 0xea, 0x6e, + 0x30, 0x78, 0x6, 0x8d, 0xd2, 0x69, 0xe3, 0x24, 0x30, 0xb6, 0x48, 0x25}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x30, 0xed, 0xbe, 0xda, 0x43, 0x36}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf7, 0x2f, 0x7b, 0xa, 0x76, 0xe9, 0x56, 0x90, 0xc6, 0x65, 0x9e}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xf7, 0xc2, 0x8e, 0xe4, 0xf7, 0xba, 0xe3, 0x38}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x4a}; + lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xc8, 0xb7, 0x7b, 0x53, 0x57, 0xec, 0xf8, 0x79, 0xc5, + 0xe0, 0xac, 0x4b, 0x2, 0xb8, 0x57, 0xb, 0x7e, 0xd3}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xf7, 0x92, 0x17, 0xfe, 0xf1, 0x16, 0xc7, 0xc5, 0xaf, 0xed, 0x5c, 0xdc, 0xd5, 0x9a, + 0xb2, 0xd6, 0x88, 0x6b, 0x93, 0x53, 0xf, 0xe4, 0x19, 0xdb, 0x81, 0x2e, 0xf0}; + lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xf9, 0x68, 0x87, 0x28, 0x41, 0x46}; + lwmqtt_string_t topic_filter_s10 = {6, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x7f, 0xd4, 0x1e, 0xd1, 0x8a, 0xb, 0x56, 0xcb, 0xb0, 0xa7, 0x1d, 0x68, 0xa6, 0xf1, + 0x61, 0xae, 0xdf, 0x86, 0x69, 0x6, 0xb4, 0x8d, 0xa7, 0x8f, 0x1d, 0x2a, 0x57}; + uint8_t bytesprops2[] = {0x53, 0xa, 0xde, 0x8a, 0xe8}; + uint8_t bytesprops4[] = {0xb1, 0x57, 0x5d, 0x3e, 0xc8, 0x4e, 0x49, 0x36, 0x67, 0x4a, 0xc7, 0x34, 0x94, + 0x7b, 0x81, 0x59, 0xca, 0x20, 0x5b, 0x31, 0xf4, 0xdf, 0x8d, 0xf0, 0x53}; + uint8_t bytesprops3[] = {0xc2, 0xa5, 0xe0, 0x8, 0x95, 0x30, 0xe2, 0x4b, 0x54, 0x79, 0xaf, 0xbb, 0x1e, 0x43, 0x35}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27347}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18294}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11531}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30913}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7702}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 357}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops3}, .v = {25, (char*)&bytesprops4}}}}, }; lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29420, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 692, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\253\220\DC4\187\155", _pubPktID = -// 28673, _pubBody = "\160\255\248\156YF\148S\164\194~\t\212\134\149`\202l", _pubProps = [PropPayloadFormatIndicator -// 176,PropWillDelayInterval 3215,PropReceiveMaximum 13425,PropReasonString -// "\216\221Ld\140\&1\193\179\163\NULN\204\151\ETB9\SO\143\153\216\ENQ\130\209()\139i\251\171",PropPayloadFormatIndicator -// 115,PropRequestProblemInformation 180,PropUserProperty -// "\241\SI\145\166\164v\239*\151\181.C?\198f\252\224\153O\190@Q\"\226r\239u\152\194\249" -// "\222\r\236IU\t\175M\165F\168zy\202\SYN2\172\228\253\250\SI\178M\130\bSj\180",PropUserProperty -// "\229Sk\DELQ\173\163\FS7\142\131\NAKU\204\132\180" -// "\232\155\&6&\185Z\178\DC4\231i'$\185\132\SOH$Qf\ETBPp\249\250",PropResponseTopic -// "\150^\217u\190\b\a\SO\139\250\&6\NAK\199|/\164`\147\164\247\&5gU\214\185",PropSharedSubscriptionAvailable -// 227,PropMaximumQoS 172,PropMaximumQoS 108,PropWillDelayInterval 7918,PropMaximumPacketSize 10821]} -TEST(Publish5QCTest, Encode66) { +// SubscribeRequest 1184 [("\170g\\2\a\FS\243\&2\134#\245<\232\v\154\&8;\169\197< " "\254\218t\234\144\136Yf<",PropResponseTopic +// "\174Zi\154\174d_\135\215\224oYC\210j*\192\186Fh\SYN\v\215L[\SOD\206\238",PropResponseTopic +// "=I\DLE\222\\e\188#\188\n\154\154\&5i\178\239\199\157@{\SOH\STX\254b8k\131",PropMessageExpiryInterval +// 28387,PropServerReference "4\245\EMk",PropPayloadFormatIndicator 115] +TEST(Subscribe5QCTest, Encode70) { uint8_t pkt[] = { - 0x35, 0xe1, 0x1, 0x0, 0x5, 0xfd, 0xdc, 0x14, 0xbb, 0x9b, 0x70, 0x1, 0xc4, 0x1, 0x1, 0xb0, 0x18, 0x0, 0x0, - 0xc, 0x8f, 0x21, 0x34, 0x71, 0x1f, 0x0, 0x1c, 0xd8, 0x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0x46, 0x94, 0x53, 0xa4, 0xc2, 0x7e, 0x9, 0xd4, 0x86, 0x95, 0x60, 0xca, 0x6c}; - - uint8_t buf[238] = {0}; - - uint8_t topic_bytes[] = {0xfd, 0xdc, 0x14, 0xbb, 0x9b}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa0, 0xff, 0xf8, 0x9c, 0x59, 0x46, 0x94, 0x53, 0xa4, - 0xc2, 0x7e, 0x9, 0xd4, 0x86, 0x95, 0x60, 0xca, 0x6c}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; - - uint8_t bytesprops0[] = {0xd8, 0xdd, 0x4c, 0x64, 0x8c, 0x31, 0xc1, 0xb3, 0xa3, 0x0, 0x4e, 0xcc, 0x97, 0x17, - 0x39, 0xe, 0x8f, 0x99, 0xd8, 0x5, 0x82, 0xd1, 0x28, 0x29, 0x8b, 0x69, 0xfb, 0xab}; - uint8_t bytesprops2[] = {0xde, 0xd, 0xec, 0x49, 0x55, 0x9, 0xaf, 0x4d, 0xa5, 0x46, 0xa8, 0x7a, 0x79, 0xca, - 0x16, 0x32, 0xac, 0xe4, 0xfd, 0xfa, 0xf, 0xb2, 0x4d, 0x82, 0x8, 0x53, 0x6a, 0xb4}; - uint8_t bytesprops1[] = {0xf1, 0xf, 0x91, 0xa6, 0xa4, 0x76, 0xef, 0x2a, 0x97, 0xb5, 0x2e, 0x43, 0x3f, 0xc6, 0x66, - 0xfc, 0xe0, 0x99, 0x4f, 0xbe, 0x40, 0x51, 0x22, 0xe2, 0x72, 0xef, 0x75, 0x98, 0xc2, 0xf9}; - uint8_t bytesprops4[] = {0xe8, 0x9b, 0x36, 0x26, 0xb9, 0x5a, 0xb2, 0x14, 0xe7, 0x69, 0x27, 0x24, - 0xb9, 0x84, 0x1, 0x24, 0x51, 0x66, 0x17, 0x50, 0x70, 0xf9, 0xfa}; - uint8_t bytesprops3[] = {0xe5, 0x53, 0x6b, 0x7f, 0x51, 0xad, 0xa3, 0x1c, - 0x37, 0x8e, 0x83, 0x15, 0x55, 0xcc, 0x84, 0xb4}; - uint8_t bytesprops5[] = {0x96, 0x5e, 0xd9, 0x75, 0xbe, 0x8, 0x7, 0xe, 0x8b, 0xfa, 0x36, 0x15, 0xc7, - 0x7c, 0x2f, 0xa4, 0x60, 0x93, 0xa4, 0xf7, 0x35, 0x67, 0x55, 0xd6, 0xb9}; + 0x82, 0x83, 0x2, 0x4, 0xa0, 0xb7, 0x1, 0x13, 0x51, 0xb0, 0xb, 0x1e, 0x18, 0x0, 0x0, 0x54, 0x7, 0x3, 0x0, + 0x14, 0x84, 0xd, 0x37, 0x5d, 0xd, 0x90, 0xde, 0x7c, 0x78, 0x48, 0x63, 0xae, 0x80, 0x29, 0x41, 0x7f, 0xbe, 0xd9, + 0x2e, 0x5b, 0x13, 0x3, 0x57, 0x15, 0x0, 0x2, 0x44, 0xc, 0x21, 0x5f, 0xc2, 0x25, 0x45, 0x1a, 0x0, 0x1c, 0xb9, + 0x97, 0xe8, 0xb1, 0x68, 0x7b, 0xb2, 0xf6, 0xf8, 0x53, 0xb1, 0xea, 0xd3, 0xf6, 0x0, 0x67, 0xab, 0xa8, 0xa1, 0x20, + 0xa6, 0xc6, 0x28, 0xcc, 0xb5, 0x10, 0x9e, 0x0, 0x26, 0x0, 0x10, 0x5e, 0xc5, 0x3d, 0x89, 0xdd, 0xc2, 0x2b, 0x52, + 0x3e, 0x9a, 0x38, 0x3b, 0xa9, 0xc5, 0x3c, 0x20, 0x0, 0x9, 0xfe, 0xda, 0x74, 0xea, 0x90, 0x88, 0x59, 0x66, 0x3c, + 0x8, 0x0, 0x1d, 0xae, 0x5a, 0x69, 0x9a, 0xae, 0x64, 0x5f, 0x87, 0xd7, 0xe0, 0x6f, 0x59, 0x43, 0xd2, 0x6a, 0x2a, + 0xc0, 0xba, 0x46, 0x68, 0x16, 0xb, 0xd7, 0x4c, 0x5b, 0xe, 0x44, 0xce, 0xee, 0x8, 0x0, 0x1b, 0x3d, 0x49, 0x10, + 0xde, 0x5c, 0x65, 0xbc, 0x23, 0xbc, 0xa, 0x9a, 0x9a, 0x35, 0x69, 0xb2, 0xef, 0xc7, 0x9d, 0x40, 0x7b, 0x1, 0x2, + 0xfe, 0x62, 0x38, 0x6b, 0x83, 0x2, 0x0, 0x0, 0x6e, 0xe3, 0x1c, 0x0, 0x4, 0x34, 0xf5, 0x19, 0x6b, 0x1, 0x73, + 0x0, 0x1c, 0xaa, 0x67, 0x5c, 0x32, 0x7, 0x1c, 0xf3, 0x32, 0x86, 0x23, 0xf5, 0x3c, 0xe8, 0xb, 0x3c, 0x73, 0x88, + 0x83, 0x17, 0xdd, 0x2f, 0x3f, 0x7, 0x68, 0x28, 0x51, 0x40, 0xb1, 0x1, 0x0, 0x1, 0xff, 0x2, 0x0, 0x3, 0xec, + 0xd0, 0xc6, 0x0, 0x0, 0x1, 0x1c, 0x1, 0x0, 0x18, 0x92, 0x10, 0x66, 0xf5, 0x6e, 0x40, 0xd0, 0x6d, 0xbf, 0x5, + 0xf8, 0xeb, 0x3d, 0xd5, 0xc0, 0x73, 0xe1, 0x5, 0x2b, 0x98, 0xa0, 0xc, 0x7c, 0xcc, 0x1}; + + uint8_t buf[272] = {0}; + + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xaa, 0x67, 0x5c, 0x32, 0x7, 0x1c, 0xf3, 0x32, 0x86, 0x23, + 0xf5, 0x3c, 0xe8, 0xb, 0x3c, 0x73, 0x88, 0x83, 0x17, 0xdd, + 0x2f, 0x3f, 0x7, 0x68, 0x28, 0x51, 0x40, 0xb1}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xff}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xec, 0xd0, 0xc6}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x1c}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x92, 0x10, 0x66, 0xf5, 0x6e, 0x40, 0xd0, 0x6d, 0xbf, 0x5, 0xf8, 0xeb, + 0x3d, 0xd5, 0xc0, 0x73, 0xe1, 0x5, 0x2b, 0x98, 0xa0, 0xc, 0x7c, 0xcc}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x84, 0xd, 0x37, 0x5d, 0xd, 0x90, 0xde, 0x7c, 0x78, 0x48, + 0x63, 0xae, 0x80, 0x29, 0x41, 0x7f, 0xbe, 0xd9, 0x2e, 0x5b}; + uint8_t bytesprops1[] = {0x44, 0xc}; + uint8_t bytesprops2[] = {0xb9, 0x97, 0xe8, 0xb1, 0x68, 0x7b, 0xb2, 0xf6, 0xf8, 0x53, 0xb1, 0xea, 0xd3, 0xf6, + 0x0, 0x67, 0xab, 0xa8, 0xa1, 0x20, 0xa6, 0xc6, 0x28, 0xcc, 0xb5, 0x10, 0x9e, 0x0}; + uint8_t bytesprops4[] = {0xfe, 0xda, 0x74, 0xea, 0x90, 0x88, 0x59, 0x66, 0x3c}; + uint8_t bytesprops3[] = {0x5e, 0xc5, 0x3d, 0x89, 0xdd, 0xc2, 0x2b, 0x52, + 0x3e, 0x9a, 0x38, 0x3b, 0xa9, 0xc5, 0x3c, 0x20}; + uint8_t bytesprops5[] = {0xae, 0x5a, 0x69, 0x9a, 0xae, 0x64, 0x5f, 0x87, 0xd7, 0xe0, 0x6f, 0x59, 0x43, 0xd2, 0x6a, + 0x2a, 0xc0, 0xba, 0x46, 0x68, 0x16, 0xb, 0xd7, 0x4c, 0x5b, 0xe, 0x44, 0xce, 0xee}; + uint8_t bytesprops6[] = {0x3d, 0x49, 0x10, 0xde, 0x5c, 0x65, 0xbc, 0x23, 0xbc, 0xa, 0x9a, 0x9a, 0x35, 0x69, + 0xb2, 0xef, 0xc7, 0x9d, 0x40, 0x7b, 0x1, 0x2, 0xfe, 0x62, 0x38, 0x6b, 0x83}; + uint8_t bytesprops7[] = {0x34, 0xf5, 0x19, 0x6b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3215}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13425}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20912}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21511}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 855}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24514}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {9, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28387}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops7}}}, {.prop = (lwmqtt_prop_t)1, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops1}, .v = {28, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {23, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7918}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10821}}, - }; - - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 28673, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\141\195\131\143\248w\207", -// _pubPktID = 574, _pubBody = "x\\\156a}\224\130S\US%\153\187\181\217\RS\201{", _pubProps = [PropMaximumQoS -// 87,PropRequestProblemInformation 231,PropUserProperty "\171\248\247\215S\157" "1\GS\241wj\178\191_\130\240[Z\ACK"]} -TEST(Publish5QCTest, Encode67) { - uint8_t pkt[] = {0x33, 0x39, 0x0, 0x7, 0x8d, 0xc3, 0x83, 0x8f, 0xf8, 0x77, 0xcf, 0x2, 0x3e, 0x1c, 0x24, - 0x57, 0x17, 0xe7, 0x26, 0x0, 0x6, 0xab, 0xf8, 0xf7, 0xd7, 0x53, 0x9d, 0x0, 0xd, 0x31, - 0x1d, 0xf1, 0x77, 0x6a, 0xb2, 0xbf, 0x5f, 0x82, 0xf0, 0x5b, 0x5a, 0x6, 0x78, 0x5c, 0x9c, - 0x61, 0x7d, 0xe0, 0x82, 0x53, 0x1f, 0x25, 0x99, 0xbb, 0xb5, 0xd9, 0x1e, 0xc9, 0x7b}; - - uint8_t buf[69] = {0}; - - uint8_t topic_bytes[] = {0x8d, 0xc3, 0x83, 0x8f, 0xf8, 0x77, 0xcf}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x78, 0x5c, 0x9c, 0x61, 0x7d, 0xe0, 0x82, 0x53, 0x1f, - 0x25, 0x99, 0xbb, 0xb5, 0xd9, 0x1e, 0xc9, 0x7b}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; - - uint8_t bytesprops1[] = {0x31, 0x1d, 0xf1, 0x77, 0x6a, 0xb2, 0xbf, 0x5f, 0x82, 0xf0, 0x5b, 0x5a, 0x6}; - uint8_t bytesprops0[] = {0xab, 0xf8, 0xf7, 0xd7, 0x53, 0x9d}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, - }; - - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 574, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "Mq\234\146\239\150W\FS1\177", -// _pubPktID = 0, _pubBody = "0\141\201\&8\139\&4\ETX>\239\RS\238\229t\225\198|\194W\186]\200\244|\171\DLE\163\193", -// _pubProps = [PropMaximumPacketSize 8091,PropTopicAliasMaximum 14682,PropUserProperty -// "\170`[\143\144<\181\138\154\150\&2[" "\197\171U(\DC1\249:aYH\248\175\t:\209 hc\210\222",PropCorrelationData -// "\169\207;\130S!n\178\ESC\247-\218\220w\225\176\140\252",PropRequestProblemInformation -// 89,PropSubscriptionIdentifierAvailable 119,PropAssignedClientIdentifier ">n\204\133\&0q",PropRetainAvailable -// 145,PropRequestResponseInformation 157]} -TEST(Publish5QCTest, Encode68) { - uint8_t pkt[] = {0x38, 0x7b, 0x0, 0xa, 0x4d, 0x71, 0xea, 0x92, 0xef, 0x96, 0x57, 0x1c, 0x31, 0xb1, 0x53, 0x27, - 0x0, 0x0, 0x1f, 0x9b, 0x22, 0x39, 0x5a, 0x26, 0x0, 0xc, 0xaa, 0x60, 0x5b, 0x8f, 0x90, 0x3c, - 0xb5, 0x8a, 0x9a, 0x96, 0x32, 0x5b, 0x0, 0x14, 0xc5, 0xab, 0x55, 0x28, 0x11, 0xf9, 0x3a, 0x61, - 0x59, 0x48, 0xf8, 0xaf, 0x9, 0x3a, 0xd1, 0x20, 0x68, 0x63, 0xd2, 0xde, 0x9, 0x0, 0x12, 0xa9, - 0xcf, 0x3b, 0x82, 0x53, 0x21, 0x6e, 0xb2, 0x1b, 0xf7, 0x2d, 0xda, 0xdc, 0x77, 0xe1, 0xb0, 0x8c, - 0xfc, 0x17, 0x59, 0x29, 0x77, 0x12, 0x0, 0x6, 0x3e, 0x6e, 0xcc, 0x85, 0x30, 0x71, 0x25, 0x91, - 0x19, 0x9d, 0x30, 0x8d, 0xc9, 0x38, 0x8b, 0x34, 0x3, 0x3e, 0xef, 0x1e, 0xee, 0xe5, 0x74, 0xe1, - 0xc6, 0x7c, 0xc2, 0x57, 0xba, 0x5d, 0xc8, 0xf4, 0x7c, 0xab, 0x10, 0xa3, 0xc1}; - - uint8_t buf[135] = {0}; - - uint8_t topic_bytes[] = {0x4d, 0x71, 0xea, 0x92, 0xef, 0x96, 0x57, 0x1c, 0x31, 0xb1}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x30, 0x8d, 0xc9, 0x38, 0x8b, 0x34, 0x3, 0x3e, 0xef, 0x1e, 0xee, 0xe5, 0x74, 0xe1, - 0xc6, 0x7c, 0xc2, 0x57, 0xba, 0x5d, 0xc8, 0xf4, 0x7c, 0xab, 0x10, 0xa3, 0xc1}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; - - uint8_t bytesprops1[] = {0xc5, 0xab, 0x55, 0x28, 0x11, 0xf9, 0x3a, 0x61, 0x59, 0x48, - 0xf8, 0xaf, 0x9, 0x3a, 0xd1, 0x20, 0x68, 0x63, 0xd2, 0xde}; - uint8_t bytesprops0[] = {0xaa, 0x60, 0x5b, 0x8f, 0x90, 0x3c, 0xb5, 0x8a, 0x9a, 0x96, 0x32, 0x5b}; - uint8_t bytesprops2[] = {0xa9, 0xcf, 0x3b, 0x82, 0x53, 0x21, 0x6e, 0xb2, 0x1b, - 0xf7, 0x2d, 0xda, 0xdc, 0x77, 0xe1, 0xb0, 0x8c, 0xfc}; - uint8_t bytesprops3[] = {0x3e, 0x6e, 0xcc, 0x85, 0x30, 0x71}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8091}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14682}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, - }; - - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "h\155\209\SYNBX\251\201\213\188", -// _pubPktID = 12728, _pubBody = "\SI\140\187\174(F\161\145", _pubProps = [PropWildcardSubscriptionAvailable -// 108,PropWildcardSubscriptionAvailable 247,PropMessageExpiryInterval 30096,PropCorrelationData -// "\138\254J\"~fp\SO\165\170\187\"\204'\182\RS"]} -TEST(Publish5QCTest, Encode69) { - uint8_t pkt[] = {0x3a, 0x33, 0x0, 0xa, 0x68, 0x9b, 0xd1, 0x16, 0x42, 0x58, 0xfb, 0xc9, 0xd5, 0xbc, - 0x31, 0xb8, 0x1c, 0x28, 0x6c, 0x28, 0xf7, 0x2, 0x0, 0x0, 0x75, 0x90, 0x9, 0x0, - 0x10, 0x8a, 0xfe, 0x4a, 0x22, 0x7e, 0x66, 0x70, 0xe, 0xa5, 0xaa, 0xbb, 0x22, 0xcc, - 0x27, 0xb6, 0x1e, 0xf, 0x8c, 0xbb, 0xae, 0x28, 0x46, 0xa1, 0x91}; - - uint8_t buf[63] = {0}; - - uint8_t topic_bytes[] = {0x68, 0x9b, 0xd1, 0x16, 0x42, 0x58, 0xfb, 0xc9, 0xd5, 0xbc}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xf, 0x8c, 0xbb, 0xae, 0x28, 0x46, 0xa1, 0x91}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 8; - - uint8_t bytesprops0[] = {0x8a, 0xfe, 0x4a, 0x22, 0x7e, 0x66, 0x70, 0xe, - 0xa5, 0xaa, 0xbb, 0x22, 0xcc, 0x27, 0xb6, 0x1e}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30096}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 12728, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "kH\169\156\ACK\a\235\&2Q\128\148\FS\135\142\FS]\168j\246\208", _pubPktID = 23840, _pubBody = "D\195\164", _pubProps -// = [PropCorrelationData -// "\135\165\202T\199\STX\150\US&\171b\171\147\234\NUL*{(\215\227\252\218\246\168|:\154<\DC1",PropTopicAliasMaximum -// 16471,PropReasonString "'\135\228(\156\&3:\US3\186e\DC4",PropMaximumPacketSize 22772,PropAssignedClientIdentifier -// "5",PropServerReference "\173}\150\243\255\t\161\&0#\234",PropReceiveMaximum 5843,PropAuthenticationData -// "\219h\207s\DC37Y",PropMaximumPacketSize 14127,PropAssignedClientIdentifier -// "vn=}\185\245Z\DC3\201\170\ACK\171\212\210\157\NUL:\140\229g\SI1\ENQL",PropWildcardSubscriptionAvailable -// 204,PropCorrelationData -// ">\NAK\183\160ii\247\191\206\222j((\US6D6M\174\196g\212\223\222\234\166",PropMessageExpiryInterval -// 25815,PropRequestResponseInformation 149,PropSubscriptionIdentifierAvailable 115,PropMessageExpiryInterval -// 9063,PropRequestProblemInformation 12,PropMaximumPacketSize 4463,PropAuthenticationMethod -// "\ACK\205+\179\a&\224\183\200\146\142yk\181\r\GSJ\192:\236\&1\ETB\183",PropSharedSubscriptionAvailable -// 125,PropResponseTopic -// "\200\130\NUL\213\EM\208h\239\171D\202\134\178\ETBY\\\212(\157\&3c\173P9(",PropSubscriptionIdentifier -// 28,PropAuthenticationData "\135\183\NAK\DEL\245\189\162J\223\ESC",PropMaximumPacketSize 28065]} -TEST(Publish5QCTest, Encode70) { + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1184, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 28334 [("\196\208x\145\a\197\236\166\237\198\\-\222a\r\140\158N\199\&7\178\RS`=>!E",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\163/?",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS +// = QoS1}),("_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\\\158\228\223\ETB:\150)dY|!\236\205\164s\139\v\167>\221\EM",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\232\208\185f\157\247N\190\191\ETX\212\t\213\229\SOH +// \206\v\178@\162^",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("m\137\v\f7\141&\216@\158!\GS\192\191\189",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\EOTg\241\167",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropSharedSubscriptionAvailable +// 34,PropServerKeepAlive 10247,PropAuthenticationMethod +// "\DEL=z\205\128\181C\232*\242:\233L\ve4\143D\155\208\&0ht\132Z{\ESC\238\159\201",PropSubscriptionIdentifierAvailable +// 248,PropRetainAvailable 28,PropMessageExpiryInterval 32489,PropMaximumPacketSize 21512,PropAuthenticationData +// "\147",PropMessageExpiryInterval 25286,PropUserProperty +// "\157\n\ACK\203\149\128\a\SYN\142\DC4}\133\193\168\228\243\200" "\128",PropReceiveMaximum +// 24957,PropSubscriptionIdentifierAvailable 191,PropAuthenticationData +// "\147\DLE\172\EM\159\172r\223Zfi.",PropMessageExpiryInterval 32172,PropSessionExpiryInterval 22638,PropReceiveMaximum +// 19477,PropTopicAlias 20439,PropRequestResponseInformation 231,PropServerKeepAlive 22562,PropMaximumPacketSize +// 20475,PropTopicAliasMaximum 14896,PropServerReference +// "\t\ETXMbx\253\ENQ4A}E\SUBR\t\138\147\141\199\253*V=\205\157",PropAssignedClientIdentifier +// "\CAN\230\&6\SO\204\212f\137m\227'\234\166o\176\222\136='F\181\137Gy\220\204\a\192\n",PropUserProperty "\245\f" +// "\176\244\230\b\213\SOH\201lP\\\158\202z\163!\198P\133\202",PropPayloadFormatIndicator 161,PropAuthenticationData +// "\\W\EM)\142\185\DC1\CAN\131f\STX\200\RS\230u\147\187\165\205"] +TEST(Subscribe5QCTest, Encode71) { uint8_t pkt[] = { - 0x33, 0x92, 0x2, 0x0, 0x14, 0x6b, 0x48, 0xa9, 0x9c, 0x6, 0x7, 0xeb, 0x32, 0x51, 0x80, 0x94, 0x1c, 0x87, 0x8e, - 0x1c, 0x5d, 0xa8, 0x6a, 0xf6, 0xd0, 0x5d, 0x20, 0xf5, 0x1, 0x9, 0x0, 0x1d, 0x87, 0xa5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x17, 0xb7, 0x2a, 0x7d, 0x8, 0x0, - 0x19, 0xc8, 0x82, 0x0, 0xd5, 0x19, 0xd0, 0x68, 0xef, 0xab, 0x44, 0xca, 0x86, 0xb2, 0x17, 0x59, 0x5c, 0xd4, 0x28, - 0x9d, 0x33, 0x63, 0xad, 0x50, 0x39, 0x28, 0xb, 0x1c, 0x16, 0x0, 0xa, 0x87, 0xb7, 0x15, 0x7f, 0xf5, 0xbd, 0xa2, - 0x4a, 0xdf, 0x1b, 0x27, 0x0, 0x0, 0x6d, 0xa1, 0x44, 0xc3, 0xa4}; - - uint8_t buf[287] = {0}; - - uint8_t topic_bytes[] = {0x6b, 0x48, 0xa9, 0x9c, 0x6, 0x7, 0xeb, 0x32, 0x51, 0x80, - 0x94, 0x1c, 0x87, 0x8e, 0x1c, 0x5d, 0xa8, 0x6a, 0xf6, 0xd0}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x44, 0xc3, 0xa4}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; - - uint8_t bytesprops0[] = {0x87, 0xa5, 0xca, 0x54, 0xc7, 0x2, 0x96, 0x1f, 0x26, 0xab, 0x62, 0xab, 0x93, 0xea, 0x0, - 0x2a, 0x7b, 0x28, 0xd7, 0xe3, 0xfc, 0xda, 0xf6, 0xa8, 0x7c, 0x3a, 0x9a, 0x3c, 0x11}; - uint8_t bytesprops1[] = {0x27, 0x87, 0xe4, 0x28, 0x9c, 0x33, 0x3a, 0x1f, 0x33, 0xba, 0x65, 0x14}; - uint8_t bytesprops2[] = {0x35}; - uint8_t bytesprops3[] = {0xad, 0x7d, 0x96, 0xf3, 0xff, 0x9, 0xa1, 0x30, 0x23, 0xea}; - uint8_t bytesprops4[] = {0xdb, 0x68, 0xcf, 0x73, 0x13, 0x37, 0x59}; - uint8_t bytesprops5[] = {0x76, 0x6e, 0x3d, 0x7d, 0xb9, 0xf5, 0x5a, 0x13, 0xc9, 0xaa, 0x6, 0xab, - 0xd4, 0xd2, 0x9d, 0x0, 0x3a, 0x8c, 0xe5, 0x67, 0xf, 0x31, 0x5, 0x4c}; - uint8_t bytesprops6[] = {0x3e, 0x15, 0xb7, 0xa0, 0x69, 0x69, 0xf7, 0xbf, 0xce, 0xde, 0x6a, 0x28, 0x28, - 0x1f, 0x36, 0x44, 0x36, 0x4d, 0xae, 0xc4, 0x67, 0xd4, 0xdf, 0xde, 0xea, 0xa6}; - uint8_t bytesprops7[] = {0x6, 0xcd, 0x2b, 0xb3, 0x7, 0x26, 0xe0, 0xb7, 0xc8, 0x92, 0x8e, 0x79, - 0x6b, 0xb5, 0xd, 0x1d, 0x4a, 0xc0, 0x3a, 0xec, 0x31, 0x17, 0xb7}; - uint8_t bytesprops8[] = {0xc8, 0x82, 0x0, 0xd5, 0x19, 0xd0, 0x68, 0xef, 0xab, 0x44, 0xca, 0x86, 0xb2, - 0x17, 0x59, 0x5c, 0xd4, 0x28, 0x9d, 0x33, 0x63, 0xad, 0x50, 0x39, 0x28}; - uint8_t bytesprops9[] = {0x87, 0xb7, 0x15, 0x7f, 0xf5, 0xbd, 0xa2, 0x4a, 0xdf, 0x1b}; + 0x82, 0xe9, 0x2, 0x6e, 0xae, 0xf2, 0x1, 0x2a, 0x22, 0x13, 0x28, 0x7, 0x15, 0x0, 0x1e, 0x7f, 0x3d, 0x7a, 0xcd, + 0x80, 0xb5, 0x43, 0xe8, 0x2a, 0xf2, 0x3a, 0xe9, 0x4c, 0xb, 0x65, 0x34, 0x8f, 0x44, 0x9b, 0xd0, 0x30, 0x68, 0x74, + 0x84, 0x5a, 0x7b, 0x1b, 0xee, 0x9f, 0xc9, 0x29, 0xf8, 0x25, 0x1c, 0x2, 0x0, 0x0, 0x7e, 0xe9, 0x27, 0x0, 0x0, + 0x54, 0x8, 0x16, 0x0, 0x1, 0x93, 0x2, 0x0, 0x0, 0x62, 0x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 0x7, 0xc5, 0xec, 0xa6, 0xed, 0xc6, 0x5c, 0x2d, 0xde, 0x61, 0xd, + 0x8c, 0x9e, 0x4e, 0xc7, 0x37, 0xb2, 0x1e, 0x60, 0x3d, 0x3e, 0x21, 0x45, 0x0, 0x0, 0x3, 0xa3, 0x2f, 0x3f, 0x1, + 0x0, 0x1, 0x5f, 0x2, 0x0, 0x16, 0x5c, 0x9e, 0xe4, 0xdf, 0x17, 0x3a, 0x96, 0x29, 0x64, 0x59, 0x7c, 0x21, 0xec, + 0xcd, 0xa4, 0x73, 0x8b, 0xb, 0xa7, 0x3e, 0xdd, 0x19, 0x2, 0x0, 0x16, 0xe8, 0xd0, 0xb9, 0x66, 0x9d, 0xf7, 0x4e, + 0xbe, 0xbf, 0x3, 0xd4, 0x9, 0xd5, 0xe5, 0x1, 0x20, 0xce, 0xb, 0xb2, 0x40, 0xa2, 0x5e, 0x1, 0x0, 0xf, 0x6d, + 0x89, 0xb, 0xc, 0x37, 0x8d, 0x26, 0xd8, 0x40, 0x9e, 0x21, 0x1d, 0xc0, 0xbf, 0xbd, 0x1, 0x0, 0x4, 0x4, 0x67, + 0xf1, 0xa7, 0x1}; + + uint8_t buf[374] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xc4, 0xd0, 0x78, 0x91, 0x7, 0xc5, 0xec, 0xa6, 0xed, 0xc6, 0x5c, 0x2d, 0xde, 0x61, + 0xd, 0x8c, 0x9e, 0x4e, 0xc7, 0x37, 0xb2, 0x1e, 0x60, 0x3d, 0x3e, 0x21, 0x45}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa3, 0x2f, 0x3f}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5f}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x5c, 0x9e, 0xe4, 0xdf, 0x17, 0x3a, 0x96, 0x29, 0x64, 0x59, 0x7c, + 0x21, 0xec, 0xcd, 0xa4, 0x73, 0x8b, 0xb, 0xa7, 0x3e, 0xdd, 0x19}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe8, 0xd0, 0xb9, 0x66, 0x9d, 0xf7, 0x4e, 0xbe, 0xbf, 0x3, 0xd4, + 0x9, 0xd5, 0xe5, 0x1, 0x20, 0xce, 0xb, 0xb2, 0x40, 0xa2, 0x5e}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6d, 0x89, 0xb, 0xc, 0x37, 0x8d, 0x26, 0xd8, + 0x40, 0x9e, 0x21, 0x1d, 0xc0, 0xbf, 0xbd}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x4, 0x67, 0xf1, 0xa7}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x7f, 0x3d, 0x7a, 0xcd, 0x80, 0xb5, 0x43, 0xe8, 0x2a, 0xf2, 0x3a, 0xe9, 0x4c, 0xb, 0x65, + 0x34, 0x8f, 0x44, 0x9b, 0xd0, 0x30, 0x68, 0x74, 0x84, 0x5a, 0x7b, 0x1b, 0xee, 0x9f, 0xc9}; + uint8_t bytesprops1[] = {0x93}; + uint8_t bytesprops3[] = {0x80}; + uint8_t bytesprops2[] = {0x9d, 0xa, 0x6, 0xcb, 0x95, 0x80, 0x7, 0x16, 0x8e, + 0x14, 0x7d, 0x85, 0xc1, 0xa8, 0xe4, 0xf3, 0xc8}; + uint8_t bytesprops4[] = {0x93, 0x10, 0xac, 0x19, 0x9f, 0xac, 0x72, 0xdf, 0x5a, 0x66, 0x69, 0x2e}; + uint8_t bytesprops5[] = {0x9, 0x3, 0x4d, 0x62, 0x78, 0xfd, 0x5, 0x34, 0x41, 0x7d, 0x45, 0x1a, + 0x52, 0x9, 0x8a, 0x93, 0x8d, 0xc7, 0xfd, 0x2a, 0x56, 0x3d, 0xcd, 0x9d}; + uint8_t bytesprops6[] = {0x18, 0xe6, 0x36, 0xe, 0xcc, 0xd4, 0x66, 0x89, 0x6d, 0xe3, 0x27, 0xea, 0xa6, 0x6f, 0xb0, + 0xde, 0x88, 0x3d, 0x27, 0x46, 0xb5, 0x89, 0x47, 0x79, 0xdc, 0xcc, 0x7, 0xc0, 0xa}; + uint8_t bytesprops8[] = {0xb0, 0xf4, 0xe6, 0x8, 0xd5, 0x1, 0xc9, 0x6c, 0x50, 0x5c, + 0x9e, 0xca, 0x7a, 0xa3, 0x21, 0xc6, 0x50, 0x85, 0xca}; + uint8_t bytesprops7[] = {0xf5, 0xc}; + uint8_t bytesprops9[] = {0x5c, 0x57, 0x19, 0x29, 0x8e, 0xb9, 0x11, 0x18, 0x83, 0x66, + 0x2, 0xc8, 0x1e, 0xe6, 0x75, 0x93, 0xbb, 0xa5, 0xcd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16471}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22772}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5843}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14127}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25815}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9063}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4463}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28065}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10247}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32489}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21512}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25286}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops2}, .v = {1, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24957}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32172}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22638}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19477}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20439}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22562}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20475}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14896}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops7}, .v = {19, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 23840, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28334, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 26598 [("=\225\250g\177\216\249\&8\252='RyD\192\199@\SOh\247\158\236\151\&4d\199\247",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("#\151\183Z\151O\182\172\150*i\\\161\230\221\176\251\180\217H;]\215\250\196L\201\228\DC3\244",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\243\152\219Kk\182Q,eE \RS*/\SYN\134V\DC3FyOS[",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\139\SOH\t\179g\DC3&n'\158C\223Y\254",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\205$\145XN\129y\188+2W2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [PropRequestResponseInformation 96,PropMessageExpiryInterval +// 28136,PropContentType +// "\214\134\176\130\223\&1\163\252\\\195\213\226\&5o\218Y6\177\140\252\204",PropRequestResponseInformation +// 139,PropReceiveMaximum 16930,PropUserProperty "\137\&1\174\174" +// "\244\252\233$*-\ESC\217z\183\165M\DC1\CAN\159S\238\232\175&|j\228U\226\171*pd\199",PropAssignedClientIdentifier +// "",PropCorrelationData "\FS\161",PropTopicAlias 6017,PropAuthenticationData +// "\NAKX\210\187\SO<\246\&2\208QF\165\205\152\145\252\203",PropReasonString +// "\165\194\150{sK\198\166\n2\174Q\213\194\&29\237_\EM!?\135\&3$\DEL\141Y\240\EM",PropResponseInformation +// "\t\245Mk@N\240\&4IC,^\249\DC2\179\SIq\211\135}v?8\135\190\159.\a.",PropReasonString +// "\f\214R3\DC2mI\182\202Dr\147\176h\ETXr\244\139\&9\NUL",PropReasonString "5\214y",PropSubscriptionIdentifierAvailable +// 161,PropSubscriptionIdentifierAvailable 197] +TEST(Subscribe5QCTest, Encode72) { + uint8_t pkt[] = { + 0x82, 0xcb, 0x2, 0x67, 0xe6, 0xcb, 0x1, 0x19, 0x60, 0x2, 0x0, 0x0, 0x6d, 0xe8, 0x3, 0x0, 0x15, 0xd6, 0x86, + 0xb0, 0x82, 0xdf, 0x31, 0xa3, 0xfc, 0x5c, 0xc3, 0xd5, 0xe2, 0x35, 0x6f, 0xda, 0x59, 0x36, 0xb1, 0x8c, 0xfc, 0xcc, + 0x19, 0x8b, 0x21, 0x42, 0x22, 0x26, 0x0, 0x4, 0x89, 0x31, 0xae, 0xae, 0x0, 0x1e, 0xf4, 0xfc, 0xe9, 0x24, 0x2a, + 0x2d, 0x1b, 0xd9, 0x7a, 0xb7, 0xa5, 0x4d, 0x11, 0x18, 0x9f, 0x53, 0xee, 0xe8, 0xaf, 0x26, 0x7c, 0x6a, 0xe4, 0x55, + 0xe2, 0xab, 0x2a, 0x70, 0x64, 0xc7, 0x12, 0x0, 0x0, 0x9, 0x0, 0x2, 0x1c, 0xa1, 0x23, 0x17, 0x81, 0x16, 0x0, + 0x11, 0x15, 0x58, 0xd2, 0xbb, 0xe, 0x3c, 0xf6, 0x32, 0xd0, 0x51, 0x46, 0xa5, 0xcd, 0x98, 0x91, 0xfc, 0xcb, 0x1f, + 0x0, 0x1d, 0xa5, 0xc2, 0x96, 0x7b, 0x73, 0x4b, 0xc6, 0xa6, 0xa, 0x32, 0xae, 0x51, 0xd5, 0xc2, 0x32, 0x39, 0xed, + 0x5f, 0x19, 0x21, 0x3f, 0x87, 0x33, 0x24, 0x7f, 0x8d, 0x59, 0xf0, 0x19, 0x1a, 0x0, 0x1d, 0x9, 0xf5, 0x4d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up = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "P\147\149\202g\200\140\&8\251", -// _pubPktID = 0, _pubBody = "\161k\226l\198m\147.\232\136\&3>\222>\138\225{\176s\227!\217C\RS\209_", _pubProps = -// [PropSubscriptionIdentifier 13,PropAuthenticationMethod "\234\v -// \227;i\206\135\130\220\158q{\216\161\246",PropMaximumQoS 236,PropServerReference -// "\ETXdV\185\248\140\206\132\190\165\195\147\128\"\DLE\147",PropReceiveMaximum 97,PropTopicAlias 16366]} -TEST(Publish5QCTest, Encode71) { - uint8_t pkt[] = {0x31, 0x56, 0x0, 0x9, 0x50, 0x93, 0x95, 0xca, 0x67, 0xc8, 0x8c, 0x38, 0xfb, 0x30, 0xb, - 0xd, 0x15, 0x0, 0x10, 0xea, 0xb, 0x20, 0xe3, 0x3b, 0x69, 0xce, 0x87, 0x82, 0xdc, 0x9e, - 0x71, 0x7b, 0xd8, 0xa1, 0xf6, 0x24, 0xec, 0x1c, 0x0, 0x10, 0x3, 0x64, 0x56, 0xb9, 0xf8, - 0x8c, 0xce, 0x84, 0xbe, 0xa5, 0xc3, 0x93, 0x80, 0x22, 0x10, 0x93, 0x21, 0x0, 0x61, 0x23, - 0x3f, 0xee, 0xa1, 0x6b, 0xe2, 0x6c, 0xc6, 0x6d, 0x93, 0x2e, 0xe8, 0x88, 0x33, 0x3e, 0xde, - 0x3e, 0x8a, 0xe1, 0x7b, 0xb0, 0x73, 0xe3, 0x21, 0xd9, 0x43, 0x1e, 0xd1, 0x5f}; - - uint8_t buf[98] = {0}; - - uint8_t topic_bytes[] = {0x50, 0x93, 0x95, 0xca, 0x67, 0xc8, 0x8c, 0x38, 0xfb}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xa1, 0x6b, 0xe2, 0x6c, 0xc6, 0x6d, 0x93, 0x2e, 0xe8, 0x88, 0x33, 0x3e, 0xde, - 0x3e, 0x8a, 0xe1, 0x7b, 0xb0, 0x73, 0xe3, 0x21, 0xd9, 0x43, 0x1e, 0xd1, 0x5f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + uint8_t buf[344] = {0}; - uint8_t bytesprops0[] = {0xea, 0xb, 0x20, 0xe3, 0x3b, 0x69, 0xce, 0x87, - 0x82, 0xdc, 0x9e, 0x71, 0x7b, 0xd8, 0xa1, 0xf6}; - uint8_t bytesprops1[] = {0x3, 0x64, 0x56, 0xb9, 0xf8, 0x8c, 0xce, 0x84, - 0xbe, 0xa5, 0xc3, 0x93, 0x80, 0x22, 0x10, 0x93}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x3d, 0xe1, 0xfa, 0x67, 0xb1, 0xd8, 0xf9, 0x38, 0xfc, 0x3d, 0x27, 0x52, 0x79, 0x44, + 0xc0, 0xc7, 0x40, 0xe, 0x68, 0xf7, 0x9e, 0xec, 0x97, 0x34, 0x64, 0xc7, 0xf7}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x23, 0x97, 0xb7, 0x5a, 0x97, 0x4f, 0xb6, 0xac, 0x96, 0x2a, + 0x69, 0x5c, 0xa1, 0xe6, 0xdd, 0xb0, 0xfb, 0xb4, 0xd9, 0x48, + 0x3b, 0x5d, 0xd7, 0xfa, 0xc4, 0x4c, 0xc9, 0xe4, 0x13, 0xf4}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf3, 0x98, 0xdb, 0x4b, 0x6b, 0xb6, 0x51, 0x2c, 0x65, 0x45, 0x20, 0x1e, + 0x2a, 0x2f, 0x16, 0x86, 0x56, 0x13, 0x46, 0x79, 0x4f, 0x53, 0x5b}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x8b, 0x1, 0x9, 0xb3, 0x67, 0x13, 0x26, 0x6e, 0x27, 0x9e, 0x43, 0xdf, 0x59, 0xfe}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xcd, 0x24, 0x91, 0x58, 0x4e, 0x81, 0x79, 0xbc, 0x2b, 0x32, 0x57, 0x32}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xd6, 0x86, 0xb0, 0x82, 0xdf, 0x31, 0xa3, 0xfc, 0x5c, 0xc3, 0xd5, + 0xe2, 0x35, 0x6f, 0xda, 0x59, 0x36, 0xb1, 0x8c, 0xfc, 0xcc}; + uint8_t bytesprops2[] = {0xf4, 0xfc, 0xe9, 0x24, 0x2a, 0x2d, 0x1b, 0xd9, 0x7a, 0xb7, 0xa5, 0x4d, 0x11, 0x18, 0x9f, + 0x53, 0xee, 0xe8, 0xaf, 0x26, 0x7c, 0x6a, 0xe4, 0x55, 0xe2, 0xab, 0x2a, 0x70, 0x64, 0xc7}; + uint8_t bytesprops1[] = {0x89, 0x31, 0xae, 0xae}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x1c, 0xa1}; + uint8_t bytesprops5[] = {0x15, 0x58, 0xd2, 0xbb, 0xe, 0x3c, 0xf6, 0x32, 0xd0, + 0x51, 0x46, 0xa5, 0xcd, 0x98, 0x91, 0xfc, 0xcb}; + uint8_t bytesprops6[] = {0xa5, 0xc2, 0x96, 0x7b, 0x73, 0x4b, 0xc6, 0xa6, 0xa, 0x32, 0xae, 0x51, 0xd5, 0xc2, 0x32, + 0x39, 0xed, 0x5f, 0x19, 0x21, 0x3f, 0x87, 0x33, 0x24, 0x7f, 0x8d, 0x59, 0xf0, 0x19}; + uint8_t bytesprops7[] = {0x9, 0xf5, 0x4d, 0x6b, 0x40, 0x4e, 0xf0, 0x34, 0x49, 0x43, 0x2c, 0x5e, 0xf9, 0x12, 0xb3, + 0xf, 0x71, 0xd3, 0x87, 0x7d, 0x76, 0x3f, 0x38, 0x87, 0xbe, 0x9f, 0x2e, 0x7, 0x2e}; + uint8_t bytesprops8[] = {0xc, 0xd6, 0x52, 0x33, 0x12, 0x6d, 0x49, 0xb6, 0xca, 0x44, + 0x72, 0x93, 0xb0, 0x68, 0x3, 0x72, 0xf4, 0x8b, 0x39, 0x0}; + uint8_t bytesprops9[] = {0x35, 0xd6, 0x79}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 97}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16366}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28136}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16930}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6017}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 197}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26598, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 8075 [("\153\219wC\224\141\212\158d\179\204\165\177\194fH\170\138^",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\163{\DC4\190\210\150W\162\228}\131*;\DC1\208;\155n\214I\147\176\137\176",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\v\244\209y\179\242\230\161\147:u\140\228\&5k\177\179\250",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("f75^!\161\178\EM\198Ir\ACK*\ETXO\202\255",PropMessageExpiryInterval 3225,PropRequestProblemInformation -// 186,PropSharedSubscriptionAvailable 215,PropRetainAvailable 131,PropResponseTopic -// "P\137\NAK\DC1\165v\243\148\DC29\219-\159\145\239 \NUL\174\254\157\&62\RS\250\144)\"\238$\226",PropCorrelationData -// "\197\146\f\170\ETX\151N\212^",PropRetainAvailable 42,PropSessionExpiryInterval 15247]} -TEST(Publish5QCTest, Encode72) { - uint8_t pkt[] = { - 0x30, 0x8f, 0x2, 0x0, 0x18, 0xfb, 0xd7, 0x18, 0x5b, 0x73, 0x53, 0xe, 0x3c, 0x6e, 0x18, 0x32, 0xb1, 0x47, 0x6, - 0xb7, 0x99, 0xc7, 0xde, 0x8c, 0x60, 0x63, 0xb2, 0x40, 0x97, 0xde, 0x1, 0x25, 0xc9, 0x17, 0x3e, 0x17, 0xab, 0x1f, - 0x0, 0xf, 0xe0, 0x2b, 0x2f, 0xa0, 0xdb, 0x24, 0x22, 0xc2, 0x6f, 0x80, 0xe, 0x13, 0x59, 0xa7, 0x42, 0xb, 0x1f, - 0x15, 0x0, 0xc, 0x9a, 0x67, 0xe3, 0xb0, 0x33, 0xd7, 0x5d, 0x98, 0x4, 0xb, 0xdd, 0x75, 0x16, 0x0, 0xe, 0x63, - 0xbd, 0xce, 0xfd, 0x73, 0x92, 0x54, 0x70, 0xff, 0x94, 0x84, 0xd4, 0xb1, 0x7e, 0x16, 0x0, 0x13, 0xd5, 0xb8, 0x8f, - 0xa1, 0xd4, 0x68, 0xcf, 0x26, 0x9c, 0xa5, 0xc3, 0x21, 0xcc, 0xfa, 0x62, 0x16, 0x7a, 0xd6, 0x46, 0x2, 0x0, 0x0, - 0x10, 0xf1, 0x19, 0x38, 0x23, 0xe, 0x5d, 0x1a, 0x0, 0xe, 0xa0, 0x22, 0x4a, 0x92, 0xfc, 0xef, 0xd1, 0x4e, 0x70, - 0x58, 0x8a, 0xee, 0xbf, 0x89, 0x2, 0x0, 0x0, 0x3a, 0xcc, 0x11, 0x0, 0x0, 0x7e, 0x63, 0x19, 0xb9, 0x22, 0x3f, - 0x93, 0x3, 0x0, 0x4, 0xbc, 0x65, 0xa, 0x86, 0x17, 0x84, 0x19, 0x94, 0x8, 0x0, 0x17, 0x79, 0xb6, 0x27, 0x43, - 0x50, 0x3e, 0x66, 0x37, 0x35, 0x5e, 0x21, 0xa1, 0xb2, 0x19, 0xc6, 0x49, 0x72, 0x6, 0x2a, 0x3, 0x4f, 0xca, 0xff, - 0x2, 0x0, 0x0, 0xc, 0x99, 0x17, 0xba, 0x2a, 0xd7, 0x25, 0x83, 0x8, 0x0, 0x1e, 0x50, 0x89, 0x15, 0x11, 0xa5, - 0x76, 0xf3, 0x94, 0x12, 0x39, 0xdb, 0x2d, 0x9f, 0x91, 0xef, 0x20, 0x0, 0xae, 0xfe, 0x9d, 0x36, 0x32, 0x1e, 0xfa, - 0x90, 0x29, 0x22, 0xee, 0x24, 0xe2, 0x9, 0x0, 0x9, 0xc5, 0x92, 0xc, 0xaa, 0x3, 0x97, 0x4e, 0xd4, 0x5e, 0x25, - 0x2a, 0x11, 0x0, 0x0, 0x3b, 0x8f, 0xa5, 0xa8, 0x8a, 0x4f, 0xe4, 0x4e, 0x39, 0x65, 0x74, 0xbf, 0xc7, 0x2c, 0x7f, - 0xf4, 0x24, 0x50, 0xc4, 0x6, 0xe9, 0x72, 0x63}; - - uint8_t buf[284] = {0}; - - uint8_t topic_bytes[] = {0xfb, 0xd7, 0x18, 0x5b, 0x73, 0x53, 0xe, 0x3c, 0x6e, 0x18, 0x32, 0xb1, - 0x47, 0x6, 0xb7, 0x99, 0xc7, 0xde, 0x8c, 0x60, 0x63, 0xb2, 0x40, 0x97}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xa5, 0xa8, 0x8a, 0x4f, 0xe4, 0x4e, 0x39, 0x65, 0x74, 0xbf, 0xc7, - 0x2c, 0x7f, 0xf4, 0x24, 0x50, 0xc4, 0x6, 0xe9, 0x72, 0x63}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - - uint8_t bytesprops0[] = {0xe0, 0x2b, 0x2f, 0xa0, 0xdb, 0x24, 0x22, 0xc2, 0x6f, 0x80, 0xe, 0x13, 0x59, 0xa7, 0x42}; - uint8_t bytesprops1[] = {0x9a, 0x67, 0xe3, 0xb0, 0x33, 0xd7, 0x5d, 0x98, 0x4, 0xb, 0xdd, 0x75}; - uint8_t bytesprops2[] = {0x63, 0xbd, 0xce, 0xfd, 0x73, 0x92, 0x54, 0x70, 0xff, 0x94, 0x84, 0xd4, 0xb1, 0x7e}; - uint8_t bytesprops3[] = {0xd5, 0xb8, 0x8f, 0xa1, 0xd4, 0x68, 0xcf, 0x26, 0x9c, 0xa5, - 0xc3, 0x21, 0xcc, 0xfa, 0x62, 0x16, 0x7a, 0xd6, 0x46}; - uint8_t bytesprops4[] = {0xa0, 0x22, 0x4a, 0x92, 0xfc, 0xef, 0xd1, 0x4e, 0x70, 0x58, 0x8a, 0xee, 0xbf, 0x89}; - uint8_t bytesprops5[] = {0xbc, 0x65, 0xa, 0x86}; - uint8_t bytesprops6[] = {0x79, 0xb6, 0x27, 0x43, 0x50, 0x3e, 0x66, 0x37, 0x35, 0x5e, 0x21, 0xa1, - 0xb2, 0x19, 0xc6, 0x49, 0x72, 0x6, 0x2a, 0x3, 0x4f, 0xca, 0xff}; - uint8_t bytesprops7[] = {0x50, 0x89, 0x15, 0x11, 0xa5, 0x76, 0xf3, 0x94, 0x12, 0x39, 0xdb, 0x2d, 0x9f, 0x91, 0xef, - 0x20, 0x0, 0xae, 0xfe, 0x9d, 0x36, 0x32, 0x1e, 0xfa, 0x90, 0x29, 0x22, 0xee, 0x24, 0xe2}; - uint8_t bytesprops8[] = {0xc5, 0x92, 0xc, 0xaa, 0x3, 0x97, 0x4e, 0xd4, 0x5e}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x99, 0xdb, 0x77, 0x43, 0xe0, 0x8d, 0xd4, 0x9e, 0x64, 0xb3, + 0xcc, 0xa5, 0xb1, 0xc2, 0x66, 0x48, 0xaa, 0x8a, 0x5e}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa3, 0x7b, 0x14, 0xbe, 0xd2, 0x96, 0x57, 0xa2, 0xe4, 0x7d, 0x83, 0x2a, + 0x3b, 0x11, 0xd0, 0x3b, 0x9b, 0x6e, 0xd6, 0x49, 0x93, 0xb0, 0x89, 0xb0}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb, 0xf4, 0xd1, 0x79, 0xb3, 0xf2, 0xe6, 0xa1, 0x93, + 0x3a, 0x75, 0x8c, 0xe4, 0x35, 0x6b, 0xb1, 0xb3, 0xfa}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x3c, 0x63, 0xdc, 0x51, 0xdb, 0xac, 0x2c, 0xa9, 0x87, 0xd0, 0x8d, + 0x6b, 0x73, 0x84, 0x22, 0xe3, 0x1, 0xc7, 0x88, 0x1a, 0x40}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x15, 0xf8, 0xca, 0xf4, 0x19, 0x68, 0x23, 0xaf, 0x86, 0xc1, 0xfa, 0x12, + 0x4a, 0xa6, 0x6f, 0x26, 0x5f, 0x6, 0x1c, 0x1a, 0xe7, 0xdb, 0x80}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x34, 0x1a, 0xc5, 0x4b, 0x31, 0x7, 0x85, 0x16, 0x32, 0xd4, 0x5a, 0x6d, 0x99}; + uint8_t bytesprops3[] = {0x59, 0xce, 0xb6, 0x94, 0x34, 0xfc, 0x53, 0x66, 0x5f, 0x2, 0xaa, 0xf4, 0xf5, 0x89, + 0x49, 0x15, 0x2d, 0xe1, 0xf8, 0x5b, 0x50, 0xbf, 0xe4, 0xf4, 0x44, 0x6c, 0x27, 0x7e}; + uint8_t bytesprops2[] = {0x8c, 0x6a, 0x8a, 0x58, 0x79, 0x1f, 0x8c, 0x98, 0xef, 0xe9, 0x48, + 0x1f, 0x32, 0xf2, 0xe3, 0x56, 0x7, 0xec, 0xd7, 0x5e, 0xda}; + uint8_t bytesprops5[] = {0xc5, 0x2e, 0x76, 0x51, 0xac, 0xf0, 0x3b, 0xb, 0x92, 0x7f, + 0x8a, 0xfc, 0x6a, 0x10, 0xd9, 0x82, 0xcf, 0x49, 0x4a, 0xfd}; + uint8_t bytesprops4[] = {0x60, 0xfc, 0xa0, 0xc6, 0xe7, 0x56, 0xca, 0x6f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4337}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3677}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15052}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32355}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16275}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3225}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15247}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {28, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29685}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19746}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops4}, .v = {20, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 204}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 29047, _pubBody = -// "l-\198\144%\200:}\215\167\168\213&!\132`\221\FSl\\\157?@-\132&\136", _pubProps = [PropSharedSubscriptionAvailable -// 251,PropTopicAliasMaximum 28572]} -TEST(Publish5QCTest, Encode73) { - uint8_t pkt[] = {0x3c, 0x25, 0x0, 0x0, 0x71, 0x77, 0x5, 0x2a, 0xfb, 0x22, 0x6f, 0x9c, 0x6c, - 0x2d, 0xc6, 0x90, 0x25, 0xc8, 0x3a, 0x7d, 0xd7, 0xa7, 0xa8, 0xd5, 0x26, 0x21, - 0x84, 0x60, 0xdd, 0x1c, 0x6c, 0x5c, 0x9d, 0x3f, 0x40, 0x2d, 0x84, 0x26, 0x88}; - - uint8_t buf[49] = {0}; - - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x6c, 0x2d, 0xc6, 0x90, 0x25, 0xc8, 0x3a, 0x7d, 0xd7, 0xa7, 0xa8, 0xd5, 0x26, 0x21, - 0x84, 0x60, 0xdd, 0x1c, 0x6c, 0x5c, 0x9d, 0x3f, 0x40, 0x2d, 0x84, 0x26, 0x88}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28572}}, - }; - - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29047, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "E\209", _pubPktID = 7404, _pubBody -// = "\235\ETX\185\192\212\183\ACK\\+\188\165\230>\\U", _pubProps = [PropMaximumPacketSize -// 18479,PropAuthenticationMethod -// "O\166\166e\146\135mG+\NAK\SUB\247\190\242\FS\180X&J\250)\SI\a=\249",PropServerKeepAlive 28420,PropReceiveMaximum -// 1572,PropAuthenticationMethod "\150\DC4ior`r\248m",PropPayloadFormatIndicator 10,PropMaximumPacketSize -// 17799,PropPayloadFormatIndicator 90,PropRequestProblemInformation 236,PropRetainAvailable -// 72,PropPayloadFormatIndicator 83,PropSessionExpiryInterval 12274,PropSubscriptionIdentifierAvailable 121]} -TEST(Publish5QCTest, Encode74) { - uint8_t pkt[] = {0x32, 0x5f, 0x0, 0x2, 0x45, 0xd1, 0x1c, 0xec, 0x49, 0x27, 0x0, 0x0, 0x48, 0x2f, 0x15, 0x0, 0x19, - 0x4f, 0xa6, 0xa6, 0x65, 0x92, 0x87, 0x6d, 0x47, 0x2b, 0x15, 0x1a, 0xf7, 0xbe, 0xf2, 0x1c, 0xb4, 0x58, - 0x26, 0x4a, 0xfa, 0x29, 0xf, 0x7, 0x3d, 0xf9, 0x13, 0x6f, 0x4, 0x21, 0x6, 0x24, 0x15, 0x0, 0x9, - 0x96, 0x14, 0x69, 0x6f, 0x72, 0x60, 0x72, 0xf8, 0x6d, 0x1, 0xa, 0x27, 0x0, 0x0, 0x45, 0x87, 0x1, - 0x5a, 0x17, 0xec, 0x25, 0x48, 0x1, 0x53, 0x11, 0x0, 0x0, 0x2f, 0xf2, 0x29, 0x79, 0xeb, 0x3, 0xb9, - 0xc0, 0xd4, 0xb7, 0x6, 0x5c, 0x2b, 0xbc, 0xa5, 0xe6, 0x3e, 0x5c, 0x55}; - - uint8_t buf[107] = {0}; - - uint8_t topic_bytes[] = {0x45, 0xd1}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xeb, 0x3, 0xb9, 0xc0, 0xd4, 0xb7, 0x6, 0x5c, 0x2b, 0xbc, 0xa5, 0xe6, 0x3e, 0x5c, 0x55}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0x4f, 0xa6, 0xa6, 0x65, 0x92, 0x87, 0x6d, 0x47, 0x2b, 0x15, 0x1a, 0xf7, 0xbe, - 0xf2, 0x1c, 0xb4, 0x58, 0x26, 0x4a, 0xfa, 0x29, 0xf, 0x7, 0x3d, 0xf9}; - uint8_t bytesprops1[] = {0x96, 0x14, 0x69, 0x6f, 0x72, 0x60, 0x72, 0xf8, 0x6d}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18479}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28420}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1572}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17799}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12274}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 121}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7404, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\198\225\DC4\245\&5\248\178f[\186\216.\218\247", _pubPktID = 16102, _pubBody = "\213@o\181\227\224\214\214UA", -// _pubProps = [PropMaximumQoS 70,PropServerReference "F\230yxn{S\217\FS\250\193\172\225f\SYN\158"]} -TEST(Publish5QCTest, Encode75) { - uint8_t pkt[] = {0x32, 0x32, 0x0, 0xe, 0xc6, 0xe1, 0x14, 0xf5, 0x35, 0xf8, 0xb2, 0x66, 0x5b, - 0xba, 0xd8, 0x2e, 0xda, 0xf7, 0x3e, 0xe6, 0x15, 0x24, 0x46, 0x1c, 0x0, 0x10, - 0x46, 0xe6, 0x79, 0x78, 0x6e, 0x7b, 0x53, 0xd9, 0x1c, 0xfa, 0xc1, 0xac, 0xe1, - 0x66, 0x16, 0x9e, 0xd5, 0x40, 0x6f, 0xb5, 0xe3, 0xe0, 0xd6, 0xd6, 0x55, 0x41}; - - uint8_t buf[62] = {0}; - - uint8_t topic_bytes[] = {0xc6, 0xe1, 0x14, 0xf5, 0x35, 0xf8, 0xb2, 0x66, 0x5b, 0xba, 0xd8, 0x2e, 0xda, 0xf7}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xd5, 0x40, 0x6f, 0xb5, 0xe3, 0xe0, 0xd6, 0xd6, 0x55, 0x41}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; - - uint8_t bytesprops0[] = {0x46, 0xe6, 0x79, 0x78, 0x6e, 0x7b, 0x53, 0xd9, - 0x1c, 0xfa, 0xc1, 0xac, 0xe1, 0x66, 0x16, 0x9e}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, - }; - - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16102, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 19098, _pubBody = -// "\216\241'G\183\&2\SO\NAK\254\130\&1\161\176A=\131x\SUB\190", _pubProps = [PropWildcardSubscriptionAvailable -// 221,PropSharedSubscriptionAvailable 221,PropReceiveMaximum 23497,PropSessionExpiryInterval 18379,PropTopicAlias -// 21052,PropWildcardSubscriptionAvailable 53,PropResponseTopic -// "\232\203\230\130T\137t\149Y\153\204\STX\148",PropSessionExpiryInterval 27272,PropRequestResponseInformation -// 206,PropWillDelayInterval 31,PropAuthenticationData -// "@\199\n7]\241\t\ESC\159\159\230k]\206#\232I\129Gs",PropRequestResponseInformation 120,PropResponseTopic -// "^\142\168r\238\161p\161\255\185\ESC\USd\182\&4\213",PropSubscriptionIdentifier 9]} -TEST(Publish5QCTest, Encode76) { - uint8_t pkt[] = {0x3b, 0x73, 0x0, 0x0, 0x4a, 0x9a, 0x5b, 0x28, 0xdd, 0x2a, 0xdd, 0x21, 0x5b, 0xc9, 0x11, 0x0, 0x0, - 0x47, 0xcb, 0x23, 0x52, 0x3c, 0x28, 0x35, 0x8, 0x0, 0xd, 0xe8, 0xcb, 0xe6, 0x82, 0x54, 0x89, 0x74, - 0x95, 0x59, 0x99, 0xcc, 0x2, 0x94, 0x11, 0x0, 0x0, 0x6a, 0x88, 0x19, 0xce, 0x18, 0x0, 0x0, 0x0, - 0x1f, 0x16, 0x0, 0x14, 0x40, 0xc7, 0xa, 0x37, 0x5d, 0xf1, 0x9, 0x1b, 0x9f, 0x9f, 0xe6, 0x6b, 0x5d, - 0xce, 0x23, 0xe8, 0x49, 0x81, 0x47, 0x73, 0x19, 0x78, 0x8, 0x0, 0x10, 0x5e, 0x8e, 0xa8, 0x72, 0xee, - 0xa1, 0x70, 0xa1, 0xff, 0xb9, 0x1b, 0x1f, 0x64, 0xb6, 0x34, 0xd5, 0xb, 0x9, 0xd8, 0xf1, 0x27, 0x47, - 0xb7, 0x32, 0xe, 0x15, 0xfe, 0x82, 0x31, 0xa1, 0xb0, 0x41, 0x3d, 0x83, 0x78, 0x1a, 0xbe}; - - uint8_t buf[127] = {0}; - - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xd8, 0xf1, 0x27, 0x47, 0xb7, 0x32, 0xe, 0x15, 0xfe, 0x82, - 0x31, 0xa1, 0xb0, 0x41, 0x3d, 0x83, 0x78, 0x1a, 0xbe}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; - - uint8_t bytesprops0[] = {0xe8, 0xcb, 0xe6, 0x82, 0x54, 0x89, 0x74, 0x95, 0x59, 0x99, 0xcc, 0x2, 0x94}; - uint8_t bytesprops1[] = {0x40, 0xc7, 0xa, 0x37, 0x5d, 0xf1, 0x9, 0x1b, 0x9f, 0x9f, - 0xe6, 0x6b, 0x5d, 0xce, 0x23, 0xe8, 0x49, 0x81, 0x47, 0x73}; - uint8_t bytesprops2[] = {0x5e, 0x8e, 0xa8, 0x72, 0xee, 0xa1, 0x70, 0xa1, - 0xff, 0xb9, 0x1b, 0x1f, 0x64, 0xb6, 0x34, 0xd5}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23497}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18379}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21052}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27272}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - }; - - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 19098, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "'\243\208\&5\245\172=e^\165", -// _pubPktID = 6458, _pubBody = "\222#/ q\128\&4\174k'\135\SI:O\193\DC4\153[", _pubProps = -// [PropRequestResponseInformation 83,PropWillDelayInterval 25748,PropSharedSubscriptionAvailable -// 74,PropSessionExpiryInterval 11787,PropWildcardSubscriptionAvailable 45,PropSessionExpiryInterval -// 19470,PropTopicAliasMaximum 8721,PropSubscriptionIdentifier 19,PropServerKeepAlive 18440,PropRetainAvailable -// 171,PropSessionExpiryInterval 10776,PropAuthenticationMethod "\138",PropRetainAvailable 45,PropReceiveMaximum -// 31306,PropResponseTopic ";t\NUL\182\143\NUL\131+P",PropServerKeepAlive 26319,PropWillDelayInterval -// 31656,PropAuthenticationData "\159\189\DC4\142\220\169\173\246\135\206\227Q\245\197|",PropMaximumPacketSize -// 7616,PropMessageExpiryInterval 15526,PropSessionExpiryInterval 12963,PropRequestResponseInformation 185]} -TEST(Publish5QCTest, Encode77) { - uint8_t pkt[] = {0x33, 0x85, 0x1, 0x0, 0xa, 0x27, 0xf3, 0xd0, 0x35, 0xf5, 0xac, 0x3d, 0x65, 0x5e, 0xa5, 0x19, - 0x3a, 0x64, 0x19, 0x53, 0x18, 0x0, 0x0, 0x64, 0x94, 0x2a, 0x4a, 0x11, 0x0, 0x0, 0x2e, 0xb, - 0x28, 0x2d, 0x11, 0x0, 0x0, 0x4c, 0xe, 0x22, 0x22, 0x11, 0xb, 0x13, 0x13, 0x48, 0x8, 0x25, - 0xab, 0x11, 0x0, 0x0, 0x2a, 0x18, 0x15, 0x0, 0x1, 0x8a, 0x25, 0x2d, 0x21, 0x7a, 0x4a, 0x8, - 0x0, 0x9, 0x3b, 0x74, 0x0, 0xb6, 0x8f, 0x0, 0x83, 0x2b, 0x50, 0x13, 0x66, 0xcf, 0x18, 0x0, - 0x0, 0x7b, 0xa8, 0x16, 0x0, 0xf, 0x9f, 0xbd, 0x14, 0x8e, 0xdc, 0xa9, 0xad, 0xf6, 0x87, 0xce, - 0xe3, 0x51, 0xf5, 0xc5, 0x7c, 0x27, 0x0, 0x0, 0x1d, 0xc0, 0x2, 0x0, 0x0, 0x3c, 0xa6, 0x11, - 0x0, 0x0, 0x32, 0xa3, 0x19, 0xb9, 0xde, 0x23, 0x2f, 0x20, 0x71, 0x80, 0x34, 0xae, 0x6b, 0x27, - 0x87, 0xf, 0x3a, 0x4f, 0xc1, 0x14, 0x99, 0x5b}; - - uint8_t buf[146] = {0}; - - uint8_t topic_bytes[] = {0x27, 0xf3, 0xd0, 0x35, 0xf5, 0xac, 0x3d, 0x65, 0x5e, 0xa5}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xde, 0x23, 0x2f, 0x20, 0x71, 0x80, 0x34, 0xae, 0x6b, - 0x27, 0x87, 0xf, 0x3a, 0x4f, 0xc1, 0x14, 0x99, 0x5b}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; - - uint8_t bytesprops0[] = {0x8a}; - uint8_t bytesprops1[] = {0x3b, 0x74, 0x0, 0xb6, 0x8f, 0x0, 0x83, 0x2b, 0x50}; - uint8_t bytesprops2[] = {0x9f, 0xbd, 0x14, 0x8e, 0xdc, 0xa9, 0xad, 0xf6, 0x87, 0xce, 0xe3, 0x51, 0xf5, 0xc5, 0x7c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25748}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11787}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19470}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8721}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18440}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10776}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31306}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26319}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31656}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7616}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15526}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12963}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 185}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 6458, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "I\168PH\213\245]<\203\142\255\147\"\251", _pubPktID = 23705, _pubBody = -// "\136\177\214\217\&8;\253\STX\147\206\151\161\183?\r\SUB\151\230c\DLE5h\249\177\236", _pubProps = -// [PropMaximumPacketSize 12446,PropPayloadFormatIndicator 141,PropMaximumPacketSize 17105,PropMessageExpiryInterval -// 25409,PropPayloadFormatIndicator 219,PropPayloadFormatIndicator 187,PropWillDelayInterval -// 2545,PropAssignedClientIdentifier "\fA\150\166\183\170\SYN",PropMaximumQoS 249,PropMessageExpiryInterval -// 27889,PropContentType "\254\248[\251Z\ACK\171\136@z]\250\240\149\161\GS\176\SUBjM\176\183",PropResponseInformation -// "\222\f\255\239\209\159\171=v$\174\t_r\190\ACK\150u\139\198\193\225\162Qm",PropSessionExpiryInterval -// 18095,PropUserProperty "~q\143z\SI\248k\DC4\149" -// "H\237\247q]1r\f\160\142\150\149g6\246\DC4\203\190\DC3\176\209",PropSubscriptionIdentifier -// 15,PropRequestResponseInformation 74,PropSessionExpiryInterval 5607,PropRetainAvailable -// 195,PropSharedSubscriptionAvailable 217,PropContentType "\146\204\243\219\177",PropMessageExpiryInterval -// 12779,PropReasonString "f\181\t\190\137\152\128\172\226l\132\215\252q",PropServerKeepAlive -// 9876,PropSharedSubscriptionAvailable 170,PropRetainAvailable 140,PropSharedSubscriptionAvailable 79]} -TEST(Publish5QCTest, Encode78) { - uint8_t pkt[] = {0x33, 0xe9, 0x1, 0x0, 0xe, 0x49, 0xa8, 0x50, 0x48, 0xd5, 0xf5, 0x5d, 0x3c, 0xcb, 0x8e, 0xff, 0x93, - 0x22, 0xfb, 0x5c, 0x99, 0xbc, 0x1, 0x27, 0x0, 0x0, 0x30, 0x9e, 0x1, 0x8d, 0x27, 0x0, 0x0, 0x42, - 0xd1, 0x2, 0x0, 0x0, 0x63, 0x41, 0x1, 0xdb, 0x1, 0xbb, 0x18, 0x0, 0x0, 0x9, 0xf1, 0x12, 0x0, - 0x7, 0xc, 0x41, 0x96, 0xa6, 0xb7, 0xaa, 0x16, 0x24, 0xf9, 0x2, 0x0, 0x0, 0x6c, 0xf1, 0x3, 0x0, - 0x16, 0xfe, 0xf8, 0x5b, 0xfb, 0x5a, 0x6, 0xab, 0x88, 0x40, 0x7a, 0x5d, 0xfa, 0xf0, 0x95, 0xa1, 0x1d, - 0xb0, 0x1a, 0x6a, 0x4d, 0xb0, 0xb7, 0x1a, 0x0, 0x19, 0xde, 0xc, 0xff, 0xef, 0xd1, 0x9f, 0xab, 0x3d, - 0x76, 0x24, 0xae, 0x9, 0x5f, 0x72, 0xbe, 0x6, 0x96, 0x75, 0x8b, 0xc6, 0xc1, 0xe1, 0xa2, 0x51, 0x6d, - 0x11, 0x0, 0x0, 0x46, 0xaf, 0x26, 0x0, 0x9, 0x7e, 0x71, 0x8f, 0x7a, 0xf, 0xf8, 0x6b, 0x14, 0x95, - 0x0, 0x15, 0x48, 0xed, 0xf7, 0x71, 0x5d, 0x31, 0x72, 0xc, 0xa0, 0x8e, 0x96, 0x95, 0x67, 0x36, 0xf6, - 0x14, 0xcb, 0xbe, 0x13, 0xb0, 0xd1, 0xb, 0xf, 0x19, 0x4a, 0x11, 0x0, 0x0, 0x15, 0xe7, 0x25, 0xc3, - 0x2a, 0xd9, 0x3, 0x0, 0x5, 0x92, 0xcc, 0xf3, 0xdb, 0xb1, 0x2, 0x0, 0x0, 0x31, 0xeb, 0x1f, 0x0, - 0xe, 0x66, 0xb5, 0x9, 0xbe, 0x89, 0x98, 0x80, 0xac, 0xe2, 0x6c, 0x84, 0xd7, 0xfc, 0x71, 0x13, 0x26, - 0x94, 0x2a, 0xaa, 0x25, 0x8c, 0x2a, 0x4f, 0x88, 0xb1, 0xd6, 0xd9, 0x38, 0x3b, 0xfd, 0x2, 0x93, 0xce, - 0x97, 0xa1, 0xb7, 0x3f, 0xd, 0x1a, 0x97, 0xe6, 0x63, 0x10, 0x35, 0x68, 0xf9, 0xb1, 0xec}; - - uint8_t buf[246] = {0}; - - uint8_t topic_bytes[] = {0x49, 0xa8, 0x50, 0x48, 0xd5, 0xf5, 0x5d, 0x3c, 0xcb, 0x8e, 0xff, 0x93, 0x22, 0xfb}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x88, 0xb1, 0xd6, 0xd9, 0x38, 0x3b, 0xfd, 0x2, 0x93, 0xce, 0x97, 0xa1, 0xb7, - 0x3f, 0xd, 0x1a, 0x97, 0xe6, 0x63, 0x10, 0x35, 0x68, 0xf9, 0xb1, 0xec}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; - - uint8_t bytesprops0[] = {0xc, 0x41, 0x96, 0xa6, 0xb7, 0xaa, 0x16}; - uint8_t bytesprops1[] = {0xfe, 0xf8, 0x5b, 0xfb, 0x5a, 0x6, 0xab, 0x88, 0x40, 0x7a, 0x5d, - 0xfa, 0xf0, 0x95, 0xa1, 0x1d, 0xb0, 0x1a, 0x6a, 0x4d, 0xb0, 0xb7}; - uint8_t bytesprops2[] = {0xde, 0xc, 0xff, 0xef, 0xd1, 0x9f, 0xab, 0x3d, 0x76, 0x24, 0xae, 0x9, 0x5f, - 0x72, 0xbe, 0x6, 0x96, 0x75, 0x8b, 0xc6, 0xc1, 0xe1, 0xa2, 0x51, 0x6d}; - uint8_t bytesprops4[] = {0x48, 0xed, 0xf7, 0x71, 0x5d, 0x31, 0x72, 0xc, 0xa0, 0x8e, 0x96, - 0x95, 0x67, 0x36, 0xf6, 0x14, 0xcb, 0xbe, 0x13, 0xb0, 0xd1}; - uint8_t bytesprops3[] = {0x7e, 0x71, 0x8f, 0x7a, 0xf, 0xf8, 0x6b, 0x14, 0x95}; - uint8_t bytesprops5[] = {0x92, 0xcc, 0xf3, 0xdb, 0xb1}; - uint8_t bytesprops6[] = {0x66, 0xb5, 0x9, 0xbe, 0x89, 0x98, 0x80, 0xac, 0xe2, 0x6c, 0x84, 0xd7, 0xfc, 0x71}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12446}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17105}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25409}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2545}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27889}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18095}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops3}, .v = {21, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5607}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12779}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9876}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 23705, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "(cp\130q\251\181\SUB\133\251\228jBh\139\191\SOH\192\213\219Q1", _pubPktID = 14770, _pubBody = -// "\155j|4h\141\198\RS\162\240\168]\208C", _pubProps = [PropServerReference -// "\249\133\222O\138\161\&1\255\f\205\134\250\254\191"]} -TEST(Publish5QCTest, Encode79) { - uint8_t pkt[] = {0x3a, 0x3a, 0x0, 0x16, 0x28, 0x63, 0x70, 0x82, 0x71, 0xfb, 0xb5, 0x1a, 0x85, 0xfb, 0xe4, - 0x6a, 0x42, 0x68, 0x8b, 0xbf, 0x1, 0xc0, 0xd5, 0xdb, 0x51, 0x31, 0x39, 0xb2, 0x11, 0x1c, - 0x0, 0xe, 0xf9, 0x85, 0xde, 0x4f, 0x8a, 0xa1, 0x31, 0xff, 0xc, 0xcd, 0x86, 0xfa, 0xfe, - 0xbf, 0x9b, 0x6a, 0x7c, 0x34, 0x68, 0x8d, 0xc6, 0x1e, 0xa2, 0xf0, 0xa8, 0x5d, 0xd0, 0x43}; - - uint8_t buf[70] = {0}; - - uint8_t topic_bytes[] = {0x28, 0x63, 0x70, 0x82, 0x71, 0xfb, 0xb5, 0x1a, 0x85, 0xfb, 0xe4, - 0x6a, 0x42, 0x68, 0x8b, 0xbf, 0x1, 0xc0, 0xd5, 0xdb, 0x51, 0x31}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x9b, 0x6a, 0x7c, 0x34, 0x68, 0x8d, 0xc6, 0x1e, 0xa2, 0xf0, 0xa8, 0x5d, 0xd0, 0x43}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; - - uint8_t bytesprops0[] = {0xf9, 0x85, 0xde, 0x4f, 0x8a, 0xa1, 0x31, 0xff, 0xc, 0xcd, 0x86, 0xfa, 0xfe, 0xbf}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops0}}}, - }; - - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 14770, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "4\USH\SYN\210z\160\141\155\238\230\171\a\233\243\192t", _pubPktID = 24524, _pubBody = -// "%\173_\207\173p\210\131\129\ESC\231\SOH\143\255\163\&4\182?LS", _pubProps = [PropCorrelationData -// "\172\&8\220\180\205\ETX\181\228\&0\DEL:_\135\211\163K\191\174\252\142\139\ENQ\185\192\181y\ETXo!",PropSubscriptionIdentifier -// 5,PropAssignedClientIdentifier -// "vc\194\156h\DC4\131]\SOH+\128uX\133S\251V\220\170\132\141:\RS\DC1~{P\SOH\142",PropWillDelayInterval -// 22759,PropRetainAvailable 19,PropWillDelayInterval 9648,PropAuthenticationData -// "\158\US\170\131\158\238\172",PropAuthenticationMethod "\228B\221\t\"\222Wk\186\189\&20",PropMessageExpiryInterval -// 21169,PropMessageExpiryInterval 20864,PropResponseInformation -// "\223\206$\bO?}\142\&7\251\167\n\234\FS\140\138\SOH^\NAKO",PropMessageExpiryInterval -// 25217,PropRequestProblemInformation 19,PropTopicAlias 22170,PropRequestResponseInformation 205,PropMaximumQoS -// 211,PropAuthenticationData "\232\217x\ETX\DLE\230B~",PropServerKeepAlive 4487,PropSessionExpiryInterval -// 17004,PropAssignedClientIdentifier ""]} -TEST(Publish5QCTest, Encode80) { - uint8_t pkt[] = {0x3a, 0xd7, 0x1, 0x0, 0x11, 0x34, 0x1f, 0x48, 0x16, 0xd2, 0x7a, 0xa0, 0x8d, 0x9b, 0xee, 0xe6, 0xab, - 0x7, 0xe9, 0xf3, 0xc0, 0x74, 0x5f, 0xcc, 0xac, 0x1, 0x9, 0x0, 0x1d, 0xac, 0x38, 0xdc, 0xb4, 0xcd, - 0x3, 0xb5, 0xe4, 0x30, 0x7f, 0x3a, 0x5f, 0x87, 0xd3, 0xa3, 0x4b, 0xbf, 0xae, 0xfc, 0x8e, 0x8b, 0x5, - 0xb9, 0xc0, 0xb5, 0x79, 0x3, 0x6f, 0x21, 0xb, 0x5, 0x12, 0x0, 0x1d, 0x76, 0x63, 0xc2, 0x9c, 0x68, - 0x14, 0x83, 0x5d, 0x1, 0x2b, 0x80, 0x75, 0x58, 0x85, 0x53, 0xfb, 0x56, 0xdc, 0xaa, 0x84, 0x8d, 0x3a, - 0x1e, 0x11, 0x7e, 0x7b, 0x50, 0x1, 0x8e, 0x18, 0x0, 0x0, 0x58, 0xe7, 0x25, 0x13, 0x18, 0x0, 0x0, - 0x25, 0xb0, 0x16, 0x0, 0x7, 0x9e, 0x1f, 0xaa, 0x83, 0x9e, 0xee, 0xac, 0x15, 0x0, 0xc, 0xe4, 0x42, - 0xdd, 0x9, 0x22, 0xde, 0x57, 0x6b, 0xba, 0xbd, 0x32, 0x30, 0x2, 0x0, 0x0, 0x52, 0xb1, 0x2, 0x0, - 0x0, 0x51, 0x80, 0x1a, 0x0, 0x14, 0xdf, 0xce, 0x24, 0x8, 0x4f, 0x3f, 0x7d, 0x8e, 0x37, 0xfb, 0xa7, - 0xa, 0xea, 0x1c, 0x8c, 0x8a, 0x1, 0x5e, 0x15, 0x4f, 0x2, 0x0, 0x0, 0x62, 0x81, 0x17, 0x13, 0x23, - 0x56, 0x9a, 0x19, 0xcd, 0x24, 0xd3, 0x16, 0x0, 0x8, 0xe8, 0xd9, 0x78, 0x3, 0x10, 0xe6, 0x42, 0x7e, - 0x13, 0x11, 0x87, 0x11, 0x0, 0x0, 0x42, 0x6c, 0x12, 0x0, 0x0, 0x25, 0xad, 0x5f, 0xcf, 0xad, 0x70, - 0xd2, 0x83, 0x81, 0x1b, 0xe7, 0x1, 0x8f, 0xff, 0xa3, 0x34, 0xb6, 0x3f, 0x4c, 0x53}; - - uint8_t buf[228] = {0}; - - uint8_t topic_bytes[] = {0x34, 0x1f, 0x48, 0x16, 0xd2, 0x7a, 0xa0, 0x8d, 0x9b, - 0xee, 0xe6, 0xab, 0x7, 0xe9, 0xf3, 0xc0, 0x74}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x25, 0xad, 0x5f, 0xcf, 0xad, 0x70, 0xd2, 0x83, 0x81, 0x1b, - 0xe7, 0x1, 0x8f, 0xff, 0xa3, 0x34, 0xb6, 0x3f, 0x4c, 0x53}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; - - uint8_t bytesprops0[] = {0xac, 0x38, 0xdc, 0xb4, 0xcd, 0x3, 0xb5, 0xe4, 0x30, 0x7f, 0x3a, 0x5f, 0x87, 0xd3, 0xa3, - 0x4b, 0xbf, 0xae, 0xfc, 0x8e, 0x8b, 0x5, 0xb9, 0xc0, 0xb5, 0x79, 0x3, 0x6f, 0x21}; - uint8_t bytesprops1[] = {0x76, 0x63, 0xc2, 0x9c, 0x68, 0x14, 0x83, 0x5d, 0x1, 0x2b, 0x80, 0x75, 0x58, 0x85, 0x53, - 0xfb, 0x56, 0xdc, 0xaa, 0x84, 0x8d, 0x3a, 0x1e, 0x11, 0x7e, 0x7b, 0x50, 0x1, 0x8e}; - uint8_t bytesprops2[] = {0x9e, 0x1f, 0xaa, 0x83, 0x9e, 0xee, 0xac}; - uint8_t bytesprops3[] = {0xe4, 0x42, 0xdd, 0x9, 0x22, 0xde, 0x57, 0x6b, 0xba, 0xbd, 0x32, 0x30}; - uint8_t bytesprops4[] = {0xdf, 0xce, 0x24, 0x8, 0x4f, 0x3f, 0x7d, 0x8e, 0x37, 0xfb, - 0xa7, 0xa, 0xea, 0x1c, 0x8c, 0x8a, 0x1, 0x5e, 0x15, 0x4f}; - uint8_t bytesprops5[] = {0xe8, 0xd9, 0x78, 0x3, 0x10, 0xe6, 0x42, 0x7e}; - uint8_t bytesprops6[] = {0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22759}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9648}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21169}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20864}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25217}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22170}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4487}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17004}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops6}}}, - }; - - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 24524, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\214u\192\231\177\&7\SYN\253\141i\217\&0\158", _pubPktID = 0, _pubBody = -// "\169\SI\241H\190p\151Qw\209\217/\163\156\&5", _pubProps = [PropSubscriptionIdentifier -// 21,PropWildcardSubscriptionAvailable 137,PropCorrelationData "PZXh\248\181\246\177j-\EM",PropAuthenticationMethod -// "\185\170\217",PropRequestResponseInformation 181,PropTopicAliasMaximum 16439,PropAuthenticationMethod -// "+\208\209X\155[b\255\157<,N",PropMaximumPacketSize 2703,PropTopicAliasMaximum 12373,PropUserProperty -// "\175,\192kC\221\220\&6\251co.\177\154\166\132\225k\248=n\150\229S\241\183\198\a" -// "\NAKC\232\185\187\244\DC43t\232\210Z\236\240\ESC\199",PropSharedSubscriptionAvailable 84,PropAuthenticationData -// "\157H(\211,\248\171\202\207\NUL\187\242\SI",PropAssignedClientIdentifier "\GS\221\156",PropMessageExpiryInterval -// 20204,PropContentType "`\138\aF\r\\\184I:c\144M\221x4\226\161J\139\&4\DC4\157",PropRequestProblemInformation -// 35,PropReasonString "/t\233\ENQ\198Z \197\200\218h\197\146\147M\DC1\220|dN\195\SYNG",PropTopicAliasMaximum -// 32647,PropResponseInformation -// "\151\\;Jx\150\255\225\252\132\145\187n\206\&7\STXl\172\196[\204\180",PropSubscriptionIdentifier -// 21,PropCorrelationData "51\167\168 \218"]} -TEST(Publish5QCTest, Encode81) { - uint8_t pkt[] = { - 0x39, 0xfe, 0x1, 0x0, 0xd, 0xd6, 0x75, 0xc0, 0xe7, 0xb1, 0x37, 0x16, 0xfd, 0x8d, 0x69, 0xd9, 0x30, 0x9e, 0xde, - 0x1, 0xb, 0x15, 0x28, 0x89, 0x9, 0x0, 0xb, 0x50, 0x5a, 0x58, 0x68, 0xf8, 0xb5, 0xf6, 0xb1, 0x6a, 0x2d, 0x19, - 0x15, 0x0, 0x3, 0xb9, 0xaa, 0xd9, 0x19, 0xb5, 0x22, 0x40, 0x37, 0x15, 0x0, 0xc, 0x2b, 0xd0, 0xd1, 0x58, 0x9b, - 0x5b, 0x62, 0xff, 0x9d, 0x3c, 0x2c, 0x4e, 0x27, 0x0, 0x0, 0xa, 0x8f, 0x22, 0x30, 0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, 0x35}; - - uint8_t buf[267] = {0}; - - uint8_t topic_bytes[] = {0xd6, 0x75, 0xc0, 0xe7, 0xb1, 0x37, 0x16, 0xfd, 0x8d, 0x69, 0xd9, 0x30, 0x9e}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xa9, 0xf, 0xf1, 0x48, 0xbe, 0x70, 0x97, 0x51, 0x77, 0xd1, 0xd9, 0x2f, 0xa3, 0x9c, 0x35}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0x50, 0x5a, 0x58, 0x68, 0xf8, 0xb5, 0xf6, 0xb1, 0x6a, 0x2d, 0x19}; - uint8_t bytesprops1[] = {0xb9, 0xaa, 0xd9}; - uint8_t bytesprops2[] = {0x2b, 0xd0, 0xd1, 0x58, 0x9b, 0x5b, 0x62, 0xff, 0x9d, 0x3c, 0x2c, 0x4e}; - uint8_t bytesprops4[] = {0x15, 0x43, 0xe8, 0xb9, 0xbb, 0xf4, 0x14, 0x33, - 0x74, 0xe8, 0xd2, 0x5a, 0xec, 0xf0, 0x1b, 0xc7}; - uint8_t bytesprops3[] = {0xaf, 0x2c, 0xc0, 0x6b, 0x43, 0xdd, 0xdc, 0x36, 0xfb, 0x63, 0x6f, 0x2e, 0xb1, 0x9a, - 0xa6, 0x84, 0xe1, 0x6b, 0xf8, 0x3d, 0x6e, 0x96, 0xe5, 0x53, 0xf1, 0xb7, 0xc6, 0x7}; - uint8_t bytesprops5[] = {0x9d, 0x48, 0x28, 0xd3, 0x2c, 0xf8, 0xab, 0xca, 0xcf, 0x0, 0xbb, 0xf2, 0xf}; - uint8_t bytesprops6[] = {0x1d, 0xdd, 0x9c}; - uint8_t bytesprops7[] = {0x60, 0x8a, 0x7, 0x46, 0xd, 0x5c, 0xb8, 0x49, 0x3a, 0x63, 0x90, - 0x4d, 0xdd, 0x78, 0x34, 0xe2, 0xa1, 0x4a, 0x8b, 0x34, 0x14, 0x9d}; - uint8_t bytesprops8[] = {0x2f, 0x74, 0xe9, 0x5, 0xc6, 0x5a, 0x20, 0xc5, 0xc8, 0xda, 0x68, 0xc5, - 0x92, 0x93, 0x4d, 0x11, 0xdc, 0x7c, 0x64, 0x4e, 0xc3, 0x16, 0x47}; - uint8_t bytesprops9[] = {0x97, 0x5c, 0x3b, 0x4a, 0x78, 0x96, 0xff, 0xe1, 0xfc, 0x84, 0x91, - 0xbb, 0x6e, 0xce, 0x37, 0x2, 0x6c, 0xac, 0xc4, 0x5b, 0xcc, 0xb4}; - uint8_t bytesprops10[] = {0x35, 0x31, 0xa7, 0xa8, 0x20, 0xda}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16439}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2703}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12373}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops3}, .v = {16, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20204}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32647}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops10}}}, - }; - - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NUL%\184|4\245A", _pubPktID = 9669, -// _pubBody = "\170\148\223\170\SOH\189\188m;\173\149\203\NUL_B\STX\209\128\FSH\211\202R*$\DC4\t\241J", _pubProps = -// [PropAuthenticationMethod "\133\130\171\253DL)v@\199j\228\134\212\250\224\134\EMe)\DC3\242\DC1\231",PropMaximumQoS -// 121,PropMaximumPacketSize 26562,PropRequestProblemInformation 233,PropTopicAliasMaximum -// 21040,PropSubscriptionIdentifierAvailable 223,PropMessageExpiryInterval 4754,PropSubscriptionIdentifier -// 30,PropReasonString "2<\152\236\226\DC1\220.\NAKkZW\US\t\169",PropSharedSubscriptionAvailable -// 24,PropAuthenticationData "\217A3&_FD\140x\150m}z_\253\SUB\151'\EOT\249c\252]\129",PropRequestProblemInformation -// 168,PropPayloadFormatIndicator 156,PropMaximumQoS 149,PropPayloadFormatIndicator 71,PropSharedSubscriptionAvailable -// 243,PropResponseInformation "\r\150&\179E\ENQ,",PropMaximumQoS 6,PropServerKeepAlive 12988,PropMessageExpiryInterval -// 450,PropMaximumPacketSize 13232,PropSharedSubscriptionAvailable 1]} -TEST(Publish5QCTest, Encode82) { - uint8_t pkt[] = {0x3a, 0xae, 0x1, 0x0, 0x7, 0x0, 0x25, 0xb8, 0x7c, 0x34, 0xf5, 0x41, 0x25, 0xc5, 0x84, 0x1, 0x15, - 0x0, 0x18, 0x85, 0x82, 0xab, 0xfd, 0x44, 0x4c, 0x29, 0x76, 0x40, 0xc7, 0x6a, 0xe4, 0x86, 0xd4, 0xfa, - 0xe0, 0x86, 0x19, 0x65, 0x29, 0x13, 0xf2, 0x11, 0xe7, 0x24, 0x79, 0x27, 0x0, 0x0, 0x67, 0xc2, 0x17, - 0xe9, 0x22, 0x52, 0x30, 0x29, 0xdf, 0x2, 0x0, 0x0, 0x12, 0x92, 0xb, 0x1e, 0x1f, 0x0, 0xf, 0x32, - 0x3c, 0x98, 0xec, 0xe2, 0x11, 0xdc, 0x2e, 0x15, 0x6b, 0x5a, 0x57, 0x1f, 0x9, 0xa9, 0x2a, 0x18, 0x16, - 0x0, 0x18, 0xd9, 0x41, 0x33, 0x26, 0x5f, 0x46, 0x44, 0x8c, 0x78, 0x96, 0x6d, 0x7d, 0x7a, 0x5f, 0xfd, - 0x1a, 0x97, 0x27, 0x4, 0xf9, 0x63, 0xfc, 0x5d, 0x81, 0x17, 0xa8, 0x1, 0x9c, 0x24, 0x95, 0x1, 0x47, - 0x2a, 0xf3, 0x1a, 0x0, 0x7, 0xd, 0x96, 0x26, 0xb3, 0x45, 0x5, 0x2c, 0x24, 0x6, 0x13, 0x32, 0xbc, - 0x2, 0x0, 0x0, 0x1, 0xc2, 0x27, 0x0, 0x0, 0x33, 0xb0, 0x2a, 0x1, 0xaa, 0x94, 0xdf, 0xaa, 0x1, - 0xbd, 0xbc, 0x6d, 0x3b, 0xad, 0x95, 0xcb, 0x0, 0x5f, 0x42, 0x2, 0xd1, 0x80, 0x1c, 0x48, 0xd3, 0xca, - 0x52, 0x2a, 0x24, 0x14, 0x9, 0xf1, 0x4a}; - - uint8_t buf[187] = {0}; - - uint8_t topic_bytes[] = {0x0, 0x25, 0xb8, 0x7c, 0x34, 0xf5, 0x41}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xaa, 0x94, 0xdf, 0xaa, 0x1, 0xbd, 0xbc, 0x6d, 0x3b, 0xad, 0x95, 0xcb, 0x0, 0x5f, 0x42, - 0x2, 0xd1, 0x80, 0x1c, 0x48, 0xd3, 0xca, 0x52, 0x2a, 0x24, 0x14, 0x9, 0xf1, 0x4a}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; - - uint8_t bytesprops0[] = {0x85, 0x82, 0xab, 0xfd, 0x44, 0x4c, 0x29, 0x76, 0x40, 0xc7, 0x6a, 0xe4, - 0x86, 0xd4, 0xfa, 0xe0, 0x86, 0x19, 0x65, 0x29, 0x13, 0xf2, 0x11, 0xe7}; - uint8_t bytesprops1[] = {0x32, 0x3c, 0x98, 0xec, 0xe2, 0x11, 0xdc, 0x2e, 0x15, 0x6b, 0x5a, 0x57, 0x1f, 0x9, 0xa9}; - uint8_t bytesprops2[] = {0xd9, 0x41, 0x33, 0x26, 0x5f, 0x46, 0x44, 0x8c, 0x78, 0x96, 0x6d, 0x7d, - 0x7a, 0x5f, 0xfd, 0x1a, 0x97, 0x27, 0x4, 0xf9, 0x63, 0xfc, 0x5d, 0x81}; - uint8_t bytesprops3[] = {0xd, 0x96, 0x26, 0xb3, 0x45, 0x5, 0x2c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26562}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21040}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4754}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12988}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 450}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13232}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 1}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 9669, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = " -// o\209~\209\242\176\161LlEV\DC1\133\143\237'Y6\212\133H\a\241\&0a", _pubPktID = 1466, _pubBody = -// "0\192\223\GS\205\153\241>N\167\&8l\DC4\151x\170\229\FS\DC3s\128\135\222", _pubProps = [PropResponseInformation -// "d\230\222_\235\DC3\t\249\239\214^z\190\212\146;\183Y_\251",PropAuthenticationMethod -// "/\161\143;\FSB\160E\NAK9er\154\151HQ\254\169R",PropAuthenticationMethod "\248\SOH\169 -// %\148\181\248[<\128\247k",PropResponseInformation -// "\196qU2Lz\146\223yZ\ENQ\253\&2\DC2h\136\155c;\201\DEL",PropSharedSubscriptionAvailable 231,PropMaximumQoS -// 182,PropUserProperty "T\166\248\237\150\n\218\ENQ\NAK%\242\187\217\166&/}\163\DEL\243\DEL\253\152\148\159" -// "\213A",PropReasonString "y\170\226\DC42$n!\237F\136\FS9\180\158\&4zG\130|\GS!\132",PropServerKeepAlive -// 19917,PropRequestProblemInformation 106,PropSharedSubscriptionAvailable 200,PropRequestResponseInformation -// 126,PropRequestProblemInformation 139,PropWildcardSubscriptionAvailable 178,PropSessionExpiryInterval -// 21423,PropRequestProblemInformation 122,PropRetainAvailable 170,PropContentType -// "\235\191^1\239\207{\139f\195",PropReceiveMaximum 2421,PropPayloadFormatIndicator 171,PropAuthenticationMethod -// "n\USj\187\ACK\142\213\NAK\220",PropRetainAvailable 210,PropAuthenticationMethod -// "K\173\189o3'\DC1\EM\197\181\144\152.\157",PropAuthenticationMethod "\242/\152\208",PropAuthenticationData -// "\DC4\141bJ\171o\SUBlv\220\DC3\233\203\ETX4\NUL\241\195S\182\145\n\240"]} -TEST(Publish5QCTest, Encode83) { - uint8_t pkt[] = { - 0x33, 0xb2, 0x2, 0x0, 0x1a, 0x20, 0x6f, 0xd1, 0x7e, 0xd1, 0xf2, 0xb0, 0xa1, 0x4c, 0x6c, 0x45, 0x56, 0x11, 0x85, - 0x8f, 0xed, 0x27, 0x59, 0x36, 0xd4, 0x85, 0x48, 0x7, 0xf1, 0x30, 0x61, 0x5, 0xba, 0xfb, 0x1, 0x1a, 0x0, 0x14, - 0x64, 0xe6, 0xde, 0x5f, 0xeb, 0x13, 0x9, 0xf9, 0xef, 0xd6, 0x5e, 0x7a, 0xbe, 0xd4, 0x92, 0x3b, 0xb7, 0x59, 0x5f, - 0xfb, 0x15, 0x0, 0x13, 0x2f, 0xa1, 0x8f, 0x3b, 0x1c, 0x42, 0xa0, 0x45,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0x4, 0xf2, 0x2f, 0x98, 0xd0, 0x16, 0x0, 0x17, 0x14, 0x8d, 0x62, - 0x4a, 0xab, 0x6f, 0x1a, 0x6c, 0x76, 0xdc, 0x13, 0xe9, 0xcb, 0x3, 0x34, 0x0, 0xf1, 0xc3, 0x53, 0xb6, 0x91, 0xa, - 0xf0, 0x30, 0xc0, 0xdf, 0x1d, 0xcd, 0x99, 0xf1, 0x3e, 0x4e, 0xa7, 0x38, 0x6c, 0x14, 0x97, 0x78, 0xaa, 0xe5, 0x1c, - 0x13, 0x73, 0x80, 0x87, 0xde}; - - uint8_t buf[319] = {0}; - - uint8_t topic_bytes[] = {0x20, 0x6f, 0xd1, 0x7e, 0xd1, 0xf2, 0xb0, 0xa1, 0x4c, 0x6c, 0x45, 0x56, 0x11, - 0x85, 0x8f, 0xed, 0x27, 0x59, 0x36, 0xd4, 0x85, 0x48, 0x7, 0xf1, 0x30, 0x61}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x30, 0xc0, 0xdf, 0x1d, 0xcd, 0x99, 0xf1, 0x3e, 0x4e, 0xa7, 0x38, 0x6c, - 0x14, 0x97, 0x78, 0xaa, 0xe5, 0x1c, 0x13, 0x73, 0x80, 0x87, 0xde}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; - - uint8_t bytesprops0[] = {0x64, 0xe6, 0xde, 0x5f, 0xeb, 0x13, 0x9, 0xf9, 0xef, 0xd6, - 0x5e, 0x7a, 0xbe, 0xd4, 0x92, 0x3b, 0xb7, 0x59, 0x5f, 0xfb}; - uint8_t bytesprops1[] = {0x2f, 0xa1, 0x8f, 0x3b, 0x1c, 0x42, 0xa0, 0x45, 0x15, 0x39, - 0x65, 0x72, 0x9a, 0x97, 0x48, 0x51, 0xfe, 0xa9, 0x52}; - uint8_t bytesprops2[] = {0xf8, 0x1, 0xa9, 0x20, 0x25, 0x94, 0xb5, 0xf8, 0x5b, 0x3c, 0x80, 0xf7, 0x6b}; - uint8_t bytesprops3[] = {0xc4, 0x71, 0x55, 0x32, 0x4c, 0x7a, 0x92, 0xdf, 0x79, 0x5a, 0x5, - 0xfd, 0x32, 0x12, 0x68, 0x88, 0x9b, 0x63, 0x3b, 0xc9, 0x7f}; - uint8_t bytesprops5[] = {0xd5, 0x41}; - uint8_t bytesprops4[] = {0x54, 0xa6, 0xf8, 0xed, 0x96, 0xa, 0xda, 0x5, 0x15, 0x25, 0xf2, 0xbb, 0xd9, - 0xa6, 0x26, 0x2f, 0x7d, 0xa3, 0x7f, 0xf3, 0x7f, 0xfd, 0x98, 0x94, 0x9f}; - uint8_t bytesprops6[] = {0x79, 0xaa, 0xe2, 0x14, 0x32, 0x24, 0x6e, 0x21, 0xed, 0x46, 0x88, 0x1c, - 0x39, 0xb4, 0x9e, 0x34, 0x7a, 0x47, 0x82, 0x7c, 0x1d, 0x21, 0x84}; - uint8_t bytesprops7[] = {0xeb, 0xbf, 0x5e, 0x31, 0xef, 0xcf, 0x7b, 0x8b, 0x66, 0xc3}; - uint8_t bytesprops8[] = {0x6e, 0x1f, 0x6a, 0xbb, 0x6, 0x8e, 0xd5, 0x15, 0xdc}; - uint8_t bytesprops9[] = {0x4b, 0xad, 0xbd, 0x6f, 0x33, 0x27, 0x11, 0x19, 0xc5, 0xb5, 0x90, 0x98, 0x2e, 0x9d}; - uint8_t bytesprops10[] = {0xf2, 0x2f, 0x98, 0xd0}; - uint8_t bytesprops11[] = {0x14, 0x8d, 0x62, 0x4a, 0xab, 0x6f, 0x1a, 0x6c, 0x76, 0xdc, 0x13, 0xe9, - 0xcb, 0x3, 0x34, 0x0, 0xf1, 0xc3, 0x53, 0xb6, 0x91, 0xa, 0xf0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19917}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21423}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2421}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops11}}}, - }; - - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1466, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\201%\197.\f\247\DC3\198kM\237D\184\RS\ENQ<\183\215\RS\217\200", _pubPktID = 0, _pubBody = ">@1E\209$\188\249zd", -// _pubProps = [PropServerReference "\ETX-_",PropMessageExpiryInterval 25845,PropMaximumQoS -// 144,PropMessageExpiryInterval 5141,PropSessionExpiryInterval 28057,PropContentType -// "y\DC3b\131#\DC3\EOT\205\ETB-\226\223\247",PropContentType "}%\ETX\t",PropReasonString "D\ENQ",PropServerKeepAlive -// 23556,PropMessageExpiryInterval 5144,PropAssignedClientIdentifier -// "\191\136'\152\SO\194\SUB\175\214\149",PropAuthenticationMethod -// "\185G1\255!\218\NULt\212\230(\221,\214`5\252)@\217<\234\161\194\190\128#\135\227v",PropReceiveMaximum -// 20953,PropCorrelationData "\197I\b\242,\220\160\207b3\188\n\SIo\185",PropContentType -// "\SOH;K\129\173\&7^\218\205P\191HC\USK",PropRequestProblemInformation 89]} -TEST(Publish5QCTest, Encode84) { - uint8_t pkt[] = {0x30, 0xb5, 0x1, 0x0, 0x15, 0xc9, 0x25, 0xc5, 0x2e, 0xc, 0xf7, 0x13, 0xc6, 0x6b, 0x4d, 0xed, 0x44, - 0xb8, 0x1e, 0x5, 0x3c, 0xb7, 0xd7, 0x1e, 0xd9, 0xc8, 0x92, 0x1, 0x1c, 0x0, 0x3, 0x3, 0x2d, 0x5f, - 0x2, 0x0, 0x0, 0x64, 0xf5, 0x24, 0x90, 0x2, 0x0, 0x0, 0x14, 0x15, 0x11, 0x0, 0x0, 0x6d, 0x99, - 0x3, 0x0, 0xd, 0x79, 0x13, 0x62, 0x83, 0x23, 0x13, 0x4, 0xcd, 0x17, 0x2d, 0xe2, 0xdf, 0xf7, 0x3, - 0x0, 0x4, 0x7d, 0x25, 0x3, 0x9, 0x1f, 0x0, 0x2, 0x44, 0x5, 0x13, 0x5c, 0x4, 0x2, 0x0, 0x0, - 0x14, 0x18, 0x12, 0x0, 0xa, 0xbf, 0x88, 0x27, 0x98, 0xe, 0xc2, 0x1a, 0xaf, 0xd6, 0x95, 0x15, 0x0, - 0x1e, 0xb9, 0x47, 0x31, 0xff, 0x21, 0xda, 0x0, 0x74, 0xd4, 0xe6, 0x28, 0xdd, 0x2c, 0xd6, 0x60, 0x35, - 0xfc, 0x29, 0x40, 0xd9, 0x3c, 0xea, 0xa1, 0xc2, 0xbe, 0x80, 0x23, 0x87, 0xe3, 0x76, 0x21, 0x51, 0xd9, - 0x9, 0x0, 0xf, 0xc5, 0x49, 0x8, 0xf2, 0x2c, 0xdc, 0xa0, 0xcf, 0x62, 0x33, 0xbc, 0xa, 0xf, 0x6f, - 0xb9, 0x3, 0x0, 0xf, 0x1, 0x3b, 0x4b, 0x81, 0xad, 0x37, 0x5e, 0xda, 0xcd, 0x50, 0xbf, 0x48, 0x43, - 0x1f, 0x4b, 0x17, 0x59, 0x3e, 0x40, 0x31, 0x45, 0xd1, 0x24, 0xbc, 0xf9, 0x7a, 0x64}; - - uint8_t buf[194] = {0}; - - uint8_t topic_bytes[] = {0xc9, 0x25, 0xc5, 0x2e, 0xc, 0xf7, 0x13, 0xc6, 0x6b, 0x4d, 0xed, - 0x44, 0xb8, 0x1e, 0x5, 0x3c, 0xb7, 0xd7, 0x1e, 0xd9, 0xc8}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x3e, 0x40, 0x31, 0x45, 0xd1, 0x24, 0xbc, 0xf9, 0x7a, 0x64}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; - - uint8_t bytesprops0[] = {0x3, 0x2d, 0x5f}; - uint8_t bytesprops1[] = {0x79, 0x13, 0x62, 0x83, 0x23, 0x13, 0x4, 0xcd, 0x17, 0x2d, 0xe2, 0xdf, 0xf7}; - uint8_t bytesprops2[] = {0x7d, 0x25, 0x3, 0x9}; - uint8_t bytesprops3[] = {0x44, 0x5}; - uint8_t bytesprops4[] = {0xbf, 0x88, 0x27, 0x98, 0xe, 0xc2, 0x1a, 0xaf, 0xd6, 0x95}; - uint8_t bytesprops5[] = {0xb9, 0x47, 0x31, 0xff, 0x21, 0xda, 0x0, 0x74, 0xd4, 0xe6, 0x28, 0xdd, 0x2c, 0xd6, 0x60, - 0x35, 0xfc, 0x29, 0x40, 0xd9, 0x3c, 0xea, 0xa1, 0xc2, 0xbe, 0x80, 0x23, 0x87, 0xe3, 0x76}; - uint8_t bytesprops6[] = {0xc5, 0x49, 0x8, 0xf2, 0x2c, 0xdc, 0xa0, 0xcf, 0x62, 0x33, 0xbc, 0xa, 0xf, 0x6f, 0xb9}; - uint8_t bytesprops7[] = {0x1, 0x3b, 0x4b, 0x81, 0xad, 0x37, 0x5e, 0xda, 0xcd, 0x50, 0xbf, 0x48, 0x43, 0x1f, 0x4b}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25845}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5141}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28057}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23556}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5144}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20953}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 89}}, - }; - - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\ACK\180\\\144\214%\183\192\168\129", -// _pubPktID = 5193, _pubBody = "\SOH\135\136&\\\133\174\132\244\244\"", _pubProps = [PropContentType -// "o\175\134\150\199\168V!\a\193\243v\192\DC2\226l",PropReceiveMaximum 26703,PropMessageExpiryInterval -// 25645,PropMessageExpiryInterval 13097,PropServerKeepAlive 22523,PropWildcardSubscriptionAvailable 183,PropContentType -// "\241\&0\251P$\221\223\&8#",PropWillDelayInterval 13818,PropSessionExpiryInterval 9707,PropRetainAvailable -// 49,PropRequestProblemInformation 189,PropContentType -// "\209jJ\151`E\239\220m\184T4$f9\200\STX\CAN?#\196\201)\151\225\196",PropMessageExpiryInterval -// 26226,PropMessageExpiryInterval 28825,PropSubscriptionIdentifier 0,PropReceiveMaximum 23784,PropWillDelayInterval -// 23963,PropResponseTopic "\152UD\222\149Uk",PropWildcardSubscriptionAvailable 60,PropReceiveMaximum -// 19669,PropMaximumQoS 175,PropResponseInformation "'\229!\138\183\&1*\173",PropReceiveMaximum 13680,PropResponseTopic -// "\163\233\152\FSt\200\157\154H\246\SO"]} -TEST(Publish5QCTest, Encode85) { - uint8_t pkt[] = { - 0x3b, 0xb8, 0x1, 0x0, 0xa, 0x6, 0xb4, 0x5c, 0x90, 0xd6, 0x25, 0xb7, 0xc0, 0xa8, 0x81, 0x14, 0x49, 0x9d, 0x1, - 0x3, 0x0, 0x10, 0x6f, 0xaf, 0x86, 0x96, 0xc7, 0xa8, 0x56, 0x21, 0x7, 0xc1, 0xf3, 0x76, 0xc0, 0x12, 0xe2, 0x6c, - 0x21, 0x68, 0x4f, 0x2, 0x0, 0x0, 0x64, 0x2d, 0x2, 0x0, 0x0, 0x33, 0x29, 0x13, 0x57, 0xfb, 0x28, 0xb7, 0x3, - 0x0, 0x9, 0xf1, 0x30, 0xfb, 0x50, 0x24, 0xdd, 0xdf, 0x38, 0x23, 0x18, 0x0, 0x0, 0x35, 0xfa, 0x11, 0x0, 0x0, - 0x25, 0xeb, 0x25, 0x31, 0x17, 0xbd, 0x3, 0x0, 0x1a, 0xd1, 0x6a, 0x4a, 0x97, 0x60, 0x45, 0xef, 0xdc, 0x6d, 0xb8, - 0x54, 0x34, 0x24, 0x66, 0x39, 0xc8, 0x2, 0x18, 0x3f, 0x23, 0xc4, 0xc9, 0x29, 0x97, 0xe1, 0xc4, 0x2, 0x0, 0x0, - 0x66, 0x72, 0x2, 0x0, 0x0, 0x70, 0x99, 0xb, 0x0, 0x21, 0x5c, 0xe8, 0x18, 0x0, 0x0, 0x5d, 0x9b, 0x8, 0x0, - 0x7, 0x98, 0x55, 0x44, 0xde, 0x95, 0x55, 0x6b, 0x28, 0x3c, 0x21, 0x4c, 0xd5, 0x24, 0xaf, 0x1a, 0x0, 0x8, 0x27, - 0xe5, 0x21, 0x8a, 0xb7, 0x31, 0x2a, 0xad, 0x21, 0x35, 0x70, 0x8, 0x0, 0xb, 0xa3, 0xe9, 0x98, 0x1c, 0x74, 0xc8, - 0x9d, 0x9a, 0x48, 0xf6, 0xe, 0x1, 0x87, 0x88, 0x26, 0x5c, 0x85, 0xae, 0x84, 0xf4, 0xf4, 0x22}; - - uint8_t buf[197] = {0}; - - uint8_t topic_bytes[] = {0x6, 0xb4, 0x5c, 0x90, 0xd6, 0x25, 0xb7, 0xc0, 0xa8, 0x81}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x1, 0x87, 0x88, 0x26, 0x5c, 0x85, 0xae, 0x84, 0xf4, 0xf4, 0x22}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; - - uint8_t bytesprops0[] = {0x6f, 0xaf, 0x86, 0x96, 0xc7, 0xa8, 0x56, 0x21, - 0x7, 0xc1, 0xf3, 0x76, 0xc0, 0x12, 0xe2, 0x6c}; - uint8_t bytesprops1[] = {0xf1, 0x30, 0xfb, 0x50, 0x24, 0xdd, 0xdf, 0x38, 0x23}; - uint8_t bytesprops2[] = {0xd1, 0x6a, 0x4a, 0x97, 0x60, 0x45, 0xef, 0xdc, 0x6d, 0xb8, 0x54, 0x34, 0x24, - 0x66, 0x39, 0xc8, 0x2, 0x18, 0x3f, 0x23, 0xc4, 0xc9, 0x29, 0x97, 0xe1, 0xc4}; - uint8_t bytesprops3[] = {0x98, 0x55, 0x44, 0xde, 0x95, 0x55, 0x6b}; - uint8_t bytesprops4[] = {0x27, 0xe5, 0x21, 0x8a, 0xb7, 0x31, 0x2a, 0xad}; - uint8_t bytesprops5[] = {0xa3, 0xe9, 0x98, 0x1c, 0x74, 0xc8, 0x9d, 0x9a, 0x48, 0xf6, 0xe}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26703}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25645}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13097}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22523}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13818}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9707}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26226}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28825}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23784}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23963}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19669}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13680}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5193, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\235c\197\&9\FS\179\195b6\STX\195n\216\&3\213\vpu\137v\147o\200\233", _pubPktID = 40, _pubBody = -// "\150\169\128N}\US\133\146\160\ENQ\253N\247", _pubProps = [PropWildcardSubscriptionAvailable -// 17,PropAssignedClientIdentifier "a\176\US",PropTopicAlias 25003,PropServerReference -// "\198~d\245\202w\CAN\SO\157\149~s=\254",PropUserProperty "\SUB&\223\DC3i\242\249\&5\\\144" -// "\135\DC2;>H\187\234\ENQ`\162\160\168`\141\134\209\156\146D\229\133\255\219\243\196`\DC3\217",PropServerKeepAlive -// 9027,PropWillDelayInterval 14049,PropUserProperty -// "x|I\173\&9\165av\NAKz\168%\EOT\192\RS\244\243$\240\NAKn\190\220a\171\172\DEL\135" -// "\234\192:",PropMessageExpiryInterval 17923]} -TEST(Publish5QCTest, Encode86) { - uint8_t pkt[] = {0x35, 0xa2, 0x1, 0x0, 0x18, 0xeb, 0x63, 0xc5, 0x39, 0x1c, 0xb3, 0xc3, 0x62, 0x36, 0x2, 0xc3, 0x6e, - 0xd8, 0x33, 0xd5, 0xb, 0x70, 0x75, 0x89, 0x76, 0x93, 0x6f, 0xc8, 0xe9, 0x0, 0x28, 0x78, 0x28, 0x11, - 0x12, 0x0, 0x3, 0x61, 0xb0, 0x1f, 0x23, 0x61, 0xab, 0x1c, 0x0, 0xe, 0xc6, 0x7e, 0x64, 0xf5, 0xca, - 0x77, 0x18, 0xe, 0x9d, 0x95, 0x7e, 0x73, 0x3d, 0xfe, 0x26, 0x0, 0xa, 0x1a, 0x26, 0xdf, 0x13, 0x69, - 0xf2, 0xf9, 0x35, 0x5c, 0x90, 0x0, 0x1c, 0x87, 0x12, 0x3b, 0x3e, 0x48, 0xbb, 0xea, 0x5, 0x60, 0xa2, - 0xa0, 0xa8, 0x60, 0x8d, 0x86, 0xd1, 0x9c, 0x92, 0x44, 0xe5, 0x85, 0xff, 0xdb, 0xf3, 0xc4, 0x60, 0x13, - 0xd9, 0x13, 0x23, 0x43, 0x18, 0x0, 0x0, 0x36, 0xe1, 0x26, 0x0, 0x1c, 0x78, 0x7c, 0x49, 0xad, 0x39, - 0xa5, 0x61, 0x76, 0x15, 0x7a, 0xa8, 0x25, 0x4, 0xc0, 0x1e, 0xf4, 0xf3, 0x24, 0xf0, 0x15, 0x6e, 0xbe, - 0xdc, 0x61, 0xab, 0xac, 0x7f, 0x87, 0x0, 0x3, 0xea, 0xc0, 0x3a, 0x2, 0x0, 0x0, 0x46, 0x3, 0x96, - 0xa9, 0x80, 0x4e, 0x7d, 0x1f, 0x85, 0x92, 0xa0, 0x5, 0xfd, 0x4e, 0xf7}; - - uint8_t buf[175] = {0}; - - uint8_t topic_bytes[] = {0xeb, 0x63, 0xc5, 0x39, 0x1c, 0xb3, 0xc3, 0x62, 0x36, 0x2, 0xc3, 0x6e, - 0xd8, 0x33, 0xd5, 0xb, 0x70, 0x75, 0x89, 0x76, 0x93, 0x6f, 0xc8, 0xe9}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x96, 0xa9, 0x80, 0x4e, 0x7d, 0x1f, 0x85, 0x92, 0xa0, 0x5, 0xfd, 0x4e, 0xf7}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; - - uint8_t bytesprops0[] = {0x61, 0xb0, 0x1f}; - uint8_t bytesprops1[] = {0xc6, 0x7e, 0x64, 0xf5, 0xca, 0x77, 0x18, 0xe, 0x9d, 0x95, 0x7e, 0x73, 0x3d, 0xfe}; - uint8_t bytesprops3[] = {0x87, 0x12, 0x3b, 0x3e, 0x48, 0xbb, 0xea, 0x5, 0x60, 0xa2, 0xa0, 0xa8, 0x60, 0x8d, - 0x86, 0xd1, 0x9c, 0x92, 0x44, 0xe5, 0x85, 0xff, 0xdb, 0xf3, 0xc4, 0x60, 0x13, 0xd9}; - uint8_t bytesprops2[] = {0x1a, 0x26, 0xdf, 0x13, 0x69, 0xf2, 0xf9, 0x35, 0x5c, 0x90}; - uint8_t bytesprops5[] = {0xea, 0xc0, 0x3a}; - uint8_t bytesprops4[] = {0x78, 0x7c, 0x49, 0xad, 0x39, 0xa5, 0x61, 0x76, 0x15, 0x7a, 0xa8, 0x25, 0x4, 0xc0, - 0x1e, 0xf4, 0xf3, 0x24, 0xf0, 0x15, 0x6e, 0xbe, 0xdc, 0x61, 0xab, 0xac, 0x7f, 0x87}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25003}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {28, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9027}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14049}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops4}, .v = {3, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17923}}, - }; - - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 40, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\SIM;=\ETX\220\ETX\214o\159\228\157\195\144\184+\216gpE\208\DC3\228\211\238W\212\&2", _pubPktID = 0, _pubBody = -// "\ETX\175\STXN\144\216\212\205c\184|\142\&5i", _pubProps = [PropSubscriptionIdentifier 10,PropResponseTopic -// "O\193\137\GS_&gG\144\252#^Z\EM\200>\151j\136\253w\DC3x{\ETB(",PropMessageExpiryInterval 23659,PropMaximumQoS 14]} -TEST(Publish5QCTest, Encode87) { - uint8_t pkt[] = {0x31, 0x53, 0x0, 0x1c, 0xf, 0x4d, 0x3b, 0x3d, 0x3, 0xdc, 0x3, 0xd6, 0x6f, 0x9f, 0xe4, - 0x9d, 0xc3, 0x90, 0xb8, 0x2b, 0xd8, 0x67, 0x70, 0x45, 0xd0, 0x13, 0xe4, 0xd3, 0xee, 0x57, - 0xd4, 0x32, 0x26, 0xb, 0xa, 0x8, 0x0, 0x1a, 0x4f, 0xc1, 0x89, 0x1d, 0x5f, 0x26, 0x67, - 0x47, 0x90, 0xfc, 0x23, 0x5e, 0x5a, 0x19, 0xc8, 0x3e, 0x97, 0x6a, 0x88, 0xfd, 0x77, 0x13, - 0x78, 0x7b, 0x17, 0x28, 0x2, 0x0, 0x0, 0x5c, 0x6b, 0x24, 0xe, 0x3, 0xaf, 0x2, 0x4e, - 0x90, 0xd8, 0xd4, 0xcd, 0x63, 0xb8, 0x7c, 0x8e, 0x35, 0x69}; - - uint8_t buf[95] = {0}; - - uint8_t topic_bytes[] = {0xf, 0x4d, 0x3b, 0x3d, 0x3, 0xdc, 0x3, 0xd6, 0x6f, 0x9f, 0xe4, 0x9d, 0xc3, 0x90, - 0xb8, 0x2b, 0xd8, 0x67, 0x70, 0x45, 0xd0, 0x13, 0xe4, 0xd3, 0xee, 0x57, 0xd4, 0x32}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x3, 0xaf, 0x2, 0x4e, 0x90, 0xd8, 0xd4, 0xcd, 0x63, 0xb8, 0x7c, 0x8e, 0x35, 0x69}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; - - uint8_t bytesprops0[] = {0x4f, 0xc1, 0x89, 0x1d, 0x5f, 0x26, 0x67, 0x47, 0x90, 0xfc, 0x23, 0x5e, 0x5a, - 0x19, 0xc8, 0x3e, 0x97, 0x6a, 0x88, 0xfd, 0x77, 0x13, 0x78, 0x7b, 0x17, 0x28}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23659}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 14}}, - }; - - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "p\185X\177s\138d\DLE.", _pubPktID = -// 29654, _pubBody = "\195o\ndF\GS\152\131\191\195;\253\248+\187y\251\129 4\244\145", _pubProps = [PropServerKeepAlive -// 26757,PropCorrelationData "\208l\212\236\139+\158\156Y\SUBdY\148\193\198\137\210*\205\208S\208D\209",PropUserProperty -// "\FS\203\241o\n" "@B\187\ETB!\214\DLE_\189P\205",PropAuthenticationData -// "\187\US\232\141\aQ",PropMessageExpiryInterval 30502,PropMessageExpiryInterval 11882,PropContentType -// "7I:b\193\246s\173\214\&7\t\f_\v"]} -TEST(Publish5QCTest, Encode88) { - uint8_t pkt[] = {0x3c, 0xa0, 0x1, 0x0, 0x9, 0x70, 0xb9, 0x58, 0xb1, 0x73, 0x8a, 0x64, 0x10, 0x2e, 0x73, 0xd6, 0x7c, - 0x13, 0x68, 0x85, 0x9, 0x0, 0x18, 0xd0, 0x6c, 0xd4, 0xec, 0x8b, 0x2b, 0x9e, 0x9c, 0x59, 0x1a, 0x64, - 0x59, 0x94, 0xc1, 0xc6, 0x89, 0xd2, 0x2a, 0xcd, 0xd0, 0x53, 0xd0, 0x44, 0xd1, 0x26, 0x0, 0x5, 0x1c, - 0xcb, 0xf1, 0x6f, 0xa, 0x0, 0xe, 0x40, 0x42, 0xbb, 0x17, 0x21, 0xd6, 0x10, 0x3c, 0x21, 0x53, 0x5a, - 0x5b, 0xad, 0xcd, 0x1c, 0x0, 0x9, 0xd4, 0x61, 0x5a, 0x20, 0xa7, 0x46, 0xeb, 0xe4, 0xd3, 0x17, 0x62, - 0x2a, 0xac, 0x2, 0x0, 0x0, 0x2c, 0xfe, 0xb, 0x12, 0x12, 0x0, 0x8, 0xf5, 0xf4, 0xa3, 0x3e, 0x5f, - 0xbd, 0x50, 0xcd, 0x16, 0x0, 0x6, 0xbb, 0x1f, 0xe8, 0x8d, 0x7, 0x51, 0x2, 0x0, 0x0, 0x77, 0x26, - 0x2, 0x0, 0x0, 0x2e, 0x6a, 0x3, 0x0, 0xe, 0x37, 0x49, 0x3a, 0x62, 0xc1, 0xf6, 0x73, 0xad, 0xd6, - 0x37, 0x9, 0xc, 0x5f, 0xb, 0xc3, 0x6f, 0xa, 0x64, 0x46, 0x1d, 0x98, 0x83, 0xbf, 0xc3, 0x3b, 0xfd, - 0xf8, 0x2b, 0xbb, 0x79, 0xfb, 0x81, 0x20, 0x34, 0xf4, 0x91}; - - uint8_t buf[173] = {0}; - - uint8_t topic_bytes[] = {0x70, 0xb9, 0x58, 0xb1, 0x73, 0x8a, 0x64, 0x10, 0x2e}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xc3, 0x6f, 0xa, 0x64, 0x46, 0x1d, 0x98, 0x83, 0xbf, 0xc3, 0x3b, - 0xfd, 0xf8, 0x2b, 0xbb, 0x79, 0xfb, 0x81, 0x20, 0x34, 0xf4, 0x91}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; - - uint8_t bytesprops0[] = {0xd0, 0x6c, 0xd4, 0xec, 0x8b, 0x2b, 0x9e, 0x9c, 0x59, 0x1a, 0x64, 0x59, - 0x94, 0xc1, 0xc6, 0x89, 0xd2, 0x2a, 0xcd, 0xd0, 0x53, 0xd0, 0x44, 0xd1}; - uint8_t bytesprops2[] = {0x40, 0x42, 0xbb, 0x17, 0x21, 0xd6, 0x10, 0x3c, 0x21, 0x53, 0x5a, 0x5b, 0xad, 0xcd}; - uint8_t bytesprops1[] = {0x1c, 0xcb, 0xf1, 0x6f, 0xa}; - uint8_t bytesprops3[] = {0xd4, 0x61, 0x5a, 0x20, 0xa7, 0x46, 0xeb, 0xe4, 0xd3}; - uint8_t bytesprops4[] = {0xf5, 0xf4, 0xa3, 0x3e, 0x5f, 0xbd, 0x50, 0xcd}; - uint8_t bytesprops5[] = {0xbb, 0x1f, 0xe8, 0x8d, 0x7, 0x51}; - uint8_t bytesprops6[] = {0x37, 0x49, 0x3a, 0x62, 0xc1, 0xf6, 0x73, 0xad, 0xd6, 0x37, 0x9, 0xc, 0x5f, 0xb}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26757}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops1}, .v = {14, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11518}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30502}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11882}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops6}}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29654, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\238\SYN\GSq4\148\154&", _pubPktID -// = 4746, _pubBody = "", _pubProps = [PropPayloadFormatIndicator 218,PropReasonString "p\t\158\r\134",PropMaximumQoS -// 42,PropPayloadFormatIndicator 36,PropUserProperty "\196" "\n|\204\152\233\210\153\140",PropResponseTopic -// "\149\218V+OX[",PropServerKeepAlive 8879,PropTopicAlias 12682,PropTopicAlias 1639,PropAuthenticationMethod -// "\219\214\231\236u\217\140\215NsP\184\191\\\229\NAK\236\144\CAN4\225\239",PropMaximumQoS -// 252,PropMessageExpiryInterval 24151,PropServerKeepAlive 13405,PropPayloadFormatIndicator 119,PropMaximumQoS -// 37,PropAuthenticationData -// "So\173>T\"\221J\RS\230\185\128\252\172$\ACK\DC1\177\157\159n>\219\DC2",PropMessageExpiryInterval -// 19289,PropServerReference "J\DC2\204R\191\147\146\231\227\212\189H\238K\136\187\v/",PropTopicAliasMaximum -// 21397,PropAuthenticationMethod "\184c\168\130^\153\201\225\245lG",PropAuthenticationMethod -// "\231\206e\135\134S\250y\227",PropTopicAlias 2018,PropRequestResponseInformation 95,PropMaximumPacketSize -// 20599,PropSharedSubscriptionAvailable 167,PropTopicAliasMaximum 10330]} -TEST(Publish5QCTest, Encode89) { - uint8_t pkt[] = {0x32, 0xc5, 0x1, 0x0, 0x8, 0xee, 0x16, 0x1d, 0x71, 0x34, 0x94, 0x9a, 0x26, 0x12, 0x8a, 0xb7, 0x1, - 0x1, 0xda, 0x1f, 0x0, 0x5, 0x70, 0x9, 0x9e, 0xd, 0x86, 0x24, 0x2a, 0x1, 0x24, 0x26, 0x0, 0x1, - 0xc4, 0x0, 0x8, 0xa, 0x7c, 0xcc, 0x98, 0xe9, 0xd2, 0x99, 0x8c, 0x8, 0x0, 0x7, 0x95, 0xda, 0x56, - 0x2b, 0x4f, 0x58, 0x5b, 0x13, 0x22, 0xaf, 0x23, 0x31, 0x8a, 0x23, 0x6, 0x67, 0x15, 0x0, 0x16, 0xdb, - 0xd6, 0xe7, 0xec, 0x75, 0xd9, 0x8c, 0xd7, 0x4e, 0x73, 0x50, 0xb8, 0xbf, 0x5c, 0xe5, 0x15, 0xec, 0x90, - 0x18, 0x34, 0xe1, 0xef, 0x24, 0xfc, 0x2, 0x0, 0x0, 0x5e, 0x57, 0x13, 0x34, 0x5d, 0x1, 0x77, 0x24, - 0x25, 0x16, 0x0, 0x18, 0x53, 0x6f, 0xad, 0x3e, 0x54, 0x22, 0xdd, 0x4a, 0x1e, 0xe6, 0xb9, 0x80, 0xfc, - 0xac, 0x24, 0x6, 0x11, 0xb1, 0x9d, 0x9f, 0x6e, 0x3e, 0xdb, 0x12, 0x2, 0x0, 0x0, 0x4b, 0x59, 0x1c, - 0x0, 0x12, 0x4a, 0x12, 0xcc, 0x52, 0xbf, 0x93, 0x92, 0xe7, 0xe3, 0xd4, 0xbd, 0x48, 0xee, 0x4b, 0x88, - 0xbb, 0xb, 0x2f, 0x22, 0x53, 0x95, 0x15, 0x0, 0xb, 0xb8, 0x63, 0xa8, 0x82, 0x5e, 0x99, 0xc9, 0xe1, - 0xf5, 0x6c, 0x47, 0x15, 0x0, 0x9, 0xe7, 0xce, 0x65, 0x87, 0x86, 0x53, 0xfa, 0x79, 0xe3, 0x23, 0x7, - 0xe2, 0x19, 0x5f, 0x27, 0x0, 0x0, 0x50, 0x77, 0x2a, 0xa7, 0x22, 0x28, 0x5a}; - - uint8_t buf[210] = {0}; - - uint8_t topic_bytes[] = {0xee, 0x16, 0x1d, 0x71, 0x34, 0x94, 0x9a, 0x26}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; - - uint8_t bytesprops0[] = {0x70, 0x9, 0x9e, 0xd, 0x86}; - uint8_t bytesprops2[] = {0xa, 0x7c, 0xcc, 0x98, 0xe9, 0xd2, 0x99, 0x8c}; - uint8_t bytesprops1[] = {0xc4}; - uint8_t bytesprops3[] = {0x95, 0xda, 0x56, 0x2b, 0x4f, 0x58, 0x5b}; - uint8_t bytesprops4[] = {0xdb, 0xd6, 0xe7, 0xec, 0x75, 0xd9, 0x8c, 0xd7, 0x4e, 0x73, 0x50, - 0xb8, 0xbf, 0x5c, 0xe5, 0x15, 0xec, 0x90, 0x18, 0x34, 0xe1, 0xef}; - uint8_t bytesprops5[] = {0x53, 0x6f, 0xad, 0x3e, 0x54, 0x22, 0xdd, 0x4a, 0x1e, 0xe6, 0xb9, 0x80, - 0xfc, 0xac, 0x24, 0x6, 0x11, 0xb1, 0x9d, 0x9f, 0x6e, 0x3e, 0xdb, 0x12}; - uint8_t bytesprops6[] = {0x4a, 0x12, 0xcc, 0x52, 0xbf, 0x93, 0x92, 0xe7, 0xe3, - 0xd4, 0xbd, 0x48, 0xee, 0x4b, 0x88, 0xbb, 0xb, 0x2f}; - uint8_t bytesprops7[] = {0xb8, 0x63, 0xa8, 0x82, 0x5e, 0x99, 0xc9, 0xe1, 0xf5, 0x6c, 0x47}; - uint8_t bytesprops8[] = {0xe7, 0xce, 0x65, 0x87, 0x86, 0x53, 0xfa, 0x79, 0xe3}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8879}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12682}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1639}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24151}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13405}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19289}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21397}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2018}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20599}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10330}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 4746, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "(\217\244\EOT\224\136\232\225\248Q\237\240\138\187\152\v<\194\216B\158\SYN\158\203t\205", _pubPktID = 13686, -// _pubBody = "g\t?\199\SOHX\128\158_", _pubProps = [PropSharedSubscriptionAvailable 137,PropUserProperty -// "p\DC4\158\167\&1u\200\FS\145q\ETB\179\217m\178K\STXP\169\216N" "\182\253",PropServerKeepAlive -// 32094,PropSubscriptionIdentifierAvailable 163,PropServerKeepAlive 30000,PropSessionExpiryInterval -// 25741,PropWildcardSubscriptionAvailable 223,PropTopicAliasMaximum 22073,PropServerKeepAlive -// 20239,PropSharedSubscriptionAvailable 136,PropMaximumPacketSize 30256,PropWillDelayInterval -// 10219,PropSubscriptionIdentifier 2,PropAuthenticationMethod -// "\242\201Pp6=\b?L\232\206\a\DC47\168&\130\167\SUB\234\237\143"]} -TEST(Publish5QCTest, Encode90) { - uint8_t pkt[] = {0x32, 0x82, 0x1, 0x0, 0x1a, 0x28, 0xd9, 0xf4, 0x4, 0xe0, 0x88, 0xe8, 0xe1, 0xf8, 0x51, 0xed, 0xf0, - 0x8a, 0xbb, 0x98, 0xb, 0x3c, 0xc2, 0xd8, 0x42, 0x9e, 0x16, 0x9e, 0xcb, 0x74, 0xcd, 0x35, 0x76, 0x5a, - 0x2a, 0x89, 0x26, 0x0, 0x15, 0x70, 0x14, 0x9e, 0xa7, 0x31, 0x75, 0xc8, 0x1c, 0x91, 0x71, 0x17, 0xb3, - 0xd9, 0x6d, 0xb2, 0x4b, 0x2, 0x50, 0xa9, 0xd8, 0x4e, 0x0, 0x2, 0xb6, 0xfd, 0x13, 0x7d, 0x5e, 0x29, - 0xa3, 0x13, 0x75, 0x30, 0x11, 0x0, 0x0, 0x64, 0x8d, 0x28, 0xdf, 0x22, 0x56, 0x39, 0x13, 0x4f, 0xf, - 0x2a, 0x88, 0x27, 0x0, 0x0, 0x76, 0x30, 0x18, 0x0, 0x0, 0x27, 0xeb, 0xb, 0x2, 0x15, 0x0, 0x16, - 0xf2, 0xc9, 0x50, 0x70, 0x36, 0x3d, 0x8, 0x3f, 0x4c, 0xe8, 0xce, 0x7, 0x14, 0x37, 0xa8, 0x26, 0x82, - 0xa7, 0x1a, 0xea, 0xed, 0x8f, 0x67, 0x9, 0x3f, 0xc7, 0x1, 0x58, 0x80, 0x9e, 0x5f}; - - uint8_t buf[143] = {0}; - - uint8_t topic_bytes[] = {0x28, 0xd9, 0xf4, 0x4, 0xe0, 0x88, 0xe8, 0xe1, 0xf8, 0x51, 0xed, 0xf0, 0x8a, - 0xbb, 0x98, 0xb, 0x3c, 0xc2, 0xd8, 0x42, 0x9e, 0x16, 0x9e, 0xcb, 0x74, 0xcd}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x67, 0x9, 0x3f, 0xc7, 0x1, 0x58, 0x80, 0x9e, 0x5f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; - - uint8_t bytesprops1[] = {0xb6, 0xfd}; - uint8_t bytesprops0[] = {0x70, 0x14, 0x9e, 0xa7, 0x31, 0x75, 0xc8, 0x1c, 0x91, 0x71, 0x17, - 0xb3, 0xd9, 0x6d, 0xb2, 0x4b, 0x2, 0x50, 0xa9, 0xd8, 0x4e}; - uint8_t bytesprops2[] = {0xf2, 0xc9, 0x50, 0x70, 0x36, 0x3d, 0x8, 0x3f, 0x4c, 0xe8, 0xce, - 0x7, 0x14, 0x37, 0xa8, 0x26, 0x82, 0xa7, 0x1a, 0xea, 0xed, 0x8f}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops0}, .v = {2, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32094}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30000}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25741}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22073}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20239}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30256}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10219}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops2}}}, - }; - - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 13686, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "FL\240\156\182\192\&3\212\166\234!\162i#\233\190}'N\176", _pubPktID = 7951, _pubBody = -// "\246\168g\152\239\&8\214\227\217R=w3\173\155\210Y\155@", _pubProps = [PropRetainAvailable -// 78,PropAssignedClientIdentifier -// "k\233\247\216l5n\202N\233\218\\\DC4\241\173/{\249\239C\ACK\214Z\218\204",PropRequestResponseInformation -// 204,PropReasonString "\136+\156",PropRetainAvailable 111,PropRequestProblemInformation 233,PropTopicAlias -// 5145,PropServerReference -// "p\RS2\145\232}\145\DC1#P\152-\DEL\137(UV\v\183F\245\209\241l\143\130\244k",PropServerReference -// "B\ad\148\164\235\140\t\145\171nR "]} -TEST(Publish5QCTest, Encode91) { - uint8_t pkt[] = {0x3c, 0x88, 0x1, 0x0, 0x14, 0x46, 0x4c, 0xf0, 0x9c, 0xb6, 0xc0, 0x33, 0xd4, 0xa6, 0xea, 0x21, - 0xa2, 0x69, 0x23, 0xe9, 0xbe, 0x7d, 0x27, 0x4e, 0xb0, 0x1f, 0xf, 0x5c, 0x25, 0x4e, 0x12, 0x0, - 0x19, 0x6b, 0xe9, 0xf7, 0xd8, 0x6c, 0x35, 0x6e, 0xca, 0x4e, 0xe9, 0xda, 0x5c, 0x14, 0xf1, 0xad, - 0x2f, 0x7b, 0xf9, 0xef, 0x43, 0x6, 0xd6, 0x5a, 0xda, 0xcc, 0x19, 0xcc, 0x1f, 0x0, 0x3, 0x88, - 0x2b, 0x9c, 0x25, 0x6f, 0x17, 0xe9, 0x23, 0x14, 0x19, 0x1c, 0x0, 0x1c, 0x70, 0x1e, 0x32, 0x91, - 0xe8, 0x7d, 0x91, 0x11, 0x23, 0x50, 0x98, 0x2d, 0x7f, 0x89, 0x28, 0x55, 0x56, 0xb, 0xb7, 0x46, - 0xf5, 0xd1, 0xf1, 0x6c, 0x8f, 0x82, 0xf4, 0x6b, 0x1c, 0x0, 0xd, 0x42, 0x7, 0x64, 0x94, 0xa4, - 0xeb, 0x8c, 0x9, 0x91, 0xab, 0x6e, 0x52, 0x20, 0xf6, 0xa8, 0x67, 0x98, 0xef, 0x38, 0xd6, 0xe3, - 0xd9, 0x52, 0x3d, 0x77, 0x33, 0xad, 0x9b, 0xd2, 0x59, 0x9b, 0x40}; - - uint8_t buf[149] = {0}; - - uint8_t topic_bytes[] = {0x46, 0x4c, 0xf0, 0x9c, 0xb6, 0xc0, 0x33, 0xd4, 0xa6, 0xea, - 0x21, 0xa2, 0x69, 0x23, 0xe9, 0xbe, 0x7d, 0x27, 0x4e, 0xb0}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xf6, 0xa8, 0x67, 0x98, 0xef, 0x38, 0xd6, 0xe3, 0xd9, 0x52, - 0x3d, 0x77, 0x33, 0xad, 0x9b, 0xd2, 0x59, 0x9b, 0x40}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; - - uint8_t bytesprops0[] = {0x6b, 0xe9, 0xf7, 0xd8, 0x6c, 0x35, 0x6e, 0xca, 0x4e, 0xe9, 0xda, 0x5c, 0x14, - 0xf1, 0xad, 0x2f, 0x7b, 0xf9, 0xef, 0x43, 0x6, 0xd6, 0x5a, 0xda, 0xcc}; - uint8_t bytesprops1[] = {0x88, 0x2b, 0x9c}; - uint8_t bytesprops2[] = {0x70, 0x1e, 0x32, 0x91, 0xe8, 0x7d, 0x91, 0x11, 0x23, 0x50, 0x98, 0x2d, 0x7f, 0x89, - 0x28, 0x55, 0x56, 0xb, 0xb7, 0x46, 0xf5, 0xd1, 0xf1, 0x6c, 0x8f, 0x82, 0xf4, 0x6b}; - uint8_t bytesprops3[] = {0x42, 0x7, 0x64, 0x94, 0xa4, 0xeb, 0x8c, 0x9, 0x91, 0xab, 0x6e, 0x52, 0x20}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5145}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops3}}}, - }; - - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7951, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\232\175\EOT\145\DEL\254\166\230\212MM\131\&6R\177A\217", _pubPktID = 26125, _pubBody = "\229\&1", _pubProps = -// [PropSharedSubscriptionAvailable 46,PropMaximumQoS 133,PropSubscriptionIdentifierAvailable 212,PropServerReference -// "\130",PropReasonString -// "7\133A>\210\220\244\f\237\128\185D\173\ETB\170U\DC3A>\230\237x\128N.\SYN:\251\202",PropAssignedClientIdentifier -// "\153\EOT\231\185\244",PropContentType -// "\251\DC3T\201\219(ozL\219g\201\166S\205\144=\f\n\194A\USQ(\219\161\162E\244\228",PropAuthenticationMethod -// "",PropTopicAlias 20730,PropAssignedClientIdentifier "R\242\197\138Z\246x\140\161\203",PropServerKeepAlive -// 7460,PropUserProperty "-m\162\172\254F\156\234&v\142\166\RS_\141\217\201\164C\152\DC3\212\224\154" -// "2\153M\249\129",PropSessionExpiryInterval 20348,PropCorrelationData -// "\184z\132\132\173\239\168\SO\194\153wk\211P\179;\246OS\ETB",PropAuthenticationData "",PropContentType -// "\213\&2\RS",PropSessionExpiryInterval 31013,PropReceiveMaximum 10571,PropResponseInformation -// "\168\239\b\253\212\129]\158\154\SI\143\ESC\242\245\163\211\205\185\203\175s\142\181rX\225\240",PropReceiveMaximum -// 11056,PropMaximumPacketSize 22864,PropReasonString -// "\209m\142\246+L\157\ETB\151\201b.\ETX\239\163\140\bhD\202\NAK\255\139j\214\199"]} -TEST(Publish5QCTest, Encode92) { - uint8_t pkt[] = { - 0x35, 0x94, 0x2, 0x0, 0x11, 0xe8, 0xaf, 0x4, 0x91, 0x7f, 0xfe, 0xa6, 0xe6, 0xd4, 0x4d, 0x4d, 0x83, 0x36, 0x52, - 0xb1, 0x41, 0xd9, 0x66, 0xd, 0xfb, 0x1, 0x2a, 0x2e, 0x24, 0x85, 0x29, 0xd4, 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 0x81, 0x5d, 0x9e, 0x9a, 0xf, 0x8f, 0x1b, 0xf2, 0xf5, 0xa3, - 0xd3, 0xcd, 0xb9, 0xcb, 0xaf, 0x73, 0x8e, 0xb5, 0x72, 0x58, 0xe1, 0xf0, 0x21, 0x2b, 0x30, 0x27, 0x0, 0x0, 0x59, - 0x50, 0x1f, 0x0, 0x1a, 0xd1, 0x6d, 0x8e, 0xf6, 0x2b, 0x4c, 0x9d, 0x17, 0x97, 0xc9, 0x62, 0x2e, 0x3, 0xef, 0xa3, - 0x8c, 0x8, 0x68, 0x44, 0xca, 0x15, 0xff, 0x8b, 0x6a, 0xd6, 0xc7, 0xe5, 0x31}; - - uint8_t buf[289] = {0}; - - uint8_t topic_bytes[] = {0xe8, 0xaf, 0x4, 0x91, 0x7f, 0xfe, 0xa6, 0xe6, 0xd4, - 0x4d, 0x4d, 0x83, 0x36, 0x52, 0xb1, 0x41, 0xd9}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xe5, 0x31}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; - - uint8_t bytesprops0[] = {0x82}; - uint8_t bytesprops1[] = {0x37, 0x85, 0x41, 0x3e, 0xd2, 0xdc, 0xf4, 0xc, 0xed, 0x80, 0xb9, 0x44, 0xad, 0x17, 0xaa, - 0x55, 0x13, 0x41, 0x3e, 0xe6, 0xed, 0x78, 0x80, 0x4e, 0x2e, 0x16, 0x3a, 0xfb, 0xca}; - uint8_t bytesprops2[] = {0x99, 0x4, 0xe7, 0xb9, 0xf4}; - uint8_t bytesprops3[] = {0xfb, 0x13, 0x54, 0xc9, 0xdb, 0x28, 0x6f, 0x7a, 0x4c, 0xdb, 0x67, 0xc9, 0xa6, 0x53, 0xcd, - 0x90, 0x3d, 0xc, 0xa, 0xc2, 0x41, 0x1f, 0x51, 0x28, 0xdb, 0xa1, 0xa2, 0x45, 0xf4, 0xe4}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0x52, 0xf2, 0xc5, 0x8a, 0x5a, 0xf6, 0x78, 0x8c, 0xa1, 0xcb}; - uint8_t bytesprops7[] = {0x32, 0x99, 0x4d, 0xf9, 0x81}; - uint8_t bytesprops6[] = {0x2d, 0x6d, 0xa2, 0xac, 0xfe, 0x46, 0x9c, 0xea, 0x26, 0x76, 0x8e, 0xa6, - 0x1e, 0x5f, 0x8d, 0xd9, 0xc9, 0xa4, 0x43, 0x98, 0x13, 0xd4, 0xe0, 0x9a}; - uint8_t bytesprops8[] = {0xb8, 0x7a, 0x84, 0x84, 0xad, 0xef, 0xa8, 0xe, 0xc2, 0x99, - 0x77, 0x6b, 0xd3, 0x50, 0xb3, 0x3b, 0xf6, 0x4f, 0x53, 0x17}; - uint8_t bytesprops9[] = {0}; - uint8_t bytesprops10[] = {0xd5, 0x32, 0x1e}; - uint8_t bytesprops11[] = {0xa8, 0xef, 0x8, 0xfd, 0xd4, 0x81, 0x5d, 0x9e, 0x9a, 0xf, 0x8f, 0x1b, 0xf2, 0xf5, - 0xa3, 0xd3, 0xcd, 0xb9, 0xcb, 0xaf, 0x73, 0x8e, 0xb5, 0x72, 0x58, 0xe1, 0xf0}; - uint8_t bytesprops12[] = {0xd1, 0x6d, 0x8e, 0xf6, 0x2b, 0x4c, 0x9d, 0x17, 0x97, 0xc9, 0x62, 0x2e, 0x3, - 0xef, 0xa3, 0x8c, 0x8, 0x68, 0x44, 0xca, 0x15, 0xff, 0x8b, 0x6a, 0xd6, 0xc7}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20730}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7460}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops6}, .v = {5, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20348}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31013}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10571}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11056}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22864}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops12}}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 26125, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\249\223\224\153M\215\191\241/z\197=\210\196\197T-", _pubPktID = 4023, _pubBody = "\146G", _pubProps = -// [PropRetainAvailable 91,PropMessageExpiryInterval 9270,PropReceiveMaximum 4788]} -TEST(Publish5QCTest, Encode93) { - uint8_t pkt[] = {0x32, 0x22, 0x0, 0x11, 0xf9, 0xdf, 0xe0, 0x99, 0x4d, 0xd7, 0xbf, 0xf1, - 0x2f, 0x7a, 0xc5, 0x3d, 0xd2, 0xc4, 0xc5, 0x54, 0x2d, 0xf, 0xb7, 0xa, - 0x25, 0x5b, 0x2, 0x0, 0x0, 0x24, 0x36, 0x21, 0x12, 0xb4, 0x92, 0x47}; - - uint8_t buf[46] = {0}; - - uint8_t topic_bytes[] = {0xf9, 0xdf, 0xe0, 0x99, 0x4d, 0xd7, 0xbf, 0xf1, 0x2f, - 0x7a, 0xc5, 0x3d, 0xd2, 0xc4, 0xc5, 0x54, 0x2d}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x92, 0x47}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9270}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4788}}, - }; - - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 4023, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "1\188?\134-\151\130\165\DC3\149\&0\188\151\r\192q\134Wi\255\238\204\193\225\205\231\164", _pubPktID = 3250, _pubBody -// = "\209\151\165\147\252]\131\r\145p\242\&6\155z\255", _pubProps = [PropMaximumQoS 34,PropSubscriptionIdentifier -// 27,PropContentType "\218\230\197\bgVnD#\155\136\193\208\141\230x\174\130>\196\179v\239r]",PropMessageExpiryInterval -// 32234,PropResponseTopic "bA\ACKy\246\186\239\153X6`\155\SYNi",PropAuthenticationMethod -// "\an|$3\239\231\240R",PropMaximumPacketSize 14841]} -TEST(Publish5QCTest, Encode94) { - uint8_t pkt[] = {0x35, 0x76, 0x0, 0x1b, 0x31, 0xbc, 0x3f, 0x86, 0x2d, 0x97, 0x82, 0xa5, 0x13, 0x95, 0x30, - 0xbc, 0x97, 0xd, 0xc0, 0x71, 0x86, 0x57, 0x69, 0xff, 0xee, 0xcc, 0xc1, 0xe1, 0xcd, 0xe7, - 0xa4, 0xc, 0xb2, 0x47, 0x24, 0x22, 0xb, 0x1b, 0x3, 0x0, 0x19, 0xda, 0xe6, 0xc5, 0x8, - 0x67, 0x56, 0x6e, 0x44, 0x23, 0x9b, 0x88, 0xc1, 0xd0, 0x8d, 0xe6, 0x78, 0xae, 0x82, 0x3e, - 0xc4, 0xb3, 0x76, 0xef, 0x72, 0x5d, 0x2, 0x0, 0x0, 0x7d, 0xea, 0x8, 0x0, 0xe, 0x62, - 0x41, 0x6, 0x79, 0xf6, 0xba, 0xef, 0x99, 0x58, 0x36, 0x60, 0x9b, 0x16, 0x69, 0x15, 0x0, - 0x9, 0x7, 0x6e, 0x7c, 0x24, 0x33, 0xef, 0xe7, 0xf0, 0x52, 0x27, 0x0, 0x0, 0x39, 0xf9, - 0xd1, 0x97, 0xa5, 0x93, 0xfc, 0x5d, 0x83, 0xd, 0x91, 0x70, 0xf2, 0x36, 0x9b, 0x7a, 0xff}; - - uint8_t buf[130] = {0}; - - uint8_t topic_bytes[] = {0x31, 0xbc, 0x3f, 0x86, 0x2d, 0x97, 0x82, 0xa5, 0x13, 0x95, 0x30, 0xbc, 0x97, 0xd, - 0xc0, 0x71, 0x86, 0x57, 0x69, 0xff, 0xee, 0xcc, 0xc1, 0xe1, 0xcd, 0xe7, 0xa4}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xd1, 0x97, 0xa5, 0x93, 0xfc, 0x5d, 0x83, 0xd, 0x91, 0x70, 0xf2, 0x36, 0x9b, 0x7a, 0xff}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0xda, 0xe6, 0xc5, 0x8, 0x67, 0x56, 0x6e, 0x44, 0x23, 0x9b, 0x88, 0xc1, 0xd0, - 0x8d, 0xe6, 0x78, 0xae, 0x82, 0x3e, 0xc4, 0xb3, 0x76, 0xef, 0x72, 0x5d}; - uint8_t bytesprops1[] = {0x62, 0x41, 0x6, 0x79, 0xf6, 0xba, 0xef, 0x99, 0x58, 0x36, 0x60, 0x9b, 0x16, 0x69}; - uint8_t bytesprops2[] = {0x7, 0x6e, 0x7c, 0x24, 0x33, 0xef, 0xe7, 0xf0, 0x52}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32234}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14841}}, - }; - - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 3250, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\149y\148\SOH\133\136\STX\n\242", -// _pubPktID = 27162, _pubBody = -// "\163\212\196\ENQ\196\186w\152\RS\219\243>k~\167\130o^\157\\\197C\128\130\185\247\201\148C\197", _pubProps = -// [PropTopicAlias 16230,PropWillDelayInterval 28392,PropAuthenticationData -// "\194\t7\142\236\197<\157\209\220\232\r\142\ETB[\239\183\144\179\SYN\140\f\246\255\&8",PropWildcardSubscriptionAvailable -// 163,PropSharedSubscriptionAvailable 254,PropResponseInformation -// "\200\228\&8e;V\178p^\188I\\<={t\234n\154,\230\253\CAN#/\197\236\174\246",PropSessionExpiryInterval -// 4151,PropMaximumQoS 240]} -TEST(Publish5QCTest, Encode95) { - uint8_t pkt[] = {0x3b, 0x7b, 0x0, 0x9, 0x95, 0x79, 0x94, 0x1, 0x85, 0x88, 0x2, 0xa, 0xf2, 0x6a, 0x1a, 0x4f, - 0x23, 0x3f, 0x66, 0x18, 0x0, 0x0, 0x6e, 0xe8, 0x16, 0x0, 0x19, 0xc2, 0x9, 0x37, 0x8e, 0xec, - 0xc5, 0x3c, 0x9d, 0xd1, 0xdc, 0xe8, 0xd, 0x8e, 0x17, 0x5b, 0xef, 0xb7, 0x90, 0xb3, 0x16, 0x8c, - 0xc, 0xf6, 0xff, 0x38, 0x28, 0xa3, 0x2a, 0xfe, 0x1a, 0x0, 0x1d, 0xc8, 0xe4, 0x38, 0x65, 0x3b, - 0x56, 0xb2, 0x70, 0x5e, 0xbc, 0x49, 0x5c, 0x3c, 0x3d, 0x7b, 0x74, 0xea, 0x6e, 0x9a, 0x2c, 0xe6, - 0xfd, 0x18, 0x23, 0x2f, 0xc5, 0xec, 0xae, 0xf6, 0x11, 0x0, 0x0, 0x10, 0x37, 0x24, 0xf0, 0xa3, - 0xd4, 0xc4, 0x5, 0xc4, 0xba, 0x77, 0x98, 0x1e, 0xdb, 0xf3, 0x3e, 0x6b, 0x7e, 0xa7, 0x82, 0x6f, - 0x5e, 0x9d, 0x5c, 0xc5, 0x43, 0x80, 0x82, 0xb9, 0xf7, 0xc9, 0x94, 0x43, 0xc5}; - - uint8_t buf[135] = {0}; - - uint8_t topic_bytes[] = {0x95, 0x79, 0x94, 0x1, 0x85, 0x88, 0x2, 0xa, 0xf2}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xa3, 0xd4, 0xc4, 0x5, 0xc4, 0xba, 0x77, 0x98, 0x1e, 0xdb, 0xf3, 0x3e, 0x6b, 0x7e, 0xa7, - 0x82, 0x6f, 0x5e, 0x9d, 0x5c, 0xc5, 0x43, 0x80, 0x82, 0xb9, 0xf7, 0xc9, 0x94, 0x43, 0xc5}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; - - uint8_t bytesprops0[] = {0xc2, 0x9, 0x37, 0x8e, 0xec, 0xc5, 0x3c, 0x9d, 0xd1, 0xdc, 0xe8, 0xd, 0x8e, - 0x17, 0x5b, 0xef, 0xb7, 0x90, 0xb3, 0x16, 0x8c, 0xc, 0xf6, 0xff, 0x38}; - uint8_t bytesprops1[] = {0xc8, 0xe4, 0x38, 0x65, 0x3b, 0x56, 0xb2, 0x70, 0x5e, 0xbc, 0x49, 0x5c, 0x3c, 0x3d, 0x7b, - 0x74, 0xea, 0x6e, 0x9a, 0x2c, 0xe6, 0xfd, 0x18, 0x23, 0x2f, 0xc5, 0xec, 0xae, 0xf6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16230}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28392}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4151}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 240}}, - }; - - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 27162, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\133\236\215", _pubPktID = 29262, -// _pubBody = "\150|7\US\164%\USi\129\ACK\161\142\139\207", _pubProps = [PropContentType -// "\220\b<+\DC3\245\ENQ\200\DEL0s\138b\223\245\&6\GS\190\149\182\DC3m\180\142<\181",PropMaximumQoS -// 238,PropWillDelayInterval 4046,PropAssignedClientIdentifier "\150\174\238\247^",PropMessageExpiryInterval -// 19374,PropServerKeepAlive 30717,PropMaximumPacketSize 22891,PropSharedSubscriptionAvailable -// 29,PropPayloadFormatIndicator 133,PropServerKeepAlive 16285,PropRequestResponseInformation 123,PropReasonString -// "",PropRequestProblemInformation 107,PropSharedSubscriptionAvailable 60,PropSharedSubscriptionAvailable -// 98,PropTopicAlias 27866,PropServerReference "\235-\158\236\241\n"]} -TEST(Publish5QCTest, Encode96) { - uint8_t pkt[] = {0x35, 0xa1, 0x1, 0x0, 0x3, 0x85, 0xec, 0xd7, 0x72, 0x4e, 0x8a, 0x1, 0x3, 0x0, 0x1a, 0xdc, 0x8, - 0x3c, 0x2b, 0x13, 0xf5, 0x5, 0xc8, 0x7f, 0x30, 0x73, 0x8a, 0x62, 0xdf, 0xf5, 0x36, 0x1d, 0xbe, 0x95, - 0xb6, 0x13, 0x6d, 0xb4, 0x8e, 0x3c, 0xb5, 0x24, 0xee, 0x18, 0x0, 0x0, 0xf, 0xce, 0x12, 0x0, 0x5, - 0x96, 0xae, 0xee, 0xf7, 0x5e, 0x2, 0x0, 0x0, 0x4b, 0xae, 0x13, 0x77, 0xfd, 0x27, 0x0, 0x0, 0x59, - 0x6b, 0x2a, 0x1d, 0x1, 0x85, 0x13, 0x3f, 0x9d, 0x19, 0x7b, 0x1f, 0x0, 0x0, 0x17, 0x6b, 0x2a, 0x3c, - 0x2a, 0x62, 0x23, 0x6c, 0xda, 0x1c, 0x0, 0x6, 0xeb, 0x2d, 0x9e, 0xec, 0x3c, 0x5a, 0x29, 0x90, 0x26, - 0x0, 0x18, 0x6b, 0xb4, 0xec, 0x46, 0x4e, 0xf5, 0x48, 0xf0, 0xd8, 0xed, 0xfe, 0x58, 0x32, 0x59, 0x74, - 0x5c, 0x56, 0x6d, 0xcd, 0x1c, 0x76, 0x54, 0xb2, 0x7b, 0x0, 0x5, 0xf0, 0x72, 0xe3, 0x44, 0xa3, 0x1, - 0xfb, 0x28, 0x59, 0x12, 0x0, 0x8, 0x65, 0xfb, 0xc, 0xc8, 0xed, 0x3e, 0xf1, 0xa, 0x96, 0x7c, 0x37, - 0x1f, 0xa4, 0x25, 0x1f, 0x69, 0x81, 0x6, 0xa1, 0x8e, 0x8b, 0xcf}; - - uint8_t buf[174] = {0}; - - uint8_t topic_bytes[] = {0x85, 0xec, 0xd7}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x96, 0x7c, 0x37, 0x1f, 0xa4, 0x25, 0x1f, 0x69, 0x81, 0x6, 0xa1, 0x8e, 0x8b, 0xcf}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; - - uint8_t bytesprops0[] = {0xdc, 0x8, 0x3c, 0x2b, 0x13, 0xf5, 0x5, 0xc8, 0x7f, 0x30, 0x73, 0x8a, 0x62, - 0xdf, 0xf5, 0x36, 0x1d, 0xbe, 0x95, 0xb6, 0x13, 0x6d, 0xb4, 0x8e, 0x3c, 0xb5}; - uint8_t bytesprops1[] = {0x96, 0xae, 0xee, 0xf7, 0x5e}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0xeb, 0x2d, 0x9e, 0xec, 0x3c, 0x5a}; - uint8_t bytesprops5[] = {0xf0, 0x72, 0xe3, 0x44, 0xa3}; - uint8_t bytesprops4[] = {0x6b, 0xb4, 0xec, 0x46, 0x4e, 0xf5, 0x48, 0xf0, 0xd8, 0xed, 0xfe, 0x58, - 0x32, 0x59, 0x74, 0x5c, 0x56, 0x6d, 0xcd, 0x1c, 0x76, 0x54, 0xb2, 0x7b}; - uint8_t bytesprops6[] = {0x65, 0xfb, 0xc, 0xc8, 0xed, 0x3e, 0xf1, 0xa}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4046}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19374}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30717}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22891}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16285}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27866}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops4}, .v = {5, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops6}}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29262, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "5b0\195\142R\129\205", _pubPktID = -// 25975, _pubBody = ":\135\203\145\&6\148\180\155\&28\243", _pubProps = [PropSubscriptionIdentifier 1]} -TEST(Publish5QCTest, Encode97) { - uint8_t pkt[] = {0x33, 0x1a, 0x0, 0x8, 0x35, 0x62, 0x30, 0xc3, 0x8e, 0x52, 0x81, 0xcd, 0x65, 0x77, - 0x2, 0xb, 0x1, 0x3a, 0x87, 0xcb, 0x91, 0x36, 0x94, 0xb4, 0x9b, 0x32, 0x38, 0xf3}; - - uint8_t buf[38] = {0}; - - uint8_t topic_bytes[] = {0x35, 0x62, 0x30, 0xc3, 0x8e, 0x52, 0x81, 0xcd}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x3a, 0x87, 0xcb, 0x91, 0x36, 0x94, 0xb4, 0x9b, 0x32, 0x38, 0xf3}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - }; - - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 25975, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\213Jr\201\234\223\158\NULA\172F$x\203\226", _pubPktID = 5740, _pubBody = -// "\v\DC4\158\192\171F\249\ESC\192U\254\"\152\151", _pubProps = [PropTopicAliasMaximum 31021,PropPayloadFormatIndicator -// 129,PropWildcardSubscriptionAvailable 110,PropAuthenticationMethod -// "\165\200\f\130\b\178\175\170\160d\253\186g\214L\t\181\NUL\152",PropMaximumPacketSize 18785,PropRetainAvailable -// 128,PropTopicAliasMaximum 8682,PropWildcardSubscriptionAvailable 123,PropAuthenticationMethod -// "\170\169\r\206<\NAKs\FS98\163\187\DC1Mx6\183M\238'\SINNHu\164",PropPayloadFormatIndicator -// 120,PropSubscriptionIdentifier 7,PropAssignedClientIdentifier "\SUBf\240.[8-c\173\240\&8\EOT\EM\n",PropResponseTopic -// "\224\198",PropServerReference -// "\200\132\249\200\203\DC4\239D\205\172\185P\173\210,c\159\137IC\224M.e\159\253\225",PropSessionExpiryInterval -// 27500,PropRequestProblemInformation 55,PropResponseTopic -// "\161\168\&9\SYN\215\203A\129\143_\183\204u\NUL#M\142\CAN\ap\167",PropAuthenticationMethod "",PropCorrelationData -// "\159\NAK=\"ew\SYN3\246\164b|\ETB\NUL{\139\190\200\182\ETX\251Nq\144\129\SYN\212Q",PropUserProperty -// "\DC1\190\247\SI\225" "z\fT\SUB[\229\135xjol\223\DLE\195\189\158\SYN\DC3\191{q\190\f^^\227<\243",PropMaximumQoS -// 49,PropServerKeepAlive 14505,PropRetainAvailable 171,PropResponseTopic -// "\240\EOT\255\SO\251\&3B\213",PropServerKeepAlive 26936,PropServerKeepAlive 24077,PropResponseTopic -// "P\206\198\253\163 \185\184\ENQ\207\188\189\141cf1",PropContentType "\189\168j~b\168",PropSharedSubscriptionAvailable -// 178,PropWildcardSubscriptionAvailable 218]} -TEST(Publish5QCTest, Encode98) { - uint8_t pkt[] = { - 0x3b, 0xc0, 0x2, 0x0, 0xf, 0xd5, 0x4a, 0x72, 0xc9, 0xea, 0xdf, 0x9e, 0x0, 0x41, 0xac, 0x46, 0x24, 0x78, 0xcb, - 0xe2, 0x16, 0x6c, 0x9d, 0x2, 0x22, 0x79, 0x2d, 0x1, 0x81, 0x28, 0x6e, 0x15, 0x0, 0x13, 0xa5, 0xc8, 0xc, 0x82, - 0x8, 0xb2, 0xaf, 0xaa, 0xa0, 0x64, 0xfd, 0xba, 0x67, 0xd6, 0x4c, 0x9, 0xb5, 0x0, 0x98, 0x27, 0x0, 0x0, 0x49, - 0x61, 0x25, 0x80, 0x22, 0x21, 0xea, 0x28, 0x7b, 0x15, 0x0, 0x1a, 0xaa, 0xa9, 0xd, 0xce, 0x3c, 0x15, 0x73, 0x1c, - 0x39, 0x38, 0xa3, 0xbb, 0x11, 0x4d, 0x78, 0x36, 0xb7, 0x4d, 0xee, 0x27, 0xf, 0x4e, 0x4e, 0x48, 0x75, 0xa4, 0x1, - 0x78, 0xb, 0x7, 0x12, 0x0, 0xe, 0x1a, 0x66, 0xf0, 0x2e, 0x5b, 0x38, 0x2d, 0x63, 0xad, 0xf0, 0x38, 0x4, 0x19, - 0xa, 0x8, 0x0, 0x2, 0xe0, 0xc6, 0x1c, 0x0, 0x1b, 0xc8, 0x84, 0xf9, 0xc8, 0xcb, 0x14, 0xef, 0x44, 0xcd, 0xac, - 0xb9, 0x50, 0xad, 0xd2, 0x2c, 0x63, 0x9f, 0x89, 0x49, 0x43, 0xe0, 0x4d, 0x2e, 0x65, 0x9f, 0xfd, 0xe1, 0x11, 0x0, - 0x0, 0x6b, 0x6c, 0x17, 0x37, 0x8, 0x0, 0x15, 0xa1, 0xa8, 0x39, 0x16, 0xd7, 0xcb, 0x41, 0x81, 0x8f, 0x5f, 0xb7, - 0xcc, 0x75, 0x0, 0x23, 0x4d, 0x8e, 0x18, 0x7, 0x70, 0xa7, 0x15, 0x0, 0x0, 0x9, 0x0, 0x1c, 0x9f, 0x15, 0x3d, - 0x22, 0x65, 0x77, 0x16, 0x33, 0xf6, 0xa4, 0x62, 0x7c, 0x17, 0x0, 0x7b, 0x8b, 0xbe, 0xc8, 0xb6, 0x3, 0xfb, 0x4e, - 0x71, 0x90, 0x81, 0x16, 0xd4, 0x51, 0x26, 0x0, 0x5, 0x11, 0xbe, 0xf7, 0xf, 0xe1, 0x0, 0x1c, 0x7a, 0xc, 0x54, - 0x1a, 0x5b, 0xe5, 0x87, 0x78, 0x6a, 0x6f, 0x6c, 0xdf, 0x10, 0xc3, 0xbd, 0x9e, 0x16, 0x13, 0xbf, 0x7b, 0x71, 0xbe, - 0xc, 0x5e, 0x5e, 0xe3, 0x3c, 0xf3, 0x24, 0x31, 0x13, 0x38, 0xa9, 0x25, 0xab, 0x8, 0x0, 0x8, 0xf0, 0x4, 0xff, - 0xe, 0xfb, 0x33, 0x42, 0xd5, 0x13, 0x69, 0x38, 0x13, 0x5e, 0xd, 0x8, 0x0, 0x10, 0x50, 0xce, 0xc6, 0xfd, 0xa3, - 0x20, 0xb9, 0xb8, 0x5, 0xcf, 0xbc, 0xbd, 0x8d, 0x63, 0x66, 0x31, 0x3, 0x0, 0x6, 0xbd, 0xa8, 0x6a, 0x7e, 0x62, - 0xa8, 0x2a, 0xb2, 0x28, 0xda, 0xb, 0x14, 0x9e, 0xc0, 0xab, 0x46, 0xf9, 0x1b, 0xc0, 0x55, 0xfe, 0x22, 0x98, 0x97}; - - uint8_t buf[333] = {0}; - - uint8_t topic_bytes[] = {0xd5, 0x4a, 0x72, 0xc9, 0xea, 0xdf, 0x9e, 0x0, 0x41, 0xac, 0x46, 0x24, 0x78, 0xcb, 0xe2}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xb, 0x14, 0x9e, 0xc0, 0xab, 0x46, 0xf9, 0x1b, 0xc0, 0x55, 0xfe, 0x22, 0x98, 0x97}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; - - uint8_t bytesprops0[] = {0xa5, 0xc8, 0xc, 0x82, 0x8, 0xb2, 0xaf, 0xaa, 0xa0, 0x64, - 0xfd, 0xba, 0x67, 0xd6, 0x4c, 0x9, 0xb5, 0x0, 0x98}; - uint8_t bytesprops1[] = {0xaa, 0xa9, 0xd, 0xce, 0x3c, 0x15, 0x73, 0x1c, 0x39, 0x38, 0xa3, 0xbb, 0x11, - 0x4d, 0x78, 0x36, 0xb7, 0x4d, 0xee, 0x27, 0xf, 0x4e, 0x4e, 0x48, 0x75, 0xa4}; - uint8_t bytesprops2[] = {0x1a, 0x66, 0xf0, 0x2e, 0x5b, 0x38, 0x2d, 0x63, 0xad, 0xf0, 0x38, 0x4, 0x19, 0xa}; - uint8_t bytesprops3[] = {0xe0, 0xc6}; - uint8_t bytesprops4[] = {0xc8, 0x84, 0xf9, 0xc8, 0xcb, 0x14, 0xef, 0x44, 0xcd, 0xac, 0xb9, 0x50, 0xad, 0xd2, - 0x2c, 0x63, 0x9f, 0x89, 0x49, 0x43, 0xe0, 0x4d, 0x2e, 0x65, 0x9f, 0xfd, 0xe1}; - uint8_t bytesprops5[] = {0xa1, 0xa8, 0x39, 0x16, 0xd7, 0xcb, 0x41, 0x81, 0x8f, 0x5f, 0xb7, - 0xcc, 0x75, 0x0, 0x23, 0x4d, 0x8e, 0x18, 0x7, 0x70, 0xa7}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops7[] = {0x9f, 0x15, 0x3d, 0x22, 0x65, 0x77, 0x16, 0x33, 0xf6, 0xa4, 0x62, 0x7c, 0x17, 0x0, - 0x7b, 0x8b, 0xbe, 0xc8, 0xb6, 0x3, 0xfb, 0x4e, 0x71, 0x90, 0x81, 0x16, 0xd4, 0x51}; - uint8_t bytesprops9[] = {0x7a, 0xc, 0x54, 0x1a, 0x5b, 0xe5, 0x87, 0x78, 0x6a, 0x6f, 0x6c, 0xdf, 0x10, 0xc3, - 0xbd, 0x9e, 0x16, 0x13, 0xbf, 0x7b, 0x71, 0xbe, 0xc, 0x5e, 0x5e, 0xe3, 0x3c, 0xf3}; - uint8_t bytesprops8[] = {0x11, 0xbe, 0xf7, 0xf, 0xe1}; - uint8_t bytesprops10[] = {0xf0, 0x4, 0xff, 0xe, 0xfb, 0x33, 0x42, 0xd5}; - uint8_t bytesprops11[] = {0x50, 0xce, 0xc6, 0xfd, 0xa3, 0x20, 0xb9, 0xb8, - 0x5, 0xcf, 0xbc, 0xbd, 0x8d, 0x63, 0x66, 0x31}; - uint8_t bytesprops12[] = {0xbd, 0xa8, 0x6a, 0x7e, 0x62, 0xa8}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31021}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18785}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8682}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27500}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops8}, .v = {28, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14505}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26936}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24077}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 218}}, - }; - - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5740, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\t\CAN\145\171\148w\238,P\186\ETBHJo\217H\202\133\175\171.\147\134f\238\240X\231\137", _pubPktID = 1370, _pubBody = -// "`\241\GS\145\216\168\157\253JO\171\208j1]K\RSL<\242\&4", _pubProps = [PropCorrelationData -// "~\SO\252\191",PropTopicAliasMaximum 29794,PropTopicAlias 18581,PropSubscriptionIdentifier 28,PropTopicAliasMaximum -// 24754,PropAssignedClientIdentifier "",PropMessageExpiryInterval 19074,PropSessionExpiryInterval -// 19069,PropCorrelationData "\176\187'QX\\\183\&7\243\230\237",PropRequestResponseInformation 117,PropServerKeepAlive -// 809,PropReasonString "",PropResponseInformation "\227'\148#\197\&8N\193\242\159",PropMessageExpiryInterval -// 9394,PropRequestResponseInformation 20,PropAuthenticationData "=\170\v@\229\161o\202Q\134\184q\165\157n\205"]} -TEST(Publish5QCTest, Encode99) { - uint8_t pkt[] = {0x32, 0x93, 0x1, 0x0, 0x1d, 0x9, 0x18, 0x91, 0xab, 0x94, 0x77, 0xee, 0x2c, 0x50, 0xba, 0x17, 0x48, - 0x4a, 0x6f, 0xd9, 0x48, 0xca, 0x85, 0xaf, 0xab, 0x2e, 0x93, 0x86, 0x66, 0xee, 0xf0, 0x58, 0xe7, 0x89, - 0x5, 0x5a, 0x5c, 0x9, 0x0, 0x4, 0x7e, 0xe, 0xfc, 0xbf, 0x22, 0x74, 0x62, 0x23, 0x48, 0x95, 0xb, - 0x1c, 0x22, 0x60, 0xb2, 0x12, 0x0, 0x0, 0x2, 0x0, 0x0, 0x4a, 0x82, 0x11, 0x0, 0x0, 0x4a, 0x7d, - 0x9, 0x0, 0xb, 0xb0, 0xbb, 0x27, 0x51, 0x58, 0x5c, 0xb7, 0x37, 0xf3, 0xe6, 0xed, 0x19, 0x75, 0x13, - 0x3, 0x29, 0x1f, 0x0, 0x0, 0x1a, 0x0, 0xa, 0xe3, 0x27, 0x94, 0x23, 0xc5, 0x38, 0x4e, 0xc1, 0xf2, - 0x9f, 0x2, 0x0, 0x0, 0x24, 0xb2, 0x19, 0x14, 0x16, 0x0, 0x10, 0x3d, 0xaa, 0xb, 0x40, 0xe5, 0xa1, - 0x6f, 0xca, 0x51, 0x86, 0xb8, 0x71, 0xa5, 0x9d, 0x6e, 0xcd, 0x60, 0xf1, 0x1d, 0x91, 0xd8, 0xa8, 0x9d, - 0xfd, 0x4a, 0x4f, 0xab, 0xd0, 0x6a, 0x31, 0x5d, 0x4b, 0x1e, 0x4c, 0x3c, 0xf2, 0x34}; - - uint8_t buf[160] = {0}; - - uint8_t topic_bytes[] = {0x9, 0x18, 0x91, 0xab, 0x94, 0x77, 0xee, 0x2c, 0x50, 0xba, 0x17, 0x48, 0x4a, 0x6f, 0xd9, - 0x48, 0xca, 0x85, 0xaf, 0xab, 0x2e, 0x93, 0x86, 0x66, 0xee, 0xf0, 0x58, 0xe7, 0x89}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x60, 0xf1, 0x1d, 0x91, 0xd8, 0xa8, 0x9d, 0xfd, 0x4a, 0x4f, 0xab, - 0xd0, 0x6a, 0x31, 0x5d, 0x4b, 0x1e, 0x4c, 0x3c, 0xf2, 0x34}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - - uint8_t bytesprops0[] = {0x7e, 0xe, 0xfc, 0xbf}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0xb0, 0xbb, 0x27, 0x51, 0x58, 0x5c, 0xb7, 0x37, 0xf3, 0xe6, 0xed}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0xe3, 0x27, 0x94, 0x23, 0xc5, 0x38, 0x4e, 0xc1, 0xf2, 0x9f}; - uint8_t bytesprops5[] = {0x3d, 0xaa, 0xb, 0x40, 0xe5, 0xa1, 0x6f, 0xca, - 0x51, 0x86, 0xb8, 0x71, 0xa5, 0x9d, 0x6e, 0xcd}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29794}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18581}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24754}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19074}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19069}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 809}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9394}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1370, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\164.\DC1\135\131x\231n\143\DC3\247\SYN\189D\158\166\166\171\143\129\137\215", _pubPktID = 27834, _pubBody = -// "e8`\SO\145\RS`\179\229\146", _pubProps = [PropMessageExpiryInterval 10598,PropAuthenticationData -// "\n",PropUserProperty "S\201\134$>\130W\199K\133/\196\210\&5L\ESC,\230W\134" -// "?\245\DLE\245\254\164\162)\238Hbc",PropReasonString "\196\&5\176mF=\\",PropCorrelationData -// ";%\255=\149.A\207\233\235&m]\182->=r<@\139\252\vD<",PropResponseInformation -// "\137\155\145\173\231\SI]2z\219c\194\166\DEL{g",PropAuthenticationMethod -// "P\193G\237]\163jl\206\229\&6m\250C*:\141>7\157\139\128\161\EM\128?,a=\168",PropCorrelationData -// "\155\137\206\235\179\166\196'y\DC2:P\133l\SUB\171",PropReceiveMaximum 18094,PropRequestProblemInformation -// 7,PropTopicAlias 25296,PropSessionExpiryInterval 22146,PropPayloadFormatIndicator 34,PropRetainAvailable -// 111,PropContentType "\170\208\249OW\147"]} -TEST(Publish5QCTest, Encode100) { - uint8_t pkt[] = { - 0x3b, 0xdb, 0x1, 0x0, 0x16, 0xa4, 0x2e, 0x11, 0x87, 0x83, 0x78, 0xe7, 0x6e, 0x8f, 0x13, 0xf7, 0x16, 0xbd, 0x44, - 0x9e, 0xa6, 0xa6, 0xab, 0x8f, 0x81, 0x89, 0xd7, 0x6c, 0xba, 0xb5, 0x1, 0x2, 0x0, 0x0, 0x29, 0x66, 0x16, 0x0, - 0x1, 0xa, 0x26, 0x0, 0x14, 0x53, 0xc9, 0x86, 0x24, 0x3e, 0x82, 0x57, 0xc7, 0x4b, 0x85, 0x2f, 0xc4, 0xd2, 0x35, - 0x4c, 0x1b, 0x2c, 0xe6, 0x57, 0x86, 0x0, 0xc, 0x3f, 0xf5, 0x10, 0xf5, 0xfe, 0xa4, 0xa2, 0x29, 0xee, 0x48, 0x62, - 0x63, 0x1f, 0x0, 0x7, 0xc4, 0x35, 0xb0, 0x6d, 0x46, 0x3d, 0x5c, 0x9, 0x0, 0x19, 0x3b, 0x25, 0xff, 0x3d, 0x95, - 0x2e, 0x41, 0xcf, 0xe9, 0xeb, 0x26, 0x6d, 0x5d, 0xb6, 0x2d, 0x3e, 0x3d, 0x72, 0x3c, 0x40, 0x8b, 0xfc, 0xb, 0x44, - 0x3c, 0x1a, 0x0, 0x10, 0x89, 0x9b, 0x91, 0xad, 0xe7, 0xf, 0x5d, 0x32, 0x7a, 0xdb, 0x63, 0xc2, 0xa6, 0x7f, 0x7b, - 0x67, 0x15, 0x0, 0x1e, 0x50, 0xc1, 0x47, 0xed, 0x5d, 0xa3, 0x6a, 0x6c, 0xce, 0xe5, 0x36, 0x6d, 0xfa, 0x43, 0x2a, - 0x3a, 0x8d, 0x3e, 0x37, 0x9d, 0x8b, 0x80, 0xa1, 0x19, 0x80, 0x3f, 0x2c, 0x61, 0x3d, 0xa8, 0x9, 0x0, 0x10, 0x9b, - 0x89, 0xce, 0xeb, 0xb3, 0xa6, 0xc4, 0x27, 0x79, 0x12, 0x3a, 0x50, 0x85, 0x6c, 0x1a, 0xab, 0x21, 0x46, 0xae, 0x17, - 0x7, 0x23, 0x62, 0xd0, 0x11, 0x0, 0x0, 0x56, 0x82, 0x1, 0x22, 0x25, 0x6f, 0x3, 0x0, 0x6, 0xaa, 0xd0, 0xf9, - 0x4f, 0x57, 0x93, 0x65, 0x38, 0x60, 0xe, 0x91, 0x1e, 0x60, 0xb3, 0xe5, 0x92}; - - uint8_t buf[232] = {0}; - - uint8_t topic_bytes[] = {0xa4, 0x2e, 0x11, 0x87, 0x83, 0x78, 0xe7, 0x6e, 0x8f, 0x13, 0xf7, - 0x16, 0xbd, 0x44, 0x9e, 0xa6, 0xa6, 0xab, 0x8f, 0x81, 0x89, 0xd7}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x65, 0x38, 0x60, 0xe, 0x91, 0x1e, 0x60, 0xb3, 0xe5, 0x92}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; - - uint8_t bytesprops0[] = {0xa}; - uint8_t bytesprops2[] = {0x3f, 0xf5, 0x10, 0xf5, 0xfe, 0xa4, 0xa2, 0x29, 0xee, 0x48, 0x62, 0x63}; - uint8_t bytesprops1[] = {0x53, 0xc9, 0x86, 0x24, 0x3e, 0x82, 0x57, 0xc7, 0x4b, 0x85, - 0x2f, 0xc4, 0xd2, 0x35, 0x4c, 0x1b, 0x2c, 0xe6, 0x57, 0x86}; - uint8_t bytesprops3[] = {0xc4, 0x35, 0xb0, 0x6d, 0x46, 0x3d, 0x5c}; - uint8_t bytesprops4[] = {0x3b, 0x25, 0xff, 0x3d, 0x95, 0x2e, 0x41, 0xcf, 0xe9, 0xeb, 0x26, 0x6d, 0x5d, - 0xb6, 0x2d, 0x3e, 0x3d, 0x72, 0x3c, 0x40, 0x8b, 0xfc, 0xb, 0x44, 0x3c}; - uint8_t bytesprops5[] = {0x89, 0x9b, 0x91, 0xad, 0xe7, 0xf, 0x5d, 0x32, - 0x7a, 0xdb, 0x63, 0xc2, 0xa6, 0x7f, 0x7b, 0x67}; - uint8_t bytesprops6[] = {0x50, 0xc1, 0x47, 0xed, 0x5d, 0xa3, 0x6a, 0x6c, 0xce, 0xe5, 0x36, 0x6d, 0xfa, 0x43, 0x2a, - 0x3a, 0x8d, 0x3e, 0x37, 0x9d, 0x8b, 0x80, 0xa1, 0x19, 0x80, 0x3f, 0x2c, 0x61, 0x3d, 0xa8}; - uint8_t bytesprops7[] = {0x9b, 0x89, 0xce, 0xeb, 0xb3, 0xa6, 0xc4, 0x27, - 0x79, 0x12, 0x3a, 0x50, 0x85, 0x6c, 0x1a, 0xab}; - uint8_t bytesprops8[] = {0xaa, 0xd0, 0xf9, 0x4f, 0x57, 0x93}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10598}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops1}, .v = {12, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18094}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25296}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22146}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops8}}}, - }; - - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 27834, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "F\171\131\SI\DC4\132\f\236\247\252", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\246\240", _willMsg = -// "\169\154\b\180\t3\183\199\&9\250\194", _willProps = []}), _cleanSession = True, _keepAlive = 3250, _connID = " -// \241\DC2\ACK\157\190\v\161\205=\\\156dS\184{", _properties = []} -TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x2d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0xc, 0xb2, 0x0, 0x10, 0x20, 0xf1, - 0x12, 0x6, 0x9d, 0xbe, 0xb, 0xa1, 0xcd, 0x3d, 0x5c, 0x9c, 0x64, 0x53, 0xb8, 0x7b, 0x0, 0x2, - 0xf6, 0xf0, 0x0, 0xb, 0xa9, 0x9a, 0x8, 0xb4, 0x9, 0x33, 0xb7, 0xc7, 0x39, 0xfa, 0xc2}; - - uint8_t buf[57] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf6, 0xf0}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa9, 0x9a, 0x8, 0xb4, 0x9, 0x33, 0xb7, 0xc7, 0x39, 0xfa, 0xc2}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 3250; - uint8_t client_id_bytes[] = {0x20, 0xf1, 0x12, 0x6, 0x9d, 0xbe, 0xb, 0xa1, - 0xcd, 0x3d, 0x5c, 0x9c, 0x64, 0x53, 0xb8, 0x7b}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x46, 0xab, 0x83, 0xf, 0x14, 0x84, 0xc, 0xec, 0xf7, 0xfc}; - lwmqtt_string_t password = {10, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\185\211\STX\225\EOT\134\DC4\DC2", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS0, _willTopic = "y\133\f\222\RS\142", _willMsg = -// "\252\142\185\165\252\211e|\US\228\205\SYN\193\227\255\173\EOT$", _willProps = []}), _cleanSession = False, -// _keepAlive = 15842, _connID = "", _properties = []} -TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x32, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x84, 0x3d, 0xe2, 0x0, - 0x0, 0x0, 0x6, 0x79, 0x85, 0xc, 0xde, 0x1e, 0x8e, 0x0, 0x12, 0xfc, 0x8e, - 0xb9, 0xa5, 0xfc, 0xd3, 0x65, 0x7c, 0x1f, 0xe4, 0xcd, 0x16, 0xc1, 0xe3, 0xff, - 0xad, 0x4, 0x24, 0x0, 0x8, 0xb9, 0xd3, 0x2, 0xe1, 0x4, 0x86, 0x14, 0x12}; - - uint8_t buf[62] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x79, 0x85, 0xc, 0xde, 0x1e, 0x8e}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfc, 0x8e, 0xb9, 0xa5, 0xfc, 0xd3, 0x65, 0x7c, 0x1f, - 0xe4, 0xcd, 0x16, 0xc1, 0xe3, 0xff, 0xad, 0x4, 0x24}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 15842; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xb9, 0xd3, 0x2, 0xe1, 0x4, 0x86, 0x14, 0x12}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "eb:\159\169fA~\133\\\r6A7\139\&2\174\229Ue", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\255\245V\194\148\209\GS\f\218\140\201\EM/;H\146\135\176\253}\184\207V7.", _willMsg = -// "\SOH11\t\238\217?\210\\\EOT\223k\192\250?\156\178<\236+\SIQ\209\ACK\177\204\163", _willProps = []}), _cleanSession = -// False, _keepAlive = 29642, _connID = "\212eR", _properties = []} -TEST(Connect311QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2c, 0x73, 0xca, 0x0, 0x3, 0xd4, - 0x65, 0x52, 0x0, 0x19, 0xff, 0xf5, 0x56, 0xc2, 0x94, 0xd1, 0x1d, 0xc, 0xda, 0x8c, 0xc9, - 0x19, 0x2f, 0x3b, 0x48, 0x92, 0x87, 0xb0, 0xfd, 0x7d, 0xb8, 0xcf, 0x56, 0x37, 0x2e, 0x0, - 0x1b, 0x1, 0x31, 0x31, 0x9, 0xee, 0xd9, 0x3f, 0xd2, 0x5c, 0x4, 0xdf, 0x6b, 0xc0, 0xfa, - 0x3f, 0x9c, 0xb2, 0x3c, 0xec, 0x2b, 0xf, 0x51, 0xd1, 0x6, 0xb1, 0xcc, 0xa3}; - - uint8_t buf[83] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xff, 0xf5, 0x56, 0xc2, 0x94, 0xd1, 0x1d, 0xc, 0xda, 0x8c, 0xc9, 0x19, 0x2f, - 0x3b, 0x48, 0x92, 0x87, 0xb0, 0xfd, 0x7d, 0xb8, 0xcf, 0x56, 0x37, 0x2e}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1, 0x31, 0x31, 0x9, 0xee, 0xd9, 0x3f, 0xd2, 0x5c, 0x4, 0xdf, 0x6b, 0xc0, 0xfa, - 0x3f, 0x9c, 0xb2, 0x3c, 0xec, 0x2b, 0xf, 0x51, 0xd1, 0x6, 0xb1, 0xcc, 0xa3}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 29642; - uint8_t client_id_bytes[] = {0xd4, 0x65, 0x52}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x65, 0x62, 0x3a, 0x9f, 0xa9, 0x66, 0x41, 0x7e, 0x85, 0x5c, - 0xd, 0x36, 0x41, 0x37, 0x8b, 0x32, 0xae, 0xe5, 0x55, 0x65}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\197\244\208\172eI\158\208\&4\a\235\DC4\182d\132\GS\189\130O\128\228\192 ", _willMsg = -// "\162T\168%T\161[\138\\\156~t\191\154\206\ETX", _willProps = []}), _cleanSession = False, _keepAlive = 5339, _connID -// = "\194\163\154\203\EOTLMG`#\161l", _properties = []} -TEST(Connect311QCTest, Encode4) { - uint8_t pkt[] = {0x10, 0x43, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0x14, 0xdb, 0x0, 0xc, - 0xc2, 0xa3, 0x9a, 0xcb, 0x4, 0x4c, 0x4d, 0x47, 0x60, 0x23, 0xa1, 0x6c, 0x0, 0x17, - 0xc5, 0xf4, 0xd0, 0xac, 0x65, 0x49, 0x9e, 0xd0, 0x34, 0x7, 0xeb, 0x14, 0xb6, 0x64, - 0x84, 0x1d, 0xbd, 0x82, 0x4f, 0x80, 0xe4, 0xc0, 0x20, 0x0, 0x10, 0xa2, 0x54, 0xa8, - 0x25, 0x54, 0xa1, 0x5b, 0x8a, 0x5c, 0x9c, 0x7e, 0x74, 0xbf, 0x9a, 0xce, 0x3}; - - uint8_t buf[79] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc5, 0xf4, 0xd0, 0xac, 0x65, 0x49, 0x9e, 0xd0, 0x34, 0x7, 0xeb, 0x14, - 0xb6, 0x64, 0x84, 0x1d, 0xbd, 0x82, 0x4f, 0x80, 0xe4, 0xc0, 0x20}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa2, 0x54, 0xa8, 0x25, 0x54, 0xa1, 0x5b, 0x8a, - 0x5c, 0x9c, 0x7e, 0x74, 0xbf, 0x9a, 0xce, 0x3}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 5339; - uint8_t client_id_bytes[] = {0xc2, 0xa3, 0x9a, 0xcb, 0x4, 0x4c, 0x4d, 0x47, 0x60, 0x23, 0xa1, 0x6c}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\185\GSc\246\205\210\\\233\183w\EOT\252|-\224", _password = Nothing, _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\154\135@Q", _willMsg = -// "=\135\DEL\152\&4.\238\216\245h\157\130\aq\223\150:WI\169k\RS\149", _willProps = []}), _cleanSession = False, -// _keepAlive = 23142, _connID = "J\242", _properties = []} -TEST(Connect311QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0x3e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb4, 0x5a, 0x66, 0x0, 0x2, 0x4a, 0xf2, - 0x0, 0x4, 0x9a, 0x87, 0x40, 0x51, 0x0, 0x17, 0x3d, 0x87, 0x7f, 0x98, 0x34, 0x2e, 0xee, 0xd8, - 0xf5, 0x68, 0x9d, 0x82, 0x7, 0x71, 0xdf, 0x96, 0x3a, 0x57, 0x49, 0xa9, 0x6b, 0x1e, 0x95, 0x0, - 0xf, 0xb9, 0x1d, 0x63, 0xf6, 0xcd, 0xd2, 0x5c, 0xe9, 0xb7, 0x77, 0x4, 0xfc, 0x7c, 0x2d, 0xe0}; - - uint8_t buf[74] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9a, 0x87, 0x40, 0x51}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3d, 0x87, 0x7f, 0x98, 0x34, 0x2e, 0xee, 0xd8, 0xf5, 0x68, 0x9d, 0x82, - 0x7, 0x71, 0xdf, 0x96, 0x3a, 0x57, 0x49, 0xa9, 0x6b, 0x1e, 0x95}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 23142; - uint8_t client_id_bytes[] = {0x4a, 0xf2}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xb9, 0x1d, 0x63, 0xf6, 0xcd, 0xd2, 0x5c, 0xe9, 0xb7, 0x77, 0x4, 0xfc, 0x7c, 0x2d, 0xe0}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just -// "\240\223\219|\165/\216\169G\212Ta\158=\151\215\242\164\220\199\164\236\142\249\194\194\EMU\245\214", _password = -// Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 11621, _connID = "Y", _properties = []} -TEST(Connect311QCTest, Encode6) { - uint8_t pkt[] = {0x10, 0x2d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x2d, 0x65, 0x0, 0x1, 0x59, 0x0, - 0x1e, 0xf0, 0xdf, 0xdb, 0x7c, 0xa5, 0x2f, 0xd8, 0xa9, 0x47, 0xd4, 0x54, 0x61, 0x9e, 0x3d, 0x97, - 0xd7, 0xf2, 0xa4, 0xdc, 0xc7, 0xa4, 0xec, 0x8e, 0xf9, 0xc2, 0xc2, 0x19, 0x55, 0xf5, 0xd6}; - - uint8_t buf[57] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 11621; - uint8_t client_id_bytes[] = {0x59}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xf0, 0xdf, 0xdb, 0x7c, 0xa5, 0x2f, 0xd8, 0xa9, 0x47, 0xd4, 0x54, 0x61, 0x9e, 0x3d, 0x97, - 0xd7, 0xf2, 0xa4, 0xdc, 0xc7, 0xa4, 0xec, 0x8e, 0xf9, 0xc2, 0xc2, 0x19, 0x55, 0xf5, 0xd6}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "]\218\DC2\160G\231\&5\185\137ZQ", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 32745, _connID = "\248\163cDx\241\168\&8\140/\228\161\192\&3o\168\223", -// _properties = []} -TEST(Connect311QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0x1d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x7f, 0xe9, 0x0, 0x11, 0xf8, 0xa3, - 0x63, 0x44, 0x78, 0xf1, 0xa8, 0x38, 0x8c, 0x2f, 0xe4, 0xa1, 0xc0, 0x33, 0x6f, 0xa8, 0xdf}; - - uint8_t buf[41] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32745; - uint8_t client_id_bytes[] = {0xf8, 0xa3, 0x63, 0x44, 0x78, 0xf1, 0xa8, 0x38, 0x8c, - 0x2f, 0xe4, 0xa1, 0xc0, 0x33, 0x6f, 0xa8, 0xdf}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x5d, 0xda, 0x12, 0xa0, 0x47, 0xe7, 0x35, 0xb9, 0x89, 0x5a, 0x51}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\NUL\136\181", _password = Just -// "d%\139\252\SUB\v\232)\218\ESC\DC3\212F\DC1\238\243j\SO\251\168", _lastWill = Nothing, _cleanSession = False, -// _keepAlive = 14321, _connID = "\SOHH\187\196\DEL\173\132\&0wH\SI\210C\131\DC4", _properties = []} -TEST(Connect311QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x37, 0xf1, 0x0, 0xf, - 0x1, 0x48, 0xbb, 0xc4, 0x7f, 0xad, 0x84, 0x30, 0x77, 0x48, 0xf, 0xd2, 0x43, 0x83, - 0x14, 0x0, 0x3, 0x0, 0x88, 0xb5, 0x0, 0x14, 0x64, 0x25, 0x8b, 0xfc, 0x1a, 0xb, - 0xe8, 0x29, 0xda, 0x1b, 0x13, 0xd4, 0x46, 0x11, 0xee, 0xf3, 0x6a, 0xe, 0xfb, 0xa8}; - - uint8_t buf[66] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 14321; - uint8_t client_id_bytes[] = {0x1, 0x48, 0xbb, 0xc4, 0x7f, 0xad, 0x84, 0x30, 0x77, 0x48, 0xf, 0xd2, 0x43, 0x83, 0x14}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x0, 0x88, 0xb5}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x64, 0x25, 0x8b, 0xfc, 0x1a, 0xb, 0xe8, 0x29, 0xda, 0x1b, - 0x13, 0xd4, 0x46, 0x11, 0xee, 0xf3, 0x6a, 0xe, 0xfb, 0xa8}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\142\224!;+'mV", _password = Just -// "{h\173\&5]\vz\\P\196\181X.\"B~\207\241\156]f\195X\DC1\203u\149\151\249", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "S]\n\ETB[\ACK)\233\177\225N\218\162\EM\240p\239O", _willMsg = "\183", -// _willProps = []}), _cleanSession = False, _keepAlive = 24734, _connID = "gYE\207\225\215\192", _properties = []} -TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x60, 0x9e, 0x0, 0x7, 0x67, - 0x59, 0x45, 0xcf, 0xe1, 0xd7, 0xc0, 0x0, 0x12, 0x53, 0x5d, 0xa, 0x17, 0x5b, 0x6, 0x29, - 0xe9, 0xb1, 0xe1, 0x4e, 0xda, 0xa2, 0x19, 0xf0, 0x70, 0xef, 0x4f, 0x0, 0x1, 0xb7, 0x0, - 0x8, 0x8e, 0xe0, 0x21, 0x3b, 0x2b, 0x27, 0x6d, 0x56, 0x0, 0x1d, 0x7b, 0x68, 0xad, 0x35, - 0x5d, 0xb, 0x7a, 0x5c, 0x50, 0xc4, 0xb5, 0x58, 0x2e, 0x22, 0x42, 0x7e, 0xcf, 0xf1, 0x9c, - 0x5d, 0x66, 0xc3, 0x58, 0x11, 0xcb, 0x75, 0x95, 0x97, 0xf9}; - - uint8_t buf[95] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x53, 0x5d, 0xa, 0x17, 0x5b, 0x6, 0x29, 0xe9, 0xb1, - 0xe1, 0x4e, 0xda, 0xa2, 0x19, 0xf0, 0x70, 0xef, 0x4f}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb7}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 24734; - uint8_t client_id_bytes[] = {0x67, 0x59, 0x45, 0xcf, 0xe1, 0xd7, 0xc0}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x8e, 0xe0, 0x21, 0x3b, 0x2b, 0x27, 0x6d, 0x56}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x7b, 0x68, 0xad, 0x35, 0x5d, 0xb, 0x7a, 0x5c, 0x50, 0xc4, 0xb5, 0x58, 0x2e, 0x22, 0x42, - 0x7e, 0xcf, 0xf1, 0x9c, 0x5d, 0x66, 0xc3, 0x58, 0x11, 0xcb, 0x75, 0x95, 0x97, 0xf9}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\r7\"\154\EOT", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "\\\131\211\214\209\183\242\162", _willMsg = ")&", _willProps = []}), -// _cleanSession = False, _keepAlive = 17778, _connID = "\160\202\220\&9^\188\ENQ\223w\149\158\233", _properties = []} -TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x2d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8c, 0x45, 0x72, 0x0, 0xc, 0xa0, 0xca, - 0xdc, 0x39, 0x5e, 0xbc, 0x5, 0xdf, 0x77, 0x95, 0x9e, 0xe9, 0x0, 0x8, 0x5c, 0x83, 0xd3, 0xd6, - 0xd1, 0xb7, 0xf2, 0xa2, 0x0, 0x2, 0x29, 0x26, 0x0, 0x5, 0xd, 0x37, 0x22, 0x9a, 0x4}; - - uint8_t buf[57] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5c, 0x83, 0xd3, 0xd6, 0xd1, 0xb7, 0xf2, 0xa2}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x29, 0x26}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 17778; - uint8_t client_id_bytes[] = {0xa0, 0xca, 0xdc, 0x39, 0x5e, 0xbc, 0x5, 0xdf, 0x77, 0x95, 0x9e, 0xe9}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xd, 0x37, 0x22, 0x9a, 0x4}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\181\bX\195\NULZ\169\250\173\230E\239g\209\226\145:pJ ^\SO\192\SYN,V\138\226", -// _password = Just "b\129\SOH\222>\130\229h\251\208QM\146\255\&3 \190\166T%QC\v\RS\n\183 &\205&Em", _willProps = []}), _cleanSession = True, _keepAlive = 8661, _connID = -// "\213\183*l\161!\168\252p\153\208\254\DC1<\235", _properties = []} -TEST(Connect311QCTest, Encode17) { - uint8_t pkt[] = {0x10, 0x4c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x21, 0xd5, 0x0, 0xf, 0xd5, 0xb7, - 0x2a, 0x6c, 0xa1, 0x21, 0xa8, 0xfc, 0x70, 0x99, 0xd0, 0xfe, 0x11, 0x3c, 0xeb, 0x0, 0x1d, 0x9, - 0xde, 0x9f, 0x53, 0xa5, 0x9d, 0x2e, 0x4c, 0xbf, 0xdb, 0x1a, 0xf9, 0x1d, 0x46, 0x40, 0xeb, 0xf1, - 0x74, 0x5c, 0xd, 0x82, 0x34, 0xff, 0xd8, 0x4b, 0xcc, 0xf6, 0x5a, 0xff, 0x0, 0x10, 0x99, 0x2a, - 0x3e, 0x25, 0x51, 0x43, 0xb, 0x1e, 0xa, 0xb7, 0x20, 0x26, 0xcd, 0x26, 0x45, 0x6d}; - - uint8_t buf[88] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9, 0xde, 0x9f, 0x53, 0xa5, 0x9d, 0x2e, 0x4c, 0xbf, 0xdb, - 0x1a, 0xf9, 0x1d, 0x46, 0x40, 0xeb, 0xf1, 0x74, 0x5c, 0xd, - 0x82, 0x34, 0xff, 0xd8, 0x4b, 0xcc, 0xf6, 0x5a, 0xff}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x99, 0x2a, 0x3e, 0x25, 0x51, 0x43, 0xb, 0x1e, - 0xa, 0xb7, 0x20, 0x26, 0xcd, 0x26, 0x45, 0x6d}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 8661; - uint8_t client_id_bytes[] = {0xd5, 0xb7, 0x2a, 0x6c, 0xa1, 0x21, 0xa8, 0xfc, - 0x70, 0x99, 0xd0, 0xfe, 0x11, 0x3c, 0xeb}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS1, _willTopic = -// "\\\255\246\RS<\212+\220\248\199\236\132\185\US]D\137\186\&5\193\r\n\237\181\231\246\&6\238\211\221", _willMsg = -// "#%`lDh\222\147\201\155e\153\136\131 [9l\GS\225\NUL^", _willProps = []}), _cleanSession = True, _keepAlive = 1275, -// _connID = "^\232\215\163\208\190\139\233T\239\SI\139\vz6}", _properties = []} -TEST(Connect311QCTest, Encode18) { - uint8_t pkt[] = {0x10, 0x54, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2e, 0x4, 0xfb, 0x0, 0x10, 0x5e, - 0xe8, 0xd7, 0xa3, 0xd0, 0xbe, 0x8b, 0xe9, 0x54, 0xef, 0xf, 0x8b, 0xb, 0x7a, 0x36, 0x7d, - 0x0, 0x1e, 0x5c, 0xff, 0xf6, 0x1e, 0x3c, 0xd4, 0x2b, 0xdc, 0xf8, 0xc7, 0xec, 0x84, 0xb9, - 0x1f, 0x5d, 0x44, 0x89, 0xba, 0x35, 0xc1, 0xd, 0xa, 0xed, 0xb5, 0xe7, 0xf6, 0x36, 0xee, - 0xd3, 0xdd, 0x0, 0x16, 0x23, 0x25, 0x60, 0x6c, 0x44, 0x68, 0xde, 0x93, 0xc9, 0x9b, 0x65, - 0x99, 0x88, 0x83, 0x20, 0x5b, 0x39, 0x6c, 0x1d, 0xe1, 0x0, 0x5e}; - - uint8_t buf[96] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5c, 0xff, 0xf6, 0x1e, 0x3c, 0xd4, 0x2b, 0xdc, 0xf8, 0xc7, - 0xec, 0x84, 0xb9, 0x1f, 0x5d, 0x44, 0x89, 0xba, 0x35, 0xc1, - 0xd, 0xa, 0xed, 0xb5, 0xe7, 0xf6, 0x36, 0xee, 0xd3, 0xdd}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x23, 0x25, 0x60, 0x6c, 0x44, 0x68, 0xde, 0x93, 0xc9, 0x9b, 0x65, - 0x99, 0x88, 0x83, 0x20, 0x5b, 0x39, 0x6c, 0x1d, 0xe1, 0x0, 0x5e}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1275; - uint8_t client_id_bytes[] = {0x5e, 0xe8, 0xd7, 0xa3, 0xd0, 0xbe, 0x8b, 0xe9, - 0x54, 0xef, 0xf, 0x8b, 0xb, 0x7a, 0x36, 0x7d}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just -// "\212\226\154\ACK\136\237\149\159E\153\b\253\235\250\216\160\201\EM3P\152^\232", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS0, _willTopic = "\128\194\131j\171v\201pWuH\170{=\145O\211\DC3'", _willMsg = -// "\190\132\174 \"\169\179\253\204\&5T\243\160\140^\179\204\131\218H\"6\191lW\184\171d\161K", _willProps = []}), -// _cleanSession = True, _keepAlive = 30712, _connID = "6", _properties = []} -TEST(Connect311QCTest, Encode19) { - uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x77, 0xf8, 0x0, 0x1, - 0x36, 0x0, 0x13, 0x80, 0xc2, 0x83, 0x6a, 0xab, 0x76, 0xc9, 0x70, 0x57, 0x75, 0x48, - 0xaa, 0x7b, 0x3d, 0x91, 0x4f, 0xd3, 0x13, 0x27, 0x0, 0x1e, 0xbe, 0x84, 0xae, 0x20, - 0x22, 0xa9, 0xb3, 0xfd, 0xcc, 0x35, 0x54, 0xf3, 0xa0, 0x8c, 0x5e, 0xb3, 0xcc, 0x83, - 0xda, 0x48, 0x22, 0x36, 0xbf, 0x6c, 0x57, 0xb8, 0xab, 0x64, 0xa1, 0x4b}; - - uint8_t buf[78] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x80, 0xc2, 0x83, 0x6a, 0xab, 0x76, 0xc9, 0x70, 0x57, 0x75, - 0x48, 0xaa, 0x7b, 0x3d, 0x91, 0x4f, 0xd3, 0x13, 0x27}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbe, 0x84, 0xae, 0x20, 0x22, 0xa9, 0xb3, 0xfd, 0xcc, 0x35, - 0x54, 0xf3, 0xa0, 0x8c, 0x5e, 0xb3, 0xcc, 0x83, 0xda, 0x48, - 0x22, 0x36, 0xbf, 0x6c, 0x57, 0xb8, 0xab, 0x64, 0xa1, 0x4b}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 30712; - uint8_t client_id_bytes[] = {0x36}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xd4, 0xe2, 0x9a, 0x6, 0x88, 0xed, 0x95, 0x9f, 0x45, 0x99, 0x8, 0xfd, - 0xeb, 0xfa, 0xd8, 0xa0, 0xc9, 0x19, 0x33, 0x50, 0x98, 0x5e, 0xe8}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "J\RSd\"\EOT.m'\DLE%\174\130S\229\172\198\176\&1\140&\228\RS\149\248\232\234", -// _password = Just "\216\183u\FS\184\187\239\148\140X\251\143\153s\176\218\&3s\168", _lastWill = Nothing, _cleanSession -// = True, _keepAlive = 24465, _connID = "\145\244\189\239z\131f", _properties = []} -TEST(Connect311QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x5f, 0x91, 0x0, 0x7, - 0x91, 0xf4, 0xbd, 0xef, 0x7a, 0x83, 0x66, 0x0, 0x1a, 0x4a, 0x1e, 0x64, 0x22, 0x4, - 0x2e, 0x6d, 0x27, 0x10, 0x25, 0xae, 0x82, 0x53, 0xe5, 0xac, 0xc6, 0xb0, 0x31, 0x8c, - 0x26, 0xe4, 0x1e, 0x95, 0xf8, 0xe8, 0xea, 0x0, 0x13, 0xd8, 0xb7, 0x75, 0x1c, 0xb8, - 0xbb, 0xef, 0x94, 0x8c, 0x58, 0xfb, 0x8f, 0x99, 0x73, 0xb0, 0xda, 0x33, 0x73, 0xa8}; - - uint8_t buf[80] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 24465; - uint8_t client_id_bytes[] = {0x91, 0xf4, 0xbd, 0xef, 0x7a, 0x83, 0x66}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x4a, 0x1e, 0x64, 0x22, 0x4, 0x2e, 0x6d, 0x27, 0x10, 0x25, 0xae, 0x82, 0x53, - 0xe5, 0xac, 0xc6, 0xb0, 0x31, 0x8c, 0x26, 0xe4, 0x1e, 0x95, 0xf8, 0xe8, 0xea}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd8, 0xb7, 0x75, 0x1c, 0xb8, 0xbb, 0xef, 0x94, 0x8c, 0x58, - 0xfb, 0x8f, 0x99, 0x73, 0xb0, 0xda, 0x33, 0x73, 0xa8}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\168\152\190:\152\"\217OGs\207_\233\129\248**\131N\190\167q;\253\ETB", _password = -// Just "hq\130\190\144\NUL\227\253\208\215\224\167\FS\203\EOT(\169\158\166\134)g\184\233\145\138*u", _lastWill = -// Nothing, _cleanSession = True, _keepAlive = 147, _connID = "\198@\194\222\146s", _properties = []} -TEST(Connect311QCTest, Encode21) { - uint8_t pkt[] = {0x10, 0x4b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x0, 0x93, 0x0, 0x6, 0xc6, 0x40, - 0xc2, 0xde, 0x92, 0x73, 0x0, 0x19, 0xa8, 0x98, 0xbe, 0x3a, 0x98, 0x22, 0xd9, 0x4f, 0x47, 0x73, - 0xcf, 0x5f, 0xe9, 0x81, 0xf8, 0x2a, 0x2a, 0x83, 0x4e, 0xbe, 0xa7, 0x71, 0x3b, 0xfd, 0x17, 0x0, - 0x1c, 0x68, 0x71, 0x82, 0xbe, 0x90, 0x0, 0xe3, 0xfd, 0xd0, 0xd7, 0xe0, 0xa7, 0x1c, 0xcb, 0x4, - 0x28, 0xa9, 0x9e, 0xa6, 0x86, 0x29, 0x67, 0xb8, 0xe9, 0x91, 0x8a, 0x2a, 0x75}; - - uint8_t buf[87] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 147; - uint8_t client_id_bytes[] = {0xc6, 0x40, 0xc2, 0xde, 0x92, 0x73}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa8, 0x98, 0xbe, 0x3a, 0x98, 0x22, 0xd9, 0x4f, 0x47, 0x73, 0xcf, 0x5f, 0xe9, - 0x81, 0xf8, 0x2a, 0x2a, 0x83, 0x4e, 0xbe, 0xa7, 0x71, 0x3b, 0xfd, 0x17}; - lwmqtt_string_t username = {25, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x68, 0x71, 0x82, 0xbe, 0x90, 0x0, 0xe3, 0xfd, 0xd0, 0xd7, 0xe0, 0xa7, 0x1c, 0xcb, - 0x4, 0x28, 0xa9, 0x9e, 0xa6, 0x86, 0x29, 0x67, 0xb8, 0xe9, 0x91, 0x8a, 0x2a, 0x75}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "9?\213\ESC\211\DLE", _lastWill = Nothing, _cleanSession = -// False, _keepAlive = 13768, _connID = -// "x\172\tI\199\244\238\243\130\&9.\206\172\ETB\SYN\164\GS\EM\128\142S\217\184\NAK]Q\209;\SUBN", _properties = []} -TEST(Connect311QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0x2a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x35, 0xc8, 0x0, 0x1e, 0x78, - 0xac, 0x9, 0x49, 0xc7, 0xf4, 0xee, 0xf3, 0x82, 0x39, 0x2e, 0xce, 0xac, 0x17, 0x16, 0xa4, - 0x1d, 0x19, 0x80, 0x8e, 0x53, 0xd9, 0xb8, 0x15, 0x5d, 0x51, 0xd1, 0x3b, 0x1a, 0x4e}; - - uint8_t buf[54] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 13768; - uint8_t client_id_bytes[] = {0x78, 0xac, 0x9, 0x49, 0xc7, 0xf4, 0xee, 0xf3, 0x82, 0x39, - 0x2e, 0xce, 0xac, 0x17, 0x16, 0xa4, 0x1d, 0x19, 0x80, 0x8e, - 0x53, 0xd9, 0xb8, 0x15, 0x5d, 0x51, 0xd1, 0x3b, 0x1a, 0x4e}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x39, 0x3f, 0xd5, 0x1b, 0xd3, 0x10}; - lwmqtt_string_t password = {6, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just -// ";\152\206s\182\199\197\227\135\ACK\251\"Z\DLE\203\162ab\203\169\203\208\172\230\&6\EOT8eS`", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "", _willMsg = "\157\160\156\193A", _willProps = []}), -// _cleanSession = False, _keepAlive = 23561, _connID = "\228\240", _properties = []} -TEST(Connect311QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0x17, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2c, 0x5c, 0x9, 0x0, - 0x2, 0xe4, 0xf0, 0x0, 0x0, 0x0, 0x5, 0x9d, 0xa0, 0x9c, 0xc1, 0x41}; - - uint8_t buf[35] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x9d, 0xa0, 0x9c, 0xc1, 0x41}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 23561; - uint8_t client_id_bytes[] = {0xe4, 0xf0}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x3b, 0x98, 0xce, 0x73, 0xb6, 0xc7, 0xc5, 0xe3, 0x87, 0x6, 0xfb, 0x22, 0x5a, 0x10, 0xcb, - 0xa2, 0x61, 0x62, 0xcb, 0xa9, 0xcb, 0xd0, 0xac, 0xe6, 0x36, 0x4, 0x38, 0x65, 0x53, 0x60}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\254\245:\136]\202n\222\DC3n\218\215\210", _password = Just -// "6\234}\152\181\DC2\ACKM\245:\DC2\ENQ\249\205q+", _lastWill = Nothing, _cleanSession = True, _keepAlive = 2628, -// _connID = "\131/w\176\163", _properties = []} -TEST(Connect311QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x32, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0xa, 0x44, 0x0, - 0x5, 0x83, 0x2f, 0x77, 0xb0, 0xa3, 0x0, 0xd, 0xfe, 0xf5, 0x3a, 0x88, 0x5d, - 0xca, 0x6e, 0xde, 0x13, 0x6e, 0xda, 0xd7, 0xd2, 0x0, 0x10, 0x36, 0xea, 0x7d, - 0x98, 0xb5, 0x12, 0x6, 0x4d, 0xf5, 0x3a, 0x12, 0x5, 0xf9, 0xcd, 0x71, 0x2b}; - - uint8_t buf[62] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 2628; - uint8_t client_id_bytes[] = {0x83, 0x2f, 0x77, 0xb0, 0xa3}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xfe, 0xf5, 0x3a, 0x88, 0x5d, 0xca, 0x6e, 0xde, 0x13, 0x6e, 0xda, 0xd7, 0xd2}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x36, 0xea, 0x7d, 0x98, 0xb5, 0x12, 0x6, 0x4d, - 0xf5, 0x3a, 0x12, 0x5, 0xf9, 0xcd, 0x71, 0x2b}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\155\217\NUL\219N>c\218$.jM\158\CAN\213\ENQA;\185\148\147T\180\244", _password = -// Just "\167\228\243\219\223\142\140\SUB-\206\&0\STXF\ACK\146\186V\DC1\167&Nk\SOH8\132", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 23808, _connID = -// "\240\217\175\155|O\226\&49\201\243L\176\239f\233\177`\130\154\221", _properties = []} -TEST(Connect311QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0x56, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x5d, 0x0, 0x0, 0x15, 0xf0, - 0xd9, 0xaf, 0x9b, 0x7c, 0x4f, 0xe2, 0x34, 0x39, 0xc9, 0xf3, 0x4c, 0xb0, 0xef, 0x66, 0xe9, - 0xb1, 0x60, 0x82, 0x9a, 0xdd, 0x0, 0x18, 0x9b, 0xd9, 0x0, 0xdb, 0x4e, 0x3e, 0x63, 0xda, - 0x24, 0x2e, 0x6a, 0x4d, 0x9e, 0x18, 0xd5, 0x5, 0x41, 0x3b, 0xb9, 0x94, 0x93, 0x54, 0xb4, - 0xf4, 0x0, 0x19, 0xa7, 0xe4, 0xf3, 0xdb, 0xdf, 0x8e, 0x8c, 0x1a, 0x2d, 0xce, 0x30, 0x2, - 0x46, 0x6, 0x92, 0xba, 0x56, 0x11, 0xa7, 0x26, 0x4e, 0x6b, 0x1, 0x38, 0x84}; - - uint8_t buf[98] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 23808; - uint8_t client_id_bytes[] = {0xf0, 0xd9, 0xaf, 0x9b, 0x7c, 0x4f, 0xe2, 0x34, 0x39, 0xc9, 0xf3, - 0x4c, 0xb0, 0xef, 0x66, 0xe9, 0xb1, 0x60, 0x82, 0x9a, 0xdd}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x9b, 0xd9, 0x0, 0xdb, 0x4e, 0x3e, 0x63, 0xda, 0x24, 0x2e, 0x6a, 0x4d, - 0x9e, 0x18, 0xd5, 0x5, 0x41, 0x3b, 0xb9, 0x94, 0x93, 0x54, 0xb4, 0xf4}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xa7, 0xe4, 0xf3, 0xdb, 0xdf, 0x8e, 0x8c, 0x1a, 0x2d, 0xce, 0x30, 0x2, 0x46, - 0x6, 0x92, 0xba, 0x56, 0x11, 0xa7, 0x26, 0x4e, 0x6b, 0x1, 0x38, 0x84}; - lwmqtt_string_t password = {25, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\147\ENQI\173\FS\139y\171U\167\&2\200\241\231_S\207A\193.'\DC3-\t", _password = -// Just "\224M\229\196\155\f", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "4g\167(\247", _willMsg = "e\SYNy\187{\214", _willProps = []}), _cleanSession = False, _keepAlive = 32591, _connID = -// "5\226G\145\159\238\225\NAK\DC2\SUB\RSc\ENQ\ACKr\238+\128\191\218\DC2\230\143X", _properties = []} -TEST(Connect311QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0x55, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x7f, 0x4f, 0x0, 0x18, 0x35, - 0xe2, 0x47, 0x91, 0x9f, 0xee, 0xe1, 0x15, 0x12, 0x1a, 0x1e, 0x63, 0x5, 0x6, 0x72, 0xee, - 0x2b, 0x80, 0xbf, 0xda, 0x12, 0xe6, 0x8f, 0x58, 0x0, 0x5, 0x34, 0x67, 0xa7, 0x28, 0xf7, - 0x0, 0x6, 0x65, 0x16, 0x79, 0xbb, 0x7b, 0xd6, 0x0, 0x18, 0x93, 0x5, 0x49, 0xad, 0x1c, - 0x8b, 0x79, 0xab, 0x55, 0xa7, 0x32, 0xc8, 0xf1, 0xe7, 0x5f, 0x53, 0xcf, 0x41, 0xc1, 0x2e, - 0x27, 0x13, 0x2d, 0x9, 0x0, 0x6, 0xe0, 0x4d, 0xe5, 0xc4, 0x9b, 0xc}; - - uint8_t buf[97] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x34, 0x67, 0xa7, 0x28, 0xf7}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x65, 0x16, 0x79, 0xbb, 0x7b, 0xd6}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32591; - uint8_t client_id_bytes[] = {0x35, 0xe2, 0x47, 0x91, 0x9f, 0xee, 0xe1, 0x15, 0x12, 0x1a, 0x1e, 0x63, - 0x5, 0x6, 0x72, 0xee, 0x2b, 0x80, 0xbf, 0xda, 0x12, 0xe6, 0x8f, 0x58}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x93, 0x5, 0x49, 0xad, 0x1c, 0x8b, 0x79, 0xab, 0x55, 0xa7, 0x32, 0xc8, - 0xf1, 0xe7, 0x5f, 0x53, 0xcf, 0x41, 0xc1, 0x2e, 0x27, 0x13, 0x2d, 0x9}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe0, 0x4d, 0xe5, 0xc4, 0x9b, 0xc}; - lwmqtt_string_t password = {6, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\135n\ACK\DEL\252\NAKj", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS0, _willTopic = "\227\242\SOH2\209\GS\241P\197$1", _willMsg = -// "\203\232{\205\152\239\158\DEL\251r\EOTy\\e\148\159p\ETX8Kg", _willProps = []}), _cleanSession = True, _keepAlive = -// 27175, _connID = "\CAN\SYN\222\163\&6J<\227\240.\181\138\158\223b_\ETB\234\SYN\232\223", _properties = []} -TEST(Connect311QCTest, Encode27) { - uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x86, 0x6a, 0x27, 0x0, 0x15, 0x18, 0x16, - 0xde, 0xa3, 0x36, 0x4a, 0x3c, 0xe3, 0xf0, 0x2e, 0xb5, 0x8a, 0x9e, 0xdf, 0x62, 0x5f, 0x17, 0xea, - 0x16, 0xe8, 0xdf, 0x0, 0xb, 0xe3, 0xf2, 0x1, 0x32, 0xd1, 0x1d, 0xf1, 0x50, 0xc5, 0x24, 0x31, - 0x0, 0x15, 0xcb, 0xe8, 0x7b, 0xcd, 0x98, 0xef, 0x9e, 0x7f, 0xfb, 0x72, 0x4, 0x79, 0x5c, 0x65, - 0x94, 0x9f, 0x70, 0x3, 0x38, 0x4b, 0x67, 0x0, 0x7, 0x87, 0x6e, 0x6, 0x7f, 0xfc, 0x15, 0x6a}; - - uint8_t buf[90] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe3, 0xf2, 0x1, 0x32, 0xd1, 0x1d, 0xf1, 0x50, 0xc5, 0x24, 0x31}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xcb, 0xe8, 0x7b, 0xcd, 0x98, 0xef, 0x9e, 0x7f, 0xfb, 0x72, 0x4, - 0x79, 0x5c, 0x65, 0x94, 0x9f, 0x70, 0x3, 0x38, 0x4b, 0x67}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 27175; - uint8_t client_id_bytes[] = {0x18, 0x16, 0xde, 0xa3, 0x36, 0x4a, 0x3c, 0xe3, 0xf0, 0x2e, 0xb5, - 0x8a, 0x9e, 0xdf, 0x62, 0x5f, 0x17, 0xea, 0x16, 0xe8, 0xdf}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x87, 0x6e, 0x6, 0x7f, 0xfc, 0x15, 0x6a}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\206\232\167N\216a\154\199\224\218QM\240^\233", _password = Just -// "\192/:\231\250i\229m\149\209\226\189\247\RS", _lastWill = Nothing, _cleanSession = True, _keepAlive = 19539, _connID -// = "\243\a_w\224\230\220\172\186\STX\157\251\SUB\221\132\ACK1\230\148", _properties = []} -TEST(Connect311QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x4c, 0x53, 0x0, 0x13, 0xf3, 0x7, 0x5f, - 0x77, 0xe0, 0xe6, 0xdc, 0xac, 0xba, 0x2, 0x9d, 0xfb, 0x1a, 0xdd, 0x84, 0x6, 0x31, 0xe6, 0x94, 0x0, - 0xf, 0xce, 0xe8, 0xa7, 0x4e, 0xd8, 0x61, 0x9a, 0xc7, 0xe0, 0xda, 0x51, 0x4d, 0xf0, 0x5e, 0xe9, 0x0, - 0xe, 0xc0, 0x2f, 0x3a, 0xe7, 0xfa, 0x69, 0xe5, 0x6d, 0x95, 0xd1, 0xe2, 0xbd, 0xf7, 0x1e}; - - uint8_t buf[76] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 19539; - uint8_t client_id_bytes[] = {0xf3, 0x7, 0x5f, 0x77, 0xe0, 0xe6, 0xdc, 0xac, 0xba, 0x2, - 0x9d, 0xfb, 0x1a, 0xdd, 0x84, 0x6, 0x31, 0xe6, 0x94}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xce, 0xe8, 0xa7, 0x4e, 0xd8, 0x61, 0x9a, 0xc7, 0xe0, 0xda, 0x51, 0x4d, 0xf0, 0x5e, 0xe9}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xc0, 0x2f, 0x3a, 0xe7, 0xfa, 0x69, 0xe5, 0x6d, 0x95, 0xd1, 0xe2, 0xbd, 0xf7, 0x1e}; - lwmqtt_string_t password = {14, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "m\215\134\182\200\&4", _password = Just -// ">\213T\DC4\232\214\180e\168@Q\130\234\201\227#\248\153`\161\244\138\218\201/xr\DEL", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "k\208\247&\US\224\153\252\216", _willMsg = "\v\157\214H\186", -// _willProps = []}), _cleanSession = False, _keepAlive = 24596, _connID = "\198\140\ETX", _properties = []} -TEST(Connect311QCTest, Encode29) { - uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x60, 0x14, 0x0, 0x3, 0xc6, - 0x8c, 0x3, 0x0, 0x9, 0x6b, 0xd0, 0xf7, 0x26, 0x1f, 0xe0, 0x99, 0xfc, 0xd8, 0x0, 0x5, - 0xb, 0x9d, 0xd6, 0x48, 0xba, 0x0, 0x6, 0x6d, 0xd7, 0x86, 0xb6, 0xc8, 0x34, 0x0, 0x1c, - 0x3e, 0xd5, 0x54, 0x14, 0xe8, 0xd6, 0xb4, 0x65, 0xa8, 0x40, 0x51, 0x82, 0xea, 0xc9, 0xe3, - 0x23, 0xf8, 0x99, 0x60, 0xa1, 0xf4, 0x8a, 0xda, 0xc9, 0x2f, 0x78, 0x72, 0x7f}; - - uint8_t buf[83] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6b, 0xd0, 0xf7, 0x26, 0x1f, 0xe0, 0x99, 0xfc, 0xd8}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb, 0x9d, 0xd6, 0x48, 0xba}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 24596; - uint8_t client_id_bytes[] = {0xc6, 0x8c, 0x3}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x6d, 0xd7, 0x86, 0xb6, 0xc8, 0x34}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x3e, 0xd5, 0x54, 0x14, 0xe8, 0xd6, 0xb4, 0x65, 0xa8, 0x40, 0x51, 0x82, 0xea, 0xc9, - 0xe3, 0x23, 0xf8, 0x99, 0x60, 0xa1, 0xf4, 0x8a, 0xda, 0xc9, 0x2f, 0x78, 0x72, 0x7f}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "e\ESCs", _password = Just "\183mF\183H", _lastWill = Nothing, _cleanSession = True, -// _keepAlive = 16377, _connID = "Ky\SOj\t\188i\157\233_I\201\187\143\DELY\175_\140}\230\&5\206\SUBqb+P0", _properties = -// []} -TEST(Connect311QCTest, Encode30) { - uint8_t pkt[] = {0x10, 0x35, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x3f, 0xf9, 0x0, 0x1d, - 0x4b, 0x79, 0xe, 0x6a, 0x9, 0xbc, 0x69, 0x9d, 0xe9, 0x5f, 0x49, 0xc9, 0xbb, 0x8f, - 0x7f, 0x59, 0xaf, 0x5f, 0x8c, 0x7d, 0xe6, 0x35, 0xce, 0x1a, 0x71, 0x62, 0x2b, 0x50, - 0x30, 0x0, 0x3, 0x65, 0x1b, 0x73, 0x0, 0x5, 0xb7, 0x6d, 0x46, 0xb7, 0x48}; - - uint8_t buf[65] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 16377; - uint8_t client_id_bytes[] = {0x4b, 0x79, 0xe, 0x6a, 0x9, 0xbc, 0x69, 0x9d, 0xe9, 0x5f, 0x49, 0xc9, 0xbb, 0x8f, 0x7f, - 0x59, 0xaf, 0x5f, 0x8c, 0x7d, 0xe6, 0x35, 0xce, 0x1a, 0x71, 0x62, 0x2b, 0x50, 0x30}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x65, 0x1b, 0x73}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xb7, 0x6d, 0x46, 0xb7, 0x48}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\238zO", _password = Just -// "\183xW\149\225\255\ACK\160\227\147\208\185\174P\148l\216\&6B\183J\152", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = "\192G3\202\231\255\195\177\168\239\233\234\161\DC3\186Q\230\"\t\146\ACK", -// _willMsg = "\GS\230a\199\205<}", _willProps = []}), _cleanSession = True, _keepAlive = 18523, _connID = -// "\232\204\f\212 \185\241-\229\183\230\160\202i\225\DC1_2\224\152\198v[\219md\170", _properties = []} -TEST(Connect311QCTest, Encode31) { - uint8_t pkt[] = {0x10, 0x64, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x48, 0x5b, 0x0, 0x1b, 0xe8, - 0xcc, 0xc, 0xd4, 0x20, 0xb9, 0xf1, 0x2d, 0xe5, 0xb7, 0xe6, 0xa0, 0xca, 0x69, 0xe1, 0x11, - 0x5f, 0x32, 0xe0, 0x98, 0xc6, 0x76, 0x5b, 0xdb, 0x6d, 0x64, 0xaa, 0x0, 0x15, 0xc0, 0x47, - 0x33, 0xca, 0xe7, 0xff, 0xc3, 0xb1, 0xa8, 0xef, 0xe9, 0xea, 0xa1, 0x13, 0xba, 0x51, 0xe6, - 0x22, 0x9, 0x92, 0x6, 0x0, 0x7, 0x1d, 0xe6, 0x61, 0xc7, 0xcd, 0x3c, 0x7d, 0x0, 0x3, - 0xee, 0x7a, 0x4f, 0x0, 0x16, 0xb7, 0x78, 0x57, 0x95, 0xe1, 0xff, 0x6, 0xa0, 0xe3, 0x93, - 0xd0, 0xb9, 0xae, 0x50, 0x94, 0x6c, 0xd8, 0x36, 0x42, 0xb7, 0x4a, 0x98}; - - uint8_t buf[112] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc0, 0x47, 0x33, 0xca, 0xe7, 0xff, 0xc3, 0xb1, 0xa8, 0xef, 0xe9, - 0xea, 0xa1, 0x13, 0xba, 0x51, 0xe6, 0x22, 0x9, 0x92, 0x6}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1d, 0xe6, 0x61, 0xc7, 0xcd, 0x3c, 0x7d}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 18523; - uint8_t client_id_bytes[] = {0xe8, 0xcc, 0xc, 0xd4, 0x20, 0xb9, 0xf1, 0x2d, 0xe5, 0xb7, 0xe6, 0xa0, 0xca, 0x69, - 0xe1, 0x11, 0x5f, 0x32, 0xe0, 0x98, 0xc6, 0x76, 0x5b, 0xdb, 0x6d, 0x64, 0xaa}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xee, 0x7a, 0x4f}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xb7, 0x78, 0x57, 0x95, 0xe1, 0xff, 0x6, 0xa0, 0xe3, 0x93, 0xd0, - 0xb9, 0xae, 0x50, 0x94, 0x6c, 0xd8, 0x36, 0x42, 0xb7, 0x4a, 0x98}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "Ae\200\161\175\235\ETX\154", _password = Just -// "\ESCm\NULa\222\180jD\243e\212[\t7\DC1\143\247~\DC4=\196NJ\FS<\201\150\171\151", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\FS;\251\141\v\199\239\NUL\196T{\DC3x?\154\217\156_", _willMsg = -// "_'9\US\219\b\147\&0\133+-\148\&7G\249\172\205[\147\208\DC3\ESCC", _willProps = []}), _cleanSession = False, -// _keepAlive = 11629, _connID = "\\X\222", _properties = []} -TEST(Connect311QCTest, Encode32) { - uint8_t pkt[] = {0x10, 0x65, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x2d, 0x6d, 0x0, 0x3, 0x5c, - 0x58, 0xde, 0x0, 0x12, 0x1c, 0x3b, 0xfb, 0x8d, 0xb, 0xc7, 0xef, 0x0, 0xc4, 0x54, 0x7b, - 0x13, 0x78, 0x3f, 0x9a, 0xd9, 0x9c, 0x5f, 0x0, 0x17, 0x5f, 0x27, 0x39, 0x1f, 0xdb, 0x8, - 0x93, 0x30, 0x85, 0x2b, 0x2d, 0x94, 0x37, 0x47, 0xf9, 0xac, 0xcd, 0x5b, 0x93, 0xd0, 0x13, - 0x1b, 0x43, 0x0, 0x8, 0x41, 0x65, 0xc8, 0xa1, 0xaf, 0xeb, 0x3, 0x9a, 0x0, 0x1d, 0x1b, - 0x6d, 0x0, 0x61, 0xde, 0xb4, 0x6a, 0x44, 0xf3, 0x65, 0xd4, 0x5b, 0x9, 0x37, 0x11, 0x8f, - 0xf7, 0x7e, 0x14, 0x3d, 0xc4, 0x4e, 0x4a, 0x1c, 0x3c, 0xc9, 0x96, 0xab, 0x97}; - - uint8_t buf[113] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1c, 0x3b, 0xfb, 0x8d, 0xb, 0xc7, 0xef, 0x0, 0xc4, - 0x54, 0x7b, 0x13, 0x78, 0x3f, 0x9a, 0xd9, 0x9c, 0x5f}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5f, 0x27, 0x39, 0x1f, 0xdb, 0x8, 0x93, 0x30, 0x85, 0x2b, 0x2d, 0x94, - 0x37, 0x47, 0xf9, 0xac, 0xcd, 0x5b, 0x93, 0xd0, 0x13, 0x1b, 0x43}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 11629; - uint8_t client_id_bytes[] = {0x5c, 0x58, 0xde}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x41, 0x65, 0xc8, 0xa1, 0xaf, 0xeb, 0x3, 0x9a}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x1b, 0x6d, 0x0, 0x61, 0xde, 0xb4, 0x6a, 0x44, 0xf3, 0x65, 0xd4, 0x5b, 0x9, 0x37, 0x11, - 0x8f, 0xf7, 0x7e, 0x14, 0x3d, 0xc4, 0x4e, 0x4a, 0x1c, 0x3c, 0xc9, 0x96, 0xab, 0x97}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\150\147\177\160\218r%'C\139\159\&6\178", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\158/9\141", _willMsg = -// "\189\DC4a\NUL\243\231@W\178\194\&7\212\\\150W\244\244\226Y=\164\138\228\154qi\129(\SOH}", _willProps = []}), -// _cleanSession = True, _keepAlive = 6008, _connID = "3\252\rE\195\SYNO^\160\182\243\US\166\254\183 -// \NAK\SUB\159\173\196\\\150\179D\245", _properties = []} -TEST(Connect311QCTest, Encode33) { - uint8_t pkt[] = {0x10, 0x4c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x17, 0x78, 0x0, 0x1a, 0x33, 0xfc, - 0xd, 0x45, 0xc3, 0x16, 0x4f, 0x5e, 0xa0, 0xb6, 0xf3, 0x1f, 0xa6, 0xfe, 0xb7, 0x20, 0x15, 0x1a, - 0x9f, 0xad, 0xc4, 0x5c, 0x96, 0xb3, 0x44, 0xf5, 0x0, 0x4, 0x9e, 0x2f, 0x39, 0x8d, 0x0, 0x1e, - 0xbd, 0x14, 0x61, 0x0, 0xf3, 0xe7, 0x40, 0x57, 0xb2, 0xc2, 0x37, 0xd4, 0x5c, 0x96, 0x57, 0xf4, - 0xf4, 0xe2, 0x59, 0x3d, 0xa4, 0x8a, 0xe4, 0x9a, 0x71, 0x69, 0x81, 0x28, 0x1, 0x7d}; - - uint8_t buf[88] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9e, 0x2f, 0x39, 0x8d}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbd, 0x14, 0x61, 0x0, 0xf3, 0xe7, 0x40, 0x57, 0xb2, 0xc2, - 0x37, 0xd4, 0x5c, 0x96, 0x57, 0xf4, 0xf4, 0xe2, 0x59, 0x3d, - 0xa4, 0x8a, 0xe4, 0x9a, 0x71, 0x69, 0x81, 0x28, 0x1, 0x7d}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 6008; - uint8_t client_id_bytes[] = {0x33, 0xfc, 0xd, 0x45, 0xc3, 0x16, 0x4f, 0x5e, 0xa0, 0xb6, 0xf3, 0x1f, 0xa6, - 0xfe, 0xb7, 0x20, 0x15, 0x1a, 0x9f, 0xad, 0xc4, 0x5c, 0x96, 0xb3, 0x44, 0xf5}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x96, 0x93, 0xb1, 0xa0, 0xda, 0x72, 0x25, 0x27, 0x43, 0x8b, 0x9f, 0x36, 0xb2}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "Y\v>5Bm\227", _password = Just "\138\203", _lastWill = Just (LastWill {_willRetain -// = False, _willQoS = QoS2, _willTopic = "\206v\171\156\146%.\249$W", _willMsg = "\bH\DC4H", _willProps = []}), -// _cleanSession = True, _keepAlive = 23415, _connID = -// "\204wCr\148\250tb\RS\139\204\142\r\206\180\231\DC26Cv\254+\STX\ETX\250\t", _properties = []} -TEST(Connect311QCTest, Encode34) { - uint8_t pkt[] = {0x10, 0x45, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x5b, 0x77, 0x0, 0x1a, 0xcc, - 0x77, 0x43, 0x72, 0x94, 0xfa, 0x74, 0x62, 0x1e, 0x8b, 0xcc, 0x8e, 0xd, 0xce, 0xb4, 0xe7, - 0x12, 0x36, 0x43, 0x76, 0xfe, 0x2b, 0x2, 0x3, 0xfa, 0x9, 0x0, 0xa, 0xce, 0x76, 0xab, - 0x9c, 0x92, 0x25, 0x2e, 0xf9, 0x24, 0x57, 0x0, 0x4, 0x8, 0x48, 0x14, 0x48, 0x0, 0x7, - 0x59, 0xb, 0x3e, 0x35, 0x42, 0x6d, 0xe3, 0x0, 0x2, 0x8a, 0xcb}; - - uint8_t buf[81] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xce, 0x76, 0xab, 0x9c, 0x92, 0x25, 0x2e, 0xf9, 0x24, 0x57}; - lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x8, 0x48, 0x14, 0x48}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 23415; - uint8_t client_id_bytes[] = {0xcc, 0x77, 0x43, 0x72, 0x94, 0xfa, 0x74, 0x62, 0x1e, 0x8b, 0xcc, 0x8e, 0xd, - 0xce, 0xb4, 0xe7, 0x12, 0x36, 0x43, 0x76, 0xfe, 0x2b, 0x2, 0x3, 0xfa, 0x9}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x59, 0xb, 0x3e, 0x35, 0x42, 0x6d, 0xe3}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x8a, 0xcb}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "]\153\135\145US\141\240H\229\241g\ETX", _willMsg = "S\147\227\222\204\171\172K", _willProps = -// []}), _cleanSession = True, _keepAlive = 12605, _connID = "\213?\SO\227\212\225\234\193\164'\SYN0,6\152", _properties -// = []} -TEST(Connect311QCTest, Encode35) { - uint8_t pkt[] = {0x10, 0x34, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x31, 0x3d, 0x0, 0xf, - 0xd5, 0x3f, 0xe, 0xe3, 0xd4, 0xe1, 0xea, 0xc1, 0xa4, 0x27, 0x16, 0x30, 0x2c, 0x36, - 0x98, 0x0, 0xd, 0x5d, 0x99, 0x87, 0x91, 0x55, 0x53, 0x8d, 0xf0, 0x48, 0xe5, 0xf1, - 0x67, 0x3, 0x0, 0x8, 0x53, 0x93, 0xe3, 0xde, 0xcc, 0xab, 0xac, 0x4b}; - - uint8_t buf[64] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5d, 0x99, 0x87, 0x91, 0x55, 0x53, 0x8d, 0xf0, 0x48, 0xe5, 0xf1, 0x67, 0x3}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x53, 0x93, 0xe3, 0xde, 0xcc, 0xab, 0xac, 0x4b}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 12605; - uint8_t client_id_bytes[] = {0xd5, 0x3f, 0xe, 0xe3, 0xd4, 0xe1, 0xea, 0xc1, 0xa4, 0x27, 0x16, 0x30, 0x2c, 0x36, 0x98}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "&\ETX\DC1tJ\204\211Q`", _password = Just "\128c\191.\162\253\GS\162q\130\138\188Y", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\245\221o", _willMsg = -// "\235\SOH,nQ&\DC1bJ\DC4\177\178\194\181\239\243I\167\232\150\179|^\185\241\164Wv\211", _willProps = []}), -// _cleanSession = True, _keepAlive = 6922, _connID = "\132\211\DC4\175\183\DC4\ETB\170Y", _properties = []} -TEST(Connect311QCTest, Encode36) { - uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x1b, 0xa, 0x0, 0x9, 0x84, - 0xd3, 0x14, 0xaf, 0xb7, 0x14, 0x17, 0xaa, 0x59, 0x0, 0x3, 0xf5, 0xdd, 0x6f, 0x0, 0x1d, - 0xeb, 0x1, 0x2c, 0x6e, 0x51, 0x26, 0x11, 0x62, 0x4a, 0x14, 0xb1, 0xb2, 0xc2, 0xb5, 0xef, - 0xf3, 0x49, 0xa7, 0xe8, 0x96, 0xb3, 0x7c, 0x5e, 0xb9, 0xf1, 0xa4, 0x57, 0x76, 0xd3, 0x0, - 0x9, 0x26, 0x3, 0x11, 0x74, 0x4a, 0xcc, 0xd3, 0x51, 0x60, 0x0, 0xd, 0x80, 0x63, 0xbf, - 0x2e, 0xa2, 0xfd, 0x1d, 0xa2, 0x71, 0x82, 0x8a, 0xbc, 0x59}; - - uint8_t buf[95] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf5, 0xdd, 0x6f}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xeb, 0x1, 0x2c, 0x6e, 0x51, 0x26, 0x11, 0x62, 0x4a, 0x14, - 0xb1, 0xb2, 0xc2, 0xb5, 0xef, 0xf3, 0x49, 0xa7, 0xe8, 0x96, - 0xb3, 0x7c, 0x5e, 0xb9, 0xf1, 0xa4, 0x57, 0x76, 0xd3}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 6922; - uint8_t client_id_bytes[] = {0x84, 0xd3, 0x14, 0xaf, 0xb7, 0x14, 0x17, 0xaa, 0x59}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x26, 0x3, 0x11, 0x74, 0x4a, 0xcc, 0xd3, 0x51, 0x60}; - lwmqtt_string_t username = {9, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x80, 0x63, 0xbf, 0x2e, 0xa2, 0xfd, 0x1d, 0xa2, 0x71, 0x82, 0x8a, 0xbc, 0x59}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\169\"\142.S\145\159\133VvX<\209\161", _password = Nothing, _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\136Rv", _willMsg = -// "v\SUB58p+]s\v\SYN\DC3!\220\199\192'K\140d\n@\133\188\CAN\174\209\SYNK", _willProps = []}), _cleanSession = False, -// _keepAlive = 25116, _connID = "\SOR\"\166}\168\197\211\153\NAK\249\165\138\211", _properties = []} -TEST(Connect311QCTest, Encode37) { - uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x94, 0x62, 0x1c, 0x0, 0xe, 0xe, 0x52, - 0x22, 0xa6, 0x7d, 0xa8, 0xc5, 0xd3, 0x99, 0x15, 0xf9, 0xa5, 0x8a, 0xd3, 0x0, 0x3, 0x88, 0x52, - 0x76, 0x0, 0x1c, 0x76, 0x1a, 0x35, 0x38, 0x70, 0x2b, 0x5d, 0x73, 0xb, 0x16, 0x13, 0x21, 0xdc, - 0xc7, 0xc0, 0x27, 0x4b, 0x8c, 0x64, 0xa, 0x40, 0x85, 0xbc, 0x18, 0xae, 0xd1, 0x16, 0x4b, 0x0, - 0xe, 0xa9, 0x22, 0x8e, 0x2e, 0x53, 0x91, 0x9f, 0x85, 0x56, 0x76, 0x58, 0x3c, 0xd1, 0xa1}; - - uint8_t buf[89] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x88, 0x52, 0x76}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x76, 0x1a, 0x35, 0x38, 0x70, 0x2b, 0x5d, 0x73, 0xb, 0x16, 0x13, 0x21, 0xdc, 0xc7, - 0xc0, 0x27, 0x4b, 0x8c, 0x64, 0xa, 0x40, 0x85, 0xbc, 0x18, 0xae, 0xd1, 0x16, 0x4b}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 25116; - uint8_t client_id_bytes[] = {0xe, 0x52, 0x22, 0xa6, 0x7d, 0xa8, 0xc5, 0xd3, 0x99, 0x15, 0xf9, 0xa5, 0x8a, 0xd3}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa9, 0x22, 0x8e, 0x2e, 0x53, 0x91, 0x9f, 0x85, 0x56, 0x76, 0x58, 0x3c, 0xd1, 0xa1}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "j3`=\194\212\200O\134\155v\212", _password = Just "\SI\FS=Y\232J\158\196\230\170", -// _lastWill = Nothing, _cleanSession = True, _keepAlive = 1881, _connID = "c\207n(N\155H\154,\158u\205*\f\182\SO", -// _properties = []} -TEST(Connect311QCTest, Encode38) { - uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x7, 0x59, 0x0, 0x10, - 0x63, 0xcf, 0x6e, 0x28, 0x4e, 0x9b, 0x48, 0x9a, 0x2c, 0x9e, 0x75, 0xcd, 0x2a, 0xc, - 0xb6, 0xe, 0x0, 0xc, 0x6a, 0x33, 0x60, 0x3d, 0xc2, 0xd4, 0xc8, 0x4f, 0x86, 0x9b, - 0x76, 0xd4, 0x0, 0xa, 0xf, 0x1c, 0x3d, 0x59, 0xe8, 0x4a, 0x9e, 0xc4, 0xe6, 0xaa}; - - uint8_t buf[66] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1881; - uint8_t client_id_bytes[] = {0x63, 0xcf, 0x6e, 0x28, 0x4e, 0x9b, 0x48, 0x9a, - 0x2c, 0x9e, 0x75, 0xcd, 0x2a, 0xc, 0xb6, 0xe}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x6a, 0x33, 0x60, 0x3d, 0xc2, 0xd4, 0xc8, 0x4f, 0x86, 0x9b, 0x76, 0xd4}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xf, 0x1c, 0x3d, 0x59, 0xe8, 0x4a, 0x9e, 0xc4, 0xe6, 0xaa}; - lwmqtt_string_t password = {10, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\ETXp\147\149\&7", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS1, _willTopic = "\218G\228", _willMsg = -// "\133\141;\199\135\145\&1\NAK\215\162H\224\199q\ft\156F\STX\178\162\152\147f\SI\229\248", _willProps = []}), -// _cleanSession = False, _keepAlive = 3338, _connID = -// "\244\164\&6\SYN\146\249\SOHR|b\175e~\146x\233H\240C\208\249M\233v\234\194\203\189\230\222", _properties = []} -TEST(Connect311QCTest, Encode39) { - uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0xd, 0xa, 0x0, 0x1e, 0xf4, - 0xa4, 0x36, 0x16, 0x92, 0xf9, 0x1, 0x52, 0x7c, 0x62, 0xaf, 0x65, 0x7e, 0x92, 0x78, 0xe9, - 0x48, 0xf0, 0x43, 0xd0, 0xf9, 0x4d, 0xe9, 0x76, 0xea, 0xc2, 0xcb, 0xbd, 0xe6, 0xde, 0x0, - 0x3, 0xda, 0x47, 0xe4, 0x0, 0x1b, 0x85, 0x8d, 0x3b, 0xc7, 0x87, 0x91, 0x31, 0x15, 0xd7, - 0xa2, 0x48, 0xe0, 0xc7, 0x71, 0xc, 0x74, 0x9c, 0x46, 0x2, 0xb2, 0xa2, 0x98, 0x93, 0x66, - 0xf, 0xe5, 0xf8, 0x0, 0x5, 0x3, 0x70, 0x93, 0x95, 0x37}; - - uint8_t buf[95] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xda, 0x47, 0xe4}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x85, 0x8d, 0x3b, 0xc7, 0x87, 0x91, 0x31, 0x15, 0xd7, 0xa2, 0x48, 0xe0, 0xc7, 0x71, - 0xc, 0x74, 0x9c, 0x46, 0x2, 0xb2, 0xa2, 0x98, 0x93, 0x66, 0xf, 0xe5, 0xf8}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3338; - uint8_t client_id_bytes[] = {0xf4, 0xa4, 0x36, 0x16, 0x92, 0xf9, 0x1, 0x52, 0x7c, 0x62, - 0xaf, 0x65, 0x7e, 0x92, 0x78, 0xe9, 0x48, 0xf0, 0x43, 0xd0, - 0xf9, 0x4d, 0xe9, 0x76, 0xea, 0xc2, 0xcb, 0xbd, 0xe6, 0xde}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x3, 0x70, 0x93, 0x95, 0x37}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "%s%1", _password = Just "JZ\188v\194\151\206\232\FS8\227", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "<3\134\&3\210\ai\247\172", _willMsg = -// "\195Z\ACK\163\170\202", _willProps = []}), _cleanSession = False, _keepAlive = 21786, _connID = -// "$\218\249\238\250,\NUL\129\DC2\162H\219_\168K\DC1\212\231\195p\167\157\177D\149", _properties = []} -TEST(Connect311QCTest, Encode40) { - uint8_t pkt[] = {0x10, 0x4b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x55, 0x1a, 0x0, 0x19, 0x24, 0xda, - 0xf9, 0xee, 0xfa, 0x2c, 0x0, 0x81, 0x12, 0xa2, 0x48, 0xdb, 0x5f, 0xa8, 0x4b, 0x11, 0xd4, 0xe7, - 0xc3, 0x70, 0xa7, 0x9d, 0xb1, 0x44, 0x95, 0x0, 0x9, 0x3c, 0x33, 0x86, 0x33, 0xd2, 0x7, 0x69, - 0xf7, 0xac, 0x0, 0x6, 0xc3, 0x5a, 0x6, 0xa3, 0xaa, 0xca, 0x0, 0x4, 0x25, 0x73, 0x25, 0x31, - 0x0, 0xb, 0x4a, 0x5a, 0xbc, 0x76, 0xc2, 0x97, 0xce, 0xe8, 0x1c, 0x38, 0xe3}; - - uint8_t buf[87] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3c, 0x33, 0x86, 0x33, 0xd2, 0x7, 0x69, 0xf7, 0xac}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc3, 0x5a, 0x6, 0xa3, 0xaa, 0xca}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 21786; - uint8_t client_id_bytes[] = {0x24, 0xda, 0xf9, 0xee, 0xfa, 0x2c, 0x0, 0x81, 0x12, 0xa2, 0x48, 0xdb, 0x5f, - 0xa8, 0x4b, 0x11, 0xd4, 0xe7, 0xc3, 0x70, 0xa7, 0x9d, 0xb1, 0x44, 0x95}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x25, 0x73, 0x25, 0x31}; - lwmqtt_string_t username = {4, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x4a, 0x5a, 0xbc, 0x76, 0xc2, 0x97, 0xce, 0xe8, 0x1c, 0x38, 0xe3}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\"\192-\143\173\214\ETXL\182X\SOHQ", _password = Just -// "\210\SI4\163\NUL>\DC1}2x\SOHq\134\ETX\245\&0\169\180", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS1, _willTopic = "\227\NAK\133\240\173\&0\r", _willMsg = "\197 \US\DEL\147\243\248\SI9\198\187\\\219\146\152\229\214\233", _lastWill = -// Nothing, _cleanSession = False, _keepAlive = 30703, _connID = "3\193)\173", _properties = []} -TEST(Connect311QCTest, Encode45) { - uint8_t pkt[] = {0x10, 0x10, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, - 0x0, 0x77, 0xef, 0x0, 0x4, 0x33, 0xc1, 0x29, 0xad}; - - uint8_t buf[28] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 30703; - uint8_t client_id_bytes[] = {0x33, 0xc1, 0x29, 0xad}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x25, 0xcc, 0xb9, 0x33, 0x17, 0x26, 0xae, 0xa3, 0xc, 0xc3, 0x25, 0xcd, 0x33, 0x5b, 0x3e, - 0x7f, 0x93, 0xf3, 0xf8, 0xf, 0x39, 0xc6, 0xbb, 0x5c, 0xdb, 0x92, 0x98, 0xe5, 0xd6, 0xe9}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "]\193c\STX\r\223\249r\ETXZ\v\aN1\DEL\172q\RS\210\169\176i\147\FS\191\181\200Vk%", -// _password = Just "\150\212\ESC\162~(\188%\191\133\243l", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 9661, _connID = "l\v\146\230\194\DC4X\149\219\171 \169y\188\176\&4\144O", _properties = []} -TEST(Connect311QCTest, Encode46) { - uint8_t pkt[] = {0x10, 0x4c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x25, 0xbd, 0x0, 0x12, 0x6c, 0xb, - 0x92, 0xe6, 0xc2, 0x14, 0x58, 0x95, 0xdb, 0xab, 0x20, 0xa9, 0x79, 0xbc, 0xb0, 0x34, 0x90, 0x4f, - 0x0, 0x1e, 0x5d, 0xc1, 0x63, 0x2, 0xd, 0xdf, 0xf9, 0x72, 0x3, 0x5a, 0xb, 0x7, 0x4e, 0x31, - 0x7f, 0xac, 0x71, 0x1e, 0xd2, 0xa9, 0xb0, 0x69, 0x93, 0x1c, 0xbf, 0xb5, 0xc8, 0x56, 0x6b, 0x25, - 0x0, 0xc, 0x96, 0xd4, 0x1b, 0xa2, 0x7e, 0x28, 0xbc, 0x25, 0xbf, 0x85, 0xf3, 0x6c}; - - uint8_t buf[88] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 9661; - uint8_t client_id_bytes[] = {0x6c, 0xb, 0x92, 0xe6, 0xc2, 0x14, 0x58, 0x95, 0xdb, - 0xab, 0x20, 0xa9, 0x79, 0xbc, 0xb0, 0x34, 0x90, 0x4f}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x5d, 0xc1, 0x63, 0x2, 0xd, 0xdf, 0xf9, 0x72, 0x3, 0x5a, 0xb, 0x7, 0x4e, 0x31, 0x7f, - 0xac, 0x71, 0x1e, 0xd2, 0xa9, 0xb0, 0x69, 0x93, 0x1c, 0xbf, 0xb5, 0xc8, 0x56, 0x6b, 0x25}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x96, 0xd4, 0x1b, 0xa2, 0x7e, 0x28, 0xbc, 0x25, 0xbf, 0x85, 0xf3, 0x6c}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "HK\160A\236!\215\217", _password = Just "\172", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "_#", _willMsg = "}\199!\254\224\b\154\&2\232\184\163\213?\186", -// _willProps = []}), _cleanSession = True, _keepAlive = 8375, _connID = "{iE\207H\USn\DLE\193\b\245\216JK", _properties -// = []} -TEST(Connect311QCTest, Encode47) { - uint8_t pkt[] = {0x10, 0x3b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x20, 0xb7, 0x0, 0xe, 0x7b, 0x69, - 0x45, 0xcf, 0x48, 0x1f, 0x6e, 0x10, 0xc1, 0x8, 0xf5, 0xd8, 0x4a, 0x4b, 0x0, 0x2, 0x5f, 0x23, - 0x0, 0xe, 0x7d, 0xc7, 0x21, 0xfe, 0xe0, 0x8, 0x9a, 0x32, 0xe8, 0xb8, 0xa3, 0xd5, 0x3f, 0xba, - 0x0, 0x8, 0x48, 0x4b, 0xa0, 0x41, 0xec, 0x21, 0xd7, 0xd9, 0x0, 0x1, 0xac}; - - uint8_t buf[71] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5f, 0x23}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7d, 0xc7, 0x21, 0xfe, 0xe0, 0x8, 0x9a, 0x32, 0xe8, 0xb8, 0xa3, 0xd5, 0x3f, 0xba}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 8375; - uint8_t client_id_bytes[] = {0x7b, 0x69, 0x45, 0xcf, 0x48, 0x1f, 0x6e, 0x10, 0xc1, 0x8, 0xf5, 0xd8, 0x4a, 0x4b}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x48, 0x4b, 0xa0, 0x41, 0xec, 0x21, 0xd7, 0xd9}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xac}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just -// "s\249\NAK\192\197\&1\198#\180\SOH2\136\150\183B\199\209W@\DC3a\DLE\246\148\187\246\"", _password = Just -// "\224\236\147\252C\148\166\DEL\185\157\241m\242\132\SO\\q", _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS1, _willTopic = "\tqP", _willMsg = "o\SO.\159", _willProps = []}), _cleanSession = False, _keepAlive = 1422, -// _connID = "\184\233(\195\247\\\DC28i\FSj\135", _properties = []} -TEST(Connect311QCTest, Encode48) { - uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x5, 0x8e, 0x0, 0xc, 0xb8, - 0xe9, 0x28, 0xc3, 0xf7, 0x5c, 0x12, 0x38, 0x69, 0x1c, 0x6a, 0x87, 0x0, 0x3, 0x9, 0x71, - 0x50, 0x0, 0x4, 0x6f, 0xe, 0x2e, 0x9f, 0x0, 0x1b, 0x73, 0xf9, 0x15, 0xc0, 0xc5, 0x31, - 0xc6, 0x23, 0xb4, 0x1, 0x32, 0x88, 0x96, 0xb7, 0x42, 0xc7, 0xd1, 0x57, 0x40, 0x13, 0x61, - 0x10, 0xf6, 0x94, 0xbb, 0xf6, 0x22, 0x0, 0x11, 0xe0, 0xec, 0x93, 0xfc, 0x43, 0x94, 0xa6, - 0x7f, 0xb9, 0x9d, 0xf1, 0x6d, 0xf2, 0x84, 0xe, 0x5c, 0x71}; - - uint8_t buf[95] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9, 0x71, 0x50}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6f, 0xe, 0x2e, 0x9f}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 1422; - uint8_t client_id_bytes[] = {0xb8, 0xe9, 0x28, 0xc3, 0xf7, 0x5c, 0x12, 0x38, 0x69, 0x1c, 0x6a, 0x87}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x73, 0xf9, 0x15, 0xc0, 0xc5, 0x31, 0xc6, 0x23, 0xb4, 0x1, 0x32, 0x88, 0x96, 0xb7, - 0x42, 0xc7, 0xd1, 0x57, 0x40, 0x13, 0x61, 0x10, 0xf6, 0x94, 0xbb, 0xf6, 0x22}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe0, 0xec, 0x93, 0xfc, 0x43, 0x94, 0xa6, 0x7f, 0xb9, - 0x9d, 0xf1, 0x6d, 0xf2, 0x84, 0xe, 0x5c, 0x71}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\204\ESC-v\215\228\195+\251.F6\r\221\213nfx\221", _password = Just "\193\152", -// _lastWill = Nothing, _cleanSession = False, _keepAlive = 20170, _connID = -// "9\b4\231\247\150H\ETB\GS\236t\185o\189\144\173\203P\207z\173", _properties = []} -TEST(Connect311QCTest, Encode49) { - uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x4e, 0xca, 0x0, 0x15, 0x39, - 0x8, 0x34, 0xe7, 0xf7, 0x96, 0x48, 0x17, 0x1d, 0xec, 0x74, 0xb9, 0x6f, 0xbd, 0x90, 0xad, - 0xcb, 0x50, 0xcf, 0x7a, 0xad, 0x0, 0x13, 0xcc, 0x1b, 0x2d, 0x76, 0xd7, 0xe4, 0xc3, 0x2b, - 0xfb, 0x2e, 0x46, 0x36, 0xd, 0xdd, 0xd5, 0x6e, 0x66, 0x78, 0xdd, 0x0, 0x2, 0xc1, 0x98}; - - uint8_t buf[70] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 20170; - uint8_t client_id_bytes[] = {0x39, 0x8, 0x34, 0xe7, 0xf7, 0x96, 0x48, 0x17, 0x1d, 0xec, 0x74, - 0xb9, 0x6f, 0xbd, 0x90, 0xad, 0xcb, 0x50, 0xcf, 0x7a, 0xad}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xcc, 0x1b, 0x2d, 0x76, 0xd7, 0xe4, 0xc3, 0x2b, 0xfb, 0x2e, - 0x46, 0x36, 0xd, 0xdd, 0xd5, 0x6e, 0x66, 0x78, 0xdd}; - lwmqtt_string_t username = {19, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xc1, 0x98}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "t\239", _password = Just "\r%\148", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "\r\226_c,\248", _willMsg = "\151\168\141\183G\198", _willProps = []}), _cleanSession = -// False, _keepAlive = 29236, _connID = "\202\219", _properties = []} -TEST(Connect311QCTest, Encode50) { - uint8_t pkt[] = {0x10, 0x27, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x72, 0x34, 0x0, 0x2, - 0xca, 0xdb, 0x0, 0x6, 0xd, 0xe2, 0x5f, 0x63, 0x2c, 0xf8, 0x0, 0x6, 0x97, 0xa8, - 0x8d, 0xb7, 0x47, 0xc6, 0x0, 0x2, 0x74, 0xef, 0x0, 0x3, 0xd, 0x25, 0x94}; - - uint8_t buf[51] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd, 0xe2, 0x5f, 0x63, 0x2c, 0xf8}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x97, 0xa8, 0x8d, 0xb7, 0x47, 0xc6}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 29236; - uint8_t client_id_bytes[] = {0xca, 0xdb}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x74, 0xef}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd, 0x25, 0x94}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\144:3}\185E\246k\210Hp\221\197\245\&6\148\135m\216\143p\136\185\STX\ENQ\186\149?", -// _password = Just "\DC3\NAK\168)\SUB\234>\CAN\168\155\253RB\142?\137D\181y\170\&3O!+", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = -// "\227\205\234\251\"J\133\178\154\154[\STX\135\DC4[\a@\245[e\SUBR1\234\201\192'\vam", _willMsg = "\CAN\230\GS", -// _willProps = []}), _cleanSession = False, _keepAlive = 542, _connID = -// ")\ESC\193I>\"[\SO\187G\\\182\199yj\DC4o\204\229yV\"n+\138u\223", _properties = []} -TEST(Connect311QCTest, Encode51) { - uint8_t pkt[] = {0x10, 0x84, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x2, 0x1e, 0x0, 0x1b, 0x29, 0x1b, - 0xc1, 0x49, 0x3e, 0x22, 0x5b, 0xe, 0xbb, 0x47, 0x5c, 0xb6, 0xc7, 0x79, 0x6a, 0x14, 0x6f, 0xcc, 0xe5, - 0x79, 0x56, 0x22, 0x6e, 0x2b, 0x8a, 0x75, 0xdf, 0x0, 0x1e, 0xe3, 0xcd, 0xea, 0xfb, 0x22, 0x4a, 0x85, - 0xb2, 0x9a, 0x9a, 0x5b, 0x2, 0x87, 0x14, 0x5b, 0x7, 0x40, 0xf5, 0x5b, 0x65, 0x1a, 0x52, 0x31, 0xea, - 0xc9, 0xc0, 0x27, 0xb, 0x61, 0x6d, 0x0, 0x3, 0x18, 0xe6, 0x1d, 0x0, 0x1c, 0x90, 0x3a, 0x33, 0x7d, - 0xb9, 0x45, 0xf6, 0x6b, 0xd2, 0x48, 0x70, 0xdd, 0xc5, 0xf5, 0x36, 0x94, 0x87, 0x6d, 0xd8, 0x8f, 0x70, - 0x88, 0xb9, 0x2, 0x5, 0xba, 0x95, 0x3f, 0x0, 0x18, 0x13, 0x15, 0xa8, 0x29, 0x1a, 0xea, 0x3e, 0x18, - 0xa8, 0x9b, 0xfd, 0x52, 0x42, 0x8e, 0x3f, 0x89, 0x44, 0xb5, 0x79, 0xaa, 0x33, 0x4f, 0x21, 0x2b}; - - uint8_t buf[145] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe3, 0xcd, 0xea, 0xfb, 0x22, 0x4a, 0x85, 0xb2, 0x9a, 0x9a, - 0x5b, 0x2, 0x87, 0x14, 0x5b, 0x7, 0x40, 0xf5, 0x5b, 0x65, - 0x1a, 0x52, 0x31, 0xea, 0xc9, 0xc0, 0x27, 0xb, 0x61, 0x6d}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x18, 0xe6, 0x1d}; - lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 542; - uint8_t client_id_bytes[] = {0x29, 0x1b, 0xc1, 0x49, 0x3e, 0x22, 0x5b, 0xe, 0xbb, 0x47, 0x5c, 0xb6, 0xc7, 0x79, - 0x6a, 0x14, 0x6f, 0xcc, 0xe5, 0x79, 0x56, 0x22, 0x6e, 0x2b, 0x8a, 0x75, 0xdf}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x90, 0x3a, 0x33, 0x7d, 0xb9, 0x45, 0xf6, 0x6b, 0xd2, 0x48, 0x70, 0xdd, 0xc5, 0xf5, - 0x36, 0x94, 0x87, 0x6d, 0xd8, 0x8f, 0x70, 0x88, 0xb9, 0x2, 0x5, 0xba, 0x95, 0x3f}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x13, 0x15, 0xa8, 0x29, 0x1a, 0xea, 0x3e, 0x18, 0xa8, 0x9b, 0xfd, 0x52, - 0x42, 0x8e, 0x3f, 0x89, 0x44, 0xb5, 0x79, 0xaa, 0x33, 0x4f, 0x21, 0x2b}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "LW\149,C?\222\163x\147\176\166e\163!\187}@2\213\n", _password = Just -// "\166\&1Vn<\147O\v\178i\245g:\SUB", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\243\244O\221\ETX\229\192\137;\183\197D/\221!m\211\162", _willMsg = -// "\239M(\237\209\235\215\"\SI\220v\217\205\n\228\156\205s\250\244\167K\185\SI-\ETB\SOq\r", _willProps = []}), -// _cleanSession = False, _keepAlive = 32428, _connID = -// "\SYN\217\207Z5\137\241\224\174\144\248\192*\233\218Z\230\DEL\198I9", _properties = []} -TEST(Connect311QCTest, Encode52) { - uint8_t pkt[] = {0x10, 0x7b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x7e, 0xac, 0x0, 0x15, 0x16, 0xd9, - 0xcf, 0x5a, 0x35, 0x89, 0xf1, 0xe0, 0xae, 0x90, 0xf8, 0xc0, 0x2a, 0xe9, 0xda, 0x5a, 0xe6, 0x7f, - 0xc6, 0x49, 0x39, 0x0, 0x12, 0xf3, 0xf4, 0x4f, 0xdd, 0x3, 0xe5, 0xc0, 0x89, 0x3b, 0xb7, 0xc5, - 0x44, 0x2f, 0xdd, 0x21, 0x6d, 0xd3, 0xa2, 0x0, 0x1d, 0xef, 0x4d, 0x28, 0xed, 0xd1, 0xeb, 0xd7, - 0x22, 0xf, 0xdc, 0x76, 0xd9, 0xcd, 0xa, 0xe4, 0x9c, 0xcd, 0x73, 0xfa, 0xf4, 0xa7, 0x4b, 0xb9, - 0xf, 0x2d, 0x17, 0xe, 0x71, 0xd, 0x0, 0x15, 0x4c, 0x57, 0x95, 0x2c, 0x43, 0x3f, 0xde, 0xa3, - 0x78, 0x93, 0xb0, 0xa6, 0x65, 0xa3, 0x21, 0xbb, 0x7d, 0x40, 0x32, 0xd5, 0xa, 0x0, 0xe, 0xa6, - 0x31, 0x56, 0x6e, 0x3c, 0x93, 0x4f, 0xb, 0xb2, 0x69, 0xf5, 0x67, 0x3a, 0x1a}; - - uint8_t buf[135] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf3, 0xf4, 0x4f, 0xdd, 0x3, 0xe5, 0xc0, 0x89, 0x3b, - 0xb7, 0xc5, 0x44, 0x2f, 0xdd, 0x21, 0x6d, 0xd3, 0xa2}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xef, 0x4d, 0x28, 0xed, 0xd1, 0xeb, 0xd7, 0x22, 0xf, 0xdc, - 0x76, 0xd9, 0xcd, 0xa, 0xe4, 0x9c, 0xcd, 0x73, 0xfa, 0xf4, - 0xa7, 0x4b, 0xb9, 0xf, 0x2d, 0x17, 0xe, 0x71, 0xd}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32428; - uint8_t client_id_bytes[] = {0x16, 0xd9, 0xcf, 0x5a, 0x35, 0x89, 0xf1, 0xe0, 0xae, 0x90, 0xf8, - 0xc0, 0x2a, 0xe9, 0xda, 0x5a, 0xe6, 0x7f, 0xc6, 0x49, 0x39}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x4c, 0x57, 0x95, 0x2c, 0x43, 0x3f, 0xde, 0xa3, 0x78, 0x93, 0xb0, - 0xa6, 0x65, 0xa3, 0x21, 0xbb, 0x7d, 0x40, 0x32, 0xd5, 0xa}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xa6, 0x31, 0x56, 0x6e, 0x3c, 0x93, 0x4f, 0xb, 0xb2, 0x69, 0xf5, 0x67, 0x3a, 0x1a}; - lwmqtt_string_t password = {14, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\230\206\252H\237\141\SIb\136w \172Y\159\155sC\141\159\"s\246{\DEL\254\208~\130", -// _password = Just "o\191Q<34\244\255\186\STXo\235,\210\v\SYN_\234\"x\219X\242\159.D\231", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\204\DC4\226:25\172", _willMsg = "\NAK\232\175\221\193,", -// _willProps = []}), _cleanSession = False, _keepAlive = 4766, _connID = -// "p\205\137>X(\171\175\246\NAKr\254\223H\232\252\254\236\198<", _properties = []} -TEST(Connect311QCTest, Encode53) { - uint8_t pkt[] = {0x10, 0x6c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x12, 0x9e, 0x0, 0x14, 0x70, 0xcd, - 0x89, 0x3e, 0x58, 0x28, 0xab, 0xaf, 0xf6, 0x15, 0x72, 0xfe, 0xdf, 0x48, 0xe8, 0xfc, 0xfe, 0xec, - 0xc6, 0x3c, 0x0, 0x7, 0xcc, 0x14, 0xe2, 0x3a, 0x32, 0x35, 0xac, 0x0, 0x6, 0x15, 0xe8, 0xaf, - 0xdd, 0xc1, 0x2c, 0x0, 0x1c, 0xe6, 0xce, 0xfc, 0x48, 0xed, 0x8d, 0xf, 0x62, 0x88, 0x77, 0x20, - 0xac, 0x59, 0x9f, 0x9b, 0x73, 0x43, 0x8d, 0x9f, 0x22, 0x73, 0xf6, 0x7b, 0x7f, 0xfe, 0xd0, 0x7e, - 0x82, 0x0, 0x1b, 0x6f, 0xbf, 0x51, 0x3c, 0x33, 0x34, 0xf4, 0xff, 0xba, 0x2, 0x6f, 0xeb, 0x2c, - 0xd2, 0xb, 0x16, 0x5f, 0xea, 0x22, 0x78, 0xdb, 0x58, 0xf2, 0x9f, 0x2e, 0x44, 0xe7}; - - uint8_t buf[120] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xcc, 0x14, 0xe2, 0x3a, 0x32, 0x35, 0xac}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x15, 0xe8, 0xaf, 0xdd, 0xc1, 0x2c}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 4766; - uint8_t client_id_bytes[] = {0x70, 0xcd, 0x89, 0x3e, 0x58, 0x28, 0xab, 0xaf, 0xf6, 0x15, - 0x72, 0xfe, 0xdf, 0x48, 0xe8, 0xfc, 0xfe, 0xec, 0xc6, 0x3c}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xe6, 0xce, 0xfc, 0x48, 0xed, 0x8d, 0xf, 0x62, 0x88, 0x77, 0x20, 0xac, 0x59, 0x9f, - 0x9b, 0x73, 0x43, 0x8d, 0x9f, 0x22, 0x73, 0xf6, 0x7b, 0x7f, 0xfe, 0xd0, 0x7e, 0x82}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6f, 0xbf, 0x51, 0x3c, 0x33, 0x34, 0xf4, 0xff, 0xba, 0x2, 0x6f, 0xeb, 0x2c, 0xd2, - 0xb, 0x16, 0x5f, 0xea, 0x22, 0x78, 0xdb, 0x58, 0xf2, 0x9f, 0x2e, 0x44, 0xe7}; - lwmqtt_string_t password = {27, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "<\n\149R0\\\216K\NAK\157\239\187b\243\172\NAKU", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\n", _willMsg = -// "w9\217yM\186\161\166g\136\140\154\178\SYN5\150\228\212\FSHP\235\202\224\242D;", _willProps = []}), _cleanSession = -// False, _keepAlive = 6302, _connID = "5\175\175\181'H\173\161[\157\&8\175BY\182|\179", _properties = []} -TEST(Connect311QCTest, Encode54) { - uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x18, 0x9e, 0x0, 0x11, 0x35, 0xaf, - 0xaf, 0xb5, 0x27, 0x48, 0xad, 0xa1, 0x5b, 0x9d, 0x38, 0xaf, 0x42, 0x59, 0xb6, 0x7c, 0xb3, 0x0, - 0x1, 0xa, 0x0, 0x1b, 0x77, 0x39, 0xd9, 0x79, 0x4d, 0xba, 0xa1, 0xa6, 0x67, 0x88, 0x8c, 0x9a, - 0xb2, 0x16, 0x35, 0x96, 0xe4, 0xd4, 0x1c, 0x48, 0x50, 0xeb, 0xca, 0xe0, 0xf2, 0x44, 0x3b}; - - uint8_t buf[73] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x77, 0x39, 0xd9, 0x79, 0x4d, 0xba, 0xa1, 0xa6, 0x67, 0x88, 0x8c, 0x9a, 0xb2, 0x16, - 0x35, 0x96, 0xe4, 0xd4, 0x1c, 0x48, 0x50, 0xeb, 0xca, 0xe0, 0xf2, 0x44, 0x3b}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 6302; - uint8_t client_id_bytes[] = {0x35, 0xaf, 0xaf, 0xb5, 0x27, 0x48, 0xad, 0xa1, 0x5b, - 0x9d, 0x38, 0xaf, 0x42, 0x59, 0xb6, 0x7c, 0xb3}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x3c, 0xa, 0x95, 0x52, 0x30, 0x5c, 0xd8, 0x4b, 0x15, - 0x9d, 0xef, 0xbb, 0x62, 0xf3, 0xac, 0x15, 0x55}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "7x\204\136o\US\ESC\232\vI\211", _password = Just "m", _lastWill = Nothing, -// _cleanSession = True, _keepAlive = 16891, _connID = "\152\237\162\129\182]", _properties = []} -TEST(Connect311QCTest, Encode55) { - uint8_t pkt[] = {0x10, 0x22, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x41, 0xfb, - 0x0, 0x6, 0x98, 0xed, 0xa2, 0x81, 0xb6, 0x5d, 0x0, 0xb, 0x37, 0x78, - 0xcc, 0x88, 0x6f, 0x1f, 0x1b, 0xe8, 0xb, 0x49, 0xd3, 0x0, 0x1, 0x6d}; - - uint8_t buf[46] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 16891; - uint8_t client_id_bytes[] = {0x98, 0xed, 0xa2, 0x81, 0xb6, 0x5d}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x37, 0x78, 0xcc, 0x88, 0x6f, 0x1f, 0x1b, 0xe8, 0xb, 0x49, 0xd3}; - lwmqtt_string_t username = {11, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6d}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\189J\246\DC4Ep\136e]\182\253\DEL\n\DC2\"\\\134&\162\252D\144", _password = -// Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 32242, _connID = -// "\218P?\172\167\243\&3_s\246\DC4\EOT\EM\139\169\186?", _properties = []} -TEST(Connect311QCTest, Encode56) { - uint8_t pkt[] = {0x10, 0x35, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x7d, 0xf2, 0x0, 0x11, - 0xda, 0x50, 0x3f, 0xac, 0xa7, 0xf3, 0x33, 0x5f, 0x73, 0xf6, 0x14, 0x4, 0x19, 0x8b, - 0xa9, 0xba, 0x3f, 0x0, 0x16, 0xbd, 0x4a, 0xf6, 0x14, 0x45, 0x70, 0x88, 0x65, 0x5d, - 0xb6, 0xfd, 0x7f, 0xa, 0x12, 0x22, 0x5c, 0x86, 0x26, 0xa2, 0xfc, 0x44, 0x90}; - - uint8_t buf[65] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32242; - uint8_t client_id_bytes[] = {0xda, 0x50, 0x3f, 0xac, 0xa7, 0xf3, 0x33, 0x5f, 0x73, - 0xf6, 0x14, 0x4, 0x19, 0x8b, 0xa9, 0xba, 0x3f}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xbd, 0x4a, 0xf6, 0x14, 0x45, 0x70, 0x88, 0x65, 0x5d, 0xb6, 0xfd, - 0x7f, 0xa, 0x12, 0x22, 0x5c, 0x86, 0x26, 0xa2, 0xfc, 0x44, 0x90}; - lwmqtt_string_t username = {22, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "Au`\168A\188\232\r\137)\223\STX\199%\136", _password = Just -// "d\160\254\DEL\EOT\147\231-\152", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\199M\"\227Xv\NUL", _willMsg = "\201Z\208~\134\159\213", _willProps = []}), _cleanSession = True, _keepAlive = -// 16538, _connID = "\ENQ\184\173\135\NAK", _properties = []} -TEST(Connect311QCTest, Encode57) { - uint8_t pkt[] = {0x10, 0x3f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x40, 0x9a, 0x0, 0x5, 0x5, 0xb8, 0xad, - 0x87, 0x15, 0x0, 0x7, 0xc7, 0x4d, 0x22, 0xe3, 0x58, 0x76, 0x0, 0x0, 0x7, 0xc9, 0x5a, 0xd0, 0x7e, - 0x86, 0x9f, 0xd5, 0x0, 0xf, 0x41, 0x75, 0x60, 0xa8, 0x41, 0xbc, 0xe8, 0xd, 0x89, 0x29, 0xdf, 0x2, - 0xc7, 0x25, 0x88, 0x0, 0x9, 0x64, 0xa0, 0xfe, 0x7f, 0x4, 0x93, 0xe7, 0x2d, 0x98}; - - uint8_t buf[75] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc7, 0x4d, 0x22, 0xe3, 0x58, 0x76, 0x0}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc9, 0x5a, 0xd0, 0x7e, 0x86, 0x9f, 0xd5}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 16538; - uint8_t client_id_bytes[] = {0x5, 0xb8, 0xad, 0x87, 0x15}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x41, 0x75, 0x60, 0xa8, 0x41, 0xbc, 0xe8, 0xd, 0x89, 0x29, 0xdf, 0x2, 0xc7, 0x25, 0x88}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x64, 0xa0, 0xfe, 0x7f, 0x4, 0x93, 0xe7, 0x2d, 0x98}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "I", _password = Just -// "\187\133u\SYN\172\178^\135<\224\244\171\211k\255\158\148\EOT\255\STX1\SI\184", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = -// "s\241\244i\ETX6\STXo?H<\137\172\RS\203\US\236\ESC\214\218\&9\SIg.", _willMsg = -// "\242en\210E\149\254\131\167\&8\178\242\SOH@#)\215\245\175\160\206e\EMy", _willProps = []}), _cleanSession = True, -// _keepAlive = 29587, _connID = "\192\178\157\213%\235i\USou\STX\245\201\145\\>J", _properties = []} -TEST(Connect311QCTest, Encode58) { - uint8_t pkt[] = {0x10, 0x6d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x73, 0x93, 0x0, 0x11, 0xc0, 0xb2, - 0x9d, 0xd5, 0x25, 0xeb, 0x69, 0x1f, 0x6f, 0x75, 0x2, 0xf5, 0xc9, 0x91, 0x5c, 0x3e, 0x4a, 0x0, - 0x18, 0x73, 0xf1, 0xf4, 0x69, 0x3, 0x36, 0x2, 0x6f, 0x3f, 0x48, 0x3c, 0x89, 0xac, 0x1e, 0xcb, - 0x1f, 0xec, 0x1b, 0xd6, 0xda, 0x39, 0xf, 0x67, 0x2e, 0x0, 0x18, 0xf2, 0x65, 0x6e, 0xd2, 0x45, - 0x95, 0xfe, 0x83, 0xa7, 0x38, 0xb2, 0xf2, 0x1, 0x40, 0x23, 0x29, 0xd7, 0xf5, 0xaf, 0xa0, 0xce, - 0x65, 0x19, 0x79, 0x0, 0x1, 0x49, 0x0, 0x17, 0xbb, 0x85, 0x75, 0x16, 0xac, 0xb2, 0x5e, 0x87, - 0x3c, 0xe0, 0xf4, 0xab, 0xd3, 0x6b, 0xff, 0x9e, 0x94, 0x4, 0xff, 0x2, 0x31, 0xf, 0xb8}; - - uint8_t buf[121] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x73, 0xf1, 0xf4, 0x69, 0x3, 0x36, 0x2, 0x6f, 0x3f, 0x48, 0x3c, 0x89, - 0xac, 0x1e, 0xcb, 0x1f, 0xec, 0x1b, 0xd6, 0xda, 0x39, 0xf, 0x67, 0x2e}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf2, 0x65, 0x6e, 0xd2, 0x45, 0x95, 0xfe, 0x83, 0xa7, 0x38, 0xb2, 0xf2, - 0x1, 0x40, 0x23, 0x29, 0xd7, 0xf5, 0xaf, 0xa0, 0xce, 0x65, 0x19, 0x79}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 29587; - uint8_t client_id_bytes[] = {0xc0, 0xb2, 0x9d, 0xd5, 0x25, 0xeb, 0x69, 0x1f, 0x6f, - 0x75, 0x2, 0xf5, 0xc9, 0x91, 0x5c, 0x3e, 0x4a}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x49}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xbb, 0x85, 0x75, 0x16, 0xac, 0xb2, 0x5e, 0x87, 0x3c, 0xe0, 0xf4, 0xab, - 0xd3, 0x6b, 0xff, 0x9e, 0x94, 0x4, 0xff, 0x2, 0x31, 0xf, 0xb8}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = -// 12978, _connID = "\160X\221W2^\230o\163\&7\179s\156", _properties = []} -TEST(Connect311QCTest, Encode59) { - uint8_t pkt[] = {0x10, 0x19, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x32, 0xb2, 0x0, 0xd, - 0xa0, 0x58, 0xdd, 0x57, 0x32, 0x5e, 0xe6, 0x6f, 0xa3, 0x37, 0xb3, 0x73, 0x9c}; - - uint8_t buf[37] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 12978; - uint8_t client_id_bytes[] = {0xa0, 0x58, 0xdd, 0x57, 0x32, 0x5e, 0xe6, 0x6f, 0xa3, 0x37, 0xb3, 0x73, 0x9c}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "^\134", _lastWill = Nothing, _cleanSession = False, _keepAlive -// = 22655, _connID = "\134^\vF\DC1{\207R", _properties = []} -TEST(Connect311QCTest, Encode60) { - uint8_t pkt[] = {0x10, 0x14, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x58, - 0x7f, 0x0, 0x8, 0x86, 0x5e, 0xb, 0x46, 0x11, 0x7b, 0xcf, 0x52}; - - uint8_t buf[32] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 22655; - uint8_t client_id_bytes[] = {0x86, 0x5e, 0xb, 0x46, 0x11, 0x7b, 0xcf, 0x52}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x5e, 0x86}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 30398, _connID = "\GSv\DC4zn\ETX\185\219i\199/\131\157\245", _properties = []} -TEST(Connect311QCTest, Encode61) { - uint8_t pkt[] = {0x10, 0x1a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x76, 0xbe, 0x0, 0xe, - 0x1d, 0x76, 0x14, 0x7a, 0x6e, 0x3, 0xb9, 0xdb, 0x69, 0xc7, 0x2f, 0x83, 0x9d, 0xf5}; - - uint8_t buf[38] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 30398; - uint8_t client_id_bytes[] = {0x1d, 0x76, 0x14, 0x7a, 0x6e, 0x3, 0xb9, 0xdb, 0x69, 0xc7, 0x2f, 0x83, 0x9d, 0xf5}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\142\168\DC2Z\a\229\255\250\192\177\&6\172\240D2", _password = Just -// "\r\137\ETBtR\130C*\DC1\223\202\169\147\197\232", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, -// _willTopic = "\209\194%\251R\ETX%3\CAN\136\174\167\169\139\167\186C)\184*n\154\ETBmG\209T\186\DC1", _willMsg = -// "#yp(#!>\196O\247\DC1\176\253\150\238\214\216\212f\161Xl\t", _willProps = []}), _cleanSession = True, _keepAlive = -// 1871, _connID = "s\ETXN", _properties = []} -TEST(Connect311QCTest, Encode62) { - uint8_t pkt[] = {0x10, 0x69, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x7, 0x4f, 0x0, 0x3, 0x73, 0x3, - 0x4e, 0x0, 0x1d, 0xd1, 0xc2, 0x25, 0xfb, 0x52, 0x3, 0x25, 0x33, 0x18, 0x88, 0xae, 0xa7, 0xa9, - 0x8b, 0xa7, 0xba, 0x43, 0x29, 0xb8, 0x2a, 0x6e, 0x9a, 0x17, 0x6d, 0x47, 0xd1, 0x54, 0xba, 0x11, - 0x0, 0x17, 0x23, 0x79, 0x70, 0x28, 0x23, 0x21, 0x3e, 0xc4, 0x4f, 0xf7, 0x11, 0xb0, 0xfd, 0x96, - 0xee, 0xd6, 0xd8, 0xd4, 0x66, 0xa1, 0x58, 0x6c, 0x9, 0x0, 0xf, 0x8e, 0xa8, 0x12, 0x5a, 0x7, - 0xe5, 0xff, 0xfa, 0xc0, 0xb1, 0x36, 0xac, 0xf0, 0x44, 0x32, 0x0, 0xf, 0xd, 0x89, 0x17, 0x74, - 0x52, 0x82, 0x43, 0x2a, 0x11, 0xdf, 0xca, 0xa9, 0x93, 0xc5, 0xe8}; - - uint8_t buf[117] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd1, 0xc2, 0x25, 0xfb, 0x52, 0x3, 0x25, 0x33, 0x18, 0x88, - 0xae, 0xa7, 0xa9, 0x8b, 0xa7, 0xba, 0x43, 0x29, 0xb8, 0x2a, - 0x6e, 0x9a, 0x17, 0x6d, 0x47, 0xd1, 0x54, 0xba, 0x11}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x23, 0x79, 0x70, 0x28, 0x23, 0x21, 0x3e, 0xc4, 0x4f, 0xf7, 0x11, 0xb0, - 0xfd, 0x96, 0xee, 0xd6, 0xd8, 0xd4, 0x66, 0xa1, 0x58, 0x6c, 0x9}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1871; - uint8_t client_id_bytes[] = {0x73, 0x3, 0x4e}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x8e, 0xa8, 0x12, 0x5a, 0x7, 0xe5, 0xff, 0xfa, 0xc0, 0xb1, 0x36, 0xac, 0xf0, 0x44, 0x32}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd, 0x89, 0x17, 0x74, 0x52, 0x82, 0x43, 0x2a, 0x11, 0xdf, 0xca, 0xa9, 0x93, 0xc5, 0xe8}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "^t\USER\139\244\152'\220\244", _willMsg = -// "\199\STX\191\&2ISE$\SOH}\221O\DC3,P\242\185\245\181\192\\\237\251p\237\247\198\203", _willProps = []}), -// _cleanSession = False, _keepAlive = 13191, _connID = "\152G\DC3\220\161\183\214\153L\231", _properties = []} -TEST(Connect311QCTest, Encode63) { - uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x33, 0x87, 0x0, 0xa, 0x98, 0x47, 0x13, - 0xdc, 0xa1, 0xb7, 0xd6, 0x99, 0x4c, 0xe7, 0x0, 0xb, 0x5e, 0x74, 0x1f, 0x45, 0x52, 0x8b, 0xf4, 0x98, - 0x27, 0xdc, 0xf4, 0x0, 0x1c, 0xc7, 0x2, 0xbf, 0x32, 0x49, 0x53, 0x45, 0x24, 0x1, 0x7d, 0xdd, 0x4f, - 0x13, 0x2c, 0x50, 0xf2, 0xb9, 0xf5, 0xb5, 0xc0, 0x5c, 0xed, 0xfb, 0x70, 0xed, 0xf7, 0xc6, 0xcb}; - - uint8_t buf[77] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5e, 0x74, 0x1f, 0x45, 0x52, 0x8b, 0xf4, 0x98, 0x27, 0xdc, 0xf4}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc7, 0x2, 0xbf, 0x32, 0x49, 0x53, 0x45, 0x24, 0x1, 0x7d, 0xdd, 0x4f, 0x13, 0x2c, - 0x50, 0xf2, 0xb9, 0xf5, 0xb5, 0xc0, 0x5c, 0xed, 0xfb, 0x70, 0xed, 0xf7, 0xc6, 0xcb}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 13191; - uint8_t client_id_bytes[] = {0x98, 0x47, 0x13, 0xdc, 0xa1, 0xb7, 0xd6, 0x99, 0x4c, 0xe7}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "4\159\162&\FS(\185Vz\159#", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\178\222\199o\DLE`0%\253\145qK;\128\218", _willMsg = -// "\130\&9Pt\tC\201\176\147", _willProps = []}), _cleanSession = False, _keepAlive = 3727, _connID = "\DEL\250\165", -// _properties = []} -TEST(Connect311QCTest, Encode64) { - uint8_t pkt[] = {0x10, 0x2b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0xe, 0x8f, 0x0, 0x3, 0x7f, - 0xfa, 0xa5, 0x0, 0xf, 0xb2, 0xde, 0xc7, 0x6f, 0x10, 0x60, 0x30, 0x25, 0xfd, 0x91, 0x71, - 0x4b, 0x3b, 0x80, 0xda, 0x0, 0x9, 0x82, 0x39, 0x50, 0x74, 0x9, 0x43, 0xc9, 0xb0, 0x93}; - - uint8_t buf[55] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb2, 0xde, 0xc7, 0x6f, 0x10, 0x60, 0x30, 0x25, - 0xfd, 0x91, 0x71, 0x4b, 0x3b, 0x80, 0xda}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x82, 0x39, 0x50, 0x74, 0x9, 0x43, 0xc9, 0xb0, 0x93}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3727; - uint8_t client_id_bytes[] = {0x7f, 0xfa, 0xa5}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x34, 0x9f, 0xa2, 0x26, 0x1c, 0x28, 0xb9, 0x56, 0x7a, 0x9f, 0x23}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\RSt\221\140\178\180\155#r\255\&3\212\203w\206\137L\202\190\SUB G\227\FS", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "~^x\SYN6\181\252#\192\a\231\220>\DC2e\NAK", _willMsg = -// "\202S\US{\160\165\GS\f\165\SUB\183D\191\212\150\157\f\SUBwj\204\SYN\167\237\251\161\189", _willProps = []}), -// _cleanSession = False, _keepAlive = 3670, _connID = "H\SI\178\231o\172\&9\153", _properties = []} -TEST(Connect311QCTest, Encode65) { - uint8_t pkt[] = {0x10, 0x5d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0xe, 0x56, 0x0, 0x8, 0x48, 0xf, - 0xb2, 0xe7, 0x6f, 0xac, 0x39, 0x99, 0x0, 0x10, 0x7e, 0x5e, 0x78, 0x16, 0x36, 0xb5, 0xfc, 0x23, - 0xc0, 0x7, 0xe7, 0xdc, 0x3e, 0x12, 0x65, 0x15, 0x0, 0x1b, 0xca, 0x53, 0x1f, 0x7b, 0xa0, 0xa5, - 0x1d, 0xc, 0xa5, 0x1a, 0xb7, 0x44, 0xbf, 0xd4, 0x96, 0x9d, 0xc, 0x1a, 0x77, 0x6a, 0xcc, 0x16, - 0xa7, 0xed, 0xfb, 0xa1, 0xbd, 0x0, 0x18, 0x1e, 0x74, 0xdd, 0x8c, 0xb2, 0xb4, 0x9b, 0x23, 0x72, - 0xff, 0x33, 0xd4, 0xcb, 0x77, 0xce, 0x89, 0x4c, 0xca, 0xbe, 0x1a, 0x20, 0x47, 0xe3, 0x1c}; - - uint8_t buf[105] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x7e, 0x5e, 0x78, 0x16, 0x36, 0xb5, 0xfc, 0x23, - 0xc0, 0x7, 0xe7, 0xdc, 0x3e, 0x12, 0x65, 0x15}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xca, 0x53, 0x1f, 0x7b, 0xa0, 0xa5, 0x1d, 0xc, 0xa5, 0x1a, 0xb7, 0x44, 0xbf, 0xd4, - 0x96, 0x9d, 0xc, 0x1a, 0x77, 0x6a, 0xcc, 0x16, 0xa7, 0xed, 0xfb, 0xa1, 0xbd}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3670; - uint8_t client_id_bytes[] = {0x48, 0xf, 0xb2, 0xe7, 0x6f, 0xac, 0x39, 0x99}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x1e, 0x74, 0xdd, 0x8c, 0xb2, 0xb4, 0x9b, 0x23, 0x72, 0xff, 0x33, 0xd4, - 0xcb, 0x77, 0xce, 0x89, 0x4c, 0xca, 0xbe, 0x1a, 0x20, 0x47, 0xe3, 0x1c}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\DC1M\180\r\a\252wp^bZ\135\DEL2@Z\253\165\DC2y\209\226r]\164", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "a\214\153~t\218\159\237r\222\195'\246(\175", _willMsg = "\224\207\248\\\EM\EM/u\n7rM\210", _willProps = []}), -// _cleanSession = True, _keepAlive = 15606, _connID = -// "\DC2O:m\245\197\216\200\\\t\162\221\172w\235d1\138\240\144\RSX%\208C\SOPC\199", _properties = []} -TEST(Connect311QCTest, Encode66) { - uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x3c, 0xf6, 0x0, 0x1d, 0x12, - 0x4f, 0x3a, 0x6d, 0xf5, 0xc5, 0xd8, 0xc8, 0x5c, 0x9, 0xa2, 0xdd, 0xac, 0x77, 0xeb, 0x64, - 0x31, 0x8a, 0xf0, 0x90, 0x1e, 0x58, 0x25, 0xd0, 0x43, 0xe, 0x50, 0x43, 0xc7, 0x0, 0xf, - 0x61, 0xd6, 0x99, 0x7e, 0x74, 0xda, 0x9f, 0xed, 0x72, 0xde, 0xc3, 0x27, 0xf6, 0x28, 0xaf, - 0x0, 0xd, 0xe0, 0xcf, 0xf8, 0x5c, 0x19, 0x19, 0x2f, 0x75, 0xa, 0x37, 0x72, 0x4d, 0xd2}; - - uint8_t buf[85] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x61, 0xd6, 0x99, 0x7e, 0x74, 0xda, 0x9f, 0xed, - 0x72, 0xde, 0xc3, 0x27, 0xf6, 0x28, 0xaf}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe0, 0xcf, 0xf8, 0x5c, 0x19, 0x19, 0x2f, 0x75, 0xa, 0x37, 0x72, 0x4d, 0xd2}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 15606; - uint8_t client_id_bytes[] = {0x12, 0x4f, 0x3a, 0x6d, 0xf5, 0xc5, 0xd8, 0xc8, 0x5c, 0x9, 0xa2, 0xdd, 0xac, 0x77, 0xeb, - 0x64, 0x31, 0x8a, 0xf0, 0x90, 0x1e, 0x58, 0x25, 0xd0, 0x43, 0xe, 0x50, 0x43, 0xc7}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x11, 0x4d, 0xb4, 0xd, 0x7, 0xfc, 0x77, 0x70, 0x5e, 0x62, 0x5a, 0x87, 0x7f, - 0x32, 0x40, 0x5a, 0xfd, 0xa5, 0x12, 0x79, 0xd1, 0xe2, 0x72, 0x5d, 0xa4}; - lwmqtt_string_t password = {25, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "7y&\a\226\163R-*\143C\172?T4\174\227\&4$\202\150\&2\DLE\231\243", _password = -// Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = 6271, _connID = -// "\193=\232\&0\251\248\&3\179\238?E\142", _properties = []} -TEST(Connect311QCTest, Encode67) { - uint8_t pkt[] = {0x10, 0x33, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x82, 0x18, 0x7f, 0x0, 0xc, - 0xc1, 0x3d, 0xe8, 0x30, 0xfb, 0xf8, 0x33, 0xb3, 0xee, 0x3f, 0x45, 0x8e, 0x0, 0x19, - 0x37, 0x79, 0x26, 0x7, 0xe2, 0xa3, 0x52, 0x2d, 0x2a, 0x8f, 0x43, 0xac, 0x3f, 0x54, - 0x34, 0xae, 0xe3, 0x34, 0x24, 0xca, 0x96, 0x32, 0x10, 0xe7, 0xf3}; - - uint8_t buf[63] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 6271; - uint8_t client_id_bytes[] = {0xc1, 0x3d, 0xe8, 0x30, 0xfb, 0xf8, 0x33, 0xb3, 0xee, 0x3f, 0x45, 0x8e}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x37, 0x79, 0x26, 0x7, 0xe2, 0xa3, 0x52, 0x2d, 0x2a, 0x8f, 0x43, 0xac, 0x3f, - 0x54, 0x34, 0xae, 0xe3, 0x34, 0x24, 0xca, 0x96, 0x32, 0x10, 0xe7, 0xf3}; - lwmqtt_string_t username = {25, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\NAK=\230S\192\217KW\211\176\174\190\213\179a\138\ENQR\222", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\218\251\CAN\137\184\196\247\&0u\SYNZ", _willMsg = "\140\162\226\246\\\158,\b\141\157Z$+", _willProps = []}), -// _cleanSession = False, _keepAlive = 18470, _connID = -// "\145\177\179\193o\203\219\238Y:\131\b\140\246\195\211\214\210p\177", _properties = []} -TEST(Connect311QCTest, Encode68) { - uint8_t pkt[] = {0x10, 0x3c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0x48, 0x26, 0x0, 0x14, 0x91, 0xb1, - 0xb3, 0xc1, 0x6f, 0xcb, 0xdb, 0xee, 0x59, 0x3a, 0x83, 0x8, 0x8c, 0xf6, 0xc3, 0xd3, 0xd6, 0xd2, - 0x70, 0xb1, 0x0, 0xb, 0xda, 0xfb, 0x18, 0x89, 0xb8, 0xc4, 0xf7, 0x30, 0x75, 0x16, 0x5a, 0x0, - 0xd, 0x8c, 0xa2, 0xe2, 0xf6, 0x5c, 0x9e, 0x2c, 0x8, 0x8d, 0x9d, 0x5a, 0x24, 0x2b}; - - uint8_t buf[72] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xda, 0xfb, 0x18, 0x89, 0xb8, 0xc4, 0xf7, 0x30, 0x75, 0x16, 0x5a}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x8c, 0xa2, 0xe2, 0xf6, 0x5c, 0x9e, 0x2c, 0x8, 0x8d, 0x9d, 0x5a, 0x24, 0x2b}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 18470; - uint8_t client_id_bytes[] = {0x91, 0xb1, 0xb3, 0xc1, 0x6f, 0xcb, 0xdb, 0xee, 0x59, 0x3a, - 0x83, 0x8, 0x8c, 0xf6, 0xc3, 0xd3, 0xd6, 0xd2, 0x70, 0xb1}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x15, 0x3d, 0xe6, 0x53, 0xc0, 0xd9, 0x4b, 0x57, 0xd3, 0xb0, - 0xae, 0xbe, 0xd5, 0xb3, 0x61, 0x8a, 0x5, 0x52, 0xde}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\SOH\253\128h\214\136>\244<\255\153", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "n\221.g\231\209[a*n'\214al\147\241$\175'-J\140\217\175\152\130\155\232", _willMsg = -// "\US\161\236\DC2\138\211_\ESC\244", _willProps = []}), _cleanSession = True, _keepAlive = 9181, _connID = -// "M\156\DC4\133Z\205\NAK&", _properties = []} -TEST(Connect311QCTest, Encode69) { - uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x23, 0xdd, 0x0, 0x8, 0x4d, 0x9c, - 0x14, 0x85, 0x5a, 0xcd, 0x15, 0x26, 0x0, 0x1c, 0x6e, 0xdd, 0x2e, 0x67, 0xe7, 0xd1, 0x5b, 0x61, - 0x2a, 0x6e, 0x27, 0xd6, 0x61, 0x6c, 0x93, 0xf1, 0x24, 0xaf, 0x27, 0x2d, 0x4a, 0x8c, 0xd9, 0xaf, - 0x98, 0x82, 0x9b, 0xe8, 0x0, 0x9, 0x1f, 0xa1, 0xec, 0x12, 0x8a, 0xd3, 0x5f, 0x1b, 0xf4}; - - uint8_t buf[73] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6e, 0xdd, 0x2e, 0x67, 0xe7, 0xd1, 0x5b, 0x61, 0x2a, 0x6e, 0x27, 0xd6, 0x61, 0x6c, - 0x93, 0xf1, 0x24, 0xaf, 0x27, 0x2d, 0x4a, 0x8c, 0xd9, 0xaf, 0x98, 0x82, 0x9b, 0xe8}; - lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1f, 0xa1, 0xec, 0x12, 0x8a, 0xd3, 0x5f, 0x1b, 0xf4}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 9181; - uint8_t client_id_bytes[] = {0x4d, 0x9c, 0x14, 0x85, 0x5a, 0xcd, 0x15, 0x26}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x1, 0xfd, 0x80, 0x68, 0xd6, 0x88, 0x3e, 0xf4, 0x3c, 0xff, 0x99}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\227\ESCQ", _password = Just "\231\239\188\247\236\FSU\172\t\232D", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "(7<,XJ9\ETB\231t\245\245\214\208\FSj\131", -// _willMsg = "", _willProps = []}), _cleanSession = False, _keepAlive = 70, _connID = -// "\226\&9\142F\US\236\161\186\252\236\147\229\210E\130\EMh\128\129\DC3axe\165\179\238Vi\169\245", _properties = []} -TEST(Connect311QCTest, Encode70) { - uint8_t pkt[] = {0x10, 0x51, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x0, 0x46, 0x0, 0x1e, 0xe2, 0x39, 0x8e, - 0x46, 0x1f, 0xec, 0xa1, 0xba, 0xfc, 0xec, 0x93, 0xe5, 0xd2, 0x45, 0x82, 0x19, 0x68, 0x80, 0x81, 0x13, - 0x61, 0x78, 0x65, 0xa5, 0xb3, 0xee, 0x56, 0x69, 0xa9, 0xf5, 0x0, 0x11, 0x28, 0x37, 0x3c, 0x2c, 0x58, - 0x4a, 0x39, 0x17, 0xe7, 0x74, 0xf5, 0xf5, 0xd6, 0xd0, 0x1c, 0x6a, 0x83, 0x0, 0x0, 0x0, 0x3, 0xe3, - 0x1b, 0x51, 0x0, 0xb, 0xe7, 0xef, 0xbc, 0xf7, 0xec, 0x1c, 0x55, 0xac, 0x9, 0xe8, 0x44}; - - uint8_t buf[93] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x28, 0x37, 0x3c, 0x2c, 0x58, 0x4a, 0x39, 0x17, 0xe7, - 0x74, 0xf5, 0xf5, 0xd6, 0xd0, 0x1c, 0x6a, 0x83}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 70; - uint8_t client_id_bytes[] = {0xe2, 0x39, 0x8e, 0x46, 0x1f, 0xec, 0xa1, 0xba, 0xfc, 0xec, - 0x93, 0xe5, 0xd2, 0x45, 0x82, 0x19, 0x68, 0x80, 0x81, 0x13, - 0x61, 0x78, 0x65, 0xa5, 0xb3, 0xee, 0x56, 0x69, 0xa9, 0xf5}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xe3, 0x1b, 0x51}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe7, 0xef, 0xbc, 0xf7, 0xec, 0x1c, 0x55, 0xac, 0x9, 0xe8, 0x44}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\a.\173\189\187\192\&5\DC1\242@\ETXGI\174r\189\191\213\CAN4\233\SOH\196", _password -// = Just "i\DC1lU\210\253\204\211\224\DC4\228", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, -// _willTopic = "\CAN\228\137ea\b\DC1\230\188B\b\185\161\213\250:\214\RSLYL\193\157K\189R~", _willMsg = -// "^\188x\173\231\249S\128\&9\STX%\133l\173s\135{F\221\169T\254", _willProps = []}), _cleanSession = False, _keepAlive -// = 3405, _connID = "\229sD\131\227v\232^4n0", _properties = []} -TEST(Connect311QCTest, Encode71) { - uint8_t pkt[] = {0x10, 0x72, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0xd, 0x4d, 0x0, 0xb, 0xe5, 0x73, 0x44, - 0x83, 0xe3, 0x76, 0xe8, 0x5e, 0x34, 0x6e, 0x30, 0x0, 0x1b, 0x18, 0xe4, 0x89, 0x65, 0x61, 0x8, 0x11, - 0xe6, 0xbc, 0x42, 0x8, 0xb9, 0xa1, 0xd5, 0xfa, 0x3a, 0xd6, 0x1e, 0x4c, 0x59, 0x4c, 0xc1, 0x9d, 0x4b, - 0xbd, 0x52, 0x7e, 0x0, 0x16, 0x5e, 0xbc, 0x78, 0xad, 0xe7, 0xf9, 0x53, 0x80, 0x39, 0x2, 0x25, 0x85, - 0x6c, 0xad, 0x73, 0x87, 0x7b, 0x46, 0xdd, 0xa9, 0x54, 0xfe, 0x0, 0x17, 0x7, 0x2e, 0xad, 0xbd, 0xbb, - 0xc0, 0x35, 0x11, 0xf2, 0x40, 0x3, 0x47, 0x49, 0xae, 0x72, 0xbd, 0xbf, 0xd5, 0x18, 0x34, 0xe9, 0x1, - 0xc4, 0x0, 0xb, 0x69, 0x11, 0x6c, 0x55, 0xd2, 0xfd, 0xcc, 0xd3, 0xe0, 0x14, 0xe4}; - - uint8_t buf[126] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x18, 0xe4, 0x89, 0x65, 0x61, 0x8, 0x11, 0xe6, 0xbc, 0x42, 0x8, 0xb9, 0xa1, 0xd5, - 0xfa, 0x3a, 0xd6, 0x1e, 0x4c, 0x59, 0x4c, 0xc1, 0x9d, 0x4b, 0xbd, 0x52, 0x7e}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5e, 0xbc, 0x78, 0xad, 0xe7, 0xf9, 0x53, 0x80, 0x39, 0x2, 0x25, - 0x85, 0x6c, 0xad, 0x73, 0x87, 0x7b, 0x46, 0xdd, 0xa9, 0x54, 0xfe}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3405; - uint8_t client_id_bytes[] = {0xe5, 0x73, 0x44, 0x83, 0xe3, 0x76, 0xe8, 0x5e, 0x34, 0x6e, 0x30}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x7, 0x2e, 0xad, 0xbd, 0xbb, 0xc0, 0x35, 0x11, 0xf2, 0x40, 0x3, 0x47, - 0x49, 0xae, 0x72, 0xbd, 0xbf, 0xd5, 0x18, 0x34, 0xe9, 0x1, 0xc4}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x69, 0x11, 0x6c, 0x55, 0xd2, 0xfd, 0xcc, 0xd3, 0xe0, 0x14, 0xe4}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "a", _password = Just "@\CAN\194hS*r\ESC'\162\SUB\222P\218g\250\&5\aN\nf\ETX\246", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\135!\172j\177\193\187\202+&FH\SO", -// _willMsg = "g\144@\161F\215\147>\217\b\228\146\186\ETB\234\252\208\201", _willProps = []}), _cleanSession = True, -// _keepAlive = 19693, _connID = "\140\204\191\171.BtU+cj", _properties = []} -TEST(Connect311QCTest, Encode72) { - uint8_t pkt[] = {0x10, 0x56, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x4c, 0xed, 0x0, 0xb, 0x8c, - 0xcc, 0xbf, 0xab, 0x2e, 0x42, 0x74, 0x55, 0x2b, 0x63, 0x6a, 0x0, 0xd, 0x87, 0x21, 0xac, - 0x6a, 0xb1, 0xc1, 0xbb, 0xca, 0x2b, 0x26, 0x46, 0x48, 0xe, 0x0, 0x12, 0x67, 0x90, 0x40, - 0xa1, 0x46, 0xd7, 0x93, 0x3e, 0xd9, 0x8, 0xe4, 0x92, 0xba, 0x17, 0xea, 0xfc, 0xd0, 0xc9, - 0x0, 0x1, 0x61, 0x0, 0x17, 0x40, 0x18, 0xc2, 0x68, 0x53, 0x2a, 0x72, 0x1b, 0x27, 0xa2, - 0x1a, 0xde, 0x50, 0xda, 0x67, 0xfa, 0x35, 0x7, 0x4e, 0xa, 0x66, 0x3, 0xf6}; - - uint8_t buf[98] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x87, 0x21, 0xac, 0x6a, 0xb1, 0xc1, 0xbb, 0xca, 0x2b, 0x26, 0x46, 0x48, 0xe}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x67, 0x90, 0x40, 0xa1, 0x46, 0xd7, 0x93, 0x3e, 0xd9, - 0x8, 0xe4, 0x92, 0xba, 0x17, 0xea, 0xfc, 0xd0, 0xc9}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 19693; - uint8_t client_id_bytes[] = {0x8c, 0xcc, 0xbf, 0xab, 0x2e, 0x42, 0x74, 0x55, 0x2b, 0x63, 0x6a}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x61}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x40, 0x18, 0xc2, 0x68, 0x53, 0x2a, 0x72, 0x1b, 0x27, 0xa2, 0x1a, 0xde, - 0x50, 0xda, 0x67, 0xfa, 0x35, 0x7, 0x4e, 0xa, 0x66, 0x3, 0xf6}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\172\219m,\215\&1j\218 -// $\179\198q\177c\172\251|\145\151)\ACKk\199\226\192\131\161\SO", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS1, _willTopic = "\253X\142\n\160\NUL\146\171ng\\\NAK\186Q\142\165\NUL\ETX6\212\255d\134|\252\181!av)", -// _willMsg = "}1\182T-u\251\128", _willProps = []}), _cleanSession = False, _keepAlive = 12479, _connID = -// "\160\198\DC2f\138Q\188Q\138!y\131\141\&4\255\149\228$=Tx\SOHa\231", _properties = []} -TEST(Connect311QCTest, Encode73) { - uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x30, 0xbf, 0x0, 0x18, 0xa0, 0xc6, - 0x12, 0x66, 0x8a, 0x51, 0xbc, 0x51, 0x8a, 0x21, 0x79, 0x83, 0x8d, 0x34, 0xff, 0x95, 0xe4, 0x24, - 0x3d, 0x54, 0x78, 0x1, 0x61, 0xe7, 0x0, 0x1e, 0xfd, 0x58, 0x8e, 0xa, 0xa0, 0x0, 0x92, 0xab, - 0x6e, 0x67, 0x5c, 0x15, 0xba, 0x51, 0x8e, 0xa5, 0x0, 0x3, 0x36, 0xd4, 0xff, 0x64, 0x86, 0x7c, - 0xfc, 0xb5, 0x21, 0x61, 0x76, 0x29, 0x0, 0x8, 0x7d, 0x31, 0xb6, 0x54, 0x2d, 0x75, 0xfb, 0x80}; - - uint8_t buf[90] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xfd, 0x58, 0x8e, 0xa, 0xa0, 0x0, 0x92, 0xab, 0x6e, 0x67, - 0x5c, 0x15, 0xba, 0x51, 0x8e, 0xa5, 0x0, 0x3, 0x36, 0xd4, - 0xff, 0x64, 0x86, 0x7c, 0xfc, 0xb5, 0x21, 0x61, 0x76, 0x29}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7d, 0x31, 0xb6, 0x54, 0x2d, 0x75, 0xfb, 0x80}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12479; - uint8_t client_id_bytes[] = {0xa0, 0xc6, 0x12, 0x66, 0x8a, 0x51, 0xbc, 0x51, 0x8a, 0x21, 0x79, 0x83, - 0x8d, 0x34, 0xff, 0x95, 0xe4, 0x24, 0x3d, 0x54, 0x78, 0x1, 0x61, 0xe7}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xac, 0xdb, 0x6d, 0x2c, 0xd7, 0x31, 0x6a, 0xda, 0x20, 0x24, 0xb3, 0xc6, 0x71, 0xb1, 0x63, - 0xac, 0xfb, 0x7c, 0x91, 0x97, 0x29, 0x6, 0x6b, 0xc7, 0xe2, 0xc0, 0x83, 0xa1, 0xe}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\186>\208\176\160\b\130H\DC3\FS\nw@\180M\223\f}~\163s\234_", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "h ", _willMsg = -// "\136Jb\133\241\194\237\174\234.J\DEL\213\CAN\189A\167\182", _willProps = []}), _cleanSession = False, _keepAlive = -// 15269, _connID = "\151O\SUBd\191\216\184\130k$\237[9\159\\\STX\130\196~\DLE\222\ESC\198}\157\129w\n", _properties = -// []} -TEST(Connect311QCTest, Encode74) { - uint8_t pkt[] = {0x10, 0x59, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x94, 0x3b, 0xa5, 0x0, 0x1c, 0x97, 0x4f, - 0x1a, 0x64, 0xbf, 0xd8, 0xb8, 0x82, 0x6b, 0x24, 0xed, 0x5b, 0x39, 0x9f, 0x5c, 0x2, 0x82, 0xc4, - 0x7e, 0x10, 0xde, 0x1b, 0xc6, 0x7d, 0x9d, 0x81, 0x77, 0xa, 0x0, 0x2, 0x68, 0x20, 0x0, 0x12, - 0x88, 0x4a, 0x62, 0x85, 0xf1, 0xc2, 0xed, 0xae, 0xea, 0x2e, 0x4a, 0x7f, 0xd5, 0x18, 0xbd, 0x41, - 0xa7, 0xb6, 0x0, 0x17, 0xba, 0x3e, 0xd0, 0xb0, 0xa0, 0x8, 0x82, 0x48, 0x13, 0x1c, 0xa, 0x77, - 0x40, 0xb4, 0x4d, 0xdf, 0xc, 0x7d, 0x7e, 0xa3, 0x73, 0xea, 0x5f}; - - uint8_t buf[101] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x68, 0x20}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x88, 0x4a, 0x62, 0x85, 0xf1, 0xc2, 0xed, 0xae, 0xea, - 0x2e, 0x4a, 0x7f, 0xd5, 0x18, 0xbd, 0x41, 0xa7, 0xb6}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 15269; - uint8_t client_id_bytes[] = {0x97, 0x4f, 0x1a, 0x64, 0xbf, 0xd8, 0xb8, 0x82, 0x6b, 0x24, 0xed, 0x5b, 0x39, 0x9f, - 0x5c, 0x2, 0x82, 0xc4, 0x7e, 0x10, 0xde, 0x1b, 0xc6, 0x7d, 0x9d, 0x81, 0x77, 0xa}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xba, 0x3e, 0xd0, 0xb0, 0xa0, 0x8, 0x82, 0x48, 0x13, 0x1c, 0xa, 0x77, - 0x40, 0xb4, 0x4d, 0xdf, 0xc, 0x7d, 0x7e, 0xa3, 0x73, 0xea, 0x5f}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "%_f0P\185\133\159\152\SOH\185\161\133\186\242\&0'", _password = Just -// "\166\165\148d\NAKy%\142\222\189,", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\222\254\185A\161\232i\ACK\180Z\146\192\254\182-\206\&8H\211\132", _willMsg = -// "\218\212\ACK\ESC\DC2_y\169\196A\228\195N\209;\219\138G\r\GS", _willProps = []}), _cleanSession = True, _keepAlive = -// 20166, _connID = "\ETBG\233\139e\tY\235MPwMH\208", _properties = []} -TEST(Connect311QCTest, Encode75) { - uint8_t pkt[] = {0x10, 0x66, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x4e, 0xc6, 0x0, 0xe, 0x17, - 0x47, 0xe9, 0x8b, 0x65, 0x9, 0x59, 0xeb, 0x4d, 0x50, 0x77, 0x4d, 0x48, 0xd0, 0x0, 0x14, - 0xde, 0xfe, 0xb9, 0x41, 0xa1, 0xe8, 0x69, 0x6, 0xb4, 0x5a, 0x92, 0xc0, 0xfe, 0xb6, 0x2d, - 0xce, 0x38, 0x48, 0xd3, 0x84, 0x0, 0x14, 0xda, 0xd4, 0x6, 0x1b, 0x12, 0x5f, 0x79, 0xa9, - 0xc4, 0x41, 0xe4, 0xc3, 0x4e, 0xd1, 0x3b, 0xdb, 0x8a, 0x47, 0xd, 0x1d, 0x0, 0x11, 0x25, - 0x5f, 0x66, 0x30, 0x50, 0xb9, 0x85, 0x9f, 0x98, 0x1, 0xb9, 0xa1, 0x85, 0xba, 0xf2, 0x30, - 0x27, 0x0, 0xb, 0xa6, 0xa5, 0x94, 0x64, 0x15, 0x79, 0x25, 0x8e, 0xde, 0xbd, 0x2c}; - - uint8_t buf[114] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xde, 0xfe, 0xb9, 0x41, 0xa1, 0xe8, 0x69, 0x6, 0xb4, 0x5a, - 0x92, 0xc0, 0xfe, 0xb6, 0x2d, 0xce, 0x38, 0x48, 0xd3, 0x84}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xda, 0xd4, 0x6, 0x1b, 0x12, 0x5f, 0x79, 0xa9, 0xc4, 0x41, - 0xe4, 0xc3, 0x4e, 0xd1, 0x3b, 0xdb, 0x8a, 0x47, 0xd, 0x1d}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 20166; - uint8_t client_id_bytes[] = {0x17, 0x47, 0xe9, 0x8b, 0x65, 0x9, 0x59, 0xeb, 0x4d, 0x50, 0x77, 0x4d, 0x48, 0xd0}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x25, 0x5f, 0x66, 0x30, 0x50, 0xb9, 0x85, 0x9f, 0x98, - 0x1, 0xb9, 0xa1, 0x85, 0xba, 0xf2, 0x30, 0x27}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xa6, 0xa5, 0x94, 0x64, 0x15, 0x79, 0x25, 0x8e, 0xde, 0xbd, 0x2c}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\172\206\237\DLE\254_Q2\226B'S\147k\177*D!\230\185<\130", _password = Just -// ".\STX\240p\196\191\165l\140\230\214\188\253\220\166\224I\197\241\153&3;\249", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS0, _willTopic = "\DC1o\221b\189\141f\242\228\CAN\219\141,e\230\221\166\&7Ar\GS", -// _willMsg = "", _willProps = []}), _cleanSession = False, _keepAlive = 20633, _connID = -// "x]*\241\253\180\253\181\DC4%\n\245\187\"\138\DLE\212b\182\171\131J\193\&0\176C", _properties = []} -TEST(Connect311QCTest, Encode76) { - uint8_t pkt[] = {0x10, 0x71, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x50, 0x99, 0x0, 0x1a, 0x78, 0x5d, 0x2a, - 0xf1, 0xfd, 0xb4, 0xfd, 0xb5, 0x14, 0x25, 0xa, 0xf5, 0xbb, 0x22, 0x8a, 0x10, 0xd4, 0x62, 0xb6, 0xab, - 0x83, 0x4a, 0xc1, 0x30, 0xb0, 0x43, 0x0, 0x15, 0x11, 0x6f, 0xdd, 0x62, 0xbd, 0x8d, 0x66, 0xf2, 0xe4, - 0x18, 0xdb, 0x8d, 0x2c, 0x65, 0xe6, 0xdd, 0xa6, 0x37, 0x41, 0x72, 0x1d, 0x0, 0x0, 0x0, 0x16, 0xac, - 0xce, 0xed, 0x10, 0xfe, 0x5f, 0x51, 0x32, 0xe2, 0x42, 0x27, 0x53, 0x93, 0x6b, 0xb1, 0x2a, 0x44, 0x21, - 0xe6, 0xb9, 0x3c, 0x82, 0x0, 0x18, 0x2e, 0x2, 0xf0, 0x70, 0xc4, 0xbf, 0xa5, 0x6c, 0x8c, 0xe6, 0xd6, - 0xbc, 0xfd, 0xdc, 0xa6, 0xe0, 0x49, 0xc5, 0xf1, 0x99, 0x26, 0x33, 0x3b, 0xf9}; - - uint8_t buf[125] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x11, 0x6f, 0xdd, 0x62, 0xbd, 0x8d, 0x66, 0xf2, 0xe4, 0x18, 0xdb, - 0x8d, 0x2c, 0x65, 0xe6, 0xdd, 0xa6, 0x37, 0x41, 0x72, 0x1d}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 20633; - uint8_t client_id_bytes[] = {0x78, 0x5d, 0x2a, 0xf1, 0xfd, 0xb4, 0xfd, 0xb5, 0x14, 0x25, 0xa, 0xf5, 0xbb, - 0x22, 0x8a, 0x10, 0xd4, 0x62, 0xb6, 0xab, 0x83, 0x4a, 0xc1, 0x30, 0xb0, 0x43}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xac, 0xce, 0xed, 0x10, 0xfe, 0x5f, 0x51, 0x32, 0xe2, 0x42, 0x27, - 0x53, 0x93, 0x6b, 0xb1, 0x2a, 0x44, 0x21, 0xe6, 0xb9, 0x3c, 0x82}; - lwmqtt_string_t username = {22, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x2e, 0x2, 0xf0, 0x70, 0xc4, 0xbf, 0xa5, 0x6c, 0x8c, 0xe6, 0xd6, 0xbc, - 0xfd, 0xdc, 0xa6, 0xe0, 0x49, 0xc5, 0xf1, 0x99, 0x26, 0x33, 0x3b, 0xf9}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "z@\a", _password = Just "\253\197(\t}\238J\253\251\192\135j", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\129B\175B", _willMsg = "S\233k'\183[ryq\189X\218", -// _willProps = []}), _cleanSession = False, _keepAlive = 32764, _connID = "d\173\189", _properties = []} -TEST(Connect311QCTest, Encode77) { - uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x7f, 0xfc, 0x0, 0x3, - 0x64, 0xad, 0xbd, 0x0, 0x4, 0x81, 0x42, 0xaf, 0x42, 0x0, 0xc, 0x53, 0xe9, 0x6b, - 0x27, 0xb7, 0x5b, 0x72, 0x79, 0x71, 0xbd, 0x58, 0xda, 0x0, 0x3, 0x7a, 0x40, 0x7, - 0x0, 0xc, 0xfd, 0xc5, 0x28, 0x9, 0x7d, 0xee, 0x4a, 0xfd, 0xfb, 0xc0, 0x87, 0x6a}; - - uint8_t buf[66] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x81, 0x42, 0xaf, 0x42}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x53, 0xe9, 0x6b, 0x27, 0xb7, 0x5b, 0x72, 0x79, 0x71, 0xbd, 0x58, 0xda}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32764; - uint8_t client_id_bytes[] = {0x64, 0xad, 0xbd}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x7a, 0x40, 0x7}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xfd, 0xc5, 0x28, 0x9, 0x7d, 0xee, 0x4a, 0xfd, 0xfb, 0xc0, 0x87, 0x6a}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "vo\255\134\EM\214ra~\221QTH]\236\&1\203\133f\193%", _password = Nothing, _lastWill -// = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\143\219\228T\SIP\210\NULp\216b\230\191\b\DC1\190\218\139\178\174\179\138\176z", _willMsg = -// "\\\196Q\224Q\138\232\DC4\230u\194\&6\147\197\138o\202\247&\180\179\RSB,\244\153h\STX", _willProps = []}), -// _cleanSession = False, _keepAlive = 18519, _connID = "cX\140\&9\221\ETXY\131\GS", _properties = []} -TEST(Connect311QCTest, Encode78) { - uint8_t pkt[] = {0x10, 0x64, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0x48, 0x57, 0x0, 0x9, 0x63, - 0x58, 0x8c, 0x39, 0xdd, 0x3, 0x59, 0x83, 0x1d, 0x0, 0x18, 0x8f, 0xdb, 0xe4, 0x54, 0xf, - 0x50, 0xd2, 0x0, 0x70, 0xd8, 0x62, 0xe6, 0xbf, 0x8, 0x11, 0xbe, 0xda, 0x8b, 0xb2, 0xae, - 0xb3, 0x8a, 0xb0, 0x7a, 0x0, 0x1c, 0x5c, 0xc4, 0x51, 0xe0, 0x51, 0x8a, 0xe8, 0x14, 0xe6, - 0x75, 0xc2, 0x36, 0x93, 0xc5, 0x8a, 0x6f, 0xca, 0xf7, 0x26, 0xb4, 0xb3, 0x1e, 0x42, 0x2c, - 0xf4, 0x99, 0x68, 0x2, 0x0, 0x15, 0x76, 0x6f, 0xff, 0x86, 0x19, 0xd6, 0x72, 0x61, 0x7e, - 0xdd, 0x51, 0x54, 0x48, 0x5d, 0xec, 0x31, 0xcb, 0x85, 0x66, 0xc1, 0x25}; - - uint8_t buf[112] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8f, 0xdb, 0xe4, 0x54, 0xf, 0x50, 0xd2, 0x0, 0x70, 0xd8, 0x62, 0xe6, - 0xbf, 0x8, 0x11, 0xbe, 0xda, 0x8b, 0xb2, 0xae, 0xb3, 0x8a, 0xb0, 0x7a}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5c, 0xc4, 0x51, 0xe0, 0x51, 0x8a, 0xe8, 0x14, 0xe6, 0x75, 0xc2, 0x36, 0x93, 0xc5, - 0x8a, 0x6f, 0xca, 0xf7, 0x26, 0xb4, 0xb3, 0x1e, 0x42, 0x2c, 0xf4, 0x99, 0x68, 0x2}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 18519; - uint8_t client_id_bytes[] = {0x63, 0x58, 0x8c, 0x39, 0xdd, 0x3, 0x59, 0x83, 0x1d}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x76, 0x6f, 0xff, 0x86, 0x19, 0xd6, 0x72, 0x61, 0x7e, 0xdd, 0x51, - 0x54, 0x48, 0x5d, 0xec, 0x31, 0xcb, 0x85, 0x66, 0xc1, 0x25}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just -// "\157\ETB\161\194\193\144\143\222H\bK\137S\211\183P\248e#\158\140\132\232~", _lastWill = Just (LastWill {_willRetain -// = True, _willQoS = QoS0, _willTopic = "\234\218\131\206!/\185r4\200\241\199\174\200\229", _willMsg = -// "?\198\253\173(", _willProps = []}), _cleanSession = True, _keepAlive = 5462, _connID = -// "~Zt\220\FS\b\166{\135\185\244Q\248@\a^", _properties = []} -TEST(Connect311QCTest, Encode79) { - uint8_t pkt[] = {0x10, 0x34, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x15, 0x56, 0x0, 0x10, - 0x7e, 0x5a, 0x74, 0xdc, 0x1c, 0x8, 0xa6, 0x7b, 0x87, 0xb9, 0xf4, 0x51, 0xf8, 0x40, - 0x7, 0x5e, 0x0, 0xf, 0xea, 0xda, 0x83, 0xce, 0x21, 0x2f, 0xb9, 0x72, 0x34, 0xc8, - 0xf1, 0xc7, 0xae, 0xc8, 0xe5, 0x0, 0x5, 0x3f, 0xc6, 0xfd, 0xad, 0x28}; - - uint8_t buf[64] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xea, 0xda, 0x83, 0xce, 0x21, 0x2f, 0xb9, 0x72, - 0x34, 0xc8, 0xf1, 0xc7, 0xae, 0xc8, 0xe5}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3f, 0xc6, 0xfd, 0xad, 0x28}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 5462; - uint8_t client_id_bytes[] = {0x7e, 0x5a, 0x74, 0xdc, 0x1c, 0x8, 0xa6, 0x7b, - 0x87, 0xb9, 0xf4, 0x51, 0xf8, 0x40, 0x7, 0x5e}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x9d, 0x17, 0xa1, 0xc2, 0xc1, 0x90, 0x8f, 0xde, 0x48, 0x8, 0x4b, 0x89, - 0x53, 0xd3, 0xb7, 0x50, 0xf8, 0x65, 0x23, 0x9e, 0x8c, 0x84, 0xe8, 0x7e}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\147{'Z\192?r8#\DLEU\192\236\160\237v\192p\NUL\171;\EOT", _password = Just -// "\160J\202\185\172\&2\153\200\SYN\a\130n\179\133f\207\&5\n8\245\n\144\220", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS0, _willTopic = "\145K\248\242\218\139\203", _willMsg = -// "\166\252\SI\215\181\NUL\150dX7\178\210", _willProps = []}), _cleanSession = True, _keepAlive = 25664, _connID = -// "\GS\225\&4\DC4\182", _properties = []} -TEST(Connect311QCTest, Encode80) { - uint8_t pkt[] = {0x10, 0x59, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x64, 0x40, 0x0, 0x5, 0x1d, 0xe1, - 0x34, 0x14, 0xb6, 0x0, 0x7, 0x91, 0x4b, 0xf8, 0xf2, 0xda, 0x8b, 0xcb, 0x0, 0xc, 0xa6, 0xfc, - 0xf, 0xd7, 0xb5, 0x0, 0x96, 0x64, 0x58, 0x37, 0xb2, 0xd2, 0x0, 0x16, 0x93, 0x7b, 0x27, 0x5a, - 0xc0, 0x3f, 0x72, 0x38, 0x23, 0x10, 0x55, 0xc0, 0xec, 0xa0, 0xed, 0x76, 0xc0, 0x70, 0x0, 0xab, - 0x3b, 0x4, 0x0, 0x17, 0xa0, 0x4a, 0xca, 0xb9, 0xac, 0x32, 0x99, 0xc8, 0x16, 0x7, 0x82, 0x6e, - 0xb3, 0x85, 0x66, 0xcf, 0x35, 0xa, 0x38, 0xf5, 0xa, 0x90, 0xdc}; - - uint8_t buf[101] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x91, 0x4b, 0xf8, 0xf2, 0xda, 0x8b, 0xcb}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa6, 0xfc, 0xf, 0xd7, 0xb5, 0x0, 0x96, 0x64, 0x58, 0x37, 0xb2, 0xd2}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 25664; - uint8_t client_id_bytes[] = {0x1d, 0xe1, 0x34, 0x14, 0xb6}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x93, 0x7b, 0x27, 0x5a, 0xc0, 0x3f, 0x72, 0x38, 0x23, 0x10, 0x55, - 0xc0, 0xec, 0xa0, 0xed, 0x76, 0xc0, 0x70, 0x0, 0xab, 0x3b, 0x4}; - lwmqtt_string_t username = {22, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xa0, 0x4a, 0xca, 0xb9, 0xac, 0x32, 0x99, 0xc8, 0x16, 0x7, 0x82, 0x6e, - 0xb3, 0x85, 0x66, 0xcf, 0x35, 0xa, 0x38, 0xf5, 0xa, 0x90, 0xdc}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "P\178\243\183\172\137\232\212\r~N\252\145\212h\230\DC1\144z}\209\&6\247\DLE\192iq", -// _password = Just "mU", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "A\148M\202\195\195\r\GS\240\235\193_b)\178\176\218-Z\176`\186\164\FSk\134\175", _willMsg = -// "4|gQ1\225\226&\214N\213\135\232\220Gm\242\172", _willProps = []}), _cleanSession = True, _keepAlive = 1343, _connID -// = "\162\&4og*T\SYN\194c\EOT\129~z\215\170\t\a\172\172xu", _properties = []} -TEST(Connect311QCTest, Encode81) { - uint8_t pkt[] = {0x10, 0x73, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x5, 0x3f, 0x0, 0x15, 0xa2, 0x34, 0x6f, - 0x67, 0x2a, 0x54, 0x16, 0xc2, 0x63, 0x4, 0x81, 0x7e, 0x7a, 0xd7, 0xaa, 0x9, 0x7, 0xac, 0xac, 0x78, - 0x75, 0x0, 0x1b, 0x41, 0x94, 0x4d, 0xca, 0xc3, 0xc3, 0xd, 0x1d, 0xf0, 0xeb, 0xc1, 0x5f, 0x62, 0x29, - 0xb2, 0xb0, 0xda, 0x2d, 0x5a, 0xb0, 0x60, 0xba, 0xa4, 0x1c, 0x6b, 0x86, 0xaf, 0x0, 0x12, 0x34, 0x7c, - 0x67, 0x51, 0x31, 0xe1, 0xe2, 0x26, 0xd6, 0x4e, 0xd5, 0x87, 0xe8, 0xdc, 0x47, 0x6d, 0xf2, 0xac, 0x0, - 0x1b, 0x50, 0xb2, 0xf3, 0xb7, 0xac, 0x89, 0xe8, 0xd4, 0xd, 0x7e, 0x4e, 0xfc, 0x91, 0xd4, 0x68, 0xe6, - 0x11, 0x90, 0x7a, 0x7d, 0xd1, 0x36, 0xf7, 0x10, 0xc0, 0x69, 0x71, 0x0, 0x2, 0x6d, 0x55}; - - uint8_t buf[127] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x41, 0x94, 0x4d, 0xca, 0xc3, 0xc3, 0xd, 0x1d, 0xf0, 0xeb, 0xc1, 0x5f, 0x62, 0x29, - 0xb2, 0xb0, 0xda, 0x2d, 0x5a, 0xb0, 0x60, 0xba, 0xa4, 0x1c, 0x6b, 0x86, 0xaf}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x34, 0x7c, 0x67, 0x51, 0x31, 0xe1, 0xe2, 0x26, 0xd6, - 0x4e, 0xd5, 0x87, 0xe8, 0xdc, 0x47, 0x6d, 0xf2, 0xac}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1343; - uint8_t client_id_bytes[] = {0xa2, 0x34, 0x6f, 0x67, 0x2a, 0x54, 0x16, 0xc2, 0x63, 0x4, 0x81, - 0x7e, 0x7a, 0xd7, 0xaa, 0x9, 0x7, 0xac, 0xac, 0x78, 0x75}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x50, 0xb2, 0xf3, 0xb7, 0xac, 0x89, 0xe8, 0xd4, 0xd, 0x7e, 0x4e, 0xfc, 0x91, 0xd4, - 0x68, 0xe6, 0x11, 0x90, 0x7a, 0x7d, 0xd1, 0x36, 0xf7, 0x10, 0xc0, 0x69, 0x71}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6d, 0x55}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\r)\190_\138\DC4\SO\163\226j\189 -// ~*BN\SI\EOT-\217\128\232\223\239\129m\a\DLEG\254", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, -// _willTopic = "+\177\246\187~\133", _willMsg = "\151\189\&3\RS\175\198\166j", _willProps = []}), _cleanSession = -// False, _keepAlive = 4479, _connID = -// "\148\233\210e\EM\168\130\133\253\SOH\232\207f\173\220\238\167\166vG\v\141\190\";", _properties = []} -TEST(Connect311QCTest, Encode82) { - uint8_t pkt[] = {0x10, 0x37, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x11, 0x7f, 0x0, 0x19, 0x94, - 0xe9, 0xd2, 0x65, 0x19, 0xa8, 0x82, 0x85, 0xfd, 0x1, 0xe8, 0xcf, 0x66, 0xad, 0xdc, 0xee, - 0xa7, 0xa6, 0x76, 0x47, 0xb, 0x8d, 0xbe, 0x22, 0x3b, 0x0, 0x6, 0x2b, 0xb1, 0xf6, 0xbb, - 0x7e, 0x85, 0x0, 0x8, 0x97, 0xbd, 0x33, 0x1e, 0xaf, 0xc6, 0xa6, 0x6a}; - - uint8_t buf[67] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2b, 0xb1, 0xf6, 0xbb, 0x7e, 0x85}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x97, 0xbd, 0x33, 0x1e, 0xaf, 0xc6, 0xa6, 0x6a}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 4479; - uint8_t client_id_bytes[] = {0x94, 0xe9, 0xd2, 0x65, 0x19, 0xa8, 0x82, 0x85, 0xfd, 0x1, 0xe8, 0xcf, 0x66, - 0xad, 0xdc, 0xee, 0xa7, 0xa6, 0x76, 0x47, 0xb, 0x8d, 0xbe, 0x22, 0x3b}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xd, 0x29, 0xbe, 0x5f, 0x8a, 0x14, 0xe, 0xa3, 0xe2, 0x6a, 0xbd, 0x20, 0x7e, 0x2a, 0x42, - 0x4e, 0xf, 0x4, 0x2d, 0xd9, 0x80, 0xe8, 0xdf, 0xef, 0x81, 0x6d, 0x7, 0x10, 0x47, 0xfe}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\193=\216", _password = Nothing, _lastWill = Nothing, _cleanSession = True, -// _keepAlive = 20616, _connID = "H\197jy\150\206eUf&\224\&9\ACK", _properties = []} -TEST(Connect311QCTest, Encode83) { - uint8_t pkt[] = {0x10, 0x1e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x82, 0x50, 0x88, 0x0, 0xd, 0x48, 0xc5, - 0x6a, 0x79, 0x96, 0xce, 0x65, 0x55, 0x66, 0x26, 0xe0, 0x39, 0x6, 0x0, 0x3, 0xc1, 0x3d, 0xd8}; - - uint8_t buf[42] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 20616; - uint8_t client_id_bytes[] = {0x48, 0xc5, 0x6a, 0x79, 0x96, 0xce, 0x65, 0x55, 0x66, 0x26, 0xe0, 0x39, 0x6}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xc1, 0x3d, 0xd8}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just -// "\DLE\162\233\185\169\148\163\FS\DLE\DLE\EM\128\172$0\v\163\NAK\171\178o\152\247\162", _password = Just -// "\SYN)'\EMZ{&\170*\141\175\195\166\136\153%P\165\171Q\221Ps\200", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS1, _willTopic = -// "\179j\234\186\173`\r5\139\224\166\231v\170\206~\241\ENQ7\249\230\240\135\&2\249\173ou\130", _willMsg = -// "\184\198C\184", _willProps = []}), _cleanSession = True, _keepAlive = 23215, _connID = "'\ESC", _properties = []} -TEST(Connect311QCTest, Encode84) { - uint8_t pkt[] = {0x10, 0x67, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x5a, 0xaf, 0x0, 0x2, 0x27, - 0x1b, 0x0, 0x1d, 0xb3, 0x6a, 0xea, 0xba, 0xad, 0x60, 0xd, 0x35, 0x8b, 0xe0, 0xa6, 0xe7, - 0x76, 0xaa, 0xce, 0x7e, 0xf1, 0x5, 0x37, 0xf9, 0xe6, 0xf0, 0x87, 0x32, 0xf9, 0xad, 0x6f, - 0x75, 0x82, 0x0, 0x4, 0xb8, 0xc6, 0x43, 0xb8, 0x0, 0x18, 0x10, 0xa2, 0xe9, 0xb9, 0xa9, - 0x94, 0xa3, 0x1c, 0x10, 0x10, 0x19, 0x80, 0xac, 0x24, 0x30, 0xb, 0xa3, 0x15, 0xab, 0xb2, - 0x6f, 0x98, 0xf7, 0xa2, 0x0, 0x18, 0x16, 0x29, 0x27, 0x19, 0x5a, 0x7b, 0x26, 0xaa, 0x2a, - 0x8d, 0xaf, 0xc3, 0xa6, 0x88, 0x99, 0x25, 0x50, 0xa5, 0xab, 0x51, 0xdd, 0x50, 0x73, 0xc8}; - - uint8_t buf[115] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb3, 0x6a, 0xea, 0xba, 0xad, 0x60, 0xd, 0x35, 0x8b, 0xe0, - 0xa6, 0xe7, 0x76, 0xaa, 0xce, 0x7e, 0xf1, 0x5, 0x37, 0xf9, - 0xe6, 0xf0, 0x87, 0x32, 0xf9, 0xad, 0x6f, 0x75, 0x82}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb8, 0xc6, 0x43, 0xb8}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 23215; - uint8_t client_id_bytes[] = {0x27, 0x1b}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x10, 0xa2, 0xe9, 0xb9, 0xa9, 0x94, 0xa3, 0x1c, 0x10, 0x10, 0x19, 0x80, - 0xac, 0x24, 0x30, 0xb, 0xa3, 0x15, 0xab, 0xb2, 0x6f, 0x98, 0xf7, 0xa2}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x16, 0x29, 0x27, 0x19, 0x5a, 0x7b, 0x26, 0xaa, 0x2a, 0x8d, 0xaf, 0xc3, - 0xa6, 0x88, 0x99, 0x25, 0x50, 0xa5, 0xab, 0x51, 0xdd, 0x50, 0x73, 0xc8}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\214", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS0, _willTopic = "\162\190\DC4\DC4\rt\172-\134\146\171Y\SUB\181GJ\232\223", _willMsg = "", _willProps = -// []}), _cleanSession = False, _keepAlive = 3268, _connID = -// "X\ENQ\249\146\ti\193j\128\159\242\ACK\200\143\vTWH]\156\DEL", _properties = []} -TEST(Connect311QCTest, Encode85) { - uint8_t pkt[] = {0x10, 0x37, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0xc, 0xc4, 0x0, 0x15, 0x58, - 0x5, 0xf9, 0x92, 0x9, 0x69, 0xc1, 0x6a, 0x80, 0x9f, 0xf2, 0x6, 0xc8, 0x8f, 0xb, 0x54, - 0x57, 0x48, 0x5d, 0x9c, 0x7f, 0x0, 0x12, 0xa2, 0xbe, 0x14, 0x14, 0xd, 0x74, 0xac, 0x2d, - 0x86, 0x92, 0xab, 0x59, 0x1a, 0xb5, 0x47, 0x4a, 0xe8, 0xdf, 0x0, 0x0}; - - uint8_t buf[67] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa2, 0xbe, 0x14, 0x14, 0xd, 0x74, 0xac, 0x2d, 0x86, - 0x92, 0xab, 0x59, 0x1a, 0xb5, 0x47, 0x4a, 0xe8, 0xdf}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3268; - uint8_t client_id_bytes[] = {0x58, 0x5, 0xf9, 0x92, 0x9, 0x69, 0xc1, 0x6a, 0x80, 0x9f, 0xf2, - 0x6, 0xc8, 0x8f, 0xb, 0x54, 0x57, 0x48, 0x5d, 0x9c, 0x7f}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xd6}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just -// ")\156AQ\231\191\SYN\185h\225\178\137\238\&3\EOT\138\248\&7R\EM,*\SYN=\n\224\DC2", _lastWill = Nothing, _cleanSession -// = True, _keepAlive = 28678, _connID = -// "\189\132\188/]\224s+\NULTF\196\233U\GS\250L\167\176\EM\133\NUL\254\161Ol\136\162\209", _properties = []} -TEST(Connect311QCTest, Encode86) { - uint8_t pkt[] = {0x10, 0x29, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x70, 0x6, 0x0, 0x1d, 0xbd, - 0x84, 0xbc, 0x2f, 0x5d, 0xe0, 0x73, 0x2b, 0x0, 0x54, 0x46, 0xc4, 0xe9, 0x55, 0x1d, 0xfa, - 0x4c, 0xa7, 0xb0, 0x19, 0x85, 0x0, 0xfe, 0xa1, 0x4f, 0x6c, 0x88, 0xa2, 0xd1}; - - uint8_t buf[53] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 28678; - uint8_t client_id_bytes[] = {0xbd, 0x84, 0xbc, 0x2f, 0x5d, 0xe0, 0x73, 0x2b, 0x0, 0x54, 0x46, 0xc4, 0xe9, 0x55, 0x1d, - 0xfa, 0x4c, 0xa7, 0xb0, 0x19, 0x85, 0x0, 0xfe, 0xa1, 0x4f, 0x6c, 0x88, 0xa2, 0xd1}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x29, 0x9c, 0x41, 0x51, 0xe7, 0xbf, 0x16, 0xb9, 0x68, 0xe1, 0xb2, 0x89, 0xee, 0x33, - 0x4, 0x8a, 0xf8, 0x37, 0x52, 0x19, 0x2c, 0x2a, 0x16, 0x3d, 0xa, 0xe0, 0x12}; - lwmqtt_string_t password = {27, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\231\136\157", _password = Nothing, _lastWill = Nothing, _cleanSession = True, -// _keepAlive = 27015, _connID = "c\202.c\142W#U\130p\148q(O\219m", _properties = []} -TEST(Connect311QCTest, Encode87) { - uint8_t pkt[] = {0x10, 0x21, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x82, 0x69, 0x87, - 0x0, 0x10, 0x63, 0xca, 0x2e, 0x63, 0x8e, 0x57, 0x23, 0x55, 0x82, 0x70, - 0x94, 0x71, 0x28, 0x4f, 0xdb, 0x6d, 0x0, 0x3, 0xe7, 0x88, 0x9d}; - - uint8_t buf[45] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 27015; - uint8_t client_id_bytes[] = {0x63, 0xca, 0x2e, 0x63, 0x8e, 0x57, 0x23, 0x55, - 0x82, 0x70, 0x94, 0x71, 0x28, 0x4f, 0xdb, 0x6d}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xe7, 0x88, 0x9d}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "U\185M\196", _lastWill = Nothing, _cleanSession = True, -// _keepAlive = 28907, _connID = ";&\203q}", _properties = []} -TEST(Connect311QCTest, Encode88) { - uint8_t pkt[] = {0x10, 0x11, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, - 0x70, 0xeb, 0x0, 0x5, 0x3b, 0x26, 0xcb, 0x71, 0x7d}; - - uint8_t buf[29] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 28907; - uint8_t client_id_bytes[] = {0x3b, 0x26, 0xcb, 0x71, 0x7d}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x55, 0xb9, 0x4d, 0xc4}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "t\171o\168\ETB\EOT\EOT\226\b\SI\205\166J\SOj\164\ETB\SUB\166\245\US\SUB", _password -// = Just "\NAK\169_\251\NAK\186\DLE\215\169kW3J\b\199", _lastWill = Nothing, _cleanSession = False, _keepAlive = 28413, -// _connID = "\215\188:\SYN]?\n\214\176\&2i", _properties = []} -TEST(Connect311QCTest, Encode89) { - uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x6e, 0xfd, 0x0, 0xb, 0xd7, 0xbc, 0x3a, - 0x16, 0x5d, 0x3f, 0xa, 0xd6, 0xb0, 0x32, 0x69, 0x0, 0x16, 0x74, 0xab, 0x6f, 0xa8, 0x17, 0x4, 0x4, - 0xe2, 0x8, 0xf, 0xcd, 0xa6, 0x4a, 0xe, 0x6a, 0xa4, 0x17, 0x1a, 0xa6, 0xf5, 0x1f, 0x1a, 0x0, 0xf, - 0x15, 0xa9, 0x5f, 0xfb, 0x15, 0xba, 0x10, 0xd7, 0xa9, 0x6b, 0x57, 0x33, 0x4a, 0x8, 0xc7}; - - uint8_t buf[76] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 28413; - uint8_t client_id_bytes[] = {0xd7, 0xbc, 0x3a, 0x16, 0x5d, 0x3f, 0xa, 0xd6, 0xb0, 0x32, 0x69}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x74, 0xab, 0x6f, 0xa8, 0x17, 0x4, 0x4, 0xe2, 0x8, 0xf, 0xcd, - 0xa6, 0x4a, 0xe, 0x6a, 0xa4, 0x17, 0x1a, 0xa6, 0xf5, 0x1f, 0x1a}; - lwmqtt_string_t username = {22, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x15, 0xa9, 0x5f, 0xfb, 0x15, 0xba, 0x10, 0xd7, 0xa9, 0x6b, 0x57, 0x33, 0x4a, 0x8, 0xc7}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "M", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS1, _willTopic = "", _willMsg = "\163\147\EOT\177\219J\221\FSm_\STX\RS\rK\130D\159\n}", _willProps = []}), -// _cleanSession = True, _keepAlive = 6707, _connID = -// "\248\222\190\&6\US\171Z\135\192\253\DEL\205\US\238\ETXR\201|\SUB", _properties = []} -TEST(Connect311QCTest, Encode90) { - uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2e, 0x1a, 0x33, 0x0, 0x13, - 0xf8, 0xde, 0xbe, 0x36, 0x1f, 0xab, 0x5a, 0x87, 0xc0, 0xfd, 0x7f, 0xcd, 0x1f, 0xee, - 0x3, 0x52, 0xc9, 0x7c, 0x1a, 0x0, 0x0, 0x0, 0x13, 0xa3, 0x93, 0x4, 0xb1, 0xdb, - 0x4a, 0xdd, 0x1c, 0x6d, 0x5f, 0x2, 0x1e, 0xd, 0x4b, 0x82, 0x44, 0x9f, 0xa, 0x7d}; - - uint8_t buf[66] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa3, 0x93, 0x4, 0xb1, 0xdb, 0x4a, 0xdd, 0x1c, 0x6d, 0x5f, - 0x2, 0x1e, 0xd, 0x4b, 0x82, 0x44, 0x9f, 0xa, 0x7d}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 6707; - uint8_t client_id_bytes[] = {0xf8, 0xde, 0xbe, 0x36, 0x1f, 0xab, 0x5a, 0x87, 0xc0, 0xfd, - 0x7f, 0xcd, 0x1f, 0xee, 0x3, 0x52, 0xc9, 0x7c, 0x1a}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x4d}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\135\167", _password = Just "do\ETX\170V\239N\235\129|\168G\SO\218O\245SW\228", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\198\149\RSL\143\254\166!", _willMsg = -// ":\215\\\152\141^\ETXb\198", _willProps = []}), _cleanSession = True, _keepAlive = 1501, _connID = -// "\234YO\DC3;\148\207\&0\153n\199\142\146\206\254\155:", _properties = []} -TEST(Connect311QCTest, Encode91) { - uint8_t pkt[] = {0x10, 0x4b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x5, 0xdd, 0x0, 0x11, 0xea, 0x59, - 0x4f, 0x13, 0x3b, 0x94, 0xcf, 0x30, 0x99, 0x6e, 0xc7, 0x8e, 0x92, 0xce, 0xfe, 0x9b, 0x3a, 0x0, - 0x8, 0xc6, 0x95, 0x1e, 0x4c, 0x8f, 0xfe, 0xa6, 0x21, 0x0, 0x9, 0x3a, 0xd7, 0x5c, 0x98, 0x8d, - 0x5e, 0x3, 0x62, 0xc6, 0x0, 0x2, 0x87, 0xa7, 0x0, 0x13, 0x64, 0x6f, 0x3, 0xaa, 0x56, 0xef, - 0x4e, 0xeb, 0x81, 0x7c, 0xa8, 0x47, 0xe, 0xda, 0x4f, 0xf5, 0x53, 0x57, 0xe4}; - - uint8_t buf[87] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc6, 0x95, 0x1e, 0x4c, 0x8f, 0xfe, 0xa6, 0x21}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3a, 0xd7, 0x5c, 0x98, 0x8d, 0x5e, 0x3, 0x62, 0xc6}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1501; - uint8_t client_id_bytes[] = {0xea, 0x59, 0x4f, 0x13, 0x3b, 0x94, 0xcf, 0x30, 0x99, - 0x6e, 0xc7, 0x8e, 0x92, 0xce, 0xfe, 0x9b, 0x3a}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x87, 0xa7}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x64, 0x6f, 0x3, 0xaa, 0x56, 0xef, 0x4e, 0xeb, 0x81, 0x7c, - 0xa8, 0x47, 0xe, 0xda, 0x4f, 0xf5, 0x53, 0x57, 0xe4}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "J3\245R\234g\199\SUBe\f]Y\184\155\252O\131", _password = Just -// "N\130Z\162\174\221xV\181", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "L\149\222\209\ETB6\200tmGe\184\245\DLEg\135|\138v", _willMsg = -// "\240S\t;\152\130\197\DEL\227\191\221\138y|D\US\188\DC2\\\198@\207\&5\174\DC4w\GS1", _willProps = []}), _cleanSession -// = True, _keepAlive = 7620, _connID = "\180X\169B\252{L\217vd\b\249L\137\219\253\249W\166\245\152\SOnJJE\131\213", -// _properties = []} -TEST(Connect311QCTest, Encode92) { - uint8_t pkt[] = {0x10, 0x79, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x1d, 0xc4, 0x0, 0x1c, 0xb4, 0x58, - 0xa9, 0x42, 0xfc, 0x7b, 0x4c, 0xd9, 0x76, 0x64, 0x8, 0xf9, 0x4c, 0x89, 0xdb, 0xfd, 0xf9, 0x57, - 0xa6, 0xf5, 0x98, 0xe, 0x6e, 0x4a, 0x4a, 0x45, 0x83, 0xd5, 0x0, 0x13, 0x4c, 0x95, 0xde, 0xd1, - 0x17, 0x36, 0xc8, 0x74, 0x6d, 0x47, 0x65, 0xb8, 0xf5, 0x10, 0x67, 0x87, 0x7c, 0x8a, 0x76, 0x0, - 0x1c, 0xf0, 0x53, 0x9, 0x3b, 0x98, 0x82, 0xc5, 0x7f, 0xe3, 0xbf, 0xdd, 0x8a, 0x79, 0x7c, 0x44, - 0x1f, 0xbc, 0x12, 0x5c, 0xc6, 0x40, 0xcf, 0x35, 0xae, 0x14, 0x77, 0x1d, 0x31, 0x0, 0x11, 0x4a, - 0x33, 0xf5, 0x52, 0xea, 0x67, 0xc7, 0x1a, 0x65, 0xc, 0x5d, 0x59, 0xb8, 0x9b, 0xfc, 0x4f, 0x83, - 0x0, 0x9, 0x4e, 0x82, 0x5a, 0xa2, 0xae, 0xdd, 0x78, 0x56, 0xb5}; - - uint8_t buf[133] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4c, 0x95, 0xde, 0xd1, 0x17, 0x36, 0xc8, 0x74, 0x6d, 0x47, - 0x65, 0xb8, 0xf5, 0x10, 0x67, 0x87, 0x7c, 0x8a, 0x76}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf0, 0x53, 0x9, 0x3b, 0x98, 0x82, 0xc5, 0x7f, 0xe3, 0xbf, 0xdd, 0x8a, 0x79, 0x7c, - 0x44, 0x1f, 0xbc, 0x12, 0x5c, 0xc6, 0x40, 0xcf, 0x35, 0xae, 0x14, 0x77, 0x1d, 0x31}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 7620; - uint8_t client_id_bytes[] = {0xb4, 0x58, 0xa9, 0x42, 0xfc, 0x7b, 0x4c, 0xd9, 0x76, 0x64, 0x8, 0xf9, 0x4c, 0x89, - 0xdb, 0xfd, 0xf9, 0x57, 0xa6, 0xf5, 0x98, 0xe, 0x6e, 0x4a, 0x4a, 0x45, 0x83, 0xd5}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x4a, 0x33, 0xf5, 0x52, 0xea, 0x67, 0xc7, 0x1a, 0x65, - 0xc, 0x5d, 0x59, 0xb8, 0x9b, 0xfc, 0x4f, 0x83}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x4e, 0x82, 0x5a, 0xa2, 0xae, 0xdd, 0x78, 0x56, 0xb5}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\DC2\145\228\152*\178X", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\143\&2Gc]\253N\249\243\153\145\225\185\215sp\SOHs\192\221\&7{", -// _willMsg = "\NUL\211NA\197", _willProps = []}), _cleanSession = True, _keepAlive = 29972, _connID = -// "\ETB8\187\183q0\214H5\201\SI\199\183B\212u[\143\253\152\199W\EOT\206\149", _properties = []} -TEST(Connect311QCTest, Encode93) { - uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x75, 0x14, 0x0, 0x19, - 0x17, 0x38, 0xbb, 0xb7, 0x71, 0x30, 0xd6, 0x48, 0x35, 0xc9, 0xf, 0xc7, 0xb7, 0x42, - 0xd4, 0x75, 0x5b, 0x8f, 0xfd, 0x98, 0xc7, 0x57, 0x4, 0xce, 0x95, 0x0, 0x16, 0x8f, - 0x32, 0x47, 0x63, 0x5d, 0xfd, 0x4e, 0xf9, 0xf3, 0x99, 0x91, 0xe1, 0xb9, 0xd7, 0x73, - 0x70, 0x1, 0x73, 0xc0, 0xdd, 0x37, 0x7b, 0x0, 0x5, 0x0, 0xd3, 0x4e, 0x41, 0xc5}; - - uint8_t buf[80] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8f, 0x32, 0x47, 0x63, 0x5d, 0xfd, 0x4e, 0xf9, 0xf3, 0x99, 0x91, - 0xe1, 0xb9, 0xd7, 0x73, 0x70, 0x1, 0x73, 0xc0, 0xdd, 0x37, 0x7b}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x0, 0xd3, 0x4e, 0x41, 0xc5}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 29972; - uint8_t client_id_bytes[] = {0x17, 0x38, 0xbb, 0xb7, 0x71, 0x30, 0xd6, 0x48, 0x35, 0xc9, 0xf, 0xc7, 0xb7, - 0x42, 0xd4, 0x75, 0x5b, 0x8f, 0xfd, 0x98, 0xc7, 0x57, 0x4, 0xce, 0x95}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x12, 0x91, 0xe4, 0x98, 0x2a, 0xb2, 0x58}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just ",dA\164\202\NUL\161\212\169\183\&0", _password = Just "\CAN\SUB\238\&0", _lastWill -// = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\GS\187\&5\157[*n\166\233S\168\&8\155\DC4\177$\168q\204\218\r\rJ", _willMsg = -// "\236[s\ESCz\217dW\STX\222\151\&0\SYNB\149\b\189fKjA", _willProps = []}), _cleanSession = True, _keepAlive = 488, -// _connID = "/\152\131mx1\208\&5", _properties = []} -TEST(Connect311QCTest, Encode94) { - uint8_t pkt[] = {0x10, 0x57, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x1, 0xe8, 0x0, 0x8, 0x2f, - 0x98, 0x83, 0x6d, 0x78, 0x31, 0xd0, 0x35, 0x0, 0x17, 0x1d, 0xbb, 0x35, 0x9d, 0x5b, 0x2a, - 0x6e, 0xa6, 0xe9, 0x53, 0xa8, 0x38, 0x9b, 0x14, 0xb1, 0x24, 0xa8, 0x71, 0xcc, 0xda, 0xd, - 0xd, 0x4a, 0x0, 0x15, 0xec, 0x5b, 0x73, 0x1b, 0x7a, 0xd9, 0x64, 0x57, 0x2, 0xde, 0x97, - 0x30, 0x16, 0x42, 0x95, 0x8, 0xbd, 0x66, 0x4b, 0x6a, 0x41, 0x0, 0xb, 0x2c, 0x64, 0x41, - 0xa4, 0xca, 0x0, 0xa1, 0xd4, 0xa9, 0xb7, 0x30, 0x0, 0x4, 0x18, 0x1a, 0xee, 0x30}; - - uint8_t buf[99] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1d, 0xbb, 0x35, 0x9d, 0x5b, 0x2a, 0x6e, 0xa6, 0xe9, 0x53, 0xa8, 0x38, - 0x9b, 0x14, 0xb1, 0x24, 0xa8, 0x71, 0xcc, 0xda, 0xd, 0xd, 0x4a}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xec, 0x5b, 0x73, 0x1b, 0x7a, 0xd9, 0x64, 0x57, 0x2, 0xde, 0x97, - 0x30, 0x16, 0x42, 0x95, 0x8, 0xbd, 0x66, 0x4b, 0x6a, 0x41}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 488; - uint8_t client_id_bytes[] = {0x2f, 0x98, 0x83, 0x6d, 0x78, 0x31, 0xd0, 0x35}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x2c, 0x64, 0x41, 0xa4, 0xca, 0x0, 0xa1, 0xd4, 0xa9, 0xb7, 0x30}; - lwmqtt_string_t username = {11, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x18, 0x1a, 0xee, 0x30}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "ox\192\209\133\220~\DC29B\182\239=\196Sa[R\ETB\NUL\US\248E", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\214ht\202Q:u\DC3\190\SYN\SYN\246\225\130\232X\196k%\RSV*\144\154\215\184\227", _willMsg = "t -// \164\CAN)\191\132\223\226\201\230\149\253N\189\218\215\&4\182Gy\247y\201", _willProps = []}), _cleanSession = True, -// _keepAlive = 24570, _connID = "K\"%j\DLE\STXu~\ESC\236\178\204S\151(?\245\214w;\r\255\&5!", _properties = []} -TEST(Connect311QCTest, Encode95) { - uint8_t pkt[] = {0x10, 0x5b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x5f, 0xfa, 0x0, 0x18, 0x4b, 0x22, - 0x25, 0x6a, 0x10, 0x2, 0x75, 0x7e, 0x1b, 0xec, 0xb2, 0xcc, 0x53, 0x97, 0x28, 0x3f, 0xf5, 0xd6, - 0x77, 0x3b, 0xd, 0xff, 0x35, 0x21, 0x0, 0x1b, 0xd6, 0x68, 0x74, 0xca, 0x51, 0x3a, 0x75, 0x13, - 0xbe, 0x16, 0x16, 0xf6, 0xe1, 0x82, 0xe8, 0x58, 0xc4, 0x6b, 0x25, 0x1e, 0x56, 0x2a, 0x90, 0x9a, - 0xd7, 0xb8, 0xe3, 0x0, 0x18, 0x74, 0x20, 0xa4, 0x18, 0x29, 0xbf, 0x84, 0xdf, 0xe2, 0xc9, 0xe6, - 0x95, 0xfd, 0x4e, 0xbd, 0xda, 0xd7, 0x34, 0xb6, 0x47, 0x79, 0xf7, 0x79, 0xc9}; - - uint8_t buf[103] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd6, 0x68, 0x74, 0xca, 0x51, 0x3a, 0x75, 0x13, 0xbe, 0x16, 0x16, 0xf6, 0xe1, 0x82, - 0xe8, 0x58, 0xc4, 0x6b, 0x25, 0x1e, 0x56, 0x2a, 0x90, 0x9a, 0xd7, 0xb8, 0xe3}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x74, 0x20, 0xa4, 0x18, 0x29, 0xbf, 0x84, 0xdf, 0xe2, 0xc9, 0xe6, 0x95, - 0xfd, 0x4e, 0xbd, 0xda, 0xd7, 0x34, 0xb6, 0x47, 0x79, 0xf7, 0x79, 0xc9}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 24570; - uint8_t client_id_bytes[] = {0x4b, 0x22, 0x25, 0x6a, 0x10, 0x2, 0x75, 0x7e, 0x1b, 0xec, 0xb2, 0xcc, - 0x53, 0x97, 0x28, 0x3f, 0xf5, 0xd6, 0x77, 0x3b, 0xd, 0xff, 0x35, 0x21}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x6f, 0x78, 0xc0, 0xd1, 0x85, 0xdc, 0x7e, 0x12, 0x39, 0x42, 0xb6, 0xef, - 0x3d, 0xc4, 0x53, 0x61, 0x5b, 0x52, 0x17, 0x0, 0x1f, 0xf8, 0x45}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\157LD\210\143*\189\134\&0\231\250\253\DC3\210\ETXh\178", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "|\157\175oRO\236\200|s\252\165x\155\f\205{\227\229\134\251u\146\144\248.", _willMsg = -// "R\242;\DC1D\209@\146\213\194Qz\230\DC3\213\RSk`\189a5\DLE\245", _willProps = []}), _cleanSession = False, _keepAlive -// = 10064, _connID = "\192u\185\&3\177\222-3\142\DLE\172\172\163\242\228P\178\180\ETB\198]c\131", _properties = []} -TEST(Connect311QCTest, Encode96) { - uint8_t pkt[] = {0x10, 0x58, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x27, 0x50, 0x0, 0x17, 0xc0, - 0x75, 0xb9, 0x33, 0xb1, 0xde, 0x2d, 0x33, 0x8e, 0x10, 0xac, 0xac, 0xa3, 0xf2, 0xe4, 0x50, - 0xb2, 0xb4, 0x17, 0xc6, 0x5d, 0x63, 0x83, 0x0, 0x1a, 0x7c, 0x9d, 0xaf, 0x6f, 0x52, 0x4f, - 0xec, 0xc8, 0x7c, 0x73, 0xfc, 0xa5, 0x78, 0x9b, 0xc, 0xcd, 0x7b, 0xe3, 0xe5, 0x86, 0xfb, - 0x75, 0x92, 0x90, 0xf8, 0x2e, 0x0, 0x17, 0x52, 0xf2, 0x3b, 0x11, 0x44, 0xd1, 0x40, 0x92, - 0xd5, 0xc2, 0x51, 0x7a, 0xe6, 0x13, 0xd5, 0x1e, 0x6b, 0x60, 0xbd, 0x61, 0x35, 0x10, 0xf5}; - - uint8_t buf[100] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x7c, 0x9d, 0xaf, 0x6f, 0x52, 0x4f, 0xec, 0xc8, 0x7c, 0x73, 0xfc, 0xa5, 0x78, - 0x9b, 0xc, 0xcd, 0x7b, 0xe3, 0xe5, 0x86, 0xfb, 0x75, 0x92, 0x90, 0xf8, 0x2e}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x52, 0xf2, 0x3b, 0x11, 0x44, 0xd1, 0x40, 0x92, 0xd5, 0xc2, 0x51, 0x7a, - 0xe6, 0x13, 0xd5, 0x1e, 0x6b, 0x60, 0xbd, 0x61, 0x35, 0x10, 0xf5}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 10064; - uint8_t client_id_bytes[] = {0xc0, 0x75, 0xb9, 0x33, 0xb1, 0xde, 0x2d, 0x33, 0x8e, 0x10, 0xac, 0xac, - 0xa3, 0xf2, 0xe4, 0x50, 0xb2, 0xb4, 0x17, 0xc6, 0x5d, 0x63, 0x83}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x9d, 0x4c, 0x44, 0xd2, 0x8f, 0x2a, 0xbd, 0x86, 0x30, - 0xe7, 0xfa, 0xfd, 0x13, 0xd2, 0x3, 0x68, 0xb2}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\136a6\248", _password = Just "aW\205\150\ACK*\208", _lastWill = Nothing, -// _cleanSession = True, _keepAlive = 27816, _connID = "\200\194\195y\163\178", _properties = []} -TEST(Connect311QCTest, Encode97) { - uint8_t pkt[] = {0x10, 0x21, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x6c, 0xa8, - 0x0, 0x6, 0xc8, 0xc2, 0xc3, 0x79, 0xa3, 0xb2, 0x0, 0x4, 0x88, 0x61, - 0x36, 0xf8, 0x0, 0x7, 0x61, 0x57, 0xcd, 0x96, 0x6, 0x2a, 0xd0}; - - uint8_t buf[45] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 27816; - uint8_t client_id_bytes[] = {0xc8, 0xc2, 0xc3, 0x79, 0xa3, 0xb2}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x88, 0x61, 0x36, 0xf8}; - lwmqtt_string_t username = {4, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x61, 0x57, 0xcd, 0x96, 0x6, 0x2a, 0xd0}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "Y2\vz\196.", _password = Just -// "Z+\195-\233*,\232\192\178w\"\201\188X\DELI\165\144\170\n\161bdTr", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = ":\152<\197\228\170\235[\NUL\207I\169=\149\NAK\225$\r\224\220\173\133EX", _willMsg = -// "E\225^YZ\STX\161\CANS\130>\215e\rU", _willProps = []}), _cleanSession = False, _keepAlive = 12906, _connID = -// "e\161\220F\196\187*\\H\151\188i\177\188\172\240", _properties = []} -TEST(Connect311QCTest, Encode98) { - uint8_t pkt[] = {0x10, 0x6b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x32, 0x6a, 0x0, 0x10, 0x65, 0xa1, - 0xdc, 0x46, 0xc4, 0xbb, 0x2a, 0x5c, 0x48, 0x97, 0xbc, 0x69, 0xb1, 0xbc, 0xac, 0xf0, 0x0, 0x18, - 0x3a, 0x98, 0x3c, 0xc5, 0xe4, 0xaa, 0xeb, 0x5b, 0x0, 0xcf, 0x49, 0xa9, 0x3d, 0x95, 0x15, 0xe1, - 0x24, 0xd, 0xe0, 0xdc, 0xad, 0x85, 0x45, 0x58, 0x0, 0xf, 0x45, 0xe1, 0x5e, 0x59, 0x5a, 0x2, - 0xa1, 0x18, 0x53, 0x82, 0x3e, 0xd7, 0x65, 0xd, 0x55, 0x0, 0x6, 0x59, 0x32, 0xb, 0x7a, 0xc4, - 0x2e, 0x0, 0x1a, 0x5a, 0x2b, 0xc3, 0x2d, 0xe9, 0x2a, 0x2c, 0xe8, 0xc0, 0xb2, 0x77, 0x22, 0xc9, - 0xbc, 0x58, 0x7f, 0x49, 0xa5, 0x90, 0xaa, 0xa, 0xa1, 0x62, 0x64, 0x54, 0x72}; - - uint8_t buf[119] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3a, 0x98, 0x3c, 0xc5, 0xe4, 0xaa, 0xeb, 0x5b, 0x0, 0xcf, 0x49, 0xa9, - 0x3d, 0x95, 0x15, 0xe1, 0x24, 0xd, 0xe0, 0xdc, 0xad, 0x85, 0x45, 0x58}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x45, 0xe1, 0x5e, 0x59, 0x5a, 0x2, 0xa1, 0x18, - 0x53, 0x82, 0x3e, 0xd7, 0x65, 0xd, 0x55}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12906; - uint8_t client_id_bytes[] = {0x65, 0xa1, 0xdc, 0x46, 0xc4, 0xbb, 0x2a, 0x5c, - 0x48, 0x97, 0xbc, 0x69, 0xb1, 0xbc, 0xac, 0xf0}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x59, 0x32, 0xb, 0x7a, 0xc4, 0x2e}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x5a, 0x2b, 0xc3, 0x2d, 0xe9, 0x2a, 0x2c, 0xe8, 0xc0, 0xb2, 0x77, 0x22, 0xc9, - 0xbc, 0x58, 0x7f, 0x49, 0xa5, 0x90, 0xaa, 0xa, 0xa1, 0x62, 0x64, 0x54, 0x72}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 19412, _connID = "\188=\183\NAK\DLE~\SYN\241", _properties = []} -TEST(Connect311QCTest, Encode99) { - uint8_t pkt[] = {0x10, 0x14, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x4b, - 0xd4, 0x0, 0x8, 0xbc, 0x3d, 0xb7, 0x15, 0x10, 0x7e, 0x16, 0xf1}; - - uint8_t buf[32] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19412; - uint8_t client_id_bytes[] = {0xbc, 0x3d, 0xb7, 0x15, 0x10, 0x7e, 0x16, 0xf1}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\213Z6\DC4\128\136\188%", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "|\RS\164\178\193a", _willMsg = -// "O\197\240\214\DC1$j5y^\EM\222\253+\DC1\147}", _willProps = []}), _cleanSession = True, _keepAlive = 19592, _connID = -// "\132\175\ETX\n\219\137\SI\183V\196\219\251\145t\244\200AZ[\156\a\212\252\177\154\245%@\249", _properties = []} -TEST(Connect311QCTest, Encode100) { - uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xae, 0x4c, 0x88, 0x0, 0x1d, 0x84, 0xaf, - 0x3, 0xa, 0xdb, 0x89, 0xf, 0xb7, 0x56, 0xc4, 0xdb, 0xfb, 0x91, 0x74, 0xf4, 0xc8, 0x41, 0x5a, - 0x5b, 0x9c, 0x7, 0xd4, 0xfc, 0xb1, 0x9a, 0xf5, 0x25, 0x40, 0xf9, 0x0, 0x6, 0x7c, 0x1e, 0xa4, - 0xb2, 0xc1, 0x61, 0x0, 0x11, 0x4f, 0xc5, 0xf0, 0xd6, 0x11, 0x24, 0x6a, 0x35, 0x79, 0x5e, 0x19, - 0xde, 0xfd, 0x2b, 0x11, 0x93, 0x7d, 0x0, 0x8, 0xd5, 0x5a, 0x36, 0x14, 0x80, 0x88, 0xbc, 0x25}; - - uint8_t buf[90] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x7c, 0x1e, 0xa4, 0xb2, 0xc1, 0x61}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4f, 0xc5, 0xf0, 0xd6, 0x11, 0x24, 0x6a, 0x35, 0x79, - 0x5e, 0x19, 0xde, 0xfd, 0x2b, 0x11, 0x93, 0x7d}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 19592; - uint8_t client_id_bytes[] = {0x84, 0xaf, 0x3, 0xa, 0xdb, 0x89, 0xf, 0xb7, 0x56, 0xc4, 0xdb, 0xfb, 0x91, 0x74, 0xf4, - 0xc8, 0x41, 0x5a, 0x5b, 0x9c, 0x7, 0xd4, 0xfc, 0xb1, 0x9a, 0xf5, 0x25, 0x40, 0xf9}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xd5, 0x5a, 0x36, 0x14, 0x80, 0x88, 0xbc, 0x25}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "F\171\131\SI\DC4\132\f\236\247\252", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\246\240", _willMsg = -// "\169\154\b\180\t3\183\199\&9\250\194", _willProps = [PropServerKeepAlive 10579,PropTopicAliasMaximum -// 32315,PropPayloadFormatIndicator 155,PropTopicAliasMaximum 4930,PropServerKeepAlive 17639,PropServerReference -// "u3\DC3~\157\133\235\254\208\177\SI\224>\ESCqM\155-\252\233F\CAN\GS\216&\EOT\235\&1z",PropWildcardSubscriptionAvailable -// 229,PropServerReference "\252NS\232\153\255\US\NAK\171\168\227\232\n\208\208\200",PropSubscriptionIdentifierAvailable -// 182,PropResponseInformation "\191",PropWildcardSubscriptionAvailable 52,PropAssignedClientIdentifier -// "\DLE\227\&8T\182J\"m;",PropReasonString -// "g\167i\254\232\166\198#\179\185Z\r\128\247\251hd\243\170\&7",PropRetainAvailable 68,PropReceiveMaximum -// 13425,PropWildcardSubscriptionAvailable 85,PropResponseInformation -// "3\212\219\SOH\201v5+\SUB\150\STX",PropRequestResponseInformation 166,PropReceiveMaximum 21964]}), _cleanSession = -// True, _keepAlive = 3250, _connID = " \241\DC2\ACK\157\190\v\161\205=\\\156dS\184{", _properties = []} -TEST(Connect5QCTest, Encode1) { - uint8_t pkt[] = { - 0x10, 0xb8, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0xc, 0xb2, 0x0, 0x0, 0x10, 0x20, 0xf1, 0x12, - 0x6, 0x9d, 0xbe, 0xb, 0xa1, 0xcd, 0x3d, 0x5c, 0x9c, 0x64, 0x53, 0xb8, 0x7b, 0x88, 0x1, 0x13, 0x29, 0x53, 0x22, - 0x7e, 0x3b, 0x1, 0x9b, 0x22, 0x13, 0x42, 0x13, 0x44, 0xe7, 0x1c, 0x0, 0x1d, 0x75, 0x33, 0x13, 0x7e, 0x9d, 0x85, - 0xeb, 0xfe, 0xd0, 0xb1, 0xf, 0xe0, 0x3e, 0x1b, 0x71, 0x4d, 0x9b, 0x2d, 0xfc, 0xe9, 0x46, 0x18, 0x1d, 0xd8, 0x26, - 0x4, 0xeb, 0x31, 0x7a, 0x28, 0xe5, 0x1c, 0x0, 0x10, 0xfc, 0x4e, 0x53, 0xe8, 0x99, 0xff, 0x1f, 0x15, 0xab, 0xa8, - 0xe3, 0xe8, 0xa, 0xd0, 0xd0, 0xc8, 0x29, 0xb6, 0x1a, 0x0, 0x1, 0xbf, 0x28, 0x34, 0x12, 0x0, 0x9, 0x10, 0xe3, - 0x38, 0x54, 0xb6, 0x4a, 0x22, 0x6d, 0x3b, 0x1f, 0x0, 0x14, 0x67, 0xa7, 0x69, 0xfe, 0xe8, 0xa6, 0xc6, 0x23, 0xb3, - 0xb9, 0x5a, 0xd, 0x80, 0xf7, 0xfb, 0x68, 0x64, 0xf3, 0xaa, 0x37, 0x25, 0x44, 0x21, 0x34, 0x71, 0x28, 0x55, 0x1a, - 0x0, 0xb, 0x33, 0xd4, 0xdb, 0x1, 0xc9, 0x76, 0x35, 0x2b, 0x1a, 0x96, 0x2, 0x19, 0xa6, 0x21, 0x55, 0xcc, 0x0, - 0x2, 0xf6, 0xf0, 0x0, 0xb, 0xa9, 0x9a, 0x8, 0xb4, 0x9, 0x33, 0xb7, 0xc7, 0x39, 0xfa, 0xc2}; - - uint8_t buf[197] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x75, 0x33, 0x13, 0x7e, 0x9d, 0x85, 0xeb, 0xfe, 0xd0, 0xb1, 0xf, 0xe0, 0x3e, 0x1b, 0x71, - 0x4d, 0x9b, 0x2d, 0xfc, 0xe9, 0x46, 0x18, 0x1d, 0xd8, 0x26, 0x4, 0xeb, 0x31, 0x7a}; - uint8_t byteswillprops1[] = {0xfc, 0x4e, 0x53, 0xe8, 0x99, 0xff, 0x1f, 0x15, - 0xab, 0xa8, 0xe3, 0xe8, 0xa, 0xd0, 0xd0, 0xc8}; - uint8_t byteswillprops2[] = {0xbf}; - uint8_t byteswillprops3[] = {0x10, 0xe3, 0x38, 0x54, 0xb6, 0x4a, 0x22, 0x6d, 0x3b}; - uint8_t byteswillprops4[] = {0x67, 0xa7, 0x69, 0xfe, 0xe8, 0xa6, 0xc6, 0x23, 0xb3, 0xb9, - 0x5a, 0xd, 0x80, 0xf7, 0xfb, 0x68, 0x64, 0xf3, 0xaa, 0x37}; - uint8_t byteswillprops5[] = {0x33, 0xd4, 0xdb, 0x1, 0xc9, 0x76, 0x35, 0x2b, 0x1a, 0x96, 0x2}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10579}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32315}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4930}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17639}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13425}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21964}}, - }; - - lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf6, 0xf0}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa9, 0x9a, 0x8, 0xb4, 0x9, 0x33, 0xb7, 0xc7, 0x39, 0xfa, 0xc2}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 3250; - uint8_t client_id_bytes[] = {0x20, 0xf1, 0x12, 0x6, 0x9d, 0xbe, 0xb, 0xa1, - 0xcd, 0x3d, 0x5c, 0x9c, 0x64, 0x53, 0xb8, 0x7b}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x46, 0xab, 0x83, 0xf, 0x14, 0x84, 0xc, 0xec, 0xf7, 0xfc}; - lwmqtt_string_t password = {10, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\185\211\STX\225\EOT\134\DC4\DC2", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS0, _willTopic = "y\133\f\222\RS\142", _willMsg = -// "\252\142\185\165\252\211e|\US\228\205\SYN\193\227\255\173\EOT$", _willProps = [PropTopicAliasMaximum -// 13488,PropPayloadFormatIndicator 204,PropSessionExpiryInterval 32098,PropMaximumQoS 149,PropResponseTopic -// "\161#\151O\188\187",PropResponseTopic "\ENQ\f\SO\ETX\200\NUL\196\137V\173HO\170R<",PropSharedSubscriptionAvailable -// 177,PropContentType "",PropSubscriptionIdentifier 6,PropRetainAvailable 121,PropMaximumQoS 0,PropReceiveMaximum -// 18726,PropAuthenticationData -// "\194\DLE\239U\170\b\197\234[\210\b\141\156\242\136,%:\245\212\ETX8",PropMaximumPacketSize 16300,PropServerKeepAlive -// 29904,PropMaximumPacketSize 3698,PropTopicAlias 6587,PropWildcardSubscriptionAvailable 175,PropMaximumPacketSize -// 20654,PropReceiveMaximum 20352,PropRetainAvailable 170,PropSubscriptionIdentifier 7,PropPayloadFormatIndicator -// 143,PropResponseTopic "\252H\151s\248=\209\175>\128\133\186\150eq1g\224ht\SOH\223\168>\DC2",PropTopicAliasMaximum -// 30495,PropSubscriptionIdentifierAvailable 49,PropSubscriptionIdentifierAvailable 126]}), _cleanSession = False, -// _keepAlive = 15842, _connID = "", _properties = [PropSubscriptionIdentifierAvailable 221,PropResponseInformation -// "\197\158\218\225\175\251\166\207\156_Dq\238*\223",PropReceiveMaximum 28123,PropSubscriptionIdentifier -// 22,PropWildcardSubscriptionAvailable 143,PropMessageExpiryInterval 25705,PropAssignedClientIdentifier -// "\236\ETXO",PropRequestResponseInformation 187,PropTopicAlias 10652,PropPayloadFormatIndicator 166,PropReceiveMaximum -// 4455,PropMessageExpiryInterval 9441,PropMessageExpiryInterval 27038,PropMessageExpiryInterval -// 19854,PropRequestProblemInformation 43,PropTopicAlias 1994,PropContentType -// "0K\218\NAK\187\180\213",PropServerKeepAlive 4973,PropSessionExpiryInterval 30803,PropRequestResponseInformation -// 104,PropResponseTopic "\203\US\230\154\176\FS?\138\235\226\ACK\141&i\161\250",PropPayloadFormatIndicator -// 69,PropContentType -// "n\DC2\201<\143K\205\EM\139\252h\223\171\250\174\161~*vBw:\DC1\255\135\FS\159",PropAssignedClientIdentifier -// "\171%\176q\186\&0\225\247\&8q\ACK\144\ESC0\211wC\167\r\ACK",PropTopicAlias 11156,PropContentType -// "\204&\217~cc\185\212zoU\220\156\201\234m\243[,\158\131W\223\236",PropMaximumQoS 255,PropAuthenticationData -// ">\f7j\201\186\146d_\224\212\192\163\183\141'\SOH\242\EOT\132\226\243l\232?T",PropMaximumPacketSize -// 12789,PropPayloadFormatIndicator 23]} -TEST(Connect5QCTest, Encode2) { - uint8_t pkt[] = { - 0x10, 0xad, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x84, 0x3d, 0xe2, 0xe6, 0x1, 0x29, 0xdd, 0x1a, 0x0, - 0xf, 0xc5, 0x9e, 0xda, 0xe1, 0xaf, 0xfb, 0xa6, 0xcf, 0x9c, 0x5f, 0x44, 0x71, 0xee, 0x2a, 0xdf, 0x21, 0x6d, 0xdb, - 0xb, 0x16, 0x28, 0x8f, 0x2, 0x0, 0x0, 0x64, 0x69, 0x12, 0x0, 0x3, 0xec, 0x3, 0x4f, 0x19, 0xbb, 0x23, 0x29, - 0x9c, 0x1, 0xa6, 0x21, 0x11, 0x67, 0x2, 0x0, 0x0, 0x24, 0xe1, 0x2, 0x0, 0x0, 0x69, 0x9e, 0x2, 0x0, 0x0, - 0x4d, 0x8e, 0x17, 0x2b, 0x23, 0x7, 0xca, 0x3, 0x0, 0x7, 0x30, 0x4b, 0xda, 0x15, 0xbb, 0xb4, 0xd5, 0x13, 0x13, - 0x6d, 0x11, 0x0, 0x0, 0x78, 0x53, 0x19, 0x68, 0x8, 0x0, 0x10, 0xcb, 0x1f, 0xe6, 0x9a, 0xb0, 0x1c, 0x3f, 0x8a, - 0xeb, 0xe2, 0x6, 0x8d, 0x26, 0x69, 0xa1, 0xfa, 0x1, 0x45, 0x3, 0x0, 0x1b, 0x6e, 0x12, 0xc9, 0x3c, 0x8f, 0x4b, - 0xcd, 0x19, 0x8b, 0xfc, 0x68, 0xdf, 0xab, 0xfa, 0xae, 0xa1, 0x7e, 0x2a, 0x76,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d0, 0x27, 0x0, 0x0, 0xe, 0x72, 0x23, 0x19, - 0xbb, 0x28, 0xaf, 0x27, 0x0, 0x0, 0x50, 0xae, 0x21, 0x4f, 0x80, 0x25, 0xaa, 0xb, 0x7, 0x1, 0x8f, 0x8, 0x0, - 0x19, 0xfc, 0x48, 0x97, 0x73, 0xf8, 0x3d, 0xd1, 0xaf, 0x3e, 0x80, 0x85, 0xba, 0x96, 0x65, 0x71, 0x31, 0x67, 0xe0, - 0x68, 0x74, 0x1, 0xdf, 0xa8, 0x3e, 0x12, 0x22, 0x77, 0x1f, 0x29, 0x31, 0x29, 0x7e, 0x0, 0x6, 0x79, 0x85, 0xc, - 0xde, 0x1e, 0x8e, 0x0, 0x12, 0xfc, 0x8e, 0xb9, 0xa5, 0xfc, 0xd3, 0x65, 0x7c, 0x1f, 0xe4, 0xcd, 0x16, 0xc1, 0xe3, - 0xff, 0xad, 0x4, 0x24, 0x0, 0x8, 0xb9, 0xd3, 0x2, 0xe1, 0x4, 0x86, 0x14, 0x12}; - - uint8_t buf[442] = {0}; - - uint8_t bytesprops0[] = {0xc5, 0x9e, 0xda, 0xe1, 0xaf, 0xfb, 0xa6, 0xcf, 0x9c, 0x5f, 0x44, 0x71, 0xee, 0x2a, 0xdf}; - uint8_t bytesprops1[] = {0xec, 0x3, 0x4f}; - uint8_t bytesprops2[] = {0x30, 0x4b, 0xda, 0x15, 0xbb, 0xb4, 0xd5}; - uint8_t bytesprops3[] = {0xcb, 0x1f, 0xe6, 0x9a, 0xb0, 0x1c, 0x3f, 0x8a, - 0xeb, 0xe2, 0x6, 0x8d, 0x26, 0x69, 0xa1, 0xfa}; - uint8_t bytesprops4[] = {0x6e, 0x12, 0xc9, 0x3c, 0x8f, 0x4b, 0xcd, 0x19, 0x8b, 0xfc, 0x68, 0xdf, 0xab, 0xfa, - 0xae, 0xa1, 0x7e, 0x2a, 0x76, 0x42, 0x77, 0x3a, 0x11, 0xff, 0x87, 0x1c, 0x9f}; - uint8_t bytesprops5[] = {0xab, 0x25, 0xb0, 0x71, 0xba, 0x30, 0xe1, 0xf7, 0x38, 0x71, - 0x6, 0x90, 0x1b, 0x30, 0xd3, 0x77, 0x43, 0xa7, 0xd, 0x6}; - uint8_t bytesprops6[] = {0xcc, 0x26, 0xd9, 0x7e, 0x63, 0x63, 0xb9, 0xd4, 0x7a, 0x6f, 0x55, 0xdc, - 0x9c, 0xc9, 0xea, 0x6d, 0xf3, 0x5b, 0x2c, 0x9e, 0x83, 0x57, 0xdf, 0xec}; - uint8_t bytesprops7[] = {0x3e, 0xc, 0x37, 0x6a, 0xc9, 0xba, 0x92, 0x64, 0x5f, 0xe0, 0xd4, 0xc0, 0xa3, - 0xb7, 0x8d, 0x27, 0x1, 0xf2, 0x4, 0x84, 0xe2, 0xf3, 0x6c, 0xe8, 0x3f, 0x54}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28123}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25705}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10652}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4455}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9441}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27038}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19854}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1994}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4973}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30803}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11156}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12789}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, - }; - - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xa1, 0x23, 0x97, 0x4f, 0xbc, 0xbb}; - uint8_t byteswillprops1[] = {0x5, 0xc, 0xe, 0x3, 0xc8, 0x0, 0xc4, 0x89, 0x56, 0xad, 0x48, 0x4f, 0xaa, 0x52, 0x3c}; - uint8_t byteswillprops2[] = {0}; - uint8_t byteswillprops3[] = {0xc2, 0x10, 0xef, 0x55, 0xaa, 0x8, 0xc5, 0xea, 0x5b, 0xd2, 0x8, - 0x8d, 0x9c, 0xf2, 0x88, 0x2c, 0x25, 0x3a, 0xf5, 0xd4, 0x3, 0x38}; - uint8_t byteswillprops4[] = {0xfc, 0x48, 0x97, 0x73, 0xf8, 0x3d, 0xd1, 0xaf, 0x3e, 0x80, 0x85, 0xba, 0x96, - 0x65, 0x71, 0x31, 0x67, 0xe0, 0x68, 0x74, 0x1, 0xdf, 0xa8, 0x3e, 0x12}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13488}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32098}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18726}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16300}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29904}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3698}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6587}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20654}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20352}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30495}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, - }; - - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x79, 0x85, 0xc, 0xde, 0x1e, 0x8e}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfc, 0x8e, 0xb9, 0xa5, 0xfc, 0xd3, 0x65, 0x7c, 0x1f, - 0xe4, 0xcd, 0x16, 0xc1, 0xe3, 0xff, 0xad, 0x4, 0x24}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 15842; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xb9, 0xd3, 0x2, 0xe1, 0x4, 0x86, 0x14, 0x12}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "eb:\159\169fA~\133\\\r6A7\139\&2\174\229Ue", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\255\245V\194\148\209\GS\f\218\140\201\EM/;H\146\135\176\253}\184\207V7.", _willMsg = -// "\SOH11\t\238\217?\210\\\EOT\223k\192\250?\156\178<\236+\SIQ\209\ACK\177\204\163", _willProps = -// [PropSessionExpiryInterval 26338,PropMessageExpiryInterval 482,PropWillDelayInterval -// 26497,PropRequestResponseInformation 255,PropSharedSubscriptionAvailable 121,PropMessageExpiryInterval -// 31822,PropRetainAvailable 10,PropAuthenticationData -// "\194\224\156f}\240\RSe\228\233JE\177s\133\ETB6\233P\NAK\n",PropRetainAvailable 150,PropSessionExpiryInterval -// 52,PropMaximumPacketSize 1043,PropReasonString "=(Q6\153\153H\167\151Q\217;\189\188F",PropResponseInformation -// "\196Z\175:\252\193Jd^]",PropTopicAliasMaximum 13915,PropAssignedClientIdentifier -// "\n\ETB\185z",PropResponseInformation "\144\SYN\182\ESC`\186\ETB\SO\137A\SO9Ix\SO\164yG",PropResponseInformation -// "F*O\232\147HTs\b\146?\146\EOT-\216\NAK\249\176\196\170\134s\248\&4\136\225\249\226\&2\134",PropWillDelayInterval -// 19003,PropResponseInformation "Z\143#\189\213V\174J\vn\SUB\228\186\230N\149A\165\156\&3",PropRetainAvailable -// 144,PropAssignedClientIdentifier "\161T\206\166%~+B\137B\SYN6\ACK\234"]}), _cleanSession = False, _keepAlive = 29642, -// _connID = "\212eR", _properties = [PropReceiveMaximum 17349]} -TEST(Connect5QCTest, Encode3) { - uint8_t pkt[] = { - 0x10, 0x99, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2c, 0x73, 0xca, 0x3, 0x21, 0x43, 0xc5, 0x0, 0x3, - 0xd4, 0x65, 0x52, 0xcc, 0x1, 0x11, 0x0, 0x0, 0x66, 0xe2, 0x2, 0x0, 0x0, 0x1, 0xe2, 0x18, 0x0, 0x0, 0x67, - 0x81, 0x19, 0xff, 0x2a, 0x79, 0x2, 0x0, 0x0, 0x7c, 0x4e, 0x25, 0xa, 0x16, 0x0, 0x15, 0xc2, 0xe0, 0x9c, 0x66, - 0x7d, 0xf0, 0x1e, 0x65, 0xe4, 0xe9, 0x4a, 0x45, 0xb1, 0x73, 0x85, 0x17, 0x36, 0xe9, 0x50, 0x15, 0xa, 0x25, 0x96, - 0x11, 0x0, 0x0, 0x0, 0x34, 0x27, 0x0, 0x0, 0x4, 0x13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 0x9c, 0xb2, 0x3c, 0xec, 0x2b, 0xf, 0x51, 0xd1, 0x6, 0xb1, 0xcc, 0xa3}; - - uint8_t buf[294] = {0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17349}}, - }; - - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc2, 0xe0, 0x9c, 0x66, 0x7d, 0xf0, 0x1e, 0x65, 0xe4, 0xe9, 0x4a, - 0x45, 0xb1, 0x73, 0x85, 0x17, 0x36, 0xe9, 0x50, 0x15, 0xa}; - uint8_t byteswillprops1[] = {0x3d, 0x28, 0x51, 0x36, 0x99, 0x99, 0x48, 0xa7, - 0x97, 0x51, 0xd9, 0x3b, 0xbd, 0xbc, 0x46}; - uint8_t byteswillprops2[] = {0xc4, 0x5a, 0xaf, 0x3a, 0xfc, 0xc1, 0x4a, 0x64, 0x5e, 0x5d}; - uint8_t byteswillprops3[] = {0xa, 0x17, 0xb9, 0x7a}; - uint8_t byteswillprops4[] = {0x90, 0x16, 0xb6, 0x1b, 0x60, 0xba, 0x17, 0xe, 0x89, - 0x41, 0xe, 0x39, 0x49, 0x78, 0xe, 0xa4, 0x79, 0x47}; - uint8_t byteswillprops5[] = {0x46, 0x2a, 0x4f, 0xe8, 0x93, 0x48, 0x54, 0x73, 0x8, 0x92, - 0x3f, 0x92, 0x4, 0x2d, 0xd8, 0x15, 0xf9, 0xb0, 0xc4, 0xaa, - 0x86, 0x73, 0xf8, 0x34, 0x88, 0xe1, 0xf9, 0xe2, 0x32, 0x86}; - uint8_t byteswillprops6[] = {0x5a, 0x8f, 0x23, 0xbd, 0xd5, 0x56, 0xae, 0x4a, 0xb, 0x6e, - 0x1a, 0xe4, 0xba, 0xe6, 0x4e, 0x95, 0x41, 0xa5, 0x9c, 0x33}; - uint8_t byteswillprops7[] = {0xa1, 0x54, 0xce, 0xa6, 0x25, 0x7e, 0x2b, 0x42, 0x89, 0x42, 0x16, 0x36, 0x6, 0xea}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26338}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 482}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26497}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31822}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 52}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1043}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13915}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19003}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops7}}}, - }; - - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xff, 0xf5, 0x56, 0xc2, 0x94, 0xd1, 0x1d, 0xc, 0xda, 0x8c, 0xc9, 0x19, 0x2f, - 0x3b, 0x48, 0x92, 0x87, 0xb0, 0xfd, 0x7d, 0xb8, 0xcf, 0x56, 0x37, 0x2e}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1, 0x31, 0x31, 0x9, 0xee, 0xd9, 0x3f, 0xd2, 0x5c, 0x4, 0xdf, 0x6b, 0xc0, 0xfa, - 0x3f, 0x9c, 0xb2, 0x3c, 0xec, 0x2b, 0xf, 0x51, 0xd1, 0x6, 0xb1, 0xcc, 0xa3}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 29642; - uint8_t client_id_bytes[] = {0xd4, 0x65, 0x52}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x65, 0x62, 0x3a, 0x9f, 0xa9, 0x66, 0x41, 0x7e, 0x85, 0x5c, - 0xd, 0x36, 0x41, 0x37, 0x8b, 0x32, 0xae, 0xe5, 0x55, 0x65}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\197\244\208\172eI\158\208\&4\a\235\DC4\182d\132\GS\189\130O\128\228\192 ", _willMsg = -// "\162T\168%T\161[\138\\\156~t\191\154\206\ETX", _willProps = [PropSharedSubscriptionAvailable -// 43,PropAssignedClientIdentifier -// "\151_\230h\aq}\US\DC1\150\190&\233\165y<\233\227\149\235\\!\DC1\186\254\208~\210",PropAuthenticationMethod -// "\128\\\158v\216}\183)\RS?\227\216\178D\ETB\US\246\153\a^za\202\152@",PropTopicAliasMaximum 14418,PropCorrelationData -// "[\188\234?\ETX\\",PropReceiveMaximum 29737,PropAuthenticationMethod -// "\207\157\198U\DC23\FS\137D\168\194\178\197,V\DC3\222Y\219\251\133.\SYN",PropPayloadFormatIndicator -// 164,PropTopicAlias 845,PropReceiveMaximum 23247,PropServerKeepAlive 6641,PropServerReference -// "\223\144\143=",PropServerKeepAlive 8003,PropAuthenticationMethod "\DC4\255\223i\148",PropWillDelayInterval -// 19857,PropContentType "\GS\v*,\184P\242-",PropUserProperty "\139[" "",PropMessageExpiryInterval 4340]}), -// _cleanSession = False, _keepAlive = 5339, _connID = "\194\163\154\203\EOTLMG`#\161l", _properties = [PropReasonString -// "\FS\203\156\EM\157nb\215\ETB\220\178\218\167\DC2\237\DC2\183\\b\CANR+g ",PropServerReference -// "\171\155\234\219?T\NUL\149o\192\234",PropAssignedClientIdentifier -// "i\210\&6\233\216\228\NAKf|\197\245",PropResponseInformation -// "'\185\237C\232g\163\183}\155'\198*%\204r\131",PropSubscriptionIdentifier 20,PropWildcardSubscriptionAvailable -// 62,PropResponseTopic "\225VS\179\DEL\"f\181O\149\164=\SOH\145",PropTopicAlias 28388,PropRequestResponseInformation -// 169,PropReceiveMaximum 20392,PropRequestProblemInformation 88,PropMessageExpiryInterval -// 9798,PropRequestProblemInformation 72,PropRetainAvailable 245,PropAuthenticationMethod " -// \136\205\&2\249\147\234\SOH(\185\183\SO\174\214V\132",PropUserProperty "\217\182dn\209j~\215\FS\211\203\205\192" -// "\DC1j\245x\NAK\176\206\188\192\251\149;\180}\DC3\195\NAK",PropTopicAliasMaximum 14104,PropTopicAliasMaximum -// 3973,PropReceiveMaximum 14160,PropWildcardSubscriptionAvailable 78,PropSubscriptionIdentifierAvailable -// 175,PropSessionExpiryInterval 31059,PropReceiveMaximum 29504,PropSessionExpiryInterval -// 27510,PropAssignedClientIdentifier ".\251M+0\162\fT\227\&8\"\141E&\186\t",PropResponseTopic -// "\158\DC2\160$\SUB\244\214"]} -TEST(Connect5QCTest, Encode4) { - uint8_t pkt[] = { - 0x10, 0xc6, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x24, 0x14, 0xdb, 0xe0, 0x1, 0x1f, 0x0, 0x18, 0x1c, - 0xcb, 0x9c, 0x19, 0x9d, 0x6e, 0x62, 0xd7, 0x17, 0xdc, 0xb2, 0xda, 0xa7, 0x12, 0xed, 0x12, 0xb7, 0x5c, 0x62, 0x18, - 0x52, 0x2b, 0x67, 0x20, 0x1c, 0x0, 0xb, 0xab, 0x9b, 0xea, 0xdb, 0x3f, 0x54, 0x0, 0x95, 0x6f, 0xc0, 0xea, 0x12, - 0x0, 0xb, 0x69, 0xd2, 0x36, 0xe9, 0xd8, 0xe4, 0x15, 0x66, 0x7c, 0xc5, 0xf5, 0x1a, 0x0, 0x11, 0x27, 0xb9, 0xed, - 0x43, 0xe8, 0x67, 0xa3, 0xb7, 0x7d, 0x9b, 0x27, 0xc6, 0x2a, 0x25, 0xcc, 0x72, 0x83, 0xb, 0x14, 0x28, 0x3e, 0x8, - 0x0, 0xe, 0xe1, 0x56, 0x53, 0xb3, 0x7f, 0x22, 0x66, 0xb5, 0x4f, 0x95, 0xa4, 0x3d, 0x1, 0x91, 0x23, 0x6e, 0xe4, - 0x19, 0xa9, 0x21, 0x4f, 0xa8, 0x17, 0x58, 0x2, 0x0, 0x0, 0x26, 0x46, 0x17, 0x48, 0x25, 0xf5, 0x15, 0x0, 0x10, - 0x20, 0x88, 0xcd, 0x32, 0xf9, 0x93, 0xea, 0x1, 0x28, 0xb9, 0xb7, 0xe, 0xae, 0xd6, 0x56, 0x84, 0x26, 0x0, 0xd, - 0xd9, 0xb6, 0x64, 0x6e, 0xd1, 0x6a, 0x7e, 0xd7, 0x1c, 0xd3, 0xcb, 0xcd, 0xc0, 0x0, 0x11, 0x11, 0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, 0x2e, 0x16, 0x1, 0xa4, 0x23, 0x3, - 0x4d, 0x21, 0x5a, 0xcf, 0x13, 0x19, 0xf1, 0x1c, 0x0, 0x4, 0xdf, 0x90, 0x8f, 0x3d, 0x13, 0x1f, 0x43, 0x15, 0x0, - 0x5, 0x14, 0xff, 0xdf, 0x69, 0x94, 0x18, 0x0, 0x0, 0x4d, 0x91, 0x3, 0x0, 0x8, 0x1d, 0xb, 0x2a, 0x2c, 0xb8, - 0x50, 0xf2, 0x2d, 0x26, 0x0, 0x2, 0x8b, 0x5b, 0x0, 0x0, 0x2, 0x0, 0x0, 0x10, 0xf4, 0x0, 0x17, 0xc5, 0xf4, - 0xd0, 0xac, 0x65, 0x49, 0x9e, 0xd0, 0x34, 0x7, 0xeb, 0x14, 0xb6, 0x64, 0x84, 0x1d, 0xbd, 0x82, 0x4f, 0x80, 0xe4, - 0xc0, 0x20, 0x0, 0x10, 0xa2, 0x54, 0xa8, 0x25, 0x54, 0xa1, 0x5b, 0x8a, 0x5c, 0x9c, 0x7e, 0x74, 0xbf, 0x9a, 0xce, - 0x3}; - - uint8_t buf[467] = {0}; - - uint8_t bytesprops0[] = {0x1c, 0xcb, 0x9c, 0x19, 0x9d, 0x6e, 0x62, 0xd7, 0x17, 0xdc, 0xb2, 0xda, - 0xa7, 0x12, 0xed, 0x12, 0xb7, 0x5c, 0x62, 0x18, 0x52, 0x2b, 0x67, 0x20}; - uint8_t bytesprops1[] = {0xab, 0x9b, 0xea, 0xdb, 0x3f, 0x54, 0x0, 0x95, 0x6f, 0xc0, 0xea}; - uint8_t bytesprops2[] = {0x69, 0xd2, 0x36, 0xe9, 0xd8, 0xe4, 0x15, 0x66, 0x7c, 0xc5, 0xf5}; - uint8_t bytesprops3[] = {0x27, 0xb9, 0xed, 0x43, 0xe8, 0x67, 0xa3, 0xb7, 0x7d, - 0x9b, 0x27, 0xc6, 0x2a, 0x25, 0xcc, 0x72, 0x83}; - uint8_t bytesprops4[] = {0xe1, 0x56, 0x53, 0xb3, 0x7f, 0x22, 0x66, 0xb5, 0x4f, 0x95, 0xa4, 0x3d, 0x1, 0x91}; - uint8_t bytesprops5[] = {0x20, 0x88, 0xcd, 0x32, 0xf9, 0x93, 0xea, 0x1, - 0x28, 0xb9, 0xb7, 0xe, 0xae, 0xd6, 0x56, 0x84}; - uint8_t bytesprops7[] = {0x11, 0x6a, 0xf5, 0x78, 0x15, 0xb0, 0xce, 0xbc, 0xc0, - 0xfb, 0x95, 0x3b, 0xb4, 0x7d, 0x13, 0xc3, 0x15}; - uint8_t bytesprops6[] = {0xd9, 0xb6, 0x64, 0x6e, 0xd1, 0x6a, 0x7e, 0xd7, 0x1c, 0xd3, 0xcb, 0xcd, 0xc0}; - uint8_t bytesprops8[] = {0x2e, 0xfb, 0x4d, 0x2b, 0x30, 0xa2, 0xc, 0x54, - 0xe3, 0x38, 0x22, 0x8d, 0x45, 0x26, 0xba, 0x9}; - uint8_t bytesprops9[] = {0x9e, 0x12, 0xa0, 0x24, 0x1a, 0xf4, 0xd6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28388}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20392}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9798}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops6}, .v = {17, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14104}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3973}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14160}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31059}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29504}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27510}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops9}}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x97, 0x5f, 0xe6, 0x68, 0x7, 0x71, 0x7d, 0x1f, 0x11, 0x96, 0xbe, 0x26, 0xe9, 0xa5, - 0x79, 0x3c, 0xe9, 0xe3, 0x95, 0xeb, 0x5c, 0x21, 0x11, 0xba, 0xfe, 0xd0, 0x7e, 0xd2}; - uint8_t byteswillprops1[] = {0x80, 0x5c, 0x9e, 0x76, 0xd8, 0x7d, 0xb7, 0x29, 0x1e, 0x3f, 0xe3, 0xd8, 0xb2, - 0x44, 0x17, 0x1f, 0xf6, 0x99, 0x7, 0x5e, 0x7a, 0x61, 0xca, 0x98, 0x40}; - uint8_t byteswillprops2[] = {0x5b, 0xbc, 0xea, 0x3f, 0x3, 0x5c}; - uint8_t byteswillprops3[] = {0xcf, 0x9d, 0xc6, 0x55, 0x12, 0x33, 0x1c, 0x89, 0x44, 0xa8, 0xc2, 0xb2, - 0xc5, 0x2c, 0x56, 0x13, 0xde, 0x59, 0xdb, 0xfb, 0x85, 0x2e, 0x16}; - uint8_t byteswillprops4[] = {0xdf, 0x90, 0x8f, 0x3d}; - uint8_t byteswillprops5[] = {0x14, 0xff, 0xdf, 0x69, 0x94}; - uint8_t byteswillprops6[] = {0x1d, 0xb, 0x2a, 0x2c, 0xb8, 0x50, 0xf2, 0x2d}; - uint8_t byteswillprops8[] = {0}; - uint8_t byteswillprops7[] = {0x8b, 0x5b}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14418}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29737}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 845}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23247}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6641}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8003}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19857}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {2, (char*)&byteswillprops7}, .v = {0, (char*)&byteswillprops8}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4340}}, - }; - - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc5, 0xf4, 0xd0, 0xac, 0x65, 0x49, 0x9e, 0xd0, 0x34, 0x7, 0xeb, 0x14, - 0xb6, 0x64, 0x84, 0x1d, 0xbd, 0x82, 0x4f, 0x80, 0xe4, 0xc0, 0x20}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa2, 0x54, 0xa8, 0x25, 0x54, 0xa1, 0x5b, 0x8a, - 0x5c, 0x9c, 0x7e, 0x74, 0xbf, 0x9a, 0xce, 0x3}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 5339; - uint8_t client_id_bytes[] = {0xc2, 0xa3, 0x9a, 0xcb, 0x4, 0x4c, 0x4d, 0x47, 0x60, 0x23, 0xa1, 0x6c}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\185\GSc\246\205\210\\\233\183w\EOT\252|-\224", _password = Nothing, _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\154\135@Q", _willMsg = -// "=\135\DEL\152\&4.\238\216\245h\157\130\aq\223\150:WI\169k\RS\149", _willProps = [PropTopicAlias -// 766,PropMaximumPacketSize 7651,PropSubscriptionIdentifierAvailable 2,PropReasonString -// "{\149\\\157P\181\&1<\n\145\166\249\142 \191\209\241\182Y\138r\204L5"]}), _cleanSession = False, _keepAlive = 23142, -// _connID = "J\242", _properties = [PropServerReference -// "\184\193\167\129\163u\196>\231\155Pzu8\SI\189\\JU\198\239,=\239P\222\DLE",PropAuthenticationMethod -// "",PropRequestResponseInformation 98,PropContentType -// "9d?:bS\182\t\n\220\152\254\RS\189v\252\189\199\210\196C\183\138\STX",PropRequestResponseInformation -// 232,PropSubscriptionIdentifier 12,PropMaximumPacketSize 23762,PropCorrelationData -// "\161\166!\166",PropSubscriptionIdentifier 30,PropRequestProblemInformation 91,PropRetainAvailable -// 79,PropAuthenticationData "_\ESC\156\&4\146/:",PropWildcardSubscriptionAvailable 233,PropTopicAliasMaximum -// 17503,PropSubscriptionIdentifierAvailable 181,PropMessageExpiryInterval 1386,PropPayloadFormatIndicator -// 179,PropServerKeepAlive 31777,PropRequestResponseInformation 171,PropWildcardSubscriptionAvailable -// 29,PropReasonString "\250m\RS\183;\183o\202g(\246\194\\#1\166\186\157\209\147\215\204\USZ\227S\156"]} -TEST(Connect5QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0xf7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb4, 0x5a, 0x66, 0x91, 0x1, 0x1c, 0x0, - 0x1b, 0xb8, 0xc1, 0xa7, 0x81, 0xa3, 0x75, 0xc4, 0x3e, 0xe7, 0x9b, 0x50, 0x7a, 0x75, 0x38, 0xf, 0xbd, - 0x5c, 0x4a, 0x55, 0xc6, 0xef, 0x2c, 0x3d, 0xef, 0x50, 0xde, 0x10, 0x15, 0x0, 0x0, 0x19, 0x62, 0x3, - 0x0, 0x18, 0x39, 0x64, 0x3f, 0x3a, 0x62, 0x53, 0xb6, 0x9, 0xa, 0xdc, 0x98, 0xfe, 0x1e, 0xbd, 0x76, - 0xfc, 0xbd, 0xc7, 0xd2, 0xc4, 0x43, 0xb7, 0x8a, 0x2, 0x19, 0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0xc4, 0x3e, 0xe7, 0x9b, 0x50, 0x7a, 0x75, 0x38, - 0xf, 0xbd, 0x5c, 0x4a, 0x55, 0xc6, 0xef, 0x2c, 0x3d, 0xef, 0x50, 0xde, 0x10}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x39, 0x64, 0x3f, 0x3a, 0x62, 0x53, 0xb6, 0x9, 0xa, 0xdc, 0x98, 0xfe, - 0x1e, 0xbd, 0x76, 0xfc, 0xbd, 0xc7, 0xd2, 0xc4, 0x43, 0xb7, 0x8a, 0x2}; - uint8_t bytesprops3[] = {0xa1, 0xa6, 0x21, 0xa6}; - uint8_t bytesprops4[] = {0x5f, 0x1b, 0x9c, 0x34, 0x92, 0x2f, 0x3a}; - uint8_t bytesprops5[] = {0xfa, 0x6d, 0x1e, 0xb7, 0x3b, 0xb7, 0x6f, 0xca, 0x67, 0x28, 0xf6, 0xc2, 0x5c, 0x23, - 0x31, 0xa6, 0xba, 0x9d, 0xd1, 0x93, 0xd7, 0xcc, 0x1f, 0x5a, 0xe3, 0x53, 0x9c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23762}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17503}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1386}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31777}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x7b, 0x95, 0x5c, 0x9d, 0x50, 0xb5, 0x31, 0x3c, 0xa, 0x91, 0xa6, 0xf9, - 0x8e, 0x20, 0xbf, 0xd1, 0xf1, 0xb6, 0x59, 0x8a, 0x72, 0xcc, 0x4c, 0x35}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 766}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7651}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops0}}}, - }; - - lwmqtt_properties_t willprops = {4, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9a, 0x87, 0x40, 0x51}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3d, 0x87, 0x7f, 0x98, 0x34, 0x2e, 0xee, 0xd8, 0xf5, 0x68, 0x9d, 0x82, - 0x7, 0x71, 0xdf, 0x96, 0x3a, 0x57, 0x49, 0xa9, 0x6b, 0x1e, 0x95}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 23142; - uint8_t client_id_bytes[] = {0x4a, 0xf2}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xb9, 0x1d, 0x63, 0xf6, 0xcd, 0xd2, 0x5c, 0xe9, 0xb7, 0x77, 0x4, 0xfc, 0x7c, 0x2d, 0xe0}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just -// "\240\223\219|\165/\216\169G\212Ta\158=\151\215\242\164\220\199\164\236\142\249\194\194\EMU\245\214", _password = -// Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 11621, _connID = "Y", _properties = -// [PropRequestProblemInformation 243,PropSharedSubscriptionAvailable 87,PropTopicAliasMaximum 3301,PropResponseTopic -// "\209\151\221A\147\217+j\220\EM"]} -TEST(Connect5QCTest, Encode6) { - uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x80, 0x2d, 0x65, 0x14, 0x17, - 0xf3, 0x2a, 0x57, 0x22, 0xc, 0xe5, 0x8, 0x0, 0xa, 0xd1, 0x97, 0xdd, 0x41, 0x93, - 0xd9, 0x2b, 0x6a, 0xdc, 0x19, 0x0, 0x1, 0x59, 0x0, 0x1e, 0xf0, 0xdf, 0xdb, 0x7c, - 0xa5, 0x2f, 0xd8, 0xa9, 0x47, 0xd4, 0x54, 0x61, 0x9e, 0x3d, 0x97, 0xd7, 0xf2, 0xa4, - 0xdc, 0xc7, 0xa4, 0xec, 0x8e, 0xf9, 0xc2, 0xc2, 0x19, 0x55, 0xf5, 0xd6}; - - uint8_t buf[78] = {0}; - - uint8_t bytesprops0[] = {0xd1, 0x97, 0xdd, 0x41, 0x93, 0xd9, 0x2b, 0x6a, 0xdc, 0x19}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3301}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops0}}}, - }; - - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 11621; - uint8_t client_id_bytes[] = {0x59}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xf0, 0xdf, 0xdb, 0x7c, 0xa5, 0x2f, 0xd8, 0xa9, 0x47, 0xd4, 0x54, 0x61, 0x9e, 0x3d, 0x97, - 0xd7, 0xf2, 0xa4, 0xdc, 0xc7, 0xa4, 0xec, 0x8e, 0xf9, 0xc2, 0xc2, 0x19, 0x55, 0xf5, 0xd6}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "]\218\DC2\160G\231\&5\185\137ZQ", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 32745, _connID = "\248\163cDx\241\168\&8\140/\228\161\192\&3o\168\223", -// _properties = [PropRetainAvailable 32,PropMessageExpiryInterval 31926,PropReceiveMaximum 835,PropResponseTopic -// "F\175=`\156q.\NAK)\232\201\167@\DEL\234",PropAssignedClientIdentifier -// "\133P\247\137J9.6\205\237\134\136\158\182\201\199\220\129\a\SO/\152!\GS",PropUserProperty -// "\214!]X\162\196I\230oq:\201" "\255tEC\CAN\234`\218",PropReceiveMaximum 18678,PropMaximumQoS -// 69,PropPayloadFormatIndicator 124,PropReasonString "\NAK\196-\173\244\231VI\164\f\215\202\147\166`_5fJ -// \230Fr\DC4\220\SUB\159",PropSubscriptionIdentifierAvailable 239,PropReasonString -// "\253\148\186\179\148",PropPayloadFormatIndicator 188,PropUserProperty "W\165jy" "{",PropCorrelationData -// "\128\&3\135\137\254\188\196\203",PropUserProperty "\ESC\b.Z\203\247#-\184/G" -// "\220]\241@z%\230!qy\FS\204J\153\218",PropMessageExpiryInterval 5765,PropReasonString -// "\ENQ7\184\f\153\254d\212",PropReceiveMaximum 10985]} -TEST(Connect5QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0xe7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x7f, 0xe9, 0xc8, 0x1, 0x25, 0x20, - 0x2, 0x0, 0x0, 0x7c, 0xb6, 0x21, 0x3, 0x43, 0x8, 0x0, 0xf, 0x46, 0xaf, 0x3d, 0x60, 0x9c, 0x71, - 0x2e, 0x15, 0x29, 0xe8, 0xc9, 0xa7, 0x40, 0x7f, 0xea, 0x12, 0x0, 0x18, 0x85, 0x50, 0xf7, 0x89, 0x4a, - 0x39, 0x2e, 0x36, 0xcd, 0xed, 0x86, 0x88, 0x9e, 0xb6, 0xc9, 0xc7, 0xdc, 0x81, 0x7, 0xe, 0x2f, 0x98, - 0x21, 0x1d, 0x26, 0x0, 0xc, 0xd6, 0x21, 0x5d, 0x58, 0xa2, 0xc4, 0x49, 0xe6, 0x6f, 0x71, 0x3a, 0xc9, - 0x0, 0x8, 0xff, 0x74, 0x45, 0x43, 0x18, 0xea, 0x60, 0xda, 0x21, 0x48, 0xf6, 0x24, 0x45, 0x1, 0x7c, - 0x1f, 0x0, 0x1b, 0x15, 0xc4, 0x2d, 0xad, 0xf4, 0xe7, 0x56, 0x49, 0xa4, 0xc, 0xd7, 0xca, 0x93, 0xa6, - 0x60, 0x5f, 0x35, 0x66, 0x4a, 0x20, 0xe6, 0x46, 0x72, 0x14, 0xdc, 0x1a, 0x9f, 0x29, 0xef, 0x1f, 0x0, - 0x5, 0xfd, 0x94, 0xba, 0xb3, 0x94, 0x1, 0xbc, 0x26, 0x0, 0x4, 0x57, 0xa5, 0x6a, 0x79, 0x0, 0x1, - 0x7b, 0x9, 0x0, 0x8, 0x80, 0x33, 0x87, 0x89, 0xfe, 0xbc, 0xc4, 0xcb, 0x26, 0x0, 0xb, 0x1b, 0x8, - 0x2e, 0x5a, 0xcb, 0xf7, 0x23, 0x2d, 0xb8, 0x2f, 0x47, 0x0, 0xf, 0xdc, 0x5d, 0xf1, 0x40, 0x7a, 0x25, - 0xe6, 0x21, 0x71, 0x79, 0x1c, 0xcc, 0x4a, 0x99, 0xda, 0x2, 0x0, 0x0, 0x16, 0x85, 0x1f, 0x0, 0x8, - 0x5, 0x37, 0xb8, 0xc, 0x99, 0xfe, 0x64, 0xd4, 0x21, 0x2a, 0xe9, 0x0, 0x11, 0xf8, 0xa3, 0x63, 0x44, - 0x78, 0xf1, 0xa8, 0x38, 0x8c, 0x2f, 0xe4, 0xa1, 0xc0, 0x33, 0x6f, 0xa8, 0xdf}; - - uint8_t buf[244] = {0}; - - uint8_t bytesprops0[] = {0x46, 0xaf, 0x3d, 0x60, 0x9c, 0x71, 0x2e, 0x15, 0x29, 0xe8, 0xc9, 0xa7, 0x40, 0x7f, 0xea}; - uint8_t bytesprops1[] = {0x85, 0x50, 0xf7, 0x89, 0x4a, 0x39, 0x2e, 0x36, 0xcd, 0xed, 0x86, 0x88, - 0x9e, 0xb6, 0xc9, 0xc7, 0xdc, 0x81, 0x7, 0xe, 0x2f, 0x98, 0x21, 0x1d}; - uint8_t bytesprops3[] = {0xff, 0x74, 0x45, 0x43, 0x18, 0xea, 0x60, 0xda}; - uint8_t bytesprops2[] = {0xd6, 0x21, 0x5d, 0x58, 0xa2, 0xc4, 0x49, 0xe6, 0x6f, 0x71, 0x3a, 0xc9}; - uint8_t bytesprops4[] = {0x15, 0xc4, 0x2d, 0xad, 0xf4, 0xe7, 0x56, 0x49, 0xa4, 0xc, 0xd7, 0xca, 0x93, 0xa6, - 0x60, 0x5f, 0x35, 0x66, 0x4a, 0x20, 0xe6, 0x46, 0x72, 0x14, 0xdc, 0x1a, 0x9f}; - uint8_t bytesprops5[] = {0xfd, 0x94, 0xba, 0xb3, 0x94}; - uint8_t bytesprops7[] = {0x7b}; - uint8_t bytesprops6[] = {0x57, 0xa5, 0x6a, 0x79}; - uint8_t bytesprops8[] = {0x80, 0x33, 0x87, 0x89, 0xfe, 0xbc, 0xc4, 0xcb}; - uint8_t bytesprops10[] = {0xdc, 0x5d, 0xf1, 0x40, 0x7a, 0x25, 0xe6, 0x21, 0x71, 0x79, 0x1c, 0xcc, 0x4a, 0x99, 0xda}; - uint8_t bytesprops9[] = {0x1b, 0x8, 0x2e, 0x5a, 0xcb, 0xf7, 0x23, 0x2d, 0xb8, 0x2f, 0x47}; - uint8_t bytesprops11[] = {0x5, 0x37, 0xb8, 0xc, 0x99, 0xfe, 0x64, 0xd4}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31926}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 835}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops2}, .v = {8, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18678}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops6}, .v = {1, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops9}, .v = {15, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5765}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10985}}, - }; - - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32745; - uint8_t client_id_bytes[] = {0xf8, 0xa3, 0x63, 0x44, 0x78, 0xf1, 0xa8, 0x38, 0x8c, - 0x2f, 0xe4, 0xa1, 0xc0, 0x33, 0x6f, 0xa8, 0xdf}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x5d, 0xda, 0x12, 0xa0, 0x47, 0xe7, 0x35, 0xb9, 0x89, 0x5a, 0x51}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\NUL\136\181", _password = Just -// "d%\139\252\SUB\v\232)\218\ESC\DC3\212F\DC1\238\243j\SO\251\168", _lastWill = Nothing, _cleanSession = False, -// _keepAlive = 14321, _connID = "\SOHH\187\196\DEL\173\132\&0wH\SI\210C\131\DC4", _properties = [PropMaximumPacketSize -// 18542,PropSubscriptionIdentifier 6,PropSessionExpiryInterval 28295,PropReasonString -// "\254\161\194\f\176\DLE\252\GS",PropMessageExpiryInterval 16473,PropSubscriptionIdentifierAvailable -// 217,PropServerKeepAlive 3242,PropMessageExpiryInterval 15053,PropTopicAlias 18566,PropReceiveMaximum -// 5338,PropMaximumPacketSize 7337,PropPayloadFormatIndicator 60,PropSharedSubscriptionAvailable -// 252,PropAuthenticationData -// "\193\229\138L`\212\245\245\207Y\151s\130\184\EOTm\178D\254\EOT\150k\219J\164;\153w\156",PropSharedSubscriptionAvailable -// 36,PropWillDelayInterval 23076,PropMessageExpiryInterval 5605,PropMaximumPacketSize 11005]} -TEST(Connect5QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x9d, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x37, 0xf1, 0x66, 0x27, 0x0, - 0x0, 0x48, 0x6e, 0xb, 0x6, 0x11, 0x0, 0x0, 0x6e, 0x87, 0x1f, 0x0, 0x8, 0xfe, 0xa1, 0xc2, - 0xc, 0xb0, 0x10, 0xfc, 0x1d, 0x2, 0x0, 0x0, 0x40, 0x59, 0x29, 0xd9, 0x13, 0xc, 0xaa, 0x2, - 0x0, 0x0, 0x3a, 0xcd, 0x23, 0x48, 0x86, 0x21, 0x14, 0xda, 0x27, 0x0, 0x0, 0x1c, 0xa9, 0x1, - 0x3c, 0x2a, 0xfc, 0x16, 0x0, 0x1d, 0xc1, 0xe5, 0x8a, 0x4c, 0x60, 0xd4, 0xf5, 0xf5, 0xcf, 0x59, - 0x97, 0x73, 0x82, 0xb8, 0x4, 0x6d, 0xb2, 0x44, 0xfe, 0x4, 0x96, 0x6b, 0xdb, 0x4a, 0xa4, 0x3b, - 0x99, 0x77, 0x9c, 0x2a, 0x24, 0x18, 0x0, 0x0, 0x5a, 0x24, 0x2, 0x0, 0x0, 0x15, 0xe5, 0x27, - 0x0, 0x0, 0x2a, 0xfd, 0x0, 0xf, 0x1, 0x48, 0xbb, 0xc4, 0x7f, 0xad, 0x84, 0x30, 0x77, 0x48, - 0xf, 0xd2, 0x43, 0x83, 0x14, 0x0, 0x3, 0x0, 0x88, 0xb5, 0x0, 0x14, 0x64, 0x25, 0x8b, 0xfc, - 0x1a, 0xb, 0xe8, 0x29, 0xda, 0x1b, 0x13, 0xd4, 0x46, 0x11, 0xee, 0xf3, 0x6a, 0xe, 0xfb, 0xa8}; - - uint8_t buf[170] = {0}; - - uint8_t bytesprops0[] = {0xfe, 0xa1, 0xc2, 0xc, 0xb0, 0x10, 0xfc, 0x1d}; - uint8_t bytesprops1[] = {0xc1, 0xe5, 0x8a, 0x4c, 0x60, 0xd4, 0xf5, 0xf5, 0xcf, 0x59, 0x97, 0x73, 0x82, 0xb8, 0x4, - 0x6d, 0xb2, 0x44, 0xfe, 0x4, 0x96, 0x6b, 0xdb, 0x4a, 0xa4, 0x3b, 0x99, 0x77, 0x9c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18542}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28295}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16473}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3242}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15053}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18566}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5338}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7337}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23076}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5605}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11005}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 14321; - uint8_t client_id_bytes[] = {0x1, 0x48, 0xbb, 0xc4, 0x7f, 0xad, 0x84, 0x30, 0x77, 0x48, 0xf, 0xd2, 0x43, 0x83, 0x14}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x0, 0x88, 0xb5}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x64, 0x25, 0x8b, 0xfc, 0x1a, 0xb, 0xe8, 0x29, 0xda, 0x1b, - 0x13, 0xd4, 0x46, 0x11, 0xee, 0xf3, 0x6a, 0xe, 0xfb, 0xa8}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\142\224!;+'mV", _password = Just -// "{h\173\&5]\vz\\P\196\181X.\"B~\207\241\156]f\195X\DC1\203u\149\151\249", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "S]\n\ETB[\ACK)\233\177\225N\218\162\EM\240p\239O", _willMsg = "\183", -// _willProps = [PropUserProperty "\214\RS\197\&8\179\187^NZ\DC4\196`\202s" -// "\a\172\216\SUB\230\244\162\"\220\186\184mt",PropMessageExpiryInterval 13266]}), _cleanSession = False, _keepAlive = -// 24734, _connID = "gYE\207\225\215\192", _properties = [PropSessionExpiryInterval -// 27757,PropSharedSubscriptionAvailable 215,PropSubscriptionIdentifierAvailable 2,PropWildcardSubscriptionAvailable -// 117,PropAssignedClientIdentifier -// "r\183\186\190\&2`\DC1\236\240\235:\DC2~|a^\162\b\165\224\168'\133G\136C\"",PropServerReference -// "P\148I\166\&6%\170\216n\212 \DLE\DEL>\204B\247\133\211ef/\232\140)",PropResponseTopic -// "\233",PropWildcardSubscriptionAvailable 19,PropWillDelayInterval 3899,PropAuthenticationMethod -// "\"\166\238\NAK\193\SO\213\160\&5~\244g\b]\233.X\230\228P",PropContentType -// "RS\255\241s3",PropWildcardSubscriptionAvailable 86,PropTopicAlias 8716,PropAuthenticationMethod -// "\189u\STXY\136\242\DC4\228\228'\167\199\DC3\218gc\253",PropSessionExpiryInterval 13590,PropRequestProblemInformation -// 199,PropTopicAliasMaximum 19507,PropServerKeepAlive 11841,PropRequestResponseInformation -// 173,PropRequestProblemInformation 35,PropRetainAvailable 16,PropMaximumQoS 13,PropResponseInformation -// "8!\227\DC2=+\169dj\138\150)]\137",PropWildcardSubscriptionAvailable 16,PropMessageExpiryInterval -// 16226,PropRequestResponseInformation 221,PropResponseTopic -// "\b\172\fp\133\221\200\138\242\239\128\"i?q\170\DC4\216\226\189\234\CANYi?\199",PropResponseInformation -// "",PropWildcardSubscriptionAvailable 12]} -TEST(Connect5QCTest, Encode9) { - uint8_t pkt[] = { - 0x10, 0xd5, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x60, 0x9e, 0xda, 0x1, 0x11, 0x0, 0x0, 0x6c, - 0x6d, 0x2a, 0xd7, 0x29, 0x2, 0x28, 0x75, 0x12, 0x0, 0x1b, 0x72, 0xb7, 0xba, 0xbe, 0x32, 0x60, 0x11, 0xec, 0xf0, - 0xeb, 0x3a, 0x12, 0x7e, 0x7c, 0x61, 0x5e, 0xa2, 0x8, 0xa5, 0xe0, 0xa8, 0x27, 0x85, 0x47, 0x88, 0x43, 0x22, 0x1c, - 0x0, 0x19, 0x50, 0x94, 0x49, 0xa6, 0x36, 0x25, 0xaa, 0xd8, 0x6e, 0xd4, 0x20, 0x10, 0x7f, 0x3e, 0xcc, 0x42, 0xf7, - 0x85, 0xd3, 0x65, 0x66, 0x2f, 0xe8, 0x8c, 0x29, 0x8, 0x0, 0x1, 0xe9, 0x28, 0x13, 0x18, 0x0, 0x0, 0xf, 0x3b, - 0x15, 0x0, 0x14, 0x22, 0xa6, 0xee, 0x15, 0xc1, 0xe, 0xd5, 0xa0, 0x35, 0x7e, 0xf4, 0x67, 0x8, 0x5d, 0xe9, 0x2e, - 0x58, 0xe6, 0xe4, 0x50, 0x3, 0x0, 0x6, 0x52, 0x53, 0xff, 0xf1, 0x73, 0x33, 0x28, 0x56, 0x23, 0x22, 0xc, 0x15, - 0x0, 0x11, 0xbd, 0x75, 0x2, 0x59, 0x88, 0xf2, 0x14, 0xe4, 0xe4, 0x27, 0xa7, 0xc7, 0x13, 0xda, 0x67, 0x63, 0xfd, - 0x11, 0x0, 0x0, 0x35, 0x16, 0x17, 0xc7, 0x22, 0x4c, 0x33, 0x13, 0x2e, 0x41, 0x19, 0xad, 0x17, 0x23, 0x25, 0x10, - 0x24, 0xd, 0x1a, 0x0, 0xe, 0x38, 0x21, 0xe3, 0x12, 0x3d, 0x2b, 0xa9, 0x64, 0x6a, 0x8a, 0x96, 0x29, 0x5d, 0x89, - 0x28, 0x10, 0x2, 0x0, 0x0, 0x3f, 0x62, 0x19, 0xdd, 0x8, 0x0, 0x1a, 0x8, 0xac, 0xc, 0x70, 0x85, 0xdd, 0xc8, - 0x8a, 0xf2, 0xef, 0x80, 0x22, 0x69, 0x3f, 0x71, 0xaa, 0x14, 0xd8, 0xe2, 0xbd, 0xea, 0x18, 0x59, 0x69, 0x3f, 0xc7, - 0x1a, 0x0, 0x0, 0x28, 0xc, 0x0, 0x7, 0x67, 0x59, 0x45, 0xcf, 0xe1, 0xd7, 0xc0, 0x25, 0x26, 0x0, 0xe, 0xd6, - 0x1e, 0xc5, 0x38, 0xb3, 0xbb, 0x5e, 0x4e, 0x5a, 0x14, 0xc4, 0x60, 0xca, 0x73, 0x0, 0xd, 0x7, 0xac, 0xd8, 0x1a, - 0xe6, 0xf4, 0xa2, 0x22, 0xdc, 0xba, 0xb8, 0x6d, 0x74, 0x2, 0x0, 0x0, 0x33, 0xd2, 0x0, 0x12, 0x53, 0x5d, 0xa, - 0x17, 0x5b, 0x6, 0x29, 0xe9, 0xb1, 0xe1, 0x4e, 0xda, 0xa2, 0x19, 0xf0, 0x70, 0xef, 0x4f, 0x0, 0x1, 0xb7, 0x0, - 0x8, 0x8e, 0xe0, 0x21, 0x3b, 0x2b, 0x27, 0x6d, 0x56, 0x0, 0x1d, 0x7b, 0x68, 0xad, 0x35, 0x5d, 0xb, 0x7a, 0x5c, - 0x50, 0xc4, 0xb5, 0x58, 0x2e, 0x22, 0x42, 0x7e, 0xcf, 0xf1, 0x9c, 0x5d, 0x66, 0xc3, 0x58, 0x11, 0xcb, 0x75, 0x95, - 0x97, 0xf9}; - - uint8_t buf[354] = {0}; - - uint8_t bytesprops0[] = {0x72, 0xb7, 0xba, 0xbe, 0x32, 0x60, 0x11, 0xec, 0xf0, 0xeb, 0x3a, 0x12, 0x7e, 0x7c, - 0x61, 0x5e, 0xa2, 0x8, 0xa5, 0xe0, 0xa8, 0x27, 0x85, 0x47, 0x88, 0x43, 0x22}; - uint8_t bytesprops1[] = {0x50, 0x94, 0x49, 0xa6, 0x36, 0x25, 0xaa, 0xd8, 0x6e, 0xd4, 0x20, 0x10, 0x7f, - 0x3e, 0xcc, 0x42, 0xf7, 0x85, 0xd3, 0x65, 0x66, 0x2f, 0xe8, 0x8c, 0x29}; - uint8_t bytesprops2[] = {0xe9}; - uint8_t bytesprops3[] = {0x22, 0xa6, 0xee, 0x15, 0xc1, 0xe, 0xd5, 0xa0, 0x35, 0x7e, - 0xf4, 0x67, 0x8, 0x5d, 0xe9, 0x2e, 0x58, 0xe6, 0xe4, 0x50}; - uint8_t bytesprops4[] = {0x52, 0x53, 0xff, 0xf1, 0x73, 0x33}; - uint8_t bytesprops5[] = {0xbd, 0x75, 0x2, 0x59, 0x88, 0xf2, 0x14, 0xe4, 0xe4, - 0x27, 0xa7, 0xc7, 0x13, 0xda, 0x67, 0x63, 0xfd}; - uint8_t bytesprops6[] = {0x38, 0x21, 0xe3, 0x12, 0x3d, 0x2b, 0xa9, 0x64, 0x6a, 0x8a, 0x96, 0x29, 0x5d, 0x89}; - uint8_t bytesprops7[] = {0x8, 0xac, 0xc, 0x70, 0x85, 0xdd, 0xc8, 0x8a, 0xf2, 0xef, 0x80, 0x22, 0x69, - 0x3f, 0x71, 0xaa, 0x14, 0xd8, 0xe2, 0xbd, 0xea, 0x18, 0x59, 0x69, 0x3f, 0xc7}; - uint8_t bytesprops8[] = {0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27757}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3899}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8716}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13590}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19507}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11841}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16226}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 12}}, - }; - - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x7, 0xac, 0xd8, 0x1a, 0xe6, 0xf4, 0xa2, 0x22, 0xdc, 0xba, 0xb8, 0x6d, 0x74}; - uint8_t byteswillprops0[] = {0xd6, 0x1e, 0xc5, 0x38, 0xb3, 0xbb, 0x5e, 0x4e, 0x5a, 0x14, 0xc4, 0x60, 0xca, 0x73}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {14, (char*)&byteswillprops0}, .v = {13, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13266}}, - }; - - lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x53, 0x5d, 0xa, 0x17, 0x5b, 0x6, 0x29, 0xe9, 0xb1, - 0xe1, 0x4e, 0xda, 0xa2, 0x19, 0xf0, 0x70, 0xef, 0x4f}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb7}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 24734; - uint8_t client_id_bytes[] = {0x67, 0x59, 0x45, 0xcf, 0xe1, 0xd7, 0xc0}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x8e, 0xe0, 0x21, 0x3b, 0x2b, 0x27, 0x6d, 0x56}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x7b, 0x68, 0xad, 0x35, 0x5d, 0xb, 0x7a, 0x5c, 0x50, 0xc4, 0xb5, 0x58, 0x2e, 0x22, 0x42, - 0x7e, 0xcf, 0xf1, 0x9c, 0x5d, 0x66, 0xc3, 0x58, 0x11, 0xcb, 0x75, 0x95, 0x97, 0xf9}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\r7\"\154\EOT", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "\\\131\211\214\209\183\242\162", _willMsg = ")&", _willProps = -// [PropAuthenticationMethod "$\252\SUB,\144>",PropSessionExpiryInterval 30269,PropAssignedClientIdentifier -// "S\129\b\221\156\a\132\&2\234\244\246",PropSubscriptionIdentifierAvailable 97,PropServerKeepAlive 5359]}), -// _cleanSession = False, _keepAlive = 17778, _connID = "\160\202\220\&9^\188\ENQ\223w\149\158\233", _properties = -// [PropContentType -// "\157~\235\155\148a\137\217\224\a\133XA\162>\149\131\b\240\249[z\234Qr\184",PropWildcardSubscriptionAvailable -// 175,PropRetainAvailable 178,PropSubscriptionIdentifierAvailable 1,PropAuthenticationMethod -// "\167\222\132q]P\252\198\FS\185\EOT\240\ESC\129\227?\208\191K\217",PropSubscriptionIdentifierAvailable -// 161,PropReceiveMaximum 28268,PropMaximumPacketSize 10703,PropSessionExpiryInterval 6418,PropMessageExpiryInterval -// 30728,PropRequestProblemInformation 91,PropTopicAliasMaximum 27090,PropSubscriptionIdentifier -// 30,PropSubscriptionIdentifier 27,PropSessionExpiryInterval 20709,PropContentType -// "$\251|\ENQ.IC\148\139\228]8[\190E\183zm|\155Cz",PropRetainAvailable 235,PropResponseTopic -// "@\181\230\n\167P\194\163S\DEL\244\181'\227",PropReceiveMaximum 6854,PropMaximumPacketSize 2644,PropCorrelationData -// "\191\188L\252\216q\190\182\182\132j\194\USx\f\143\FS\241\161\SI\STX\GS[",PropMaximumPacketSize -// 20784,PropMessageExpiryInterval 30567,PropReasonString -// "\RSJ\181\235\172\ESC\208\157\f\252\147\&5\181\168p\183\222.\156\164\180\139B~\FS\a\DC4Q",PropServerKeepAlive -// 31825,PropMaximumPacketSize 21098]} -TEST(Connect5QCTest, Encode10) { - uint8_t pkt[] = { - 0x10, 0xac, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8c, 0x45, 0x72, 0xdb, 0x1, 0x3, 0x0, 0x1a, 0x9d, - 0x7e, 0xeb, 0x9b, 0x94, 0x61, 0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, 0xb5, 0xa8, 0x70, 0xb7, 0xde, 0x2e, 0x9c, 0xa4, 0xb4, 0x8b, 0x42, 0x7e, 0x1c, 0x7, 0x14, 0x51, 0x13, 0x7c, - 0x51, 0x27, 0x0, 0x0, 0x52, 0x6a, 0x0, 0xc, 0xa0, 0xca, 0xdc, 0x39, 0x5e, 0xbc, 0x5, 0xdf, 0x77, 0x95, 0x9e, - 0xe9, 0x21, 0x15, 0x0, 0x6, 0x24, 0xfc, 0x1a, 0x2c, 0x90, 0x3e, 0x11, 0x0, 0x0, 0x76, 0x3d, 0x12, 0x0, 0xb, - 0x53, 0x81, 0x8, 0xdd, 0x9c, 0x7, 0x84, 0x32, 0xea, 0xf4, 0xf6, 0x29, 0x61, 0x13, 0x14, 0xef, 0x0, 0x8, 0x5c, - 0x83, 0xd3, 0xd6, 0xd1, 0xb7, 0xf2, 0xa2, 0x0, 0x2, 0x29, 0x26, 0x0, 0x5, 0xd, 0x37, 0x22, 0x9a, 0x4}; - - uint8_t buf[313] = {0}; - - uint8_t bytesprops0[] = {0x9d, 0x7e, 0xeb, 0x9b, 0x94, 0x61, 0x89, 0xd9, 0xe0, 0x7, 0x85, 0x58, 0x41, - 0xa2, 0x3e, 0x95, 0x83, 0x8, 0xf0, 0xf9, 0x5b, 0x7a, 0xea, 0x51, 0x72, 0xb8}; - uint8_t bytesprops1[] = {0xa7, 0xde, 0x84, 0x71, 0x5d, 0x50, 0xfc, 0xc6, 0x1c, 0xb9, - 0x4, 0xf0, 0x1b, 0x81, 0xe3, 0x3f, 0xd0, 0xbf, 0x4b, 0xd9}; - uint8_t bytesprops2[] = {0x24, 0xfb, 0x7c, 0x5, 0x2e, 0x49, 0x43, 0x94, 0x8b, 0xe4, 0x5d, - 0x38, 0x5b, 0xbe, 0x45, 0xb7, 0x7a, 0x6d, 0x7c, 0x9b, 0x43, 0x7a}; - uint8_t bytesprops3[] = {0x40, 0xb5, 0xe6, 0xa, 0xa7, 0x50, 0xc2, 0xa3, 0x53, 0x7f, 0xf4, 0xb5, 0x27, 0xe3}; - uint8_t bytesprops4[] = {0xbf, 0xbc, 0x4c, 0xfc, 0xd8, 0x71, 0xbe, 0xb6, 0xb6, 0x84, 0x6a, 0xc2, - 0x1f, 0x78, 0xc, 0x8f, 0x1c, 0xf1, 0xa1, 0xf, 0x2, 0x1d, 0x5b}; - uint8_t bytesprops5[] = {0x1e, 0x4a, 0xb5, 0xeb, 0xac, 0x1b, 0xd0, 0x9d, 0xc, 0xfc, 0x93, 0x35, 0xb5, 0xa8, - 0x70, 0xb7, 0xde, 0x2e, 0x9c, 0xa4, 0xb4, 0x8b, 0x42, 0x7e, 0x1c, 0x7, 0x14, 0x51}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28268}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10703}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6418}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30728}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27090}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20709}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6854}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2644}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20784}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30567}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31825}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21098}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x24, 0xfc, 0x1a, 0x2c, 0x90, 0x3e}; - uint8_t byteswillprops1[] = {0x53, 0x81, 0x8, 0xdd, 0x9c, 0x7, 0x84, 0x32, 0xea, 0xf4, 0xf6}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30269}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5359}}, - }; - - lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5c, 0x83, 0xd3, 0xd6, 0xd1, 0xb7, 0xf2, 0xa2}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x29, 0x26}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 17778; - uint8_t client_id_bytes[] = {0xa0, 0xca, 0xdc, 0x39, 0x5e, 0xbc, 0x5, 0xdf, 0x77, 0x95, 0x9e, 0xe9}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xd, 0x37, 0x22, 0x9a, 0x4}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\181\bX\195\NULZ\169\250\173\230E\239g\209\226\145:pJ ^\SO\192\SYN,V\138\226", -// _password = Just "b\129\SOH\222>\130\229h\251\208QM\146\255\&3 \190\166Ty\CAN\211\154\208\148hWO\146P\DC2\208r\209\180\253\215F\211\223,\ESC",PropSharedSubscriptionAvailable -// 34,PropMaximumPacketSize 24332,PropAuthenticationMethod -// "\rt\ETX8\130\135Y\209L\236J!\253\&4\213\250\243\184\134\190T\aC\236",PropMaximumQoS 126,PropAuthenticationMethod -// "\212h\236h",PropPayloadFormatIndicator 139,PropWildcardSubscriptionAvailable 99,PropTopicAliasMaximum -// 31936,PropTopicAliasMaximum 21507,PropContentType "\FS\252\206\173j\a$\200\133H\rM\n\241\215\SI?]"]}), _cleanSession -// = False, _keepAlive = 3108, _connID = "\211\250\245_\185\238\&6\147\133\144c\168\US\246\SUB\175\170|HZ\184\nE", -// _properties = [PropWildcardSubscriptionAvailable 245,PropResponseTopic "\157\196\226\SYNr",PropServerReference -// "#:\150",PropMaximumPacketSize 24216,PropSessionExpiryInterval 26003,PropReceiveMaximum 6740,PropTopicAliasMaximum -// 16967]} -TEST(Connect5QCTest, Encode14) { - uint8_t pkt[] = { - 0x10, 0xb5, 0x2, 0x0, 0x4, 0x4d,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b4, 0xfd, 0xd7, 0x46, 0xd3, 0xdf, 0x2c, 0x1b, 0x2a, 0x22, 0x27, 0x0, 0x0, 0x5f, 0xc, - 0x15, 0x0, 0x18, 0xd, 0x74, 0x3, 0x38, 0x82, 0x87, 0x59, 0xd1, 0x4c, 0xec, 0x4a, 0x21, 0xfd, 0x34, 0xd5, 0xfa, - 0xf3, 0xb8, 0x86, 0xbe, 0x54, 0x7, 0x43, 0xec, 0x24, 0x7e, 0x15, 0x0, 0x4, 0xd4, 0x68, 0xec, 0x68, 0x1, 0x8b, - 0x28, 0x63, 0x22, 0x7c, 0xc0, 0x22, 0x54, 0x3, 0x3, 0x0, 0x12, 0x1c, 0xfc, 0xce, 0xad, 0x6a, 0x7, 0x24, 0xc8, - 0x85, 0x48, 0xd, 0x4d, 0xa, 0xf1, 0xd7, 0xf, 0x3f, 0x5d, 0x0, 0x12, 0x2a, 0xd3, 0x2c, 0xef, 0x28, 0x8c, 0xd9, - 0x3c, 0x51, 0xcd, 0xdb, 0x80, 0x68, 0xc9, 0xe4, 0xe6, 0xa1, 0xe9, 0x0, 0x9, 0xe9, 0x7, 0x5e, 0x5f, 0xa6, 0x9d, - 0x76, 0x25, 0x2b, 0x0, 0x3, 0xd9, 0x86, 0xb6}; - - uint8_t buf[322] = {0}; - - uint8_t bytesprops0[] = {0x9d, 0xc4, 0xe2, 0x16, 0x72}; - uint8_t bytesprops1[] = {0x23, 0x3a, 0x96}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24216}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26003}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6740}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16967}}, - }; - - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x31, 0x19, 0xdb, 0x14, 0xfc, 0x0, 0x90, 0x24, 0xe7, 0x28, 0xbf, 0x48, 0x8, - 0x2e, 0xa2, 0x99, 0xed, 0x13, 0xfb, 0x23, 0x4e, 0xe3, 0x5d, 0xff, 0x7, 0x28}; - uint8_t byteswillprops1[] = {0x8d, 0x0, 0x26}; - uint8_t byteswillprops2[] = {0xfd, 0x22, 0x4e}; - uint8_t byteswillprops3[] = {0x85, 0x60, 0xd6, 0x83, 0xc0, 0x43, 0x1b, 0x6d, 0xfd, 0x11, 0xeb, 0x37, 0x4b, - 0xf5, 0x53, 0x99, 0x32, 0xb2, 0xb9, 0x28, 0x2d, 0xdd, 0x91, 0x9a, 0x8, 0x83}; - uint8_t byteswillprops4[] = {0x9, 0xbb, 0xb, 0x9a, 0x55, 0x43, 0x3b, 0xea, 0x44}; - uint8_t byteswillprops5[] = {0x8b, 0x25, 0x2a, 0x35, 0x5f, 0x44, 0x3e, 0x79, 0x18, 0xd3, - 0x9a, 0xd0, 0x94, 0x68, 0x57, 0x4f, 0x92, 0x50, 0x12, 0xd0, - 0x72, 0xd1, 0xb4, 0xfd, 0xd7, 0x46, 0xd3, 0xdf, 0x2c, 0x1b}; - uint8_t byteswillprops6[] = {0xd, 0x74, 0x3, 0x38, 0x82, 0x87, 0x59, 0xd1, 0x4c, 0xec, 0x4a, 0x21, - 0xfd, 0x34, 0xd5, 0xfa, 0xf3, 0xb8, 0x86, 0xbe, 0x54, 0x7, 0x43, 0xec}; - uint8_t byteswillprops7[] = {0xd4, 0x68, 0xec, 0x68}; - uint8_t byteswillprops8[] = {0x1c, 0xfc, 0xce, 0xad, 0x6a, 0x7, 0x24, 0xc8, 0x85, - 0x48, 0xd, 0x4d, 0xa, 0xf1, 0xd7, 0xf, 0x3f, 0x5d}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13764}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9290}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24332}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31936}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21507}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops8}}}, - }; - - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2a, 0xd3, 0x2c, 0xef, 0x28, 0x8c, 0xd9, 0x3c, 0x51, - 0xcd, 0xdb, 0x80, 0x68, 0xc9, 0xe4, 0xe6, 0xa1, 0xe9}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe9, 0x7, 0x5e, 0x5f, 0xa6, 0x9d, 0x76, 0x25, 0x2b}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3108; - uint8_t client_id_bytes[] = {0xd3, 0xfa, 0xf5, 0x5f, 0xb9, 0xee, 0x36, 0x93, 0x85, 0x90, 0x63, 0xa8, - 0x1f, 0xf6, 0x1a, 0xaf, 0xaa, 0x7c, 0x48, 0x5a, 0xb8, 0xa, 0x45}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xd9, 0x86, 0xb6}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "]*\250E|\140H\246\144\236\ACK\196\152\216@\SO\EOTK\248 -// \199\&6\n\STX=\149s\235\206R", _password = Just "o\197\204\215\153\171tJ\230U\196K\209xYvu\252\206a\129\\", _lastWill -// = Nothing, _cleanSession = False, _keepAlive = 2582, _connID = -// "Zj\DC2\237\243_-\201=\176\154\233\163\196\234\210\176!", _properties = [PropReceiveMaximum 18664,PropServerKeepAlive -// 6658,PropServerKeepAlive 18381,PropMessageExpiryInterval 15208,PropWillDelayInterval 29547,PropUserProperty -// "\150Z\132\248Y\f\170\138.Dl" "&\203u",PropPayloadFormatIndicator 224,PropTopicAlias 26630,PropUserProperty -// "\232M\139\142\SOH5\130\220v\153\146\163\149\238\185\140\242H\226\ETX\RS\DEL" -// "\158\189\210`Pr\255i\198Z9\175\156\220E\STX\131\167(W\170\f\161\192\239\DEL\179",PropServerReference -// "\144\USc\179\&9\222\FS\vJ/\168\236\180u\240\167.=,\SOHNJ@)\ETX",PropRequestProblemInformation 212]} -TEST(Connect5QCTest, Encode15) { - uint8_t pkt[] = {0x10, 0xd6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0xa, 0x16, 0x7f, 0x21, 0x48, 0xe8, - 0x13, 0x1a, 0x2, 0x13, 0x47, 0xcd, 0x2, 0x0, 0x0, 0x3b, 0x68, 0x18, 0x0, 0x0, 0x73, 0x6b, 0x26, - 0x0, 0xb, 0x96, 0x5a, 0x84, 0xf8, 0x59, 0xc, 0xaa, 0x8a, 0x2e, 0x44, 0x6c, 0x0, 0x3, 0x26, 0xcb, - 0x75, 0x1, 0xe0, 0x23, 0x68, 0x6, 0x26, 0x0, 0x16, 0xe8, 0x4d, 0x8b, 0x8e, 0x1, 0x35, 0x82, 0xdc, - 0x76, 0x99, 0x92, 0xa3, 0x95, 0xee, 0xb9, 0x8c, 0xf2, 0x48, 0xe2, 0x3, 0x1e, 0x7f, 0x0, 0x1b, 0x9e, - 0xbd, 0xd2, 0x60, 0x50, 0x72, 0xff, 0x69, 0xc6, 0x5a, 0x39, 0xaf, 0x9c, 0xdc, 0x45, 0x2, 0x83, 0xa7, - 0x28, 0x57, 0xaa, 0xc, 0xa1, 0xc0, 0xef, 0x7f, 0xb3, 0x1c, 0x0, 0x19, 0x90, 0x1f, 0x63, 0xb3, 0x39, - 0xde, 0x1c, 0xb, 0x4a, 0x2f, 0xa8, 0xec, 0xb4, 0x75, 0xf0, 0xa7, 0x2e, 0x3d, 0x2c, 0x1, 0x4e, 0x4a, - 0x40, 0x29, 0x3, 0x17, 0xd4, 0x0, 0x12, 0x5a, 0x6a, 0x12, 0xed, 0xf3, 0x5f, 0x2d, 0xc9, 0x3d, 0xb0, - 0x9a, 0xe9, 0xa3, 0xc4, 0xea, 0xd2, 0xb0, 0x21, 0x0, 0x1e, 0x5d, 0x2a, 0xfa, 0x45, 0x7c, 0x8c, 0x48, - 0xf6, 0x90, 0xec, 0x6, 0xc4, 0x98, 0xd8, 0x40, 0xe, 0x4, 0x4b, 0xf8, 0x20, 0xc7, 0x36, 0xa, 0x2, - 0x3d, 0x95, 0x73, 0xeb, 0xce, 0x52, 0x0, 0x16, 0x6f, 0xc5, 0xcc, 0xd7, 0x99, 0xab, 0x74, 0x4a, 0xe6, - 0x55, 0xc4, 0x4b, 0xd1, 0x78, 0x59, 0x76, 0x75, 0xfc, 0xce, 0x61, 0x81, 0x5c}; - - uint8_t buf[227] = {0}; - - uint8_t bytesprops1[] = {0x26, 0xcb, 0x75}; - uint8_t bytesprops0[] = {0x96, 0x5a, 0x84, 0xf8, 0x59, 0xc, 0xaa, 0x8a, 0x2e, 0x44, 0x6c}; - uint8_t bytesprops3[] = {0x9e, 0xbd, 0xd2, 0x60, 0x50, 0x72, 0xff, 0x69, 0xc6, 0x5a, 0x39, 0xaf, 0x9c, 0xdc, - 0x45, 0x2, 0x83, 0xa7, 0x28, 0x57, 0xaa, 0xc, 0xa1, 0xc0, 0xef, 0x7f, 0xb3}; - uint8_t bytesprops2[] = {0xe8, 0x4d, 0x8b, 0x8e, 0x1, 0x35, 0x82, 0xdc, 0x76, 0x99, 0x92, - 0xa3, 0x95, 0xee, 0xb9, 0x8c, 0xf2, 0x48, 0xe2, 0x3, 0x1e, 0x7f}; - uint8_t bytesprops4[] = {0x90, 0x1f, 0x63, 0xb3, 0x39, 0xde, 0x1c, 0xb, 0x4a, 0x2f, 0xa8, 0xec, 0xb4, - 0x75, 0xf0, 0xa7, 0x2e, 0x3d, 0x2c, 0x1, 0x4e, 0x4a, 0x40, 0x29, 0x3}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18664}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6658}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18381}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15208}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29547}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {3, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26630}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops2}, .v = {27, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, - }; - - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 2582; - uint8_t client_id_bytes[] = {0x5a, 0x6a, 0x12, 0xed, 0xf3, 0x5f, 0x2d, 0xc9, 0x3d, - 0xb0, 0x9a, 0xe9, 0xa3, 0xc4, 0xea, 0xd2, 0xb0, 0x21}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x5d, 0x2a, 0xfa, 0x45, 0x7c, 0x8c, 0x48, 0xf6, 0x90, 0xec, 0x6, 0xc4, 0x98, 0xd8, 0x40, - 0xe, 0x4, 0x4b, 0xf8, 0x20, 0xc7, 0x36, 0xa, 0x2, 0x3d, 0x95, 0x73, 0xeb, 0xce, 0x52}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6f, 0xc5, 0xcc, 0xd7, 0x99, 0xab, 0x74, 0x4a, 0xe6, 0x55, 0xc4, - 0x4b, 0xd1, 0x78, 0x59, 0x76, 0x75, 0xfc, 0xce, 0x61, 0x81, 0x5c}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\EOTG\170Y\132\235\193\STX\132\236", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 14063, _connID = "\253gc\224:\148 v\185T^gmf\158Z\DC1#\211\SYN#[~", _properties = -// [PropWildcardSubscriptionAvailable 153,PropAuthenticationMethod -// "%*V\246\139\252A\250\140\210\SI\218\213\190\164kEI\252",PropTopicAliasMaximum 20364,PropSharedSubscriptionAvailable -// 45,PropSessionExpiryInterval 19290,PropPayloadFormatIndicator 17,PropResponseInformation -// "d\SOQ\254X\189\247V\190\140\144\173\&5\214\241\160\164-\231",PropContentType "f\v\240",PropAuthenticationData -// "\141u\201X\250\ESC7`\"`\DC45\234\144m\211\135\209\199N\158\199\214\244\165\162\131",PropSharedSubscriptionAvailable -// 226,PropSubscriptionIdentifierAvailable 5,PropMessageExpiryInterval 251,PropMessageExpiryInterval -// 20049,PropResponseInformation -// "A\145\SOH\194\135\168HK\GS\NAK\f\161\US\192\231\NUL\199\"q\211M\204v\ETX\187\n",PropRequestProblemInformation -// 143,PropSharedSubscriptionAvailable 100,PropWildcardSubscriptionAvailable 44,PropRequestResponseInformation -// 218,PropTopicAliasMaximum 23440,PropPayloadFormatIndicator 71,PropAssignedClientIdentifier ":0",PropReceiveMaximum -// 12681]} -TEST(Connect5QCTest, Encode16) { - uint8_t pkt[] = {0x10, 0xc3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x36, 0xef, 0x9e, 0x1, 0x28, 0x99, - 0x15, 0x0, 0x13, 0x25, 0x2a, 0x56, 0xf6, 0x8b, 0xfc, 0x41, 0xfa, 0x8c, 0xd2, 0xf, 0xda, 0xd5, 0xbe, - 0xa4, 0x6b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x49, 0xfc}; - uint8_t bytesprops1[] = {0x64, 0xe, 0x51, 0xfe, 0x58, 0xbd, 0xf7, 0x56, 0xbe, 0x8c, - 0x90, 0xad, 0x35, 0xd6, 0xf1, 0xa0, 0xa4, 0x2d, 0xe7}; - uint8_t bytesprops2[] = {0x66, 0xb, 0xf0}; - uint8_t bytesprops3[] = {0x8d, 0x75, 0xc9, 0x58, 0xfa, 0x1b, 0x37, 0x60, 0x22, 0x60, 0x14, 0x35, 0xea, 0x90, - 0x6d, 0xd3, 0x87, 0xd1, 0xc7, 0x4e, 0x9e, 0xc7, 0xd6, 0xf4, 0xa5, 0xa2, 0x83}; - uint8_t bytesprops4[] = {0x41, 0x91, 0x1, 0xc2, 0x87, 0xa8, 0x48, 0x4b, 0x1d, 0x15, 0xc, 0xa1, 0x1f, - 0xc0, 0xe7, 0x0, 0xc7, 0x22, 0x71, 0xd3, 0x4d, 0xcc, 0x76, 0x3, 0xbb, 0xa}; - uint8_t bytesprops5[] = {0x3a, 0x30}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20364}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19290}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 251}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20049}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23440}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12681}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 14063; - uint8_t client_id_bytes[] = {0xfd, 0x67, 0x63, 0xe0, 0x3a, 0x94, 0x20, 0x76, 0xb9, 0x54, 0x5e, 0x67, - 0x6d, 0x66, 0x9e, 0x5a, 0x11, 0x23, 0xd3, 0x16, 0x23, 0x5b, 0x7e}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x4, 0x47, 0xaa, 0x59, 0x84, 0xeb, 0xc1, 0x2, 0x84, 0xec}; - lwmqtt_string_t password = {10, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\t\222\159S\165\157.L\191\219\SUB\249\GSF@\235\241t\\\r\130\&4\255\216K\204\246Z\255", _willMsg = -// "\153*>%QC\v\RS\n\183 &\205&Em", _willProps = [PropSessionExpiryInterval 29828,PropUserProperty "c0g\225\157+P" -// "\187\138\&1y\183o\128\&5\133\196t\198\177*_W\203\205\&6\223 b&",PropTopicAliasMaximum 5227,PropMaximumPacketSize -// 7849,PropSubscriptionIdentifierAvailable 157,PropTopicAliasMaximum 27560,PropTopicAliasMaximum -// 2575,PropSubscriptionIdentifier 20,PropMessageExpiryInterval 11317,PropMaximumPacketSize 28505,PropCorrelationData -// "\161\194\180Ejo\168#\153\ESC\184\145\178\GS\254\240S\t\229d\DLEI\243\198",PropRequestProblemInformation -// 194,PropAssignedClientIdentifier "\"\"{28\241r+\182\198\146",PropAuthenticationMethod "\142&\147\255\153c\237'"]}), -// _cleanSession = True, _keepAlive = 8661, _connID = "\213\183*l\161!\168\252p\153\208\254\DC1<\235", _properties = -// [PropResponseInformation "",PropRequestProblemInformation 241,PropMessageExpiryInterval 13783,PropReceiveMaximum -// 29834,PropAuthenticationData -// "\200C\132\EMx*f\241\218lN\ACK\215\183\236\248\222\&5\151\n\141\146\172o\154",PropMessageExpiryInterval -// 23078,PropAuthenticationData -// "\DC3!\149(eo\146,\ETBHn3c\136\209\213\SI\226PZ\166&'\213\198\DC2\229+",PropSharedSubscriptionAvailable -// 231,PropRequestResponseInformation 108,PropSubscriptionIdentifier 25,PropWildcardSubscriptionAvailable -// 232,PropWildcardSubscriptionAvailable 89,PropPayloadFormatIndicator 156,PropWillDelayInterval 30760,PropUserProperty -// "2y\231\136\182E\176\DC1h\148Q\132\b\CAN" -// "\176-yt\234\219\176@\SYNx\b\191S\150\f\ENQk[\v|\199\SUB\"y\ENQX\EOTrH",PropWillDelayInterval 25980]} -TEST(Connect5QCTest, Encode17) { - uint8_t pkt[] = { - 0x10, 0xdc, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x21, 0xd5, 0x93, 0x1, 0x1a, 0x0, 0x0, 0x17, - 0xf1, 0x2, 0x0, 0x0, 0x35, 0xd7, 0x21, 0x74, 0x8a, 0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, 0x20, 0x62, 0x26, 0x22, 0x14, 0x6b, 0x27, 0x0, 0x0, 0x1e, 0xa9, - 0x29, 0x9d, 0x22, 0x6b, 0xa8, 0x22, 0xa, 0xf, 0xb, 0x14, 0x2, 0x0, 0x0, 0x2c, 0x35, 0x27, 0x0, 0x0, 0x6f, - 0x59, 0x9, 0x0, 0x18, 0xa1, 0xc2, 0xb4, 0x45, 0x6a, 0x6f, 0xa8, 0x23, 0x99, 0x1b, 0xb8, 0x91, 0xb2, 0x1d, 0xfe, - 0xf0, 0x53, 0x9, 0xe5, 0x64, 0x10, 0x49, 0xf3, 0xc6, 0x17, 0xc2, 0x12, 0x0, 0xb, 0x22, 0x22, 0x7b, 0x32, 0x38, - 0xf1, 0x72, 0x2b, 0xb6, 0xc6, 0x92, 0x15, 0x0, 0x8, 0x8e, 0x26, 0x93, 0xff, 0x99, 0x63, 0xed, 0x27, 0x0, 0x1d, - 0x9, 0xde, 0x9f, 0x53, 0xa5, 0x9d, 0x2e, 0x4c, 0xbf, 0xdb, 0x1a, 0xf9, 0x1d, 0x46, 0x40, 0xeb, 0xf1, 0x74, 0x5c, - 0xd, 0x82, 0x34, 0xff, 0xd8, 0x4b, 0xcc, 0xf6, 0x5a, 0xff, 0x0, 0x10, 0x99, 0x2a, 0x3e, 0x25, 0x51, 0x43, 0xb, - 0x1e, 0xa, 0xb7, 0x20, 0x26, 0xcd, 0x26, 0x45, 0x6d}; - - uint8_t buf[361] = {0}; - - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xc8, 0x43, 0x84, 0x19, 0x78, 0x2a, 0x66, 0xf1, 0xda, 0x6c, 0x4e, 0x6, 0xd7, - 0xb7, 0xec, 0xf8, 0xde, 0x35, 0x97, 0xa, 0x8d, 0x92, 0xac, 0x6f, 0x9a}; - uint8_t bytesprops2[] = {0x13, 0x21, 0x95, 0x28, 0x65, 0x6f, 0x92, 0x2c, 0x17, 0x48, 0x6e, 0x33, 0x63, 0x88, - 0xd1, 0xd5, 0xf, 0xe2, 0x50, 0x5a, 0xa6, 0x26, 0x27, 0xd5, 0xc6, 0x12, 0xe5, 0x2b}; - uint8_t bytesprops4[] = {0xb0, 0x2d, 0x79, 0x74, 0xea, 0xdb, 0xb0, 0x40, 0x16, 0x78, 0x8, 0xbf, 0x53, 0x96, 0xc, - 0x5, 0x6b, 0x5b, 0xb, 0x7c, 0xc7, 0x1a, 0x22, 0x79, 0x5, 0x58, 0x4, 0x72, 0x48}; - uint8_t bytesprops3[] = {0x32, 0x79, 0xe7, 0x88, 0xb6, 0x45, 0xb0, 0x11, 0x68, 0x94, 0x51, 0x84, 0x8, 0x18}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13783}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29834}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23078}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30760}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops3}, .v = {29, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25980}}, - }; - - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xbb, 0x8a, 0x31, 0x79, 0xb7, 0x6f, 0x80, 0x35, 0x85, 0xc4, 0x74, 0xc6, - 0xb1, 0x2a, 0x5f, 0x57, 0xcb, 0xcd, 0x36, 0xdf, 0x20, 0x62, 0x26}; - uint8_t byteswillprops0[] = {0x63, 0x30, 0x67, 0xe1, 0x9d, 0x2b, 0x50}; - uint8_t byteswillprops2[] = {0xa1, 0xc2, 0xb4, 0x45, 0x6a, 0x6f, 0xa8, 0x23, 0x99, 0x1b, 0xb8, 0x91, - 0xb2, 0x1d, 0xfe, 0xf0, 0x53, 0x9, 0xe5, 0x64, 0x10, 0x49, 0xf3, 0xc6}; - uint8_t byteswillprops3[] = {0x22, 0x22, 0x7b, 0x32, 0x38, 0xf1, 0x72, 0x2b, 0xb6, 0xc6, 0x92}; - uint8_t byteswillprops4[] = {0x8e, 0x26, 0x93, 0xff, 0x99, 0x63, 0xed, 0x27}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29828}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {7, (char*)&byteswillprops0}, .v = {23, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5227}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7849}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27560}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2575}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11317}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28505}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops4}}}, - }; - - lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9, 0xde, 0x9f, 0x53, 0xa5, 0x9d, 0x2e, 0x4c, 0xbf, 0xdb, - 0x1a, 0xf9, 0x1d, 0x46, 0x40, 0xeb, 0xf1, 0x74, 0x5c, 0xd, - 0x82, 0x34, 0xff, 0xd8, 0x4b, 0xcc, 0xf6, 0x5a, 0xff}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x99, 0x2a, 0x3e, 0x25, 0x51, 0x43, 0xb, 0x1e, - 0xa, 0xb7, 0x20, 0x26, 0xcd, 0x26, 0x45, 0x6d}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 8661; - uint8_t client_id_bytes[] = {0xd5, 0xb7, 0x2a, 0x6c, 0xa1, 0x21, 0xa8, 0xfc, - 0x70, 0x99, 0xd0, 0xfe, 0x11, 0x3c, 0xeb}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS1, _willTopic = -// "\\\255\246\RS<\212+\220\248\199\236\132\185\US]D\137\186\&5\193\r\n\237\181\231\246\&6\238\211\221", _willMsg = -// "#%`lDh\222\147\201\155e\153\136\131 [9l\GS\225\NUL^", _willProps = [PropSubscriptionIdentifierAvailable 171]}), -// _cleanSession = True, _keepAlive = 1275, _connID = "^\232\215\163\208\190\139\233T\239\SI\139\vz6}", _properties = -// [PropServerKeepAlive 25090,PropRequestResponseInformation 194,PropAuthenticationMethod -// "\153\225h\DC3dj\SOH\211\159\136e\151X",PropAssignedClientIdentifier -// "\145M\ESC\149d53dKi}",PropSubscriptionIdentifier 9,PropSharedSubscriptionAvailable 42,PropPayloadFormatIndicator -// 229,PropResponseInformation "u\219C\233\206\200\SOH\129r\172\NAK\DC3\214W",PropWillDelayInterval -// 9633,PropResponseTopic "\ENQ\199\203o\171\ESC9\156\250\253\252v\243\253\172\222\171",PropResponseInformation -// "\250",PropSharedSubscriptionAvailable 116,PropRequestResponseInformation 100,PropRequestResponseInformation -// 88,PropResponseTopic "\130\185\189\255\216\159\223\245\210h\159\225\DC4`am\193\FS\201\&7 -// iq\148\DLE\220\205\NAK",PropAuthenticationData -// "WX\180\215\FS\DC2/\252\238\172\243\159\245\&1\241",PropAuthenticationMethod "\167\200Tv\140\211\a&/",PropMaximumQoS -// 72,PropServerKeepAlive 17275,PropMessageExpiryInterval 21530,PropRequestResponseInformation 16,PropTopicAliasMaximum -// 28029,PropServerKeepAlive 12384,PropWillDelayInterval 11964,PropMessageExpiryInterval -// 28696,PropSubscriptionIdentifier 15,PropTopicAlias 13015]} -TEST(Connect5QCTest, Encode18) { - uint8_t pkt[] = { - 0x10, 0x94, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2e, 0x4, 0xfb, 0xbb, 0x1, 0x13, 0x62, 0x2, 0x19, - 0xc2, 0x15, 0x0, 0xd, 0x99, 0xe1, 0x68, 0x13, 0x64, 0x6a, 0x1, 0xd3, 0x9f, 0x88, 0x65, 0x97, 0x58, 0x12, 0x0, - 0xb, 0x91, 0x4d, 0x1b, 0x95, 0x64, 0x35, 0x33, 0x64, 0x4b, 0x69, 0x7d, 0xb, 0x9, 0x2a,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5d, 0x44, 0x89, 0xba, 0x35, 0xc1, 0xd, 0xa, - 0xed, 0xb5, 0xe7, 0xf6, 0x36, 0xee, 0xd3, 0xdd, 0x0, 0x16, 0x23, 0x25, 0x60, 0x6c, 0x44, 0x68, 0xde, 0x93, 0xc9, - 0x9b, 0x65, 0x99, 0x88, 0x83, 0x20, 0x5b, 0x39, 0x6c, 0x1d, 0xe1, 0x0, 0x5e}; - - uint8_t buf[289] = {0}; - - uint8_t bytesprops0[] = {0x99, 0xe1, 0x68, 0x13, 0x64, 0x6a, 0x1, 0xd3, 0x9f, 0x88, 0x65, 0x97, 0x58}; - uint8_t bytesprops1[] = {0x91, 0x4d, 0x1b, 0x95, 0x64, 0x35, 0x33, 0x64, 0x4b, 0x69, 0x7d}; - uint8_t bytesprops2[] = {0x75, 0xdb, 0x43, 0xe9, 0xce, 0xc8, 0x1, 0x81, 0x72, 0xac, 0x15, 0x13, 0xd6, 0x57}; - uint8_t bytesprops3[] = {0x5, 0xc7, 0xcb, 0x6f, 0xab, 0x1b, 0x39, 0x9c, 0xfa, - 0xfd, 0xfc, 0x76, 0xf3, 0xfd, 0xac, 0xde, 0xab}; - uint8_t bytesprops4[] = {0xfa}; - uint8_t bytesprops5[] = {0x82, 0xb9, 0xbd, 0xff, 0xd8, 0x9f, 0xdf, 0xf5, 0xd2, 0x68, 0x9f, 0xe1, 0x14, 0x60, - 0x61, 0x6d, 0xc1, 0x1c, 0xc9, 0x37, 0x20, 0x69, 0x71, 0x94, 0x10, 0xdc, 0xcd, 0x15}; - uint8_t bytesprops6[] = {0x57, 0x58, 0xb4, 0xd7, 0x1c, 0x12, 0x2f, 0xfc, 0xee, 0xac, 0xf3, 0x9f, 0xf5, 0x31, 0xf1}; - uint8_t bytesprops7[] = {0xa7, 0xc8, 0x54, 0x76, 0x8c, 0xd3, 0x7, 0x26, 0x2f}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25090}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9633}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17275}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21530}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28029}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12384}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11964}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28696}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13015}}, - }; - - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 171}}, - }; - - lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5c, 0xff, 0xf6, 0x1e, 0x3c, 0xd4, 0x2b, 0xdc, 0xf8, 0xc7, - 0xec, 0x84, 0xb9, 0x1f, 0x5d, 0x44, 0x89, 0xba, 0x35, 0xc1, - 0xd, 0xa, 0xed, 0xb5, 0xe7, 0xf6, 0x36, 0xee, 0xd3, 0xdd}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x23, 0x25, 0x60, 0x6c, 0x44, 0x68, 0xde, 0x93, 0xc9, 0x9b, 0x65, - 0x99, 0x88, 0x83, 0x20, 0x5b, 0x39, 0x6c, 0x1d, 0xe1, 0x0, 0x5e}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1275; - uint8_t client_id_bytes[] = {0x5e, 0xe8, 0xd7, 0xa3, 0xd0, 0xbe, 0x8b, 0xe9, - 0x54, 0xef, 0xf, 0x8b, 0xb, 0x7a, 0x36, 0x7d}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just -// "\212\226\154\ACK\136\237\149\159E\153\b\253\235\250\216\160\201\EM3P\152^\232", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS0, _willTopic = "\128\194\131j\171v\201pWuH\170{=\145O\211\DC3'", _willMsg = -// "\190\132\174 \"\169\179\253\204\&5T\243\160\140^\179\204\131\218H\"6\191lW\184\171d\161K", _willProps = -// [PropResponseInformation -// "\213\250\210\174\160\213\174\236\&4XZ\192\GS\212\\\202\186zvdg\195~\202\240\ESC",PropSubscriptionIdentifierAvailable -// 165,PropTopicAliasMaximum 5284,PropAuthenticationData "|$\183\205\224\&9",PropResponseInformation -// "2T*T\212\251\231\188\240\131\203|\180\168",PropMaximumPacketSize 16,PropTopicAlias 3988,PropMaximumQoS -// 190,PropMessageExpiryInterval 32549,PropPayloadFormatIndicator 165]}), _cleanSession = True, _keepAlive = 30712, -// _connID = "6", _properties = [PropAuthenticationData "\159\212\&4\r\184\DLE",PropResponseTopic -// "\SO\183\148",PropTopicAliasMaximum 25003,PropRequestResponseInformation 220,PropAssignedClientIdentifier -// "\US\185\191\147S\242)\DC3\169@YO\146^\219?\EM",PropUserProperty "\141r\141-\164)n\205U\237d\158\162w^7" -// "\200\167m+\194v\244\142\176\135F \206\154\&2m\EOTsZ&TD+z\185\161",PropAuthenticationData -// "9Vn\235|\n\193\149\206\241r-u",PropAssignedClientIdentifier -// "\RS\145\188\r\241\EOTA\237\v(",PropMessageExpiryInterval 27528,PropWildcardSubscriptionAvailable -// 106,PropMessageExpiryInterval 26165,PropMessageExpiryInterval 16789,PropSubscriptionIdentifierAvailable -// 89,PropRetainAvailable 196,PropSessionExpiryInterval 520,PropAuthenticationMethod -// ",\171\239\149\170",PropResponseInformation "\a3\ACKq\234",PropRequestProblemInformation -// 197,PropSharedSubscriptionAvailable 146,PropResponseInformation -// "t]k\155\178}jP\179",PropWildcardSubscriptionAvailable 93,PropUserProperty "Jh\DC2\RS\202\217\254\163\230\\" -// "Cq\212Y3s\186::B\145\171\146\131\f"]} -TEST(Connect5QCTest, Encode19) { - uint8_t pkt[] = { - 0x10, 0xe0, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x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9, 0xfe, 0xa3, 0xe6, 0x5c, 0x0, 0xf, 0x43, 0x71, 0xd4, - 0x59, 0x33, 0x73, 0xba, 0x3a, 0x3a, 0x42, 0x91, 0xab, 0x92, 0x83, 0xc, 0x0, 0x1, 0x36, 0x4d, 0x1a, 0x0, 0x1a, - 0xd5, 0xfa, 0xd2, 0xae, 0xa0, 0xd5, 0xae, 0xec, 0x34, 0x58, 0x5a, 0xc0, 0x1d, 0xd4, 0x5c, 0xca, 0xba, 0x7a, 0x76, - 0x64, 0x67, 0xc3, 0x7e, 0xca, 0xf0, 0x1b, 0x29, 0xa5, 0x22, 0x14, 0xa4, 0x16, 0x0, 0x6, 0x7c, 0x24, 0xb7, 0xcd, - 0xe0, 0x39, 0x1a, 0x0, 0xe, 0x32, 0x54, 0x2a, 0x54, 0xd4, 0xfb, 0xe7, 0xbc, 0xf0, 0x83, 0xcb, 0x7c, 0xb4, 0xa8, - 0x27, 0x0, 0x0, 0x0, 0x10, 0x23, 0xf, 0x94, 0x24, 0xbe, 0x2, 0x0, 0x0, 0x7f, 0x25, 0x1, 0xa5, 0x0, 0x13, - 0x80, 0xc2, 0x83, 0x6a, 0xab, 0x76, 0xc9, 0x70, 0x57, 0x75, 0x48, 0xaa, 0x7b, 0x3d, 0x91, 0x4f, 0xd3, 0x13, 0x27, - 0x0, 0x1e, 0xbe, 0x84, 0xae, 0x20, 0x22, 0xa9, 0xb3, 0xfd, 0xcc, 0x35, 0x54, 0xf3, 0xa0, 0x8c, 0x5e, 0xb3, 0xcc, - 0x83, 0xda, 0x48, 0x22, 0x36, 0xbf, 0x6c, 0x57, 0xb8, 0xab, 0x64, 0xa1, 0x4b}; - - uint8_t buf[365] = {0}; - - uint8_t bytesprops0[] = {0x9f, 0xd4, 0x34, 0xd, 0xb8, 0x10}; - uint8_t bytesprops1[] = {0xe, 0xb7, 0x94}; - uint8_t bytesprops2[] = {0x1f, 0xb9, 0xbf, 0x93, 0x53, 0xf2, 0x29, 0x13, 0xa9, - 0x40, 0x59, 0x4f, 0x92, 0x5e, 0xdb, 0x3f, 0x19}; - uint8_t bytesprops4[] = {0xc8, 0xa7, 0x6d, 0x2b, 0xc2, 0x76, 0xf4, 0x8e, 0xb0, 0x87, 0x46, 0x20, 0xce, - 0x9a, 0x32, 0x6d, 0x4, 0x73, 0x5a, 0x26, 0x54, 0x44, 0x2b, 0x7a, 0xb9, 0xa1}; - uint8_t bytesprops3[] = {0x8d, 0x72, 0x8d, 0x2d, 0xa4, 0x29, 0x6e, 0xcd, - 0x55, 0xed, 0x64, 0x9e, 0xa2, 0x77, 0x5e, 0x37}; - uint8_t bytesprops5[] = {0x39, 0x56, 0x6e, 0xeb, 0x7c, 0xa, 0xc1, 0x95, 0xce, 0xf1, 0x72, 0x2d, 0x75}; - uint8_t bytesprops6[] = {0x1e, 0x91, 0xbc, 0xd, 0xf1, 0x4, 0x41, 0xed, 0xb, 0x28}; - uint8_t bytesprops7[] = {0x2c, 0xab, 0xef, 0x95, 0xaa}; - uint8_t bytesprops8[] = {0x7, 0x33, 0x6, 0x71, 0xea}; - uint8_t bytesprops9[] = {0x74, 0x5d, 0x6b, 0x9b, 0xb2, 0x7d, 0x6a, 0x50, 0xb3}; - uint8_t bytesprops11[] = {0x43, 0x71, 0xd4, 0x59, 0x33, 0x73, 0xba, 0x3a, 0x3a, 0x42, 0x91, 0xab, 0x92, 0x83, 0xc}; - uint8_t bytesprops10[] = {0x4a, 0x68, 0x12, 0x1e, 0xca, 0xd9, 0xfe, 0xa3, 0xe6, 0x5c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25003}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {26, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27528}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26165}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16789}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 520}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {10, (char*)&bytesprops10}, .v = {15, (char*)&bytesprops11}}}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd5, 0xfa, 0xd2, 0xae, 0xa0, 0xd5, 0xae, 0xec, 0x34, 0x58, 0x5a, 0xc0, 0x1d, - 0xd4, 0x5c, 0xca, 0xba, 0x7a, 0x76, 0x64, 0x67, 0xc3, 0x7e, 0xca, 0xf0, 0x1b}; - uint8_t byteswillprops1[] = {0x7c, 0x24, 0xb7, 0xcd, 0xe0, 0x39}; - uint8_t byteswillprops2[] = {0x32, 0x54, 0x2a, 0x54, 0xd4, 0xfb, 0xe7, 0xbc, 0xf0, 0x83, 0xcb, 0x7c, 0xb4, 0xa8}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5284}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3988}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32549}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 165}}, - }; - - lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x80, 0xc2, 0x83, 0x6a, 0xab, 0x76, 0xc9, 0x70, 0x57, 0x75, - 0x48, 0xaa, 0x7b, 0x3d, 0x91, 0x4f, 0xd3, 0x13, 0x27}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbe, 0x84, 0xae, 0x20, 0x22, 0xa9, 0xb3, 0xfd, 0xcc, 0x35, - 0x54, 0xf3, 0xa0, 0x8c, 0x5e, 0xb3, 0xcc, 0x83, 0xda, 0x48, - 0x22, 0x36, 0xbf, 0x6c, 0x57, 0xb8, 0xab, 0x64, 0xa1, 0x4b}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 30712; - uint8_t client_id_bytes[] = {0x36}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xd4, 0xe2, 0x9a, 0x6, 0x88, 0xed, 0x95, 0x9f, 0x45, 0x99, 0x8, 0xfd, - 0xeb, 0xfa, 0xd8, 0xa0, 0xc9, 0x19, 0x33, 0x50, 0x98, 0x5e, 0xe8}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "J\RSd\"\EOT.m'\DLE%\174\130S\229\172\198\176\&1\140&\228\RS\149\248\232\234", -// _password = Just "\216\183u\FS\184\187\239\148\140X\251\143\153s\176\218\&3s\168", _lastWill = Nothing, _cleanSession -// = True, _keepAlive = 24465, _connID = "\145\244\189\239z\131f", _properties = [PropMessageExpiryInterval -// 25911,PropMessageExpiryInterval 26152,PropRetainAvailable 109,PropWillDelayInterval 1298,PropMaximumPacketSize -// 1990,PropAssignedClientIdentifier "\227\191\148\NUL\ETB\SYNnU",PropWildcardSubscriptionAvailable 81,PropUserProperty -// "\183Z\214\198\215v\254ar\128\v\178\DC2\203mj" "",PropSessionExpiryInterval 6212,PropReceiveMaximum -// 1155,PropTopicAlias 10564,PropResponseTopic -// "\171#\144\222\DC2\195y\220#\183V?y\144\145\187#\219\159",PropAssignedClientIdentifier -// "\230l\250\137/\224\215\n\248n\252\t\194\&9",PropSharedSubscriptionAvailable 20,PropCorrelationData -// "",PropResponseTopic "Lq\184\226\204\158Y\207g\250\136\NAK\128",PropSubscriptionIdentifierAvailable -// 197,PropRetainAvailable 146]} -TEST(Connect5QCTest, Encode20) { - uint8_t pkt[] = { - 0x10, 0xc9, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x5f, 0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 0x73, 0xa8}; - - uint8_t buf[214] = {0}; - - uint8_t bytesprops0[] = {0xe3, 0xbf, 0x94, 0x0, 0x17, 0x16, 0x6e, 0x55}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops1[] = {0xb7, 0x5a, 0xd6, 0xc6, 0xd7, 0x76, 0xfe, 0x61, - 0x72, 0x80, 0xb, 0xb2, 0x12, 0xcb, 0x6d, 0x6a}; - uint8_t bytesprops3[] = {0xab, 0x23, 0x90, 0xde, 0x12, 0xc3, 0x79, 0xdc, 0x23, 0xb7, - 0x56, 0x3f, 0x79, 0x90, 0x91, 0xbb, 0x23, 0xdb, 0x9f}; - uint8_t bytesprops4[] = {0xe6, 0x6c, 0xfa, 0x89, 0x2f, 0xe0, 0xd7, 0xa, 0xf8, 0x6e, 0xfc, 0x9, 0xc2, 0x39}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0x4c, 0x71, 0xb8, 0xe2, 0xcc, 0x9e, 0x59, 0xcf, 0x67, 0xfa, 0x88, 0x15, 0x80}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25911}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26152}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1298}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1990}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {0, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6212}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1155}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10564}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 24465; - uint8_t client_id_bytes[] = {0x91, 0xf4, 0xbd, 0xef, 0x7a, 0x83, 0x66}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x4a, 0x1e, 0x64, 0x22, 0x4, 0x2e, 0x6d, 0x27, 0x10, 0x25, 0xae, 0x82, 0x53, - 0xe5, 0xac, 0xc6, 0xb0, 0x31, 0x8c, 0x26, 0xe4, 0x1e, 0x95, 0xf8, 0xe8, 0xea}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd8, 0xb7, 0x75, 0x1c, 0xb8, 0xbb, 0xef, 0x94, 0x8c, 0x58, - 0xfb, 0x8f, 0x99, 0x73, 0xb0, 0xda, 0x33, 0x73, 0xa8}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\168\152\190:\152\"\217OGs\207_\233\129\248**\131N\190\167q;\253\ETB", _password = -// Just "hq\130\190\144\NUL\227\253\208\215\224\167\FS\203\EOT(\169\158\166\134)g\184\233\145\138*u", _lastWill = -// Nothing, _cleanSession = True, _keepAlive = 147, _connID = "\198@\194\222\146s", _properties = -// [PropPayloadFormatIndicator 143,PropCorrelationData -// "\157Ea4\197\&8\202\EOTAd\US\151\142\&9sC\163O\232\150\239\&0-\176\201\143?\217(",PropMaximumQoS -// 147,PropWildcardSubscriptionAvailable 91,PropAuthenticationData -// "\148\ENQ\ETX\197UL\188Q\232\221S\245\172",PropWillDelayInterval 29870,PropSubscriptionIdentifier -// 11,PropPayloadFormatIndicator 220,PropResponseInformation -// "\DC4\DEL\STX\158\SUB\DLE\ACK\DLE\154\204\223\161\DC4\249\212:\245D\174:\147sA\247\147H\240",PropReasonString -// "\DC1\146\254\142\222\171xo\159%\SO/",PropAssignedClientIdentifier "l",PropPayloadFormatIndicator -// 86,PropRequestResponseInformation 19,PropReasonString -// "\174\167r\166\217>\NUL}Z\154eu\252\234\136#Q\199\221\253\185\227\245\253",PropRequestResponseInformation -// 241,PropContentType "\191\251O\179\DC2\163\&9$\162\190&\144;~)\191Q\251",PropSubscriptionIdentifier -// 10,PropUserProperty "\144\193k\172\172\"\STX\162" "U\215\EOT\204\214\255\DC2dk\198\250\160",PropContentType -// "\190\156:6\145\195\186\167\144X\221Zq\224\228n\131P\240\171\172:\GSc",PropContentType -// "J\FS\180\187\130\&9\249\188&\215\a\244\SUBw\ao\215\203\171\199uCb",PropSharedSubscriptionAvailable -// 255,PropAssignedClientIdentifier "\138\133\203?"]} -TEST(Connect5QCTest, Encode21) { - uint8_t pkt[] = { - 0x10, 0xcc, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x0, 0x93, 0xff, 0x1, 0x1, 0x8f, 0x9, 0x0, - 0x1d, 0x9d, 0x45, 0x61, 0x34, 0xc5, 0x38, 0xca, 0x4, 0x41, 0x64, 0x1f, 0x97, 0x8e, 0x39, 0x73, 0x43, 0xa3, 0x4f, - 0xe8, 0x96, 0xef, 0x30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, - 0x50, 0xf0, 0xab, 0xac, 0x3a, 0x1d, 0x63, 0x3, 0x0, 0x17, 0x4a, 0x1c, 0xb4, 0xbb, 0x82, 0x39, 0xf9, 0xbc, 0x26, - 0xd7, 0x7, 0xf4, 0x1a, 0x77, 0x7, 0x6f, 0xd7, 0xcb, 0xab, 0xc7, 0x75, 0x43, 0x62, 0x2a, 0xff, 0x12, 0x0, 0x4, - 0x8a, 0x85, 0xcb, 0x3f, 0x0, 0x6, 0xc6, 0x40, 0xc2, 0xde, 0x92, 0x73, 0x0, 0x19, 0xa8, 0x98, 0xbe, 0x3a, 0x98, - 0x22, 0xd9, 0x4f, 0x47, 0x73, 0xcf, 0x5f, 0xe9, 0x81, 0xf8, 0x2a, 0x2a, 0x83, 0x4e, 0xbe, 0xa7, 0x71, 0x3b, 0xfd, - 0x17, 0x0, 0x1c, 0x68, 0x71, 0x82, 0xbe, 0x90, 0x0, 0xe3, 0xfd, 0xd0, 0xd7, 0xe0, 0xa7, 0x1c, 0xcb, 0x4, 0x28, - 0xa9, 0x9e, 0xa6, 0x86, 0x29, 0x67, 0xb8, 0xe9, 0x91, 0x8a, 0x2a, 0x75}; - - uint8_t buf[345] = {0}; - - uint8_t bytesprops0[] = {0x9d, 0x45, 0x61, 0x34, 0xc5, 0x38, 0xca, 0x4, 0x41, 0x64, 0x1f, 0x97, 0x8e, 0x39, 0x73, - 0x43, 0xa3, 0x4f, 0xe8, 0x96, 0xef, 0x30, 0x2d, 0xb0, 0xc9, 0x8f, 0x3f, 0xd9, 0x28}; - uint8_t bytesprops1[] = {0x94, 0x5, 0x3, 0xc5, 0x55, 0x4c, 0xbc, 0x51, 0xe8, 0xdd, 0x53, 0xf5, 0xac}; - uint8_t bytesprops2[] = {0x14, 0x7f, 0x2, 0x9e, 0x1a, 0x10, 0x6, 0x10, 0x9a, 0xcc, 0xdf, 0xa1, 0x14, 0xf9, - 0xd4, 0x3a, 0xf5, 0x44, 0xae, 0x3a, 0x93, 0x73, 0x41, 0xf7, 0x93, 0x48, 0xf0}; - uint8_t bytesprops3[] = {0x11, 0x92, 0xfe, 0x8e, 0xde, 0xab, 0x78, 0x6f, 0x9f, 0x25, 0xe, 0x2f}; - uint8_t bytesprops4[] = {0x6c}; - uint8_t bytesprops5[] = {0xae, 0xa7, 0x72, 0xa6, 0xd9, 0x3e, 0x0, 0x7d, 0x5a, 0x9a, 0x65, 0x75, - 0xfc, 0xea, 0x88, 0x23, 0x51, 0xc7, 0xdd, 0xfd, 0xb9, 0xe3, 0xf5, 0xfd}; - uint8_t bytesprops6[] = {0xbf, 0xfb, 0x4f, 0xb3, 0x12, 0xa3, 0x39, 0x24, 0xa2, - 0xbe, 0x26, 0x90, 0x3b, 0x7e, 0x29, 0xbf, 0x51, 0xfb}; - uint8_t bytesprops8[] = {0x55, 0xd7, 0x4, 0xcc, 0xd6, 0xff, 0x12, 0x64, 0x6b, 0xc6, 0xfa, 0xa0}; - uint8_t bytesprops7[] = {0x90, 0xc1, 0x6b, 0xac, 0xac, 0x22, 0x2, 0xa2}; - uint8_t bytesprops9[] = {0xbe, 0x9c, 0x3a, 0x36, 0x91, 0xc3, 0xba, 0xa7, 0x90, 0x58, 0xdd, 0x5a, - 0x71, 0xe0, 0xe4, 0x6e, 0x83, 0x50, 0xf0, 0xab, 0xac, 0x3a, 0x1d, 0x63}; - uint8_t bytesprops10[] = {0x4a, 0x1c, 0xb4, 0xbb, 0x82, 0x39, 0xf9, 0xbc, 0x26, 0xd7, 0x7, 0xf4, - 0x1a, 0x77, 0x7, 0x6f, 0xd7, 0xcb, 0xab, 0xc7, 0x75, 0x43, 0x62}; - uint8_t bytesprops11[] = {0x8a, 0x85, 0xcb, 0x3f}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29870}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops7}, .v = {12, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops11}}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 147; - uint8_t client_id_bytes[] = {0xc6, 0x40, 0xc2, 0xde, 0x92, 0x73}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa8, 0x98, 0xbe, 0x3a, 0x98, 0x22, 0xd9, 0x4f, 0x47, 0x73, 0xcf, 0x5f, 0xe9, - 0x81, 0xf8, 0x2a, 0x2a, 0x83, 0x4e, 0xbe, 0xa7, 0x71, 0x3b, 0xfd, 0x17}; - lwmqtt_string_t username = {25, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x68, 0x71, 0x82, 0xbe, 0x90, 0x0, 0xe3, 0xfd, 0xd0, 0xd7, 0xe0, 0xa7, 0x1c, 0xcb, - 0x4, 0x28, 0xa9, 0x9e, 0xa6, 0x86, 0x29, 0x67, 0xb8, 0xe9, 0x91, 0x8a, 0x2a, 0x75}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "9?\213\ESC\211\DLE", _lastWill = Nothing, _cleanSession = -// False, _keepAlive = 13768, _connID = -// "x\172\tI\199\244\238\243\130\&9.\206\172\ETB\SYN\164\GS\EM\128\142S\217\184\NAK]Q\209;\SUBN", _properties = -// [PropWillDelayInterval 17575,PropUserProperty "\216u|\131\168\247\t\188\DEL\140M\183\253\195\192" -// "5\t",PropMessageExpiryInterval 10754,PropSubscriptionIdentifierAvailable 60,PropWildcardSubscriptionAvailable -// 90,PropTopicAliasMaximum 8351,PropContentType "\128}|D\139\190\235G\129\173R\DC299",PropRetainAvailable -// 39,PropWillDelayInterval 5356,PropMessageExpiryInterval 12914,PropMessageExpiryInterval 5103,PropResponseInformation -// "+\195l\250&\EOTQ\235\200\245g\189\180\246jF:\175",PropResponseInformation -// "\130\205;q\203gs\ESC\\slL\EM)4}\177\163\f~\251D2E;9\SI[\176",PropSubscriptionIdentifierAvailable -// 84,PropRetainAvailable 95,PropSubscriptionIdentifier 15,PropCorrelationData -// "\232\190\241\128\239\254\240\238\189oI\204@qq\133\128\211\133\&1\153D\221",PropReceiveMaximum 19357]} -TEST(Connect5QCTest, Encode22) { - uint8_t pkt[] = { - 0x10, 0xcd, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x35, 0xc8, 0xa1, 0x1, 0x18, 0x0, 0x0, 0x44, - 0xa7, 0x26, 0x0, 0xf, 0xd8, 0x75, 0x7c, 0x83, 0xa8, 0xf7, 0x9, 0xbc, 0x7f, 0x8c, 0x4d, 0xb7, 0xfd, 0xc3, 0xc0, - 0x0, 0x2, 0x35, 0x9, 0x2, 0x0, 0x0, 0x2a, 0x2, 0x29, 0x3c, 0x28, 0x5a, 0x22, 0x20, 0x9f, 0x3, 0x0, 0xe, - 0x80, 0x7d, 0x7c, 0x44, 0x8b, 0xbe, 0xeb, 0x47, 0x81, 0xad, 0x52, 0x12, 0x39, 0x39, 0x25, 0x27, 0x18, 0x0, 0x0, - 0x14, 0xec, 0x2, 0x0, 0x0, 0x32, 0x72, 0x2, 0x0, 0x0, 0x13, 0xef, 0x1a, 0x0, 0x12, 0x2b, 0xc3, 0x6c, 0xfa, - 0x26, 0x4, 0x51, 0xeb, 0xc8, 0xf5, 0x67, 0xbd, 0xb4, 0xf6, 0x6a, 0x46, 0x3a, 0xaf, 0x1a, 0x0, 0x1d, 0x82, 0xcd, - 0x3b, 0x71, 0xcb, 0x67, 0x73, 0x1b, 0x5c, 0x73, 0x6c, 0x4c, 0x19, 0x29, 0x34, 0x7d, 0xb1, 0xa3, 0xc, 0x7e, 0xfb, - 0x44, 0x32, 0x45, 0x3b, 0x39, 0xf, 0x5b, 0xb0, 0x29, 0x54, 0x25, 0x5f, 0xb, 0xf, 0x9, 0x0, 0x17, 0xe8, 0xbe, - 0xf1, 0x80, 0xef, 0xfe, 0xf0, 0xee, 0xbd, 0x6f, 0x49, 0xcc, 0x40, 0x71, 0x71, 0x85, 0x80, 0xd3, 0x85, 0x31, 0x99, - 0x44, 0xdd, 0x21, 0x4b, 0x9d, 0x0, 0x1e, 0x78, 0xac, 0x9, 0x49, 0xc7, 0xf4, 0xee, 0xf3, 0x82, 0x39, 0x2e, 0xce, - 0xac, 0x17, 0x16, 0xa4, 0x1d, 0x19, 0x80, 0x8e, 0x53, 0xd9, 0xb8, 0x15, 0x5d, 0x51, 0xd1, 0x3b, 0x1a, 0x4e}; - - uint8_t buf[218] = {0}; - - uint8_t bytesprops1[] = {0x35, 0x9}; - uint8_t bytesprops0[] = {0xd8, 0x75, 0x7c, 0x83, 0xa8, 0xf7, 0x9, 0xbc, 0x7f, 0x8c, 0x4d, 0xb7, 0xfd, 0xc3, 0xc0}; - uint8_t bytesprops2[] = {0x80, 0x7d, 0x7c, 0x44, 0x8b, 0xbe, 0xeb, 0x47, 0x81, 0xad, 0x52, 0x12, 0x39, 0x39}; - uint8_t bytesprops3[] = {0x2b, 0xc3, 0x6c, 0xfa, 0x26, 0x4, 0x51, 0xeb, 0xc8, - 0xf5, 0x67, 0xbd, 0xb4, 0xf6, 0x6a, 0x46, 0x3a, 0xaf}; - uint8_t bytesprops4[] = {0x82, 0xcd, 0x3b, 0x71, 0xcb, 0x67, 0x73, 0x1b, 0x5c, 0x73, 0x6c, 0x4c, 0x19, 0x29, 0x34, - 0x7d, 0xb1, 0xa3, 0xc, 0x7e, 0xfb, 0x44, 0x32, 0x45, 0x3b, 0x39, 0xf, 0x5b, 0xb0}; - uint8_t bytesprops5[] = {0xe8, 0xbe, 0xf1, 0x80, 0xef, 0xfe, 0xf0, 0xee, 0xbd, 0x6f, 0x49, 0xcc, - 0x40, 0x71, 0x71, 0x85, 0x80, 0xd3, 0x85, 0x31, 0x99, 0x44, 0xdd}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17575}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {2, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10754}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8351}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5356}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12914}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5103}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19357}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 13768; - uint8_t client_id_bytes[] = {0x78, 0xac, 0x9, 0x49, 0xc7, 0xf4, 0xee, 0xf3, 0x82, 0x39, - 0x2e, 0xce, 0xac, 0x17, 0x16, 0xa4, 0x1d, 0x19, 0x80, 0x8e, - 0x53, 0xd9, 0xb8, 0x15, 0x5d, 0x51, 0xd1, 0x3b, 0x1a, 0x4e}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x39, 0x3f, 0xd5, 0x1b, 0xd3, 0x10}; - lwmqtt_string_t password = {6, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just -// ";\152\206s\182\199\197\227\135\ACK\251\"Z\DLE\203\162ab\203\169\203\208\172\230\&6\EOT8eS`", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "", _willMsg = "\157\160\156\193A", _willProps = -// [PropRetainAvailable 238,PropMessageExpiryInterval 5930,PropAuthenticationMethod -// "\177\238/\141%\149i\155\170\a\204",PropRequestResponseInformation 202,PropPayloadFormatIndicator -// 52,PropRequestResponseInformation 250,PropAuthenticationMethod "?\133\191\230\140x*Q\172",PropSubscriptionIdentifier -// 14,PropReceiveMaximum 30728,PropAssignedClientIdentifier "_\EM\196\215",PropAssignedClientIdentifier -// "\192>E\160Z\211'\218\196\ENQ",PropCorrelationData "%\247(6\170",PropSubscriptionIdentifierAvailable 149]}), -// _cleanSession = False, _keepAlive = 23561, _connID = "\228\240", _properties = [PropMessageExpiryInterval -// 22985,PropAssignedClientIdentifier "\142P\178\230\194\176[\ETB\182\&5\163\230c\SYNB",PropWillDelayInterval -// 27154,PropWillDelayInterval 26341]} -TEST(Connect5QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0x84, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2c, 0x5c, 0x9, 0x21, 0x2, 0x0, 0x0, - 0x59, 0xc9, 0x12, 0x0, 0xf, 0x8e, 0x50, 0xb2, 0xe6, 0xc2, 0xb0, 0x5b, 0x17, 0xb6, 0x35, 0xa3, 0xe6, - 0x63, 0x16, 0x42, 0x18, 0x0, 0x0, 0x6a, 0x12, 0x18, 0x0, 0x0, 0x66, 0xe5, 0x0, 0x2, 0xe4, 0xf0, - 0x4a, 0x25, 0xee, 0x2, 0x0, 0x0, 0x17, 0x2a, 0x15, 0x0, 0xb, 0xb1, 0xee, 0x2f, 0x8d, 0x25, 0x95, - 0x69, 0x9b, 0xaa, 0x7, 0xcc, 0x19, 0xca, 0x1, 0x34, 0x19, 0xfa, 0x15, 0x0, 0x9, 0x3f, 0x85, 0xbf, - 0xe6, 0x8c, 0x78, 0x2a, 0x51, 0xac, 0xb, 0xe, 0x21, 0x78, 0x8, 0x12, 0x0, 0x4, 0x5f, 0x19, 0xc4, - 0xd7, 0x12, 0x0, 0xa, 0xc0, 0x3e, 0x45, 0xa0, 0x5a, 0xd3, 0x27, 0xda, 0xc4, 0x5, 0x9, 0x0, 0x5, - 0x25, 0xf7, 0x28, 0x36, 0xaa, 0x29, 0x95, 0x0, 0x0, 0x0, 0x5, 0x9d, 0xa0, 0x9c, 0xc1, 0x41}; - - uint8_t buf[145] = {0}; - - uint8_t bytesprops0[] = {0x8e, 0x50, 0xb2, 0xe6, 0xc2, 0xb0, 0x5b, 0x17, 0xb6, 0x35, 0xa3, 0xe6, 0x63, 0x16, 0x42}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22985}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27154}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26341}}, - }; - - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xb1, 0xee, 0x2f, 0x8d, 0x25, 0x95, 0x69, 0x9b, 0xaa, 0x7, 0xcc}; - uint8_t byteswillprops1[] = {0x3f, 0x85, 0xbf, 0xe6, 0x8c, 0x78, 0x2a, 0x51, 0xac}; - uint8_t byteswillprops2[] = {0x5f, 0x19, 0xc4, 0xd7}; - uint8_t byteswillprops3[] = {0xc0, 0x3e, 0x45, 0xa0, 0x5a, 0xd3, 0x27, 0xda, 0xc4, 0x5}; - uint8_t byteswillprops4[] = {0x25, 0xf7, 0x28, 0x36, 0xaa}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5930}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30728}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 149}}, - }; - - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x9d, 0xa0, 0x9c, 0xc1, 0x41}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 23561; - uint8_t client_id_bytes[] = {0xe4, 0xf0}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x3b, 0x98, 0xce, 0x73, 0xb6, 0xc7, 0xc5, 0xe3, 0x87, 0x6, 0xfb, 0x22, 0x5a, 0x10, 0xcb, - 0xa2, 0x61, 0x62, 0xcb, 0xa9, 0xcb, 0xd0, 0xac, 0xe6, 0x36, 0x4, 0x38, 0x65, 0x53, 0x60}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\254\245:\136]\202n\222\DC3n\218\215\210", _password = Just -// "6\234}\152\181\DC2\ACKM\245:\DC2\ENQ\249\205q+", _lastWill = Nothing, _cleanSession = True, _keepAlive = 2628, -// _connID = "\131/w\176\163", _properties = [PropResponseTopic "f\173jnbG\135\200\&5)\226B<\137&Z",PropSubscriptionIdentifier 9,PropSharedSubscriptionAvailable -// 223,PropPayloadFormatIndicator 104,PropResponseInformation -// "\DLE\242\&5\231K\158\147o-\230\140\230u\246\206\211\250\225.G1H",PropSubscriptionIdentifierAvailable -// 29,PropAuthenticationData "!f\179a\254&k\SOH\222\149\&6\168\196v\158qD\ETB\159\RS\f\232\172s"]} -TEST(Connect5QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0xc1, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0xa, 0x44, 0x8d, 0x1, 0x8, 0x0, - 0xb, 0x66, 0xad, 0x6a, 0x6e, 0x62, 0x47, 0x3c, 0x7a, 0xe9, 0x74, 0x84, 0x19, 0x95, 0x1, 0x1c, 0x16, - 0x0, 0x6, 0x2e, 0xff, 0xc1, 0x1, 0x7d, 0x8d, 0x11, 0x0, 0x0, 0x16, 0xe3, 0x2a, 0xf5, 0x18, 0x0, - 0x0, 0x10, 0x2e, 0x26, 0x0, 0x15, 0xa2, 0x42, 0x72, 0x51, 0xb5, 0xad, 0x58, 0xf8, 0x7c, 0x1a, 0x3b, - 0x3, 0x27, 0xfd, 0x4c, 0xaf, 0x12, 0xc1, 0x97, 0xfd, 0x8e, 0x0, 0x2, 0xba, 0x63, 0x1c, 0x0, 0xb, - 0x3e, 0x87, 0xc8, 0x35, 0x29, 0xe2, 0x42, 0x3c, 0x89, 0x26, 0x5a, 0xb, 0x9, 0x2a, 0xdf, 0x1, 0x68, - 0x1a, 0x0, 0x16, 0x10, 0xf2, 0x35, 0xe7, 0x4b, 0x9e, 0x93, 0x6f, 0x2d, 0xe6, 0x8c, 0xe6, 0x75, 0xf6, - 0xce, 0xd3, 0xfa, 0xe1, 0x2e, 0x47, 0x31, 0x48, 0x29, 0x1d, 0x16, 0x0, 0x18, 0x21, 0x66, 0xb3, 0x61, - 0xfe, 0x26, 0x6b, 0x1, 0xde, 0x95, 0x36, 0xa8, 0xc4, 0x76, 0x9e, 0x71, 0x44, 0x17, 0x9f, 0x1e, 0xc, - 0xe8, 0xac, 0x73, 0x0, 0x5, 0x83, 0x2f, 0x77, 0xb0, 0xa3, 0x0, 0xd, 0xfe, 0xf5, 0x3a, 0x88, 0x5d, - 0xca, 0x6e, 0xde, 0x13, 0x6e, 0xda, 0xd7, 0xd2, 0x0, 0x10, 0x36, 0xea, 0x7d, 0x98, 0xb5, 0x12, 0x6, - 0x4d, 0xf5, 0x3a, 0x12, 0x5, 0xf9, 0xcd, 0x71, 0x2b}; - - uint8_t buf[206] = {0}; - - uint8_t bytesprops0[] = {0x66, 0xad, 0x6a, 0x6e, 0x62, 0x47, 0x3c, 0x7a, 0xe9, 0x74, 0x84}; - uint8_t bytesprops1[] = {0x2e, 0xff, 0xc1, 0x1, 0x7d, 0x8d}; - uint8_t bytesprops3[] = {0xba, 0x63}; - uint8_t bytesprops2[] = {0xa2, 0x42, 0x72, 0x51, 0xb5, 0xad, 0x58, 0xf8, 0x7c, 0x1a, 0x3b, - 0x3, 0x27, 0xfd, 0x4c, 0xaf, 0x12, 0xc1, 0x97, 0xfd, 0x8e}; - uint8_t bytesprops4[] = {0x3e, 0x87, 0xc8, 0x35, 0x29, 0xe2, 0x42, 0x3c, 0x89, 0x26, 0x5a}; - uint8_t bytesprops5[] = {0x10, 0xf2, 0x35, 0xe7, 0x4b, 0x9e, 0x93, 0x6f, 0x2d, 0xe6, 0x8c, - 0xe6, 0x75, 0xf6, 0xce, 0xd3, 0xfa, 0xe1, 0x2e, 0x47, 0x31, 0x48}; - uint8_t bytesprops6[] = {0x21, 0x66, 0xb3, 0x61, 0xfe, 0x26, 0x6b, 0x1, 0xde, 0x95, 0x36, 0xa8, - 0xc4, 0x76, 0x9e, 0x71, 0x44, 0x17, 0x9f, 0x1e, 0xc, 0xe8, 0xac, 0x73}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5859}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4142}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {2, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops6}}}, - }; - - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 2628; - uint8_t client_id_bytes[] = {0x83, 0x2f, 0x77, 0xb0, 0xa3}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xfe, 0xf5, 0x3a, 0x88, 0x5d, 0xca, 0x6e, 0xde, 0x13, 0x6e, 0xda, 0xd7, 0xd2}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x36, 0xea, 0x7d, 0x98, 0xb5, 0x12, 0x6, 0x4d, - 0xf5, 0x3a, 0x12, 0x5, 0xf9, 0xcd, 0x71, 0x2b}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\155\217\NUL\219N>c\218$.jM\158\CAN\213\ENQA;\185\148\147T\180\244", _password = -// Just "\167\228\243\219\223\142\140\SUB-\206\&0\STXF\ACK\146\186V\DC1\167&Nk\SOH8\132", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 23808, _connID = -// "\240\217\175\155|O\226\&49\201\243L\176\239f\233\177`\130\154\221", _properties = [PropReasonString -// "\134\NAKW\244",PropAssignedClientIdentifier -// "\RS\227\154\160~\164\235\211H\170\160C\203\155\191\v",PropRequestProblemInformation 24,PropAuthenticationData -// "fe&\fTpK\CAN\197ZQ}\240(\r\141\251\255\SOHJ\ENQG\173",PropResponseTopic -// "\187\DLEh\154\191\152\180",PropServerKeepAlive 19082,PropSubscriptionIdentifier 4,PropMaximumQoS -// 151,PropUserProperty "t\167\209S\253;3[\179Er\nHE\142\f\v" "\146\129\186p\143Hk",PropMaximumPacketSize 2628]} -TEST(Connect5QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0xc0, 0x1, 0x0, 0x4, 0x4d, 0x51, 0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, 0x84}; - - uint8_t buf[205] = {0}; - - uint8_t bytesprops0[] = {0x86, 0x15, 0x57, 0xf4}; - uint8_t bytesprops1[] = {0x1e, 0xe3, 0x9a, 0xa0, 0x7e, 0xa4, 0xeb, 0xd3, - 0x48, 0xaa, 0xa0, 0x43, 0xcb, 0x9b, 0xbf, 0xb}; - uint8_t bytesprops2[] = {0x66, 0x65, 0x26, 0xc, 0x54, 0x70, 0x4b, 0x18, 0xc5, 0x5a, 0x51, 0x7d, - 0xf0, 0x28, 0xd, 0x8d, 0xfb, 0xff, 0x1, 0x4a, 0x5, 0x47, 0xad}; - uint8_t bytesprops3[] = {0xbb, 0x10, 0x68, 0x9a, 0xbf, 0x98, 0xb4}; - uint8_t bytesprops5[] = {0x92, 0x81, 0xba, 0x70, 0x8f, 0x48, 0x6b}; - uint8_t bytesprops4[] = {0x74, 0xa7, 0xd1, 0x53, 0xfd, 0x3b, 0x33, 0x5b, 0xb3, - 0x45, 0x72, 0xa, 0x48, 0x45, 0x8e, 0xc, 0xb}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19082}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops4}, .v = {7, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2628}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 23808; - uint8_t client_id_bytes[] = {0xf0, 0xd9, 0xaf, 0x9b, 0x7c, 0x4f, 0xe2, 0x34, 0x39, 0xc9, 0xf3, - 0x4c, 0xb0, 0xef, 0x66, 0xe9, 0xb1, 0x60, 0x82, 0x9a, 0xdd}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x9b, 0xd9, 0x0, 0xdb, 0x4e, 0x3e, 0x63, 0xda, 0x24, 0x2e, 0x6a, 0x4d, - 0x9e, 0x18, 0xd5, 0x5, 0x41, 0x3b, 0xb9, 0x94, 0x93, 0x54, 0xb4, 0xf4}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xa7, 0xe4, 0xf3, 0xdb, 0xdf, 0x8e, 0x8c, 0x1a, 0x2d, 0xce, 0x30, 0x2, 0x46, - 0x6, 0x92, 0xba, 0x56, 0x11, 0xa7, 0x26, 0x4e, 0x6b, 0x1, 0x38, 0x84}; - lwmqtt_string_t password = {25, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\147\ENQI\173\FS\139y\171U\167\&2\200\241\231_S\207A\193.'\DC3-\t", _password = -// Just "\224M\229\196\155\f", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "4g\167(\247", _willMsg = "e\SYNy\187{\214", _willProps = [PropResponseInformation -// "\232\174\152\213f\144\240r",PropSubscriptionIdentifier 17,PropContentType -// "\190Y\ESCU\254\253\248>V\128\v=\166\166\192\188\DC2\200\227\192\187\231\157\RS\252Rv\196\155",PropMessageExpiryInterval -// 12137,PropMaximumQoS 175,PropCorrelationData "`\185\255\158\151\205\221\141=-\236P\140\130\135Iu",PropResponseTopic -// "\215\203\r\176\215\133\DC1\189\131$\238e1O/\203\223\207\149H?R\132YZ\195Q",PropAuthenticationData -// "IJ\CAN\166\GS+\137\EM8",PropReasonString -// "\FS\ENQ\221an\136\130\169\EM\245~\228Oy\195\SOH;9\160[\170\&6*c\166\188\206\228",PropReceiveMaximum -// 4886,PropRequestProblemInformation 47,PropAuthenticationMethod -// "\242\&7/\159S\215}y\135$+\136\ETB\221y6\192g|\SUBn\141#MH\187\166\244",PropReasonString -// "\254\154\181\216m\175\193ic\255\210T\139\172\133",PropSessionExpiryInterval 28988,PropCorrelationData -// "aw,\209\179\n0\243Z\153\DC4\181B\190\SO\235\209\178$\246\\",PropServerReference -// "\154<\EOT\199+\252\147\189EV]h\RS\v",PropReceiveMaximum 31344,PropMessageExpiryInterval -// 1883,PropAuthenticationMethod "\208\232\151U\195\178\174X\144\213]\168\EOT\176",PropRequestResponseInformation -// 134,PropSessionExpiryInterval 14426,PropServerReference -// "\GS\152\253\STX\221\FSt\195\134\197\254\204)E+\128,",PropAuthenticationMethod -// "\206%\164\DLE`\196Vn\ETX\136E\DC2s\156\228]]\205B\223\248\a<<\228\ETX",PropReasonString -// "\234l\DC2\155C\162\158\ACK\EM\252\174R",PropContentType "\245\182.t",PropReasonString -// "@\204:N\f\129\243\170\128\157\192\212\130\248z\US\178\ENQ",PropWillDelayInterval 4586,PropTopicAlias 4212]}), -// _cleanSession = False, _keepAlive = 32591, _connID = -// "5\226G\145\159\238\225\NAK\DC2\SUB\RSc\ENQ\ACKr\238+\128\191\218\DC2\230\143X", _properties = -// [PropAssignedClientIdentifier -// "\146\146\202\208n\208X\160\ETXc\bu'\243h\146\152F\SUBw\145\205/\188RT\148S]",PropWildcardSubscriptionAvailable -// 201,PropRequestProblemInformation 25,PropRequestResponseInformation 117,PropServerKeepAlive -// 27326,PropMaximumPacketSize 13373,PropReasonString -// "\ETB\NUL}\250\131\161\bX>\GS?\212\150\&5?,\226",PropSubscriptionIdentifier 9,PropCorrelationData -// "\181x{",PropServerKeepAlive 10603,PropRetainAvailable 59,PropSessionExpiryInterval 16761,PropWillDelayInterval -// 31394,PropUserProperty "\ACKP\220c*\253`I\aP\174\173\SYNG\202\SUB\142\&5~\\\EM\145" -// "\222\208\ACKwE\241r\f\148\162\130\SI\186\249\224!\198`\215;\183\160\ETB*o\200\130\156",PropResponseTopic -// "\STX\204\207\142]\226\163\254\CAN\169\139\222\219\"\167)&k42\207\201\146\&9%\a\174",PropResponseInformation -// "P",PropSharedSubscriptionAvailable 186,PropResponseInformation -// "F\GS\tvkF,\221\247'M<\SO.P%-\129%\133f?\NAK\153\212\213",PropTopicAliasMaximum 17345,PropSharedSubscriptionAvailable -// 242,PropResponseInformation "e\EM\ENQ\147j",PropContentType -// "\171$\GS\151\&1\169&\176\255\201~c\130",PropRequestResponseInformation 23,PropAssignedClientIdentifier -// "\178\189\219\145a\142\159\136\136\246\171\164\v\CANn",PropContentType "\200\142\228\241\129oX\228l"]} -TEST(Connect5QCTest, Encode26) { - uint8_t pkt[] = { - 0x10, 0xe0, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x7f, 0x4f, 0x8e, 0x2, 0x12, 0x0, 0x1d, 0x92, - 0x92, 0xca, 0xd0, 0x6e, 0xd0, 0x58, 0xa0, 0x3, 0x63, 0x8, 0x75, 0x27, 0xf3, 0x68, 0x92, 0x98, 0x46, 0x1a, 0x77, - 0x91, 0xcd, 0x2f, 0xbc, 0x52, 0x54, 0x94, 0x53, 0x5d, 0x28, 0xc9, 0x17, 0x19, 0x19, 0x75, 0x13, 0x6a, 0xbe, 0x27, - 0x0, 0x0, 0x34, 0x3d, 0x1f, 0x0, 0x11, 0x17, 0x0, 0x7d, 0xfa, 0x83, 0xa1, 0x8, 0x58, 0x3e, 0x1d, 0x3f, 0xd4, - 0x96, 0x35, 0x3f, 0x2c, 0xe2, 0xb, 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 0x0, 0xc, 0xea, 0x6c, 0x12, 0x9b, - 0x43, 0xa2, 0x9e, 0x6, 0x19, 0xfc, 0xae, 0x52, 0x3, 0x0, 0x4, 0xf5, 0xb6, 0x2e, 0x74, 0x1f, 0x0, 0x12, 0x40, - 0xcc, 0x3a, 0x4e, 0xc, 0x81, 0xf3, 0xaa, 0x80, 0x9d, 0xc0, 0xd4, 0x82, 0xf8, 0x7a, 0x1f, 0xb2, 0x5, 0x18, 0x0, - 0x0, 0x11, 0xea, 0x23, 0x10, 0x74, 0x0, 0x5, 0x34, 0x67, 0xa7, 0x28, 0xf7, 0x0, 0x6, 0x65, 0x16, 0x79, 0xbb, - 0x7b, 0xd6, 0x0, 0x18, 0x93, 0x5, 0x49, 0xad, 0x1c, 0x8b, 0x79, 0xab, 0x55, 0xa7, 0x32, 0xc8, 0xf1, 0xe7, 0x5f, - 0x53, 0xcf, 0x41, 0xc1, 0x2e, 0x27, 0x13, 0x2d, 0x9, 0x0, 0x6, 0xe0, 0x4d, 0xe5, 0xc4, 0x9b, 0xc}; - - uint8_t buf[749] = {0}; - - uint8_t bytesprops0[] = {0x92, 0x92, 0xca, 0xd0, 0x6e, 0xd0, 0x58, 0xa0, 0x3, 0x63, 0x8, 0x75, 0x27, 0xf3, 0x68, - 0x92, 0x98, 0x46, 0x1a, 0x77, 0x91, 0xcd, 0x2f, 0xbc, 0x52, 0x54, 0x94, 0x53, 0x5d}; - uint8_t bytesprops1[] = {0x17, 0x0, 0x7d, 0xfa, 0x83, 0xa1, 0x8, 0x58, 0x3e, - 0x1d, 0x3f, 0xd4, 0x96, 0x35, 0x3f, 0x2c, 0xe2}; - uint8_t bytesprops2[] = {0xb5, 0x78, 0x7b}; - uint8_t bytesprops4[] = {0xde, 0xd0, 0x6, 0x77, 0x45, 0xf1, 0x72, 0xc, 0x94, 0xa2, 0x82, 0xf, 0xba, 0xf9, - 0xe0, 0x21, 0xc6, 0x60, 0xd7, 0x3b, 0xb7, 0xa0, 0x17, 0x2a, 0x6f, 0xc8, 0x82, 0x9c}; - uint8_t bytesprops3[] = {0x6, 0x50, 0xdc, 0x63, 0x2a, 0xfd, 0x60, 0x49, 0x7, 0x50, 0xae, - 0xad, 0x16, 0x47, 0xca, 0x1a, 0x8e, 0x35, 0x7e, 0x5c, 0x19, 0x91}; - uint8_t bytesprops5[] = {0x2, 0xcc, 0xcf, 0x8e, 0x5d, 0xe2, 0xa3, 0xfe, 0x18, 0xa9, 0x8b, 0xde, 0xdb, 0x22, - 0xa7, 0x29, 0x26, 0x6b, 0x34, 0x32, 0xcf, 0xc9, 0x92, 0x39, 0x25, 0x7, 0xae}; - uint8_t bytesprops6[] = {0x50}; - uint8_t bytesprops7[] = {0x46, 0x1d, 0x9, 0x76, 0x6b, 0x46, 0x2c, 0xdd, 0xf7, 0x27, 0x4d, 0x3c, 0xe, - 0x2e, 0x50, 0x25, 0x2d, 0x81, 0x25, 0x85, 0x66, 0x3f, 0x15, 0x99, 0xd4, 0xd5}; - uint8_t bytesprops8[] = {0x65, 0x19, 0x5, 0x93, 0x6a}; - uint8_t bytesprops9[] = {0xab, 0x24, 0x1d, 0x97, 0x31, 0xa9, 0x26, 0xb0, 0xff, 0xc9, 0x7e, 0x63, 0x82}; - uint8_t bytesprops10[] = {0xb2, 0xbd, 0xdb, 0x91, 0x61, 0x8e, 0x9f, 0x88, 0x88, 0xf6, 0xab, 0xa4, 0xb, 0x18, 0x6e}; - uint8_t bytesprops11[] = {0xc8, 0x8e, 0xe4, 0xf1, 0x81, 0x6f, 0x58, 0xe4, 0x6c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27326}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13373}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10603}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16761}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31394}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17345}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops11}}}, - }; - - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe8, 0xae, 0x98, 0xd5, 0x66, 0x90, 0xf0, 0x72}; - uint8_t byteswillprops1[] = {0xbe, 0x59, 0x1b, 0x55, 0xfe, 0xfd, 0xf8, 0x3e, 0x56, 0x80, 0xb, 0x3d, 0xa6, 0xa6, 0xc0, - 0xbc, 0x12, 0xc8, 0xe3, 0xc0, 0xbb, 0xe7, 0x9d, 0x1e, 0xfc, 0x52, 0x76, 0xc4, 0x9b}; - uint8_t byteswillprops2[] = {0x60, 0xb9, 0xff, 0x9e, 0x97, 0xcd, 0xdd, 0x8d, 0x3d, - 0x2d, 0xec, 0x50, 0x8c, 0x82, 0x87, 0x49, 0x75}; - uint8_t byteswillprops3[] = {0xd7, 0xcb, 0xd, 0xb0, 0xd7, 0x85, 0x11, 0xbd, 0x83, 0x24, 0xee, 0x65, 0x31, 0x4f, - 0x2f, 0xcb, 0xdf, 0xcf, 0x95, 0x48, 0x3f, 0x52, 0x84, 0x59, 0x5a, 0xc3, 0x51}; - uint8_t byteswillprops4[] = {0x49, 0x4a, 0x18, 0xa6, 0x1d, 0x2b, 0x89, 0x19, 0x38}; - uint8_t byteswillprops5[] = {0x1c, 0x5, 0xdd, 0x61, 0x6e, 0x88, 0x82, 0xa9, 0x19, 0xf5, 0x7e, 0xe4, 0x4f, 0x79, - 0xc3, 0x1, 0x3b, 0x39, 0xa0, 0x5b, 0xaa, 0x36, 0x2a, 0x63, 0xa6, 0xbc, 0xce, 0xe4}; - uint8_t byteswillprops6[] = {0xf2, 0x37, 0x2f, 0x9f, 0x53, 0xd7, 0x7d, 0x79, 0x87, 0x24, 0x2b, 0x88, 0x17, 0xdd, - 0x79, 0x36, 0xc0, 0x67, 0x7c, 0x1a, 0x6e, 0x8d, 0x23, 0x4d, 0x48, 0xbb, 0xa6, 0xf4}; - uint8_t byteswillprops7[] = {0xfe, 0x9a, 0xb5, 0xd8, 0x6d, 0xaf, 0xc1, 0x69, - 0x63, 0xff, 0xd2, 0x54, 0x8b, 0xac, 0x85}; - uint8_t byteswillprops8[] = {0x61, 0x77, 0x2c, 0xd1, 0xb3, 0xa, 0x30, 0xf3, 0x5a, 0x99, 0x14, - 0xb5, 0x42, 0xbe, 0xe, 0xeb, 0xd1, 0xb2, 0x24, 0xf6, 0x5c}; - uint8_t byteswillprops9[] = {0x9a, 0x3c, 0x4, 0xc7, 0x2b, 0xfc, 0x93, 0xbd, 0x45, 0x56, 0x5d, 0x68, 0x1e, 0xb}; - uint8_t byteswillprops10[] = {0xd0, 0xe8, 0x97, 0x55, 0xc3, 0xb2, 0xae, 0x58, 0x90, 0xd5, 0x5d, 0xa8, 0x4, 0xb0}; - uint8_t byteswillprops11[] = {0x1d, 0x98, 0xfd, 0x2, 0xdd, 0x1c, 0x74, 0xc3, 0x86, - 0xc5, 0xfe, 0xcc, 0x29, 0x45, 0x2b, 0x80, 0x2c}; - uint8_t byteswillprops12[] = {0xce, 0x25, 0xa4, 0x10, 0x60, 0xc4, 0x56, 0x6e, 0x3, 0x88, 0x45, 0x12, 0x73, - 0x9c, 0xe4, 0x5d, 0x5d, 0xcd, 0x42, 0xdf, 0xf8, 0x7, 0x3c, 0x3c, 0xe4, 0x3}; - uint8_t byteswillprops13[] = {0xea, 0x6c, 0x12, 0x9b, 0x43, 0xa2, 0x9e, 0x6, 0x19, 0xfc, 0xae, 0x52}; - uint8_t byteswillprops14[] = {0xf5, 0xb6, 0x2e, 0x74}; - uint8_t byteswillprops15[] = {0x40, 0xcc, 0x3a, 0x4e, 0xc, 0x81, 0xf3, 0xaa, 0x80, - 0x9d, 0xc0, 0xd4, 0x82, 0xf8, 0x7a, 0x1f, 0xb2, 0x5}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12137}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4886}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28988}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31344}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1883}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14426}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&byteswillprops12}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&byteswillprops13}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&byteswillprops14}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&byteswillprops15}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4586}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4212}}, - }; - - lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x34, 0x67, 0xa7, 0x28, 0xf7}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x65, 0x16, 0x79, 0xbb, 0x7b, 0xd6}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32591; - uint8_t client_id_bytes[] = {0x35, 0xe2, 0x47, 0x91, 0x9f, 0xee, 0xe1, 0x15, 0x12, 0x1a, 0x1e, 0x63, - 0x5, 0x6, 0x72, 0xee, 0x2b, 0x80, 0xbf, 0xda, 0x12, 0xe6, 0x8f, 0x58}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x93, 0x5, 0x49, 0xad, 0x1c, 0x8b, 0x79, 0xab, 0x55, 0xa7, 0x32, 0xc8, - 0xf1, 0xe7, 0x5f, 0x53, 0xcf, 0x41, 0xc1, 0x2e, 0x27, 0x13, 0x2d, 0x9}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe0, 0x4d, 0xe5, 0xc4, 0x9b, 0xc}; - lwmqtt_string_t password = {6, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\135n\ACK\DEL\252\NAKj", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS0, _willTopic = "\227\242\SOH2\209\GS\241P\197$1", _willMsg = -// "\203\232{\205\152\239\158\DEL\251r\EOTy\\e\148\159p\ETX8Kg", _willProps = [PropResponseTopic -// "\212\ETB\EOT\132M\"^\\(\254\171\ACK\188\&5\174\NAK?I\181\221\221B\246\226\233\210?\232",PropMaximumQoS -// 142,PropCorrelationData "<'\194\DC45\216\200p\216)\175G\NUL",PropServerReference -// "f\150\160\131/\ETX\216_\157\202\142\t\136\&8;\178\143\177,3+\148",PropWildcardSubscriptionAvailable -// 231,PropWildcardSubscriptionAvailable 103,PropWildcardSubscriptionAvailable 67,PropRequestResponseInformation -// 151,PropSharedSubscriptionAvailable 197,PropWildcardSubscriptionAvailable 192,PropRetainAvailable -// 167,PropSubscriptionIdentifier 8,PropServerReference "\182\213\155\213\v\r\DC2\181",PropAuthenticationData -// "\199xmb\245",PropWildcardSubscriptionAvailable 177,PropResponseInformation -// "k5\245)\203y+\223*\202\252,\251u\240\176\195Y",PropSharedSubscriptionAvailable 66,PropRetainAvailable -// 186,PropAuthenticationMethod "\152>\128\158\235\150\182N8F\223\200\SYN\154.\161",PropTopicAlias -// 25938,PropMessageExpiryInterval 9743,PropResponseTopic -// "\150\145\&9\168\134\228\&9\SO\210\200O\230r\SYN\209\RS\SO\214"]}), _cleanSession = True, _keepAlive = 27175, _connID -// = "\CAN\SYN\222\163\&6J<\227\240.\181\138\158\223b_\ETB\234\SYN\232\223", _properties = [PropMessageExpiryInterval -// 2882,PropCorrelationData "7\176\229\218\&9\SYN\227#]#\200a\DC1\205}\223\ETBs<\205r$[",PropTopicAliasMaximum -// 19033,PropSharedSubscriptionAvailable 238,PropServerReference "\199y\243\b",PropSharedSubscriptionAvailable -// 200,PropMessageExpiryInterval 25291,PropUserProperty "" -// "\228\197\r\232\193\nW4kl\SOH\t\\\DC4",PropSubscriptionIdentifierAvailable 101,PropUserProperty -// "!\n0`*\161b\147\188u" -// "#\146\139\&4sy\207Q\255En\n'<\248\&6\232\253-\196\ETXKz\137\ETX\164^\230",PropMessageExpiryInterval -// 11776,PropSubscriptionIdentifierAvailable 107,PropPayloadFormatIndicator 174]} -TEST(Connect5QCTest, Encode27) { - uint8_t pkt[] = { - 0x10, 0x84, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x86, 0x6a, 0x27, 0x7b, 0x2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, 0xfc, 0x15, 0x6a}; - - uint8_t buf[401] = {0}; - - uint8_t bytesprops0[] = {0x37, 0xb0, 0xe5, 0xda, 0x39, 0x16, 0xe3, 0x23, 0x5d, 0x23, 0xc8, 0x61, - 0x11, 0xcd, 0x7d, 0xdf, 0x17, 0x73, 0x3c, 0xcd, 0x72, 0x24, 0x5b}; - uint8_t bytesprops1[] = {0xc7, 0x79, 0xf3, 0x8}; - uint8_t bytesprops3[] = {0xe4, 0xc5, 0xd, 0xe8, 0xc1, 0xa, 0x57, 0x34, 0x6b, 0x6c, 0x1, 0x9, 0x5c, 0x14}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops5[] = {0x23, 0x92, 0x8b, 0x34, 0x73, 0x79, 0xcf, 0x51, 0xff, 0x45, 0x6e, 0xa, 0x27, 0x3c, - 0xf8, 0x36, 0xe8, 0xfd, 0x2d, 0xc4, 0x3, 0x4b, 0x7a, 0x89, 0x3, 0xa4, 0x5e, 0xe6}; - uint8_t bytesprops4[] = {0x21, 0xa, 0x30, 0x60, 0x2a, 0xa1, 0x62, 0x93, 0xbc, 0x75}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2882}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19033}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25291}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops2}, .v = {14, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops4}, .v = {28, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11776}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 174}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd4, 0x17, 0x4, 0x84, 0x4d, 0x22, 0x5e, 0x5c, 0x28, 0xfe, 0xab, 0x6, 0xbc, 0x35, - 0xae, 0x15, 0x3f, 0x49, 0xb5, 0xdd, 0xdd, 0x42, 0xf6, 0xe2, 0xe9, 0xd2, 0x3f, 0xe8}; - uint8_t byteswillprops1[] = {0x3c, 0x27, 0xc2, 0x14, 0x35, 0xd8, 0xc8, 0x70, 0xd8, 0x29, 0xaf, 0x47, 0x0}; - uint8_t byteswillprops2[] = {0x66, 0x96, 0xa0, 0x83, 0x2f, 0x3, 0xd8, 0x5f, 0x9d, 0xca, 0x8e, - 0x9, 0x88, 0x38, 0x3b, 0xb2, 0x8f, 0xb1, 0x2c, 0x33, 0x2b, 0x94}; - uint8_t byteswillprops3[] = {0xb6, 0xd5, 0x9b, 0xd5, 0xb, 0xd, 0x12, 0xb5}; - uint8_t byteswillprops4[] = {0xc7, 0x78, 0x6d, 0x62, 0xf5}; - uint8_t byteswillprops5[] = {0x6b, 0x35, 0xf5, 0x29, 0xcb, 0x79, 0x2b, 0xdf, 0x2a, - 0xca, 0xfc, 0x2c, 0xfb, 0x75, 0xf0, 0xb0, 0xc3, 0x59}; - uint8_t byteswillprops6[] = {0x98, 0x3e, 0x80, 0x9e, 0xeb, 0x96, 0xb6, 0x4e, - 0x38, 0x46, 0xdf, 0xc8, 0x16, 0x9a, 0x2e, 0xa1}; - uint8_t byteswillprops7[] = {0x96, 0x91, 0x39, 0xa8, 0x86, 0xe4, 0x39, 0xe, 0xd2, - 0xc8, 0x4f, 0xe6, 0x72, 0x16, 0xd1, 0x1e, 0xe, 0xd6}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25938}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9743}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops7}}}, - }; - - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe3, 0xf2, 0x1, 0x32, 0xd1, 0x1d, 0xf1, 0x50, 0xc5, 0x24, 0x31}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xcb, 0xe8, 0x7b, 0xcd, 0x98, 0xef, 0x9e, 0x7f, 0xfb, 0x72, 0x4, - 0x79, 0x5c, 0x65, 0x94, 0x9f, 0x70, 0x3, 0x38, 0x4b, 0x67}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 27175; - uint8_t client_id_bytes[] = {0x18, 0x16, 0xde, 0xa3, 0x36, 0x4a, 0x3c, 0xe3, 0xf0, 0x2e, 0xb5, - 0x8a, 0x9e, 0xdf, 0x62, 0x5f, 0x17, 0xea, 0x16, 0xe8, 0xdf}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x87, 0x6e, 0x6, 0x7f, 0xfc, 0x15, 0x6a}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\206\232\167N\216a\154\199\224\218QM\240^\233", _password = Just -// "\192/:\231\250i\229m\149\209\226\189\247\RS", _lastWill = Nothing, _cleanSession = True, _keepAlive = 19539, _connID -// = "\243\a_w\224\230\220\172\186\STX\157\251\SUB\221\132\ACK1\230\148", _properties = [PropContentType -// "QH\133\ETX\204\nCa\145\182\179",PropPayloadFormatIndicator 127,PropAuthenticationData -// "u\230\227\235K\130\148\217M\150\172p\251\145\DC2\v\ETB\DC2O\181g?\198\253",PropResponseInformation -// "l\219\199)\200Q\215\128\219\GS\161o)\254\US\RS\212\186aR$S\ENQ_C\SOHvQEv",PropAssignedClientIdentifier -// "\186.\\\159\184\222\213\237\199\179\208e\221rn\224H\191\143\CAN\134\194\183*",PropRequestResponseInformation -// 219,PropPayloadFormatIndicator 221,PropReceiveMaximum 19233,PropResponseTopic "H\196\238",PropRetainAvailable -// 172,PropMaximumQoS 154,PropMessageExpiryInterval 9718]} -TEST(Connect5QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0xbe, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x4c, 0x53, 0x7d, 0x3, 0x0, 0xb, - 0x51, 0x48, 0x85, 0x3, 0xcc, 0xa, 0x43, 0x61, 0x91, 0xb6, 0xb3, 0x1, 0x7f, 0x16, 0x0, 0x18, 0x75, - 0xe6, 0xe3, 0xeb, 0x4b, 0x82, 0x94, 0xd9, 0x4d, 0x96, 0xac, 0x70, 0xfb, 0x91, 0x12, 0xb, 0x17, 0x12, - 0x4f, 0xb5, 0x67, 0x3f, 0xc6, 0xfd, 0x1a, 0x0, 0x1e, 0x6c, 0xdb, 0xc7, 0x29, 0xc8, 0x51, 0xd7, 0x80, - 0xdb, 0x1d, 0xa1, 0x6f, 0x29, 0xfe, 0x1f, 0x1e, 0xd4, 0xba, 0x61, 0x52, 0x24, 0x53, 0x5, 0x5f, 0x43, - 0x1, 0x76, 0x51, 0x45, 0x76, 0x12, 0x0, 0x18, 0xba, 0x2e, 0x5c, 0x9f, 0xb8, 0xde, 0xd5, 0xed, 0xc7, - 0xb3, 0xd0, 0x65, 0xdd, 0x72, 0x6e, 0xe0, 0x48, 0xbf, 0x8f, 0x18, 0x86, 0xc2, 0xb7, 0x2a, 0x19, 0xdb, - 0x1, 0xdd, 0x21, 0x4b, 0x21, 0x8, 0x0, 0x3, 0x48, 0xc4, 0xee, 0x25, 0xac, 0x24, 0x9a, 0x2, 0x0, - 0x0, 0x25, 0xf6, 0x0, 0x13, 0xf3, 0x7, 0x5f, 0x77, 0xe0, 0xe6, 0xdc, 0xac, 0xba, 0x2, 0x9d, 0xfb, - 0x1a, 0xdd, 0x84, 0x6, 0x31, 0xe6, 0x94, 0x0, 0xf, 0xce, 0xe8, 0xa7, 0x4e, 0xd8, 0x61, 0x9a, 0xc7, - 0xe0, 0xda, 0x51, 0x4d, 0xf0, 0x5e, 0xe9, 0x0, 0xe, 0xc0, 0x2f, 0x3a, 0xe7, 0xfa, 0x69, 0xe5, 0x6d, - 0x95, 0xd1, 0xe2, 0xbd, 0xf7, 0x1e}; - - uint8_t buf[203] = {0}; - - uint8_t bytesprops0[] = {0x51, 0x48, 0x85, 0x3, 0xcc, 0xa, 0x43, 0x61, 0x91, 0xb6, 0xb3}; - uint8_t bytesprops1[] = {0x75, 0xe6, 0xe3, 0xeb, 0x4b, 0x82, 0x94, 0xd9, 0x4d, 0x96, 0xac, 0x70, - 0xfb, 0x91, 0x12, 0xb, 0x17, 0x12, 0x4f, 0xb5, 0x67, 0x3f, 0xc6, 0xfd}; - uint8_t bytesprops2[] = {0x6c, 0xdb, 0xc7, 0x29, 0xc8, 0x51, 0xd7, 0x80, 0xdb, 0x1d, 0xa1, 0x6f, 0x29, 0xfe, 0x1f, - 0x1e, 0xd4, 0xba, 0x61, 0x52, 0x24, 0x53, 0x5, 0x5f, 0x43, 0x1, 0x76, 0x51, 0x45, 0x76}; - uint8_t bytesprops3[] = {0xba, 0x2e, 0x5c, 0x9f, 0xb8, 0xde, 0xd5, 0xed, 0xc7, 0xb3, 0xd0, 0x65, - 0xdd, 0x72, 0x6e, 0xe0, 0x48, 0xbf, 0x8f, 0x18, 0x86, 0xc2, 0xb7, 0x2a}; - uint8_t bytesprops4[] = {0x48, 0xc4, 0xee}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19233}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9718}}, - }; - - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 19539; - uint8_t client_id_bytes[] = {0xf3, 0x7, 0x5f, 0x77, 0xe0, 0xe6, 0xdc, 0xac, 0xba, 0x2, - 0x9d, 0xfb, 0x1a, 0xdd, 0x84, 0x6, 0x31, 0xe6, 0x94}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xce, 0xe8, 0xa7, 0x4e, 0xd8, 0x61, 0x9a, 0xc7, 0xe0, 0xda, 0x51, 0x4d, 0xf0, 0x5e, 0xe9}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xc0, 0x2f, 0x3a, 0xe7, 0xfa, 0x69, 0xe5, 0x6d, 0x95, 0xd1, 0xe2, 0xbd, 0xf7, 0x1e}; - lwmqtt_string_t password = {14, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "m\215\134\182\200\&4", _password = Just -// ">\213T\DC4\232\214\180e\168@Q\130\234\201\227#\248\153`\161\244\138\218\201/xr\DEL", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "k\208\247&\US\224\153\252\216", _willMsg = "\v\157\214H\186", -// _willProps = [PropPayloadFormatIndicator 187,PropTopicAliasMaximum 32718,PropServerReference -// "\vh\247\147\223\169\132\211K\249\160E\141W\140\167\GS\166\220\201",PropServerKeepAlive -// 17111,PropAssignedClientIdentifier "f\176G\ENQ#'\177\239G\164\176\247\236\240\202",PropSessionExpiryInterval -// 14845,PropReceiveMaximum 32716,PropWillDelayInterval 5765,PropPayloadFormatIndicator 200,PropResponseInformation -// "pf\STX6",PropSharedSubscriptionAvailable 198,PropTopicAlias 20010,PropWillDelayInterval 26929,PropCorrelationData -// "6k;\183\248\ENQ\148\245\199w=",PropRetainAvailable 174,PropAuthenticationMethod -// "\206\NAK\182\182}\216\249\159\140:\238\202\139\248",PropAuthenticationMethod "\205\135\ETX",PropTopicAliasMaximum -// 14663,PropWildcardSubscriptionAvailable 87,PropCorrelationData -// "\248U\149\192\173\230\SO\143\215KL*j\154\239t\140\249j\150",PropRequestResponseInformation 164,PropReceiveMaximum -// 22648,PropMessageExpiryInterval 22675,PropWillDelayInterval 29136]}), _cleanSession = False, _keepAlive = 24596, -// _connID = "\198\140\ETX", _properties = [PropSessionExpiryInterval 14824,PropMessageExpiryInterval -// 21140,PropTopicAlias 28394,PropCorrelationData -// "\135\237\f\236\165d\248\137\DEL\218c\230\168\192\235u|'\237}|\"\187\DEL\DEL",PropRetainAvailable -// 236,PropMessageExpiryInterval 3189,PropSubscriptionIdentifierAvailable 13,PropWillDelayInterval -// 17060,PropReceiveMaximum 25160,PropCorrelationData "\233",PropRequestResponseInformation 160,PropMaximumQoS -// 131,PropMaximumPacketSize 16528,PropSharedSubscriptionAvailable 89,PropAssignedClientIdentifier -// "\ACK*4\n\241\234^&n\232\213ED\ACK\229\252\232\&6",PropMessageExpiryInterval 11067,PropWildcardSubscriptionAvailable -// 39,PropResponseInformation "0\148\NAK\212h\200\132\219\&9",PropServerReference -// "|\DC2\n\DC2\159\144%\221\248\137\160\230^\SI\a\154\147u",PropServerReference -// "\238\137\251\a\229{\202\153\210\ENQ\194\240\GS<\223\183\208\241\179{\NAKS\236\140\234f",PropAuthenticationData -// "\130\200\243",PropRetainAvailable 200,PropSubscriptionIdentifier 13,PropMessageExpiryInterval -// 6275,PropRequestProblemInformation 236,PropMessageExpiryInterval 10831,PropCorrelationData -// "y\214",PropWillDelayInterval 13007,PropWildcardSubscriptionAvailable 14]} -TEST(Connect5QCTest, Encode29) { - uint8_t pkt[] = { - 0x10, 0xb3, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x60, 0x14, 0xc5, 0x1, 0x11, 0x0, 0x0, 0x39, - 0xe8, 0x2, 0x0, 0x0, 0x52, 0x94, 0x23, 0x6e, 0xea, 0x9, 0x0, 0x19, 0x87, 0xed, 0xc, 0xec, 0xa5, 0x64, 0xf8, - 0x89, 0x7f, 0xda, 0x63, 0xe6, 0xa8, 0xc0, 0xeb, 0x75, 0x7c, 0x27, 0xed, 0x7d, 0x7c, 0x22, 0xbb, 0x7f, 0x7f, 0x25, - 0xec, 0x2, 0x0, 0x0, 0xc, 0x75, 0x29, 0xd, 0x18, 0x0, 0x0, 0x42, 0xa4, 0x21, 0x62, 0x48, 0x9, 0x0, 0x1, - 0xe9, 0x19, 0xa0, 0x24, 0x83, 0x27, 0x0, 0x0, 0x40, 0x90, 0x2a, 0x59, 0x12, 0x0, 0x12, 0x6, 0x2a, 0x34, 0xa, - 0xf1, 0xea, 0x5e, 0x26, 0x6e, 0xe8, 0xd5, 0x45, 0x44, 0x6, 0xe5, 0xfc, 0xe8, 0x36, 0x2, 0x0, 0x0, 0x2b, 0x3b, - 0x28, 0x27, 0x1a, 0x0, 0x9, 0x30, 0x94, 0x15, 0xd4, 0x68, 0xc8, 0x84, 0xdb, 0x39, 0x1c, 0x0, 0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0xe, 0xce, 0x15, 0xb6, 0xb6, - 0x7d, 0xd8, 0xf9, 0x9f, 0x8c, 0x3a, 0xee, 0xca, 0x8b, 0xf8, 0x15, 0x0, 0x3, 0xcd, 0x87, 0x3, 0x22, 0x39, 0x47, - 0x28, 0x57, 0x9, 0x0, 0x14, 0xf8, 0x55, 0x95, 0xc0, 0xad, 0xe6, 0xe, 0x8f, 0xd7, 0x4b, 0x4c, 0x2a, 0x6a, 0x9a, - 0xef, 0x74, 0x8c, 0xf9, 0x6a, 0x96, 0x19, 0xa4, 0x21, 0x58, 0x78, 0x2, 0x0, 0x0, 0x58, 0x93, 0x18, 0x0, 0x0, - 0x71, 0xd0, 0x0, 0x9, 0x6b, 0xd0, 0xf7, 0x26, 0x1f, 0xe0, 0x99, 0xfc, 0xd8, 0x0, 0x5, 0xb, 0x9d, 0xd6, 0x48, - 0xba, 0x0, 0x6, 0x6d, 0xd7, 0x86, 0xb6, 0xc8, 0x34, 0x0, 0x1c, 0x3e, 0xd5, 0x54, 0x14, 0xe8, 0xd6, 0xb4, 0x65, - 0xa8, 0x40, 0x51, 0x82, 0xea, 0xc9, 0xe3, 0x23, 0xf8, 0x99, 0x60, 0xa1, 0xf4, 0x8a, 0xda, 0xc9, 0x2f, 0x78, 0x72, - 0x7f}; - - uint8_t buf[448] = {0}; - - uint8_t bytesprops0[] = {0x87, 0xed, 0xc, 0xec, 0xa5, 0x64, 0xf8, 0x89, 0x7f, 0xda, 0x63, 0xe6, 0xa8, - 0xc0, 0xeb, 0x75, 0x7c, 0x27, 0xed, 0x7d, 0x7c, 0x22, 0xbb, 0x7f, 0x7f}; - uint8_t bytesprops1[] = {0xe9}; - uint8_t bytesprops2[] = {0x6, 0x2a, 0x34, 0xa, 0xf1, 0xea, 0x5e, 0x26, 0x6e, - 0xe8, 0xd5, 0x45, 0x44, 0x6, 0xe5, 0xfc, 0xe8, 0x36}; - uint8_t bytesprops3[] = {0x30, 0x94, 0x15, 0xd4, 0x68, 0xc8, 0x84, 0xdb, 0x39}; - uint8_t bytesprops4[] = {0x7c, 0x12, 0xa, 0x12, 0x9f, 0x90, 0x25, 0xdd, 0xf8, - 0x89, 0xa0, 0xe6, 0x5e, 0xf, 0x7, 0x9a, 0x93, 0x75}; - uint8_t bytesprops5[] = {0xee, 0x89, 0xfb, 0x7, 0xe5, 0x7b, 0xca, 0x99, 0xd2, 0x5, 0xc2, 0xf0, 0x1d, - 0x3c, 0xdf, 0xb7, 0xd0, 0xf1, 0xb3, 0x7b, 0x15, 0x53, 0xec, 0x8c, 0xea, 0x66}; - uint8_t bytesprops6[] = {0x82, 0xc8, 0xf3}; - uint8_t bytesprops7[] = {0x79, 0xd6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14824}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21140}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28394}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3189}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17060}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25160}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16528}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11067}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6275}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10831}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13007}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 14}}, - }; - - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xb, 0x68, 0xf7, 0x93, 0xdf, 0xa9, 0x84, 0xd3, 0x4b, 0xf9, - 0xa0, 0x45, 0x8d, 0x57, 0x8c, 0xa7, 0x1d, 0xa6, 0xdc, 0xc9}; - uint8_t byteswillprops1[] = {0x66, 0xb0, 0x47, 0x5, 0x23, 0x27, 0xb1, 0xef, 0x47, 0xa4, 0xb0, 0xf7, 0xec, 0xf0, 0xca}; - uint8_t byteswillprops2[] = {0x70, 0x66, 0x2, 0x36}; - uint8_t byteswillprops3[] = {0x36, 0x6b, 0x3b, 0xb7, 0xf8, 0x5, 0x94, 0xf5, 0xc7, 0x77, 0x3d}; - uint8_t byteswillprops4[] = {0xce, 0x15, 0xb6, 0xb6, 0x7d, 0xd8, 0xf9, 0x9f, 0x8c, 0x3a, 0xee, 0xca, 0x8b, 0xf8}; - uint8_t byteswillprops5[] = {0xcd, 0x87, 0x3}; - uint8_t byteswillprops6[] = {0xf8, 0x55, 0x95, 0xc0, 0xad, 0xe6, 0xe, 0x8f, 0xd7, 0x4b, - 0x4c, 0x2a, 0x6a, 0x9a, 0xef, 0x74, 0x8c, 0xf9, 0x6a, 0x96}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32718}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17111}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14845}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32716}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5765}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20010}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26929}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14663}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22648}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22675}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29136}}, - }; - - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6b, 0xd0, 0xf7, 0x26, 0x1f, 0xe0, 0x99, 0xfc, 0xd8}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb, 0x9d, 0xd6, 0x48, 0xba}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 24596; - uint8_t client_id_bytes[] = {0xc6, 0x8c, 0x3}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x6d, 0xd7, 0x86, 0xb6, 0xc8, 0x34}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x3e, 0xd5, 0x54, 0x14, 0xe8, 0xd6, 0xb4, 0x65, 0xa8, 0x40, 0x51, 0x82, 0xea, 0xc9, - 0xe3, 0x23, 0xf8, 0x99, 0x60, 0xa1, 0xf4, 0x8a, 0xda, 0xc9, 0x2f, 0x78, 0x72, 0x7f}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "e\ESCs", _password = Just "\183mF\183H", _lastWill = Nothing, _cleanSession = True, -// _keepAlive = 16377, _connID = "Ky\SOj\t\188i\157\233_I\201\187\143\DELY\175_\140}\230\&5\206\SUBqb+P0", _properties = -// [PropMessageExpiryInterval 12557,PropResponseInformation -// "\\\146\EM\EOT\170]y\131\188\DLE\201~\128\v\207\199\166\131\253\224*\133\EOT[A\214\197\"",PropAuthenticationMethod -// "\189\140T\249\247u\STX\138\151\197G",PropMaximumQoS 2,PropContentType -// "\STX\197\139@O\230\165\DEL\tcVj)eh\241-\STX\245\171\DLE\SOH\198\237\ETBc\239\DC3\ACK",PropAssignedClientIdentifier -// "Q\136\161\f\132x\203C\234\232\248\208x\246S\180\136I6\200\216b\239q",PropSubscriptionIdentifier -// 0,PropMaximumPacketSize 28632,PropSharedSubscriptionAvailable 164,PropTopicAliasMaximum -// 26012,PropSessionExpiryInterval 1199,PropTopicAliasMaximum 10320,PropUserProperty -// "\SOV\245\128\205z>\131\146v[\239\t4)O\141\198\226\r\t\SYN\189g&\171\202\166O" "\150l-h",PropUserProperty "\ETXO" -// "\ETB\148\188",PropPayloadFormatIndicator 169,PropAssignedClientIdentifier -// "\156\132aO\182\147iE\198y\rY\SI0",PropTopicAliasMaximum 28032,PropUserProperty -// "\187_VoL\CANwj\137(l\129\236<\209z\220FGI\237c\171\187\150'\215h" -// "2\128f\220\132\v\215\245cO\US\207\136",PropTopicAliasMaximum 29924,PropReceiveMaximum 32359,PropCorrelationData -// "\138\143\159:",PropAuthenticationData "\168\156\219\195\143\129",PropAssignedClientIdentifier "\142",PropTopicAlias -// 8611]} -TEST(Connect5QCTest, Encode30) { - uint8_t pkt[] = { - 0x10, 0xcb, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x3f, 0xf9, 0x94, 0x2, 0x2, 0x0, 0x0, 0x31, - 0xd, 0x1a, 0x0, 0x1c, 0x5c, 0x92, 0x19, 0x4, 0xaa, 0x5d, 0x79, 0x83, 0xbc, 0x10, 0xc9, 0x7e, 0x80, 0xb, 0xcf, - 0xc7, 0xa6, 0x83, 0xfd, 0xe0, 0x2a, 0x85, 0x4, 0x5b, 0x41, 0xd6, 0xc5, 0x22, 0x15, 0x0, 0xb, 0xbd, 0x8c, 0x54, -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68, - 0x0, 0xd, 0x32, 0x80, 0x66, 0xdc, 0x84, 0xb, 0xd7, 0xf5, 0x63, 0x4f, 0x1f, 0xcf, 0x88, 0x22, 0x74, 0xe4, 0x21, - 0x7e, 0x67, 0x9, 0x0, 0x4, 0x8a, 0x8f, 0x9f, 0x3a, 0x16, 0x0, 0x6, 0xa8, 0x9c, 0xdb, 0xc3, 0x8f, 0x81, 0x12, - 0x0, 0x1, 0x8e, 0x23, 0x21, 0xa3, 0x0, 0x1d, 0x4b, 0x79, 0xe, 0x6a, 0x9, 0xbc, 0x69, 0x9d, 0xe9, 0x5f, 0x49, - 0xc9, 0xbb, 0x8f, 0x7f, 0x59, 0xaf, 0x5f, 0x8c, 0x7d, 0xe6, 0x35, 0xce, 0x1a, 0x71, 0x62, 0x2b, 0x50, 0x30, 0x0, - 0x3, 0x65, 0x1b, 0x73, 0x0, 0x5, 0xb7, 0x6d, 0x46, 0xb7, 0x48}; - - uint8_t buf[344] = {0}; - - uint8_t bytesprops0[] = {0x5c, 0x92, 0x19, 0x4, 0xaa, 0x5d, 0x79, 0x83, 0xbc, 0x10, 0xc9, 0x7e, 0x80, 0xb, - 0xcf, 0xc7, 0xa6, 0x83, 0xfd, 0xe0, 0x2a, 0x85, 0x4, 0x5b, 0x41, 0xd6, 0xc5, 0x22}; - uint8_t bytesprops1[] = {0xbd, 0x8c, 0x54, 0xf9, 0xf7, 0x75, 0x2, 0x8a, 0x97, 0xc5, 0x47}; - uint8_t bytesprops2[] = {0x2, 0xc5, 0x8b, 0x40, 0x4f, 0xe6, 0xa5, 0x7f, 0x9, 0x63, 0x56, 0x6a, 0x29, 0x65, 0x68, - 0xf1, 0x2d, 0x2, 0xf5, 0xab, 0x10, 0x1, 0xc6, 0xed, 0x17, 0x63, 0xef, 0x13, 0x6}; - uint8_t bytesprops3[] = {0x51, 0x88, 0xa1, 0xc, 0x84, 0x78, 0xcb, 0x43, 0xea, 0xe8, 0xf8, 0xd0, - 0x78, 0xf6, 0x53, 0xb4, 0x88, 0x49, 0x36, 0xc8, 0xd8, 0x62, 0xef, 0x71}; - uint8_t bytesprops5[] = {0x96, 0x6c, 0x2d, 0x68}; - uint8_t bytesprops4[] = {0xe, 0x56, 0xf5, 0x80, 0xcd, 0x7a, 0x3e, 0x83, 0x92, 0x76, 0x5b, 0xef, 0x9, 0x34, 0x29, - 0x4f, 0x8d, 0xc6, 0xe2, 0xd, 0x9, 0x16, 0xbd, 0x67, 0x26, 0xab, 0xca, 0xa6, 0x4f}; - uint8_t bytesprops7[] = {0x17, 0x94, 0xbc}; - uint8_t bytesprops6[] = {0x3, 0x4f}; - uint8_t bytesprops8[] = {0x9c, 0x84, 0x61, 0x4f, 0xb6, 0x93, 0x69, 0x45, 0xc6, 0x79, 0xd, 0x59, 0xf, 0x30}; - uint8_t bytesprops10[] = {0x32, 0x80, 0x66, 0xdc, 0x84, 0xb, 0xd7, 0xf5, 0x63, 0x4f, 0x1f, 0xcf, 0x88}; - uint8_t bytesprops9[] = {0xbb, 0x5f, 0x56, 0x6f, 0x4c, 0x18, 0x77, 0x6a, 0x89, 0x28, 0x6c, 0x81, 0xec, 0x3c, - 0xd1, 0x7a, 0xdc, 0x46, 0x47, 0x49, 0xed, 0x63, 0xab, 0xbb, 0x96, 0x27, 0xd7, 0x68}; - uint8_t bytesprops11[] = {0x8a, 0x8f, 0x9f, 0x3a}; - uint8_t bytesprops12[] = {0xa8, 0x9c, 0xdb, 0xc3, 0x8f, 0x81}; - uint8_t bytesprops13[] = {0x8e}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12557}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28632}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26012}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1199}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10320}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {4, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops6}, .v = {3, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28032}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops9}, .v = {13, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29924}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32359}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8611}}, - }; - - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 16377; - uint8_t client_id_bytes[] = {0x4b, 0x79, 0xe, 0x6a, 0x9, 0xbc, 0x69, 0x9d, 0xe9, 0x5f, 0x49, 0xc9, 0xbb, 0x8f, 0x7f, - 0x59, 0xaf, 0x5f, 0x8c, 0x7d, 0xe6, 0x35, 0xce, 0x1a, 0x71, 0x62, 0x2b, 0x50, 0x30}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x65, 0x1b, 0x73}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xb7, 0x6d, 0x46, 0xb7, 0x48}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\238zO", _password = Just -// "\183xW\149\225\255\ACK\160\227\147\208\185\174P\148l\216\&6B\183J\152", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = "\192G3\202\231\255\195\177\168\239\233\234\161\DC3\186Q\230\"\t\146\ACK", -// _willMsg = "\GS\230a\199\205<}", _willProps = [PropResponseTopic -// "o%\204\217\EOT\DC2\197\131\CAN\r\241\134\247\215Ag0\135",PropAssignedClientIdentifier "\162w\t[",PropCorrelationData -// "\144",PropReceiveMaximum 976,PropRequestProblemInformation 134,PropContentType "\204\245",PropTopicAlias -// 32453,PropMaximumPacketSize 30765,PropWillDelayInterval 25398,PropPayloadFormatIndicator -// 110,PropRequestProblemInformation 6,PropReasonString "\223\236s\137\161",PropRequestResponseInformation -// 221,PropSharedSubscriptionAvailable 75,PropMaximumQoS 153,PropSharedSubscriptionAvailable 16,PropTopicAlias -// 14248,PropServerKeepAlive 32227,PropRequestProblemInformation 248]}), _cleanSession = True, _keepAlive = 18523, -// _connID = "\232\204\f\212 \185\241-\229\183\230\160\202i\225\DC1_2\224\152\198v[\219md\170", _properties = -// [PropServerKeepAlive 12674,PropServerKeepAlive 10216,PropReasonString -// "\136\181\GS\135\130^\"\216\136\&5",PropTopicAlias 20600,PropSubscriptionIdentifier 3,PropResponseTopic -// "\b\163W\\\226\ACKd\131\213\163",PropServerKeepAlive 21705,PropResponseTopic -// "\252\185R\160\"2\DLE$\f|\FS\178\205\197\188\254D7\185z\189%M",PropTopicAlias 22536,PropPayloadFormatIndicator -// 71,PropTopicAliasMaximum 12012,PropSessionExpiryInterval 14012,PropUserProperty -// "\175\254Q\166P<\228\a\141-|@\181\241\&2e\142\231\212\173\255\&7\131\194\195\154/7" -// "`\252\221Z'-\130\238\ETX\216&B\246\&8F9\ACK\ENQ\201\DC4\154S@)\198\183\132",PropRequestProblemInformation -// 71,PropWildcardSubscriptionAvailable 107,PropMessageExpiryInterval 7104,PropServerReference -// "\224\FS\STX",PropReceiveMaximum 12644,PropRetainAvailable 27,PropWildcardSubscriptionAvailable -// 226,PropSharedSubscriptionAvailable 163,PropSubscriptionIdentifier 13,PropPayloadFormatIndicator 171,PropTopicAlias -// 25711,PropTopicAliasMaximum 16376,PropUserProperty "r\NAK\206(7\198\CAN\DC4[!O\141\176\EMu\SO\199Mz$\151\156;" -// "sc\255-y"]} -TEST(Connect5QCTest, Encode31) { - uint8_t pkt[] = { - 0x10, 0x88, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x48, 0x5b, 0xce, 0x1, 0x13, 0x31, 0x82, 0x13, - 0x27, 0xe8, 0x1f, 0x0, 0xa, 0x88, 0xb5, 0x1d, 0x87, 0x82, 0x5e, 0x22, 0xd8, 0x88, 0x35, 0x23, 0x50, 0x78, 0xb, - 0x3, 0x8, 0x0, 0xa, 0x8, 0xa3, 0x57, 0x5c, 0xe2, 0x6, 0x64, 0x83, 0xd5, 0xa3, 0x13, 0x54, 0xc9, 0x8, 0x0, - 0x17, 0xfc, 0xb9, 0x52, 0xa0, 0x22, 0x32, 0x10, 0x24, 0xc, 0x7c, 0x1c, 0xb2, 0xcd, 0xc5, 0xbc, 0xfe, 0x44, 0x37, - 0xb9, 0x7a, 0xbd, 0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0xf7, 0xd7, 0x41, 0x67, 0x30, 0x87, 0x12, 0x0, 0x4, 0xa2, 0x77, 0x9, 0x5b, 0x9, 0x0, 0x1, 0x90, 0x21, 0x3, - 0xd0, 0x17, 0x86, 0x3, 0x0, 0x2, 0xcc, 0xf5, 0x23, 0x7e, 0xc5, 0x27, 0x0, 0x0, 0x78, 0x2d, 0x18, 0x0, 0x0, - 0x63, 0x36, 0x1, 0x6e, 0x17, 0x6, 0x1f, 0x0, 0x5, 0xdf, 0xec, 0x73, 0x89, 0xa1, 0x19, 0xdd, 0x2a, 0x4b, 0x24, - 0x99, 0x2a, 0x10, 0x23, 0x37, 0xa8, 0x13, 0x7d, 0xe3, 0x17, 0xf8, 0x0, 0x15, 0xc0, 0x47, 0x33, 0xca, 0xe7, 0xff, - 0xc3, 0xb1, 0xa8, 0xef, 0xe9, 0xea, 0xa1, 0x13, 0xba, 0x51, 0xe6, 0x22, 0x9, 0x92, 0x6, 0x0, 0x7, 0x1d, 0xe6, - 0x61, 0xc7, 0xcd, 0x3c, 0x7d, 0x0, 0x3, 0xee, 0x7a, 0x4f, 0x0, 0x16, 0xb7, 0x78, 0x57, 0x95, 0xe1, 0xff, 0x6, - 0xa0, 0xe3, 0x93, 0xd0, 0xb9, 0xae, 0x50, 0x94, 0x6c, 0xd8, 0x36, 0x42, 0xb7, 0x4a, 0x98}; - - uint8_t buf[405] = {0}; - - uint8_t bytesprops0[] = {0x88, 0xb5, 0x1d, 0x87, 0x82, 0x5e, 0x22, 0xd8, 0x88, 0x35}; - uint8_t bytesprops1[] = {0x8, 0xa3, 0x57, 0x5c, 0xe2, 0x6, 0x64, 0x83, 0xd5, 0xa3}; - uint8_t bytesprops2[] = {0xfc, 0xb9, 0x52, 0xa0, 0x22, 0x32, 0x10, 0x24, 0xc, 0x7c, 0x1c, 0xb2, - 0xcd, 0xc5, 0xbc, 0xfe, 0x44, 0x37, 0xb9, 0x7a, 0xbd, 0x25, 0x4d}; - uint8_t bytesprops4[] = {0x60, 0xfc, 0xdd, 0x5a, 0x27, 0x2d, 0x82, 0xee, 0x3, 0xd8, 0x26, 0x42, 0xf6, 0x38, - 0x46, 0x39, 0x6, 0x5, 0xc9, 0x14, 0x9a, 0x53, 0x40, 0x29, 0xc6, 0xb7, 0x84}; - uint8_t bytesprops3[] = {0xaf, 0xfe, 0x51, 0xa6, 0x50, 0x3c, 0xe4, 0x7, 0x8d, 0x2d, 0x7c, 0x40, 0xb5, 0xf1, - 0x32, 0x65, 0x8e, 0xe7, 0xd4, 0xad, 0xff, 0x37, 0x83, 0xc2, 0xc3, 0x9a, 0x2f, 0x37}; - uint8_t bytesprops5[] = {0xe0, 0x1c, 0x2}; - uint8_t bytesprops7[] = {0x73, 0x63, 0xff, 0x2d, 0x79}; - uint8_t bytesprops6[] = {0x72, 0x15, 0xce, 0x28, 0x37, 0xc6, 0x18, 0x14, 0x5b, 0x21, 0x4f, 0x8d, - 0xb0, 0x19, 0x75, 0xe, 0xc7, 0x4d, 0x7a, 0x24, 0x97, 0x9c, 0x3b}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12674}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10216}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20600}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21705}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22536}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12012}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14012}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops3}, .v = {27, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7104}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12644}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25711}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16376}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops6}, .v = {5, (char*)&bytesprops7}}}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x6f, 0x25, 0xcc, 0xd9, 0x4, 0x12, 0xc5, 0x83, 0x18, - 0xd, 0xf1, 0x86, 0xf7, 0xd7, 0x41, 0x67, 0x30, 0x87}; - uint8_t byteswillprops1[] = {0xa2, 0x77, 0x9, 0x5b}; - uint8_t byteswillprops2[] = {0x90}; - uint8_t byteswillprops3[] = {0xcc, 0xf5}; - uint8_t byteswillprops4[] = {0xdf, 0xec, 0x73, 0x89, 0xa1}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 976}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32453}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30765}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25398}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14248}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32227}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 248}}, - }; - - lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc0, 0x47, 0x33, 0xca, 0xe7, 0xff, 0xc3, 0xb1, 0xa8, 0xef, 0xe9, - 0xea, 0xa1, 0x13, 0xba, 0x51, 0xe6, 0x22, 0x9, 0x92, 0x6}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1d, 0xe6, 0x61, 0xc7, 0xcd, 0x3c, 0x7d}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 18523; - uint8_t client_id_bytes[] = {0xe8, 0xcc, 0xc, 0xd4, 0x20, 0xb9, 0xf1, 0x2d, 0xe5, 0xb7, 0xe6, 0xa0, 0xca, 0x69, - 0xe1, 0x11, 0x5f, 0x32, 0xe0, 0x98, 0xc6, 0x76, 0x5b, 0xdb, 0x6d, 0x64, 0xaa}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xee, 0x7a, 0x4f}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xb7, 0x78, 0x57, 0x95, 0xe1, 0xff, 0x6, 0xa0, 0xe3, 0x93, 0xd0, - 0xb9, 0xae, 0x50, 0x94, 0x6c, 0xd8, 0x36, 0x42, 0xb7, 0x4a, 0x98}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "Ae\200\161\175\235\ETX\154", _password = Just -// "\ESCm\NULa\222\180jD\243e\212[\t7\DC1\143\247~\DC4=\196NJ\FS<\201\150\171\151", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\FS;\251\141\v\199\239\NUL\196T{\DC3x?\154\217\156_", _willMsg = -// "_'9\US\219\b\147\&0\133+-\148\&7G\249\172\205[\147\208\DC3\ESCC", _willProps = [PropMaximumPacketSize -// 17904,PropMessageExpiryInterval 1141,PropReasonString -// ";\"B\177\185\\n\DC3uxPC\v{\185?S\223j\146\190\vWg\158cE\"\151A",PropMessageExpiryInterval -// 29326,PropMaximumPacketSize 25000,PropWildcardSubscriptionAvailable 77,PropSubscriptionIdentifierAvailable -// 224,PropServerKeepAlive 7466,PropCorrelationData -// "\228\209\212?\135S`&\NAK\204\ENQ\200\215\161~V\220\224O\243-\213\131R9_\198\207\174",PropResponseInformation -// "c\197f\227_\NUL\246\228",PropCorrelationData "\140\153@\RS\176\212\128\237K(\ACK\218\223\&1\168\185p\DC1\171\146\198:\171\218",PropRequestProblemInformation -// 168,PropMaximumQoS 86,PropSharedSubscriptionAvailable 69,PropSharedSubscriptionAvailable 78,PropContentType -// "\196/?\150\169&\134\128 H\176r\DLE!\152\&8\168\174\252\133\218\DC2\203\181s.",PropReceiveMaximum -// 11980,PropSubscriptionIdentifier 7,PropWillDelayInterval 21313,PropContentType -// "\226\136\254\152\227\198;",PropWillDelayInterval 21790]}), _cleanSession = False, _keepAlive = 11629, _connID = -// "\\X\222", _properties = [PropSubscriptionIdentifier 13,PropUserProperty "\251\234vxH\143\177\&2\183M\180w\180\NULV" -// "\NAK\132\212&",PropSessionExpiryInterval 6175,PropAuthenticationData "\226\205",PropCorrelationData -// "",PropRequestProblemInformation 154,PropServerReference -// "\v\163\&7\160\145\221V\228\227\186\215*9\220\244\\\195\142\199M\229\207\246\&0",PropReasonString "\203"]} -TEST(Connect5QCTest, Encode32) { - uint8_t pkt[] = { - 0x10, 0xdb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x2d, 0x6d, 0x48, 0xb, 0xd, 0x26, 0x0, 0xf, - 0xfb, 0xea, 0x76, 0x78, 0x48, 0x8f, 0xb1, 0x32, 0xb7, 0x4d, 0xb4, 0x77, 0xb4, 0x0, 0x56, 0x0, 0x4, 0x15, 0x84, - 0xd4, 0x26, 0x11, 0x0, 0x0, 0x18, 0x1f, 0x16, 0x0, 0x2, 0xe2, 0xcd, 0x9, 0x0, 0x0, 0x17, 0x9a, 0x1c, 0x0, - 0x18, 0xb, 0xa3, 0x37, 0xa0, 0x91, 0xdd, 0x56, 0xe4, 0xe3, 0xba, 0xd7, 0x2a, 0x39, 0xdc, 0xf4, 0x5c, 0xc3, 0x8e, - 0xc7, 0x4d, 0xe5, 0xcf, 0xf6, 0x30, 0x1f,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0xf3, 0x65, 0xd4, 0x5b, 0x9, 0x37, 0x11, 0x8f, 0xf7, 0x7e, 0x14, 0x3d, 0xc4, 0x4e, 0x4a, 0x1c, 0x3c, 0xc9, - 0x96, 0xab, 0x97}; - - uint8_t buf[488] = {0}; - - uint8_t bytesprops1[] = {0x15, 0x84, 0xd4, 0x26}; - uint8_t bytesprops0[] = {0xfb, 0xea, 0x76, 0x78, 0x48, 0x8f, 0xb1, 0x32, 0xb7, 0x4d, 0xb4, 0x77, 0xb4, 0x0, 0x56}; - uint8_t bytesprops2[] = {0xe2, 0xcd}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0xb, 0xa3, 0x37, 0xa0, 0x91, 0xdd, 0x56, 0xe4, 0xe3, 0xba, 0xd7, 0x2a, - 0x39, 0xdc, 0xf4, 0x5c, 0xc3, 0x8e, 0xc7, 0x4d, 0xe5, 0xcf, 0xf6, 0x30}; - uint8_t bytesprops5[] = {0xcb}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {4, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6175}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x3b, 0x22, 0x42, 0xb1, 0xb9, 0x5c, 0x6e, 0x13, 0x75, 0x78, - 0x50, 0x43, 0xb, 0x7b, 0xb9, 0x3f, 0x53, 0xdf, 0x6a, 0x92, - 0xbe, 0xb, 0x57, 0x67, 0x9e, 0x63, 0x45, 0x22, 0x97, 0x41}; - uint8_t byteswillprops1[] = {0xe4, 0xd1, 0xd4, 0x3f, 0x87, 0x53, 0x60, 0x26, 0x15, 0xcc, 0x5, 0xc8, 0xd7, 0xa1, 0x7e, - 0x56, 0xdc, 0xe0, 0x4f, 0xf3, 0x2d, 0xd5, 0x83, 0x52, 0x39, 0x5f, 0xc6, 0xcf, 0xae}; - uint8_t byteswillprops2[] = {0x63, 0xc5, 0x66, 0xe3, 0x5f, 0x0, 0xf6, 0xe4}; - uint8_t byteswillprops3[] = {0x8c, 0x99, 0x40, 0x1e, 0x3c, 0x51, 0xce, 0x49, 0x7e, 0xb4, 0x92, 0xe7, 0xfc, 0x97}; - uint8_t byteswillprops4[] = {0x7b, 0x74, 0xad, 0x14, 0xcc, 0x5, 0xc3, 0x94, 0x67, 0x4, 0xbc, 0x1b, 0x42, 0xfe}; - uint8_t byteswillprops5[] = {0xe5, 0x2e, 0xbc, 0x65, 0x57, 0x2e, 0xce, 0x8}; - uint8_t byteswillprops6[] = {0x50, 0x88, 0xaf, 0x34, 0x5b, 0x29, 0x36, 0x81, - 0x61, 0x3c, 0xa1, 0xe1, 0xdd, 0xe3, 0x99, 0x5f}; - uint8_t byteswillprops8[] = {0x6e, 0x64, 0x6f, 0xc, 0xbd, 0x44, 0x36, 0x7c, 0x3e, 0xb0, 0xd4, 0x80, 0xed, 0x4b, 0x28, - 0x6, 0xda, 0xdf, 0x31, 0xa8, 0xb9, 0x70, 0x11, 0xab, 0x92, 0xc6, 0x3a, 0xab, 0xda}; - uint8_t byteswillprops7[] = {0x8e, 0x5a, 0x2d, 0x8a, 0x24, 0xb8, 0x3d, 0x5b, 0x2d, 0x39, - 0x7, 0xc6, 0xef, 0xda, 0xd0, 0x42, 0xba, 0x12, 0x32}; - uint8_t byteswillprops9[] = {0xc4, 0x2f, 0x3f, 0x96, 0xa9, 0x26, 0x86, 0x80, 0x20, 0x48, 0xb0, 0x72, 0x10, - 0x21, 0x98, 0x38, 0xa8, 0xae, 0xfc, 0x85, 0xda, 0x12, 0xcb, 0xb5, 0x73, 0x2e}; - uint8_t byteswillprops10[] = {0xe2, 0x88, 0xfe, 0x98, 0xe3, 0xc6, 0x3b}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17904}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1141}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29326}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25000}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7466}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4866}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27714}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19961}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {19, (char*)&byteswillprops7}, .v = {29, (char*)&byteswillprops8}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11980}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21313}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21790}}, - }; - - lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1c, 0x3b, 0xfb, 0x8d, 0xb, 0xc7, 0xef, 0x0, 0xc4, - 0x54, 0x7b, 0x13, 0x78, 0x3f, 0x9a, 0xd9, 0x9c, 0x5f}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5f, 0x27, 0x39, 0x1f, 0xdb, 0x8, 0x93, 0x30, 0x85, 0x2b, 0x2d, 0x94, - 0x37, 0x47, 0xf9, 0xac, 0xcd, 0x5b, 0x93, 0xd0, 0x13, 0x1b, 0x43}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 11629; - uint8_t client_id_bytes[] = {0x5c, 0x58, 0xde}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x41, 0x65, 0xc8, 0xa1, 0xaf, 0xeb, 0x3, 0x9a}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x1b, 0x6d, 0x0, 0x61, 0xde, 0xb4, 0x6a, 0x44, 0xf3, 0x65, 0xd4, 0x5b, 0x9, 0x37, 0x11, - 0x8f, 0xf7, 0x7e, 0x14, 0x3d, 0xc4, 0x4e, 0x4a, 0x1c, 0x3c, 0xc9, 0x96, 0xab, 0x97}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\150\147\177\160\218r%'C\139\159\&6\178", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\158/9\141", _willMsg = -// "\189\DC4a\NUL\243\231@W\178\194\&7\212\\\150W\244\244\226Y=\164\138\228\154qi\129(\SOH}", _willProps = -// [PropSharedSubscriptionAvailable 219,PropTopicAlias 23920,PropResponseTopic -// "2\181Q\254\DC1\192\172N\186",PropWildcardSubscriptionAvailable 247,PropRetainAvailable 33,PropUserProperty -// "\ESC6\160\DEL\193\145\ENQ\r\208\&7\201\253t" "\189O\235\NAK'm\186\SO\\i",PropSharedSubscriptionAvailable -// 244,PropAssignedClientIdentifier -// "\195\&5\163\191#\236;\252\SYN;\178\165~\194\203\229z\GS\250\DELW\v\230\155\DC1'm",PropRequestResponseInformation -// 26,PropPayloadFormatIndicator 192,PropWillDelayInterval 16423,PropAssignedClientIdentifier -// "Q\195\v\253",PropReasonString "\ENQ\161\133\237_\215\184\184&CW",PropCorrelationData -// "~\167\239\141\208\215g",PropServerKeepAlive 10841,PropAssignedClientIdentifier -// "~\186\176\176h\NAKv",PropWildcardSubscriptionAvailable 29,PropMessageExpiryInterval -// 26220,PropRequestResponseInformation 54,PropWillDelayInterval 16152,PropSubscriptionIdentifier -// 14,PropWildcardSubscriptionAvailable 90,PropReasonString "\211\172\247",PropContentType "\246",PropAuthenticationData -// "\DC3U\193ldY\254\253)\192`\216>\199\"\219\207\217",PropAuthenticationData -// "\131\v\174\206\161\CAN\ETB\n\132\&4s@\a",PropResponseTopic ""]}), _cleanSession = True, _keepAlive = 6008, _connID = -// "3\252\rE\195\SYNO^\160\182\243\US\166\254\183 \NAK\SUB\159\173\196\\\150\179D\245", _properties = -// [PropMaximumPacketSize 5391,PropAssignedClientIdentifier -// "kU[\143\214o\252\200\233\166bT\SI\218\247\147\152\226\n",PropAssignedClientIdentifier -// "\207\157[\245RG8\193",PropPayloadFormatIndicator 2,PropMaximumPacketSize 32093,PropSessionExpiryInterval -// 16956,PropPayloadFormatIndicator 157,PropReceiveMaximum 28710,PropReceiveMaximum 15106,PropResponseTopic -// "",PropAssignedClientIdentifier "\CAN\140%\214",PropTopicAlias 2832,PropMessageExpiryInterval 27101,PropTopicAlias -// 4406,PropSubscriptionIdentifierAvailable 181,PropRequestProblemInformation 154,PropAuthenticationData -// "i~\230\224bT\129\209\137\182",PropSessionExpiryInterval 21237,PropTopicAlias 25576]} -TEST(Connect5QCTest, Encode33) { - uint8_t pkt[] = { - 0x10, 0x81, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe, 0x17, 0x78, 0x68, 0x27, 0x0, 0x0, 0x15, 0xf, - 0x12, 0x0, 0x13, 0x6b, 0x55, 0x5b, 0x8f, 0xd6, 0x6f, 0xfc, 0xc8, 0xe9, 0xa6, 0x62, 0x54, 0xf, 0xda, 0xf7, 0x93, - 0x98, 0xe2, 0xa, 0x12, 0x0, 0x8, 0xcf, 0x9d, 0x5b, 0xf5, 0x52, 0x47, 0x38, 0xc1, 0x1, 0x2, 0x27, 0x0, 0x0, - 0x7d, 0x5d, 0x11, 0x0, 0x0, 0x42, 0x3c, 0x1, 0x9d, 0x21, 0x70, 0x26, 0x21, 0x3b, 0x2, 0x8, 0x0, 0x0, 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7, 0x7e, 0xa7, 0xef, 0x8d, - 0xd0, 0xd7, 0x67, 0x13, 0x2a, 0x59, 0x12, 0x0, 0x7, 0x7e, 0xba, 0xb0, 0xb0, 0x68, 0x15, 0x76, 0x28, 0x1d, 0x2, - 0x0, 0x0, 0x66, 0x6c, 0x19, 0x36, 0x18, 0x0, 0x0, 0x3f, 0x18, 0xb, 0xe, 0x28, 0x5a, 0x1f, 0x0, 0x3, 0xd3, - 0xac, 0xf7, 0x3, 0x0, 0x1, 0xf6, 0x16, 0x0, 0x12, 0x13, 0x55, 0xc1, 0x6c, 0x64, 0x59, 0xfe, 0xfd, 0x29, 0xc0, - 0x60, 0xd8, 0x3e, 0xc7, 0x22, 0xdb, 0xcf, 0xd9, 0x16, 0x0, 0xd, 0x83, 0xb, 0xae, 0xce, 0xa1, 0x18, 0x17, 0xa, - 0x84, 0x34, 0x73, 0x40, 0x7, 0x8, 0x0, 0x0, 0x0, 0x4, 0x9e, 0x2f, 0x39, 0x8d, 0x0, 0x1e, 0xbd, 0x14, 0x61, - 0x0, 0xf3, 0xe7, 0x40, 0x57, 0xb2, 0xc2, 0x37, 0xd4, 0x5c, 0x96, 0x57, 0xf4, 0xf4, 0xe2, 0x59, 0x3d, 0xa4, 0x8a, - 0xe4, 0x9a, 0x71, 0x69, 0x81, 0x28, 0x1, 0x7d}; - - uint8_t buf[398] = {0}; - - uint8_t bytesprops0[] = {0x6b, 0x55, 0x5b, 0x8f, 0xd6, 0x6f, 0xfc, 0xc8, 0xe9, 0xa6, - 0x62, 0x54, 0xf, 0xda, 0xf7, 0x93, 0x98, 0xe2, 0xa}; - uint8_t bytesprops1[] = {0xcf, 0x9d, 0x5b, 0xf5, 0x52, 0x47, 0x38, 0xc1}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x18, 0x8c, 0x25, 0xd6}; - uint8_t bytesprops4[] = {0x69, 0x7e, 0xe6, 0xe0, 0x62, 0x54, 0x81, 0xd1, 0x89, 0xb6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5391}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32093}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16956}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28710}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15106}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2832}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27101}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4406}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21237}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25576}}, - }; - - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x32, 0xb5, 0x51, 0xfe, 0x11, 0xc0, 0xac, 0x4e, 0xba}; - uint8_t byteswillprops2[] = {0xbd, 0x4f, 0xeb, 0x15, 0x27, 0x6d, 0xba, 0xe, 0x5c, 0x69}; - uint8_t byteswillprops1[] = {0x1b, 0x36, 0xa0, 0x7f, 0xc1, 0x91, 0x5, 0xd, 0xd0, 0x37, 0xc9, 0xfd, 0x74}; - uint8_t byteswillprops3[] = {0xc3, 0x35, 0xa3, 0xbf, 0x23, 0xec, 0x3b, 0xfc, 0x16, 0x3b, 0xb2, 0xa5, 0x7e, 0xc2, - 0xcb, 0xe5, 0x7a, 0x1d, 0xfa, 0x7f, 0x57, 0xb, 0xe6, 0x9b, 0x11, 0x27, 0x6d}; - uint8_t byteswillprops4[] = {0x51, 0xc3, 0xb, 0xfd}; - uint8_t byteswillprops5[] = {0x5, 0xa1, 0x85, 0xed, 0x5f, 0xd7, 0xb8, 0xb8, 0x26, 0x43, 0x57}; - uint8_t byteswillprops6[] = {0x7e, 0xa7, 0xef, 0x8d, 0xd0, 0xd7, 0x67}; - uint8_t byteswillprops7[] = {0x7e, 0xba, 0xb0, 0xb0, 0x68, 0x15, 0x76}; - uint8_t byteswillprops8[] = {0xd3, 0xac, 0xf7}; - uint8_t byteswillprops9[] = {0xf6}; - uint8_t byteswillprops10[] = {0x13, 0x55, 0xc1, 0x6c, 0x64, 0x59, 0xfe, 0xfd, 0x29, - 0xc0, 0x60, 0xd8, 0x3e, 0xc7, 0x22, 0xdb, 0xcf, 0xd9}; - uint8_t byteswillprops11[] = {0x83, 0xb, 0xae, 0xce, 0xa1, 0x18, 0x17, 0xa, 0x84, 0x34, 0x73, 0x40, 0x7}; - uint8_t byteswillprops12[] = {0}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23920}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {13, (char*)&byteswillprops1}, .v = {10, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16423}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10841}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26220}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16152}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&byteswillprops12}}}, - }; - - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9e, 0x2f, 0x39, 0x8d}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbd, 0x14, 0x61, 0x0, 0xf3, 0xe7, 0x40, 0x57, 0xb2, 0xc2, - 0x37, 0xd4, 0x5c, 0x96, 0x57, 0xf4, 0xf4, 0xe2, 0x59, 0x3d, - 0xa4, 0x8a, 0xe4, 0x9a, 0x71, 0x69, 0x81, 0x28, 0x1, 0x7d}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 6008; - uint8_t client_id_bytes[] = {0x33, 0xfc, 0xd, 0x45, 0xc3, 0x16, 0x4f, 0x5e, 0xa0, 0xb6, 0xf3, 0x1f, 0xa6, - 0xfe, 0xb7, 0x20, 0x15, 0x1a, 0x9f, 0xad, 0xc4, 0x5c, 0x96, 0xb3, 0x44, 0xf5}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x96, 0x93, 0xb1, 0xa0, 0xda, 0x72, 0x25, 0x27, 0x43, 0x8b, 0x9f, 0x36, 0xb2}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "Y\v>5Bm\227", _password = Just "\138\203", _lastWill = Just (LastWill {_willRetain -// = False, _willQoS = QoS2, _willTopic = "\206v\171\156\146%.\249$W", _willMsg = "\bH\DC4H", _willProps = -// [PropRetainAvailable 199,PropMessageExpiryInterval 29826,PropRequestResponseInformation -// 144,PropRequestProblemInformation 175,PropSubscriptionIdentifier 23,PropSharedSubscriptionAvailable -// 242,PropCorrelationData -// "_\181\173j\250\161\156\248\135\161D\ETB\199\142\228\159\251\148/\SOH\202\225",PropCorrelationData -// "\r*\r\212yag\218[_\151k\225\191\136\186\216\232\230\182\223\160\GS",PropServerKeepAlive 11815]}), _cleanSession = -// True, _keepAlive = 23415, _connID = "\204wCr\148\250tb\RS\139\204\142\r\206\180\231\DC26Cv\254+\STX\ETX\250\t", -// _properties = [PropCorrelationData -// "S\SUB,\146\197/J\FS\145.\a\147L\155\167\230+U&\151S\DLE\254\167t\167Ve\200\180",PropRetainAvailable -// 197,PropPayloadFormatIndicator 175,PropTopicAliasMaximum 2854,PropReasonString -// "\179\NAK\154\a;Na%\128\234Q\141x\248<\178\254r\232o\147/\252r\179\229\230",PropMessageExpiryInterval -// 12863,PropTopicAlias 5178,PropRetainAvailable 17,PropMessageExpiryInterval 31630,PropUserProperty -// "V\136v\182\196(4\146\145P" "W\206\210\196\185Z)o\240\130C\248X\219R\202\153\b\221",PropMessageExpiryInterval -// 11401,PropUserProperty "\ETBf" "}\v}\248\167\EM\217\154\139K\231h\253\173fa\209\240",PropAuthenticationData -// "\EMSz\229\231W\246f\US\238\228%\192}\210\173\185t\205",PropMessageExpiryInterval -// 3915,PropSubscriptionIdentifierAvailable 223,PropWillDelayInterval 7999,PropMessageExpiryInterval -// 21248,PropRetainAvailable 63,PropTopicAliasMaximum 30995,PropServerKeepAlive 5186,PropReasonString " -// .\246$\145\200?|\236m\175D",PropTopicAliasMaximum 31289,PropRetainAvailable 46]} -TEST(Connect5QCTest, Encode34) { - uint8_t pkt[] = { - 0x10, 0xe5, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x5b, 0x77, 0xd8, 0x1, 0x9, 0x0, 0x1e, 0x53, - 0x1a, 0x2c, 0x92, 0xc5, 0x2f, 0x4a, 0x1c, 0x91, 0x2e, 0x7, 0x93, 0x4c, 0x9b, 0xa7, 0xe6, 0x2b, 0x55, 0x26, 0x97, - 0x53, 0x10, 0xfe, 0xa7, 0x74, 0xa7, 0x56, 0x65, 0xc8, 0xb4, 0x25, 0xc5, 0x1, 0xaf, 0x22, 0xb, 0x26, 0x1f, 0x0, - 0x1b, 0xb3, 0x15, 0x9a, 0x7, 0x3b, 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, 0x43, 0x76, 0xfe, 0x2b, 0x2, 0x3, 0xfa, 0x9, 0x45, 0x25, 0xc7, 0x2, 0x0, 0x0, 0x74, - 0x82, 0x19, 0x90, 0x17, 0xaf, 0xb, 0x17, 0x2a, 0xf2, 0x9, 0x0, 0x16, 0x5f, 0xb5, 0xad, 0x6a, 0xfa, 0xa1, 0x9c, - 0xf8, 0x87, 0xa1, 0x44, 0x17, 0xc7, 0x8e, 0xe4, 0x9f, 0xfb, 0x94, 0x2f, 0x1, 0xca, 0xe1, 0x9, 0x0, 0x17, 0xd, - 0x2a, 0xd, 0xd4, 0x79, 0x61, 0x67, 0xda, 0x5b, 0x5f, 0x97, 0x6b, 0xe1, 0xbf, 0x88, 0xba, 0xd8, 0xe8, 0xe6, 0xb6, - 0xdf, 0xa0, 0x1d, 0x13, 0x2e, 0x27, 0x0, 0xa, 0xce, 0x76, 0xab, 0x9c, 0x92, 0x25, 0x2e, 0xf9, 0x24, 0x57, 0x0, - 0x4, 0x8, 0x48, 0x14, 0x48, 0x0, 0x7, 0x59, 0xb, 0x3e, 0x35, 0x42, 0x6d, 0xe3, 0x0, 0x2, 0x8a, 0xcb}; - - uint8_t buf[370] = {0}; - - uint8_t bytesprops0[] = {0x53, 0x1a, 0x2c, 0x92, 0xc5, 0x2f, 0x4a, 0x1c, 0x91, 0x2e, 0x7, 0x93, 0x4c, 0x9b, 0xa7, - 0xe6, 0x2b, 0x55, 0x26, 0x97, 0x53, 0x10, 0xfe, 0xa7, 0x74, 0xa7, 0x56, 0x65, 0xc8, 0xb4}; - uint8_t bytesprops1[] = {0xb3, 0x15, 0x9a, 0x7, 0x3b, 0x4e, 0x61, 0x25, 0x80, 0xea, 0x51, 0x8d, 0x78, 0xf8, - 0x3c, 0xb2, 0xfe, 0x72, 0xe8, 0x6f, 0x93, 0x2f, 0xfc, 0x72, 0xb3, 0xe5, 0xe6}; - uint8_t bytesprops3[] = {0x57, 0xce, 0xd2, 0xc4, 0xb9, 0x5a, 0x29, 0x6f, 0xf0, 0x82, - 0x43, 0xf8, 0x58, 0xdb, 0x52, 0xca, 0x99, 0x8, 0xdd}; - uint8_t bytesprops2[] = {0x56, 0x88, 0x76, 0xb6, 0xc4, 0x28, 0x34, 0x92, 0x91, 0x50}; - uint8_t bytesprops5[] = {0x7d, 0xb, 0x7d, 0xf8, 0xa7, 0x19, 0xd9, 0x9a, 0x8b, - 0x4b, 0xe7, 0x68, 0xfd, 0xad, 0x66, 0x61, 0xd1, 0xf0}; - uint8_t bytesprops4[] = {0x17, 0x66}; - uint8_t bytesprops6[] = {0x19, 0x53, 0x7a, 0xe5, 0xe7, 0x57, 0xf6, 0x66, 0x1f, 0xee, - 0xe4, 0x25, 0xc0, 0x7d, 0xd2, 0xad, 0xb9, 0x74, 0xcd}; - uint8_t bytesprops7[] = {0x20, 0x2e, 0xf6, 0x24, 0x91, 0xc8, 0x3f, 0x7c, 0xec, 0x6d, 0xaf, 0x44}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2854}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12863}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5178}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31630}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {19, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11401}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops4}, .v = {18, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3915}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7999}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21248}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30995}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5186}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31289}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 46}}, - }; - - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x5f, 0xb5, 0xad, 0x6a, 0xfa, 0xa1, 0x9c, 0xf8, 0x87, 0xa1, 0x44, - 0x17, 0xc7, 0x8e, 0xe4, 0x9f, 0xfb, 0x94, 0x2f, 0x1, 0xca, 0xe1}; - uint8_t byteswillprops1[] = {0xd, 0x2a, 0xd, 0xd4, 0x79, 0x61, 0x67, 0xda, 0x5b, 0x5f, 0x97, 0x6b, - 0xe1, 0xbf, 0x88, 0xba, 0xd8, 0xe8, 0xe6, 0xb6, 0xdf, 0xa0, 0x1d}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29826}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11815}}, - }; - - lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xce, 0x76, 0xab, 0x9c, 0x92, 0x25, 0x2e, 0xf9, 0x24, 0x57}; - lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x8, 0x48, 0x14, 0x48}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 23415; - uint8_t client_id_bytes[] = {0xcc, 0x77, 0x43, 0x72, 0x94, 0xfa, 0x74, 0x62, 0x1e, 0x8b, 0xcc, 0x8e, 0xd, - 0xce, 0xb4, 0xe7, 0x12, 0x36, 0x43, 0x76, 0xfe, 0x2b, 0x2, 0x3, 0xfa, 0x9}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x59, 0xb, 0x3e, 0x35, 0x42, 0x6d, 0xe3}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x8a, 0xcb}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "]\153\135\145US\141\240H\229\241g\ETX", _willMsg = "S\147\227\222\204\171\172K", _willProps = -// [PropServerKeepAlive 1944,PropReasonString -// "0\239\168\&5<\ETX\140\235I\244\173\138z\ESC{\129\197\207\143\220M\195\150\a\155oC",PropPayloadFormatIndicator -// 130,PropMessageExpiryInterval 8409,PropWildcardSubscriptionAvailable 23,PropWillDelayInterval -// 14617,PropCorrelationData -// "\167t\142\149G\RS#\158\136\243\220Ok\210\DC4\205\155(\137\n\239\141&\215<\174\169",PropRetainAvailable -// 166,PropContentType -// "5\FS\177TN@\249.\151b\245\216&\147\128\212I$\236\v\238\221\237\200\204\212\149\NUL\ETB\154\155\209\134\224f\224M\176\ETX\254\FS\252\150",PropMessageExpiryInterval -// 11960,PropRequestResponseInformation 48,PropMaximumQoS 34,PropRetainAvailable 88,PropWildcardSubscriptionAvailable -// 149]}), _cleanSession = True, _keepAlive = 6922, _connID = "\132\211\DC4\175\183\DC4\ETB\170Y", _properties = []} -TEST(Connect5QCTest, Encode36) { - uint8_t pkt[] = { - 0x10, 0x91, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x1b, 0xa, 0x0, 0x0, 0x9, 0x84, 0xd3, 0x14, - 0xaf, 0xb7, 0x14, 0x17, 0xaa, 0x59, 0xbb, 0x1, 0x8, 0x0, 0x8, 0x67, 0x4, 0xe4, 0xda, 0x51, 0x7, 0xa3, 0x2b, - 0x11, 0x0, 0x0, 0x39, 0x93, 0x1c, 0x0, 0x11, 0x54, 0xf9, 0x58, 0xd5, 0xf4, 0xb1, 0xfa, 0xc9, 0x18, 0x24, 0x12, - 0x16, 0x75, 0x23, 0xc7, 0x50, 0xeb, 0x24, 0xbb, 0x1c, 0x0, 0x2, 0xe9, 0x12, 0x25, 0xb4, 0x24, 0x97, 0x13, 0x52, - 0xaa, 0x1f, 0x0, 0x12, 0x93, 0xec, 0xd9, 0xd7, 0x2f, 0x14, 0xbc, 0x4b, 0xa9, 0x61, 0xa1, 0x90, 0x85, 0xaa, 0x1b, - 0xe3, 0x65, 0x43, 0x22, 0x53, 0x96, 0x17, 0x28, 0x25, 0xdb, 0x27, 0x0, 0x0, 0x66, 0xa7, 0x21, 0x44, 0x75, 0x21, - 0x7e, 0xbb, 0x2a, 0x54, 0x25, 0x7d, 0x2, 0x0, 0x0, 0x2d, 0xae, 0x3, 0x0, 0x1c, 0xc1, 0x1b, 0x9c, 0x4f, 0x15, - 0x15, 0xd7, 0x3b, 0x81, 0xb7, 0x31, 0x6, 0xf, 0xbf, 0x51, 0x74, 0x33, 0x3f, 0xc1, 0x96, 0x45, 0x99, 0xd, 0x3a, - 0x84, 0x2a, 0x1b, 0x24, 0x2a, 0xf, 0xb, 0x2, 0x2, 0x0, 0x0, 0x1c, 0x72, 0x23, 0x1, 0x32, 0x15, 0x0, 0x1e, - 0xfa, 0x57, 0x39, 0x1d, 0x1b, 0xfc, 0xfb, 0x86, 0x3e, 0xed, 0xc8, 0xcc, 0xd4, 0x95, 0x0, 0x17, 0x9a, 0x9b, 0xd1, - 0x86, 0xe0, 0x66, 0xe0, 0x4d, 0xb0, 0x3, 0xfe, 0x1c, 0xfc, 0x96, 0x2, 0x0, 0x0, 0x2e, 0xb8, 0x19, 0x30, 0x24, - 0x22, 0x25, 0x58, 0x28, 0x95, 0x0, 0x3, 0xf5, 0xdd, 0x6f, 0x0, 0x1d, 0xeb, 0x1, 0x2c, 0x6e, 0x51, 0x26, 0x11, - 0x62, 0x4a, 0x14, 0xb1, 0xb2, 0xc2, 0xb5, 0xef, 0xf3, 0x49, 0xa7, 0xe8, 0x96, 0xb3, 0x7c, 0x5e, 0xb9, 0xf1, 0xa4, - 0x57, 0x76, 0xd3, 0x0, 0x9, 0x26, 0x3, 0x11, 0x74, 0x4a, 0xcc, 0xd3, 0x51, 0x60, 0x0, 0xd, 0x80, 0x63, 0xbf, - 0x2e, 0xa2, 0xfd, 0x1d, 0xa2, 0x71, 0x82, 0x8a, 0xbc, 0x59}; - - uint8_t buf[286] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x67, 0x4, 0xe4, 0xda, 0x51, 0x7, 0xa3, 0x2b}; - uint8_t byteswillprops1[] = {0x54, 0xf9, 0x58, 0xd5, 0xf4, 0xb1, 0xfa, 0xc9, 0x18, - 0x24, 0x12, 0x16, 0x75, 0x23, 0xc7, 0x50, 0xeb}; - uint8_t byteswillprops2[] = {0xe9, 0x12}; - uint8_t byteswillprops3[] = {0x93, 0xec, 0xd9, 0xd7, 0x2f, 0x14, 0xbc, 0x4b, 0xa9, - 0x61, 0xa1, 0x90, 0x85, 0xaa, 0x1b, 0xe3, 0x65, 0x43}; - uint8_t byteswillprops4[] = {0xc1, 0x1b, 0x9c, 0x4f, 0x15, 0x15, 0xd7, 0x3b, 0x81, 0xb7, 0x31, 0x6, 0xf, 0xbf, - 0x51, 0x74, 0x33, 0x3f, 0xc1, 0x96, 0x45, 0x99, 0xd, 0x3a, 0x84, 0x2a, 0x1b, 0x24}; - uint8_t byteswillprops5[] = {0xfa, 0x57, 0x39, 0x1d, 0x1b, 0xfc, 0xfb, 0x86, 0x3e, 0xed, - 0xc8, 0xcc, 0xd4, 0x95, 0x0, 0x17, 0x9a, 0x9b, 0xd1, 0x86, - 0xe0, 0x66, 0xe0, 0x4d, 0xb0, 0x3, 0xfe, 0x1c, 0xfc, 0x96}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14739}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21162}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21398}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26279}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17525}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32443}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11694}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7282}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 306}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11960}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 149}}, - }; - - lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf5, 0xdd, 0x6f}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xeb, 0x1, 0x2c, 0x6e, 0x51, 0x26, 0x11, 0x62, 0x4a, 0x14, - 0xb1, 0xb2, 0xc2, 0xb5, 0xef, 0xf3, 0x49, 0xa7, 0xe8, 0x96, - 0xb3, 0x7c, 0x5e, 0xb9, 0xf1, 0xa4, 0x57, 0x76, 0xd3}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 6922; - uint8_t client_id_bytes[] = {0x84, 0xd3, 0x14, 0xaf, 0xb7, 0x14, 0x17, 0xaa, 0x59}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x26, 0x3, 0x11, 0x74, 0x4a, 0xcc, 0xd3, 0x51, 0x60}; - lwmqtt_string_t username = {9, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x80, 0x63, 0xbf, 0x2e, 0xa2, 0xfd, 0x1d, 0xa2, 0x71, 0x82, 0x8a, 0xbc, 0x59}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\169\"\142.S\145\159\133VvX<\209\161", _password = Nothing, _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\136Rv", _willMsg = -// "v\SUB58p+]s\v\SYN\DC3!\220\199\192'K\140d\n@\133\188\CAN\174\209\SYNK", _willProps = [PropAuthenticationMethod -// "\136\131\t\134\DEL\b\146\224)H\168\SOH^\ACK\138\191\f",PropResponseInformation -// "\n\"4Y\CAN\144r\DC3\249;\194\155\183\211\188\139\189\195\212\198\218.",PropResponseInformation -// "\239\242p\150\NUL\ve\FS\129\248&K<\DEL\155&6\218\155u\200\233v\195\157S",PropResponseInformation -// "GsM\185DI&\220,\199\225}\232\210\230",PropServerKeepAlive 5331,PropMessageExpiryInterval -// 8248,PropSubscriptionIdentifierAvailable 138,PropTopicAlias 10808,PropWillDelayInterval 18139,PropServerReference -// "\245\191P\171\128W\137\254\153\201\a\144@;`\STXD\192}\240\174A\a\140\ETXK\195\196",PropContentType -// "2\227\200\218\239@\146\CANu\165C\218C\160\213*\248A\184:2\137 \EM\201\177]\241\133)",PropMessageExpiryInterval -// 20966,PropTopicAlias 3704,PropAuthenticationMethod -// "\FS\SYN;-\219^\ACK\tN\200\227\r\198Z\139\178*.\166\238",PropReasonString "s\204",PropUserProperty "\SI\225\229\135" -// "\169\r9\219!\164W\149w]w\160\151^",PropRequestResponseInformation 226,PropUserProperty -// "\199$\141b\191m\222\150\234\&9p\FS2A\EM\207\\\187\STX\244Y!?L\v" "\255\153\214"]}), _cleanSession = False, -// _keepAlive = 25116, _connID = "\SOR\"\166}\168\197\211\153\NAK\249\165\138\211", _properties = -// [PropMessageExpiryInterval 15040]} -TEST(Connect5QCTest, Encode37) { - uint8_t pkt[] = { - 0x10, 0xe1, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x94, 0x62, 0x1c, 0x5, 0x2, 0x0, 0x0, 0x3a, 0xc0, - 0x0, 0xe, 0xe, 0x52, 0x22, 0xa6, 0x7d, 0xa8, 0xc5, 0xd3, 0x99, 0x15, 0xf9, 0xa5, 0x8a, 0xd3, 0x8c, 0x2, 0x15, - 0x0, 0x11, 0x88, 0x83, 0x9, 0x86, 0x7f, 0x8, 0x92, 0xe0, 0x29, 0x48, 0xa8, 0x1, 0x5e, 0x6, 0x8a, 0xbf, 0xc, - 0x1a, 0x0, 0x16, 0xa, 0x22, 0x34, 0x59, 0x18, 0x90, 0x72, 0x13, 0xf9, 0x3b, 0xc2, 0x9b, 0xb7, 0xd3, 0xbc, 0x8b, - 0xbd, 0xc3, 0xd4, 0xc6, 0xda, 0x2e, 0x1a, 0x0, 0x1a, 0x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 0x26, 0x0, 0x19, 0xc7, 0x24, 0x8d, 0x62, 0xbf, 0x6d, 0xde, 0x96, 0xea, 0x39, - 0x70, 0x1c, 0x32, 0x41, 0x19, 0xcf, 0x5c, 0xbb, 0x2, 0xf4, 0x59, 0x21, 0x3f, 0x4c, 0xb, 0x0, 0x3, 0xff, 0x99, - 0xd6, 0x0, 0x3, 0x88, 0x52, 0x76, 0x0, 0x1c, 0x76, 0x1a, 0x35, 0x38, 0x70, 0x2b, 0x5d, 0x73, 0xb, 0x16, 0x13, - 0x21, 0xdc, 0xc7, 0xc0, 0x27, 0x4b, 0x8c, 0x64, 0xa, 0x40, 0x85, 0xbc, 0x18, 0xae, 0xd1, 0x16, 0x4b, 0x0, 0xe, - 0xa9, 0x22, 0x8e, 0x2e, 0x53, 0x91, 0x9f, 0x85, 0x56, 0x76, 0x58, 0x3c, 0xd1, 0xa1}; - - uint8_t buf[366] = {0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15040}}, - }; - - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x88, 0x83, 0x9, 0x86, 0x7f, 0x8, 0x92, 0xe0, 0x29, - 0x48, 0xa8, 0x1, 0x5e, 0x6, 0x8a, 0xbf, 0xc}; - uint8_t byteswillprops1[] = {0xa, 0x22, 0x34, 0x59, 0x18, 0x90, 0x72, 0x13, 0xf9, 0x3b, 0xc2, - 0x9b, 0xb7, 0xd3, 0xbc, 0x8b, 0xbd, 0xc3, 0xd4, 0xc6, 0xda, 0x2e}; - uint8_t byteswillprops2[] = {0xef, 0xf2, 0x70, 0x96, 0x0, 0xb, 0x65, 0x1c, 0x81, 0xf8, 0x26, 0x4b, 0x3c, - 0x7f, 0x9b, 0x26, 0x36, 0xda, 0x9b, 0x75, 0xc8, 0xe9, 0x76, 0xc3, 0x9d, 0x53}; - uint8_t byteswillprops3[] = {0x47, 0x73, 0x4d, 0xb9, 0x44, 0x49, 0x26, 0xdc, - 0x2c, 0xc7, 0xe1, 0x7d, 0xe8, 0xd2, 0xe6}; - uint8_t byteswillprops4[] = {0xf5, 0xbf, 0x50, 0xab, 0x80, 0x57, 0x89, 0xfe, 0x99, 0xc9, 0x7, 0x90, 0x40, 0x3b, - 0x60, 0x2, 0x44, 0xc0, 0x7d, 0xf0, 0xae, 0x41, 0x7, 0x8c, 0x3, 0x4b, 0xc3, 0xc4}; - uint8_t byteswillprops5[] = {0x32, 0xe3, 0xc8, 0xda, 0xef, 0x40, 0x92, 0x18, 0x75, 0xa5, - 0x43, 0xda, 0x43, 0xa0, 0xd5, 0x2a, 0xf8, 0x41, 0xb8, 0x3a, - 0x32, 0x89, 0x20, 0x19, 0xc9, 0xb1, 0x5d, 0xf1, 0x85, 0x29}; - uint8_t byteswillprops6[] = {0x1c, 0x16, 0x3b, 0x2d, 0xdb, 0x5e, 0x6, 0x9, 0x4e, 0xc8, - 0xe3, 0xd, 0xc6, 0x5a, 0x8b, 0xb2, 0x2a, 0x2e, 0xa6, 0xee}; - uint8_t byteswillprops7[] = {0x73, 0xcc}; - uint8_t byteswillprops9[] = {0xa9, 0xd, 0x39, 0xdb, 0x21, 0xa4, 0x57, 0x95, 0x77, 0x5d, 0x77, 0xa0, 0x97, 0x5e}; - uint8_t byteswillprops8[] = {0xf, 0xe1, 0xe5, 0x87}; - uint8_t byteswillprops11[] = {0xff, 0x99, 0xd6}; - uint8_t byteswillprops10[] = {0xc7, 0x24, 0x8d, 0x62, 0xbf, 0x6d, 0xde, 0x96, 0xea, 0x39, 0x70, 0x1c, 0x32, - 0x41, 0x19, 0xcf, 0x5c, 0xbb, 0x2, 0xf4, 0x59, 0x21, 0x3f, 0x4c, 0xb}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5331}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8248}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10808}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18139}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20966}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3704}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {4, (char*)&byteswillprops8}, .v = {14, (char*)&byteswillprops9}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {25, (char*)&byteswillprops10}, .v = {3, (char*)&byteswillprops11}}}}, - }; - - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x88, 0x52, 0x76}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x76, 0x1a, 0x35, 0x38, 0x70, 0x2b, 0x5d, 0x73, 0xb, 0x16, 0x13, 0x21, 0xdc, 0xc7, - 0xc0, 0x27, 0x4b, 0x8c, 0x64, 0xa, 0x40, 0x85, 0xbc, 0x18, 0xae, 0xd1, 0x16, 0x4b}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 25116; - uint8_t client_id_bytes[] = {0xe, 0x52, 0x22, 0xa6, 0x7d, 0xa8, 0xc5, 0xd3, 0x99, 0x15, 0xf9, 0xa5, 0x8a, 0xd3}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa9, 0x22, 0x8e, 0x2e, 0x53, 0x91, 0x9f, 0x85, 0x56, 0x76, 0x58, 0x3c, 0xd1, 0xa1}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "j3`=\194\212\200O\134\155v\212", _password = Just "\SI\FS=Y\232J\158\196\230\170", -// _lastWill = Nothing, _cleanSession = True, _keepAlive = 1881, _connID = "c\207n(N\155H\154,\158u\205*\f\182\SO", -// _properties = [PropSharedSubscriptionAvailable 242,PropMaximumPacketSize 12669,PropCorrelationData -// "\171&qocN\205\158\212\&9\DC1\187\DLE\193\132D\241\&6\140",PropResponseTopic -// "\164p\153\DEL\159\222]~\r\239\227\248~#\212\195",PropReasonString -// "\236\166\EOT\r\251\153,\128\229\206k8>\227\CAN\201Rv\181\174\225\138EL\128;wLi",PropCorrelationData -// "6\234\236G\GS-w\210\ENQLG\STX\243\197",PropTopicAliasMaximum 9001,PropAuthenticationMethod -// "/\174!\180\165x\158S\247\165@3\253\249\\}\SYN\208\\\"\139\167\192\204\225)\163v",PropAuthenticationData -// "E\174\255`s\170\198\249A#\ACK\206J\ACK\STX\CANC6U\229\152\SI\CANfoe\\\139\254k",PropRequestResponseInformation -// 139,PropRequestResponseInformation 12,PropMessageExpiryInterval 29570,PropAuthenticationMethod -// "\193\ACK\198\207v\195\144w\162\191\DC4\176\142PZ\203\192o\EOTL\ETX\128N\155\175\174o(\197",PropUserProperty -// "\254\141k,`q\209e\DC4\"K\253\224Z\SOH'\246" -// "\164\204\139\NUL>Vr\166&\SYN\192\150r\191\141",PropSessionExpiryInterval 28694,PropAuthenticationMethod -// "\174%\178\170H\191\151b3X\219\219\194\140\ESC\197I\136\229.FO\198J",PropSharedSubscriptionAvailable -// 198,PropAuthenticationMethod "\144\145GA;\DC4{\198\221\129\253e \172\206\v\"\146v23\178\203qp"]} -TEST(Connect5QCTest, Encode38) { - uint8_t pkt[] = { - 0x10, 0xe8, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x7, 0x59, 0xb0, 0x2, 0x2a, 0xf2, 0x27, 0x0, - 0x0, 0x31, 0x7d, 0x9, 0x0, 0x13, 0xab, 0x26, 0x71, 0x6f, 0x63, 0x4e, 0xcd, 0x9e, 0xd4, 0x39, 0x11, 0xbb, 0x10, - 0xc1, 0x84, 0x44, 0xf1, 0x36, 0x8c, 0x8, 0x0, 0x10, 0xa4, 0x70, 0x99, 0x7f, 0x9f, 0xde, 0x5d, 0x7e, 0xd, 0xef, - 0xe3, 0xf8, 0x7e, 0x23, 0xd4, 0xc3, 0x1f, 0x0, 0x1d, 0xec, 0xa6, 0x4, 0xd, 0xfb, 0x99, 0x2c, 0x80, 0xe5, 0xce, - 0x6b, 0x38, 0x3e, 0xe3, 0x18, 0xc9, 0x52, 0x76, 0xb5, 0xae, 0xe1, 0x8a, 0x45, 0x4c, 0x80, 0x3b, 0x77, 0x4c, 0x69, - 0x9, 0x0, 0xe, 0x36, 0xea, 0xec, 0x47, 0x1d, 0x2d, 0x77, 0xd2, 0x5, 0x4c, 0x47, 0x2, 0xf3, 0xc5, 0x22, 0x23, - 0x29, 0x15, 0x0, 0x1c, 0x2f, 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d, 0x65, 0x20, 0xac, 0xce, 0xb, 0x22, 0x92, 0x76, 0x32, 0x33, 0xb2, 0xcb, 0x71, 0x70, 0x0, 0x10, 0x63, 0xcf, - 0x6e, 0x28, 0x4e, 0x9b, 0x48, 0x9a, 0x2c, 0x9e, 0x75, 0xcd, 0x2a, 0xc, 0xb6, 0xe, 0x0, 0xc, 0x6a, 0x33, 0x60, - 0x3d, 0xc2, 0xd4, 0xc8, 0x4f, 0x86, 0x9b, 0x76, 0xd4, 0x0, 0xa, 0xf, 0x1c, 0x3d, 0x59, 0xe8, 0x4a, 0x9e, 0xc4, - 0xe6, 0xaa}; - - uint8_t buf[373] = {0}; - - uint8_t bytesprops0[] = {0xab, 0x26, 0x71, 0x6f, 0x63, 0x4e, 0xcd, 0x9e, 0xd4, 0x39, - 0x11, 0xbb, 0x10, 0xc1, 0x84, 0x44, 0xf1, 0x36, 0x8c}; - uint8_t bytesprops1[] = {0xa4, 0x70, 0x99, 0x7f, 0x9f, 0xde, 0x5d, 0x7e, - 0xd, 0xef, 0xe3, 0xf8, 0x7e, 0x23, 0xd4, 0xc3}; - uint8_t bytesprops2[] = {0xec, 0xa6, 0x4, 0xd, 0xfb, 0x99, 0x2c, 0x80, 0xe5, 0xce, 0x6b, 0x38, 0x3e, 0xe3, 0x18, - 0xc9, 0x52, 0x76, 0xb5, 0xae, 0xe1, 0x8a, 0x45, 0x4c, 0x80, 0x3b, 0x77, 0x4c, 0x69}; - uint8_t bytesprops3[] = {0x36, 0xea, 0xec, 0x47, 0x1d, 0x2d, 0x77, 0xd2, 0x5, 0x4c, 0x47, 0x2, 0xf3, 0xc5}; - uint8_t bytesprops4[] = {0x2f, 0xae, 0x21, 0xb4, 0xa5, 0x78, 0x9e, 0x53, 0xf7, 0xa5, 0x40, 0x33, 0xfd, 0xf9, - 0x5c, 0x7d, 0x16, 0xd0, 0x5c, 0x22, 0x8b, 0xa7, 0xc0, 0xcc, 0xe1, 0x29, 0xa3, 0x76}; - uint8_t bytesprops5[] = {0x45, 0xae, 0xff, 0x60, 0x73, 0xaa, 0xc6, 0xf9, 0x41, 0x23, 0x6, 0xce, 0x4a, 0x6, 0x2, - 0x18, 0x43, 0x36, 0x55, 0xe5, 0x98, 0xf, 0x18, 0x66, 0x6f, 0x65, 0x5c, 0x8b, 0xfe, 0x6b}; - uint8_t bytesprops6[] = {0xc1, 0x6, 0xc6, 0xcf, 0x76, 0xc3, 0x90, 0x77, 0xa2, 0xbf, 0x14, 0xb0, 0x8e, 0x50, 0x5a, - 0xcb, 0xc0, 0x6f, 0x4, 0x4c, 0x3, 0x80, 0x4e, 0x9b, 0xaf, 0xae, 0x6f, 0x28, 0xc5}; - uint8_t bytesprops8[] = {0xa4, 0xcc, 0x8b, 0x0, 0x3e, 0x56, 0x72, 0xa6, 0x26, 0x16, 0xc0, 0x96, 0x72, 0xbf, 0x8d}; - uint8_t bytesprops7[] = {0xfe, 0x8d, 0x6b, 0x2c, 0x60, 0x71, 0xd1, 0x65, 0x14, - 0x22, 0x4b, 0xfd, 0xe0, 0x5a, 0x1, 0x27, 0xf6}; - uint8_t bytesprops9[] = {0xae, 0x25, 0xb2, 0xaa, 0x48, 0xbf, 0x97, 0x62, 0x33, 0x58, 0xdb, 0xdb, - 0xc2, 0x8c, 0x1b, 0xc5, 0x49, 0x88, 0xe5, 0x2e, 0x46, 0x4f, 0xc6, 0x4a}; - uint8_t bytesprops10[] = {0x90, 0x91, 0x47, 0x41, 0x3b, 0x14, 0x7b, 0xc6, 0xdd, 0x81, 0xfd, 0x65, 0x20, - 0xac, 0xce, 0xb, 0x22, 0x92, 0x76, 0x32, 0x33, 0xb2, 0xcb, 0x71, 0x70}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12669}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9001}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29570}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops7}, .v = {15, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28694}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops10}}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1881; - uint8_t client_id_bytes[] = {0x63, 0xcf, 0x6e, 0x28, 0x4e, 0x9b, 0x48, 0x9a, - 0x2c, 0x9e, 0x75, 0xcd, 0x2a, 0xc, 0xb6, 0xe}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x6a, 0x33, 0x60, 0x3d, 0xc2, 0xd4, 0xc8, 0x4f, 0x86, 0x9b, 0x76, 0xd4}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xf, 0x1c, 0x3d, 0x59, 0xe8, 0x4a, 0x9e, 0xc4, 0xe6, 0xaa}; - lwmqtt_string_t password = {10, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\ETXp\147\149\&7", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS1, _willTopic = "\218G\228", _willMsg = -// "\133\141;\199\135\145\&1\NAK\215\162H\224\199q\ft\156F\STX\178\162\152\147f\SI\229\248", _willProps = -// [PropAuthenticationMethod "\"G\166\181(C\175\&1\210\"\158Y\SYN\ETB\ESCa\156\190\US\245-o\227",PropServerReference -// ">\159\208\132\v\243N\233\179o,*B\148\210~(\192\DC4\255\SOH\244\149\133\ETB:\187m>",PropServerKeepAlive -// 2146,PropMessageExpiryInterval 25696,PropSessionExpiryInterval 27600,PropAuthenticationData -// "\130\CAN\165P/\148\165\149\&3\192\143\148n>$\141\242\224\231\&0\145{\230f\RS\178\189",PropMessageExpiryInterval -// 31786,PropRetainAvailable 93,PropCorrelationData "\198",PropSubscriptionIdentifierAvailable -// 106,PropPayloadFormatIndicator 124,PropRetainAvailable 138,PropWillDelayInterval 27628,PropRequestProblemInformation -// 210]}), _cleanSession = False, _keepAlive = 3338, _connID = -// "\244\164\&6\SYN\146\249\SOHR|b\175e~\146x\233H\240C\208\249M\233v\234\194\203\189\230\222", _properties = []} -TEST(Connect5QCTest, Encode39) { - uint8_t pkt[] = {0x10, 0xd2, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xac, 0xd, 0xa, 0x0, 0x0, 0x1e, 0xf4, - 0xa4, 0x36, 0x16, 0x92, 0xf9, 0x1, 0x52, 0x7c, 0x62, 0xaf, 0x65, 0x7e, 0x92, 0x78, 0xe9, 0x48, 0xf0, - 0x43, 0xd0, 0xf9, 0x4d, 0xe9, 0x76, 0xea, 0xc2, 0xcb, 0xbd, 0xe6, 0xde, 0x7d, 0x15, 0x0, 0x17, 0x22, - 0x47, 0xa6, 0xb5, 0x28, 0x43, 0xaf, 0x31, 0xd2, 0x22, 0x9e, 0x59, 0x16, 0x17, 0x1b, 0x61, 0x9c, 0xbe, - 0x1f, 0xf5, 0x2d, 0x6f, 0xe3, 0x1c, 0x0, 0x1d, 0x3e, 0x9f, 0xd0, 0x84, 0xb, 0xf3, 0x4e, 0xe9, 0xb3, - 0x6f, 0x2c, 0x2a, 0x42, 0x94, 0xd2, 0x7e, 0x28, 0xc0, 0x14, 0xff, 0x1, 0xf4, 0x95, 0x85, 0x17, 0x3a, - 0xbb, 0x6d, 0x3e, 0x13, 0x8, 0x62, 0x2, 0x0, 0x0, 0x64, 0x60, 0x11, 0x0, 0x0, 0x6b, 0xd0, 0x16, - 0x0, 0x1b, 0x82, 0x18, 0xa5, 0x50, 0x2f, 0x94, 0xa5, 0x95, 0x33, 0xc0, 0x8f, 0x94, 0x6e, 0x3e, 0x24, - 0x8d, 0xf2, 0xe0, 0xe7, 0x30, 0x91, 0x7b, 0xe6, 0x66, 0x1e, 0xb2, 0xbd, 0x2, 0x0, 0x0, 0x7c, 0x2a, - 0x25, 0x5d, 0x9, 0x0, 0x1, 0xc6, 0x29, 0x6a, 0x1, 0x7c, 0x25, 0x8a, 0x18, 0x0, 0x0, 0x6b, 0xec, - 0x17, 0xd2, 0x0, 0x3, 0xda, 0x47, 0xe4, 0x0, 0x1b, 0x85, 0x8d, 0x3b, 0xc7, 0x87, 0x91, 0x31, 0x15, - 0xd7, 0xa2, 0x48, 0xe0, 0xc7, 0x71, 0xc, 0x74, 0x9c, 0x46, 0x2, 0xb2, 0xa2, 0x98, 0x93, 0x66, 0xf, - 0xe5, 0xf8, 0x0, 0x5, 0x3, 0x70, 0x93, 0x95, 0x37}; - - uint8_t buf[223] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x22, 0x47, 0xa6, 0xb5, 0x28, 0x43, 0xaf, 0x31, 0xd2, 0x22, 0x9e, 0x59, - 0x16, 0x17, 0x1b, 0x61, 0x9c, 0xbe, 0x1f, 0xf5, 0x2d, 0x6f, 0xe3}; - uint8_t byteswillprops1[] = {0x3e, 0x9f, 0xd0, 0x84, 0xb, 0xf3, 0x4e, 0xe9, 0xb3, 0x6f, 0x2c, 0x2a, 0x42, 0x94, 0xd2, - 0x7e, 0x28, 0xc0, 0x14, 0xff, 0x1, 0xf4, 0x95, 0x85, 0x17, 0x3a, 0xbb, 0x6d, 0x3e}; - uint8_t byteswillprops2[] = {0x82, 0x18, 0xa5, 0x50, 0x2f, 0x94, 0xa5, 0x95, 0x33, 0xc0, 0x8f, 0x94, 0x6e, 0x3e, - 0x24, 0x8d, 0xf2, 0xe0, 0xe7, 0x30, 0x91, 0x7b, 0xe6, 0x66, 0x1e, 0xb2, 0xbd}; - uint8_t byteswillprops3[] = {0xc6}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2146}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25696}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27600}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31786}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27628}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, - }; - - lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xda, 0x47, 0xe4}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x85, 0x8d, 0x3b, 0xc7, 0x87, 0x91, 0x31, 0x15, 0xd7, 0xa2, 0x48, 0xe0, 0xc7, 0x71, - 0xc, 0x74, 0x9c, 0x46, 0x2, 0xb2, 0xa2, 0x98, 0x93, 0x66, 0xf, 0xe5, 0xf8}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3338; - uint8_t client_id_bytes[] = {0xf4, 0xa4, 0x36, 0x16, 0x92, 0xf9, 0x1, 0x52, 0x7c, 0x62, - 0xaf, 0x65, 0x7e, 0x92, 0x78, 0xe9, 0x48, 0xf0, 0x43, 0xd0, - 0xf9, 0x4d, 0xe9, 0x76, 0xea, 0xc2, 0xcb, 0xbd, 0xe6, 0xde}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x3, 0x70, 0x93, 0x95, 0x37}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "%s%1", _password = Just "JZ\188v\194\151\206\232\FS8\227", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "<3\134\&3\210\ai\247\172", _willMsg = -// "\195Z\ACK\163\170\202", _willProps = [PropCorrelationData "\a\217q",PropAuthenticationData -// "/\157\198\206R\DC4\242S\164@\164\228A",PropMaximumQoS 158,PropRequestResponseInformation -// 204,PropWildcardSubscriptionAvailable 143,PropSharedSubscriptionAvailable 230,PropAssignedClientIdentifier -// "\207\249\164\SYN3\EM'\185\247\252\153\ESC\153\229\218\157\aiSb",PropAuthenticationMethod -// "\239\ETB",PropSubscriptionIdentifier 19,PropResponseTopic -// "q\197\&33\137\f\201\253T~\229i.\147\SUB\221\170",PropReceiveMaximum 4184,PropReceiveMaximum -// 15100,PropRequestProblemInformation 182,PropPayloadFormatIndicator 133,PropAssignedClientIdentifier -// "\DC1\152C\221\192\182\USj\134>4\191\160\210}\171",PropSubscriptionIdentifier 4,PropSharedSubscriptionAvailable -// 15,PropContentType "a\160\237w\210k"]}), _cleanSession = False, _keepAlive = 21786, _connID = -// "$\218\249\238\250,\NUL\129\DC2\162H\219_\168K\DC1\212\231\195p\167\157\177D\149", _properties = []} -TEST(Connect5QCTest, Encode40) { - uint8_t pkt[] = {0x10, 0xc7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x55, 0x1a, 0x0, 0x0, 0x19, 0x24, - 0xda, 0xf9, 0xee, 0xfa, 0x2c, 0x0, 0x81, 0x12, 0xa2, 0x48, 0xdb, 0x5f, 0xa8, 0x4b, 0x11, 0xd4, 0xe7, - 0xc3, 0x70, 0xa7, 0x9d, 0xb1, 0x44, 0x95, 0x7a, 0x9, 0x0, 0x3, 0x7, 0xd9, 0x71, 0x16, 0x0, 0xd, - 0x2f, 0x9d, 0xc6, 0xce, 0x52, 0x14, 0xf2, 0x53, 0xa4, 0x40, 0xa4, 0xe4, 0x41, 0x24, 0x9e, 0x19, 0xcc, - 0x28, 0x8f, 0x2a, 0xe6, 0x12, 0x0, 0x14, 0xcf, 0xf9, 0xa4, 0x16, 0x33, 0x19, 0x27, 0xb9, 0xf7, 0xfc, - 0x99, 0x1b, 0x99, 0xe5, 0xda, 0x9d, 0x7, 0x69, 0x53, 0x62, 0x15, 0x0, 0x2, 0xef, 0x17, 0xb, 0x13, - 0x8, 0x0, 0x11, 0x71, 0xc5, 0x33, 0x33, 0x89, 0xc, 0xc9, 0xfd, 0x54, 0x7e, 0xe5, 0x69, 0x2e, 0x93, - 0x1a, 0xdd, 0xaa, 0x21, 0x10, 0x58, 0x21, 0x3a, 0xfc, 0x17, 0xb6, 0x1, 0x85, 0x12, 0x0, 0x10, 0x11, - 0x98, 0x43, 0xdd, 0xc0, 0xb6, 0x1f, 0x6a, 0x86, 0x3e, 0x34, 0xbf, 0xa0, 0xd2, 0x7d, 0xab, 0xb, 0x4, - 0x2a, 0xf, 0x3, 0x0, 0x6, 0x61, 0xa0, 0xed, 0x77, 0xd2, 0x6b, 0x0, 0x9, 0x3c, 0x33, 0x86, 0x33, - 0xd2, 0x7, 0x69, 0xf7, 0xac, 0x0, 0x6, 0xc3, 0x5a, 0x6, 0xa3, 0xaa, 0xca, 0x0, 0x4, 0x25, 0x73, - 0x25, 0x31, 0x0, 0xb, 0x4a, 0x5a, 0xbc, 0x76, 0xc2, 0x97, 0xce, 0xe8, 0x1c, 0x38, 0xe3}; - - uint8_t buf[212] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x7, 0xd9, 0x71}; - uint8_t byteswillprops1[] = {0x2f, 0x9d, 0xc6, 0xce, 0x52, 0x14, 0xf2, 0x53, 0xa4, 0x40, 0xa4, 0xe4, 0x41}; - uint8_t byteswillprops2[] = {0xcf, 0xf9, 0xa4, 0x16, 0x33, 0x19, 0x27, 0xb9, 0xf7, 0xfc, - 0x99, 0x1b, 0x99, 0xe5, 0xda, 0x9d, 0x7, 0x69, 0x53, 0x62}; - uint8_t byteswillprops3[] = {0xef, 0x17}; - uint8_t byteswillprops4[] = {0x71, 0xc5, 0x33, 0x33, 0x89, 0xc, 0xc9, 0xfd, 0x54, - 0x7e, 0xe5, 0x69, 0x2e, 0x93, 0x1a, 0xdd, 0xaa}; - uint8_t byteswillprops5[] = {0x11, 0x98, 0x43, 0xdd, 0xc0, 0xb6, 0x1f, 0x6a, - 0x86, 0x3e, 0x34, 0xbf, 0xa0, 0xd2, 0x7d, 0xab}; - uint8_t byteswillprops6[] = {0x61, 0xa0, 0xed, 0x77, 0xd2, 0x6b}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4184}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15100}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops6}}}, - }; - - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3c, 0x33, 0x86, 0x33, 0xd2, 0x7, 0x69, 0xf7, 0xac}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc3, 0x5a, 0x6, 0xa3, 0xaa, 0xca}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 21786; - uint8_t client_id_bytes[] = {0x24, 0xda, 0xf9, 0xee, 0xfa, 0x2c, 0x0, 0x81, 0x12, 0xa2, 0x48, 0xdb, 0x5f, - 0xa8, 0x4b, 0x11, 0xd4, 0xe7, 0xc3, 0x70, 0xa7, 0x9d, 0xb1, 0x44, 0x95}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x25, 0x73, 0x25, 0x31}; - lwmqtt_string_t username = {4, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x4a, 0x5a, 0xbc, 0x76, 0xc2, 0x97, 0xce, 0xe8, 0x1c, 0x38, 0xe3}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\"\192-\143\173\214\ETXL\182X\SOHQ", _password = Just -// "\210\SI4\163\NUL>\DC1}2x\SOHq\134\ETX\245\&0\169\180", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS1, _willTopic = "\227\NAK\133\240\173\&0\r", _willMsg = "\197 \US\DEL\147\243\248\SI9\198\187\\\219\146\152\229\214\233", _lastWill = -// Nothing, _cleanSession = False, _keepAlive = 30703, _connID = "3\193)\173", _properties = [PropMaximumQoS -// 61,PropWildcardSubscriptionAvailable 121,PropResponseInformation "x\147;\224\240\232&\186",PropMessageExpiryInterval -// 8287,PropSharedSubscriptionAvailable 248,PropRequestResponseInformation 39,PropMessageExpiryInterval -// 18350,PropAssignedClientIdentifier "\192[\a",PropServerKeepAlive 6307,PropServerKeepAlive 24378,PropTopicAlias -// 5418,PropCorrelationData "\205\252\196\192\199P\163\199{xH\165e\229\152\141\143\DLE\148",PropAuthenticationMethod -// "\ETXeI\135\250\180",PropReasonString "N)\DC1|\218X>\247p $k\174a\STX\130\227{\178\RSJ\128",PropUserProperty -// "\216\157\182\181\250\DC1/\201L\169l\148\SOu\141\&1\FS)\229\253\150%\141" -// "I\228\DC4j\246]&\233\194\164",PropWillDelayInterval 15403,PropWildcardSubscriptionAvailable -// 171,PropResponseInformation "n\DC3\SOr\179",PropWillDelayInterval 4719,PropPayloadFormatIndicator -// 90,PropAssignedClientIdentifier "\133P"]} -TEST(Connect5QCTest, Encode45) { - uint8_t pkt[] = {0x10, 0xb7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x77, 0xef, 0xa5, 0x1, 0x24, 0x3d, - 0x28, 0x79, 0x1a, 0x0, 0x8, 0x78, 0x93, 0x3b, 0xe0, 0xf0, 0xe8, 0x26, 0xba, 0x2, 0x0, 0x0, 0x20, - 0x5f, 0x2a, 0xf8, 0x19, 0x27, 0x2, 0x0, 0x0, 0x47, 0xae, 0x12, 0x0, 0x3, 0xc0, 0x5b, 0x7, 0x13, - 0x18, 0xa3, 0x13, 0x5f, 0x3a, 0x23, 0x15, 0x2a, 0x9, 0x0, 0x13, 0xcd, 0xfc, 0xc4, 0xc0, 0xc7, 0x50, - 0xa3, 0xc7, 0x7b, 0x78, 0x48, 0xa5, 0x65, 0xe5, 0x98, 0x8d, 0x8f, 0x10, 0x94, 0x15, 0x0, 0x6, 0x3, - 0x65, 0x49, 0x87, 0xfa, 0xb4, 0x1f, 0x0, 0x16, 0x4e, 0x29, 0x11, 0x7c, 0xda, 0x58, 0x3e, 0xf7, 0x70, - 0x20, 0x24, 0x6b, 0xae, 0x61, 0x2, 0x82, 0xe3, 0x7b, 0xb2, 0x1e, 0x4a, 0x80, 0x26, 0x0, 0x17, 0xd8, - 0x9d, 0xb6, 0xb5, 0xfa, 0x11, 0x2f, 0xc9, 0x4c, 0xa9, 0x6c, 0x94, 0xe, 0x75, 0x8d, 0x31, 0x1c, 0x29, - 0xe5, 0xfd, 0x96, 0x25, 0x8d, 0x0, 0xa, 0x49, 0xe4, 0x14, 0x6a, 0xf6, 0x5d, 0x26, 0xe9, 0xc2, 0xa4, - 0x18, 0x0, 0x0, 0x3c, 0x2b, 0x28, 0xab, 0x1a, 0x0, 0x5, 0x6e, 0x13, 0xe, 0x72, 0xb3, 0x18, 0x0, - 0x0, 0x12, 0x6f, 0x1, 0x5a, 0x12, 0x0, 0x2, 0x85, 0x50, 0x0, 0x4, 0x33, 0xc1, 0x29, 0xad}; - - uint8_t buf[196] = {0}; - - uint8_t bytesprops0[] = {0x78, 0x93, 0x3b, 0xe0, 0xf0, 0xe8, 0x26, 0xba}; - uint8_t bytesprops1[] = {0xc0, 0x5b, 0x7}; - uint8_t bytesprops2[] = {0xcd, 0xfc, 0xc4, 0xc0, 0xc7, 0x50, 0xa3, 0xc7, 0x7b, 0x78, - 0x48, 0xa5, 0x65, 0xe5, 0x98, 0x8d, 0x8f, 0x10, 0x94}; - uint8_t bytesprops3[] = {0x3, 0x65, 0x49, 0x87, 0xfa, 0xb4}; - uint8_t bytesprops4[] = {0x4e, 0x29, 0x11, 0x7c, 0xda, 0x58, 0x3e, 0xf7, 0x70, 0x20, 0x24, - 0x6b, 0xae, 0x61, 0x2, 0x82, 0xe3, 0x7b, 0xb2, 0x1e, 0x4a, 0x80}; - uint8_t bytesprops6[] = {0x49, 0xe4, 0x14, 0x6a, 0xf6, 0x5d, 0x26, 0xe9, 0xc2, 0xa4}; - uint8_t bytesprops5[] = {0xd8, 0x9d, 0xb6, 0xb5, 0xfa, 0x11, 0x2f, 0xc9, 0x4c, 0xa9, 0x6c, 0x94, - 0xe, 0x75, 0x8d, 0x31, 0x1c, 0x29, 0xe5, 0xfd, 0x96, 0x25, 0x8d}; - uint8_t bytesprops7[] = {0x6e, 0x13, 0xe, 0x72, 0xb3}; - uint8_t bytesprops8[] = {0x85, 0x50}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8287}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18350}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6307}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24378}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5418}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops5}, .v = {10, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15403}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4719}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops8}}}, - }; - - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 30703; - uint8_t client_id_bytes[] = {0x33, 0xc1, 0x29, 0xad}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x25, 0xcc, 0xb9, 0x33, 0x17, 0x26, 0xae, 0xa3, 0xc, 0xc3, 0x25, 0xcd, 0x33, 0x5b, 0x3e, - 0x7f, 0x93, 0xf3, 0xf8, 0xf, 0x39, 0xc6, 0xbb, 0x5c, 0xdb, 0x92, 0x98, 0xe5, 0xd6, 0xe9}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "]\193c\STX\r\223\249r\ETXZ\v\aN1\DEL\172q\RS\210\169\176i\147\FS\191\181\200Vk%", -// _password = Just "\150\212\ESC\162~(\188%\191\133\243l", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 9661, _connID = "l\v\146\230\194\DC4X\149\219\171 \169y\188\176\&4\144O", _properties = [PropPayloadFormatIndicator -// 189,PropReasonString "M\159k\191]\152\DC3\243f\228_\149",PropRequestResponseInformation 79,PropServerReference -// "B\153\206\149l\229\147\&5\129}\188}=\238\161-\215\129\145\209G\254\234\190\205A\206\&9h",PropTopicAlias -// 21199,PropMaximumPacketSize 7621,PropMessageExpiryInterval 13332,PropSubscriptionIdentifierAvailable -// 210,PropServerKeepAlive 11594,PropTopicAlias 3010,PropAuthenticationData -// "\183J\162f.\243/\ETB?\156E\195",PropTopicAlias 14998,PropMaximumQoS 58,PropMessageExpiryInterval -// 12903,PropSubscriptionIdentifier 6,PropReceiveMaximum 9744,PropUserProperty "pW\173~e" -// "\239\200U]\144\250n\239",PropServerKeepAlive 17303,PropWildcardSubscriptionAvailable 253,PropMaximumPacketSize -// 17305,PropWildcardSubscriptionAvailable 226,PropAssignedClientIdentifier -// "p\235\135\211\138\NUL\179L\187Z\240\152\227\190\222\f\237\SOH\CAN\135\n\213q\251/\223\219"]} -TEST(Connect5QCTest, Encode46) { - uint8_t pkt[] = { - 0x10, 0xf0, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x25, 0xbd, 0xa2, 0x1, 0x1, 0xbd, 0x1f, 0x0, - 0xc, 0x4d, 0x9f, 0x6b, 0xbf, 0x5d, 0x98, 0x13, 0xf3, 0x66, 0xe4, 0x5f, 0x95, 0x19, 0x4f, 0x1c, 0x0, 0x1d, 0x42, - 0x99, 0xce, 0x95, 0x6c, 0xe5, 0x93, 0x35, 0x81, 0x7d, 0xbc, 0x7d, 0x3d, 0xee, 0xa1, 0x2d, 0xd7, 0x81, 0x91, 0xd1, - 0x47, 0xfe, 0xea, 0xbe, 0xcd, 0x41, 0xce, 0x39, 0x68, 0x23, 0x52, 0xcf, 0x27, 0x0, 0x0, 0x1d, 0xc5, 0x2, 0x0, - 0x0, 0x34, 0x14, 0x29, 0xd2, 0x13, 0x2d, 0x4a, 0x23, 0xb, 0xc2, 0x16, 0x0, 0xc, 0xb7, 0x4a, 0xa2, 0x66, 0x2e, - 0xf3, 0x2f, 0x17, 0x3f, 0x9c, 0x45, 0xc3, 0x23, 0x3a, 0x96, 0x24, 0x3a, 0x2, 0x0, 0x0, 0x32, 0x67, 0xb, 0x6, - 0x21, 0x26, 0x10, 0x26, 0x0, 0x5, 0x70, 0x57, 0xad, 0x7e, 0x65, 0x0, 0x8, 0xef, 0xc8, 0x55, 0x5d, 0x90, 0xfa, - 0x6e, 0xef, 0x13, 0x43, 0x97, 0x28, 0xfd, 0x27, 0x0, 0x0, 0x43, 0x99, 0x28, 0xe2, 0x12, 0x0, 0x1b, 0x70, 0xeb, - 0x87, 0xd3, 0x8a, 0x0, 0xb3, 0x4c, 0xbb, 0x5a, 0xf0, 0x98, 0xe3, 0xbe, 0xde, 0xc, 0xed, 0x1, 0x18, 0x87, 0xa, - 0xd5, 0x71, 0xfb, 0x2f, 0xdf, 0xdb, 0x0, 0x12, 0x6c, 0xb, 0x92, 0xe6, 0xc2, 0x14, 0x58, 0x95, 0xdb, 0xab, 0x20, - 0xa9, 0x79, 0xbc, 0xb0, 0x34, 0x90, 0x4f, 0x0, 0x1e, 0x5d, 0xc1, 0x63, 0x2, 0xd, 0xdf, 0xf9, 0x72, 0x3, 0x5a, - 0xb, 0x7, 0x4e, 0x31, 0x7f, 0xac, 0x71, 0x1e, 0xd2, 0xa9, 0xb0, 0x69, 0x93, 0x1c, 0xbf, 0xb5, 0xc8, 0x56, 0x6b, - 0x25, 0x0, 0xc, 0x96, 0xd4, 0x1b, 0xa2, 0x7e, 0x28, 0xbc, 0x25, 0xbf, 0x85, 0xf3, 0x6c}; - - uint8_t buf[253] = {0}; - - uint8_t bytesprops0[] = {0x4d, 0x9f, 0x6b, 0xbf, 0x5d, 0x98, 0x13, 0xf3, 0x66, 0xe4, 0x5f, 0x95}; - uint8_t bytesprops1[] = {0x42, 0x99, 0xce, 0x95, 0x6c, 0xe5, 0x93, 0x35, 0x81, 0x7d, 0xbc, 0x7d, 0x3d, 0xee, 0xa1, - 0x2d, 0xd7, 0x81, 0x91, 0xd1, 0x47, 0xfe, 0xea, 0xbe, 0xcd, 0x41, 0xce, 0x39, 0x68}; - uint8_t bytesprops2[] = {0xb7, 0x4a, 0xa2, 0x66, 0x2e, 0xf3, 0x2f, 0x17, 0x3f, 0x9c, 0x45, 0xc3}; - uint8_t bytesprops4[] = {0xef, 0xc8, 0x55, 0x5d, 0x90, 0xfa, 0x6e, 0xef}; - uint8_t bytesprops3[] = {0x70, 0x57, 0xad, 0x7e, 0x65}; - uint8_t bytesprops5[] = {0x70, 0xeb, 0x87, 0xd3, 0x8a, 0x0, 0xb3, 0x4c, 0xbb, 0x5a, 0xf0, 0x98, 0xe3, 0xbe, - 0xde, 0xc, 0xed, 0x1, 0x18, 0x87, 0xa, 0xd5, 0x71, 0xfb, 0x2f, 0xdf, 0xdb}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21199}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7621}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13332}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11594}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3010}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14998}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12903}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9744}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops3}, .v = {8, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17303}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17305}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 9661; - uint8_t client_id_bytes[] = {0x6c, 0xb, 0x92, 0xe6, 0xc2, 0x14, 0x58, 0x95, 0xdb, - 0xab, 0x20, 0xa9, 0x79, 0xbc, 0xb0, 0x34, 0x90, 0x4f}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x5d, 0xc1, 0x63, 0x2, 0xd, 0xdf, 0xf9, 0x72, 0x3, 0x5a, 0xb, 0x7, 0x4e, 0x31, 0x7f, - 0xac, 0x71, 0x1e, 0xd2, 0xa9, 0xb0, 0x69, 0x93, 0x1c, 0xbf, 0xb5, 0xc8, 0x56, 0x6b, 0x25}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x96, 0xd4, 0x1b, 0xa2, 0x7e, 0x28, 0xbc, 0x25, 0xbf, 0x85, 0xf3, 0x6c}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "HK\160A\236!\215\217", _password = Just "\172", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "_#", _willMsg = "}\199!\254\224\b\154\&2\232\184\163\213?\186", -// _willProps = [PropMaximumPacketSize 11544,PropReasonString -// "\231e\251\t\139\&1\227z\t5}\242Y\188\ENQ\255\189\200\241\216e\227\223",PropWillDelayInterval -// 27907,PropAuthenticationMethod "\253Uz>\225\f",PropContentType -// "\148\161\201\DEL$\165\167<:\208AZx%\246\255\133\231\173\193\ENQ\181\169\208\US\182\136\215\196",PropSubscriptionIdentifier -// 30,PropReasonString "u\241\SOO\DC1\153\199Z",PropRequestProblemInformation 103,PropPayloadFormatIndicator -// 43,PropRequestResponseInformation 227,PropPayloadFormatIndicator 40,PropResponseTopic -// "e{M\164\STX\240\225$\188\202\145\149\133p<\203\241\168o\133s\130\CAN\154\r\220\178\227\194",PropTopicAlias -// 7,PropTopicAlias 23134,PropRetainAvailable 141,PropTopicAlias 30201,PropTopicAliasMaximum 1945,PropTopicAlias -// 7974,PropUserProperty "\DLE\219\236\SI\253\233\rA" -// "\143&{H\171\&0q\SUBc\139\t6\US\231Hp\186\228\182",PropAuthenticationData -// "\196g\208\248\n",PropRequestResponseInformation 36,PropServerKeepAlive 10008,PropTopicAlias 13108]}), _cleanSession -// = True, _keepAlive = 8375, _connID = "{iE\207H\USn\DLE\193\b\245\216JK", _properties = [PropSessionExpiryInterval -// 19323,PropMessageExpiryInterval 30707,PropTopicAliasMaximum 25463,PropAuthenticationMethod -// "\157\190\201\186\DLE/\142\ESC\\\197\235\173\244\130\176\152"]} -TEST(Connect5QCTest, Encode47) { - uint8_t pkt[] = { - 0x10, 0xa1, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x20, 0xb7, 0x20, 0x11, 0x0, 0x0, 0x4b, 0x7b, - 0x2, 0x0, 0x0, 0x77, 0xf3, 0x22, 0x63, 0x77, 0x15, 0x0, 0x10, 0x9d, 0xbe, 0xc9, 0xba, 0x10, 0x2f, 0x8e, 0x1b, - 0x5c, 0xc5, 0xeb, 0xad, 0xf4, 0x82, 0xb0, 0x98, 0x0, 0xe, 0x7b, 0x69, 0x45, 0xcf, 0x48, 0x1f, 0x6e, 0x10, 0xc1, - 0x8, 0xf5, 0xd8, 0x4a, 0x4b, 0x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d0, 0xf8, 0xa, 0x19, 0x24, 0x13, 0x27, 0x18, 0x23, 0x33, 0x34, 0x0, 0x2, 0x5f, 0x23, 0x0, 0xe, 0x7d, - 0xc7, 0x21, 0xfe, 0xe0, 0x8, 0x9a, 0x32, 0xe8, 0xb8, 0xa3, 0xd5, 0x3f, 0xba, 0x0, 0x8, 0x48, 0x4b, 0xa0, 0x41, - 0xec, 0x21, 0xd7, 0xd9, 0x0, 0x1, 0xac}; - - uint8_t buf[302] = {0}; - - uint8_t bytesprops0[] = {0x9d, 0xbe, 0xc9, 0xba, 0x10, 0x2f, 0x8e, 0x1b, - 0x5c, 0xc5, 0xeb, 0xad, 0xf4, 0x82, 0xb0, 0x98}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19323}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30707}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25463}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, - }; - - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe7, 0x65, 0xfb, 0x9, 0x8b, 0x31, 0xe3, 0x7a, 0x9, 0x35, 0x7d, 0xf2, - 0x59, 0xbc, 0x5, 0xff, 0xbd, 0xc8, 0xf1, 0xd8, 0x65, 0xe3, 0xdf}; - uint8_t byteswillprops1[] = {0xfd, 0x55, 0x7a, 0x3e, 0xe1, 0xc}; - uint8_t byteswillprops2[] = {0x94, 0xa1, 0xc9, 0x7f, 0x24, 0xa5, 0xa7, 0x3c, 0x3a, 0xd0, 0x41, 0x5a, 0x78, 0x25, 0xf6, - 0xff, 0x85, 0xe7, 0xad, 0xc1, 0x5, 0xb5, 0xa9, 0xd0, 0x1f, 0xb6, 0x88, 0xd7, 0xc4}; - uint8_t byteswillprops3[] = {0x75, 0xf1, 0xe, 0x4f, 0x11, 0x99, 0xc7, 0x5a}; - uint8_t byteswillprops4[] = {0x65, 0x7b, 0x4d, 0xa4, 0x2, 0xf0, 0xe1, 0x24, 0xbc, 0xca, 0x91, 0x95, 0x85, 0x70, 0x3c, - 0xcb, 0xf1, 0xa8, 0x6f, 0x85, 0x73, 0x82, 0x18, 0x9a, 0xd, 0xdc, 0xb2, 0xe3, 0xc2}; - uint8_t byteswillprops6[] = {0x8f, 0x26, 0x7b, 0x48, 0xab, 0x30, 0x71, 0x1a, 0x63, 0x8b, - 0x9, 0x36, 0x1f, 0xe7, 0x48, 0x70, 0xba, 0xe4, 0xb6}; - uint8_t byteswillprops5[] = {0x10, 0xdb, 0xec, 0xf, 0xfd, 0xe9, 0xd, 0x41}; - uint8_t byteswillprops7[] = {0xc4, 0x67, 0xd0, 0xf8, 0xa}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11544}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27907}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23134}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30201}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1945}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7974}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {8, (char*)&byteswillprops5}, .v = {19, (char*)&byteswillprops6}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10008}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13108}}, - }; - - lwmqtt_properties_t willprops = {23, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5f, 0x23}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7d, 0xc7, 0x21, 0xfe, 0xe0, 0x8, 0x9a, 0x32, 0xe8, 0xb8, 0xa3, 0xd5, 0x3f, 0xba}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 8375; - uint8_t client_id_bytes[] = {0x7b, 0x69, 0x45, 0xcf, 0x48, 0x1f, 0x6e, 0x10, 0xc1, 0x8, 0xf5, 0xd8, 0x4a, 0x4b}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x48, 0x4b, 0xa0, 0x41, 0xec, 0x21, 0xd7, 0xd9}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xac}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just -// "s\249\NAK\192\197\&1\198#\180\SOH2\136\150\183B\199\209W@\DC3a\DLE\246\148\187\246\"", _password = Just -// "\224\236\147\252C\148\166\DEL\185\157\241m\242\132\SO\\q", _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS1, _willTopic = "\tqP", _willMsg = "o\SO.\159", _willProps = [PropMessageExpiryInterval -// 21061,PropAuthenticationData "\178\US",PropSessionExpiryInterval 26010,PropResponseInformation -// "\DC3\243?$s\DC1\135`\155.k\DC48\210\194F\244",PropSubscriptionIdentifierAvailable -// 219,PropSharedSubscriptionAvailable 247,PropTopicAlias 13806,PropWildcardSubscriptionAvailable 35,PropUserProperty -// "\157\239@x2\153?" -// "Q\167\227\&6\140Vgv\217\143\141\192D\225\201d\SI,o-\ESC\129[\182J\NAK;\146\222l",PropAuthenticationData -// "m7\245\161\140\163\139mF\188B\206\FS]\229\236u<\175 ",PropRetainAvailable 189,PropCorrelationData -// "\254y5AEL\136+\160\141\158\US\\\154\EOT}4;\207\156 \182\161M\216\172\160u\f\206",PropRequestResponseInformation -// 247,PropResponseTopic "\166\228s+W\165\ACK\243W\217s\a\189",PropWildcardSubscriptionAvailable 143,PropReceiveMaximum -// 11329,PropTopicAlias 5333,PropPayloadFormatIndicator 101,PropAssignedClientIdentifier -// "6\NAK\233\154",PropSessionExpiryInterval 5547,PropRetainAvailable 76,PropResponseTopic -// "\240\200uo\250\ESC\209\n\198\r\230\ETB\DC13\137\209\EMj?\227\179",PropResponseTopic -// "\215\153\GS\224\140\ACKr3Y\204.kT9\255\&0\150\134uQY\NUL\211\198\r\v\tzt\164",PropRetainAvailable -// 69,PropAuthenticationMethod "0\254\&7",PropAuthenticationData -// "]\202&\165\174\&4\184\&0\STX\DC4\151\GS\135\170\154\213\151&",PropContentType -// "\242\DC2\DLE\219\211\187\195\175\254n{K\ENQ\238\168\186\DEL\212IL\163Y\138"]}), _cleanSession = False, _keepAlive = -// 1422, _connID = "\184\233(\195\247\\\DC28i\FSj\135", _properties = [PropSessionExpiryInterval -// 19012,PropCorrelationData "}${\157\222to\135\t\DLE=]\213\219 \n\244LBsV",PropPayloadFormatIndicator -// 171,PropSubscriptionIdentifierAvailable 85,PropSharedSubscriptionAvailable 79,PropCorrelationData -// "sO{\173\150\226~\250\213\168\\;\216ST",PropAuthenticationMethod "K",PropWillDelayInterval -// 18157,PropAuthenticationData "\SYN\EM\141\150<\ETX\250\231\DEL",PropRequestResponseInformation -// 56,PropMaximumPacketSize 28986,PropSharedSubscriptionAvailable 227,PropMaximumPacketSize 9042,PropResponseInformation -// "\212\FS\STXB\210 (\182\251\a*\238*V~\199`\214\248\GS\198\170\FS\246\234)\253"]} -TEST(Connect5QCTest, Encode48) { - uint8_t pkt[] = { - 0x10, 0xf6, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x5, 0x8e, 0x76, 0x11, 0x0, 0x0, 0x4a, 0x44, - 0x9, 0x0, 0x15, 0x7d, 0x24, 0x7b, 0x9d, 0xde, 0x74, 0x6f, 0x87, 0x9, 0x10, 0x3d, 0x5d, 0xd5, 0xdb, 0x20, 0xa, - 0xf4, 0x4c, 0x42, 0x73, 0x56, 0x1, 0xab, 0x29, 0x55, 0x2a, 0x4f, 0x9, 0x0, 0xf, 0x73, 0x4f, 0x7b, 0xad, 0x96, - 0xe2, 0x7e, 0xfa, 0xd5, 0xa8, 0x5c, 0x3b, 0xd8, 0x53, 0x54, 0x15, 0x0, 0x1, 0x4b, 0x18, 0x0, 0x0, 0x46, 0xed, - 0x16, 0x0, 0x9, 0x16, 0x19, 0x8d, 0x96, 0x3c, 0x3, 0xfa, 0xe7, 0x7f, 0x19, 0x38, 0x27, 0x0, 0x0, 0x71, 0x3a, - 0x2a, 0xe3, 0x27, 0x0, 0x0, 0x23, 0x52,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 0xc7, - 0xd1, 0x57, 0x40, 0x13, 0x61, 0x10, 0xf6, 0x94, 0xbb, 0xf6, 0x22, 0x0, 0x11, 0xe0, 0xec, 0x93, 0xfc, 0x43, 0x94, - 0xa6, 0x7f, 0xb9, 0x9d, 0xf1, 0x6d, 0xf2, 0x84, 0xe, 0x5c, 0x71}; - - uint8_t buf[515] = {0}; - - uint8_t bytesprops0[] = {0x7d, 0x24, 0x7b, 0x9d, 0xde, 0x74, 0x6f, 0x87, 0x9, 0x10, 0x3d, - 0x5d, 0xd5, 0xdb, 0x20, 0xa, 0xf4, 0x4c, 0x42, 0x73, 0x56}; - uint8_t bytesprops1[] = {0x73, 0x4f, 0x7b, 0xad, 0x96, 0xe2, 0x7e, 0xfa, 0xd5, 0xa8, 0x5c, 0x3b, 0xd8, 0x53, 0x54}; - uint8_t bytesprops2[] = {0x4b}; - uint8_t bytesprops3[] = {0x16, 0x19, 0x8d, 0x96, 0x3c, 0x3, 0xfa, 0xe7, 0x7f}; - uint8_t bytesprops4[] = {0xd4, 0x1c, 0x2, 0x42, 0xd2, 0x20, 0x28, 0xb6, 0xfb, 0x7, 0x2a, 0xee, 0x2a, 0x56, - 0x7e, 0xc7, 0x60, 0xd6, 0xf8, 0x1d, 0xc6, 0xaa, 0x1c, 0xf6, 0xea, 0x29, 0xfd}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19012}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18157}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28986}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9042}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops4}}}, - }; - - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xb2, 0x1f}; - uint8_t byteswillprops1[] = {0x13, 0xf3, 0x3f, 0x24, 0x73, 0x11, 0x87, 0x60, 0x9b, - 0x2e, 0x6b, 0x14, 0x38, 0xd2, 0xc2, 0x46, 0xf4}; - uint8_t byteswillprops3[] = {0x51, 0xa7, 0xe3, 0x36, 0x8c, 0x56, 0x67, 0x76, 0xd9, 0x8f, - 0x8d, 0xc0, 0x44, 0xe1, 0xc9, 0x64, 0xf, 0x2c, 0x6f, 0x2d, - 0x1b, 0x81, 0x5b, 0xb6, 0x4a, 0x15, 0x3b, 0x92, 0xde, 0x6c}; - uint8_t byteswillprops2[] = {0x9d, 0xef, 0x40, 0x78, 0x32, 0x99, 0x3f}; - uint8_t byteswillprops4[] = {0x6d, 0x37, 0xf5, 0xa1, 0x8c, 0xa3, 0x8b, 0x6d, 0x46, 0xbc, - 0x42, 0xce, 0x1c, 0x5d, 0xe5, 0xec, 0x75, 0x3c, 0xaf, 0x20}; - uint8_t byteswillprops5[] = {0xfe, 0x79, 0x35, 0x41, 0x45, 0x4c, 0x88, 0x2b, 0xa0, 0x8d, - 0x9e, 0x1f, 0x5c, 0x9a, 0x4, 0x7d, 0x34, 0x3b, 0xcf, 0x9c, - 0x20, 0xb6, 0xa1, 0x4d, 0xd8, 0xac, 0xa0, 0x75, 0xc, 0xce}; - uint8_t byteswillprops6[] = {0xa6, 0xe4, 0x73, 0x2b, 0x57, 0xa5, 0x6, 0xf3, 0x57, 0xd9, 0x73, 0x7, 0xbd}; - uint8_t byteswillprops7[] = {0x36, 0x15, 0xe9, 0x9a}; - uint8_t byteswillprops8[] = {0xf0, 0xc8, 0x75, 0x6f, 0xfa, 0x1b, 0xd1, 0xa, 0xc6, 0xd, 0xe6, - 0x17, 0x11, 0x33, 0x89, 0xd1, 0x19, 0x6a, 0x3f, 0xe3, 0xb3}; - uint8_t byteswillprops9[] = {0xd7, 0x99, 0x1d, 0xe0, 0x8c, 0x6, 0x72, 0x33, 0x59, 0xcc, - 0x2e, 0x6b, 0x54, 0x39, 0xff, 0x30, 0x96, 0x86, 0x75, 0x51, - 0x59, 0x0, 0xd3, 0xc6, 0xd, 0xb, 0x9, 0x7a, 0x74, 0xa4}; - uint8_t byteswillprops10[] = {0x30, 0xfe, 0x37}; - uint8_t byteswillprops11[] = {0x5d, 0xca, 0x26, 0xa5, 0xae, 0x34, 0xb8, 0x30, 0x2, - 0x14, 0x97, 0x1d, 0x87, 0xaa, 0x9a, 0xd5, 0x97, 0x26}; - uint8_t byteswillprops12[] = {0xf2, 0x12, 0x10, 0xdb, 0xd3, 0xbb, 0xc3, 0xaf, 0xfe, 0x6e, 0x7b, 0x4b, - 0x5, 0xee, 0xa8, 0xba, 0x7f, 0xd4, 0x49, 0x4c, 0xa3, 0x59, 0x8a}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21061}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26010}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13806}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {7, (char*)&byteswillprops2}, .v = {30, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11329}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5333}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5547}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops12}}}, - }; - - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9, 0x71, 0x50}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6f, 0xe, 0x2e, 0x9f}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 1422; - uint8_t client_id_bytes[] = {0xb8, 0xe9, 0x28, 0xc3, 0xf7, 0x5c, 0x12, 0x38, 0x69, 0x1c, 0x6a, 0x87}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x73, 0xf9, 0x15, 0xc0, 0xc5, 0x31, 0xc6, 0x23, 0xb4, 0x1, 0x32, 0x88, 0x96, 0xb7, - 0x42, 0xc7, 0xd1, 0x57, 0x40, 0x13, 0x61, 0x10, 0xf6, 0x94, 0xbb, 0xf6, 0x22}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe0, 0xec, 0x93, 0xfc, 0x43, 0x94, 0xa6, 0x7f, 0xb9, - 0x9d, 0xf1, 0x6d, 0xf2, 0x84, 0xe, 0x5c, 0x71}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\204\ESC-v\215\228\195+\251.F6\r\221\213nfx\221", _password = Just "\193\152", -// _lastWill = Nothing, _cleanSession = False, _keepAlive = 20170, _connID = -// "9\b4\231\247\150H\ETB\GS\236t\185o\189\144\173\203P\207z\173", _properties = [PropCorrelationData -// "F\236\180\232z\241\217\234\140\167;!48\149a\223",PropAuthenticationMethod -// "\t\181U",PropSubscriptionIdentifierAvailable 40,PropRequestProblemInformation 170,PropAuthenticationData -// "\142\ACK\147",PropRetainAvailable 16,PropMaximumPacketSize 20456,PropResponseTopic "\183",PropReceiveMaximum -// 30861,PropUserProperty "U!\207\165\163?\140e\168=\245\200cQ\234\229\197\194\160\CAN\169" -// "\159_)h;\197\250G\189\223OS\EOT\153\160\209\200\153",PropMaximumPacketSize 27921,PropWillDelayInterval -// 24764,PropTopicAlias 621,PropMaximumPacketSize 8044,PropResponseTopic "",PropMaximumQoS 234,PropUserProperty -// "\231d\ESCy\SYN\254<@&\209\\\188j\236I\179\182m\154" -// "@\RS9cX\252\v\243\167?U9V\235o\248\224]\SO\194\237\228N\218\&6\ACK\DC2\US\224\207",PropUserProperty -// "R\163U\EOT\159\EM\b?\207?\ESC\222\DELl\249\DC1\172j" -// "\213\f\186V\199\t\240g\133\170\249\153\181\t`x<\254\153\198~\184\FS\200",PropAuthenticationMethod -// "",PropSubscriptionIdentifier 26,PropAuthenticationMethod "\191\226",PropWildcardSubscriptionAvailable -// 154,PropServerReference "",PropResponseTopic "(\139B\250\208T<\179\DC11*@\130\253\207",PropServerReference -// "+P\254\NUL6\161nD\240l*\144\208\237|\NAK.r\167\&1A\187\FS\210\240\DC4",PropWildcardSubscriptionAvailable -// 163,PropResponseInformation -// "\SUB^?\210\183\138\ESC\ACK\196:\175\181'\215(2\DC1\147\134~@\195\252\DC3xA.",PropServerReference ";\242\218"]} -TEST(Connect5QCTest, Encode50) { - uint8_t pkt[] = { - 0x10, 0x85, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x72, 0x34, 0x8c, 0x1, 0x3, 0x0, 0x6, 0xd6, - 0x98, 0xa9, 0x47, 0xdc, 0xf4, 0x1f, 0x0, 0x1c, 0x46, 0xf2, 0x47, 0xc3, 0x7a, 0x5d, 0xcb, 0xea, 0x6b, 0x9d, 0x2d, - 0x2e, 0x90, 0x60, 0x79, 0x1e, 0xcb, 0x1c, 0x23, 0xd5, 0x56, 0x73, 0x99, 0x6b, 0x3e, 0xb8, 0x1c, 0xc8, 0x15, 0x0, - 0x0, 0xb, 0x1a, 0x15, 0x0, 0x2, 0xbf, 0xe2, 0x28, 0x9a, 0x1c, 0x0, 0x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6, 0x0, 0x2, 0x74, 0xef, 0x0, 0x3, 0xd, 0x25, 0x94}; - - uint8_t buf[274] = {0}; - - uint8_t bytesprops0[] = {0xd6, 0x98, 0xa9, 0x47, 0xdc, 0xf4}; - uint8_t bytesprops1[] = {0x46, 0xf2, 0x47, 0xc3, 0x7a, 0x5d, 0xcb, 0xea, 0x6b, 0x9d, 0x2d, 0x2e, 0x90, 0x60, - 0x79, 0x1e, 0xcb, 0x1c, 0x23, 0xd5, 0x56, 0x73, 0x99, 0x6b, 0x3e, 0xb8, 0x1c, 0xc8}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0xbf, 0xe2}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0x28, 0x8b, 0x42, 0xfa, 0xd0, 0x54, 0x3c, 0xb3, 0x11, 0x31, 0x2a, 0x40, 0x82, 0xfd, 0xcf}; - uint8_t bytesprops6[] = {0x2b, 0x50, 0xfe, 0x0, 0x36, 0xa1, 0x6e, 0x44, 0xf0, 0x6c, 0x2a, 0x90, 0xd0, - 0xed, 0x7c, 0x15, 0x2e, 0x72, 0xa7, 0x31, 0x41, 0xbb, 0x1c, 0xd2, 0xf0, 0x14}; - uint8_t bytesprops7[] = {0x1a, 0x5e, 0x3f, 0xd2, 0xb7, 0x8a, 0x1b, 0x6, 0xc4, 0x3a, 0xaf, 0xb5, 0x27, 0xd7, - 0x28, 0x32, 0x11, 0x93, 0x86, 0x7e, 0x40, 0xc3, 0xfc, 0x13, 0x78, 0x41, 0x2e}; - uint8_t bytesprops8[] = {0x3b, 0xf2, 0xda}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops8}}}, - }; - - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xa1, 0xa1, 0x29, 0xc4, 0x21, 0x8a, 0xf8, 0xbc, 0x29, 0x31, 0x54, 0x3c, 0x5f, - 0xc8, 0x4, 0x70, 0xd2, 0x28, 0xb8, 0xcf, 0x7b, 0xa9, 0xe0, 0xa6, 0xed, 0x3c}; - uint8_t byteswillprops1[] = {0x6f, 0x48, 0xff, 0x68, 0x47, 0x82, 0xc0, 0xfc, 0xb, 0x96, 0x10, 0x26, - 0xca, 0x50, 0xcb, 0x98, 0x8e, 0x9e, 0x72, 0x6b, 0x49, 0xc7, 0x3b}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23303}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13748}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21210}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31986}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25715}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23018}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - }; - - lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd, 0xe2, 0x5f, 0x63, 0x2c, 0xf8}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x97, 0xa8, 0x8d, 0xb7, 0x47, 0xc6}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 29236; - uint8_t client_id_bytes[] = {0xca, 0xdb}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x74, 0xef}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd, 0x25, 0x94}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\144:3}\185E\246k\210Hp\221\197\245\&6\148\135m\216\143p\136\185\STX\ENQ\186\149?", -// _password = Just "\DC3\NAK\168)\SUB\234>\CAN\168\155\253RB\142?\137D\181y\170\&3O!+", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = -// "\227\205\234\251\"J\133\178\154\154[\STX\135\DC4[\a@\245[e\SUBR1\234\201\192'\vam", _willMsg = "\CAN\230\GS", -// _willProps = [PropSubscriptionIdentifierAvailable 23,PropSharedSubscriptionAvailable -// 192,PropSharedSubscriptionAvailable 231,PropSubscriptionIdentifier 17,PropTopicAliasMaximum -// 30146,PropMessageExpiryInterval 32008,PropRetainAvailable 255,PropServerKeepAlive 14818]}), _cleanSession = False, -// _keepAlive = 542, _connID = ")\ESC\193I>\"[\SO\187G\\\182\199yj\DC4o\204\229yV\"n+\138u\223", _properties = -// [PropWildcardSubscriptionAvailable 38,PropReasonString -// "\183\205\145\166@S!\178\&9\236\f",PropSharedSubscriptionAvailable 86]} -TEST(Connect5QCTest, Encode51) { - uint8_t pkt[] = {0x10, 0xad, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x2, 0x1e, 0x12, 0x28, 0x26, - 0x1f, 0x0, 0xb, 0xb7, 0xcd, 0x91, 0xa6, 0x40, 0x53, 0x21, 0xb2, 0x39, 0xec, 0xc, 0x2a, 0x56, - 0x0, 0x1b, 0x29, 0x1b, 0xc1, 0x49, 0x3e, 0x22, 0x5b, 0xe, 0xbb, 0x47, 0x5c, 0xb6, 0xc7, 0x79, - 0x6a, 0x14, 0x6f, 0xcc, 0xe5, 0x79, 0x56, 0x22, 0x6e, 0x2b, 0x8a, 0x75, 0xdf, 0x15, 0x29, 0x17, - 0x2a, 0xc0, 0x2a, 0xe7, 0xb, 0x11, 0x22, 0x75, 0xc2, 0x2, 0x0, 0x0, 0x7d, 0x8, 0x25, 0xff, - 0x13, 0x39, 0xe2, 0x0, 0x1e, 0xe3, 0xcd, 0xea, 0xfb, 0x22, 0x4a, 0x85, 0xb2, 0x9a, 0x9a, 0x5b, - 0x2, 0x87, 0x14, 0x5b, 0x7, 0x40, 0xf5, 0x5b, 0x65, 0x1a, 0x52, 0x31, 0xea, 0xc9, 0xc0, 0x27, - 0xb, 0x61, 0x6d, 0x0, 0x3, 0x18, 0xe6, 0x1d, 0x0, 0x1c, 0x90, 0x3a, 0x33, 0x7d, 0xb9, 0x45, - 0xf6, 0x6b, 0xd2, 0x48, 0x70, 0xdd, 0xc5, 0xf5, 0x36, 0x94, 0x87, 0x6d, 0xd8, 0x8f, 0x70, 0x88, - 0xb9, 0x2, 0x5, 0xba, 0x95, 0x3f, 0x0, 0x18, 0x13, 0x15, 0xa8, 0x29, 0x1a, 0xea, 0x3e, 0x18, - 0xa8, 0x9b, 0xfd, 0x52, 0x42, 0x8e, 0x3f, 0x89, 0x44, 0xb5, 0x79, 0xaa, 0x33, 0x4f, 0x21, 0x2b}; - - uint8_t buf[186] = {0}; - - uint8_t bytesprops0[] = {0xb7, 0xcd, 0x91, 0xa6, 0x40, 0x53, 0x21, 0xb2, 0x39, 0xec, 0xc}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 86}}, - }; - - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 23}}, {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 231}}, {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30146}}, {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32008}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 255}}, {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14818}}, - }; - - lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe3, 0xcd, 0xea, 0xfb, 0x22, 0x4a, 0x85, 0xb2, 0x9a, 0x9a, - 0x5b, 0x2, 0x87, 0x14, 0x5b, 0x7, 0x40, 0xf5, 0x5b, 0x65, - 0x1a, 0x52, 0x31, 0xea, 0xc9, 0xc0, 0x27, 0xb, 0x61, 0x6d}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x18, 0xe6, 0x1d}; - lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 542; - uint8_t client_id_bytes[] = {0x29, 0x1b, 0xc1, 0x49, 0x3e, 0x22, 0x5b, 0xe, 0xbb, 0x47, 0x5c, 0xb6, 0xc7, 0x79, - 0x6a, 0x14, 0x6f, 0xcc, 0xe5, 0x79, 0x56, 0x22, 0x6e, 0x2b, 0x8a, 0x75, 0xdf}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x90, 0x3a, 0x33, 0x7d, 0xb9, 0x45, 0xf6, 0x6b, 0xd2, 0x48, 0x70, 0xdd, 0xc5, 0xf5, - 0x36, 0x94, 0x87, 0x6d, 0xd8, 0x8f, 0x70, 0x88, 0xb9, 0x2, 0x5, 0xba, 0x95, 0x3f}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x13, 0x15, 0xa8, 0x29, 0x1a, 0xea, 0x3e, 0x18, 0xa8, 0x9b, 0xfd, 0x52, - 0x42, 0x8e, 0x3f, 0x89, 0x44, 0xb5, 0x79, 0xaa, 0x33, 0x4f, 0x21, 0x2b}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "LW\149,C?\222\163x\147\176\166e\163!\187}@2\213\n", _password = Just -// "\166\&1Vn<\147O\v\178i\245g:\SUB", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\243\244O\221\ETX\229\192\137;\183\197D/\221!m\211\162", _willMsg = -// "\239M(\237\209\235\215\"\SI\220v\217\205\n\228\156\205s\250\244\167K\185\SI-\ETB\SOq\r", _willProps = -// [PropPayloadFormatIndicator 179,PropUserProperty -// "R\245\138t\142U\US\129U\179R\254\254\191\139E\171\189\157\219\144\185]Po]" "z",PropAssignedClientIdentifier -// "\182u\130\176\&6",PropAuthenticationMethod "&\154\EMEW\186",PropResponseInformation -// "\132\189q0\142\247\196G\196\198\&70\NUL\ETX$f\139\DLE\CANw\144\r$\155",PropPayloadFormatIndicator -// 19,PropRequestProblemInformation 215,PropMaximumQoS 170,PropRequestProblemInformation 100,PropAuthenticationData -// "\160",PropAssignedClientIdentifier "R\137\217\168",PropRequestResponseInformation 99,PropServerReference -// "h\147\144\EMT\f\190\170\224\157\167\205\223\174S\215\DC3\222\b\ENQ\DLE\208\202\248\141i\SOH",PropAssignedClientIdentifier -// "\140",PropResponseTopic "\168\251\179\150\162\aO)?\160U\135\202$\147\188\182",PropResponseTopic -// "\SOH\232T\188\r]jZ^\235e\224\SUB\135GdI=\166",PropSubscriptionIdentifier 17,PropRetainAvailable -// 103,PropAuthenticationMethod "\143\211\213\153\230\242",PropRequestProblemInformation -// 23,PropWildcardSubscriptionAvailable 104]}), _cleanSession = False, _keepAlive = 32428, _connID = -// "\SYN\217\207Z5\137\241\224\174\144\248\192*\233\218Z\230\DEL\198I9", _properties = [PropSubscriptionIdentifier -// 13,PropMaximumQoS 96,PropTopicAlias 32544,PropAuthenticationMethod ")6U",PropTopicAliasMaximum -// 26085,PropServerKeepAlive 12645,PropResponseInformation "\165\229\230B\r.ib\141\&6E\240n\EM\157 -// \208\160\201\221\131\231'\244\SINb\159+Q",PropPayloadFormatIndicator 147,PropRetainAvailable 90,PropRetainAvailable -// 197,PropTopicAliasMaximum 5288,PropMaximumQoS 8,PropResponseTopic -// "\204\228\FS\199\&4\160v\173\186\131\147\DC2`^\217\162\&4\244U\243<\SUB\208",PropReasonString "'\143\157YG"]} -TEST(Connect5QCTest, Encode52) { - uint8_t pkt[] = { - 0x10, 0x9f, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x7e, 0xac, 0x61, 0xb, 0xd, 0x24, 0x60, 0x23, - 0x7f, 0x20, 0x15, 0x0, 0x3, 0x29, 0x36, 0x55, 0x22, 0x65, 0xe5, 0x13, 0x31, 0x65, 0x1a, 0x0, 0x1e, 0xa5, 0xe5, - 0xe6, 0x42, 0xd, 0x2e, 0x69, 0x62, 0x8d, 0x36, 0x45, 0xf0, 0x6e, 0x19, 0x9d, 0x20, 0xd0, 0xa0, 0xc9, 0xdd, 0x83, - 0xe7, 0x27, 0xf4, 0xf, 0x4e, 0x62, 0x9f, 0x2b, 0x51, 0x1, 0x93, 0x25, 0x5a, 0x25, 0xc5, 0x22, 0x14, 0xa8, 0x24, - 0x8, 0x8, 0x0, 0x17, 0xcc, 0xe4, 0x1c, 0xc7, 0x34, 0xa0, 0x76, 0xad, 0xba, 0x83, 0x93, 0x12, 0x60, 0x5e, 0xd9, - 0xa2, 0x34, 0xf4, 0x55, 0xf3, 0x3c, 0x1a, 0xd0, 0x1f, 0x0, 0x5, 0x27, 0x8f, 0x9d, 0x59, 0x47, 0x0, 0x15, 0x16, - 0xd9, 0xcf, 0x5a, 0x35, 0x89, 0xf1, 0xe0, 0xae, 0x90, 0xf8, 0xc0, 0x2a, 0xe9, 0xda, 0x5a, 0xe6, 0x7f, 0xc6, 0x49, - 0x39, 0xc0, 0x1, 0x1, 0xb3, 0x26, 0x0, 0x1a, 0x52, 0xf5, 0x8a, 0x74, 0x8e, 0x55, 0x1f, 0x81, 0x55, 0xb3, 0x52, - 0xfe, 0xfe, 0xbf, 0x8b, 0x45, 0xab, 0xbd, 0x9d, 0xdb, 0x90, 0xb9, 0x5d, 0x50, 0x6f, 0x5d, 0x0, 0x1, 0x7a, 0x12, - 0x0, 0x5, 0xb6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d9, 0xcd, 0xa, 0xe4, 0x9c, 0xcd, 0x73, 0xfa, 0xf4, 0xa7, 0x4b, 0xb9, 0xf, 0x2d, 0x17, 0xe, 0x71, 0xd, 0x0, - 0x15, 0x4c, 0x57, 0x95, 0x2c, 0x43, 0x3f, 0xde, 0xa3, 0x78, 0x93, 0xb0, 0xa6, 0x65, 0xa3, 0x21, 0xbb, 0x7d, 0x40, - 0x32, 0xd5, 0xa, 0x0, 0xe, 0xa6, 0x31, 0x56, 0x6e, 0x3c, 0x93, 0x4f, 0xb, 0xb2, 0x69, 0xf5, 0x67, 0x3a, 0x1a}; - - uint8_t buf[428] = {0}; - - uint8_t bytesprops0[] = {0x29, 0x36, 0x55}; - uint8_t bytesprops1[] = {0xa5, 0xe5, 0xe6, 0x42, 0xd, 0x2e, 0x69, 0x62, 0x8d, 0x36, 0x45, 0xf0, 0x6e, 0x19, 0x9d, - 0x20, 0xd0, 0xa0, 0xc9, 0xdd, 0x83, 0xe7, 0x27, 0xf4, 0xf, 0x4e, 0x62, 0x9f, 0x2b, 0x51}; - uint8_t bytesprops2[] = {0xcc, 0xe4, 0x1c, 0xc7, 0x34, 0xa0, 0x76, 0xad, 0xba, 0x83, 0x93, 0x12, - 0x60, 0x5e, 0xd9, 0xa2, 0x34, 0xf4, 0x55, 0xf3, 0x3c, 0x1a, 0xd0}; - uint8_t bytesprops3[] = {0x27, 0x8f, 0x9d, 0x59, 0x47}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32544}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26085}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12645}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5288}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops3}}}, - }; - - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x7a}; - uint8_t byteswillprops0[] = {0x52, 0xf5, 0x8a, 0x74, 0x8e, 0x55, 0x1f, 0x81, 0x55, 0xb3, 0x52, 0xfe, 0xfe, - 0xbf, 0x8b, 0x45, 0xab, 0xbd, 0x9d, 0xdb, 0x90, 0xb9, 0x5d, 0x50, 0x6f, 0x5d}; - uint8_t byteswillprops2[] = {0xb6, 0x75, 0x82, 0xb0, 0x36}; - uint8_t byteswillprops3[] = {0x26, 0x9a, 0x19, 0x45, 0x57, 0xba}; - uint8_t byteswillprops4[] = {0x84, 0xbd, 0x71, 0x30, 0x8e, 0xf7, 0xc4, 0x47, 0xc4, 0xc6, 0x37, 0x30, - 0x0, 0x3, 0x24, 0x66, 0x8b, 0x10, 0x18, 0x77, 0x90, 0xd, 0x24, 0x9b}; - uint8_t byteswillprops5[] = {0xa0}; - uint8_t byteswillprops6[] = {0x52, 0x89, 0xd9, 0xa8}; - uint8_t byteswillprops7[] = {0x68, 0x93, 0x90, 0x19, 0x54, 0xc, 0xbe, 0xaa, 0xe0, 0x9d, 0xa7, 0xcd, 0xdf, 0xae, - 0x53, 0xd7, 0x13, 0xde, 0x8, 0x5, 0x10, 0xd0, 0xca, 0xf8, 0x8d, 0x69, 0x1}; - uint8_t byteswillprops8[] = {0x8c}; - uint8_t byteswillprops9[] = {0xa8, 0xfb, 0xb3, 0x96, 0xa2, 0x7, 0x4f, 0x29, 0x3f, - 0xa0, 0x55, 0x87, 0xca, 0x24, 0x93, 0xbc, 0xb6}; - uint8_t byteswillprops10[] = {0x1, 0xe8, 0x54, 0xbc, 0xd, 0x5d, 0x6a, 0x5a, 0x5e, 0xeb, - 0x65, 0xe0, 0x1a, 0x87, 0x47, 0x64, 0x49, 0x3d, 0xa6}; - uint8_t byteswillprops11[] = {0x8f, 0xd3, 0xd5, 0x99, 0xe6, 0xf2}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {26, (char*)&byteswillprops0}, .v = {1, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 104}}, - }; - - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf3, 0xf4, 0x4f, 0xdd, 0x3, 0xe5, 0xc0, 0x89, 0x3b, - 0xb7, 0xc5, 0x44, 0x2f, 0xdd, 0x21, 0x6d, 0xd3, 0xa2}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xef, 0x4d, 0x28, 0xed, 0xd1, 0xeb, 0xd7, 0x22, 0xf, 0xdc, - 0x76, 0xd9, 0xcd, 0xa, 0xe4, 0x9c, 0xcd, 0x73, 0xfa, 0xf4, - 0xa7, 0x4b, 0xb9, 0xf, 0x2d, 0x17, 0xe, 0x71, 0xd}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32428; - uint8_t client_id_bytes[] = {0x16, 0xd9, 0xcf, 0x5a, 0x35, 0x89, 0xf1, 0xe0, 0xae, 0x90, 0xf8, - 0xc0, 0x2a, 0xe9, 0xda, 0x5a, 0xe6, 0x7f, 0xc6, 0x49, 0x39}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x4c, 0x57, 0x95, 0x2c, 0x43, 0x3f, 0xde, 0xa3, 0x78, 0x93, 0xb0, - 0xa6, 0x65, 0xa3, 0x21, 0xbb, 0x7d, 0x40, 0x32, 0xd5, 0xa}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xa6, 0x31, 0x56, 0x6e, 0x3c, 0x93, 0x4f, 0xb, 0xb2, 0x69, 0xf5, 0x67, 0x3a, 0x1a}; - lwmqtt_string_t password = {14, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\230\206\252H\237\141\SIb\136w \172Y\159\155sC\141\159\"s\246{\DEL\254\208~\130", -// _password = Just "o\191Q<34\244\255\186\STXo\235,\210\v\SYN_\234\"x\219X\242\159.D\231", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\204\DC4\226:25\172", _willMsg = "\NAK\232\175\221\193,", -// _willProps = [PropWildcardSubscriptionAvailable 151,PropRetainAvailable 219,PropReasonString -// ":\226\&5#\STX\167\SO%\181\176\210sv\135\SO\129Kq5\224\131\205\ACK8L*\129\205\224P",PropTopicAlias -// 23946,PropServerReference "\166\135\216=",PropRequestProblemInformation 50,PropRequestProblemInformation -// 106,PropMessageExpiryInterval 29679,PropSubscriptionIdentifierAvailable 10,PropContentType -// "\182\218\232\231m\SOH\240\198\227\252\f\231\132ED",PropAssignedClientIdentifier "\DC3~\157\240\238"]}), -// _cleanSession = False, _keepAlive = 4766, _connID = "p\205\137>X(\171\175\246\NAKr\254\223H\232\252\254\236\198<", -// _properties = [PropMaximumPacketSize 32218,PropMaximumQoS 136,PropAssignedClientIdentifier -// "\250\131@\212H6\158\179\249\165",PropResponseInformation -// "\201\180t\DC1gN\208\176\200x\252\173\201\234\US\154\t\202\188u\SI",PropReasonString -// "w\168\188\221\159\EOT[\SYN\219\222\239\229({@3\171\200\CAN\147\197\"{\195C\148B\211'",PropWillDelayInterval -// 23335,PropPayloadFormatIndicator 34,PropWildcardSubscriptionAvailable 162,PropRetainAvailable 117,PropResponseTopic -// "\248s\223\159\170\220G\247\166",PropMessageExpiryInterval 19508,PropReceiveMaximum 26213,PropResponseTopic -// "\177H\134\133",PropSharedSubscriptionAvailable 185,PropResponseInformation -// "\DC3\245\235s\US\246\226\205G\159nd\220\248g-\195c\222\185\163\178g",PropTopicAlias -// 12131,PropWildcardSubscriptionAvailable 179,PropAuthenticationData -// "8\230\178jp\243\153\227\235\154\&4-2\214#\145X\153\185\175\199\"\166s\DC2\207@",PropCorrelationData -// "\SUBg>\\\vz\206\247\fL\189\176\202\129\EOT\211\&7\134\r",PropResponseTopic -// "8\169\DEL\205\233\153\131\192\191\132\230\165\252l\DC1\157",PropAssignedClientIdentifier -// "\201YwF$%\137\NUL\230\ENQUM\219\220s",PropSubscriptionIdentifier 27,PropSharedSubscriptionAvailable -// 87,PropUserProperty -// "\169\149\215\197\129~\186\194\237&\DC3\180\130\179\248\233\215`\194\173\167\164\157\148\209\f\155s\ETB" -// "\202\"\255\210\225",PropAuthenticationMethod "\205\191i:\180",PropUserProperty -// "\136\129\247>\NULS\230\&8^\171r\237\213mk" "\226\178",PropSubscriptionIdentifier 3,PropTopicAliasMaximum -// 2449,PropRequestResponseInformation 14]}), _cleanSession = False, _keepAlive = 6302, _connID = -// "5\175\175\181'H\173\161[\157\&8\175BY\182|\179", _properties = [PropServerReference -// "YP\224~\225A!",PropServerKeepAlive 2913,PropWillDelayInterval 20651]} -TEST(Connect5QCTest, Encode54) { - uint8_t pkt[] = { - 0x10, 0xe0, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x34, 0x18, 0x9e, 0x12, 0x1c, 0x0, 0x7, 0x59, 0x50, - 0xe0, 0x7e, 0xe1, 0x41, 0x21, 0x13, 0xb, 0x61, 0x18, 0x0, 0x0, 0x50, 0xab, 0x0, 0x11, 0x35, 0xaf, 0xaf, 0xb5, - 0x27, 0x48, 0xad, 0xa1, 0x5b, 0x9d, 0x38, 0xaf, 0x42, 0x59, 0xb6, 0x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, 0xe6, 0x5, 0x55, 0x4d, 0xdb, 0xdc, 0x73, 0xb, 0x1b, 0x2a, 0x57, - 0x26, 0x0, 0x1d, 0xa9, 0x95, 0xd7, 0xc5, 0x81, 0x7e, 0xba, 0xc2, 0xed, 0x26, 0x13, 0xb4, 0x82, 0xb3, 0xf8, 0xe9, - 0xd7, 0x60, 0xc2, 0xad, 0xa7, 0xa4, 0x9d, 0x94, 0xd1, 0xc, 0x9b, 0x73, 0x17, 0x0, 0x5, 0xca, 0x22, 0xff, 0xd2, - 0xe1, 0x15, 0x0, 0x5, 0xcd, 0xbf, 0x69, 0x3a, 0xb4, 0x26, 0x0, 0xf, 0x88, 0x81, 0xf7, 0x3e, 0x0, 0x53, 0xe6, - 0x38, 0x5e, 0xab, 0x72, 0xed, 0xd5, 0x6d, 0x6b, 0x0, 0x2, 0xe2, 0xb2, 0xb, 0x3, 0x22, 0x9, 0x91, 0x19, 0xe, - 0x0, 0x1, 0xa, 0x0, 0x1b, 0x77, 0x39, 0xd9, 0x79, 0x4d, 0xba, 0xa1, 0xa6, 0x67, 0x88, 0x8c, 0x9a, 0xb2, 0x16, - 0x35, 0x96, 0xe4, 0xd4, 0x1c, 0x48, 0x50, 0xeb, 0xca, 0xe0, 0xf2, 0x44, 0x3b}; - - uint8_t buf[365] = {0}; - - uint8_t bytesprops0[] = {0x59, 0x50, 0xe0, 0x7e, 0xe1, 0x41, 0x21}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2913}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20651}}, - }; - - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x65, 0xb0, 0x46, 0xb3, 0x27, 0x73, 0x35}; - uint8_t byteswillprops1[] = {0xb3, 0xa5, 0x64, 0xd9, 0x9d, 0x3a, 0xce, 0x2c, 0xe6, 0xa, 0xd4, 0x57, - 0xb2, 0xae, 0x64, 0x9f, 0x38, 0x49, 0xe0, 0x97, 0x66, 0xc1, 0x93, 0xdc}; - uint8_t byteswillprops2[] = {0x75, 0xf0, 0x3f, 0x3e, 0xf7, 0xa6}; - uint8_t byteswillprops3[] = {0xb1, 0x48, 0x86, 0x85}; - uint8_t byteswillprops4[] = {0x13, 0xf5, 0xeb, 0x73, 0x1f, 0xf6, 0xe2, 0xcd, 0x47, 0x9f, 0x6e, 0x64, - 0xdc, 0xf8, 0x67, 0x2d, 0xc3, 0x63, 0xde, 0xb9, 0xa3, 0xb2, 0x67}; - uint8_t byteswillprops5[] = {0x38, 0xe6, 0xb2, 0x6a, 0x70, 0xf3, 0x99, 0xe3, 0xeb, 0x9a, 0x34, 0x2d, 0x32, 0xd6, - 0x23, 0x91, 0x58, 0x99, 0xb9, 0xaf, 0xc7, 0x22, 0xa6, 0x73, 0x12, 0xcf, 0x40}; - uint8_t byteswillprops6[] = {0x1a, 0x67, 0x3e, 0x5c, 0xb, 0x7a, 0xce, 0xf7, 0xc, 0x4c, - 0xbd, 0xb0, 0xca, 0x81, 0x4, 0xd3, 0x37, 0x86, 0xd}; - uint8_t byteswillprops7[] = {0x38, 0xa9, 0x7f, 0xcd, 0xe9, 0x99, 0x83, 0xc0, - 0xbf, 0x84, 0xe6, 0xa5, 0xfc, 0x6c, 0x11, 0x9d}; - uint8_t byteswillprops8[] = {0xc9, 0x59, 0x77, 0x46, 0x24, 0x25, 0x89, 0x0, 0xe6, 0x5, 0x55, 0x4d, 0xdb, 0xdc, 0x73}; - uint8_t byteswillprops10[] = {0xca, 0x22, 0xff, 0xd2, 0xe1}; - uint8_t byteswillprops9[] = {0xa9, 0x95, 0xd7, 0xc5, 0x81, 0x7e, 0xba, 0xc2, 0xed, 0x26, 0x13, 0xb4, 0x82, 0xb3, 0xf8, - 0xe9, 0xd7, 0x60, 0xc2, 0xad, 0xa7, 0xa4, 0x9d, 0x94, 0xd1, 0xc, 0x9b, 0x73, 0x17}; - uint8_t byteswillprops11[] = {0xcd, 0xbf, 0x69, 0x3a, 0xb4}; - uint8_t byteswillprops13[] = {0xe2, 0xb2}; - uint8_t byteswillprops12[] = {0x88, 0x81, 0xf7, 0x3e, 0x0, 0x53, 0xe6, 0x38, - 0x5e, 0xab, 0x72, 0xed, 0xd5, 0x6d, 0x6b}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12776}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19508}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26213}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12131}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {29, (char*)&byteswillprops9}, .v = {5, (char*)&byteswillprops10}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {15, (char*)&byteswillprops12}, .v = {2, (char*)&byteswillprops13}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2449}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 14}}, - }; - - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x77, 0x39, 0xd9, 0x79, 0x4d, 0xba, 0xa1, 0xa6, 0x67, 0x88, 0x8c, 0x9a, 0xb2, 0x16, - 0x35, 0x96, 0xe4, 0xd4, 0x1c, 0x48, 0x50, 0xeb, 0xca, 0xe0, 0xf2, 0x44, 0x3b}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 6302; - uint8_t client_id_bytes[] = {0x35, 0xaf, 0xaf, 0xb5, 0x27, 0x48, 0xad, 0xa1, 0x5b, - 0x9d, 0x38, 0xaf, 0x42, 0x59, 0xb6, 0x7c, 0xb3}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x3c, 0xa, 0x95, 0x52, 0x30, 0x5c, 0xd8, 0x4b, 0x15, - 0x9d, 0xef, 0xbb, 0x62, 0xf3, 0xac, 0x15, 0x55}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "7x\204\136o\US\ESC\232\vI\211", _password = Just "m", _lastWill = Nothing, -// _cleanSession = True, _keepAlive = 16891, _connID = "\152\237\162\129\182]", _properties = [PropSessionExpiryInterval -// 9597,PropTopicAliasMaximum 2865,PropWildcardSubscriptionAvailable 99,PropRequestProblemInformation -// 104,PropAuthenticationMethod -// "\STX\212\ESCFo\170a\162\220\143\177\131\218\144\ENQ\239R\RS\215\138\DLEJ\200B\237\166\168",PropAuthenticationMethod -// "\160\209\173T\ETX\140\184\247\137\213\DLEp9'y2\147",PropWildcardSubscriptionAvailable 84,PropSubscriptionIdentifier -// 28,PropRequestProblemInformation 6,PropTopicAliasMaximum 3045,PropResponseTopic "",PropCorrelationData -// "\250\196O\247\DC1\176\253\150\238\214\216\212f\161Xl\t", _willProps = [PropSubscriptionIdentifier 20]}), -// _cleanSession = True, _keepAlive = 1871, _connID = "s\ETXN", _properties = [PropResponseInformation -// "\252\192\196\"\230/",PropWillDelayInterval 16667,PropReceiveMaximum 30002,PropSubscriptionIdentifier -// 18,PropMessageExpiryInterval 21381,PropWillDelayInterval 24570,PropAuthenticationData -// "\189\175R\137\130\r\203\SUB\r\EOT",PropTopicAliasMaximum 26398,PropMaximumPacketSize 25296,PropTopicAliasMaximum -// 22383,PropAssignedClientIdentifier "\236\161TO>\"\144\233|",PropResponseInformation -// "\194\199-i\151\v\220\GS\234l\189\176\155\148\240*\"\237j\165+\212\rU",PropRequestResponseInformation -// 128,PropCorrelationData "\227k>\160\SOy\157\251\243;0\199\242\237]\155\ETX2\"x\140\173\149\152",PropWillDelayInterval -// 11756,PropMaximumPacketSize 6416,PropUserProperty "" "8\t\180",PropResponseTopic "\135",PropTopicAlias -// 8174,PropPayloadFormatIndicator 236,PropWildcardSubscriptionAvailable 243,PropTopicAlias 26948,PropTopicAliasMaximum -// 23415,PropSubscriptionIdentifier 6,PropSubscriptionIdentifierAvailable 137,PropServerReference -// "\209\DC1\233\230O",PropTopicAlias 13735]} -TEST(Connect5QCTest, Encode62) { - uint8_t pkt[] = { - 0x10, 0x99, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x7, 0x4f, 0xab, 0x1, 0x1a, 0x0, 0x6, 0xfc, - 0xc0, 0xc4, 0x22, 0xe6, 0x2f, 0x18, 0x0, 0x0, 0x41, 0x1b, 0x21, 0x75, 0x32, 0xb, 0x12, 0x2, 0x0, 0x0, 0x53, - 0x85, 0x18, 0x0, 0x0, 0x5f, 0xfa, 0x16, 0x0, 0xa, 0xbd, 0xaf, 0x52, 0x89, 0x82, 0xd, 0xcb, 0x1a, 0xd, 0x4, - 0x22, 0x67, 0x1e, 0x27, 0x0, 0x0, 0x62, 0xd0, 0x22, 0x57, 0x6f, 0x12, 0x0, 0x9, 0xec, 0xa1, 0x54, 0x4f, 0x3e, - 0x22, 0x90, 0xe9, 0x7c, 0x1a, 0x0, 0x18, 0xc2, 0xc7, 0x2d, 0x69, 0x97, 0xb, 0xdc, 0x1d, 0xea, 0x6c, 0xbd, 0xb0, - 0x9b, 0x94, 0xf0, 0x2a, 0x22, 0xed, 0x6a, 0xa5, 0x2b, 0xd4, 0xd, 0x55, 0x19, 0x80, 0x9, 0x0, 0x18, 0xe3, 0x6b, - 0x3e, 0xa0, 0xe, 0x79, 0x9d, 0xfb, 0xf3, 0x3b, 0x30, 0xc7, 0xf2, 0xed, 0x5d, 0x9b, 0x3, 0x32, 0x22, 0x78, 0x8c, - 0xad, 0x95, 0x98, 0x18, 0x0, 0x0, 0x2d, 0xec, 0x27, 0x0, 0x0, 0x19, 0x10, 0x26, 0x0, 0x0, 0x0, 0x3, 0x38, - 0x9, 0xb4, 0x8, 0x0, 0x1, 0x87, 0x23, 0x1f, 0xee, 0x1, 0xec, 0x28, 0xf3, 0x23, 0x69, 0x44, 0x22, 0x5b, 0x77, - 0xb, 0x6, 0x29, 0x89, 0x1c, 0x0, 0x5, 0xd1, 0x11, 0xe9, 0xe6, 0x4f, 0x23, 0x35, 0xa7, 0x0, 0x3, 0x73, 0x3, - 0x4e, 0x2, 0xb, 0x14, 0x0, 0x1d, 0xd1, 0xc2, 0x25, 0xfb, 0x52, 0x3, 0x25, 0x33, 0x18, 0x88, 0xae, 0xa7, 0xa9, - 0x8b, 0xa7, 0xba, 0x43, 0x29, 0xb8, 0x2a, 0x6e, 0x9a, 0x17, 0x6d, 0x47, 0xd1, 0x54, 0xba, 0x11, 0x0, 0x17, 0x23, - 0x79, 0x70, 0x28, 0x23, 0x21, 0x3e, 0xc4, 0x4f, 0xf7, 0x11, 0xb0, 0xfd, 0x96, 0xee, 0xd6, 0xd8, 0xd4, 0x66, 0xa1, - 0x58, 0x6c, 0x9, 0x0, 0xf, 0x8e, 0xa8, 0x12, 0x5a, 0x7, 0xe5, 0xff, 0xfa, 0xc0, 0xb1, 0x36, 0xac, 0xf0, 0x44, - 0x32, 0x0, 0xf, 0xd, 0x89, 0x17, 0x74, 0x52, 0x82, 0x43, 0x2a, 0x11, 0xdf, 0xca, 0xa9, 0x93, 0xc5, 0xe8}; - - uint8_t buf[294] = {0}; - - uint8_t bytesprops0[] = {0xfc, 0xc0, 0xc4, 0x22, 0xe6, 0x2f}; - uint8_t bytesprops1[] = {0xbd, 0xaf, 0x52, 0x89, 0x82, 0xd, 0xcb, 0x1a, 0xd, 0x4}; - uint8_t bytesprops2[] = {0xec, 0xa1, 0x54, 0x4f, 0x3e, 0x22, 0x90, 0xe9, 0x7c}; - uint8_t bytesprops3[] = {0xc2, 0xc7, 0x2d, 0x69, 0x97, 0xb, 0xdc, 0x1d, 0xea, 0x6c, 0xbd, 0xb0, - 0x9b, 0x94, 0xf0, 0x2a, 0x22, 0xed, 0x6a, 0xa5, 0x2b, 0xd4, 0xd, 0x55}; - uint8_t bytesprops4[] = {0xe3, 0x6b, 0x3e, 0xa0, 0xe, 0x79, 0x9d, 0xfb, 0xf3, 0x3b, 0x30, 0xc7, - 0xf2, 0xed, 0x5d, 0x9b, 0x3, 0x32, 0x22, 0x78, 0x8c, 0xad, 0x95, 0x98}; - uint8_t bytesprops6[] = {0x38, 0x9, 0xb4}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops7[] = {0x87}; - uint8_t bytesprops8[] = {0xd1, 0x11, 0xe9, 0xe6, 0x4f}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16667}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30002}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21381}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24570}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26398}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25296}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22383}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11756}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6416}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops5}, .v = {3, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8174}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26948}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23415}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13735}}, - }; - - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - }; - - lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd1, 0xc2, 0x25, 0xfb, 0x52, 0x3, 0x25, 0x33, 0x18, 0x88, - 0xae, 0xa7, 0xa9, 0x8b, 0xa7, 0xba, 0x43, 0x29, 0xb8, 0x2a, - 0x6e, 0x9a, 0x17, 0x6d, 0x47, 0xd1, 0x54, 0xba, 0x11}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x23, 0x79, 0x70, 0x28, 0x23, 0x21, 0x3e, 0xc4, 0x4f, 0xf7, 0x11, 0xb0, - 0xfd, 0x96, 0xee, 0xd6, 0xd8, 0xd4, 0x66, 0xa1, 0x58, 0x6c, 0x9}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1871; - uint8_t client_id_bytes[] = {0x73, 0x3, 0x4e}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x8e, 0xa8, 0x12, 0x5a, 0x7, 0xe5, 0xff, 0xfa, 0xc0, 0xb1, 0x36, 0xac, 0xf0, 0x44, 0x32}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd, 0x89, 0x17, 0x74, 0x52, 0x82, 0x43, 0x2a, 0x11, 0xdf, 0xca, 0xa9, 0x93, 0xc5, 0xe8}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "^t\USER\139\244\152'\220\244", _willMsg = -// "\199\STX\191\&2ISE$\SOH}\221O\DC3,P\242\185\245\181\192\\\237\251p\237\247\198\203", _willProps = [PropUserProperty -// "qR" "\217)\202\185n\ESC\224\146p\176\128C\202E\EOT\135",PropAuthenticationData -// "\200\250\191\184\228\224\234\149\NULCz,\175\251\SOH}G\187",PropMaximumPacketSize 30947]}), _cleanSession = False, -// _keepAlive = 13191, _connID = "\152G\DC3\220\161\183\214\153L\231", _properties = [PropWildcardSubscriptionAvailable -// 209,PropMaximumPacketSize 10805,PropMaximumQoS 99,PropAssignedClientIdentifier -// "\EOT\221\142]!)\188\DEL\191\178\218",PropResponseInformation -// "\134j.\213,\200\203\248\133q\249E{\191\240,\146N\166",PropAuthenticationMethod -// "\156\ETX",PropAssignedClientIdentifier "\175\214",PropTopicAliasMaximum 1901,PropCorrelationData -// "\150D\SI\160\&8\ENQ"]} -TEST(Connect5QCTest, Encode63) { - uint8_t pkt[] = {0x10, 0xb7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc, 0x33, 0x87, 0x43,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f, 0xbf, 0xb2, 0xda}; - uint8_t bytesprops1[] = {0x86, 0x6a, 0x2e, 0xd5, 0x2c, 0xc8, 0xcb, 0xf8, 0x85, 0x71, - 0xf9, 0x45, 0x7b, 0xbf, 0xf0, 0x2c, 0x92, 0x4e, 0xa6}; - uint8_t bytesprops2[] = {0x9c, 0x3}; - uint8_t bytesprops3[] = {0xaf, 0xd6}; - uint8_t bytesprops4[] = {0x96, 0x44, 0xf, 0xa0, 0x38, 0x5}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10805}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1901}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops4}}}, - }; - - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xd9, 0x29, 0xca, 0xb9, 0x6e, 0x1b, 0xe0, 0x92, - 0x70, 0xb0, 0x80, 0x43, 0xca, 0x45, 0x4, 0x87}; - uint8_t byteswillprops0[] = {0x71, 0x52}; - uint8_t byteswillprops2[] = {0xc8, 0xfa, 0xbf, 0xb8, 0xe4, 0xe0, 0xea, 0x95, 0x0, - 0x43, 0x7a, 0x2c, 0xaf, 0xfb, 0x1, 0x7d, 0x47, 0xbb}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {2, (char*)&byteswillprops0}, .v = {16, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30947}}, - }; - - lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5e, 0x74, 0x1f, 0x45, 0x52, 0x8b, 0xf4, 0x98, 0x27, 0xdc, 0xf4}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc7, 0x2, 0xbf, 0x32, 0x49, 0x53, 0x45, 0x24, 0x1, 0x7d, 0xdd, 0x4f, 0x13, 0x2c, - 0x50, 0xf2, 0xb9, 0xf5, 0xb5, 0xc0, 0x5c, 0xed, 0xfb, 0x70, 0xed, 0xf7, 0xc6, 0xcb}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 13191; - uint8_t client_id_bytes[] = {0x98, 0x47, 0x13, 0xdc, 0xa1, 0xb7, 0xd6, 0x99, 0x4c, 0xe7}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "4\159\162&\FS(\185Vz\159#", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\178\222\199o\DLE`0%\253\145qK;\128\218", _willMsg = -// "\130\&9Pt\tC\201\176\147", _willProps = [PropRetainAvailable 148,PropServerKeepAlive -// 2497,PropWildcardSubscriptionAvailable 254,PropRetainAvailable 116,PropMaximumQoS 37,PropAuthenticationMethod -// "\137{\FS\CAN",PropTopicAlias 3471,PropTopicAliasMaximum 29487,PropCorrelationData -// "\ESC\130/\145\130\&0\206\198N",PropTopicAliasMaximum 2890,PropServerReference -// "J\NUL`\250\238\230\160\210B",PropSessionExpiryInterval 17715,PropCorrelationData -// "\\\192\197\&6\245\181h\147+\205\228s\248\229\EOTI\243P\175\185",PropAuthenticationData -// ";{F\167\DC4%F\222\DC4\170\204\217\SYNj\206h\ACK\141\235\198$\193\DEL\209)~-",PropAssignedClientIdentifier -// "\151\136\RS",PropTopicAlias 9534,PropMaximumQoS 98,PropResponseTopic -// "\ACKvI\186\202\141\176#\199\218\DC3\223R\189\220\208\&6\180QR\231\148\189\182",PropSharedSubscriptionAvailable -// 238,PropContentType "\RS.\n\EM;\187:\223Y\210D5[\171\171",PropResponseTopic -// "_x\a:\235?\174\248\146\154\CAN\131\255\&4"]}), _cleanSession = False, _keepAlive = 3727, _connID = "\DEL\250\165", -// _properties = [PropReceiveMaximum 2641,PropRetainAvailable 87,PropRetainAvailable 235,PropMessageExpiryInterval -// 9273,PropSubscriptionIdentifierAvailable 25,PropSubscriptionIdentifierAvailable 10,PropSharedSubscriptionAvailable -// 20,PropMessageExpiryInterval 6127,PropSubscriptionIdentifierAvailable 248,PropServerReference "\184\231\164\139"]} -TEST(Connect5QCTest, Encode64) { - uint8_t pkt[] = { - 0x10, 0x86, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x34, 0xe, 0x8f, 0x20, 0x21, 0xa, 0x51, 0x25, 0x57, - 0x25, 0xeb, 0x2, 0x0, 0x0, 0x24, 0x39, 0x29, 0x19, 0x29, 0xa, 0x2a, 0x14, 0x2, 0x0, 0x0, 0x17, 0xef, 0x29, - 0xf8, 0x1c, 0x0, 0x4, 0xb8, 0xe7, 0xa4, 0x8b, 0x0, 0x3, 0x7f, 0xfa, 0xa5, 0xb8, 0x1, 0x25, 0x94, 0x13,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x10, 0x60, 0x30, 0x25, - 0xfd, 0x91, 0x71, 0x4b, 0x3b, 0x80, 0xda, 0x0, 0x9, 0x82, 0x39, 0x50, 0x74, 0x9, 0x43, 0xc9, 0xb0, 0x93}; - - uint8_t buf[275] = {0}; - - uint8_t bytesprops0[] = {0xb8, 0xe7, 0xa4, 0x8b}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2641}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9273}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6127}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops0}}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x89, 0x7b, 0x1c, 0x18}; - uint8_t byteswillprops1[] = {0x1b, 0x82, 0x2f, 0x91, 0x82, 0x30, 0xce, 0xc6, 0x4e}; - uint8_t byteswillprops2[] = {0x4a, 0x0, 0x60, 0xfa, 0xee, 0xe6, 0xa0, 0xd2, 0x42}; - uint8_t byteswillprops3[] = {0x5c, 0xc0, 0xc5, 0x36, 0xf5, 0xb5, 0x68, 0x93, 0x2b, 0xcd, - 0xe4, 0x73, 0xf8, 0xe5, 0x4, 0x49, 0xf3, 0x50, 0xaf, 0xb9}; - uint8_t byteswillprops4[] = {0x3b, 0x7b, 0x46, 0xa7, 0x14, 0x25, 0x46, 0xde, 0x14, 0xaa, 0xcc, 0xd9, 0x16, 0x6a, - 0xce, 0x68, 0x6, 0x8d, 0xeb, 0xc6, 0x24, 0xc1, 0x7f, 0xd1, 0x29, 0x7e, 0x2d}; - uint8_t byteswillprops5[] = {0x97, 0x88, 0x1e}; - uint8_t byteswillprops6[] = {0x6, 0x76, 0x49, 0xba, 0xca, 0x8d, 0xb0, 0x23, 0xc7, 0xda, 0x13, 0xdf, - 0x52, 0xbd, 0xdc, 0xd0, 0x36, 0xb4, 0x51, 0x52, 0xe7, 0x94, 0xbd, 0xb6}; - uint8_t byteswillprops7[] = {0x1e, 0x2e, 0xa, 0x19, 0x3b, 0xbb, 0x3a, 0xdf, 0x59, 0xd2, 0x44, 0x35, 0x5b, 0xab, 0xab}; - uint8_t byteswillprops8[] = {0x5f, 0x78, 0x7, 0x3a, 0xeb, 0x3f, 0xae, 0xf8, 0x92, 0x9a, 0x18, 0x83, 0xff, 0x34}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2497}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3471}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29487}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2890}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17715}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9534}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&byteswillprops8}}}, - }; - - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb2, 0xde, 0xc7, 0x6f, 0x10, 0x60, 0x30, 0x25, - 0xfd, 0x91, 0x71, 0x4b, 0x3b, 0x80, 0xda}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x82, 0x39, 0x50, 0x74, 0x9, 0x43, 0xc9, 0xb0, 0x93}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3727; - uint8_t client_id_bytes[] = {0x7f, 0xfa, 0xa5}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x34, 0x9f, 0xa2, 0x26, 0x1c, 0x28, 0xb9, 0x56, 0x7a, 0x9f, 0x23}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\RSt\221\140\178\180\155#r\255\&3\212\203w\206\137L\202\190\SUB G\227\FS", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "~^x\SYN6\181\252#\192\a\231\220>\DC2e\NAK", _willMsg = -// "\202S\US{\160\165\GS\f\165\SUB\183D\191\212\150\157\f\SUBwj\204\SYN\167\237\251\161\189", _willProps = -// [PropMaximumPacketSize 31654,PropMaximumPacketSize 2463,PropUserProperty -// "W\171\240\137+\250\199\243\137\ACKQ\177\143\216=\"\DEL\138T5\204E" -// "7\162\169\173\246QV\ENQ\245\239gw\207z\201\180\142RW+\219|i\180\194\b\194",PropTopicAlias -// 20921,PropWillDelayInterval 24817,PropReasonString -// "R\219s\190JX\ESC\164w\148~\CAN\226Bi<\228\EM\232P\135o'\171\178\143\DEL\\",PropReceiveMaximum -// 26593,PropCorrelationData ":A\187\149\178\&7\145\220\DC2\166)U}7\252F\130\151\208T\183s",PropMessageExpiryInterval -// 29335,PropPayloadFormatIndicator 77,PropSharedSubscriptionAvailable 25,PropWildcardSubscriptionAvailable -// 26,PropServerReference -// "\FS\190\152\209\&0\SO\SOH\176\241\fj\244\DEL\155\172\STX\n\t\149\180G\SOH:xj\254\&5\237k",PropCorrelationData -// "\194\238\209\SI\190\238R\138\236\240\175z",PropServerReference "v\146v",PropMessageExpiryInterval -// 22045,PropRequestResponseInformation 214,PropTopicAliasMaximum 29161,PropRequestResponseInformation -// 180,PropWildcardSubscriptionAvailable 170,PropSessionExpiryInterval 27399]}), _cleanSession = False, _keepAlive = -// 3670, _connID = "H\SI\178\231o\172\&9\153", _properties = [PropResponseInformation -// "H\179p8\ETX\137zM\223\202\250\177\v\ETB=\197\201-\r\225\185",PropMaximumPacketSize 15938,PropServerReference -// "\DC2\227\184\137\232-\210\151\&5\163\171\201\v\207|:\DLE\223\183\243%",PropTopicAliasMaximum -// 14229,PropWillDelayInterval 13002,PropMaximumPacketSize 6555,PropRequestProblemInformation 143,PropAuthenticationData -// "",PropRetainAvailable 54]} -TEST(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0x9b, 0x23, 0x72, 0xff, 0x33, 0xd4, 0xcb, 0x77, 0xce, 0x89, 0x4c, 0xca, - 0xbe, 0x1a, 0x20, 0x47, 0xe3, 0x1c}; - - uint8_t buf[396] = {0}; - - uint8_t bytesprops0[] = {0x48, 0xb3, 0x70, 0x38, 0x3, 0x89, 0x7a, 0x4d, 0xdf, 0xca, 0xfa, - 0xb1, 0xb, 0x17, 0x3d, 0xc5, 0xc9, 0x2d, 0xd, 0xe1, 0xb9}; - uint8_t bytesprops1[] = {0x12, 0xe3, 0xb8, 0x89, 0xe8, 0x2d, 0xd2, 0x97, 0x35, 0xa3, 0xab, - 0xc9, 0xb, 0xcf, 0x7c, 0x3a, 0x10, 0xdf, 0xb7, 0xf3, 0x25}; - uint8_t bytesprops2[] = {0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15938}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14229}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13002}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6555}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 54}}, - }; - - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x37, 0xa2, 0xa9, 0xad, 0xf6, 0x51, 0x56, 0x5, 0xf5, 0xef, 0x67, 0x77, 0xcf, 0x7a, - 0xc9, 0xb4, 0x8e, 0x52, 0x57, 0x2b, 0xdb, 0x7c, 0x69, 0xb4, 0xc2, 0x8, 0xc2}; - uint8_t byteswillprops0[] = {0x57, 0xab, 0xf0, 0x89, 0x2b, 0xfa, 0xc7, 0xf3, 0x89, 0x6, 0x51, - 0xb1, 0x8f, 0xd8, 0x3d, 0x22, 0x7f, 0x8a, 0x54, 0x35, 0xcc, 0x45}; - uint8_t byteswillprops2[] = {0x52, 0xdb, 0x73, 0xbe, 0x4a, 0x58, 0x1b, 0xa4, 0x77, 0x94, 0x7e, 0x18, 0xe2, 0x42, - 0x69, 0x3c, 0xe4, 0x19, 0xe8, 0x50, 0x87, 0x6f, 0x27, 0xab, 0xb2, 0x8f, 0x7f, 0x5c}; - uint8_t byteswillprops3[] = {0x3a, 0x41, 0xbb, 0x95, 0xb2, 0x37, 0x91, 0xdc, 0x12, 0xa6, 0x29, - 0x55, 0x7d, 0x37, 0xfc, 0x46, 0x82, 0x97, 0xd0, 0x54, 0xb7, 0x73}; - uint8_t byteswillprops4[] = {0x1c, 0xbe, 0x98, 0xd1, 0x30, 0xe, 0x1, 0xb0, 0xf1, 0xc, 0x6a, 0xf4, 0x7f, 0x9b, 0xac, - 0x2, 0xa, 0x9, 0x95, 0xb4, 0x47, 0x1, 0x3a, 0x78, 0x6a, 0xfe, 0x35, 0xed, 0x6b}; - uint8_t byteswillprops5[] = {0xc2, 0xee, 0xd1, 0xf, 0xbe, 0xee, 0x52, 0x8a, 0xec, 0xf0, 0xaf, 0x7a}; - uint8_t byteswillprops6[] = {0x76, 0x92, 0x76}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31654}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2463}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {22, (char*)&byteswillprops0}, .v = {27, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20921}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24817}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26593}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29335}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22045}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29161}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27399}}, - }; - - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x7e, 0x5e, 0x78, 0x16, 0x36, 0xb5, 0xfc, 0x23, - 0xc0, 0x7, 0xe7, 0xdc, 0x3e, 0x12, 0x65, 0x15}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xca, 0x53, 0x1f, 0x7b, 0xa0, 0xa5, 0x1d, 0xc, 0xa5, 0x1a, 0xb7, 0x44, 0xbf, 0xd4, - 0x96, 0x9d, 0xc, 0x1a, 0x77, 0x6a, 0xcc, 0x16, 0xa7, 0xed, 0xfb, 0xa1, 0xbd}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3670; - uint8_t client_id_bytes[] = {0x48, 0xf, 0xb2, 0xe7, 0x6f, 0xac, 0x39, 0x99}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x1e, 0x74, 0xdd, 0x8c, 0xb2, 0xb4, 0x9b, 0x23, 0x72, 0xff, 0x33, 0xd4, - 0xcb, 0x77, 0xce, 0x89, 0x4c, 0xca, 0xbe, 0x1a, 0x20, 0x47, 0xe3, 0x1c}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\DC1M\180\r\a\252wp^bZ\135\DEL2@Z\253\165\DC2y\209\226r]\164", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "a\214\153~t\218\159\237r\222\195'\246(\175", _willMsg = "\224\207\248\\\EM\EM/u\n7rM\210", _willProps = -// [PropAuthenticationData "\182",PropMessageExpiryInterval 20665,PropAuthenticationData -// "\162DZ&_\160\142eRK(\236L\156\147\183\&7\224\rhZg",PropRequestResponseInformation 71,PropMessageExpiryInterval -// 20758,PropRequestResponseInformation 117,PropMessageExpiryInterval 10617,PropSharedSubscriptionAvailable -// 90,PropAuthenticationData "o.\150\152\253T\249\&0\201 -// H\210\211\198\185l\CAN\174Jpw\173\171\DC1r",PropAuthenticationData -// "CY\207w\154\136\231/",PropAssignedClientIdentifier -// "\211ImG\228\194\183\212D\143\180V\180`b\203\229",PropMessageExpiryInterval 26735]}), _cleanSession = True, -// _keepAlive = 15606, _connID = "\DC2O:m\245\197\216\200\\\t\162\221\172w\235d1\138\240\144\RSX%\208C\SOPC\199", -// _properties = [PropServerKeepAlive 13066,PropRetainAvailable 173,PropUserProperty -// "\203\219\190\n\207\189\160\151Gg>\225\159|\DC1\ETX\204\151\140\233\244" -// "\\\226\242\209\RS\255\191\182\218\241\SI<\168\216",PropTopicAliasMaximum 18576,PropContentType -// "z\r\252\147\233",PropContentType "|\241\151\190\134H\192T|;\v",PropMessageExpiryInterval 15714,PropReasonString -// "9\177\218w\243\US\202z\207\&3\135\&9\216\255\200l\ESCsT\246\133zf",PropTopicAlias 31604,PropRetainAvailable -// 206,PropWillDelayInterval 22587,PropReceiveMaximum 697,PropSubscriptionIdentifierAvailable 85,PropWillDelayInterval -// 15540]} -TEST(Connect5QCTest, Encode66) { - uint8_t pkt[] = { - 0x10, 0xb6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0x3c, 0xf6, 0x79, 0x13, 0x33, 0xa, 0x25, 0xad, - 0x26, 0x0, 0x15, 0xcb, 0xdb, 0xbe, 0xa, 0xcf, 0xbd, 0xa0, 0x97, 0x47, 0x67, 0x3e, 0xe1, 0x9f, 0x7c, 0x11, 0x3, - 0xcc, 0x97, 0x8c, 0xe9, 0xf4, 0x0, 0xe, 0x5c, 0xe2, 0xf2, 0xd1, 0x1e, 0xff, 0xbf, 0xb6, 0xda, 0xf1, 0xf, 0x3c, - 0xa8, 0xd8, 0x22, 0x48, 0x90, 0x3, 0x0, 0x5, 0x7a, 0xd, 0xfc, 0x93, 0xe9, 0x3, 0x0, 0xb, 0x7c, 0xf1, 0x97, - 0xbe, 0x86, 0x48, 0xc0, 0x54, 0x7c, 0x3b, 0xb, 0x2, 0x0, 0x0, 0x3d, 0x62, 0x1f, 0x0, 0x17, 0x39, 0xb1, 0xda, - 0x77, 0xf3, 0x1f, 0xca, 0x7a, 0xcf, 0x33, 0x87, 0x39, 0xd8, 0xff, 0xc8, 0x6c, 0x1b, 0x73, 0x54, 0xf6, 0x85, 0x7a, - 0x66, 0x23, 0x7b, 0x74, 0x25, 0xce, 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0xa, 0x37, 0x72, 0x4d, 0xd2}; - - uint8_t buf[323] = {0}; - - uint8_t bytesprops1[] = {0x5c, 0xe2, 0xf2, 0xd1, 0x1e, 0xff, 0xbf, 0xb6, 0xda, 0xf1, 0xf, 0x3c, 0xa8, 0xd8}; - uint8_t bytesprops0[] = {0xcb, 0xdb, 0xbe, 0xa, 0xcf, 0xbd, 0xa0, 0x97, 0x47, 0x67, 0x3e, - 0xe1, 0x9f, 0x7c, 0x11, 0x3, 0xcc, 0x97, 0x8c, 0xe9, 0xf4}; - uint8_t bytesprops2[] = {0x7a, 0xd, 0xfc, 0x93, 0xe9}; - uint8_t bytesprops3[] = {0x7c, 0xf1, 0x97, 0xbe, 0x86, 0x48, 0xc0, 0x54, 0x7c, 0x3b, 0xb}; - uint8_t bytesprops4[] = {0x39, 0xb1, 0xda, 0x77, 0xf3, 0x1f, 0xca, 0x7a, 0xcf, 0x33, 0x87, 0x39, - 0xd8, 0xff, 0xc8, 0x6c, 0x1b, 0x73, 0x54, 0xf6, 0x85, 0x7a, 0x66}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13066}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops0}, .v = {14, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18576}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15714}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31604}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22587}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 697}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15540}}, - }; - - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xb6}; - uint8_t byteswillprops1[] = {0xa2, 0x44, 0x5a, 0x26, 0x5f, 0xa0, 0x8e, 0x65, 0x52, 0x4b, 0x28, - 0xec, 0x4c, 0x9c, 0x93, 0xb7, 0x37, 0xe0, 0xd, 0x68, 0x5a, 0x67}; - uint8_t byteswillprops2[] = {0x6f, 0x2e, 0x96, 0x98, 0xfd, 0x54, 0xf9, 0x30, 0xc9, 0x20, 0x48, 0xd2, 0xd3, - 0xc6, 0xb9, 0x6c, 0x18, 0xae, 0x4a, 0x70, 0x77, 0xad, 0xab, 0x11, 0x72}; - uint8_t byteswillprops3[] = {0x43, 0x59, 0xcf, 0x77, 0x9a, 0x88, 0xe7, 0x2f}; - uint8_t byteswillprops4[] = {0xd3, 0x49, 0x6d, 0x47, 0xe4, 0xc2, 0xb7, 0xd4, 0x44, - 0x8f, 0xb4, 0x56, 0xb4, 0x60, 0x62, 0xcb, 0xe5}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20665}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20758}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10617}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26735}}, - }; - - lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x61, 0xd6, 0x99, 0x7e, 0x74, 0xda, 0x9f, 0xed, - 0x72, 0xde, 0xc3, 0x27, 0xf6, 0x28, 0xaf}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe0, 0xcf, 0xf8, 0x5c, 0x19, 0x19, 0x2f, 0x75, 0xa, 0x37, 0x72, 0x4d, 0xd2}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 15606; - uint8_t client_id_bytes[] = {0x12, 0x4f, 0x3a, 0x6d, 0xf5, 0xc5, 0xd8, 0xc8, 0x5c, 0x9, 0xa2, 0xdd, 0xac, 0x77, 0xeb, - 0x64, 0x31, 0x8a, 0xf0, 0x90, 0x1e, 0x58, 0x25, 0xd0, 0x43, 0xe, 0x50, 0x43, 0xc7}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x11, 0x4d, 0xb4, 0xd, 0x7, 0xfc, 0x77, 0x70, 0x5e, 0x62, 0x5a, 0x87, 0x7f, - 0x32, 0x40, 0x5a, 0xfd, 0xa5, 0x12, 0x79, 0xd1, 0xe2, 0x72, 0x5d, 0xa4}; - lwmqtt_string_t password = {25, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "7y&\a\226\163R-*\143C\172?T4\174\227\&4$\202\150\&2\DLE\231\243", _password = -// Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = 6271, _connID = -// "\193=\232\&0\251\248\&3\179\238?E\142", _properties = [PropTopicAlias 12909,PropAssignedClientIdentifier -// "\DC2\244KT\188\SYN\203\b\224\233\EMB\158e\174",PropTopicAliasMaximum 26424,PropSubscriptionIdentifier -// 24,PropAuthenticationData "\177#C\232E\164\208\147\247Y\186\172*m",PropCorrelationData "\192\219@\GS\208?\213 -// Td7a",PropRetainAvailable 9,PropSessionExpiryInterval 13511,PropSessionExpiryInterval 7047,PropPayloadFormatIndicator -// 58,PropMaximumQoS 42,PropMessageExpiryInterval 20638,PropSharedSubscriptionAvailable 173,PropResponseInformation -// "\130\249\156\145\DC1FY\137\192\f\134\231\179\ACK\216\EM\237\217#\DC2L\251\DLE\161WA",PropWildcardSubscriptionAvailable -// 121,PropWillDelayInterval 7128,PropServerReference -// "\136\203\131\142xEw\179J\202Yg\218\231HT\249\180\GS\140\229C\DC3\233",PropCorrelationData -// "\143m\143\"\220\142",PropRequestResponseInformation 127,PropAuthenticationMethod "",PropResponseInformation -// "",PropRequestProblemInformation 149,PropServerKeepAlive 1854,PropServerReference -// "\159\152)\128\STXxK\140\153uC\225Y^o\254",PropAssignedClientIdentifier -// "\bLg\183\252w\212o\212\164V\203\EOT*y\145D$\211\DC3\183\238\185[h\167M\SYN",PropSharedSubscriptionAvailable -// 99,PropCorrelationData "\146\&1\"\157\143#|\135\237\179( -// E\DEL\203\199\163ae\172\162\130l\209\218c|\226\a",PropMaximumPacketSize 13527,PropTopicAlias -// 20115,PropSubscriptionIdentifierAvailable 130]} -TEST(Connect5QCTest, Encode67) { - uint8_t pkt[] = { - 0x10, 0xb9, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54,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x5e, 0x6f, 0xfe, 0x12, 0x0, 0x1c, 0x8, 0x4c, 0x67, 0xb7, 0xfc, 0x77, - 0xd4, 0x6f, 0xd4, 0xa4, 0x56, 0xcb, 0x4, 0x2a, 0x79, 0x91, 0x44, 0x24, 0xd3, 0x13, 0xb7, 0xee, 0xb9, 0x5b, 0x68, - 0xa7, 0x4d, 0x16, 0x2a, 0x63, 0x9, 0x0, 0x1d, 0x92, 0x31, 0x22, 0x9d, 0x8f, 0x23, 0x7c, 0x87, 0xed, 0xb3, 0x28, - 0x20, 0x45, 0x7f, 0xcb, 0xc7, 0xa3, 0x61, 0x65, 0xac, 0xa2, 0x82, 0x6c, 0xd1, 0xda, 0x63, 0x7c, 0xe2, 0x7, 0x27, - 0x0, 0x0, 0x34, 0xd7, 0x23, 0x4e, 0x93, 0x29, 0x82, 0x0, 0xc, 0xc1, 0x3d, 0xe8, 0x30, 0xfb, 0xf8, 0x33, 0xb3, - 0xee, 0x3f, 0x45, 0x8e, 0x0, 0x19, 0x37, 0x79, 0x26, 0x7, 0xe2, 0xa3, 0x52, 0x2d, 0x2a, 0x8f, 0x43, 0xac, 0x3f, - 0x54, 0x34, 0xae, 0xe3, 0x34, 0x24, 0xca, 0x96, 0x32, 0x10, 0xe7, 0xf3}; - - uint8_t buf[326] = {0}; - - uint8_t bytesprops0[] = {0x12, 0xf4, 0x4b, 0x54, 0xbc, 0x16, 0xcb, 0x8, 0xe0, 0xe9, 0x19, 0x42, 0x9e, 0x65, 0xae}; - uint8_t bytesprops1[] = {0xb1, 0x23, 0x43, 0xe8, 0x45, 0xa4, 0xd0, 0x93, 0xf7, 0x59, 0xba, 0xac, 0x2a, 0x6d}; - uint8_t bytesprops2[] = {0xc0, 0xdb, 0x40, 0x1d, 0xd0, 0x3f, 0xd5, 0x20, 0x54, 0x64, 0x37, 0x61}; - uint8_t bytesprops3[] = {0x82, 0xf9, 0x9c, 0x91, 0x11, 0x46, 0x59, 0x89, 0xc0, 0xc, 0x86, 0xe7, 0xb3, - 0x6, 0xd8, 0x19, 0xed, 0xd9, 0x23, 0x12, 0x4c, 0xfb, 0x10, 0xa1, 0x57, 0x41}; - uint8_t bytesprops4[] = {0x88, 0xcb, 0x83, 0x8e, 0x78, 0x45, 0x77, 0xb3, 0x4a, 0xca, 0x59, 0x67, - 0xda, 0xe7, 0x48, 0x54, 0xf9, 0xb4, 0x1d, 0x8c, 0xe5, 0x43, 0x13, 0xe9}; - uint8_t bytesprops5[] = {0x8f, 0x6d, 0x8f, 0x22, 0xdc, 0x8e}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops8[] = {0x9f, 0x98, 0x29, 0x80, 0x2, 0x78, 0x4b, 0x8c, - 0x99, 0x75, 0x43, 0xe1, 0x59, 0x5e, 0x6f, 0xfe}; - uint8_t bytesprops9[] = {0x8, 0x4c, 0x67, 0xb7, 0xfc, 0x77, 0xd4, 0x6f, 0xd4, 0xa4, 0x56, 0xcb, 0x4, 0x2a, - 0x79, 0x91, 0x44, 0x24, 0xd3, 0x13, 0xb7, 0xee, 0xb9, 0x5b, 0x68, 0xa7, 0x4d, 0x16}; - uint8_t bytesprops10[] = {0x92, 0x31, 0x22, 0x9d, 0x8f, 0x23, 0x7c, 0x87, 0xed, 0xb3, 0x28, 0x20, 0x45, 0x7f, 0xcb, - 0xc7, 0xa3, 0x61, 0x65, 0xac, 0xa2, 0x82, 0x6c, 0xd1, 0xda, 0x63, 0x7c, 0xe2, 0x7}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12909}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26424}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13511}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7047}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20638}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7128}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1854}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13527}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20115}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, - }; - - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 6271; - uint8_t client_id_bytes[] = {0xc1, 0x3d, 0xe8, 0x30, 0xfb, 0xf8, 0x33, 0xb3, 0xee, 0x3f, 0x45, 0x8e}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x37, 0x79, 0x26, 0x7, 0xe2, 0xa3, 0x52, 0x2d, 0x2a, 0x8f, 0x43, 0xac, 0x3f, - 0x54, 0x34, 0xae, 0xe3, 0x34, 0x24, 0xca, 0x96, 0x32, 0x10, 0xe7, 0xf3}; - lwmqtt_string_t username = {25, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\NAK=\230S\192\217KW\211\176\174\190\213\179a\138\ENQR\222", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\218\251\CAN\137\184\196\247\&0u\SYNZ", _willMsg = "\140\162\226\246\\\158,\b\141\157Z$+", _willProps = -// [PropAuthenticationMethod "!Y\246\135\136\194 \233\208om\171[$\131TI\CANr\227",PropSessionExpiryInterval -// 15018,PropRetainAvailable 75,PropPayloadFormatIndicator 193,PropReceiveMaximum 24624,PropTopicAlias -// 1393,PropCorrelationData "\153 <\241\DC1\244\177=]\157\218\NUL(\EOTC",PropCorrelationData -// "sn\RS'\227\b/\141\210DO?\230\171\NAK%\162\195\220B\253",PropAuthenticationData -// "1\ETX2\154\237\146\183\217\158\163",PropAssignedClientIdentifier -// "\196\ENQ\128\254\153\169",PropRequestResponseInformation 65,PropReasonString "\203\183",PropAssignedClientIdentifier -// "",PropServerKeepAlive 7567,PropMessageExpiryInterval 10027,PropWillDelayInterval 4878,PropContentType -// "@/\NUL\169",PropRequestResponseInformation 210,PropResponseTopic -// "\218\ETB\204\254\207u\132\229\144\133\213\134}DDsl",PropCorrelationData -// "\196\240U\248",PropWildcardSubscriptionAvailable 42,PropTopicAlias 28909,PropSubscriptionIdentifierAvailable -// 10,PropCorrelationData "\184\&8Z\163\\\t\154\160D\ACK\190\133\154\151",PropAuthenticationMethod -// "S\175V\175\191\181\226\206\186\DC4\254\155\134W\178\255",PropResponseInformation -// "\238+&\227\235eg\189\133Q7D\CAN\DC1\147\188\158\170\251\159x\236\234\&8N\146n"]}), _cleanSession = False, _keepAlive -// = 18470, _connID = "\145\177\179\193o\203\219\238Y:\131\b\140\246\195\211\214\210p\177", _properties = -// [PropAssignedClientIdentifier ""]} -TEST(Connect5QCTest, Encode68) { - uint8_t pkt[] = { - 0x10, 0xac, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x24, 0x48, 0x26, 0x3, 0x12, 0x0, 0x0, 0x0, 0x14, - 0x91, 0xb1, 0xb3, 0xc1, 0x6f, 0xcb, 0xdb, 0xee, 0x59, 0x3a, 0x83, 0x8, 0x8c, 0xf6, 0xc3, 0xd3, 0xd6, 0xd2, 0x70, - 0xb1, 0xea, 0x1, 0x15, 0x0, 0x14, 0x21, 0x59, 0xf6, 0x87, 0x88, 0xc2, 0x20, 0xe9, 0xd0, 0x6f, 0x6d, 0xab, 0x5b, - 0x24, 0x83, 0x54, 0x49, 0x18, 0x72, 0xe3, 0x11, 0x0, 0x0, 0x3a, 0xaa, 0x25, 0x4b, 0x1, 0xc1, 0x21, 0x60, 0x30, - 0x23, 0x5, 0x71, 0x9, 0x0, 0xf, 0x99, 0x20, 0x3c, 0xf1, 0x11, 0xf4, 0xb1, 0x3d, 0x5d, 0x9d, 0xda, 0x0, 0x28, - 0x4, 0x43, 0x9, 0x0, 0x15, 0x73, 0x6e, 0x1e, 0x27, 0xe3, 0x8, 0x2f, 0x8d, 0xd2, 0x44, 0x4f, 0x3f, 0xe6, 0xab, - 0x15, 0x25, 0xa2, 0xc3, 0xdc, 0x42, 0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props0[] = {0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, - }; - - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x21, 0x59, 0xf6, 0x87, 0x88, 0xc2, 0x20, 0xe9, 0xd0, 0x6f, - 0x6d, 0xab, 0x5b, 0x24, 0x83, 0x54, 0x49, 0x18, 0x72, 0xe3}; - uint8_t byteswillprops1[] = {0x99, 0x20, 0x3c, 0xf1, 0x11, 0xf4, 0xb1, 0x3d, 0x5d, 0x9d, 0xda, 0x0, 0x28, 0x4, 0x43}; - uint8_t byteswillprops2[] = {0x73, 0x6e, 0x1e, 0x27, 0xe3, 0x8, 0x2f, 0x8d, 0xd2, 0x44, 0x4f, - 0x3f, 0xe6, 0xab, 0x15, 0x25, 0xa2, 0xc3, 0xdc, 0x42, 0xfd}; - uint8_t byteswillprops3[] = {0x31, 0x3, 0x32, 0x9a, 0xed, 0x92, 0xb7, 0xd9, 0x9e, 0xa3}; - uint8_t byteswillprops4[] = {0xc4, 0x5, 0x80, 0xfe, 0x99, 0xa9}; - uint8_t byteswillprops5[] = {0xcb, 0xb7}; - uint8_t byteswillprops6[] = {0}; - uint8_t byteswillprops7[] = {0x40, 0x2f, 0x0, 0xa9}; - uint8_t byteswillprops8[] = {0xda, 0x17, 0xcc, 0xfe, 0xcf, 0x75, 0x84, 0xe5, 0x90, - 0x85, 0xd5, 0x86, 0x7d, 0x44, 0x44, 0x73, 0x6c}; - uint8_t byteswillprops9[] = {0xc4, 0xf0, 0x55, 0xf8}; - uint8_t byteswillprops10[] = {0xb8, 0x38, 0x5a, 0xa3, 0x5c, 0x9, 0x9a, 0xa0, 0x44, 0x6, 0xbe, 0x85, 0x9a, 0x97}; - uint8_t byteswillprops11[] = {0x53, 0xaf, 0x56, 0xaf, 0xbf, 0xb5, 0xe2, 0xce, - 0xba, 0x14, 0xfe, 0x9b, 0x86, 0x57, 0xb2, 0xff}; - uint8_t byteswillprops12[] = {0xee, 0x2b, 0x26, 0xe3, 0xeb, 0x65, 0x67, 0xbd, 0x85, 0x51, 0x37, 0x44, 0x18, 0x11, - 0x93, 0xbc, 0x9e, 0xaa, 0xfb, 0x9f, 0x78, 0xec, 0xea, 0x38, 0x4e, 0x92, 0x6e}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15018}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24624}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1393}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7567}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10027}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4878}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28909}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops12}}}, - }; - - lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xda, 0xfb, 0x18, 0x89, 0xb8, 0xc4, 0xf7, 0x30, 0x75, 0x16, 0x5a}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x8c, 0xa2, 0xe2, 0xf6, 0x5c, 0x9e, 0x2c, 0x8, 0x8d, 0x9d, 0x5a, 0x24, 0x2b}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 18470; - uint8_t client_id_bytes[] = {0x91, 0xb1, 0xb3, 0xc1, 0x6f, 0xcb, 0xdb, 0xee, 0x59, 0x3a, - 0x83, 0x8, 0x8c, 0xf6, 0xc3, 0xd3, 0xd6, 0xd2, 0x70, 0xb1}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x15, 0x3d, 0xe6, 0x53, 0xc0, 0xd9, 0x4b, 0x57, 0xd3, 0xb0, - 0xae, 0xbe, 0xd5, 0xb3, 0x61, 0x8a, 0x5, 0x52, 0xde}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\SOH\253\128h\214\136>\244<\255\153", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "n\221.g\231\209[a*n'\214al\147\241$\175'-J\140\217\175\152\130\155\232", _willMsg = -// "\US\161\236\DC2\138\211_\ESC\244", _willProps = [PropTopicAlias 27954,PropSubscriptionIdentifier -// 12,PropAuthenticationData "\186(J",PropUserProperty "" ";\235\\\DC1\146\255\185\ACK",PropTopicAliasMaximum -// 18528,PropReasonString -// "\167G\198\a\249\150\184\195\210\130\249\SUB\206\DEL\249m\185:\182\224\177\254",PropUserProperty "i4\n\232iz\191\GS" -// ">\232)\SOv\v\rF\199G\DC1l9\224.\251",PropRequestResponseInformation 102,PropCorrelationData -// "\210\223\183\209\SYNz(i\164\159 ym\206\170\224\175\233:/\165\172Y\183X\r&}0",PropTopicAlias -// 4523,PropMessageExpiryInterval 15484,PropResponseTopic -// "B\SUB\181\202\154-\165\157\239`\150(\166\201\146",PropCorrelationData "\207\220\167\172\FS",PropUserProperty -// "\235\209\255\154C\DC1\155K/\DLE\183d7Ib\167J\128\&9" "\192\190\DC3\237\199",PropServerReference -// "\n$\GS\184g#",PropPayloadFormatIndicator 230,PropServerKeepAlive 2306,PropSharedSubscriptionAvailable 103]}), -// _cleanSession = True, _keepAlive = 9181, _connID = "M\156\DC4\133Z\205\NAK&", _properties = [PropResponseInformation -// "qg\170\DEL\192\194V\130<\226U\139\166\&5\"Qp",PropSubscriptionIdentifierAvailable 60,PropServerKeepAlive -// 2214,PropMaximumQoS 109,PropSubscriptionIdentifierAvailable 83,PropReceiveMaximum 5805,PropServerKeepAlive -// 15509,PropWildcardSubscriptionAvailable 66,PropTopicAliasMaximum 29709,PropResponseTopic -// "\STXE1\231\136\190e\190\192\232\225",PropWildcardSubscriptionAvailable 0,PropTopicAlias -// 10103,PropSubscriptionIdentifierAvailable 198,PropRequestProblemInformation 61,PropServerKeepAlive -// 11863,PropSubscriptionIdentifierAvailable 153,PropSubscriptionIdentifierAvailable 33,PropWillDelayInterval -// 13860,PropAuthenticationData "\233\\\148",PropContentType -// ">\CAN\EM\173\EM\200\138\155\153\SUB\134=\DC114\229\172\162w\DC2\141q\186\188\171",PropAssignedClientIdentifier -// "&\240/\167E\150\238A\190o\252\131\139\&3",PropAssignedClientIdentifier -// "\128\144\253\244e\238\158U~\139\EOTU\"n\164\v\229\&0",PropRetainAvailable 146,PropWildcardSubscriptionAvailable -// 188,PropSharedSubscriptionAvailable 162,PropRequestProblemInformation 102,PropWildcardSubscriptionAvailable 223]} -TEST(Connect5QCTest, Encode69) { - uint8_t pkt[] = { - 0x10, 0xa0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6, 0x23, 0xdd, 0x9d, 0x1, 0x1a, 0x0, 0x11, 0x71, - 0x67, 0xaa, 0x7f, 0xc0, 0xc2, 0x56, 0x82, 0x3c, 0xe2, 0x55, 0x8b, 0xa6, 0x35, 0x22, 0x51, 0x70, 0x29, 0x3c, 0x13, - 0x8, 0xa6, 0x24, 0x6d, 0x29, 0x53, 0x21, 0x16, 0xad, 0x13, 0x3c, 0x95, 0x28, 0x42, 0x22, 0x74, 0xd, 0x8, 0x0, - 0xb, 0x2, 0x45, 0x31, 0xe7, 0x88, 0xbe, 0x65, 0xbe, 0xc0, 0xe8, 0xe1, 0x28, 0x0, 0x23, 0x27, 0x77, 0x29, 0xc6, - 0x17, 0x3d, 0x13, 0x2e, 0x57, 0x29, 0x99, 0x29, 0x21, 0x18, 0x0, 0x0, 0x36, 0x24, 0x16, 0x0, 0x3, 0xe9, 0x5c, - 0x94, 0x3, 0x0, 0x19, 0x3e, 0x18, 0x19, 0xad, 0x19, 0xc8, 0x8a, 0x9b, 0x99, 0x1a, 0x86, 0x3d,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d, 0x30, 0x23, 0x11, 0xab, 0x2, 0x0, - 0x0, 0x3c, 0x7c, 0x8, 0x0, 0xf, 0x42, 0x1a, 0xb5, 0xca, 0x9a, 0x2d, 0xa5, 0x9d, 0xef, 0x60, 0x96, 0x28, 0xa6, - 0xc9, 0x92, 0x9, 0x0, 0x5, 0xcf, 0xdc, 0xa7, 0xac, 0x1c, 0x26, 0x0, 0x13, 0xeb, 0xd1, 0xff, 0x9a, 0x43, 0x11, - 0x9b, 0x4b, 0x2f, 0x10, 0xb7, 0x64, 0x37, 0x49, 0x62, 0xa7, 0x4a, 0x80, 0x39, 0x0, 0x5, 0xc0, 0xbe, 0x13, 0xed, - 0xc7, 0x1c, 0x0, 0x6, 0xa, 0x24, 0x1d, 0xb8, 0x67, 0x23, 0x1, 0xe6, 0x13, 0x9, 0x2, 0x2a, 0x67, 0x0, 0x1c, - 0x6e, 0xdd, 0x2e, 0x67, 0xe7, 0xd1, 0x5b, 0x61, 0x2a, 0x6e, 0x27, 0xd6, 0x61, 0x6c, 0x93, 0xf1, 0x24, 0xaf, 0x27, - 0x2d, 0x4a, 0x8c, 0xd9, 0xaf, 0x98, 0x82, 0x9b, 0xe8, 0x0, 0x9, 0x1f, 0xa1, 0xec, 0x12, 0x8a, 0xd3, 0x5f, 0x1b, - 0xf4}; - - uint8_t buf[429] = {0}; - - uint8_t bytesprops0[] = {0x71, 0x67, 0xaa, 0x7f, 0xc0, 0xc2, 0x56, 0x82, 0x3c, - 0xe2, 0x55, 0x8b, 0xa6, 0x35, 0x22, 0x51, 0x70}; - uint8_t bytesprops1[] = {0x2, 0x45, 0x31, 0xe7, 0x88, 0xbe, 0x65, 0xbe, 0xc0, 0xe8, 0xe1}; - uint8_t bytesprops2[] = {0xe9, 0x5c, 0x94}; - uint8_t bytesprops3[] = {0x3e, 0x18, 0x19, 0xad, 0x19, 0xc8, 0x8a, 0x9b, 0x99, 0x1a, 0x86, 0x3d, 0x11, - 0x31, 0x34, 0xe5, 0xac, 0xa2, 0x77, 0x12, 0x8d, 0x71, 0xba, 0xbc, 0xab}; - uint8_t bytesprops4[] = {0x26, 0xf0, 0x2f, 0xa7, 0x45, 0x96, 0xee, 0x41, 0xbe, 0x6f, 0xfc, 0x83, 0x8b, 0x33}; - uint8_t bytesprops5[] = {0x80, 0x90, 0xfd, 0xf4, 0x65, 0xee, 0x9e, 0x55, 0x7e, - 0x8b, 0x4, 0x55, 0x22, 0x6e, 0xa4, 0xb, 0xe5, 0x30}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2214}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5805}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15509}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29709}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10103}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11863}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13860}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 223}}, - }; - - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xba, 0x28, 0x4a}; - uint8_t byteswillprops2[] = {0x3b, 0xeb, 0x5c, 0x11, 0x92, 0xff, 0xb9, 0x6}; - uint8_t byteswillprops1[] = {0}; - uint8_t byteswillprops3[] = {0xa7, 0x47, 0xc6, 0x7, 0xf9, 0x96, 0xb8, 0xc3, 0xd2, 0x82, 0xf9, - 0x1a, 0xce, 0x7f, 0xf9, 0x6d, 0xb9, 0x3a, 0xb6, 0xe0, 0xb1, 0xfe}; - uint8_t byteswillprops5[] = {0x3e, 0xe8, 0x29, 0xe, 0x76, 0xb, 0xd, 0x46, - 0xc7, 0x47, 0x11, 0x6c, 0x39, 0xe0, 0x2e, 0xfb}; - uint8_t byteswillprops4[] = {0x69, 0x34, 0xa, 0xe8, 0x69, 0x7a, 0xbf, 0x1d}; - uint8_t byteswillprops6[] = {0xd2, 0xdf, 0xb7, 0xd1, 0x16, 0x7a, 0x28, 0x69, 0xa4, 0x9f, 0x20, 0x79, 0x6d, 0xce, 0xaa, - 0xe0, 0xaf, 0xe9, 0x3a, 0x2f, 0xa5, 0xac, 0x59, 0xb7, 0x58, 0xd, 0x26, 0x7d, 0x30}; - uint8_t byteswillprops7[] = {0x42, 0x1a, 0xb5, 0xca, 0x9a, 0x2d, 0xa5, 0x9d, - 0xef, 0x60, 0x96, 0x28, 0xa6, 0xc9, 0x92}; - uint8_t byteswillprops8[] = {0xcf, 0xdc, 0xa7, 0xac, 0x1c}; - uint8_t byteswillprops10[] = {0xc0, 0xbe, 0x13, 0xed, 0xc7}; - uint8_t byteswillprops9[] = {0xeb, 0xd1, 0xff, 0x9a, 0x43, 0x11, 0x9b, 0x4b, 0x2f, 0x10, - 0xb7, 0x64, 0x37, 0x49, 0x62, 0xa7, 0x4a, 0x80, 0x39}; - uint8_t byteswillprops11[] = {0xa, 0x24, 0x1d, 0xb8, 0x67, 0x23}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27954}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {0, (char*)&byteswillprops1}, .v = {8, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18528}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {8, (char*)&byteswillprops4}, .v = {16, (char*)&byteswillprops5}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4523}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15484}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {19, (char*)&byteswillprops9}, .v = {5, (char*)&byteswillprops10}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2306}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, - }; - - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6e, 0xdd, 0x2e, 0x67, 0xe7, 0xd1, 0x5b, 0x61, 0x2a, 0x6e, 0x27, 0xd6, 0x61, 0x6c, - 0x93, 0xf1, 0x24, 0xaf, 0x27, 0x2d, 0x4a, 0x8c, 0xd9, 0xaf, 0x98, 0x82, 0x9b, 0xe8}; - lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1f, 0xa1, 0xec, 0x12, 0x8a, 0xd3, 0x5f, 0x1b, 0xf4}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 9181; - uint8_t client_id_bytes[] = {0x4d, 0x9c, 0x14, 0x85, 0x5a, 0xcd, 0x15, 0x26}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x1, 0xfd, 0x80, 0x68, 0xd6, 0x88, 0x3e, 0xf4, 0x3c, 0xff, 0x99}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\227\ESCQ", _password = Just "\231\239\188\247\236\FSU\172\t\232D", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "(7<,XJ9\ETB\231t\245\245\214\208\FSj\131", -// _willMsg = "", _willProps = [PropMaximumPacketSize 13992,PropUserProperty "\165\145\192A\164~wb\153\252\SYN" -// "e\167\ETX\STX|j\a\160\185\229o\155\176\168\167\b",PropSharedSubscriptionAvailable 66,PropContentType -// "'\SOH\196\&9,5\209",PropWillDelayInterval 17285,PropSessionExpiryInterval 8449,PropSessionExpiryInterval -// 18445,PropReceiveMaximum 5075,PropSubscriptionIdentifierAvailable 202,PropResponseInformation "",PropResponseTopic -// "\214^\190c\RS\171nC)O",PropTopicAliasMaximum 21628,PropAuthenticationMethod -// "\176mT\ETX\141\236\172$[>)\207\&5\144",PropServerReference -// "\188\153\146\SI\218\197c\ACK0l\f\160\245y1<\235\146\130\135v\bfs\250",PropSubscriptionIdentifier -// 29,PropMaximumPacketSize 31692]}), _cleanSession = False, _keepAlive = 3405, _connID = "\229sD\131\227v\232^4n0", -// _properties = [PropTopicAlias 29021,PropSharedSubscriptionAvailable 181,PropServerReference -// "\224?\161\230\151;\255\216\204^\158\151\SYNL\175\128",PropWildcardSubscriptionAvailable -// 226,PropAssignedClientIdentifier -// "\176^iwh\SO\EOTV\250\249\220\247@\228i}c\DLE\207\246\131\218\135\215*",PropAuthenticationMethod -// "g\152\CAN{N\183d#\152\192\151",PropPayloadFormatIndicator 186,PropSubscriptionIdentifierAvailable -// 90,PropRetainAvailable 227,PropReasonString "",PropRequestResponseInformation 124,PropReasonString -// "\NAK\142\"\242#\198\214\220+k\144\147\GS\210\152",PropReceiveMaximum 12762,PropServerKeepAlive -// 16767,PropAssignedClientIdentifier "\245\230; R\FSU\247\236\149x\ENQsxqD\158\144;",PropMessageExpiryInterval -// 21735,PropAuthenticationMethod "q\139\236*O\a\179",PropSubscriptionIdentifier 2,PropReasonString -// "",PropSubscriptionIdentifierAvailable 103,PropAuthenticationData -// "\194\&76\250\253\ETX0\179q\218\162\138",PropReceiveMaximum 30578,PropMaximumPacketSize -// 21991,PropAssignedClientIdentifier "z\135,\185\191?\201\160:",PropResponseInformation -// "\DELP0`\209\168\tT\\L\DC2\a\134\254[\ACK$d#\DC4|c\226\167Md\t\177\217U",PropReasonString -// "\252\135\192\DC2\192\172,\RS\228\252\r&\139\191\235 A\DC1"]} -TEST(Connect5QCTest, Encode71) { - uint8_t pkt[] = { - 0x10, 0xca, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0xd, 0x4d, 0xec, 0x1, 0x23, 0x71, 0x5d, 0x2a, - 0xb5, 0x1c, 0x0, 0x10, 0xe0, 0x3f, 0xa1, 0xe6, 0x97, 0x3b, 0xff, 0xd8, 0xcc, 0x5e, 0x9e, 0x97, 0x16, 0x4c, 0xaf, - 0x80, 0x28, 0xe2, 0x12, 0x0, 0x19, 0xb0, 0x5e, 0x69, 0x77, 0x68, 0xe, 0x4, 0x56, 0xfa, 0xf9, 0xdc, 0xf7, 0x40, - 0xe4, 0x69, 0x7d, 0x63, 0x10, 0xcf, 0xf6, 0x83, 0xda, 0x87, 0xd7, 0x2a, 0x15, 0x0, 0xb, 0x67, 0x98, 0x18, 0x7b, - 0x4e, 0xb7, 0x64, 0x23, 0x98, 0xc0, 0x97, 0x1, 0xba, 0x29, 0x5a, 0x25, 0xe3, 0x1f, 0x0, 0x0, 0x19, 0x7c, 0x1f, - 0x0, 0xf, 0x15, 0x8e, 0x22, 0xf2, 0x23, 0xc6, 0xd6, 0xdc, 0x2b, 0x6b, 0x90, 0x93, 0x1d, 0xd2, 0x98, 0x21, 0x31, - 0xda, 0x13, 0x41, 0x7f, 0x12, 0x0, 0x13, 0xf5, 0xe6, 0x3b, 0x20, 0x52, 0x1c, 0x55, 0xf7, 0xec, 0x95, 0x78, 0x5, - 0x73, 0x78, 0x71, 0x44, 0x9e, 0x90, 0x3b, 0x2, 0x0, 0x0, 0x54, 0xe7, 0x15, 0x0, 0x7, 0x71, 0x8b, 0xec, 0x2a, - 0x4f, 0x7, 0xb3, 0xb, 0x2, 0x1f, 0x0, 0x0, 0x29, 0x67, 0x16, 0x0, 0xc, 0xc2, 0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, 0xeb, 0x92, 0x82, 0x87, 0x76, 0x8, 0x66, - 0x73, 0xfa, 0xb, 0x1d, 0x27, 0x0, 0x0, 0x7b, 0xcc, 0x0, 0x1b, 0x18, 0xe4, 0x89, 0x65, 0x61, 0x8, 0x11, 0xe6, - 0xbc, 0x42, 0x8, 0xb9, 0xa1, 0xd5, 0xfa, 0x3a, 0xd6, 0x1e, 0x4c, 0x59, 0x4c, 0xc1, 0x9d, 0x4b, 0xbd, 0x52, 0x7e, - 0x0, 0x16, 0x5e, 0xbc, 0x78, 0xad, 0xe7, 0xf9, 0x53, 0x80, 0x39, 0x2, 0x25, 0x85, 0x6c, 0xad, 0x73, 0x87, 0x7b, - 0x46, 0xdd, 0xa9, 0x54, 0xfe, 0x0, 0x17, 0x7, 0x2e, 0xad, 0xbd, 0xbb, 0xc0, 0x35, 0x11, 0xf2, 0x40, 0x3, 0x47, - 0x49, 0xae, 0x72, 0xbd, 0xbf, 0xd5, 0x18, 0x34, 0xe9, 0x1, 0xc4, 0x0, 0xb, 0x69, 0x11, 0x6c, 0x55, 0xd2, 0xfd, - 0xcc, 0xd3, 0xe0, 0x14, 0xe4}; - - uint8_t buf[471] = {0}; - - uint8_t bytesprops0[] = {0xe0, 0x3f, 0xa1, 0xe6, 0x97, 0x3b, 0xff, 0xd8, - 0xcc, 0x5e, 0x9e, 0x97, 0x16, 0x4c, 0xaf, 0x80}; - uint8_t bytesprops1[] = {0xb0, 0x5e, 0x69, 0x77, 0x68, 0xe, 0x4, 0x56, 0xfa, 0xf9, 0xdc, 0xf7, 0x40, - 0xe4, 0x69, 0x7d, 0x63, 0x10, 0xcf, 0xf6, 0x83, 0xda, 0x87, 0xd7, 0x2a}; - uint8_t bytesprops2[] = {0x67, 0x98, 0x18, 0x7b, 0x4e, 0xb7, 0x64, 0x23, 0x98, 0xc0, 0x97}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x15, 0x8e, 0x22, 0xf2, 0x23, 0xc6, 0xd6, 0xdc, 0x2b, 0x6b, 0x90, 0x93, 0x1d, 0xd2, 0x98}; - uint8_t bytesprops5[] = {0xf5, 0xe6, 0x3b, 0x20, 0x52, 0x1c, 0x55, 0xf7, 0xec, 0x95, - 0x78, 0x5, 0x73, 0x78, 0x71, 0x44, 0x9e, 0x90, 0x3b}; - uint8_t bytesprops6[] = {0x71, 0x8b, 0xec, 0x2a, 0x4f, 0x7, 0xb3}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops8[] = {0xc2, 0x37, 0x36, 0xfa, 0xfd, 0x3, 0x30, 0xb3, 0x71, 0xda, 0xa2, 0x8a}; - uint8_t bytesprops9[] = {0x7a, 0x87, 0x2c, 0xb9, 0xbf, 0x3f, 0xc9, 0xa0, 0x3a}; - uint8_t bytesprops10[] = {0x7f, 0x50, 0x30, 0x60, 0xd1, 0xa8, 0x9, 0x54, 0x5c, 0x4c, 0x12, 0x7, 0x86, 0xfe, 0x5b, - 0x6, 0x24, 0x64, 0x23, 0x14, 0x7c, 0x63, 0xe2, 0xa7, 0x4d, 0x64, 0x9, 0xb1, 0xd9, 0x55}; - uint8_t bytesprops11[] = {0xfc, 0x87, 0xc0, 0x12, 0xc0, 0xac, 0x2c, 0x1e, 0xe4, - 0xfc, 0xd, 0x26, 0x8b, 0xbf, 0xeb, 0x20, 0x41, 0x11}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29021}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12762}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16767}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21735}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30578}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21991}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops11}}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x37, 0x98, 0x15, 0xf6, 0x6c, 0x32, 0x8f, 0xb7, 0xab, 0x41}; - uint8_t byteswillprops1[] = {0xb5, 0x41}; - uint8_t byteswillprops2[] = {0x6b, 0x98, 0x14, 0x18, 0x3, 0x4c, 0xbb, 0x70, 0xd5, 0x5f, 0x12, - 0x3e, 0x5e, 0xbe, 0x63, 0x1e, 0xab, 0x6e, 0x43, 0x29, 0x4f}; - uint8_t byteswillprops3[] = {0xb0, 0x6d, 0x54, 0x3, 0x8d, 0xec, 0xac, 0x24, 0x5b, 0x3e, 0x29, 0xcf, 0x35, 0x90}; - uint8_t byteswillprops4[] = {0xbc, 0x99, 0x92, 0xf, 0xda, 0xc5, 0x63, 0x6, 0x30, 0x6c, 0xc, 0xa0, 0xf5, - 0x79, 0x31, 0x3c, 0xeb, 0x92, 0x82, 0x87, 0x76, 0x8, 0x66, 0x73, 0xfa}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21628}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31692}}, - }; - - lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x18, 0xe4, 0x89, 0x65, 0x61, 0x8, 0x11, 0xe6, 0xbc, 0x42, 0x8, 0xb9, 0xa1, 0xd5, - 0xfa, 0x3a, 0xd6, 0x1e, 0x4c, 0x59, 0x4c, 0xc1, 0x9d, 0x4b, 0xbd, 0x52, 0x7e}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5e, 0xbc, 0x78, 0xad, 0xe7, 0xf9, 0x53, 0x80, 0x39, 0x2, 0x25, - 0x85, 0x6c, 0xad, 0x73, 0x87, 0x7b, 0x46, 0xdd, 0xa9, 0x54, 0xfe}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3405; - uint8_t client_id_bytes[] = {0xe5, 0x73, 0x44, 0x83, 0xe3, 0x76, 0xe8, 0x5e, 0x34, 0x6e, 0x30}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x7, 0x2e, 0xad, 0xbd, 0xbb, 0xc0, 0x35, 0x11, 0xf2, 0x40, 0x3, 0x47, - 0x49, 0xae, 0x72, 0xbd, 0xbf, 0xd5, 0x18, 0x34, 0xe9, 0x1, 0xc4}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x69, 0x11, 0x6c, 0x55, 0xd2, 0xfd, 0xcc, 0xd3, 0xe0, 0x14, 0xe4}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "a", _password = Just "@\CAN\194hS*r\ESC'\162\SUB\222P\218g\250\&5\aN\nf\ETX\246", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\135!\172j\177\193\187\202+&FH\SO", -// _willMsg = "g\144@\161F\215\147>\217\b\228\146\186\ETB\234\252\208\201", _willProps = -// [PropSharedSubscriptionAvailable 52,PropUserProperty -// "\206\154\130\229\136\166~:\EOTZ\136\253\164\184\134RS8~\212a\161\&6h\185\202\tG\229" -// "\198Z\148b4\167\246\209\193V\ACK",PropAuthenticationData -// "\224\132\219*[8\SUB\209\&8\232c\DC1\152L\ETX\174\191y\NUL\210KOz\137\197\243Q",PropContentType -// "?os\201e$\226F\169u\242\242d\137/\233\254",PropSessionExpiryInterval 22845,PropMaximumQoS 56,PropRetainAvailable -// 185,PropAssignedClientIdentifier "P\162\CAN\136\137NK]~\179\205F\176",PropContentType -// "H\218\179\&2\193]$\191\SUB\220\236x\211k\254\231\142\DLE\222\243\DC4F\DEL:\ENQ",PropRequestResponseInformation -// 55,PropMessageExpiryInterval 15612,PropCorrelationData -// "\SOH!.\194G~\DC4g\136z\131\229\255O\245\211\226\171(\243u\174j#",PropRequestResponseInformation -// 140,PropAuthenticationMethod "\197",PropAuthenticationMethod "\225\195~m\249\DC1\a\f -// \214\203\234C",PropWildcardSubscriptionAvailable 45,PropMessageExpiryInterval 13177,PropUserProperty -// "t.Pc\ENQ\250\200\CAN\198}Fp4g\205D\185\249" "\ACK\CANtZ\DC4\133\182c5h\161;J -// \215\154D0r",PropSharedSubscriptionAvailable 171,PropRetainAvailable 36,PropSessionExpiryInterval -// 32065,PropReceiveMaximum 16540,PropCorrelationData -// "\230C\153\&3\179\255\\\166\209$\158\223@\160",PropResponseInformation "\176s\227jL'U\133a\233\144\228\215\254"]}), -// _cleanSession = True, _keepAlive = 19693, _connID = "\140\204\191\171.BtU+cj", _properties = [PropRetainAvailable -// 22,PropSessionExpiryInterval 8887,PropSharedSubscriptionAvailable 25,PropWildcardSubscriptionAvailable -// 185,PropServerReference -// "\142\223\SUB\ETX\242\ETX\172\232\248\232\\\189\171\212\141\DC4x\216\162\229\140\GS\158\151\235",PropRetainAvailable -// 182,PropResponseInformation "=\226\238\222\247\204\141\218Z2\STX\131\147\&3FE\200C\217\198",PropRetainAvailable -// 193,PropWildcardSubscriptionAvailable 79,PropServerReference -// "\190\DC32\237\&6\133\211\236\215\218\134\f\164%-\193\214\161Vs"]} -TEST(Connect5QCTest, Encode72) { - uint8_t pkt[] = { - 0x10, 0xe1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x4c, 0xed, 0x5b, 0x25, 0x16, 0x11, 0x0, 0x0, - 0x22, 0xb7, 0x2a, 0x19, 0x28, 0xb9, 0x1c, 0x0, 0x19, 0x8e, 0xdf, 0x1a, 0x3, 0xf2, 0x3, 0xac, 0xe8, 0xf8, 0xe8, - 0x5c, 0xbd, 0xab, 0xd4, 0x8d, 0x14, 0x78, 0xd8, 0xa2, 0xe5, 0x8c, 0x1d, 0x9e, 0x97, 0xeb, 0x25, 0xb6, 0x1a, 0x0, - 0x14, 0x3d, 0xe2, 0xee, 0xde, 0xf7, 0xcc, 0x8d, 0xda, 0x5a, 0x32, 0x2, 0x83, 0x93, 0x33, 0x46, 0x45, 0xc8, 0x43, - 0xd9, 0xc6, 0x25, 0xc1, 0x28, 0x4f, 0x1c, 0x0, 0x14, 0xbe, 0x13, 0x32, 0xed, 0x36, 0x85, 0xd3, 0xec, 0xd7, 0xda, - 0x86, 0xc, 0xa4, 0x25, 0x2d, 0xc1, 0xd6, 0xa1, 0x56, 0x73, 0x0, 0xb, 0x8c, 0xcc, 0xbf, 0xab, 0x2e, 0x42, 0x74, - 0x55, 0x2b, 0x63, 0x6a, 0xad, 0x2, 0x2a, 0x34, 0x26, 0x0, 0x1d, 0xce, 0x9a, 0x82, 0xe5, 0x88, 0xa6, 0x7e, 0x3a, - 0x4, 0x5a, 0x88, 0xfd, 0xa4, 0xb8, 0x86, 0x52, 0x53, 0x38, 0x7e, 0xd4, 0x61, 0xa1, 0x36, 0x68, 0xb9, 0xca, 0x9, - 0x47, 0xe5, 0x0, 0xb, 0xc6, 0x5a, 0x94, 0x62, 0x34, 0xa7, 0xf6, 0xd1, 0xc1, 0x56, 0x6, 0x16, 0x0, 0x1b, 0xe0, - 0x84, 0xdb, 0x2a, 0x5b, 0x38, 0x1a, 0xd1, 0x38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xa1, 0x3b, 0x4a, 0x20, 0xd7, 0x9a, 0x44, 0x30, 0x72, 0x2a, 0xab, 0x25, 0x24, 0x11, - 0x0, 0x0, 0x7d, 0x41, 0x21, 0x40, 0x9c, 0x9, 0x0, 0xe, 0xe6, 0x43, 0x99, 0x33, 0xb3, 0xff, 0x5c, 0xa6, 0xd1, - 0x24, 0x9e, 0xdf, 0x40, 0xa0, 0x1a, 0x0, 0xe, 0xb0, 0x73, 0xe3, 0x6a, 0x4c, 0x27, 0x55, 0x85, 0x61, 0xe9, 0x90, - 0xe4, 0xd7, 0xfe, 0x0, 0xd, 0x87, 0x21, 0xac, 0x6a, 0xb1, 0xc1, 0xbb, 0xca, 0x2b, 0x26, 0x46, 0x48, 0xe, 0x0, - 0x12, 0x67, 0x90, 0x40, 0xa1, 0x46, 0xd7, 0x93, 0x3e, 0xd9, 0x8, 0xe4, 0x92, 0xba, 0x17, 0xea, 0xfc, 0xd0, 0xc9, - 0x0, 0x1, 0x61, 0x0, 0x17, 0x40, 0x18, 0xc2, 0x68, 0x53, 0x2a, 0x72, 0x1b, 0x27, 0xa2, 0x1a, 0xde, 0x50, 0xda, - 0x67, 0xfa, 0x35, 0x7, 0x4e, 0xa, 0x66, 0x3, 0xf6}; - - uint8_t buf[494] = {0}; - - uint8_t bytesprops0[] = {0x8e, 0xdf, 0x1a, 0x3, 0xf2, 0x3, 0xac, 0xe8, 0xf8, 0xe8, 0x5c, 0xbd, 0xab, - 0xd4, 0x8d, 0x14, 0x78, 0xd8, 0xa2, 0xe5, 0x8c, 0x1d, 0x9e, 0x97, 0xeb}; - uint8_t bytesprops1[] = {0x3d, 0xe2, 0xee, 0xde, 0xf7, 0xcc, 0x8d, 0xda, 0x5a, 0x32, - 0x2, 0x83, 0x93, 0x33, 0x46, 0x45, 0xc8, 0x43, 0xd9, 0xc6}; - uint8_t bytesprops2[] = {0xbe, 0x13, 0x32, 0xed, 0x36, 0x85, 0xd3, 0xec, 0xd7, 0xda, - 0x86, 0xc, 0xa4, 0x25, 0x2d, 0xc1, 0xd6, 0xa1, 0x56, 0x73}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8887}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops2}}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xc6, 0x5a, 0x94, 0x62, 0x34, 0xa7, 0xf6, 0xd1, 0xc1, 0x56, 0x6}; - uint8_t byteswillprops0[] = {0xce, 0x9a, 0x82, 0xe5, 0x88, 0xa6, 0x7e, 0x3a, 0x4, 0x5a, 0x88, 0xfd, 0xa4, 0xb8, 0x86, - 0x52, 0x53, 0x38, 0x7e, 0xd4, 0x61, 0xa1, 0x36, 0x68, 0xb9, 0xca, 0x9, 0x47, 0xe5}; - uint8_t byteswillprops2[] = {0xe0, 0x84, 0xdb, 0x2a, 0x5b, 0x38, 0x1a, 0xd1, 0x38, 0xe8, 0x63, 0x11, 0x98, 0x4c, - 0x3, 0xae, 0xbf, 0x79, 0x0, 0xd2, 0x4b, 0x4f, 0x7a, 0x89, 0xc5, 0xf3, 0x51}; - uint8_t byteswillprops3[] = {0x3f, 0x6f, 0x73, 0xc9, 0x65, 0x24, 0xe2, 0x46, 0xa9, - 0x75, 0xf2, 0xf2, 0x64, 0x89, 0x2f, 0xe9, 0xfe}; - uint8_t byteswillprops4[] = {0x50, 0xa2, 0x18, 0x88, 0x89, 0x4e, 0x4b, 0x5d, 0x7e, 0xb3, 0xcd, 0x46, 0xb0}; - uint8_t byteswillprops5[] = {0x48, 0xda, 0xb3, 0x32, 0xc1, 0x5d, 0x24, 0xbf, 0x1a, 0xdc, 0xec, 0x78, 0xd3, - 0x6b, 0xfe, 0xe7, 0x8e, 0x10, 0xde, 0xf3, 0x14, 0x46, 0x7f, 0x3a, 0x5}; - uint8_t byteswillprops6[] = {0x1, 0x21, 0x2e, 0xc2, 0x47, 0x7e, 0x14, 0x67, 0x88, 0x7a, 0x83, 0xe5, - 0xff, 0x4f, 0xf5, 0xd3, 0xe2, 0xab, 0x28, 0xf3, 0x75, 0xae, 0x6a, 0x23}; - uint8_t byteswillprops7[] = {0xc5}; - uint8_t byteswillprops8[] = {0xe1, 0xc3, 0x7e, 0x6d, 0xf9, 0x11, 0x7, 0xc, 0x20, 0xd6, 0xcb, 0xea, 0x43}; - uint8_t byteswillprops10[] = {0x6, 0x18, 0x74, 0x5a, 0x14, 0x85, 0xb6, 0x63, 0x35, 0x68, - 0xa1, 0x3b, 0x4a, 0x20, 0xd7, 0x9a, 0x44, 0x30, 0x72}; - uint8_t byteswillprops9[] = {0x74, 0x2e, 0x50, 0x63, 0x5, 0xfa, 0xc8, 0x18, 0xc6, - 0x7d, 0x46, 0x70, 0x34, 0x67, 0xcd, 0x44, 0xb9, 0xf9}; - uint8_t byteswillprops11[] = {0xe6, 0x43, 0x99, 0x33, 0xb3, 0xff, 0x5c, 0xa6, 0xd1, 0x24, 0x9e, 0xdf, 0x40, 0xa0}; - uint8_t byteswillprops12[] = {0xb0, 0x73, 0xe3, 0x6a, 0x4c, 0x27, 0x55, 0x85, 0x61, 0xe9, 0x90, 0xe4, 0xd7, 0xfe}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {29, (char*)&byteswillprops0}, .v = {11, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22845}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15612}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13177}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {18, (char*)&byteswillprops9}, .v = {19, (char*)&byteswillprops10}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32065}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16540}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&byteswillprops12}}}, - }; - - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x87, 0x21, 0xac, 0x6a, 0xb1, 0xc1, 0xbb, 0xca, 0x2b, 0x26, 0x46, 0x48, 0xe}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x67, 0x90, 0x40, 0xa1, 0x46, 0xd7, 0x93, 0x3e, 0xd9, - 0x8, 0xe4, 0x92, 0xba, 0x17, 0xea, 0xfc, 0xd0, 0xc9}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 19693; - uint8_t client_id_bytes[] = {0x8c, 0xcc, 0xbf, 0xab, 0x2e, 0x42, 0x74, 0x55, 0x2b, 0x63, 0x6a}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x61}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x40, 0x18, 0xc2, 0x68, 0x53, 0x2a, 0x72, 0x1b, 0x27, 0xa2, 0x1a, 0xde, - 0x50, 0xda, 0x67, 0xfa, 0x35, 0x7, 0x4e, 0xa, 0x66, 0x3, 0xf6}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\172\219m,\215\&1j\218 -// $\179\198q\177c\172\251|\145\151)\ACKk\199\226\192\131\161\SO", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS1, _willTopic = "\253X\142\n\160\NUL\146\171ng\\\NAK\186Q\142\165\NUL\ETX6\212\255d\134|\252\181!av)", -// _willMsg = "}1\182T-u\251\128", _willProps = [PropPayloadFormatIndicator 6,PropResponseInformation -// "\179Q$t\211=\DC4\219.\223A\STX\CAN\EM\f\150"]}), _cleanSession = False, _keepAlive = 12479, _connID = -// "\160\198\DC2f\138Q\188Q\138!y\131\141\&4\255\149\228$=Tx\SOHa\231", _properties = [PropMessageExpiryInterval -// 31115,PropResponseTopic "\206v\205\SI*.o\153\156S\221*\SUBd\131B\229\EM\DLEb!\205",PropAuthenticationMethod -// "\197'\183\128\201\\\179\204\202\222",PropPayloadFormatIndicator 249,PropUserProperty -// "\171X\SO|:\t\164\164e\220\SOHna\243\194\195\168\191\209?j\149 \v" -// "u\188\217\EM\217\175{L|\188\v\STXx+\253\STX\ESC\207",PropRequestProblemInformation 50,PropResponseTopic -// "lg\ACKZ'\182\206\137\&2(*\247^\214\145\146\184\US\202m]\SYN\221f\243",PropRequestProblemInformation -// 107,PropTopicAliasMaximum 25143,PropRetainAvailable 27,PropPayloadFormatIndicator 20,PropServerReference "\r\200m -// \247\155\198\ETX\240\223\137X\220\242\230\SOH\193a\SOHQC\232\247d",PropPayloadFormatIndicator -// 235,PropResponseInformation -// "\NUL\186\170\145\&2\DC3\243\ENQ_\FS\188\133}a\148\132\bu\241\136\213{\227\&1",PropAuthenticationMethod -// "\194\148'\236\DC4\196\EOT\249\128\144\&0\b\239\235W0\172\&1\207\170Pv\243.\RS\241%\226P\208",PropSessionExpiryInterval -// 27855]} -TEST(Connect5QCTest, Encode73) { - uint8_t pkt[] = { - 0x10, 0xc7, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc, 0x30, 0xbf, 0xe1, 0x1, 0x2, 0x0, 0x0, 0x79, - 0x8b, 0x8, 0x0, 0x16, 0xce, 0x76, 0xcd, 0xf, 0x2a, 0x2e, 0x6f, 0x99, 0x9c, 0x53, 0xdd, 0x2a, 0x1a, 0x64, 0x83, - 0x42, 0xe5, 0x19, 0x10, 0x62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, 0x1e, 0xf1, 0x25, 0xe2, 0x50, 0xd0, 0x11, 0x0, 0x0, 0x6c, 0xcf, 0x0, 0x18, 0xa0, 0xc6, 0x12, 0x66, 0x8a, - 0x51, 0xbc, 0x51, 0x8a, 0x21, 0x79, 0x83, 0x8d, 0x34, 0xff, 0x95, 0xe4, 0x24, 0x3d, 0x54, 0x78, 0x1, 0x61, 0xe7, - 0x15, 0x1, 0x6, 0x1a, 0x0, 0x10, 0xb3, 0x51, 0x24, 0x74, 0xd3, 0x3d, 0x14, 0xdb, 0x2e, 0xdf, 0x41, 0x2, 0x18, - 0x19, 0xc, 0x96, 0x0, 0x1e, 0xfd, 0x58, 0x8e, 0xa, 0xa0, 0x0, 0x92, 0xab, 0x6e, 0x67, 0x5c, 0x15, 0xba, 0x51, - 0x8e, 0xa5, 0x0, 0x3, 0x36, 0xd4, 0xff, 0x64, 0x86, 0x7c, 0xfc, 0xb5, 0x21, 0x61, 0x76, 0x29, 0x0, 0x8, 0x7d, - 0x31, 0xb6, 0x54, 0x2d, 0x75, 0xfb, 0x80}; - - uint8_t buf[340] = {0}; - - uint8_t bytesprops0[] = {0xce, 0x76, 0xcd, 0xf, 0x2a, 0x2e, 0x6f, 0x99, 0x9c, 0x53, 0xdd, - 0x2a, 0x1a, 0x64, 0x83, 0x42, 0xe5, 0x19, 0x10, 0x62, 0x21, 0xcd}; - uint8_t bytesprops1[] = {0xc5, 0x27, 0xb7, 0x80, 0xc9, 0x5c, 0xb3, 0xcc, 0xca, 0xde}; - uint8_t bytesprops3[] = {0x75, 0xbc, 0xd9, 0x19, 0xd9, 0xaf, 0x7b, 0x4c, 0x7c, - 0xbc, 0xb, 0x2, 0x78, 0x2b, 0xfd, 0x2, 0x1b, 0xcf}; - uint8_t bytesprops2[] = {0xab, 0x58, 0xe, 0x7c, 0x3a, 0x9, 0xa4, 0xa4, 0x65, 0xdc, 0x1, 0x6e, - 0x61, 0xf3, 0xc2, 0xc3, 0xa8, 0xbf, 0xd1, 0x3f, 0x6a, 0x95, 0x20, 0xb}; - uint8_t bytesprops4[] = {0x6c, 0x67, 0x6, 0x5a, 0x27, 0xb6, 0xce, 0x89, 0x32, 0x28, 0x2a, 0xf7, 0x5e, - 0xd6, 0x91, 0x92, 0xb8, 0x1f, 0xca, 0x6d, 0x5d, 0x16, 0xdd, 0x66, 0xf3}; - uint8_t bytesprops5[] = {0xd, 0xc8, 0x6d, 0x20, 0xf7, 0x9b, 0xc6, 0x3, 0xf0, 0xdf, 0x89, 0x58, - 0xdc, 0xf2, 0xe6, 0x1, 0xc1, 0x61, 0x1, 0x51, 0x43, 0xe8, 0xf7, 0x64}; - uint8_t bytesprops6[] = {0x0, 0xba, 0xaa, 0x91, 0x32, 0x13, 0xf3, 0x5, 0x5f, 0x1c, 0xbc, 0x85, - 0x7d, 0x61, 0x94, 0x84, 0x8, 0x75, 0xf1, 0x88, 0xd5, 0x7b, 0xe3, 0x31}; - uint8_t bytesprops7[] = {0xc2, 0x94, 0x27, 0xec, 0x14, 0xc4, 0x4, 0xf9, 0x80, 0x90, 0x30, 0x8, 0xef, 0xeb, 0x57, - 0x30, 0xac, 0x31, 0xcf, 0xaa, 0x50, 0x76, 0xf3, 0x2e, 0x1e, 0xf1, 0x25, 0xe2, 0x50, 0xd0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31115}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops2}, .v = {18, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25143}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27855}}, - }; - - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xb3, 0x51, 0x24, 0x74, 0xd3, 0x3d, 0x14, 0xdb, - 0x2e, 0xdf, 0x41, 0x2, 0x18, 0x19, 0xc, 0x96}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops0}}}, - }; - - lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xfd, 0x58, 0x8e, 0xa, 0xa0, 0x0, 0x92, 0xab, 0x6e, 0x67, - 0x5c, 0x15, 0xba, 0x51, 0x8e, 0xa5, 0x0, 0x3, 0x36, 0xd4, - 0xff, 0x64, 0x86, 0x7c, 0xfc, 0xb5, 0x21, 0x61, 0x76, 0x29}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7d, 0x31, 0xb6, 0x54, 0x2d, 0x75, 0xfb, 0x80}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12479; - uint8_t client_id_bytes[] = {0xa0, 0xc6, 0x12, 0x66, 0x8a, 0x51, 0xbc, 0x51, 0x8a, 0x21, 0x79, 0x83, - 0x8d, 0x34, 0xff, 0x95, 0xe4, 0x24, 0x3d, 0x54, 0x78, 0x1, 0x61, 0xe7}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xac, 0xdb, 0x6d, 0x2c, 0xd7, 0x31, 0x6a, 0xda, 0x20, 0x24, 0xb3, 0xc6, 0x71, 0xb1, 0x63, - 0xac, 0xfb, 0x7c, 0x91, 0x97, 0x29, 0x6, 0x6b, 0xc7, 0xe2, 0xc0, 0x83, 0xa1, 0xe}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\186>\208\176\160\b\130H\DC3\FS\nw@\180M\223\f}~\163s\234_", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "h ", _willMsg = -// "\136Jb\133\241\194\237\174\234.J\DEL\213\CAN\189A\167\182", _willProps = [PropResponseInformation -// "\242r\139q\200\EM\r5",PropServerReference "\144H\212\165\186+\t\159\228U\SOH[D\141",PropSessionExpiryInterval -// 29968,PropTopicAliasMaximum 19634,PropMessageExpiryInterval 32147,PropReasonString -// "(\250\142\167A?\214\252c\245\153",PropAuthenticationData -// "\188\179\192\210\RS\178\133\197\\\212\RS\245\213{j\154\b\DEL\130\247\166",PropRetainAvailable -// 227,PropTopicAliasMaximum 627,PropAuthenticationMethod "",PropAuthenticationData "",PropMessageExpiryInterval -// 26962,PropReasonString "\b\251-|\132EL\aX",PropResponseInformation "\134\SYN8",PropAuthenticationData -// "\194\241{\172Br\STX\156\153\195Y\200\167\144AJV\229P\135\155"]}), _cleanSession = False, _keepAlive = 15269, _connID -// = "\151O\SUBd\191\216\184\130k$\237[9\159\\\STX\130\196~\DLE\222\ESC\198}\157\129w\n", _properties = -// [PropAssignedClientIdentifier "\NUL\230W\EOTdV\160\232",PropMessageExpiryInterval 22106,PropTopicAliasMaximum -// 25843,PropTopicAliasMaximum 12574,PropReasonString "\241K\130\208",PropResponseInformation -// "M>\216\ETB\205\223\186",PropMessageExpiryInterval 5857,PropAuthenticationData "\NULZ\231\157",PropReceiveMaximum -// 13735,PropTopicAlias 8358,PropTopicAliasMaximum 21535,PropServerReference "\227\238^E\154\141\FS\153\ACK9}\134\238 -// \240hT",PropAuthenticationMethod -// "\196L\182\ETBgp\253D\129\131\223\210m\140B\210\182)\181`y\251\147\192\197Z\246P\217",PropTopicAlias -// 3384,PropRequestProblemInformation 175,PropSessionExpiryInterval 23888,PropServerReference -// "\152\135\180\234\193\200f\209\183U\173;\r\246\203D\194\174_\SO\170ox\160\190+\135\195",PropSubscriptionIdentifier -// 27,PropResponseInformation -// "\164\212\147\148$s*C\195\202\n\148\DLE0\221\SYN\156\146=\DEL\EOT\192\CAN\203X",PropAuthenticationData -// "Xv\139S\153\219\160\ESC}J",PropWillDelayInterval 12717,PropMaximumQoS 193,PropSessionExpiryInterval -// 1719,PropWildcardSubscriptionAvailable 149,PropMaximumQoS 132,PropMaximumPacketSize -// 19992,PropSubscriptionIdentifierAvailable 154]} -TEST(Connect5QCTest, Encode74) { - uint8_t pkt[] = { - 0x10, 0xc1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x94, 0x3b, 0xa5, 0xdb, 0x1, 0x12, 0x0, 0x8, 0x0, - 0xe6, 0x57, 0x4, 0x64, 0x56, 0xa0, 0xe8, 0x2, 0x0, 0x0, 0x56, 0x5a, 0x22, 0x64, 0xf3, 0x22, 0x31, 0x1e, 0x1f, - 0x0, 0x4, 0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0xc2, 0xed, 0xae, 0xea, - 0x2e, 0x4a, 0x7f, 0xd5, 0x18, 0xbd, 0x41, 0xa7, 0xb6, 0x0, 0x17, 0xba, 0x3e, 0xd0, 0xb0, 0xa0, 0x8, 0x82, 0x48, - 0x13, 0x1c, 0xa, 0x77, 0x40, 0xb4, 0x4d, 0xdf, 0xc, 0x7d, 0x7e, 0xa3, 0x73, 0xea, 0x5f}; - - uint8_t buf[462] = {0}; - - uint8_t bytesprops0[] = {0x0, 0xe6, 0x57, 0x4, 0x64, 0x56, 0xa0, 0xe8}; - uint8_t bytesprops1[] = {0xf1, 0x4b, 0x82, 0xd0}; - uint8_t bytesprops2[] = {0x4d, 0x3e, 0xd8, 0x17, 0xcd, 0xdf, 0xba}; - uint8_t bytesprops3[] = {0x0, 0x5a, 0xe7, 0x9d}; - uint8_t bytesprops4[] = {0xe3, 0xee, 0x5e, 0x45, 0x9a, 0x8d, 0x1c, 0x99, 0x6, - 0x39, 0x7d, 0x86, 0xee, 0x20, 0xf0, 0x68, 0x54}; - uint8_t bytesprops5[] = {0xc4, 0x4c, 0xb6, 0x17, 0x67, 0x70, 0xfd, 0x44, 0x81, 0x83, 0xdf, 0xd2, 0x6d, 0x8c, 0x42, - 0xd2, 0xb6, 0x29, 0xb5, 0x60, 0x79, 0xfb, 0x93, 0xc0, 0xc5, 0x5a, 0xf6, 0x50, 0xd9}; - uint8_t bytesprops6[] = {0x98, 0x87, 0xb4, 0xea, 0xc1, 0xc8, 0x66, 0xd1, 0xb7, 0x55, 0xad, 0x3b, 0xd, 0xf6, - 0xcb, 0x44, 0xc2, 0xae, 0x5f, 0xe, 0xaa, 0x6f, 0x78, 0xa0, 0xbe, 0x2b, 0x87, 0xc3}; - uint8_t bytesprops7[] = {0xa4, 0xd4, 0x93, 0x94, 0x24, 0x73, 0x2a, 0x43, 0xc3, 0xca, 0xa, 0x94, 0x10, - 0x30, 0xdd, 0x16, 0x9c, 0x92, 0x3d, 0x7f, 0x4, 0xc0, 0x18, 0xcb, 0x58}; - uint8_t bytesprops8[] = {0x58, 0x76, 0x8b, 0x53, 0x99, 0xdb, 0xa0, 0x1b, 0x7d, 0x4a}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22106}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25843}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12574}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5857}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13735}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8358}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21535}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3384}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23888}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12717}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1719}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19992}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 154}}, - }; - - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xf2, 0x72, 0x8b, 0x71, 0xc8, 0x19, 0xd, 0x35}; - uint8_t byteswillprops1[] = {0x90, 0x48, 0xd4, 0xa5, 0xba, 0x2b, 0x9, 0x9f, 0xe4, 0x55, 0x1, 0x5b, 0x44, 0x8d}; - uint8_t byteswillprops2[] = {0x28, 0xfa, 0x8e, 0xa7, 0x41, 0x3f, 0xd6, 0xfc, 0x63, 0xf5, 0x99}; - uint8_t byteswillprops3[] = {0xbc, 0xb3, 0xc0, 0xd2, 0x1e, 0xb2, 0x85, 0xc5, 0x5c, 0xd4, 0x1e, - 0xf5, 0xd5, 0x7b, 0x6a, 0x9a, 0x8, 0x7f, 0x82, 0xf7, 0xa6}; - uint8_t byteswillprops4[] = {0}; - uint8_t byteswillprops5[] = {0}; - uint8_t byteswillprops6[] = {0x8, 0xfb, 0x2d, 0x7c, 0x84, 0x45, 0x4c, 0x7, 0x58}; - uint8_t byteswillprops7[] = {0x86, 0x16, 0x38}; - uint8_t byteswillprops8[] = {0xc2, 0xf1, 0x7b, 0xac, 0x42, 0x72, 0x2, 0x9c, 0x99, 0xc3, 0x59, - 0xc8, 0xa7, 0x90, 0x41, 0x4a, 0x56, 0xe5, 0x50, 0x87, 0x9b}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29968}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19634}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32147}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 627}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26962}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops8}}}, - }; - - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x68, 0x20}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x88, 0x4a, 0x62, 0x85, 0xf1, 0xc2, 0xed, 0xae, 0xea, - 0x2e, 0x4a, 0x7f, 0xd5, 0x18, 0xbd, 0x41, 0xa7, 0xb6}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 15269; - uint8_t client_id_bytes[] = {0x97, 0x4f, 0x1a, 0x64, 0xbf, 0xd8, 0xb8, 0x82, 0x6b, 0x24, 0xed, 0x5b, 0x39, 0x9f, - 0x5c, 0x2, 0x82, 0xc4, 0x7e, 0x10, 0xde, 0x1b, 0xc6, 0x7d, 0x9d, 0x81, 0x77, 0xa}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xba, 0x3e, 0xd0, 0xb0, 0xa0, 0x8, 0x82, 0x48, 0x13, 0x1c, 0xa, 0x77, - 0x40, 0xb4, 0x4d, 0xdf, 0xc, 0x7d, 0x7e, 0xa3, 0x73, 0xea, 0x5f}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "%_f0P\185\133\159\152\SOH\185\161\133\186\242\&0'", _password = Just -// "\166\165\148d\NAKy%\142\222\189,", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\222\254\185A\161\232i\ACK\180Z\146\192\254\182-\206\&8H\211\132", _willMsg = -// "\218\212\ACK\ESC\DC2_y\169\196A\228\195N\209;\219\138G\r\GS", _willProps = [PropRequestProblemInformation -// 77,PropSharedSubscriptionAvailable 90,PropSubscriptionIdentifierAvailable 75,PropServerReference -// "+\STX8v^n00@\142\165\ENQ\176\209\134%\180\139k_ #\220R"]}), _cleanSession = True, _keepAlive = 20166, _connID = -// "\ETBG\233\139e\tY\235MPwMH\208", _properties = [PropUserProperty "\234\253bJ+" "$",PropAssignedClientIdentifier -// ",\241\206f\241\RSJ2\DC3\NAK\136i\SOHDK!\237\136",PropSubscriptionIdentifierAvailable 138,PropReceiveMaximum -// 13275,PropSubscriptionIdentifierAvailable 32,PropRequestProblemInformation 72,PropTopicAliasMaximum -// 19915,PropWillDelayInterval 22210,PropAssignedClientIdentifier -// "8Vs*\191\200\128\ACKt\237\142\217\218",PropMaximumPacketSize 14118,PropRetainAvailable 34,PropResponseTopic -// "\205h\227\148",PropAssignedClientIdentifier "\176[\ESC\183\196\228\129+\202\174\vO",PropMaximumQoS -// 254,PropResponseInformation "T\180\202\170t\n\"\250\CAN",PropCorrelationData "9\161\239"]} -TEST(Connect5QCTest, Encode75) { - uint8_t pkt[] = {0x10, 0xfb, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x4e, 0xc6, 0x72, 0x26, 0x0, 0x5, - 0xea, 0xfd, 0x62, 0x4a, 0x2b, 0x0, 0x1, 0x24, 0x12, 0x0, 0x12, 0x2c, 0xf1, 0xce, 0x66, 0xf1, 0x1e, - 0x4a, 0x32, 0x13, 0x15, 0x88, 0x69, 0x1, 0x44, 0x4b, 0x21, 0xed, 0x88, 0x29, 0x8a, 0x21, 0x33, 0xdb, - 0x29, 0x20, 0x17, 0x48, 0x22, 0x4d, 0xcb, 0x18, 0x0, 0x0, 0x56, 0xc2, 0x12, 0x0, 0xd, 0x38, 0x56, - 0x73, 0x2a, 0xbf, 0xc8, 0x80, 0x6, 0x74, 0xed, 0x8e, 0xd9, 0xda, 0x27, 0x0, 0x0, 0x37, 0x26, 0x25, - 0x22, 0x8, 0x0, 0x4, 0xcd, 0x68, 0xe3, 0x94, 0x12, 0x0, 0xc, 0xb0, 0x5b, 0x1b, 0xb7, 0xc4, 0xe4, - 0x81, 0x2b, 0xca, 0xae, 0xb, 0x4f, 0x24, 0xfe, 0x1a, 0x0, 0x9, 0x54, 0xb4, 0xca, 0xaa, 0x74, 0xa, - 0x22, 0xfa, 0x18, 0x9, 0x0, 0x3, 0x39, 0xa1, 0xef, 0x0, 0xe, 0x17, 0x47, 0xe9, 0x8b, 0x65, 0x9, - 0x59, 0xeb, 0x4d, 0x50, 0x77, 0x4d, 0x48, 0xd0, 0x21, 0x17, 0x4d, 0x2a, 0x5a, 0x29, 0x4b, 0x1c, 0x0, - 0x18, 0x2b, 0x2, 0x38, 0x76, 0x5e, 0x6e, 0x30, 0x30, 0x40, 0x8e, 0xa5, 0x5, 0xb0, 0xd1, 0x86, 0x25, - 0xb4, 0x8b, 0x6b, 0x5f, 0x20, 0x23, 0xdc, 0x52, 0x0, 0x14, 0xde, 0xfe, 0xb9, 0x41, 0xa1, 0xe8, 0x69, - 0x6, 0xb4, 0x5a, 0x92, 0xc0, 0xfe, 0xb6, 0x2d, 0xce, 0x38, 0x48, 0xd3, 0x84, 0x0, 0x14, 0xda, 0xd4, - 0x6, 0x1b, 0x12, 0x5f, 0x79, 0xa9, 0xc4, 0x41, 0xe4, 0xc3, 0x4e, 0xd1, 0x3b, 0xdb, 0x8a, 0x47, 0xd, - 0x1d, 0x0, 0x11, 0x25, 0x5f, 0x66, 0x30, 0x50, 0xb9, 0x85, 0x9f, 0x98, 0x1, 0xb9, 0xa1, 0x85, 0xba, - 0xf2, 0x30, 0x27, 0x0, 0xb, 0xa6, 0xa5, 0x94, 0x64, 0x15, 0x79, 0x25, 0x8e, 0xde, 0xbd, 0x2c}; - - uint8_t buf[264] = {0}; - - uint8_t bytesprops1[] = {0x24}; - uint8_t bytesprops0[] = {0xea, 0xfd, 0x62, 0x4a, 0x2b}; - uint8_t bytesprops2[] = {0x2c, 0xf1, 0xce, 0x66, 0xf1, 0x1e, 0x4a, 0x32, 0x13, - 0x15, 0x88, 0x69, 0x1, 0x44, 0x4b, 0x21, 0xed, 0x88}; - uint8_t bytesprops3[] = {0x38, 0x56, 0x73, 0x2a, 0xbf, 0xc8, 0x80, 0x6, 0x74, 0xed, 0x8e, 0xd9, 0xda}; - uint8_t bytesprops4[] = {0xcd, 0x68, 0xe3, 0x94}; - uint8_t bytesprops5[] = {0xb0, 0x5b, 0x1b, 0xb7, 0xc4, 0xe4, 0x81, 0x2b, 0xca, 0xae, 0xb, 0x4f}; - uint8_t bytesprops6[] = {0x54, 0xb4, 0xca, 0xaa, 0x74, 0xa, 0x22, 0xfa, 0x18}; - uint8_t bytesprops7[] = {0x39, 0xa1, 0xef}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops0}, .v = {1, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13275}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19915}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22210}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14118}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops7}}}, - }; - - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x2b, 0x2, 0x38, 0x76, 0x5e, 0x6e, 0x30, 0x30, 0x40, 0x8e, 0xa5, 0x5, - 0xb0, 0xd1, 0x86, 0x25, 0xb4, 0x8b, 0x6b, 0x5f, 0x20, 0x23, 0xdc, 0x52}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops0}}}, - }; - - lwmqtt_properties_t willprops = {4, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xde, 0xfe, 0xb9, 0x41, 0xa1, 0xe8, 0x69, 0x6, 0xb4, 0x5a, - 0x92, 0xc0, 0xfe, 0xb6, 0x2d, 0xce, 0x38, 0x48, 0xd3, 0x84}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xda, 0xd4, 0x6, 0x1b, 0x12, 0x5f, 0x79, 0xa9, 0xc4, 0x41, - 0xe4, 0xc3, 0x4e, 0xd1, 0x3b, 0xdb, 0x8a, 0x47, 0xd, 0x1d}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 20166; - uint8_t client_id_bytes[] = {0x17, 0x47, 0xe9, 0x8b, 0x65, 0x9, 0x59, 0xeb, 0x4d, 0x50, 0x77, 0x4d, 0x48, 0xd0}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x25, 0x5f, 0x66, 0x30, 0x50, 0xb9, 0x85, 0x9f, 0x98, - 0x1, 0xb9, 0xa1, 0x85, 0xba, 0xf2, 0x30, 0x27}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xa6, 0xa5, 0x94, 0x64, 0x15, 0x79, 0x25, 0x8e, 0xde, 0xbd, 0x2c}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\172\206\237\DLE\254_Q2\226B'S\147k\177*D!\230\185<\130", _password = Just -// ".\STX\240p\196\191\165l\140\230\214\188\253\220\166\224I\197\241\153&3;\249", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS0, _willTopic = "\DC1o\221b\189\141f\242\228\CAN\219\141,e\230\221\166\&7Ar\GS", -// _willMsg = "", _willProps = []}), _cleanSession = False, _keepAlive = 20633, _connID = -// "x]*\241\253\180\253\181\DC4%\n\245\187\"\138\DLE\212b\182\171\131J\193\&0\176C", _properties = -// [PropRequestResponseInformation 254,PropAuthenticationMethod -// "\178\217\228\159;\DC4\209\143\165J\180\232\132\FSW",PropAuthenticationMethod -// "\170(\184H\158\183\236\197\134\157\DC1\RS\246\177\215mC",PropRequestProblemInformation 95,PropReasonString -// "\255Z\n>",PropSubscriptionIdentifierAvailable 56,PropUserProperty -// "\209\221\ACK+\SO\142\168\219\202\141\194C\169\167\SYN\253D\180\161\224\191\147-\226v,\DC27\140" -// "|\150p",PropWildcardSubscriptionAvailable 116,PropContentType -// "`0Y0\204\145\131\229\160\220mI\RS\170t\180*iw\188Hz\163\&8*\ESC,,\178",PropSharedSubscriptionAvailable -// 123,PropServerReference "\162V -// ,\235\164\DC4\207\152Uut\228\187\248\215s\214(\196u\243\b\bS\223t\151",PropResponseInformation -// "",PropPayloadFormatIndicator 83,PropSessionExpiryInterval 24887,PropCorrelationData "",PropRetainAvailable -// 95,PropMessageExpiryInterval 9307,PropSessionExpiryInterval 3503,PropResponseInformation -// "tR\NUL\248!\173\197p<\183\SYN\f\177=x\210\164a7=\SI\230d\\\149\157\232",PropUserProperty -// "\139\252S\156\149\134k\213\195\137^" "a\238\&5\222\160\192OaG{\251\231\SO\184\SI",PropTopicAliasMaximum -// 31387,PropUserProperty "''%\241k\158l\148\EM" "o\206\156(\ACK\142\204\&5\176\207Dx",PropMessageExpiryInterval -// 6104,PropSubscriptionIdentifier 15,PropContentType "\144\168\174\250\ETB\155\156",PropMessageExpiryInterval 18880]} -TEST(Connect5QCTest, Encode76) { - uint8_t pkt[] = { - 0x10, 0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0x27, 0x53, 0x93, 0x6b, 0xb1, 0x2a, 0x44, - 0x21, 0xe6, 0xb9, 0x3c, 0x82, 0x0, 0x18, 0x2e, 0x2, 0xf0, 0x70, 0xc4, 0xbf, 0xa5, 0x6c, 0x8c, 0xe6, 0xd6, 0xbc, - 0xfd, 0xdc, 0xa6, 0xe0, 0x49, 0xc5, 0xf1, 0x99, 0x26, 0x33, 0x3b, 0xf9}; - - uint8_t buf[421] = {0}; - - uint8_t bytesprops0[] = {0xb2, 0xd9, 0xe4, 0x9f, 0x3b, 0x14, 0xd1, 0x8f, 0xa5, 0x4a, 0xb4, 0xe8, 0x84, 0x1c, 0x57}; - uint8_t bytesprops1[] = {0xaa, 0x28, 0xb8, 0x48, 0x9e, 0xb7, 0xec, 0xc5, 0x86, - 0x9d, 0x11, 0x1e, 0xf6, 0xb1, 0xd7, 0x6d, 0x43}; - uint8_t bytesprops2[] = {0xff, 0x5a, 0xa, 0x3e}; - uint8_t bytesprops4[] = {0x7c, 0x96, 0x70}; - uint8_t bytesprops3[] = {0xd1, 0xdd, 0x6, 0x2b, 0xe, 0x8e, 0xa8, 0xdb, 0xca, 0x8d, 0xc2, 0x43, 0xa9, 0xa7, 0x16, - 0xfd, 0x44, 0xb4, 0xa1, 0xe0, 0xbf, 0x93, 0x2d, 0xe2, 0x76, 0x2c, 0x12, 0x37, 0x8c}; - uint8_t bytesprops5[] = {0x60, 0x30, 0x59, 0x30, 0xcc, 0x91, 0x83, 0xe5, 0xa0, 0xdc, 0x6d, 0x49, 0x1e, 0xaa, 0x74, - 0xb4, 0x2a, 0x69, 0x77, 0xbc, 0x48, 0x7a, 0xa3, 0x38, 0x2a, 0x1b, 0x2c, 0x2c, 0xb2}; - uint8_t bytesprops6[] = {0xa2, 0x56, 0x20, 0x2c, 0xeb, 0xa4, 0x14, 0xcf, 0x98, 0x55, 0x75, 0x74, 0xe4, 0xbb, - 0xf8, 0xd7, 0x73, 0xd6, 0x28, 0xc4, 0x75, 0xf3, 0x8, 0x8, 0x53, 0xdf, 0x74, 0x97}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops9[] = {0x74, 0x52, 0x0, 0xf8, 0x21, 0xad, 0xc5, 0x70, 0x3c, 0xb7, 0x16, 0xc, 0xb1, 0x3d, - 0x78, 0xd2, 0xa4, 0x61, 0x37, 0x3d, 0xf, 0xe6, 0x64, 0x5c, 0x95, 0x9d, 0xe8}; - uint8_t bytesprops11[] = {0x61, 0xee, 0x35, 0xde, 0xa0, 0xc0, 0x4f, 0x61, 0x47, 0x7b, 0xfb, 0xe7, 0xe, 0xb8, 0xf}; - uint8_t bytesprops10[] = {0x8b, 0xfc, 0x53, 0x9c, 0x95, 0x86, 0x6b, 0xd5, 0xc3, 0x89, 0x5e}; - uint8_t bytesprops13[] = {0x6f, 0xce, 0x9c, 0x28, 0x6, 0x8e, 0xcc, 0x35, 0xb0, 0xcf, 0x44, 0x78}; - uint8_t bytesprops12[] = {0x27, 0x27, 0x25, 0xf1, 0x6b, 0x9e, 0x6c, 0x94, 0x19}; - uint8_t bytesprops14[] = {0x90, 0xa8, 0xae, 0xfa, 0x17, 0x9b, 0x9c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops3}, .v = {3, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24887}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9307}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3503}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {11, (char*)&bytesprops10}, .v = {15, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31387}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops12}, .v = {12, (char*)&bytesprops13}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6104}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18880}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x11, 0x6f, 0xdd, 0x62, 0xbd, 0x8d, 0x66, 0xf2, 0xe4, 0x18, 0xdb, - 0x8d, 0x2c, 0x65, 0xe6, 0xdd, 0xa6, 0x37, 0x41, 0x72, 0x1d}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 20633; - uint8_t client_id_bytes[] = {0x78, 0x5d, 0x2a, 0xf1, 0xfd, 0xb4, 0xfd, 0xb5, 0x14, 0x25, 0xa, 0xf5, 0xbb, - 0x22, 0x8a, 0x10, 0xd4, 0x62, 0xb6, 0xab, 0x83, 0x4a, 0xc1, 0x30, 0xb0, 0x43}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xac, 0xce, 0xed, 0x10, 0xfe, 0x5f, 0x51, 0x32, 0xe2, 0x42, 0x27, - 0x53, 0x93, 0x6b, 0xb1, 0x2a, 0x44, 0x21, 0xe6, 0xb9, 0x3c, 0x82}; - lwmqtt_string_t username = {22, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x2e, 0x2, 0xf0, 0x70, 0xc4, 0xbf, 0xa5, 0x6c, 0x8c, 0xe6, 0xd6, 0xbc, - 0xfd, 0xdc, 0xa6, 0xe0, 0x49, 0xc5, 0xf1, 0x99, 0x26, 0x33, 0x3b, 0xf9}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "z@\a", _password = Just "\253\197(\t}\238J\253\251\192\135j", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\129B\175B", _willMsg = "S\233k'\183[ryq\189X\218", -// _willProps = [PropSubscriptionIdentifierAvailable 59,PropRequestProblemInformation 184,PropTopicAlias -// 11545,PropResponseTopic "\\0\128\214\&2`\162x\179\176))\207D\255S\134\224X\DC2\b\159",PropSessionExpiryInterval -// 32591,PropSessionExpiryInterval 6459,PropRequestProblemInformation 129,PropSharedSubscriptionAvailable -// 184,PropAssignedClientIdentifier -// "\145\248\128|\178\150\242\235d\NAK\190R\137t\169\217n\174E\156Y\SUB6\SYN\151XH",PropRetainAvailable 204]}), -// _cleanSession = False, _keepAlive = 32764, _connID = "d\173\189", _properties = [PropMessageExpiryInterval -// 19357,PropContentType "{fW\192\248\DC4\206\191\235",PropAuthenticationMethod "\DC2l1",PropAuthenticationData -// "\198\159$\188\RS\196\222O\217\225R\191\212d>\241W\131\191BF)O\180\227v\145i",PropSessionExpiryInterval -// 20981,PropSessionExpiryInterval 18282,PropAssignedClientIdentifier -// "\185\249\196\187\a\247\161\214_|\166\229\&2k\179\151ak\151\151%=O\132\246\144*6>",PropAssignedClientIdentifier -// "\223m\v\197\233X/\NUL\NAK\166C\132\f\135c&\231$j\206",PropPayloadFormatIndicator 5,PropWildcardSubscriptionAvailable -// 184,PropAuthenticationMethod "\210n|<\132\243?\193\251\DC3a\EOT\169\171\"n^\161\RS",PropUserProperty -// "\165K\198\SOBe\170'3m\220\211\185\SId\168\154\SYN~\247v\208\197\231\153" -// "\140\210\128\139\DLE\238W\240\138G\164AE\155\173\255$\138\r\201\235\&3w\134\&0`6\245s"]} -TEST(Connect5QCTest, Encode77) { - uint8_t pkt[] = { - 0x10, 0xd3, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x7f, 0xfc, 0xcc, 0x1, 0x2, 0x0, 0x0, 0x4b, - 0x9d, 0x3, 0x0, 0x9, 0x7b, 0x66, 0x57, 0xc0, 0xf8, 0x14, 0xce, 0xbf, 0xeb, 0x15, 0x0, 0x3, 0x12, 0x6c, 0x31, - 0x16, 0x0, 0x1c, 0xc6, 0x9f, 0x24, 0xbc, 0x1e, 0xc4, 0xde, 0x4f, 0xd9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5c, 0x30, 0x80, 0xd6, 0x32, 0x60, 0xa2, 0x78, 0xb3, 0xb0, 0x29, 0x29, - 0xcf, 0x44, 0xff, 0x53, 0x86, 0xe0, 0x58, 0x12, 0x8, 0x9f, 0x11, 0x0, 0x0, 0x7f, 0x4f, 0x11, 0x0, 0x0, 0x19, - 0x3b, 0x17, 0x81, 0x2a, 0xb8, 0x12, 0x0, 0x1b, 0x91, 0xf8, 0x80, 0x7c, 0xb2, 0x96, 0xf2, 0xeb, 0x64, 0x15, 0xbe, - 0x52, 0x89, 0x74, 0xa9, 0xd9, 0x6e, 0xae, 0x45, 0x9c, 0x59, 0x1a, 0x36, 0x16, 0x97, 0x58, 0x48, 0x25, 0xcc, 0x0, - 0x4, 0x81, 0x42, 0xaf, 0x42, 0x0, 0xc, 0x53, 0xe9, 0x6b, 0x27, 0xb7, 0x5b, 0x72, 0x79, 0x71, 0xbd, 0x58, 0xda, - 0x0, 0x3, 0x7a, 0x40, 0x7, 0x0, 0xc, 0xfd, 0xc5, 0x28, 0x9, 0x7d, 0xee, 0x4a, 0xfd, 0xfb, 0xc0, 0x87, 0x6a}; - - uint8_t buf[352] = {0}; - - uint8_t bytesprops0[] = {0x7b, 0x66, 0x57, 0xc0, 0xf8, 0x14, 0xce, 0xbf, 0xeb}; - uint8_t bytesprops1[] = {0x12, 0x6c, 0x31}; - uint8_t bytesprops2[] = {0xc6, 0x9f, 0x24, 0xbc, 0x1e, 0xc4, 0xde, 0x4f, 0xd9, 0xe1, 0x52, 0xbf, 0xd4, 0x64, - 0x3e, 0xf1, 0x57, 0x83, 0xbf, 0x42, 0x46, 0x29, 0x4f, 0xb4, 0xe3, 0x76, 0x91, 0x69}; - uint8_t bytesprops3[] = {0xb9, 0xf9, 0xc4, 0xbb, 0x7, 0xf7, 0xa1, 0xd6, 0x5f, 0x7c, 0xa6, 0xe5, 0x32, 0x6b, 0xb3, - 0x97, 0x61, 0x6b, 0x97, 0x97, 0x25, 0x3d, 0x4f, 0x84, 0xf6, 0x90, 0x2a, 0x36, 0x3e}; - uint8_t bytesprops4[] = {0xdf, 0x6d, 0xb, 0xc5, 0xe9, 0x58, 0x2f, 0x0, 0x15, 0xa6, - 0x43, 0x84, 0xc, 0x87, 0x63, 0x26, 0xe7, 0x24, 0x6a, 0xce}; - uint8_t bytesprops5[] = {0xd2, 0x6e, 0x7c, 0x3c, 0x84, 0xf3, 0x3f, 0xc1, 0xfb, 0x13, - 0x61, 0x4, 0xa9, 0xab, 0x22, 0x6e, 0x5e, 0xa1, 0x1e}; - uint8_t bytesprops7[] = {0x8c, 0xd2, 0x80, 0x8b, 0x10, 0xee, 0x57, 0xf0, 0x8a, 0x47, 0xa4, 0x41, 0x45, 0x9b, 0xad, - 0xff, 0x24, 0x8a, 0xd, 0xc9, 0xeb, 0x33, 0x77, 0x86, 0x30, 0x60, 0x36, 0xf5, 0x73}; - uint8_t bytesprops6[] = {0xa5, 0x4b, 0xc6, 0xe, 0x42, 0x65, 0xaa, 0x27, 0x33, 0x6d, 0xdc, 0xd3, 0xb9, - 0xf, 0x64, 0xa8, 0x9a, 0x16, 0x7e, 0xf7, 0x76, 0xd0, 0xc5, 0xe7, 0x99}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19357}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20981}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18282}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops6}, .v = {29, (char*)&bytesprops7}}}}, - }; - - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x5c, 0x30, 0x80, 0xd6, 0x32, 0x60, 0xa2, 0x78, 0xb3, 0xb0, 0x29, - 0x29, 0xcf, 0x44, 0xff, 0x53, 0x86, 0xe0, 0x58, 0x12, 0x8, 0x9f}; - uint8_t byteswillprops1[] = {0x91, 0xf8, 0x80, 0x7c, 0xb2, 0x96, 0xf2, 0xeb, 0x64, 0x15, 0xbe, 0x52, 0x89, 0x74, - 0xa9, 0xd9, 0x6e, 0xae, 0x45, 0x9c, 0x59, 0x1a, 0x36, 0x16, 0x97, 0x58, 0x48}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11545}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32591}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6459}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, - }; - - lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x81, 0x42, 0xaf, 0x42}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x53, 0xe9, 0x6b, 0x27, 0xb7, 0x5b, 0x72, 0x79, 0x71, 0xbd, 0x58, 0xda}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32764; - uint8_t client_id_bytes[] = {0x64, 0xad, 0xbd}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x7a, 0x40, 0x7}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xfd, 0xc5, 0x28, 0x9, 0x7d, 0xee, 0x4a, 0xfd, 0xfb, 0xc0, 0x87, 0x6a}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "vo\255\134\EM\214ra~\221QTH]\236\&1\203\133f\193%", _password = Nothing, _lastWill -// = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\143\219\228T\SIP\210\NULp\216b\230\191\b\DC1\190\218\139\178\174\179\138\176z", _willMsg = -// "\\\196Q\224Q\138\232\DC4\230u\194\&6\147\197\138o\202\247&\180\179\RSB,\244\153h\STX", _willProps = -// [PropRequestResponseInformation 5]}), _cleanSession = False, _keepAlive = 18519, _connID = -// "cX\140\&9\221\ETXY\131\GS", _properties = [PropCorrelationData -// "cD\152\188\136\&0\ETB\178Ya6",PropSharedSubscriptionAvailable 108,PropMessageExpiryInterval 17865]} -TEST(Connect5QCTest, Encode78) { - uint8_t pkt[] = {0x10, 0x7d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xac, 0x48, 0x57, 0x15, 0x9, 0x0, 0xb, - 0x63, 0x44, 0x98, 0xbc, 0x88, 0x30, 0x17, 0xb2, 0x59, 0x61, 0x36, 0x2a, 0x6c, 0x2, 0x0, 0x0, - 0x45, 0xc9, 0x0, 0x9, 0x63, 0x58, 0x8c, 0x39, 0xdd, 0x3, 0x59, 0x83, 0x1d, 0x2, 0x19, 0x5, - 0x0, 0x18, 0x8f, 0xdb, 0xe4, 0x54, 0xf, 0x50, 0xd2, 0x0, 0x70, 0xd8, 0x62, 0xe6, 0xbf, 0x8, - 0x11, 0xbe, 0xda, 0x8b, 0xb2, 0xae, 0xb3, 0x8a, 0xb0, 0x7a, 0x0, 0x1c, 0x5c, 0xc4, 0x51, 0xe0, - 0x51, 0x8a, 0xe8, 0x14, 0xe6, 0x75, 0xc2, 0x36, 0x93, 0xc5, 0x8a, 0x6f, 0xca, 0xf7, 0x26, 0xb4, - 0xb3, 0x1e, 0x42, 0x2c, 0xf4, 0x99, 0x68, 0x2, 0x0, 0x15, 0x76, 0x6f, 0xff, 0x86, 0x19, 0xd6, - 0x72, 0x61, 0x7e, 0xdd, 0x51, 0x54, 0x48, 0x5d, 0xec, 0x31, 0xcb, 0x85, 0x66, 0xc1, 0x25}; - - uint8_t buf[137] = {0}; - - uint8_t bytesprops0[] = {0x63, 0x44, 0x98, 0xbc, 0x88, 0x30, 0x17, 0xb2, 0x59, 0x61, 0x36}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17865}}, - }; - - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 5}}, - }; - - lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8f, 0xdb, 0xe4, 0x54, 0xf, 0x50, 0xd2, 0x0, 0x70, 0xd8, 0x62, 0xe6, - 0xbf, 0x8, 0x11, 0xbe, 0xda, 0x8b, 0xb2, 0xae, 0xb3, 0x8a, 0xb0, 0x7a}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5c, 0xc4, 0x51, 0xe0, 0x51, 0x8a, 0xe8, 0x14, 0xe6, 0x75, 0xc2, 0x36, 0x93, 0xc5, - 0x8a, 0x6f, 0xca, 0xf7, 0x26, 0xb4, 0xb3, 0x1e, 0x42, 0x2c, 0xf4, 0x99, 0x68, 0x2}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 18519; - uint8_t client_id_bytes[] = {0x63, 0x58, 0x8c, 0x39, 0xdd, 0x3, 0x59, 0x83, 0x1d}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x76, 0x6f, 0xff, 0x86, 0x19, 0xd6, 0x72, 0x61, 0x7e, 0xdd, 0x51, - 0x54, 0x48, 0x5d, 0xec, 0x31, 0xcb, 0x85, 0x66, 0xc1, 0x25}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just -// "\157\ETB\161\194\193\144\143\222H\bK\137S\211\183P\248e#\158\140\132\232~", _lastWill = Just (LastWill {_willRetain -// = True, _willQoS = QoS0, _willTopic = "\234\218\131\206!/\185r4\200\241\199\174\200\229", _willMsg = -// "?\198\253\173(", _willProps = [PropServerKeepAlive 29962,PropReceiveMaximum 19631,PropMaximumPacketSize -// 17084,PropTopicAlias 21494,PropMaximumPacketSize 20387,PropSessionExpiryInterval 10289,PropServerKeepAlive 23645]}), -// _cleanSession = True, _keepAlive = 5462, _connID = "~Zt\220\FS\b\166{\135\185\244Q\248@\a^", _properties = -// [PropWillDelayInterval 7867,PropServerReference "cS\248\169\DLE\189Q\207\170gE\239\146\231szjp\137",PropReasonString -// "F7\v\177l\189\191\DEL\198\162[\162\146\SUB\180\t\228\156y\171F\218-\246\156\169\229'",PropServerKeepAlive -// 30499,PropWillDelayInterval 18658,PropAssignedClientIdentifier "\174\209g",PropMaximumPacketSize 22566,PropMaximumQoS -// 204,PropAuthenticationData "L\133}qW\235\165r\183\195'\ny\148;7Ja",PropServerKeepAlive 21943,PropReasonString -// "\255\189\230TO\231\f\235\148\SOH\192\205\f\234\250\176\202r\197\214\t\199\252\230\167:\228\175\147",PropAssignedClientIdentifier -// "-$\ETX\200\r\255Id\GS\\C\238&\SI=\b<\194\167\&9O\197\164\245\236+\250\159\209\167",PropAssignedClientIdentifier -// "\252\f",PropWillDelayInterval 31642,PropSessionExpiryInterval 30092,PropAssignedClientIdentifier -// "\149\213\139\STX\SOHD\209!\184\251)\235fj\146\184\216\206\140$",PropAssignedClientIdentifier -// "\251\DC2\255j\235\236\&2\169\226\151l\136\CAN\155\205\220:\171\147W5`\224",PropRetainAvailable 210]} -TEST(Connect5QCTest, Encode79) { - uint8_t pkt[] = { - 0x10, 0xbc, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x15, 0x56, 0xea, 0x1, 0x18, 0x0, 0x0, 0x1e, - 0xbb, 0x1c, 0x0, 0x13, 0x63, 0x53, 0xf8, 0xa9, 0x10, 0xbd, 0x51, 0xcf, 0xaa, 0x67, 0x45, 0xef, 0x92, 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12, 0x0, 0x17, 0xfb, 0x12, 0xff, 0x6a, - 0xeb, 0xec, 0x32, 0xa9, 0xe2, 0x97, 0x6c, 0x88, 0x18, 0x9b, 0xcd, 0xdc, 0x3a, 0xab, 0x93, 0x57, 0x35, 0x60, 0xe0, - 0x25, 0xd2, 0x0, 0x10, 0x7e, 0x5a, 0x74, 0xdc, 0x1c, 0x8, 0xa6, 0x7b, 0x87, 0xb9, 0xf4, 0x51, 0xf8, 0x40, 0x7, - 0x5e, 0x1b, 0x13, 0x75, 0xa, 0x21, 0x4c, 0xaf, 0x27, 0x0, 0x0, 0x42, 0xbc, 0x23, 0x53, 0xf6, 0x27, 0x0, 0x0, - 0x4f, 0xa3, 0x11, 0x0, 0x0, 0x28, 0x31, 0x13, 0x5c, 0x5d, 0x0, 0xf, 0xea, 0xda, 0x83, 0xce, 0x21, 0x2f, 0xb9, - 0x72, 0x34, 0xc8, 0xf1, 0xc7, 0xae, 0xc8, 0xe5, 0x0, 0x5, 0x3f, 0xc6, 0xfd, 0xad, 0x28}; - - uint8_t buf[329] = {0}; - - uint8_t bytesprops0[] = {0x63, 0x53, 0xf8, 0xa9, 0x10, 0xbd, 0x51, 0xcf, 0xaa, 0x67, - 0x45, 0xef, 0x92, 0xe7, 0x73, 0x7a, 0x6a, 0x70, 0x89}; - uint8_t bytesprops1[] = {0x46, 0x37, 0xb, 0xb1, 0x6c, 0xbd, 0xbf, 0x7f, 0xc6, 0xa2, 0x5b, 0xa2, 0x92, 0x1a, - 0xb4, 0x9, 0xe4, 0x9c, 0x79, 0xab, 0x46, 0xda, 0x2d, 0xf6, 0x9c, 0xa9, 0xe5, 0x27}; - uint8_t bytesprops2[] = {0xae, 0xd1, 0x67}; - uint8_t bytesprops3[] = {0x4c, 0x85, 0x7d, 0x71, 0x57, 0xeb, 0xa5, 0x72, 0xb7, - 0xc3, 0x27, 0xa, 0x79, 0x94, 0x3b, 0x37, 0x4a, 0x61}; - uint8_t bytesprops4[] = {0xff, 0xbd, 0xe6, 0x54, 0x4f, 0xe7, 0xc, 0xeb, 0x94, 0x1, 0xc0, 0xcd, 0xc, 0xea, 0xfa, - 0xb0, 0xca, 0x72, 0xc5, 0xd6, 0x9, 0xc7, 0xfc, 0xe6, 0xa7, 0x3a, 0xe4, 0xaf, 0x93}; - uint8_t bytesprops5[] = {0x2d, 0x24, 0x3, 0xc8, 0xd, 0xff, 0x49, 0x64, 0x1d, 0x5c, 0x43, 0xee, 0x26, 0xf, 0x3d, - 0x8, 0x3c, 0xc2, 0xa7, 0x39, 0x4f, 0xc5, 0xa4, 0xf5, 0xec, 0x2b, 0xfa, 0x9f, 0xd1, 0xa7}; - uint8_t bytesprops6[] = {0xfc, 0xc}; - uint8_t bytesprops7[] = {0x95, 0xd5, 0x8b, 0x2, 0x1, 0x44, 0xd1, 0x21, 0xb8, 0xfb, - 0x29, 0xeb, 0x66, 0x6a, 0x92, 0xb8, 0xd8, 0xce, 0x8c, 0x24}; - uint8_t bytesprops8[] = {0xfb, 0x12, 0xff, 0x6a, 0xeb, 0xec, 0x32, 0xa9, 0xe2, 0x97, 0x6c, 0x88, - 0x18, 0x9b, 0xcd, 0xdc, 0x3a, 0xab, 0x93, 0x57, 0x35, 0x60, 0xe0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7867}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30499}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18658}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22566}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21943}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31642}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30092}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29962}}, {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19631}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17084}}, {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21494}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20387}}, {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10289}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23645}}, - }; - - lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xea, 0xda, 0x83, 0xce, 0x21, 0x2f, 0xb9, 0x72, - 0x34, 0xc8, 0xf1, 0xc7, 0xae, 0xc8, 0xe5}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3f, 0xc6, 0xfd, 0xad, 0x28}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 5462; - uint8_t client_id_bytes[] = {0x7e, 0x5a, 0x74, 0xdc, 0x1c, 0x8, 0xa6, 0x7b, - 0x87, 0xb9, 0xf4, 0x51, 0xf8, 0x40, 0x7, 0x5e}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x9d, 0x17, 0xa1, 0xc2, 0xc1, 0x90, 0x8f, 0xde, 0x48, 0x8, 0x4b, 0x89, - 0x53, 0xd3, 0xb7, 0x50, 0xf8, 0x65, 0x23, 0x9e, 0x8c, 0x84, 0xe8, 0x7e}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\147{'Z\192?r8#\DLEU\192\236\160\237v\192p\NUL\171;\EOT", _password = Just -// "\160J\202\185\172\&2\153\200\SYN\a\130n\179\133f\207\&5\n8\245\n\144\220", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS0, _willTopic = "\145K\248\242\218\139\203", _willMsg = -// "\166\252\SI\215\181\NUL\150dX7\178\210", _willProps = [PropSubscriptionIdentifierAvailable 128,PropTopicAliasMaximum -// 24138,PropReceiveMaximum 13075,PropResponseTopic -// "\178\236j\DEL\154Z\251\STXs\196\164M\171\140\&9G\210\212\187",PropMaximumQoS 54,PropReasonString -// "\SI\ACKc;n\160k\a\SUB\218r\171*\236\168",PropAssignedClientIdentifier "p$\150Q\174\199",PropAssignedClientIdentifier -// "\ACK\DLE\EOTC\146\161\130\145<\139hM\ETX\147\180\166\165\r\147\a\165t\254\156\178\188",PropMaximumPacketSize -// 29686,PropRetainAvailable 253,PropResponseTopic "*\135Z\155\139*H\NUL\152n\GS\EM\ETX\196\217"]}), _cleanSession = -// True, _keepAlive = 25664, _connID = "\GS\225\&4\DC4\182", _properties = [PropResponseInformation -// "\178\132\159",PropRequestResponseInformation 123,PropResponseTopic -// "\129\182\170\SOH\225l\227\163\169&\211\b\131|\216\182\234\168\&6\186\DC2\146",PropPayloadFormatIndicator -// 135,PropTopicAliasMaximum 18172,PropMaximumPacketSize 4275,PropReasonString -// "\179\187\181$DQ\SI5\246\185\130L",PropAuthenticationMethod ",\235\RS=f8\239\160",PropCorrelationData -// "\156\213L:8\192\216\174\228V\217\229\255i",PropSubscriptionIdentifier 25,PropUserProperty "\CAN\n\147\196\221" -// ">\193\151Y\177\f\248\DC1\191O",PropWildcardSubscriptionAvailable 198,PropTopicAliasMaximum -// 1330,PropSharedSubscriptionAvailable 56,PropTopicAliasMaximum 3080,PropSubscriptionIdentifier 29,PropReasonString -// "k\v\180x\237\SYN=\246w\248!D%",PropResponseTopic -// "\DC2\219\NUL\154\179O\174\136\r\175+\ENQ\196\244yf\\\180\183[",PropServerReference -// "\197",PropContentType "^P\DLE',\232\240\&6\185\&9H\167\185\140\204_Oa5\174I\164\239\FS",PropUserProperty -// "\232\159\167FWQ\135\EM\148\193\143\a\187{\243\SYN\DC4\DEL\182\248" "\178/\227\250\209\206T",PropWillDelayInterval -// 17881,PropAuthenticationData "&\219\245^\244R\236d-?0\169\156\EOTp\US\190\227w",PropAssignedClientIdentifier -// "h",PropContentType "\200",PropReasonString -// "*\US\143\194$P\\\208\186^\193\v\f{\ENQ\ETB%\194",PropAssignedClientIdentifier "NLF\218\&7",PropServerKeepAlive -// 21484,PropMaximumPacketSize 12647,PropMaximumPacketSize 5652]} -TEST(Connect5QCTest, Encode81) { - uint8_t pkt[] = { - 0x10, 0x87, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x5, 0x3f, 0xc0, 0x1, 0x26, 0x0, 0x1a, 0x4c, - 0xde, 0x6a, 0xef, 0x22, 0x99, 0x12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 0x9a, 0xc9, 0x91, 0xd, 0x7d, 0x2a, 0xbf, 0x88, 0x4a, 0xea, 0x4c, 0xc7, 0xe6, 0x8e, 0xf7, 0x9, 0x0, 0xa, - 0x20, 0xc1, 0x71, 0x97, 0x7e, 0x71, 0x2d, 0x3d, 0x34, 0x2, 0x2a, 0xd7, 0x12, 0x0, 0x7, 0xc8, 0xc0, 0x74, 0xfd, - 0xcd, 0xa4, 0x69, 0x0, 0x1b, 0x41, 0x94, 0x4d, 0xca, 0xc3, 0xc3, 0xd, 0x1d, 0xf0, 0xeb, 0xc1, 0x5f, 0x62, 0x29, - 0xb2, 0xb0, 0xda, 0x2d, 0x5a, 0xb0, 0x60, 0xba, 0xa4, 0x1c, 0x6b, 0x86, 0xaf, 0x0, 0x12, 0x34, 0x7c, 0x67, 0x51, - 0x31, 0xe1, 0xe2, 0x26, 0xd6, 0x4e, 0xd5, 0x87, 0xe8, 0xdc, 0x47, 0x6d, 0xf2, 0xac, 0x0, 0x1b, 0x50, 0xb2, 0xf3, - 0xb7, 0xac, 0x89, 0xe8, 0xd4, 0xd, 0x7e, 0x4e, 0xfc, 0x91, 0xd4, 0x68, 0xe6, 0x11, 0x90, 0x7a, 0x7d, 0xd1, 0x36, - 0xf7, 0x10, 0xc0, 0x69, 0x71, 0x0, 0x2, 0x6d, 0x55}; - - uint8_t buf[532] = {0}; - - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops0[] = {0x4c, 0xde, 0x6a, 0xef, 0x22, 0x99, 0x12, 0xbb, 0x77, 0xea, 0x20, 0x4c, 0x7f, - 0x1, 0x9c, 0xce, 0x90, 0x92, 0x72, 0x7b, 0x7c, 0x31, 0x19, 0xb3, 0x6c, 0x3b}; - uint8_t bytesprops2[] = {0xa1, 0x81, 0xe1, 0xe0}; - uint8_t bytesprops3[] = {0xa6, 0xa7, 0xd0, 0x3e}; - uint8_t bytesprops4[] = {0x5e, 0x50, 0x10, 0x27, 0x2c, 0xe8, 0xf0, 0x36, 0xb9, 0x39, 0x48, 0xa7, - 0xb9, 0x8c, 0xcc, 0x5f, 0x4f, 0x61, 0x35, 0xae, 0x49, 0xa4, 0xef, 0x1c}; - uint8_t bytesprops6[] = {0xb2, 0x2f, 0xe3, 0xfa, 0xd1, 0xce, 0x54}; - uint8_t bytesprops5[] = {0xe8, 0x9f, 0xa7, 0x46, 0x57, 0x51, 0x87, 0x19, 0x94, 0xc1, - 0x8f, 0x7, 0xbb, 0x7b, 0xf3, 0x16, 0x14, 0x7f, 0xb6, 0xf8}; - uint8_t bytesprops7[] = {0x26, 0xdb, 0xf5, 0x5e, 0xf4, 0x52, 0xec, 0x64, 0x2d, 0x3f, - 0x30, 0xa9, 0x9c, 0x4, 0x70, 0x1f, 0xbe, 0xe3, 0x77}; - uint8_t bytesprops8[] = {0x68}; - uint8_t bytesprops9[] = {0xc8}; - uint8_t bytesprops10[] = {0x2a, 0x1f, 0x8f, 0xc2, 0x24, 0x50, 0x5c, 0xd0, 0xba, - 0x5e, 0xc1, 0xb, 0xc, 0x7b, 0x5, 0x17, 0x25, 0xc2}; - uint8_t bytesprops11[] = {0x4e, 0x4c, 0x46, 0xda, 0x37}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1766}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops5}, .v = {7, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17881}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21484}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12647}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5652}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x9, 0x8d, 0x8e, 0x3, 0xa9, 0x68, 0x25, 0x9d, 0x76, 0x6a, 0x96, 0x70, - 0xc8, 0x82, 0xb0, 0x6e, 0x69, 0xcc, 0x45, 0xde, 0xc1, 0xa0, 0xf7, 0x3c}; - uint8_t byteswillprops1[] = {0xdf, 0xbd, 0xb8, 0x99, 0x5, 0xe5, 0xdf, 0xab, 0x51}; - uint8_t byteswillprops2[] = {0x4f, 0xd7, 0xdb, 0x77, 0x70, 0x2a, 0x93, 0x4a, 0xc, 0x9d}; - uint8_t byteswillprops3[] = {0x37, 0x9d, 0x73, 0x21, 0xdd, 0x26, 0x7, 0x96, 0xa, 0x8d, 0xcc, 0x46, 0xd8, 0x71, - 0x29, 0x48, 0x89, 0xf3, 0xd0, 0xa1, 0xd5, 0x3, 0x46, 0x41, 0xc6, 0xd9, 0x8f}; - uint8_t byteswillprops4[] = {0x2, 0xbc, 0x6b, 0xc8, 0x84, 0x19, 0x13, 0xc9, 0x20, - 0x43, 0x4d, 0xaf, 0x5b, 0x95, 0xf, 0x84, 0xd5, 0x82}; - uint8_t byteswillprops5[] = {0x57, 0x57, 0x42, 0xe7, 0x2e, 0xd5, 0x94, 0xba, 0x36, 0x45, 0x54, 0xff, - 0x4a, 0xa3, 0x93, 0xc6, 0xa6, 0x4a, 0xa1, 0x1f, 0xb0, 0xd3, 0xe1}; - uint8_t byteswillprops6[] = {0x28, 0x42, 0xc9}; - uint8_t byteswillprops7[] = {0x15, 0xd1, 0x9a, 0xc9, 0x91, 0xd, 0x7d, 0x2a, 0xbf, - 0x88, 0x4a, 0xea, 0x4c, 0xc7, 0xe6, 0x8e, 0xf7}; - uint8_t byteswillprops8[] = {0x20, 0xc1, 0x71, 0x97, 0x7e, 0x71, 0x2d, 0x3d, 0x34, 0x2}; - uint8_t byteswillprops9[] = {0xc8, 0xc0, 0x74, 0xfd, 0xcd, 0xa4, 0x69}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15844}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16158}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21310}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18603}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops9}}}, - }; - - lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x41, 0x94, 0x4d, 0xca, 0xc3, 0xc3, 0xd, 0x1d, 0xf0, 0xeb, 0xc1, 0x5f, 0x62, 0x29, - 0xb2, 0xb0, 0xda, 0x2d, 0x5a, 0xb0, 0x60, 0xba, 0xa4, 0x1c, 0x6b, 0x86, 0xaf}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x34, 0x7c, 0x67, 0x51, 0x31, 0xe1, 0xe2, 0x26, 0xd6, - 0x4e, 0xd5, 0x87, 0xe8, 0xdc, 0x47, 0x6d, 0xf2, 0xac}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1343; - uint8_t client_id_bytes[] = {0xa2, 0x34, 0x6f, 0x67, 0x2a, 0x54, 0x16, 0xc2, 0x63, 0x4, 0x81, - 0x7e, 0x7a, 0xd7, 0xaa, 0x9, 0x7, 0xac, 0xac, 0x78, 0x75}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x50, 0xb2, 0xf3, 0xb7, 0xac, 0x89, 0xe8, 0xd4, 0xd, 0x7e, 0x4e, 0xfc, 0x91, 0xd4, - 0x68, 0xe6, 0x11, 0x90, 0x7a, 0x7d, 0xd1, 0x36, 0xf7, 0x10, 0xc0, 0x69, 0x71}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6d, 0x55}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "\r)\190_\138\DC4\SO\163\226j\189 -// ~*BN\SI\EOT-\217\128\232\223\239\129m\a\DLEG\254", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, -// _willTopic = "+\177\246\187~\133", _willMsg = "\151\189\&3\RS\175\198\166j", _willProps = [PropMaximumQoS -// 180,PropTopicAliasMaximum 20703,PropWildcardSubscriptionAvailable 142,PropSessionExpiryInterval -// 30839,PropWillDelayInterval 31512,PropRetainAvailable 43,PropRetainAvailable 77,PropUserProperty -// "e4\213\v\167\ENQ\152\201\168c\173\vu>Zz\181\157\198d|\DC4" -// "\241\252\163\163\EOTrjN\250\160\168\161A\SYN\RS4#\240\156\185\164a\US\186",PropAssignedClientIdentifier -// "\160m\187",PropServerReference -// "\SI\199\200\139H\210)\223\223\146G\\\139\220\130\a~\192\EOT\ESC!\ENQ\172\234fW\249\129\GS",PropResponseTopic -// "\DC1M9\139\229\177\178\212\&83.LM{L\221\216\&5a\142\245\140",PropSharedSubscriptionAvailable 249,PropContentType -// "\201\190\ACK\ENQ\212\209T\247\178\&9p"]}), _cleanSession = False, _keepAlive = 4479, _connID = -// "\148\233\210e\EM\168\130\133\253\SOH\232\207f\173\220\238\167\166vG\v\141\190\";", _properties = -// [PropMessageExpiryInterval 8357,PropResponseInformation "\n>\141\228\180\153",PropMaximumQoS -// 233,PropSubscriptionIdentifierAvailable 51]} -TEST(Connect5QCTest, Encode82) { - uint8_t pkt[] = {0x10, 0xe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b, 0x4c, 0xdd, 0xd8, 0x35, 0x61, 0x8e, 0xf5, 0x8c, 0x2a, 0xf9, 0x3, 0x0, 0xb, 0xc9, 0xbe, 0x6, - 0x5, 0xd4, 0xd1, 0x54, 0xf7, 0xb2, 0x39, 0x70, 0x0, 0x6, 0x2b, 0xb1, 0xf6, 0xbb, 0x7e, 0x85, 0x0, - 0x8, 0x97, 0xbd, 0x33, 0x1e, 0xaf, 0xc6, 0xa6, 0x6a}; - - uint8_t buf[240] = {0}; - - uint8_t bytesprops0[] = {0xa, 0x3e, 0x8d, 0xe4, 0xb4, 0x99}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8357}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 51}}, - }; - - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xf1, 0xfc, 0xa3, 0xa3, 0x4, 0x72, 0x6a, 0x4e, 0xfa, 0xa0, 0xa8, 0xa1, - 0x41, 0x16, 0x1e, 0x34, 0x23, 0xf0, 0x9c, 0xb9, 0xa4, 0x61, 0x1f, 0xba}; - uint8_t byteswillprops0[] = {0x65, 0x34, 0xd5, 0xb, 0xa7, 0x5, 0x98, 0xc9, 0xa8, 0x63, 0xad, - 0xb, 0x75, 0x3e, 0x5a, 0x7a, 0xb5, 0x9d, 0xc6, 0x64, 0x7c, 0x14}; - uint8_t byteswillprops2[] = {0xa0, 0x6d, 0xbb}; - uint8_t byteswillprops3[] = {0xf, 0xc7, 0xc8, 0x8b, 0x48, 0xd2, 0x29, 0xdf, 0xdf, 0x92, 0x47, 0x5c, 0x8b, 0xdc, 0x82, - 0x7, 0x7e, 0xc0, 0x4, 0x1b, 0x21, 0x5, 0xac, 0xea, 0x66, 0x57, 0xf9, 0x81, 0x1d}; - uint8_t byteswillprops4[] = {0x11, 0x4d, 0x39, 0x8b, 0xe5, 0xb1, 0xb2, 0xd4, 0x38, 0x33, 0x2e, - 0x4c, 0x4d, 0x7b, 0x4c, 0xdd, 0xd8, 0x35, 0x61, 0x8e, 0xf5, 0x8c}; - uint8_t byteswillprops5[] = {0xc9, 0xbe, 0x6, 0x5, 0xd4, 0xd1, 0x54, 0xf7, 0xb2, 0x39, 0x70}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20703}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30839}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31512}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {22, (char*)&byteswillprops0}, .v = {24, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&byteswillprops5}}}, - }; - - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2b, 0xb1, 0xf6, 0xbb, 0x7e, 0x85}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x97, 0xbd, 0x33, 0x1e, 0xaf, 0xc6, 0xa6, 0x6a}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 4479; - uint8_t client_id_bytes[] = {0x94, 0xe9, 0xd2, 0x65, 0x19, 0xa8, 0x82, 0x85, 0xfd, 0x1, 0xe8, 0xcf, 0x66, - 0xad, 0xdc, 0xee, 0xa7, 0xa6, 0x76, 0x47, 0xb, 0x8d, 0xbe, 0x22, 0x3b}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xd, 0x29, 0xbe, 0x5f, 0x8a, 0x14, 0xe, 0xa3, 0xe2, 0x6a, 0xbd, 0x20, 0x7e, 0x2a, 0x42, - 0x4e, 0xf, 0x4, 0x2d, 0xd9, 0x80, 0xe8, 0xdf, 0xef, 0x81, 0x6d, 0x7, 0x10, 0x47, 0xfe}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\193=\216", _password = Nothing, _lastWill = Nothing, _cleanSession = True, -// _keepAlive = 20616, _connID = "H\197jy\150\206eUf&\224\&9\ACK", _properties = [PropMessageExpiryInterval -// 29488,PropSessionExpiryInterval 29737,PropResponseTopic -// "Ls5x<+3\252\&4\144\174\CAN6'\ENQ\239Ahs?\DLE[",PropSessionExpiryInterval 5430,PropSubscriptionIdentifierAvailable -// 227,PropReasonString "yKY\251\167me\234W\197M\201 -// c\166\159\DC4\218\206/\132\151\203\DC1\238l\tF\192",PropSharedSubscriptionAvailable 99,PropResponseInformation -// "",PropSessionExpiryInterval 17158,PropContentType "N\220",PropTopicAlias 12265,PropSharedSubscriptionAvailable -// 66,PropRequestResponseInformation 71,PropContentType -// "\153\250\142\165\205PH\235\SOH\152\128o",PropResponseInformation -// "|\222\"SX\r\FS\153$\213\&5\ESCt=\235\143\SOcj\192\162\187j",PropMaximumQoS 134,PropMessageExpiryInterval -// 30799,PropServerKeepAlive 31360,PropAuthenticationMethod "\140\150\CAN\178\188\220\&5\r-\175",PropCorrelationData -// "\DC3\226",PropReceiveMaximum 31509]} -TEST(Connect5QCTest, Encode83) { - uint8_t pkt[] = {0x10, 0xc8, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x82, 0x50, 0x88, 0xa8, 0x1, 0x2, 0x0, - 0x0, 0x73, 0x30, 0x11, 0x0, 0x0, 0x74, 0x29, 0x8, 0x0, 0x16, 0x4c, 0x73, 0x35, 0x78, 0x3c, 0x2b, - 0x33, 0xfc, 0x34, 0x90, 0xae, 0x18, 0x36, 0x27, 0x5, 0xef, 0x41, 0x68, 0x73, 0x3f, 0x10, 0x5b, 0x11, - 0x0, 0x0, 0x15, 0x36, 0x29, 0xe3, 0x1f, 0x0, 0x1d, 0x79, 0x4b, 0x59, 0xfb, 0xa7, 0x6d, 0x65, 0xea, - 0x57, 0xc5, 0x4d, 0xc9, 0x20, 0x63, 0xa6, 0x9f, 0x14, 0xda, 0xce, 0x2f, 0x84, 0x97, 0xcb, 0x11, 0xee, - 0x6c, 0x9, 0x46, 0xc0, 0x2a, 0x63, 0x1a, 0x0, 0x0, 0x11, 0x0, 0x0, 0x43, 0x6, 0x3, 0x0, 0x2, - 0x4e, 0xdc, 0x23, 0x2f, 0xe9, 0x2a, 0x42, 0x19, 0x47, 0x3, 0x0, 0xc, 0x99, 0xfa, 0x8e, 0xa5, 0xcd, - 0x50, 0x48, 0xeb, 0x1, 0x98, 0x80, 0x6f, 0x1a, 0x0, 0x17, 0x7c, 0xde, 0x22, 0x53, 0x58, 0xd, 0x1c, - 0x99, 0x24, 0xd5, 0x35, 0x1b, 0x74, 0x3d, 0xeb, 0x8f, 0xe, 0x63, 0x6a, 0xc0, 0xa2, 0xbb, 0x6a, 0x24, - 0x86, 0x2, 0x0, 0x0, 0x78, 0x4f, 0x13, 0x7a, 0x80, 0x15, 0x0, 0xa, 0x8c, 0x96, 0x18, 0xb2, 0xbc, - 0xdc, 0x35, 0xd, 0x2d, 0xaf, 0x9, 0x0, 0x2, 0x13, 0xe2, 0x21, 0x7b, 0x15, 0x0, 0xd, 0x48, 0xc5, - 0x6a, 0x79, 0x96, 0xce, 0x65, 0x55, 0x66, 0x26, 0xe0, 0x39, 0x6, 0x0, 0x3, 0xc1, 0x3d, 0xd8}; - - uint8_t buf[213] = {0}; - - uint8_t bytesprops0[] = {0x4c, 0x73, 0x35, 0x78, 0x3c, 0x2b, 0x33, 0xfc, 0x34, 0x90, 0xae, - 0x18, 0x36, 0x27, 0x5, 0xef, 0x41, 0x68, 0x73, 0x3f, 0x10, 0x5b}; - uint8_t bytesprops1[] = {0x79, 0x4b, 0x59, 0xfb, 0xa7, 0x6d, 0x65, 0xea, 0x57, 0xc5, 0x4d, 0xc9, 0x20, 0x63, 0xa6, - 0x9f, 0x14, 0xda, 0xce, 0x2f, 0x84, 0x97, 0xcb, 0x11, 0xee, 0x6c, 0x9, 0x46, 0xc0}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x4e, 0xdc}; - uint8_t bytesprops4[] = {0x99, 0xfa, 0x8e, 0xa5, 0xcd, 0x50, 0x48, 0xeb, 0x1, 0x98, 0x80, 0x6f}; - uint8_t bytesprops5[] = {0x7c, 0xde, 0x22, 0x53, 0x58, 0xd, 0x1c, 0x99, 0x24, 0xd5, 0x35, 0x1b, - 0x74, 0x3d, 0xeb, 0x8f, 0xe, 0x63, 0x6a, 0xc0, 0xa2, 0xbb, 0x6a}; - uint8_t bytesprops6[] = {0x8c, 0x96, 0x18, 0xb2, 0xbc, 0xdc, 0x35, 0xd, 0x2d, 0xaf}; - uint8_t bytesprops7[] = {0x13, 0xe2}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29488}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29737}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5430}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17158}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12265}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30799}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31360}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31509}}, - }; - - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 20616; - uint8_t client_id_bytes[] = {0x48, 0xc5, 0x6a, 0x79, 0x96, 0xce, 0x65, 0x55, 0x66, 0x26, 0xe0, 0x39, 0x6}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xc1, 0x3d, 0xd8}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just -// "\DLE\162\233\185\169\148\163\FS\DLE\DLE\EM\128\172$0\v\163\NAK\171\178o\152\247\162", _password = Just -// "\SYN)'\EMZ{&\170*\141\175\195\166\136\153%P\165\171Q\221Ps\200", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS1, _willTopic = -// "\179j\234\186\173`\r5\139\224\166\231v\170\206~\241\ENQ7\249\230\240\135\&2\249\173ou\130", _willMsg = -// "\184\198C\184", _willProps = [PropSharedSubscriptionAvailable 97,PropReasonString -// "Qx\242(`\168?L\196\NUL\GS\199\&80\131\207*\205\155\&9%5",PropAuthenticationData "",PropTopicAlias -// 8045,PropServerKeepAlive 6785,PropResponseTopic -// "\165\244\r\164\209\238&\148\238\ETX\222}z\174\144\154@\203[\157\222",PropMaximumPacketSize -// 9028,PropPayloadFormatIndicator 201,PropTopicAliasMaximum 26182,PropSessionExpiryInterval -// 10590,PropSessionExpiryInterval 14802,PropAuthenticationData -// "HE\197Ob\t\129\189>\237\230.\185m\SUB3-\211G",PropRequestProblemInformation 135,PropReasonString -// "\219\255\142",PropReasonString "\t%UZ",PropUserProperty "\226" "",PropSessionExpiryInterval -// 18513,PropWildcardSubscriptionAvailable 239,PropMaximumPacketSize 21805]}), _cleanSession = True, _keepAlive = 23215, -// _connID = "'\ESC", _properties = [PropAuthenticationMethod -// "\198^NL]\DLEA(\NAKG+\195-\NAK\219h",PropRequestResponseInformation 124,PropWillDelayInterval -// 1971,PropWildcardSubscriptionAvailable 130,PropMaximumPacketSize 1315,PropSubscriptionIdentifier -// 22,PropAuthenticationData "\163\244\181\255\217\157\198`\DC4\144",PropMaximumQoS 80,PropTopicAliasMaximum -// 9708,PropSessionExpiryInterval 9993,PropReasonString "\DC1",PropMaximumPacketSize 26296,PropSessionExpiryInterval -// 6407,PropSharedSubscriptionAvailable 177,PropCorrelationData -// "\151\193\187\168\"W\163\128\169\SUBx\FS\148k{\176",PropReceiveMaximum 30173,PropReasonString -// "\199\186",PropResponseInformation "]-\182\240\167\SUB\153\174<\CAN\FS\NAK\136+H\204\128#",PropServerReference -// "\187>\224\253\SOH\SOH\140\218\f\ACK",PropTopicAliasMaximum 32410,PropResponseInformation -// ":G\150\STX",PropSharedSubscriptionAvailable 32,PropMaximumPacketSize 3674,PropMessageExpiryInterval 7003]} -TEST(Connect5QCTest, Encode84) { - uint8_t pkt[] = { - 0x10, 0x8f, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x5a, 0xaf, 0x9d, 0x1, 0x15, 0x0, 0x10, 0xc6, - 0x5e, 0x4e, 0x4c, 0x5d, 0x10, 0x41, 0x28, 0x15, 0x47, 0x2b, 0xc3, 0x2d, 0x15, 0xdb, 0x68, 0x19, 0x7c, 0x18, 0x0, - 0x0, 0x7, 0xb3, 0x28, 0x82, 0x27, 0x0, 0x0, 0x5, 0x23, 0xb, 0x16, 0x16, 0x0, 0xa, 0xa3, 0xf4, 0xb5, 0xff, - 0xd9, 0x9d, 0xc6, 0x60, 0x14, 0x90, 0x24, 0x50, 0x22, 0x25, 0xec, 0x11, 0x0, 0x0, 0x27, 0x9, 0x1f, 0x0, 0x1, - 0x11, 0x27, 0x0, 0x0, 0x66, 0xb8, 0x11, 0x0, 0x0, 0x19, 0x7, 0x2a, 0xb1, 0x9, 0x0, 0x10, 0x97, 0xc1, 0xbb, - 0xa8, 0x22, 0x57, 0xa3, 0x80, 0xa9, 0x1a, 0x78, 0x1c, 0x94, 0x6b, 0x7b, 0xb0, 0x21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, 0x1, 0xe2, 0x0, 0x0, 0x11, 0x0, 0x0, - 0x48, 0x51, 0x28, 0xef, 0x27, 0x0, 0x0, 0x55, 0x2d, 0x0, 0x1d, 0xb3, 0x6a, 0xea, 0xba, 0xad, 0x60, 0xd, 0x35, - 0x8b, 0xe0, 0xa6, 0xe7, 0x76, 0xaa, 0xce, 0x7e, 0xf1, 0x5, 0x37, 0xf9, 0xe6, 0xf0, 0x87, 0x32, 0xf9, 0xad, 0x6f, - 0x75, 0x82, 0x0, 0x4, 0xb8, 0xc6, 0x43, 0xb8, 0x0, 0x18, 0x10, 0xa2, 0xe9, 0xb9, 0xa9, 0x94, 0xa3, 0x1c, 0x10, - 0x10, 0x19, 0x80, 0xac, 0x24, 0x30, 0xb, 0xa3, 0x15, 0xab, 0xb2, 0x6f, 0x98, 0xf7, 0xa2, 0x0, 0x18, 0x16, 0x29, - 0x27, 0x19, 0x5a, 0x7b, 0x26, 0xaa, 0x2a, 0x8d, 0xaf, 0xc3, 0xa6, 0x88, 0x99, 0x25, 0x50, 0xa5, 0xab, 0x51, 0xdd, - 0x50, 0x73, 0xc8}; - - uint8_t buf[412] = {0}; - - uint8_t bytesprops0[] = {0xc6, 0x5e, 0x4e, 0x4c, 0x5d, 0x10, 0x41, 0x28, - 0x15, 0x47, 0x2b, 0xc3, 0x2d, 0x15, 0xdb, 0x68}; - uint8_t bytesprops1[] = {0xa3, 0xf4, 0xb5, 0xff, 0xd9, 0x9d, 0xc6, 0x60, 0x14, 0x90}; - uint8_t bytesprops2[] = {0x11}; - uint8_t bytesprops3[] = {0x97, 0xc1, 0xbb, 0xa8, 0x22, 0x57, 0xa3, 0x80, - 0xa9, 0x1a, 0x78, 0x1c, 0x94, 0x6b, 0x7b, 0xb0}; - uint8_t bytesprops4[] = {0xc7, 0xba}; - uint8_t bytesprops5[] = {0x5d, 0x2d, 0xb6, 0xf0, 0xa7, 0x1a, 0x99, 0xae, 0x3c, - 0x18, 0x1c, 0x15, 0x88, 0x2b, 0x48, 0xcc, 0x80, 0x23}; - uint8_t bytesprops6[] = {0xbb, 0x3e, 0xe0, 0xfd, 0x1, 0x1, 0x8c, 0xda, 0xc, 0x6}; - uint8_t bytesprops7[] = {0x3a, 0x47, 0x96, 0x2}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1971}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1315}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9708}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9993}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26296}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6407}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30173}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32410}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3674}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7003}}, - }; - - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x51, 0x78, 0xf2, 0x28, 0x60, 0xa8, 0x3f, 0x4c, 0xc4, 0x0, 0x1d, - 0xc7, 0x38, 0x30, 0x83, 0xcf, 0x2a, 0xcd, 0x9b, 0x39, 0x25, 0x35}; - uint8_t byteswillprops1[] = {0}; - uint8_t byteswillprops2[] = {0xa5, 0xf4, 0xd, 0xa4, 0xd1, 0xee, 0x26, 0x94, 0xee, 0x3, 0xde, - 0x7d, 0x7a, 0xae, 0x90, 0x9a, 0x40, 0xcb, 0x5b, 0x9d, 0xde}; - uint8_t byteswillprops3[] = {0x48, 0x45, 0xc5, 0x4f, 0x62, 0x9, 0x81, 0xbd, 0x3e, 0xed, - 0xe6, 0x2e, 0xb9, 0x6d, 0x1a, 0x33, 0x2d, 0xd3, 0x47}; - uint8_t byteswillprops4[] = {0xdb, 0xff, 0x8e}; - uint8_t byteswillprops5[] = {0x9, 0x25, 0x55, 0x5a}; - uint8_t byteswillprops7[] = {0}; - uint8_t byteswillprops6[] = {0xe2}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8045}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6785}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9028}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26182}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10590}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14802}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {1, (char*)&byteswillprops6}, .v = {0, (char*)&byteswillprops7}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18513}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21805}}, - }; - - lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb3, 0x6a, 0xea, 0xba, 0xad, 0x60, 0xd, 0x35, 0x8b, 0xe0, - 0xa6, 0xe7, 0x76, 0xaa, 0xce, 0x7e, 0xf1, 0x5, 0x37, 0xf9, - 0xe6, 0xf0, 0x87, 0x32, 0xf9, 0xad, 0x6f, 0x75, 0x82}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb8, 0xc6, 0x43, 0xb8}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 23215; - uint8_t client_id_bytes[] = {0x27, 0x1b}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x10, 0xa2, 0xe9, 0xb9, 0xa9, 0x94, 0xa3, 0x1c, 0x10, 0x10, 0x19, 0x80, - 0xac, 0x24, 0x30, 0xb, 0xa3, 0x15, 0xab, 0xb2, 0x6f, 0x98, 0xf7, 0xa2}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x16, 0x29, 0x27, 0x19, 0x5a, 0x7b, 0x26, 0xaa, 0x2a, 0x8d, 0xaf, 0xc3, - 0xa6, 0x88, 0x99, 0x25, 0x50, 0xa5, 0xab, 0x51, 0xdd, 0x50, 0x73, 0xc8}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8075, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 17947 [("E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\b\194\179\135\DEL\153\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS1}),("Ck\239\&5\r'\223d\205C\238\188\149\179\198\131\139\135\200j\152\135\161aZ5r\178",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("P\157\181\133\180{",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("hs_K\231\&7\ENQ\142\157\194\196\252\240\136)\157\159\167\255G",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("t\128h\134T\160\178ra\146\201",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("2\136\235\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("t\200\SOH\144\243\v\159F&\253\186*\163\136d\rA\DC1\ACK\209\"\DC1\193V\DC1",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\232\169\205\147\SYN\129\145\196#!\ACK\171I\225",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\215\221\EM\254/\164d>\184\211O\228\212N\251O\183\208V\241\211\t\209\244\RS\186",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic +// "\ENQ\140\&1\235e",PropSubscriptionIdentifierAvailable 44,PropSubscriptionIdentifierAvailable +// 21,PropMaximumPacketSize 27004,PropSubscriptionIdentifier 12,PropRequestResponseInformation 254] +TEST(Subscribe5QCTest, Encode74) { + uint8_t pkt[] = {0x82, 0xc7, 0x1, 0x46, 0x1b, 0x15, 0x8, 0x0, 0x5, 0x5, 0x8c, 0x31, 0xeb, 0x65, 0x29, 0x2c, 0x29, + 0x15, 0x27, 0x0, 0x0, 0x69, 0x7c, 0xb, 0xc, 0x19, 0xfe, 0x0, 0x1, 0x45, 0x0, 0x0, 0x7, 0x8, + 0xc2, 0xb3, 0x87, 0x7f, 0x99, 0x5c, 0x1, 0x0, 0x1c, 0x43, 0x6b, 0xef, 0x35, 0xd, 0x27, 0xdf, 0x64, + 0xcd, 0x43, 0xee, 0xbc, 0x95, 0xb3, 0xc6, 0x83, 0x8b, 0x87, 0xc8, 0x6a, 0x98, 0x87, 0xa1, 0x61, 0x5a, + 0x35, 0x72, 0xb2, 0x0, 0x0, 0x6, 0x50, 0x9d, 0xb5, 0x85, 0xb4, 0x7b, 0x1, 0x0, 0x14, 0x68, 0x73, + 0x5f, 0x4b, 0xe7, 0x37, 0x5, 0x8e, 0x9d, 0xc2, 0xc4, 0xfc, 0xf0, 0x88, 0x29, 0x9d, 0x9f, 0xa7, 0xff, + 0x47, 0x0, 0x0, 0xb, 0x74, 0x80, 0x68, 0x86, 0x54, 0xa0, 0xb2, 0x72, 0x61, 0x92, 0xc9, 0x2, 0x0, + 0x4, 0x32, 0x88, 0xeb, 0xe1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x19, 0x74, 0xc8, 0x1, 0x90, 0xf3, 0xb, + 0x9f, 0x46, 0x26, 0xfd, 0xba, 0x2a, 0xa3, 0x88, 0x64, 0xd, 0x41, 0x11, 0x6, 0xd1, 0x22, 0x11, 0xc1, + 0x56, 0x11, 0x2, 0x0, 0xe, 0xe8, 0xa9, 0xcd, 0x93, 0x16, 0x81, 0x91, 0xc4, 0x23, 0x21, 0x6, 0xab, + 0x49, 0xe1, 0x1, 0x0, 0x1a, 0xd7, 0xdd, 0x19, 0xfe, 0x2f, 0xa4, 0x64, 0x3e, 0xb8, 0xd3, 0x4f, 0xe4, + 0xd4, 0x4e, 0xfb, 0x4f, 0xb7, 0xd0, 0x56, 0xf1, 0xd3, 0x9, 0xd1, 0xf4, 0x1e, 0xba, 0x1}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[212] = {0}; -// ConnectRequest {_username = Nothing, _password = Just "\214", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS0, _willTopic = "\162\190\DC4\DC4\rt\172-\134\146\171Y\SUB\181GJ\232\223", _willMsg = "", _willProps = -// [PropMessageExpiryInterval 2668,PropContentType -// "a\250\155\193\222\253\221\130d\151\&2\195;-\128G\DC4\231\ACK^-\232w\194\236\DEL\212",PropRequestResponseInformation -// 218,PropMessageExpiryInterval 20814,PropMaximumPacketSize 24455,PropWildcardSubscriptionAvailable -// 17,PropMessageExpiryInterval 27712]}), _cleanSession = False, _keepAlive = 3268, _connID = -// "X\ENQ\249\146\ti\193j\128\159\242\ACK\200\143\vTWH]\156\DEL", _properties = [PropServerKeepAlive -// 13392,PropResponseInformation -// "\185C\227'\DEL\ACK\b$\244\219\252\254\STX\191\209Hs\EOT\STX^5\132",PropSessionExpiryInterval 7071,PropMaximumQoS -// 91,PropRequestProblemInformation 198,PropContentType -// "\133^6\183^\198\143l\rrA\DC4\SOC\130t+\SYN9",PropTopicAliasMaximum 24597,PropSessionExpiryInterval -// 25612,PropTopicAliasMaximum 13004,PropWildcardSubscriptionAvailable 179,PropCorrelationData -// "\144\244l\RSl]\206\134\RS\156}6Aq\197\197\SIp\188\249\173B\223w\141\142\DC4\219\199\178",PropReceiveMaximum -// 31787,PropMessageExpiryInterval 6868,PropWildcardSubscriptionAvailable 8,PropAuthenticationData -// "@\236\171\225\232L\159e\157\a\250[\192\230\167\r\140\128\137sY\138\t9a3\EM",PropSessionExpiryInterval -// 23555,PropMessageExpiryInterval 25043,PropResponseTopic "\251T4=\145",PropAssignedClientIdentifier -// "\133\141\166\f\137\"\214\212\156\GS#cD\235j\229$\251\228\FS",PropRetainAvailable -// 151,PropSubscriptionIdentifierAvailable 152,PropServerReference -// "7t\213$V\174\208\143\143.\197\156@\SUB\247\233,3[L\NUL\236\152",PropCorrelationData "",PropMessageExpiryInterval -// 12365,PropRequestProblemInformation 44]} -TEST(Connect5QCTest, Encode85) { - uint8_t pkt[] = { - 0x10, 0xd2, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x24, 0xc, 0xc4, 0xe2, 0x1, 0x13, 0x34, 0x50, 0x1a, - 0x0, 0x16, 0xb9, 0x43, 0xe3, 0x27, 0x7f, 0x6, 0x8, 0x24, 0xf4, 0xdb, 0xfc, 0xfe, 0x2, 0xbf, 0xd1, 0x48, 0x73, - 0x4, 0x2, 0x5e, 0x35, 0x84, 0x11, 0x0, 0x0, 0x1b, 0x9f, 0x24, 0x5b, 0x17, 0xc6,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17, 0x2c, 0x0, 0x15, 0x58, 0x5, 0xf9, 0x92, - 0x9, 0x69, 0xc1, 0x6a, 0x80, 0x9f, 0xf2, 0x6, 0xc8, 0x8f, 0xb, 0x54, 0x57, 0x48, 0x5d, 0x9c, 0x7f, 0x36, 0x2, - 0x0, 0x0, 0xa, 0x6c, 0x3, 0x0, 0x1b, 0x61, 0xfa, 0x9b, 0xc1, 0xde, 0xfd, 0xdd, 0x82, 0x64, 0x97, 0x32, 0xc3, - 0x3b, 0x2d, 0x80, 0x47, 0x14, 0xe7, 0x6, 0x5e, 0x2d, 0xe8, 0x77, 0xc2, 0xec, 0x7f, 0xd4, 0x19, 0xda, 0x2, 0x0, - 0x0, 0x51, 0x4e, 0x27, 0x0, 0x0, 0x5f, 0x87, 0x28, 0x11, 0x2, 0x0, 0x0, 0x6c, 0x40, 0x0, 0x12, 0xa2, 0xbe, - 0x14, 0x14, 0xd, 0x74, 0xac, 0x2d, 0x86, 0x92, 0xab, 0x59, 0x1a, 0xb5, 0x47, 0x4a, 0xe8, 0xdf, 0x0, 0x0}; - - uint8_t buf[351] = {0}; - - uint8_t bytesprops0[] = {0xb9, 0x43, 0xe3, 0x27, 0x7f, 0x6, 0x8, 0x24, 0xf4, 0xdb, 0xfc, - 0xfe, 0x2, 0xbf, 0xd1, 0x48, 0x73, 0x4, 0x2, 0x5e, 0x35, 0x84}; - uint8_t bytesprops1[] = {0x85, 0x5e, 0x36, 0xb7, 0x5e, 0xc6, 0x8f, 0x6c, 0xd, 0x72, - 0x41, 0x14, 0xe, 0x43, 0x82, 0x74, 0x2b, 0x16, 0x39}; - uint8_t bytesprops2[] = {0x90, 0xf4, 0x6c, 0x1e, 0x6c, 0x5d, 0xce, 0x86, 0x1e, 0x9c, 0x7d, 0x36, 0x41, 0x71, 0xc5, - 0xc5, 0xf, 0x70, 0xbc, 0xf9, 0xad, 0x42, 0xdf, 0x77, 0x8d, 0x8e, 0x14, 0xdb, 0xc7, 0xb2}; - uint8_t bytesprops3[] = {0x40, 0xec, 0xab, 0xe1, 0xe8, 0x4c, 0x9f, 0x65, 0x9d, 0x7, 0xfa, 0x5b, 0xc0, 0xe6, - 0xa7, 0xd, 0x8c, 0x80, 0x89, 0x73, 0x59, 0x8a, 0x9, 0x39, 0x61, 0x33, 0x19}; - uint8_t bytesprops4[] = {0xfb, 0x54, 0x34, 0x3d, 0x91}; - uint8_t bytesprops5[] = {0x85, 0x8d, 0xa6, 0xc, 0x89, 0x22, 0xd6, 0xd4, 0x9c, 0x1d, - 0x23, 0x63, 0x44, 0xeb, 0x6a, 0xe5, 0x24, 0xfb, 0xe4, 0x1c}; - uint8_t bytesprops6[] = {0x37, 0x74, 0xd5, 0x24, 0x56, 0xae, 0xd0, 0x8f, 0x8f, 0x2e, 0xc5, 0x9c, - 0x40, 0x1a, 0xf7, 0xe9, 0x2c, 0x33, 0x5b, 0x4c, 0x0, 0xec, 0x98}; - uint8_t bytesprops7[] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x45}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x8, 0xc2, 0xb3, 0x87, 0x7f, 0x99, 0x5c}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x43, 0x6b, 0xef, 0x35, 0xd, 0x27, 0xdf, 0x64, 0xcd, 0x43, + 0xee, 0xbc, 0x95, 0xb3, 0xc6, 0x83, 0x8b, 0x87, 0xc8, 0x6a, + 0x98, 0x87, 0xa1, 0x61, 0x5a, 0x35, 0x72, 0xb2}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x50, 0x9d, 0xb5, 0x85, 0xb4, 0x7b}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x68, 0x73, 0x5f, 0x4b, 0xe7, 0x37, 0x5, 0x8e, 0x9d, 0xc2, + 0xc4, 0xfc, 0xf0, 0x88, 0x29, 0x9d, 0x9f, 0xa7, 0xff, 0x47}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x74, 0x80, 0x68, 0x86, 0x54, 0xa0, 0xb2, 0x72, 0x61, 0x92, 0xc9}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x32, 0x88, 0xeb, 0xe1}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x74, 0xc8, 0x1, 0x90, 0xf3, 0xb, 0x9f, 0x46, 0x26, 0xfd, 0xba, 0x2a, 0xa3, + 0x88, 0x64, 0xd, 0x41, 0x11, 0x6, 0xd1, 0x22, 0x11, 0xc1, 0x56, 0x11}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe8, 0xa9, 0xcd, 0x93, 0x16, 0x81, 0x91, 0xc4, 0x23, 0x21, 0x6, 0xab, 0x49, 0xe1}; + lwmqtt_string_t topic_filter_s9 = {14, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xd7, 0xdd, 0x19, 0xfe, 0x2f, 0xa4, 0x64, 0x3e, 0xb8, 0xd3, 0x4f, 0xe4, 0xd4, + 0x4e, 0xfb, 0x4f, 0xb7, 0xd0, 0x56, 0xf1, 0xd3, 0x9, 0xd1, 0xf4, 0x1e, 0xba}; + lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x5, 0x8c, 0x31, 0xeb, 0x65}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13392}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7071}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24597}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25612}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13004}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31787}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6868}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23555}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25043}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12365}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 44}}, - }; - - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x61, 0xfa, 0x9b, 0xc1, 0xde, 0xfd, 0xdd, 0x82, 0x64, 0x97, 0x32, 0xc3, 0x3b, 0x2d, - 0x80, 0x47, 0x14, 0xe7, 0x6, 0x5e, 0x2d, 0xe8, 0x77, 0xc2, 0xec, 0x7f, 0xd4}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2668}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20814}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24455}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27712}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27004}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 254}}, }; - lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa2, 0xbe, 0x14, 0x14, 0xd, 0x74, 0xac, 0x2d, 0x86, - 0x92, 0xab, 0x59, 0x1a, 0xb5, 0x47, 0x4a, 0xe8, 0xdf}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3268; - uint8_t client_id_bytes[] = {0x58, 0x5, 0xf9, 0x92, 0x9, 0x69, 0xc1, 0x6a, 0x80, 0x9f, 0xf2, - 0x6, 0xc8, 0x8f, 0xb, 0x54, 0x57, 0x48, 0x5d, 0x9c, 0x7f}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xd6}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17947, 11, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 167 [("\231\169\150\t\250\191\150<\142\244\175\168\192\184\179",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\212\vx}\a\239:\\|\164~\165\239\172\b\182j\"e\244",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\199\200~",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\US97\178\208\r#N\n\150nm+6\213\NUL\171\252\t",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\137\ETX\197\217\NUL\223\232\207\253\202\144V#\158k\156DSE2\145\ENQ\158\234\133\150",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("#\149\222<\ETXQ\182,\188$Y~(\178|T\176_\145\151'",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\175\ENQ\GS\245\242)\153\DC2\129\190\DC4\n\235\129\160 \190\233",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("DJ\236\247\\fp\240\131\213\DLEP\133\CAN\133",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\188n\248-\193\248\138\147\SI\181\to\137\t\148\230\233=",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerReference +// "\159\250\222\226B\146z{\n\GS\163Q>\212\209b\140\f^|\225!\ETBS",PropRequestProblemInformation 41,PropCorrelationData +// "\167\165\236\242\220\NUL!\243\239\236\249(50\143",PropCorrelationData "!V\136\227\201R\STX",PropReasonString +// "\204\220Z\199A\209\242\&4\137\ETB\182r\nQ\137\234P\239\174^&\SYN",PropRequestProblemInformation +// 146,PropResponseTopic "\153+\SYN\164\143\202\203\241\178\ETX/\129\179\SI\165:L\187\249aXN",PropSubscriptionIdentifier +// 13,PropRequestResponseInformation 80,PropMessageExpiryInterval 23274,PropReceiveMaximum +// 1962,PropSharedSubscriptionAvailable 149,PropMaximumQoS 62,PropResponseInformation +// "QD5\172e\226i\226F\131J\188\136",PropResponseTopic "\EM\160\CAN\131 +// \229\162\139LF\219\159\167p,\217b\176\208\242Y\199I\US\246(\169",PropSharedSubscriptionAvailable +// 59,PropReceiveMaximum 31104,PropMessageExpiryInterval 8247,PropAssignedClientIdentifier +// "\GSA\148\189\b\203\157\128T\142%\EOT`\179{N\151l",PropRequestResponseInformation 165,PropRequestProblemInformation +// 246,PropAssignedClientIdentifier +// "\255\243\220\ENQ\239\198\194d\159\145\171\ENQ\f\149\EMH\176g\235",PropReceiveMaximum 18795] +TEST(Subscribe5QCTest, Encode75) { + uint8_t pkt[] = { + 0x82, 0xa1, 0x3, 0x0, 0xa7, 0xe7, 0x1, 0x1c, 0x0, 0x18, 0x9f, 0xfa, 0xde, 0xe2, 0x42, 0x92, 0x7a, 0x7b, 0xa, + 0x1d, 0xa3, 0x51, 0x3e, 0xd4, 0xd1, 0x62, 0x8c, 0xc, 0x5e, 0x7c, 0xe1, 0x21, 0x17, 0x53, 0x17, 0x29, 0x9, 0x0, + 0xf, 0xa7, 0xa5, 0xec, 0xf2, 0xdc, 0x0, 0x21, 0xf3, 0xef, 0xec, 0xf9, 0x28, 0x35, 0x30, 0x8f, 0x9, 0x0, 0x7, + 0x21, 0x56, 0x88, 0xe3, 0xc9, 0x52, 0x2, 0x1f, 0x0, 0x16, 0xcc, 0xdc, 0x5a, 0xc7, 0x41, 0xd1, 0xf2, 0x34, 0x89, + 0x17, 0xb6, 0x72, 0xa, 0x51, 0x89, 0xea, 0x50, 0xef, 0xae, 0x5e, 0x26, 0x16, 0x17, 0x92, 0x8, 0x0, 0x16, 0x99, + 0x2b, 0x16, 0xa4, 0x8f, 0xca, 0xcb, 0xf1, 0xb2, 0x3, 0x2f, 0x81, 0xb3, 0xf, 0xa5, 0x3a, 0x4c, 0xbb, 0xf9, 0x61, + 0x58, 0x4e, 0xb, 0xd, 0x19, 0x50, 0x2, 0x0, 0x0, 0x5a, 0xea, 0x21, 0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xd9, 0x0, 0xdf, 0xe8, 0xcf, 0xfd, 0xca, 0x90, 0x56, 0x23, 0x9e, + 0x6b, 0x9c, 0x44, 0x53, 0x45, 0x32, 0x91, 0x5, 0x9e, 0xea, 0x85, 0x96, 0x1, 0x0, 0x15, 0x23, 0x95, 0xde, 0x3c, + 0x3, 0x51, 0xb6, 0x2c, 0xbc, 0x24, 0x59, 0x7e, 0x28, 0xb2, 0x7c, 0x54, 0xb0, 0x5f, 0x91, 0x97, 0x27, 0x0, 0x0, + 0x12, 0xaf, 0x5, 0x1d, 0xf5, 0xf2, 0x29, 0x99, 0x12, 0x81, 0xbe, 0x14, 0xa, 0xeb, 0x81, 0xa0, 0x20, 0xbe, 0xe9, + 0x2, 0x0, 0xf, 0x44, 0x4a, 0xec, 0xf7, 0x5c, 0x66, 0x70, 0xf0, 0x83, 0xd5, 0x10, 0x50, 0x85, 0x18, 0x85, 0x1, + 0x0, 0x12, 0xbc, 0x6e, 0xf8, 0x2d, 0xc1, 0xf8, 0x8a, 0x93, 0xf, 0xb5, 0x9, 0x6f, 0x89, 0x9, 0x94, 0xe6, 0xe9, + 0x3d, 0x1}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[430] = {0}; -// ConnectRequest {_username = Nothing, _password = Just -// ")\156AQ\231\191\SYN\185h\225\178\137\238\&3\EOT\138\248\&7R\EM,*\SYN=\n\224\DC2", _lastWill = Nothing, _cleanSession -// = True, _keepAlive = 28678, _connID = -// "\189\132\188/]\224s+\NULTF\196\233U\GS\250L\167\176\EM\133\NUL\254\161Ol\136\162\209", _properties = -// [PropReceiveMaximum 15858,PropServerReference "",PropAuthenticationData -// "\207\177<\220\196Y\170\EM\208\204o",PropCorrelationData -// "J\DEL\175\233\219\227\204\&3\175\CANF\246\182\146\163Y\214\133\\\SI\190\226\234\f\135`Ey",PropResponseInformation -// "k\SYN\188t\231\r;\221\142.\137\DLE\NAK \197E\181\248\178",PropPayloadFormatIndicator 44,PropUserProperty -// "\t\182\149\164B\132;\187\215\201\SO\ACK\194j" "0b",PropTopicAliasMaximum 19404,PropMessageExpiryInterval -// 32432,PropTopicAliasMaximum 21496,PropSharedSubscriptionAvailable 216,PropWillDelayInterval -// 24641,PropAuthenticationMethod "\145\217\155\157",PropResponseTopic -// "\SYN/\143\DC1(l#\187\242\242\DC4P0",PropAuthenticationData "\190\235-",PropMaximumPacketSize -// 19451,PropServerReference "\175\207\a.\NAK\246",PropResponseTopic -// "\SUB\NAK\211\161f\DC2\179\238H6\157\145\247\130OgP*\NULw\212.\199&\224\145\242\231\145\205"]} -TEST(Connect5QCTest, Encode86) { - uint8_t pkt[] = {0x10, 0xe9, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2, 0x70, 0x6, 0xbe, 0x1, 0x21, 0x3d, - 0xf2, 0x1c, 0x0, 0x0, 0x16, 0x0, 0xb, 0xcf, 0xb1, 0x3c, 0xdc, 0xc4, 0x59, 0xaa, 0x19, 0xd0, 0xcc, - 0x6f, 0x9, 0x0, 0x1c, 0x4a, 0x7f, 0xaf, 0xe9, 0xdb, 0xe3, 0xcc, 0x33, 0xaf, 0x18, 0x46, 0xf6, 0xb6, - 0x92, 0xa3, 0x59, 0xd6, 0x85, 0x5c, 0xf, 0xbe, 0xe2, 0xea, 0xc, 0x87, 0x60, 0x45, 0x79, 0x1a, 0x0, - 0x13, 0x6b, 0x16, 0xbc, 0x74, 0xe7, 0xd, 0x3b, 0xdd, 0x8e, 0x2e, 0x89, 0x10, 0x15, 0x20, 0xc5, 0x45, - 0xb5, 0xf8, 0xb2, 0x1, 0x2c, 0x26, 0x0, 0xe, 0x9, 0xb6, 0x95, 0xa4, 0x42, 0x84, 0x3b, 0xbb, 0xd7, - 0xc9, 0xe, 0x6, 0xc2, 0x6a, 0x0, 0x2, 0x30, 0x62, 0x22, 0x4b, 0xcc, 0x2, 0x0, 0x0, 0x7e, 0xb0, - 0x22, 0x53, 0xf8, 0x2a, 0xd8, 0x18, 0x0, 0x0, 0x60, 0x41, 0x15, 0x0, 0x4, 0x91, 0xd9, 0x9b, 0x9d, - 0x8, 0x0, 0xd, 0x16, 0x2f, 0x8f, 0x11, 0x28, 0x6c, 0x23, 0xbb, 0xf2, 0xf2, 0x14, 0x50, 0x30, 0x16, - 0x0, 0x3, 0xbe, 0xeb, 0x2d, 0x27, 0x0, 0x0, 0x4b, 0xfb, 0x1c, 0x0, 0x6, 0xaf, 0xcf, 0x7, 0x2e, - 0x15, 0xf6, 0x8, 0x0, 0x1e, 0x1a, 0x15, 0xd3, 0xa1, 0x66, 0x12, 0xb3, 0xee, 0x48, 0x36, 0x9d, 0x91, - 0xf7, 0x82, 0x4f, 0x67, 0x50, 0x2a, 0x0, 0x77, 0xd4, 0x2e, 0xc7, 0x26, 0xe0, 0x91, 0xf2, 0xe7, 0x91, - 0xcd, 0x0, 0x1d, 0xbd, 0x84, 0xbc, 0x2f, 0x5d, 0xe0, 0x73, 0x2b, 0x0, 0x54, 0x46, 0xc4, 0xe9, 0x55, - 0x1d, 0xfa, 0x4c, 0xa7, 0xb0, 0x19, 0x85, 0x0, 0xfe, 0xa1, 0x4f, 0x6c, 0x88, 0xa2, 0xd1}; - - uint8_t buf[246] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xe7, 0xa9, 0x96, 0x9, 0xfa, 0xbf, 0x96, 0x3c, + 0x8e, 0xf4, 0xaf, 0xa8, 0xc0, 0xb8, 0xb3}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd4, 0xb, 0x78, 0x7d, 0x7, 0xef, 0x3a, 0x5c, 0x7c, 0xa4, + 0x7e, 0xa5, 0xef, 0xac, 0x8, 0xb6, 0x6a, 0x22, 0x65, 0xf4}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc7, 0xc8, 0x7e}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x1f, 0x39, 0x37, 0xb2, 0xd0, 0xd, 0x23, 0x4e, 0xa, 0x96, + 0x6e, 0x6d, 0x2b, 0x36, 0xd5, 0x0, 0xab, 0xfc, 0x9}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x89, 0x3, 0xc5, 0xd9, 0x0, 0xdf, 0xe8, 0xcf, 0xfd, 0xca, 0x90, 0x56, 0x23, + 0x9e, 0x6b, 0x9c, 0x44, 0x53, 0x45, 0x32, 0x91, 0x5, 0x9e, 0xea, 0x85, 0x96}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x23, 0x95, 0xde, 0x3c, 0x3, 0x51, 0xb6, 0x2c, 0xbc, 0x24, 0x59, + 0x7e, 0x28, 0xb2, 0x7c, 0x54, 0xb0, 0x5f, 0x91, 0x97, 0x27}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xaf, 0x5, 0x1d, 0xf5, 0xf2, 0x29, 0x99, 0x12, 0x81, + 0xbe, 0x14, 0xa, 0xeb, 0x81, 0xa0, 0x20, 0xbe, 0xe9}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x44, 0x4a, 0xec, 0xf7, 0x5c, 0x66, 0x70, 0xf0, + 0x83, 0xd5, 0x10, 0x50, 0x85, 0x18, 0x85}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xbc, 0x6e, 0xf8, 0x2d, 0xc1, 0xf8, 0x8a, 0x93, 0xf, + 0xb5, 0x9, 0x6f, 0x89, 0x9, 0x94, 0xe6, 0xe9, 0x3d}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x9f, 0xfa, 0xde, 0xe2, 0x42, 0x92, 0x7a, 0x7b, 0xa, 0x1d, 0xa3, 0x51, + 0x3e, 0xd4, 0xd1, 0x62, 0x8c, 0xc, 0x5e, 0x7c, 0xe1, 0x21, 0x17, 0x53}; + uint8_t bytesprops1[] = {0xa7, 0xa5, 0xec, 0xf2, 0xdc, 0x0, 0x21, 0xf3, 0xef, 0xec, 0xf9, 0x28, 0x35, 0x30, 0x8f}; + uint8_t bytesprops2[] = {0x21, 0x56, 0x88, 0xe3, 0xc9, 0x52, 0x2}; + uint8_t bytesprops3[] = {0xcc, 0xdc, 0x5a, 0xc7, 0x41, 0xd1, 0xf2, 0x34, 0x89, 0x17, 0xb6, + 0x72, 0xa, 0x51, 0x89, 0xea, 0x50, 0xef, 0xae, 0x5e, 0x26, 0x16}; + uint8_t bytesprops4[] = {0x99, 0x2b, 0x16, 0xa4, 0x8f, 0xca, 0xcb, 0xf1, 0xb2, 0x3, 0x2f, + 0x81, 0xb3, 0xf, 0xa5, 0x3a, 0x4c, 0xbb, 0xf9, 0x61, 0x58, 0x4e}; + uint8_t bytesprops5[] = {0x51, 0x44, 0x35, 0xac, 0x65, 0xe2, 0x69, 0xe2, 0x46, 0x83, 0x4a, 0xbc, 0x88}; + uint8_t bytesprops6[] = {0x19, 0xa0, 0x18, 0x83, 0x20, 0xe5, 0xa2, 0x8b, 0x4c, 0x46, 0xdb, 0x9f, 0xa7, 0x70, + 0x2c, 0xd9, 0x62, 0xb0, 0xd0, 0xf2, 0x59, 0xc7, 0x49, 0x1f, 0xf6, 0x28, 0xa9}; + uint8_t bytesprops7[] = {0x1d, 0x41, 0x94, 0xbd, 0x8, 0xcb, 0x9d, 0x80, 0x54, + 0x8e, 0x25, 0x4, 0x60, 0xb3, 0x7b, 0x4e, 0x97, 0x6c}; + uint8_t bytesprops8[] = {0xff, 0xf3, 0xdc, 0x5, 0xef, 0xc6, 0xc2, 0x64, 0x9f, 0x91, + 0xab, 0x5, 0xc, 0x95, 0x19, 0x48, 0xb0, 0x67, 0xeb}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xcf, 0xb1, 0x3c, 0xdc, 0xc4, 0x59, 0xaa, 0x19, 0xd0, 0xcc, 0x6f}; - uint8_t bytesprops2[] = {0x4a, 0x7f, 0xaf, 0xe9, 0xdb, 0xe3, 0xcc, 0x33, 0xaf, 0x18, 0x46, 0xf6, 0xb6, 0x92, - 0xa3, 0x59, 0xd6, 0x85, 0x5c, 0xf, 0xbe, 0xe2, 0xea, 0xc, 0x87, 0x60, 0x45, 0x79}; - uint8_t bytesprops3[] = {0x6b, 0x16, 0xbc, 0x74, 0xe7, 0xd, 0x3b, 0xdd, 0x8e, 0x2e, - 0x89, 0x10, 0x15, 0x20, 0xc5, 0x45, 0xb5, 0xf8, 0xb2}; - uint8_t bytesprops5[] = {0x30, 0x62}; - uint8_t bytesprops4[] = {0x9, 0xb6, 0x95, 0xa4, 0x42, 0x84, 0x3b, 0xbb, 0xd7, 0xc9, 0xe, 0x6, 0xc2, 0x6a}; - uint8_t bytesprops6[] = {0x91, 0xd9, 0x9b, 0x9d}; - uint8_t bytesprops7[] = {0x16, 0x2f, 0x8f, 0x11, 0x28, 0x6c, 0x23, 0xbb, 0xf2, 0xf2, 0x14, 0x50, 0x30}; - uint8_t bytesprops8[] = {0xbe, 0xeb, 0x2d}; - uint8_t bytesprops9[] = {0xaf, 0xcf, 0x7, 0x2e, 0x15, 0xf6}; - uint8_t bytesprops10[] = {0x1a, 0x15, 0xd3, 0xa1, 0x66, 0x12, 0xb3, 0xee, 0x48, 0x36, 0x9d, 0x91, 0xf7, 0x82, 0x4f, - 0x67, 0x50, 0x2a, 0x0, 0x77, 0xd4, 0x2e, 0xc7, 0x26, 0xe0, 0x91, 0xf2, 0xe7, 0x91, 0xcd}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23274}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1962}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31104}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8247}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18795}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 167, 9, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 3223 [("U#\128\166r\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\198l]6!\158\151\NUL\255\155|\156\254",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval +// 18865,PropRetainAvailable 202,PropTopicAlias 15710,PropResponseInformation +// "\238\&7\201Y\185y\211Ij\205\207\ACK\162\ETX",PropReasonString +// "!c\200DX\145\208I\215\184\&1\174\131\234\202\132\159\164\222\159q&\189<\203\145",PropReceiveMaximum +// 29462,PropMaximumQoS 133,PropMessageExpiryInterval 13197,PropReceiveMaximum 15894,PropSubscriptionIdentifierAvailable +// 133,PropTopicAlias 18101,PropMessageExpiryInterval 16249,PropSessionExpiryInterval 17732,PropResponseInformation +// ";\155\231\222\240\216\162M\195\&3x\ACKxX\STXm",PropSessionExpiryInterval 3716,PropMessageExpiryInterval +// 31538,PropRetainAvailable 30,PropRequestResponseInformation 254,PropContentType +// "\208\GSp\244\&3\210sa{\134\SUB\204\129%\213\162\159\185['K5\146\251\173",PropRetainAvailable 147,PropCorrelationData +// "\185vv\211r;\240\137",PropRetainAvailable 46,PropTopicAlias 12882,PropWildcardSubscriptionAvailable +// 188,PropTopicAlias 15907,PropAuthenticationData "\167\141\SOuS\147\248k\STX\218X\189\203\&7$\242x\181\&0<\v\253\168\a +// ",PropMaximumPacketSize 8047] +TEST(Subscribe5QCTest, Encode76) { + uint8_t pkt[] = {0x82, 0xe6, 0x1, 0xc, 0x97, 0xc9, 0x1, 0x2, 0x0, 0x0, 0x49, 0xb1, 0x25, 0xca, 0x23, 0x3d, 0x5e, + 0x1a, 0x0, 0xe, 0xee, 0x37, 0xc9, 0x59, 0xb9, 0x79, 0xd3, 0x49, 0x6a, 0xcd, 0xcf, 0x6, 0xa2, 0x3, + 0x1f, 0x0, 0x1a, 0x21, 0x63, 0xc8, 0x44, 0x58, 0x91, 0xd0, 0x49, 0xd7, 0xb8, 0x31, 0xae, 0x83, 0xea, + 0xca, 0x84, 0x9f, 0xa4, 0xde, 0x9f, 0x71, 0x26, 0xbd, 0x3c, 0xcb, 0x91, 0x21, 0x73, 0x16, 0x24, 0x85, + 0x2, 0x0, 0x0, 0x33, 0x8d, 0x21, 0x3e, 0x16, 0x29, 0x85, 0x23, 0x46, 0xb5, 0x2, 0x0, 0x0, 0x3f, + 0x79, 0x11, 0x0, 0x0, 0x45, 0x44, 0x1a, 0x0, 0x10, 0x3b, 0x9b, 0xe7, 0xde, 0xf0, 0xd8, 0xa2, 0x4d, + 0xc3, 0x33, 0x78, 0x6, 0x78, 0x58, 0x2, 0x6d, 0x11, 0x0, 0x0, 0xe, 0x84, 0x2, 0x0, 0x0, 0x7b, + 0x32, 0x25, 0x1e, 0x19, 0xfe, 0x3, 0x0, 0x19, 0xd0, 0x1d, 0x70, 0xf4, 0x33, 0xd2, 0x73, 0x61, 0x7b, + 0x86, 0x1a, 0xcc, 0x81, 0x25, 0xd5, 0xa2, 0x9f, 0xb9, 0x5b, 0x27, 0x4b, 0x35, 0x92, 0xfb, 0xad, 0x25, + 0x93, 0x9, 0x0, 0x8, 0xb9, 0x76, 0x76, 0xd3, 0x72, 0x3b, 0xf0, 0x89, 0x25, 0x2e, 0x23, 0x32, 0x52, + 0x28, 0xbc, 0x23, 0x3e, 0x23, 0x16, 0x0, 0x19, 0xa7, 0x8d, 0xe, 0x75, 0x53, 0x93, 0xf8, 0x6b, 0x2, + 0xda, 0x58, 0xbd, 0xcb, 0x37, 0x24, 0xf2, 0x78, 0xb5, 0x30, 0x3c, 0xb, 0xfd, 0xa8, 0x7, 0x20, 0x27, + 0x0, 0x0, 0x1f, 0x6f, 0x0, 0x6, 0x55, 0x23, 0x80, 0xa6, 0x72, 0xd9, 0x0, 0x0, 0xd, 0xc6, 0x6c, + 0x5d, 0x36, 0x21, 0x9e, 0x97, 0x0, 0xff, 0x9b, 0x7c, 0x9c, 0xfe, 0x1}; + + uint8_t buf[243] = {0}; + + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x55, 0x23, 0x80, 0xa6, 0x72, 0xd9}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc6, 0x6c, 0x5d, 0x36, 0x21, 0x9e, 0x97, 0x0, 0xff, 0x9b, 0x7c, 0x9c, 0xfe}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xee, 0x37, 0xc9, 0x59, 0xb9, 0x79, 0xd3, 0x49, 0x6a, 0xcd, 0xcf, 0x6, 0xa2, 0x3}; + uint8_t bytesprops1[] = {0x21, 0x63, 0xc8, 0x44, 0x58, 0x91, 0xd0, 0x49, 0xd7, 0xb8, 0x31, 0xae, 0x83, + 0xea, 0xca, 0x84, 0x9f, 0xa4, 0xde, 0x9f, 0x71, 0x26, 0xbd, 0x3c, 0xcb, 0x91}; + uint8_t bytesprops2[] = {0x3b, 0x9b, 0xe7, 0xde, 0xf0, 0xd8, 0xa2, 0x4d, + 0xc3, 0x33, 0x78, 0x6, 0x78, 0x58, 0x2, 0x6d}; + uint8_t bytesprops3[] = {0xd0, 0x1d, 0x70, 0xf4, 0x33, 0xd2, 0x73, 0x61, 0x7b, 0x86, 0x1a, 0xcc, 0x81, + 0x25, 0xd5, 0xa2, 0x9f, 0xb9, 0x5b, 0x27, 0x4b, 0x35, 0x92, 0xfb, 0xad}; + uint8_t bytesprops4[] = {0xb9, 0x76, 0x76, 0xd3, 0x72, 0x3b, 0xf0, 0x89}; + uint8_t bytesprops5[] = {0xa7, 0x8d, 0xe, 0x75, 0x53, 0x93, 0xf8, 0x6b, 0x2, 0xda, 0x58, 0xbd, 0xcb, + 0x37, 0x24, 0xf2, 0x78, 0xb5, 0x30, 0x3c, 0xb, 0xfd, 0xa8, 0x7, 0x20}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15858}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19404}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32432}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21496}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24641}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19451}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18865}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15710}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29462}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13197}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15894}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18101}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16249}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17732}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3716}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31538}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12882}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15907}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8047}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 28678; - uint8_t client_id_bytes[] = {0xbd, 0x84, 0xbc, 0x2f, 0x5d, 0xe0, 0x73, 0x2b, 0x0, 0x54, 0x46, 0xc4, 0xe9, 0x55, 0x1d, - 0xfa, 0x4c, 0xa7, 0xb0, 0x19, 0x85, 0x0, 0xfe, 0xa1, 0x4f, 0x6c, 0x88, 0xa2, 0xd1}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x29, 0x9c, 0x41, 0x51, 0xe7, 0xbf, 0x16, 0xb9, 0x68, 0xe1, 0xb2, 0x89, 0xee, 0x33, - 0x4, 0x8a, 0xf8, 0x37, 0x52, 0x19, 0x2c, 0x2a, 0x16, 0x3d, 0xa, 0xe0, 0x12}; - lwmqtt_string_t password = {27, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3223, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 1845 [("\196\128\&4\163O\255",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("f\255\128\199\ETXD\164B\184\249 \251\243\158TM\242\130",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("d@V!\249\199\168\166\194\241\244\243y\202\222\203\132\164\184\145\196\164",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SYN\197\232MQ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\242W\198\204\146t\ESC\192'\177\DC49>\166`{\152Q\247v\213\133\EM \160~@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\229\252\136\170\181]\155\129\151\157\222\219P\163\177\130\146F\205",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\234\196[a\EOTi\137\214",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\232\&4\187\230\144aj3\ETB\EM\162%t\228",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\STXv\213",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\"=\211\194\176",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropTopicAlias +// 21229,PropMessageExpiryInterval 5033,PropWillDelayInterval 9775,PropWildcardSubscriptionAvailable +// 227,PropUserProperty "\162\141\132\193:%{\193\EM\199\159[" +// "\144\172\ACK@5\206\203\141\f\218:\223.zN\176\226I;\150",PropMaximumQoS 255,PropServerReference +// "\151\DEL|\194\172\180o\208\163o\176m\250\ESC\159\223\188&.\173\144\v\233\179\210\224",PropSessionExpiryInterval +// 14355,PropWildcardSubscriptionAvailable 15,PropAssignedClientIdentifier +// "\DC2<\FSy\144\SYN\170\216\159\140H\151s\195Z6\220W\215H,\SUB\137",PropRetainAvailable +// 162,PropRequestProblemInformation 225,PropResponseInformation +// "{\197{\170\210\200\204\&8^\144\154\195K\EOT\209z\231\243\131\222k\185\171\221b\170^\159\195",PropTopicAlias +// 6806,PropResponseTopic "\US9\206\131\NUL\145\DC1\233\226\&7\FS\135",PropContentType +// "D",PropSharedSubscriptionAvailable 205,PropMessageExpiryInterval 31351,PropWillDelayInterval +// 12650,PropMessageExpiryInterval 30600,PropSubscriptionIdentifier 30,PropAuthenticationData +// "D\188\255kP\167x\228\DC3v\164\246`\144=\203\152R\242"] +TEST(Subscribe5QCTest, Encode77) { + uint8_t pkt[] = { + 0x82, 0xfb, 0x2, 0x7, 0x35, 0xd7, 0x1, 0x23, 0x52, 0xed, 0x2, 0x0, 0x0, 0x13, 0xa9, 0x18, 0x0, 0x0, 0x26, + 0x2f, 0x28, 0xe3, 0x26, 0x0, 0xc, 0xa2, 0x8d, 0x84, 0xc1, 0x3a, 0x25, 0x7b, 0xc1, 0x19, 0xc7, 0x9f, 0x5b, 0x0, + 0x14, 0x90, 0xac, 0x6, 0x40, 0x35, 0xce, 0xcb, 0x8d, 0xc, 0xda, 0x3a, 0xdf, 0x2e, 0x7a, 0x4e, 0xb0, 0xe2, 0x49, + 0x3b, 0x96, 0x24, 0xff, 0x1c, 0x0, 0x1a, 0x97, 0x7f, 0x7c, 0xc2, 0xac, 0xb4, 0x6f, 0xd0, 0xa3, 0x6f, 0xb0, 0x6d, + 0xfa, 0x1b, 0x9f, 0xdf, 0xbc, 0x26, 0x2e, 0xad, 0x90, 0xb, 0xe9, 0xb3, 0xd2, 0xe0, 0x11, 0x0, 0x0, 0x38, 0x13, + 0x28, 0xf, 0x12, 0x0, 0x17, 0x12, 0x3c, 0x1c, 0x79, 0x90, 0x16, 0xaa, 0xd8, 0x9f,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0, 0x27, 0xb1, 0x14, 0x39, 0x3e, 0xa6, 0x60, 0x7b, 0x98, + 0x51, 0xf7, 0x76, 0xd5, 0x85, 0x19, 0x20, 0xa0, 0x7e, 0x40, 0x0, 0x0, 0x13, 0xe5, 0xfc, 0x88, 0xaa, 0xb5, 0x5d, + 0x9b, 0x81, 0x97, 0x9d, 0xde, 0xdb, 0x50, 0xa3, 0xb1, 0x82, 0x92, 0x46, 0xcd, 0x1, 0x0, 0x0, 0x0, 0x0, 0x8, + 0xea, 0xc4, 0x5b, 0x61, 0x4, 0x69, 0x89, 0xd6, 0x2, 0x0, 0xe, 0xe8, 0x34, 0xbb, 0xe6, 0x90, 0x61, 0x6a, 0x33, + 0x17, 0x19, 0xa2, 0x25, 0x74, 0xe4, 0x0, 0x0, 0x3, 0x2, 0x76, 0xd5, 0x2, 0x0, 0x5, 0x22, 0x3d, 0xd3, 0xc2, + 0xb0, 0x2}; + + uint8_t buf[392] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xc4, 0x80, 0x34, 0xa3, 0x4f, 0xff}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x66, 0xff, 0x80, 0xc7, 0x3, 0x44, 0xa4, 0x42, 0xb8, + 0xf9, 0x20, 0xfb, 0xf3, 0x9e, 0x54, 0x4d, 0xf2, 0x82}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x64, 0x40, 0x56, 0x21, 0xf9, 0xc7, 0xa8, 0xa6, 0xc2, 0xf1, 0xf4, + 0xf3, 0x79, 0xca, 0xde, 0xcb, 0x84, 0xa4, 0xb8, 0x91, 0xc4, 0xa4}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x16, 0xc5, 0xe8, 0x4d, 0x51}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xf2, 0x57, 0xc6, 0xcc, 0x92, 0x74, 0x1b, 0xc0, 0x27, 0xb1, 0x14, 0x39, 0x3e, 0xa6, + 0x60, 0x7b, 0x98, 0x51, 0xf7, 0x76, 0xd5, 0x85, 0x19, 0x20, 0xa0, 0x7e, 0x40}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe5, 0xfc, 0x88, 0xaa, 0xb5, 0x5d, 0x9b, 0x81, 0x97, 0x9d, + 0xde, 0xdb, 0x50, 0xa3, 0xb1, 0x82, 0x92, 0x46, 0xcd}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xea, 0xc4, 0x5b, 0x61, 0x4, 0x69, 0x89, 0xd6}; + lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe8, 0x34, 0xbb, 0xe6, 0x90, 0x61, 0x6a, + 0x33, 0x17, 0x19, 0xa2, 0x25, 0x74, 0xe4}; + lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x2, 0x76, 0xd5}; + lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x22, 0x3d, 0xd3, 0xc2, 0xb0}; + lwmqtt_string_t topic_filter_s10 = {5, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t bytesprops1[] = {0x90, 0xac, 0x6, 0x40, 0x35, 0xce, 0xcb, 0x8d, 0xc, 0xda, + 0x3a, 0xdf, 0x2e, 0x7a, 0x4e, 0xb0, 0xe2, 0x49, 0x3b, 0x96}; + uint8_t bytesprops0[] = {0xa2, 0x8d, 0x84, 0xc1, 0x3a, 0x25, 0x7b, 0xc1, 0x19, 0xc7, 0x9f, 0x5b}; + uint8_t bytesprops2[] = {0x97, 0x7f, 0x7c, 0xc2, 0xac, 0xb4, 0x6f, 0xd0, 0xa3, 0x6f, 0xb0, 0x6d, 0xfa, + 0x1b, 0x9f, 0xdf, 0xbc, 0x26, 0x2e, 0xad, 0x90, 0xb, 0xe9, 0xb3, 0xd2, 0xe0}; + uint8_t bytesprops3[] = {0x12, 0x3c, 0x1c, 0x79, 0x90, 0x16, 0xaa, 0xd8, 0x9f, 0x8c, 0x48, 0x97, + 0x73, 0xc3, 0x5a, 0x36, 0xdc, 0x57, 0xd7, 0x48, 0x2c, 0x1a, 0x89}; + uint8_t bytesprops4[] = {0x7b, 0xc5, 0x7b, 0xaa, 0xd2, 0xc8, 0xcc, 0x38, 0x5e, 0x90, 0x9a, 0xc3, 0x4b, 0x4, 0xd1, + 0x7a, 0xe7, 0xf3, 0x83, 0xde, 0x6b, 0xb9, 0xab, 0xdd, 0x62, 0xaa, 0x5e, 0x9f, 0xc3}; + uint8_t bytesprops5[] = {0x1f, 0x39, 0xce, 0x83, 0x0, 0x91, 0x11, 0xe9, 0xe2, 0x37, 0x1c, 0x87}; + uint8_t bytesprops6[] = {0x44}; + uint8_t bytesprops7[] = {0x44, 0xbc, 0xff, 0x6b, 0x50, 0xa7, 0x78, 0xe4, 0x13, 0x76, + 0xa4, 0xf6, 0x60, 0x90, 0x3d, 0xcb, 0x98, 0x52, 0xf2}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21229}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5033}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9775}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14355}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6806}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31351}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12650}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30600}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops7}}}, + }; -// ConnectRequest {_username = Just "\231\136\157", _password = Nothing, _lastWill = Nothing, _cleanSession = True, -// _keepAlive = 27015, _connID = "c\202.c\142W#U\130p\148q(O\219m", _properties = [PropTopicAliasMaximum -// 1328,PropSharedSubscriptionAvailable 102,PropTopicAliasMaximum 18059,PropTopicAlias 15044,PropContentType -// "\t\138k\190\169",PropMaximumPacketSize 20110,PropAuthenticationData -// "2q\166o\171\206aJ$t\141\139Q{\DEL",PropMessageExpiryInterval 11401,PropReasonString -// "\160aNz\178e<\175lb\208\231\255\192\&0\199k\254\NAK\ry\"8gA\238",PropCorrelationData -// "\190XDv\SOH\195\197\228k~\210\SId\167\211\129[\198\247\197Q",PropAuthenticationMethod -// "\173\156\134\169\DC3IN\231H\225`\DLE\238\135\133\241\253G\170\145]\189\139\201\223",PropAssignedClientIdentifier -// "\128\133l\161\206?\144\215\145m\160\221",PropResponseInformation -// "Y\147\224X\192\238=\b\EOT\147UT9\148\239\252\NUL",PropMessageExpiryInterval 15590,PropRequestProblemInformation -// 15,PropSharedSubscriptionAvailable 43,PropSubscriptionIdentifier 3,PropReceiveMaximum 3169,PropMaximumQoS -// 110,PropMessageExpiryInterval 27843,PropSessionExpiryInterval 17032,PropUserProperty -// "\213R,\DLE\160j\238\b\238\173\243`t,\STX\SO\FS\135\150\180\DC2vct\137p\135w" ">\253\202\194\245\219j",PropTopicAlias -// 27026]} -TEST(Connect5QCTest, Encode87) { - uint8_t pkt[] = {0x10, 0x8b, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x82, 0x69, 0x87, 0xe8, 0x1, 0x22, 0x5, - 0x30, 0x2a, 0x66, 0x22, 0x46, 0x8b, 0x23, 0x3a, 0xc4, 0x3, 0x0, 0x5, 0x9, 0x8a, 0x6b, 0xbe, 0xa9, - 0x27, 0x0, 0x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c, 0x87, 0x96, 0xb4, 0x12, 0x76, 0x63, 0x74, 0x89, 0x70, 0x87, 0x77, 0x0, 0x7, 0x3e, - 0xfd, 0xca, 0xc2, 0xf5, 0xdb, 0x6a, 0x23, 0x69, 0x92, 0x0, 0x10, 0x63, 0xca, 0x2e, 0x63, 0x8e, 0x57, - 0x23, 0x55, 0x82, 0x70, 0x94, 0x71, 0x28, 0x4f, 0xdb, 0x6d, 0x0, 0x3, 0xe7, 0x88, 0x9d}; - - uint8_t buf[280] = {0}; - - uint8_t bytesprops0[] = {0x9, 0x8a, 0x6b, 0xbe, 0xa9}; - uint8_t bytesprops1[] = {0x32, 0x71, 0xa6, 0x6f, 0xab, 0xce, 0x61, 0x4a, 0x24, 0x74, 0x8d, 0x8b, 0x51, 0x7b, 0x7f}; - uint8_t bytesprops2[] = {0xa0, 0x61, 0x4e, 0x7a, 0xb2, 0x65, 0x3c, 0xaf, 0x6c, 0x62, 0xd0, 0xe7, 0xff, - 0xc0, 0x30, 0xc7, 0x6b, 0xfe, 0x15, 0xd, 0x79, 0x22, 0x38, 0x67, 0x41, 0xee}; - uint8_t bytesprops3[] = {0xbe, 0x58, 0x44, 0x76, 0x1, 0xc3, 0xc5, 0xe4, 0x6b, 0x7e, 0xd2, - 0xf, 0x64, 0xa7, 0xd3, 0x81, 0x5b, 0xc6, 0xf7, 0xc5, 0x51}; - uint8_t bytesprops4[] = {0xad, 0x9c, 0x86, 0xa9, 0x13, 0x49, 0x4e, 0xe7, 0x48, 0xe1, 0x60, 0x10, 0xee, - 0x87, 0x85, 0xf1, 0xfd, 0x47, 0xaa, 0x91, 0x5d, 0xbd, 0x8b, 0xc9, 0xdf}; - uint8_t bytesprops5[] = {0x80, 0x85, 0x6c, 0xa1, 0xce, 0x3f, 0x90, 0xd7, 0x91, 0x6d, 0xa0, 0xdd}; - uint8_t bytesprops6[] = {0x59, 0x93, 0xe0, 0x58, 0xc0, 0xee, 0x3d, 0x8, 0x4, - 0x93, 0x55, 0x54, 0x39, 0x94, 0xef, 0xfc, 0x0}; - uint8_t bytesprops8[] = {0x3e, 0xfd, 0xca, 0xc2, 0xf5, 0xdb, 0x6a}; - uint8_t bytesprops7[] = {0xd5, 0x52, 0x2c, 0x10, 0xa0, 0x6a, 0xee, 0x8, 0xee, 0xad, 0xf3, 0x60, 0x74, 0x2c, - 0x2, 0xe, 0x1c, 0x87, 0x96, 0xb4, 0x12, 0x76, 0x63, 0x74, 0x89, 0x70, 0x87, 0x77}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1845, 11, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12377 [("\156\222Z\207\145\DC1\171\133j\149\210Dr\137\&1\130\219\182 2H\210\203s",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty +// "\DC4" "u\208\RS\233\"\219\SUB\211{G\250\142\a|\SO\206\221=\166\a\b.\USG\234",PropTopicAlias +// 28621,PropSharedSubscriptionAvailable 82,PropRetainAvailable 188,PropWildcardSubscriptionAvailable 205,PropMaximumQoS +// 207,PropSubscriptionIdentifierAvailable 249,PropMessageExpiryInterval 21158,PropSessionExpiryInterval +// 21268,PropSessionExpiryInterval 31778,PropAuthenticationMethod +// "\157\&4\177\242\134\GS\ESC\187R\131y3\255.\STX",PropAssignedClientIdentifier +// "\"\183\DC1\222\220\183b\193\198m\v\211\&7\205\205\225\128\GS",PropTopicAlias 11340,PropRequestProblemInformation +// 134,PropMessageExpiryInterval 16425] +TEST(Subscribe5QCTest, Encode78) { + uint8_t pkt[] = {0x82, 0x8a, 0x1, 0x30, 0x59, 0x6c, 0x26, 0x0, 0x1, 0x14, 0x0, 0x19, 0x75, 0xd0, 0x1e, 0xe9, + 0x22, 0xdb, 0x1a, 0xd3, 0x7b, 0x47, 0xfa, 0x8e, 0x7, 0x7c, 0xe, 0xce, 0xdd, 0x3d, 0xa6, 0x7, + 0x8, 0x2e, 0x1f, 0x47, 0xea, 0x23, 0x6f, 0xcd, 0x2a, 0x52, 0x25, 0xbc, 0x28, 0xcd, 0x24, 0xcf, + 0x29, 0xf9, 0x2, 0x0, 0x0, 0x52, 0xa6, 0x11, 0x0, 0x0, 0x53, 0x14, 0x11, 0x0, 0x0, 0x7c, + 0x22, 0x15, 0x0, 0xf, 0x9d, 0x34, 0xb1, 0xf2, 0x86, 0x1d, 0x1b, 0xbb, 0x52, 0x83, 0x79, 0x33, + 0xff, 0x2e, 0x2, 0x12, 0x0, 0x12, 0x22, 0xb7, 0x11, 0xde, 0xdc, 0xb7, 0x62, 0xc1, 0xc6, 0x6d, + 0xb, 0xd3, 0x37, 0xcd, 0xcd, 0xe1, 0x80, 0x1d, 0x23, 0x2c, 0x4c, 0x17, 0x86, 0x2, 0x0, 0x0, + 0x40, 0x29, 0x0, 0x18, 0x9c, 0xde, 0x5a, 0xcf, 0x91, 0x11, 0xab, 0x85, 0x6a, 0x95, 0xd2, 0x44, + 0x72, 0x89, 0x31, 0x82, 0xdb, 0xb6, 0x20, 0x32, 0x48, 0xd2, 0xcb, 0x73, 0x1}; + + uint8_t buf[151] = {0}; + + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x9c, 0xde, 0x5a, 0xcf, 0x91, 0x11, 0xab, 0x85, 0x6a, 0x95, 0xd2, 0x44, + 0x72, 0x89, 0x31, 0x82, 0xdb, 0xb6, 0x20, 0x32, 0x48, 0xd2, 0xcb, 0x73}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t bytesprops1[] = {0x75, 0xd0, 0x1e, 0xe9, 0x22, 0xdb, 0x1a, 0xd3, 0x7b, 0x47, 0xfa, 0x8e, 0x7, + 0x7c, 0xe, 0xce, 0xdd, 0x3d, 0xa6, 0x7, 0x8, 0x2e, 0x1f, 0x47, 0xea}; + uint8_t bytesprops0[] = {0x14}; + uint8_t bytesprops2[] = {0x9d, 0x34, 0xb1, 0xf2, 0x86, 0x1d, 0x1b, 0xbb, 0x52, 0x83, 0x79, 0x33, 0xff, 0x2e, 0x2}; + uint8_t bytesprops3[] = {0x22, 0xb7, 0x11, 0xde, 0xdc, 0xb7, 0x62, 0xc1, 0xc6, + 0x6d, 0xb, 0xd3, 0x37, 0xcd, 0xcd, 0xe1, 0x80, 0x1d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1328}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18059}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15044}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20110}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11401}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15590}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3169}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27843}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17032}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops7}, .v = {7, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27026}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28621}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21158}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21268}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31778}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11340}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16425}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 27015; - uint8_t client_id_bytes[] = {0x63, 0xca, 0x2e, 0x63, 0x8e, 0x57, 0x23, 0x55, - 0x82, 0x70, 0x94, 0x71, 0x28, 0x4f, 0xdb, 0x6d}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xe7, 0x88, 0x9d}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12377, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 290 [("-\CAN\FSe\144\STXP\243wu\191%\250\176\&5\250\204V\239\137}",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\128&U[\222\&1,\232\&9\137\194\vD\146\155m\DLE\213\249\229d\FSI+\v]",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\232g?\215\156\STXD\132\NUL\197\ACK(\234:\DC1\153C\148\b/\180^",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\176\160\178:&\NUL\182\\\173\RS\138\144\138@\148U\ENQA>\191\&1t",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),(".\162!\217\216*\155\205\236\RSc\tEWe2\159'\216\149\193\235\DC1[\200\188\233\230\215",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\187\152j\248\219\&2\152\&3\SO\GS\135",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\176\144m\168\226",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\227\202\180@6a",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("|\129\183e\162\160X\243e\238E\183\184\128SY\157\EM6\253",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropTopicAlias +// 24863,PropWildcardSubscriptionAvailable 239,PropUserProperty "{Z" +// "\186\233\227\247%\136R",PropWildcardSubscriptionAvailable 225,PropSessionExpiryInterval 19459,PropCorrelationData +// "\v\132\148-\145\ETB\191\228'Y\230\150\207q\218\140",PropContentType "",PropAssignedClientIdentifier +// "\a\200\136\148\t\162\222q\192",PropReasonString +// "\128^\"\EOT\DC4\201Z\SOH$\172\218\249G\147\&5>",PropTopicAliasMaximum 20513,PropContentType +// "\216r\EOTN\213\231\185\146\197\a\193k\ETB\170\246\227\174JI\192\FS\230\228v'\193\128\209=\144",PropServerReference +// "m@:"] +TEST(Subscribe5QCTest, Encode79) { + uint8_t pkt[] = { + 0x82, 0xb9, 0x2, 0x1, 0x22, 0x79, 0x23, 0x61, 0x1f, 0x28, 0xef, 0x26, 0x0, 0x2, 0x7b, 0x5a, 0x0, 0x7, 0xba, + 0xe9, 0xe3, 0xf7, 0x25, 0x88, 0x52, 0x28, 0xe1, 0x11, 0x0, 0x0, 0x4c, 0x3, 0x9, 0x0, 0x10, 0xb, 0x84, 0x94, + 0x2d, 0x91, 0x17, 0xbf, 0xe4, 0x27, 0x59, 0xe6, 0x96, 0xcf, 0x71, 0xda, 0x8c, 0x3, 0x0, 0x0, 0x12, 0x0, 0x9, + 0x7, 0xc8, 0x88, 0x94, 0x9, 0xa2, 0xde, 0x71, 0xc0, 0x1f, 0x0, 0x10, 0x80, 0x5e, 0x22, 0x4, 0x14, 0xc9, 0x5a, + 0x1, 0x24, 0xac, 0xda, 0xf9, 0x47, 0x93, 0x35, 0x3e, 0x22, 0x50, 0x21, 0x3, 0x0, 0x1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, 0x0, 0x5, 0xb0, 0x90, 0x6d, 0xa8, 0xe2, 0x1, 0x0, + 0x6, 0xe3, 0xca, 0xb4, 0x40, 0x36, 0x61, 0x2, 0x0, 0x14, 0x7c, 0x81, 0xb7, 0x65, 0xa2, 0xa0, 0x58, 0xf3, 0x65, + 0xee, 0x45, 0xb7, 0xb8, 0x80, 0x53, 0x59, 0x9d, 0x19, 0x36, 0xfd, 0x1}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[326] = {0}; -// ConnectRequest {_username = Nothing, _password = Just "U\185M\196", _lastWill = Nothing, _cleanSession = True, -// _keepAlive = 28907, _connID = ";&\203q}", _properties = [PropSubscriptionIdentifierAvailable 203,PropUserProperty -// "\227as\202\169c~\DC2\202h\254X\SYNUz" "\181FH",PropSubscriptionIdentifier 28,PropReceiveMaximum -// 26196,PropReceiveMaximum 25509,PropCorrelationData "|\181\ACK\178\NUL\229\190\140",PropCorrelationData -// "@U\165\f\205\147\&8M\241\r\226\159\214P\186\tz\248\201\a\146\215\255<\DEL",PropMaximumQoS 197,PropReceiveMaximum -// 912,PropWildcardSubscriptionAvailable 16,PropResponseTopic "\154",PropResponseInformation -// "\231o\246\171",PropPayloadFormatIndicator 166,PropRetainAvailable 111,PropTopicAliasMaximum -// 4682,PropMaximumPacketSize 13367,PropReasonString -// "\f\n9\151I(\222\136\&1$\144\135PA\210\132\183\148\&0d'",PropResponseTopic -// "\235Z\208h\168F\147G\183\213\FS@~\223\240g\aY\134\203\143p\181\&8\143",PropRequestResponseInformation -// 190,PropMessageExpiryInterval 12716,PropSharedSubscriptionAvailable 133,PropSessionExpiryInterval -// 24785,PropServerKeepAlive 16193,PropSharedSubscriptionAvailable 100,PropTopicAlias 9013,PropSessionExpiryInterval -// 32590,PropCorrelationData "\153\222\159%\157x3\216\US\250\248\231l\DC1\212\162",PropWillDelayInterval -// 11170,PropMessageExpiryInterval 23686]} -TEST(Connect5QCTest, Encode88) { - uint8_t pkt[] = {0x10, 0xe5, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2, 0x70, 0xeb, 0xd2, 0x1, 0x29, 0xcb, - 0x26, 0x0, 0xf, 0xe3, 0x61, 0x73, 0xca, 0xa9, 0x63, 0x7e, 0x12, 0xca, 0x68, 0xfe, 0x58, 0x16, 0x55, - 0x7a, 0x0, 0x3, 0xb5, 0x46, 0x48, 0xb, 0x1c, 0x21, 0x66, 0x54, 0x21, 0x63, 0xa5, 0x9, 0x0, 0x8, - 0x7c, 0xb5, 0x6, 0xb2, 0x0, 0xe5, 0xbe, 0x8c, 0x9, 0x0, 0x19, 0x40, 0x55, 0xa5, 0xc, 0xcd, 0x93, - 0x38, 0x4d, 0xf1, 0xd, 0xe2, 0x9f, 0xd6, 0x50, 0xba, 0x9, 0x7a, 0xf8, 0xc9, 0x7, 0x92, 0xd7, 0xff, - 0x3c, 0x7f, 0x24, 0xc5, 0x21, 0x3, 0x90, 0x28, 0x10, 0x8, 0x0, 0x1, 0x9a, 0x1a, 0x0, 0x4, 0xe7, - 0x6f, 0xf6, 0xab, 0x1, 0xa6, 0x25, 0x6f, 0x22, 0x12, 0x4a, 0x27, 0x0, 0x0, 0x34, 0x37, 0x1f, 0x0, - 0x15, 0xc, 0xa, 0x39, 0x97, 0x49, 0x28, 0xde, 0x88, 0x31, 0x24, 0x90, 0x87, 0x50, 0x41, 0xd2, 0x84, - 0xb7, 0x94, 0x30, 0x64, 0x27, 0x8, 0x0, 0x19, 0xeb, 0x5a, 0xd0, 0x68, 0xa8, 0x46, 0x93, 0x47, 0xb7, - 0xd5, 0x1c, 0x40, 0x7e, 0xdf, 0xf0, 0x67, 0x7, 0x59, 0x86, 0xcb, 0x8f, 0x70, 0xb5, 0x38, 0x8f, 0x19, - 0xbe, 0x2, 0x0, 0x0, 0x31, 0xac, 0x2a, 0x85, 0x11, 0x0, 0x0, 0x60, 0xd1, 0x13, 0x3f, 0x41, 0x2a, - 0x64, 0x23, 0x23, 0x35, 0x11, 0x0, 0x0, 0x7f, 0x4e, 0x9, 0x0, 0x10, 0x99, 0xde, 0x9f, 0x25, 0x9d, - 0x78, 0x33, 0xd8, 0x1f, 0xfa, 0xf8, 0xe7, 0x6c, 0x11, 0xd4, 0xa2, 0x18, 0x0, 0x0, 0x2b, 0xa2, 0x2, - 0x0, 0x0, 0x5c, 0x86, 0x0, 0x5, 0x3b, 0x26, 0xcb, 0x71, 0x7d}; - - uint8_t buf[242] = {0}; - - uint8_t bytesprops1[] = {0xb5, 0x46, 0x48}; - uint8_t bytesprops0[] = {0xe3, 0x61, 0x73, 0xca, 0xa9, 0x63, 0x7e, 0x12, 0xca, 0x68, 0xfe, 0x58, 0x16, 0x55, 0x7a}; - uint8_t bytesprops2[] = {0x7c, 0xb5, 0x6, 0xb2, 0x0, 0xe5, 0xbe, 0x8c}; - uint8_t bytesprops3[] = {0x40, 0x55, 0xa5, 0xc, 0xcd, 0x93, 0x38, 0x4d, 0xf1, 0xd, 0xe2, 0x9f, 0xd6, - 0x50, 0xba, 0x9, 0x7a, 0xf8, 0xc9, 0x7, 0x92, 0xd7, 0xff, 0x3c, 0x7f}; - uint8_t bytesprops4[] = {0x9a}; - uint8_t bytesprops5[] = {0xe7, 0x6f, 0xf6, 0xab}; - uint8_t bytesprops6[] = {0xc, 0xa, 0x39, 0x97, 0x49, 0x28, 0xde, 0x88, 0x31, 0x24, 0x90, - 0x87, 0x50, 0x41, 0xd2, 0x84, 0xb7, 0x94, 0x30, 0x64, 0x27}; - uint8_t bytesprops7[] = {0xeb, 0x5a, 0xd0, 0x68, 0xa8, 0x46, 0x93, 0x47, 0xb7, 0xd5, 0x1c, 0x40, 0x7e, - 0xdf, 0xf0, 0x67, 0x7, 0x59, 0x86, 0xcb, 0x8f, 0x70, 0xb5, 0x38, 0x8f}; - uint8_t bytesprops8[] = {0x99, 0xde, 0x9f, 0x25, 0x9d, 0x78, 0x33, 0xd8, - 0x1f, 0xfa, 0xf8, 0xe7, 0x6c, 0x11, 0xd4, 0xa2}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x2d, 0x18, 0x1c, 0x65, 0x90, 0x2, 0x50, 0xf3, 0x77, 0x75, 0xbf, + 0x25, 0xfa, 0xb0, 0x35, 0xfa, 0xcc, 0x56, 0xef, 0x89, 0x7d}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x80, 0x26, 0x55, 0x5b, 0xde, 0x31, 0x2c, 0xe8, 0x39, 0x89, 0xc2, 0xb, 0x44, + 0x92, 0x9b, 0x6d, 0x10, 0xd5, 0xf9, 0xe5, 0x64, 0x1c, 0x49, 0x2b, 0xb, 0x5d}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe8, 0x67, 0x3f, 0xd7, 0x9c, 0x2, 0x44, 0x84, 0x0, 0xc5, 0x6, + 0x28, 0xea, 0x3a, 0x11, 0x99, 0x43, 0x94, 0x8, 0x2f, 0xb4, 0x5e}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb0, 0xa0, 0xb2, 0x3a, 0x26, 0x0, 0xb6, 0x5c, 0xad, 0x1e, 0x8a, + 0x90, 0x8a, 0x40, 0x94, 0x55, 0x5, 0x41, 0x3e, 0xbf, 0x31, 0x74}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x2e, 0xa2, 0x21, 0xd9, 0xd8, 0x2a, 0x9b, 0xcd, 0xec, 0x1e, + 0x63, 0x9, 0x45, 0x57, 0x65, 0x32, 0x9f, 0x27, 0xd8, 0x95, + 0xc1, 0xeb, 0x11, 0x5b, 0xc8, 0xbc, 0xe9, 0xe6, 0xd7}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xbb, 0x98, 0x6a, 0xf8, 0xdb, 0x32, 0x98, 0x33, 0xe, 0x1d, 0x87}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xb0, 0x90, 0x6d, 0xa8, 0xe2}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe3, 0xca, 0xb4, 0x40, 0x36, 0x61}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x7c, 0x81, 0xb7, 0x65, 0xa2, 0xa0, 0x58, 0xf3, 0x65, 0xee, + 0x45, 0xb7, 0xb8, 0x80, 0x53, 0x59, 0x9d, 0x19, 0x36, 0xfd}; + lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops1[] = {0xba, 0xe9, 0xe3, 0xf7, 0x25, 0x88, 0x52}; + uint8_t bytesprops0[] = {0x7b, 0x5a}; + uint8_t bytesprops2[] = {0xb, 0x84, 0x94, 0x2d, 0x91, 0x17, 0xbf, 0xe4, + 0x27, 0x59, 0xe6, 0x96, 0xcf, 0x71, 0xda, 0x8c}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x7, 0xc8, 0x88, 0x94, 0x9, 0xa2, 0xde, 0x71, 0xc0}; + uint8_t bytesprops5[] = {0x80, 0x5e, 0x22, 0x4, 0x14, 0xc9, 0x5a, 0x1, + 0x24, 0xac, 0xda, 0xf9, 0x47, 0x93, 0x35, 0x3e}; + uint8_t bytesprops6[] = {0xd8, 0x72, 0x4, 0x4e, 0xd5, 0xe7, 0xb9, 0x92, 0xc5, 0x7, 0xc1, 0x6b, 0x17, 0xaa, 0xf6, + 0xe3, 0xae, 0x4a, 0x49, 0xc0, 0x1c, 0xe6, 0xe4, 0x76, 0x27, 0xc1, 0x80, 0xd1, 0x3d, 0x90}; + uint8_t bytesprops7[] = {0x6d, 0x40, 0x3a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {3, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26196}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25509}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 912}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4682}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13367}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12716}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24785}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16193}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9013}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32590}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11170}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23686}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24863}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops0}, .v = {7, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19459}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20513}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 28907; - uint8_t client_id_bytes[] = {0x3b, 0x26, 0xcb, 0x71, 0x7d}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x55, 0xb9, 0x4d, 0xc4}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 290, 9, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 28088 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),(":\193@\178\186\219\136\180",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\254\238]\245\184?\239",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("W'\132<\DC3\nUBMC\159\172b\NUL\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [PropRequestProblemInformation 165,PropUserProperty +// "\242N\RS\214\&9\199\245ZQ" "",PropServerReference "\235\207Mm\ETB",PropAuthenticationData +// "\131X\147\FSD\246",PropServerReference +// "\219\149tsY\SI\152#5\DC3\225\f\255\233\SO\SOH\205\182\163$\255\223\224\246\SI\150\tOE\226",PropMessageExpiryInterval +// 28313,PropSubscriptionIdentifierAvailable 11,PropServerKeepAlive 2536,PropSubscriptionIdentifierAvailable +// 53,PropSubscriptionIdentifierAvailable 117,PropSubscriptionIdentifier 23,PropCorrelationData +// "/\164\vQ\174\ACK",PropRequestResponseInformation 202,PropSubscriptionIdentifierAvailable 246,PropMaximumQoS +// 136,PropMaximumQoS 177,PropAuthenticationMethod "\215\v\NUL5\249\n",PropTopicAliasMaximum +// 24195,PropSessionExpiryInterval 19137,PropSharedSubscriptionAvailable 204,PropReceiveMaximum +// 12776,PropAuthenticationData "\160KZ\159r\143R\136\226\239vy\SYN\DC4\FS\204\SOH\228"] +TEST(Subscribe5QCTest, Encode80) { + uint8_t pkt[] = {0x82, 0xbc, 0x1, 0x6d, 0xb8, 0x8e, 0x1, 0x17, 0xa5, 0x26, 0x0, 0x9, 0xf2, 0x4e, 0x1e, 0xd6, + 0x39, 0xc7, 0xf5, 0x5a, 0x51, 0x0, 0x0, 0x1c, 0x0, 0x5, 0xeb, 0xcf, 0x4d, 0x6d, 0x17, 0x16, + 0x0, 0x6, 0x83, 0x58, 0x93, 0x1c, 0x44, 0xf6, 0x1c, 0x0, 0x1e, 0xdb, 0x95, 0x74, 0x73, 0x59, + 0xf, 0x98, 0x23, 0x35, 0x13, 0xe1, 0xc, 0xff, 0xe9, 0xe, 0x1, 0xcd, 0xb6, 0xa3, 0x24, 0xff, + 0xdf, 0xe0, 0xf6, 0xf, 0x96, 0x9, 0x4f, 0x45, 0xe2, 0x2, 0x0, 0x0, 0x6e, 0x99, 0x29, 0xb, + 0x13, 0x9, 0xe8, 0x29, 0x35, 0x29, 0x75, 0xb, 0x17, 0x9, 0x0, 0x6, 0x2f, 0xa4, 0xb, 0x51, + 0xae, 0x6, 0x19, 0xca, 0x29, 0xf6, 0x24, 0x88, 0x24, 0xb1, 0x15, 0x0, 0x6, 0xd7, 0xb, 0x0, + 0x35, 0xf9, 0xa, 0x22, 0x5e, 0x83, 0x11, 0x0, 0x0, 0x4a, 0xc1, 0x2a, 0xcc, 0x21, 0x31, 0xe8, + 0x16, 0x0, 0x12, 0xa0, 0x4b, 0x5a, 0x9f, 0x72, 0x8f, 0x52, 0x88, 0xe2, 0xef, 0x76, 0x79, 0x16, + 0x14, 0x1c, 0xcc, 0x1, 0xe4, 0x0, 0x0, 0x2, 0x0, 0x8, 0x3a, 0xc1, 0x40, 0xb2, 0xba, 0xdb, + 0x88, 0xb4, 0x2, 0x0, 0x7, 0xfe, 0xee, 0x5d, 0xf5, 0xb8, 0x3f, 0xef, 0x0, 0x0, 0xf, 0x57, + 0x27, 0x84, 0x3c, 0x13, 0xa, 0x55, 0x42, 0x4d, 0x43, 0x9f, 0xac, 0x62, 0x0, 0xb9, 0x1}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[201] = {0}; -// ConnectRequest {_username = Just "t\171o\168\ETB\EOT\EOT\226\b\SI\205\166J\SOj\164\ETB\SUB\166\245\US\SUB", _password -// = Just "\NAK\169_\251\NAK\186\DLE\215\169kW3J\b\199", _lastWill = Nothing, _cleanSession = False, _keepAlive = 28413, -// _connID = "\215\188:\SYN]?\n\214\176\&2i", _properties = [PropUserProperty "Dsn\191;\139\245)]\214 \STX\189\206Q\176" -// "\231\242\&5{\SUB\179\227\180\221\209:\135\128\188\ACK\177e\NUL",PropResponseInformation -// "a\132\238\194Ge\198\204@xC@%in\RS\138!\SIl@\241"]} -TEST(Connect5QCTest, Encode89) { - uint8_t pkt[] = {0x10, 0x81, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x6e, 0xfd, 0x40, 0x26, 0x0, 0x10, - 0x44, 0x73, 0x6e, 0xbf, 0x3b, 0x8b, 0xf5, 0x29, 0x5d, 0xd6, 0x20, 0x2, 0xbd, 0xce, 0x51, 0xb0, 0x0, - 0x12, 0xe7, 0xf2, 0x35, 0x7b, 0x1a, 0xb3, 0xe3, 0xb4, 0xdd, 0xd1, 0x3a, 0x87, 0x80, 0xbc, 0x6, 0xb1, - 0x65, 0x0, 0x1a, 0x0, 0x16, 0x61, 0x84, 0xee, 0xc2, 0x47, 0x65, 0xc6, 0xcc, 0x40, 0x78, 0x43, 0x40, - 0x25, 0x69, 0x6e, 0x1e, 0x8a, 0x21, 0xf, 0x6c, 0x40, 0xf1, 0x0, 0xb, 0xd7, 0xbc, 0x3a, 0x16, 0x5d, - 0x3f, 0xa, 0xd6, 0xb0, 0x32, 0x69, 0x0, 0x16, 0x74, 0xab, 0x6f, 0xa8, 0x17, 0x4, 0x4, 0xe2, 0x8, - 0xf, 0xcd, 0xa6, 0x4a, 0xe, 0x6a, 0xa4, 0x17, 0x1a, 0xa6, 0xf5, 0x1f, 0x1a, 0x0, 0xf, 0x15, 0xa9, - 0x5f, 0xfb, 0x15, 0xba, 0x10, 0xd7, 0xa9, 0x6b, 0x57, 0x33, 0x4a, 0x8, 0xc7}; - - uint8_t buf[142] = {0}; - - uint8_t bytesprops1[] = {0xe7, 0xf2, 0x35, 0x7b, 0x1a, 0xb3, 0xe3, 0xb4, 0xdd, - 0xd1, 0x3a, 0x87, 0x80, 0xbc, 0x6, 0xb1, 0x65, 0x0}; - uint8_t bytesprops0[] = {0x44, 0x73, 0x6e, 0xbf, 0x3b, 0x8b, 0xf5, 0x29, - 0x5d, 0xd6, 0x20, 0x2, 0xbd, 0xce, 0x51, 0xb0}; - uint8_t bytesprops2[] = {0x61, 0x84, 0xee, 0xc2, 0x47, 0x65, 0xc6, 0xcc, 0x40, 0x78, 0x43, - 0x40, 0x25, 0x69, 0x6e, 0x1e, 0x8a, 0x21, 0xf, 0x6c, 0x40, 0xf1}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x3a, 0xc1, 0x40, 0xb2, 0xba, 0xdb, 0x88, 0xb4}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xfe, 0xee, 0x5d, 0xf5, 0xb8, 0x3f, 0xef}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x57, 0x27, 0x84, 0x3c, 0x13, 0xa, 0x55, 0x42, + 0x4d, 0x43, 0x9f, 0xac, 0x62, 0x0, 0xb9}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops0[] = {0xf2, 0x4e, 0x1e, 0xd6, 0x39, 0xc7, 0xf5, 0x5a, 0x51}; + uint8_t bytesprops2[] = {0xeb, 0xcf, 0x4d, 0x6d, 0x17}; + uint8_t bytesprops3[] = {0x83, 0x58, 0x93, 0x1c, 0x44, 0xf6}; + uint8_t bytesprops4[] = {0xdb, 0x95, 0x74, 0x73, 0x59, 0xf, 0x98, 0x23, 0x35, 0x13, 0xe1, 0xc, 0xff, 0xe9, 0xe, + 0x1, 0xcd, 0xb6, 0xa3, 0x24, 0xff, 0xdf, 0xe0, 0xf6, 0xf, 0x96, 0x9, 0x4f, 0x45, 0xe2}; + uint8_t bytesprops5[] = {0x2f, 0xa4, 0xb, 0x51, 0xae, 0x6}; + uint8_t bytesprops6[] = {0xd7, 0xb, 0x0, 0x35, 0xf9, 0xa}; + uint8_t bytesprops7[] = {0xa0, 0x4b, 0x5a, 0x9f, 0x72, 0x8f, 0x52, 0x88, 0xe2, + 0xef, 0x76, 0x79, 0x16, 0x14, 0x1c, 0xcc, 0x1, 0xe4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops0}, .v = {18, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28313}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2536}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24195}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19137}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12776}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 28413; - uint8_t client_id_bytes[] = {0xd7, 0xbc, 0x3a, 0x16, 0x5d, 0x3f, 0xa, 0xd6, 0xb0, 0x32, 0x69}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x74, 0xab, 0x6f, 0xa8, 0x17, 0x4, 0x4, 0xe2, 0x8, 0xf, 0xcd, - 0xa6, 0x4a, 0xe, 0x6a, 0xa4, 0x17, 0x1a, 0xa6, 0xf5, 0x1f, 0x1a}; - lwmqtt_string_t username = {22, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x15, 0xa9, 0x5f, 0xfb, 0x15, 0xba, 0x10, 0xd7, 0xa9, 0x6b, 0x57, 0x33, 0x4a, 0x8, 0xc7}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28088, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "M", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS1, _willTopic = "", _willMsg = "\163\147\EOT\177\219J\221\FSm_\STX\RS\rK\130D\159\n}", _willProps = -// [PropRequestResponseInformation 142,PropCorrelationData "}d\US\205\128\232tmf",PropContentType -// "\NULS\DC4\225_2M\USZA\218`,b\216\f\250\SI\157",PropResponseInformation -// "\171L8M\DC21\CAN\147\DLE\ETXR\229\151\159\EOT ",PropMaximumQoS 249,PropResponseTopic -// "\EOTu\DC2\225\176\241\146\161",PropAuthenticationMethod -// "!\143\DC2vB\188G\RS\213FH\140\129\137J\223\227\NAK",PropRequestProblemInformation 18,PropMessageExpiryInterval -// 31057,PropUserProperty "\f\231\205b\SO?\v'q_\205<\168i\210\130\238\146" "\t%\202Zl\253\153 -// \143a\EOT\237w",PropRetainAvailable 151]}), _cleanSession = True, _keepAlive = 6707, _connID = -// "\248\222\190\&6\US\171Z\135\192\253\DEL\205\US\238\ETXR\201|\SUB", _properties = [PropResponseTopic -// "\138\ESC\135\164\v\250\216z\\\154\161\203",PropMaximumPacketSize 17854,PropServerReference -// "\142\246\245\211K\171^\SI\238\171\140C\241\248C\FS\218]",PropSubscriptionIdentifierAvailable -// 167,PropMessageExpiryInterval 18201,PropMessageExpiryInterval 31288,PropCorrelationData -// "8\US,\247\193\189\207\226\251\233\DEL4\255&A\229\182l\DC4\209@\150?g",PropRequestProblemInformation -// 245,PropUserProperty "\193\168" "\207\180\179\155",PropSessionExpiryInterval 7300,PropMaximumQoS 101,PropMaximumQoS -// 160,PropCorrelationData "\200\207\189\253u~~b",PropRequestResponseInformation 107,PropSubscriptionIdentifier 18]} -TEST(Connect5QCTest, Encode90) { - uint8_t pkt[] = { - 0x10, 0xb4, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2e, 0x1a, 0x33, 0x75, 0x8, 0x0, 0xc, 0x8a, 0x1b, - 0x87, 0xa4, 0xb, 0xfa, 0xd8, 0x7a, 0x5c, 0x9a, 0xa1, 0xcb, 0x27, 0x0, 0x0, 0x45, 0xbe, 0x1c, 0x0, 0x12, 0x8e, - 0xf6, 0xf5, 0xd3, 0x4b, 0xab, 0x5e, 0xf, 0xee, 0xab, 0x8c, 0x43, 0xf1, 0xf8, 0x43, 0x1c, 0xda, 0x5d, 0x29, 0xa7, - 0x2, 0x0, 0x0, 0x47, 0x19, 0x2, 0x0, 0x0, 0x7a, 0x38, 0x9, 0x0, 0x18, 0x38, 0x1f, 0x2c, 0xf7, 0xc1, 0xbd, - 0xcf, 0xe2, 0xfb, 0xe9, 0x7f, 0x34, 0xff, 0x26, 0x41, 0xe5, 0xb6, 0x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 0x5a, 0x6c, 0xfd, 0x99, 0x20, 0x8f, 0x61, 0x4, 0xed, - 0x77, 0x25, 0x97, 0x0, 0x0, 0x0, 0x13, 0xa3, 0x93, 0x4, 0xb1, 0xdb, 0x4a, 0xdd, 0x1c, 0x6d, 0x5f, 0x2, 0x1e, - 0xd, 0x4b, 0x82, 0x44, 0x9f, 0xa, 0x7d}; +// SubscribeRequest 4272 [("\":\159\"\202S\RS\ACK\244z5",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\242\235\190\253wC6\EMH\250\232\247\131u\172\a=\132\224\&9\192 \GS",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\222!bl\193ck\202\&8K",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\162\190\167\211\FS\232\161;\130{%\ENQ\ACK\200\DC1\153\206\DC2\172b\193r\138",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("!",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropServerReference +// "g\GS,j\141\215\ETXY\202\154\226>\167\230\b9",PropPayloadFormatIndicator 19] +TEST(Subscribe5QCTest, Encode81) { + uint8_t pkt[] = {0x82, 0x6b, 0x10, 0xb0, 0x15, 0x1c, 0x0, 0x10, 0x67, 0x1d, 0x2c, 0x6a, 0x8d, 0xd7, 0x3, 0x59, + 0xca, 0x9a, 0xe2, 0x3e, 0xa7, 0xe6, 0x8, 0x39, 0x1, 0x13, 0x0, 0xb, 0x22, 0x3a, 0x9f, 0x22, + 0xca, 0x53, 0x1e, 0x6, 0xf4, 0x7a, 0x35, 0x2, 0x0, 0x17, 0xf2, 0xeb, 0xbe, 0xfd, 0x77, 0x43, + 0x36, 0x19, 0x48, 0xfa, 0xe8, 0xf7, 0x83, 0x75, 0xac, 0x7, 0x3d, 0x84, 0xe0, 0x39, 0xc0, 0x20, + 0x1d, 0x0, 0x0, 0xa, 0xde, 0x21, 0x62, 0x6c, 0xc1, 0x63, 0x6b, 0xca, 0x38, 0x4b, 0x0, 0x0, + 0x17, 0xa2, 0xbe, 0xa7, 0xd3, 0x1c, 0xe8, 0xa1, 0x3b, 0x82, 0x7b, 0x25, 0x5, 0x6, 0xc8, 0x11, + 0x99, 0xce, 0x12, 0xac, 0x62, 0xc1, 0x72, 0x8a, 0x2, 0x0, 0x1, 0x21, 0x2}; - uint8_t buf[321] = {0}; + uint8_t buf[119] = {0}; - uint8_t bytesprops0[] = {0x8a, 0x1b, 0x87, 0xa4, 0xb, 0xfa, 0xd8, 0x7a, 0x5c, 0x9a, 0xa1, 0xcb}; - uint8_t bytesprops1[] = {0x8e, 0xf6, 0xf5, 0xd3, 0x4b, 0xab, 0x5e, 0xf, 0xee, - 0xab, 0x8c, 0x43, 0xf1, 0xf8, 0x43, 0x1c, 0xda, 0x5d}; - uint8_t bytesprops2[] = {0x38, 0x1f, 0x2c, 0xf7, 0xc1, 0xbd, 0xcf, 0xe2, 0xfb, 0xe9, 0x7f, 0x34, - 0xff, 0x26, 0x41, 0xe5, 0xb6, 0x6c, 0x14, 0xd1, 0x40, 0x96, 0x3f, 0x67}; - uint8_t bytesprops4[] = {0xcf, 0xb4, 0xb3, 0x9b}; - uint8_t bytesprops3[] = {0xc1, 0xa8}; - uint8_t bytesprops5[] = {0xc8, 0xcf, 0xbd, 0xfd, 0x75, 0x7e, 0x7e, 0x62}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x22, 0x3a, 0x9f, 0x22, 0xca, 0x53, 0x1e, 0x6, 0xf4, 0x7a, 0x35}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf2, 0xeb, 0xbe, 0xfd, 0x77, 0x43, 0x36, 0x19, 0x48, 0xfa, 0xe8, 0xf7, + 0x83, 0x75, 0xac, 0x7, 0x3d, 0x84, 0xe0, 0x39, 0xc0, 0x20, 0x1d}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xde, 0x21, 0x62, 0x6c, 0xc1, 0x63, 0x6b, 0xca, 0x38, 0x4b}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa2, 0xbe, 0xa7, 0xd3, 0x1c, 0xe8, 0xa1, 0x3b, 0x82, 0x7b, 0x25, 0x5, + 0x6, 0xc8, 0x11, 0x99, 0xce, 0x12, 0xac, 0x62, 0xc1, 0x72, 0x8a}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x21}; + lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x67, 0x1d, 0x2c, 0x6a, 0x8d, 0xd7, 0x3, 0x59, + 0xca, 0x9a, 0xe2, 0x3e, 0xa7, 0xe6, 0x8, 0x39}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17854}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18201}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31288}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops3}, .v = {4, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7300}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - }; - - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x7d, 0x64, 0x1f, 0xcd, 0x80, 0xe8, 0x74, 0x6d, 0x66}; - uint8_t byteswillprops1[] = {0x0, 0x53, 0x14, 0xe1, 0x5f, 0x32, 0x4d, 0x1f, 0x5a, 0x41, - 0xda, 0x60, 0x2c, 0x62, 0xd8, 0xc, 0xfa, 0xf, 0x9d}; - uint8_t byteswillprops2[] = {0xab, 0x4c, 0x38, 0x4d, 0x12, 0x31, 0x18, 0x93, - 0x10, 0x3, 0x52, 0xe5, 0x97, 0x9f, 0x4, 0x20}; - uint8_t byteswillprops3[] = {0x4, 0x75, 0x12, 0xe1, 0xb0, 0xf1, 0x92, 0xa1}; - uint8_t byteswillprops4[] = {0x21, 0x8f, 0x12, 0x76, 0x42, 0xbc, 0x47, 0x1e, 0xd5, - 0x46, 0x48, 0x8c, 0x81, 0x89, 0x4a, 0xdf, 0xe3, 0x15}; - uint8_t byteswillprops6[] = {0x9, 0x25, 0xca, 0x5a, 0x6c, 0xfd, 0x99, 0x20, 0x8f, 0x61, 0x4, 0xed, 0x77}; - uint8_t byteswillprops5[] = {0xc, 0xe7, 0xcd, 0x62, 0xe, 0x3f, 0xb, 0x27, 0x71, - 0x5f, 0xcd, 0x3c, 0xa8, 0x69, 0xd2, 0x82, 0xee, 0x92}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31057}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {18, (char*)&byteswillprops5}, .v = {13, (char*)&byteswillprops6}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 19}}, }; - lwmqtt_properties_t willprops = {11, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa3, 0x93, 0x4, 0xb1, 0xdb, 0x4a, 0xdd, 0x1c, 0x6d, 0x5f, - 0x2, 0x1e, 0xd, 0x4b, 0x82, 0x44, 0x9f, 0xa, 0x7d}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 6707; - uint8_t client_id_bytes[] = {0xf8, 0xde, 0xbe, 0x36, 0x1f, 0xab, 0x5a, 0x87, 0xc0, 0xfd, - 0x7f, 0xcd, 0x1f, 0xee, 0x3, 0x52, 0xc9, 0x7c, 0x1a}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x4d}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4272, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\135\167", _password = Just "do\ETX\170V\239N\235\129|\168G\SO\218O\245SW\228", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\198\149\RSL\143\254\166!", _willMsg = -// ":\215\\\152\141^\ETXb\198", _willProps = [PropServerReference "\138",PropSubscriptionIdentifier -// 30,PropRetainAvailable 153,PropReceiveMaximum 18956,PropMessageExpiryInterval -// 23816,PropSubscriptionIdentifierAvailable 147,PropResponseInformation -// "\250Z\151[\183\193d\144E](P\181\239g\172\251\240q\180\189k\165,\b",PropSubscriptionIdentifierAvailable -// 34,PropCorrelationData "\133\220\130\235\214\244\246W\202\ACK -// @\218$\199\211\235uzSf\215fF!\160\255V\151",PropMessageExpiryInterval 19228,PropReceiveMaximum -// 15862,PropCorrelationData "89\160U\196\207,\164\221;\US7\f\220\128\145\&6c&\158R",PropServerReference -// "%\n\NAK@tW?\141\228\214\254\&8\GS\DC4J\SUB\197;?",PropTopicAlias 12803,PropRequestResponseInformation -// 24,PropWillDelayInterval 23550,PropSubscriptionIdentifierAvailable 114,PropResponseInformation -// "\155N!U\136\DC3\155y\245\139f(]0\211\SUBV\229",PropAssignedClientIdentifier -// "W]\166\225_&\137\&5\208\192",PropSessionExpiryInterval 5122,PropMessageExpiryInterval 8890,PropContentType -// "\229Q"]}), _cleanSession = True, _keepAlive = 1501, _connID = -// "\234YO\DC3;\148\207\&0\153n\199\142\146\206\254\155:", _properties = [PropResponseInformation -// "\204\143",PropRequestResponseInformation 158,PropSubscriptionIdentifierAvailable 8,PropPayloadFormatIndicator -// 12,PropCorrelationData "\211\132\206M\223\171\159\226pm",PropWildcardSubscriptionAvailable 46,PropReceiveMaximum -// 12964,PropSharedSubscriptionAvailable 216,PropAuthenticationMethod -// "\SI\vG\189?\EOT\222\162\137\190\181D?d",PropTopicAlias 20345,PropTopicAlias 8272,PropUserProperty -// "\234e\223\137\155\SYN\t\221i\219>" "\241",PropPayloadFormatIndicator 200,PropReasonString -// "C\141\208\229\CAN[\166\140\149",PropSessionExpiryInterval 26063,PropAuthenticationMethod -// "\255U\155a\213\202/\170\235\144\RS:\156\138\ETB|(\169n\192\250m"]} -TEST(Connect5QCTest, Encode91) { +// SubscribeRequest 14420 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\193\143\248\171\SUBB\US\162U`\238\207",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\230\138\SIF\159~gN\227\241|",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("'\194\SUB\DC1\143+,\"\128\209\SUB\220\162\DC1\240\196\DC3\226\NUL\146\226:\STX\189J*~&\200",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("~3\195L&]\160\184\161\STX\168\181#Em!\205\252K\253",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("dI\177g\202Vp4k\ENQ\178\255z\171x\212\STX\224\RSS\FS\169\144\180\151\182\201",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("6\NAK\EOT\145\216\229B\EM\247\242\&1b\223\131\141",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropRequestProblemInformation +// 252,PropAssignedClientIdentifier +// "%B\255}\155\198\220`\225\SUB\199A\186\240\129\&2\DLE\236y\186",PropMessageExpiryInterval 25332] +TEST(Subscribe5QCTest, Encode82) { uint8_t pkt[] = { - 0x10, 0x84, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x5, 0xdd, 0x73, 0x1a, 0x0, 0x2, 0xcc, 0x8f, - 0x19, 0x9e, 0x29, 0x8, 0x1, 0xc, 0x9, 0x0, 0xa, 0xd3, 0x84, 0xce, 0x4d, 0xdf, 0xab, 0x9f, 0xe2, 0x70, 0x6d, - 0x28, 0x2e, 0x21, 0x32, 0xa4, 0x2a, 0xd8, 0x15, 0x0, 0xe, 0xf, 0xb, 0x47, 0xbd, 0x3f, 0x4, 0xde, 0xa2, 0x89, - 0xbe, 0xb5, 0x44, 0x3f, 0x64, 0x23, 0x4f, 0x79, 0x23, 0x20, 0x50, 0x26, 0x0, 0xb, 0xea, 0x65, 0xdf, 0x89, 0x9b, - 0x16, 0x9, 0xdd, 0x69, 0xdb, 0x3e, 0x0, 0x1, 0xf1, 0x1, 0xc8, 0x1f, 0x0, 0x9, 0x43, 0x8d, 0xd0, 0xe5, 0x18, - 0x5b, 0xa6, 0x8c, 0x95, 0x11, 0x0, 0x0, 0x65, 0xcf, 0x15, 0x0, 0x16, 0xff, 0x55, 0x9b, 0x61, 0xd5, 0xca, 0x2f, - 0xaa, 0xeb, 0x90, 0x1e, 0x3a, 0x9c, 0x8a, 0x17, 0x7c, 0x28, 0x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0x5d, 0x30, 0xd3, 0x1a, 0x56, 0xe5, 0x12, 0x0, 0xa, 0x57, 0x5d, 0xa6, - 0xe1, 0x5f, 0x26, 0x89, 0x35, 0xd0, 0xc0, 0x11, 0x0, 0x0, 0x14, 0x2, 0x2, 0x0, 0x0, 0x22, 0xba, 0x3, 0x0, - 0x2, 0xe5, 0x51, 0x0, 0x8, 0xc6, 0x95, 0x1e, 0x4c, 0x8f, 0xfe, 0xa6, 0x21, 0x0, 0x9, 0x3a, 0xd7, 0x5c, 0x98, - 0x8d, 0x5e, 0x3, 0x62, 0xc6, 0x0, 0x2, 0x87, 0xa7, 0x0, 0x13, 0x64, 0x6f, 0x3, 0xaa, 0x56, 0xef, 0x4e, 0xeb, - 0x81, 0x7c, 0xa8, 0x47, 0xe, 0xda, 0x4f, 0xf5, 0x53, 0x57, 0xe4}; - - uint8_t buf[401] = {0}; - - uint8_t bytesprops0[] = {0xcc, 0x8f}; - uint8_t bytesprops1[] = {0xd3, 0x84, 0xce, 0x4d, 0xdf, 0xab, 0x9f, 0xe2, 0x70, 0x6d}; - uint8_t bytesprops2[] = {0xf, 0xb, 0x47, 0xbd, 0x3f, 0x4, 0xde, 0xa2, 0x89, 0xbe, 0xb5, 0x44, 0x3f, 0x64}; - uint8_t bytesprops4[] = {0xf1}; - uint8_t bytesprops3[] = {0xea, 0x65, 0xdf, 0x89, 0x9b, 0x16, 0x9, 0xdd, 0x69, 0xdb, 0x3e}; - uint8_t bytesprops5[] = {0x43, 0x8d, 0xd0, 0xe5, 0x18, 0x5b, 0xa6, 0x8c, 0x95}; - uint8_t bytesprops6[] = {0xff, 0x55, 0x9b, 0x61, 0xd5, 0xca, 0x2f, 0xaa, 0xeb, 0x90, 0x1e, - 0x3a, 0x9c, 0x8a, 0x17, 0x7c, 0x28, 0xa9, 0x6e, 0xc0, 0xfa, 0x6d}; + 0x82, 0xa8, 0x1, 0x38, 0x54, 0x1e, 0x17, 0xfc, 0x12, 0x0, 0x14, 0x25, 0x42, 0xff, 0x7d, 0x9b, 0xc6, 0xdc, 0x60, + 0xe1, 0x1a, 0xc7, 0x41, 0xba, 0xf0, 0x81, 0x32, 0x10, 0xec, 0x79, 0xba, 0x2, 0x0, 0x0, 0x62, 0xf4, 0x0, 0x0, + 0x0, 0x0, 0xc, 0xc1, 0x8f, 0xf8, 0xab, 0x1a, 0x42, 0x1f, 0xa2, 0x55, 0x60, 0xee, 0xcf, 0x0, 0x0, 0xb, 0xe6, + 0x8a, 0xf, 0x46, 0x9f, 0x7e, 0x67, 0x4e, 0xe3, 0xf1, 0x7c, 0x0, 0x0, 0x1d, 0x27, 0xc2, 0x1a, 0x11, 0x8f, 0x2b, + 0x2c, 0x22, 0x80, 0xd1, 0x1a, 0xdc, 0xa2, 0x11, 0xf0, 0xc4, 0x13, 0xe2, 0x0, 0x92, 0xe2, 0x3a, 0x2, 0xbd, 0x4a, + 0x2a, 0x7e, 0x26, 0xc8, 0x2, 0x0, 0x14, 0x7e, 0x33, 0xc3, 0x4c, 0x26, 0x5d, 0xa0, 0xb8, 0xa1, 0x2, 0xa8, 0xb5, + 0x23, 0x45, 0x6d, 0x21, 0xcd, 0xfc, 0x4b, 0xfd, 0x2, 0x0, 0x1b, 0x64, 0x49, 0xb1, 0x67, 0xca, 0x56, 0x70, 0x34, + 0x6b, 0x5, 0xb2, 0xff, 0x7a, 0xab, 0x78, 0xd4, 0x2, 0xe0, 0x1e, 0x53, 0x1c, 0xa9, 0x90, 0xb4, 0x97, 0xb6, 0xc9, + 0x2, 0x0, 0xf, 0x36, 0x15, 0x4, 0x91, 0xd8, 0xe5, 0x42, 0x19, 0xf7, 0xf2, 0x31, 0x62, 0xdf, 0x83, 0x8d, 0x2}; + + uint8_t buf[181] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc1, 0x8f, 0xf8, 0xab, 0x1a, 0x42, 0x1f, 0xa2, 0x55, 0x60, 0xee, 0xcf}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe6, 0x8a, 0xf, 0x46, 0x9f, 0x7e, 0x67, 0x4e, 0xe3, 0xf1, 0x7c}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x27, 0xc2, 0x1a, 0x11, 0x8f, 0x2b, 0x2c, 0x22, 0x80, 0xd1, + 0x1a, 0xdc, 0xa2, 0x11, 0xf0, 0xc4, 0x13, 0xe2, 0x0, 0x92, + 0xe2, 0x3a, 0x2, 0xbd, 0x4a, 0x2a, 0x7e, 0x26, 0xc8}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x7e, 0x33, 0xc3, 0x4c, 0x26, 0x5d, 0xa0, 0xb8, 0xa1, 0x2, + 0xa8, 0xb5, 0x23, 0x45, 0x6d, 0x21, 0xcd, 0xfc, 0x4b, 0xfd}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x64, 0x49, 0xb1, 0x67, 0xca, 0x56, 0x70, 0x34, 0x6b, 0x5, 0xb2, 0xff, 0x7a, 0xab, + 0x78, 0xd4, 0x2, 0xe0, 0x1e, 0x53, 0x1c, 0xa9, 0x90, 0xb4, 0x97, 0xb6, 0xc9}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x36, 0x15, 0x4, 0x91, 0xd8, 0xe5, 0x42, 0x19, + 0xf7, 0xf2, 0x31, 0x62, 0xdf, 0x83, 0x8d}; + lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x25, 0x42, 0xff, 0x7d, 0x9b, 0xc6, 0xdc, 0x60, 0xe1, 0x1a, + 0xc7, 0x41, 0xba, 0xf0, 0x81, 0x32, 0x10, 0xec, 0x79, 0xba}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12964}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20345}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8272}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops3}, .v = {1, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26063}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25332}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x8a}; - uint8_t byteswillprops1[] = {0xfa, 0x5a, 0x97, 0x5b, 0xb7, 0xc1, 0x64, 0x90, 0x45, 0x5d, 0x28, 0x50, 0xb5, - 0xef, 0x67, 0xac, 0xfb, 0xf0, 0x71, 0xb4, 0xbd, 0x6b, 0xa5, 0x2c, 0x8}; - uint8_t byteswillprops2[] = {0x85, 0xdc, 0x82, 0xeb, 0xd6, 0xf4, 0xf6, 0x57, 0xca, 0x6, 0x20, 0x40, 0xda, 0x24, 0xc7, - 0xd3, 0xeb, 0x75, 0x7a, 0x53, 0x66, 0xd7, 0x66, 0x46, 0x21, 0xa0, 0xff, 0x56, 0x97}; - uint8_t byteswillprops3[] = {0x38, 0x39, 0xa0, 0x55, 0xc4, 0xcf, 0x2c, 0xa4, 0xdd, 0x3b, 0x1f, - 0x37, 0xc, 0xdc, 0x80, 0x91, 0x36, 0x63, 0x26, 0x9e, 0x52}; - uint8_t byteswillprops4[] = {0x25, 0xa, 0x15, 0x40, 0x74, 0x57, 0x3f, 0x8d, 0xe4, 0xd6, - 0xfe, 0x38, 0x1d, 0x14, 0x4a, 0x1a, 0xc5, 0x3b, 0x3f}; - uint8_t byteswillprops5[] = {0x9b, 0x4e, 0x21, 0x55, 0x88, 0x13, 0x9b, 0x79, 0xf5, - 0x8b, 0x66, 0x28, 0x5d, 0x30, 0xd3, 0x1a, 0x56, 0xe5}; - uint8_t byteswillprops6[] = {0x57, 0x5d, 0xa6, 0xe1, 0x5f, 0x26, 0x89, 0x35, 0xd0, 0xc0}; - uint8_t byteswillprops7[] = {0xe5, 0x51}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14420, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 27160 [("\162D\159",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\195_\131\NULo|\DC3\153\204\130Z\129\a\148$\133jPw\238<\201\&1X\151F\133\248\217l",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\168\&1\255\241I\162\173v\254uZ*\140G",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\US=\184j\\AA\155\156@\178\229r'K0i\204\ESC\168Q'\196\226\234\233",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable +// 187,PropWildcardSubscriptionAvailable 85,PropReasonString "a~\212\\2\174",PropMessageExpiryInterval +// 1915,PropAuthenticationMethod "\203\EOT\163\f\ETB\185g+ny",PropMaximumQoS 220,PropReasonString +// "}m\a\DEL\205\&6'n\191\249\179d\213\200",PropSessionExpiryInterval 29557,PropCorrelationData +// "\160\194{\148{\SI\195\&8\174\f3\165\142\231(\180\145\NAK\216\214\152\201\187",PropWildcardSubscriptionAvailable 203] +TEST(Subscribe5QCTest, Encode83) { + uint8_t pkt[] = {0x82, 0xab, 0x1, 0x6a, 0x18, 0x53, 0x2a, 0xbb, 0x28, 0x55, 0x1f, 0x0, 0x6, 0x61, 0x7e, 0xd4, + 0x5c, 0x32, 0xae, 0x2, 0x0, 0x0, 0x7, 0x7b, 0x15, 0x0, 0xa, 0xcb, 0x4, 0xa3, 0xc, 0x17, + 0xb9, 0x67, 0x2b, 0x6e, 0x79, 0x24, 0xdc, 0x1f, 0x0, 0xe, 0x7d, 0x6d, 0x7, 0x7f, 0xcd, 0x36, + 0x27, 0x6e, 0xbf, 0xf9, 0xb3, 0x64, 0xd5, 0xc8, 0x11, 0x0, 0x0, 0x73, 0x75, 0x9, 0x0, 0x17, + 0xa0, 0xc2, 0x7b, 0x94, 0x7b, 0xf, 0xc3, 0x38, 0xae, 0xc, 0x33, 0xa5, 0x8e, 0xe7, 0x28, 0xb4, + 0x91, 0x15, 0xd8, 0xd6, 0x98, 0xc9, 0xbb, 0x28, 0xcb, 0x0, 0x3, 0xa2, 0x44, 0x9f, 0x2, 0x0, + 0x1e, 0xc3, 0x5f, 0x83, 0x0, 0x6f, 0x7c, 0x13, 0x99, 0xcc, 0x82, 0x5a, 0x81, 0x7, 0x94, 0x24, + 0x85, 0x6a, 0x50, 0x77, 0xee, 0x3c, 0xc9, 0x31, 0x58, 0x97, 0x46, 0x85, 0xf8, 0xd9, 0x6c, 0x2, + 0x0, 0xe, 0xa8, 0x31, 0xff, 0xf1, 0x49, 0xa2, 0xad, 0x76, 0xfe, 0x75, 0x5a, 0x2a, 0x8c, 0x47, + 0x1, 0x0, 0x1a, 0x1f, 0x3d, 0xb8, 0x6a, 0x5c, 0x41, 0x41, 0x9b, 0x9c, 0x40, 0xb2, 0xe5, 0x72, + 0x27, 0x4b, 0x30, 0x69, 0xcc, 0x1b, 0xa8, 0x51, 0x27, 0xc4, 0xe2, 0xea, 0xe9, 0x2}; + + uint8_t buf[184] = {0}; + + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xa2, 0x44, 0x9f}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc3, 0x5f, 0x83, 0x0, 0x6f, 0x7c, 0x13, 0x99, 0xcc, 0x82, + 0x5a, 0x81, 0x7, 0x94, 0x24, 0x85, 0x6a, 0x50, 0x77, 0xee, + 0x3c, 0xc9, 0x31, 0x58, 0x97, 0x46, 0x85, 0xf8, 0xd9, 0x6c}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa8, 0x31, 0xff, 0xf1, 0x49, 0xa2, 0xad, + 0x76, 0xfe, 0x75, 0x5a, 0x2a, 0x8c, 0x47}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x1f, 0x3d, 0xb8, 0x6a, 0x5c, 0x41, 0x41, 0x9b, 0x9c, 0x40, 0xb2, 0xe5, 0x72, + 0x27, 0x4b, 0x30, 0x69, 0xcc, 0x1b, 0xa8, 0x51, 0x27, 0xc4, 0xe2, 0xea, 0xe9}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x61, 0x7e, 0xd4, 0x5c, 0x32, 0xae}; + uint8_t bytesprops1[] = {0xcb, 0x4, 0xa3, 0xc, 0x17, 0xb9, 0x67, 0x2b, 0x6e, 0x79}; + uint8_t bytesprops2[] = {0x7d, 0x6d, 0x7, 0x7f, 0xcd, 0x36, 0x27, 0x6e, 0xbf, 0xf9, 0xb3, 0x64, 0xd5, 0xc8}; + uint8_t bytesprops3[] = {0xa0, 0xc2, 0x7b, 0x94, 0x7b, 0xf, 0xc3, 0x38, 0xae, 0xc, 0x33, 0xa5, + 0x8e, 0xe7, 0x28, 0xb4, 0x91, 0x15, 0xd8, 0xd6, 0x98, 0xc9, 0xbb}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18956}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23816}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19228}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15862}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12803}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23550}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5122}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8890}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&byteswillprops7}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1915}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29557}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 203}}, }; - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc6, 0x95, 0x1e, 0x4c, 0x8f, 0xfe, 0xa6, 0x21}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3a, 0xd7, 0x5c, 0x98, 0x8d, 0x5e, 0x3, 0x62, 0xc6}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1501; - uint8_t client_id_bytes[] = {0xea, 0x59, 0x4f, 0x13, 0x3b, 0x94, 0xcf, 0x30, 0x99, - 0x6e, 0xc7, 0x8e, 0x92, 0xce, 0xfe, 0x9b, 0x3a}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x87, 0xa7}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x64, 0x6f, 0x3, 0xaa, 0x56, 0xef, 0x4e, 0xeb, 0x81, 0x7c, - 0xa8, 0x47, 0xe, 0xda, 0x4f, 0xf5, 0x53, 0x57, 0xe4}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "J3\245R\234g\199\SUBe\f]Y\184\155\252O\131", _password = Just -// "N\130Z\162\174\221xV\181", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "L\149\222\209\ETB6\200tmGe\184\245\DLEg\135|\138v", _willMsg = -// "\240S\t;\152\130\197\DEL\227\191\221\138y|D\US\188\DC2\\\198@\207\&5\174\DC4w\GS1", _willProps = -// [PropSubscriptionIdentifier 3,PropRequestProblemInformation 225,PropRequestProblemInformation 27,PropUserProperty "" -// "9\239\SO:\222\213\150Y+X",PropMaximumPacketSize 14754,PropReasonString -// "b\DEL\t\176\128\r\242\201;\219n\242\144}\ETX\214\ETB\142\246\157n\162C1\201",PropMessageExpiryInterval -// 22587,PropAssignedClientIdentifier "\169]\148\nA\v\243\199\&1\NUL\SIU\228",PropServerReference -// "*\181R+jA\ETB\184\&7\243,3\215\152\145\182l",PropWildcardSubscriptionAvailable 163,PropUserProperty ">s" -// "\a\202\CAN\177@\197\210BLSH\202\228\220!Q\GS\211\160\158",PropReceiveMaximum 26684,PropAssignedClientIdentifier -// "\FS7\EOT\220J\220\196f\251k\179\174\SUBu\203\207\189\145\130\204@\146\DC4",PropSubscriptionIdentifier -// 0,PropUserProperty "\NAK\240Tn\ESC\210\EM\178\183\SI\195\251gt\190\248\158\211Q\SO_m*\186._j\137\198\DC3" -// "\164mE\b\156`",PropSessionExpiryInterval 12603,PropResponseInformation -// "\128\194\170\151\&1",PropWildcardSubscriptionAvailable 88,PropContentType -// "q\DLE\149\136\v\ESCS\234\132\ENQ",PropWildcardSubscriptionAvailable 84,PropSessionExpiryInterval -// 17195,PropSubscriptionIdentifierAvailable 83]}), _cleanSession = True, _keepAlive = 7620, _connID = -// "\180X\169B\252{L\217vd\b\249L\137\219\253\249W\166\245\152\SOnJJE\131\213", _properties = -// [PropPayloadFormatIndicator 252,PropRequestProblemInformation 223,PropSubscriptionIdentifierAvailable -// 195,PropSharedSubscriptionAvailable 91,PropSubscriptionIdentifier 5,PropRetainAvailable 80,PropSubscriptionIdentifier -// 0,PropContentType "\163O\195\187\207\n2\178\239TS"]} -TEST(Connect5QCTest, Encode92) { + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27160, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 22660 +// [("k\215\&6o4\168\148\NAKl|\DC2eLi\r\203\ETX\152\158\131\197\142\143\248\134l\CAN\243\SYN",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("!m\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS +// = QoS1}),("t\a\155\243\134r\ETB)\244Y:",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\144",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("Dy",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("\169p\197\187\137\SUBA\138\224\242\167\174\rh\b\143\210f\225\220\STX\200\t",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\rw\214#2r\221~\249",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropMaximumPacketSize 15050,PropMessageExpiryInterval 9141,PropTopicAliasMaximum 1046,PropContentType +// "Cw\245\144na\225\236s\130\SO\167\166\DEL\246\227\139\140\131\161Y\DLE/i\149\173 ",PropRequestProblemInformation +// 147,PropWillDelayInterval 25750,PropContentType +// "\128\179\&7[\212\ETX\252\DC3\242\226}\EMT\198\134\&1\150\NUL\165n\140\&8{}\134",PropContentType +// "\a\r\192\211\194\202\197\255M:\214\196\SUB\ETB",PropWildcardSubscriptionAvailable 34,PropSubscriptionIdentifier +// 7,PropWillDelayInterval 11753,PropReceiveMaximum 29355,PropRetainAvailable 27,PropUserProperty +// "\173\202\135N\253\&3\186\\Yh\234Q\156\166\170\&9\148" +// "\156\203h`>Pmip\STX\214:\RSc\221\240\211\183\217ZQ\183,\175)\217\133>",PropMaximumQoS 212,PropTopicAlias +// 13251,PropWildcardSubscriptionAvailable 11,PropContentType +// "\183\175b\225!\234\241\EOT\189I\133f\158M",PropMessageExpiryInterval 19195,PropSessionExpiryInterval +// 3913,PropSubscriptionIdentifier 3,PropContentType "\226\212H\204\184\198",PropTopicAlias +// 4680,PropRequestResponseInformation 110,PropCorrelationData +// "\223\162K\142\179\DC1\ETX7\137s\250i\NUL\a\206'.",PropServerReference +// "/\151\SUB\232\186cY\147s3U/E\219\161z\214\210\148\228\227i\183"] +TEST(Subscribe5QCTest, Encode84) { uint8_t pkt[] = { - 0x10, 0x81, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x1d, 0xc4, 0x1c, 0x1, 0xfc, 0x17, 0xdf, 0x29, - 0xc3, 0x2a, 0x5b, 0xb, 0x5, 0x25, 0x50, 0xb, 0x0, 0x3, 0x0, 0xb, 0xa3, 0x4f, 0xc3, 0xbb, 0xcf, 0xa, 0x32, - 0xb2, 0xef, 0x54, 0x53, 0x0, 0x1c, 0xb4, 0x58, 0xa9, 0x42, 0xfc, 0x7b, 0x4c, 0xd9, 0x76, 0x64, 0x8, 0xf9, 0x4c, - 0x89, 0xdb, 0xfd, 0xf9, 0x57, 0xa6, 0xf5, 0x98, 0xe, 0x6e, 0x4a, 0x4a, 0x45, 0x83, 0xd5, 0xe9, 0x1, 0xb, 0x3, - 0x17, 0xe1, 0x17, 0x1b, 0x26, 0x0, 0x0, 0x0, 0xa, 0x39, 0xef, 0xe, 0x3a, 0xde, 0xd5, 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0, 0x5, 0x80, 0xc2, 0xaa, 0x97, 0x31, 0x28, 0x58, - 0x3, 0x0, 0xa, 0x71, 0x10, 0x95, 0x88, 0xb, 0x1b, 0x53, 0xea, 0x84, 0x5, 0x28, 0x54, 0x11, 0x0, 0x0, 0x43, - 0x2b, 0x29, 0x53, 0x0, 0x13, 0x4c, 0x95, 0xde, 0xd1, 0x17, 0x36, 0xc8, 0x74, 0x6d, 0x47, 0x65, 0xb8, 0xf5, 0x10, - 0x67, 0x87, 0x7c, 0x8a, 0x76, 0x0, 0x1c, 0xf0, 0x53, 0x9, 0x3b, 0x98, 0x82, 0xc5, 0x7f, 0xe3, 0xbf, 0xdd, 0x8a, - 0x79, 0x7c, 0x44, 0x1f, 0xbc, 0x12, 0x5c, 0xc6, 0x40, 0xcf, 0x35, 0xae, 0x14, 0x77, 0x1d, 0x31, 0x0, 0x11, 0x4a, - 0x33, 0xf5, 0x52, 0xea, 0x67, 0xc7, 0x1a, 0x65, 0xc, 0x5d, 0x59, 0xb8, 0x9b, 0xfc, 0x4f, 0x83, 0x0, 0x9, 0x4e, - 0x82, 0x5a, 0xa2, 0xae, 0xdd, 0x78, 0x56, 0xb5}; - - uint8_t buf[398] = {0}; - - uint8_t bytesprops0[] = {0xa3, 0x4f, 0xc3, 0xbb, 0xcf, 0xa, 0x32, 0xb2, 0xef, 0x54, 0x53}; + 0x82, 0xe6, 0x2, 0x58, 0x84, 0xff, 0x1, 0x27, 0x0, 0x0, 0x3a, 0xca, 0x2, 0x0, 0x0, 0x23, 0xb5, 0x22, 0x4, + 0x16, 0x3, 0x0, 0x1b, 0x43, 0x77, 0xf5, 0x90, 0x6e, 0x61, 0xe1, 0xec, 0x73, 0x82, 0xe, 0xa7, 0xa6, 0x7f, 0xf6, + 0xe3, 0x8b, 0x8c, 0x83, 0xa1, 0x59, 0x10, 0x2f, 0x69, 0x95, 0xad, 0x20, 0x17, 0x93, 0x18, 0x0, 0x0, 0x64, 0x96, + 0x3, 0x0, 0x19, 0x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, 0x33, 0x55, 0x2f, 0x45, 0xdb, 0xa1, 0x7a, 0xd6, 0xd2, 0x94, 0xe4, 0xe3, 0x69, 0xb7, 0x0, 0x1d, 0x6b, 0xd7, + 0x36, 0x6f, 0x34, 0xa8, 0x94, 0x15, 0x6c, 0x7c, 0x12, 0x65, 0x4c, 0x69, 0xd, 0xcb, 0x3, 0x98, 0x9e, 0x83, 0xc5, + 0x8e, 0x8f, 0xf8, 0x86, 0x6c, 0x18, 0xf3, 0x16, 0x0, 0x0, 0x3, 0x21, 0x6d, 0xb9, 0x1, 0x0, 0xb, 0x74, 0x7, + 0x9b, 0xf3, 0x86, 0x72, 0x17, 0x29, 0xf4, 0x59, 0x3a, 0x2, 0x0, 0x1, 0x90, 0x1, 0x0, 0x2, 0x44, 0x79, 0x0, + 0x0, 0x17, 0xa9, 0x70, 0xc5, 0xbb, 0x89, 0x1a, 0x41, 0x8a, 0xe0, 0xf2, 0xa7, 0xae, 0xd, 0x68, 0x8, 0x8f, 0xd2, + 0x66, 0xe1, 0xdc, 0x2, 0xc8, 0x9, 0x1, 0x0, 0x9, 0xd, 0x77, 0xd6, 0x23, 0x32, 0x72, 0xdd, 0x7e, 0xf9, 0x2}; + + uint8_t buf[371] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x6b, 0xd7, 0x36, 0x6f, 0x34, 0xa8, 0x94, 0x15, 0x6c, 0x7c, + 0x12, 0x65, 0x4c, 0x69, 0xd, 0xcb, 0x3, 0x98, 0x9e, 0x83, + 0xc5, 0x8e, 0x8f, 0xf8, 0x86, 0x6c, 0x18, 0xf3, 0x16}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x21, 0x6d, 0xb9}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x74, 0x7, 0x9b, 0xf3, 0x86, 0x72, 0x17, 0x29, 0xf4, 0x59, 0x3a}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x90}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x44, 0x79}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa9, 0x70, 0xc5, 0xbb, 0x89, 0x1a, 0x41, 0x8a, 0xe0, 0xf2, 0xa7, 0xae, + 0xd, 0x68, 0x8, 0x8f, 0xd2, 0x66, 0xe1, 0xdc, 0x2, 0xc8, 0x9}; + lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xd, 0x77, 0xd6, 0x23, 0x32, 0x72, 0xdd, 0x7e, 0xf9}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x43, 0x77, 0xf5, 0x90, 0x6e, 0x61, 0xe1, 0xec, 0x73, 0x82, 0xe, 0xa7, 0xa6, 0x7f, + 0xf6, 0xe3, 0x8b, 0x8c, 0x83, 0xa1, 0x59, 0x10, 0x2f, 0x69, 0x95, 0xad, 0x20}; + uint8_t bytesprops1[] = {0x80, 0xb3, 0x37, 0x5b, 0xd4, 0x3, 0xfc, 0x13, 0xf2, 0xe2, 0x7d, 0x19, 0x54, + 0xc6, 0x86, 0x31, 0x96, 0x0, 0xa5, 0x6e, 0x8c, 0x38, 0x7b, 0x7d, 0x86}; + uint8_t bytesprops2[] = {0x7, 0xd, 0xc0, 0xd3, 0xc2, 0xca, 0xc5, 0xff, 0x4d, 0x3a, 0xd6, 0xc4, 0x1a, 0x17}; + uint8_t bytesprops4[] = {0x9c, 0xcb, 0x68, 0x60, 0x3e, 0x50, 0x6d, 0x69, 0x70, 0x2, 0xd6, 0x3a, 0x1e, 0x63, + 0xdd, 0xf0, 0xd3, 0xb7, 0xd9, 0x5a, 0x51, 0xb7, 0x2c, 0xaf, 0x29, 0xd9, 0x85, 0x3e}; + uint8_t bytesprops3[] = {0xad, 0xca, 0x87, 0x4e, 0xfd, 0x33, 0xba, 0x5c, 0x59, + 0x68, 0xea, 0x51, 0x9c, 0xa6, 0xaa, 0x39, 0x94}; + uint8_t bytesprops5[] = {0xb7, 0xaf, 0x62, 0xe1, 0x21, 0xea, 0xf1, 0x4, 0xbd, 0x49, 0x85, 0x66, 0x9e, 0x4d}; + uint8_t bytesprops6[] = {0xe2, 0xd4, 0x48, 0xcc, 0xb8, 0xc6}; + uint8_t bytesprops7[] = {0xdf, 0xa2, 0x4b, 0x8e, 0xb3, 0x11, 0x3, 0x37, 0x89, + 0x73, 0xfa, 0x69, 0x0, 0x7, 0xce, 0x27, 0x2e}; + uint8_t bytesprops8[] = {0x2f, 0x97, 0x1a, 0xe8, 0xba, 0x63, 0x59, 0x93, 0x73, 0x33, 0x55, 0x2f, + 0x45, 0xdb, 0xa1, 0x7a, 0xd6, 0xd2, 0x94, 0xe4, 0xe3, 0x69, 0xb7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15050}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9141}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1046}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25750}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11753}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29355}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13251}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19195}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3913}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4680}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x39, 0xef, 0xe, 0x3a, 0xde, 0xd5, 0x96, 0x59, 0x2b, 0x58}; - uint8_t byteswillprops0[] = {0}; - uint8_t byteswillprops2[] = {0x62, 0x7f, 0x9, 0xb0, 0x80, 0xd, 0xf2, 0xc9, 0x3b, 0xdb, 0x6e, 0xf2, 0x90, - 0x7d, 0x3, 0xd6, 0x17, 0x8e, 0xf6, 0x9d, 0x6e, 0xa2, 0x43, 0x31, 0xc9}; - uint8_t byteswillprops3[] = {0xa9, 0x5d, 0x94, 0xa, 0x41, 0xb, 0xf3, 0xc7, 0x31, 0x0, 0xf, 0x55, 0xe4}; - uint8_t byteswillprops4[] = {0x2a, 0xb5, 0x52, 0x2b, 0x6a, 0x41, 0x17, 0xb8, 0x37, - 0xf3, 0x2c, 0x33, 0xd7, 0x98, 0x91, 0xb6, 0x6c}; - uint8_t byteswillprops6[] = {0x7, 0xca, 0x18, 0xb1, 0x40, 0xc5, 0xd2, 0x42, 0x4c, 0x53, - 0x48, 0xca, 0xe4, 0xdc, 0x21, 0x51, 0x1d, 0xd3, 0xa0, 0x9e}; - uint8_t byteswillprops5[] = {0x3e, 0x73}; - uint8_t byteswillprops7[] = {0x1c, 0x37, 0x4, 0xdc, 0x4a, 0xdc, 0xc4, 0x66, 0xfb, 0x6b, 0xb3, 0xae, - 0x1a, 0x75, 0xcb, 0xcf, 0xbd, 0x91, 0x82, 0xcc, 0x40, 0x92, 0x14}; - uint8_t byteswillprops9[] = {0xa4, 0x6d, 0x45, 0x8, 0x9c, 0x60}; - uint8_t byteswillprops8[] = {0x15, 0xf0, 0x54, 0x6e, 0x1b, 0xd2, 0x19, 0xb2, 0xb7, 0xf, - 0xc3, 0xfb, 0x67, 0x74, 0xbe, 0xf8, 0x9e, 0xd3, 0x51, 0xe, - 0x5f, 0x6d, 0x2a, 0xba, 0x2e, 0x5f, 0x6a, 0x89, 0xc6, 0x13}; - uint8_t byteswillprops10[] = {0x80, 0xc2, 0xaa, 0x97, 0x31}; - uint8_t byteswillprops11[] = {0x71, 0x10, 0x95, 0x88, 0xb, 0x1b, 0x53, 0xea, 0x84, 0x5}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22660, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 13206 [("\134\245\ft\GS\160Zb\214\NAK\247^\170\162\CAN\201D\147\244$\SUB\DC2\130d\170",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\134",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\190\142\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\NAKe\ETB\156>o\252\206\DC2F\DLE\224\224\183\231O\254`K\185\191\202",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\246\204EG\236x\DC3\172\243\168+\175\196v@#\DEL\188\&4\205M\226p1\165\174",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\ETX;\137\191}\SOdq\196\DC1\234\160\DEL1\173\155Rr8(\241S\132\173\129",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic +// "\178d\243\202\146\135\EM\156\214\174\SO\170\195\ESCNQ\190\bi\166f\213\182\244EK\192",PropSessionExpiryInterval +// 31168,PropResponseInformation +// "i\242\233\191\143\187&\129\136ZFH\209\129\SO\226\161&\ESC\155\221v\244d\ESC4\229b1^",PropMessageExpiryInterval +// 31515,PropRetainAvailable 52,PropReasonString "cA\DC3_d\NUL\FS\157\234\129",PropServerReference +// "{U\217\208\211m\186\r9\248\STX<\162|(\247\147\175ok\ESC",PropMaximumQoS 193,PropServerReference +// "\147kpEV\130",PropUserProperty "\137" "%(\164\218\157 +// \229\253\142\193\220\DLEMU[#\251\131\230\241\201\&5B\147\182",PropRequestProblemInformation 70,PropResponseTopic +// "s\STX\155RN\130\175\133v\240]\222\214\241\170E\ESC\DEL9\138\193\ETX\170\&0~m\ESC",PropWillDelayInterval +// 488,PropResponseTopic "\\y/2ZW\NUL^ n\215\227\248_\ESC\241p\248bW",PropReasonString +// "\169\230i\DC2\251d\164\250&\DLE\184\158|\187\156}\141,\141\241\176\181\226\134}xe\210",PropCorrelationData +// "5u\129\201\165b\137\239\SOHY\RS\250`\255\192\131",PropAuthenticationMethod +// "\208*1$\174\&6d4\224\238\255\141E\207,\fv\214\240}\137",PropMessageExpiryInterval 7357,PropAssignedClientIdentifier +// "\199g!\229\219jw\246GP\248~>\212\143F0\DLE\246\161D\150\a\253\188\173\b",PropMessageExpiryInterval +// 14764,PropMessageExpiryInterval 29761,PropContentType +// "^\188\172\164<9\245l\128\254\141\170\\",PropSharedSubscriptionAvailable 167,PropTopicAliasMaximum +// 11277,PropAssignedClientIdentifier "\165w4"] +TEST(Subscribe5QCTest, Encode85) { + uint8_t pkt[] = { + 0x82, 0xaf, 0x4, 0x33, 0x96, 0xaf, 0x3, 0x8, 0x0, 0x1b, 0xb2, 0x64, 0xf3, 0xca, 0x92, 0x87, 0x19, 0x9c, 0xd6, + 0xae, 0xe, 0xaa, 0xc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c, 0xad, 0x8, 0x2, 0x0, 0x0, + 0x39, 0xac, 0x2, 0x0, 0x0, 0x74, 0x41, 0x3, 0x0, 0x12, 0x5e, 0xbc, 0x3c, 0x67, 0xbf, 0xa4, 0x3e, 0xac, 0xa4, + 0x3c, 0x39, 0xf5, 0x6c, 0x80, 0xfe, 0x8d, 0xaa, 0x5c, 0x2a, 0xa7, 0x22, 0x2c, 0xd, 0x12, 0x0, 0x3, 0xa5, 0x77, + 0x34, 0x0, 0x19, 0x86, 0xf5, 0xc, 0x74, 0x1d, 0xa0, 0x5a, 0x62, 0xd6, 0x15, 0xf7, 0x5e, 0xaa, 0xa2, 0x18, 0xc9, + 0x44, 0x93, 0xf4, 0x24, 0x1a, 0x12, 0x82, 0x64, 0xaa, 0x1, 0x0, 0x1, 0x86, 0x1, 0x0, 0x3, 0xbe, 0x8e, 0xd2, + 0x2, 0x0, 0x1, 0x39, 0x1, 0x0, 0x16, 0x15, 0x65, 0x17, 0x9c, 0x3e, 0x6f, 0xfc, 0xce, 0x12, 0x46, 0x10, 0xe0, + 0xe0, 0xb7, 0xe7, 0x4f, 0xfe, 0x60, 0x4b, 0xb9, 0xbf, 0xca, 0x2, 0x0, 0x1a, 0xf6, 0xcc, 0x45, 0x47, 0xec, 0x78, + 0x13, 0xac, 0xf3, 0xa8, 0x2b, 0xaf, 0xc4, 0x76, 0x40, 0x23, 0x7f, 0xbc, 0x34, 0xcd, 0x4d, 0xe2, 0x70, 0x31, 0xa5, + 0xae, 0x0, 0x0, 0x19, 0x3, 0x3b, 0x89, 0xbf, 0x7d, 0xe, 0x64, 0x71, 0xc4, 0x11, 0xea, 0xa0, 0x7f, 0x31, 0xad, + 0x9b, 0x52, 0x72, 0x38, 0x28, 0xf1, 0x53, 0x84, 0xad, 0x81, 0x1}; + + uint8_t buf[572] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x86, 0xf5, 0xc, 0x74, 0x1d, 0xa0, 0x5a, 0x62, 0xd6, 0x15, 0xf7, 0x5e, 0xaa, + 0xa2, 0x18, 0xc9, 0x44, 0x93, 0xf4, 0x24, 0x1a, 0x12, 0x82, 0x64, 0xaa}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x86}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xbe, 0x8e, 0xd2}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x39}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x15, 0x65, 0x17, 0x9c, 0x3e, 0x6f, 0xfc, 0xce, 0x12, 0x46, 0x10, + 0xe0, 0xe0, 0xb7, 0xe7, 0x4f, 0xfe, 0x60, 0x4b, 0xb9, 0xbf, 0xca}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf6, 0xcc, 0x45, 0x47, 0xec, 0x78, 0x13, 0xac, 0xf3, 0xa8, 0x2b, 0xaf, 0xc4, + 0x76, 0x40, 0x23, 0x7f, 0xbc, 0x34, 0xcd, 0x4d, 0xe2, 0x70, 0x31, 0xa5, 0xae}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3, 0x3b, 0x89, 0xbf, 0x7d, 0xe, 0x64, 0x71, 0xc4, 0x11, 0xea, 0xa0, 0x7f, + 0x31, 0xad, 0x9b, 0x52, 0x72, 0x38, 0x28, 0xf1, 0x53, 0x84, 0xad, 0x81}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xb2, 0x64, 0xf3, 0xca, 0x92, 0x87, 0x19, 0x9c, 0xd6, 0xae, 0xe, 0xaa, 0xc3, 0x1b, + 0x4e, 0x51, 0xbe, 0x8, 0x69, 0xa6, 0x66, 0xd5, 0xb6, 0xf4, 0x45, 0x4b, 0xc0}; + uint8_t bytesprops1[] = {0x69, 0xf2, 0xe9, 0xbf, 0x8f, 0xbb, 0x26, 0x81, 0x88, 0x5a, 0x46, 0x48, 0xd1, 0x81, 0xe, + 0xe2, 0xa1, 0x26, 0x1b, 0x9b, 0xdd, 0x76, 0xf4, 0x64, 0x1b, 0x34, 0xe5, 0x62, 0x31, 0x5e}; + uint8_t bytesprops2[] = {0x63, 0x41, 0x13, 0x5f, 0x64, 0x0, 0x1c, 0x9d, 0xea, 0x81}; + uint8_t bytesprops3[] = {0x7b, 0x55, 0xd9, 0xd0, 0xd3, 0x6d, 0xba, 0xd, 0x39, 0xf8, 0x2, + 0x3c, 0xa2, 0x7c, 0x28, 0xf7, 0x93, 0xaf, 0x6f, 0x6b, 0x1b}; + uint8_t bytesprops4[] = {0x93, 0x6b, 0x70, 0x45, 0x56, 0x82}; + uint8_t bytesprops6[] = {0x25, 0x28, 0xa4, 0xda, 0x9d, 0x20, 0xe5, 0xfd, 0x8e, 0xc1, 0xdc, 0x10, 0x4d, + 0x55, 0x5b, 0x23, 0xfb, 0x83, 0xe6, 0xf1, 0xc9, 0x35, 0x42, 0x93, 0xb6}; + uint8_t bytesprops5[] = {0x89}; + uint8_t bytesprops7[] = {0x73, 0x2, 0x9b, 0x52, 0x4e, 0x82, 0xaf, 0x85, 0x76, 0xf0, 0x5d, 0xde, 0xd6, 0xf1, + 0xaa, 0x45, 0x1b, 0x7f, 0x39, 0x8a, 0xc1, 0x3, 0xaa, 0x30, 0x7e, 0x6d, 0x1b}; + uint8_t bytesprops8[] = {0x5c, 0x79, 0x2f, 0x32, 0x5a, 0x57, 0x0, 0x5e, 0x20, 0x6e, + 0xd7, 0xe3, 0xf8, 0x5f, 0x1b, 0xf1, 0x70, 0xf8, 0x62, 0x57}; + uint8_t bytesprops9[] = {0xa9, 0xe6, 0x69, 0x12, 0xfb, 0x64, 0xa4, 0xfa, 0x26, 0x10, 0xb8, 0x9e, 0x7c, 0xbb, + 0x9c, 0x7d, 0x8d, 0x2c, 0x8d, 0xf1, 0xb0, 0xb5, 0xe2, 0x86, 0x7d, 0x78, 0x65, 0xd2}; + uint8_t bytesprops10[] = {0x35, 0x75, 0x81, 0xc9, 0xa5, 0x62, 0x89, 0xef, + 0x1, 0x59, 0x1e, 0xfa, 0x60, 0xff, 0xc0, 0x83}; + uint8_t bytesprops11[] = {0xd0, 0x2a, 0x31, 0x24, 0xae, 0x36, 0x64, 0x34, 0xe0, 0xee, + 0xff, 0x8d, 0x45, 0xcf, 0x2c, 0xc, 0x76, 0xd6, 0x3c, 0x55}; + uint8_t bytesprops13[] = {0x96, 0xea, 0x9a, 0xd5, 0x4a, 0xc2, 0x56, 0x84, 0x94, 0x96, 0xb8, 0x1b, 0x9e, 0xac, 0x1d}; + uint8_t bytesprops12[] = {0x29, 0x95, 0x6c, 0xe8, 0x9c, 0x8d, 0x31, 0x94, 0x56, 0x64, 0x50, 0x64, + 0xe6, 0x26, 0xc6, 0x65, 0xa5, 0xf, 0xe7, 0x4f, 0x8d, 0x59, 0xa2}; + uint8_t bytesprops14[] = {0x30, 0x54, 0x57, 0x55, 0xca, 0xa2, 0x72, 0x37, 0x33, + 0x5, 0x69, 0xf9, 0x6, 0x3e, 0xf0, 0x7d, 0x89}; + uint8_t bytesprops15[] = {0xc7, 0x67, 0x21, 0xe5, 0xdb, 0x6a, 0x77, 0xf6, 0x47, 0x50, 0xf8, 0x7e, 0x3e, 0xd4, + 0x8f, 0x46, 0x30, 0x10, 0xf6, 0xa1, 0x44, 0x96, 0x7, 0xfd, 0xbc, 0xad, 0x8}; + uint8_t bytesprops16[] = {0x5e, 0xbc, 0x3c, 0x67, 0xbf, 0xa4, 0x3e, 0xac, 0xa4, + 0x3c, 0x39, 0xf5, 0x6c, 0x80, 0xfe, 0x8d, 0xaa, 0x5c}; + uint8_t bytesprops17[] = {0xa5, 0x77, 0x34}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {0, (char*)&byteswillprops0}, .v = {10, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14754}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22587}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {2, (char*)&byteswillprops5}, .v = {20, (char*)&byteswillprops6}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26684}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31168}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31515}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops5}, .v = {25, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 488}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 186}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {30, (char*)&byteswillprops8}, .v = {6, (char*)&byteswillprops9}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12603}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17195}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 83}}, + .value = {.pair = {.k = {23, (char*)&bytesprops12}, .v = {15, (char*)&bytesprops13}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7357}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14764}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29761}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops16}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11277}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops17}}}, }; - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4c, 0x95, 0xde, 0xd1, 0x17, 0x36, 0xc8, 0x74, 0x6d, 0x47, - 0x65, 0xb8, 0xf5, 0x10, 0x67, 0x87, 0x7c, 0x8a, 0x76}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf0, 0x53, 0x9, 0x3b, 0x98, 0x82, 0xc5, 0x7f, 0xe3, 0xbf, 0xdd, 0x8a, 0x79, 0x7c, - 0x44, 0x1f, 0xbc, 0x12, 0x5c, 0xc6, 0x40, 0xcf, 0x35, 0xae, 0x14, 0x77, 0x1d, 0x31}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 7620; - uint8_t client_id_bytes[] = {0xb4, 0x58, 0xa9, 0x42, 0xfc, 0x7b, 0x4c, 0xd9, 0x76, 0x64, 0x8, 0xf9, 0x4c, 0x89, - 0xdb, 0xfd, 0xf9, 0x57, 0xa6, 0xf5, 0x98, 0xe, 0x6e, 0x4a, 0x4a, 0x45, 0x83, 0xd5}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x4a, 0x33, 0xf5, 0x52, 0xea, 0x67, 0xc7, 0x1a, 0x65, - 0xc, 0x5d, 0x59, 0xb8, 0x9b, 0xfc, 0x4f, 0x83}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x4e, 0x82, 0x5a, 0xa2, 0xae, 0xdd, 0x78, 0x56, 0xb5}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13206, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 8501 [("\203p\176B\229Ul'\142n\159\GS\221",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropMessageExpiryInterval +// 24653,PropTopicAliasMaximum 4164,PropServerReference "t\177\211\&1\236\ETB\210\242\225\211I\183\254\219\208s\240\DC3E +// y\197\134\&3V\185\176",PropTopicAliasMaximum 23401,PropCorrelationData +// "@$\USa\SYNU\143\DC2\183%%><-\231\160\229\187\216",PropMessageExpiryInterval 8933,PropServerReference +// "9\234X\STX\GS\173\169\197Q\131\224\&9\191",PropServerReference "\185b\205ge!",PropAuthenticationMethod +// "\221\SIDGQ",PropSharedSubscriptionAvailable 181,PropSharedSubscriptionAvailable 26,PropSubscriptionIdentifier +// 4,PropServerReference +// "W\237\135\DC3\252\190\a\144\179\187g\140\175W$\226\181\240\&9\206\221\STX\FS\216\r\136\129",PropMessageExpiryInterval +// 13114,PropAuthenticationData +// "^\f\DC4\EOT\"b)\129\239\130\200\177\174\136\187jD\184\230'",PropRequestProblemInformation 92,PropServerReference +// "2t.\\\158\RSV",PropContentType "sEGBA\198a[\DC3\255\STX",PropServerReference +// "\169\"\212\129\aJl-\209\152",PropReasonString +// "!\168m/\210\144\DLE,\232\215G\156",PropSubscriptionIdentifierAvailable 122,PropCorrelationData +// "\149\FS%k5\143\US\v\203\&1",PropAuthenticationData "W\191 5]_RE\255\244\228\229",PropUserProperty "\233 " +// "\201\172\136\145#\206ub",PropRequestProblemInformation 148,PropResponseTopic "t\\>\184W\200\240\&9\143.1\229%:"] +TEST(Subscribe5QCTest, Encode86) { + uint8_t pkt[] = {0x82, 0xaf, 0x2, 0x21, 0x35, 0x9b, 0x2, 0x2, 0x0, 0x0, 0x60, 0x4d, 0x22, 0x10, 0x44, 0x1c, 0x0, + 0x1b, 0x74, 0xb1, 0xd3, 0x31, 0xec, 0x17, 0xd2, 0xf2, 0xe1, 0xd3, 0x49, 0xb7, 0xfe, 0xdb, 0xd0, 0x73, + 0xf0, 0x13, 0x45, 0x20, 0x79, 0xc5, 0x86, 0x33, 0x56, 0xb9, 0xb0, 0x22, 0x5b, 0x69, 0x9, 0x0, 0x13, + 0x40, 0x24, 0x1f, 0x61, 0x16, 0x55, 0x8f, 0x12, 0xb7, 0x25, 0x25, 0x3e, 0x3c, 0x2d, 0xe7, 0xa0, 0xe5, + 0xbb, 0xd8, 0x2, 0x0, 0x0, 0x22, 0xe5, 0x1c, 0x0, 0xd, 0x39, 0xea, 0x58, 0x2, 0x1d, 0xad, 0xa9, + 0xc5, 0x51, 0x83, 0xe0, 0x39, 0xbf, 0x1c, 0x0, 0x6, 0xb9, 0x62, 0xcd, 0x67, 0x65, 0x21, 0x15, 0x0, + 0x5, 0x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xd, 0xcb, 0x70, 0xb0, 0x42, 0xe5, 0x55, 0x6c, 0x27, 0x8e, 0x6e, 0x9f, 0x1d, 0xdd, 0x2}; + + uint8_t buf[316] = {0}; + + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xcb, 0x70, 0xb0, 0x42, 0xe5, 0x55, 0x6c, 0x27, 0x8e, 0x6e, 0x9f, 0x1d, 0xdd}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x74, 0xb1, 0xd3, 0x31, 0xec, 0x17, 0xd2, 0xf2, 0xe1, 0xd3, 0x49, 0xb7, 0xfe, 0xdb, + 0xd0, 0x73, 0xf0, 0x13, 0x45, 0x20, 0x79, 0xc5, 0x86, 0x33, 0x56, 0xb9, 0xb0}; + uint8_t bytesprops1[] = {0x40, 0x24, 0x1f, 0x61, 0x16, 0x55, 0x8f, 0x12, 0xb7, 0x25, + 0x25, 0x3e, 0x3c, 0x2d, 0xe7, 0xa0, 0xe5, 0xbb, 0xd8}; + uint8_t bytesprops2[] = {0x39, 0xea, 0x58, 0x2, 0x1d, 0xad, 0xa9, 0xc5, 0x51, 0x83, 0xe0, 0x39, 0xbf}; + uint8_t bytesprops3[] = {0xb9, 0x62, 0xcd, 0x67, 0x65, 0x21}; + uint8_t bytesprops4[] = {0xdd, 0xf, 0x44, 0x47, 0x51}; + uint8_t bytesprops5[] = {0x57, 0xed, 0x87, 0x13, 0xfc, 0xbe, 0x7, 0x90, 0xb3, 0xbb, 0x67, 0x8c, 0xaf, 0x57, + 0x24, 0xe2, 0xb5, 0xf0, 0x39, 0xce, 0xdd, 0x2, 0x1c, 0xd8, 0xd, 0x88, 0x81}; + uint8_t bytesprops6[] = {0x5e, 0xc, 0x14, 0x4, 0x22, 0x62, 0x29, 0x81, 0xef, 0x82, + 0xc8, 0xb1, 0xae, 0x88, 0xbb, 0x6a, 0x44, 0xb8, 0xe6, 0x27}; + uint8_t bytesprops7[] = {0x32, 0x74, 0x2e, 0x5c, 0x9e, 0x1e, 0x56}; + uint8_t bytesprops8[] = {0x73, 0x45, 0x47, 0x42, 0x41, 0xc6, 0x61, 0x5b, 0x13, 0xff, 0x2}; + uint8_t bytesprops9[] = {0xa9, 0x22, 0xd4, 0x81, 0x7, 0x4a, 0x6c, 0x2d, 0xd1, 0x98}; + uint8_t bytesprops10[] = {0x21, 0xa8, 0x6d, 0x2f, 0xd2, 0x90, 0x10, 0x2c, 0xe8, 0xd7, 0x47, 0x9c}; + uint8_t bytesprops11[] = {0x95, 0x1c, 0x25, 0x6b, 0x35, 0x8f, 0x1f, 0xb, 0xcb, 0x31}; + uint8_t bytesprops12[] = {0x57, 0xbf, 0x20, 0x35, 0x5d, 0x5f, 0x52, 0x45, 0xff, 0xf4, 0xe4, 0xe5}; + uint8_t bytesprops14[] = {0xc9, 0xac, 0x88, 0x91, 0x23, 0xce, 0x75, 0x62}; + uint8_t bytesprops13[] = {0xe9, 0x20}; + uint8_t bytesprops15[] = {0x74, 0x5c, 0x3e, 0xb8, 0x57, 0xc8, 0xf0, 0x39, 0x8f, 0x2e, 0x31, 0xe5, 0x25, 0x3a}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24653}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4164}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23401}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8933}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13114}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops13}, .v = {8, (char*)&bytesprops14}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops15}}}, + }; -// ConnectRequest {_username = Nothing, _password = Just "\DC2\145\228\152*\178X", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\143\&2Gc]\253N\249\243\153\145\225\185\215sp\SOHs\192\221\&7{", -// _willMsg = "\NUL\211NA\197", _willProps = [PropSubscriptionIdentifierAvailable 9,PropRequestResponseInformation -// 70,PropServerReference "\194x\EOT\249\241\183\&4\210t\184IU\240\224\174\213\223M",PropPayloadFormatIndicator -// 234,PropAuthenticationData -// "J\DC4M\227\211\160\165\201\ESC\159\169]|\244x.\214\DELc\199\147\154\ESC",PropSubscriptionIdentifier -// 7,PropSubscriptionIdentifier 31,PropReceiveMaximum 9626,PropAuthenticationMethod -// "o\155,\201\SI\192\179\ACK\219\131\214\148\246\CANv;R\239",PropRequestProblemInformation -// 195,PropWildcardSubscriptionAvailable 144,PropMaximumQoS 238,PropCorrelationData -// "<\ENQ\253\SYN\133*6\219\237a\SI\244\RS\\\188",PropServerKeepAlive 26333,PropServerKeepAlive 28853]}), _cleanSession -// = True, _keepAlive = 29972, _connID = "\ETB8\187\183q0\214H5\201\SI\199\183B\212u[\143\253\152\199W\EOT\206\149", -// _properties = [PropSubscriptionIdentifierAvailable 197,PropSessionExpiryInterval 6618,PropPayloadFormatIndicator -// 17,PropUserProperty "Xh\249\187$?^z\168p" "&\133\152G\NAK\206\181}'(n\NAK\136\173\238g,\NAK",PropResponseTopic -// "\155\&6\DEL/\176\244C\176k0\233",PropMessageExpiryInterval 7269,PropWillDelayInterval 21711,PropMaximumQoS -// 137,PropSharedSubscriptionAvailable 86,PropMaximumPacketSize 4793,PropSessionExpiryInterval -// 26648,PropSharedSubscriptionAvailable 205,PropRetainAvailable 231,PropCorrelationData -// "\224\177",PropSharedSubscriptionAvailable 66]} -TEST(Connect5QCTest, Encode93) { + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8501, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 25153 [("\132f\153\132\244w'\154\220S",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\249\167\241%",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\142\244",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\151NI\219\241\129\216N\187\248`\189\"G}\165\133)7R\135\154\ETX~\175",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("/;\227\164B+\151W!\206\238\128\136\GS\vz\163\244:G\172V",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("5\145\185{#B\152\236",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("<\131\162\143,2\130\130\159\151\150\CAN2\223\208\ESC\181\218\201\149\&6",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropContentType +// "5\251\237Ie\142\CANs",PropMessageExpiryInterval 23405,PropContentType +// "DI\171\251Z\ETB\216\185`N\246d\194+\f\164\245>h\177\b\217c\144",PropUserProperty +// "\211\162\150O\132h\138\&37N\205\STX\NAK\129\152\230\213\167\SOH\213\176\157:\140d\251" +// "\193n\241w\SO\223>\DLE\t\175WH?]\220{\SIJ\179\238\240`\199]\a\DLE\235\213\204",PropUserProperty +// "L\149\140\154xwdj~.\201\158\175ce\ENQ\173?OV2\212\189sB\US" "\r\251",PropTopicAlias +// 20702,PropSharedSubscriptionAvailable 44,PropServerKeepAlive 20616,PropMessageExpiryInterval +// 3019,PropSubscriptionIdentifier 2,PropAuthenticationData +// ":\ACK\184\168F8Z\204\227\229=\DC3\255Z\197\145\128\168\136\228\165\251u(\149\188",PropReasonString +// "\145\133\201\f\250\235\229\251C8\181\160\US\SUB\154\167\234\210\220T8",PropSubscriptionIdentifierAvailable +// 201,PropResponseInformation "\EOT5\174\EM\197\236\RS\239n\164",PropAuthenticationMethod +// "\162h7\140t|\202\FSw\DC1\SOHeh\169ONq\139\204\250\219\145\193\246BL",PropSharedSubscriptionAvailable +// 142,PropSharedSubscriptionAvailable 223,PropRequestProblemInformation 38,PropAuthenticationMethod +// "\DC3Bf\242\201#\200ldr*\215_\DLE\206\202",PropRetainAvailable 40,PropRetainAvailable 73,PropResponseTopic +// "\STX}\253\252\215Q\128\213z\160\EM\208T\164a\133\&0\b(\214\n+a\136oL5\143.",PropAuthenticationMethod +// "\210\212\183DL\b4!]y_\234\232\237\DC3\226C\175",PropServerKeepAlive 31013,PropMessageExpiryInterval +// 5923,PropMaximumPacketSize 6507,PropSessionExpiryInterval 27876,PropSessionExpiryInterval 11429] +TEST(Subscribe5QCTest, Encode87) { uint8_t pkt[] = { - 0x10, 0x90, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x36, 0x75, 0x14, 0x5b, 0x29, 0xc5, 0x11, 0x0, 0x0, - 0x19, 0xda, 0x1, 0x11, 0x26, 0x0, 0xa, 0x58, 0x68, 0xf9, 0xbb, 0x24, 0x3f, 0x5e, 0x7a, 0xa8, 0x70, 0x0, 0x12, - 0x26, 0x85, 0x98, 0x47, 0x15, 0xce, 0xb5, 0x7d, 0x27, 0x28, 0x6e, 0x15, 0x88, 0xad, 0xee, 0x67, 0x2c, 0x15, 0x8, - 0x0, 0xb, 0x9b, 0x36, 0x7f, 0x2f, 0xb0, 0xf4, 0x43, 0xb0, 0x6b, 0x30, 0xe9, 0x2, 0x0, 0x0, 0x1c, 0x65, 0x18, - 0x0, 0x0, 0x54, 0xcf, 0x24, 0x89, 0x2a, 0x56, 0x27, 0x0, 0x0, 0x12, 0xb9, 0x11, 0x0, 0x0, 0x68, 0x18, 0x2a, - 0xcd, 0x25, 0xe7, 0x9, 0x0, 0x2, 0xe0, 0xb1, 0x2a, 0x42, 0x0, 0x19, 0x17, 0x38, 0xbb, 0xb7, 0x71, 0x30, 0xd6, - 0x48, 0x35, 0xc9, 0xf, 0xc7, 0xb7, 0x42, 0xd4, 0x75, 0x5b, 0x8f, 0xfd, 0x98, 0xc7, 0x57, 0x4, 0xce, 0x95, 0x6f, - 0x29, 0x9, 0x19, 0x46, 0x1c, 0x0, 0x12, 0xc2, 0x78, 0x4, 0xf9, 0xf1, 0xb7, 0x34, 0xd2, 0x74, 0xb8, 0x49, 0x55, - 0xf0, 0xe0, 0xae, 0xd5, 0xdf, 0x4d, 0x1, 0xea, 0x16, 0x0, 0x17, 0x4a, 0x14, 0x4d, 0xe3, 0xd3, 0xa0, 0xa5, 0xc9, - 0x1b, 0x9f, 0xa9, 0x5d, 0x7c, 0xf4, 0x78, 0x2e, 0xd6, 0x7f, 0x63, 0xc7, 0x93, 0x9a, 0x1b, 0xb, 0x7, 0xb, 0x1f, - 0x21, 0x25, 0x9a, 0x15, 0x0, 0x12, 0x6f, 0x9b, 0x2c, 0xc9, 0xf, 0xc0, 0xb3, 0x6, 0xdb, 0x83, 0xd6, 0x94, 0xf6, - 0x18, 0x76, 0x3b, 0x52, 0xef, 0x17, 0xc3, 0x28, 0x90, 0x24, 0xee, 0x9, 0x0, 0xf, 0x3c, 0x5, 0xfd, 0x16, 0x85, - 0x2a, 0x36, 0xdb, 0xed, 0x61, 0xf, 0xf4, 0x1e, 0x5c, 0xbc, 0x13, 0x66, 0xdd, 0x13, 0x70, 0xb5, 0x0, 0x16, 0x8f, - 0x32, 0x47, 0x63, 0x5d, 0xfd, 0x4e, 0xf9, 0xf3, 0x99, 0x91, 0xe1, 0xb9, 0xd7, 0x73, 0x70, 0x1, 0x73, 0xc0, 0xdd, - 0x37, 0x7b, 0x0, 0x5, 0x0, 0xd3, 0x4e, 0x41, 0xc5}; - - uint8_t buf[285] = {0}; - - uint8_t bytesprops1[] = {0x26, 0x85, 0x98, 0x47, 0x15, 0xce, 0xb5, 0x7d, 0x27, - 0x28, 0x6e, 0x15, 0x88, 0xad, 0xee, 0x67, 0x2c, 0x15}; - uint8_t bytesprops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x2, 0x0, + 0x0, 0x17, 0x23, 0x27, 0x0, 0x0, 0x19, 0x6b, 0x11, 0x0, 0x0, 0x6c, 0xe4, 0x11, 0x0, 0x0, 0x2c, 0xa5, 0x0, + 0xa, 0x84, 0x66, 0x99, 0x84, 0xf4, 0x77, 0x27, 0x9a, 0xdc, 0x53, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0xf9, 0xa7, + 0xf1, 0x25, 0x2, 0x0, 0x2, 0x8e, 0xf4, 0x1, 0x0, 0x19, 0x97, 0x4e, 0x49, 0xdb, 0xf1, 0x81, 0xd8, 0x4e, 0xbb, + 0xf8, 0x60, 0xbd, 0x22, 0x47, 0x7d, 0xa5, 0x85, 0x29, 0x37, 0x52, 0x87, 0x9a, 0x3, 0x7e, 0xaf, 0x0, 0x0, 0x16, + 0x2f, 0x3b, 0xe3, 0xa4, 0x42, 0x2b, 0x97, 0x57, 0x21, 0xce, 0xee, 0x80, 0x88, 0x1d, 0xb, 0x7a, 0xa3, 0xf4, 0x3a, + 0x47, 0xac, 0x56, 0x0, 0x0, 0x8, 0x35, 0x91, 0xb9, 0x7b, 0x23, 0x42, 0x98, 0xec, 0x0, 0x0, 0x15, 0x3c, 0x83, + 0xa2, 0x8f, 0x2c, 0x32, 0x82, 0x82, 0x9f, 0x97, 0x96, 0x18, 0x32, 0xdf, 0xd0, 0x1b, 0xb5, 0xda, 0xc9, 0x95, 0x36, + 0x0}; + + uint8_t buf[486] = {0}; + + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x84, 0x66, 0x99, 0x84, 0xf4, 0x77, 0x27, 0x9a, 0xdc, 0x53}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf9, 0xa7, 0xf1, 0x25}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8e, 0xf4}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x97, 0x4e, 0x49, 0xdb, 0xf1, 0x81, 0xd8, 0x4e, 0xbb, 0xf8, 0x60, 0xbd, 0x22, + 0x47, 0x7d, 0xa5, 0x85, 0x29, 0x37, 0x52, 0x87, 0x9a, 0x3, 0x7e, 0xaf}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x2f, 0x3b, 0xe3, 0xa4, 0x42, 0x2b, 0x97, 0x57, 0x21, 0xce, 0xee, + 0x80, 0x88, 0x1d, 0xb, 0x7a, 0xa3, 0xf4, 0x3a, 0x47, 0xac, 0x56}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x35, 0x91, 0xb9, 0x7b, 0x23, 0x42, 0x98, 0xec}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x3c, 0x83, 0xa2, 0x8f, 0x2c, 0x32, 0x82, 0x82, 0x9f, 0x97, 0x96, + 0x18, 0x32, 0xdf, 0xd0, 0x1b, 0xb5, 0xda, 0xc9, 0x95, 0x36}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x35, 0xfb, 0xed, 0x49, 0x65, 0x8e, 0x18, 0x73}; + uint8_t bytesprops1[] = {0x44, 0x49, 0xab, 0xfb, 0x5a, 0x17, 0xd8, 0xb9, 0x60, 0x4e, 0xf6, 0x64, + 0xc2, 0x2b, 0xc, 0xa4, 0xf5, 0x3e, 0x68, 0xb1, 0x8, 0xd9, 0x63, 0x90}; + uint8_t bytesprops3[] = {0xc1, 0x6e, 0xf1, 0x77, 0xe, 0xdf, 0x3e, 0x10, 0x9, 0xaf, 0x57, 0x48, 0x3f, 0x5d, 0xdc, + 0x7b, 0xf, 0x4a, 0xb3, 0xee, 0xf0, 0x60, 0xc7, 0x5d, 0x7, 0x10, 0xeb, 0xd5, 0xcc}; + uint8_t bytesprops2[] = {0xd3, 0xa2, 0x96, 0x4f, 0x84, 0x68, 0x8a, 0x33, 0x37, 0x4e, 0xcd, 0x2, 0x15, + 0x81, 0x98, 0xe6, 0xd5, 0xa7, 0x1, 0xd5, 0xb0, 0x9d, 0x3a, 0x8c, 0x64, 0xfb}; + uint8_t bytesprops5[] = {0xd, 0xfb}; + uint8_t bytesprops4[] = {0x4c, 0x95, 0x8c, 0x9a, 0x78, 0x77, 0x64, 0x6a, 0x7e, 0x2e, 0xc9, 0x9e, 0xaf, + 0x63, 0x65, 0x5, 0xad, 0x3f, 0x4f, 0x56, 0x32, 0xd4, 0xbd, 0x73, 0x42, 0x1f}; + uint8_t bytesprops6[] = {0x3a, 0x6, 0xb8, 0xa8, 0x46, 0x38, 0x5a, 0xcc, 0xe3, 0xe5, 0x3d, 0x13, 0xff, + 0x5a, 0xc5, 0x91, 0x80, 0xa8, 0x88, 0xe4, 0xa5, 0xfb, 0x75, 0x28, 0x95, 0xbc}; + uint8_t bytesprops7[] = {0x91, 0x85, 0xc9, 0xc, 0xfa, 0xeb, 0xe5, 0xfb, 0x43, 0x38, 0xb5, + 0xa0, 0x1f, 0x1a, 0x9a, 0xa7, 0xea, 0xd2, 0xdc, 0x54, 0x38}; + uint8_t bytesprops8[] = {0x4, 0x35, 0xae, 0x19, 0xc5, 0xec, 0x1e, 0xef, 0x6e, 0xa4}; + uint8_t bytesprops9[] = {0xa2, 0x68, 0x37, 0x8c, 0x74, 0x7c, 0xca, 0x1c, 0x77, 0x11, 0x1, 0x65, 0x68, + 0xa9, 0x4f, 0x4e, 0x71, 0x8b, 0xcc, 0xfa, 0xdb, 0x91, 0xc1, 0xf6, 0x42, 0x4c}; + uint8_t bytesprops10[] = {0x13, 0x42, 0x66, 0xf2, 0xc9, 0x23, 0xc8, 0x6c, + 0x64, 0x72, 0x2a, 0xd7, 0x5f, 0x10, 0xce, 0xca}; + uint8_t bytesprops11[] = {0x2, 0x7d, 0xfd, 0xfc, 0xd7, 0x51, 0x80, 0xd5, 0x7a, 0xa0, 0x19, 0xd0, 0x54, 0xa4, 0x61, + 0x85, 0x30, 0x8, 0x28, 0xd6, 0xa, 0x2b, 0x61, 0x88, 0x6f, 0x4c, 0x35, 0x8f, 0x2e}; + uint8_t bytesprops12[] = {0xd2, 0xd4, 0xb7, 0x44, 0x4c, 0x8, 0x34, 0x21, 0x5d, + 0x79, 0x5f, 0xea, 0xe8, 0xed, 0x13, 0xe2, 0x43, 0xaf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6618}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {18, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7269}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21711}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4793}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26648}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23405}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops2}, .v = {29, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20702}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20616}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3019}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31013}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5923}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6507}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27876}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11429}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc2, 0x78, 0x4, 0xf9, 0xf1, 0xb7, 0x34, 0xd2, 0x74, - 0xb8, 0x49, 0x55, 0xf0, 0xe0, 0xae, 0xd5, 0xdf, 0x4d}; - uint8_t byteswillprops1[] = {0x4a, 0x14, 0x4d, 0xe3, 0xd3, 0xa0, 0xa5, 0xc9, 0x1b, 0x9f, 0xa9, 0x5d, - 0x7c, 0xf4, 0x78, 0x2e, 0xd6, 0x7f, 0x63, 0xc7, 0x93, 0x9a, 0x1b}; - uint8_t byteswillprops2[] = {0x6f, 0x9b, 0x2c, 0xc9, 0xf, 0xc0, 0xb3, 0x6, 0xdb, - 0x83, 0xd6, 0x94, 0xf6, 0x18, 0x76, 0x3b, 0x52, 0xef}; - uint8_t byteswillprops3[] = {0x3c, 0x5, 0xfd, 0x16, 0x85, 0x2a, 0x36, 0xdb, 0xed, 0x61, 0xf, 0xf4, 0x1e, 0x5c, 0xbc}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25153, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 10517 [("\252",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1})] [PropMessageExpiryInterval 18639,PropMessageExpiryInterval 28021,PropResponseTopic +// "\200\189Z\216w\f\161\181C\217\187\EM",PropRequestProblemInformation 131,PropRequestResponseInformation +// 48,PropServerKeepAlive 14539,PropRetainAvailable 17,PropContentType "*\143\144Tg\215U",PropReceiveMaximum +// 5051,PropAuthenticationData "",PropSubscriptionIdentifierAvailable 70,PropRequestResponseInformation +// 31,PropTopicAlias 29124,PropRequestResponseInformation 52,PropServerKeepAlive +// 13965,PropSubscriptionIdentifierAvailable 44,PropTopicAlias 6091,PropSessionExpiryInterval 11780,PropUserProperty +// "\189e\133\205\194\218\162\170p)!\158\224\SIm\207\&5\128e\154" "e\252\170gv",PropMaximumPacketSize +// 3381,PropAssignedClientIdentifier +// "\t\210c\133\STX(\225\250\DC2a\137\192\180\DLE\242\154\EOTH\238T{\v^A\207",PropMessageExpiryInterval 7236] +TEST(Subscribe5QCTest, Encode88) { + uint8_t pkt[] = {0x82, 0x94, 0x1, 0x29, 0x15, 0x8c, 0x1, 0x2, 0x0, 0x0, 0x48, 0xcf, 0x2, 0x0, 0x0, 0x6d, 0x75, + 0x8, 0x0, 0xc, 0xc8, 0xbd, 0x5a, 0xd8, 0x77, 0xc, 0xa1, 0xb5, 0x43, 0xd9, 0xbb, 0x19, 0x17, 0x83, + 0x19, 0x30, 0x13, 0x38, 0xcb, 0x25, 0x11, 0x3, 0x0, 0x7, 0x2a, 0x8f, 0x90, 0x54, 0x67, 0xd7, 0x55, + 0x21, 0x13, 0xbb, 0x16, 0x0, 0x0, 0x29, 0x46, 0x19, 0x1f, 0x23, 0x71, 0xc4, 0x19, 0x34, 0x13, 0x36, + 0x8d, 0x29, 0x2c, 0x23, 0x17, 0xcb, 0x11, 0x0, 0x0, 0x2e, 0x4, 0x26, 0x0, 0x14, 0xbd, 0x65, 0x85, + 0xcd, 0xc2, 0xda, 0xa2, 0xaa, 0x70, 0x29, 0x21, 0x9e, 0xe0, 0xf, 0x6d, 0xcf, 0x35, 0x80, 0x65, 0x9a, + 0x0, 0x5, 0x65, 0xfc, 0xaa, 0x67, 0x76, 0x27, 0x0, 0x0, 0xd, 0x35, 0x12, 0x0, 0x19, 0x9, 0xd2, + 0x63, 0x85, 0x2, 0x28, 0xe1, 0xfa, 0x12, 0x61, 0x89, 0xc0, 0xb4, 0x10, 0xf2, 0x9a, 0x4, 0x48, 0xee, + 0x54, 0x7b, 0xb, 0x5e, 0x41, 0xcf, 0x2, 0x0, 0x0, 0x1c, 0x44, 0x0, 0x1, 0xfc, 0x1}; + + uint8_t buf[161] = {0}; + + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xfc}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xc8, 0xbd, 0x5a, 0xd8, 0x77, 0xc, 0xa1, 0xb5, 0x43, 0xd9, 0xbb, 0x19}; + uint8_t bytesprops1[] = {0x2a, 0x8f, 0x90, 0x54, 0x67, 0xd7, 0x55}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops4[] = {0x65, 0xfc, 0xaa, 0x67, 0x76}; + uint8_t bytesprops3[] = {0xbd, 0x65, 0x85, 0xcd, 0xc2, 0xda, 0xa2, 0xaa, 0x70, 0x29, + 0x21, 0x9e, 0xe0, 0xf, 0x6d, 0xcf, 0x35, 0x80, 0x65, 0x9a}; + uint8_t bytesprops5[] = {0x9, 0xd2, 0x63, 0x85, 0x2, 0x28, 0xe1, 0xfa, 0x12, 0x61, 0x89, 0xc0, 0xb4, + 0x10, 0xf2, 0x9a, 0x4, 0x48, 0xee, 0x54, 0x7b, 0xb, 0x5e, 0x41, 0xcf}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9626}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26333}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28853}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18639}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28021}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14539}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5051}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29124}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13965}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6091}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11780}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3381}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7236}}, }; - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8f, 0x32, 0x47, 0x63, 0x5d, 0xfd, 0x4e, 0xf9, 0xf3, 0x99, 0x91, - 0xe1, 0xb9, 0xd7, 0x73, 0x70, 0x1, 0x73, 0xc0, 0xdd, 0x37, 0x7b}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x0, 0xd3, 0x4e, 0x41, 0xc5}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 29972; - uint8_t client_id_bytes[] = {0x17, 0x38, 0xbb, 0xb7, 0x71, 0x30, 0xd6, 0x48, 0x35, 0xc9, 0xf, 0xc7, 0xb7, - 0x42, 0xd4, 0x75, 0x5b, 0x8f, 0xfd, 0x98, 0xc7, 0x57, 0x4, 0xce, 0x95}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x12, 0x91, 0xe4, 0x98, 0x2a, 0xb2, 0x58}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10517, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just ",dA\164\202\NUL\161\212\169\183\&0", _password = Just "\CAN\SUB\238\&0", _lastWill -// = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\GS\187\&5\157[*n\166\233S\168\&8\155\DC4\177$\168q\204\218\r\rJ", _willMsg = -// "\236[s\ESCz\217dW\STX\222\151\&0\SYNB\149\b\189fKjA", _willProps = [PropSubscriptionIdentifier 18,PropReasonString -// "\208##+\v\198l\138\152l\STX\229\221\249r\240\174g\152^\FSW:)\219\&9\155\181",PropResponseInformation -// "\161d4\184\130\ETB\SUB\238\253\FS\141m\204a\bh\171I\EM\241\&8",PropWildcardSubscriptionAvailable -// 113,PropServerReference "A$\254|R\222\136\251\&6\247\223\132\158\248\213\161",PropMaximumPacketSize -// 18104,PropResponseInformation "\247\167-\SYN\170\136T1\FS\183x",PropSubscriptionIdentifierAvailable -// 245,PropSessionExpiryInterval 11538,PropMaximumPacketSize 16358,PropWildcardSubscriptionAvailable -// 192,PropReceiveMaximum 19034,PropResponseInformation "\164\r -// \201h\t\211\&0_\226'\DC2;;1\211\SOH\NUL",PropAuthenticationData "8RJ#\\Ko*J&\NUL\NUL nKj\188",PropReceiveMaximum -// 12561,PropContentType "\248\230\230=\129v \163z\247\167\222\253\245\187\255j\ETX\183",PropContentType -// "\192j%\162\231\223\136\189\CAN!N\171\"\128#\139\153\b\227\&9f\157\FS\244\242e\134\DLE",PropRequestProblemInformation -// 94,PropUserProperty "\EOTN\199>J\223G\201" -// "\191+P\245\199\181P\215\236\238\&2X\197\ACK\166)\173D,J\235",PropWildcardSubscriptionAvailable 98,PropTopicAlias -// 23734,PropMaximumPacketSize 10399,PropResponseInformation -// "m\DC2o{\ENQ\176D\241\173F\230\DEL\203\235\139\128\rc\SI\161PWV\195\t\150\236",PropUserProperty -// "\141g1\198\ESC\174D\155\153\254\128\SYN\GS" "\DC3\239%\204\134\236c\180\247V\206\SO\200\208\SO",PropServerReference -// "\230yf\EMo\140\234\"\139"]}), _cleanSession = True, _keepAlive = 488, _connID = "/\152\131mx1\208\&5", _properties = -// [PropTopicAliasMaximum 16695,PropTopicAlias 17555,PropServerReference "",PropWillDelayInterval -// 2609,PropMessageExpiryInterval 14470]} -TEST(Connect5QCTest, Encode94) { - uint8_t pkt[] = { - 0x10, 0xb9, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x1, 0xe8, 0x13, 0x22, 0x41, 0x37, 0x23, 0x44, - 0x93, 0x1c, 0x0, 0x0, 0x18, 0x0, 0x0, 0xa, 0x31, 0x2, 0x0, 0x0, 0x38, 0x86, 0x0, 0x8, 0x2f, 0x98, 0x83, - 0x6d, 0x78, 0x31, 0xd0, 0x35, 0xcc, 0x2, 0xb, 0x12, 0x1f, 0x0, 0x1c, 0xd0, 0x23, 0x23, 0x2b, 0xb, 0xc6, 0x6c, - 0x8a, 0x98, 0x6c, 0x2, 0xe5, 0xdd, 0xf9, 0x72, 0xf0, 0xae, 0x67, 0x98, 0x5e, 0x1c, 0x57, 0x3a, 0x29, 0xdb, 0x39, - 0x9b, 0xb5, 0x1a, 0x0, 0x15, 0xa1, 0x64, 0x34, 0xb8, 0x82, 0x17, 0x1a, 0xee, 0xfd, 0x1c, 0x8d,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50, 0xd7, 0xec, 0xee, 0x32, 0x58, 0xc5, 0x6, - 0xa6, 0x29, 0xad, 0x44, 0x2c, 0x4a, 0xeb, 0x28, 0x62, 0x23, 0x5c, 0xb6, 0x27, 0x0, 0x0, 0x28, 0x9f, 0x1a, 0x0, - 0x1b, 0x6d, 0x12, 0x6f, 0x7b, 0x5, 0xb0, 0x44, 0xf1, 0xad, 0x46, 0xe6, 0x7f, 0xcb, 0xeb, 0x8b, 0x80, 0xd, 0x63, - 0xf, 0xa1, 0x50, 0x57, 0x56, 0xc3, 0x9, 0x96, 0xec, 0x26, 0x0, 0xd, 0x8d, 0x67, 0x31, 0xc6, 0x1b, 0xae, 0x44, - 0x9b, 0x99, 0xfe, 0x80, 0x16, 0x1d, 0x0, 0xf, 0x13, 0xef, 0x25, 0xcc, 0x86, 0xec, 0x63, 0xb4, 0xf7, 0x56, 0xce, - 0xe, 0xc8, 0xd0, 0xe, 0x1c, 0x0, 0x9, 0xe6, 0x79, 0x66, 0x19, 0x6f, 0x8c, 0xea, 0x22, 0x8b, 0x0, 0x17, 0x1d, - 0xbb, 0x35, 0x9d, 0x5b, 0x2a, 0x6e, 0xa6, 0xe9, 0x53, 0xa8, 0x38, 0x9b, 0x14, 0xb1, 0x24, 0xa8, 0x71, 0xcc, 0xda, - 0xd, 0xd, 0x4a, 0x0, 0x15, 0xec, 0x5b, 0x73, 0x1b, 0x7a, 0xd9, 0x64, 0x57, 0x2, 0xde, 0x97, 0x30, 0x16, 0x42, - 0x95, 0x8, 0xbd, 0x66, 0x4b, 0x6a, 0x41, 0x0, 0xb, 0x2c, 0x64, 0x41, 0xa4, 0xca, 0x0, 0xa1, 0xd4, 0xa9, 0xb7, - 0x30, 0x0, 0x4, 0x18, 0x1a, 0xee, 0x30}; +// SubscribeRequest 24618 [("\162\&7a\196\249\&0\135*\143\198O\209\148nI",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationMethod "s\"",PropContentType +// "\151\161:\SYN\182l\196#\210\240\136\v\140yS4\DC4\193\204\179\177\174c",PropMaximumQoS 231,PropPayloadFormatIndicator +// 171,PropAuthenticationMethod +// "\148\150\243\143\156\130r\168\FS\199\183\148\SUB\176\233E_\194\249\165\&6\191\246!\210\a{\NUL[\f",PropTopicAlias +// 3944] +TEST(Subscribe5QCTest, Encode89) { + uint8_t pkt[] = {0x82, 0x5c, 0x60, 0x2a, 0x47, 0x15, 0x0, 0x2, 0x73, 0x22, 0x3, 0x0, 0x17, 0x97, 0xa1, 0x3a, + 0x16, 0xb6, 0x6c, 0xc4, 0x23, 0xd2, 0xf0, 0x88, 0xb, 0x8c, 0x79, 0x53, 0x34, 0x14, 0xc1, 0xcc, + 0xb3, 0xb1, 0xae, 0x63, 0x24, 0xe7, 0x1, 0xab, 0x15, 0x0, 0x1e, 0x94, 0x96, 0xf3, 0x8f, 0x9c, + 0x82, 0x72, 0xa8, 0x1c, 0xc7, 0xb7, 0x94, 0x1a, 0xb0, 0xe9, 0x45, 0x5f, 0xc2, 0xf9, 0xa5, 0x36, + 0xbf, 0xf6, 0x21, 0xd2, 0x7, 0x7b, 0x0, 0x5b, 0xc, 0x23, 0xf, 0x68, 0x0, 0xf, 0xa2, 0x37, + 0x61, 0xc4, 0xf9, 0x30, 0x87, 0x2a, 0x8f, 0xc6, 0x4f, 0xd1, 0x94, 0x6e, 0x49, 0x0}; - uint8_t buf[454] = {0}; + uint8_t buf[104] = {0}; - uint8_t bytesprops0[] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xa2, 0x37, 0x61, 0xc4, 0xf9, 0x30, 0x87, 0x2a, + 0x8f, 0xc6, 0x4f, 0xd1, 0x94, 0x6e, 0x49}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x73, 0x22}; + uint8_t bytesprops1[] = {0x97, 0xa1, 0x3a, 0x16, 0xb6, 0x6c, 0xc4, 0x23, 0xd2, 0xf0, 0x88, 0xb, + 0x8c, 0x79, 0x53, 0x34, 0x14, 0xc1, 0xcc, 0xb3, 0xb1, 0xae, 0x63}; + uint8_t bytesprops2[] = {0x94, 0x96, 0xf3, 0x8f, 0x9c, 0x82, 0x72, 0xa8, 0x1c, 0xc7, 0xb7, 0x94, 0x1a, 0xb0, 0xe9, + 0x45, 0x5f, 0xc2, 0xf9, 0xa5, 0x36, 0xbf, 0xf6, 0x21, 0xd2, 0x7, 0x7b, 0x0, 0x5b, 0xc}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16695}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17555}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2609}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14470}}, - }; - - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd0, 0x23, 0x23, 0x2b, 0xb, 0xc6, 0x6c, 0x8a, 0x98, 0x6c, 0x2, 0xe5, 0xdd, 0xf9, - 0x72, 0xf0, 0xae, 0x67, 0x98, 0x5e, 0x1c, 0x57, 0x3a, 0x29, 0xdb, 0x39, 0x9b, 0xb5}; - uint8_t byteswillprops1[] = {0xa1, 0x64, 0x34, 0xb8, 0x82, 0x17, 0x1a, 0xee, 0xfd, 0x1c, 0x8d, - 0x6d, 0xcc, 0x61, 0x8, 0x68, 0xab, 0x49, 0x19, 0xf1, 0x38}; - uint8_t byteswillprops2[] = {0x41, 0x24, 0xfe, 0x7c, 0x52, 0xde, 0x88, 0xfb, - 0x36, 0xf7, 0xdf, 0x84, 0x9e, 0xf8, 0xd5, 0xa1}; - uint8_t byteswillprops3[] = {0xf7, 0xa7, 0x2d, 0x16, 0xaa, 0x88, 0x54, 0x31, 0x1c, 0xb7, 0x78}; - uint8_t byteswillprops4[] = {0xa4, 0xd, 0x20, 0xc9, 0x68, 0x9, 0xd3, 0x30, 0x5f, - 0xe2, 0x27, 0x12, 0x3b, 0x3b, 0x31, 0xd3, 0x1, 0x0}; - uint8_t byteswillprops5[] = {0x38, 0x52, 0x4a, 0x23, 0x5c, 0x4b, 0x6f, 0x2a, 0x4a, - 0x26, 0x0, 0x0, 0x20, 0x6e, 0x4b, 0x6a, 0xbc}; - uint8_t byteswillprops6[] = {0xf8, 0xe6, 0xe6, 0x3d, 0x81, 0x76, 0x20, 0xa3, 0x7a, 0xf7, - 0xa7, 0xde, 0xfd, 0xf5, 0xbb, 0xff, 0x6a, 0x3, 0xb7}; - uint8_t byteswillprops7[] = {0xc0, 0x6a, 0x25, 0xa2, 0xe7, 0xdf, 0x88, 0xbd, 0x18, 0x21, 0x4e, 0xab, 0x22, 0x80, - 0x23, 0x8b, 0x99, 0x8, 0xe3, 0x39, 0x66, 0x9d, 0x1c, 0xf4, 0xf2, 0x65, 0x86, 0x10}; - uint8_t byteswillprops9[] = {0xbf, 0x2b, 0x50, 0xf5, 0xc7, 0xb5, 0x50, 0xd7, 0xec, 0xee, 0x32, - 0x58, 0xc5, 0x6, 0xa6, 0x29, 0xad, 0x44, 0x2c, 0x4a, 0xeb}; - uint8_t byteswillprops8[] = {0x4, 0x4e, 0xc7, 0x3e, 0x4a, 0xdf, 0x47, 0xc9}; - uint8_t byteswillprops10[] = {0x6d, 0x12, 0x6f, 0x7b, 0x5, 0xb0, 0x44, 0xf1, 0xad, 0x46, 0xe6, 0x7f, 0xcb, 0xeb, - 0x8b, 0x80, 0xd, 0x63, 0xf, 0xa1, 0x50, 0x57, 0x56, 0xc3, 0x9, 0x96, 0xec}; - uint8_t byteswillprops12[] = {0x13, 0xef, 0x25, 0xcc, 0x86, 0xec, 0x63, 0xb4, 0xf7, 0x56, 0xce, 0xe, 0xc8, 0xd0, 0xe}; - uint8_t byteswillprops11[] = {0x8d, 0x67, 0x31, 0xc6, 0x1b, 0xae, 0x44, 0x9b, 0x99, 0xfe, 0x80, 0x16, 0x1d}; - uint8_t byteswillprops13[] = {0xe6, 0x79, 0x66, 0x19, 0x6f, 0x8c, 0xea, 0x22, 0x8b}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18104}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11538}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16358}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19034}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12561}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {8, (char*)&byteswillprops8}, .v = {21, (char*)&byteswillprops9}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23734}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10399}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {13, (char*)&byteswillprops11}, .v = {15, (char*)&byteswillprops12}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops13}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3944}}, }; - lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1d, 0xbb, 0x35, 0x9d, 0x5b, 0x2a, 0x6e, 0xa6, 0xe9, 0x53, 0xa8, 0x38, - 0x9b, 0x14, 0xb1, 0x24, 0xa8, 0x71, 0xcc, 0xda, 0xd, 0xd, 0x4a}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xec, 0x5b, 0x73, 0x1b, 0x7a, 0xd9, 0x64, 0x57, 0x2, 0xde, 0x97, - 0x30, 0x16, 0x42, 0x95, 0x8, 0xbd, 0x66, 0x4b, 0x6a, 0x41}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 488; - uint8_t client_id_bytes[] = {0x2f, 0x98, 0x83, 0x6d, 0x78, 0x31, 0xd0, 0x35}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x2c, 0x64, 0x41, 0xa4, 0xca, 0x0, 0xa1, 0xd4, 0xa9, 0xb7, 0x30}; - lwmqtt_string_t username = {11, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x18, 0x1a, 0xee, 0x30}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24618, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "ox\192\209\133\220~\DC29B\182\239=\196Sa[R\ETB\NUL\US\248E", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\214ht\202Q:u\DC3\190\SYN\SYN\246\225\130\232X\196k%\RSV*\144\154\215\184\227", _willMsg = "t -// \164\CAN)\191\132\223\226\201\230\149\253N\189\218\215\&4\182Gy\247y\201", _willProps = [PropTopicAlias -// 18598,PropUserProperty "5" "i\194)\SI\220OI\r\208\155Z\192]ExD\230\240\167\&4",PropServerReference -// "\135\a\r\161\&18\230(u4cB5?.0\144\198\130g\184",PropReasonString "\129\206\194F\CANuN -// \216u\223/I\173\209\244\247\&1T\DEL\135<\187\FS\FSI\157\223\129\184",PropServerKeepAlive 30447]}), _cleanSession = -// True, _keepAlive = 24570, _connID = "K\"%j\DLE\STXu~\ESC\236\178\204S\151(?\245\214w;\r\255\&5!", _properties = -// [PropResponseTopic "\DC3P\229\204EU\190O\n\164\131\&7\188%",PropReceiveMaximum 26323,PropAuthenticationData -// "\199\251\129\STX\236\199\193\159\184yd\DC2\233\237\204\241\221\208l]\135\"\237\229uk\236\183\137\213"]} -TEST(Connect5QCTest, Encode95) { +// SubscribeRequest 32265 [("\188Z\ESCD\172\&2\GSO\235_\175N*$\243\136\224 =\137\169\155\DEL\227\&1",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\203\232q4\EM\v\220\158X\173l\SUB\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable 103,PropReasonString +// "\189\221b\217\174Y\212\151\168\b\173E$S\163\DELw7\175Tw\223\aF",PropWillDelayInterval +// 13033,PropMessageExpiryInterval 25541,PropCorrelationData +// "N\221\138\208\176\nu\157\143\130N_\SYNn\145\148\150\171\"",PropWillDelayInterval 28428,PropMessageExpiryInterval +// 21622,PropRequestProblemInformation 33,PropReceiveMaximum 16827,PropMessageExpiryInterval 8407,PropReasonString +// "\224\&4'7M\r*LN\136\254\237\222\180Jc\249h",PropTopicAlias 11873,PropReceiveMaximum +// 15245,PropRequestResponseInformation 108,PropAuthenticationMethod "u{!\146\234\n~\145>\253",PropServerKeepAlive +// 14260,PropRequestResponseInformation 184,PropMessageExpiryInterval 13662,PropRequestProblemInformation +// 209,PropContentType "|\181\241\162\DC3\166\218\192 \137\130\204pR>\192\&0\152",PropSharedSubscriptionAvailable 51] +TEST(Subscribe5QCTest, Encode90) { uint8_t pkt[] = { - 0x10, 0xeb, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0x5f, 0xfa, 0x35, 0x8, 0x0, 0xe, 0x13, 0x50, - 0xe5, 0xcc, 0x45, 0x55, 0xbe, 0x4f, 0xa, 0xa4, 0x83, 0x37, 0xbc, 0x25, 0x21, 0x66, 0xd3, 0x16, 0x0, 0x1e, 0xc7, - 0xfb, 0x81, 0x2, 0xec,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- 0xbd, 0xda, 0xd7, 0x34, 0xb6, 0x47, 0x79, 0xf7, 0x79, 0xc9}; - - uint8_t buf[248] = {0}; - - uint8_t bytesprops0[] = {0x13, 0x50, 0xe5, 0xcc, 0x45, 0x55, 0xbe, 0x4f, 0xa, 0xa4, 0x83, 0x37, 0xbc, 0x25}; - uint8_t bytesprops1[] = {0xc7, 0xfb, 0x81, 0x2, 0xec, 0xc7, 0xc1, 0x9f, 0xb8, 0x79, 0x64, 0x12, 0xe9, 0xed, 0xcc, - 0xf1, 0xdd, 0xd0, 0x6c, 0x5d, 0x87, 0x22, 0xed, 0xe5, 0x75, 0x6b, 0xec, 0xb7, 0x89, 0xd5}; + 0x82, 0xce, 0x1, 0x7e, 0x9, 0x9e, 0x1, 0x2a, 0x67, 0x1f, 0x0, 0x18, 0xbd, 0xdd, 0x62, 0xd9, 0xae, 0x59, 0xd4, + 0x97, 0xa8, 0x8, 0xad, 0x45, 0x24, 0x53, 0xa3, 0x7f, 0x77, 0x37, 0xaf, 0x54, 0x77, 0xdf, 0x7, 0x46, 0x18, 0x0, + 0x0, 0x32, 0xe9, 0x2, 0x0, 0x0, 0x63, 0xc5, 0x9, 0x0, 0x13, 0x4e, 0xdd, 0x8a, 0xd0, 0xb0, 0xa, 0x75, 0x9d, + 0x8f, 0x82, 0x4e, 0x5f, 0x16, 0x6e, 0x91, 0x94, 0x96, 0xab, 0x22, 0x18, 0x0, 0x0, 0x6f, 0xc, 0x2, 0x0, 0x0, + 0x54, 0x76, 0x17, 0x21, 0x21, 0x41, 0xbb, 0x2, 0x0, 0x0, 0x20, 0xd7, 0x1f, 0x0, 0x12, 0xe0, 0x34, 0x27, 0x37, + 0x4d, 0xd, 0x2a, 0x4c, 0x4e, 0x88, 0xfe, 0xed, 0xde, 0xb4, 0x4a, 0x63, 0xf9, 0x68, 0x23, 0x2e, 0x61, 0x21, 0x3b, + 0x8d, 0x19, 0x6c, 0x15, 0x0, 0xa, 0x75, 0x7b, 0x21, 0x92, 0xea, 0xa, 0x7e, 0x91, 0x3e, 0xfd, 0x13, 0x37, 0xb4, + 0x19, 0xb8, 0x2, 0x0, 0x0, 0x35, 0x5e, 0x17, 0xd1, 0x3, 0x0, 0x12, 0x7c, 0xb5, 0xf1, 0xa2, 0x13, 0xa6, 0xda, + 0xc0, 0x20, 0x89, 0x82, 0xcc, 0x70, 0x52, 0x3e, 0xc0, 0x30, 0x98, 0x2a, 0x33, 0x0, 0x19, 0xbc, 0x5a, 0x1b, 0x44, + 0xac, 0x32, 0x1d, 0x4f, 0xeb, 0x5f, 0xaf, 0x4e, 0x2a, 0x24, 0xf3, 0x88, 0xe0, 0x20, 0x3d, 0x89, 0xa9, 0x9b, 0x7f, + 0xe3, 0x31, 0x0, 0x0, 0xd, 0xcb, 0xe8, 0x71, 0x34, 0x19, 0xb, 0xdc, 0x9e, 0x58, 0xad, 0x6c, 0x1a, 0xae, 0x2}; + + uint8_t buf[219] = {0}; + + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xbc, 0x5a, 0x1b, 0x44, 0xac, 0x32, 0x1d, 0x4f, 0xeb, 0x5f, 0xaf, 0x4e, 0x2a, + 0x24, 0xf3, 0x88, 0xe0, 0x20, 0x3d, 0x89, 0xa9, 0x9b, 0x7f, 0xe3, 0x31}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xcb, 0xe8, 0x71, 0x34, 0x19, 0xb, 0xdc, 0x9e, 0x58, 0xad, 0x6c, 0x1a, 0xae}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0xbd, 0xdd, 0x62, 0xd9, 0xae, 0x59, 0xd4, 0x97, 0xa8, 0x8, 0xad, 0x45, + 0x24, 0x53, 0xa3, 0x7f, 0x77, 0x37, 0xaf, 0x54, 0x77, 0xdf, 0x7, 0x46}; + uint8_t bytesprops1[] = {0x4e, 0xdd, 0x8a, 0xd0, 0xb0, 0xa, 0x75, 0x9d, 0x8f, 0x82, + 0x4e, 0x5f, 0x16, 0x6e, 0x91, 0x94, 0x96, 0xab, 0x22}; + uint8_t bytesprops2[] = {0xe0, 0x34, 0x27, 0x37, 0x4d, 0xd, 0x2a, 0x4c, 0x4e, + 0x88, 0xfe, 0xed, 0xde, 0xb4, 0x4a, 0x63, 0xf9, 0x68}; + uint8_t bytesprops3[] = {0x75, 0x7b, 0x21, 0x92, 0xea, 0xa, 0x7e, 0x91, 0x3e, 0xfd}; + uint8_t bytesprops4[] = {0x7c, 0xb5, 0xf1, 0xa2, 0x13, 0xa6, 0xda, 0xc0, 0x20, + 0x89, 0x82, 0xcc, 0x70, 0x52, 0x3e, 0xc0, 0x30, 0x98}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26323}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13033}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25541}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28428}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21622}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16827}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8407}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11873}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15245}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14260}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13662}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x69, 0xc2, 0x29, 0xf, 0xdc, 0x4f, 0x49, 0xd, 0xd0, 0x9b, - 0x5a, 0xc0, 0x5d, 0x45, 0x78, 0x44, 0xe6, 0xf0, 0xa7, 0x34}; - uint8_t byteswillprops0[] = {0x35}; - uint8_t byteswillprops2[] = {0x87, 0x7, 0xd, 0xa1, 0x31, 0x38, 0xe6, 0x28, 0x75, 0x34, 0x63, - 0x42, 0x35, 0x3f, 0x2e, 0x30, 0x90, 0xc6, 0x82, 0x67, 0xb8}; - uint8_t byteswillprops3[] = {0x81, 0xce, 0xc2, 0x46, 0x18, 0x75, 0x4e, 0x20, 0xd8, 0x75, - 0xdf, 0x2f, 0x49, 0xad, 0xd1, 0xf4, 0xf7, 0x31, 0x54, 0x7f, - 0x87, 0x3c, 0xbb, 0x1c, 0x1c, 0x49, 0x9d, 0xdf, 0x81, 0xb8}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32265, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 7342 [("\RS8\172\211YnUe\216\&6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("~\\\198\&7Ty\GS\206{}\244\164c@{",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("j\227\vg\167<\\S\255\151",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("$S\172",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\174\RS\128=\161\254b\152\&4 \209\226m\237`\SOHcY\162",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\210\179\&8\244\FS\DC2\219W\171\&8!\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("Z\202\&4E\179\143\226E\151\146!\135\216",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\150\&5\226T\150\145THQ\tM\156\165\146Y\245\"\ESC\152YF\252\180\142\222\181\171\175D",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\220\144\&8\247r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("G=\164\r\202\193\181\145:\160V\n7F/\251\199)\224\DLE\197\239\r",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropServerKeepAlive +// 20872,PropSubscriptionIdentifier 10,PropServerReference "3\157z\229n)",PropCorrelationData +// "G\242\"\SO\177\163\221\223\242",PropSharedSubscriptionAvailable 210] +TEST(Subscribe5QCTest, Encode91) { + uint8_t pkt[] = {0x82, 0xc8, 0x1, 0x1c, 0xae, 0x1c, 0x13, 0x51, 0x88, 0xb, 0xa, 0x1c, 0x0, 0x6, 0x33, 0x9d, 0x7a, + 0xe5, 0x6e, 0x29, 0x9, 0x0, 0x9, 0x47, 0xf2, 0x22, 0xe, 0xb1, 0xa3, 0xdd, 0xdf, 0xf2, 0x2a, 0xd2, + 0x0, 0xa, 0x1e, 0x38, 0xac, 0xd3, 0x59, 0x6e, 0x55, 0x65, 0xd8, 0x36, 0x2, 0x0, 0xf, 0x7e, 0x5c, + 0xc6, 0x37, 0x54, 0x79, 0x1d, 0xce, 0x7b, 0x7d, 0xf4, 0xa4, 0x63, 0x40, 0x7b, 0x2, 0x0, 0xa, 0x6a, + 0xe3, 0xb, 0x67, 0xa7, 0x3c, 0x5c, 0x53, 0xff, 0x97, 0x0, 0x0, 0x3, 0x24, 0x53, 0xac, 0x0, 0x0, + 0x13, 0xae, 0x1e, 0x80, 0x3d, 0xa1, 0xfe, 0x62, 0x98, 0x34, 0x20, 0xd1, 0xe2, 0x6d, 0xed, 0x60, 0x1, + 0x63, 0x59, 0xa2, 0x1, 0x0, 0xc, 0xd2, 0xb3, 0x38, 0xf4, 0x1c, 0x12, 0xdb, 0x57, 0xab, 0x38, 0x21, + 0xba, 0x1, 0x0, 0xd, 0x5a, 0xca, 0x34, 0x45, 0xb3, 0x8f, 0xe2, 0x45, 0x97, 0x92, 0x21, 0x87, 0xd8, + 0x1, 0x0, 0x1d, 0x96, 0x35, 0xe2, 0x54, 0x96, 0x91, 0x54, 0x48, 0x51, 0x9, 0x4d, 0x9c, 0xa5, 0x92, + 0x59, 0xf5, 0x22, 0x1b, 0x98, 0x59, 0x46, 0xfc, 0xb4, 0x8e, 0xde, 0xb5, 0xab, 0xaf, 0x44, 0x1, 0x0, + 0x5, 0xdc, 0x90, 0x38, 0xf7, 0x72, 0x1, 0x0, 0x17, 0x47, 0x3d, 0xa4, 0xd, 0xca, 0xc1, 0xb5, 0x91, + 0x3a, 0xa0, 0x56, 0xa, 0x37, 0x46, 0x2f, 0xfb, 0xc7, 0x29, 0xe0, 0x10, 0xc5, 0xef, 0xd, 0x2}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18598}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {1, (char*)&byteswillprops0}, .v = {20, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30447}}, + uint8_t buf[213] = {0}; + + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x1e, 0x38, 0xac, 0xd3, 0x59, 0x6e, 0x55, 0x65, 0xd8, 0x36}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7e, 0x5c, 0xc6, 0x37, 0x54, 0x79, 0x1d, 0xce, + 0x7b, 0x7d, 0xf4, 0xa4, 0x63, 0x40, 0x7b}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x6a, 0xe3, 0xb, 0x67, 0xa7, 0x3c, 0x5c, 0x53, 0xff, 0x97}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x24, 0x53, 0xac}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xae, 0x1e, 0x80, 0x3d, 0xa1, 0xfe, 0x62, 0x98, 0x34, 0x20, + 0xd1, 0xe2, 0x6d, 0xed, 0x60, 0x1, 0x63, 0x59, 0xa2}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xd2, 0xb3, 0x38, 0xf4, 0x1c, 0x12, 0xdb, 0x57, 0xab, 0x38, 0x21, 0xba}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x5a, 0xca, 0x34, 0x45, 0xb3, 0x8f, 0xe2, 0x45, 0x97, 0x92, 0x21, 0x87, 0xd8}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x96, 0x35, 0xe2, 0x54, 0x96, 0x91, 0x54, 0x48, 0x51, 0x9, + 0x4d, 0x9c, 0xa5, 0x92, 0x59, 0xf5, 0x22, 0x1b, 0x98, 0x59, + 0x46, 0xfc, 0xb4, 0x8e, 0xde, 0xb5, 0xab, 0xaf, 0x44}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xdc, 0x90, 0x38, 0xf7, 0x72}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x47, 0x3d, 0xa4, 0xd, 0xca, 0xc1, 0xb5, 0x91, 0x3a, 0xa0, 0x56, 0xa, + 0x37, 0x46, 0x2f, 0xfb, 0xc7, 0x29, 0xe0, 0x10, 0xc5, 0xef, 0xd}; + lwmqtt_string_t topic_filter_s9 = {23, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x33, 0x9d, 0x7a, 0xe5, 0x6e, 0x29}; + uint8_t bytesprops1[] = {0x47, 0xf2, 0x22, 0xe, 0xb1, 0xa3, 0xdd, 0xdf, 0xf2}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20872}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, }; - lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd6, 0x68, 0x74, 0xca, 0x51, 0x3a, 0x75, 0x13, 0xbe, 0x16, 0x16, 0xf6, 0xe1, 0x82, - 0xe8, 0x58, 0xc4, 0x6b, 0x25, 0x1e, 0x56, 0x2a, 0x90, 0x9a, 0xd7, 0xb8, 0xe3}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x74, 0x20, 0xa4, 0x18, 0x29, 0xbf, 0x84, 0xdf, 0xe2, 0xc9, 0xe6, 0x95, - 0xfd, 0x4e, 0xbd, 0xda, 0xd7, 0x34, 0xb6, 0x47, 0x79, 0xf7, 0x79, 0xc9}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 24570; - uint8_t client_id_bytes[] = {0x4b, 0x22, 0x25, 0x6a, 0x10, 0x2, 0x75, 0x7e, 0x1b, 0xec, 0xb2, 0xcc, - 0x53, 0x97, 0x28, 0x3f, 0xf5, 0xd6, 0x77, 0x3b, 0xd, 0xff, 0x35, 0x21}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x6f, 0x78, 0xc0, 0xd1, 0x85, 0xdc, 0x7e, 0x12, 0x39, 0x42, 0xb6, 0xef, - 0x3d, 0xc4, 0x53, 0x61, 0x5b, 0x52, 0x17, 0x0, 0x1f, 0xf8, 0x45}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7342, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\157LD\210\143*\189\134\&0\231\250\253\DC3\210\ETXh\178", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "|\157\175oRO\236\200|s\252\165x\155\f\205{\227\229\134\251u\146\144\248.", _willMsg = -// "R\242;\DC1D\209@\146\213\194Qz\230\DC3\213\RSk`\189a5\DLE\245", _willProps = [PropSubscriptionIdentifierAvailable -// 218,PropMaximumPacketSize 24888,PropAssignedClientIdentifier "\132\148\178\238\227 -// \SYN\186x`\172\158h",PropSubscriptionIdentifierAvailable 246,PropSharedSubscriptionAvailable -// 110,PropPayloadFormatIndicator 59,PropAuthenticationData -// "\133\164!\202V\175\202\208\f/n\NUL\206W\242Y\237\160\238\236Y",PropSessionExpiryInterval -// 1237,PropSubscriptionIdentifierAvailable 196,PropSharedSubscriptionAvailable 232,PropMaximumQoS -// 79,PropMessageExpiryInterval 5045,PropUserProperty "\129K\209~I\DC1\rl\144\176F~4\131Wn3c\220\170\135]o\207(\164k" -// "\EOT\160",PropContentType -// "\159\SYNC\t\245\152\217|\167\242{l\186o\251\203\170\&5\GS\STX\169",PropSubscriptionIdentifierAvailable -// 5,PropReasonString "\155\133\&6\153\132o4\143O\RS\220q\DC3\RS\143",PropReceiveMaximum 26389,PropResponseTopic -// "Jq\184\229\146\180^L~\147}\241GW#\v\149\138\194\230\202",PropMessageExpiryInterval 22509,PropMaximumQoS -// 6,PropMaximumPacketSize 29831,PropMessageExpiryInterval 4338,PropMessageExpiryInterval 3098,PropAuthenticationMethod -// "\172\171;4\204XG\215\239\185\131={"]}), _cleanSession = False, _keepAlive = 10064, _connID = -// "\192u\185\&3\177\222-3\142\DLE\172\172\163\242\228P\178\180\ETB\198]c\131", _properties = [PropRetainAvailable -// 158,PropRetainAvailable 154,PropTopicAliasMaximum 25958,PropRetainAvailable 43,PropAuthenticationData -// "e\135\139z\130\a\172\207\197\175\SOH\200'\SOH\165\181",PropUserProperty "f)\"\242X\153" -// "\STX\219",PropMessageExpiryInterval 24476,PropReasonString -// "\242\159\212\245\211\SYNY\171;\134\174",PropWillDelayInterval 942,PropWildcardSubscriptionAvailable -// 122,PropResponseTopic "m%\226\241\247\193\211\ESC\150\226H0_\226iJa\208\155\226~\DC3\202\192",PropTopicAlias -// 21751,PropAuthenticationMethod "\209^\194",PropServerReference "\ETX\223\235\193+\138Mr\239\142",PropUserProperty -// "q;\184\240\150\ACKD\219M\193,5\170\155N\172\137\DC3\234N\154\176{\174\199\202v\134" -// "\179anxx\178\204\205\187\184\131H4\US7\163%f\250O\241/\222$\141\174",PropWillDelayInterval -// 288,PropAssignedClientIdentifier "\159\EOT3'\rw\231\213?",PropContentType -// "\GS[aW\t2\192\USBN\128\186\198+>\243\155\186O?\143",PropReceiveMaximum 24840,PropReceiveMaximum -// 22186,PropMessageExpiryInterval 27150,PropServerReference ".mL\SO\146K\188\159\157.\248c.\178",PropTopicAlias -// 14699,PropContentType "?\ESC\157\170\195T~\153\155\181\239\a\207_\156e\SYNw\130\219",PropTopicAliasMaximum -// 32514,PropRequestProblemInformation 70,PropResponseTopic "\212\181\RS\157a\224\247",PropServerReference -// "\187\208\173{u.=\200\DC4wgJ~\253\152S\DC1s\ACK\209",PropSubscriptionIdentifier 22]} -TEST(Connect5QCTest, Encode96) { - uint8_t pkt[] = { - 0x10, 0xe6, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x34, 0x27, 0x50, 0xb6, 0x2, 0x25, 0x9e, 0x25, 0x9a, - 0x22, 0x65, 0x66, 0x25, 0x2b, 0x16, 0x0, 0x10, 0x65, 0x87, 0x8b, 0x7a, 0x82, 0x7, 0xac, 0xcf, 0xc5, 0xaf, 0x1, - 0xc8, 0x27, 0x1, 0xa5, 0xb5, 0x26, 0x0, 0x6, 0x66, 0x29, 0x22, 0xf2, 0x58, 0x99, 0x0, 0x2, 0x2, 0xdb, 0x2, - 0x0, 0x0, 0x5f, 0x9c, 0x1f, 0x0, 0xb, 0xf2, 0x9f, 0xd4, 0xf5, 0xd3, 0x16, 0x59, 0xab, 0x3b, 0x86, 0xae, 0x18, - 0x0, 0x0, 0x3, 0xae, 0x28, 0x7a, 0x8, 0x0, 0x18, 0x6d, 0x25, 0xe2, 0xf1, 0xf7, 0xc1, 0xd3, 0x1b, 0x96, 0xe2, - 0x48, 0x30, 0x5f, 0xe2, 0x69, 0x4a, 0x61, 0xd0, 0x9b, 0xe2, 0x7e, 0x13, 0xca, 0xc0, 0x23, 0x54, 0xf7, 0x15, 0x0, - 0x3, 0xd1, 0x5e, 0xc2, 0x1c, 0x0, 0xa, 0x3, 0xdf, 0xeb, 0xc1, 0x2b, 0x8a, 0x4d, 0x72, 0xef, 0x8e, 0x26, 0x0, - 0x1c, 0x71, 0x3b, 0xb8, 0xf0, 0x96, 0x6, 0x44, 0xdb, 0x4d, 0xc1, 0x2c, 0x35,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x57, 0x23, 0xb, 0x95, 0x8a, 0xc2, 0xe6, 0xca, 0x2, 0x0, 0x0, 0x57, 0xed, 0x24, - 0x6, 0x27, 0x0, 0x0, 0x74, 0x87, 0x2, 0x0, 0x0, 0x10, 0xf2, 0x2, 0x0, 0x0, 0xc, 0x1a, 0x15, 0x0, 0xd, - 0xac, 0xab, 0x3b, 0x34, 0xcc, 0x58, 0x47, 0xd7, 0xef, 0xb9, 0x83, 0x3d, 0x7b, 0x0, 0x1a, 0x7c, 0x9d, 0xaf, 0x6f, - 0x52, 0x4f, 0xec, 0xc8, 0x7c, 0x73, 0xfc, 0xa5, 0x78, 0x9b, 0xc, 0xcd, 0x7b, 0xe3, 0xe5, 0x86, 0xfb, 0x75, 0x92, - 0x90, 0xf8, 0x2e, 0x0, 0x17, 0x52, 0xf2, 0x3b, 0x11, 0x44, 0xd1, 0x40, 0x92, 0xd5, 0xc2, 0x51, 0x7a, 0xe6, 0x13, - 0xd5, 0x1e, 0x6b, 0x60, 0xbd, 0x61, 0x35, 0x10, 0xf5}; - - uint8_t buf[627] = {0}; - - uint8_t bytesprops0[] = {0x65, 0x87, 0x8b, 0x7a, 0x82, 0x7, 0xac, 0xcf, 0xc5, 0xaf, 0x1, 0xc8, 0x27, 0x1, 0xa5, 0xb5}; - uint8_t bytesprops2[] = {0x2, 0xdb}; - uint8_t bytesprops1[] = {0x66, 0x29, 0x22, 0xf2, 0x58, 0x99}; - uint8_t bytesprops3[] = {0xf2, 0x9f, 0xd4, 0xf5, 0xd3, 0x16, 0x59, 0xab, 0x3b, 0x86, 0xae}; - uint8_t bytesprops4[] = {0x6d, 0x25, 0xe2, 0xf1, 0xf7, 0xc1, 0xd3, 0x1b, 0x96, 0xe2, 0x48, 0x30, - 0x5f, 0xe2, 0x69, 0x4a, 0x61, 0xd0, 0x9b, 0xe2, 0x7e, 0x13, 0xca, 0xc0}; - uint8_t bytesprops5[] = {0xd1, 0x5e, 0xc2}; - uint8_t bytesprops6[] = {0x3, 0xdf, 0xeb, 0xc1, 0x2b, 0x8a, 0x4d, 0x72, 0xef, 0x8e}; - uint8_t bytesprops8[] = {0xb3, 0x61, 0x6e, 0x78, 0x78, 0xb2, 0xcc, 0xcd, 0xbb, 0xb8, 0x83, 0x48, 0x34, - 0x1f, 0x37, 0xa3, 0x25, 0x66, 0xfa, 0x4f, 0xf1, 0x2f, 0xde, 0x24, 0x8d, 0xae}; - uint8_t bytesprops7[] = {0x71, 0x3b, 0xb8, 0xf0, 0x96, 0x6, 0x44, 0xdb, 0x4d, 0xc1, 0x2c, 0x35, 0xaa, 0x9b, - 0x4e, 0xac, 0x89, 0x13, 0xea, 0x4e, 0x9a, 0xb0, 0x7b, 0xae, 0xc7, 0xca, 0x76, 0x86}; - uint8_t bytesprops9[] = {0x9f, 0x4, 0x33, 0x27, 0xd, 0x77, 0xe7, 0xd5, 0x3f}; - uint8_t bytesprops10[] = {0x1d, 0x5b, 0x61, 0x57, 0x9, 0x32, 0xc0, 0x1f, 0x42, 0x4e, 0x80, - 0xba, 0xc6, 0x2b, 0x3e, 0xf3, 0x9b, 0xba, 0x4f, 0x3f, 0x8f}; - uint8_t bytesprops11[] = {0x2e, 0x6d, 0x4c, 0xe, 0x92, 0x4b, 0xbc, 0x9f, 0x9d, 0x2e, 0xf8, 0x63, 0x2e, 0xb2}; - uint8_t bytesprops12[] = {0x3f, 0x1b, 0x9d, 0xaa, 0xc3, 0x54, 0x7e, 0x99, 0x9b, 0xb5, - 0xef, 0x7, 0xcf, 0x5f, 0x9c, 0x65, 0x16, 0x77, 0x82, 0xdb}; - uint8_t bytesprops13[] = {0xd4, 0xb5, 0x1e, 0x9d, 0x61, 0xe0, 0xf7}; - uint8_t bytesprops14[] = {0xbb, 0xd0, 0xad, 0x7b, 0x75, 0x2e, 0x3d, 0xc8, 0x14, 0x77, - 0x67, 0x4a, 0x7e, 0xfd, 0x98, 0x53, 0x11, 0x73, 0x6, 0xd1}; +// SubscribeRequest 25785 [("4\DC1\131\219{\253\160\n\151f\226{\218\179",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("F\173\174\178\252\144\161\193\&0H\130c\170,\160\167-)\162",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\230\216\219R\ACK\203\\\EM\206|\151\250\&7",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("7!\245\132~\DC2(\164\v\167p\249O]\EOTx*&\173pP\249\209",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\213\FS\146i\223\DC4\233\DC1\SI\208*_B\198EP\ACK[\226\182)\255",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\247P\157\US\255e\250\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe5QCTest, Encode92) { + uint8_t pkt[] = {0x82, 0x78, 0x64, 0xb9, 0x0, 0x0, 0xe, 0x34, 0x11, 0x83, 0xdb, 0x7b, 0xfd, 0xa0, 0xa, 0x97, + 0x66, 0xe2, 0x7b, 0xda, 0xb3, 0x0, 0x0, 0x13, 0x46, 0xad, 0xae, 0xb2, 0xfc, 0x90, 0xa1, 0xc1, + 0x30, 0x48, 0x82, 0x63, 0xaa, 0x2c, 0xa0, 0xa7, 0x2d, 0x29, 0xa2, 0x0, 0x0, 0xd, 0xe6, 0xd8, + 0xdb, 0x52, 0x6, 0xcb, 0x5c, 0x19, 0xce, 0x7c, 0x97, 0xfa, 0x37, 0x1, 0x0, 0x17, 0x37, 0x21, + 0xf5, 0x84, 0x7e, 0x12, 0x28, 0xa4, 0xb, 0xa7, 0x70, 0xf9, 0x4f, 0x5d, 0x4, 0x78, 0x2a, 0x26, + 0xad, 0x70, 0x50, 0xf9, 0xd1, 0x1, 0x0, 0x16, 0xd5, 0x1c, 0x92, 0x69, 0xdf, 0x14, 0xe9, 0x11, + 0xf, 0xd0, 0x2a, 0x5f, 0x42, 0xc6, 0x45, 0x50, 0x6, 0x5b, 0xe2, 0xb6, 0x29, 0xff, 0x2, 0x0, + 0x8, 0xf7, 0x50, 0x9d, 0x1f, 0xff, 0x65, 0xfa, 0xb4, 0x0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25958}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {2, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24476}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 942}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21751}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops7}, .v = {26, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 288}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24840}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22186}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27150}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14699}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32514}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - }; + uint8_t buf[132] = {0}; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x84, 0x94, 0xb2, 0xee, 0xe3, 0x20, 0x16, 0xba, 0x78, 0x60, 0xac, 0x9e, 0x68}; - uint8_t byteswillprops1[] = {0x85, 0xa4, 0x21, 0xca, 0x56, 0xaf, 0xca, 0xd0, 0xc, 0x2f, 0x6e, - 0x0, 0xce, 0x57, 0xf2, 0x59, 0xed, 0xa0, 0xee, 0xec, 0x59}; - uint8_t byteswillprops3[] = {0x4, 0xa0}; - uint8_t byteswillprops2[] = {0x81, 0x4b, 0xd1, 0x7e, 0x49, 0x11, 0xd, 0x6c, 0x90, 0xb0, 0x46, 0x7e, 0x34, 0x83, - 0x57, 0x6e, 0x33, 0x63, 0xdc, 0xaa, 0x87, 0x5d, 0x6f, 0xcf, 0x28, 0xa4, 0x6b}; - uint8_t byteswillprops4[] = {0x9f, 0x16, 0x43, 0x9, 0xf5, 0x98, 0xd9, 0x7c, 0xa7, 0xf2, 0x7b, - 0x6c, 0xba, 0x6f, 0xfb, 0xcb, 0xaa, 0x35, 0x1d, 0x2, 0xa9}; - uint8_t byteswillprops5[] = {0x9b, 0x85, 0x36, 0x99, 0x84, 0x6f, 0x34, 0x8f, - 0x4f, 0x1e, 0xdc, 0x71, 0x13, 0x1e, 0x8f}; - uint8_t byteswillprops6[] = {0x4a, 0x71, 0xb8, 0xe5, 0x92, 0xb4, 0x5e, 0x4c, 0x7e, 0x93, 0x7d, - 0xf1, 0x47, 0x57, 0x23, 0xb, 0x95, 0x8a, 0xc2, 0xe6, 0xca}; - uint8_t byteswillprops7[] = {0xac, 0xab, 0x3b, 0x34, 0xcc, 0x58, 0x47, 0xd7, 0xef, 0xb9, 0x83, 0x3d, 0x7b}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x34, 0x11, 0x83, 0xdb, 0x7b, 0xfd, 0xa0, 0xa, 0x97, 0x66, 0xe2, 0x7b, 0xda, 0xb3}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x46, 0xad, 0xae, 0xb2, 0xfc, 0x90, 0xa1, 0xc1, 0x30, 0x48, + 0x82, 0x63, 0xaa, 0x2c, 0xa0, 0xa7, 0x2d, 0x29, 0xa2}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe6, 0xd8, 0xdb, 0x52, 0x6, 0xcb, 0x5c, 0x19, 0xce, 0x7c, 0x97, 0xfa, 0x37}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x37, 0x21, 0xf5, 0x84, 0x7e, 0x12, 0x28, 0xa4, 0xb, 0xa7, 0x70, 0xf9, + 0x4f, 0x5d, 0x4, 0x78, 0x2a, 0x26, 0xad, 0x70, 0x50, 0xf9, 0xd1}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd5, 0x1c, 0x92, 0x69, 0xdf, 0x14, 0xe9, 0x11, 0xf, 0xd0, 0x2a, + 0x5f, 0x42, 0xc6, 0x45, 0x50, 0x6, 0x5b, 0xe2, 0xb6, 0x29, 0xff}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf7, 0x50, 0x9d, 0x1f, 0xff, 0x65, 0xfa, 0xb4}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24888}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1237}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5045}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {27, (char*)&byteswillprops2}, .v = {2, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26389}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22509}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29831}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4338}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3098}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops7}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x7c, 0x9d, 0xaf, 0x6f, 0x52, 0x4f, 0xec, 0xc8, 0x7c, 0x73, 0xfc, 0xa5, 0x78, - 0x9b, 0xc, 0xcd, 0x7b, 0xe3, 0xe5, 0x86, 0xfb, 0x75, 0x92, 0x90, 0xf8, 0x2e}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x52, 0xf2, 0x3b, 0x11, 0x44, 0xd1, 0x40, 0x92, 0xd5, 0xc2, 0x51, 0x7a, - 0xe6, 0x13, 0xd5, 0x1e, 0x6b, 0x60, 0xbd, 0x61, 0x35, 0x10, 0xf5}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 10064; - uint8_t client_id_bytes[] = {0xc0, 0x75, 0xb9, 0x33, 0xb1, 0xde, 0x2d, 0x33, 0x8e, 0x10, 0xac, 0xac, - 0xa3, 0xf2, 0xe4, 0x50, 0xb2, 0xb4, 0x17, 0xc6, 0x5d, 0x63, 0x83}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x9d, 0x4c, 0x44, 0xd2, 0x8f, 0x2a, 0xbd, 0x86, 0x30, - 0xe7, 0xfa, 0xfd, 0x13, 0xd2, 0x3, 0x68, 0xb2}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25785, 6, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\136a6\248", _password = Just "aW\205\150\ACK*\208", _lastWill = Nothing, -// _cleanSession = True, _keepAlive = 27816, _connID = "\200\194\195y\163\178", _properties = [PropWillDelayInterval -// 4578,PropRequestProblemInformation 132,PropSharedSubscriptionAvailable 114,PropWildcardSubscriptionAvailable -// 89,PropAssignedClientIdentifier "\DELK9 \219\148ag\184\229d\164~\232\133\156\237\243\218\NAK9\221\nFy"]} -TEST(Connect5QCTest, Encode97) { - uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x6c, 0xa8, 0x27, 0x18, 0x0, - 0x0, 0x11, 0xe2, 0x17, 0x84, 0x2a, 0x72, 0x28, 0x59, 0x12, 0x0, 0x19, 0x7f, 0x4b, 0x39, - 0x20, 0xdb, 0x94, 0x61, 0x67, 0xb8, 0xe5, 0x64, 0xa4, 0x7e, 0xe8, 0x85, 0x9c, 0xed, 0xf3, - 0xda, 0x15, 0x39, 0xdd, 0xa, 0x46, 0x79, 0x0, 0x6, 0xc8, 0xc2, 0xc3, 0x79, 0xa3, 0xb2, - 0x0, 0x4, 0x88, 0x61, 0x36, 0xf8, 0x0, 0x7, 0x61, 0x57, 0xcd, 0x96, 0x6, 0x2a, 0xd0}; +// SubscribeRequest 8081 [("\247\197\143\CANr(\SO\230",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0}),("\183\151u\251Or\149\230`\218\133\NUL\ETX\f",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("%\232\ACKq\200;\197\192\155\162\245|\t(\206\172\a\DELe\148\253\227\200\253\187s\219\179y",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("rp\156\133\138@\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\STX\f\202\217I\195/\218#\168^\215e\rU", _willProps = [PropServerKeepAlive 5351,PropSharedSubscriptionAvailable -// 40,PropWillDelayInterval 16062,PropPayloadFormatIndicator 215,PropAssignedClientIdentifier -// "\204m",PropServerReference "\RS\142U\199\244z\133x^y",PropContentType "\ETB\219\GS",PropContentType " -// \235\223\ETX:u\211\230\166 \r[\166\253~}\138\201G1\147",PropServerKeepAlive 32098,PropMaximumPacketSize -// 8075,PropRequestProblemInformation 143,PropWildcardSubscriptionAvailable 233,PropMaximumPacketSize -// 21067,PropServerKeepAlive 12021,PropMessageExpiryInterval 3499,PropContentType -// "V\157\r\167\136A\228\204\176\173V4\239E\138\129\184\189\249\208\203[\132\248/",PropMaximumPacketSize -// 13183,PropWillDelayInterval 18332,PropResponseTopic "\193\213\187J",PropPayloadFormatIndicator -// 137,PropPayloadFormatIndicator 88,PropRequestProblemInformation 95,PropRetainAvailable -// 117,PropRequestProblemInformation 107]}), _cleanSession = False, _keepAlive = 12906, _connID = -// "e\161\220F\196\187*\\H\151\188i\177\188\172\240", _properties = []} -TEST(Connect5QCTest, Encode98) { - uint8_t pkt[] = {0x10, 0xfa, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x32, 0x6a, 0x0, 0x0, 0x10, 0x65, - 0xa1, 0xdc, 0x46, 0xc4, 0xbb, 0x2a, 0x5c, 0x48, 0x97, 0xbc, 0x69, 0xb1, 0xbc, 0xac, 0xf0, 0x8c, 0x1, - 0x13, 0x14, 0xe7, 0x2a, 0x28, 0x18, 0x0, 0x0, 0x3e, 0xbe, 0x1, 0xd7, 0x12, 0x0, 0x2, 0xcc, 0x6d, - 0x1c, 0x0, 0xa, 0x1e, 0x8e, 0x55, 0xc7, 0xf4, 0x7a, 0x85, 0x78, 0x5e, 0x79, 0x3, 0x0, 0x3, 0x17, - 0xdb, 0x1d, 0x3, 0x0, 0x15, 0x20, 0xeb, 0xdf, 0x3, 0x3a, 0x75, 0xd3, 0xe6, 0xa6, 0x20, 0xd, 0x5b, - 0xa6, 0xfd, 0x7e, 0x7d, 0x8a, 0xc9, 0x47, 0x31, 0x93, 0x13, 0x7d, 0x62, 0x27, 0x0, 0x0, 0x1f, 0x8b, - 0x17, 0x8f, 0x28, 0xe9, 0x27, 0x0, 0x0, 0x52, 0x4b, 0x13, 0x2e, 0xf5, 0x2, 0x0, 0x0, 0xd, 0xab, - 0x3, 0x0, 0x19, 0x56, 0x9d, 0xd, 0xa7, 0x88, 0x41, 0xe4, 0xcc, 0xb0, 0xad, 0x56, 0x34, 0xef, 0x45, - 0x8a, 0x81, 0xb8, 0xbd, 0xf9, 0xd0, 0xcb, 0x5b, 0x84, 0xf8, 0x2f, 0x27, 0x0, 0x0, 0x33, 0x7f, 0x18, - 0x0, 0x0, 0x47, 0x9c, 0x8, 0x0, 0x4, 0xc1, 0xd5, 0xbb, 0x4a, 0x1, 0x89, 0x1, 0x58, 0x17, 0x5f, - 0x25, 0x75, 0x17, 0x6b, 0x0, 0x18, 0x3a, 0x98, 0x3c, 0xc5, 0xe4, 0xaa, 0xeb, 0x5b, 0x0, 0xcf, 0x49, - 0xa9, 0x3d, 0x95, 0x15, 0xe1, 0x24, 0xd, 0xe0, 0xdc, 0xad, 0x85, 0x45, 0x58, 0x0, 0xf, 0x45, 0xe1, - 0x5e, 0x59, 0x5a, 0x2, 0xa1, 0x18, 0x53, 0x82, 0x3e, 0xd7, 0x65, 0xd, 0x55, 0x0, 0x6, 0x59, 0x32, - 0xb, 0x7a, 0xc4, 0x2e, 0x0, 0x1a, 0x5a, 0x2b, 0xc3, 0x2d, 0xe9, 0x2a, 0x2c, 0xe8, 0xc0, 0xb2, 0x77, - 0x22, 0xc9, 0xbc, 0x58, 0x7f, 0x49, 0xa5, 0x90, 0xaa, 0xa, 0xa1, 0x62, 0x64, 0x54, 0x72}; - - uint8_t buf[263] = {0}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4638, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 30339 [("\179u\189\US\149]BIh\141\231\&6-\r\DC1Zc\223\\\DC3\163",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\RS\239\NAK.\t\226\168BS\142\163\209\211\134\\Uz\EOTV\129\STX.\ENQ\RS\ETB",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("r\146\230\ESC\129\250\136&\248\195p\140J(\DC2|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\251\175\166\&3\137\173N\196\187T~\DEL\158\245\238\247B\151\139\r\142=\247\EOT/\171E",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\204\171\242\244a7\178\140\138\149\174\201",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\131\241\222xlu'9!6\242\213K\227\&0\234\199\150+d\"\DC2/\145\149i;EV",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SYNr\167\NUL\254\180",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\193\211\192\222m\154\164",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [PropRetainAvailable 242,PropServerReference +// "\DC2\147\&9\ESC\178\DEL\169\DC1\168\172",PropTopicAlias 3260,PropRequestProblemInformation 61,PropServerKeepAlive +// 24137,PropWillDelayInterval 1106,PropRetainAvailable 194,PropMaximumQoS 114,PropTopicAlias 31301,PropUserProperty +// "r\US\227\&3I\138$\229g\240\135\212F\157\142\&6\DC3\NAKw>\243\&5gR\165\231" +// "\t\148\246\163>\ENQ\185\132\&1y\158w\144\151\196\174A*\209\221\235\223E",PropMessageExpiryInterval +// 11966,PropMessageExpiryInterval 7995,PropWillDelayInterval 4193,PropResponseInformation +// "\129C\199\179\199\234\SOH\231\194\132eH?\210ZF\210Ce/\152\209!\217\151\178\205",PropAuthenticationData +// "\n&\253\209\t\211V7\250E\ENQ\228",PropResponseTopic +// "1\181\177\206\164\155?\243q\145\&6\227,\SUB`#\EM\236]\136\178\162\228\\(",PropMaximumQoS +// 7,PropSubscriptionIdentifierAvailable 214,PropMaximumPacketSize 17538,PropPayloadFormatIndicator +// 193,PropSessionExpiryInterval 27816,PropRequestProblemInformation 68,PropMaximumPacketSize +// 19853,PropTopicAliasMaximum 19517,PropReasonString +// "\135\158\251\144m\NUL9\DC1\EM\209\ACK\250=!\135\129\&6\DLE+)\v\190\154\204Y\GSA\217\140",PropRequestProblemInformation +// 99,PropSubscriptionIdentifier 24,PropSubscriptionIdentifierAvailable 200,PropReceiveMaximum 3399] +TEST(Subscribe5QCTest, Encode95) { + uint8_t pkt[] = { + 0x82, 0x9f, 0x3, 0x76, 0x83, 0xf4, 0x1, 0x25, 0xf2, 0x1c, 0x0, 0xa, 0x12, 0x93, 0x39, 0x1b, 0xb2, 0x7f, 0xa9, + 0x11, 0xa8, 0xac, 0x23, 0xc, 0xbc, 0x17, 0x3d, 0x13, 0x5e, 0x49, 0x18, 0x0, 0x0, 0x4, 0x52, 0x25, 0xc2, 0x24, + 0x72, 0x23, 0x7a, 0x45, 0x26, 0x0, 0x1a, 0x72, 0x1f, 0xe3, 0x33, 0x49, 0x8a, 0x24, 0xe5, 0x67, 0xf0, 0x87, 0xd4, + 0x46, 0x9d, 0x8e, 0x36, 0x13, 0x15, 0x77, 0x3e, 0xf3, 0x35, 0x67, 0x52, 0xa5, 0xe7, 0x0, 0x17, 0x9, 0x94, 0xf6, + 0xa3, 0x3e, 0x5, 0xb9, 0x84, 0x31, 0x79, 0x9e, 0x77, 0x90, 0x97, 0xc4, 0xae, 0x41, 0x2a, 0xd1, 0xdd, 0xeb, 0xdf, + 0x45, 0x2, 0x0, 0x0, 0x2e, 0xbe, 0x2, 0x0, 0x0, 0x1f, 0x3b, 0x18, 0x0, 0x0, 0x10, 0x61, 0x1a, 0x0, 0x1b, + 0x81, 0x43, 0xc7, 0xb3, 0xc7, 0xea, 0x1, 0xe7, 0xc2, 0x84, 0x65, 0x48, 0x3f, 0xd2, 0x5a, 0x46, 0xd2, 0x43, 0x65, + 0x2f, 0x98, 0xd1, 0x21, 0xd9, 0x97, 0xb2, 0xcd, 0x16, 0x0, 0xc, 0xa, 0x26, 0xfd, 0xd1, 0x9, 0xd3, 0x56, 0x37, + 0xfa, 0x45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x42, 0x97, + 0x8b, 0xd, 0x8e, 0x3d, 0xf7, 0x4, 0x2f, 0xab, 0x45, 0x0, 0x0, 0xc, 0xcc, 0xab, 0xf2, 0xf4, 0x61, 0x37, 0xb2, + 0x8c, 0x8a, 0x95, 0xae, 0xc9, 0x2, 0x0, 0x1d, 0x83, 0xf1, 0xde, 0x78, 0x6c, 0x75, 0x27, 0x39, 0x21, 0x36, 0xf2, + 0xd5, 0x4b, 0xe3, 0x30, 0xea, 0xc7, 0x96, 0x2b, 0x64, 0x22, 0x12, 0x2f, 0x91, 0x95, 0x69, 0x3b, 0x45, 0x56, 0x1, + 0x0, 0x6, 0x16, 0x72, 0xa7, 0x0, 0xfe, 0xb4, 0x2, 0x0, 0x7, 0xc1, 0xd3, 0xc0, 0xde, 0x6d, 0x9a, 0xa4, 0x2}; - lwmqtt_property_t propslist[] = {}; + uint8_t buf[428] = {0}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xcc, 0x6d}; - uint8_t byteswillprops1[] = {0x1e, 0x8e, 0x55, 0xc7, 0xf4, 0x7a, 0x85, 0x78, 0x5e, 0x79}; - uint8_t byteswillprops2[] = {0x17, 0xdb, 0x1d}; - uint8_t byteswillprops3[] = {0x20, 0xeb, 0xdf, 0x3, 0x3a, 0x75, 0xd3, 0xe6, 0xa6, 0x20, 0xd, - 0x5b, 0xa6, 0xfd, 0x7e, 0x7d, 0x8a, 0xc9, 0x47, 0x31, 0x93}; - uint8_t byteswillprops4[] = {0x56, 0x9d, 0xd, 0xa7, 0x88, 0x41, 0xe4, 0xcc, 0xb0, 0xad, 0x56, 0x34, 0xef, - 0x45, 0x8a, 0x81, 0xb8, 0xbd, 0xf9, 0xd0, 0xcb, 0x5b, 0x84, 0xf8, 0x2f}; - uint8_t byteswillprops5[] = {0xc1, 0xd5, 0xbb, 0x4a}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xb3, 0x75, 0xbd, 0x1f, 0x95, 0x5d, 0x42, 0x49, 0x68, 0x8d, 0xe7, + 0x36, 0x2d, 0xd, 0x11, 0x5a, 0x63, 0xdf, 0x5c, 0x13, 0xa3}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0xef, 0x15, 0x2e, 0x9, 0xe2, 0xa8, 0x42, 0x53, 0x8e, 0xa3, 0xd1, 0xd3, + 0x86, 0x5c, 0x55, 0x7a, 0x4, 0x56, 0x81, 0x2, 0x2e, 0x5, 0x1e, 0x17}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x72, 0x92, 0xe6, 0x1b, 0x81, 0xfa, 0x88, 0x26, + 0xf8, 0xc3, 0x70, 0x8c, 0x4a, 0x28, 0x12, 0x7c}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xfb, 0xaf, 0xa6, 0x33, 0x89, 0xad, 0x4e, 0xc4, 0xbb, 0x54, 0x7e, 0x7f, 0x9e, 0xf5, + 0xee, 0xf7, 0x42, 0x97, 0x8b, 0xd, 0x8e, 0x3d, 0xf7, 0x4, 0x2f, 0xab, 0x45}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xcc, 0xab, 0xf2, 0xf4, 0x61, 0x37, 0xb2, 0x8c, 0x8a, 0x95, 0xae, 0xc9}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x83, 0xf1, 0xde, 0x78, 0x6c, 0x75, 0x27, 0x39, 0x21, 0x36, + 0xf2, 0xd5, 0x4b, 0xe3, 0x30, 0xea, 0xc7, 0x96, 0x2b, 0x64, + 0x22, 0x12, 0x2f, 0x91, 0x95, 0x69, 0x3b, 0x45, 0x56}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x16, 0x72, 0xa7, 0x0, 0xfe, 0xb4}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xc1, 0xd3, 0xc0, 0xde, 0x6d, 0x9a, 0xa4}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x12, 0x93, 0x39, 0x1b, 0xb2, 0x7f, 0xa9, 0x11, 0xa8, 0xac}; + uint8_t bytesprops2[] = {0x9, 0x94, 0xf6, 0xa3, 0x3e, 0x5, 0xb9, 0x84, 0x31, 0x79, 0x9e, 0x77, + 0x90, 0x97, 0xc4, 0xae, 0x41, 0x2a, 0xd1, 0xdd, 0xeb, 0xdf, 0x45}; + uint8_t bytesprops1[] = {0x72, 0x1f, 0xe3, 0x33, 0x49, 0x8a, 0x24, 0xe5, 0x67, 0xf0, 0x87, 0xd4, 0x46, + 0x9d, 0x8e, 0x36, 0x13, 0x15, 0x77, 0x3e, 0xf3, 0x35, 0x67, 0x52, 0xa5, 0xe7}; + uint8_t bytesprops3[] = {0x81, 0x43, 0xc7, 0xb3, 0xc7, 0xea, 0x1, 0xe7, 0xc2, 0x84, 0x65, 0x48, 0x3f, 0xd2, + 0x5a, 0x46, 0xd2, 0x43, 0x65, 0x2f, 0x98, 0xd1, 0x21, 0xd9, 0x97, 0xb2, 0xcd}; + uint8_t bytesprops4[] = {0xa, 0x26, 0xfd, 0xd1, 0x9, 0xd3, 0x56, 0x37, 0xfa, 0x45, 0x5, 0xe4}; + uint8_t bytesprops5[] = {0x31, 0xb5, 0xb1, 0xce, 0xa4, 0x9b, 0x3f, 0xf3, 0x71, 0x91, 0x36, 0xe3, 0x2c, + 0x1a, 0x60, 0x23, 0x19, 0xec, 0x5d, 0x88, 0xb2, 0xa2, 0xe4, 0x5c, 0x28}; + uint8_t bytesprops6[] = {0x87, 0x9e, 0xfb, 0x90, 0x6d, 0x0, 0x39, 0x11, 0x19, 0xd1, 0x6, 0xfa, 0x3d, 0x21, 0x87, + 0x81, 0x36, 0x10, 0x2b, 0x29, 0xb, 0xbe, 0x9a, 0xcc, 0x59, 0x1d, 0x41, 0xd9, 0x8c}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5351}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16062}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32098}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8075}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21067}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12021}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3499}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13183}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18332}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3260}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24137}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1106}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31301}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops1}, .v = {23, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11966}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7995}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4193}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17538}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27816}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19853}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19517}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3399}}, }; - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3a, 0x98, 0x3c, 0xc5, 0xe4, 0xaa, 0xeb, 0x5b, 0x0, 0xcf, 0x49, 0xa9, - 0x3d, 0x95, 0x15, 0xe1, 0x24, 0xd, 0xe0, 0xdc, 0xad, 0x85, 0x45, 0x58}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x45, 0xe1, 0x5e, 0x59, 0x5a, 0x2, 0xa1, 0x18, - 0x53, 0x82, 0x3e, 0xd7, 0x65, 0xd, 0x55}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12906; - uint8_t client_id_bytes[] = {0x65, 0xa1, 0xdc, 0x46, 0xc4, 0xbb, 0x2a, 0x5c, - 0x48, 0x97, 0xbc, 0x69, 0xb1, 0xbc, 0xac, 0xf0}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x59, 0x32, 0xb, 0x7a, 0xc4, 0x2e}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x5a, 0x2b, 0xc3, 0x2d, 0xe9, 0x2a, 0x2c, 0xe8, 0xc0, 0xb2, 0x77, 0x22, 0xc9, - 0xbc, 0x58, 0x7f, 0x49, 0xa5, 0x90, 0xaa, 0xa, 0xa1, 0x62, 0x64, 0x54, 0x72}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30339, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 19412, _connID = "\188=\183\NAK\DLE~\SYN\241", _properties = [PropMessageExpiryInterval 21066,PropAuthenticationData -// "C\203*\185*\211\218,\157F;\222",PropAuthenticationData "\RSB\229B\239u\205g\211\204",PropContentType -// "",PropMaximumQoS 61,PropSubscriptionIdentifier 12,PropMessageExpiryInterval 7641,PropResponseInformation -// "\157,\237\241\NUL\SYN\248=o\186_\140\209\134c\t",PropServerKeepAlive 7496,PropResponseInformation -// "K\GS\133\238+\182\ETX\150|l-6(\168\&1\187s~Ly~\GS\v\143",PropSharedSubscriptionAvailable -// 218,PropWildcardSubscriptionAvailable 151,PropAuthenticationData -// "\SUB[\ACK\GS\216\v\244\218\&9q\ETX!\252/\202\186\167E}!Ih\137\196\238L\152V(\156",PropAuthenticationData -// "\202q\166\144\190H\234(",PropResponseTopic "\134\142\212\228",PropTopicAlias 17133,PropAuthenticationData -// "f\DC3\NUL\187l",PropReceiveMaximum 28577,PropAuthenticationData "\f\210\227\234&",PropRequestResponseInformation -// 13,PropWildcardSubscriptionAvailable 114,PropSubscriptionIdentifier 31,PropRequestProblemInformation -// 252,PropResponseTopic "\215\178M\205\b\144\&4$\164Q\170)\246\210\RS",PropSessionExpiryInterval -// 12656,PropPayloadFormatIndicator 71,PropMessageExpiryInterval 22660,PropServerKeepAlive 29280,PropMaximumPacketSize -// 13910,PropAuthenticationData "\170L$\217\168\225\216N\250\130@\179\STX\NULo\223"]} -TEST(Connect5QCTest, Encode99) { - uint8_t pkt[] = { - 0x10, 0x82, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x4b, 0xd4, 0xec, 0x1, 0x2, 0x0, 0x0, 0x52, - 0x4a, 0x16, 0x0, 0xc, 0x43, 0xcb, 0x2a, 0xb9, 0x2a, 0xd3, 0xda, 0x2c, 0x9d, 0x46, 0x3b, 0xde, 0x16, 0x0, 0xa, - 0x1e, 0x42, 0xe5, 0x42, 0xef, 0x75, 0xcd, 0x67, 0xd3, 0xcc, 0x3, 0x0, 0x0, 0x24, 0x3d, 0xb, 0xc, 0x2, 0x0, - 0x0, 0x1d, 0xd9, 0x1a, 0x0, 0x10, 0x9d, 0x2c, 0xed, 0xf1, 0x0, 0x16, 0xf8, 0x3d, 0x6f, 0xba, 0x5f, 0x8c, 0xd1, - 0x86, 0x63, 0x9, 0x13, 0x1d, 0x48, 0x1a, 0x0, 0x18, 0x4b, 0x1d, 0x85, 0xee, 0x2b, 0xb6, 0x3, 0x96, 0x7c, 0x6c, - 0x2d, 0x36, 0x28, 0xa8, 0x31, 0xbb, 0x73, 0x7e, 0x4c, 0x79, 0x7e, 0x1d, 0xb, 0x8f, 0x2a, 0xda, 0x28, 0x97, 0x16, - 0x0, 0x1e, 0x1a, 0x5b, 0x6, 0x1d, 0xd8, 0xb, 0xf4, 0xda, 0x39, 0x71, 0x3, 0x21, 0xfc, 0x2f, 0xca, 0xba, 0xa7, - 0x45, 0x7d, 0x21, 0x49, 0x68, 0x89, 0xc4, 0xee, 0x4c, 0x98, 0x56, 0x28, 0x9c, 0x16, 0x0, 0x8, 0xca, 0x71, 0xa6, - 0x90, 0xbe, 0x48, 0xea, 0x28, 0x8, 0x0, 0x4, 0x86, 0x8e, 0xd4, 0xe4, 0x23, 0x42, 0xed, 0x16, 0x0, 0x5, 0x66, - 0x13, 0x0, 0xbb, 0x6c, 0x21, 0x6f, 0xa1, 0x16, 0x0, 0x5, 0xc, 0xd2, 0xe3, 0xea, 0x26, 0x19, 0xd, 0x28, 0x72, - 0xb, 0x1f, 0x17, 0xfc, 0x8, 0x0, 0xf, 0xd7, 0xb2, 0x4d, 0xcd, 0x8, 0x90, 0x34, 0x24, 0xa4, 0x51, 0xaa, 0x29, - 0xf6, 0xd2, 0x1e, 0x11, 0x0, 0x0, 0x31, 0x70, 0x1, 0x47, 0x2, 0x0, 0x0, 0x58, 0x84, 0x13, 0x72, 0x60, 0x27, - 0x0, 0x0, 0x36, 0x56, 0x16, 0x0, 0x10, 0xaa, 0x4c, 0x24, 0xd9, 0xa8, 0xe1, 0xd8, 0x4e, 0xfa, 0x82, 0x40, 0xb3, - 0x2, 0x0, 0x6f, 0xdf, 0x0, 0x8, 0xbc, 0x3d, 0xb7, 0x15, 0x10, 0x7e, 0x16, 0xf1}; +// SubscribeRequest 25983 [("\NULh]\172\248\158\GS:.\SOH<\\0\204q",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\CAN?\208\234\166~,\246\198\198\RS\128\a\167#\ESC\USb\161\FS",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\160\US\153\210\&2\243#\154\167",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\129\CAN\203\191Y5\132\246\162\129\192XU\"\172S",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe5QCTest, Encode96) { + uint8_t pkt[] = {0x82, 0x4b, 0x65, 0x7f, 0x0, 0x0, 0xf, 0x0, 0x68, 0x5d, 0xac, 0xf8, 0x9e, 0x1d, 0x3a, 0x2e, + 0x1, 0x3c, 0x5c, 0x30, 0xcc, 0x71, 0x2, 0x0, 0x14, 0x18, 0x3f, 0xd0, 0xea, 0xa6, 0x7e, 0x2c, + 0xf6, 0xc6, 0xc6, 0x1e, 0x80, 0x7, 0xa7, 0x23, 0x1b, 0x1f, 0x62, 0xa1, 0x1c, 0x1, 0x0, 0x9, + 0xa0, 0x1f, 0x99, 0xd2, 0x32, 0xf3, 0x23, 0x9a, 0xa7, 0x0, 0x0, 0x10, 0x81, 0x18, 0xcb, 0xbf, + 0x59, 0x35, 0x84, 0xf6, 0xa2, 0x81, 0xc0, 0x58, 0x55, 0x22, 0xac, 0x53, 0x1}; - uint8_t buf[271] = {0}; + uint8_t buf[87] = {0}; - uint8_t bytesprops0[] = {0x43, 0xcb, 0x2a, 0xb9, 0x2a, 0xd3, 0xda, 0x2c, 0x9d, 0x46, 0x3b, 0xde}; - uint8_t bytesprops1[] = {0x1e, 0x42, 0xe5, 0x42, 0xef, 0x75, 0xcd, 0x67, 0xd3, 0xcc}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x9d, 0x2c, 0xed, 0xf1, 0x0, 0x16, 0xf8, 0x3d, - 0x6f, 0xba, 0x5f, 0x8c, 0xd1, 0x86, 0x63, 0x9}; - uint8_t bytesprops4[] = {0x4b, 0x1d, 0x85, 0xee, 0x2b, 0xb6, 0x3, 0x96, 0x7c, 0x6c, 0x2d, 0x36, - 0x28, 0xa8, 0x31, 0xbb, 0x73, 0x7e, 0x4c, 0x79, 0x7e, 0x1d, 0xb, 0x8f}; - uint8_t bytesprops5[] = {0x1a, 0x5b, 0x6, 0x1d, 0xd8, 0xb, 0xf4, 0xda, 0x39, 0x71, 0x3, 0x21, 0xfc, 0x2f, 0xca, - 0xba, 0xa7, 0x45, 0x7d, 0x21, 0x49, 0x68, 0x89, 0xc4, 0xee, 0x4c, 0x98, 0x56, 0x28, 0x9c}; - uint8_t bytesprops6[] = {0xca, 0x71, 0xa6, 0x90, 0xbe, 0x48, 0xea, 0x28}; - uint8_t bytesprops7[] = {0x86, 0x8e, 0xd4, 0xe4}; - uint8_t bytesprops8[] = {0x66, 0x13, 0x0, 0xbb, 0x6c}; - uint8_t bytesprops9[] = {0xc, 0xd2, 0xe3, 0xea, 0x26}; - uint8_t bytesprops10[] = {0xd7, 0xb2, 0x4d, 0xcd, 0x8, 0x90, 0x34, 0x24, 0xa4, 0x51, 0xaa, 0x29, 0xf6, 0xd2, 0x1e}; - uint8_t bytesprops11[] = {0xaa, 0x4c, 0x24, 0xd9, 0xa8, 0xe1, 0xd8, 0x4e, - 0xfa, 0x82, 0x40, 0xb3, 0x2, 0x0, 0x6f, 0xdf}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x0, 0x68, 0x5d, 0xac, 0xf8, 0x9e, 0x1d, 0x3a, + 0x2e, 0x1, 0x3c, 0x5c, 0x30, 0xcc, 0x71}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x18, 0x3f, 0xd0, 0xea, 0xa6, 0x7e, 0x2c, 0xf6, 0xc6, 0xc6, + 0x1e, 0x80, 0x7, 0xa7, 0x23, 0x1b, 0x1f, 0x62, 0xa1, 0x1c}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa0, 0x1f, 0x99, 0xd2, 0x32, 0xf3, 0x23, 0x9a, 0xa7}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x81, 0x18, 0xcb, 0xbf, 0x59, 0x35, 0x84, 0xf6, + 0xa2, 0x81, 0xc0, 0x58, 0x55, 0x22, 0xac, 0x53}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25983, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 14533 [("\207u\229\191Dm6]U\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\159\195\128\SOHK\243\248gf\DEL",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("[{\199\214\EMb\b\140H/\140\146\DC3\SYN\141\SOh\251\148\a\145\SOH*\160\190\145\130D\SO/",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\v6\STX\"\b% +// \211\241\184\238\234b\247\174\178w",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\158\143\t\131\211\229\129,\234\193GG\206r\191\150\176\DC2",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("6\195\241\184/\168\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS0}),("\140\DC3M\195\237\DLEO\231",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRequestProblemInformation +// 251,PropSubscriptionIdentifier 27,PropServerReference "\166",PropServerKeepAlive 26843,PropSubscriptionIdentifier +// 24,PropAssignedClientIdentifier "#\SYN'\154\145\133\138\183\237y\195]rp?\DC3\DC1\164\203\169\r",PropUserProperty +// "iT\ACK\197\191@3\226\DC4\225h\145\247\160\180\238\204\213\a\221c\188*\252" +// "@\226`hV\230I\187\221\150V\144\ESCuV\191",PropMessageExpiryInterval 14849,PropAuthenticationMethod +// "\184\175z\170\154\183\234\144\226\151W\224"] +TEST(Subscribe5QCTest, Encode97) { + uint8_t pkt[] = {0x82, 0xe2, 0x1, 0x38, 0xc5, 0x66, 0x17, 0xfb, 0xb, 0x1b, 0x1c, 0x0, 0x1, 0xa6, 0x13, 0x68, 0xdb, + 0xb, 0x18, 0x12, 0x0, 0x15, 0x23, 0x16, 0x27, 0x9a, 0x91, 0x85, 0x8a, 0xb7, 0xed, 0x79, 0xc3, 0x5d, + 0x72, 0x70, 0x3f, 0x13, 0x11, 0xa4, 0xcb, 0xa9, 0xd, 0x26, 0x0, 0x18, 0x69, 0x54, 0x6, 0xc5, 0xbf, + 0x40, 0x33, 0xe2, 0x14, 0xe1, 0x68, 0x91, 0xf7, 0xa0, 0xb4, 0xee, 0xcc, 0xd5, 0x7, 0xdd, 0x63, 0xbc, + 0x2a, 0xfc, 0x0, 0x10, 0x40, 0xe2, 0x60, 0x68, 0x56, 0xe6, 0x49, 0xbb, 0xdd, 0x96, 0x56, 0x90, 0x1b, + 0x75, 0x56, 0xbf, 0x2, 0x0, 0x0, 0x3a, 0x1, 0x15, 0x0, 0xc, 0xb8, 0xaf, 0x7a, 0xaa, 0x9a, 0xb7, + 0xea, 0x90, 0xe2, 0x97, 0x57, 0xe0, 0x0, 0xa, 0xcf, 0x75, 0xe5, 0xbf, 0x44, 0x6d, 0x36, 0x5d, 0x55, + 0x98, 0x2, 0x0, 0xa, 0x9f, 0xc3, 0x80, 0x1, 0x4b, 0xf3, 0xf8, 0x67, 0x66, 0x7f, 0x0, 0x0, 0x1e, + 0x5b, 0x7b, 0xc7, 0xd6, 0x19, 0x62, 0x8, 0x8c, 0x48, 0x2f, 0x8c, 0x92, 0x13, 0x16, 0x8d, 0xe, 0x68, + 0xfb, 0x94, 0x7, 0x91, 0x1, 0x2a, 0xa0, 0xbe, 0x91, 0x82, 0x44, 0xe, 0x2f, 0x2, 0x0, 0x11, 0xb, + 0x36, 0x2, 0x22, 0x8, 0x25, 0x20, 0xd3, 0xf1, 0xb8, 0xee, 0xea, 0x62, 0xf7, 0xae, 0xb2, 0x77, 0x2, + 0x0, 0x12, 0x9e, 0x8f, 0x9, 0x83, 0xd3, 0xe5, 0x81, 0x2c, 0xea, 0xc1, 0x47, 0x47, 0xce, 0x72, 0xbf, + 0x96, 0xb0, 0x12, 0x0, 0x0, 0x7, 0x36, 0xc3, 0xf1, 0xb8, 0x2f, 0xa8, 0xce, 0x0, 0x0, 0x8, 0x8c, + 0x13, 0x4d, 0xc3, 0xed, 0x10, 0x4f, 0xe7, 0x1}; + + uint8_t buf[239] = {0}; + + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xcf, 0x75, 0xe5, 0xbf, 0x44, 0x6d, 0x36, 0x5d, 0x55, 0x98}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x9f, 0xc3, 0x80, 0x1, 0x4b, 0xf3, 0xf8, 0x67, 0x66, 0x7f}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5b, 0x7b, 0xc7, 0xd6, 0x19, 0x62, 0x8, 0x8c, 0x48, 0x2f, + 0x8c, 0x92, 0x13, 0x16, 0x8d, 0xe, 0x68, 0xfb, 0x94, 0x7, + 0x91, 0x1, 0x2a, 0xa0, 0xbe, 0x91, 0x82, 0x44, 0xe, 0x2f}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb, 0x36, 0x2, 0x22, 0x8, 0x25, 0x20, 0xd3, 0xf1, + 0xb8, 0xee, 0xea, 0x62, 0xf7, 0xae, 0xb2, 0x77}; + lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9e, 0x8f, 0x9, 0x83, 0xd3, 0xe5, 0x81, 0x2c, 0xea, + 0xc1, 0x47, 0x47, 0xce, 0x72, 0xbf, 0x96, 0xb0, 0x12}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x36, 0xc3, 0xf1, 0xb8, 0x2f, 0xa8, 0xce}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8c, 0x13, 0x4d, 0xc3, 0xed, 0x10, 0x4f, 0xe7}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xa6}; + uint8_t bytesprops1[] = {0x23, 0x16, 0x27, 0x9a, 0x91, 0x85, 0x8a, 0xb7, 0xed, 0x79, 0xc3, + 0x5d, 0x72, 0x70, 0x3f, 0x13, 0x11, 0xa4, 0xcb, 0xa9, 0xd}; + uint8_t bytesprops3[] = {0x40, 0xe2, 0x60, 0x68, 0x56, 0xe6, 0x49, 0xbb, + 0xdd, 0x96, 0x56, 0x90, 0x1b, 0x75, 0x56, 0xbf}; + uint8_t bytesprops2[] = {0x69, 0x54, 0x6, 0xc5, 0xbf, 0x40, 0x33, 0xe2, 0x14, 0xe1, 0x68, 0x91, + 0xf7, 0xa0, 0xb4, 0xee, 0xcc, 0xd5, 0x7, 0xdd, 0x63, 0xbc, 0x2a, 0xfc}; + uint8_t bytesprops4[] = {0xb8, 0xaf, 0x7a, 0xaa, 0x9a, 0xb7, 0xea, 0x90, 0xe2, 0x97, 0x57, 0xe0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21066}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7641}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7496}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17133}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28577}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12656}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22660}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29280}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13910}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26843}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops2}, .v = {16, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14849}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19412; - uint8_t client_id_bytes[] = {0xbc, 0x3d, 0xb7, 0x15, 0x10, 0x7e, 0x16, 0xf1}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14533, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\213Z6\DC4\128\136\188%", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "|\RS\164\178\193a", _willMsg = -// "O\197\240\214\DC1$j5y^\EM\222\253+\DC1\147}", _willProps = [PropWillDelayInterval 26708,PropAuthenticationData -// "\164\209\149\&8Y\185',W\171#\230\224\131\re\178\249r",PropReasonString "\217|\nd\175&\237\183",PropContentType -// "3)\ESCM\v\US\201|3\154\135%\GS\144i\194\"\229\255\203l:\230\t\ETB\131\198\233\162",PropMessageExpiryInterval -// 19690,PropAuthenticationMethod "\183\212\249\182\191\138V\253H\t\188X\\",PropReceiveMaximum 27145,PropServerKeepAlive -// 9680,PropReceiveMaximum 22519,PropWillDelayInterval 32057,PropMessageExpiryInterval 18312,PropAuthenticationData -// ",N*\192\229RA\\\129\&7",PropReceiveMaximum 3747,PropRequestResponseInformation 58,PropPayloadFormatIndicator -// 70,PropServerKeepAlive 6129,PropMaximumQoS 105,PropRequestResponseInformation 93,PropReasonString -// "A\147s~\181s\231\213@\169\186\203~\243\188\149T\174q",PropTopicAlias 32116,PropServerKeepAlive -// 25356,PropMaximumPacketSize 1804,PropReasonString "\170Xs"]}), _cleanSession = True, _keepAlive = 19592, _connID = -// "\132\175\ETX\n\219\137\SI\183V\196\219\251\145t\244\200AZ[\156\a\212\252\177\154\245%@\249", _properties = -// [PropAuthenticationData "\149\182P\130\208\190\201\136x",PropMaximumQoS 132,PropAuthenticationData -// "\156I\184p\248\220al8{\255\216c\230L?\215\212\DC3\183<\191\141\128",PropSubscriptionIdentifierAvailable -// 87,PropRetainAvailable 169,PropMaximumPacketSize 25664,PropMessageExpiryInterval 20874,PropRequestResponseInformation -// 27,PropWildcardSubscriptionAvailable 209,PropSubscriptionIdentifierAvailable 223,PropReasonString -// "G\215\RS@\134e\DC3\230\234\225\229\&7",PropMessageExpiryInterval 10633,PropAssignedClientIdentifier -// "k\144~\242\234l2\254\207\148\230>\SYN",PropContentType "\185\233\214\129K\170\211\SO\STX\135\&0u\244 -// ",PropRequestResponseInformation 171,PropMaximumQoS 31]} -TEST(Connect5QCTest, Encode100) { +// SubscribeRequest 1538 +// [("\136v9\252\152\153\179\197P\132F\ETX\176\STX\166RR\222\t\216\163\143\252n\ETB\212",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAssignedClientIdentifier +// "\DC1c1\177\SOHV?\239\218\ESCn\SOHw\209",PropRequestProblemInformation 42,PropServerReference +// "l4\ENQT4\206\180\147\246\133\144\227\196f\246r\156\173\180\185\161\145\ETB",PropTopicAliasMaximum +// 24939,PropSubscriptionIdentifierAvailable 37,PropResponseInformation "_\168\232",PropWillDelayInterval +// 4504,PropContentType "\180\175\DEL\203\188Y\132\218\USV\235\248\DC3\211FW\174\215\&0\145\DC4",PropAuthenticationData +// "\222\129\211\bX\179\228\157\DC2\255W",PropMessageExpiryInterval 29266,PropPayloadFormatIndicator +// 78,PropRequestProblemInformation 39,PropUserProperty "\ETB\219\158\168\n\163\204\231\&6\198\167\136\206\140\132" +// "\235\144\185\206n\202\145\GS\GSr\216Y\233z\235",PropMaximumPacketSize 6755,PropContentType +// "B\198",PropSharedSubscriptionAvailable 221,PropAssignedClientIdentifier +// "\132\186\207sp\139,\148\233\154\137\160",PropTopicAliasMaximum 13715,PropMaximumPacketSize +// 2433,PropSessionExpiryInterval 16981,PropTopicAlias 10270,PropUserProperty +// "\217\SYNH\205\201\163\196\135\237\239z;\167\227\NUL\202\&3\180\132I\199\200 r\156N" +// "\EM\164\182\b\235t&\139\158f\253.\b\ETX\195\219h?w\129\GS\140\141\234",PropPayloadFormatIndicator 167,PropTopicAlias +// 31167,PropMaximumQoS 132,PropWildcardSubscriptionAvailable 6,PropMaximumPacketSize 24806,PropAssignedClientIdentifier +// "",PropSessionExpiryInterval 28383] +TEST(Subscribe5QCTest, Encode98) { uint8_t pkt[] = { - 0x10, 0xf7, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xae, 0x4c, 0x88, 0x76, 0x16, 0x0, 0x9, 0x95, 0xb6, - 0x50, 0x82, 0xd0, 0xbe, 0xc9, 0x88, 0x78, 0x24, 0x84, 0x16, 0x0, 0x18, 0x9c, 0x49, 0xb8, 0x70, 0xf8, 0xdc, 0x61, - 0x6c, 0x38, 0x7b, 0xff, 0xd8, 0x63, 0xe6, 0x4c, 0x3f, 0xd7, 0xd4, 0x13, 0xb7, 0x3c, 0xbf, 0x8d, 0x80, 0x29, 0x57, - 0x25, 0xa9, 0x27, 0x0, 0x0, 0x64, 0x40, 0x2, 0x0, 0x0, 0x51, 0x8a, 0x19, 0x1b, 0x28, 0xd1, 0x29, 0xdf, 0x1f, - 0x0, 0xc, 0x47, 0xd7, 0x1e, 0x40, 0x86, 0x65, 0x13, 0xe6, 0xea, 0xe1, 0xe5, 0x37, 0x2, 0x0, 0x0, 0x29, 0x89, - 0x12, 0x0, 0xd, 0x6b, 0x90, 0x7e, 0xf2, 0xea, 0x6c, 0x32, 0xfe, 0xcf, 0x94, 0xe6, 0x3e, 0x16, 0x3, 0x0, 0xe, - 0xb9, 0xe9, 0xd6, 0x81, 0x4b, 0xaa, 0xd3, 0xe, 0x2, 0x87, 0x30, 0x75, 0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0x40, 0xa9, 0xba, 0xcb, 0x7e, 0xf3, 0xbc, 0x95, 0x54, 0xae, - 0x71, 0x23, 0x7d, 0x74, 0x13, 0x63, 0xc, 0x27, 0x0, 0x0, 0x7, 0xc, 0x1f, 0x0, 0x3, 0xaa, 0x58, 0x73, 0x0, - 0x6, 0x7c, 0x1e, 0xa4, 0xb2, 0xc1, 0x61, 0x0, 0x11, 0x4f, 0xc5, 0xf0, 0xd6, 0x11, 0x24, 0x6a, 0x35, 0x79, 0x5e, - 0x19, 0xde, 0xfd, 0x2b, 0x11, 0x93, 0x7d, 0x0, 0x8, 0xd5, 0x5a, 0x36, 0x14, 0x80, 0x88, 0xbc, 0x25}; - - uint8_t buf[388] = {0}; - - uint8_t bytesprops0[] = {0x95, 0xb6, 0x50, 0x82, 0xd0, 0xbe, 0xc9, 0x88, 0x78}; - uint8_t bytesprops1[] = {0x9c, 0x49, 0xb8, 0x70, 0xf8, 0xdc, 0x61, 0x6c, 0x38, 0x7b, 0xff, 0xd8, - 0x63, 0xe6, 0x4c, 0x3f, 0xd7, 0xd4, 0x13, 0xb7, 0x3c, 0xbf, 0x8d, 0x80}; - uint8_t bytesprops2[] = {0x47, 0xd7, 0x1e, 0x40, 0x86, 0x65, 0x13, 0xe6, 0xea, 0xe1, 0xe5, 0x37}; - uint8_t bytesprops3[] = {0x6b, 0x90, 0x7e, 0xf2, 0xea, 0x6c, 0x32, 0xfe, 0xcf, 0x94, 0xe6, 0x3e, 0x16}; - uint8_t bytesprops4[] = {0xb9, 0xe9, 0xd6, 0x81, 0x4b, 0xaa, 0xd3, 0xe, 0x2, 0x87, 0x30, 0x75, 0xf4, 0x20}; + 0x82, 0xa8, 0x2, 0x6, 0x2, 0x87, 0x2, 0x12, 0x0, 0xe, 0x11, 0x63, 0x31, 0xb1, 0x1, 0x56, 0x3f, 0xef, 0xda, + 0x1b, 0x6e, 0x1, 0x77, 0xd1, 0x17, 0x2a, 0x1c, 0x0, 0x17, 0x6c, 0x34, 0x5, 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c, 0x4e, 0x0, 0x18, 0x19, 0xa4, 0xb6, 0x8, + 0xeb, 0x74, 0x26, 0x8b, 0x9e, 0x66, 0xfd, 0x2e, 0x8, 0x3, 0xc3, 0xdb, 0x68, 0x3f, 0x77, 0x81, 0x1d, 0x8c, 0x8d, + 0xea, 0x1, 0xa7, 0x23, 0x79, 0xbf, 0x24, 0x84, 0x28, 0x6, 0x27, 0x0, 0x0, 0x60, 0xe6, 0x12, 0x0, 0x0, 0x11, + 0x0, 0x0, 0x6e, 0xdf, 0x0, 0x1a, 0x88, 0x76, 0x39, 0xfc, 0x98, 0x99, 0xb3, 0xc5, 0x50, 0x84, 0x46, 0x3, 0xb0, + 0x2, 0xa6, 0x52, 0x52, 0xde, 0x9, 0xd8, 0xa3, 0x8f, 0xfc, 0x6e, 0x17, 0xd4, 0x1}; + + uint8_t buf[309] = {0}; + + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x88, 0x76, 0x39, 0xfc, 0x98, 0x99, 0xb3, 0xc5, 0x50, 0x84, 0x46, 0x3, 0xb0, + 0x2, 0xa6, 0x52, 0x52, 0xde, 0x9, 0xd8, 0xa3, 0x8f, 0xfc, 0x6e, 0x17, 0xd4}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x11, 0x63, 0x31, 0xb1, 0x1, 0x56, 0x3f, 0xef, 0xda, 0x1b, 0x6e, 0x1, 0x77, 0xd1}; + uint8_t bytesprops1[] = {0x6c, 0x34, 0x5, 0x54, 0x34, 0xce, 0xb4, 0x93, 0xf6, 0x85, 0x90, 0xe3, + 0xc4, 0x66, 0xf6, 0x72, 0x9c, 0xad, 0xb4, 0xb9, 0xa1, 0x91, 0x17}; + uint8_t bytesprops2[] = {0x5f, 0xa8, 0xe8}; + uint8_t bytesprops3[] = {0xb4, 0xaf, 0x7f, 0xcb, 0xbc, 0x59, 0x84, 0xda, 0x1f, 0x56, 0xeb, + 0xf8, 0x13, 0xd3, 0x46, 0x57, 0xae, 0xd7, 0x30, 0x91, 0x14}; + uint8_t bytesprops4[] = {0xde, 0x81, 0xd3, 0x8, 0x58, 0xb3, 0xe4, 0x9d, 0x12, 0xff, 0x57}; + uint8_t bytesprops6[] = {0xeb, 0x90, 0xb9, 0xce, 0x6e, 0xca, 0x91, 0x1d, 0x1d, 0x72, 0xd8, 0x59, 0xe9, 0x7a, 0xeb}; + uint8_t bytesprops5[] = {0x17, 0xdb, 0x9e, 0xa8, 0xa, 0xa3, 0xcc, 0xe7, 0x36, 0xc6, 0xa7, 0x88, 0xce, 0x8c, 0x84}; + uint8_t bytesprops7[] = {0x42, 0xc6}; + uint8_t bytesprops8[] = {0x84, 0xba, 0xcf, 0x73, 0x70, 0x8b, 0x2c, 0x94, 0xe9, 0x9a, 0x89, 0xa0}; + uint8_t bytesprops10[] = {0x19, 0xa4, 0xb6, 0x8, 0xeb, 0x74, 0x26, 0x8b, 0x9e, 0x66, 0xfd, 0x2e, + 0x8, 0x3, 0xc3, 0xdb, 0x68, 0x3f, 0x77, 0x81, 0x1d, 0x8c, 0x8d, 0xea}; + uint8_t bytesprops9[] = {0xd9, 0x16, 0x48, 0xcd, 0xc9, 0xa3, 0xc4, 0x87, 0xed, 0xef, 0x7a, 0x3b, 0xa7, + 0xe3, 0x0, 0xca, 0x33, 0xb4, 0x84, 0x49, 0xc7, 0xc8, 0x20, 0x72, 0x9c, 0x4e}; + uint8_t bytesprops11[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24939}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4504}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29266}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops5}, .v = {15, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6755}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13715}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2433}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16981}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10270}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops9}, .v = {24, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31167}}, {.prop = (lwmqtt_prop_t)36, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25664}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20874}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10633}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24806}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28383}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xa4, 0xd1, 0x95, 0x38, 0x59, 0xb9, 0x27, 0x2c, 0x57, 0xab, - 0x23, 0xe6, 0xe0, 0x83, 0xd, 0x65, 0xb2, 0xf9, 0x72}; - uint8_t byteswillprops1[] = {0xd9, 0x7c, 0xa, 0x64, 0xaf, 0x26, 0xed, 0xb7}; - uint8_t byteswillprops2[] = {0x33, 0x29, 0x1b, 0x4d, 0xb, 0x1f, 0xc9, 0x7c, 0x33, 0x9a, 0x87, 0x25, 0x1d, 0x90, 0x69, - 0xc2, 0x22, 0xe5, 0xff, 0xcb, 0x6c, 0x3a, 0xe6, 0x9, 0x17, 0x83, 0xc6, 0xe9, 0xa2}; - uint8_t byteswillprops3[] = {0xb7, 0xd4, 0xf9, 0xb6, 0xbf, 0x8a, 0x56, 0xfd, 0x48, 0x9, 0xbc, 0x58, 0x5c}; - uint8_t byteswillprops4[] = {0x2c, 0x4e, 0x2a, 0xc0, 0xe5, 0x52, 0x41, 0x5c, 0x81, 0x37}; - uint8_t byteswillprops5[] = {0x41, 0x93, 0x73, 0x7e, 0xb5, 0x73, 0xe7, 0xd5, 0x40, 0xa9, - 0xba, 0xcb, 0x7e, 0xf3, 0xbc, 0x95, 0x54, 0xae, 0x71}; - uint8_t byteswillprops6[] = {0xaa, 0x58, 0x73}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1538, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 22336 [("\239\178\194.\198\235(\167c\190\ETX\155\184\185\245\170}\US\231$\149\255\212",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("3\STXm\179%\DLE\247O\NULI\CAN\t\180\147\136\133\176\195[r\158\131\b\SOE\SYN\139\163\154",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\225\235\137\179 ",PropRequestProblemInformation 71,PropTopicAlias 23140,PropTopicAliasMaximum +// 1797,PropMaximumPacketSize 22929,PropMaximumQoS 129,PropRetainAvailable 26,PropServerReference +// "]\140\148e\196yn\218+U\DEL\DC3\153P\EOT\131fk\EOT",PropReasonString "\136\&9gq\194-",PropSharedSubscriptionAvailable +// 175,PropRequestProblemInformation 36,PropCorrelationData +// "\ESC-\165\237\149\204q\219\"\138u(\249>\SYN\186==\248\155(\254\SUB\139"] +TEST(Subscribe5QCTest, Encode99) { + uint8_t pkt[] = { + 0x82, 0xbc, 0x3, 0x57, 0x40, 0xaa, 0x2, 0x16, 0x0, 0x1b, 0xc9, 0xde, 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, 0x4e, 0xa1, 0xa2, 0xd9, 0x1, 0x0, 0x1d, 0xc0, 0xf8, 0x5a, 0xd9, 0xab, 0x3, + 0xdc, 0x75, 0x15, 0x75, 0x8, 0x37, 0x2, 0x28, 0x81, 0x13, 0x1c, 0xdf, 0x68, 0xc3, 0xc2, 0x88, 0x7, 0x40, 0x1a, + 0x39, 0x6c, 0x6f, 0xfb, 0x0, 0x0, 0x15, 0xfc, 0x93, 0xbf, 0xa0, 0xb0, 0x70, 0x9, 0x71, 0x83, 0x9f, 0x9c, 0x58, + 0x98, 0x3c, 0xa8, 0x8d, 0x8c, 0xe5, 0x2a, 0xc4, 0x5b, 0x2}; + + uint8_t buf[457] = {0}; + + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xef, 0xb2, 0xc2, 0x2e, 0xc6, 0xeb, 0x28, 0xa7, 0x63, 0xbe, 0x3, 0x9b, + 0xb8, 0xb9, 0xf5, 0xaa, 0x7d, 0x1f, 0xe7, 0x24, 0x95, 0xff, 0xd4}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x33, 0x2, 0x6d, 0xb3, 0x25, 0x10, 0xf7, 0x4f, 0x0, 0x49, + 0x18, 0x9, 0xb4, 0x93, 0x88, 0x85, 0xb0, 0xc3, 0x5b, 0x72, + 0x9e, 0x83, 0x8, 0xe, 0x45, 0x16, 0x8b, 0xa3, 0x9a}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe1, 0xeb, 0x89, 0x3c, 0x53, 0x7f, 0x34, 0xf5, 0xdd, 0x61, 0x44, 0xa7, 0x65, + 0xa, 0xb, 0xdb, 0x9c, 0x22, 0x16, 0x49, 0x4b, 0x4e, 0xa1, 0xa2, 0xd9}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc0, 0xf8, 0x5a, 0xd9, 0xab, 0x3, 0xdc, 0x75, 0x15, 0x75, + 0x8, 0x37, 0x2, 0x28, 0x81, 0x13, 0x1c, 0xdf, 0x68, 0xc3, + 0xc2, 0x88, 0x7, 0x40, 0x1a, 0x39, 0x6c, 0x6f, 0xfb}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xfc, 0x93, 0xbf, 0xa0, 0xb0, 0x70, 0x9, 0x71, 0x83, 0x9f, 0x9c, + 0x58, 0x98, 0x3c, 0xa8, 0x8d, 0x8c, 0xe5, 0x2a, 0xc4, 0x5b}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0xc9, 0xde, 0xc8, 0xe, 0xe0, 0x20, 0xe6, 0x82, 0x78, 0xf9, 0x89, 0xcc, 0x5b, 0x5d, + 0x85, 0xf2, 0x68, 0x26, 0x42, 0xb0, 0x5e, 0x55, 0x96, 0x7f, 0x41, 0x2d, 0x33}; + uint8_t bytesprops1[] = {0xd4, 0xcd, 0x7e, 0x2a, 0x7a, 0x11, 0x9d, 0x0, 0xd, + 0x23, 0xd1, 0xb, 0x8c, 0x67, 0x10, 0x2c, 0xdb}; + uint8_t bytesprops2[] = {0xb9, 0x8, 0x18, 0xd3, 0x72, 0x19, 0x42, 0xbc, 0x23, 0x46, 0x7c, + 0x5, 0x1f, 0x1b, 0x4, 0x65, 0x63, 0x27, 0x89, 0x77, 0xb9, 0xa9}; + uint8_t bytesprops3[] = {0x64, 0x86, 0x45, 0xbd}; + uint8_t bytesprops4[] = {0x3d, 0xa9, 0x2e, 0x5e, 0x62, 0xe2, 0x82, 0xec, 0xd5, 0xce, 0x58, + 0x37, 0x83, 0x29, 0xec, 0x45, 0x64, 0x5b, 0xf3, 0x7b, 0x57}; + uint8_t bytesprops5[] = {0xbc, 0x55, 0x1e, 0xf3, 0x89, 0xd8, 0xa1, 0xb9, 0xf7, 0xde, + 0xec, 0x32, 0xa0, 0x6a, 0xd1, 0x1d, 0x17, 0xf1, 0xba, 0xb5}; + uint8_t bytesprops6[] = {0x59, 0x53, 0xdd, 0x5b, 0x7f, 0x50, 0xc8, 0x9c, 0x32}; + uint8_t bytesprops7[] = {0x1d, 0xe3, 0x70, 0xe1, 0xcc, 0x12, 0xee, 0xcf, 0x95, 0x47, 0xcc, 0x34, 0xf, 0x5d, + 0x2d, 0x32, 0x5b, 0x56, 0x2b, 0x54, 0xd1, 0xa0, 0x44, 0xd2, 0x38, 0xf6, 0x5f, 0x39}; + uint8_t bytesprops8[] = {0x5f, 0x42, 0xe2, 0xed, 0xcc, 0xbc, 0x36, 0x22, 0x27, 0x5d, 0x3e, 0xb3, 0x20}; + uint8_t bytesprops9[] = {0x5d, 0x8c, 0x94, 0x65, 0xc4, 0x79, 0x6e, 0xda, 0x2b, 0x55, + 0x7f, 0x13, 0x99, 0x50, 0x4, 0x83, 0x66, 0x6b, 0x4}; + uint8_t bytesprops10[] = {0x88, 0x39, 0x67, 0x71, 0xc2, 0x2d}; + uint8_t bytesprops11[] = {0x1b, 0x2d, 0xa5, 0xed, 0x95, 0xcc, 0x71, 0xdb, 0x22, 0x8a, 0x75, 0x28, + 0xf9, 0x3e, 0x16, 0xba, 0x3d, 0x3d, 0xf8, 0x9b, 0x28, 0xfe, 0x1a, 0x8b}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26708}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19690}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27145}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9680}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22519}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32057}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18312}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3747}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6129}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32116}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25356}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1804}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops6}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32231}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5414}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31183}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27120}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23005}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23140}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1797}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22929}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t willprops = {23, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x7c, 0x1e, 0xa4, 0xb2, 0xc1, 0x61}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4f, 0xc5, 0xf0, 0xd6, 0x11, 0x24, 0x6a, 0x35, 0x79, - 0x5e, 0x19, 0xde, 0xfd, 0x2b, 0x11, 0x93, 0x7d}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 19592; - uint8_t client_id_bytes[] = {0x84, 0xaf, 0x3, 0xa, 0xdb, 0x89, 0xf, 0xb7, 0x56, 0xc4, 0xdb, 0xfb, 0x91, 0x74, 0xf4, - 0xc8, 0x41, 0x5a, 0x5b, 0x9c, 0x7, 0xd4, 0xfc, 0xb1, 0x9a, 0xf5, 0x25, 0x40, 0xf9}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xd5, 0x5a, 0x36, 0x14, 0x80, 0x88, 0xbc, 0x25}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22336, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 13807 [("wL\191\189\221|G\238\226$\136\tIp\SO\n\STX\165, \246K\185U\237\\",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("T\FS\235=\v;\128q\152\153}\"U[\178",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\184\150",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\190\236)\ENQ@h\184\224\&0",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("j\178B\166\172b\202\203P\STX,'\174\145\243o>\197\223\157\229|5\SOH\220\&94\241",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("BR\DLEz\176\178\218\206\141\160\252]Y\170\218\142\167\ETX\204\229=\r\255UWG",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\144\229\227)\143\168?\194\171\204\212\138\180\ETX\176\GS+\SO\254C>bp\150\184\247\144\231 ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\222CJ\178\&0\215~\186\&5\STX/\241\178\136H\207\"",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerKeepAlive 18605,PropMaximumQoS +// 231,PropResponseInformation "\249\200",PropResponseInformation "J\246\210\198k\185wX",PropRetainAvailable +// 78,PropTopicAliasMaximum 17928,PropSubscriptionIdentifierAvailable 87] +TEST(Subscribe5QCTest, Encode100) { + uint8_t pkt[] = {0x82, 0xcf, 0x1, 0x35, 0xef, 0x1c, 0x13, 0x48, 0xad, 0x24, 0xe7, 0x1a, 0x0, 0x2, 0xf9, 0xc8, 0x1a, + 0x0, 0x8, 0x4a, 0xf6, 0xd2, 0xc6, 0x6b, 0xb9, 0x77, 0x58, 0x25, 0x4e, 0x22, 0x46, 0x8, 0x29, 0x57, + 0x0, 0x1a, 0x77, 0x4c, 0xbf, 0xbd, 0xdd, 0x7c, 0x47, 0xee, 0xe2, 0x24, 0x88, 0x9, 0x49, 0x70, 0xe, + 0xa, 0x2, 0xa5, 0x2c, 0x20, 0xf6, 0x4b, 0xb9, 0x55, 0xed, 0x5c, 0x0, 0x0, 0xf, 0x54, 0x1c, 0xeb, + 0x3d, 0xb, 0x3b, 0x80, 0x71, 0x98, 0x99, 0x7d, 0x22, 0x55, 0x5b, 0xb2, 0x1, 0x0, 0x2, 0xb8, 0x96, + 0x1, 0x0, 0x9, 0xbe, 0xec, 0x29, 0x5, 0x40, 0x68, 0xb8, 0xe0, 0x30, 0x1, 0x0, 0x1c, 0x6a, 0xb2, + 0x42, 0xa6, 0xac, 0x62, 0xca, 0xcb, 0x50, 0x2, 0x2c, 0x27, 0xae, 0x91, 0xf3, 0x6f, 0x3e, 0xc5, 0xdf, + 0x9d, 0xe5, 0x7c, 0x35, 0x1, 0xdc, 0x39, 0x34, 0xf1, 0x2, 0x0, 0x1a, 0x42, 0x52, 0x10, 0x7a, 0xb0, + 0xb2, 0xda, 0xce, 0x8d, 0xa0, 0xfc, 0x5d, 0x59, 0xaa, 0xda, 0x8e, 0xa7, 0x3, 0xcc, 0xe5, 0x3d, 0xd, + 0xff, 0x55, 0x57, 0x47, 0x1, 0x0, 0x1d, 0x90, 0xe5, 0xe3, 0x29, 0x8f, 0xa8, 0x3f, 0xc2, 0xab, 0xcc, + 0xd4, 0x8a, 0xb4, 0x3, 0xb0, 0x1d, 0x2b, 0xe, 0xfe, 0x43, 0x3e, 0x62, 0x70, 0x96, 0xb8, 0xf7, 0x90, + 0xe7, 0x20, 0x2, 0x0, 0x11, 0xde, 0x43, 0x4a, 0xb2, 0x30, 0xd7, 0x7e, 0xba, 0x35, 0x2, 0x2f, 0xf1, + 0xb2, 0x88, 0x48, 0xcf, 0x22, 0x1}; + + uint8_t buf[220] = {0}; + + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x77, 0x4c, 0xbf, 0xbd, 0xdd, 0x7c, 0x47, 0xee, 0xe2, 0x24, 0x88, 0x9, 0x49, + 0x70, 0xe, 0xa, 0x2, 0xa5, 0x2c, 0x20, 0xf6, 0x4b, 0xb9, 0x55, 0xed, 0x5c}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x54, 0x1c, 0xeb, 0x3d, 0xb, 0x3b, 0x80, 0x71, + 0x98, 0x99, 0x7d, 0x22, 0x55, 0x5b, 0xb2}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb8, 0x96}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xbe, 0xec, 0x29, 0x5, 0x40, 0x68, 0xb8, 0xe0, 0x30}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x6a, 0xb2, 0x42, 0xa6, 0xac, 0x62, 0xca, 0xcb, 0x50, 0x2, 0x2c, 0x27, 0xae, 0x91, + 0xf3, 0x6f, 0x3e, 0xc5, 0xdf, 0x9d, 0xe5, 0x7c, 0x35, 0x1, 0xdc, 0x39, 0x34, 0xf1}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x42, 0x52, 0x10, 0x7a, 0xb0, 0xb2, 0xda, 0xce, 0x8d, 0xa0, 0xfc, 0x5d, 0x59, + 0xaa, 0xda, 0x8e, 0xa7, 0x3, 0xcc, 0xe5, 0x3d, 0xd, 0xff, 0x55, 0x57, 0x47}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x90, 0xe5, 0xe3, 0x29, 0x8f, 0xa8, 0x3f, 0xc2, 0xab, 0xcc, + 0xd4, 0x8a, 0xb4, 0x3, 0xb0, 0x1d, 0x2b, 0xe, 0xfe, 0x43, + 0x3e, 0x62, 0x70, 0x96, 0xb8, 0xf7, 0x90, 0xe7, 0x20}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xde, 0x43, 0x4a, 0xb2, 0x30, 0xd7, 0x7e, 0xba, 0x35, + 0x2, 0x2f, 0xf1, 0xb2, 0x88, 0x48, 0xcf, 0x22}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xf9, 0xc8}; + uint8_t bytesprops1[] = {0x4a, 0xf6, 0xd2, 0xc6, 0x6b, 0xb9, 0x77, 0x58}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18605}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17928}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 87}}, + }; + + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13807, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); From 067650b8dafe7c48731a15ff1d28e1b08a65850a Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 18 Sep 2019 12:58:57 -0700 Subject: [PATCH 10/26] Test decoding publish messages. --- gentests/app/Main.hs | 73 +- tests/generated.cpp | 21223 ++++++++--------------------------------- 2 files changed, 4183 insertions(+), 17113 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index cab4906..38159de 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -153,28 +153,59 @@ genPublishTest :: ProtocolLevel -> Int -> PublishRequest -> IO () genPublishTest prot i p@PublishRequest{..} = do let e = toByteString prot p - putStrLn $ "// " <> show p - putStrLn $ "TEST(Publish" <> shortprot prot <> "QCTest, Encode" <> show i <> ") {" - putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" + encTest e + decTest e - putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" + where + encTest e = do + putStrLn $ "// " <> show p + putStrLn $ "TEST(Publish" <> shortprot prot <> "QCTest, Encode" <> show i <> ") {" + putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" + + putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" + + putStrLn . mconcat $ [ + encodeString "topic" _pubTopic, + " lwmqtt_message_t msg = lwmqtt_default_message;\n", + " msg.qos = " <> qos _pubQoS <> ";\n", + " msg.retained = " <> bool _pubRetain <> ";\n", + " uint8_t msg_bytes[] = {" <> hexa _pubBody <> "};\n", + " msg.payload = (unsigned char*)&msg_bytes;\n", + " msg.payload_len = " <> show (BL.length _pubBody) <> ";\n\n", + genProperties "props" _pubProps, + " size_t len = 0;\n", + " lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, " <> protlvl prot <> ", ", + bool _pubDup, ", ", show _pubPktID, ", topic, msg, props);\n\n", + " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + " EXPECT_ARRAY_EQ(pkt, buf, len);", + "}\n" + ] + + decTest e = do + putStrLn . mconcat $ [ + "// ", show p, "\n", + "TEST(Publish" <> shortprot prot <> "QCTest, Decode" <> show i <> ") {\n", + "uint8_t pkt[] = {" <> hexa e <> "};\n", + "bool dup;\n", + "uint16_t packet_id;\n", + "lwmqtt_string_t topic;\n", + "lwmqtt_message_t msg;\n", + "lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), ", protlvl prot, ", &dup, &packet_id, &topic, &msg);\n", + "\n", + "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + encodeString "exp_topic" _pubTopic, + encodeString "exp_body" _pubBody, + "EXPECT_EQ(dup, ", bool _pubDup, ");\n", + "EXPECT_EQ(msg.qos, ", qos _pubQoS, ");\n", + "EXPECT_EQ(msg.retained, ", bool _pubRetain, ");\n", + "EXPECT_EQ(packet_id, ", show _pubPktID, ");\n", + "EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), ", show (BL.length _pubTopic), ");\n", + "EXPECT_EQ(msg.payload_len, ", show (BL.length _pubBody), ");\n", + "EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, ", show (BL.length _pubBody), ");\n", + "lwmqtt_string_t x = exp_topic;\nx = exp_body;\n", + "}\n" + ] - putStrLn . mconcat $ [ - encodeString "topic" _pubTopic, - " lwmqtt_message_t msg = lwmqtt_default_message;\n", - " msg.qos = " <> qos _pubQoS <> ";\n", - " msg.retained = " <> bool _pubRetain <> ";\n", - " uint8_t msg_bytes[] = {" <> hexa _pubBody <> "};\n", - " msg.payload = (unsigned char*)&msg_bytes;\n", - " msg.payload_len = " <> show (BL.length _pubBody) <> ";\n\n", - genProperties "props" _pubProps, - " size_t len = 0;\n", - " lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, " <> protlvl prot <> ", ", - bool _pubDup, ", ", show _pubPktID, ", topic, msg, props);\n\n", - " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", - " EXPECT_ARRAY_EQ(pkt, buf, len);" - ] - putStrLn "}\n" genSubTest :: ProtocolLevel -> Int -> SubscribeRequest -> IO () genSubTest prot i p@(SubscribeRequest pid subs props) = do @@ -300,6 +331,6 @@ extern "C" { mapM_ (uncurry $ genConnectTest Protocol311) $ zip [1..] (userFix . v311ConnReq <$> conns) mapM_ (uncurry $ genConnectTest Protocol50) $ zip [1..] (userFix <$> conns) - subs <- replicateM 100 $ generate arbitrary + subs <- replicateM numTests $ generate arbitrary mapM_ (uncurry $ genSubTest Protocol311) $ zip [1..] (v311SubReq <$> subs) mapM_ (uncurry $ genSubTest Protocol50) $ zip [1..] (simplifySubOptions <$> subs) diff --git a/tests/generated.cpp b/tests/generated.cpp index 218a2f5..1d76ce6 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,226 +21,436 @@ extern "C" { } \ } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\164\&3g\145", _pubPktID = 25063, -// _pubBody = "s\178\237\US", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\181m\255\144\250L\DC3iF\146\ACK\157\198\202\ACK\176\195z\141\216e\SYN\176", _pubPktID = 5540, _pubBody = "-\222", +// _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x3c, 0xc, 0x0, 0x4, 0xa4, 0x33, 0x67, 0x91, 0x61, 0xe7, 0x73, 0xb2, 0xed, 0x1f}; + uint8_t pkt[] = {0x3d, 0x1d, 0x0, 0x17, 0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, + 0xc6, 0xca, 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0, 0x15, 0xa4, 0x2d, 0xde}; - uint8_t buf[24] = {0}; + uint8_t buf[41] = {0}; - uint8_t topic_bytes[] = {0xa4, 0x33, 0x67, 0x91}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, + 0xc6, 0xca, 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x73, 0xb2, 0xed, 0x1f}; + msg.retained = true; + uint8_t msg_bytes[] = {0x2d, 0xde}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 2; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25063, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5540, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\213\SUB", _pubPktID = 13464, -// _pubBody = "o\ETBQD}\r\r\192J-\226\"\219Q\SO\244\182!", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\181m\255\144\250L\DC3iF\146\ACK\157\198\202\ACK\176\195z\141\216e\SYN\176", _pubPktID = 5540, _pubBody = "-\222", +// _pubProps = []} +TEST(Publish311QCTest, Decode1) { + uint8_t pkt[] = {0x3d, 0x1d, 0x0, 0x17, 0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, + 0xc6, 0xca, 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0, 0x15, 0xa4, 0x2d, 0xde}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, + 0xc6, 0xca, 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2d, 0xde}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 5540); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "|5\229o-\r\179\163\252\150\208^\255(\140Y+\a\226xNy\RS\200\237\233\&5\214", _pubPktID = 0, _pubBody = +// "/\130\238\202\224\230", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x3a, 0x18, 0x0, 0x2, 0xd5, 0x1a, 0x34, 0x98, 0x6f, 0x17, 0x51, 0x44, 0x7d, - 0xd, 0xd, 0xc0, 0x4a, 0x2d, 0xe2, 0x22, 0xdb, 0x51, 0xe, 0xf4, 0xb6, 0x21}; + uint8_t pkt[] = {0x39, 0x24, 0x0, 0x1c, 0x7c, 0x35, 0xe5, 0x6f, 0x2d, 0xd, 0xb3, 0xa3, 0xfc, + 0x96, 0xd0, 0x5e, 0xff, 0x28, 0x8c, 0x59, 0x2b, 0x7, 0xe2, 0x78, 0x4e, 0x79, + 0x1e, 0xc8, 0xed, 0xe9, 0x35, 0xd6, 0x2f, 0x82, 0xee, 0xca, 0xe0, 0xe6}; - uint8_t buf[36] = {0}; + uint8_t buf[48] = {0}; - uint8_t topic_bytes[] = {0xd5, 0x1a}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x7c, 0x35, 0xe5, 0x6f, 0x2d, 0xd, 0xb3, 0xa3, 0xfc, 0x96, 0xd0, 0x5e, 0xff, 0x28, + 0x8c, 0x59, 0x2b, 0x7, 0xe2, 0x78, 0x4e, 0x79, 0x1e, 0xc8, 0xed, 0xe9, 0x35, 0xd6}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x6f, 0x17, 0x51, 0x44, 0x7d, 0xd, 0xd, 0xc0, 0x4a, - 0x2d, 0xe2, 0x22, 0xdb, 0x51, 0xe, 0xf4, 0xb6, 0x21}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x2f, 0x82, 0xee, 0xca, 0xe0, 0xe6}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 6; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13464, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "^\128\189\159\\k\153Q\222\207%\t\157-\238\240l\DLE&\ESC\220\&5\201yk\184\SO", _pubPktID = 18950, _pubBody = -// "\186\231\&1`\228\223^\203\149L\134\175o\ENQ-b\212\170\128\244\t}", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "|5\229o-\r\179\163\252\150\208^\255(\140Y+\a\226xNy\RS\200\237\233\&5\214", _pubPktID = 0, _pubBody = +// "/\130\238\202\224\230", _pubProps = []} +TEST(Publish311QCTest, Decode2) { + uint8_t pkt[] = {0x39, 0x24, 0x0, 0x1c, 0x7c, 0x35, 0xe5, 0x6f, 0x2d, 0xd, 0xb3, 0xa3, 0xfc, + 0x96, 0xd0, 0x5e, 0xff, 0x28, 0x8c, 0x59, 0x2b, 0x7, 0xe2, 0x78, 0x4e, 0x79, + 0x1e, 0xc8, 0xed, 0xe9, 0x35, 0xd6, 0x2f, 0x82, 0xee, 0xca, 0xe0, 0xe6}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7c, 0x35, 0xe5, 0x6f, 0x2d, 0xd, 0xb3, 0xa3, 0xfc, 0x96, 0xd0, 0x5e, 0xff, 0x28, + 0x8c, 0x59, 0x2b, 0x7, 0xe2, 0x78, 0x4e, 0x79, 0x1e, 0xc8, 0xed, 0xe9, 0x35, 0xd6}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2f, 0x82, 0xee, 0xca, 0xe0, 0xe6}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "#s+\243\184\144t\234lj\248\SO=\182TOG$\130\135YOE+\204", _pubPktID = 9717, _pubBody = "\n}\168", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x3c, 0x35, 0x0, 0x1b, 0x5e, 0x80, 0xbd, 0x9f, 0x5c, 0x6b, 0x99, 0x51, 0xde, 0xcf, - 0x25, 0x9, 0x9d, 0x2d, 0xee, 0xf0, 0x6c, 0x10, 0x26, 0x1b, 0xdc, 0x35, 0xc9, 0x79, - 0x6b, 0xb8, 0xe, 0x4a, 0x6, 0xba, 0xe7, 0x31, 0x60, 0xe4, 0xdf, 0x5e, 0xcb, 0x95, - 0x4c, 0x86, 0xaf, 0x6f, 0x5, 0x2d, 0x62, 0xd4, 0xaa, 0x80, 0xf4, 0x9, 0x7d}; + uint8_t pkt[] = {0x35, 0x20, 0x0, 0x19, 0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, + 0x6c, 0x6a, 0xf8, 0xe, 0x3d, 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, + 0x59, 0x4f, 0x45, 0x2b, 0xcc, 0x25, 0xf5, 0xa, 0x7d, 0xa8}; - uint8_t buf[65] = {0}; + uint8_t buf[44] = {0}; - uint8_t topic_bytes[] = {0x5e, 0x80, 0xbd, 0x9f, 0x5c, 0x6b, 0x99, 0x51, 0xde, 0xcf, 0x25, 0x9, 0x9d, 0x2d, - 0xee, 0xf0, 0x6c, 0x10, 0x26, 0x1b, 0xdc, 0x35, 0xc9, 0x79, 0x6b, 0xb8, 0xe}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, 0x3d, + 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xba, 0xe7, 0x31, 0x60, 0xe4, 0xdf, 0x5e, 0xcb, 0x95, 0x4c, 0x86, - 0xaf, 0x6f, 0x5, 0x2d, 0x62, 0xd4, 0xaa, 0x80, 0xf4, 0x9, 0x7d}; + msg.retained = true; + uint8_t msg_bytes[] = {0xa, 0x7d, 0xa8}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 3; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 18950, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 9717, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\152\SUBq2\SOH\150", _pubPktID = -// 6631, _pubBody = "p\177\185\198Z\188\203\EOT\\\211>c\165\219\215U\r,", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "#s+\243\184\144t\234lj\248\SO=\182TOG$\130\135YOE+\204", _pubPktID = 9717, _pubBody = "\n}\168", _pubProps = []} +TEST(Publish311QCTest, Decode3) { + uint8_t pkt[] = {0x35, 0x20, 0x0, 0x19, 0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, + 0x6c, 0x6a, 0xf8, 0xe, 0x3d, 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, + 0x59, 0x4f, 0x45, 0x2b, 0xcc, 0x25, 0xf5, 0xa, 0x7d, 0xa8}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, 0x3d, + 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa, 0x7d, 0xa8}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 9717); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\173\179\129=\155\186E\131\242g\224\149\&5\f\ESCk\250\130", _pubPktID = 696, _pubBody = +// "\210\212B\245\204\143IYw\217p\214\&5\152\133@\ETB{\FS\238\226", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x3a, 0x1c, 0x0, 0x6, 0x98, 0x1a, 0x71, 0x32, 0x1, 0x96, 0x19, 0xe7, 0x70, 0xb1, 0xb9, - 0xc6, 0x5a, 0xbc, 0xcb, 0x4, 0x5c, 0xd3, 0x3e, 0x63, 0xa5, 0xdb, 0xd7, 0x55, 0xd, 0x2c}; + uint8_t pkt[] = {0x33, 0x2b, 0x0, 0x12, 0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, 0x67, 0xe0, + 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82, 0x2, 0xb8, 0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, + 0x49, 0x59, 0x77, 0xd9, 0x70, 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; - uint8_t buf[40] = {0}; + uint8_t buf[55] = {0}; - uint8_t topic_bytes[] = {0x98, 0x1a, 0x71, 0x32, 0x1, 0x96}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, + 0x67, 0xe0, 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x70, 0xb1, 0xb9, 0xc6, 0x5a, 0xbc, 0xcb, 0x4, 0x5c, - 0xd3, 0x3e, 0x63, 0xa5, 0xdb, 0xd7, 0x55, 0xd, 0x2c}; + msg.retained = true; + uint8_t msg_bytes[] = {0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, 0x77, 0xd9, 0x70, + 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6631, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 696, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// ",=;\135\178\237\227\194~\130\190\147}\190\249wf\151\200\SI\170fO", _pubPktID = 22051, _pubBody = -// "\fJ\139u\132\RS\170\170\v\DC3\148\&2\213!,\174A\170\235~\144/\200", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\173\179\129=\155\186E\131\242g\224\149\&5\f\ESCk\250\130", _pubPktID = 696, _pubBody = +// "\210\212B\245\204\143IYw\217p\214\&5\152\133@\ETB{\FS\238\226", _pubProps = []} +TEST(Publish311QCTest, Decode4) { + uint8_t pkt[] = {0x33, 0x2b, 0x0, 0x12, 0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, 0x67, 0xe0, + 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82, 0x2, 0xb8, 0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, + 0x49, 0x59, 0x77, 0xd9, 0x70, 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, + 0x67, 0xe0, 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, 0x77, 0xd9, 0x70, + 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 696); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "!\189a\ENQ\235r\186\232?!\140O>\201\220\163\133\166!\139i", _pubPktID = 0, _pubBody = +// "\249\159L\166\132\147`Q\206\238\229\138\217\DEL\219\t\243\131\192H\SIJ\168@y", _pubProps = []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x3b, 0x32, 0x0, 0x17, 0x2c, 0x3d, 0x3b, 0x87, 0xb2, 0xed, 0xe3, 0xc2, 0x7e, - 0x82, 0xbe, 0x93, 0x7d, 0xbe, 0xf9, 0x77, 0x66, 0x97, 0xc8, 0xf, 0xaa, 0x66, - 0x4f, 0x56, 0x23, 0xc, 0x4a, 0x8b, 0x75, 0x84, 0x1e, 0xaa, 0xaa, 0xb, 0x13, - 0x94, 0x32, 0xd5, 0x21, 0x2c, 0xae, 0x41, 0xaa, 0xeb, 0x7e, 0x90, 0x2f, 0xc8}; + uint8_t pkt[] = {0x38, 0x30, 0x0, 0x15, 0x21, 0xbd, 0x61, 0x5, 0xeb, 0x72, 0xba, 0xe8, 0x3f, 0x21, 0x8c, 0x4f, 0x3e, + 0xc9, 0xdc, 0xa3, 0x85, 0xa6, 0x21, 0x8b, 0x69, 0xf9, 0x9f, 0x4c, 0xa6, 0x84, 0x93, 0x60, 0x51, 0xce, + 0xee, 0xe5, 0x8a, 0xd9, 0x7f, 0xdb, 0x9, 0xf3, 0x83, 0xc0, 0x48, 0xf, 0x4a, 0xa8, 0x40, 0x79}; - uint8_t buf[62] = {0}; + uint8_t buf[60] = {0}; - uint8_t topic_bytes[] = {0x2c, 0x3d, 0x3b, 0x87, 0xb2, 0xed, 0xe3, 0xc2, 0x7e, 0x82, 0xbe, 0x93, - 0x7d, 0xbe, 0xf9, 0x77, 0x66, 0x97, 0xc8, 0xf, 0xaa, 0x66, 0x4f}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x21, 0xbd, 0x61, 0x5, 0xeb, 0x72, 0xba, 0xe8, 0x3f, 0x21, 0x8c, + 0x4f, 0x3e, 0xc9, 0xdc, 0xa3, 0x85, 0xa6, 0x21, 0x8b, 0x69}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xc, 0x4a, 0x8b, 0x75, 0x84, 0x1e, 0xaa, 0xaa, 0xb, 0x13, 0x94, 0x32, - 0xd5, 0x21, 0x2c, 0xae, 0x41, 0xaa, 0xeb, 0x7e, 0x90, 0x2f, 0xc8}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xf9, 0x9f, 0x4c, 0xa6, 0x84, 0x93, 0x60, 0x51, 0xce, 0xee, 0xe5, 0x8a, 0xd9, + 0x7f, 0xdb, 0x9, 0xf3, 0x83, 0xc0, 0x48, 0xf, 0x4a, 0xa8, 0x40, 0x79}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 25; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 22051, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\STXO\147", _pubPktID = 12656, -// _pubBody = "\b\213$\145\229\187z\252G t\147N", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "!\189a\ENQ\235r\186\232?!\140O>\201\220\163\133\166!\139i", _pubPktID = 0, _pubBody = +// "\249\159L\166\132\147`Q\206\238\229\138\217\DEL\219\t\243\131\192H\SIJ\168@y", _pubProps = []} +TEST(Publish311QCTest, Decode5) { + uint8_t pkt[] = {0x38, 0x30, 0x0, 0x15, 0x21, 0xbd, 0x61, 0x5, 0xeb, 0x72, 0xba, 0xe8, 0x3f, 0x21, 0x8c, 0x4f, 0x3e, + 0xc9, 0xdc, 0xa3, 0x85, 0xa6, 0x21, 0x8b, 0x69, 0xf9, 0x9f, 0x4c, 0xa6, 0x84, 0x93, 0x60, 0x51, 0xce, + 0xee, 0xe5, 0x8a, 0xd9, 0x7f, 0xdb, 0x9, 0xf3, 0x83, 0xc0, 0x48, 0xf, 0x4a, 0xa8, 0x40, 0x79}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x21, 0xbd, 0x61, 0x5, 0xeb, 0x72, 0xba, 0xe8, 0x3f, 0x21, 0x8c, + 0x4f, 0x3e, 0xc9, 0xdc, 0xa3, 0x85, 0xa6, 0x21, 0x8b, 0x69}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf9, 0x9f, 0x4c, 0xa6, 0x84, 0x93, 0x60, 0x51, 0xce, 0xee, 0xe5, 0x8a, 0xd9, + 0x7f, 0xdb, 0x9, 0xf3, 0x83, 0xc0, 0x48, 0xf, 0x4a, 0xa8, 0x40, 0x79}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\216WQ\"", _pubPktID = 0, _pubBody = +// "\v\225\187\153*%\252qh\193\210\232\r0tw\196\176*\254C", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x35, 0x14, 0x0, 0x3, 0x2, 0x4f, 0x93, 0x31, 0x70, 0x8, 0xd5, - 0x24, 0x91, 0xe5, 0xbb, 0x7a, 0xfc, 0x47, 0x20, 0x74, 0x93, 0x4e}; + uint8_t pkt[] = {0x38, 0x1b, 0x0, 0x4, 0xd8, 0x57, 0x51, 0x22, 0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, + 0x71, 0x68, 0xc1, 0xd2, 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; - uint8_t buf[32] = {0}; + uint8_t buf[39] = {0}; - uint8_t topic_bytes[] = {0x2, 0x4f, 0x93}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xd8, 0x57, 0x51, 0x22}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x8, 0xd5, 0x24, 0x91, 0xe5, 0xbb, 0x7a, 0xfc, 0x47, 0x20, 0x74, 0x93, 0x4e}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, 0xd2, + 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 12656, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "a \154R\188d2\n\193\213a_`\215\209", -// _pubPktID = 0, _pubBody = "\223\f\232\t\237\211\234\248", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\216WQ\"", _pubPktID = 0, _pubBody = +// "\v\225\187\153*%\252qh\193\210\232\r0tw\196\176*\254C", _pubProps = []} +TEST(Publish311QCTest, Decode6) { + uint8_t pkt[] = {0x38, 0x1b, 0x0, 0x4, 0xd8, 0x57, 0x51, 0x22, 0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, + 0x71, 0x68, 0xc1, 0xd2, 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xd8, 0x57, 0x51, 0x22}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, 0xd2, + 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\130\tw\142", _pubPktID = 9801, +// _pubBody = "\154z+\141\DC3\201)z\n", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x31, 0x19, 0x0, 0xf, 0x61, 0x20, 0x9a, 0x52, 0xbc, 0x64, 0x32, 0xa, 0xc1, 0xd5, - 0x61, 0x5f, 0x60, 0xd7, 0xd1, 0xdf, 0xc, 0xe8, 0x9, 0xed, 0xd3, 0xea, 0xf8}; + uint8_t pkt[] = {0x32, 0x11, 0x0, 0x4, 0x82, 0x9, 0x77, 0x8e, 0x26, 0x49, + 0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; - uint8_t buf[37] = {0}; + uint8_t buf[29] = {0}; - uint8_t topic_bytes[] = {0x61, 0x20, 0x9a, 0x52, 0xbc, 0x64, 0x32, 0xa, 0xc1, 0xd5, 0x61, 0x5f, 0x60, 0xd7, 0xd1}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x82, 0x9, 0x77, 0x8e}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xdf, 0xc, 0xe8, 0x9, 0xed, 0xd3, 0xea, 0xf8}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 8; + msg.payload_len = 9; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 9801, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\130\tw\142", _pubPktID = 9801, +// _pubBody = "\154z+\141\DC3\201)z\n", _pubProps = []} +TEST(Publish311QCTest, Decode7) { + uint8_t pkt[] = {0x32, 0x11, 0x0, 0x4, 0x82, 0x9, 0x77, 0x8e, 0x26, 0x49, + 0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x82, 0x9, 0x77, 0x8e}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 9801); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "e\144}\187\204\234\r\DLE\238\SOHC\168\198\137\151;\170\232", _pubPktID = 0, _pubBody = -// "u\221\241\212\194^\n\142\246\204\133\216\SOH\232\215\139\249)", _pubProps = []} +// "W\165\ETX\202d\140Z\185\FSm\158\159\206Gj\177D\DC3\250=", _pubPktID = 0, _pubBody = +// "\204r\156\176\144\163\ESC+\228\214X\196\&6\212\179\NULI\132\128`nQ\153\188\153", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x39, 0x26, 0x0, 0x12, 0x65, 0x90, 0x7d, 0xbb, 0xcc, 0xea, 0xd, 0x10, 0xee, 0x1, - 0x43, 0xa8, 0xc6, 0x89, 0x97, 0x3b, 0xaa, 0xe8, 0x75, 0xdd, 0xf1, 0xd4, 0xc2, 0x5e, - 0xa, 0x8e, 0xf6, 0xcc, 0x85, 0xd8, 0x1, 0xe8, 0xd7, 0x8b, 0xf9, 0x29}; + uint8_t pkt[] = {0x39, 0x2f, 0x0, 0x14, 0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, 0x9e, 0x9f, 0xce, + 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d, 0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, + 0x58, 0xc4, 0x36, 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; - uint8_t buf[50] = {0}; + uint8_t buf[59] = {0}; - uint8_t topic_bytes[] = {0x65, 0x90, 0x7d, 0xbb, 0xcc, 0xea, 0xd, 0x10, 0xee, - 0x1, 0x43, 0xa8, 0xc6, 0x89, 0x97, 0x3b, 0xaa, 0xe8}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, + 0x9e, 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x75, 0xdd, 0xf1, 0xd4, 0xc2, 0x5e, 0xa, 0x8e, 0xf6, - 0xcc, 0x85, 0xd8, 0x1, 0xe8, 0xd7, 0x8b, 0xf9, 0x29}; + uint8_t msg_bytes[] = {0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, 0x58, 0xc4, 0x36, + 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 25; lwmqtt_property_t propslist[] = {}; @@ -252,563 +462,1048 @@ TEST(Publish311QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "", _pubPktID = 2526, _pubBody = -// "\230r\220N\f\196\206\176_\178\199 P\193-;\128\182%[", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "W\165\ETX\202d\140Z\185\FSm\158\159\206Gj\177D\DC3\250=", _pubPktID = 0, _pubBody = +// "\204r\156\176\144\163\ESC+\228\214X\196\&6\212\179\NULI\132\128`nQ\153\188\153", _pubProps = []} +TEST(Publish311QCTest, Decode8) { + uint8_t pkt[] = {0x39, 0x2f, 0x0, 0x14, 0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, 0x9e, 0x9f, 0xce, + 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d, 0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, + 0x58, 0xc4, 0x36, 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, + 0x9e, 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, 0x58, 0xc4, 0x36, + 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\STX", _pubPktID = 30584, _pubBody = +// "u\219\"\173\243\187\226Z\193\t\210\"\201K)", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x3a, 0x18, 0x0, 0x0, 0x9, 0xde, 0xe6, 0x72, 0xdc, 0x4e, 0xc, 0xc4, 0xce, - 0xb0, 0x5f, 0xb2, 0xc7, 0x20, 0x50, 0xc1, 0x2d, 0x3b, 0x80, 0xb6, 0x25, 0x5b}; + uint8_t pkt[] = {0x3b, 0x14, 0x0, 0x1, 0x2, 0x77, 0x78, 0x75, 0xdb, 0x22, 0xad, + 0xf3, 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; - uint8_t buf[36] = {0}; + uint8_t buf[32] = {0}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x2}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xe6, 0x72, 0xdc, 0x4e, 0xc, 0xc4, 0xce, 0xb0, 0x5f, 0xb2, - 0xc7, 0x20, 0x50, 0xc1, 0x2d, 0x3b, 0x80, 0xb6, 0x25, 0x5b}; + msg.retained = true; + uint8_t msg_bytes[] = {0x75, 0xdb, 0x22, 0xad, 0xf3, 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2526, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30584, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "}5\238\204\DC2\254\162n\196-\172U\\\169\162\FS\RS\"\189v\148\229\\\223\144|\223\NUL\203", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\STX", _pubPktID = 30584, _pubBody = +// "u\219\"\173\243\187\226Z\193\t\210\"\201K)", _pubProps = []} +TEST(Publish311QCTest, Decode9) { + uint8_t pkt[] = {0x3b, 0x14, 0x0, 0x1, 0x2, 0x77, 0x78, 0x75, 0xdb, 0x22, 0xad, + 0xf3, 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x2}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x75, 0xdb, 0x22, 0xad, 0xf3, 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 30584); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "E_/\183|O\206\131\173f\212\204", +// _pubPktID = 31613, _pubBody = "\155\216/Ef", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x30, 0x1f, 0x0, 0x0, 0x7d, 0x35, 0xee, 0xcc, 0x12, 0xfe, 0xa2, 0x6e, 0xc4, 0x2d, 0xac, 0x55, 0x5c, - 0xa9, 0xa2, 0x1c, 0x1e, 0x22, 0xbd, 0x76, 0x94, 0xe5, 0x5c, 0xdf, 0x90, 0x7c, 0xdf, 0x0, 0xcb}; + uint8_t pkt[] = {0x32, 0x15, 0x0, 0xc, 0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, + 0xad, 0x66, 0xd4, 0xcc, 0x7b, 0x7d, 0x9b, 0xd8, 0x2f, 0x45, 0x66}; - uint8_t buf[43] = {0}; + uint8_t buf[33] = {0}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x7d, 0x35, 0xee, 0xcc, 0x12, 0xfe, 0xa2, 0x6e, 0xc4, 0x2d, 0xac, 0x55, 0x5c, 0xa9, 0xa2, - 0x1c, 0x1e, 0x22, 0xbd, 0x76, 0x94, 0xe5, 0x5c, 0xdf, 0x90, 0x7c, 0xdf, 0x0, 0xcb}; + uint8_t msg_bytes[] = {0x9b, 0xd8, 0x2f, 0x45, 0x66}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 5; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\164\&3g\145", _pubPktID = 25063, -// _pubBody = "s\178\237\US", _pubProps = [PropResponseInformation -// "L!\184\215\210_\255\ETB\163\229\EOT\141\214\173ES\136\224[\a\231Un",PropTopicAlias 28899,PropResponseInformation -// "\SUB\244>k\235hg\149[[&\157\218\EM\n]>\173\255\"*\DC4km\167'\166\176\135:",PropSessionExpiryInterval -// 1026,PropContentType "\195\170\244Y\SI\160\NAK\188\131",PropSessionExpiryInterval 1608,PropTopicAlias -// 15486,PropServerKeepAlive 2825,PropReasonString -// "\162o6_+a\190\216\144sk-\233\240}`\190\136",PropWildcardSubscriptionAvailable 165,PropServerKeepAlive -// 1630,PropResponseInformation "\157\230b\252P\221E\172\156^aK[\224",PropAuthenticationMethod -// "\r~\DC4\137\ETBK\250\235J]=\205\204]",PropResponseInformation -// ",\EM0\156%$=\228\DC44\180W\213\162,",PropTopicAliasMaximum 21055,PropTopicAliasMaximum -// 21339,PropMessageExpiryInterval 8748,PropReceiveMaximum 28723,PropRetainAvailable 108,PropSessionExpiryInterval -// 18854]} + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31613, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "E_/\183|O\206\131\173f\212\204", +// _pubPktID = 31613, _pubBody = "\155\216/Ef", _pubProps = []} +TEST(Publish311QCTest, Decode10) { + uint8_t pkt[] = {0x32, 0x15, 0x0, 0xc, 0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, + 0xad, 0x66, 0xd4, 0xcc, 0x7b, 0x7d, 0x9b, 0xd8, 0x2f, 0x45, 0x66}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9b, 0xd8, 0x2f, 0x45, 0x66}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 31613); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\181m\255\144\250L\DC3iF\146\ACK\157\198\202\ACK\176\195z\141\216e\SYN\176", _pubPktID = 5540, _pubBody = "-\222", +// _pubProps = [PropMessageExpiryInterval 31218,PropMessageExpiryInterval 6930,PropSessionExpiryInterval +// 32694,PropUserProperty "\155 N\153]\236?\192FZu}\139L\176m\189\211Jq\183~\202\t\159" +// "!\\\179x\147\242_",PropSubscriptionIdentifier 6,PropSubscriptionIdentifierAvailable +// 171,PropRequestResponseInformation 68,PropRetainAvailable 146,PropMaximumPacketSize +// 18652,PropRequestResponseInformation 207,PropSubscriptionIdentifierAvailable 232,PropMaximumPacketSize +// 26180,PropTopicAlias 20402,PropMessageExpiryInterval 15307,PropUserProperty "\ENQ\247G" +// "xK+e\211r\SO\192]k\203\DC1\170in\NUL",PropAssignedClientIdentifier +// "\CANH\224A}S\SUBLe^1\150\227)_uM\190\232(",PropResponseTopic "Ql\133\206l",PropUserProperty +// "\214\NUL\146\136\192#(l" "\189\155\DC3\218b;\154\142\187\169t3$U\189\RS\249\202\232:i",PropAuthenticationData +// "\171\190`\236\157\185\192Q\246\245x\216M\241\ETXB\233d\137",PropResponseTopic +// "\148\208K\143r3?\247,v\230\171@F\162",PropMessageExpiryInterval 18906,PropRequestProblemInformation +// 117,PropPayloadFormatIndicator 196,PropSessionExpiryInterval 9189,PropWildcardSubscriptionAvailable +// 26,PropRequestResponseInformation 184,PropResponseTopic "\149\&4K",PropResponseInformation +// "\175;\a,C\155\t\178\RSe\172\192\201n\146\138\164d\DEL\184X\216\201\224y\184\206\v",PropPayloadFormatIndicator +// 172,PropRetainAvailable 73]} TEST(Publish5QCTest, Encode1) { uint8_t pkt[] = { - 0x3c, 0xcb, 0x1, 0x0, 0x4, 0xa4, 0x33, 0x67, 0x91, 0x61, 0xe7, 0xbd, 0x1, 0x1a, 0x0, 0x17, 0x4c, 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x73, 0xb2, 0xed, 0x1f}; - - uint8_t buf[216] = {0}; - - uint8_t topic_bytes[] = {0xa4, 0x33, 0x67, 0x91}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + 0x3d, 0xad, 0x2, 0x0, 0x17, 0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, 0xc6, 0xca, + 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0, 0x15, 0xa4, 0x8e, 0x2, 0x2, 0x0, 0x0, 0x79, 0xf2, 0x2, + 0x0, 0x0, 0x1b, 0x12, 0x11, 0x0, 0x0, 0x7f, 0xb6, 0x26, 0x0, 0x19, 0x9b, 0x20, 0x4e, 0x99, 0x5d, 0xec, 0x3f, + 0xc0, 0x46, 0x5a, 0x75, 0x7d, 0x8b, 0x4c, 0xb0, 0x6d, 0xbd, 0xd3, 0x4a, 0x71, 0xb7, 0x7e, 0xca, 0x9, 0x9f, 0x0, + 0x7, 0x21, 0x5c, 0xb3, 0x78, 0x93, 0xf2, 0x5f, 0xb, 0x6, 0x29, 0xab, 0x19, 0x44, 0x25, 0x92, 0x27, 0x0, 0x0, + 0x48, 0xdc, 0x19, 0xcf, 0x29, 0xe8, 0x27, 0x0, 0x0, 0x66, 0x44, 0x23, 0x4f, 0xb2, 0x2, 0x0, 0x0, 0x3b, 0xcb, + 0x26, 0x0, 0x3, 0x5, 0xf7, 0x47, 0x0, 0x10, 0x78, 0x4b, 0x2b, 0x65, 0xd3, 0x72, 0xe, 0xc0, 0x5d, 0x6b, 0xcb, + 0x11, 0xaa, 0x69, 0x6e, 0x0, 0x12, 0x0, 0x14, 0x18, 0x48, 0xe0, 0x41, 0x7d, 0x53, 0x1a, 0x4c, 0x65, 0x5e, 0x31, + 0x96, 0xe3, 0x29, 0x5f, 0x75, 0x4d, 0xbe, 0xe8, 0x28, 0x8, 0x0, 0x5, 0x51, 0x6c, 0x85, 0xce, 0x6c, 0x26, 0x0, + 0x8, 0xd6, 0x0, 0x92, 0x88, 0xc0, 0x23, 0x28, 0x6c, 0x0, 0x15, 0xbd, 0x9b, 0x13, 0xda, 0x62, 0x3b, 0x9a, 0x8e, + 0xbb, 0xa9, 0x74, 0x33, 0x24, 0x55, 0xbd, 0x1e, 0xf9, 0xca, 0xe8, 0x3a, 0x69, 0x16, 0x0, 0x13, 0xab, 0xbe, 0x60, + 0xec, 0x9d, 0xb9, 0xc0, 0x51, 0xf6, 0xf5, 0x78, 0xd8, 0x4d, 0xf1, 0x3, 0x42, 0xe9, 0x64, 0x89, 0x8, 0x0, 0xf, + 0x94, 0xd0, 0x4b, 0x8f, 0x72, 0x33, 0x3f, 0xf7, 0x2c, 0x76, 0xe6, 0xab, 0x40, 0x46, 0xa2, 0x2, 0x0, 0x0, 0x49, + 0xda, 0x17, 0x75, 0x1, 0xc4, 0x11, 0x0, 0x0, 0x23, 0xe5, 0x28, 0x1a, 0x19, 0xb8, 0x8, 0x0, 0x3, 0x95, 0x34, + 0x4b, 0x1a, 0x0, 0x1c, 0xaf, 0x3b, 0x7, 0x2c, 0x43, 0x9b, 0x9, 0xb2, 0x1e, 0x65, 0xac, 0xc0, 0xc9, 0x6e, 0x92, + 0x8a, 0xa4, 0x64, 0x7f, 0xb8, 0x58, 0xd8, 0xc9, 0xe0, 0x79, 0xb8, 0xce, 0xb, 0x1, 0xac, 0x25, 0x49, 0x2d, 0xde}; + + uint8_t buf[314] = {0}; + + uint8_t topic_bytes[] = {0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, + 0xc6, 0xca, 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x73, 0xb2, 0xed, 0x1f}; + msg.retained = true; + uint8_t msg_bytes[] = {0x2d, 0xde}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; - - uint8_t bytesprops0[] = {0x4c, 0x21, 0xb8, 0xd7, 0xd2, 0x5f, 0xff, 0x17, 0xa3, 0xe5, 0x4, 0x8d, - 0xd6, 0xad, 0x45, 0x53, 0x88, 0xe0, 0x5b, 0x7, 0xe7, 0x55, 0x6e}; - uint8_t bytesprops1[] = {0x1a, 0xf4, 0x3e, 0x6b, 0xeb, 0x68, 0x67, 0x95, 0x5b, 0x5b, 0x26, 0x9d, 0xda, 0x19, 0xa, - 0x5d, 0x3e, 0xad, 0xff, 0x22, 0x2a, 0x14, 0x6b, 0x6d, 0xa7, 0x27, 0xa6, 0xb0, 0x87, 0x3a}; - uint8_t bytesprops2[] = {0xc3, 0xaa, 0xf4, 0x59, 0xf, 0xa0, 0x15, 0xbc, 0x83}; - uint8_t bytesprops3[] = {0xa2, 0x6f, 0x36, 0x5f, 0x2b, 0x61, 0xbe, 0xd8, 0x90, - 0x73, 0x6b, 0x2d, 0xe9, 0xf0, 0x7d, 0x60, 0xbe, 0x88}; - uint8_t bytesprops4[] = {0x9d, 0xe6, 0x62, 0xfc, 0x50, 0xdd, 0x45, 0xac, 0x9c, 0x5e, 0x61, 0x4b, 0x5b, 0xe0}; - uint8_t bytesprops5[] = {0xd, 0x7e, 0x14, 0x89, 0x17, 0x4b, 0xfa, 0xeb, 0x4a, 0x5d, 0x3d, 0xcd, 0xcc, 0x5d}; - uint8_t bytesprops6[] = {0x2c, 0x19, 0x30, 0x9c, 0x25, 0x24, 0x3d, 0xe4, 0x14, 0x34, 0xb4, 0x57, 0xd5, 0xa2, 0x2c}; + msg.payload_len = 2; + + uint8_t bytesprops1[] = {0x21, 0x5c, 0xb3, 0x78, 0x93, 0xf2, 0x5f}; + uint8_t bytesprops0[] = {0x9b, 0x20, 0x4e, 0x99, 0x5d, 0xec, 0x3f, 0xc0, 0x46, 0x5a, 0x75, 0x7d, 0x8b, + 0x4c, 0xb0, 0x6d, 0xbd, 0xd3, 0x4a, 0x71, 0xb7, 0x7e, 0xca, 0x9, 0x9f}; + uint8_t bytesprops3[] = {0x78, 0x4b, 0x2b, 0x65, 0xd3, 0x72, 0xe, 0xc0, + 0x5d, 0x6b, 0xcb, 0x11, 0xaa, 0x69, 0x6e, 0x0}; + uint8_t bytesprops2[] = {0x5, 0xf7, 0x47}; + uint8_t bytesprops4[] = {0x18, 0x48, 0xe0, 0x41, 0x7d, 0x53, 0x1a, 0x4c, 0x65, 0x5e, + 0x31, 0x96, 0xe3, 0x29, 0x5f, 0x75, 0x4d, 0xbe, 0xe8, 0x28}; + uint8_t bytesprops5[] = {0x51, 0x6c, 0x85, 0xce, 0x6c}; + uint8_t bytesprops7[] = {0xbd, 0x9b, 0x13, 0xda, 0x62, 0x3b, 0x9a, 0x8e, 0xbb, 0xa9, 0x74, + 0x33, 0x24, 0x55, 0xbd, 0x1e, 0xf9, 0xca, 0xe8, 0x3a, 0x69}; + uint8_t bytesprops6[] = {0xd6, 0x0, 0x92, 0x88, 0xc0, 0x23, 0x28, 0x6c}; + uint8_t bytesprops8[] = {0xab, 0xbe, 0x60, 0xec, 0x9d, 0xb9, 0xc0, 0x51, 0xf6, 0xf5, + 0x78, 0xd8, 0x4d, 0xf1, 0x3, 0x42, 0xe9, 0x64, 0x89}; + uint8_t bytesprops9[] = {0x94, 0xd0, 0x4b, 0x8f, 0x72, 0x33, 0x3f, 0xf7, 0x2c, 0x76, 0xe6, 0xab, 0x40, 0x46, 0xa2}; + uint8_t bytesprops10[] = {0x95, 0x34, 0x4b}; + uint8_t bytesprops11[] = {0xaf, 0x3b, 0x7, 0x2c, 0x43, 0x9b, 0x9, 0xb2, 0x1e, 0x65, 0xac, 0xc0, 0xc9, 0x6e, + 0x92, 0x8a, 0xa4, 0x64, 0x7f, 0xb8, 0x58, 0xd8, 0xc9, 0xe0, 0x79, 0xb8, 0xce, 0xb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28899}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1026}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1608}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15486}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2825}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1630}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21055}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21339}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8748}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28723}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18854}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31218}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6930}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32694}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops0}, .v = {7, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18652}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26180}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20402}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15307}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops2}, .v = {16, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops6}, .v = {21, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18906}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9189}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 73}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25063, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5540, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\213\SUB", _pubPktID = 13464, -// _pubBody = "o\ETBQD}\r\r\192J-\226\"\219Q\SO\244\182!", _pubProps = [PropResponseInformation -// "\194\135h\173\237}\162\160!b\215\197&\246}%\178\245\&9\170\GS",PropRetainAvailable 76,PropContentType -// ":\218W\DC37\181\243\164a\188i\DC3\198\193#^37\240\DC4\GSB0'C\228\169 9",PropReasonString -// "\248\139\145\ETX\170\&1\194\EM!\128]\US\182\182\203q\231\151T\180)",PropResponseInformation -// "\ETB\225\223\174M?f\214\128+wQ\US\246\156\238v\143ym[F",PropPayloadFormatIndicator 42,PropRequestResponseInformation -// 223,PropWildcardSubscriptionAvailable 32,PropPayloadFormatIndicator 79,PropRequestResponseInformation -// 125,PropResponseInformation -// "\170\220\ETXb\156\232\251\&8\199\250\153\255\203(topic.data), 23); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "|5\229o-\r\179\163\252\150\208^\255(\140Y+\a\226xNy\RS\200\237\233\&5\214", _pubPktID = 0, _pubBody = +// "/\130\238\202\224\230", _pubProps = [PropSessionExpiryInterval 13319,PropReceiveMaximum +// 2476,PropPayloadFormatIndicator 219,PropRetainAvailable 217,PropSubscriptionIdentifier 21,PropServerReference +// "-\CANBb\a\211\&4\201M\227\140B\189\b9\135\188X\SOH'X",PropMaximumPacketSize 28709,PropMessageExpiryInterval +// 28695,PropSubscriptionIdentifier 7,PropPayloadFormatIndicator 174,PropRequestProblemInformation +// 173,PropWillDelayInterval 1999,PropTopicAlias 31049,PropSubscriptionIdentifierAvailable +// 105,PropSubscriptionIdentifier 4,PropSubscriptionIdentifierAvailable 86,PropTopicAliasMaximum +// 14292,PropTopicAliasMaximum 12764,PropMaximumQoS 159,PropWildcardSubscriptionAvailable 197]} TEST(Publish5QCTest, Encode2) { - uint8_t pkt[] = {0x3a, 0x88, 0x2, 0x0, 0x2, 0xd5, 0x1a, 0x34, 0x98, 0xee, 0x1, 0x1a, 0x0, 0x15, 0xc2, 0x87, 0x68, - 0xad, 0xed, 0x7d, 0xa2, 0xa0, 0x21, 0x62, 0xd7, 0xc5, 0x26, 0xf6, 0x7d, 0x25, 0xb2, 0xf5, 0x39, 0xaa, - 0x1d, 0x25, 0x4c, 0x3, 0x0, 0x1d, 0x3a, 0xda, 0x57, 0x13, 0x37, 0xb5, 0xf3, 0xa4, 0x61, 0xbc, 0x69, - 0x13, 0xc6, 0xc1, 0x23, 0x5e, 0x33, 0x37, 0xf0, 0x14, 0x1d, 0x42, 0x30, 0x27, 0x43, 0xe4, 0xa9, 0x20, - 0x39, 0x1f, 0x0, 0x15, 0xf8, 0x8b, 0x91, 0x3, 0xaa, 0x31, 0xc2, 0x19, 0x21, 0x80, 0x5d, 0x1f, 0xb6, - 0xb6, 0xcb, 0x71, 0xe7, 0x97, 0x54, 0xb4, 0x29, 0x1a, 0x0, 0x16, 0x17, 0xe1, 0xdf, 0xae, 0x4d, 0x3f, - 0x66, 0xd6, 0x80, 0x2b, 0x77, 0x51, 0x1f, 0xf6, 0x9c, 0xee, 0x76, 0x8f, 0x79, 0x6d, 0x5b, 0x46, 0x1, - 0x2a, 0x19, 0xdf, 0x28, 0x20, 0x1, 0x4f, 0x19, 0x7d, 0x1a, 0x0, 0x1d, 0xaa, 0xdc, 0x3, 0x62, 0x9c, - 0xe8, 0xfb, 0x38, 0xc7, 0xfa, 0x99, 0xff, 0xcb, 0x3c, 0x42, 0x22, 0x56, 0xf0, 0xae, 0x99, 0x69, 0xde, - 0x66, 0x4, 0x30, 0x26, 0x7f, 0xf, 0x7f, 0x1c, 0x0, 0x0, 0x18, 0x0, 0x0, 0x72, 0xc, 0x12, 0x0, - 0x3, 0xe0, 0x1c, 0xe5, 0x1c, 0x0, 0x1a, 0x96, 0xe9, 0xd5, 0x34, 0xd1, 0x22, 0x73, 0xca, 0x21, 0xc3, - 0x2, 0xdd, 0xf6, 0xd7, 0x7e, 0xb, 0x86, 0xe9, 0x57, 0xc7, 0xaf, 0x77, 0xf2, 0x86, 0x16, 0xf6, 0x21, - 0x2f, 0xbf, 0x12, 0x0, 0x1a, 0xf6, 0x21, 0xbe, 0xe8, 0xf8, 0x1c, 0xa1, 0x19, 0x6b, 0xa1, 0xe7, 0x4b, - 0x6d, 0x71, 0x66, 0x9, 0x20, 0x1f, 0xad, 0xff, 0xb3, 0x99, 0x23, 0x13, 0x84, 0xd, 0x15, 0x0, 0xb, - 0x96, 0x3c, 0x84, 0x72, 0xf7, 0x18, 0xbf, 0xd1, 0xd4, 0x53, 0x89, 0x6f, 0x17, 0x51, 0x44, 0x7d, 0xd, - 0xd, 0xc0, 0x4a, 0x2d, 0xe2, 0x22, 0xdb, 0x51, 0xe, 0xf4, 0xb6, 0x21}; - - uint8_t buf[277] = {0}; - - uint8_t topic_bytes[] = {0xd5, 0x1a}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x73, 0x0, 0x1c, 0x7c, 0x35, 0xe5, 0x6f, 0x2d, 0xd, 0xb3, 0xa3, 0xfc, 0x96, 0xd0, 0x5e, 0xff, + 0x28, 0x8c, 0x59, 0x2b, 0x7, 0xe2, 0x78, 0x4e, 0x79, 0x1e, 0xc8, 0xed, 0xe9, 0x35, 0xd6, 0x4e, 0x11, + 0x0, 0x0, 0x34, 0x7, 0x21, 0x9, 0xac, 0x1, 0xdb, 0x25, 0xd9, 0xb, 0x15, 0x1c, 0x0, 0x15, 0x2d, + 0x18, 0x42, 0x62, 0x7, 0xd3, 0x34, 0xc9, 0x4d, 0xe3, 0x8c, 0x42, 0xbd, 0x8, 0x39, 0x87, 0xbc, 0x58, + 0x1, 0x27, 0x58, 0x27, 0x0, 0x0, 0x70, 0x25, 0x2, 0x0, 0x0, 0x70, 0x17, 0xb, 0x7, 0x1, 0xae, + 0x17, 0xad, 0x18, 0x0, 0x0, 0x7, 0xcf, 0x23, 0x79, 0x49, 0x29, 0x69, 0xb, 0x4, 0x29, 0x56, 0x22, + 0x37, 0xd4, 0x22, 0x31, 0xdc, 0x24, 0x9f, 0x28, 0xc5, 0x2f, 0x82, 0xee, 0xca, 0xe0, 0xe6}; + + uint8_t buf[127] = {0}; + + uint8_t topic_bytes[] = {0x7c, 0x35, 0xe5, 0x6f, 0x2d, 0xd, 0xb3, 0xa3, 0xfc, 0x96, 0xd0, 0x5e, 0xff, 0x28, + 0x8c, 0x59, 0x2b, 0x7, 0xe2, 0x78, 0x4e, 0x79, 0x1e, 0xc8, 0xed, 0xe9, 0x35, 0xd6}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x6f, 0x17, 0x51, 0x44, 0x7d, 0xd, 0xd, 0xc0, 0x4a, - 0x2d, 0xe2, 0x22, 0xdb, 0x51, 0xe, 0xf4, 0xb6, 0x21}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x2f, 0x82, 0xee, 0xca, 0xe0, 0xe6}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; - - uint8_t bytesprops0[] = {0xc2, 0x87, 0x68, 0xad, 0xed, 0x7d, 0xa2, 0xa0, 0x21, 0x62, 0xd7, - 0xc5, 0x26, 0xf6, 0x7d, 0x25, 0xb2, 0xf5, 0x39, 0xaa, 0x1d}; - uint8_t bytesprops1[] = {0x3a, 0xda, 0x57, 0x13, 0x37, 0xb5, 0xf3, 0xa4, 0x61, 0xbc, 0x69, 0x13, 0xc6, 0xc1, 0x23, - 0x5e, 0x33, 0x37, 0xf0, 0x14, 0x1d, 0x42, 0x30, 0x27, 0x43, 0xe4, 0xa9, 0x20, 0x39}; - uint8_t bytesprops2[] = {0xf8, 0x8b, 0x91, 0x3, 0xaa, 0x31, 0xc2, 0x19, 0x21, 0x80, 0x5d, - 0x1f, 0xb6, 0xb6, 0xcb, 0x71, 0xe7, 0x97, 0x54, 0xb4, 0x29}; - uint8_t bytesprops3[] = {0x17, 0xe1, 0xdf, 0xae, 0x4d, 0x3f, 0x66, 0xd6, 0x80, 0x2b, 0x77, - 0x51, 0x1f, 0xf6, 0x9c, 0xee, 0x76, 0x8f, 0x79, 0x6d, 0x5b, 0x46}; - uint8_t bytesprops4[] = {0xaa, 0xdc, 0x3, 0x62, 0x9c, 0xe8, 0xfb, 0x38, 0xc7, 0xfa, 0x99, 0xff, 0xcb, 0x3c, 0x42, - 0x22, 0x56, 0xf0, 0xae, 0x99, 0x69, 0xde, 0x66, 0x4, 0x30, 0x26, 0x7f, 0xf, 0x7f}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0xe0, 0x1c, 0xe5}; - uint8_t bytesprops7[] = {0x96, 0xe9, 0xd5, 0x34, 0xd1, 0x22, 0x73, 0xca, 0x21, 0xc3, 0x2, 0xdd, 0xf6, - 0xd7, 0x7e, 0xb, 0x86, 0xe9, 0x57, 0xc7, 0xaf, 0x77, 0xf2, 0x86, 0x16, 0xf6}; - uint8_t bytesprops8[] = {0xf6, 0x21, 0xbe, 0xe8, 0xf8, 0x1c, 0xa1, 0x19, 0x6b, 0xa1, 0xe7, 0x4b, 0x6d, - 0x71, 0x66, 0x9, 0x20, 0x1f, 0xad, 0xff, 0xb3, 0x99, 0x23, 0x13, 0x84, 0xd}; - uint8_t bytesprops9[] = {0x96, 0x3c, 0x84, 0x72, 0xf7, 0x18, 0xbf, 0xd1, 0xd4, 0x53, 0x89}; + msg.payload_len = 6; + + uint8_t bytesprops0[] = {0x2d, 0x18, 0x42, 0x62, 0x7, 0xd3, 0x34, 0xc9, 0x4d, 0xe3, 0x8c, + 0x42, 0xbd, 0x8, 0x39, 0x87, 0xbc, 0x58, 0x1, 0x27, 0x58}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29196}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12223}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13319}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2476}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28709}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28695}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1999}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31049}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14292}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12764}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 197}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 13464, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "^\128\189\159\\k\153Q\222\207%\t\157-\238\240l\DLE&\ESC\220\&5\201yk\184\SO", _pubPktID = 18950, _pubBody = -// "\186\231\&1`\228\223^\203\149L\134\175o\ENQ-b\212\170\128\244\t}", _pubProps = [PropReceiveMaximum -// 29869,PropUserProperty "\215Uz\241\&2\131\141\157\STX\EOT+\NAK\183O\236waZ\182" ")~$e",PropMaximumPacketSize -// 2422,PropResponseInformation "\230\244P\197\218\&5\216\196\NULY\209\DC3\183\208",PropMaximumPacketSize -// 5035,PropPayloadFormatIndicator 117,PropReceiveMaximum 26803,PropTopicAliasMaximum 14296,PropSessionExpiryInterval -// 31679,PropPayloadFormatIndicator 45,PropRetainAvailable 244,PropServerReference -// "\173\152\144\ACK\129\USviC\246-\182\&6\242+\179p\186\192:\162?Pm1\228\164",PropTopicAliasMaximum -// 28785,PropUserProperty "\154\165\DC4!T\200o\139\206\186\237\DC1\fiQ\166\172\159\211S\161\130\GS)\186\128<\169\248" -// "",PropResponseTopic "\194\201\SOH\194\248",PropReceiveMaximum 15379,PropMessageExpiryInterval 27645,PropUserProperty -// "\253\215\139\230\SI\148\199k\DC2\237\251G\ETB" "\180f\216\140",PropRequestResponseInformation 84,PropMaximumQoS -// 84,PropRequestProblemInformation 114,PropWildcardSubscriptionAvailable 79,PropMessageExpiryInterval 18902]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "|5\229o-\r\179\163\252\150\208^\255(\140Y+\a\226xNy\RS\200\237\233\&5\214", _pubPktID = 0, _pubBody = +// "/\130\238\202\224\230", _pubProps = [PropSessionExpiryInterval 13319,PropReceiveMaximum +// 2476,PropPayloadFormatIndicator 219,PropRetainAvailable 217,PropSubscriptionIdentifier 21,PropServerReference +// "-\CANBb\a\211\&4\201M\227\140B\189\b9\135\188X\SOH'X",PropMaximumPacketSize 28709,PropMessageExpiryInterval +// 28695,PropSubscriptionIdentifier 7,PropPayloadFormatIndicator 174,PropRequestProblemInformation +// 173,PropWillDelayInterval 1999,PropTopicAlias 31049,PropSubscriptionIdentifierAvailable +// 105,PropSubscriptionIdentifier 4,PropSubscriptionIdentifierAvailable 86,PropTopicAliasMaximum +// 14292,PropTopicAliasMaximum 12764,PropMaximumQoS 159,PropWildcardSubscriptionAvailable 197]} +TEST(Publish5QCTest, Decode2) { + uint8_t pkt[] = {0x39, 0x73, 0x0, 0x1c, 0x7c, 0x35, 0xe5, 0x6f, 0x2d, 0xd, 0xb3, 0xa3, 0xfc, 0x96, 0xd0, 0x5e, 0xff, + 0x28, 0x8c, 0x59, 0x2b, 0x7, 0xe2, 0x78, 0x4e, 0x79, 0x1e, 0xc8, 0xed, 0xe9, 0x35, 0xd6, 0x4e, 0x11, + 0x0, 0x0, 0x34, 0x7, 0x21, 0x9, 0xac, 0x1, 0xdb, 0x25, 0xd9, 0xb, 0x15, 0x1c, 0x0, 0x15, 0x2d, + 0x18, 0x42, 0x62, 0x7, 0xd3, 0x34, 0xc9, 0x4d, 0xe3, 0x8c, 0x42, 0xbd, 0x8, 0x39, 0x87, 0xbc, 0x58, + 0x1, 0x27, 0x58, 0x27, 0x0, 0x0, 0x70, 0x25, 0x2, 0x0, 0x0, 0x70, 0x17, 0xb, 0x7, 0x1, 0xae, + 0x17, 0xad, 0x18, 0x0, 0x0, 0x7, 0xcf, 0x23, 0x79, 0x49, 0x29, 0x69, 0xb, 0x4, 0x29, 0x56, 0x22, + 0x37, 0xd4, 0x22, 0x31, 0xdc, 0x24, 0x9f, 0x28, 0xc5, 0x2f, 0x82, 0xee, 0xca, 0xe0, 0xe6}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7c, 0x35, 0xe5, 0x6f, 0x2d, 0xd, 0xb3, 0xa3, 0xfc, 0x96, 0xd0, 0x5e, 0xff, 0x28, + 0x8c, 0x59, 0x2b, 0x7, 0xe2, 0x78, 0x4e, 0x79, 0x1e, 0xc8, 0xed, 0xe9, 0x35, 0xd6}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2f, 0x82, 0xee, 0xca, 0xe0, 0xe6}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "#s+\243\184\144t\234lj\248\SO=\182TOG$\130\135YOE+\204", _pubPktID = 9717, _pubBody = "\n}\168", _pubProps = +// [PropReasonString "B\198+o;\198\n",PropSharedSubscriptionAvailable 12,PropResponseInformation +// "\DEL\175&H\NAK\178Wd4\RS\228",PropContentType +// "\t\nu\214'\180P^\247\250\&9\201\188\174\US>p\225",PropMaximumPacketSize 28051,PropTopicAlias +// 2937,PropSharedSubscriptionAvailable 108,PropWildcardSubscriptionAvailable 106,PropServerKeepAlive +// 8610,PropMessageExpiryInterval 31767,PropReasonString +// "K\190\200\150\223\234\232\DC3eE\218\221*\239\US\246\214\224%",PropTopicAlias 13083,PropSharedSubscriptionAvailable +// 85,PropResponseInformation "?D}\233\NAK\177\235\227\253\\\187\237}#",PropUserProperty "\NULz{\159\224L\193_;\CAN" +// "e\n\197\214\153\193\247\174\157\179I\SOC@SD\170\243a\136\141\r\"",PropRequestProblemInformation +// 28,PropPayloadFormatIndicator 242,PropAuthenticationData +// "\220\166s\EOTB\234o&QX\174\ACK\GS[\223\RS",PropAuthenticationMethod "\238\244"]} TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = {0x3c, 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, 0x13, 0x2, 0x0, 0x0, 0x6b, 0xfd, 0x26, 0x0, 0xd, 0xfd, 0xd7, 0x8b, 0xe6, 0xf, 0x94, 0xc7, - 0x6b, 0x12, 0xed, 0xfb, 0x47, 0x17, 0x0, 0x4, 0xb4, 0x66, 0xd8, 0x8c, 0x19, 0x54, 0x24, 0x54, 0x17, - 0x72, 0x28, 0x4f, 0x2, 0x0, 0x0, 0x49, 0xd6, 0xba, 0xe7, 0x31, 0x60, 0xe4, 0xdf, 0x5e, 0xcb, 0x95, - 0x4c, 0x86, 0xaf, 0x6f, 0x5, 0x2d, 0x62, 0xd4, 0xaa, 0x80, 0xf4, 0x9, 0x7d}; - - uint8_t buf[261] = {0}; - - uint8_t topic_bytes[] = {0x5e, 0x80, 0xbd, 0x9f, 0x5c, 0x6b, 0x99, 0x51, 0xde, 0xcf, 0x25, 0x9, 0x9d, 0x2d, - 0xee, 0xf0, 0x6c, 0x10, 0x26, 0x1b, 0xdc, 0x35, 0xc9, 0x79, 0x6b, 0xb8, 0xe}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0xd3, 0x1, 0x0, 0x19, 0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, + 0x3d, 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc, 0x25, 0xf5, 0xb1, 0x1, + 0x1f, 0x0, 0x7, 0x42, 0xc6, 0x2b, 0x6f, 0x3b, 0xc6, 0xa, 0x2a, 0xc, 0x1a, 0x0, 0xb, 0x7f, 0xaf, + 0x26, 0x48, 0x15, 0xb2, 0x57, 0x64, 0x34, 0x1e, 0xe4, 0x3, 0x0, 0x12, 0x9, 0xa, 0x75, 0xd6, 0x27, + 0xb4, 0x50, 0x5e, 0xf7, 0xfa, 0x39, 0xc9, 0xbc, 0xae, 0x1f, 0x3e, 0x70, 0xe1, 0x27, 0x0, 0x0, 0x6d, + 0x93, 0x23, 0xb, 0x79, 0x2a, 0x6c, 0x28, 0x6a, 0x13, 0x21, 0xa2, 0x2, 0x0, 0x0, 0x7c, 0x17, 0x1f, + 0x0, 0x13, 0x4b, 0xbe, 0xc8, 0x96, 0xdf, 0xea, 0xe8, 0x13, 0x65, 0x45, 0xda, 0xdd, 0x2a, 0xef, 0x1f, + 0xf6, 0xd6, 0xe0, 0x25, 0x23, 0x33, 0x1b, 0x2a, 0x55, 0x1a, 0x0, 0xe, 0x3f, 0x44, 0x7d, 0xe9, 0x15, + 0xb1, 0xeb, 0xe3, 0xfd, 0x5c, 0xbb, 0xed, 0x7d, 0x23, 0x26, 0x0, 0xa, 0x0, 0x7a, 0x7b, 0x9f, 0xe0, + 0x4c, 0xc1, 0x5f, 0x3b, 0x18, 0x0, 0x17, 0x65, 0xa, 0xc5, 0xd6, 0x99, 0xc1, 0xf7, 0xae, 0x9d, 0xb3, + 0x49, 0xe, 0x43, 0x40, 0x53, 0x44, 0xaa, 0xf3, 0x61, 0x88, 0x8d, 0xd, 0x22, 0x17, 0x1c, 0x1, 0xf2, + 0x16, 0x0, 0x10, 0xdc, 0xa6, 0x73, 0x4, 0x42, 0xea, 0x6f, 0x26, 0x51, 0x58, 0xae, 0x6, 0x1d, 0x5b, + 0xdf, 0x1e, 0x15, 0x0, 0x2, 0xee, 0xf4, 0xa, 0x7d, 0xa8}; + + uint8_t buf[224] = {0}; + + uint8_t topic_bytes[] = {0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, 0x3d, + 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xba, 0xe7, 0x31, 0x60, 0xe4, 0xdf, 0x5e, 0xcb, 0x95, 0x4c, 0x86, - 0xaf, 0x6f, 0x5, 0x2d, 0x62, 0xd4, 0xaa, 0x80, 0xf4, 0x9, 0x7d}; + msg.retained = true; + uint8_t msg_bytes[] = {0xa, 0x7d, 0xa8}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; - - uint8_t bytesprops1[] = {0x29, 0x7e, 0x24, 0x65}; - uint8_t bytesprops0[] = {0xd7, 0x55, 0x7a, 0xf1, 0x32, 0x83, 0x8d, 0x9d, 0x2, 0x4, - 0x2b, 0x15, 0xb7, 0x4f, 0xec, 0x77, 0x61, 0x5a, 0xb6}; - uint8_t bytesprops2[] = {0xe6, 0xf4, 0x50, 0xc5, 0xda, 0x35, 0xd8, 0xc4, 0x0, 0x59, 0xd1, 0x13, 0xb7, 0xd0}; - uint8_t bytesprops3[] = {0xad, 0x98, 0x90, 0x6, 0x81, 0x1f, 0x76, 0x69, 0x43, 0xf6, 0x2d, 0xb6, 0x36, 0xf2, - 0x2b, 0xb3, 0x70, 0xba, 0xc0, 0x3a, 0xa2, 0x3f, 0x50, 0x6d, 0x31, 0xe4, 0xa4}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops4[] = {0x9a, 0xa5, 0x14, 0x21, 0x54, 0xc8, 0x6f, 0x8b, 0xce, 0xba, 0xed, 0x11, 0xc, 0x69, 0x51, - 0xa6, 0xac, 0x9f, 0xd3, 0x53, 0xa1, 0x82, 0x1d, 0x29, 0xba, 0x80, 0x3c, 0xa9, 0xf8}; - uint8_t bytesprops6[] = {0xc2, 0xc9, 0x1, 0xc2, 0xf8}; - uint8_t bytesprops8[] = {0xb4, 0x66, 0xd8, 0x8c}; - uint8_t bytesprops7[] = {0xfd, 0xd7, 0x8b, 0xe6, 0xf, 0x94, 0xc7, 0x6b, 0x12, 0xed, 0xfb, 0x47, 0x17}; + msg.payload_len = 3; + + uint8_t bytesprops0[] = {0x42, 0xc6, 0x2b, 0x6f, 0x3b, 0xc6, 0xa}; + uint8_t bytesprops1[] = {0x7f, 0xaf, 0x26, 0x48, 0x15, 0xb2, 0x57, 0x64, 0x34, 0x1e, 0xe4}; + uint8_t bytesprops2[] = {0x9, 0xa, 0x75, 0xd6, 0x27, 0xb4, 0x50, 0x5e, 0xf7, + 0xfa, 0x39, 0xc9, 0xbc, 0xae, 0x1f, 0x3e, 0x70, 0xe1}; + uint8_t bytesprops3[] = {0x4b, 0xbe, 0xc8, 0x96, 0xdf, 0xea, 0xe8, 0x13, 0x65, 0x45, + 0xda, 0xdd, 0x2a, 0xef, 0x1f, 0xf6, 0xd6, 0xe0, 0x25}; + uint8_t bytesprops4[] = {0x3f, 0x44, 0x7d, 0xe9, 0x15, 0xb1, 0xeb, 0xe3, 0xfd, 0x5c, 0xbb, 0xed, 0x7d, 0x23}; + uint8_t bytesprops6[] = {0x65, 0xa, 0xc5, 0xd6, 0x99, 0xc1, 0xf7, 0xae, 0x9d, 0xb3, 0x49, 0xe, + 0x43, 0x40, 0x53, 0x44, 0xaa, 0xf3, 0x61, 0x88, 0x8d, 0xd, 0x22}; + uint8_t bytesprops5[] = {0x0, 0x7a, 0x7b, 0x9f, 0xe0, 0x4c, 0xc1, 0x5f, 0x3b, 0x18}; + uint8_t bytesprops7[] = {0xdc, 0xa6, 0x73, 0x4, 0x42, 0xea, 0x6f, 0x26, + 0x51, 0x58, 0xae, 0x6, 0x1d, 0x5b, 0xdf, 0x1e}; + uint8_t bytesprops8[] = {0xee, 0xf4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29869}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops0}, .v = {4, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2422}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5035}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26803}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14296}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31679}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28785}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {0, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15379}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27645}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops7}, .v = {4, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18902}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28051}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2937}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8610}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31767}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13083}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops5}, .v = {23, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 18950, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\152\SUBq2\SOH\150", _pubPktID = -// 6631, _pubBody = "p\177\185\198Z\188\203\EOT\\\211>c\165\219\215U\r,", _pubProps = [PropResponseTopic -// "l\240\222\&5\155S\DC1\144",PropSharedSubscriptionAvailable 195,PropTopicAlias 21764,PropAssignedClientIdentifier -// "5~5s\229n8\168[\185\169#j\178",PropMessageExpiryInterval 6243,PropSubscriptionIdentifier -// 8,PropWildcardSubscriptionAvailable 98,PropTopicAlias 18850]} + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 9717, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "#s+\243\184\144t\234lj\248\SO=\182TOG$\130\135YOE+\204", _pubPktID = 9717, _pubBody = "\n}\168", _pubProps = +// [PropReasonString "B\198+o;\198\n",PropSharedSubscriptionAvailable 12,PropResponseInformation +// "\DEL\175&H\NAK\178Wd4\RS\228",PropContentType +// "\t\nu\214'\180P^\247\250\&9\201\188\174\US>p\225",PropMaximumPacketSize 28051,PropTopicAlias +// 2937,PropSharedSubscriptionAvailable 108,PropWildcardSubscriptionAvailable 106,PropServerKeepAlive +// 8610,PropMessageExpiryInterval 31767,PropReasonString +// "K\190\200\150\223\234\232\DC3eE\218\221*\239\US\246\214\224%",PropTopicAlias 13083,PropSharedSubscriptionAvailable +// 85,PropResponseInformation "?D}\233\NAK\177\235\227\253\\\187\237}#",PropUserProperty "\NULz{\159\224L\193_;\CAN" +// "e\n\197\214\153\193\247\174\157\179I\SOC@SD\170\243a\136\141\r\"",PropRequestProblemInformation +// 28,PropPayloadFormatIndicator 242,PropAuthenticationData +// "\220\166s\EOTB\234o&QX\174\ACK\GS[\223\RS",PropAuthenticationMethod "\238\244"]} +TEST(Publish5QCTest, Decode3) { + uint8_t pkt[] = {0x35, 0xd3, 0x1, 0x0, 0x19, 0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, + 0x3d, 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc, 0x25, 0xf5, 0xb1, 0x1, + 0x1f, 0x0, 0x7, 0x42, 0xc6, 0x2b, 0x6f, 0x3b, 0xc6, 0xa, 0x2a, 0xc, 0x1a, 0x0, 0xb, 0x7f, 0xaf, + 0x26, 0x48, 0x15, 0xb2, 0x57, 0x64, 0x34, 0x1e, 0xe4, 0x3, 0x0, 0x12, 0x9, 0xa, 0x75, 0xd6, 0x27, + 0xb4, 0x50, 0x5e, 0xf7, 0xfa, 0x39, 0xc9, 0xbc, 0xae, 0x1f, 0x3e, 0x70, 0xe1, 0x27, 0x0, 0x0, 0x6d, + 0x93, 0x23, 0xb, 0x79, 0x2a, 0x6c, 0x28, 0x6a, 0x13, 0x21, 0xa2, 0x2, 0x0, 0x0, 0x7c, 0x17, 0x1f, + 0x0, 0x13, 0x4b, 0xbe, 0xc8, 0x96, 0xdf, 0xea, 0xe8, 0x13, 0x65, 0x45, 0xda, 0xdd, 0x2a, 0xef, 0x1f, + 0xf6, 0xd6, 0xe0, 0x25, 0x23, 0x33, 0x1b, 0x2a, 0x55, 0x1a, 0x0, 0xe, 0x3f, 0x44, 0x7d, 0xe9, 0x15, + 0xb1, 0xeb, 0xe3, 0xfd, 0x5c, 0xbb, 0xed, 0x7d, 0x23, 0x26, 0x0, 0xa, 0x0, 0x7a, 0x7b, 0x9f, 0xe0, + 0x4c, 0xc1, 0x5f, 0x3b, 0x18, 0x0, 0x17, 0x65, 0xa, 0xc5, 0xd6, 0x99, 0xc1, 0xf7, 0xae, 0x9d, 0xb3, + 0x49, 0xe, 0x43, 0x40, 0x53, 0x44, 0xaa, 0xf3, 0x61, 0x88, 0x8d, 0xd, 0x22, 0x17, 0x1c, 0x1, 0xf2, + 0x16, 0x0, 0x10, 0xdc, 0xa6, 0x73, 0x4, 0x42, 0xea, 0x6f, 0x26, 0x51, 0x58, 0xae, 0x6, 0x1d, 0x5b, + 0xdf, 0x1e, 0x15, 0x0, 0x2, 0xee, 0xf4, 0xa, 0x7d, 0xa8}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, 0x3d, + 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa, 0x7d, 0xa8}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 9717); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\173\179\129=\155\186E\131\242g\224\149\&5\f\ESCk\250\130", _pubPktID = 696, _pubBody = +// "\210\212B\245\204\143IYw\217p\214\&5\152\133@\ETB{\FS\238\226", _pubProps = [PropContentType +// "\253iAd\SOH\225\GS\160\178\DC1\143\NULa\DC3\RSz\f\SYN\185",PropSessionExpiryInterval 21518]} TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = {0x3a, 0x4a, 0x0, 0x6, 0x98, 0x1a, 0x71, 0x32, 0x1, 0x96, 0x19, 0xe7, 0x2d, 0x8, 0x0, 0x8, - 0x6c, 0xf0, 0xde, 0x35, 0x9b, 0x53, 0x11, 0x90, 0x2a, 0xc3, 0x23, 0x55, 0x4, 0x12, 0x0, 0xe, - 0x35, 0x7e, 0x35, 0x73, 0xe5, 0x6e, 0x38, 0xa8, 0x5b, 0xb9, 0xa9, 0x23, 0x6a, 0xb2, 0x2, 0x0, - 0x0, 0x18, 0x63, 0xb, 0x8, 0x28, 0x62, 0x23, 0x49, 0xa2, 0x70, 0xb1, 0xb9, 0xc6, 0x5a, 0xbc, - 0xcb, 0x4, 0x5c, 0xd3, 0x3e, 0x63, 0xa5, 0xdb, 0xd7, 0x55, 0xd, 0x2c}; + uint8_t pkt[] = {0x33, 0x47, 0x0, 0x12, 0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, 0x67, 0xe0, + 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82, 0x2, 0xb8, 0x1b, 0x3, 0x0, 0x13, 0xfd, 0x69, + 0x41, 0x64, 0x1, 0xe1, 0x1d, 0xa0, 0xb2, 0x11, 0x8f, 0x0, 0x61, 0x13, 0x1e, 0x7a, 0xc, + 0x16, 0xb9, 0x11, 0x0, 0x0, 0x54, 0xe, 0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, + 0x77, 0xd9, 0x70, 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; - uint8_t buf[86] = {0}; + uint8_t buf[83] = {0}; - uint8_t topic_bytes[] = {0x98, 0x1a, 0x71, 0x32, 0x1, 0x96}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, + 0x67, 0xe0, 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x70, 0xb1, 0xb9, 0xc6, 0x5a, 0xbc, 0xcb, 0x4, 0x5c, - 0xd3, 0x3e, 0x63, 0xa5, 0xdb, 0xd7, 0x55, 0xd, 0x2c}; + msg.retained = true; + uint8_t msg_bytes[] = {0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, 0x77, 0xd9, 0x70, + 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 21; - uint8_t bytesprops0[] = {0x6c, 0xf0, 0xde, 0x35, 0x9b, 0x53, 0x11, 0x90}; - uint8_t bytesprops1[] = {0x35, 0x7e, 0x35, 0x73, 0xe5, 0x6e, 0x38, 0xa8, 0x5b, 0xb9, 0xa9, 0x23, 0x6a, 0xb2}; + uint8_t bytesprops0[] = {0xfd, 0x69, 0x41, 0x64, 0x1, 0xe1, 0x1d, 0xa0, 0xb2, 0x11, + 0x8f, 0x0, 0x61, 0x13, 0x1e, 0x7a, 0xc, 0x16, 0xb9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21764}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6243}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18850}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21518}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6631, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// ",=;\135\178\237\227\194~\130\190\147}\190\249wf\151\200\SI\170fO", _pubPktID = 22051, _pubBody = -// "\fJ\139u\132\RS\170\170\v\DC3\148\&2\213!,\174A\170\235~\144/\200", _pubProps = [PropTopicAlias -// 4075,PropCorrelationData "\DLE\191\196:\147\187(\220\172Vn\161`\131{L\154\170\146\220#\252~\187"]} + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 696, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\173\179\129=\155\186E\131\242g\224\149\&5\f\ESCk\250\130", _pubPktID = 696, _pubBody = +// "\210\212B\245\204\143IYw\217p\214\&5\152\133@\ETB{\FS\238\226", _pubProps = [PropContentType +// "\253iAd\SOH\225\GS\160\178\DC1\143\NULa\DC3\RSz\f\SYN\185",PropSessionExpiryInterval 21518]} +TEST(Publish5QCTest, Decode4) { + uint8_t pkt[] = {0x33, 0x47, 0x0, 0x12, 0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, 0x67, 0xe0, + 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82, 0x2, 0xb8, 0x1b, 0x3, 0x0, 0x13, 0xfd, 0x69, + 0x41, 0x64, 0x1, 0xe1, 0x1d, 0xa0, 0xb2, 0x11, 0x8f, 0x0, 0x61, 0x13, 0x1e, 0x7a, 0xc, + 0x16, 0xb9, 0x11, 0x0, 0x0, 0x54, 0xe, 0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, + 0x77, 0xd9, 0x70, 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, + 0x67, 0xe0, 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, 0x77, 0xd9, 0x70, + 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 696); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "!\189a\ENQ\235r\186\232?!\140O>\201\220\163\133\166!\139i", _pubPktID = 0, _pubBody = +// "\249\159L\166\132\147`Q\206\238\229\138\217\DEL\219\t\243\131\192H\SIJ\168@y", _pubProps = [PropRetainAvailable +// 63,PropSubscriptionIdentifierAvailable 254,PropUserProperty "\200TB\215\255V,X\247^\NAK\175\GS\155R\SI\183)wiCQ" +// "@\181\SYN\250\227\154\&63\188\242\205\235\210>\195No\148\148\219\167\135N\206\\",PropRequestProblemInformation +// 17,PropAuthenticationData "",PropAssignedClientIdentifier +// "\222\GSoB\\[0\229\225\240\DC4\246\a\230\DLEJ\220\198-\250\172\SOQ\223c\183\156B",PropContentType +// "\252@\145\231\f\172",PropTopicAliasMaximum 13537,PropRequestResponseInformation 228,PropRequestProblemInformation +// 101,PropRequestProblemInformation 78,PropMessageExpiryInterval 27680,PropTopicAlias 10759,PropSubscriptionIdentifier +// 7,PropReceiveMaximum 11393,PropMaximumQoS 183,PropPayloadFormatIndicator 102,PropAuthenticationMethod +// "\212",PropServerKeepAlive 30667,PropRequestResponseInformation 129,PropMessageExpiryInterval 5688]} TEST(Publish5QCTest, Encode5) { - uint8_t pkt[] = {0x3b, 0x51, 0x0, 0x17, 0x2c, 0x3d, 0x3b, 0x87, 0xb2, 0xed, 0xe3, 0xc2, 0x7e, 0x82, 0xbe, 0x93, 0x7d, - 0xbe, 0xf9, 0x77, 0x66, 0x97, 0xc8, 0xf, 0xaa, 0x66, 0x4f, 0x56, 0x23, 0x1e, 0x23, 0xf, 0xeb, 0x9, - 0x0, 0x18, 0x10, 0xbf, 0xc4, 0x3a, 0x93, 0xbb, 0x28, 0xdc, 0xac, 0x56, 0x6e, 0xa1, 0x60, 0x83, 0x7b, - 0x4c, 0x9a, 0xaa, 0x92, 0xdc, 0x23, 0xfc, 0x7e, 0xbb, 0xc, 0x4a, 0x8b, 0x75, 0x84, 0x1e, 0xaa, 0xaa, - 0xb, 0x13, 0x94, 0x32, 0xd5, 0x21, 0x2c, 0xae, 0x41, 0xaa, 0xeb, 0x7e, 0x90, 0x2f, 0xc8}; + uint8_t pkt[] = {0x38, 0xbf, 0x1, 0x0, 0x15, 0x21, 0xbd, 0x61, 0x5, 0xeb, 0x72, 0xba, 0xe8, 0x3f, 0x21, 0x8c, 0x4f, + 0x3e, 0xc9, 0xdc, 0xa3, 0x85, 0xa6, 0x21, 0x8b, 0x69, 0x8d, 0x1, 0x25, 0x3f, 0x29, 0xfe, 0x26, 0x0, + 0x16, 0xc8, 0x54, 0x42, 0xd7, 0xff, 0x56, 0x2c, 0x58, 0xf7, 0x5e, 0x15, 0xaf, 0x1d, 0x9b, 0x52, 0xf, + 0xb7, 0x29, 0x77, 0x69, 0x43, 0x51, 0x0, 0x19, 0x40, 0xb5, 0x16, 0xfa, 0xe3, 0x9a, 0x36, 0x33, 0xbc, + 0xf2, 0xcd, 0xeb, 0xd2, 0x3e, 0xc3, 0x4e, 0x6f, 0x94, 0x94, 0xdb, 0xa7, 0x87, 0x4e, 0xce, 0x5c, 0x17, + 0x11, 0x16, 0x0, 0x0, 0x12, 0x0, 0x1c, 0xde, 0x1d, 0x6f, 0x42, 0x5c, 0x5b, 0x30, 0xe5, 0xe1, 0xf0, + 0x14, 0xf6, 0x7, 0xe6, 0x10, 0x4a, 0xdc, 0xc6, 0x2d, 0xfa, 0xac, 0xe, 0x51, 0xdf, 0x63, 0xb7, 0x9c, + 0x42, 0x3, 0x0, 0x6, 0xfc, 0x40, 0x91, 0xe7, 0xc, 0xac, 0x22, 0x34, 0xe1, 0x19, 0xe4, 0x17, 0x65, + 0x17, 0x4e, 0x2, 0x0, 0x0, 0x6c, 0x20, 0x23, 0x2a, 0x7, 0xb, 0x7, 0x21, 0x2c, 0x81, 0x24, 0xb7, + 0x1, 0x66, 0x15, 0x0, 0x1, 0xd4, 0x13, 0x77, 0xcb, 0x19, 0x81, 0x2, 0x0, 0x0, 0x16, 0x38, 0xf9, + 0x9f, 0x4c, 0xa6, 0x84, 0x93, 0x60, 0x51, 0xce, 0xee, 0xe5, 0x8a, 0xd9, 0x7f, 0xdb, 0x9, 0xf3, 0x83, + 0xc0, 0x48, 0xf, 0x4a, 0xa8, 0x40, 0x79}; - uint8_t buf[93] = {0}; + uint8_t buf[204] = {0}; - uint8_t topic_bytes[] = {0x2c, 0x3d, 0x3b, 0x87, 0xb2, 0xed, 0xe3, 0xc2, 0x7e, 0x82, 0xbe, 0x93, - 0x7d, 0xbe, 0xf9, 0x77, 0x66, 0x97, 0xc8, 0xf, 0xaa, 0x66, 0x4f}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x21, 0xbd, 0x61, 0x5, 0xeb, 0x72, 0xba, 0xe8, 0x3f, 0x21, 0x8c, + 0x4f, 0x3e, 0xc9, 0xdc, 0xa3, 0x85, 0xa6, 0x21, 0x8b, 0x69}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xc, 0x4a, 0x8b, 0x75, 0x84, 0x1e, 0xaa, 0xaa, 0xb, 0x13, 0x94, 0x32, - 0xd5, 0x21, 0x2c, 0xae, 0x41, 0xaa, 0xeb, 0x7e, 0x90, 0x2f, 0xc8}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xf9, 0x9f, 0x4c, 0xa6, 0x84, 0x93, 0x60, 0x51, 0xce, 0xee, 0xe5, 0x8a, 0xd9, + 0x7f, 0xdb, 0x9, 0xf3, 0x83, 0xc0, 0x48, 0xf, 0x4a, 0xa8, 0x40, 0x79}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 25; - uint8_t bytesprops0[] = {0x10, 0xbf, 0xc4, 0x3a, 0x93, 0xbb, 0x28, 0xdc, 0xac, 0x56, 0x6e, 0xa1, - 0x60, 0x83, 0x7b, 0x4c, 0x9a, 0xaa, 0x92, 0xdc, 0x23, 0xfc, 0x7e, 0xbb}; + uint8_t bytesprops1[] = {0x40, 0xb5, 0x16, 0xfa, 0xe3, 0x9a, 0x36, 0x33, 0xbc, 0xf2, 0xcd, 0xeb, 0xd2, + 0x3e, 0xc3, 0x4e, 0x6f, 0x94, 0x94, 0xdb, 0xa7, 0x87, 0x4e, 0xce, 0x5c}; + uint8_t bytesprops0[] = {0xc8, 0x54, 0x42, 0xd7, 0xff, 0x56, 0x2c, 0x58, 0xf7, 0x5e, 0x15, + 0xaf, 0x1d, 0x9b, 0x52, 0xf, 0xb7, 0x29, 0x77, 0x69, 0x43, 0x51}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0xde, 0x1d, 0x6f, 0x42, 0x5c, 0x5b, 0x30, 0xe5, 0xe1, 0xf0, 0x14, 0xf6, 0x7, 0xe6, + 0x10, 0x4a, 0xdc, 0xc6, 0x2d, 0xfa, 0xac, 0xe, 0x51, 0xdf, 0x63, 0xb7, 0x9c, 0x42}; + uint8_t bytesprops4[] = {0xfc, 0x40, 0x91, 0xe7, 0xc, 0xac}; + uint8_t bytesprops5[] = {0xd4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4075}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13537}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27680}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10759}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11393}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30667}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5688}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 22051, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\STXO\147", _pubPktID = 12656, -// _pubBody = "\b\213$\145\229\187z\252G t\147N", _pubProps = [PropAssignedClientIdentifier " -// \252V\RS\233\245\158\128\150\184\254\245",PropReceiveMaximum 4428]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "!\189a\ENQ\235r\186\232?!\140O>\201\220\163\133\166!\139i", _pubPktID = 0, _pubBody = +// "\249\159L\166\132\147`Q\206\238\229\138\217\DEL\219\t\243\131\192H\SIJ\168@y", _pubProps = [PropRetainAvailable +// 63,PropSubscriptionIdentifierAvailable 254,PropUserProperty "\200TB\215\255V,X\247^\NAK\175\GS\155R\SI\183)wiCQ" +// "@\181\SYN\250\227\154\&63\188\242\205\235\210>\195No\148\148\219\167\135N\206\\",PropRequestProblemInformation +// 17,PropAuthenticationData "",PropAssignedClientIdentifier +// "\222\GSoB\\[0\229\225\240\DC4\246\a\230\DLEJ\220\198-\250\172\SOQ\223c\183\156B",PropContentType +// "\252@\145\231\f\172",PropTopicAliasMaximum 13537,PropRequestResponseInformation 228,PropRequestProblemInformation +// 101,PropRequestProblemInformation 78,PropMessageExpiryInterval 27680,PropTopicAlias 10759,PropSubscriptionIdentifier +// 7,PropReceiveMaximum 11393,PropMaximumQoS 183,PropPayloadFormatIndicator 102,PropAuthenticationMethod +// "\212",PropServerKeepAlive 30667,PropRequestResponseInformation 129,PropMessageExpiryInterval 5688]} +TEST(Publish5QCTest, Decode5) { + uint8_t pkt[] = {0x38, 0xbf, 0x1, 0x0, 0x15, 0x21, 0xbd, 0x61, 0x5, 0xeb, 0x72, 0xba, 0xe8, 0x3f, 0x21, 0x8c, 0x4f, + 0x3e, 0xc9, 0xdc, 0xa3, 0x85, 0xa6, 0x21, 0x8b, 0x69, 0x8d, 0x1, 0x25, 0x3f, 0x29, 0xfe, 0x26, 0x0, + 0x16, 0xc8, 0x54, 0x42, 0xd7, 0xff, 0x56, 0x2c, 0x58, 0xf7, 0x5e, 0x15, 0xaf, 0x1d, 0x9b, 0x52, 0xf, + 0xb7, 0x29, 0x77, 0x69, 0x43, 0x51, 0x0, 0x19, 0x40, 0xb5, 0x16, 0xfa, 0xe3, 0x9a, 0x36, 0x33, 0xbc, + 0xf2, 0xcd, 0xeb, 0xd2, 0x3e, 0xc3, 0x4e, 0x6f, 0x94, 0x94, 0xdb, 0xa7, 0x87, 0x4e, 0xce, 0x5c, 0x17, + 0x11, 0x16, 0x0, 0x0, 0x12, 0x0, 0x1c, 0xde, 0x1d, 0x6f, 0x42, 0x5c, 0x5b, 0x30, 0xe5, 0xe1, 0xf0, + 0x14, 0xf6, 0x7, 0xe6, 0x10, 0x4a, 0xdc, 0xc6, 0x2d, 0xfa, 0xac, 0xe, 0x51, 0xdf, 0x63, 0xb7, 0x9c, + 0x42, 0x3, 0x0, 0x6, 0xfc, 0x40, 0x91, 0xe7, 0xc, 0xac, 0x22, 0x34, 0xe1, 0x19, 0xe4, 0x17, 0x65, + 0x17, 0x4e, 0x2, 0x0, 0x0, 0x6c, 0x20, 0x23, 0x2a, 0x7, 0xb, 0x7, 0x21, 0x2c, 0x81, 0x24, 0xb7, + 0x1, 0x66, 0x15, 0x0, 0x1, 0xd4, 0x13, 0x77, 0xcb, 0x19, 0x81, 0x2, 0x0, 0x0, 0x16, 0x38, 0xf9, + 0x9f, 0x4c, 0xa6, 0x84, 0x93, 0x60, 0x51, 0xce, 0xee, 0xe5, 0x8a, 0xd9, 0x7f, 0xdb, 0x9, 0xf3, 0x83, + 0xc0, 0x48, 0xf, 0x4a, 0xa8, 0x40, 0x79}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x21, 0xbd, 0x61, 0x5, 0xeb, 0x72, 0xba, 0xe8, 0x3f, 0x21, 0x8c, + 0x4f, 0x3e, 0xc9, 0xdc, 0xa3, 0x85, 0xa6, 0x21, 0x8b, 0x69}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf9, 0x9f, 0x4c, 0xa6, 0x84, 0x93, 0x60, 0x51, 0xce, 0xee, 0xe5, 0x8a, 0xd9, + 0x7f, 0xdb, 0x9, 0xf3, 0x83, 0xc0, 0x48, 0xf, 0x4a, 0xa8, 0x40, 0x79}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\216WQ\"", _pubPktID = 0, _pubBody = +// "\v\225\187\153*%\252qh\193\210\232\r0tw\196\176*\254C", _pubProps = [PropMessageExpiryInterval +// 17186,PropCorrelationData "C\214\155\209\176\162H\244v\167\201\244\243?\225\179\t\243%]\175\187",PropUserProperty +// "W\DC2yE\170\135\241z\181\152O\170%\US\185\156\DLEr\209sK\145\198\235=" +// "\153\132\199!\225\188\RSC\173\253\213\220\EOTWW\241\221\247\159b",PropTopicAliasMaximum 23680,PropTopicAliasMaximum +// 20899,PropSessionExpiryInterval 28081,PropMaximumQoS 158,PropMessageExpiryInterval 16231,PropUserProperty +// "\195\SI\ENQ=\216\&0D\152\151\f\SI=\249\238\a\176R" "\172\176\205\198\133%9\226\180h\139\248"]} TEST(Publish5QCTest, Encode6) { - uint8_t pkt[] = {0x35, 0x27, 0x0, 0x3, 0x2, 0x4f, 0x93, 0x31, 0x70, 0x12, 0x12, 0x0, 0xc, 0x20, - 0xfc, 0x56, 0x1e, 0xe9, 0xf5, 0x9e, 0x80, 0x96, 0xb8, 0xfe, 0xf5, 0x21, 0x11, 0x4c, - 0x8, 0xd5, 0x24, 0x91, 0xe5, 0xbb, 0x7a, 0xfc, 0x47, 0x20, 0x74, 0x93, 0x4e}; - - uint8_t buf[51] = {0}; - - uint8_t topic_bytes[] = {0x2, 0x4f, 0x93}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0xa1, 0x1, 0x0, 0x4, 0xd8, 0x57, 0x51, 0x22, 0x84, 0x1, 0x2, 0x0, 0x0, 0x43, 0x22, 0x9, + 0x0, 0x16, 0x43, 0xd6, 0x9b, 0xd1, 0xb0, 0xa2, 0x48, 0xf4, 0x76, 0xa7, 0xc9, 0xf4, 0xf3, 0x3f, 0xe1, + 0xb3, 0x9, 0xf3, 0x25, 0x5d, 0xaf, 0xbb, 0x26, 0x0, 0x19, 0x57, 0x12, 0x79, 0x45, 0xaa, 0x87, 0xf1, + 0x7a, 0xb5, 0x98, 0x4f, 0xaa, 0x25, 0x1f, 0xb9, 0x9c, 0x10, 0x72, 0xd1, 0x73, 0x4b, 0x91, 0xc6, 0xeb, + 0x3d, 0x0, 0x14, 0x99, 0x84, 0xc7, 0x21, 0xe1, 0xbc, 0x1e, 0x43, 0xad, 0xfd, 0xd5, 0xdc, 0x4, 0x57, + 0x57, 0xf1, 0xdd, 0xf7, 0x9f, 0x62, 0x22, 0x5c, 0x80, 0x22, 0x51, 0xa3, 0x11, 0x0, 0x0, 0x6d, 0xb1, + 0x24, 0x9e, 0x2, 0x0, 0x0, 0x3f, 0x67, 0x26, 0x0, 0x11, 0xc3, 0xf, 0x5, 0x3d, 0xd8, 0x30, 0x44, + 0x98, 0x97, 0xc, 0xf, 0x3d, 0xf9, 0xee, 0x7, 0xb0, 0x52, 0x0, 0xc, 0xac, 0xb0, 0xcd, 0xc6, 0x85, + 0x25, 0x39, 0xe2, 0xb4, 0x68, 0x8b, 0xf8, 0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, + 0xd2, 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; + + uint8_t buf[174] = {0}; + + uint8_t topic_bytes[] = {0xd8, 0x57, 0x51, 0x22}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x8, 0xd5, 0x24, 0x91, 0xe5, 0xbb, 0x7a, 0xfc, 0x47, 0x20, 0x74, 0x93, 0x4e}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, 0xd2, + 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; - - uint8_t bytesprops0[] = {0x20, 0xfc, 0x56, 0x1e, 0xe9, 0xf5, 0x9e, 0x80, 0x96, 0xb8, 0xfe, 0xf5}; + msg.payload_len = 21; + + uint8_t bytesprops0[] = {0x43, 0xd6, 0x9b, 0xd1, 0xb0, 0xa2, 0x48, 0xf4, 0x76, 0xa7, 0xc9, + 0xf4, 0xf3, 0x3f, 0xe1, 0xb3, 0x9, 0xf3, 0x25, 0x5d, 0xaf, 0xbb}; + uint8_t bytesprops2[] = {0x99, 0x84, 0xc7, 0x21, 0xe1, 0xbc, 0x1e, 0x43, 0xad, 0xfd, + 0xd5, 0xdc, 0x4, 0x57, 0x57, 0xf1, 0xdd, 0xf7, 0x9f, 0x62}; + uint8_t bytesprops1[] = {0x57, 0x12, 0x79, 0x45, 0xaa, 0x87, 0xf1, 0x7a, 0xb5, 0x98, 0x4f, 0xaa, 0x25, + 0x1f, 0xb9, 0x9c, 0x10, 0x72, 0xd1, 0x73, 0x4b, 0x91, 0xc6, 0xeb, 0x3d}; + uint8_t bytesprops4[] = {0xac, 0xb0, 0xcd, 0xc6, 0x85, 0x25, 0x39, 0xe2, 0xb4, 0x68, 0x8b, 0xf8}; + uint8_t bytesprops3[] = {0xc3, 0xf, 0x5, 0x3d, 0xd8, 0x30, 0x44, 0x98, 0x97, + 0xc, 0xf, 0x3d, 0xf9, 0xee, 0x7, 0xb0, 0x52}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4428}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17186}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops1}, .v = {20, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23680}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20899}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28081}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16231}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops3}, .v = {12, (char*)&bytesprops4}}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 12656, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "a \154R\188d2\n\193\213a_`\215\209", -// _pubPktID = 0, _pubBody = "\223\f\232\t\237\211\234\248", _pubProps = [PropRequestProblemInformation -// 97,PropServerKeepAlive 31945,PropContentType "N'/\251'.\FS\225",PropMaximumQoS 83,PropMessageExpiryInterval -// 24968,PropTopicAlias 8465,PropAuthenticationData "\128\a\156\230",PropResponseTopic -// "\ACK\243\182\177\174b\f\US\168I$\EOT#\151&\RS",PropMaximumPacketSize 7420,PropAuthenticationData -// "\199\ENQ\199\225\219u",PropSubscriptionIdentifierAvailable 243,PropMessageExpiryInterval -// 11397,PropMessageExpiryInterval 29159,PropResponseTopic -// "r\134:OosukI\239-\139\&9&\192F+\CAN\168{\199\148",PropResponseTopic "\170\143\179j\163",PropUserProperty -// "ZY\167m\229\252\215\166'`\148^\142\185\227\218\ESCns\191~)" "d\138\183\"\186z\141\154\SO",PropServerReference -// "\137O\226",PropMaximumQoS 132,PropMessageExpiryInterval 3796,PropAuthenticationData -// "\ENQ\141P\158D",PropRequestResponseInformation 51,PropSharedSubscriptionAvailable 173,PropTopicAlias 15896]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\216WQ\"", _pubPktID = 0, _pubBody = +// "\v\225\187\153*%\252qh\193\210\232\r0tw\196\176*\254C", _pubProps = [PropMessageExpiryInterval +// 17186,PropCorrelationData "C\214\155\209\176\162H\244v\167\201\244\243?\225\179\t\243%]\175\187",PropUserProperty +// "W\DC2yE\170\135\241z\181\152O\170%\US\185\156\DLEr\209sK\145\198\235=" +// "\153\132\199!\225\188\RSC\173\253\213\220\EOTWW\241\221\247\159b",PropTopicAliasMaximum 23680,PropTopicAliasMaximum +// 20899,PropSessionExpiryInterval 28081,PropMaximumQoS 158,PropMessageExpiryInterval 16231,PropUserProperty +// "\195\SI\ENQ=\216\&0D\152\151\f\SI=\249\238\a\176R" "\172\176\205\198\133%9\226\180h\139\248"]} +TEST(Publish5QCTest, Decode6) { + uint8_t pkt[] = {0x38, 0xa1, 0x1, 0x0, 0x4, 0xd8, 0x57, 0x51, 0x22, 0x84, 0x1, 0x2, 0x0, 0x0, 0x43, 0x22, 0x9, + 0x0, 0x16, 0x43, 0xd6, 0x9b, 0xd1, 0xb0, 0xa2, 0x48, 0xf4, 0x76, 0xa7, 0xc9, 0xf4, 0xf3, 0x3f, 0xe1, + 0xb3, 0x9, 0xf3, 0x25, 0x5d, 0xaf, 0xbb, 0x26, 0x0, 0x19, 0x57, 0x12, 0x79, 0x45, 0xaa, 0x87, 0xf1, + 0x7a, 0xb5, 0x98, 0x4f, 0xaa, 0x25, 0x1f, 0xb9, 0x9c, 0x10, 0x72, 0xd1, 0x73, 0x4b, 0x91, 0xc6, 0xeb, + 0x3d, 0x0, 0x14, 0x99, 0x84, 0xc7, 0x21, 0xe1, 0xbc, 0x1e, 0x43, 0xad, 0xfd, 0xd5, 0xdc, 0x4, 0x57, + 0x57, 0xf1, 0xdd, 0xf7, 0x9f, 0x62, 0x22, 0x5c, 0x80, 0x22, 0x51, 0xa3, 0x11, 0x0, 0x0, 0x6d, 0xb1, + 0x24, 0x9e, 0x2, 0x0, 0x0, 0x3f, 0x67, 0x26, 0x0, 0x11, 0xc3, 0xf, 0x5, 0x3d, 0xd8, 0x30, 0x44, + 0x98, 0x97, 0xc, 0xf, 0x3d, 0xf9, 0xee, 0x7, 0xb0, 0x52, 0x0, 0xc, 0xac, 0xb0, 0xcd, 0xc6, 0x85, + 0x25, 0x39, 0xe2, 0xb4, 0x68, 0x8b, 0xf8, 0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, + 0xd2, 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xd8, 0x57, 0x51, 0x22}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, 0xd2, + 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\130\tw\142", _pubPktID = 9801, +// _pubBody = "\154z+\141\DC3\201)z\n", _pubProps = [PropAuthenticationMethod +// "ZB@2{y\190\206\147\202;e\226\144\219s",PropMaximumQoS 20,PropUserProperty "=,\216\239\186\129\162\131" +// "\208&\170\&0K\204\184\&7\142\v\148\246\131%\224\222\255^\237`05\150\154\246\208Q",PropServerReference +// "\196\&8_\204\196\200+.\204x\v\143\245\242\196\227\233BG\t(\161Z\226@x",PropMaximumPacketSize +// 17975,PropWillDelayInterval 32302,PropReasonString "\204z\245\175\135k\225\ENQ\EOT\240\200\221\212!\207\167 +// 4\172]\213]\251B\142\GSV\219",PropPayloadFormatIndicator 233,PropContentType +// "\171\ENQ\DC3\151\236m\131\DC2\DLE1\214s\DC3\ESC\174\144k\164B\249\151",PropMaximumPacketSize 31507,PropTopicAlias +// 31094,PropCorrelationData "~\137s\238\239(\221\ESC\192\193\212",PropRequestProblemInformation +// 96,PropSessionExpiryInterval 30094,PropAuthenticationMethod +// "\DLE#\225\230b\190\225\214\188f\194M\211\219\SIk",PropWillDelayInterval 3844,PropReasonString +// "\172\ETX\142%\182M\SUB+\230\175\238\151",PropServerReference "\v\164\245\183\136\131J\184\249\225\134"]} TEST(Publish5QCTest, Encode7) { uint8_t pkt[] = { - 0x31, 0xca, 0x1, 0x0, 0xf, 0x61, 0x20, 0x9a, 0x52, 0xbc, 0x64, 0x32, 0xa, 0xc1, 0xd5, 0x61, 0x5f, 0x60, 0xd7, - 0xd1, 0xaf, 0x1, 0x17, 0x61, 0x13, 0x7c, 0xc9, 0x3, 0x0, 0x8, 0x4e, 0x27, 0x2f, 0xfb, 0x27, 0x2e, 0x1c, 0xe1, - 0x24, 0x53, 0x2, 0x0, 0x0, 0x61, 0x88, 0x23, 0x21, 0x11, 0x16, 0x0, 0x4, 0x80, 0x7, 0x9c, 0xe6, 0x8, 0x0, - 0x10, 0x6, 0xf3, 0xb6, 0xb1, 0xae, 0x62, 0xc, 0x1f, 0xa8, 0x49, 0x24, 0x4, 0x23, 0x97, 0x26, 0x1e, 0x27, 0x0, - 0x0, 0x1c, 0xfc, 0x16, 0x0, 0x6, 0xc7, 0x5, 0xc7, 0xe1, 0xdb, 0x75, 0x29, 0xf3, 0x2, 0x0, 0x0, 0x2c, 0x85, - 0x2, 0x0, 0x0, 0x71, 0xe7, 0x8, 0x0, 0x16, 0x72, 0x86, 0x3a, 0x4f, 0x6f, 0x73, 0x75, 0x6b, 0x49, 0xef, 0x2d, - 0x8b, 0x39, 0x26, 0xc0, 0x46, 0x2b, 0x18, 0xa8, 0x7b, 0xc7, 0x94, 0x8, 0x0, 0x5, 0xaa, 0x8f, 0xb3, 0x6a, 0xa3, - 0x26, 0x0, 0x16, 0x5a, 0x59, 0xa7, 0x6d, 0xe5, 0xfc, 0xd7, 0xa6, 0x27, 0x60, 0x94, 0x5e, 0x8e, 0xb9, 0xe3, 0xda, - 0x1b, 0x6e, 0x73, 0xbf, 0x7e, 0x29, 0x0, 0x9, 0x64, 0x8a, 0xb7, 0x22, 0xba, 0x7a, 0x8d, 0x9a, 0xe, 0x1c, 0x0, - 0x3, 0x89, 0x4f, 0xe2, 0x24, 0x84, 0x2, 0x0, 0x0, 0xe, 0xd4, 0x16, 0x0, 0x5, 0x5, 0x8d, 0x50, 0x9e, 0x44, - 0x19, 0x33, 0x2a, 0xad, 0x23, 0x3e, 0x18, 0xdf, 0xc, 0xe8, 0x9, 0xed, 0xd3, 0xea, 0xf8}; - - uint8_t buf[215] = {0}; - - uint8_t topic_bytes[] = {0x61, 0x20, 0x9a, 0x52, 0xbc, 0x64, 0x32, 0xa, 0xc1, 0xd5, 0x61, 0x5f, 0x60, 0xd7, 0xd1}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + 0x32, 0x82, 0x2, 0x0, 0x4, 0x82, 0x9, 0x77, 0x8e, 0x26, 0x49, 0xef, 0x1, 0x15, 0x0, 0x10, 0x5a, 0x42, 0x40, + 0x32, 0x7b, 0x79, 0xbe, 0xce, 0x93, 0xca, 0x3b, 0x65, 0xe2, 0x90, 0xdb, 0x73, 0x24, 0x14, 0x26, 0x0, 0x8, 0x3d, + 0x2c, 0xd8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0xac, 0x3, + 0x8e, 0x25, 0xb6, 0x4d, 0x1a, 0x2b, 0xe6, 0xaf, 0xee, 0x97, 0x1c, 0x0, 0xb, 0xb, 0xa4, 0xf5, 0xb7, 0x88, 0x83, + 0x4a, 0xb8, 0xf9, 0xe1, 0x86, 0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; + + uint8_t buf[271] = {0}; + + uint8_t topic_bytes[] = {0x82, 0x9, 0x77, 0x8e}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xdf, 0xc, 0xe8, 0x9, 0xed, 0xd3, 0xea, 0xf8}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 8; - - uint8_t bytesprops0[] = {0x4e, 0x27, 0x2f, 0xfb, 0x27, 0x2e, 0x1c, 0xe1}; - uint8_t bytesprops1[] = {0x80, 0x7, 0x9c, 0xe6}; - uint8_t bytesprops2[] = {0x6, 0xf3, 0xb6, 0xb1, 0xae, 0x62, 0xc, 0x1f, 0xa8, 0x49, 0x24, 0x4, 0x23, 0x97, 0x26, 0x1e}; - uint8_t bytesprops3[] = {0xc7, 0x5, 0xc7, 0xe1, 0xdb, 0x75}; - uint8_t bytesprops4[] = {0x72, 0x86, 0x3a, 0x4f, 0x6f, 0x73, 0x75, 0x6b, 0x49, 0xef, 0x2d, - 0x8b, 0x39, 0x26, 0xc0, 0x46, 0x2b, 0x18, 0xa8, 0x7b, 0xc7, 0x94}; - uint8_t bytesprops5[] = {0xaa, 0x8f, 0xb3, 0x6a, 0xa3}; - uint8_t bytesprops7[] = {0x64, 0x8a, 0xb7, 0x22, 0xba, 0x7a, 0x8d, 0x9a, 0xe}; - uint8_t bytesprops6[] = {0x5a, 0x59, 0xa7, 0x6d, 0xe5, 0xfc, 0xd7, 0xa6, 0x27, 0x60, 0x94, - 0x5e, 0x8e, 0xb9, 0xe3, 0xda, 0x1b, 0x6e, 0x73, 0xbf, 0x7e, 0x29}; - uint8_t bytesprops8[] = {0x89, 0x4f, 0xe2}; - uint8_t bytesprops9[] = {0x5, 0x8d, 0x50, 0x9e, 0x44}; + msg.payload_len = 9; + + uint8_t bytesprops0[] = {0x5a, 0x42, 0x40, 0x32, 0x7b, 0x79, 0xbe, 0xce, + 0x93, 0xca, 0x3b, 0x65, 0xe2, 0x90, 0xdb, 0x73}; + uint8_t bytesprops2[] = {0xd0, 0x26, 0xaa, 0x30, 0x4b, 0xcc, 0xb8, 0x37, 0x8e, 0xb, 0x94, 0xf6, 0x83, 0x25, + 0xe0, 0xde, 0xff, 0x5e, 0xed, 0x60, 0x30, 0x35, 0x96, 0x9a, 0xf6, 0xd0, 0x51}; + uint8_t bytesprops1[] = {0x3d, 0x2c, 0xd8, 0xef, 0xba, 0x81, 0xa2, 0x83}; + uint8_t bytesprops3[] = {0xc4, 0x38, 0x5f, 0xcc, 0xc4, 0xc8, 0x2b, 0x2e, 0xcc, 0x78, 0xb, 0x8f, 0xf5, + 0xf2, 0xc4, 0xe3, 0xe9, 0x42, 0x47, 0x9, 0x28, 0xa1, 0x5a, 0xe2, 0x40, 0x78}; + uint8_t bytesprops4[] = {0xcc, 0x7a, 0xf5, 0xaf, 0x87, 0x6b, 0xe1, 0x5, 0x4, 0xf0, 0xc8, 0xdd, 0xd4, 0x21, + 0xcf, 0xa7, 0x20, 0x34, 0xac, 0x5d, 0xd5, 0x5d, 0xfb, 0x42, 0x8e, 0x1d, 0x56, 0xdb}; + uint8_t bytesprops5[] = {0xab, 0x5, 0x13, 0x97, 0xec, 0x6d, 0x83, 0x12, 0x10, 0x31, 0xd6, + 0x73, 0x13, 0x1b, 0xae, 0x90, 0x6b, 0xa4, 0x42, 0xf9, 0x97}; + uint8_t bytesprops6[] = {0x7e, 0x89, 0x73, 0xee, 0xef, 0x28, 0xdd, 0x1b, 0xc0, 0xc1, 0xd4}; + uint8_t bytesprops7[] = {0x10, 0x23, 0xe1, 0xe6, 0x62, 0xbe, 0xe1, 0xd6, + 0xbc, 0x66, 0xc2, 0x4d, 0xd3, 0xdb, 0xf, 0x6b}; + uint8_t bytesprops8[] = {0xac, 0x3, 0x8e, 0x25, 0xb6, 0x4d, 0x1a, 0x2b, 0xe6, 0xaf, 0xee, 0x97}; + uint8_t bytesprops9[] = {0xb, 0xa4, 0xf5, 0xb7, 0x88, 0x83, 0x4a, 0xb8, 0xf9, 0xe1, 0x86}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31945}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24968}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8465}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7420}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11397}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29159}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops6}, .v = {9, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3796}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15896}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops1}, .v = {27, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17975}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32302}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31507}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31094}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30094}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3844}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 9801, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\130\tw\142", _pubPktID = 9801, +// _pubBody = "\154z+\141\DC3\201)z\n", _pubProps = [PropAuthenticationMethod +// "ZB@2{y\190\206\147\202;e\226\144\219s",PropMaximumQoS 20,PropUserProperty "=,\216\239\186\129\162\131" +// "\208&\170\&0K\204\184\&7\142\v\148\246\131%\224\222\255^\237`05\150\154\246\208Q",PropServerReference +// "\196\&8_\204\196\200+.\204x\v\143\245\242\196\227\233BG\t(\161Z\226@x",PropMaximumPacketSize +// 17975,PropWillDelayInterval 32302,PropReasonString "\204z\245\175\135k\225\ENQ\EOT\240\200\221\212!\207\167 +// 4\172]\213]\251B\142\GSV\219",PropPayloadFormatIndicator 233,PropContentType +// "\171\ENQ\DC3\151\236m\131\DC2\DLE1\214s\DC3\ESC\174\144k\164B\249\151",PropMaximumPacketSize 31507,PropTopicAlias +// 31094,PropCorrelationData "~\137s\238\239(\221\ESC\192\193\212",PropRequestProblemInformation +// 96,PropSessionExpiryInterval 30094,PropAuthenticationMethod +// "\DLE#\225\230b\190\225\214\188f\194M\211\219\SIk",PropWillDelayInterval 3844,PropReasonString +// "\172\ETX\142%\182M\SUB+\230\175\238\151",PropServerReference "\v\164\245\183\136\131J\184\249\225\134"]} +TEST(Publish5QCTest, Decode7) { + uint8_t pkt[] = { + 0x32, 0x82, 0x2, 0x0, 0x4, 0x82, 0x9, 0x77, 0x8e, 0x26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, 0x75, 0x8e, 0x15, 0x0, 0x10, 0x10, 0x23, 0xe1, 0xe6, 0x62, 0xbe, 0xe1, + 0xd6, 0xbc, 0x66, 0xc2, 0x4d, 0xd3, 0xdb, 0xf, 0x6b, 0x18, 0x0, 0x0, 0xf, 0x4, 0x1f, 0x0, 0xc, 0xac, 0x3, + 0x8e, 0x25, 0xb6, 0x4d, 0x1a, 0x2b, 0xe6, 0xaf, 0xee, 0x97, 0x1c, 0x0, 0xb, 0xb, 0xa4, 0xf5, 0xb7, 0x88, 0x83, + 0x4a, 0xb8, 0xf9, 0xe1, 0x86, 0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x82, 0x9, 0x77, 0x8e}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 9801); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "e\144}\187\204\234\r\DLE\238\SOHC\168\198\137\151;\170\232", _pubPktID = 0, _pubBody = -// "u\221\241\212\194^\n\142\246\204\133\216\SOH\232\215\139\249)", _pubProps = [PropMessageExpiryInterval -// 548,PropSharedSubscriptionAvailable 3,PropSubscriptionIdentifier 21,PropSubscriptionIdentifierAvailable -// 46,PropSessionExpiryInterval 21517,PropAuthenticationMethod -// "(OV\255B\EM\232\131\NULqlC#\n\250\233\150D\ACK",PropServerKeepAlive 30127]} +// "W\165\ETX\202d\140Z\185\FSm\158\159\206Gj\177D\DC3\250=", _pubPktID = 0, _pubBody = +// "\204r\156\176\144\163\ESC+\228\214X\196\&6\212\179\NULI\132\128`nQ\153\188\153", _pubProps = [PropContentType +// "\238\173[.y\187\201",PropCorrelationData +// "\196u\DC2K\206\224\240\249\238\DC3>\175\GS\EMS6/v*\SI\222\EM\236\153\245$=",PropMaximumPacketSize +// 16725,PropSharedSubscriptionAvailable 42,PropAuthenticationData "\147\"?\178\238)\SOH +// \246\196\211\208\183<\180W\n",PropServerKeepAlive 9570,PropCorrelationData +// "\ESC?\180\ETB\217B\r\176B\166^\190\FS\a'\189\247\t]\246\171P\200\138",PropRequestResponseInformation +// 148,PropRequestResponseInformation 49,PropRequestResponseInformation 139,PropResponseTopic +// "",PropAssignedClientIdentifier ""]} TEST(Publish5QCTest, Encode8) { - uint8_t pkt[] = {0x39, 0x50, 0x0, 0x12, 0x65, 0x90, 0x7d, 0xbb, 0xcc, 0xea, 0xd, 0x10, 0xee, 0x1, 0x43, 0xa8, 0xc6, - 0x89, 0x97, 0x3b, 0xaa, 0xe8, 0x29, 0x2, 0x0, 0x0, 0x2, 0x24, 0x2a, 0x3, 0xb, 0x15, 0x29, 0x2e, - 0x11, 0x0, 0x0, 0x54, 0xd, 0x15, 0x0, 0x13, 0x28, 0x4f, 0x56, 0xff, 0x42, 0x19, 0xe8, 0x83, 0x0, - 0x71, 0x6c, 0x43, 0x23, 0xa, 0xfa, 0xe9, 0x96, 0x44, 0x6, 0x13, 0x75, 0xaf, 0x75, 0xdd, 0xf1, 0xd4, - 0xc2, 0x5e, 0xa, 0x8e, 0xf6, 0xcc, 0x85, 0xd8, 0x1, 0xe8, 0xd7, 0x8b, 0xf9, 0x29}; + uint8_t pkt[] = {0x39, 0x9d, 0x1, 0x0, 0x14, 0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, 0x9e, + 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d, 0x6d, 0x3, 0x0, 0x7, 0xee, 0xad, 0x5b, + 0x2e, 0x79, 0xbb, 0xc9, 0x9, 0x0, 0x1b, 0xc4, 0x75, 0x12, 0x4b, 0xce, 0xe0, 0xf0, 0xf9, 0xee, + 0x13, 0x3e, 0xaf, 0x1d, 0x19, 0x53, 0x36, 0x2f, 0x76, 0x2a, 0xf, 0xde, 0x19, 0xec, 0x99, 0xf5, + 0x24, 0x3d, 0x27, 0x0, 0x0, 0x41, 0x55, 0x2a, 0x2a, 0x16, 0x0, 0x11, 0x93, 0x22, 0x3f, 0xb2, + 0xee, 0x29, 0x1, 0x20, 0xf6, 0xc4, 0xd3, 0xd0, 0xb7, 0x3c, 0xb4, 0x57, 0xa, 0x13, 0x25, 0x62, + 0x9, 0x0, 0x18, 0x1b, 0x3f, 0xb4, 0x17, 0xd9, 0x42, 0xd, 0xb0, 0x42, 0xa6, 0x5e, 0xbe, 0x1c, + 0x7, 0x27, 0xbd, 0xf7, 0x9, 0x5d, 0xf6, 0xab, 0x50, 0xc8, 0x8a, 0x19, 0x94, 0x19, 0x31, 0x19, + 0x8b, 0x8, 0x0, 0x0, 0x12, 0x0, 0x0, 0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, + 0xd6, 0x58, 0xc4, 0x36, 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; - uint8_t buf[92] = {0}; + uint8_t buf[170] = {0}; - uint8_t topic_bytes[] = {0x65, 0x90, 0x7d, 0xbb, 0xcc, 0xea, 0xd, 0x10, 0xee, - 0x1, 0x43, 0xa8, 0xc6, 0x89, 0x97, 0x3b, 0xaa, 0xe8}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, + 0x9e, 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x75, 0xdd, 0xf1, 0xd4, 0xc2, 0x5e, 0xa, 0x8e, 0xf6, - 0xcc, 0x85, 0xd8, 0x1, 0xe8, 0xd7, 0x8b, 0xf9, 0x29}; + uint8_t msg_bytes[] = {0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, 0x58, 0xc4, 0x36, + 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; - - uint8_t bytesprops0[] = {0x28, 0x4f, 0x56, 0xff, 0x42, 0x19, 0xe8, 0x83, 0x0, 0x71, - 0x6c, 0x43, 0x23, 0xa, 0xfa, 0xe9, 0x96, 0x44, 0x6}; + msg.payload_len = 25; + + uint8_t bytesprops0[] = {0xee, 0xad, 0x5b, 0x2e, 0x79, 0xbb, 0xc9}; + uint8_t bytesprops1[] = {0xc4, 0x75, 0x12, 0x4b, 0xce, 0xe0, 0xf0, 0xf9, 0xee, 0x13, 0x3e, 0xaf, 0x1d, 0x19, + 0x53, 0x36, 0x2f, 0x76, 0x2a, 0xf, 0xde, 0x19, 0xec, 0x99, 0xf5, 0x24, 0x3d}; + uint8_t bytesprops2[] = {0x93, 0x22, 0x3f, 0xb2, 0xee, 0x29, 0x1, 0x20, 0xf6, + 0xc4, 0xd3, 0xd0, 0xb7, 0x3c, 0xb4, 0x57, 0xa}; + uint8_t bytesprops3[] = {0x1b, 0x3f, 0xb4, 0x17, 0xd9, 0x42, 0xd, 0xb0, 0x42, 0xa6, 0x5e, 0xbe, + 0x1c, 0x7, 0x27, 0xbd, 0xf7, 0x9, 0x5d, 0xf6, 0xab, 0x50, 0xc8, 0x8a}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 548}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21517}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30127}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16725}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9570}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); @@ -816,181 +1511,357 @@ TEST(Publish5QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "", _pubPktID = 2526, _pubBody = -// "\230r\220N\f\196\206\176_\178\199 P\193-;\128\182%[", _pubProps = [PropTopicAlias 14375,PropUserProperty "" -// "\CAN\168[j\236\236\204\ACK\214\rpk\DLE\242a\144\217\181\208\SOH\t|\146:\249",PropUserProperty -// "\151\r\128Fo\144\211\DC1<\EM\153\190NU6\134'>\186]" -// "uhX\173\171\223\&7\248\223\US1ODw4\203\177\ESC\EOT1\246]3\168\131\129N\EM\207\238",PropCorrelationData -// "\139\210\185\155\SUB\r\191"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "W\165\ETX\202d\140Z\185\FSm\158\159\206Gj\177D\DC3\250=", _pubPktID = 0, _pubBody = +// "\204r\156\176\144\163\ESC+\228\214X\196\&6\212\179\NULI\132\128`nQ\153\188\153", _pubProps = [PropContentType +// "\238\173[.y\187\201",PropCorrelationData +// "\196u\DC2K\206\224\240\249\238\DC3>\175\GS\EMS6/v*\SI\222\EM\236\153\245$=",PropMaximumPacketSize +// 16725,PropSharedSubscriptionAvailable 42,PropAuthenticationData "\147\"?\178\238)\SOH +// \246\196\211\208\183<\180W\n",PropServerKeepAlive 9570,PropCorrelationData +// "\ESC?\180\ETB\217B\r\176B\166^\190\FS\a'\189\247\t]\246\171P\200\138",PropRequestResponseInformation +// 148,PropRequestResponseInformation 49,PropRequestResponseInformation 139,PropResponseTopic +// "",PropAssignedClientIdentifier ""]} +TEST(Publish5QCTest, Decode8) { + uint8_t pkt[] = {0x39, 0x9d, 0x1, 0x0, 0x14, 0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, 0x9e, + 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d, 0x6d, 0x3, 0x0, 0x7, 0xee, 0xad, 0x5b, + 0x2e, 0x79, 0xbb, 0xc9, 0x9, 0x0, 0x1b, 0xc4, 0x75, 0x12, 0x4b, 0xce, 0xe0, 0xf0, 0xf9, 0xee, + 0x13, 0x3e, 0xaf, 0x1d, 0x19, 0x53, 0x36, 0x2f, 0x76, 0x2a, 0xf, 0xde, 0x19, 0xec, 0x99, 0xf5, + 0x24, 0x3d, 0x27, 0x0, 0x0, 0x41, 0x55, 0x2a, 0x2a, 0x16, 0x0, 0x11, 0x93, 0x22, 0x3f, 0xb2, + 0xee, 0x29, 0x1, 0x20, 0xf6, 0xc4, 0xd3, 0xd0, 0xb7, 0x3c, 0xb4, 0x57, 0xa, 0x13, 0x25, 0x62, + 0x9, 0x0, 0x18, 0x1b, 0x3f, 0xb4, 0x17, 0xd9, 0x42, 0xd, 0xb0, 0x42, 0xa6, 0x5e, 0xbe, 0x1c, + 0x7, 0x27, 0xbd, 0xf7, 0x9, 0x5d, 0xf6, 0xab, 0x50, 0xc8, 0x8a, 0x19, 0x94, 0x19, 0x31, 0x19, + 0x8b, 0x8, 0x0, 0x0, 0x12, 0x0, 0x0, 0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, + 0xd6, 0x58, 0xc4, 0x36, 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, + 0x9e, 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, 0x58, 0xc4, 0x36, + 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\STX", _pubPktID = 30584, _pubBody = +// "u\219\"\173\243\187\226Z\193\t\210\"\201K)", _pubProps = [PropSharedSubscriptionAvailable +// 48,PropPayloadFormatIndicator 15,PropSubscriptionIdentifierAvailable 46,PropContentType "\220\191\t;G\215.\NUL +// (\148N&\156\242\186\142",PropSubscriptionIdentifierAvailable 8,PropCorrelationData +// ":\223\CAN\213\&6\135ah\135\224\239S\185\249\DEL\162;\250\ESC\233",PropPayloadFormatIndicator 112,PropCorrelationData +// "\RS\129\208>\230\f\246I\196\246\250K\130\163\242\221",PropReceiveMaximum 15410,PropWillDelayInterval +// 6524,PropServerReference "\144\201\151\159{&\248\208\215\ETXb\198\175\ETX\215!"]} TEST(Publish5QCTest, Encode9) { - uint8_t pkt[] = {0x3a, 0x7b, 0x0, 0x0, 0x9, 0xde, 0x62, 0x23, 0x38, 0x27, 0x26, 0x0, 0x0, 0x0, 0x19, 0x18, - 0xa8, 0x5b, 0x6a, 0xec, 0xec, 0xcc, 0x6, 0xd6, 0xd, 0x70, 0x6b, 0x10, 0xf2, 0x61, 0x90, 0xd9, - 0xb5, 0xd0, 0x1, 0x9, 0x7c, 0x92, 0x3a, 0xf9, 0x26, 0x0, 0x14, 0x97, 0xd, 0x80, 0x46, 0x6f, - 0x90, 0xd3, 0x11, 0x3c, 0x19, 0x99, 0xbe, 0x4e, 0x55, 0x36, 0x86, 0x27, 0x3e, 0xba, 0x5d, 0x0, - 0x1e, 0x75, 0x68, 0x58, 0xad, 0xab, 0xdf, 0x37, 0xf8, 0xdf, 0x1f, 0x31, 0x4f, 0x44, 0x77, 0x34, - 0xcb, 0xb1, 0x1b, 0x4, 0x31, 0xf6, 0x5d, 0x33, 0xa8, 0x83, 0x81, 0x4e, 0x19, 0xcf, 0xee, 0x9, - 0x0, 0x7, 0x8b, 0xd2, 0xb9, 0x9b, 0x1a, 0xd, 0xbf, 0xe6, 0x72, 0xdc, 0x4e, 0xc, 0xc4, 0xce, - 0xb0, 0x5f, 0xb2, 0xc7, 0x20, 0x50, 0xc1, 0x2d, 0x3b, 0x80, 0xb6, 0x25, 0x5b}; - - uint8_t buf[135] = {0}; - - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x78, 0x0, 0x1, 0x2, 0x77, 0x78, 0x63, 0x2a, 0x30, 0x1, 0xf, 0x29, 0x2e, 0x3, 0x0, + 0x11, 0xdc, 0xbf, 0x9, 0x3b, 0x47, 0xd7, 0x2e, 0x0, 0x20, 0x28, 0x94, 0x4e, 0x26, 0x9c, 0xf2, + 0xba, 0x8e, 0x29, 0x8, 0x9, 0x0, 0x14, 0x3a, 0xdf, 0x18, 0xd5, 0x36, 0x87, 0x61, 0x68, 0x87, + 0xe0, 0xef, 0x53, 0xb9, 0xf9, 0x7f, 0xa2, 0x3b, 0xfa, 0x1b, 0xe9, 0x1, 0x70, 0x9, 0x0, 0x10, + 0x1e, 0x81, 0xd0, 0x3e, 0xe6, 0xc, 0xf6, 0x49, 0xc4, 0xf6, 0xfa, 0x4b, 0x82, 0xa3, 0xf2, 0xdd, + 0x21, 0x3c, 0x32, 0x18, 0x0, 0x0, 0x19, 0x7c, 0x1c, 0x0, 0x10, 0x90, 0xc9, 0x97, 0x9f, 0x7b, + 0x26, 0xf8, 0xd0, 0xd7, 0x3, 0x62, 0xc6, 0xaf, 0x3, 0xd7, 0x21, 0x75, 0xdb, 0x22, 0xad, 0xf3, + 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; + + uint8_t buf[132] = {0}; + + uint8_t topic_bytes[] = {0x2}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xe6, 0x72, 0xdc, 0x4e, 0xc, 0xc4, 0xce, 0xb0, 0x5f, 0xb2, - 0xc7, 0x20, 0x50, 0xc1, 0x2d, 0x3b, 0x80, 0xb6, 0x25, 0x5b}; + msg.retained = true; + uint8_t msg_bytes[] = {0x75, 0xdb, 0x22, 0xad, 0xf3, 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 15; - uint8_t bytesprops1[] = {0x18, 0xa8, 0x5b, 0x6a, 0xec, 0xec, 0xcc, 0x6, 0xd6, 0xd, 0x70, 0x6b, 0x10, - 0xf2, 0x61, 0x90, 0xd9, 0xb5, 0xd0, 0x1, 0x9, 0x7c, 0x92, 0x3a, 0xf9}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops3[] = {0x75, 0x68, 0x58, 0xad, 0xab, 0xdf, 0x37, 0xf8, 0xdf, 0x1f, 0x31, 0x4f, 0x44, 0x77, 0x34, - 0xcb, 0xb1, 0x1b, 0x4, 0x31, 0xf6, 0x5d, 0x33, 0xa8, 0x83, 0x81, 0x4e, 0x19, 0xcf, 0xee}; - uint8_t bytesprops2[] = {0x97, 0xd, 0x80, 0x46, 0x6f, 0x90, 0xd3, 0x11, 0x3c, 0x19, - 0x99, 0xbe, 0x4e, 0x55, 0x36, 0x86, 0x27, 0x3e, 0xba, 0x5d}; - uint8_t bytesprops4[] = {0x8b, 0xd2, 0xb9, 0x9b, 0x1a, 0xd, 0xbf}; + uint8_t bytesprops0[] = {0xdc, 0xbf, 0x9, 0x3b, 0x47, 0xd7, 0x2e, 0x0, 0x20, + 0x28, 0x94, 0x4e, 0x26, 0x9c, 0xf2, 0xba, 0x8e}; + uint8_t bytesprops1[] = {0x3a, 0xdf, 0x18, 0xd5, 0x36, 0x87, 0x61, 0x68, 0x87, 0xe0, + 0xef, 0x53, 0xb9, 0xf9, 0x7f, 0xa2, 0x3b, 0xfa, 0x1b, 0xe9}; + uint8_t bytesprops2[] = {0x1e, 0x81, 0xd0, 0x3e, 0xe6, 0xc, 0xf6, 0x49, + 0xc4, 0xf6, 0xfa, 0x4b, 0x82, 0xa3, 0xf2, 0xdd}; + uint8_t bytesprops3[] = {0x90, 0xc9, 0x97, 0x9f, 0x7b, 0x26, 0xf8, 0xd0, + 0xd7, 0x3, 0x62, 0xc6, 0xaf, 0x3, 0xd7, 0x21}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14375}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops2}, .v = {30, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15410}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6524}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2526, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 30584, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\STX", _pubPktID = 30584, _pubBody = +// "u\219\"\173\243\187\226Z\193\t\210\"\201K)", _pubProps = [PropSharedSubscriptionAvailable +// 48,PropPayloadFormatIndicator 15,PropSubscriptionIdentifierAvailable 46,PropContentType "\220\191\t;G\215.\NUL +// (\148N&\156\242\186\142",PropSubscriptionIdentifierAvailable 8,PropCorrelationData +// ":\223\CAN\213\&6\135ah\135\224\239S\185\249\DEL\162;\250\ESC\233",PropPayloadFormatIndicator 112,PropCorrelationData +// "\RS\129\208>\230\f\246I\196\246\250K\130\163\242\221",PropReceiveMaximum 15410,PropWillDelayInterval +// 6524,PropServerReference "\144\201\151\159{&\248\208\215\ETXb\198\175\ETX\215!"]} +TEST(Publish5QCTest, Decode9) { + uint8_t pkt[] = {0x3b, 0x78, 0x0, 0x1, 0x2, 0x77, 0x78, 0x63, 0x2a, 0x30, 0x1, 0xf, 0x29, 0x2e, 0x3, 0x0, + 0x11, 0xdc, 0xbf, 0x9, 0x3b, 0x47, 0xd7, 0x2e, 0x0, 0x20, 0x28, 0x94, 0x4e, 0x26, 0x9c, 0xf2, + 0xba, 0x8e, 0x29, 0x8, 0x9, 0x0, 0x14, 0x3a, 0xdf, 0x18, 0xd5, 0x36, 0x87, 0x61, 0x68, 0x87, + 0xe0, 0xef, 0x53, 0xb9, 0xf9, 0x7f, 0xa2, 0x3b, 0xfa, 0x1b, 0xe9, 0x1, 0x70, 0x9, 0x0, 0x10, + 0x1e, 0x81, 0xd0, 0x3e, 0xe6, 0xc, 0xf6, 0x49, 0xc4, 0xf6, 0xfa, 0x4b, 0x82, 0xa3, 0xf2, 0xdd, + 0x21, 0x3c, 0x32, 0x18, 0x0, 0x0, 0x19, 0x7c, 0x1c, 0x0, 0x10, 0x90, 0xc9, 0x97, 0x9f, 0x7b, + 0x26, 0xf8, 0xd0, 0xd7, 0x3, 0x62, 0xc6, 0xaf, 0x3, 0xd7, 0x21, 0x75, 0xdb, 0x22, 0xad, 0xf3, + 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x2}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x75, 0xdb, 0x22, 0xad, 0xf3, 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 30584); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "E_/\183|O\206\131\173f\212\204", +// _pubPktID = 31613, _pubBody = "\155\216/Ef", _pubProps = [PropServerReference +// "r>\SOX\140\NUL\SO\ETX\176\133B\f\156\234\STX\202_:\EOT\160\206n\219\229H\151\SI\185",PropMaximumQoS +// 173,PropReceiveMaximum 18751,PropRequestResponseInformation 60,PropMaximumPacketSize 6732,PropReceiveMaximum +// 11501,PropSessionExpiryInterval 17948,PropServerKeepAlive 10159,PropServerKeepAlive +// 4218,PropRequestProblemInformation 31,PropMessageExpiryInterval 31284,PropServerReference +// "\SO\220\235",PropReceiveMaximum 15238,PropMessageExpiryInterval 8262,PropContentType +// "\137)\ESCSg\226S\205\235\RS\194\DC2e\246\ESC\146\SO\216",PropRetainAvailable 89,PropMaximumPacketSize +// 21478,PropServerKeepAlive 12711,PropAuthenticationMethod +// "\DC4\182\SYNJ\156\159\224{\RS\146Q\151\229\207\185\146\SIaEOCa",PropServerReference +// "P\229fx\DC4\131\176Wk\ETBXI\ETX\142",PropAssignedClientIdentifier +// "\ESCV5\DC1\ENQ-\215\246\172F\140\242\\V\188\SI!\222\STX\DLE\249",PropRequestResponseInformation +// 120,PropWillDelayInterval 16810,PropSubscriptionIdentifier 16]} +TEST(Publish5QCTest, Encode10) { + uint8_t pkt[] = {0x32, 0xcf, 0x1, 0x0, 0xc, 0x45, 0x5f, 0x2f, 0xb7, 0x7c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18, 0x0, 0x0, 0x41, 0xaa, 0xb, + 0x10, 0x9b, 0xd8, 0x2f, 0x45, 0x66}; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[220] = {0}; -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "}5\238\204\DC2\254\162n\196-\172U\\\169\162\FS\RS\"\189v\148\229\\\223\144|\223\NUL\203", _pubProps = -// [PropResponseTopic "f\145\140\205",PropSharedSubscriptionAvailable 213,PropReceiveMaximum -// 32116,PropSubscriptionIdentifierAvailable 232,PropCorrelationData -// "\178:4~\ESCW\197\185\219\NAK8\235\ETX\249\DEL4!\170",PropMaximumQoS 107,PropRequestProblemInformation -// 183,PropAuthenticationMethod "\214\218>\166\211\140\225\198\162\252\225\195\139\SOH\200,\222",PropServerKeepAlive -// 24310,PropWillDelayInterval 24774,PropMaximumQoS 165,PropResponseTopic -// "\FS\199k\197\227\NAK\183\135\ENQ\145\183*\190\255zg^\220&n\217r.\159",PropRequestProblemInformation -// 131,PropSharedSubscriptionAvailable 206,PropCorrelationData -// "@?m1T\SI\228\207\&2\160c\194\&0S\194\191\223\222",PropSubscriptionIdentifierAvailable 51]} -TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = {0x30, 0x9b, 0x1, 0x0, 0x0, 0x7b, 0x8, 0x0, 0x4, 0x66, 0x91, 0x8c, 0xcd, 0x2a, 0xd5, 0x21, - 0x7d, 0x74, 0x29, 0xe8, 0x9, 0x0, 0x12, 0xb2, 0x3a, 0x34, 0x7e, 0x1b, 0x57, 0xc5, 0xb9, 0xdb, - 0x15, 0x38, 0xeb, 0x3, 0xf9, 0x7f, 0x34, 0x21, 0xaa, 0x24, 0x6b, 0x17, 0xb7, 0x15, 0x0, 0x11, - 0xd6, 0xda, 0x3e, 0xa6, 0xd3, 0x8c, 0xe1, 0xc6, 0xa2, 0xfc, 0xe1, 0xc3, 0x8b, 0x1, 0xc8, 0x2c, - 0xde, 0x13, 0x5e, 0xf6, 0x18, 0x0, 0x0, 0x60, 0xc6, 0x24, 0xa5, 0x8, 0x0, 0x18, 0x1c, 0xc7, - 0x6b, 0xc5, 0xe3, 0x15, 0xb7, 0x87, 0x5, 0x91, 0xb7, 0x2a, 0xbe, 0xff, 0x7a, 0x67, 0x5e, 0xdc, - 0x26, 0x6e, 0xd9, 0x72, 0x2e, 0x9f, 0x17, 0x83, 0x2a, 0xce, 0x9, 0x0, 0x12, 0x40, 0x3f, 0x6d, - 0x31, 0x54, 0xf, 0xe4, 0xcf, 0x32, 0xa0, 0x63, 0xc2, 0x30, 0x53, 0xc2, 0xbf, 0xdf, 0xde, 0x29, - 0x33, 0x7d, 0x35, 0xee, 0xcc, 0x12, 0xfe, 0xa2, 0x6e, 0xc4, 0x2d, 0xac, 0x55, 0x5c, 0xa9, 0xa2, - 0x1c, 0x1e, 0x22, 0xbd, 0x76, 0x94, 0xe5, 0x5c, 0xdf, 0x90, 0x7c, 0xdf, 0x0, 0xcb}; - - uint8_t buf[168] = {0}; - - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t topic_bytes[] = {0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x7d, 0x35, 0xee, 0xcc, 0x12, 0xfe, 0xa2, 0x6e, 0xc4, 0x2d, 0xac, 0x55, 0x5c, 0xa9, 0xa2, - 0x1c, 0x1e, 0x22, 0xbd, 0x76, 0x94, 0xe5, 0x5c, 0xdf, 0x90, 0x7c, 0xdf, 0x0, 0xcb}; + uint8_t msg_bytes[] = {0x9b, 0xd8, 0x2f, 0x45, 0x66}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; - - uint8_t bytesprops0[] = {0x66, 0x91, 0x8c, 0xcd}; - uint8_t bytesprops1[] = {0xb2, 0x3a, 0x34, 0x7e, 0x1b, 0x57, 0xc5, 0xb9, 0xdb, - 0x15, 0x38, 0xeb, 0x3, 0xf9, 0x7f, 0x34, 0x21, 0xaa}; - uint8_t bytesprops2[] = {0xd6, 0xda, 0x3e, 0xa6, 0xd3, 0x8c, 0xe1, 0xc6, 0xa2, - 0xfc, 0xe1, 0xc3, 0x8b, 0x1, 0xc8, 0x2c, 0xde}; - uint8_t bytesprops3[] = {0x1c, 0xc7, 0x6b, 0xc5, 0xe3, 0x15, 0xb7, 0x87, 0x5, 0x91, 0xb7, 0x2a, - 0xbe, 0xff, 0x7a, 0x67, 0x5e, 0xdc, 0x26, 0x6e, 0xd9, 0x72, 0x2e, 0x9f}; - uint8_t bytesprops4[] = {0x40, 0x3f, 0x6d, 0x31, 0x54, 0xf, 0xe4, 0xcf, 0x32, - 0xa0, 0x63, 0xc2, 0x30, 0x53, 0xc2, 0xbf, 0xdf, 0xde}; + msg.payload_len = 5; + + uint8_t bytesprops0[] = {0x72, 0x3e, 0xe, 0x58, 0x8c, 0x0, 0xe, 0x3, 0xb0, 0x85, 0x42, 0xc, 0x9c, 0xea, + 0x2, 0xca, 0x5f, 0x3a, 0x4, 0xa0, 0xce, 0x6e, 0xdb, 0xe5, 0x48, 0x97, 0xf, 0xb9}; + uint8_t bytesprops1[] = {0xe, 0xdc, 0xeb}; + uint8_t bytesprops2[] = {0x89, 0x29, 0x1b, 0x53, 0x67, 0xe2, 0x53, 0xcd, 0xeb, + 0x1e, 0xc2, 0x12, 0x65, 0xf6, 0x1b, 0x92, 0xe, 0xd8}; + uint8_t bytesprops3[] = {0x14, 0xb6, 0x16, 0x4a, 0x9c, 0x9f, 0xe0, 0x7b, 0x1e, 0x92, 0x51, + 0x97, 0xe5, 0xcf, 0xb9, 0x92, 0xf, 0x61, 0x45, 0x4f, 0x43, 0x61}; + uint8_t bytesprops4[] = {0x50, 0xe5, 0x66, 0x78, 0x14, 0x83, 0xb0, 0x57, 0x6b, 0x17, 0x58, 0x49, 0x3, 0x8e}; + uint8_t bytesprops5[] = {0x1b, 0x56, 0x35, 0x11, 0x5, 0x2d, 0xd7, 0xf6, 0xac, 0x46, 0x8c, + 0xf2, 0x5c, 0x56, 0xbc, 0xf, 0x21, 0xde, 0x2, 0x10, 0xf9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32116}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24310}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24774}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18751}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6732}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11501}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17948}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10159}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4218}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31284}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15238}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8262}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21478}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12711}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16810}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 31613, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "E_/\183|O\206\131\173f\212\204", +// _pubPktID = 31613, _pubBody = "\155\216/Ef", _pubProps = [PropServerReference +// "r>\SOX\140\NUL\SO\ETX\176\133B\f\156\234\STX\202_:\EOT\160\206n\219\229H\151\SI\185",PropMaximumQoS +// 173,PropReceiveMaximum 18751,PropRequestResponseInformation 60,PropMaximumPacketSize 6732,PropReceiveMaximum +// 11501,PropSessionExpiryInterval 17948,PropServerKeepAlive 10159,PropServerKeepAlive +// 4218,PropRequestProblemInformation 31,PropMessageExpiryInterval 31284,PropServerReference +// "\SO\220\235",PropReceiveMaximum 15238,PropMessageExpiryInterval 8262,PropContentType +// "\137)\ESCSg\226S\205\235\RS\194\DC2e\246\ESC\146\SO\216",PropRetainAvailable 89,PropMaximumPacketSize +// 21478,PropServerKeepAlive 12711,PropAuthenticationMethod +// "\DC4\182\SYNJ\156\159\224{\RS\146Q\151\229\207\185\146\SIaEOCa",PropServerReference +// "P\229fx\DC4\131\176Wk\ETBXI\ETX\142",PropAssignedClientIdentifier +// "\ESCV5\DC1\ENQ-\215\246\172F\140\242\\V\188\SI!\222\STX\DLE\249",PropRequestResponseInformation +// 120,PropWillDelayInterval 16810,PropSubscriptionIdentifier 16]} +TEST(Publish5QCTest, Decode10) { + uint8_t pkt[] = {0x32, 0xcf, 0x1, 0x0, 0xc, 0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc, + 0x7b, 0x7d, 0xb8, 0x1, 0x1c, 0x0, 0x1c, 0x72, 0x3e, 0xe, 0x58, 0x8c, 0x0, 0xe, 0x3, 0xb0, 0x85, + 0x42, 0xc, 0x9c, 0xea, 0x2, 0xca, 0x5f, 0x3a, 0x4, 0xa0, 0xce, 0x6e, 0xdb, 0xe5, 0x48, 0x97, 0xf, + 0xb9, 0x24, 0xad, 0x21, 0x49, 0x3f, 0x19, 0x3c, 0x27, 0x0, 0x0, 0x1a, 0x4c, 0x21, 0x2c, 0xed, 0x11, + 0x0, 0x0, 0x46, 0x1c, 0x13, 0x27, 0xaf, 0x13, 0x10, 0x7a, 0x17, 0x1f, 0x2, 0x0, 0x0, 0x7a, 0x34, + 0x1c, 0x0, 0x3, 0xe, 0xdc, 0xeb, 0x21, 0x3b, 0x86, 0x2, 0x0, 0x0, 0x20, 0x46, 0x3, 0x0, 0x12, + 0x89, 0x29, 0x1b, 0x53, 0x67, 0xe2, 0x53, 0xcd, 0xeb, 0x1e, 0xc2, 0x12, 0x65, 0xf6, 0x1b, 0x92, 0xe, + 0xd8, 0x25, 0x59, 0x27, 0x0, 0x0, 0x53, 0xe6, 0x13, 0x31, 0xa7, 0x15, 0x0, 0x16, 0x14, 0xb6, 0x16, + 0x4a, 0x9c, 0x9f, 0xe0, 0x7b, 0x1e, 0x92, 0x51, 0x97, 0xe5, 0xcf, 0xb9, 0x92, 0xf, 0x61, 0x45, 0x4f, + 0x43, 0x61, 0x1c, 0x0, 0xe, 0x50, 0xe5, 0x66, 0x78, 0x14, 0x83, 0xb0, 0x57, 0x6b, 0x17, 0x58, 0x49, + 0x3, 0x8e, 0x12, 0x0, 0x15, 0x1b, 0x56, 0x35, 0x11, 0x5, 0x2d, 0xd7, 0xf6, 0xac, 0x46, 0x8c, 0xf2, + 0x5c, 0x56, 0xbc, 0xf, 0x21, 0xde, 0x2, 0x10, 0xf9, 0x19, 0x78, 0x18, 0x0, 0x0, 0x41, 0xaa, 0xb, + 0x10, 0x9b, 0xd8, 0x2f, 0x45, 0x66}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9b, 0xd8, 0x2f, 0x45, 0x66}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 31613); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + lwmqtt_string_t x = exp_topic; + x = exp_body; } -// ConnectRequest {_username = Just ",\186\SUB\f\DC3\188\204KRj<%\n2x", _password = Just -// "\158A=\ETB\b\254\145\215X\242\128\192\ETB\DELE\ENQp\169\139;s~\SYN\135\CAN\209\EOT\226", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 22937, _connID = "\148<+X\194\247d\187\STXi\DLE\171\DC1\RS!:dW", _properties = -// []} +// ConnectRequest {_username = Just +// "\185\251\207\168Q\134\135\143\222\196\233\144\GS2\233\186\RS9\206\169\133%\142\159\215\144I", _password = Just +// "\226\211\189:\248cm\238\136\&0\f\162/\b\199!", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, +// _willTopic = ")V\230\ETB\138\201\162\143nR~n\217\SUBq\193\137\223\STX\EOT\218o-", _willMsg = +// "8\US\146\&6\140\255wr\180\153\226P\197c\191\139y\166q\243\140\235", _willProps = []}), _cleanSession = False, +// _keepAlive = 26495, _connID = "\178t?\235s\202\a;KB\143\142\223\245\b\219\194\166\232\CAN@", _properties = []} TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x59, 0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, 0xe2, 0xd3, 0xbd, + 0x3a, 0xf8, 0x63, 0x6d, 0xee, 0x88, 0x30, 0xc, 0xa2, 0x2f, 0x8, 0xc7, 0x21}; - uint8_t buf[89] = {0}; + uint8_t buf[142] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x29, 0x56, 0xe6, 0x17, 0x8a, 0xc9, 0xa2, 0x8f, 0x6e, 0x52, 0x7e, 0x6e, + 0xd9, 0x1a, 0x71, 0xc1, 0x89, 0xdf, 0x2, 0x4, 0xda, 0x6f, 0x2d}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x38, 0x1f, 0x92, 0x36, 0x8c, 0xff, 0x77, 0x72, 0xb4, 0x99, 0xe2, + 0x50, 0xc5, 0x63, 0xbf, 0x8b, 0x79, 0xa6, 0x71, 0xf3, 0x8c, 0xeb}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 22937; - uint8_t client_id_bytes[] = {0x94, 0x3c, 0x2b, 0x58, 0xc2, 0xf7, 0x64, 0xbb, 0x2, - 0x69, 0x10, 0xab, 0x11, 0x1e, 0x21, 0x3a, 0x64, 0x57}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.keep_alive = 26495; + uint8_t client_id_bytes[] = {0xb2, 0x74, 0x3f, 0xeb, 0x73, 0xca, 0x7, 0x3b, 0x4b, 0x42, 0x8f, + 0x8e, 0xdf, 0xf5, 0x8, 0xdb, 0xc2, 0xa6, 0xe8, 0x18, 0x40}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2c, 0xba, 0x1a, 0xc, 0x13, 0xbc, 0xcc, 0x4b, 0x52, 0x6a, 0x3c, 0x25, 0xa, 0x32, 0x78}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb9, 0xfb, 0xcf, 0xa8, 0x51, 0x86, 0x87, 0x8f, 0xde, 0xc4, 0xe9, 0x90, 0x1d, 0x32, + 0xe9, 0xba, 0x1e, 0x39, 0xce, 0xa9, 0x85, 0x25, 0x8e, 0x9f, 0xd7, 0x90, 0x49}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x9e, 0x41, 0x3d, 0x17, 0x8, 0xfe, 0x91, 0xd7, 0x58, 0xf2, 0x80, 0xc0, 0x17, 0x7f, - 0x45, 0x5, 0x70, 0xa9, 0x8b, 0x3b, 0x73, 0x7e, 0x16, 0x87, 0x18, 0xd1, 0x4, 0xe2}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe2, 0xd3, 0xbd, 0x3a, 0xf8, 0x63, 0x6d, 0xee, + 0x88, 0x30, 0xc, 0xa2, 0x2f, 0x8, 0xc7, 0x21}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\164\SYNT\228'W\255\244\187\193\237\180\r\238d\151m\191\n\183", _password = -// Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "2\RS", _willMsg = -// "C\US\226G\191\RS\225\238\241\187U\183Nx\ESC\165\135\147\181\SO|\ESC\236\155\198\&6\255\195", _willProps = []}), -// _cleanSession = True, _keepAlive = 23276, _connID = "\131={\SYN\158\175']\FS\233\139mf\131#\146\252M3", _properties = -// []} +// ConnectRequest {_username = Just "S\EMr\236\180m\171\241#\147\247\CAN6\217\212}\226\139 +// H\249\252\SI\164\190G\DLE\253\139P", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\DC1\204\194j\212B2e>?\248=l\142X\199U\rs\EMI\a\190", _willMsg = ";\212\214\144\179\bu\237", +// _willProps = []}), _cleanSession = True, _keepAlive = 30140, _connID = +// "N\199j\187\238\237\193\\-\250\182V\DC3\193R\DEL\DC1>o\168\185\199\195i\201BW\253\189\&8", _properties = []} TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x57, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa6, 0x5a, 0xec, 0x0, 0x13, 0x83, - 0x3d, 0x7b, 0x16, 0x9e, 0xaf, 0x27, 0x5d, 0x1c, 0xe9, 0x8b, 0x6d, 0x66, 0x83, 0x23, 0x92, - 0xfc, 0x4d, 0x33, 0x0, 0x2, 0x32, 0x1e, 0x0, 0x1c, 0x43, 0x1f, 0xe2, 0x47, 0xbf, 0x1e, - 0xe1, 0xee, 0xf1, 0xbb, 0x55, 0xb7, 0x4e, 0x78, 0x1b, 0xa5, 0x87, 0x93, 0xb5, 0xe, 0x7c, - 0x1b, 0xec, 0x9b, 0xc6, 0x36, 0xff, 0xc3, 0x0, 0x14, 0xa4, 0x16, 0x54, 0xe4, 0x27, 0x57, - 0xff, 0xf4, 0xbb, 0xc1, 0xed, 0xb4, 0xd, 0xee, 0x64, 0x97, 0x6d, 0xbf, 0xa, 0xb7}; + uint8_t pkt[] = {0x10, 0x6d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x96, 0x75, 0xbc, 0x0, 0x1e, 0x4e, 0xc7, + 0x6a, 0xbb, 0xee, 0xed, 0xc1, 0x5c, 0x2d, 0xfa, 0xb6, 0x56, 0x13, 0xc1, 0x52, 0x7f, 0x11, 0x3e, + 0x6f, 0xa8, 0xb9, 0xc7, 0xc3, 0x69, 0xc9, 0x42, 0x57, 0xfd, 0xbd, 0x38, 0x0, 0x17, 0x11, 0xcc, + 0xc2, 0x6a, 0xd4, 0x42, 0x32, 0x65, 0x3e, 0x3f, 0xf8, 0x3d, 0x6c, 0x8e, 0x58, 0xc7, 0x55, 0xd, + 0x73, 0x19, 0x49, 0x7, 0xbe, 0x0, 0x8, 0x3b, 0xd4, 0xd6, 0x90, 0xb3, 0x8, 0x75, 0xed, 0x0, + 0x1e, 0x53, 0x19, 0x72, 0xec, 0xb4, 0x6d, 0xab, 0xf1, 0x23, 0x93, 0xf7, 0x18, 0x36, 0xd9, 0xd4, + 0x7d, 0xe2, 0x8b, 0x20, 0x48, 0xf9, 0xfc, 0xf, 0xa4, 0xbe, 0x47, 0x10, 0xfd, 0x8b, 0x50}; - uint8_t buf[99] = {0}; + uint8_t buf[121] = {0}; lwmqtt_property_t propslist[] = {}; @@ -1000,27 +1871,28 @@ TEST(Connect311QCTest, Encode2) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x32, 0x1e}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x43, 0x1f, 0xe2, 0x47, 0xbf, 0x1e, 0xe1, 0xee, 0xf1, 0xbb, 0x55, 0xb7, 0x4e, 0x78, - 0x1b, 0xa5, 0x87, 0x93, 0xb5, 0xe, 0x7c, 0x1b, 0xec, 0x9b, 0xc6, 0x36, 0xff, 0xc3}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x11, 0xcc, 0xc2, 0x6a, 0xd4, 0x42, 0x32, 0x65, 0x3e, 0x3f, 0xf8, 0x3d, + 0x6c, 0x8e, 0x58, 0xc7, 0x55, 0xd, 0x73, 0x19, 0x49, 0x7, 0xbe}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3b, 0xd4, 0xd6, 0x90, 0xb3, 0x8, 0x75, 0xed}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 23276; - uint8_t client_id_bytes[] = {0x83, 0x3d, 0x7b, 0x16, 0x9e, 0xaf, 0x27, 0x5d, 0x1c, 0xe9, - 0x8b, 0x6d, 0x66, 0x83, 0x23, 0x92, 0xfc, 0x4d, 0x33}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.keep_alive = 30140; + uint8_t client_id_bytes[] = {0x4e, 0xc7, 0x6a, 0xbb, 0xee, 0xed, 0xc1, 0x5c, 0x2d, 0xfa, + 0xb6, 0x56, 0x13, 0xc1, 0x52, 0x7f, 0x11, 0x3e, 0x6f, 0xa8, + 0xb9, 0xc7, 0xc3, 0x69, 0xc9, 0x42, 0x57, 0xfd, 0xbd, 0x38}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa4, 0x16, 0x54, 0xe4, 0x27, 0x57, 0xff, 0xf4, 0xbb, 0xc1, - 0xed, 0xb4, 0xd, 0xee, 0x64, 0x97, 0x6d, 0xbf, 0xa, 0xb7}; - lwmqtt_string_t username = {20, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x53, 0x19, 0x72, 0xec, 0xb4, 0x6d, 0xab, 0xf1, 0x23, 0x93, 0xf7, 0x18, 0x36, 0xd9, 0xd4, + 0x7d, 0xe2, 0x8b, 0x20, 0x48, 0xf9, 0xfc, 0xf, 0xa4, 0xbe, 0x47, 0x10, 0xfd, 0x8b, 0x50}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -1029,20 +1901,22 @@ TEST(Connect311QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\237TI=\140\157[R\161\178\154\138\249", _password = Just "\156\221\243", _lastWill -// = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "q\252\157\161\146\222\a\NAK2\173\167\152X\152\NAK", _willMsg = -// "\172\197\EM>", _willProps = []}), _cleanSession = False, _keepAlive = 21561, +// _connID = "X\167X\244/`\v\181e#h\159\179\219;Q\173\v\134\181+\149\190xs", _properties = []} TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x92, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x23, 0x8e, 0x0, 0x1e, 0xea, 0x42, - 0x4, 0xf7, 0xf7, 0x57, 0xc2, 0xde, 0xa, 0x50, 0x83, 0x29, 0x26, 0x3f, 0xe2, 0x30, 0x58, 0xd1, 0x70, - 0x1b, 0xb1, 0x7a, 0xc9, 0xe, 0x74, 0x83, 0x67, 0x28, 0xd7, 0x57, 0x0, 0x1d, 0xde, 0x76, 0xc3, 0xfc, - 0xf3, 0x9f, 0x70, 0x81, 0x2, 0xda, 0x72, 0x2, 0x1b, 0x6d, 0xf2, 0xc9, 0xc1, 0x36, 0x58, 0xbf, 0x68, - 0xce, 0xe9, 0xd2, 0x78, 0x86, 0x64, 0xaa, 0xc, 0x0, 0x1e, 0x12, 0x42, 0x6d, 0x98, 0x10, 0x8c, 0xe, - 0xec, 0x2a, 0x96, 0x86, 0x86, 0x6d, 0xc3, 0x49, 0x8c, 0x9, 0x4d, 0x70, 0x47, 0xb, 0xc7, 0x8a, 0x27, - 0xe6, 0xf2, 0xe3, 0xf7, 0x6d, 0xca, 0x0, 0x1d, 0xf2, 0xdc, 0x1a, 0xcc, 0xb, 0x2d, 0x88, 0xd3, 0x2f, - 0xda, 0x12, 0xf3, 0x9e, 0x5d, 0xbe, 0xa5, 0xfb, 0x96, 0x48, 0xee, 0xc8, 0x12, 0x98, 0xf5, 0x55, 0xca, - 0x0, 0x66, 0x99, 0x0, 0x8, 0xa1, 0xb, 0x40, 0x9, 0x9b, 0xe9, 0x57, 0x42}; - - uint8_t buf[159] = {0}; + uint8_t pkt[] = {0x10, 0x79, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x54, 0x39, 0x0, 0x19, 0x58, 0xa7, + 0x58, 0xf4, 0x2f, 0x60, 0xb, 0xb5, 0x65, 0x23, 0x68, 0x9f, 0xb3, 0xdb, 0x3b, 0x51, 0xad, 0xb, + 0x86, 0xb5, 0x2b, 0x95, 0xbe, 0x78, 0x73, 0x0, 0x14, 0x4f, 0x31, 0x16, 0xda, 0x97, 0x26, 0xe5, + 0x9b, 0x6a, 0xed, 0x10, 0x46, 0x8f, 0xd8, 0xe8, 0x61, 0xbd, 0xc3, 0xe2, 0x8e, 0x0, 0x11, 0xb2, + 0xa5, 0xaa, 0xb5, 0x28, 0x2d, 0xf8, 0xcc, 0x10, 0xe6, 0x6a, 0x4b, 0x59, 0x4, 0x3e, 0x19, 0x3e, + 0x0, 0xf, 0x7d, 0xc3, 0x56, 0x49, 0x1a, 0x50, 0xa6, 0xcf, 0x8d, 0x3c, 0x8c, 0xcb, 0xa4, 0xe0, + 0x5a, 0x0, 0x18, 0xef, 0x1f, 0x1d, 0x73, 0x28, 0x8b, 0x6c, 0x71, 0x98, 0x27, 0xce, 0xee, 0x13, + 0x28, 0x66, 0xac, 0x50, 0x1d, 0x98, 0x82, 0xeb, 0x4b, 0x0, 0xea}; + + uint8_t buf[133] = {0}; lwmqtt_property_t propslist[] = {}; @@ -1359,14 +2215,12 @@ TEST(Connect311QCTest, Encode9) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xde, 0x76, 0xc3, 0xfc, 0xf3, 0x9f, 0x70, 0x81, 0x2, 0xda, - 0x72, 0x2, 0x1b, 0x6d, 0xf2, 0xc9, 0xc1, 0x36, 0x58, 0xbf, - 0x68, 0xce, 0xe9, 0xd2, 0x78, 0x86, 0x64, 0xaa, 0xc}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x12, 0x42, 0x6d, 0x98, 0x10, 0x8c, 0xe, 0xec, 0x2a, 0x96, - 0x86, 0x86, 0x6d, 0xc3, 0x49, 0x8c, 0x9, 0x4d, 0x70, 0x47, - 0xb, 0xc7, 0x8a, 0x27, 0xe6, 0xf2, 0xe3, 0xf7, 0x6d, 0xca}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x4f, 0x31, 0x16, 0xda, 0x97, 0x26, 0xe5, 0x9b, 0x6a, 0xed, + 0x10, 0x46, 0x8f, 0xd8, 0xe8, 0x61, 0xbd, 0xc3, 0xe2, 0x8e}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb2, 0xa5, 0xaa, 0xb5, 0x28, 0x2d, 0xf8, 0xcc, 0x10, + 0xe6, 0x6a, 0x4b, 0x59, 0x4, 0x3e, 0x19, 0x3e}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -1374,18 +2228,18 @@ TEST(Connect311QCTest, Encode9) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 9102; - uint8_t client_id_bytes[] = {0xea, 0x42, 0x4, 0xf7, 0xf7, 0x57, 0xc2, 0xde, 0xa, 0x50, 0x83, 0x29, 0x26, 0x3f, 0xe2, - 0x30, 0x58, 0xd1, 0x70, 0x1b, 0xb1, 0x7a, 0xc9, 0xe, 0x74, 0x83, 0x67, 0x28, 0xd7, 0x57}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 21561; + uint8_t client_id_bytes[] = {0x58, 0xa7, 0x58, 0xf4, 0x2f, 0x60, 0xb, 0xb5, 0x65, 0x23, 0x68, 0x9f, 0xb3, + 0xdb, 0x3b, 0x51, 0xad, 0xb, 0x86, 0xb5, 0x2b, 0x95, 0xbe, 0x78, 0x73}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf2, 0xdc, 0x1a, 0xcc, 0xb, 0x2d, 0x88, 0xd3, 0x2f, 0xda, 0x12, 0xf3, 0x9e, 0x5d, 0xbe, - 0xa5, 0xfb, 0x96, 0x48, 0xee, 0xc8, 0x12, 0x98, 0xf5, 0x55, 0xca, 0x0, 0x66, 0x99}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x7d, 0xc3, 0x56, 0x49, 0x1a, 0x50, 0xa6, 0xcf, 0x8d, 0x3c, 0x8c, 0xcb, 0xa4, 0xe0, 0x5a}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xa1, 0xb, 0x40, 0x9, 0x9b, 0xe9, 0x57, 0x42}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xef, 0x1f, 0x1d, 0x73, 0x28, 0x8b, 0x6c, 0x71, 0x98, 0x27, 0xce, 0xee, + 0x13, 0x28, 0x66, 0xac, 0x50, 0x1d, 0x98, 0x82, 0xeb, 0x4b, 0x0, 0xea}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -1394,18 +2248,21 @@ TEST(Connect311QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\174\237\224:\154\243X\224`\199", _password = Just -// "%\185W1f}\195\140\153\169\181\238\243\236\EM,V\216\ESC\151\168", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "\162\219\EM\161\228\128\255m", _willMsg = "", _willProps = []}), _cleanSession = True, -// _keepAlive = 17212, _connID = "\203o\140\199r\n\144n\FS\211\223\147\152?\GS\152/\v\245r\"\250", _properties = []} +// ConnectRequest {_username = Just "\239zk\159\ETX\223!\141\ETX\233\248\f1=\DC4i", _password = Just +// "\191\141\246E\193\236\243\223\153\216myo\194\214\244\200\140\198\147\236Q\194X\130\136", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS0, _willTopic = "L&sv\176Yc2O\\\201,", _willMsg = +// "/\a}\172t\US\218\131\240\224S\221\205S\227\223\231\246~_\168}|8\172\219\157\168", _willProps = []}), _cleanSession = +// False, _keepAlive = 478, _connID = "+\251Q\185q\193\199\n\237\186\162\a", _properties = []} TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x51, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x43, 0x3c, 0x0, 0x16, 0xcb, 0x6f, 0x8c, - 0xc7, 0x72, 0xa, 0x90, 0x6e, 0x1c, 0xd3, 0xdf, 0x93, 0x98, 0x3f, 0x1d, 0x98, 0x2f, 0xb, 0xf5, 0x72, - 0x22, 0xfa, 0x0, 0x8, 0xa2, 0xdb, 0x19, 0xa1, 0xe4, 0x80, 0xff, 0x6d, 0x0, 0x0, 0x0, 0xa, 0xae, - 0xed, 0xe0, 0x3a, 0x9a, 0xf3, 0x58, 0xe0, 0x60, 0xc7, 0x0, 0x15, 0x25, 0xb9, 0x57, 0x31, 0x66, 0x7d, - 0xc3, 0x8c, 0x99, 0xa9, 0xb5, 0xee, 0xf3, 0xec, 0x19, 0x2c, 0x56, 0xd8, 0x1b, 0x97, 0xa8}; + uint8_t pkt[] = {0x10, 0x72, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x1, 0xde, 0x0, 0xc, 0x2b, 0xfb, 0x51, + 0xb9, 0x71, 0xc1, 0xc7, 0xa, 0xed, 0xba, 0xa2, 0x7, 0x0, 0xc, 0x4c, 0x26, 0x73, 0x76, 0xb0, 0x59, + 0x63, 0x32, 0x4f, 0x5c, 0xc9, 0x2c, 0x0, 0x1c, 0x2f, 0x7, 0x7d, 0xac, 0x74, 0x1f, 0xda, 0x83, 0xf0, + 0xe0, 0x53, 0xdd, 0xcd, 0x53, 0xe3, 0xdf, 0xe7, 0xf6, 0x7e, 0x5f, 0xa8, 0x7d, 0x7c, 0x38, 0xac, 0xdb, + 0x9d, 0xa8, 0x0, 0x10, 0xef, 0x7a, 0x6b, 0x9f, 0x3, 0xdf, 0x21, 0x8d, 0x3, 0xe9, 0xf8, 0xc, 0x31, + 0x3d, 0x14, 0x69, 0x0, 0x1a, 0xbf, 0x8d, 0xf6, 0x45, 0xc1, 0xec, 0xf3, 0xdf, 0x99, 0xd8, 0x6d, 0x79, + 0x6f, 0xc2, 0xd6, 0xf4, 0xc8, 0x8c, 0xc6, 0x93, 0xec, 0x51, 0xc2, 0x58, 0x82, 0x88}; - uint8_t buf[93] = {0}; + uint8_t buf[126] = {0}; lwmqtt_property_t propslist[] = {}; @@ -1415,29 +2272,30 @@ TEST(Connect311QCTest, Encode10) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa2, 0xdb, 0x19, 0xa1, 0xe4, 0x80, 0xff, 0x6d}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x4c, 0x26, 0x73, 0x76, 0xb0, 0x59, 0x63, 0x32, 0x4f, 0x5c, 0xc9, 0x2c}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2f, 0x7, 0x7d, 0xac, 0x74, 0x1f, 0xda, 0x83, 0xf0, 0xe0, 0x53, 0xdd, 0xcd, 0x53, + 0xe3, 0xdf, 0xe7, 0xf6, 0x7e, 0x5f, 0xa8, 0x7d, 0x7c, 0x38, 0xac, 0xdb, 0x9d, 0xa8}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 17212; - uint8_t client_id_bytes[] = {0xcb, 0x6f, 0x8c, 0xc7, 0x72, 0xa, 0x90, 0x6e, 0x1c, 0xd3, 0xdf, - 0x93, 0x98, 0x3f, 0x1d, 0x98, 0x2f, 0xb, 0xf5, 0x72, 0x22, 0xfa}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 478; + uint8_t client_id_bytes[] = {0x2b, 0xfb, 0x51, 0xb9, 0x71, 0xc1, 0xc7, 0xa, 0xed, 0xba, 0xa2, 0x7}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xae, 0xed, 0xe0, 0x3a, 0x9a, 0xf3, 0x58, 0xe0, 0x60, 0xc7}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xef, 0x7a, 0x6b, 0x9f, 0x3, 0xdf, 0x21, 0x8d, + 0x3, 0xe9, 0xf8, 0xc, 0x31, 0x3d, 0x14, 0x69}; + lwmqtt_string_t username = {16, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x25, 0xb9, 0x57, 0x31, 0x66, 0x7d, 0xc3, 0x8c, 0x99, 0xa9, 0xb5, - 0xee, 0xf3, 0xec, 0x19, 0x2c, 0x56, 0xd8, 0x1b, 0x97, 0xa8}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xbf, 0x8d, 0xf6, 0x45, 0xc1, 0xec, 0xf3, 0xdf, 0x99, 0xd8, 0x6d, 0x79, 0x6f, + 0xc2, 0xd6, 0xf4, 0xc8, 0x8c, 0xc6, 0x93, 0xec, 0x51, 0xc2, 0x58, 0x82, 0x88}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -1446,197 +2304,231 @@ TEST(Connect311QCTest, Encode10) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just ",\186\SUB\f\DC3\188\204KRj<%\n2x", _password = Just -// "\158A=\ETB\b\254\145\215X\242\128\192\ETB\DELE\ENQp\169\139;s~\SYN\135\CAN\209\EOT\226", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 22937, _connID = "\148<+X\194\247d\187\STXi\DLE\171\DC1\RS!:dW", _properties = -// [PropCorrelationData -// "\144\SO\142\195{!!z\131\203i\FS\DC3&\149\141\168;\221\161?A\ar\137\248\&5\168\184",PropContentType -// "\SOH\164",PropWildcardSubscriptionAvailable 190,PropSubscriptionIdentifier 12,PropSubscriptionIdentifier -// 8,PropPayloadFormatIndicator 27,PropCorrelationData -// "\205\&3\250%\190\141\145\175\244\RS\180\166\&8\136",PropSharedSubscriptionAvailable 213,PropMaximumPacketSize -// 1915,PropPayloadFormatIndicator 113,PropMaximumPacketSize 21593,PropReasonString -// "\250\249uz\138\249\194\b\228\DC2\255\ETX\255\197\147\151Q<\253\233",PropServerKeepAlive -// 7204,PropRequestResponseInformation 136,PropSubscriptionIdentifierAvailable 128,PropMessageExpiryInterval -// 9096,PropReceiveMaximum 15561,PropMessageExpiryInterval 7455,PropSubscriptionIdentifierAvailable 135,PropUserProperty -// "\176\189N\131h\172\225Z\211\180p\167*\229\193\SYN\f\191\190K\211\241Ca\193" -// "]yn\185\183\189R\213\162\202,\EOT\237ni[;Y\SUB",PropRequestProblemInformation 194,PropMaximumQoS -// 99,PropSessionExpiryInterval 11028]} +// ConnectRequest {_username = Just +// "\185\251\207\168Q\134\135\143\222\196\233\144\GS2\233\186\RS9\206\169\133%\142\159\215\144I", _password = Just +// "\226\211\189:\248cm\238\136\&0\f\162/\b\199!", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, +// _willTopic = ")V\230\ETB\138\201\162\143nR~n\217\SUBq\193\137\223\STX\EOT\218o-", _willMsg = +// "8\US\146\&6\140\255wr\180\153\226P\197c\191\139y\166q\243\140\235", _willProps = [PropUserProperty "" +// "&O\EM,\149YV.w!",PropSubscriptionIdentifier 27,PropWillDelayInterval 2671,PropRetainAvailable +// 214,PropMessageExpiryInterval 2278,PropReasonString "lH6Qh\185\&3r\171\254\138Dp\157",PropTopicAlias +// 26598,PropSharedSubscriptionAvailable 185,PropAuthenticationData +// "\134DTa4\227\151\180\255\135\144c\226\232\142",PropReasonString "S\143",PropMaximumQoS 217,PropServerReference +// "\186\DC2Iv",PropResponseInformation +// "\182Zc\177\146\181\190\131\236\250\182\252\v\167=dy\199\210\235\133:\165\SYN\167\220",PropMessageExpiryInterval +// 5186,PropPayloadFormatIndicator 87,PropSharedSubscriptionAvailable 234,PropMessageExpiryInterval +// 7625,PropAssignedClientIdentifier "\161\203T\253"]}), _cleanSession = False, _keepAlive = 26495, _connID = +// "\178t?\235s\202\a;KB\143\142\223\245\b\219\194\166\232\CAN@", _properties = [PropReasonString +// "\232\FS\252\134H\249\185 \189\228^\CANl\146\153\US3\188g\255",PropReasonString +// "r\248\DC27",PropAssignedClientIdentifier +// "\176\187D0\149\ETB\SO\173\155\227VD\215}\157\SYNU\175\DEL\225>\254",PropMessageExpiryInterval +// 15875,PropRequestProblemInformation 32,PropServerKeepAlive 14420,PropSubscriptionIdentifier 14,PropServerKeepAlive +// 12053,PropRetainAvailable 196]} TEST(Connect5QCTest, Encode1) { uint8_t pkt[] = { - 0x10, 0x82, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x59, 0x99, 0xb3, 0x1, 0x9, 0x0, 0x1d, 0x90, - 0xe, 0x8e, 0xc3, 0x7b, 0x21, 0x21, 0x7a, 0x83, 0xcb, 0x69, 0x1c, 0x13, 0x26, 0x95, 0x8d, 0xa8, 0x3b, 0xdd, 0xa1, - 0x3f, 0x41, 0x7, 0x72, 0x89, 0xf8, 0x35, 0xa8, 0xb8, 0x3, 0x0, 0x2, 0x1, 0xa4, 0x28, 0xbe, 0xb, 0xc, 0xb, - 0x8, 0x1, 0x1b, 0x9, 0x0, 0xe, 0xcd, 0x33, 0xfa, 0x25, 0xbe, 0x8d, 0x91, 0xaf, 0xf4, 0x1e, 0xb4, 0xa6, 0x38, - 0x88, 0x2a, 0xd5, 0x27, 0x0, 0x0, 0x7, 0x7b, 0x1, 0x71, 0x27, 0x0, 0x0, 0x54, 0x59, 0x1f, 0x0, 0x14, 0xfa, - 0xf9, 0x75, 0x7a, 0x8a, 0xf9, 0xc2, 0x8, 0xe4, 0x12, 0xff, 0x3, 0xff, 0xc5, 0x93, 0x97, 0x51, 0x3c, 0xfd, 0xe9, - 0x13, 0x1c, 0x24, 0x19, 0x88, 0x29, 0x80, 0x2, 0x0, 0x0, 0x23, 0x88, 0x21, 0x3c, 0xc9, 0x2, 0x0, 0x0, 0x1d, - 0x1f, 0x29, 0x87, 0x26, 0x0, 0x19, 0xb0, 0xbd, 0x4e, 0x83, 0x68, 0xac, 0xe1, 0x5a, 0xd3, 0xb4, 0x70, 0xa7, 0x2a, - 0xe5, 0xc1, 0x16, 0xc, 0xbf, 0xbe, 0x4b, 0xd3, 0xf1,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36, 0x8c, 0xff, 0x77, 0x72, 0xb4, 0x99, 0xe2, 0x50, 0xc5, 0x63, + 0xbf, 0x8b, 0x79, 0xa6, 0x71, 0xf3, 0x8c, 0xeb, 0x0, 0x1b, 0xb9, 0xfb, 0xcf, 0xa8, 0x51, 0x86, 0x87, 0x8f, 0xde, + 0xc4, 0xe9, 0x90, 0x1d, 0x32, 0xe9, 0xba, 0x1e, 0x39, 0xce, 0xa9, 0x85, 0x25, 0x8e, 0x9f, 0xd7, 0x90, 0x49, 0x0, + 0x10, 0xe2, 0xd3, 0xbd, 0x3a, 0xf8, 0x63, 0x6d, 0xee, 0x88, 0x30, 0xc, 0xa2, 0x2f, 0x8, 0xc7, 0x21}; + + uint8_t buf[350] = {0}; + + uint8_t bytesprops0[] = {0xe8, 0x1c, 0xfc, 0x86, 0x48, 0xf9, 0xb9, 0x20, 0xbd, 0xe4, + 0x5e, 0x18, 0x6c, 0x92, 0x99, 0x1f, 0x33, 0xbc, 0x67, 0xff}; + uint8_t bytesprops1[] = {0x72, 0xf8, 0x12, 0x37}; + uint8_t bytesprops2[] = {0xb0, 0xbb, 0x44, 0x30, 0x95, 0x17, 0xe, 0xad, 0x9b, 0xe3, 0x56, + 0x44, 0xd7, 0x7d, 0x9d, 0x16, 0x55, 0xaf, 0x7f, 0xe1, 0x3e, 0xfe}; - uint8_t buf[271] = {0}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15875}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14420}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12053}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 196}}, + }; - uint8_t bytesprops0[] = {0x90, 0xe, 0x8e, 0xc3, 0x7b, 0x21, 0x21, 0x7a, 0x83, 0xcb, 0x69, 0x1c, 0x13, 0x26, 0x95, - 0x8d, 0xa8, 0x3b, 0xdd, 0xa1, 0x3f, 0x41, 0x7, 0x72, 0x89, 0xf8, 0x35, 0xa8, 0xb8}; - uint8_t bytesprops1[] = {0x1, 0xa4}; - uint8_t bytesprops2[] = {0xcd, 0x33, 0xfa, 0x25, 0xbe, 0x8d, 0x91, 0xaf, 0xf4, 0x1e, 0xb4, 0xa6, 0x38, 0x88}; - uint8_t bytesprops3[] = {0xfa, 0xf9, 0x75, 0x7a, 0x8a, 0xf9, 0xc2, 0x8, 0xe4, 0x12, - 0xff, 0x3, 0xff, 0xc5, 0x93, 0x97, 0x51, 0x3c, 0xfd, 0xe9}; - uint8_t bytesprops5[] = {0x5d, 0x79, 0x6e, 0xb9, 0xb7, 0xbd, 0x52, 0xd5, 0xa2, 0xca, - 0x2c, 0x4, 0xed, 0x6e, 0x69, 0x5b, 0x3b, 0x59, 0x1a}; - uint8_t bytesprops4[] = {0xb0, 0xbd, 0x4e, 0x83, 0x68, 0xac, 0xe1, 0x5a, 0xd3, 0xb4, 0x70, 0xa7, 0x2a, - 0xe5, 0xc1, 0x16, 0xc, 0xbf, 0xbe, 0x4b, 0xd3, 0xf1, 0x43, 0x61, 0xc1}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x26, 0x4f, 0x19, 0x2c, 0x95, 0x59, 0x56, 0x2e, 0x77, 0x21}; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops2[] = {0x6c, 0x48, 0x36, 0x51, 0x68, 0xb9, 0x33, 0x72, 0xab, 0xfe, 0x8a, 0x44, 0x70, 0x9d}; + uint8_t byteswillprops3[] = {0x86, 0x44, 0x54, 0x61, 0x34, 0xe3, 0x97, 0xb4, + 0xff, 0x87, 0x90, 0x63, 0xe2, 0xe8, 0x8e}; + uint8_t byteswillprops4[] = {0x53, 0x8f}; + uint8_t byteswillprops5[] = {0xba, 0x12, 0x49, 0x76}; + uint8_t byteswillprops6[] = {0xb6, 0x5a, 0x63, 0xb1, 0x92, 0xb5, 0xbe, 0x83, 0xec, 0xfa, 0xb6, 0xfc, 0xb, + 0xa7, 0x3d, 0x64, 0x79, 0xc7, 0xd2, 0xeb, 0x85, 0x3a, 0xa5, 0x16, 0xa7, 0xdc}; + uint8_t byteswillprops7[] = {0xa1, 0xcb, 0x54, 0xfd}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1915}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21593}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7204}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9096}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15561}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7455}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops4}, .v = {19, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11028}}, + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {0, (char*)&byteswillprops0}, .v = {10, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2671}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2278}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26598}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5186}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7625}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops7}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x29, 0x56, 0xe6, 0x17, 0x8a, 0xc9, 0xa2, 0x8f, 0x6e, 0x52, 0x7e, 0x6e, + 0xd9, 0x1a, 0x71, 0xc1, 0x89, 0xdf, 0x2, 0x4, 0xda, 0x6f, 0x2d}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x38, 0x1f, 0x92, 0x36, 0x8c, 0xff, 0x77, 0x72, 0xb4, 0x99, 0xe2, + 0x50, 0xc5, 0x63, 0xbf, 0x8b, 0x79, 0xa6, 0x71, 0xf3, 0x8c, 0xeb}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 22937; - uint8_t client_id_bytes[] = {0x94, 0x3c, 0x2b, 0x58, 0xc2, 0xf7, 0x64, 0xbb, 0x2, - 0x69, 0x10, 0xab, 0x11, 0x1e, 0x21, 0x3a, 0x64, 0x57}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.keep_alive = 26495; + uint8_t client_id_bytes[] = {0xb2, 0x74, 0x3f, 0xeb, 0x73, 0xca, 0x7, 0x3b, 0x4b, 0x42, 0x8f, + 0x8e, 0xdf, 0xf5, 0x8, 0xdb, 0xc2, 0xa6, 0xe8, 0x18, 0x40}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2c, 0xba, 0x1a, 0xc, 0x13, 0xbc, 0xcc, 0x4b, 0x52, 0x6a, 0x3c, 0x25, 0xa, 0x32, 0x78}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb9, 0xfb, 0xcf, 0xa8, 0x51, 0x86, 0x87, 0x8f, 0xde, 0xc4, 0xe9, 0x90, 0x1d, 0x32, + 0xe9, 0xba, 0x1e, 0x39, 0xce, 0xa9, 0x85, 0x25, 0x8e, 0x9f, 0xd7, 0x90, 0x49}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x9e, 0x41, 0x3d, 0x17, 0x8, 0xfe, 0x91, 0xd7, 0x58, 0xf2, 0x80, 0xc0, 0x17, 0x7f, - 0x45, 0x5, 0x70, 0xa9, 0x8b, 0x3b, 0x73, 0x7e, 0x16, 0x87, 0x18, 0xd1, 0x4, 0xe2}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe2, 0xd3, 0xbd, 0x3a, 0xf8, 0x63, 0x6d, 0xee, + 0x88, 0x30, 0xc, 0xa2, 0x2f, 0x8, 0xc7, 0x21}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\164\SYNT\228'W\255\244\187\193\237\180\r\238d\151m\191\n\183", _password = -// Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "2\RS", _willMsg = -// "C\US\226G\191\RS\225\238\241\187U\183Nx\ESC\165\135\147\181\SO|\ESC\236\155\198\&6\255\195", _willProps = []}), -// _cleanSession = True, _keepAlive = 23276, _connID = "\131={\SYN\158\175']\FS\233\139mf\131#\146\252M3", _properties = -// [PropServerKeepAlive 26284,PropSharedSubscriptionAvailable 216,PropMessageExpiryInterval 27230,PropTopicAlias -// 10402,PropServerKeepAlive 13080,PropRequestProblemInformation 123,PropSessionExpiryInterval 3460,PropServerKeepAlive -// 15256,PropRequestProblemInformation 228,PropReasonString "=\142\SUB\252 -// \167\SYN\214\250t\224/\233\253bf\161\242\186(\213\ETB~\NULHY\245\203\158",PropCorrelationData -// "\252\188c#G\138\210\231\&8\154_\233R",PropPayloadFormatIndicator 247,PropSubscriptionIdentifier -// 30,PropPayloadFormatIndicator 39,PropContentType "\226\128\\\\J,\158",PropTopicAliasMaximum -// 21236,PropPayloadFormatIndicator 66,PropRetainAvailable 105,PropCorrelationData -// "\158\DC2A{W\204%\154\154U\170o\ENQ\247i\166|_]\214\231",PropMessageExpiryInterval 30139,PropAssignedClientIdentifier -// "\237\SOH)\185\193\166",PropWillDelayInterval 23656,PropRequestResponseInformation 57,PropTopicAlias -// 1904,PropMaximumQoS 29,PropSubscriptionIdentifierAvailable 242,PropSubscriptionIdentifier 27]} +// ConnectRequest {_username = Just "S\EMr\236\180m\171\241#\147\247\CAN6\217\212}\226\139 +// H\249\252\SI\164\190G\DLE\253\139P", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\DC1\204\194j\212B2e>?\248=l\142X\199U\rs\EMI\a\190", _willMsg = ";\212\214\144\179\bu\237", +// _willProps = [PropResponseTopic "A\238\131\188"]}), _cleanSession = True, _keepAlive = 30140, _connID = +// "N\199j\187\238\237\193\\-\250\182V\DC3\193R\DEL\DC1>o\168\185\199\195i\201BW\253\189\&8", _properties = +// [PropRetainAvailable 118,PropUserProperty "\222\137\224" "\FS,Z\167W",PropTopicAlias 26986,PropAuthenticationData +// "\142\192\248\243\147\141K\145\174\164\220\151.;0\217\232#\167\128\130\188\ACK",PropRequestProblemInformation +// 144,PropUserProperty "\209K\133\216\224\164I\SI\248\DC3\226\ESCo&\191\SUBJ\177" +// "\DC4\249?\240+\239\DC4\243z.\\\SI\155 ",PropMaximumQoS 38,PropReceiveMaximum 21644,PropServerReference +// "\181\171d\182f_R\206\172\142c\196\250\r\NAK\245",PropResponseTopic +// "\DLE;2a\178;\EOTk>Z\170\STX\EOT\132\203\USn",PropReceiveMaximum 18705,PropReasonString "\170",PropReasonString +// "\251\226Ug\148\ETB\216\t\142\167\153*\154J\207\179\171U^y\143\&51\168",PropRetainAvailable 63]} TEST(Connect5QCTest, Encode2) { uint8_t pkt[] = { - 0x10, 0xf3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xa6, 0x5a, 0xec, 0x99, 0x1, 0x13, 0x66, 0xac, 0x2a, - 0xd8, 0x2, 0x0, 0x0, 0x6a, 0x5e, 0x23, 0x28, 0xa2, 0x13, 0x33, 0x18, 0x17, 0x7b, 0x11, 0x0, 0x0, 0xd, 0x84, - 0x13, 0x3b, 0x98, 0x17, 0xe4, 0x1f, 0x0, 0x1d, 0x3d, 0x8e, 0x1a, 0xfc, 0x20, 0xa7, 0x16, 0xd6, 0xfa, 0x74, 0xe0, - 0x2f, 0xe9, 0xfd, 0x62, 0x66, 0xa1, 0xf2, 0xba, 0x28, 0xd5, 0x17, 0x7e, 0x0, 0x48, 0x59, 0xf5, 0xcb, 0x9e, 0x9, - 0x0, 0xd, 0xfc, 0xbc, 0x63, 0x23, 0x47, 0x8a, 0xd2, 0xe7, 0x38, 0x9a, 0x5f, 0xe9, 0x52, 0x1, 0xf7, 0xb, 0x1e, - 0x1, 0x27, 0x3, 0x0, 0x7, 0xe2, 0x80, 0x5c, 0x5c, 0x4a, 0x2c, 0x9e, 0x22, 0x52, 0xf4, 0x1, 0x42, 0x25, 0x69, - 0x9, 0x0, 0x15, 0x9e, 0x12, 0x41, 0x7b, 0x57, 0xcc, 0x25, 0x9a, 0x9a, 0x55, 0xaa, 0x6f, 0x5, 0xf7, 0x69, 0xa6, - 0x7c, 0x5f, 0x5d, 0xd6, 0xe7, 0x2, 0x0, 0x0, 0x75, 0xbb, 0x12, 0x0, 0x6, 0xed, 0x1, 0x29, 0xb9, 0xc1, 0xa6, - 0x18, 0x0, 0x0, 0x5c, 0x68, 0x19, 0x39, 0x23, 0x7, 0x70, 0x24, 0x1d, 0x29, 0xf2, 0xb, 0x1b, 0x0, 0x13, 0x83, - 0x3d, 0x7b, 0x16, 0x9e, 0xaf, 0x27, 0x5d, 0x1c, 0xe9, 0x8b, 0x6d, 0x66, 0x83, 0x23, 0x92, 0xfc, 0x4d, 0x33, 0x0, - 0x0, 0x2, 0x32, 0x1e, 0x0, 0x1c, 0x43, 0x1f, 0xe2, 0x47, 0xbf, 0x1e, 0xe1, 0xee, 0xf1, 0xbb, 0x55, 0xb7, 0x4e, - 0x78, 0x1b, 0xa5, 0x87, 0x93, 0xb5, 0xe, 0x7c, 0x1b, 0xec, 0x9b, 0xc6, 0x36, 0xff, 0xc3, 0x0, 0x14, 0xa4, 0x16, - 0x54, 0xe4, 0x27, 0x57, 0xff, 0xf4, 0xbb, 0xc1, 0xed, 0xb4, 0xd, 0xee, 0x64, 0x97, 0x6d, 0xbf, 0xa, 0xb7}; - - uint8_t buf[256] = {0}; - - uint8_t bytesprops0[] = {0x3d, 0x8e, 0x1a, 0xfc, 0x20, 0xa7, 0x16, 0xd6, 0xfa, 0x74, 0xe0, 0x2f, 0xe9, 0xfd, 0x62, - 0x66, 0xa1, 0xf2, 0xba, 0x28, 0xd5, 0x17, 0x7e, 0x0, 0x48, 0x59, 0xf5, 0xcb, 0x9e}; - uint8_t bytesprops1[] = {0xfc, 0xbc, 0x63, 0x23, 0x47, 0x8a, 0xd2, 0xe7, 0x38, 0x9a, 0x5f, 0xe9, 0x52}; - uint8_t bytesprops2[] = {0xe2, 0x80, 0x5c, 0x5c, 0x4a, 0x2c, 0x9e}; - uint8_t bytesprops3[] = {0x9e, 0x12, 0x41, 0x7b, 0x57, 0xcc, 0x25, 0x9a, 0x9a, 0x55, 0xaa, - 0x6f, 0x5, 0xf7, 0x69, 0xa6, 0x7c, 0x5f, 0x5d, 0xd6, 0xe7}; - uint8_t bytesprops4[] = {0xed, 0x1, 0x29, 0xb9, 0xc1, 0xa6}; + 0x10, 0x9a, 0x2, 0x0, 0x4,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+ 0xb6, 0x56, 0x13, 0xc1, 0x52, 0x7f, 0x11, 0x3e, 0x6f, 0xa8, 0xb9, 0xc7, 0xc3, 0x69, 0xc9, 0x42, 0x57, 0xfd, 0xbd, + 0x38, 0x7, 0x8, 0x0, 0x4, 0x41, 0xee, 0x83, 0xbc, 0x0, 0x17, 0x11, 0xcc, 0xc2, 0x6a, 0xd4, 0x42, 0x32, 0x65, + 0x3e, 0x3f, 0xf8, 0x3d, 0x6c, 0x8e, 0x58, 0xc7, 0x55, 0xd, 0x73, 0x19, 0x49, 0x7, 0xbe, 0x0, 0x8, 0x3b, 0xd4, + 0xd6, 0x90, 0xb3, 0x8, 0x75, 0xed, 0x0, 0x1e, 0x53, 0x19, 0x72, 0xec, 0xb4, 0x6d, 0xab, 0xf1, 0x23, 0x93, 0xf7, + 0x18, 0x36, 0xd9, 0xd4, 0x7d, 0xe2, 0x8b, 0x20, 0x48, 0xf9, 0xfc, 0xf, 0xa4, 0xbe, 0x47, 0x10, 0xfd, 0x8b, 0x50}; + + uint8_t buf[295] = {0}; + + uint8_t bytesprops1[] = {0x1c, 0x2c, 0x5a, 0xa7, 0x57}; + uint8_t bytesprops0[] = {0xde, 0x89, 0xe0}; + uint8_t bytesprops2[] = {0x8e, 0xc0, 0xf8, 0xf3, 0x93, 0x8d, 0x4b, 0x91, 0xae, 0xa4, 0xdc, 0x97, + 0x2e, 0x3b, 0x30, 0xd9, 0xe8, 0x23, 0xa7, 0x80, 0x82, 0xbc, 0x6}; + uint8_t bytesprops4[] = {0x14, 0xf9, 0x3f, 0xf0, 0x2b, 0xef, 0x14, 0xf3, 0x7a, 0x2e, 0x5c, 0xf, 0x9b, 0x20}; + uint8_t bytesprops3[] = {0xd1, 0x4b, 0x85, 0xd8, 0xe0, 0xa4, 0x49, 0xf, 0xf8, + 0x13, 0xe2, 0x1b, 0x6f, 0x26, 0xbf, 0x1a, 0x4a, 0xb1}; + uint8_t bytesprops5[] = {0xb5, 0xab, 0x64, 0xb6, 0x66, 0x5f, 0x52, 0xce, + 0xac, 0x8e, 0x63, 0xc4, 0xfa, 0xd, 0x15, 0xf5}; + uint8_t bytesprops6[] = {0x10, 0x3b, 0x32, 0x61, 0xb2, 0x3b, 0x4, 0x6b, 0x3e, + 0x5a, 0xaa, 0x2, 0x4, 0x84, 0xcb, 0x1f, 0x6e}; + uint8_t bytesprops7[] = {0xaa}; + uint8_t bytesprops8[] = {0xfb, 0xe2, 0x55, 0x67, 0x94, 0x17, 0xd8, 0x9, 0x8e, 0xa7, 0x99, 0x2a, + 0x9a, 0x4a, 0xcf, 0xb3, 0xab, 0x55, 0x5e, 0x79, 0x8f, 0x35, 0x31, 0xa8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26284}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27230}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10402}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13080}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3460}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15256}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21236}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30139}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23656}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1904}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops0}, .v = {5, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26986}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops3}, .v = {14, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21644}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18705}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x41, 0xee, 0x83, 0xbc}; - lwmqtt_property_t willpropslist[] = {}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops0}}}, + }; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x32, 0x1e}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x43, 0x1f, 0xe2, 0x47, 0xbf, 0x1e, 0xe1, 0xee, 0xf1, 0xbb, 0x55, 0xb7, 0x4e, 0x78, - 0x1b, 0xa5, 0x87, 0x93, 0xb5, 0xe, 0x7c, 0x1b, 0xec, 0x9b, 0xc6, 0x36, 0xff, 0xc3}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x11, 0xcc, 0xc2, 0x6a, 0xd4, 0x42, 0x32, 0x65, 0x3e, 0x3f, 0xf8, 0x3d, + 0x6c, 0x8e, 0x58, 0xc7, 0x55, 0xd, 0x73, 0x19, 0x49, 0x7, 0xbe}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3b, 0xd4, 0xd6, 0x90, 0xb3, 0x8, 0x75, 0xed}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 23276; - uint8_t client_id_bytes[] = {0x83, 0x3d, 0x7b, 0x16, 0x9e, 0xaf, 0x27, 0x5d, 0x1c, 0xe9, - 0x8b, 0x6d, 0x66, 0x83, 0x23, 0x92, 0xfc, 0x4d, 0x33}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.keep_alive = 30140; + uint8_t client_id_bytes[] = {0x4e, 0xc7, 0x6a, 0xbb, 0xee, 0xed, 0xc1, 0x5c, 0x2d, 0xfa, + 0xb6, 0x56, 0x13, 0xc1, 0x52, 0x7f, 0x11, 0x3e, 0x6f, 0xa8, + 0xb9, 0xc7, 0xc3, 0x69, 0xc9, 0x42, 0x57, 0xfd, 0xbd, 0x38}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa4, 0x16, 0x54, 0xe4, 0x27, 0x57, 0xff, 0xf4, 0xbb, 0xc1, - 0xed, 0xb4, 0xd, 0xee, 0x64, 0x97, 0x6d, 0xbf, 0xa, 0xb7}; - lwmqtt_string_t username = {20, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x53, 0x19, 0x72, 0xec, 0xb4, 0x6d, 0xab, 0xf1, 0x23, 0x93, 0xf7, 0x18, 0x36, 0xd9, 0xd4, + 0x7d, 0xe2, 0x8b, 0x20, 0x48, 0xf9, 0xfc, 0xf, 0xa4, 0xbe, 0x47, 0x10, 0xfd, 0x8b, 0x50}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -1645,105 +2537,211 @@ TEST(Connect5QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\237TI=\140\157[R\161\178\154\138\249", _password = Just "\156\221\243", _lastWill -// = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "q\252\157\161\146\222\a\NAK2\173\167\152X\152\NAK", _willMsg = -// "\172\197<*\246\137\ESC\188\RS;\ENQ",PropAuthenticationMethod -// "s\224\226\217",PropRequestProblemInformation 110,PropAssignedClientIdentifier -// "\162\178\&6\\\164v\202\137\&70\DEL\150;<;We>\183",PropReceiveMaximum 1866,PropSharedSubscriptionAvailable -// 78,PropRetainAvailable 14,PropMessageExpiryInterval 2378,PropTopicAlias 8222,PropMessageExpiryInterval -// 24111,PropWillDelayInterval 8276,PropServerKeepAlive 18954,PropRequestProblemInformation 76,PropReasonString -// "x\240|",PropMessageExpiryInterval 13256]}), _cleanSession = True, _keepAlive = 7844, _connID = -// "\DC3\182\162\243D\231aQ<\184p\138\206\248T\248E\205\216S", _properties = [PropTopicAlias -// 27783,PropSubscriptionIdentifier 23,PropCorrelationData "(+\145\222*\206\250\207f!\172\&9",PropMessageExpiryInterval -// 14693,PropRetainAvailable 22,PropSharedSubscriptionAvailable 157,PropSharedSubscriptionAvailable -// 196,PropPayloadFormatIndicator 140,PropServerKeepAlive 26053,PropRetainAvailable 25]} +// ConnectRequest {_username = Just "-/\n", _password = Just +// "\DC1\248,\158\217\201a;Ayt\223u8\DC1\202\235z;\132E4z\135~b\208\175}\228", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS2, _willTopic = "\199\150!\SI0f4q\193\205\138\240\172!\SO/V\131\230\160", _willMsg = +// "\SOHv\ETB.O\221\DEL\243$\SYN\186\156g\r\218*\222c", _willProps = [PropWillDelayInterval +// 29655,PropWildcardSubscriptionAvailable 46,PropUserProperty "\206\164\216\220O$\136\220\189\166" +// "4\f\216+\152(\190\\J\249\196\156/\150_\171\140L",PropSessionExpiryInterval 24620,PropRequestResponseInformation +// 238,PropMessageExpiryInterval 8243,PropServerKeepAlive 9792,PropSessionExpiryInterval 21683,PropContentType +// "\147S\189\f+hL\234'HE*\252\nK\203\STX\140|\162S\173\155",PropReasonString +// "\227\149\216W\198\229p\231\208\251d\235\DC18$6\228\188\147<\154\211\&0\130%|6\161",PropCorrelationData +// "\152jc\170u\SI\234\&8=\143-\"\DC4\192\222\DLE.I",PropMaximumQoS 70,PropSubscriptionIdentifierAvailable +// 169,PropAuthenticationData +// "(\189\SO\RSZk\234\DC1\213\139\DC2\212\242C\205p\r]~l\252\ESC3\185,m\SOH\160\162",PropContentType +// "\f\251Uh\199",PropAuthenticationData +// "=\243\b\DC4\r\146L\233:W\160}\175\204\251\SOH#\194\223",PropSessionExpiryInterval 31741,PropResponseInformation +// "\144w\227\235",PropReasonString +// "\235D\r\214\f\239\US\EOT\ETB\212\ACK\255+\148\150\173\EOT",PropMessageExpiryInterval 3305,PropPayloadFormatIndicator +// 158,PropMessageExpiryInterval 24180,PropRequestResponseInformation 186,PropResponseInformation +// "",PropResponseInformation "\DC3u\SUB",PropMaximumPacketSize 4574,PropServerKeepAlive +// 14158,PropRequestProblemInformation 104,PropUserProperty "b\167\239\137-\177\&1\156$K\146\252,\162@\190F\233\210\189" +// "\GS\132\208q\240\208\255\188\155\&2\242\SI\214\129\b\STX\240/1%\182m\EOTh\200@\189\152"]}), _cleanSession = False, +// _keepAlive = 9480, _connID = "\221G3\134\ad\205\255\246S\165\157\209\247\DC4w\180\"T\253\227k\210\179\154(\202", +// _properties = [PropMessageExpiryInterval 13222,PropAuthenticationMethod "\\x\t\194d\SUB_\154D",PropRetainAvailable +// 79,PropMessageExpiryInterval 18495,PropAuthenticationData +// "8V\RS\r\189.\185\174\131\NUL\179\SUB\152\169\174\235\170\164\NUL\DC1\SIS\151\EOT\156",PropAuthenticationMethod +// "\165",PropRequestProblemInformation 213,PropPayloadFormatIndicator 186,PropReasonString +// "\SYN0",PropAuthenticationMethod "0!2\192\182\211u\244e\179\ACK\189\DEL\GS\238Q",PropAuthenticationMethod +// "|oN>G\255R\171\NUL\226\188z9K\134\169\128x\241\128\254\\f\tm0\147\149\229H",PropContentType +// "\207",PropReceiveMaximum 27076,PropUserProperty +// "\164\&0^cq0\187\165\177\225\227\DC3\167\224\164\208R\231\ETB\ESCf\232" +// "\167\201v\204\156\249\SOgAw\175\199\191l^\227T\191H\DC3",PropAuthenticationMethod +// "%v\SOH\255\164\237\154\SI\t\234\150K\235}\132\228n\162\&4\212 ",PropMaximumQoS 92,PropReceiveMaximum +// 17436,PropSubscriptionIdentifierAvailable 73,PropWillDelayInterval 12518,PropWillDelayInterval +// 21753,PropSessionExpiryInterval 13068,PropMessageExpiryInterval 32198,PropWildcardSubscriptionAvailable +// 77,PropPayloadFormatIndicator 49]} TEST(Connect5QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0xe6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x1e, 0xa4, 0x26, 0x23, 0x6c, 0x87, - 0xb, 0x17, 0x9, 0x0, 0xc, 0x28, 0x2b, 0x91, 0xde, 0x2a, 0xce, 0xfa, 0xcf, 0x66, 0x21, 0xac, 0x39, - 0x2, 0x0, 0x0, 0x39, 0x65, 0x25, 0x16, 0x2a, 0x9d, 0x2a, 0xc4, 0x1, 0x8c, 0x13, 0x65, 0xc5, 0x25, - 0x19, 0x0, 0x14, 0x13, 0xb6, 0xa2, 0xf3, 0x44, 0xe7, 0x61, 0x51, 0x3c, 0xb8, 0x70, 0x8a, 0xce, 0xf8, - 0x54, 0xf8, 0x45, 0xcd, 0xd8, 0x53, 0x5f, 0x1f, 0x0, 0x14, 0x49, 0xbd, 0xc0, 0xfb, 0xe2, 0xb6, 0x43, - 0x82, 0x3a, 0xec, 0x3e, 0x3c, 0x2a, 0xf6, 0x89, 0x1b, 0xbc, 0x1e, 0x3b, 0x5, 0x15, 0x0, 0x4, 0x73, - 0xe0, 0xe2, 0xd9, 0x17, 0x6e, 0x12, 0x0, 0x13, 0xa2, 0xb2, 0x36, 0x5c, 0xa4, 0x76, 0xca, 0x89, 0x37, - 0x30, 0x7f, 0x96, 0x3b, 0x3c, 0x3b, 0x57, 0x65, 0x3e, 0xb7, 0x21, 0x7, 0x4a, 0x2a, 0x4e, 0x25, 0xe, - 0x2, 0x0, 0x0, 0x9, 0x4a, 0x23, 0x20, 0x1e, 0x2, 0x0, 0x0, 0x5e, 0x2f, 0x18, 0x0, 0x0, 0x20, - 0x54, 0x13, 0x4a, 0xa, 0x17, 0x4c, 0x1f, 0x0, 0x3, 0x78, 0xf0, 0x7c, 0x2, 0x0, 0x0, 0x33, 0xc8, - 0x0, 0xf, 0x71, 0xfc, 0x9d, 0xa1, 0x92, 0xde, 0x7, 0x15, 0x32, 0xad, 0xa7, 0x98, 0x58, 0x98, 0x15, - 0x0, 0x18, 0xac, 0xc5, 0x3c, 0x65, 0x41, 0x55, 0x1e, 0x90, 0xf2, 0xe9, 0x41, 0x3, 0x64, 0x13, 0xeb, - 0xf1, 0xb7, 0xc4, 0xc5, 0xe6, 0x21, 0x1a, 0x9f, 0x70, 0x0, 0xd, 0xed, 0x54, 0x49, 0x3d, 0x8c, 0x9d, - 0x5b, 0x52, 0xa1, 0xb2, 0x9a, 0x8a, 0xf9, 0x0, 0x3, 0x9c, 0xdd, 0xf3}; - - uint8_t buf[243] = {0}; - - uint8_t bytesprops0[] = {0x28, 0x2b, 0x91, 0xde, 0x2a, 0xce, 0xfa, 0xcf, 0x66, 0x21, 0xac, 0x39}; + uint8_t pkt[] = { + 0x10, 0x9e, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x25, 0x8, 0xe2, 0x1, 0x2, 0x0, 0x0, 0x33, + 0xa6, 0x15, 0x0, 0x9, 0x5c, 0x78, 0x9, 0xc2, 0x64, 0x1a, 0x5f, 0x9a, 0x44, 0x25, 0x4f, 0x2, 0x0, 0x0, 0x48, + 0x3f, 0x16, 0x0, 0x19, 0x38, 0x56, 0x1e, 0xd, 0xbd, 0x2e, 0xb9, 0xae, 0x83, 0x0, 0xb3, 0x1a, 0x98, 0xa9, 0xae, + 0xeb, 0xaa, 0xa4, 0x0, 0x11, 0xf, 0x53, 0x97, 0x4, 0x9c, 0x15, 0x0, 0x1, 0xa5, 0x17, 0xd5, 0x1, 0xba, 0x1f, + 0x0, 0x2, 0x16, 0x30, 0x15, 0x0, 0x10, 0x30, 0x21, 0x32, 0xc0, 0xb6, 0xd3, 0x75, 0xf4, 0x65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 0x79, 0x74, 0xdf, 0x75, 0x38, 0x11, 0xca, 0xeb, 0x7a, 0x3b, 0x84, 0x45, 0x34, + 0x7a, 0x87, 0x7e, 0x62, 0xd0, 0xaf, 0x7d, 0xe4}; + + uint8_t buf[683] = {0}; + + uint8_t bytesprops0[] = {0x5c, 0x78, 0x9, 0xc2, 0x64, 0x1a, 0x5f, 0x9a, 0x44}; + uint8_t bytesprops1[] = {0x38, 0x56, 0x1e, 0xd, 0xbd, 0x2e, 0xb9, 0xae, 0x83, 0x0, 0xb3, 0x1a, 0x98, + 0xa9, 0xae, 0xeb, 0xaa, 0xa4, 0x0, 0x11, 0xf, 0x53, 0x97, 0x4, 0x9c}; + uint8_t bytesprops2[] = {0xa5}; + uint8_t bytesprops3[] = {0x16, 0x30}; + uint8_t bytesprops4[] = {0x30, 0x21, 0x32, 0xc0, 0xb6, 0xd3, 0x75, 0xf4, + 0x65, 0xb3, 0x6, 0xbd, 0x7f, 0x1d, 0xee, 0x51}; + uint8_t bytesprops5[] = {0x7c, 0x6f, 0x4e, 0x3e, 0x47, 0xff, 0x52, 0xab, 0x0, 0xe2, 0xbc, 0x7a, 0x39, 0x4b, 0x86, + 0xa9, 0x80, 0x78, 0xf1, 0x80, 0xfe, 0x5c, 0x66, 0x9, 0x6d, 0x30, 0x93, 0x95, 0xe5, 0x48}; + uint8_t bytesprops6[] = {0xcf}; + uint8_t bytesprops8[] = {0xa7, 0xc9, 0x76, 0xcc, 0x9c, 0xf9, 0xe, 0x67, 0x41, 0x77, + 0xaf, 0xc7, 0xbf, 0x6c, 0x5e, 0xe3, 0x54, 0xbf, 0x48, 0x13}; + uint8_t bytesprops7[] = {0xa4, 0x30, 0x5e, 0x63, 0x71, 0x30, 0xbb, 0xa5, 0xb1, 0xe1, 0xe3, + 0x13, 0xa7, 0xe0, 0xa4, 0xd0, 0x52, 0xe7, 0x17, 0x1b, 0x66, 0xe8}; + uint8_t bytesprops9[] = {0x25, 0x76, 0x1, 0xff, 0xa4, 0xed, 0x9a, 0xf, 0x9, 0xea, 0x96, + 0x4b, 0xeb, 0x7d, 0x84, 0xe4, 0x6e, 0xa2, 0x34, 0xd4, 0x20}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27783}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14693}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26053}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13222}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18495}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27076}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops7}, .v = {20, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17436}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12518}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21753}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13068}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32198}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 49}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x49, 0xbd, 0xc0, 0xfb, 0xe2, 0xb6, 0x43, 0x82, 0x3a, 0xec, - 0x3e, 0x3c, 0x2a, 0xf6, 0x89, 0x1b, 0xbc, 0x1e, 0x3b, 0x5}; - uint8_t byteswillprops1[] = {0x73, 0xe0, 0xe2, 0xd9}; - uint8_t byteswillprops2[] = {0xa2, 0xb2, 0x36, 0x5c, 0xa4, 0x76, 0xca, 0x89, 0x37, 0x30, - 0x7f, 0x96, 0x3b, 0x3c, 0x3b, 0x57, 0x65, 0x3e, 0xb7}; - uint8_t byteswillprops3[] = {0x78, 0xf0, 0x7c}; + uint8_t byteswillprops1[] = {0x34, 0xc, 0xd8, 0x2b, 0x98, 0x28, 0xbe, 0x5c, 0x4a, + 0xf9, 0xc4, 0x9c, 0x2f, 0x96, 0x5f, 0xab, 0x8c, 0x4c}; + uint8_t byteswillprops0[] = {0xce, 0xa4, 0xd8, 0xdc, 0x4f, 0x24, 0x88, 0xdc, 0xbd, 0xa6}; + uint8_t byteswillprops2[] = {0x93, 0x53, 0xbd, 0xc, 0x2b, 0x68, 0x4c, 0xea, 0x27, 0x48, 0x45, 0x2a, + 0xfc, 0xa, 0x4b, 0xcb, 0x2, 0x8c, 0x7c, 0xa2, 0x53, 0xad, 0x9b}; + uint8_t byteswillprops3[] = {0xe3, 0x95, 0xd8, 0x57, 0xc6, 0xe5, 0x70, 0xe7, 0xd0, 0xfb, 0x64, 0xeb, 0x11, 0x38, + 0x24, 0x36, 0xe4, 0xbc, 0x93, 0x3c, 0x9a, 0xd3, 0x30, 0x82, 0x25, 0x7c, 0x36, 0xa1}; + uint8_t byteswillprops4[] = {0x98, 0x6a, 0x63, 0xaa, 0x75, 0xf, 0xea, 0x38, 0x3d, + 0x8f, 0x2d, 0x22, 0x14, 0xc0, 0xde, 0x10, 0x2e, 0x49}; + uint8_t byteswillprops5[] = {0x28, 0xbd, 0xe, 0x1e, 0x5a, 0x6b, 0xea, 0x11, 0xd5, 0x8b, 0x12, 0xd4, 0xf2, 0x43, 0xcd, + 0x70, 0xd, 0x5d, 0x7e, 0x6c, 0xfc, 0x1b, 0x33, 0xb9, 0x2c, 0x6d, 0x1, 0xa0, 0xa2}; + uint8_t byteswillprops6[] = {0xc, 0xfb, 0x55, 0x68, 0xc7}; + uint8_t byteswillprops7[] = {0x3d, 0xf3, 0x8, 0x14, 0xd, 0x92, 0x4c, 0xe9, 0x3a, 0x57, + 0xa0, 0x7d, 0xaf, 0xcc, 0xfb, 0x1, 0x23, 0xc2, 0xdf}; + uint8_t byteswillprops8[] = {0x90, 0x77, 0xe3, 0xeb}; + uint8_t byteswillprops9[] = {0xeb, 0x44, 0xd, 0xd6, 0xc, 0xef, 0x1f, 0x4, 0x17, + 0xd4, 0x6, 0xff, 0x2b, 0x94, 0x96, 0xad, 0x4}; + uint8_t byteswillprops10[] = {0}; + uint8_t byteswillprops11[] = {0x13, 0x75, 0x1a}; + uint8_t byteswillprops13[] = {0x1d, 0x84, 0xd0, 0x71, 0xf0, 0xd0, 0xff, 0xbc, 0x9b, 0x32, 0xf2, 0xf, 0xd6, 0x81, + 0x8, 0x2, 0xf0, 0x2f, 0x31, 0x25, 0xb6, 0x6d, 0x4, 0x68, 0xc8, 0x40, 0xbd, 0x98}; + uint8_t byteswillprops12[] = {0x62, 0xa7, 0xef, 0x89, 0x2d, 0xb1, 0x31, 0x9c, 0x24, 0x4b, + 0x92, 0xfc, 0x2c, 0xa2, 0x40, 0xbe, 0x46, 0xe9, 0xd2, 0xbd}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1866}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2378}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8222}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24111}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8276}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18954}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13256}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29655}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {10, (char*)&byteswillprops0}, .v = {18, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24620}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8243}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9792}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21683}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31741}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3305}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24180}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4574}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14158}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {20, (char*)&byteswillprops12}, .v = {28, (char*)&byteswillprops13}}}}, }; - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x71, 0xfc, 0x9d, 0xa1, 0x92, 0xde, 0x7, 0x15, - 0x32, 0xad, 0xa7, 0x98, 0x58, 0x98, 0x15}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xac, 0xc5, 0x3c, 0x65, 0x41, 0x55, 0x1e, 0x90, 0xf2, 0xe9, 0x41, 0x3, - 0x64, 0x13, 0xeb, 0xf1, 0xb7, 0xc4, 0xc5, 0xe6, 0x21, 0x1a, 0x9f, 0x70}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc7, 0x96, 0x21, 0xf, 0x30, 0x66, 0x34, 0x71, 0xc1, 0xcd, + 0x8a, 0xf0, 0xac, 0x21, 0xe, 0x2f, 0x56, 0x83, 0xe6, 0xa0}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1, 0x76, 0x17, 0x2e, 0x4f, 0xdd, 0x7f, 0xf3, 0x24, + 0x16, 0xba, 0x9c, 0x67, 0xd, 0xda, 0x2a, 0xde, 0x63}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 7844; - uint8_t client_id_bytes[] = {0x13, 0xb6, 0xa2, 0xf3, 0x44, 0xe7, 0x61, 0x51, 0x3c, 0xb8, - 0x70, 0x8a, 0xce, 0xf8, 0x54, 0xf8, 0x45, 0xcd, 0xd8, 0x53}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 9480; + uint8_t client_id_bytes[] = {0xdd, 0x47, 0x33, 0x86, 0x7, 0x64, 0xcd, 0xff, 0xf6, 0x53, 0xa5, 0x9d, 0xd1, 0xf7, + 0x14, 0x77, 0xb4, 0x22, 0x54, 0xfd, 0xe3, 0x6b, 0xd2, 0xb3, 0x9a, 0x28, 0xca}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xed, 0x54, 0x49, 0x3d, 0x8c, 0x9d, 0x5b, 0x52, 0xa1, 0xb2, 0x9a, 0x8a, 0xf9}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x2d, 0x2f, 0xa}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x9c, 0xdd, 0xf3}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x11, 0xf8, 0x2c, 0x9e, 0xd9, 0xc9, 0x61, 0x3b, 0x41, 0x79, 0x74, 0xdf, 0x75, 0x38, 0x11, + 0xca, 0xeb, 0x7a, 0x3b, 0x84, 0x45, 0x34, 0x7a, 0x87, 0x7e, 0x62, 0xd0, 0xaf, 0x7d, 0xe4}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -1752,269 +2750,193 @@ TEST(Connect5QCTest, Encode3) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\224i\DLEM\214\247\187\191\DEL\211\139G\208\177\241\223\240\254Q\187\238", -// _password = Just "\214t\171wJ\205+", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = -// "\201\&2\STXO\162\178*\207.", _willMsg = "\130sO\246\224\216\186Y^\142PH\235zMe+\247P:~\151\243", _willProps = -// [PropSharedSubscriptionAvailable 234,PropMaximumPacketSize 13128,PropSharedSubscriptionAvailable -// 26,PropTopicAliasMaximum 30233,PropContentType -// "\210\206\"\ENQ_J\STX28\252At\252V|x\233\153\145b9\160\n\192\209\247I\197\DC4_",PropAssignedClientIdentifier -// "\162\RS\214y\233\129\212\162\239",PropMessageExpiryInterval 3560,PropSubscriptionIdentifierAvailable -// 237,PropTopicAliasMaximum 10546,PropContentType -// "\ESCN\DC2\156\134|o\183\183k\219\DC2e\222{\197]",PropMaximumPacketSize 12592,PropSubscriptionIdentifierAvailable -// 202,PropWildcardSubscriptionAvailable 238,PropSubscriptionIdentifier 11,PropMaximumPacketSize -// 27524,PropSubscriptionIdentifierAvailable 195,PropResponseInformation -// "q\SUB\169\EOT\245]\169\CAN\SI\b\b\218U\220\238\247\156\STX\213B\130M\231\190\EM\255",PropReceiveMaximum -// 30498,PropTopicAlias 13431,PropAuthenticationData "\129z\243*~",PropAuthenticationData -// ">W3\237\160\SYN\r_\139\248HFF",PropCorrelationData "zP\EM\229\CAN\NAK",PropMaximumQoS 133,PropMessageExpiryInterval -// 3956]}), _cleanSession = True, _keepAlive = 27556, _connID = -// "\SYN=D\DC23R\135\142|\151\t7\226\201\228\239\224\189\DC4a\198\210\FSA\189", _properties = [PropMessageExpiryInterval -// 23978,PropResponseInformation "\EOTa\156N\222\CAN\224\198\171\RSq6\194)\NAK\223\137"]} +// ConnectRequest {_username = Nothing, _password = Just "\192\131", _lastWill = Nothing, _cleanSession = False, +// _keepAlive = 25448, _connID = "\131\216\FS}\NAKIn$\DC37\186M\161\151kP\148\142|\224Q\234\249\223\172hF\168", +// _properties = [PropAuthenticationMethod +// "v\166\197\235u\245\160t\\\141]\133g\242\246\183\148\198\DC1:\155\164\GS",PropServerKeepAlive 14593,PropMaximumQoS +// 166,PropMessageExpiryInterval 2517,PropAssignedClientIdentifier +// "\248\DLEQ\154\151\146\234Z\172\204\242\148\&1L\213\234\202\147\n\SO`|`",PropRequestProblemInformation +// 97,PropMaximumPacketSize 27560,PropMessageExpiryInterval 14874,PropMessageExpiryInterval +// 230,PropRequestProblemInformation 214,PropWillDelayInterval 2090,PropAssignedClientIdentifier +// "\EM\207\\<\152\NAKG3$Wa\249",PropMaximumQoS 210]} TEST(Connect5QCTest, Encode4) { - uint8_t pkt[] = { - 0x10, 0xb9, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x6b, 0xa4, 0x19, 0x2, 0x0, 0x0, 0x5d, 0xaa, - 0x1a, 0x0, 0x11, 0x4, 0x61, 0x9c, 0x4e, 0xde, 0x18, 0xe0, 0xc6, 0xab, 0x1e, 0x71, 0x36, 0xc2, 0x29, 0x15, 0xdf, - 0x89, 0x0, 0x19, 0x16, 0x3d, 0x44, 0x12, 0x33, 0x52, 0x87, 0x8e, 0x7c, 0x97, 0x9, 0x37, 0xe2, 0xc9, 0xe4, 0xef, - 0xe0, 0xbd, 0x14, 0x61, 0xc6, 0xd2, 0x1c, 0x41, 0xbd, 0xb4, 0x1, 0x2a, 0xea, 0x27, 0x0, 0x0, 0x33, 0x48, 0x2a, - 0x1a, 0x22, 0x76, 0x19, 0x3, 0x0, 0x1e, 0xd2, 0xce, 0x22, 0x5, 0x5f, 0x4a, 0x2, 0x32, 0x38, 0xfc, 0x41, 0x74, - 0xfc, 0x56, 0x7c, 0x78, 0xe9, 0x99, 0x91, 0x62, 0x39, 0xa0, 0xa, 0xc0, 0xd1, 0xf7, 0x49, 0xc5, 0x14, 0x5f, 0x12, - 0x0, 0x9, 0xa2, 0x1e, 0xd6, 0x79, 0xe9, 0x81, 0xd4, 0xa2, 0xef, 0x2, 0x0, 0x0, 0xd, 0xe8, 0x29, 0xed, 0x22, - 0x29, 0x32, 0x3, 0x0, 0x11, 0x1b, 0x4e, 0x12, 0x9c, 0x86, 0x7c, 0x6f, 0xb7, 0xb7, 0x6b, 0xdb, 0x12, 0x65, 0xde, - 0x7b, 0xc5, 0x5d, 0x27, 0x0, 0x0, 0x31, 0x30, 0x29, 0xca, 0x28, 0xee, 0xb, 0xb, 0x27, 0x0, 0x0, 0x6b, 0x84, - 0x29, 0xc3, 0x1a, 0x0, 0x1a, 0x71, 0x1a, 0xa9, 0x4, 0xf5, 0x5d, 0xa9, 0x18, 0xf, 0x8, 0x8, 0xda, 0x55, 0xdc, - 0xee, 0xf7, 0x9c, 0x2, 0xd5, 0x42, 0x82, 0x4d, 0xe7, 0xbe, 0x19, 0xff, 0x21, 0x77, 0x22, 0x23, 0x34, 0x77, 0x16, - 0x0, 0x5, 0x81, 0x7a, 0xf3, 0x2a, 0x7e, 0x16, 0x0, 0xd, 0x3e, 0x57, 0x33, 0xed, 0xa0, 0x16, 0xd, 0x5f, 0x8b, - 0xf8, 0x48, 0x46, 0x46, 0x9, 0x0, 0x6, 0x7a, 0x50, 0x19, 0xe5, 0x18, 0x15, 0x24, 0x85, 0x2, 0x0, 0x0, 0xf, - 0x74, 0x0, 0x9, 0xc9, 0x32, 0x2, 0x4f, 0xa2, 0xb2, 0x2a, 0xcf, 0x2e, 0x0, 0x17, 0x82, 0x73, 0x4f, 0xf6, 0xe0, - 0xd8, 0xba, 0x59, 0x5e, 0x8e, 0x50, 0x48, 0xeb, 0x7a, 0x4d, 0x65, 0x2b, 0xf7, 0x50, 0x3a, 0x7e, 0x97, 0xf3, 0x0, - 0x15, 0xe0, 0x69, 0x10, 0x4d, 0xd6, 0xf7, 0xbb, 0xbf, 0x7f, 0xd3, 0x8b, 0x47, 0xd0, 0xb1, 0xf1, 0xdf, 0xf0, 0xfe, - 0x51, 0xbb, 0xee, 0x0, 0x7, 0xd6, 0x74, 0xab, 0x77, 0x4a, 0xcd, 0x2b}; - - uint8_t buf[326] = {0}; - - uint8_t bytesprops0[] = {0x4, 0x61, 0x9c, 0x4e, 0xde, 0x18, 0xe0, 0xc6, 0xab, - 0x1e, 0x71, 0x36, 0xc2, 0x29, 0x15, 0xdf, 0x89}; + uint8_t pkt[] = {0x10, 0x90, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x63, 0x68, 0x67, 0x15, 0x0, 0x17, + 0x76, 0xa6, 0xc5, 0xeb, 0x75, 0xf5, 0xa0, 0x74, 0x5c, 0x8d, 0x5d, 0x85, 0x67, 0xf2, 0xf6, 0xb7, 0x94, + 0xc6, 0x11, 0x3a, 0x9b, 0xa4, 0x1d, 0x13, 0x39, 0x1, 0x24, 0xa6, 0x2, 0x0, 0x0, 0x9, 0xd5, 0x12, + 0x0, 0x17, 0xf8, 0x10, 0x51, 0x9a, 0x97, 0x92, 0xea, 0x5a, 0xac, 0xcc, 0xf2, 0x94, 0x31, 0x4c, 0xd5, + 0xea, 0xca, 0x93, 0xa, 0xe, 0x60, 0x7c, 0x60, 0x17, 0x61, 0x27, 0x0, 0x0, 0x6b, 0xa8, 0x2, 0x0, + 0x0, 0x3a, 0x1a, 0x2, 0x0, 0x0, 0x0, 0xe6, 0x17, 0xd6, 0x18, 0x0, 0x0, 0x8, 0x2a, 0x12, 0x0, + 0xc, 0x19, 0xcf, 0x5c, 0x3c, 0x98, 0x15, 0x47, 0x33, 0x24, 0x57, 0x61, 0xf9, 0x24, 0xd2, 0x0, 0x1c, + 0x83, 0xd8, 0x1c, 0x7d, 0x15, 0x49, 0x6e, 0x24, 0x13, 0x37, 0xba, 0x4d, 0xa1, 0x97, 0x6b, 0x50, 0x94, + 0x8e, 0x7c, 0xe0, 0x51, 0xea, 0xf9, 0xdf, 0xac, 0x68, 0x46, 0xa8}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23978}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, - }; + uint8_t buf[157] = {0}; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd2, 0xce, 0x22, 0x5, 0x5f, 0x4a, 0x2, 0x32, 0x38, 0xfc, - 0x41, 0x74, 0xfc, 0x56, 0x7c, 0x78, 0xe9, 0x99, 0x91, 0x62, - 0x39, 0xa0, 0xa, 0xc0, 0xd1, 0xf7, 0x49, 0xc5, 0x14, 0x5f}; - uint8_t byteswillprops1[] = {0xa2, 0x1e, 0xd6, 0x79, 0xe9, 0x81, 0xd4, 0xa2, 0xef}; - uint8_t byteswillprops2[] = {0x1b, 0x4e, 0x12, 0x9c, 0x86, 0x7c, 0x6f, 0xb7, 0xb7, - 0x6b, 0xdb, 0x12, 0x65, 0xde, 0x7b, 0xc5, 0x5d}; - uint8_t byteswillprops3[] = {0x71, 0x1a, 0xa9, 0x4, 0xf5, 0x5d, 0xa9, 0x18, 0xf, 0x8, 0x8, 0xda, 0x55, - 0xdc, 0xee, 0xf7, 0x9c, 0x2, 0xd5, 0x42, 0x82, 0x4d, 0xe7, 0xbe, 0x19, 0xff}; - uint8_t byteswillprops4[] = {0x81, 0x7a, 0xf3, 0x2a, 0x7e}; - uint8_t byteswillprops5[] = {0x3e, 0x57, 0x33, 0xed, 0xa0, 0x16, 0xd, 0x5f, 0x8b, 0xf8, 0x48, 0x46, 0x46}; - uint8_t byteswillprops6[] = {0x7a, 0x50, 0x19, 0xe5, 0x18, 0x15}; + uint8_t bytesprops0[] = {0x76, 0xa6, 0xc5, 0xeb, 0x75, 0xf5, 0xa0, 0x74, 0x5c, 0x8d, 0x5d, 0x85, + 0x67, 0xf2, 0xf6, 0xb7, 0x94, 0xc6, 0x11, 0x3a, 0x9b, 0xa4, 0x1d}; + uint8_t bytesprops1[] = {0xf8, 0x10, 0x51, 0x9a, 0x97, 0x92, 0xea, 0x5a, 0xac, 0xcc, 0xf2, 0x94, + 0x31, 0x4c, 0xd5, 0xea, 0xca, 0x93, 0xa, 0xe, 0x60, 0x7c, 0x60}; + uint8_t bytesprops2[] = {0x19, 0xcf, 0x5c, 0x3c, 0x98, 0x15, 0x47, 0x33, 0x24, 0x57, 0x61, 0xf9}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13128}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30233}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3560}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10546}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12592}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27524}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30498}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13431}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3956}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14593}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2517}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27560}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14874}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 230}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2090}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, }; - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc9, 0x32, 0x2, 0x4f, 0xa2, 0xb2, 0x2a, 0xcf, 0x2e}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x82, 0x73, 0x4f, 0xf6, 0xe0, 0xd8, 0xba, 0x59, 0x5e, 0x8e, 0x50, 0x48, - 0xeb, 0x7a, 0x4d, 0x65, 0x2b, 0xf7, 0x50, 0x3a, 0x7e, 0x97, 0xf3}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 27556; - uint8_t client_id_bytes[] = {0x16, 0x3d, 0x44, 0x12, 0x33, 0x52, 0x87, 0x8e, 0x7c, 0x97, 0x9, 0x37, 0xe2, - 0xc9, 0xe4, 0xef, 0xe0, 0xbd, 0x14, 0x61, 0xc6, 0xd2, 0x1c, 0x41, 0xbd}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 25448; + uint8_t client_id_bytes[] = {0x83, 0xd8, 0x1c, 0x7d, 0x15, 0x49, 0x6e, 0x24, 0x13, 0x37, 0xba, 0x4d, 0xa1, 0x97, + 0x6b, 0x50, 0x94, 0x8e, 0x7c, 0xe0, 0x51, 0xea, 0xf9, 0xdf, 0xac, 0x68, 0x46, 0xa8}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xe0, 0x69, 0x10, 0x4d, 0xd6, 0xf7, 0xbb, 0xbf, 0x7f, 0xd3, 0x8b, - 0x47, 0xd0, 0xb1, 0xf1, 0xdf, 0xf0, 0xfe, 0x51, 0xbb, 0xee}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd6, 0x74, 0xab, 0x77, 0x4a, 0xcd, 0x2b}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xc0, 0x83}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "`\158g", _password = Just "\232\SI\164\182", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS0, _willTopic = "\228\209\134\&8\254\183", _willMsg = -// "u`\185\164|=O\ACK\216nx\132", _willProps = [PropMessageExpiryInterval 15261,PropTopicAliasMaximum -// 29836,PropRequestProblemInformation 20,PropRetainAvailable 102,PropRequestResponseInformation 129,PropRetainAvailable -// 104,PropUserProperty "\234\&8x\EMW" "\230\149\DC2;^\DLE\165\STX\245\151@V\211\149A\178S",PropUserProperty -// "\225p\154\210" "\131J\SI\129g\189\DC3\170\143RS\234\129\245\252X\228\171\215\&0",PropWildcardSubscriptionAvailable -// 78,PropAuthenticationMethod "f\141\254\185\233#",PropServerReference -// "[u\253\220\RS\235\188\183\155\202\CAN\186\229\185hV_\130\172)A\210%\ETX",PropUserProperty -// "f\161)F\206\248o\174\212\rf\169\241\164\223U-\214\186!\169\162\163\198\152" -// "\189Mi\200\EOT&1\203\221\182\SUB\194\222e\199\ACK\130U%\"",PropAssignedClientIdentifier -// "\GS_\206V\SUBy\174Q\STX\187b\161F.\141s\235{\DC3\251",PropMessageExpiryInterval 28877,PropResponseInformation -// "\CANP\ENQN8>\229D*",PropMessageExpiryInterval 19314,PropRequestResponseInformation 24,PropResponseInformation -// "]\147J\178\146&\158l\177\153\238\161\a\192",PropMessageExpiryInterval -// 5878,PropSessionExpiryInterval 18096,PropReceiveMaximum 27639,PropWildcardSubscriptionAvailable 151]}), _cleanSession -// = True, _keepAlive = 1272, _connID = "v=A\216\191\162\"ul\165(\217\182\151@.q", _properties = -// [PropSubscriptionIdentifier 22,PropPayloadFormatIndicator 172,PropContentType "\247\129",PropReceiveMaximum -// 14439,PropUserProperty "a\142 \153\240G" "\\\202\249\165\251\134/\v",PropSessionExpiryInterval -// 24192,PropWildcardSubscriptionAvailable 11,PropSubscriptionIdentifier 29,PropReceiveMaximum -// 8508,PropWildcardSubscriptionAvailable 28,PropMessageExpiryInterval 22152,PropReasonString -// "w\n0.",PropMessageExpiryInterval 18385,PropContentType "N\146\217\145fE\231\231\248\201\149\"u\212\139"]} +// ConnectRequest {_username = Just "\168\156M\204\209\177\255\141Bh\181\255\ACK4\218\ACKG\184\227\213\203", _password = +// Just "\GS\180\153*L\206\143\205", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "`\ACK\139\b", _willMsg = "\156E)Ei\136\NAK\137\140x\237K\166\154", _willProps = [PropPayloadFormatIndicator +// 173,PropPayloadFormatIndicator 200,PropMaximumPacketSize 3870,PropRetainAvailable 100,PropResponseTopic +// "O\191\160\201\166\235\204",PropRetainAvailable 168,PropMessageExpiryInterval 26217]}), _cleanSession = True, +// _keepAlive = 12280, _connID = "_\f\142\129\132{J\221 Xo", _properties = [PropMessageExpiryInterval +// 29411,PropResponseInformation "\247\147\216a\133",PropUserProperty +// "\145\193!\159\173\170o'\155\187{\144\191\ETB\187$)\145" +// "8\140\222\140J\190\&1z\218w\145\&8\225\159\201\236\227\230",PropRetainAvailable 134,PropReceiveMaximum +// 15749,PropSubscriptionIdentifier 1,PropSubscriptionIdentifierAvailable 176,PropMaximumPacketSize +// 16367,PropServerKeepAlive 7145,PropPayloadFormatIndicator 16,PropMaximumQoS 164,PropSubscriptionIdentifierAvailable +// 218,PropTopicAliasMaximum 2297,PropMessageExpiryInterval 16013,PropTopicAliasMaximum 19029,PropResponseTopic +// "\229\ACK $\132\183\211_y\202\184)\137\253\131\v\a\216\206\b\181\DC1\197\236~",PropRequestProblemInformation +// 174,PropContentType "\192\180\DLE\DEL=\DLE\148\221\CAN\RS\CAN_\158",PropAssignedClientIdentifier +// "\219\180\143",PropTopicAlias 7933,PropServerKeepAlive 21408,PropWillDelayInterval +// 29037,PropRequestResponseInformation 77,PropMessageExpiryInterval 14660,PropUserProperty +// "\199z\a\150I\189\132[\195s\136\178" "R\180v\130{)y\223+\203y\225\225}",PropAssignedClientIdentifier +// "\174zu\174M\137\228\191\167\205Z\166\136\a\240?\152\194\182D\170\&4\146\&53A{\151\239 ",PropResponseInformation +// "\226\193"]} TEST(Connect5QCTest, Encode5) { uint8_t pkt[] = { - 0x10, 0x8e, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x4, 0xf8, 0x50, 0xb, 0x16, 0x1, 0xac, 0x3, - 0x0, 0x2, 0xf7, 0x81, 0x21, 0x38, 0x67, 0x26, 0x0, 0x6, 0x61, 0x8e, 0x20, 0x99, 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x81}; - uint8_t bytesprops2[] = {0x5c, 0xca, 0xf9, 0xa5, 0xfb, 0x86, 0x2f, 0xb}; - uint8_t bytesprops1[] = {0x61, 0x8e, 0x20, 0x99, 0xf0, 0x47}; - uint8_t bytesprops3[] = {0x77, 0xa, 0x30, 0x2e}; - uint8_t bytesprops4[] = {0x4e, 0x92, 0xd9, 0x91, 0x66, 0x45, 0xe7, 0xe7, 0xf8, 0xc9, 0x95, 0x22, 0x75, 0xd4, 0x8b}; + 0x10, 0xd0, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x2f, 0xf8, 0xe3, 0x1, 0x2, 0x0, 0x0, 0x72, + 0xe3, 0x1a, 0x0, 0x5, 0xf7, 0x93, 0xd8, 0x61, 0x85, 0x26, 0x0, 0x12, 0x91, 0xc1, 0x21, 0x9f, 0xad, 0xaa, 0x6f, + 0x27, 0x9b, 0xbb, 0x7b, 0x90, 0xbf, 0x17, 0xbb, 0x24, 0x29, 0x91, 0x0, 0x12, 0x38, 0x8c, 0xde, 0x8c, 0x4a, 0xbe, + 0x31, 0x7a, 0xda, 0x77, 0x91, 0x38, 0xe1, 0x9f, 0xc9, 0xec, 0xe3, 0xe6, 0x25, 0x86, 0x21, 0x3d, 0x85, 0xb, 0x1, + 0x29, 0xb0, 0x27, 0x0, 0x0, 0x3f, 0xef, 0x13, 0x1b, 0xe9, 0x1, 0x10, 0x24, 0xa4, 0x29, 0xda, 0x22, 0x8, 0xf9, + 0x2, 0x0, 0x0, 0x3e, 0x8d, 0x22, 0x4a, 0x55, 0x8, 0x0, 0x19, 0xe5, 0x6, 0x20, 0x24, 0x84, 0xb7, 0xd3, 0x5f, + 0x79, 0xca, 0xb8, 0x29, 0x89, 0xfd, 0x83, 0xb, 0x7, 0xd8, 0xce, 0x8, 0xb5, 0x11, 0xc5, 0xec, 0x7e, 0x17, 0xae, + 0x3, 0x0, 0xd, 0xc0, 0xb4, 0x10, 0x7f, 0x3d, 0x10, 0x94,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 0x8, 0x1d, 0xb4, 0x99, 0x2a, 0x4c, 0xce, 0x8f, 0xcd}; + + uint8_t buf[349] = {0}; + + uint8_t bytesprops0[] = {0xf7, 0x93, 0xd8, 0x61, 0x85}; + uint8_t bytesprops2[] = {0x38, 0x8c, 0xde, 0x8c, 0x4a, 0xbe, 0x31, 0x7a, 0xda, + 0x77, 0x91, 0x38, 0xe1, 0x9f, 0xc9, 0xec, 0xe3, 0xe6}; + uint8_t bytesprops1[] = {0x91, 0xc1, 0x21, 0x9f, 0xad, 0xaa, 0x6f, 0x27, 0x9b, + 0xbb, 0x7b, 0x90, 0xbf, 0x17, 0xbb, 0x24, 0x29, 0x91}; + uint8_t bytesprops3[] = {0xe5, 0x6, 0x20, 0x24, 0x84, 0xb7, 0xd3, 0x5f, 0x79, 0xca, 0xb8, 0x29, 0x89, + 0xfd, 0x83, 0xb, 0x7, 0xd8, 0xce, 0x8, 0xb5, 0x11, 0xc5, 0xec, 0x7e}; + uint8_t bytesprops4[] = {0xc0, 0xb4, 0x10, 0x7f, 0x3d, 0x10, 0x94, 0xdd, 0x18, 0x1e, 0x18, 0x5f, 0x9e}; + uint8_t bytesprops5[] = {0xdb, 0xb4, 0x8f}; + uint8_t bytesprops7[] = {0x52, 0xb4, 0x76, 0x82, 0x7b, 0x29, 0x79, 0xdf, 0x2b, 0xcb, 0x79, 0xe1, 0xe1, 0x7d}; + uint8_t bytesprops6[] = {0xc7, 0x7a, 0x7, 0x96, 0x49, 0xbd, 0x84, 0x5b, 0xc3, 0x73, 0x88, 0xb2}; + uint8_t bytesprops8[] = {0xae, 0x7a, 0x75, 0xae, 0x4d, 0x89, 0xe4, 0xbf, 0xa7, 0xcd, 0x5a, 0xa6, 0x88, 0x7, 0xf0, + 0x3f, 0x98, 0xc2, 0xb6, 0x44, 0xaa, 0x34, 0x92, 0x35, 0x33, 0x41, 0x7b, 0x97, 0xef, 0x20}; + uint8_t bytesprops9[] = {0xe2, 0xc1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14439}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24192}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8508}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22152}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18385}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29411}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15749}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16367}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7145}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2297}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16013}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19029}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7933}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21408}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29037}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14660}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops6}, .v = {14, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xe6, 0x95, 0x12, 0x3b, 0x5e, 0x10, 0xa5, 0x2, 0xf5, - 0x97, 0x40, 0x56, 0xd3, 0x95, 0x41, 0xb2, 0x53}; - uint8_t byteswillprops0[] = {0xea, 0x38, 0x78, 0x19, 0x57}; - uint8_t byteswillprops3[] = {0x83, 0x4a, 0xf, 0x81, 0x67, 0xbd, 0x13, 0xaa, 0x8f, 0x52, - 0x53, 0xea, 0x81, 0xf5, 0xfc, 0x58, 0xe4, 0xab, 0xd7, 0x30}; - uint8_t byteswillprops2[] = {0xe1, 0x70, 0x9a, 0xd2}; - uint8_t byteswillprops4[] = {0x66, 0x8d, 0xfe, 0xb9, 0xe9, 0x23}; - uint8_t byteswillprops5[] = {0x5b, 0x75, 0xfd, 0xdc, 0x1e, 0xeb, 0xbc, 0xb7, 0x9b, 0xca, 0x18, 0xba, - 0xe5, 0xb9, 0x68, 0x56, 0x5f, 0x82, 0xac, 0x29, 0x41, 0xd2, 0x25, 0x3}; - uint8_t byteswillprops7[] = {0xbd, 0x4d, 0x69, 0xc8, 0x4, 0x26, 0x31, 0xcb, 0xdd, 0xb6, - 0x1a, 0xc2, 0xde, 0x65, 0xc7, 0x6, 0x82, 0x55, 0x25, 0x22}; - uint8_t byteswillprops6[] = {0x66, 0xa1, 0x29, 0x46, 0xce, 0xf8, 0x6f, 0xae, 0xd4, 0xd, 0x66, 0xa9, 0xf1, - 0xa4, 0xdf, 0x55, 0x2d, 0xd6, 0xba, 0x21, 0xa9, 0xa2, 0xa3, 0xc6, 0x98}; - uint8_t byteswillprops8[] = {0x1d, 0x5f, 0xce, 0x56, 0x1a, 0x79, 0xae, 0x51, 0x2, 0xbb, - 0x62, 0xa1, 0x46, 0x2e, 0x8d, 0x73, 0xeb, 0x7b, 0x13, 0xfb}; - uint8_t byteswillprops9[] = {0x18, 0x50, 0x5, 0x4e, 0x38, 0x3e, 0xe5, 0x44, 0x2a}; - uint8_t byteswillprops10[] = {0x5d, 0x93, 0x4a, 0xb2, 0x92, 0x26, 0x9e, 0x3c, 0x74, 0xf0, 0x9c, 0x64, 0xfb, 0xbc, - 0x18, 0x30, 0x92, 0x11, 0x1d, 0xcc, 0x3e, 0x6c, 0xb1, 0x99, 0xee, 0xa1, 0x7, 0xc0}; + uint8_t byteswillprops0[] = {0x4f, 0xbf, 0xa0, 0xc9, 0xa6, 0xeb, 0xcc}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15261}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29836}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {5, (char*)&byteswillprops0}, .v = {17, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {4, (char*)&byteswillprops2}, .v = {20, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {25, (char*)&byteswillprops6}, .v = {20, (char*)&byteswillprops7}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28877}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19314}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5878}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18096}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27639}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3870}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26217}}, }; - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe4, 0xd1, 0x86, 0x38, 0xfe, 0xb7}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x75, 0x60, 0xb9, 0xa4, 0x7c, 0x3d, 0x4f, 0x6, 0xd8, 0x6e, 0x78, 0x84}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x60, 0x6, 0x8b, 0x8}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x9c, 0x45, 0x29, 0x45, 0x69, 0x88, 0x15, 0x89, 0x8c, 0x78, 0xed, 0x4b, 0xa6, 0x9a}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS1; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 1272; - uint8_t client_id_bytes[] = {0x76, 0x3d, 0x41, 0xd8, 0xbf, 0xa2, 0x22, 0x75, 0x6c, - 0xa5, 0x28, 0xd9, 0xb6, 0x97, 0x40, 0x2e, 0x71}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.keep_alive = 12280; + uint8_t client_id_bytes[] = {0x5f, 0xc, 0x8e, 0x81, 0x84, 0x7b, 0x4a, 0xdd, 0x20, 0x58, 0x6f}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x60, 0x9e, 0x67}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa8, 0x9c, 0x4d, 0xcc, 0xd1, 0xb1, 0xff, 0x8d, 0x42, 0x68, 0xb5, + 0xff, 0x6, 0x34, 0xda, 0x6, 0x47, 0xb8, 0xe3, 0xd5, 0xcb}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xe8, 0xf, 0xa4, 0xb6}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x1d, 0xb4, 0x99, 0x2a, 0x4c, 0xce, 0x8f, 0xcd}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -2023,196 +2945,145 @@ TEST(Connect5QCTest, Encode5) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "|\ENQ\ETXN\196/!2\EOT\150wV\ETB\205R\NUL", _password = Just -// "\171\176x\189\&3I\250!\207\139J\139\160x\SYN", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, -// _willTopic = "9~,\236\224~@\247G|] \153\191\142\DC3\DEL\ETBcx\a\192\211\EOT\138IF", _willMsg = -// "\143q\200<\208LHV\222HO1\181U\229\173\158\255", _willProps = [PropMessageExpiryInterval 22676,PropUserProperty -// "t\GS\172\&3\213\181\221\140" "\242\191K\211F\247{\232\&31q`dJ",PropWillDelayInterval 18062,PropMaximumPacketSize -// 5758,PropContentType "\181\&9d\177\196@$a\155\132E\247\177\DEL\209\155\SYN\SOHZ\SI\167\156\r",PropMaximumPacketSize -// 32395,PropRequestResponseInformation 230,PropResponseTopic -// "\231%-\195\204\160\230\130\238S\176\187\128\214\247*fN.)k\146C\DC43\180!O;",PropMaximumPacketSize -// 8412,PropMessageExpiryInterval 20741,PropSubscriptionIdentifier 34,PropMessageExpiryInterval -// 3727,PropAuthenticationData -// "\208\182P\212\"bl\174\233\177+\249\EOT\230\173\a\194w\156\251\165\244\192\224\DC2\242\180\CAN",PropRequestProblemInformation -// 140,PropReceiveMaximum 31448,PropContentType "\SYN\168Tq\255\&4\226\237",PropServerKeepAlive 12597,PropReceiveMaximum -// 26906,PropWillDelayInterval 20356,PropCorrelationData "+p\240\GS\180\STX\235b$",PropResponseInformation -// "GT\ACKV",PropAssignedClientIdentifier -// "\160\&3!\SI\208GJ\233\153\130\163\169\f\CAN\221",PropWildcardSubscriptionAvailable 219,PropMaximumPacketSize -// 29532,PropReasonString -// "\169\RST\156~+\254\NAKF\208\195J\US\ESC$\177\190]\247\v\162\153D.\ENQ\175\136\214",PropTopicAliasMaximum -// 17359,PropReasonString -// "\DC1\SUB2\179\235\196U\SIi\196\&3\n_\234\DC3\EM\US\t(\ETB\226\&3\226\215\132\&6\222\NUL",PropMessageExpiryInterval -// 15547,PropMaximumPacketSize 435,PropServerReference "\SOHA"]}), _cleanSession = True, _keepAlive = 22109, _connID = -// "\DC4\170\162a\211\176\131\ETX\208", _properties = [PropServerReference "",PropRequestProblemInformation -// 9,PropCorrelationData "r\163\FS\131^\203\171\228\251",PropTopicAliasMaximum 30892,PropRequestResponseInformation -// 40,PropResponseTopic "\"gmj\239\211\&9\223\171\175\RS I0\136\154\233&\155\163",PropAuthenticationData -// "Y\FS\ENQZ\249s\147&H\188|q'3\236\193?!\178\184~Y\160\148\227",PropSubscriptionIdentifier 3,PropTopicAliasMaximum -// 13591,PropRequestProblemInformation 67,PropServerReference "\151\FSZ\189\161\249ha\DC1l\ETX\208\&6e\203r(\213 -// \240\&9\172\130@\181\131\fI\152",PropPayloadFormatIndicator 88,PropCorrelationData "\195%",PropWillDelayInterval -// 25823,PropRequestProblemInformation 234,PropRetainAvailable 166,PropPayloadFormatIndicator 99,PropUserProperty -// "\164\SI\183\198'\153l\223" -// "\US\204\185\164\243\228\209\ACKC\156\247{\143\241\145\135\180\131\138\178\188\DEL>\160\\\SYN1\139",PropSubscriptionIdentifierAvailable -// 7,PropSubscriptionIdentifier 9,PropServerReference "s\172\218\206K\156i\GS\154$\133O\174\160 -// \199i\205\247_$%Ux\170L\205",PropMaximumPacketSize 18119,PropCorrelationData -// "\227\157\235\193\139&\"L\231\133",PropWillDelayInterval 24104,PropResponseInformation -// "\227\254\251\227\145\RS\164OH\r\200\204\158",PropContentType -// "\134\224\147\203\ETX\189\185\189\179\189jT\148|\165~#",PropReasonString -// "a\229\206\164\193K\NUL\ETB8\148\DLE\191\245",PropReceiveMaximum 30786,PropSubscriptionIdentifierAvailable 109]} +// ConnectRequest {_username = Nothing, _password = Just "2\161\185\SYNP2z\ACK0l\186\203\155R\148\SUBXt\251\SI", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "V\140x\158\250\EOT>\241\241\148\199U", +// _willMsg = "\164[\137g\135\241I\233\146\232\214\165\163\235E\163v0\138#\DC3T4", _willProps = +// [PropWildcardSubscriptionAvailable 71,PropTopicAlias 18041,PropAuthenticationMethod +// "\212\181\&7\180\DLE\181\r\v3\CAN[\ENQP\210/\207I\221",PropPayloadFormatIndicator 198,PropMessageExpiryInterval +// 21952,PropRetainAvailable 197,PropSubscriptionIdentifier 29,PropSharedSubscriptionAvailable 82,PropContentType +// "Y\157.\140D\184\133\166\217\214\186`\168\b=\196T",PropReasonString +// "\SYN\EOT\DC1v\189\245\&00Vl\b\145\&6\200\ENQ\228N\155\204\147",PropResponseInformation +// "\224a\143U\206\193\159x\164\b\227\207\SUB\183\193I\183",PropTopicAlias 23073,PropServerKeepAlive +// 17368,PropServerReference "\161\196\235\243a}\172\239M\157y\225z",PropRequestProblemInformation +// 210,PropRequestProblemInformation 50,PropSharedSubscriptionAvailable 108,PropServerKeepAlive +// 21906,PropSubscriptionIdentifier 17]}), _cleanSession = True, _keepAlive = 18446, _connID = +// "\223\DC1\215tI\188[\152", _properties = [PropReasonString +// "\154\149x\231\fWY\160\156\184\140\168\DLE=\128\169\186]1\179",PropSubscriptionIdentifier 1,PropUserProperty +// "S\226\&8\228\&8b5\244\CAN0v\EM\211\t\186\t\132\t\202\DC3^\182\FS\183" +// "\229\159l\240\DLEq8\239\228\254\204\184\SOH\141(\200\170/\\\144\184\ACK\155\146w+\203\179\ENQ\r",PropWillDelayInterval +// 12947,PropUserProperty "#\RSY\240\180\159\238\250PH\155$\234\DC2\158'\ENQ\169f\SO6Gt\214\175r\184" +// "",PropReasonString "x\STX\133n\224\247\138\249t\153\SYN",PropSubscriptionIdentifierAvailable 127,PropUserProperty +// "5\RS\244\224\172\USp\ETX\141(\v\162\146 \ACK\232Ix\152\197\202\171" +// "Jm\143\143r\209\188\183\DLE\198\187}\158\DC4\155f\162\fL\EOT\144\212\221\237\218g",PropResponseTopic +// "\SYNa\168R\188\SUB3\DC1\ACK4\177\156\182\223\243\250\DC1",PropWildcardSubscriptionAvailable +// 38,PropPayloadFormatIndicator 30,PropServerKeepAlive 29748,PropSubscriptionIdentifierAvailable 226,PropUserProperty +// "&\237\191\199\197\&8\177\ACK_\186\ESCa\149\211\134\178^(@K(" +// "\238C\NAK`#\ESCQj\163s\157\213Z7\NUL\RS\DC1\246\208\ESC\ETX\EM\SYN\200\128\SYN\169\a",PropReceiveMaximum +// 2976,PropReasonString "EWM\253p\225=\196\148.\237\ACK\DC3",PropWildcardSubscriptionAvailable 153]} TEST(Connect5QCTest, Encode6) { uint8_t pkt[] = { - 0x10, 0xbc, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x56, 0x5d, 0x9d, 0x2, 0x1c, 0x0, 0x0, 0x17, - 0x9, 0x9, 0x0, 0x9, 0x72, 0xa3, 0x1c, 0x83, 0x5e, 0xcb, 0xab, 0xe4, 0xfb, 0x22, 0x78, 0xac, 0x19, 0x28, 0x8, - 0x0, 0x14, 0x22, 0x67, 0x6d, 0x6a, 0xef, 0xd3, 0x39, 0xdf, 0xab, 0xaf, 0x1e, 0x20, 0x49, 0x30, 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xb3, 0x1c, 0x0, 0x2, 0x1, 0x41, 0x0, 0x1b, 0x39, 0x7e, 0x2c, 0xec, 0xe0, 0x7e, - 0x40, 0xf7, 0x47, 0x7c, 0x5d, 0x20, 0x99, 0xbf, 0x8e, 0x13, 0x7f, 0x17, 0x63, 0x78, 0x7, 0xc0, 0xd3, 0x4, 0x8a, - 0x49, 0x46, 0x0, 0x12, 0x8f, 0x71, 0xc8, 0x3c, 0xd0, 0x4c, 0x48, 0x56, 0xde, 0x48, 0x4f, 0x31, 0xb5, 0x55, 0xe5, - 0xad, 0x9e, 0xff, 0x0, 0x10, 0x7c, 0x5, 0x3, 0x4e, 0xc4, 0x2f, 0x21, 0x32, 0x4, 0x96, 0x77, 0x56, 0x17, 0xcd, - 0x52, 0x0, 0x0, 0xf, 0xab, 0xb0, 0x78, 0xbd, 0x33, 0x49, 0xfa, 0x21, 0xcf, 0x8b, 0x4a, 0x8b, 0xa0, 0x78, 0x16}; - - uint8_t buf[713] = {0}; - - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x72, 0xa3, 0x1c, 0x83, 0x5e, 0xcb, 0xab, 0xe4, 0xfb}; - uint8_t bytesprops2[] = {0x22, 0x67, 0x6d, 0x6a, 0xef, 0xd3, 0x39, 0xdf, 0xab, 0xaf, - 0x1e, 0x20, 0x49, 0x30, 0x88, 0x9a, 0xe9, 0x26, 0x9b, 0xa3}; - uint8_t bytesprops3[] = {0x59, 0x1c, 0x5, 0x5a, 0xf9, 0x73, 0x93, 0x26, 0x48, 0xbc, 0x7c, 0x71, 0x27, - 0x33, 0xec, 0xc1, 0x3f, 0x21, 0xb2, 0xb8, 0x7e, 0x59, 0xa0, 0x94, 0xe3}; - uint8_t bytesprops4[] = {0x97, 0x1c, 0x5a, 0xbd, 0xa1, 0xf9, 0x68, 0x61, 0x11, 0x6c, 0x3, 0xd0, 0x36, 0x65, 0xcb, - 0x72, 0x28, 0xd5, 0x20, 0xf0, 0x39, 0xac, 0x82, 0x40, 0xb5, 0x83, 0xc, 0x49, 0x98}; - uint8_t bytesprops5[] = {0xc3, 0x25}; - uint8_t bytesprops7[] = {0x1f, 0xcc, 0xb9, 0xa4, 0xf3, 0xe4, 0xd1, 0x6, 0x43, 0x9c, 0xf7, 0x7b, 0x8f, 0xf1, - 0x91, 0x87, 0xb4, 0x83, 0x8a, 0xb2, 0xbc, 0x7f, 0x3e, 0xa0, 0x5c, 0x16, 0x31, 0x8b}; - uint8_t bytesprops6[] = {0xa4, 0xf, 0xb7, 0xc6, 0x27, 0x99, 0x6c, 0xdf}; - uint8_t bytesprops8[] = {0x73, 0xac, 0xda, 0xce, 0x4b, 0x9c, 0x69, 0x1d, 0x9a, 0x24, 0x85, 0x4f, 0xae, 0xa0, - 0x20, 0xc7, 0x69, 0xcd, 0xf7, 0x5f, 0x24, 0x25, 0x55, 0x78, 0xaa, 0x4c, 0xcd}; - uint8_t bytesprops9[] = {0xe3, 0x9d, 0xeb, 0xc1, 0x8b, 0x26, 0x22, 0x4c, 0xe7, 0x85}; - uint8_t bytesprops10[] = {0xe3, 0xfe, 0xfb, 0xe3, 0x91, 0x1e, 0xa4, 0x4f, 0x48, 0xd, 0xc8, 0xcc, 0x9e}; - uint8_t bytesprops11[] = {0x86, 0xe0, 0x93, 0xcb, 0x3, 0xbd, 0xb9, 0xbd, 0xb3, - 0xbd, 0x6a, 0x54, 0x94, 0x7c, 0xa5, 0x7e, 0x23}; - uint8_t bytesprops12[] = {0x61, 0xe5, 0xce, 0xa4, 0xc1, 0x4b, 0x0, 0x17, 0x38, 0x94, 0x10, 0xbf, 0xf5}; + 0x10, 0xec, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x48, 0xe, 0xa6, 0x2, 0x1f, 0x0, 0x14, 0x9a, + 0x95, 0x78, 0xe7, 0xc, 0x57, 0x59, 0xa0, 0x9c, 0xb8, 0x8c, 0xa8, 0x10, 0x3d, 0x80, 0xa9, 0xba, 0x5d, 0x31, 0xb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x9f, 0x78, 0xa4, 0x8, 0xe3, 0xcf, + 0x1a, 0xb7, 0xc1, 0x49, 0xb7, 0x23, 0x5a, 0x21, 0x13, 0x43, 0xd8, 0x1c, 0x0, 0xd, 0xa1, 0xc4, 0xeb, 0xf3, 0x61, + 0x7d, 0xac, 0xef, 0x4d, 0x9d, 0x79, 0xe1, 0x7a, 0x17, 0xd2, 0x17, 0x32, 0x2a, 0x6c, 0x13, 0x55, 0x92, 0xb, 0x11, + 0x0, 0xc, 0x56, 0x8c, 0x78, 0x9e, 0xfa, 0x4, 0x3e, 0xf1, 0xf1, 0x94, 0xc7, 0x55, 0x0, 0x17, 0xa4, 0x5b, 0x89, + 0x67, 0x87, 0xf1, 0x49, 0xe9, 0x92, 0xe8, 0xd6, 0xa5, 0xa3, 0xeb, 0x45, 0xa3, 0x76, 0x30, 0x8a, 0x23, 0x13, 0x54, + 0x34}; + + uint8_t buf[505] = {0}; + + uint8_t bytesprops0[] = {0x9a, 0x95, 0x78, 0xe7, 0xc, 0x57, 0x59, 0xa0, 0x9c, 0xb8, + 0x8c, 0xa8, 0x10, 0x3d, 0x80, 0xa9, 0xba, 0x5d, 0x31, 0xb3}; + uint8_t bytesprops2[] = {0xe5, 0x9f, 0x6c, 0xf0, 0x10, 0x71, 0x38, 0xef, 0xe4, 0xfe, 0xcc, 0xb8, 0x1, 0x8d, 0x28, + 0xc8, 0xaa, 0x2f, 0x5c, 0x90, 0xb8, 0x6, 0x9b, 0x92, 0x77, 0x2b, 0xcb, 0xb3, 0x5, 0xd}; + uint8_t bytesprops1[] = {0x53, 0xe2, 0x38, 0xe4, 0x38, 0x62, 0x35, 0xf4, 0x18, 0x30, 0x76, 0x19, + 0xd3, 0x9, 0xba, 0x9, 0x84, 0x9, 0xca, 0x13, 0x5e, 0xb6, 0x1c, 0xb7}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops3[] = {0x23, 0x1e, 0x59, 0xf0, 0xb4, 0x9f, 0xee, 0xfa, 0x50, 0x48, 0x9b, 0x24, 0xea, 0x12, + 0x9e, 0x27, 0x5, 0xa9, 0x66, 0xe, 0x36, 0x47, 0x74, 0xd6, 0xaf, 0x72, 0xb8}; + uint8_t bytesprops5[] = {0x78, 0x2, 0x85, 0x6e, 0xe0, 0xf7, 0x8a, 0xf9, 0x74, 0x99, 0x16}; + uint8_t bytesprops7[] = {0x4a, 0x6d, 0x8f, 0x8f, 0x72, 0xd1, 0xbc, 0xb7, 0x10, 0xc6, 0xbb, 0x7d, 0x9e, + 0x14, 0x9b, 0x66, 0xa2, 0xc, 0x4c, 0x4, 0x90, 0xd4, 0xdd, 0xed, 0xda, 0x67}; + uint8_t bytesprops6[] = {0x35, 0x1e, 0xf4, 0xe0, 0xac, 0x1f, 0x70, 0x3, 0x8d, 0x28, 0xb, + 0xa2, 0x92, 0x20, 0x6, 0xe8, 0x49, 0x78, 0x98, 0xc5, 0xca, 0xab}; + uint8_t bytesprops8[] = {0x16, 0x61, 0xa8, 0x52, 0xbc, 0x1a, 0x33, 0x11, 0x6, + 0x34, 0xb1, 0x9c, 0xb6, 0xdf, 0xf3, 0xfa, 0x11}; + uint8_t bytesprops10[] = {0xee, 0x43, 0x15, 0x60, 0x23, 0x1b, 0x51, 0x6a, 0xa3, 0x73, 0x9d, 0xd5, 0x5a, 0x37, + 0x0, 0x1e, 0x11, 0xf6, 0xd0, 0x1b, 0x3, 0x19, 0x16, 0xc8, 0x80, 0x16, 0xa9, 0x7}; + uint8_t bytesprops9[] = {0x26, 0xed, 0xbf, 0xc7, 0xc5, 0x38, 0xb1, 0x6, 0x5f, 0xba, 0x1b, + 0x61, 0x95, 0xd3, 0x86, 0xb2, 0x5e, 0x28, 0x40, 0x4b, 0x28}; + uint8_t bytesprops11[] = {0x45, 0x57, 0x4d, 0xfd, 0x70, 0xe1, 0x3d, 0xc4, 0x94, 0x2e, 0xed, 0x6, 0x13}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30892}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13591}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25823}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops6}, .v = {28, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18119}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24104}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30786}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12947}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops3}, .v = {0, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops6}, .v = {26, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29748}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops9}, .v = {28, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2976}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 153}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xf2, 0xbf, 0x4b, 0xd3, 0x46, 0xf7, 0x7b, 0xe8, 0x33, 0x31, 0x71, 0x60, 0x64, 0x4a}; - uint8_t byteswillprops0[] = {0x74, 0x1d, 0xac, 0x33, 0xd5, 0xb5, 0xdd, 0x8c}; - uint8_t byteswillprops2[] = {0xb5, 0x39, 0x64, 0xb1, 0xc4, 0x40, 0x24, 0x61, 0x9b, 0x84, 0x45, 0xf7, - 0xb1, 0x7f, 0xd1, 0x9b, 0x16, 0x1, 0x5a, 0xf, 0xa7, 0x9c, 0xd}; - uint8_t byteswillprops3[] = {0xe7, 0x25, 0x2d, 0xc3, 0xcc, 0xa0, 0xe6, 0x82, 0xee, 0x53, 0xb0, 0xbb, 0x80, 0xd6, 0xf7, - 0x2a, 0x66, 0x4e, 0x2e, 0x29, 0x6b, 0x92, 0x43, 0x14, 0x33, 0xb4, 0x21, 0x4f, 0x3b}; - uint8_t byteswillprops4[] = {0xd0, 0xb6, 0x50, 0xd4, 0x22, 0x62, 0x6c, 0xae, 0xe9, 0xb1, 0x2b, 0xf9, 0x4, 0xe6, - 0xad, 0x7, 0xc2, 0x77, 0x9c, 0xfb, 0xa5, 0xf4, 0xc0, 0xe0, 0x12, 0xf2, 0xb4, 0x18}; - uint8_t byteswillprops5[] = {0x16, 0xa8, 0x54, 0x71, 0xff, 0x34, 0xe2, 0xed}; - uint8_t byteswillprops6[] = {0x2b, 0x70, 0xf0, 0x1d, 0xb4, 0x2, 0xeb, 0x62, 0x24}; - uint8_t byteswillprops7[] = {0x47, 0x54, 0x6, 0x56}; - uint8_t byteswillprops8[] = {0xa0, 0x33, 0x21, 0xf, 0xd0, 0x47, 0x4a, 0xe9, 0x99, 0x82, 0xa3, 0xa9, 0xc, 0x18, 0xdd}; - uint8_t byteswillprops9[] = {0xa9, 0x1e, 0x54, 0x9c, 0x7e, 0x2b, 0xfe, 0x15, 0x46, 0xd0, 0xc3, 0x4a, 0x1f, 0x1b, - 0x24, 0xb1, 0xbe, 0x5d, 0xf7, 0xb, 0xa2, 0x99, 0x44, 0x2e, 0x5, 0xaf, 0x88, 0xd6}; - uint8_t byteswillprops10[] = {0x11, 0x1a, 0x32, 0xb3, 0xeb, 0xc4, 0x55, 0xf, 0x69, 0xc4, 0x33, 0xa, 0x5f, 0xea, - 0x13, 0x19, 0x1f, 0x9, 0x28, 0x17, 0xe2, 0x33, 0xe2, 0xd7, 0x84, 0x36, 0xde, 0x0}; - uint8_t byteswillprops11[] = {0x1, 0x41}; + uint8_t byteswillprops0[] = {0xd4, 0xb5, 0x37, 0xb4, 0x10, 0xb5, 0xd, 0xb, 0x33, + 0x18, 0x5b, 0x5, 0x50, 0xd2, 0x2f, 0xcf, 0x49, 0xdd}; + uint8_t byteswillprops1[] = {0x59, 0x9d, 0x2e, 0x8c, 0x44, 0xb8, 0x85, 0xa6, 0xd9, + 0xd6, 0xba, 0x60, 0xa8, 0x8, 0x3d, 0xc4, 0x54}; + uint8_t byteswillprops2[] = {0x16, 0x4, 0x11, 0x76, 0xbd, 0xf5, 0x30, 0x30, 0x56, 0x6c, + 0x8, 0x91, 0x36, 0xc8, 0x5, 0xe4, 0x4e, 0x9b, 0xcc, 0x93}; + uint8_t byteswillprops3[] = {0xe0, 0x61, 0x8f, 0x55, 0xce, 0xc1, 0x9f, 0x78, 0xa4, + 0x8, 0xe3, 0xcf, 0x1a, 0xb7, 0xc1, 0x49, 0xb7}; + uint8_t byteswillprops4[] = {0xa1, 0xc4, 0xeb, 0xf3, 0x61, 0x7d, 0xac, 0xef, 0x4d, 0x9d, 0x79, 0xe1, 0x7a}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22676}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {8, (char*)&byteswillprops0}, .v = {14, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18062}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5758}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32395}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8412}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20741}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 34}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3727}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31448}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12597}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26906}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20356}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29532}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17359}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15547}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 435}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18041}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21952}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23073}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17368}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21906}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, }; - lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x39, 0x7e, 0x2c, 0xec, 0xe0, 0x7e, 0x40, 0xf7, 0x47, 0x7c, 0x5d, 0x20, 0x99, 0xbf, - 0x8e, 0x13, 0x7f, 0x17, 0x63, 0x78, 0x7, 0xc0, 0xd3, 0x4, 0x8a, 0x49, 0x46}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x8f, 0x71, 0xc8, 0x3c, 0xd0, 0x4c, 0x48, 0x56, 0xde, - 0x48, 0x4f, 0x31, 0xb5, 0x55, 0xe5, 0xad, 0x9e, 0xff}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x56, 0x8c, 0x78, 0x9e, 0xfa, 0x4, 0x3e, 0xf1, 0xf1, 0x94, 0xc7, 0x55}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa4, 0x5b, 0x89, 0x67, 0x87, 0xf1, 0x49, 0xe9, 0x92, 0xe8, 0xd6, 0xa5, + 0xa3, 0xeb, 0x45, 0xa3, 0x76, 0x30, 0x8a, 0x23, 0x13, 0x54, 0x34}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -2221,16 +3092,13 @@ TEST(Connect5QCTest, Encode6) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 22109; - uint8_t client_id_bytes[] = {0x14, 0xaa, 0xa2, 0x61, 0xd3, 0xb0, 0x83, 0x3, 0xd0}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.keep_alive = 18446; + uint8_t client_id_bytes[] = {0xdf, 0x11, 0xd7, 0x74, 0x49, 0xbc, 0x5b, 0x98}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x7c, 0x5, 0x3, 0x4e, 0xc4, 0x2f, 0x21, 0x32, - 0x4, 0x96, 0x77, 0x56, 0x17, 0xcd, 0x52, 0x0}; - lwmqtt_string_t username = {16, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xab, 0xb0, 0x78, 0xbd, 0x33, 0x49, 0xfa, 0x21, 0xcf, 0x8b, 0x4a, 0x8b, 0xa0, 0x78, 0x16}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x32, 0xa1, 0xb9, 0x16, 0x50, 0x32, 0x7a, 0x6, 0x30, 0x6c, + 0xba, 0xcb, 0x9b, 0x52, 0x94, 0x1a, 0x58, 0x74, 0xfb, 0xf}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -2239,176 +3107,319 @@ TEST(Connect5QCTest, Encode6) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "$\EM\165\160\SUBJ\a\172X\237g2\r\233#\197H\209G\165\171\255\DEL", _password = Just -// "\EM\190|\164\130", _lastWill = Nothing, _cleanSession = False, _keepAlive = 10212, _connID = "\"{\179:\181", -// _properties = [PropRequestResponseInformation 114,PropCorrelationData "L\166\133\n]g/`\244"]} +// ConnectRequest {_username = Just "\153\228E\255\142\252(L", _password = Just "NP\144 \208\ETB", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "C\192\208T\157\190'\DC3E\153\205\237\208\137\EOT\130\GS\200", _willMsg = "", _willProps = [PropTopicAliasMaximum +// 21421,PropSubscriptionIdentifier 8,PropAssignedClientIdentifier +// "\170\224\142\133\166\207:\SYN",PropMessageExpiryInterval 28506,PropSharedSubscriptionAvailable 21,PropContentType +// "t\143\213\&1:\237",PropRetainAvailable 224,PropReasonString +// "?ua\ETB\232\157g\DEL\GSg\239\139\246A\183\254{i\209]\DC2]\150g\155#\140\&6\171\172",PropMessageExpiryInterval +// 9448,PropSubscriptionIdentifierAvailable 129,PropSharedSubscriptionAvailable 177,PropWillDelayInterval +// 14239,PropWillDelayInterval 29282,PropCorrelationData +// "\130m\182\216,\199\198t\CAN\218\208\&1\178\178",PropMessageExpiryInterval 29362]}), _cleanSession = True, _keepAlive +// = 24334, _connID = "\191\181\157\159\245\202\211", _properties = [PropUserProperty +// ";\152\DLE\194<\195Z\236\167%7R\129\225\146\188\DEL\164" "y\184\250",PropResponseInformation +// "\bi\214\215%\182-{Rn\tu\EMp\213-\193\tc\NAK\226",PropWildcardSubscriptionAvailable 207,PropAuthenticationData +// "\228\ETX\227\172\134\212K~8\DEL\193\DELA\ESC\DC2",PropMaximumQoS 110,PropUserProperty +// "H\222\254\195{\179\254\239>[\198\242\173\204\171h\210b" "\148",PropRetainAvailable 165,PropAuthenticationData +// "\220\130\223\ACKy\ESC\154\254/i\171.\DELt\193\244Z\247A\175kd\228\129J\228",PropMaximumQoS +// 22,PropAssignedClientIdentifier "A\188a7\CAN\DLE\242Z\171\RS\202\169\SOHSJ\134\EM\213;\248",PropResponseTopic +// "\132}\CAN\201\154\139\179\SUB82\237~\129\212",PropAuthenticationData "",PropContentType +// "Gq\237\NAKA\142\199\165\229\154",PropRequestResponseInformation 150,PropUserProperty +// "&\182\241\STX\233\132\228N\148mR\SIH" "",PropAuthenticationMethod "b\250\228!\145\147\190>",PropMaximumPacketSize +// 22973,PropReasonString "\163=\US,\130\139rA\160\ACK\241",PropResponseInformation +// "\194\ti,r\168\213;k\150\227\190\194\215\233\171<\224I\NAK",PropMaximumQoS 166,PropServerReference +// "\246FG\242\128\&9\150\130u`\158\139G\224\ESC\172",PropMaximumPacketSize 24530,PropSubscriptionIdentifier 0]} TEST(Connect5QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x27, 0xe4, 0xe, 0x19, 0x72, 0x9, 0x0, - 0x9, 0x4c, 0xa6, 0x85, 0xa, 0x5d, 0x67, 0x2f, 0x60, 0xf4, 0x0, 0x5, 0x22, 0x7b, 0xb3, 0x3a, 0xb5, - 0x0, 0x17, 0x24, 0x19, 0xa5, 0xa0, 0x1a, 0x4a, 0x7, 0xac, 0x58, 0xed, 0x67, 0x32, 0xd, 0xe9, 0x23, - 0xc5, 0x48, 0xd1, 0x47, 0xa5, 0xab, 0xff, 0x7f, 0x0, 0x5, 0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7b, 0x69, 0xd1, 0x5d, 0x12, 0x5d, 0x96, 0x67, 0x9b, 0x23, 0x8c, 0x36, 0xab, 0xac, 0x2, 0x0, + 0x0, 0x24, 0xe8, 0x29, 0x81, 0x2a, 0xb1, 0x18, 0x0, 0x0, 0x37, 0x9f, 0x18, 0x0, 0x0, 0x72, 0x62, 0x9, 0x0, + 0xe, 0x82, 0x6d, 0xb6, 0xd8, 0x2c, 0xc7, 0xc6, 0x74, 0x18, 0xda, 0xd0, 0x31, 0xb2, 0xb2, 0x2, 0x0, 0x0, 0x72, + 0xb2, 0x0, 0x12, 0x43, 0xc0, 0xd0, 0x54, 0x9d, 0xbe, 0x27, 0x13, 0x45, 0x99, 0xcd, 0xed, 0xd0, 0x89, 0x4, 0x82, + 0x1d, 0xc8, 0x0, 0x0, 0x0, 0x8, 0x99, 0xe4, 0x45, 0xff, 0x8e, 0xfc, 0x28, 0x4c, 0x0, 0x6, 0x4e, 0x50, 0x90, + 0x20, 0xd0, 0x17}; + + uint8_t buf[469] = {0}; + + uint8_t bytesprops1[] = {0x79, 0xb8, 0xfa}; + uint8_t bytesprops0[] = {0x3b, 0x98, 0x10, 0xc2, 0x3c, 0xc3, 0x5a, 0xec, 0xa7, + 0x25, 0x37, 0x52, 0x81, 0xe1, 0x92, 0xbc, 0x7f, 0xa4}; + uint8_t bytesprops2[] = {0x8, 0x69, 0xd6, 0xd7, 0x25, 0xb6, 0x2d, 0x7b, 0x52, 0x6e, 0x9, + 0x75, 0x19, 0x70, 0xd5, 0x2d, 0xc1, 0x9, 0x63, 0x15, 0xe2}; + uint8_t bytesprops3[] = {0xe4, 0x3, 0xe3, 0xac, 0x86, 0xd4, 0x4b, 0x7e, 0x38, 0x7f, 0xc1, 0x7f, 0x41, 0x1b, 0x12}; + uint8_t bytesprops5[] = {0x94}; + uint8_t bytesprops4[] = {0x48, 0xde, 0xfe, 0xc3, 0x7b, 0xb3, 0xfe, 0xef, 0x3e, + 0x5b, 0xc6, 0xf2, 0xad, 0xcc, 0xab, 0x68, 0xd2, 0x62}; + uint8_t bytesprops6[] = {0xdc, 0x82, 0xdf, 0x6, 0x79, 0x1b, 0x9a, 0xfe, 0x2f, 0x69, 0xab, 0x2e, 0x7f, + 0x74, 0xc1, 0xf4, 0x5a, 0xf7, 0x41, 0xaf, 0x6b, 0x64, 0xe4, 0x81, 0x4a, 0xe4}; + uint8_t bytesprops7[] = {0x41, 0xbc, 0x61, 0x37, 0x18, 0x10, 0xf2, 0x5a, 0xab, 0x1e, + 0xca, 0xa9, 0x1, 0x53, 0x4a, 0x86, 0x19, 0xd5, 0x3b, 0xf8}; + uint8_t bytesprops8[] = {0x84, 0x7d, 0x18, 0xc9, 0x9a, 0x8b, 0xb3, 0x1a, 0x38, 0x32, 0xed, 0x7e, 0x81, 0xd4}; + uint8_t bytesprops9[] = {0}; + uint8_t bytesprops10[] = {0x47, 0x71, 0xed, 0x15, 0x41, 0x8e, 0xc7, 0xa5, 0xe5, 0x9a}; + uint8_t bytesprops12[] = {0}; + uint8_t bytesprops11[] = {0x26, 0xb6, 0xf1, 0x2, 0xe9, 0x84, 0xe4, 0x4e, 0x94, 0x6d, 0x52, 0xf, 0x48}; + uint8_t bytesprops13[] = {0x62, 0xfa, 0xe4, 0x21, 0x91, 0x93, 0xbe, 0x3e}; + uint8_t bytesprops14[] = {0xa3, 0x3d, 0x1f, 0x2c, 0x82, 0x8b, 0x72, 0x41, 0xa0, 0x6, 0xf1}; + uint8_t bytesprops15[] = {0xc2, 0x9, 0x69, 0x2c, 0x72, 0xa8, 0xd5, 0x3b, 0x6b, 0x96, + 0xe3, 0xbe, 0xc2, 0xd7, 0xe9, 0xab, 0x3c, 0xe0, 0x49, 0x15}; + uint8_t bytesprops16[] = {0xf6, 0x46, 0x47, 0xf2, 0x80, 0x39, 0x96, 0x82, + 0x75, 0x60, 0x9e, 0x8b, 0x47, 0xe0, 0x1b, 0xac}; - uint8_t buf[76] = {0}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops0}, .v = {3, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops4}, .v = {1, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops11}, .v = {0, (char*)&bytesprops12}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22973}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops16}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24530}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + }; - uint8_t bytesprops0[] = {0x4c, 0xa6, 0x85, 0xa, 0x5d, 0x67, 0x2f, 0x60, 0xf4}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xaa, 0xe0, 0x8e, 0x85, 0xa6, 0xcf, 0x3a, 0x16}; + uint8_t byteswillprops1[] = {0x74, 0x8f, 0xd5, 0x31, 0x3a, 0xed}; + uint8_t byteswillprops2[] = {0x3f, 0x75, 0x61, 0x17, 0xe8, 0x9d, 0x67, 0x7f, 0x1d, 0x67, + 0xef, 0x8b, 0xf6, 0x41, 0xb7, 0xfe, 0x7b, 0x69, 0xd1, 0x5d, + 0x12, 0x5d, 0x96, 0x67, 0x9b, 0x23, 0x8c, 0x36, 0xab, 0xac}; + uint8_t byteswillprops3[] = {0x82, 0x6d, 0xb6, 0xd8, 0x2c, 0xc7, 0xc6, 0x74, 0x18, 0xda, 0xd0, 0x31, 0xb2, 0xb2}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops0}}}, + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21421}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28506}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9448}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14239}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29282}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29362}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x43, 0xc0, 0xd0, 0x54, 0x9d, 0xbe, 0x27, 0x13, 0x45, + 0x99, 0xcd, 0xed, 0xd0, 0x89, 0x4, 0x82, 0x1d, 0xc8}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 10212; - uint8_t client_id_bytes[] = {0x22, 0x7b, 0xb3, 0x3a, 0xb5}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 24334; + uint8_t client_id_bytes[] = {0xbf, 0xb5, 0x9d, 0x9f, 0xf5, 0xca, 0xd3}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x24, 0x19, 0xa5, 0xa0, 0x1a, 0x4a, 0x7, 0xac, 0x58, 0xed, 0x67, 0x32, - 0xd, 0xe9, 0x23, 0xc5, 0x48, 0xd1, 0x47, 0xa5, 0xab, 0xff, 0x7f}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x99, 0xe4, 0x45, 0xff, 0x8e, 0xfc, 0x28, 0x4c}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x19, 0xbe, 0x7c, 0xa4, 0x82}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x4e, 0x50, 0x90, 0x20, 0xd0, 0x17}; + lwmqtt_string_t password = {6, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\152\195~\228&V\199\194\ESC\206\154", _password = Just -// "ve\174\255\183:\192\165\&3\171\241\187+\DEL\209\"\248\224\186\154", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS1, _willTopic = "\162\193N\246G", _willMsg = "\193\226\183\237\166\202\233", _willProps = -// [PropServerReference "%P\DC3\242\SI \147\v\164\140:=\246\178$",PropReceiveMaximum -// 23397,PropWildcardSubscriptionAvailable 190,PropSessionExpiryInterval 31340,PropRetainAvailable -// 201,PropWildcardSubscriptionAvailable 101,PropAssignedClientIdentifier -// "\180\140\GS\EM\189\227\242v\200\CAN\201\152\243\144\141\158\&2\143\155t\206\&8{|"]}), _cleanSession = False, -// _keepAlive = 16879, _connID = "", _properties = [PropTopicAliasMaximum 26905,PropResponseTopic -// "\ETXr\195\163#\207C\193\194\249\&7\239\160\155\STX\138\182\141nl\138\224",PropAuthenticationMethod -// "v\200\207\&5\ACK%\203\225^\DLE\DC1?R\186\t\209i",PropPayloadFormatIndicator 12,PropMaximumQoS -// 27,PropAuthenticationData "\255r\171bm0q8>\ESCQ\128\193\243\236\198K\221\152",PropSessionExpiryInterval -// 18432,PropRetainAvailable 60,PropSharedSubscriptionAvailable 200,PropSubscriptionIdentifier 20,PropMaximumPacketSize -// 19861,PropMaximumQoS 189,PropServerKeepAlive 18916,PropResponseTopic -// "\153\189\238U\240f\201\251\130\RS\247\167\152.?\RSz\241\164g'[c\181!\140\&2\133",PropResponseInformation -// "W-=I\247(\235 8X\209\224\239o\196M\134\157\232\SYN\145\153\141ri\130PI\158a",PropSessionExpiryInterval -// 29328,PropUserProperty "" "\230",PropAuthenticationMethod -// "\\\253\\\152\SI\194\ESC\218\207\182l\ENQ\193.\248K",PropMaximumQoS 134,PropMaximumPacketSize -// 22187,PropRetainAvailable 16,PropMessageExpiryInterval 23463,PropRequestResponseInformation -// 242,PropResponseInformation "E\208\DC4\160\137\135\v3\197\181\130\GS\SYN\b8\ENQ\n",PropReceiveMaximum -// 14612,PropWildcardSubscriptionAvailable 72,PropReceiveMaximum 8504]} +// ConnectRequest {_username = Just "\166B\SO^~\248\144\152\224\232\161\186", _password = Just "s\130\248.\129\v\222", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\b8\n\140)k\ESC\v", _willMsg = +// "$\173\176\USm\202h\211\254\147\r\241c\217", _willProps = [PropMessageExpiryInterval 1361,PropAuthenticationData +// "\153\193xr\243\DC2\204\255\168s\a\231h",PropAssignedClientIdentifier +// "\171+[\192\146H\229M\">U\186\192\249\n\ETX\231z\213\140\166\147K\"m\157\217S\204\&3",PropMaximumQoS +// 203,PropSubscriptionIdentifierAvailable 178,PropAuthenticationData +// "\224\209\233\158~O\217Y\241I\130c\253N\163\r\229`\f\182O\231Y\r\157\236\165\246\161F",PropUserProperty +// "e0\DC1\137\225\252+/\183p\216\255M\189z\134\&3&\140;\198\255bt\236w" +// "\219\&8y\206\EM\ETBO\207\a\173\195%\195\ETB\219\SOHb^*e\129k\161R\211\SYN",PropSessionExpiryInterval +// 3244,PropReasonString "\167\SI\180w\230~\140[\237\139\"\246|\142\173\225Z\223\208\160\209Ga\151\f",PropReasonString +// "g\216\159\185\220V",PropCorrelationData +// "_\153\STX\b1b#4\NUL\CAN\222\185,G\206\228\&9\128\231\&3\200GtW\165\222\\\135\219)",PropRetainAvailable +// 241,PropWillDelayInterval 22307,PropAssignedClientIdentifier +// "|\152\214\141\151/\187\189\FS\DEL",PropPayloadFormatIndicator 179,PropUserProperty "\252\203" +// "D\137\NUL\218\239;\SYNC\208\148\155\192[JHW \185i\159Q",PropContentType +// "\192\150|\185y\167\235\128\219\DC1\235\149\FSW1\208\243\210\227W\228\165\240 \223)@&\149",PropAuthenticationMethod +// "\CAN\247}\160\153\154\"\DC3/\179J\t\DELWV_\237m\141\170e\141\&0pkf\209{\130",PropMaximumPacketSize +// 7609,PropTopicAliasMaximum 12535,PropRetainAvailable 122,PropResponseInformation +// "C\151\199\249\131\151o\176\132pp\167aK\173\190\SOP\240\180z\STX\178\NAKz\232L\156",PropPayloadFormatIndicator +// 195,PropServerReference "\134\FSl\ETB\US\232",PropAuthenticationData +// "?I\ESC\143\USB\167\171d\DC31\172-N\240\&8P\176\253\ETB\131\230\204DS\DEL0\129_:",PropWillDelayInterval +// 29716,PropSubscriptionIdentifier 18]}), _cleanSession = True, _keepAlive = 11162, _connID = +// "\\\NUL\237\211\216\199\228=\232-\185\&9^/Qf\251L", _properties = [PropSubscriptionIdentifier 4]} TEST(Connect5QCTest, Encode8) { uint8_t pkt[] = { - 0x10, 0xe6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x41, 0xef, 0xe9, 0x1, 0x22, 0x69, 0x19, 0x8, - 0x0, 0x16, 0x3, 0x72, 0xc3, 0xa3, 0x23, 0xcf, 0x43, 0xc1, 0xc2, 0xf9, 0x37, 0xef, 0xa0, 0x9b, 0x2, 0x8a, 0xb6, - 0x8d, 0x6e, 0x6c, 0x8a, 0xe0, 0x15, 0x0, 0x11, 0x76, 0xc8, 0xcf, 0x35, 0x6, 0x25, 0xcb, 0xe1, 0x5e, 0x10, 0x11, - 0x3f, 0x52, 0xba, 0x9, 0xd1, 0x69, 0x1, 0xc, 0x24, 0x1b, 0x16, 0x0, 0x13,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f, 0x20, 0x93, 0xb, 0xa4, 0x8c, 0x3a, 0x3d, - 0xf6, 0xb2, 0x24, 0x21, 0x5b, 0x65, 0x28, 0xbe, 0x11, 0x0, 0x0, 0x7a, 0x6c, 0x25, 0xc9, 0x28, 0x65, 0x12, 0x0, - 0x18, 0xb4, 0x8c, 0x1d, 0x19, 0xbd, 0xe3, 0xf2, 0x76, 0xc8, 0x18, 0xc9, 0x98, 0xf3, 0x90, 0x8d, 0x9e, 0x32, 0x8f, - 0x9b, 0x74, 0xce, 0x38, 0x7b, 0x7c, 0x0, 0x5, 0xa2, 0xc1, 0x4e, 0xf6, 0x47, 0x0, 0x7, 0xc1, 0xe2, 0xb7, 0xed, - 0xa6, 0xca, 0xe9, 0x0, 0xb, 0x98, 0xc3, 0x7e, 0xe4, 0x26, 0x56, 0xc7, 0xc2, 0x1b, 0xce, 0x9a, 0x0, 0x14, 0x76, - 0x65, 0xae, 0xff, 0xb7, 0x3a, 0xc0, 0xa5, 0x33, 0xab, 0xf1, 0xbb, 0x2b, 0x7f, 0xd1, 0x22, 0xf8, 0xe0, 0xba, 0x9a}; - - uint8_t buf[371] = {0}; - - uint8_t bytesprops0[] = {0x3, 0x72, 0xc3, 0xa3, 0x23, 0xcf, 0x43, 0xc1, 0xc2, 0xf9, 0x37, - 0xef, 0xa0, 0x9b, 0x2, 0x8a, 0xb6, 0x8d, 0x6e, 0x6c, 0x8a, 0xe0}; - uint8_t bytesprops1[] = {0x76, 0xc8, 0xcf, 0x35, 0x6, 0x25, 0xcb, 0xe1, 0x5e, - 0x10, 0x11, 0x3f, 0x52, 0xba, 0x9, 0xd1, 0x69}; - uint8_t bytesprops2[] = {0xff, 0x72, 0xab, 0x62, 0x6d, 0x30, 0x71, 0x38, 0x3e, 0x1b, - 0x51, 0x80, 0xc1, 0xf3, 0xec, 0xc6, 0x4b, 0xdd, 0x98}; - uint8_t bytesprops3[] = {0x99, 0xbd, 0xee, 0x55, 0xf0, 0x66, 0xc9, 0xfb, 0x82, 0x1e, 0xf7, 0xa7, 0x98, 0x2e, - 0x3f, 0x1e, 0x7a, 0xf1, 0xa4, 0x67, 0x27, 0x5b, 0x63, 0xb5, 0x21, 0x8c, 0x32, 0x85}; - uint8_t bytesprops4[] = {0x57, 0x2d, 0x3d, 0x49, 0xf7, 0x28, 0xeb, 0x20, 0x38, 0x58, 0xd1, 0xe0, 0xef, 0x6f, 0xc4, - 0x4d, 0x86, 0x9d, 0xe8, 0x16, 0x91, 0x99, 0x8d, 0x72, 0x69, 0x82, 0x50, 0x49, 0x9e, 0x61}; - uint8_t bytesprops6[] = {0xe6}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops7[] = {0x5c, 0xfd, 0x5c, 0x98, 0xf, 0xc2, 0x1b, 0xda, - 0xcf, 0xb6, 0x6c, 0x5, 0xc1, 0x2e, 0xf8, 0x4b}; - uint8_t bytesprops8[] = {0x45, 0xd0, 0x14, 0xa0, 0x89, 0x87, 0xb, 0x33, 0xc5, - 0xb5, 0x82, 0x1d, 0x16, 0x8, 0x38, 0x5, 0xa}; + 0x10, 0x81, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x2b, 0x9a, 0x2, 0xb, 0x4, 0x0, 0x12, 0x5c, + 0x0, 0xed, 0xd3, 0xd8, 0xc7, 0xe4, 0x3d, 0xe8, 0x2d, 0xb9, 0x39, 0x5e, 0x2f, 0x51, 0x66, 0xfb, 0x4c, 0xad, 0x3, + 0x2, 0x0, 0x0, 0x5, 0x51, 0x16, 0x0, 0xd, 0x99, 0xc1, 0x78, 0x72, 0xf3, 0x12, 0xcc, 0xff, 0xa8, 0x73, 0x7, + 0xe7, 0x68, 0x12, 0x0, 0x1e, 0xab, 0x2b, 0x5b, 0xc0, 0x92, 0x48, 0xe5, 0x4d, 0x22, 0x3e, 0x55, 0xba, 0xc0, 0xf9, + 0xa, 0x3, 0xe7, 0x7a, 0xd5, 0x8c, 0xa6, 0x93, 0x4b, 0x22, 0x6d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 0x81, 0x5f, 0x3a, 0x18, 0x0, 0x0, 0x74, 0x14, 0xb, 0x12, 0x0, 0x8, 0x8, 0x38, 0xa, 0x8c, 0x29, 0x6b, + 0x1b, 0xb, 0x0, 0xe, 0x24, 0xad, 0xb0, 0x1f, 0x6d, 0xca, 0x68, 0xd3, 0xfe, 0x93, 0xd, 0xf1, 0x63, 0xd9, 0x0, + 0xc, 0xa6, 0x42, 0xe, 0x5e, 0x7e, 0xf8, 0x90, 0x98, 0xe0, 0xe8, 0xa1, 0xba, 0x0, 0x7, 0x73, 0x82, 0xf8, 0x2e, + 0x81, 0xb, 0xde}; + + uint8_t buf[526] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26905}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18432}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19861}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18916}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29328}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops5}, .v = {1, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22187}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23463}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14612}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8504}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x25, 0x50, 0x13, 0xf2, 0xf, 0x20, 0x93, 0xb, 0xa4, 0x8c, 0x3a, 0x3d, 0xf6, 0xb2, 0x24}; - uint8_t byteswillprops1[] = {0xb4, 0x8c, 0x1d, 0x19, 0xbd, 0xe3, 0xf2, 0x76, 0xc8, 0x18, 0xc9, 0x98, - 0xf3, 0x90, 0x8d, 0x9e, 0x32, 0x8f, 0x9b, 0x74, 0xce, 0x38, 0x7b, 0x7c}; + uint8_t byteswillprops0[] = {0x99, 0xc1, 0x78, 0x72, 0xf3, 0x12, 0xcc, 0xff, 0xa8, 0x73, 0x7, 0xe7, 0x68}; + uint8_t byteswillprops1[] = {0xab, 0x2b, 0x5b, 0xc0, 0x92, 0x48, 0xe5, 0x4d, 0x22, 0x3e, + 0x55, 0xba, 0xc0, 0xf9, 0xa, 0x3, 0xe7, 0x7a, 0xd5, 0x8c, + 0xa6, 0x93, 0x4b, 0x22, 0x6d, 0x9d, 0xd9, 0x53, 0xcc, 0x33}; + uint8_t byteswillprops2[] = {0xe0, 0xd1, 0xe9, 0x9e, 0x7e, 0x4f, 0xd9, 0x59, 0xf1, 0x49, + 0x82, 0x63, 0xfd, 0x4e, 0xa3, 0xd, 0xe5, 0x60, 0xc, 0xb6, + 0x4f, 0xe7, 0x59, 0xd, 0x9d, 0xec, 0xa5, 0xf6, 0xa1, 0x46}; + uint8_t byteswillprops4[] = {0xdb, 0x38, 0x79, 0xce, 0x19, 0x17, 0x4f, 0xcf, 0x7, 0xad, 0xc3, 0x25, 0xc3, + 0x17, 0xdb, 0x1, 0x62, 0x5e, 0x2a, 0x65, 0x81, 0x6b, 0xa1, 0x52, 0xd3, 0x16}; + uint8_t byteswillprops3[] = {0x65, 0x30, 0x11, 0x89, 0xe1, 0xfc, 0x2b, 0x2f, 0xb7, 0x70, 0xd8, 0xff, 0x4d, + 0xbd, 0x7a, 0x86, 0x33, 0x26, 0x8c, 0x3b, 0xc6, 0xff, 0x62, 0x74, 0xec, 0x77}; + uint8_t byteswillprops5[] = {0xa7, 0xf, 0xb4, 0x77, 0xe6, 0x7e, 0x8c, 0x5b, 0xed, 0x8b, 0x22, 0xf6, 0x7c, + 0x8e, 0xad, 0xe1, 0x5a, 0xdf, 0xd0, 0xa0, 0xd1, 0x47, 0x61, 0x97, 0xc}; + uint8_t byteswillprops6[] = {0x67, 0xd8, 0x9f, 0xb9, 0xdc, 0x56}; + uint8_t byteswillprops7[] = {0x5f, 0x99, 0x2, 0x8, 0x31, 0x62, 0x23, 0x34, 0x0, 0x18, + 0xde, 0xb9, 0x2c, 0x47, 0xce, 0xe4, 0x39, 0x80, 0xe7, 0x33, + 0xc8, 0x47, 0x74, 0x57, 0xa5, 0xde, 0x5c, 0x87, 0xdb, 0x29}; + uint8_t byteswillprops8[] = {0x7c, 0x98, 0xd6, 0x8d, 0x97, 0x2f, 0xbb, 0xbd, 0x1c, 0x7f}; + uint8_t byteswillprops10[] = {0x44, 0x89, 0x0, 0xda, 0xef, 0x3b, 0x16, 0x43, 0xd0, 0x94, 0x9b, + 0xc0, 0x5b, 0x4a, 0x48, 0x57, 0x20, 0xb9, 0x69, 0x9f, 0x51}; + uint8_t byteswillprops9[] = {0xfc, 0xcb}; + uint8_t byteswillprops11[] = {0xc0, 0x96, 0x7c, 0xb9, 0x79, 0xa7, 0xeb, 0x80, 0xdb, 0x11, + 0xeb, 0x95, 0x1c, 0x57, 0x31, 0xd0, 0xf3, 0xd2, 0xe3, 0x57, + 0xe4, 0xa5, 0xf0, 0x20, 0xdf, 0x29, 0x40, 0x26, 0x95}; + uint8_t byteswillprops12[] = {0x18, 0xf7, 0x7d, 0xa0, 0x99, 0x9a, 0x22, 0x13, 0x2f, 0xb3, + 0x4a, 0x9, 0x7f, 0x57, 0x56, 0x5f, 0xed, 0x6d, 0x8d, 0xaa, + 0x65, 0x8d, 0x30, 0x70, 0x6b, 0x66, 0xd1, 0x7b, 0x82}; + uint8_t byteswillprops13[] = {0x43, 0x97, 0xc7, 0xf9, 0x83, 0x97, 0x6f, 0xb0, 0x84, 0x70, 0x70, 0xa7, 0x61, 0x4b, + 0xad, 0xbe, 0xe, 0x50, 0xf0, 0xb4, 0x7a, 0x2, 0xb2, 0x15, 0x7a, 0xe8, 0x4c, 0x9c}; + uint8_t byteswillprops14[] = {0x86, 0x1c, 0x6c, 0x17, 0x1f, 0xe8}; + uint8_t byteswillprops15[] = {0x3f, 0x49, 0x1b, 0x8f, 0x1f, 0x42, 0xa7, 0xab, 0x64, 0x13, + 0x31, 0xac, 0x2d, 0x4e, 0xf0, 0x38, 0x50, 0xb0, 0xfd, 0x17, + 0x83, 0xe6, 0xcc, 0x44, 0x53, 0x7f, 0x30, 0x81, 0x5f, 0x3a}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23397}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31340}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1361}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {26, (char*)&byteswillprops3}, .v = {26, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3244}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22307}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {2, (char*)&byteswillprops9}, .v = {21, (char*)&byteswillprops10}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&byteswillprops12}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7609}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12535}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&byteswillprops13}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&byteswillprops14}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops15}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29716}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, }; - lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa2, 0xc1, 0x4e, 0xf6, 0x47}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc1, 0xe2, 0xb7, 0xed, 0xa6, 0xca, 0xe9}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8, 0x38, 0xa, 0x8c, 0x29, 0x6b, 0x1b, 0xb}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x24, 0xad, 0xb0, 0x1f, 0x6d, 0xca, 0x68, 0xd3, 0xfe, 0x93, 0xd, 0xf1, 0x63, 0xd9}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 16879; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 11162; + uint8_t client_id_bytes[] = {0x5c, 0x0, 0xed, 0xd3, 0xd8, 0xc7, 0xe4, 0x3d, 0xe8, + 0x2d, 0xb9, 0x39, 0x5e, 0x2f, 0x51, 0x66, 0xfb, 0x4c}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x98, 0xc3, 0x7e, 0xe4, 0x26, 0x56, 0xc7, 0xc2, 0x1b, 0xce, 0x9a}; - lwmqtt_string_t username = {11, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa6, 0x42, 0xe, 0x5e, 0x7e, 0xf8, 0x90, 0x98, 0xe0, 0xe8, 0xa1, 0xba}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x76, 0x65, 0xae, 0xff, 0xb7, 0x3a, 0xc0, 0xa5, 0x33, 0xab, - 0xf1, 0xbb, 0x2b, 0x7f, 0xd1, 0x22, 0xf8, 0xe0, 0xba, 0x9a}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x73, 0x82, 0xf8, 0x2e, 0x81, 0xb, 0xde}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -2417,175 +3428,96 @@ TEST(Connect5QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "\242\220\SUB\204\v-\136\211/\218\DC2\243\158]\190\165\251\150H\238\200\DC2\152\245U\202\NULf\153", _password = Just -// "\161\v@\t\155\233WB", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "\222v\195\252\243\159p\129\STX\218r\STX\ESCm\242\201\193\&6X\191h\206\233\210x\134d\170\f", _willMsg = -// "\DC2Bm\152\DLE\140\SO\236*\150\134\134m\195I\140\tMpG\v\199\138'\230\242\227\247m\202", _willProps = -// [PropReceiveMaximum 23059,PropWillDelayInterval 22019,PropContentType -// "\250\"\SI\252\ETX!s\bqK\197g2\204\142~M2\155F\NAK",PropWillDelayInterval 21909,PropRequestProblemInformation -// 21,PropAuthenticationData "\STX@R\EOT\150#m\SO\184\245B\196=O",PropMessageExpiryInterval 17248,PropCorrelationData -// "\195G\209x\242o\204pR%\152\243'\244\210MF\nd+U\183I",PropAuthenticationData -// "\221\214+\237\ETX\"\198\217\DC2\231\183\156\210\CANi\228:\137\EOT\233wn\208\ACK\207\ETX8,",PropWildcardSubscriptionAvailable -// 191,PropMaximumQoS 176,PropAuthenticationData -// "\186\210\159\\A\140\212)h\190\240\205dTF\190\\B\228\ETB\139\173\244\132\168\n(\143c",PropSubscriptionIdentifierAvailable -// 178,PropMessageExpiryInterval 30219,PropTopicAliasMaximum 938]}), _cleanSession = True, _keepAlive = 9102, _connID = -// "\234B\EOT\247\247W\194\222\nP\131)&?\226\&0X\209p\ESC\177z\201\SOt\131g(\215W", _properties = -// [PropPayloadFormatIndicator 87,PropContentType "\ETX\136\218.\199\146\ACK\"\154.a\247>VX",PropCorrelationData -// "\SOH\213\167\169\140\SOH\ESC\209\191\199g\174D\197\252\183o\SUB\143\227Nn\r!b\182",PropTopicAliasMaximum -// 4141,PropSubscriptionIdentifier 2,PropMaximumQoS 103,PropMaximumPacketSize 26526,PropSharedSubscriptionAvailable -// 64,PropTopicAlias 530,PropAssignedClientIdentifier "\NUL\218g\RS",PropSubscriptionIdentifierAvailable -// 120,PropSessionExpiryInterval 18660,PropAuthenticationData -// "4\208\STX\247Z\226w\182\132",PropSubscriptionIdentifierAvailable 190,PropSessionExpiryInterval -// 8586,PropResponseTopic -// "\183\&4\169K*U\SO{\155\181.\137\215j\154\\\203\179\252\&042g\SUB\f\a\153",PropMaximumPacketSize -// 364,PropRetainAvailable 110,PropResponseTopic "\230\ENQyA\t\128\221+",PropAuthenticationData -// "kRr\164\251\193\203\251c\244{P\ENQ\182\238\206~\179\238\US\159",PropCorrelationData -// "\207\222\198\DC2\163r\129&\145\244\197]\156\192\215!",PropRetainAvailable 87,PropReasonString "o -// \US0\204\136~\188\vl1\a\237",PropAuthenticationData -// "\249\SO\189\DC1Z\DELL\235\161\191\220|\222/\219kL\156n+\CAN\230\162l\231^s\207",PropCorrelationData -// "\246Tp\163&O\201\224TS\151\SUBU/P\227\ETB\152\234\255.5\148\235\&1\138\220\156\172\154",PropServerReference -// "\152\153q2X\ENQ\200\218\221X\217}\212\246\227\&0<@\217\SI\142",PropResponseInformation -// "d6\219d1\159\DC3\202GyEn",PropRequestProblemInformation 234,PropUserProperty "\213]&\138\232ID\159\238o\178#k%P\151" -// "%\132\DC2y\142\216\171%\248~\252\165~\r\171\RSp\229\192-\225\236\SYN&X\US"]} +// ConnectRequest {_username = Just "}\195VI\SUBP\166\207\141<\140\203\164\224Z", _password = Just +// "\239\US\GSs(\139lq\152'\206\238\DC3(f\172P\GS\152\130\235K\NUL\234", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS0, _willTopic = "O1\SYN\218\151&\229\155j\237\DLEF\143\216\232a\189\195\226\142", _willMsg = +// "\178\165\170\181(-\248\204\DLE\230jKY\EOT>\EM>", _willProps = [PropReceiveMaximum 3726,PropRequestProblemInformation +// 170,PropCorrelationData +// "d\142\&3\202p\217\210\153\129ZP\207v\139\242\204F\135\f\187\131\153\204\187\156\225#\144",PropTopicAlias +// 31770,PropSessionExpiryInterval 29169,PropMessageExpiryInterval 6570,PropTopicAliasMaximum +// 11129,PropSessionExpiryInterval 12415,PropRetainAvailable 45,PropAssignedClientIdentifier "",PropReasonString +// "",PropReasonString +// "\EOT\240`\164\DC3\DLE\169\173@\159\194X\203\168R.\218\ENQ\US\247\&3?\252\&8fB\165",PropWillDelayInterval +// 24015,PropReceiveMaximum 31266,PropReasonString +// "\192\226\149\129\254\201dc\fg\177\179\DC2\RS\DC3.\CAN\230\217\170\164\178\174",PropServerKeepAlive 3690]}), +// _cleanSession = False, _keepAlive = 21561, _connID = "X\167X\244/`\v\181e#h\159\179\219;Q\173\v\134\181+\149\190xs", +// _properties = [PropMaximumPacketSize 9684,PropMaximumQoS 94,PropAssignedClientIdentifier +// "\163\215w?\166\EM\205dI?\147\&7\136\168",PropMessageExpiryInterval 13352,PropCorrelationData +// "I\181\231\181\185\136\221\150\213\&2\164-\179\ESC",PropTopicAliasMaximum 13292,PropSubscriptionIdentifier +// 6,PropTopicAlias 17975]} TEST(Connect5QCTest, Encode9) { uint8_t pkt[] = { - 0x10, 0xa2, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x23, 0x8e, 0xe8, 0x2, 0x1, 0x57, 0x3, 0x0, - 0xf, 0x3, 0x88, 0xda, 0x2e, 0xc7, 0x92, 0x6, 0x22, 0x9a, 0x2e, 0x61, 0xf7, 0x3e, 0x56, 0x58, 0x9, 0x0, 0x1a, - 0x1, 0xd5, 0xa7, 0xa9, 0x8c, 0x1, 0x1b, 0xd1, 0xbf, 0xc7, 0x67, 0xae, 0x44, 0xc5, 0xfc, 0xb7, 0x6f, 0x1a, 0x8f, - 0xe3, 0x4e, 0x6e, 0xd, 0x21, 0x62, 0xb6, 0x22, 0x10, 0x2d, 0xb, 0x2, 0x24, 0x67, 0x27, 0x0, 0x0, 0x67, 0x9e, - 0x2a, 0x40, 0x23, 0x2, 0x12, 0x12, 0x0, 0x4, 0x0, 0xda, 0x67, 0x1e, 0x29, 0x78, 0x11, 0x0, 0x0, 0x48, 0xe4, - 0x16, 0x0, 0x9, 0x34, 0xd0, 0x2, 0xf7, 0x5a, 0xe2, 0x77, 0xb6, 0x84, 0x29, 0xbe, 0x11, 0x0, 0x0, 0x21, 0x8a, - 0x8, 0x0, 0x1b, 0xb7, 0x34, 0xa9, 0x4b, 0x2a, 0x55, 0xe, 0x7b, 0x9b, 0xb5, 0x2e, 0x89, 0xd7, 0x6a, 0x9a, 0x5c, - 0xcb, 0xb3, 0xfc, 0x30, 0x34, 0x32, 0x67, 0x1a, 0xc, 0x7, 0x99, 0x27, 0x0,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 0x77, 0x6e, 0xd0, 0x6, 0xcf, 0x3, 0x38, 0x2c, 0x28, 0xbf, 0x24, 0xb0, 0x16, - 0x0, 0x1d, 0xba, 0xd2, 0x9f, 0x5c, 0x41, 0x8c, 0xd4, 0x29, 0x68, 0xbe, 0xf0, 0xcd, 0x64, 0x54, 0x46, 0xbe, 0x5c, - 0x42, 0xe4, 0x17, 0x8b, 0xad, 0xf4, 0x84, 0xa8, 0xa, 0x28, 0x8f, 0x63, 0x29, 0xb2, 0x2, 0x0, 0x0, 0x76, 0xb, - 0x22, 0x3, 0xaa, 0x0, 0x1d, 0xde, 0x76, 0xc3, 0xfc, 0xf3, 0x9f, 0x70, 0x81, 0x2, 0xda, 0x72, 0x2, 0x1b, 0x6d, - 0xf2, 0xc9, 0xc1, 0x36, 0x58, 0xbf, 0x68, 0xce, 0xe9, 0xd2, 0x78, 0x86, 0x64, 0xaa, 0xc, 0x0, 0x1e, 0x12, 0x42, - 0x6d, 0x98, 0x10, 0x8c, 0xe, 0xec, 0x2a, 0x96, 0x86, 0x86, 0x6d, 0xc3, 0x49, 0x8c, 0x9, 0x4d, 0x70, 0x47, 0xb, - 0xc7, 0x8a, 0x27, 0xe6, 0xf2, 0xe3, 0xf7, 0x6d, 0xca, 0x0, 0x1d, 0xf2, 0xdc, 0x1a, 0xcc, 0xb, 0x2d, 0x88, 0xd3, - 0x2f, 0xda, 0x12, 0xf3, 0x9e, 0x5d, 0xbe, 0xa5, 0xfb, 0x96, 0x48, 0xee, 0xc8, 0x12, 0x98, 0xf5, 0x55, 0xca, 0x0, - 0x66, 0x99, 0x0, 0x8, 0xa1, 0xb, 0x40, 0x9, 0x9b, 0xe9, 0x57, 0x42}; - - uint8_t buf[687] = {0}; - - uint8_t bytesprops0[] = {0x3, 0x88, 0xda, 0x2e, 0xc7, 0x92, 0x6, 0x22, 0x9a, 0x2e, 0x61, 0xf7, 0x3e, 0x56, 0x58}; - uint8_t bytesprops1[] = {0x1, 0xd5, 0xa7, 0xa9, 0x8c, 0x1, 0x1b, 0xd1, 0xbf, 0xc7, 0x67, 0xae, 0x44, - 0xc5, 0xfc, 0xb7, 0x6f, 0x1a, 0x8f, 0xe3, 0x4e, 0x6e, 0xd, 0x21, 0x62, 0xb6}; - uint8_t bytesprops2[] = {0x0, 0xda, 0x67, 0x1e}; - uint8_t bytesprops3[] = {0x34, 0xd0, 0x2, 0xf7, 0x5a, 0xe2, 0x77, 0xb6, 0x84}; - uint8_t bytesprops4[] = {0xb7, 0x34, 0xa9, 0x4b, 0x2a, 0x55, 0xe, 0x7b, 0x9b, 0xb5, 0x2e, 0x89, 0xd7, 0x6a, - 0x9a, 0x5c, 0xcb, 0xb3, 0xfc, 0x30, 0x34, 0x32, 0x67, 0x1a, 0xc, 0x7, 0x99}; - uint8_t bytesprops5[] = {0xe6, 0x5, 0x79, 0x41, 0x9, 0x80, 0xdd, 0x2b}; - uint8_t bytesprops6[] = {0x6b, 0x52, 0x72, 0xa4, 0xfb, 0xc1, 0xcb, 0xfb, 0x63, 0xf4, 0x7b, - 0x50, 0x5, 0xb6, 0xee, 0xce, 0x7e, 0xb3, 0xee, 0x1f, 0x9f}; - uint8_t bytesprops7[] = {0xcf, 0xde, 0xc6, 0x12, 0xa3, 0x72, 0x81, 0x26, - 0x91, 0xf4, 0xc5, 0x5d, 0x9c, 0xc0, 0xd7, 0x21}; - uint8_t bytesprops8[] = {0x6f, 0x20, 0x1f, 0x30, 0xcc, 0x88, 0x7e, 0xbc, 0xb, 0x6c, 0x31, 0x7, 0xed}; - uint8_t bytesprops9[] = {0xf9, 0xe, 0xbd, 0x11, 0x5a, 0x7f, 0x4c, 0xeb, 0xa1, 0xbf, 0xdc, 0x7c, 0xde, 0x2f, - 0xdb, 0x6b, 0x4c, 0x9c, 0x6e, 0x2b, 0x18, 0xe6, 0xa2, 0x6c, 0xe7, 0x5e, 0x73, 0xcf}; - uint8_t bytesprops10[] = {0xf6, 0x54, 0x70, 0xa3, 0x26, 0x4f, 0xc9, 0xe0, 0x54, 0x53, 0x97, 0x1a, 0x55, 0x2f, 0x50, - 0xe3, 0x17, 0x98, 0xea, 0xff, 0x2e, 0x35, 0x94, 0xeb, 0x31, 0x8a, 0xdc, 0x9c, 0xac, 0x9a}; - uint8_t bytesprops11[] = {0x98, 0x99, 0x71, 0x32, 0x58, 0x5, 0xc8, 0xda, 0xdd, 0x58, 0xd9, - 0x7d, 0xd4, 0xf6, 0xe3, 0x30, 0x3c, 0x40, 0xd9, 0xf, 0x8e}; - uint8_t bytesprops12[] = {0x64, 0x36, 0xdb, 0x64, 0x31, 0x9f, 0x13, 0xca, 0x47, 0x79, 0x45, 0x6e}; - uint8_t bytesprops14[] = {0x25, 0x84, 0x12, 0x79, 0x8e, 0xd8, 0xab, 0x25, 0xf8, 0x7e, 0xfc, 0xa5, 0x7e, - 0xd, 0xab, 0x1e, 0x70, 0xe5, 0xc0, 0x2d, 0xe1, 0xec, 0x16, 0x26, 0x58, 0x1f}; - uint8_t bytesprops13[] = {0xd5, 0x5d, 0x26, 0x8a, 0xe8, 0x49, 0x44, 0x9f, - 0xee, 0x6f, 0xb2, 0x23, 0x6b, 0x25, 0x50, 0x97}; + 0x10, 0xb6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc4, 0x54, 0x39, 0x36, 0x27, 0x0, 0x0, 0x25, 0xd4, + 0x24, 0x5e, 0x12, 0x0, 0xe, 0xa3, 0xd7, 0x77, 0x3f, 0xa6, 0x19, 0xcd, 0x64, 0x49, 0x3f, 0x93, 0x37, 0x88, 0xa8, + 0x2, 0x0, 0x0, 0x34, 0x28, 0x9, 0x0, 0xe, 0x49, 0xb5, 0xe7, 0xb5, 0xb9, 0x88, 0xdd, 0x96, 0xd5, 0x32, 0xa4, + 0x2d, 0xb3, 0x1b, 0x22, 0x33, 0xec, 0xb, 0x6, 0x23, 0x46, 0x37, 0x0, 0x19, 0x58, 0xa7, 0x58, 0xf4, 0x2f, 0x60, + 0xb, 0xb5, 0x65,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 0x59, + 0x4, 0x3e, 0x19, 0x3e, 0x0, 0xf, 0x7d, 0xc3, 0x56, 0x49, 0x1a, 0x50, 0xa6, 0xcf, 0x8d, 0x3c, 0x8c, 0xcb, 0xa4, + 0xe0, 0x5a, 0x0, 0x18, 0xef, 0x1f, 0x1d, 0x73, 0x28, 0x8b, 0x6c, 0x71, 0x98, 0x27, 0xce, 0xee, 0x13, 0x28, 0x66, + 0xac, 0x50, 0x1d, 0x98, 0x82, 0xeb, 0x4b, 0x0, 0xea}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4141}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26526}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 530}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18660}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8586}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 364}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {16, (char*)&bytesprops13}, .v = {26, (char*)&bytesprops14}}}}, - }; + uint8_t buf[323] = {0}; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xfa, 0x22, 0xf, 0xfc, 0x3, 0x21, 0x73, 0x8, 0x71, 0x4b, 0xc5, - 0x67, 0x32, 0xcc, 0x8e, 0x7e, 0x4d, 0x32, 0x9b, 0x46, 0x15}; - uint8_t byteswillprops1[] = {0x2, 0x40, 0x52, 0x4, 0x96, 0x23, 0x6d, 0xe, 0xb8, 0xf5, 0x42, 0xc4, 0x3d, 0x4f}; - uint8_t byteswillprops2[] = {0xc3, 0x47, 0xd1, 0x78, 0xf2, 0x6f, 0xcc, 0x70, 0x52, 0x25, 0x98, 0xf3, - 0x27, 0xf4, 0xd2, 0x4d, 0x46, 0xa, 0x64, 0x2b, 0x55, 0xb7, 0x49}; - uint8_t byteswillprops3[] = {0xdd, 0xd6, 0x2b, 0xed, 0x3, 0x22, 0xc6, 0xd9, 0x12, 0xe7, 0xb7, 0x9c, 0xd2, 0x18, - 0x69, 0xe4, 0x3a, 0x89, 0x4, 0xe9, 0x77, 0x6e, 0xd0, 0x6, 0xcf, 0x3, 0x38, 0x2c}; - uint8_t byteswillprops4[] = {0xba, 0xd2, 0x9f, 0x5c, 0x41, 0x8c, 0xd4, 0x29, 0x68, 0xbe, 0xf0, 0xcd, 0x64, 0x54, 0x46, - 0xbe, 0x5c, 0x42, 0xe4, 0x17, 0x8b, 0xad, 0xf4, 0x84, 0xa8, 0xa, 0x28, 0x8f, 0x63}; + uint8_t bytesprops0[] = {0xa3, 0xd7, 0x77, 0x3f, 0xa6, 0x19, 0xcd, 0x64, 0x49, 0x3f, 0x93, 0x37, 0x88, 0xa8}; + uint8_t bytesprops1[] = {0x49, 0xb5, 0xe7, 0xb5, 0xb9, 0x88, 0xdd, 0x96, 0xd5, 0x32, 0xa4, 0x2d, 0xb3, 0x1b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9684}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13352}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13292}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17975}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x64, 0x8e, 0x33, 0xca, 0x70, 0xd9, 0xd2, 0x99, 0x81, 0x5a, 0x50, 0xcf, 0x76, 0x8b, + 0xf2, 0xcc, 0x46, 0x87, 0xc, 0xbb, 0x83, 0x99, 0xcc, 0xbb, 0x9c, 0xe1, 0x23, 0x90}; + uint8_t byteswillprops1[] = {0}; + uint8_t byteswillprops2[] = {0}; + uint8_t byteswillprops3[] = {0x4, 0xf0, 0x60, 0xa4, 0x13, 0x10, 0xa9, 0xad, 0x40, 0x9f, 0xc2, 0x58, 0xcb, 0xa8, + 0x52, 0x2e, 0xda, 0x5, 0x1f, 0xf7, 0x33, 0x3f, 0xfc, 0x38, 0x66, 0x42, 0xa5}; + uint8_t byteswillprops4[] = {0xc0, 0xe2, 0x95, 0x81, 0xfe, 0xc9, 0x64, 0x63, 0xc, 0x67, 0xb1, 0xb3, + 0x12, 0x1e, 0x13, 0x2e, 0x18, 0xe6, 0xd9, 0xaa, 0xa4, 0xb2, 0xae}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23059}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22019}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21909}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17248}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30219}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 938}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3726}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31770}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29169}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6570}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11129}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12415}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24015}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31266}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3690}}, }; - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xde, 0x76, 0xc3, 0xfc, 0xf3, 0x9f, 0x70, 0x81, 0x2, 0xda, - 0x72, 0x2, 0x1b, 0x6d, 0xf2, 0xc9, 0xc1, 0x36, 0x58, 0xbf, - 0x68, 0xce, 0xe9, 0xd2, 0x78, 0x86, 0x64, 0xaa, 0xc}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x12, 0x42, 0x6d, 0x98, 0x10, 0x8c, 0xe, 0xec, 0x2a, 0x96, - 0x86, 0x86, 0x6d, 0xc3, 0x49, 0x8c, 0x9, 0x4d, 0x70, 0x47, - 0xb, 0xc7, 0x8a, 0x27, 0xe6, 0xf2, 0xe3, 0xf7, 0x6d, 0xca}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4f, 0x31, 0x16, 0xda, 0x97, 0x26, 0xe5, 0x9b, 0x6a, 0xed, + 0x10, 0x46, 0x8f, 0xd8, 0xe8, 0x61, 0xbd, 0xc3, 0xe2, 0x8e}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb2, 0xa5, 0xaa, 0xb5, 0x28, 0x2d, 0xf8, 0xcc, 0x10, + 0xe6, 0x6a, 0x4b, 0x59, 0x4, 0x3e, 0x19, 0x3e}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -2593,18 +3525,18 @@ TEST(Connect5QCTest, Encode9) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 9102; - uint8_t client_id_bytes[] = {0xea, 0x42, 0x4, 0xf7, 0xf7, 0x57, 0xc2, 0xde, 0xa, 0x50, 0x83, 0x29, 0x26, 0x3f, 0xe2, - 0x30, 0x58, 0xd1, 0x70, 0x1b, 0xb1, 0x7a, 0xc9, 0xe, 0x74, 0x83, 0x67, 0x28, 0xd7, 0x57}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 21561; + uint8_t client_id_bytes[] = {0x58, 0xa7, 0x58, 0xf4, 0x2f, 0x60, 0xb, 0xb5, 0x65, 0x23, 0x68, 0x9f, 0xb3, + 0xdb, 0x3b, 0x51, 0xad, 0xb, 0x86, 0xb5, 0x2b, 0x95, 0xbe, 0x78, 0x73}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf2, 0xdc, 0x1a, 0xcc, 0xb, 0x2d, 0x88, 0xd3, 0x2f, 0xda, 0x12, 0xf3, 0x9e, 0x5d, 0xbe, - 0xa5, 0xfb, 0x96, 0x48, 0xee, 0xc8, 0x12, 0x98, 0xf5, 0x55, 0xca, 0x0, 0x66, 0x99}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x7d, 0xc3, 0x56, 0x49, 0x1a, 0x50, 0xa6, 0xcf, 0x8d, 0x3c, 0x8c, 0xcb, 0xa4, 0xe0, 0x5a}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xa1, 0xb, 0x40, 0x9, 0x9b, 0xe9, 0x57, 0x42}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xef, 0x1f, 0x1d, 0x73, 0x28, 0x8b, 0x6c, 0x71, 0x98, 0x27, 0xce, 0xee, + 0x13, 0x28, 0x66, 0xac, 0x50, 0x1d, 0x98, 0x82, 0xeb, 0x4b, 0x0, 0xea}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -2613,113 +3545,79 @@ TEST(Connect5QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\174\237\224:\154\243X\224`\199", _password = Just -// "%\185W1f}\195\140\153\169\181\238\243\236\EM,V\216\ESC\151\168", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "\162\219\EM\161\228\128\255m", _willMsg = "", _willProps = [PropAuthenticationData -// "",PropUserProperty "\241\182\DELW\185\FSV\203\254!\191e\184\173v" -// "5\186\170\159J\173\138LGd\DC2",PropSubscriptionIdentifier 30,PropAuthenticationData -// "\DC4\203\EOT\t\137/l\252\129(\211\187\225",PropTopicAliasMaximum 31859,PropMaximumPacketSize 5092,PropResponseTopic -// "",PropRequestResponseInformation 63,PropWildcardSubscriptionAvailable 50,PropSessionExpiryInterval -// 28357,PropSubscriptionIdentifierAvailable 244,PropTopicAliasMaximum 4424,PropAuthenticationMethod -// ",\DC3\161\192\DLE\137\&7",PropSharedSubscriptionAvailable 33,PropCorrelationData -// "\234+\178+\DLE?o\137\164\210\145\238<\193Ci\148\233\b\251\FS\DLE\217\145\238\164",PropMaximumPacketSize -// 21984,PropSubscriptionIdentifierAvailable 55,PropAuthenticationData "US\224/\189"]}), _cleanSession = True, -// _keepAlive = 17212, _connID = "\203o\140\199r\n\144n\FS\211\223\147\152?\GS\152/\v\245r\"\250", _properties = -// [PropAuthenticationMethod "\188\249MP\236w3\210\146\"\141m\208E\204\148",PropReasonString -// "\178\&1\131\&3=h\198\GS'\231\140\148\253\194\169a\134#P(\249\196\b\174\174/\214\"\149",PropTopicAlias -// 29058,PropSubscriptionIdentifier 10,PropWildcardSubscriptionAvailable 243]} +// ConnectRequest {_username = Just "\239zk\159\ETX\223!\141\ETX\233\248\f1=\DC4i", _password = Just +// "\191\141\246E\193\236\243\223\153\216myo\194\214\244\200\140\198\147\236Q\194X\130\136", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS0, _willTopic = "L&sv\176Yc2O\\\201,", _willMsg = +// "/\a}\172t\US\218\131\240\224S\221\205S\227\223\231\246~_\168}|8\172\219\157\168", _willProps = +// [PropAssignedClientIdentifier "\253{\222\SUB\ESC\ENQ\223\244",PropRequestResponseInformation 223]}), _cleanSession = +// False, _keepAlive = 478, _connID = "+\251Q\185q\193\199\n\237\186\162\a", _properties = [PropAssignedClientIdentifier +// "\235s\DEL\151g\v\bBE\215",PropWildcardSubscriptionAvailable 91,PropUserProperty "|p\194\v1\161" +// "\247z\SOr\192\246c\152%_\132zbR\US\218)\195\147k\149\199",PropAssignedClientIdentifier +// "\r,\176N#\158._Gf\218\228,\180-",PropTopicAliasMaximum 15986]} TEST(Connect5QCTest, Encode10) { - uint8_t pkt[] = { - 0x10, 0x93, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x43, 0x3c, 0x3a, 0x15, 0x0, 0x10, 0xbc, 0xf9, - 0x4d, 0x50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x8, - 0xfb, 0x1c, 0x10, 0xd9, 0x91, 0xee, 0xa4, 0x27, 0x0, 0x0, 0x55, 0xe0, 0x29, 0x37, 0x16, 0x0, 0x5, 0x55, 0x53, - 0xe0, 0x2f, 0xbd, 0x0, 0x8, 0xa2, 0xdb, 0x19, 0xa1, 0xe4, 0x80, 0xff, 0x6d, 0x0, 0x0, 0x0, 0xa, 0xae, 0xed, - 0xe0, 0x3a, 0x9a, 0xf3, 0x58, 0xe0, 0x60, 0xc7, 0x0, 0x15, 0x25, 0xb9, 0x57, 0x31, 0x66, 0x7d, 0xc3, 0x8c, 0x99, - 0xa9, 0xb5, 0xee, 0xf3, 0xec, 0x19, 0x2c, 0x56, 0xd8, 0x1b, 0x97, 0xa8}; - - uint8_t buf[288] = {0}; - - uint8_t bytesprops0[] = {0xbc, 0xf9, 0x4d, 0x50, 0xec, 0x77, 0x33, 0xd2, - 0x92, 0x22, 0x8d, 0x6d, 0xd0, 0x45, 0xcc, 0x94}; - uint8_t bytesprops1[] = {0xb2, 0x31, 0x83, 0x33, 0x3d, 0x68, 0xc6, 0x1d, 0x27, 0xe7, 0x8c, 0x94, 0xfd, 0xc2, 0xa9, - 0x61, 0x86, 0x23, 0x50, 0x28, 0xf9, 0xc4, 0x8, 0xae, 0xae, 0x2f, 0xd6, 0x22, 0x95}; + uint8_t pkt[] = {0x10, 0xc6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x1, 0xde, 0x45, 0x12, 0x0, 0xa, + 0xeb, 0x73, 0x7f, 0x97, 0x67, 0xb, 0x8, 0x42, 0x45, 0xd7, 0x28, 0x5b, 0x26, 0x0, 0x6, 0x7c, 0x70, + 0xc2, 0xb, 0x31, 0xa1, 0x0, 0x16, 0xf7, 0x7a, 0xe, 0x72, 0xc0, 0xf6, 0x63, 0x98, 0x25, 0x5f, 0x84, + 0x7a, 0x62, 0x52, 0x1f, 0xda, 0x29, 0xc3, 0x93, 0x6b, 0x95, 0xc7, 0x12, 0x0, 0xf, 0xd, 0x2c, 0xb0, + 0x4e, 0x23, 0x9e, 0x2e, 0x5f, 0x47, 0x66, 0xda, 0xe4, 0x2c, 0xb4, 0x2d, 0x22, 0x3e, 0x72, 0x0, 0xc, + 0x2b, 0xfb, 0x51, 0xb9, 0x71, 0xc1, 0xc7, 0xa, 0xed, 0xba, 0xa2, 0x7, 0xd, 0x12, 0x0, 0x8, 0xfd, + 0x7b, 0xde, 0x1a, 0x1b, 0x5, 0xdf, 0xf4, 0x19, 0xdf, 0x0, 0xc, 0x4c, 0x26, 0x73, 0x76, 0xb0, 0x59, + 0x63, 0x32, 0x4f, 0x5c, 0xc9, 0x2c, 0x0, 0x1c, 0x2f, 0x7, 0x7d, 0xac, 0x74, 0x1f, 0xda, 0x83, 0xf0, + 0xe0, 0x53, 0xdd, 0xcd, 0x53, 0xe3, 0xdf, 0xe7, 0xf6, 0x7e, 0x5f, 0xa8, 0x7d, 0x7c, 0x38, 0xac, 0xdb, + 0x9d, 0xa8, 0x0, 0x10, 0xef, 0x7a, 0x6b, 0x9f, 0x3, 0xdf, 0x21, 0x8d, 0x3, 0xe9, 0xf8, 0xc, 0x31, + 0x3d, 0x14, 0x69, 0x0, 0x1a, 0xbf, 0x8d, 0xf6, 0x45, 0xc1, 0xec, 0xf3, 0xdf, 0x99, 0xd8, 0x6d, 0x79, + 0x6f, 0xc2, 0xd6, 0xf4, 0xc8, 0x8c, 0xc6, 0x93, 0xec, 0x51, 0xc2, 0x58, 0x82, 0x88}; + + uint8_t buf[211] = {0}; + + uint8_t bytesprops0[] = {0xeb, 0x73, 0x7f, 0x97, 0x67, 0xb, 0x8, 0x42, 0x45, 0xd7}; + uint8_t bytesprops2[] = {0xf7, 0x7a, 0xe, 0x72, 0xc0, 0xf6, 0x63, 0x98, 0x25, 0x5f, 0x84, + 0x7a, 0x62, 0x52, 0x1f, 0xda, 0x29, 0xc3, 0x93, 0x6b, 0x95, 0xc7}; + uint8_t bytesprops1[] = {0x7c, 0x70, 0xc2, 0xb, 0x31, 0xa1}; + uint8_t bytesprops3[] = {0xd, 0x2c, 0xb0, 0x4e, 0x23, 0x9e, 0x2e, 0x5f, 0x47, 0x66, 0xda, 0xe4, 0x2c, 0xb4, 0x2d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29058}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {22, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15986}}, }; lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0}; - uint8_t byteswillprops2[] = {0x35, 0xba, 0xaa, 0x9f, 0x4a, 0xad, 0x8a, 0x4c, 0x47, 0x64, 0x12}; - uint8_t byteswillprops1[] = {0xf1, 0xb6, 0x7f, 0x57, 0xb9, 0x1c, 0x56, 0xcb, - 0xfe, 0x21, 0xbf, 0x65, 0xb8, 0xad, 0x76}; - uint8_t byteswillprops3[] = {0x14, 0xcb, 0x4, 0x9, 0x89, 0x2f, 0x6c, 0xfc, 0x81, 0x28, 0xd3, 0xbb, 0xe1}; - uint8_t byteswillprops4[] = {0}; - uint8_t byteswillprops5[] = {0x2c, 0x13, 0xa1, 0xc0, 0x10, 0x89, 0x37}; - uint8_t byteswillprops6[] = {0xea, 0x2b, 0xb2, 0x2b, 0x10, 0x3f, 0x6f, 0x89, 0xa4, 0xd2, 0x91, 0xee, 0x3c, - 0xc1, 0x43, 0x69, 0x94, 0xe9, 0x8, 0xfb, 0x1c, 0x10, 0xd9, 0x91, 0xee, 0xa4}; - uint8_t byteswillprops7[] = {0x55, 0x53, 0xe0, 0x2f, 0xbd}; + uint8_t byteswillprops0[] = {0xfd, 0x7b, 0xde, 0x1a, 0x1b, 0x5, 0xdf, 0xf4}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {15, (char*)&byteswillprops1}, .v = {11, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31859}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5092}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28357}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4424}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21984}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 223}}, }; - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa2, 0xdb, 0x19, 0xa1, 0xe4, 0x80, 0xff, 0x6d}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4c, 0x26, 0x73, 0x76, 0xb0, 0x59, 0x63, 0x32, 0x4f, 0x5c, 0xc9, 0x2c}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2f, 0x7, 0x7d, 0xac, 0x74, 0x1f, 0xda, 0x83, 0xf0, 0xe0, 0x53, 0xdd, 0xcd, 0x53, + 0xe3, 0xdf, 0xe7, 0xf6, 0x7e, 0x5f, 0xa8, 0x7d, 0x7c, 0x38, 0xac, 0xdb, 0x9d, 0xa8}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 17212; - uint8_t client_id_bytes[] = {0xcb, 0x6f, 0x8c, 0xc7, 0x72, 0xa, 0x90, 0x6e, 0x1c, 0xd3, 0xdf, - 0x93, 0x98, 0x3f, 0x1d, 0x98, 0x2f, 0xb, 0xf5, 0x72, 0x22, 0xfa}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 478; + uint8_t client_id_bytes[] = {0x2b, 0xfb, 0x51, 0xb9, 0x71, 0xc1, 0xc7, 0xa, 0xed, 0xba, 0xa2, 0x7}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xae, 0xed, 0xe0, 0x3a, 0x9a, 0xf3, 0x58, 0xe0, 0x60, 0xc7}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xef, 0x7a, 0x6b, 0x9f, 0x3, 0xdf, 0x21, 0x8d, + 0x3, 0xe9, 0xf8, 0xc, 0x31, 0x3d, 0x14, 0x69}; + lwmqtt_string_t username = {16, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x25, 0xb9, 0x57, 0x31, 0x66, 0x7d, 0xc3, 0x8c, 0x99, 0xa9, 0xb5, - 0xee, 0xf3, 0xec, 0x19, 0x2c, 0x56, 0xd8, 0x1b, 0x97, 0xa8}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xbf, 0x8d, 0xf6, 0x45, 0xc1, 0xec, 0xf3, 0xdf, 0x99, 0xd8, 0x6d, 0x79, 0x6f, + 0xc2, 0xd6, 0xf4, 0xc8, 0x8c, 0xc6, 0x93, 0xec, 0x51, 0xc2, 0x58, 0x82, 0x88}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -2728,15527 +3626,1668 @@ TEST(Connect5QCTest, Encode10) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 31688 [("\134Q\r\137U\191\DEL\166>c<~\234\229\251\206\249tYv\161\\\154OeS",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\220\254\200+\222G\NUL\254\179r\136{N\185N\151rL\147\ETX\251\145p\202\177\129\244\220",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),(";\154\220$\161c\EM\CAN\187~\EM\131+\SYN\242\172q\CAN(\214",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 27385 [("\203r\138\235\US\213\196\158\177\226",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\199G9%\137ER:\132\252\SUB\145)\DC1\238\243q\SI",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k",SubOptions {_retainHandling = SendOnSubscribe, +// QoS1}),("\210\190\198\&0ofo\DC1|E\r\rL\152\233\224d\199",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\151\228-h2E\145\155\RS[\a\180\192{W\249\DC2k\241\246&L\189\146\SI\227P\233(",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\188\128\150\245A\241\232\247\246K\242\221E\146@\166n\144\178VMY",SubOptions {_retainHandling = +// QoS2}),("\237\&4\212\155\143\216\v\200\DEL\206\242\145\213W\133\216HU\FSK",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("]!b\157\132\190\207K\CAN\240\196\ENQ\CAN\224\246\SOR9CcF\242\206\r\248\GSj",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS2}),("\149\ETX\DC3%\228\238+\165\167r\NAKr\178\170",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("4\244y\238\205\153\213",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\135",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\187\224\219\172\\$\133[rk\157\200\159O\ENQ@\167\217\254^\202\145\206\SOH\DC1\152\r\214\128\148\140",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\248\143P2v\177\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("n\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2}),("X\159\CAN\143\245\n\206y\DC4\135\DC4i\232`",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\DLEA\227\&5x\234\US\171",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\164\177\152\ETBhD\152\251\180\"\244\239\191\241\149\227}\183\&0",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\r@\174C\FSM$\180\212'\253\157\173\SOI9\204b",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("C\226\169\230)",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\145Tu\NUL\b\ESC\227",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS0}),("\246\&2\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x8a, 0x1, 0x3c, 0x68, 0x0, 0x1d, 0xe, 0x43, 0x9b, 0xd9, 0x1b, 0xb, 0x4a, 0x8b, 0xe, - 0x57, 0xb7, 0x1e, 0x5d, 0x2, 0x26, 0x1a, 0xb8, 0x0, 0xf2, 0x4a, 0xba, 0xa5, 0xa5, 0xcc, 0x35, - 0xa0, 0xd1, 0x9c, 0x39, 0x0, 0x0, 0x7, 0xf8, 0x8f, 0x50, 0x32, 0x76, 0xb1, 0x32, 0x2, 0x0, - 0x2, 0x6e, 0xd2, 0x2, 0x0, 0xe, 0x58, 0x9f, 0x18, 0x8f, 0xf5, 0xa, 0xce, 0x79, 0x14, 0x87, - 0x14, 0x69, 0xe8, 0x60, 0x2, 0x0, 0x8, 0x10, 0x41, 0xe3, 0x35, 0x78, 0xea, 0x1f, 0xab, 0x0, - 0x0, 0x13, 0xa4, 0xb1, 0x98, 0x17, 0x68, 0x44, 0x98, 0xfb, 0xb4, 0x22, 0xf4, 0xef, 0xbf, 0xf1, - 0x95, 0xe3, 0x7d, 0xb7, 0x30, 0x0, 0x0, 0x12, 0xd, 0x40, 0xae, 0x43, 0x1c, 0x4d, 0x24, 0xb4, - 0xd4, 0x27, 0xfd, 0x9d, 0xad, 0xe, 0x49, 0x39, 0xcc, 0x62, 0x0, 0x0, 0x5, 0x43, 0xe2, 0xa9, - 0xe6, 0x29, 0x0, 0x0, 0x7, 0x91, 0x54, 0x75, 0x0, 0x8, 0x1b, 0xe3, 0x1}; - - uint8_t buf[151] = {0}; + uint8_t pkt[] = {0x82, 0x2b, 0x1b, 0xbb, 0x0, 0x4, 0x83, 0x4a, 0xa5, 0xca, 0x2, 0x0, 0x4, 0xd, 0xf2, + 0x23, 0x5b, 0x0, 0x0, 0x1, 0x2b, 0x2, 0x0, 0xe, 0xa5, 0x3e, 0x5e, 0xca, 0x91, 0xce, + 0x1, 0x11, 0x98, 0xd, 0xd6, 0x80, 0x94, 0x8c, 0x0, 0x0, 0x3, 0xf6, 0x32, 0xba, 0x2}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xe, 0x43, 0x9b, 0xd9, 0x1b, 0xb, 0x4a, 0x8b, 0xe, 0x57, - 0xb7, 0x1e, 0x5d, 0x2, 0x26, 0x1a, 0xb8, 0x0, 0xf2, 0x4a, - 0xba, 0xa5, 0xa5, 0xcc, 0x35, 0xa0, 0xd1, 0x9c, 0x39}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + uint8_t buf[55] = {0}; + + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x83, 0x4a, 0xa5, 0xca}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf8, 0x8f, 0x50, 0x32, 0x76, 0xb1, 0x32}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd, 0xf2, 0x23, 0x5b}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6e, 0xd2}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2b}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x58, 0x9f, 0x18, 0x8f, 0xf5, 0xa, 0xce, 0x79, 0x14, 0x87, 0x14, 0x69, 0xe8, 0x60}; + uint8_t topic_filter_s3_bytes[] = {0xa5, 0x3e, 0x5e, 0xca, 0x91, 0xce, 0x1, 0x11, 0x98, 0xd, 0xd6, 0x80, 0x94, 0x8c}; lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x10, 0x41, 0xe3, 0x35, 0x78, 0xea, 0x1f, 0xab}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xf6, 0x32, 0xba}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa4, 0xb1, 0x98, 0x17, 0x68, 0x44, 0x98, 0xfb, 0xb4, 0x22, - 0xf4, 0xef, 0xbf, 0xf1, 0x95, 0xe3, 0x7d, 0xb7, 0x30}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xd, 0x40, 0xae, 0x43, 0x1c, 0x4d, 0x24, 0xb4, 0xd4, - 0x27, 0xfd, 0x9d, 0xad, 0xe, 0x49, 0x39, 0xcc, 0x62}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x43, 0xe2, 0xa9, 0xe6, 0x29}; - lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x91, 0x54, 0x75, 0x0, 0x8, 0x1b, 0xe3}; - lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15464, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7099, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 838 [("$-\227\252n\140N\241\225\146S\213\231(\193\150\248\177u\194",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 835 [("\160\159FO\167\\r\224\141\226\228-\226\247\r@\206\&1w",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\GS9\DLE\253:\192\SOH/M#\196\191O\159f",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\NULT\227e\232\&8\141\133n#\DLE.\193\163\199\173\&0\184\&9\231\190\253\DEL\144\SUB\130\137\210",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0x19, 0x3, 0x46, 0x0, 0x14, 0x24, 0x2d, 0xe3, 0xfc, 0x6e, 0x8c, 0x4e, 0xf1, - 0xe1, 0x92, 0x53, 0xd5, 0xe7, 0x28, 0xc1, 0x96, 0xf8, 0xb1, 0x75, 0xc2, 0x1}; + uint8_t pkt[] = {0x82, 0x49, 0x3, 0x43, 0x0, 0x13, 0xa0, 0x9f, 0x46, 0x4f, 0xa7, 0x5c, 0x72, 0xe0, 0x8d, + 0xe2, 0xe4, 0x2d, 0xe2, 0xf7, 0xd, 0x40, 0xce, 0x31, 0x77, 0x0, 0x0, 0xf, 0x1d, 0x39, + 0x10, 0xfd, 0x3a, 0xc0, 0x1, 0x2f, 0x4d, 0x23, 0xc4, 0xbf, 0x4f, 0x9f, 0x66, 0x0, 0x0, + 0x1c, 0x0, 0x54, 0xe3, 0x65, 0xe8, 0x38, 0x8d, 0x85, 0x6e, 0x23, 0x10, 0x2e, 0xc1, 0xa3, + 0xc7, 0xad, 0x30, 0xb8, 0x39, 0xe7, 0xbe, 0xfd, 0x7f, 0x90, 0x1a, 0x82, 0x89, 0xd2, 0x1}; - uint8_t buf[37] = {0}; + uint8_t buf[85] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x24, 0x2d, 0xe3, 0xfc, 0x6e, 0x8c, 0x4e, 0xf1, 0xe1, 0x92, - 0x53, 0xd5, 0xe7, 0x28, 0xc1, 0x96, 0xf8, 0xb1, 0x75, 0xc2}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xa0, 0x9f, 0x46, 0x4f, 0xa7, 0x5c, 0x72, 0xe0, 0x8d, 0xe2, + 0xe4, 0x2d, 0xe2, 0xf7, 0xd, 0x40, 0xce, 0x31, 0x77}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t topic_filter_s1_bytes[] = {0x1d, 0x39, 0x10, 0xfd, 0x3a, 0xc0, 0x1, 0x2f, + 0x4d, 0x23, 0xc4, 0xbf, 0x4f, 0x9f, 0x66}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x0, 0x54, 0xe3, 0x65, 0xe8, 0x38, 0x8d, 0x85, 0x6e, 0x23, + 0x10, 0x2e, 0xc1, 0xa3, 0xc7, 0xad, 0x30, 0xb8, 0x39, 0xe7, + 0xbe, 0xfd, 0x7f, 0x90, 0x1a, 0x82, 0x89, 0xd2}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 838, 1, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 835, 3, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 16617 [("*\213.\SOH{\207\165\GS\FS\150\148]qq=A\239\234\252\189\STX;",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\210<\215\&2\177\181\232\211j\199\228\159~/\181X\SYN\136\205\\\253#",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\223[\223\187\180|\210;\149\229\164E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\133\253\223\167\156+\246\156\162\137\SYN\187I\v\233\SUB-\204P\169\233",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("1\b?\185o\135\176\195\173\ETB\161\156'\128M",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("6\129\247\STX\251H6",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("#`\225\150-e~\189\179c\212Qv\226U\171q\201\244\186i\219\169\234\t\175",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\NUL\136\CANO\SI\DEL\DC3\SYN\162\134\176\241\190eb\210\155",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\129>",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 26916 [("g\184\175\169W\207b4\EOTv|>\229C",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0xad, 0x1, 0x40, 0xe9, 0x0, 0x16, 0x2a, 0xd5, 0x2e, 0x1, 0x7b, 0xcf, 0xa5, 0x1d, 0x1c, - 0x96, 0x94, 0x5d, 0x71, 0x71, 0x3d, 0x41, 0xef, 0xea, 0xfc, 0xbd, 0x2, 0x3b, 0x2, 0x0, 0x16, - 0xd2, 0x3c, 0xd7, 0x32, 0xb1, 0xb5, 0xe8, 0xd3, 0x6a, 0xc7, 0xe4, 0x9f, 0x7e, 0x2f, 0xb5, 0x58, - 0x16, 0x88, 0xcd, 0x5c, 0xfd, 0x23, 0x1, 0x0, 0xc, 0xdf, 0x5b, 0xdf, 0xbb, 0xb4, 0x7c, 0xd2, - 0x3b, 0x95, 0xe5, 0xa4, 0x45, 0x0, 0x0, 0x15, 0x85, 0xfd, 0xdf, 0xa7, 0x9c, 0x2b, 0xf6, 0x9c, - 0xa2, 0x89, 0x16, 0xbb, 0x49, 0xb, 0xe9, 0x1a, 0x2d, 0xcc, 0x50, 0xa9, 0xe9, 0x0, 0x0, 0xf, - 0x31, 0x8, 0x3f, 0xb9, 0x6f, 0x87, 0xb0, 0xc3, 0xad, 0x17, 0xa1, 0x9c, 0x27, 0x80, 0x4d, 0x2, - 0x0, 0x7, 0x36, 0x81, 0xf7, 0x2, 0xfb, 0x48, 0x36, 0x0, 0x0, 0x1a, 0x23, 0x60, 0xe1, 0x96, - 0x2d, 0x65, 0x7e, 0xbd, 0xb3, 0x63, 0xd4, 0x51, 0x76, 0xe2, 0x55, 0xab, 0x71, 0xc9, 0xf4, 0xba, - 0x69, 0xdb, 0xa9, 0xea, 0x9, 0xaf, 0x0, 0x0, 0x11, 0x0, 0x88, 0x18, 0x4f, 0xf, 0x7f, 0x13, - 0x16, 0xa2, 0x86, 0xb0, 0xf1, 0xbe, 0x65, 0x62, 0xd2, 0x9b, 0x1, 0x0, 0x2, 0x81, 0x3e, 0x1}; - - uint8_t buf[186] = {0}; + uint8_t pkt[] = {0x82, 0x13, 0x69, 0x24, 0x0, 0xe, 0x67, 0xb8, 0xaf, 0xa9, 0x57, + 0xcf, 0x62, 0x34, 0x4, 0x76, 0x7c, 0x3e, 0xe5, 0x43, 0x1}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x2a, 0xd5, 0x2e, 0x1, 0x7b, 0xcf, 0xa5, 0x1d, 0x1c, 0x96, 0x94, - 0x5d, 0x71, 0x71, 0x3d, 0x41, 0xef, 0xea, 0xfc, 0xbd, 0x2, 0x3b}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + uint8_t buf[31] = {0}; + + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x67, 0xb8, 0xaf, 0xa9, 0x57, 0xcf, 0x62, 0x34, 0x4, 0x76, 0x7c, 0x3e, 0xe5, 0x43}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd2, 0x3c, 0xd7, 0x32, 0xb1, 0xb5, 0xe8, 0xd3, 0x6a, 0xc7, 0xe4, - 0x9f, 0x7e, 0x2f, 0xb5, 0x58, 0x16, 0x88, 0xcd, 0x5c, 0xfd, 0x23}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdf, 0x5b, 0xdf, 0xbb, 0xb4, 0x7c, 0xd2, 0x3b, 0x95, 0xe5, 0xa4, 0x45}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x85, 0xfd, 0xdf, 0xa7, 0x9c, 0x2b, 0xf6, 0x9c, 0xa2, 0x89, 0x16, - 0xbb, 0x49, 0xb, 0xe9, 0x1a, 0x2d, 0xcc, 0x50, 0xa9, 0xe9}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x31, 0x8, 0x3f, 0xb9, 0x6f, 0x87, 0xb0, 0xc3, - 0xad, 0x17, 0xa1, 0x9c, 0x27, 0x80, 0x4d}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x36, 0x81, 0xf7, 0x2, 0xfb, 0x48, 0x36}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x23, 0x60, 0xe1, 0x96, 0x2d, 0x65, 0x7e, 0xbd, 0xb3, 0x63, 0xd4, 0x51, 0x76, - 0xe2, 0x55, 0xab, 0x71, 0xc9, 0xf4, 0xba, 0x69, 0xdb, 0xa9, 0xea, 0x9, 0xaf}; - lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x0, 0x88, 0x18, 0x4f, 0xf, 0x7f, 0x13, 0x16, 0xa2, - 0x86, 0xb0, 0xf1, 0xbe, 0x65, 0x62, 0xd2, 0x9b}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x81, 0x3e}; - lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16617, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26916, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4070 [("\v\136/\233\EOT\FS\240\255\227\DC3q9\SI\SOH\\",SubOptions {_retainHandling = +// SubscribeRequest 23203 [("\130\206\197\ETX(;3ie\228\139L\185\152\193\203\DC4\200\v}\b",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\170\176\237\215\202\131\&2\ESCK\136h\184\178\226\178}.\242",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS1}),("U\v,\200o\aH\192\130\227\236\180=2\240\253\167!\139t\f\173-\140M",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\169\159D\FS\199m]J\SOHG\136Y7r7\160\252\231\185/\172\205N.\193\&9V",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\182\132\145J\160\&3\216-f\DC4X\142\188",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("X\DEL\227P \242\&23\175\NULVC\243jl\150\148B\250m",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\ESC\229&\185`\246\NULRL\168\216C;\165\167",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\t8\146\169\253\156^\157\EM|\141~t\205l\160\ETX\255\137\142v\188\"\DC22",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("U(!\US\174\250\156Z\ESC",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\US\219\141B\210\224Z\240",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\128\181\150r\134\164",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\146v\DLEM\165!\205`q\245ah.\235f\245#O\214c;\134\203\155\b",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0x29, 0xf, 0xe6, 0x0, 0xf, 0xb, 0x88, 0x2f, 0xe9, 0x4, 0x1c, 0xf0, 0xff, 0xe3, - 0x13, 0x71, 0x39, 0xf, 0x1, 0x5c, 0x1, 0x0, 0x12, 0xaa, 0xb0, 0xed, 0xd7, 0xca, 0x83, - 0x32, 0x1b, 0x4b, 0x88, 0x68, 0xb8, 0xb2, 0xe2, 0xb2, 0x7d, 0x2e, 0xf2, 0x0}; - - uint8_t buf[53] = {0}; + uint8_t pkt[] = {0x82, 0xe5, 0x1,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, 0x8d, 0x42, 0xd2, 0xe0, 0x5a, 0xf0, 0x2, 0x0, 0x6, 0x80, 0xb5, 0x96, 0x72, 0x86, 0xa4, 0x1, + 0x0, 0x19, 0x92, 0x76, 0x10, 0x4d, 0xa5, 0x21, 0xcd, 0x60, 0x71, 0xf5, 0x61, 0x68, 0x2e, 0xeb, 0x66, + 0xf5, 0x23, 0x4f, 0xd6, 0x63, 0x3b, 0x86, 0xcb, 0x9b, 0x8, 0x1}; + + uint8_t buf[242] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xb, 0x88, 0x2f, 0xe9, 0x4, 0x1c, 0xf0, 0xff, - 0xe3, 0x13, 0x71, 0x39, 0xf, 0x1, 0x5c}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x82, 0xce, 0xc5, 0x3, 0x28, 0x3b, 0x33, 0x69, 0x65, 0xe4, 0x8b, + 0x4c, 0xb9, 0x98, 0xc1, 0xcb, 0x14, 0xc8, 0xb, 0x7d, 0x8}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xaa, 0xb0, 0xed, 0xd7, 0xca, 0x83, 0x32, 0x1b, 0x4b, - 0x88, 0x68, 0xb8, 0xb2, 0xe2, 0xb2, 0x7d, 0x2e, 0xf2}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x55, 0xb, 0x2c, 0xc8, 0x6f, 0x7, 0x48, 0xc0, 0x82, 0xe3, 0xec, 0xb4, 0x3d, + 0x32, 0xf0, 0xfd, 0xa7, 0x21, 0x8b, 0x74, 0xc, 0xad, 0x2d, 0x8c, 0x4d}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0}; + uint8_t topic_filter_s2_bytes[] = {0xa9, 0x9f, 0x44, 0x1c, 0xc7, 0x6d, 0x5d, 0x4a, 0x1, 0x47, 0x88, 0x59, 0x37, 0x72, + 0x37, 0xa0, 0xfc, 0xe7, 0xb9, 0x2f, 0xac, 0xcd, 0x4e, 0x2e, 0xc1, 0x39, 0x56}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb6, 0x84, 0x91, 0x4a, 0xa0, 0x33, 0xd8, 0x2d, 0x66, 0x14, 0x58, 0x8e, 0xbc}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x58, 0x7f, 0xe3, 0x50, 0x20, 0xf2, 0x32, 0x33, 0xaf, 0x0, + 0x56, 0x43, 0xf3, 0x6a, 0x6c, 0x96, 0x94, 0x42, 0xfa, 0x6d}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1b, 0xe5, 0x26, 0xb9, 0x60, 0xf6, 0x0, 0x52, + 0x4c, 0xa8, 0xd8, 0x43, 0x3b, 0xa5, 0xa7}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x9, 0x38, 0x92, 0xa9, 0xfd, 0x9c, 0x5e, 0x9d, 0x19, 0x7c, 0x8d, 0x7e, 0x74, + 0xcd, 0x6c, 0xa0, 0x3, 0xff, 0x89, 0x8e, 0x76, 0xbc, 0x22, 0x12, 0x32}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x55, 0x28, 0x21, 0x1f, 0xae, 0xfa, 0x9c, 0x5a, 0x1b}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x1f, 0xdb, 0x8d, 0x42, 0xd2, 0xe0, 0x5a, 0xf0}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x80, 0xb5, 0x96, 0x72, 0x86, 0xa4}; + lwmqtt_string_t topic_filter_s9 = {6, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x92, 0x76, 0x10, 0x4d, 0xa5, 0x21, 0xcd, 0x60, 0x71, 0xf5, 0x61, 0x68, 0x2e, + 0xeb, 0x66, 0xf5, 0x23, 0x4f, 0xd6, 0x63, 0x3b, 0x86, 0xcb, 0x9b, 0x8}; + lwmqtt_string_t topic_filter_s10 = {25, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4070, 2, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23203, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 1318 [("\141",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("(\232l\147\231\ETB\129\188\&6\207\SO\182\244\225\193S\228\&7\179\DEL\220",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\241\168\NUL\143\233m\184\163\STX\218\&8\156\252\250i\184C\188B\167\197\224A",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\177s\170{`\"e\RSr\DC3\r[\215\130\150\199q\253\216\221\231;\SYN",SubOptions {_retainHandling = +// SubscribeRequest 13111 [("\222\SYN24:\156\202\f\132\ETX\186\240",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\v\bAF\245\&5\231\181\211\&88\180\244\224q\245\&2\137||\146\&2\ESC\186p`",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\254*\164\NUL.\198\237\227\&3\143\SUB\248\248\162\t\167\n\146\232\250AK\234\220\178f\205\210\226",SubOptions +// QoS0}),("z-Q\ETX\250}\168H\222\137\DC4\"\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\br\NUL\ENQ]\221\ETXkL\190o\238.#\227\230\EM\169wd",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\159}A_\221B\190\143\&5\n\NUL\186z)\143",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\r0\DC1\n\226K\201\177\128\US:\237o\241I\186d|",SubOptions +// QoS1}),("\189\224\230\&0x$\EOTbXn\EM)\200\184\154ZeB\a\136Q+\233\158B",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\r\182,I",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("G\130\251\147\twO",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\188",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Q\EM\214h\"_\196\253z\ACK\211F7\211D\144\NUL",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(")\213\149\ACK",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS0}),("\222\RS\248\196\163\204P",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\160hI\180~R7W\238",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\174\215\218\172V{\162\237\153\169\144\SO\STXM\190\n\135U\180\173\SYN\244\&5\227$\154\ACK\194\249\249",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0xb4, 0x1, 0x5, 0x26, 0x0, 0x1, 0x8d, 0x2, 0x0, 0x15, 0x28, 0xe8, 0x6c, 0x93, 0xe7, 0x17, - 0x81, 0xbc, 0x36, 0xcf, 0xe, 0xb6, 0xf4, 0xe1, 0xc1, 0x53, 0xe4, 0x37, 0xb3, 0x7f, 0xdc, 0x2, 0x0, - 0x17, 0xf1, 0xa8, 0x0, 0x8f, 0xe9, 0x6d, 0xb8, 0xa3, 0x2, 0xda, 0x38, 0x9c, 0xfc, 0xfa, 0x69, 0xb8, - 0x43, 0xbc, 0x42, 0xa7, 0xc5, 0xe0, 0x41, 0x2, 0x0, 0x17, 0xb1, 0x73,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0x14, 0x22, 0xaa, + 0x1, 0x0, 0x14, 0x8, 0x72, 0x0, 0x5, 0x5d, 0xdd, 0x3, 0x6b, 0x4c, 0xbe, 0x6f, 0xee, 0x2e, + 0x23, 0xe3, 0xe6, 0x19, 0xa9, 0x77, 0x64, 0x1, 0x0, 0x19, 0xbd, 0xe0, 0xe6, 0x30, 0x78, 0x24, + 0x4, 0x62, 0x58, 0x6e, 0x19, 0x29, 0xc8, 0xb8, 0x9a, 0x5a, 0x65, 0x42, 0x7, 0x88, 0x51, 0x2b, + 0xe9, 0x9e, 0x42, 0x2, 0x0, 0x4, 0xd, 0xb6, 0x2c, 0x49, 0x2, 0x0, 0x7, 0x47, 0x82, 0xfb, + 0x93, 0x9, 0x77, 0x4f, 0x2, 0x0, 0x1, 0xbc, 0x0, 0x0, 0x7, 0xde, 0x1e, 0xf8, 0xc4, 0xa3, + 0xcc, 0x50, 0x0, 0x0, 0x9, 0xa0, 0x68, 0x49, 0xb4, 0x7e, 0x52, 0x37, 0x57, 0xee, 0x2, 0x0, + 0x1e, 0xae, 0xd7, 0xda, 0xac, 0x56, 0x7b, 0xa2, 0xed, 0x99, 0xa9, 0x90, 0xe, 0x2, 0x4d, 0xbe, + 0xa, 0x87, 0x55, 0xb4, 0xad, 0x16, 0xf4, 0x35, 0xe3, 0x24, 0x9a, 0x6, 0xc2, 0xf9, 0xf9, 0x0}; + + uint8_t buf[202] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x8d}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xde, 0x16, 0x32, 0x34, 0x3a, 0x9c, 0xca, 0xc, 0x84, 0x3, 0xba, 0xf0}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x28, 0xe8, 0x6c, 0x93, 0xe7, 0x17, 0x81, 0xbc, 0x36, 0xcf, 0xe, - 0xb6, 0xf4, 0xe1, 0xc1, 0x53, 0xe4, 0x37, 0xb3, 0x7f, 0xdc}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb, 0x8, 0x41, 0x46, 0xf5, 0x35, 0xe7, 0xb5, 0xd3, 0x38, 0x38, 0xb4, 0xf4, + 0xe0, 0x71, 0xf5, 0x32, 0x89, 0x7c, 0x7c, 0x92, 0x32, 0x1b, 0xba, 0x70, 0x60}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf1, 0xa8, 0x0, 0x8f, 0xe9, 0x6d, 0xb8, 0xa3, 0x2, 0xda, 0x38, 0x9c, - 0xfc, 0xfa, 0x69, 0xb8, 0x43, 0xbc, 0x42, 0xa7, 0xc5, 0xe0, 0x41}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7a, 0x2d, 0x51, 0x3, 0xfa, 0x7d, 0xa8, 0x48, 0xde, 0x89, 0x14, 0x22, 0xaa}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb1, 0x73, 0xaa, 0x7b, 0x60, 0x22, 0x65, 0x1e, 0x72, 0x13, 0xd, 0x5b, - 0xd7, 0x82, 0x96, 0xc7, 0x71, 0xfd, 0xd8, 0xdd, 0xe7, 0x3b, 0x16}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x8, 0x72, 0x0, 0x5, 0x5d, 0xdd, 0x3, 0x6b, 0x4c, 0xbe, + 0x6f, 0xee, 0x2e, 0x23, 0xe3, 0xe6, 0x19, 0xa9, 0x77, 0x64}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xfe, 0x2a, 0xa4, 0x0, 0x2e, 0xc6, 0xed, 0xe3, 0x33, 0x8f, - 0x1a, 0xf8, 0xf8, 0xa2, 0x9, 0xa7, 0xa, 0x92, 0xe8, 0xfa, - 0x41, 0x4b, 0xea, 0xdc, 0xb2, 0x66, 0xcd, 0xd2, 0xe2}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xbd, 0xe0, 0xe6, 0x30, 0x78, 0x24, 0x4, 0x62, 0x58, 0x6e, 0x19, 0x29, 0xc8, + 0xb8, 0x9a, 0x5a, 0x65, 0x42, 0x7, 0x88, 0x51, 0x2b, 0xe9, 0x9e, 0x42}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x9f, 0x7d, 0x41, 0x5f, 0xdd, 0x42, 0xbe, 0x8f, - 0x35, 0xa, 0x0, 0xba, 0x7a, 0x29, 0x8f}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xd, 0xb6, 0x2c, 0x49}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xd, 0x30, 0x11, 0xa, 0xe2, 0x4b, 0xc9, 0xb1, 0x80, - 0x1f, 0x3a, 0xed, 0x6f, 0xf1, 0x49, 0xba, 0x64, 0x7c}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x47, 0x82, 0xfb, 0x93, 0x9, 0x77, 0x4f}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x51, 0x19, 0xd6, 0x68, 0x22, 0x5f, 0xc4, 0xfd, 0x7a, - 0x6, 0xd3, 0x46, 0x37, 0xd3, 0x44, 0x90, 0x0}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xbc}; + lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x29, 0xd5, 0x95, 0x6}; - lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xde, 0x1e, 0xf8, 0xc4, 0xa3, 0xcc, 0x50}; + lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t topic_filter_s9_bytes[] = {0xa0, 0x68, 0x49, 0xb4, 0x7e, 0x52, 0x37, 0x57, 0xee}; + lwmqtt_string_t topic_filter_s9 = {9, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xae, 0xd7, 0xda, 0xac, 0x56, 0x7b, 0xa2, 0xed, 0x99, 0xa9, + 0x90, 0xe, 0x2, 0x4d, 0xbe, 0xa, 0x87, 0x55, 0xb4, 0xad, + 0x16, 0xf4, 0x35, 0xe3, 0x24, 0x9a, 0x6, 0xc2, 0xf9, 0xf9}; + lwmqtt_string_t topic_filter_s10 = {30, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1318, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13111, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4255 -// [("\180\179\158\152\140\184\134\243\150\253\DELV\188\SIa\US\207\DEL\234C\tl\186p*M\209\246\162",SubOptions +// SubscribeRequest 22578 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = +// QoS2}),("Y\180\175\251o\184au\195\159\207(+B\f\233\165\201\242\165\130\246Y\187q\CANg\155",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("/\140^\ESC#\181^Ia%o\229mJ\166XA\DELA\183l;S_l\133^",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\159\&8\162\SYN\188\181",SubOptions {_retainHandling +// QoS2}),("R,\DC1w\SI\227c}",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\134\NUL\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\US6\195Ct\137l\EOT\155\185\230\144\143H\n\vU!\196",SubOptions {_retainHandling // = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\253\&9-\SOH\n\189\207\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1})] [] +// QoS1}),("\195T\236\253h\n\197\181\188\199\206\134\174\196\215\FS\165\227'\220\DC1m}\206\164;\249\SOHR",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x54, 0x10, 0x9f, 0x0, 0x1d, 0xb4, 0xb3, 0x9e, 0x98, 0x8c, 0xb8, 0x86, 0xf3, 0x96, - 0xfd, 0x7f, 0x56, 0xbc, 0xf, 0x61, 0x1f, 0xcf, 0x7f, 0xea, 0x43, 0x9, 0x6c, 0xba, 0x70, - 0x2a, 0x4d, 0xd1, 0xf6, 0xa2, 0x0, 0x0, 0x1b, 0x2f, 0x8c, 0x5e, 0x1b, 0x23, 0xb5, 0x5e, - 0x49, 0x61, 0x25, 0x6f, 0xe5, 0x6d, 0x4a, 0xa6, 0x58, 0x41, 0x7f, 0x41, 0xb7, 0x6c, 0x3b, - 0x53, 0x5f, 0x6c, 0x85, 0x5e, 0x0, 0x0, 0x6, 0x9f, 0x38, 0xa2, 0x16, 0xbc, 0xb5, 0x1, - 0x0, 0x8, 0xfd, 0x39, 0x2d, 0x1, 0xa, 0xbd, 0xcf, 0xdb, 0x1}; + uint8_t pkt[] = {0x82, 0x6e, 0x58, 0x32, 0x0, 0x0, 0x2, 0x0, 0x1c, 0x59, 0xb4, 0xaf, 0xfb, 0x6f, 0xb8, 0x61, + 0x75, 0xc3, 0x9f, 0xcf, 0x28, 0x2b, 0x42, 0xc, 0xe9, 0xa5, 0xc9, 0xf2, 0xa5, 0x82, 0xf6, 0x59, + 0xbb, 0x71, 0x18, 0x67, 0x9b, 0x2, 0x0, 0x8, 0x52, 0x2c, 0x11, 0x77, 0xf, 0xe3, 0x63, 0x7d, + 0x1, 0x0, 0x3, 0x86, 0x0, 0xe8, 0x0, 0x0, 0x0, 0x1, 0x0, 0x13, 0x1f, 0x36, 0xc3, 0x43, + 0x74, 0x89, 0x6c, 0x4, 0x9b, 0xb9, 0xe6, 0x90, 0x8f, 0x48, 0xa, 0xb, 0x55, 0x21, 0xc4, 0x1, + 0x0, 0x1d, 0xc3, 0x54, 0xec, 0xfd, 0x68, 0xa, 0xc5, 0xb5, 0xbc, 0xc7, 0xce, 0x86, 0xae, 0xc4, + 0xd7, 0x1c, 0xa5, 0xe3, 0x27, 0xdc, 0x11, 0x6d, 0x7d, 0xce, 0xa4, 0x3b, 0xf9, 0x1, 0x52, 0x2}; - uint8_t buf[96] = {0}; + uint8_t buf[122] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xb4, 0xb3, 0x9e, 0x98, 0x8c, 0xb8, 0x86, 0xf3, 0x96, 0xfd, - 0x7f, 0x56, 0xbc, 0xf, 0x61, 0x1f, 0xcf, 0x7f, 0xea, 0x43, - 0x9, 0x6c, 0xba, 0x70, 0x2a, 0x4d, 0xd1, 0xf6, 0xa2}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2f, 0x8c, 0x5e, 0x1b, 0x23, 0xb5, 0x5e, 0x49, 0x61, 0x25, 0x6f, 0xe5, 0x6d, 0x4a, - 0xa6, 0x58, 0x41, 0x7f, 0x41, 0xb7, 0x6c, 0x3b, 0x53, 0x5f, 0x6c, 0x85, 0x5e}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x59, 0xb4, 0xaf, 0xfb, 0x6f, 0xb8, 0x61, 0x75, 0xc3, 0x9f, + 0xcf, 0x28, 0x2b, 0x42, 0xc, 0xe9, 0xa5, 0xc9, 0xf2, 0xa5, + 0x82, 0xf6, 0x59, 0xbb, 0x71, 0x18, 0x67, 0x9b}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9f, 0x38, 0xa2, 0x16, 0xbc, 0xb5}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x52, 0x2c, 0x11, 0x77, 0xf, 0xe3, 0x63, 0x7d}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfd, 0x39, 0x2d, 0x1, 0xa, 0xbd, 0xcf, 0xdb}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x86, 0x0, 0xe8}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1f, 0x36, 0xc3, 0x43, 0x74, 0x89, 0x6c, 0x4, 0x9b, 0xb9, + 0xe6, 0x90, 0x8f, 0x48, 0xa, 0xb, 0x55, 0x21, 0xc4}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc3, 0x54, 0xec, 0xfd, 0x68, 0xa, 0xc5, 0xb5, 0xbc, 0xc7, + 0xce, 0x86, 0xae, 0xc4, 0xd7, 0x1c, 0xa5, 0xe3, 0x27, 0xdc, + 0x11, 0x6d, 0x7d, 0xce, 0xa4, 0x3b, 0xf9, 0x1, 0x52}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4255, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22578, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8790 [("BZ_)",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\244x\187\186\255\245oy\163<\181\242J3\202-",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("'8\171[\231\210\133\201\GSP\238\199\163'\182bO@\226\RS?\SO@\244uRA\SI2",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("W\239\192\&2\217\184?\141\&7\FSL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\200h\214",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\187\DC2\tI\174\251I\ETB\FS\NAK\148\DC4\136Je\193|\216V)j",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 5714 [("Z\154\192",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("n\209\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\236[5",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1}),("+l\193\192-m.\NUL\128\147\191\196\DC4\255 +// \250\233P\183w\192\176F-\192\208\158\201\172\231",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("A\222\209\219\SO\f\212\243or\200\&4",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0x68, 0x22, 0x56, 0x0, 0x4, 0x42, 0x5a, 0x5f, 0x29, 0x0, 0x0, 0x10, 0xf4, 0x78, 0xbb, - 0xba, 0xff, 0xf5, 0x6f, 0x79, 0xa3, 0x3c, 0xb5, 0xf2, 0x4a, 0x33, 0xca, 0x2d, 0x0, 0x0, 0x1d, - 0x27, 0x38, 0xab, 0x5b, 0xe7, 0xd2, 0x85, 0xc9, 0x1d, 0x50, 0xee, 0xc7, 0xa3, 0x27, 0xb6, 0x62, - 0x4f, 0x40, 0xe2, 0x1e, 0x3f, 0xe, 0x40, 0xf4, 0x75, 0x52, 0x41, 0xf, 0x32, 0x2, 0x0, 0xb, - 0x57, 0xef, 0xc0, 0x32, 0xd9, 0xb8, 0x3f, 0x8d, 0x37, 0x1c, 0x4c, 0x2, 0x0, 0x3, 0xc8, 0x68, - 0xd6, 0x0, 0x0, 0x15, 0xbb, 0x12, 0x9, 0x49, 0xae, 0xfb, 0x49, 0x17, 0x1c, 0x15, 0x94, 0x14, - 0x88, 0x4a, 0x65, 0xc1, 0x7c, 0xd8, 0x56, 0x29, 0x6a, 0x0}; - - uint8_t buf[116] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x42, 0x5a, 0x5f, 0x29}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x44, 0x16, 0x52, 0x0, 0x3, 0x5a, 0x9a, 0xc0, 0x0, 0x0, 0x3, 0x6e, 0xd1, + 0x83, 0x2, 0x0, 0x3, 0xec, 0x5b, 0x35, 0x1, 0x0, 0x1e, 0x2b, 0x6c, 0xc1, 0xc0, + 0x2d, 0x6d, 0x2e, 0x0, 0x80, 0x93, 0xbf, 0xc4, 0x14, 0xff, 0x20, 0xfa, 0xe9, 0x50, + 0xb7, 0x77, 0xc0, 0xb0, 0x46, 0x2d, 0xc0, 0xd0, 0x9e, 0xc9, 0xac, 0xe7, 0x1, 0x0, + 0xc, 0x41, 0xde, 0xd1, 0xdb, 0xe, 0xc, 0xd4, 0xf3, 0x6f, 0x72, 0xc8, 0x34, 0x1}; + + uint8_t buf[80] = {0}; + + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x5a, 0x9a, 0xc0}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf4, 0x78, 0xbb, 0xba, 0xff, 0xf5, 0x6f, 0x79, - 0xa3, 0x3c, 0xb5, 0xf2, 0x4a, 0x33, 0xca, 0x2d}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6e, 0xd1, 0x83}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x27, 0x38, 0xab, 0x5b, 0xe7, 0xd2, 0x85, 0xc9, 0x1d, 0x50, - 0xee, 0xc7, 0xa3, 0x27, 0xb6, 0x62, 0x4f, 0x40, 0xe2, 0x1e, - 0x3f, 0xe, 0x40, 0xf4, 0x75, 0x52, 0x41, 0xf, 0x32}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xec, 0x5b, 0x35}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x57, 0xef, 0xc0, 0x32, 0xd9, 0xb8, 0x3f, 0x8d, 0x37, 0x1c, 0x4c}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x2b, 0x6c, 0xc1, 0xc0, 0x2d, 0x6d, 0x2e, 0x0, 0x80, 0x93, + 0xbf, 0xc4, 0x14, 0xff, 0x20, 0xfa, 0xe9, 0x50, 0xb7, 0x77, + 0xc0, 0xb0, 0x46, 0x2d, 0xc0, 0xd0, 0x9e, 0xc9, 0xac, 0xe7}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc8, 0x68, 0xd6}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x41, 0xde, 0xd1, 0xdb, 0xe, 0xc, 0xd4, 0xf3, 0x6f, 0x72, 0xc8, 0x34}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xbb, 0x12, 0x9, 0x49, 0xae, 0xfb, 0x49, 0x17, 0x1c, 0x15, 0x94, - 0x14, 0x88, 0x4a, 0x65, 0xc1, 0x7c, 0xd8, 0x56, 0x29, 0x6a}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8790, 6, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5714, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28419 [("\172\146\187b\165\234\194\249&",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("&\154ju i",SubOptions {_retainHandling = +// SubscribeRequest 3531 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\254\134x\175,x\231\DC3\SOHJ\EOT",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\132bW\232H.\t\251\ACK\185\246\221\163",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\240\158)|E\240\&8\229\159#3\US$\GS\163\142\184\204\a\254\249\NAK\212}",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\196\DC4\v\a\177\139Fn\195",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("m\205\237M\200/\184hq79.3\134,\188\154\r\211\201\143\CAN\223\SYN -// \200v\164<",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ENQ\241`\255\207+~",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1})] [] +// QoS2}),(".\US\239\142\182M\DC2\228v\142",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\145\239\128\212\215v\211R\239\248\165M\231oh\163\192PE\213\174\249\165\218\ETB\148",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("'\251\128\148 +// \133P@7h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\v\210V\DLE\245\137\166\n\v!:\NAK\231Y\SYN\215\n\247\191g\147\RS\STX",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("FH\178&\154",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0x4d, 0x6f, 0x3, 0x0, 0x9, 0xac, 0x92, 0xbb, 0x62, 0xa5, 0xea, 0xc2, 0xf9, 0x26, 0x0, - 0x0, 0x6, 0x26, 0x9a, 0x6a, 0x75, 0x20, 0x69, 0x1, 0x0, 0x9, 0xc4, 0x14, 0xb, 0x7, 0xb1, - 0x8b, 0x46, 0x6e, 0xc3, 0x1, 0x0, 0x1d, 0x6d, 0xcd, 0xed, 0x4d, 0xc8, 0x2f, 0xb8, 0x68, 0x71, - 0x37, 0x39, 0x2e, 0x33, 0x86, 0x2c, 0xbc, 0x9a, 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167] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xac, 0x92, 0xbb, 0x62, 0xa5, 0xea, 0xc2, 0xf9, 0x26}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x26, 0x9a, 0x6a, 0x75, 0x20, 0x69}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xfe, 0x86, 0x78, 0xaf, 0x2c, 0x78, 0xe7, 0x13, 0x1, 0x4a, 0x4}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc4, 0x14, 0xb, 0x7, 0xb1, 0x8b, 0x46, 0x6e, 0xc3}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x84, 0x62, 0x57, 0xe8, 0x48, 0x2e, 0x9, 0xfb, 0x6, 0xb9, 0xf6, 0xdd, 0xa3}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6d, 0xcd, 0xed, 0x4d, 0xc8, 0x2f, 0xb8, 0x68, 0x71, 0x37, - 0x39, 0x2e, 0x33, 0x86, 0x2c, 0xbc, 0x9a, 0xd, 0xd3, 0xc9, - 0x8f, 0x18, 0xdf, 0x16, 0x20, 0xc8, 0x76, 0xa4, 0x3c}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf0, 0x9e, 0x29, 0x7c, 0x45, 0xf0, 0x38, 0xe5, 0x9f, 0x23, 0x33, 0x1f, + 0x24, 0x1d, 0xa3, 0x8e, 0xb8, 0xcc, 0x7, 0xfe, 0xf9, 0x15, 0xd4, 0x7d}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5, 0xf1, 0x60, 0xff, 0xcf, 0x2b, 0x7e}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2e, 0x1f, 0xef, 0x8e, 0xb6, 0x4d, 0x12, 0xe4, 0x76, 0x8e}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t topic_filter_s5_bytes[] = {0x91, 0xef, 0x80, 0xd4, 0xd7, 0x76, 0xd3, 0x52, 0xef, 0xf8, 0xa5, 0x4d, 0xe7, + 0x6f, 0x68, 0xa3, 0xc0, 0x50, 0x45, 0xd5, 0xae, 0xf9, 0xa5, 0xda, 0x17, 0x94}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x27, 0xfb, 0x80, 0x94, 0x20, 0x85, 0x50, 0x40, 0x37, 0x68}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xb, 0xd2, 0x56, 0x10, 0xf5, 0x89, 0xa6, 0xa, 0xb, 0x21, 0x3a, 0x15, + 0xe7, 0x59, 0x16, 0xd7, 0xa, 0xf7, 0xbf, 0x67, 0x93, 0x1e, 0x2}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0}; + lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x46, 0x48, 0xb2, 0x26, 0x9a}; + lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28419, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3531, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 5081 [("Zq\ETB\209",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),("\254\248\251$\238\158f\176\218\152\154A\147\STX^\184'w\188\&2{\US\165I\vF\139",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\164\143V*3\253\171\214\141x.\184\242l\217\&2\255\ENQ",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 27385 [("\203r\138\235\US\213\196\158\177\226",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\171E\173\162L\158>9\a\202\138\223Jb{\170Y8\RS\137\226\166I\177J",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\185\188",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0x60, 0x13, 0xd9, 0x0, 0x4, 0x5a, 0x71, 0x17, 0xd1, 0x0, 0x0, 0x1b, 0xfe, 0xf8, 0xfb, 0x24, - 0xee, 0x9e, 0x66, 0xb0, 0xda, 0x98, 0x9a, 0x41, 0x93, 0x2, 0x5e, 0xb8, 0x27, 0x77, 0xbc, 0x32, 0x7b, - 0x1f, 0xa5, 0x49, 0xb, 0x46, 0x8b, 0x1, 0x0, 0x12, 0xa4, 0x8f, 0x56, 0x2a, 0x33, 0xfd, 0xab, 0xd6, - 0x8d, 0x78, 0x2e, 0xb8, 0xf2, 0x6c, 0xd9, 0x32, 0xff, 0x5, 0x1, 0x0, 0x19, 0xab, 0x45, 0xad, 0xa2, - 0x4c, 0x9e, 0x3e, 0x39, 0x7, 0xca, 0x8a, 0xdf, 0x4a, 0x62, 0x7b, 0xaa, 0x59, 0x38, 0x1e, 0x89, 0xe2, - 0xa6, 0x49, 0xb1, 0x4a, 0x2, 0x0, 0x2, 0xb9, 0xbc, 0x2, 0x0, 0x0, 0x1}; - - uint8_t buf[108] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x5a, 0x71, 0x17, 0xd1}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; +// QoS1}),("\210\190\198\&0ofo\DC1|E\r\rL\152\233\224d\199",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\237\&4\212\155\143\216\v\200\DEL\206\242\145\213W\133\216HU\FSK",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\149\ETX\DC3%\228\238+\165\167r\NAKr\178\170",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("4\244y\238\205\153\213",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\135",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\187\224\219\172\\$\133[rk\157\200\159O\ENQ@\167\217\254F\213\130\&4",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("}\ENQ\233z\235\223\134Z\220y\220\255\ACK\f8\r\211\178\171\145=\183\148\DC4\187{S:\215\247",SubOptions +// SubscribeRequest 22666 [("G\DLE\141c\141\r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\DLEq\227\252\175\246{\157\250\NUL\231",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\175\SO.Id[",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("SL0j\ENQ\STX\v\178\243,\155\168-3\RS*R\246\NAK\134f)\183\196",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\t\185T\132Z\205GI\DC2\146\156\233\201\134k\142\168\247\201=\179\134\&1",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\200\160\129\198|>\238\159\254\255\CANc\149\154\139\167#\234n",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\169\216=\154v",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("9\254'\139~\175N\ETX\172\240\223\&5^\171\"\163\222\225*\182\&2,\254\&6\174\EM2\f\227",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("o\SOH\195\158\&0R\138\250",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\EM\SYN\174\218\152k\247\&5i_\205`,\fm*\131_",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\163n)\179A=<\NUL\US\199\129\163\137+u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode12) { +// QoS1}),("p\210\142F\178\242R\233\138\188\253$$r\142\SYN\244\167k\195",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSubscriptionIdentifier +// 11,PropAssignedClientIdentifier "r",PropSubscriptionIdentifier 21,PropMaximumQoS 17,PropSessionExpiryInterval +// 25518,PropSubscriptionIdentifierAvailable 52,PropAuthenticationMethod +// "Vl\175z'\GS\DC3\176\131\238\194\201\247\165\&4\143\240\234\201",PropServerKeepAlive 7849,PropSubscriptionIdentifier +// 31,PropReceiveMaximum 29865,PropMaximumPacketSize 6256,PropRetainAvailable 83,PropRetainAvailable +// 104,PropUserProperty "\ax\198\170\185\135\247;\250\245Fv\186W\CAN\SOH\155\178\150\223\SYN\174\170>{n\138" +// "}\a\nj\GS\191U\238\192\204\&4\213.\238\178j\DEL\255\222\167\190\&7\218\144\US(\SOH",PropContentType +// "p\232-\135\244\&4\220O{F\192\ESC z\166a\213\183\133Z@4\132\155\EOTiy"] +TEST(Subscribe5QCTest, Encode2)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0xa6, 0x61, 0xd5, 0xb7, 0x85, 0x5a, 0x40, 0x34, 0x84, 0x9b, 0x4, 0x69, 0x79, + 0x0, 0x6, 0x47, 0x10, 0x8d, 0x63, 0x8d, 0xd, 0x2, 0x0, 0xb, 0x10, 0x71, 0xe3, 0xfc, 0xaf, 0xf6, 0x7b, 0x9d, + 0xfa, 0x0, 0xe7, 0x0, 0x0, 0x6, 0xaf, 0xe, 0x2e, 0x49, 0x64, 0x5b, 0x1, 0x0, 0x14, 0x70, 0xd2, 0x8e, 0x46, + 0xb2, 0xf2, 0x52, 0xe9, 0x8a, 0xbc, 0xfd, 0x24, 0x24, 0x72, 0x8e, 0x16, 0xf4, 0xa7, 0x6b, 0xc3, 0x2}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xc4, 0xea, 0xe9, 0x43, 0xf5, 0x2, 0xe5, 0x9a, 0x9, - 0x1f, 0xd, 0x8, 0x26, 0x3e, 0x46, 0xd5, 0x82, 0x34}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7d, 0x5, 0xe9, 0x7a, 0xeb, 0xdf, 0x86, 0x5a, 0xdc, 0x79, - 0xdc, 0xff, 0x6, 0xc, 0x38, 0xd, 0xd3, 0xb2, 0xab, 0x91, - 0x3d, 0xb7, 0x94, 0x14, 0xbb, 0x7b, 0x53, 0x3a, 0xd7, 0xf7}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x53, 0x4c, 0x30, 0x6a, 0x5, 0x2, 0xb, 0xb2, 0xf3, 0x2c, 0x9b, 0xa8, - 0x2d, 0x33, 0x1e, 0x2a, 0x52, 0xf6, 0x15, 0x86, 0x66, 0x29, 0xb7, 0xc4}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9, 0xb9, 0x54, 0x84, 0x5a, 0xcd, 0x47, 0x49, 0x12, 0x92, 0x9c, 0xe9, - 0xc9, 0x86, 0x6b, 0x8e, 0xa8, 0xf7, 0xc9, 0x3d, 0xb3, 0x86, 0x31}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc8, 0xa0, 0x81, 0xc6, 0x7c, 0x3e, 0xee, 0x9f, 0xfe, 0xff, - 0x18, 0x63, 0x95, 0x9a, 0x8b, 0xa7, 0x23, 0xea, 0x6e}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa9, 0xd8, 0x3d, 0x9a, 0x76}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x39, 0xfe, 0x27, 0x8b, 0x7e, 0xaf, 0x4e, 0x3, 0xac, 0xf0, - 0xdf, 0x35, 0x5e, 0xab, 0x22, 0xa3, 0xde, 0xe1, 0x2a, 0xb6, - 0x32, 0x2c, 0xfe, 0x36, 0xae, 0x19, 0x32, 0xc, 0xe3}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6f, 0x1, 0xc3, 0x9e, 0x30, 0x52, 0x8a, 0xfa}; - lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x19, 0x16, 0xae, 0xda, 0x98, 0x6b, 0xf7, 0x35, 0x69, - 0x5f, 0xcd, 0x60, 0x2c, 0xc, 0x6d, 0x2a, 0x83, 0x5f}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa3, 0x6e, 0x29, 0xb3, 0x41, 0x3d, 0x3c, 0x0, - 0x1f, 0xc7, 0x81, 0xa3, 0x89, 0x2b, 0x75}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0}; - lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25469, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14214 [("96\SIk\238a\SI\ETX\203\216\176fgS\149\148\229\206$",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\242\218\225YA\243\153\247\189I",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("1\141\ENQ\206\182U",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0x32, 0x37, 0x86, 0x0, 0x13, 0x39, 0x36, 0xf, 0x6b, 0xee, 0x61, 0xf, - 0x3, 0xcb, 0xd8, 0xb0, 0x66, 0x67, 0x53, 0x95, 0x94, 0xe5, 0xce, 0x24, 0x2, - 0x0, 0xa, 0xf2, 0xda, 0xe1, 0x59, 0x41, 0xf3, 0x99, 0xf7, 0xbd, 0x49, 0x1, - 0x0, 0x1, 0xeb, 0x0, 0x0, 0x6, 0x31, 0x8d, 0x5, 0xce, 0xb6, 0x55, 0x0}; - - uint8_t buf[62] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x39, 0x36, 0xf, 0x6b, 0xee, 0x61, 0xf, 0x3, 0xcb, 0xd8, - 0xb0, 0x66, 0x67, 0x53, 0x95, 0x94, 0xe5, 0xce, 0x24}; - lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf2, 0xda, 0xe1, 0x59, 0x41, 0xf3, 0x99, 0xf7, 0xbd, 0x49}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xeb}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x31, 0x8d, 0x5, 0xce, 0xb6, 0x55}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14214, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 26235 [("\DLE",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("m;1\220gk`\169\152\251",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\SIj6\144\200ar\STX",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\241c\229\NULx\190Q\SYN",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0x29, 0x66, 0x7b, 0x0, 0x1, 0x10, 0x1, 0x0, 0xa, 0x6d, 0x3b, 0x31, 0xdc, 0x67, - 0x6b, 0x60, 0xa9, 0x98, 0xfb, 0x1, 0x0, 0x8, 0xf, 0x6a, 0x36, 0x90, 0xc8, 0x61, 0x72, - 0x2, 0x0, 0x0, 0x8, 0xf1, 0x63, 0xe5, 0x0, 0x78, 0xbe, 0x51, 0x16, 0x0}; - - uint8_t buf[53] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x10}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6d, 0x3b, 0x31, 0xdc, 0x67, 0x6b, 0x60, 0xa9, 0x98, 0xfb}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf, 0x6a, 0x36, 0x90, 0xc8, 0x61, 0x72, 0x2}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf1, 0x63, 0xe5, 0x0, 0x78, 0xbe, 0x51, 0x16}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26235, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 10474 [("\ACK\214li.\ESC\US;\201}3\165",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\152\173{\218\168a\184Y_y\149\241F:y\188",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\147\ESC\141H\166\226\230G\180\252\198\196\GS",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\236\183\RSM\169v\254\179TT7\211\194\132\161fbQ\218\US\135\202\f\149E\197\197\SOHuK",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("3\179|)\222p\245\SUB\197\v\182\RSnw#\225\157t\ETX\DC2E",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\233\213\221\219\SUB0\164J\162\185\156\230\230\&5\156\244\133",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("d\NULN\129\242u`\152\ACK\DEL_\164\207\168\191T\132\177\"\FS*",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\136f7w\182\132'",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\220w'\179\FSxy\194[@\163;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("9H\134H\191\242[\206S\129\162\243\244Kw$",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode15) { - uint8_t pkt[] = { - 0x82, 0xca, 0x1, 0x28, 0xea, 0x0, 0x11, 0x6, 0xd6, 0x6c, 0x69, 0x2e, 0x1b, 0x1f, 0x3b, 0x3c, 0x4f, 0x5d, 0x74, - 0x3e, 0xc9, 0x7d, 0x33, 0xa5, 0x0, 0x0, 0x10, 0x98, 0xad, 0x7b, 0xda, 0xa8, 0x61, 0xb8, 0x59, 0x5f, 0x79, 0x95, - 0xf1, 0x46, 0x3a, 0x79, 0xbc, 0x2, 0x0, 0xd, 0x93, 0x1b, 0x8d, 0x48, 0xa6, 0xe2, 0xe6, 0x47, 0xb4, 0xfc, 0xc6, - 0xc4, 0x1d, 0x2, 0x0, 0x1e, 0xec, 0xb7, 0x1e, 0x4d, 0xa9, 0x76, 0xfe, 0xb3, 0x54, 0x54, 0x37, 0xd3, 0xc2, 0x84, - 0xa1, 0x66, 0x62, 0x51, 0xda, 0x1f, 0x87, 0xca, 0xc, 0x95, 0x45, 0xc5, 0xc5, 0x1, 0x75, 0x4b, 0x0, 0x0, 0x15, - 0x33, 0xb3, 0x7c, 0x29, 0xde, 0x70, 0xf5, 0x1a, 0xc5, 0xb, 0xb6, 0x1e, 0x6e, 0x77, 0x23, 0xe1, 0x9d, 0x74, 0x3, - 0x12, 0x45, 0x1, 0x0, 0x11, 0xe9, 0xd5, 0xdd, 0xdb, 0x1a, 0x30, 0xa4, 0x4a, 0xa2, 0xb9, 0x9c, 0xe6, 0xe6, 0x35, - 0x9c, 0xf4, 0x85, 0x2, 0x0, 0x15, 0x64, 0x0, 0x4e, 0x81, 0xf2, 0x75, 0x60, 0x98, 0x6, 0x7f, 0x5f, 0xa4, 0xcf, - 0xa8, 0xbf, 0x54, 0x84, 0xb1, 0x22, 0x1c, 0x2a, 0x2, 0x0, 0x7, 0x88, 0x66, 0x37, 0x77, 0xb6, 0x84, 0x27, 0x2, - 0x0, 0xc, 0xdc, 0x77, 0x27, 0xb3, 0x1c, 0x78, 0x79, 0xc2, 0x5b, 0x40, 0xa3, 0x3b, 0x2, 0x0, 0x10, 0x39, 0x48, - 0x86, 0x48, 0xbf, 0xf2, 0x5b, 0xce, 0x53, 0x81, 0xa2, 0xf3, 0xf4, 0x4b, 0x77, 0x24, 0x1}; - - uint8_t buf[215] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x6, 0xd6, 0x6c, 0x69, 0x2e, 0x1b, 0x1f, 0x3b, 0x3c, - 0x4f, 0x5d, 0x74, 0x3e, 0xc9, 0x7d, 0x33, 0xa5}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x98, 0xad, 0x7b, 0xda, 0xa8, 0x61, 0xb8, 0x59, - 0x5f, 0x79, 0x95, 0xf1, 0x46, 0x3a, 0x79, 0xbc}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x93, 0x1b, 0x8d, 0x48, 0xa6, 0xe2, 0xe6, 0x47, 0xb4, 0xfc, 0xc6, 0xc4, 0x1d}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xec, 0xb7, 0x1e, 0x4d, 0xa9, 0x76, 0xfe, 0xb3, 0x54, 0x54, - 0x37, 0xd3, 0xc2, 0x84, 0xa1, 0x66, 0x62, 0x51, 0xda, 0x1f, - 0x87, 0xca, 0xc, 0x95, 0x45, 0xc5, 0xc5, 0x1, 0x75, 0x4b}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x33, 0xb3, 0x7c, 0x29, 0xde, 0x70, 0xf5, 0x1a, 0xc5, 0xb, 0xb6, - 0x1e, 0x6e, 0x77, 0x23, 0xe1, 0x9d, 0x74, 0x3, 0x12, 0x45}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe9, 0xd5, 0xdd, 0xdb, 0x1a, 0x30, 0xa4, 0x4a, 0xa2, - 0xb9, 0x9c, 0xe6, 0xe6, 0x35, 0x9c, 0xf4, 0x85}; - lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x64, 0x0, 0x4e, 0x81, 0xf2, 0x75, 0x60, 0x98, 0x6, 0x7f, 0x5f, - 0xa4, 0xcf, 0xa8, 0xbf, 0x54, 0x84, 0xb1, 0x22, 0x1c, 0x2a}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x88, 0x66, 0x37, 0x77, 0xb6, 0x84, 0x27}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xdc, 0x77, 0x27, 0xb3, 0x1c, 0x78, 0x79, 0xc2, 0x5b, 0x40, 0xa3, 0x3b}; - lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x39, 0x48, 0x86, 0x48, 0xbf, 0xf2, 0x5b, 0xce, - 0x53, 0x81, 0xa2, 0xf3, 0xf4, 0x4b, 0x77, 0x24}; - lwmqtt_string_t topic_filter_s9 = {16, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10474, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 3250 [("x\215}:\240\130\FS\DC3r\185\253t\214\&4\231\195dG<\187\f",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\ETB\236&\173\154\233\&7\EOT~",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("!\CAN\STX\GSG;\179\203\n\224\213",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\208d*\128\&7+\217w\"\f\250\ENQ\189\159\234\236\247\238\ACK0\195",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\155\218X\182O\200\175-#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\219\217L\214\219",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("A\235\201\159~{C\168\132nu\ETB",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\159jI\215+\216\176`\223\230\169\155\239\249q6",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0x82, 0x1, 0xc, 0xb2, 0x0, 0x15, 0x78, 0xd7, 0x7d, 0x3a, 0xf0, 0x82, 0x1c, 0x13, 0x72, 0xb9, - 0xfd, 0x74, 0xd6, 0x34, 0xe7, 0xc3, 0x64, 0x47, 0x3c, 0xbb, 0xc, 0x0, 0x0, 0x9, 0x17, 0xec, 0x26, - 0xad, 0x9a, 0xe9, 0x37, 0x4, 0x7e, 0x2, 0x0, 0xb, 0x21, 0x18, 0x2, 0x1d, 0x47, 0x3b, 0xb3, 0xcb, - 0xa, 0xe0, 0xd5, 0x0, 0x0, 0x15, 0xd0, 0x64, 0x2a, 0x80, 0x37, 0x2b, 0xd9, 0x77, 0x22, 0xc, 0xfa, - 0x5, 0xbd, 0x9f, 0xea, 0xec, 0xf7, 0xee, 0x6, 0x30, 0xc3, 0x0, 0x0, 0x9, 0x9b, 0xda, 0x58, 0xb6, - 0x4f, 0xc8, 0xaf, 0x2d, 0x23, 0x1, 0x0, 0x5, 0xdb, 0xd9, 0x4c, 0xd6, 0xdb, 0x1, 0x0, 0xc, 0x41, - 0xeb, 0xc9, 0x9f, 0x7e, 0x7b, 0x43, 0xa8, 0x84, 0x6e, 0x75, 0x17, 0x1, 0x0, 0x10, 0x9f, 0x6a, 0x49, - 0xd7, 0x2b, 0xd8, 0xb0, 0x60, 0xdf, 0xe6, 0xa9, 0x9b, 0xef, 0xf9, 0x71, 0x36, 0x1}; - - uint8_t buf[143] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x78, 0xd7, 0x7d, 0x3a, 0xf0, 0x82, 0x1c, 0x13, 0x72, 0xb9, 0xfd, - 0x74, 0xd6, 0x34, 0xe7, 0xc3, 0x64, 0x47, 0x3c, 0xbb, 0xc}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x17, 0xec, 0x26, 0xad, 0x9a, 0xe9, 0x37, 0x4, 0x7e}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x21, 0x18, 0x2, 0x1d, 0x47, 0x3b, 0xb3, 0xcb, 0xa, 0xe0, 0xd5}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd0, 0x64, 0x2a, 0x80, 0x37, 0x2b, 0xd9, 0x77, 0x22, 0xc, 0xfa, - 0x5, 0xbd, 0x9f, 0xea, 0xec, 0xf7, 0xee, 0x6, 0x30, 0xc3}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9b, 0xda, 0x58, 0xb6, 0x4f, 0xc8, 0xaf, 0x2d, 0x23}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xdb, 0xd9, 0x4c, 0xd6, 0xdb}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x41, 0xeb, 0xc9, 0x9f, 0x7e, 0x7b, 0x43, 0xa8, 0x84, 0x6e, 0x75, 0x17}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x9f, 0x6a, 0x49, 0xd7, 0x2b, 0xd8, 0xb0, 0x60, - 0xdf, 0xe6, 0xa9, 0x9b, 0xef, 0xf9, 0x71, 0x36}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3250, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12034 -// [("\128.\143\172\255%\203\247\222\207O\146%X\169\204g\245\223\SUB\150#\190tM\173Fw9",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode17) { - uint8_t pkt[] = {0x82, 0x22, 0x2f, 0x2, 0x0, 0x1d, 0x80, 0x2e, 0x8f, 0xac, 0xff, 0x25, - 0xcb, 0xf7, 0xde, 0xcf, 0x4f, 0x92, 0x25, 0x58, 0xa9, 0xcc, 0x67, 0xf5, - 0xdf, 0x1a, 0x96, 0x23, 0xbe, 0x74, 0x4d, 0xad, 0x46, 0x77, 0x39, 0x0}; - - uint8_t buf[46] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x80, 0x2e, 0x8f, 0xac, 0xff, 0x25, 0xcb, 0xf7, 0xde, 0xcf, - 0x4f, 0x92, 0x25, 0x58, 0xa9, 0xcc, 0x67, 0xf5, 0xdf, 0x1a, - 0x96, 0x23, 0xbe, 0x74, 0x4d, 0xad, 0x46, 0x77, 0x39}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12034, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 4596 [("7\239\237\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\201\SI~\174\182\156;o{\142",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\219\b\DLE\SYN\228sb\177\143\195\230o<\196\246f=B",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\135\224?\NUL\161\188\134E\172\&4>1",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(".\233\181Y\146\&6\140\157\t\205\161Mo\215\&5\186\RSB_\ACK\219\186\f\238",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("1\174\&9\253\135o\201\235\GS\243\240\SYN\177jUy\141\218\158\251\232Pg\161\SYN\SO\162",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\137\&5u\EOT\209\DC4e\177\194H\NAKp;Q\228\b\149\178\182\140\217>!\",\FS\154\163\&1",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\189r\185K\155\247:&\129\FS}\SUB\136\205\198gm\202\183|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode18) { - uint8_t pkt[] = {0x82, 0xb1, 0x1, 0x11, 0xf4, 0x0, 0x4, 0x37, 0xef, 0xed, 0x94, 0x2, 0x0, 0x0, 0x1, 0x0, 0x1, - 0xce, 0x2, 0x0, 0xa, 0xc9, 0xf, 0x7e, 0xae, 0xb6, 0x9c, 0x3b, 0x6f, 0x7b, 0x8e, 0x1, 0x0, 0x12, - 0xdb, 0x8, 0x10, 0x16, 0xe4, 0x73, 0x62, 0xb1, 0x8f, 0xc3, 0xe6, 0x6f, 0x3c, 0xc4, 0xf6, 0x66, 0x3d, - 0x42, 0x2, 0x0, 0xc, 0x87, 0xe0, 0x3f, 0x0, 0xa1, 0xbc, 0x86, 0x45, 0xac, 0x34, 0x3e, 0x31, 0x2, - 0x0, 0x18, 0x2e, 0xe9, 0xb5, 0x59, 0x92, 0x36, 0x8c, 0x9d, 0x9, 0xcd, 0xa1, 0x4d, 0x6f, 0xd7, 0x35, - 0xba, 0x1e, 0x42, 0x5f, 0x6, 0xdb, 0xba, 0xc, 0xee, 0x2, 0x0, 0x1b, 0x31, 0xae, 0x39, 0xfd, 0x87, - 0x6f, 0xc9, 0xeb, 0x1d, 0xf3, 0xf0, 0x16, 0xb1, 0x6a, 0x55, 0x79, 0x8d, 0xda, 0x9e, 0xfb, 0xe8, 0x50, - 0x67, 0xa1, 0x16, 0xe, 0xa2, 0x2, 0x0, 0x1d, 0x89, 0x35, 0x75, 0x4, 0xd1, 0x14, 0x65, 0xb1, 0xc2, - 0x48, 0x15, 0x70, 0x3b, 0x51, 0xe4, 0x8, 0x95, 0xb2, 0xb6, 0x8c, 0xd9, 0x3e, 0x21, 0x22, 0x2c, 0x1c, - 0x9a, 0xa3, 0x31, 0x2, 0x0, 0x14, 0xbd, 0x72, 0xb9, 0x4b, 0x9b, 0xf7, 0x3a, 0x26, 0x81, 0x1c, 0x7d, - 0x1a, 0x88, 0xcd, 0xc6, 0x67, 0x6d, 0xca, 0xb7, 0x7c, 0x0}; - - uint8_t buf[190] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x37, 0xef, 0xed, 0x94}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xce}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc9, 0xf, 0x7e, 0xae, 0xb6, 0x9c, 0x3b, 0x6f, 0x7b, 0x8e}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xdb, 0x8, 0x10, 0x16, 0xe4, 0x73, 0x62, 0xb1, 0x8f, - 0xc3, 0xe6, 0x6f, 0x3c, 0xc4, 0xf6, 0x66, 0x3d, 0x42}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x87, 0xe0, 0x3f, 0x0, 0xa1, 0xbc, 0x86, 0x45, 0xac, 0x34, 0x3e, 0x31}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x2e, 0xe9, 0xb5, 0x59, 0x92, 0x36, 0x8c, 0x9d, 0x9, 0xcd, 0xa1, 0x4d, - 0x6f, 0xd7, 0x35, 0xba, 0x1e, 0x42, 0x5f, 0x6, 0xdb, 0xba, 0xc, 0xee}; - lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x31, 0xae, 0x39, 0xfd, 0x87, 0x6f, 0xc9, 0xeb, 0x1d, 0xf3, 0xf0, 0x16, 0xb1, 0x6a, - 0x55, 0x79, 0x8d, 0xda, 0x9e, 0xfb, 0xe8, 0x50, 0x67, 0xa1, 0x16, 0xe, 0xa2}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x89, 0x35, 0x75, 0x4, 0xd1, 0x14, 0x65, 0xb1, 0xc2, 0x48, - 0x15, 0x70, 0x3b, 0x51, 0xe4, 0x8, 0x95, 0xb2, 0xb6, 0x8c, - 0xd9, 0x3e, 0x21, 0x22, 0x2c, 0x1c, 0x9a, 0xa3, 0x31}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xbd, 0x72, 0xb9, 0x4b, 0x9b, 0xf7, 0x3a, 0x26, 0x81, 0x1c, - 0x7d, 0x1a, 0x88, 0xcd, 0xc6, 0x67, 0x6d, 0xca, 0xb7, 0x7c}; - lwmqtt_string_t topic_filter_s9 = {20, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4596, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12163 [("\r\156\"+\229.^L8\n\226%&\152\200\143De",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\233=P\128\f\151\147O\193\209\230l\183\&7Z\153\201\152z:\237\&8\STX\176Z\187\245\253",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\154\238U\255\128\128\129\222",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\178\STX7\173\221\210\128$\v\SOHQ\223\172\129",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("J\179\253\197\215CRg\185\217\STX1\223\&5\213\&17\245y\\h\154\DC4Jz\238\168\243\DC3!",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("G-\208\165h?\SO\131[\DC1",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\193\175\185E?\229\197iQ\ETX\234\174%\176\197\223\197\DLE\233M\211\250X\185wU",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode19) { - uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x2f, 0x83, 0x0, 0x12, 0xd, 0x9c, 0x22, 0x2b, 0xe5, 0x2e, 0x5e, 0x4c, 0x38, - 0xa, 0xe2, 0x25, 0x26, 0x98, 0xc8, 0x8f, 0x44, 0x65, 0x0, 0x0, 0x1c, 0xe9, 0x3d, 0x50, 0x80, - 0xc, 0x97, 0x93, 0x4f, 0xc1, 0xd1, 0xe6, 0x6c, 0xb7, 0x37, 0x5a, 0x99, 0xc9, 0x98, 0x7a, 0x3a, - 0xed, 0x38, 0x2, 0xb0, 0x5a, 0xbb, 0xf5, 0xfd, 0x2, 0x0, 0x8, 0x9a, 0xee, 0x55, 0xff, 0x80, - 0x80, 0x81, 0xde, 0x2, 0x0, 0xe, 0xb2, 0x2, 0x37, 0xad, 0xdd, 0xd2, 0x80, 0x24, 0xb, 0x1, - 0x51, 0xdf, 0xac, 0x81, 0x2, 0x0, 0x1e, 0x4a, 0xb3, 0xfd, 0xc5, 0xd7, 0x43, 0x52, 0x67, 0xb9, - 0xd9, 0x2, 0x31, 0xdf, 0x35, 0xd5, 0x31, 0x37, 0xf5, 0x79, 0x5c, 0x68, 0x9a, 0x14, 0x4a, 0x7a, - 0xee, 0xa8, 0xf3, 0x13, 0x21, 0x0, 0x0, 0xa, 0x47, 0x2d, 0xd0, 0xa5, 0x68, 0x3f, 0xe, 0x83, - 0x5b, 0x11, 0x2, 0x0, 0x1a, 0xc1, 0xaf, 0xb9, 0x45, 0x3f, 0xe5, 0xc5, 0x69, 0x51, 0x3, 0xea, - 0xae, 0x25, 0xb0, 0xc5, 0xdf, 0xc5, 0x10, 0xe9, 0x4d, 0xd3, 0xfa, 0x58, 0xb9, 0x77, 0x55, 0x2}; - - uint8_t buf[170] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xd, 0x9c, 0x22, 0x2b, 0xe5, 0x2e, 0x5e, 0x4c, 0x38, - 0xa, 0xe2, 0x25, 0x26, 0x98, 0xc8, 0x8f, 0x44, 0x65}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe9, 0x3d, 0x50, 0x80, 0xc, 0x97, 0x93, 0x4f, 0xc1, 0xd1, - 0xe6, 0x6c, 0xb7, 0x37, 0x5a, 0x99, 0xc9, 0x98, 0x7a, 0x3a, - 0xed, 0x38, 0x2, 0xb0, 0x5a, 0xbb, 0xf5, 0xfd}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9a, 0xee, 0x55, 0xff, 0x80, 0x80, 0x81, 0xde}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb2, 0x2, 0x37, 0xad, 0xdd, 0xd2, 0x80, 0x24, 0xb, 0x1, 0x51, 0xdf, 0xac, 0x81}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4a, 0xb3, 0xfd, 0xc5, 0xd7, 0x43, 0x52, 0x67, 0xb9, 0xd9, - 0x2, 0x31, 0xdf, 0x35, 0xd5, 0x31, 0x37, 0xf5, 0x79, 0x5c, - 0x68, 0x9a, 0x14, 0x4a, 0x7a, 0xee, 0xa8, 0xf3, 0x13, 0x21}; - lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x47, 0x2d, 0xd0, 0xa5, 0x68, 0x3f, 0xe, 0x83, 0x5b, 0x11}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc1, 0xaf, 0xb9, 0x45, 0x3f, 0xe5, 0xc5, 0x69, 0x51, 0x3, 0xea, 0xae, 0x25, - 0xb0, 0xc5, 0xdf, 0xc5, 0x10, 0xe9, 0x4d, 0xd3, 0xfa, 0x58, 0xb9, 0x77, 0x55}; - lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12163, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 21672 [(":f\201\245\150t\153",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("g^\195\215\\\138\194\147\188\181W\136",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\163\181\241IK\nA\212\254d\216",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode20) { - uint8_t pkt[] = {0x82, 0x29, 0x54, 0xa8, 0x0, 0x7, 0x3a, 0x66, 0xc9, 0xf5, 0x96, 0x74, 0x99, 0x1, 0x0, - 0xc, 0x67, 0x5e, 0xc3, 0xd7, 0x5c, 0x8a, 0xc2, 0x93, 0xbc, 0xb5, 0x57, 0x88, 0x0, 0x0, - 0xb, 0xa3, 0xb5, 0xf1, 0x49, 0x4b, 0xa, 0x41, 0xd4, 0xfe, 0x64, 0xd8, 0x0}; - - uint8_t buf[53] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x3a, 0x66, 0xc9, 0xf5, 0x96, 0x74, 0x99}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x67, 0x5e, 0xc3, 0xd7, 0x5c, 0x8a, 0xc2, 0x93, 0xbc, 0xb5, 0x57, 0x88}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa3, 0xb5, 0xf1, 0x49, 0x4b, 0xa, 0x41, 0xd4, 0xfe, 0x64, 0xd8}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21672, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2811 [("\232\155/\190\204\180\EOT\185\187J",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\204\150\224\190\140\164\182\211\159\f`\DC1",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\246te&\248u\229%^L\158\FSG\SYNQPL\237b\SOH\240\185",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k\ETX\f\tX\164\ETX",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode21) { - uint8_t pkt[] = {0x82, 0x41, 0xa, 0xfb, 0x0, 0xa, 0xe8, 0x9b, 0x2f, 0xbe, 0xcc, 0xb4, 0x4, 0xb9, 0xbb, 0x4a, 0x1, - 0x0, 0xc, 0xcc, 0x96, 0xe0, 0xbe, 0x8c, 0xa4, 0xb6, 0xd3, 0x9f, 0xc, 0x60, 0x11, 0x2, 0x0, 0x16, - 0xf6, 0x74, 0x65, 0x26, 0xf8, 0x75, 0xe5, 0x25, 0x5e, 0x4c, 0x9e, 0x1c, 0x47, 0x16, 0x51, 0x50, 0x4c, - 0xed, 0x62, 0x1, 0xf0, 0xb9, 0x0, 0x0, 0x7, 0x6b, 0x3, 0xc, 0x9, 0x58, 0xa4, 0x3, 0x1}; - - uint8_t buf[77] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xe8, 0x9b, 0x2f, 0xbe, 0xcc, 0xb4, 0x4, 0xb9, 0xbb, 0x4a}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcc, 0x96, 0xe0, 0xbe, 0x8c, 0xa4, 0xb6, 0xd3, 0x9f, 0xc, 0x60, 0x11}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf6, 0x74, 0x65, 0x26, 0xf8, 0x75, 0xe5, 0x25, 0x5e, 0x4c, 0x9e, - 0x1c, 0x47, 0x16, 0x51, 0x50, 0x4c, 0xed, 0x62, 0x1, 0xf0, 0xb9}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6b, 0x3, 0xc, 0x9, 0x58, 0xa4, 0x3}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2811, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 27615 [("\NAK\134\219\&6;\150\&1UX\155\237e\170\221",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("D\188\171\141\181i\189E\145\165\209^\172\DC3\184\&4\DC3\GS\221\USd\169UZ\156]\218",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("U\197\163\225\242\DELe\225y\183n'_\168\130\EOTv\134DS\164\148\vc=\226\240\215",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("%\220\143Z\STX\254s5\230\248\161\215\251k\222j2\132\174X\243\199\DC1\147\231",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\230\199yn\147I\171\f\206\152\247\ACK\246\205\&7i>7\137\ETXi",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("YLH\ETXb\224\237\198\151j\195\234\238",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\NUL4\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode22) { - uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x6b, 0xdf, 0x0, 0xe, 0x15, 0x86, 0xdb, 0x36, 0x3b, 0x96, 0x31, 0x55, 0x58, - 0x9b, 0xed, 0x65, 0xaa, 0xdd, 0x2, 0x0, 0x0, 0x2, 0x0, 0x1b, 0x44, 0xbc, 0xab, 0x8d, 0xb5, - 0x69, 0xbd, 0x45, 0x91, 0xa5, 0xd1, 0x5e, 0xac, 0x13, 0xb8, 0x34, 0x13, 0x1d, 0xdd, 0x1f, 0x64, - 0xa9, 0x55, 0x5a, 0x9c, 0x5d, 0xda, 0x2, 0x0, 0x1c, 0x55, 0xc5, 0xa3, 0xe1, 0xf2, 0x7f, 0x65, - 0xe1, 0x79, 0xb7, 0x6e, 0x27, 0x5f, 0xa8, 0x82, 0x4, 0x76, 0x86, 0x44, 0x53, 0xa4, 0x94, 0xb, - 0x63, 0x3d, 0xe2, 0xf0, 0xd7, 0x2, 0x0, 0x19, 0x25, 0xdc, 0x8f, 0x5a, 0x2, 0xfe, 0x73, 0x35, - 0xe6, 0xf8, 0xa1, 0xd7, 0xfb, 0x6b, 0xde, 0x6a, 0x32, 0x84, 0xae, 0x58, 0xf3, 0xc7, 0x11, 0x93, - 0xe7, 0x1, 0x0, 0x15, 0xe6, 0xc7, 0x79, 0x6e, 0x93, 0x49, 0xab, 0xc, 0xce, 0x98, 0xf7, 0x6, - 0xf6, 0xcd, 0x37, 0x69, 0x3e, 0x37, 0x89, 0x3, 0x69, 0x1, 0x0, 0xd, 0x59, 0x4c, 0x48, 0x3, - 0x62, 0xe0, 0xed, 0xc6, 0x97, 0x6a, 0xc3, 0xea, 0xee, 0x0, 0x0, 0x3, 0x0, 0x34, 0xe8, 0x1}; - - uint8_t buf[170] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x15, 0x86, 0xdb, 0x36, 0x3b, 0x96, 0x31, - 0x55, 0x58, 0x9b, 0xed, 0x65, 0xaa, 0xdd}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x44, 0xbc, 0xab, 0x8d, 0xb5, 0x69, 0xbd, 0x45, 0x91, 0xa5, 0xd1, 0x5e, 0xac, 0x13, - 0xb8, 0x34, 0x13, 0x1d, 0xdd, 0x1f, 0x64, 0xa9, 0x55, 0x5a, 0x9c, 0x5d, 0xda}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x55, 0xc5, 0xa3, 0xe1, 0xf2, 0x7f, 0x65, 0xe1, 0x79, 0xb7, - 0x6e, 0x27, 0x5f, 0xa8, 0x82, 0x4, 0x76, 0x86, 0x44, 0x53, - 0xa4, 0x94, 0xb, 0x63, 0x3d, 0xe2, 0xf0, 0xd7}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x25, 0xdc, 0x8f, 0x5a, 0x2, 0xfe, 0x73, 0x35, 0xe6, 0xf8, 0xa1, 0xd7, 0xfb, - 0x6b, 0xde, 0x6a, 0x32, 0x84, 0xae, 0x58, 0xf3, 0xc7, 0x11, 0x93, 0xe7}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe6, 0xc7, 0x79, 0x6e, 0x93, 0x49, 0xab, 0xc, 0xce, 0x98, 0xf7, - 0x6, 0xf6, 0xcd, 0x37, 0x69, 0x3e, 0x37, 0x89, 0x3, 0x69}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x59, 0x4c, 0x48, 0x3, 0x62, 0xe0, 0xed, 0xc6, 0x97, 0x6a, 0xc3, 0xea, 0xee}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x0, 0x34, 0xe8}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27615, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14083 [("\135\234\FS",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("n\183\&9\DC1f\NUL@\185\255\185qq\STX\"\173\fJ\218\SUB",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\128p\197\DC1\162\160\171\171K\149\206 \ACK\145\202\142",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode23) { - uint8_t pkt[] = {0x82, 0x31, 0x37, 0x3, 0x0, 0x3, 0x87, 0xea, 0x1c, 0x2, 0x0, 0x13, 0x6e, 0xb7, 0x39, 0x11, 0x66, - 0x0, 0x40, 0xb9, 0xff, 0xb9, 0x71, 0x71, 0x2, 0x22, 0xad, 0xc, 0x4a, 0xda, 0x1a, 0x1, 0x0, 0x10, - 0x80, 0x70, 0xc5, 0x11, 0xa2, 0xa0, 0xab, 0xab, 0x4b, 0x95, 0xce, 0x20, 0x6, 0x91, 0xca, 0x8e, 0x0}; - - uint8_t buf[61] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x87, 0xea, 0x1c}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6e, 0xb7, 0x39, 0x11, 0x66, 0x0, 0x40, 0xb9, 0xff, 0xb9, - 0x71, 0x71, 0x2, 0x22, 0xad, 0xc, 0x4a, 0xda, 0x1a}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x80, 0x70, 0xc5, 0x11, 0xa2, 0xa0, 0xab, 0xab, - 0x4b, 0x95, 0xce, 0x20, 0x6, 0x91, 0xca, 0x8e}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14083, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 16713 [("\141D\238n\154\164\246$)\214WR\f v\189\185*\139\r\DLE\ESC\135\SOH\164\132",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\185\139@\EM\a\ETX\186\130\FS\DC4\149\129",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS1}),("\139\211\225\252\160\193\136\130\164\243{3h\210\157/\220\156Eg\147l52",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\254\153c\253\205\198H\213\STX\SYN\139d#\249ON\143{\v\NAK3Iwz\EOT|\GS\ESC:^",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x6a, 0x41, 0x49, 0x0, 0x1a, 0x8d, 0x44, 0xee, 0x6e, 0x9a, 0xa4, 0xf6, 0x24, 0x29, 0xd6, - 0x57, 0x52, 0xc, 0x20, 0x76, 0xbd, 0xb9, 0x2a, 0x8b, 0xd, 0x10, 0x1b, 0x87, 0x1, 0xa4, 0x84, - 0x2, 0x0, 0xc, 0xb9, 0x8b, 0x40, 0x19, 0x7, 0x3, 0xba, 0x82, 0x1c, 0x14, 0x95, 0x81, 0x1, - 0x0, 0x18, 0x8b, 0xd3, 0xe1, 0xfc, 0xa0, 0xc1, 0x88, 0x82, 0xa4, 0xf3, 0x7b, 0x33, 0x68, 0xd2, - 0x9d, 0x2f, 0xdc, 0x9c, 0x45, 0x67, 0x93, 0x6c, 0x35, 0x32, 0x1, 0x0, 0x1e, 0xfe, 0x99, 0x63, - 0xfd, 0xcd, 0xc6, 0x48, 0xd5, 0x2, 0x16, 0x8b, 0x64, 0x23, 0xf9, 0x4f, 0x4e, 0x8f, 0x7b, 0xb, - 0x15, 0x33, 0x49, 0x77, 0x7a, 0x4, 0x7c, 0x1d, 0x1b, 0x3a, 0x5e, 0x2}; - - uint8_t buf[118] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x8d, 0x44, 0xee, 0x6e, 0x9a, 0xa4, 0xf6, 0x24, 0x29, 0xd6, 0x57, 0x52, 0xc, - 0x20, 0x76, 0xbd, 0xb9, 0x2a, 0x8b, 0xd, 0x10, 0x1b, 0x87, 0x1, 0xa4, 0x84}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb9, 0x8b, 0x40, 0x19, 0x7, 0x3, 0xba, 0x82, 0x1c, 0x14, 0x95, 0x81}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8b, 0xd3, 0xe1, 0xfc, 0xa0, 0xc1, 0x88, 0x82, 0xa4, 0xf3, 0x7b, 0x33, - 0x68, 0xd2, 0x9d, 0x2f, 0xdc, 0x9c, 0x45, 0x67, 0x93, 0x6c, 0x35, 0x32}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfe, 0x99, 0x63, 0xfd, 0xcd, 0xc6, 0x48, 0xd5, 0x2, 0x16, - 0x8b, 0x64, 0x23, 0xf9, 0x4f, 0x4e, 0x8f, 0x7b, 0xb, 0x15, - 0x33, 0x49, 0x77, 0x7a, 0x4, 0x7c, 0x1d, 0x1b, 0x3a, 0x5e}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16713, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 25471 [(" -// g\199\217\146\253&\DC3\235\b\186\200\t\171\254\172\FS\140m\DC3\CAN\238F\224\187\190\171\242",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\179hw\206r\aC\GS\159\n\206\SUB\255$mE\EOTm]\210A\224",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("Vd\170\246\&2\v",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\230\130+\153\214\164\236\ENQas\251\192}h)\SOH\ESC{\189=\190\235'w\202\225\&4\223\ACK",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\221\&8F\142\&7\197\DC4\193\151\193@\EOT\151\ACK\146\157\239\149\STX\181\220\148\157\STX\224",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("l\160\229\230\146",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0x8a, 0x1, 0x63, 0x7f, 0x0, 0x1c, 0x20, 0x67, 0xc7, 0xd9, 0x92, 0xfd, 0x26, 0x13, 0xeb, - 0x8, 0xba, 0xc8, 0x9, 0xab, 0xfe, 0xac, 0x1c, 0x8c, 0x6d, 0x13, 0x18, 0xee, 0x46, 0xe0, 0xbb, - 0xbe, 0xab, 0xf2, 0x0, 0x0, 0x0, 0x1, 0x0, 0x16, 0xb3, 0x68, 0x77, 0xce, 0x72, 0x7, 0x43, - 0x1d, 0x9f, 0xa, 0xce, 0x1a, 0xff, 0x24, 0x6d, 0x45, 0x4, 0x6d, 0x5d, 0xd2, 0x41, 0xe0, 0x0, - 0x0, 0x6, 0x56, 0x64, 0xaa, 0xf6, 0x32, 0xb, 0x1, 0x0, 0x1d, 0xe6, 0x82, 0x2b, 0x99, 0xd6, - 0xa4, 0xec, 0x5, 0x61, 0x73, 0xfb, 0xc0, 0x7d, 0x68, 0x29, 0x1, 0x1b, 0x7b, 0xbd, 0x3d, 0xbe, - 0xeb, 0x27, 0x77, 0xca, 0xe1, 0x34, 0xdf, 0x6, 0x1, 0x0, 0x19, 0xdd, 0x38, 0x46, 0x8e, 0x37, - 0xc5, 0x14, 0xc1, 0x97, 0xc1, 0x40, 0x4, 0x97, 0x6, 0x92, 0x9d, 0xef, 0x95, 0x2, 0xb5, 0xdc, - 0x94, 0x9d, 0x2, 0xe0, 0x1, 0x0, 0x5, 0x6c, 0xa0, 0xe5, 0xe6, 0x92, 0x0}; - - uint8_t buf[151] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x20, 0x67, 0xc7, 0xd9, 0x92, 0xfd, 0x26, 0x13, 0xeb, 0x8, - 0xba, 0xc8, 0x9, 0xab, 0xfe, 0xac, 0x1c, 0x8c, 0x6d, 0x13, - 0x18, 0xee, 0x46, 0xe0, 0xbb, 0xbe, 0xab, 0xf2}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb3, 0x68, 0x77, 0xce, 0x72, 0x7, 0x43, 0x1d, 0x9f, 0xa, 0xce, - 0x1a, 0xff, 0x24, 0x6d, 0x45, 0x4, 0x6d, 0x5d, 0xd2, 0x41, 0xe0}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x56, 0x64, 0xaa, 0xf6, 0x32, 0xb}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe6, 0x82, 0x2b, 0x99, 0xd6, 0xa4, 0xec, 0x5, 0x61, 0x73, - 0xfb, 0xc0, 0x7d, 0x68, 0x29, 0x1, 0x1b, 0x7b, 0xbd, 0x3d, - 0xbe, 0xeb, 0x27, 0x77, 0xca, 0xe1, 0x34, 0xdf, 0x6}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xdd, 0x38, 0x46, 0x8e, 0x37, 0xc5, 0x14, 0xc1, 0x97, 0xc1, 0x40, 0x4, 0x97, - 0x6, 0x92, 0x9d, 0xef, 0x95, 0x2, 0xb5, 0xdc, 0x94, 0x9d, 0x2, 0xe0}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6c, 0xa0, 0xe5, 0xe6, 0x92}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25471, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 10657 [("\ENQ4\f\143\197\ENQ\145\193\247\141\221i\199\192\173\223",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\188\156\DC3\177\134%\161",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\\\222\217\&5\226r",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\176c\ESCP\163\GSx\DC3",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("G\ENQ\204\136\fTN\163\214\228\254eHG\166\CAN\210\146>",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\172\144=\175\\\ESC\f\226\179v\175\164D$R9\211",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("S\242\171\242\STX\221\188uJ\199l\155\137\232\\\135\187\141\SYN\217",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\NAK\205\STX\156\ENQ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\161\200eM1\161*\234\207\198\169\252.\DC2nE\230\227HE8\135\164\244",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("al}\149\EOT(\233\DLE\STX\233\208\183ui-F\t",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0xab, 0x1, 0x29, 0xa1, 0x0, 0x10, 0x5, 0x34, 0xc, 0x8f, 0xc5, 0x5, 0x91, 0xc1, 0xf7, - 0x8d, 0xdd, 0x69, 0xc7, 0xc0, 0xad, 0xdf, 0x2, 0x0, 0x7, 0xbc, 0x9c, 0x13, 0xb1, 0x86, 0x25, - 0xa1, 0x0, 0x0, 0x6, 0x5c, 0xde, 0xd9, 0x35, 0xe2, 0x72, 0x2, 0x0, 0x8, 0xb0, 0x63, 0x1b, - 0x50, 0xa3, 0x1d, 0x78, 0x13, 0x1, 0x0, 0x13, 0x47, 0x5, 0xcc, 0x88, 0xc, 0x54, 0x4e, 0xa3, - 0xd6, 0xe4, 0xfe, 0x65, 0x48, 0x47, 0xa6, 0x18, 0xd2, 0x92, 0x3e, 0x1, 0x0, 0x11, 0xac, 0x90, - 0x3d, 0xaf, 0x5c, 0x1b, 0xc, 0xe2, 0xb3, 0x76, 0xaf, 0xa4, 0x44, 0x24, 0x52, 0x39, 0xd3, 0x1, - 0x0, 0x14, 0x53, 0xf2, 0xab, 0xf2, 0x2, 0xdd, 0xbc, 0x75, 0x4a, 0xc7, 0x6c, 0x9b, 0x89, 0xe8, - 0x5c, 0x87, 0xbb, 0x8d, 0x16, 0xd9, 0x1, 0x0, 0x5, 0x15, 0xcd, 0x2, 0x9c, 0x5, 0x1, 0x0, - 0x18, 0xa1, 0xc8, 0x65, 0x4d, 0x31, 0xa1, 0x2a, 0xea, 0xcf, 0xc6, 0xa9, 0xfc, 0x2e, 0x12, 0x6e, - 0x45, 0xe6, 0xe3, 0x48, 0x45, 0x38, 0x87, 0xa4, 0xf4, 0x1, 0x0, 0x11, 0x61, 0x6c, 0x7d, 0x95, - 0x4, 0x28, 0xe9, 0x10, 0x2, 0xe9, 0xd0, 0xb7, 0x75, 0x69, 0x2d, 0x46, 0x9, 0x2}; - - uint8_t buf[184] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x5, 0x34, 0xc, 0x8f, 0xc5, 0x5, 0x91, 0xc1, - 0xf7, 0x8d, 0xdd, 0x69, 0xc7, 0xc0, 0xad, 0xdf}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbc, 0x9c, 0x13, 0xb1, 0x86, 0x25, 0xa1}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5c, 0xde, 0xd9, 0x35, 0xe2, 0x72}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb0, 0x63, 0x1b, 0x50, 0xa3, 0x1d, 0x78, 0x13}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x47, 0x5, 0xcc, 0x88, 0xc, 0x54, 0x4e, 0xa3, 0xd6, 0xe4, - 0xfe, 0x65, 0x48, 0x47, 0xa6, 0x18, 0xd2, 0x92, 0x3e}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xac, 0x90, 0x3d, 0xaf, 0x5c, 0x1b, 0xc, 0xe2, 0xb3, - 0x76, 0xaf, 0xa4, 0x44, 0x24, 0x52, 0x39, 0xd3}; - lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x53, 0xf2, 0xab, 0xf2, 0x2, 0xdd, 0xbc, 0x75, 0x4a, 0xc7, - 0x6c, 0x9b, 0x89, 0xe8, 0x5c, 0x87, 0xbb, 0x8d, 0x16, 0xd9}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x15, 0xcd, 0x2, 0x9c, 0x5}; - lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa1, 0xc8, 0x65, 0x4d, 0x31, 0xa1, 0x2a, 0xea, 0xcf, 0xc6, 0xa9, 0xfc, - 0x2e, 0x12, 0x6e, 0x45, 0xe6, 0xe3, 0x48, 0x45, 0x38, 0x87, 0xa4, 0xf4}; - lwmqtt_string_t topic_filter_s8 = {24, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x61, 0x6c, 0x7d, 0x95, 0x4, 0x28, 0xe9, 0x10, 0x2, - 0xe9, 0xd0, 0xb7, 0x75, 0x69, 0x2d, 0x46, 0x9}; - lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10657, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 15036 [("\ETB\177\238\199$\NUL\128\209",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("3r:\DC1c[upm\234_c`\195V\252C\vu\153\196",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("g\238\250",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("\183\236\166\159+\v\b\SI\149\DC2\247\&1",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ESCd\242\134N\161i\169\135\230\198m\163\166\229\247e\211E",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("Y\216\242f(\ETX=\152\ESC\208?B|\197\n\198Z\148\153\199\f\r\\n5\137#4",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0x6f, 0x3a, 0xbc, 0x0, 0x8, 0x17, 0xb1, 0xee, 0xc7, 0x24, 0x0, 0x80, 0xd1, 0x0, 0x0, 0x15, - 0x33, 0x72, 0x3a, 0x11, 0x63, 0x5b, 0x75, 0x70, 0x6d, 0xea, 0x5f, 0x63, 0x60, 0xc3, 0x56, 0xfc, 0x43, - 0xb, 0x75, 0x99, 0xc4, 0x1, 0x0, 0x3, 0x67, 0xee, 0xfa, 0x0, 0x0, 0xc, 0xb7, 0xec, 0xa6, 0x9f, - 0x2b, 0xb, 0x8, 0xf, 0x95, 0x12, 0xf7, 0x31, 0x2, 0x0, 0x13, 0x1b, 0x64, 0xf2, 0x86, 0x4e, 0xa1, - 0x69, 0xa9, 0x87, 0xe6, 0xc6, 0x6d, 0xa3, 0xa6, 0xe5, 0xf7, 0x65, 0xd3, 0x45, 0x0, 0x0, 0x1c, 0x59, - 0xd8, 0xf2, 0x66, 0x28, 0x3, 0x3d, 0x98, 0x1b, 0xd0, 0x3f, 0x42, 0x7c, 0xc5, 0xa, 0xc6, 0x5a, 0x94, - 0x99, 0xc7, 0xc, 0xd, 0x5c, 0x6e, 0x35, 0x89, 0x23, 0x34, 0x1}; - - uint8_t buf[123] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x17, 0xb1, 0xee, 0xc7, 0x24, 0x0, 0x80, 0xd1}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x33, 0x72, 0x3a, 0x11, 0x63, 0x5b, 0x75, 0x70, 0x6d, 0xea, 0x5f, - 0x63, 0x60, 0xc3, 0x56, 0xfc, 0x43, 0xb, 0x75, 0x99, 0xc4}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x67, 0xee, 0xfa}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb7, 0xec, 0xa6, 0x9f, 0x2b, 0xb, 0x8, 0xf, 0x95, 0x12, 0xf7, 0x31}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x1b, 0x64, 0xf2, 0x86, 0x4e, 0xa1, 0x69, 0xa9, 0x87, 0xe6, - 0xc6, 0x6d, 0xa3, 0xa6, 0xe5, 0xf7, 0x65, 0xd3, 0x45}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x59, 0xd8, 0xf2, 0x66, 0x28, 0x3, 0x3d, 0x98, 0x1b, 0xd0, - 0x3f, 0x42, 0x7c, 0xc5, 0xa, 0xc6, 0x5a, 0x94, 0x99, 0xc7, - 0xc, 0xd, 0x5c, 0x6e, 0x35, 0x89, 0x23, 0x34}; - lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15036, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2876 [("\143\161\221\224\191",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("rT\145\ay\160\215s,\146c\129\150>@!/\217\141",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\r\184\142p\151\204\170\249\180/\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\235\167\DLE\217\198\169\175\SI\182\ESC",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("G\130\214\&0\b\EM/\194\249\193\148`\222\217\ETXQZ\251\&7\n\147k\254\158t\249\130\219-E",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\SO\205\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("\175\GS\210~\190\GS\178\&9\230=\236|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\213\RSA\148\250i2Cbmo\147D\254\170\&33p\218\CAN\232\206\SO\142\&7",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\169\DEL\233~\135W\168q\226\158\197\227\151}9",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0xa2, 0x1, 0xb, 0x3c, 0x0, 0x5, 0x8f, 0xa1, 0xdd, 0xe0, 0xbf, 0x1, 0x0, 0x13, 0x72, 0x54, - 0x91, 0x7, 0x79, 0xa0, 0xd7, 0x73, 0x2c, 0x92, 0x63, 0x81, 0x96, 0x3e, 0x40, 0x21, 0x2f, 0xd9, 0x8d, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xb, 0xd, 0xb8, 0x8e, 0x70, 0x97, 0xcc, 0xaa, 0xf9, 0xb4, 0x2f, 0xd2, - 0x1, 0x0, 0xa, 0xeb, 0xa7, 0x10, 0xd9, 0xc6, 0xa9, 0xaf, 0xf, 0xb6, 0x1b, 0x1, 0x0, 0x1e, 0x47, - 0x82, 0xd6, 0x30, 0x8, 0x19, 0x2f, 0xc2, 0xf9, 0xc1, 0x94, 0x60, 0xde, 0xd9, 0x3, 0x51, 0x5a, 0xfb, - 0x37, 0xa, 0x93, 0x6b, 0xfe, 0x9e, 0x74, 0xf9, 0x82, 0xdb, 0x2d, 0x45, 0x0, 0x0, 0x3, 0xe, 0xcd, - 0xce, 0x2, 0x0, 0xc, 0xaf, 0x1d, 0xd2, 0x7e, 0xbe, 0x1d, 0xb2, 0x39, 0xe6, 0x3d, 0xec, 0x7c, 0x2, - 0x0, 0x19, 0xd5, 0x1e, 0x41, 0x94, 0xfa, 0x69, 0x32, 0x43, 0x62, 0x6d, 0x6f, 0x93, 0x44, 0xfe, 0xaa, - 0x33, 0x33, 0x70, 0xda, 0x18, 0xe8, 0xce, 0xe, 0x8e, 0x37, 0x1, 0x0, 0xf, 0xa9, 0x7f, 0xe9, 0x7e, - 0x87, 0x57, 0xa8, 0x71, 0xe2, 0x9e, 0xc5, 0xe3, 0x97, 0x7d, 0x39, 0x2}; - - uint8_t buf[175] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x8f, 0xa1, 0xdd, 0xe0, 0xbf}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x72, 0x54, 0x91, 0x7, 0x79, 0xa0, 0xd7, 0x73, 0x2c, 0x92, - 0x63, 0x81, 0x96, 0x3e, 0x40, 0x21, 0x2f, 0xd9, 0x8d}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd, 0xb8, 0x8e, 0x70, 0x97, 0xcc, 0xaa, 0xf9, 0xb4, 0x2f, 0xd2}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xeb, 0xa7, 0x10, 0xd9, 0xc6, 0xa9, 0xaf, 0xf, 0xb6, 0x1b}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x47, 0x82, 0xd6, 0x30, 0x8, 0x19, 0x2f, 0xc2, 0xf9, 0xc1, - 0x94, 0x60, 0xde, 0xd9, 0x3, 0x51, 0x5a, 0xfb, 0x37, 0xa, - 0x93, 0x6b, 0xfe, 0x9e, 0x74, 0xf9, 0x82, 0xdb, 0x2d, 0x45}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xe, 0xcd, 0xce}; - lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xaf, 0x1d, 0xd2, 0x7e, 0xbe, 0x1d, 0xb2, 0x39, 0xe6, 0x3d, 0xec, 0x7c}; - lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd5, 0x1e, 0x41, 0x94, 0xfa, 0x69, 0x32, 0x43, 0x62, 0x6d, 0x6f, 0x93, 0x44, - 0xfe, 0xaa, 0x33, 0x33, 0x70, 0xda, 0x18, 0xe8, 0xce, 0xe, 0x8e, 0x37}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa9, 0x7f, 0xe9, 0x7e, 0x87, 0x57, 0xa8, 0x71, - 0xe2, 0x9e, 0xc5, 0xe3, 0x97, 0x7d, 0x39}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2876, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 30960 [("\185\236\245\223\167kV\209\203\206v",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("`\208\168\173\228W\128\NUL\ESC\220\215\244'8\132 -// \151\&8\151\138\SO\228g",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\196b\128&>\147\253\195D\218\SI\NAK\EOT\ETBV\195\140\"s\215\166Z:9",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("=|\155\128\168\238V\248\201^w7\200+\247\FS\194\185\218\184",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0x5f, 0x78, 0xf0, 0x0, 0xb, 0xb9, 0xec, 0xf5, 0xdf, 0xa7, 0x6b, 0x56, 0xd1, 0xcb, 0xce, 0x76, - 0x1, 0x0, 0x0, 0x2, 0x0, 0x17, 0x60, 0xd0, 0xa8, 0xad, 0xe4, 0x57, 0x80, 0x0, 0x1b, 0xdc, 0xd7, - 0xf4, 0x27, 0x38, 0x84, 0x20, 0x97, 0x38, 0x97, 0x8a, 0xe, 0xe4, 0x67, 0x1, 0x0, 0x18, 0xc4, 0x62, - 0x80, 0x26, 0x3e, 0x93, 0xfd, 0xc3, 0x44, 0xda, 0xf, 0x15, 0x4, 0x17, 0x56, 0xc3, 0x8c, 0x22, 0x73, - 0xd7, 0xa6, 0x5a, 0x3a, 0x39, 0x2, 0x0, 0x14, 0x3d, 0x7c, 0x9b, 0x80, 0xa8, 0xee, 0x56, 0xf8, 0xc9, - 0x5e, 0x77, 0x37, 0xc8, 0x2b, 0xf7, 0x1c, 0xc2, 0xb9, 0xda, 0xb8, 0x1}; - - uint8_t buf[107] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xb9, 0xec, 0xf5, 0xdf, 0xa7, 0x6b, 0x56, 0xd1, 0xcb, 0xce, 0x76}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x60, 0xd0, 0xa8, 0xad, 0xe4, 0x57, 0x80, 0x0, 0x1b, 0xdc, 0xd7, 0xf4, - 0x27, 0x38, 0x84, 0x20, 0x97, 0x38, 0x97, 0x8a, 0xe, 0xe4, 0x67}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc4, 0x62, 0x80, 0x26, 0x3e, 0x93, 0xfd, 0xc3, 0x44, 0xda, 0xf, 0x15, - 0x4, 0x17, 0x56, 0xc3, 0x8c, 0x22, 0x73, 0xd7, 0xa6, 0x5a, 0x3a, 0x39}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x3d, 0x7c, 0x9b, 0x80, 0xa8, 0xee, 0x56, 0xf8, 0xc9, 0x5e, - 0x77, 0x37, 0xc8, 0x2b, 0xf7, 0x1c, 0xc2, 0xb9, 0xda, 0xb8}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30960, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 19821 [("\162",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\200\151\208c\FS\228\171\229\143c\210\no\DC1F(\147w\158",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("w\206\216e\255h\237\252\178.",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\196)\168x0\242\199\SI\251\223L\150\183\234\205\197\137`\215'\aD\164\EOT5\148\ETB\189",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x48, 0x4d, 0x6d, 0x0, 0x1, 0xa2, 0x2, 0x0, 0x13, 0xc8, 0x97, 0xd0, 0x63, 0x1c, - 0xe4, 0xab, 0xe5, 0x8f, 0x63, 0xd2, 0xa, 0x6f, 0x11, 0x46, 0x28, 0x93, 0x77, 0x9e, 0x1, - 0x0, 0xa, 0x77, 0xce, 0xd8, 0x65, 0xff, 0x68, 0xed, 0xfc, 0xb2, 0x2e, 0x2, 0x0, 0x1c, - 0xc4, 0x29, 0xa8, 0x78, 0x30, 0xf2, 0xc7, 0xf, 0xfb, 0xdf, 0x4c, 0x96, 0xb7, 0xea, 0xcd, - 0xc5, 0x89, 0x60, 0xd7, 0x27, 0x7, 0x44, 0xa4, 0x4, 0x35, 0x94, 0x17, 0xbd, 0x2}; - - uint8_t buf[84] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xa2}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc8, 0x97, 0xd0, 0x63, 0x1c, 0xe4, 0xab, 0xe5, 0x8f, 0x63, - 0xd2, 0xa, 0x6f, 0x11, 0x46, 0x28, 0x93, 0x77, 0x9e}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x77, 0xce, 0xd8, 0x65, 0xff, 0x68, 0xed, 0xfc, 0xb2, 0x2e}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc4, 0x29, 0xa8, 0x78, 0x30, 0xf2, 0xc7, 0xf, 0xfb, 0xdf, - 0x4c, 0x96, 0xb7, 0xea, 0xcd, 0xc5, 0x89, 0x60, 0xd7, 0x27, - 0x7, 0x44, 0xa4, 0x4, 0x35, 0x94, 0x17, 0xbd}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19821, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 21770 -// [("\139=b\145p\157\223b|\STX[\197\203\167e^\171\235\151}k\149\EOT\132\SO\239\218\159\152",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ACK\227+\134\ETB\170\253\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\148-\198\ACKO:X\191\162",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\128\150\&7\b\f^g\182Dr\t8k\240\170\&7",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("jBu\DC1!5\207\193K6\164\a\EOT\189m\169\154}\186\220\246\141\&8\167\GS\184\RS\192",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("s\207#\r\188b4B|f>\135\234\142\&7\202\154\186",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode31) { - uint8_t pkt[] = {0x82, 0x80, 0x1, 0x55, 0xa, 0x0, 0x1d, 0x8b, 0x3d, 0x62, 0x91, 0x70, 0x9d, 0xdf, 0x62, 0x7c, 0x2, - 0x5b, 0xc5, 0xcb, 0xa7, 0x65, 0x5e, 0xab, 0xeb, 0x97, 0x7d, 0x6b, 0x95, 0x4, 0x84, 0xe, 0xef, 0xda, - 0x9f, 0x98, 0x1, 0x0, 0x8, 0x6, 0xe3, 0x2b, 0x86, 0x17, 0xaa, 0xfd, 0xa6, 0x2, 0x0, 0x9, 0x94, - 0x2d, 0xc6, 0x6, 0x4f, 0x3a, 0x58, 0xbf, 0xa2, 0x2, 0x0, 0x10, 0x80, 0x96, 0x37, 0x8, 0xc, 0x5e, - 0x67, 0xb6, 0x44, 0x72, 0x9, 0x38, 0x6b, 0xf0, 0xaa, 0x37, 0x1, 0x0, 0x1c, 0x6a, 0x42, 0x75, 0x11, - 0x21, 0x35, 0xcf, 0xc1, 0x4b, 0x36, 0xa4, 0x7, 0x4, 0xbd, 0x6d, 0xa9, 0x9a, 0x7d, 0xba, 0xdc, 0xf6, - 0x8d, 0x38, 0xa7, 0x1d, 0xb8, 0x1e, 0xc0, 0x2, 0x0, 0x12, 0x73, 0xcf, 0x23, 0xd, 0xbc, 0x62, 0x34, - 0x42, 0x7c, 0x66, 0x3e, 0x87, 0xea, 0x8e, 0x37, 0xca, 0x9a, 0xba, 0x1}; - - uint8_t buf[141] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x8b, 0x3d, 0x62, 0x91, 0x70, 0x9d, 0xdf, 0x62, 0x7c, 0x2, - 0x5b, 0xc5, 0xcb, 0xa7, 0x65, 0x5e, 0xab, 0xeb, 0x97, 0x7d, - 0x6b, 0x95, 0x4, 0x84, 0xe, 0xef, 0xda, 0x9f, 0x98}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6, 0xe3, 0x2b, 0x86, 0x17, 0xaa, 0xfd, 0xa6}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x94, 0x2d, 0xc6, 0x6, 0x4f, 0x3a, 0x58, 0xbf, 0xa2}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x80, 0x96, 0x37, 0x8, 0xc, 0x5e, 0x67, 0xb6, - 0x44, 0x72, 0x9, 0x38, 0x6b, 0xf0, 0xaa, 0x37}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x6a, 0x42, 0x75, 0x11, 0x21, 0x35, 0xcf, 0xc1, 0x4b, 0x36, - 0xa4, 0x7, 0x4, 0xbd, 0x6d, 0xa9, 0x9a, 0x7d, 0xba, 0xdc, - 0xf6, 0x8d, 0x38, 0xa7, 0x1d, 0xb8, 0x1e, 0xc0}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x73, 0xcf, 0x23, 0xd, 0xbc, 0x62, 0x34, 0x42, 0x7c, - 0x66, 0x3e, 0x87, 0xea, 0x8e, 0x37, 0xca, 0x9a, 0xba}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21770, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 24232 -// [("\228\219\211\ENQ\144\&1\EMRC\252<\249\191\134\214I\149\ENQ\204~\DC4\165\182\150\219\180^\DC2",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("js\191\171\SYN\189\226K\172j8\255\165\172\234R\174`\205\174\r)\ESCN\b\166\150\&6\151",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\195\230#0b={P\147",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = -// QoS1}),("\b\181\152j\EMo\228\134\219\174\179~\246\170>\175\209\193\138D\129\150K\v\163.\223@",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("F\212\150u\137\212\165\227\t\252\203'8\195\187\205~",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\232\133xTT\221\207\NUL",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ETX}\171pE",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("@$\166\244=%&\CANS\tx2\215\"\DLE\204\197\147\DC4nU\ENQ]\229>\EM`\246H",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\153\175\GS\173\ETB\160a\b\FS\195\152\193\STX\139\242\129\254{",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\244\&6\\v\143b\181\188\130\153t\237\185>\130",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\161g3\193\181G;",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode32) { - uint8_t pkt[] = {0x82, 0xe4, 0x1, 0x5e, 0xa8, 0x0, 0x1c, 0xe4, 0xdb, 0xd3, 0x5, 0x90, 0x31, 0x19, 0x52, 0x43, 0xfc, - 0x3c, 0xf9, 0xbf, 0x86, 0xd6, 0x49, 0x95, 0x5, 0xcc, 0x7e, 0x14, 0xa5, 0xb6, 0x96, 0xdb, 0xb4, 0x5e, - 0x12, 0x0, 0x0, 0x1d, 0x6a, 0x73, 0xbf, 0xab, 0x16, 0xbd, 0xe2, 0x4b, 0xac, 0x6a, 0x38, 0xff, 0xa5, - 0xac, 0xea, 0x52, 0xae, 0x60, 0xcd, 0xae, 0xd, 0x29, 0x1b, 0x4e, 0x8, 0xa6, 0x96, 0x36, 0x97, 0x0, - 0x0, 0x9, 0xc3, 0xe6, 0x23, 0x30, 0x62, 0x3d, 0x7b, 0x50, 0x93, 0x1, 0x0, 0x1c, 0x8, 0xb5, 0x98, - 0x6a, 0x19, 0x6f, 0xe4, 0x86, 0xdb, 0xae, 0xb3, 0x7e, 0xf6, 0xaa, 0x3e, 0xaf, 0xd1, 0xc1, 0x8a, 0x44, - 0x81, 0x96, 0x4b, 0xb, 0xa3, 0x2e, 0xdf, 0x40, 0x1, 0x0, 0x11, 0x46, 0xd4, 0x96, 0x75, 0x89, 0xd4, - 0xa5, 0xe3, 0x9, 0xfc, 0xcb, 0x27, 0x38, 0xc3, 0xbb, 0xcd, 0x7e, 0x1, 0x0, 0x8, 0xe8, 0x85, 0x78, - 0x54, 0x54, 0xdd, 0xcf, 0x0, 0x0, 0x0, 0x5, 0x3, 0x7d, 0xab, 0x70, 0x45, 0x1, 0x0, 0x1d, 0x40, - 0x24, 0xa6, 0xf4, 0x3d, 0x25, 0x26, 0x18, 0x53, 0x9, 0x78, 0x32, 0xd7, 0x22, 0x10, 0xcc, 0xc5, 0x93, - 0x14, 0x6e, 0x55, 0x5, 0x5d, 0xe5, 0x3e, 0x19, 0x60, 0xf6, 0x48, 0x0, 0x0, 0x12, 0x99, 0xaf, 0x1d, - 0xad, 0x17, 0xa0, 0x61, 0x8, 0x1c, 0xc3, 0x98, 0xc1, 0x2, 0x8b, 0xf2, 0x81, 0xfe, 0x7b, 0x0, 0x0, - 0xf, 0xf4, 0x36, 0x5c, 0x76, 0x8f, 0x62, 0xb5, 0xbc, 0x82, 0x99, 0x74, 0xed, 0xb9, 0x3e, 0x82, 0x2, - 0x0, 0x7, 0xa1, 0x67, 0x33, 0xc1, 0xb5, 0x47, 0x3b, 0x1}; - - uint8_t buf[241] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xe4, 0xdb, 0xd3, 0x5, 0x90, 0x31, 0x19, 0x52, 0x43, 0xfc, 0x3c, 0xf9, 0xbf, 0x86, - 0xd6, 0x49, 0x95, 0x5, 0xcc, 0x7e, 0x14, 0xa5, 0xb6, 0x96, 0xdb, 0xb4, 0x5e, 0x12}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6a, 0x73, 0xbf, 0xab, 0x16, 0xbd, 0xe2, 0x4b, 0xac, 0x6a, - 0x38, 0xff, 0xa5, 0xac, 0xea, 0x52, 0xae, 0x60, 0xcd, 0xae, - 0xd, 0x29, 0x1b, 0x4e, 0x8, 0xa6, 0x96, 0x36, 0x97}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc3, 0xe6, 0x23, 0x30, 0x62, 0x3d, 0x7b, 0x50, 0x93}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8, 0xb5, 0x98, 0x6a, 0x19, 0x6f, 0xe4, 0x86, 0xdb, 0xae, - 0xb3, 0x7e, 0xf6, 0xaa, 0x3e, 0xaf, 0xd1, 0xc1, 0x8a, 0x44, - 0x81, 0x96, 0x4b, 0xb, 0xa3, 0x2e, 0xdf, 0x40}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x46, 0xd4, 0x96, 0x75, 0x89, 0xd4, 0xa5, 0xe3, 0x9, - 0xfc, 0xcb, 0x27, 0x38, 0xc3, 0xbb, 0xcd, 0x7e}; - lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe8, 0x85, 0x78, 0x54, 0x54, 0xdd, 0xcf, 0x0}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3, 0x7d, 0xab, 0x70, 0x45}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x40, 0x24, 0xa6, 0xf4, 0x3d, 0x25, 0x26, 0x18, 0x53, 0x9, - 0x78, 0x32, 0xd7, 0x22, 0x10, 0xcc, 0xc5, 0x93, 0x14, 0x6e, - 0x55, 0x5, 0x5d, 0xe5, 0x3e, 0x19, 0x60, 0xf6, 0x48}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x99, 0xaf, 0x1d, 0xad, 0x17, 0xa0, 0x61, 0x8, 0x1c, - 0xc3, 0x98, 0xc1, 0x2, 0x8b, 0xf2, 0x81, 0xfe, 0x7b}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xf4, 0x36, 0x5c, 0x76, 0x8f, 0x62, 0xb5, 0xbc, - 0x82, 0x99, 0x74, 0xed, 0xb9, 0x3e, 0x82}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xa1, 0x67, 0x33, 0xc1, 0xb5, 0x47, 0x3b}; - lwmqtt_string_t topic_filter_s10 = {7, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24232, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 1966 [("\202jY\229%\180?VjcM\232\215\146\SYNs\253\SYNW\162\170\244Y",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("6\r\249\236N\201*c",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("K\131A\193\166$\USc,N\221\254\172\242\137\232s\"l\ETB\DC4;S\198(",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("r\129\"\198\151\161\183\159\156\156\202\DC1\GS\153\EOT\ETX\146",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\202aP!\RSH\210E\130Q\ETX\r\161r -// \168u\216\145\SYN\157G\204\148\180\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("]wv2\143\149\148\159\RS\157",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\158\DC4\161$H\248\233\&7q\130-\225\219em\181\DC4nH\v\228=G#0\243O\f\DC4{",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(";\232\243\148t\249g\EM\247\&4 -// \198\130\228\f\ACK\203\199\250\215\&6\RS\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("I\191\225\be\SO\193\210\CAN=z\199$i\\a\157\145\132\&7\137\174\GS\148\ESC\245\194\193\134J",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\189\225\230\152\147\154q\DC2\158\197\187\194\178\146&\GSl\235\157\248\246\"\232\253\204\253I\DC2\143<",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode33) { - uint8_t pkt[] = { - 0x82, 0xfe, 0x1, 0x7, 0xae, 0x0, 0x17, 0xca, 0x6a, 0x59, 0xe5, 0x25, 0xb4, 0x3f, 0x56, 0x6a, 0x63, 0x4d, 0xe8, - 0xd7, 0x92, 0x16, 0x73, 0xfd, 0x16, 0x57, 0xa2, 0xaa, 0xf4, 0x59, 0x2, 0x0, 0x8, 0x36, 0xd, 0xf9, 0xec, 0x4e, - 0xc9, 0x2a, 0x63, 0x0, 0x0, 0x19, 0x4b, 0x83, 0x41, 0xc1, 0xa6, 0x24, 0x1f, 0x63, 0x2c, 0x4e, 0xdd, 0xfe, 0xac, - 0xf2, 0x89, 0xe8, 0x73, 0x22, 0x6c, 0x17, 0x14, 0x3b, 0x53, 0xc6, 0x28, 0x2, 0x0, 0x11, 0x72, 0x81, 0x22, 0xc6, - 0x97, 0xa1, 0xb7, 0x9f, 0x9c, 0x9c, 0xca, 0x11, 0x1d, 0x99, 0x4, 0x3, 0x92, 0x0, 0x0, 0x1a, 0xca, 0x61, 0x50, - 0x21, 0x1e, 0x48, 0xd2, 0x45, 0x82, 0x51, 0x3, 0xd, 0xa1, 0x72, 0x20, 0xa8, 0x75, 0xd8, 0x91, 0x16, 0x9d, 0x47, - 0xcc, 0x94, 0xb4, 0x2, 0x0, 0x0, 0xa, 0x5d, 0x77, 0x76, 0x32, 0x8f, 0x95, 0x94, 0x9f, 0x1e, 0x9d, 0x2, 0x0, - 0x1e, 0x9e, 0x14, 0xa1, 0x24, 0x48, 0xf8, 0xe9, 0x37, 0x71, 0x82, 0x2d, 0xe1, 0xdb, 0x65, 0x6d, 0xb5, 0x14, 0x6e, - 0x48, 0xb, 0xe4, 0x3d, 0x47, 0x23, 0x30, 0xf3, 0x4f, 0xc, 0x14, 0x7b, 0x1, 0x0, 0x17, 0x3b, 0xe8, 0xf3, 0x94, - 0x74, 0xf9, 0x67, 0x19, 0xf7, 0x34, 0x20, 0xc6, 0x82, 0xe4, 0xc, 0x6, 0xcb, 0xc7, 0xfa, 0xd7, 0x36, 0x1e, 0x94, - 0x0, 0x0, 0x1e, 0x49, 0xbf, 0xe1, 0x8, 0x65, 0xe, 0xc1, 0xd2, 0x18, 0x3d, 0x7a, 0xc7, 0x24, 0x69, 0x5c, 0x61, - 0x9d, 0x91, 0x84, 0x37, 0x89, 0xae, 0x1d, 0x94, 0x1b, 0xf5, 0xc2, 0xc1, 0x86, 0x4a, 0x0, 0x0, 0x1e, 0xbd, 0xe1, - 0xe6, 0x98, 0x93, 0x9a, 0x71, 0x12, 0x9e, 0xc5, 0xbb, 0xc2, 0xb2, 0x92, 0x26, 0x1d, 0x6c, 0xeb, 0x9d, 0xf8, 0xf6, - 0x22, 0xe8, 0xfd, 0xcc, 0xfd, 0x49, 0x12, 0x8f, 0x3c, 0x2}; - - uint8_t buf[267] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xca, 0x6a, 0x59, 0xe5, 0x25, 0xb4, 0x3f, 0x56, 0x6a, 0x63, 0x4d, 0xe8, - 0xd7, 0x92, 0x16, 0x73, 0xfd, 0x16, 0x57, 0xa2, 0xaa, 0xf4, 0x59}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x36, 0xd, 0xf9, 0xec, 0x4e, 0xc9, 0x2a, 0x63}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4b, 0x83, 0x41, 0xc1, 0xa6, 0x24, 0x1f, 0x63, 0x2c, 0x4e, 0xdd, 0xfe, 0xac, - 0xf2, 0x89, 0xe8, 0x73, 0x22, 0x6c, 0x17, 0x14, 0x3b, 0x53, 0xc6, 0x28}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x72, 0x81, 0x22, 0xc6, 0x97, 0xa1, 0xb7, 0x9f, 0x9c, - 0x9c, 0xca, 0x11, 0x1d, 0x99, 0x4, 0x3, 0x92}; - lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xca, 0x61, 0x50, 0x21, 0x1e, 0x48, 0xd2, 0x45, 0x82, 0x51, 0x3, 0xd, 0xa1, - 0x72, 0x20, 0xa8, 0x75, 0xd8, 0x91, 0x16, 0x9d, 0x47, 0xcc, 0x94, 0xb4, 0x2}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5d, 0x77, 0x76, 0x32, 0x8f, 0x95, 0x94, 0x9f, 0x1e, 0x9d}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x9e, 0x14, 0xa1, 0x24, 0x48, 0xf8, 0xe9, 0x37, 0x71, 0x82, - 0x2d, 0xe1, 0xdb, 0x65, 0x6d, 0xb5, 0x14, 0x6e, 0x48, 0xb, - 0xe4, 0x3d, 0x47, 0x23, 0x30, 0xf3, 0x4f, 0xc, 0x14, 0x7b}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x3b, 0xe8, 0xf3, 0x94, 0x74, 0xf9, 0x67, 0x19, 0xf7, 0x34, 0x20, 0xc6, - 0x82, 0xe4, 0xc, 0x6, 0xcb, 0xc7, 0xfa, 0xd7, 0x36, 0x1e, 0x94}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x49, 0xbf, 0xe1, 0x8, 0x65, 0xe, 0xc1, 0xd2, 0x18, 0x3d, - 0x7a, 0xc7, 0x24, 0x69, 0x5c, 0x61, 0x9d, 0x91, 0x84, 0x37, - 0x89, 0xae, 0x1d, 0x94, 0x1b, 0xf5, 0xc2, 0xc1, 0x86, 0x4a}; - lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xbd, 0xe1, 0xe6, 0x98, 0x93, 0x9a, 0x71, 0x12, 0x9e, 0xc5, - 0xbb, 0xc2, 0xb2, 0x92, 0x26, 0x1d, 0x6c, 0xeb, 0x9d, 0xf8, - 0xf6, 0x22, 0xe8, 0xfd, 0xcc, 0xfd, 0x49, 0x12, 0x8f, 0x3c}; - lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1966, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 11595 [("\157Y\254\b\253\241E\158M\CAN\255\215Q\ENQ\217\131\177",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\171\DC1\150\DLE\ETBSSi\198{\213\206\249t\216\rt\218\236\161\143\&8\145",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\181\FS]\249\210A:\189\185\DC1\ENQ\175]\150\218\169\SOH\193\SOH`\150\169\182l",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\233/\143\172\SIn:m\212Pf\177&\234\165\181\226\DEL3\153\SI\241l\144\242",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode34) { - uint8_t pkt[] = {0x82, 0x67, 0x2d, 0x4b, 0x0, 0x11, 0x9d, 0x59, 0xfe, 0x8, 0xfd, 0xf1, 0x45, 0x9e, 0x4d, - 0x18, 0xff, 0xd7, 0x51, 0x5, 0xd9, 0x83, 0xb1, 0x2, 0x0, 0x17, 0xab, 0x11, 0x96, 0x10, - 0x17, 0x53, 0x53, 0x69, 0xc6, 0x7b, 0xd5, 0xce, 0xf9, 0x74, 0xd8, 0xd, 0x74, 0xda, 0xec, - 0xa1, 0x8f, 0x38, 0x91, 0x2, 0x0, 0x18, 0xb5, 0x1c, 0x5d, 0xf9, 0xd2, 0x41, 0x3a, 0xbd, - 0xb9, 0x11, 0x5, 0xaf, 0x5d, 0x96, 0xda, 0xa9, 0x1, 0xc1, 0x1, 0x60, 0x96, 0xa9, 0xb6, - 0x6c, 0x2, 0x0, 0x19, 0xe9, 0x2f, 0x8f, 0xac, 0xf, 0x6e, 0x3a, 0x6d, 0xd4, 0x50, 0x66, - 0xb1, 0x26, 0xea, 0xa5, 0xb5, 0xe2, 0x7f, 0x33, 0x99, 0xf, 0xf1, 0x6c, 0x90, 0xf2, 0x1}; - - uint8_t buf[115] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x9d, 0x59, 0xfe, 0x8, 0xfd, 0xf1, 0x45, 0x9e, 0x4d, - 0x18, 0xff, 0xd7, 0x51, 0x5, 0xd9, 0x83, 0xb1}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xab, 0x11, 0x96, 0x10, 0x17, 0x53, 0x53, 0x69, 0xc6, 0x7b, 0xd5, 0xce, - 0xf9, 0x74, 0xd8, 0xd, 0x74, 0xda, 0xec, 0xa1, 0x8f, 0x38, 0x91}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb5, 0x1c, 0x5d, 0xf9, 0xd2, 0x41, 0x3a, 0xbd, 0xb9, 0x11, 0x5, 0xaf, - 0x5d, 0x96, 0xda, 0xa9, 0x1, 0xc1, 0x1, 0x60, 0x96, 0xa9, 0xb6, 0x6c}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe9, 0x2f, 0x8f, 0xac, 0xf, 0x6e, 0x3a, 0x6d, 0xd4, 0x50, 0x66, 0xb1, 0x26, - 0xea, 0xa5, 0xb5, 0xe2, 0x7f, 0x33, 0x99, 0xf, 0xf1, 0x6c, 0x90, 0xf2}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11595, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 3561 [("\SI\230\235\135\157\175%\128",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\174\n|v\146#k\154\224-R\219\SUB\245k\186\207: -// \r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\DC2\181\156\155\180{\234\ETX\GS\223\168\199u\168N\218w\246\&3\DC3z\168y\249",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\170\211",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("R\230\221\&6\239O\211\146vM3YD\140\129+\194B\160\200\163\189",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode35) { - uint8_t pkt[] = {0x82, 0x5d, 0xd, 0xe9, 0x0, 0x8, 0xf, 0xe6, 0xeb, 0x87, 0x9d, 0xaf, 0x25, 0x80, 0x0, 0x0, - 0x14, 0xae, 0xa, 0x7c, 0x76, 0x92, 0x23, 0x6b, 0x9a, 0xe0, 0x2d, 0x52, 0xdb, 0x1a, 0xf5, 0x6b, - 0xba, 0xcf, 0x3a, 0x20, 0xd, 0x0, 0x0, 0x18, 0x12, 0xb5, 0x9c, 0x9b, 0xb4, 0x7b, 0xea, 0x3, - 0x1d, 0xdf, 0xa8, 0xc7, 0x75, 0xa8, 0x4e, 0xda, 0x77, 0xf6, 0x33, 0x13, 0x7a, 0xa8, 0x79, 0xf9, - 0x1, 0x0, 0x2, 0xaa, 0xd3, 0x2, 0x0, 0x16, 0x52, 0xe6, 0xdd, 0x36, 0xef, 0x4f, 0xd3, 0x92, - 0x76, 0x4d, 0x33, 0x59, 0x44, 0x8c, 0x81, 0x2b, 0xc2, 0x42, 0xa0, 0xc8, 0xa3, 0xbd, 0x0}; - - uint8_t buf[105] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xf, 0xe6, 0xeb, 0x87, 0x9d, 0xaf, 0x25, 0x80}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xae, 0xa, 0x7c, 0x76, 0x92, 0x23, 0x6b, 0x9a, 0xe0, 0x2d, - 0x52, 0xdb, 0x1a, 0xf5, 0x6b, 0xba, 0xcf, 0x3a, 0x20, 0xd}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x12, 0xb5, 0x9c, 0x9b, 0xb4, 0x7b, 0xea, 0x3, 0x1d, 0xdf, 0xa8, 0xc7, - 0x75, 0xa8, 0x4e, 0xda, 0x77, 0xf6, 0x33, 0x13, 0x7a, 0xa8, 0x79, 0xf9}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xaa, 0xd3}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x52, 0xe6, 0xdd, 0x36, 0xef, 0x4f, 0xd3, 0x92, 0x76, 0x4d, 0x33, - 0x59, 0x44, 0x8c, 0x81, 0x2b, 0xc2, 0x42, 0xa0, 0xc8, 0xa3, 0xbd}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3561, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 27717 [("\241m\204\194)1\\\134\EOTj\252\251\183\169o~+",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\165\223\t",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ETX)\192\ETXE\164\158\181\239\216\SOH\131\171\196\207",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\182bC|\240!\219\DC4Q\200\161",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\160\162\&7\226\196(\141G\165\139\207\SI\255\171\251J\DC2\ETX\168q'1\240-^\185\192\191]",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("}$%\168\155\130\v\149v!\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\167o\ETX\243\&6\210\&8\STX\199\236h\129H1M\147\GS\241\143S\246B\130\234\160\215\223\184",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\SUBq\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("]g\181\SUBP\232h\172\GS\180\247\RS\203\236",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\201\158",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("C\229\189\187\171\185\NAKjA!\129\253",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode36) { - uint8_t pkt[] = {0x82, 0xb4, 0x1, 0x6c, 0x45, 0x0, 0x11, 0xf1, 0x6d, 0xcc, 0xc2, 0x29, 0x31, 0x5c, 0x86, 0x4, 0x6a, - 0xfc, 0xfb, 0xb7, 0xa9, 0x6f, 0x7e, 0x2b, 0x1, 0x0, 0x3, 0xa5, 0xdf, 0x9, 0x1, 0x0, 0xf, 0x3, - 0x29, 0xc0, 0x3, 0x45, 0xa4, 0x9e, 0xb5, 0xef, 0xd8, 0x1, 0x83, 0xab, 0xc4, 0xcf, 0x2, 0x0, 0xb, - 0xb6, 0x62, 0x43, 0x7c, 0xf0, 0x21, 0xdb, 0x14, 0x51, 0xc8, 0xa1, 0x1, 0x0, 0x1d, 0xa0, 0xa2, 0x37, - 0xe2, 0xc4, 0x28, 0x8d, 0x47, 0xa5, 0x8b, 0xcf, 0xf, 0xff, 0xab, 0xfb, 0x4a, 0x12, 0x3, 0xa8, 0x71, - 0x27, 0x31, 0xf0, 0x2d, 0x5e, 0xb9, 0xc0, 0xbf, 0x5d, 0x1, 0x0, 0xb, 0x7d, 0x24, 0x25, 0xa8, 0x9b, - 0x82, 0xb, 0x95, 0x76, 0x21, 0xa6, 0x2, 0x0, 0x1c, 0xa7, 0x6f, 0x3, 0xf3, 0x36, 0xd2, 0x38, 0x2, - 0xc7, 0xec, 0x68, 0x81, 0x48, 0x31, 0x4d, 0x93, 0x1d, 0xf1, 0x8f, 0x53, 0xf6, 0x42, 0x82, 0xea, 0xa0, - 0xd7, 0xdf, 0xb8, 0x2, 0x0, 0x3, 0x1a, 0x71, 0xeb, 0x0, 0x0, 0xe, 0x5d, 0x67, 0xb5, 0x1a, 0x50, - 0xe8, 0x68, 0xac, 0x1d, 0xb4, 0xf7, 0x1e, 0xcb, 0xec, 0x1, 0x0, 0x2, 0xc9, 0x9e, 0x1, 0x0, 0xc, - 0x43, 0xe5, 0xbd, 0xbb, 0xab, 0xb9, 0x15, 0x6a, 0x41, 0x21, 0x81, 0xfd, 0x2}; - - uint8_t buf[193] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xf1, 0x6d, 0xcc, 0xc2, 0x29, 0x31, 0x5c, 0x86, 0x4, - 0x6a, 0xfc, 0xfb, 0xb7, 0xa9, 0x6f, 0x7e, 0x2b}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa5, 0xdf, 0x9}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x3, 0x29, 0xc0, 0x3, 0x45, 0xa4, 0x9e, 0xb5, - 0xef, 0xd8, 0x1, 0x83, 0xab, 0xc4, 0xcf}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb6, 0x62, 0x43, 0x7c, 0xf0, 0x21, 0xdb, 0x14, 0x51, 0xc8, 0xa1}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa0, 0xa2, 0x37, 0xe2, 0xc4, 0x28, 0x8d, 0x47, 0xa5, 0x8b, - 0xcf, 0xf, 0xff, 0xab, 0xfb, 0x4a, 0x12, 0x3, 0xa8, 0x71, - 0x27, 0x31, 0xf0, 0x2d, 0x5e, 0xb9, 0xc0, 0xbf, 0x5d}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7d, 0x24, 0x25, 0xa8, 0x9b, 0x82, 0xb, 0x95, 0x76, 0x21, 0xa6}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa7, 0x6f, 0x3, 0xf3, 0x36, 0xd2, 0x38, 0x2, 0xc7, 0xec, - 0x68, 0x81, 0x48, 0x31, 0x4d, 0x93, 0x1d, 0xf1, 0x8f, 0x53, - 0xf6, 0x42, 0x82, 0xea, 0xa0, 0xd7, 0xdf, 0xb8}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x1a, 0x71, 0xeb}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x5d, 0x67, 0xb5, 0x1a, 0x50, 0xe8, 0x68, - 0xac, 0x1d, 0xb4, 0xf7, 0x1e, 0xcb, 0xec}; - lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xc9, 0x9e}; - lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x43, 0xe5, 0xbd, 0xbb, 0xab, 0xb9, 0x15, 0x6a, 0x41, 0x21, 0x81, 0xfd}; - lwmqtt_string_t topic_filter_s10 = {12, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27717, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 10081 [("\254\182\236\b\134\175Afy\149p\146)\CAN\196]\172",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\140\141\202Y\140aB-\ENQx\198i\168\DEL\ESC\244\250-",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode37) { - uint8_t pkt[] = {0x82, 0x2b, 0x27, 0x61, 0x0, 0x11, 0xfe, 0xb6, 0xec, 0x8, 0x86, 0xaf, 0x41, 0x66, 0x79, - 0x95, 0x70, 0x92, 0x29, 0x18, 0xc4, 0x5d, 0xac, 0x0, 0x0, 0x12, 0x8c, 0x8d, 0xca, 0x59, - 0x8c, 0x61, 0x42, 0x2d, 0x5, 0x78, 0xc6, 0x69, 0xa8, 0x7f, 0x1b, 0xf4, 0xfa, 0x2d, 0x1}; - - uint8_t buf[55] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xfe, 0xb6, 0xec, 0x8, 0x86, 0xaf, 0x41, 0x66, 0x79, - 0x95, 0x70, 0x92, 0x29, 0x18, 0xc4, 0x5d, 0xac}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8c, 0x8d, 0xca, 0x59, 0x8c, 0x61, 0x42, 0x2d, 0x5, - 0x78, 0xc6, 0x69, 0xa8, 0x7f, 0x1b, 0xf4, 0xfa, 0x2d}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10081, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12277 [("Qa\142\154\DC1\250'%d\167",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\251-\198\134\225\144X\220\STXN\142\199g*\SYN\128\238\209\135\238\166\183Q\232K)",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\173\&7va\196^-\248\&9\223;d\152(1\217u\154X\206\246\247\129o\211Z",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("8\207\165@\ESC\201\ri\241",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\141{KJ$\219&c3\196\b3,W\232`\131~\\\165\243\175\201\199E\240\SO6",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode38) { - uint8_t pkt[] = {0x82, 0x74, 0x2f, 0xf5, 0x0, 0xa, 0x51, 0x61, 0x8e, 0x9a, 0x11, 0xfa, 0x27, 0x25, 0x64, 0xa7, 0x1, - 0x0, 0x1a, 0xfb, 0x2d, 0xc6, 0x86, 0xe1, 0x90, 0x58, 0xdc, 0x2, 0x4e, 0x8e, 0xc7, 0x67, 0x2a, 0x16, - 0x80, 0xee, 0xd1, 0x87, 0xee, 0xa6, 0xb7, 0x51, 0xe8, 0x4b, 0x29, 0x1, 0x0, 0x1a, 0xad, 0x37, 0x76, - 0x61, 0xc4, 0x5e, 0x2d, 0xf8, 0x39, 0xdf, 0x3b, 0x64, 0x98, 0x28, 0x31, 0xd9, 0x75, 0x9a, 0x58, 0xce, - 0xf6, 0xf7, 0x81, 0x6f, 0xd3, 0x5a, 0x1, 0x0, 0x9, 0x38, 0xcf, 0xa5, 0x40, 0x1b, 0xc9, 0xd, 0x69, - 0xf1, 0x2, 0x0, 0x1c, 0x8d, 0x7b, 0x4b, 0x4a, 0x24, 0xdb, 0x26, 0x63, 0x33, 0xc4, 0x8, 0x33, 0x2c, - 0x57, 0xe8, 0x60, 0x83, 0x7e, 0x5c, 0xa5, 0xf3, 0xaf, 0xc9, 0xc7, 0x45, 0xf0, 0xe, 0x36, 0x0}; - - uint8_t buf[128] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x51, 0x61, 0x8e, 0x9a, 0x11, 0xfa, 0x27, 0x25, 0x64, 0xa7}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfb, 0x2d, 0xc6, 0x86, 0xe1, 0x90, 0x58, 0xdc, 0x2, 0x4e, 0x8e, 0xc7, 0x67, - 0x2a, 0x16, 0x80, 0xee, 0xd1, 0x87, 0xee, 0xa6, 0xb7, 0x51, 0xe8, 0x4b, 0x29}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xad, 0x37, 0x76, 0x61, 0xc4, 0x5e, 0x2d, 0xf8, 0x39, 0xdf, 0x3b, 0x64, 0x98, - 0x28, 0x31, 0xd9, 0x75, 0x9a, 0x58, 0xce, 0xf6, 0xf7, 0x81, 0x6f, 0xd3, 0x5a}; - lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x38, 0xcf, 0xa5, 0x40, 0x1b, 0xc9, 0xd, 0x69, 0xf1}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8d, 0x7b, 0x4b, 0x4a, 0x24, 0xdb, 0x26, 0x63, 0x33, 0xc4, - 0x8, 0x33, 0x2c, 0x57, 0xe8, 0x60, 0x83, 0x7e, 0x5c, 0xa5, - 0xf3, 0xaf, 0xc9, 0xc7, 0x45, 0xf0, 0xe, 0x36}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12277, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 518 [("\139\STXE:n\137b\f\184\166\168\143a\150+/\136,\154\148\190k\196u\189n\n",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode39) { - uint8_t pkt[] = {0x82, 0x20, 0x2, 0x6, 0x0, 0x1b, 0x8b, 0x2, 0x45, 0x3a, 0x6e, 0x89, 0x62, 0xc, 0xb8, 0xa6, 0xa8, - 0x8f, 0x61, 0x96, 0x2b, 0x2f, 0x88, 0x2c, 0x9a, 0x94, 0xbe, 0x6b, 0xc4, 0x75, 0xbd, 0x6e, 0xa, 0x2}; - - uint8_t buf[44] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x8b, 0x2, 0x45, 0x3a, 0x6e, 0x89, 0x62, 0xc, 0xb8, 0xa6, 0xa8, 0x8f, 0x61, 0x96, - 0x2b, 0x2f, 0x88, 0x2c, 0x9a, 0x94, 0xbe, 0x6b, 0xc4, 0x75, 0xbd, 0x6e, 0xa}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 518, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 20513 [("\246\249y9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\174\158\&9I\236",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\234)\247\155]i\178i\160:\ENQ\162\186\204\194v^KTS.P\233&\189",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode40) { - uint8_t pkt[] = {0x82, 0x2d, 0x50, 0x21, 0x0, 0x4, 0xf6, 0xf9, 0x79, 0x39, 0x0, 0x0, 0x5, 0xae, 0x9e, 0x39, - 0x49, 0xec, 0x1, 0x0, 0x19, 0xea, 0x29, 0xf7, 0x9b, 0x5d, 0x69, 0xb2, 0x69, 0xa0, 0x3a, 0x5, - 0xa2, 0xba, 0xcc, 0xc2, 0x76, 0x5e, 0x4b, 0x54, 0x53, 0x2e, 0x50, 0xe9, 0x26, 0xbd, 0x1}; - - uint8_t buf[57] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xf6, 0xf9, 0x79, 0x39}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xae, 0x9e, 0x39, 0x49, 0xec}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xea, 0x29, 0xf7, 0x9b, 0x5d, 0x69, 0xb2, 0x69, 0xa0, 0x3a, 0x5, 0xa2, 0xba, - 0xcc, 0xc2, 0x76, 0x5e, 0x4b, 0x54, 0x53, 0x2e, 0x50, 0xe9, 0x26, 0xbd}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20513, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 13179 [("YR\212\171\209\EOTx\164\209\197\US\155",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\235",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\172\250G",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\r\149\246#m\237\132i\162%c\ESC\144\159F`\229\254\ENQG",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("}O6\STX\EM\250D>\167\STX",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\140\134n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode41) { - uint8_t pkt[] = {0x82, 0x48, 0x33, 0x7b, 0x0, 0xc, 0x59, 0x52, 0xd4, 0xab, 0xd1, 0x4, 0x78, 0xa4, 0xd1, - 0xc5, 0x1f, 0x9b, 0x1, 0x0, 0x1, 0xeb, 0x1, 0x0, 0x3, 0xac, 0xfa, 0x47, 0x2, 0x0, - 0x0, 0x2, 0x0, 0x14, 0xd, 0x95, 0xf6, 0x23, 0x6d, 0xed, 0x84, 0x69, 0xa2, 0x25, 0x63, - 0x1b, 0x90, 0x9f, 0x46, 0x60, 0xe5, 0xfe, 0x5, 0x47, 0x1, 0x0, 0xa, 0x7d, 0x4f, 0x36, - 0x2, 0x19, 0xfa, 0x44, 0x3e, 0xa7, 0x2, 0x0, 0x0, 0x3, 0x8c, 0x86, 0x6e, 0x2}; - - uint8_t buf[84] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x59, 0x52, 0xd4, 0xab, 0xd1, 0x4, 0x78, 0xa4, 0xd1, 0xc5, 0x1f, 0x9b}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xeb}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xac, 0xfa, 0x47}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd, 0x95, 0xf6, 0x23, 0x6d, 0xed, 0x84, 0x69, 0xa2, 0x25, - 0x63, 0x1b, 0x90, 0x9f, 0x46, 0x60, 0xe5, 0xfe, 0x5, 0x47}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7d, 0x4f, 0x36, 0x2, 0x19, 0xfa, 0x44, 0x3e, 0xa7, 0x2}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8c, 0x86, 0x6e}; - lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13179, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2708 [("\128\SUB\143\242\FS\143\181\142tg\159H\SI\193<",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\STX\194;\241\194\228a\t\191u0o\203O|\SUBV\174x\171\235\159\149\&6",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("4\173\128\155%\a\234\DLE\166\&1\188\EOT@\142qQuA\154N",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\169p4\162\139:?",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\130)\226\134",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode42) { - uint8_t pkt[] = {0x82, 0x57, 0xa, 0x94, 0x0, 0xf, 0x80, 0x1a, 0x8f, 0xf2, 0x1c, 0x8f, 0xb5, 0x8e, 0x74, - 0x67, 0x9f, 0x48, 0xf, 0xc1, 0x3c, 0x1, 0x0, 0x18, 0x2, 0xc2, 0x3b, 0xf1, 0xc2, 0xe4, - 0x61, 0x9, 0xbf, 0x75, 0x30, 0x6f, 0xcb, 0x4f, 0x7c, 0x1a, 0x56, 0xae, 0x78, 0xab, 0xeb, - 0x9f, 0x95, 0x36, 0x2, 0x0, 0x14, 0x34, 0xad, 0x80, 0x9b, 0x25, 0x7, 0xea, 0x10, 0xa6, - 0x31, 0xbc, 0x4, 0x40, 0x8e, 0x71, 0x51, 0x75, 0x41, 0x9a, 0x4e, 0x1, 0x0, 0x7, 0xa9, - 0x70, 0x34, 0xa2, 0x8b, 0x3a, 0x3f, 0x1, 0x0, 0x4, 0x82, 0x29, 0xe2, 0x86, 0x0}; - - uint8_t buf[99] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x80, 0x1a, 0x8f, 0xf2, 0x1c, 0x8f, 0xb5, 0x8e, - 0x74, 0x67, 0x9f, 0x48, 0xf, 0xc1, 0x3c}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2, 0xc2, 0x3b, 0xf1, 0xc2, 0xe4, 0x61, 0x9, 0xbf, 0x75, 0x30, 0x6f, - 0xcb, 0x4f, 0x7c, 0x1a, 0x56, 0xae, 0x78, 0xab, 0xeb, 0x9f, 0x95, 0x36}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x34, 0xad, 0x80, 0x9b, 0x25, 0x7, 0xea, 0x10, 0xa6, 0x31, - 0xbc, 0x4, 0x40, 0x8e, 0x71, 0x51, 0x75, 0x41, 0x9a, 0x4e}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa9, 0x70, 0x34, 0xa2, 0x8b, 0x3a, 0x3f}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x82, 0x29, 0xe2, 0x86}; - lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2708, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 22393 [("4\151\147%\225\205\145\214",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\170\240\162w`E\254\232 -// \143\DC2x\209h3\148\197\DEL\195~\165h\DLE\232\201Bm",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\248\158\234\227[R.\240VV'\227@\DC3)\DLE\242\199\US\199\221H\199",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode43) { - uint8_t pkt[] = {0x82, 0x45, 0x57, 0x79, 0x0, 0x8, 0x34, 0x97, 0x93, 0x25, 0xe1, 0xcd, 0x91, 0xd6, 0x2, - 0x0, 0x1b, 0xaa, 0xf0, 0xa2, 0x77, 0x60, 0x45, 0xfe, 0xe8, 0x20, 0x8f, 0x12, 0x78, 0xd1, - 0x68, 0x33, 0x94, 0xc5, 0x7f, 0xc3, 0x7e, 0xa5, 0x68, 0x10, 0xe8, 0xc9, 0x42, 0x6d, 0x2, - 0x0, 0x17, 0xf8, 0x9e, 0xea, 0xe3, 0x5b, 0x52, 0x2e, 0xf0, 0x56, 0x56, 0x27, 0xe3, 0x40, - 0x13, 0x29, 0x10, 0xf2, 0xc7, 0x1f, 0xc7, 0xdd, 0x48, 0xc7, 0x0}; - - uint8_t buf[81] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x34, 0x97, 0x93, 0x25, 0xe1, 0xcd, 0x91, 0xd6}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xaa, 0xf0, 0xa2, 0x77, 0x60, 0x45, 0xfe, 0xe8, 0x20, 0x8f, 0x12, 0x78, 0xd1, 0x68, - 0x33, 0x94, 0xc5, 0x7f, 0xc3, 0x7e, 0xa5, 0x68, 0x10, 0xe8, 0xc9, 0x42, 0x6d}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf8, 0x9e, 0xea, 0xe3, 0x5b, 0x52, 0x2e, 0xf0, 0x56, 0x56, 0x27, 0xe3, - 0x40, 0x13, 0x29, 0x10, 0xf2, 0xc7, 0x1f, 0xc7, 0xdd, 0x48, 0xc7}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22393, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 16009 [("\v\252$!\153S\184\231\225\247\182w\185\196\179\251-)D\130W\129\222\SYNQ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Bn\211\153\\\EOT\238\190\196\180C1\146B\199\236h\DC1\210\&9,\147I",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\EOT;7\159\130c%\243\CAN\148\213\v\247'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\220\225\t\132\131\223\183",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode44) { - uint8_t pkt[] = {0x82, 0x53, 0x3e, 0x89, 0x0, 0x19, 0xb, 0xfc, 0x24, 0x21, 0x99, 0x53, 0xb8, 0xe7, 0xe1, 0xf7, 0xb6, - 0x77, 0xb9, 0xc4, 0xb3, 0xfb, 0x2d, 0x29, 0x44, 0x82, 0x57, 0x81, 0xde, 0x16, 0x51, 0x2, 0x0, 0x17, - 0x42, 0x6e, 0xd3, 0x99, 0x5c, 0x4, 0xee, 0xbe, 0xc4, 0xb4, 0x43, 0x31, 0x92, 0x42, 0xc7, 0xec, 0x68, - 0x11, 0xd2, 0x39, 0x2c, 0x93, 0x49, 0x1, 0x0, 0xe, 0x4, 0x3b, 0x37, 0x9f, 0x82, 0x63, 0x25, 0xf3, - 0x18, 0x94, 0xd5, 0xb, 0xf7, 0x27, 0x1, 0x0, 0x7, 0xdc, 0xe1, 0x9, 0x84, 0x83, 0xdf, 0xb7, 0x1}; - - uint8_t buf[95] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xb, 0xfc, 0x24, 0x21, 0x99, 0x53, 0xb8, 0xe7, 0xe1, 0xf7, 0xb6, 0x77, 0xb9, - 0xc4, 0xb3, 0xfb, 0x2d, 0x29, 0x44, 0x82, 0x57, 0x81, 0xde, 0x16, 0x51}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x42, 0x6e, 0xd3, 0x99, 0x5c, 0x4, 0xee, 0xbe, 0xc4, 0xb4, 0x43, 0x31, - 0x92, 0x42, 0xc7, 0xec, 0x68, 0x11, 0xd2, 0x39, 0x2c, 0x93, 0x49}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4, 0x3b, 0x37, 0x9f, 0x82, 0x63, 0x25, 0xf3, 0x18, 0x94, 0xd5, 0xb, 0xf7, 0x27}; - lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xdc, 0xe1, 0x9, 0x84, 0x83, 0xdf, 0xb7}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16009, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14676 [("\219\215v\249b\191\208\&8H\181\rI&\210",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode45) { - uint8_t pkt[] = {0x82, 0x13, 0x39, 0x54, 0x0, 0xe, 0xdb, 0xd7, 0x76, 0xf9, 0x62, - 0xbf, 0xd0, 0x38, 0x48, 0xb5, 0xd, 0x49, 0x26, 0xd2, 0x1}; - - uint8_t buf[31] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xdb, 0xd7, 0x76, 0xf9, 0x62, 0xbf, 0xd0, 0x38, 0x48, 0xb5, 0xd, 0x49, 0x26, 0xd2}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14676, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2406 -// [("\154wi\237\149\207\222\244\234fa?\209A\DEL\205\221\&5\DLE\224@\211\160\208\239\&0\134\SO\NUL",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("L|I\231\128\172e\STX@\198x",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("Sa \169\184R\183\199\225\251\153%v6\228H\"\244J\193",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(";\"\b\143\221\r",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\210\147\237\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\141\237\229\157\173\ETXX/\224\174,\\\236\228",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\219\SOH\f)\241\252",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode46) { - uint8_t pkt[] = {0x82, 0x71, 0x9, 0x66, 0x0, 0x1d, 0x9a, 0x77, 0x69, 0xed, 0x95, 0xcf, 0xde, 0xf4, 0xea, 0x66, 0x61, - 0x3f, 0xd1, 0x41, 0x7f, 0xcd, 0xdd, 0x35, 0x10, 0xe0, 0x40, 0xd3, 0xa0, 0xd0, 0xef, 0x30, 0x86, 0xe, - 0x0, 0x0, 0x0, 0xb, 0x4c, 0x7c, 0x49, 0xe7, 0x80, 0xac, 0x65, 0x2, 0x40, 0xc6, 0x78, 0x0, 0x0, - 0x14, 0x53, 0x61, 0x20, 0xa9, 0xb8, 0x52, 0xb7, 0xc7, 0xe1, 0xfb, 0x99, 0x25, 0x76, 0x36, 0xe4, 0x48, - 0x22, 0xf4, 0x4a, 0xc1, 0x0, 0x0, 0x6, 0x3b, 0x22, 0x8, 0x8f, 0xdd, 0xd, 0x0, 0x0, 0x4, 0xd2, - 0x93, 0xed, 0x19, 0x2, 0x0, 0xe, 0x8d, 0xed, 0xe5, 0x9d, 0xad, 0x3, 0x58, 0x2f, 0xe0, 0xae, 0x2c, - 0x5c, 0xec, 0xe4, 0x2, 0x0, 0x6, 0xdb, 0x1, 0xc, 0x29, 0xf1, 0xfc, 0x1}; - - uint8_t buf[125] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x9a, 0x77, 0x69, 0xed, 0x95, 0xcf, 0xde, 0xf4, 0xea, 0x66, - 0x61, 0x3f, 0xd1, 0x41, 0x7f, 0xcd, 0xdd, 0x35, 0x10, 0xe0, - 0x40, 0xd3, 0xa0, 0xd0, 0xef, 0x30, 0x86, 0xe, 0x0}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4c, 0x7c, 0x49, 0xe7, 0x80, 0xac, 0x65, 0x2, 0x40, 0xc6, 0x78}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x53, 0x61, 0x20, 0xa9, 0xb8, 0x52, 0xb7, 0xc7, 0xe1, 0xfb, - 0x99, 0x25, 0x76, 0x36, 0xe4, 0x48, 0x22, 0xf4, 0x4a, 0xc1}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3b, 0x22, 0x8, 0x8f, 0xdd, 0xd}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd2, 0x93, 0xed, 0x19}; - lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8d, 0xed, 0xe5, 0x9d, 0xad, 0x3, 0x58, 0x2f, 0xe0, 0xae, 0x2c, 0x5c, 0xec, 0xe4}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xdb, 0x1, 0xc, 0x29, 0xf1, 0xfc}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2406, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 4955 [("\ENQ\139D6\149b\234\144\205\249k\207\248\b5\137\DC1\211*i\214\212Z\197\232\EM",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\193\&7\178\197`\133\195'\217\NAK\245\130i",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\vU\DEL\193\165\247\239O\244\220",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode47) { - uint8_t pkt[] = {0x82, 0x3c, 0x13, 0x5b, 0x0, 0x1a, 0x5, 0x8b, 0x44, 0x36, 0x95, 0x62, 0xea, 0x90, 0xcd, 0xf9, - 0x6b, 0xcf, 0xf8, 0x8, 0x35, 0x89, 0x11, 0xd3, 0x2a, 0x69, 0xd6, 0xd4, 0x5a, 0xc5, 0xe8, 0x19, - 0x0, 0x0, 0xd, 0xc1, 0x37, 0xb2, 0xc5, 0x60, 0x85, 0xc3, 0x27, 0xd9, 0x15, 0xf5, 0x82, 0x69, - 0x1, 0x0, 0xa, 0xb, 0x55, 0x7f, 0xc1, 0xa5, 0xf7, 0xef, 0x4f, 0xf4, 0xdc, 0x1}; - - uint8_t buf[72] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x5, 0x8b, 0x44, 0x36, 0x95, 0x62, 0xea, 0x90, 0xcd, 0xf9, 0x6b, 0xcf, 0xf8, - 0x8, 0x35, 0x89, 0x11, 0xd3, 0x2a, 0x69, 0xd6, 0xd4, 0x5a, 0xc5, 0xe8, 0x19}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc1, 0x37, 0xb2, 0xc5, 0x60, 0x85, 0xc3, 0x27, 0xd9, 0x15, 0xf5, 0x82, 0x69}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb, 0x55, 0x7f, 0xc1, 0xa5, 0xf7, 0xef, 0x4f, 0xf4, 0xdc}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4955, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 11203 [("\204\DC2P\234<\186\CANVS(\203F\SO\243\v\199\215\190\165-j\243",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\131\130\210u\174\253S\151\142FR\139\135\186\209\232\170\138\156\&1\NAKf\158E\186\167",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("#\151\&7\NULk\190\232\&6\DEL\DC4H\212\161\&6:\225",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\198\255$N$\183E\246\148\&8\242:\214\128\&2\178\149v/\140",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("O:\185)_;T{\187\198[\166&\148\153\147\203\\YB+Z\169fv\133\rL",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\182\ESC\138\244\250D\150\219B\SI\149\ENQ\172]i\166&\153\190~\228\193>\209",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\143\&6\\:",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode48) { - uint8_t pkt[] = {0x82, 0xa3, 0x1, 0x2b, 0xc3, 0x0, 0x16, 0xcc, 0x12, 0x50, 0xea, 0x3c, 0xba, 0x18, 0x56, 0x53, 0x28, - 0xcb, 0x46, 0xe, 0xf3, 0xb, 0xc7, 0xd7, 0xbe, 0xa5, 0x2d, 0x6a, 0xf3, 0x0, 0x0, 0x1a, 0x83, 0x82, - 0xd2, 0x75, 0xae, 0xfd, 0x53, 0x97, 0x8e, 0x46, 0x52, 0x8b, 0x87, 0xba, 0xd1, 0xe8, 0xaa, 0x8a, 0x9c, - 0x31, 0x15, 0x66, 0x9e, 0x45, 0xba, 0xa7, 0x2, 0x0, 0x10, 0x23, 0x97, 0x37, 0x0, 0x6b, 0xbe, 0xe8, - 0x36, 0x7f, 0x14, 0x48, 0xd4, 0xa1, 0x36, 0x3a, 0xe1, 0x0, 0x0, 0x14, 0xc6, 0xff, 0x24, 0x4e, 0x24, - 0xb7, 0x45, 0xf6, 0x94, 0x38, 0xf2, 0x3a, 0xd6, 0x80, 0x32, 0xb2, 0x95, 0x76, 0x2f, 0x8c, 0x0, 0x0, - 0x1c, 0x4f, 0x3a, 0xb9, 0x29, 0x5f, 0x3b, 0x54, 0x7b, 0xbb, 0xc6, 0x5b, 0xa6, 0x26, 0x94, 0x99, 0x93, - 0xcb, 0x5c, 0x59, 0x42, 0x2b, 0x5a, 0xa9, 0x66, 0x76, 0x85, 0xd, 0x4c, 0x0, 0x0, 0x18, 0xb6, 0x1b, - 0x8a, 0xf4, 0xfa, 0x44, 0x96, 0xdb, 0x42, 0xf, 0x95, 0x5, 0xac, 0x5d, 0x69, 0xa6, 0x26, 0x99, 0xbe, - 0x7e, 0xe4, 0xc1, 0x3e, 0xd1, 0x1, 0x0, 0x4, 0x8f, 0x36, 0x5c, 0x3a, 0x1}; - - uint8_t buf[176] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xcc, 0x12, 0x50, 0xea, 0x3c, 0xba, 0x18, 0x56, 0x53, 0x28, 0xcb, - 0x46, 0xe, 0xf3, 0xb, 0xc7, 0xd7, 0xbe, 0xa5, 0x2d, 0x6a, 0xf3}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x83, 0x82, 0xd2, 0x75, 0xae, 0xfd, 0x53, 0x97, 0x8e, 0x46, 0x52, 0x8b, 0x87, - 0xba, 0xd1, 0xe8, 0xaa, 0x8a, 0x9c, 0x31, 0x15, 0x66, 0x9e, 0x45, 0xba, 0xa7}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x23, 0x97, 0x37, 0x0, 0x6b, 0xbe, 0xe8, 0x36, - 0x7f, 0x14, 0x48, 0xd4, 0xa1, 0x36, 0x3a, 0xe1}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc6, 0xff, 0x24, 0x4e, 0x24, 0xb7, 0x45, 0xf6, 0x94, 0x38, - 0xf2, 0x3a, 0xd6, 0x80, 0x32, 0xb2, 0x95, 0x76, 0x2f, 0x8c}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4f, 0x3a, 0xb9, 0x29, 0x5f, 0x3b, 0x54, 0x7b, 0xbb, 0xc6, - 0x5b, 0xa6, 0x26, 0x94, 0x99, 0x93, 0xcb, 0x5c, 0x59, 0x42, - 0x2b, 0x5a, 0xa9, 0x66, 0x76, 0x85, 0xd, 0x4c}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb6, 0x1b, 0x8a, 0xf4, 0xfa, 0x44, 0x96, 0xdb, 0x42, 0xf, 0x95, 0x5, - 0xac, 0x5d, 0x69, 0xa6, 0x26, 0x99, 0xbe, 0x7e, 0xe4, 0xc1, 0x3e, 0xd1}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8f, 0x36, 0x5c, 0x3a}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11203, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 30275 [("\NAK\ENQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode49) { - uint8_t pkt[] = {0x82, 0x7, 0x76, 0x43, 0x0, 0x2, 0x15, 0x5, 0x2}; - - uint8_t buf[19] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x15, 0x5}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30275, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 16095 [("\NAK;\166\150$",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("~U\133\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\187m\GS\SOH\205\135\128<\RS\242\204^T\DC1]\f'\v\166\151\218v\STX\FS\131>\NUL",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("n\134\188wS\138\128\229\&1w*\244&",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode50) { - uint8_t pkt[] = {0x82, 0x3f, 0x3e, 0xdf, 0x0, 0x5, 0x15, 0x3b, 0xa6, 0x96, 0x24, 0x1, 0x0, 0x4, 0x7e, 0x55, 0x85, - 0x19, 0x1, 0x0, 0x1b, 0xbb, 0x6d, 0x1d, 0x1, 0xcd, 0x87, 0x80, 0x3c, 0x1e, 0xf2, 0xcc, 0x5e, 0x54, - 0x11, 0x5d, 0xc, 0x27, 0xb, 0xa6, 0x97, 0xda, 0x76, 0x2, 0x1c, 0x83, 0x3e, 0x0, 0x0, 0x0, 0xd, - 0x6e, 0x86, 0xbc, 0x77, 0x53, 0x8a, 0x80, 0xe5, 0x31, 0x77, 0x2a, 0xf4, 0x26, 0x2}; - - uint8_t buf[75] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x15, 0x3b, 0xa6, 0x96, 0x24}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7e, 0x55, 0x85, 0x19}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xbb, 0x6d, 0x1d, 0x1, 0xcd, 0x87, 0x80, 0x3c, 0x1e, 0xf2, 0xcc, 0x5e, 0x54, 0x11, - 0x5d, 0xc, 0x27, 0xb, 0xa6, 0x97, 0xda, 0x76, 0x2, 0x1c, 0x83, 0x3e, 0x0}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6e, 0x86, 0xbc, 0x77, 0x53, 0x8a, 0x80, 0xe5, 0x31, 0x77, 0x2a, 0xf4, 0x26}; - lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16095, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 27116 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode51) { - uint8_t pkt[] = {0x82, 0x5, 0x69, 0xec, 0x0, 0x0, 0x1}; - - uint8_t buf[17] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27116, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 21718 [("1\174I~\249\CAN\ETB\DC1\225r>\134\n\208\t\160\184\206T\DC3\207L:\206C\137\158",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\207\SI\180J\RSA\SYN\212",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\b\176\222\185\206Sp\170\133",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode52) { - uint8_t pkt[] = {0x82, 0x37, 0x54, 0xd6, 0x0, 0x1b, 0x31, 0xae, 0x49, 0x7e, 0xf9, 0x18, 0x17, 0x11, 0xe1, - 0x72, 0x3e, 0x86, 0xa, 0xd0, 0x9, 0xa0, 0xb8, 0xce, 0x54, 0x13, 0xcf, 0x4c, 0x3a, 0xce, - 0x43, 0x89, 0x9e, 0x2, 0x0, 0x8, 0xcf, 0xf, 0xb4, 0x4a, 0x1e, 0x41, 0x16, 0xd4, 0x1, - 0x0, 0x9, 0x8, 0xb0, 0xde, 0xb9, 0xce, 0x53, 0x70, 0xaa, 0x85, 0x0}; - - uint8_t buf[67] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x31, 0xae, 0x49, 0x7e, 0xf9, 0x18, 0x17, 0x11, 0xe1, 0x72, 0x3e, 0x86, 0xa, 0xd0, - 0x9, 0xa0, 0xb8, 0xce, 0x54, 0x13, 0xcf, 0x4c, 0x3a, 0xce, 0x43, 0x89, 0x9e}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcf, 0xf, 0xb4, 0x4a, 0x1e, 0x41, 0x16, 0xd4}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8, 0xb0, 0xde, 0xb9, 0xce, 0x53, 0x70, 0xaa, 0x85}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21718, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 32713 [("2\214\247\243(1\182\&4\130\248PZ\198\183\251=\\\128w\163\165~o\202",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("Z\195\171vhT\212\152\tmFk\v\159",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("v[g\156",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode57) { - uint8_t pkt[] = {0x82, 0x24, 0x19, 0xff, 0x0, 0x18, 0x78, 0x95, 0x92, 0xf2, 0x44, 0xcf, 0xfe, - 0x44, 0xd0, 0xda, 0xe3, 0x68, 0x8d, 0x3e, 0x68, 0x54, 0xd4, 0x98, 0x9, 0x6d, - 0x46, 0x6b, 0xb, 0x9f, 0x2, 0x0, 0x4, 0x76, 0x5b, 0x67, 0x9c, 0x0}; - - uint8_t buf[48] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x78, 0x95, 0x92, 0xf2, 0x44, 0xcf, 0xfe, 0x44, 0xd0, 0xda, 0xe3, 0x68, - 0x8d, 0x3e, 0x68, 0x54, 0xd4, 0x98, 0x9, 0x6d, 0x46, 0x6b, 0xb, 0x9f}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x76, 0x5b, 0x67, 0x9c}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6655, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2977 [("\137K3uf\128\132\202\FS\FS\224`z\196\144d\197\197\158\200y\233\ACK\184\220",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\171c\189\177zn\130)$\236\168",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\204\230!\136BX\135:J\204\170O\186\244\SO\140L2\187\"\132",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\185TD=\248\202\150\235L\245\DC4\184\200\145\EM\255\170\192\203\233\178\205\230\"w",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\138\215!n9\139\196\249\192\194\244\135Z'\136\194",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("S\170L\DC2\175\154u\143\228\222\"p8\148\148\170\224\213\161\189\147",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode58) { - uint8_t pkt[] = {0x82, 0x8b, 0x1, 0xb, 0xa1, 0x0, 0x19, 0x89, 0x4b, 0x33, 0x75, 0x66, 0x80, 0x84, 0xca, 0x1c, - 0x1c, 0xe0, 0x60, 0x7a, 0xc4, 0x90, 0x64, 0xc5, 0xc5, 0x9e, 0xc8, 0x79, 0xe9, 0x6, 0xb8, 0xdc, - 0x2, 0x0, 0xb, 0xab, 0x63, 0xbd, 0xb1, 0x7a, 0x6e, 0x82, 0x29, 0x24, 0xec, 0xa8, 0x1, 0x0, - 0x15, 0xcc, 0xe6, 0x21, 0x88, 0x42, 0x58, 0x87, 0x3a, 0x4a, 0xcc, 0xaa, 0x4f, 0xba, 0xf4, 0xe, - 0x8c, 0x4c, 0x32, 0xbb, 0x22, 0x84, 0x1, 0x0, 0x19, 0xb9, 0x54, 0x44, 0x3d, 0xf8, 0xca, 0x96, - 0xeb, 0x4c, 0xf5, 0x14, 0xb8, 0xc8, 0x91, 0x19, 0xff, 0xaa, 0xc0, 0xcb, 0xe9, 0xb2, 0xcd, 0xe6, - 0x22, 0x77, 0x1, 0x0, 0x10, 0x8a, 0xd7, 0x21, 0x6e, 0x39, 0x8b, 0xc4, 0xf9, 0xc0, 0xc2, 0xf4, - 0x87, 0x5a, 0x27, 0x88, 0xc2, 0x0, 0x0, 0x15, 0x53, 0xaa, 0x4c, 0x12, 0xaf, 0x9a, 0x75, 0x8f, - 0xe4, 0xde, 0x22, 0x70, 0x38, 0x94, 0x94, 0xaa, 0xe0, 0xd5, 0xa1, 0xbd, 0x93, 0x0}; - - uint8_t buf[152] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x89, 0x4b, 0x33, 0x75, 0x66, 0x80, 0x84, 0xca, 0x1c, 0x1c, 0xe0, 0x60, 0x7a, - 0xc4, 0x90, 0x64, 0xc5, 0xc5, 0x9e, 0xc8, 0x79, 0xe9, 0x6, 0xb8, 0xdc}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xab, 0x63, 0xbd, 0xb1, 0x7a, 0x6e, 0x82, 0x29, 0x24, 0xec, 0xa8}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xcc, 0xe6, 0x21, 0x88, 0x42, 0x58, 0x87, 0x3a, 0x4a, 0xcc, 0xaa, - 0x4f, 0xba, 0xf4, 0xe, 0x8c, 0x4c, 0x32, 0xbb, 0x22, 0x84}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb9, 0x54, 0x44, 0x3d, 0xf8, 0xca, 0x96, 0xeb, 0x4c, 0xf5, 0x14, 0xb8, 0xc8, - 0x91, 0x19, 0xff, 0xaa, 0xc0, 0xcb, 0xe9, 0xb2, 0xcd, 0xe6, 0x22, 0x77}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8a, 0xd7, 0x21, 0x6e, 0x39, 0x8b, 0xc4, 0xf9, - 0xc0, 0xc2, 0xf4, 0x87, 0x5a, 0x27, 0x88, 0xc2}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x53, 0xaa, 0x4c, 0x12, 0xaf, 0x9a, 0x75, 0x8f, 0xe4, 0xde, 0x22, - 0x70, 0x38, 0x94, 0x94, 0xaa, 0xe0, 0xd5, 0xa1, 0xbd, 0x93}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2977, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14796 [("dL\223\173OD1\b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\194\241\150\GS\SYN\239\&9\227\136c\138\225ItdFP",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode59) { - uint8_t pkt[] = {0x82, 0x21, 0x39, 0xcc, 0x0, 0x8, 0x64, 0x4c, 0xdf, 0xad, 0x4f, 0x44, - 0x31, 0x8, 0x1, 0x0, 0x11, 0xc2, 0xf1, 0x96, 0x1d, 0x16, 0xef, 0x39, - 0xe3, 0x88, 0x63, 0x8a, 0xe1, 0x49, 0x74, 0x64, 0x46, 0x50, 0x1}; - - uint8_t buf[45] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x64, 0x4c, 0xdf, 0xad, 0x4f, 0x44, 0x31, 0x8}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc2, 0xf1, 0x96, 0x1d, 0x16, 0xef, 0x39, 0xe3, 0x88, - 0x63, 0x8a, 0xe1, 0x49, 0x74, 0x64, 0x46, 0x50}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14796, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12164 [("\215\191",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\183\&1\149d|\172\187\170\n\253\&0\247d\147\189",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\"-\141\168\ESCz\249\US;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\248\206\134zY'gO\232M\144X\242\ESC\196\210\242Ka",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\155\&9\136\225\249<@6\DC2C8VS\170\237\208=1\161t\156e\198R'\149\183",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\138h\162\"\239\145\&1Q\212\182\ETB\132\178T\203\211\181\250\190\ETX\US\154\132c\168\205\218\139\176\171",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\165\160\138\189\b1fH\233\ACK_\\\a\250\137\DEL\130\251\NUL\US\166\145[\162J",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\193\ETX\186T\206c}8/>H\163\255\173\&4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("<\STX\246d\230",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("e\229|n.\CAN\FS\177\249\229Y\"Fe\193\209\"\225+\217x\190ub\253|",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\170R!*\191)5\154\202|,\DEL};bb\224\&1\233\194M\DC4`&\NUL\131",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode60) { - uint8_t pkt[] = {0x82, 0xea, 0x1, 0x2f, 0x84, 0x0, 0x2, 0xd7, 0xbf, 0x1, 0x0, 0xf, 0xb7, 0x31, 0x95, 0x64, 0x7c, - 0xac, 0xbb, 0xaa, 0xa, 0xfd, 0x30, 0xf7, 0x64, 0x93, 0xbd, 0x2, 0x0, 0x9, 0x22, 0x2d, 0x8d, 0xa8, - 0x1b, 0x7a, 0xf9, 0x1f, 0x3b, 0x0, 0x0, 0x13, 0xf8, 0xce, 0x86, 0x7a, 0x59, 0x27, 0x67, 0x4f, 0xe8, - 0x4d, 0x90, 0x58, 0xf2, 0x1b, 0xc4, 0xd2, 0xf2, 0x4b, 0x61, 0x2, 0x0, 0x1b, 0x9b, 0x39, 0x88, 0xe1, - 0xf9, 0x3c, 0x40, 0x36, 0x12, 0x43, 0x38, 0x56, 0x53, 0xaa, 0xed, 0xd0, 0x3d, 0x31, 0xa1, 0x74, 0x9c, - 0x65, 0xc6, 0x52, 0x27, 0x95, 0xb7, 0x0, 0x0, 0x1e, 0x8a, 0x68, 0xa2, 0x22, 0xef, 0x91, 0x31, 0x51, - 0xd4, 0xb6, 0x17, 0x84, 0xb2, 0x54, 0xcb, 0xd3, 0xb5, 0xfa, 0xbe, 0x3, 0x1f, 0x9a, 0x84, 0x63, 0xa8, - 0xcd, 0xda, 0x8b, 0xb0, 0xab, 0x2, 0x0, 0x19, 0xa5, 0xa0, 0x8a, 0xbd, 0x8, 0x31, 0x66, 0x48, 0xe9, - 0x6, 0x5f, 0x5c, 0x7, 0xfa, 0x89, 0x7f, 0x82, 0xfb, 0x0, 0x1f, 0xa6, 0x91, 0x5b, 0xa2, 0x4a, 0x2, - 0x0, 0xf, 0xc1, 0x3, 0xba, 0x54, 0xce, 0x63, 0x7d, 0x38, 0x2f, 0x3e, 0x48, 0xa3, 0xff, 0xad, 0x34, - 0x0, 0x0, 0x5, 0x3c, 0x2, 0xf6, 0x64, 0xe6, 0x1, 0x0, 0x1a, 0x65, 0xe5, 0x7c, 0x6e, 0x2e, 0x18, - 0x1c, 0xb1, 0xf9, 0xe5, 0x59, 0x22, 0x46, 0x65, 0xc1, 0xd1, 0x22, 0xe1, 0x2b, 0xd9, 0x78, 0xbe, 0x75, - 0x62, 0xfd, 0x7c, 0x2, 0x0, 0x1a, 0xaa, 0x52, 0x21, 0x2a, 0xbf, 0x29, 0x35, 0x9a, 0xca, 0x7c, 0x2c, - 0x7f, 0x7d, 0x3b, 0x62, 0x62, 0xe0, 0x31, 0xe9, 0xc2, 0x4d, 0x14, 0x60, 0x26, 0x0, 0x83, 0x2}; - - uint8_t buf[247] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xd7, 0xbf}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb7, 0x31, 0x95, 0x64, 0x7c, 0xac, 0xbb, 0xaa, - 0xa, 0xfd, 0x30, 0xf7, 0x64, 0x93, 0xbd}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x22, 0x2d, 0x8d, 0xa8, 0x1b, 0x7a, 0xf9, 0x1f, 0x3b}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf8, 0xce, 0x86, 0x7a, 0x59, 0x27, 0x67, 0x4f, 0xe8, 0x4d, - 0x90, 0x58, 0xf2, 0x1b, 0xc4, 0xd2, 0xf2, 0x4b, 0x61}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9b, 0x39, 0x88, 0xe1, 0xf9, 0x3c, 0x40, 0x36, 0x12, 0x43, 0x38, 0x56, 0x53, 0xaa, - 0xed, 0xd0, 0x3d, 0x31, 0xa1, 0x74, 0x9c, 0x65, 0xc6, 0x52, 0x27, 0x95, 0xb7}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8a, 0x68, 0xa2, 0x22, 0xef, 0x91, 0x31, 0x51, 0xd4, 0xb6, - 0x17, 0x84, 0xb2, 0x54, 0xcb, 0xd3, 0xb5, 0xfa, 0xbe, 0x3, - 0x1f, 0x9a, 0x84, 0x63, 0xa8, 0xcd, 0xda, 0x8b, 0xb0, 0xab}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa5, 0xa0, 0x8a, 0xbd, 0x8, 0x31, 0x66, 0x48, 0xe9, 0x6, 0x5f, 0x5c, 0x7, - 0xfa, 0x89, 0x7f, 0x82, 0xfb, 0x0, 0x1f, 0xa6, 0x91, 0x5b, 0xa2, 0x4a}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xc1, 0x3, 0xba, 0x54, 0xce, 0x63, 0x7d, 0x38, - 0x2f, 0x3e, 0x48, 0xa3, 0xff, 0xad, 0x34}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x3c, 0x2, 0xf6, 0x64, 0xe6}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x65, 0xe5, 0x7c, 0x6e, 0x2e, 0x18, 0x1c, 0xb1, 0xf9, 0xe5, 0x59, 0x22, 0x46, - 0x65, 0xc1, 0xd1, 0x22, 0xe1, 0x2b, 0xd9, 0x78, 0xbe, 0x75, 0x62, 0xfd, 0x7c}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xaa, 0x52, 0x21, 0x2a, 0xbf, 0x29, 0x35, 0x9a, 0xca, 0x7c, 0x2c, 0x7f, 0x7d, - 0x3b, 0x62, 0x62, 0xe0, 0x31, 0xe9, 0xc2, 0x4d, 0x14, 0x60, 0x26, 0x0, 0x83}; - lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12164, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12633 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\142\241\204\138,\174\131\149\199\160o\205\146",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("r\146\242\132\DC1\212\252\ETX\DC3\192\195\&3\169\231!",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\225\238p\223\135rJ\134'\ETB\DEL\137\131\NUL\223h\DC4\171\ESC\248",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("l1\185\139a\217\DEL7?\r\EM?",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("?\226!\129{\254Q",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\FSG=\NUL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\142gv\133\156\SYN\162\216C",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\152\212\158(t\138F\128{&?'-\194\239p\DC2H\132\131\SYNd\169\128\215\NAKa\217",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\179\212\228\145\130\161\198\&5\236H\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS0}),("\196\&6?\162\212TA\205\USkt\b\208",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode62) { - uint8_t pkt[] = {0x82, 0x70, 0x54, 0x8a, 0x0, 0xd, 0xd9, 0xc1, 0x92, 0x85, 0xe9, 0xed, 0x38, 0x34, 0x2, 0x7c, 0x39, - 0xf, 0x5e, 0x1, 0x0, 0xb, 0x21, 0xbf, 0xfa, 0x54, 0x3e, 0xe2, 0x21, 0x81, 0x7b, 0xfe, 0x51, 0x1, - 0x0, 0x4, 0x1c, 0x47, 0x3d, 0x0, 0x1, 0x0, 0x9, 0x8e, 0x67, 0x76, 0x85, 0x9c, 0x16, 0xa2, 0xd8, - 0x43, 0x1, 0x0, 0x1c, 0x98, 0xd4, 0x9e, 0x28, 0x74, 0x8a, 0x46, 0x80, 0x7b, 0x26, 0x3f, 0x27, 0x2d, - 0xc2, 0xef, 0x70, 0x12, 0x48, 0x84, 0x83, 0x16, 0x64, 0xa9, 0x80, 0xd7, 0x15, 0x61, 0xd9, 0x2, 0x0, - 0xb, 0xb3, 0xd4, 0xe4, 0x91, 0x82, 0xa1, 0xc6, 0x35, 0xec, 0x48, 0x98, 0x0, 0x0, 0xd, 0xc4, 0x36, - 0x3f, 0xa2, 0xd4, 0x54, 0x41, 0xcd, 0x1f, 0x6b, 0x74, 0x8, 0xd0, 0x2}; - - uint8_t buf[124] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xd9, 0xc1, 0x92, 0x85, 0xe9, 0xed, 0x38, 0x34, 0x2, 0x7c, 0x39, 0xf, 0x5e}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x21, 0xbf, 0xfa, 0x54, 0x3e, 0xe2, 0x21, 0x81, 0x7b, 0xfe, 0x51}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1c, 0x47, 0x3d, 0x0}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8e, 0x67, 0x76, 0x85, 0x9c, 0x16, 0xa2, 0xd8, 0x43}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x98, 0xd4, 0x9e, 0x28, 0x74, 0x8a, 0x46, 0x80, 0x7b, 0x26, - 0x3f, 0x27, 0x2d, 0xc2, 0xef, 0x70, 0x12, 0x48, 0x84, 0x83, - 0x16, 0x64, 0xa9, 0x80, 0xd7, 0x15, 0x61, 0xd9}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb3, 0xd4, 0xe4, 0x91, 0x82, 0xa1, 0xc6, 0x35, 0xec, 0x48, 0x98}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc4, 0x36, 0x3f, 0xa2, 0xd4, 0x54, 0x41, 0xcd, 0x1f, 0x6b, 0x74, 0x8, 0xd0}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21642, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 17671 [("u\219]\165\215\137\250\193O\129\136\181\180\tG@\188t",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\250\141\FS\155\a\192Q}\186\203\ACK\DEL\246\233\SUB\206\&2/\240\137\189'F$\189dq\159\142h",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\SYN\189~\178VN\200\201\v\165\218\230\166\ETB",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("L\136+\152\143",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\139\202\184\152g\f\231`",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode63) { - uint8_t pkt[] = {0x82, 0x63, 0x45, 0x7, 0x0, 0x12, 0x75, 0xdb, 0x5d, 0xa5, 0xd7, 0x89, 0xfa, 0xc1, 0x4f, 0x81, 0x88, - 0xb5, 0xb4, 0x9, 0x47, 0x40, 0xbc, 0x74, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1e, 0xfa, 0x8d, 0x1c, 0x9b, - 0x7, 0xc0, 0x51, 0x7d, 0xba, 0xcb, 0x6, 0x7f, 0xf6, 0xe9, 0x1a, 0xce, 0x32, 0x2f, 0xf0, 0x89, 0xbd, - 0x27, 0x46, 0x24, 0xbd, 0x64, 0x71, 0x9f, 0x8e, 0x68, 0x0, 0x0, 0xe, 0x16, 0xbd, 0x7e, 0xb2, 0x56, - 0x4e, 0xc8, 0xc9, 0xb, 0xa5, 0xda, 0xe6, 0xa6, 0x17, 0x1, 0x0, 0x5, 0x4c, 0x88, 0x2b, 0x98, 0x8f, - 0x2, 0x0, 0x8, 0x8b, 0xca, 0xb8, 0x98, 0x67, 0xc, 0xe7, 0x60, 0x1, 0x0, 0x1, 0x5c, 0x2}; - - uint8_t buf[111] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x75, 0xdb, 0x5d, 0xa5, 0xd7, 0x89, 0xfa, 0xc1, 0x4f, - 0x81, 0x88, 0xb5, 0xb4, 0x9, 0x47, 0x40, 0xbc, 0x74}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfa, 0x8d, 0x1c, 0x9b, 0x7, 0xc0, 0x51, 0x7d, 0xba, 0xcb, - 0x6, 0x7f, 0xf6, 0xe9, 0x1a, 0xce, 0x32, 0x2f, 0xf0, 0x89, - 0xbd, 0x27, 0x46, 0x24, 0xbd, 0x64, 0x71, 0x9f, 0x8e, 0x68}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x16, 0xbd, 0x7e, 0xb2, 0x56, 0x4e, 0xc8, 0xc9, 0xb, 0xa5, 0xda, 0xe6, 0xa6, 0x17}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4c, 0x88, 0x2b, 0x98, 0x8f}; - lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8b, 0xca, 0xb8, 0x98, 0x67, 0xc, 0xe7, 0x60}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5c}; - lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17671, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 18903 [("\245\147\176",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("sQ\169h\ACK\237\155\fg\232\206\138",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode64) { - uint8_t pkt[] = {0x82, 0x17, 0x49, 0xd7, 0x0, 0x3, 0xf5, 0x93, 0xb0, 0x0, 0x0, 0xc, 0x73, - 0x51, 0xa9, 0x68, 0x6, 0xed, 0x9b, 0xc, 0x67, 0xe8, 0xce, 0x8a, 0x2}; - - uint8_t buf[35] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xf5, 0x93, 0xb0}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x73, 0x51, 0xa9, 0x68, 0x6, 0xed, 0x9b, 0xc, 0x67, 0xe8, 0xce, 0x8a}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18903, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 187 [("5>j",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("\134/\US\STX\249\130\n\159\"\235\ETB\FS\163\USR\194\156d>\213\144=\161/*'\231\"",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\DEL\250Oc\141\225\&8\234B\179",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\141\218\241\136\246\183d\251\&3\182\235#\208\bPH\170Y\194",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\215N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS -// = QoS1}),("}'\141;\170\&26H\213Yh\130\RS\178\DLEuL\155\134\229\210\138\DLEi\GS~S",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\220\&6\DC2a\245\161\nd\210\tR\238\159Z1\236\207\215\181\204\ACKb}\252\217",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("f\245\230\190d\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS0}),("\SYN\233\177\236i\130\128\129L\208\174U\146\138F\247\182\212.\225y\DC2R\230s`9\178X_",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("C\183z\254h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\232t\GS\132\129\184f\CAN\CAN>\141:L\216\DC3{\191Y\213\232\SYN|\212\146k\195",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\SO]\228\162\189*ST\168t\ACK\143\216r\249\178\199\&0(\200[}\173\235\206\159F",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\STX\148\192L*\157`\179\224=e\224\228\&6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS0}),("\232J\211\179\136\130\218\157A\177\157j!\157\237\a\248\213\SUB\155",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode68) { - uint8_t pkt[] = {0x82, 0xb2, 0x1, 0x2a, 0xa7, 0x0, 0x10, 0x74, 0x1a, 0x39, 0xbc, 0x36, 0xf6, 0x91, 0x8b, 0xb3, 0x5a, - 0xdb, 0xc9, 0xc3, 0x5f, 0x45, 0xfb, 0x1, 0x0, 0xe, 0xc1, 0x69, 0x61, 0xff, 0xe8, 0x35, 0x8a, 0xc7, - 0x3e, 0xf5, 0xe6, 0xbe, 0x64, 0xa, 0x0, 0x0, 0x1e, 0x16, 0xe9, 0xb1, 0xec, 0x69, 0x82, 0x80, 0x81, - 0x4c, 0xd0, 0xae, 0x55, 0x92, 0x8a, 0x46, 0xf7, 0xb6, 0xd4, 0x2e, 0xe1, 0x79, 0x12, 0x52, 0xe6, 0x73, - 0x60, 0x39, 0xb2, 0x58, 0x5f, 0x0, 0x0, 0x5, 0x43, 0xb7, 0x7a, 0xfe, 0x68, 0x1, 0x0, 0x1a, 0xe8, - 0x74, 0x1d, 0x84, 0x81, 0xb8, 0x66, 0x18, 0x18, 0x3e, 0x8d, 0x3a, 0x4c, 0xd8, 0x13, 0x7b, 0xbf, 0x59, - 0xd5, 0xe8, 0x16, 0x7c, 0xd4, 0x92, 0x6b, 0xc3, 0x1, 0x0, 0x1b, 0xe, 0x5d, 0xe4, 0xa2, 0xbd, 0x2a, - 0x53, 0x54, 0xa8, 0x74, 0x6, 0x8f, 0xd8, 0x72, 0xf9, 0xb2, 0xc7, 0x30, 0x28, 0xc8, 0x5b, 0x7d, 0xad, - 0xeb, 0xce, 0x9f, 0x46, 0x1, 0x0, 0xe, 0x2, 0x94, 0xc0, 0x4c, 0x2a, 0x9d, 0x60, 0xb3, 0xe0, 0x3d, - 0x65, 0xe0, 0xe4, 0x36, 0x0, 0x0, 0x14, 0xe8, 0x4a, 0xd3, 0xb3, 0x88, 0x82, 0xda, 0x9d, 0x41, 0xb1, - 0x9d, 0x6a, 0x21, 0x9d, 0xed, 0x7, 0xf8, 0xd5, 0x1a, 0x9b, 0x0}; - - uint8_t buf[191] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x74, 0x1a, 0x39, 0xbc, 0x36, 0xf6, 0x91, 0x8b, - 0xb3, 0x5a, 0xdb, 0xc9, 0xc3, 0x5f, 0x45, 0xfb}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc1, 0x69, 0x61, 0xff, 0xe8, 0x35, 0x8a, 0xc7, 0x3e, 0xf5, 0xe6, 0xbe, 0x64, 0xa}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x16, 0xe9, 0xb1, 0xec, 0x69, 0x82, 0x80, 0x81, 0x4c, 0xd0, - 0xae, 0x55, 0x92, 0x8a, 0x46, 0xf7, 0xb6, 0xd4, 0x2e, 0xe1, - 0x79, 0x12, 0x52, 0xe6, 0x73, 0x60, 0x39, 0xb2, 0x58, 0x5f}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x43, 0xb7, 0x7a, 0xfe, 0x68}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe8, 0x74, 0x1d, 0x84, 0x81, 0xb8, 0x66, 0x18, 0x18, 0x3e, 0x8d, 0x3a, 0x4c, - 0xd8, 0x13, 0x7b, 0xbf, 0x59, 0xd5, 0xe8, 0x16, 0x7c, 0xd4, 0x92, 0x6b, 0xc3}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe, 0x5d, 0xe4, 0xa2, 0xbd, 0x2a, 0x53, 0x54, 0xa8, 0x74, 0x6, 0x8f, 0xd8, 0x72, - 0xf9, 0xb2, 0xc7, 0x30, 0x28, 0xc8, 0x5b, 0x7d, 0xad, 0xeb, 0xce, 0x9f, 0x46}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x2, 0x94, 0xc0, 0x4c, 0x2a, 0x9d, 0x60, 0xb3, 0xe0, 0x3d, 0x65, 0xe0, 0xe4, 0x36}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe8, 0x4a, 0xd3, 0xb3, 0x88, 0x82, 0xda, 0x9d, 0x41, 0xb1, - 0x9d, 0x6a, 0x21, 0x9d, 0xed, 0x7, 0xf8, 0xd5, 0x1a, 0x9b}; - lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10919, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 692 [("\151\140>\206\207\NUL\208\139\194L\251\227\220\170\163\153*~?,w\245u",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\227\154\215d\192;_\237G\128o\235Q\218rV\202\SOHr\DEL\144\155",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("S'\141\229\&7]\"\179\212\174\r\185\176",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\137\202Y\ENQ\254#\197\FS(R\208\234n0x\ACK\141\210i\227$0\182H%",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("0\237\190\218C6",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\247/{\nv\233V\144\198e\158",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\247\194\142\228\247\186\227\&8",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("J",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\200\183{SW\236\248y\197\224\172K\STX\184W\v~\211",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\247\146\ETB\254\241\SYN\199\197\175\237\\\220\213\154\178\214\136k\147S\SI\228\EM\219\129.\240",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\249h\135(AF",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode69) { - uint8_t pkt[] = {0x82, 0xc3, 0x1, 0x2, 0xb4, 0x0, 0x17, 0x97, 0x8c, 0x3e, 0xce, 0xcf, 0x0, 0xd0, 0x8b, 0xc2, 0x4c, - 0xfb, 0xe3, 0xdc, 0xaa, 0xa3, 0x99, 0x2a, 0x7e, 0x3f, 0x2c, 0x77, 0xf5, 0x75, 0x2, 0x0, 0x16, 0xe3, - 0x9a, 0xd7, 0x64, 0xc0, 0x3b, 0x5f, 0xed, 0x47, 0x80, 0x6f, 0xeb, 0x51, 0xda, 0x72, 0x56, 0xca, 0x1, - 0x72, 0x7f, 0x90, 0x9b, 0x0, 0x0, 0xd, 0x53, 0x27, 0x8d, 0xe5, 0x37, 0x5d, 0x22, 0xb3, 0xd4, 0xae, - 0xd, 0xb9, 0xb0, 0x1, 0x0, 0x19, 0x89, 0xca, 0x59, 0x5, 0xfe, 0x23, 0xc5, 0x1c, 0x28, 0x52, 0xd0, - 0xea, 0x6e, 0x30, 0x78, 0x6, 0x8d, 0xd2, 0x69, 0xe3, 0x24, 0x30, 0xb6, 0x48, 0x25, 0x1, 0x0, 0x6, - 0x30, 0xed, 0xbe, 0xda, 0x43, 0x36, 0x1, 0x0, 0xb, 0xf7, 0x2f, 0x7b, 0xa, 0x76, 0xe9, 0x56, 0x90, - 0xc6, 0x65, 0x9e, 0x0, 0x0, 0x8, 0xf7, 0xc2, 0x8e, 0xe4, 0xf7, 0xba, 0xe3, 0x38, 0x0, 0x0, 0x1, - 0x4a, 0x2, 0x0, 0x12, 0xc8, 0xb7, 0x7b, 0x53, 0x57, 0xec, 0xf8, 0x79, 0xc5, 0xe0, 0xac, 0x4b, 0x2, - 0xb8, 0x57, 0xb, 0x7e, 0xd3, 0x0, 0x0, 0x1b, 0xf7, 0x92, 0x17, 0xfe, 0xf1, 0x16, 0xc7, 0xc5, 0xaf, - 0xed, 0x5c, 0xdc, 0xd5, 0x9a, 0xb2, 0xd6, 0x88, 0x6b, 0x93, 0x53, 0xf, 0xe4, 0x19, 0xdb, 0x81, 0x2e, - 0xf0, 0x2, 0x0, 0x6, 0xf9, 0x68, 0x87, 0x28, 0x41, 0x46, 0x1}; - - uint8_t buf[208] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x97, 0x8c, 0x3e, 0xce, 0xcf, 0x0, 0xd0, 0x8b, 0xc2, 0x4c, 0xfb, 0xe3, - 0xdc, 0xaa, 0xa3, 0x99, 0x2a, 0x7e, 0x3f, 0x2c, 0x77, 0xf5, 0x75}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe3, 0x9a, 0xd7, 0x64, 0xc0, 0x3b, 0x5f, 0xed, 0x47, 0x80, 0x6f, - 0xeb, 0x51, 0xda, 0x72, 0x56, 0xca, 0x1, 0x72, 0x7f, 0x90, 0x9b}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x53, 0x27, 0x8d, 0xe5, 0x37, 0x5d, 0x22, 0xb3, 0xd4, 0xae, 0xd, 0xb9, 0xb0}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x89, 0xca, 0x59, 0x5, 0xfe, 0x23, 0xc5, 0x1c, 0x28, 0x52, 0xd0, 0xea, 0x6e, - 0x30, 0x78, 0x6, 0x8d, 0xd2, 0x69, 0xe3, 0x24, 0x30, 0xb6, 0x48, 0x25}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x30, 0xed, 0xbe, 0xda, 0x43, 0x36}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf7, 0x2f, 0x7b, 0xa, 0x76, 0xe9, 0x56, 0x90, 0xc6, 0x65, 0x9e}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf7, 0xc2, 0x8e, 0xe4, 0xf7, 0xba, 0xe3, 0x38}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x4a}; - lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc8, 0xb7, 0x7b, 0x53, 0x57, 0xec, 0xf8, 0x79, 0xc5, - 0xe0, 0xac, 0x4b, 0x2, 0xb8, 0x57, 0xb, 0x7e, 0xd3}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xf7, 0x92, 0x17, 0xfe, 0xf1, 0x16, 0xc7, 0xc5, 0xaf, 0xed, 0x5c, 0xdc, 0xd5, 0x9a, - 0xb2, 0xd6, 0x88, 0x6b, 0x93, 0x53, 0xf, 0xe4, 0x19, 0xdb, 0x81, 0x2e, 0xf0}; - lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xf9, 0x68, 0x87, 0x28, 0x41, 0x46}; - lwmqtt_string_t topic_filter_s10 = {6, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 692, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 1184 [("\170g\\2\a\FS\243\&2\134#\245<\232\v!E",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\163/?",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS -// = QoS1}),("_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\\\158\228\223\ETB:\150)dY|!\236\205\164s\139\v\167>\221\EM",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\232\208\185f\157\247N\190\191\ETX\212\t\213\229\SOH -// \206\v\178@\162^",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("m\137\v\f7\141&\216@\158!\GS\192\191\189",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\EOTg\241\167",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode71) { - uint8_t pkt[] = {0x82, 0x75, 0x6e, 0xae, 0x0, 0x1b, 0xc4, 0xd0, 0x78, 0x91, 0x7, 0xc5, 0xec, 0xa6, 0xed, 0xc6, 0x5c, - 0x2d, 0xde, 0x61, 0xd, 0x8c, 0x9e, 0x4e, 0xc7, 0x37, 0xb2, 0x1e, 0x60, 0x3d, 0x3e, 0x21, 0x45, 0x0, - 0x0, 0x3, 0xa3, 0x2f, 0x3f, 0x1, 0x0, 0x1, 0x5f, 0x2, 0x0, 0x16, 0x5c, 0x9e, 0xe4, 0xdf, 0x17, - 0x3a, 0x96, 0x29, 0x64, 0x59, 0x7c, 0x21, 0xec, 0xcd, 0xa4, 0x73, 0x8b, 0xb, 0xa7, 0x3e, 0xdd, 0x19, - 0x2, 0x0, 0x16, 0xe8, 0xd0, 0xb9, 0x66, 0x9d, 0xf7, 0x4e, 0xbe, 0xbf, 0x3, 0xd4, 0x9, 0xd5, 0xe5, - 0x1, 0x20, 0xce, 0xb, 0xb2, 0x40, 0xa2, 0x5e, 0x1, 0x0, 0xf, 0x6d, 0x89, 0xb, 0xc, 0x37, 0x8d, - 0x26, 0xd8, 0x40, 0x9e, 0x21, 0x1d, 0xc0, 0xbf, 0xbd, 0x1, 0x0, 0x4, 0x4, 0x67, 0xf1, 0xa7, 0x1}; - - uint8_t buf[129] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xc4, 0xd0, 0x78, 0x91, 0x7, 0xc5, 0xec, 0xa6, 0xed, 0xc6, 0x5c, 0x2d, 0xde, 0x61, - 0xd, 0x8c, 0x9e, 0x4e, 0xc7, 0x37, 0xb2, 0x1e, 0x60, 0x3d, 0x3e, 0x21, 0x45}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa3, 0x2f, 0x3f}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5f}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x5c, 0x9e, 0xe4, 0xdf, 0x17, 0x3a, 0x96, 0x29, 0x64, 0x59, 0x7c, - 0x21, 0xec, 0xcd, 0xa4, 0x73, 0x8b, 0xb, 0xa7, 0x3e, 0xdd, 0x19}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe8, 0xd0, 0xb9, 0x66, 0x9d, 0xf7, 0x4e, 0xbe, 0xbf, 0x3, 0xd4, - 0x9, 0xd5, 0xe5, 0x1, 0x20, 0xce, 0xb, 0xb2, 0x40, 0xa2, 0x5e}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6d, 0x89, 0xb, 0xc, 0x37, 0x8d, 0x26, 0xd8, - 0x40, 0x9e, 0x21, 0x1d, 0xc0, 0xbf, 0xbd}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4, 0x67, 0xf1, 0xa7}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28334, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 26598 [("=\225\250g\177\216\249\&8\252='RyD\192\199@\SOh\247\158\236\151\&4d\199\247",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("#\151\183Z\151O\182\172\150*i\\\161\230\221\176\251\180\217H;]\215\250\196L\201\228\DC3\244",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\243\152\219Kk\182Q,eE \RS*/\SYN\134V\DC3FyOS[",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\139\SOH\t\179g\DC3&n'\158C\223Y\254",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\205$\145XN\129y\188+2W2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode72) { - uint8_t pkt[] = {0x82, 0x7e, 0x67, 0xe6, 0x0, 0x1b, 0x3d, 0xe1, 0xfa, 0x67, 0xb1, 0xd8, 0xf9, 0x38, 0xfc, 0x3d, - 0x27, 0x52, 0x79, 0x44, 0xc0, 0xc7, 0x40, 0xe, 0x68, 0xf7, 0x9e, 0xec, 0x97, 0x34, 0x64, 0xc7, - 0xf7, 0x2, 0x0, 0x0, 0x1, 0x0, 0x1e, 0x23, 0x97, 0xb7, 0x5a, 0x97, 0x4f, 0xb6, 0xac, 0x96, - 0x2a, 0x69, 0x5c, 0xa1, 0xe6, 0xdd, 0xb0, 0xfb, 0xb4, 0xd9, 0x48, 0x3b, 0x5d, 0xd7, 0xfa, 0xc4, - 0x4c, 0xc9, 0xe4, 0x13, 0xf4, 0x0, 0x0, 0x17, 0xf3, 0x98, 0xdb, 0x4b, 0x6b, 0xb6, 0x51, 0x2c, - 0x65, 0x45, 0x20, 0x1e, 0x2a, 0x2f, 0x16, 0x86, 0x56, 0x13, 0x46, 0x79, 0x4f, 0x53, 0x5b, 0x1, - 0x0, 0xe, 0x8b, 0x1, 0x9, 0xb3, 0x67, 0x13, 0x26, 0x6e, 0x27, 0x9e, 0x43, 0xdf, 0x59, 0xfe, - 0x0, 0x0, 0xc, 0xcd, 0x24, 0x91, 0x58, 0x4e, 0x81, 0x79, 0xbc, 0x2b, 0x32, 0x57, 0x32, 0x1}; - - uint8_t buf[138] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x3d, 0xe1, 0xfa, 0x67, 0xb1, 0xd8, 0xf9, 0x38, 0xfc, 0x3d, 0x27, 0x52, 0x79, 0x44, - 0xc0, 0xc7, 0x40, 0xe, 0x68, 0xf7, 0x9e, 0xec, 0x97, 0x34, 0x64, 0xc7, 0xf7}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x23, 0x97, 0xb7, 0x5a, 0x97, 0x4f, 0xb6, 0xac, 0x96, 0x2a, - 0x69, 0x5c, 0xa1, 0xe6, 0xdd, 0xb0, 0xfb, 0xb4, 0xd9, 0x48, - 0x3b, 0x5d, 0xd7, 0xfa, 0xc4, 0x4c, 0xc9, 0xe4, 0x13, 0xf4}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf3, 0x98, 0xdb, 0x4b, 0x6b, 0xb6, 0x51, 0x2c, 0x65, 0x45, 0x20, 0x1e, - 0x2a, 0x2f, 0x16, 0x86, 0x56, 0x13, 0x46, 0x79, 0x4f, 0x53, 0x5b}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8b, 0x1, 0x9, 0xb3, 0x67, 0x13, 0x26, 0x6e, 0x27, 0x9e, 0x43, 0xdf, 0x59, 0xfe}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xcd, 0x24, 0x91, 0x58, 0x4e, 0x81, 0x79, 0xbc, 0x2b, 0x32, 0x57, 0x32}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26598, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 8075 [("\153\219wC\224\141\212\158d\179\204\165\177\194fH\170\138^",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\163{\DC4\190\210\150W\162\228}\131*;\DC1\208;\155n\214I\147\176\137\176",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\v\244\209y\179\242\230\161\147:u\140\228\&5k\177\179\250",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\184\211O\228\212N\251O\183\208V\241\211\t\209\244\RS\186",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode74) { - uint8_t pkt[] = {0x82, 0xb1, 0x1, 0x46, 0x1b, 0x0, 0x1, 0x45, 0x0, 0x0, 0x7, 0x8, 0xc2, 0xb3, 0x87, 0x7f, 0x99, - 0x5c, 0x1, 0x0, 0x1c, 0x43, 0x6b, 0xef, 0x35, 0xd, 0x27, 0xdf, 0x64, 0xcd, 0x43, 0xee, 0xbc, 0x95, - 0xb3, 0xc6, 0x83, 0x8b, 0x87, 0xc8, 0x6a, 0x98, 0x87, 0xa1, 0x61, 0x5a, 0x35, 0x72, 0xb2, 0x0, 0x0, - 0x6, 0x50, 0x9d, 0xb5, 0x85, 0xb4, 0x7b, 0x1, 0x0, 0x14, 0x68, 0x73, 0x5f, 0x4b, 0xe7, 0x37, 0x5, - 0x8e, 0x9d, 0xc2, 0xc4, 0xfc, 0xf0, 0x88, 0x29, 0x9d, 0x9f, 0xa7, 0xff, 0x47, 0x0, 0x0, 0xb, 0x74, - 0x80, 0x68, 0x86, 0x54, 0xa0, 0xb2, 0x72, 0x61, 0x92, 0xc9, 0x2, 0x0, 0x4, 0x32, 0x88, 0xeb, 0xe1, - 0x0, 0x0, 0x0, 0x1, 0x0, 0x19, 0x74, 0xc8, 0x1, 0x90, 0xf3, 0xb, 0x9f, 0x46, 0x26, 0xfd, 0xba, - 0x2a, 0xa3, 0x88, 0x64, 0xd, 0x41, 0x11, 0x6, 0xd1, 0x22, 0x11, 0xc1, 0x56, 0x11, 0x2, 0x0, 0xe, - 0xe8, 0xa9, 0xcd, 0x93, 0x16, 0x81, 0x91, 0xc4, 0x23, 0x21, 0x6, 0xab, 0x49, 0xe1, 0x1, 0x0, 0x1a, - 0xd7, 0xdd, 0x19, 0xfe, 0x2f, 0xa4, 0x64, 0x3e, 0xb8, 0xd3, 0x4f, 0xe4, 0xd4, 0x4e, 0xfb, 0x4f, 0xb7, - 0xd0, 0x56, 0xf1, 0xd3, 0x9, 0xd1, 0xf4, 0x1e, 0xba, 0x1}; - - uint8_t buf[190] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x45}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8, 0xc2, 0xb3, 0x87, 0x7f, 0x99, 0x5c}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x43, 0x6b, 0xef, 0x35, 0xd, 0x27, 0xdf, 0x64, 0xcd, 0x43, - 0xee, 0xbc, 0x95, 0xb3, 0xc6, 0x83, 0x8b, 0x87, 0xc8, 0x6a, - 0x98, 0x87, 0xa1, 0x61, 0x5a, 0x35, 0x72, 0xb2}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x50, 0x9d, 0xb5, 0x85, 0xb4, 0x7b}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x68, 0x73, 0x5f, 0x4b, 0xe7, 0x37, 0x5, 0x8e, 0x9d, 0xc2, - 0xc4, 0xfc, 0xf0, 0x88, 0x29, 0x9d, 0x9f, 0xa7, 0xff, 0x47}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x74, 0x80, 0x68, 0x86, 0x54, 0xa0, 0xb2, 0x72, 0x61, 0x92, 0xc9}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x32, 0x88, 0xeb, 0xe1}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0}; - lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x74, 0xc8, 0x1, 0x90, 0xf3, 0xb, 0x9f, 0x46, 0x26, 0xfd, 0xba, 0x2a, 0xa3, - 0x88, 0x64, 0xd, 0x41, 0x11, 0x6, 0xd1, 0x22, 0x11, 0xc1, 0x56, 0x11}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe8, 0xa9, 0xcd, 0x93, 0x16, 0x81, 0x91, 0xc4, 0x23, 0x21, 0x6, 0xab, 0x49, 0xe1}; - lwmqtt_string_t topic_filter_s9 = {14, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xd7, 0xdd, 0x19, 0xfe, 0x2f, 0xa4, 0x64, 0x3e, 0xb8, 0xd3, 0x4f, 0xe4, 0xd4, - 0x4e, 0xfb, 0x4f, 0xb7, 0xd0, 0x56, 0xf1, 0xd3, 0x9, 0xd1, 0xf4, 0x1e, 0xba}; - lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17947, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 167 [("\231\169\150\t\250\191\150<\142\244\175\168\192\184\179",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\212\vx}\a\239:\\|\164~\165\239\172\b\182j\"e\244",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\199\200~",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\US97\178\208\r#N\n\150nm+6\213\NUL\171\252\t",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\137\ETX\197\217\NUL\223\232\207\253\202\144V#\158k\156DSE2\145\ENQ\158\234\133\150",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("#\149\222<\ETXQ\182,\188$Y~(\178|T\176_\145\151'",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\175\ENQ\GS\245\242)\153\DC2\129\190\DC4\n\235\129\160 \190\233",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("DJ\236\247\\fp\240\131\213\DLEP\133\CAN\133",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\188n\248-\193\248\138\147\SI\181\to\137\t\148\230\233=",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode75) { - uint8_t pkt[] = {0x82, 0xb8, 0x1, 0x0, 0xa7, 0x0, 0xf, 0xe7, 0xa9, 0x96, 0x9, 0xfa, 0xbf, 0x96, 0x3c, 0x8e, 0xf4, - 0xaf, 0xa8, 0xc0, 0xb8, 0xb3, 0x2, 0x0, 0x14, 0xd4, 0xb, 0x78, 0x7d, 0x7, 0xef, 0x3a, 0x5c, 0x7c, - 0xa4, 0x7e, 0xa5, 0xef, 0xac, 0x8, 0xb6, 0x6a, 0x22, 0x65, 0xf4, 0x2, 0x0, 0x3, 0xc7, 0xc8, 0x7e, - 0x0, 0x0, 0x13, 0x1f, 0x39, 0x37, 0xb2, 0xd0, 0xd, 0x23, 0x4e, 0xa, 0x96, 0x6e, 0x6d, 0x2b, 0x36, - 0xd5, 0x0, 0xab, 0xfc, 0x9, 0x2, 0x0, 0x1a, 0x89, 0x3, 0xc5, 0xd9, 0x0, 0xdf, 0xe8, 0xcf, 0xfd, - 0xca, 0x90, 0x56, 0x23, 0x9e, 0x6b, 0x9c, 0x44, 0x53, 0x45, 0x32, 0x91, 0x5, 0x9e, 0xea, 0x85, 0x96, - 0x1, 0x0, 0x15, 0x23, 0x95, 0xde, 0x3c, 0x3, 0x51, 0xb6, 0x2c, 0xbc, 0x24, 0x59, 0x7e, 0x28, 0xb2, - 0x7c, 0x54, 0xb0, 0x5f, 0x91, 0x97, 0x27, 0x0, 0x0, 0x12, 0xaf, 0x5, 0x1d, 0xf5, 0xf2, 0x29, 0x99, - 0x12, 0x81, 0xbe, 0x14, 0xa, 0xeb, 0x81, 0xa0, 0x20, 0xbe, 0xe9, 0x2, 0x0, 0xf, 0x44, 0x4a, 0xec, - 0xf7, 0x5c, 0x66, 0x70, 0xf0, 0x83, 0xd5, 0x10, 0x50, 0x85, 0x18, 0x85, 0x1, 0x0, 0x12, 0xbc, 0x6e, - 0xf8, 0x2d, 0xc1, 0xf8, 0x8a, 0x93, 0xf, 0xb5, 0x9, 0x6f, 0x89, 0x9, 0x94, 0xe6, 0xe9, 0x3d, 0x1}; - - uint8_t buf[197] = {0}; - - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xe7, 0xa9, 0x96, 0x9, 0xfa, 0xbf, 0x96, 0x3c, - 0x8e, 0xf4, 0xaf, 0xa8, 0xc0, 0xb8, 0xb3}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd4, 0xb, 0x78, 0x7d, 0x7, 0xef, 0x3a, 0x5c, 0x7c, 0xa4, - 0x7e, 0xa5, 0xef, 0xac, 0x8, 0xb6, 0x6a, 0x22, 0x65, 0xf4}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc7, 0xc8, 0x7e}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1f, 0x39, 0x37, 0xb2, 0xd0, 0xd, 0x23, 0x4e, 0xa, 0x96, - 0x6e, 0x6d, 0x2b, 0x36, 0xd5, 0x0, 0xab, 0xfc, 0x9}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x89, 0x3, 0xc5, 0xd9, 0x0, 0xdf, 0xe8, 0xcf, 0xfd, 0xca, 0x90, 0x56, 0x23, - 0x9e, 0x6b, 0x9c, 0x44, 0x53, 0x45, 0x32, 0x91, 0x5, 0x9e, 0xea, 0x85, 0x96}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x23, 0x95, 0xde, 0x3c, 0x3, 0x51, 0xb6, 0x2c, 0xbc, 0x24, 0x59, - 0x7e, 0x28, 0xb2, 0x7c, 0x54, 0xb0, 0x5f, 0x91, 0x97, 0x27}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xaf, 0x5, 0x1d, 0xf5, 0xf2, 0x29, 0x99, 0x12, 0x81, - 0xbe, 0x14, 0xa, 0xeb, 0x81, 0xa0, 0x20, 0xbe, 0xe9}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x44, 0x4a, 0xec, 0xf7, 0x5c, 0x66, 0x70, 0xf0, - 0x83, 0xd5, 0x10, 0x50, 0x85, 0x18, 0x85}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xbc, 0x6e, 0xf8, 0x2d, 0xc1, 0xf8, 0x8a, 0x93, 0xf, - 0xb5, 0x9, 0x6f, 0x89, 0x9, 0x94, 0xe6, 0xe9, 0x3d}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 167, 9, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 3223 [("U#\128\166r\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\198l]6!\158\151\NUL\255\155|\156\254",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode76) { - uint8_t pkt[] = {0x82, 0x1b, 0xc, 0x97, 0x0, 0x6, 0x55, 0x23, 0x80, 0xa6, 0x72, 0xd9, 0x0, 0x0, 0xd, - 0xc6, 0x6c, 0x5d, 0x36, 0x21, 0x9e, 0x97, 0x0, 0xff, 0x9b, 0x7c, 0x9c, 0xfe, 0x1}; - - uint8_t buf[39] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x55, 0x23, 0x80, 0xa6, 0x72, 0xd9}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc6, 0x6c, 0x5d, 0x36, 0x21, 0x9e, 0x97, 0x0, 0xff, 0x9b, 0x7c, 0x9c, 0xfe}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3223, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 1845 [("\196\128\&4\163O\255",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("f\255\128\199\ETXD\164B\184\249 \251\243\158TM\242\130",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("d@V!\249\199\168\166\194\241\244\243y\202\222\203\132\164\184\145\196\164",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SYN\197\232MQ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\242W\198\204\146t\ESC\192'\177\DC49>\166`{\152Q\247v\213\133\EM \160~@",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\229\252\136\170\181]\155\129\151\157\222\219P\163\177\130\146F\205",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\234\196[a\EOTi\137\214",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\232\&4\187\230\144aj3\ETB\EM\162%t\228",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\STXv\213",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\"=\211\194\176",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode77) { - uint8_t pkt[] = {0x82, 0xa2, 0x1, 0x7, 0x35, 0x0, 0x6, 0xc4, 0x80, 0x34, 0xa3, 0x4f, 0xff, 0x2, 0x0, 0x12, 0x66, - 0xff, 0x80, 0xc7, 0x3, 0x44, 0xa4, 0x42, 0xb8, 0xf9, 0x20, 0xfb, 0xf3, 0x9e, 0x54, 0x4d, 0xf2, 0x82, - 0x0, 0x0, 0x16, 0x64, 0x40, 0x56, 0x21, 0xf9, 0xc7, 0xa8, 0xa6, 0xc2, 0xf1, 0xf4, 0xf3, 0x79, 0xca, - 0xde, 0xcb, 0x84, 0xa4, 0xb8, 0x91, 0xc4, 0xa4, 0x0, 0x0, 0x5, 0x16, 0xc5, 0xe8, 0x4d, 0x51, 0x1, - 0x0, 0x1b, 0xf2, 0x57, 0xc6, 0xcc, 0x92, 0x74, 0x1b, 0xc0, 0x27, 0xb1, 0x14, 0x39, 0x3e, 0xa6, 0x60, - 0x7b, 0x98, 0x51, 0xf7, 0x76, 0xd5, 0x85, 0x19, 0x20, 0xa0, 0x7e, 0x40, 0x0, 0x0, 0x13, 0xe5, 0xfc, - 0x88, 0xaa, 0xb5, 0x5d, 0x9b, 0x81, 0x97, 0x9d, 0xde, 0xdb, 0x50, 0xa3, 0xb1, 0x82, 0x92, 0x46, 0xcd, - 0x1, 0x0, 0x0, 0x0, 0x0, 0x8, 0xea, 0xc4, 0x5b, 0x61, 0x4, 0x69, 0x89, 0xd6, 0x2, 0x0, 0xe, - 0xe8, 0x34, 0xbb, 0xe6, 0x90, 0x61, 0x6a, 0x33, 0x17, 0x19, 0xa2, 0x25, 0x74, 0xe4, 0x0, 0x0, 0x3, - 0x2, 0x76, 0xd5, 0x2, 0x0, 0x5, 0x22, 0x3d, 0xd3, 0xc2, 0xb0, 0x2}; - - uint8_t buf[175] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xc4, 0x80, 0x34, 0xa3, 0x4f, 0xff}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x66, 0xff, 0x80, 0xc7, 0x3, 0x44, 0xa4, 0x42, 0xb8, - 0xf9, 0x20, 0xfb, 0xf3, 0x9e, 0x54, 0x4d, 0xf2, 0x82}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x64, 0x40, 0x56, 0x21, 0xf9, 0xc7, 0xa8, 0xa6, 0xc2, 0xf1, 0xf4, - 0xf3, 0x79, 0xca, 0xde, 0xcb, 0x84, 0xa4, 0xb8, 0x91, 0xc4, 0xa4}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x16, 0xc5, 0xe8, 0x4d, 0x51}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xf2, 0x57, 0xc6, 0xcc, 0x92, 0x74, 0x1b, 0xc0, 0x27, 0xb1, 0x14, 0x39, 0x3e, 0xa6, - 0x60, 0x7b, 0x98, 0x51, 0xf7, 0x76, 0xd5, 0x85, 0x19, 0x20, 0xa0, 0x7e, 0x40}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe5, 0xfc, 0x88, 0xaa, 0xb5, 0x5d, 0x9b, 0x81, 0x97, 0x9d, - 0xde, 0xdb, 0x50, 0xa3, 0xb1, 0x82, 0x92, 0x46, 0xcd}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xea, 0xc4, 0x5b, 0x61, 0x4, 0x69, 0x89, 0xd6}; - lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe8, 0x34, 0xbb, 0xe6, 0x90, 0x61, 0x6a, - 0x33, 0x17, 0x19, 0xa2, 0x25, 0x74, 0xe4}; - lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x2, 0x76, 0xd5}; - lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x22, 0x3d, 0xd3, 0xc2, 0xb0}; - lwmqtt_string_t topic_filter_s10 = {5, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1845, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12377 [("\156\222Z\207\145\DC1\171\133j\149\210Dr\137\&1\130\219\182 2H\210\203s",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode78) { - uint8_t pkt[] = {0x82, 0x1d, 0x30, 0x59, 0x0, 0x18, 0x9c, 0xde, 0x5a, 0xcf, 0x91, 0x11, 0xab, 0x85, 0x6a, 0x95, - 0xd2, 0x44, 0x72, 0x89, 0x31, 0x82, 0xdb, 0xb6, 0x20, 0x32, 0x48, 0xd2, 0xcb, 0x73, 0x1}; - - uint8_t buf[41] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x9c, 0xde, 0x5a, 0xcf, 0x91, 0x11, 0xab, 0x85, 0x6a, 0x95, 0xd2, 0x44, - 0x72, 0x89, 0x31, 0x82, 0xdb, 0xb6, 0x20, 0x32, 0x48, 0xd2, 0xcb, 0x73}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12377, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 290 [("-\CAN\FSe\144\STXP\243wu\191%\250\176\&5\250\204V\239\137}",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\128&U[\222\&1,\232\&9\137\194\vD\146\155m\DLE\213\249\229d\FSI+\v]",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\232g?\215\156\STXD\132\NUL\197\ACK(\234:\DC1\153C\148\b/\180^",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\176\160\178:&\NUL\182\\\173\RS\138\144\138@\148U\ENQA>\191\&1t",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),(".\162!\217\216*\155\205\236\RSc\tEWe2\159'\216\149\193\235\DC1[\200\188\233\230\215",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\187\152j\248\219\&2\152\&3\SO\GS\135",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\176\144m\168\226",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\227\202\180@6a",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("|\129\183e\162\160X\243e\238E\183\184\128SY\157\EM6\253",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode79) { - uint8_t pkt[] = {0x82, 0xbf, 0x1, 0x1, 0x22, 0x0, 0x15, 0x2d, 0x18, 0x1c, 0x65, 0x90, 0x2, 0x50, 0xf3, 0x77, 0x75, - 0xbf, 0x25, 0xfa, 0xb0, 0x35, 0xfa, 0xcc, 0x56, 0xef, 0x89, 0x7d, 0x1, 0x0, 0x1a, 0x80, 0x26, 0x55, - 0x5b, 0xde, 0x31, 0x2c, 0xe8, 0x39, 0x89, 0xc2, 0xb, 0x44, 0x92, 0x9b, 0x6d, 0x10, 0xd5, 0xf9, 0xe5, - 0x64, 0x1c, 0x49, 0x2b, 0xb, 0x5d, 0x0, 0x0, 0x16, 0xe8, 0x67, 0x3f, 0xd7, 0x9c, 0x2, 0x44, 0x84, - 0x0, 0xc5, 0x6, 0x28, 0xea, 0x3a, 0x11, 0x99, 0x43, 0x94, 0x8, 0x2f, 0xb4, 0x5e, 0x1, 0x0, 0x16, - 0xb0, 0xa0, 0xb2, 0x3a, 0x26, 0x0, 0xb6, 0x5c, 0xad, 0x1e, 0x8a, 0x90, 0x8a, 0x40, 0x94, 0x55, 0x5, - 0x41, 0x3e, 0xbf, 0x31, 0x74, 0x1, 0x0, 0x1d, 0x2e, 0xa2, 0x21, 0xd9, 0xd8, 0x2a, 0x9b, 0xcd, 0xec, - 0x1e, 0x63, 0x9, 0x45, 0x57, 0x65, 0x32, 0x9f, 0x27, 0xd8, 0x95, 0xc1, 0xeb, 0x11, 0x5b, 0xc8, 0xbc, - 0xe9, 0xe6, 0xd7, 0x2, 0x0, 0xb, 0xbb, 0x98, 0x6a, 0xf8, 0xdb, 0x32, 0x98, 0x33, 0xe, 0x1d, 0x87, - 0x2, 0x0, 0x5, 0xb0, 0x90, 0x6d, 0xa8, 0xe2, 0x1, 0x0, 0x6, 0xe3, 0xca, 0xb4, 0x40, 0x36, 0x61, - 0x2, 0x0, 0x14, 0x7c, 0x81, 0xb7, 0x65, 0xa2, 0xa0, 0x58, 0xf3, 0x65, 0xee, 0x45, 0xb7, 0xb8, 0x80, - 0x53, 0x59, 0x9d, 0x19, 0x36, 0xfd, 0x1}; - - uint8_t buf[204] = {0}; - - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x2d, 0x18, 0x1c, 0x65, 0x90, 0x2, 0x50, 0xf3, 0x77, 0x75, 0xbf, - 0x25, 0xfa, 0xb0, 0x35, 0xfa, 0xcc, 0x56, 0xef, 0x89, 0x7d}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x80, 0x26, 0x55, 0x5b, 0xde, 0x31, 0x2c, 0xe8, 0x39, 0x89, 0xc2, 0xb, 0x44, - 0x92, 0x9b, 0x6d, 0x10, 0xd5, 0xf9, 0xe5, 0x64, 0x1c, 0x49, 0x2b, 0xb, 0x5d}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe8, 0x67, 0x3f, 0xd7, 0x9c, 0x2, 0x44, 0x84, 0x0, 0xc5, 0x6, - 0x28, 0xea, 0x3a, 0x11, 0x99, 0x43, 0x94, 0x8, 0x2f, 0xb4, 0x5e}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb0, 0xa0, 0xb2, 0x3a, 0x26, 0x0, 0xb6, 0x5c, 0xad, 0x1e, 0x8a, - 0x90, 0x8a, 0x40, 0x94, 0x55, 0x5, 0x41, 0x3e, 0xbf, 0x31, 0x74}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2e, 0xa2, 0x21, 0xd9, 0xd8, 0x2a, 0x9b, 0xcd, 0xec, 0x1e, - 0x63, 0x9, 0x45, 0x57, 0x65, 0x32, 0x9f, 0x27, 0xd8, 0x95, - 0xc1, 0xeb, 0x11, 0x5b, 0xc8, 0xbc, 0xe9, 0xe6, 0xd7}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xbb, 0x98, 0x6a, 0xf8, 0xdb, 0x32, 0x98, 0x33, 0xe, 0x1d, 0x87}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb0, 0x90, 0x6d, 0xa8, 0xe2}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe3, 0xca, 0xb4, 0x40, 0x36, 0x61}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x7c, 0x81, 0xb7, 0x65, 0xa2, 0xa0, 0x58, 0xf3, 0x65, 0xee, - 0x45, 0xb7, 0xb8, 0x80, 0x53, 0x59, 0x9d, 0x19, 0x36, 0xfd}; - lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 290, 9, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 28088 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),(":\193@\178\186\219\136\180",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\254\238]\245\184?\239",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("W'\132<\DC3\nUBMC\159\172b\NUL\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode80) { - uint8_t pkt[] = {0x82, 0x2c, 0x6d, 0xb8, 0x0, 0x0, 0x2, 0x0, 0x8, 0x3a, 0xc1, 0x40, 0xb2, 0xba, 0xdb, 0x88, - 0xb4, 0x2, 0x0, 0x7, 0xfe, 0xee, 0x5d, 0xf5, 0xb8, 0x3f, 0xef, 0x0, 0x0, 0xf, 0x57, 0x27, - 0x84, 0x3c, 0x13, 0xa, 0x55, 0x42, 0x4d, 0x43, 0x9f, 0xac, 0x62, 0x0, 0xb9, 0x1}; - - uint8_t buf[56] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3a, 0xc1, 0x40, 0xb2, 0xba, 0xdb, 0x88, 0xb4}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfe, 0xee, 0x5d, 0xf5, 0xb8, 0x3f, 0xef}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x57, 0x27, 0x84, 0x3c, 0x13, 0xa, 0x55, 0x42, - 0x4d, 0x43, 0x9f, 0xac, 0x62, 0x0, 0xb9}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28088, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 4272 [("\":\159\"\202S\RS\ACK\244z5",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\242\235\190\253wC6\EMH\250\232\247\131u\172\a=\132\224\&9\192 \GS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\222!bl\193ck\202\&8K",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\162\190\167\211\FS\232\161;\130{%\ENQ\ACK\200\DC1\153\206\DC2\172b\193r\138",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("!",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode81) { - uint8_t pkt[] = {0x82, 0x55, 0x10, 0xb0, 0x0, 0xb, 0x22, 0x3a, 0x9f, 0x22, 0xca, 0x53, 0x1e, 0x6, 0xf4, - 0x7a, 0x35, 0x2, 0x0, 0x17, 0xf2, 0xeb, 0xbe, 0xfd, 0x77, 0x43, 0x36, 0x19, 0x48, 0xfa, - 0xe8, 0xf7, 0x83, 0x75, 0xac, 0x7, 0x3d, 0x84, 0xe0, 0x39, 0xc0, 0x20, 0x1d, 0x0, 0x0, - 0xa, 0xde, 0x21, 0x62, 0x6c, 0xc1, 0x63, 0x6b, 0xca, 0x38, 0x4b, 0x0, 0x0, 0x17, 0xa2, - 0xbe, 0xa7, 0xd3, 0x1c, 0xe8, 0xa1, 0x3b, 0x82, 0x7b, 0x25, 0x5, 0x6, 0xc8, 0x11, 0x99, - 0xce, 0x12, 0xac, 0x62, 0xc1, 0x72, 0x8a, 0x2, 0x0, 0x1, 0x21, 0x2}; - - uint8_t buf[97] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x22, 0x3a, 0x9f, 0x22, 0xca, 0x53, 0x1e, 0x6, 0xf4, 0x7a, 0x35}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf2, 0xeb, 0xbe, 0xfd, 0x77, 0x43, 0x36, 0x19, 0x48, 0xfa, 0xe8, 0xf7, - 0x83, 0x75, 0xac, 0x7, 0x3d, 0x84, 0xe0, 0x39, 0xc0, 0x20, 0x1d}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xde, 0x21, 0x62, 0x6c, 0xc1, 0x63, 0x6b, 0xca, 0x38, 0x4b}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa2, 0xbe, 0xa7, 0xd3, 0x1c, 0xe8, 0xa1, 0x3b, 0x82, 0x7b, 0x25, 0x5, - 0x6, 0xc8, 0x11, 0x99, 0xce, 0x12, 0xac, 0x62, 0xc1, 0x72, 0x8a}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x21}; - lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4272, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14420 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\193\143\248\171\SUBB\US\162U`\238\207",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\230\138\SIF\159~gN\227\241|",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("'\194\SUB\DC1\143+,\"\128\209\SUB\220\162\DC1\240\196\DC3\226\NUL\146\226:\STX\189J*~&\200",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("~3\195L&]\160\184\161\STX\168\181#Em!\205\252K\253",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("dI\177g\202Vp4k\ENQ\178\255z\171x\212\STX\224\RSS\FS\169\144\180\151\182\201",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("6\NAK\EOT\145\216\229B\EM\247\242\&1b\223\131\141",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode82) { - uint8_t pkt[] = {0x82, 0x89, 0x1, 0x38, 0x54, 0x0, 0x0, 0x0, 0x0, 0xc, 0xc1, 0x8f, 0xf8, 0xab, 0x1a, 0x42, - 0x1f, 0xa2, 0x55, 0x60, 0xee, 0xcf, 0x0, 0x0, 0xb, 0xe6, 0x8a, 0xf, 0x46, 0x9f, 0x7e, 0x67, - 0x4e, 0xe3, 0xf1, 0x7c, 0x0, 0x0, 0x1d, 0x27, 0xc2, 0x1a, 0x11, 0x8f, 0x2b, 0x2c, 0x22, 0x80, - 0xd1, 0x1a, 0xdc, 0xa2, 0x11, 0xf0, 0xc4, 0x13, 0xe2, 0x0, 0x92, 0xe2, 0x3a, 0x2, 0xbd, 0x4a, - 0x2a, 0x7e, 0x26, 0xc8, 0x2, 0x0, 0x14, 0x7e, 0x33, 0xc3, 0x4c, 0x26, 0x5d, 0xa0, 0xb8, 0xa1, - 0x2, 0xa8, 0xb5, 0x23, 0x45, 0x6d, 0x21, 0xcd, 0xfc, 0x4b, 0xfd, 0x2, 0x0, 0x1b, 0x64, 0x49, - 0xb1, 0x67, 0xca, 0x56, 0x70, 0x34, 0x6b, 0x5, 0xb2, 0xff, 0x7a, 0xab, 0x78, 0xd4, 0x2, 0xe0, - 0x1e, 0x53, 0x1c, 0xa9, 0x90, 0xb4, 0x97, 0xb6, 0xc9, 0x2, 0x0, 0xf, 0x36, 0x15, 0x4, 0x91, - 0xd8, 0xe5, 0x42, 0x19, 0xf7, 0xf2, 0x31, 0x62, 0xdf, 0x83, 0x8d, 0x2}; - - uint8_t buf[150] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc1, 0x8f, 0xf8, 0xab, 0x1a, 0x42, 0x1f, 0xa2, 0x55, 0x60, 0xee, 0xcf}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe6, 0x8a, 0xf, 0x46, 0x9f, 0x7e, 0x67, 0x4e, 0xe3, 0xf1, 0x7c}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x27, 0xc2, 0x1a, 0x11, 0x8f, 0x2b, 0x2c, 0x22, 0x80, 0xd1, - 0x1a, 0xdc, 0xa2, 0x11, 0xf0, 0xc4, 0x13, 0xe2, 0x0, 0x92, - 0xe2, 0x3a, 0x2, 0xbd, 0x4a, 0x2a, 0x7e, 0x26, 0xc8}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7e, 0x33, 0xc3, 0x4c, 0x26, 0x5d, 0xa0, 0xb8, 0xa1, 0x2, - 0xa8, 0xb5, 0x23, 0x45, 0x6d, 0x21, 0xcd, 0xfc, 0x4b, 0xfd}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x64, 0x49, 0xb1, 0x67, 0xca, 0x56, 0x70, 0x34, 0x6b, 0x5, 0xb2, 0xff, 0x7a, 0xab, - 0x78, 0xd4, 0x2, 0xe0, 0x1e, 0x53, 0x1c, 0xa9, 0x90, 0xb4, 0x97, 0xb6, 0xc9}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x36, 0x15, 0x4, 0x91, 0xd8, 0xe5, 0x42, 0x19, - 0xf7, 0xf2, 0x31, 0x62, 0xdf, 0x83, 0x8d}; - lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14420, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 27160 [("\162D\159",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\195_\131\NULo|\DC3\153\204\130Z\129\a\148$\133jPw\238<\201\&1X\151F\133\248\217l",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\168\&1\255\241I\162\173v\254uZ*\140G",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\US=\184j\\AA\155\156@\178\229r'K0i\204\ESC\168Q'\196\226\234\233",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode83) { - uint8_t pkt[] = {0x82, 0x57, 0x6a, 0x18, 0x0, 0x3, 0xa2, 0x44, 0x9f, 0x2, 0x0, 0x1e, 0xc3, 0x5f, 0x83, - 0x0, 0x6f, 0x7c, 0x13, 0x99, 0xcc, 0x82, 0x5a, 0x81, 0x7, 0x94, 0x24, 0x85, 0x6a, 0x50, - 0x77, 0xee, 0x3c, 0xc9, 0x31, 0x58, 0x97, 0x46, 0x85, 0xf8, 0xd9, 0x6c, 0x2, 0x0, 0xe, - 0xa8, 0x31, 0xff, 0xf1, 0x49, 0xa2, 0xad, 0x76, 0xfe, 0x75, 0x5a, 0x2a, 0x8c, 0x47, 0x1, - 0x0, 0x1a, 0x1f, 0x3d, 0xb8, 0x6a, 0x5c, 0x41, 0x41, 0x9b, 0x9c, 0x40, 0xb2, 0xe5, 0x72, - 0x27, 0x4b, 0x30, 0x69, 0xcc, 0x1b, 0xa8, 0x51, 0x27, 0xc4, 0xe2, 0xea, 0xe9, 0x2}; - - uint8_t buf[99] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xa2, 0x44, 0x9f}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc3, 0x5f, 0x83, 0x0, 0x6f, 0x7c, 0x13, 0x99, 0xcc, 0x82, - 0x5a, 0x81, 0x7, 0x94, 0x24, 0x85, 0x6a, 0x50, 0x77, 0xee, - 0x3c, 0xc9, 0x31, 0x58, 0x97, 0x46, 0x85, 0xf8, 0xd9, 0x6c}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa8, 0x31, 0xff, 0xf1, 0x49, 0xa2, 0xad, - 0x76, 0xfe, 0x75, 0x5a, 0x2a, 0x8c, 0x47}; - lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1f, 0x3d, 0xb8, 0x6a, 0x5c, 0x41, 0x41, 0x9b, 0x9c, 0x40, 0xb2, 0xe5, 0x72, - 0x27, 0x4b, 0x30, 0x69, 0xcc, 0x1b, 0xa8, 0x51, 0x27, 0xc4, 0xe2, 0xea, 0xe9}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27160, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 22660 -// [("k\215\&6o4\168\148\NAKl|\DC2eLi\r\203\ETX\152\158\131\197\142\143\248\134l\CAN\243\SYN",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("!m\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS -// = QoS1}),("t\a\155\243\134r\ETB)\244Y:",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\144",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("Dy",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),("\169p\197\187\137\SUBA\138\224\242\167\174\rh\b\143\210f\225\220\STX\200\t",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\rw\214#2r\221~\249",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode84) { - uint8_t pkt[] = {0x82, 0x65, 0x58, 0x84, 0x0, 0x1d, 0x6b, 0xd7, 0x36, 0x6f, 0x34, 0xa8, 0x94, 0x15, 0x6c, - 0x7c, 0x12, 0x65, 0x4c, 0x69, 0xd, 0xcb, 0x3, 0x98, 0x9e, 0x83, 0xc5, 0x8e, 0x8f, 0xf8, - 0x86, 0x6c, 0x18, 0xf3, 0x16, 0x0, 0x0, 0x3, 0x21, 0x6d, 0xb9, 0x1, 0x0, 0xb, 0x74, - 0x7, 0x9b, 0xf3, 0x86, 0x72, 0x17, 0x29, 0xf4, 0x59, 0x3a, 0x2, 0x0, 0x1, 0x90, 0x1, - 0x0, 0x2, 0x44, 0x79, 0x0, 0x0, 0x17, 0xa9, 0x70, 0xc5, 0xbb, 0x89, 0x1a, 0x41, 0x8a, - 0xe0, 0xf2, 0xa7, 0xae, 0xd, 0x68, 0x8, 0x8f, 0xd2, 0x66, 0xe1, 0xdc, 0x2, 0xc8, 0x9, - 0x1, 0x0, 0x9, 0xd, 0x77, 0xd6, 0x23, 0x32, 0x72, 0xdd, 0x7e, 0xf9, 0x2}; - - uint8_t buf[113] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x6b, 0xd7, 0x36, 0x6f, 0x34, 0xa8, 0x94, 0x15, 0x6c, 0x7c, - 0x12, 0x65, 0x4c, 0x69, 0xd, 0xcb, 0x3, 0x98, 0x9e, 0x83, - 0xc5, 0x8e, 0x8f, 0xf8, 0x86, 0x6c, 0x18, 0xf3, 0x16}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x21, 0x6d, 0xb9}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x74, 0x7, 0x9b, 0xf3, 0x86, 0x72, 0x17, 0x29, 0xf4, 0x59, 0x3a}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x90}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x44, 0x79}; - lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa9, 0x70, 0xc5, 0xbb, 0x89, 0x1a, 0x41, 0x8a, 0xe0, 0xf2, 0xa7, 0xae, - 0xd, 0x68, 0x8, 0x8f, 0xd2, 0x66, 0xe1, 0xdc, 0x2, 0xc8, 0x9}; - lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xd, 0x77, 0xd6, 0x23, 0x32, 0x72, 0xdd, 0x7e, 0xf9}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22660, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 13206 [("\134\245\ft\GS\160Zb\214\NAK\247^\170\162\CAN\201D\147\244$\SUB\DC2\130d\170",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\134",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\190\142\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\NAKe\ETB\156>o\252\206\DC2F\DLE\224\224\183\231O\254`K\185\191\202",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\246\204EG\236x\DC3\172\243\168+\175\196v@#\DEL\188\&4\205M\226p1\165\174",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\ETX;\137\191}\SOdq\196\DC1\234\160\DEL1\173\155Rr8(\241S\132\173\129",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode85) { - uint8_t pkt[] = {0x82, 0x7e, 0x33, 0x96, 0x0, 0x19, 0x86, 0xf5, 0xc, 0x74, 0x1d, 0xa0, 0x5a, 0x62, 0xd6, 0x15, - 0xf7, 0x5e, 0xaa, 0xa2, 0x18, 0xc9, 0x44, 0x93, 0xf4, 0x24, 0x1a, 0x12, 0x82, 0x64, 0xaa, 0x1, - 0x0, 0x1, 0x86, 0x1, 0x0, 0x3, 0xbe, 0x8e, 0xd2, 0x2, 0x0, 0x1, 0x39, 0x1, 0x0, 0x16, - 0x15, 0x65, 0x17, 0x9c, 0x3e, 0x6f, 0xfc, 0xce, 0x12, 0x46, 0x10, 0xe0, 0xe0, 0xb7, 0xe7, 0x4f, - 0xfe, 0x60, 0x4b, 0xb9, 0xbf, 0xca, 0x2, 0x0, 0x1a, 0xf6, 0xcc, 0x45, 0x47, 0xec, 0x78, 0x13, - 0xac, 0xf3, 0xa8, 0x2b, 0xaf, 0xc4, 0x76, 0x40, 0x23, 0x7f, 0xbc, 0x34, 0xcd, 0x4d, 0xe2, 0x70, - 0x31, 0xa5, 0xae, 0x0, 0x0, 0x19, 0x3, 0x3b, 0x89, 0xbf, 0x7d, 0xe, 0x64, 0x71, 0xc4, 0x11, - 0xea, 0xa0, 0x7f, 0x31, 0xad, 0x9b, 0x52, 0x72, 0x38, 0x28, 0xf1, 0x53, 0x84, 0xad, 0x81, 0x1}; - - uint8_t buf[138] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x86, 0xf5, 0xc, 0x74, 0x1d, 0xa0, 0x5a, 0x62, 0xd6, 0x15, 0xf7, 0x5e, 0xaa, - 0xa2, 0x18, 0xc9, 0x44, 0x93, 0xf4, 0x24, 0x1a, 0x12, 0x82, 0x64, 0xaa}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x86}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xbe, 0x8e, 0xd2}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x39}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x15, 0x65, 0x17, 0x9c, 0x3e, 0x6f, 0xfc, 0xce, 0x12, 0x46, 0x10, - 0xe0, 0xe0, 0xb7, 0xe7, 0x4f, 0xfe, 0x60, 0x4b, 0xb9, 0xbf, 0xca}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf6, 0xcc, 0x45, 0x47, 0xec, 0x78, 0x13, 0xac, 0xf3, 0xa8, 0x2b, 0xaf, 0xc4, - 0x76, 0x40, 0x23, 0x7f, 0xbc, 0x34, 0xcd, 0x4d, 0xe2, 0x70, 0x31, 0xa5, 0xae}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3, 0x3b, 0x89, 0xbf, 0x7d, 0xe, 0x64, 0x71, 0xc4, 0x11, 0xea, 0xa0, 0x7f, - 0x31, 0xad, 0x9b, 0x52, 0x72, 0x38, 0x28, 0xf1, 0x53, 0x84, 0xad, 0x81}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13206, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 8501 [("\203p\176B\229Ul'\142n\159\GS\221",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode86) { - uint8_t pkt[] = {0x82, 0x12, 0x21, 0x35, 0x0, 0xd, 0xcb, 0x70, 0xb0, 0x42, - 0xe5, 0x55, 0x6c, 0x27, 0x8e, 0x6e, 0x9f, 0x1d, 0xdd, 0x2}; - - uint8_t buf[30] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xcb, 0x70, 0xb0, 0x42, 0xe5, 0x55, 0x6c, 0x27, 0x8e, 0x6e, 0x9f, 0x1d, 0xdd}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8501, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 25153 [("\132f\153\132\244w'\154\220S",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\249\167\241%",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\142\244",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\151NI\219\241\129\216N\187\248`\189\"G}\165\133)7R\135\154\ETX~\175",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("/;\227\164B+\151W!\206\238\128\136\GS\vz\163\244:G\172V",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("5\145\185{#B\152\236",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("<\131\162\143,2\130\130\159\151\150\CAN2\223\208\ESC\181\218\201\149\&6",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode87) { - uint8_t pkt[] = {0x82, 0x76, 0x62, 0x41, 0x0, 0xa, 0x84, 0x66, 0x99, 0x84, 0xf4, 0x77, 0x27, 0x9a, 0xdc, - 0x53, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0xf9, 0xa7, 0xf1, 0x25, 0x2, 0x0, 0x2, 0x8e, - 0xf4, 0x1, 0x0, 0x19, 0x97, 0x4e, 0x49, 0xdb, 0xf1, 0x81, 0xd8, 0x4e, 0xbb, 0xf8, 0x60, - 0xbd, 0x22, 0x47, 0x7d, 0xa5, 0x85, 0x29, 0x37, 0x52, 0x87, 0x9a, 0x3, 0x7e, 0xaf, 0x0, - 0x0, 0x16, 0x2f, 0x3b, 0xe3, 0xa4, 0x42, 0x2b, 0x97, 0x57, 0x21, 0xce, 0xee, 0x80, 0x88, - 0x1d, 0xb, 0x7a, 0xa3, 0xf4, 0x3a, 0x47, 0xac, 0x56, 0x0, 0x0, 0x8, 0x35, 0x91, 0xb9, - 0x7b, 0x23, 0x42, 0x98, 0xec, 0x0, 0x0, 0x15, 0x3c, 0x83, 0xa2, 0x8f, 0x2c, 0x32, 0x82, - 0x82, 0x9f, 0x97, 0x96, 0x18, 0x32, 0xdf, 0xd0, 0x1b, 0xb5, 0xda, 0xc9, 0x95, 0x36, 0x0}; - - uint8_t buf[130] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x84, 0x66, 0x99, 0x84, 0xf4, 0x77, 0x27, 0x9a, 0xdc, 0x53}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf9, 0xa7, 0xf1, 0x25}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8e, 0xf4}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x97, 0x4e, 0x49, 0xdb, 0xf1, 0x81, 0xd8, 0x4e, 0xbb, 0xf8, 0x60, 0xbd, 0x22, - 0x47, 0x7d, 0xa5, 0x85, 0x29, 0x37, 0x52, 0x87, 0x9a, 0x3, 0x7e, 0xaf}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x2f, 0x3b, 0xe3, 0xa4, 0x42, 0x2b, 0x97, 0x57, 0x21, 0xce, 0xee, - 0x80, 0x88, 0x1d, 0xb, 0x7a, 0xa3, 0xf4, 0x3a, 0x47, 0xac, 0x56}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x35, 0x91, 0xb9, 0x7b, 0x23, 0x42, 0x98, 0xec}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x3c, 0x83, 0xa2, 0x8f, 0x2c, 0x32, 0x82, 0x82, 0x9f, 0x97, 0x96, - 0x18, 0x32, 0xdf, 0xd0, 0x1b, 0xb5, 0xda, 0xc9, 0x95, 0x36}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25153, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 10517 [("\252",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode88) { - uint8_t pkt[] = {0x82, 0x6, 0x29, 0x15, 0x0, 0x1, 0xfc, 0x1}; - - uint8_t buf[18] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xfc}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10517, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 24618 [("\162\&7a\196\249\&0\135*\143\198O\209\148nI",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode89) { - uint8_t pkt[] = {0x82, 0x14, 0x60, 0x2a, 0x0, 0xf, 0xa2, 0x37, 0x61, 0xc4, 0xf9, - 0x30, 0x87, 0x2a, 0x8f, 0xc6, 0x4f, 0xd1, 0x94, 0x6e, 0x49, 0x0}; - - uint8_t buf[32] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xa2, 0x37, 0x61, 0xc4, 0xf9, 0x30, 0x87, 0x2a, - 0x8f, 0xc6, 0x4f, 0xd1, 0x94, 0x6e, 0x49}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24618, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 32265 [("\188Z\ESCD\172\&2\GSO\235_\175N*$\243\136\224 =\137\169\155\DEL\227\&1",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\203\232q4\EM\v\220\158X\173l\SUB\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode90) { - uint8_t pkt[] = {0x82, 0x2e, 0x7e, 0x9, 0x0, 0x19, 0xbc, 0x5a, 0x1b, 0x44, 0xac, 0x32, 0x1d, 0x4f, 0xeb, 0x5f, - 0xaf, 0x4e, 0x2a, 0x24, 0xf3, 0x88, 0xe0, 0x20, 0x3d, 0x89, 0xa9, 0x9b, 0x7f, 0xe3, 0x31, 0x0, - 0x0, 0xd, 0xcb, 0xe8, 0x71, 0x34, 0x19, 0xb, 0xdc, 0x9e, 0x58, 0xad, 0x6c, 0x1a, 0xae, 0x2}; - - uint8_t buf[58] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xbc, 0x5a, 0x1b, 0x44, 0xac, 0x32, 0x1d, 0x4f, 0xeb, 0x5f, 0xaf, 0x4e, 0x2a, - 0x24, 0xf3, 0x88, 0xe0, 0x20, 0x3d, 0x89, 0xa9, 0x9b, 0x7f, 0xe3, 0x31}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcb, 0xe8, 0x71, 0x34, 0x19, 0xb, 0xdc, 0x9e, 0x58, 0xad, 0x6c, 0x1a, 0xae}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32265, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 7342 [("\RS8\172\211YnUe\216\&6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("~\\\198\&7Ty\GS\206{}\244\164c@{",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("j\227\vg\167<\\S\255\151",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("$S\172",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\174\RS\128=\161\254b\152\&4 \209\226m\237`\SOHcY\162",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\210\179\&8\244\FS\DC2\219W\171\&8!\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("Z\202\&4E\179\143\226E\151\146!\135\216",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\150\&5\226T\150\145THQ\tM\156\165\146Y\245\"\ESC\152YF\252\180\142\222\181\171\175D",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\220\144\&8\247r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("G=\164\r\202\193\181\145:\160V\n7F/\251\199)\224\DLE\197\239\r",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode91) { - uint8_t pkt[] = {0x82, 0xab, 0x1, 0x1c, 0xae, 0x0, 0xa, 0x1e, 0x38, 0xac, 0xd3, 0x59, 0x6e, 0x55, 0x65, 0xd8, - 0x36, 0x2, 0x0, 0xf, 0x7e, 0x5c, 0xc6, 0x37, 0x54, 0x79, 0x1d, 0xce, 0x7b, 0x7d, 0xf4, 0xa4, - 0x63, 0x40, 0x7b, 0x2, 0x0, 0xa, 0x6a, 0xe3, 0xb, 0x67, 0xa7, 0x3c, 0x5c, 0x53, 0xff, 0x97, - 0x0, 0x0, 0x3, 0x24, 0x53, 0xac, 0x0, 0x0, 0x13, 0xae, 0x1e, 0x80, 0x3d, 0xa1, 0xfe, 0x62, - 0x98, 0x34, 0x20, 0xd1, 0xe2, 0x6d, 0xed, 0x60, 0x1, 0x63, 0x59, 0xa2, 0x1, 0x0, 0xc, 0xd2, - 0xb3, 0x38, 0xf4, 0x1c, 0x12, 0xdb, 0x57, 0xab, 0x38, 0x21, 0xba, 0x1, 0x0, 0xd, 0x5a, 0xca, - 0x34, 0x45, 0xb3, 0x8f, 0xe2, 0x45, 0x97, 0x92, 0x21, 0x87, 0xd8, 0x1, 0x0, 0x1d, 0x96, 0x35, - 0xe2, 0x54, 0x96, 0x91, 0x54, 0x48, 0x51, 0x9, 0x4d, 0x9c, 0xa5, 0x92, 0x59, 0xf5, 0x22, 0x1b, - 0x98, 0x59, 0x46, 0xfc, 0xb4, 0x8e, 0xde, 0xb5, 0xab, 0xaf, 0x44, 0x1, 0x0, 0x5, 0xdc, 0x90, - 0x38, 0xf7, 0x72, 0x1, 0x0, 0x17, 0x47, 0x3d, 0xa4, 0xd, 0xca, 0xc1, 0xb5, 0x91, 0x3a, 0xa0, - 0x56, 0xa, 0x37, 0x46, 0x2f, 0xfb, 0xc7, 0x29, 0xe0, 0x10, 0xc5, 0xef, 0xd, 0x2}; - - uint8_t buf[184] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x1e, 0x38, 0xac, 0xd3, 0x59, 0x6e, 0x55, 0x65, 0xd8, 0x36}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7e, 0x5c, 0xc6, 0x37, 0x54, 0x79, 0x1d, 0xce, - 0x7b, 0x7d, 0xf4, 0xa4, 0x63, 0x40, 0x7b}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6a, 0xe3, 0xb, 0x67, 0xa7, 0x3c, 0x5c, 0x53, 0xff, 0x97}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x24, 0x53, 0xac}; - lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xae, 0x1e, 0x80, 0x3d, 0xa1, 0xfe, 0x62, 0x98, 0x34, 0x20, - 0xd1, 0xe2, 0x6d, 0xed, 0x60, 0x1, 0x63, 0x59, 0xa2}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xd2, 0xb3, 0x38, 0xf4, 0x1c, 0x12, 0xdb, 0x57, 0xab, 0x38, 0x21, 0xba}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5a, 0xca, 0x34, 0x45, 0xb3, 0x8f, 0xe2, 0x45, 0x97, 0x92, 0x21, 0x87, 0xd8}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x96, 0x35, 0xe2, 0x54, 0x96, 0x91, 0x54, 0x48, 0x51, 0x9, - 0x4d, 0x9c, 0xa5, 0x92, 0x59, 0xf5, 0x22, 0x1b, 0x98, 0x59, - 0x46, 0xfc, 0xb4, 0x8e, 0xde, 0xb5, 0xab, 0xaf, 0x44}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xdc, 0x90, 0x38, 0xf7, 0x72}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x47, 0x3d, 0xa4, 0xd, 0xca, 0xc1, 0xb5, 0x91, 0x3a, 0xa0, 0x56, 0xa, - 0x37, 0x46, 0x2f, 0xfb, 0xc7, 0x29, 0xe0, 0x10, 0xc5, 0xef, 0xd}; - lwmqtt_string_t topic_filter_s9 = {23, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7342, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 25785 [("4\DC1\131\219{\253\160\n\151f\226{\218\179",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("F\173\174\178\252\144\161\193\&0H\130c\170,\160\167-)\162",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\230\216\219R\ACK\203\\\EM\206|\151\250\&7",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("7!\245\132~\DC2(\164\v\167p\249O]\EOTx*&\173pP\249\209",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\213\FS\146i\223\DC4\233\DC1\SI\208*_B\198EP\ACK[\226\182)\255",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\247P\157\US\255e\250\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode92) { - uint8_t pkt[] = {0x82, 0x77, 0x64, 0xb9, 0x0, 0xe, 0x34, 0x11, 0x83, 0xdb, 0x7b, 0xfd, 0xa0, 0xa, 0x97, 0x66, - 0xe2, 0x7b, 0xda, 0xb3, 0x0, 0x0, 0x13, 0x46, 0xad, 0xae, 0xb2, 0xfc, 0x90, 0xa1, 0xc1, 0x30, - 0x48, 0x82, 0x63, 0xaa, 0x2c, 0xa0, 0xa7, 0x2d, 0x29, 0xa2, 0x0, 0x0, 0xd, 0xe6, 0xd8, 0xdb, - 0x52, 0x6, 0xcb, 0x5c, 0x19, 0xce, 0x7c, 0x97, 0xfa, 0x37, 0x1, 0x0, 0x17, 0x37, 0x21, 0xf5, - 0x84, 0x7e, 0x12, 0x28, 0xa4, 0xb, 0xa7, 0x70, 0xf9, 0x4f, 0x5d, 0x4, 0x78, 0x2a, 0x26, 0xad, - 0x70, 0x50, 0xf9, 0xd1, 0x1, 0x0, 0x16, 0xd5, 0x1c, 0x92, 0x69, 0xdf, 0x14, 0xe9, 0x11, 0xf, - 0xd0, 0x2a, 0x5f, 0x42, 0xc6, 0x45, 0x50, 0x6, 0x5b, 0xe2, 0xb6, 0x29, 0xff, 0x2, 0x0, 0x8, - 0xf7, 0x50, 0x9d, 0x1f, 0xff, 0x65, 0xfa, 0xb4, 0x0}; - - uint8_t buf[131] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x34, 0x11, 0x83, 0xdb, 0x7b, 0xfd, 0xa0, 0xa, 0x97, 0x66, 0xe2, 0x7b, 0xda, 0xb3}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x46, 0xad, 0xae, 0xb2, 0xfc, 0x90, 0xa1, 0xc1, 0x30, 0x48, - 0x82, 0x63, 0xaa, 0x2c, 0xa0, 0xa7, 0x2d, 0x29, 0xa2}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe6, 0xd8, 0xdb, 0x52, 0x6, 0xcb, 0x5c, 0x19, 0xce, 0x7c, 0x97, 0xfa, 0x37}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x37, 0x21, 0xf5, 0x84, 0x7e, 0x12, 0x28, 0xa4, 0xb, 0xa7, 0x70, 0xf9, - 0x4f, 0x5d, 0x4, 0x78, 0x2a, 0x26, 0xad, 0x70, 0x50, 0xf9, 0xd1}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd5, 0x1c, 0x92, 0x69, 0xdf, 0x14, 0xe9, 0x11, 0xf, 0xd0, 0x2a, - 0x5f, 0x42, 0xc6, 0x45, 0x50, 0x6, 0x5b, 0xe2, 0xb6, 0x29, 0xff}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf7, 0x50, 0x9d, 0x1f, 0xff, 0x65, 0xfa, 0xb4}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25785, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 8081 [("\247\197\143\CANr(\SO\230",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS0}),("\183\151u\251Or\149\230`\218\133\NUL\ETX\f",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("%\232\ACKq\200;\197\192\155\162\245|\t(\206\172\a\DELe\148\253\227\200\253\187s\219\179y",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("rp\156\133\138@\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\STX\f\202\217I\195/\218#\168^\197\223\157\229|5\SOH\220\&94\241",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("BR\DLEz\176\178\218\206\141\160\252]Y\170\218\142\167\ETX\204\229=\r\255UWG",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\144\229\227)\143\168?\194\171\204\212\138\180\ETX\176\GS+\SO\254C>bp\150\184\247\144\231 ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\222CJ\178\&0\215~\186\&5\STX/\241\178\136H\207\"",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode100) { - uint8_t pkt[] = {0x82, 0xb2, 0x1, 0x35, 0xef, 0x0, 0x1a, 0x77, 0x4c, 0xbf, 0xbd, 0xdd, 0x7c, 0x47, 0xee, 0xe2, 0x24, - 0x88, 0x9, 0x49, 0x70, 0xe, 0xa, 0x2, 0xa5, 0x2c, 0x20, 0xf6, 0x4b, 0xb9, 0x55, 0xed, 0x5c, 0x0, - 0x0, 0xf, 0x54, 0x1c, 0xeb, 0x3d, 0xb, 0x3b, 0x80, 0x71, 0x98, 0x99, 0x7d, 0x22, 0x55, 0x5b, 0xb2, - 0x1, 0x0, 0x2, 0xb8, 0x96, 0x1, 0x0, 0x9, 0xbe, 0xec, 0x29, 0x5, 0x40, 0x68, 0xb8, 0xe0, 0x30, - 0x1, 0x0, 0x1c, 0x6a, 0xb2, 0x42, 0xa6, 0xac, 0x62, 0xca, 0xcb, 0x50, 0x2, 0x2c, 0x27, 0xae, 0x91, - 0xf3, 0x6f, 0x3e, 0xc5, 0xdf, 0x9d, 0xe5, 0x7c, 0x35, 0x1, 0xdc, 0x39, 0x34, 0xf1, 0x2, 0x0, 0x1a, - 0x42, 0x52, 0x10, 0x7a, 0xb0, 0xb2, 0xda, 0xce, 0x8d, 0xa0, 0xfc, 0x5d, 0x59, 0xaa, 0xda, 0x8e, 0xa7, - 0x3, 0xcc, 0xe5, 0x3d, 0xd, 0xff, 0x55, 0x57, 0x47, 0x1, 0x0, 0x1d, 0x90, 0xe5, 0xe3, 0x29, 0x8f, - 0xa8, 0x3f, 0xc2, 0xab, 0xcc, 0xd4, 0x8a, 0xb4, 0x3, 0xb0, 0x1d, 0x2b, 0xe, 0xfe, 0x43, 0x3e, 0x62, - 0x70, 0x96, 0xb8, 0xf7, 0x90, 0xe7, 0x20, 0x2, 0x0, 0x11, 0xde, 0x43, 0x4a, 0xb2, 0x30, 0xd7, 0x7e, - 0xba, 0x35, 0x2, 0x2f, 0xf1, 0xb2, 0x88, 0x48, 0xcf, 0x22, 0x1}; - - uint8_t buf[191] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x77, 0x4c, 0xbf, 0xbd, 0xdd, 0x7c, 0x47, 0xee, 0xe2, 0x24, 0x88, 0x9, 0x49, - 0x70, 0xe, 0xa, 0x2, 0xa5, 0x2c, 0x20, 0xf6, 0x4b, 0xb9, 0x55, 0xed, 0x5c}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x54, 0x1c, 0xeb, 0x3d, 0xb, 0x3b, 0x80, 0x71, - 0x98, 0x99, 0x7d, 0x22, 0x55, 0x5b, 0xb2}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb8, 0x96}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xbe, 0xec, 0x29, 0x5, 0x40, 0x68, 0xb8, 0xe0, 0x30}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x6a, 0xb2, 0x42, 0xa6, 0xac, 0x62, 0xca, 0xcb, 0x50, 0x2, 0x2c, 0x27, 0xae, 0x91, - 0xf3, 0x6f, 0x3e, 0xc5, 0xdf, 0x9d, 0xe5, 0x7c, 0x35, 0x1, 0xdc, 0x39, 0x34, 0xf1}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x42, 0x52, 0x10, 0x7a, 0xb0, 0xb2, 0xda, 0xce, 0x8d, 0xa0, 0xfc, 0x5d, 0x59, - 0xaa, 0xda, 0x8e, 0xa7, 0x3, 0xcc, 0xe5, 0x3d, 0xd, 0xff, 0x55, 0x57, 0x47}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x90, 0xe5, 0xe3, 0x29, 0x8f, 0xa8, 0x3f, 0xc2, 0xab, 0xcc, - 0xd4, 0x8a, 0xb4, 0x3, 0xb0, 0x1d, 0x2b, 0xe, 0xfe, 0x43, - 0x3e, 0x62, 0x70, 0x96, 0xb8, 0xf7, 0x90, 0xe7, 0x20}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xde, 0x43, 0x4a, 0xb2, 0x30, 0xd7, 0x7e, 0xba, 0x35, - 0x2, 0x2f, 0xf1, 0xb2, 0x88, 0x48, 0xcf, 0x22}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13807, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 31688 [("\134Q\r\137U\191\DEL\166>c<~\234\229\251\206\249tYv\161\\\154OeS",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\220\254\200+\222G\NUL\254\179r\136{N\185N\151rL\147\ETX\251\145p\202\177\129\244\220",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),(";\154\220$\161c\EM\CAN\187~\EM\131+\SYN\242\172q\CAN(\214",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\199G9%\137ER:\132\252\SUB\145)\DC1\238\243q\SI",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\151\228-h2E\145\155\RS[\a\180\192{W\249\DC2k\241\246&L\189\146\SI\227P\233(",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\188\128\150\245A\241\232\247\246K\242\221E\146@\166n\144\178VMY",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("]!b\157\132\190\207K\CAN\240\196\ENQ\CAN\224\246\SOR9CcF\242\206\r\248\GSj",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropResponseInformation -// "\141\230\237\153\196\150\138\175jF)\162\152\&39\138v\253\CAN\176\&9\164",PropContentType "\142 -// |\228q\150TQt\NAK\147",PropResponseInformation "4FN\ENQU\207\&3\137\NUL\240B[K\239\140e/\206\143W\214\229\234L\191 -// ",PropRequestResponseInformation 228,PropResponseTopic "\246\&33\DLE\183\160\165\247",PropMaximumPacketSize -// 10572,PropServerKeepAlive 5009,PropCorrelationData -// "\GS/\140\160\220\135\188\242\235j\EOT\223\aH\242\191\183\a\135\&8",PropSubscriptionIdentifierAvailable -// 113,PropMessageExpiryInterval 31499,PropAuthenticationData -// "\195\f\174r\145\DEL\a\254\194B\228\\^\234z\222\CANyXwm",PropResponseTopic "",PropReceiveMaximum -// 29806,PropTopicAliasMaximum 6132,PropReceiveMaximum 6074,PropSubscriptionIdentifier 23,PropTopicAlias -// 25692,PropReasonString "\US\250\199\&6\251q\STX\138\f`_\RSE&JIG\247\v8\242\EOT",PropContentType -// "\223Y&\254\134\151\NAK\SUB\ETX\174\223"] -TEST(Subscribe5QCTest, Encode1) { - uint8_t pkt[] = { - 0x82, 0x97, 0x3, 0x7b, 0xc8, 0xc7, 0x1, 0x1a, 0x0, 0x16, 0x8d, 0xe6, 0xed, 0x99, 0xc4, 0x96, 0x8a, 0xaf, 0x6a, - 0x46, 0x29, 0xa2, 0x98, 0x33, 0x39, 0x8a, 0x76, 0xfd, 0x18, 0xb0, 0x39, 0xa4, 0x3, 0x0, 0xb, 0x8e, 0x20, 0x7c, - 0xe4, 0x71, 0x96, 0x54, 0x51, 0x74, 0x15, 0x93, 0x1a, 0x0, 0x1a, 0x34, 0x46, 0x4e, 0x5, 0x55, 0xcf, 0x33, 0x89, - 0x0, 0xf0, 0x42, 0x5b, 0x4b, 0xef, 0x8c, 0x65, 0x2f, 0xce, 0x8f, 0x57, 0xd6, 0xe5, 0xea, 0x4c, 0xbf, 0x20, 0x19, - 0xe4, 0x8, 0x0, 0x8, 0xf6, 0x33, 0x33, 0x10, 0xb7, 0xa0, 0xa5, 0xf7, 0x27, 0x0, 0x0, 0x29, 0x4c, 0x13, 0x13, - 0x91, 0x9, 0x0, 0x14, 0x1d, 0x2f, 0x8c, 0xa0, 0xdc, 0x87, 0xbc, 0xf2, 0xeb, 0x6a, 0x4, 0xdf, 0x7, 0x48, 0xf2, - 0xbf, 0xb7, 0x7, 0x87, 0x38, 0x29, 0x71, 0x2, 0x0, 0x0, 0x7b, 0xb, 0x16, 0x0, 0x15, 0xc3, 0xc, 0xae, 0x72, - 0x91, 0x7f, 0x7, 0xfe, 0xc2, 0x42, 0xe4, 0x5c, 0x5e, 0xea, 0x7a, 0xde, 0x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, 0xf9, 0x12, 0x6b, 0xf1, 0xf6, 0x26, 0x4c, 0xbd, - 0x92, 0xf, 0xe3, 0x50, 0xe9, 0x28, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x2, 0x0, 0x16, 0xbc, 0x80, 0x96, 0xf5, - 0x41, 0xf1, 0xe8, 0xf7, 0xf6, 0x4b, 0xf2, 0xdd, 0x45, 0x92, 0x40, 0xa6, 0x6e, 0x90, 0xb2, 0x56, 0x4d, 0x59, 0x1, - 0x0, 0x1b, 0x5d, 0x21, 0x62, 0x9d, 0x84, 0xbe, 0xcf, 0x4b, 0x18, 0xf0, 0xc4, 0x5, 0x18, 0xe0, 0xf6, 0xe, 0x52, - 0x39, 0x43, 0x63, 0x46, 0xf2, 0xce, 0xd, 0xf8, 0x1d, 0x6a, 0x2}; - - uint8_t buf[420] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x86, 0x51, 0xd, 0x89, 0x55, 0xbf, 0x7f, 0xa6, 0x3e, 0x63, 0x3c, 0x7e, 0xea, - 0xe5, 0xfb, 0xce, 0xf9, 0x74, 0x59, 0x76, 0xa1, 0x5c, 0x9a, 0x4f, 0x65, 0x53}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xdc, 0xfe, 0xc8, 0x2b, 0xde, 0x47, 0x0, 0xfe, 0xb3, 0x72, - 0x88, 0x7b, 0x4e, 0xb9, 0x4e, 0x97, 0x72, 0x4c, 0x93, 0x3, - 0xfb, 0x91, 0x70, 0xca, 0xb1, 0x81, 0xf4, 0xdc}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x3b, 0x9a, 0xdc, 0x24, 0xa1, 0x63, 0x19, 0x18, 0xbb, 0x7e, - 0x19, 0x83, 0x2b, 0x16, 0xf2, 0xac, 0x71, 0x18, 0x28, 0xd6}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc7, 0x47, 0x39, 0x25, 0x89, 0x45, 0x52, 0x3a, 0x84, - 0xfc, 0x1a, 0x91, 0x29, 0x11, 0xee, 0xf3, 0x71, 0xf}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6b}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x97, 0xe4, 0x2d, 0x68, 0x32, 0x45, 0x91, 0x9b, 0x1e, 0x5b, - 0x7, 0xb4, 0xc0, 0x7b, 0x57, 0xf9, 0x12, 0x6b, 0xf1, 0xf6, - 0x26, 0x4c, 0xbd, 0x92, 0xf, 0xe3, 0x50, 0xe9, 0x28}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0}; - lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0}; - lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xbc, 0x80, 0x96, 0xf5, 0x41, 0xf1, 0xe8, 0xf7, 0xf6, 0x4b, 0xf2, - 0xdd, 0x45, 0x92, 0x40, 0xa6, 0x6e, 0x90, 0xb2, 0x56, 0x4d, 0x59}; - lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x5d, 0x21, 0x62, 0x9d, 0x84, 0xbe, 0xcf, 0x4b, 0x18, - 0xf0, 0xc4, 0x5, 0x18, 0xe0, 0xf6, 0xe, 0x52, 0x39, - 0x43, 0x63, 0x46, 0xf2, 0xce, 0xd, 0xf8, 0x1d, 0x6a}; - lwmqtt_string_t topic_filter_s10 = {27, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x8d, 0xe6, 0xed, 0x99, 0xc4, 0x96, 0x8a, 0xaf, 0x6a, 0x46, 0x29, - 0xa2, 0x98, 0x33, 0x39, 0x8a, 0x76, 0xfd, 0x18, 0xb0, 0x39, 0xa4}; - uint8_t bytesprops1[] = {0x8e, 0x20, 0x7c, 0xe4, 0x71, 0x96, 0x54, 0x51, 0x74, 0x15, 0x93}; - uint8_t bytesprops2[] = {0x34, 0x46, 0x4e, 0x5, 0x55, 0xcf, 0x33, 0x89, 0x0, 0xf0, 0x42, 0x5b, 0x4b, - 0xef, 0x8c, 0x65, 0x2f, 0xce, 0x8f, 0x57, 0xd6, 0xe5, 0xea, 0x4c, 0xbf, 0x20}; - uint8_t bytesprops3[] = {0xf6, 0x33, 0x33, 0x10, 0xb7, 0xa0, 0xa5, 0xf7}; - uint8_t bytesprops4[] = {0x1d, 0x2f, 0x8c, 0xa0, 0xdc, 0x87, 0xbc, 0xf2, 0xeb, 0x6a, - 0x4, 0xdf, 0x7, 0x48, 0xf2, 0xbf, 0xb7, 0x7, 0x87, 0x38}; - uint8_t bytesprops5[] = {0xc3, 0xc, 0xae, 0x72, 0x91, 0x7f, 0x7, 0xfe, 0xc2, 0x42, 0xe4, - 0x5c, 0x5e, 0xea, 0x7a, 0xde, 0x18, 0x79, 0x58, 0x77, 0x6d}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops7[] = {0x1f, 0xfa, 0xc7, 0x36, 0xfb, 0x71, 0x2, 0x8a, 0xc, 0x60, 0x5f, - 0x1e, 0x45, 0x26, 0x4a, 0x49, 0x47, 0xf7, 0xb, 0x38, 0xf2, 0x4}; - uint8_t bytesprops8[] = {0xdf, 0x59, 0x26, 0xfe, 0x86, 0x97, 0x15, 0x1a, 0x3, 0xae, 0xdf}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10572}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5009}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31499}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29806}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6132}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6074}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25692}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops8}}}, - }; - - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31688, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 25984 -// [("1\GS\194\RS\CAND\173\140\252\160\207\178\215*q\172o\165\DC3\n\250\129\USa\128\ETB\183\171",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\175\195N\144p\188x@x\190\233.LbP!\f{\DLEez\153\bs\DC3",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\246\&9\f\n\v\143znf!\192pb2",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Vw\169\NUL\222V\237}\DLE\240t\249",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [PropPayloadFormatIndicator 130,PropMessageExpiryInterval -// 14472,PropAuthenticationData -// "\156?\131\151\US\207_\177\246\228\153?\205\&0V\253\ETX\r\SI2\236\\\214\rV\136=z7\153",PropWildcardSubscriptionAvailable -// 90,PropMessageExpiryInterval 12708,PropReceiveMaximum 13332,PropResponseTopic -// "\222>$",PropSharedSubscriptionAvailable 122,PropSessionExpiryInterval 7520,PropAuthenticationData -// "\161\231\137_\217\166\204]\192\233\175\246P$\DEL\189\147",PropRequestResponseInformation 212,PropReasonString -// "\155A5\164+$"] -TEST(Subscribe5QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0xbc, 0x1, 0x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; - - uint8_t buf[201] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x31, 0x1d, 0xc2, 0x1e, 0x18, 0x44, 0xad, 0x8c, 0xfc, 0xa0, - 0xcf, 0xb2, 0xd7, 0x2a, 0x71, 0xac, 0x6f, 0xa5, 0x13, 0xa, - 0xfa, 0x81, 0x1f, 0x61, 0x80, 0x17, 0xb7, 0xab}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xaf, 0xc3, 0x4e, 0x90, 0x70, 0xbc, 0x78, 0x40, 0x78, 0xbe, 0xe9, 0x2e, 0x4c, - 0x62, 0x50, 0x21, 0xc, 0x7b, 0x10, 0x65, 0x7a, 0x99, 0x8, 0x73, 0x13}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf6, 0x39, 0xc, 0xa, 0xb, 0x8f, 0x7a, 0x6e, 0x66, 0x21, 0xc0, 0x70, 0x62, 0x32}; - lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x56, 0x77, 0xa9, 0x0, 0xde, 0x56, 0xed, 0x7d, 0x10, 0xf0, 0x74, 0xf9}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x9c, 0x3f, 0x83, 0x97, 0x1f, 0xcf, 0x5f, 0xb1, 0xf6, 0xe4, 0x99, 0x3f, 0xcd, 0x30, 0x56, - 0xfd, 0x3, 0xd, 0xf, 0x32, 0xec, 0x5c, 0xd6, 0xd, 0x56, 0x88, 0x3d, 0x7a, 0x37, 0x99}; - uint8_t bytesprops1[] = {0xde, 0x3e, 0x24}; - uint8_t bytesprops2[] = {0xa1, 0xe7, 0x89, 0x5f, 0xd9, 0xa6, 0xcc, 0x5d, 0xc0, - 0xe9, 0xaf, 0xf6, 0x50, 0x24, 0x7f, 0xbd, 0x93}; - uint8_t bytesprops3[] = {0x9b, 0x41, 0x35, 0xa4, 0x2b, 0x24}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14472}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12708}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13332}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7520}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops3}}}, - }; - - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25984, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 15464 -// [("\SOC\155\217\ESC\vJ\139\SOW\183\RS]\STX&\SUB\184\NUL\242J\186\165\165\204\&5\160\209\156\&9",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\248\143P2v\177\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("n\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2}),("X\159\CAN\143\245\n\206y\DC4\135\DC4i\232`",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\DLEA\227\&5x\234\US\171",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\164\177\152\ETBhD\152\251\180\"\244\239\191\241\149\227}\183\&0",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\r@\174C\FSM$\180\212'\253\157\173\SOI9\204b",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("C\226\169\230)",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\145Tu\NUL\b\ESC\227",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropTopicAliasMaximum 18730,PropSessionExpiryInterval 5052,PropSubscriptionIdentifierAvailable -// 10,PropCorrelationData "\EOT\160_\129\199h\241\244\158Di\130\128A\157*\n\199",PropMessageExpiryInterval -// 9252,PropRetainAvailable 152,PropContentType "X\170",PropMaximumQoS 200,PropAuthenticationMethod -// "\133\&0\230d\240#\198\167\152[\t\141\162\&5\f\182\174\222J\238\141\223Q\210\&9;",PropServerReference -// "\246\243'\142\140gr\158\229/\220\198\&8e\217\221\&5\195\239\164\237\200\t\189\t\n\177\FS\193\b",PropCorrelationData -// "b@M\135U=@X",PropReceiveMaximum 13606,PropPayloadFormatIndicator 76,PropReceiveMaximum 21293,PropReasonString -// "\178\ETB\135\DEL\141.p\US\146mg\v%b\210\147;_8\252\231_\191\242K\v\246*d\230",PropSubscriptionIdentifierAvailable -// 140] -TEST(Subscribe5QCTest, Encode3) { - uint8_t pkt[] = { - 0x82, 0xad, 0x2, 0x3c, 0x68, 0xa1, 0x1, 0x22, 0x49, 0x2a, 0x11, 0x0, 0x0, 0x13, 0xbc, 0x29, 0xa, 0x9, 0x0, - 0x12, 0x4, 0xa0, 0x5f, 0x81, 0xc7, 0x68, 0xf1, 0xf4, 0x9e, 0x44, 0x69, 0x82, 0x80, 0x41, 0x9d, 0x2a, 0xa, 0xc7, - 0x2, 0x0, 0x0, 0x24, 0x24, 0x25, 0x98, 0x3, 0x0, 0x2, 0x58, 0xaa, 0x24, 0xc8, 0x15, 0x0, 0x1a, 0x85, 0x30, - 0xe6, 0x64, 0xf0, 0x23, 0xc6, 0xa7, 0x98, 0x5b, 0x9, 0x8d, 0xa2, 0x35, 0xc, 0xb6, 0xae, 0xde, 0x4a, 0xee, 0x8d, - 0xdf, 0x51, 0xd2, 0x39, 0x3b, 0x1c, 0x0, 0x1e, 0xf6, 0xf3, 0x27, 0x8e, 0x8c, 0x67, 0x72, 0x9e, 0xe5, 0x2f, 0xdc, - 0xc6, 0x38, 0x65, 0xd9, 0xdd, 0x35, 0xc3, 0xef, 0xa4, 0xed, 0xc8, 0x9, 0xbd, 0x9, 0xa, 0xb1, 0x1c, 0xc1, 0x8, - 0x9, 0x0, 0x8, 0x62, 0x40, 0x4d, 0x87, 0x55, 0x3d, 0x40, 0x58, 0x21, 0x35, 0x26, 0x1, 0x4c, 0x21, 0x53, 0x2d, - 0x1f, 0x0, 0x1e, 0xb2, 0x17, 0x87, 0x7f, 0x8d, 0x2e, 0x70, 0x1f, 0x92, 0x6d, 0x67, 0xb, 0x25, 0x62, 0xd2, 0x93, - 0x3b, 0x5f, 0x38, 0xfc, 0xe7, 0x5f, 0xbf, 0xf2, 0x4b, 0xb, 0xf6, 0x2a, 0x64, 0xe6, 0x29, 0x8c, 0x0, 0x1d, 0xe, - 0x43, 0x9b, 0xd9, 0x1b, 0xb, 0x4a, 0x8b, 0xe, 0x57, 0xb7, 0x1e, 0x5d, 0x2, 0x26, 0x1a, 0xb8, 0x0, 0xf2, 0x4a, - 0xba, 0xa5, 0xa5, 0xcc, 0x35, 0xa0, 0xd1, 0x9c, 0x39, 0x0, 0x0, 0x7, 0xf8, 0x8f, 0x50, 0x32, 0x76, 0xb1, 0x32, - 0x2, 0x0, 0x2, 0x6e, 0xd2, 0x2, 0x0, 0xe, 0x58, 0x9f, 0x18, 0x8f, 0xf5, 0xa, 0xce, 0x79, 0x14, 0x87, 0x14, - 0x69, 0xe8, 0x60, 0x2, 0x0, 0x8, 0x10, 0x41, 0xe3, 0x35, 0x78, 0xea, 0x1f, 0xab, 0x0, 0x0, 0x13, 0xa4, 0xb1, - 0x98, 0x17, 0x68, 0x44, 0x98, 0xfb, 0xb4, 0x22, 0xf4, 0xef, 0xbf, 0xf1, 0x95, 0xe3, 0x7d, 0xb7, 0x30, 0x0, 0x0, - 0x12, 0xd, 0x40, 0xae, 0x43, 0x1c, 0x4d, 0x24, 0xb4, 0xd4, 0x27, 0xfd, 0x9d, 0xad, 0xe, 0x49, 0x39, 0xcc, 0x62, - 0x0, 0x0, 0x5, 0x43, 0xe2, 0xa9, 0xe6, 0x29, 0x0, 0x0, 0x7, 0x91, 0x54, 0x75, 0x0, 0x8, 0x1b, 0xe3, 0x1}; - - uint8_t buf[314] = {0}; - - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xe, 0x43, 0x9b, 0xd9, 0x1b, 0xb, 0x4a, 0x8b, 0xe, 0x57, - 0xb7, 0x1e, 0x5d, 0x2, 0x26, 0x1a, 0xb8, 0x0, 0xf2, 0x4a, - 0xba, 0xa5, 0xa5, 0xcc, 0x35, 0xa0, 0xd1, 0x9c, 0x39}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf8, 0x8f, 0x50, 0x32, 0x76, 0xb1, 0x32}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6e, 0xd2}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x58, 0x9f, 0x18, 0x8f, 0xf5, 0xa, 0xce, 0x79, 0x14, 0x87, 0x14, 0x69, 0xe8, 0x60}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x10, 0x41, 0xe3, 0x35, 0x78, 0xea, 0x1f, 0xab}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa4, 0xb1, 0x98, 0x17, 0x68, 0x44, 0x98, 0xfb, 0xb4, 0x22, - 0xf4, 0xef, 0xbf, 0xf1, 0x95, 0xe3, 0x7d, 0xb7, 0x30}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xd, 0x40, 0xae, 0x43, 0x1c, 0x4d, 0x24, 0xb4, 0xd4, - 0x27, 0xfd, 0x9d, 0xad, 0xe, 0x49, 0x39, 0xcc, 0x62}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x43, 0xe2, 0xa9, 0xe6, 0x29}; - lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x91, 0x54, 0x75, 0x0, 0x8, 0x1b, 0xe3}; - lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x4, 0xa0, 0x5f, 0x81, 0xc7, 0x68, 0xf1, 0xf4, 0x9e, - 0x44, 0x69, 0x82, 0x80, 0x41, 0x9d, 0x2a, 0xa, 0xc7}; - uint8_t bytesprops1[] = {0x58, 0xaa}; - uint8_t bytesprops2[] = {0x85, 0x30, 0xe6, 0x64, 0xf0, 0x23, 0xc6, 0xa7, 0x98, 0x5b, 0x9, 0x8d, 0xa2, - 0x35, 0xc, 0xb6, 0xae, 0xde, 0x4a, 0xee, 0x8d, 0xdf, 0x51, 0xd2, 0x39, 0x3b}; - uint8_t bytesprops3[] = {0xf6, 0xf3, 0x27, 0x8e, 0x8c, 0x67, 0x72, 0x9e, 0xe5, 0x2f, 0xdc, 0xc6, 0x38, 0x65, 0xd9, - 0xdd, 0x35, 0xc3, 0xef, 0xa4, 0xed, 0xc8, 0x9, 0xbd, 0x9, 0xa, 0xb1, 0x1c, 0xc1, 0x8}; - uint8_t bytesprops4[] = {0x62, 0x40, 0x4d, 0x87, 0x55, 0x3d, 0x40, 0x58}; - uint8_t bytesprops5[] = {0xb2, 0x17, 0x87, 0x7f, 0x8d, 0x2e, 0x70, 0x1f, 0x92, 0x6d, 0x67, 0xb, 0x25, 0x62, 0xd2, - 0x93, 0x3b, 0x5f, 0x38, 0xfc, 0xe7, 0x5f, 0xbf, 0xf2, 0x4b, 0xb, 0xf6, 0x2a, 0x64, 0xe6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18730}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5052}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9252}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13606}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21293}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 140}}, - }; - - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15464, 9, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 838 [("$-\227\252n\140N\241\225\146S\213\231(\193\150\248\177u\194",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval -// 9616,PropPayloadFormatIndicator 152,PropAssignedClientIdentifier "\237\248\176\172\135H\154s\242\197|\140 -// &\209\rQh#e\171\234",PropAssignedClientIdentifier "\t",PropAuthenticationMethod -// "\214\255_\213g\182\&5m\217\n\"",PropUserProperty "\224<\159\154\193\174\207\166" -// "BL;3R\187j\225\246mD\222\239\153\230\146\240\233\149\175\189"] -TEST(Subscribe5QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0x6e, 0x3, 0x46, 0x54, 0x2, 0x0, 0x0, 0x25, 0x90, 0x1, 0x98, 0x12, 0x0, 0x16, 0xed, - 0xf8, 0xb0, 0xac, 0x87, 0x48, 0x9a, 0x73, 0xf2, 0xc5, 0x7c, 0x8c, 0x20, 0x26, 0xd1, 0xd, 0x51, - 0x68, 0x23, 0x65, 0xab, 0xea, 0x12, 0x0, 0x1, 0x9, 0x15, 0x0, 0xb, 0xd6, 0xff, 0x5f, 0xd5, - 0x67, 0xb6, 0x35, 0x6d, 0xd9, 0xa, 0x22, 0x26, 0x0, 0x8, 0xe0, 0x3c, 0x9f, 0x9a, 0xc1, 0xae, - 0xcf, 0xa6, 0x0, 0x15, 0x42, 0x4c, 0x3b, 0x33, 0x52, 0xbb, 0x6a, 0xe1, 0xf6, 0x6d, 0x44, 0xde, - 0xef, 0x99, 0xe6, 0x92, 0xf0, 0xe9, 0x95, 0xaf, 0xbd, 0x0, 0x14, 0x24, 0x2d, 0xe3, 0xfc, 0x6e, - 0x8c, 0x4e, 0xf1, 0xe1, 0x92, 0x53, 0xd5, 0xe7, 0x28, 0xc1, 0x96, 0xf8, 0xb1, 0x75, 0xc2, 0x1}; - - uint8_t buf[122] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x24, 0x2d, 0xe3, 0xfc, 0x6e, 0x8c, 0x4e, 0xf1, 0xe1, 0x92, - 0x53, 0xd5, 0xe7, 0x28, 0xc1, 0x96, 0xf8, 0xb1, 0x75, 0xc2}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xed, 0xf8, 0xb0, 0xac, 0x87, 0x48, 0x9a, 0x73, 0xf2, 0xc5, 0x7c, - 0x8c, 0x20, 0x26, 0xd1, 0xd, 0x51, 0x68, 0x23, 0x65, 0xab, 0xea}; - uint8_t bytesprops1[] = {0x9}; - uint8_t bytesprops2[] = {0xd6, 0xff, 0x5f, 0xd5, 0x67, 0xb6, 0x35, 0x6d, 0xd9, 0xa, 0x22}; - uint8_t bytesprops4[] = {0x42, 0x4c, 0x3b, 0x33, 0x52, 0xbb, 0x6a, 0xe1, 0xf6, 0x6d, 0x44, - 0xde, 0xef, 0x99, 0xe6, 0x92, 0xf0, 0xe9, 0x95, 0xaf, 0xbd}; - uint8_t bytesprops3[] = {0xe0, 0x3c, 0x9f, 0x9a, 0xc1, 0xae, 0xcf, 0xa6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9616}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops3}, .v = {21, (char*)&bytesprops4}}}}, - }; - - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 838, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 16617 [("*\213.\SOH{\207\165\GS\FS\150\148]qq=A\239\234\252\189\STX;",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\210<\215\&2\177\181\232\211j\199\228\159~/\181X\SYN\136\205\\\253#",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\223[\223\187\180|\210;\149\229\164E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\133\253\223\167\156+\246\156\162\137\SYN\187I\v\233\SUB-\204P\169\233",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("1\b?\185o\135\176\195\173\ETB\161\156'\128M",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("6\129\247\STX\251H6",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("#`\225\150-e~\189\179c\212Qv\226U\171q\201\244\186i\219\169\234\t\175",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\NUL\136\CANO\SI\DEL\DC3\SYN\162\134\176\241\190eb\210\155",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\129>",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerReference -// "4\241{\135)\177\156\182\DC2|\186'?\161\224\&3",PropUserProperty -// "=G\147\136\ETX\169_\SOH\232\143\197\218\191\DC3d\238E\157\v7\ETXlP" -// "P~\254\155\151\194",PropSharedSubscriptionAvailable 185,PropAuthenticationData -// "\170\172\181:\178\228\255I\b\159\147\172\ETX\137'#\215a\144",PropRequestResponseInformation -// 207,PropMessageExpiryInterval 5495,PropWillDelayInterval 605,PropAssignedClientIdentifier -// "v\183\b\142\195\244\240\130\161\254\&6x\FSJ",PropMessageExpiryInterval 15712,PropServerKeepAlive -// 1894,PropTopicAliasMaximum 13651,PropAuthenticationMethod "\235T}\CAN",PropUserProperty "K\249\DC2|" -// "\237\n\158OC\182\178\242\255\238\179\248\a\253",PropResponseTopic -// "\DC4\f\160\215\192Yp;\221\172\ENQHf^\185u\207\&0\EM\203\133!\ACKs_\214q",PropSubscriptionIdentifier -// 1,PropMaximumPacketSize 25076,PropRequestProblemInformation 68] -TEST(Subscribe5QCTest, Encode5) { - uint8_t pkt[] = { - 0x82, 0xe9, 0x2, 0x40, 0xe9, 0xba, 0x1, 0x1c, 0x0, 0x10, 0x34, 0xf1, 0x7b, 0x87, 0x29, 0xb1, 0x9c, 0xb6, 0x12, - 0x7c, 0xba, 0x27, 0x3f, 0xa1, 0xe0, 0x33, 0x26, 0x0, 0x17, 0x3d, 0x47, 0x93, 0x88, 0x3, 0xa9, 0x5f, 0x1, 0xe8, - 0x8f, 0xc5, 0xda, 0xbf, 0x13, 0x64, 0xee, 0x45, 0x9d, 0xb, 0x37, 0x3, 0x6c, 0x50, 0x0, 0x6, 0x50, 0x7e, 0xfe, - 0x9b, 0x97, 0xc2, 0x2a, 0xb9, 0x16, 0x0, 0x13, 0xaa, 0xac, 0xb5, 0x3a, 0xb2, 0xe4, 0xff, 0x49, 0x8, 0x9f, 0x93, - 0xac, 0x3, 0x89, 0x27, 0x23, 0xd7, 0x61, 0x90, 0x19, 0xcf, 0x2, 0x0, 0x0, 0x15, 0x77, 0x18, 0x0, 0x0, 0x2, - 0x5d, 0x12, 0x0, 0xe, 0x76, 0xb7, 0x8, 0x8e, 0xc3, 0xf4, 0xf0, 0x82, 0xa1, 0xfe, 0x36, 0x78, 0x1c, 0x4a, 0x2, - 0x0, 0x0, 0x3d, 0x60, 0x13, 0x7, 0x66, 0x22, 0x35, 0x53, 0x15, 0x0, 0x4, 0xeb, 0x54, 0x7d, 0x18, 0x26, 0x0, - 0x4, 0x4b, 0xf9, 0x12, 0x7c, 0x0, 0xe, 0xed, 0xa, 0x9e, 0x4f, 0x43, 0xb6, 0xb2, 0xf2, 0xff, 0xee, 0xb3, 0xf8, - 0x7, 0xfd, 0x8, 0x0, 0x1b, 0x14, 0xc, 0xa0, 0xd7, 0xc0, 0x59, 0x70, 0x3b, 0xdd, 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xb0, 0xf1, 0xbe, 0x65, 0x62, 0xd2, 0x9b, 0x1, 0x0, 0x2, - 0x81, 0x3e, 0x1}; - - uint8_t buf[374] = {0}; - - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x2a, 0xd5, 0x2e, 0x1, 0x7b, 0xcf, 0xa5, 0x1d, 0x1c, 0x96, 0x94, - 0x5d, 0x71, 0x71, 0x3d, 0x41, 0xef, 0xea, 0xfc, 0xbd, 0x2, 0x3b}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd2, 0x3c, 0xd7, 0x32, 0xb1, 0xb5, 0xe8, 0xd3, 0x6a, 0xc7, 0xe4, - 0x9f, 0x7e, 0x2f, 0xb5, 0x58, 0x16, 0x88, 0xcd, 0x5c, 0xfd, 0x23}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdf, 0x5b, 0xdf, 0xbb, 0xb4, 0x7c, 0xd2, 0x3b, 0x95, 0xe5, 0xa4, 0x45}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x85, 0xfd, 0xdf, 0xa7, 0x9c, 0x2b, 0xf6, 0x9c, 0xa2, 0x89, 0x16, - 0xbb, 0x49, 0xb, 0xe9, 0x1a, 0x2d, 0xcc, 0x50, 0xa9, 0xe9}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x31, 0x8, 0x3f, 0xb9, 0x6f, 0x87, 0xb0, 0xc3, - 0xad, 0x17, 0xa1, 0x9c, 0x27, 0x80, 0x4d}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x36, 0x81, 0xf7, 0x2, 0xfb, 0x48, 0x36}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x23, 0x60, 0xe1, 0x96, 0x2d, 0x65, 0x7e, 0xbd, 0xb3, 0x63, 0xd4, 0x51, 0x76, - 0xe2, 0x55, 0xab, 0x71, 0xc9, 0xf4, 0xba, 0x69, 0xdb, 0xa9, 0xea, 0x9, 0xaf}; - lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x0, 0x88, 0x18, 0x4f, 0xf, 0x7f, 0x13, 0x16, 0xa2, - 0x86, 0xb0, 0xf1, 0xbe, 0x65, 0x62, 0xd2, 0x9b}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x81, 0x3e}; - lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x34, 0xf1, 0x7b, 0x87, 0x29, 0xb1, 0x9c, 0xb6, - 0x12, 0x7c, 0xba, 0x27, 0x3f, 0xa1, 0xe0, 0x33}; - uint8_t bytesprops2[] = {0x50, 0x7e, 0xfe, 0x9b, 0x97, 0xc2}; - uint8_t bytesprops1[] = {0x3d, 0x47, 0x93, 0x88, 0x3, 0xa9, 0x5f, 0x1, 0xe8, 0x8f, 0xc5, 0xda, - 0xbf, 0x13, 0x64, 0xee, 0x45, 0x9d, 0xb, 0x37, 0x3, 0x6c, 0x50}; - uint8_t bytesprops3[] = {0xaa, 0xac, 0xb5, 0x3a, 0xb2, 0xe4, 0xff, 0x49, 0x8, 0x9f, - 0x93, 0xac, 0x3, 0x89, 0x27, 0x23, 0xd7, 0x61, 0x90}; - uint8_t bytesprops4[] = {0x76, 0xb7, 0x8, 0x8e, 0xc3, 0xf4, 0xf0, 0x82, 0xa1, 0xfe, 0x36, 0x78, 0x1c, 0x4a}; - uint8_t bytesprops5[] = {0xeb, 0x54, 0x7d, 0x18}; - uint8_t bytesprops7[] = {0xed, 0xa, 0x9e, 0x4f, 0x43, 0xb6, 0xb2, 0xf2, 0xff, 0xee, 0xb3, 0xf8, 0x7, 0xfd}; - uint8_t bytesprops6[] = {0x4b, 0xf9, 0x12, 0x7c}; - uint8_t bytesprops8[] = {0x14, 0xc, 0xa0, 0xd7, 0xc0, 0x59, 0x70, 0x3b, 0xdd, 0xac, 0x5, 0x48, 0x66, 0x5e, - 0xb9, 0x75, 0xcf, 0x30, 0x19, 0xcb, 0x85, 0x21, 0x6, 0x73, 0x5f, 0xd6, 0x71}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5495}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 605}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15712}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1894}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13651}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops6}, .v = {14, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25076}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, - }; - - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16617, 9, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 4070 [("\v\136/\233\EOT\FS\240\255\227\DC3q9\SI\SOH\\",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\170\176\237\215\202\131\&2\ESCK\136h\184\178\226\178}.\242",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropMessageExpiryInterval -// 23503,PropSessionExpiryInterval 6089,PropMaximumPacketSize 7148,PropUserProperty "[\DC2\234\153\CAN'\ETX\152d\186" -// "\208\na\201\165\173p\232",PropAuthenticationData "\240h5\143\128\179:\131|\140Z",PropMessageExpiryInterval -// 23070,PropWillDelayInterval 1219,PropSubscriptionIdentifierAvailable 72,PropWillDelayInterval -// 20808,PropCorrelationData "U\rh\144",PropServerKeepAlive 3568,PropRequestResponseInformation -// 236,PropPayloadFormatIndicator 46,PropMessageExpiryInterval 14380,PropWildcardSubscriptionAvailable -// 95,PropAuthenticationData "\137\189l\153\160\233\ETX\237\r"] -TEST(Subscribe5QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0x90, 0x1, 0xf, 0xe6, 0x66, 0x2, 0x0, 0x0, 0x5b, 0xcf, 0x11, 0x0, 0x0, 0x17, 0xc9, 0x27, - 0x0, 0x0, 0x1b, 0xec, 0x26, 0x0, 0xa, 0x5b, 0x12, 0xea, 0x99, 0x18, 0x27, 0x3, 0x98, 0x64, 0xba, - 0x0, 0x8, 0xd0, 0xa, 0x61, 0xc9, 0xa5, 0xad, 0x70, 0xe8, 0x16, 0x0, 0xb, 0xf0, 0x68, 0x35, 0x8f, - 0x80, 0xb3, 0x3a, 0x83, 0x7c, 0x8c, 0x5a, 0x2, 0x0, 0x0, 0x5a, 0x1e, 0x18, 0x0, 0x0, 0x4, 0xc3, - 0x29, 0x48, 0x18, 0x0, 0x0, 0x51, 0x48, 0x9, 0x0, 0x4, 0x55, 0xd, 0x68, 0x90, 0x13, 0xd, 0xf0, - 0x19, 0xec, 0x1, 0x2e, 0x2, 0x0, 0x0, 0x38, 0x2c, 0x28, 0x5f, 0x16, 0x0, 0x9, 0x89, 0xbd, 0x6c, - 0x99, 0xa0, 0xe9, 0x3, 0xed, 0xd, 0x0, 0xf, 0xb, 0x88, 0x2f, 0xe9, 0x4, 0x1c, 0xf0, 0xff, 0xe3, - 0x13, 0x71, 0x39, 0xf, 0x1, 0x5c, 0x1, 0x0, 0x12, 0xaa, 0xb0, 0xed, 0xd7, 0xca, 0x83, 0x32, 0x1b, - 0x4b, 0x88, 0x68, 0xb8, 0xb2, 0xe2, 0xb2, 0x7d, 0x2e, 0xf2, 0x0}; - - uint8_t buf[157] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xb, 0x88, 0x2f, 0xe9, 0x4, 0x1c, 0xf0, 0xff, - 0xe3, 0x13, 0x71, 0x39, 0xf, 0x1, 0x5c}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xaa, 0xb0, 0xed, 0xd7, 0xca, 0x83, 0x32, 0x1b, 0x4b, - 0x88, 0x68, 0xb8, 0xb2, 0xe2, 0xb2, 0x7d, 0x2e, 0xf2}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0}; - uint8_t bytesprops1[] = {0xd0, 0xa, 0x61, 0xc9, 0xa5, 0xad, 0x70, 0xe8}; - uint8_t bytesprops0[] = {0x5b, 0x12, 0xea, 0x99, 0x18, 0x27, 0x3, 0x98, 0x64, 0xba}; - uint8_t bytesprops2[] = {0xf0, 0x68, 0x35, 0x8f, 0x80, 0xb3, 0x3a, 0x83, 0x7c, 0x8c, 0x5a}; - uint8_t bytesprops3[] = {0x55, 0xd, 0x68, 0x90}; - uint8_t bytesprops4[] = {0x89, 0xbd, 0x6c, 0x99, 0xa0, 0xe9, 0x3, 0xed, 0xd}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23503}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6089}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7148}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23070}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1219}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20808}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3568}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14380}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops4}}}, - }; - - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4070, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 1318 [("\141",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("(\232l\147\231\ETB\129\188\&6\207\SO\182\244\225\193S\228\&7\179\DEL\220",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\241\168\NUL\143\233m\184\163\STX\218\&8\156\252\250i\184C\188B\167\197\224A",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\177s\170{`\"e\RSr\DC3\r[\215\130\150\199q\253\216\221\231;\SYN",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\254*\164\NUL.\198\237\227\&3\143\SUB\248\248\162\t\167\n\146\232\250AK\234\220\178f\205\210\226",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\159}A_\221B\190\143\&5\n\NUL\186z)\143",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\r0\DC1\n\226K\201\177\128\US:\237o\241I\186d|",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Q\EM\214h\"_\196\253z\ACK\211F7\211D\144\NUL",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(")\213\149\ACK",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropContentType -// "\130\ENQm\151\150mh\225Hc\184\187\247",PropResponseTopic "S51\GS\134\178\187V@\221",PropResponseInformation -// "\204\196\n$a-\EOT\243\SYNJ\190",PropAuthenticationMethod -// "j\131\232\175\144\213p2\166\179\218\167\130\153\195\242\204J\142Ti\179pM\164",PropAuthenticationData -// "\143\NUL\253\152\190\179\v\184\n\143\&9\170\162\138\230\a\254",PropTopicAlias 25408,PropSharedSubscriptionAvailable -// 253,PropTopicAlias 9479,PropSessionExpiryInterval 28451,PropWildcardSubscriptionAvailable 200,PropResponseInformation -// "\161\165\SO\189\173\EOT\175\&4\\jwc\177\193\SYNJ\186\235\223(#v",PropSessionExpiryInterval -// 14824,PropMaximumPacketSize 4374,PropSubscriptionIdentifier 12,PropMaximumPacketSize 2638,PropMaximumQoS -// 100,PropCorrelationData "\249\&3\\\211\147",PropRequestResponseInformation 8,PropReasonString -// "#",PropWildcardSubscriptionAvailable 248,PropPayloadFormatIndicator 146,PropAuthenticationMethod -// "\218`\167",PropRequestProblemInformation 80,PropAuthenticationMethod -// "o\170\235\155\200^(\171(\SYN\216\214\b\227\163DV\211\163",PropMessageExpiryInterval 17106,PropAuthenticationData -// "v\253\DC2\198\a\EMO\188\176\213\FS\159\202\RS\b\248g\170\243\234\140\DC4\v\EOTb\242\205\135\&0\141",PropReasonString -// "\DC4\154\ENQ\239\170\178\203\153U\208\153\DLE\230\146\226$\178\NUL\"\198;9\175MY\150\211Im",PropMessageExpiryInterval -// 21474,PropReasonString "A^\155er\157"] -TEST(Subscribe5QCTest, Encode7) { - uint8_t pkt[] = { - 0x82, 0xd0, 0x3, 0x5, 0x26, 0x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0xe3, 0x33, - 0x8f, 0x1a, 0xf8, 0xf8, 0xa2, 0x9, 0xa7, 0xa, 0x92, 0xe8, 0xfa, 0x41, 0x4b, 0xea, 0xdc, 0xb2, 0x66, 0xcd, 0xd2, - 0xe2, 0x2, 0x0, 0xf, 0x9f, 0x7d, 0x41, 0x5f, 0xdd, 0x42, 0xbe, 0x8f, 0x35, 0xa, 0x0, 0xba, 0x7a, 0x29, 0x8f, - 0x0, 0x0, 0x12, 0xd, 0x30, 0x11, 0xa, 0xe2, 0x4b, 0xc9, 0xb1, 0x80, 0x1f, 0x3a, 0xed, 0x6f, 0xf1, 0x49, 0xba, - 0x64, 0x7c, 0x2, 0x0, 0x11, 0x51, 0x19, 0xd6, 0x68, 0x22, 0x5f, 0xc4, 0xfd, 0x7a, 0x6, 0xd3, 0x46, 0x37, 0xd3, - 0x44, 0x90, 0x0, 0x1, 0x0, 0x4, 0x29, 0xd5, 0x95, 0x6, 0x2}; - - uint8_t buf[477] = {0}; - - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x8d}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x28, 0xe8, 0x6c, 0x93, 0xe7, 0x17, 0x81, 0xbc, 0x36, 0xcf, 0xe, - 0xb6, 0xf4, 0xe1, 0xc1, 0x53, 0xe4, 0x37, 0xb3, 0x7f, 0xdc}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf1, 0xa8, 0x0, 0x8f, 0xe9, 0x6d, 0xb8, 0xa3, 0x2, 0xda, 0x38, 0x9c, - 0xfc, 0xfa, 0x69, 0xb8, 0x43, 0xbc, 0x42, 0xa7, 0xc5, 0xe0, 0x41}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb1, 0x73, 0xaa, 0x7b, 0x60, 0x22, 0x65, 0x1e, 0x72, 0x13, 0xd, 0x5b, - 0xd7, 0x82, 0x96, 0xc7, 0x71, 0xfd, 0xd8, 0xdd, 0xe7, 0x3b, 0x16}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xfe, 0x2a, 0xa4, 0x0, 0x2e, 0xc6, 0xed, 0xe3, 0x33, 0x8f, - 0x1a, 0xf8, 0xf8, 0xa2, 0x9, 0xa7, 0xa, 0x92, 0xe8, 0xfa, - 0x41, 0x4b, 0xea, 0xdc, 0xb2, 0x66, 0xcd, 0xd2, 0xe2}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x9f, 0x7d, 0x41, 0x5f, 0xdd, 0x42, 0xbe, 0x8f, - 0x35, 0xa, 0x0, 0xba, 0x7a, 0x29, 0x8f}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xd, 0x30, 0x11, 0xa, 0xe2, 0x4b, 0xc9, 0xb1, 0x80, - 0x1f, 0x3a, 0xed, 0x6f, 0xf1, 0x49, 0xba, 0x64, 0x7c}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x51, 0x19, 0xd6, 0x68, 0x22, 0x5f, 0xc4, 0xfd, 0x7a, - 0x6, 0xd3, 0x46, 0x37, 0xd3, 0x44, 0x90, 0x0}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x29, 0xd5, 0x95, 0x6}; - lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x82, 0x5, 0x6d, 0x97, 0x96, 0x6d, 0x68, 0xe1, 0x48, 0x63, 0xb8, 0xbb, 0xf7}; - uint8_t bytesprops1[] = {0x53, 0x35, 0x31, 0x1d, 0x86, 0xb2, 0xbb, 0x56, 0x40, 0xdd}; - uint8_t bytesprops2[] = {0xcc, 0xc4, 0xa, 0x24, 0x61, 0x2d, 0x4, 0xf3, 0x16, 0x4a, 0xbe}; - uint8_t bytesprops3[] = {0x6a, 0x83, 0xe8, 0xaf, 0x90, 0xd5, 0x70, 0x32, 0xa6, 0xb3, 0xda, 0xa7, 0x82, - 0x99, 0xc3, 0xf2, 0xcc, 0x4a, 0x8e, 0x54, 0x69, 0xb3, 0x70, 0x4d, 0xa4}; - uint8_t bytesprops4[] = {0x8f, 0x0, 0xfd, 0x98, 0xbe, 0xb3, 0xb, 0xb8, 0xa, - 0x8f, 0x39, 0xaa, 0xa2, 0x8a, 0xe6, 0x7, 0xfe}; - uint8_t bytesprops5[] = {0xa1, 0xa5, 0xe, 0xbd, 0xad, 0x4, 0xaf, 0x34, 0x5c, 0x6a, 0x77, - 0x63, 0xb1, 0xc1, 0x16, 0x4a, 0xba, 0xeb, 0xdf, 0x28, 0x23, 0x76}; - uint8_t bytesprops6[] = {0xf9, 0x33, 0x5c, 0xd3, 0x93}; - uint8_t bytesprops7[] = {0x23}; - uint8_t bytesprops8[] = {0xda, 0x60, 0xa7}; - uint8_t bytesprops9[] = {0x6f, 0xaa, 0xeb, 0x9b, 0xc8, 0x5e, 0x28, 0xab, 0x28, 0x16, - 0xd8, 0xd6, 0x8, 0xe3, 0xa3, 0x44, 0x56, 0xd3, 0xa3}; - uint8_t bytesprops10[] = {0x76, 0xfd, 0x12, 0xc6, 0x7, 0x19, 0x4f, 0xbc, 0xb0, 0xd5, 0x1c, 0x9f, 0xca, 0x1e, 0x8, - 0xf8, 0x67, 0xaa, 0xf3, 0xea, 0x8c, 0x14, 0xb, 0x4, 0x62, 0xf2, 0xcd, 0x87, 0x30, 0x8d}; - uint8_t bytesprops11[] = {0x14, 0x9a, 0x5, 0xef, 0xaa, 0xb2, 0xcb, 0x99, 0x55, 0xd0, 0x99, 0x10, 0xe6, 0x92, 0xe2, - 0x24, 0xb2, 0x0, 0x22, 0xc6, 0x3b, 0x39, 0xaf, 0x4d, 0x59, 0x96, 0xd3, 0x49, 0x6d}; - uint8_t bytesprops12[] = {0x41, 0x5e, 0x9b, 0x65, 0x72, 0x9d}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25408}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9479}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28451}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14824}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4374}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2638}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17106}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21474}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops12}}}, - }; - - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1318, 9, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 4255 -// [("\180\179\158\152\140\184\134\243\150\253\DELV\188\SIa\US\207\DEL\234C\tl\186p*M\209\246\162",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("/\140^\ESC#\181^Ia%o\229mJ\166XA\DELA\183l;S_l\133^",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\159\&8\162\SYN\188\181",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\253\&9-\SOH\n\189\207\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1})] [PropServerKeepAlive 10210,PropServerReference "",PropAuthenticationMethod -// "\210A\184>i:\DC3X\235\203\ESC\ESC]\SO\254\a\249\137\150\195[\176\136D\161\254u~",PropServerReference -// "\234\166'\198\222\235\EM\232\216\167\174\156\&4\182b7\r2\ETB\\\231JPj\DC4\ACK\194K",PropResponseTopic -// "\131L\NAK\157\240)\SI\FS\241\234\184\146m",PropSharedSubscriptionAvailable 213,PropRequestResponseInformation -// 75,PropAuthenticationMethod "\USjH\219\193\175",PropReceiveMaximum 4502,PropSubscriptionIdentifier 20,PropTopicAlias -// 4861,PropCorrelationData "\226=\243Q\226\154\204/`0",PropResponseInformation "<\195u",PropSharedSubscriptionAvailable -// 229,PropSubscriptionIdentifierAvailable 37,PropSubscriptionIdentifierAvailable 148,PropAuthenticationMethod -// "\145r.\DC4\164\219\&4\133\170\150\NUL",PropSessionExpiryInterval 1927,PropTopicAliasMaximum 12840,PropResponseTopic -// "\251$4\141ye\202\216",PropReceiveMaximum 29338,PropSubscriptionIdentifierAvailable 0,PropSessionExpiryInterval -// 9070,PropRetainAvailable 159,PropCorrelationData "\US\251\187R{\203\133B\146\206"] -TEST(Subscribe5QCTest, Encode8) { - uint8_t pkt[] = { - 0x82, 0x92, 0x2, 0x10, 0x9f, 0xbc, 0x1, 0x13, 0x27, 0xe2, 0x1c, 0x0, 0x0, 0x15, 0x0, 0x1c, 0xd2, 0x41, 0xb8, - 0x3e, 0x69, 0x3a, 0x13, 0x58, 0xeb, 0xcb, 0x1b, 0x1b, 0x5d, 0xe, 0xfe, 0x7, 0xf9, 0x89, 0x96, 0xc3, 0x5b, 0xb0, - 0x88, 0x44, 0xa1, 0xfe, 0x75, 0x7e, 0x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0x5e, 0x1b, 0x23, 0xb5, 0x5e, 0x49, 0x61, 0x25, 0x6f, 0xe5, 0x6d, 0x4a, 0xa6, 0x58, 0x41, 0x7f, - 0x41, 0xb7, 0x6c, 0x3b, 0x53, 0x5f, 0x6c, 0x85, 0x5e, 0x0, 0x0, 0x6, 0x9f, 0x38, 0xa2, 0x16, 0xbc, 0xb5, 0x1, - 0x0, 0x8, 0xfd, 0x39, 0x2d, 0x1, 0xa, 0xbd, 0xcf, 0xdb, 0x1}; - - uint8_t buf[287] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xb4, 0xb3, 0x9e, 0x98, 0x8c, 0xb8, 0x86, 0xf3, 0x96, 0xfd, - 0x7f, 0x56, 0xbc, 0xf, 0x61, 0x1f, 0xcf, 0x7f, 0xea, 0x43, - 0x9, 0x6c, 0xba, 0x70, 0x2a, 0x4d, 0xd1, 0xf6, 0xa2}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2f, 0x8c, 0x5e, 0x1b, 0x23, 0xb5, 0x5e, 0x49, 0x61, 0x25, 0x6f, 0xe5, 0x6d, 0x4a, - 0xa6, 0x58, 0x41, 0x7f, 0x41, 0xb7, 0x6c, 0x3b, 0x53, 0x5f, 0x6c, 0x85, 0x5e}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9f, 0x38, 0xa2, 0x16, 0xbc, 0xb5}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfd, 0x39, 0x2d, 0x1, 0xa, 0xbd, 0xcf, 0xdb}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xd2, 0x41, 0xb8, 0x3e, 0x69, 0x3a, 0x13, 0x58, 0xeb, 0xcb, 0x1b, 0x1b, 0x5d, 0xe, - 0xfe, 0x7, 0xf9, 0x89, 0x96, 0xc3, 0x5b, 0xb0, 0x88, 0x44, 0xa1, 0xfe, 0x75, 0x7e}; - uint8_t bytesprops2[] = {0xea, 0xa6, 0x27, 0xc6, 0xde, 0xeb, 0x19, 0xe8, 0xd8, 0xa7, 0xae, 0x9c, 0x34, 0xb6, - 0x62, 0x37, 0xd, 0x32, 0x17, 0x5c, 0xe7, 0x4a, 0x50, 0x6a, 0x14, 0x6, 0xc2, 0x4b}; - uint8_t bytesprops3[] = {0x83, 0x4c, 0x15, 0x9d, 0xf0, 0x29, 0xf, 0x1c, 0xf1, 0xea, 0xb8, 0x92, 0x6d}; - uint8_t bytesprops4[] = {0x1f, 0x6a, 0x48, 0xdb, 0xc1, 0xaf}; - uint8_t bytesprops5[] = {0xe2, 0x3d, 0xf3, 0x51, 0xe2, 0x9a, 0xcc, 0x2f, 0x60, 0x30}; - uint8_t bytesprops6[] = {0x3c, 0xc3, 0x75}; - uint8_t bytesprops7[] = {0x91, 0x72, 0x2e, 0x14, 0xa4, 0xdb, 0x34, 0x85, 0xaa, 0x96, 0x0}; - uint8_t bytesprops8[] = {0xfb, 0x24, 0x34, 0x8d, 0x79, 0x65, 0xca, 0xd8}; - uint8_t bytesprops9[] = {0x1f, 0xfb, 0xbb, 0x52, 0x7b, 0xcb, 0x85, 0x42, 0x92, 0xce}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10210}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4502}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4861}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1927}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12840}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29338}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9070}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops9}}}, - }; - - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4255, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 8790 [("BZ_)",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\244x\187\186\255\245oy\163<\181\242J3\202-",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("'8\171[\231\210\133\201\GSP\238\199\163'\182bO@\226\RS?\SO@\244uRA\SI2",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("W\239\192\&2\217\184?\141\&7\FSL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\200h\214",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\187\DC2\tI\174\251I\ETB\FS\NAK\148\DC4\136Je\193|\216V)j",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropResponseTopic "\"k\179G\190w1\150\208\185\FS\155S\250i\146\220\EMR",PropAuthenticationMethod -// "w\199\142\212\ACK$\129l\156\143\206\245\134r\144o\176\204\228\169",PropReceiveMaximum -// 28238,PropPayloadFormatIndicator 218,PropAuthenticationMethod "\172\160\143\182\169q\221",PropTopicAlias -// 7951,PropServerReference -// "\168\160*\DC3\152=L|\151\136A\f\ESCz\153NKJ!\133W\178H\241\167\174",PropSubscriptionIdentifierAvailable -// 83,PropCorrelationData "",PropWildcardSubscriptionAvailable 184,PropWillDelayInterval -// 30166,PropPayloadFormatIndicator 91,PropAssignedClientIdentifier -// "\162@\168\DC3\137#\DC1\136`I\183",PropWildcardSubscriptionAvailable 60,PropResponseInformation -// "`<\231\128f\183i\149bUp\EMt\\ \147W\222\220\234\aYq>\217\192\159\161",PropReceiveMaximum -// 8969,PropRequestProblemInformation 202,PropUserProperty "\r\128\DLE\254ts\\3\US\CAN\197\196\241\200" -// "l\RS\145\143,\147\224\245\ESCT\CAN\174\DC2k7\r\SOH\146\247\173\DC3\221-",PropCorrelationData -// "\r\DC3\233\240s\DC2\227\ETBf\RS\142\"\189\161\173\226\&1T\173\199\138\171\243\217\179\213\206",PropUserProperty -// "\192-\SI9\243t\224\&7\130\156{\222\144\179\247\199JZT\176" "\149",PropTopicAlias 26691,PropAssignedClientIdentifier -// "\218u\205H9pV%\142\163M\NUL\233\129\184\139*\138jk!\ESC\192a",PropWillDelayInterval 24054,PropWillDelayInterval -// 8523,PropAuthenticationData "\145\GS\RS\238\DC4\228t\243\225\217\v\f",PropAuthenticationData -// "?\239\197\219mF[\215.\228\236\158\250\NAKT~\SOH&\235\159\DC3"] -TEST(Subscribe5QCTest, Encode9) { - uint8_t pkt[] = { - 0x82, 0xb9, 0x3, 0x22, 0x56, 0xcf, 0x2, 0x8, 0x0, 0x13, 0x22, 0x6b, 0xb3, 0x47, 0xbe, 0x77, 0x31, 0x96, 0xd0, - 0xb9, 0x1c, 0x9b, 0x53, 0xfa, 0x69, 0x92, 0xdc, 0x19, 0x52, 0x15, 0x0, 0x14, 0x77, 0xc7, 0x8e, 0xd4, 0x6, 0x24, - 0x81, 0x6c, 0x9c, 0x8f, 0xce, 0xf5, 0x86, 0x72, 0x90, 0x6f, 0xb0, 0xcc, 0xe4, 0xa9, 0x21, 0x6e, 0x4e, 0x1, 0xda, - 0x15, 0x0, 0x7, 0xac, 0xa0, 0x8f, 0xb6, 0xa9, 0x71, 0xdd, 0x23, 0x1f, 0xf, 0x1c, 0x0, 0x1a, 0xa8, 0xa0, 0x2a, - 0x13, 0x98, 0x3d, 0x4c, 0x7c, 0x97, 0x88, 0x41, 0xc, 0x1b, 0x7a, 0x99, 0x4e, 0x4b, 0x4a, 0x21, 0x85, 0x57, 0xb2, - 0x48, 0xf1, 0xa7, 0xae, 0x29, 0x53, 0x9, 0x0, 0x0, 0x28, 0xb8, 0x18, 0x0, 0x0, 0x75, 0xd6, 0x1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0x0, 0x0, 0x21, 0x4b, 0x16, - 0x0, 0xc, 0x91, 0x1d, 0x1e, 0xee, 0x14, 0xe4, 0x74, 0xf3, 0xe1, 0xd9, 0xb, 0xc, 0x16, 0x0, 0x15, 0x3f, 0xef, - 0xc5, 0xdb, 0x6d, 0x46, 0x5b, 0xd7, 0x2e, 0xe4, 0xec, 0x9e, 0xfa, 0x15, 0x54, 0x7e, 0x1, 0x26, 0xeb, 0x9f, 0x13, - 0x0, 0x4, 0x42, 0x5a, 0x5f, 0x29, 0x0, 0x0, 0x10, 0xf4, 0x78, 0xbb, 0xba, 0xff, 0xf5, 0x6f, 0x79, 0xa3, 0x3c, - 0xb5, 0xf2, 0x4a, 0x33, 0xca, 0x2d, 0x0, 0x0, 0x1d, 0x27, 0x38, 0xab, 0x5b, 0xe7, 0xd2, 0x85, 0xc9, 0x1d, 0x50, - 0xee, 0xc7, 0xa3, 0x27, 0xb6, 0x62, 0x4f, 0x40, 0xe2, 0x1e, 0x3f, 0xe, 0x40, 0xf4, 0x75, 0x52, 0x41, 0xf, 0x32, - 0x2, 0x0, 0xb, 0x57, 0xef, 0xc0, 0x32, 0xd9, 0xb8, 0x3f, 0x8d, 0x37, 0x1c, 0x4c, 0x2, 0x0, 0x3, 0xc8, 0x68, - 0xd6, 0x0, 0x0, 0x15, 0xbb, 0x12, 0x9, 0x49, 0xae, 0xfb, 0x49, 0x17, 0x1c, 0x15, 0x94, 0x14, 0x88, 0x4a, 0x65, - 0xc1, 0x7c, 0xd8, 0x56, 0x29, 0x6a, 0x0}; - - uint8_t buf[454] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x42, 0x5a, 0x5f, 0x29}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf4, 0x78, 0xbb, 0xba, 0xff, 0xf5, 0x6f, 0x79, - 0xa3, 0x3c, 0xb5, 0xf2, 0x4a, 0x33, 0xca, 0x2d}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x27, 0x38, 0xab, 0x5b, 0xe7, 0xd2, 0x85, 0xc9, 0x1d, 0x50, - 0xee, 0xc7, 0xa3, 0x27, 0xb6, 0x62, 0x4f, 0x40, 0xe2, 0x1e, - 0x3f, 0xe, 0x40, 0xf4, 0x75, 0x52, 0x41, 0xf, 0x32}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x57, 0xef, 0xc0, 0x32, 0xd9, 0xb8, 0x3f, 0x8d, 0x37, 0x1c, 0x4c}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc8, 0x68, 0xd6}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xbb, 0x12, 0x9, 0x49, 0xae, 0xfb, 0x49, 0x17, 0x1c, 0x15, 0x94, - 0x14, 0x88, 0x4a, 0x65, 0xc1, 0x7c, 0xd8, 0x56, 0x29, 0x6a}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x22, 0x6b, 0xb3, 0x47, 0xbe, 0x77, 0x31, 0x96, 0xd0, 0xb9, - 0x1c, 0x9b, 0x53, 0xfa, 0x69, 0x92, 0xdc, 0x19, 0x52}; - uint8_t bytesprops1[] = {0x77, 0xc7, 0x8e, 0xd4, 0x6, 0x24, 0x81, 0x6c, 0x9c, 0x8f, - 0xce, 0xf5, 0x86, 0x72, 0x90, 0x6f, 0xb0, 0xcc, 0xe4, 0xa9}; - uint8_t bytesprops2[] = {0xac, 0xa0, 0x8f, 0xb6, 0xa9, 0x71, 0xdd}; - uint8_t bytesprops3[] = {0xa8, 0xa0, 0x2a, 0x13, 0x98, 0x3d, 0x4c, 0x7c, 0x97, 0x88, 0x41, 0xc, 0x1b, - 0x7a, 0x99, 0x4e, 0x4b, 0x4a, 0x21, 0x85, 0x57, 0xb2, 0x48, 0xf1, 0xa7, 0xae}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0xa2, 0x40, 0xa8, 0x13, 0x89, 0x23, 0x11, 0x88, 0x60, 0x49, 0xb7}; - uint8_t bytesprops6[] = {0x60, 0x3c, 0xe7, 0x80, 0x66, 0xb7, 0x69, 0x95, 0x62, 0x55, 0x70, 0x19, 0x74, 0x5c, - 0x20, 0x93, 0x57, 0xde, 0xdc, 0xea, 0x7, 0x59, 0x71, 0x3e, 0xd9, 0xc0, 0x9f, 0xa1}; - uint8_t bytesprops8[] = {0x6c, 0x1e, 0x91, 0x8f, 0x2c, 0x93, 0xe0, 0xf5, 0x1b, 0x54, 0x18, 0xae, - 0x12, 0x6b, 0x37, 0xd, 0x1, 0x92, 0xf7, 0xad, 0x13, 0xdd, 0x2d}; - uint8_t bytesprops7[] = {0xd, 0x80, 0x10, 0xfe, 0x74, 0x73, 0x5c, 0x33, 0x1f, 0x18, 0xc5, 0xc4, 0xf1, 0xc8}; - uint8_t bytesprops9[] = {0xd, 0x13, 0xe9, 0xf0, 0x73, 0x12, 0xe3, 0x17, 0x66, 0x1e, 0x8e, 0x22, 0xbd, 0xa1, - 0xad, 0xe2, 0x31, 0x54, 0xad, 0xc7, 0x8a, 0xab, 0xf3, 0xd9, 0xb3, 0xd5, 0xce}; - uint8_t bytesprops11[] = {0x95}; - uint8_t bytesprops10[] = {0xc0, 0x2d, 0xf, 0x39, 0xf3, 0x74, 0xe0, 0x37, 0x82, 0x9c, - 0x7b, 0xde, 0x90, 0xb3, 0xf7, 0xc7, 0x4a, 0x5a, 0x54, 0xb0}; - uint8_t bytesprops12[] = {0xda, 0x75, 0xcd, 0x48, 0x39, 0x70, 0x56, 0x25, 0x8e, 0xa3, 0x4d, 0x0, - 0xe9, 0x81, 0xb8, 0x8b, 0x2a, 0x8a, 0x6a, 0x6b, 0x21, 0x1b, 0xc0, 0x61}; - uint8_t bytesprops13[] = {0x91, 0x1d, 0x1e, 0xee, 0x14, 0xe4, 0x74, 0xf3, 0xe1, 0xd9, 0xb, 0xc}; - uint8_t bytesprops14[] = {0x3f, 0xef, 0xc5, 0xdb, 0x6d, 0x46, 0x5b, 0xd7, 0x2e, 0xe4, 0xec, - 0x9e, 0xfa, 0x15, 0x54, 0x7e, 0x1, 0x26, 0xeb, 0x9f, 0x13}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28238}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7951}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30166}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8969}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops7}, .v = {23, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops10}, .v = {1, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26691}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24054}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8523}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops14}}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8790, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 28419 [("\172\146\187b\165\234\194\249&",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("&\154ju i",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\196\DC4\v\a\177\139Fn\195",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("m\205\237M\200/\184hq79.3\134,\188\154\r\211\201\143\CAN\223\SYN -// \200v\164<",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ENQ\241`\255\207+~",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1})] [PropReasonString "G\DLE#\178\SUB\\W\139\169\&3\ENQl\EOT\206\193\201\181yl",PropMaximumQoS -// 233,PropWillDelayInterval 7767,PropSubscriptionIdentifier 19,PropMaximumQoS 119,PropWillDelayInterval -// 5694,PropWillDelayInterval 9243,PropAssignedClientIdentifier -// "l\183\"\142Ss\NAKwH#\210\254\211\132\210\229\143\198\190\246\241\229",PropRetainAvailable 16,PropUserProperty -// "\155pJ\\'M/@\EOT\NUL\207\216\DC1.\214\&0" "<)X\219'T{\"_#\206",PropTopicAliasMaximum 8705,PropMaximumPacketSize -// 18115,PropRequestResponseInformation 36,PropCorrelationData "Q\n\n\229\&6\193\169\140X^\191y",PropMaximumPacketSize -// 10019,PropRequestResponseInformation 189,PropServerKeepAlive 28101,PropTopicAliasMaximum 32452] -TEST(Subscribe5QCTest, Encode10) { - uint8_t pkt[] = { - 0x82, 0xdb, 0x1, 0x6f, 0x3, 0x8c, 0x1, 0x1f, 0x0, 0x13, 0x47, 0x10, 0x23, 0xb2, 0x1a, 0x5c, 0x57, 0x8b, 0xa9, - 0x33, 0x5, 0x6c, 0x4, 0xce, 0xc1, 0xc9, 0xb5, 0x79, 0x6c, 0x24, 0xe9, 0x18, 0x0, 0x0, 0x1e, 0x57, 0xb, 0x13, - 0x24, 0x77, 0x18, 0x0, 0x0, 0x16, 0x3e, 0x18, 0x0, 0x0, 0x24, 0x1b, 0x12, 0x0, 0x16, 0x6c, 0xb7, 0x22, 0x8e, - 0x53, 0x73, 0x15, 0x77, 0x48, 0x23, 0xd2, 0xfe, 0xd3, 0x84, 0xd2, 0xe5, 0x8f, 0xc6, 0xbe, 0xf6, 0xf1, 0xe5, 0x25, - 0x10, 0x26, 0x0, 0x10, 0x9b, 0x70, 0x4a, 0x5c, 0x27, 0x4d, 0x2f, 0x40, 0x4, 0x0, 0xcf, 0xd8, 0x11, 0x2e, 0xd6, - 0x30, 0x0, 0xb, 0x3c, 0x29, 0x58, 0xdb, 0x27, 0x54, 0x7b, 0x22, 0x5f, 0x23, 0xce, 0x22, 0x22, 0x1, 0x27, 0x0, - 0x0, 0x46, 0xc3, 0x19, 0x24, 0x9, 0x0, 0xc, 0x51, 0xa, 0xa, 0xe5, 0x36, 0xc1, 0xa9, 0x8c, 0x58, 0x5e, 0xbf, - 0x79, 0x27, 0x0, 0x0, 0x27, 0x23, 0x19, 0xbd, 0x13, 0x6d, 0xc5, 0x22, 0x7e, 0xc4, 0x0, 0x9, 0xac, 0x92, 0xbb, - 0x62, 0xa5, 0xea, 0xc2, 0xf9, 0x26, 0x0, 0x0, 0x6, 0x26, 0x9a, 0x6a, 0x75, 0x20, 0x69, 0x1, 0x0, 0x9, 0xc4, - 0x14, 0xb, 0x7, 0xb1, 0x8b, 0x46, 0x6e, 0xc3, 0x1, 0x0, 0x1d, 0x6d, 0xcd, 0xed, 0x4d, 0xc8, 0x2f, 0xb8, 0x68, - 0x71, 0x37, 0x39, 0x2e, 0x33, 0x86, 0x2c, 0xbc, 0x9a, 0xd, 0xd3, 0xc9, 0x8f, 0x18, 0xdf, 0x16, 0x20, 0xc8, 0x76, - 0xa4, 0x3c, 0x1, 0x0, 0x7, 0x5, 0xf1, 0x60, 0xff, 0xcf, 0x2b, 0x7e, 0x1}; - - uint8_t buf[232] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xac, 0x92, 0xbb, 0x62, 0xa5, 0xea, 0xc2, 0xf9, 0x26}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x26, 0x9a, 0x6a, 0x75, 0x20, 0x69}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc4, 0x14, 0xb, 0x7, 0xb1, 0x8b, 0x46, 0x6e, 0xc3}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6d, 0xcd, 0xed, 0x4d, 0xc8, 0x2f, 0xb8, 0x68, 0x71, 0x37, - 0x39, 0x2e, 0x33, 0x86, 0x2c, 0xbc, 0x9a, 0xd, 0xd3, 0xc9, - 0x8f, 0x18, 0xdf, 0x16, 0x20, 0xc8, 0x76, 0xa4, 0x3c}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5, 0xf1, 0x60, 0xff, 0xcf, 0x2b, 0x7e}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x47, 0x10, 0x23, 0xb2, 0x1a, 0x5c, 0x57, 0x8b, 0xa9, 0x33, - 0x5, 0x6c, 0x4, 0xce, 0xc1, 0xc9, 0xb5, 0x79, 0x6c}; - uint8_t bytesprops1[] = {0x6c, 0xb7, 0x22, 0x8e, 0x53, 0x73, 0x15, 0x77, 0x48, 0x23, 0xd2, - 0xfe, 0xd3, 0x84, 0xd2, 0xe5, 0x8f, 0xc6, 0xbe, 0xf6, 0xf1, 0xe5}; - uint8_t bytesprops3[] = {0x3c, 0x29, 0x58, 0xdb, 0x27, 0x54, 0x7b, 0x22, 0x5f, 0x23, 0xce}; - uint8_t bytesprops2[] = {0x9b, 0x70, 0x4a, 0x5c, 0x27, 0x4d, 0x2f, 0x40, - 0x4, 0x0, 0xcf, 0xd8, 0x11, 0x2e, 0xd6, 0x30}; - uint8_t bytesprops4[] = {0x51, 0xa, 0xa, 0xe5, 0x36, 0xc1, 0xa9, 0x8c, 0x58, 0x5e, 0xbf, 0x79}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7767}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5694}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9243}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8705}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18115}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10019}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28101}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32452}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28419, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 5081 [("Zq\ETB\209",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),("\254\248\251$\238\158f\176\218\152\154A\147\STX^\184'w\188\&2{\US\165I\vF\139",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\164\143V*3\253\171\214\141x.\184\242l\217\&2\255\ENQ",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\171E\173\162L\158>9\a\202\138\223Jb{\170Y8\RS\137\226\166I\177J",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\185\188",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropTopicAlias -// 10841,PropContentType "c\166;3\224\143\205\145s/~\212\185K",PropReasonString -// "\182m\218-L\210\146\166\GS|\DC1\165)8\238\192\172g\184\137\167z\168\248\211U",PropServerReference -// "\133\129\239\146",PropRequestResponseInformation 196,PropCorrelationData -// ",kk\NUL\234\211\CAN\159Y\185\&5\164R\162",PropRetainAvailable 165,PropResponseTopic -// "\179\215\177\DEL\r\249\170\tI\253b@\184\195\246\143\193\194<`\EM8r\ENQ\160",PropSharedSubscriptionAvailable -// 69,PropSharedSubscriptionAvailable 119,PropRequestResponseInformation 58,PropMessageExpiryInterval -// 12503,PropReasonString "\133\131\212\&7\153\246\&0",PropContentType -// "\167E'Z\209*\144\ETXC",PropPayloadFormatIndicator 38,PropContentType -// "\145^\201(0\SYN\174\188\198A\SUBfl,\139\&2_\230\233NRy\205\255\249b\160\155\176",PropTopicAlias -// 1094,PropRequestResponseInformation 213,PropReasonString "vwj%+ -// \140\150\NAK\231\248\187+\130\210\&2j\NAK\168\b\189y",PropWildcardSubscriptionAvailable 155,PropMessageExpiryInterval -// 31491] -TEST(Subscribe5QCTest, Encode11) { - uint8_t pkt[] = { - 0x82, 0xb3, 0x2, 0x13, 0xd9, 0xd1, 0x1, 0x23, 0x2a, 0x59, 0x3, 0x0, 0xe, 0x63, 0xa6, 0x3b, 0x33, 0xe0, 0x8f, - 0xcd, 0x91, 0x73, 0x2f, 0x7e, 0xd4, 0xb9, 0x4b, 0x1f, 0x0, 0x1a, 0xb6, 0x6d, 0xda, 0x2d, 0x4c, 0xd2, 0x92, 0xa6, - 0x1d, 0x7c, 0x11, 0xa5, 0x29, 0x38, 0xee, 0xc0, 0xac, 0x67, 0xb8, 0x89, 0xa7, 0x7a, 0xa8, 0xf8, 0xd3, 0x55, 0x1c, - 0x0, 0x4, 0x85, 0x81, 0xef, 0x92, 0x19, 0xc4, 0x9, 0x0, 0xe, 0x2c, 0x6b, 0x6b, 0x0, 0xea, 0xd3, 0x18, 0x9f, - 0x59, 0xb9, 0x35, 0xa4, 0x52, 0xa2, 0x25, 0xa5, 0x8, 0x0, 0x19, 0xb3, 0xd7, 0xb1, 0x7f, 0xd, 0xf9, 0xaa, 0x9, - 0x49, 0xfd, 0x62, 0x40, 0xb8, 0xc3, 0xf6, 0x8f, 0xc1, 0xc2, 0x3c, 0x60, 0x19, 0x38, 0x72, 0x5, 0xa0, 0x2a, 0x45, - 0x2a, 0x77, 0x19, 0x3a, 0x2, 0x0, 0x0, 0x30, 0xd7, 0x1f, 0x0, 0x7, 0x85, 0x83, 0xd4, 0x37, 0x99, 0xf6, 0x30, - 0x3, 0x0, 0x9, 0xa7, 0x45, 0x27, 0x5a, 0xd1, 0x2a, 0x90, 0x3, 0x43, 0x1, 0x26, 0x3, 0x0, 0x1d, 0x91, 0x5e, - 0xc9, 0x28, 0x30, 0x16, 0xae, 0xbc, 0xc6, 0x41, 0x1a, 0x66, 0x6c, 0x2c, 0x8b, 0x32, 0x5f, 0xe6, 0xe9, 0x4e, 0x52, - 0x79, 0xcd, 0xff, 0xf9, 0x62, 0xa0, 0x9b, 0xb0, 0x23, 0x4, 0x46, 0x19, 0xd5, 0x1f, 0x0, 0x16, 0x76, 0x77, 0x6a, - 0x25, 0x2b, 0x20, 0x8c, 0x96, 0x15, 0xe7, 0xf8, 0xbb, 0x2b, 0x82, 0xd2, 0x32, 0x6a, 0x15, 0xa8, 0x8, 0xbd, 0x79, - 0x28, 0x9b, 0x2, 0x0, 0x0, 0x7b, 0x3, 0x0, 0x4, 0x5a, 0x71, 0x17, 0xd1, 0x0, 0x0, 0x1b, 0xfe, 0xf8, 0xfb, - 0x24, 0xee, 0x9e, 0x66, 0xb0, 0xda, 0x98, 0x9a, 0x41, 0x93, 0x2, 0x5e, 0xb8, 0x27, 0x77, 0xbc, 0x32, 0x7b, 0x1f, - 0xa5, 0x49, 0xb, 0x46, 0x8b, 0x1, 0x0, 0x12, 0xa4, 0x8f, 0x56, 0x2a, 0x33, 0xfd, 0xab, 0xd6, 0x8d, 0x78, 0x2e, - 0xb8, 0xf2, 0x6c, 0xd9, 0x32, 0xff, 0x5, 0x1, 0x0, 0x19, 0xab, 0x45, 0xad, 0xa2, 0x4c, 0x9e, 0x3e, 0x39, 0x7, - 0xca, 0x8a, 0xdf, 0x4a, 0x62, 0x7b, 0xaa, 0x59, 0x38, 0x1e, 0x89, 0xe2, 0xa6, 0x49, 0xb1, 0x4a, 0x2, 0x0, 0x2, - 0xb9, 0xbc, 0x2, 0x0, 0x0, 0x1}; - - uint8_t buf[320] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x5a, 0x71, 0x17, 0xd1}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfe, 0xf8, 0xfb, 0x24, 0xee, 0x9e, 0x66, 0xb0, 0xda, 0x98, 0x9a, 0x41, 0x93, 0x2, - 0x5e, 0xb8, 0x27, 0x77, 0xbc, 0x32, 0x7b, 0x1f, 0xa5, 0x49, 0xb, 0x46, 0x8b}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa4, 0x8f, 0x56, 0x2a, 0x33, 0xfd, 0xab, 0xd6, 0x8d, - 0x78, 0x2e, 0xb8, 0xf2, 0x6c, 0xd9, 0x32, 0xff, 0x5}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xab, 0x45, 0xad, 0xa2, 0x4c, 0x9e, 0x3e, 0x39, 0x7, 0xca, 0x8a, 0xdf, 0x4a, - 0x62, 0x7b, 0xaa, 0x59, 0x38, 0x1e, 0x89, 0xe2, 0xa6, 0x49, 0xb1, 0x4a}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb9, 0xbc}; - lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x63, 0xa6, 0x3b, 0x33, 0xe0, 0x8f, 0xcd, 0x91, 0x73, 0x2f, 0x7e, 0xd4, 0xb9, 0x4b}; - uint8_t bytesprops1[] = {0xb6, 0x6d, 0xda, 0x2d, 0x4c, 0xd2, 0x92, 0xa6, 0x1d, 0x7c, 0x11, 0xa5, 0x29, - 0x38, 0xee, 0xc0, 0xac, 0x67, 0xb8, 0x89, 0xa7, 0x7a, 0xa8, 0xf8, 0xd3, 0x55}; - uint8_t bytesprops2[] = {0x85, 0x81, 0xef, 0x92}; - uint8_t bytesprops3[] = {0x2c, 0x6b, 0x6b, 0x0, 0xea, 0xd3, 0x18, 0x9f, 0x59, 0xb9, 0x35, 0xa4, 0x52, 0xa2}; - uint8_t bytesprops4[] = {0xb3, 0xd7, 0xb1, 0x7f, 0xd, 0xf9, 0xaa, 0x9, 0x49, 0xfd, 0x62, 0x40, 0xb8, - 0xc3, 0xf6, 0x8f, 0xc1, 0xc2, 0x3c, 0x60, 0x19, 0x38, 0x72, 0x5, 0xa0}; - uint8_t bytesprops5[] = {0x85, 0x83, 0xd4, 0x37, 0x99, 0xf6, 0x30}; - uint8_t bytesprops6[] = {0xa7, 0x45, 0x27, 0x5a, 0xd1, 0x2a, 0x90, 0x3, 0x43}; - uint8_t bytesprops7[] = {0x91, 0x5e, 0xc9, 0x28, 0x30, 0x16, 0xae, 0xbc, 0xc6, 0x41, 0x1a, 0x66, 0x6c, 0x2c, 0x8b, - 0x32, 0x5f, 0xe6, 0xe9, 0x4e, 0x52, 0x79, 0xcd, 0xff, 0xf9, 0x62, 0xa0, 0x9b, 0xb0}; - uint8_t bytesprops8[] = {0x76, 0x77, 0x6a, 0x25, 0x2b, 0x20, 0x8c, 0x96, 0x15, 0xe7, 0xf8, - 0xbb, 0x2b, 0x82, 0xd2, 0x32, 0x6a, 0x15, 0xa8, 0x8, 0xbd, 0x79}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10841}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12503}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1094}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31491}}, - }; - - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5081, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 25469 [("\196\234\233C\245\STX\229\154\t\US\r\b&>F\213\130\&4",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("}\ENQ\233z\235\223\134Z\220y\220\255\ACK\f8\r\211\178\171\145=\183\148\DC4\187{S:\215\247",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("SL0j\ENQ\STX\v\178\243,\155\168-3\RS*R\246\NAK\134f)\183\196",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\t\185T\132Z\205GI\DC2\146\156\233\201\134k\142\168\247\201=\179\134\&1",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\200\160\129\198|>\238\159\254\255\CANc\149\154\139\167#\234n",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\169\216=\154v",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("9\254'\139~\175N\ETX\172\240\223\&5^\171\"\163\222\225*\182\&2,\254\&6\174\EM2\f\227",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("o\SOH\195\158\&0R\138\250",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\EM\SYN\174\218\152k\247\&5i_\205`,\fm*\131_",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\163n)\179A=<\NUL\US\199\129\163\137+u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [PropContentType "\155\244\a\DC1\198\244J -// \146\r5\f\201\DC23\204",PropReceiveMaximum 31257,PropResponseInformation -// "$9\154\216\&7\238\DC2\204\252\254Z\209",PropTopicAlias 4733,PropRequestProblemInformation 43,PropResponseInformation -// "x\191S\255\152\DC3\a\139n\175\SOH*]\195\EOT\136\222\177\214:\NUL\130\GS\202",PropAssignedClientIdentifier -// "\253F?\STX?\172\167R\212(\206\213\200\227w\135\204\215\229\235",PropSubscriptionIdentifierAvailable -// 102,PropSessionExpiryInterval 19209,PropMaximumPacketSize 4183,PropContentType "\131\216\229\138",PropRetainAvailable -// 88,PropMaximumQoS 160,PropUserProperty "\210U\EOTm\128" -// "\151\146\212\169\159D}\154n\211x\vYOp\132`M_9\236\216M\221$L",PropWillDelayInterval 13355,PropResponseInformation -// "\199X\SYNK*",PropMessageExpiryInterval 6044,PropPayloadFormatIndicator 175,PropAssignedClientIdentifier -// "\243G\138\f\220\234W\182"] -TEST(Subscribe5QCTest, Encode12) { - uint8_t pkt[] = { - 0x82, 0x98, 0x3, 0x63, 0x7d, 0xb6, 0x1, 0x3, 0x0, 0x10, 0x9b, 0xf4, 0x7, 0x11, 0xc6, 0xf4, 0x4a, 0x20, 0x92, - 0xd, 0x35, 0xc, 0xc9, 0x12, 0x33, 0xcc, 0x21, 0x7a, 0x19, 0x1a, 0x0, 0xc, 0x24, 0x39, 0x9a, 0xd8, 0x37, 0xee, - 0x12, 0xcc, 0xfc, 0xfe, 0x5a, 0xd1, 0x23, 0x12, 0x7d, 0x17, 0x2b, 0x1a, 0x0, 0x18, 0x78, 0xbf, 0x53, 0xff, 0x98, - 0x13, 0x7, 0x8b, 0x6e, 0xaf, 0x1, 0x2a, 0x5d, 0xc3, 0x4, 0x88, 0xde, 0xb1, 0xd6, 0x3a, 0x0, 0x82, 0x1d, 0xca, - 0x12, 0x0, 0x14, 0xfd, 0x46, 0x3f, 0x2, 0x3f, 0xac, 0xa7, 0x52, 0xd4, 0x28, 0xce, 0xd5, 0xc8, 0xe3, 0x77, 0x87, - 0xcc, 0xd7, 0xe5, 0xeb, 0x29, 0x66, 0x11, 0x0, 0x0, 0x4b, 0x9, 0x27, 0x0, 0x0, 0x10, 0x57, 0x3, 0x0, 0x4, - 0x83, 0xd8, 0xe5, 0x8a, 0x25, 0x58, 0x24, 0xa0, 0x26, 0x0, 0x5, 0xd2, 0x55, 0x4, 0x6d, 0x80, 0x0, 0x1a, 0x97, - 0x92, 0xd4, 0xa9, 0x9f, 0x44, 0x7d, 0x9a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0x1, 0x0, 0x1d, 0x39, 0xfe, 0x27, 0x8b, 0x7e, 0xaf, 0x4e, 0x3, 0xac, 0xf0, 0xdf, 0x35, 0x5e, 0xab, - 0x22, 0xa3, 0xde, 0xe1, 0x2a, 0xb6, 0x32, 0x2c, 0xfe, 0x36, 0xae, 0x19, 0x32, 0xc, 0xe3, 0x2, 0x0, 0x8, 0x6f, - 0x1, 0xc3, 0x9e, 0x30, 0x52, 0x8a, 0xfa, 0x0, 0x0, 0x12, 0x19, 0x16, 0xae, 0xda, 0x98, 0x6b, 0xf7, 0x35, 0x69, - 0x5f, 0xcd, 0x60, 0x2c, 0xc, 0x6d, 0x2a, 0x83, 0x5f, 0x2, 0x0, 0xf, 0xa3, 0x6e, 0x29, 0xb3, 0x41, 0x3d, 0x3c, - 0x0, 0x1f, 0xc7, 0x81, 0xa3, 0x89, 0x2b, 0x75, 0x0, 0x0, 0x0, 0x2}; - - uint8_t buf[421] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xc4, 0xea, 0xe9, 0x43, 0xf5, 0x2, 0xe5, 0x9a, 0x9, - 0x1f, 0xd, 0x8, 0x26, 0x3e, 0x46, 0xd5, 0x82, 0x34}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7d, 0x5, 0xe9, 0x7a, 0xeb, 0xdf, 0x86, 0x5a, 0xdc, 0x79, - 0xdc, 0xff, 0x6, 0xc, 0x38, 0xd, 0xd3, 0xb2, 0xab, 0x91, - 0x3d, 0xb7, 0x94, 0x14, 0xbb, 0x7b, 0x53, 0x3a, 0xd7, 0xf7}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x53, 0x4c, 0x30, 0x6a, 0x5, 0x2, 0xb, 0xb2, 0xf3, 0x2c, 0x9b, 0xa8, - 0x2d, 0x33, 0x1e, 0x2a, 0x52, 0xf6, 0x15, 0x86, 0x66, 0x29, 0xb7, 0xc4}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9, 0xb9, 0x54, 0x84, 0x5a, 0xcd, 0x47, 0x49, 0x12, 0x92, 0x9c, 0xe9, - 0xc9, 0x86, 0x6b, 0x8e, 0xa8, 0xf7, 0xc9, 0x3d, 0xb3, 0x86, 0x31}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc8, 0xa0, 0x81, 0xc6, 0x7c, 0x3e, 0xee, 0x9f, 0xfe, 0xff, - 0x18, 0x63, 0x95, 0x9a, 0x8b, 0xa7, 0x23, 0xea, 0x6e}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa9, 0xd8, 0x3d, 0x9a, 0x76}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x39, 0xfe, 0x27, 0x8b, 0x7e, 0xaf, 0x4e, 0x3, 0xac, 0xf0, - 0xdf, 0x35, 0x5e, 0xab, 0x22, 0xa3, 0xde, 0xe1, 0x2a, 0xb6, - 0x32, 0x2c, 0xfe, 0x36, 0xae, 0x19, 0x32, 0xc, 0xe3}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6f, 0x1, 0xc3, 0x9e, 0x30, 0x52, 0x8a, 0xfa}; - lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x19, 0x16, 0xae, 0xda, 0x98, 0x6b, 0xf7, 0x35, 0x69, - 0x5f, 0xcd, 0x60, 0x2c, 0xc, 0x6d, 0x2a, 0x83, 0x5f}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa3, 0x6e, 0x29, 0xb3, 0x41, 0x3d, 0x3c, 0x0, - 0x1f, 0xc7, 0x81, 0xa3, 0x89, 0x2b, 0x75}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0}; - lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x9b, 0xf4, 0x7, 0x11, 0xc6, 0xf4, 0x4a, 0x20, 0x92, 0xd, 0x35, 0xc, 0xc9, 0x12, 0x33, 0xcc}; - uint8_t bytesprops1[] = {0x24, 0x39, 0x9a, 0xd8, 0x37, 0xee, 0x12, 0xcc, 0xfc, 0xfe, 0x5a, 0xd1}; - uint8_t bytesprops2[] = {0x78, 0xbf, 0x53, 0xff, 0x98, 0x13, 0x7, 0x8b, 0x6e, 0xaf, 0x1, 0x2a, - 0x5d, 0xc3, 0x4, 0x88, 0xde, 0xb1, 0xd6, 0x3a, 0x0, 0x82, 0x1d, 0xca}; - uint8_t bytesprops3[] = {0xfd, 0x46, 0x3f, 0x2, 0x3f, 0xac, 0xa7, 0x52, 0xd4, 0x28, - 0xce, 0xd5, 0xc8, 0xe3, 0x77, 0x87, 0xcc, 0xd7, 0xe5, 0xeb}; - uint8_t bytesprops4[] = {0x83, 0xd8, 0xe5, 0x8a}; - uint8_t bytesprops6[] = {0x97, 0x92, 0xd4, 0xa9, 0x9f, 0x44, 0x7d, 0x9a, 0x6e, 0xd3, 0x78, 0xb, 0x59, - 0x4f, 0x70, 0x84, 0x60, 0x4d, 0x5f, 0x39, 0xec, 0xd8, 0x4d, 0xdd, 0x24, 0x4c}; - uint8_t bytesprops5[] = {0xd2, 0x55, 0x4, 0x6d, 0x80}; - uint8_t bytesprops7[] = {0xc7, 0x58, 0x16, 0x4b, 0x2a}; - uint8_t bytesprops8[] = {0xf3, 0x47, 0x8a, 0xc, 0xdc, 0xea, 0x57, 0xb6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31257}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4733}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19209}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4183}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops5}, .v = {26, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13355}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6044}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops8}}}, - }; - - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25469, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14214 [("96\SIk\238a\SI\ETX\203\216\176fgS\149\148\229\206$",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\242\218\225YA\243\153\247\189I",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("1\141\ENQ\206\182U",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationData -// "\155\207z\253\172\191\&9\211\156I\234\244Gl\212\210\a\134\ENQ\ACK\255\r\206\228\230/\229",PropContentType -// "\231\148>\255\162QmDX\176#\\D\191\202\251\194\&8\t\205t",PropMaximumQoS 27,PropCorrelationData -// ")T\204\185\r",PropUserProperty "\DEL\137R_I\GSqE\226\238\NAK\204\187\250\bj])U\EM\200\SO\195B" -// "a=[bS\189\r\144\161\155@Bs\ESC\EOT\253",PropMaximumPacketSize 20849] -TEST(Subscribe5QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0xa5, 0x1, 0x37, 0x86, 0x72, 0x16, 0x0, 0x1b, 0x9b, 0xcf, 0x7a, 0xfd, 0xac, 0xbf, 0x39, 0xd3, - 0x9c, 0x49, 0xea, 0xf4, 0x47, 0x6c, 0xd4, 0xd2, 0x7, 0x86, 0x5, 0x6, 0xff, 0xd, 0xce, 0xe4, 0xe6, - 0x2f, 0xe5, 0x3, 0x0, 0x15, 0xe7, 0x94, 0x3e, 0xff, 0xa2, 0x51, 0x6d, 0x44, 0x58, 0xb0, 0x23, 0x5c, - 0x44, 0xbf, 0xca, 0xfb, 0xc2, 0x38, 0x9, 0xcd, 0x74, 0x24, 0x1b, 0x9, 0x0, 0x5, 0x29, 0x54, 0xcc, - 0xb9, 0xd, 0x26, 0x0, 0x18, 0x7f, 0x89, 0x52, 0x5f, 0x49, 0x1d, 0x71, 0x45, 0xe2, 0xee, 0x15, 0xcc, - 0xbb, 0xfa, 0x8, 0x6a, 0x5d, 0x29, 0x55, 0x19, 0xc8, 0xe, 0xc3, 0x42, 0x0, 0x10, 0x61, 0x3d, 0x5b, - 0x62, 0x53, 0xbd, 0xd, 0x90, 0xa1, 0x9b, 0x40, 0x42, 0x73, 0x1b, 0x4, 0xfd, 0x27, 0x0, 0x0, 0x51, - 0x71, 0x0, 0x13, 0x39, 0x36, 0xf, 0x6b, 0xee, 0x61, 0xf, 0x3, 0xcb, 0xd8, 0xb0, 0x66, 0x67, 0x53, - 0x95, 0x94, 0xe5, 0xce, 0x24, 0x2, 0x0, 0xa, 0xf2, 0xda, 0xe1, 0x59, 0x41, 0xf3, 0x99, 0xf7, 0xbd, - 0x49, 0x1, 0x0, 0x1, 0xeb, 0x0, 0x0, 0x6, 0x31, 0x8d, 0x5, 0xce, 0xb6, 0x55, 0x0}; - - uint8_t buf[178] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x39, 0x36, 0xf, 0x6b, 0xee, 0x61, 0xf, 0x3, 0xcb, 0xd8, - 0xb0, 0x66, 0x67, 0x53, 0x95, 0x94, 0xe5, 0xce, 0x24}; - lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf2, 0xda, 0xe1, 0x59, 0x41, 0xf3, 0x99, 0xf7, 0xbd, 0x49}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xeb}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x31, 0x8d, 0x5, 0xce, 0xb6, 0x55}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x9b, 0xcf, 0x7a, 0xfd, 0xac, 0xbf, 0x39, 0xd3, 0x9c, 0x49, 0xea, 0xf4, 0x47, 0x6c, - 0xd4, 0xd2, 0x7, 0x86, 0x5, 0x6, 0xff, 0xd, 0xce, 0xe4, 0xe6, 0x2f, 0xe5}; - uint8_t bytesprops1[] = {0xe7, 0x94, 0x3e, 0xff, 0xa2, 0x51, 0x6d, 0x44, 0x58, 0xb0, 0x23, - 0x5c, 0x44, 0xbf, 0xca, 0xfb, 0xc2, 0x38, 0x9, 0xcd, 0x74}; - uint8_t bytesprops2[] = {0x29, 0x54, 0xcc, 0xb9, 0xd}; - uint8_t bytesprops4[] = {0x61, 0x3d, 0x5b, 0x62, 0x53, 0xbd, 0xd, 0x90, - 0xa1, 0x9b, 0x40, 0x42, 0x73, 0x1b, 0x4, 0xfd}; - uint8_t bytesprops3[] = {0x7f, 0x89, 0x52, 0x5f, 0x49, 0x1d, 0x71, 0x45, 0xe2, 0xee, 0x15, 0xcc, - 0xbb, 0xfa, 0x8, 0x6a, 0x5d, 0x29, 0x55, 0x19, 0xc8, 0xe, 0xc3, 0x42}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops3}, .v = {16, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20849}}, - }; - - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14214, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 26235 [("\DLE",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("m;1\220gk`\169\152\251",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\SIj6\144\200ar\STX",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\241c\229\NULx\190Q\SYN",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropResponseInformation -// "\168\DC3\ETX",PropCorrelationData -// "Z{\175\133\a\247\182Sh\158\140\141\141\186J\f\183\ENQ\167\238\200\242}Ii\200",PropRequestProblemInformation -// 109,PropResponseInformation "\199\212\227\135:",PropResponseInformation -// "\SI6x~\198A\EOT.\138\197\193\138/\v\EM--6\f\ACK\191\v\STX",PropSubscriptionIdentifier 26,PropSessionExpiryInterval -// 19031,PropMessageExpiryInterval 30136,PropMaximumPacketSize 18409,PropSubscriptionIdentifier -// 6,PropRequestResponseInformation 8,PropRetainAvailable 55,PropRequestResponseInformation 81] -TEST(Subscribe5QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0x8a, 0x1, 0x66, 0x7b, 0x60, 0x1a, 0x0, 0x3, 0xa8, 0x13, 0x3, 0x9, 0x0, 0x1a, 0x5a, - 0x7b, 0xaf, 0x85, 0x7, 0xf7, 0xb6, 0x53, 0x68, 0x9e, 0x8c, 0x8d, 0x8d, 0xba, 0x4a, 0xc, 0xb7, - 0x5, 0xa7, 0xee, 0xc8, 0xf2, 0x7d, 0x49, 0x69, 0xc8, 0x17, 0x6d, 0x1a, 0x0, 0x5, 0xc7, 0xd4, - 0xe3, 0x87, 0x3a, 0x1a, 0x0, 0x17, 0xf, 0x36, 0x78, 0x7e, 0xc6, 0x41, 0x4, 0x2e, 0x8a, 0xc5, - 0xc1, 0x8a, 0x2f, 0xb, 0x19, 0x2d, 0x2d, 0x36, 0xc, 0x6, 0xbf, 0xb, 0x2, 0xb, 0x1a, 0x11, - 0x0, 0x0, 0x4a, 0x57, 0x2, 0x0, 0x0, 0x75, 0xb8, 0x27, 0x0, 0x0, 0x47, 0xe9, 0xb, 0x6, - 0x19, 0x8, 0x25, 0x37, 0x19, 0x51, 0x0, 0x1, 0x10, 0x1, 0x0, 0xa, 0x6d, 0x3b, 0x31, 0xdc, - 0x67, 0x6b, 0x60, 0xa9, 0x98, 0xfb, 0x1, 0x0, 0x8, 0xf, 0x6a, 0x36, 0x90, 0xc8, 0x61, 0x72, - 0x2, 0x0, 0x0, 0x8, 0xf1, 0x63, 0xe5, 0x0, 0x78, 0xbe, 0x51, 0x16, 0x0}; - - uint8_t buf[151] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x10}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6d, 0x3b, 0x31, 0xdc, 0x67, 0x6b, 0x60, 0xa9, 0x98, 0xfb}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf, 0x6a, 0x36, 0x90, 0xc8, 0x61, 0x72, 0x2}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf1, 0x63, 0xe5, 0x0, 0x78, 0xbe, 0x51, 0x16}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0xa8, 0x13, 0x3}; - uint8_t bytesprops1[] = {0x5a, 0x7b, 0xaf, 0x85, 0x7, 0xf7, 0xb6, 0x53, 0x68, 0x9e, 0x8c, 0x8d, 0x8d, - 0xba, 0x4a, 0xc, 0xb7, 0x5, 0xa7, 0xee, 0xc8, 0xf2, 0x7d, 0x49, 0x69, 0xc8}; - uint8_t bytesprops2[] = {0xc7, 0xd4, 0xe3, 0x87, 0x3a}; - uint8_t bytesprops3[] = {0xf, 0x36, 0x78, 0x7e, 0xc6, 0x41, 0x4, 0x2e, 0x8a, 0xc5, 0xc1, 0x8a, - 0x2f, 0xb, 0x19, 0x2d, 0x2d, 0x36, 0xc, 0x6, 0xbf, 0xb, 0x2}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19031}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30136}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18409}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26235, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 10474 [("\ACK\214li.\ESC\US;\201}3\165",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\152\173{\218\168a\184Y_y\149\241F:y\188",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\147\ESC\141H\166\226\230G\180\252\198\196\GS",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\236\183\RSM\169v\254\179TT7\211\194\132\161fbQ\218\US\135\202\f\149E\197\197\SOHuK",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("3\179|)\222p\245\SUB\197\v\182\RSnw#\225\157t\ETX\DC2E",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\233\213\221\219\SUB0\164J\162\185\156\230\230\&5\156\244\133",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("d\NULN\129\242u`\152\ACK\DEL_\164\207\168\191T\132\177\"\FS*",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\136f7w\182\132'",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\220w'\179\FSxy\194[@\163;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("9H\134H\191\242[\206S\129\162\243\244Kw$",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropResponseInformation -// "\240\203\GS\183\250\137l\224\235\250'\249}\SO\206|\144\162",PropResponseTopic -// "o6j\209\186\192\221<\139\204\253`\186\220\ETB?\213-?\239\132G",PropSharedSubscriptionAvailable 35,PropReasonString -// "X\DELS\248\184G\255+\194\169",PropMessageExpiryInterval 18569,PropTopicAlias 4449,PropReceiveMaximum -// 7814,PropTopicAlias 30892,PropUserProperty "e\a8\208\CAN\131b\134N\160\228\163\189y$\151a\130\169\244{\198\141\177" -// "\163\195M\241ue-\211\212\174\ACK\b\204\255\SYN\208\188+N\196\237\171\129R\129\226\ETX\163w",PropRetainAvailable -// 199,PropCorrelationData "}\165\223L\181\EOTt\CAN\253\176\210\209",PropServerKeepAlive -// 2300,PropWildcardSubscriptionAvailable 187] -TEST(Subscribe5QCTest, Encode15) { - uint8_t pkt[] = { - 0x82, 0xe7, 0x2, 0x28, 0xea, 0x9b, 0x1, 0x1a, 0x0, 0x12, 0xf0, 0xcb, 0x1d, 0xb7, 0xfa, 0x89, 0x6c, 0xe0, 0xeb, - 0xfa, 0x27, 0xf9, 0x7d, 0xe, 0xce, 0x7c, 0x90, 0xa2, 0x8, 0x0, 0x16, 0x6f, 0x36, 0x6a, 0xd1, 0xba, 0xc0, 0xdd, - 0x3c, 0x8b, 0xcc,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, 0xb3, 0x54, - 0x54, 0x37, 0xd3, 0xc2, 0x84, 0xa1, 0x66, 0x62, 0x51, 0xda, 0x1f, 0x87, 0xca, 0xc, 0x95, 0x45, 0xc5, 0xc5, 0x1, - 0x75, 0x4b, 0x0, 0x0, 0x15, 0x33, 0xb3, 0x7c, 0x29, 0xde, 0x70, 0xf5, 0x1a, 0xc5, 0xb, 0xb6, 0x1e, 0x6e, 0x77, - 0x23, 0xe1, 0x9d, 0x74, 0x3, 0x12, 0x45, 0x1, 0x0, 0x11, 0xe9, 0xd5, 0xdd, 0xdb, 0x1a, 0x30, 0xa4, 0x4a, 0xa2, - 0xb9, 0x9c, 0xe6, 0xe6, 0x35, 0x9c, 0xf4, 0x85, 0x2, 0x0, 0x15, 0x64, 0x0, 0x4e, 0x81, 0xf2, 0x75, 0x60, 0x98, - 0x6, 0x7f, 0x5f, 0xa4, 0xcf, 0xa8, 0xbf, 0x54, 0x84, 0xb1, 0x22, 0x1c, 0x2a, 0x2, 0x0, 0x7, 0x88, 0x66, 0x37, - 0x77, 0xb6, 0x84, 0x27, 0x2, 0x0, 0xc, 0xdc, 0x77, 0x27, 0xb3, 0x1c, 0x78, 0x79, 0xc2, 0x5b, 0x40, 0xa3, 0x3b, - 0x2, 0x0, 0x10, 0x39, 0x48, 0x86, 0x48, 0xbf, 0xf2, 0x5b, 0xce, 0x53, 0x81, 0xa2, 0xf3, 0xf4, 0x4b, 0x77, 0x24, - 0x1}; - - uint8_t buf[372] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x6, 0xd6, 0x6c, 0x69, 0x2e, 0x1b, 0x1f, 0x3b, 0x3c, - 0x4f, 0x5d, 0x74, 0x3e, 0xc9, 0x7d, 0x33, 0xa5}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x98, 0xad, 0x7b, 0xda, 0xa8, 0x61, 0xb8, 0x59, - 0x5f, 0x79, 0x95, 0xf1, 0x46, 0x3a, 0x79, 0xbc}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x93, 0x1b, 0x8d, 0x48, 0xa6, 0xe2, 0xe6, 0x47, 0xb4, 0xfc, 0xc6, 0xc4, 0x1d}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xec, 0xb7, 0x1e, 0x4d, 0xa9, 0x76, 0xfe, 0xb3, 0x54, 0x54, - 0x37, 0xd3, 0xc2, 0x84, 0xa1, 0x66, 0x62, 0x51, 0xda, 0x1f, - 0x87, 0xca, 0xc, 0x95, 0x45, 0xc5, 0xc5, 0x1, 0x75, 0x4b}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x33, 0xb3, 0x7c, 0x29, 0xde, 0x70, 0xf5, 0x1a, 0xc5, 0xb, 0xb6, - 0x1e, 0x6e, 0x77, 0x23, 0xe1, 0x9d, 0x74, 0x3, 0x12, 0x45}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe9, 0xd5, 0xdd, 0xdb, 0x1a, 0x30, 0xa4, 0x4a, 0xa2, - 0xb9, 0x9c, 0xe6, 0xe6, 0x35, 0x9c, 0xf4, 0x85}; - lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x64, 0x0, 0x4e, 0x81, 0xf2, 0x75, 0x60, 0x98, 0x6, 0x7f, 0x5f, - 0xa4, 0xcf, 0xa8, 0xbf, 0x54, 0x84, 0xb1, 0x22, 0x1c, 0x2a}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x88, 0x66, 0x37, 0x77, 0xb6, 0x84, 0x27}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xdc, 0x77, 0x27, 0xb3, 0x1c, 0x78, 0x79, 0xc2, 0x5b, 0x40, 0xa3, 0x3b}; - lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x39, 0x48, 0x86, 0x48, 0xbf, 0xf2, 0x5b, 0xce, - 0x53, 0x81, 0xa2, 0xf3, 0xf4, 0x4b, 0x77, 0x24}; - lwmqtt_string_t topic_filter_s9 = {16, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xf0, 0xcb, 0x1d, 0xb7, 0xfa, 0x89, 0x6c, 0xe0, 0xeb, - 0xfa, 0x27, 0xf9, 0x7d, 0xe, 0xce, 0x7c, 0x90, 0xa2}; - uint8_t bytesprops1[] = {0x6f, 0x36, 0x6a, 0xd1, 0xba, 0xc0, 0xdd, 0x3c, 0x8b, 0xcc, 0xfd, - 0x60, 0xba, 0xdc, 0x17, 0x3f, 0xd5, 0x2d, 0x3f, 0xef, 0x84, 0x47}; - uint8_t bytesprops2[] = {0x58, 0x7f, 0x53, 0xf8, 0xb8, 0x47, 0xff, 0x2b, 0xc2, 0xa9}; - uint8_t bytesprops4[] = {0xa3, 0xc3, 0x4d, 0xf1, 0x75, 0x65, 0x2d, 0xd3, 0xd4, 0xae, 0x6, 0x8, 0xcc, 0xff, 0x16, - 0xd0, 0xbc, 0x2b, 0x4e, 0xc4, 0xed, 0xab, 0x81, 0x52, 0x81, 0xe2, 0x3, 0xa3, 0x77}; - uint8_t bytesprops3[] = {0x65, 0x7, 0x38, 0xd0, 0x18, 0x83, 0x62, 0x86, 0x4e, 0xa0, 0xe4, 0xa3, - 0xbd, 0x79, 0x24, 0x97, 0x61, 0x82, 0xa9, 0xf4, 0x7b, 0xc6, 0x8d, 0xb1}; - uint8_t bytesprops5[] = {0x7d, 0xa5, 0xdf, 0x4c, 0xb5, 0x4, 0x74, 0x18, 0xfd, 0xb0, 0xd2, 0xd1}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18569}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4449}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7814}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30892}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops3}, .v = {29, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2300}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 187}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10474, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 3250 [("x\215}:\240\130\FS\DC3r\185\253t\214\&4\231\195dG<\187\f",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\ETB\236&\173\154\233\&7\EOT~",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("!\CAN\STX\GSG;\179\203\n\224\213",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\208d*\128\&7+\217w\"\f\250\ENQ\189\159\234\236\247\238\ACK0\195",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\155\218X\182O\200\175-#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\219\217L\214\219",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("A\235\201\159~{C\168\132nu\ETB",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\159jI\215+\216\176`\223\230\169\155\239\249q6",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAssignedClientIdentifier -// "\199es!\\\EOT\210\170\134",PropAuthenticationMethod "\219\135",PropTopicAlias 24882,PropResponseTopic -// "g\146\RSP",PropContentType "\\\188\201\153\183\157\226\172\219\vb\224\217\157\&9\162\SOH",PropAuthenticationMethod -// "\162\t\209c\229\&4Mr{\"E\229\223\183\r\EMq\ENQUBD",PropReasonString -// "\222\140\b\153\&4L\244\147A|L\EMd\163\US\156\&4\244\137\156",PropAssignedClientIdentifier -// "v\EM\186\129\USkJ\162",PropTopicAliasMaximum 17487,PropServerReference -// "!\136\189\242%\245\SO\184\204\203",PropSubscriptionIdentifier 27,PropServerReference "=\175\132",PropCorrelationData -// "\172\206\t\b\143\167\&7|5~",PropCorrelationData "y\229\234D\199",PropTopicAliasMaximum 9292,PropMaximumQoS -// 48,PropContentType "\237\207\183\254\EM`\201,Y\ETX\232\n\246\166\179\198\227-",PropSubscriptionIdentifier 4] -TEST(Subscribe5QCTest, Encode16) { - uint8_t pkt[] = { - 0x82, 0xb6, 0x2, 0xc, 0xb2, 0xb2, 0x1, 0x12, 0x0, 0x9, 0xc7, 0x65, 0x73, 0x21, 0x5c, 0x4, 0xd2, 0xaa, 0x86, - 0x15, 0x0, 0x2, 0xdb, 0x87, 0x23, 0x61, 0x32, 0x8, 0x0, 0x4, 0x67, 0x92, 0x1e, 0x50, 0x3, 0x0, 0x11, 0x5c, - 0xbc, 0xc9, 0x99, 0xb7, 0x9d, 0xe2, 0xac, 0xdb, 0xb, 0x62, 0xe0, 0xd9, 0x9d, 0x39, 0xa2, 0x1, 0x15, 0x0, 0x15, - 0xa2, 0x9, 0xd1, 0x63, 0xe5, 0x34, 0x4d, 0x72, 0x7b, 0x22, 0x45, 0xe5, 0xdf, 0xb7, 0xd, 0x19, 0x71, 0x5, 0x55, - 0x42, 0x44, 0x1f, 0x0, 0x14, 0xde, 0x8c, 0x8, 0x99, 0x34, 0x4c, 0xf4, 0x93, 0x41, 0x7c, 0x4c, 0x19, 0x64, 0xa3, - 0x1f, 0x9c, 0x34, 0xf4, 0x89, 0x9c, 0x12, 0x0, 0x8, 0x76, 0x19, 0xba, 0x81, 0x1f, 0x6b, 0x4a, 0xa2, 0x22, 0x44, - 0x4f, 0x1c, 0x0, 0xa, 0x21, 0x88, 0xbd, 0xf2, 0x25, 0xf5, 0xe, 0xb8, 0xcc, 0xcb, 0xb, 0x1b, 0x1c, 0x0, 0x3, - 0x3d, 0xaf, 0x84, 0x9, 0x0, 0xa, 0xac, 0xce, 0x9, 0x8, 0x8f, 0xa7, 0x37, 0x7c, 0x35, 0x7e, 0x9, 0x0, 0x5, - 0x79, 0xe5, 0xea, 0x44, 0xc7, 0x22, 0x24, 0x4c, 0x24, 0x30, 0x3, 0x0, 0x12, 0xed, 0xcf, 0xb7, 0xfe, 0x19, 0x60, - 0xc9, 0x2c, 0x59, 0x3, 0xe8, 0xa, 0xf6, 0xa6, 0xb3, 0xc6, 0xe3, 0x2d, 0xb, 0x4, 0x0, 0x15, 0x78, 0xd7, 0x7d, - 0x3a, 0xf0, 0x82, 0x1c, 0x13, 0x72, 0xb9, 0xfd, 0x74, 0xd6, 0x34, 0xe7, 0xc3, 0x64, 0x47, 0x3c, 0xbb, 0xc, 0x0, - 0x0, 0x9, 0x17, 0xec, 0x26, 0xad, 0x9a, 0xe9, 0x37, 0x4, 0x7e, 0x2, 0x0, 0xb, 0x21, 0x18, 0x2, 0x1d, 0x47, - 0x3b, 0xb3, 0xcb, 0xa, 0xe0, 0xd5, 0x0, 0x0, 0x15, 0xd0, 0x64, 0x2a, 0x80, 0x37, 0x2b, 0xd9, 0x77, 0x22, 0xc, - 0xfa, 0x5, 0xbd, 0x9f, 0xea, 0xec, 0xf7, 0xee, 0x6, 0x30, 0xc3, 0x0, 0x0, 0x9, 0x9b, 0xda, 0x58, 0xb6, 0x4f, - 0xc8, 0xaf, 0x2d, 0x23, 0x1, 0x0, 0x5, 0xdb, 0xd9, 0x4c, 0xd6, 0xdb, 0x1, 0x0, 0xc, 0x41, 0xeb, 0xc9, 0x9f, - 0x7e, 0x7b, 0x43, 0xa8, 0x84, 0x6e, 0x75, 0x17, 0x1, 0x0, 0x10, 0x9f, 0x6a, 0x49, 0xd7, 0x2b, 0xd8, 0xb0, 0x60, - 0xdf, 0xe6, 0xa9, 0x9b, 0xef, 0xf9, 0x71, 0x36, 0x1}; - - uint8_t buf[323] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x78, 0xd7, 0x7d, 0x3a, 0xf0, 0x82, 0x1c, 0x13, 0x72, 0xb9, 0xfd, - 0x74, 0xd6, 0x34, 0xe7, 0xc3, 0x64, 0x47, 0x3c, 0xbb, 0xc}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x17, 0xec, 0x26, 0xad, 0x9a, 0xe9, 0x37, 0x4, 0x7e}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x21, 0x18, 0x2, 0x1d, 0x47, 0x3b, 0xb3, 0xcb, 0xa, 0xe0, 0xd5}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd0, 0x64, 0x2a, 0x80, 0x37, 0x2b, 0xd9, 0x77, 0x22, 0xc, 0xfa, - 0x5, 0xbd, 0x9f, 0xea, 0xec, 0xf7, 0xee, 0x6, 0x30, 0xc3}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9b, 0xda, 0x58, 0xb6, 0x4f, 0xc8, 0xaf, 0x2d, 0x23}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xdb, 0xd9, 0x4c, 0xd6, 0xdb}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x41, 0xeb, 0xc9, 0x9f, 0x7e, 0x7b, 0x43, 0xa8, 0x84, 0x6e, 0x75, 0x17}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x9f, 0x6a, 0x49, 0xd7, 0x2b, 0xd8, 0xb0, 0x60, - 0xdf, 0xe6, 0xa9, 0x9b, 0xef, 0xf9, 0x71, 0x36}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xc7, 0x65, 0x73, 0x21, 0x5c, 0x4, 0xd2, 0xaa, 0x86}; - uint8_t bytesprops1[] = {0xdb, 0x87}; - uint8_t bytesprops2[] = {0x67, 0x92, 0x1e, 0x50}; - uint8_t bytesprops3[] = {0x5c, 0xbc, 0xc9, 0x99, 0xb7, 0x9d, 0xe2, 0xac, 0xdb, - 0xb, 0x62, 0xe0, 0xd9, 0x9d, 0x39, 0xa2, 0x1}; - uint8_t bytesprops4[] = {0xa2, 0x9, 0xd1, 0x63, 0xe5, 0x34, 0x4d, 0x72, 0x7b, 0x22, 0x45, - 0xe5, 0xdf, 0xb7, 0xd, 0x19, 0x71, 0x5, 0x55, 0x42, 0x44}; - uint8_t bytesprops5[] = {0xde, 0x8c, 0x8, 0x99, 0x34, 0x4c, 0xf4, 0x93, 0x41, 0x7c, - 0x4c, 0x19, 0x64, 0xa3, 0x1f, 0x9c, 0x34, 0xf4, 0x89, 0x9c}; - uint8_t bytesprops6[] = {0x76, 0x19, 0xba, 0x81, 0x1f, 0x6b, 0x4a, 0xa2}; - uint8_t bytesprops7[] = {0x21, 0x88, 0xbd, 0xf2, 0x25, 0xf5, 0xe, 0xb8, 0xcc, 0xcb}; - uint8_t bytesprops8[] = {0x3d, 0xaf, 0x84}; - uint8_t bytesprops9[] = {0xac, 0xce, 0x9, 0x8, 0x8f, 0xa7, 0x37, 0x7c, 0x35, 0x7e}; - uint8_t bytesprops10[] = {0x79, 0xe5, 0xea, 0x44, 0xc7}; - uint8_t bytesprops11[] = {0xed, 0xcf, 0xb7, 0xfe, 0x19, 0x60, 0xc9, 0x2c, 0x59, - 0x3, 0xe8, 0xa, 0xf6, 0xa6, 0xb3, 0xc6, 0xe3, 0x2d}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24882}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17487}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9292}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3250, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12034 -// [("\128.\143\172\255%\203\247\222\207O\146%X\169\204g\245\223\SUB\150#\190tM\173Fw9",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropServerKeepAlive -// 4778,PropWillDelayInterval 10353,PropMessageExpiryInterval 18887,PropSharedSubscriptionAvailable 75,PropTopicAlias -// 8848,PropRetainAvailable 170,PropAuthenticationMethod "{\ETXs\233\138\SO*",PropWillDelayInterval -// 29469,PropMaximumPacketSize 4282,PropSharedSubscriptionAvailable 241,PropServerReference -// "",PropRequestProblemInformation 234,PropSubscriptionIdentifier 14,PropReceiveMaximum 24890,PropServerReference -// "\184}Wx\223M\202\NUL0\220E\249\247\n\191\202",PropSharedSubscriptionAvailable 112,PropRequestResponseInformation -// 142,PropSharedSubscriptionAvailable 65,PropSubscriptionIdentifier 12,PropReceiveMaximum 25373,PropServerKeepAlive -// 9978,PropReceiveMaximum 970] -TEST(Subscribe5QCTest, Encode17) { - uint8_t pkt[] = {0x82, 0x7b, 0x2f, 0x2, 0x58, 0x13, 0x12, 0xaa, 0x18, 0x0, 0x0, 0x28, 0x71, 0x2, 0x0, 0x0, - 0x49, 0xc7, 0x2a, 0x4b, 0x23, 0x22, 0x90, 0x25, 0xaa, 0x15, 0x0, 0x7, 0x7b, 0x3, 0x73, 0xe9, - 0x8a, 0xe, 0x2a, 0x18, 0x0, 0x0, 0x73, 0x1d, 0x27, 0x0, 0x0, 0x10, 0xba, 0x2a, 0xf1, 0x1c, - 0x0, 0x0, 0x17, 0xea, 0xb, 0xe, 0x21, 0x61, 0x3a, 0x1c, 0x0, 0x10, 0xb8, 0x7d, 0x57, 0x78, - 0xdf, 0x4d, 0xca, 0x0, 0x30, 0xdc, 0x45, 0xf9, 0xf7, 0xa, 0xbf, 0xca, 0x2a, 0x70, 0x19, 0x8e, - 0x2a, 0x41, 0xb, 0xc, 0x21, 0x63, 0x1d, 0x13, 0x26, 0xfa, 0x21, 0x3, 0xca, 0x0, 0x1d, 0x80, - 0x2e, 0x8f, 0xac, 0xff, 0x25, 0xcb, 0xf7, 0xde, 0xcf, 0x4f, 0x92, 0x25, 0x58, 0xa9, 0xcc, 0x67, - 0xf5, 0xdf, 0x1a, 0x96, 0x23, 0xbe, 0x74, 0x4d, 0xad, 0x46, 0x77, 0x39, 0x0}; - - uint8_t buf[135] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x80, 0x2e, 0x8f, 0xac, 0xff, 0x25, 0xcb, 0xf7, 0xde, 0xcf, - 0x4f, 0x92, 0x25, 0x58, 0xa9, 0xcc, 0x67, 0xf5, 0xdf, 0x1a, - 0x96, 0x23, 0xbe, 0x74, 0x4d, 0xad, 0x46, 0x77, 0x39}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x7b, 0x3, 0x73, 0xe9, 0x8a, 0xe, 0x2a}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0xb8, 0x7d, 0x57, 0x78, 0xdf, 0x4d, 0xca, 0x0, - 0x30, 0xdc, 0x45, 0xf9, 0xf7, 0xa, 0xbf, 0xca}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4778}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10353}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18887}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8848}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29469}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4282}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24890}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25373}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9978}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 970}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12034, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 4596 [("7\239\237\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\201\SI~\174\182\156;o{\142",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\219\b\DLE\SYN\228sb\177\143\195\230o<\196\246f=B",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\135\224?\NUL\161\188\134E\172\&4>1",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(".\233\181Y\146\&6\140\157\t\205\161Mo\215\&5\186\RSB_\ACK\219\186\f\238",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("1\174\&9\253\135o\201\235\GS\243\240\SYN\177jUy\141\218\158\251\232Pg\161\SYN\SO\162",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\137\&5u\EOT\209\DC4e\177\194H\NAKp;Q\228\b\149\178\182\140\217>!\",\FS\154\163\&1",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\189r\185K\155\247:&\129\FS}\SUB\136\205\198gm\202\183|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAssignedClientIdentifier -// "\DC1\200\ta\151ad%\149\206\235\139-\ETX\224\&7j\168ZE\ACK*",PropTopicAlias 26951,PropSessionExpiryInterval -// 19408,PropServerKeepAlive 13738,PropAssignedClientIdentifier -// "K\177Yq\"\199\190\168\a\160\DC3Q6o\221\134\168\206\254\\.*9",PropServerKeepAlive 22953,PropMessageExpiryInterval -// 20380,PropRetainAvailable 82,PropPayloadFormatIndicator 101,PropSubscriptionIdentifierAvailable -// 35,PropWillDelayInterval 26378,PropSessionExpiryInterval 6332,PropMessageExpiryInterval 18541,PropAuthenticationData -// "J\130;\242\RS\213\230\152\169\243",PropWildcardSubscriptionAvailable 38,PropSessionExpiryInterval -// 12922,PropServerReference "Cv\165\&7\219\228\t,\ETX/\159\176\200(\227H\\f -// \178\FS&o\142\172'D\250\SYN",PropCorrelationData "\131\ESC\DC1nr\DEL\237\235\FS\ACK\220\238",PropReasonString -// "\251\194\163\212`F\160\FS5.\207d\241D\138\240n\ESC^*\ESC\174",PropServerReference -// "\233\v\244\185\DEL!6\131\243\232;\173\129a\242\176\147\b\161\209\156Z\169\DLE/"] -TEST(Subscribe5QCTest, Encode18) { - uint8_t pkt[] = { - 0x82, 0x86, 0x3, 0x11, 0xf4, 0xd3, 0x1, 0x12, 0x0, 0x16, 0x11, 0xc8, 0x9, 0x61, 0x97, 0x61, 0x64, 0x25, 0x95, - 0xce, 0xeb, 0x8b, 0x2d, 0x3, 0xe0, 0x37, 0x6a, 0xa8, 0x5a, 0x45, 0x6, 0x2a, 0x23, 0x69, 0x47, 0x11, 0x0, 0x0, - 0x4b, 0xd0, 0x13, 0x35, 0xaa, 0x12, 0x0, 0x17, 0x4b, 0xb1, 0x59, 0x71, 0x22, 0xc7, 0xbe, 0xa8, 0x7, 0xa0, 0x13, - 0x51, 0x36, 0x6f, 0xdd, 0x86, 0xa8, 0xce, 0xfe, 0x5c, 0x2e, 0x2a, 0x39, 0x13, 0x59, 0xa9, 0x2, 0x0, 0x0, 0x4f, - 0x9c, 0x25, 0x52, 0x1, 0x65, 0x29, 0x23, 0x18, 0x0, 0x0, 0x67, 0xa, 0x11, 0x0, 0x0, 0x18, 0xbc, 0x2, 0x0, - 0x0, 0x48, 0x6d, 0x16, 0x0, 0xa, 0x4a, 0x82, 0x3b, 0xf2, 0x1e, 0xd5, 0xe6, 0x98, 0xa9, 0xf3, 0x28, 0x26, 0x11, - 0x0, 0x0, 0x32, 0x7a, 0x1c, 0x0, 0x1d, 0x43, 0x76, 0xa5, 0x37, 0xdb, 0xe4, 0x9, 0x2c, 0x3, 0x2f, 0x9f, 0xb0, - 0xc8, 0x28, 0xe3, 0x48, 0x5c, 0x66, 0x20, 0xb2, 0x1c, 0x26, 0x6f, 0x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xfb, 0xe8, 0x50, 0x67, 0xa1, 0x16, 0xe, 0xa2, 0x2, 0x0, 0x1d, 0x89, 0x35, - 0x75, 0x4, 0xd1, 0x14, 0x65, 0xb1, 0xc2, 0x48, 0x15, 0x70, 0x3b, 0x51, 0xe4, 0x8, 0x95, 0xb2, 0xb6, 0x8c, 0xd9, - 0x3e, 0x21, 0x22, 0x2c, 0x1c, 0x9a, 0xa3, 0x31, 0x2, 0x0, 0x14, 0xbd, 0x72, 0xb9, 0x4b, 0x9b, 0xf7, 0x3a, 0x26, - 0x81, 0x1c, 0x7d, 0x1a, 0x88, 0xcd, 0xc6, 0x67, 0x6d, 0xca, 0xb7, 0x7c, 0x0}; - - uint8_t buf[403] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x37, 0xef, 0xed, 0x94}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xce}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc9, 0xf, 0x7e, 0xae, 0xb6, 0x9c, 0x3b, 0x6f, 0x7b, 0x8e}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xdb, 0x8, 0x10, 0x16, 0xe4, 0x73, 0x62, 0xb1, 0x8f, - 0xc3, 0xe6, 0x6f, 0x3c, 0xc4, 0xf6, 0x66, 0x3d, 0x42}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x87, 0xe0, 0x3f, 0x0, 0xa1, 0xbc, 0x86, 0x45, 0xac, 0x34, 0x3e, 0x31}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x2e, 0xe9, 0xb5, 0x59, 0x92, 0x36, 0x8c, 0x9d, 0x9, 0xcd, 0xa1, 0x4d, - 0x6f, 0xd7, 0x35, 0xba, 0x1e, 0x42, 0x5f, 0x6, 0xdb, 0xba, 0xc, 0xee}; - lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x31, 0xae, 0x39, 0xfd, 0x87, 0x6f, 0xc9, 0xeb, 0x1d, 0xf3, 0xf0, 0x16, 0xb1, 0x6a, - 0x55, 0x79, 0x8d, 0xda, 0x9e, 0xfb, 0xe8, 0x50, 0x67, 0xa1, 0x16, 0xe, 0xa2}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x89, 0x35, 0x75, 0x4, 0xd1, 0x14, 0x65, 0xb1, 0xc2, 0x48, - 0x15, 0x70, 0x3b, 0x51, 0xe4, 0x8, 0x95, 0xb2, 0xb6, 0x8c, - 0xd9, 0x3e, 0x21, 0x22, 0x2c, 0x1c, 0x9a, 0xa3, 0x31}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xbd, 0x72, 0xb9, 0x4b, 0x9b, 0xf7, 0x3a, 0x26, 0x81, 0x1c, - 0x7d, 0x1a, 0x88, 0xcd, 0xc6, 0x67, 0x6d, 0xca, 0xb7, 0x7c}; - lwmqtt_string_t topic_filter_s9 = {20, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x11, 0xc8, 0x9, 0x61, 0x97, 0x61, 0x64, 0x25, 0x95, 0xce, 0xeb, - 0x8b, 0x2d, 0x3, 0xe0, 0x37, 0x6a, 0xa8, 0x5a, 0x45, 0x6, 0x2a}; - uint8_t bytesprops1[] = {0x4b, 0xb1, 0x59, 0x71, 0x22, 0xc7, 0xbe, 0xa8, 0x7, 0xa0, 0x13, 0x51, - 0x36, 0x6f, 0xdd, 0x86, 0xa8, 0xce, 0xfe, 0x5c, 0x2e, 0x2a, 0x39}; - uint8_t bytesprops2[] = {0x4a, 0x82, 0x3b, 0xf2, 0x1e, 0xd5, 0xe6, 0x98, 0xa9, 0xf3}; - uint8_t bytesprops3[] = {0x43, 0x76, 0xa5, 0x37, 0xdb, 0xe4, 0x9, 0x2c, 0x3, 0x2f, 0x9f, 0xb0, 0xc8, 0x28, 0xe3, - 0x48, 0x5c, 0x66, 0x20, 0xb2, 0x1c, 0x26, 0x6f, 0x8e, 0xac, 0x27, 0x44, 0xfa, 0x16}; - uint8_t bytesprops4[] = {0x83, 0x1b, 0x11, 0x6e, 0x72, 0x7f, 0xed, 0xeb, 0x1c, 0x6, 0xdc, 0xee}; - uint8_t bytesprops5[] = {0xfb, 0xc2, 0xa3, 0xd4, 0x60, 0x46, 0xa0, 0x1c, 0x35, 0x2e, 0xcf, - 0x64, 0xf1, 0x44, 0x8a, 0xf0, 0x6e, 0x1b, 0x5e, 0x2a, 0x1b, 0xae}; - uint8_t bytesprops6[] = {0xe9, 0xb, 0xf4, 0xb9, 0x7f, 0x21, 0x36, 0x83, 0xf3, 0xe8, 0x3b, 0xad, 0x81, - 0x61, 0xf2, 0xb0, 0x93, 0x8, 0xa1, 0xd1, 0x9c, 0x5a, 0xa9, 0x10, 0x2f}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26951}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19408}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13738}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22953}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20380}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26378}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6332}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18541}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12922}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops6}}}, - }; - - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4596, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12163 [("\r\156\"+\229.^L8\n\226%&\152\200\143De",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\233=P\128\f\151\147O\193\209\230l\183\&7Z\153\201\152z:\237\&8\STX\176Z\187\245\253",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\154\238U\255\128\128\129\222",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\178\STX7\173\221\210\128$\v\SOHQ\223\172\129",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("J\179\253\197\215CRg\185\217\STX1\223\&5\213\&17\245y\\h\154\DC4Jz\238\168\243\DC3!",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("G-\208\165h?\SO\131[\DC1",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\193\175\185E?\229\197iQ\ETX\234\174%\176\197\223\197\DLE\233M\211\250X\185wU",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropUserProperty -// "\199\SOH\DC4\"W\246\183`Q\194\223\255\154\197K\148\241o#B\212\156\133\203\193\248`\"" -// "x\ESC\ETX4\207\FS\NAK\208\RSy",PropMaximumQoS 201,PropWillDelayInterval 10233,PropServerKeepAlive -// 20327,PropRequestProblemInformation 208,PropServerReference -// "\171\ETX\253Y\160\DC2\DC3n",PropRequestProblemInformation 23,PropSessionExpiryInterval -// 11687,PropMessageExpiryInterval 21409,PropContentType -// "\136\199\FSr\187\&1\187\225\&2Wu#",PropAssignedClientIdentifier -// "\SO\b\183\194\136\ENQW!\DC2\DC3\202\216[\200\148\168",PropMaximumPacketSize 20756,PropReceiveMaximum -// 23959,PropReceiveMaximum 15319,PropSubscriptionIdentifier 22,PropSubscriptionIdentifier -// 2,PropWildcardSubscriptionAvailable 114,PropReceiveMaximum 5175,PropAssignedClientIdentifier -// "a:\164\135\SYNk\182m\USl=\252\201\&8O\183\244p7\205pN\197\STX\188e\164\160\211",PropWildcardSubscriptionAvailable -// 0,PropMaximumQoS 212,PropSubscriptionIdentifierAvailable 170,PropRequestProblemInformation 179,PropWillDelayInterval -// 2439,PropRetainAvailable 181,PropServerReference "'\252\ACK\177",PropResponseInformation -// "\133\243",PropWildcardSubscriptionAvailable 194,PropMessageExpiryInterval 30882,PropAuthenticationMethod -// "\175\DC1\SUB\181\187=Q\225\SYN\135\&3wYc"] -TEST(Subscribe5QCTest, Encode19) { - uint8_t pkt[] = { - 0x82, 0xf6, 0x2, 0x2f, 0x83, 0xd7, 0x1, 0x26, 0x0, 0x1c, 0xc7, 0x1, 0x14, 0x22, 0x57, 0xf6, 0xb7, 0x60, 0x51, - 0xc2, 0xdf, 0xff, 0x9a, 0xc5, 0x4b, 0x94, 0xf1, 0x6f, 0x23, 0x42, 0xd4, 0x9c, 0x85, 0xcb, 0xc1, 0xf8, 0x60, 0x22, - 0x0, 0xa, 0x78, 0x1b, 0x3, 0x34, 0xcf, 0x1c, 0x15, 0xd0, 0x1e, 0x79, 0x24, 0xc9, 0x18, 0x0, 0x0, 0x27, 0xf9, - 0x13, 0x4f, 0x67, 0x17, 0xd0, 0x1c, 0x0, 0x8, 0xab, 0x3, 0xfd, 0x59, 0xa0, 0x12, 0x13, 0x6e, 0x17, 0x17, 0x11, - 0x0, 0x0, 0x2d, 0xa7, 0x2, 0x0, 0x0, 0x53, 0xa1, 0x3, 0x0, 0xc, 0x88, 0xc7, 0x1c, 0x72, 0xbb, 0x31, 0xbb, - 0xe1, 0x32, 0x57, 0x75, 0x23, 0x12, 0x0, 0x10, 0xe, 0x8, 0xb7, 0xc2, 0x88, 0x5, 0x57, 0x21, 0x12, 0x13, 0xca, - 0xd8, 0x5b, 0xc8, 0x94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xb3, 0xfd, 0xc5, 0xd7, 0x43, 0x52, 0x67, 0xb9, 0xd9, 0x2, 0x31, 0xdf, 0x35, 0xd5, 0x31, 0x37, 0xf5, 0x79, - 0x5c, 0x68, 0x9a, 0x14, 0x4a, 0x7a, 0xee, 0xa8, 0xf3, 0x13, 0x21, 0x0, 0x0, 0xa, 0x47, 0x2d, 0xd0, 0xa5, 0x68, - 0x3f, 0xe, 0x83, 0x5b, 0x11, 0x2, 0x0, 0x1a, 0xc1, 0xaf, 0xb9, 0x45, 0x3f, 0xe5, 0xc5, 0x69, 0x51, 0x3, 0xea, - 0xae, 0x25, 0xb0, 0xc5, 0xdf, 0xc5, 0x10, 0xe9, 0x4d, 0xd3, 0xfa, 0x58, 0xb9, 0x77, 0x55, 0x2}; - - uint8_t buf[387] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xd, 0x9c, 0x22, 0x2b, 0xe5, 0x2e, 0x5e, 0x4c, 0x38, - 0xa, 0xe2, 0x25, 0x26, 0x98, 0xc8, 0x8f, 0x44, 0x65}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe9, 0x3d, 0x50, 0x80, 0xc, 0x97, 0x93, 0x4f, 0xc1, 0xd1, - 0xe6, 0x6c, 0xb7, 0x37, 0x5a, 0x99, 0xc9, 0x98, 0x7a, 0x3a, - 0xed, 0x38, 0x2, 0xb0, 0x5a, 0xbb, 0xf5, 0xfd}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9a, 0xee, 0x55, 0xff, 0x80, 0x80, 0x81, 0xde}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb2, 0x2, 0x37, 0xad, 0xdd, 0xd2, 0x80, 0x24, 0xb, 0x1, 0x51, 0xdf, 0xac, 0x81}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4a, 0xb3, 0xfd, 0xc5, 0xd7, 0x43, 0x52, 0x67, 0xb9, 0xd9, - 0x2, 0x31, 0xdf, 0x35, 0xd5, 0x31, 0x37, 0xf5, 0x79, 0x5c, - 0x68, 0x9a, 0x14, 0x4a, 0x7a, 0xee, 0xa8, 0xf3, 0x13, 0x21}; - lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x47, 0x2d, 0xd0, 0xa5, 0x68, 0x3f, 0xe, 0x83, 0x5b, 0x11}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc1, 0xaf, 0xb9, 0x45, 0x3f, 0xe5, 0xc5, 0x69, 0x51, 0x3, 0xea, 0xae, 0x25, - 0xb0, 0xc5, 0xdf, 0xc5, 0x10, 0xe9, 0x4d, 0xd3, 0xfa, 0x58, 0xb9, 0x77, 0x55}; - lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops1[] = {0x78, 0x1b, 0x3, 0x34, 0xcf, 0x1c, 0x15, 0xd0, 0x1e, 0x79}; - uint8_t bytesprops0[] = {0xc7, 0x1, 0x14, 0x22, 0x57, 0xf6, 0xb7, 0x60, 0x51, 0xc2, 0xdf, 0xff, 0x9a, 0xc5, - 0x4b, 0x94, 0xf1, 0x6f, 0x23, 0x42, 0xd4, 0x9c, 0x85, 0xcb, 0xc1, 0xf8, 0x60, 0x22}; - uint8_t bytesprops2[] = {0xab, 0x3, 0xfd, 0x59, 0xa0, 0x12, 0x13, 0x6e}; - uint8_t bytesprops3[] = {0x88, 0xc7, 0x1c, 0x72, 0xbb, 0x31, 0xbb, 0xe1, 0x32, 0x57, 0x75, 0x23}; - uint8_t bytesprops4[] = {0xe, 0x8, 0xb7, 0xc2, 0x88, 0x5, 0x57, 0x21, 0x12, 0x13, 0xca, 0xd8, 0x5b, 0xc8, 0x94, 0xa8}; - uint8_t bytesprops5[] = {0x61, 0x3a, 0xa4, 0x87, 0x16, 0x6b, 0xb6, 0x6d, 0x1f, 0x6c, 0x3d, 0xfc, 0xc9, 0x38, 0x4f, - 0xb7, 0xf4, 0x70, 0x37, 0xcd, 0x70, 0x4e, 0xc5, 0x2, 0xbc, 0x65, 0xa4, 0xa0, 0xd3}; - uint8_t bytesprops6[] = {0x27, 0xfc, 0x6, 0xb1}; - uint8_t bytesprops7[] = {0x85, 0xf3}; - uint8_t bytesprops8[] = {0xaf, 0x11, 0x1a, 0xb5, 0xbb, 0x3d, 0x51, 0xe1, 0x16, 0x87, 0x33, 0x77, 0x59, 0x63}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10233}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20327}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11687}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21409}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20756}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23959}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15319}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5175}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2439}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30882}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops8}}}, - }; - - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12163, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 21672 [(":f\201\245\150t\153",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("g^\195\215\\\138\194\147\188\181W\136",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\163\181\241IK\nA\212\254d\216",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0})] [PropCorrelationData "\US\225\249\235f=\176\228\234.",PropReasonString -// "-A\ACKM\206",PropRequestResponseInformation 8,PropUserProperty -// "h\r\185e\243\196\159\a\191\"!\160\193\DC46\128A\185,)gx\190" -// "\146,\136=~\194G\ri\ESC\ENQE\132\SYN\242\242G",PropMessageExpiryInterval 32206,PropMessageExpiryInterval -// 11439,PropUserProperty "t\252\251\235\172\255\234\204\b\SYN\170\148'\184z\t\139\212&\150H\\\184\223" -// "jS\144\130\ESCx\140\GS\221O\182\EM\ESCX\156",PropReceiveMaximum 19536,PropAssignedClientIdentifier -// "ij\232z+\133\ETB]]\148-,Ai\129\205\172\195d\175W$\236O",PropUserProperty -// "\239\192\\\153\166\ACK\ENQ_\224\131^k3\221\137\137\251B" -// "\203\NAK\180\150\USWn\\\235NF@\220\228\206=*",PropTopicAliasMaximum 13940,PropAssignedClientIdentifier -// "N0~\ETX;\185!S\STX\210M\148\186\206\SUB_",PropRequestResponseInformation 88,PropTopicAliasMaximum -// 12386,PropMaximumPacketSize 7196,PropAuthenticationMethod -// "\166\231p\217\241\205&\167Os\240\US.\151\197",PropTopicAliasMaximum 16731,PropAuthenticationMethod -// "+\175\&7c\141[\EM\204\202\222",PropSubscriptionIdentifierAvailable 86,PropAuthenticationData -// "S\214\FS\243\b\139Qt\130\132\ENQ\206\144\STX\142v\STX\DC1\197o\220E\131",PropCorrelationData -// "\244H\174",PropMaximumPacketSize 4306,PropMessageExpiryInterval 10977,PropMessageExpiryInterval -// 14925,PropRequestProblemInformation 220] -TEST(Subscribe5QCTest, Encode20) { - uint8_t pkt[] = { - 0x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57, 0x6e, 0x5c, - 0xeb, 0x4e, 0x46, 0x40, 0xdc, 0xe4, 0xce, 0x3d, 0x2a, 0x22, 0x36, 0x74, 0x12, 0x0, 0x10, 0x4e, 0x30, 0x7e, 0x3, - 0x3b, 0xb9, 0x21, 0x53, 0x2, 0xd2, 0x4d, 0x94, 0xba, 0xce, 0x1a, 0x5f, 0x19, 0x58, 0x22, 0x30, 0x62, 0x27, 0x0, - 0x0, 0x1c, 0x1c, 0x15, 0x0, 0xf, 0xa6, 0xe7, 0x70, 0xd9, 0xf1, 0xcd, 0x26, 0xa7, 0x4f, 0x73, 0xf0, 0x1f, 0x2e, - 0x97, 0xc5, 0x22, 0x41, 0x5b, 0x15, 0x0, 0xa, 0x2b, 0xaf, 0x37, 0x63, 0x8d, 0x5b, 0x19, 0xcc, 0xca, 0xde, 0x29, - 0x56, 0x16, 0x0, 0x17, 0x53, 0xd6, 0x1c, 0xf3, 0x8, 0x8b, 0x51, 0x74, 0x82, 0x84, 0x5, 0xce, 0x90, 0x2, 0x8e, - 0x76, 0x2, 0x11, 0xc5, 0x6f, 0xdc, 0x45, 0x83, 0x9, 0x0, 0x3, 0xf4, 0x48, 0xae, 0x27, 0x0, 0x0, 0x10, 0xd2, - 0x2, 0x0, 0x0, 0x2a, 0xe1, 0x2, 0x0, 0x0, 0x3a, 0x4d, 0x17, 0xdc, 0x0, 0x7, 0x3a, 0x66, 0xc9, 0xf5, 0x96, - 0x74, 0x99, 0x1, 0x0, 0xc, 0x67, 0x5e, 0xc3, 0xd7, 0x5c, 0x8a, 0xc2, 0x93, 0xbc, 0xb5, 0x57, 0x88, 0x0, 0x0, - 0xb, 0xa3, 0xb5, 0xf1, 0x49, 0x4b, 0xa, 0x41, 0xd4, 0xfe, 0x64, 0xd8, 0x0}; - - uint8_t buf[365] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x3a, 0x66, 0xc9, 0xf5, 0x96, 0x74, 0x99}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x67, 0x5e, 0xc3, 0xd7, 0x5c, 0x8a, 0xc2, 0x93, 0xbc, 0xb5, 0x57, 0x88}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa3, 0xb5, 0xf1, 0x49, 0x4b, 0xa, 0x41, 0xd4, 0xfe, 0x64, 0xd8}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x1f, 0xe1, 0xf9, 0xeb, 0x66, 0x3d, 0xb0, 0xe4, 0xea, 0x2e}; - uint8_t bytesprops1[] = {0x2d, 0x41, 0x6, 0x4d, 0xce}; - uint8_t bytesprops3[] = {0x92, 0x2c, 0x88, 0x3d, 0x7e, 0xc2, 0x47, 0xd, 0x69, - 0x1b, 0x5, 0x45, 0x84, 0x16, 0xf2, 0xf2, 0x47}; - uint8_t bytesprops2[] = {0x68, 0xd, 0xb9, 0x65, 0xf3, 0xc4, 0x9f, 0x7, 0xbf, 0x22, 0x21, 0xa0, - 0xc1, 0x14, 0x36, 0x80, 0x41, 0xb9, 0x2c, 0x29, 0x67, 0x78, 0xbe}; - uint8_t bytesprops5[] = {0x6a, 0x53, 0x90, 0x82, 0x1b, 0x78, 0x8c, 0x1d, 0xdd, 0x4f, 0xb6, 0x19, 0x1b, 0x58, 0x9c}; - uint8_t bytesprops4[] = {0x74, 0xfc, 0xfb, 0xeb, 0xac, 0xff, 0xea, 0xcc, 0x8, 0x16, 0xaa, 0x94, - 0x27, 0xb8, 0x7a, 0x9, 0x8b, 0xd4, 0x26, 0x96, 0x48, 0x5c, 0xb8, 0xdf}; - uint8_t bytesprops6[] = {0x69, 0x6a, 0xe8, 0x7a, 0x2b, 0x85, 0x17, 0x5d, 0x5d, 0x94, 0x2d, 0x2c, - 0x41, 0x69, 0x81, 0xcd, 0xac, 0xc3, 0x64, 0xaf, 0x57, 0x24, 0xec, 0x4f}; - uint8_t bytesprops8[] = {0xcb, 0x15, 0xb4, 0x96, 0x1f, 0x57, 0x6e, 0x5c, 0xeb, - 0x4e, 0x46, 0x40, 0xdc, 0xe4, 0xce, 0x3d, 0x2a}; - uint8_t bytesprops7[] = {0xef, 0xc0, 0x5c, 0x99, 0xa6, 0x6, 0x5, 0x5f, 0xe0, - 0x83, 0x5e, 0x6b, 0x33, 0xdd, 0x89, 0x89, 0xfb, 0x42}; - uint8_t bytesprops9[] = {0x4e, 0x30, 0x7e, 0x3, 0x3b, 0xb9, 0x21, 0x53, - 0x2, 0xd2, 0x4d, 0x94, 0xba, 0xce, 0x1a, 0x5f}; - uint8_t bytesprops10[] = {0xa6, 0xe7, 0x70, 0xd9, 0xf1, 0xcd, 0x26, 0xa7, 0x4f, 0x73, 0xf0, 0x1f, 0x2e, 0x97, 0xc5}; - uint8_t bytesprops11[] = {0x2b, 0xaf, 0x37, 0x63, 0x8d, 0x5b, 0x19, 0xcc, 0xca, 0xde}; - uint8_t bytesprops12[] = {0x53, 0xd6, 0x1c, 0xf3, 0x8, 0x8b, 0x51, 0x74, 0x82, 0x84, 0x5, 0xce, - 0x90, 0x2, 0x8e, 0x76, 0x2, 0x11, 0xc5, 0x6f, 0xdc, 0x45, 0x83}; - uint8_t bytesprops13[] = {0xf4, 0x48, 0xae}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops2}, .v = {17, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32206}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11439}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops4}, .v = {15, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19536}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops7}, .v = {17, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13940}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12386}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7196}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16731}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4306}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10977}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14925}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, - }; - - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21672, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2811 [("\232\155/\190\204\180\EOT\185\187J",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\204\150\224\190\140\164\182\211\159\f`\DC1",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\246te&\248u\229%^L\158\FSG\SYNQPL\237b\SOH\240\185",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k\ETX\f\tX\164\ETX",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerKeepAlive -// 22588,PropServerReference "",PropResponseTopic "\SO\214\\kc",PropRequestProblemInformation 203,PropServerReference -// "u\190\167\137\DC2\205v\US\145 \215\181h\f",PropResponseInformation "\236ri\GS\150\151g1\194i\199 -// \252\140H9\174\204L\176\210tH\226\&4\213\147",PropMaximumPacketSize 17747,PropAuthenticationData -// "\139\f\232/3`\181\213`\253",PropAuthenticationData -// "20^\232]\215\251\227\&1\197_P5\"\144\SI\240#3RT\143\USj\202\DC1\174\250",PropAuthenticationMethod -// "3\185_\193\138\156\205\142=(k",PropSubscriptionIdentifierAvailable 30,PropResponseInformation -// "BE\229\205:\193",PropAssignedClientIdentifier -// "\129R\153C!\133}\220\131z\173m\ESC\239\201\EOT\255\239\ETXi\n\233",PropCorrelationData -// "\152-\152~\157\\",PropRequestResponseInformation 213,PropAuthenticationMethod -// "l\217\159r\ETXY\161\211\145\203\244\138\164\177%tv\203\&6\136\ETX\209\228\216\136\221Xy\179",PropAuthenticationMethod -// "\205#\141\&9\185\152\DLEm\RS\RS\231\239\STXZ\227O9t\167}\136\212\227>\191\128\EMC\196!",PropMessageExpiryInterval -// 7170,PropMaximumQoS 100,PropMessageExpiryInterval 3938,PropRequestResponseInformation 12] -TEST(Subscribe5QCTest, Encode21) { - uint8_t pkt[] = { - 0x82, 0xbf, 0x2, 0xa, 0xfb, 0xfc, 0x1, 0x13, 0x58, 0x3c, 0x1c, 0x0, 0x0, 0x8, 0x0, 0x5, 0xe, 0xd6, 0x5c, - 0x6b, 0x63, 0x17, 0xcb, 0x1c, 0x0, 0xe, 0x75, 0xbe, 0xa7, 0x89, 0x12, 0xcd, 0x76, 0x1f, 0x91, 0x20, 0xd7, 0xb5, - 0x68, 0xc, 0x1a, 0x0, 0x1b, 0xec, 0x72, 0x69, 0x1d, 0x96, 0x97, 0x67, 0x31, 0xc2, 0x69, 0xc7, 0x20, 0xfc, 0x8c, - 0x48, 0x39, 0xae, 0xcc, 0x4c, 0xb0, 0xd2, 0x74, 0x48, 0xe2, 0x34, 0xd5, 0x93, 0x27, 0x0, 0x0, 0x45, 0x53, 0x16, - 0x0, 0xa, 0x8b, 0xc, 0xe8, 0x2f, 0x33, 0x60, 0xb5, 0xd5, 0x60, 0xfd, 0x16, 0x0, 0x1c, 0x32, 0x30, 0x5e, 0xe8, - 0x5d, 0xd7, 0xfb, 0xe3, 0x31, 0xc5, 0x5f, 0x50, 0x35, 0x22, 0x90, 0xf, 0xf0, 0x23, 0x33, 0x52, 0x54, 0x8f, 0x1f, - 0x6a, 0xca, 0x11, 0xae, 0xfa, 0x15, 0x0, 0xb, 0x33, 0xb9, 0x5f, 0xc1, 0x8a, 0x9c, 0xcd, 0x8e, 0x3d, 0x28, 0x6b, - 0x29, 0x1e, 0x1a, 0x0, 0x6, 0x42, 0x45, 0xe5, 0xcd, 0x3a, 0xc1, 0x12, 0x0, 0x16, 0x81, 0x52, 0x99, 0x43, 0x21, - 0x85, 0x7d, 0xdc, 0x83, 0x7a, 0xad, 0x6d, 0x1b, 0xef, 0xc9, 0x4, 0xff, 0xef, 0x3, 0x69, 0xa, 0xe9, 0x9, 0x0, - 0x6, 0x98, 0x2d, 0x98, 0x7e, 0x9d, 0x5c, 0x19, 0xd5, 0x15, 0x0, 0x1d, 0x6c, 0xd9, 0x9f, 0x72, 0x3, 0x59, 0xa1, - 0xd3, 0x91, 0xcb, 0xf4, 0x8a, 0xa4, 0xb1, 0x25, 0x74, 0x76, 0xcb, 0x36, 0x88, 0x3, 0xd1, 0xe4, 0xd8, 0x88, 0xdd, - 0x58, 0x79, 0xb3, 0x15, 0x0, 0x1e, 0xcd, 0x23, 0x8d, 0x39, 0xb9, 0x98, 0x10, 0x6d, 0x1e, 0x1e, 0xe7, 0xef, 0x2, - 0x5a, 0xe3, 0x4f, 0x39, 0x74, 0xa7, 0x7d, 0x88, 0xd4, 0xe3, 0x3e, 0xbf, 0x80, 0x19, 0x43, 0xc4, 0x21, 0x2, 0x0, - 0x0, 0x1c, 0x2, 0x24, 0x64, 0x2, 0x0, 0x0, 0xf, 0x62, 0x19, 0xc, 0x0, 0xa, 0xe8, 0x9b, 0x2f, 0xbe, 0xcc, - 0xb4, 0x4, 0xb9, 0xbb, 0x4a, 0x1, 0x0, 0xc, 0xcc, 0x96, 0xe0, 0xbe, 0x8c, 0xa4, 0xb6, 0xd3, 0x9f, 0xc, 0x60, - 0x11, 0x2, 0x0, 0x16, 0xf6, 0x74, 0x65, 0x26, 0xf8, 0x75, 0xe5, 0x25, 0x5e, 0x4c, 0x9e, 0x1c, 0x47, 0x16, 0x51, - 0x50, 0x4c, 0xed, 0x62, 0x1, 0xf0, 0xb9, 0x0, 0x0, 0x7, 0x6b, 0x3, 0xc, 0x9, 0x58, 0xa4, 0x3, 0x1}; - - uint8_t buf[332] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xe8, 0x9b, 0x2f, 0xbe, 0xcc, 0xb4, 0x4, 0xb9, 0xbb, 0x4a}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcc, 0x96, 0xe0, 0xbe, 0x8c, 0xa4, 0xb6, 0xd3, 0x9f, 0xc, 0x60, 0x11}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf6, 0x74, 0x65, 0x26, 0xf8, 0x75, 0xe5, 0x25, 0x5e, 0x4c, 0x9e, - 0x1c, 0x47, 0x16, 0x51, 0x50, 0x4c, 0xed, 0x62, 0x1, 0xf0, 0xb9}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6b, 0x3, 0xc, 0x9, 0x58, 0xa4, 0x3}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xe, 0xd6, 0x5c, 0x6b, 0x63}; - uint8_t bytesprops2[] = {0x75, 0xbe, 0xa7, 0x89, 0x12, 0xcd, 0x76, 0x1f, 0x91, 0x20, 0xd7, 0xb5, 0x68, 0xc}; - uint8_t bytesprops3[] = {0xec, 0x72, 0x69, 0x1d, 0x96, 0x97, 0x67, 0x31, 0xc2, 0x69, 0xc7, 0x20, 0xfc, 0x8c, - 0x48, 0x39, 0xae, 0xcc, 0x4c, 0xb0, 0xd2, 0x74, 0x48, 0xe2, 0x34, 0xd5, 0x93}; - uint8_t bytesprops4[] = {0x8b, 0xc, 0xe8, 0x2f, 0x33, 0x60, 0xb5, 0xd5, 0x60, 0xfd}; - uint8_t bytesprops5[] = {0x32, 0x30, 0x5e, 0xe8, 0x5d, 0xd7, 0xfb, 0xe3, 0x31, 0xc5, 0x5f, 0x50, 0x35, 0x22, - 0x90, 0xf, 0xf0, 0x23, 0x33, 0x52, 0x54, 0x8f, 0x1f, 0x6a, 0xca, 0x11, 0xae, 0xfa}; - uint8_t bytesprops6[] = {0x33, 0xb9, 0x5f, 0xc1, 0x8a, 0x9c, 0xcd, 0x8e, 0x3d, 0x28, 0x6b}; - uint8_t bytesprops7[] = {0x42, 0x45, 0xe5, 0xcd, 0x3a, 0xc1}; - uint8_t bytesprops8[] = {0x81, 0x52, 0x99, 0x43, 0x21, 0x85, 0x7d, 0xdc, 0x83, 0x7a, 0xad, - 0x6d, 0x1b, 0xef, 0xc9, 0x4, 0xff, 0xef, 0x3, 0x69, 0xa, 0xe9}; - uint8_t bytesprops9[] = {0x98, 0x2d, 0x98, 0x7e, 0x9d, 0x5c}; - uint8_t bytesprops10[] = {0x6c, 0xd9, 0x9f, 0x72, 0x3, 0x59, 0xa1, 0xd3, 0x91, 0xcb, 0xf4, 0x8a, 0xa4, 0xb1, 0x25, - 0x74, 0x76, 0xcb, 0x36, 0x88, 0x3, 0xd1, 0xe4, 0xd8, 0x88, 0xdd, 0x58, 0x79, 0xb3}; - uint8_t bytesprops11[] = {0xcd, 0x23, 0x8d, 0x39, 0xb9, 0x98, 0x10, 0x6d, 0x1e, 0x1e, 0xe7, 0xef, 0x2, 0x5a, 0xe3, - 0x4f, 0x39, 0x74, 0xa7, 0x7d, 0x88, 0xd4, 0xe3, 0x3e, 0xbf, 0x80, 0x19, 0x43, 0xc4, 0x21}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22588}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17747}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7170}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3938}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 12}}, - }; - - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2811, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 27615 [("\NAK\134\219\&6;\150\&1UX\155\237e\170\221",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("D\188\171\141\181i\189E\145\165\209^\172\DC3\184\&4\DC3\GS\221\USd\169UZ\156]\218",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("U\197\163\225\242\DELe\225y\183n'_\168\130\EOTv\134DS\164\148\vc=\226\240\215",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("%\220\143Z\STX\254s5\230\248\161\215\251k\222j2\132\174X\243\199\DC1\147\231",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\230\199yn\147I\171\f\206\152\247\ACK\246\205\&7i>7\137\ETXi",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("YLH\ETXb\224\237\198\151j\195\234\238",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\NUL4\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1})] [PropReceiveMaximum 3944,PropResponseTopic "y`\151\a\136\219Y0x\163\134\148\250 -// \209}\231",PropRequestProblemInformation 237,PropCorrelationData -// "\139\170\209\162\177n\149\NUL\DC4\ETB\142\183\175\202\234\169m\138\167a0\204\147\161\242\200\185\250\146\204",PropTopicAliasMaximum -// 32369,PropWildcardSubscriptionAvailable 198,PropMaximumPacketSize 19095,PropAssignedClientIdentifier -// "8L",PropServerReference -// "\225\SOH\ESC\NAK\167\162h?[\tfo\130F\251\227\214\&7J\EOT_\184\ENQ\136\193\223\157+",PropSubscriptionIdentifierAvailable -// 244,PropReasonString "\170V\146\DEL\147R}}\129\193\164\143\197\165[\225.%\156\&5R\213\194",PropUserProperty -// "\190\196\144y\243\201\161I\NULy\GS\234\251_(\242\US\221q2@\222\186\189x\189\129" "\201X\n -// \182\220P",PropWillDelayInterval 4591,PropSubscriptionIdentifierAvailable 212,PropResponseInformation -// "\ETXdcIt\a\GS\GSsp_BO",PropRequestProblemInformation 141,PropWillDelayInterval 26969,PropRequestProblemInformation -// 7,PropCorrelationData "\162\137+6\186\161V\133(\158\156\US\DC2`\207FQ\166\233>\224S\NUL\218R",PropServerReference -// "\SOH\184O_\237\167=\f\223\243Q\ETB\252\154\FSu\ETB>\151\219\131N\239l",PropRetainAvailable 116,PropServerKeepAlive -// 14370,PropTopicAlias 352,PropServerReference -// "\NUL\NUL8d\145\245\148\161\DC1\153N\183\129\172_\SYN\214.\200*=\189\142\DC1\150kL4",PropCorrelationData -// "\179{g0\EOT\195\129t\169_2\202y\255~-\239\254G\DC1+\EOT",PropWillDelayInterval 23938,PropMaximumQoS -// 131,PropWildcardSubscriptionAvailable 137,PropServerReference -// "?\SI\151S\130\GS$>(\140~\DLE\158$f(A\210'\132\&6",PropTopicAlias 20026] -TEST(Subscribe5QCTest, Encode22) { - uint8_t pkt[] = { - 0x82, 0x85, 0x4, 0x6b, 0xdf, 0xe6, 0x2, 0x21, 0xf, 0x68, 0x8, 0x0, 0x11, 0x79, 0x60, 0x97, 0x7, 0x88, 0xdb, - 0x59, 0x30, 0x78, 0xa3, 0x86, 0x94, 0xfa, 0x20, 0xd1, 0x7d, 0xe7, 0x17, 0xed, 0x9, 0x0, 0x1e, 0x8b, 0xaa, 0xd1, - 0xa2, 0xb1, 0x6e, 0x95, 0x0, 0x14, 0x17, 0x8e, 0xb7, 0xaf, 0xca, 0xea, 0xa9, 0x6d, 0x8a, 0xa7, 0x61, 0x30, 0xcc, - 0x93, 0xa1, 0xf2, 0xc8, 0xb9, 0xfa, 0x92, 0xcc, 0x22, 0x7e, 0x71, 0x28, 0xc6, 0x27, 0x0, 0x0, 0x4a, 0x97, 0x12, - 0x0, 0x2, 0x38, 0x4c, 0x1c, 0x0, 0x1c, 0xe1, 0x1, 0x1b, 0x15, 0xa7, 0xa2, 0x68, 0x3f, 0x5b, 0x9, 0x66, 0x6f, - 0x82, 0x46, 0xfb, 0xe3, 0xd6, 0x37, 0x4a, 0x4, 0x5f, 0xb8, 0x5, 0x88, 0xc1, 0xdf, 0x9d, 0x2b, 0x29, 0xf4, 0x1f, - 0x0, 0x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, 0x37, 0x69, 0x3e, 0x37, - 0x89, 0x3, 0x69, 0x1, 0x0, 0xd, 0x59, 0x4c, 0x48, 0x3, 0x62, 0xe0, 0xed, 0xc6, 0x97, 0x6a, 0xc3, 0xea, 0xee, - 0x0, 0x0, 0x3, 0x0, 0x34, 0xe8, 0x1}; - - uint8_t buf[530] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x15, 0x86, 0xdb, 0x36, 0x3b, 0x96, 0x31, - 0x55, 0x58, 0x9b, 0xed, 0x65, 0xaa, 0xdd}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x44, 0xbc, 0xab, 0x8d, 0xb5, 0x69, 0xbd, 0x45, 0x91, 0xa5, 0xd1, 0x5e, 0xac, 0x13, - 0xb8, 0x34, 0x13, 0x1d, 0xdd, 0x1f, 0x64, 0xa9, 0x55, 0x5a, 0x9c, 0x5d, 0xda}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x55, 0xc5, 0xa3, 0xe1, 0xf2, 0x7f, 0x65, 0xe1, 0x79, 0xb7, - 0x6e, 0x27, 0x5f, 0xa8, 0x82, 0x4, 0x76, 0x86, 0x44, 0x53, - 0xa4, 0x94, 0xb, 0x63, 0x3d, 0xe2, 0xf0, 0xd7}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x25, 0xdc, 0x8f, 0x5a, 0x2, 0xfe, 0x73, 0x35, 0xe6, 0xf8, 0xa1, 0xd7, 0xfb, - 0x6b, 0xde, 0x6a, 0x32, 0x84, 0xae, 0x58, 0xf3, 0xc7, 0x11, 0x93, 0xe7}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe6, 0xc7, 0x79, 0x6e, 0x93, 0x49, 0xab, 0xc, 0xce, 0x98, 0xf7, - 0x6, 0xf6, 0xcd, 0x37, 0x69, 0x3e, 0x37, 0x89, 0x3, 0x69}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x59, 0x4c, 0x48, 0x3, 0x62, 0xe0, 0xed, 0xc6, 0x97, 0x6a, 0xc3, 0xea, 0xee}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x0, 0x34, 0xe8}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x79, 0x60, 0x97, 0x7, 0x88, 0xdb, 0x59, 0x30, 0x78, - 0xa3, 0x86, 0x94, 0xfa, 0x20, 0xd1, 0x7d, 0xe7}; - uint8_t bytesprops1[] = {0x8b, 0xaa, 0xd1, 0xa2, 0xb1, 0x6e, 0x95, 0x0, 0x14, 0x17, 0x8e, 0xb7, 0xaf, 0xca, 0xea, - 0xa9, 0x6d, 0x8a, 0xa7, 0x61, 0x30, 0xcc, 0x93, 0xa1, 0xf2, 0xc8, 0xb9, 0xfa, 0x92, 0xcc}; - uint8_t bytesprops2[] = {0x38, 0x4c}; - uint8_t bytesprops3[] = {0xe1, 0x1, 0x1b, 0x15, 0xa7, 0xa2, 0x68, 0x3f, 0x5b, 0x9, 0x66, 0x6f, 0x82, 0x46, - 0xfb, 0xe3, 0xd6, 0x37, 0x4a, 0x4, 0x5f, 0xb8, 0x5, 0x88, 0xc1, 0xdf, 0x9d, 0x2b}; - uint8_t bytesprops4[] = {0xaa, 0x56, 0x92, 0x7f, 0x93, 0x52, 0x7d, 0x7d, 0x81, 0xc1, 0xa4, 0x8f, - 0xc5, 0xa5, 0x5b, 0xe1, 0x2e, 0x25, 0x9c, 0x35, 0x52, 0xd5, 0xc2}; - uint8_t bytesprops6[] = {0xc9, 0x58, 0xa, 0x20, 0xb6, 0xdc, 0x50}; - uint8_t bytesprops5[] = {0xbe, 0xc4, 0x90, 0x79, 0xf3, 0xc9, 0xa1, 0x49, 0x0, 0x79, 0x1d, 0xea, 0xfb, 0x5f, - 0x28, 0xf2, 0x1f, 0xdd, 0x71, 0x32, 0x40, 0xde, 0xba, 0xbd, 0x78, 0xbd, 0x81}; - uint8_t bytesprops7[] = {0x3, 0x64, 0x63, 0x49, 0x74, 0x7, 0x1d, 0x1d, 0x73, 0x70, 0x5f, 0x42, 0x4f}; - uint8_t bytesprops8[] = {0xa2, 0x89, 0x2b, 0x36, 0xba, 0xa1, 0x56, 0x85, 0x28, 0x9e, 0x9c, 0x1f, 0x12, - 0x60, 0xcf, 0x46, 0x51, 0xa6, 0xe9, 0x3e, 0xe0, 0x53, 0x0, 0xda, 0x52}; - uint8_t bytesprops9[] = {0x1, 0xb8, 0x4f, 0x5f, 0xed, 0xa7, 0x3d, 0xc, 0xdf, 0xf3, 0x51, 0x17, - 0xfc, 0x9a, 0x1c, 0x75, 0x17, 0x3e, 0x97, 0xdb, 0x83, 0x4e, 0xef, 0x6c}; - uint8_t bytesprops10[] = {0x0, 0x0, 0x38, 0x64, 0x91, 0xf5, 0x94, 0xa1, 0x11, 0x99, 0x4e, 0xb7, 0x81, 0xac, - 0x5f, 0x16, 0xd6, 0x2e, 0xc8, 0x2a, 0x3d, 0xbd, 0x8e, 0x11, 0x96, 0x6b, 0x4c, 0x34}; - uint8_t bytesprops11[] = {0xb3, 0x7b, 0x67, 0x30, 0x4, 0xc3, 0x81, 0x74, 0xa9, 0x5f, 0x32, - 0xca, 0x79, 0xff, 0x7e, 0x2d, 0xef, 0xfe, 0x47, 0x11, 0x2b, 0x4}; - uint8_t bytesprops12[] = {0x3f, 0xf, 0x97, 0x53, 0x82, 0x1d, 0x24, 0x3e, 0x28, 0x8c, 0x7e, - 0x10, 0x9e, 0x24, 0x66, 0x28, 0x41, 0xd2, 0x27, 0x84, 0x36}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3944}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32369}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19095}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops5}, .v = {7, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4591}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26969}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14370}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 352}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23938}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20026}}, - }; - - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27615, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14083 [("\135\234\FS",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("n\183\&9\DC1f\NUL@\185\255\185qq\STX\"\173\fJ\218\SUB",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\128p\197\DC1\162\160\171\171K\149\206 \ACK\145\202\142",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropUserProperty "\196" -// "\178\189\SOH\171\CAN\DLEf\EM\139\r\193\188\201\DC1x\244/\EOT}\151\&1\ETB\204\172",PropCorrelationData -// "\198\247%\146\202'\172",PropWildcardSubscriptionAvailable 255,PropServerReference "I@",PropTopicAliasMaximum -// 29613,PropAuthenticationMethod "\177\DC2P\ESC",PropAuthenticationMethod -// "\ENQ\167\214\183J\159u",PropWillDelayInterval 17943] -TEST(Subscribe5QCTest, Encode23) { - uint8_t pkt[] = {0x82, 0x7a, 0x37, 0x3, 0x48, 0x26, 0x0, 0x1, 0xc4, 0x0, 0x18, 0xb2, 0xbd, 0x1, 0xab, 0x18, - 0x10, 0x66, 0x19, 0x8b, 0xd, 0xc1, 0xbc, 0xc9, 0x11, 0x78, 0xf4, 0x2f, 0x4, 0x7d, 0x97, 0x31, - 0x17, 0xcc, 0xac, 0x9, 0x0, 0x7, 0xc6, 0xf7, 0x25, 0x92, 0xca, 0x27, 0xac, 0x28, 0xff, 0x1c, - 0x0, 0x2, 0x49, 0x40, 0x22, 0x73, 0xad, 0x15, 0x0, 0x4, 0xb1, 0x12, 0x50, 0x1b, 0x15, 0x0, - 0x7, 0x5, 0xa7, 0xd6, 0xb7, 0x4a, 0x9f, 0x75, 0x18, 0x0, 0x0, 0x46, 0x17, 0x0, 0x3, 0x87, - 0xea, 0x1c, 0x2, 0x0, 0x13, 0x6e, 0xb7, 0x39, 0x11, 0x66, 0x0, 0x40, 0xb9, 0xff, 0xb9, 0x71, - 0x71, 0x2, 0x22, 0xad, 0xc, 0x4a, 0xda, 0x1a, 0x1, 0x0, 0x10, 0x80, 0x70, 0xc5, 0x11, 0xa2, - 0xa0, 0xab, 0xab, 0x4b, 0x95, 0xce, 0x20, 0x6, 0x91, 0xca, 0x8e, 0x0}; - - uint8_t buf[134] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x87, 0xea, 0x1c}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6e, 0xb7, 0x39, 0x11, 0x66, 0x0, 0x40, 0xb9, 0xff, 0xb9, - 0x71, 0x71, 0x2, 0x22, 0xad, 0xc, 0x4a, 0xda, 0x1a}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x80, 0x70, 0xc5, 0x11, 0xa2, 0xa0, 0xab, 0xab, - 0x4b, 0x95, 0xce, 0x20, 0x6, 0x91, 0xca, 0x8e}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0}; - uint8_t bytesprops1[] = {0xb2, 0xbd, 0x1, 0xab, 0x18, 0x10, 0x66, 0x19, 0x8b, 0xd, 0xc1, 0xbc, - 0xc9, 0x11, 0x78, 0xf4, 0x2f, 0x4, 0x7d, 0x97, 0x31, 0x17, 0xcc, 0xac}; - uint8_t bytesprops0[] = {0xc4}; - uint8_t bytesprops2[] = {0xc6, 0xf7, 0x25, 0x92, 0xca, 0x27, 0xac}; - uint8_t bytesprops3[] = {0x49, 0x40}; - uint8_t bytesprops4[] = {0xb1, 0x12, 0x50, 0x1b}; - uint8_t bytesprops5[] = {0x5, 0xa7, 0xd6, 0xb7, 0x4a, 0x9f, 0x75}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29613}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17943}}, - }; - - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14083, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 16713 [("\141D\238n\154\164\246$)\214WR\f v\189\185*\139\r\DLE\ESC\135\SOH\164\132",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\185\139@\EM\a\ETX\186\130\FS\DC4\149\129",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS1}),("\139\211\225\252\160\193\136\130\164\243{3h\210\157/\220\156Eg\147l52",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\254\153c\253\205\198H\213\STX\SYN\139d#\249ON\143{\v\NAK3Iwz\EOT|\GS\ESC:^",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSubscriptionIdentifier -// 27,PropSessionExpiryInterval 19874,PropTopicAlias 16501,PropSharedSubscriptionAvailable -// 94,PropAssignedClientIdentifier -// "\135\RS\176~j\DC13G\224\SO6\160\254\v\159\253\169\130\198",PropRequestProblemInformation 64,PropServerReference -// "1b\148\133\SUB\134\165\248\131",PropSharedSubscriptionAvailable 53,PropAuthenticationData -// "I6\144\178w\185\190\n7Y\195\230T",PropSessionExpiryInterval 54,PropTopicAlias 17109] -TEST(Subscribe5QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x41, 0x49, 0x4a, 0xb, 0x1b, 0x11, 0x0, 0x0, 0x4d, 0xa2, 0x23, 0x40, 0x75, 0x2a, - 0x5e, 0x12, 0x0, 0x13, 0x87, 0x1e, 0xb0, 0x7e, 0x6a, 0x11, 0x33, 0x47, 0xe0, 0xe, 0x36, 0xa0, 0xfe, - 0xb, 0x9f, 0xfd, 0xa9, 0x82, 0xc6, 0x17, 0x40, 0x1c, 0x0, 0x9, 0x31, 0x62, 0x94, 0x85, 0x1a, 0x86, - 0xa5, 0xf8, 0x83, 0x2a, 0x35, 0x16, 0x0, 0xd, 0x49, 0x36, 0x90, 0xb2, 0x77, 0xb9, 0xbe, 0xa, 0x37, - 0x59, 0xc3, 0xe6, 0x54, 0x11, 0x0, 0x0, 0x0, 0x36, 0x23, 0x42, 0xd5, 0x0, 0x1a, 0x8d, 0x44, 0xee, - 0x6e, 0x9a, 0xa4, 0xf6, 0x24, 0x29, 0xd6, 0x57, 0x52, 0xc, 0x20, 0x76, 0xbd, 0xb9, 0x2a, 0x8b, 0xd, - 0x10, 0x1b, 0x87, 0x1, 0xa4, 0x84, 0x2, 0x0, 0xc, 0xb9, 0x8b, 0x40, 0x19, 0x7, 0x3, 0xba, 0x82, - 0x1c, 0x14, 0x95, 0x81, 0x1, 0x0, 0x18, 0x8b, 0xd3, 0xe1, 0xfc, 0xa0, 0xc1, 0x88, 0x82, 0xa4, 0xf3, - 0x7b, 0x33, 0x68, 0xd2, 0x9d, 0x2f, 0xdc, 0x9c, 0x45, 0x67, 0x93, 0x6c, 0x35, 0x32, 0x1, 0x0, 0x1e, - 0xfe, 0x99, 0x63, 0xfd, 0xcd, 0xc6, 0x48, 0xd5, 0x2, 0x16, 0x8b, 0x64, 0x23, 0xf9, 0x4f, 0x4e, 0x8f, - 0x7b, 0xb, 0x15, 0x33, 0x49, 0x77, 0x7a, 0x4, 0x7c, 0x1d, 0x1b, 0x3a, 0x5e, 0x2}; - - uint8_t buf[194] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x8d, 0x44, 0xee, 0x6e, 0x9a, 0xa4, 0xf6, 0x24, 0x29, 0xd6, 0x57, 0x52, 0xc, - 0x20, 0x76, 0xbd, 0xb9, 0x2a, 0x8b, 0xd, 0x10, 0x1b, 0x87, 0x1, 0xa4, 0x84}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb9, 0x8b, 0x40, 0x19, 0x7, 0x3, 0xba, 0x82, 0x1c, 0x14, 0x95, 0x81}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8b, 0xd3, 0xe1, 0xfc, 0xa0, 0xc1, 0x88, 0x82, 0xa4, 0xf3, 0x7b, 0x33, - 0x68, 0xd2, 0x9d, 0x2f, 0xdc, 0x9c, 0x45, 0x67, 0x93, 0x6c, 0x35, 0x32}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfe, 0x99, 0x63, 0xfd, 0xcd, 0xc6, 0x48, 0xd5, 0x2, 0x16, - 0x8b, 0x64, 0x23, 0xf9, 0x4f, 0x4e, 0x8f, 0x7b, 0xb, 0x15, - 0x33, 0x49, 0x77, 0x7a, 0x4, 0x7c, 0x1d, 0x1b, 0x3a, 0x5e}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x87, 0x1e, 0xb0, 0x7e, 0x6a, 0x11, 0x33, 0x47, 0xe0, 0xe, - 0x36, 0xa0, 0xfe, 0xb, 0x9f, 0xfd, 0xa9, 0x82, 0xc6}; - uint8_t bytesprops1[] = {0x31, 0x62, 0x94, 0x85, 0x1a, 0x86, 0xa5, 0xf8, 0x83}; - uint8_t bytesprops2[] = {0x49, 0x36, 0x90, 0xb2, 0x77, 0xb9, 0xbe, 0xa, 0x37, 0x59, 0xc3, 0xe6, 0x54}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19874}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16501}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 54}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17109}}, - }; - - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16713, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 25471 [(" -// g\199\217\146\253&\DC3\235\b\186\200\t\171\254\172\FS\140m\DC3\CAN\238F\224\187\190\171\242",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\179hw\206r\aC\GS\159\n\206\SUB\255$mE\EOTm]\210A\224",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("Vd\170\246\&2\v",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\230\130+\153\214\164\236\ENQas\251\192}h)\SOH\ESC{\189=\190\235'w\202\225\&4\223\ACK",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\221\&8F\142\&7\197\DC4\193\151\193@\EOT\151\ACK\146\157\239\149\STX\181\220\148\157\STX\224",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("l\160\229\230\146",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0})] [PropServerKeepAlive 17235,PropSharedSubscriptionAvailable -// 126,PropSubscriptionIdentifierAvailable 74,PropAuthenticationData -// "o\198\221\DC2H4\149>\169\142\223\199$\202\NUL\146\142\SOH\163_",PropSessionExpiryInterval 6247,PropTopicAlias -// 31335,PropAuthenticationData -// "S\244(!\a\EM\137\142\155=9p<\DEL\DC4\SYN\140V\STX\STX\159\198",PropSharedSubscriptionAvailable 146] -TEST(Subscribe5QCTest, Encode25) { - uint8_t pkt[] = { - 0x82, 0xcc, 0x1, 0x63, 0x7f, 0x41, 0x13, 0x43, 0x53, 0x2a, 0x7e, 0x29, 0x4a, 0x16, 0x0, 0x14, 0x6f, 0xc6, 0xdd, - 0x12, 0x48, 0x34, 0x95, 0x3e, 0xa9, 0x8e, 0xdf, 0xc7, 0x24, 0xca, 0x0, 0x92, 0x8e, 0x1, 0xa3, 0x5f, 0x11, 0x0, - 0x0, 0x18, 0x67, 0x23, 0x7a, 0x67, 0x16, 0x0, 0x16, 0x53, 0xf4, 0x28, 0x21, 0x7, 0x19, 0x89, 0x8e, 0x9b, 0x3d, - 0x39, 0x70, 0x3c, 0x7f, 0x14, 0x16, 0x8c, 0x56, 0x2, 0x2, 0x9f, 0xc6, 0x2a, 0x92, 0x0, 0x1c, 0x20, 0x67, 0xc7, - 0xd9, 0x92, 0xfd, 0x26, 0x13, 0xeb, 0x8, 0xba, 0xc8, 0x9, 0xab, 0xfe, 0xac, 0x1c, 0x8c, 0x6d, 0x13, 0x18, 0xee, - 0x46, 0xe0, 0xbb, 0xbe, 0xab, 0xf2, 0x0, 0x0, 0x0, 0x1, 0x0, 0x16, 0xb3, 0x68, 0x77, 0xce, 0x72, 0x7, 0x43, - 0x1d, 0x9f, 0xa, 0xce, 0x1a, 0xff, 0x24, 0x6d, 0x45, 0x4, 0x6d, 0x5d, 0xd2, 0x41, 0xe0, 0x0, 0x0, 0x6, 0x56, - 0x64, 0xaa, 0xf6, 0x32, 0xb, 0x1, 0x0, 0x1d, 0xe6, 0x82, 0x2b, 0x99, 0xd6, 0xa4, 0xec, 0x5, 0x61, 0x73, 0xfb, - 0xc0, 0x7d, 0x68, 0x29, 0x1, 0x1b, 0x7b, 0xbd, 0x3d, 0xbe, 0xeb, 0x27, 0x77, 0xca, 0xe1, 0x34, 0xdf, 0x6, 0x1, - 0x0, 0x19, 0xdd, 0x38, 0x46, 0x8e, 0x37, 0xc5, 0x14, 0xc1, 0x97, 0xc1, 0x40, 0x4, 0x97, 0x6, 0x92, 0x9d, 0xef, - 0x95, 0x2, 0xb5, 0xdc, 0x94, 0x9d, 0x2, 0xe0, 0x1, 0x0, 0x5, 0x6c, 0xa0, 0xe5, 0xe6, 0x92, 0x0}; - - uint8_t buf[217] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x20, 0x67, 0xc7, 0xd9, 0x92, 0xfd, 0x26, 0x13, 0xeb, 0x8, - 0xba, 0xc8, 0x9, 0xab, 0xfe, 0xac, 0x1c, 0x8c, 0x6d, 0x13, - 0x18, 0xee, 0x46, 0xe0, 0xbb, 0xbe, 0xab, 0xf2}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb3, 0x68, 0x77, 0xce, 0x72, 0x7, 0x43, 0x1d, 0x9f, 0xa, 0xce, - 0x1a, 0xff, 0x24, 0x6d, 0x45, 0x4, 0x6d, 0x5d, 0xd2, 0x41, 0xe0}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x56, 0x64, 0xaa, 0xf6, 0x32, 0xb}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe6, 0x82, 0x2b, 0x99, 0xd6, 0xa4, 0xec, 0x5, 0x61, 0x73, - 0xfb, 0xc0, 0x7d, 0x68, 0x29, 0x1, 0x1b, 0x7b, 0xbd, 0x3d, - 0xbe, 0xeb, 0x27, 0x77, 0xca, 0xe1, 0x34, 0xdf, 0x6}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xdd, 0x38, 0x46, 0x8e, 0x37, 0xc5, 0x14, 0xc1, 0x97, 0xc1, 0x40, 0x4, 0x97, - 0x6, 0x92, 0x9d, 0xef, 0x95, 0x2, 0xb5, 0xdc, 0x94, 0x9d, 0x2, 0xe0}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6c, 0xa0, 0xe5, 0xe6, 0x92}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x6f, 0xc6, 0xdd, 0x12, 0x48, 0x34, 0x95, 0x3e, 0xa9, 0x8e, - 0xdf, 0xc7, 0x24, 0xca, 0x0, 0x92, 0x8e, 0x1, 0xa3, 0x5f}; - uint8_t bytesprops1[] = {0x53, 0xf4, 0x28, 0x21, 0x7, 0x19, 0x89, 0x8e, 0x9b, 0x3d, 0x39, - 0x70, 0x3c, 0x7f, 0x14, 0x16, 0x8c, 0x56, 0x2, 0x2, 0x9f, 0xc6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17235}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6247}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31335}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 146}}, - }; - - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25471, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 10657 [("\ENQ4\f\143\197\ENQ\145\193\247\141\221i\199\192\173\223",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\188\156\DC3\177\134%\161",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\\\222\217\&5\226r",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\176c\ESCP\163\GSx\DC3",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("G\ENQ\204\136\fTN\163\214\228\254eHG\166\CAN\210\146>",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\172\144=\175\\\ESC\f\226\179v\175\164D$R9\211",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("S\242\171\242\STX\221\188uJ\199l\155\137\232\\\135\187\141\SYN\217",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\NAK\205\STX\156\ENQ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\161\200eM1\161*\234\207\198\169\252.\DC2nE\230\227HE8\135\164\244",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("al}\149\EOT(\233\DLE\STX\233\208\183ui-F\t",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropTopicAliasMaximum 29858,PropServerReference -// "]9\CAN\DC3\197\217E\197_g\206\202.pF\203k\211",PropPayloadFormatIndicator 191,PropTopicAliasMaximum -// 6452,PropServerReference "t\216\160\150~",PropTopicAlias 5241,PropTopicAlias 29173,PropSharedSubscriptionAvailable -// 168,PropMaximumPacketSize 3240,PropSubscriptionIdentifierAvailable 206,PropUserProperty -// ":\232\199\223v'\194\209\SUB\253\171" "Ek\GS\169\133\ACK\DC4\v\176~E",PropAssignedClientIdentifier -// "\NAK\NAK\190.v\156\229\136\FSN\249\212T\134\231\218\152#K",PropReasonString "\NAK\DELI",PropResponseInformation -// "\ESC\251\217,\228\a\183N\194\132\&4\154\226y\NUL\133\192L)#M\ENQ\140xX\SYN4\212\204",PropMaximumPacketSize -// 27146,PropTopicAlias 1220,PropMessageExpiryInterval 612,PropContentType -// "Bf\GS\207\180\DC4\US\201\229o\232\212\209\251\251$U)\DLE\134\SYN\DC3\227\149W@\STX",PropSessionExpiryInterval -// 13945,PropAuthenticationMethod -// "^\139B\228L\STXt\142R\228a\197\194\137\160\&2\177\181\192\tjY\190\148\SI",PropMaximumPacketSize -// 10669,PropUserProperty "\158\201H\153\198\246Q" -// "\a\245\233\150\t\t\NUL\155\219\159[\240\140\226\n",PropAuthenticationData "S"] -TEST(Subscribe5QCTest, Encode26) { - uint8_t pkt[] = { - 0x82, 0xa8, 0x3, 0x29, 0xa1, 0xfb, 0x1, 0x22, 0x74, 0xa2, 0x1c, 0x0, 0x12, 0x5d, 0x39, 0x18, 0x13, 0xc5, 0xd9, - 0x45, 0xc5, 0x5f, 0x67, 0xce, 0xca, 0x2e, 0x70, 0x46, 0xcb, 0x6b, 0xd3, 0x1, 0xbf, 0x22, 0x19, 0x34, 0x1c, 0x0, - 0x5, 0x74, 0xd8, 0xa0, 0x96, 0x7e, 0x23, 0x14, 0x79, 0x23, 0x71, 0xf5, 0x2a, 0xa8, 0x27, 0x0, 0x0, 0xc, 0xa8, - 0x29, 0xce, 0x26, 0x0, 0xb, 0x3a, 0xe8, 0xc7, 0xdf, 0x76, 0x27, 0xc2, 0xd1, 0x1a, 0xfd, 0xab, 0x0, 0xb, 0x45, - 0x6b, 0x1d, 0xa9, 0x85, 0x6, 0x14, 0xb, 0xb0, 0x7e, 0x45, 0x12, 0x0, 0x13, 0x15, 0x15, 0xbe, 0x2e, 0x76, 0x9c, - 0xe5, 0x88, 0x1c, 0x4e, 0xf9, 0xd4, 0x54, 0x86, 0xe7, 0xda, 0x98, 0x23, 0x4b, 0x1f, 0x0, 0x3, 0x15, 0x7f, 0x49, - 0x1a, 0x0, 0x1d, 0x1b,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0x13, 0x1, 0x0, 0x13, 0x47, 0x5, 0xcc, 0x88, 0xc, 0x54, 0x4e, 0xa3, 0xd6, 0xe4, 0xfe, 0x65, 0x48, 0x47, - 0xa6, 0x18, 0xd2, 0x92, 0x3e, 0x1, 0x0, 0x11, 0xac, 0x90, 0x3d, 0xaf, 0x5c, 0x1b, 0xc, 0xe2, 0xb3, 0x76, 0xaf, - 0xa4, 0x44, 0x24, 0x52, 0x39, 0xd3, 0x1, 0x0, 0x14, 0x53, 0xf2, 0xab, 0xf2, 0x2, 0xdd, 0xbc, 0x75, 0x4a, 0xc7, - 0x6c, 0x9b, 0x89, 0xe8, 0x5c, 0x87, 0xbb, 0x8d, 0x16, 0xd9, 0x1, 0x0, 0x5, 0x15, 0xcd, 0x2, 0x9c, 0x5, 0x1, - 0x0, 0x18, 0xa1, 0xc8, 0x65, 0x4d, 0x31, 0xa1, 0x2a, 0xea, 0xcf, 0xc6, 0xa9, 0xfc, 0x2e, 0x12, 0x6e, 0x45, 0xe6, - 0xe3, 0x48, 0x45, 0x38, 0x87, 0xa4, 0xf4, 0x1, 0x0, 0x11, 0x61, 0x6c, 0x7d, 0x95, 0x4, 0x28, 0xe9, 0x10, 0x2, - 0xe9, 0xd0, 0xb7, 0x75, 0x69, 0x2d, 0x46, 0x9, 0x2}; - - uint8_t buf[437] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x5, 0x34, 0xc, 0x8f, 0xc5, 0x5, 0x91, 0xc1, - 0xf7, 0x8d, 0xdd, 0x69, 0xc7, 0xc0, 0xad, 0xdf}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbc, 0x9c, 0x13, 0xb1, 0x86, 0x25, 0xa1}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5c, 0xde, 0xd9, 0x35, 0xe2, 0x72}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb0, 0x63, 0x1b, 0x50, 0xa3, 0x1d, 0x78, 0x13}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x47, 0x5, 0xcc, 0x88, 0xc, 0x54, 0x4e, 0xa3, 0xd6, 0xe4, - 0xfe, 0x65, 0x48, 0x47, 0xa6, 0x18, 0xd2, 0x92, 0x3e}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xac, 0x90, 0x3d, 0xaf, 0x5c, 0x1b, 0xc, 0xe2, 0xb3, - 0x76, 0xaf, 0xa4, 0x44, 0x24, 0x52, 0x39, 0xd3}; - lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x53, 0xf2, 0xab, 0xf2, 0x2, 0xdd, 0xbc, 0x75, 0x4a, 0xc7, - 0x6c, 0x9b, 0x89, 0xe8, 0x5c, 0x87, 0xbb, 0x8d, 0x16, 0xd9}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x15, 0xcd, 0x2, 0x9c, 0x5}; - lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa1, 0xc8, 0x65, 0x4d, 0x31, 0xa1, 0x2a, 0xea, 0xcf, 0xc6, 0xa9, 0xfc, - 0x2e, 0x12, 0x6e, 0x45, 0xe6, 0xe3, 0x48, 0x45, 0x38, 0x87, 0xa4, 0xf4}; - lwmqtt_string_t topic_filter_s8 = {24, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x61, 0x6c, 0x7d, 0x95, 0x4, 0x28, 0xe9, 0x10, 0x2, - 0xe9, 0xd0, 0xb7, 0x75, 0x69, 0x2d, 0x46, 0x9}; - lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x5d, 0x39, 0x18, 0x13, 0xc5, 0xd9, 0x45, 0xc5, 0x5f, - 0x67, 0xce, 0xca, 0x2e, 0x70, 0x46, 0xcb, 0x6b, 0xd3}; - uint8_t bytesprops1[] = {0x74, 0xd8, 0xa0, 0x96, 0x7e}; - uint8_t bytesprops3[] = {0x45, 0x6b, 0x1d, 0xa9, 0x85, 0x6, 0x14, 0xb, 0xb0, 0x7e, 0x45}; - uint8_t bytesprops2[] = {0x3a, 0xe8, 0xc7, 0xdf, 0x76, 0x27, 0xc2, 0xd1, 0x1a, 0xfd, 0xab}; - uint8_t bytesprops4[] = {0x15, 0x15, 0xbe, 0x2e, 0x76, 0x9c, 0xe5, 0x88, 0x1c, 0x4e, - 0xf9, 0xd4, 0x54, 0x86, 0xe7, 0xda, 0x98, 0x23, 0x4b}; - uint8_t bytesprops5[] = {0x15, 0x7f, 0x49}; - uint8_t bytesprops6[] = {0x1b, 0xfb, 0xd9, 0x2c, 0xe4, 0x7, 0xb7, 0x4e, 0xc2, 0x84, 0x34, 0x9a, 0xe2, 0x79, 0x0, - 0x85, 0xc0, 0x4c, 0x29, 0x23, 0x4d, 0x5, 0x8c, 0x78, 0x58, 0x16, 0x34, 0xd4, 0xcc}; - uint8_t bytesprops7[] = {0x42, 0x66, 0x1d, 0xcf, 0xb4, 0x14, 0x1f, 0xc9, 0xe5, 0x6f, 0xe8, 0xd4, 0xd1, 0xfb, - 0xfb, 0x24, 0x55, 0x29, 0x10, 0x86, 0x16, 0x13, 0xe3, 0x95, 0x57, 0x40, 0x2}; - uint8_t bytesprops8[] = {0x5e, 0x8b, 0x42, 0xe4, 0x4c, 0x2, 0x74, 0x8e, 0x52, 0xe4, 0x61, 0xc5, 0xc2, - 0x89, 0xa0, 0x32, 0xb1, 0xb5, 0xc0, 0x9, 0x6a, 0x59, 0xbe, 0x94, 0xf}; - uint8_t bytesprops10[] = {0x7, 0xf5, 0xe9, 0x96, 0x9, 0x9, 0x0, 0x9b, 0xdb, 0x9f, 0x5b, 0xf0, 0x8c, 0xe2, 0xa}; - uint8_t bytesprops9[] = {0x9e, 0xc9, 0x48, 0x99, 0xc6, 0xf6, 0x51}; - uint8_t bytesprops11[] = {0x53}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29858}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6452}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5241}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29173}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3240}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27146}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1220}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 612}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13945}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10669}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops9}, .v = {15, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops11}}}, - }; - - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10657, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 15036 [("\ETB\177\238\199$\NUL\128\209",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("3r:\DC1c[upm\234_c`\195V\252C\vu\153\196",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("g\238\250",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("\183\236\166\159+\v\b\SI\149\DC2\247\&1",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ESCd\242\134N\161i\169\135\230\198m\163\166\229\247e\211E",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("Y\216\242f(\ETX=\152\ESC\208?B|\197\n\198Z\148\153\199\f\r\\n5\137#4",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty "\DLE\DLE\177\184 -// \237{\223\SUBR\b\153=j;" "\\\172\155\241c]\132g`_\227aO\SO1\167\"\238\RSy",PropPayloadFormatIndicator -// 213,PropSessionExpiryInterval 24785,PropMaximumQoS 239,PropMaximumQoS 27,PropSubscriptionIdentifier -// 28,PropMaximumPacketSize 7341,PropRequestResponseInformation 196,PropMessageExpiryInterval -// 25044,PropAssignedClientIdentifier -// "\129\225=\207.UC\165*)\160\184\197\a\r\213H\EOT\202\&2\163\249u*",PropUserProperty -// "\138Z&\167\EM\219\DEL\218\234\243\FS\231\224\248z" -// "\FS\152\&8\US\230\153\150\175\238`\211\161R\DLE\DC1\"\209\&4\209wm\174k\239V",PropWildcardSubscriptionAvailable -// 234,PropResponseInformation ""] -TEST(Subscribe5QCTest, Encode27) { - uint8_t pkt[] = { - 0x82, 0xff, 0x1, 0x3a, 0xbc, 0x8e, 0x1, 0x26, 0x0, 0xf, 0x10, 0x10, 0xb1, 0xb8, 0x20, 0xed, 0x7b, 0xdf, 0x1a, - 0x52, 0x8, 0x99, 0x3d, 0x6a, 0x3b, 0x0, 0x14, 0x5c, 0xac, 0x9b, 0xf1, 0x63, 0x5d, 0x84, 0x67, 0x60, 0x5f, 0xe3, - 0x61, 0x4f, 0xe, 0x31, 0xa7, 0x22, 0xee, 0x1e, 0x79, 0x1, 0xd5, 0x11, 0x0, 0x0, 0x60, 0xd1, 0x24, 0xef, 0x24, - 0x1b, 0xb, 0x1c, 0x27, 0x0, 0x0, 0x1c, 0xad, 0x19, 0xc4, 0x2, 0x0, 0x0, 0x61, 0xd4, 0x12, 0x0, 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; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x17, 0xb1, 0xee, 0xc7, 0x24, 0x0, 0x80, 0xd1}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x33, 0x72, 0x3a, 0x11, 0x63, 0x5b, 0x75, 0x70, 0x6d, 0xea, 0x5f, - 0x63, 0x60, 0xc3, 0x56, 0xfc, 0x43, 0xb, 0x75, 0x99, 0xc4}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x67, 0xee, 0xfa}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb7, 0xec, 0xa6, 0x9f, 0x2b, 0xb, 0x8, 0xf, 0x95, 0x12, 0xf7, 0x31}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x1b, 0x64, 0xf2, 0x86, 0x4e, 0xa1, 0x69, 0xa9, 0x87, 0xe6, - 0xc6, 0x6d, 0xa3, 0xa6, 0xe5, 0xf7, 0x65, 0xd3, 0x45}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x59, 0xd8, 0xf2, 0x66, 0x28, 0x3, 0x3d, 0x98, 0x1b, 0xd0, - 0x3f, 0x42, 0x7c, 0xc5, 0xa, 0xc6, 0x5a, 0x94, 0x99, 0xc7, - 0xc, 0xd, 0x5c, 0x6e, 0x35, 0x89, 0x23, 0x34}; - lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops1[] = {0x5c, 0xac, 0x9b, 0xf1, 0x63, 0x5d, 0x84, 0x67, 0x60, 0x5f, - 0xe3, 0x61, 0x4f, 0xe, 0x31, 0xa7, 0x22, 0xee, 0x1e, 0x79}; - uint8_t bytesprops0[] = {0x10, 0x10, 0xb1, 0xb8, 0x20, 0xed, 0x7b, 0xdf, 0x1a, 0x52, 0x8, 0x99, 0x3d, 0x6a, 0x3b}; - uint8_t bytesprops2[] = {0x81, 0xe1, 0x3d, 0xcf, 0x2e, 0x55, 0x43, 0xa5, 0x2a, 0x29, 0xa0, 0xb8, - 0xc5, 0x7, 0xd, 0xd5, 0x48, 0x4, 0xca, 0x32, 0xa3, 0xf9, 0x75, 0x2a}; - uint8_t bytesprops4[] = {0x1c, 0x98, 0x38, 0x1f, 0xe6, 0x99, 0x96, 0xaf, 0xee, 0x60, 0xd3, 0xa1, 0x52, - 0x10, 0x11, 0x22, 0xd1, 0x34, 0xd1, 0x77, 0x6d, 0xae, 0x6b, 0xef, 0x56}; - uint8_t bytesprops3[] = {0x8a, 0x5a, 0x26, 0xa7, 0x19, 0xdb, 0x7f, 0xda, 0xea, 0xf3, 0x1c, 0xe7, 0xe0, 0xf8, 0x7a}; - uint8_t bytesprops5[] = {0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24785}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7341}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25044}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops3}, .v = {25, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15036, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2876 [("\143\161\221\224\191",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("rT\145\ay\160\215s,\146c\129\150>@!/\217\141",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\r\184\142p\151\204\170\249\180/\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\235\167\DLE\217\198\169\175\SI\182\ESC",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("G\130\214\&0\b\EM/\194\249\193\148`\222\217\ETXQZ\251\&7\n\147k\254\158t\249\130\219-E",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\SO\205\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("\175\GS\210~\190\GS\178\&9\230=\236|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\213\RSA\148\250i2Cbmo\147D\254\170\&33p\218\CAN\232\206\SO\142\&7",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\169\DEL\233~\135W\168q\226\158\197\227\151}9",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropCorrelationData -// "\177\207\186!\SUB\162\215\147X\144",PropWildcardSubscriptionAvailable 78,PropResponseInformation -// "[\NAK\229M",PropSubscriptionIdentifierAvailable 176,PropTopicAlias 10740,PropPayloadFormatIndicator -// 225,PropWildcardSubscriptionAvailable 1,PropSharedSubscriptionAvailable 127,PropResponseInformation -// "\ENQ\229\169\159Q\161\r6\245\220\&4",PropRequestResponseInformation 127] -TEST(Subscribe5QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0xd4, 0x1, 0xb, 0x3c, 0x31, 0x9, 0x0, 0xa, 0xb1, 0xcf, 0xba, 0x21, 0x1a, 0xa2, 0xd7, 0x93, - 0x58, 0x90, 0x28, 0x4e, 0x1a, 0x0, 0x4, 0x5b, 0x15, 0xe5, 0x4d, 0x29, 0xb0, 0x23, 0x29, 0xf4, 0x1, - 0xe1, 0x28, 0x1, 0x2a, 0x7f, 0x1a, 0x0, 0xb, 0x5, 0xe5, 0xa9, 0x9f, 0x51, 0xa1, 0xd, 0x36, 0xf5, - 0xdc, 0x34, 0x19, 0x7f, 0x0, 0x5, 0x8f, 0xa1, 0xdd, 0xe0, 0xbf, 0x1, 0x0, 0x13, 0x72, 0x54, 0x91, - 0x7, 0x79, 0xa0, 0xd7, 0x73, 0x2c, 0x92, 0x63, 0x81, 0x96, 0x3e, 0x40, 0x21, 0x2f, 0xd9, 0x8d, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xb, 0xd, 0xb8, 0x8e, 0x70, 0x97, 0xcc, 0xaa, 0xf9, 0xb4, 0x2f, 0xd2, 0x1, - 0x0, 0xa, 0xeb, 0xa7, 0x10, 0xd9, 0xc6, 0xa9, 0xaf, 0xf, 0xb6, 0x1b, 0x1, 0x0, 0x1e, 0x47, 0x82, - 0xd6, 0x30, 0x8, 0x19, 0x2f, 0xc2, 0xf9, 0xc1, 0x94, 0x60, 0xde, 0xd9, 0x3, 0x51, 0x5a, 0xfb, 0x37, - 0xa, 0x93, 0x6b, 0xfe, 0x9e, 0x74, 0xf9, 0x82, 0xdb, 0x2d, 0x45, 0x0, 0x0, 0x3, 0xe, 0xcd, 0xce, - 0x2, 0x0, 0xc, 0xaf, 0x1d, 0xd2, 0x7e, 0xbe, 0x1d, 0xb2, 0x39, 0xe6, 0x3d, 0xec, 0x7c, 0x2, 0x0, - 0x19, 0xd5, 0x1e, 0x41, 0x94, 0xfa, 0x69, 0x32, 0x43, 0x62, 0x6d, 0x6f, 0x93, 0x44, 0xfe, 0xaa, 0x33, - 0x33, 0x70, 0xda, 0x18, 0xe8, 0xce, 0xe, 0x8e, 0x37, 0x1, 0x0, 0xf, 0xa9, 0x7f, 0xe9, 0x7e, 0x87, - 0x57, 0xa8, 0x71, 0xe2, 0x9e, 0xc5, 0xe3, 0x97, 0x7d, 0x39, 0x2}; - - uint8_t buf[225] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x8f, 0xa1, 0xdd, 0xe0, 0xbf}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x72, 0x54, 0x91, 0x7, 0x79, 0xa0, 0xd7, 0x73, 0x2c, 0x92, - 0x63, 0x81, 0x96, 0x3e, 0x40, 0x21, 0x2f, 0xd9, 0x8d}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd, 0xb8, 0x8e, 0x70, 0x97, 0xcc, 0xaa, 0xf9, 0xb4, 0x2f, 0xd2}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xeb, 0xa7, 0x10, 0xd9, 0xc6, 0xa9, 0xaf, 0xf, 0xb6, 0x1b}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x47, 0x82, 0xd6, 0x30, 0x8, 0x19, 0x2f, 0xc2, 0xf9, 0xc1, - 0x94, 0x60, 0xde, 0xd9, 0x3, 0x51, 0x5a, 0xfb, 0x37, 0xa, - 0x93, 0x6b, 0xfe, 0x9e, 0x74, 0xf9, 0x82, 0xdb, 0x2d, 0x45}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xe, 0xcd, 0xce}; - lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xaf, 0x1d, 0xd2, 0x7e, 0xbe, 0x1d, 0xb2, 0x39, 0xe6, 0x3d, 0xec, 0x7c}; - lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd5, 0x1e, 0x41, 0x94, 0xfa, 0x69, 0x32, 0x43, 0x62, 0x6d, 0x6f, 0x93, 0x44, - 0xfe, 0xaa, 0x33, 0x33, 0x70, 0xda, 0x18, 0xe8, 0xce, 0xe, 0x8e, 0x37}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa9, 0x7f, 0xe9, 0x7e, 0x87, 0x57, 0xa8, 0x71, - 0xe2, 0x9e, 0xc5, 0xe3, 0x97, 0x7d, 0x39}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0xb1, 0xcf, 0xba, 0x21, 0x1a, 0xa2, 0xd7, 0x93, 0x58, 0x90}; - uint8_t bytesprops1[] = {0x5b, 0x15, 0xe5, 0x4d}; - uint8_t bytesprops2[] = {0x5, 0xe5, 0xa9, 0x9f, 0x51, 0xa1, 0xd, 0x36, 0xf5, 0xdc, 0x34}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10740}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 127}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2876, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 30960 [("\185\236\245\223\167kV\209\203\206v",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("`\208\168\173\228W\128\NUL\ESC\220\215\244'8\132 -// \151\&8\151\138\SO\228g",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\196b\128&>\147\253\195D\218\SI\NAK\EOT\ETBV\195\140\"s\215\166Z:9",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("=|\155\128\168\238V\248\201^w7\200+\247\FS\194\185\218\184",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty "\149" -// "\247\196\167(\a8\153M\220l\USq\252R\182[",PropWildcardSubscriptionAvailable 231,PropTopicAlias 32292,PropContentType -// "i\CANt\218\SIGE\189\158\211`\130\195\240M15.a\250\135$",PropAuthenticationData -// "\131\239B\132\161W\226\&88\187\228\191\DC4\200\209\NAKr\249",PropPayloadFormatIndicator 255,PropUserProperty -// "\175\231\176\254\238\r\145\SIDk\CAN[\157\153l\185\146\254\184\238\218\SI\134\244\ETXM" -// "\253\140\167H\b",PropAuthenticationMethod "\182\190\172\245k)\163PB\253",PropWillDelayInterval -// 27287,PropRetainAvailable 119,PropServerReference -// "l\r\149\216\138\253\166\209z\f\230\DEL[\195\236\169\FS\250",PropSharedSubscriptionAvailable -// 23,PropRequestProblemInformation 121,PropResponseTopic -// "|81`lO\243\&8d\227\SI\169\176`\248\246\239:-7\193?\137B8\CAN\172p\205",PropSubscriptionIdentifier -// 14,PropPayloadFormatIndicator 208,PropMessageExpiryInterval 26592,PropContentType -// "%]\187\SI\207\153\181\169",PropMessageExpiryInterval 19734,PropAuthenticationMethod -// "\RS\231\216\STXEz\172\208Le\188\&2\RS\132He\185",PropCorrelationData -// "|d<\DC44\161uC\143\209\248\DEL5)\225V\251@\235\160\240\210m<>a\166\&5F",PropMessageExpiryInterval -// 27232,PropAuthenticationData -// "\226\166a\147E\132S\247\128\205_\247\169\152\&68\131\171\DC4\DC3\ACKng=\169L\230\&1\161",PropMaximumPacketSize -// 22761,PropMessageExpiryInterval 11220] -TEST(Subscribe5QCTest, Encode29) { - uint8_t pkt[] = { - 0x82, 0x99, 0x3, 0x78, 0xf0, 0xb8, 0x2, 0x26, 0x0, 0x1, 0x95, 0x0, 0x10, 0xf7, 0xc4, 0xa7, 0x28, 0x7, 0x38, - 0x99, 0x4d, 0xdc, 0x6c, 0x1f, 0x71, 0xfc, 0x52, 0xb6, 0x5b, 0x28, 0xe7, 0x23, 0x7e, 0x24, 0x3, 0x0, 0x16, 0x69, - 0x18, 0x74, 0xda, 0xf, 0x47, 0x45, 0xbd, 0x9e, 0xd3, 0x60, 0x82, 0xc3, 0xf0, 0x4d, 0x31, 0x35, 0x2e, 0x61, 0xfa, - 0x87, 0x24, 0x16, 0x0, 0x12, 0x83, 0xef, 0x42, 0x84, 0xa1, 0x57, 0xe2, 0x38, 0x38, 0xbb, 0xe4, 0xbf, 0x14, 0xc8, - 0xd1, 0x15, 0x72, 0xf9, 0x1, 0xff, 0x26, 0x0, 0x1a, 0xaf, 0xe7, 0xb0, 0xfe, 0xee, 0xd, 0x91, 0xf, 0x44, 0x6b, - 0x18, 0x5b, 0x9d, 0x99, 0x6c, 0xb9, 0x92, 0xfe, 0xb8, 0xee, 0xda, 0xf, 0x86, 0xf4, 0x3, 0x4d, 0x0, 0x5, 0xfd, - 0x8c, 0xa7, 0x48, 0x8, 0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xa9, 0x4c, 0xe6, 0x31, 0xa1, 0x27, 0x0, 0x0, 0x58, 0xe9, 0x2, 0x0, 0x0, 0x2b, 0xd4, 0x0, 0xb, 0xb9, 0xec, - 0xf5, 0xdf, 0xa7, 0x6b, 0x56, 0xd1, 0xcb, 0xce, 0x76, 0x1, 0x0, 0x0, 0x2, 0x0, 0x17, 0x60, 0xd0, 0xa8, 0xad, - 0xe4, 0x57, 0x80, 0x0, 0x1b, 0xdc, 0xd7, 0xf4, 0x27, 0x38, 0x84, 0x20, 0x97, 0x38, 0x97, 0x8a, 0xe, 0xe4, 0x67, - 0x1, 0x0, 0x18, 0xc4, 0x62, 0x80, 0x26, 0x3e, 0x93, 0xfd, 0xc3, 0x44, 0xda, 0xf, 0x15, 0x4, 0x17, 0x56, 0xc3, - 0x8c, 0x22, 0x73, 0xd7, 0xa6, 0x5a, 0x3a, 0x39, 0x2, 0x0, 0x14, 0x3d, 0x7c, 0x9b, 0x80, 0xa8, 0xee, 0x56, 0xf8, - 0xc9, 0x5e, 0x77, 0x37, 0xc8, 0x2b, 0xf7, 0x1c, 0xc2, 0xb9, 0xda, 0xb8, 0x1}; - - uint8_t buf[422] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xb9, 0xec, 0xf5, 0xdf, 0xa7, 0x6b, 0x56, 0xd1, 0xcb, 0xce, 0x76}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x60, 0xd0, 0xa8, 0xad, 0xe4, 0x57, 0x80, 0x0, 0x1b, 0xdc, 0xd7, 0xf4, - 0x27, 0x38, 0x84, 0x20, 0x97, 0x38, 0x97, 0x8a, 0xe, 0xe4, 0x67}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc4, 0x62, 0x80, 0x26, 0x3e, 0x93, 0xfd, 0xc3, 0x44, 0xda, 0xf, 0x15, - 0x4, 0x17, 0x56, 0xc3, 0x8c, 0x22, 0x73, 0xd7, 0xa6, 0x5a, 0x3a, 0x39}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x3d, 0x7c, 0x9b, 0x80, 0xa8, 0xee, 0x56, 0xf8, 0xc9, 0x5e, - 0x77, 0x37, 0xc8, 0x2b, 0xf7, 0x1c, 0xc2, 0xb9, 0xda, 0xb8}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops1[] = {0xf7, 0xc4, 0xa7, 0x28, 0x7, 0x38, 0x99, 0x4d, - 0xdc, 0x6c, 0x1f, 0x71, 0xfc, 0x52, 0xb6, 0x5b}; - uint8_t bytesprops0[] = {0x95}; - uint8_t bytesprops2[] = {0x69, 0x18, 0x74, 0xda, 0xf, 0x47, 0x45, 0xbd, 0x9e, 0xd3, 0x60, - 0x82, 0xc3, 0xf0, 0x4d, 0x31, 0x35, 0x2e, 0x61, 0xfa, 0x87, 0x24}; - uint8_t bytesprops3[] = {0x83, 0xef, 0x42, 0x84, 0xa1, 0x57, 0xe2, 0x38, 0x38, - 0xbb, 0xe4, 0xbf, 0x14, 0xc8, 0xd1, 0x15, 0x72, 0xf9}; - uint8_t bytesprops5[] = {0xfd, 0x8c, 0xa7, 0x48, 0x8}; - uint8_t bytesprops4[] = {0xaf, 0xe7, 0xb0, 0xfe, 0xee, 0xd, 0x91, 0xf, 0x44, 0x6b, 0x18, 0x5b, 0x9d, - 0x99, 0x6c, 0xb9, 0x92, 0xfe, 0xb8, 0xee, 0xda, 0xf, 0x86, 0xf4, 0x3, 0x4d}; - uint8_t bytesprops6[] = {0xb6, 0xbe, 0xac, 0xf5, 0x6b, 0x29, 0xa3, 0x50, 0x42, 0xfd}; - uint8_t bytesprops7[] = {0x6c, 0xd, 0x95, 0xd8, 0x8a, 0xfd, 0xa6, 0xd1, 0x7a, - 0xc, 0xe6, 0x7f, 0x5b, 0xc3, 0xec, 0xa9, 0x1c, 0xfa}; - uint8_t bytesprops8[] = {0x7c, 0x38, 0x31, 0x60, 0x6c, 0x4f, 0xf3, 0x38, 0x64, 0xe3, 0xf, 0xa9, 0xb0, 0x60, 0xf8, - 0xf6, 0xef, 0x3a, 0x2d, 0x37, 0xc1, 0x3f, 0x89, 0x42, 0x38, 0x18, 0xac, 0x70, 0xcd}; - uint8_t bytesprops9[] = {0x25, 0x5d, 0xbb, 0xf, 0xcf, 0x99, 0xb5, 0xa9}; - uint8_t bytesprops10[] = {0x1e, 0xe7, 0xd8, 0x2, 0x45, 0x7a, 0xac, 0xd0, 0x4c, - 0x65, 0xbc, 0x32, 0x1e, 0x84, 0x48, 0x65, 0xb9}; - uint8_t bytesprops11[] = {0x7c, 0x64, 0x3c, 0x14, 0x34, 0xa1, 0x75, 0x43, 0x8f, 0xd1, 0xf8, 0x7f, 0x35, 0x29, 0xe1, - 0x56, 0xfb, 0x40, 0xeb, 0xa0, 0xf0, 0xd2, 0x6d, 0x3c, 0x3e, 0x61, 0xa6, 0x35, 0x46}; - uint8_t bytesprops12[] = {0xe2, 0xa6, 0x61, 0x93, 0x45, 0x84, 0x53, 0xf7, 0x80, 0xcd, 0x5f, 0xf7, 0xa9, 0x98, 0x36, - 0x38, 0x83, 0xab, 0x14, 0x13, 0x6, 0x6e, 0x67, 0x3d, 0xa9, 0x4c, 0xe6, 0x31, 0xa1}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32292}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops4}, .v = {5, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27287}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26592}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19734}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27232}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22761}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11220}}, - }; - - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30960, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 19821 [("\162",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\200\151\208c\FS\228\171\229\143c\210\no\DC1F(\147w\158",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("w\206\216e\255h\237\252\178.",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\196)\168x0\242\199\SI\251\223L\150\183\234\205\197\137`\215'\aD\164\EOT5\148\ETB\189",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropAuthenticationMethod -// "x\205\226K\169ZM\228\155,w\FS\a\193n\192\225N\251\166\241\230\159\172\249\144",PropSharedSubscriptionAvailable -// 169,PropWildcardSubscriptionAvailable 229,PropReceiveMaximum 27247,PropSharedSubscriptionAvailable 7,PropTopicAlias -// 6098,PropWillDelayInterval 7011,PropResponseTopic "\ENQR]\202\145\167\246\253\199",PropAssignedClientIdentifier -// "\196\163>\154q<\245\182\NAK\155\254,\137MQ\234\190h\SYN",PropServerKeepAlive 28601] -TEST(Subscribe5QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x9c, 0x1, 0x4d, 0x6d, 0x53, 0x15, 0x0, 0x1a, 0x78, 0xcd, 0xe2, 0x4b, 0xa9, 0x5a, 0x4d, - 0xe4, 0x9b, 0x2c, 0x77, 0x1c, 0x7, 0xc1, 0x6e, 0xc0, 0xe1, 0x4e, 0xfb, 0xa6, 0xf1, 0xe6, 0x9f, - 0xac, 0xf9, 0x90, 0x2a, 0xa9, 0x28, 0xe5, 0x21, 0x6a, 0x6f, 0x2a, 0x7, 0x23, 0x17, 0xd2, 0x18, - 0x0, 0x0, 0x1b, 0x63, 0x8, 0x0, 0x9, 0x5, 0x52, 0x5d, 0xca, 0x91, 0xa7, 0xf6, 0xfd, 0xc7, - 0x12, 0x0, 0x13, 0xc4, 0xa3, 0x3e, 0x9a, 0x71, 0x3c, 0xf5, 0xb6, 0x15, 0x9b, 0xfe, 0x2c, 0x89, - 0x4d, 0x51, 0xea, 0xbe, 0x68, 0x16, 0x13, 0x6f, 0xb9, 0x0, 0x1, 0xa2, 0x2, 0x0, 0x13, 0xc8, - 0x97, 0xd0, 0x63, 0x1c, 0xe4, 0xab, 0xe5, 0x8f, 0x63, 0xd2, 0xa, 0x6f, 0x11, 0x46, 0x28, 0x93, - 0x77, 0x9e, 0x1, 0x0, 0xa, 0x77, 0xce, 0xd8, 0x65, 0xff, 0x68, 0xed, 0xfc, 0xb2, 0x2e, 0x2, - 0x0, 0x1c, 0xc4, 0x29, 0xa8, 0x78, 0x30, 0xf2, 0xc7, 0xf, 0xfb, 0xdf, 0x4c, 0x96, 0xb7, 0xea, - 0xcd, 0xc5, 0x89, 0x60, 0xd7, 0x27, 0x7, 0x44, 0xa4, 0x4, 0x35, 0x94, 0x17, 0xbd, 0x2}; - - uint8_t buf[169] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xa2}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc8, 0x97, 0xd0, 0x63, 0x1c, 0xe4, 0xab, 0xe5, 0x8f, 0x63, - 0xd2, 0xa, 0x6f, 0x11, 0x46, 0x28, 0x93, 0x77, 0x9e}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x77, 0xce, 0xd8, 0x65, 0xff, 0x68, 0xed, 0xfc, 0xb2, 0x2e}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc4, 0x29, 0xa8, 0x78, 0x30, 0xf2, 0xc7, 0xf, 0xfb, 0xdf, - 0x4c, 0x96, 0xb7, 0xea, 0xcd, 0xc5, 0x89, 0x60, 0xd7, 0x27, - 0x7, 0x44, 0xa4, 0x4, 0x35, 0x94, 0x17, 0xbd}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x78, 0xcd, 0xe2, 0x4b, 0xa9, 0x5a, 0x4d, 0xe4, 0x9b, 0x2c, 0x77, 0x1c, 0x7, - 0xc1, 0x6e, 0xc0, 0xe1, 0x4e, 0xfb, 0xa6, 0xf1, 0xe6, 0x9f, 0xac, 0xf9, 0x90}; - uint8_t bytesprops1[] = {0x5, 0x52, 0x5d, 0xca, 0x91, 0xa7, 0xf6, 0xfd, 0xc7}; - uint8_t bytesprops2[] = {0xc4, 0xa3, 0x3e, 0x9a, 0x71, 0x3c, 0xf5, 0xb6, 0x15, 0x9b, - 0xfe, 0x2c, 0x89, 0x4d, 0x51, 0xea, 0xbe, 0x68, 0x16}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27247}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6098}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7011}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28601}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19821, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 21770 -// [("\139=b\145p\157\223b|\STX[\197\203\167e^\171\235\151}k\149\EOT\132\SO\239\218\159\152",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ACK\227+\134\ETB\170\253\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\148-\198\ACKO:X\191\162",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\128\150\&7\b\f^g\182Dr\t8k\240\170\&7",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("jBu\DC1!5\207\193K6\164\a\EOT\189m\169\154}\186\220\246\141\&8\167\GS\184\RS\192",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("s\207#\r\188b4B|f>\135\234\142\&7\202\154\186",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropSubscriptionIdentifierAvailable -// 66,PropContentType ",Gd\165.?\DC2b\148H\244]\NAK\179\b\230\199\162\249/\168\255",PropContentType -// "\161\128\&7\169\SI\STX\132\142\241\r\DC3\234e\153\180\193j\164\DC2\230\220a\194H\154\217z?",PropSubscriptionIdentifier -// 20,PropServerKeepAlive 27818,PropWildcardSubscriptionAvailable 207,PropAuthenticationMethod -// "0\248\178\173\199\STX\t5\251\236 /FAy\158\174\230\SYN\152\151",PropPayloadFormatIndicator 0,PropCorrelationData -// "&\250\151Y",PropAuthenticationData -// "e\191\149m\242\ACKN\208\EOTu\GS\STX\142\155\b\225\243\154\172Z~O\250\165\157",PropRequestProblemInformation -// 85,PropMessageExpiryInterval 32539,PropRetainAvailable 248,PropWillDelayInterval 17574,PropRequestResponseInformation -// 127,PropSharedSubscriptionAvailable 69,PropTopicAlias 32610,PropTopicAliasMaximum 1124,PropRequestProblemInformation -// 52,PropServerKeepAlive 14995,PropSubscriptionIdentifier 22,PropWildcardSubscriptionAvailable -// 199,PropMaximumPacketSize 31108,PropRetainAvailable 211,PropCorrelationData "6\247\174\209",PropTopicAlias 25422] -TEST(Subscribe5QCTest, Encode31) { - uint8_t pkt[] = { - 0x82, 0xb2, 0x2, 0x55, 0xa, 0xb0, 0x1, 0x29, 0x42, 0x3, 0x0, 0x16, 0x2c, 0x47, 0x64, 0xa5, 0x2e, 0x3f, 0x12, - 0x62, 0x94, 0x48, 0xf4, 0x5d, 0x15, 0xb3, 0x8, 0xe6, 0xc7, 0xa2, 0xf9, 0x2f, 0xa8, 0xff, 0x3, 0x0, 0x1c, 0xa1, - 0x80, 0x37, 0xa9, 0xf, 0x2, 0x84, 0x8e, 0xf1, 0xd, 0x13, 0xea, 0x65, 0x99, 0xb4, 0xc1, 0x6a, 0xa4, 0x12, 0xe6, - 0xdc, 0x61, 0xc2, 0x48, 0x9a, 0xd9, 0x7a, 0x3f, 0xb, 0x14, 0x13, 0x6c, 0xaa, 0x28, 0xcf, 0x15, 0x0, 0x15, 0x30, - 0xf8, 0xb2, 0xad, 0xc7, 0x2, 0x9, 0x35, 0xfb, 0xec, 0x20, 0x2f, 0x46, 0x41, 0x79, 0x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xdc, 0xf6, 0x8d, 0x38, 0xa7, 0x1d, 0xb8, - 0x1e, 0xc0, 0x2, 0x0, 0x12, 0x73, 0xcf, 0x23, 0xd, 0xbc, 0x62, 0x34, 0x42, 0x7c, 0x66, 0x3e, 0x87, 0xea, 0x8e, - 0x37, 0xca, 0x9a, 0xba, 0x1}; - - uint8_t buf[319] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x8b, 0x3d, 0x62, 0x91, 0x70, 0x9d, 0xdf, 0x62, 0x7c, 0x2, - 0x5b, 0xc5, 0xcb, 0xa7, 0x65, 0x5e, 0xab, 0xeb, 0x97, 0x7d, - 0x6b, 0x95, 0x4, 0x84, 0xe, 0xef, 0xda, 0x9f, 0x98}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6, 0xe3, 0x2b, 0x86, 0x17, 0xaa, 0xfd, 0xa6}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x94, 0x2d, 0xc6, 0x6, 0x4f, 0x3a, 0x58, 0xbf, 0xa2}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x80, 0x96, 0x37, 0x8, 0xc, 0x5e, 0x67, 0xb6, - 0x44, 0x72, 0x9, 0x38, 0x6b, 0xf0, 0xaa, 0x37}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x6a, 0x42, 0x75, 0x11, 0x21, 0x35, 0xcf, 0xc1, 0x4b, 0x36, - 0xa4, 0x7, 0x4, 0xbd, 0x6d, 0xa9, 0x9a, 0x7d, 0xba, 0xdc, - 0xf6, 0x8d, 0x38, 0xa7, 0x1d, 0xb8, 0x1e, 0xc0}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x73, 0xcf, 0x23, 0xd, 0xbc, 0x62, 0x34, 0x42, 0x7c, - 0x66, 0x3e, 0x87, 0xea, 0x8e, 0x37, 0xca, 0x9a, 0xba}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x2c, 0x47, 0x64, 0xa5, 0x2e, 0x3f, 0x12, 0x62, 0x94, 0x48, 0xf4, - 0x5d, 0x15, 0xb3, 0x8, 0xe6, 0xc7, 0xa2, 0xf9, 0x2f, 0xa8, 0xff}; - uint8_t bytesprops1[] = {0xa1, 0x80, 0x37, 0xa9, 0xf, 0x2, 0x84, 0x8e, 0xf1, 0xd, 0x13, 0xea, 0x65, 0x99, - 0xb4, 0xc1, 0x6a, 0xa4, 0x12, 0xe6, 0xdc, 0x61, 0xc2, 0x48, 0x9a, 0xd9, 0x7a, 0x3f}; - uint8_t bytesprops2[] = {0x30, 0xf8, 0xb2, 0xad, 0xc7, 0x2, 0x9, 0x35, 0xfb, 0xec, 0x20, - 0x2f, 0x46, 0x41, 0x79, 0x9e, 0xae, 0xe6, 0x16, 0x98, 0x97}; - uint8_t bytesprops3[] = {0x26, 0xfa, 0x97, 0x59}; - uint8_t bytesprops4[] = {0x65, 0xbf, 0x95, 0x6d, 0xf2, 0x6, 0x4e, 0xd0, 0x4, 0x75, 0x1d, 0x2, 0x8e, - 0x9b, 0x8, 0xe1, 0xf3, 0x9a, 0xac, 0x5a, 0x7e, 0x4f, 0xfa, 0xa5, 0x9d}; - uint8_t bytesprops5[] = {0x36, 0xf7, 0xae, 0xd1}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27818}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32539}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17574}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32610}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1124}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14995}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31108}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25422}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21770, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 24232 -// [("\228\219\211\ENQ\144\&1\EMRC\252<\249\191\134\214I\149\ENQ\204~\DC4\165\182\150\219\180^\DC2",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("js\191\171\SYN\189\226K\172j8\255\165\172\234R\174`\205\174\r)\ESCN\b\166\150\&6\151",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\195\230#0b={P\147",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = -// QoS1}),("\b\181\152j\EMo\228\134\219\174\179~\246\170>\175\209\193\138D\129\150K\v\163.\223@",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("F\212\150u\137\212\165\227\t\252\203'8\195\187\205~",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\232\133xTT\221\207\NUL",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ETX}\171pE",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("@$\166\244=%&\CANS\tx2\215\"\DLE\204\197\147\DC4nU\ENQ]\229>\EM`\246H",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\153\175\GS\173\ETB\160a\b\FS\195\152\193\STX\139\242\129\254{",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\244\&6\\v\143b\181\188\130\153t\237\185>\130",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\161g3\193\181G;",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMaximumPacketSize -// 3126,PropCorrelationData "\204\133\131*K.8\158\&1\DEL:\174yq\GS\SUB",PropMessageExpiryInterval -// 6930,PropRequestResponseInformation 253,PropContentType "\204\186%\178\187",PropTopicAliasMaximum -// 24459,PropTopicAlias 21845,PropContentType "lM\v>",PropResponseTopic -// "\199\a\138\137\&1_\135/\203/\141\153q\194\153\245B\177\156",PropAuthenticationMethod -// "",PropRequestProblemInformation 137] -TEST(Subscribe5QCTest, Encode32) { - uint8_t pkt[] = { - 0x82, 0xb4, 0x2, 0x5e, 0xa8, 0x4f, 0x27, 0x0, 0x0, 0xc, 0x36, 0x9, 0x0, 0x10, 0xcc, 0x85, 0x83, 0x2a, 0x4b, - 0x2e, 0x38, 0x9e, 0x31, 0x7f, 0x3a, 0xae, 0x79, 0x71, 0x1d, 0x1a, 0x2, 0x0, 0x0, 0x1b, 0x12, 0x19, 0xfd, 0x3, - 0x0, 0x5, 0xcc, 0xba, 0x25, 0xb2, 0xbb, 0x22, 0x5f, 0x8b, 0x23, 0x55, 0x55, 0x3, 0x0, 0x4, 0x6c, 0x4d, 0xb, - 0x3e, 0x8, 0x0, 0x13, 0xc7, 0x7, 0x8a, 0x89, 0x31, 0x5f, 0x87, 0x2f, 0xcb, 0x2f, 0x8d, 0x99, 0x71, 0xc2, 0x99, - 0xf5, 0x42, 0xb1, 0x9c, 0x15, 0x0, 0x0, 0x17, 0x89, 0x0, 0x1c, 0xe4, 0xdb, 0xd3, 0x5, 0x90, 0x31, 0x19, 0x52, - 0x43, 0xfc, 0x3c, 0xf9, 0xbf, 0x86, 0xd6, 0x49, 0x95, 0x5, 0xcc,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bc, 0x82, 0x99, 0x74, 0xed, 0xb9, 0x3e, 0x82, 0x2, 0x0, 0x7, 0xa1, - 0x67, 0x33, 0xc1, 0xb5, 0x47, 0x3b, 0x1}; - - uint8_t buf[321] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xe4, 0xdb, 0xd3, 0x5, 0x90, 0x31, 0x19, 0x52, 0x43, 0xfc, 0x3c, 0xf9, 0xbf, 0x86, - 0xd6, 0x49, 0x95, 0x5, 0xcc, 0x7e, 0x14, 0xa5, 0xb6, 0x96, 0xdb, 0xb4, 0x5e, 0x12}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6a, 0x73, 0xbf, 0xab, 0x16, 0xbd, 0xe2, 0x4b, 0xac, 0x6a, - 0x38, 0xff, 0xa5, 0xac, 0xea, 0x52, 0xae, 0x60, 0xcd, 0xae, - 0xd, 0x29, 0x1b, 0x4e, 0x8, 0xa6, 0x96, 0x36, 0x97}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc3, 0xe6, 0x23, 0x30, 0x62, 0x3d, 0x7b, 0x50, 0x93}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8, 0xb5, 0x98, 0x6a, 0x19, 0x6f, 0xe4, 0x86, 0xdb, 0xae, - 0xb3, 0x7e, 0xf6, 0xaa, 0x3e, 0xaf, 0xd1, 0xc1, 0x8a, 0x44, - 0x81, 0x96, 0x4b, 0xb, 0xa3, 0x2e, 0xdf, 0x40}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x46, 0xd4, 0x96, 0x75, 0x89, 0xd4, 0xa5, 0xe3, 0x9, - 0xfc, 0xcb, 0x27, 0x38, 0xc3, 0xbb, 0xcd, 0x7e}; - lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe8, 0x85, 0x78, 0x54, 0x54, 0xdd, 0xcf, 0x0}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3, 0x7d, 0xab, 0x70, 0x45}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x40, 0x24, 0xa6, 0xf4, 0x3d, 0x25, 0x26, 0x18, 0x53, 0x9, - 0x78, 0x32, 0xd7, 0x22, 0x10, 0xcc, 0xc5, 0x93, 0x14, 0x6e, - 0x55, 0x5, 0x5d, 0xe5, 0x3e, 0x19, 0x60, 0xf6, 0x48}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x99, 0xaf, 0x1d, 0xad, 0x17, 0xa0, 0x61, 0x8, 0x1c, - 0xc3, 0x98, 0xc1, 0x2, 0x8b, 0xf2, 0x81, 0xfe, 0x7b}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xf4, 0x36, 0x5c, 0x76, 0x8f, 0x62, 0xb5, 0xbc, - 0x82, 0x99, 0x74, 0xed, 0xb9, 0x3e, 0x82}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xa1, 0x67, 0x33, 0xc1, 0xb5, 0x47, 0x3b}; - lwmqtt_string_t topic_filter_s10 = {7, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xcc, 0x85, 0x83, 0x2a, 0x4b, 0x2e, 0x38, 0x9e, - 0x31, 0x7f, 0x3a, 0xae, 0x79, 0x71, 0x1d, 0x1a}; - uint8_t bytesprops1[] = {0xcc, 0xba, 0x25, 0xb2, 0xbb}; - uint8_t bytesprops2[] = {0x6c, 0x4d, 0xb, 0x3e}; - uint8_t bytesprops3[] = {0xc7, 0x7, 0x8a, 0x89, 0x31, 0x5f, 0x87, 0x2f, 0xcb, 0x2f, - 0x8d, 0x99, 0x71, 0xc2, 0x99, 0xf5, 0x42, 0xb1, 0x9c}; - uint8_t bytesprops4[] = {0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3126}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6930}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24459}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21845}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 137}}, - }; - - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24232, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 1966 [("\202jY\229%\180?VjcM\232\215\146\SYNs\253\SYNW\162\170\244Y",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("6\r\249\236N\201*c",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("K\131A\193\166$\USc,N\221\254\172\242\137\232s\"l\ETB\DC4;S\198(",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("r\129\"\198\151\161\183\159\156\156\202\DC1\GS\153\EOT\ETX\146",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\202aP!\RSH\210E\130Q\ETX\r\161r -// \168u\216\145\SYN\157G\204\148\180\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("]wv2\143\149\148\159\RS\157",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\158\DC4\161$H\248\233\&7q\130-\225\219em\181\DC4nH\v\228=G#0\243O\f\DC4{",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(";\232\243\148t\249g\EM\247\&4 -// \198\130\228\f\ACK\203\199\250\215\&6\RS\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("I\191\225\be\SO\193\210\CAN=z\199$i\\a\157\145\132\&7\137\174\GS\148\ESC\245\194\193\134J",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\189\225\230\152\147\154q\DC2\158\197\187\194\178\146&\GSl\235\157\248\246\"\232\253\204\253I\DC2\143<",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropAuthenticationMethod "D\199\188\STX\SO9\\\155M\171\CAN\241u\223\237\253'",PropTopicAliasMaximum -// 29564,PropServerReference "\153}\CAN\241\237\175w\139,\197\252",PropServerKeepAlive -// 32502,PropSharedSubscriptionAvailable 2,PropMaximumQoS 21,PropMaximumPacketSize 11144,PropTopicAlias -// 22858,PropSharedSubscriptionAvailable 196,PropServerReference "\230\&66\242M]h\193\160",PropMaximumQoS -// 22,PropTopicAliasMaximum 32231,PropUserProperty -// "&\168\228\236\146'\185A\US\234\137\DLEA\215hp]\196\129\t{\167\161\STX\217sK\214C" -// "*+\DELc4\ESCR\155S\196>7\159\159\142\141\137|O;8\163j\148\251\167\250!P",PropTopicAlias -// 4591,PropRequestResponseInformation 66,PropCorrelationData -// "\EOTj\198\r\rd\207\129c4\200\SOH\EM\152]\254Vq",PropTopicAlias 13262,PropRetainAvailable 146,PropTopicAliasMaximum -// 12396,PropRequestResponseInformation 210,PropAuthenticationData -// "\240\166T\CAN;\CAN\SI\DC2\NUL;\209H",PropResponseTopic -// "\195\170\142tsHK*8eDw\165&\EMX]\240\&24\154\138\254",PropContentType -// "\SOH.X\215\150\130\&6+\165\132\197\DELSf\130x\192\CAN&\ENQ\157",PropRequestResponseInformation -// 87,PropRequestProblemInformation 55,PropAuthenticationMethod -// "\217\178-3\238(\224\166\233&\b\159\252\238J\194\207\DEL\161*\168\238{\232g\139\ETB\133",PropPayloadFormatIndicator -// 63,PropContentType "qG\237'\210\159\168^o)\RS",PropUserProperty "\244;\233\139\207\213\237-wS\STX\168y\244" -// "\134\156\223\b\r\RS\240\181I8\183.\235T\188\165-o\190"] -TEST(Subscribe5QCTest, Encode33) { - uint8_t pkt[] = { - 0x82, 0xc4, 0x4, 0x7, 0xae, 0xc4, 0x2, 0x15, 0x0, 0x11, 0x44, 0xc7, 0xbc, 0x2, 0xe, 0x39, 0x5c, 0x9b, 0x4d, - 0xab, 0x18, 0xf1, 0x75, 0xdf, 0xed, 0xfd, 0x27, 0x22, 0x73, 0x7c, 0x1c, 0x0, 0xb, 0x99, 0x7d, 0x18, 0xf1, 0xed, - 0xaf, 0x77, 0x8b, 0x2c, 0xc5, 0xfc, 0x13, 0x7e, 0xf6, 0x2a, 0x2, 0x24, 0x15, 0x27, 0x0, 0x0, 0x2b, 0x88, 0x23, - 0x59, 0x4a, 0x2a, 0xc4, 0x1c, 0x0, 0x9, 0xe6, 0x36, 0x36, 0xf2, 0x4d, 0x5d, 0x68, 0xc1, 0xa0, 0x24, 0x16, 0x22, - 0x7d, 0xe7, 0x26, 0x0, 0x1d, 0x26, 0xa8, 0xe4, 0xec, 0x92, 0x27, 0xb9, 0x41, 0x1f, 0xea, 0x89, 0x10, 0x41, 0xd7, - 0x68, 0x70, 0x5d, 0xc4, 0x81, 0x9, 0x7b, 0xa7, 0xa1, 0x2, 0xd9, 0x73, 0x4b, 0xd6, 0x43, 0x0, 0x1d, 0x2a, 0x2b, - 0x7f, 0x63, 0x34, 0x1b, 0x52, 0x9b, 0x53, 0xc4, 0x3e, 0x37, 0x9f, 0x9f, 0x8e, 0x8d, 0x89, 0x7c, 0x4f, 0x3b, 0x38, - 0xa3, 0x6a, 0x94, 0xfb, 0xa7, 0xfa, 0x21, 0x50, 0x23, 0x11, 0xef, 0x19, 0x42, 0x9, 0x0, 0x12, 0x4, 0x6a, 0xc6, - 0xd, 0xd, 0x64, 0xcf, 0x81, 0x63, 0x34, 0xc8, 0x1, 0x19, 0x98, 0x5d, 0xfe, 0x56, 0x71, 0x23, 0x33, 0xce, 0x25, - 0x92, 0x22, 0x30, 0x6c, 0x19, 0xd2, 0x16, 0x0, 0xc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 0xbd, 0xe1, 0xe6, 0x98, 0x93, 0x9a, 0x71, 0x12, 0x9e, 0xc5, 0xbb, 0xc2, 0xb2, 0x92, 0x26, 0x1d, 0x6c, 0xeb, - 0x9d, 0xf8, 0xf6, 0x22, 0xe8, 0xfd, 0xcc, 0xfd, 0x49, 0x12, 0x8f, 0x3c, 0x2}; - - uint8_t buf[593] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xca, 0x6a, 0x59, 0xe5, 0x25, 0xb4, 0x3f, 0x56, 0x6a, 0x63, 0x4d, 0xe8, - 0xd7, 0x92, 0x16, 0x73, 0xfd, 0x16, 0x57, 0xa2, 0xaa, 0xf4, 0x59}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x36, 0xd, 0xf9, 0xec, 0x4e, 0xc9, 0x2a, 0x63}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4b, 0x83, 0x41, 0xc1, 0xa6, 0x24, 0x1f, 0x63, 0x2c, 0x4e, 0xdd, 0xfe, 0xac, - 0xf2, 0x89, 0xe8, 0x73, 0x22, 0x6c, 0x17, 0x14, 0x3b, 0x53, 0xc6, 0x28}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x72, 0x81, 0x22, 0xc6, 0x97, 0xa1, 0xb7, 0x9f, 0x9c, - 0x9c, 0xca, 0x11, 0x1d, 0x99, 0x4, 0x3, 0x92}; - lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xca, 0x61, 0x50, 0x21, 0x1e, 0x48, 0xd2, 0x45, 0x82, 0x51, 0x3, 0xd, 0xa1, - 0x72, 0x20, 0xa8, 0x75, 0xd8, 0x91, 0x16, 0x9d, 0x47, 0xcc, 0x94, 0xb4, 0x2}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5d, 0x77, 0x76, 0x32, 0x8f, 0x95, 0x94, 0x9f, 0x1e, 0x9d}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x9e, 0x14, 0xa1, 0x24, 0x48, 0xf8, 0xe9, 0x37, 0x71, 0x82, - 0x2d, 0xe1, 0xdb, 0x65, 0x6d, 0xb5, 0x14, 0x6e, 0x48, 0xb, - 0xe4, 0x3d, 0x47, 0x23, 0x30, 0xf3, 0x4f, 0xc, 0x14, 0x7b}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x3b, 0xe8, 0xf3, 0x94, 0x74, 0xf9, 0x67, 0x19, 0xf7, 0x34, 0x20, 0xc6, - 0x82, 0xe4, 0xc, 0x6, 0xcb, 0xc7, 0xfa, 0xd7, 0x36, 0x1e, 0x94}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x49, 0xbf, 0xe1, 0x8, 0x65, 0xe, 0xc1, 0xd2, 0x18, 0x3d, - 0x7a, 0xc7, 0x24, 0x69, 0x5c, 0x61, 0x9d, 0x91, 0x84, 0x37, - 0x89, 0xae, 0x1d, 0x94, 0x1b, 0xf5, 0xc2, 0xc1, 0x86, 0x4a}; - lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xbd, 0xe1, 0xe6, 0x98, 0x93, 0x9a, 0x71, 0x12, 0x9e, 0xc5, - 0xbb, 0xc2, 0xb2, 0x92, 0x26, 0x1d, 0x6c, 0xeb, 0x9d, 0xf8, - 0xf6, 0x22, 0xe8, 0xfd, 0xcc, 0xfd, 0x49, 0x12, 0x8f, 0x3c}; - lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x44, 0xc7, 0xbc, 0x2, 0xe, 0x39, 0x5c, 0x9b, 0x4d, - 0xab, 0x18, 0xf1, 0x75, 0xdf, 0xed, 0xfd, 0x27}; - uint8_t bytesprops1[] = {0x99, 0x7d, 0x18, 0xf1, 0xed, 0xaf, 0x77, 0x8b, 0x2c, 0xc5, 0xfc}; - uint8_t bytesprops2[] = {0xe6, 0x36, 0x36, 0xf2, 0x4d, 0x5d, 0x68, 0xc1, 0xa0}; - uint8_t bytesprops4[] = {0x2a, 0x2b, 0x7f, 0x63, 0x34, 0x1b, 0x52, 0x9b, 0x53, 0xc4, 0x3e, 0x37, 0x9f, 0x9f, 0x8e, - 0x8d, 0x89, 0x7c, 0x4f, 0x3b, 0x38, 0xa3, 0x6a, 0x94, 0xfb, 0xa7, 0xfa, 0x21, 0x50}; - uint8_t bytesprops3[] = {0x26, 0xa8, 0xe4, 0xec, 0x92, 0x27, 0xb9, 0x41, 0x1f, 0xea, 0x89, 0x10, 0x41, 0xd7, 0x68, - 0x70, 0x5d, 0xc4, 0x81, 0x9, 0x7b, 0xa7, 0xa1, 0x2, 0xd9, 0x73, 0x4b, 0xd6, 0x43}; - uint8_t bytesprops5[] = {0x4, 0x6a, 0xc6, 0xd, 0xd, 0x64, 0xcf, 0x81, 0x63, - 0x34, 0xc8, 0x1, 0x19, 0x98, 0x5d, 0xfe, 0x56, 0x71}; - uint8_t bytesprops6[] = {0xf0, 0xa6, 0x54, 0x18, 0x3b, 0x18, 0xf, 0x12, 0x0, 0x3b, 0xd1, 0x48}; - uint8_t bytesprops7[] = {0xc3, 0xaa, 0x8e, 0x74, 0x73, 0x48, 0x4b, 0x2a, 0x38, 0x65, 0x44, 0x77, - 0xa5, 0x26, 0x19, 0x58, 0x5d, 0xf0, 0x32, 0x34, 0x9a, 0x8a, 0xfe}; - uint8_t bytesprops8[] = {0x1, 0x2e, 0x58, 0xd7, 0x96, 0x82, 0x36, 0x2b, 0xa5, 0x84, 0xc5, - 0x7f, 0x53, 0x66, 0x82, 0x78, 0xc0, 0x18, 0x26, 0x5, 0x9d}; - uint8_t bytesprops9[] = {0xd9, 0xb2, 0x2d, 0x33, 0xee, 0x28, 0xe0, 0xa6, 0xe9, 0x26, 0x8, 0x9f, 0xfc, 0xee, - 0x4a, 0xc2, 0xcf, 0x7f, 0xa1, 0x2a, 0xa8, 0xee, 0x7b, 0xe8, 0x67, 0x8b, 0x17, 0x85}; - uint8_t bytesprops10[] = {0x71, 0x47, 0xed, 0x27, 0xd2, 0x9f, 0xa8, 0x5e, 0x6f, 0x29, 0x1e}; - uint8_t bytesprops12[] = {0x86, 0x9c, 0xdf, 0x8, 0xd, 0x1e, 0xf0, 0xb5, 0x49, 0x38, - 0xb7, 0x2e, 0xeb, 0x54, 0xbc, 0xa5, 0x2d, 0x6f, 0xbe}; - uint8_t bytesprops11[] = {0xf4, 0x3b, 0xe9, 0x8b, 0xcf, 0xd5, 0xed, 0x2d, 0x77, 0x53, 0x2, 0xa8, 0x79, 0xf4}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29564}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32502}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11144}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22858}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32231}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops3}, .v = {29, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4591}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13262}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12396}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {14, (char*)&bytesprops11}, .v = {19, (char*)&bytesprops12}}}}, - }; - - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1966, 10, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 11595 [("\157Y\254\b\253\241E\158M\CAN\255\215Q\ENQ\217\131\177",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\171\DC1\150\DLE\ETBSSi\198{\213\206\249t\216\rt\218\236\161\143\&8\145",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\181\FS]\249\210A:\189\185\DC1\ENQ\175]\150\218\169\SOH\193\SOH`\150\169\182l",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\233/\143\172\SIn:m\212Pf\177&\234\165\181\226\DEL3\153\SI\241l\144\242",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReceiveMaximum -// 4658,PropMaximumQoS 249,PropServerKeepAlive 13,PropResponseTopic -// "\156\163\169,\213\&3\131\186\DC1K\128\162\&2\222{\170\152y\164\DC1\255\180\137\142\237",PropCorrelationData -// "\254",PropTopicAliasMaximum 27561,PropSharedSubscriptionAvailable 233,PropMessageExpiryInterval -// 27068,PropResponseTopic "\186\196h\154\211<\n\180\\9@il`\149a~\246|\220\226\ESC\204",PropMessageExpiryInterval -// 23693,PropSubscriptionIdentifier 16,PropTopicAlias 18385,PropSharedSubscriptionAvailable 18,PropContentType -// "\SOH\138o\228\229B\206\136B\ESCX\147\EOT\FSa",PropAuthenticationData -// "y\129H;\ENQ4\237\v\183\182yn\ACK.\SO\132n\205,\187\DC4`\239>\188",PropResponseInformation -// "\FS\205\250\DC3\134\193\b\SO\239\&2HM",PropSubscriptionIdentifier 27,PropMaximumQoS 122] -TEST(Subscribe5QCTest, Encode34) { - uint8_t pkt[] = { - 0x82, 0x82, 0x2, 0x2d, 0x4b, 0x99, 0x1, 0x21, 0x12, 0x32, 0x24, 0xf9, 0x13, 0x0, 0xd, 0x8, 0x0, 0x19, 0x9c, - 0xa3, 0xa9, 0x2c, 0xd5, 0x33, 0x83, 0xba, 0x11, 0x4b, 0x80, 0xa2, 0x32, 0xde, 0x7b, 0xaa, 0x98, 0x79, 0xa4, 0x11, - 0xff, 0xb4, 0x89, 0x8e, 0xed, 0x9, 0x0, 0x1, 0xfe, 0x22, 0x6b, 0xa9, 0x2a, 0xe9, 0x2, 0x0, 0x0, 0x69, 0xbc, - 0x8, 0x0, 0x17, 0xba, 0xc4, 0x68, 0x9a, 0xd3, 0x3c, 0xa, 0xb4, 0x5c, 0x39, 0x40, 0x69, 0x6c, 0x60, 0x95, 0x61, - 0x7e, 0xf6, 0x7c, 0xdc, 0xe2, 0x1b, 0xcc, 0x2, 0x0, 0x0, 0x5c, 0x8d, 0xb, 0x10, 0x23, 0x47, 0xd1, 0x2a, 0x12, - 0x3, 0x0, 0xf, 0x1, 0x8a, 0x6f, 0xe4, 0xe5, 0x42, 0xce, 0x88, 0x42, 0x1b, 0x58, 0x93, 0x4, 0x1c, 0x61, 0x16, - 0x0, 0x19, 0x79, 0x81, 0x48, 0x3b, 0x5, 0x34, 0xed, 0xb, 0xb7, 0xb6, 0x79, 0x6e, 0x6, 0x2e, 0xe, 0x84, 0x6e, - 0xcd, 0x2c, 0xbb, 0x14, 0x60, 0xef, 0x3e, 0xbc, 0x1a, 0x0, 0xc, 0x1c, 0xcd, 0xfa, 0x13, 0x86, 0xc1, 0x8, 0xe, - 0xef, 0x32, 0x48, 0x4d, 0xb, 0x1b, 0x24, 0x7a, 0x0, 0x11, 0x9d, 0x59, 0xfe, 0x8, 0xfd, 0xf1, 0x45, 0x9e, 0x4d, - 0x18, 0xff, 0xd7, 0x51, 0x5, 0xd9, 0x83, 0xb1, 0x2, 0x0, 0x17, 0xab, 0x11, 0x96, 0x10, 0x17, 0x53, 0x53, 0x69, - 0xc6, 0x7b, 0xd5, 0xce, 0xf9, 0x74, 0xd8, 0xd, 0x74, 0xda, 0xec, 0xa1, 0x8f, 0x38, 0x91, 0x2, 0x0, 0x18, 0xb5, - 0x1c, 0x5d, 0xf9, 0xd2, 0x41, 0x3a, 0xbd, 0xb9, 0x11, 0x5, 0xaf, 0x5d, 0x96, 0xda, 0xa9, 0x1, 0xc1, 0x1, 0x60, - 0x96, 0xa9, 0xb6, 0x6c, 0x2, 0x0, 0x19, 0xe9, 0x2f, 0x8f, 0xac, 0xf, 0x6e, 0x3a, 0x6d, 0xd4, 0x50, 0x66, 0xb1, - 0x26, 0xea, 0xa5, 0xb5, 0xe2, 0x7f, 0x33, 0x99, 0xf, 0xf1, 0x6c, 0x90, 0xf2, 0x1}; - - uint8_t buf[271] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x9d, 0x59, 0xfe, 0x8, 0xfd, 0xf1, 0x45, 0x9e, 0x4d, - 0x18, 0xff, 0xd7, 0x51, 0x5, 0xd9, 0x83, 0xb1}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xab, 0x11, 0x96, 0x10, 0x17, 0x53, 0x53, 0x69, 0xc6, 0x7b, 0xd5, 0xce, - 0xf9, 0x74, 0xd8, 0xd, 0x74, 0xda, 0xec, 0xa1, 0x8f, 0x38, 0x91}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb5, 0x1c, 0x5d, 0xf9, 0xd2, 0x41, 0x3a, 0xbd, 0xb9, 0x11, 0x5, 0xaf, - 0x5d, 0x96, 0xda, 0xa9, 0x1, 0xc1, 0x1, 0x60, 0x96, 0xa9, 0xb6, 0x6c}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe9, 0x2f, 0x8f, 0xac, 0xf, 0x6e, 0x3a, 0x6d, 0xd4, 0x50, 0x66, 0xb1, 0x26, - 0xea, 0xa5, 0xb5, 0xe2, 0x7f, 0x33, 0x99, 0xf, 0xf1, 0x6c, 0x90, 0xf2}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x9c, 0xa3, 0xa9, 0x2c, 0xd5, 0x33, 0x83, 0xba, 0x11, 0x4b, 0x80, 0xa2, 0x32, - 0xde, 0x7b, 0xaa, 0x98, 0x79, 0xa4, 0x11, 0xff, 0xb4, 0x89, 0x8e, 0xed}; - uint8_t bytesprops1[] = {0xfe}; - uint8_t bytesprops2[] = {0xba, 0xc4, 0x68, 0x9a, 0xd3, 0x3c, 0xa, 0xb4, 0x5c, 0x39, 0x40, 0x69, - 0x6c, 0x60, 0x95, 0x61, 0x7e, 0xf6, 0x7c, 0xdc, 0xe2, 0x1b, 0xcc}; - uint8_t bytesprops3[] = {0x1, 0x8a, 0x6f, 0xe4, 0xe5, 0x42, 0xce, 0x88, 0x42, 0x1b, 0x58, 0x93, 0x4, 0x1c, 0x61}; - uint8_t bytesprops4[] = {0x79, 0x81, 0x48, 0x3b, 0x5, 0x34, 0xed, 0xb, 0xb7, 0xb6, 0x79, 0x6e, 0x6, - 0x2e, 0xe, 0x84, 0x6e, 0xcd, 0x2c, 0xbb, 0x14, 0x60, 0xef, 0x3e, 0xbc}; - uint8_t bytesprops5[] = {0x1c, 0xcd, 0xfa, 0x13, 0x86, 0xc1, 0x8, 0xe, 0xef, 0x32, 0x48, 0x4d}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4658}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27561}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27068}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23693}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18385}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 122}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11595, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 3561 [("\SI\230\235\135\157\175%\128",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\174\n|v\146#k\154\224-R\219\SUB\245k\186\207: -// \r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\DC2\181\156\155\180{\234\ETX\GS\223\168\199u\168N\218w\246\&3\DC3z\168y\249",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\170\211",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("R\230\221\&6\239O\211\146vM3YD\140\129+\194B\160\200\163\189",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropServerReference "i",PropCorrelationData -// "&\244t\193\&3o\f\193\186g\SUB\143\225\215",PropResponseTopic "q=\170\168R\167",PropMaximumQoS -// 195,PropSharedSubscriptionAvailable 84,PropResponseInformation -// "\186\207\146\n\"\201\&9\160m;B\GS\208\201\179\132\205.\131n\221C",PropSessionExpiryInterval -// 31601,PropServerKeepAlive 20698,PropServerReference -// "\132\216\221)\172\160\SI\SUB\a\US*=\SYN\GS\185F\141Y>P\194",PropAuthenticationData -// "\201\209\189\193\GS\193\235\143\USD\FS\193\r\231\t\142\221\132\166\184s\192\157\GSS",PropUserProperty "" -// "I^z\212\224#\235UQ\188\224\244\SYN\USq$\166",PropRequestProblemInformation 35,PropPayloadFormatIndicator -// 73,PropServerKeepAlive 15730,PropTopicAliasMaximum 6340,PropMessageExpiryInterval 27016,PropUserProperty "\149\245" -// "M\169\168\ETXu\FS\185_\156",PropReceiveMaximum 29452,PropMessageExpiryInterval 31914,PropMaximumPacketSize -// 30557,PropCorrelationData "",PropServerReference "}",PropResponseTopic -// "\214\197\244\128\222fq",PropAuthenticationMethod -// "O\170i\240\179\136\207b\206g\222\r\242\221\234^_\140u9i\201\222\173e",PropMaximumQoS 166,PropMessageExpiryInterval -// 9383,PropRequestProblemInformation 42,PropMaximumQoS 173,PropSessionExpiryInterval 20164,PropResponseTopic -// "\186I\232\SUB"] -TEST(Subscribe5QCTest, Encode35) { - uint8_t pkt[] = { - 0x82, 0xdc, 0x2, 0xd, 0xe9, 0xfd, 0x1, 0x1c, 0x0, 0x1, 0x69, 0x9, 0x0, 0xe, 0x26, 0xf4, 0x74, 0xc1, 0x33, - 0x6f, 0xc, 0xc1, 0xba, 0x67, 0x1a, 0x8f, 0xe1, 0xd7, 0x8, 0x0, 0x6, 0x71, 0x3d, 0xaa, 0xa8, 0x52, 0xa7, 0x24, - 0xc3, 0x2a, 0x54, 0x1a, 0x0, 0x16, 0xba, 0xcf, 0x92, 0xa, 0x22, 0xc9, 0x39, 0xa0, 0x6d, 0x3b, 0x42, 0x1d, 0xd0, - 0xc9, 0xb3, 0x84, 0xcd, 0x2e, 0x83, 0x6e, 0xdd, 0x43, 0x11, 0x0, 0x0, 0x7b, 0x71, 0x13, 0x50, 0xda, 0x1c, 0x0, - 0x15, 0x84, 0xd8, 0xdd, 0x29, 0xac, 0xa0, 0xf, 0x1a, 0x7, 0x1f, 0x2a, 0x3d, 0x16, 0x1d, 0xb9, 0x46, 0x8d, 0x59, - 0x3e, 0x50, 0xc2, 0x16, 0x0, 0x19, 0xc9, 0xd1, 0xbd, 0xc1, 0x1d, 0xc1, 0xeb, 0x8f, 0x1f, 0x44, 0x1c, 0xc1, 0xd, - 0xe7, 0x9, 0x8e, 0xdd, 0x84, 0xa6, 0xb8, 0x73, 0xc0, 0x9d, 0x1d, 0x53, 0x26, 0x0, 0x0, 0x0, 0x11, 0x49, 0x5e, - 0x7a, 0xd4, 0xe0, 0x23, 0xeb, 0x55, 0x51, 0xbc, 0xe0, 0xf4, 0x16, 0x1f, 0x71, 0x24, 0xa6, 0x17, 0x23, 0x1, 0x49, - 0x13, 0x3d, 0x72, 0x22, 0x18, 0xc4, 0x2, 0x0, 0x0, 0x69, 0x88, 0x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}; - - uint8_t buf[361] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xf, 0xe6, 0xeb, 0x87, 0x9d, 0xaf, 0x25, 0x80}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xae, 0xa, 0x7c, 0x76, 0x92, 0x23, 0x6b, 0x9a, 0xe0, 0x2d, - 0x52, 0xdb, 0x1a, 0xf5, 0x6b, 0xba, 0xcf, 0x3a, 0x20, 0xd}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x12, 0xb5, 0x9c, 0x9b, 0xb4, 0x7b, 0xea, 0x3, 0x1d, 0xdf, 0xa8, 0xc7, - 0x75, 0xa8, 0x4e, 0xda, 0x77, 0xf6, 0x33, 0x13, 0x7a, 0xa8, 0x79, 0xf9}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xaa, 0xd3}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x52, 0xe6, 0xdd, 0x36, 0xef, 0x4f, 0xd3, 0x92, 0x76, 0x4d, 0x33, - 0x59, 0x44, 0x8c, 0x81, 0x2b, 0xc2, 0x42, 0xa0, 0xc8, 0xa3, 0xbd}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x69}; - uint8_t bytesprops1[] = {0x26, 0xf4, 0x74, 0xc1, 0x33, 0x6f, 0xc, 0xc1, 0xba, 0x67, 0x1a, 0x8f, 0xe1, 0xd7}; - uint8_t bytesprops2[] = {0x71, 0x3d, 0xaa, 0xa8, 0x52, 0xa7}; - uint8_t bytesprops3[] = {0xba, 0xcf, 0x92, 0xa, 0x22, 0xc9, 0x39, 0xa0, 0x6d, 0x3b, 0x42, - 0x1d, 0xd0, 0xc9, 0xb3, 0x84, 0xcd, 0x2e, 0x83, 0x6e, 0xdd, 0x43}; - uint8_t bytesprops4[] = {0x84, 0xd8, 0xdd, 0x29, 0xac, 0xa0, 0xf, 0x1a, 0x7, 0x1f, 0x2a, - 0x3d, 0x16, 0x1d, 0xb9, 0x46, 0x8d, 0x59, 0x3e, 0x50, 0xc2}; - uint8_t bytesprops5[] = {0xc9, 0xd1, 0xbd, 0xc1, 0x1d, 0xc1, 0xeb, 0x8f, 0x1f, 0x44, 0x1c, 0xc1, 0xd, - 0xe7, 0x9, 0x8e, 0xdd, 0x84, 0xa6, 0xb8, 0x73, 0xc0, 0x9d, 0x1d, 0x53}; - uint8_t bytesprops7[] = {0x49, 0x5e, 0x7a, 0xd4, 0xe0, 0x23, 0xeb, 0x55, 0x51, - 0xbc, 0xe0, 0xf4, 0x16, 0x1f, 0x71, 0x24, 0xa6}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops9[] = {0x4d, 0xa9, 0xa8, 0x3, 0x75, 0x1c, 0xb9, 0x5f, 0x9c}; - uint8_t bytesprops8[] = {0x95, 0xf5}; - uint8_t bytesprops10[] = {0}; - uint8_t bytesprops11[] = {0x7d}; - uint8_t bytesprops12[] = {0xd6, 0xc5, 0xf4, 0x80, 0xde, 0x66, 0x71}; - uint8_t bytesprops13[] = {0x4f, 0xaa, 0x69, 0xf0, 0xb3, 0x88, 0xcf, 0x62, 0xce, 0x67, 0xde, 0xd, 0xf2, - 0xdd, 0xea, 0x5e, 0x5f, 0x8c, 0x75, 0x39, 0x69, 0xc9, 0xde, 0xad, 0x65}; - uint8_t bytesprops14[] = {0xba, 0x49, 0xe8, 0x1a}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31601}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20698}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops6}, .v = {17, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15730}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6340}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27016}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops8}, .v = {9, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29452}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31914}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30557}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9383}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20164}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops14}}}, - }; - - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3561, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 27717 [("\241m\204\194)1\\\134\EOTj\252\251\183\169o~+",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\165\223\t",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ETX)\192\ETXE\164\158\181\239\216\SOH\131\171\196\207",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\182bC|\240!\219\DC4Q\200\161",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\160\162\&7\226\196(\141G\165\139\207\SI\255\171\251J\DC2\ETX\168q'1\240-^\185\192\191]",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("}$%\168\155\130\v\149v!\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\167o\ETX\243\&6\210\&8\STX\199\236h\129H1M\147\GS\241\143S\246B\130\234\160\215\223\184",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\SUBq\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("]g\181\SUBP\232h\172\GS\180\247\RS\203\236",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\201\158",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("C\229\189\187\171\185\NAKjA!\129\253",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [PropUserProperty "\172\&7\175\206\210_" -// "\164\129\&4\176\STX\153\214\v2\200\"\144i\216\&1\236\251\147\164m\230\151Z\245",PropWildcardSubscriptionAvailable -// 179] -TEST(Subscribe5QCTest, Encode36) { - uint8_t pkt[] = {0x82, 0xda, 0x1, 0x6c, 0x45, 0x25, 0x26, 0x0, 0x6, 0xac, 0x37, 0xaf, 0xce, 0xd2, 0x5f, 0x0, 0x18, - 0xa4, 0x81, 0x34, 0xb0, 0x2, 0x99, 0xd6, 0xb, 0x32, 0xc8, 0x22, 0x90, 0x69, 0xd8, 0x31, 0xec, 0xfb, - 0x93, 0xa4, 0x6d, 0xe6, 0x97, 0x5a, 0xf5, 0x28, 0xb3, 0x0, 0x11, 0xf1, 0x6d, 0xcc, 0xc2, 0x29, 0x31, - 0x5c, 0x86, 0x4, 0x6a, 0xfc, 0xfb, 0xb7, 0xa9, 0x6f, 0x7e, 0x2b, 0x1, 0x0, 0x3, 0xa5, 0xdf, 0x9, - 0x1, 0x0, 0xf, 0x3, 0x29, 0xc0, 0x3, 0x45, 0xa4, 0x9e, 0xb5, 0xef, 0xd8, 0x1, 0x83, 0xab, 0xc4, - 0xcf, 0x2, 0x0, 0xb, 0xb6, 0x62, 0x43, 0x7c, 0xf0, 0x21, 0xdb, 0x14, 0x51, 0xc8, 0xa1, 0x1, 0x0, - 0x1d, 0xa0, 0xa2, 0x37, 0xe2, 0xc4, 0x28, 0x8d, 0x47, 0xa5, 0x8b, 0xcf, 0xf, 0xff, 0xab, 0xfb, 0x4a, - 0x12, 0x3, 0xa8, 0x71, 0x27, 0x31, 0xf0, 0x2d, 0x5e, 0xb9, 0xc0, 0xbf, 0x5d, 0x1, 0x0, 0xb, 0x7d, - 0x24, 0x25, 0xa8, 0x9b, 0x82, 0xb, 0x95, 0x76, 0x21, 0xa6, 0x2, 0x0, 0x1c, 0xa7, 0x6f, 0x3, 0xf3, - 0x36, 0xd2, 0x38, 0x2, 0xc7, 0xec, 0x68, 0x81, 0x48, 0x31, 0x4d, 0x93, 0x1d, 0xf1, 0x8f, 0x53, 0xf6, - 0x42, 0x82, 0xea, 0xa0, 0xd7, 0xdf, 0xb8, 0x2, 0x0, 0x3, 0x1a, 0x71, 0xeb, 0x0, 0x0, 0xe, 0x5d, - 0x67, 0xb5, 0x1a, 0x50, 0xe8, 0x68, 0xac, 0x1d, 0xb4, 0xf7, 0x1e, 0xcb, 0xec, 0x1, 0x0, 0x2, 0xc9, - 0x9e, 0x1, 0x0, 0xc, 0x43, 0xe5, 0xbd, 0xbb, 0xab, 0xb9, 0x15, 0x6a, 0x41, 0x21, 0x81, 0xfd, 0x2}; - - uint8_t buf[231] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xf1, 0x6d, 0xcc, 0xc2, 0x29, 0x31, 0x5c, 0x86, 0x4, - 0x6a, 0xfc, 0xfb, 0xb7, 0xa9, 0x6f, 0x7e, 0x2b}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa5, 0xdf, 0x9}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x3, 0x29, 0xc0, 0x3, 0x45, 0xa4, 0x9e, 0xb5, - 0xef, 0xd8, 0x1, 0x83, 0xab, 0xc4, 0xcf}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb6, 0x62, 0x43, 0x7c, 0xf0, 0x21, 0xdb, 0x14, 0x51, 0xc8, 0xa1}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa0, 0xa2, 0x37, 0xe2, 0xc4, 0x28, 0x8d, 0x47, 0xa5, 0x8b, - 0xcf, 0xf, 0xff, 0xab, 0xfb, 0x4a, 0x12, 0x3, 0xa8, 0x71, - 0x27, 0x31, 0xf0, 0x2d, 0x5e, 0xb9, 0xc0, 0xbf, 0x5d}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7d, 0x24, 0x25, 0xa8, 0x9b, 0x82, 0xb, 0x95, 0x76, 0x21, 0xa6}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa7, 0x6f, 0x3, 0xf3, 0x36, 0xd2, 0x38, 0x2, 0xc7, 0xec, - 0x68, 0x81, 0x48, 0x31, 0x4d, 0x93, 0x1d, 0xf1, 0x8f, 0x53, - 0xf6, 0x42, 0x82, 0xea, 0xa0, 0xd7, 0xdf, 0xb8}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x1a, 0x71, 0xeb}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x5d, 0x67, 0xb5, 0x1a, 0x50, 0xe8, 0x68, - 0xac, 0x1d, 0xb4, 0xf7, 0x1e, 0xcb, 0xec}; - lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xc9, 0x9e}; - lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x43, 0xe5, 0xbd, 0xbb, 0xab, 0xb9, 0x15, 0x6a, 0x41, 0x21, 0x81, 0xfd}; - lwmqtt_string_t topic_filter_s10 = {12, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops1[] = {0xa4, 0x81, 0x34, 0xb0, 0x2, 0x99, 0xd6, 0xb, 0x32, 0xc8, 0x22, 0x90, - 0x69, 0xd8, 0x31, 0xec, 0xfb, 0x93, 0xa4, 0x6d, 0xe6, 0x97, 0x5a, 0xf5}; - uint8_t bytesprops0[] = {0xac, 0x37, 0xaf, 0xce, 0xd2, 0x5f}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, - }; - - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27717, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 10081 [("\254\182\236\b\134\175Afy\149p\146)\CAN\196]\172",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\140\141\202Y\140aB-\ENQx\198i\168\DEL\ESC\244\250-",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReasonString -// "\214\243\154\153\177c\229p\198\168\n+{\251\199",PropMessageExpiryInterval 30022,PropPayloadFormatIndicator -// 179,PropWildcardSubscriptionAvailable 40,PropUserProperty ",@a\201\ACK'\244\221" -// "@\b\255\217Z\154T}\216",PropSubscriptionIdentifierAvailable 130,PropPayloadFormatIndicator -// 96,PropAssignedClientIdentifier "MR\166\195\176/xo )x\n0\251\SYN+\140\234\160}"] -TEST(Subscribe5QCTest, Encode37) { - uint8_t pkt[] = {0x82, 0x78, 0x27, 0x61, 0x4c, 0x1f, 0x0, 0xf, 0xd6, 0xf3, 0x9a, 0x99, 0xb1, 0x63, 0xe5, 0x70, - 0xc6, 0xa8, 0xa, 0x2b, 0x7b, 0xfb, 0xc7, 0x2, 0x0, 0x0, 0x75, 0x46, 0x1, 0xb3, 0x28, 0x28, - 0x26, 0x0, 0x8, 0x2c, 0x40, 0x61, 0xc9, 0x6, 0x27, 0xf4, 0xdd, 0x0, 0x9, 0x40, 0x8, 0xff, - 0xd9, 0x5a, 0x9a, 0x54, 0x7d, 0xd8, 0x29, 0x82, 0x1, 0x60, 0x12, 0x0, 0x14, 0x4d, 0x52, 0xa6, - 0xc3, 0xb0, 0x2f, 0x78, 0x6f, 0x20, 0x29, 0x78, 0xa, 0x30, 0xfb, 0x16, 0x2b, 0x8c, 0xea, 0xa0, - 0x7d, 0x0, 0x11, 0xfe, 0xb6, 0xec, 0x8, 0x86, 0xaf, 0x41, 0x66, 0x79, 0x95, 0x70, 0x92, 0x29, - 0x18, 0xc4, 0x5d, 0xac, 0x0, 0x0, 0x12, 0x8c, 0x8d, 0xca, 0x59, 0x8c, 0x61, 0x42, 0x2d, 0x5, - 0x78, 0xc6, 0x69, 0xa8, 0x7f, 0x1b, 0xf4, 0xfa, 0x2d, 0x1}; - - uint8_t buf[132] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xfe, 0xb6, 0xec, 0x8, 0x86, 0xaf, 0x41, 0x66, 0x79, - 0x95, 0x70, 0x92, 0x29, 0x18, 0xc4, 0x5d, 0xac}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8c, 0x8d, 0xca, 0x59, 0x8c, 0x61, 0x42, 0x2d, 0x5, - 0x78, 0xc6, 0x69, 0xa8, 0x7f, 0x1b, 0xf4, 0xfa, 0x2d}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xd6, 0xf3, 0x9a, 0x99, 0xb1, 0x63, 0xe5, 0x70, 0xc6, 0xa8, 0xa, 0x2b, 0x7b, 0xfb, 0xc7}; - uint8_t bytesprops2[] = {0x40, 0x8, 0xff, 0xd9, 0x5a, 0x9a, 0x54, 0x7d, 0xd8}; - uint8_t bytesprops1[] = {0x2c, 0x40, 0x61, 0xc9, 0x6, 0x27, 0xf4, 0xdd}; - uint8_t bytesprops3[] = {0x4d, 0x52, 0xa6, 0xc3, 0xb0, 0x2f, 0x78, 0x6f, 0x20, 0x29, - 0x78, 0xa, 0x30, 0xfb, 0x16, 0x2b, 0x8c, 0xea, 0xa0, 0x7d}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30022}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops1}, .v = {9, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, - }; - - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10081, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12277 [("Qa\142\154\DC1\250'%d\167",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\251-\198\134\225\144X\220\STXN\142\199g*\SYN\128\238\209\135\238\166\183Q\232K)",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\173\&7va\196^-\248\&9\223;d\152(1\217u\154X\206\246\247\129o\211Z",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("8\207\165@\ESC\201\ri\241",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\141{KJ$\219&c3\196\b3,W\232`\131~\\\165\243\175\201\199E\240\SO6",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe5QCTest, Encode38) { - uint8_t pkt[] = {0x82, 0x75, 0x2f, 0xf5, 0x0, 0x0, 0xa, 0x51, 0x61, 0x8e, 0x9a, 0x11, 0xfa, 0x27, 0x25, 0x64, 0xa7, - 0x1, 0x0, 0x1a, 0xfb, 0x2d, 0xc6, 0x86, 0xe1, 0x90, 0x58, 0xdc, 0x2, 0x4e, 0x8e, 0xc7, 0x67, 0x2a, - 0x16, 0x80, 0xee, 0xd1, 0x87, 0xee, 0xa6, 0xb7, 0x51, 0xe8, 0x4b, 0x29, 0x1, 0x0, 0x1a, 0xad, 0x37, - 0x76, 0x61, 0xc4, 0x5e, 0x2d, 0xf8, 0x39, 0xdf, 0x3b, 0x64, 0x98, 0x28, 0x31, 0xd9, 0x75, 0x9a, 0x58, - 0xce, 0xf6, 0xf7, 0x81, 0x6f, 0xd3, 0x5a, 0x1, 0x0, 0x9, 0x38, 0xcf, 0xa5, 0x40, 0x1b, 0xc9, 0xd, - 0x69, 0xf1, 0x2, 0x0, 0x1c, 0x8d, 0x7b, 0x4b, 0x4a, 0x24, 0xdb, 0x26, 0x63, 0x33, 0xc4, 0x8, 0x33, - 0x2c, 0x57, 0xe8, 0x60, 0x83, 0x7e, 0x5c, 0xa5, 0xf3, 0xaf, 0xc9, 0xc7, 0x45, 0xf0, 0xe, 0x36, 0x0}; - - uint8_t buf[129] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x51, 0x61, 0x8e, 0x9a, 0x11, 0xfa, 0x27, 0x25, 0x64, 0xa7}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfb, 0x2d, 0xc6, 0x86, 0xe1, 0x90, 0x58, 0xdc, 0x2, 0x4e, 0x8e, 0xc7, 0x67, - 0x2a, 0x16, 0x80, 0xee, 0xd1, 0x87, 0xee, 0xa6, 0xb7, 0x51, 0xe8, 0x4b, 0x29}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xad, 0x37, 0x76, 0x61, 0xc4, 0x5e, 0x2d, 0xf8, 0x39, 0xdf, 0x3b, 0x64, 0x98, - 0x28, 0x31, 0xd9, 0x75, 0x9a, 0x58, 0xce, 0xf6, 0xf7, 0x81, 0x6f, 0xd3, 0x5a}; - lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x38, 0xcf, 0xa5, 0x40, 0x1b, 0xc9, 0xd, 0x69, 0xf1}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8d, 0x7b, 0x4b, 0x4a, 0x24, 0xdb, 0x26, 0x63, 0x33, 0xc4, - 0x8, 0x33, 0x2c, 0x57, 0xe8, 0x60, 0x83, 0x7e, 0x5c, 0xa5, - 0xf3, 0xaf, 0xc9, 0xc7, 0x45, 0xf0, 0xe, 0x36}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12277, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 518 [("\139\STXE:n\137b\f\184\166\168\143a\150+/\136,\154\148\190k\196u\189n\n",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropSubscriptionIdentifierAvailable 150,PropReasonString -// "b\253\SO\253\138\136t\232\141\182\SI\198O",PropMessageExpiryInterval 4658,PropWildcardSubscriptionAvailable -// 197,PropResponseTopic "\247!\184Y\240\b.\142\226l\195",PropAuthenticationMethod -// "\173\154u\SOHo#&H\213\207\162\253\203\237",PropMessageExpiryInterval 31275,PropSubscriptionIdentifierAvailable -// 128,PropAssignedClientIdentifier "",PropMessageExpiryInterval 10976,PropSubscriptionIdentifierAvailable -// 167,PropResponseTopic "\ESC\242EU\158I\242\FSB\205(#u\138\216\DLE\SIQ\\\171\227ae\206\&3",PropRetainAvailable -// 215,PropPayloadFormatIndicator 160,PropTopicAliasMaximum 10006,PropMaximumQoS 198] -TEST(Subscribe5QCTest, Encode39) { - uint8_t pkt[] = {0x82, 0x8f, 0x1, 0x2, 0x6, 0x6e, 0x29, 0x96, 0x1f, 0x0, 0xd, 0x62, 0xfd, 0xe, 0xfd, 0x8a, 0x88, - 0x74, 0xe8, 0x8d, 0xb6, 0xf, 0xc6, 0x4f, 0x2, 0x0, 0x0, 0x12, 0x32, 0x28, 0xc5, 0x8, 0x0, 0xb, - 0xf7, 0x21, 0xb8, 0x59, 0xf0, 0x8, 0x2e, 0x8e, 0xe2, 0x6c, 0xc3, 0x15, 0x0, 0xe, 0xad, 0x9a, 0x75, - 0x1, 0x6f, 0x23, 0x26, 0x48, 0xd5, 0xcf, 0xa2, 0xfd, 0xcb, 0xed, 0x2, 0x0, 0x0, 0x7a, 0x2b, 0x29, - 0x80, 0x12, 0x0, 0x0, 0x2, 0x0, 0x0, 0x2a, 0xe0, 0x29, 0xa7, 0x8, 0x0, 0x19, 0x1b, 0xf2, 0x45, - 0x55, 0x9e, 0x49, 0xf2, 0x1c, 0x42, 0xcd, 0x28, 0x23, 0x75, 0x8a, 0xd8, 0x10, 0xf, 0x51, 0x5c, 0xab, - 0xe3, 0x61, 0x65, 0xce, 0x33, 0x25, 0xd7, 0x1, 0xa0, 0x22, 0x27, 0x16, 0x24, 0xc6, 0x0, 0x1b, 0x8b, - 0x2, 0x45, 0x3a, 0x6e, 0x89, 0x62, 0xc, 0xb8, 0xa6, 0xa8, 0x8f, 0x61, 0x96, 0x2b, 0x2f, 0x88, 0x2c, - 0x9a, 0x94, 0xbe, 0x6b, 0xc4, 0x75, 0xbd, 0x6e, 0xa, 0x2}; - - uint8_t buf[156] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x8b, 0x2, 0x45, 0x3a, 0x6e, 0x89, 0x62, 0xc, 0xb8, 0xa6, 0xa8, 0x8f, 0x61, 0x96, - 0x2b, 0x2f, 0x88, 0x2c, 0x9a, 0x94, 0xbe, 0x6b, 0xc4, 0x75, 0xbd, 0x6e, 0xa}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x62, 0xfd, 0xe, 0xfd, 0x8a, 0x88, 0x74, 0xe8, 0x8d, 0xb6, 0xf, 0xc6, 0x4f}; - uint8_t bytesprops1[] = {0xf7, 0x21, 0xb8, 0x59, 0xf0, 0x8, 0x2e, 0x8e, 0xe2, 0x6c, 0xc3}; - uint8_t bytesprops2[] = {0xad, 0x9a, 0x75, 0x1, 0x6f, 0x23, 0x26, 0x48, 0xd5, 0xcf, 0xa2, 0xfd, 0xcb, 0xed}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x1b, 0xf2, 0x45, 0x55, 0x9e, 0x49, 0xf2, 0x1c, 0x42, 0xcd, 0x28, 0x23, 0x75, - 0x8a, 0xd8, 0x10, 0xf, 0x51, 0x5c, 0xab, 0xe3, 0x61, 0x65, 0xce, 0x33}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4658}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31275}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10976}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10006}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 198}}, - }; - - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 518, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 20513 [("\246\249y9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\174\158\&9I\236",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\234)\247\155]i\178i\160:\ENQ\162\186\204\194v^KTS.P\233&\189",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval -// 4904,PropRequestProblemInformation 22,PropMessageExpiryInterval 8007,PropMaximumQoS -// 78,PropWildcardSubscriptionAvailable 176,PropTopicAlias 11429,PropResponseTopic -// "V\180\210\236\&4\253U\210C\179\244bq",PropSharedSubscriptionAvailable 151,PropSharedSubscriptionAvailable -// 145,PropContentType "\167\237$\a\200\203\156\180\138\250\a\237@",PropServerKeepAlive 20621,PropCorrelationData -// "\129*~\205L\n\192_Q\207\167N8~\132rB\140\140z|+\223\128\238\218",PropSubscriptionIdentifier 3,PropTopicAliasMaximum -// 14322,PropResponseInformation "/?!\CAN-?w\249\223\207",PropRetainAvailable 126,PropMessageExpiryInterval -// 25279,PropMessageExpiryInterval 2138,PropRetainAvailable 215,PropServerReference -// "q,\210\STX\151b\139A",PropResponseTopic "$\177\175\161",PropServerKeepAlive 31943,PropSharedSubscriptionAvailable -// 237,PropPayloadFormatIndicator 39,PropSubscriptionIdentifierAvailable 194,PropResponseTopic -// "\169a\243Y",PropCorrelationData "\206S\135R\226:\157\245\247~\218\159\203\136",PropTopicAliasMaximum -// 6865,PropSubscriptionIdentifierAvailable 165] -TEST(Subscribe5QCTest, Encode40) { - uint8_t pkt[] = { - 0x82, 0xde, 0x1, 0x50, 0x21, 0xaf, 0x1, 0x2, 0x0, 0x0, 0x13, 0x28, 0x17, 0x16, 0x2, 0x0, 0x0, 0x1f, 0x47, - 0x24, 0x4e, 0x28, 0xb0, 0x23, 0x2c, 0xa5, 0x8, 0x0, 0xd, 0x56, 0xb4, 0xd2, 0xec, 0x34, 0xfd, 0x55, 0xd2, 0x43, - 0xb3, 0xf4, 0x62, 0x71, 0x2a, 0x97, 0x2a, 0x91, 0x3, 0x0, 0xd, 0xa7, 0xed, 0x24, 0x7, 0xc8, 0xcb, 0x9c, 0xb4, - 0x8a, 0xfa, 0x7, 0xed, 0x40, 0x13, 0x50, 0x8d, 0x9, 0x0, 0x1a, 0x81, 0x2a, 0x7e, 0xcd, 0x4c, 0xa, 0xc0, 0x5f, - 0x51, 0xcf, 0xa7, 0x4e, 0x38, 0x7e, 0x84, 0x72, 0x42, 0x8c, 0x8c, 0x7a, 0x7c, 0x2b, 0xdf, 0x80, 0xee, 0xda, 0xb, - 0x3, 0x22, 0x37, 0xf2, 0x1a, 0x0, 0xa, 0x2f, 0x3f, 0x21, 0x18, 0x2d, 0x3f, 0x77, 0xf9, 0xdf, 0xcf, 0x25, 0x7e, - 0x2, 0x0, 0x0, 0x62, 0xbf, 0x2, 0x0, 0x0, 0x8, 0x5a, 0x25, 0xd7, 0x1c, 0x0, 0x8, 0x71, 0x2c, 0xd2, 0x2, - 0x97, 0x62, 0x8b, 0x41, 0x8, 0x0, 0x4, 0x24, 0xb1, 0xaf, 0xa1, 0x13, 0x7c, 0xc7, 0x2a, 0xed, 0x1, 0x27, 0x29, - 0xc2, 0x8, 0x0, 0x4, 0xa9, 0x61, 0xf3, 0x59, 0x9, 0x0, 0xe, 0xce, 0x53, 0x87, 0x52, 0xe2, 0x3a, 0x9d, 0xf5, - 0xf7, 0x7e, 0xda, 0x9f, 0xcb, 0x88, 0x22, 0x1a, 0xd1, 0x29, 0xa5, 0x0, 0x4, 0xf6, 0xf9, 0x79, 0x39, 0x0, 0x0, - 0x5, 0xae, 0x9e, 0x39, 0x49, 0xec, 0x1, 0x0, 0x19, 0xea, 0x29, 0xf7, 0x9b, 0x5d, 0x69, 0xb2, 0x69, 0xa0, 0x3a, - 0x5, 0xa2, 0xba, 0xcc, 0xc2, 0x76, 0x5e, 0x4b, 0x54, 0x53, 0x2e, 0x50, 0xe9, 0x26, 0xbd, 0x1}; - - uint8_t buf[235] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xf6, 0xf9, 0x79, 0x39}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xae, 0x9e, 0x39, 0x49, 0xec}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xea, 0x29, 0xf7, 0x9b, 0x5d, 0x69, 0xb2, 0x69, 0xa0, 0x3a, 0x5, 0xa2, 0xba, - 0xcc, 0xc2, 0x76, 0x5e, 0x4b, 0x54, 0x53, 0x2e, 0x50, 0xe9, 0x26, 0xbd}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x56, 0xb4, 0xd2, 0xec, 0x34, 0xfd, 0x55, 0xd2, 0x43, 0xb3, 0xf4, 0x62, 0x71}; - uint8_t bytesprops1[] = {0xa7, 0xed, 0x24, 0x7, 0xc8, 0xcb, 0x9c, 0xb4, 0x8a, 0xfa, 0x7, 0xed, 0x40}; - uint8_t bytesprops2[] = {0x81, 0x2a, 0x7e, 0xcd, 0x4c, 0xa, 0xc0, 0x5f, 0x51, 0xcf, 0xa7, 0x4e, 0x38, - 0x7e, 0x84, 0x72, 0x42, 0x8c, 0x8c, 0x7a, 0x7c, 0x2b, 0xdf, 0x80, 0xee, 0xda}; - uint8_t bytesprops3[] = {0x2f, 0x3f, 0x21, 0x18, 0x2d, 0x3f, 0x77, 0xf9, 0xdf, 0xcf}; - uint8_t bytesprops4[] = {0x71, 0x2c, 0xd2, 0x2, 0x97, 0x62, 0x8b, 0x41}; - uint8_t bytesprops5[] = {0x24, 0xb1, 0xaf, 0xa1}; - uint8_t bytesprops6[] = {0xa9, 0x61, 0xf3, 0x59}; - uint8_t bytesprops7[] = {0xce, 0x53, 0x87, 0x52, 0xe2, 0x3a, 0x9d, 0xf5, 0xf7, 0x7e, 0xda, 0x9f, 0xcb, 0x88}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4904}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8007}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11429}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20621}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14322}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25279}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2138}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31943}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6865}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, - }; - - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20513, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 13179 [("YR\212\171\209\EOTx\164\209\197\US\155",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\235",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\172\250G",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\r\149\246#m\237\132i\162%c\ESC\144\159F`\229\254\ENQG",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("}O6\STX\EM\250D>\167\STX",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\140\134n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2})] [PropResponseTopic -// "<\185t\174\203e\SUBL\235\232\154\CAN_\199\217\164\&4R\161\ACK\239\v\211",PropTopicAlias 2853,PropServerKeepAlive -// 20997,PropResponseTopic ";\213",PropMaximumQoS 53,PropWillDelayInterval 19196,PropCorrelationData -// "\188\134\175\158\211}Z\208\157\137\SYN\130\US",PropPayloadFormatIndicator 46,PropAuthenticationData -// "\154\251",PropUserProperty "\243:\176T\161*\195\213\SOH" "\159",PropSubscriptionIdentifier 17,PropTopicAliasMaximum -// 19238,PropServerReference "",PropMessageExpiryInterval 20733,PropSubscriptionIdentifierAvailable 57,PropResponseTopic -// "\206\v\206_\179\190t",PropResponseInformation "l\219\230\175\255\171",PropServerKeepAlive 16101,PropTopicAlias -// 5826,PropSharedSubscriptionAvailable 113,PropRequestProblemInformation 166,PropReceiveMaximum 6526,PropTopicAlias -// 21054,PropSessionExpiryInterval 21021,PropSubscriptionIdentifierAvailable 245,PropMessageExpiryInterval -// 26743,PropReasonString "f\"w]\\\v\b\237U\227\144\r\216\137.kl\130X/\DC16+\ESC{\ETBD]X",PropSessionExpiryInterval -// 9739,PropSubscriptionIdentifier 3,PropTopicAlias 22499] -TEST(Subscribe5QCTest, Encode41) { - uint8_t pkt[] = { - 0x82, 0x84, 0x2, 0x33, 0x7b, 0xba, 0x1, 0x8, 0x0, 0x17, 0x3c, 0xb9, 0x74, 0xae, 0xcb, 0x65, 0x1a, 0x4c, 0xeb, - 0xe8, 0x9a, 0x18, 0x5f, 0xc7, 0xd9, 0xa4, 0x34, 0x52, 0xa1, 0x6, 0xef, 0xb, 0xd3, 0x23, 0xb, 0x25, 0x13, 0x52, - 0x5, 0x8, 0x0, 0x2, 0x3b, 0xd5, 0x24, 0x35, 0x18, 0x0, 0x0, 0x4a, 0xfc, 0x9, 0x0, 0xd, 0xbc, 0x86, 0xaf, - 0x9e, 0xd3, 0x7d, 0x5a, 0xd0, 0x9d, 0x89, 0x16, 0x82, 0x1f, 0x1, 0x2e, 0x16, 0x0, 0x2, 0x9a, 0xfb, 0x26, 0x0, - 0x9, 0xf3, 0x3a, 0xb0, 0x54, 0xa1, 0x2a, 0xc3, 0xd5, 0x1, 0x0, 0x1, 0x9f, 0xb, 0x11, 0x22, 0x4b, 0x26, 0x1c, - 0x0, 0x0, 0x2, 0x0, 0x0, 0x50, 0xfd, 0x29, 0x39, 0x8, 0x0, 0x7, 0xce, 0xb, 0xce, 0x5f, 0xb3, 0xbe, 0x74, - 0x1a, 0x0, 0x6, 0x6c, 0xdb, 0xe6, 0xaf, 0xff, 0xab, 0x13, 0x3e, 0xe5, 0x23, 0x16, 0xc2, 0x2a, 0x71, 0x17, 0xa6, - 0x21, 0x19, 0x7e, 0x23, 0x52, 0x3e, 0x11, 0x0, 0x0, 0x52, 0x1d, 0x29, 0xf5, 0x2, 0x0, 0x0, 0x68, 0x77, 0x1f, - 0x0, 0x1d, 0x66, 0x22, 0x77, 0x5d, 0x5c, 0xb, 0x8, 0xed, 0x55, 0xe3, 0x90, 0xd, 0xd8, 0x89, 0x2e, 0x6b, 0x6c, - 0x82, 0x58, 0x2f, 0x11, 0x36, 0x2b, 0x1b, 0x7b, 0x17, 0x44, 0x5d, 0x58, 0x11, 0x0, 0x0, 0x26, 0xb, 0xb, 0x3, - 0x23, 0x57, 0xe3, 0x0, 0xc, 0x59, 0x52, 0xd4, 0xab, 0xd1, 0x4, 0x78, 0xa4, 0xd1, 0xc5, 0x1f, 0x9b, 0x1, 0x0, - 0x1, 0xeb, 0x1, 0x0, 0x3, 0xac, 0xfa, 0x47, 0x2, 0x0, 0x0, 0x2, 0x0, 0x14, 0xd, 0x95, 0xf6, 0x23, 0x6d, - 0xed, 0x84, 0x69, 0xa2, 0x25, 0x63, 0x1b, 0x90, 0x9f, 0x46, 0x60, 0xe5, 0xfe, 0x5, 0x47, 0x1, 0x0, 0xa, 0x7d, - 0x4f, 0x36, 0x2, 0x19, 0xfa, 0x44, 0x3e, 0xa7, 0x2, 0x0, 0x0, 0x3, 0x8c, 0x86, 0x6e, 0x2}; - - uint8_t buf[273] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x59, 0x52, 0xd4, 0xab, 0xd1, 0x4, 0x78, 0xa4, 0xd1, 0xc5, 0x1f, 0x9b}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xeb}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xac, 0xfa, 0x47}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd, 0x95, 0xf6, 0x23, 0x6d, 0xed, 0x84, 0x69, 0xa2, 0x25, - 0x63, 0x1b, 0x90, 0x9f, 0x46, 0x60, 0xe5, 0xfe, 0x5, 0x47}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7d, 0x4f, 0x36, 0x2, 0x19, 0xfa, 0x44, 0x3e, 0xa7, 0x2}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8c, 0x86, 0x6e}; - lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x3c, 0xb9, 0x74, 0xae, 0xcb, 0x65, 0x1a, 0x4c, 0xeb, 0xe8, 0x9a, 0x18, - 0x5f, 0xc7, 0xd9, 0xa4, 0x34, 0x52, 0xa1, 0x6, 0xef, 0xb, 0xd3}; - uint8_t bytesprops1[] = {0x3b, 0xd5}; - uint8_t bytesprops2[] = {0xbc, 0x86, 0xaf, 0x9e, 0xd3, 0x7d, 0x5a, 0xd0, 0x9d, 0x89, 0x16, 0x82, 0x1f}; - uint8_t bytesprops3[] = {0x9a, 0xfb}; - uint8_t bytesprops5[] = {0x9f}; - uint8_t bytesprops4[] = {0xf3, 0x3a, 0xb0, 0x54, 0xa1, 0x2a, 0xc3, 0xd5, 0x1}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops7[] = {0xce, 0xb, 0xce, 0x5f, 0xb3, 0xbe, 0x74}; - uint8_t bytesprops8[] = {0x6c, 0xdb, 0xe6, 0xaf, 0xff, 0xab}; - uint8_t bytesprops9[] = {0x66, 0x22, 0x77, 0x5d, 0x5c, 0xb, 0x8, 0xed, 0x55, 0xe3, 0x90, 0xd, 0xd8, 0x89, 0x2e, - 0x6b, 0x6c, 0x82, 0x58, 0x2f, 0x11, 0x36, 0x2b, 0x1b, 0x7b, 0x17, 0x44, 0x5d, 0x58}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2853}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20997}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19196}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops4}, .v = {1, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19238}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20733}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16101}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5826}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6526}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21054}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21021}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26743}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9739}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22499}}, - }; - - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13179, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2708 [("\128\SUB\143\242\FS\143\181\142tg\159H\SI\193<",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\STX\194;\241\194\228a\t\191u0o\203O|\SUBV\174x\171\235\159\149\&6",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("4\173\128\155%\a\234\DLE\166\&1\188\EOT@\142qQuA\154N",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\169p4\162\139:?",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\130)\226\134",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropReasonString -// "J=\154\157t\176\185\252\239`r~j=",PropServerReference "\207\220\145R",PropServerKeepAlive 4925,PropContentType -// "\170\212\219I_\147\151uT\216~\248\200\240u\rU\DLE\148P\252'\180\207\RS\177",PropTopicAlias -// 1012,PropSharedSubscriptionAvailable 102,PropMessageExpiryInterval 4429,PropReasonString -// "\SOH\NUL\DC2\156\138\243\242i\182",PropContentType -// "\217\229\179\184v(\170\228\197\128\EM\184",PropSessionExpiryInterval 751,PropMessageExpiryInterval -// 2764,PropPayloadFormatIndicator 141,PropUserProperty "aef\RS\177" -// "\227\151\225\SOH~i\DC1ri\252\151\131\192\a\250\220\182`\174",PropTopicAliasMaximum 23948,PropMaximumPacketSize -// 15730] -TEST(Subscribe5QCTest, Encode42) { - uint8_t pkt[] = {0x82, 0xe7, 0x1, 0xa, 0x94, 0x8e, 0x1, 0x1f, 0x0, 0xe, 0x4a, 0x3d, 0x9a, 0x9d, 0x74, 0xb0, 0xb9, - 0xfc, 0xef, 0x60, 0x72, 0x7e, 0x6a, 0x3d, 0x1c, 0x0, 0x4, 0xcf, 0xdc, 0x91, 0x52, 0x13, 0x13, 0x3d, - 0x3, 0x0, 0x1a, 0xaa, 0xd4, 0xdb, 0x49, 0x5f, 0x93, 0x97, 0x75, 0x54, 0xd8, 0x7e, 0xf8, 0xc8, 0xf0, - 0x75, 0xd, 0x55, 0x10, 0x94, 0x50, 0xfc, 0x27, 0xb4, 0xcf, 0x1e, 0xb1, 0x23, 0x3, 0xf4, 0x2a, 0x66, - 0x2, 0x0, 0x0, 0x11, 0x4d, 0x1f, 0x0, 0x9, 0x1, 0x0, 0x12, 0x9c, 0x8a, 0xf3, 0xf2, 0x69, 0xb6, - 0x3, 0x0, 0xc, 0xd9, 0xe5, 0xb3, 0xb8, 0x76, 0x28, 0xaa, 0xe4, 0xc5, 0x80, 0x19, 0xb8, 0x11, 0x0, - 0x0, 0x2, 0xef, 0x2, 0x0, 0x0, 0xa, 0xcc, 0x1, 0x8d, 0x26, 0x0, 0x5, 0x61, 0x65, 0x66, 0x1e, - 0xb1, 0x0, 0x13, 0xe3, 0x97, 0xe1, 0x1, 0x7e, 0x69, 0x11, 0x72, 0x69, 0xfc, 0x97, 0x83, 0xc0, 0x7, - 0xfa, 0xdc, 0xb6, 0x60, 0xae, 0x22, 0x5d, 0x8c, 0x27, 0x0, 0x0, 0x3d, 0x72, 0x0, 0xf, 0x80, 0x1a, - 0x8f, 0xf2, 0x1c, 0x8f, 0xb5, 0x8e, 0x74, 0x67, 0x9f, 0x48, 0xf, 0xc1, 0x3c, 0x1, 0x0, 0x18, 0x2, - 0xc2, 0x3b, 0xf1, 0xc2, 0xe4, 0x61, 0x9, 0xbf, 0x75, 0x30, 0x6f, 0xcb, 0x4f, 0x7c, 0x1a, 0x56, 0xae, - 0x78, 0xab, 0xeb, 0x9f, 0x95, 0x36, 0x2, 0x0, 0x14, 0x34, 0xad, 0x80, 0x9b, 0x25, 0x7, 0xea, 0x10, - 0xa6, 0x31, 0xbc, 0x4, 0x40, 0x8e, 0x71, 0x51, 0x75, 0x41, 0x9a, 0x4e, 0x1, 0x0, 0x7, 0xa9, 0x70, - 0x34, 0xa2, 0x8b, 0x3a, 0x3f, 0x1, 0x0, 0x4, 0x82, 0x29, 0xe2, 0x86, 0x0}; - - uint8_t buf[244] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x80, 0x1a, 0x8f, 0xf2, 0x1c, 0x8f, 0xb5, 0x8e, - 0x74, 0x67, 0x9f, 0x48, 0xf, 0xc1, 0x3c}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2, 0xc2, 0x3b, 0xf1, 0xc2, 0xe4, 0x61, 0x9, 0xbf, 0x75, 0x30, 0x6f, - 0xcb, 0x4f, 0x7c, 0x1a, 0x56, 0xae, 0x78, 0xab, 0xeb, 0x9f, 0x95, 0x36}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x34, 0xad, 0x80, 0x9b, 0x25, 0x7, 0xea, 0x10, 0xa6, 0x31, - 0xbc, 0x4, 0x40, 0x8e, 0x71, 0x51, 0x75, 0x41, 0x9a, 0x4e}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa9, 0x70, 0x34, 0xa2, 0x8b, 0x3a, 0x3f}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x82, 0x29, 0xe2, 0x86}; - lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x4a, 0x3d, 0x9a, 0x9d, 0x74, 0xb0, 0xb9, 0xfc, 0xef, 0x60, 0x72, 0x7e, 0x6a, 0x3d}; - uint8_t bytesprops1[] = {0xcf, 0xdc, 0x91, 0x52}; - uint8_t bytesprops2[] = {0xaa, 0xd4, 0xdb, 0x49, 0x5f, 0x93, 0x97, 0x75, 0x54, 0xd8, 0x7e, 0xf8, 0xc8, - 0xf0, 0x75, 0xd, 0x55, 0x10, 0x94, 0x50, 0xfc, 0x27, 0xb4, 0xcf, 0x1e, 0xb1}; - uint8_t bytesprops3[] = {0x1, 0x0, 0x12, 0x9c, 0x8a, 0xf3, 0xf2, 0x69, 0xb6}; - uint8_t bytesprops4[] = {0xd9, 0xe5, 0xb3, 0xb8, 0x76, 0x28, 0xaa, 0xe4, 0xc5, 0x80, 0x19, 0xb8}; - uint8_t bytesprops6[] = {0xe3, 0x97, 0xe1, 0x1, 0x7e, 0x69, 0x11, 0x72, 0x69, 0xfc, - 0x97, 0x83, 0xc0, 0x7, 0xfa, 0xdc, 0xb6, 0x60, 0xae}; - uint8_t bytesprops5[] = {0x61, 0x65, 0x66, 0x1e, 0xb1}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4925}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1012}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4429}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 751}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2764}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops5}, .v = {19, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23948}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15730}}, - }; - - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2708, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 22393 [("4\151\147%\225\205\145\214",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\170\240\162w`E\254\232 -// \143\DC2x\209h3\148\197\DEL\195~\165h\DLE\232\201Bm",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\248\158\234\227[R.\240VV'\227@\DC3)\DLE\242\199\US\199\221H\199",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationData -// "",PropContentType "\206o\195\135\253\250\246\193\205\200\172\238|VO\rv\158\&4",PropServerKeepAlive -// 16840,PropSharedSubscriptionAvailable 14,PropResponseInformation -// ":E-\170:\ESC\232\GS\196A\166\168\238\182\220",PropAuthenticationMethod "b\STX4#\201",PropServerReference -// "\205\208\156\255a5A0\144<_\148\SIs\SI\152\130\137'\203",PropTopicAlias 19282,PropRequestResponseInformation -// 145,PropAssignedClientIdentifier -// "\161\193;\174\250\190\142Z\209Q\157\DC1'\210o\252\161g\a\132\141|\176p\FSh\173\186#D",PropCorrelationData -// "\147{\164A$\149\204ln\162]\220\162\&9NY",PropAssignedClientIdentifier "4\215\137cz\DC16&]",PropContentType -// "[`\147=\ETB\185\136\221\252\200\US\DC2\f\236\&9\198\205rkz\SI\171\&9\164\EM\227",PropUserProperty -// "\DC1\144\DLE\EMV|h\226\230u\205\194B\236\ETB/\220&\US\216s\EM\EOT4\177\a\178\175S\a" -// "\255\197\253\226\";\213\241S\225\194Y\169\SI1\133\180\140\240$Yo",PropAuthenticationData -// "*\130\DC3\239\&6\SI\206\252\156\223\\oS\NUL\216\164\NUL,\SOH\a",PropMaximumPacketSize 1890,PropUserProperty -// "\131\252\204\242\138\241\154\145\184\216\142\&9\187F\NAKU/\148a\179\205\DC3" -// "gQ\206\227\230\216\240\b\DEL|\144\135`\197\217Vx=\234\178i\244",PropRequestResponseInformation 81,PropUserProperty -// "\240{G" "",PropMaximumPacketSize 2959,PropWillDelayInterval 10548,PropReceiveMaximum -// 30850,PropSubscriptionIdentifierAvailable 177,PropMaximumQoS 0,PropWillDelayInterval 17382,PropCorrelationData -// "k'\188)\161\143",PropPayloadFormatIndicator 3,PropTopicAlias 7431,PropMaximumQoS 180] -TEST(Subscribe5QCTest, Encode43) { - uint8_t pkt[] = { - 0x82, 0xae, 0x3, 0x57, 0x79, 0xe7, 0x2, 0x16, 0x0, 0x0, 0x3, 0x0, 0x13, 0xce, 0x6f, 0xc3, 0x87, 0xfd, 0xfa, - 0xf6, 0xc1, 0xcd, 0xc8, 0xac, 0xee, 0x7c, 0x56, 0x4f, 0xd, 0x76, 0x9e, 0x34, 0x13, 0x41, 0xc8, 0x2a, 0xe, 0x1a, - 0x0, 0xf, 0x3a, 0x45, 0x2d, 0xaa, 0x3a, 0x1b, 0xe8, 0x1d, 0xc4, 0x41, 0xa6, 0xa8, 0xee, 0xb6, 0xdc, 0x15, 0x0, - 0x5, 0x62, 0x2, 0x34, 0x23, 0xc9, 0x1c, 0x0, 0x14, 0xcd, 0xd0, 0x9c, 0xff, 0x61, 0x35, 0x41, 0x30, 0x90, 0x3c, - 0x5f, 0x94, 0xf, 0x73, 0xf, 0x98, 0x82, 0x89, 0x27, 0xcb, 0x23, 0x4b, 0x52, 0x19, 0x91, 0x12, 0x0, 0x1e, 0xa1, - 0xc1, 0x3b, 0xae, 0xfa, 0xbe, 0x8e, 0x5a, 0xd1, 0x51, 0x9d, 0x11, 0x27, 0xd2, 0x6f, 0xfc, 0xa1, 0x67, 0x7, 0x84, - 0x8d, 0x7c, 0xb0, 0x70, 0x1c, 0x68, 0xad, 0xba, 0x23, 0x44, 0x9, 0x0, 0x10, 0x93, 0x7b, 0xa4, 0x41, 0x24, 0x95, - 0xcc, 0x6c, 0x6e, 0xa2, 0x5d, 0xdc, 0xa2, 0x39, 0x4e, 0x59, 0x12, 0x0, 0x9,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 0x18, 0x0, 0x0, 0x29, 0x34, 0x21, 0x78, 0x82, 0x29, - 0xb1, 0x24, 0x0, 0x18, 0x0, 0x0, 0x43, 0xe6, 0x9, 0x0, 0x6, 0x6b, 0x27, 0xbc, 0x29, 0xa1, 0x8f, 0x1, 0x3, - 0x23, 0x1d, 0x7, 0x24, 0xb4, 0x0, 0x8, 0x34, 0x97, 0x93, 0x25, 0xe1, 0xcd, 0x91, 0xd6, 0x2, 0x0, 0x1b, 0xaa, - 0xf0, 0xa2, 0x77, 0x60, 0x45, 0xfe, 0xe8, 0x20, 0x8f, 0x12, 0x78, 0xd1, 0x68, 0x33, 0x94, 0xc5, 0x7f, 0xc3, 0x7e, - 0xa5, 0x68, 0x10, 0xe8, 0xc9, 0x42, 0x6d, 0x2, 0x0, 0x17, 0xf8, 0x9e, 0xea, 0xe3, 0x5b, 0x52, 0x2e, 0xf0, 0x56, - 0x56, 0x27, 0xe3, 0x40, 0x13, 0x29, 0x10, 0xf2, 0xc7, 0x1f, 0xc7, 0xdd, 0x48, 0xc7, 0x0}; - - uint8_t buf[443] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x34, 0x97, 0x93, 0x25, 0xe1, 0xcd, 0x91, 0xd6}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xaa, 0xf0, 0xa2, 0x77, 0x60, 0x45, 0xfe, 0xe8, 0x20, 0x8f, 0x12, 0x78, 0xd1, 0x68, - 0x33, 0x94, 0xc5, 0x7f, 0xc3, 0x7e, 0xa5, 0x68, 0x10, 0xe8, 0xc9, 0x42, 0x6d}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf8, 0x9e, 0xea, 0xe3, 0x5b, 0x52, 0x2e, 0xf0, 0x56, 0x56, 0x27, 0xe3, - 0x40, 0x13, 0x29, 0x10, 0xf2, 0xc7, 0x1f, 0xc7, 0xdd, 0x48, 0xc7}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xce, 0x6f, 0xc3, 0x87, 0xfd, 0xfa, 0xf6, 0xc1, 0xcd, 0xc8, - 0xac, 0xee, 0x7c, 0x56, 0x4f, 0xd, 0x76, 0x9e, 0x34}; - uint8_t bytesprops2[] = {0x3a, 0x45, 0x2d, 0xaa, 0x3a, 0x1b, 0xe8, 0x1d, 0xc4, 0x41, 0xa6, 0xa8, 0xee, 0xb6, 0xdc}; - uint8_t bytesprops3[] = {0x62, 0x2, 0x34, 0x23, 0xc9}; - uint8_t bytesprops4[] = {0xcd, 0xd0, 0x9c, 0xff, 0x61, 0x35, 0x41, 0x30, 0x90, 0x3c, - 0x5f, 0x94, 0xf, 0x73, 0xf, 0x98, 0x82, 0x89, 0x27, 0xcb}; - uint8_t bytesprops5[] = {0xa1, 0xc1, 0x3b, 0xae, 0xfa, 0xbe, 0x8e, 0x5a, 0xd1, 0x51, 0x9d, 0x11, 0x27, 0xd2, 0x6f, - 0xfc, 0xa1, 0x67, 0x7, 0x84, 0x8d, 0x7c, 0xb0, 0x70, 0x1c, 0x68, 0xad, 0xba, 0x23, 0x44}; - uint8_t bytesprops6[] = {0x93, 0x7b, 0xa4, 0x41, 0x24, 0x95, 0xcc, 0x6c, - 0x6e, 0xa2, 0x5d, 0xdc, 0xa2, 0x39, 0x4e, 0x59}; - uint8_t bytesprops7[] = {0x34, 0xd7, 0x89, 0x63, 0x7a, 0x11, 0x36, 0x26, 0x5d}; - uint8_t bytesprops8[] = {0x5b, 0x60, 0x93, 0x3d, 0x17, 0xb9, 0x88, 0xdd, 0xfc, 0xc8, 0x1f, 0x12, 0xc, - 0xec, 0x39, 0xc6, 0xcd, 0x72, 0x6b, 0x7a, 0xf, 0xab, 0x39, 0xa4, 0x19, 0xe3}; - uint8_t bytesprops10[] = {0xff, 0xc5, 0xfd, 0xe2, 0x22, 0x3b, 0xd5, 0xf1, 0x53, 0xe1, 0xc2, - 0x59, 0xa9, 0xf, 0x31, 0x85, 0xb4, 0x8c, 0xf0, 0x24, 0x59, 0x6f}; - uint8_t bytesprops9[] = {0x11, 0x90, 0x10, 0x19, 0x56, 0x7c, 0x68, 0xe2, 0xe6, 0x75, 0xcd, 0xc2, 0x42, 0xec, 0x17, - 0x2f, 0xdc, 0x26, 0x1f, 0xd8, 0x73, 0x19, 0x4, 0x34, 0xb1, 0x7, 0xb2, 0xaf, 0x53, 0x7}; - uint8_t bytesprops11[] = {0x2a, 0x82, 0x13, 0xef, 0x36, 0xf, 0xce, 0xfc, 0x9c, 0xdf, - 0x5c, 0x6f, 0x53, 0x0, 0xd8, 0xa4, 0x0, 0x2c, 0x1, 0x7}; - uint8_t bytesprops13[] = {0x67, 0x51, 0xce, 0xe3, 0xe6, 0xd8, 0xf0, 0x8, 0x7f, 0x7c, 0x90, - 0x87, 0x60, 0xc5, 0xd9, 0x56, 0x78, 0x3d, 0xea, 0xb2, 0x69, 0xf4}; - uint8_t bytesprops12[] = {0x83, 0xfc, 0xcc, 0xf2, 0x8a, 0xf1, 0x9a, 0x91, 0xb8, 0xd8, 0x8e, - 0x39, 0xbb, 0x46, 0x15, 0x55, 0x2f, 0x94, 0x61, 0xb3, 0xcd, 0x13}; - uint8_t bytesprops15[] = {0}; - uint8_t bytesprops14[] = {0xf0, 0x7b, 0x47}; - uint8_t bytesprops16[] = {0x6b, 0x27, 0xbc, 0x29, 0xa1, 0x8f}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16840}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19282}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops9}, .v = {22, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1890}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {22, (char*)&bytesprops12}, .v = {22, (char*)&bytesprops13}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops14}, .v = {0, (char*)&bytesprops15}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2959}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10548}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30850}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17382}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops16}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7431}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 180}}, - }; - - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22393, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 16009 [("\v\252$!\153S\184\231\225\247\182w\185\196\179\251-)D\130W\129\222\SYNQ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Bn\211\153\\\EOT\238\190\196\180C1\146B\199\236h\DC1\210\&9,\147I",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\EOT;7\159\130c%\243\CAN\148\213\v\247'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\220\225\t\132\131\223\183",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropTopicAliasMaximum -// 20116,PropWildcardSubscriptionAvailable 84,PropWildcardSubscriptionAvailable 215,PropRetainAvailable -// 70,PropResponseTopic "\"?~\SI\178\156\215b\173`\235\DC2\243\ACK\165Q\157",PropRetainAvailable -// 7,PropRequestResponseInformation 91,PropReceiveMaximum 2391,PropTopicAliasMaximum -// 28497,PropSharedSubscriptionAvailable 22,PropRequestResponseInformation 239,PropAuthenticationData -// "A(\159\209\179$o\137>",PropReasonString "\202P -// \219\129\206D\\\214\165\237\195\SOH\209,\244\215t\DELg^\SOH\167\135",PropAuthenticationData -// "#\253T\223(8\215o\244cA\162\252\EM\DC2\160P\148\r>1\215\136\164!",PropTopicAlias 15751] -TEST(Subscribe5QCTest, Encode44) { - uint8_t pkt[] = {0x82, 0xc5, 0x1, 0x3e, 0x89, 0x71, 0x22, 0x4e, 0x94, 0x28, 0x54, 0x28, 0xd7, 0x25, 0x46, 0x8, 0x0, - 0x11, 0x22, 0x3f, 0x7e, 0xf, 0xb2, 0x9c, 0xd7, 0x62, 0xad, 0x60, 0xeb, 0x12, 0xf3, 0x6, 0xa5, 0x51, - 0x9d, 0x25, 0x7, 0x19, 0x5b, 0x21, 0x9, 0x57, 0x22, 0x6f, 0x51, 0x2a, 0x16, 0x19, 0xef, 0x16, 0x0, - 0x9, 0x41, 0x28, 0x9f, 0xd1, 0xb3, 0x24, 0x6f, 0x89, 0x3e, 0x1f, 0x0, 0x18, 0xca, 0x50, 0x20, 0xdb, - 0x81, 0xce, 0x44, 0x5c, 0xd6, 0xa5, 0xed, 0xc3, 0x1, 0xd1, 0x2c, 0xf4, 0xd7, 0x74, 0x7f, 0x67, 0x5e, - 0x1, 0xa7, 0x87, 0x16, 0x0, 0x19, 0x23, 0xfd, 0x54, 0xdf, 0x28, 0x38, 0xd7, 0x6f, 0xf4, 0x63, 0x41, - 0xa2, 0xfc, 0x19, 0x12, 0xa0, 0x50, 0x94, 0xd, 0x3e, 0x31, 0xd7, 0x88, 0xa4, 0x21, 0x23, 0x3d, 0x87, - 0x0, 0x19, 0xb, 0xfc, 0x24, 0x21, 0x99, 0x53, 0xb8, 0xe7, 0xe1, 0xf7, 0xb6, 0x77, 0xb9, 0xc4, 0xb3, - 0xfb, 0x2d, 0x29, 0x44, 0x82, 0x57, 0x81, 0xde, 0x16, 0x51, 0x2, 0x0, 0x17, 0x42, 0x6e, 0xd3, 0x99, - 0x5c, 0x4, 0xee, 0xbe, 0xc4, 0xb4, 0x43, 0x31, 0x92, 0x42, 0xc7, 0xec, 0x68, 0x11, 0xd2, 0x39, 0x2c, - 0x93, 0x49, 0x1, 0x0, 0xe, 0x4, 0x3b, 0x37, 0x9f, 0x82, 0x63, 0x25, 0xf3, 0x18, 0x94, 0xd5, 0xb, - 0xf7, 0x27, 0x1, 0x0, 0x7, 0xdc, 0xe1, 0x9, 0x84, 0x83, 0xdf, 0xb7, 0x1}; - - uint8_t buf[210] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xb, 0xfc, 0x24, 0x21, 0x99, 0x53, 0xb8, 0xe7, 0xe1, 0xf7, 0xb6, 0x77, 0xb9, - 0xc4, 0xb3, 0xfb, 0x2d, 0x29, 0x44, 0x82, 0x57, 0x81, 0xde, 0x16, 0x51}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x42, 0x6e, 0xd3, 0x99, 0x5c, 0x4, 0xee, 0xbe, 0xc4, 0xb4, 0x43, 0x31, - 0x92, 0x42, 0xc7, 0xec, 0x68, 0x11, 0xd2, 0x39, 0x2c, 0x93, 0x49}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4, 0x3b, 0x37, 0x9f, 0x82, 0x63, 0x25, 0xf3, 0x18, 0x94, 0xd5, 0xb, 0xf7, 0x27}; - lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xdc, 0xe1, 0x9, 0x84, 0x83, 0xdf, 0xb7}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x22, 0x3f, 0x7e, 0xf, 0xb2, 0x9c, 0xd7, 0x62, 0xad, - 0x60, 0xeb, 0x12, 0xf3, 0x6, 0xa5, 0x51, 0x9d}; - uint8_t bytesprops1[] = {0x41, 0x28, 0x9f, 0xd1, 0xb3, 0x24, 0x6f, 0x89, 0x3e}; - uint8_t bytesprops2[] = {0xca, 0x50, 0x20, 0xdb, 0x81, 0xce, 0x44, 0x5c, 0xd6, 0xa5, 0xed, 0xc3, - 0x1, 0xd1, 0x2c, 0xf4, 0xd7, 0x74, 0x7f, 0x67, 0x5e, 0x1, 0xa7, 0x87}; - uint8_t bytesprops3[] = {0x23, 0xfd, 0x54, 0xdf, 0x28, 0x38, 0xd7, 0x6f, 0xf4, 0x63, 0x41, 0xa2, 0xfc, - 0x19, 0x12, 0xa0, 0x50, 0x94, 0xd, 0x3e, 0x31, 0xd7, 0x88, 0xa4, 0x21}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20116}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2391}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28497}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15751}}, - }; - - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16009, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14676 [("\219\215v\249b\191\208\&8H\181\rI&\210",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAssignedClientIdentifier -// "",PropResponseInformation "\SOMU\195",PropServerKeepAlive 9648,PropUserProperty "0 -// \"\229\155\171a\226\215\CAN\219\135\212\175P\202\172\179\251'q" -// "\187e\228\130\212>\155\230,`5\DC3\159\182\177\DC1\b\ESCT\135\GS\CAN\239\b\177\203\248",PropReasonString -// "I\237\USN\131\238C\177C",PropResponseInformation "xr\130a\v\244\180q*+\200\209\159\206\188\244\148["] -TEST(Subscribe5QCTest, Encode45) { - uint8_t pkt[] = {0x82, 0x77, 0x39, 0x54, 0x63, 0x12, 0x0, 0x0, 0x1a, 0x0, 0x4, 0xe, 0x4d, 0x55, 0xc3, 0x13, - 0x25, 0xb0, 0x26, 0x0, 0x15, 0x30, 0x20, 0x22, 0xe5, 0x9b, 0xab, 0x61, 0xe2, 0xd7, 0x18, 0xdb, - 0x87, 0xd4, 0xaf, 0x50, 0xca, 0xac, 0xb3, 0xfb, 0x27, 0x71, 0x0, 0x1b, 0xbb, 0x65, 0xe4, 0x82, - 0xd4, 0x3e, 0x9b, 0xe6, 0x2c, 0x60, 0x35, 0x13, 0x9f, 0xb6, 0xb1, 0x11, 0x8, 0x1b, 0x54, 0x87, - 0x1d, 0x18, 0xef, 0x8, 0xb1, 0xcb, 0xf8, 0x1f, 0x0, 0x9, 0x49, 0xed, 0x1f, 0x4e, 0x83, 0xee, - 0x43, 0xb1, 0x43, 0x1a, 0x0, 0x12, 0x78, 0x72, 0x82, 0x61, 0xb, 0xf4, 0xb4, 0x71, 0x2a, 0x2b, - 0xc8, 0xd1, 0x9f, 0xce, 0xbc, 0xf4, 0x94, 0x5b, 0x0, 0xe, 0xdb, 0xd7, 0x76, 0xf9, 0x62, 0xbf, - 0xd0, 0x38, 0x48, 0xb5, 0xd, 0x49, 0x26, 0xd2, 0x1}; - - uint8_t buf[131] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xdb, 0xd7, 0x76, 0xf9, 0x62, 0xbf, 0xd0, 0x38, 0x48, 0xb5, 0xd, 0x49, 0x26, 0xd2}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xe, 0x4d, 0x55, 0xc3}; - uint8_t bytesprops3[] = {0xbb, 0x65, 0xe4, 0x82, 0xd4, 0x3e, 0x9b, 0xe6, 0x2c, 0x60, 0x35, 0x13, 0x9f, 0xb6, - 0xb1, 0x11, 0x8, 0x1b, 0x54, 0x87, 0x1d, 0x18, 0xef, 0x8, 0xb1, 0xcb, 0xf8}; - uint8_t bytesprops2[] = {0x30, 0x20, 0x22, 0xe5, 0x9b, 0xab, 0x61, 0xe2, 0xd7, 0x18, 0xdb, - 0x87, 0xd4, 0xaf, 0x50, 0xca, 0xac, 0xb3, 0xfb, 0x27, 0x71}; - uint8_t bytesprops4[] = {0x49, 0xed, 0x1f, 0x4e, 0x83, 0xee, 0x43, 0xb1, 0x43}; - uint8_t bytesprops5[] = {0x78, 0x72, 0x82, 0x61, 0xb, 0xf4, 0xb4, 0x71, 0x2a, - 0x2b, 0xc8, 0xd1, 0x9f, 0xce, 0xbc, 0xf4, 0x94, 0x5b}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9648}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {27, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14676, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2406 -// [("\154wi\237\149\207\222\244\234fa?\209A\DEL\205\221\&5\DLE\224@\211\160\208\239\&0\134\SO\NUL",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("L|I\231\128\172e\STX@\198x",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("Sa \169\184R\183\199\225\251\153%v6\228H\"\244J\193",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(";\"\b\143\221\r",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\210\147\237\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\141\237\229\157\173\ETXX/\224\174,\\\236\228",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\219\SOH\f)\241\252",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropMaximumPacketSize 29740,PropRequestResponseInformation 178,PropMessageExpiryInterval 17484,PropMaximumQoS -// 17,PropMaximumPacketSize 22624,PropSessionExpiryInterval 7138,PropResponseTopic -// "\180\242\156{\131p\177\222",PropResponseInformation -// "\139\227\221\&7\213\177'78/\186\215\133\GS\155\\Jy\143\a\217\239\181\247=~\NUL,j",PropSessionExpiryInterval -// 22972,PropWillDelayInterval 18526,PropReceiveMaximum 11707,PropReasonString "\157\147)\155)\USKX\185}|\DELt"] -TEST(Subscribe5QCTest, Encode46) { - uint8_t pkt[] = {0x82, 0xd2, 0x1, 0x9, 0x66, 0x60, 0x27, 0x0, 0x0, 0x74, 0x2c, 0x19, 0xb2, 0x2, 0x0, 0x0, 0x44, - 0x4c, 0x24, 0x11, 0x27, 0x0, 0x0, 0x58, 0x60, 0x11, 0x0, 0x0, 0x1b, 0xe2, 0x8, 0x0, 0x8, 0xb4, - 0xf2, 0x9c, 0x7b, 0x83, 0x70, 0xb1, 0xde, 0x1a, 0x0, 0x1d, 0x8b, 0xe3, 0xdd, 0x37, 0xd5, 0xb1, 0x27, - 0x37, 0x38, 0x2f, 0xba, 0xd7, 0x85, 0x1d, 0x9b, 0x5c, 0x4a, 0x79, 0x8f, 0x7, 0xd9, 0xef, 0xb5, 0xf7, - 0x3d, 0x7e, 0x0, 0x2c, 0x6a, 0x11, 0x0, 0x0, 0x59, 0xbc, 0x18, 0x0, 0x0, 0x48, 0x5e, 0x21, 0x2d, - 0xbb, 0x1f, 0x0, 0xd, 0x9d, 0x93, 0x29, 0x9b, 0x29, 0x1f, 0x4b, 0x58, 0xb9, 0x7d, 0x7c, 0x7f, 0x74, - 0x0, 0x1d, 0x9a, 0x77, 0x69, 0xed, 0x95, 0xcf, 0xde, 0xf4, 0xea, 0x66, 0x61, 0x3f, 0xd1, 0x41, 0x7f, - 0xcd, 0xdd, 0x35, 0x10, 0xe0, 0x40, 0xd3, 0xa0, 0xd0, 0xef, 0x30, 0x86, 0xe, 0x0, 0x0, 0x0, 0xb, - 0x4c, 0x7c, 0x49, 0xe7, 0x80, 0xac, 0x65, 0x2, 0x40, 0xc6, 0x78, 0x0, 0x0, 0x14, 0x53, 0x61, 0x20, - 0xa9, 0xb8, 0x52, 0xb7, 0xc7, 0xe1, 0xfb, 0x99, 0x25, 0x76, 0x36, 0xe4, 0x48, 0x22, 0xf4, 0x4a, 0xc1, - 0x0, 0x0, 0x6, 0x3b, 0x22, 0x8, 0x8f, 0xdd, 0xd, 0x0, 0x0, 0x4, 0xd2, 0x93, 0xed, 0x19, 0x2, - 0x0, 0xe, 0x8d, 0xed, 0xe5, 0x9d, 0xad, 0x3, 0x58, 0x2f, 0xe0, 0xae, 0x2c, 0x5c, 0xec, 0xe4, 0x2, - 0x0, 0x6, 0xdb, 0x1, 0xc, 0x29, 0xf1, 0xfc, 0x1}; - - uint8_t buf[223] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x9a, 0x77, 0x69, 0xed, 0x95, 0xcf, 0xde, 0xf4, 0xea, 0x66, - 0x61, 0x3f, 0xd1, 0x41, 0x7f, 0xcd, 0xdd, 0x35, 0x10, 0xe0, - 0x40, 0xd3, 0xa0, 0xd0, 0xef, 0x30, 0x86, 0xe, 0x0}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4c, 0x7c, 0x49, 0xe7, 0x80, 0xac, 0x65, 0x2, 0x40, 0xc6, 0x78}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x53, 0x61, 0x20, 0xa9, 0xb8, 0x52, 0xb7, 0xc7, 0xe1, 0xfb, - 0x99, 0x25, 0x76, 0x36, 0xe4, 0x48, 0x22, 0xf4, 0x4a, 0xc1}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3b, 0x22, 0x8, 0x8f, 0xdd, 0xd}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd2, 0x93, 0xed, 0x19}; - lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8d, 0xed, 0xe5, 0x9d, 0xad, 0x3, 0x58, 0x2f, 0xe0, 0xae, 0x2c, 0x5c, 0xec, 0xe4}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xdb, 0x1, 0xc, 0x29, 0xf1, 0xfc}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xb4, 0xf2, 0x9c, 0x7b, 0x83, 0x70, 0xb1, 0xde}; - uint8_t bytesprops1[] = {0x8b, 0xe3, 0xdd, 0x37, 0xd5, 0xb1, 0x27, 0x37, 0x38, 0x2f, 0xba, 0xd7, 0x85, 0x1d, 0x9b, - 0x5c, 0x4a, 0x79, 0x8f, 0x7, 0xd9, 0xef, 0xb5, 0xf7, 0x3d, 0x7e, 0x0, 0x2c, 0x6a}; - uint8_t bytesprops2[] = {0x9d, 0x93, 0x29, 0x9b, 0x29, 0x1f, 0x4b, 0x58, 0xb9, 0x7d, 0x7c, 0x7f, 0x74}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29740}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17484}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22624}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7138}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22972}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18526}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11707}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops2}}}, - }; - - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2406, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 4955 [("\ENQ\139D6\149b\234\144\205\249k\207\248\b5\137\DC1\211*i\214\212Z\197\232\EM",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\193\&7\178\197`\133\195'\217\NAK\245\130i",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\vU\DEL\193\165\247\239O\244\220",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropCorrelationData "K",PropResponseInformation "\130\207\148~\RS[c",PropTopicAliasMaximum -// 13446,PropRequestResponseInformation 118,PropCorrelationData -// "\254\148Ng\143$\CANm\189x]J\242\175\211\183\SI5\242\227U\214o\NUL\245I\150\173 -// j",PropSubscriptionIdentifierAvailable 163,PropRetainAvailable 40,PropMaximumQoS 150,PropContentType -// "\143\159h<\131*3\130\129\184\DC4\221,\141\254\139\ETX\235\131'x\187\158\EOT\157\219L\186\146\243",PropServerReference -// "\196s\218\CAN\217\SYNq\199\&8",PropAuthenticationData "P\151\251\167<.R\228\ETB\NAK\DLE",PropContentType -// "\156\173\156\174\161\138RF1\184y-3",PropResponseTopic -// "Z\241\196\229\168b\ESC[[0\"\185\192\t\225\&3SY\DEL",PropWildcardSubscriptionAvailable -// 75,PropWildcardSubscriptionAvailable 2,PropSessionExpiryInterval 28657,PropMaximumPacketSize -// 15747,PropSubscriptionIdentifierAvailable 219,PropServerReference -// "\193~UU\191a#\254\&8\196\236\181,i\136\217\202\161\231\144\160",PropSubscriptionIdentifier 6,PropServerKeepAlive -// 25297,PropSharedSubscriptionAvailable 104,PropRetainAvailable 181,PropSessionExpiryInterval 15689,PropCorrelationData -// "\151\144\230\192\241\&4\163tL\164e\179\210\178\232\v\ACK\242\151\173\191(\SYN'\221\181\202h",PropMaximumQoS -// 43,PropRequestResponseInformation 10] -TEST(Subscribe5QCTest, Encode47) { - uint8_t pkt[] = { - 0x82, 0xb2, 0x2, 0x13, 0x5b, 0xf4, 0x1, 0x9, 0x0, 0x1, 0x4b, 0x1a, 0x0, 0x7, 0x82, 0xcf, 0x94, 0x7e, 0x1e, - 0x5b, 0x63, 0x22, 0x34, 0x86, 0x19, 0x76, 0x9, 0x0, 0x1e, 0xfe, 0x94, 0x4e, 0x67, 0x8f, 0x24, 0x18, 0x6d, 0xbd, - 0x78, 0x5d, 0x4a, 0xf2, 0xaf, 0xd3, 0xb7, 0xf, 0x35, 0xf2, 0xe3, 0x55, 0xd6, 0x6f, 0x0, 0xf5, 0x49, 0x96, 0xad, - 0x20, 0x6a, 0x29, 0xa3, 0x25, 0x28, 0x24, 0x96, 0x3, 0x0, 0x1e, 0x8f, 0x9f, 0x68, 0x3c, 0x83, 0x2a, 0x33, 0x82, - 0x81, 0xb8, 0x14, 0xdd, 0x2c, 0x8d, 0xfe, 0x8b, 0x3, 0x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x69, 0xd6, 0xd4, 0x5a, 0xc5, 0xe8, 0x19, 0x0, 0x0, 0xd, 0xc1, 0x37, 0xb2, - 0xc5, 0x60, 0x85, 0xc3, 0x27, 0xd9, 0x15, 0xf5, 0x82, 0x69, 0x1, 0x0, 0xa, 0xb, 0x55, 0x7f, 0xc1, 0xa5, 0xf7, - 0xef, 0x4f, 0xf4, 0xdc, 0x1}; - - uint8_t buf[319] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x5, 0x8b, 0x44, 0x36, 0x95, 0x62, 0xea, 0x90, 0xcd, 0xf9, 0x6b, 0xcf, 0xf8, - 0x8, 0x35, 0x89, 0x11, 0xd3, 0x2a, 0x69, 0xd6, 0xd4, 0x5a, 0xc5, 0xe8, 0x19}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc1, 0x37, 0xb2, 0xc5, 0x60, 0x85, 0xc3, 0x27, 0xd9, 0x15, 0xf5, 0x82, 0x69}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb, 0x55, 0x7f, 0xc1, 0xa5, 0xf7, 0xef, 0x4f, 0xf4, 0xdc}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x4b}; - uint8_t bytesprops1[] = {0x82, 0xcf, 0x94, 0x7e, 0x1e, 0x5b, 0x63}; - uint8_t bytesprops2[] = {0xfe, 0x94, 0x4e, 0x67, 0x8f, 0x24, 0x18, 0x6d, 0xbd, 0x78, 0x5d, 0x4a, 0xf2, 0xaf, 0xd3, - 0xb7, 0xf, 0x35, 0xf2, 0xe3, 0x55, 0xd6, 0x6f, 0x0, 0xf5, 0x49, 0x96, 0xad, 0x20, 0x6a}; - uint8_t bytesprops3[] = {0x8f, 0x9f, 0x68, 0x3c, 0x83, 0x2a, 0x33, 0x82, 0x81, 0xb8, 0x14, 0xdd, 0x2c, 0x8d, 0xfe, - 0x8b, 0x3, 0xeb, 0x83, 0x27, 0x78, 0xbb, 0x9e, 0x4, 0x9d, 0xdb, 0x4c, 0xba, 0x92, 0xf3}; - uint8_t bytesprops4[] = {0xc4, 0x73, 0xda, 0x18, 0xd9, 0x16, 0x71, 0xc7, 0x38}; - uint8_t bytesprops5[] = {0x50, 0x97, 0xfb, 0xa7, 0x3c, 0x2e, 0x52, 0xe4, 0x17, 0x15, 0x10}; - uint8_t bytesprops6[] = {0x9c, 0xad, 0x9c, 0xae, 0xa1, 0x8a, 0x52, 0x46, 0x31, 0xb8, 0x79, 0x2d, 0x33}; - uint8_t bytesprops7[] = {0x5a, 0xf1, 0xc4, 0xe5, 0xa8, 0x62, 0x1b, 0x5b, 0x5b, 0x30, - 0x22, 0xb9, 0xc0, 0x9, 0xe1, 0x33, 0x53, 0x59, 0x7f}; - uint8_t bytesprops8[] = {0xc1, 0x7e, 0x55, 0x55, 0xbf, 0x61, 0x23, 0xfe, 0x38, 0xc4, 0xec, - 0xb5, 0x2c, 0x69, 0x88, 0xd9, 0xca, 0xa1, 0xe7, 0x90, 0xa0}; - uint8_t bytesprops9[] = {0x97, 0x90, 0xe6, 0xc0, 0xf1, 0x34, 0xa3, 0x74, 0x4c, 0xa4, 0x65, 0xb3, 0xd2, 0xb2, - 0xe8, 0xb, 0x6, 0xf2, 0x97, 0xad, 0xbf, 0x28, 0x16, 0x27, 0xdd, 0xb5, 0xca, 0x68}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13446}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28657}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15747}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25297}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15689}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 10}}, - }; - - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4955, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 11203 [("\204\DC2P\234<\186\CANVS(\203F\SO\243\v\199\215\190\165-j\243",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\131\130\210u\174\253S\151\142FR\139\135\186\209\232\170\138\156\&1\NAKf\158E\186\167",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("#\151\&7\NULk\190\232\&6\DEL\DC4H\212\161\&6:\225",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\198\255$N$\183E\246\148\&8\242:\214\128\&2\178\149v/\140",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("O:\185)_;T{\187\198[\166&\148\153\147\203\\YB+Z\169fv\133\rL",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\182\ESC\138\244\250D\150\219B\SI\149\ENQ\172]i\166&\153\190~\228\193>\209",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\143\&6\\:",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropTopicAliasMaximum 5455,PropResponseTopic "\187\253\SUB\196\DC2",PropSubscriptionIdentifierAvailable -// 243,PropRequestProblemInformation 201,PropAuthenticationData -// "\161\182\235/\188\SYN\134\204\193\157\DC4\216",PropRequestProblemInformation 193,PropRetainAvailable -// 208,PropWillDelayInterval 24782,PropMessageExpiryInterval 9486,PropSharedSubscriptionAvailable 185,PropContentType -// "\230\200i\248\225\227\227\207\153\DC3\225<+'\f\154\174\133b\185\189A\205)\197\226l\168",PropMessageExpiryInterval -// 16144,PropSharedSubscriptionAvailable 132,PropWildcardSubscriptionAvailable 11,PropTopicAlias -// 24962,PropCorrelationData "\240='\222\206\181\SOHN\175\&0x",PropSubscriptionIdentifierAvailable 86] -TEST(Subscribe5QCTest, Encode48) { - uint8_t pkt[] = {0x82, 0x8d, 0x2, 0x2b, 0xc3, 0x69, 0x22, 0x15, 0x4f, 0x8, 0x0, 0x5, 0xbb, 0xfd, 0x1a, 0xc4, 0x12, - 0x29, 0xf3, 0x17, 0xc9, 0x16, 0x0, 0xc, 0xa1, 0xb6, 0xeb, 0x2f, 0xbc, 0x16, 0x86, 0xcc, 0xc1, 0x9d, - 0x14, 0xd8, 0x17, 0xc1, 0x25, 0xd0, 0x18, 0x0, 0x0, 0x60, 0xce, 0x2, 0x0, 0x0, 0x25, 0xe, 0x2a, - 0xb9, 0x3, 0x0, 0x1c, 0xe6, 0xc8, 0x69, 0xf8, 0xe1, 0xe3, 0xe3, 0xcf, 0x99, 0x13, 0xe1, 0x3c, 0x2b, - 0x27, 0xc, 0x9a, 0xae, 0x85, 0x62, 0xb9, 0xbd, 0x41, 0xcd, 0x29, 0xc5, 0xe2, 0x6c, 0xa8, 0x2, 0x0, - 0x0, 0x3f, 0x10, 0x2a, 0x84, 0x28, 0xb, 0x23, 0x61, 0x82, 0x9, 0x0, 0xb, 0xf0, 0x3d, 0x27, 0xde, - 0xce, 0xb5, 0x1, 0x4e, 0xaf, 0x30, 0x78, 0x29, 0x56, 0x0, 0x16, 0xcc, 0x12, 0x50, 0xea, 0x3c, 0xba, - 0x18, 0x56, 0x53, 0x28, 0xcb, 0x46, 0xe, 0xf3, 0xb, 0xc7, 0xd7, 0xbe, 0xa5, 0x2d, 0x6a, 0xf3, 0x0, - 0x0, 0x1a, 0x83, 0x82, 0xd2, 0x75, 0xae, 0xfd, 0x53, 0x97, 0x8e, 0x46, 0x52, 0x8b, 0x87, 0xba, 0xd1, - 0xe8, 0xaa, 0x8a, 0x9c, 0x31, 0x15, 0x66, 0x9e, 0x45, 0xba, 0xa7, 0x2, 0x0, 0x10, 0x23, 0x97, 0x37, - 0x0, 0x6b, 0xbe, 0xe8, 0x36, 0x7f, 0x14, 0x48, 0xd4, 0xa1, 0x36, 0x3a, 0xe1, 0x0, 0x0, 0x14, 0xc6, - 0xff, 0x24, 0x4e, 0x24, 0xb7, 0x45, 0xf6, 0x94, 0x38, 0xf2, 0x3a, 0xd6, 0x80, 0x32, 0xb2, 0x95, 0x76, - 0x2f, 0x8c, 0x0, 0x0, 0x1c, 0x4f, 0x3a, 0xb9, 0x29, 0x5f, 0x3b, 0x54, 0x7b, 0xbb, 0xc6, 0x5b, 0xa6, - 0x26, 0x94, 0x99, 0x93, 0xcb, 0x5c, 0x59, 0x42, 0x2b, 0x5a, 0xa9, 0x66, 0x76, 0x85, 0xd, 0x4c, 0x0, - 0x0, 0x18, 0xb6, 0x1b, 0x8a, 0xf4, 0xfa, 0x44, 0x96, 0xdb, 0x42, 0xf, 0x95, 0x5, 0xac, 0x5d, 0x69, - 0xa6, 0x26, 0x99, 0xbe, 0x7e, 0xe4, 0xc1, 0x3e, 0xd1, 0x1, 0x0, 0x4, 0x8f, 0x36, 0x5c, 0x3a, 0x1}; - - uint8_t buf[282] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xcc, 0x12, 0x50, 0xea, 0x3c, 0xba, 0x18, 0x56, 0x53, 0x28, 0xcb, - 0x46, 0xe, 0xf3, 0xb, 0xc7, 0xd7, 0xbe, 0xa5, 0x2d, 0x6a, 0xf3}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x83, 0x82, 0xd2, 0x75, 0xae, 0xfd, 0x53, 0x97, 0x8e, 0x46, 0x52, 0x8b, 0x87, - 0xba, 0xd1, 0xe8, 0xaa, 0x8a, 0x9c, 0x31, 0x15, 0x66, 0x9e, 0x45, 0xba, 0xa7}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x23, 0x97, 0x37, 0x0, 0x6b, 0xbe, 0xe8, 0x36, - 0x7f, 0x14, 0x48, 0xd4, 0xa1, 0x36, 0x3a, 0xe1}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc6, 0xff, 0x24, 0x4e, 0x24, 0xb7, 0x45, 0xf6, 0x94, 0x38, - 0xf2, 0x3a, 0xd6, 0x80, 0x32, 0xb2, 0x95, 0x76, 0x2f, 0x8c}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4f, 0x3a, 0xb9, 0x29, 0x5f, 0x3b, 0x54, 0x7b, 0xbb, 0xc6, - 0x5b, 0xa6, 0x26, 0x94, 0x99, 0x93, 0xcb, 0x5c, 0x59, 0x42, - 0x2b, 0x5a, 0xa9, 0x66, 0x76, 0x85, 0xd, 0x4c}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb6, 0x1b, 0x8a, 0xf4, 0xfa, 0x44, 0x96, 0xdb, 0x42, 0xf, 0x95, 0x5, - 0xac, 0x5d, 0x69, 0xa6, 0x26, 0x99, 0xbe, 0x7e, 0xe4, 0xc1, 0x3e, 0xd1}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8f, 0x36, 0x5c, 0x3a}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xbb, 0xfd, 0x1a, 0xc4, 0x12}; - uint8_t bytesprops1[] = {0xa1, 0xb6, 0xeb, 0x2f, 0xbc, 0x16, 0x86, 0xcc, 0xc1, 0x9d, 0x14, 0xd8}; - uint8_t bytesprops2[] = {0xe6, 0xc8, 0x69, 0xf8, 0xe1, 0xe3, 0xe3, 0xcf, 0x99, 0x13, 0xe1, 0x3c, 0x2b, 0x27, - 0xc, 0x9a, 0xae, 0x85, 0x62, 0xb9, 0xbd, 0x41, 0xcd, 0x29, 0xc5, 0xe2, 0x6c, 0xa8}; - uint8_t bytesprops3[] = {0xf0, 0x3d, 0x27, 0xde, 0xce, 0xb5, 0x1, 0x4e, 0xaf, 0x30, 0x78}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5455}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24782}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9486}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16144}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24962}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 86}}, - }; - - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11203, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 30275 [("\NAK\ENQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [PropServerKeepAlive 25108,PropMessageExpiryInterval 5293,PropResponseInformation -// "\132C\ACK>\207\166\158\244\153 \161\STX\246\192\246\254]H\FS!\219\&5\199\ETX~\135\195",PropTopicAliasMaximum -// 17913,PropAuthenticationData "\131\191\164\132\ETB\154\243`%\240",PropReceiveMaximum 28062,PropTopicAliasMaximum -// 15030] -TEST(Subscribe5QCTest, Encode49) { - uint8_t pkt[] = {0x82, 0x44, 0x76, 0x43, 0x3c, 0x13, 0x62, 0x14, 0x2, 0x0, 0x0, 0x14, 0xad, 0x1a, - 0x0, 0x1b, 0x84, 0x43, 0x6, 0x3e, 0xcf, 0xa6, 0x9e, 0xf4, 0x99, 0x20, 0xa1, 0x2, - 0xf6, 0xc0, 0xf6, 0xfe, 0x5d, 0x48, 0x1c, 0x21, 0xdb, 0x35, 0xc7, 0x3, 0x7e, 0x87, - 0xc3, 0x22, 0x45, 0xf9, 0x16, 0x0, 0xa, 0x83, 0xbf, 0xa4, 0x84, 0x17, 0x9a, 0xf3, - 0x60, 0x25, 0xf0, 0x21, 0x6d, 0x9e, 0x22, 0x3a, 0xb6, 0x0, 0x2, 0x15, 0x5, 0x2}; - - uint8_t buf[80] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x15, 0x5}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x84, 0x43, 0x6, 0x3e, 0xcf, 0xa6, 0x9e, 0xf4, 0x99, 0x20, 0xa1, 0x2, 0xf6, 0xc0, - 0xf6, 0xfe, 0x5d, 0x48, 0x1c, 0x21, 0xdb, 0x35, 0xc7, 0x3, 0x7e, 0x87, 0xc3}; - uint8_t bytesprops1[] = {0x83, 0xbf, 0xa4, 0x84, 0x17, 0x9a, 0xf3, 0x60, 0x25, 0xf0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25108}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5293}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17913}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28062}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15030}}, - }; - - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30275, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 16095 [("\NAK;\166\150$",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("~U\133\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\187m\GS\SOH\205\135\128<\RS\242\204^T\DC1]\f'\v\166\151\218v\STX\FS\131>\NUL",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("n\134\188wS\138\128\229\&1w*\244&",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe5QCTest, Encode50) { - uint8_t pkt[] = {0x82, 0x40, 0x3e, 0xdf, 0x0, 0x0, 0x5, 0x15, 0x3b, 0xa6, 0x96, 0x24, 0x1, 0x0, 0x4, 0x7e, 0x55, - 0x85, 0x19, 0x1, 0x0, 0x1b, 0xbb, 0x6d, 0x1d, 0x1, 0xcd, 0x87, 0x80, 0x3c, 0x1e, 0xf2, 0xcc, 0x5e, - 0x54, 0x11, 0x5d, 0xc, 0x27, 0xb, 0xa6, 0x97, 0xda, 0x76, 0x2, 0x1c, 0x83, 0x3e, 0x0, 0x0, 0x0, - 0xd, 0x6e, 0x86, 0xbc, 0x77, 0x53, 0x8a, 0x80, 0xe5, 0x31, 0x77, 0x2a, 0xf4, 0x26, 0x2}; - - uint8_t buf[76] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x15, 0x3b, 0xa6, 0x96, 0x24}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7e, 0x55, 0x85, 0x19}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xbb, 0x6d, 0x1d, 0x1, 0xcd, 0x87, 0x80, 0x3c, 0x1e, 0xf2, 0xcc, 0x5e, 0x54, 0x11, - 0x5d, 0xc, 0x27, 0xb, 0xa6, 0x97, 0xda, 0x76, 0x2, 0x1c, 0x83, 0x3e, 0x0}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6e, 0x86, 0xbc, 0x77, 0x53, 0x8a, 0x80, 0xe5, 0x31, 0x77, 0x2a, 0xf4, 0x26}; - lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16095, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 27116 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1})] [PropWildcardSubscriptionAvailable 131,PropTopicAliasMaximum 17943,PropResponseTopic -// "\NAK\134\198\&7K\241^\149\187:T\161\191\226l%\145\178\164\178\188\230\227\159\v",PropSharedSubscriptionAvailable -// 187,PropReasonString "\156\"\EMl\255\242]\GSy\223",PropRequestResponseInformation -// 144,PropSubscriptionIdentifierAvailable 48,PropContentType "\142\170\147!\223",PropMaximumPacketSize 32259] -TEST(Subscribe5QCTest, Encode51) { - uint8_t pkt[] = {0x82, 0x47, 0x69, 0xec, 0x41, 0x28, 0x83, 0x22, 0x46, 0x17, 0x8, 0x0, 0x19, 0x15, 0x86, - 0xc6, 0x37, 0x4b, 0xf1, 0x5e, 0x95, 0xbb, 0x3a, 0x54, 0xa1, 0xbf, 0xe2, 0x6c, 0x25, 0x91, - 0xb2, 0xa4, 0xb2, 0xbc, 0xe6, 0xe3, 0x9f, 0xb, 0x2a, 0xbb, 0x1f, 0x0, 0xa, 0x9c, 0x22, - 0x19, 0x6c, 0xff, 0xf2, 0x5d, 0x1d, 0x79, 0xdf, 0x19, 0x90, 0x29, 0x30, 0x3, 0x0, 0x5, - 0x8e, 0xaa, 0x93, 0x21, 0xdf, 0x27, 0x0, 0x0, 0x7e, 0x3, 0x0, 0x0, 0x1}; - - uint8_t buf[83] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x15, 0x86, 0xc6, 0x37, 0x4b, 0xf1, 0x5e, 0x95, 0xbb, 0x3a, 0x54, 0xa1, 0xbf, - 0xe2, 0x6c, 0x25, 0x91, 0xb2, 0xa4, 0xb2, 0xbc, 0xe6, 0xe3, 0x9f, 0xb}; - uint8_t bytesprops1[] = {0x9c, 0x22, 0x19, 0x6c, 0xff, 0xf2, 0x5d, 0x1d, 0x79, 0xdf}; - uint8_t bytesprops2[] = {0x8e, 0xaa, 0x93, 0x21, 0xdf}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17943}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32259}}, - }; - - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27116, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 21718 [("1\174I~\249\CAN\ETB\DC1\225r>\134\n\208\t\160\184\206T\DC3\207L:\206C\137\158",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\207\SI\180J\RSA\SYN\212",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\b\176\222\185\206Sp\170\133",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe5QCTest, Encode52) { - uint8_t pkt[] = {0x82, 0x38, 0x54, 0xd6, 0x0, 0x0, 0x1b, 0x31, 0xae, 0x49, 0x7e, 0xf9, 0x18, 0x17, 0x11, - 0xe1, 0x72, 0x3e, 0x86, 0xa, 0xd0, 0x9, 0xa0, 0xb8, 0xce, 0x54, 0x13, 0xcf, 0x4c, 0x3a, - 0xce, 0x43, 0x89, 0x9e, 0x2, 0x0, 0x8, 0xcf, 0xf, 0xb4, 0x4a, 0x1e, 0x41, 0x16, 0xd4, - 0x1, 0x0, 0x9, 0x8, 0xb0, 0xde, 0xb9, 0xce, 0x53, 0x70, 0xaa, 0x85, 0x0}; - - uint8_t buf[68] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x31, 0xae, 0x49, 0x7e, 0xf9, 0x18, 0x17, 0x11, 0xe1, 0x72, 0x3e, 0x86, 0xa, 0xd0, - 0x9, 0xa0, 0xb8, 0xce, 0x54, 0x13, 0xcf, 0x4c, 0x3a, 0xce, 0x43, 0x89, 0x9e}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcf, 0xf, 0xb4, 0x4a, 0x1e, 0x41, 0x16, 0xd4}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8, 0xb0, 0xde, 0xb9, 0xce, 0x53, 0x70, 0xaa, 0x85}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21718, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 32713 [("2\214\247\243(1\182\&4\130\248PZ\198\183\251=\\\128w\163\165~o\202",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("Z\195\171v\219\&5=\227\f\227X1\\\178\172\251\165\154\161\194",PropWillDelayInterval -// 11579,PropMessageExpiryInterval 12043,PropSessionExpiryInterval 14813,PropTopicAliasMaximum 32111,PropMaximumQoS -// 129,PropCorrelationData "\198\187(",PropRequestResponseInformation 47,PropRetainAvailable 92,PropMaximumPacketSize -// 1709,PropContentType "\230\SUB\157\r\174'Z|Z\250pC\148\168\138\163\225\193Q\164\250J",PropMessageExpiryInterval -// 5711,PropRequestProblemInformation 109,PropPayloadFormatIndicator 229,PropAuthenticationMethod -// "\131\161\181M\203!\164\145-\161,\ACKq",PropServerReference -// "B\231W\171\175\ETB\138\140\230",PropMessageExpiryInterval 5530,PropRetainAvailable 242] -TEST(Subscribe5QCTest, Encode54) { - uint8_t pkt[] = { - 0x82, 0xa5, 0x2,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, - 0x3, 0x64, 0x1, 0x0, 0x16, 0x3d, 0x88, 0x4, 0x5a, 0x6d, 0x14, 0x85, 0x96, 0xf7, 0x56, 0xb7, 0xaf, 0xd5, 0xa8, - 0x4d, 0x50, 0x45, 0xcf, 0x61, 0xbd, 0xab, 0xe9, 0x0, 0x0, 0x1d, 0x55, 0x4c, 0x7, 0xa1, 0xa8, 0x55, 0x30, 0x17, - 0x9b, 0x1b, 0x6e, 0x2f, 0xc3, 0xc7, 0xef, 0x3a, 0xaa, 0xb9, 0x3f, 0xcd, 0x9d, 0xf6, 0xa1, 0x78, 0xda, 0xf2, 0x28, - 0x8c, 0xbb, 0x0, 0x0, 0xa, 0xfb, 0x89, 0x2c, 0x8e, 0xf1, 0xbe, 0xf8, 0xce, 0xd1, 0xf2, 0x1, 0x0, 0x7, 0xbb, - 0x85, 0xcc, 0xfc, 0x13, 0xaa, 0x80, 0x0, 0x0, 0x14, 0x6b, 0x9, 0x11, 0x49, 0x28, 0x1b, 0xc1, 0x5a, 0x6f, 0xae, - 0x11, 0x44, 0x99, 0xd5, 0xa6, 0xa, 0x8d, 0x9e, 0x5, 0xc8, 0x0}; - - uint8_t buf[306] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x61, 0x80, 0x30, 0x1c, 0xa2, 0x34, 0x87, 0x61, 0x86, - 0x2d, 0x2e, 0xf3, 0x3d, 0x5a, 0x83, 0xff, 0x66, 0x5e}; - lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x57, 0x6a, 0x6e, 0xed, 0xf8}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8c, 0xb7, 0x9a, 0x8, 0xac, 0x6e, 0x8, 0x29, 0x3, 0x64}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3d, 0x88, 0x4, 0x5a, 0x6d, 0x14, 0x85, 0x96, 0xf7, 0x56, 0xb7, - 0xaf, 0xd5, 0xa8, 0x4d, 0x50, 0x45, 0xcf, 0x61, 0xbd, 0xab, 0xe9}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x55, 0x4c, 0x7, 0xa1, 0xa8, 0x55, 0x30, 0x17, 0x9b, 0x1b, - 0x6e, 0x2f, 0xc3, 0xc7, 0xef, 0x3a, 0xaa, 0xb9, 0x3f, 0xcd, - 0x9d, 0xf6, 0xa1, 0x78, 0xda, 0xf2, 0x28, 0x8c, 0xbb}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfb, 0x89, 0x2c, 0x8e, 0xf1, 0xbe, 0xf8, 0xce, 0xd1, 0xf2}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbb, 0x85, 0xcc, 0xfc, 0x13, 0xaa, 0x80}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6b, 0x9, 0x11, 0x49, 0x28, 0x1b, 0xc1, 0x5a, 0x6f, 0xae, - 0x11, 0x44, 0x99, 0xd5, 0xa6, 0xa, 0x8d, 0x9e, 0x5, 0xc8}; - lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0xa, 0xf3}; - uint8_t bytesprops1[] = {0x9a, 0xf1, 0x86, 0x60, 0x9e, 0x3, 0x5e, 0xe5, 0x3, 0x27, 0x53, 0x36, 0x3e, 0xdb, 0x35, - 0x3d, 0xe3, 0xc, 0xe3, 0x58, 0x31, 0x5c, 0xb2, 0xac, 0xfb, 0xa5, 0x9a, 0xa1, 0xc2}; - uint8_t bytesprops2[] = {0xc6, 0xbb, 0x28}; - uint8_t bytesprops3[] = {0xe6, 0x1a, 0x9d, 0xd, 0xae, 0x27, 0x5a, 0x7c, 0x5a, 0xfa, 0x70, - 0x43, 0x94, 0xa8, 0x8a, 0xa3, 0xe1, 0xc1, 0x51, 0xa4, 0xfa, 0x4a}; - uint8_t bytesprops4[] = {0x83, 0xa1, 0xb5, 0x4d, 0xcb, 0x21, 0xa4, 0x91, 0x2d, 0xa1, 0x2c, 0x6, 0x71}; - uint8_t bytesprops5[] = {0x42, 0xe7, 0x57, 0xab, 0xaf, 0x17, 0x8a, 0x8c, 0xe6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11579}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12043}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14813}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32111}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1709}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5711}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5530}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, - }; - - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29246, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2039 [("\134\204K\176hu :\174\236V\DC1u\178\203",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\US\NULy38e\DC4\186\218\247&\r\202\247\214\221\158\tO:\146?c\221\188\174\202\241\206",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropServerReference "KXv\\y\228\248\185\228\&3\166\245\t\249=\STX)\173\182",PropRequestProblemInformation -// 175,PropRequestResponseInformation 131,PropCorrelationData -// "Yx\141(\159D6\176!.\181b\225.\145\r\206\ETB\163\234\243\175\180f\191\214\128",PropServerKeepAlive -// 27540,PropReceiveMaximum 20437,PropResponseInformation "\193\209\DC4:B\FSx\163\140\198\v",PropUserProperty -// "\a|\174\EOT3\136" "\147\134\143\DC3,",PropWillDelayInterval 22556,PropSessionExpiryInterval -// 11928,PropAuthenticationMethod "-\187\143\206\141Y\194\249\DC2\138\249\219k\158"] -TEST(Subscribe5QCTest, Encode55) { - uint8_t pkt[] = {0x82, 0xac, 0x1, 0x7, 0xf7, 0x77, 0x1c, 0x0, 0x13, 0x4b, 0x58, 0x76, 0x5c, 0x79, 0xe4, 0xf8, - 0xb9, 0xe4, 0x33, 0xa6, 0xf5, 0x9, 0xf9, 0x3d, 0x2, 0x29, 0xad, 0xb6, 0x17, 0xaf, 0x19, 0x83, - 0x9, 0x0, 0x1b, 0x59, 0x78, 0x8d, 0x28, 0x9f, 0x44, 0x36, 0xb0, 0x21, 0x2e, 0xb5, 0x62, 0xe1, - 0x2e, 0x91, 0xd, 0xce, 0x17, 0xa3, 0xea, 0xf3, 0xaf, 0xb4, 0x66, 0xbf, 0xd6, 0x80, 0x13, 0x6b, - 0x94, 0x21, 0x4f, 0xd5, 0x1a, 0x0, 0xb, 0xc1, 0xd1, 0x14, 0x3a, 0x42, 0x1c, 0x78, 0xa3, 0x8c, - 0xc6, 0xb, 0x26, 0x0, 0x6, 0x7, 0x7c, 0xae, 0x4, 0x33, 0x88, 0x0, 0x5, 0x93, 0x86, 0x8f, - 0x13, 0x2c, 0x18, 0x0, 0x0, 0x58, 0x1c, 0x11, 0x0, 0x0, 0x2e, 0x98, 0x15, 0x0, 0xe, 0x2d, - 0xbb, 0x8f, 0xce, 0x8d, 0x59, 0xc2, 0xf9, 0x12, 0x8a, 0xf9, 0xdb, 0x6b, 0x9e, 0x0, 0xf, 0x86, - 0xcc, 0x4b, 0xb0, 0x68, 0x75, 0x20, 0x3a, 0xae, 0xec, 0x56, 0x11, 0x75, 0xb2, 0xcb, 0x1, 0x0, - 0x1d, 0x1f, 0x0, 0x79, 0x33, 0x38, 0x65, 0x14, 0xba, 0xda, 0xf7, 0x26, 0xd, 0xca, 0xf7, 0xd6, - 0xdd, 0x9e, 0x9, 0x4f, 0x3a, 0x92, 0x3f, 0x63, 0xdd, 0xbc, 0xae, 0xca, 0xf1, 0xce, 0x2}; - - uint8_t buf[185] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x86, 0xcc, 0x4b, 0xb0, 0x68, 0x75, 0x20, 0x3a, - 0xae, 0xec, 0x56, 0x11, 0x75, 0xb2, 0xcb}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1f, 0x0, 0x79, 0x33, 0x38, 0x65, 0x14, 0xba, 0xda, 0xf7, - 0x26, 0xd, 0xca, 0xf7, 0xd6, 0xdd, 0x9e, 0x9, 0x4f, 0x3a, - 0x92, 0x3f, 0x63, 0xdd, 0xbc, 0xae, 0xca, 0xf1, 0xce}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x4b, 0x58, 0x76, 0x5c, 0x79, 0xe4, 0xf8, 0xb9, 0xe4, 0x33, - 0xa6, 0xf5, 0x9, 0xf9, 0x3d, 0x2, 0x29, 0xad, 0xb6}; - uint8_t bytesprops1[] = {0x59, 0x78, 0x8d, 0x28, 0x9f, 0x44, 0x36, 0xb0, 0x21, 0x2e, 0xb5, 0x62, 0xe1, 0x2e, - 0x91, 0xd, 0xce, 0x17, 0xa3, 0xea, 0xf3, 0xaf, 0xb4, 0x66, 0xbf, 0xd6, 0x80}; - uint8_t bytesprops2[] = {0xc1, 0xd1, 0x14, 0x3a, 0x42, 0x1c, 0x78, 0xa3, 0x8c, 0xc6, 0xb}; - uint8_t bytesprops4[] = {0x93, 0x86, 0x8f, 0x13, 0x2c}; - uint8_t bytesprops3[] = {0x7, 0x7c, 0xae, 0x4, 0x33, 0x88}; - uint8_t bytesprops5[] = {0x2d, 0xbb, 0x8f, 0xce, 0x8d, 0x59, 0xc2, 0xf9, 0x12, 0x8a, 0xf9, 0xdb, 0x6b, 0x9e}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27540}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20437}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22556}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11928}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2039, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 29065 -// [("^Q\224\196\169V\128\198eL\204\194\202.?\DEL\NAK\206Z\162;V\t\163\214\DLE\156\232",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\216\186a\141",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\173\DC4j\205\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2})] [PropMessageExpiryInterval 19729,PropSubscriptionIdentifier 11,PropContentType -// "{\213\222x#\147\160\190}\SYN\145\164\n[",PropResponseTopic "w\150\179\171\228\153E\f\216",PropContentType -// ";\208a\239\144y)tB'\DC2",PropMessageExpiryInterval 29087,PropServerReference "\181Fb -// \185\229\NUL\RS\158\150\n2\130",PropWillDelayInterval 4042,PropServerReference "w",PropContentType -// "\160\164\191\240\237Y\147\&9\182\193\ACK{B<\172\238\238u\161N\164V7\NAK%\241\214\192\200",PropReceiveMaximum -// 22724,PropResponseTopic "\EM\236\NUL<\146z\205\131\168%\186\&2",PropAssignedClientIdentifier -// "F\246\DC2\133\171\151\RS\129'2\254\162M\206\232\181`\f\209\148M",PropMaximumQoS 157,PropReceiveMaximum -// 26184,PropResponseTopic -// "\t_\236\130j\182\199\DC3Cl-\201\218\165a*\ENQ@\234\241\241\187\f\243\215\184\238\163",PropCorrelationData -// "\232\234:\223\164\218X\213\246y\SUB\143\244\175\209\&0l\176\211",PropAuthenticationData "\226\195\ACK\218 -// A\136M\193)O3\255q~e'\154\242\190\136\147\176d\DC4d\231",PropSessionExpiryInterval 21583,PropAuthenticationMethod -// "\144\204\169x!^\213",PropServerKeepAlive 20138,PropMaximumQoS 108,PropContentType "\148\193\210F\163@\129\242"] -TEST(Subscribe5QCTest, Encode56) { - uint8_t pkt[] = { - 0x82, 0xc3, 0x2, 0x71, 0x89, 0x91, 0x2, 0x2, 0x0, 0x0, 0x4d, 0x11, 0xb, 0xb, 0x3, 0x0, 0xe, 0x7b, 0xd5, - 0xde, 0x78, 0x23, 0x93, 0xa0, 0xbe, 0x7d, 0x16, 0x91, 0xa4, 0xa, 0x5b, 0x8, 0x0, 0x9, 0x77, 0x96, 0xb3, 0xab, - 0xe4, 0x99, 0x45, 0xc, 0xd8, 0x3, 0x0, 0xb, 0x3b, 0xd0, 0x61, 0xef, 0x90, 0x79, 0x29, 0x74, 0x42, 0x27, 0x12, - 0x2, 0x0, 0x0, 0x71, 0x9f, 0x1c, 0x0, 0xd, 0xb5, 0x46, 0x62, 0x20, 0xb9, 0xe5, 0x0, 0x1e, 0x9e, 0x96, 0x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e, 0xd5, 0x13, 0x4e, - 0xaa, 0x24, 0x6c, 0x3, 0x0, 0x8, 0x94, 0xc1, 0xd2, 0x46, 0xa3, 0x40, 0x81, 0xf2, 0x0, 0x1c, 0x5e, 0x51, 0xe0, - 0xc4, 0xa9, 0x56, 0x80, 0xc6, 0x65, 0x4c, 0xcc, 0xc2, 0xca, 0x2e, 0x3f, 0x7f, 0x15, 0xce, 0x5a, 0xa2, 0x3b, 0x56, - 0x9, 0xa3, 0xd6, 0x10, 0x9c, 0xe8, 0x1, 0x0, 0x4, 0xd8, 0xba, 0x61, 0x8d, 0x1, 0x0, 0x5, 0xad, 0x14, 0x6a, - 0xcd, 0xeb, 0x2}; - - uint8_t buf[336] = {0}; - - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x5e, 0x51, 0xe0, 0xc4, 0xa9, 0x56, 0x80, 0xc6, 0x65, 0x4c, - 0xcc, 0xc2, 0xca, 0x2e, 0x3f, 0x7f, 0x15, 0xce, 0x5a, 0xa2, - 0x3b, 0x56, 0x9, 0xa3, 0xd6, 0x10, 0x9c, 0xe8}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd8, 0xba, 0x61, 0x8d}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xad, 0x14, 0x6a, 0xcd, 0xeb}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x7b, 0xd5, 0xde, 0x78, 0x23, 0x93, 0xa0, 0xbe, 0x7d, 0x16, 0x91, 0xa4, 0xa, 0x5b}; - uint8_t bytesprops1[] = {0x77, 0x96, 0xb3, 0xab, 0xe4, 0x99, 0x45, 0xc, 0xd8}; - uint8_t bytesprops2[] = {0x3b, 0xd0, 0x61, 0xef, 0x90, 0x79, 0x29, 0x74, 0x42, 0x27, 0x12}; - uint8_t bytesprops3[] = {0xb5, 0x46, 0x62, 0x20, 0xb9, 0xe5, 0x0, 0x1e, 0x9e, 0x96, 0xa, 0x32, 0x82}; - uint8_t bytesprops4[] = {0x77}; - uint8_t bytesprops5[] = {0xa0, 0xa4, 0xbf, 0xf0, 0xed, 0x59, 0x93, 0x39, 0xb6, 0xc1, 0x6, 0x7b, 0x42, 0x3c, 0xac, - 0xee, 0xee, 0x75, 0xa1, 0x4e, 0xa4, 0x56, 0x37, 0x15, 0x25, 0xf1, 0xd6, 0xc0, 0xc8}; - uint8_t bytesprops6[] = {0x19, 0xec, 0x0, 0x3c, 0x92, 0x7a, 0xcd, 0x83, 0xa8, 0x25, 0xba, 0x32}; - uint8_t bytesprops7[] = {0x46, 0xf6, 0x12, 0x85, 0xab, 0x97, 0x1e, 0x81, 0x27, 0x32, 0xfe, - 0xa2, 0x4d, 0xce, 0xe8, 0xb5, 0x60, 0xc, 0xd1, 0x94, 0x4d}; - uint8_t bytesprops8[] = {0x9, 0x5f, 0xec, 0x82, 0x6a, 0xb6, 0xc7, 0x13, 0x43, 0x6c, 0x2d, 0xc9, 0xda, 0xa5, - 0x61, 0x2a, 0x5, 0x40, 0xea, 0xf1, 0xf1, 0xbb, 0xc, 0xf3, 0xd7, 0xb8, 0xee, 0xa3}; - uint8_t bytesprops9[] = {0xe8, 0xea, 0x3a, 0xdf, 0xa4, 0xda, 0x58, 0xd5, 0xf6, 0x79, - 0x1a, 0x8f, 0xf4, 0xaf, 0xd1, 0x30, 0x6c, 0xb0, 0xd3}; - uint8_t bytesprops10[] = {0xe2, 0xc3, 0x6, 0xda, 0x20, 0x41, 0x88, 0x4d, 0xc1, 0x29, 0x4f, 0x33, 0xff, 0x71, - 0x7e, 0x65, 0x27, 0x9a, 0xf2, 0xbe, 0x88, 0x93, 0xb0, 0x64, 0x14, 0x64, 0xe7}; - uint8_t bytesprops11[] = {0x90, 0xcc, 0xa9, 0x78, 0x21, 0x5e, 0xd5}; - uint8_t bytesprops12[] = {0x94, 0xc1, 0xd2, 0x46, 0xa3, 0x40, 0x81, 0xf2}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19729}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29087}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4042}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22724}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26184}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21583}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20138}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops12}}}, - }; - - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29065, 3, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 6655 [("x\149\146\242D\207\254D\208\218\227h\141>hT\212\152\tmFk\v\159",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("v[g\156",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropMessageExpiryInterval 19764,PropAssignedClientIdentifier -// "\ACK\139Q\243#\155\166*\151\227\159\189\237w\185\EM",PropResponseTopic -// "\212F_\151B\237\207\186G07\r\153",PropWildcardSubscriptionAvailable 108,PropContentType -// "\192\225\STX\218\161\143\v\DC4:d;%\194\153\216\&7\ETB\235j\136",PropMaximumQoS 69,PropMessageExpiryInterval -// 4203,PropResponseInformation "",PropSubscriptionIdentifierAvailable 158,PropRequestProblemInformation -// 80,PropWildcardSubscriptionAvailable 181] -TEST(Subscribe5QCTest, Encode57) { - uint8_t pkt[] = {0x82, 0x76, 0x19, 0xff, 0x51, 0x2, 0x0, 0x0, 0x4d, 0x34, 0x12, 0x0, 0x10, 0x6, 0x8b, - 0x51, 0xf3, 0x23, 0x9b, 0xa6, 0x2a, 0x97, 0xe3, 0x9f, 0xbd, 0xed, 0x77, 0xb9, 0x19, 0x8, - 0x0, 0xd, 0xd4, 0x46, 0x5f, 0x97, 0x42, 0xed, 0xcf, 0xba, 0x47, 0x30, 0x37, 0xd, 0x99, - 0x28, 0x6c, 0x3, 0x0, 0x14, 0xc0, 0xe1, 0x2, 0xda, 0xa1, 0x8f, 0xb, 0x14, 0x3a, 0x64, - 0x3b, 0x25, 0xc2, 0x99, 0xd8, 0x37, 0x17, 0xeb, 0x6a, 0x88, 0x24, 0x45, 0x2, 0x0, 0x0, - 0x10, 0x6b, 0x1a, 0x0, 0x0, 0x29, 0x9e, 0x17, 0x50, 0x28, 0xb5, 0x0, 0x18, 0x78, 0x95, - 0x92, 0xf2, 0x44, 0xcf, 0xfe, 0x44, 0xd0, 0xda, 0xe3, 0x68, 0x8d, 0x3e, 0x68, 0x54, 0xd4, - 0x98, 0x9, 0x6d, 0x46, 0x6b, 0xb, 0x9f, 0x2, 0x0, 0x4, 0x76, 0x5b, 0x67, 0x9c, 0x0}; - - uint8_t buf[130] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x78, 0x95, 0x92, 0xf2, 0x44, 0xcf, 0xfe, 0x44, 0xd0, 0xda, 0xe3, 0x68, - 0x8d, 0x3e, 0x68, 0x54, 0xd4, 0x98, 0x9, 0x6d, 0x46, 0x6b, 0xb, 0x9f}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x76, 0x5b, 0x67, 0x9c}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x6, 0x8b, 0x51, 0xf3, 0x23, 0x9b, 0xa6, 0x2a, - 0x97, 0xe3, 0x9f, 0xbd, 0xed, 0x77, 0xb9, 0x19}; - uint8_t bytesprops1[] = {0xd4, 0x46, 0x5f, 0x97, 0x42, 0xed, 0xcf, 0xba, 0x47, 0x30, 0x37, 0xd, 0x99}; - uint8_t bytesprops2[] = {0xc0, 0xe1, 0x2, 0xda, 0xa1, 0x8f, 0xb, 0x14, 0x3a, 0x64, - 0x3b, 0x25, 0xc2, 0x99, 0xd8, 0x37, 0x17, 0xeb, 0x6a, 0x88}; - uint8_t bytesprops3[] = {0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19764}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4203}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 181}}, - }; - - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6655, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 2977 [("\137K3uf\128\132\202\FS\FS\224`z\196\144d\197\197\158\200y\233\ACK\184\220",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\171c\189\177zn\130)$\236\168",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\204\230!\136BX\135:J\204\170O\186\244\SO\140L2\187\"\132",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\185TD=\248\202\150\235L\245\DC4\184\200\145\EM\255\170\192\203\233\178\205\230\"w",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\138\215!n9\139\196\249\192\194\244\135Z'\136\194",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("S\170L\DC2\175\154u\143\228\222\"p8\148\148\170\224\213\161\189\147",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropSubscriptionIdentifier -// 29,PropResponseTopic "\171\193\SI\168\&5\FS\254\250",PropResponseInformation -// "\146\161\176w\ENQ\DC1\206\167\237\DLE\ACK\231@k\233\208g\154&:\132\217\148\240B",PropRetainAvailable -// 111,PropTopicAliasMaximum 4497,PropServerReference "f\234%l\243\128PT4\198",PropWildcardSubscriptionAvailable 55] -TEST(Subscribe5QCTest, Encode58) { - uint8_t pkt[] = {0x82, 0xc9, 0x1, 0xb, 0xa1, 0x3d, 0xb, 0x1d, 0x8, 0x0, 0x8, 0xab, 0xc1, 0xf, 0xa8, 0x35, 0x1c, - 0xfe, 0xfa, 0x1a, 0x0, 0x19, 0x92, 0xa1, 0xb0, 0x77, 0x5, 0x11, 0xce, 0xa7, 0xed, 0x10, 0x6, 0xe7, - 0x40, 0x6b, 0xe9, 0xd0, 0x67, 0x9a, 0x26, 0x3a, 0x84, 0xd9, 0x94, 0xf0, 0x42, 0x25, 0x6f, 0x22, 0x11, - 0x91, 0x1c, 0x0, 0xa, 0x66, 0xea, 0x25, 0x6c, 0xf3, 0x80, 0x50, 0x54, 0x34, 0xc6, 0x28, 0x37, 0x0, - 0x19, 0x89, 0x4b, 0x33, 0x75, 0x66, 0x80, 0x84, 0xca, 0x1c, 0x1c, 0xe0, 0x60, 0x7a, 0xc4, 0x90, 0x64, - 0xc5, 0xc5, 0x9e, 0xc8, 0x79, 0xe9, 0x6, 0xb8, 0xdc, 0x2, 0x0, 0xb, 0xab, 0x63, 0xbd, 0xb1, 0x7a, - 0x6e, 0x82, 0x29, 0x24, 0xec, 0xa8, 0x1, 0x0, 0x15, 0xcc, 0xe6, 0x21, 0x88, 0x42, 0x58, 0x87, 0x3a, - 0x4a, 0xcc, 0xaa, 0x4f, 0xba, 0xf4, 0xe, 0x8c, 0x4c, 0x32, 0xbb, 0x22, 0x84, 0x1, 0x0, 0x19, 0xb9, - 0x54, 0x44, 0x3d, 0xf8, 0xca, 0x96, 0xeb, 0x4c, 0xf5, 0x14, 0xb8, 0xc8, 0x91, 0x19, 0xff, 0xaa, 0xc0, - 0xcb, 0xe9, 0xb2, 0xcd, 0xe6, 0x22, 0x77, 0x1, 0x0, 0x10, 0x8a, 0xd7, 0x21, 0x6e, 0x39, 0x8b, 0xc4, - 0xf9, 0xc0, 0xc2, 0xf4, 0x87, 0x5a, 0x27, 0x88, 0xc2, 0x0, 0x0, 0x15, 0x53, 0xaa, 0x4c, 0x12, 0xaf, - 0x9a, 0x75, 0x8f, 0xe4, 0xde, 0x22, 0x70, 0x38, 0x94, 0x94, 0xaa, 0xe0, 0xd5, 0xa1, 0xbd, 0x93, 0x0}; - - uint8_t buf[214] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x89, 0x4b, 0x33, 0x75, 0x66, 0x80, 0x84, 0xca, 0x1c, 0x1c, 0xe0, 0x60, 0x7a, - 0xc4, 0x90, 0x64, 0xc5, 0xc5, 0x9e, 0xc8, 0x79, 0xe9, 0x6, 0xb8, 0xdc}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xab, 0x63, 0xbd, 0xb1, 0x7a, 0x6e, 0x82, 0x29, 0x24, 0xec, 0xa8}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xcc, 0xe6, 0x21, 0x88, 0x42, 0x58, 0x87, 0x3a, 0x4a, 0xcc, 0xaa, - 0x4f, 0xba, 0xf4, 0xe, 0x8c, 0x4c, 0x32, 0xbb, 0x22, 0x84}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb9, 0x54, 0x44, 0x3d, 0xf8, 0xca, 0x96, 0xeb, 0x4c, 0xf5, 0x14, 0xb8, 0xc8, - 0x91, 0x19, 0xff, 0xaa, 0xc0, 0xcb, 0xe9, 0xb2, 0xcd, 0xe6, 0x22, 0x77}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8a, 0xd7, 0x21, 0x6e, 0x39, 0x8b, 0xc4, 0xf9, - 0xc0, 0xc2, 0xf4, 0x87, 0x5a, 0x27, 0x88, 0xc2}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x53, 0xaa, 0x4c, 0x12, 0xaf, 0x9a, 0x75, 0x8f, 0xe4, 0xde, 0x22, - 0x70, 0x38, 0x94, 0x94, 0xaa, 0xe0, 0xd5, 0xa1, 0xbd, 0x93}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0xab, 0xc1, 0xf, 0xa8, 0x35, 0x1c, 0xfe, 0xfa}; - uint8_t bytesprops1[] = {0x92, 0xa1, 0xb0, 0x77, 0x5, 0x11, 0xce, 0xa7, 0xed, 0x10, 0x6, 0xe7, 0x40, - 0x6b, 0xe9, 0xd0, 0x67, 0x9a, 0x26, 0x3a, 0x84, 0xd9, 0x94, 0xf0, 0x42}; - uint8_t bytesprops2[] = {0x66, 0xea, 0x25, 0x6c, 0xf3, 0x80, 0x50, 0x54, 0x34, 0xc6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4497}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 55}}, - }; - - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2977, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14796 [("dL\223\173OD1\b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\194\241\150\GS\SYN\239\&9\227\136c\138\225ItdFP",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropSubscriptionIdentifier -// 0,PropWillDelayInterval 9891,PropTopicAliasMaximum 19892,PropMessageExpiryInterval 10256,PropServerReference -// "\236gE\STX\NUL\193\149\249\&7lh\154~\198",PropServerKeepAlive 4439,PropTopicAlias -// 19774,PropRequestResponseInformation 33,PropMessageExpiryInterval 1725] -TEST(Subscribe5QCTest, Encode59) { - uint8_t pkt[] = {0x82, 0x4f, 0x39, 0xcc, 0x2d, 0xb, 0x0, 0x18, 0x0, 0x0, 0x26, 0xa3, 0x22, 0x4d, 0xb4, 0x2, 0x0, - 0x0, 0x28, 0x10, 0x1c, 0x0, 0xe, 0xec, 0x67, 0x45, 0x2, 0x0, 0xc1, 0x95, 0xf9, 0x37, 0x6c, 0x68, - 0x9a, 0x7e, 0xc6, 0x13, 0x11, 0x57, 0x23, 0x4d, 0x3e, 0x19, 0x21, 0x2, 0x0, 0x0, 0x6, 0xbd, 0x0, - 0x8, 0x64, 0x4c, 0xdf, 0xad, 0x4f, 0x44, 0x31, 0x8, 0x1, 0x0, 0x11, 0xc2, 0xf1, 0x96, 0x1d, 0x16, - 0xef, 0x39, 0xe3, 0x88, 0x63, 0x8a, 0xe1, 0x49, 0x74, 0x64, 0x46, 0x50, 0x1}; - - uint8_t buf[91] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x64, 0x4c, 0xdf, 0xad, 0x4f, 0x44, 0x31, 0x8}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc2, 0xf1, 0x96, 0x1d, 0x16, 0xef, 0x39, 0xe3, 0x88, - 0x63, 0x8a, 0xe1, 0x49, 0x74, 0x64, 0x46, 0x50}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xec, 0x67, 0x45, 0x2, 0x0, 0xc1, 0x95, 0xf9, 0x37, 0x6c, 0x68, 0x9a, 0x7e, 0xc6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9891}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19892}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10256}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4439}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19774}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1725}}, - }; - - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14796, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12164 [("\215\191",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\183\&1\149d|\172\187\170\n\253\&0\247d\147\189",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\"-\141\168\ESCz\249\US;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\248\206\134zY'gO\232M\144X\242\ESC\196\210\242Ka",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\155\&9\136\225\249<@6\DC2C8VS\170\237\208=1\161t\156e\198R'\149\183",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\138h\162\"\239\145\&1Q\212\182\ETB\132\178T\203\211\181\250\190\ETX\US\154\132c\168\205\218\139\176\171",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\165\160\138\189\b1fH\233\ACK_\\\a\250\137\DEL\130\251\NUL\US\166\145[\162J",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\193\ETX\186T\206c}8/>H\163\255\173\&4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("<\STX\246d\230",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("e\229|n.\CAN\FS\177\249\229Y\"Fe\193\209\"\225+\217x\190ub\253|",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\170R!*\191)5\154\202|,\DEL};bb\224\&1\233\194M\DC4`&\NUL\131",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropServerReference -// "\141\160\211*\222\198\STX\229\139\DC4\160B`\DC18\246/\192C\212\195\149]i\221\149D\242I\142",PropReasonString -// "?\255z\246\231\"\163\DLE\218i%O\209\246\224\217U\EOT\235\151\159\222",PropServerKeepAlive 9806,PropServerReference -// ".\230\&2(m\254\178u=R\151\227g\188KW_\182\216\222]\"P\fz",PropRetainAvailable 41,PropRequestProblemInformation -// 13,PropRetainAvailable 59,PropResponseInformation -// "k\216\247\&2|,\152Z\206\152\188\129-(\208\DLE\EM\164\f\146\202\234",PropServerReference -// "2\217\RS\141\&6U\190b",PropMaximumQoS 153,PropMaximumPacketSize 20414,PropAuthenticationData -// "\201\226\193\CANS\"\CAN\FS",PropAuthenticationData ")Ag\208\v\n\241\229\176\171u\217"] -TEST(Subscribe5QCTest, Encode60) { - uint8_t pkt[] = { - 0x82, 0x90, 0x3, 0x2f, 0x84, 0xa4, 0x1, 0x1c, 0x0, 0x1e, 0x8d, 0xa0, 0xd3, 0x2a, 0xde, 0xc6, 0x2, 0xe5, 0x8b, - 0x14, 0xa0, 0x42, 0x60, 0x11, 0x38, 0xf6, 0x2f, 0xc0, 0x43, 0xd4, 0xc3, 0x95, 0x5d, 0x69, 0xdd, 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- lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xd7, 0xbf}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb7, 0x31, 0x95, 0x64, 0x7c, 0xac, 0xbb, 0xaa, - 0xa, 0xfd, 0x30, 0xf7, 0x64, 0x93, 0xbd}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x22, 0x2d, 0x8d, 0xa8, 0x1b, 0x7a, 0xf9, 0x1f, 0x3b}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf8, 0xce, 0x86, 0x7a, 0x59, 0x27, 0x67, 0x4f, 0xe8, 0x4d, - 0x90, 0x58, 0xf2, 0x1b, 0xc4, 0xd2, 0xf2, 0x4b, 0x61}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9b, 0x39, 0x88, 0xe1, 0xf9, 0x3c, 0x40, 0x36, 0x12, 0x43, 0x38, 0x56, 0x53, 0xaa, - 0xed, 0xd0, 0x3d, 0x31, 0xa1, 0x74, 0x9c, 0x65, 0xc6, 0x52, 0x27, 0x95, 0xb7}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8a, 0x68, 0xa2, 0x22, 0xef, 0x91, 0x31, 0x51, 0xd4, 0xb6, - 0x17, 0x84, 0xb2, 0x54, 0xcb, 0xd3, 0xb5, 0xfa, 0xbe, 0x3, - 0x1f, 0x9a, 0x84, 0x63, 0xa8, 0xcd, 0xda, 0x8b, 0xb0, 0xab}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa5, 0xa0, 0x8a, 0xbd, 0x8, 0x31, 0x66, 0x48, 0xe9, 0x6, 0x5f, 0x5c, 0x7, - 0xfa, 0x89, 0x7f, 0x82, 0xfb, 0x0, 0x1f, 0xa6, 0x91, 0x5b, 0xa2, 0x4a}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xc1, 0x3, 0xba, 0x54, 0xce, 0x63, 0x7d, 0x38, - 0x2f, 0x3e, 0x48, 0xa3, 0xff, 0xad, 0x34}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x3c, 0x2, 0xf6, 0x64, 0xe6}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x65, 0xe5, 0x7c, 0x6e, 0x2e, 0x18, 0x1c, 0xb1, 0xf9, 0xe5, 0x59, 0x22, 0x46, - 0x65, 0xc1, 0xd1, 0x22, 0xe1, 0x2b, 0xd9, 0x78, 0xbe, 0x75, 0x62, 0xfd, 0x7c}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xaa, 0x52, 0x21, 0x2a, 0xbf, 0x29, 0x35, 0x9a, 0xca, 0x7c, 0x2c, 0x7f, 0x7d, - 0x3b, 0x62, 0x62, 0xe0, 0x31, 0xe9, 0xc2, 0x4d, 0x14, 0x60, 0x26, 0x0, 0x83}; - lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x8d, 0xa0, 0xd3, 0x2a, 0xde, 0xc6, 0x2, 0xe5, 0x8b, 0x14, 0xa0, 0x42, 0x60, 0x11, 0x38, - 0xf6, 0x2f, 0xc0, 0x43, 0xd4, 0xc3, 0x95, 0x5d, 0x69, 0xdd, 0x95, 0x44, 0xf2, 0x49, 0x8e}; - uint8_t bytesprops1[] = {0x3f, 0xff, 0x7a, 0xf6, 0xe7, 0x22, 0xa3, 0x10, 0xda, 0x69, 0x25, - 0x4f, 0xd1, 0xf6, 0xe0, 0xd9, 0x55, 0x4, 0xeb, 0x97, 0x9f, 0xde}; - uint8_t bytesprops2[] = {0x2e, 0xe6, 0x32, 0x28, 0x6d, 0xfe, 0xb2, 0x75, 0x3d, 0x52, 0x97, 0xe3, 0x67, - 0xbc, 0x4b, 0x57, 0x5f, 0xb6, 0xd8, 0xde, 0x5d, 0x22, 0x50, 0xc, 0x7a}; - uint8_t bytesprops3[] = {0x6b, 0xd8, 0xf7, 0x32, 0x7c, 0x2c, 0x98, 0x5a, 0xce, 0x98, 0xbc, - 0x81, 0x2d, 0x28, 0xd0, 0x10, 0x19, 0xa4, 0xc, 0x92, 0xca, 0xea}; - uint8_t bytesprops4[] = {0x32, 0xd9, 0x1e, 0x8d, 0x36, 0x55, 0xbe, 0x62}; - uint8_t bytesprops5[] = {0xc9, 0xe2, 0xc1, 0x18, 0x53, 0x22, 0x18, 0x1c}; - uint8_t bytesprops6[] = {0x29, 0x41, 0x67, 0xd0, 0xb, 0xa, 0xf1, 0xe5, 0xb0, 0xab, 0x75, 0xd9}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9806}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20414}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops6}}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12164, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12633 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\142\241\204\138,\174\131\149\199\160o\205\146",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("r\146\242\132\DC1\212\252\ETX\DC3\192\195\&3\169\231!",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\225\238p\223\135rJ\134'\ETB\DEL\137\131\NUL\223h\DC4\171\ESC\248",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("l1\185\139a\217\DEL7?\r\EM?",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("?\226!\129{\254Q",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\FSG=\NUL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\142gv\133\156\SYN\162\216C",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\152\212\158(t\138F\128{&?'-\194\239p\DC2H\132\131\SYNd\169\128\215\NAKa\217",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\179\212\228\145\130\161\198\&5\236H\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS0}),("\196\&6?\162\212TA\205\USkt\b\208",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropRequestResponseInformation -// 215,PropResponseInformation "\238w\DC3_W$!\151P1\237xy\158\140!~~\EMl\240",PropAuthenticationMethod -// "'\151b\\\162\166\174\GSV\248>\144",PropRetainAvailable 182,PropRetainAvailable 38,PropCorrelationData -// "2\148\238\164i\145\156(\245U\SO"] -TEST(Subscribe5QCTest, Encode62) { - uint8_t pkt[] = {0x82, 0xac, 0x1, 0x54, 0x8a, 0x3b, 0x19, 0xd7, 0x1a, 0x0, 0x15, 0xee, 0x77, 0x13, 0x5f, 0x57, - 0x24, 0x21, 0x97, 0x50, 0x31, 0xed, 0x78, 0x79, 0x9e, 0x8c, 0x21, 0x7e, 0x7e, 0x19, 0x6c, 0xf0, - 0x15, 0x0, 0xc, 0x27, 0x97, 0x62, 0x5c, 0xa2, 0xa6, 0xae, 0x1d, 0x56, 0xf8, 0x3e, 0x90, 0x25, - 0xb6, 0x25, 0x26, 0x9, 0x0, 0xb, 0x32, 0x94, 0xee, 0xa4, 0x69, 0x91, 0x9c, 0x28, 0xf5, 0x55, - 0xe, 0x0, 0xd, 0xd9, 0xc1, 0x92, 0x85, 0xe9, 0xed, 0x38, 0x34, 0x2, 0x7c, 0x39, 0xf, 0x5e, - 0x1, 0x0, 0xb, 0x21, 0xbf, 0xfa, 0x54, 0x3e, 0xe2, 0x21, 0x81, 0x7b, 0xfe, 0x51, 0x1, 0x0, - 0x4, 0x1c, 0x47, 0x3d, 0x0, 0x1, 0x0, 0x9, 0x8e, 0x67, 0x76, 0x85, 0x9c, 0x16, 0xa2, 0xd8, - 0x43, 0x1, 0x0, 0x1c, 0x98, 0xd4, 0x9e, 0x28, 0x74, 0x8a, 0x46, 0x80, 0x7b, 0x26, 0x3f, 0x27, - 0x2d, 0xc2, 0xef, 0x70, 0x12, 0x48, 0x84, 0x83, 0x16, 0x64, 0xa9, 0x80, 0xd7, 0x15, 0x61, 0xd9, - 0x2, 0x0, 0xb, 0xb3, 0xd4, 0xe4, 0x91, 0x82, 0xa1, 0xc6, 0x35, 0xec, 0x48, 0x98, 0x0, 0x0, - 0xd, 0xc4, 0x36, 0x3f, 0xa2, 0xd4, 0x54, 0x41, 0xcd, 0x1f, 0x6b, 0x74, 0x8, 0xd0, 0x2}; - - uint8_t buf[185] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xd9, 0xc1, 0x92, 0x85, 0xe9, 0xed, 0x38, 0x34, 0x2, 0x7c, 0x39, 0xf, 0x5e}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x21, 0xbf, 0xfa, 0x54, 0x3e, 0xe2, 0x21, 0x81, 0x7b, 0xfe, 0x51}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1c, 0x47, 0x3d, 0x0}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8e, 0x67, 0x76, 0x85, 0x9c, 0x16, 0xa2, 0xd8, 0x43}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x98, 0xd4, 0x9e, 0x28, 0x74, 0x8a, 0x46, 0x80, 0x7b, 0x26, - 0x3f, 0x27, 0x2d, 0xc2, 0xef, 0x70, 0x12, 0x48, 0x84, 0x83, - 0x16, 0x64, 0xa9, 0x80, 0xd7, 0x15, 0x61, 0xd9}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb3, 0xd4, 0xe4, 0x91, 0x82, 0xa1, 0xc6, 0x35, 0xec, 0x48, 0x98}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc4, 0x36, 0x3f, 0xa2, 0xd4, 0x54, 0x41, 0xcd, 0x1f, 0x6b, 0x74, 0x8, 0xd0}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0xee, 0x77, 0x13, 0x5f, 0x57, 0x24, 0x21, 0x97, 0x50, 0x31, 0xed, - 0x78, 0x79, 0x9e, 0x8c, 0x21, 0x7e, 0x7e, 0x19, 0x6c, 0xf0}; - uint8_t bytesprops1[] = {0x27, 0x97, 0x62, 0x5c, 0xa2, 0xa6, 0xae, 0x1d, 0x56, 0xf8, 0x3e, 0x90}; - uint8_t bytesprops2[] = {0x32, 0x94, 0xee, 0xa4, 0x69, 0x91, 0x9c, 0x28, 0xf5, 0x55, 0xe}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops2}}}, - }; - - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21642, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 17671 [("u\219]\165\215\137\250\193O\129\136\181\180\tG@\188t",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\250\141\FS\155\a\192Q}\186\203\ACK\DEL\246\233\SUB\206\&2/\240\137\189'F$\189dq\159\142h",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\SYN\189~\178VN\200\201\v\165\218\230\166\ETB",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("L\136+\152\143",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\139\202\184\152g\f\231`",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [PropResponseInformation -// "\146V\195\218\217\DC4H\209q\GS",PropPayloadFormatIndicator 34,PropContentType -// "6\a0\fVG^\148\132\138.\137\220\DC4\187\"=\188.",PropSubscriptionIdentifierAvailable 205,PropResponseTopic -// "\180\154\201r7N\146\195\"\175\198A)\171\250\155\133\t\228J\STX\172[\172",PropAssignedClientIdentifier -// "",PropServerKeepAlive 12008,PropReasonString "\198S\163,(\242\243",PropAuthenticationData -// "\253\131\189\&2\190*\208\DC4\DC2\149\220\184",PropSubscriptionIdentifier 28,PropRequestResponseInformation -// 174,PropCorrelationData "j\DLE\152\248\171'Y\147\DEL\233 \139\196\253b?\"\r\FS\191\163\159y"] -TEST(Subscribe5QCTest, Encode63) { - uint8_t pkt[] = {0x82, 0xe3, 0x1, 0x45, 0x7, 0x7f, 0x1a, 0x0, 0xa, 0x92, 0x56, 0xc3, 0xda, 0xd9, 0x14, 0x48, 0xd1, - 0x71, 0x1d, 0x1, 0x22, 0x3, 0x0, 0x13, 0x36, 0x7, 0x30, 0xc, 0x56, 0x47, 0x5e, 0x94, 0x84, 0x8a, - 0x2e, 0x89, 0xdc, 0x14, 0xbb, 0x22, 0x3d, 0xbc, 0x2e, 0x29, 0xcd, 0x8, 0x0, 0x18, 0xb4, 0x9a, 0xc9, - 0x72, 0x37, 0x4e, 0x92, 0xc3, 0x22, 0xaf, 0xc6, 0x41, 0x29, 0xab, 0xfa, 0x9b, 0x85, 0x9, 0xe4, 0x4a, - 0x2, 0xac, 0x5b, 0xac, 0x12, 0x0, 0x0, 0x13, 0x2e, 0xe8, 0x1f, 0x0, 0x7, 0xc6, 0x53, 0xa3, 0x2c, - 0x28, 0xf2, 0xf3, 0x16, 0x0, 0xc, 0xfd, 0x83, 0xbd, 0x32, 0xbe, 0x2a, 0xd0, 0x14, 0x12, 0x95, 0xdc, - 0xb8, 0xb, 0x1c, 0x19, 0xae, 0x9, 0x0, 0x17, 0x6a, 0x10, 0x98, 0xf8, 0xab, 0x27, 0x59, 0x93, 0x7f, - 0xe9, 0x20, 0x8b, 0xc4, 0xfd, 0x62, 0x3f, 0x22, 0xd, 0x1c, 0xbf, 0xa3, 0x9f, 0x79, 0x0, 0x12, 0x75, - 0xdb, 0x5d, 0xa5, 0xd7, 0x89, 0xfa, 0xc1, 0x4f, 0x81, 0x88, 0xb5, 0xb4, 0x9, 0x47, 0x40, 0xbc, 0x74, - 0x1, 0x0, 0x0, 0x1, 0x0, 0x1e, 0xfa, 0x8d, 0x1c, 0x9b, 0x7, 0xc0, 0x51, 0x7d, 0xba, 0xcb, 0x6, - 0x7f, 0xf6, 0xe9, 0x1a, 0xce, 0x32, 0x2f, 0xf0, 0x89, 0xbd, 0x27, 0x46, 0x24, 0xbd, 0x64, 0x71, 0x9f, - 0x8e, 0x68, 0x0, 0x0, 0xe, 0x16, 0xbd, 0x7e, 0xb2, 0x56, 0x4e, 0xc8, 0xc9, 0xb, 0xa5, 0xda, 0xe6, - 0xa6, 0x17, 0x1, 0x0, 0x5, 0x4c, 0x88, 0x2b, 0x98, 0x8f, 0x2, 0x0, 0x8, 0x8b, 0xca, 0xb8, 0x98, - 0x67, 0xc, 0xe7, 0x60, 0x1, 0x0, 0x1, 0x5c, 0x2}; - - uint8_t buf[240] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x75, 0xdb, 0x5d, 0xa5, 0xd7, 0x89, 0xfa, 0xc1, 0x4f, - 0x81, 0x88, 0xb5, 0xb4, 0x9, 0x47, 0x40, 0xbc, 0x74}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfa, 0x8d, 0x1c, 0x9b, 0x7, 0xc0, 0x51, 0x7d, 0xba, 0xcb, - 0x6, 0x7f, 0xf6, 0xe9, 0x1a, 0xce, 0x32, 0x2f, 0xf0, 0x89, - 0xbd, 0x27, 0x46, 0x24, 0xbd, 0x64, 0x71, 0x9f, 0x8e, 0x68}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x16, 0xbd, 0x7e, 0xb2, 0x56, 0x4e, 0xc8, 0xc9, 0xb, 0xa5, 0xda, 0xe6, 0xa6, 0x17}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4c, 0x88, 0x2b, 0x98, 0x8f}; - lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8b, 0xca, 0xb8, 0x98, 0x67, 0xc, 0xe7, 0x60}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5c}; - lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x92, 0x56, 0xc3, 0xda, 0xd9, 0x14, 0x48, 0xd1, 0x71, 0x1d}; - uint8_t bytesprops1[] = {0x36, 0x7, 0x30, 0xc, 0x56, 0x47, 0x5e, 0x94, 0x84, 0x8a, - 0x2e, 0x89, 0xdc, 0x14, 0xbb, 0x22, 0x3d, 0xbc, 0x2e}; - uint8_t bytesprops2[] = {0xb4, 0x9a, 0xc9, 0x72, 0x37, 0x4e, 0x92, 0xc3, 0x22, 0xaf, 0xc6, 0x41, - 0x29, 0xab, 0xfa, 0x9b, 0x85, 0x9, 0xe4, 0x4a, 0x2, 0xac, 0x5b, 0xac}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0xc6, 0x53, 0xa3, 0x2c, 0x28, 0xf2, 0xf3}; - uint8_t bytesprops5[] = {0xfd, 0x83, 0xbd, 0x32, 0xbe, 0x2a, 0xd0, 0x14, 0x12, 0x95, 0xdc, 0xb8}; - uint8_t bytesprops6[] = {0x6a, 0x10, 0x98, 0xf8, 0xab, 0x27, 0x59, 0x93, 0x7f, 0xe9, 0x20, 0x8b, - 0xc4, 0xfd, 0x62, 0x3f, 0x22, 0xd, 0x1c, 0xbf, 0xa3, 0x9f, 0x79}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12008}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops6}}}, - }; - - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17671, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 18903 [("\245\147\176",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("sQ\169h\ACK\237\155\fg\232\206\138",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSubscriptionIdentifier -// 7,PropTopicAliasMaximum 1496,PropResponseInformation "]\177\198?\210\a",PropRetainAvailable -// 103,PropMessageExpiryInterval 4264,PropMaximumPacketSize 17108,PropSessionExpiryInterval -// 13290,PropAuthenticationMethod "\139\169\181\186(]\220\a",PropAuthenticationMethod -// "\251vk\EM<8\157\SYN\172\&2\185\171\143\228\243\&0r\132B\251\&26\151\217-\225",PropContentType -// "X\147\161u\230\184\171\226\184[S\b\129ru\234\138\169",PropResponseTopic "\214*\r\155\154",PropServerKeepAlive -// 21747,PropMaximumPacketSize 31882,PropMessageExpiryInterval 2727,PropReasonString -// ":\193#\154|(8\182\185!\v0\240\148\147R\248C\146\205\US\STX\168\247\205\242\243\179",PropReasonString -// "\246\157'\205\&1\ETBS",PropWildcardSubscriptionAvailable 213,PropRetainAvailable -// 20,PropSubscriptionIdentifierAvailable 73,PropAssignedClientIdentifier -// "\ENQ.\158\SOHZK\228\173\138\202d&3\249\219\233*\229b:\236\DLE\CANQ\232\211DS",PropReasonString -// "y\209l\SO\152\198y/\132\251\251~\t\DC2\246\ETXj",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("\134/\US\STX\249\130\n\159\"\235\ETB\FS\163\USR\194\156d>\213\144=\161/*'\231\"",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\DEL\250Oc\141\225\&8\234B\179",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\141\218\241\136\246\183d\251\&3\182\235#\208\bPH\170Y\194",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\215N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS -// = QoS1}),("}'\141;\170\&26H\213Yh\130\RS\178\DLEuL\155\134\229\210\138\DLEi\GS~S",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\220\&6\DC2a\245\161\nd\210\tR\238\159Z1\236\207\215\181\204\ACKb}\252\217",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("f\DLE\USF\DC2\210D\237A\172\246;\FS"] -TEST(Subscribe5QCTest, Encode66) { - uint8_t pkt[] = { - 0x82, 0x9f, 0x3, 0x12, 0x7c, 0xfe, 0x1, 0x8, 0x0, 0xf, 0x7d, 0xd9, 0x43, 0xc7, 0x90, 0x77, 0xcd, 0xa3, 0xa4, - 0xfa, 0x2a, 0x51, 0xd, 0xbc, 0x88, 0x27, 0x0, 0x0, 0xa, 0x53, 0x12, 0x0, 0xb, 0xf0, 0x73, 0xca, 0xd0, 0xfa, - 0x5b, 0x62, 0x63, 0x84, 0x73, 0x50, 0xb, 0x8, 0x26, 0x0, 0x19, 0x95, 0x6d, 0x2b, 0xa6, 0xa2, 0x7d, 0xa, 0x5b, - 0x6f, 0xfc, 0xa9, 0x97, 0xa8, 0x12, 0x14, 0xd9, 0xb8, 0x95, 0x95, 0x1f, 0x34, 0x13, 0x93, 0xf1, 0x6, 0x0, 0xc, - 0x8f, 0x24, 0xc3, 0x7b, 0xaf, 0xad, 0x7e, 0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xcd, 0xb4, 0x20, 0x30, 0x5c, 0xee, 0x27, 0xb, 0xef, 0x25, 0x8c, 0x79, 0x82, 0xa6, 0x10, - 0x46, 0x57, 0xc4, 0x2b, 0x2f, 0x1a, 0xaf, 0x6b, 0x2, 0x0, 0x12, 0xa5, 0xd0, 0x44, 0x52, 0xba, 0xa4, 0xa9, 0x2c, - 0xf7, 0xb9, 0x1d, 0x38, 0x2e, 0xfb, 0x2c, 0x6a, 0x39, 0x5, 0x0, 0x0, 0xd, 0xec, 0x31, 0xb4, 0x65, 0x9f, 0x78, - 0xbe, 0x7b, 0x6, 0x65, 0xde, 0x35, 0x96, 0x2, 0x0, 0x7, 0xa9, 0x1b, 0xa4, 0x2a, 0x77, 0x33, 0x58, 0x0, 0x0, - 0x3, 0x88, 0xb, 0x89, 0x0, 0x0, 0x1b, 0xf3, 0xc1, 0x4d, 0x7a, 0x26, 0x97, 0xf0, 0x69, 0x8a, 0xab, 0x3d, 0xde, - 0xe2, 0xa9, 0x28, 0xfb, 0x92, 0x95, 0x6b, 0x33, 0xb0, 0x74, 0xce, 0xa1, 0x4e, 0x7e, 0xa5, 0x0, 0x0, 0x16, 0xb1, - 0xd1, 0xf2, 0xad, 0x55, 0xe8, 0x3, 0x2a, 0xd9, 0x69, 0xfa, 0xa7, 0x4a, 0x68, 0xf0, 0x1, 0xd2, 0xe6, 0x19, 0x96, - 0x7a, 0xcd, 0x2, 0x0, 0xd, 0xb7, 0xbd, 0x9f, 0x3f, 0x2c, 0xfb, 0xf6, 0x7f, 0x1c, 0x24, 0x86, 0x86, 0x7d, 0x1}; - - uint8_t buf[428] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x6a, 0xa0, 0x90, 0x83, 0xc7, 0x95, 0x89, 0xcd, 0xb4, 0x20, - 0x30, 0x5c, 0xee, 0x27, 0xb, 0xef, 0x25, 0x8c, 0x79, 0x82, - 0xa6, 0x10, 0x46, 0x57, 0xc4, 0x2b, 0x2f, 0x1a, 0xaf, 0x6b}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa5, 0xd0, 0x44, 0x52, 0xba, 0xa4, 0xa9, 0x2c, 0xf7, - 0xb9, 0x1d, 0x38, 0x2e, 0xfb, 0x2c, 0x6a, 0x39, 0x5}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xec, 0x31, 0xb4, 0x65, 0x9f, 0x78, 0xbe, 0x7b, 0x6, 0x65, 0xde, 0x35, 0x96}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa9, 0x1b, 0xa4, 0x2a, 0x77, 0x33, 0x58}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x88, 0xb, 0x89}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf3, 0xc1, 0x4d, 0x7a, 0x26, 0x97, 0xf0, 0x69, 0x8a, 0xab, 0x3d, 0xde, 0xe2, 0xa9, - 0x28, 0xfb, 0x92, 0x95, 0x6b, 0x33, 0xb0, 0x74, 0xce, 0xa1, 0x4e, 0x7e, 0xa5}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb1, 0xd1, 0xf2, 0xad, 0x55, 0xe8, 0x3, 0x2a, 0xd9, 0x69, 0xfa, - 0xa7, 0x4a, 0x68, 0xf0, 0x1, 0xd2, 0xe6, 0x19, 0x96, 0x7a, 0xcd}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb7, 0xbd, 0x9f, 0x3f, 0x2c, 0xfb, 0xf6, 0x7f, 0x1c, 0x24, 0x86, 0x86, 0x7d}; - lwmqtt_string_t topic_filter_s7 = {13, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x7d, 0xd9, 0x43, 0xc7, 0x90, 0x77, 0xcd, 0xa3, 0xa4, 0xfa, 0x2a, 0x51, 0xd, 0xbc, 0x88}; - uint8_t bytesprops1[] = {0xf0, 0x73, 0xca, 0xd0, 0xfa, 0x5b, 0x62, 0x63, 0x84, 0x73, 0x50}; - uint8_t bytesprops3[] = {0x8f, 0x24, 0xc3, 0x7b, 0xaf, 0xad, 0x7e, 0x95, 0xf9, 0xb8, 0xea, 0x86}; - uint8_t bytesprops2[] = {0x95, 0x6d, 0x2b, 0xa6, 0xa2, 0x7d, 0xa, 0x5b, 0x6f, 0xfc, 0xa9, 0x97, 0xa8, - 0x12, 0x14, 0xd9, 0xb8, 0x95, 0x95, 0x1f, 0x34, 0x13, 0x93, 0xf1, 0x6}; - uint8_t bytesprops4[] = {0x58, 0xff, 0x8d, 0x5c, 0xc2, 0x9b, 0x1c, 0xa0, 0x14, 0x82, 0x5a, 0x59, - 0xdf, 0x4e, 0xe, 0x7e, 0xec, 0xce, 0x54, 0x58, 0x87, 0xf, 0x12, 0x39}; - uint8_t bytesprops5[] = {0xc7, 0x12, 0x1a, 0x9a, 0xd5, 0x9f, 0xd1, 0x9, 0xa3, 0xaa, 0xf4, 0xee, - 0x59, 0x16, 0x5b, 0x8d, 0x68, 0x47, 0xb, 0x48, 0x82, 0x29, 0xe, 0xa1}; - uint8_t bytesprops6[] = {0x96, 0xf2, 0x9c, 0x29, 0x72, 0x41, 0x31, 0x90, 0x21, 0xe6, 0x10, 0xdb, 0x1e, 0x1e}; - uint8_t bytesprops7[] = {0x5d, 0x23, 0x1, 0x92, 0x6f, 0x65, 0x8c, 0x50, 0x59, 0x2a, 0xf5, 0x41, 0x47, 0xe5, 0xf3}; - uint8_t bytesprops8[] = {0xb0, 0x8d, 0x79, 0x63, 0xaf, 0x44, 0xed, 0xe7, 0xf7, 0x38, 0x5b}; - uint8_t bytesprops9[] = {0x12, 0xdc, 0x70, 0x3f, 0xf1, 0xd4, 0xfb, 0xc5, 0x3d, 0xd3, - 0x37, 0x90, 0xdb, 0x73, 0x5d, 0x83, 0x49, 0x8d, 0xf}; - uint8_t bytesprops10[] = {0x2d, 0xf9, 0x91, 0xe5, 0xa7, 0x8c, 0xb2, 0xdf, 0xed, 0xbb, 0x3e, 0x10, - 0x1f, 0x46, 0x12, 0xd2, 0x44, 0xed, 0x41, 0xac, 0xf6, 0x3b, 0x1c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2643}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops2}, .v = {12, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25146}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24261}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops10}}}, - }; - - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4732, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14957 -// [("J\147\230\135V\211\184\205\203c\167\216Fb\245\187\165\175\&7\175Zh\224\EOT\247\147&#",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\134n\153\177\133\152\145aTM\141\223#\220\167X\138\DLE\143JK\148\201\ETX\251\138\229",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropMessageExpiryInterval 6325,PropRequestResponseInformation 164,PropWildcardSubscriptionAvailable -// 61,PropContentType "&\138\128\202\\\208\172\237e\245\230\190d\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS0}),("\SYN\233\177\236i\130\128\129L\208\174U\146\138F\247\182\212.\225y\DC2R\230s`9\178X_",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("C\183z\254h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\232t\GS\132\129\184f\CAN\CAN>\141:L\216\DC3{\191Y\213\232\SYN|\212\146k\195",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\SO]\228\162\189*ST\168t\ACK\143\216r\249\178\199\&0(\200[}\173\235\206\159F",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\STX\148\192L*\157`\179\224=e\224\228\&6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS0}),("\232J\211\179\136\130\218\157A\177\157j!\157\237\a\248\213\SUB\155",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropResponseInformation -// "\141\218\fB",PropMaximumQoS 48,PropUserProperty "8\STX\171\212E" -// "\205.\225\DC2)S\236\SO\221\ENQb\205\162\227G\206\194\171",PropWildcardSubscriptionAvailable 97,PropServerReference -// "",PropSharedSubscriptionAvailable 231,PropMessageExpiryInterval 8639,PropTopicAlias 18302,PropSubscriptionIdentifier -// 24,PropResponseTopic "N\232",PropRetainAvailable 16,PropServerReference -// "eR\198\190}\129\&0\DC4\130\133&\n\200\232q\197v\217\231|\236\&9\177",PropPayloadFormatIndicator -// 91,PropRequestResponseInformation 218,PropSubscriptionIdentifier 19,PropResponseTopic "\231\212A",PropContentType -// "\170\220\180\147\DC3\b\128\EOTD\166\220\EOTTr.\156\143es\186\f\SI\223",PropSubscriptionIdentifierAvailable -// 46,PropCorrelationData -// "\204s\151Y\143\185\163\219}\202\&3\197\DEL\230\162\201\223\"1\SUB\254s\246];\142ll\235",PropReceiveMaximum -// 11098,PropResponseInformation "\237)\FS.?~N",PropReasonString "t\239\236\164\&7\216]\131\205",PropUserProperty "@?l'" -// ">\215\168\185\215\198\234\247\182F\220\215\171\185\200\155\235\NUL7\133\128\n\v\146\183n+\214 -// \249",PropMessageExpiryInterval 23401,PropPayloadFormatIndicator 155,PropMessageExpiryInterval -// 15350,PropMessageExpiryInterval 15537,PropRequestProblemInformation 205,PropMaximumPacketSize -// 25844,PropSessionExpiryInterval 9076] -TEST(Subscribe5QCTest, Encode68) { - uint8_t pkt[] = { - 0x82, 0xb0, 0x3, 0x2a, 0xa7, 0xfc, 0x1, 0x1a, 0x0, 0x4, 0x8d, 0xda, 0xc, 0x42, 0x24, 0x30, 0x26, 0x0, 0x5, - 0x38, 0x2, 0xab, 0xd4, 0x45, 0x0, 0x12, 0xcd, 0x2e, 0xe1, 0x12, 0x29, 0x53, 0xec, 0xe, 0xdd, 0x5, 0x62, 0xcd, - 0xa2, 0xe3, 0x47, 0xce, 0xc2, 0xab, 0x28, 0x61, 0x1c, 0x0, 0x0, 0x2a, 0xe7, 0x2, 0x0, 0x0, 0x21, 0xbf, 0x23, - 0x47, 0x7e, 0xb, 0x18, 0x8, 0x0, 0x2, 0x4e, 0xe8, 0x25, 0x10, 0x1c, 0x0, 0x17, 0x65, 0x52, 0xc6, 0xbe, 0x7d, - 0x81, 0x30, 0x14, 0x82, 0x85, 0x26, 0xa, 0xc8, 0xe8, 0x71, 0xc5, 0x76, 0xd9, 0xe7, 0x7c, 0xec, 0x39, 0xb1, 0x1, - 0x5b, 0x19, 0xda, 0xb, 0x13, 0x8, 0x0, 0x3, 0xe7, 0xd4, 0x41, 0x3, 0x0, 0x17, 0xaa, 0xdc, 0xb4, 0x93, 0x13, - 0x8, 0x80, 0x4, 0x44, 0xa6, 0xdc, 0x4, 0x54, 0x72, 0x2e, 0x9c, 0x8f, 0x65, 0x73, 0xba, 0xc, 0xf, 0xdf, 0x29, - 0x2e, 0x9, 0x0, 0x1d, 0xcc, 0x73, 0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x39, 0xb2, 0x58, 0x5f, 0x0, 0x0, 0x5, 0x43, 0xb7, 0x7a, 0xfe, 0x68, 0x1, 0x0, 0x1a, 0xe8, 0x74, 0x1d, 0x84, - 0x81, 0xb8, 0x66, 0x18, 0x18, 0x3e, 0x8d, 0x3a, 0x4c, 0xd8, 0x13, 0x7b, 0xbf, 0x59, 0xd5, 0xe8, 0x16, 0x7c, 0xd4, - 0x92, 0x6b, 0xc3, 0x1, 0x0, 0x1b, 0xe, 0x5d, 0xe4, 0xa2, 0xbd, 0x2a, 0x53, 0x54, 0xa8, 0x74, 0x6, 0x8f, 0xd8, - 0x72, 0xf9, 0xb2, 0xc7, 0x30, 0x28, 0xc8, 0x5b, 0x7d, 0xad, 0xeb, 0xce, 0x9f, 0x46, 0x1, 0x0, 0xe, 0x2, 0x94, - 0xc0, 0x4c, 0x2a, 0x9d, 0x60, 0xb3, 0xe0, 0x3d, 0x65, 0xe0, 0xe4, 0x36, 0x0, 0x0, 0x14, 0xe8, 0x4a, 0xd3, 0xb3, - 0x88, 0x82, 0xda, 0x9d, 0x41, 0xb1, 0x9d, 0x6a, 0x21, 0x9d, 0xed, 0x7, 0xf8, 0xd5, 0x1a, 0x9b, 0x0}; - - uint8_t buf[445] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x74, 0x1a, 0x39, 0xbc, 0x36, 0xf6, 0x91, 0x8b, - 0xb3, 0x5a, 0xdb, 0xc9, 0xc3, 0x5f, 0x45, 0xfb}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc1, 0x69, 0x61, 0xff, 0xe8, 0x35, 0x8a, 0xc7, 0x3e, 0xf5, 0xe6, 0xbe, 0x64, 0xa}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x16, 0xe9, 0xb1, 0xec, 0x69, 0x82, 0x80, 0x81, 0x4c, 0xd0, - 0xae, 0x55, 0x92, 0x8a, 0x46, 0xf7, 0xb6, 0xd4, 0x2e, 0xe1, - 0x79, 0x12, 0x52, 0xe6, 0x73, 0x60, 0x39, 0xb2, 0x58, 0x5f}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x43, 0xb7, 0x7a, 0xfe, 0x68}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe8, 0x74, 0x1d, 0x84, 0x81, 0xb8, 0x66, 0x18, 0x18, 0x3e, 0x8d, 0x3a, 0x4c, - 0xd8, 0x13, 0x7b, 0xbf, 0x59, 0xd5, 0xe8, 0x16, 0x7c, 0xd4, 0x92, 0x6b, 0xc3}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe, 0x5d, 0xe4, 0xa2, 0xbd, 0x2a, 0x53, 0x54, 0xa8, 0x74, 0x6, 0x8f, 0xd8, 0x72, - 0xf9, 0xb2, 0xc7, 0x30, 0x28, 0xc8, 0x5b, 0x7d, 0xad, 0xeb, 0xce, 0x9f, 0x46}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x2, 0x94, 0xc0, 0x4c, 0x2a, 0x9d, 0x60, 0xb3, 0xe0, 0x3d, 0x65, 0xe0, 0xe4, 0x36}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe8, 0x4a, 0xd3, 0xb3, 0x88, 0x82, 0xda, 0x9d, 0x41, 0xb1, - 0x9d, 0x6a, 0x21, 0x9d, 0xed, 0x7, 0xf8, 0xd5, 0x1a, 0x9b}; - lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x8d, 0xda, 0xc, 0x42}; - uint8_t bytesprops2[] = {0xcd, 0x2e, 0xe1, 0x12, 0x29, 0x53, 0xec, 0xe, 0xdd, - 0x5, 0x62, 0xcd, 0xa2, 0xe3, 0x47, 0xce, 0xc2, 0xab}; - uint8_t bytesprops1[] = {0x38, 0x2, 0xab, 0xd4, 0x45}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x4e, 0xe8}; - uint8_t bytesprops5[] = {0x65, 0x52, 0xc6, 0xbe, 0x7d, 0x81, 0x30, 0x14, 0x82, 0x85, 0x26, 0xa, - 0xc8, 0xe8, 0x71, 0xc5, 0x76, 0xd9, 0xe7, 0x7c, 0xec, 0x39, 0xb1}; - uint8_t bytesprops6[] = {0xe7, 0xd4, 0x41}; - uint8_t bytesprops7[] = {0xaa, 0xdc, 0xb4, 0x93, 0x13, 0x8, 0x80, 0x4, 0x44, 0xa6, 0xdc, 0x4, - 0x54, 0x72, 0x2e, 0x9c, 0x8f, 0x65, 0x73, 0xba, 0xc, 0xf, 0xdf}; - uint8_t bytesprops8[] = {0xcc, 0x73, 0x97, 0x59, 0x8f, 0xb9, 0xa3, 0xdb, 0x7d, 0xca, 0x33, 0xc5, 0x7f, 0xe6, 0xa2, - 0xc9, 0xdf, 0x22, 0x31, 0x1a, 0xfe, 0x73, 0xf6, 0x5d, 0x3b, 0x8e, 0x6c, 0x6c, 0xeb}; - uint8_t bytesprops9[] = {0xed, 0x29, 0x1c, 0x2e, 0x3f, 0x7e, 0x4e}; - uint8_t bytesprops10[] = {0x74, 0xef, 0xec, 0xa4, 0x37, 0xd8, 0x5d, 0x83, 0xcd}; - uint8_t bytesprops12[] = {0x3e, 0xd7, 0xa8, 0xb9, 0xd7, 0xc6, 0xea, 0xf7, 0xb6, 0x46, 0xdc, 0xd7, 0xab, 0xb9, 0xc8, - 0x9b, 0xeb, 0x0, 0x37, 0x85, 0x80, 0xa, 0xb, 0x92, 0xb7, 0x6e, 0x2b, 0xd6, 0x20, 0xf9}; - uint8_t bytesprops11[] = {0x40, 0x3f, 0x6c, 0x27}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8639}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18302}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11098}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops11}, .v = {30, (char*)&bytesprops12}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23401}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15350}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15537}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25844}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9076}}, - }; - - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10919, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 692 [("\151\140>\206\207\NUL\208\139\194L\251\227\220\170\163\153*~?,w\245u",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\227\154\215d\192;_\237G\128o\235Q\218rV\202\SOHr\DEL\144\155",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("S'\141\229\&7]\"\179\212\174\r\185\176",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\137\202Y\ENQ\254#\197\FS(R\208\234n0x\ACK\141\210i\227$0\182H%",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("0\237\190\218C6",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\247/{\nv\233V\144\198e\158",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\247\194\142\228\247\186\227\&8",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("J",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\200\183{SW\236\248y\197\224\172K\STX\184W\v~\211",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\247\146\ETB\254\241\SYN\199\197\175\237\\\220\213\154\178\214\136k\147S\SI\228\EM\219\129.\240",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\249h\135(AF",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1})] [PropPayloadFormatIndicator 98,PropSubscriptionIdentifierAvailable 91,PropAssignedClientIdentifier -// "",PropReceiveMaximum 7702,PropReasonString -// "\DEL\212\RS\209\138\vV\203\176\167\GSh\166\241a\174\223\134i\ACK\180\141\167\143\GS*W",PropResponseInformation -// "S\n\222\138\232",PropSubscriptionIdentifierAvailable 17,PropRequestResponseInformation 229,PropMessageExpiryInterval -// 357,PropUserProperty "\194\165\224\b\149\&0\226KTy\175\187\RSC5" "\177W]>\200NI6gJ\199\&4\148{\129Y\202 -// [1\244\223\141\240S"] -TEST(Subscribe5QCTest, Encode69) { - uint8_t pkt[] = { - 0x82, 0xaa, 0x2, 0x2, 0xb4, 0x66, 0x1, 0x62, 0x29, 0x5b, 0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, 0xe3, 0x24, 0x30, 0xb6, 0x48, 0x25, 0x1, 0x0, 0x6, 0x30, 0xed, 0xbe, 0xda, - 0x43, 0x36, 0x1, 0x0, 0xb, 0xf7, 0x2f, 0x7b, 0xa, 0x76, 0xe9, 0x56, 0x90, 0xc6, 0x65, 0x9e, 0x0, 0x0, 0x8, - 0xf7, 0xc2, 0x8e, 0xe4, 0xf7, 0xba, 0xe3, 0x38, 0x0, 0x0, 0x1, 0x4a, 0x2, 0x0, 0x12, 0xc8, 0xb7, 0x7b, 0x53, - 0x57, 0xec, 0xf8, 0x79, 0xc5, 0xe0, 0xac, 0x4b, 0x2, 0xb8, 0x57, 0xb, 0x7e, 0xd3, 0x0, 0x0, 0x1b, 0xf7, 0x92, - 0x17, 0xfe, 0xf1, 0x16, 0xc7, 0xc5, 0xaf, 0xed, 0x5c, 0xdc, 0xd5, 0x9a, 0xb2, 0xd6, 0x88, 0x6b, 0x93, 0x53, 0xf, - 0xe4, 0x19, 0xdb, 0x81, 0x2e, 0xf0, 0x2, 0x0, 0x6, 0xf9, 0x68, 0x87, 0x28, 0x41, 0x46, 0x1}; - - uint8_t buf[311] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x97, 0x8c, 0x3e, 0xce, 0xcf, 0x0, 0xd0, 0x8b, 0xc2, 0x4c, 0xfb, 0xe3, - 0xdc, 0xaa, 0xa3, 0x99, 0x2a, 0x7e, 0x3f, 0x2c, 0x77, 0xf5, 0x75}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe3, 0x9a, 0xd7, 0x64, 0xc0, 0x3b, 0x5f, 0xed, 0x47, 0x80, 0x6f, - 0xeb, 0x51, 0xda, 0x72, 0x56, 0xca, 0x1, 0x72, 0x7f, 0x90, 0x9b}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x53, 0x27, 0x8d, 0xe5, 0x37, 0x5d, 0x22, 0xb3, 0xd4, 0xae, 0xd, 0xb9, 0xb0}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x89, 0xca, 0x59, 0x5, 0xfe, 0x23, 0xc5, 0x1c, 0x28, 0x52, 0xd0, 0xea, 0x6e, - 0x30, 0x78, 0x6, 0x8d, 0xd2, 0x69, 0xe3, 0x24, 0x30, 0xb6, 0x48, 0x25}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x30, 0xed, 0xbe, 0xda, 0x43, 0x36}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf7, 0x2f, 0x7b, 0xa, 0x76, 0xe9, 0x56, 0x90, 0xc6, 0x65, 0x9e}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf7, 0xc2, 0x8e, 0xe4, 0xf7, 0xba, 0xe3, 0x38}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x4a}; - lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc8, 0xb7, 0x7b, 0x53, 0x57, 0xec, 0xf8, 0x79, 0xc5, - 0xe0, 0xac, 0x4b, 0x2, 0xb8, 0x57, 0xb, 0x7e, 0xd3}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xf7, 0x92, 0x17, 0xfe, 0xf1, 0x16, 0xc7, 0xc5, 0xaf, 0xed, 0x5c, 0xdc, 0xd5, 0x9a, - 0xb2, 0xd6, 0x88, 0x6b, 0x93, 0x53, 0xf, 0xe4, 0x19, 0xdb, 0x81, 0x2e, 0xf0}; - lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xf9, 0x68, 0x87, 0x28, 0x41, 0x46}; - lwmqtt_string_t topic_filter_s10 = {6, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x7f, 0xd4, 0x1e, 0xd1, 0x8a, 0xb, 0x56, 0xcb, 0xb0, 0xa7, 0x1d, 0x68, 0xa6, 0xf1, - 0x61, 0xae, 0xdf, 0x86, 0x69, 0x6, 0xb4, 0x8d, 0xa7, 0x8f, 0x1d, 0x2a, 0x57}; - uint8_t bytesprops2[] = {0x53, 0xa, 0xde, 0x8a, 0xe8}; - uint8_t bytesprops4[] = {0xb1, 0x57, 0x5d, 0x3e, 0xc8, 0x4e, 0x49, 0x36, 0x67, 0x4a, 0xc7, 0x34, 0x94, - 0x7b, 0x81, 0x59, 0xca, 0x20, 0x5b, 0x31, 0xf4, 0xdf, 0x8d, 0xf0, 0x53}; - uint8_t bytesprops3[] = {0xc2, 0xa5, 0xe0, 0x8, 0x95, 0x30, 0xe2, 0x4b, 0x54, 0x79, 0xaf, 0xbb, 0x1e, 0x43, 0x35}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7702}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 357}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops3}, .v = {25, (char*)&bytesprops4}}}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 692, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 1184 [("\170g\\2\a\FS\243\&2\134#\245<\232\v\154\&8;\169\197< " "\254\218t\234\144\136Yf<",PropResponseTopic -// "\174Zi\154\174d_\135\215\224oYC\210j*\192\186Fh\SYN\v\215L[\SOD\206\238",PropResponseTopic -// "=I\DLE\222\\e\188#\188\n\154\154\&5i\178\239\199\157@{\SOH\STX\254b8k\131",PropMessageExpiryInterval -// 28387,PropServerReference "4\245\EMk",PropPayloadFormatIndicator 115] -TEST(Subscribe5QCTest, Encode70) { - uint8_t pkt[] = { - 0x82, 0x83, 0x2, 0x4, 0xa0, 0xb7, 0x1, 0x13, 0x51, 0xb0, 0xb, 0x1e, 0x18, 0x0, 0x0, 0x54, 0x7, 0x3, 0x0, - 0x14, 0x84, 0xd, 0x37, 0x5d, 0xd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0xdd, 0x2f, 0x3f, 0x7, 0x68, 0x28, 0x51, 0x40, 0xb1, 0x1, 0x0, 0x1, 0xff, 0x2, 0x0, 0x3, 0xec, - 0xd0, 0xc6, 0x0, 0x0, 0x1, 0x1c, 0x1, 0x0, 0x18, 0x92, 0x10, 0x66, 0xf5, 0x6e, 0x40, 0xd0, 0x6d, 0xbf, 0x5, - 0xf8, 0xeb, 0x3d, 0xd5, 0xc0, 0x73, 0xe1, 0x5, 0x2b, 0x98, 0xa0, 0xc, 0x7c, 0xcc, 0x1}; - - uint8_t buf[272] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xaa, 0x67, 0x5c, 0x32, 0x7, 0x1c, 0xf3, 0x32, 0x86, 0x23, - 0xf5, 0x3c, 0xe8, 0xb, 0x3c, 0x73, 0x88, 0x83, 0x17, 0xdd, - 0x2f, 0x3f, 0x7, 0x68, 0x28, 0x51, 0x40, 0xb1}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xff}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xec, 0xd0, 0xc6}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1c}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x92, 0x10, 0x66, 0xf5, 0x6e, 0x40, 0xd0, 0x6d, 0xbf, 0x5, 0xf8, 0xeb, - 0x3d, 0xd5, 0xc0, 0x73, 0xe1, 0x5, 0x2b, 0x98, 0xa0, 0xc, 0x7c, 0xcc}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x84, 0xd, 0x37, 0x5d, 0xd, 0x90, 0xde, 0x7c, 0x78, 0x48, - 0x63, 0xae, 0x80, 0x29, 0x41, 0x7f, 0xbe, 0xd9, 0x2e, 0x5b}; - uint8_t bytesprops1[] = {0x44, 0xc}; - uint8_t bytesprops2[] = {0xb9, 0x97, 0xe8, 0xb1, 0x68, 0x7b, 0xb2, 0xf6, 0xf8, 0x53, 0xb1, 0xea, 0xd3, 0xf6, - 0x0, 0x67, 0xab, 0xa8, 0xa1, 0x20, 0xa6, 0xc6, 0x28, 0xcc, 0xb5, 0x10, 0x9e, 0x0}; - uint8_t bytesprops4[] = {0xfe, 0xda, 0x74, 0xea, 0x90, 0x88, 0x59, 0x66, 0x3c}; - uint8_t bytesprops3[] = {0x5e, 0xc5, 0x3d, 0x89, 0xdd, 0xc2, 0x2b, 0x52, - 0x3e, 0x9a, 0x38, 0x3b, 0xa9, 0xc5, 0x3c, 0x20}; - uint8_t bytesprops5[] = {0xae, 0x5a, 0x69, 0x9a, 0xae, 0x64, 0x5f, 0x87, 0xd7, 0xe0, 0x6f, 0x59, 0x43, 0xd2, 0x6a, - 0x2a, 0xc0, 0xba, 0x46, 0x68, 0x16, 0xb, 0xd7, 0x4c, 0x5b, 0xe, 0x44, 0xce, 0xee}; - uint8_t bytesprops6[] = {0x3d, 0x49, 0x10, 0xde, 0x5c, 0x65, 0xbc, 0x23, 0xbc, 0xa, 0x9a, 0x9a, 0x35, 0x69, - 0xb2, 0xef, 0xc7, 0x9d, 0x40, 0x7b, 0x1, 0x2, 0xfe, 0x62, 0x38, 0x6b, 0x83}; - uint8_t bytesprops7[] = {0x34, 0xf5, 0x19, 0x6b}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20912}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21511}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 855}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24514}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {9, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28387}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 115}}, - }; - - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1184, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 28334 [("\196\208x\145\a\197\236\166\237\198\\-\222a\r\140\158N\199\&7\178\RS`=>!E",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\163/?",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS -// = QoS1}),("_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\\\158\228\223\ETB:\150)dY|!\236\205\164s\139\v\167>\221\EM",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\232\208\185f\157\247N\190\191\ETX\212\t\213\229\SOH -// \206\v\178@\162^",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("m\137\v\f7\141&\216@\158!\GS\192\191\189",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\EOTg\241\167",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropSharedSubscriptionAvailable -// 34,PropServerKeepAlive 10247,PropAuthenticationMethod -// "\DEL=z\205\128\181C\232*\242:\233L\ve4\143D\155\208\&0ht\132Z{\ESC\238\159\201",PropSubscriptionIdentifierAvailable -// 248,PropRetainAvailable 28,PropMessageExpiryInterval 32489,PropMaximumPacketSize 21512,PropAuthenticationData -// "\147",PropMessageExpiryInterval 25286,PropUserProperty -// "\157\n\ACK\203\149\128\a\SYN\142\DC4}\133\193\168\228\243\200" "\128",PropReceiveMaximum -// 24957,PropSubscriptionIdentifierAvailable 191,PropAuthenticationData -// "\147\DLE\172\EM\159\172r\223Zfi.",PropMessageExpiryInterval 32172,PropSessionExpiryInterval 22638,PropReceiveMaximum -// 19477,PropTopicAlias 20439,PropRequestResponseInformation 231,PropServerKeepAlive 22562,PropMaximumPacketSize -// 20475,PropTopicAliasMaximum 14896,PropServerReference -// "\t\ETXMbx\253\ENQ4A}E\SUBR\t\138\147\141\199\253*V=\205\157",PropAssignedClientIdentifier -// "\CAN\230\&6\SO\204\212f\137m\227'\234\166o\176\222\136='F\181\137Gy\220\204\a\192\n",PropUserProperty "\245\f" -// "\176\244\230\b\213\SOH\201lP\\\158\202z\163!\198P\133\202",PropPayloadFormatIndicator 161,PropAuthenticationData -// "\\W\EM)\142\185\DC1\CAN\131f\STX\200\RS\230u\147\187\165\205"] -TEST(Subscribe5QCTest, Encode71) { - uint8_t pkt[] = { - 0x82, 0xe9, 0x2, 0x6e, 0xae, 0xf2, 0x1, 0x2a, 0x22, 0x13, 0x28, 0x7, 0x15, 0x0, 0x1e, 0x7f, 0x3d, 0x7a, 0xcd, - 0x80, 0xb5, 0x43, 0xe8, 0x2a, 0xf2, 0x3a, 0xe9, 0x4c, 0xb, 0x65, 0x34, 0x8f, 0x44, 0x9b, 0xd0, 0x30, 0x68, 0x74, - 0x84, 0x5a, 0x7b, 0x1b, 0xee, 0x9f, 0xc9, 0x29, 0xf8, 0x25, 0x1c, 0x2, 0x0, 0x0, 0x7e, 0xe9, 0x27, 0x0, 0x0, - 0x54, 0x8, 0x16, 0x0, 0x1, 0x93, 0x2, 0x0, 0x0, 0x62, 0xc6, 0x26, 0x0, 0x11, 0x9d, 0xa, 0x6, 0xcb, 0x95, - 0x80, 0x7, 0x16, 0x8e, 0x14, 0x7d, 0x85, 0xc1, 0xa8, 0xe4, 0xf3, 0xc8, 0x0, 0x1, 0x80, 0x21, 0x61, 0x7d, 0x29, - 0xbf, 0x16, 0x0, 0xc, 0x93, 0x10, 0xac, 0x19, 0x9f, 0xac, 0x72, 0xdf, 0x5a, 0x66, 0x69, 0x2e, 0x2, 0x0, 0x0, - 0x7d, 0xac, 0x11, 0x0, 0x0, 0x58, 0x6e, 0x21, 0x4c, 0x15, 0x23, 0x4f, 0xd7, 0x19, 0xe7, 0x13, 0x58, 0x22, 0x27, - 0x0, 0x0, 0x4f, 0xfb, 0x22, 0x3a, 0x30, 0x1c, 0x0, 0x18, 0x9, 0x3, 0x4d, 0x62, 0x78, 0xfd, 0x5, 0x34, 0x41, - 0x7d, 0x45, 0x1a, 0x52, 0x9, 0x8a, 0x93, 0x8d, 0xc7, 0xfd, 0x2a, 0x56, 0x3d, 0xcd, 0x9d, 0x12, 0x0, 0x1d, 0x18, - 0xe6, 0x36, 0xe, 0xcc, 0xd4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xf1, 0xa7, 0x1}; - - uint8_t buf[374] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xc4, 0xd0, 0x78, 0x91, 0x7, 0xc5, 0xec, 0xa6, 0xed, 0xc6, 0x5c, 0x2d, 0xde, 0x61, - 0xd, 0x8c, 0x9e, 0x4e, 0xc7, 0x37, 0xb2, 0x1e, 0x60, 0x3d, 0x3e, 0x21, 0x45}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa3, 0x2f, 0x3f}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5f}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x5c, 0x9e, 0xe4, 0xdf, 0x17, 0x3a, 0x96, 0x29, 0x64, 0x59, 0x7c, - 0x21, 0xec, 0xcd, 0xa4, 0x73, 0x8b, 0xb, 0xa7, 0x3e, 0xdd, 0x19}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe8, 0xd0, 0xb9, 0x66, 0x9d, 0xf7, 0x4e, 0xbe, 0xbf, 0x3, 0xd4, - 0x9, 0xd5, 0xe5, 0x1, 0x20, 0xce, 0xb, 0xb2, 0x40, 0xa2, 0x5e}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6d, 0x89, 0xb, 0xc, 0x37, 0x8d, 0x26, 0xd8, - 0x40, 0x9e, 0x21, 0x1d, 0xc0, 0xbf, 0xbd}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4, 0x67, 0xf1, 0xa7}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x7f, 0x3d, 0x7a, 0xcd, 0x80, 0xb5, 0x43, 0xe8, 0x2a, 0xf2, 0x3a, 0xe9, 0x4c, 0xb, 0x65, - 0x34, 0x8f, 0x44, 0x9b, 0xd0, 0x30, 0x68, 0x74, 0x84, 0x5a, 0x7b, 0x1b, 0xee, 0x9f, 0xc9}; - uint8_t bytesprops1[] = {0x93}; - uint8_t bytesprops3[] = {0x80}; - uint8_t bytesprops2[] = {0x9d, 0xa, 0x6, 0xcb, 0x95, 0x80, 0x7, 0x16, 0x8e, - 0x14, 0x7d, 0x85, 0xc1, 0xa8, 0xe4, 0xf3, 0xc8}; - uint8_t bytesprops4[] = {0x93, 0x10, 0xac, 0x19, 0x9f, 0xac, 0x72, 0xdf, 0x5a, 0x66, 0x69, 0x2e}; - uint8_t bytesprops5[] = {0x9, 0x3, 0x4d, 0x62, 0x78, 0xfd, 0x5, 0x34, 0x41, 0x7d, 0x45, 0x1a, - 0x52, 0x9, 0x8a, 0x93, 0x8d, 0xc7, 0xfd, 0x2a, 0x56, 0x3d, 0xcd, 0x9d}; - uint8_t bytesprops6[] = {0x18, 0xe6, 0x36, 0xe, 0xcc, 0xd4, 0x66, 0x89, 0x6d, 0xe3, 0x27, 0xea, 0xa6, 0x6f, 0xb0, - 0xde, 0x88, 0x3d, 0x27, 0x46, 0xb5, 0x89, 0x47, 0x79, 0xdc, 0xcc, 0x7, 0xc0, 0xa}; - uint8_t bytesprops8[] = {0xb0, 0xf4, 0xe6, 0x8, 0xd5, 0x1, 0xc9, 0x6c, 0x50, 0x5c, - 0x9e, 0xca, 0x7a, 0xa3, 0x21, 0xc6, 0x50, 0x85, 0xca}; - uint8_t bytesprops7[] = {0xf5, 0xc}; - uint8_t bytesprops9[] = {0x5c, 0x57, 0x19, 0x29, 0x8e, 0xb9, 0x11, 0x18, 0x83, 0x66, - 0x2, 0xc8, 0x1e, 0xe6, 0x75, 0x93, 0xbb, 0xa5, 0xcd}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10247}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32489}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21512}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25286}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops2}, .v = {1, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24957}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32172}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22638}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19477}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20439}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22562}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20475}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14896}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops7}, .v = {19, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops9}}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28334, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 26598 [("=\225\250g\177\216\249\&8\252='RyD\192\199@\SOh\247\158\236\151\&4d\199\247",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("#\151\183Z\151O\182\172\150*i\\\161\230\221\176\251\180\217H;]\215\250\196L\201\228\DC3\244",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\243\152\219Kk\182Q,eE \RS*/\SYN\134V\DC3FyOS[",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\139\SOH\t\179g\DC3&n'\158C\223Y\254",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\205$\145XN\129y\188+2W2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1})] [PropRequestResponseInformation 96,PropMessageExpiryInterval -// 28136,PropContentType -// "\214\134\176\130\223\&1\163\252\\\195\213\226\&5o\218Y6\177\140\252\204",PropRequestResponseInformation -// 139,PropReceiveMaximum 16930,PropUserProperty "\137\&1\174\174" -// "\244\252\233$*-\ESC\217z\183\165M\DC1\CAN\159S\238\232\175&|j\228U\226\171*pd\199",PropAssignedClientIdentifier -// "",PropCorrelationData "\FS\161",PropTopicAlias 6017,PropAuthenticationData -// "\NAKX\210\187\SO<\246\&2\208QF\165\205\152\145\252\203",PropReasonString -// "\165\194\150{sK\198\166\n2\174Q\213\194\&29\237_\EM!?\135\&3$\DEL\141Y\240\EM",PropResponseInformation -// "\t\245Mk@N\240\&4IC,^\249\DC2\179\SIq\211\135}v?8\135\190\159.\a.",PropReasonString -// "\f\214R3\DC2mI\182\202Dr\147\176h\ETXr\244\139\&9\NUL",PropReasonString "5\214y",PropSubscriptionIdentifierAvailable -// 161,PropSubscriptionIdentifierAvailable 197] -TEST(Subscribe5QCTest, Encode72) { - uint8_t pkt[] = { - 0x82, 0xcb, 0x2, 0x67, 0xe6, 0xcb, 0x1, 0x19, 0x60, 0x2, 0x0, 0x0, 0x6d, 0xe8, 0x3, 0x0, 0x15, 0xd6, 0x86, - 0xb0, 0x82, 0xdf, 0x31, 0xa3, 0xfc, 0x5c, 0xc3, 0xd5, 0xe2, 0x35, 0x6f, 0xda, 0x59, 0x36, 0xb1, 0x8c, 0xfc, 0xcc, - 0x19, 0x8b, 0x21, 0x42, 0x22, 0x26, 0x0, 0x4, 0x89, 0x31, 0xae, 0xae, 0x0, 0x1e, 0xf4, 0xfc, 0xe9, 0x24, 0x2a, - 0x2d, 0x1b, 0xd9, 0x7a, 0xb7, 0xa5, 0x4d, 0x11, 0x18, 0x9f, 0x53, 0xee, 0xe8, 0xaf, 0x26, 0x7c, 0x6a, 0xe4, 0x55, - 0xe2, 0xab, 0x2a, 0x70, 0x64, 0xc7, 0x12, 0x0, 0x0, 0x9, 0x0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c9, 0xe4, 0x13, 0xf4, 0x0, 0x0, 0x17, 0xf3, 0x98, 0xdb, 0x4b, 0x6b, 0xb6, 0x51, - 0x2c, 0x65, 0x45, 0x20, 0x1e, 0x2a, 0x2f, 0x16, 0x86, 0x56, 0x13, 0x46, 0x79, 0x4f, 0x53, 0x5b, 0x1, 0x0, 0xe, - 0x8b, 0x1, 0x9, 0xb3, 0x67, 0x13, 0x26, 0x6e, 0x27, 0x9e, 0x43, 0xdf, 0x59, 0xfe, 0x0, 0x0, 0xc, 0xcd, 0x24, - 0x91, 0x58, 0x4e, 0x81, 0x79, 0xbc, 0x2b, 0x32, 0x57, 0x32, 0x1}; - - uint8_t buf[344] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x3d, 0xe1, 0xfa, 0x67, 0xb1, 0xd8, 0xf9, 0x38, 0xfc, 0x3d, 0x27, 0x52, 0x79, 0x44, - 0xc0, 0xc7, 0x40, 0xe, 0x68, 0xf7, 0x9e, 0xec, 0x97, 0x34, 0x64, 0xc7, 0xf7}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x23, 0x97, 0xb7, 0x5a, 0x97, 0x4f, 0xb6, 0xac, 0x96, 0x2a, - 0x69, 0x5c, 0xa1, 0xe6, 0xdd, 0xb0, 0xfb, 0xb4, 0xd9, 0x48, - 0x3b, 0x5d, 0xd7, 0xfa, 0xc4, 0x4c, 0xc9, 0xe4, 0x13, 0xf4}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf3, 0x98, 0xdb, 0x4b, 0x6b, 0xb6, 0x51, 0x2c, 0x65, 0x45, 0x20, 0x1e, - 0x2a, 0x2f, 0x16, 0x86, 0x56, 0x13, 0x46, 0x79, 0x4f, 0x53, 0x5b}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8b, 0x1, 0x9, 0xb3, 0x67, 0x13, 0x26, 0x6e, 0x27, 0x9e, 0x43, 0xdf, 0x59, 0xfe}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xcd, 0x24, 0x91, 0x58, 0x4e, 0x81, 0x79, 0xbc, 0x2b, 0x32, 0x57, 0x32}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xd6, 0x86, 0xb0, 0x82, 0xdf, 0x31, 0xa3, 0xfc, 0x5c, 0xc3, 0xd5, - 0xe2, 0x35, 0x6f, 0xda, 0x59, 0x36, 0xb1, 0x8c, 0xfc, 0xcc}; - uint8_t bytesprops2[] = {0xf4, 0xfc, 0xe9, 0x24, 0x2a, 0x2d, 0x1b, 0xd9, 0x7a, 0xb7, 0xa5, 0x4d, 0x11, 0x18, 0x9f, - 0x53, 0xee, 0xe8, 0xaf, 0x26, 0x7c, 0x6a, 0xe4, 0x55, 0xe2, 0xab, 0x2a, 0x70, 0x64, 0xc7}; - uint8_t bytesprops1[] = {0x89, 0x31, 0xae, 0xae}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x1c, 0xa1}; - uint8_t bytesprops5[] = {0x15, 0x58, 0xd2, 0xbb, 0xe, 0x3c, 0xf6, 0x32, 0xd0, - 0x51, 0x46, 0xa5, 0xcd, 0x98, 0x91, 0xfc, 0xcb}; - uint8_t bytesprops6[] = {0xa5, 0xc2, 0x96, 0x7b, 0x73, 0x4b, 0xc6, 0xa6, 0xa, 0x32, 0xae, 0x51, 0xd5, 0xc2, 0x32, - 0x39, 0xed, 0x5f, 0x19, 0x21, 0x3f, 0x87, 0x33, 0x24, 0x7f, 0x8d, 0x59, 0xf0, 0x19}; - uint8_t bytesprops7[] = {0x9, 0xf5, 0x4d, 0x6b, 0x40, 0x4e, 0xf0, 0x34, 0x49, 0x43, 0x2c, 0x5e, 0xf9, 0x12, 0xb3, - 0xf, 0x71, 0xd3, 0x87, 0x7d, 0x76, 0x3f, 0x38, 0x87, 0xbe, 0x9f, 0x2e, 0x7, 0x2e}; - uint8_t bytesprops8[] = {0xc, 0xd6, 0x52, 0x33, 0x12, 0x6d, 0x49, 0xb6, 0xca, 0x44, - 0x72, 0x93, 0xb0, 0x68, 0x3, 0x72, 0xf4, 0x8b, 0x39, 0x0}; - uint8_t bytesprops9[] = {0x35, 0xd6, 0x79}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28136}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16930}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6017}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 197}}, - }; - - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26598, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 8075 [("\153\219wC\224\141\212\158d\179\204\165\177\194fH\170\138^",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\163{\DC4\190\210\150W\162\228}\131*;\DC1\208;\155n\214I\147\176\137\176",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\v\244\209y\179\242\230\161\147:u\140\228\&5k\177\179\250",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\184\211O\228\212N\251O\183\208V\241\211\t\209\244\RS\186",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic -// "\ENQ\140\&1\235e",PropSubscriptionIdentifierAvailable 44,PropSubscriptionIdentifierAvailable -// 21,PropMaximumPacketSize 27004,PropSubscriptionIdentifier 12,PropRequestResponseInformation 254] -TEST(Subscribe5QCTest, Encode74) { - uint8_t pkt[] = {0x82, 0xc7, 0x1, 0x46, 0x1b, 0x15, 0x8, 0x0, 0x5, 0x5, 0x8c, 0x31, 0xeb, 0x65,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x1}; - - uint8_t buf[212] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x45}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8, 0xc2, 0xb3, 0x87, 0x7f, 0x99, 0x5c}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x43, 0x6b, 0xef, 0x35, 0xd, 0x27, 0xdf, 0x64, 0xcd, 0x43, - 0xee, 0xbc, 0x95, 0xb3, 0xc6, 0x83, 0x8b, 0x87, 0xc8, 0x6a, - 0x98, 0x87, 0xa1, 0x61, 0x5a, 0x35, 0x72, 0xb2}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x50, 0x9d, 0xb5, 0x85, 0xb4, 0x7b}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x68, 0x73, 0x5f, 0x4b, 0xe7, 0x37, 0x5, 0x8e, 0x9d, 0xc2, - 0xc4, 0xfc, 0xf0, 0x88, 0x29, 0x9d, 0x9f, 0xa7, 0xff, 0x47}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x74, 0x80, 0x68, 0x86, 0x54, 0xa0, 0xb2, 0x72, 0x61, 0x92, 0xc9}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x32, 0x88, 0xeb, 0xe1}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0}; - lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x74, 0xc8, 0x1, 0x90, 0xf3, 0xb, 0x9f, 0x46, 0x26, 0xfd, 0xba, 0x2a, 0xa3, - 0x88, 0x64, 0xd, 0x41, 0x11, 0x6, 0xd1, 0x22, 0x11, 0xc1, 0x56, 0x11}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe8, 0xa9, 0xcd, 0x93, 0x16, 0x81, 0x91, 0xc4, 0x23, 0x21, 0x6, 0xab, 0x49, 0xe1}; - lwmqtt_string_t topic_filter_s9 = {14, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xd7, 0xdd, 0x19, 0xfe, 0x2f, 0xa4, 0x64, 0x3e, 0xb8, 0xd3, 0x4f, 0xe4, 0xd4, - 0x4e, 0xfb, 0x4f, 0xb7, 0xd0, 0x56, 0xf1, 0xd3, 0x9, 0xd1, 0xf4, 0x1e, 0xba}; - lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x5, 0x8c, 0x31, 0xeb, 0x65}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27004}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 254}}, - }; - - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17947, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 167 [("\231\169\150\t\250\191\150<\142\244\175\168\192\184\179",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\212\vx}\a\239:\\|\164~\165\239\172\b\182j\"e\244",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\199\200~",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\US97\178\208\r#N\n\150nm+6\213\NUL\171\252\t",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\137\ETX\197\217\NUL\223\232\207\253\202\144V#\158k\156DSE2\145\ENQ\158\234\133\150",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("#\149\222<\ETXQ\182,\188$Y~(\178|T\176_\145\151'",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\175\ENQ\GS\245\242)\153\DC2\129\190\DC4\n\235\129\160 \190\233",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("DJ\236\247\\fp\240\131\213\DLEP\133\CAN\133",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\188n\248-\193\248\138\147\SI\181\to\137\t\148\230\233=",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerReference -// "\159\250\222\226B\146z{\n\GS\163Q>\212\209b\140\f^|\225!\ETBS",PropRequestProblemInformation 41,PropCorrelationData -// "\167\165\236\242\220\NUL!\243\239\236\249(50\143",PropCorrelationData "!V\136\227\201R\STX",PropReasonString -// "\204\220Z\199A\209\242\&4\137\ETB\182r\nQ\137\234P\239\174^&\SYN",PropRequestProblemInformation -// 146,PropResponseTopic "\153+\SYN\164\143\202\203\241\178\ETX/\129\179\SI\165:L\187\249aXN",PropSubscriptionIdentifier -// 13,PropRequestResponseInformation 80,PropMessageExpiryInterval 23274,PropReceiveMaximum -// 1962,PropSharedSubscriptionAvailable 149,PropMaximumQoS 62,PropResponseInformation -// "QD5\172e\226i\226F\131J\188\136",PropResponseTopic "\EM\160\CAN\131 -// \229\162\139LF\219\159\167p,\217b\176\208\242Y\199I\US\246(\169",PropSharedSubscriptionAvailable -// 59,PropReceiveMaximum 31104,PropMessageExpiryInterval 8247,PropAssignedClientIdentifier -// "\GSA\148\189\b\203\157\128T\142%\EOT`\179{N\151l",PropRequestResponseInformation 165,PropRequestProblemInformation -// 246,PropAssignedClientIdentifier -// "\255\243\220\ENQ\239\198\194d\159\145\171\ENQ\f\149\EMH\176g\235",PropReceiveMaximum 18795] -TEST(Subscribe5QCTest, Encode75) { - uint8_t pkt[] = { - 0x82, 0xa1, 0x3, 0x0, 0xa7, 0xe7, 0x1, 0x1c, 0x0, 0x18, 0x9f, 0xfa, 0xde, 0xe2, 0x42, 0x92, 0x7a, 0x7b, 0xa, - 0x1d, 0xa3, 0x51, 0x3e, 0xd4, 0xd1, 0x62, 0x8c, 0xc, 0x5e, 0x7c, 0xe1, 0x21, 0x17, 0x53, 0x17, 0x29, 0x9, 0x0, - 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6f, 0x89, 0x9, 0x94, 0xe6, 0xe9, - 0x3d, 0x1}; - - uint8_t buf[430] = {0}; - - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xe7, 0xa9, 0x96, 0x9, 0xfa, 0xbf, 0x96, 0x3c, - 0x8e, 0xf4, 0xaf, 0xa8, 0xc0, 0xb8, 0xb3}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd4, 0xb, 0x78, 0x7d, 0x7, 0xef, 0x3a, 0x5c, 0x7c, 0xa4, - 0x7e, 0xa5, 0xef, 0xac, 0x8, 0xb6, 0x6a, 0x22, 0x65, 0xf4}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc7, 0xc8, 0x7e}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1f, 0x39, 0x37, 0xb2, 0xd0, 0xd, 0x23, 0x4e, 0xa, 0x96, - 0x6e, 0x6d, 0x2b, 0x36, 0xd5, 0x0, 0xab, 0xfc, 0x9}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x89, 0x3, 0xc5, 0xd9, 0x0, 0xdf, 0xe8, 0xcf, 0xfd, 0xca, 0x90, 0x56, 0x23, - 0x9e, 0x6b, 0x9c, 0x44, 0x53, 0x45, 0x32, 0x91, 0x5, 0x9e, 0xea, 0x85, 0x96}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x23, 0x95, 0xde, 0x3c, 0x3, 0x51, 0xb6, 0x2c, 0xbc, 0x24, 0x59, - 0x7e, 0x28, 0xb2, 0x7c, 0x54, 0xb0, 0x5f, 0x91, 0x97, 0x27}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xaf, 0x5, 0x1d, 0xf5, 0xf2, 0x29, 0x99, 0x12, 0x81, - 0xbe, 0x14, 0xa, 0xeb, 0x81, 0xa0, 0x20, 0xbe, 0xe9}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x44, 0x4a, 0xec, 0xf7, 0x5c, 0x66, 0x70, 0xf0, - 0x83, 0xd5, 0x10, 0x50, 0x85, 0x18, 0x85}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xbc, 0x6e, 0xf8, 0x2d, 0xc1, 0xf8, 0x8a, 0x93, 0xf, - 0xb5, 0x9, 0x6f, 0x89, 0x9, 0x94, 0xe6, 0xe9, 0x3d}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x9f, 0xfa, 0xde, 0xe2, 0x42, 0x92, 0x7a, 0x7b, 0xa, 0x1d, 0xa3, 0x51, - 0x3e, 0xd4, 0xd1, 0x62, 0x8c, 0xc, 0x5e, 0x7c, 0xe1, 0x21, 0x17, 0x53}; - uint8_t bytesprops1[] = {0xa7, 0xa5, 0xec, 0xf2, 0xdc, 0x0, 0x21, 0xf3, 0xef, 0xec, 0xf9, 0x28, 0x35, 0x30, 0x8f}; - uint8_t bytesprops2[] = {0x21, 0x56, 0x88, 0xe3, 0xc9, 0x52, 0x2}; - uint8_t bytesprops3[] = {0xcc, 0xdc, 0x5a, 0xc7, 0x41, 0xd1, 0xf2, 0x34, 0x89, 0x17, 0xb6, - 0x72, 0xa, 0x51, 0x89, 0xea, 0x50, 0xef, 0xae, 0x5e, 0x26, 0x16}; - uint8_t bytesprops4[] = {0x99, 0x2b, 0x16, 0xa4, 0x8f, 0xca, 0xcb, 0xf1, 0xb2, 0x3, 0x2f, - 0x81, 0xb3, 0xf, 0xa5, 0x3a, 0x4c, 0xbb, 0xf9, 0x61, 0x58, 0x4e}; - uint8_t bytesprops5[] = {0x51, 0x44, 0x35, 0xac, 0x65, 0xe2, 0x69, 0xe2, 0x46, 0x83, 0x4a, 0xbc, 0x88}; - uint8_t bytesprops6[] = {0x19, 0xa0, 0x18, 0x83, 0x20, 0xe5, 0xa2, 0x8b, 0x4c, 0x46, 0xdb, 0x9f, 0xa7, 0x70, - 0x2c, 0xd9, 0x62, 0xb0, 0xd0, 0xf2, 0x59, 0xc7, 0x49, 0x1f, 0xf6, 0x28, 0xa9}; - uint8_t bytesprops7[] = {0x1d, 0x41, 0x94, 0xbd, 0x8, 0xcb, 0x9d, 0x80, 0x54, - 0x8e, 0x25, 0x4, 0x60, 0xb3, 0x7b, 0x4e, 0x97, 0x6c}; - uint8_t bytesprops8[] = {0xff, 0xf3, 0xdc, 0x5, 0xef, 0xc6, 0xc2, 0x64, 0x9f, 0x91, - 0xab, 0x5, 0xc, 0x95, 0x19, 0x48, 0xb0, 0x67, 0xeb}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23274}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1962}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31104}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8247}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18795}}, - }; - - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 167, 9, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 3223 [("U#\128\166r\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\198l]6!\158\151\NUL\255\155|\156\254",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval -// 18865,PropRetainAvailable 202,PropTopicAlias 15710,PropResponseInformation -// "\238\&7\201Y\185y\211Ij\205\207\ACK\162\ETX",PropReasonString -// "!c\200DX\145\208I\215\184\&1\174\131\234\202\132\159\164\222\159q&\189<\203\145",PropReceiveMaximum -// 29462,PropMaximumQoS 133,PropMessageExpiryInterval 13197,PropReceiveMaximum 15894,PropSubscriptionIdentifierAvailable -// 133,PropTopicAlias 18101,PropMessageExpiryInterval 16249,PropSessionExpiryInterval 17732,PropResponseInformation -// ";\155\231\222\240\216\162M\195\&3x\ACKxX\STXm",PropSessionExpiryInterval 3716,PropMessageExpiryInterval -// 31538,PropRetainAvailable 30,PropRequestResponseInformation 254,PropContentType -// "\208\GSp\244\&3\210sa{\134\SUB\204\129%\213\162\159\185['K5\146\251\173",PropRetainAvailable 147,PropCorrelationData -// "\185vv\211r;\240\137",PropRetainAvailable 46,PropTopicAlias 12882,PropWildcardSubscriptionAvailable -// 188,PropTopicAlias 15907,PropAuthenticationData "\167\141\SOuS\147\248k\STX\218X\189\203\&7$\242x\181\&0<\v\253\168\a -// ",PropMaximumPacketSize 8047] -TEST(Subscribe5QCTest, Encode76) { - uint8_t pkt[] = {0x82, 0xe6, 0x1, 0xc, 0x97, 0xc9, 0x1, 0x2, 0x0, 0x0, 0x49, 0xb1, 0x25, 0xca, 0x23, 0x3d, 0x5e, - 0x1a, 0x0, 0xe, 0xee, 0x37, 0xc9, 0x59, 0xb9, 0x79, 0xd3, 0x49, 0x6a, 0xcd, 0xcf, 0x6, 0xa2, 0x3, - 0x1f, 0x0, 0x1a, 0x21, 0x63, 0xc8, 0x44, 0x58, 0x91, 0xd0, 0x49, 0xd7, 0xb8, 0x31, 0xae, 0x83, 0xea, - 0xca, 0x84, 0x9f, 0xa4, 0xde, 0x9f, 0x71, 0x26, 0xbd, 0x3c, 0xcb, 0x91, 0x21, 0x73, 0x16, 0x24, 0x85, - 0x2, 0x0, 0x0, 0x33, 0x8d, 0x21, 0x3e, 0x16, 0x29, 0x85, 0x23, 0x46, 0xb5, 0x2, 0x0, 0x0, 0x3f, - 0x79, 0x11, 0x0, 0x0, 0x45, 0x44, 0x1a, 0x0, 0x10, 0x3b, 0x9b, 0xe7, 0xde, 0xf0, 0xd8, 0xa2, 0x4d, - 0xc3, 0x33, 0x78, 0x6, 0x78, 0x58, 0x2, 0x6d, 0x11, 0x0, 0x0, 0xe, 0x84, 0x2, 0x0, 0x0, 0x7b, - 0x32, 0x25, 0x1e, 0x19, 0xfe, 0x3, 0x0, 0x19, 0xd0, 0x1d, 0x70, 0xf4, 0x33, 0xd2, 0x73, 0x61, 0x7b, - 0x86, 0x1a, 0xcc, 0x81, 0x25, 0xd5, 0xa2, 0x9f, 0xb9, 0x5b, 0x27, 0x4b, 0x35, 0x92, 0xfb, 0xad, 0x25, - 0x93, 0x9, 0x0, 0x8, 0xb9, 0x76, 0x76, 0xd3, 0x72, 0x3b, 0xf0, 0x89, 0x25, 0x2e, 0x23, 0x32, 0x52, - 0x28, 0xbc, 0x23, 0x3e, 0x23, 0x16, 0x0, 0x19, 0xa7, 0x8d, 0xe, 0x75, 0x53, 0x93, 0xf8, 0x6b, 0x2, - 0xda, 0x58, 0xbd, 0xcb, 0x37, 0x24, 0xf2, 0x78, 0xb5, 0x30, 0x3c, 0xb, 0xfd, 0xa8, 0x7, 0x20, 0x27, - 0x0, 0x0, 0x1f, 0x6f, 0x0, 0x6, 0x55, 0x23, 0x80, 0xa6, 0x72, 0xd9, 0x0, 0x0, 0xd, 0xc6, 0x6c, - 0x5d, 0x36, 0x21, 0x9e, 0x97, 0x0, 0xff, 0x9b, 0x7c, 0x9c, 0xfe, 0x1}; - - uint8_t buf[243] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x55, 0x23, 0x80, 0xa6, 0x72, 0xd9}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc6, 0x6c, 0x5d, 0x36, 0x21, 0x9e, 0x97, 0x0, 0xff, 0x9b, 0x7c, 0x9c, 0xfe}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xee, 0x37, 0xc9, 0x59, 0xb9, 0x79, 0xd3, 0x49, 0x6a, 0xcd, 0xcf, 0x6, 0xa2, 0x3}; - uint8_t bytesprops1[] = {0x21, 0x63, 0xc8, 0x44, 0x58, 0x91, 0xd0, 0x49, 0xd7, 0xb8, 0x31, 0xae, 0x83, - 0xea, 0xca, 0x84, 0x9f, 0xa4, 0xde, 0x9f, 0x71, 0x26, 0xbd, 0x3c, 0xcb, 0x91}; - uint8_t bytesprops2[] = {0x3b, 0x9b, 0xe7, 0xde, 0xf0, 0xd8, 0xa2, 0x4d, - 0xc3, 0x33, 0x78, 0x6, 0x78, 0x58, 0x2, 0x6d}; - uint8_t bytesprops3[] = {0xd0, 0x1d, 0x70, 0xf4, 0x33, 0xd2, 0x73, 0x61, 0x7b, 0x86, 0x1a, 0xcc, 0x81, - 0x25, 0xd5, 0xa2, 0x9f, 0xb9, 0x5b, 0x27, 0x4b, 0x35, 0x92, 0xfb, 0xad}; - uint8_t bytesprops4[] = {0xb9, 0x76, 0x76, 0xd3, 0x72, 0x3b, 0xf0, 0x89}; - uint8_t bytesprops5[] = {0xa7, 0x8d, 0xe, 0x75, 0x53, 0x93, 0xf8, 0x6b, 0x2, 0xda, 0x58, 0xbd, 0xcb, - 0x37, 0x24, 0xf2, 0x78, 0xb5, 0x30, 0x3c, 0xb, 0xfd, 0xa8, 0x7, 0x20}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18865}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15710}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29462}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13197}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15894}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18101}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16249}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17732}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3716}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31538}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12882}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15907}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8047}}, - }; - - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3223, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 1845 [("\196\128\&4\163O\255",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("f\255\128\199\ETXD\164B\184\249 \251\243\158TM\242\130",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("d@V!\249\199\168\166\194\241\244\243y\202\222\203\132\164\184\145\196\164",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SYN\197\232MQ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\242W\198\204\146t\ESC\192'\177\DC49>\166`{\152Q\247v\213\133\EM \160~@",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\229\252\136\170\181]\155\129\151\157\222\219P\163\177\130\146F\205",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\234\196[a\EOTi\137\214",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\232\&4\187\230\144aj3\ETB\EM\162%t\228",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\STXv\213",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\"=\211\194\176",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropTopicAlias -// 21229,PropMessageExpiryInterval 5033,PropWillDelayInterval 9775,PropWildcardSubscriptionAvailable -// 227,PropUserProperty "\162\141\132\193:%{\193\EM\199\159[" -// "\144\172\ACK@5\206\203\141\f\218:\223.zN\176\226I;\150",PropMaximumQoS 255,PropServerReference -// "\151\DEL|\194\172\180o\208\163o\176m\250\ESC\159\223\188&.\173\144\v\233\179\210\224",PropSessionExpiryInterval -// 14355,PropWildcardSubscriptionAvailable 15,PropAssignedClientIdentifier -// "\DC2<\FSy\144\SYN\170\216\159\140H\151s\195Z6\220W\215H,\SUB\137",PropRetainAvailable -// 162,PropRequestProblemInformation 225,PropResponseInformation -// "{\197{\170\210\200\204\&8^\144\154\195K\EOT\209z\231\243\131\222k\185\171\221b\170^\159\195",PropTopicAlias -// 6806,PropResponseTopic "\US9\206\131\NUL\145\DC1\233\226\&7\FS\135",PropContentType -// "D",PropSharedSubscriptionAvailable 205,PropMessageExpiryInterval 31351,PropWillDelayInterval -// 12650,PropMessageExpiryInterval 30600,PropSubscriptionIdentifier 30,PropAuthenticationData -// "D\188\255kP\167x\228\DC3v\164\246`\144=\203\152R\242"] -TEST(Subscribe5QCTest, Encode77) { - uint8_t pkt[] = { - 0x82, 0xfb, 0x2, 0x7, 0x35, 0xd7, 0x1, 0x23, 0x52, 0xed, 0x2, 0x0, 0x0, 0x13, 0xa9, 0x18, 0x0, 0x0, 0x26, - 0x2f, 0x28, 0xe3, 0x26, 0x0, 0xc, 0xa2, 0x8d, 0x84, 0xc1, 0x3a, 0x25, 0x7b, 0xc1, 0x19, 0xc7, 0x9f, 0x5b, 0x0, - 0x14, 0x90, 0xac, 0x6, 0x40, 0x35, 0xce, 0xcb, 0x8d, 0xc, 0xda, 0x3a, 0xdf, 0x2e, 0x7a, 0x4e, 0xb0, 0xe2, 0x49, - 0x3b, 0x96, 0x24, 0xff, 0x1c, 0x0, 0x1a, 0x97, 0x7f, 0x7c, 0xc2, 0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 0x64, 0x40, 0x56, 0x21, 0xf9, 0xc7, 0xa8, 0xa6, 0xc2, 0xf1, 0xf4, 0xf3, - 0x79, 0xca, 0xde, 0xcb, 0x84, 0xa4, 0xb8, 0x91, 0xc4, 0xa4, 0x0, 0x0, 0x5, 0x16, 0xc5, 0xe8, 0x4d, 0x51, 0x1, - 0x0, 0x1b, 0xf2, 0x57, 0xc6, 0xcc, 0x92, 0x74, 0x1b, 0xc0, 0x27, 0xb1, 0x14, 0x39, 0x3e, 0xa6, 0x60, 0x7b, 0x98, - 0x51, 0xf7, 0x76, 0xd5, 0x85, 0x19, 0x20, 0xa0, 0x7e, 0x40, 0x0, 0x0, 0x13, 0xe5, 0xfc, 0x88, 0xaa, 0xb5, 0x5d, - 0x9b, 0x81, 0x97, 0x9d, 0xde, 0xdb, 0x50, 0xa3, 0xb1, 0x82, 0x92, 0x46, 0xcd, 0x1, 0x0, 0x0, 0x0, 0x0, 0x8, - 0xea, 0xc4, 0x5b, 0x61, 0x4, 0x69, 0x89, 0xd6, 0x2, 0x0, 0xe, 0xe8, 0x34, 0xbb, 0xe6, 0x90, 0x61, 0x6a, 0x33, - 0x17, 0x19, 0xa2, 0x25, 0x74, 0xe4, 0x0, 0x0, 0x3, 0x2, 0x76, 0xd5, 0x2, 0x0, 0x5, 0x22, 0x3d, 0xd3, 0xc2, - 0xb0, 0x2}; - - uint8_t buf[392] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xc4, 0x80, 0x34, 0xa3, 0x4f, 0xff}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x66, 0xff, 0x80, 0xc7, 0x3, 0x44, 0xa4, 0x42, 0xb8, - 0xf9, 0x20, 0xfb, 0xf3, 0x9e, 0x54, 0x4d, 0xf2, 0x82}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x64, 0x40, 0x56, 0x21, 0xf9, 0xc7, 0xa8, 0xa6, 0xc2, 0xf1, 0xf4, - 0xf3, 0x79, 0xca, 0xde, 0xcb, 0x84, 0xa4, 0xb8, 0x91, 0xc4, 0xa4}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x16, 0xc5, 0xe8, 0x4d, 0x51}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xf2, 0x57, 0xc6, 0xcc, 0x92, 0x74, 0x1b, 0xc0, 0x27, 0xb1, 0x14, 0x39, 0x3e, 0xa6, - 0x60, 0x7b, 0x98, 0x51, 0xf7, 0x76, 0xd5, 0x85, 0x19, 0x20, 0xa0, 0x7e, 0x40}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe5, 0xfc, 0x88, 0xaa, 0xb5, 0x5d, 0x9b, 0x81, 0x97, 0x9d, - 0xde, 0xdb, 0x50, 0xa3, 0xb1, 0x82, 0x92, 0x46, 0xcd}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xea, 0xc4, 0x5b, 0x61, 0x4, 0x69, 0x89, 0xd6}; - lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe8, 0x34, 0xbb, 0xe6, 0x90, 0x61, 0x6a, - 0x33, 0x17, 0x19, 0xa2, 0x25, 0x74, 0xe4}; - lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x2, 0x76, 0xd5}; - lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x22, 0x3d, 0xd3, 0xc2, 0xb0}; - lwmqtt_string_t topic_filter_s10 = {5, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops1[] = {0x90, 0xac, 0x6, 0x40, 0x35, 0xce, 0xcb, 0x8d, 0xc, 0xda, - 0x3a, 0xdf, 0x2e, 0x7a, 0x4e, 0xb0, 0xe2, 0x49, 0x3b, 0x96}; - uint8_t bytesprops0[] = {0xa2, 0x8d, 0x84, 0xc1, 0x3a, 0x25, 0x7b, 0xc1, 0x19, 0xc7, 0x9f, 0x5b}; - uint8_t bytesprops2[] = {0x97, 0x7f, 0x7c, 0xc2, 0xac, 0xb4, 0x6f, 0xd0, 0xa3, 0x6f, 0xb0, 0x6d, 0xfa, - 0x1b, 0x9f, 0xdf, 0xbc, 0x26, 0x2e, 0xad, 0x90, 0xb, 0xe9, 0xb3, 0xd2, 0xe0}; - uint8_t bytesprops3[] = {0x12, 0x3c, 0x1c, 0x79, 0x90, 0x16, 0xaa, 0xd8, 0x9f, 0x8c, 0x48, 0x97, - 0x73, 0xc3, 0x5a, 0x36, 0xdc, 0x57, 0xd7, 0x48, 0x2c, 0x1a, 0x89}; - uint8_t bytesprops4[] = {0x7b, 0xc5, 0x7b, 0xaa, 0xd2, 0xc8, 0xcc, 0x38, 0x5e, 0x90, 0x9a, 0xc3, 0x4b, 0x4, 0xd1, - 0x7a, 0xe7, 0xf3, 0x83, 0xde, 0x6b, 0xb9, 0xab, 0xdd, 0x62, 0xaa, 0x5e, 0x9f, 0xc3}; - uint8_t bytesprops5[] = {0x1f, 0x39, 0xce, 0x83, 0x0, 0x91, 0x11, 0xe9, 0xe2, 0x37, 0x1c, 0x87}; - uint8_t bytesprops6[] = {0x44}; - uint8_t bytesprops7[] = {0x44, 0xbc, 0xff, 0x6b, 0x50, 0xa7, 0x78, 0xe4, 0x13, 0x76, - 0xa4, 0xf6, 0x60, 0x90, 0x3d, 0xcb, 0x98, 0x52, 0xf2}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21229}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5033}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9775}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14355}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6806}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31351}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12650}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30600}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops7}}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1845, 11, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 12377 [("\156\222Z\207\145\DC1\171\133j\149\210Dr\137\&1\130\219\182 2H\210\203s",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty -// "\DC4" "u\208\RS\233\"\219\SUB\211{G\250\142\a|\SO\206\221=\166\a\b.\USG\234",PropTopicAlias -// 28621,PropSharedSubscriptionAvailable 82,PropRetainAvailable 188,PropWildcardSubscriptionAvailable 205,PropMaximumQoS -// 207,PropSubscriptionIdentifierAvailable 249,PropMessageExpiryInterval 21158,PropSessionExpiryInterval -// 21268,PropSessionExpiryInterval 31778,PropAuthenticationMethod -// "\157\&4\177\242\134\GS\ESC\187R\131y3\255.\STX",PropAssignedClientIdentifier -// "\"\183\DC1\222\220\183b\193\198m\v\211\&7\205\205\225\128\GS",PropTopicAlias 11340,PropRequestProblemInformation -// 134,PropMessageExpiryInterval 16425] -TEST(Subscribe5QCTest, Encode78) { - uint8_t pkt[] = {0x82, 0x8a, 0x1, 0x30, 0x59, 0x6c, 0x26, 0x0, 0x1, 0x14, 0x0, 0x19, 0x75, 0xd0, 0x1e, 0xe9, - 0x22, 0xdb, 0x1a, 0xd3, 0x7b, 0x47, 0xfa, 0x8e, 0x7, 0x7c, 0xe, 0xce, 0xdd, 0x3d, 0xa6, 0x7, - 0x8, 0x2e, 0x1f, 0x47, 0xea, 0x23, 0x6f, 0xcd, 0x2a, 0x52, 0x25, 0xbc, 0x28, 0xcd, 0x24, 0xcf, - 0x29, 0xf9, 0x2, 0x0, 0x0, 0x52, 0xa6, 0x11, 0x0, 0x0, 0x53, 0x14, 0x11, 0x0, 0x0, 0x7c, - 0x22, 0x15, 0x0, 0xf, 0x9d, 0x34, 0xb1, 0xf2, 0x86, 0x1d, 0x1b, 0xbb, 0x52, 0x83, 0x79, 0x33, - 0xff, 0x2e, 0x2, 0x12, 0x0, 0x12, 0x22, 0xb7, 0x11, 0xde, 0xdc, 0xb7, 0x62, 0xc1, 0xc6, 0x6d, - 0xb, 0xd3, 0x37, 0xcd, 0xcd, 0xe1, 0x80, 0x1d, 0x23, 0x2c, 0x4c, 0x17, 0x86, 0x2, 0x0, 0x0, - 0x40, 0x29, 0x0, 0x18, 0x9c, 0xde, 0x5a, 0xcf, 0x91, 0x11, 0xab, 0x85, 0x6a, 0x95, 0xd2, 0x44, - 0x72, 0x89, 0x31, 0x82, 0xdb, 0xb6, 0x20, 0x32, 0x48, 0xd2, 0xcb, 0x73, 0x1}; - - uint8_t buf[151] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x9c, 0xde, 0x5a, 0xcf, 0x91, 0x11, 0xab, 0x85, 0x6a, 0x95, 0xd2, 0x44, - 0x72, 0x89, 0x31, 0x82, 0xdb, 0xb6, 0x20, 0x32, 0x48, 0xd2, 0xcb, 0x73}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - uint8_t bytesprops1[] = {0x75, 0xd0, 0x1e, 0xe9, 0x22, 0xdb, 0x1a, 0xd3, 0x7b, 0x47, 0xfa, 0x8e, 0x7, - 0x7c, 0xe, 0xce, 0xdd, 0x3d, 0xa6, 0x7, 0x8, 0x2e, 0x1f, 0x47, 0xea}; - uint8_t bytesprops0[] = {0x14}; - uint8_t bytesprops2[] = {0x9d, 0x34, 0xb1, 0xf2, 0x86, 0x1d, 0x1b, 0xbb, 0x52, 0x83, 0x79, 0x33, 0xff, 0x2e, 0x2}; - uint8_t bytesprops3[] = {0x22, 0xb7, 0x11, 0xde, 0xdc, 0xb7, 0x62, 0xc1, 0xc6, - 0x6d, 0xb, 0xd3, 0x37, 0xcd, 0xcd, 0xe1, 0x80, 0x1d}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28621}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21158}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21268}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31778}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11340}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16425}}, - }; - - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12377, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 290 [("-\CAN\FSe\144\STXP\243wu\191%\250\176\&5\250\204V\239\137}",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\128&U[\222\&1,\232\&9\137\194\vD\146\155m\DLE\213\249\229d\FSI+\v]",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\232g?\215\156\STXD\132\NUL\197\ACK(\234:\DC1\153C\148\b/\180^",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\176\160\178:&\NUL\182\\\173\RS\138\144\138@\148U\ENQA>\191\&1t",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),(".\162!\217\216*\155\205\236\RSc\tEWe2\159'\216\149\193\235\DC1[\200\188\233\230\215",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\187\152j\248\219\&2\152\&3\SO\GS\135",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\176\144m\168\226",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\227\202\180@6a",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("|\129\183e\162\160X\243e\238E\183\184\128SY\157\EM6\253",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropTopicAlias -// 24863,PropWildcardSubscriptionAvailable 239,PropUserProperty "{Z" -// "\186\233\227\247%\136R",PropWildcardSubscriptionAvailable 225,PropSessionExpiryInterval 19459,PropCorrelationData -// "\v\132\148-\145\ETB\191\228'Y\230\150\207q\218\140",PropContentType "",PropAssignedClientIdentifier -// "\a\200\136\148\t\162\222q\192",PropReasonString -// "\128^\"\EOT\DC4\201Z\SOH$\172\218\249G\147\&5>",PropTopicAliasMaximum 20513,PropContentType -// "\216r\EOTN\213\231\185\146\197\a\193k\ETB\170\246\227\174JI\192\FS\230\228v'\193\128\209=\144",PropServerReference -// "m@:"] -TEST(Subscribe5QCTest, Encode79) { - uint8_t pkt[] = { - 0x82, 0xb9, 0x2, 0x1, 0x22, 0x79, 0x23, 0x61, 0x1f, 0x28, 0xef, 0x26, 0x0, 0x2, 0x7b, 0x5a, 0x0, 0x7, 0xba, - 0xe9, 0xe3, 0xf7, 0x25, 0x88, 0x52, 0x28, 0xe1, 0x11, 0x0, 0x0, 0x4c, 0x3, 0x9, 0x0, 0x10, 0xb, 0x84, 0x94, - 0x2d, 0x91, 0x17, 0xbf, 0xe4, 0x27, 0x59, 0xe6, 0x96, 0xcf, 0x71, 0xda, 0x8c, 0x3, 0x0, 0x0, 0x12, 0x0, 0x9, - 0x7, 0xc8, 0x88, 0x94, 0x9, 0xa2, 0xde, 0x71, 0xc0, 0x1f, 0x0, 0x10, 0x80, 0x5e, 0x22, 0x4, 0x14, 0xc9, 0x5a, - 0x1, 0x24, 0xac, 0xda, 0xf9, 0x47, 0x93, 0x35, 0x3e, 0x22, 0x50, 0x21, 0x3, 0x0, 0x1e, 0xd8, 0x72, 0x4, 0x4e, - 0xd5, 0xe7, 0xb9, 0x92, 0xc5, 0x7, 0xc1, 0x6b, 0x17, 0xaa, 0xf6, 0xe3, 0xae, 0x4a, 0x49, 0xc0, 0x1c, 0xe6, 0xe4, - 0x76, 0x27, 0xc1, 0x80, 0xd1, 0x3d, 0x90, 0x1c, 0x0, 0x3, 0x6d, 0x40, 0x3a, 0x0, 0x15, 0x2d, 0x18, 0x1c, 0x65, - 0x90, 0x2, 0x50, 0xf3, 0x77, 0x75, 0xbf, 0x25, 0xfa, 0xb0, 0x35, 0xfa, 0xcc, 0x56, 0xef, 0x89, 0x7d, 0x1, 0x0, - 0x1a, 0x80, 0x26, 0x55, 0x5b, 0xde, 0x31, 0x2c, 0xe8, 0x39, 0x89, 0xc2, 0xb, 0x44, 0x92, 0x9b, 0x6d, 0x10, 0xd5, - 0xf9, 0xe5, 0x64, 0x1c, 0x49, 0x2b, 0xb, 0x5d, 0x0, 0x0, 0x16, 0xe8, 0x67, 0x3f, 0xd7, 0x9c, 0x2, 0x44, 0x84, - 0x0, 0xc5, 0x6, 0x28, 0xea, 0x3a, 0x11, 0x99, 0x43, 0x94, 0x8, 0x2f, 0xb4, 0x5e, 0x1, 0x0, 0x16, 0xb0, 0xa0, - 0xb2, 0x3a, 0x26, 0x0, 0xb6, 0x5c, 0xad, 0x1e, 0x8a, 0x90, 0x8a, 0x40, 0x94, 0x55, 0x5, 0x41, 0x3e, 0xbf, 0x31, - 0x74, 0x1, 0x0, 0x1d, 0x2e, 0xa2, 0x21, 0xd9, 0xd8, 0x2a, 0x9b, 0xcd, 0xec, 0x1e, 0x63, 0x9, 0x45, 0x57, 0x65, - 0x32, 0x9f, 0x27, 0xd8, 0x95, 0xc1, 0xeb, 0x11, 0x5b, 0xc8, 0xbc, 0xe9, 0xe6, 0xd7, 0x2, 0x0, 0xb, 0xbb, 0x98, - 0x6a, 0xf8, 0xdb, 0x32, 0x98, 0x33, 0xe, 0x1d, 0x87, 0x2, 0x0, 0x5, 0xb0, 0x90, 0x6d, 0xa8, 0xe2, 0x1, 0x0, - 0x6, 0xe3, 0xca, 0xb4, 0x40, 0x36, 0x61, 0x2, 0x0, 0x14, 0x7c, 0x81, 0xb7, 0x65, 0xa2, 0xa0, 0x58, 0xf3, 0x65, - 0xee, 0x45, 0xb7, 0xb8, 0x80, 0x53, 0x59, 0x9d, 0x19, 0x36, 0xfd, 0x1}; - - uint8_t buf[326] = {0}; - - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x2d, 0x18, 0x1c, 0x65, 0x90, 0x2, 0x50, 0xf3, 0x77, 0x75, 0xbf, - 0x25, 0xfa, 0xb0, 0x35, 0xfa, 0xcc, 0x56, 0xef, 0x89, 0x7d}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x80, 0x26, 0x55, 0x5b, 0xde, 0x31, 0x2c, 0xe8, 0x39, 0x89, 0xc2, 0xb, 0x44, - 0x92, 0x9b, 0x6d, 0x10, 0xd5, 0xf9, 0xe5, 0x64, 0x1c, 0x49, 0x2b, 0xb, 0x5d}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe8, 0x67, 0x3f, 0xd7, 0x9c, 0x2, 0x44, 0x84, 0x0, 0xc5, 0x6, - 0x28, 0xea, 0x3a, 0x11, 0x99, 0x43, 0x94, 0x8, 0x2f, 0xb4, 0x5e}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb0, 0xa0, 0xb2, 0x3a, 0x26, 0x0, 0xb6, 0x5c, 0xad, 0x1e, 0x8a, - 0x90, 0x8a, 0x40, 0x94, 0x55, 0x5, 0x41, 0x3e, 0xbf, 0x31, 0x74}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2e, 0xa2, 0x21, 0xd9, 0xd8, 0x2a, 0x9b, 0xcd, 0xec, 0x1e, - 0x63, 0x9, 0x45, 0x57, 0x65, 0x32, 0x9f, 0x27, 0xd8, 0x95, - 0xc1, 0xeb, 0x11, 0x5b, 0xc8, 0xbc, 0xe9, 0xe6, 0xd7}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xbb, 0x98, 0x6a, 0xf8, 0xdb, 0x32, 0x98, 0x33, 0xe, 0x1d, 0x87}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb0, 0x90, 0x6d, 0xa8, 0xe2}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe3, 0xca, 0xb4, 0x40, 0x36, 0x61}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x7c, 0x81, 0xb7, 0x65, 0xa2, 0xa0, 0x58, 0xf3, 0x65, 0xee, - 0x45, 0xb7, 0xb8, 0x80, 0x53, 0x59, 0x9d, 0x19, 0x36, 0xfd}; - lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops1[] = {0xba, 0xe9, 0xe3, 0xf7, 0x25, 0x88, 0x52}; - uint8_t bytesprops0[] = {0x7b, 0x5a}; - uint8_t bytesprops2[] = {0xb, 0x84, 0x94, 0x2d, 0x91, 0x17, 0xbf, 0xe4, - 0x27, 0x59, 0xe6, 0x96, 0xcf, 0x71, 0xda, 0x8c}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x7, 0xc8, 0x88, 0x94, 0x9, 0xa2, 0xde, 0x71, 0xc0}; - uint8_t bytesprops5[] = {0x80, 0x5e, 0x22, 0x4, 0x14, 0xc9, 0x5a, 0x1, - 0x24, 0xac, 0xda, 0xf9, 0x47, 0x93, 0x35, 0x3e}; - uint8_t bytesprops6[] = {0xd8, 0x72, 0x4, 0x4e, 0xd5, 0xe7, 0xb9, 0x92, 0xc5, 0x7, 0xc1, 0x6b, 0x17, 0xaa, 0xf6, - 0xe3, 0xae, 0x4a, 0x49, 0xc0, 0x1c, 0xe6, 0xe4, 0x76, 0x27, 0xc1, 0x80, 0xd1, 0x3d, 0x90}; - uint8_t bytesprops7[] = {0x6d, 0x40, 0x3a}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24863}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops0}, .v = {7, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19459}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20513}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops7}}}, - }; - - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 290, 9, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 28088 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),(":\193@\178\186\219\136\180",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\254\238]\245\184?\239",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("W'\132<\DC3\nUBMC\159\172b\NUL\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [PropRequestProblemInformation 165,PropUserProperty -// "\242N\RS\214\&9\199\245ZQ" "",PropServerReference "\235\207Mm\ETB",PropAuthenticationData -// "\131X\147\FSD\246",PropServerReference -// "\219\149tsY\SI\152#5\DC3\225\f\255\233\SO\SOH\205\182\163$\255\223\224\246\SI\150\tOE\226",PropMessageExpiryInterval -// 28313,PropSubscriptionIdentifierAvailable 11,PropServerKeepAlive 2536,PropSubscriptionIdentifierAvailable -// 53,PropSubscriptionIdentifierAvailable 117,PropSubscriptionIdentifier 23,PropCorrelationData -// "/\164\vQ\174\ACK",PropRequestResponseInformation 202,PropSubscriptionIdentifierAvailable 246,PropMaximumQoS -// 136,PropMaximumQoS 177,PropAuthenticationMethod "\215\v\NUL5\249\n",PropTopicAliasMaximum -// 24195,PropSessionExpiryInterval 19137,PropSharedSubscriptionAvailable 204,PropReceiveMaximum -// 12776,PropAuthenticationData "\160KZ\159r\143R\136\226\239vy\SYN\DC4\FS\204\SOH\228"] -TEST(Subscribe5QCTest, Encode80) { - uint8_t pkt[] = {0x82, 0xbc, 0x1, 0x6d, 0xb8, 0x8e, 0x1, 0x17, 0xa5, 0x26, 0x0, 0x9, 0xf2, 0x4e, 0x1e, 0xd6, - 0x39, 0xc7, 0xf5, 0x5a, 0x51, 0x0, 0x0, 0x1c, 0x0, 0x5, 0xeb, 0xcf, 0x4d, 0x6d, 0x17, 0x16, - 0x0, 0x6, 0x83, 0x58, 0x93, 0x1c, 0x44, 0xf6, 0x1c, 0x0, 0x1e, 0xdb, 0x95, 0x74, 0x73, 0x59, - 0xf, 0x98, 0x23, 0x35, 0x13, 0xe1, 0xc, 0xff, 0xe9, 0xe, 0x1, 0xcd, 0xb6, 0xa3, 0x24, 0xff, - 0xdf, 0xe0, 0xf6, 0xf, 0x96, 0x9, 0x4f, 0x45, 0xe2, 0x2, 0x0, 0x0, 0x6e, 0x99, 0x29, 0xb, - 0x13, 0x9, 0xe8, 0x29, 0x35, 0x29, 0x75, 0xb, 0x17, 0x9, 0x0, 0x6, 0x2f, 0xa4, 0xb, 0x51, - 0xae, 0x6, 0x19, 0xca, 0x29, 0xf6, 0x24, 0x88, 0x24, 0xb1, 0x15, 0x0, 0x6, 0xd7, 0xb, 0x0, - 0x35, 0xf9, 0xa, 0x22, 0x5e, 0x83, 0x11, 0x0, 0x0, 0x4a, 0xc1, 0x2a, 0xcc, 0x21, 0x31, 0xe8, - 0x16, 0x0, 0x12, 0xa0, 0x4b, 0x5a, 0x9f, 0x72, 0x8f, 0x52, 0x88, 0xe2, 0xef, 0x76, 0x79, 0x16, - 0x14, 0x1c, 0xcc, 0x1, 0xe4, 0x0, 0x0, 0x2, 0x0, 0x8, 0x3a, 0xc1, 0x40, 0xb2, 0xba, 0xdb, - 0x88, 0xb4, 0x2, 0x0, 0x7, 0xfe, 0xee, 0x5d, 0xf5, 0xb8, 0x3f, 0xef, 0x0, 0x0, 0xf, 0x57, - 0x27, 0x84, 0x3c, 0x13, 0xa, 0x55, 0x42, 0x4d, 0x43, 0x9f, 0xac, 0x62, 0x0, 0xb9, 0x1}; - - uint8_t buf[201] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3a, 0xc1, 0x40, 0xb2, 0xba, 0xdb, 0x88, 0xb4}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfe, 0xee, 0x5d, 0xf5, 0xb8, 0x3f, 0xef}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x57, 0x27, 0x84, 0x3c, 0x13, 0xa, 0x55, 0x42, - 0x4d, 0x43, 0x9f, 0xac, 0x62, 0x0, 0xb9}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops0[] = {0xf2, 0x4e, 0x1e, 0xd6, 0x39, 0xc7, 0xf5, 0x5a, 0x51}; - uint8_t bytesprops2[] = {0xeb, 0xcf, 0x4d, 0x6d, 0x17}; - uint8_t bytesprops3[] = {0x83, 0x58, 0x93, 0x1c, 0x44, 0xf6}; - uint8_t bytesprops4[] = {0xdb, 0x95, 0x74, 0x73, 0x59, 0xf, 0x98, 0x23, 0x35, 0x13, 0xe1, 0xc, 0xff, 0xe9, 0xe, - 0x1, 0xcd, 0xb6, 0xa3, 0x24, 0xff, 0xdf, 0xe0, 0xf6, 0xf, 0x96, 0x9, 0x4f, 0x45, 0xe2}; - uint8_t bytesprops5[] = {0x2f, 0xa4, 0xb, 0x51, 0xae, 0x6}; - uint8_t bytesprops6[] = {0xd7, 0xb, 0x0, 0x35, 0xf9, 0xa}; - uint8_t bytesprops7[] = {0xa0, 0x4b, 0x5a, 0x9f, 0x72, 0x8f, 0x52, 0x88, 0xe2, - 0xef, 0x76, 0x79, 0x16, 0x14, 0x1c, 0xcc, 0x1, 0xe4}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28313}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2536}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24195}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19137}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12776}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops7}}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28088, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 4272 [("\":\159\"\202S\RS\ACK\244z5",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\242\235\190\253wC6\EMH\250\232\247\131u\172\a=\132\224\&9\192 \GS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\222!bl\193ck\202\&8K",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\162\190\167\211\FS\232\161;\130{%\ENQ\ACK\200\DC1\153\206\DC2\172b\193r\138",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("!",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropServerReference -// "g\GS,j\141\215\ETXY\202\154\226>\167\230\b9",PropPayloadFormatIndicator 19] -TEST(Subscribe5QCTest, Encode81) { - uint8_t pkt[] = {0x82, 0x6b, 0x10, 0xb0, 0x15, 0x1c, 0x0, 0x10, 0x67, 0x1d, 0x2c, 0x6a, 0x8d, 0xd7, 0x3, 0x59, - 0xca, 0x9a, 0xe2, 0x3e, 0xa7, 0xe6, 0x8, 0x39, 0x1, 0x13, 0x0, 0xb, 0x22, 0x3a, 0x9f, 0x22, - 0xca, 0x53, 0x1e, 0x6, 0xf4, 0x7a, 0x35, 0x2, 0x0, 0x17, 0xf2, 0xeb, 0xbe, 0xfd, 0x77, 0x43, - 0x36, 0x19, 0x48, 0xfa, 0xe8, 0xf7, 0x83, 0x75, 0xac, 0x7, 0x3d, 0x84, 0xe0, 0x39, 0xc0, 0x20, - 0x1d, 0x0, 0x0, 0xa, 0xde, 0x21, 0x62, 0x6c, 0xc1, 0x63, 0x6b, 0xca, 0x38, 0x4b, 0x0, 0x0, - 0x17, 0xa2, 0xbe, 0xa7, 0xd3, 0x1c, 0xe8, 0xa1, 0x3b, 0x82, 0x7b, 0x25, 0x5, 0x6, 0xc8, 0x11, - 0x99, 0xce, 0x12, 0xac, 0x62, 0xc1, 0x72, 0x8a, 0x2, 0x0, 0x1, 0x21, 0x2}; - - uint8_t buf[119] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x22, 0x3a, 0x9f, 0x22, 0xca, 0x53, 0x1e, 0x6, 0xf4, 0x7a, 0x35}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf2, 0xeb, 0xbe, 0xfd, 0x77, 0x43, 0x36, 0x19, 0x48, 0xfa, 0xe8, 0xf7, - 0x83, 0x75, 0xac, 0x7, 0x3d, 0x84, 0xe0, 0x39, 0xc0, 0x20, 0x1d}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xde, 0x21, 0x62, 0x6c, 0xc1, 0x63, 0x6b, 0xca, 0x38, 0x4b}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa2, 0xbe, 0xa7, 0xd3, 0x1c, 0xe8, 0xa1, 0x3b, 0x82, 0x7b, 0x25, 0x5, - 0x6, 0xc8, 0x11, 0x99, 0xce, 0x12, 0xac, 0x62, 0xc1, 0x72, 0x8a}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x21}; - lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x67, 0x1d, 0x2c, 0x6a, 0x8d, 0xd7, 0x3, 0x59, - 0xca, 0x9a, 0xe2, 0x3e, 0xa7, 0xe6, 0x8, 0x39}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 19}}, - }; - - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4272, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14420 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\193\143\248\171\SUBB\US\162U`\238\207",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\230\138\SIF\159~gN\227\241|",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("'\194\SUB\DC1\143+,\"\128\209\SUB\220\162\DC1\240\196\DC3\226\NUL\146\226:\STX\189J*~&\200",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("~3\195L&]\160\184\161\STX\168\181#Em!\205\252K\253",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("dI\177g\202Vp4k\ENQ\178\255z\171x\212\STX\224\RSS\FS\169\144\180\151\182\201",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("6\NAK\EOT\145\216\229B\EM\247\242\&1b\223\131\141",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropRequestProblemInformation -// 252,PropAssignedClientIdentifier -// "%B\255}\155\198\220`\225\SUB\199A\186\240\129\&2\DLE\236y\186",PropMessageExpiryInterval 25332] -TEST(Subscribe5QCTest, Encode82) { - uint8_t pkt[] = { - 0x82, 0xa8, 0x1, 0x38, 0x54, 0x1e, 0x17, 0xfc, 0x12, 0x0, 0x14, 0x25, 0x42, 0xff, 0x7d, 0x9b, 0xc6, 0xdc, 0x60, - 0xe1, 0x1a, 0xc7, 0x41, 0xba, 0xf0, 0x81, 0x32, 0x10, 0xec, 0x79, 0xba, 0x2, 0x0, 0x0, 0x62, 0xf4, 0x0, 0x0, - 0x0, 0x0, 0xc, 0xc1, 0x8f, 0xf8, 0xab, 0x1a, 0x42, 0x1f, 0xa2, 0x55, 0x60, 0xee, 0xcf, 0x0, 0x0, 0xb, 0xe6, - 0x8a, 0xf, 0x46, 0x9f, 0x7e, 0x67, 0x4e, 0xe3, 0xf1, 0x7c, 0x0, 0x0, 0x1d, 0x27, 0xc2, 0x1a, 0x11, 0x8f, 0x2b, - 0x2c, 0x22, 0x80, 0xd1, 0x1a, 0xdc, 0xa2, 0x11, 0xf0, 0xc4, 0x13, 0xe2, 0x0, 0x92, 0xe2, 0x3a, 0x2, 0xbd, 0x4a, - 0x2a, 0x7e, 0x26, 0xc8, 0x2, 0x0, 0x14, 0x7e, 0x33, 0xc3, 0x4c, 0x26, 0x5d, 0xa0, 0xb8, 0xa1, 0x2, 0xa8, 0xb5, - 0x23, 0x45, 0x6d, 0x21, 0xcd, 0xfc, 0x4b, 0xfd, 0x2, 0x0, 0x1b, 0x64, 0x49, 0xb1, 0x67, 0xca, 0x56, 0x70, 0x34, - 0x6b, 0x5, 0xb2, 0xff, 0x7a, 0xab, 0x78, 0xd4, 0x2, 0xe0, 0x1e, 0x53, 0x1c, 0xa9, 0x90, 0xb4, 0x97, 0xb6, 0xc9, - 0x2, 0x0, 0xf, 0x36, 0x15, 0x4, 0x91, 0xd8, 0xe5, 0x42, 0x19, 0xf7, 0xf2, 0x31, 0x62, 0xdf, 0x83, 0x8d, 0x2}; - - uint8_t buf[181] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc1, 0x8f, 0xf8, 0xab, 0x1a, 0x42, 0x1f, 0xa2, 0x55, 0x60, 0xee, 0xcf}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe6, 0x8a, 0xf, 0x46, 0x9f, 0x7e, 0x67, 0x4e, 0xe3, 0xf1, 0x7c}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x27, 0xc2, 0x1a, 0x11, 0x8f, 0x2b, 0x2c, 0x22, 0x80, 0xd1, - 0x1a, 0xdc, 0xa2, 0x11, 0xf0, 0xc4, 0x13, 0xe2, 0x0, 0x92, - 0xe2, 0x3a, 0x2, 0xbd, 0x4a, 0x2a, 0x7e, 0x26, 0xc8}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7e, 0x33, 0xc3, 0x4c, 0x26, 0x5d, 0xa0, 0xb8, 0xa1, 0x2, - 0xa8, 0xb5, 0x23, 0x45, 0x6d, 0x21, 0xcd, 0xfc, 0x4b, 0xfd}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x64, 0x49, 0xb1, 0x67, 0xca, 0x56, 0x70, 0x34, 0x6b, 0x5, 0xb2, 0xff, 0x7a, 0xab, - 0x78, 0xd4, 0x2, 0xe0, 0x1e, 0x53, 0x1c, 0xa9, 0x90, 0xb4, 0x97, 0xb6, 0xc9}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x36, 0x15, 0x4, 0x91, 0xd8, 0xe5, 0x42, 0x19, - 0xf7, 0xf2, 0x31, 0x62, 0xdf, 0x83, 0x8d}; - lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x25, 0x42, 0xff, 0x7d, 0x9b, 0xc6, 0xdc, 0x60, 0xe1, 0x1a, - 0xc7, 0x41, 0xba, 0xf0, 0x81, 0x32, 0x10, 0xec, 0x79, 0xba}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25332}}, - }; - - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14420, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 27160 [("\162D\159",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\195_\131\NULo|\DC3\153\204\130Z\129\a\148$\133jPw\238<\201\&1X\151F\133\248\217l",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\168\&1\255\241I\162\173v\254uZ*\140G",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\US=\184j\\AA\155\156@\178\229r'K0i\204\ESC\168Q'\196\226\234\233",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable -// 187,PropWildcardSubscriptionAvailable 85,PropReasonString "a~\212\\2\174",PropMessageExpiryInterval -// 1915,PropAuthenticationMethod "\203\EOT\163\f\ETB\185g+ny",PropMaximumQoS 220,PropReasonString -// "}m\a\DEL\205\&6'n\191\249\179d\213\200",PropSessionExpiryInterval 29557,PropCorrelationData -// "\160\194{\148{\SI\195\&8\174\f3\165\142\231(\180\145\NAK\216\214\152\201\187",PropWildcardSubscriptionAvailable 203] -TEST(Subscribe5QCTest, Encode83) { - uint8_t pkt[] = {0x82, 0xab, 0x1, 0x6a, 0x18, 0x53, 0x2a, 0xbb, 0x28, 0x55, 0x1f, 0x0, 0x6, 0x61, 0x7e, 0xd4, - 0x5c, 0x32, 0xae, 0x2, 0x0, 0x0, 0x7, 0x7b, 0x15, 0x0, 0xa, 0xcb, 0x4, 0xa3, 0xc, 0x17, - 0xb9, 0x67, 0x2b, 0x6e, 0x79, 0x24, 0xdc, 0x1f, 0x0, 0xe, 0x7d, 0x6d, 0x7, 0x7f, 0xcd, 0x36, - 0x27, 0x6e, 0xbf, 0xf9, 0xb3, 0x64, 0xd5, 0xc8, 0x11, 0x0, 0x0, 0x73, 0x75, 0x9, 0x0, 0x17, - 0xa0, 0xc2, 0x7b, 0x94, 0x7b, 0xf, 0xc3, 0x38, 0xae, 0xc, 0x33, 0xa5, 0x8e, 0xe7, 0x28, 0xb4, - 0x91, 0x15, 0xd8, 0xd6, 0x98, 0xc9, 0xbb, 0x28, 0xcb, 0x0, 0x3, 0xa2, 0x44, 0x9f, 0x2, 0x0, - 0x1e, 0xc3, 0x5f, 0x83, 0x0, 0x6f, 0x7c, 0x13, 0x99, 0xcc, 0x82, 0x5a, 0x81, 0x7, 0x94, 0x24, - 0x85, 0x6a, 0x50, 0x77, 0xee, 0x3c, 0xc9, 0x31, 0x58, 0x97, 0x46, 0x85, 0xf8, 0xd9, 0x6c, 0x2, - 0x0, 0xe, 0xa8, 0x31, 0xff, 0xf1, 0x49, 0xa2, 0xad, 0x76, 0xfe, 0x75, 0x5a, 0x2a, 0x8c, 0x47, - 0x1, 0x0, 0x1a, 0x1f, 0x3d, 0xb8, 0x6a, 0x5c, 0x41, 0x41, 0x9b, 0x9c, 0x40, 0xb2, 0xe5, 0x72, - 0x27, 0x4b, 0x30, 0x69, 0xcc, 0x1b, 0xa8, 0x51, 0x27, 0xc4, 0xe2, 0xea, 0xe9, 0x2}; - - uint8_t buf[184] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xa2, 0x44, 0x9f}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc3, 0x5f, 0x83, 0x0, 0x6f, 0x7c, 0x13, 0x99, 0xcc, 0x82, - 0x5a, 0x81, 0x7, 0x94, 0x24, 0x85, 0x6a, 0x50, 0x77, 0xee, - 0x3c, 0xc9, 0x31, 0x58, 0x97, 0x46, 0x85, 0xf8, 0xd9, 0x6c}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa8, 0x31, 0xff, 0xf1, 0x49, 0xa2, 0xad, - 0x76, 0xfe, 0x75, 0x5a, 0x2a, 0x8c, 0x47}; - lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1f, 0x3d, 0xb8, 0x6a, 0x5c, 0x41, 0x41, 0x9b, 0x9c, 0x40, 0xb2, 0xe5, 0x72, - 0x27, 0x4b, 0x30, 0x69, 0xcc, 0x1b, 0xa8, 0x51, 0x27, 0xc4, 0xe2, 0xea, 0xe9}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x61, 0x7e, 0xd4, 0x5c, 0x32, 0xae}; - uint8_t bytesprops1[] = {0xcb, 0x4, 0xa3, 0xc, 0x17, 0xb9, 0x67, 0x2b, 0x6e, 0x79}; - uint8_t bytesprops2[] = {0x7d, 0x6d, 0x7, 0x7f, 0xcd, 0x36, 0x27, 0x6e, 0xbf, 0xf9, 0xb3, 0x64, 0xd5, 0xc8}; - uint8_t bytesprops3[] = {0xa0, 0xc2, 0x7b, 0x94, 0x7b, 0xf, 0xc3, 0x38, 0xae, 0xc, 0x33, 0xa5, - 0x8e, 0xe7, 0x28, 0xb4, 0x91, 0x15, 0xd8, 0xd6, 0x98, 0xc9, 0xbb}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1915}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29557}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 203}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27160, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 22660 -// [("k\215\&6o4\168\148\NAKl|\DC2eLi\r\203\ETX\152\158\131\197\142\143\248\134l\CAN\243\SYN",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("!m\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS -// = QoS1}),("t\a\155\243\134r\ETB)\244Y:",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\144",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("Dy",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),("\169p\197\187\137\SUBA\138\224\242\167\174\rh\b\143\210f\225\220\STX\200\t",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\rw\214#2r\221~\249",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropMaximumPacketSize 15050,PropMessageExpiryInterval 9141,PropTopicAliasMaximum 1046,PropContentType -// "Cw\245\144na\225\236s\130\SO\167\166\DEL\246\227\139\140\131\161Y\DLE/i\149\173 ",PropRequestProblemInformation -// 147,PropWillDelayInterval 25750,PropContentType -// "\128\179\&7[\212\ETX\252\DC3\242\226}\EMT\198\134\&1\150\NUL\165n\140\&8{}\134",PropContentType -// "\a\r\192\211\194\202\197\255M:\214\196\SUB\ETB",PropWildcardSubscriptionAvailable 34,PropSubscriptionIdentifier -// 7,PropWillDelayInterval 11753,PropReceiveMaximum 29355,PropRetainAvailable 27,PropUserProperty -// "\173\202\135N\253\&3\186\\Yh\234Q\156\166\170\&9\148" -// "\156\203h`>Pmip\STX\214:\RSc\221\240\211\183\217ZQ\183,\175)\217\133>",PropMaximumQoS 212,PropTopicAlias -// 13251,PropWildcardSubscriptionAvailable 11,PropContentType -// "\183\175b\225!\234\241\EOT\189I\133f\158M",PropMessageExpiryInterval 19195,PropSessionExpiryInterval -// 3913,PropSubscriptionIdentifier 3,PropContentType "\226\212H\204\184\198",PropTopicAlias -// 4680,PropRequestResponseInformation 110,PropCorrelationData -// "\223\162K\142\179\DC1\ETX7\137s\250i\NUL\a\206'.",PropServerReference -// "/\151\SUB\232\186cY\147s3U/E\219\161z\214\210\148\228\227i\183"] -TEST(Subscribe5QCTest, Encode84) { - uint8_t pkt[] = { - 0x82, 0xe6, 0x2, 0x58, 0x84, 0xff, 0x1, 0x27, 0x0, 0x0, 0x3a, 0xca, 0x2, 0x0, 0x0, 0x23, 0xb5, 0x22, 0x4, - 0x16, 0x3, 0x0, 0x1b, 0x43, 0x77, 0xf5, 0x90, 0x6e, 0x61, 0xe1, 0xec, 0x73, 0x82, 0xe, 0xa7, 0xa6, 0x7f, 0xf6, - 0xe3, 0x8b, 0x8c, 0x83, 0xa1, 0x59, 0x10, 0x2f, 0x69, 0x95, 0xad, 0x20, 0x17, 0x93, 0x18, 0x0, 0x0, 0x64, 0x96, - 0x3, 0x0, 0x19, 0x80, 0xb3, 0x37, 0x5b, 0xd4, 0x3, 0xfc, 0x13, 0xf2, 0xe2, 0x7d, 0x19, 0x54, 0xc6, 0x86, 0x31, - 0x96, 0x0, 0xa5, 0x6e, 0x8c, 0x38, 0x7b, 0x7d, 0x86, 0x3, 0x0, 0xe, 0x7, 0xd, 0xc0, 0xd3, 0xc2, 0xca, 0xc5, - 0xff, 0x4d, 0x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5, - 0x8e, 0x8f, 0xf8, 0x86, 0x6c, 0x18, 0xf3, 0x16, 0x0, 0x0, 0x3, 0x21, 0x6d, 0xb9, 0x1, 0x0, 0xb, 0x74, 0x7, - 0x9b, 0xf3, 0x86, 0x72, 0x17, 0x29, 0xf4, 0x59, 0x3a, 0x2, 0x0, 0x1, 0x90, 0x1, 0x0, 0x2, 0x44, 0x79, 0x0, - 0x0, 0x17, 0xa9, 0x70, 0xc5, 0xbb, 0x89, 0x1a, 0x41, 0x8a, 0xe0, 0xf2, 0xa7, 0xae, 0xd, 0x68, 0x8, 0x8f, 0xd2, - 0x66, 0xe1, 0xdc, 0x2, 0xc8, 0x9, 0x1, 0x0, 0x9, 0xd, 0x77, 0xd6, 0x23, 0x32, 0x72, 0xdd, 0x7e, 0xf9, 0x2}; - - uint8_t buf[371] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x6b, 0xd7, 0x36, 0x6f, 0x34, 0xa8, 0x94, 0x15, 0x6c, 0x7c, - 0x12, 0x65, 0x4c, 0x69, 0xd, 0xcb, 0x3, 0x98, 0x9e, 0x83, - 0xc5, 0x8e, 0x8f, 0xf8, 0x86, 0x6c, 0x18, 0xf3, 0x16}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x21, 0x6d, 0xb9}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x74, 0x7, 0x9b, 0xf3, 0x86, 0x72, 0x17, 0x29, 0xf4, 0x59, 0x3a}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x90}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x44, 0x79}; - lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa9, 0x70, 0xc5, 0xbb, 0x89, 0x1a, 0x41, 0x8a, 0xe0, 0xf2, 0xa7, 0xae, - 0xd, 0x68, 0x8, 0x8f, 0xd2, 0x66, 0xe1, 0xdc, 0x2, 0xc8, 0x9}; - lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xd, 0x77, 0xd6, 0x23, 0x32, 0x72, 0xdd, 0x7e, 0xf9}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x43, 0x77, 0xf5, 0x90, 0x6e, 0x61, 0xe1, 0xec, 0x73, 0x82, 0xe, 0xa7, 0xa6, 0x7f, - 0xf6, 0xe3, 0x8b, 0x8c, 0x83, 0xa1, 0x59, 0x10, 0x2f, 0x69, 0x95, 0xad, 0x20}; - uint8_t bytesprops1[] = {0x80, 0xb3, 0x37, 0x5b, 0xd4, 0x3, 0xfc, 0x13, 0xf2, 0xe2, 0x7d, 0x19, 0x54, - 0xc6, 0x86, 0x31, 0x96, 0x0, 0xa5, 0x6e, 0x8c, 0x38, 0x7b, 0x7d, 0x86}; - uint8_t bytesprops2[] = {0x7, 0xd, 0xc0, 0xd3, 0xc2, 0xca, 0xc5, 0xff, 0x4d, 0x3a, 0xd6, 0xc4, 0x1a, 0x17}; - uint8_t bytesprops4[] = {0x9c, 0xcb, 0x68, 0x60, 0x3e, 0x50, 0x6d, 0x69, 0x70, 0x2, 0xd6, 0x3a, 0x1e, 0x63, - 0xdd, 0xf0, 0xd3, 0xb7, 0xd9, 0x5a, 0x51, 0xb7, 0x2c, 0xaf, 0x29, 0xd9, 0x85, 0x3e}; - uint8_t bytesprops3[] = {0xad, 0xca, 0x87, 0x4e, 0xfd, 0x33, 0xba, 0x5c, 0x59, - 0x68, 0xea, 0x51, 0x9c, 0xa6, 0xaa, 0x39, 0x94}; - uint8_t bytesprops5[] = {0xb7, 0xaf, 0x62, 0xe1, 0x21, 0xea, 0xf1, 0x4, 0xbd, 0x49, 0x85, 0x66, 0x9e, 0x4d}; - uint8_t bytesprops6[] = {0xe2, 0xd4, 0x48, 0xcc, 0xb8, 0xc6}; - uint8_t bytesprops7[] = {0xdf, 0xa2, 0x4b, 0x8e, 0xb3, 0x11, 0x3, 0x37, 0x89, - 0x73, 0xfa, 0x69, 0x0, 0x7, 0xce, 0x27, 0x2e}; - uint8_t bytesprops8[] = {0x2f, 0x97, 0x1a, 0xe8, 0xba, 0x63, 0x59, 0x93, 0x73, 0x33, 0x55, 0x2f, - 0x45, 0xdb, 0xa1, 0x7a, 0xd6, 0xd2, 0x94, 0xe4, 0xe3, 0x69, 0xb7}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15050}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9141}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1046}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25750}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11753}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29355}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13251}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19195}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3913}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4680}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops8}}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22660, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 13206 [("\134\245\ft\GS\160Zb\214\NAK\247^\170\162\CAN\201D\147\244$\SUB\DC2\130d\170",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\134",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\190\142\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\NAKe\ETB\156>o\252\206\DC2F\DLE\224\224\183\231O\254`K\185\191\202",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\246\204EG\236x\DC3\172\243\168+\175\196v@#\DEL\188\&4\205M\226p1\165\174",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\ETX;\137\191}\SOdq\196\DC1\234\160\DEL1\173\155Rr8(\241S\132\173\129",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic -// "\178d\243\202\146\135\EM\156\214\174\SO\170\195\ESCNQ\190\bi\166f\213\182\244EK\192",PropSessionExpiryInterval -// 31168,PropResponseInformation -// "i\242\233\191\143\187&\129\136ZFH\209\129\SO\226\161&\ESC\155\221v\244d\ESC4\229b1^",PropMessageExpiryInterval -// 31515,PropRetainAvailable 52,PropReasonString "cA\DC3_d\NUL\FS\157\234\129",PropServerReference -// "{U\217\208\211m\186\r9\248\STX<\162|(\247\147\175ok\ESC",PropMaximumQoS 193,PropServerReference -// "\147kpEV\130",PropUserProperty "\137" "%(\164\218\157 -// \229\253\142\193\220\DLEMU[#\251\131\230\241\201\&5B\147\182",PropRequestProblemInformation 70,PropResponseTopic -// "s\STX\155RN\130\175\133v\240]\222\214\241\170E\ESC\DEL9\138\193\ETX\170\&0~m\ESC",PropWillDelayInterval -// 488,PropResponseTopic "\\y/2ZW\NUL^ n\215\227\248_\ESC\241p\248bW",PropReasonString -// "\169\230i\DC2\251d\164\250&\DLE\184\158|\187\156}\141,\141\241\176\181\226\134}xe\210",PropCorrelationData -// "5u\129\201\165b\137\239\SOHY\RS\250`\255\192\131",PropAuthenticationMethod -// "\208*1$\174\&6d4\224\238\255\141E\207,\fv\214\240}\137",PropMessageExpiryInterval 7357,PropAssignedClientIdentifier -// "\199g!\229\219jw\246GP\248~>\212\143F0\DLE\246\161D\150\a\253\188\173\b",PropMessageExpiryInterval -// 14764,PropMessageExpiryInterval 29761,PropContentType -// "^\188\172\164<9\245l\128\254\141\170\\",PropSharedSubscriptionAvailable 167,PropTopicAliasMaximum -// 11277,PropAssignedClientIdentifier "\165w4"] -TEST(Subscribe5QCTest, Encode85) { - uint8_t pkt[] = { - 0x82, 0xaf, 0x4, 0x33, 0x96, 0xaf, 0x3, 0x8, 0x0, 0x1b, 0xb2, 0x64, 0xf3, 0xca, 0x92, 0x87, 0x19, 0x9c, 0xd6, - 0xae, 0xe, 0xaa, 0xc3, 0x1b, 0x4e, 0x51, 0xbe, 0x8, 0x69, 0xa6, 0x66, 0xd5, 0xb6, 0xf4, 0x45, 0x4b, 0xc0, 0x11, - 0x0, 0x0, 0x79, 0xc0, 0x1a, 0x0, 0x1e, 0x69, 0xf2, 0xe9, 0xbf, 0x8f, 0xbb, 0x26, 0x81, 0x88, 0x5a, 0x46, 0x48, - 0xd1, 0x81, 0xe, 0xe2, 0xa1, 0x26, 0x1b, 0x9b, 0xdd, 0x76, 0xf4, 0x64, 0x1b, 0x34, 0xe5, 0x62, 0x31, 0x5e, 0x2, - 0x0, 0x0, 0x7b, 0x1b, 0x25, 0x34, 0x1f, 0x0, 0xa, 0x63, 0x41, 0x13, 0x5f, 0x64, 0x0, 0x1c, 0x9d, 0xea, 0x81, - 0x1c, 0x0, 0x15, 0x7b, 0x55, 0xd9, 0xd0, 0xd3, 0x6d, 0xba, 0xd, 0x39, 0xf8, 0x2, 0x3c, 0xa2, 0x7c, 0x28, 0xf7, - 0x93, 0xaf, 0x6f, 0x6b, 0x1b, 0x24, 0xc1, 0x1c, 0x0, 0x6, 0x93, 0x6b, 0x70, 0x45, 0x56, 0x82, 0x26, 0x0, 0x1, - 0x89, 0x0, 0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0xf6, 0xcc, 0x45, 0x47, 0xec, 0x78, - 0x13, 0xac, 0xf3, 0xa8, 0x2b, 0xaf, 0xc4, 0x76, 0x40, 0x23, 0x7f, 0xbc, 0x34, 0xcd, 0x4d, 0xe2, 0x70, 0x31, 0xa5, - 0xae, 0x0, 0x0, 0x19, 0x3, 0x3b, 0x89, 0xbf, 0x7d, 0xe, 0x64, 0x71, 0xc4, 0x11, 0xea, 0xa0, 0x7f, 0x31, 0xad, - 0x9b, 0x52, 0x72, 0x38, 0x28, 0xf1, 0x53, 0x84, 0xad, 0x81, 0x1}; - - uint8_t buf[572] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x86, 0xf5, 0xc, 0x74, 0x1d, 0xa0, 0x5a, 0x62, 0xd6, 0x15, 0xf7, 0x5e, 0xaa, - 0xa2, 0x18, 0xc9, 0x44, 0x93, 0xf4, 0x24, 0x1a, 0x12, 0x82, 0x64, 0xaa}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x86}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xbe, 0x8e, 0xd2}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x39}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x15, 0x65, 0x17, 0x9c, 0x3e, 0x6f, 0xfc, 0xce, 0x12, 0x46, 0x10, - 0xe0, 0xe0, 0xb7, 0xe7, 0x4f, 0xfe, 0x60, 0x4b, 0xb9, 0xbf, 0xca}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf6, 0xcc, 0x45, 0x47, 0xec, 0x78, 0x13, 0xac, 0xf3, 0xa8, 0x2b, 0xaf, 0xc4, - 0x76, 0x40, 0x23, 0x7f, 0xbc, 0x34, 0xcd, 0x4d, 0xe2, 0x70, 0x31, 0xa5, 0xae}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3, 0x3b, 0x89, 0xbf, 0x7d, 0xe, 0x64, 0x71, 0xc4, 0x11, 0xea, 0xa0, 0x7f, - 0x31, 0xad, 0x9b, 0x52, 0x72, 0x38, 0x28, 0xf1, 0x53, 0x84, 0xad, 0x81}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xb2, 0x64, 0xf3, 0xca, 0x92, 0x87, 0x19, 0x9c, 0xd6, 0xae, 0xe, 0xaa, 0xc3, 0x1b, - 0x4e, 0x51, 0xbe, 0x8, 0x69, 0xa6, 0x66, 0xd5, 0xb6, 0xf4, 0x45, 0x4b, 0xc0}; - uint8_t bytesprops1[] = {0x69, 0xf2, 0xe9, 0xbf, 0x8f, 0xbb, 0x26, 0x81, 0x88, 0x5a, 0x46, 0x48, 0xd1, 0x81, 0xe, - 0xe2, 0xa1, 0x26, 0x1b, 0x9b, 0xdd, 0x76, 0xf4, 0x64, 0x1b, 0x34, 0xe5, 0x62, 0x31, 0x5e}; - uint8_t bytesprops2[] = {0x63, 0x41, 0x13, 0x5f, 0x64, 0x0, 0x1c, 0x9d, 0xea, 0x81}; - uint8_t bytesprops3[] = {0x7b, 0x55, 0xd9, 0xd0, 0xd3, 0x6d, 0xba, 0xd, 0x39, 0xf8, 0x2, - 0x3c, 0xa2, 0x7c, 0x28, 0xf7, 0x93, 0xaf, 0x6f, 0x6b, 0x1b}; - uint8_t bytesprops4[] = {0x93, 0x6b, 0x70, 0x45, 0x56, 0x82}; - uint8_t bytesprops6[] = {0x25, 0x28, 0xa4, 0xda, 0x9d, 0x20, 0xe5, 0xfd, 0x8e, 0xc1, 0xdc, 0x10, 0x4d, - 0x55, 0x5b, 0x23, 0xfb, 0x83, 0xe6, 0xf1, 0xc9, 0x35, 0x42, 0x93, 0xb6}; - uint8_t bytesprops5[] = {0x89}; - uint8_t bytesprops7[] = {0x73, 0x2, 0x9b, 0x52, 0x4e, 0x82, 0xaf, 0x85, 0x76, 0xf0, 0x5d, 0xde, 0xd6, 0xf1, - 0xaa, 0x45, 0x1b, 0x7f, 0x39, 0x8a, 0xc1, 0x3, 0xaa, 0x30, 0x7e, 0x6d, 0x1b}; - uint8_t bytesprops8[] = {0x5c, 0x79, 0x2f, 0x32, 0x5a, 0x57, 0x0, 0x5e, 0x20, 0x6e, - 0xd7, 0xe3, 0xf8, 0x5f, 0x1b, 0xf1, 0x70, 0xf8, 0x62, 0x57}; - uint8_t bytesprops9[] = {0xa9, 0xe6, 0x69, 0x12, 0xfb, 0x64, 0xa4, 0xfa, 0x26, 0x10, 0xb8, 0x9e, 0x7c, 0xbb, - 0x9c, 0x7d, 0x8d, 0x2c, 0x8d, 0xf1, 0xb0, 0xb5, 0xe2, 0x86, 0x7d, 0x78, 0x65, 0xd2}; - uint8_t bytesprops10[] = {0x35, 0x75, 0x81, 0xc9, 0xa5, 0x62, 0x89, 0xef, - 0x1, 0x59, 0x1e, 0xfa, 0x60, 0xff, 0xc0, 0x83}; - uint8_t bytesprops11[] = {0xd0, 0x2a, 0x31, 0x24, 0xae, 0x36, 0x64, 0x34, 0xe0, 0xee, - 0xff, 0x8d, 0x45, 0xcf, 0x2c, 0xc, 0x76, 0xd6, 0x3c, 0x55}; - uint8_t bytesprops13[] = {0x96, 0xea, 0x9a, 0xd5, 0x4a, 0xc2, 0x56, 0x84, 0x94, 0x96, 0xb8, 0x1b, 0x9e, 0xac, 0x1d}; - uint8_t bytesprops12[] = {0x29, 0x95, 0x6c, 0xe8, 0x9c, 0x8d, 0x31, 0x94, 0x56, 0x64, 0x50, 0x64, - 0xe6, 0x26, 0xc6, 0x65, 0xa5, 0xf, 0xe7, 0x4f, 0x8d, 0x59, 0xa2}; - uint8_t bytesprops14[] = {0x30, 0x54, 0x57, 0x55, 0xca, 0xa2, 0x72, 0x37, 0x33, - 0x5, 0x69, 0xf9, 0x6, 0x3e, 0xf0, 0x7d, 0x89}; - uint8_t bytesprops15[] = {0xc7, 0x67, 0x21, 0xe5, 0xdb, 0x6a, 0x77, 0xf6, 0x47, 0x50, 0xf8, 0x7e, 0x3e, 0xd4, - 0x8f, 0x46, 0x30, 0x10, 0xf6, 0xa1, 0x44, 0x96, 0x7, 0xfd, 0xbc, 0xad, 0x8}; - uint8_t bytesprops16[] = {0x5e, 0xbc, 0x3c, 0x67, 0xbf, 0xa4, 0x3e, 0xac, 0xa4, - 0x3c, 0x39, 0xf5, 0x6c, 0x80, 0xfe, 0x8d, 0xaa, 0x5c}; - uint8_t bytesprops17[] = {0xa5, 0x77, 0x34}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31168}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31515}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops5}, .v = {25, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 488}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {23, (char*)&bytesprops12}, .v = {15, (char*)&bytesprops13}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7357}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops15}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14764}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29761}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops16}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11277}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops17}}}, - }; - - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13206, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 8501 [("\203p\176B\229Ul'\142n\159\GS\221",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropMessageExpiryInterval -// 24653,PropTopicAliasMaximum 4164,PropServerReference "t\177\211\&1\236\ETB\210\242\225\211I\183\254\219\208s\240\DC3E -// y\197\134\&3V\185\176",PropTopicAliasMaximum 23401,PropCorrelationData -// "@$\USa\SYNU\143\DC2\183%%><-\231\160\229\187\216",PropMessageExpiryInterval 8933,PropServerReference -// "9\234X\STX\GS\173\169\197Q\131\224\&9\191",PropServerReference "\185b\205ge!",PropAuthenticationMethod -// "\221\SIDGQ",PropSharedSubscriptionAvailable 181,PropSharedSubscriptionAvailable 26,PropSubscriptionIdentifier -// 4,PropServerReference -// "W\237\135\DC3\252\190\a\144\179\187g\140\175W$\226\181\240\&9\206\221\STX\FS\216\r\136\129",PropMessageExpiryInterval -// 13114,PropAuthenticationData -// "^\f\DC4\EOT\"b)\129\239\130\200\177\174\136\187jD\184\230'",PropRequestProblemInformation 92,PropServerReference -// "2t.\\\158\RSV",PropContentType "sEGBA\198a[\DC3\255\STX",PropServerReference -// "\169\"\212\129\aJl-\209\152",PropReasonString -// "!\168m/\210\144\DLE,\232\215G\156",PropSubscriptionIdentifierAvailable 122,PropCorrelationData -// "\149\FS%k5\143\US\v\203\&1",PropAuthenticationData "W\191 5]_RE\255\244\228\229",PropUserProperty "\233 " -// "\201\172\136\145#\206ub",PropRequestProblemInformation 148,PropResponseTopic "t\\>\184W\200\240\&9\143.1\229%:"] -TEST(Subscribe5QCTest, Encode86) { - uint8_t pkt[] = {0x82, 0xaf, 0x2, 0x21, 0x35, 0x9b, 0x2, 0x2, 0x0, 0x0, 0x60, 0x4d, 0x22, 0x10, 0x44, 0x1c, 0x0, - 0x1b, 0x74, 0xb1, 0xd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x2d, 0xd1, 0x98, 0x1f, 0x0, 0xc, 0x21, 0xa8, 0x6d, 0x2f, 0xd2, 0x90, 0x10, - 0x2c, 0xe8, 0xd7, 0x47, 0x9c, 0x29, 0x7a, 0x9, 0x0, 0xa, 0x95, 0x1c, 0x25, 0x6b, 0x35, 0x8f, 0x1f, - 0xb, 0xcb, 0x31, 0x16, 0x0, 0xc, 0x57, 0xbf, 0x20, 0x35, 0x5d, 0x5f, 0x52, 0x45, 0xff, 0xf4, 0xe4, - 0xe5, 0x26, 0x0, 0x2, 0xe9, 0x20, 0x0, 0x8, 0xc9, 0xac, 0x88, 0x91, 0x23, 0xce, 0x75, 0x62, 0x17, - 0x94, 0x8, 0x0, 0xe, 0x74, 0x5c, 0x3e, 0xb8, 0x57, 0xc8, 0xf0, 0x39, 0x8f, 0x2e, 0x31, 0xe5, 0x25, - 0x3a, 0x0, 0xd, 0xcb, 0x70, 0xb0, 0x42, 0xe5, 0x55, 0x6c, 0x27, 0x8e, 0x6e, 0x9f, 0x1d, 0xdd, 0x2}; - - uint8_t buf[316] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xcb, 0x70, 0xb0, 0x42, 0xe5, 0x55, 0x6c, 0x27, 0x8e, 0x6e, 0x9f, 0x1d, 0xdd}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x74, 0xb1, 0xd3, 0x31, 0xec, 0x17, 0xd2, 0xf2, 0xe1, 0xd3, 0x49, 0xb7, 0xfe, 0xdb, - 0xd0, 0x73, 0xf0, 0x13, 0x45, 0x20, 0x79, 0xc5, 0x86, 0x33, 0x56, 0xb9, 0xb0}; - uint8_t bytesprops1[] = {0x40, 0x24, 0x1f, 0x61, 0x16, 0x55, 0x8f, 0x12, 0xb7, 0x25, - 0x25, 0x3e, 0x3c, 0x2d, 0xe7, 0xa0, 0xe5, 0xbb, 0xd8}; - uint8_t bytesprops2[] = {0x39, 0xea, 0x58, 0x2, 0x1d, 0xad, 0xa9, 0xc5, 0x51, 0x83, 0xe0, 0x39, 0xbf}; - uint8_t bytesprops3[] = {0xb9, 0x62, 0xcd, 0x67, 0x65, 0x21}; - uint8_t bytesprops4[] = {0xdd, 0xf, 0x44, 0x47, 0x51}; - uint8_t bytesprops5[] = {0x57, 0xed, 0x87, 0x13, 0xfc, 0xbe, 0x7, 0x90, 0xb3, 0xbb, 0x67, 0x8c, 0xaf, 0x57, - 0x24, 0xe2, 0xb5, 0xf0, 0x39, 0xce, 0xdd, 0x2, 0x1c, 0xd8, 0xd, 0x88, 0x81}; - uint8_t bytesprops6[] = {0x5e, 0xc, 0x14, 0x4, 0x22, 0x62, 0x29, 0x81, 0xef, 0x82, - 0xc8, 0xb1, 0xae, 0x88, 0xbb, 0x6a, 0x44, 0xb8, 0xe6, 0x27}; - uint8_t bytesprops7[] = {0x32, 0x74, 0x2e, 0x5c, 0x9e, 0x1e, 0x56}; - uint8_t bytesprops8[] = {0x73, 0x45, 0x47, 0x42, 0x41, 0xc6, 0x61, 0x5b, 0x13, 0xff, 0x2}; - uint8_t bytesprops9[] = {0xa9, 0x22, 0xd4, 0x81, 0x7, 0x4a, 0x6c, 0x2d, 0xd1, 0x98}; - uint8_t bytesprops10[] = {0x21, 0xa8, 0x6d, 0x2f, 0xd2, 0x90, 0x10, 0x2c, 0xe8, 0xd7, 0x47, 0x9c}; - uint8_t bytesprops11[] = {0x95, 0x1c, 0x25, 0x6b, 0x35, 0x8f, 0x1f, 0xb, 0xcb, 0x31}; - uint8_t bytesprops12[] = {0x57, 0xbf, 0x20, 0x35, 0x5d, 0x5f, 0x52, 0x45, 0xff, 0xf4, 0xe4, 0xe5}; - uint8_t bytesprops14[] = {0xc9, 0xac, 0x88, 0x91, 0x23, 0xce, 0x75, 0x62}; - uint8_t bytesprops13[] = {0xe9, 0x20}; - uint8_t bytesprops15[] = {0x74, 0x5c, 0x3e, 0xb8, 0x57, 0xc8, 0xf0, 0x39, 0x8f, 0x2e, 0x31, 0xe5, 0x25, 0x3a}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24653}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4164}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23401}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8933}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13114}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops13}, .v = {8, (char*)&bytesprops14}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops15}}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8501, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 25153 [("\132f\153\132\244w'\154\220S",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\249\167\241%",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\142\244",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\151NI\219\241\129\216N\187\248`\189\"G}\165\133)7R\135\154\ETX~\175",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("/;\227\164B+\151W!\206\238\128\136\GS\vz\163\244:G\172V",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("5\145\185{#B\152\236",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("<\131\162\143,2\130\130\159\151\150\CAN2\223\208\ESC\181\218\201\149\&6",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropContentType -// "5\251\237Ie\142\CANs",PropMessageExpiryInterval 23405,PropContentType -// "DI\171\251Z\ETB\216\185`N\246d\194+\f\164\245>h\177\b\217c\144",PropUserProperty -// "\211\162\150O\132h\138\&37N\205\STX\NAK\129\152\230\213\167\SOH\213\176\157:\140d\251" -// "\193n\241w\SO\223>\DLE\t\175WH?]\220{\SIJ\179\238\240`\199]\a\DLE\235\213\204",PropUserProperty -// "L\149\140\154xwdj~.\201\158\175ce\ENQ\173?OV2\212\189sB\US" "\r\251",PropTopicAlias -// 20702,PropSharedSubscriptionAvailable 44,PropServerKeepAlive 20616,PropMessageExpiryInterval -// 3019,PropSubscriptionIdentifier 2,PropAuthenticationData -// ":\ACK\184\168F8Z\204\227\229=\DC3\255Z\197\145\128\168\136\228\165\251u(\149\188",PropReasonString -// "\145\133\201\f\250\235\229\251C8\181\160\US\SUB\154\167\234\210\220T8",PropSubscriptionIdentifierAvailable -// 201,PropResponseInformation "\EOT5\174\EM\197\236\RS\239n\164",PropAuthenticationMethod -// "\162h7\140t|\202\FSw\DC1\SOHeh\169ONq\139\204\250\219\145\193\246BL",PropSharedSubscriptionAvailable -// 142,PropSharedSubscriptionAvailable 223,PropRequestProblemInformation 38,PropAuthenticationMethod -// "\DC3Bf\242\201#\200ldr*\215_\DLE\206\202",PropRetainAvailable 40,PropRetainAvailable 73,PropResponseTopic -// "\STX}\253\252\215Q\128\213z\160\EM\208T\164a\133\&0\b(\214\n+a\136oL5\143.",PropAuthenticationMethod -// "\210\212\183DL\b4!]y_\234\232\237\DC3\226C\175",PropServerKeepAlive 31013,PropMessageExpiryInterval -// 5923,PropMaximumPacketSize 6507,PropSessionExpiryInterval 27876,PropSessionExpiryInterval 11429] -TEST(Subscribe5QCTest, Encode87) { - uint8_t pkt[] = { - 0x82, 0xd9, 0x3, 0x62, 0x41, 0xe1, 0x2, 0x3, 0x0, 0x8, 0x35, 0xfb, 0xed, 0x49, 0x65, 0x8e, 0x18, 0x73, 0x2, - 0x0, 0x0, 0x5b, 0x6d, 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 0x81, 0xd8, 0x4e, 0xbb, - 0xf8, 0x60, 0xbd, 0x22, 0x47, 0x7d, 0xa5, 0x85, 0x29, 0x37, 0x52, 0x87, 0x9a, 0x3, 0x7e, 0xaf, 0x0, 0x0, 0x16, - 0x2f, 0x3b, 0xe3, 0xa4, 0x42, 0x2b, 0x97, 0x57, 0x21, 0xce, 0xee, 0x80, 0x88, 0x1d, 0xb, 0x7a, 0xa3, 0xf4, 0x3a, - 0x47, 0xac, 0x56, 0x0, 0x0, 0x8, 0x35, 0x91, 0xb9, 0x7b, 0x23, 0x42, 0x98, 0xec, 0x0, 0x0, 0x15, 0x3c, 0x83, - 0xa2, 0x8f, 0x2c, 0x32, 0x82, 0x82, 0x9f, 0x97, 0x96, 0x18, 0x32, 0xdf, 0xd0, 0x1b, 0xb5, 0xda, 0xc9, 0x95, 0x36, - 0x0}; - - uint8_t buf[486] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x84, 0x66, 0x99, 0x84, 0xf4, 0x77, 0x27, 0x9a, 0xdc, 0x53}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf9, 0xa7, 0xf1, 0x25}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8e, 0xf4}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x97, 0x4e, 0x49, 0xdb, 0xf1, 0x81, 0xd8, 0x4e, 0xbb, 0xf8, 0x60, 0xbd, 0x22, - 0x47, 0x7d, 0xa5, 0x85, 0x29, 0x37, 0x52, 0x87, 0x9a, 0x3, 0x7e, 0xaf}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x2f, 0x3b, 0xe3, 0xa4, 0x42, 0x2b, 0x97, 0x57, 0x21, 0xce, 0xee, - 0x80, 0x88, 0x1d, 0xb, 0x7a, 0xa3, 0xf4, 0x3a, 0x47, 0xac, 0x56}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x35, 0x91, 0xb9, 0x7b, 0x23, 0x42, 0x98, 0xec}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x3c, 0x83, 0xa2, 0x8f, 0x2c, 0x32, 0x82, 0x82, 0x9f, 0x97, 0x96, - 0x18, 0x32, 0xdf, 0xd0, 0x1b, 0xb5, 0xda, 0xc9, 0x95, 0x36}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x35, 0xfb, 0xed, 0x49, 0x65, 0x8e, 0x18, 0x73}; - uint8_t bytesprops1[] = {0x44, 0x49, 0xab, 0xfb, 0x5a, 0x17, 0xd8, 0xb9, 0x60, 0x4e, 0xf6, 0x64, - 0xc2, 0x2b, 0xc, 0xa4, 0xf5, 0x3e, 0x68, 0xb1, 0x8, 0xd9, 0x63, 0x90}; - uint8_t bytesprops3[] = {0xc1, 0x6e, 0xf1, 0x77, 0xe, 0xdf, 0x3e, 0x10, 0x9, 0xaf, 0x57, 0x48, 0x3f, 0x5d, 0xdc, - 0x7b, 0xf, 0x4a, 0xb3, 0xee, 0xf0, 0x60, 0xc7, 0x5d, 0x7, 0x10, 0xeb, 0xd5, 0xcc}; - uint8_t bytesprops2[] = {0xd3, 0xa2, 0x96, 0x4f, 0x84, 0x68, 0x8a, 0x33, 0x37, 0x4e, 0xcd, 0x2, 0x15, - 0x81, 0x98, 0xe6, 0xd5, 0xa7, 0x1, 0xd5, 0xb0, 0x9d, 0x3a, 0x8c, 0x64, 0xfb}; - uint8_t bytesprops5[] = {0xd, 0xfb}; - uint8_t bytesprops4[] = {0x4c, 0x95, 0x8c, 0x9a, 0x78, 0x77, 0x64, 0x6a, 0x7e, 0x2e, 0xc9, 0x9e, 0xaf, - 0x63, 0x65, 0x5, 0xad, 0x3f, 0x4f, 0x56, 0x32, 0xd4, 0xbd, 0x73, 0x42, 0x1f}; - uint8_t bytesprops6[] = {0x3a, 0x6, 0xb8, 0xa8, 0x46, 0x38, 0x5a, 0xcc, 0xe3, 0xe5, 0x3d, 0x13, 0xff, - 0x5a, 0xc5, 0x91, 0x80, 0xa8, 0x88, 0xe4, 0xa5, 0xfb, 0x75, 0x28, 0x95, 0xbc}; - uint8_t bytesprops7[] = {0x91, 0x85, 0xc9, 0xc, 0xfa, 0xeb, 0xe5, 0xfb, 0x43, 0x38, 0xb5, - 0xa0, 0x1f, 0x1a, 0x9a, 0xa7, 0xea, 0xd2, 0xdc, 0x54, 0x38}; - uint8_t bytesprops8[] = {0x4, 0x35, 0xae, 0x19, 0xc5, 0xec, 0x1e, 0xef, 0x6e, 0xa4}; - uint8_t bytesprops9[] = {0xa2, 0x68, 0x37, 0x8c, 0x74, 0x7c, 0xca, 0x1c, 0x77, 0x11, 0x1, 0x65, 0x68, - 0xa9, 0x4f, 0x4e, 0x71, 0x8b, 0xcc, 0xfa, 0xdb, 0x91, 0xc1, 0xf6, 0x42, 0x4c}; - uint8_t bytesprops10[] = {0x13, 0x42, 0x66, 0xf2, 0xc9, 0x23, 0xc8, 0x6c, - 0x64, 0x72, 0x2a, 0xd7, 0x5f, 0x10, 0xce, 0xca}; - uint8_t bytesprops11[] = {0x2, 0x7d, 0xfd, 0xfc, 0xd7, 0x51, 0x80, 0xd5, 0x7a, 0xa0, 0x19, 0xd0, 0x54, 0xa4, 0x61, - 0x85, 0x30, 0x8, 0x28, 0xd6, 0xa, 0x2b, 0x61, 0x88, 0x6f, 0x4c, 0x35, 0x8f, 0x2e}; - uint8_t bytesprops12[] = {0xd2, 0xd4, 0xb7, 0x44, 0x4c, 0x8, 0x34, 0x21, 0x5d, - 0x79, 0x5f, 0xea, 0xe8, 0xed, 0x13, 0xe2, 0x43, 0xaf}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23405}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops2}, .v = {29, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20702}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20616}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3019}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31013}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5923}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6507}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27876}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11429}}, - }; - - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25153, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 10517 [("\252",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1})] [PropMessageExpiryInterval 18639,PropMessageExpiryInterval 28021,PropResponseTopic -// "\200\189Z\216w\f\161\181C\217\187\EM",PropRequestProblemInformation 131,PropRequestResponseInformation -// 48,PropServerKeepAlive 14539,PropRetainAvailable 17,PropContentType "*\143\144Tg\215U",PropReceiveMaximum -// 5051,PropAuthenticationData "",PropSubscriptionIdentifierAvailable 70,PropRequestResponseInformation -// 31,PropTopicAlias 29124,PropRequestResponseInformation 52,PropServerKeepAlive -// 13965,PropSubscriptionIdentifierAvailable 44,PropTopicAlias 6091,PropSessionExpiryInterval 11780,PropUserProperty -// "\189e\133\205\194\218\162\170p)!\158\224\SIm\207\&5\128e\154" "e\252\170gv",PropMaximumPacketSize -// 3381,PropAssignedClientIdentifier -// "\t\210c\133\STX(\225\250\DC2a\137\192\180\DLE\242\154\EOTH\238T{\v^A\207",PropMessageExpiryInterval 7236] -TEST(Subscribe5QCTest, Encode88) { - uint8_t pkt[] = {0x82, 0x94, 0x1, 0x29, 0x15, 0x8c, 0x1, 0x2, 0x0, 0x0, 0x48, 0xcf, 0x2, 0x0, 0x0, 0x6d, 0x75, - 0x8, 0x0, 0xc, 0xc8, 0xbd, 0x5a, 0xd8, 0x77, 0xc, 0xa1, 0xb5, 0x43, 0xd9, 0xbb, 0x19, 0x17, 0x83, - 0x19, 0x30, 0x13, 0x38, 0xcb, 0x25, 0x11, 0x3, 0x0, 0x7, 0x2a, 0x8f, 0x90, 0x54, 0x67, 0xd7, 0x55, - 0x21, 0x13, 0xbb, 0x16, 0x0, 0x0, 0x29, 0x46, 0x19, 0x1f, 0x23, 0x71, 0xc4, 0x19, 0x34, 0x13, 0x36, - 0x8d, 0x29, 0x2c, 0x23, 0x17, 0xcb, 0x11, 0x0, 0x0, 0x2e, 0x4, 0x26, 0x0, 0x14, 0xbd, 0x65, 0x85, - 0xcd, 0xc2, 0xda, 0xa2, 0xaa, 0x70, 0x29, 0x21, 0x9e, 0xe0, 0xf, 0x6d, 0xcf, 0x35, 0x80, 0x65, 0x9a, - 0x0, 0x5, 0x65, 0xfc, 0xaa, 0x67, 0x76, 0x27, 0x0, 0x0, 0xd, 0x35, 0x12, 0x0, 0x19, 0x9, 0xd2, - 0x63, 0x85, 0x2, 0x28, 0xe1, 0xfa, 0x12, 0x61, 0x89, 0xc0, 0xb4, 0x10, 0xf2, 0x9a, 0x4, 0x48, 0xee, - 0x54, 0x7b, 0xb, 0x5e, 0x41, 0xcf, 0x2, 0x0, 0x0, 0x1c, 0x44, 0x0, 0x1, 0xfc, 0x1}; - - uint8_t buf[161] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xfc}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xc8, 0xbd, 0x5a, 0xd8, 0x77, 0xc, 0xa1, 0xb5, 0x43, 0xd9, 0xbb, 0x19}; - uint8_t bytesprops1[] = {0x2a, 0x8f, 0x90, 0x54, 0x67, 0xd7, 0x55}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops4[] = {0x65, 0xfc, 0xaa, 0x67, 0x76}; - uint8_t bytesprops3[] = {0xbd, 0x65, 0x85, 0xcd, 0xc2, 0xda, 0xa2, 0xaa, 0x70, 0x29, - 0x21, 0x9e, 0xe0, 0xf, 0x6d, 0xcf, 0x35, 0x80, 0x65, 0x9a}; - uint8_t bytesprops5[] = {0x9, 0xd2, 0x63, 0x85, 0x2, 0x28, 0xe1, 0xfa, 0x12, 0x61, 0x89, 0xc0, 0xb4, - 0x10, 0xf2, 0x9a, 0x4, 0x48, 0xee, 0x54, 0x7b, 0xb, 0x5e, 0x41, 0xcf}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18639}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28021}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14539}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5051}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29124}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13965}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6091}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11780}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3381}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7236}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10517, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 24618 [("\162\&7a\196\249\&0\135*\143\198O\209\148nI",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationMethod "s\"",PropContentType -// "\151\161:\SYN\182l\196#\210\240\136\v\140yS4\DC4\193\204\179\177\174c",PropMaximumQoS 231,PropPayloadFormatIndicator -// 171,PropAuthenticationMethod -// "\148\150\243\143\156\130r\168\FS\199\183\148\SUB\176\233E_\194\249\165\&6\191\246!\210\a{\NUL[\f",PropTopicAlias -// 3944] -TEST(Subscribe5QCTest, Encode89) { - uint8_t pkt[] = {0x82, 0x5c, 0x60, 0x2a, 0x47, 0x15, 0x0, 0x2, 0x73, 0x22, 0x3, 0x0, 0x17, 0x97, 0xa1, 0x3a, - 0x16, 0xb6, 0x6c, 0xc4, 0x23, 0xd2, 0xf0, 0x88, 0xb, 0x8c, 0x79, 0x53, 0x34, 0x14, 0xc1, 0xcc, - 0xb3, 0xb1, 0xae, 0x63, 0x24, 0xe7, 0x1, 0xab, 0x15, 0x0, 0x1e, 0x94, 0x96, 0xf3, 0x8f, 0x9c, - 0x82, 0x72, 0xa8, 0x1c, 0xc7, 0xb7, 0x94, 0x1a, 0xb0, 0xe9, 0x45, 0x5f, 0xc2, 0xf9, 0xa5, 0x36, - 0xbf, 0xf6, 0x21, 0xd2, 0x7, 0x7b, 0x0, 0x5b, 0xc, 0x23, 0xf, 0x68, 0x0, 0xf, 0xa2, 0x37, - 0x61, 0xc4, 0xf9, 0x30, 0x87, 0x2a, 0x8f, 0xc6, 0x4f, 0xd1, 0x94, 0x6e, 0x49, 0x0}; - - uint8_t buf[104] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xa2, 0x37, 0x61, 0xc4, 0xf9, 0x30, 0x87, 0x2a, - 0x8f, 0xc6, 0x4f, 0xd1, 0x94, 0x6e, 0x49}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x73, 0x22}; - uint8_t bytesprops1[] = {0x97, 0xa1, 0x3a, 0x16, 0xb6, 0x6c, 0xc4, 0x23, 0xd2, 0xf0, 0x88, 0xb, - 0x8c, 0x79, 0x53, 0x34, 0x14, 0xc1, 0xcc, 0xb3, 0xb1, 0xae, 0x63}; - uint8_t bytesprops2[] = {0x94, 0x96, 0xf3, 0x8f, 0x9c, 0x82, 0x72, 0xa8, 0x1c, 0xc7, 0xb7, 0x94, 0x1a, 0xb0, 0xe9, - 0x45, 0x5f, 0xc2, 0xf9, 0xa5, 0x36, 0xbf, 0xf6, 0x21, 0xd2, 0x7, 0x7b, 0x0, 0x5b, 0xc}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3944}}, - }; - - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24618, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[217] = {0}; -// SubscribeRequest 32265 [("\188Z\ESCD\172\&2\GSO\235_\175N*$\243\136\224 =\137\169\155\DEL\227\&1",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\203\232q4\EM\v\220\158X\173l\SUB\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable 103,PropReasonString -// "\189\221b\217\174Y\212\151\168\b\173E$S\163\DELw7\175Tw\223\aF",PropWillDelayInterval -// 13033,PropMessageExpiryInterval 25541,PropCorrelationData -// "N\221\138\208\176\nu\157\143\130N_\SYNn\145\148\150\171\"",PropWillDelayInterval 28428,PropMessageExpiryInterval -// 21622,PropRequestProblemInformation 33,PropReceiveMaximum 16827,PropMessageExpiryInterval 8407,PropReasonString -// "\224\&4'7M\r*LN\136\254\237\222\180Jc\249h",PropTopicAlias 11873,PropReceiveMaximum -// 15245,PropRequestResponseInformation 108,PropAuthenticationMethod "u{!\146\234\n~\145>\253",PropServerKeepAlive -// 14260,PropRequestResponseInformation 184,PropMessageExpiryInterval 13662,PropRequestProblemInformation -// 209,PropContentType "|\181\241\162\DC3\166\218\192 \137\130\204pR>\192\&0\152",PropSharedSubscriptionAvailable 51] -TEST(Subscribe5QCTest, Encode90) { - uint8_t pkt[] = { - 0x82, 0xce, 0x1, 0x7e, 0x9, 0x9e, 0x1, 0x2a, 0x67, 0x1f, 0x0, 0x18, 0xbd, 0xdd, 0x62, 0xd9, 0xae, 0x59, 0xd4, - 0x97, 0xa8, 0x8, 0xad, 0x45, 0x24, 0x53, 0xa3, 0x7f, 0x77, 0x37, 0xaf, 0x54, 0x77, 0xdf, 0x7, 0x46, 0x18, 0x0, - 0x0, 0x32, 0xe9, 0x2, 0x0, 0x0, 0x63, 0xc5, 0x9, 0x0, 0x13, 0x4e, 0xdd, 0x8a, 0xd0, 0xb0, 0xa, 0x75, 0x9d, - 0x8f, 0x82, 0x4e, 0x5f, 0x16, 0x6e, 0x91, 0x94, 0x96, 0xab, 0x22, 0x18, 0x0, 0x0, 0x6f, 0xc, 0x2, 0x0, 0x0, - 0x54, 0x76, 0x17, 0x21, 0x21, 0x41, 0xbb, 0x2, 0x0, 0x0, 0x20, 0xd7, 0x1f, 0x0, 0x12, 0xe0, 0x34, 0x27, 0x37, - 0x4d, 0xd, 0x2a, 0x4c, 0x4e, 0x88, 0xfe, 0xed, 0xde, 0xb4, 0x4a, 0x63, 0xf9, 0x68, 0x23, 0x2e, 0x61, 0x21, 0x3b, - 0x8d, 0x19, 0x6c, 0x15, 0x0, 0xa, 0x75, 0x7b, 0x21, 0x92, 0xea, 0xa, 0x7e, 0x91, 0x3e, 0xfd, 0x13, 0x37, 0xb4, - 0x19, 0xb8, 0x2, 0x0, 0x0, 0x35, 0x5e, 0x17, 0xd1, 0x3, 0x0, 0x12, 0x7c, 0xb5, 0xf1, 0xa2, 0x13, 0xa6, 0xda, - 0xc0, 0x20, 0x89, 0x82, 0xcc, 0x70, 0x52, 0x3e, 0xc0, 0x30, 0x98, 0x2a, 0x33, 0x0, 0x19, 0xbc, 0x5a, 0x1b, 0x44, - 0xac, 0x32, 0x1d, 0x4f, 0xeb, 0x5f, 0xaf, 0x4e, 0x2a, 0x24, 0xf3, 0x88, 0xe0, 0x20, 0x3d, 0x89, 0xa9, 0x9b, 0x7f, - 0xe3, 0x31, 0x0, 0x0, 0xd, 0xcb, 0xe8, 0x71, 0x34, 0x19, 0xb, 0xdc, 0x9e, 0x58, 0xad, 0x6c, 0x1a, 0xae, 0x2}; - - uint8_t buf[219] = {0}; - - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xbc, 0x5a, 0x1b, 0x44, 0xac, 0x32, 0x1d, 0x4f, 0xeb, 0x5f, 0xaf, 0x4e, 0x2a, - 0x24, 0xf3, 0x88, 0xe0, 0x20, 0x3d, 0x89, 0xa9, 0x9b, 0x7f, 0xe3, 0x31}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x47, 0x10, 0x8d, 0x63, 0x8d, 0xd}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcb, 0xe8, 0x71, 0x34, 0x19, 0xb, 0xdc, 0x9e, 0x58, 0xad, 0x6c, 0x1a, 0xae}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x10, 0x71, 0xe3, 0xfc, 0xaf, 0xf6, 0x7b, 0x9d, 0xfa, 0x0, 0xe7}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0xbd, 0xdd, 0x62, 0xd9, 0xae, 0x59, 0xd4, 0x97, 0xa8, 0x8, 0xad, 0x45, - 0x24, 0x53, 0xa3, 0x7f, 0x77, 0x37, 0xaf, 0x54, 0x77, 0xdf, 0x7, 0x46}; - uint8_t bytesprops1[] = {0x4e, 0xdd, 0x8a, 0xd0, 0xb0, 0xa, 0x75, 0x9d, 0x8f, 0x82, - 0x4e, 0x5f, 0x16, 0x6e, 0x91, 0x94, 0x96, 0xab, 0x22}; - uint8_t bytesprops2[] = {0xe0, 0x34, 0x27, 0x37, 0x4d, 0xd, 0x2a, 0x4c, 0x4e, - 0x88, 0xfe, 0xed, 0xde, 0xb4, 0x4a, 0x63, 0xf9, 0x68}; - uint8_t bytesprops3[] = {0x75, 0x7b, 0x21, 0x92, 0xea, 0xa, 0x7e, 0x91, 0x3e, 0xfd}; - uint8_t bytesprops4[] = {0x7c, 0xb5, 0xf1, 0xa2, 0x13, 0xa6, 0xda, 0xc0, 0x20, - 0x89, 0x82, 0xcc, 0x70, 0x52, 0x3e, 0xc0, 0x30, 0x98}; + uint8_t topic_filter_s2_bytes[] = {0xaf, 0xe, 0x2e, 0x49, 0x64, 0x5b}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x70, 0xd2, 0x8e, 0x46, 0xb2, 0xf2, 0x52, 0xe9, 0x8a, 0xbc, + 0xfd, 0x24, 0x24, 0x72, 0x8e, 0x16, 0xf4, 0xa7, 0x6b, 0xc3}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x72}; + uint8_t bytesprops1[] = {0x56, 0x6c, 0xaf, 0x7a, 0x27, 0x1d, 0x13, 0xb0, 0x83, 0xee, + 0xc2, 0xc9, 0xf7, 0xa5, 0x34, 0x8f, 0xf0, 0xea, 0xc9}; + uint8_t bytesprops3[] = {0x7d, 0x7, 0xa, 0x6a, 0x1d, 0xbf, 0x55, 0xee, 0xc0, 0xcc, 0x34, 0xd5, 0x2e, 0xee, + 0xb2, 0x6a, 0x7f, 0xff, 0xde, 0xa7, 0xbe, 0x37, 0xda, 0x90, 0x1f, 0x28, 0x1}; + uint8_t bytesprops2[] = {0x7, 0x78, 0xc6, 0xaa, 0xb9, 0x87, 0xf7, 0x3b, 0xfa, 0xf5, 0x46, 0x76, 0xba, 0x57, + 0x18, 0x1, 0x9b, 0xb2, 0x96, 0xdf, 0x16, 0xae, 0xaa, 0x3e, 0x7b, 0x6e, 0x8a}; + uint8_t bytesprops4[] = {0x70, 0xe8, 0x2d, 0x87, 0xf4, 0x34, 0xdc, 0x4f, 0x7b, 0x46, 0xc0, 0x1b, 0x20, 0x7a, + 0xa6, 0x61, 0xd5, 0xb7, 0x85, 0x5a, 0x40, 0x34, 0x84, 0x9b, 0x4, 0x69, 0x79}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13033}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25541}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28428}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21622}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16827}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8407}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11873}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15245}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14260}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13662}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25518}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7849}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29865}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6256}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops2}, .v = {27, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32265, 2, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22666, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7342 [("\RS8\172\211YnUe\216\&6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("~\\\198\&7Ty\GS\206{}\244\164c@{",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("j\227\vg\167<\\S\255\151",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("$S\172",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\174\RS\128=\161\254b\152\&4 \209\226m\237`\SOHcY\162",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\210\179\&8\244\FS\DC2\219W\171\&8!\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("Z\202\&4E\179\143\226E\151\146!\135\216",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\150\&5\226T\150\145THQ\tM\156\165\146Y\245\"\ESC\152YF\252\180\142\222\181\171\175D",SubOptions +// SubscribeRequest 7099 [("\131J\165\202",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\r\242#[",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("+",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\165>^\202\145\206\SOH\DC1\152\r\214\128\148\140",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\220\144\&8\247r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("G=\164\r\202\193\181\145:\160V\n7F/\251\199)\224\DLE\197\239\r",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropServerKeepAlive -// 20872,PropSubscriptionIdentifier 10,PropServerReference "3\157z\229n)",PropCorrelationData -// "G\242\"\SO\177\163\221\223\242",PropSharedSubscriptionAvailable 210] -TEST(Subscribe5QCTest, Encode91) { - uint8_t pkt[] = {0x82, 0xc8, 0x1, 0x1c, 0xae, 0x1c, 0x13, 0x51, 0x88, 0xb, 0xa, 0x1c, 0x0, 0x6, 0x33, 0x9d, 0x7a, - 0xe5, 0x6e, 0x29, 0x9, 0x0, 0x9, 0x47, 0xf2, 0x22, 0xe, 0xb1, 0xa3, 0xdd, 0xdf, 0xf2, 0x2a, 0xd2, - 0x0, 0xa, 0x1e, 0x38, 0xac, 0xd3, 0x59, 0x6e, 0x55, 0x65, 0xd8, 0x36, 0x2, 0x0, 0xf, 0x7e, 0x5c, - 0xc6, 0x37, 0x54, 0x79, 0x1d, 0xce, 0x7b, 0x7d, 0xf4, 0xa4, 0x63, 0x40, 0x7b, 0x2, 0x0, 0xa, 0x6a, - 0xe3, 0xb, 0x67, 0xa7, 0x3c, 0x5c, 0x53, 0xff, 0x97, 0x0, 0x0, 0x3, 0x24, 0x53, 0xac, 0x0, 0x0, - 0x13, 0xae, 0x1e, 0x80, 0x3d, 0xa1, 0xfe, 0x62, 0x98, 0x34, 0x20, 0xd1, 0xe2, 0x6d, 0xed, 0x60, 0x1, - 0x63, 0x59, 0xa2, 0x1, 0x0, 0xc, 0xd2, 0xb3, 0x38, 0xf4, 0x1c, 0x12, 0xdb, 0x57, 0xab, 0x38, 0x21, - 0xba, 0x1, 0x0, 0xd, 0x5a, 0xca, 0x34, 0x45, 0xb3, 0x8f, 0xe2, 0x45, 0x97, 0x92, 0x21, 0x87, 0xd8, - 0x1, 0x0, 0x1d, 0x96, 0x35, 0xe2, 0x54, 0x96, 0x91, 0x54, 0x48, 0x51, 0x9, 0x4d, 0x9c, 0xa5, 0x92, - 0x59, 0xf5, 0x22, 0x1b, 0x98, 0x59, 0x46, 0xfc, 0xb4, 0x8e, 0xde, 0xb5, 0xab, 0xaf, 0x44, 0x1, 0x0, - 0x5, 0xdc, 0x90, 0x38, 0xf7, 0x72, 0x1, 0x0, 0x17, 0x47, 0x3d, 0xa4, 0xd, 0xca, 0xc1, 0xb5, 0x91, - 0x3a, 0xa0, 0x56, 0xa, 0x37, 0x46, 0x2f, 0xfb, 0xc7, 0x29, 0xe0, 0x10, 0xc5, 0xef, 0xd, 0x2}; - - uint8_t buf[213] = {0}; +// QoS0}),("\246\&2\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2})] [PropRetainAvailable 23,PropRequestProblemInformation 43,PropServerReference +// "\149\145Y",PropResponseTopic "\132_\140",PropServerReference "\fz",PropReceiveMaximum 18811,PropRetainAvailable +// 158,PropWildcardSubscriptionAvailable 164,PropTopicAlias 6160,PropAssignedClientIdentifier +// "\214\136\&8\169n\199\207h\134\ETB\190\nL\236J\DC4",PropTopicAlias 2203,PropMessageExpiryInterval +// 26792,PropWildcardSubscriptionAvailable 89,PropRequestProblemInformation 98,PropWillDelayInterval +// 5160,PropResponseTopic +// "\167\254S\214Z7\219\209\b\226`\176\203\195\170JQM\162\139\135\235,",PropRequestProblemInformation +// 200,PropRequestResponseInformation 104,PropRetainAvailable 212,PropServerKeepAlive 9758,PropServerReference +// "\226B\250p\221E\137\146\254\179&\173\249\EOT\213\194\DC4"] +TEST(Subscribe5QCTest, Encode3) { + uint8_t pkt[] = {0x82, 0xa6, 0x1, 0x1b, 0xbb, 0x7a, 0x25, 0x17, 0x17, 0x2b, 0x1c, 0x0, 0x3, 0x95, 0x91, 0x59, 0x8, + 0x0, 0x3, 0x84, 0x5f, 0x8c, 0x1c, 0x0, 0x2, 0xc, 0x7a, 0x21, 0x49, 0x7b, 0x25, 0x9e, 0x28, 0xa4, + 0x23, 0x18, 0x10, 0x12, 0x0, 0x10, 0xd6, 0x88, 0x38, 0xa9, 0x6e, 0xc7, 0xcf, 0x68, 0x86, 0x17, 0xbe, + 0xa, 0x4c, 0xec, 0x4a, 0x14, 0x23, 0x8, 0x9b, 0x2, 0x0, 0x0, 0x68, 0xa8, 0x28, 0x59, 0x17, 0x62, + 0x18, 0x0, 0x0, 0x14, 0x28, 0x8, 0x0, 0x17, 0xa7, 0xfe, 0x53, 0xd6, 0x5a, 0x37, 0xdb, 0xd1, 0x8, + 0xe2, 0x60, 0xb0, 0xcb, 0xc3, 0xaa, 0x4a, 0x51, 0x4d, 0xa2, 0x8b, 0x87, 0xeb, 0x2c, 0x17, 0xc8, 0x19, + 0x68, 0x25, 0xd4, 0x13, 0x26, 0x1e, 0x1c, 0x0, 0x11, 0xe2, 0x42, 0xfa, 0x70, 0xdd, 0x45, 0x89, 0x92, + 0xfe, 0xb3, 0x26, 0xad, 0xf9, 0x4, 0xd5, 0xc2, 0x14, 0x0, 0x4, 0x83, 0x4a, 0xa5, 0xca, 0x2, 0x0, + 0x4, 0xd, 0xf2, 0x23, 0x5b, 0x0, 0x0, 0x1, 0x2b, 0x2, 0x0, 0xe, 0xa5, 0x3e, 0x5e, 0xca, 0x91, + 0xce, 0x1, 0x11, 0x98, 0xd, 0xd6, 0x80, 0x94, 0x8c, 0x0, 0x0, 0x3, 0xf6, 0x32, 0xba, 0x2}; + + uint8_t buf[179] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x1e, 0x38, 0xac, 0xd3, 0x59, 0x6e, 0x55, 0x65, 0xd8, 0x36}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x83, 0x4a, 0xa5, 0xca}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7e, 0x5c, 0xc6, 0x37, 0x54, 0x79, 0x1d, 0xce, - 0x7b, 0x7d, 0xf4, 0xa4, 0x63, 0x40, 0x7b}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd, 0xf2, 0x23, 0x5b}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6a, 0xe3, 0xb, 0x67, 0xa7, 0x3c, 0x5c, 0x53, 0xff, 0x97}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2b}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x24, 0x53, 0xac}; - lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa5, 0x3e, 0x5e, 0xca, 0x91, 0xce, 0x1, 0x11, 0x98, 0xd, 0xd6, 0x80, 0x94, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xae, 0x1e, 0x80, 0x3d, 0xa1, 0xfe, 0x62, 0x98, 0x34, 0x20, - 0xd1, 0xe2, 0x6d, 0xed, 0x60, 0x1, 0x63, 0x59, 0xa2}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xf6, 0x32, 0xba}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xd2, 0xb3, 0x38, 0xf4, 0x1c, 0x12, 0xdb, 0x57, 0xab, 0x38, 0x21, 0xba}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5a, 0xca, 0x34, 0x45, 0xb3, 0x8f, 0xe2, 0x45, 0x97, 0x92, 0x21, 0x87, 0xd8}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x96, 0x35, 0xe2, 0x54, 0x96, 0x91, 0x54, 0x48, 0x51, 0x9, - 0x4d, 0x9c, 0xa5, 0x92, 0x59, 0xf5, 0x22, 0x1b, 0x98, 0x59, - 0x46, 0xfc, 0xb4, 0x8e, 0xde, 0xb5, 0xab, 0xaf, 0x44}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xdc, 0x90, 0x38, 0xf7, 0x72}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x47, 0x3d, 0xa4, 0xd, 0xca, 0xc1, 0xb5, 0x91, 0x3a, 0xa0, 0x56, 0xa, - 0x37, 0x46, 0x2f, 0xfb, 0xc7, 0x29, 0xe0, 0x10, 0xc5, 0xef, 0xd}; - lwmqtt_string_t topic_filter_s9 = {23, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x33, 0x9d, 0x7a, 0xe5, 0x6e, 0x29}; - uint8_t bytesprops1[] = {0x47, 0xf2, 0x22, 0xe, 0xb1, 0xa3, 0xdd, 0xdf, 0xf2}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x95, 0x91, 0x59}; + uint8_t bytesprops1[] = {0x84, 0x5f, 0x8c}; + uint8_t bytesprops2[] = {0xc, 0x7a}; + uint8_t bytesprops3[] = {0xd6, 0x88, 0x38, 0xa9, 0x6e, 0xc7, 0xcf, 0x68, + 0x86, 0x17, 0xbe, 0xa, 0x4c, 0xec, 0x4a, 0x14}; + uint8_t bytesprops4[] = {0xa7, 0xfe, 0x53, 0xd6, 0x5a, 0x37, 0xdb, 0xd1, 0x8, 0xe2, 0x60, 0xb0, + 0xcb, 0xc3, 0xaa, 0x4a, 0x51, 0x4d, 0xa2, 0x8b, 0x87, 0xeb, 0x2c}; + uint8_t bytesprops5[] = {0xe2, 0x42, 0xfa, 0x70, 0xdd, 0x45, 0x89, 0x92, 0xfe, + 0xb3, 0x26, 0xad, 0xf9, 0x4, 0xd5, 0xc2, 0x14}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20872}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18811}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6160}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2203}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26792}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5160}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9758}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7342, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7099, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25785 [("4\DC1\131\219{\253\160\n\151f\226{\218\179",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("F\173\174\178\252\144\161\193\&0H\130c\170,\160\167-)\162",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\230\216\219R\ACK\203\\\EM\206|\151\250\&7",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("7!\245\132~\DC2(\164\v\167p\249O]\EOTx*&\173pP\249\209",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\213\FS\146i\223\DC4\233\DC1\SI\208*_B\198EP\ACK[\226\182)\255",SubOptions {_retainHandling = +// SubscribeRequest 835 [("\160\159FO\167\\r\224\141\226\228-\226\247\r@\206\&1w",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\247P\157\US\255e\250\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe5QCTest, Encode92) { - uint8_t pkt[] = {0x82, 0x78, 0x64, 0xb9, 0x0, 0x0, 0xe, 0x34, 0x11, 0x83, 0xdb, 0x7b, 0xfd, 0xa0, 0xa, 0x97, - 0x66, 0xe2, 0x7b, 0xda, 0xb3, 0x0, 0x0, 0x13, 0x46, 0xad, 0xae, 0xb2, 0xfc, 0x90, 0xa1, 0xc1, - 0x30, 0x48, 0x82, 0x63, 0xaa, 0x2c, 0xa0, 0xa7, 0x2d, 0x29, 0xa2, 0x0, 0x0, 0xd, 0xe6, 0xd8, - 0xdb, 0x52, 0x6, 0xcb, 0x5c, 0x19, 0xce, 0x7c, 0x97, 0xfa, 0x37, 0x1, 0x0, 0x17, 0x37, 0x21, - 0xf5, 0x84, 0x7e, 0x12, 0x28, 0xa4, 0xb, 0xa7, 0x70, 0xf9, 0x4f, 0x5d, 0x4, 0x78, 0x2a, 0x26, - 0xad, 0x70, 0x50, 0xf9, 0xd1, 0x1, 0x0, 0x16, 0xd5, 0x1c, 0x92, 0x69, 0xdf, 0x14, 0xe9, 0x11, - 0xf, 0xd0, 0x2a, 0x5f, 0x42, 0xc6, 0x45, 0x50, 0x6, 0x5b, 0xe2, 0xb6, 0x29, 0xff, 0x2, 0x0, - 0x8, 0xf7, 0x50, 0x9d, 0x1f, 0xff, 0x65, 0xfa, 0xb4, 0x0}; - - uint8_t buf[132] = {0}; - - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x34, 0x11, 0x83, 0xdb, 0x7b, 0xfd, 0xa0, 0xa, 0x97, 0x66, 0xe2, 0x7b, 0xda, 0xb3}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x46, 0xad, 0xae, 0xb2, 0xfc, 0x90, 0xa1, 0xc1, 0x30, 0x48, - 0x82, 0x63, 0xaa, 0x2c, 0xa0, 0xa7, 0x2d, 0x29, 0xa2}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe6, 0xd8, 0xdb, 0x52, 0x6, 0xcb, 0x5c, 0x19, 0xce, 0x7c, 0x97, 0xfa, 0x37}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x37, 0x21, 0xf5, 0x84, 0x7e, 0x12, 0x28, 0xa4, 0xb, 0xa7, 0x70, 0xf9, - 0x4f, 0x5d, 0x4, 0x78, 0x2a, 0x26, 0xad, 0x70, 0x50, 0xf9, 0xd1}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd5, 0x1c, 0x92, 0x69, 0xdf, 0x14, 0xe9, 0x11, 0xf, 0xd0, 0x2a, - 0x5f, 0x42, 0xc6, 0x45, 0x50, 0x6, 0x5b, 0xe2, 0xb6, 0x29, 0xff}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf7, 0x50, 0x9d, 0x1f, 0xff, 0x65, 0xfa, 0xb4}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25785, 6, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 8081 [("\247\197\143\CANr(\SO\230",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS0}),("\183\151u\251Or\149\230`\218\133\NUL\ETX\f",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("%\232\ACKq\200;\197\192\155\162\245|\t(\206\172\a\DELe\148\253\227\200\253\187s\219\179y",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("rp\156\133\138@\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\STX\f\202\217I\195/\218#\168^\229C",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRetainAvailable 96,PropMessageExpiryInterval +// 7158,PropAuthenticationData +// "\ETB^\173{f\146\"\152oK\166\235\161\159\v\182M\rqRoh\154\181\226O\EM^\245",PropPayloadFormatIndicator +// 223,PropSubscriptionIdentifier 12,PropMaximumQoS 231,PropTopicAlias 8619,PropMessageExpiryInterval +// 30952,PropRequestResponseInformation 197,PropWildcardSubscriptionAvailable 255] +TEST(Subscribe5QCTest, Encode5) { + uint8_t pkt[] = {0x82, 0x4d, 0x69, 0x24, 0x39, 0x25, 0x60, 0x2, 0x0, 0x0, 0x1b, 0xf6, 0x16, 0x0, 0x1d, 0x17, + 0x5e, 0xad, 0x7b, 0x66, 0x92, 0x22, 0x98, 0x6f, 0x4b, 0xa6, 0xeb, 0xa1, 0x9f, 0xb, 0xb6, 0x4d, + 0xd, 0x71, 0x52, 0x6f, 0x68, 0x9a, 0xb5, 0xe2, 0x4f, 0x19, 0x5e, 0xf5, 0x1, 0xdf, 0xb, 0xc, + 0x24, 0xe7, 0x23, 0x21, 0xab, 0x2, 0x0, 0x0, 0x78, 0xe8, 0x19, 0xc5, 0x28, 0xff, 0x0, 0xe, + 0x67, 0xb8, 0xaf, 0xa9, 0x57, 0xcf, 0x62, 0x34, 0x4, 0x76, 0x7c, 0x3e, 0xe5, 0x43, 0x1}; + + uint8_t buf[89] = {0}; + + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x67, 0xb8, 0xaf, 0xa9, 0x57, 0xcf, 0x62, 0x34, 0x4, 0x76, 0x7c, 0x3e, 0xe5, 0x43}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x63, 0xa1, 0xc, 0x47, 0x96, 0xce, 0x54, 0xbb, 0x45, 0xaa, - 0x6f, 0x18, 0x2, 0xa8, 0xac, 0xee, 0xf9, 0xd2, 0x9a, 0xd7, - 0x90, 0xee, 0x72, 0xaa, 0x2d, 0xaf, 0x27, 0x68}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x74, 0x4e, 0x53, 0x72, 0x67}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x11, 0x79, 0xa0, 0x42, 0xf3, 0x1f, 0xf, 0xe4, 0x48, 0xda, 0x80, 0x9e, - 0xd2, 0x5b, 0x8c, 0x93, 0xc, 0x33, 0xb1, 0x4, 0x97, 0x94, 0x32, 0x27}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe2, 0xc5, 0xbe, 0x7, 0x29, 0x9c, 0x9b, 0xf6, - 0x9d, 0x7c, 0xf3, 0xb5, 0x5b, 0x54, 0xc7, 0x70}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5c, 0xf8, 0x48, 0x8a, 0x2}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops1[] = {0x2f, 0xe7, 0x6d, 0x13, 0x5d, 0xc4, 0xa0, 0xa3, 0x29, - 0x2e, 0xa, 0x63, 0xda, 0xd, 0x78, 0x63, 0x2d}; - uint8_t bytesprops0[] = {0xc6, 0x3c, 0xe3, 0x2f}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x17, 0x5e, 0xad, 0x7b, 0x66, 0x92, 0x22, 0x98, 0x6f, 0x4b, 0xa6, 0xeb, 0xa1, 0x9f, 0xb, + 0xb6, 0x4d, 0xd, 0x71, 0x52, 0x6f, 0x68, 0x9a, 0xb5, 0xe2, 0x4f, 0x19, 0x5e, 0xf5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops0}, .v = {17, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18623}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30497}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8366}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7158}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8619}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30952}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4638, 6, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26916, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30339 [("\179u\189\US\149]BIh\141\231\&6-\r\DC1Zc\223\\\DC3\163",SubOptions {_retainHandling = +// SubscribeRequest 23203 [("\130\206\197\ETX(;3ie\228\139L\185\152\193\203\DC4\200\v}\b",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\RS\239\NAK.\t\226\168BS\142\163\209\211\134\\Uz\EOTV\129\STX.\ENQ\RS\ETB",SubOptions {_retainHandling = +// QoS1}),("U\v,\200o\aH\192\130\227\236\180=2\240\253\167!\139t\f\173-\140M",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("r\146\230\ESC\129\250\136&\248\195p\140J(\DC2|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\251\175\166\&3\137\173N\196\187T~\DEL\158\245\238\247B\151\139\r\142=\247\EOT/\171E",SubOptions +// QoS0}),("\169\159D\FS\199m]J\SOHG\136Y7r7\160\252\231\185/\172\205N.\193\&9V",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\182\132\145J\160\&3\216-f\DC4X\142\188",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("X\DEL\227P \242\&23\175\NULVC\243jl\150\148B\250m",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\204\171\242\244a7\178\140\138\149\174\201",SubOptions {_retainHandling = SendOnSubscribe, +// QoS0}),("\ESC\229&\185`\246\NULRL\168\216C;\165\167",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\131\241\222xlu'9!6\242\213K\227\&0\234\199\150+d\"\DC2/\145\149i;EV",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SYNr\167\NUL\254\180",SubOptions +// QoS2}),("\t8\146\169\253\156^\157\EM|\141~t\205l\160\ETX\255\137\142v\188\"\DC22",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("U(!\US\174\250\156Z\ESC",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\193\211\192\222m\154\164",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [PropRetainAvailable 242,PropServerReference -// "\DC2\147\&9\ESC\178\DEL\169\DC1\168\172",PropTopicAlias 3260,PropRequestProblemInformation 61,PropServerKeepAlive -// 24137,PropWillDelayInterval 1106,PropRetainAvailable 194,PropMaximumQoS 114,PropTopicAlias 31301,PropUserProperty -// "r\US\227\&3I\138$\229g\240\135\212F\157\142\&6\DC3\NAKw>\243\&5gR\165\231" -// "\t\148\246\163>\ENQ\185\132\&1y\158w\144\151\196\174A*\209\221\235\223E",PropMessageExpiryInterval -// 11966,PropMessageExpiryInterval 7995,PropWillDelayInterval 4193,PropResponseInformation -// "\129C\199\179\199\234\SOH\231\194\132eH?\210ZF\210Ce/\152\209!\217\151\178\205",PropAuthenticationData -// "\n&\253\209\t\211V7\250E\ENQ\228",PropResponseTopic -// "1\181\177\206\164\155?\243q\145\&6\227,\SUB`#\EM\236]\136\178\162\228\\(",PropMaximumQoS -// 7,PropSubscriptionIdentifierAvailable 214,PropMaximumPacketSize 17538,PropPayloadFormatIndicator -// 193,PropSessionExpiryInterval 27816,PropRequestProblemInformation 68,PropMaximumPacketSize -// 19853,PropTopicAliasMaximum 19517,PropReasonString -// "\135\158\251\144m\NUL9\DC1\EM\209\ACK\250=!\135\129\&6\DLE+)\v\190\154\204Y\GSA\217\140",PropRequestProblemInformation -// 99,PropSubscriptionIdentifier 24,PropSubscriptionIdentifierAvailable 200,PropReceiveMaximum 3399] -TEST(Subscribe5QCTest, Encode95) { +// QoS2}),("\US\219\141B\210\224Z\240",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\128\181\150r\134\164",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\146v\DLEM\165!\205`q\245ah.\235f\245#O\214c;\134\203\155\b",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty "O\148)\234\f\SYNf\227\130\194&" +// "\210\168\135\205\202\132#\EOT",PropWillDelayInterval 10640,PropTopicAliasMaximum 24111,PropSubscriptionIdentifier +// 23,PropServerKeepAlive 21621,PropServerReference +// "\248\255\t\NUL\155]\131g8?\216\251\228\199\250yP?\182\133\240i^\234p",PropSharedSubscriptionAvailable +// 247,PropServerKeepAlive 17592,PropAuthenticationMethod +// "\247\222\246\251\&58(\a\229E\185XEx\128\197O\131\FS)\192\253-!\174\SOH\249",PropMaximumPacketSize +// 10655,PropRequestProblemInformation 61,PropCorrelationData +// "\150\170\SOHf\r\176\208\ENQ\205\240\180\a\191h\GS\196<\204\145\US\168\231\210F\149\176\170\&1",PropSessionExpiryInterval +// 16529,PropAuthenticationData +// "\209\159i\191)*\172J\168\&9\232d\239\186\224\133?\242/\174\247%\188\238\US\175\131\181\194",PropCorrelationData +// "yn\222<_3\146a\144&n\204\DC4O\237\205C\CAN\240*\186\235&\225I\188",PropWillDelayInterval 11904,PropContentType +// "\145\150\246\205X\225f\146sU\182\134\155\164~\172Y\182\251\226,>\252\200\177\SO$\136M<",PropAuthenticationData +// "\240@\181\187\&7G",PropPayloadFormatIndicator 120,PropMaximumQoS 55,PropCorrelationData +// "*}/]=\f\GS\147t\133\133\246\184\250\246\NUL\131x\240\207\151\149~6"] +TEST(Subscribe5QCTest, Encode6) { uint8_t pkt[] = { - 0x82, 0x9f, 0x3, 0x76, 0x83, 0xf4, 0x1, 0x25, 0xf2, 0x1c, 0x0, 0xa, 0x12, 0x93, 0x39, 0x1b, 0xb2, 0x7f, 0xa9, - 0x11, 0xa8, 0xac, 0x23, 0xc, 0xbc, 0x17, 0x3d, 0x13, 0x5e, 0x49, 0x18, 0x0, 0x0, 0x4, 0x52, 0x25, 0xc2, 0x24, - 0x72, 0x23, 0x7a, 0x45, 0x26, 0x0, 0x1a, 0x72, 0x1f, 0xe3, 0x33, 0x49, 0x8a, 0x24, 0xe5, 0x67, 0xf0, 0x87, 0xd4, - 0x46, 0x9d, 0x8e, 0x36, 0x13, 0x15, 0x77, 0x3e, 0xf3, 0x35, 0x67, 0x52, 0xa5, 0xe7, 0x0, 0x17, 0x9, 0x94, 0xf6, - 0xa3, 0x3e, 0x5, 0xb9, 0x84, 0x31, 0x79, 0x9e, 0x77, 0x90, 0x97, 0xc4, 0xae, 0x41, 0x2a, 0xd1, 0xdd, 0xeb, 0xdf, - 0x45, 0x2, 0x0, 0x0, 0x2e, 0xbe, 0x2, 0x0, 0x0, 0x1f, 0x3b, 0x18, 0x0, 0x0, 0x10, 0x61, 0x1a, 0x0, 0x1b, - 0x81, 0x43, 0xc7, 0xb3, 0xc7, 0xea, 0x1, 0xe7, 0xc2, 0x84, 0x65, 0x48, 0x3f, 0xd2, 0x5a, 0x46, 0xd2, 0x43, 0x65, - 0x2f, 0x98, 0xd1, 0x21, 0xd9, 0x97, 0xb2, 0xcd, 0x16, 0x0, 0xc, 0xa, 0x26, 0xfd, 0xd1, 0x9, 0xd3, 0x56, 0x37, - 0xfa, 0x45, 0x5, 0xe4, 0x8, 0x0, 0x19, 0x31, 0xb5, 0xb1, 0xce,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 0xab, 0x45, 0x0, 0x0, 0xc, 0xcc, 0xab, 0xf2, 0xf4, 0x61, 0x37, 0xb2, - 0x8c, 0x8a, 0x95, 0xae, 0xc9, 0x2, 0x0, 0x1d, 0x83, 0xf1, 0xde, 0x78, 0x6c, 0x75, 0x27, 0x39, 0x21, 0x36, 0xf2, - 0xd5, 0x4b, 0xe3, 0x30, 0xea, 0xc7, 0x96, 0x2b, 0x64, 0x22, 0x12, 0x2f, 0x91, 0x95, 0x69, 0x3b, 0x45, 0x56, 0x1, - 0x0, 0x6, 0x16, 0x72, 0xa7, 0x0, 0xfe, 0xb4, 0x2, 0x0, 0x7, 0xc1, 0xd3, 0xc0, 0xde, 0x6d, 0x9a, 0xa4, 0x2}; - - uint8_t buf[428] = {0}; - - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xb3, 0x75, 0xbd, 0x1f, 0x95, 0x5d, 0x42, 0x49, 0x68, 0x8d, 0xe7, - 0x36, 0x2d, 0xd, 0x11, 0x5a, 0x63, 0xdf, 0x5c, 0x13, 0xa3}; + 0x82, 0x81, 0x4, 0x5a, 0xa3, 0x9a, 0x2, 0x26, 0x0, 0xb, 0x4f, 0x94, 0x29, 0xea, 0xc, 0x16, 0x66, 0xe3, 0x82, + 0xc2, 0x26, 0x0, 0x8, 0xd2, 0xa8, 0x87, 0xcd, 0xca, 0x84, 0x23, 0x4, 0x18, 0x0, 0x0, 0x29, 0x90, 0x22, 0x5e, + 0x2f, 0xb, 0x17, 0x13, 0x54, 0x75, 0x1c, 0x0, 0x19, 0xf8, 0xff, 0x9, 0x0, 0x9b, 0x5d, 0x83, 0x67, 0x38, 0x3f, + 0xd8, 0xfb, 0xe4, 0xc7, 0xfa, 0x79, 0x50, 0x3f, 0xb6, 0x85, 0xf0, 0x69, 0x5e, 0xea, 0x70, 0x2a, 0xf7, 0x13, 0x44, + 0xb8, 0x15, 0x0, 0x1b, 0xf7, 0xde, 0xf6, 0xfb, 0x35, 0x38, 0x28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x9, 0x55, 0x28, 0x21, 0x1f, 0xae, 0xfa, 0x9c, 0x5a, 0x1b, 0x2, 0x0, 0x8, 0x1f, 0xdb, 0x8d, 0x42, 0xd2, + 0xe0, 0x5a, 0xf0, 0x2, 0x0, 0x6, 0x80, 0xb5, 0x96, 0x72, 0x86, 0xa4, 0x1, 0x0, 0x19, 0x92, 0x76, 0x10, 0x4d, + 0xa5, 0x21, 0xcd, 0x60, 0x71, 0xf5, 0x61, 0x68, 0x2e, 0xeb, 0x66, 0xf5, 0x23, 0x4f, 0xd6, 0x63, 0x3b, 0x86, 0xcb, + 0x9b, 0x8, 0x1}; + + uint8_t buf[526] = {0}; + + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x82, 0xce, 0xc5, 0x3, 0x28, 0x3b, 0x33, 0x69, 0x65, 0xe4, 0x8b, + 0x4c, 0xb9, 0x98, 0xc1, 0xcb, 0x14, 0xc8, 0xb, 0x7d, 0x8}; lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1e, 0xef, 0x15, 0x2e, 0x9, 0xe2, 0xa8, 0x42, 0x53, 0x8e, 0xa3, 0xd1, 0xd3, - 0x86, 0x5c, 0x55, 0x7a, 0x4, 0x56, 0x81, 0x2, 0x2e, 0x5, 0x1e, 0x17}; + uint8_t topic_filter_s1_bytes[] = {0x55, 0xb, 0x2c, 0xc8, 0x6f, 0x7, 0x48, 0xc0, 0x82, 0xe3, 0xec, 0xb4, 0x3d, + 0x32, 0xf0, 0xfd, 0xa7, 0x21, 0x8b, 0x74, 0xc, 0xad, 0x2d, 0x8c, 0x4d}; lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x72, 0x92, 0xe6, 0x1b, 0x81, 0xfa, 0x88, 0x26, - 0xf8, 0xc3, 0x70, 0x8c, 0x4a, 0x28, 0x12, 0x7c}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa9, 0x9f, 0x44, 0x1c, 0xc7, 0x6d, 0x5d, 0x4a, 0x1, 0x47, 0x88, 0x59, 0x37, 0x72, + 0x37, 0xa0, 0xfc, 0xe7, 0xb9, 0x2f, 0xac, 0xcd, 0x4e, 0x2e, 0xc1, 0x39, 0x56}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfb, 0xaf, 0xa6, 0x33, 0x89, 0xad, 0x4e, 0xc4, 0xbb, 0x54, 0x7e, 0x7f, 0x9e, 0xf5, - 0xee, 0xf7, 0x42, 0x97, 0x8b, 0xd, 0x8e, 0x3d, 0xf7, 0x4, 0x2f, 0xab, 0x45}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xb6, 0x84, 0x91, 0x4a, 0xa0, 0x33, 0xd8, 0x2d, 0x66, 0x14, 0x58, 0x8e, 0xbc}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xcc, 0xab, 0xf2, 0xf4, 0x61, 0x37, 0xb2, 0x8c, 0x8a, 0x95, 0xae, 0xc9}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x58, 0x7f, 0xe3, 0x50, 0x20, 0xf2, 0x32, 0x33, 0xaf, 0x0, + 0x56, 0x43, 0xf3, 0x6a, 0x6c, 0x96, 0x94, 0x42, 0xfa, 0x6d}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x83, 0xf1, 0xde, 0x78, 0x6c, 0x75, 0x27, 0x39, 0x21, 0x36, - 0xf2, 0xd5, 0x4b, 0xe3, 0x30, 0xea, 0xc7, 0x96, 0x2b, 0x64, - 0x22, 0x12, 0x2f, 0x91, 0x95, 0x69, 0x3b, 0x45, 0x56}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x1b, 0xe5, 0x26, 0xb9, 0x60, 0xf6, 0x0, 0x52, + 0x4c, 0xa8, 0xd8, 0x43, 0x3b, 0xa5, 0xa7}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x16, 0x72, 0xa7, 0x0, 0xfe, 0xb4}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x9, 0x38, 0x92, 0xa9, 0xfd, 0x9c, 0x5e, 0x9d, 0x19, 0x7c, 0x8d, 0x7e, 0x74, + 0xcd, 0x6c, 0xa0, 0x3, 0xff, 0x89, 0x8e, 0x76, 0xbc, 0x22, 0x12, 0x32}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xc1, 0xd3, 0xc0, 0xde, 0x6d, 0x9a, 0xa4}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x55, 0x28, 0x21, 0x1f, 0xae, 0xfa, 0x9c, 0x5a, 0x1b}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x12, 0x93, 0x39, 0x1b, 0xb2, 0x7f, 0xa9, 0x11, 0xa8, 0xac}; - uint8_t bytesprops2[] = {0x9, 0x94, 0xf6, 0xa3, 0x3e, 0x5, 0xb9, 0x84, 0x31, 0x79, 0x9e, 0x77, - 0x90, 0x97, 0xc4, 0xae, 0x41, 0x2a, 0xd1, 0xdd, 0xeb, 0xdf, 0x45}; - uint8_t bytesprops1[] = {0x72, 0x1f, 0xe3, 0x33, 0x49, 0x8a, 0x24, 0xe5, 0x67, 0xf0, 0x87, 0xd4, 0x46, - 0x9d, 0x8e, 0x36, 0x13, 0x15, 0x77, 0x3e, 0xf3, 0x35, 0x67, 0x52, 0xa5, 0xe7}; - uint8_t bytesprops3[] = {0x81, 0x43, 0xc7, 0xb3, 0xc7, 0xea, 0x1, 0xe7, 0xc2, 0x84, 0x65, 0x48, 0x3f, 0xd2, - 0x5a, 0x46, 0xd2, 0x43, 0x65, 0x2f, 0x98, 0xd1, 0x21, 0xd9, 0x97, 0xb2, 0xcd}; - uint8_t bytesprops4[] = {0xa, 0x26, 0xfd, 0xd1, 0x9, 0xd3, 0x56, 0x37, 0xfa, 0x45, 0x5, 0xe4}; - uint8_t bytesprops5[] = {0x31, 0xb5, 0xb1, 0xce, 0xa4, 0x9b, 0x3f, 0xf3, 0x71, 0x91, 0x36, 0xe3, 0x2c, - 0x1a, 0x60, 0x23, 0x19, 0xec, 0x5d, 0x88, 0xb2, 0xa2, 0xe4, 0x5c, 0x28}; - uint8_t bytesprops6[] = {0x87, 0x9e, 0xfb, 0x90, 0x6d, 0x0, 0x39, 0x11, 0x19, 0xd1, 0x6, 0xfa, 0x3d, 0x21, 0x87, - 0x81, 0x36, 0x10, 0x2b, 0x29, 0xb, 0xbe, 0x9a, 0xcc, 0x59, 0x1d, 0x41, 0xd9, 0x8c}; + uint8_t topic_filter_s8_bytes[] = {0x1f, 0xdb, 0x8d, 0x42, 0xd2, 0xe0, 0x5a, 0xf0}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x80, 0xb5, 0x96, 0x72, 0x86, 0xa4}; + lwmqtt_string_t topic_filter_s9 = {6, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x92, 0x76, 0x10, 0x4d, 0xa5, 0x21, 0xcd, 0x60, 0x71, 0xf5, 0x61, 0x68, 0x2e, + 0xeb, 0x66, 0xf5, 0x23, 0x4f, 0xd6, 0x63, 0x3b, 0x86, 0xcb, 0x9b, 0x8}; + lwmqtt_string_t topic_filter_s10 = {25, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops1[] = {0xd2, 0xa8, 0x87, 0xcd, 0xca, 0x84, 0x23, 0x4}; + uint8_t bytesprops0[] = {0x4f, 0x94, 0x29, 0xea, 0xc, 0x16, 0x66, 0xe3, 0x82, 0xc2, 0x26}; + uint8_t bytesprops2[] = {0xf8, 0xff, 0x9, 0x0, 0x9b, 0x5d, 0x83, 0x67, 0x38, 0x3f, 0xd8, 0xfb, 0xe4, + 0xc7, 0xfa, 0x79, 0x50, 0x3f, 0xb6, 0x85, 0xf0, 0x69, 0x5e, 0xea, 0x70}; + uint8_t bytesprops3[] = {0xf7, 0xde, 0xf6, 0xfb, 0x35, 0x38, 0x28, 0x7, 0xe5, 0x45, 0xb9, 0x58, 0x45, 0x78, + 0x80, 0xc5, 0x4f, 0x83, 0x1c, 0x29, 0xc0, 0xfd, 0x2d, 0x21, 0xae, 0x1, 0xf9}; + uint8_t bytesprops4[] = {0x96, 0xaa, 0x1, 0x66, 0xd, 0xb0, 0xd0, 0x5, 0xcd, 0xf0, 0xb4, 0x7, 0xbf, 0x68, + 0x1d, 0xc4, 0x3c, 0xcc, 0x91, 0x1f, 0xa8, 0xe7, 0xd2, 0x46, 0x95, 0xb0, 0xaa, 0x31}; + uint8_t bytesprops5[] = {0xd1, 0x9f, 0x69, 0xbf, 0x29, 0x2a, 0xac, 0x4a, 0xa8, 0x39, 0xe8, 0x64, 0xef, 0xba, 0xe0, + 0x85, 0x3f, 0xf2, 0x2f, 0xae, 0xf7, 0x25, 0xbc, 0xee, 0x1f, 0xaf, 0x83, 0xb5, 0xc2}; + uint8_t bytesprops6[] = {0x79, 0x6e, 0xde, 0x3c, 0x5f, 0x33, 0x92, 0x61, 0x90, 0x26, 0x6e, 0xcc, 0x14, + 0x4f, 0xed, 0xcd, 0x43, 0x18, 0xf0, 0x2a, 0xba, 0xeb, 0x26, 0xe1, 0x49, 0xbc}; + uint8_t bytesprops7[] = {0x91, 0x96, 0xf6, 0xcd, 0x58, 0xe1, 0x66, 0x92, 0x73, 0x55, 0xb6, 0x86, 0x9b, 0xa4, 0x7e, + 0xac, 0x59, 0xb6, 0xfb, 0xe2, 0x2c, 0x3e, 0xfc, 0xc8, 0xb1, 0xe, 0x24, 0x88, 0x4d, 0x3c}; + uint8_t bytesprops8[] = {0xf0, 0x40, 0xb5, 0xbb, 0x37, 0x47}; + uint8_t bytesprops9[] = {0x2a, 0x7d, 0x2f, 0x5d, 0x3d, 0xc, 0x1d, 0x93, 0x74, 0x85, 0x85, 0xf6, + 0xb8, 0xfa, 0xf6, 0x0, 0x83, 0x78, 0xf0, 0xcf, 0x97, 0x95, 0x7e, 0x36}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3260}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10640}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24111}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21621}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17592}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10655}}, {.prop = (lwmqtt_prop_t)23, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24137}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1106}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31301}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops1}, .v = {23, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11966}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7995}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4193}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17538}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27816}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19853}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19517}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3399}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16529}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11904}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30339, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23203, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25983 [("\NULh]\172\248\158\GS:.\SOH<\\0\204q",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 13111 [("\222\SYN24:\156\202\f\132\ETX\186\240",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\CAN?\208\234\166~,\246\198\198\RS\128\a\167#\ESC\USb\161\FS",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\160\US\153\210\&2\243#\154\167",SubOptions +// QoS1}),("\v\bAF\245\&5\231\181\211\&88\180\244\224q\245\&2\137||\146\&2\ESC\186p`",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("z-Q\ETX\250}\168H\222\137\DC4\"\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\br\NUL\ENQ]\221\ETXkL\190o\238.#\227\230\EM\169wd",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\129\CAN\203\191Y5\132\246\162\129\192XU\"\172S",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe5QCTest, Encode96) { - uint8_t pkt[] = {0x82, 0x4b, 0x65, 0x7f, 0x0, 0x0, 0xf, 0x0, 0x68, 0x5d, 0xac, 0xf8, 0x9e, 0x1d, 0x3a, 0x2e, - 0x1, 0x3c, 0x5c, 0x30, 0xcc, 0x71, 0x2, 0x0, 0x14, 0x18, 0x3f, 0xd0, 0xea, 0xa6, 0x7e, 0x2c, - 0xf6, 0xc6, 0xc6, 0x1e, 0x80, 0x7, 0xa7, 0x23, 0x1b, 0x1f, 0x62, 0xa1, 0x1c, 0x1, 0x0, 0x9, - 0xa0, 0x1f, 0x99, 0xd2, 0x32, 0xf3, 0x23, 0x9a, 0xa7, 0x0, 0x0, 0x10, 0x81, 0x18, 0xcb, 0xbf, - 0x59, 0x35, 0x84, 0xf6, 0xa2, 0x81, 0xc0, 0x58, 0x55, 0x22, 0xac, 0x53, 0x1}; - - uint8_t buf[87] = {0}; +// QoS1}),("\189\224\230\&0x$\EOTbXn\EM)\200\184\154ZeB\a\136Q+\233\158B",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\r\182,I",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("G\130\251\147\twO",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\188",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\222\RS\248\196\163\204P",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\160hI\180~R7W\238",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\174\215\218\172V{\162\237\153\169\144\SO\STXM\190\n\135U\180\173\SYN\244\&5\227$\154\ACK\194\249\249",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropMessageExpiryInterval 6824,PropServerReference "\205{\201\150P\202\142e\f6#5\154",PropMessageExpiryInterval +// 4252,PropSubscriptionIdentifier 22,PropMessageExpiryInterval 4271,PropAssignedClientIdentifier +// "\216\135\ETX/\136\138q_\222?\STX\153\142t5\241\162\195M\162\171\&6N\235o3\247[?",PropRetainAvailable +// 141,PropTopicAliasMaximum 15144,PropSharedSubscriptionAvailable 59,PropServerKeepAlive 26100,PropContentType +// "\176^H\181tT\167\&0\135\186?",PropSubscriptionIdentifier 21,PropPayloadFormatIndicator 171,PropCorrelationData +// "V\242t\188@\DC3\241\212\NUL",PropTopicAliasMaximum 18065,PropSharedSubscriptionAvailable 15] +TEST(Subscribe5QCTest, Encode7) { + uint8_t pkt[] = { + 0x82, 0xac, 0x2, 0x33, 0x37, 0x6e, 0x2, 0x0, 0x0, 0x1a, 0xa8, 0x1c, 0x0, 0xd, 0xcd, 0x7b, 0xc9, 0x96, 0x50, + 0xca, 0x8e, 0x65, 0xc, 0x36, 0x23, 0x35, 0x9a, 0x2, 0x0, 0x0, 0x10, 0x9c, 0xb, 0x16, 0x2, 0x0, 0x0, 0x10, + 0xaf, 0x12, 0x0, 0x1d, 0xd8, 0x87, 0x3, 0x2f, 0x88, 0x8a, 0x71, 0x5f, 0xde, 0x3f, 0x2, 0x99, 0x8e, 0x74, 0x35, + 0xf1, 0xa2, 0xc3, 0x4d, 0xa2, 0xab, 0x36, 0x4e, 0xeb, 0x6f, 0x33, 0xf7, 0x5b, 0x3f, 0x25, 0x8d, 0x22, 0x3b, 0x28, + 0x2a, 0x3b, 0x13, 0x65, 0xf4, 0x3, 0x0, 0xb, 0xb0, 0x5e, 0x48, 0xb5, 0x74, 0x54, 0xa7, 0x30, 0x87, 0xba, 0x3f, + 0xb, 0x15, 0x1, 0xab, 0x9, 0x0, 0x9, 0x56, 0xf2, 0x74, 0xbc, 0x40, 0x13, 0xf1, 0xd4, 0x0, 0x22, 0x46, 0x91, + 0x2a, 0xf, 0x0, 0xc, 0xde, 0x16, 0x32, 0x34, 0x3a, 0x9c, 0xca, 0xc, 0x84, 0x3, 0xba, 0xf0, 0x1, 0x0, 0x1a, + 0xb, 0x8, 0x41, 0x46, 0xf5, 0x35, 0xe7, 0xb5, 0xd3, 0x38, 0x38, 0xb4, 0xf4, 0xe0, 0x71, 0xf5, 0x32, 0x89, 0x7c, + 0x7c, 0x92, 0x32, 0x1b, 0xba, 0x70, 0x60, 0x0, 0x0, 0xd, 0x7a, 0x2d, 0x51, 0x3, 0xfa, 0x7d, 0xa8, 0x48, 0xde, + 0x89, 0x14, 0x22, 0xaa, 0x1, 0x0, 0x14, 0x8, 0x72, 0x0, 0x5, 0x5d, 0xdd, 0x3, 0x6b, 0x4c, 0xbe, 0x6f, 0xee, + 0x2e, 0x23, 0xe3, 0xe6, 0x19, 0xa9, 0x77, 0x64, 0x1, 0x0, 0x19, 0xbd, 0xe0, 0xe6, 0x30, 0x78, 0x24, 0x4, 0x62, + 0x58, 0x6e, 0x19, 0x29, 0xc8, 0xb8, 0x9a, 0x5a, 0x65, 0x42, 0x7, 0x88, 0x51, 0x2b, 0xe9, 0x9e, 0x42, 0x2, 0x0, + 0x4, 0xd, 0xb6, 0x2c, 0x49, 0x2, 0x0, 0x7, 0x47, 0x82, 0xfb, 0x93, 0x9, 0x77, 0x4f, 0x2, 0x0, 0x1, 0xbc, + 0x0, 0x0, 0x7, 0xde, 0x1e, 0xf8, 0xc4, 0xa3, 0xcc, 0x50, 0x0, 0x0, 0x9, 0xa0, 0x68, 0x49, 0xb4, 0x7e, 0x52, + 0x37, 0x57, 0xee, 0x2, 0x0, 0x1e, 0xae, 0xd7, 0xda, 0xac, 0x56, 0x7b, 0xa2, 0xed, 0x99, 0xa9, 0x90, 0xe, 0x2, + 0x4d, 0xbe, 0xa, 0x87, 0x55, 0xb4, 0xad, 0x16, 0xf4, 0x35, 0xe3, 0x24, 0x9a, 0x6, 0xc2, 0xf9, 0xf9, 0x0}; + + uint8_t buf[313] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x0, 0x68, 0x5d, 0xac, 0xf8, 0x9e, 0x1d, 0x3a, - 0x2e, 0x1, 0x3c, 0x5c, 0x30, 0xcc, 0x71}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xde, 0x16, 0x32, 0x34, 0x3a, 0x9c, 0xca, 0xc, 0x84, 0x3, 0xba, 0xf0}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x18, 0x3f, 0xd0, 0xea, 0xa6, 0x7e, 0x2c, 0xf6, 0xc6, 0xc6, - 0x1e, 0x80, 0x7, 0xa7, 0x23, 0x1b, 0x1f, 0x62, 0xa1, 0x1c}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb, 0x8, 0x41, 0x46, 0xf5, 0x35, 0xe7, 0xb5, 0xd3, 0x38, 0x38, 0xb4, 0xf4, + 0xe0, 0x71, 0xf5, 0x32, 0x89, 0x7c, 0x7c, 0x92, 0x32, 0x1b, 0xba, 0x70, 0x60}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa0, 0x1f, 0x99, 0xd2, 0x32, 0xf3, 0x23, 0x9a, 0xa7}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7a, 0x2d, 0x51, 0x3, 0xfa, 0x7d, 0xa8, 0x48, 0xde, 0x89, 0x14, 0x22, 0xaa}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x81, 0x18, 0xcb, 0xbf, 0x59, 0x35, 0x84, 0xf6, - 0xa2, 0x81, 0xc0, 0x58, 0x55, 0x22, 0xac, 0x53}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x8, 0x72, 0x0, 0x5, 0x5d, 0xdd, 0x3, 0x6b, 0x4c, 0xbe, + 0x6f, 0xee, 0x2e, 0x23, 0xe3, 0xe6, 0x19, 0xa9, 0x77, 0x64}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t topic_filter_s4_bytes[] = {0xbd, 0xe0, 0xe6, 0x30, 0x78, 0x24, 0x4, 0x62, 0x58, 0x6e, 0x19, 0x29, 0xc8, + 0xb8, 0x9a, 0x5a, 0x65, 0x42, 0x7, 0x88, 0x51, 0x2b, 0xe9, 0x9e, 0x42}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xd, 0xb6, 0x2c, 0x49}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x47, 0x82, 0xfb, 0x93, 0x9, 0x77, 0x4f}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xbc}; + lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xde, 0x1e, 0xf8, 0xc4, 0xa3, 0xcc, 0x50}; + lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa0, 0x68, 0x49, 0xb4, 0x7e, 0x52, 0x37, 0x57, 0xee}; + lwmqtt_string_t topic_filter_s9 = {9, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xae, 0xd7, 0xda, 0xac, 0x56, 0x7b, 0xa2, 0xed, 0x99, 0xa9, + 0x90, 0xe, 0x2, 0x4d, 0xbe, 0xa, 0x87, 0x55, 0xb4, 0xad, + 0x16, 0xf4, 0x35, 0xe3, 0x24, 0x9a, 0x6, 0xc2, 0xf9, 0xf9}; + lwmqtt_string_t topic_filter_s10 = {30, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0xcd, 0x7b, 0xc9, 0x96, 0x50, 0xca, 0x8e, 0x65, 0xc, 0x36, 0x23, 0x35, 0x9a}; + uint8_t bytesprops1[] = {0xd8, 0x87, 0x3, 0x2f, 0x88, 0x8a, 0x71, 0x5f, 0xde, 0x3f, 0x2, 0x99, 0x8e, 0x74, 0x35, + 0xf1, 0xa2, 0xc3, 0x4d, 0xa2, 0xab, 0x36, 0x4e, 0xeb, 0x6f, 0x33, 0xf7, 0x5b, 0x3f}; + uint8_t bytesprops2[] = {0xb0, 0x5e, 0x48, 0xb5, 0x74, 0x54, 0xa7, 0x30, 0x87, 0xba, 0x3f}; + uint8_t bytesprops3[] = {0x56, 0xf2, 0x74, 0xbc, 0x40, 0x13, 0xf1, 0xd4, 0x0}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6824}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4252}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4271}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15144}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26100}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18065}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25983, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13111, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14533 [("\207u\229\191Dm6]U\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\159\195\128\SOHK\243\248gf\DEL",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("[{\199\214\EMb\b\140H/\140\146\DC3\SYN\141\SOh\251\148\a\145\SOH*\160\190\145\130D\SO/",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\v6\STX\"\b% -// \211\241\184\238\234b\247\174\178w",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\158\143\t\131\211\229\129,\234\193GG\206r\191\150\176\DC2",SubOptions +// SubscribeRequest 22578 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = +// QoS2}),("Y\180\175\251o\184au\195\159\207(+B\f\233\165\201\242\165\130\246Y\187q\CANg\155",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("6\195\241\184/\168\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS0}),("\140\DC3M\195\237\DLEO\231",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRequestProblemInformation -// 251,PropSubscriptionIdentifier 27,PropServerReference "\166",PropServerKeepAlive 26843,PropSubscriptionIdentifier -// 24,PropAssignedClientIdentifier "#\SYN'\154\145\133\138\183\237y\195]rp?\DC3\DC1\164\203\169\r",PropUserProperty -// "iT\ACK\197\191@3\226\DC4\225h\145\247\160\180\238\204\213\a\221c\188*\252" -// "@\226`hV\230I\187\221\150V\144\ESCuV\191",PropMessageExpiryInterval 14849,PropAuthenticationMethod -// "\184\175z\170\154\183\234\144\226\151W\224"] -TEST(Subscribe5QCTest, Encode97) { - uint8_t pkt[] = {0x82, 0xe2, 0x1, 0x38, 0xc5, 0x66, 0x17, 0xfb, 0xb, 0x1b, 0x1c, 0x0, 0x1, 0xa6, 0x13, 0x68, 0xdb, - 0xb, 0x18, 0x12, 0x0, 0x15, 0x23, 0x16, 0x27, 0x9a, 0x91, 0x85, 0x8a, 0xb7, 0xed, 0x79, 0xc3, 0x5d, - 0x72, 0x70, 0x3f, 0x13, 0x11, 0xa4, 0xcb, 0xa9, 0xd, 0x26, 0x0, 0x18, 0x69, 0x54, 0x6, 0xc5, 0xbf, - 0x40, 0x33, 0xe2, 0x14, 0xe1, 0x68, 0x91, 0xf7, 0xa0, 0xb4, 0xee, 0xcc, 0xd5, 0x7, 0xdd, 0x63, 0xbc, - 0x2a, 0xfc, 0x0, 0x10, 0x40, 0xe2, 0x60, 0x68, 0x56, 0xe6, 0x49, 0xbb, 0xdd, 0x96, 0x56, 0x90, 0x1b, - 0x75, 0x56, 0xbf, 0x2, 0x0, 0x0, 0x3a, 0x1, 0x15, 0x0, 0xc, 0xb8, 0xaf, 0x7a, 0xaa, 0x9a, 0xb7, - 0xea, 0x90, 0xe2, 0x97, 0x57, 0xe0, 0x0, 0xa, 0xcf, 0x75, 0xe5, 0xbf, 0x44, 0x6d, 0x36, 0x5d, 0x55, - 0x98, 0x2, 0x0, 0xa, 0x9f, 0xc3, 0x80, 0x1, 0x4b, 0xf3, 0xf8, 0x67, 0x66, 0x7f, 0x0, 0x0, 0x1e, - 0x5b, 0x7b, 0xc7, 0xd6, 0x19, 0x62, 0x8, 0x8c, 0x48, 0x2f, 0x8c, 0x92, 0x13, 0x16, 0x8d, 0xe, 0x68, - 0xfb, 0x94, 0x7, 0x91, 0x1, 0x2a, 0xa0, 0xbe, 0x91, 0x82, 0x44, 0xe, 0x2f, 0x2, 0x0, 0x11, 0xb, - 0x36, 0x2, 0x22, 0x8, 0x25, 0x20, 0xd3, 0xf1, 0xb8, 0xee, 0xea, 0x62, 0xf7, 0xae, 0xb2, 0x77, 0x2, - 0x0, 0x12, 0x9e, 0x8f, 0x9, 0x83, 0xd3, 0xe5, 0x81, 0x2c, 0xea, 0xc1, 0x47, 0x47, 0xce, 0x72, 0xbf, - 0x96, 0xb0, 0x12, 0x0, 0x0, 0x7, 0x36, 0xc3, 0xf1, 0xb8, 0x2f, 0xa8, 0xce, 0x0, 0x0, 0x8, 0x8c, - 0x13, 0x4d, 0xc3, 0xed, 0x10, 0x4f, 0xe7, 0x1}; - - uint8_t buf[239] = {0}; +// QoS2}),("R,\DC1w\SI\227c}",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\134\NUL\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\US6\195Ct\137l\EOT\155\185\230\144\143H\n\vU!\196",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\195T\236\253h\n\197\181\188\199\206\134\174\196\215\FS\165\227'\220\DC1m}\206\164;\249\SOHR",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropMessageExpiryInterval 26993,PropPayloadFormatIndicator 117,PropMaximumQoS 245,PropAuthenticationMethod +// "\196R\165\DC4\SUBV 5e",PropMessageExpiryInterval 26854,PropMessageExpiryInterval 23171,PropResponseInformation +// "\CANh\145Q\246[\212\&5S\177WJ\fA\STX\EM\"\184\f\196\DC4\f7",PropCorrelationData "\171",PropAuthenticationData +// "\174\243\DC3P\181<:w\170\226",PropSubscriptionIdentifier 8,PropServerReference +// "GK\253\187\129\ETXd\240",PropTopicAliasMaximum 3019,PropReasonString "",PropUserProperty +// "\169\218a\DC3|\ETB\216y\DC3\136/\136=GGvdH5>\156\183\203}" "\FSD.;",PropSessionExpiryInterval +// 9051,PropSharedSubscriptionAvailable 97,PropRequestResponseInformation 125,PropContentType +// "\137\255S\254h",PropWillDelayInterval 18039,PropResponseTopic +// "\t\ETXL\138b\200\189\172?\v*\225\228\143z\ESC\231>\217&\231",PropRequestProblemInformation 169,PropTopicAlias +// 8806,PropTopicAliasMaximum 26514,PropWillDelayInterval 11232,PropTopicAliasMaximum 8472,PropReceiveMaximum +// 13639,PropWildcardSubscriptionAvailable 224,PropCorrelationData +// "Cl$9?\DC4k[\129x\181\DLE\233\CANIZF\200",PropPayloadFormatIndicator 94] +TEST(Subscribe5QCTest, Encode8) { + uint8_t pkt[] = { + 0x82, 0xc8, 0x2, 0x58, 0x32, 0xd8, 0x1, 0x2, 0x0, 0x0, 0x69, 0x71, 0x1, 0x75, 0x24, 0xf5, 0x15, 0x0, 0x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14, + 0x6b, 0x5b, 0x81, 0x78, 0xb5, 0x10, 0xe9, 0x18, 0x49, 0x5a, 0x46, 0xc8, 0x1, 0x5e, 0x0, 0x0, 0x2, 0x0, 0x1c, + 0x59, 0xb4, 0xaf, 0xfb, 0x6f, 0xb8, 0x61, 0x75, 0xc3, 0x9f, 0xcf, 0x28, 0x2b, 0x42, 0xc, 0xe9, 0xa5, 0xc9, 0xf2, + 0xa5, 0x82, 0xf6, 0x59, 0xbb, 0x71, 0x18, 0x67, 0x9b, 0x2, 0x0, 0x8, 0x52, 0x2c, 0x11, 0x77, 0xf, 0xe3, 0x63, + 0x7d, 0x1, 0x0, 0x3, 0x86, 0x0, 0xe8, 0x0, 0x0, 0x0, 0x1, 0x0, 0x13, 0x1f, 0x36, 0xc3, 0x43, 0x74, 0x89, + 0x6c, 0x4, 0x9b, 0xb9, 0xe6, 0x90, 0x8f, 0x48, 0xa, 0xb, 0x55, 0x21, 0xc4, 0x1, 0x0, 0x1d, 0xc3, 0x54, 0xec, + 0xfd, 0x68, 0xa, 0xc5, 0xb5, 0xbc, 0xc7, 0xce, 0x86, 0xae, 0xc4, 0xd7, 0x1c, 0xa5, 0xe3, 0x27, 0xdc, 0x11, 0x6d, + 0x7d, 0xce, 0xa4, 0x3b, 0xf9, 0x1, 0x52, 0x2}; + + uint8_t buf[341] = {0}; lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xcf, 0x75, 0xe5, 0xbf, 0x44, 0x6d, 0x36, 0x5d, 0x55, 0x98}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9f, 0xc3, 0x80, 0x1, 0x4b, 0xf3, 0xf8, 0x67, 0x66, 0x7f}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x59, 0xb4, 0xaf, 0xfb, 0x6f, 0xb8, 0x61, 0x75, 0xc3, 0x9f, + 0xcf, 0x28, 0x2b, 0x42, 0xc, 0xe9, 0xa5, 0xc9, 0xf2, 0xa5, + 0x82, 0xf6, 0x59, 0xbb, 0x71, 0x18, 0x67, 0x9b}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5b, 0x7b, 0xc7, 0xd6, 0x19, 0x62, 0x8, 0x8c, 0x48, 0x2f, - 0x8c, 0x92, 0x13, 0x16, 0x8d, 0xe, 0x68, 0xfb, 0x94, 0x7, - 0x91, 0x1, 0x2a, 0xa0, 0xbe, 0x91, 0x82, 0x44, 0xe, 0x2f}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x52, 0x2c, 0x11, 0x77, 0xf, 0xe3, 0x63, 0x7d}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb, 0x36, 0x2, 0x22, 0x8, 0x25, 0x20, 0xd3, 0xf1, - 0xb8, 0xee, 0xea, 0x62, 0xf7, 0xae, 0xb2, 0x77}; - lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x86, 0x0, 0xe8}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9e, 0x8f, 0x9, 0x83, 0xd3, 0xe5, 0x81, 0x2c, 0xea, - 0xc1, 0x47, 0x47, 0xce, 0x72, 0xbf, 0x96, 0xb0, 0x12}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x36, 0xc3, 0xf1, 0xb8, 0x2f, 0xa8, 0xce}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x1f, 0x36, 0xc3, 0x43, 0x74, 0x89, 0x6c, 0x4, 0x9b, 0xb9, + 0xe6, 0x90, 0x8f, 0x48, 0xa, 0xb, 0x55, 0x21, 0xc4}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8c, 0x13, 0x4d, 0xc3, 0xed, 0x10, 0x4f, 0xe7}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xc3, 0x54, 0xec, 0xfd, 0x68, 0xa, 0xc5, 0xb5, 0xbc, 0xc7, + 0xce, 0x86, 0xae, 0xc4, 0xd7, 0x1c, 0xa5, 0xe3, 0x27, 0xdc, + 0x11, 0x6d, 0x7d, 0xce, 0xa4, 0x3b, 0xf9, 0x1, 0x52}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xa6}; - uint8_t bytesprops1[] = {0x23, 0x16, 0x27, 0x9a, 0x91, 0x85, 0x8a, 0xb7, 0xed, 0x79, 0xc3, - 0x5d, 0x72, 0x70, 0x3f, 0x13, 0x11, 0xa4, 0xcb, 0xa9, 0xd}; - uint8_t bytesprops3[] = {0x40, 0xe2, 0x60, 0x68, 0x56, 0xe6, 0x49, 0xbb, - 0xdd, 0x96, 0x56, 0x90, 0x1b, 0x75, 0x56, 0xbf}; - uint8_t bytesprops2[] = {0x69, 0x54, 0x6, 0xc5, 0xbf, 0x40, 0x33, 0xe2, 0x14, 0xe1, 0x68, 0x91, - 0xf7, 0xa0, 0xb4, 0xee, 0xcc, 0xd5, 0x7, 0xdd, 0x63, 0xbc, 0x2a, 0xfc}; - uint8_t bytesprops4[] = {0xb8, 0xaf, 0x7a, 0xaa, 0x9a, 0xb7, 0xea, 0x90, 0xe2, 0x97, 0x57, 0xe0}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26843}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops2}, .v = {16, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14849}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops4}}}, - }; - - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14533, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 1538 -// [("\136v9\252\152\153\179\197P\132F\ETX\176\STX\166RR\222\t\216\163\143\252n\ETB\212",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAssignedClientIdentifier -// "\DC1c1\177\SOHV?\239\218\ESCn\SOHw\209",PropRequestProblemInformation 42,PropServerReference -// "l4\ENQT4\206\180\147\246\133\144\227\196f\246r\156\173\180\185\161\145\ETB",PropTopicAliasMaximum -// 24939,PropSubscriptionIdentifierAvailable 37,PropResponseInformation "_\168\232",PropWillDelayInterval -// 4504,PropContentType "\180\175\DEL\203\188Y\132\218\USV\235\248\DC3\211FW\174\215\&0\145\DC4",PropAuthenticationData -// "\222\129\211\bX\179\228\157\DC2\255W",PropMessageExpiryInterval 29266,PropPayloadFormatIndicator -// 78,PropRequestProblemInformation 39,PropUserProperty "\ETB\219\158\168\n\163\204\231\&6\198\167\136\206\140\132" -// "\235\144\185\206n\202\145\GS\GSr\216Y\233z\235",PropMaximumPacketSize 6755,PropContentType -// "B\198",PropSharedSubscriptionAvailable 221,PropAssignedClientIdentifier -// "\132\186\207sp\139,\148\233\154\137\160",PropTopicAliasMaximum 13715,PropMaximumPacketSize -// 2433,PropSessionExpiryInterval 16981,PropTopicAlias 10270,PropUserProperty -// "\217\SYNH\205\201\163\196\135\237\239z;\167\227\NUL\202\&3\180\132I\199\200 r\156N" -// "\EM\164\182\b\235t&\139\158f\253.\b\ETX\195\219h?w\129\GS\140\141\234",PropPayloadFormatIndicator 167,PropTopicAlias -// 31167,PropMaximumQoS 132,PropWildcardSubscriptionAvailable 6,PropMaximumPacketSize 24806,PropAssignedClientIdentifier -// "",PropSessionExpiryInterval 28383] -TEST(Subscribe5QCTest, Encode98) { - uint8_t pkt[] = { - 0x82, 0xa8, 0x2, 0x6, 0x2, 0x87, 0x2, 0x12, 0x0, 0xe, 0x11, 0x63, 0x31, 0xb1, 0x1, 0x56, 0x3f, 0xef, 0xda, - 0x1b, 0x6e, 0x1, 0x77, 0xd1, 0x17, 0x2a, 0x1c, 0x0, 0x17, 0x6c, 0x34, 0x5, 0x54, 0x34, 0xce, 0xb4, 0x93, 0xf6, - 0x85, 0x90, 0xe3, 0xc4, 0x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 0x8b, 0x9e, 0x66, 0xfd, 0x2e, 0x8, 0x3, 0xc3, 0xdb, 0x68, 0x3f, 0x77, 0x81, 0x1d, 0x8c, 0x8d, - 0xea, 0x1, 0xa7, 0x23, 0x79, 0xbf, 0x24, 0x84, 0x28, 0x6, 0x27, 0x0, 0x0, 0x60, 0xe6, 0x12, 0x0, 0x0, 0x11, - 0x0, 0x0, 0x6e, 0xdf, 0x0, 0x1a, 0x88, 0x76, 0x39, 0xfc, 0x98, 0x99, 0xb3, 0xc5, 0x50, 0x84, 0x46, 0x3, 0xb0, - 0x2, 0xa6, 0x52, 0x52, 0xde, 0x9, 0xd8, 0xa3, 0x8f, 0xfc, 0x6e, 0x17, 0xd4, 0x1}; - - uint8_t buf[309] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x88, 0x76, 0x39, 0xfc, 0x98, 0x99, 0xb3, 0xc5, 0x50, 0x84, 0x46, 0x3, 0xb0, - 0x2, 0xa6, 0x52, 0x52, 0xde, 0x9, 0xd8, 0xa3, 0x8f, 0xfc, 0x6e, 0x17, 0xd4}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x11, 0x63, 0x31, 0xb1, 0x1, 0x56, 0x3f, 0xef, 0xda, 0x1b, 0x6e, 0x1, 0x77, 0xd1}; - uint8_t bytesprops1[] = {0x6c, 0x34, 0x5, 0x54, 0x34, 0xce, 0xb4, 0x93, 0xf6, 0x85, 0x90, 0xe3, - 0xc4, 0x66, 0xf6, 0x72, 0x9c, 0xad, 0xb4, 0xb9, 0xa1, 0x91, 0x17}; - uint8_t bytesprops2[] = {0x5f, 0xa8, 0xe8}; - uint8_t bytesprops3[] = {0xb4, 0xaf, 0x7f, 0xcb, 0xbc, 0x59, 0x84, 0xda, 0x1f, 0x56, 0xeb, - 0xf8, 0x13, 0xd3, 0x46, 0x57, 0xae, 0xd7, 0x30, 0x91, 0x14}; - uint8_t bytesprops4[] = {0xde, 0x81, 0xd3, 0x8, 0x58, 0xb3, 0xe4, 0x9d, 0x12, 0xff, 0x57}; - uint8_t bytesprops6[] = {0xeb, 0x90, 0xb9, 0xce, 0x6e, 0xca, 0x91, 0x1d, 0x1d, 0x72, 0xd8, 0x59, 0xe9, 0x7a, 0xeb}; - uint8_t bytesprops5[] = {0x17, 0xdb, 0x9e, 0xa8, 0xa, 0xa3, 0xcc, 0xe7, 0x36, 0xc6, 0xa7, 0x88, 0xce, 0x8c, 0x84}; - uint8_t bytesprops7[] = {0x42, 0xc6}; - uint8_t bytesprops8[] = {0x84, 0xba, 0xcf, 0x73, 0x70, 0x8b, 0x2c, 0x94, 0xe9, 0x9a, 0x89, 0xa0}; - uint8_t bytesprops10[] = {0x19, 0xa4, 0xb6, 0x8, 0xeb, 0x74, 0x26, 0x8b, 0x9e, 0x66, 0xfd, 0x2e, - 0x8, 0x3, 0xc3, 0xdb, 0x68, 0x3f, 0x77, 0x81, 0x1d, 0x8c, 0x8d, 0xea}; - uint8_t bytesprops9[] = {0xd9, 0x16, 0x48, 0xcd, 0xc9, 0xa3, 0xc4, 0x87, 0xed, 0xef, 0x7a, 0x3b, 0xa7, - 0xe3, 0x0, 0xca, 0x33, 0xb4, 0x84, 0x49, 0xc7, 0xc8, 0x20, 0x72, 0x9c, 0x4e}; - uint8_t bytesprops11[] = {0}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0xc4, 0x52, 0xa5, 0x14, 0x1a, 0x56, 0x20, 0x35, 0x65}; + uint8_t bytesprops1[] = {0x18, 0x68, 0x91, 0x51, 0xf6, 0x5b, 0xd4, 0x35, 0x53, 0xb1, 0x57, 0x4a, + 0xc, 0x41, 0x2, 0x19, 0x22, 0xb8, 0xc, 0xc4, 0x14, 0xc, 0x37}; + uint8_t bytesprops2[] = {0xab}; + uint8_t bytesprops3[] = {0xae, 0xf3, 0x13, 0x50, 0xb5, 0x3c, 0x3a, 0x77, 0xaa, 0xe2}; + uint8_t bytesprops4[] = {0x47, 0x4b, 0xfd, 0xbb, 0x81, 0x3, 0x64, 0xf0}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops7[] = {0x1c, 0x44, 0x2e, 0x3b}; + uint8_t bytesprops6[] = {0xa9, 0xda, 0x61, 0x13, 0x7c, 0x17, 0xd8, 0x79, 0x13, 0x88, 0x2f, 0x88, + 0x3d, 0x47, 0x47, 0x76, 0x64, 0x48, 0x35, 0x3e, 0x9c, 0xb7, 0xcb, 0x7d}; + uint8_t bytesprops8[] = {0x89, 0xff, 0x53, 0xfe, 0x68}; + uint8_t bytesprops9[] = {0x9, 0x3, 0x4c, 0x8a, 0x62, 0xc8, 0xbd, 0xac, 0x3f, 0xb, 0x2a, + 0xe1, 0xe4, 0x8f, 0x7a, 0x1b, 0xe7, 0x3e, 0xd9, 0x26, 0xe7}; + uint8_t bytesprops10[] = {0x43, 0x6c, 0x24, 0x39, 0x3f, 0x14, 0x6b, 0x5b, 0x81, + 0x78, 0xb5, 0x10, 0xe9, 0x18, 0x49, 0x5a, 0x46, 0xc8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24939}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4504}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29266}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops5}, .v = {15, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6755}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13715}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2433}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16981}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10270}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops9}, .v = {24, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31167}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24806}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28383}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26993}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26854}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23171}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3019}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops6}, .v = {4, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9051}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18039}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8806}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26514}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11232}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8472}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13639}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 94}}, }; lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1538, 1, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22578, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22336 [("\239\178\194.\198\235(\167c\190\ETX\155\184\185\245\170}\US\231$\149\255\212",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("3\STXm\179%\DLE\247O\NULI\CAN\t\180\147\136\133\176\195[r\158\131\b\SOE\SYN\139\163\154",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\225\235\137\179 ",PropRequestProblemInformation 71,PropTopicAlias 23140,PropTopicAliasMaximum -// 1797,PropMaximumPacketSize 22929,PropMaximumQoS 129,PropRetainAvailable 26,PropServerReference -// "]\140\148e\196yn\218+U\DEL\DC3\153P\EOT\131fk\EOT",PropReasonString "\136\&9gq\194-",PropSharedSubscriptionAvailable -// 175,PropRequestProblemInformation 36,PropCorrelationData -// "\ESC-\165\237\149\204q\219\"\138u(\249>\SYN\186==\248\155(\254\SUB\139"] -TEST(Subscribe5QCTest, Encode99) { - uint8_t pkt[] = { - 0x82, 0xbc, 0x3, 0x57, 0x40, 0xaa, 0x2, 0x16, 0x0, 0x1b, 0xc9, 0xde, 0xc8, 0xe, 0xe0, 0x20, 0xe6, 0x82, 0x78, - 0xf9, 0x89, 0xcc, 0x5b, 0x5d, 0x85, 0xf2, 0x68, 0x26, 0x42, 0xb0, 0x5e, 0x55, 0x96, 0x7f, 0x41, 0x2d, 0x33, 0x27, - 0x0, 0x0, 0x7d, 0xe7, 0x8, 0x0, 0x11, 0xd4, 0xcd, 0x7e, 0x2a, 0x7a, 0x11, 0x9d, 0x0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93, 0xbf, 0xa0, 0xb0, 0x70, 0x9, 0x71, 0x83, 0x9f, 0x9c, 0x58, - 0x98, 0x3c, 0xa8, 0x8d, 0x8c, 0xe5, 0x2a, 0xc4, 0x5b, 0x2}; - - uint8_t buf[457] = {0}; +// SubscribeRequest 5714 [("Z\154\192",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("n\209\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\236[5",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1}),("+l\193\192-m.\NUL\128\147\191\196\DC4\255 +// \250\233P\183w\192\176F-\192\208\158\201\172\231",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("A\222\209\219\SO\f\212\243or\200\&4",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval +// 28129,PropWillDelayInterval 7503,PropSharedSubscriptionAvailable 212,PropResponseInformation +// "l6\225w\170\&4\241\182",PropSubscriptionIdentifier 12,PropUserProperty +// "\248\202dYf\DEL\153\152x\217\"b\220O\152r\DC4\228\230\209\178P\240\230>" +// "SB\166n;C\173\155Dw\ETX\208\140\180\194\220t\241\213\148\&0\223n\230x\SYNmz\154"] +TEST(Subscribe5QCTest, Encode9) { + uint8_t pkt[] = {0x82, 0x99, 0x1, 0x16, 0x52, 0x54, 0x2, 0x0, 0x0, 0x6d, 0xe1, 0x18, 0x0, 0x0, 0x1d, 0x4f, + 0x2a, 0xd4, 0x1a, 0x0, 0x8, 0x6c, 0x36, 0xe1, 0x77, 0xaa, 0x34, 0xf1, 0xb6, 0xb, 0xc, 0x26, + 0x0, 0x19, 0xf8, 0xca, 0x64, 0x59, 0x66, 0x7f, 0x99, 0x98, 0x78, 0xd9, 0x22, 0x62, 0xdc, 0x4f, + 0x98, 0x72, 0x14, 0xe4, 0xe6, 0xd1, 0xb2, 0x50, 0xf0, 0xe6, 0x3e, 0x0, 0x1d, 0x53, 0x42, 0xa6, + 0x6e, 0x3b, 0x43, 0xad, 0x9b, 0x44, 0x77, 0x3, 0xd0, 0x8c, 0xb4, 0xc2, 0xdc, 0x74, 0xf1, 0xd5, + 0x94, 0x30, 0xdf, 0x6e, 0xe6, 0x78, 0x16, 0x6d, 0x7a, 0x9a, 0x0, 0x3, 0x5a, 0x9a, 0xc0, 0x0, + 0x0, 0x3, 0x6e, 0xd1, 0x83, 0x2, 0x0, 0x3, 0xec, 0x5b, 0x35, 0x1, 0x0, 0x1e, 0x2b, 0x6c, + 0xc1, 0xc0, 0x2d, 0x6d, 0x2e, 0x0, 0x80, 0x93, 0xbf, 0xc4, 0x14, 0xff, 0x20, 0xfa, 0xe9, 0x50, + 0xb7, 0x77, 0xc0, 0xb0, 0x46, 0x2d, 0xc0, 0xd0, 0x9e, 0xc9, 0xac, 0xe7, 0x1, 0x0, 0xc, 0x41, + 0xde, 0xd1, 0xdb, 0xe, 0xc, 0xd4, 0xf3, 0x6f, 0x72, 0xc8, 0x34, 0x1}; + + uint8_t buf[166] = {0}; lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xef, 0xb2, 0xc2, 0x2e, 0xc6, 0xeb, 0x28, 0xa7, 0x63, 0xbe, 0x3, 0x9b, - 0xb8, 0xb9, 0xf5, 0xaa, 0x7d, 0x1f, 0xe7, 0x24, 0x95, 0xff, 0xd4}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x5a, 0x9a, 0xc0}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x33, 0x2, 0x6d, 0xb3, 0x25, 0x10, 0xf7, 0x4f, 0x0, 0x49, - 0x18, 0x9, 0xb4, 0x93, 0x88, 0x85, 0xb0, 0xc3, 0x5b, 0x72, - 0x9e, 0x83, 0x8, 0xe, 0x45, 0x16, 0x8b, 0xa3, 0x9a}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6e, 0xd1, 0x83}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe1, 0xeb, 0x89, 0x3c, 0x53, 0x7f, 0x34, 0xf5, 0xdd, 0x61, 0x44, 0xa7, 0x65, - 0xa, 0xb, 0xdb, 0x9c, 0x22, 0x16, 0x49, 0x4b, 0x4e, 0xa1, 0xa2, 0xd9}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xec, 0x5b, 0x35}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc0, 0xf8, 0x5a, 0xd9, 0xab, 0x3, 0xdc, 0x75, 0x15, 0x75, - 0x8, 0x37, 0x2, 0x28, 0x81, 0x13, 0x1c, 0xdf, 0x68, 0xc3, - 0xc2, 0x88, 0x7, 0x40, 0x1a, 0x39, 0x6c, 0x6f, 0xfb}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x2b, 0x6c, 0xc1, 0xc0, 0x2d, 0x6d, 0x2e, 0x0, 0x80, 0x93, + 0xbf, 0xc4, 0x14, 0xff, 0x20, 0xfa, 0xe9, 0x50, 0xb7, 0x77, + 0xc0, 0xb0, 0x46, 0x2d, 0xc0, 0xd0, 0x9e, 0xc9, 0xac, 0xe7}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xfc, 0x93, 0xbf, 0xa0, 0xb0, 0x70, 0x9, 0x71, 0x83, 0x9f, 0x9c, - 0x58, 0x98, 0x3c, 0xa8, 0x8d, 0x8c, 0xe5, 0x2a, 0xc4, 0x5b}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x41, 0xde, 0xd1, 0xdb, 0xe, 0xc, 0xd4, 0xf3, 0x6f, 0x72, 0xc8, 0x34}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0xc9, 0xde, 0xc8, 0xe, 0xe0, 0x20, 0xe6, 0x82, 0x78, 0xf9, 0x89, 0xcc, 0x5b, 0x5d, - 0x85, 0xf2, 0x68, 0x26, 0x42, 0xb0, 0x5e, 0x55, 0x96, 0x7f, 0x41, 0x2d, 0x33}; - uint8_t bytesprops1[] = {0xd4, 0xcd, 0x7e, 0x2a, 0x7a, 0x11, 0x9d, 0x0, 0xd, - 0x23, 0xd1, 0xb, 0x8c, 0x67, 0x10, 0x2c, 0xdb}; - uint8_t bytesprops2[] = {0xb9, 0x8, 0x18, 0xd3, 0x72, 0x19, 0x42, 0xbc, 0x23, 0x46, 0x7c, - 0x5, 0x1f, 0x1b, 0x4, 0x65, 0x63, 0x27, 0x89, 0x77, 0xb9, 0xa9}; - uint8_t bytesprops3[] = {0x64, 0x86, 0x45, 0xbd}; - uint8_t bytesprops4[] = {0x3d, 0xa9, 0x2e, 0x5e, 0x62, 0xe2, 0x82, 0xec, 0xd5, 0xce, 0x58, - 0x37, 0x83, 0x29, 0xec, 0x45, 0x64, 0x5b, 0xf3, 0x7b, 0x57}; - uint8_t bytesprops5[] = {0xbc, 0x55, 0x1e, 0xf3, 0x89, 0xd8, 0xa1, 0xb9, 0xf7, 0xde, - 0xec, 0x32, 0xa0, 0x6a, 0xd1, 0x1d, 0x17, 0xf1, 0xba, 0xb5}; - uint8_t bytesprops6[] = {0x59, 0x53, 0xdd, 0x5b, 0x7f, 0x50, 0xc8, 0x9c, 0x32}; - uint8_t bytesprops7[] = {0x1d, 0xe3, 0x70, 0xe1, 0xcc, 0x12, 0xee, 0xcf, 0x95, 0x47, 0xcc, 0x34, 0xf, 0x5d, - 0x2d, 0x32, 0x5b, 0x56, 0x2b, 0x54, 0xd1, 0xa0, 0x44, 0xd2, 0x38, 0xf6, 0x5f, 0x39}; - uint8_t bytesprops8[] = {0x5f, 0x42, 0xe2, 0xed, 0xcc, 0xbc, 0x36, 0x22, 0x27, 0x5d, 0x3e, 0xb3, 0x20}; - uint8_t bytesprops9[] = {0x5d, 0x8c, 0x94, 0x65, 0xc4, 0x79, 0x6e, 0xda, 0x2b, 0x55, - 0x7f, 0x13, 0x99, 0x50, 0x4, 0x83, 0x66, 0x6b, 0x4}; - uint8_t bytesprops10[] = {0x88, 0x39, 0x67, 0x71, 0xc2, 0x2d}; - uint8_t bytesprops11[] = {0x1b, 0x2d, 0xa5, 0xed, 0x95, 0xcc, 0x71, 0xdb, 0x22, 0x8a, 0x75, 0x28, - 0xf9, 0x3e, 0x16, 0xba, 0x3d, 0x3d, 0xf8, 0x9b, 0x28, 0xfe, 0x1a, 0x8b}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x6c, 0x36, 0xe1, 0x77, 0xaa, 0x34, 0xf1, 0xb6}; + uint8_t bytesprops2[] = {0x53, 0x42, 0xa6, 0x6e, 0x3b, 0x43, 0xad, 0x9b, 0x44, 0x77, 0x3, 0xd0, 0x8c, 0xb4, 0xc2, + 0xdc, 0x74, 0xf1, 0xd5, 0x94, 0x30, 0xdf, 0x6e, 0xe6, 0x78, 0x16, 0x6d, 0x7a, 0x9a}; + uint8_t bytesprops1[] = {0xf8, 0xca, 0x64, 0x59, 0x66, 0x7f, 0x99, 0x98, 0x78, 0xd9, 0x22, 0x62, 0xdc, + 0x4f, 0x98, 0x72, 0x14, 0xe4, 0xe6, 0xd1, 0xb2, 0x50, 0xf0, 0xe6, 0x3e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32231}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5414}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31183}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27120}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23005}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23140}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1797}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22929}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28129}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7503}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops1}, .v = {29, (char*)&bytesprops2}}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22336, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5714, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 13807 [("wL\191\189\221|G\238\226$\136\tIp\SO\n\STX\165, \246K\185U\237\\",SubOptions +// SubscribeRequest 3531 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\254\134x\175,x\231\DC3\SOHJ\EOT",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\132bW\232H.\t\251\ACK\185\246\221\163",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("T\FS\235=\v;\128q\152\153}\"U[\178",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\184\150",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\190\236)\ENQ@h\184\224\&0",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("j\178B\166\172b\202\203P\STX,'\174\145\243o>\197\223\157\229|5\SOH\220\&94\241",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("BR\DLEz\176\178\218\206\141\160\252]Y\170\218\142\167\ETX\204\229=\r\255UWG",SubOptions {_retainHandling = +// QoS0}),("\240\158)|E\240\&8\229\159#3\US$\GS\163\142\184\204\a\254\249\NAK\212}",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\144\229\227)\143\168?\194\171\204\212\138\180\ETX\176\GS+\SO\254C>bp\150\184\247\144\231 ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\222CJ\178\&0\215~\186\&5\STX/\241\178\136H\207\"",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerKeepAlive 18605,PropMaximumQoS -// 231,PropResponseInformation "\249\200",PropResponseInformation "J\246\210\198k\185wX",PropRetainAvailable -// 78,PropTopicAliasMaximum 17928,PropSubscriptionIdentifierAvailable 87] -TEST(Subsc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, 0x62, 0x70, 0x96, 0xb8, 0xf7, 0x90, - 0xe7, 0x20, 0x2, 0x0, 0x11, 0xde, 0x43, 0x4a, 0xb2, 0x30, 0xd7, 0x7e, 0xba, 0x35, 0x2, 0x2f, 0xf1, - 0xb2, 0x88, 0x48, 0xcf, 0x22, 0x1}; +// QoS2}),(".\US\239\142\182M\DC2\228v\142",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\145\239\128\212\215v\211R\239\248\165M\231oh\163\192PE\213\174\249\165\218\ETB\148",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("'\251\128\148 +// \133P@7h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\v\210V\DLE\245\137\166\n\v!:\NAK\231Y\SYN\215\n\247\191g\147\RS\STX",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("FH\178&\154",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropMaximumPacketSize 8327,PropSubscriptionIdentifierAvailable 142,PropContentType +// "\234VQb\ETB\227\144^\211\173\227\US\238\USE\CAN\149\134A",PropRetainAvailable 227,PropTopicAliasMaximum +// 1282,PropCorrelationData +// "\221i\226\245e\131b\248\157P\DEL\189\145!\ENQ[q\222+\212\SYN\231j\DC4\233\244A",PropAuthenticationMethod +// "\165HfSK.o\RS\169\ESC\238|l\238\134\148<\193\STXa#\198\SO>",PropUserProperty +// "_ws\206\209\223\224\214\207\182\179\147" "",PropMaximumPacketSize 6778,PropTopicAliasMaximum +// 3766,PropSharedSubscriptionAvailable 102,PropResponseTopic "",PropTopicAliasMaximum 4261,PropWillDelayInterval +// 21768,PropContentType +// "\ENQP\171\163\SUBQ\SYNf\225\158\223\214\171\a\r\218\245\231\213\163\DLE_\US\250\167\n1\206$",PropCorrelationData +// "\167\204\190C E\144Y\214\175\139\199r\v",PropServerReference +// "\RS\237\254\DC3\232\138\251c7\154R~\177\v)\170",PropMaximumQoS 8,PropResponseInformation +// "\180I\209d\175\SI?\132U\225)\175\141\179",PropRequestProblemInformation 155,PropTopicAlias +// 13440,PropSubscriptionIdentifierAvailable 115,PropCorrelationData +// "{Ha~\t\220\231\242\226\240G\157\146cY^'\SYN\243Q\211\241",PropReceiveMaximum 4880] +TEST(Subscribe5QCTest, Encode10) { + uint8_t pkt[] = { + 0x82, 0x97, 0x3, 0xd, 0xcb, 0xfb, 0x1, 0x27, 0x0, 0x0, 0x20, 0x87, 0x29, 0x8e, 0x3, 0x0, 0x13, 0xea, 0x56, + 0x51, 0x62, 0x17, 0xe3, 0x90, 0x5e, 0xd3, 0xad, 0xe3, 0x1f, 0xee, 0x1f, 0x45, 0x18, 0x95, 0x86, 0x41, 0x25, 0xe3, + 0x22, 0x5, 0x2, 0x9, 0x0, 0x1b, 0xdd, 0x69, 0xe2, 0xf5, 0x65, 0x83, 0x62, 0xf8, 0x9d, 0x50, 0x7f, 0xbd, 0x91, + 0x21, 0x5, 0x5b, 0x71, 0xde, 0x2b, 0xd4, 0x16, 0xe7, 0x6a, 0x14, 0xe9, 0xf4, 0x41, 0x15, 0x0, 0x18, 0xa5, 0x48, + 0x66, 0x53, 0x4b, 0x2e, 0x6f, 0x1e, 0xa9, 0x1b, 0xee, 0x7c, 0x6c, 0xee, 0x86, 0x94, 0x3c, 0xc1, 0x2, 0x61, 0x23, + 0xc6, 0xe, 0x3e, 0x26, 0x0, 0xc, 0x5f, 0x77, 0x73, 0xce, 0xd1, 0xdf, 0xe0, 0xd6, 0xcf, 0xb6, 0xb3, 0x93, 0x0, + 0x0, 0x27, 0x0, 0x0, 0x1a, 0x7a, 0x22, 0xe, 0xb6, 0x2a, 0x66, 0x8, 0x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xf9, 0x15, 0xd4, 0x7d, 0x2, 0x0, 0xa, 0x2e, 0x1f, 0xef, + 0x8e, 0xb6, 0x4d, 0x12, 0xe4, 0x76, 0x8e, 0x2, 0x0, 0x1a, 0x91, 0xef, 0x80, 0xd4, 0xd7, 0x76, 0xd3, 0x52, 0xef, + 0xf8, 0xa5, 0x4d, 0xe7, 0x6f, 0x68, 0xa3, 0xc0, 0x50, 0x45, 0xd5, 0xae, 0xf9, 0xa5, 0xda, 0x17, 0x94, 0x2, 0x0, + 0xa, 0x27, 0xfb, 0x80, 0x94, 0x20, 0x85, 0x50, 0x40, 0x37, 0x68, 0x2, 0x0, 0x17, 0xb, 0xd2, 0x56, 0x10, 0xf5, + 0x89, 0xa6, 0xa, 0xb, 0x21, 0x3a, 0x15, 0xe7, 0x59, 0x16, 0xd7, 0xa, 0xf7, 0xbf, 0x67, 0x93, 0x1e, 0x2, 0x2, + 0x0, 0x0, 0x0, 0x0, 0x5, 0x46, 0x48, 0xb2, 0x26, 0x9a, 0x2}; - uint8_t buf[220] = {0}; + uint8_t buf[420] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x77, 0x4c, 0xbf, 0xbd, 0xdd, 0x7c, 0x47, 0xee, 0xe2, 0x24, 0x88, 0x9, 0x49, - 0x70, 0xe, 0xa, 0x2, 0xa5, 0x2c, 0x20, 0xf6, 0x4b, 0xb9, 0x55, 0xed, 0x5c}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x54, 0x1c, 0xeb, 0x3d, 0xb, 0x3b, 0x80, 0x71, - 0x98, 0x99, 0x7d, 0x22, 0x55, 0x5b, 0xb2}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xfe, 0x86, 0x78, 0xaf, 0x2c, 0x78, 0xe7, 0x13, 0x1, 0x4a, 0x4}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb8, 0x96}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x84, 0x62, 0x57, 0xe8, 0x48, 0x2e, 0x9, 0xfb, 0x6, 0xb9, 0xf6, 0xdd, 0xa3}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xbe, 0xec, 0x29, 0x5, 0x40, 0x68, 0xb8, 0xe0, 0x30}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf0, 0x9e, 0x29, 0x7c, 0x45, 0xf0, 0x38, 0xe5, 0x9f, 0x23, 0x33, 0x1f, + 0x24, 0x1d, 0xa3, 0x8e, 0xb8, 0xcc, 0x7, 0xfe, 0xf9, 0x15, 0xd4, 0x7d}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x6a, 0xb2, 0x42, 0xa6, 0xac, 0x62, 0xca, 0xcb, 0x50, 0x2, 0x2c, 0x27, 0xae, 0x91, - 0xf3, 0x6f, 0x3e, 0xc5, 0xdf, 0x9d, 0xe5, 0x7c, 0x35, 0x1, 0xdc, 0x39, 0x34, 0xf1}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2e, 0x1f, 0xef, 0x8e, 0xb6, 0x4d, 0x12, 0xe4, 0x76, 0x8e}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x42, 0x52, 0x10, 0x7a, 0xb0, 0xb2, 0xda, 0xce, 0x8d, 0xa0, 0xfc, 0x5d, 0x59, - 0xaa, 0xda, 0x8e, 0xa7, 0x3, 0xcc, 0xe5, 0x3d, 0xd, 0xff, 0x55, 0x57, 0x47}; + uint8_t topic_filter_s5_bytes[] = {0x91, 0xef, 0x80, 0xd4, 0xd7, 0x76, 0xd3, 0x52, 0xef, 0xf8, 0xa5, 0x4d, 0xe7, + 0x6f, 0x68, 0xa3, 0xc0, 0x50, 0x45, 0xd5, 0xae, 0xf9, 0xa5, 0xda, 0x17, 0x94}; lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x90, 0xe5, 0xe3, 0x29, 0x8f, 0xa8, 0x3f, 0xc2, 0xab, 0xcc, - 0xd4, 0x8a, 0xb4, 0x3, 0xb0, 0x1d, 0x2b, 0xe, 0xfe, 0x43, - 0x3e, 0x62, 0x70, 0x96, 0xb8, 0xf7, 0x90, 0xe7, 0x20}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x27, 0xfb, 0x80, 0x94, 0x20, 0x85, 0x50, 0x40, 0x37, 0x68}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xde, 0x43, 0x4a, 0xb2, 0x30, 0xd7, 0x7e, 0xba, 0x35, - 0x2, 0x2f, 0xf1, 0xb2, 0x88, 0x48, 0xcf, 0x22}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xb, 0xd2, 0x56, 0x10, 0xf5, 0x89, 0xa6, 0xa, 0xb, 0x21, 0x3a, 0x15, + 0xe7, 0x59, 0x16, 0xd7, 0xa, 0xf7, 0xbf, 0x67, 0x93, 0x1e, 0x2}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xf9, 0xc8}; - uint8_t bytesprops1[] = {0x4a, 0xf6, 0xd2, 0xc6, 0x6b, 0xb9, 0x77, 0x58}; + uint8_t topic_filter_s8_bytes[] = {0}; + lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x46, 0x48, 0xb2, 0x26, 0x9a}; + lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0xea, 0x56, 0x51, 0x62, 0x17, 0xe3, 0x90, 0x5e, 0xd3, 0xad, + 0xe3, 0x1f, 0xee, 0x1f, 0x45, 0x18, 0x95, 0x86, 0x41}; + uint8_t bytesprops1[] = {0xdd, 0x69, 0xe2, 0xf5, 0x65, 0x83, 0x62, 0xf8, 0x9d, 0x50, 0x7f, 0xbd, 0x91, 0x21, + 0x5, 0x5b, 0x71, 0xde, 0x2b, 0xd4, 0x16, 0xe7, 0x6a, 0x14, 0xe9, 0xf4, 0x41}; + uint8_t bytesprops2[] = {0xa5, 0x48, 0x66, 0x53, 0x4b, 0x2e, 0x6f, 0x1e, 0xa9, 0x1b, 0xee, 0x7c, + 0x6c, 0xee, 0x86, 0x94, 0x3c, 0xc1, 0x2, 0x61, 0x23, 0xc6, 0xe, 0x3e}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops3[] = {0x5f, 0x77, 0x73, 0xce, 0xd1, 0xdf, 0xe0, 0xd6, 0xcf, 0xb6, 0xb3, 0x93}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0x5, 0x50, 0xab, 0xa3, 0x1a, 0x51, 0x16, 0x66, 0xe1, 0x9e, 0xdf, 0xd6, 0xab, 0x7, 0xd, + 0xda, 0xf5, 0xe7, 0xd5, 0xa3, 0x10, 0x5f, 0x1f, 0xfa, 0xa7, 0xa, 0x31, 0xce, 0x24}; + uint8_t bytesprops7[] = {0xa7, 0xcc, 0xbe, 0x43, 0x20, 0x45, 0x90, 0x59, 0xd6, 0xaf, 0x8b, 0xc7, 0x72, 0xb}; + uint8_t bytesprops8[] = {0x1e, 0xed, 0xfe, 0x13, 0xe8, 0x8a, 0xfb, 0x63, + 0x37, 0x9a, 0x52, 0x7e, 0xb1, 0xb, 0x29, 0xaa}; + uint8_t bytesprops9[] = {0xb4, 0x49, 0xd1, 0x64, 0xaf, 0xf, 0x3f, 0x84, 0x55, 0xe1, 0x29, 0xaf, 0x8d, 0xb3}; + uint8_t bytesprops10[] = {0x7b, 0x48, 0x61, 0x7e, 0x9, 0xdc, 0xe7, 0xf2, 0xe2, 0xf0, 0x47, + 0x9d, 0x92, 0x63, 0x59, 0x5e, 0x27, 0x16, 0xf3, 0x51, 0xd3, 0xf1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18605}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17928}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8327}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1282}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops3}, .v = {0, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6778}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3766}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4261}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21768}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13440}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4880}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13807, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3531, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); From 64bcf066a558a1839638fef486d66ceacb3b0941 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 18 Sep 2019 13:01:38 -0700 Subject: [PATCH 11/26] Fixed a couple warnings. --- gentests/app/Main.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 38159de..c8d5e01 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -234,14 +234,14 @@ genSubTest prot i p@(SubscribeRequest pid subs props) = do (concatMap aSub $ zip [0..] subs) where aSub :: (Int, (BL.ByteString, SubOptions)) -> String - aSub (i, (s,_)) = mconcat [ - encodeString ("topic_filter_s" <> show i) s, - "topic_filters[", show i, "] = topic_filter_s", show i, ";\n" + aSub (i', (s,_)) = mconcat [ + encodeString ("topic_filter_s" <> show i') s, + "topic_filters[", show i', "] = topic_filter_s", show i', ";\n" ] - encodeQos = "lwmqtt_qos_t qos_levels[] = {" <> intercalate ", " (map aQ $ zip [0..] subs) <> "};\n" + encodeQos = "lwmqtt_qos_t qos_levels[] = {" <> intercalate ", " (map aQ subs) <> "};\n" where - aQ (i, (_,SubOptions{..})) = qos _subQoS + aQ (_,SubOptions{..}) = qos _subQoS genConnectTest :: ProtocolLevel -> Int -> ConnectRequest -> IO () genConnectTest prot i p@ConnectRequest{..} = do From e2c9f9cc8ad4e75703aec70082a6e8f3bbe467e0 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 18 Sep 2019 13:20:38 -0700 Subject: [PATCH 12/26] Some hlint fixes and other cleanups. --- gentests/app/Main.hs | 105 +++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 60 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index c8d5e01..e2bd39d 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -55,10 +55,10 @@ userFix :: ConnectRequest -> ConnectRequest userFix = ufix . pfix where ufix p@ConnectRequest{..} - | _username == (Just "") = p{_username=Nothing} + | _username == Just "" = p{_username=Nothing} | otherwise = p pfix p@ConnectRequest{..} - | _password == (Just "") = p{_password=Nothing} + | _password == Just "" = p{_password=Nothing} | otherwise = p data Prop = IProp Int String Int @@ -73,7 +73,7 @@ captureProps = map e peW32 i x = IProp i "int32" (fromEnum x) peUTF8 i x = SProp i "str" (0,x) peBin i x = SProp i "str" (0,x) - peVarInt i x = IProp i "varint" x + peVarInt i = IProp i "varint" pePair i k v = UProp i (0,k) (0,v) e (PropPayloadFormatIndicator x) = peW8 0x01 x @@ -123,9 +123,9 @@ genProperties name props = mconcat [ where go :: [String] -> [Prop] -> Int -> [Prop] -> ([String], [Prop]) go l p _ [] = (reverse l, reverse p) - go l p n ((x@IProp{}):xs) = go l (x:p) n xs - go l p n ((SProp i s (_,bs)):xs) = go (newstr n bs:l) (SProp i s (n,bs):p) (n+1) xs - go l p n ((UProp i (_,bs1) (_,bs2)):xs) = go (newstr n bs1 : newstr (n+1) bs2 : l) (UProp i (n,bs1) (n+1,bs2):p) (n+2) xs + go l p n (x@IProp{}:xs) = go l (x:p) n xs + go l p n (SProp i s (_,bs):xs) = go (newstr n bs:l) (SProp i s (n,bs):p) (n+1) xs + go l p n (UProp i (_,bs1) (_,bs2):xs) = go (newstr n bs1 : newstr (n+1) bs2 : l) (UProp i (n,bs1) (n+1,bs2):p) (n+2) xs newstr n s = "uint8_t bytes" <> name <> show n <> "[] = {" <> hexa s <> "};" @@ -140,9 +140,6 @@ genProperties name props = mconcat [ b x xv = "{" <> show (BL.length xv) <> ", (char*)&bytes" <> name <> show x <> "}" - p :: [BL.ByteString] -> [String] - p = map (map (toEnum . fromEnum) . BL.unpack) - encodeString :: String -> BL.ByteString -> String encodeString name bytes = mconcat [ " uint8_t " <> name <> "_bytes[] = {" <> hexa bytes <> "};\n", @@ -150,39 +147,32 @@ encodeString name bytes = mconcat [ ] genPublishTest :: ProtocolLevel -> Int -> PublishRequest -> IO () -genPublishTest prot i p@PublishRequest{..} = do - let e = toByteString prot p - - encTest e - decTest e +genPublishTest prot i p@PublishRequest{..} = + mapM_ (putStrLn . ($toByteString prot p)) [encTest, decTest] where - encTest e = do - putStrLn $ "// " <> show p - putStrLn $ "TEST(Publish" <> shortprot prot <> "QCTest, Encode" <> show i <> ") {" - putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" - - putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" - - putStrLn . mconcat $ [ - encodeString "topic" _pubTopic, - " lwmqtt_message_t msg = lwmqtt_default_message;\n", - " msg.qos = " <> qos _pubQoS <> ";\n", - " msg.retained = " <> bool _pubRetain <> ";\n", - " uint8_t msg_bytes[] = {" <> hexa _pubBody <> "};\n", - " msg.payload = (unsigned char*)&msg_bytes;\n", - " msg.payload_len = " <> show (BL.length _pubBody) <> ";\n\n", - genProperties "props" _pubProps, - " size_t len = 0;\n", - " lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, " <> protlvl prot <> ", ", - bool _pubDup, ", ", show _pubPktID, ", topic, msg, props);\n\n", - " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", - " EXPECT_ARRAY_EQ(pkt, buf, len);", - "}\n" - ] + encTest e = mconcat [ + "// ", show p, "\n", + "TEST(Publish" <> shortprot prot <> "QCTest, Encode" <> show i <> ") {\n", + "uint8_t pkt[] = {" <> hexa e <> "};\n", + "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n", + encodeString "topic" _pubTopic, + "lwmqtt_message_t msg = lwmqtt_default_message;\n", + "msg.qos = " <> qos _pubQoS <> ";\n", + "msg.retained = " <> bool _pubRetain <> ";\n", + "uint8_t msg_bytes[] = {" <> hexa _pubBody <> "};\n", + "msg.payload = (unsigned char*)&msg_bytes;\n", + "msg.payload_len = " <> show (BL.length _pubBody) <> ";\n\n", + genProperties "props" _pubProps, + "size_t len = 0;\n", + "lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, " <> protlvl prot <> ", ", + bool _pubDup, ", ", show _pubPktID, ", topic, msg, props);\n\n", + "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + "EXPECT_ARRAY_EQ(pkt, buf, len);", + "}\n\n" + ] - decTest e = do - putStrLn . mconcat $ [ + decTest e = mconcat [ "// ", show p, "\n", "TEST(Publish" <> shortprot prot <> "QCTest, Decode" <> show i <> ") {\n", "uint8_t pkt[] = {" <> hexa e <> "};\n", @@ -203,21 +193,18 @@ genPublishTest prot i p@PublishRequest{..} = do "EXPECT_EQ(msg.payload_len, ", show (BL.length _pubBody), ");\n", "EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, ", show (BL.length _pubBody), ");\n", "lwmqtt_string_t x = exp_topic;\nx = exp_body;\n", - "}\n" + "}\n\n" ] genSubTest :: ProtocolLevel -> Int -> SubscribeRequest -> IO () genSubTest prot i p@(SubscribeRequest pid subs props) = do let e = toByteString prot p - - putStrLn $ "// " <> show p - putStrLn $ "TEST(Subscribe" <> shortprot prot <> "QCTest, Encode" <> show i <> ") {" - putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" - - putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" - - putStrLn . mconcat $ [ + putStrLn . mconcat $ [ + "// ", show p, "\n", + "TEST(Subscribe", shortprot prot, "QCTest, Encode" <> show i <> ") {\n", + "uint8_t pkt[] = {", hexa e, "};\n\n", + "uint8_t buf[", show (BL.length e + 10), "] = { 0 };\n", encodeFilters, encodeQos, genProperties "props" props, @@ -225,13 +212,13 @@ genSubTest prot i p@(SubscribeRequest pid subs props) = do " lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, ", protlvl prot, ", ", show pid, ", ", show (length subs), ", topic_filters, qos_levels, props);\n\n", " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", - " EXPECT_ARRAY_EQ(pkt, buf, len);" + " EXPECT_ARRAY_EQ(pkt, buf, len);\n", + "}\n" ] - putStrLn "}\n" where encodeFilters = "lwmqtt_string_t topic_filters[" <> show (length subs) <> "];\n" <> - (concatMap aSub $ zip [0..] subs) + concatMap aSub (zip [0..] subs) where aSub :: (Int, (BL.ByteString, SubOptions)) -> String aSub (i', (s,_)) = mconcat [ @@ -246,14 +233,12 @@ genSubTest prot i p@(SubscribeRequest pid subs props) = do genConnectTest :: ProtocolLevel -> Int -> ConnectRequest -> IO () genConnectTest prot i p@ConnectRequest{..} = do let e = toByteString prot p - - putStrLn $ "// " <> show p - putStrLn $ "TEST(Connect" <> shortprot prot <> "QCTest, Encode" <> show i <> ") {" - putStrLn $ " uint8_t pkt[] = {" <> hexa e <> "};" - - putStrLn $ "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n" - putStrLn . mconcat $ [ + "// ", show p, "\n", + "TEST(Connect", shortprot prot, "QCTest, Encode" <> show i <> ") {\n", + "uint8_t pkt[] = {", hexa e, "};\n\n", + "uint8_t buf[", show (BL.length e + 10), "] = { 0 };\n", + genProperties "props" _properties, encodeWill _lastWill, encodeOptions, @@ -261,9 +246,9 @@ genConnectTest prot i p@ConnectRequest{..} = do "lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, " <> protlvl prot <> ", opts, ", if isJust _lastWill then "&will" else "NULL", ");\n\n", "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", - "EXPECT_ARRAY_EQ(pkt, buf, len);" + "EXPECT_ARRAY_EQ(pkt, buf, len);\n", + "}\n" ] - putStrLn "}\n" where encodeWill Nothing = "" From 66e9de13082ec2d0a7279e0e6266a0acc9c4afd7 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 18 Sep 2019 13:21:26 -0700 Subject: [PATCH 13/26] Generated test update with current generator. --- tests/generated.cpp | 7307 ++++++++++++++++++++----------------------- 1 file changed, 3477 insertions(+), 3830 deletions(-) diff --git a/tests/generated.cpp b/tests/generated.cpp index 1d76ce6..9d59501 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,41 +21,45 @@ extern "C" { } \ } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\181m\255\144\250L\DC3iF\146\ACK\157\198\202\ACK\176\195z\141\216e\SYN\176", _pubPktID = 5540, _pubBody = "-\222", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\226\186&N9\161\169\214\183\fO\210\SYNC\190Hj\233\221\189\173D\191", _pubPktID = 1989, _pubBody = +// "P\197\196\209K[\SOH/\132\207R\165\&9\180D\DLE\250_G\130f\DC2)\140kR", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x3d, 0x1d, 0x0, 0x17, 0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, - 0xc6, 0xca, 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0, 0x15, 0xa4, 0x2d, 0xde}; - - uint8_t buf[41] = {0}; - - uint8_t topic_bytes[] = {0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, - 0xc6, 0xca, 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0}; + uint8_t pkt[] = {0x35, 0x35, 0x0, 0x17, 0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, + 0x4f, 0xd2, 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf, 0x7, + 0xc5, 0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, + 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; + + uint8_t buf[65] = {0}; + uint8_t topic_bytes[] = {0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, 0x4f, 0xd2, + 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf}; lwmqtt_string_t topic = {23, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x2d, 0xde}; + uint8_t msg_bytes[] = {0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, + 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 26; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5540, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1989, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\181m\255\144\250L\DC3iF\146\ACK\157\198\202\ACK\176\195z\141\216e\SYN\176", _pubPktID = 5540, _pubBody = "-\222", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\226\186&N9\161\169\214\183\fO\210\SYNC\190Hj\233\221\189\173D\191", _pubPktID = 1989, _pubBody = +// "P\197\196\209K[\SOH/\132\207R\165\&9\180D\DLE\250_G\130f\DC2)\140kR", _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x3d, 0x1d, 0x0, 0x17, 0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, - 0xc6, 0xca, 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0, 0x15, 0xa4, 0x2d, 0xde}; + uint8_t pkt[] = {0x35, 0x35, 0x0, 0x17, 0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, + 0x4f, 0xd2, 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf, 0x7, + 0xc5, 0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, + 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -63,41 +67,41 @@ TEST(Publish311QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, - 0xc6, 0xca, 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0}; + uint8_t exp_topic_bytes[] = {0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, 0x4f, 0xd2, + 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf}; lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2d, 0xde}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_body_bytes[] = {0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, + 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 5540); + EXPECT_EQ(packet_id, 1989); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "|5\229o-\r\179\163\252\150\208^\255(\140Y+\a\226xNy\RS\200\237\233\&5\214", _pubPktID = 0, _pubBody = -// "/\130\238\202\224\230", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\222\145Cc\220\210\226\245x\246qst\249\156\SUB\226\132\137Ys\173(topic.data), 28); - EXPECT_EQ(msg.payload_len, 6); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "#s+\243\184\144t\234lj\248\SO=\182TOG$\130\135YOE+\204", _pubPktID = 9717, _pubBody = "\n}\168", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = ",f", _pubPktID = 3323, _pubBody = +// "\130\170\152", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x35, 0x20, 0x0, 0x19, 0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, - 0x6c, 0x6a, 0xf8, 0xe, 0x3d, 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, - 0x59, 0x4f, 0x45, 0x2b, 0xcc, 0x25, 0xf5, 0xa, 0x7d, 0xa8}; - - uint8_t buf[44] = {0}; + uint8_t pkt[] = {0x3a, 0x9, 0x0, 0x2, 0x2c, 0x66, 0xc, 0xfb, 0x82, 0xaa, 0x98}; - uint8_t topic_bytes[] = {0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, 0x3d, - 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t buf[21] = {0}; + uint8_t topic_bytes[] = {0x2c, 0x66}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa, 0x7d, 0xa8}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x82, 0xaa, 0x98}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 3; @@ -162,18 +162,16 @@ TEST(Publish311QCTest, Encode3) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 9717, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 3323, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "#s+\243\184\144t\234lj\248\SO=\182TOG$\130\135YOE+\204", _pubPktID = 9717, _pubBody = "\n}\168", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = ",f", _pubPktID = 3323, _pubBody = +// "\130\170\152", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x35, 0x20, 0x0, 0x19, 0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, - 0x6c, 0x6a, 0xf8, 0xe, 0x3d, 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, - 0x59, 0x4f, 0x45, 0x2b, 0xcc, 0x25, 0xf5, 0xa, 0x7d, 0xa8}; + uint8_t pkt[] = {0x3a, 0x9, 0x0, 0x2, 0x2c, 0x66, 0xc, 0xfb, 0x82, 0xaa, 0x98}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -181,60 +179,52 @@ TEST(Publish311QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, 0x3d, - 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa, 0x7d, 0xa8}; + uint8_t exp_topic_bytes[] = {0x2c, 0x66}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x82, 0xaa, 0x98}; lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 9717); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 3323); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); EXPECT_EQ(msg.payload_len, 3); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\173\179\129=\155\186E\131\242g\224\149\&5\f\ESCk\250\130", _pubPktID = 696, _pubBody = -// "\210\212B\245\204\143IYw\217p\214\&5\152\133@\ETB{\FS\238\226", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "e\226\145", _pubPktID = 0, _pubBody = +// "\225?\246P\197\165t\243\173C\134\185", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x33, 0x2b, 0x0, 0x12, 0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, 0x67, 0xe0, - 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82, 0x2, 0xb8, 0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, - 0x49, 0x59, 0x77, 0xd9, 0x70, 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; + uint8_t pkt[] = {0x39, 0x11, 0x0, 0x3, 0x65, 0xe2, 0x91, 0xe1, 0x3f, 0xf6, + 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; - uint8_t buf[55] = {0}; - - uint8_t topic_bytes[] = {0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, - 0x67, 0xe0, 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t buf[29] = {0}; + uint8_t topic_bytes[] = {0x65, 0xe2, 0x91}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, 0x77, 0xd9, 0x70, - 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; + uint8_t msg_bytes[] = {0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 12; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 696, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\173\179\129=\155\186E\131\242g\224\149\&5\f\ESCk\250\130", _pubPktID = 696, _pubBody = -// "\210\212B\245\204\143IYw\217p\214\&5\152\133@\ETB{\FS\238\226", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "e\226\145", _pubPktID = 0, _pubBody = +// "\225?\246P\197\165t\243\173C\134\185", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x33, 0x2b, 0x0, 0x12, 0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, 0x67, 0xe0, - 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82, 0x2, 0xb8, 0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, - 0x49, 0x59, 0x77, 0xd9, 0x70, 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; + uint8_t pkt[] = {0x39, 0x11, 0x0, 0x3, 0x65, 0xe2, 0x91, 0xe1, 0x3f, 0xf6, + 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -242,61 +232,52 @@ TEST(Publish311QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, - 0x67, 0xe0, 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, 0x77, 0xd9, 0x70, - 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x65, 0xe2, 0x91}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 696); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "!\189a\ENQ\235r\186\232?!\140O>\201\220\163\133\166!\139i", _pubPktID = 0, _pubBody = -// "\249\159L\166\132\147`Q\206\238\229\138\217\DEL\219\t\243\131\192H\SIJ\168@y", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\191", _pubPktID = 26120, +// _pubBody = "_e(\238\187\252\234\241\201\201\220\163\133\166!\139i", _pubPktID = 0, _pubBody = -// "\249\159L\166\132\147`Q\206\238\229\138\217\DEL\219\t\243\131\192H\SIJ\168@y", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\191", _pubPktID = 26120, +// _pubBody = "_e(\238\187\252\234\241\201(topic.data), 21); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 26120); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\216WQ\"", _pubPktID = 0, _pubBody = -// "\v\225\187\153*%\252qh\193\210\232\r0tw\196\176*\254C", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\tz\186\176\196\148\DC1", _pubPktID +// = 10274, _pubBody = "\199\149\244", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x38, 0x1b, 0x0, 0x4, 0xd8, 0x57, 0x51, 0x22, 0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, - 0x71, 0x68, 0xc1, 0xd2, 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; + uint8_t pkt[] = {0x3a, 0xe, 0x0, 0x7, 0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, 0x11, 0x28, 0x22, 0xc7, 0x95, 0xf4}; - uint8_t buf[39] = {0}; - - uint8_t topic_bytes[] = {0xd8, 0x57, 0x51, 0x22}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t buf[26] = {0}; + uint8_t topic_bytes[] = {0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, 0x11}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, 0xd2, - 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; + uint8_t msg_bytes[] = {0xc7, 0x95, 0xf4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 3; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10274, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\216WQ\"", _pubPktID = 0, _pubBody = -// "\v\225\187\153*%\252qh\193\210\232\r0tw\196\176*\254C", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\tz\186\176\196\148\DC1", _pubPktID +// = 10274, _pubBody = "\199\149\244", _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x38, 0x1b, 0x0, 0x4, 0xd8, 0x57, 0x51, 0x22, 0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, - 0x71, 0x68, 0xc1, 0xd2, 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; + uint8_t pkt[] = {0x3a, 0xe, 0x0, 0x7, 0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, 0x11, 0x28, 0x22, 0xc7, 0x95, 0xf4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -361,54 +336,57 @@ TEST(Publish311QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xd8, 0x57, 0x51, 0x22}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, 0xd2, - 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, 0x11}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc7, 0x95, 0xf4}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 10274); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\130\tw\142", _pubPktID = 9801, -// _pubBody = "\154z+\141\DC3\201)z\n", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "l\GS\SO\SI\176\NAKT\189\t0b\NUL\154#1", _pubPktID = 0, _pubBody = +// "\180v\132PX\145\222\160?9\205\204\241\168\&5<\235\222\160\\\190Tg\128", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x32, 0x11, 0x0, 0x4, 0x82, 0x9, 0x77, 0x8e, 0x26, 0x49, - 0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; - - uint8_t buf[29] = {0}; + uint8_t pkt[] = {0x31, 0x29, 0x0, 0xf, 0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, + 0x0, 0x9a, 0x23, 0x31, 0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, 0x3f, 0x39, 0xcd, + 0xcc, 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; - uint8_t topic_bytes[] = {0x82, 0x9, 0x77, 0x8e}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t buf[53] = {0}; + uint8_t topic_bytes[] = {0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, 0x0, 0x9a, 0x23, 0x31}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, 0x3f, 0x39, 0xcd, 0xcc, + 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 24; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 9801, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\130\tw\142", _pubPktID = 9801, -// _pubBody = "\154z+\141\DC3\201)z\n", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "l\GS\SO\SI\176\NAKT\189\t0b\NUL\154#1", _pubPktID = 0, _pubBody = +// "\180v\132PX\145\222\160?9\205\204\241\168\&5<\235\222\160\\\190Tg\128", _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x32, 0x11, 0x0, 0x4, 0x82, 0x9, 0x77, 0x8e, 0x26, 0x49, - 0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; + uint8_t pkt[] = {0x31, 0x29, 0x0, 0xf, 0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, + 0x0, 0x9a, 0x23, 0x31, 0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, 0x3f, 0x39, 0xcd, + 0xcc, 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -416,59 +394,54 @@ TEST(Publish311QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x82, 0x9, 0x77, 0x8e}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, 0x0, 0x9a, 0x23, 0x31}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, 0x3f, 0x39, 0xcd, 0xcc, + 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 9801); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "W\165\ETX\202d\140Z\185\FSm\158\159\206Gj\177D\DC3\250=", _pubPktID = 0, _pubBody = -// "\204r\156\176\144\163\ESC+\228\214X\196\&6\212\179\NULI\132\128`nQ\153\188\153", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\244_\249R\255\232t\194", _pubPktID +// = 4521, _pubBody = "\213\SOQ\252\167\179#\DEL\SIc\223\EOT\156\210\214\bp", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x39, 0x2f, 0x0, 0x14, 0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, 0x9e, 0x9f, 0xce, - 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d, 0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, - 0x58, 0xc4, 0x36, 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; + uint8_t pkt[] = {0x35, 0x1d, 0x0, 0x8, 0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2, 0x11, 0xa9, 0xd5, 0xe, + 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; - uint8_t buf[59] = {0}; - - uint8_t topic_bytes[] = {0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, - 0x9e, 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t buf[41] = {0}; + uint8_t topic_bytes[] = {0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, 0x58, 0xc4, 0x36, - 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; + uint8_t msg_bytes[] = {0xd5, 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, + 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 4521, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "W\165\ETX\202d\140Z\185\FSm\158\159\206Gj\177D\DC3\250=", _pubPktID = 0, _pubBody = -// "\204r\156\176\144\163\ESC+\228\214X\196\&6\212\179\NULI\132\128`nQ\153\188\153", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\244_\249R\255\232t\194", _pubPktID +// = 4521, _pubBody = "\213\SOQ\252\167\179#\DEL\SIc\223\EOT\156\210\214\bp", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x39, 0x2f, 0x0, 0x14, 0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, 0x9e, 0x9f, 0xce, - 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d, 0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, - 0x58, 0xc4, 0x36, 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; + uint8_t pkt[] = {0x35, 0x1d, 0x0, 0x8, 0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2, 0x11, 0xa9, 0xd5, 0xe, + 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -476,55 +449,61 @@ TEST(Publish311QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, - 0x9e, 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, 0x58, 0xc4, 0x36, - 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + uint8_t exp_topic_bytes[] = {0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd5, 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, + 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + EXPECT_EQ(packet_id, 4521); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\STX", _pubPktID = 30584, _pubBody = -// "u\219\"\173\243\187\226Z\193\t\210\"\201K)", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "a\239\170\203|\"\t\198g\b\v[V\ETXkc\GS+\205\&5Q13M\196E", _pubPktID = 21638, _pubBody = +// "\NAK\153\221\DC3\250(2\DC2\166z\179\183Z\205>5\158\160\245", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x3b, 0x14, 0x0, 0x1, 0x2, 0x77, 0x78, 0x75, 0xdb, 0x22, 0xad, - 0xf3, 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; - - uint8_t buf[32] = {0}; - - uint8_t topic_bytes[] = {0x2}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x31, 0x0, 0x1a, 0x61, 0xef, 0xaa, 0xcb, 0x7c, 0x22, 0x9, 0xc6, 0x67, + 0x8, 0xb, 0x5b, 0x56, 0x3, 0x6b, 0x63, 0x1d, 0x2b, 0xcd, 0x35, 0x51, 0x31, + 0x33, 0x4d, 0xc4, 0x45, 0x54, 0x86, 0x15, 0x99, 0xdd, 0x13, 0xfa, 0x28, 0x32, + 0x12, 0xa6, 0x7a, 0xb3, 0xb7, 0x5a, 0xcd, 0x3e, 0x35, 0x9e, 0xa0, 0xf5}; + + uint8_t buf[61] = {0}; + uint8_t topic_bytes[] = {0x61, 0xef, 0xaa, 0xcb, 0x7c, 0x22, 0x9, 0xc6, 0x67, 0x8, 0xb, 0x5b, 0x56, + 0x3, 0x6b, 0x63, 0x1d, 0x2b, 0xcd, 0x35, 0x51, 0x31, 0x33, 0x4d, 0xc4, 0x45}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x75, 0xdb, 0x22, 0xad, 0xf3, 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; + uint8_t msg_bytes[] = {0x15, 0x99, 0xdd, 0x13, 0xfa, 0x28, 0x32, 0x12, 0xa6, 0x7a, + 0xb3, 0xb7, 0x5a, 0xcd, 0x3e, 0x35, 0x9e, 0xa0, 0xf5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30584, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 21638, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\STX", _pubPktID = 30584, _pubBody = -// "u\219\"\173\243\187\226Z\193\t\210\"\201K)", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "a\239\170\203|\"\t\198g\b\v[V\ETXkc\GS+\205\&5Q13M\196E", _pubPktID = 21638, _pubBody = +// "\NAK\153\221\DC3\250(2\DC2\166z\179\183Z\205>5\158\160\245", _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x3b, 0x14, 0x0, 0x1, 0x2, 0x77, 0x78, 0x75, 0xdb, 0x22, 0xad, - 0xf3, 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; + uint8_t pkt[] = {0x3d, 0x31, 0x0, 0x1a, 0x61, 0xef, 0xaa, 0xcb, 0x7c, 0x22, 0x9, 0xc6, 0x67, + 0x8, 0xb, 0x5b, 0x56, 0x3, 0x6b, 0x63, 0x1d, 0x2b, 0xcd, 0x35, 0x51, 0x31, + 0x33, 0x4d, 0xc4, 0x45, 0x54, 0x86, 0x15, 0x99, 0xdd, 0x13, 0xfa, 0x28, 0x32, + 0x12, 0xa6, 0x7a, 0xb3, 0xb7, 0x5a, 0xcd, 0x3e, 0x35, 0x9e, 0xa0, 0xf5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -532,53 +511,62 @@ TEST(Publish311QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x2}; - lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x75, 0xdb, 0x22, 0xad, 0xf3, 0xbb, 0xe2, 0x5a, 0xc1, 0x9, 0xd2, 0x22, 0xc9, 0x4b, 0x29}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x61, 0xef, 0xaa, 0xcb, 0x7c, 0x22, 0x9, 0xc6, 0x67, 0x8, 0xb, 0x5b, 0x56, + 0x3, 0x6b, 0x63, 0x1d, 0x2b, 0xcd, 0x35, 0x51, 0x31, 0x33, 0x4d, 0xc4, 0x45}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x15, 0x99, 0xdd, 0x13, 0xfa, 0x28, 0x32, 0x12, 0xa6, 0x7a, + 0xb3, 0xb7, 0x5a, 0xcd, 0x3e, 0x35, 0x9e, 0xa0, 0xf5}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 30584); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 21638); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "E_/\183|O\206\131\173f\212\204", -// _pubPktID = 31613, _pubBody = "\155\216/Ef", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "3\DC2\163\160\US\252\129\206\EMa\SYN\ESC\248J%\210\t0\224\159T\165\137&\153", _pubPktID = 14459, _pubBody = +// "\161;R\191\DC4\212,\ETB\168<\r}\244\250\&6\145_\153\241\218\175\133\NAK\SO\234\f", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x32, 0x15, 0x0, 0xc, 0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, - 0xad, 0x66, 0xd4, 0xcc, 0x7b, 0x7d, 0x9b, 0xd8, 0x2f, 0x45, 0x66}; - - uint8_t buf[33] = {0}; - - uint8_t topic_bytes[] = {0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x37, 0x0, 0x19, 0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, + 0x1b, 0xf8, 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99, 0x38, + 0x7b, 0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, 0xfa, + 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; + + uint8_t buf[67] = {0}; + uint8_t topic_bytes[] = {0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, 0xf8, + 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x9b, 0xd8, 0x2f, 0x45, 0x66}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, + 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + msg.payload_len = 26; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31613, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 14459, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "E_/\183|O\206\131\173f\212\204", -// _pubPktID = 31613, _pubBody = "\155\216/Ef", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "3\DC2\163\160\US\252\129\206\EMa\SYN\ESC\248J%\210\t0\224\159T\165\137&\153", _pubPktID = 14459, _pubBody = +// "\161;R\191\DC4\212,\ETB\168<\r}\244\250\&6\145_\153\241\218\175\133\NAK\SO\234\f", _pubProps = []} TEST(Publish311QCTest, Decode10) { - uint8_t pkt[] = {0x32, 0x15, 0x0, 0xc, 0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, - 0xad, 0x66, 0xd4, 0xcc, 0x7b, 0x7d, 0x9b, 0xd8, 0x2f, 0x45, 0x66}; + uint8_t pkt[] = {0x35, 0x37, 0x0, 0x19, 0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, + 0x1b, 0xf8, 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99, 0x38, + 0x7b, 0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, 0xfa, + 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -586,164 +574,136 @@ TEST(Publish311QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9b, 0xd8, 0x2f, 0x45, 0x66}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, 0xf8, + 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, + 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 31613); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 14459); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\181m\255\144\250L\DC3iF\146\ACK\157\198\202\ACK\176\195z\141\216e\SYN\176", _pubPktID = 5540, _pubBody = "-\222", -// _pubProps = [PropMessageExpiryInterval 31218,PropMessageExpiryInterval 6930,PropSessionExpiryInterval -// 32694,PropUserProperty "\155 N\153]\236?\192FZu}\139L\176m\189\211Jq\183~\202\t\159" -// "!\\\179x\147\242_",PropSubscriptionIdentifier 6,PropSubscriptionIdentifierAvailable -// 171,PropRequestResponseInformation 68,PropRetainAvailable 146,PropMaximumPacketSize -// 18652,PropRequestResponseInformation 207,PropSubscriptionIdentifierAvailable 232,PropMaximumPacketSize -// 26180,PropTopicAlias 20402,PropMessageExpiryInterval 15307,PropUserProperty "\ENQ\247G" -// "xK+e\211r\SO\192]k\203\DC1\170in\NUL",PropAssignedClientIdentifier -// "\CANH\224A}S\SUBLe^1\150\227)_uM\190\232(",PropResponseTopic "Ql\133\206l",PropUserProperty -// "\214\NUL\146\136\192#(l" "\189\155\DC3\218b;\154\142\187\169t3$U\189\RS\249\202\232:i",PropAuthenticationData -// "\171\190`\236\157\185\192Q\246\245x\216M\241\ETXB\233d\137",PropResponseTopic -// "\148\208K\143r3?\247,v\230\171@F\162",PropMessageExpiryInterval 18906,PropRequestProblemInformation -// 117,PropPayloadFormatIndicator 196,PropSessionExpiryInterval 9189,PropWildcardSubscriptionAvailable -// 26,PropRequestResponseInformation 184,PropResponseTopic "\149\&4K",PropResponseInformation -// "\175;\a,C\155\t\178\RSe\172\192\201n\146\138\164d\DEL\184X\216\201\224y\184\206\v",PropPayloadFormatIndicator -// 172,PropRetainAvailable 73]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\226\186&N9\161\169\214\183\fO\210\SYNC\190Hj\233\221\189\173D\191", _pubPktID = 1989, _pubBody = +// "P\197\196\209K[\SOH/\132\207R\165\&9\180D\DLE\250_G\130f\DC2)\140kR", _pubProps = [PropResponseTopic +// "\225k\246\nM\143\253\170\FS\159\167\132G\185\152\160\223\196\218\223\217\252\137\223\157\DC2",PropRequestProblemInformation +// 123,PropTopicAlias 9167,PropReceiveMaximum 9103,PropRequestResponseInformation 66,PropMaximumQoS 202,PropUserProperty +// "\245\140L\167\136,6\243\248\200\229\211p'\139\t\CAN4\144\170\&5st\202\235\198o" +// "\159\133\232\&9\186?\GS9b\NAK\167\182\148\130\141\238=\152\217y\174\230\FSZi\235@\SI\129\198",PropSubscriptionIdentifier +// 15,PropUserProperty "\131\244\131Q\ENQ\ETB\170\172Ka\ENQU\r\DEL\bJ\181\DLE" +// "D\163z38\186\137\129\DC1\254\215\221\ETX\NUL9\183e\172\182\225\210 \239",PropMaximumPacketSize +// 2615,PropSessionExpiryInterval 1558,PropSessionExpiryInterval 31946,PropAssignedClientIdentifier +// ":}\236\160G\147\239n\209c\233d\133\230\188\196\&18\228\DLE/d\192|\222\NULMb\190",PropResponseInformation +// "hl]",PropMessageExpiryInterval 9713,PropWildcardSubscriptionAvailable 28,PropSessionExpiryInterval 14464]} TEST(Publish5QCTest, Encode1) { uint8_t pkt[] = { - 0x3d, 0xad, 0x2, 0x0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0x1a, 0x0, 0x3, 0x68, 0x6c, 0x5d, 0x2, 0x0, 0x0, 0x25, 0xf1, 0x28, 0x1c, 0x11, 0x0, 0x0, 0x38, + 0x80, 0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, 0xb4, 0x44, 0x10, 0xfa, 0x5f, + 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; + + uint8_t buf[284] = {0}; + uint8_t topic_bytes[] = {0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, 0x4f, 0xd2, + 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf}; lwmqtt_string_t topic = {23, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x2d, 0xde}; + uint8_t msg_bytes[] = {0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, + 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; - - uint8_t bytesprops1[] = {0x21, 0x5c, 0xb3, 0x78, 0x93, 0xf2, 0x5f}; - uint8_t bytesprops0[] = {0x9b, 0x20, 0x4e, 0x99, 0x5d, 0xec, 0x3f, 0xc0, 0x46, 0x5a, 0x75, 0x7d, 0x8b, - 0x4c, 0xb0, 0x6d, 0xbd, 0xd3, 0x4a, 0x71, 0xb7, 0x7e, 0xca, 0x9, 0x9f}; - uint8_t bytesprops3[] = {0x78, 0x4b, 0x2b, 0x65, 0xd3, 0x72, 0xe, 0xc0, - 0x5d, 0x6b, 0xcb, 0x11, 0xaa, 0x69, 0x6e, 0x0}; - uint8_t bytesprops2[] = {0x5, 0xf7, 0x47}; - uint8_t bytesprops4[] = {0x18, 0x48, 0xe0, 0x41, 0x7d, 0x53, 0x1a, 0x4c, 0x65, 0x5e, - 0x31, 0x96, 0xe3, 0x29, 0x5f, 0x75, 0x4d, 0xbe, 0xe8, 0x28}; - uint8_t bytesprops5[] = {0x51, 0x6c, 0x85, 0xce, 0x6c}; - uint8_t bytesprops7[] = {0xbd, 0x9b, 0x13, 0xda, 0x62, 0x3b, 0x9a, 0x8e, 0xbb, 0xa9, 0x74, - 0x33, 0x24, 0x55, 0xbd, 0x1e, 0xf9, 0xca, 0xe8, 0x3a, 0x69}; - uint8_t bytesprops6[] = {0xd6, 0x0, 0x92, 0x88, 0xc0, 0x23, 0x28, 0x6c}; - uint8_t bytesprops8[] = {0xab, 0xbe, 0x60, 0xec, 0x9d, 0xb9, 0xc0, 0x51, 0xf6, 0xf5, - 0x78, 0xd8, 0x4d, 0xf1, 0x3, 0x42, 0xe9, 0x64, 0x89}; - uint8_t bytesprops9[] = {0x94, 0xd0, 0x4b, 0x8f, 0x72, 0x33, 0x3f, 0xf7, 0x2c, 0x76, 0xe6, 0xab, 0x40, 0x46, 0xa2}; - uint8_t bytesprops10[] = {0x95, 0x34, 0x4b}; - uint8_t bytesprops11[] = {0xaf, 0x3b, 0x7, 0x2c, 0x43, 0x9b, 0x9, 0xb2, 0x1e, 0x65, 0xac, 0xc0, 0xc9, 0x6e, - 0x92, 0x8a, 0xa4, 0x64, 0x7f, 0xb8, 0x58, 0xd8, 0xc9, 0xe0, 0x79, 0xb8, 0xce, 0xb}; + msg.payload_len = 26; + + uint8_t bytesprops0[] = {0xe1, 0x6b, 0xf6, 0xa, 0x4d, 0x8f, 0xfd, 0xaa, 0x1c, 0x9f, 0xa7, 0x84, 0x47, + 0xb9, 0x98, 0xa0, 0xdf, 0xc4, 0xda, 0xdf, 0xd9, 0xfc, 0x89, 0xdf, 0x9d, 0x12}; + uint8_t bytesprops2[] = {0x9f, 0x85, 0xe8, 0x39, 0xba, 0x3f, 0x1d, 0x39, 0x62, 0x15, 0xa7, 0xb6, 0x94, 0x82, 0x8d, + 0xee, 0x3d, 0x98, 0xd9, 0x79, 0xae, 0xe6, 0x1c, 0x5a, 0x69, 0xeb, 0x40, 0xf, 0x81, 0xc6}; + uint8_t bytesprops1[] = {0xf5, 0x8c, 0x4c, 0xa7, 0x88, 0x2c, 0x36, 0xf3, 0xf8, 0xc8, 0xe5, 0xd3, 0x70, 0x27, + 0x8b, 0x9, 0x18, 0x34, 0x90, 0xaa, 0x35, 0x73, 0x74, 0xca, 0xeb, 0xc6, 0x6f}; + uint8_t bytesprops4[] = {0x44, 0xa3, 0x7a, 0x33, 0x38, 0xba, 0x89, 0x81, 0x11, 0xfe, 0xd7, 0xdd, + 0x3, 0x0, 0x39, 0xb7, 0x65, 0xac, 0xb6, 0xe1, 0xd2, 0x20, 0xef}; + uint8_t bytesprops3[] = {0x83, 0xf4, 0x83, 0x51, 0x5, 0x17, 0xaa, 0xac, 0x4b, + 0x61, 0x5, 0x55, 0xd, 0x7f, 0x8, 0x4a, 0xb5, 0x10}; + uint8_t bytesprops5[] = {0x3a, 0x7d, 0xec, 0xa0, 0x47, 0x93, 0xef, 0x6e, 0xd1, 0x63, 0xe9, 0x64, 0x85, 0xe6, 0xbc, + 0xc4, 0x31, 0x38, 0xe4, 0x10, 0x2f, 0x64, 0xc0, 0x7c, 0xde, 0x0, 0x4d, 0x62, 0xbe}; + uint8_t bytesprops6[] = {0x68, 0x6c, 0x5d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31218}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6930}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32694}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops0}, .v = {7, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18652}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26180}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20402}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15307}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops2}, .v = {16, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops6}, .v = {21, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18906}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9189}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9167}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9103}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops3}, .v = {23, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2615}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1558}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31946}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9713}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14464}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5540, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1989, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\181m\255\144\250L\DC3iF\146\ACK\157\198\202\ACK\176\195z\141\216e\SYN\176", _pubPktID = 5540, _pubBody = "-\222", -// _pubProps = [PropMessageExpiryInterval 31218,PropMessageExpiryInterval 6930,PropSessionExpiryInterval -// 32694,PropUserProperty "\155 N\153]\236?\192FZu}\139L\176m\189\211Jq\183~\202\t\159" -// "!\\\179x\147\242_",PropSubscriptionIdentifier 6,PropSubscriptionIdentifierAvailable -// 171,PropRequestResponseInformation 68,PropRetainAvailable 146,PropMaximumPacketSize -// 18652,PropRequestResponseInformation 207,PropSubscriptionIdentifierAvailable 232,PropMaximumPacketSize -// 26180,PropTopicAlias 20402,PropMessageExpiryInterval 15307,PropUserProperty "\ENQ\247G" -// "xK+e\211r\SO\192]k\203\DC1\170in\NUL",PropAssignedClientIdentifier -// "\CANH\224A}S\SUBLe^1\150\227)_uM\190\232(",PropResponseTopic "Ql\133\206l",PropUserProperty -// "\214\NUL\146\136\192#(l" "\189\155\DC3\218b;\154\142\187\169t3$U\189\RS\249\202\232:i",PropAuthenticationData -// "\171\190`\236\157\185\192Q\246\245x\216M\241\ETXB\233d\137",PropResponseTopic -// "\148\208K\143r3?\247,v\230\171@F\162",PropMessageExpiryInterval 18906,PropRequestProblemInformation -// 117,PropPayloadFormatIndicator 196,PropSessionExpiryInterval 9189,PropWildcardSubscriptionAvailable -// 26,PropRequestResponseInformation 184,PropResponseTopic "\149\&4K",PropResponseInformation -// "\175;\a,C\155\t\178\RSe\172\192\201n\146\138\164d\DEL\184X\216\201\224y\184\206\v",PropPayloadFormatIndicator -// 172,PropRetainAvailable 73]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\226\186&N9\161\169\214\183\fO\210\SYNC\190Hj\233\221\189\173D\191", _pubPktID = 1989, _pubBody = +// "P\197\196\209K[\SOH/\132\207R\165\&9\180D\DLE\250_G\130f\DC2)\140kR", _pubProps = [PropResponseTopic +// "\225k\246\nM\143\253\170\FS\159\167\132G\185\152\160\223\196\218\223\217\252\137\223\157\DC2",PropRequestProblemInformation +// 123,PropTopicAlias 9167,PropReceiveMaximum 9103,PropRequestResponseInformation 66,PropMaximumQoS 202,PropUserProperty +// "\245\140L\167\136,6\243\248\200\229\211p'\139\t\CAN4\144\170\&5st\202\235\198o" +// "\159\133\232\&9\186?\GS9b\NAK\167\182\148\130\141\238=\152\217y\174\230\FSZi\235@\SI\129\198",PropSubscriptionIdentifier +// 15,PropUserProperty "\131\244\131Q\ENQ\ETB\170\172Ka\ENQU\r\DEL\bJ\181\DLE" +// "D\163z38\186\137\129\DC1\254\215\221\ETX\NUL9\183e\172\182\225\210 \239",PropMaximumPacketSize +// 2615,PropSessionExpiryInterval 1558,PropSessionExpiryInterval 31946,PropAssignedClientIdentifier +// ":}\236\160G\147\239n\209c\233d\133\230\188\196\&18\228\DLE/d\192|\222\NULMb\190",PropResponseInformation +// "hl]",PropMessageExpiryInterval 9713,PropWildcardSubscriptionAvailable 28,PropSessionExpiryInterval 14464]} TEST(Publish5QCTest, Decode1) { uint8_t pkt[] = { - 0x3d, 0xad, 0x2, 0x0, 0x17, 0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, 0xc6, 0xca, - 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0, 0x15, 0xa4, 0x8e, 0x2, 0x2, 0x0, 0x0, 0x79, 0xf2, 0x2, - 0x0, 0x0, 0x1b, 0x12, 0x11, 0x0, 0x0, 0x7f, 0xb6, 0x26, 0x0, 0x19, 0x9b, 0x20, 0x4e, 0x99, 0x5d, 0xec, 0x3f, - 0xc0, 0x46, 0x5a, 0x75, 0x7d, 0x8b, 0x4c, 0xb0, 0x6d, 0xbd, 0xd3, 0x4a, 0x71, 0xb7, 0x7e, 0xca, 0x9, 0x9f, 0x0, - 0x7, 0x21, 0x5c, 0xb3, 0x78, 0x93, 0xf2, 0x5f, 0xb, 0x6, 0x29, 0xab, 0x19, 0x44, 0x25, 0x92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x44, 0xa3, 0x7a, 0x33, 0x38, 0xba, 0x89, 0x81, 0x11, 0xfe, 0xd7, + 0xdd, 0x3, 0x0, 0x39, 0xb7, 0x65, 0xac, 0xb6, 0xe1, 0xd2, 0x20, 0xef, 0x27, 0x0, 0x0, 0xa, 0x37, 0x11, 0x0, + 0x0, 0x6, 0x16, 0x11, 0x0, 0x0, 0x7c, 0xca, 0x12, 0x0, 0x1d, 0x3a, 0x7d, 0xec, 0xa0, 0x47, 0x93, 0xef, 0x6e, + 0xd1, 0x63, 0xe9, 0x64, 0x85, 0xe6, 0xbc, 0xc4, 0x31, 0x38, 0xe4, 0x10, 0x2f, 0x64, 0xc0, 0x7c, 0xde, 0x0, 0x4d, + 0x62, 0xbe, 0x1a, 0x0, 0x3, 0x68, 0x6c, 0x5d, 0x2, 0x0, 0x0, 0x25, 0xf1, 0x28, 0x1c, 0x11, 0x0, 0x0, 0x38, + 0x80, 0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, 0xb4, 0x44, 0x10, 0xfa, 0x5f, + 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -751,79 +711,109 @@ TEST(Publish5QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb5, 0x6d, 0xff, 0x90, 0xfa, 0x4c, 0x13, 0x69, 0x46, 0x92, 0x6, 0x9d, - 0xc6, 0xca, 0x6, 0xb0, 0xc3, 0x7a, 0x8d, 0xd8, 0x65, 0x16, 0xb0}; + uint8_t exp_topic_bytes[] = {0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, 0x4f, 0xd2, + 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf}; lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2d, 0xde}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_body_bytes[] = {0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, + 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 5540); + EXPECT_EQ(packet_id, 1989); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "|5\229o-\r\179\163\252\150\208^\255(\140Y+\a\226xNy\RS\200\237\233\&5\214", _pubPktID = 0, _pubBody = -// "/\130\238\202\224\230", _pubProps = [PropSessionExpiryInterval 13319,PropReceiveMaximum -// 2476,PropPayloadFormatIndicator 219,PropRetainAvailable 217,PropSubscriptionIdentifier 21,PropServerReference -// "-\CANBb\a\211\&4\201M\227\140B\189\b9\135\188X\SOH'X",PropMaximumPacketSize 28709,PropMessageExpiryInterval -// 28695,PropSubscriptionIdentifier 7,PropPayloadFormatIndicator 174,PropRequestProblemInformation -// 173,PropWillDelayInterval 1999,PropTopicAlias 31049,PropSubscriptionIdentifierAvailable -// 105,PropSubscriptionIdentifier 4,PropSubscriptionIdentifierAvailable 86,PropTopicAliasMaximum -// 14292,PropTopicAliasMaximum 12764,PropMaximumQoS 159,PropWildcardSubscriptionAvailable 197]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\222\145Cc\220\210\226\245x\246qst\249\156\SUB\226\132\137Ys\173\176\137-\176\137-(topic.data), 28); - EXPECT_EQ(msg.payload_len, 6); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "#s+\243\184\144t\234lj\248\SO=\182TOG$\130\135YOE+\204", _pubPktID = 9717, _pubBody = "\n}\168", _pubProps = -// [PropReasonString "B\198+o;\198\n",PropSharedSubscriptionAvailable 12,PropResponseInformation -// "\DEL\175&H\NAK\178Wd4\RS\228",PropContentType -// "\t\nu\214'\180P^\247\250\&9\201\188\174\US>p\225",PropMaximumPacketSize 28051,PropTopicAlias -// 2937,PropSharedSubscriptionAvailable 108,PropWildcardSubscriptionAvailable 106,PropServerKeepAlive -// 8610,PropMessageExpiryInterval 31767,PropReasonString -// "K\190\200\150\223\234\232\DC3eE\218\221*\239\US\246\214\224%",PropTopicAlias 13083,PropSharedSubscriptionAvailable -// 85,PropResponseInformation "?D}\233\NAK\177\235\227\253\\\187\237}#",PropUserProperty "\NULz{\159\224L\193_;\CAN" -// "e\n\197\214\153\193\247\174\157\179I\SOC@SD\170\243a\136\141\r\"",PropRequestProblemInformation -// 28,PropPayloadFormatIndicator 242,PropAuthenticationData -// "\220\166s\EOTB\234o&QX\174\ACK\GS[\223\RS",PropAuthenticationMethod "\238\244"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = ",f", _pubPktID = 3323, _pubBody = +// "\130\170\152", _pubProps = [PropRetainAvailable 140,PropServerKeepAlive 6795,PropReceiveMaximum +// 17419,PropReasonString "\149",PropUserProperty "\172WQ\136i\193\150\253\185z\190\187\231Z\fn\RS\161\147\165 +// \186\&0\172\&7\164\228p\240\DC1" "/\SYN\163",PropServerReference "\149\ACKx\243_",PropAuthenticationData +// "\184\166\234,$\137\154Q",PropReceiveMaximum 29340,PropSessionExpiryInterval 4083,PropMaximumPacketSize +// 6103,PropServerReference +// "\233\214B\196'8\203\143=\215g\182\136\181\243K\218\ETB+\129\134v\SUBug}Dz^",PropResponseTopic +// "\SIg\r\141f\163J\DLEtR'\170\129\222\207\245\144\ETX\223=\227",PropTopicAliasMaximum 2774,PropUserProperty "\ETX" +// "\ETB\161\194\254\224\136\DEL\212\133\EOTif\249\234n\189\234\205h\EOT\196\134\&5\190\RS!O",PropSubscriptionIdentifierAvailable +// 229,PropTopicAliasMaximum 31358,PropMaximumQoS 169]} TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = {0x35, 0xd3, 0x1, 0x0, 0x19, 0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, - 0x3d, 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc, 0x25, 0xf5, 0xb1, 0x1, - 0x1f, 0x0, 0x7, 0x42, 0xc6, 0x2b, 0x6f, 0x3b, 0xc6, 0xa, 0x2a, 0xc, 0x1a, 0x0, 0xb, 0x7f, 0xaf, - 0x26, 0x48, 0x15, 0xb2, 0x57, 0x64, 0x34, 0x1e, 0xe4, 0x3, 0x0, 0x12, 0x9, 0xa, 0x75, 0xd6, 0x27, - 0xb4, 0x50, 0x5e, 0xf7, 0xfa, 0x39, 0xc9, 0xbc, 0xae, 0x1f, 0x3e, 0x70, 0xe1, 0x27, 0x0, 0x0, 0x6d, - 0x93, 0x23, 0xb, 0x79, 0x2a, 0x6c, 0x28, 0x6a, 0x13, 0x21, 0xa2, 0x2, 0x0, 0x0, 0x7c, 0x17, 0x1f, - 0x0, 0x13, 0x4b, 0xbe, 0xc8, 0x96, 0xdf, 0xea, 0xe8, 0x13, 0x65, 0x45, 0xda, 0xdd, 0x2a, 0xef, 0x1f, - 0xf6, 0xd6, 0xe0, 0x25, 0x23, 0x33, 0x1b, 0x2a, 0x55, 0x1a, 0x0, 0xe, 0x3f, 0x44, 0x7d, 0xe9, 0x15, - 0xb1, 0xeb, 0xe3, 0xfd, 0x5c, 0xbb, 0xed, 0x7d, 0x23, 0x26, 0x0, 0xa, 0x0, 0x7a, 0x7b, 0x9f, 0xe0, - 0x4c, 0xc1, 0x5f, 0x3b, 0x18, 0x0, 0x17, 0x65, 0xa, 0xc5, 0xd6, 0x99, 0xc1, 0xf7, 0xae, 0x9d, 0xb3, - 0x49, 0xe, 0x43, 0x40, 0x53, 0x44, 0xaa, 0xf3, 0x61, 0x88, 0x8d, 0xd, 0x22, 0x17, 0x1c, 0x1, 0xf2, - 0x16, 0x0, 0x10, 0xdc, 0xa6, 0x73, 0x4, 0x42, 0xea, 0x6f, 0x26, 0x51, 0x58, 0xae, 0x6, 0x1d, 0x5b, - 0xdf, 0x1e, 0x15, 0x0, 0x2, 0xee, 0xf4, 0xa, 0x7d, 0xa8}; - - uint8_t buf[224] = {0}; - - uint8_t topic_bytes[] = {0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, 0x3d, - 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0xc0, 0x1, 0x0, 0x2, 0x2c, 0x66, 0xc, 0xfb, 0xb5, 0x1, 0x25, 0x8c, 0x13, 0x1a, 0x8b, 0x21, + 0x44, 0xb, 0x1f, 0x0, 0x1, 0x95, 0x26, 0x0, 0x1e, 0xac, 0x57, 0x51, 0x88, 0x69, 0xc1, 0x96, 0xfd, + 0xb9, 0x7a, 0xbe, 0xbb, 0xe7, 0x5a, 0xc, 0x6e, 0x1e, 0xa1, 0x93, 0xa5, 0x20, 0xba, 0x30, 0xac, 0x37, + 0xa4, 0xe4, 0x70, 0xf0, 0x11, 0x0, 0x3, 0x2f, 0x16, 0xa3, 0x1c, 0x0, 0x5, 0x95, 0x6, 0x78, 0xf3, + 0x5f, 0x16, 0x0, 0x8, 0xb8, 0xa6, 0xea, 0x2c, 0x24, 0x89, 0x9a, 0x51, 0x21, 0x72, 0x9c, 0x11, 0x0, + 0x0, 0xf, 0xf3, 0x27, 0x0, 0x0, 0x17, 0xd7, 0x1c, 0x0, 0x1d, 0xe9, 0xd6, 0x42, 0xc4, 0x27, 0x38, + 0xcb, 0x8f, 0x3d, 0xd7, 0x67, 0xb6, 0x88, 0xb5, 0xf3, 0x4b, 0xda, 0x17, 0x2b, 0x81, 0x86, 0x76, 0x1a, + 0x75, 0x67, 0x7d, 0x44, 0x7a, 0x5e, 0x8, 0x0, 0x15, 0xf, 0x67, 0xd, 0x8d, 0x66, 0xa3, 0x4a, 0x10, + 0x74, 0x52, 0x27, 0xaa, 0x81, 0xde, 0xcf, 0xf5, 0x90, 0x3, 0xdf, 0x3d, 0xe3, 0x22, 0xa, 0xd6, 0x26, + 0x0, 0x1, 0x3, 0x0, 0x1b, 0x17, 0xa1, 0xc2, 0xfe, 0xe0, 0x88, 0x7f, 0xd4, 0x85, 0x4, 0x69, 0x66, + 0xf9, 0xea, 0x6e, 0xbd, 0xea, 0xcd, 0x68, 0x4, 0xc4, 0x86, 0x35, 0xbe, 0x1e, 0x21, 0x4f, 0x29, 0xe5, + 0x22, 0x7a, 0x7e, 0x24, 0xa9, 0x82, 0xaa, 0x98}; + + uint8_t buf[205] = {0}; + uint8_t topic_bytes[] = {0x2c, 0x66}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa, 0x7d, 0xa8}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x82, 0xaa, 0x98}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 3; - uint8_t bytesprops0[] = {0x42, 0xc6, 0x2b, 0x6f, 0x3b, 0xc6, 0xa}; - uint8_t bytesprops1[] = {0x7f, 0xaf, 0x26, 0x48, 0x15, 0xb2, 0x57, 0x64, 0x34, 0x1e, 0xe4}; - uint8_t bytesprops2[] = {0x9, 0xa, 0x75, 0xd6, 0x27, 0xb4, 0x50, 0x5e, 0xf7, - 0xfa, 0x39, 0xc9, 0xbc, 0xae, 0x1f, 0x3e, 0x70, 0xe1}; - uint8_t bytesprops3[] = {0x4b, 0xbe, 0xc8, 0x96, 0xdf, 0xea, 0xe8, 0x13, 0x65, 0x45, - 0xda, 0xdd, 0x2a, 0xef, 0x1f, 0xf6, 0xd6, 0xe0, 0x25}; - uint8_t bytesprops4[] = {0x3f, 0x44, 0x7d, 0xe9, 0x15, 0xb1, 0xeb, 0xe3, 0xfd, 0x5c, 0xbb, 0xed, 0x7d, 0x23}; - uint8_t bytesprops6[] = {0x65, 0xa, 0xc5, 0xd6, 0x99, 0xc1, 0xf7, 0xae, 0x9d, 0xb3, 0x49, 0xe, - 0x43, 0x40, 0x53, 0x44, 0xaa, 0xf3, 0x61, 0x88, 0x8d, 0xd, 0x22}; - uint8_t bytesprops5[] = {0x0, 0x7a, 0x7b, 0x9f, 0xe0, 0x4c, 0xc1, 0x5f, 0x3b, 0x18}; - uint8_t bytesprops7[] = {0xdc, 0xa6, 0x73, 0x4, 0x42, 0xea, 0x6f, 0x26, - 0x51, 0x58, 0xae, 0x6, 0x1d, 0x5b, 0xdf, 0x1e}; - uint8_t bytesprops8[] = {0xee, 0xf4}; + uint8_t bytesprops0[] = {0x95}; + uint8_t bytesprops2[] = {0x2f, 0x16, 0xa3}; + uint8_t bytesprops1[] = {0xac, 0x57, 0x51, 0x88, 0x69, 0xc1, 0x96, 0xfd, 0xb9, 0x7a, 0xbe, 0xbb, 0xe7, 0x5a, 0xc, + 0x6e, 0x1e, 0xa1, 0x93, 0xa5, 0x20, 0xba, 0x30, 0xac, 0x37, 0xa4, 0xe4, 0x70, 0xf0, 0x11}; + uint8_t bytesprops3[] = {0x95, 0x6, 0x78, 0xf3, 0x5f}; + uint8_t bytesprops4[] = {0xb8, 0xa6, 0xea, 0x2c, 0x24, 0x89, 0x9a, 0x51}; + uint8_t bytesprops5[] = {0xe9, 0xd6, 0x42, 0xc4, 0x27, 0x38, 0xcb, 0x8f, 0x3d, 0xd7, 0x67, 0xb6, 0x88, 0xb5, 0xf3, + 0x4b, 0xda, 0x17, 0x2b, 0x81, 0x86, 0x76, 0x1a, 0x75, 0x67, 0x7d, 0x44, 0x7a, 0x5e}; + uint8_t bytesprops6[] = {0xf, 0x67, 0xd, 0x8d, 0x66, 0xa3, 0x4a, 0x10, 0x74, 0x52, 0x27, + 0xaa, 0x81, 0xde, 0xcf, 0xf5, 0x90, 0x3, 0xdf, 0x3d, 0xe3}; + uint8_t bytesprops8[] = {0x17, 0xa1, 0xc2, 0xfe, 0xe0, 0x88, 0x7f, 0xd4, 0x85, 0x4, 0x69, 0x66, 0xf9, 0xea, + 0x6e, 0xbd, 0xea, 0xcd, 0x68, 0x4, 0xc4, 0x86, 0x35, 0xbe, 0x1e, 0x21, 0x4f}; + uint8_t bytesprops7[] = {0x3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28051}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2937}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8610}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31767}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13083}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops5}, .v = {23, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6795}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17419}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops1}, .v = {3, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29340}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4083}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6103}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2774}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops7}, .v = {27, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31358}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 9717, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 3323, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "#s+\243\184\144t\234lj\248\SO=\182TOG$\130\135YOE+\204", _pubPktID = 9717, _pubBody = "\n}\168", _pubProps = -// [PropReasonString "B\198+o;\198\n",PropSharedSubscriptionAvailable 12,PropResponseInformation -// "\DEL\175&H\NAK\178Wd4\RS\228",PropContentType -// "\t\nu\214'\180P^\247\250\&9\201\188\174\US>p\225",PropMaximumPacketSize 28051,PropTopicAlias -// 2937,PropSharedSubscriptionAvailable 108,PropWildcardSubscriptionAvailable 106,PropServerKeepAlive -// 8610,PropMessageExpiryInterval 31767,PropReasonString -// "K\190\200\150\223\234\232\DC3eE\218\221*\239\US\246\214\224%",PropTopicAlias 13083,PropSharedSubscriptionAvailable -// 85,PropResponseInformation "?D}\233\NAK\177\235\227\253\\\187\237}#",PropUserProperty "\NULz{\159\224L\193_;\CAN" -// "e\n\197\214\153\193\247\174\157\179I\SOC@SD\170\243a\136\141\r\"",PropRequestProblemInformation -// 28,PropPayloadFormatIndicator 242,PropAuthenticationData -// "\220\166s\EOTB\234o&QX\174\ACK\GS[\223\RS",PropAuthenticationMethod "\238\244"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = ",f", _pubPktID = 3323, _pubBody = +// "\130\170\152", _pubProps = [PropRetainAvailable 140,PropServerKeepAlive 6795,PropReceiveMaximum +// 17419,PropReasonString "\149",PropUserProperty "\172WQ\136i\193\150\253\185z\190\187\231Z\fn\RS\161\147\165 +// \186\&0\172\&7\164\228p\240\DC1" "/\SYN\163",PropServerReference "\149\ACKx\243_",PropAuthenticationData +// "\184\166\234,$\137\154Q",PropReceiveMaximum 29340,PropSessionExpiryInterval 4083,PropMaximumPacketSize +// 6103,PropServerReference +// "\233\214B\196'8\203\143=\215g\182\136\181\243K\218\ETB+\129\134v\SUBug}Dz^",PropResponseTopic +// "\SIg\r\141f\163J\DLEtR'\170\129\222\207\245\144\ETX\223=\227",PropTopicAliasMaximum 2774,PropUserProperty "\ETX" +// "\ETB\161\194\254\224\136\DEL\212\133\EOTif\249\234n\189\234\205h\EOT\196\134\&5\190\RS!O",PropSubscriptionIdentifierAvailable +// 229,PropTopicAliasMaximum 31358,PropMaximumQoS 169]} TEST(Publish5QCTest, Decode3) { - uint8_t pkt[] = {0x35, 0xd3, 0x1, 0x0, 0x19, 0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, - 0x3d, 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc, 0x25, 0xf5, 0xb1, 0x1, - 0x1f, 0x0, 0x7, 0x42, 0xc6, 0x2b, 0x6f, 0x3b, 0xc6, 0xa, 0x2a, 0xc, 0x1a, 0x0, 0xb, 0x7f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x1f, 0x0, 0x1, 0x95, 0x26, 0x0, 0x1e, 0xac, 0x57, 0x51, 0x88, 0x69, 0xc1, 0x96, 0xfd, + 0xb9, 0x7a, 0xbe, 0xbb, 0xe7, 0x5a, 0xc, 0x6e, 0x1e, 0xa1, 0x93, 0xa5, 0x20, 0xba, 0x30, 0xac, 0x37, + 0xa4, 0xe4, 0x70, 0xf0, 0x11, 0x0, 0x3, 0x2f, 0x16, 0xa3, 0x1c, 0x0, 0x5, 0x95, 0x6, 0x78, 0xf3, + 0x5f, 0x16, 0x0, 0x8, 0xb8, 0xa6, 0xea, 0x2c, 0x24, 0x89, 0x9a, 0x51, 0x21, 0x72, 0x9c, 0x11, 0x0, + 0x0, 0xf, 0xf3, 0x27, 0x0, 0x0, 0x17, 0xd7, 0x1c, 0x0, 0x1d, 0xe9, 0xd6, 0x42, 0xc4, 0x27, 0x38, + 0xcb, 0x8f, 0x3d, 0xd7, 0x67, 0xb6, 0x88, 0xb5, 0xf3, 0x4b, 0xda, 0x17, 0x2b, 0x81, 0x86, 0x76, 0x1a, + 0x75, 0x67, 0x7d, 0x44, 0x7a, 0x5e, 0x8, 0x0, 0x15, 0xf, 0x67, 0xd, 0x8d, 0x66, 0xa3, 0x4a, 0x10, + 0x74, 0x52, 0x27, 0xaa, 0x81, 0xde, 0xcf, 0xf5, 0x90, 0x3, 0xdf, 0x3d, 0xe3, 0x22, 0xa, 0xd6, 0x26, + 0x0, 0x1, 0x3, 0x0, 0x1b, 0x17, 0xa1, 0xc2, 0xfe, 0xe0, 0x88, 0x7f, 0xd4, 0x85, 0x4, 0x69, 0x66, + 0xf9, 0xea, 0x6e, 0xbd, 0xea, 0xcd, 0x68, 0x4, 0xc4, 0x86, 0x35, 0xbe, 0x1e, 0x21, 0x4f, 0x29, 0xe5, + 0x22, 0x7a, 0x7e, 0x24, 0xa9, 0x82, 0xaa, 0x98}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -987,72 +983,156 @@ TEST(Publish5QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x23, 0x73, 0x2b, 0xf3, 0xb8, 0x90, 0x74, 0xea, 0x6c, 0x6a, 0xf8, 0xe, 0x3d, - 0xb6, 0x54, 0x4f, 0x47, 0x24, 0x82, 0x87, 0x59, 0x4f, 0x45, 0x2b, 0xcc}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa, 0x7d, 0xa8}; + uint8_t exp_topic_bytes[] = {0x2c, 0x66}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x82, 0xaa, 0x98}; lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 9717); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 3323); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); EXPECT_EQ(msg.payload_len, 3); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\173\179\129=\155\186E\131\242g\224\149\&5\f\ESCk\250\130", _pubPktID = 696, _pubBody = -// "\210\212B\245\204\143IYw\217p\214\&5\152\133@\ETB{\FS\238\226", _pubProps = [PropContentType -// "\253iAd\SOH\225\GS\160\178\DC1\143\NULa\DC3\RSz\f\SYN\185",PropSessionExpiryInterval 21518]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "e\226\145", _pubPktID = 0, _pubBody = +// "\225?\246P\197\165t\243\173C\134\185", _pubProps = [PropUserProperty +// "\DLE8;\201\154\212Cf\233\255=\204\229>\145\245\166\144\EM\DC2B\DC4v< \GSvl" +// "\191Gn\251\a\EOTYm\220\SI|\213b\164\&1P\180\251\191\130\239\SYNv?^\159\189\180\144",PropPayloadFormatIndicator +// 100,PropAssignedClientIdentifier "\SIOT\211\182\253;r\SO\203",PropServerKeepAlive 24019,PropContentType +// "\209!\230\188\166< >e\n\233n\218\FS\212\205K7K\\H]\148X)v",PropAuthenticationMethod +// "\210e-\150\131\DC3\237\144\251}\179\141\ETB\151\184\b\146\202O|T\ACKOk\167\130xU\DC1\134",PropRequestResponseInformation +// 124,PropSessionExpiryInterval 27494,PropServerKeepAlive 22183,PropMessageExpiryInterval 32728,PropServerKeepAlive +// 31098,PropAuthenticationMethod "\153\210\196\v\200\163[/\212\155d9\239",PropSessionExpiryInterval +// 32275,PropContentType "\193\163\FS\205\133\&2\191\249;\v",PropSubscriptionIdentifier 29,PropAssignedClientIdentifier +// "}\SOH\DC2(\ESC\227\175\a\174\185\165\186",PropCorrelationData +// "\ENQ\238\250\159\219\247og\162\198$\NAKV\SYN\n",PropReceiveMaximum 28998,PropWildcardSubscriptionAvailable +// 146,PropWildcardSubscriptionAvailable 213,PropMaximumPacketSize 7834,PropSharedSubscriptionAvailable +// 250,PropServerKeepAlive 10556,PropReceiveMaximum 19508,PropRequestProblemInformation 187,PropServerReference +// "\246\190\241%\135\228\&2\NAKC\158\187N'\149\235\FS\225\245t\216p\128\132\147\221\206\188",PropSubscriptionIdentifierAvailable +// 115]} TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = {0x33, 0x47, 0x0, 0x12, 0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, 0x67, 0xe0, - 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82, 0x2, 0xb8, 0x1b, 0x3, 0x0, 0x13, 0xfd, 0x69, - 0x41, 0x64, 0x1, 0xe1, 0x1d, 0xa0, 0xb2, 0x11, 0x8f, 0x0, 0x61, 0x13, 0x1e, 0x7a, 0xc, - 0x16, 0xb9, 0x11, 0x0, 0x0, 0x54, 0xe, 0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, - 0x77, 0xd9, 0x70, 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; - - uint8_t buf[83] = {0}; - - uint8_t topic_bytes[] = {0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, - 0x67, 0xe0, 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0xae, 0x2, 0x0, 0x3, 0x65, 0xe2, 0x91, 0x9b, 0x2, 0x26, 0x0, 0x1c, 0x10, 0x38, 0x3b, 0xc9, + 0x9a, 0xd4, 0x43, 0x66, 0xe9, 0xff, 0x3d, 0xcc, 0xe5, 0x3e, 0x91, 0xf5, 0xa6, 0x90, 0x19, 0x12, 0x42, + 0x14, 0x76, 0x3c, 0x20, 0x1d, 0x76, 0x6c, 0x0, 0x1d, 0xbf, 0x47, 0x6e, 0xfb, 0x7, 0x4, 0x59, 0x6d, + 0xdc, 0xf, 0x7c, 0xd5, 0x62, 0xa4, 0x31, 0x50, 0xb4, 0xfb, 0xbf, 0x82, 0xef, 0x16, 0x76, 0x3f, 0x5e, + 0x9f, 0xbd, 0xb4, 0x90, 0x1, 0x64, 0x12, 0x0, 0xa, 0xf, 0x4f, 0x54, 0xd3, 0xb6, 0xfd, 0x3b, 0x72, + 0xe, 0xcb, 0x13, 0x5d, 0xd3, 0x3, 0x0, 0x1a, 0xd1, 0x21, 0xe6, 0xbc, 0xa6, 0x3c, 0x20, 0x3e, 0x65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xdd, + 0xce, 0xbc, 0x29, 0x73, 0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; + + uint8_t buf[315] = {0}; + uint8_t topic_bytes[] = {0x65, 0xe2, 0x91}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, 0x77, 0xd9, 0x70, - 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; + uint8_t msg_bytes[] = {0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - - uint8_t bytesprops0[] = {0xfd, 0x69, 0x41, 0x64, 0x1, 0xe1, 0x1d, 0xa0, 0xb2, 0x11, - 0x8f, 0x0, 0x61, 0x13, 0x1e, 0x7a, 0xc, 0x16, 0xb9}; + msg.payload_len = 12; + + uint8_t bytesprops1[] = {0xbf, 0x47, 0x6e, 0xfb, 0x7, 0x4, 0x59, 0x6d, 0xdc, 0xf, 0x7c, 0xd5, 0x62, 0xa4, 0x31, + 0x50, 0xb4, 0xfb, 0xbf, 0x82, 0xef, 0x16, 0x76, 0x3f, 0x5e, 0x9f, 0xbd, 0xb4, 0x90}; + uint8_t bytesprops0[] = {0x10, 0x38, 0x3b, 0xc9, 0x9a, 0xd4, 0x43, 0x66, 0xe9, 0xff, 0x3d, 0xcc, 0xe5, 0x3e, + 0x91, 0xf5, 0xa6, 0x90, 0x19, 0x12, 0x42, 0x14, 0x76, 0x3c, 0x20, 0x1d, 0x76, 0x6c}; + uint8_t bytesprops2[] = {0xf, 0x4f, 0x54, 0xd3, 0xb6, 0xfd, 0x3b, 0x72, 0xe, 0xcb}; + uint8_t bytesprops3[] = {0xd1, 0x21, 0xe6, 0xbc, 0xa6, 0x3c, 0x20, 0x3e, 0x65, 0xa, 0xe9, 0x6e, 0xda, + 0x1c, 0xd4, 0xcd, 0x4b, 0x37, 0x4b, 0x5c, 0x48, 0x5d, 0x94, 0x58, 0x29, 0x76}; + uint8_t bytesprops4[] = {0xd2, 0x65, 0x2d, 0x96, 0x83, 0x13, 0xed, 0x90, 0xfb, 0x7d, 0xb3, 0x8d, 0x17, 0x97, 0xb8, + 0x8, 0x92, 0xca, 0x4f, 0x7c, 0x54, 0x6, 0x4f, 0x6b, 0xa7, 0x82, 0x78, 0x55, 0x11, 0x86}; + uint8_t bytesprops5[] = {0x99, 0xd2, 0xc4, 0xb, 0xc8, 0xa3, 0x5b, 0x2f, 0xd4, 0x9b, 0x64, 0x39, 0xef}; + uint8_t bytesprops6[] = {0xc1, 0xa3, 0x1c, 0xcd, 0x85, 0x32, 0xbf, 0xf9, 0x3b, 0xb}; + uint8_t bytesprops7[] = {0x7d, 0x1, 0x12, 0x28, 0x1b, 0xe3, 0xaf, 0x7, 0xae, 0xb9, 0xa5, 0xba}; + uint8_t bytesprops8[] = {0x5, 0xee, 0xfa, 0x9f, 0xdb, 0xf7, 0x6f, 0x67, 0xa2, 0xc6, 0x24, 0x15, 0x56, 0x16, 0xa}; + uint8_t bytesprops9[] = {0xf6, 0xbe, 0xf1, 0x25, 0x87, 0xe4, 0x32, 0x15, 0x43, 0x9e, 0xbb, 0x4e, 0x27, 0x95, + 0xeb, 0x1c, 0xe1, 0xf5, 0x74, 0xd8, 0x70, 0x80, 0x84, 0x93, 0xdd, 0xce, 0xbc}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21518}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops0}, .v = {29, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24019}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27494}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22183}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32728}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31098}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32275}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28998}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7834}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10556}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19508}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 696, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\173\179\129=\155\186E\131\242g\224\149\&5\f\ESCk\250\130", _pubPktID = 696, _pubBody = -// "\210\212B\245\204\143IYw\217p\214\&5\152\133@\ETB{\FS\238\226", _pubProps = [PropContentType -// "\253iAd\SOH\225\GS\160\178\DC1\143\NULa\DC3\RSz\f\SYN\185",PropSessionExpiryInterval 21518]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "e\226\145", _pubPktID = 0, _pubBody = +// "\225?\246P\197\165t\243\173C\134\185", _pubProps = [PropUserProperty +// "\DLE8;\201\154\212Cf\233\255=\204\229>\145\245\166\144\EM\DC2B\DC4v< \GSvl" +// "\191Gn\251\a\EOTYm\220\SI|\213b\164\&1P\180\251\191\130\239\SYNv?^\159\189\180\144",PropPayloadFormatIndicator +// 100,PropAssignedClientIdentifier "\SIOT\211\182\253;r\SO\203",PropServerKeepAlive 24019,PropContentType +// "\209!\230\188\166< >e\n\233n\218\FS\212\205K7K\\H]\148X)v",PropAuthenticationMethod +// "\210e-\150\131\DC3\237\144\251}\179\141\ETB\151\184\b\146\202O|T\ACKOk\167\130xU\DC1\134",PropRequestResponseInformation +// 124,PropSessionExpiryInterval 27494,PropServerKeepAlive 22183,PropMessageExpiryInterval 32728,PropServerKeepAlive +// 31098,PropAuthenticationMethod "\153\210\196\v\200\163[/\212\155d9\239",PropSessionExpiryInterval +// 32275,PropContentType "\193\163\FS\205\133\&2\191\249;\v",PropSubscriptionIdentifier 29,PropAssignedClientIdentifier +// "}\SOH\DC2(\ESC\227\175\a\174\185\165\186",PropCorrelationData +// "\ENQ\238\250\159\219\247og\162\198$\NAKV\SYN\n",PropReceiveMaximum 28998,PropWildcardSubscriptionAvailable +// 146,PropWildcardSubscriptionAvailable 213,PropMaximumPacketSize 7834,PropSharedSubscriptionAvailable +// 250,PropServerKeepAlive 10556,PropReceiveMaximum 19508,PropRequestProblemInformation 187,PropServerReference +// "\246\190\241%\135\228\&2\NAKC\158\187N'\149\235\FS\225\245t\216p\128\132\147\221\206\188",PropSubscriptionIdentifierAvailable +// 115]} TEST(Publish5QCTest, Decode4) { - uint8_t pkt[] = {0x33, 0x47, 0x0, 0x12, 0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, 0x67, 0xe0, - 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82, 0x2, 0xb8, 0x1b, 0x3, 0x0, 0x13, 0xfd, 0x69, - 0x41, 0x64, 0x1, 0xe1, 0x1d, 0xa0, 0xb2, 0x11, 0x8f, 0x0, 0x61, 0x13, 0x1e, 0x7a, 0xc, - 0x16, 0xb9, 0x11, 0x0, 0x0, 0x54, 0xe, 0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, - 0x77, 0xd9, 0x70, 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; + uint8_t pkt[] = {0x39, 0xae, 0x2, 0x0, 0x3, 0x65, 0xe2, 0x91, 0x9b, 0x2, 0x26, 0x0, 0x1c, 0x10, 0x38, 0x3b, 0xc9, + 0x9a, 0xd4, 0x43, 0x66, 0xe9, 0xff, 0x3d, 0xcc, 0xe5, 0x3e, 0x91, 0xf5, 0xa6, 0x90, 0x19, 0x12, 0x42, + 0x14, 0x76, 0x3c, 0x20, 0x1d, 0x76, 0x6c, 0x0, 0x1d, 0xb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xf7, 0x6f, 0x67, 0xa2, 0xc6, 0x24, 0x15, 0x56, 0x16, + 0xa, 0x21, 0x71, 0x46, 0x28, 0x92, 0x28, 0xd5, 0x27, 0x0, 0x0, 0x1e, 0x9a, 0x2a, 0xfa, 0x13, 0x29, + 0x3c, 0x21, 0x4c, 0x34, 0x17, 0xbb, 0x1c, 0x0, 0x1b, 0xf6, 0xbe, 0xf1, 0x25, 0x87, 0xe4, 0x32, 0x15, + 0x43, 0x9e, 0xbb, 0x4e, 0x27, 0x95, 0xeb, 0x1c, 0xe1, 0xf5, 0x74, 0xd8, 0x70, 0x80, 0x84, 0x93, 0xdd, + 0xce, 0xbc, 0x29, 0x73, 0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1060,127 +1140,134 @@ TEST(Publish5QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xad, 0xb3, 0x81, 0x3d, 0x9b, 0xba, 0x45, 0x83, 0xf2, - 0x67, 0xe0, 0x95, 0x35, 0xc, 0x1b, 0x6b, 0xfa, 0x82}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd2, 0xd4, 0x42, 0xf5, 0xcc, 0x8f, 0x49, 0x59, 0x77, 0xd9, 0x70, - 0xd6, 0x35, 0x98, 0x85, 0x40, 0x17, 0x7b, 0x1c, 0xee, 0xe2}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x65, 0xe2, 0x91}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 696); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "!\189a\ENQ\235r\186\232?!\140O>\201\220\163\133\166!\139i", _pubPktID = 0, _pubBody = -// "\249\159L\166\132\147`Q\206\238\229\138\217\DEL\219\t\243\131\192H\SIJ\168@y", _pubProps = [PropRetainAvailable -// 63,PropSubscriptionIdentifierAvailable 254,PropUserProperty "\200TB\215\255V,X\247^\NAK\175\GS\155R\SI\183)wiCQ" -// "@\181\SYN\250\227\154\&63\188\242\205\235\210>\195No\148\148\219\167\135N\206\\",PropRequestProblemInformation -// 17,PropAuthenticationData "",PropAssignedClientIdentifier -// "\222\GSoB\\[0\229\225\240\DC4\246\a\230\DLEJ\220\198-\250\172\SOQ\223c\183\156B",PropContentType -// "\252@\145\231\f\172",PropTopicAliasMaximum 13537,PropRequestResponseInformation 228,PropRequestProblemInformation -// 101,PropRequestProblemInformation 78,PropMessageExpiryInterval 27680,PropTopicAlias 10759,PropSubscriptionIdentifier -// 7,PropReceiveMaximum 11393,PropMaximumQoS 183,PropPayloadFormatIndicator 102,PropAuthenticationMethod -// "\212",PropServerKeepAlive 30667,PropRequestResponseInformation 129,PropMessageExpiryInterval 5688]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\191", _pubPktID = 26120, +// _pubBody = "_e(\238\187\252\234\241\201\201\220\163\133\166!\139i", _pubPktID = 0, _pubBody = -// "\249\159L\166\132\147`Q\206\238\229\138\217\DEL\219\t\243\131\192H\SIJ\168@y", _pubProps = [PropRetainAvailable -// 63,PropSubscriptionIdentifierAvailable 254,PropUserProperty "\200TB\215\255V,X\247^\NAK\175\GS\155R\SI\183)wiCQ" -// "@\181\SYN\250\227\154\&63\188\242\205\235\210>\195No\148\148\219\167\135N\206\\",PropRequestProblemInformation -// 17,PropAuthenticationData "",PropAssignedClientIdentifier -// "\222\GSoB\\[0\229\225\240\DC4\246\a\230\DLEJ\220\198-\250\172\SOQ\223c\183\156B",PropContentType -// "\252@\145\231\f\172",PropTopicAliasMaximum 13537,PropRequestResponseInformation 228,PropRequestProblemInformation -// 101,PropRequestProblemInformation 78,PropMessageExpiryInterval 27680,PropTopicAlias 10759,PropSubscriptionIdentifier -// 7,PropReceiveMaximum 11393,PropMaximumQoS 183,PropPayloadFormatIndicator 102,PropAuthenticationMethod -// "\212",PropServerKeepAlive 30667,PropRequestResponseInformation 129,PropMessageExpiryInterval 5688]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\191", _pubPktID = 26120, +// _pubBody = "_e(\238\187\252\234\241\201(topic.data), 21); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 26120); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\216WQ\"", _pubPktID = 0, _pubBody = -// "\v\225\187\153*%\252qh\193\210\232\r0tw\196\176*\254C", _pubProps = [PropMessageExpiryInterval -// 17186,PropCorrelationData "C\214\155\209\176\162H\244v\167\201\244\243?\225\179\t\243%]\175\187",PropUserProperty -// "W\DC2yE\170\135\241z\181\152O\170%\US\185\156\DLEr\209sK\145\198\235=" -// "\153\132\199!\225\188\RSC\173\253\213\220\EOTWW\241\221\247\159b",PropTopicAliasMaximum 23680,PropTopicAliasMaximum -// 20899,PropSessionExpiryInterval 28081,PropMaximumQoS 158,PropMessageExpiryInterval 16231,PropUserProperty -// "\195\SI\ENQ=\216\&0D\152\151\f\SI=\249\238\a\176R" "\172\176\205\198\133%9\226\180h\139\248"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\tz\186\176\196\148\DC1", _pubPktID +// = 10274, _pubBody = "\199\149\244", _pubProps = [PropPayloadFormatIndicator 131]} TEST(Publish5QCTest, Encode6) { - uint8_t pkt[] = {0x38, 0xa1, 0x1, 0x0, 0x4, 0xd8, 0x57, 0x51, 0x22, 0x84, 0x1, 0x2, 0x0, 0x0, 0x43, 0x22, 0x9, - 0x0, 0x16, 0x43, 0xd6, 0x9b, 0xd1, 0xb0, 0xa2, 0x48, 0xf4, 0x76, 0xa7, 0xc9, 0xf4, 0xf3, 0x3f, 0xe1, - 0xb3, 0x9, 0xf3, 0x25, 0x5d, 0xaf, 0xbb, 0x26, 0x0, 0x19, 0x57, 0x12, 0x79, 0x45, 0xaa, 0x87, 0xf1, - 0x7a, 0xb5, 0x98, 0x4f, 0xaa, 0x25, 0x1f, 0xb9, 0x9c, 0x10, 0x72, 0xd1, 0x73, 0x4b, 0x91, 0xc6, 0xeb, - 0x3d, 0x0, 0x14, 0x99, 0x84, 0xc7, 0x21, 0xe1, 0xbc, 0x1e, 0x43, 0xad, 0xfd, 0xd5, 0xdc, 0x4, 0x57, - 0x57, 0xf1, 0xdd, 0xf7, 0x9f, 0x62, 0x22, 0x5c, 0x80, 0x22, 0x51, 0xa3, 0x11, 0x0, 0x0, 0x6d, 0xb1, - 0x24, 0x9e, 0x2, 0x0, 0x0, 0x3f, 0x67, 0x26, 0x0, 0x11, 0xc3, 0xf, 0x5, 0x3d, 0xd8, 0x30, 0x44, - 0x98, 0x97, 0xc, 0xf, 0x3d, 0xf9, 0xee, 0x7, 0xb0, 0x52, 0x0, 0xc, 0xac, 0xb0, 0xcd, 0xc6, 0x85, - 0x25, 0x39, 0xe2, 0xb4, 0x68, 0x8b, 0xf8, 0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, - 0xd2, 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; - - uint8_t buf[174] = {0}; - - uint8_t topic_bytes[] = {0xd8, 0x57, 0x51, 0x22}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x11, 0x0, 0x7, 0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, + 0x11, 0x28, 0x22, 0x2, 0x1, 0x83, 0xc7, 0x95, 0xf4}; + + uint8_t buf[29] = {0}; + uint8_t topic_bytes[] = {0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, 0x11}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, 0xd2, - 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; + uint8_t msg_bytes[] = {0xc7, 0x95, 0xf4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - - uint8_t bytesprops0[] = {0x43, 0xd6, 0x9b, 0xd1, 0xb0, 0xa2, 0x48, 0xf4, 0x76, 0xa7, 0xc9, - 0xf4, 0xf3, 0x3f, 0xe1, 0xb3, 0x9, 0xf3, 0x25, 0x5d, 0xaf, 0xbb}; - uint8_t bytesprops2[] = {0x99, 0x84, 0xc7, 0x21, 0xe1, 0xbc, 0x1e, 0x43, 0xad, 0xfd, - 0xd5, 0xdc, 0x4, 0x57, 0x57, 0xf1, 0xdd, 0xf7, 0x9f, 0x62}; - uint8_t bytesprops1[] = {0x57, 0x12, 0x79, 0x45, 0xaa, 0x87, 0xf1, 0x7a, 0xb5, 0x98, 0x4f, 0xaa, 0x25, - 0x1f, 0xb9, 0x9c, 0x10, 0x72, 0xd1, 0x73, 0x4b, 0x91, 0xc6, 0xeb, 0x3d}; - uint8_t bytesprops4[] = {0xac, 0xb0, 0xcd, 0xc6, 0x85, 0x25, 0x39, 0xe2, 0xb4, 0x68, 0x8b, 0xf8}; - uint8_t bytesprops3[] = {0xc3, 0xf, 0x5, 0x3d, 0xd8, 0x30, 0x44, 0x98, 0x97, - 0xc, 0xf, 0x3d, 0xf9, 0xee, 0x7, 0xb0, 0x52}; + msg.payload_len = 3; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17186}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops1}, .v = {20, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23680}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20899}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28081}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16231}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops3}, .v = {12, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 131}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10274, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\216WQ\"", _pubPktID = 0, _pubBody = -// "\v\225\187\153*%\252qh\193\210\232\r0tw\196\176*\254C", _pubProps = [PropMessageExpiryInterval -// 17186,PropCorrelationData "C\214\155\209\176\162H\244v\167\201\244\243?\225\179\t\243%]\175\187",PropUserProperty -// "W\DC2yE\170\135\241z\181\152O\170%\US\185\156\DLEr\209sK\145\198\235=" -// "\153\132\199!\225\188\RSC\173\253\213\220\EOTWW\241\221\247\159b",PropTopicAliasMaximum 23680,PropTopicAliasMaximum -// 20899,PropSessionExpiryInterval 28081,PropMaximumQoS 158,PropMessageExpiryInterval 16231,PropUserProperty -// "\195\SI\ENQ=\216\&0D\152\151\f\SI=\249\238\a\176R" "\172\176\205\198\133%9\226\180h\139\248"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\tz\186\176\196\148\DC1", _pubPktID +// = 10274, _pubBody = "\199\149\244", _pubProps = [PropPayloadFormatIndicator 131]} TEST(Publish5QCTest, Decode6) { - uint8_t pkt[] = {0x38, 0xa1, 0x1, 0x0, 0x4, 0xd8, 0x57, 0x51, 0x22, 0x84, 0x1, 0x2, 0x0, 0x0, 0x43, 0x22, 0x9, - 0x0, 0x16, 0x43, 0xd6, 0x9b, 0xd1, 0xb0, 0xa2, 0x48, 0xf4, 0x76, 0xa7, 0xc9, 0xf4, 0xf3, 0x3f, 0xe1, - 0xb3, 0x9, 0xf3, 0x25, 0x5d, 0xaf, 0xbb, 0x26, 0x0, 0x19, 0x57, 0x12, 0x79, 0x45, 0xaa, 0x87, 0xf1, - 0x7a, 0xb5, 0x98, 0x4f, 0xaa, 0x25, 0x1f, 0xb9, 0x9c, 0x10, 0x72, 0xd1, 0x73, 0x4b, 0x91, 0xc6, 0xeb, - 0x3d, 0x0, 0x14, 0x99, 0x84, 0xc7, 0x21, 0xe1, 0xbc, 0x1e, 0x43, 0xad, 0xfd, 0xd5, 0xdc, 0x4, 0x57, - 0x57, 0xf1, 0xdd, 0xf7, 0x9f, 0x62, 0x22, 0x5c, 0x80, 0x22, 0x51, 0xa3, 0x11, 0x0, 0x0, 0x6d, 0xb1, - 0x24, 0x9e, 0x2, 0x0, 0x0, 0x3f, 0x67, 0x26, 0x0, 0x11, 0xc3, 0xf, 0x5, 0x3d, 0xd8, 0x30, 0x44, - 0x98, 0x97, 0xc, 0xf, 0x3d, 0xf9, 0xee, 0x7, 0xb0, 0x52, 0x0, 0xc, 0xac, 0xb0, 0xcd, 0xc6, 0x85, - 0x25, 0x39, 0xe2, 0xb4, 0x68, 0x8b, 0xf8, 0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, - 0xd2, 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; + uint8_t pkt[] = {0x3a, 0x11, 0x0, 0x7, 0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, + 0x11, 0x28, 0x22, 0x2, 0x1, 0x83, 0xc7, 0x95, 0xf4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1291,136 +1330,176 @@ TEST(Publish5QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xd8, 0x57, 0x51, 0x22}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb, 0xe1, 0xbb, 0x99, 0x2a, 0x25, 0xfc, 0x71, 0x68, 0xc1, 0xd2, - 0xe8, 0xd, 0x30, 0x74, 0x77, 0xc4, 0xb0, 0x2a, 0xfe, 0x43}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, 0x11}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc7, 0x95, 0xf4}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 10274); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\130\tw\142", _pubPktID = 9801, -// _pubBody = "\154z+\141\DC3\201)z\n", _pubProps = [PropAuthenticationMethod -// "ZB@2{y\190\206\147\202;e\226\144\219s",PropMaximumQoS 20,PropUserProperty "=,\216\239\186\129\162\131" -// "\208&\170\&0K\204\184\&7\142\v\148\246\131%\224\222\255^\237`05\150\154\246\208Q",PropServerReference -// "\196\&8_\204\196\200+.\204x\v\143\245\242\196\227\233BG\t(\161Z\226@x",PropMaximumPacketSize -// 17975,PropWillDelayInterval 32302,PropReasonString "\204z\245\175\135k\225\ENQ\EOT\240\200\221\212!\207\167 -// 4\172]\213]\251B\142\GSV\219",PropPayloadFormatIndicator 233,PropContentType -// "\171\ENQ\DC3\151\236m\131\DC2\DLE1\214s\DC3\ESC\174\144k\164B\249\151",PropMaximumPacketSize 31507,PropTopicAlias -// 31094,PropCorrelationData "~\137s\238\239(\221\ESC\192\193\212",PropRequestProblemInformation -// 96,PropSessionExpiryInterval 30094,PropAuthenticationMethod -// "\DLE#\225\230b\190\225\214\188f\194M\211\219\SIk",PropWillDelayInterval 3844,PropReasonString -// "\172\ETX\142%\182M\SUB+\230\175\238\151",PropServerReference "\v\164\245\183\136\131J\184\249\225\134"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "l\GS\SO\SI\176\NAKT\189\t0b\NUL\154#1", _pubPktID = 0, _pubBody = +// "\180v\132PX\145\222\160?9\205\204\241\168\&5<\235\222\160\\\190Tg\128", _pubProps = [PropResponseTopic +// "A\229\&5\242\b\DC4m\212]6\178\178\210\136WX\n\CAN",PropResponseInformation +// "\132^\\\136\159s\165\140\151o\195\227\170XR\197\247\145\ESC>2F\172\&2\189\\",PropMaximumPacketSize +// 21600,PropMaximumPacketSize 13269,PropRequestProblemInformation 94,PropWillDelayInterval +// 18146,PropRequestResponseInformation 220,PropSubscriptionIdentifierAvailable 112,PropSessionExpiryInterval +// 24193,PropMaximumQoS 254,PropAuthenticationMethod "L\DLE}",PropWildcardSubscriptionAvailable 171,PropResponseTopic +// "\252]\250\240\179\228\t\172\144\226\226\151(\214\156\225\210A\241.\198\DC2o\228W\223o_",PropContentType +// "\160\197\161\150W\179\181\&0b\DLEn\RS(\148ET|G",PropContentType +// "<@M\204\204\166[\SI\182\143\251S5\156\151|\176",PropCorrelationData +// "\189\CAN\EMA\188l\SUB\190",PropResponseInformation "\234f\205j\184j\238\243u\130\238",PropMessageExpiryInterval +// 23833,PropMaximumPacketSize 12844,PropMaximumQoS 135,PropAssignedClientIdentifier +// "\190JnM\190I\187*\213\221\178\168,1\175a\SUB\244\254\192",PropUserProperty +// "\236\ETB\235R\182d\242\184\217\214[>h\210\204\209\f\146\183\185\153\184\"\ESC\234" +// "?\DC4\SOHl\129\&2?L\US\ETX",PropRequestResponseInformation 19,PropWildcardSubscriptionAvailable +// 22,PropAssignedClientIdentifier "\234!ZGR\254\RS\US\183\135\191",PropReasonString +// "\217\141\153!V\187\216\148r\211\ACK\EM\197\183\&6\221&\180\237",PropResponseTopic "en\252!",PropWillDelayInterval +// 6918,PropRequestProblemInformation 173]} TEST(Publish5QCTest, Encode7) { uint8_t pkt[] = { - 0x32, 0x82, 0x2, 0x0, 0x4, 0x82, 0x9, 0x77, 0x8e, 0x26, 0x49, 0xef, 0x1, 0x15, 0x0, 0x10, 0x5a, 0x42, 0x40, - 0x32, 0x7b, 0x79, 0xbe, 0xce, 0x93, 0xca, 0x3b, 0x65, 0xe2, 0x90, 0xdb, 0x73, 0x24, 0x14, 0x26, 0x0, 0x8, 0x3d, - 0x2c, 0xd8, 0xef, 0xba, 0x81, 0xa2, 0x83, 0x0, 0x1b, 0xd0, 0x26, 0xaa, 0x30, 0x4b, 0xcc, 0xb8, 0x37, 0x8e, 0xb, - 0x94, 0xf6, 0x83, 0x25, 0xe0, 0xde, 0xff, 0x5e, 0xed, 0x60, 0x30, 0x35, 0x96, 0x9a, 0xf6, 0xd0, 0x51, 0x1c, 0x0, - 0x1a, 0xc4, 0x38, 0x5f, 0xcc, 0xc4, 0xc8, 0x2b, 0x2e, 0xcc, 0x78, 0xb, 0x8f, 0xf5, 0xf2, 0xc4, 0xe3, 0xe9, 0x42, - 0x47, 0x9, 0x28, 0xa1, 0x5a, 0xe2, 0x40, 0x78, 0x27, 0x0, 0x0, 0x46, 0x37, 0x18, 0x0, 0x0, 0x7e, 0x2e, 0x1f, - 0x0, 0x1c, 0xcc, 0x7a, 0xf5, 0xaf, 0x87, 0x6b, 0xe1, 0x5, 0x4, 0xf0, 0xc8, 0xdd, 0xd4, 0x21, 0xcf, 0xa7, 0x20, - 0x34, 0xac, 0x5d, 0xd5, 0x5d, 0xfb, 0x42, 0x8e, 0x1d, 0x56, 0xdb, 0x1, 0xe9, 0x3, 0x0, 0x15, 0xab, 0x5, 0x13, - 0x97, 0xec, 0x6d, 0x83, 0x12, 0x10, 0x31, 0xd6, 0x73, 0x13, 0x1b, 0xae, 0x90, 0x6b, 0xa4, 0x42, 0xf9, 0x97, 0x27, - 0x0, 0x0, 0x7b, 0x13, 0x23, 0x79, 0x76, 0x9, 0x0, 0xb, 0x7e, 0x89, 0x73, 0xee, 0xef, 0x28, 0xdd, 0x1b, 0xc0, - 0xc1, 0xd4, 0x17, 0x60, 0x11, 0x0, 0x0, 0x75, 0x8e, 0x15, 0x0, 0x10, 0x10, 0x23, 0xe1, 0xe6, 0x62, 0xbe, 0xe1, - 0xd6, 0xbc, 0x66, 0xc2, 0x4d, 0xd3, 0xdb, 0xf, 0x6b, 0x18, 0x0, 0x0, 0xf, 0x4, 0x1f, 0x0, 0xc, 0xac, 0x3, - 0x8e, 0x25, 0xb6, 0x4d, 0x1a, 0x2b, 0xe6, 0xaf, 0xee, 0x97, 0x1c, 0x0, 0xb, 0xb, 0xa4, 0xf5, 0xb7, 0x88, 0x83, - 0x4a, 0xb8, 0xf9, 0xe1, 0x86, 0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; - - uint8_t buf[271] = {0}; - - uint8_t topic_bytes[] = {0x82, 0x9, 0x77, 0x8e}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + 0x31, 0xe3, 0x2, 0x0, 0xf, 0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, 0x0, 0x9a, 0x23, + 0x31, 0xb8, 0x2, 0x8, 0x0, 0x12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x27, 0x0, 0x0, 0x32, 0x2c, 0x24, 0x87, 0x12, 0x0, 0x14, 0xbe, 0x4a, 0x6e, 0x4d, 0xbe, 0x49, 0xbb, 0x2a, + 0xd5, 0xdd, 0xb2, 0xa8, 0x2c, 0x31, 0xaf, 0x61, 0x1a, 0xf4, 0xfe, 0xc0, 0x26, 0x0, 0x19, 0xec, 0x17, 0xeb, 0x52, + 0xb6, 0x64, 0xf2, 0xb8, 0xd9, 0xd6, 0x5b, 0x3e, 0x68, 0xd2, 0xcc, 0xd1, 0xc, 0x92, 0xb7, 0xb9, 0x99, 0xb8, 0x22, + 0x1b, 0xea, 0x0, 0xa, 0x3f, 0x14, 0x1, 0x6c, 0x81, 0x32, 0x3f, 0x4c, 0x1f, 0x3, 0x19, 0x13, 0x28, 0x16, 0x12, + 0x0, 0xb, 0xea, 0x21, 0x5a, 0x47, 0x52, 0xfe, 0x1e, 0x1f, 0xb7, 0x87, 0xbf, 0x1f, 0x0, 0x13, 0xd9, 0x8d, 0x99, + 0x21, 0x56, 0xbb, 0xd8, 0x94, 0x72, 0xd3, 0x6, 0x19, 0xc5, 0xb7, 0x36, 0xdd, 0x26, 0xb4, 0xed, 0x8, 0x0, 0x4, + 0x65, 0x6e, 0xfc, 0x21, 0x18, 0x0, 0x0, 0x1b, 0x6, 0x17, 0xad, 0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, + 0x3f, 0x39, 0xcd, 0xcc, 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; + + uint8_t buf[368] = {0}; + uint8_t topic_bytes[] = {0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, 0x0, 0x9a, 0x23, 0x31}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, 0x3f, 0x39, 0xcd, 0xcc, + 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; - - uint8_t bytesprops0[] = {0x5a, 0x42, 0x40, 0x32, 0x7b, 0x79, 0xbe, 0xce, - 0x93, 0xca, 0x3b, 0x65, 0xe2, 0x90, 0xdb, 0x73}; - uint8_t bytesprops2[] = {0xd0, 0x26, 0xaa, 0x30, 0x4b, 0xcc, 0xb8, 0x37, 0x8e, 0xb, 0x94, 0xf6, 0x83, 0x25, - 0xe0, 0xde, 0xff, 0x5e, 0xed, 0x60, 0x30, 0x35, 0x96, 0x9a, 0xf6, 0xd0, 0x51}; - uint8_t bytesprops1[] = {0x3d, 0x2c, 0xd8, 0xef, 0xba, 0x81, 0xa2, 0x83}; - uint8_t bytesprops3[] = {0xc4, 0x38, 0x5f, 0xcc, 0xc4, 0xc8, 0x2b, 0x2e, 0xcc, 0x78, 0xb, 0x8f, 0xf5, - 0xf2, 0xc4, 0xe3, 0xe9, 0x42, 0x47, 0x9, 0x28, 0xa1, 0x5a, 0xe2, 0x40, 0x78}; - uint8_t bytesprops4[] = {0xcc, 0x7a, 0xf5, 0xaf, 0x87, 0x6b, 0xe1, 0x5, 0x4, 0xf0, 0xc8, 0xdd, 0xd4, 0x21, - 0xcf, 0xa7, 0x20, 0x34, 0xac, 0x5d, 0xd5, 0x5d, 0xfb, 0x42, 0x8e, 0x1d, 0x56, 0xdb}; - uint8_t bytesprops5[] = {0xab, 0x5, 0x13, 0x97, 0xec, 0x6d, 0x83, 0x12, 0x10, 0x31, 0xd6, - 0x73, 0x13, 0x1b, 0xae, 0x90, 0x6b, 0xa4, 0x42, 0xf9, 0x97}; - uint8_t bytesprops6[] = {0x7e, 0x89, 0x73, 0xee, 0xef, 0x28, 0xdd, 0x1b, 0xc0, 0xc1, 0xd4}; - uint8_t bytesprops7[] = {0x10, 0x23, 0xe1, 0xe6, 0x62, 0xbe, 0xe1, 0xd6, - 0xbc, 0x66, 0xc2, 0x4d, 0xd3, 0xdb, 0xf, 0x6b}; - uint8_t bytesprops8[] = {0xac, 0x3, 0x8e, 0x25, 0xb6, 0x4d, 0x1a, 0x2b, 0xe6, 0xaf, 0xee, 0x97}; - uint8_t bytesprops9[] = {0xb, 0xa4, 0xf5, 0xb7, 0x88, 0x83, 0x4a, 0xb8, 0xf9, 0xe1, 0x86}; + msg.payload_len = 24; + + uint8_t bytesprops0[] = {0x41, 0xe5, 0x35, 0xf2, 0x8, 0x14, 0x6d, 0xd4, 0x5d, + 0x36, 0xb2, 0xb2, 0xd2, 0x88, 0x57, 0x58, 0xa, 0x18}; + uint8_t bytesprops1[] = {0x84, 0x5e, 0x5c, 0x88, 0x9f, 0x73, 0xa5, 0x8c, 0x97, 0x6f, 0xc3, 0xe3, 0xaa, + 0x58, 0x52, 0xc5, 0xf7, 0x91, 0x1b, 0x3e, 0x32, 0x46, 0xac, 0x32, 0xbd, 0x5c}; + uint8_t bytesprops2[] = {0x4c, 0x10, 0x7d}; + uint8_t bytesprops3[] = {0xfc, 0x5d, 0xfa, 0xf0, 0xb3, 0xe4, 0x9, 0xac, 0x90, 0xe2, 0xe2, 0x97, 0x28, 0xd6, + 0x9c, 0xe1, 0xd2, 0x41, 0xf1, 0x2e, 0xc6, 0x12, 0x6f, 0xe4, 0x57, 0xdf, 0x6f, 0x5f}; + uint8_t bytesprops4[] = {0xa0, 0xc5, 0xa1, 0x96, 0x57, 0xb3, 0xb5, 0x30, 0x62, + 0x10, 0x6e, 0x1e, 0x28, 0x94, 0x45, 0x54, 0x7c, 0x47}; + uint8_t bytesprops5[] = {0x3c, 0x40, 0x4d, 0xcc, 0xcc, 0xa6, 0x5b, 0xf, 0xb6, + 0x8f, 0xfb, 0x53, 0x35, 0x9c, 0x97, 0x7c, 0xb0}; + uint8_t bytesprops6[] = {0xbd, 0x18, 0x19, 0x41, 0xbc, 0x6c, 0x1a, 0xbe}; + uint8_t bytesprops7[] = {0xea, 0x66, 0xcd, 0x6a, 0xb8, 0x6a, 0xee, 0xf3, 0x75, 0x82, 0xee}; + uint8_t bytesprops8[] = {0xbe, 0x4a, 0x6e, 0x4d, 0xbe, 0x49, 0xbb, 0x2a, 0xd5, 0xdd, + 0xb2, 0xa8, 0x2c, 0x31, 0xaf, 0x61, 0x1a, 0xf4, 0xfe, 0xc0}; + uint8_t bytesprops10[] = {0x3f, 0x14, 0x1, 0x6c, 0x81, 0x32, 0x3f, 0x4c, 0x1f, 0x3}; + uint8_t bytesprops9[] = {0xec, 0x17, 0xeb, 0x52, 0xb6, 0x64, 0xf2, 0xb8, 0xd9, 0xd6, 0x5b, 0x3e, 0x68, + 0xd2, 0xcc, 0xd1, 0xc, 0x92, 0xb7, 0xb9, 0x99, 0xb8, 0x22, 0x1b, 0xea}; + uint8_t bytesprops11[] = {0xea, 0x21, 0x5a, 0x47, 0x52, 0xfe, 0x1e, 0x1f, 0xb7, 0x87, 0xbf}; + uint8_t bytesprops12[] = {0xd9, 0x8d, 0x99, 0x21, 0x56, 0xbb, 0xd8, 0x94, 0x72, 0xd3, + 0x6, 0x19, 0xc5, 0xb7, 0x36, 0xdd, 0x26, 0xb4, 0xed}; + uint8_t bytesprops13[] = {0x65, 0x6e, 0xfc, 0x21}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops1}, .v = {27, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17975}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32302}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31507}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31094}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30094}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3844}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21600}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13269}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18146}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24193}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23833}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12844}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops9}, .v = {10, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6918}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 173}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 9801, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\130\tw\142", _pubPktID = 9801, -// _pubBody = "\154z+\141\DC3\201)z\n", _pubProps = [PropAuthenticationMethod -// "ZB@2{y\190\206\147\202;e\226\144\219s",PropMaximumQoS 20,PropUserProperty "=,\216\239\186\129\162\131" -// "\208&\170\&0K\204\184\&7\142\v\148\246\131%\224\222\255^\237`05\150\154\246\208Q",PropServerReference -// "\196\&8_\204\196\200+.\204x\v\143\245\242\196\227\233BG\t(\161Z\226@x",PropMaximumPacketSize -// 17975,PropWillDelayInterval 32302,PropReasonString "\204z\245\175\135k\225\ENQ\EOT\240\200\221\212!\207\167 -// 4\172]\213]\251B\142\GSV\219",PropPayloadFormatIndicator 233,PropContentType -// "\171\ENQ\DC3\151\236m\131\DC2\DLE1\214s\DC3\ESC\174\144k\164B\249\151",PropMaximumPacketSize 31507,PropTopicAlias -// 31094,PropCorrelationData "~\137s\238\239(\221\ESC\192\193\212",PropRequestProblemInformation -// 96,PropSessionExpiryInterval 30094,PropAuthenticationMethod -// "\DLE#\225\230b\190\225\214\188f\194M\211\219\SIk",PropWillDelayInterval 3844,PropReasonString -// "\172\ETX\142%\182M\SUB+\230\175\238\151",PropServerReference "\v\164\245\183\136\131J\184\249\225\134"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "l\GS\SO\SI\176\NAKT\189\t0b\NUL\154#1", _pubPktID = 0, _pubBody = +// "\180v\132PX\145\222\160?9\205\204\241\168\&5<\235\222\160\\\190Tg\128", _pubProps = [PropResponseTopic +// "A\229\&5\242\b\DC4m\212]6\178\178\210\136WX\n\CAN",PropResponseInformation +// "\132^\\\136\159s\165\140\151o\195\227\170XR\197\247\145\ESC>2F\172\&2\189\\",PropMaximumPacketSize +// 21600,PropMaximumPacketSize 13269,PropRequestProblemInformation 94,PropWillDelayInterval +// 18146,PropRequestResponseInformation 220,PropSubscriptionIdentifierAvailable 112,PropSessionExpiryInterval +// 24193,PropMaximumQoS 254,PropAuthenticationMethod "L\DLE}",PropWildcardSubscriptionAvailable 171,PropResponseTopic +// "\252]\250\240\179\228\t\172\144\226\226\151(\214\156\225\210A\241.\198\DC2o\228W\223o_",PropContentType +// "\160\197\161\150W\179\181\&0b\DLEn\RS(\148ET|G",PropContentType +// "<@M\204\204\166[\SI\182\143\251S5\156\151|\176",PropCorrelationData +// "\189\CAN\EMA\188l\SUB\190",PropResponseInformation "\234f\205j\184j\238\243u\130\238",PropMessageExpiryInterval +// 23833,PropMaximumPacketSize 12844,PropMaximumQoS 135,PropAssignedClientIdentifier +// "\190JnM\190I\187*\213\221\178\168,1\175a\SUB\244\254\192",PropUserProperty +// "\236\ETB\235R\182d\242\184\217\214[>h\210\204\209\f\146\183\185\153\184\"\ESC\234" +// "?\DC4\SOHl\129\&2?L\US\ETX",PropRequestResponseInformation 19,PropWildcardSubscriptionAvailable +// 22,PropAssignedClientIdentifier "\234!ZGR\254\RS\US\183\135\191",PropReasonString +// "\217\141\153!V\187\216\148r\211\ACK\EM\197\183\&6\221&\180\237",PropResponseTopic "en\252!",PropWillDelayInterval +// 6918,PropRequestProblemInformation 173]} TEST(Publish5QCTest, Decode7) { uint8_t pkt[] = { - 0x32, 0x82, 0x2, 0x0, 0x4, 0x82, 0x9, 0x77, 0x8e, 0x26, 0x49, 0xef, 0x1, 0x15, 0x0, 0x10, 0x5a, 0x42, 0x40, - 0x32, 0x7b, 0x79, 0xbe, 0xce, 0x93, 0xca, 0x3b, 0x65, 0xe2, 0x90, 0xdb, 0x73, 0x24, 0x14, 0x26, 0x0, 0x8, 0x3d, - 0x2c, 0xd8, 0xef, 0xba, 0x81, 0xa2, 0x83, 0x0, 0x1b, 0xd0, 0x26, 0xaa, 0x30, 0x4b, 0xcc, 0xb8, 0x37, 0x8e, 0xb, - 0x94, 0xf6, 0x83, 0x25, 0xe0, 0xde, 0xff, 0x5e, 0xed, 0x60, 0x30, 0x35, 0x96, 0x9a, 0xf6, 0xd0, 0x51, 0x1c, 0x0, - 0x1a,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bc, 0x6c, 0x1a, + 0xbe, 0x1a, 0x0, 0xb, 0xea, 0x66, 0xcd, 0x6a, 0xb8, 0x6a, 0xee, 0xf3, 0x75, 0x82, 0xee, 0x2, 0x0, 0x0, 0x5d, + 0x19, 0x27, 0x0, 0x0, 0x32, 0x2c, 0x24, 0x87, 0x12, 0x0, 0x14, 0xbe, 0x4a, 0x6e, 0x4d, 0xbe, 0x49, 0xbb, 0x2a, + 0xd5, 0xdd, 0xb2, 0xa8, 0x2c, 0x31, 0xaf, 0x61, 0x1a, 0xf4, 0xfe, 0xc0, 0x26, 0x0, 0x19, 0xec, 0x17, 0xeb, 0x52, + 0xb6, 0x64, 0xf2, 0xb8, 0xd9, 0xd6, 0x5b, 0x3e, 0x68, 0xd2, 0xcc, 0xd1, 0xc, 0x92, 0xb7, 0xb9, 0x99, 0xb8, 0x22, + 0x1b, 0xea, 0x0, 0xa, 0x3f, 0x14, 0x1, 0x6c, 0x81, 0x32, 0x3f, 0x4c, 0x1f, 0x3, 0x19, 0x13, 0x28, 0x16, 0x12, + 0x0, 0xb, 0xea, 0x21, 0x5a, 0x47, 0x52, 0xfe, 0x1e, 0x1f, 0xb7, 0x87, 0xbf, 0x1f, 0x0, 0x13, 0xd9, 0x8d, 0x99, + 0x21, 0x56, 0xbb, 0xd8, 0x94, 0x72, 0xd3, 0x6, 0x19, 0xc5, 0xb7, 0x36, 0xdd, 0x26, 0xb4, 0xed, 0x8, 0x0, 0x4, + 0x65, 0x6e, 0xfc, 0x21, 0x18, 0x0, 0x0, 0x1b, 0x6, 0x17, 0xad, 0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, + 0x3f, 0x39, 0xcd, 0xcc, 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1428,110 +1507,85 @@ TEST(Publish5QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x82, 0x9, 0x77, 0x8e}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9a, 0x7a, 0x2b, 0x8d, 0x13, 0xc9, 0x29, 0x7a, 0xa}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, 0x0, 0x9a, 0x23, 0x31}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, 0x3f, 0x39, 0xcd, 0xcc, + 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 9801); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "W\165\ETX\202d\140Z\185\FSm\158\159\206Gj\177D\DC3\250=", _pubPktID = 0, _pubBody = -// "\204r\156\176\144\163\ESC+\228\214X\196\&6\212\179\NULI\132\128`nQ\153\188\153", _pubProps = [PropContentType -// "\238\173[.y\187\201",PropCorrelationData -// "\196u\DC2K\206\224\240\249\238\DC3>\175\GS\EMS6/v*\SI\222\EM\236\153\245$=",PropMaximumPacketSize -// 16725,PropSharedSubscriptionAvailable 42,PropAuthenticationData "\147\"?\178\238)\SOH -// \246\196\211\208\183<\180W\n",PropServerKeepAlive 9570,PropCorrelationData -// "\ESC?\180\ETB\217B\r\176B\166^\190\FS\a'\189\247\t]\246\171P\200\138",PropRequestResponseInformation -// 148,PropRequestResponseInformation 49,PropRequestResponseInformation 139,PropResponseTopic -// "",PropAssignedClientIdentifier ""]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\244_\249R\255\232t\194", _pubPktID +// = 4521, _pubBody = "\213\SOQ\252\167\179#\DEL\SIc\223\EOT\156\210\214\bp", _pubProps = [PropRetainAvailable +// 141,PropAssignedClientIdentifier +// "\198\246L\228q\t\203\216\147\GS\"*\181\f\198\DELAn\SO\185\232\DC3\195\181\193",PropSessionExpiryInterval +// 28422,PropRetainAvailable 4,PropSharedSubscriptionAvailable 192,PropPayloadFormatIndicator 178,PropResponseTopic " +// \161\189",PropAssignedClientIdentifier "\142YT\144%\STX\bL\fK^\163\134^\212Z\199\234]"]} TEST(Publish5QCTest, Encode8) { - uint8_t pkt[] = {0x39, 0x9d, 0x1, 0x0, 0x14, 0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, 0x9e, - 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d, 0x6d, 0x3, 0x0, 0x7, 0xee, 0xad, 0x5b, - 0x2e, 0x79, 0xbb, 0xc9, 0x9, 0x0, 0x1b, 0xc4, 0x75, 0x12, 0x4b, 0xce, 0xe0, 0xf0, 0xf9, 0xee, - 0x13, 0x3e, 0xaf, 0x1d, 0x19, 0x53, 0x36, 0x2f, 0x76, 0x2a, 0xf, 0xde, 0x19, 0xec, 0x99, 0xf5, - 0x24, 0x3d, 0x27, 0x0, 0x0, 0x41, 0x55, 0x2a, 0x2a, 0x16, 0x0, 0x11, 0x93, 0x22, 0x3f, 0xb2, - 0xee, 0x29, 0x1, 0x20, 0xf6, 0xc4, 0xd3, 0xd0, 0xb7, 0x3c, 0xb4, 0x57, 0xa, 0x13, 0x25, 0x62, - 0x9, 0x0, 0x18, 0x1b, 0x3f, 0xb4, 0x17, 0xd9, 0x42, 0xd, 0xb0, 0x42, 0xa6, 0x5e, 0xbe, 0x1c, - 0x7, 0x27, 0xbd, 0xf7, 0x9, 0x5d, 0xf6, 0xab, 0x50, 0xc8, 0x8a, 0x19, 0x94, 0x19, 0x31, 0x19, - 0x8b, 0x8, 0x0, 0x0, 0x12, 0x0, 0x0, 0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, - 0xd6, 0x58, 0xc4, 0x36, 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; - - uint8_t buf[170] = {0}; - - uint8_t topic_bytes[] = {0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, - 0x9e, 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x63, 0x0, 0x8, 0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2, 0x11, 0xa9, 0x45, 0x25, 0x8d, + 0x12, 0x0, 0x19, 0xc6, 0xf6, 0x4c, 0xe4, 0x71, 0x9, 0xcb, 0xd8, 0x93, 0x1d, 0x22, 0x2a, 0xb5, 0xc, + 0xc6, 0x7f, 0x41, 0x6e, 0xe, 0xb9, 0xe8, 0x13, 0xc3, 0xb5, 0xc1, 0x11, 0x0, 0x0, 0x6f, 0x6, 0x25, + 0x4, 0x2a, 0xc0, 0x1, 0xb2, 0x8, 0x0, 0x3, 0x20, 0xa1, 0xbd, 0x12, 0x0, 0x13, 0x8e, 0x59, 0x54, + 0x90, 0x25, 0x2, 0x8, 0x4c, 0xc, 0x4b, 0x5e, 0xa3, 0x86, 0x5e, 0xd4, 0x5a, 0xc7, 0xea, 0x5d, 0xd5, + 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; + + uint8_t buf[111] = {0}; + uint8_t topic_bytes[] = {0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, 0x58, 0xc4, 0x36, - 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; + uint8_t msg_bytes[] = {0xd5, 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, + 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; - - uint8_t bytesprops0[] = {0xee, 0xad, 0x5b, 0x2e, 0x79, 0xbb, 0xc9}; - uint8_t bytesprops1[] = {0xc4, 0x75, 0x12, 0x4b, 0xce, 0xe0, 0xf0, 0xf9, 0xee, 0x13, 0x3e, 0xaf, 0x1d, 0x19, - 0x53, 0x36, 0x2f, 0x76, 0x2a, 0xf, 0xde, 0x19, 0xec, 0x99, 0xf5, 0x24, 0x3d}; - uint8_t bytesprops2[] = {0x93, 0x22, 0x3f, 0xb2, 0xee, 0x29, 0x1, 0x20, 0xf6, - 0xc4, 0xd3, 0xd0, 0xb7, 0x3c, 0xb4, 0x57, 0xa}; - uint8_t bytesprops3[] = {0x1b, 0x3f, 0xb4, 0x17, 0xd9, 0x42, 0xd, 0xb0, 0x42, 0xa6, 0x5e, 0xbe, - 0x1c, 0x7, 0x27, 0xbd, 0xf7, 0x9, 0x5d, 0xf6, 0xab, 0x50, 0xc8, 0x8a}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0}; + msg.payload_len = 17; + + uint8_t bytesprops0[] = {0xc6, 0xf6, 0x4c, 0xe4, 0x71, 0x9, 0xcb, 0xd8, 0x93, 0x1d, 0x22, 0x2a, 0xb5, + 0xc, 0xc6, 0x7f, 0x41, 0x6e, 0xe, 0xb9, 0xe8, 0x13, 0xc3, 0xb5, 0xc1}; + uint8_t bytesprops1[] = {0x20, 0xa1, 0xbd}; + uint8_t bytesprops2[] = {0x8e, 0x59, 0x54, 0x90, 0x25, 0x2, 0x8, 0x4c, 0xc, 0x4b, + 0x5e, 0xa3, 0x86, 0x5e, 0xd4, 0x5a, 0xc7, 0xea, 0x5d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16725}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9570}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28422}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 4521, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "W\165\ETX\202d\140Z\185\FSm\158\159\206Gj\177D\DC3\250=", _pubPktID = 0, _pubBody = -// "\204r\156\176\144\163\ESC+\228\214X\196\&6\212\179\NULI\132\128`nQ\153\188\153", _pubProps = [PropContentType -// "\238\173[.y\187\201",PropCorrelationData -// "\196u\DC2K\206\224\240\249\238\DC3>\175\GS\EMS6/v*\SI\222\EM\236\153\245$=",PropMaximumPacketSize -// 16725,PropSharedSubscriptionAvailable 42,PropAuthenticationData "\147\"?\178\238)\SOH -// \246\196\211\208\183<\180W\n",PropServerKeepAlive 9570,PropCorrelationData -// "\ESC?\180\ETB\217B\r\176B\166^\190\FS\a'\189\247\t]\246\171P\200\138",PropRequestResponseInformation -// 148,PropRequestResponseInformation 49,PropRequestResponseInformation 139,PropResponseTopic -// "",PropAssignedClientIdentifier ""]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\244_\249R\255\232t\194", _pubPktID +// = 4521, _pubBody = "\213\SOQ\252\167\179#\DEL\SIc\223\EOT\156\210\214\bp", _pubProps = [PropRetainAvailable +// 141,PropAssignedClientIdentifier +// "\198\246L\228q\t\203\216\147\GS\"*\181\f\198\DELAn\SO\185\232\DC3\195\181\193",PropSessionExpiryInterval +// 28422,PropRetainAvailable 4,PropSharedSubscriptionAvailable 192,PropPayloadFormatIndicator 178,PropResponseTopic " +// \161\189",PropAssignedClientIdentifier "\142YT\144%\STX\bL\fK^\163\134^\212Z\199\234]"]} TEST(Publish5QCTest, Decode8) { - uint8_t pkt[] = {0x39, 0x9d, 0x1, 0x0, 0x14, 0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, 0x9e, - 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d, 0x6d, 0x3, 0x0, 0x7, 0xee, 0xad, 0x5b, - 0x2e, 0x79, 0xbb, 0xc9, 0x9, 0x0, 0x1b, 0xc4, 0x75, 0x12, 0x4b, 0xce, 0xe0, 0xf0, 0xf9, 0xee, - 0x13, 0x3e, 0xaf, 0x1d, 0x19, 0x53, 0x36, 0x2f, 0x76, 0x2a, 0xf, 0xde, 0x19, 0xec, 0x99, 0xf5, - 0x24, 0x3d, 0x27, 0x0, 0x0, 0x41, 0x55, 0x2a, 0x2a, 0x16, 0x0, 0x11, 0x93, 0x22, 0x3f, 0xb2, - 0xee, 0x29, 0x1, 0x20, 0xf6, 0xc4, 0xd3, 0xd0, 0xb7, 0x3c, 0xb4, 0x57, 0xa, 0x13, 0x25, 0x62, - 0x9, 0x0, 0x18, 0x1b, 0x3f, 0xb4, 0x17, 0xd9, 0x42, 0xd, 0xb0, 0x42, 0xa6, 0x5e, 0xbe, 0x1c, - 0x7, 0x27, 0xbd, 0xf7, 0x9, 0x5d, 0xf6, 0xab, 0x50, 0xc8, 0x8a, 0x19, 0x94, 0x19, 0x31, 0x19, - 0x8b, 0x8, 0x0, 0x0, 0x12, 0x0, 0x0, 0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, - 0xd6, 0x58, 0xc4, 0x36, 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; + uint8_t pkt[] = {0x35, 0x63, 0x0, 0x8, 0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2, 0x11, 0xa9, 0x45, 0x25, 0x8d, + 0x12, 0x0, 0x19, 0xc6, 0xf6, 0x4c, 0xe4, 0x71, 0x9, 0xcb, 0xd8, 0x93, 0x1d, 0x22, 0x2a, 0xb5, 0xc, + 0xc6, 0x7f, 0x41, 0x6e, 0xe, 0xb9, 0xe8, 0x13, 0xc3, 0xb5, 0xc1, 0x11, 0x0, 0x0, 0x6f, 0x6, 0x25, + 0x4, 0x2a, 0xc0, 0x1, 0xb2, 0x8, 0x0, 0x3, 0x20, 0xa1, 0xbd, 0x12, 0x0, 0x13, 0x8e, 0x59, 0x54, + 0x90, 0x25, 0x2, 0x8, 0x4c, 0xc, 0x4b, 0x5e, 0xa3, 0x86, 0x5e, 0xd4, 0x5a, 0xc7, 0xea, 0x5d, 0xd5, + 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1539,98 +1593,100 @@ TEST(Publish5QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x57, 0xa5, 0x3, 0xca, 0x64, 0x8c, 0x5a, 0xb9, 0x1c, 0x6d, - 0x9e, 0x9f, 0xce, 0x47, 0x6a, 0xb1, 0x44, 0x13, 0xfa, 0x3d}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcc, 0x72, 0x9c, 0xb0, 0x90, 0xa3, 0x1b, 0x2b, 0xe4, 0xd6, 0x58, 0xc4, 0x36, - 0xd4, 0xb3, 0x0, 0x49, 0x84, 0x80, 0x60, 0x6e, 0x51, 0x99, 0xbc, 0x99}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + uint8_t exp_topic_bytes[] = {0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd5, 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, + 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + EXPECT_EQ(packet_id, 4521); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\STX", _pubPktID = 30584, _pubBody = -// "u\219\"\173\243\187\226Z\193\t\210\"\201K)", _pubProps = [PropSharedSubscriptionAvailable -// 48,PropPayloadFormatIndicator 15,PropSubscriptionIdentifierAvailable 46,PropContentType "\220\191\t;G\215.\NUL -// (\148N&\156\242\186\142",PropSubscriptionIdentifierAvailable 8,PropCorrelationData -// ":\223\CAN\213\&6\135ah\135\224\239S\185\249\DEL\162;\250\ESC\233",PropPayloadFormatIndicator 112,PropCorrelationData -// "\RS\129\208>\230\f\246I\196\246\250K\130\163\242\221",PropReceiveMaximum 15410,PropWillDelayInterval -// 6524,PropServerReference "\144\201\151\159{&\248\208\215\ETXb\198\175\ETX\215!"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "a\239\170\203|\"\t\198g\b\v[V\ETXkc\GS+\205\&5Q13M\196E", _pubPktID = 21638, _pubBody = +// "\NAK\153\221\DC3\250(2\DC2\166z\179\183Z\205>5\158\160\245", _pubProps = [PropContentType +// "\176\254u\222\148\197\221B \168",PropTopicAliasMaximum 19316,PropCorrelationData "R\222g",PropAuthenticationData +// "q\219\133G\216b,p\148\GS\132\181\185\224\131\146\145.\NUL\149\253\GSPn\147#\236k\ACKI",PropMaximumPacketSize +// 11778,PropResponseTopic +// "\228\239I\244hm\STX\SOz\244\156\192#8\197\194\a\201T\176\254.\237\201\GS\EOT`S\248\RS",PropRequestResponseInformation +// 101,PropAssignedClientIdentifier "\164@\128\131B\169\131#D\230\f\246I\196\246\250K\130\163\242\221",PropReceiveMaximum 15410,PropWillDelayInterval -// 6524,PropServerReference "\144\201\151\159{&\248\208\215\ETXb\198\175\ETX\215!"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "a\239\170\203|\"\t\198g\b\v[V\ETXkc\GS+\205\&5Q13M\196E", _pubPktID = 21638, _pubBody = +// "\NAK\153\221\DC3\250(2\DC2\166z\179\183Z\205>5\158\160\245", _pubProps = [PropContentType +// "\176\254u\222\148\197\221B \168",PropTopicAliasMaximum 19316,PropCorrelationData "R\222g",PropAuthenticationData +// "q\219\133G\216b,p\148\GS\132\181\185\224\131\146\145.\NUL\149\253\GSPn\147#\236k\ACKI",PropMaximumPacketSize +// 11778,PropResponseTopic +// "\228\239I\244hm\STX\SOz\244\156\192#8\197\194\a\201T\176\254.\237\201\GS\EOT`S\248\RS",PropRequestResponseInformation +// 101,PropAssignedClientIdentifier "\164@\128\131B\169\131#D(topic.data), 1); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 21638); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "E_/\183|O\206\131\173f\212\204", -// _pubPktID = 31613, _pubBody = "\155\216/Ef", _pubProps = [PropServerReference -// "r>\SOX\140\NUL\SO\ETX\176\133B\f\156\234\STX\202_:\EOT\160\206n\219\229H\151\SI\185",PropMaximumQoS -// 173,PropReceiveMaximum 18751,PropRequestResponseInformation 60,PropMaximumPacketSize 6732,PropReceiveMaximum -// 11501,PropSessionExpiryInterval 17948,PropServerKeepAlive 10159,PropServerKeepAlive -// 4218,PropRequestProblemInformation 31,PropMessageExpiryInterval 31284,PropServerReference -// "\SO\220\235",PropReceiveMaximum 15238,PropMessageExpiryInterval 8262,PropContentType -// "\137)\ESCSg\226S\205\235\RS\194\DC2e\246\ESC\146\SO\216",PropRetainAvailable 89,PropMaximumPacketSize -// 21478,PropServerKeepAlive 12711,PropAuthenticationMethod -// "\DC4\182\SYNJ\156\159\224{\RS\146Q\151\229\207\185\146\SIaEOCa",PropServerReference -// "P\229fx\DC4\131\176Wk\ETBXI\ETX\142",PropAssignedClientIdentifier -// "\ESCV5\DC1\ENQ-\215\246\172F\140\242\\V\188\SI!\222\STX\DLE\249",PropRequestResponseInformation -// 120,PropWillDelayInterval 16810,PropSubscriptionIdentifier 16]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "3\DC2\163\160\US\252\129\206\EMa\SYN\ESC\248J%\210\t0\224\159T\165\137&\153", _pubPktID = 14459, _pubBody = +// "\161;R\191\DC4\212,\ETB\168<\r}\244\250\&6\145_\153\241\218\175\133\NAK\SO\234\f", _pubProps = +// [PropWillDelayInterval 19833,PropContentType "'f\225\ETB\202",PropServerKeepAlive 17420,PropPayloadFormatIndicator +// 155,PropServerKeepAlive 11561,PropTopicAliasMaximum 5638,PropResponseInformation +// "\FS\EM\145\217\SUB\GS_R\f\175",PropResponseTopic +// "k\ETB\180g\156\223\215\CAN[\207\188mH\200\ETB\230\203\220\177\173\158\149\178@",PropReasonString +// "\149\180\194\131T\234&\237\143\170\166",PropMaximumQoS 239,PropAssignedClientIdentifier +// "Z\233,B\231\vH\143\DC1d\SO\233\163\202\213",PropResponseInformation +// "\r\226jm\227\213A>N/\157\185F\164",PropTopicAliasMaximum 13496]} TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = {0x32, 0xcf, 0x1, 0x0, 0xc, 0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc, - 0x7b, 0x7d, 0xb8, 0x1, 0x1c, 0x0, 0x1c, 0x72, 0x3e, 0xe, 0x58, 0x8c, 0x0, 0xe, 0x3, 0xb0, 0x85, - 0x42, 0xc, 0x9c, 0xea, 0x2, 0xca, 0x5f, 0x3a, 0x4, 0xa0, 0xce, 0x6e, 0xdb, 0xe5, 0x48, 0x97, 0xf, - 0xb9, 0x24, 0xad, 0x21, 0x49, 0x3f, 0x19, 0x3c, 0x27, 0x0, 0x0, 0x1a, 0x4c, 0x21, 0x2c, 0xed, 0x11, - 0x0, 0x0, 0x46, 0x1c, 0x13, 0x27, 0xaf, 0x13, 0x10, 0x7a, 0x17, 0x1f, 0x2, 0x0, 0x0, 0x7a, 0x34, - 0x1c, 0x0, 0x3, 0xe, 0xdc, 0xeb, 0x21, 0x3b, 0x86, 0x2, 0x0, 0x0, 0x20, 0x46, 0x3, 0x0, 0x12, - 0x89, 0x29, 0x1b, 0x53, 0x67, 0xe2, 0x53, 0xcd, 0xeb, 0x1e, 0xc2, 0x12, 0x65, 0xf6, 0x1b, 0x92, 0xe, - 0xd8, 0x25, 0x59, 0x27, 0x0, 0x0, 0x53, 0xe6, 0x13, 0x31, 0xa7, 0x15, 0x0, 0x16, 0x14, 0xb6, 0x16, - 0x4a, 0x9c, 0x9f, 0xe0, 0x7b, 0x1e, 0x92, 0x51, 0x97, 0xe5, 0xcf, 0xb9, 0x92, 0xf, 0x61, 0x45, 0x4f, - 0x43, 0x61, 0x1c, 0x0, 0xe, 0x50, 0xe5, 0x66, 0x78, 0x14, 0x83, 0xb0, 0x57, 0x6b, 0x17, 0x58, 0x49, - 0x3, 0x8e, 0x12, 0x0, 0x15, 0x1b, 0x56, 0x35, 0x11, 0x5, 0x2d, 0xd7, 0xf6, 0xac, 0x46, 0x8c, 0xf2, - 0x5c, 0x56, 0xbc, 0xf, 0x21, 0xde, 0x2, 0x10, 0xf9, 0x19, 0x78, 0x18, 0x0, 0x0, 0x41, 0xaa, 0xb, - 0x10, 0x9b, 0xd8, 0x2f, 0x45, 0x66}; - - uint8_t buf[220] = {0}; - - uint8_t topic_bytes[] = {0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0xae, 0x1, 0x0, 0x19, 0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, + 0xf8, 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99, 0x38, 0x7b, 0x76, 0x18, + 0x0, 0x0, 0x4d, 0x79, 0x3, 0x0, 0x5, 0x27, 0x66, 0xe1, 0x17, 0xca, 0x13, 0x44, 0xc, 0x1, 0x9b, + 0x13, 0x2d, 0x29, 0x22, 0x16, 0x6, 0x1a, 0x0, 0xa, 0x1c, 0x19, 0x91, 0xd9, 0x1a, 0x1d, 0x5f, 0x52, + 0xc, 0xaf, 0x8, 0x0, 0x18, 0x6b, 0x17, 0xb4, 0x67, 0x9c, 0xdf, 0xd7, 0x18, 0x5b, 0xcf, 0xbc, 0x6d, + 0x48, 0xc8, 0x17, 0xe6, 0xcb, 0xdc, 0xb1, 0xad, 0x9e, 0x95, 0xb2, 0x40, 0x1f, 0x0, 0xb, 0x95, 0xb4, + 0xc2, 0x83, 0x54, 0xea, 0x26, 0xed, 0x8f, 0xaa, 0xa6, 0x24, 0xef, 0x12, 0x0, 0xf, 0x5a, 0xe9, 0x2c, + 0x42, 0xe7, 0xb, 0x48, 0x8f, 0x11, 0x64, 0xe, 0xe9, 0xa3, 0xca, 0xd5, 0x1a, 0x0, 0xe, 0xd, 0xe2, + 0x6a, 0x6d, 0xe3, 0xd5, 0x41, 0x3e, 0x4e, 0x2f, 0x9d, 0xb9, 0x46, 0xa4, 0x22, 0x34, 0xb8, 0xa1, 0x3b, + 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, + 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; + + uint8_t buf[187] = {0}; + uint8_t topic_bytes[] = {0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, 0xf8, + 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x9b, 0xd8, 0x2f, 0x45, 0x66}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, + 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; - - uint8_t bytesprops0[] = {0x72, 0x3e, 0xe, 0x58, 0x8c, 0x0, 0xe, 0x3, 0xb0, 0x85, 0x42, 0xc, 0x9c, 0xea, - 0x2, 0xca, 0x5f, 0x3a, 0x4, 0xa0, 0xce, 0x6e, 0xdb, 0xe5, 0x48, 0x97, 0xf, 0xb9}; - uint8_t bytesprops1[] = {0xe, 0xdc, 0xeb}; - uint8_t bytesprops2[] = {0x89, 0x29, 0x1b, 0x53, 0x67, 0xe2, 0x53, 0xcd, 0xeb, - 0x1e, 0xc2, 0x12, 0x65, 0xf6, 0x1b, 0x92, 0xe, 0xd8}; - uint8_t bytesprops3[] = {0x14, 0xb6, 0x16, 0x4a, 0x9c, 0x9f, 0xe0, 0x7b, 0x1e, 0x92, 0x51, - 0x97, 0xe5, 0xcf, 0xb9, 0x92, 0xf, 0x61, 0x45, 0x4f, 0x43, 0x61}; - uint8_t bytesprops4[] = {0x50, 0xe5, 0x66, 0x78, 0x14, 0x83, 0xb0, 0x57, 0x6b, 0x17, 0x58, 0x49, 0x3, 0x8e}; - uint8_t bytesprops5[] = {0x1b, 0x56, 0x35, 0x11, 0x5, 0x2d, 0xd7, 0xf6, 0xac, 0x46, 0x8c, - 0xf2, 0x5c, 0x56, 0xbc, 0xf, 0x21, 0xde, 0x2, 0x10, 0xf9}; + msg.payload_len = 26; + + uint8_t bytesprops0[] = {0x27, 0x66, 0xe1, 0x17, 0xca}; + uint8_t bytesprops1[] = {0x1c, 0x19, 0x91, 0xd9, 0x1a, 0x1d, 0x5f, 0x52, 0xc, 0xaf}; + uint8_t bytesprops2[] = {0x6b, 0x17, 0xb4, 0x67, 0x9c, 0xdf, 0xd7, 0x18, 0x5b, 0xcf, 0xbc, 0x6d, + 0x48, 0xc8, 0x17, 0xe6, 0xcb, 0xdc, 0xb1, 0xad, 0x9e, 0x95, 0xb2, 0x40}; + uint8_t bytesprops3[] = {0x95, 0xb4, 0xc2, 0x83, 0x54, 0xea, 0x26, 0xed, 0x8f, 0xaa, 0xa6}; + uint8_t bytesprops4[] = {0x5a, 0xe9, 0x2c, 0x42, 0xe7, 0xb, 0x48, 0x8f, 0x11, 0x64, 0xe, 0xe9, 0xa3, 0xca, 0xd5}; + uint8_t bytesprops5[] = {0xd, 0xe2, 0x6a, 0x6d, 0xe3, 0xd5, 0x41, 0x3e, 0x4e, 0x2f, 0x9d, 0xb9, 0x46, 0xa4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18751}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6732}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11501}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17948}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10159}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4218}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31284}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15238}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8262}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21478}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12711}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16810}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19833}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17420}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11561}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5638}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13496}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 31613, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14459, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "E_/\183|O\206\131\173f\212\204", -// _pubPktID = 31613, _pubBody = "\155\216/Ef", _pubProps = [PropServerReference -// "r>\SOX\140\NUL\SO\ETX\176\133B\f\156\234\STX\202_:\EOT\160\206n\219\229H\151\SI\185",PropMaximumQoS -// 173,PropReceiveMaximum 18751,PropRequestResponseInformation 60,PropMaximumPacketSize 6732,PropReceiveMaximum -// 11501,PropSessionExpiryInterval 17948,PropServerKeepAlive 10159,PropServerKeepAlive -// 4218,PropRequestProblemInformation 31,PropMessageExpiryInterval 31284,PropServerReference -// "\SO\220\235",PropReceiveMaximum 15238,PropMessageExpiryInterval 8262,PropContentType -// "\137)\ESCSg\226S\205\235\RS\194\DC2e\246\ESC\146\SO\216",PropRetainAvailable 89,PropMaximumPacketSize -// 21478,PropServerKeepAlive 12711,PropAuthenticationMethod -// "\DC4\182\SYNJ\156\159\224{\RS\146Q\151\229\207\185\146\SIaEOCa",PropServerReference -// "P\229fx\DC4\131\176Wk\ETBXI\ETX\142",PropAssignedClientIdentifier -// "\ESCV5\DC1\ENQ-\215\246\172F\140\242\\V\188\SI!\222\STX\DLE\249",PropRequestResponseInformation -// 120,PropWillDelayInterval 16810,PropSubscriptionIdentifier 16]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "3\DC2\163\160\US\252\129\206\EMa\SYN\ESC\248J%\210\t0\224\159T\165\137&\153", _pubPktID = 14459, _pubBody = +// "\161;R\191\DC4\212,\ETB\168<\r}\244\250\&6\145_\153\241\218\175\133\NAK\SO\234\f", _pubProps = +// [PropWillDelayInterval 19833,PropContentType "'f\225\ETB\202",PropServerKeepAlive 17420,PropPayloadFormatIndicator +// 155,PropServerKeepAlive 11561,PropTopicAliasMaximum 5638,PropResponseInformation +// "\FS\EM\145\217\SUB\GS_R\f\175",PropResponseTopic +// "k\ETB\180g\156\223\215\CAN[\207\188mH\200\ETB\230\203\220\177\173\158\149\178@",PropReasonString +// "\149\180\194\131T\234&\237\143\170\166",PropMaximumQoS 239,PropAssignedClientIdentifier +// "Z\233,B\231\vH\143\DC1d\SO\233\163\202\213",PropResponseInformation +// "\r\226jm\227\213A>N/\157\185F\164",PropTopicAliasMaximum 13496]} TEST(Publish5QCTest, Decode10) { - uint8_t pkt[] = {0x32, 0xcf, 0x1, 0x0, 0xc, 0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc, - 0x7b, 0x7d, 0xb8, 0x1, 0x1c, 0x0, 0x1c, 0x72, 0x3e, 0xe, 0x58, 0x8c, 0x0, 0xe, 0x3, 0xb0, 0x85, - 0x42, 0xc, 0x9c, 0xea, 0x2, 0xca, 0x5f, 0x3a, 0x4, 0xa0, 0xce, 0x6e, 0xdb, 0xe5, 0x48, 0x97, 0xf, - 0xb9, 0x24, 0xad, 0x21, 0x49, 0x3f, 0x19, 0x3c, 0x27, 0x0, 0x0, 0x1a, 0x4c, 0x21, 0x2c, 0xed, 0x11, - 0x0, 0x0, 0x46, 0x1c, 0x13, 0x27, 0xaf, 0x13, 0x10, 0x7a, 0x17, 0x1f, 0x2, 0x0, 0x0, 0x7a, 0x34, - 0x1c, 0x0, 0x3, 0xe, 0xdc, 0xeb, 0x21, 0x3b, 0x86, 0x2, 0x0, 0x0, 0x20, 0x46, 0x3, 0x0, 0x12, - 0x89, 0x29, 0x1b, 0x53, 0x67, 0xe2, 0x53, 0xcd, 0xeb, 0x1e, 0xc2, 0x12, 0x65, 0xf6, 0x1b, 0x92, 0xe, - 0xd8, 0x25, 0x59, 0x27, 0x0, 0x0, 0x53, 0xe6, 0x13, 0x31, 0xa7, 0x15, 0x0, 0x16, 0x14, 0xb6, 0x16, - 0x4a, 0x9c, 0x9f, 0xe0, 0x7b, 0x1e, 0x92, 0x51, 0x97, 0xe5, 0xcf, 0xb9, 0x92, 0xf, 0x61, 0x45, 0x4f, - 0x43, 0x61, 0x1c, 0x0, 0xe, 0x50, 0xe5, 0x66, 0x78, 0x14, 0x83, 0xb0, 0x57, 0x6b, 0x17, 0x58, 0x49, - 0x3, 0x8e, 0x12, 0x0, 0x15, 0x1b, 0x56, 0x35, 0x11, 0x5, 0x2d, 0xd7, 0xf6, 0xac, 0x46, 0x8c, 0xf2, - 0x5c, 0x56, 0xbc, 0xf, 0x21, 0xde, 0x2, 0x10, 0xf9, 0x19, 0x78, 0x18, 0x0, 0x0, 0x41, 0xaa, 0xb, - 0x10, 0x9b, 0xd8, 0x2f, 0x45, 0x66}; + uint8_t pkt[] = {0x35, 0xae, 0x1, 0x0, 0x19, 0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, + 0xf8, 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99, 0x38, 0x7b, 0x76, 0x18, + 0x0, 0x0, 0x4d, 0x79, 0x3, 0x0, 0x5, 0x27, 0x66, 0xe1, 0x17, 0xca, 0x13, 0x44, 0xc, 0x1, 0x9b, + 0x13, 0x2d, 0x29, 0x22, 0x16, 0x6, 0x1a, 0x0, 0xa, 0x1c, 0x19, 0x91, 0xd9, 0x1a, 0x1d, 0x5f, 0x52, + 0xc, 0xaf, 0x8, 0x0, 0x18, 0x6b, 0x17, 0xb4, 0x67, 0x9c, 0xdf, 0xd7, 0x18, 0x5b, 0xcf, 0xbc, 0x6d, + 0x48, 0xc8, 0x17, 0xe6, 0xcb, 0xdc, 0xb1, 0xad, 0x9e, 0x95, 0xb2, 0x40, 0x1f, 0x0, 0xb, 0x95, 0xb4, + 0xc2, 0x83, 0x54, 0xea, 0x26, 0xed, 0x8f, 0xaa, 0xa6, 0x24, 0xef, 0x12, 0x0, 0xf, 0x5a, 0xe9, 0x2c, + 0x42, 0xe7, 0xb, 0x48, 0x8f, 0x11, 0x64, 0xe, 0xe9, 0xa3, 0xca, 0xd5, 0x1a, 0x0, 0xe, 0xd, 0xe2, + 0x6a, 0x6d, 0xe3, 0xd5, 0x41, 0x3e, 0x4e, 0x2f, 0x9d, 0xb9, 0x46, 0xa4, 0x22, 0x34, 0xb8, 0xa1, 0x3b, + 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, + 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1772,38 +1807,38 @@ TEST(Publish5QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x45, 0x5f, 0x2f, 0xb7, 0x7c, 0x4f, 0xce, 0x83, 0xad, 0x66, 0xd4, 0xcc}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9b, 0xd8, 0x2f, 0x45, 0x66}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, 0xf8, + 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, + 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 31613); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 14459); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// ConnectRequest {_username = Just -// "\185\251\207\168Q\134\135\143\222\196\233\144\GS2\233\186\RS9\206\169\133%\142\159\215\144I", _password = Just -// "\226\211\189:\248cm\238\136\&0\f\162/\b\199!", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, -// _willTopic = ")V\230\ETB\138\201\162\143nR~n\217\SUBq\193\137\223\STX\EOT\218o-", _willMsg = -// "8\US\146\&6\140\255wr\180\153\226P\197c\191\139y\166q\243\140\235", _willProps = []}), _cleanSession = False, -// _keepAlive = 26495, _connID = "\178t?\235s\202\a;KB\143\142\223\245\b\219\194\166\232\CAN@", _properties = []} +// ConnectRequest {_username = Just "\\$\245\DELg\180\&6\136n\177S\153", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\187\152\148yT\196\161\178\207\&7:s\148\144\169n\217\222n=u\190\f\147", _willMsg = +// "r\244\252S\171\236L\225\159\&2\192\246\223\255o)`\238\SOn\DC3", _willProps = []}), _cleanSession = False, _keepAlive +// = 12967, _connID = "\SI\255\178<\ETBPC\254\194 f:\152s}\165&\SO M`\251\NULx\STXiB", _properties = []} TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x81, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x67, 0x7f, 0x0, 0x15, 0xb2, 0x74, - 0x3f, 0xeb, 0x73, 0xca, 0x7, 0x3b, 0x4b, 0x42, 0x8f, 0x8e, 0xdf, 0xf5, 0x8, 0xdb, 0xc2, 0xa6, 0xe8, - 0x18, 0x40, 0x0, 0x17, 0x29, 0x56, 0xe6, 0x17, 0x8a, 0xc9, 0xa2, 0x8f, 0x6e, 0x52, 0x7e, 0x6e, 0xd9, - 0x1a, 0x71, 0xc1, 0x89, 0xdf, 0x2, 0x4, 0xda, 0x6f, 0x2d, 0x0, 0x16, 0x38, 0x1f, 0x92, 0x36, 0x8c, - 0xff, 0x77, 0x72, 0xb4, 0x99, 0xe2, 0x50, 0xc5, 0x63, 0xbf, 0x8b, 0x79, 0xa6, 0x71, 0xf3, 0x8c, 0xeb, - 0x0, 0x1b, 0xb9, 0xfb, 0xcf, 0xa8, 0x51, 0x86, 0x87, 0x8f, 0xde, 0xc4, 0xe9, 0x90, 0x1d, 0x32, 0xe9, - 0xba, 0x1e, 0x39, 0xce, 0xa9, 0x85, 0x25, 0x8e, 0x9f, 0xd7, 0x90, 0x49, 0x0, 0x10, 0xe2, 0xd3, 0xbd, - 0x3a, 0xf8, 0x63, 0x6d, 0xee, 0x88, 0x30, 0xc, 0xa2, 0x2f, 0x8, 0xc7, 0x21}; + uint8_t pkt[] = {0x10, 0x66, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8c, 0x32, 0xa7, 0x0, 0x1b, 0xf, + 0xff, 0xb2, 0x3c, 0x17, 0x50, 0x43, 0xfe, 0xc2, 0x20, 0x66, 0x3a, 0x98, 0x73, 0x7d, 0xa5, + 0x26, 0xe, 0x20, 0x4d, 0x60, 0xfb, 0x0, 0x78, 0x2, 0x69, 0x42, 0x0, 0x18, 0xbb, 0x98, + 0x94, 0x79, 0x54, 0xc4, 0xa1, 0xb2, 0xcf, 0x37, 0x3a, 0x73, 0x94, 0x90, 0xa9, 0x6e, 0xd9, + 0xde, 0x6e, 0x3d, 0x75, 0xbe, 0xc, 0x93, 0x0, 0x15, 0x72, 0xf4, 0xfc, 0x53, 0xab, 0xec, + 0x4c, 0xe1, 0x9f, 0x32, 0xc0, 0xf6, 0xdf, 0xff, 0x6f, 0x29, 0x60, 0xee, 0xe, 0x6e, 0x13, + 0x0, 0xc, 0x5c, 0x24, 0xf5, 0x7f, 0x67, 0xb4, 0x36, 0x88, 0x6e, 0xb1, 0x53, 0x99}; - uint8_t buf[142] = {0}; + uint8_t buf[114] = {0}; lwmqtt_property_t propslist[] = {}; @@ -1813,33 +1848,28 @@ TEST(Connect311QCTest, Encode1) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x29, 0x56, 0xe6, 0x17, 0x8a, 0xc9, 0xa2, 0x8f, 0x6e, 0x52, 0x7e, 0x6e, - 0xd9, 0x1a, 0x71, 0xc1, 0x89, 0xdf, 0x2, 0x4, 0xda, 0x6f, 0x2d}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x38, 0x1f, 0x92, 0x36, 0x8c, 0xff, 0x77, 0x72, 0xb4, 0x99, 0xe2, - 0x50, 0xc5, 0x63, 0xbf, 0x8b, 0x79, 0xa6, 0x71, 0xf3, 0x8c, 0xeb}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xbb, 0x98, 0x94, 0x79, 0x54, 0xc4, 0xa1, 0xb2, 0xcf, 0x37, 0x3a, 0x73, + 0x94, 0x90, 0xa9, 0x6e, 0xd9, 0xde, 0x6e, 0x3d, 0x75, 0xbe, 0xc, 0x93}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x72, 0xf4, 0xfc, 0x53, 0xab, 0xec, 0x4c, 0xe1, 0x9f, 0x32, 0xc0, + 0xf6, 0xdf, 0xff, 0x6f, 0x29, 0x60, 0xee, 0xe, 0x6e, 0x13}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 26495; - uint8_t client_id_bytes[] = {0xb2, 0x74, 0x3f, 0xeb, 0x73, 0xca, 0x7, 0x3b, 0x4b, 0x42, 0x8f, - 0x8e, 0xdf, 0xf5, 0x8, 0xdb, 0xc2, 0xa6, 0xe8, 0x18, 0x40}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.keep_alive = 12967; + uint8_t client_id_bytes[] = {0xf, 0xff, 0xb2, 0x3c, 0x17, 0x50, 0x43, 0xfe, 0xc2, 0x20, 0x66, 0x3a, 0x98, 0x73, + 0x7d, 0xa5, 0x26, 0xe, 0x20, 0x4d, 0x60, 0xfb, 0x0, 0x78, 0x2, 0x69, 0x42}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb9, 0xfb, 0xcf, 0xa8, 0x51, 0x86, 0x87, 0x8f, 0xde, 0xc4, 0xe9, 0x90, 0x1d, 0x32, - 0xe9, 0xba, 0x1e, 0x39, 0xce, 0xa9, 0x85, 0x25, 0x8e, 0x9f, 0xd7, 0x90, 0x49}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x5c, 0x24, 0xf5, 0x7f, 0x67, 0xb4, 0x36, 0x88, 0x6e, 0xb1, 0x53, 0x99}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xe2, 0xd3, 0xbd, 0x3a, 0xf8, 0x63, 0x6d, 0xee, - 0x88, 0x30, 0xc, 0xa2, 0x2f, 0x8, 0xc7, 0x21}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -1847,21 +1877,18 @@ TEST(Connect311QCTest, Encode1) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "S\EMr\236\180m\171\241#\147\247\CAN6\217\212}\226\139 -// H\249\252\SI\164\190G\DLE\253\139P", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "\DC1\204\194j\212B2e>?\248=l\142X\199U\rs\EMI\a\190", _willMsg = ";\212\214\144\179\bu\237", -// _willProps = []}), _cleanSession = True, _keepAlive = 30140, _connID = -// "N\199j\187\238\237\193\\-\250\182V\DC3\193R\DEL\DC1>o\168\185\199\195i\201BW\253\189\&8", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just +// "b\178\DC3\167\181\244O`\DLE\131\239\236)\NAK*\179`\210\203-\213\144\135\193\157\221\244\182", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "5m\FS[\176f\152", _willMsg = +// "y\STX\EM\232\172\190s\130\201\153\199L\132n\189", _willProps = []}), _cleanSession = True, _keepAlive = 11130, +// _connID = "\DELq\DLE\242s\179\EM\158\193\158\ACKPz", _properties = []} TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x6d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x96, 0x75, 0xbc, 0x0, 0x1e, 0x4e, 0xc7, - 0x6a, 0xbb, 0xee, 0xed, 0xc1, 0x5c, 0x2d, 0xfa, 0xb6, 0x56, 0x13, 0xc1, 0x52, 0x7f, 0x11, 0x3e, - 0x6f, 0xa8, 0xb9, 0xc7, 0xc3, 0x69, 0xc9, 0x42, 0x57, 0xfd, 0xbd, 0x38, 0x0, 0x17, 0x11, 0xcc, - 0xc2, 0x6a, 0xd4, 0x42, 0x32, 0x65, 0x3e, 0x3f, 0xf8, 0x3d, 0x6c, 0x8e, 0x58, 0xc7, 0x55, 0xd, - 0x73, 0x19, 0x49, 0x7, 0xbe, 0x0, 0x8, 0x3b, 0xd4, 0xd6, 0x90, 0xb3, 0x8, 0x75, 0xed, 0x0, - 0x1e, 0x53, 0x19, 0x72, 0xec, 0xb4, 0x6d, 0xab, 0xf1, 0x23, 0x93, 0xf7, 0x18, 0x36, 0xd9, 0xd4, - 0x7d, 0xe2, 0x8b, 0x20, 0x48, 0xf9, 0xfc, 0xf, 0xa4, 0xbe, 0x47, 0x10, 0xfd, 0x8b, 0x50}; + uint8_t pkt[] = {0x10, 0x33, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x2b, 0x7a, 0x0, 0xd, + 0x7f, 0x71, 0x10, 0xf2, 0x73, 0xb3, 0x19, 0x9e, 0xc1, 0x9e, 0x6, 0x50, 0x7a, 0x0, + 0x7, 0x35, 0x6d, 0x1c, 0x5b, 0xb0, 0x66, 0x98, 0x0, 0xf, 0x79, 0x2, 0x19, 0xe8, + 0xac, 0xbe, 0x73, 0x82, 0xc9, 0x99, 0xc7, 0x4c, 0x84, 0x6e, 0xbd}; - uint8_t buf[121] = {0}; + uint8_t buf[63] = {0}; lwmqtt_property_t propslist[] = {}; @@ -1871,29 +1898,27 @@ TEST(Connect311QCTest, Encode2) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x11, 0xcc, 0xc2, 0x6a, 0xd4, 0x42, 0x32, 0x65, 0x3e, 0x3f, 0xf8, 0x3d, - 0x6c, 0x8e, 0x58, 0xc7, 0x55, 0xd, 0x73, 0x19, 0x49, 0x7, 0xbe}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3b, 0xd4, 0xd6, 0x90, 0xb3, 0x8, 0x75, 0xed}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x35, 0x6d, 0x1c, 0x5b, 0xb0, 0x66, 0x98}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x79, 0x2, 0x19, 0xe8, 0xac, 0xbe, 0x73, 0x82, + 0xc9, 0x99, 0xc7, 0x4c, 0x84, 0x6e, 0xbd}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 30140; - uint8_t client_id_bytes[] = {0x4e, 0xc7, 0x6a, 0xbb, 0xee, 0xed, 0xc1, 0x5c, 0x2d, 0xfa, - 0xb6, 0x56, 0x13, 0xc1, 0x52, 0x7f, 0x11, 0x3e, 0x6f, 0xa8, - 0xb9, 0xc7, 0xc3, 0x69, 0xc9, 0x42, 0x57, 0xfd, 0xbd, 0x38}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.keep_alive = 11130; + uint8_t client_id_bytes[] = {0x7f, 0x71, 0x10, 0xf2, 0x73, 0xb3, 0x19, 0x9e, 0xc1, 0x9e, 0x6, 0x50, 0x7a}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x53, 0x19, 0x72, 0xec, 0xb4, 0x6d, 0xab, 0xf1, 0x23, 0x93, 0xf7, 0x18, 0x36, 0xd9, 0xd4, - 0x7d, 0xe2, 0x8b, 0x20, 0x48, 0xf9, 0xfc, 0xf, 0xa4, 0xbe, 0x47, 0x10, 0xfd, 0x8b, 0x50}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; + uint8_t password_bytes[] = {0x62, 0xb2, 0x13, 0xa7, 0xb5, 0xf4, 0x4f, 0x60, 0x10, 0x83, 0xef, 0xec, 0x29, 0x15, + 0x2a, 0xb3, 0x60, 0xd2, 0xcb, 0x2d, 0xd5, 0x90, 0x87, 0xc1, 0x9d, 0xdd, 0xf4, 0xb6}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -1901,22 +1926,18 @@ TEST(Connect311QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "-/\n", _password = Just -// "\DC1\248,\158\217\201a;Ayt\223u8\DC1\202\235z;\132E4z\135~b\208\175}\228", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS2, _willTopic = "\199\150!\SI0f4q\193\205\138\240\172!\SO/V\131\230\160", _willMsg = -// "\SOHv\ETB.O\221\DEL\243$\SYN\186\156g\r\218*\222c", _willProps = []}), _cleanSession = False, _keepAlive = 9480, -// _connID = "\221G3\134\ad\205\255\246S\165\157\209\247\DC4w\180\"T\253\227k\210\179\154(\202", _properties = []} +// ConnectRequest {_username = Just "$J\t\NUL\130\250\238\188R\250\153\177\ETB\216wo\RS9%X\251e#\SO\201\147", _password +// = Just "\\\218\240\185\155\162\192\252t\131\184HV\192\235", _lastWill = Just (LastWill {_willRetain = True, _willQoS +// = QoS2, _willTopic = "\157\174", _willMsg = "\147\218", _willProps = []}), _cleanSession = False, _keepAlive = 6678, +// _connID = "\179\rO`Y", _properties = []} TEST(Connect311QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0x76, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x25, 0x8, 0x0, 0x1b, 0xdd, - 0x47, 0x33, 0x86, 0x7, 0x64, 0xcd, 0xff, 0xf6, 0x53, 0xa5, 0x9d, 0xd1, 0xf7, 0x14, 0x77, - 0xb4, 0x22, 0x54, 0xfd, 0xe3, 0x6b, 0xd2, 0xb3, 0x9a, 0x28, 0xca, 0x0, 0x14, 0xc7, 0x96, - 0x21, 0xf, 0x30, 0x66, 0x34, 0x71, 0xc1, 0xcd, 0x8a, 0xf0, 0xac, 0x21, 0xe, 0x2f, 0x56, - 0x83, 0xe6, 0xa0, 0x0, 0x12, 0x1, 0x76, 0x17, 0x2e, 0x4f, 0xdd, 0x7f, 0xf3, 0x24, 0x16, - 0xba, 0x9c, 0x67, 0xd, 0xda, 0x2a, 0xde, 0x63, 0x0, 0x3, 0x2d, 0x2f, 0xa, 0x0, 0x1e, - 0x11, 0xf8, 0x2c, 0x9e, 0xd9, 0xc9, 0x61, 0x3b, 0x41, 0x79, 0x74, 0xdf, 0x75, 0x38, 0x11, - 0xca, 0xeb, 0x7a, 0x3b, 0x84, 0x45, 0x34, 0x7a, 0x87, 0x7e, 0x62, 0xd0, 0xaf, 0x7d, 0xe4}; + uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x1a, 0x16, 0x0, 0x5, 0xb3, + 0xd, 0x4f, 0x60, 0x59, 0x0, 0x2, 0x9d, 0xae, 0x0, 0x2, 0x93, 0xda, 0x0, 0x1a, 0x24, + 0x4a, 0x9, 0x0, 0x82, 0xfa, 0xee, 0xbc, 0x52, 0xfa, 0x99, 0xb1, 0x17, 0xd8, 0x77, 0x6f, + 0x1e, 0x39, 0x25, 0x58, 0xfb, 0x65, 0x23, 0xe, 0xc9, 0x93, 0x0, 0xf, 0x5c, 0xda, 0xf0, + 0xb9, 0x9b, 0xa2, 0xc0, 0xfc, 0x74, 0x83, 0xb8, 0x48, 0x56, 0xc0, 0xeb}; - uint8_t buf[130] = {0}; + uint8_t buf[82] = {0}; lwmqtt_property_t propslist[] = {}; @@ -1926,12 +1947,10 @@ TEST(Connect311QCTest, Encode3) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc7, 0x96, 0x21, 0xf, 0x30, 0x66, 0x34, 0x71, 0xc1, 0xcd, - 0x8a, 0xf0, 0xac, 0x21, 0xe, 0x2f, 0x56, 0x83, 0xe6, 0xa0}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1, 0x76, 0x17, 0x2e, 0x4f, 0xdd, 0x7f, 0xf3, 0x24, - 0x16, 0xba, 0x9c, 0x67, 0xd, 0xda, 0x2a, 0xde, 0x63}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x9d, 0xae}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x93, 0xda}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; @@ -1940,17 +1959,16 @@ TEST(Connect311QCTest, Encode3) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 9480; - uint8_t client_id_bytes[] = {0xdd, 0x47, 0x33, 0x86, 0x7, 0x64, 0xcd, 0xff, 0xf6, 0x53, 0xa5, 0x9d, 0xd1, 0xf7, - 0x14, 0x77, 0xb4, 0x22, 0x54, 0xfd, 0xe3, 0x6b, 0xd2, 0xb3, 0x9a, 0x28, 0xca}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.keep_alive = 6678; + uint8_t client_id_bytes[] = {0xb3, 0xd, 0x4f, 0x60, 0x59}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2d, 0x2f, 0xa}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x24, 0x4a, 0x9, 0x0, 0x82, 0xfa, 0xee, 0xbc, 0x52, 0xfa, 0x99, 0xb1, 0x17, + 0xd8, 0x77, 0x6f, 0x1e, 0x39, 0x25, 0x58, 0xfb, 0x65, 0x23, 0xe, 0xc9, 0x93}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x11, 0xf8, 0x2c, 0x9e, 0xd9, 0xc9, 0x61, 0x3b, 0x41, 0x79, 0x74, 0xdf, 0x75, 0x38, 0x11, - 0xca, 0xeb, 0x7a, 0x3b, 0x84, 0x45, 0x34, 0x7a, 0x87, 0x7e, 0x62, 0xd0, 0xaf, 0x7d, 0xe4}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x5c, 0xda, 0xf0, 0xb9, 0x9b, 0xa2, 0xc0, 0xfc, 0x74, 0x83, 0xb8, 0x48, 0x56, 0xc0, 0xeb}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -1959,49 +1977,70 @@ TEST(Connect311QCTest, Encode3) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\192\131", _lastWill = Nothing, _cleanSession = False, -// _keepAlive = 25448, _connID = "\131\216\FS}\NAKIn$\DC37\186M\161\151kP\148\142|\224Q\234\249\223\172hF\168", -// _properties = []} +// ConnectRequest {_username = Just "\ETX\162\182\251\&5\254\129A\181!!/ +// \229\172\171\204\210R\201\DC1\250\190\&4_\"X\154", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS2, _willTopic = "\130\DEL/\236|]", _willMsg = "\161\186\166\161\248x\189;\ETX\167", _willProps = +// []}), _cleanSession = False, _keepAlive = 31398, _connID = "\165=K\CAN\208~\SYN\241*\f6#\208H\198\177p.", _properties +// = []} TEST(Connect311QCTest, Encode4) { - uint8_t pkt[] = {0x10, 0x28, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x63, 0x68, 0x0, 0x1c, - 0x83, 0xd8, 0x1c, 0x7d, 0x15, 0x49, 0x6e, 0x24, 0x13, 0x37, 0xba, 0x4d, 0xa1, 0x97, - 0x6b, 0x50, 0x94, 0x8e, 0x7c, 0xe0, 0x51, 0xea, 0xf9, 0xdf, 0xac, 0x68, 0x46, 0xa8}; + uint8_t pkt[] = {0x10, 0x50, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x94, 0x7a, 0xa6, 0x0, 0x12, 0xa5, 0x3d, 0x4b, + 0x18, 0xd0, 0x7e, 0x16, 0xf1, 0x2a, 0xc, 0x36, 0x23, 0xd0, 0x48, 0xc6, 0xb1, 0x70, 0x2e, 0x0, 0x6, + 0x82, 0x7f, 0x2f, 0xec, 0x7c, 0x5d, 0x0, 0xa, 0xa1, 0xba, 0xa6, 0xa1, 0xf8, 0x78, 0xbd, 0x3b, 0x3, + 0xa7, 0x0, 0x1c, 0x3, 0xa2, 0xb6, 0xfb, 0x35, 0xfe, 0x81, 0x41, 0xb5, 0x21, 0x21, 0x2f, 0x20, 0xe5, + 0xac, 0xab, 0xcc, 0xd2, 0x52, 0xc9, 0x11, 0xfa, 0xbe, 0x34, 0x5f, 0x22, 0x58, 0x9a}; - uint8_t buf[52] = {0}; + uint8_t buf[92] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x82, 0x7f, 0x2f, 0xec, 0x7c, 0x5d}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa1, 0xba, 0xa6, 0xa1, 0xf8, 0x78, 0xbd, 0x3b, 0x3, 0xa7}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 25448; - uint8_t client_id_bytes[] = {0x83, 0xd8, 0x1c, 0x7d, 0x15, 0x49, 0x6e, 0x24, 0x13, 0x37, 0xba, 0x4d, 0xa1, 0x97, - 0x6b, 0x50, 0x94, 0x8e, 0x7c, 0xe0, 0x51, 0xea, 0xf9, 0xdf, 0xac, 0x68, 0x46, 0xa8}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.keep_alive = 31398; + uint8_t client_id_bytes[] = {0xa5, 0x3d, 0x4b, 0x18, 0xd0, 0x7e, 0x16, 0xf1, 0x2a, + 0xc, 0x36, 0x23, 0xd0, 0x48, 0xc6, 0xb1, 0x70, 0x2e}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xc0, 0x83}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; + uint8_t username_bytes[] = {0x3, 0xa2, 0xb6, 0xfb, 0x35, 0xfe, 0x81, 0x41, 0xb5, 0x21, 0x21, 0x2f, 0x20, 0xe5, + 0xac, 0xab, 0xcc, 0xd2, 0x52, 0xc9, 0x11, 0xfa, 0xbe, 0x34, 0x5f, 0x22, 0x58, 0x9a}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\168\156M\204\209\177\255\141Bh\181\255\ACK4\218\ACKG\184\227\213\203", _password = -// Just "\GS\180\153*L\206\143\205", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "`\ACK\139\b", _willMsg = "\156E)Ei\136\NAK\137\140x\237K\166\154", _willProps = []}), _cleanSession = True, -// _keepAlive = 12280, _connID = "_\f\142\129\132{J\221 Xo", _properties = []} +// ConnectRequest {_username = Just "GM0)\182\157\&9s", _password = Just +// "nBK\142m\DEL\248~\175W\169oW\173\176\EM7\245\222c%\177", _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS0, _willTopic = "<\166\216{\222\a\STX\238\153\rd\166Zm\206JH\vO\242\143\&7\163\173\233\EOT&Q", _willMsg = +// "\243x\161_\SUB\249f\DC3", _willProps = []}), _cleanSession = True, _keepAlive = 11821, _connID = "\EOT", _properties +// = []} TEST(Connect311QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x2f, 0xf8, 0x0, 0xb, 0x5f, 0xc, - 0x8e, 0x81, 0x84, 0x7b, 0x4a, 0xdd, 0x20, 0x58, 0x6f, 0x0, 0x4, 0x60, 0x6, 0x8b, 0x8, 0x0, - 0xe, 0x9c, 0x45, 0x29, 0x45, 0x69, 0x88, 0x15, 0x89, 0x8c, 0x78, 0xed, 0x4b, 0xa6, 0x9a, 0x0, - 0x15, 0xa8, 0x9c, 0x4d, 0xcc, 0xd1, 0xb1, 0xff, 0x8d, 0x42, 0x68, 0xb5, 0xff, 0x6, 0x34, 0xda, - 0x6, 0x47, 0xb8, 0xe3, 0xd5, 0xcb, 0x0, 0x8, 0x1d, 0xb4, 0x99, 0x2a, 0x4c, 0xce, 0x8f, 0xcd}; + uint8_t pkt[] = {0x10, 0x57, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x2e, 0x2d, 0x0, 0x1, 0x4, + 0x0, 0x1c, 0x3c, 0xa6, 0xd8, 0x7b, 0xde, 0x7, 0x2, 0xee, 0x99, 0xd, 0x64, 0xa6, 0x5a, + 0x6d, 0xce, 0x4a, 0x48, 0xb, 0x4f, 0xf2, 0x8f, 0x37, 0xa3, 0xad, 0xe9, 0x4, 0x26, 0x51, + 0x0, 0x8, 0xf3, 0x78, 0xa1, 0x5f, 0x1a, 0xf9, 0x66, 0x13, 0x0, 0x8, 0x47, 0x4d, 0x30, + 0x29, 0xb6, 0x9d, 0x39, 0x73, 0x0, 0x16, 0x6e, 0x42, 0x4b, 0x8e, 0x6d, 0x7f, 0xf8, 0x7e, + 0xaf, 0x57, 0xa9, 0x6f, 0x57, 0xad, 0xb0, 0x19, 0x37, 0xf5, 0xde, 0x63, 0x25, 0xb1}; - uint8_t buf[90] = {0}; + uint8_t buf[99] = {0}; lwmqtt_property_t propslist[] = {}; @@ -2011,28 +2050,29 @@ TEST(Connect311QCTest, Encode5) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x60, 0x6, 0x8b, 0x8}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x9c, 0x45, 0x29, 0x45, 0x69, 0x88, 0x15, 0x89, 0x8c, 0x78, 0xed, 0x4b, 0xa6, 0x9a}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x3c, 0xa6, 0xd8, 0x7b, 0xde, 0x7, 0x2, 0xee, 0x99, 0xd, 0x64, 0xa6, 0x5a, 0x6d, + 0xce, 0x4a, 0x48, 0xb, 0x4f, 0xf2, 0x8f, 0x37, 0xa3, 0xad, 0xe9, 0x4, 0x26, 0x51}; + lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf3, 0x78, 0xa1, 0x5f, 0x1a, 0xf9, 0x66, 0x13}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 12280; - uint8_t client_id_bytes[] = {0x5f, 0xc, 0x8e, 0x81, 0x84, 0x7b, 0x4a, 0xdd, 0x20, 0x58, 0x6f}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.keep_alive = 11821; + uint8_t client_id_bytes[] = {0x4}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa8, 0x9c, 0x4d, 0xcc, 0xd1, 0xb1, 0xff, 0x8d, 0x42, 0x68, 0xb5, - 0xff, 0x6, 0x34, 0xda, 0x6, 0x47, 0xb8, 0xe3, 0xd5, 0xcb}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x47, 0x4d, 0x30, 0x29, 0xb6, 0x9d, 0x39, 0x73}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x1d, 0xb4, 0x99, 0x2a, 0x4c, 0xce, 0x8f, 0xcd}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x6e, 0x42, 0x4b, 0x8e, 0x6d, 0x7f, 0xf8, 0x7e, 0xaf, 0x57, 0xa9, + 0x6f, 0x57, 0xad, 0xb0, 0x19, 0x37, 0xf5, 0xde, 0x63, 0x25, 0xb1}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -2041,17 +2081,19 @@ TEST(Connect311QCTest, Encode5) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "2\161\185\SYNP2z\ACK0l\186\203\155R\148\SUBXt\251\SI", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "V\140x\158\250\EOT>\241\241\148\199U", -// _willMsg = "\164[\137g\135\241I\233\146\232\214\165\163\235E\163v0\138#\DC3T4", _willProps = []}), _cleanSession = -// True, _keepAlive = 18446, _connID = "\223\DC1\215tI\188[\152", _properties = []} +// ConnectRequest {_username = Just "\213\218\180\190MN\136\210\233\DC2\224\201\191:0\161RI\197\210\192\GSV=", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\r|\168fB\231\&1h\EM>", _willProps = []}), _cleanSession = False, _keepAlive = 21561, -// _connID = "X\167X\244/`\v\181e#h\159\179\219;Q\173\v\134\181+\149\190xs", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\RSYG\vm5p\188\128\155\248\238J;\221\217B\211\170%\241\&9*R ", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\207\240\217\DLE\243\157", _willMsg = +// "\v\143\189\245\140\200_\255\201%\EOTa\240\ESC\170\&4\160\216\CAN\193O\ACK\245\EOT8vEam&", _willProps = []}), +// _cleanSession = False, _keepAlive = 4261, _connID = "T\208\249\166\143\DC3\200/\202", _properties = []} TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x79, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x54, 0x39, 0x0, 0x19, 0x58, 0xa7, - 0x58, 0xf4, 0x2f, 0x60, 0xb, 0xb5, 0x65, 0x23, 0x68, 0x9f, 0xb3, 0xdb, 0x3b, 0x51, 0xad, 0xb, - 0x86, 0xb5, 0x2b, 0x95, 0xbe, 0x78, 0x73, 0x0, 0x14, 0x4f, 0x31, 0x16, 0xda, 0x97, 0x26, 0xe5, - 0x9b, 0x6a, 0xed, 0x10, 0x46, 0x8f, 0xd8, 0xe8, 0x61, 0xbd, 0xc3, 0xe2, 0x8e, 0x0, 0x11, 0xb2, - 0xa5, 0xaa, 0xb5, 0x28, 0x2d, 0xf8, 0xcc, 0x10, 0xe6, 0x6a, 0x4b, 0x59, 0x4, 0x3e, 0x19, 0x3e, - 0x0, 0xf, 0x7d, 0xc3, 0x56, 0x49, 0x1a, 0x50, 0xa6, 0xcf, 0x8d, 0x3c, 0x8c, 0xcb, 0xa4, 0xe0, - 0x5a, 0x0, 0x18, 0xef, 0x1f, 0x1d, 0x73, 0x28, 0x8b, 0x6c, 0x71, 0x98, 0x27, 0xce, 0xee, 0x13, - 0x28, 0x66, 0xac, 0x50, 0x1d, 0x98, 0x82, 0xeb, 0x4b, 0x0, 0xea}; + uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x10, 0xa5, 0x0, 0x9, 0x54, 0xd0, + 0xf9, 0xa6, 0x8f, 0x13, 0xc8, 0x2f, 0xca, 0x0, 0x6, 0xcf, 0xf0, 0xd9, 0x10, 0xf3, 0x9d, 0x0, + 0x1e, 0xb, 0x8f, 0xbd, 0xf5, 0x8c, 0xc8, 0x5f, 0xff, 0xc9, 0x25, 0x4, 0x61, 0xf0, 0x1b, 0xaa, + 0x34, 0xa0, 0xd8, 0x18, 0xc1, 0x4f, 0x6, 0xf5, 0x4, 0x38, 0x76, 0x45, 0x61, 0x6d, 0x26}; - uint8_t buf[133] = {0}; + uint8_t buf[73] = {0}; lwmqtt_property_t propslist[] = {}; @@ -2215,31 +2256,27 @@ TEST(Connect311QCTest, Encode9) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4f, 0x31, 0x16, 0xda, 0x97, 0x26, 0xe5, 0x9b, 0x6a, 0xed, - 0x10, 0x46, 0x8f, 0xd8, 0xe8, 0x61, 0xbd, 0xc3, 0xe2, 0x8e}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb2, 0xa5, 0xaa, 0xb5, 0x28, 0x2d, 0xf8, 0xcc, 0x10, - 0xe6, 0x6a, 0x4b, 0x59, 0x4, 0x3e, 0x19, 0x3e}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xcf, 0xf0, 0xd9, 0x10, 0xf3, 0x9d}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb, 0x8f, 0xbd, 0xf5, 0x8c, 0xc8, 0x5f, 0xff, 0xc9, 0x25, + 0x4, 0x61, 0xf0, 0x1b, 0xaa, 0x34, 0xa0, 0xd8, 0x18, 0xc1, + 0x4f, 0x6, 0xf5, 0x4, 0x38, 0x76, 0x45, 0x61, 0x6d, 0x26}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS2; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 21561; - uint8_t client_id_bytes[] = {0x58, 0xa7, 0x58, 0xf4, 0x2f, 0x60, 0xb, 0xb5, 0x65, 0x23, 0x68, 0x9f, 0xb3, - 0xdb, 0x3b, 0x51, 0xad, 0xb, 0x86, 0xb5, 0x2b, 0x95, 0xbe, 0x78, 0x73}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.keep_alive = 4261; + uint8_t client_id_bytes[] = {0x54, 0xd0, 0xf9, 0xa6, 0x8f, 0x13, 0xc8, 0x2f, 0xca}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x7d, 0xc3, 0x56, 0x49, 0x1a, 0x50, 0xa6, 0xcf, 0x8d, 0x3c, 0x8c, 0xcb, 0xa4, 0xe0, 0x5a}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xef, 0x1f, 0x1d, 0x73, 0x28, 0x8b, 0x6c, 0x71, 0x98, 0x27, 0xce, 0xee, - 0x13, 0x28, 0x66, 0xac, 0x50, 0x1d, 0x98, 0x82, 0xeb, 0x4b, 0x0, 0xea}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x1e, 0x59, 0x47, 0xb, 0x6d, 0x35, 0x70, 0xbc, 0x80, 0x9b, 0xf8, 0xee, 0x4a, + 0x3b, 0xdd, 0xd9, 0x42, 0xd3, 0xaa, 0x25, 0xf1, 0x39, 0x2a, 0x52, 0x20}; + lwmqtt_string_t password = {25, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -2248,21 +2285,18 @@ TEST(Connect311QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\239zk\159\ETX\223!\141\ETX\233\248\f1=\DC4i", _password = Just -// "\191\141\246E\193\236\243\223\153\216myo\194\214\244\200\140\198\147\236Q\194X\130\136", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS0, _willTopic = "L&sv\176Yc2O\\\201,", _willMsg = -// "/\a}\172t\US\218\131\240\224S\221\205S\227\223\231\246~_\168}|8\172\219\157\168", _willProps = []}), _cleanSession = -// False, _keepAlive = 478, _connID = "+\251Q\185q\193\199\n\237\186\162\a", _properties = []} +// ConnectRequest {_username = Just "\241\185^\SOH4\186U}I\208\137\131M\161C\190\134\174(B\181", _password = Nothing, +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "8\\s\tW\213@\b\174\150", _willMsg = +// "\245\248\244q)\133\&9%\158\ESC\a\252]Rco'^\200;", _willProps = []}), _cleanSession = True, _keepAlive = 15075, +// _connID = "~g'\172", _properties = []} TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x72, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x1, 0xde, 0x0, 0xc, 0x2b, 0xfb, 0x51, - 0xb9, 0x71, 0xc1, 0xc7, 0xa, 0xed, 0xba, 0xa2, 0x7, 0x0, 0xc, 0x4c, 0x26, 0x73, 0x76, 0xb0, 0x59, - 0x63, 0x32, 0x4f, 0x5c, 0xc9, 0x2c, 0x0, 0x1c, 0x2f, 0x7, 0x7d, 0xac, 0x74, 0x1f, 0xda, 0x83, 0xf0, - 0xe0, 0x53, 0xdd, 0xcd, 0x53, 0xe3, 0xdf, 0xe7, 0xf6, 0x7e, 0x5f, 0xa8, 0x7d, 0x7c, 0x38, 0xac, 0xdb, - 0x9d, 0xa8, 0x0, 0x10, 0xef, 0x7a, 0x6b, 0x9f, 0x3, 0xdf, 0x21, 0x8d, 0x3, 0xe9, 0xf8, 0xc, 0x31, - 0x3d, 0x14, 0x69, 0x0, 0x1a, 0xbf, 0x8d, 0xf6, 0x45, 0xc1, 0xec, 0xf3, 0xdf, 0x99, 0xd8, 0x6d, 0x79, - 0x6f, 0xc2, 0xd6, 0xf4, 0xc8, 0x8c, 0xc6, 0x93, 0xec, 0x51, 0xc2, 0x58, 0x82, 0x88}; + uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0x3a, 0xe3, 0x0, 0x4, 0x7e, + 0x67, 0x27, 0xac, 0x0, 0xa, 0x38, 0x5c, 0x73, 0x9, 0x57, 0xd5, 0x40, 0x8, 0xae, 0x96, + 0x0, 0x14, 0xf5, 0xf8, 0xf4, 0x71, 0x29, 0x85, 0x39, 0x25, 0x9e, 0x1b, 0x7, 0xfc, 0x5d, + 0x52, 0x63, 0x6f, 0x27, 0x5e, 0xc8, 0x3b, 0x0, 0x15, 0xf1, 0xb9, 0x5e, 0x1, 0x34, 0xba, + 0x55, 0x7d, 0x49, 0xd0, 0x89, 0x83, 0x4d, 0xa1, 0x43, 0xbe, 0x86, 0xae, 0x28, 0x42, 0xb5}; - uint8_t buf[126] = {0}; + uint8_t buf[85] = {0}; lwmqtt_property_t propslist[] = {}; @@ -2272,31 +2306,27 @@ TEST(Connect311QCTest, Encode10) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4c, 0x26, 0x73, 0x76, 0xb0, 0x59, 0x63, 0x32, 0x4f, 0x5c, 0xc9, 0x2c}; - lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x2f, 0x7, 0x7d, 0xac, 0x74, 0x1f, 0xda, 0x83, 0xf0, 0xe0, 0x53, 0xdd, 0xcd, 0x53, - 0xe3, 0xdf, 0xe7, 0xf6, 0x7e, 0x5f, 0xa8, 0x7d, 0x7c, 0x38, 0xac, 0xdb, 0x9d, 0xa8}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x38, 0x5c, 0x73, 0x9, 0x57, 0xd5, 0x40, 0x8, 0xae, 0x96}; + lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf5, 0xf8, 0xf4, 0x71, 0x29, 0x85, 0x39, 0x25, 0x9e, 0x1b, + 0x7, 0xfc, 0x5d, 0x52, 0x63, 0x6f, 0x27, 0x5e, 0xc8, 0x3b}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 478; - uint8_t client_id_bytes[] = {0x2b, 0xfb, 0x51, 0xb9, 0x71, 0xc1, 0xc7, 0xa, 0xed, 0xba, 0xa2, 0x7}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 15075; + uint8_t client_id_bytes[] = {0x7e, 0x67, 0x27, 0xac}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xef, 0x7a, 0x6b, 0x9f, 0x3, 0xdf, 0x21, 0x8d, - 0x3, 0xe9, 0xf8, 0xc, 0x31, 0x3d, 0x14, 0x69}; - lwmqtt_string_t username = {16, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf1, 0xb9, 0x5e, 0x1, 0x34, 0xba, 0x55, 0x7d, 0x49, 0xd0, 0x89, + 0x83, 0x4d, 0xa1, 0x43, 0xbe, 0x86, 0xae, 0x28, 0x42, 0xb5}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xbf, 0x8d, 0xf6, 0x45, 0xc1, 0xec, 0xf3, 0xdf, 0x99, 0xd8, 0x6d, 0x79, 0x6f, - 0xc2, 0xd6, 0xf4, 0xc8, 0x8c, 0xc6, 0x93, 0xec, 0x51, 0xc2, 0x58, 0x82, 0x88}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -2304,129 +2334,129 @@ TEST(Connect311QCTest, Encode10) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "\185\251\207\168Q\134\135\143\222\196\233\144\GS2\233\186\RS9\206\169\133%\142\159\215\144I", _password = Just -// "\226\211\189:\248cm\238\136\&0\f\162/\b\199!", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, -// _willTopic = ")V\230\ETB\138\201\162\143nR~n\217\SUBq\193\137\223\STX\EOT\218o-", _willMsg = -// "8\US\146\&6\140\255wr\180\153\226P\197c\191\139y\166q\243\140\235", _willProps = [PropUserProperty "" -// "&O\EM,\149YV.w!",PropSubscriptionIdentifier 27,PropWillDelayInterval 2671,PropRetainAvailable -// 214,PropMessageExpiryInterval 2278,PropReasonString "lH6Qh\185\&3r\171\254\138Dp\157",PropTopicAlias -// 26598,PropSharedSubscriptionAvailable 185,PropAuthenticationData -// "\134DTa4\227\151\180\255\135\144c\226\232\142",PropReasonString "S\143",PropMaximumQoS 217,PropServerReference -// "\186\DC2Iv",PropResponseInformation -// "\182Zc\177\146\181\190\131\236\250\182\252\v\167=dy\199\210\235\133:\165\SYN\167\220",PropMessageExpiryInterval -// 5186,PropPayloadFormatIndicator 87,PropSharedSubscriptionAvailable 234,PropMessageExpiryInterval -// 7625,PropAssignedClientIdentifier "\161\203T\253"]}), _cleanSession = False, _keepAlive = 26495, _connID = -// "\178t?\235s\202\a;KB\143\142\223\245\b\219\194\166\232\CAN@", _properties = [PropReasonString -// "\232\FS\252\134H\249\185 \189\228^\CANl\146\153\US3\188g\255",PropReasonString -// "r\248\DC27",PropAssignedClientIdentifier -// "\176\187D0\149\ETB\SO\173\155\227VD\215}\157\SYNU\175\DEL\225>\254",PropMessageExpiryInterval -// 15875,PropRequestProblemInformation 32,PropServerKeepAlive 14420,PropSubscriptionIdentifier 14,PropServerKeepAlive -// 12053,PropRetainAvailable 196]} +// ConnectRequest {_username = Just "\\$\245\DELg\180\&6\136n\177S\153", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\187\152\148yT\196\161\178\207\&7:s\148\144\169n\217\222n=u\190\f\147", _willMsg = +// "r\244\252S\171\236L\225\159\&2\192\246\223\255o)`\238\SOn\DC3", _willProps = [PropUserProperty "\"\202\175\250\f1P" +// "#\146\&6\222V{\147\145o\145",PropSubscriptionIdentifier 12,PropMaximumQoS 242,PropSubscriptionIdentifierAvailable +// 227,PropPayloadFormatIndicator 225,PropServerKeepAlive 634,PropMessageExpiryInterval 17255,PropTopicAlias +// 6501,PropSubscriptionIdentifierAvailable 163,PropServerReference +// "\156\210\219\147|C-U\164\164\195^!$s\163\136O\162\b\164\177\177\a\ENQ\SI\176",PropSessionExpiryInterval +// 8407,PropReceiveMaximum 6195,PropAuthenticationMethod "'x\180\132\203\&7",PropMessageExpiryInterval +// 17356,PropTopicAlias 15658,PropPayloadFormatIndicator 33,PropAuthenticationData +// "\206z\211G\253\206\EOT\215\&8\145g\197",PropServerKeepAlive 15035,PropMaximumQoS 20,PropCorrelationData +// "2V:]\177\SOH\FSU\"#1p\v1\214\164\147\185\221p\176\186",PropRetainAvailable 125]}), _cleanSession = False, _keepAlive +// = 12967, _connID = "\SI\255\178<\ETBPC\254\194 f:\152s}\165&\SO M`\251\NULx\STXiB", _properties = [PropReceiveMaximum +// 20333,PropSubscriptionIdentifierAvailable 181,PropRequestProblemInformation 241,PropTopicAliasMaximum +// 19826,PropAssignedClientIdentifier "\STX&",PropWildcardSubscriptionAvailable 16,PropMessageExpiryInterval +// 2481,PropSubscriptionIdentifier 3,PropMessageExpiryInterval 29790,PropRetainAvailable 51,PropMaximumQoS +// 175,PropMessageExpiryInterval 25868,PropSubscriptionIdentifierAvailable 209,PropMessageExpiryInterval +// 4206,PropPayloadFormatIndicator 43,PropPayloadFormatIndicator 55,PropTopicAliasMaximum 10371,PropServerKeepAlive +// 14124,PropWillDelayInterval 5820]} TEST(Connect5QCTest, Encode1) { uint8_t pkt[] = { - 0x10, 0xd1, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x67, 0x7f, 0x48, 0x1f, 0x0, 0x14, 0xe8, 0x1c, - 0xfc, 0x86, 0x48, 0xf9, 0xb9, 0x20, 0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79, 0xc7, 0xd2, 0xeb, 0x85, 0x3a, 0xa5, 0x16, 0xa7, 0xdc, 0x2, 0x0, 0x0, 0x14, 0x42, - 0x1, 0x57, 0x2a, 0xea, 0x2, 0x0, 0x0, 0x1d, 0xc9, 0x12, 0x0, 0x4, 0xa1, 0xcb, 0x54, 0xfd, 0x0, 0x17, 0x29, - 0x56, 0xe6, 0x17, 0x8a, 0xc9, 0xa2, 0x8f, 0x6e, 0x52, 0x7e, 0x6e, 0xd9, 0x1a, 0x71, 0xc1, 0x89, 0xdf, 0x2, 0x4, - 0xda, 0x6f, 0x2d, 0x0, 0x16, 0x38, 0x1f, 0x92, 0x36, 0x8c, 0xff, 0x77, 0x72, 0xb4, 0x99, 0xe2, 0x50, 0xc5, 0x63, - 0xbf, 0x8b, 0x79, 0xa6, 0x71, 0xf3, 0x8c, 0xeb, 0x0, 0x1b, 0xb9, 0xfb, 0xcf, 0xa8, 0x51, 0x86, 0x87, 0x8f, 0xde, - 0xc4, 0xe9, 0x90, 0x1d, 0x32, 0xe9, 0xba, 0x1e, 0x39, 0xce, 0xa9, 0x85, 0x25, 0x8e, 0x9f, 0xd7, 0x90, 0x49, 0x0, - 0x10, 0xe2, 0xd3, 0xbd, 0x3a, 0xf8, 0x63, 0x6d, 0xee, 0x88, 0x30, 0xc, 0xa2, 0x2f, 0x8, 0xc7, 0x21}; - - uint8_t buf[350] = {0}; - - uint8_t bytesprops0[] = {0xe8, 0x1c, 0xfc, 0x86, 0x48, 0xf9, 0xb9, 0x20, 0xbd, 0xe4, - 0x5e, 0x18, 0x6c, 0x92, 0x99, 0x1f, 0x33, 0xbc, 0x67, 0xff}; - uint8_t bytesprops1[] = {0x72, 0xf8, 0x12, 0x37}; - uint8_t bytesprops2[] = {0xb0, 0xbb, 0x44, 0x30, 0x95, 0x17, 0xe, 0xad, 0x9b, 0xe3, 0x56, - 0x44, 0xd7, 0x7d, 0x9d, 0x16, 0x55, 0xaf, 0x7f, 0xe1, 0x3e, 0xfe}; +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b4, 0x84, 0xcb, 0x37, 0x2, 0x0, 0x0, 0x43, 0xcc, 0x23, 0x3d, 0x2a, 0x1, 0x21, 0x16, 0x0, 0xc, 0xce, + 0x7a, 0xd3, 0x47, 0xfd, 0xce, 0x4, 0xd7, 0x38, 0x91, 0x67, 0xc5, 0x13, 0x3a, 0xbb, 0x24, 0x14, 0x9, 0x0, 0x16, + 0x32, 0x56, 0x3a, 0x5d, 0xb1, 0x1, 0x1c, 0x55, 0x22, 0x23, 0x31, 0x70, 0xb, 0x31, 0xd6, 0xa4, 0x93, 0xb9, 0xdd, + 0x70, 0xb0, 0xba, 0x25, 0x7d, 0x0, 0x18, 0xbb, 0x98, 0x94, 0x79, 0x54, 0xc4, 0xa1, 0xb2, 0xcf, 0x37, 0x3a, 0x73, + 0x94, 0x90, 0xa9, 0x6e, 0xd9, 0xde, 0x6e, 0x3d, 0x75, 0xbe, 0xc, 0x93, 0x0, 0x15, 0x72, 0xf4, 0xfc, 0x53, 0xab, + 0xec, 0x4c, 0xe1, 0x9f, 0x32, 0xc0, 0xf6, 0xdf, 0xff, 0x6f, 0x29, 0x60, 0xee, 0xe, 0x6e, 0x13, 0x0, 0xc, 0x5c, + 0x24, 0xf5, 0x7f, 0x67, 0xb4, 0x36, 0x88, 0x6e, 0xb1, 0x53, 0x99}; + + uint8_t buf[325] = {0}; + uint8_t bytesprops0[] = {0x2, 0x26}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15875}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14420}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12053}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20333}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19826}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2481}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29790}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25868}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4206}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10371}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14124}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5820}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x26, 0x4f, 0x19, 0x2c, 0x95, 0x59, 0x56, 0x2e, 0x77, 0x21}; - uint8_t byteswillprops0[] = {0}; - uint8_t byteswillprops2[] = {0x6c, 0x48, 0x36, 0x51, 0x68, 0xb9, 0x33, 0x72, 0xab, 0xfe, 0x8a, 0x44, 0x70, 0x9d}; - uint8_t byteswillprops3[] = {0x86, 0x44, 0x54, 0x61, 0x34, 0xe3, 0x97, 0xb4, - 0xff, 0x87, 0x90, 0x63, 0xe2, 0xe8, 0x8e}; - uint8_t byteswillprops4[] = {0x53, 0x8f}; - uint8_t byteswillprops5[] = {0xba, 0x12, 0x49, 0x76}; - uint8_t byteswillprops6[] = {0xb6, 0x5a, 0x63, 0xb1, 0x92, 0xb5, 0xbe, 0x83, 0xec, 0xfa, 0xb6, 0xfc, 0xb, - 0xa7, 0x3d, 0x64, 0x79, 0xc7, 0xd2, 0xeb, 0x85, 0x3a, 0xa5, 0x16, 0xa7, 0xdc}; - uint8_t byteswillprops7[] = {0xa1, 0xcb, 0x54, 0xfd}; + uint8_t byteswillprops1[] = {0x23, 0x92, 0x36, 0xde, 0x56, 0x7b, 0x93, 0x91, 0x6f, 0x91}; + uint8_t byteswillprops0[] = {0x22, 0xca, 0xaf, 0xfa, 0xc, 0x31, 0x50}; + uint8_t byteswillprops2[] = {0x9c, 0xd2, 0xdb, 0x93, 0x7c, 0x43, 0x2d, 0x55, 0xa4, 0xa4, 0xc3, 0x5e, 0x21, 0x24, + 0x73, 0xa3, 0x88, 0x4f, 0xa2, 0x8, 0xa4, 0xb1, 0xb1, 0x7, 0x5, 0xf, 0xb0}; + uint8_t byteswillprops3[] = {0x27, 0x78, 0xb4, 0x84, 0xcb, 0x37}; + uint8_t byteswillprops4[] = {0xce, 0x7a, 0xd3, 0x47, 0xfd, 0xce, 0x4, 0xd7, 0x38, 0x91, 0x67, 0xc5}; + uint8_t byteswillprops5[] = {0x32, 0x56, 0x3a, 0x5d, 0xb1, 0x1, 0x1c, 0x55, 0x22, 0x23, 0x31, + 0x70, 0xb, 0x31, 0xd6, 0xa4, 0x93, 0xb9, 0xdd, 0x70, 0xb0, 0xba}; lwmqtt_property_t willpropslist[] = { {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {0, (char*)&byteswillprops0}, .v = {10, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2671}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2278}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26598}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5186}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7625}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops7}}}, + .value = {.pair = {.k = {7, (char*)&byteswillprops0}, .v = {10, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 634}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17255}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6501}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8407}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6195}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17356}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15658}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15035}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, }; - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x29, 0x56, 0xe6, 0x17, 0x8a, 0xc9, 0xa2, 0x8f, 0x6e, 0x52, 0x7e, 0x6e, - 0xd9, 0x1a, 0x71, 0xc1, 0x89, 0xdf, 0x2, 0x4, 0xda, 0x6f, 0x2d}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x38, 0x1f, 0x92, 0x36, 0x8c, 0xff, 0x77, 0x72, 0xb4, 0x99, 0xe2, - 0x50, 0xc5, 0x63, 0xbf, 0x8b, 0x79, 0xa6, 0x71, 0xf3, 0x8c, 0xeb}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xbb, 0x98, 0x94, 0x79, 0x54, 0xc4, 0xa1, 0xb2, 0xcf, 0x37, 0x3a, 0x73, + 0x94, 0x90, 0xa9, 0x6e, 0xd9, 0xde, 0x6e, 0x3d, 0x75, 0xbe, 0xc, 0x93}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x72, 0xf4, 0xfc, 0x53, 0xab, 0xec, 0x4c, 0xe1, 0x9f, 0x32, 0xc0, + 0xf6, 0xdf, 0xff, 0x6f, 0x29, 0x60, 0xee, 0xe, 0x6e, 0x13}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 26495; - uint8_t client_id_bytes[] = {0xb2, 0x74, 0x3f, 0xeb, 0x73, 0xca, 0x7, 0x3b, 0x4b, 0x42, 0x8f, - 0x8e, 0xdf, 0xf5, 0x8, 0xdb, 0xc2, 0xa6, 0xe8, 0x18, 0x40}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.keep_alive = 12967; + uint8_t client_id_bytes[] = {0xf, 0xff, 0xb2, 0x3c, 0x17, 0x50, 0x43, 0xfe, 0xc2, 0x20, 0x66, 0x3a, 0x98, 0x73, + 0x7d, 0xa5, 0x26, 0xe, 0x20, 0x4d, 0x60, 0xfb, 0x0, 0x78, 0x2, 0x69, 0x42}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb9, 0xfb, 0xcf, 0xa8, 0x51, 0x86, 0x87, 0x8f, 0xde, 0xc4, 0xe9, 0x90, 0x1d, 0x32, - 0xe9, 0xba, 0x1e, 0x39, 0xce, 0xa9, 0x85, 0x25, 0x8e, 0x9f, 0xd7, 0x90, 0x49}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x5c, 0x24, 0xf5, 0x7f, 0x67, 0xb4, 0x36, 0x88, 0x6e, 0xb1, 0x53, 0x99}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xe2, 0xd3, 0xbd, 0x3a, 0xf8, 0x63, 0x6d, 0xee, - 0x88, 0x30, 0xc, 0xa2, 0x2f, 0x8, 0xc7, 0x21}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -2434,102 +2464,82 @@ TEST(Connect5QCTest, Encode1) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "S\EMr\236\180m\171\241#\147\247\CAN6\217\212}\226\139 -// H\249\252\SI\164\190G\DLE\253\139P", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "\DC1\204\194j\212B2e>?\248=l\142X\199U\rs\EMI\a\190", _willMsg = ";\212\214\144\179\bu\237", -// _willProps = [PropResponseTopic "A\238\131\188"]}), _cleanSession = True, _keepAlive = 30140, _connID = -// "N\199j\187\238\237\193\\-\250\182V\DC3\193R\DEL\DC1>o\168\185\199\195i\201BW\253\189\&8", _properties = -// [PropRetainAvailable 118,PropUserProperty "\222\137\224" "\FS,Z\167W",PropTopicAlias 26986,PropAuthenticationData -// "\142\192\248\243\147\141K\145\174\164\220\151.;0\217\232#\167\128\130\188\ACK",PropRequestProblemInformation -// 144,PropUserProperty "\209K\133\216\224\164I\SI\248\DC3\226\ESCo&\191\SUBJ\177" -// "\DC4\249?\240+\239\DC4\243z.\\\SI\155 ",PropMaximumQoS 38,PropReceiveMaximum 21644,PropServerReference -// "\181\171d\182f_R\206\172\142c\196\250\r\NAK\245",PropResponseTopic -// "\DLE;2a\178;\EOTk>Z\170\STX\EOT\132\203\USn",PropReceiveMaximum 18705,PropReasonString "\170",PropReasonString -// "\251\226Ug\148\ETB\216\t\142\167\153*\154J\207\179\171U^y\143\&51\168",PropRetainAvailable 63]} +// ConnectRequest {_username = Nothing, _password = Just +// "b\178\DC3\167\181\244O`\DLE\131\239\236)\NAK*\179`\210\203-\213\144\135\193\157\221\244\182", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "5m\FS[\176f\152", _willMsg = +// "y\STX\EM\232\172\190s\130\201\153\199L\132n\189", _willProps = [PropUserProperty "\219\190\FS" ""]}), _cleanSession +// = True, _keepAlive = 11130, _connID = "\DELq\DLE\242s\179\EM\158\193\158\ACKPz", _properties = +// [PropResponseInformation "\150Z",PropAuthenticationData "\\\157",PropResponseTopic +// "=C\DC2\252\157P\DC1\FS\143\SUB\183\212%[s\221\242\150\246\170\159\180\221\ACK>4",PropRequestResponseInformation +// 187,PropSubscriptionIdentifier 14,PropUserProperty "\b3\241\"\155?\146\204+\204\236\203\ESCV" +// "n\193r\ESCA4\146\ESC\CAN\226\"\204\221\163c\224?\219]\229PD,\249\b\138",PropMaximumQoS +// 58,PropRequestProblemInformation 16,PropReceiveMaximum 8160,PropTopicAlias 23979]} TEST(Connect5QCTest, Encode2) { - uint8_t pkt[] = { - 0x10, 0x9a, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x96, 0x75, 0xbc, 0xa3, 0x1, 0x25, 0x76, 0x26, 0x0, - 0x3, 0xde, 0x89, 0xe0, 0x0, 0x5, 0x1c, 0x2c, 0x5a, 0xa7, 0x57, 0x23, 0x69, 0x6a, 0x16, 0x0, 0x17, 0x8e, 0xc0, - 0xf8, 0xf3, 0x93, 0x8d, 0x4b, 0x91, 0xae, 0xa4, 0xdc, 0x97, 0x2e, 0x3b, 0x30, 0xd9, 0xe8, 0x23, 0xa7, 0x80, 0x82, - 0xbc, 0x6, 0x17, 0x90, 0x26, 0x0, 0x12, 0xd1, 0x4b, 0x85, 0xd8, 0xe0, 0xa4, 0x49, 0xf, 0xf8, 0x13, 0xe2, 0x1b, - 0x6f, 0x26, 0xbf, 0x1a, 0x4a, 0xb1, 0x0, 0xe, 0x14, 0xf9, 0x3f, 0xf0, 0x2b, 0xef, 0x14, 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 0xfc, 0xf, 0xa4, 0xbe, 0x47, 0x10, 0xfd, 0x8b, 0x50}; - - uint8_t buf[295] = {0}; - - uint8_t bytesprops1[] = {0x1c, 0x2c, 0x5a, 0xa7, 0x57}; - uint8_t bytesprops0[] = {0xde, 0x89, 0xe0}; - uint8_t bytesprops2[] = {0x8e, 0xc0, 0xf8, 0xf3, 0x93, 0x8d, 0x4b, 0x91, 0xae, 0xa4, 0xdc, 0x97, - 0x2e, 0x3b, 0x30, 0xd9, 0xe8, 0x23, 0xa7, 0x80, 0x82, 0xbc, 0x6}; - uint8_t bytesprops4[] = {0x14, 0xf9, 0x3f, 0xf0, 0x2b, 0xef, 0x14, 0xf3, 0x7a, 0x2e, 0x5c, 0xf, 0x9b, 0x20}; - uint8_t bytesprops3[] = {0xd1, 0x4b, 0x85, 0xd8, 0xe0, 0xa4, 0x49, 0xf, 0xf8, - 0x13, 0xe2, 0x1b, 0x6f, 0x26, 0xbf, 0x1a, 0x4a, 0xb1}; - uint8_t bytesprops5[] = {0xb5, 0xab, 0x64, 0xb6, 0x66, 0x5f, 0x52, 0xce, - 0xac, 0x8e, 0x63, 0xc4, 0xfa, 0xd, 0x15, 0xf5}; - uint8_t bytesprops6[] = {0x10, 0x3b, 0x32, 0x61, 0xb2, 0x3b, 0x4, 0x6b, 0x3e, - 0x5a, 0xaa, 0x2, 0x4, 0x84, 0xcb, 0x1f, 0x6e}; - uint8_t bytesprops7[] = {0xaa}; - uint8_t bytesprops8[] = {0xfb, 0xe2, 0x55, 0x67, 0x94, 0x17, 0xd8, 0x9, 0x8e, 0xa7, 0x99, 0x2a, - 0x9a, 0x4a, 0xcf, 0xb3, 0xab, 0x55, 0x5e, 0x79, 0x8f, 0x35, 0x31, 0xa8}; + uint8_t pkt[] = {0x10, 0x9f, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x2b, 0x7a, 0x62, 0x1a, 0x0, 0x2, + 0x96, 0x5a, 0x16, 0x0, 0x2, 0x5c, 0x9d, 0x8, 0x0, 0x1a, 0x3d, 0x43, 0x12, 0xfc, 0x9d, 0x50, 0x11, + 0x1c, 0x8f, 0x1a, 0xb7, 0xd4, 0x25, 0x5b, 0x73, 0xdd, 0xf2, 0x96, 0xf6, 0xaa, 0x9f, 0xb4, 0xdd, 0x6, + 0x3e, 0x34, 0x19, 0xbb, 0xb, 0xe, 0x26, 0x0, 0xe, 0x8, 0x33, 0xf1, 0x22, 0x9b, 0x3f, 0x92, 0xcc, + 0x2b, 0xcc, 0xec, 0xcb, 0x1b, 0x56, 0x0, 0x1a, 0x6e, 0xc1, 0x72, 0x1b, 0x41, 0x34, 0x92, 0x1b, 0x18, + 0xe2, 0x22, 0xcc, 0xdd, 0xa3, 0x63, 0xe0, 0x3f, 0xdb, 0x5d, 0xe5, 0x50, 0x44, 0x2c, 0xf9, 0x8, 0x8a, + 0x24, 0x3a, 0x17, 0x10, 0x21, 0x1f, 0xe0, 0x23, 0x5d, 0xab, 0x0, 0xd, 0x7f, 0x71, 0x10, 0xf2, 0x73, + 0xb3, 0x19, 0x9e, 0xc1, 0x9e, 0x6, 0x50, 0x7a, 0x8, 0x26, 0x0, 0x3, 0xdb, 0xbe, 0x1c, 0x0, 0x0, + 0x0, 0x7, 0x35, 0x6d, 0x1c, 0x5b, 0xb0, 0x66, 0x98, 0x0, 0xf, 0x79, 0x2, 0x19, 0xe8, 0xac, 0xbe, + 0x73, 0x82, 0xc9, 0x99, 0xc7, 0x4c, 0x84, 0x6e, 0xbd}; + + uint8_t buf[172] = {0}; + uint8_t bytesprops0[] = {0x96, 0x5a}; + uint8_t bytesprops1[] = {0x5c, 0x9d}; + uint8_t bytesprops2[] = {0x3d, 0x43, 0x12, 0xfc, 0x9d, 0x50, 0x11, 0x1c, 0x8f, 0x1a, 0xb7, 0xd4, 0x25, + 0x5b, 0x73, 0xdd, 0xf2, 0x96, 0xf6, 0xaa, 0x9f, 0xb4, 0xdd, 0x6, 0x3e, 0x34}; + uint8_t bytesprops4[] = {0x6e, 0xc1, 0x72, 0x1b, 0x41, 0x34, 0x92, 0x1b, 0x18, 0xe2, 0x22, 0xcc, 0xdd, + 0xa3, 0x63, 0xe0, 0x3f, 0xdb, 0x5d, 0xe5, 0x50, 0x44, 0x2c, 0xf9, 0x8, 0x8a}; + uint8_t bytesprops3[] = {0x8, 0x33, 0xf1, 0x22, 0x9b, 0x3f, 0x92, 0xcc, 0x2b, 0xcc, 0xec, 0xcb, 0x1b, 0x56}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops0}, .v = {5, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26986}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops3}, .v = {14, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21644}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18705}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops3}, .v = {26, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8160}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23979}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x41, 0xee, 0x83, 0xbc}; + uint8_t byteswillprops1[] = {0}; + uint8_t byteswillprops0[] = {0xdb, 0xbe, 0x1c}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {3, (char*)&byteswillprops0}, .v = {0, (char*)&byteswillprops1}}}}, }; lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x11, 0xcc, 0xc2, 0x6a, 0xd4, 0x42, 0x32, 0x65, 0x3e, 0x3f, 0xf8, 0x3d, - 0x6c, 0x8e, 0x58, 0xc7, 0x55, 0xd, 0x73, 0x19, 0x49, 0x7, 0xbe}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3b, 0xd4, 0xd6, 0x90, 0xb3, 0x8, 0x75, 0xed}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x35, 0x6d, 0x1c, 0x5b, 0xb0, 0x66, 0x98}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x79, 0x2, 0x19, 0xe8, 0xac, 0xbe, 0x73, 0x82, + 0xc9, 0x99, 0xc7, 0x4c, 0x84, 0x6e, 0xbd}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 30140; - uint8_t client_id_bytes[] = {0x4e, 0xc7, 0x6a, 0xbb, 0xee, 0xed, 0xc1, 0x5c, 0x2d, 0xfa, - 0xb6, 0x56, 0x13, 0xc1, 0x52, 0x7f, 0x11, 0x3e, 0x6f, 0xa8, - 0xb9, 0xc7, 0xc3, 0x69, 0xc9, 0x42, 0x57, 0xfd, 0xbd, 0x38}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.keep_alive = 11130; + uint8_t client_id_bytes[] = {0x7f, 0x71, 0x10, 0xf2, 0x73, 0xb3, 0x19, 0x9e, 0xc1, 0x9e, 0x6, 0x50, 0x7a}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x53, 0x19, 0x72, 0xec, 0xb4, 0x6d, 0xab, 0xf1, 0x23, 0x93, 0xf7, 0x18, 0x36, 0xd9, 0xd4, - 0x7d, 0xe2, 0x8b, 0x20, 0x48, 0xf9, 0xfc, 0xf, 0xa4, 0xbe, 0x47, 0x10, 0xfd, 0x8b, 0x50}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; + uint8_t password_bytes[] = {0x62, 0xb2, 0x13, 0xa7, 0xb5, 0xf4, 0x4f, 0x60, 0x10, 0x83, 0xef, 0xec, 0x29, 0x15, + 0x2a, 0xb3, 0x60, 0xd2, 0xcb, 0x2d, 0xd5, 0x90, 0x87, 0xc1, 0x9d, 0xdd, 0xf4, 0xb6}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -2537,192 +2547,121 @@ TEST(Connect5QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "-/\n", _password = Just -// "\DC1\248,\158\217\201a;Ayt\223u8\DC1\202\235z;\132E4z\135~b\208\175}\228", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS2, _willTopic = "\199\150!\SI0f4q\193\205\138\240\172!\SO/V\131\230\160", _willMsg = -// "\SOHv\ETB.O\221\DEL\243$\SYN\186\156g\r\218*\222c", _willProps = [PropWillDelayInterval -// 29655,PropWildcardSubscriptionAvailable 46,PropUserProperty "\206\164\216\220O$\136\220\189\166" -// "4\f\216+\152(\190\\J\249\196\156/\150_\171\140L",PropSessionExpiryInterval 24620,PropRequestResponseInformation -// 238,PropMessageExpiryInterval 8243,PropServerKeepAlive 9792,PropSessionExpiryInterval 21683,PropContentType -// "\147S\189\f+hL\234'HE*\252\nK\203\STX\140|\162S\173\155",PropReasonString -// "\227\149\216W\198\229p\231\208\251d\235\DC18$6\228\188\147<\154\211\&0\130%|6\161",PropCorrelationData -// "\152jc\170u\SI\234\&8=\143-\"\DC4\192\222\DLE.I",PropMaximumQoS 70,PropSubscriptionIdentifierAvailable -// 169,PropAuthenticationData -// "(\189\SO\RSZk\234\DC1\213\139\DC2\212\242C\205p\r]~l\252\ESC3\185,m\SOH\160\162",PropContentType -// "\f\251Uh\199",PropAuthenticationData -// "=\243\b\DC4\r\146L\233:W\160}\175\204\251\SOH#\194\223",PropSessionExpiryInterval 31741,PropResponseInformation -// "\144w\227\235",PropReasonString -// "\235D\r\214\f\239\US\EOT\ETB\212\ACK\255+\148\150\173\EOT",PropMessageExpiryInterval 3305,PropPayloadFormatIndicator -// 158,PropMessageExpiryInterval 24180,PropRequestResponseInformation 186,PropResponseInformation -// "",PropResponseInformation "\DC3u\SUB",PropMaximumPacketSize 4574,PropServerKeepAlive -// 14158,PropRequestProblemInformation 104,PropUserProperty "b\167\239\137-\177\&1\156$K\146\252,\162@\190F\233\210\189" -// "\GS\132\208q\240\208\255\188\155\&2\242\SI\214\129\b\STX\240/1%\182m\EOTh\200@\189\152"]}), _cleanSession = False, -// _keepAlive = 9480, _connID = "\221G3\134\ad\205\255\246S\165\157\209\247\DC4w\180\"T\253\227k\210\179\154(\202", -// _properties = [PropMessageExpiryInterval 13222,PropAuthenticationMethod "\\x\t\194d\SUB_\154D",PropRetainAvailable -// 79,PropMessageExpiryInterval 18495,PropAuthenticationData -// "8V\RS\r\189.\185\174\131\NUL\179\SUB\152\169\174\235\170\164\NUL\DC1\SIS\151\EOT\156",PropAuthenticationMethod -// "\165",PropRequestProblemInformation 213,PropPayloadFormatIndicator 186,PropReasonString -// "\SYN0",PropAuthenticationMethod "0!2\192\182\211u\244e\179\ACK\189\DEL\GS\238Q",PropAuthenticationMethod -// "|oN>G\255R\171\NUL\226\188z9K\134\169\128x\241\128\254\\f\tm0\147\149\229H",PropContentType -// "\207",PropReceiveMaximum 27076,PropUserProperty -// "\164\&0^cq0\187\165\177\225\227\DC3\167\224\164\208R\231\ETB\ESCf\232" -// "\167\201v\204\156\249\SOgAw\175\199\191l^\227T\191H\DC3",PropAuthenticationMethod -// "%v\SOH\255\164\237\154\SI\t\234\150K\235}\132\228n\162\&4\212 ",PropMaximumQoS 92,PropReceiveMaximum -// 17436,PropSubscriptionIdentifierAvailable 73,PropWillDelayInterval 12518,PropWillDelayInterval -// 21753,PropSessionExpiryInterval 13068,PropMessageExpiryInterval 32198,PropWildcardSubscriptionAvailable -// 77,PropPayloadFormatIndicator 49]} +// ConnectRequest {_username = Just "$J\t\NUL\130\250\238\188R\250\153\177\ETB\216wo\RS9%X\251e#\SO\201\147", _password +// = Just "\\\218\240\185\155\162\192\252t\131\184HV\192\235", _lastWill = Just (LastWill {_willRetain = True, _willQoS +// = QoS2, _willTopic = "\157\174", _willMsg = "\147\218", _willProps = [PropSubscriptionIdentifier +// 16,PropRequestProblemInformation 60,PropSharedSubscriptionAvailable 100,PropTopicAlias 27717,PropResponseInformation +// "A\\\245\160\210\f\181_\213mor\SO'h\213\182\187\172+9\183\214L",PropSessionExpiryInterval +// 1861,PropMessageExpiryInterval 9152,PropMaximumPacketSize 13235,PropWillDelayInterval 27953,PropWillDelayInterval +// 22815,PropSessionExpiryInterval 3149,PropServerKeepAlive 22221]}), _cleanSession = False, _keepAlive = 6678, _connID +// = "\179\rO`Y", _properties = [PropContentType "\186\149\132\SI\235\143\182\&8`\ENQ\146\150",PropMaximumQoS +// 120,PropMessageExpiryInterval 30,PropMaximumPacketSize 32305,PropAuthenticationData "\208\182e\180=a\205c\f\182Z)\DC3 +// Aw\208w\209",PropAuthenticationData "\173\169\231\202z\249\GS\221\139F\181\242\185\146o>\225\139",PropContentType +// "\SO\t\SOH\229z\220p9\184\f\242\RSw\185(u\f\175\146\240",PropPayloadFormatIndicator 198,PropContentType +// "\186\234c\225\&9h\194\175\188.8At`u\189\240\240\144\139\237\149T\154(\196\243",PropContentType +// "|`\150\246\\\DC1\163F ]\187S\198\139:\176\230\251\&6\199\131r\198\192",PropMaximumQoS 91,PropMaximumQoS +// 204,PropMaximumQoS 189,PropCorrelationData "\249\227",PropAssignedClientIdentifier +// "\151Bz*\131j\231\233\234\192\230g\191\245\207\237\217I[\217",PropRequestProblemInformation +// 174,PropResponseInformation "\218\187\242\230\225\164b",PropSessionExpiryInterval +// 6339,PropSubscriptionIdentifierAvailable 124,PropTopicAliasMaximum 968,PropSharedSubscriptionAvailable +// 75,PropSubscriptionIdentifierAvailable 75,PropMaximumQoS 227,PropReasonString "$\235 +// \255\DC4\151\179\FS_\181IR\152\183\218\204\&07\134\NAK\237s\131\252\&67\EM\169TC",PropMessageExpiryInterval 1337]} TEST(Connect5QCTest, Encode3) { uint8_t pkt[] = { - 0x10, 0x9e, 0x5, 0x0, 0x4, 0x4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, 0xd0, 0x71, - 0xf0, 0xd0, 0xff, 0xbc, 0x9b, 0x32, 0xf2, 0xf, 0xd6, 0x81, 0x8, 0x2, 0xf0, 0x2f, 0x31, 0x25, 0xb6, 0x6d, 0x4, - 0x68, 0xc8, 0x40, 0xbd, 0x98, 0x0, 0x14, 0xc7, 0x96, 0x21, 0xf, 0x30, 0x66, 0x34, 0x71, 0xc1, 0xcd, 0x8a, 0xf0, - 0xac, 0x21, 0xe, 0x2f, 0x56, 0x83, 0xe6, 0xa0, 0x0, 0x12, 0x1, 0x76, 0x17, 0x2e, 0x4f, 0xdd, 0x7f, 0xf3, 0x24, - 0x16, 0xba, 0x9c, 0x67, 0xd, 0xda, 0x2a, 0xde, 0x63, 0x0, 0x3, 0x2d, 0x2f, 0xa, 0x0, 0x1e, 0x11, 0xf8, 0x2c, - 0x9e, 0xd9, 0xc9, 0x61, 0x3b, 0x41, 0x79, 0x74, 0xdf, 0x75, 0x38, 0x11, 0xca, 0xeb, 0x7a, 0x3b, 0x84, 0x45, 0x34, - 0x7a, 0x87, 0x7e, 0x62, 0xd0, 0xaf, 0x7d, 0xe4}; - - uint8_t buf[683] = {0}; - - uint8_t bytesprops0[] = {0x5c, 0x78, 0x9, 0xc2, 0x64, 0x1a, 0x5f, 0x9a, 0x44}; - uint8_t bytesprops1[] = {0x38, 0x56, 0x1e, 0xd, 0xbd, 0x2e, 0xb9, 0xae, 0x83, 0x0, 0xb3, 0x1a, 0x98, - 0xa9, 0xae, 0xeb, 0xaa, 0xa4, 0x0, 0x11, 0xf, 0x53, 0x97, 0x4, 0x9c}; - uint8_t bytesprops2[] = {0xa5}; - uint8_t bytesprops3[] = {0x16, 0x30}; - uint8_t bytesprops4[] = {0x30, 0x21, 0x32, 0xc0, 0xb6, 0xd3, 0x75, 0xf4, - 0x65, 0xb3, 0x6, 0xbd, 0x7f, 0x1d, 0xee, 0x51}; - uint8_t bytesprops5[] = {0x7c, 0x6f, 0x4e, 0x3e, 0x47, 0xff, 0x52, 0xab, 0x0, 0xe2, 0xbc, 0x7a, 0x39, 0x4b, 0x86, - 0xa9, 0x80, 0x78, 0xf1, 0x80, 0xfe, 0x5c, 0x66, 0x9, 0x6d, 0x30, 0x93, 0x95, 0xe5, 0x48}; - uint8_t bytesprops6[] = {0xcf}; - uint8_t bytesprops8[] = {0xa7, 0xc9, 0x76, 0xcc, 0x9c, 0xf9, 0xe, 0x67, 0x41, 0x77, - 0xaf, 0xc7, 0xbf, 0x6c, 0x5e, 0xe3, 0x54, 0xbf, 0x48, 0x13}; - uint8_t bytesprops7[] = {0xa4, 0x30, 0x5e, 0x63, 0x71, 0x30, 0xbb, 0xa5, 0xb1, 0xe1, 0xe3, - 0x13, 0xa7, 0xe0, 0xa4, 0xd0, 0x52, 0xe7, 0x17, 0x1b, 0x66, 0xe8}; - uint8_t bytesprops9[] = {0x25, 0x76, 0x1, 0xff, 0xa4, 0xed, 0x9a, 0xf, 0x9, 0xea, 0x96, - 0x4b, 0xeb, 0x7d, 0x84, 0xe4, 0x6e, 0xa2, 0x34, 0xd4, 0x20}; + 0x10, 0x8a, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x1a, 0x16, 0xfc, 0x1, 0x3, 0x0, 0xc, 0xba, + 0x95, 0x84, 0xf, 0xeb, 0x8f, 0xb6, 0x38, 0x60, 0x5, 0x92, 0x96, 0x24, 0x78, 0x2, 0x0, 0x0, 0x0, 0x1e, 0x27, + 0x0, 0x0, 0x7e, 0x31, 0x16, 0x0, 0x13, 0xd0, 0xb6, 0x65, 0xb4, 0x3d, 0x61, 0xcd, 0x63, 0xc, 0xb6, 0x5a, 0x29, + 0x13, 0x20, 0x41, 0x77, 0xd0, 0x77, 0xd1, 0x16, 0x0, 0x12, 0xad, 0xa9, 0xe7, 0xca, 0x7a, 0xf9, 0x1d, 0xdd, 0x8b, + 0x46, 0xb5, 0xf2, 0xb9, 0x92, 0x6f, 0x3e, 0xe1, 0x8b, 0x3, 0x0, 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59, 0x45, 0xb, 0x10, 0x17, 0x3c, 0x2a, 0x64, 0x23, 0x6c, 0x45, 0x1a, + 0x0, 0x18, 0x41, 0x5c, 0xf5, 0xa0, 0xd2, 0xc, 0xb5, 0x5f, 0xd5, 0x6d, 0x6f, 0x72, 0xe, 0x27, 0x68, 0xd5, 0xb6, + 0xbb, 0xac, 0x2b, 0x39, 0xb7, 0xd6, 0x4c, 0x11, 0x0, 0x0, 0x7, 0x45, 0x2, 0x0, 0x0, 0x23, 0xc0, 0x27, 0x0, + 0x0, 0x33, 0xb3, 0x18, 0x0, 0x0, 0x6d, 0x31, 0x18, 0x0, 0x0, 0x59, 0x1f, 0x11, 0x0, 0x0, 0xc, 0x4d, 0x13, + 0x56, 0xcd, 0x0, 0x2, 0x9d, 0xae, 0x0, 0x2, 0x93, 0xda, 0x0, 0x1a, 0x24, 0x4a, 0x9, 0x0, 0x82, 0xfa, 0xee, + 0xbc, 0x52, 0xfa, 0x99, 0xb1, 0x17, 0xd8, 0x77, 0x6f, 0x1e, 0x39, 0x25, 0x58, 0xfb, 0x65, 0x23, 0xe, 0xc9, 0x93, + 0x0, 0xf, 0x5c, 0xda, 0xf0, 0xb9, 0x9b, 0xa2, 0xc0, 0xfc, 0x74, 0x83, 0xb8, 0x48, 0x56, 0xc0, 0xeb}; + + uint8_t buf[407] = {0}; + uint8_t bytesprops0[] = {0xba, 0x95, 0x84, 0xf, 0xeb, 0x8f, 0xb6, 0x38, 0x60, 0x5, 0x92, 0x96}; + uint8_t bytesprops1[] = {0xd0, 0xb6, 0x65, 0xb4, 0x3d, 0x61, 0xcd, 0x63, 0xc, 0xb6, + 0x5a, 0x29, 0x13, 0x20, 0x41, 0x77, 0xd0, 0x77, 0xd1}; + uint8_t bytesprops2[] = {0xad, 0xa9, 0xe7, 0xca, 0x7a, 0xf9, 0x1d, 0xdd, 0x8b, + 0x46, 0xb5, 0xf2, 0xb9, 0x92, 0x6f, 0x3e, 0xe1, 0x8b}; + uint8_t bytesprops3[] = {0xe, 0x9, 0x1, 0xe5, 0x7a, 0xdc, 0x70, 0x39, 0xb8, 0xc, + 0xf2, 0x1e, 0x77, 0xb9, 0x28, 0x75, 0xc, 0xaf, 0x92, 0xf0}; + uint8_t bytesprops4[] = {0xba, 0xea, 0x63, 0xe1, 0x39, 0x68, 0xc2, 0xaf, 0xbc, 0x2e, 0x38, 0x41, 0x74, 0x60, + 0x75, 0xbd, 0xf0, 0xf0, 0x90, 0x8b, 0xed, 0x95, 0x54, 0x9a, 0x28, 0xc4, 0xf3}; + uint8_t bytesprops5[] = {0x7c, 0x60, 0x96, 0xf6, 0x5c, 0x11, 0xa3, 0x46, 0x20, 0x5d, 0xbb, 0x53, + 0xc6, 0x8b, 0x3a, 0xb0, 0xe6, 0xfb, 0x36, 0xc7, 0x83, 0x72, 0xc6, 0xc0}; + uint8_t bytesprops6[] = {0xf9, 0xe3}; + uint8_t bytesprops7[] = {0x97, 0x42, 0x7a, 0x2a, 0x83, 0x6a, 0xe7, 0xe9, 0xea, 0xc0, + 0xe6, 0x67, 0xbf, 0xf5, 0xcf, 0xed, 0xd9, 0x49, 0x5b, 0xd9}; + uint8_t bytesprops8[] = {0xda, 0xbb, 0xf2, 0xe6, 0xe1, 0xa4, 0x62}; + uint8_t bytesprops9[] = {0x24, 0xeb, 0x20, 0xff, 0x14, 0x97, 0xb3, 0x1c, 0x5f, 0xb5, 0x49, 0x52, 0x98, 0xb7, 0xda, + 0xcc, 0x30, 0x37, 0x86, 0x15, 0xed, 0x73, 0x83, 0xfc, 0x36, 0x37, 0x19, 0xa9, 0x54, 0x43}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13222}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18495}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27076}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops7}, .v = {20, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17436}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12518}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21753}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13068}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32198}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32305}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6339}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 968}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1337}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x34, 0xc, 0xd8, 0x2b, 0x98, 0x28, 0xbe, 0x5c, 0x4a, - 0xf9, 0xc4, 0x9c, 0x2f, 0x96, 0x5f, 0xab, 0x8c, 0x4c}; - uint8_t byteswillprops0[] = {0xce, 0xa4, 0xd8, 0xdc, 0x4f, 0x24, 0x88, 0xdc, 0xbd, 0xa6}; - uint8_t byteswillprops2[] = {0x93, 0x53, 0xbd, 0xc, 0x2b, 0x68, 0x4c, 0xea, 0x27, 0x48, 0x45, 0x2a, - 0xfc, 0xa, 0x4b, 0xcb, 0x2, 0x8c, 0x7c, 0xa2, 0x53, 0xad, 0x9b}; - uint8_t byteswillprops3[] = {0xe3, 0x95, 0xd8, 0x57, 0xc6, 0xe5, 0x70, 0xe7, 0xd0, 0xfb, 0x64, 0xeb, 0x11, 0x38, - 0x24, 0x36, 0xe4, 0xbc, 0x93, 0x3c, 0x9a, 0xd3, 0x30, 0x82, 0x25, 0x7c, 0x36, 0xa1}; - uint8_t byteswillprops4[] = {0x98, 0x6a, 0x63, 0xaa, 0x75, 0xf, 0xea, 0x38, 0x3d, - 0x8f, 0x2d, 0x22, 0x14, 0xc0, 0xde, 0x10, 0x2e, 0x49}; - uint8_t byteswillprops5[] = {0x28, 0xbd, 0xe, 0x1e, 0x5a, 0x6b, 0xea, 0x11, 0xd5, 0x8b, 0x12, 0xd4, 0xf2, 0x43, 0xcd, - 0x70, 0xd, 0x5d, 0x7e, 0x6c, 0xfc, 0x1b, 0x33, 0xb9, 0x2c, 0x6d, 0x1, 0xa0, 0xa2}; - uint8_t byteswillprops6[] = {0xc, 0xfb, 0x55, 0x68, 0xc7}; - uint8_t byteswillprops7[] = {0x3d, 0xf3, 0x8, 0x14, 0xd, 0x92, 0x4c, 0xe9, 0x3a, 0x57, - 0xa0, 0x7d, 0xaf, 0xcc, 0xfb, 0x1, 0x23, 0xc2, 0xdf}; - uint8_t byteswillprops8[] = {0x90, 0x77, 0xe3, 0xeb}; - uint8_t byteswillprops9[] = {0xeb, 0x44, 0xd, 0xd6, 0xc, 0xef, 0x1f, 0x4, 0x17, - 0xd4, 0x6, 0xff, 0x2b, 0x94, 0x96, 0xad, 0x4}; - uint8_t byteswillprops10[] = {0}; - uint8_t byteswillprops11[] = {0x13, 0x75, 0x1a}; - uint8_t byteswillprops13[] = {0x1d, 0x84, 0xd0, 0x71, 0xf0, 0xd0, 0xff, 0xbc, 0x9b, 0x32, 0xf2, 0xf, 0xd6, 0x81, - 0x8, 0x2, 0xf0, 0x2f, 0x31, 0x25, 0xb6, 0x6d, 0x4, 0x68, 0xc8, 0x40, 0xbd, 0x98}; - uint8_t byteswillprops12[] = {0x62, 0xa7, 0xef, 0x89, 0x2d, 0xb1, 0x31, 0x9c, 0x24, 0x4b, - 0x92, 0xfc, 0x2c, 0xa2, 0x40, 0xbe, 0x46, 0xe9, 0xd2, 0xbd}; + uint8_t byteswillprops0[] = {0x41, 0x5c, 0xf5, 0xa0, 0xd2, 0xc, 0xb5, 0x5f, 0xd5, 0x6d, 0x6f, 0x72, + 0xe, 0x27, 0x68, 0xd5, 0xb6, 0xbb, 0xac, 0x2b, 0x39, 0xb7, 0xd6, 0x4c}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29655}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {10, (char*)&byteswillprops0}, .v = {18, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24620}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8243}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9792}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21683}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31741}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3305}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24180}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4574}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14158}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {20, (char*)&byteswillprops12}, .v = {28, (char*)&byteswillprops13}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27717}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1861}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9152}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13235}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27953}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22815}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3149}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22221}}, }; - lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc7, 0x96, 0x21, 0xf, 0x30, 0x66, 0x34, 0x71, 0xc1, 0xcd, - 0x8a, 0xf0, 0xac, 0x21, 0xe, 0x2f, 0x56, 0x83, 0xe6, 0xa0}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1, 0x76, 0x17, 0x2e, 0x4f, 0xdd, 0x7f, 0xf3, 0x24, - 0x16, 0xba, 0x9c, 0x67, 0xd, 0xda, 0x2a, 0xde, 0x63}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9d, 0xae}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x93, 0xda}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; @@ -2731,17 +2670,16 @@ TEST(Connect5QCTest, Encode3) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 9480; - uint8_t client_id_bytes[] = {0xdd, 0x47, 0x33, 0x86, 0x7, 0x64, 0xcd, 0xff, 0xf6, 0x53, 0xa5, 0x9d, 0xd1, 0xf7, - 0x14, 0x77, 0xb4, 0x22, 0x54, 0xfd, 0xe3, 0x6b, 0xd2, 0xb3, 0x9a, 0x28, 0xca}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.keep_alive = 6678; + uint8_t client_id_bytes[] = {0xb3, 0xd, 0x4f, 0x60, 0x59}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2d, 0x2f, 0xa}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x24, 0x4a, 0x9, 0x0, 0x82, 0xfa, 0xee, 0xbc, 0x52, 0xfa, 0x99, 0xb1, 0x17, + 0xd8, 0x77, 0x6f, 0x1e, 0x39, 0x25, 0x58, 0xfb, 0x65, 0x23, 0xe, 0xc9, 0x93}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x11, 0xf8, 0x2c, 0x9e, 0xd9, 0xc9, 0x61, 0x3b, 0x41, 0x79, 0x74, 0xdf, 0x75, 0x38, 0x11, - 0xca, 0xeb, 0x7a, 0x3b, 0x84, 0x45, 0x34, 0x7a, 0x87, 0x7e, 0x62, 0xd0, 0xaf, 0x7d, 0xe4}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x5c, 0xda, 0xf0, 0xb9, 0x9b, 0xa2, 0xc0, 0xfc, 0x74, 0x83, 0xb8, 0x48, 0x56, 0xc0, 0xeb}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -2750,193 +2688,211 @@ TEST(Connect5QCTest, Encode3) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\192\131", _lastWill = Nothing, _cleanSession = False, -// _keepAlive = 25448, _connID = "\131\216\FS}\NAKIn$\DC37\186M\161\151kP\148\142|\224Q\234\249\223\172hF\168", -// _properties = [PropAuthenticationMethod -// "v\166\197\235u\245\160t\\\141]\133g\242\246\183\148\198\DC1:\155\164\GS",PropServerKeepAlive 14593,PropMaximumQoS -// 166,PropMessageExpiryInterval 2517,PropAssignedClientIdentifier -// "\248\DLEQ\154\151\146\234Z\172\204\242\148\&1L\213\234\202\147\n\SO`|`",PropRequestProblemInformation -// 97,PropMaximumPacketSize 27560,PropMessageExpiryInterval 14874,PropMessageExpiryInterval -// 230,PropRequestProblemInformation 214,PropWillDelayInterval 2090,PropAssignedClientIdentifier -// "\EM\207\\<\152\NAKG3$Wa\249",PropMaximumQoS 210]} +// ConnectRequest {_username = Just "\ETX\162\182\251\&5\254\129A\181!!/ +// \229\172\171\204\210R\201\DC1\250\190\&4_\"X\154", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS2, _willTopic = "\130\DEL/\236|]", _willMsg = "\161\186\166\161\248x\189;\ETX\167", _willProps = +// [PropRequestResponseInformation 130,PropServerReference +// "4\222\196\&3\DC3d]\170|P\DC4\202\227\155\132\186l\157\199\235\140y\SUB\240\&5\174i\200/",PropContentType +// "\153\136&9\RS\230dLF%MsS\174{\148",PropMessageExpiryInterval 1267,PropWillDelayInterval 6184,PropMaximumPacketSize +// 271,PropReceiveMaximum 8643,PropSessionExpiryInterval 24954,PropResponseTopic +// "+\170.#lf\189\RS);6\240\&7\158]\DC4g\DLE\219>\242\DC3\235",PropWildcardSubscriptionAvailable +// 62,PropSharedSubscriptionAvailable 46,PropUserProperty "s\196\SOH" +// "\128\168\193o\150\214\142\139p\130\181\147c\254w",PropRequestProblemInformation 181,PropMessageExpiryInterval +// 28708,PropResponseInformation "^@{g\166by\ENQ\250\196Y\141\164\161ft\161\190$M"]}), _cleanSession = False, _keepAlive +// = 31398, _connID = "\165=K\CAN\208~\SYN\241*\f6#\208H\198\177p.", _properties = [PropReceiveMaximum +// 30115,PropUserProperty "\ETX\163\192\tV\NUL:9\174\227\135\255\152p\234M\DC1\238%x9+\200\162?" +// "\145\175",PropContentType "h\187\229G\240gt\253\&1",PropAssignedClientIdentifier +// "b\200\188Y\152\218\153\228f\217",PropResponseTopic "\r^]\176\204\197\t\200m.@8s"]} TEST(Connect5QCTest, Encode4) { - uint8_t pkt[] = {0x10, 0x90, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x63, 0x68, 0x67, 0x15, 0x0, 0x17, - 0x76, 0xa6, 0xc5, 0xeb, 0x75, 0xf5, 0xa0, 0x74, 0x5c, 0x8d, 0x5d, 0x85, 0x67, 0xf2, 0xf6, 0xb7, 0x94, - 0xc6, 0x11, 0x3a, 0x9b, 0xa4, 0x1d, 0x13, 0x39, 0x1, 0x24, 0xa6, 0x2, 0x0, 0x0, 0x9, 0xd5, 0x12, - 0x0, 0x17, 0xf8, 0x10, 0x51, 0x9a, 0x97, 0x92, 0xea, 0x5a, 0xac, 0xcc, 0xf2, 0x94, 0x31, 0x4c, 0xd5, - 0xea, 0xca, 0x93, 0xa, 0xe, 0x60, 0x7c, 0x60, 0x17, 0x61, 0x27, 0x0, 0x0, 0x6b, 0xa8, 0x2, 0x0, - 0x0, 0x3a, 0x1a, 0x2, 0x0, 0x0, 0x0, 0xe6, 0x17, 0xd6, 0x18, 0x0, 0x0, 0x8, 0x2a, 0x12, 0x0, - 0xc, 0x19, 0xcf, 0x5c, 0x3c, 0x98, 0x15, 0x47, 0x33, 0x24, 0x57, 0x61, 0xf9, 0x24, 0xd2, 0x0, 0x1c, - 0x83, 0xd8, 0x1c, 0x7d, 0x15, 0x49, 0x6e, 0x24, 0x13, 0x37, 0xba, 0x4d, 0xa1, 0x97, 0x6b, 0x50, 0x94, - 0x8e, 0x7c, 0xe0, 0x51, 0xea, 0xf9, 0xdf, 0xac, 0x68, 0x46, 0xa8}; - - uint8_t buf[157] = {0}; - - uint8_t bytesprops0[] = {0x76, 0xa6, 0xc5, 0xeb, 0x75, 0xf5, 0xa0, 0x74, 0x5c, 0x8d, 0x5d, 0x85, - 0x67, 0xf2, 0xf6, 0xb7, 0x94, 0xc6, 0x11, 0x3a, 0x9b, 0xa4, 0x1d}; - uint8_t bytesprops1[] = {0xf8, 0x10, 0x51, 0x9a, 0x97, 0x92, 0xea, 0x5a, 0xac, 0xcc, 0xf2, 0x94, - 0x31, 0x4c, 0xd5, 0xea, 0xca, 0x93, 0xa, 0xe, 0x60, 0x7c, 0x60}; - uint8_t bytesprops2[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x18, 0x28, 0x27, 0x0, 0x0, 0x1, 0xf, 0x21, 0x21, 0xc3, 0x11, 0x0, 0x0, 0x61, 0x7a, 0x8, 0x0, + 0x17, 0x2b, 0xaa, 0x2e, 0x23, 0x6c, 0x66, 0xbd, 0x1e, 0x29, 0x3b, 0x36, 0xf0, 0x37, 0x9e, 0x5d, 0x14, 0x67, 0x10, + 0xdb, 0x3e, 0xf2, 0x13, 0xeb, 0x28, 0x3e, 0x2a, 0x2e, 0x26, 0x0, 0x3, 0x73, 0xc4, 0x1, 0x0, 0xf, 0x80, 0xa8, + 0xc1, 0x6f, 0x96, 0xd6, 0x8e, 0x8b, 0x70, 0x82, 0xb5, 0x93, 0x63, 0xfe, 0x77, 0x17, 0xb5, 0x2, 0x0, 0x0, 0x70, + 0x24, 0x1a, 0x0, 0x14, 0x5e, 0x40, 0x7b, 0x67, 0xa6, 0x62, 0x79, 0x5, 0xfa, 0xc4, 0x59, 0x8d, 0xa4, 0xa1, 0x66, + 0x74, 0xa1, 0xbe, 0x24, 0x4d, 0x0, 0x6, 0x82, 0x7f, 0x2f, 0xec, 0x7c, 0x5d, 0x0, 0xa, 0xa1, 0xba, 0xa6, 0xa1, + 0xf8, 0x78, 0xbd, 0x3b, 0x3, 0xa7, 0x0, 0x1c, 0x3, 0xa2, 0xb6, 0xfb, 0x35, 0xfe, 0x81, 0x41, 0xb5, 0x21, 0x21, + 0x2f, 0x20, 0xe5, 0xac, 0xab, 0xcc, 0xd2, 0x52, 0xc9, 0x11, 0xfa, 0xbe, 0x34, 0x5f, 0x22, 0x58, 0x9a}; + + uint8_t buf[331] = {0}; + uint8_t bytesprops1[] = {0x91, 0xaf}; + uint8_t bytesprops0[] = {0x3, 0xa3, 0xc0, 0x9, 0x56, 0x0, 0x3a, 0x39, 0xae, 0xe3, 0x87, 0xff, 0x98, + 0x70, 0xea, 0x4d, 0x11, 0xee, 0x25, 0x78, 0x39, 0x2b, 0xc8, 0xa2, 0x3f}; + uint8_t bytesprops2[] = {0x68, 0xbb, 0xe5, 0x47, 0xf0, 0x67, 0x74, 0xfd, 0x31}; + uint8_t bytesprops3[] = {0x62, 0xc8, 0xbc, 0x59, 0x98, 0xda, 0x99, 0xe4, 0x66, 0xd9}; + uint8_t bytesprops4[] = {0xd, 0x5e, 0x5d, 0xb0, 0xcc, 0xc5, 0x9, 0xc8, 0x6d, 0x2e, 0x40, 0x38, 0x73}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14593}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2517}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27560}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14874}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 230}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2090}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30115}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops0}, .v = {2, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x34, 0xde, 0xc4, 0x33, 0x13, 0x64, 0x5d, 0xaa, 0x7c, 0x50, 0x14, 0xca, 0xe3, 0x9b, 0x84, + 0xba, 0x6c, 0x9d, 0xc7, 0xeb, 0x8c, 0x79, 0x1a, 0xf0, 0x35, 0xae, 0x69, 0xc8, 0x2f}; + uint8_t byteswillprops1[] = {0x99, 0x88, 0x26, 0x39, 0x1e, 0xe6, 0x64, 0x4c, + 0x46, 0x25, 0x4d, 0x73, 0x53, 0xae, 0x7b, 0x94}; + uint8_t byteswillprops2[] = {0x2b, 0xaa, 0x2e, 0x23, 0x6c, 0x66, 0xbd, 0x1e, 0x29, 0x3b, 0x36, 0xf0, + 0x37, 0x9e, 0x5d, 0x14, 0x67, 0x10, 0xdb, 0x3e, 0xf2, 0x13, 0xeb}; + uint8_t byteswillprops4[] = {0x80, 0xa8, 0xc1, 0x6f, 0x96, 0xd6, 0x8e, 0x8b, + 0x70, 0x82, 0xb5, 0x93, 0x63, 0xfe, 0x77}; + uint8_t byteswillprops3[] = {0x73, 0xc4, 0x1}; + uint8_t byteswillprops5[] = {0x5e, 0x40, 0x7b, 0x67, 0xa6, 0x62, 0x79, 0x5, 0xfa, 0xc4, + 0x59, 0x8d, 0xa4, 0xa1, 0x66, 0x74, 0xa1, 0xbe, 0x24, 0x4d}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1267}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6184}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 271}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8643}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24954}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {3, (char*)&byteswillprops3}, .v = {15, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28708}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&byteswillprops5}}}, + }; + + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x82, 0x7f, 0x2f, 0xec, 0x7c, 0x5d}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa1, 0xba, 0xa6, 0xa1, 0xf8, 0x78, 0xbd, 0x3b, 0x3, 0xa7}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 25448; - uint8_t client_id_bytes[] = {0x83, 0xd8, 0x1c, 0x7d, 0x15, 0x49, 0x6e, 0x24, 0x13, 0x37, 0xba, 0x4d, 0xa1, 0x97, - 0x6b, 0x50, 0x94, 0x8e, 0x7c, 0xe0, 0x51, 0xea, 0xf9, 0xdf, 0xac, 0x68, 0x46, 0xa8}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.keep_alive = 31398; + uint8_t client_id_bytes[] = {0xa5, 0x3d, 0x4b, 0x18, 0xd0, 0x7e, 0x16, 0xf1, 0x2a, + 0xc, 0x36, 0x23, 0xd0, 0x48, 0xc6, 0xb1, 0x70, 0x2e}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xc0, 0x83}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; + uint8_t username_bytes[] = {0x3, 0xa2, 0xb6, 0xfb, 0x35, 0xfe, 0x81, 0x41, 0xb5, 0x21, 0x21, 0x2f, 0x20, 0xe5, + 0xac, 0xab, 0xcc, 0xd2, 0x52, 0xc9, 0x11, 0xfa, 0xbe, 0x34, 0x5f, 0x22, 0x58, 0x9a}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\168\156M\204\209\177\255\141Bh\181\255\ACK4\218\ACKG\184\227\213\203", _password = -// Just "\GS\180\153*L\206\143\205", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "`\ACK\139\b", _willMsg = "\156E)Ei\136\NAK\137\140x\237K\166\154", _willProps = [PropPayloadFormatIndicator -// 173,PropPayloadFormatIndicator 200,PropMaximumPacketSize 3870,PropRetainAvailable 100,PropResponseTopic -// "O\191\160\201\166\235\204",PropRetainAvailable 168,PropMessageExpiryInterval 26217]}), _cleanSession = True, -// _keepAlive = 12280, _connID = "_\f\142\129\132{J\221 Xo", _properties = [PropMessageExpiryInterval -// 29411,PropResponseInformation "\247\147\216a\133",PropUserProperty -// "\145\193!\159\173\170o'\155\187{\144\191\ETB\187$)\145" -// "8\140\222\140J\190\&1z\218w\145\&8\225\159\201\236\227\230",PropRetainAvailable 134,PropReceiveMaximum -// 15749,PropSubscriptionIdentifier 1,PropSubscriptionIdentifierAvailable 176,PropMaximumPacketSize -// 16367,PropServerKeepAlive 7145,PropPayloadFormatIndicator 16,PropMaximumQoS 164,PropSubscriptionIdentifierAvailable -// 218,PropTopicAliasMaximum 2297,PropMessageExpiryInterval 16013,PropTopicAliasMaximum 19029,PropResponseTopic -// "\229\ACK $\132\183\211_y\202\184)\137\253\131\v\a\216\206\b\181\DC1\197\236~",PropRequestProblemInformation -// 174,PropContentType "\192\180\DLE\DEL=\DLE\148\221\CAN\RS\CAN_\158",PropAssignedClientIdentifier -// "\219\180\143",PropTopicAlias 7933,PropServerKeepAlive 21408,PropWillDelayInterval -// 29037,PropRequestResponseInformation 77,PropMessageExpiryInterval 14660,PropUserProperty -// "\199z\a\150I\189\132[\195s\136\178" "R\180v\130{)y\223+\203y\225\225}",PropAssignedClientIdentifier -// "\174zu\174M\137\228\191\167\205Z\166\136\a\240?\152\194\182D\170\&4\146\&53A{\151\239 ",PropResponseInformation -// "\226\193"]} +// ConnectRequest {_username = Just "GM0)\182\157\&9s", _password = Just +// "nBK\142m\DEL\248~\175W\169oW\173\176\EM7\245\222c%\177", _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS0, _willTopic = "<\166\216{\222\a\STX\238\153\rd\166Zm\206JH\vO\242\143\&7\163\173\233\EOT&Q", _willMsg = +// "\243x\161_\SUB\249f\DC3", _willProps = [PropTopicAlias 10344,PropResponseTopic "\155\GSe\SOH",PropServerKeepAlive +// 30085,PropSubscriptionIdentifierAvailable 184,PropContentType "nd\196\144",PropMaximumQoS 106,PropResponseInformation +// "\160\227\209\224CJR\217\216o\223\254\245m\156\216\207c",PropTopicAliasMaximum 22542,PropRetainAvailable +// 48,PropRequestResponseInformation 118,PropMessageExpiryInterval 7982,PropWillDelayInterval 11886]}), _cleanSession = +// True, _keepAlive = 11821, _connID = "\EOT", _properties = [PropReasonString +// "NIX$\246\251\&3\135\187#\132\212G\174\SUB\RS\246\201\157\DC2\155v\138\176=r\192\149\246",PropTopicAlias +// 8083,PropUserProperty "\129\205[0\239\164\254'x\139\197\216\161,\NUL\241<" +// "\140\SI\SO\197\&8\232\243h@\142\163,i\209\244\226B\STXk\255 ",PropAuthenticationMethod +// "\202\&6\ETB\DC4Q\137\197\195\v?\162\224\&5\152\130\217\195"]} TEST(Connect5QCTest, Encode5) { - uint8_t pkt[] = { - 0x10, 0xd0, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x2f, 0xf8, 0xe3, 0x1, 0x2, 0x0, 0x0, 0x72, - 0xe3, 0x1a, 0x0, 0x5, 0xf7, 0x93, 0xd8, 0x61, 0x85, 0x26, 0x0, 0x12, 0x91, 0xc1, 0x21, 0x9f, 0xad, 0xaa, 0x6f, - 0x27, 0x9b, 0xbb, 0x7b, 0x90, 0xbf, 0x17, 0xbb, 0x24, 0x29, 0x91, 0x0, 0x12, 0x38, 0x8c, 0xde, 0x8c, 0x4a, 0xbe, - 0x31, 0x7a, 0xda, 0x77, 0x91, 0x38, 0xe1, 0x9f, 0xc9, 0xec, 0xe3, 0xe6, 0x25, 0x86, 0x21, 0x3d, 0x85, 0xb, 0x1, - 0x29, 0xb0, 0x27, 0x0, 0x0, 0x3f, 0xef, 0x13, 0x1b, 0xe9, 0x1, 0x10, 0x24, 0xa4, 0x29, 0xda, 0x22, 0x8, 0xf9, - 0x2, 0x0, 0x0, 0x3e, 0x8d, 0x22, 0x4a, 0x55, 0x8, 0x0, 0x19, 0xe5, 0x6, 0x20, 0x24, 0x84, 0xb7, 0xd3, 0x5f, - 0x79, 0xca, 0xb8, 0x29, 0x89, 0xfd, 0x83, 0xb, 0x7, 0xd8, 0xce, 0x8, 0xb5, 0x11, 0xc5, 0xec, 0x7e, 0x17, 0xae, - 0x3, 0x0, 0xd, 0xc0, 0xb4, 0x10, 0x7f, 0x3d, 0x10, 0x94, 0xdd, 0x18, 0x1e, 0x18, 0x5f, 0x9e, 0x12, 0x0, 0x3, - 0xdb, 0xb4, 0x8f, 0x23, 0x1e, 0xfd, 0x13, 0x53, 0xa0, 0x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x61, 0x85}; - uint8_t bytesprops2[] = {0x38, 0x8c, 0xde, 0x8c, 0x4a, 0xbe, 0x31, 0x7a, 0xda, - 0x77, 0x91, 0x38, 0xe1, 0x9f, 0xc9, 0xec, 0xe3, 0xe6}; - uint8_t bytesprops1[] = {0x91, 0xc1, 0x21, 0x9f, 0xad, 0xaa, 0x6f, 0x27, 0x9b, - 0xbb, 0x7b, 0x90, 0xbf, 0x17, 0xbb, 0x24, 0x29, 0x91}; - uint8_t bytesprops3[] = {0xe5, 0x6, 0x20, 0x24, 0x84, 0xb7, 0xd3, 0x5f, 0x79, 0xca, 0xb8, 0x29, 0x89, - 0xfd, 0x83, 0xb, 0x7, 0xd8, 0xce, 0x8, 0xb5, 0x11, 0xc5, 0xec, 0x7e}; - uint8_t bytesprops4[] = {0xc0, 0xb4, 0x10, 0x7f, 0x3d, 0x10, 0x94, 0xdd, 0x18, 0x1e, 0x18, 0x5f, 0x9e}; - uint8_t bytesprops5[] = {0xdb, 0xb4, 0x8f}; - uint8_t bytesprops7[] = {0x52, 0xb4, 0x76, 0x82, 0x7b, 0x29, 0x79, 0xdf, 0x2b, 0xcb, 0x79, 0xe1, 0xe1, 0x7d}; - uint8_t bytesprops6[] = {0xc7, 0x7a, 0x7, 0x96, 0x49, 0xbd, 0x84, 0x5b, 0xc3, 0x73, 0x88, 0xb2}; - uint8_t bytesprops8[] = {0xae, 0x7a, 0x75, 0xae, 0x4d, 0x89, 0xe4, 0xbf, 0xa7, 0xcd, 0x5a, 0xa6, 0x88, 0x7, 0xf0, - 0x3f, 0x98, 0xc2, 0xb6, 0x44, 0xaa, 0x34, 0x92, 0x35, 0x33, 0x41, 0x7b, 0x97, 0xef, 0x20}; - uint8_t bytesprops9[] = {0xe2, 0xc1}; + uint8_t pkt[] = {0x10, 0xf9, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x2e, 0x2d, 0x62, 0x1f, 0x0, 0x1d, + 0x4e, 0x49, 0x58, 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4, 0x26, 0x51, 0x0, 0x8, 0xf3, 0x78, 0xa1, 0x5f, 0x1a, 0xf9, 0x66, 0x13, 0x0, 0x8, 0x47, + 0x4d, 0x30, 0x29, 0xb6, 0x9d, 0x39, 0x73, 0x0, 0x16, 0x6e, 0x42, 0x4b, 0x8e, 0x6d, 0x7f, 0xf8, 0x7e, + 0xaf, 0x57, 0xa9, 0x6f, 0x57, 0xad, 0xb0, 0x19, 0x37, 0xf5, 0xde, 0x63, 0x25, 0xb1}; + + uint8_t buf[262] = {0}; + uint8_t bytesprops0[] = {0x4e, 0x49, 0x58, 0x24, 0xf6, 0xfb, 0x33, 0x87, 0xbb, 0x23, 0x84, 0xd4, 0x47, 0xae, 0x1a, + 0x1e, 0xf6, 0xc9, 0x9d, 0x12, 0x9b, 0x76, 0x8a, 0xb0, 0x3d, 0x72, 0xc0, 0x95, 0xf6}; + uint8_t bytesprops2[] = {0x8c, 0xf, 0xe, 0xc5, 0x38, 0xe8, 0xf3, 0x68, 0x40, 0x8e, 0xa3, + 0x2c, 0x69, 0xd1, 0xf4, 0xe2, 0x42, 0x2, 0x6b, 0xff, 0x20}; + uint8_t bytesprops1[] = {0x81, 0xcd, 0x5b, 0x30, 0xef, 0xa4, 0xfe, 0x27, 0x78, + 0x8b, 0xc5, 0xd8, 0xa1, 0x2c, 0x0, 0xf1, 0x3c}; + uint8_t bytesprops3[] = {0xca, 0x36, 0x17, 0x14, 0x51, 0x89, 0xc5, 0xc3, 0xb, + 0x3f, 0xa2, 0xe0, 0x35, 0x98, 0x82, 0xd9, 0xc3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29411}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15749}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16367}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7145}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2297}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16013}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19029}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7933}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21408}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29037}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14660}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops6}, .v = {14, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8083}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {21, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x4f, 0xbf, 0xa0, 0xc9, 0xa6, 0xeb, 0xcc}; + uint8_t byteswillprops0[] = {0x9b, 0x1d, 0x65, 0x1}; + uint8_t byteswillprops1[] = {0x6e, 0x64, 0xc4, 0x90}; + uint8_t byteswillprops2[] = {0xa0, 0xe3, 0xd1, 0xe0, 0x43, 0x4a, 0x52, 0xd9, 0xd8, + 0x6f, 0xdf, 0xfe, 0xf5, 0x6d, 0x9c, 0xd8, 0xcf, 0x63}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3870}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26217}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10344}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30085}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22542}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7982}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11886}}, }; - lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x60, 0x6, 0x8b, 0x8}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x9c, 0x45, 0x29, 0x45, 0x69, 0x88, 0x15, 0x89, 0x8c, 0x78, 0xed, 0x4b, 0xa6, 0x9a}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x3c, 0xa6, 0xd8, 0x7b, 0xde, 0x7, 0x2, 0xee, 0x99, 0xd, 0x64, 0xa6, 0x5a, 0x6d, + 0xce, 0x4a, 0x48, 0xb, 0x4f, 0xf2, 0x8f, 0x37, 0xa3, 0xad, 0xe9, 0x4, 0x26, 0x51}; + lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf3, 0x78, 0xa1, 0x5f, 0x1a, 0xf9, 0x66, 0x13}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 12280; - uint8_t client_id_bytes[] = {0x5f, 0xc, 0x8e, 0x81, 0x84, 0x7b, 0x4a, 0xdd, 0x20, 0x58, 0x6f}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.keep_alive = 11821; + uint8_t client_id_bytes[] = {0x4}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa8, 0x9c, 0x4d, 0xcc, 0xd1, 0xb1, 0xff, 0x8d, 0x42, 0x68, 0xb5, - 0xff, 0x6, 0x34, 0xda, 0x6, 0x47, 0xb8, 0xe3, 0xd5, 0xcb}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x47, 0x4d, 0x30, 0x29, 0xb6, 0x9d, 0x39, 0x73}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x1d, 0xb4, 0x99, 0x2a, 0x4c, 0xce, 0x8f, 0xcd}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x6e, 0x42, 0x4b, 0x8e, 0x6d, 0x7f, 0xf8, 0x7e, 0xaf, 0x57, 0xa9, + 0x6f, 0x57, 0xad, 0xb0, 0x19, 0x37, 0xf5, 0xde, 0x63, 0x25, 0xb1}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -2945,161 +2901,80 @@ TEST(Connect5QCTest, Encode5) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "2\161\185\SYNP2z\ACK0l\186\203\155R\148\SUBXt\251\SI", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "V\140x\158\250\EOT>\241\241\148\199U", -// _willMsg = "\164[\137g\135\241I\233\146\232\214\165\163\235E\163v0\138#\DC3T4", _willProps = -// [PropWildcardSubscriptionAvailable 71,PropTopicAlias 18041,PropAuthenticationMethod -// "\212\181\&7\180\DLE\181\r\v3\CAN[\ENQP\210/\207I\221",PropPayloadFormatIndicator 198,PropMessageExpiryInterval -// 21952,PropRetainAvailable 197,PropSubscriptionIdentifier 29,PropSharedSubscriptionAvailable 82,PropContentType -// "Y\157.\140D\184\133\166\217\214\186`\168\b=\196T",PropReasonString -// "\SYN\EOT\DC1v\189\245\&00Vl\b\145\&6\200\ENQ\228N\155\204\147",PropResponseInformation -// "\224a\143U\206\193\159x\164\b\227\207\SUB\183\193I\183",PropTopicAlias 23073,PropServerKeepAlive -// 17368,PropServerReference "\161\196\235\243a}\172\239M\157y\225z",PropRequestProblemInformation -// 210,PropRequestProblemInformation 50,PropSharedSubscriptionAvailable 108,PropServerKeepAlive -// 21906,PropSubscriptionIdentifier 17]}), _cleanSession = True, _keepAlive = 18446, _connID = -// "\223\DC1\215tI\188[\152", _properties = [PropReasonString -// "\154\149x\231\fWY\160\156\184\140\168\DLE=\128\169\186]1\179",PropSubscriptionIdentifier 1,PropUserProperty -// "S\226\&8\228\&8b5\244\CAN0v\EM\211\t\186\t\132\t\202\DC3^\182\FS\183" -// "\229\159l\240\DLEq8\239\228\254\204\184\SOH\141(\200\170/\\\144\184\ACK\155\146w+\203\179\ENQ\r",PropWillDelayInterval -// 12947,PropUserProperty "#\RSY\240\180\159\238\250PH\155$\234\DC2\158'\ENQ\169f\SO6Gt\214\175r\184" -// "",PropReasonString "x\STX\133n\224\247\138\249t\153\SYN",PropSubscriptionIdentifierAvailable 127,PropUserProperty -// "5\RS\244\224\172\USp\ETX\141(\v\162\146 \ACK\232Ix\152\197\202\171" -// "Jm\143\143r\209\188\183\DLE\198\187}\158\DC4\155f\162\fL\EOT\144\212\221\237\218g",PropResponseTopic -// "\SYNa\168R\188\SUB3\DC1\ACK4\177\156\182\223\243\250\DC1",PropWildcardSubscriptionAvailable -// 38,PropPayloadFormatIndicator 30,PropServerKeepAlive 29748,PropSubscriptionIdentifierAvailable 226,PropUserProperty -// "&\237\191\199\197\&8\177\ACK_\186\ESCa\149\211\134\178^(@K(" -// "\238C\NAK`#\ESCQj\163s\157\213Z7\NUL\RS\DC1\246\208\ESC\ETX\EM\SYN\200\128\SYN\169\a",PropReceiveMaximum -// 2976,PropReasonString "EWM\253p\225=\196\148.\237\ACK\DC3",PropWildcardSubscriptionAvailable 153]} +// ConnectRequest {_username = Just "\213\218\180\190MN\136\210\233\DC2\224\201\191:0\161RI\197\210\192\GSV[\198\242\173\204\171h\210b" "\148",PropRetainAvailable 165,PropAuthenticationData -// "\220\130\223\ACKy\ESC\154\254/i\171.\DELt\193\244Z\247A\175kd\228\129J\228",PropMaximumQoS -// 22,PropAssignedClientIdentifier "A\188a7\CAN\DLE\242Z\171\RS\202\169\SOHSJ\134\EM\213;\248",PropResponseTopic -// "\132}\CAN\201\154\139\179\SUB82\237~\129\212",PropAuthenticationData "",PropContentType -// "Gq\237\NAKA\142\199\165\229\154",PropRequestResponseInformation 150,PropUserProperty -// "&\182\241\STX\233\132\228N\148mR\SIH" "",PropAuthenticationMethod "b\250\228!\145\147\190>",PropMaximumPacketSize -// 22973,PropReasonString "\163=\US,\130\139rA\160\ACK\241",PropResponseInformation -// "\194\ti,r\168\213;k\150\227\190\194\215\233\171<\224I\NAK",PropMaximumQoS 166,PropServerReference -// "\246FG\242\128\&9\150\130u`\158\139G\224\ESC\172",PropMaximumPacketSize 24530,PropSubscriptionIdentifier 0]} +// ConnectRequest {_username = Just "\181\225\241%KX\185'\148", _password = Just "\CAN(\"\ACKI\133\239\&64\253\241/>=", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\r|\168fB\231\&1hU\186\192\249\n\ETX\231z\213\140\166\147K\"m\157\217S\204\&3",PropMaximumQoS -// 203,PropSubscriptionIdentifierAvailable 178,PropAuthenticationData -// "\224\209\233\158~O\217Y\241I\130c\253N\163\r\229`\f\182O\231Y\r\157\236\165\246\161F",PropUserProperty -// "e0\DC1\137\225\252+/\183p\216\255M\189z\134\&3&\140;\198\255bt\236w" -// "\219\&8y\206\EM\ETBO\207\a\173\195%\195\ETB\219\SOHb^*e\129k\161R\211\SYN",PropSessionExpiryInterval -// 3244,PropReasonString "\167\SI\180w\230~\140[\237\139\"\246|\142\173\225Z\223\208\160\209Ga\151\f",PropReasonString -// "g\216\159\185\220V",PropCorrelationData -// "_\153\STX\b1b#4\NUL\CAN\222\185,G\206\228\&9\128\231\&3\200GtW\165\222\\\135\219)",PropRetainAvailable -// 241,PropWillDelayInterval 22307,PropAssignedClientIdentifier -// "|\152\214\141\151/\187\189\FS\DEL",PropPayloadFormatIndicator 179,PropUserProperty "\252\203" -// "D\137\NUL\218\239;\SYNC\208\148\155\192[JHW \185i\159Q",PropContentType -// "\192\150|\185y\167\235\128\219\DC1\235\149\FSW1\208\243\210\227W\228\165\240 \223)@&\149",PropAuthenticationMethod -// "\CAN\247}\160\153\154\"\DC3/\179J\t\DELWV_\237m\141\170e\141\&0pkf\209{\130",PropMaximumPacketSize -// 7609,PropTopicAliasMaximum 12535,PropRetainAvailable 122,PropResponseInformation -// "C\151\199\249\131\151o\176\132pp\167aK\173\190\SOP\240\180z\STX\178\NAKz\232L\156",PropPayloadFormatIndicator -// 195,PropServerReference "\134\FSl\ETB\US\232",PropAuthenticationData -// "?I\ESC\143\USB\167\171d\DC31\172-N\240\&8P\176\253\ETB\131\230\204DS\DEL0\129_:",PropWillDelayInterval -// 29716,PropSubscriptionIdentifier 18]}), _cleanSession = True, _keepAlive = 11162, _connID = -// "\\\NUL\237\211\216\199\228=\232-\185\&9^/Qf\251L", _properties = [PropSubscriptionIdentifier 4]} +// ConnectRequest {_username = Just "\166\ETX\"\234D\249J8\176\230-", _password = Just "\181\"\ENQ\157\137L\US,", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "t\163\228", _willMsg = +// "\FS\227\151\f\191 \NUL\145\166!\154\157\205=\147|oE\SO\163\DC3\221\139\156\234\241\\(", _willProps = +// [PropRequestProblemInformation 81,PropWillDelayInterval 3835,PropSubscriptionIdentifier +// 22,PropRequestProblemInformation 167,PropTopicAlias 28029,PropSubscriptionIdentifierAvailable +// 141,PropMessageExpiryInterval 14497,PropServerKeepAlive 9066,PropServerReference +// "\197\&0t\155\179\ETXa\137\&9\135\238\&7\222(\131Og",PropWillDelayInterval 2997]}), _cleanSession = False, _keepAlive +// = 26482, _connID = "\203|M\250r7f|5\177\239", _properties = [PropTopicAliasMaximum 28466,PropReceiveMaximum +// 20117,PropSubscriptionIdentifier 20,PropRequestProblemInformation 82,PropAuthenticationData +// "\EMj]\240&oI\138!\238\155\&1\DLE1\159\b\154|{\143",PropRequestResponseInformation +// 168,PropSubscriptionIdentifierAvailable 144,PropMaximumQoS 220,PropUserProperty +// "\vU\150\212\156\174\207w\DC2`\a\158\161\US\189A\158 \223\&6\146\182" "\231\180\226\180\238\210{D"]} TEST(Connect5QCTest, Encode8) { uint8_t pkt[] = { - 0x10, 0x81, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x2b, 0x9a, 0x2, 0xb, 0x4, 0x0, 0x12, 0x5c, - 0x0, 0xed, 0xd3, 0xd8, 0xc7, 0xe4, 0x3d, 0xe8, 0x2d, 0xb9, 0x39, 0x5e, 0x2f, 0x51, 0x66, 0xfb, 0x4c, 0xad, 0x3, - 0x2, 0x0, 0x0, 0x5, 0x51, 0x16, 0x0, 0xd, 0x99, 0xc1, 0x78, 0x72, 0xf3, 0x12, 0xcc, 0xff, 0xa8, 0x73, 0x7, - 0xe7, 0x68, 0x12, 0x0, 0x1e, 0xab, 0x2b, 0x5b, 0xc0, 0x92, 0x48, 0xe5, 0x4d, 0x22, 0x3e, 0x55, 0xba, 0xc0, 0xf9, - 0xa, 0x3, 0xe7, 0x7a, 0xd5, 0x8c, 0xa6, 0x93, 0x4b, 0x22, 0x6d, 0x9d, 0xd9, 0x53, 0xcc, 0x33, 0x24, 0xcb, 0x29, - 0xb2, 0x16, 0x0, 0x1e, 0xe0, 0xd1, 0xe9, 0x9e, 0x7e, 0x4f, 0xd9, 0x59, 0xf1, 0x49, 0x82, 0x63, 0xfd, 0x4e, 0xa3, - 0xd, 0xe5, 0x60, 0xc, 0xb6, 0x4f, 0xe7, 0x59, 0xd, 0x9d, 0xec, 0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xe, 0x5e, 0x7e, 0xf8, 0x90, 0x98, 0xe0, 0xe8, 0xa1, 0xba, 0x0, 0x7, 0x73, 0x82, 0xf8, 0x2e, - 0x81, 0xb, 0xde}; - - uint8_t buf[526] = {0}; + 0x10, 0xce, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x67, 0x72, 0x4a, 0x22, 0x6f, 0x32, 0x21, 0x4e, + 0x95, 0xb, 0x14, 0x17, 0x52, 0x16, 0x0, 0x14, 0x19, 0x6a, 0x5d, 0xf0, 0x26, 0x6f, 0x49, 0x8a, 0x21, 0xee, 0x9b, + 0x31, 0x10, 0x31, 0x9f, 0x8, 0x9a, 0x7c, 0x7b, 0x8f, 0x19, 0xa8, 0x29, 0x90, 0x24, 0xdc, 0x26, 0x0, 0x16, 0xb, + 0x55, 0x96, 0xd4, 0x9c, 0xae, 0xcf, 0x77, 0x12, 0x60, 0x7, 0x9e, 0xa1, 0x1f, 0xbd, 0x41, 0x9e, 0x20, 0xdf, 0x36, + 0x92, 0xb6, 0x0, 0x8, 0xe7, 0xb4, 0xe2, 0xb4, 0xee, 0xd2, 0x7b, 0x44, 0x0, 0xb, 0xcb, 0x7c, 0x4d, 0xfa, 0x72, + 0x37, 0x66, 0x7c, 0x35, 0xb1, 0xef, 0x31, 0x17, 0x51, 0x18, 0x0, 0x0, 0xe, 0xfb, 0xb, 0x16, 0x17, 0xa7, 0x23, + 0x6d, 0x7d, 0x29, 0x8d, 0x2, 0x0, 0x0, 0x38, 0xa1, 0x13, 0x23, 0x6a, 0x1c, 0x0, 0x11, 0xc5, 0x30, 0x74, 0x9b, + 0xb3, 0x3, 0x61, 0x89, 0x39, 0x87, 0xee, 0x37, 0xde, 0x28, 0x83, 0x4f, 0x67, 0x18, 0x0, 0x0, 0xb, 0xb5, 0x0, + 0x3, 0x74, 0xa3, 0xe4, 0x0, 0x1c, 0x1c, 0xe3, 0x97, 0xc, 0xbf, 0x20, 0x0, 0x91, 0xa6, 0x21, 0x9a, 0x9d, 0xcd, + 0x3d, 0x93, 0x7c, 0x6f, 0x45, 0xe, 0xa3, 0x13, 0xdd, 0x8b, 0x9c, 0xea, 0xf1, 0x5c, 0x28, 0x0, 0xb, 0xa6, 0x3, + 0x22, 0xea, 0x44, 0xf9, 0x4a, 0x38, 0xb0, 0xe6, 0x2d, 0x0, 0x8, 0xb5, 0x22, 0x5, 0x9d, 0x89, 0x4c, 0x1f, 0x2c}; + + uint8_t buf[219] = {0}; + uint8_t bytesprops0[] = {0x19, 0x6a, 0x5d, 0xf0, 0x26, 0x6f, 0x49, 0x8a, 0x21, 0xee, + 0x9b, 0x31, 0x10, 0x31, 0x9f, 0x8, 0x9a, 0x7c, 0x7b, 0x8f}; + uint8_t bytesprops2[] = {0xe7, 0xb4, 0xe2, 0xb4, 0xee, 0xd2, 0x7b, 0x44}; + uint8_t bytesprops1[] = {0xb, 0x55, 0x96, 0xd4, 0x9c, 0xae, 0xcf, 0x77, 0x12, 0x60, 0x7, + 0x9e, 0xa1, 0x1f, 0xbd, 0x41, 0x9e, 0x20, 0xdf, 0x36, 0x92, 0xb6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28466}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20117}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x99, 0xc1, 0x78, 0x72, 0xf3, 0x12, 0xcc, 0xff, 0xa8, 0x73, 0x7, 0xe7, 0x68}; - uint8_t byteswillprops1[] = {0xab, 0x2b, 0x5b, 0xc0, 0x92, 0x48, 0xe5, 0x4d, 0x22, 0x3e, - 0x55, 0xba, 0xc0, 0xf9, 0xa, 0x3, 0xe7, 0x7a, 0xd5, 0x8c, - 0xa6, 0x93, 0x4b, 0x22, 0x6d, 0x9d, 0xd9, 0x53, 0xcc, 0x33}; - uint8_t byteswillprops2[] = {0xe0, 0xd1, 0xe9, 0x9e, 0x7e, 0x4f, 0xd9, 0x59, 0xf1, 0x49, - 0x82, 0x63, 0xfd, 0x4e, 0xa3, 0xd, 0xe5, 0x60, 0xc, 0xb6, - 0x4f, 0xe7, 0x59, 0xd, 0x9d, 0xec, 0xa5, 0xf6, 0xa1, 0x46}; - uint8_t byteswillprops4[] = {0xdb, 0x38, 0x79, 0xce, 0x19, 0x17, 0x4f, 0xcf, 0x7, 0xad, 0xc3, 0x25, 0xc3, - 0x17, 0xdb, 0x1, 0x62, 0x5e, 0x2a, 0x65, 0x81, 0x6b, 0xa1, 0x52, 0xd3, 0x16}; - uint8_t byteswillprops3[] = {0x65, 0x30, 0x11, 0x89, 0xe1, 0xfc, 0x2b, 0x2f, 0xb7, 0x70, 0xd8, 0xff, 0x4d, - 0xbd, 0x7a, 0x86, 0x33, 0x26, 0x8c, 0x3b, 0xc6, 0xff, 0x62, 0x74, 0xec, 0x77}; - uint8_t byteswillprops5[] = {0xa7, 0xf, 0xb4, 0x77, 0xe6, 0x7e, 0x8c, 0x5b, 0xed, 0x8b, 0x22, 0xf6, 0x7c, - 0x8e, 0xad, 0xe1, 0x5a, 0xdf, 0xd0, 0xa0, 0xd1, 0x47, 0x61, 0x97, 0xc}; - uint8_t byteswillprops6[] = {0x67, 0xd8, 0x9f, 0xb9, 0xdc, 0x56}; - uint8_t byteswillprops7[] = {0x5f, 0x99, 0x2, 0x8, 0x31, 0x62, 0x23, 0x34, 0x0, 0x18, - 0xde, 0xb9, 0x2c, 0x47, 0xce, 0xe4, 0x39, 0x80, 0xe7, 0x33, - 0xc8, 0x47, 0x74, 0x57, 0xa5, 0xde, 0x5c, 0x87, 0xdb, 0x29}; - uint8_t byteswillprops8[] = {0x7c, 0x98, 0xd6, 0x8d, 0x97, 0x2f, 0xbb, 0xbd, 0x1c, 0x7f}; - uint8_t byteswillprops10[] = {0x44, 0x89, 0x0, 0xda, 0xef, 0x3b, 0x16, 0x43, 0xd0, 0x94, 0x9b, - 0xc0, 0x5b, 0x4a, 0x48, 0x57, 0x20, 0xb9, 0x69, 0x9f, 0x51}; - uint8_t byteswillprops9[] = {0xfc, 0xcb}; - uint8_t byteswillprops11[] = {0xc0, 0x96, 0x7c, 0xb9, 0x79, 0xa7, 0xeb, 0x80, 0xdb, 0x11, - 0xeb, 0x95, 0x1c, 0x57, 0x31, 0xd0, 0xf3, 0xd2, 0xe3, 0x57, - 0xe4, 0xa5, 0xf0, 0x20, 0xdf, 0x29, 0x40, 0x26, 0x95}; - uint8_t byteswillprops12[] = {0x18, 0xf7, 0x7d, 0xa0, 0x99, 0x9a, 0x22, 0x13, 0x2f, 0xb3, - 0x4a, 0x9, 0x7f, 0x57, 0x56, 0x5f, 0xed, 0x6d, 0x8d, 0xaa, - 0x65, 0x8d, 0x30, 0x70, 0x6b, 0x66, 0xd1, 0x7b, 0x82}; - uint8_t byteswillprops13[] = {0x43, 0x97, 0xc7, 0xf9, 0x83, 0x97, 0x6f, 0xb0, 0x84, 0x70, 0x70, 0xa7, 0x61, 0x4b, - 0xad, 0xbe, 0xe, 0x50, 0xf0, 0xb4, 0x7a, 0x2, 0xb2, 0x15, 0x7a, 0xe8, 0x4c, 0x9c}; - uint8_t byteswillprops14[] = {0x86, 0x1c, 0x6c, 0x17, 0x1f, 0xe8}; - uint8_t byteswillprops15[] = {0x3f, 0x49, 0x1b, 0x8f, 0x1f, 0x42, 0xa7, 0xab, 0x64, 0x13, - 0x31, 0xac, 0x2d, 0x4e, 0xf0, 0x38, 0x50, 0xb0, 0xfd, 0x17, - 0x83, 0xe6, 0xcc, 0x44, 0x53, 0x7f, 0x30, 0x81, 0x5f, 0x3a}; + uint8_t byteswillprops0[] = {0xc5, 0x30, 0x74, 0x9b, 0xb3, 0x3, 0x61, 0x89, 0x39, + 0x87, 0xee, 0x37, 0xde, 0x28, 0x83, 0x4f, 0x67}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1361}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {26, (char*)&byteswillprops3}, .v = {26, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3244}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22307}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {2, (char*)&byteswillprops9}, .v = {21, (char*)&byteswillprops10}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&byteswillprops12}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7609}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12535}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&byteswillprops13}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&byteswillprops14}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops15}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29716}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3835}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28029}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14497}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9066}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2997}}, }; - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8, 0x38, 0xa, 0x8c, 0x29, 0x6b, 0x1b, 0xb}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x24, 0xad, 0xb0, 0x1f, 0x6d, 0xca, 0x68, 0xd3, 0xfe, 0x93, 0xd, 0xf1, 0x63, 0xd9}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x74, 0xa3, 0xe4}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1c, 0xe3, 0x97, 0xc, 0xbf, 0x20, 0x0, 0x91, 0xa6, 0x21, 0x9a, 0x9d, 0xcd, 0x3d, + 0x93, 0x7c, 0x6f, 0x45, 0xe, 0xa3, 0x13, 0xdd, 0x8b, 0x9c, 0xea, 0xf1, 0x5c, 0x28}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 11162; - uint8_t client_id_bytes[] = {0x5c, 0x0, 0xed, 0xd3, 0xd8, 0xc7, 0xe4, 0x3d, 0xe8, - 0x2d, 0xb9, 0x39, 0x5e, 0x2f, 0x51, 0x66, 0xfb, 0x4c}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 26482; + uint8_t client_id_bytes[] = {0xcb, 0x7c, 0x4d, 0xfa, 0x72, 0x37, 0x66, 0x7c, 0x35, 0xb1, 0xef}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa6, 0x42, 0xe, 0x5e, 0x7e, 0xf8, 0x90, 0x98, 0xe0, 0xe8, 0xa1, 0xba}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa6, 0x3, 0x22, 0xea, 0x44, 0xf9, 0x4a, 0x38, 0xb0, 0xe6, 0x2d}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x73, 0x82, 0xf8, 0x2e, 0x81, 0xb, 0xde}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xb5, 0x22, 0x5, 0x9d, 0x89, 0x4c, 0x1f, 0x2c}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -3428,115 +3223,160 @@ TEST(Connect5QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "}\195VI\SUBP\166\207\141<\140\203\164\224Z", _password = Just -// "\239\US\GSs(\139lq\152'\206\238\DC3(f\172P\GS\152\130\235K\NUL\234", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS0, _willTopic = "O1\SYN\218\151&\229\155j\237\DLEF\143\216\232a\189\195\226\142", _willMsg = -// "\178\165\170\181(-\248\204\DLE\230jKY\EOT>\EM>", _willProps = [PropReceiveMaximum 3726,PropRequestProblemInformation -// 170,PropCorrelationData -// "d\142\&3\202p\217\210\153\129ZP\207v\139\242\204F\135\f\187\131\153\204\187\156\225#\144",PropTopicAlias -// 31770,PropSessionExpiryInterval 29169,PropMessageExpiryInterval 6570,PropTopicAliasMaximum -// 11129,PropSessionExpiryInterval 12415,PropRetainAvailable 45,PropAssignedClientIdentifier "",PropReasonString -// "",PropReasonString -// "\EOT\240`\164\DC3\DLE\169\173@\159\194X\203\168R.\218\ENQ\US\247\&3?\252\&8fB\165",PropWillDelayInterval -// 24015,PropReceiveMaximum 31266,PropReasonString -// "\192\226\149\129\254\201dc\fg\177\179\DC2\RS\DC3.\CAN\230\217\170\164\178\174",PropServerKeepAlive 3690]}), -// _cleanSession = False, _keepAlive = 21561, _connID = "X\167X\244/`\v\181e#h\159\179\219;Q\173\v\134\181+\149\190xs", -// _properties = [PropMaximumPacketSize 9684,PropMaximumQoS 94,PropAssignedClientIdentifier -// "\163\215w?\166\EM\205dI?\147\&7\136\168",PropMessageExpiryInterval 13352,PropCorrelationData -// "I\181\231\181\185\136\221\150\213\&2\164-\179\ESC",PropTopicAliasMaximum 13292,PropSubscriptionIdentifier -// 6,PropTopicAlias 17975]} +// ConnectRequest {_username = Nothing, _password = Just "\RSYG\vm5p\188\128\155\248\238J;\221\217B\211\170%\241\&9*R ", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\207\240\217\DLE\243\157", _willMsg = +// "\v\143\189\245\140\200_\255\201%\EOTa\240\ESC\170\&4\160\216\CAN\193O\ACK\245\EOT8vEam&", _willProps = +// [PropResponseTopic "%\172'\197`)\200\251\178\&0=X=\220\153\&9\204",PropServerReference +// ";\184B\132\243F\154R\201\172\128\224\207&U\151\172W\244+\ACKB\208\&2\191$\233\&5r",PropMaximumQoS +// 201,PropPayloadFormatIndicator 25,PropContentType "m\188\FS",PropSubscriptionIdentifierAvailable +// 143,PropTopicAliasMaximum 28176,PropContentType +// "6\154\153r_\138\159\207Z\b\143\SOH\245\168\th\190\216\NAK\195r9\ETX\195H\249/l\180\236",PropWillDelayInterval +// 20471,PropWillDelayInterval 26856,PropCorrelationData "\153\217\175\RSX\246\189",PropUserProperty +// "w\250\170L?\229(~MM\STX\223\b\163A\rt\f" +// "\175\226\206\165\172F-cT\157\240\FS\254^$\218\202{\EOT\219c\252\GS\190o",PropRetainAvailable +// 118,PropAssignedClientIdentifier "\231<^R[\132\&2=\154v",PropAssignedClientIdentifier +// "\150\173\182\139&\179\178s\226\217\198\240\131\207\139",PropReasonString +// "\131\&7x\SOH\202=\233\175\209\171o\143w\136\200\253\153\200':\254\187\RS#nO\204\213",PropReceiveMaximum 17699]}), +// _cleanSession = False, _keepAlive = 4261, _connID = "T\208\249\166\143\DC3\200/\202", _properties = +// [PropServerKeepAlive 21864,PropCorrelationData "\217\235\188\190\FSl\172\ENQ\231\146",PropMaximumPacketSize +// 5914,PropUserProperty "h\146\NUL\227UV\EOT\151\196\FS\171 \138\224\SIq\SYN" +// "Oi\213\n\192i\158",PropMessageExpiryInterval 5162,PropRequestProblemInformation 164,PropAssignedClientIdentifier +// "V\255\179\DC1\188\213\208\131\&5\235\SYND\174`\225\SOH\r\142\169#\RS\152W5\190",PropMaximumPacketSize +// 32764,PropRequestProblemInformation 216,PropReceiveMaximum 2749,PropContentType "\243",PropResponseTopic +// "\245\169t\215p\180?\ACK\139gJV\FSQ \182?\215N\242\147v\221u1R\212\USh\216",PropServerReference +// "\133\195b\217\133\224\&8\ENQo\140\223\156\155\&4\178\217\195",PropWildcardSubscriptionAvailable +// 75,PropTopicAliasMaximum 10186,PropMaximumPacketSize 24607,PropTopicAlias 21250,PropTopicAliasMaximum +// 23940,PropMessageExpiryInterval 31128,PropWildcardSubscriptionAvailable 87,PropMessageExpiryInterval 11982]} TEST(Connect5QCTest, Encode9) { uint8_t pkt[] = { - 0x10, 0xb6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc4, 0x54, 0x39, 0x36, 0x27, 0x0, 0x0, 0x25, 0xd4, - 0x24, 0x5e, 0x12, 0x0, 0xe, 0xa3, 0xd7, 0x77, 0x3f, 0xa6, 0x19, 0xcd, 0x64, 0x49, 0x3f, 0x93, 0x37, 0x88, 0xa8, - 0x2, 0x0, 0x0, 0x34, 0x28, 0x9, 0x0, 0xe, 0x49, 0xb5, 0xe7, 0xb5, 0xb9, 0x88, 0xdd, 0x96, 0xd5, 0x32, 0xa4, - 0x2d, 0xb3, 0x1b, 0x22, 0x33, 0xec, 0xb, 0x6, 0x23, 0x46, 0x37, 0x0, 0x19, 0x58, 0xa7, 0x58, 0xf4, 0x2f, 0x60, - 0xb, 0xb5, 0x65, 0x23, 0x68, 0x9f, 0xb3, 0xdb, 0x3b, 0x51, 0xad, 0xb, 0x86, 0xb5, 0x2b, 0x95, 0xbe, 0x78, 0x73, - 0x84, 0x1, 0x21, 0xe, 0x8e, 0x17, 0xaa, 0x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x0, 0x18, 0xef, 0x1f, 0x1d, 0x73, 0x28, 0x8b, 0x6c, 0x71, 0x98, 0x27, 0xce, 0xee, 0x13, 0x28, 0x66, - 0xac, 0x50, 0x1d, 0x98, 0x82, 0xeb, 0x4b, 0x0, 0xea}; - - uint8_t buf[323] = {0}; - - uint8_t bytesprops0[] = {0xa3, 0xd7, 0x77, 0x3f, 0xa6, 0x19, 0xcd, 0x64, 0x49, 0x3f, 0x93, 0x37, 0x88, 0xa8}; - uint8_t bytesprops1[] = {0x49, 0xb5, 0xe7, 0xb5, 0xb9, 0x88, 0xdd, 0x96, 0xd5, 0x32, 0xa4, 0x2d, 0xb3, 0x1b}; + 0x10, 0xe0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x34, 0x10, 0xa5, 0xb4, 0x1, 0x13, 0x55, 0x68, 0x9, + 0x0, 0xa, 0xd9, 0xeb, 0xbc, 0xbe, 0x1c, 0x6c, 0xac, 0x5, 0xe7, 0x92, 0x27, 0x0, 0x0, 0x17, 0x1a, 0x26, 0x0, + 0x11, 0x68, 0x92, 0x0, 0xe3, 0x55, 0x56, 0x4, 0x97, 0xc4, 0x1c, 0xab, 0x20, 0x8a, 0xe0, 0xf, 0x71, 0x16, 0x0, + 0x7, 0x4f, 0x69, 0xd5, 0xa, 0xc0, 0x69, 0x9e, 0x2, 0x0, 0x0, 0x14, 0x2a, 0x17, 0xa4, 0x12, 0x0, 0x19, 0x56, + 0xff, 0xb3, 0x11, 0xbc, 0xd5, 0xd0, 0x83, 0x35, 0xeb, 0x16, 0x44, 0xae, 0x60, 0xe1, 0x1, 0xd, 0x8e, 0xa9, 0x23, + 0x1e, 0x98, 0x57, 0x35, 0xbe, 0x27, 0x0, 0x0, 0x7f, 0xfc, 0x17, 0xd8, 0x21, 0xa, 0xbd, 0x3, 0x0, 0x1, 0xf3, + 0x8, 0x0, 0x1e, 0xf5, 0xa9, 0x74, 0xd7, 0x70, 0xb4, 0x3f, 0x6, 0x8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ac, 0x5, 0xe7, 0x92}; + uint8_t bytesprops2[] = {0x4f, 0x69, 0xd5, 0xa, 0xc0, 0x69, 0x9e}; + uint8_t bytesprops1[] = {0x68, 0x92, 0x0, 0xe3, 0x55, 0x56, 0x4, 0x97, 0xc4, + 0x1c, 0xab, 0x20, 0x8a, 0xe0, 0xf, 0x71, 0x16}; + uint8_t bytesprops3[] = {0x56, 0xff, 0xb3, 0x11, 0xbc, 0xd5, 0xd0, 0x83, 0x35, 0xeb, 0x16, 0x44, 0xae, + 0x60, 0xe1, 0x1, 0xd, 0x8e, 0xa9, 0x23, 0x1e, 0x98, 0x57, 0x35, 0xbe}; + uint8_t bytesprops4[] = {0xf3}; + uint8_t bytesprops5[] = {0xf5, 0xa9, 0x74, 0xd7, 0x70, 0xb4, 0x3f, 0x6, 0x8b, 0x67, 0x4a, 0x56, 0x1c, 0x51, 0x20, + 0xb6, 0x3f, 0xd7, 0x4e, 0xf2, 0x93, 0x76, 0xdd, 0x75, 0x31, 0x52, 0xd4, 0x1f, 0x68, 0xd8}; + uint8_t bytesprops6[] = {0x85, 0xc3, 0x62, 0xd9, 0x85, 0xe0, 0x38, 0x5, 0x6f, + 0x8c, 0xdf, 0x9c, 0x9b, 0x34, 0xb2, 0xd9, 0xc3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9684}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13352}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13292}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17975}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21864}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5914}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {7, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5162}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32764}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2749}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10186}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24607}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21250}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23940}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31128}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11982}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x64, 0x8e, 0x33, 0xca, 0x70, 0xd9, 0xd2, 0x99, 0x81, 0x5a, 0x50, 0xcf, 0x76, 0x8b, - 0xf2, 0xcc, 0x46, 0x87, 0xc, 0xbb, 0x83, 0x99, 0xcc, 0xbb, 0x9c, 0xe1, 0x23, 0x90}; - uint8_t byteswillprops1[] = {0}; - uint8_t byteswillprops2[] = {0}; - uint8_t byteswillprops3[] = {0x4, 0xf0, 0x60, 0xa4, 0x13, 0x10, 0xa9, 0xad, 0x40, 0x9f, 0xc2, 0x58, 0xcb, 0xa8, - 0x52, 0x2e, 0xda, 0x5, 0x1f, 0xf7, 0x33, 0x3f, 0xfc, 0x38, 0x66, 0x42, 0xa5}; - uint8_t byteswillprops4[] = {0xc0, 0xe2, 0x95, 0x81, 0xfe, 0xc9, 0x64, 0x63, 0xc, 0x67, 0xb1, 0xb3, - 0x12, 0x1e, 0x13, 0x2e, 0x18, 0xe6, 0xd9, 0xaa, 0xa4, 0xb2, 0xae}; + uint8_t byteswillprops0[] = {0x25, 0xac, 0x27, 0xc5, 0x60, 0x29, 0xc8, 0xfb, 0xb2, + 0x30, 0x3d, 0x58, 0x3d, 0xdc, 0x99, 0x39, 0xcc}; + uint8_t byteswillprops1[] = {0x3b, 0xb8, 0x42, 0x84, 0xf3, 0x46, 0x9a, 0x52, 0xc9, 0xac, 0x80, 0xe0, 0xcf, 0x26, 0x55, + 0x97, 0xac, 0x57, 0xf4, 0x2b, 0x6, 0x42, 0xd0, 0x32, 0xbf, 0x24, 0xe9, 0x35, 0x72}; + uint8_t byteswillprops2[] = {0x6d, 0xbc, 0x1c}; + uint8_t byteswillprops3[] = {0x36, 0x9a, 0x99, 0x72, 0x5f, 0x8a, 0x9f, 0xcf, 0x5a, 0x8, + 0x8f, 0x1, 0xf5, 0xa8, 0x9, 0x68, 0xbe, 0xd8, 0x15, 0xc3, + 0x72, 0x39, 0x3, 0xc3, 0x48, 0xf9, 0x2f, 0x6c, 0xb4, 0xec}; + uint8_t byteswillprops4[] = {0x99, 0xd9, 0xaf, 0x1e, 0x58, 0xf6, 0xbd}; + uint8_t byteswillprops6[] = {0xaf, 0xe2, 0xce, 0xa5, 0xac, 0x46, 0x2d, 0x63, 0x54, 0x9d, 0xf0, 0x1c, 0xfe, + 0x5e, 0x24, 0xda, 0xca, 0x7b, 0x4, 0xdb, 0x63, 0xfc, 0x1d, 0xbe, 0x6f}; + uint8_t byteswillprops5[] = {0x77, 0xfa, 0xaa, 0x4c, 0x3f, 0xe5, 0x28, 0x7e, 0x4d, + 0x4d, 0x2, 0xdf, 0x8, 0xa3, 0x41, 0xd, 0x74, 0xc}; + uint8_t byteswillprops7[] = {0xe7, 0x3c, 0x5e, 0x52, 0x5b, 0x84, 0x32, 0x3d, 0x9a, 0x76}; + uint8_t byteswillprops8[] = {0x96, 0xad, 0xb6, 0x8b, 0x26, 0xb3, 0xb2, 0x73, + 0xe2, 0xd9, 0xc6, 0xf0, 0x83, 0xcf, 0x8b}; + uint8_t byteswillprops9[] = {0x83, 0x37, 0x78, 0x1, 0xca, 0x3d, 0xe9, 0xaf, 0xd1, 0xab, 0x6f, 0x8f, 0x77, 0x88, + 0xc8, 0xfd, 0x99, 0xc8, 0x27, 0x3a, 0xfe, 0xbb, 0x1e, 0x23, 0x6e, 0x4f, 0xcc, 0xd5}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3726}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31770}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29169}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6570}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11129}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12415}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24015}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31266}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3690}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28176}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20471}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26856}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {18, (char*)&byteswillprops5}, .v = {25, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17699}}, }; - lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4f, 0x31, 0x16, 0xda, 0x97, 0x26, 0xe5, 0x9b, 0x6a, 0xed, - 0x10, 0x46, 0x8f, 0xd8, 0xe8, 0x61, 0xbd, 0xc3, 0xe2, 0x8e}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb2, 0xa5, 0xaa, 0xb5, 0x28, 0x2d, 0xf8, 0xcc, 0x10, - 0xe6, 0x6a, 0x4b, 0x59, 0x4, 0x3e, 0x19, 0x3e}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xcf, 0xf0, 0xd9, 0x10, 0xf3, 0x9d}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb, 0x8f, 0xbd, 0xf5, 0x8c, 0xc8, 0x5f, 0xff, 0xc9, 0x25, + 0x4, 0x61, 0xf0, 0x1b, 0xaa, 0x34, 0xa0, 0xd8, 0x18, 0xc1, + 0x4f, 0x6, 0xf5, 0x4, 0x38, 0x76, 0x45, 0x61, 0x6d, 0x26}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS2; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 21561; - uint8_t client_id_bytes[] = {0x58, 0xa7, 0x58, 0xf4, 0x2f, 0x60, 0xb, 0xb5, 0x65, 0x23, 0x68, 0x9f, 0xb3, - 0xdb, 0x3b, 0x51, 0xad, 0xb, 0x86, 0xb5, 0x2b, 0x95, 0xbe, 0x78, 0x73}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.keep_alive = 4261; + uint8_t client_id_bytes[] = {0x54, 0xd0, 0xf9, 0xa6, 0x8f, 0x13, 0xc8, 0x2f, 0xca}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x7d, 0xc3, 0x56, 0x49, 0x1a, 0x50, 0xa6, 0xcf, 0x8d, 0x3c, 0x8c, 0xcb, 0xa4, 0xe0, 0x5a}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xef, 0x1f, 0x1d, 0x73, 0x28, 0x8b, 0x6c, 0x71, 0x98, 0x27, 0xce, 0xee, - 0x13, 0x28, 0x66, 0xac, 0x50, 0x1d, 0x98, 0x82, 0xeb, 0x4b, 0x0, 0xea}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x1e, 0x59, 0x47, 0xb, 0x6d, 0x35, 0x70, 0xbc, 0x80, 0x9b, 0xf8, 0xee, 0x4a, + 0x3b, 0xdd, 0xd9, 0x42, 0xd3, 0xaa, 0x25, 0xf1, 0x39, 0x2a, 0x52, 0x20}; + lwmqtt_string_t password = {25, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -3545,80 +3385,126 @@ TEST(Connect5QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\239zk\159\ETX\223!\141\ETX\233\248\f1=\DC4i", _password = Just -// "\191\141\246E\193\236\243\223\153\216myo\194\214\244\200\140\198\147\236Q\194X\130\136", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS0, _willTopic = "L&sv\176Yc2O\\\201,", _willMsg = -// "/\a}\172t\US\218\131\240\224S\221\205S\227\223\231\246~_\168}|8\172\219\157\168", _willProps = -// [PropAssignedClientIdentifier "\253{\222\SUB\ESC\ENQ\223\244",PropRequestResponseInformation 223]}), _cleanSession = -// False, _keepAlive = 478, _connID = "+\251Q\185q\193\199\n\237\186\162\a", _properties = [PropAssignedClientIdentifier -// "\235s\DEL\151g\v\bBE\215",PropWildcardSubscriptionAvailable 91,PropUserProperty "|p\194\v1\161" -// "\247z\SOr\192\246c\152%_\132zbR\US\218)\195\147k\149\199",PropAssignedClientIdentifier -// "\r,\176N#\158._Gf\218\228,\180-",PropTopicAliasMaximum 15986]} +// ConnectRequest {_username = Just "\241\185^\SOH4\186U}I\208\137\131M\161C\190\134\174(B\181", _password = Nothing, +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "8\\s\tW\213@\b\174\150", _willMsg = +// "\245\248\244q)\133\&9%\158\ESC\a\252]Rco'^\200;", _willProps = [PropRequestProblemInformation +// 112,PropRequestProblemInformation 179,PropWildcardSubscriptionAvailable 61,PropAuthenticationData +// "\213L\153\173\148Z\254\177\155\231\153F32\235'\176\195",PropServerKeepAlive 1358,PropSharedSubscriptionAvailable +// 250,PropResponseInformation "\b4\222\STXQ\253\188\252\140\ra\b\176\GSs",PropSessionExpiryInterval 5859]}), +// _cleanSession = True, _keepAlive = 15075, _connID = "~g'\172", _properties = [PropTopicAliasMaximum +// 13675,PropSubscriptionIdentifierAvailable 45,PropSubscriptionIdentifierAvailable 160,PropAuthenticationData +// "D\184\161\ETX\189\196W\233\EOT\DEL|\168\&7\232",PropAuthenticationMethod +// "e\225\186\240p\147\227U\188v\132\192\251s\SO!~?\154\246\203\237\241\145",PropWildcardSubscriptionAvailable +// 210,PropReceiveMaximum 19490,PropMessageExpiryInterval 17696,PropResponseInformation +// "\SI\237.3\208",PropServerReference +// "\228f&\209!\147\165\215W\149\128\172\174\240\177o\207\156\128#\184\&8+\219\210\173-\196C",PropTopicAliasMaximum +// 10620,PropRequestResponseInformation 178,PropServerKeepAlive 17815,PropSessionExpiryInterval +// 31669,PropSubscriptionIdentifierAvailable 37,PropSharedSubscriptionAvailable 196,PropSessionExpiryInterval +// 9649,PropRetainAvailable 115,PropAssignedClientIdentifier "k\NAKr\222\138\154U\249\&4 +// \ESC^o]\230",PropMaximumPacketSize 31762,PropSessionExpiryInterval 10448,PropServerReference +// "v\211F\243=3\195",PropRetainAvailable 125,PropRequestProblemInformation 76,PropSubscriptionIdentifier +// 0,PropAuthenticationData "\236YG\200IK\ESC2h\141w\186\191f\250p\165\232#\153\183\209yB\206\152\&8\230"]} TEST(Connect5QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0xc6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x1, 0xde, 0x45, 0x12, 0x0, 0xa, - 0xeb, 0x73, 0x7f, 0x97, 0x67, 0xb, 0x8, 0x42, 0x45, 0xd7, 0x28, 0x5b, 0x26, 0x0, 0x6, 0x7c, 0x70, - 0xc2, 0xb, 0x31, 0xa1, 0x0, 0x16, 0xf7, 0x7a, 0xe, 0x72, 0xc0, 0xf6, 0x63, 0x98, 0x25, 0x5f, 0x84, - 0x7a, 0x62, 0x52, 0x1f, 0xda, 0x29, 0xc3, 0x93, 0x6b, 0x95, 0xc7, 0x12, 0x0, 0xf, 0xd, 0x2c, 0xb0, - 0x4e, 0x23, 0x9e, 0x2e, 0x5f, 0x47, 0x66, 0xda, 0xe4, 0x2c, 0xb4, 0x2d, 0x22, 0x3e, 0x72, 0x0, 0xc, - 0x2b, 0xfb, 0x51, 0xb9, 0x71, 0xc1, 0xc7, 0xa, 0xed, 0xba, 0xa2, 0x7, 0xd, 0x12, 0x0, 0x8, 0xfd, - 0x7b, 0xde, 0x1a, 0x1b, 0x5, 0xdf, 0xf4, 0x19, 0xdf, 0x0, 0xc, 0x4c, 0x26, 0x73, 0x76, 0xb0, 0x59, - 0x63, 0x32, 0x4f, 0x5c, 0xc9, 0x2c, 0x0, 0x1c, 0x2f, 0x7, 0x7d, 0xac, 0x74, 0x1f, 0xda, 0x83, 0xf0, - 0xe0, 0x53, 0xdd, 0xcd, 0x53, 0xe3, 0xdf, 0xe7, 0xf6, 0x7e, 0x5f, 0xa8, 0x7d, 0x7c, 0x38, 0xac, 0xdb, - 0x9d, 0xa8, 0x0, 0x10, 0xef, 0x7a, 0x6b, 0x9f, 0x3, 0xdf, 0x21, 0x8d, 0x3, 0xe9, 0xf8, 0xc, 0x31, - 0x3d, 0x14, 0x69, 0x0, 0x1a, 0xbf, 0x8d, 0xf6, 0x45, 0xc1, 0xec, 0xf3, 0xdf, 0x99, 0xd8, 0x6d, 0x79, - 0x6f, 0xc2, 0xd6, 0xf4, 0xc8, 0x8c, 0xc6, 0x93, 0xec, 0x51, 0xc2, 0x58, 0x82, 0x88}; - - uint8_t buf[211] = {0}; - - uint8_t bytesprops0[] = {0xeb, 0x73, 0x7f, 0x97, 0x67, 0xb, 0x8, 0x42, 0x45, 0xd7}; - uint8_t bytesprops2[] = {0xf7, 0x7a, 0xe, 0x72, 0xc0, 0xf6, 0x63, 0x98, 0x25, 0x5f, 0x84, - 0x7a, 0x62, 0x52, 0x1f, 0xda, 0x29, 0xc3, 0x93, 0x6b, 0x95, 0xc7}; - uint8_t bytesprops1[] = {0x7c, 0x70, 0xc2, 0xb, 0x31, 0xa1}; - uint8_t bytesprops3[] = {0xd, 0x2c, 0xb0, 0x4e, 0x23, 0x9e, 0x2e, 0x5f, 0x47, 0x66, 0xda, 0xe4, 0x2c, 0xb4, 0x2d}; + uint8_t pkt[] = { + 0x10, 0xcb, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0x3a, 0xe3, 0xc8, 0x1, 0x22, 0x35, 0x6b, 0x29, + 0x2d, 0x29, 0xa0, 0x16, 0x0, 0xe, 0x44, 0xb8, 0xa1, 0x3, 0xbd, 0xc4, 0x57, 0xe9, 0x4, 0x7f, 0x7c, 0xa8, 0x37, + 0xe8, 0x15, 0x0, 0x18, 0x65, 0xe1, 0xba, 0xf0, 0x70, 0x93, 0xe3, 0x55, 0xbc, 0x76, 0x84, 0xc0, 0xfb, 0x73, 0xe, + 0x21, 0x7e, 0x3f, 0x9a, 0xf6, 0xcb, 0xed, 0xf1, 0x91, 0x28, 0xd2, 0x21, 0x4c, 0x22, 0x2, 0x0, 0x0, 0x45, 0x20, + 0x1a, 0x0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8c, + 0xd, 0x61, 0x8, 0xb0, 0x1d, 0x73, 0x11, 0x0, 0x0, 0x16, 0xe3, 0x0, 0xa, 0x38, 0x5c, 0x73, 0x9, 0x57, 0xd5, + 0x40, 0x8, 0xae, 0x96, 0x0, 0x14, 0xf5, 0xf8, 0xf4, 0x71, 0x29, 0x85, 0x39, 0x25, 0x9e, 0x1b, 0x7, 0xfc, 0x5d, + 0x52, 0x63, 0x6f, 0x27, 0x5e, 0xc8, 0x3b, 0x0, 0x15, 0xf1, 0xb9, 0x5e, 0x1, 0x34, 0xba, 0x55, 0x7d, 0x49, 0xd0, + 0x89, 0x83, 0x4d, 0xa1, 0x43, 0xbe, 0x86, 0xae, 0x28, 0x42, 0xb5}; + + uint8_t buf[344] = {0}; + uint8_t bytesprops0[] = {0x44, 0xb8, 0xa1, 0x3, 0xbd, 0xc4, 0x57, 0xe9, 0x4, 0x7f, 0x7c, 0xa8, 0x37, 0xe8}; + uint8_t bytesprops1[] = {0x65, 0xe1, 0xba, 0xf0, 0x70, 0x93, 0xe3, 0x55, 0xbc, 0x76, 0x84, 0xc0, + 0xfb, 0x73, 0xe, 0x21, 0x7e, 0x3f, 0x9a, 0xf6, 0xcb, 0xed, 0xf1, 0x91}; + uint8_t bytesprops2[] = {0xf, 0xed, 0x2e, 0x33, 0xd0}; + uint8_t bytesprops3[] = {0xe4, 0x66, 0x26, 0xd1, 0x21, 0x93, 0xa5, 0xd7, 0x57, 0x95, 0x80, 0xac, 0xae, 0xf0, 0xb1, + 0x6f, 0xcf, 0x9c, 0x80, 0x23, 0xb8, 0x38, 0x2b, 0xdb, 0xd2, 0xad, 0x2d, 0xc4, 0x43}; + uint8_t bytesprops4[] = {0x6b, 0x15, 0x72, 0xde, 0x8a, 0x9a, 0x55, 0xf9, 0x34, 0x20, 0x1b, 0x5e, 0x6f, 0x5d, 0xe6}; + uint8_t bytesprops5[] = {0x76, 0xd3, 0x46, 0xf3, 0x3d, 0x33, 0xc3}; + uint8_t bytesprops6[] = {0xec, 0x59, 0x47, 0xc8, 0x49, 0x4b, 0x1b, 0x32, 0x68, 0x8d, 0x77, 0xba, 0xbf, 0x66, + 0xfa, 0x70, 0xa5, 0xe8, 0x23, 0x99, 0xb7, 0xd1, 0x79, 0x42, 0xce, 0x98, 0x38, 0xe6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {22, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15986}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13675}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19490}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17696}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10620}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17815}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31669}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9649}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31762}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10448}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xfd, 0x7b, 0xde, 0x1a, 0x1b, 0x5, 0xdf, 0xf4}; + uint8_t byteswillprops0[] = {0xd5, 0x4c, 0x99, 0xad, 0x94, 0x5a, 0xfe, 0xb1, 0x9b, + 0xe7, 0x99, 0x46, 0x33, 0x32, 0xeb, 0x27, 0xb0, 0xc3}; + uint8_t byteswillprops1[] = {0x8, 0x34, 0xde, 0x2, 0x51, 0xfd, 0xbc, 0xfc, 0x8c, 0xd, 0x61, 0x8, 0xb0, 0x1d, 0x73}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1358}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5859}}, }; - lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4c, 0x26, 0x73, 0x76, 0xb0, 0x59, 0x63, 0x32, 0x4f, 0x5c, 0xc9, 0x2c}; - lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x2f, 0x7, 0x7d, 0xac, 0x74, 0x1f, 0xda, 0x83, 0xf0, 0xe0, 0x53, 0xdd, 0xcd, 0x53, - 0xe3, 0xdf, 0xe7, 0xf6, 0x7e, 0x5f, 0xa8, 0x7d, 0x7c, 0x38, 0xac, 0xdb, 0x9d, 0xa8}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x38, 0x5c, 0x73, 0x9, 0x57, 0xd5, 0x40, 0x8, 0xae, 0x96}; + lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf5, 0xf8, 0xf4, 0x71, 0x29, 0x85, 0x39, 0x25, 0x9e, 0x1b, + 0x7, 0xfc, 0x5d, 0x52, 0x63, 0x6f, 0x27, 0x5e, 0xc8, 0x3b}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 478; - uint8_t client_id_bytes[] = {0x2b, 0xfb, 0x51, 0xb9, 0x71, 0xc1, 0xc7, 0xa, 0xed, 0xba, 0xa2, 0x7}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 15075; + uint8_t client_id_bytes[] = {0x7e, 0x67, 0x27, 0xac}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xef, 0x7a, 0x6b, 0x9f, 0x3, 0xdf, 0x21, 0x8d, - 0x3, 0xe9, 0xf8, 0xc, 0x31, 0x3d, 0x14, 0x69}; - lwmqtt_string_t username = {16, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf1, 0xb9, 0x5e, 0x1, 0x34, 0xba, 0x55, 0x7d, 0x49, 0xd0, 0x89, + 0x83, 0x4d, 0xa1, 0x43, 0xbe, 0x86, 0xae, 0x28, 0x42, 0xb5}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xbf, 0x8d, 0xf6, 0x45, 0xc1, 0xec, 0xf3, 0xdf, 0x99, 0xd8, 0x6d, 0x79, 0x6f, - 0xc2, 0xd6, 0xf4, 0xc8, 0x8c, 0xc6, 0x93, 0xec, 0x51, 0xc2, 0x58, 0x82, 0x88}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -3626,1668 +3512,1429 @@ TEST(Connect5QCTest, Encode10) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27385 [("\203r\138\235\US\213\196\158\177\226",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\210\190\198\&0ofo\DC1|E\r\rL\152\233\224d\199",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\237\&4\212\155\143\216\v\200\DEL\206\242\145\213W\133\216HU\FSK",SubOptions {_retainHandling = +// SubscribeRequest 30493 [("\214C\211\153\&6\151\166\198\180w\131_\236",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\173\182\235`z\189",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\149\ETX\DC3%\228\238+\165\167r\NAKr\178\170",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("4\244y\238\205\153\213",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\135",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\187\224\219\172\\$\133[rk\157\200\159O\ENQ@\167\217\254",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\237\ETB1\149\ETX\245\172\173\ETB\135\SOI",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("\245\157c\165h\181Ss\238\217\ESC\ENQ\206\225\171l\SUB\160A$\239\146pa\170\138",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\142\210",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0xa0, 0x1, 0x6a, 0xf9, 0x0, 0xa, 0xcb, 0x72, 0x8a, 0xeb, 0x1f, 0xd5, 0xc4, 0x9e, 0xb1, 0xe2, - 0x1, 0x0, 0x12, 0xd2, 0xbe, 0xc6, 0x30, 0x6f, 0x66, 0x6f, 0x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x1d, 0x5f, 0xff, + 0x5d, 0x2a, 0x74, 0x17, 0xa2, 0x6a, 0xce, 0x84, 0x8d, 0x33, 0xa9, 0x94, 0xaa, 0xd9, 0x24, 0x48, 0x16, + 0xff, 0xbb, 0x83, 0xe9, 0xf4, 0x9f, 0x27, 0xa5, 0xe5, 0x4d, 0x1, 0x0, 0x1d, 0x18, 0x59, 0xf, 0x32, + 0xbb, 0xc7, 0x44, 0xe3, 0x47, 0xfd, 0xca, 0x18, 0xd0, 0x68, 0x9a, 0x68, 0x60, 0xfe, 0xec, 0x85, 0x2f, + 0xc8, 0xad, 0xa3, 0x9e, 0xd0, 0xee, 0x75, 0x3e, 0x0, 0x0, 0xc, 0xed, 0x17, 0x31, 0x95, 0x3, 0xf5, + 0xac, 0xad, 0x17, 0x87, 0xe, 0x49, 0x0, 0x0, 0x1a, 0xf5, 0x9d, 0x63, 0xa5, 0x68, 0xb5, 0x53, 0x73, + 0xee, 0xd9, 0x1b, 0x5, 0xce, 0xe1, 0xab, 0x6c, 0x1a, 0xa0, 0x41, 0x24, 0xef, 0x92, 0x70, 0x61, 0xaa, + 0x8a, 0x2, 0x0, 0x0, 0x0, 0x0, 0x2, 0x8e, 0xd2, 0x0}; uint8_t buf[173] = {0}; - - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xcb, 0x72, 0x8a, 0xeb, 0x1f, 0xd5, 0xc4, 0x9e, 0xb1, 0xe2}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd6, 0x43, 0xd3, 0x99, 0x36, 0x97, 0xa6, 0xc6, 0xb4, 0x77, 0x83, 0x5f, 0xec}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd2, 0xbe, 0xc6, 0x30, 0x6f, 0x66, 0x6f, 0x11, 0x7c, - 0x45, 0xd, 0xd, 0x4c, 0x98, 0xe9, 0xe0, 0x64, 0xc7}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xed, 0x34, 0xd4, 0x9b, 0x8f, 0xd8, 0xb, 0xc8, 0x7f, 0xce, - 0xf2, 0x91, 0xd5, 0x57, 0x85, 0xd8, 0x48, 0x55, 0x1c, 0x4b}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xad, 0xb6, 0xeb, 0x60, 0x7a, 0xbd}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x95, 0x3, 0x13, 0x25, 0xe4, 0xee, 0x2b, 0xa5, 0xa7, 0x72, 0x15, 0x72, 0xb2, 0xaa}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x8e, 0x4a, 0xa3, 0x1a, 0x3c, 0xa6, 0xf0, 0x79, 0xb0, 0x72, 0xc0}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x34, 0xf4, 0x79, 0xee, 0xcd, 0x99, 0xd5}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x5f, 0xff, 0x5d, 0x2a, 0x74, 0x17, 0xa2, 0x6a, 0xce, 0x84, + 0x8d, 0x33, 0xa9, 0x94, 0xaa, 0xd9, 0x24, 0x48, 0x16, 0xff, + 0xbb, 0x83, 0xe9, 0xf4, 0x9f, 0x27, 0xa5, 0xe5, 0x4d}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x87}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x18, 0x59, 0xf, 0x32, 0xbb, 0xc7, 0x44, 0xe3, 0x47, 0xfd, + 0xca, 0x18, 0xd0, 0x68, 0x9a, 0x68, 0x60, 0xfe, 0xec, 0x85, + 0x2f, 0xc8, 0xad, 0xa3, 0x9e, 0xd0, 0xee, 0x75, 0x3e}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbb, 0xe0, 0xdb, 0xac, 0x5c, 0x24, 0x85, 0x5b, 0x72, 0x6b, - 0x9d, 0xc8, 0x9f, 0x4f, 0x5, 0x40, 0xa7, 0xd9, 0xfe, 0x3c, - 0x71, 0xad, 0x1f, 0xba, 0x89, 0xee, 0xb, 0x16, 0xe9, 0xbb}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xed, 0x17, 0x31, 0x95, 0x3, 0xf5, 0xac, 0xad, 0x17, 0x87, 0xe, 0x49}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6d, 0x34, 0xda, 0x57, 0xeb, 0x86, 0x4b, - 0x64, 0xaf, 0xbd, 0xd6, 0x52, 0x69, 0x4f}; - lwmqtt_string_t topic_filter_s7 = {14, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xf5, 0x9d, 0x63, 0xa5, 0x68, 0xb5, 0x53, 0x73, 0xee, 0xd9, 0x1b, 0x5, 0xce, + 0xe1, 0xab, 0x6c, 0x1a, 0xa0, 0x41, 0x24, 0xef, 0x92, 0x70, 0x61, 0xaa, 0x8a}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc3, 0xfe, 0x56, 0x7, 0xd3, 0x9d, 0x31, 0x3f, 0x4a, - 0x4c, 0xd2, 0x6d, 0xa, 0x5a, 0xc3, 0x33, 0xb}; - lwmqtt_string_t topic_filter_s8 = {17, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0}; + lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t topic_filter_s9_bytes[] = {0x8e, 0xd2}; + lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27385, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30493, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22666 [("G\DLE\141c\141\r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\DLEq\227\252\175\246{\157\250\NUL\231",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\175\SO.Id[",SubOptions +// SubscribeRequest 20478 [("\184}2\DC2\bp#\148\f\DC1\208}\194",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\181\209\150\255\240\&5\243\DC2\SO\208ji\180\129&P\178\ENQ?\229W?\192\GS\185\211\166\213\&4",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("p\210\142F\178\242R\233\138\188\253$$r\142\SYN\244\167k\195",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS2}),("\248\196L\195\ESC\ETX\DC3N\135\&3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\198\170\141\229\221[\227KN\143Fw\153\t\163\203\n\181\151\147\170",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\160\253\207yPZ\a\211\172o\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\164s\134^.\223\218\240\197J\148\212",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\240\\\189j\185\226\139}",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("x\172\224\142\143\226\196Z\SYN0\229l\218\175u`\190\250.m\227\222\240\ACK\255\DC2\211W",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\197U\154\166\243\218<\211^f\176\170Y\DC3\162;9^\159\232\181\239\161D\179\&2",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0x39, 0x58, 0x8a, 0x0, 0x6, 0x47, 0x10, 0x8d, 0x63, 0x8d, 0xd, 0x2, 0x0, 0xb, - 0x10, 0x71, 0xe3, 0xfc, 0xaf, 0xf6, 0x7b, 0x9d, 0xfa, 0x0, 0xe7, 0x0, 0x0, 0x6, 0xaf, - 0xe, 0x2e, 0x49, 0x64, 0x5b, 0x1, 0x0, 0x14, 0x70, 0xd2, 0x8e, 0x46, 0xb2, 0xf2, 0x52, - 0xe9, 0x8a, 0xbc, 0xfd, 0x24, 0x24, 0x72, 0x8e, 0x16, 0xf4, 0xa7, 0x6b, 0xc3, 0x2}; - - uint8_t buf[69] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x47, 0x10, 0x8d, 0x63, 0x8d, 0xd}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = { + 0x82, 0xbb, 0x1, 0x4f, 0xfe, 0x0, 0xd, 0xb8, 0x7d, 0x32, 0x12, 0x8, 0x70, 0x23, 0x94, 0xc, 0x11, 0xd0, 0x7d, + 0xc2, 0x1, 0x0, 0x1d, 0xb5, 0xd1, 0x96, 0xff, 0xf0, 0x35, 0xf3, 0x12, 0xe, 0xd0, 0x6a, 0x69, 0xb4, 0x81, 0x26, + 0x50, 0xb2, 0x5, 0x3f, 0xe5, 0x57, 0x3f, 0xc0, 0x1d, 0xb9, 0xd3, 0xa6, 0xd5, 0x34, 0x2, 0x0, 0xa, 0xf8, 0xc4, + 0x4c, 0xc3, 0x1b, 0x3, 0x13, 0x4e, 0x87, 0x33, 0x0, 0x0, 0x15, 0xc6, 0xaa, 0x8d, 0xe5, 0xdd, 0x5b, 0xe3, 0x4b, + 0x4e, 0x8f, 0x46, 0x77, 0x99, 0x9, 0xa3, 0xcb, 0xa, 0xb5, 0x97, 0x93, 0xaa, 0x1, 0x0, 0xb, 0xa0, 0xfd, 0xcf, + 0x79, 0x50, 0x5a, 0x7, 0xd3, 0xac, 0x6f, 0x94, 0x0, 0x0, 0xc, 0xa4, 0x73, 0x86, 0x5e, 0x2e, 0xdf, 0xda, 0xf0, + 0xc5, 0x4a, 0x94, 0xd4, 0x2, 0x0, 0x8, 0xf0, 0x5c, 0xbd, 0x6a, 0xb9, 0xe2, 0x8b, 0x7d, 0x2, 0x0, 0x1c, 0x78, + 0xac, 0xe0, 0x8e, 0x8f, 0xe2, 0xc4, 0x5a, 0x16, 0x30, 0xe5, 0x6c, 0xda, 0xaf, 0x75, 0x60, 0xbe, 0xfa, 0x2e, 0x6d, + 0xe3, 0xde, 0xf0, 0x6, 0xff, 0x12, 0xd3, 0x57, 0x0, 0x0, 0x1a, 0xc5, 0x55, 0x9a, 0xa6, 0xf3, 0xda, 0x3c, 0xd3, + 0x5e, 0x66, 0xb0, 0xaa, 0x59, 0x13, 0xa2, 0x3b, 0x39, 0x5e, 0x9f, 0xe8, 0xb5, 0xef, 0xa1, 0x44, 0xb3, 0x32, 0x2}; + + uint8_t buf[200] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xb8, 0x7d, 0x32, 0x12, 0x8, 0x70, 0x23, 0x94, 0xc, 0x11, 0xd0, 0x7d, 0xc2}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x10, 0x71, 0xe3, 0xfc, 0xaf, 0xf6, 0x7b, 0x9d, 0xfa, 0x0, 0xe7}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb5, 0xd1, 0x96, 0xff, 0xf0, 0x35, 0xf3, 0x12, 0xe, 0xd0, + 0x6a, 0x69, 0xb4, 0x81, 0x26, 0x50, 0xb2, 0x5, 0x3f, 0xe5, + 0x57, 0x3f, 0xc0, 0x1d, 0xb9, 0xd3, 0xa6, 0xd5, 0x34}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xaf, 0xe, 0x2e, 0x49, 0x64, 0x5b}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf8, 0xc4, 0x4c, 0xc3, 0x1b, 0x3, 0x13, 0x4e, 0x87, 0x33}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x70, 0xd2, 0x8e, 0x46, 0xb2, 0xf2, 0x52, 0xe9, 0x8a, 0xbc, - 0xfd, 0x24, 0x24, 0x72, 0x8e, 0x16, 0xf4, 0xa7, 0x6b, 0xc3}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc6, 0xaa, 0x8d, 0xe5, 0xdd, 0x5b, 0xe3, 0x4b, 0x4e, 0x8f, 0x46, + 0x77, 0x99, 0x9, 0xa3, 0xcb, 0xa, 0xb5, 0x97, 0x93, 0xaa}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t topic_filter_s4_bytes[] = {0xa0, 0xfd, 0xcf, 0x79, 0x50, 0x5a, 0x7, 0xd3, 0xac, 0x6f, 0x94}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa4, 0x73, 0x86, 0x5e, 0x2e, 0xdf, 0xda, 0xf0, 0xc5, 0x4a, 0x94, 0xd4}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xf0, 0x5c, 0xbd, 0x6a, 0xb9, 0xe2, 0x8b, 0x7d}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x78, 0xac, 0xe0, 0x8e, 0x8f, 0xe2, 0xc4, 0x5a, 0x16, 0x30, + 0xe5, 0x6c, 0xda, 0xaf, 0x75, 0x60, 0xbe, 0xfa, 0x2e, 0x6d, + 0xe3, 0xde, 0xf0, 0x6, 0xff, 0x12, 0xd3, 0x57}; + lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xc5, 0x55, 0x9a, 0xa6, 0xf3, 0xda, 0x3c, 0xd3, 0x5e, 0x66, 0xb0, 0xaa, 0x59, + 0x13, 0xa2, 0x3b, 0x39, 0x5e, 0x9f, 0xe8, 0xb5, 0xef, 0xa1, 0x44, 0xb3, 0x32}; + lwmqtt_string_t topic_filter_s8 = {26, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22666, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20478, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7099 [("\131J\165\202",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\r\242#[",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("+",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\165>^\202\145\206\SOH\DC1\152\r\214\128\148\140",SubOptions +// SubscribeRequest 17981 +// [("\236?\165\226{\229C",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 2713 [("\v\149\153&\227@\158",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\137\178V\240lc\224\b\175']\235\NUL$\243G\224_*\254",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("9\210TgR\152e\221\141\200\213\141\198U\DC3V5\226\221\190M\169",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x13, 0x69, 0x24, 0x0, 0xe, 0x67, 0xb8, 0xaf, 0xa9, 0x57, - 0xcf, 0x62, 0x34, 0x4, 0x76, 0x7c, 0x3e, 0xe5, 0x43, 0x1}; - - uint8_t buf[31] = {0}; + uint8_t pkt[] = {0x82, 0x3c, 0xa, 0x99, 0x0, 0x7, 0xb, 0x95, 0x99, 0x26, 0xe3, 0x40, 0x9e, 0x2, 0x0, 0x14, + 0x89, 0xb2, 0x56, 0xf0, 0x6c, 0x63, 0xe0, 0x8, 0xaf, 0x27, 0x5d, 0xeb, 0x0, 0x24, 0xf3, 0x47, + 0xe0, 0x5f, 0x2a, 0xfe, 0x0, 0x0, 0x16, 0x39, 0xd2, 0x54, 0x67, 0x52, 0x98, 0x65, 0xdd, 0x8d, + 0xc8, 0xd5, 0x8d, 0xc6, 0x55, 0x13, 0x56, 0x35, 0xe2, 0xdd, 0xbe, 0x4d, 0xa9, 0x1}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x67, 0xb8, 0xaf, 0xa9, 0x57, 0xcf, 0x62, 0x34, 0x4, 0x76, 0x7c, 0x3e, 0xe5, 0x43}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + uint8_t buf[72] = {0}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xb, 0x95, 0x99, 0x26, 0xe3, 0x40, 0x9e}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t topic_filter_s1_bytes[] = {0x89, 0xb2, 0x56, 0xf0, 0x6c, 0x63, 0xe0, 0x8, 0xaf, 0x27, + 0x5d, 0xeb, 0x0, 0x24, 0xf3, 0x47, 0xe0, 0x5f, 0x2a, 0xfe}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x39, 0xd2, 0x54, 0x67, 0x52, 0x98, 0x65, 0xdd, 0x8d, 0xc8, 0xd5, + 0x8d, 0xc6, 0x55, 0x13, 0x56, 0x35, 0xe2, 0xdd, 0xbe, 0x4d, 0xa9}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26916, 1, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2713, 3, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23203 [("\130\206\197\ETX(;3ie\228\139L\185\152\193\203\DC4\200\v}\b",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("U\v,\200o\aH\192\130\227\236\180=2\240\253\167!\139t\f\173-\140M",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\169\159D\FS\199m]J\SOHG\136Y7r7\160\252\231\185/\172\205N.\193\&9V",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\182\132\145J\160\&3\216-f\DC4X\142\188",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("X\DEL\227P \242\&23\175\NULVC\243jl\150\148B\250m",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\ESC\229&\185`\246\NULRL\168\216C;\165\167",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\t8\146\169\253\156^\157\EM|\141~t\205l\160\ETX\255\137\142v\188\"\DC22",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("U(!\US\174\250\156Z\ESC",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\US\219\141B\210\224Z\240",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\128\181\150r\134\164",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\146v\DLEM\165!\205`q\245ah.\235f\245#O\214c;\134\203\155\b",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 7741 [("7\233y\244\229-\244\179\172\&6\164H",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(")\139\210\DC4\162\189qQ\DC4\141\253\&8",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0xe5, 0x1, 0x5a, 0xa3, 0x0, 0x15, 0x82, 0xce, 0xc5, 0x3, 0x28, 0x3b, 0x33, 0x69, 0x65, 0xe4, - 0x8b, 0x4c, 0xb9, 0x98, 0xc1, 0xcb, 0x14, 0xc8, 0xb, 0x7d, 0x8, 0x1, 0x0, 0x19, 0x55, 0xb, 0x2c, - 0xc8, 0x6f, 0x7, 0x48, 0xc0, 0x82, 0xe3, 0xec, 0xb4, 0x3d, 0x32, 0xf0, 0xfd, 0xa7, 0x21, 0x8b, 0x74, - 0xc, 0xad, 0x2d, 0x8c, 0x4d, 0x0, 0x0, 0x1b, 0xa9, 0x9f, 0x44, 0x1c, 0xc7, 0x6d, 0x5d, 0x4a, 0x1, - 0x47, 0x88, 0x59, 0x37, 0x72, 0x37, 0xa0, 0xfc, 0xe7, 0xb9, 0x2f, 0xac, 0xcd, 0x4e, 0x2e, 0xc1, 0x39, - 0x56, 0x1, 0x0, 0xd, 0xb6, 0x84, 0x91, 0x4a, 0xa0, 0x33, 0xd8, 0x2d, 0x66, 0x14, 0x58, 0x8e, 0xbc, - 0x1, 0x0, 0x14, 0x58, 0x7f, 0xe3, 0x50, 0x20, 0xf2, 0x32, 0x33, 0xaf, 0x0, 0x56, 0x43, 0xf3, 0x6a, - 0x6c, 0x96, 0x94, 0x42, 0xfa, 0x6d, 0x0, 0x0, 0xf, 0x1b, 0xe5, 0x26, 0xb9, 0x60, 0xf6, 0x0, 0x52, - 0x4c, 0xa8, 0xd8, 0x43, 0x3b, 0xa5, 0xa7, 0x2, 0x0, 0x19, 0x9, 0x38, 0x92, 0xa9, 0xfd, 0x9c, 0x5e, - 0x9d, 0x19, 0x7c, 0x8d, 0x7e, 0x74, 0xcd, 0x6c, 0xa0, 0x3, 0xff, 0x89, 0x8e, 0x76, 0xbc, 0x22, 0x12, - 0x32, 0x1, 0x0, 0x9, 0x55, 0x28, 0x21, 0x1f, 0xae, 0xfa, 0x9c, 0x5a, 0x1b, 0x2, 0x0, 0x8, 0x1f, - 0xdb, 0x8d, 0x42, 0xd2, 0xe0, 0x5a, 0xf0, 0x2, 0x0, 0x6, 0x80, 0xb5, 0x96, 0x72, 0x86, 0xa4, 0x1, - 0x0, 0x19, 0x92, 0x76, 0x10, 0x4d, 0xa5, 0x21, 0xcd, 0x60, 0x71, 0xf5, 0x61, 0x68, 0x2e, 0xeb, 0x66, - 0xf5, 0x23, 0x4f, 0xd6, 0x63, 0x3b, 0x86, 0xcb, 0x9b, 0x8, 0x1}; - - uint8_t buf[242] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x82, 0xce, 0xc5, 0x3, 0x28, 0x3b, 0x33, 0x69, 0x65, 0xe4, 0x8b, - 0x4c, 0xb9, 0x98, 0xc1, 0xcb, 0x14, 0xc8, 0xb, 0x7d, 0x8}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x20, 0x1e, 0x3d, 0x0, 0xc, 0x37, 0xe9, 0x79, 0xf4, 0xe5, 0x2d, 0xf4, 0xb3, 0xac, 0x36, 0xa4, + 0x48, 0x1, 0x0, 0xc, 0x29, 0x8b, 0xd2, 0x14, 0xa2, 0xbd, 0x71, 0x51, 0x14, 0x8d, 0xfd, 0x38, 0x1}; + + uint8_t buf[44] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x37, 0xe9, 0x79, 0xf4, 0xe5, 0x2d, 0xf4, 0xb3, 0xac, 0x36, 0xa4, 0x48}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x55, 0xb, 0x2c, 0xc8, 0x6f, 0x7, 0x48, 0xc0, 0x82, 0xe3, 0xec, 0xb4, 0x3d, - 0x32, 0xf0, 0xfd, 0xa7, 0x21, 0x8b, 0x74, 0xc, 0xad, 0x2d, 0x8c, 0x4d}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x29, 0x8b, 0xd2, 0x14, 0xa2, 0xbd, 0x71, 0x51, 0x14, 0x8d, 0xfd, 0x38}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa9, 0x9f, 0x44, 0x1c, 0xc7, 0x6d, 0x5d, 0x4a, 0x1, 0x47, 0x88, 0x59, 0x37, 0x72, - 0x37, 0xa0, 0xfc, 0xe7, 0xb9, 0x2f, 0xac, 0xcd, 0x4e, 0x2e, 0xc1, 0x39, 0x56}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb6, 0x84, 0x91, 0x4a, 0xa0, 0x33, 0xd8, 0x2d, 0x66, 0x14, 0x58, 0x8e, 0xbc}; - lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x58, 0x7f, 0xe3, 0x50, 0x20, 0xf2, 0x32, 0x33, 0xaf, 0x0, - 0x56, 0x43, 0xf3, 0x6a, 0x6c, 0x96, 0x94, 0x42, 0xfa, 0x6d}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1b, 0xe5, 0x26, 0xb9, 0x60, 0xf6, 0x0, 0x52, - 0x4c, 0xa8, 0xd8, 0x43, 0x3b, 0xa5, 0xa7}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x9, 0x38, 0x92, 0xa9, 0xfd, 0x9c, 0x5e, 0x9d, 0x19, 0x7c, 0x8d, 0x7e, 0x74, - 0xcd, 0x6c, 0xa0, 0x3, 0xff, 0x89, 0x8e, 0x76, 0xbc, 0x22, 0x12, 0x32}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x55, 0x28, 0x21, 0x1f, 0xae, 0xfa, 0x9c, 0x5a, 0x1b}; - lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x1f, 0xdb, 0x8d, 0x42, 0xd2, 0xe0, 0x5a, 0xf0}; - lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x80, 0xb5, 0x96, 0x72, 0x86, 0xa4}; - lwmqtt_string_t topic_filter_s9 = {6, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x92, 0x76, 0x10, 0x4d, 0xa5, 0x21, 0xcd, 0x60, 0x71, 0xf5, 0x61, 0x68, 0x2e, - 0xeb, 0x66, 0xf5, 0x23, 0x4f, 0xd6, 0x63, 0x3b, 0x86, 0xcb, 0x9b, 0x8}; - lwmqtt_string_t topic_filter_s10 = {25, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23203, 11, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7741, 2, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 13111 [("\222\SYN24:\156\202\f\132\ETX\186\240",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\v\bAF\245\&5\231\181\211\&88\180\244\224q\245\&2\137||\146\&2\ESC\186p`",SubOptions {_retainHandling = +// SubscribeRequest 11149 +// [("^\226\251\181\&2\156|t\151S\169\252\146\ETX\GS\172S\169\EOT\142\201\173\164=\170a",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("z-Q\ETX\250}\168H\222\137\DC4\"\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\br\NUL\ENQ]\221\ETXkL\190o\238.#\227\230\EM\169wd",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\189\224\230\&0x$\EOTbXn\EM)\200\184\154ZeB\a\136Q+\233\158B",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\r\182,I",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("G\130\251\147\twO",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\188",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\222\RS\248\196\163\204P",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\160hI\180~R7W\238",SubOptions {_retainHandling = SendOnSubscribe, +// QoS1}),("\225W3k!\151\245\228>\205\198\132\168,\142",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\174\215\218\172V{\162\237\153\169\144\SO\STXM\190\n\135U\180\173\SYN\244\&5\227$\154\ACK\194\249\249",SubOptions +// QoS0}),("\FS\245\145\RS\166*\SOH\163\232\246[\204\144\192O\181\160",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\236\214\206\181\DC2\167\181k\255c\150C&X`R\250\150\SI\184G\241x\151\196\143R\144\210w",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0xbd, 0x1, 0x33, 0x37, 0x0, 0xc, 0xde, 0x16, 0x32, 0x34, 0x3a, 0x9c, 0xca, 0xc, 0x84, - 0x3, 0xba, 0xf0, 0x1, 0x0, 0x1a, 0xb, 0x8, 0x41, 0x46, 0xf5, 0x35, 0xe7, 0xb5, 0xd3, 0x38, - 0x38, 0xb4, 0xf4, 0xe0, 0x71, 0xf5, 0x32, 0x89, 0x7c, 0x7c, 0x92, 0x32, 0x1b, 0xba, 0x70, 0x60, - 0x0, 0x0, 0xd, 0x7a, 0x2d, 0x51, 0x3, 0xfa, 0x7d, 0xa8, 0x48, 0xde, 0x89, 0x14, 0x22, 0xaa, - 0x1, 0x0, 0x14, 0x8, 0x72, 0x0, 0x5, 0x5d, 0xdd, 0x3, 0x6b, 0x4c, 0xbe, 0x6f, 0xee, 0x2e, - 0x23, 0xe3, 0xe6, 0x19, 0xa9, 0x77, 0x64, 0x1, 0x0, 0x19, 0xbd, 0xe0, 0xe6, 0x30, 0x78, 0x24, - 0x4, 0x62, 0x58, 0x6e, 0x19, 0x29, 0xc8, 0xb8, 0x9a, 0x5a, 0x65, 0x42, 0x7, 0x88, 0x51, 0x2b, - 0xe9, 0x9e, 0x42, 0x2, 0x0, 0x4, 0xd, 0xb6, 0x2c, 0x49, 0x2, 0x0, 0x7, 0x47, 0x82, 0xfb, - 0x93, 0x9, 0x77, 0x4f, 0x2, 0x0, 0x1, 0xbc, 0x0, 0x0, 0x7, 0xde, 0x1e, 0xf8, 0xc4, 0xa3, - 0xcc, 0x50, 0x0, 0x0, 0x9, 0xa0, 0x68, 0x49, 0xb4, 0x7e, 0x52, 0x37, 0x57, 0xee, 0x2, 0x0, - 0x1e, 0xae, 0xd7, 0xda, 0xac, 0x56, 0x7b, 0xa2, 0xed, 0x99, 0xa9, 0x90, 0xe, 0x2, 0x4d, 0xbe, - 0xa, 0x87, 0x55, 0xb4, 0xad, 0x16, 0xf4, 0x35, 0xe3, 0x24, 0x9a, 0x6, 0xc2, 0xf9, 0xf9, 0x0}; - - uint8_t buf[202] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xde, 0x16, 0x32, 0x34, 0x3a, 0x9c, 0xca, 0xc, 0x84, 0x3, 0xba, 0xf0}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x66, 0x2b, 0x8d, 0x0, 0x1a, 0x5e, 0xe2, 0xfb, 0xb5, 0x32, 0x9c, 0x7c, 0x74, 0x97, + 0x53, 0xa9, 0xfc, 0x92, 0x3, 0x1d, 0xac, 0x53, 0xa9, 0x4, 0x8e, 0xc9, 0xad, 0xa4, 0x3d, + 0xaa, 0x61, 0x1, 0x0, 0xf, 0xe1, 0x57, 0x33, 0x6b, 0x21, 0x97, 0xf5, 0xe4, 0x3e, 0xcd, + 0xc6, 0x84, 0xa8, 0x2c, 0x8e, 0x0, 0x0, 0x11, 0x1c, 0xf5, 0x91, 0x1e, 0xa6, 0x2a, 0x1, + 0xa3, 0xe8, 0xf6, 0x5b, 0xcc, 0x90, 0xc0, 0x4f, 0xb5, 0xa0, 0x0, 0x0, 0x1e, 0xec, 0xd6, + 0xce, 0xb5, 0x12, 0xa7, 0xb5, 0x6b, 0xff, 0x63, 0x96, 0x43, 0x26, 0x58, 0x60, 0x52, 0xfa, + 0x96, 0xf, 0xb8, 0x47, 0xf1, 0x78, 0x97, 0xc4, 0x8f, 0x52, 0x90, 0xd2, 0x77, 0x0}; + + uint8_t buf[114] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x5e, 0xe2, 0xfb, 0xb5, 0x32, 0x9c, 0x7c, 0x74, 0x97, 0x53, 0xa9, 0xfc, 0x92, + 0x3, 0x1d, 0xac, 0x53, 0xa9, 0x4, 0x8e, 0xc9, 0xad, 0xa4, 0x3d, 0xaa, 0x61}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb, 0x8, 0x41, 0x46, 0xf5, 0x35, 0xe7, 0xb5, 0xd3, 0x38, 0x38, 0xb4, 0xf4, - 0xe0, 0x71, 0xf5, 0x32, 0x89, 0x7c, 0x7c, 0x92, 0x32, 0x1b, 0xba, 0x70, 0x60}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe1, 0x57, 0x33, 0x6b, 0x21, 0x97, 0xf5, 0xe4, + 0x3e, 0xcd, 0xc6, 0x84, 0xa8, 0x2c, 0x8e}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7a, 0x2d, 0x51, 0x3, 0xfa, 0x7d, 0xa8, 0x48, 0xde, 0x89, 0x14, 0x22, 0xaa}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1c, 0xf5, 0x91, 0x1e, 0xa6, 0x2a, 0x1, 0xa3, 0xe8, + 0xf6, 0x5b, 0xcc, 0x90, 0xc0, 0x4f, 0xb5, 0xa0}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8, 0x72, 0x0, 0x5, 0x5d, 0xdd, 0x3, 0x6b, 0x4c, 0xbe, - 0x6f, 0xee, 0x2e, 0x23, 0xe3, 0xe6, 0x19, 0xa9, 0x77, 0x64}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xec, 0xd6, 0xce, 0xb5, 0x12, 0xa7, 0xb5, 0x6b, 0xff, 0x63, + 0x96, 0x43, 0x26, 0x58, 0x60, 0x52, 0xfa, 0x96, 0xf, 0xb8, + 0x47, 0xf1, 0x78, 0x97, 0xc4, 0x8f, 0x52, 0x90, 0xd2, 0x77}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xbd, 0xe0, 0xe6, 0x30, 0x78, 0x24, 0x4, 0x62, 0x58, 0x6e, 0x19, 0x29, 0xc8, - 0xb8, 0x9a, 0x5a, 0x65, 0x42, 0x7, 0x88, 0x51, 0x2b, 0xe9, 0x9e, 0x42}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xd, 0xb6, 0x2c, 0x49}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x47, 0x82, 0xfb, 0x93, 0x9, 0x77, 0x4f}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xbc}; - lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xde, 0x1e, 0xf8, 0xc4, 0xa3, 0xcc, 0x50}; - lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa0, 0x68, 0x49, 0xb4, 0x7e, 0x52, 0x37, 0x57, 0xee}; - lwmqtt_string_t topic_filter_s9 = {9, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xae, 0xd7, 0xda, 0xac, 0x56, 0x7b, 0xa2, 0xed, 0x99, 0xa9, - 0x90, 0xe, 0x2, 0x4d, 0xbe, 0xa, 0x87, 0x55, 0xb4, 0xad, - 0x16, 0xf4, 0x35, 0xe3, 0x24, 0x9a, 0x6, 0xc2, 0xf9, 0xf9}; - lwmqtt_string_t topic_filter_s10 = {30, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13111, 11, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11149, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22578 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = -// QoS2}),("Y\180\175\251o\184au\195\159\207(+B\f\233\165\201\242\165\130\246Y\187q\CANg\155",SubOptions +// SubscribeRequest 2269 [("\DC2\238\205\167\203qt\199%Vl\129\160y\134\175U^\144K\SYN\ENQ\155+\GSdIr",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("R,\DC1w\SI\227c}",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("\134\NUL\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\US6\195Ct\137l\EOT\155\185\230\144\143H\n\vU!\196",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\195T\236\253h\n\197\181\188\199\206\134\174\196\215\FS\165\227'\220\DC1m}\206\164;\249\SOHR",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS2}),("\208\157\230h\219\215$\215\133\STXrRf\214m\159\156\229\196\139\223EF>1\n'",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\195S:\237\&8\249\f\223\SOH\EOTZ?\209RD1\128I\133\205\137\135c",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\252\&2\240JZ\198a\161y\244\135\130Ki\174\129\150\137H\142\184\151\167",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("%m\230\152\&3B\177\207",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\SO\US\NUL\133[",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\SO|\177\228\ETB\214C\165`\152*\SOM\180y9\233\&3`",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\160\&8\129\v\DC4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\\z\220\157\147\201\254\SUB\195\158\139\t\158\140\173\133\r\233\175q\212\152\175B\181d\FS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x6e, 0x58, 0x32, 0x0, 0x0, 0x2, 0x0, 0x1c, 0x59, 0xb4, 0xaf, 0xfb, 0x6f, 0xb8, 0x61, - 0x75, 0xc3, 0x9f, 0xcf, 0x28, 0x2b, 0x42, 0xc, 0xe9, 0xa5, 0xc9, 0xf2, 0xa5, 0x82, 0xf6, 0x59, - 0xbb, 0x71, 0x18, 0x67, 0x9b, 0x2, 0x0, 0x8, 0x52, 0x2c, 0x11, 0x77, 0xf, 0xe3, 0x63, 0x7d, - 0x1, 0x0, 0x3, 0x86, 0x0, 0xe8, 0x0, 0x0, 0x0, 0x1, 0x0, 0x13, 0x1f, 0x36, 0xc3, 0x43, - 0x74, 0x89, 0x6c, 0x4, 0x9b, 0xb9, 0xe6, 0x90, 0x8f, 0x48, 0xa, 0xb, 0x55, 0x21, 0xc4, 0x1, - 0x0, 0x1d, 0xc3, 0x54, 0xec, 0xfd, 0x68, 0xa, 0xc5, 0xb5, 0xbc, 0xc7, 0xce, 0x86, 0xae, 0xc4, - 0xd7, 0x1c, 0xa5, 0xe3, 0x27, 0xdc, 0x11, 0x6d, 0x7d, 0xce, 0xa4, 0x3b, 0xf9, 0x1, 0x52, 0x2}; - - uint8_t buf[122] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0xc5, 0x1, 0x8, 0xdd, 0x0, 0x1c, 0x12, 0xee, 0xcd, 0xa7, 0xcb, 0x71, 0x74, 0xc7, 0x25, 0x56, + 0x6c, 0x81, 0xa0, 0x79, 0x86, 0xaf, 0x55, 0x5e, 0x90, 0x4b, 0x16, 0x5, 0x9b, 0x2b, 0x1d, 0x64, 0x49, + 0x72, 0x2, 0x0, 0x1b, 0xd0, 0x9d, 0xe6, 0x68, 0xdb, 0xd7, 0x24, 0xd7, 0x85, 0x2, 0x72, 0x52, 0x66, + 0xd6, 0x6d, 0x9f, 0x9c, 0xe5, 0xc4, 0x8b, 0xdf, 0x45, 0x46, 0x3e, 0x31, 0xa, 0x27, 0x0, 0x0, 0x17, + 0xc3, 0x53, 0x3a, 0xed, 0x38, 0xf9, 0xc, 0xdf, 0x1, 0x4, 0x5a, 0x3f, 0xd1, 0x52, 0x44, 0x31, 0x80, + 0x49, 0x85, 0xcd, 0x89, 0x87, 0x63, 0x1, 0x0, 0x17, 0xfc, 0x32, 0xf0, 0x4a, 0x5a, 0xc6, 0x61, 0xa1, + 0x79, 0xf4, 0x87, 0x82, 0x4b, 0x69, 0xae, 0x81, 0x96, 0x89, 0x48, 0x8e, 0xb8, 0x97, 0xa7, 0x0, 0x0, + 0x8, 0x25, 0x6d, 0xe6, 0x98, 0x33, 0x42, 0xb1, 0xcf, 0x0, 0x0, 0x5, 0xe, 0x1f, 0x0, 0x85, 0x5b, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x13, 0xe, 0x7c, 0xb1, 0xe4, 0x17, 0xd6, 0x43, 0xa5, 0x60, 0x98, 0x2a, + 0xe, 0x4d, 0xb4, 0x79, 0x39, 0xe9, 0x33, 0x60, 0x2, 0x0, 0x5, 0xa0, 0x38, 0x81, 0xb, 0x14, 0x2, + 0x0, 0x1b, 0x5c, 0x7a, 0xdc, 0x9d, 0x93, 0xc9, 0xfe, 0x1a, 0xc3, 0x9e, 0x8b, 0x9, 0x9e, 0x8c, 0xad, + 0x85, 0xd, 0xe9, 0xaf, 0x71, 0xd4, 0x98, 0xaf, 0x42, 0xb5, 0x64, 0x1c, 0x0}; + + uint8_t buf[210] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x12, 0xee, 0xcd, 0xa7, 0xcb, 0x71, 0x74, 0xc7, 0x25, 0x56, + 0x6c, 0x81, 0xa0, 0x79, 0x86, 0xaf, 0x55, 0x5e, 0x90, 0x4b, + 0x16, 0x5, 0x9b, 0x2b, 0x1d, 0x64, 0x49, 0x72}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x59, 0xb4, 0xaf, 0xfb, 0x6f, 0xb8, 0x61, 0x75, 0xc3, 0x9f, - 0xcf, 0x28, 0x2b, 0x42, 0xc, 0xe9, 0xa5, 0xc9, 0xf2, 0xa5, - 0x82, 0xf6, 0x59, 0xbb, 0x71, 0x18, 0x67, 0x9b}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd0, 0x9d, 0xe6, 0x68, 0xdb, 0xd7, 0x24, 0xd7, 0x85, 0x2, 0x72, 0x52, 0x66, 0xd6, + 0x6d, 0x9f, 0x9c, 0xe5, 0xc4, 0x8b, 0xdf, 0x45, 0x46, 0x3e, 0x31, 0xa, 0x27}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x52, 0x2c, 0x11, 0x77, 0xf, 0xe3, 0x63, 0x7d}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc3, 0x53, 0x3a, 0xed, 0x38, 0xf9, 0xc, 0xdf, 0x1, 0x4, 0x5a, 0x3f, + 0xd1, 0x52, 0x44, 0x31, 0x80, 0x49, 0x85, 0xcd, 0x89, 0x87, 0x63}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x86, 0x0, 0xe8}; - lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfc, 0x32, 0xf0, 0x4a, 0x5a, 0xc6, 0x61, 0xa1, 0x79, 0xf4, 0x87, 0x82, + 0x4b, 0x69, 0xae, 0x81, 0x96, 0x89, 0x48, 0x8e, 0xb8, 0x97, 0xa7}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x25, 0x6d, 0xe6, 0x98, 0x33, 0x42, 0xb1, 0xcf}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1f, 0x36, 0xc3, 0x43, 0x74, 0x89, 0x6c, 0x4, 0x9b, 0xb9, - 0xe6, 0x90, 0x8f, 0x48, 0xa, 0xb, 0x55, 0x21, 0xc4}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe, 0x1f, 0x0, 0x85, 0x5b}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc3, 0x54, 0xec, 0xfd, 0x68, 0xa, 0xc5, 0xb5, 0xbc, 0xc7, - 0xce, 0x86, 0xae, 0xc4, 0xd7, 0x1c, 0xa5, 0xe3, 0x27, 0xdc, - 0x11, 0x6d, 0x7d, 0xce, 0xa4, 0x3b, 0xf9, 0x1, 0x52}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t topic_filter_s7_bytes[] = {0xe, 0x7c, 0xb1, 0xe4, 0x17, 0xd6, 0x43, 0xa5, 0x60, 0x98, + 0x2a, 0xe, 0x4d, 0xb4, 0x79, 0x39, 0xe9, 0x33, 0x60}; + lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa0, 0x38, 0x81, 0xb, 0x14}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x5c, 0x7a, 0xdc, 0x9d, 0x93, 0xc9, 0xfe, 0x1a, 0xc3, 0x9e, 0x8b, 0x9, 0x9e, 0x8c, + 0xad, 0x85, 0xd, 0xe9, 0xaf, 0x71, 0xd4, 0x98, 0xaf, 0x42, 0xb5, 0x64, 0x1c}; + lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22578, 7, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2269, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 5714 [("Z\154\192",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("n\209\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\236[5",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1}),("+l\193\192-m.\NUL\128\147\191\196\DC4\255 -// \250\233P\183w\192\176F-\192\208\158\201\172\231",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("A\222\209\219\SO\f\212\243or\200\&4",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 9248 [("\233\154\252\129\230\&9\142\177.,%\202H\EM",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("s\ETB\220\154j\DC1\149e\235\252\163\CANis@",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SOHz\161\174&\ESC;\181-\130",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\204l}DdML\130\250\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0x44, 0x16, 0x52, 0x0, 0x3, 0x5a, 0x9a, 0xc0, 0x0, 0x0, 0x3, 0x6e, 0xd1, - 0x83, 0x2, 0x0, 0x3, 0xec, 0x5b, 0x35, 0x1, 0x0, 0x1e, 0x2b, 0x6c, 0xc1, 0xc0, - 0x2d, 0x6d, 0x2e, 0x0, 0x80, 0x93, 0xbf, 0xc4, 0x14, 0xff, 0x20, 0xfa, 0xe9, 0x50, - 0xb7, 0x77, 0xc0, 0xb0, 0x46, 0x2d, 0xc0, 0xd0, 0x9e, 0xc9, 0xac, 0xe7, 0x1, 0x0, - 0xc, 0x41, 0xde, 0xd1, 0xdb, 0xe, 0xc, 0xd4, 0xf3, 0x6f, 0x72, 0xc8, 0x34, 0x1}; - - uint8_t buf[80] = {0}; + uint8_t pkt[] = {0x82, 0x3f, 0x24, 0x20, 0x0, 0xe, 0xe9, 0x9a, 0xfc, 0x81, 0xe6, 0x39, 0x8e, 0xb1, 0x2e, 0x2c, 0x25, + 0xca, 0x48, 0x19, 0x2, 0x0, 0xf, 0x73, 0x17, 0xdc, 0x9a, 0x6a, 0x11, 0x95, 0x65, 0xeb, 0xfc, 0xa3, + 0x18, 0x69, 0x73, 0x40, 0x0, 0x0, 0xa, 0x1, 0x7a, 0xa1, 0xae, 0x26, 0x1b, 0x3b, 0xb5, 0x2d, 0x82, + 0x1, 0x0, 0xa, 0xcc, 0x6c, 0x7d, 0x44, 0x64, 0x4d, 0x4c, 0x82, 0xfa, 0x2, 0x2}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x5a, 0x9a, 0xc0}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + uint8_t buf[75] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xe9, 0x9a, 0xfc, 0x81, 0xe6, 0x39, 0x8e, + 0xb1, 0x2e, 0x2c, 0x25, 0xca, 0x48, 0x19}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6e, 0xd1, 0x83}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x73, 0x17, 0xdc, 0x9a, 0x6a, 0x11, 0x95, 0x65, + 0xeb, 0xfc, 0xa3, 0x18, 0x69, 0x73, 0x40}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xec, 0x5b, 0x35}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1, 0x7a, 0xa1, 0xae, 0x26, 0x1b, 0x3b, 0xb5, 0x2d, 0x82}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2b, 0x6c, 0xc1, 0xc0, 0x2d, 0x6d, 0x2e, 0x0, 0x80, 0x93, - 0xbf, 0xc4, 0x14, 0xff, 0x20, 0xfa, 0xe9, 0x50, 0xb7, 0x77, - 0xc0, 0xb0, 0x46, 0x2d, 0xc0, 0xd0, 0x9e, 0xc9, 0xac, 0xe7}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xcc, 0x6c, 0x7d, 0x44, 0x64, 0x4d, 0x4c, 0x82, 0xfa, 0x2}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x41, 0xde, 0xd1, 0xdb, 0xe, 0xc, 0xd4, 0xf3, 0x6f, 0x72, 0xc8, 0x34}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5714, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9248, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3531 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\254\134x\175,x\231\DC3\SOHJ\EOT",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\132bW\232H.\t\251\ACK\185\246\221\163",SubOptions +// SubscribeRequest 22320 [("U\\Dd9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = +// QoS2}),("w\225r\ETB\229\148t\144\141\ETB\DC3\141\216\DEL\SYN7r^\157\169\201\222\240{\CAN\162",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\240\158)|E\240\&8\229\159#3\US$\GS\163\142\184\204\a\254\249\NAK\212}",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(".\US\239\142\182M\DC2\228v\142",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\145\239\128\212\215v\211R\239\248\165M\231oh\163\192PE\213\174\249\165\218\ETB\148",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("'\251\128\148 -// \133P@7h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\v\210V\DLE\245\137\166\n\v!:\NAK\231Y\SYN\215\n\247\191g\147\RS\STX",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("FH\178&\154",SubOptions +// QoS1}),("\144%\189P}R&]F\140hw\FS\134Pm\201\240\130#\185",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("6\155R=&\211a\DC3v\192\rP~\175",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\228\161\STXal\230\192\ETB\213\134\a\178a4",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\223\209\242\169\SO\193\&9\248\172\170\181\153\222E!\208\167mA\140\206\170\\\189-A\155",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0x9a, 0x1, 0xd, 0xcb, 0x0, 0x0, 0x0, 0x0, 0xb, 0xfe, 0x86, 0x78, 0xaf, 0x2c, 0x78, - 0xe7, 0x13, 0x1, 0x4a, 0x4, 0x2, 0x0, 0xd, 0x84, 0x62, 0x57, 0xe8, 0x48, 0x2e, 0x9, 0xfb, - 0x6, 0xb9, 0xf6, 0xdd, 0xa3, 0x0, 0x0, 0x18, 0xf0, 0x9e, 0x29, 0x7c, 0x45, 0xf0, 0x38, 0xe5, - 0x9f, 0x23, 0x33, 0x1f, 0x24, 0x1d, 0xa3, 0x8e, 0xb8, 0xcc, 0x7, 0xfe, 0xf9, 0x15, 0xd4, 0x7d, - 0x2, 0x0, 0xa, 0x2e, 0x1f, 0xef, 0x8e, 0xb6, 0x4d, 0x12, 0xe4, 0x76, 0x8e, 0x2, 0x0, 0x1a, - 0x91, 0xef, 0x80, 0xd4, 0xd7, 0x76, 0xd3, 0x52, 0xef, 0xf8, 0xa5, 0x4d, 0xe7, 0x6f, 0x68, 0xa3, - 0xc0, 0x50, 0x45, 0xd5, 0xae, 0xf9, 0xa5, 0xda, 0x17, 0x94, 0x2, 0x0, 0xa, 0x27, 0xfb, 0x80, - 0x94, 0x20, 0x85, 0x50, 0x40, 0x37, 0x68, 0x2, 0x0, 0x17, 0xb, 0xd2, 0x56, 0x10, 0xf5, 0x89, - 0xa6, 0xa, 0xb, 0x21, 0x3a, 0x15, 0xe7, 0x59, 0x16, 0xd7, 0xa, 0xf7, 0xbf, 0x67, 0x93, 0x1e, - 0x2, 0x2, 0x0, 0x0, 0x0, 0x0, 0x5, 0x46, 0x48, 0xb2, 0x26, 0x9a, 0x2}; - - uint8_t buf[167] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x7f, 0x57, 0x30, 0x0, 0x5, 0x55, 0x5c, 0x44, 0x64, 0x39, 0x2, 0x0, 0x1a, 0x77, 0xe1, 0x72, + 0x17, 0xe5, 0x94, 0x74, 0x90, 0x8d, 0x17, 0x13, 0x8d, 0xd8, 0x7f, 0x16, 0x37, 0x72, 0x5e, 0x9d, 0xa9, + 0xc9, 0xde, 0xf0, 0x7b, 0x18, 0xa2, 0x1, 0x0, 0x15, 0x90, 0x25, 0xbd, 0x50, 0x7d, 0x52, 0x26, 0x5d, + 0x46, 0x8c, 0x68, 0x77, 0x1c, 0x86, 0x50, 0x6d, 0xc9, 0xf0, 0x82, 0x23, 0xb9, 0x1, 0x0, 0xe, 0x36, + 0x9b, 0x52, 0x3d, 0x26, 0xd3, 0x61, 0x13, 0x76, 0xc0, 0xd, 0x50, 0x7e, 0xaf, 0x0, 0x0, 0xe, 0xe4, + 0xa1, 0x2, 0x61, 0x6c, 0xe6, 0xc0, 0x17, 0xd5, 0x86, 0x7, 0xb2, 0x61, 0x34, 0x1, 0x0, 0x1b, 0xdf, + 0xd1, 0xf2, 0xa9, 0xe, 0xc1, 0x39, 0xf8, 0xac, 0xaa, 0xb5, 0x99, 0xde, 0x45, 0x21, 0xd0, 0xa7, 0x6d, + 0x41, 0x8c, 0xce, 0xaa, 0x5c, 0xbd, 0x2d, 0x41, 0x9b, 0x2}; + + uint8_t buf[139] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x55, 0x5c, 0x44, 0x64, 0x39}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfe, 0x86, 0x78, 0xaf, 0x2c, 0x78, 0xe7, 0x13, 0x1, 0x4a, 0x4}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x77, 0xe1, 0x72, 0x17, 0xe5, 0x94, 0x74, 0x90, 0x8d, 0x17, 0x13, 0x8d, 0xd8, + 0x7f, 0x16, 0x37, 0x72, 0x5e, 0x9d, 0xa9, 0xc9, 0xde, 0xf0, 0x7b, 0x18, 0xa2}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x84, 0x62, 0x57, 0xe8, 0x48, 0x2e, 0x9, 0xfb, 0x6, 0xb9, 0xf6, 0xdd, 0xa3}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x90, 0x25, 0xbd, 0x50, 0x7d, 0x52, 0x26, 0x5d, 0x46, 0x8c, 0x68, + 0x77, 0x1c, 0x86, 0x50, 0x6d, 0xc9, 0xf0, 0x82, 0x23, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf0, 0x9e, 0x29, 0x7c, 0x45, 0xf0, 0x38, 0xe5, 0x9f, 0x23, 0x33, 0x1f, - 0x24, 0x1d, 0xa3, 0x8e, 0xb8, 0xcc, 0x7, 0xfe, 0xf9, 0x15, 0xd4, 0x7d}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x36, 0x9b, 0x52, 0x3d, 0x26, 0xd3, 0x61, 0x13, 0x76, 0xc0, 0xd, 0x50, 0x7e, 0xaf}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2e, 0x1f, 0xef, 0x8e, 0xb6, 0x4d, 0x12, 0xe4, 0x76, 0x8e}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xe4, 0xa1, 0x2, 0x61, 0x6c, 0xe6, 0xc0, 0x17, 0xd5, 0x86, 0x7, 0xb2, 0x61, 0x34}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x91, 0xef, 0x80, 0xd4, 0xd7, 0x76, 0xd3, 0x52, 0xef, 0xf8, 0xa5, 0x4d, 0xe7, - 0x6f, 0x68, 0xa3, 0xc0, 0x50, 0x45, 0xd5, 0xae, 0xf9, 0xa5, 0xda, 0x17, 0x94}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xdf, 0xd1, 0xf2, 0xa9, 0xe, 0xc1, 0x39, 0xf8, 0xac, 0xaa, 0xb5, 0x99, 0xde, 0x45, + 0x21, 0xd0, 0xa7, 0x6d, 0x41, 0x8c, 0xce, 0xaa, 0x5c, 0xbd, 0x2d, 0x41, 0x9b}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x27, 0xfb, 0x80, 0x94, 0x20, 0x85, 0x50, 0x40, 0x37, 0x68}; - lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb, 0xd2, 0x56, 0x10, 0xf5, 0x89, 0xa6, 0xa, 0xb, 0x21, 0x3a, 0x15, - 0xe7, 0x59, 0x16, 0xd7, 0xa, 0xf7, 0xbf, 0x67, 0x93, 0x1e, 0x2}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0}; - lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x46, 0x48, 0xb2, 0x26, 0x9a}; - lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3531, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22320, 6, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27385 [("\203r\138\235\US\213\196\158\177\226",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\210\190\198\&0ofo\DC1|E\r\rL\152\233\224d\199",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\237\&4\212\155\143\216\v\200\DEL\206\242\145\213W\133\216HU\FSK",SubOptions {_retainHandling = +// SubscribeRequest 30493 [("\214C\211\153\&6\151\166\198\180w\131_\236",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\173\182\235`z\189",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\149\ETX\DC3%\228\238+\165\167r\NAKr\178\170",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("4\244y\238\205\153\213",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\135",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\187\224\219\172\\$\133[rk\157\200\159O\ENQ@\167\217\254",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("m4\218W\235\134Kd\175\189\214RiO",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\195\254V\a\211\157\&1?JL\210m\nZ\195\&3\v",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReceiveMaximum -// 20429,PropUserProperty "\193" -// "\188C\192\153\192\230A\231WSt\132\189[\DC4B\176\228\247O\174\128\136\213\179\255\173\232\"0",PropSubscriptionIdentifierAvailable -// 152,PropAuthenticationMethod "\153x\250\184\242\SOH\195\190",PropSessionExpiryInterval -// 15605,PropSubscriptionIdentifierAvailable 220,PropMaximumQoS 247,PropReceiveMaximum 2807,PropMaximumQoS -// 94,PropCorrelationData "",PropWillDelayInterval 23153,PropReasonString -// "bOZRd\a\227\217\255u\156\248DW\ESCg\146\215\233\200\157\193",PropUserProperty -// "\168\160\245`?:\216G\SYN4\241\177\237\DC3" "u:\148_\181\&7\199\GS\136\DC3I$9 \176\186",PropSessionExpiryInterval -// 1621,PropRetainAvailable 254,PropServerKeepAlive 28200,PropServerKeepAlive 26260] +// QoS0}),("\237\ETB1\149\ETX\245\172\173\ETB\135\SOI",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("\245\157c\165h\181Ss\238\217\ESC\ENQ\206\225\171l\SUB\160A$\239\146pa\170\138",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\142\210",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropRetainAvailable 254,PropContentType "a$\140\162\133`\134\\G\US\DLE\191",PropWildcardSubscriptionAvailable +// 25,PropMaximumPacketSize 16917,PropRequestResponseInformation 230,PropAssignedClientIdentifier +// "0d\171\242]\161B\161\213\166W\202v\128\147\240}aGG\161A\253\181\182\156"] TEST(Subscribe5QCTest, Encode1) { - uint8_t pkt[] = { - 0x82, 0xb5, 0x2, 0x6a, 0xf9, 0x93, 0x1, 0x21, 0x4f, 0xcd, 0x26, 0x0, 0x1, 0xc1, 0x0, 0x1e, 0xbc, 0x43, 0xc0, - 0x99, 0xc0, 0xe6, 0x41, 0xe7, 0x57, 0x53, 0x74, 0x84, 0xbd, 0x5b, 0x14, 0x42, 0xb0, 0xe4, 0xf7, 0x4f, 0xae, 0x80, - 0x88, 0xd5, 0xb3, 0xff, 0xad, 0xe8, 0x22, 0x30, 0x29, 0x98, 0x15, 0x0, 0x8, 0x99, 0x78, 0xfa, 0xb8, 0xf2, 0x1, - 0xc3, 0xbe, 0x11, 0x0, 0x0, 0x3c, 0xf5, 0x29, 0xdc, 0x24, 0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x9d, 0xc8, 0x9f, 0x4f, 0x5, 0x40, 0xa7, 0xd9, 0xfe, 0x3c, 0x71, 0xad, - 0x1f, 0xba, 0x89, 0xee, 0xb, 0x16, 0xe9, 0xbb, 0x2, 0x0, 0xe, 0x6d, 0x34, 0xda, 0x57, 0xeb, 0x86, 0x4b, 0x64, - 0xaf, 0xbd, 0xd6, 0x52, 0x69, 0x4f, 0x0, 0x0, 0x11, 0xc3, 0xfe, 0x56, 0x7, 0xd3, 0x9d, 0x31, 0x3f, 0x4a, 0x4c, - 0xd2, 0x6d, 0xa, 0x5a, 0xc3, 0x33, 0xb, 0x1}; - - uint8_t buf[322] = {0}; - - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xcb, 0x72, 0x8a, 0xeb, 0x1f, 0xd5, 0xc4, 0x9e, 0xb1, 0xe2}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0xd8, 0x1, 0x77, 0x1d, 0x37, 0x25, 0xfe, 0x3, 0x0, 0xc, 0x61, 0x24, 0x8c, 0xa2, 0x85, 0x60, + 0x86, 0x5c, 0x47, 0x1f, 0x10, 0xbf, 0x28, 0x19, 0x27, 0x0, 0x0, 0x42, 0x15, 0x19, 0xe6, 0x12, 0x0, + 0x1a, 0x30, 0x64, 0xab, 0xf2, 0x5d, 0xa1, 0x42, 0xa1, 0xd5, 0xa6, 0x57, 0xca, 0x76, 0x80, 0x93, 0xf0, + 0x7d, 0x61, 0x47, 0x47, 0xa1, 0x41, 0xfd, 0xb5, 0xb6, 0x9c, 0x0, 0xd, 0xd6, 0x43, 0xd3, 0x99, 0x36, + 0x97, 0xa6, 0xc6, 0xb4, 0x77, 0x83, 0x5f, 0xec, 0x2, 0x0, 0x0, 0x1, 0x0, 0x6, 0xad, 0xb6, 0xeb, + 0x60, 0x7a, 0xbd, 0x0, 0x0, 0xb, 0x8e, 0x4a, 0xa3, 0x1a, 0x3c, 0xa6, 0xf0, 0x79, 0xb0, 0x72, 0xc0, + 0x1, 0x0, 0x1d, 0x5f, 0xff, 0x5d, 0x2a, 0x74, 0x17, 0xa2, 0x6a, 0xce, 0x84, 0x8d, 0x33, 0xa9, 0x94, + 0xaa, 0xd9, 0x24, 0x48, 0x16, 0xff, 0xbb, 0x83, 0xe9, 0xf4, 0x9f, 0x27, 0xa5, 0xe5, 0x4d, 0x1, 0x0, + 0x1d, 0x18, 0x59, 0xf, 0x32, 0xbb, 0xc7, 0x44, 0xe3, 0x47, 0xfd, 0xca, 0x18, 0xd0, 0x68, 0x9a, 0x68, + 0x60, 0xfe, 0xec, 0x85, 0x2f, 0xc8, 0xad, 0xa3, 0x9e, 0xd0, 0xee, 0x75, 0x3e, 0x0, 0x0, 0xc, 0xed, + 0x17, 0x31, 0x95, 0x3, 0xf5, 0xac, 0xad, 0x17, 0x87, 0xe, 0x49, 0x0, 0x0, 0x1a, 0xf5, 0x9d, 0x63, + 0xa5, 0x68, 0xb5, 0x53, 0x73, 0xee, 0xd9, 0x1b, 0x5, 0xce, 0xe1, 0xab, 0x6c, 0x1a, 0xa0, 0x41, 0x24, + 0xef, 0x92, 0x70, 0x61, 0xaa, 0x8a, 0x2, 0x0, 0x0, 0x0, 0x0, 0x2, 0x8e, 0xd2, 0x0}; + + uint8_t buf[229] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd6, 0x43, 0xd3, 0x99, 0x36, 0x97, 0xa6, 0xc6, 0xb4, 0x77, 0x83, 0x5f, 0xec}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd2, 0xbe, 0xc6, 0x30, 0x6f, 0x66, 0x6f, 0x11, 0x7c, - 0x45, 0xd, 0xd, 0x4c, 0x98, 0xe9, 0xe0, 0x64, 0xc7}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xed, 0x34, 0xd4, 0x9b, 0x8f, 0xd8, 0xb, 0xc8, 0x7f, 0xce, - 0xf2, 0x91, 0xd5, 0x57, 0x85, 0xd8, 0x48, 0x55, 0x1c, 0x4b}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xad, 0xb6, 0xeb, 0x60, 0x7a, 0xbd}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x95, 0x3, 0x13, 0x25, 0xe4, 0xee, 0x2b, 0xa5, 0xa7, 0x72, 0x15, 0x72, 0xb2, 0xaa}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x8e, 0x4a, 0xa3, 0x1a, 0x3c, 0xa6, 0xf0, 0x79, 0xb0, 0x72, 0xc0}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x34, 0xf4, 0x79, 0xee, 0xcd, 0x99, 0xd5}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x5f, 0xff, 0x5d, 0x2a, 0x74, 0x17, 0xa2, 0x6a, 0xce, 0x84, + 0x8d, 0x33, 0xa9, 0x94, 0xaa, 0xd9, 0x24, 0x48, 0x16, 0xff, + 0xbb, 0x83, 0xe9, 0xf4, 0x9f, 0x27, 0xa5, 0xe5, 0x4d}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x87}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x18, 0x59, 0xf, 0x32, 0xbb, 0xc7, 0x44, 0xe3, 0x47, 0xfd, + 0xca, 0x18, 0xd0, 0x68, 0x9a, 0x68, 0x60, 0xfe, 0xec, 0x85, + 0x2f, 0xc8, 0xad, 0xa3, 0x9e, 0xd0, 0xee, 0x75, 0x3e}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbb, 0xe0, 0xdb, 0xac, 0x5c, 0x24, 0x85, 0x5b, 0x72, 0x6b, - 0x9d, 0xc8, 0x9f, 0x4f, 0x5, 0x40, 0xa7, 0xd9, 0xfe, 0x3c, - 0x71, 0xad, 0x1f, 0xba, 0x89, 0xee, 0xb, 0x16, 0xe9, 0xbb}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xed, 0x17, 0x31, 0x95, 0x3, 0xf5, 0xac, 0xad, 0x17, 0x87, 0xe, 0x49}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6d, 0x34, 0xda, 0x57, 0xeb, 0x86, 0x4b, - 0x64, 0xaf, 0xbd, 0xd6, 0x52, 0x69, 0x4f}; - lwmqtt_string_t topic_filter_s7 = {14, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xf5, 0x9d, 0x63, 0xa5, 0x68, 0xb5, 0x53, 0x73, 0xee, 0xd9, 0x1b, 0x5, 0xce, + 0xe1, 0xab, 0x6c, 0x1a, 0xa0, 0x41, 0x24, 0xef, 0x92, 0x70, 0x61, 0xaa, 0x8a}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc3, 0xfe, 0x56, 0x7, 0xd3, 0x9d, 0x31, 0x3f, 0x4a, - 0x4c, 0xd2, 0x6d, 0xa, 0x5a, 0xc3, 0x33, 0xb}; - lwmqtt_string_t topic_filter_s8 = {17, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0}; + lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops1[] = {0xbc, 0x43, 0xc0, 0x99, 0xc0, 0xe6, 0x41, 0xe7, 0x57, 0x53, 0x74, 0x84, 0xbd, 0x5b, 0x14, - 0x42, 0xb0, 0xe4, 0xf7, 0x4f, 0xae, 0x80, 0x88, 0xd5, 0xb3, 0xff, 0xad, 0xe8, 0x22, 0x30}; - uint8_t bytesprops0[] = {0xc1}; - uint8_t bytesprops2[] = {0x99, 0x78, 0xfa, 0xb8, 0xf2, 0x1, 0xc3, 0xbe}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x62, 0x4f, 0x5a, 0x52, 0x64, 0x7, 0xe3, 0xd9, 0xff, 0x75, 0x9c, - 0xf8, 0x44, 0x57, 0x1b, 0x67, 0x92, 0xd7, 0xe9, 0xc8, 0x9d, 0xc1}; - uint8_t bytesprops6[] = {0x75, 0x3a, 0x94, 0x5f, 0xb5, 0x37, 0xc7, 0x1d, - 0x88, 0x13, 0x49, 0x24, 0x39, 0x20, 0xb0, 0xba}; - uint8_t bytesprops5[] = {0xa8, 0xa0, 0xf5, 0x60, 0x3f, 0x3a, 0xd8, 0x47, 0x16, 0x34, 0xf1, 0xb1, 0xed, 0x13}; + uint8_t topic_filter_s9_bytes[] = {0x8e, 0xd2}; + lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x61, 0x24, 0x8c, 0xa2, 0x85, 0x60, 0x86, 0x5c, 0x47, 0x1f, 0x10, 0xbf}; + uint8_t bytesprops1[] = {0x30, 0x64, 0xab, 0xf2, 0x5d, 0xa1, 0x42, 0xa1, 0xd5, 0xa6, 0x57, 0xca, 0x76, + 0x80, 0x93, 0xf0, 0x7d, 0x61, 0x47, 0x47, 0xa1, 0x41, 0xfd, 0xb5, 0xb6, 0x9c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20429}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {30, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15605}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2807}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23153}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops5}, .v = {16, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1621}}, {.prop = (lwmqtt_prop_t)37, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28200}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26260}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16917}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27385, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30493, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22666 [("G\DLE\141c\141\r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\DLEq\227\252\175\246{\157\250\NUL\231",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\175\SO.Id[",SubOptions +// SubscribeRequest 20478 [("\184}2\DC2\bp#\148\f\DC1\208}\194",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\181\209\150\255\240\&5\243\DC2\SO\208ji\180\129&P\178\ENQ?\229W?\192\GS\185\211\166\213\&4",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("p\210\142F\178\242R\233\138\188\253$$r\142\SYN\244\167k\195",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSubscriptionIdentifier -// 11,PropAssignedClientIdentifier "r",PropSubscriptionIdentifier 21,PropMaximumQoS 17,PropSessionExpiryInterval -// 25518,PropSubscriptionIdentifierAvailable 52,PropAuthenticationMethod -// "Vl\175z'\GS\DC3\176\131\238\194\201\247\165\&4\143\240\234\201",PropServerKeepAlive 7849,PropSubscriptionIdentifier -// 31,PropReceiveMaximum 29865,PropMaximumPacketSize 6256,PropRetainAvailable 83,PropRetainAvailable -// 104,PropUserProperty "\ax\198\170\185\135\247;\250\245Fv\186W\CAN\SOH\155\178\150\223\SYN\174\170>{n\138" -// "}\a\nj\GS\191U\238\192\204\&4\213.\238\178j\DEL\255\222\167\190\&7\218\144\US(\SOH",PropContentType -// "p\232-\135\244\&4\220O{F\192\ESC z\166a\213\183\133Z@4\132\155\EOTiy"] +// QoS2}),("\248\196L\195\ESC\ETX\DC3N\135\&3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\198\170\141\229\221[\227KN\143Fw\153\t\163\203\n\181\151\147\170",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\160\253\207yPZ\a\211\172o\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\164s\134^.\223\218\240\197J\148\212",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\240\\\189j\185\226\139}",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("x\172\224\142\143\226\196Z\SYN0\229l\218\175u`\190\250.m\227\222\240\ACK\255\DC2\211W",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\197U\154\166\243\218<\211^f\176\170Y\DC3\162;9^\159\232\181\239\161D\179\&2",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropReasonString +// "3\GS\220\243\DC3\147\SI\142r\SUBo\198\137\235\137t\217\223n\190m",PropTopicAlias 15148] TEST(Subscribe5QCTest, Encode2) { - uint8_t pkt[] = { - 0x82, 0xcc, 0x1, 0x58, 0x8a, 0x91, 0x1, 0xb, 0xb, 0x12, 0x0, 0x1, 0x72, 0xb, 0x15, 0x24, 0x11, 0x11, 0x0, - 0x0, 0x63, 0xae, 0x29, 0x34, 0x15, 0x0, 0x13, 0x56, 0x6c, 0xaf, 0x7a, 0x27, 0x1d, 0x13, 0xb0, 0x83, 0xee, 0xc2, - 0xc9, 0xf7, 0xa5, 0x34, 0x8f, 0xf0, 0xea, 0xc9, 0x13, 0x1e, 0xa9, 0xb, 0x1f, 0x21, 0x74, 0xa9, 0x27, 0x0, 0x0, - 0x18, 0x70, 0x25, 0x53, 0x25, 0x68, 0x26, 0x0, 0x1b, 0x7, 0x78, 0xc6, 0xaa, 0xb9, 0x87, 0xf7, 0x3b, 0xfa, 0xf5, - 0x46, 0x76, 0xba, 0x57, 0x18, 0x1, 0x9b, 0xb2, 0x96, 0xdf, 0x16, 0xae, 0xaa, 0x3e, 0x7b, 0x6e, 0x8a, 0x0, 0x1b, - 0x7d, 0x7, 0xa, 0x6a, 0x1d, 0xbf, 0x55, 0xee, 0xc0, 0xcc, 0x34, 0xd5, 0x2e, 0xee, 0xb2, 0x6a, 0x7f, 0xff, 0xde, - 0xa7, 0xbe, 0x37, 0xda, 0x90, 0x1f, 0x28, 0x1, 0x3, 0x0, 0x1b, 0x70, 0xe8, 0x2d, 0x87, 0xf4, 0x34, 0xdc, 0x4f, - 0x7b, 0x46, 0xc0, 0x1b, 0x20, 0x7a, 0xa6, 0x61, 0xd5, 0xb7, 0x85, 0x5a, 0x40, 0x34, 0x84, 0x9b, 0x4, 0x69, 0x79, - 0x0, 0x6, 0x47, 0x10, 0x8d, 0x63, 0x8d, 0xd, 0x2, 0x0, 0xb, 0x10, 0x71, 0xe3, 0xfc, 0xaf, 0xf6, 0x7b, 0x9d, - 0xfa, 0x0, 0xe7, 0x0, 0x0, 0x6, 0xaf, 0xe, 0x2e, 0x49, 0x64, 0x5b, 0x1, 0x0, 0x14, 0x70, 0xd2, 0x8e, 0x46, - 0xb2, 0xf2, 0x52, 0xe9, 0x8a, 0xbc, 0xfd, 0x24, 0x24, 0x72, 0x8e, 0x16, 0xf4, 0xa7, 0x6b, 0xc3, 0x2}; - - uint8_t buf[217] = {0}; - - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x47, 0x10, 0x8d, 0x63, 0x8d, 0xd}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0xd7, 0x1, 0x4f, 0xfe, 0x1b, 0x1f, 0x0, 0x15, 0x33, 0x1d, 0xdc, 0xf3, 0x13, 0x93, 0xf, 0x8e, + 0x72, 0x1a, 0x6f, 0xc6, 0x89, 0xeb, 0x89, 0x74, 0xd9, 0xdf, 0x6e, 0xbe, 0x6d, 0x23, 0x3b, 0x2c, 0x0, + 0xd, 0xb8, 0x7d, 0x32, 0x12, 0x8, 0x70, 0x23, 0x94, 0xc, 0x11, 0xd0, 0x7d, 0xc2, 0x1, 0x0, 0x1d, + 0xb5, 0xd1, 0x96, 0xff, 0xf0, 0x35, 0xf3, 0x12, 0xe, 0xd0, 0x6a, 0x69, 0xb4, 0x81, 0x26, 0x50, 0xb2, + 0x5, 0x3f, 0xe5, 0x57, 0x3f, 0xc0, 0x1d, 0xb9, 0xd3, 0xa6, 0xd5, 0x34, 0x2, 0x0, 0xa, 0xf8, 0xc4, + 0x4c, 0xc3, 0x1b, 0x3, 0x13, 0x4e, 0x87, 0x33, 0x0, 0x0, 0x15, 0xc6, 0xaa, 0x8d, 0xe5, 0xdd, 0x5b, + 0xe3, 0x4b, 0x4e, 0x8f, 0x46, 0x77, 0x99, 0x9, 0xa3, 0xcb, 0xa, 0xb5, 0x97, 0x93, 0xaa, 0x1, 0x0, + 0xb, 0xa0, 0xfd, 0xcf, 0x79, 0x50, 0x5a, 0x7, 0xd3, 0xac, 0x6f, 0x94, 0x0, 0x0, 0xc, 0xa4, 0x73, + 0x86, 0x5e, 0x2e, 0xdf, 0xda, 0xf0, 0xc5, 0x4a, 0x94, 0xd4, 0x2, 0x0, 0x8, 0xf0, 0x5c, 0xbd, 0x6a, + 0xb9, 0xe2, 0x8b, 0x7d, 0x2, 0x0, 0x1c, 0x78, 0xac, 0xe0, 0x8e, 0x8f, 0xe2, 0xc4, 0x5a, 0x16, 0x30, + 0xe5, 0x6c, 0xda, 0xaf, 0x75, 0x60, 0xbe, 0xfa, 0x2e, 0x6d, 0xe3, 0xde, 0xf0, 0x6, 0xff, 0x12, 0xd3, + 0x57, 0x0, 0x0, 0x1a, 0xc5, 0x55, 0x9a, 0xa6, 0xf3, 0xda, 0x3c, 0xd3, 0x5e, 0x66, 0xb0, 0xaa, 0x59, + 0x13, 0xa2, 0x3b, 0x39, 0x5e, 0x9f, 0xe8, 0xb5, 0xef, 0xa1, 0x44, 0xb3, 0x32, 0x2}; + + uint8_t buf[228] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xb8, 0x7d, 0x32, 0x12, 0x8, 0x70, 0x23, 0x94, 0xc, 0x11, 0xd0, 0x7d, 0xc2}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x10, 0x71, 0xe3, 0xfc, 0xaf, 0xf6, 0x7b, 0x9d, 0xfa, 0x0, 0xe7}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb5, 0xd1, 0x96, 0xff, 0xf0, 0x35, 0xf3, 0x12, 0xe, 0xd0, + 0x6a, 0x69, 0xb4, 0x81, 0x26, 0x50, 0xb2, 0x5, 0x3f, 0xe5, + 0x57, 0x3f, 0xc0, 0x1d, 0xb9, 0xd3, 0xa6, 0xd5, 0x34}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xaf, 0xe, 0x2e, 0x49, 0x64, 0x5b}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf8, 0xc4, 0x4c, 0xc3, 0x1b, 0x3, 0x13, 0x4e, 0x87, 0x33}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x70, 0xd2, 0x8e, 0x46, 0xb2, 0xf2, 0x52, 0xe9, 0x8a, 0xbc, - 0xfd, 0x24, 0x24, 0x72, 0x8e, 0x16, 0xf4, 0xa7, 0x6b, 0xc3}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc6, 0xaa, 0x8d, 0xe5, 0xdd, 0x5b, 0xe3, 0x4b, 0x4e, 0x8f, 0x46, + 0x77, 0x99, 0x9, 0xa3, 0xcb, 0xa, 0xb5, 0x97, 0x93, 0xaa}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x72}; - uint8_t bytesprops1[] = {0x56, 0x6c, 0xaf, 0x7a, 0x27, 0x1d, 0x13, 0xb0, 0x83, 0xee, - 0xc2, 0xc9, 0xf7, 0xa5, 0x34, 0x8f, 0xf0, 0xea, 0xc9}; - uint8_t bytesprops3[] = {0x7d, 0x7, 0xa, 0x6a, 0x1d, 0xbf, 0x55, 0xee, 0xc0, 0xcc, 0x34, 0xd5, 0x2e, 0xee, - 0xb2, 0x6a, 0x7f, 0xff, 0xde, 0xa7, 0xbe, 0x37, 0xda, 0x90, 0x1f, 0x28, 0x1}; - uint8_t bytesprops2[] = {0x7, 0x78, 0xc6, 0xaa, 0xb9, 0x87, 0xf7, 0x3b, 0xfa, 0xf5, 0x46, 0x76, 0xba, 0x57, - 0x18, 0x1, 0x9b, 0xb2, 0x96, 0xdf, 0x16, 0xae, 0xaa, 0x3e, 0x7b, 0x6e, 0x8a}; - uint8_t bytesprops4[] = {0x70, 0xe8, 0x2d, 0x87, 0xf4, 0x34, 0xdc, 0x4f, 0x7b, 0x46, 0xc0, 0x1b, 0x20, 0x7a, - 0xa6, 0x61, 0xd5, 0xb7, 0x85, 0x5a, 0x40, 0x34, 0x84, 0x9b, 0x4, 0x69, 0x79}; + uint8_t topic_filter_s4_bytes[] = {0xa0, 0xfd, 0xcf, 0x79, 0x50, 0x5a, 0x7, 0xd3, 0xac, 0x6f, 0x94}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa4, 0x73, 0x86, 0x5e, 0x2e, 0xdf, 0xda, 0xf0, 0xc5, 0x4a, 0x94, 0xd4}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xf0, 0x5c, 0xbd, 0x6a, 0xb9, 0xe2, 0x8b, 0x7d}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x78, 0xac, 0xe0, 0x8e, 0x8f, 0xe2, 0xc4, 0x5a, 0x16, 0x30, + 0xe5, 0x6c, 0xda, 0xaf, 0x75, 0x60, 0xbe, 0xfa, 0x2e, 0x6d, + 0xe3, 0xde, 0xf0, 0x6, 0xff, 0x12, 0xd3, 0x57}; + lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xc5, 0x55, 0x9a, 0xa6, 0xf3, 0xda, 0x3c, 0xd3, 0x5e, 0x66, 0xb0, 0xaa, 0x59, + 0x13, 0xa2, 0x3b, 0x39, 0x5e, 0x9f, 0xe8, 0xb5, 0xef, 0xa1, 0x44, 0xb3, 0x32}; + lwmqtt_string_t topic_filter_s8 = {26, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x33, 0x1d, 0xdc, 0xf3, 0x13, 0x93, 0xf, 0x8e, 0x72, 0x1a, 0x6f, + 0xc6, 0x89, 0xeb, 0x89, 0x74, 0xd9, 0xdf, 0x6e, 0xbe, 0x6d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25518}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7849}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29865}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6256}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops2}, .v = {27, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15148}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22666, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20478, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7099 [("\131J\165\202",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\r\242#[",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("+",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\165>^\202\145\206\SOH\DC1\152\r\214\128\148\140",SubOptions +// SubscribeRequest 17981 +// [("\236?\165\226{!\241\176\148uM",PropMaximumQoS 1,PropTopicAlias +// 9863,PropResponseTopic "\249O\221\134\STX*\131\148\136\ETB\220\238\213a'\174!\SUB.p",PropServerReference +// "\251){E?}\238y\USJ\132\193D\r\186\173p\174\r\244b\144",PropAssignedClientIdentifier +// "vD\148\RS`\189\228\247]%\236,\186W\NAK\203\198\250mx\172\230H\137\252T\222"] TEST(Subscribe5QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0xa6, 0x1, 0x1b, 0xbb, 0x7a, 0x25, 0x17, 0x17, 0x2b, 0x1c, 0x0, 0x3, 0x95, 0x91, 0x59, 0x8, - 0x0, 0x3, 0x84, 0x5f, 0x8c, 0x1c, 0x0, 0x2, 0xc, 0x7a, 0x21, 0x49, 0x7b, 0x25, 0x9e, 0x28, 0xa4, - 0x23, 0x18, 0x10, 0x12, 0x0, 0x10, 0xd6, 0x88, 0x38, 0xa9, 0x6e, 0xc7, 0xcf, 0x68, 0x86, 0x17, 0xbe, - 0xa, 0x4c, 0xec, 0x4a, 0x14, 0x23, 0x8, 0x9b, 0x2, 0x0, 0x0, 0x68, 0xa8, 0x28, 0x59, 0x17, 0x62, - 0x18, 0x0, 0x0, 0x14, 0x28, 0x8, 0x0, 0x17, 0xa7, 0xfe, 0x53, 0xd6, 0x5a, 0x37, 0xdb, 0xd1, 0x8, - 0xe2, 0x60, 0xb0, 0xcb, 0xc3, 0xaa, 0x4a, 0x51, 0x4d, 0xa2, 0x8b, 0x87, 0xeb, 0x2c, 0x17, 0xc8, 0x19, - 0x68, 0x25, 0xd4, 0x13, 0x26, 0x1e, 0x1c, 0x0, 0x11, 0xe2, 0x42, 0xfa, 0x70, 0xdd, 0x45, 0x89, 0x92, - 0xfe, 0xb3, 0x26, 0xad, 0xf9, 0x4, 0xd5, 0xc2, 0x14, 0x0, 0x4, 0x83, 0x4a, 0xa5, 0xca, 0x2, 0x0, - 0x4, 0xd, 0xf2, 0x23, 0x5b, 0x0, 0x0, 0x1, 0x2b, 0x2, 0x0, 0xe, 0xa5, 0x3e, 0x5e, 0xca, 0x91, - 0xce, 0x1, 0x11, 0x98, 0xd, 0xd6, 0x80, 0x94, 0x8c, 0x0, 0x0, 0x3, 0xf6, 0x32, 0xba, 0x2}; - - uint8_t buf[179] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x83, 0x4a, 0xa5, 0xca}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = { + 0x82, 0xe6, 0x2, 0x46, 0x3d, 0x94, 0x1, 0x17, 0x62, 0x25, 0x89, 0x2, 0x0, 0x0, 0x28, 0x56, 0x1f, 0x0, 0x1, + 0xc5, 0x26, 0x0, 0x2, 0xc7, 0xab, 0x0, 0xd, 0x66, 0x4e, 0x40, 0x32, 0xd2, 0x37, 0x58, 0x5f, 0x84, 0x5d, 0xbf, + 0xbd, 0x65, 0x26, 0x0, 0x5, 0x90, 0xfc, 0x6, 0xfd, 0xc0, 0x0, 0x16, 0x92, 0xfb, 0xe3, 0xf0, 0x30, 0xb0, 0x33, + 0x4d, 0xb5, 0xe9, 0x6e, 0xf6, 0x76, 0x89, 0x9c, 0x3e, 0x21, 0xf1, 0xb0, 0x94, 0x75, 0x4d, 0x24, 0x1, 0x23, 0x26, + 0x87, 0x8, 0x0, 0x14, 0xf9, 0x4f, 0xdd, 0x86, 0x2, 0x2a, 0x83, 0x94, 0x88, 0x17, 0xdc, 0xee, 0xd5, 0x61, 0x27, + 0xae, 0x21, 0x1a, 0x2e, 0x70, 0x1c, 0x0, 0x16, 0xfb, 0x29, 0x7b, 0x45, 0x3f, 0x7d, 0xee, 0x79, 0x1f, 0x4a, 0x84, + 0xc1, 0x44, 0xd, 0xba, 0xad, 0x70, 0xae, 0xd, 0xf4, 0x62, 0x90, 0x12, 0x0, 0x1b, 0x76, 0x44, 0x94, 0x1e, 0x60, + 0xbd, 0xe4, 0xf7, 0x5d, 0x25, 0xec, 0x2c, 0xba, 0x57, 0x15, 0xcb, 0xc6, 0xfa, 0x6d, 0x78, 0xac, 0xe6, 0x48, 0x89, + 0xfc, 0x54, 0xde, 0x0, 0x1e, 0xec, 0x3f, 0xa5, 0xe2, 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 0xf, 0x27, 0xef, 0xd6, 0xb7, 0xaf, 0xa, 0xf4, 0x50, 0x5, 0x7f, 0x91, 0x3, 0xb4, 0x2}; + + uint8_t buf[371] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xec, 0x3f, 0xa5, 0xe2, 0x7b, 0x3c, 0x79, 0x25, 0xdf, 0x2e, + 0x1d, 0x34, 0x67, 0x96, 0xc7, 0x31, 0x94, 0xf1, 0x10, 0x52, + 0x8a, 0x9e, 0xd0, 0x85, 0xf6, 0xc, 0x38, 0xf2, 0x1f, 0xe8}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd, 0xf2, 0x23, 0x5b}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa9, 0x89, 0xf8, 0x9c, 0x98, 0x1a, 0x26, 0x7, 0x84, 0x23, + 0x96, 0x8f, 0xf5, 0x60, 0x7b, 0xa9, 0x21, 0x61, 0xca, 0xa6, + 0x4f, 0x21, 0xd, 0x6e, 0x5c, 0xd5, 0xc3, 0x2d, 0x41, 0x55}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2b}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5b, 0x7, 0xe5, 0xce, 0xdf, 0x13, 0x5c, 0x83, 0x33, 0xc1, 0x27, 0x18, + 0xf0, 0x95, 0x1d, 0x8d, 0x49, 0x2b, 0x82, 0xdd, 0xe5, 0xe4, 0x41}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa5, 0x3e, 0x5e, 0xca, 0x91, 0xce, 0x1, 0x11, 0x98, 0xd, 0xd6, 0x80, 0x94, 0x8c}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xb7, 0xeb, 0x84, 0x34, 0x2b, 0x5a, 0xf1, 0xf7}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xf6, 0x32, 0xba}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xaf, 0x2d, 0x84, 0x4e, 0xe2, 0xb3, 0xc7, + 0x4d, 0x6b, 0x1e, 0x77, 0x6b, 0xbc, 0x94}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x95, 0x91, 0x59}; - uint8_t bytesprops1[] = {0x84, 0x5f, 0x8c}; - uint8_t bytesprops2[] = {0xc, 0x7a}; - uint8_t bytesprops3[] = {0xd6, 0x88, 0x38, 0xa9, 0x6e, 0xc7, 0xcf, 0x68, - 0x86, 0x17, 0xbe, 0xa, 0x4c, 0xec, 0x4a, 0x14}; - uint8_t bytesprops4[] = {0xa7, 0xfe, 0x53, 0xd6, 0x5a, 0x37, 0xdb, 0xd1, 0x8, 0xe2, 0x60, 0xb0, - 0xcb, 0xc3, 0xaa, 0x4a, 0x51, 0x4d, 0xa2, 0x8b, 0x87, 0xeb, 0x2c}; - uint8_t bytesprops5[] = {0xe2, 0x42, 0xfa, 0x70, 0xdd, 0x45, 0x89, 0x92, 0xfe, - 0xb3, 0x26, 0xad, 0xf9, 0x4, 0xd5, 0xc2, 0x14}; + uint8_t topic_filter_s5_bytes[] = {0x13, 0xe5, 0x74, 0x5a, 0x77, 0xc6, 0x33, + 0x21, 0x64, 0x2b, 0xc6, 0x55, 0x85, 0xa2}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x1f, 0x33, 0x1f, 0xeb, 0xbc, 0xab, 0xe1, 0x9b, + 0xd6, 0x9b, 0xe8, 0x8d, 0x71, 0x88, 0x7e}; + lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x19, 0x5b, 0xbc, 0x9f, 0xf4, 0x78, 0xde, 0xaa, 0x15, 0x23, + 0x10, 0x64, 0x6c, 0x3a, 0xda, 0xfd, 0x8b, 0xc4, 0x1d, 0xa8}; + lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xf, 0x69, 0x61, 0xff, 0x89, 0x3d, 0xeb, 0xc}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xf, 0x27, 0xef, 0xd6, 0xb7, 0xaf, 0xa, 0xf4, 0x50, 0x5, 0x7f, 0x91, 0x3, 0xb4}; + lwmqtt_string_t topic_filter_s9 = {14, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0xc5}; + uint8_t bytesprops2[] = {0x66, 0x4e, 0x40, 0x32, 0xd2, 0x37, 0x58, 0x5f, 0x84, 0x5d, 0xbf, 0xbd, 0x65}; + uint8_t bytesprops1[] = {0xc7, 0xab}; + uint8_t bytesprops4[] = {0x92, 0xfb, 0xe3, 0xf0, 0x30, 0xb0, 0x33, 0x4d, 0xb5, 0xe9, 0x6e, + 0xf6, 0x76, 0x89, 0x9c, 0x3e, 0x21, 0xf1, 0xb0, 0x94, 0x75, 0x4d}; + uint8_t bytesprops3[] = {0x90, 0xfc, 0x6, 0xfd, 0xc0}; + uint8_t bytesprops5[] = {0xf9, 0x4f, 0xdd, 0x86, 0x2, 0x2a, 0x83, 0x94, 0x88, 0x17, + 0xdc, 0xee, 0xd5, 0x61, 0x27, 0xae, 0x21, 0x1a, 0x2e, 0x70}; + uint8_t bytesprops6[] = {0xfb, 0x29, 0x7b, 0x45, 0x3f, 0x7d, 0xee, 0x79, 0x1f, 0x4a, 0x84, + 0xc1, 0x44, 0xd, 0xba, 0xad, 0x70, 0xae, 0xd, 0xf4, 0x62, 0x90}; + uint8_t bytesprops7[] = {0x76, 0x44, 0x94, 0x1e, 0x60, 0xbd, 0xe4, 0xf7, 0x5d, 0x25, 0xec, 0x2c, 0xba, 0x57, + 0x15, 0xcb, 0xc6, 0xfa, 0x6d, 0x78, 0xac, 0xe6, 0x48, 0x89, 0xfc, 0x54, 0xde}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18811}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6160}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2203}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26792}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5160}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9758}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10326}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops1}, .v = {13, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops3}, .v = {22, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9863}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7099, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17981, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 835 [("\160\159FO\167\\r\224\141\226\228-\226\247\r@\206\&1w",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\GS9\DLE\253:\192\SOH/M#\196\191O\159f",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\NULT\227e\232\&8\141\133n#\DLE.\193\163\199\173\&0\184\&9\231\190\253\DEL\144\SUB\130\137\210",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropResponseTopic "\\\229C",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRetainAvailable 96,PropMessageExpiryInterval -// 7158,PropAuthenticationData -// "\ETB^\173{f\146\"\152oK\166\235\161\159\v\182M\rqRoh\154\181\226O\EM^\245",PropPayloadFormatIndicator -// 223,PropSubscriptionIdentifier 12,PropMaximumQoS 231,PropTopicAlias 8619,PropMessageExpiryInterval -// 30952,PropRequestResponseInformation 197,PropWildcardSubscriptionAvailable 255] +// SubscribeRequest 2713 [("\v\149\153&\227@\158",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\137\178V\240lc\224\b\175']\235\NUL$\243G\224_*\254",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("9\210TgR\152e\221\141\200\213\141\198U\DC3V5\226\221\190M\169",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAuthenticationData +// "\132\&6vF\NUL\217\DEL^\246\DC3m5!\212\238\ESC\239[f",PropMaximumQoS 92,PropRequestResponseInformation +// 33,PropRequestProblemInformation 243,PropTopicAlias 1722,PropAssignedClientIdentifier +// "Q%\151\&1\226Z\147\153\247b",PropCorrelationData "\163",PropRequestProblemInformation 24,PropResponseInformation +// "\213\215\151\SOH",PropAuthenticationMethod "6\254t\b\241\&3\208"] TEST(Subscribe5QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x4d, 0x69, 0x24, 0x39, 0x25, 0x60, 0x2, 0x0, 0x0, 0x1b, 0xf6, 0x16, 0x0, 0x1d, 0x17, - 0x5e, 0xad, 0x7b, 0x66, 0x92, 0x22, 0x98, 0x6f, 0x4b, 0xa6, 0xeb, 0xa1, 0x9f, 0xb, 0xb6, 0x4d, - 0xd, 0x71, 0x52, 0x6f, 0x68, 0x9a, 0xb5, 0xe2, 0x4f, 0x19, 0x5e, 0xf5, 0x1, 0xdf, 0xb, 0xc, - 0x24, 0xe7, 0x23, 0x21, 0xab, 0x2, 0x0, 0x0, 0x78, 0xe8, 0x19, 0xc5, 0x28, 0xff, 0x0, 0xe, - 0x67, 0xb8, 0xaf, 0xa9, 0x57, 0xcf, 0x62, 0x34, 0x4, 0x76, 0x7c, 0x3e, 0xe5, 0x43, 0x1}; - - uint8_t buf[89] = {0}; - - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x67, 0xb8, 0xaf, 0xa9, 0x57, 0xcf, 0x62, 0x34, 0x4, 0x76, 0x7c, 0x3e, 0xe5, 0x43}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x80, 0x1, 0xa, 0x99, 0x43, 0x16, 0x0, 0x13, 0x84, 0x36, 0x76, 0x46, 0x0, 0xd9, 0x7f, 0x5e, + 0xf6, 0x13, 0x6d, 0x35, 0x21, 0xd4, 0xee, 0x1b, 0xef, 0x5b, 0x66, 0x24, 0x5c, 0x19, 0x21, 0x17, 0xf3, + 0x23, 0x6, 0xba, 0x12, 0x0, 0xa, 0x51, 0x25, 0x97, 0x31, 0xe2, 0x5a, 0x93, 0x99, 0xf7, 0x62, 0x9, + 0x0, 0x1, 0xa3, 0x17, 0x18, 0x1a, 0x0, 0x4, 0xd5, 0xd7, 0x97, 0x1, 0x15, 0x0, 0x7, 0x36, 0xfe, + 0x74, 0x8, 0xf1, 0x33, 0xd0, 0x0, 0x7, 0xb, 0x95, 0x99, 0x26, 0xe3, 0x40, 0x9e, 0x2, 0x0, 0x14, + 0x89, 0xb2, 0x56, 0xf0, 0x6c, 0x63, 0xe0, 0x8, 0xaf, 0x27, 0x5d, 0xeb, 0x0, 0x24, 0xf3, 0x47, 0xe0, + 0x5f, 0x2a, 0xfe, 0x0, 0x0, 0x16, 0x39, 0xd2, 0x54, 0x67, 0x52, 0x98, 0x65, 0xdd, 0x8d, 0xc8, 0xd5, + 0x8d, 0xc6, 0x55, 0x13, 0x56, 0x35, 0xe2, 0xdd, 0xbe, 0x4d, 0xa9, 0x1}; + + uint8_t buf[141] = {0}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xb, 0x95, 0x99, 0x26, 0xe3, 0x40, 0x9e}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x17, 0x5e, 0xad, 0x7b, 0x66, 0x92, 0x22, 0x98, 0x6f, 0x4b, 0xa6, 0xeb, 0xa1, 0x9f, 0xb, - 0xb6, 0x4d, 0xd, 0x71, 0x52, 0x6f, 0x68, 0x9a, 0xb5, 0xe2, 0x4f, 0x19, 0x5e, 0xf5}; + uint8_t topic_filter_s1_bytes[] = {0x89, 0xb2, 0x56, 0xf0, 0x6c, 0x63, 0xe0, 0x8, 0xaf, 0x27, + 0x5d, 0xeb, 0x0, 0x24, 0xf3, 0x47, 0xe0, 0x5f, 0x2a, 0xfe}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x39, 0xd2, 0x54, 0x67, 0x52, 0x98, 0x65, 0xdd, 0x8d, 0xc8, 0xd5, + 0x8d, 0xc6, 0x55, 0x13, 0x56, 0x35, 0xe2, 0xdd, 0xbe, 0x4d, 0xa9}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x84, 0x36, 0x76, 0x46, 0x0, 0xd9, 0x7f, 0x5e, 0xf6, 0x13, + 0x6d, 0x35, 0x21, 0xd4, 0xee, 0x1b, 0xef, 0x5b, 0x66}; + uint8_t bytesprops1[] = {0x51, 0x25, 0x97, 0x31, 0xe2, 0x5a, 0x93, 0x99, 0xf7, 0x62}; + uint8_t bytesprops2[] = {0xa3}; + uint8_t bytesprops3[] = {0xd5, 0xd7, 0x97, 0x1}; + uint8_t bytesprops4[] = {0x36, 0xfe, 0x74, 0x8, 0xf1, 0x33, 0xd0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7158}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8619}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30952}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1722}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops4}}}, }; lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26916, 1, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2713, 3, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23203 [("\130\206\197\ETX(;3ie\228\139L\185\152\193\203\DC4\200\v}\b",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("U\v,\200o\aH\192\130\227\236\180=2\240\253\167!\139t\f\173-\140M",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\169\159D\FS\199m]J\SOHG\136Y7r7\160\252\231\185/\172\205N.\193\&9V",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\182\132\145J\160\&3\216-f\DC4X\142\188",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("X\DEL\227P \242\&23\175\NULVC\243jl\150\148B\250m",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\ESC\229&\185`\246\NULRL\168\216C;\165\167",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\t8\146\169\253\156^\157\EM|\141~t\205l\160\ETX\255\137\142v\188\"\DC22",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("U(!\US\174\250\156Z\ESC",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\US\219\141B\210\224Z\240",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\128\181\150r\134\164",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\146v\DLEM\165!\205`q\245ah.\235f\245#O\214c;\134\203\155\b",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty "O\148)\234\f\SYNf\227\130\194&" -// "\210\168\135\205\202\132#\EOT",PropWillDelayInterval 10640,PropTopicAliasMaximum 24111,PropSubscriptionIdentifier -// 23,PropServerKeepAlive 21621,PropServerReference -// "\248\255\t\NUL\155]\131g8?\216\251\228\199\250yP?\182\133\240i^\234p",PropSharedSubscriptionAvailable -// 247,PropServerKeepAlive 17592,PropAuthenticationMethod -// "\247\222\246\251\&58(\a\229E\185XEx\128\197O\131\FS)\192\253-!\174\SOH\249",PropMaximumPacketSize -// 10655,PropRequestProblemInformation 61,PropCorrelationData -// "\150\170\SOHf\r\176\208\ENQ\205\240\180\a\191h\GS\196<\204\145\US\168\231\210F\149\176\170\&1",PropSessionExpiryInterval -// 16529,PropAuthenticationData -// "\209\159i\191)*\172J\168\&9\232d\239\186\224\133?\242/\174\247%\188\238\US\175\131\181\194",PropCorrelationData -// "yn\222<_3\146a\144&n\204\DC4O\237\205C\CAN\240*\186\235&\225I\188",PropWillDelayInterval 11904,PropContentType -// "\145\150\246\205X\225f\146sU\182\134\155\164~\172Y\182\251\226,>\252\200\177\SO$\136M<",PropAuthenticationData -// "\240@\181\187\&7G",PropPayloadFormatIndicator 120,PropMaximumQoS 55,PropCorrelationData -// "*}/]=\f\GS\147t\133\133\246\184\250\246\NUL\131x\240\207\151\149~6"] +// SubscribeRequest 7741 [("7\233y\244\229-\244\179\172\&6\164H",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(")\139\210\DC4\162\189qQ\DC4\141\253\&8",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] +// [PropAuthenticationMethod "\227\ACK\144\181\222",PropTopicAliasMaximum 7962,PropResponseInformation +// "\137\132",PropMessageExpiryInterval 26117,PropMessageExpiryInterval 22772,PropResponseTopic +// "\166\249/hZ\139\DC4",PropUserProperty "i\a\140}\167\249k" +// "\196H\133j\236\STXd)\ESC\201{\207",PropAssignedClientIdentifier "H\196\239",PropReasonString "\NUL\DEL\176\252 +// \177\231@u-\144\NAK\220TiQ\128\144",PropSubscriptionIdentifierAvailable 188,PropAssignedClientIdentifier +// "\DC3ht\222\180\182\154\240\186J\135t\188=\SYN\212'\US:S\193h\ETX",PropServerKeepAlive +// 12221,PropMessageExpiryInterval 1211] TEST(Subscribe5QCTest, Encode6) { - uint8_t pkt[] = { - 0x82, 0x81, 0x4, 0x5a, 0xa3, 0x9a, 0x2, 0x26, 0x0, 0xb, 0x4f, 0x94, 0x29, 0xea, 0xc, 0x16, 0x66, 0xe3, 0x82, - 0xc2, 0x26, 0x0, 0x8, 0xd2, 0xa8, 0x87, 0xcd, 0xca, 0x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0x43, 0xf3, 0x6a, 0x6c, 0x96, 0x94, 0x42, 0xfa, 0x6d, 0x0, 0x0, 0xf, 0x1b, 0xe5, 0x26, 0xb9, 0x60, 0xf6, - 0x0, 0x52, 0x4c, 0xa8, 0xd8, 0x43, 0x3b, 0xa5, 0xa7, 0x2, 0x0, 0x19, 0x9, 0x38, 0x92, 0xa9, 0xfd, 0x9c, 0x5e, - 0x9d, 0x19, 0x7c, 0x8d, 0x7e, 0x74, 0xcd, 0x6c, 0xa0, 0x3, 0xff, 0x89, 0x8e, 0x76, 0xbc, 0x22, 0x12, 0x32, 0x1, - 0x0, 0x9, 0x55, 0x28, 0x21, 0x1f, 0xae, 0xfa, 0x9c, 0x5a, 0x1b, 0x2, 0x0, 0x8, 0x1f, 0xdb, 0x8d, 0x42, 0xd2, - 0xe0, 0x5a, 0xf0, 0x2, 0x0, 0x6, 0x80, 0xb5, 0x96, 0x72, 0x86, 0xa4, 0x1, 0x0, 0x19, 0x92, 0x76, 0x10, 0x4d, - 0xa5, 0x21, 0xcd, 0x60, 0x71, 0xf5, 0x61, 0x68, 0x2e, 0xeb, 0x66, 0xf5, 0x23, 0x4f, 0xd6, 0x63, 0x3b, 0x86, 0xcb, - 0x9b, 0x8, 0x1}; - - uint8_t buf[526] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x82, 0xce, 0xc5, 0x3, 0x28, 0x3b, 0x33, 0x69, 0x65, 0xe4, 0x8b, - 0x4c, 0xb9, 0x98, 0xc1, 0xcb, 0x14, 0xc8, 0xb, 0x7d, 0x8}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x9c, 0x1, 0x1e, 0x3d, 0x7b, 0x15, 0x0, 0x5, 0xe3, 0x6, 0x90, 0xb5, 0xde, 0x22, 0x1f, + 0x1a, 0x1a, 0x0, 0x2, 0x89, 0x84, 0x2, 0x0, 0x0, 0x66, 0x5, 0x2, 0x0, 0x0, 0x58, 0xf4, + 0x8, 0x0, 0x7, 0xa6, 0xf9, 0x2f, 0x68, 0x5a, 0x8b, 0x14, 0x26, 0x0, 0x7, 0x69, 0x7, 0x8c, + 0x7d, 0xa7, 0xf9, 0x6b, 0x0, 0xc, 0xc4, 0x48, 0x85, 0x6a, 0xec, 0x2, 0x64, 0x29, 0x1b, 0xc9, + 0x7b, 0xcf, 0x12, 0x0, 0x3, 0x48, 0xc4, 0xef, 0x1f, 0x0, 0x12, 0x0, 0x7f, 0xb0, 0xfc, 0x20, + 0xb1, 0xe7, 0x40, 0x75, 0x2d, 0x90, 0x15, 0xdc, 0x54, 0x69, 0x51, 0x80, 0x90, 0x29, 0xbc, 0x12, + 0x0, 0x17, 0x13, 0x68, 0x74, 0xde, 0xb4, 0xb6, 0x9a, 0xf0, 0xba, 0x4a, 0x87, 0x74, 0xbc, 0x3d, + 0x16, 0xd4, 0x27, 0x1f, 0x3a, 0x53, 0xc1, 0x68, 0x3, 0x13, 0x2f, 0xbd, 0x2, 0x0, 0x0, 0x4, + 0xbb, 0x0, 0xc, 0x37, 0xe9, 0x79, 0xf4, 0xe5, 0x2d, 0xf4, 0xb3, 0xac, 0x36, 0xa4, 0x48, 0x1, + 0x0, 0xc, 0x29, 0x8b, 0xd2, 0x14, 0xa2, 0xbd, 0x71, 0x51, 0x14, 0x8d, 0xfd, 0x38, 0x1}; + + uint8_t buf[169] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x37, 0xe9, 0x79, 0xf4, 0xe5, 0x2d, 0xf4, 0xb3, 0xac, 0x36, 0xa4, 0x48}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x55, 0xb, 0x2c, 0xc8, 0x6f, 0x7, 0x48, 0xc0, 0x82, 0xe3, 0xec, 0xb4, 0x3d, - 0x32, 0xf0, 0xfd, 0xa7, 0x21, 0x8b, 0x74, 0xc, 0xad, 0x2d, 0x8c, 0x4d}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x29, 0x8b, 0xd2, 0x14, 0xa2, 0xbd, 0x71, 0x51, 0x14, 0x8d, 0xfd, 0x38}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa9, 0x9f, 0x44, 0x1c, 0xc7, 0x6d, 0x5d, 0x4a, 0x1, 0x47, 0x88, 0x59, 0x37, 0x72, - 0x37, 0xa0, 0xfc, 0xe7, 0xb9, 0x2f, 0xac, 0xcd, 0x4e, 0x2e, 0xc1, 0x39, 0x56}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb6, 0x84, 0x91, 0x4a, 0xa0, 0x33, 0xd8, 0x2d, 0x66, 0x14, 0x58, 0x8e, 0xbc}; - lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x58, 0x7f, 0xe3, 0x50, 0x20, 0xf2, 0x32, 0x33, 0xaf, 0x0, - 0x56, 0x43, 0xf3, 0x6a, 0x6c, 0x96, 0x94, 0x42, 0xfa, 0x6d}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1b, 0xe5, 0x26, 0xb9, 0x60, 0xf6, 0x0, 0x52, - 0x4c, 0xa8, 0xd8, 0x43, 0x3b, 0xa5, 0xa7}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x9, 0x38, 0x92, 0xa9, 0xfd, 0x9c, 0x5e, 0x9d, 0x19, 0x7c, 0x8d, 0x7e, 0x74, - 0xcd, 0x6c, 0xa0, 0x3, 0xff, 0x89, 0x8e, 0x76, 0xbc, 0x22, 0x12, 0x32}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x55, 0x28, 0x21, 0x1f, 0xae, 0xfa, 0x9c, 0x5a, 0x1b}; - lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x1f, 0xdb, 0x8d, 0x42, 0xd2, 0xe0, 0x5a, 0xf0}; - lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x80, 0xb5, 0x96, 0x72, 0x86, 0xa4}; - lwmqtt_string_t topic_filter_s9 = {6, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x92, 0x76, 0x10, 0x4d, 0xa5, 0x21, 0xcd, 0x60, 0x71, 0xf5, 0x61, 0x68, 0x2e, - 0xeb, 0x66, 0xf5, 0x23, 0x4f, 0xd6, 0x63, 0x3b, 0x86, 0xcb, 0x9b, 0x8}; - lwmqtt_string_t topic_filter_s10 = {25, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops1[] = {0xd2, 0xa8, 0x87, 0xcd, 0xca, 0x84, 0x23, 0x4}; - uint8_t bytesprops0[] = {0x4f, 0x94, 0x29, 0xea, 0xc, 0x16, 0x66, 0xe3, 0x82, 0xc2, 0x26}; - uint8_t bytesprops2[] = {0xf8, 0xff, 0x9, 0x0, 0x9b, 0x5d, 0x83, 0x67, 0x38, 0x3f, 0xd8, 0xfb, 0xe4, - 0xc7, 0xfa, 0x79, 0x50, 0x3f, 0xb6, 0x85, 0xf0, 0x69, 0x5e, 0xea, 0x70}; - uint8_t bytesprops3[] = {0xf7, 0xde, 0xf6, 0xfb, 0x35, 0x38, 0x28, 0x7, 0xe5, 0x45, 0xb9, 0x58, 0x45, 0x78, - 0x80, 0xc5, 0x4f, 0x83, 0x1c, 0x29, 0xc0, 0xfd, 0x2d, 0x21, 0xae, 0x1, 0xf9}; - uint8_t bytesprops4[] = {0x96, 0xaa, 0x1, 0x66, 0xd, 0xb0, 0xd0, 0x5, 0xcd, 0xf0, 0xb4, 0x7, 0xbf, 0x68, - 0x1d, 0xc4, 0x3c, 0xcc, 0x91, 0x1f, 0xa8, 0xe7, 0xd2, 0x46, 0x95, 0xb0, 0xaa, 0x31}; - uint8_t bytesprops5[] = {0xd1, 0x9f, 0x69, 0xbf, 0x29, 0x2a, 0xac, 0x4a, 0xa8, 0x39, 0xe8, 0x64, 0xef, 0xba, 0xe0, - 0x85, 0x3f, 0xf2, 0x2f, 0xae, 0xf7, 0x25, 0xbc, 0xee, 0x1f, 0xaf, 0x83, 0xb5, 0xc2}; - uint8_t bytesprops6[] = {0x79, 0x6e, 0xde, 0x3c, 0x5f, 0x33, 0x92, 0x61, 0x90, 0x26, 0x6e, 0xcc, 0x14, - 0x4f, 0xed, 0xcd, 0x43, 0x18, 0xf0, 0x2a, 0xba, 0xeb, 0x26, 0xe1, 0x49, 0xbc}; - uint8_t bytesprops7[] = {0x91, 0x96, 0xf6, 0xcd, 0x58, 0xe1, 0x66, 0x92, 0x73, 0x55, 0xb6, 0x86, 0x9b, 0xa4, 0x7e, - 0xac, 0x59, 0xb6, 0xfb, 0xe2, 0x2c, 0x3e, 0xfc, 0xc8, 0xb1, 0xe, 0x24, 0x88, 0x4d, 0x3c}; - uint8_t bytesprops8[] = {0xf0, 0x40, 0xb5, 0xbb, 0x37, 0x47}; - uint8_t bytesprops9[] = {0x2a, 0x7d, 0x2f, 0x5d, 0x3d, 0xc, 0x1d, 0x93, 0x74, 0x85, 0x85, 0xf6, - 0xb8, 0xfa, 0xf6, 0x0, 0x83, 0x78, 0xf0, 0xcf, 0x97, 0x95, 0x7e, 0x36}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xe3, 0x6, 0x90, 0xb5, 0xde}; + uint8_t bytesprops1[] = {0x89, 0x84}; + uint8_t bytesprops2[] = {0xa6, 0xf9, 0x2f, 0x68, 0x5a, 0x8b, 0x14}; + uint8_t bytesprops4[] = {0xc4, 0x48, 0x85, 0x6a, 0xec, 0x2, 0x64, 0x29, 0x1b, 0xc9, 0x7b, 0xcf}; + uint8_t bytesprops3[] = {0x69, 0x7, 0x8c, 0x7d, 0xa7, 0xf9, 0x6b}; + uint8_t bytesprops5[] = {0x48, 0xc4, 0xef}; + uint8_t bytesprops6[] = {0x0, 0x7f, 0xb0, 0xfc, 0x20, 0xb1, 0xe7, 0x40, 0x75, + 0x2d, 0x90, 0x15, 0xdc, 0x54, 0x69, 0x51, 0x80, 0x90}; + uint8_t bytesprops7[] = {0x13, 0x68, 0x74, 0xde, 0xb4, 0xb6, 0x9a, 0xf0, 0xba, 0x4a, 0x87, 0x74, + 0xbc, 0x3d, 0x16, 0xd4, 0x27, 0x1f, 0x3a, 0x53, 0xc1, 0x68, 0x3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10640}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24111}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21621}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17592}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10655}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16529}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11904}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7962}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26117}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22772}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {12, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12221}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1211}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23203, 11, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7741, 2, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 13111 [("\222\SYN24:\156\202\f\132\ETX\186\240",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\v\bAF\245\&5\231\181\211\&88\180\244\224q\245\&2\137||\146\&2\ESC\186p`",SubOptions {_retainHandling = +// SubscribeRequest 11149 +// [("^\226\251\181\&2\156|t\151S\169\252\146\ETX\GS\172S\169\EOT\142\201\173\164=\170a",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("z-Q\ETX\250}\168H\222\137\DC4\"\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\br\NUL\ENQ]\221\ETXkL\190o\238.#\227\230\EM\169wd",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\189\224\230\&0x$\EOTbXn\EM)\200\184\154ZeB\a\136Q+\233\158B",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\r\182,I",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("G\130\251\147\twO",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\188",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\222\RS\248\196\163\204P",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\160hI\180~R7W\238",SubOptions {_retainHandling = SendOnSubscribe, +// QoS1}),("\225W3k!\151\245\228>\205\198\132\168,\142",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\FS\245\145\RS\166*\SOH\163\232\246[\204\144\192O\181\160",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\174\215\218\172V{\162\237\153\169\144\SO\STXM\190\n\135U\180\173\SYN\244\&5\227$\154\ACK\194\249\249",SubOptions +// QoS0}),("\236\214\206\181\DC2\167\181k\255c\150C&X`R\250\150\SI\184G\241x\151\196\143R\144\210w",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropMessageExpiryInterval 6824,PropServerReference "\205{\201\150P\202\142e\f6#5\154",PropMessageExpiryInterval -// 4252,PropSubscriptionIdentifier 22,PropMessageExpiryInterval 4271,PropAssignedClientIdentifier -// "\216\135\ETX/\136\138q_\222?\STX\153\142t5\241\162\195M\162\171\&6N\235o3\247[?",PropRetainAvailable -// 141,PropTopicAliasMaximum 15144,PropSharedSubscriptionAvailable 59,PropServerKeepAlive 26100,PropContentType -// "\176^H\181tT\167\&0\135\186?",PropSubscriptionIdentifier 21,PropPayloadFormatIndicator 171,PropCorrelationData -// "V\242t\188@\DC3\241\212\NUL",PropTopicAliasMaximum 18065,PropSharedSubscriptionAvailable 15] +// [PropAuthenticationData "^-u\FS\NAK\ACKO\170z\169\219\182\154\238\DC2\NAKB\134\158\v/\DC123\242t",PropServerReference +// "\DEL]\197\217\158)\RSC50\154\255\214E]\NAK\190\b\187f\217_\237\ACK\152*",PropSubscriptionIdentifierAvailable +// 78,PropTopicAlias 20242,PropReasonString "$\153K)mq\t\173>\194\168!\177=\GS\CAN",PropContentType +// "\184\217\179)7\168$~K\176'\205\159!\247\229\ACK\167F\ESC\223s\160",PropPayloadFormatIndicator +// 199,PropServerReference "\164",PropCorrelationData "+\229w^\235\r\172\245q\202\202\219b\151\155M\176?\224"] TEST(Subscribe5QCTest, Encode7) { uint8_t pkt[] = { - 0x82, 0xac, 0x2, 0x33, 0x37, 0x6e, 0x2, 0x0, 0x0, 0x1a, 0xa8, 0x1c, 0x0, 0xd, 0xcd, 0x7b, 0xc9, 0x96, 0x50, - 0xca, 0x8e, 0x65, 0xc, 0x36, 0x23, 0x35, 0x9a, 0x2, 0x0, 0x0, 0x10, 0x9c, 0xb, 0x16, 0x2, 0x0, 0x0, 0x10, - 0xaf, 0x12, 0x0, 0x1d, 0xd8, 0x87, 0x3, 0x2f, 0x88, 0x8a, 0x71, 0x5f, 0xde, 0x3f, 0x2, 0x99, 0x8e, 0x74, 0x35, - 0xf1, 0xa2, 0xc3, 0x4d, 0xa2, 0xab, 0x36, 0x4e, 0xeb, 0x6f, 0x33, 0xf7, 0x5b, 0x3f, 0x25, 0x8d, 0x22, 0x3b, 0x28, - 0x2a, 0x3b, 0x13, 0x65, 0xf4, 0x3, 0x0, 0xb, 0xb0, 0x5e, 0x48, 0xb5, 0x74, 0x54, 0xa7, 0x30, 0x87, 0xba, 0x3f, - 0xb, 0x15, 0x1, 0xab, 0x9, 0x0, 0x9, 0x56, 0xf2, 0x74, 0xbc, 0x40, 0x13, 0xf1, 0xd4, 0x0, 0x22, 0x46, 0x91, - 0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- uint8_t buf[313] = {0}; - - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xde, 0x16, 0x32, 0x34, 0x3a, 0x9c, 0xca, 0xc, 0x84, 0x3, 0xba, 0xf0}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + 0x82, 0xf0, 0x1, 0x2b, 0x8d, 0x88, 0x1, 0x16, 0x0, 0x1a, 0x5e, 0x2d, 0x75, 0x1c, 0x15, 0x6, 0x4f, 0xaa, 0x7a, + 0xa9, 0xdb, 0xb6, 0x9a, 0xee, 0x12, 0x15, 0x42, 0x86, 0x9e, 0xb, 0x2f, 0x11, 0x32, 0x33, 0xf2, 0x74, 0x1c, 0x0, + 0x1a, 0x7f, 0x5d, 0xc5, 0xd9, 0x9e, 0x29, 0x1e, 0x43, 0x35, 0x30, 0x9a, 0xff, 0xd6, 0x45, 0x5d, 0x15, 0xbe, 0x8, + 0xbb, 0x66, 0xd9, 0x5f, 0xed, 0x6, 0x98, 0x2a, 0x29, 0x4e, 0x23, 0x4f, 0x12, 0x1f, 0x0, 0x10, 0x24, 0x99, 0x4b, + 0x29, 0x6d, 0x71, 0x9, 0xad, 0x3e, 0xc2, 0xa8, 0x21, 0xb1, 0x3d, 0x1d, 0x18, 0x3, 0x0, 0x17, 0xb8, 0xd9, 0xb3, + 0x29, 0x37, 0xa8, 0x24, 0x7e, 0x4b, 0xb0, 0x27, 0xcd, 0x9f, 0x21, 0xf7, 0xe5, 0x6, 0xa7, 0x46, 0x1b, 0xdf, 0x73, + 0xa0, 0x1, 0xc7, 0x1c, 0x0, 0x1, 0xa4, 0x9, 0x0, 0x13, 0x2b, 0xe5, 0x77, 0x5e, 0xeb, 0xd, 0xac, 0xf5, 0x71, + 0xca, 0xca, 0xdb, 0x62, 0x97, 0x9b, 0x4d, 0xb0, 0x3f, 0xe0, 0x0, 0x1a, 0x5e, 0xe2, 0xfb, 0xb5, 0x32, 0x9c, 0x7c, + 0x74, 0x97, 0x53, 0xa9, 0xfc, 0x92, 0x3, 0x1d, 0xac, 0x53, 0xa9, 0x4, 0x8e, 0xc9, 0xad, 0xa4, 0x3d, 0xaa, 0x61, + 0x1, 0x0, 0xf, 0xe1, 0x57, 0x33, 0x6b, 0x21, 0x97, 0xf5, 0xe4, 0x3e, 0xcd, 0xc6, 0x84, 0xa8, 0x2c, 0x8e, 0x0, + 0x0, 0x11, 0x1c, 0xf5, 0x91, 0x1e, 0xa6, 0x2a, 0x1, 0xa3, 0xe8, 0xf6, 0x5b, 0xcc, 0x90, 0xc0, 0x4f, 0xb5, 0xa0, + 0x0, 0x0, 0x1e, 0xec, 0xd6, 0xce, 0xb5, 0x12, 0xa7, 0xb5, 0x6b, 0xff, 0x63, 0x96, 0x43, 0x26, 0x58, 0x60, 0x52, + 0xfa, 0x96, 0xf, 0xb8, 0x47, 0xf1, 0x78, 0x97, 0xc4, 0x8f, 0x52, 0x90, 0xd2, 0x77, 0x0}; + + uint8_t buf[253] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x5e, 0xe2, 0xfb, 0xb5, 0x32, 0x9c, 0x7c, 0x74, 0x97, 0x53, 0xa9, 0xfc, 0x92, + 0x3, 0x1d, 0xac, 0x53, 0xa9, 0x4, 0x8e, 0xc9, 0xad, 0xa4, 0x3d, 0xaa, 0x61}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb, 0x8, 0x41, 0x46, 0xf5, 0x35, 0xe7, 0xb5, 0xd3, 0x38, 0x38, 0xb4, 0xf4, - 0xe0, 0x71, 0xf5, 0x32, 0x89, 0x7c, 0x7c, 0x92, 0x32, 0x1b, 0xba, 0x70, 0x60}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe1, 0x57, 0x33, 0x6b, 0x21, 0x97, 0xf5, 0xe4, + 0x3e, 0xcd, 0xc6, 0x84, 0xa8, 0x2c, 0x8e}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7a, 0x2d, 0x51, 0x3, 0xfa, 0x7d, 0xa8, 0x48, 0xde, 0x89, 0x14, 0x22, 0xaa}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1c, 0xf5, 0x91, 0x1e, 0xa6, 0x2a, 0x1, 0xa3, 0xe8, + 0xf6, 0x5b, 0xcc, 0x90, 0xc0, 0x4f, 0xb5, 0xa0}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8, 0x72, 0x0, 0x5, 0x5d, 0xdd, 0x3, 0x6b, 0x4c, 0xbe, - 0x6f, 0xee, 0x2e, 0x23, 0xe3, 0xe6, 0x19, 0xa9, 0x77, 0x64}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xec, 0xd6, 0xce, 0xb5, 0x12, 0xa7, 0xb5, 0x6b, 0xff, 0x63, + 0x96, 0x43, 0x26, 0x58, 0x60, 0x52, 0xfa, 0x96, 0xf, 0xb8, + 0x47, 0xf1, 0x78, 0x97, 0xc4, 0x8f, 0x52, 0x90, 0xd2, 0x77}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xbd, 0xe0, 0xe6, 0x30, 0x78, 0x24, 0x4, 0x62, 0x58, 0x6e, 0x19, 0x29, 0xc8, - 0xb8, 0x9a, 0x5a, 0x65, 0x42, 0x7, 0x88, 0x51, 0x2b, 0xe9, 0x9e, 0x42}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xd, 0xb6, 0x2c, 0x49}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x47, 0x82, 0xfb, 0x93, 0x9, 0x77, 0x4f}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xbc}; - lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xde, 0x1e, 0xf8, 0xc4, 0xa3, 0xcc, 0x50}; - lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa0, 0x68, 0x49, 0xb4, 0x7e, 0x52, 0x37, 0x57, 0xee}; - lwmqtt_string_t topic_filter_s9 = {9, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xae, 0xd7, 0xda, 0xac, 0x56, 0x7b, 0xa2, 0xed, 0x99, 0xa9, - 0x90, 0xe, 0x2, 0x4d, 0xbe, 0xa, 0x87, 0x55, 0xb4, 0xad, - 0x16, 0xf4, 0x35, 0xe3, 0x24, 0x9a, 0x6, 0xc2, 0xf9, 0xf9}; - lwmqtt_string_t topic_filter_s10 = {30, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0xcd, 0x7b, 0xc9, 0x96, 0x50, 0xca, 0x8e, 0x65, 0xc, 0x36, 0x23, 0x35, 0x9a}; - uint8_t bytesprops1[] = {0xd8, 0x87, 0x3, 0x2f, 0x88, 0x8a, 0x71, 0x5f, 0xde, 0x3f, 0x2, 0x99, 0x8e, 0x74, 0x35, - 0xf1, 0xa2, 0xc3, 0x4d, 0xa2, 0xab, 0x36, 0x4e, 0xeb, 0x6f, 0x33, 0xf7, 0x5b, 0x3f}; - uint8_t bytesprops2[] = {0xb0, 0x5e, 0x48, 0xb5, 0x74, 0x54, 0xa7, 0x30, 0x87, 0xba, 0x3f}; - uint8_t bytesprops3[] = {0x56, 0xf2, 0x74, 0xbc, 0x40, 0x13, 0xf1, 0xd4, 0x0}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x5e, 0x2d, 0x75, 0x1c, 0x15, 0x6, 0x4f, 0xaa, 0x7a, 0xa9, 0xdb, 0xb6, 0x9a, + 0xee, 0x12, 0x15, 0x42, 0x86, 0x9e, 0xb, 0x2f, 0x11, 0x32, 0x33, 0xf2, 0x74}; + uint8_t bytesprops1[] = {0x7f, 0x5d, 0xc5, 0xd9, 0x9e, 0x29, 0x1e, 0x43, 0x35, 0x30, 0x9a, 0xff, 0xd6, + 0x45, 0x5d, 0x15, 0xbe, 0x8, 0xbb, 0x66, 0xd9, 0x5f, 0xed, 0x6, 0x98, 0x2a}; + uint8_t bytesprops2[] = {0x24, 0x99, 0x4b, 0x29, 0x6d, 0x71, 0x9, 0xad, + 0x3e, 0xc2, 0xa8, 0x21, 0xb1, 0x3d, 0x1d, 0x18}; + uint8_t bytesprops3[] = {0xb8, 0xd9, 0xb3, 0x29, 0x37, 0xa8, 0x24, 0x7e, 0x4b, 0xb0, 0x27, 0xcd, + 0x9f, 0x21, 0xf7, 0xe5, 0x6, 0xa7, 0x46, 0x1b, 0xdf, 0x73, 0xa0}; + uint8_t bytesprops4[] = {0xa4}; + uint8_t bytesprops5[] = {0x2b, 0xe5, 0x77, 0x5e, 0xeb, 0xd, 0xac, 0xf5, 0x71, 0xca, + 0xca, 0xdb, 0x62, 0x97, 0x9b, 0x4d, 0xb0, 0x3f, 0xe0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6824}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4252}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4271}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15144}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26100}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18065}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20242}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13111, 11, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11149, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22578 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = -// QoS2}),("Y\180\175\251o\184au\195\159\207(+B\f\233\165\201\242\165\130\246Y\187q\CANg\155",SubOptions +// SubscribeRequest 2269 [("\DC2\238\205\167\203qt\199%Vl\129\160y\134\175U^\144K\SYN\ENQ\155+\GSdIr",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("R,\DC1w\SI\227c}",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("\134\NUL\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\US6\195Ct\137l\EOT\155\185\230\144\143H\n\vU!\196",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\195T\236\253h\n\197\181\188\199\206\134\174\196\215\FS\165\227'\220\DC1m}\206\164;\249\SOHR",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropMessageExpiryInterval 26993,PropPayloadFormatIndicator 117,PropMaximumQoS 245,PropAuthenticationMethod -// "\196R\165\DC4\SUBV 5e",PropMessageExpiryInterval 26854,PropMessageExpiryInterval 23171,PropResponseInformation -// "\CANh\145Q\246[\212\&5S\177WJ\fA\STX\EM\"\184\f\196\DC4\f7",PropCorrelationData "\171",PropAuthenticationData -// "\174\243\DC3P\181<:w\170\226",PropSubscriptionIdentifier 8,PropServerReference -// "GK\253\187\129\ETXd\240",PropTopicAliasMaximum 3019,PropReasonString "",PropUserProperty -// "\169\218a\DC3|\ETB\216y\DC3\136/\136=GGvdH5>\156\183\203}" "\FSD.;",PropSessionExpiryInterval -// 9051,PropSharedSubscriptionAvailable 97,PropRequestResponseInformation 125,PropContentType -// "\137\255S\254h",PropWillDelayInterval 18039,PropResponseTopic -// "\t\ETXL\138b\200\189\172?\v*\225\228\143z\ESC\231>\217&\231",PropRequestProblemInformation 169,PropTopicAlias -// 8806,PropTopicAliasMaximum 26514,PropWillDelayInterval 11232,PropTopicAliasMaximum 8472,PropReceiveMaximum -// 13639,PropWildcardSubscriptionAvailable 224,PropCorrelationData -// "Cl$9?\DC4k[\129x\181\DLE\233\CANIZF\200",PropPayloadFormatIndicator 94] +// QoS2}),("\208\157\230h\219\215$\215\133\STXrRf\214m\159\156\229\196\139\223EF>1\n'",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\195S:\237\&8\249\f\223\SOH\EOTZ?\209RD1\128I\133\205\137\135c",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\252\&2\240JZ\198a\161y\244\135\130Ki\174\129\150\137H\142\184\151\167",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("%m\230\152\&3B\177\207",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\SO\US\NUL\133[",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\SO|\177\228\ETB\214C\165`\152*\SOM\180y9\233\&3`",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\160\&8\129\v\DC4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\\z\220\157\147\201\254\SUB\195\158\139\t\158\140\173\133\r\233\175q\212\152\175B\181d\FS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropAuthenticationData "\184\223\189Z\137\FS\218\128\216\&5\192\198Iw\207y4\232",PropRequestProblemInformation +// 197,PropMessageExpiryInterval 11093,PropRequestResponseInformation 99,PropTopicAliasMaximum 22661,PropUserProperty +// "K1\STX6Q\132\129}\t>G\233\&3KkU[\v\STXS" +// "\143g\145_\170\203\159\142\197\140\144{\ETB\STX\ETX<\"))\251G\GS\132\158K",PropMessageExpiryInterval +// 11179,PropResponseTopic "\NULk&8:\238H\174",PropMessageExpiryInterval 3353,PropReceiveMaximum +// 4866,PropWildcardSubscriptionAvailable 41,PropAssignedClientIdentifier +// "\194\201\&1\222\247\SYN\191T$@\155C\DEL\255\b\202g\194\240\148\167\&2",PropRetainAvailable +// 136,PropAssignedClientIdentifier "^\229\129!\196\185",PropRetainAvailable 99,PropWillDelayInterval +// 14562,PropSubscriptionIdentifierAvailable 215] TEST(Subscribe5QCTest, Encode8) { uint8_t pkt[] = { - 0x82, 0xc8, 0x2, 0x58, 0x32, 0xd8, 0x1, 0x2, 0x0, 0x0, 0x69, 0x71, 0x1, 0x75, 0x24,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 0x24, 0x39, 0x3f, 0x14, - 0x6b, 0x5b, 0x81, 0x78, 0xb5, 0x10, 0xe9, 0x18, 0x49, 0x5a, 0x46, 0xc8, 0x1, 0x5e, 0x0, 0x0, 0x2, 0x0, 0x1c, - 0x59, 0xb4, 0xaf, 0xfb, 0x6f, 0xb8, 0x61, 0x75, 0xc3, 0x9f, 0xcf, 0x28, 0x2b, 0x42, 0xc, 0xe9, 0xa5, 0xc9, 0xf2, - 0xa5, 0x82, 0xf6, 0x59, 0xbb, 0x71, 0x18, 0x67, 0x9b, 0x2, 0x0, 0x8, 0x52, 0x2c, 0x11, 0x77, 0xf, 0xe3, 0x63, - 0x7d, 0x1, 0x0, 0x3, 0x86, 0x0, 0xe8, 0x0, 0x0, 0x0, 0x1, 0x0, 0x13, 0x1f, 0x36, 0xc3, 0x43, 0x74, 0x89, - 0x6c, 0x4, 0x9b, 0xb9, 0xe6, 0x90, 0x8f, 0x48, 0xa, 0xb, 0x55, 0x21, 0xc4, 0x1, 0x0, 0x1d, 0xc3, 0x54, 0xec, - 0xfd, 0x68, 0xa, 0xc5, 0xb5, 0xbc, 0xc7, 0xce, 0x86, 0xae, 0xc4, 0xd7, 0x1c, 0xa5, 0xe3, 0x27, 0xdc, 0x11, 0x6d, - 0x7d, 0xce, 0xa4, 0x3b, 0xf9, 0x1, 0x52, 0x2}; - - uint8_t buf[341] = {0}; - - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + 0x82, 0xe1, 0x2, 0x8, 0xdd, 0x9a, 0x1, 0x16, 0x0, 0x12, 0xb8, 0xdf, 0xbd, 0x5a, 0x89, 0x1c, 0xda, 0x80, 0xd8, + 0x35, 0xc0, 0xc6, 0x49, 0x77, 0xcf, 0x79, 0x34, 0xe8, 0x17, 0xc5, 0x2, 0x0, 0x0, 0x2b, 0x55, 0x19, 0x63, 0x22, + 0x58, 0x85, 0x26, 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, 0xc, 0xdf, 0x1, 0x4, 0x5a, 0x3f, 0xd1, 0x52, 0x44, 0x31, 0x80, 0x49, 0x85, 0xcd, 0x89, 0x87, 0x63, + 0x1, 0x0, 0x17, 0xfc, 0x32, 0xf0, 0x4a, 0x5a, 0xc6, 0x61, 0xa1, 0x79, 0xf4, 0x87, 0x82, 0x4b, 0x69, 0xae, 0x81, + 0x96, 0x89, 0x48, 0x8e, 0xb8, 0x97, 0xa7, 0x0, 0x0, 0x8, 0x25, 0x6d, 0xe6, 0x98, 0x33, 0x42, 0xb1, 0xcf, 0x0, + 0x0, 0x5, 0xe, 0x1f, 0x0, 0x85, 0x5b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x13, 0xe, 0x7c, 0xb1, 0xe4, 0x17, 0xd6, + 0x43, 0xa5, 0x60, 0x98, 0x2a, 0xe, 0x4d, 0xb4, 0x79, 0x39, 0xe9, 0x33, 0x60, 0x2, 0x0, 0x5, 0xa0, 0x38, 0x81, + 0xb, 0x14, 0x2, 0x0, 0x1b, 0x5c, 0x7a, 0xdc, 0x9d, 0x93, 0xc9, 0xfe, 0x1a, 0xc3, 0x9e, 0x8b, 0x9, 0x9e, 0x8c, + 0xad, 0x85, 0xd, 0xe9, 0xaf, 0x71, 0xd4, 0x98, 0xaf, 0x42, 0xb5, 0x64, 0x1c, 0x0}; + + uint8_t buf[366] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x12, 0xee, 0xcd, 0xa7, 0xcb, 0x71, 0x74, 0xc7, 0x25, 0x56, + 0x6c, 0x81, 0xa0, 0x79, 0x86, 0xaf, 0x55, 0x5e, 0x90, 0x4b, + 0x16, 0x5, 0x9b, 0x2b, 0x1d, 0x64, 0x49, 0x72}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x59, 0xb4, 0xaf, 0xfb, 0x6f, 0xb8, 0x61, 0x75, 0xc3, 0x9f, - 0xcf, 0x28, 0x2b, 0x42, 0xc, 0xe9, 0xa5, 0xc9, 0xf2, 0xa5, - 0x82, 0xf6, 0x59, 0xbb, 0x71, 0x18, 0x67, 0x9b}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd0, 0x9d, 0xe6, 0x68, 0xdb, 0xd7, 0x24, 0xd7, 0x85, 0x2, 0x72, 0x52, 0x66, 0xd6, + 0x6d, 0x9f, 0x9c, 0xe5, 0xc4, 0x8b, 0xdf, 0x45, 0x46, 0x3e, 0x31, 0xa, 0x27}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x52, 0x2c, 0x11, 0x77, 0xf, 0xe3, 0x63, 0x7d}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc3, 0x53, 0x3a, 0xed, 0x38, 0xf9, 0xc, 0xdf, 0x1, 0x4, 0x5a, 0x3f, + 0xd1, 0x52, 0x44, 0x31, 0x80, 0x49, 0x85, 0xcd, 0x89, 0x87, 0x63}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x86, 0x0, 0xe8}; - lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfc, 0x32, 0xf0, 0x4a, 0x5a, 0xc6, 0x61, 0xa1, 0x79, 0xf4, 0x87, 0x82, + 0x4b, 0x69, 0xae, 0x81, 0x96, 0x89, 0x48, 0x8e, 0xb8, 0x97, 0xa7}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x25, 0x6d, 0xe6, 0x98, 0x33, 0x42, 0xb1, 0xcf}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1f, 0x36, 0xc3, 0x43, 0x74, 0x89, 0x6c, 0x4, 0x9b, 0xb9, - 0xe6, 0x90, 0x8f, 0x48, 0xa, 0xb, 0x55, 0x21, 0xc4}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe, 0x1f, 0x0, 0x85, 0x5b}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc3, 0x54, 0xec, 0xfd, 0x68, 0xa, 0xc5, 0xb5, 0xbc, 0xc7, - 0xce, 0x86, 0xae, 0xc4, 0xd7, 0x1c, 0xa5, 0xe3, 0x27, 0xdc, - 0x11, 0x6d, 0x7d, 0xce, 0xa4, 0x3b, 0xf9, 0x1, 0x52}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0xc4, 0x52, 0xa5, 0x14, 0x1a, 0x56, 0x20, 0x35, 0x65}; - uint8_t bytesprops1[] = {0x18, 0x68, 0x91, 0x51, 0xf6, 0x5b, 0xd4, 0x35, 0x53, 0xb1, 0x57, 0x4a, - 0xc, 0x41, 0x2, 0x19, 0x22, 0xb8, 0xc, 0xc4, 0x14, 0xc, 0x37}; - uint8_t bytesprops2[] = {0xab}; - uint8_t bytesprops3[] = {0xae, 0xf3, 0x13, 0x50, 0xb5, 0x3c, 0x3a, 0x77, 0xaa, 0xe2}; - uint8_t bytesprops4[] = {0x47, 0x4b, 0xfd, 0xbb, 0x81, 0x3, 0x64, 0xf0}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops7[] = {0x1c, 0x44, 0x2e, 0x3b}; - uint8_t bytesprops6[] = {0xa9, 0xda, 0x61, 0x13, 0x7c, 0x17, 0xd8, 0x79, 0x13, 0x88, 0x2f, 0x88, - 0x3d, 0x47, 0x47, 0x76, 0x64, 0x48, 0x35, 0x3e, 0x9c, 0xb7, 0xcb, 0x7d}; - uint8_t bytesprops8[] = {0x89, 0xff, 0x53, 0xfe, 0x68}; - uint8_t bytesprops9[] = {0x9, 0x3, 0x4c, 0x8a, 0x62, 0xc8, 0xbd, 0xac, 0x3f, 0xb, 0x2a, - 0xe1, 0xe4, 0x8f, 0x7a, 0x1b, 0xe7, 0x3e, 0xd9, 0x26, 0xe7}; - uint8_t bytesprops10[] = {0x43, 0x6c, 0x24, 0x39, 0x3f, 0x14, 0x6b, 0x5b, 0x81, - 0x78, 0xb5, 0x10, 0xe9, 0x18, 0x49, 0x5a, 0x46, 0xc8}; + uint8_t topic_filter_s7_bytes[] = {0xe, 0x7c, 0xb1, 0xe4, 0x17, 0xd6, 0x43, 0xa5, 0x60, 0x98, + 0x2a, 0xe, 0x4d, 0xb4, 0x79, 0x39, 0xe9, 0x33, 0x60}; + lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa0, 0x38, 0x81, 0xb, 0x14}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x5c, 0x7a, 0xdc, 0x9d, 0x93, 0xc9, 0xfe, 0x1a, 0xc3, 0x9e, 0x8b, 0x9, 0x9e, 0x8c, + 0xad, 0x85, 0xd, 0xe9, 0xaf, 0x71, 0xd4, 0x98, 0xaf, 0x42, 0xb5, 0x64, 0x1c}; + lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0xb8, 0xdf, 0xbd, 0x5a, 0x89, 0x1c, 0xda, 0x80, 0xd8, + 0x35, 0xc0, 0xc6, 0x49, 0x77, 0xcf, 0x79, 0x34, 0xe8}; + uint8_t bytesprops2[] = {0x8f, 0x67, 0x91, 0x5f, 0xaa, 0xcb, 0x9f, 0x8e, 0xc5, 0x8c, 0x90, 0x7b, 0x17, + 0x2, 0x3, 0x3c, 0x22, 0x29, 0x29, 0xfb, 0x47, 0x1d, 0x84, 0x9e, 0x4b}; + uint8_t bytesprops1[] = {0x4b, 0x31, 0x2, 0x36, 0x51, 0x84, 0x81, 0x7d, 0x9, 0x3e, + 0x47, 0xe9, 0x33, 0x4b, 0x6b, 0x55, 0x5b, 0xb, 0x2, 0x53}; + uint8_t bytesprops3[] = {0x0, 0x6b, 0x26, 0x38, 0x3a, 0xee, 0x48, 0xae}; + uint8_t bytesprops4[] = {0xc2, 0xc9, 0x31, 0xde, 0xf7, 0x16, 0xbf, 0x54, 0x24, 0x40, 0x9b, + 0x43, 0x7f, 0xff, 0x8, 0xca, 0x67, 0xc2, 0xf0, 0x94, 0xa7, 0x32}; + uint8_t bytesprops5[] = {0x5e, 0xe5, 0x81, 0x21, 0xc4, 0xb9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26993}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26854}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23171}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3019}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops6}, .v = {4, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9051}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18039}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8806}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26514}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11232}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8472}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13639}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11093}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22661}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops1}, .v = {25, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11179}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3353}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4866}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14562}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22578, 7, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2269, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 5714 [("Z\154\192",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("n\209\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\236[5",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1}),("+l\193\192-m.\NUL\128\147\191\196\DC4\255 -// \250\233P\183w\192\176F-\192\208\158\201\172\231",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("A\222\209\219\SO\f\212\243or\200\&4",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval -// 28129,PropWillDelayInterval 7503,PropSharedSubscriptionAvailable 212,PropResponseInformation -// "l6\225w\170\&4\241\182",PropSubscriptionIdentifier 12,PropUserProperty -// "\248\202dYf\DEL\153\152x\217\"b\220O\152r\DC4\228\230\209\178P\240\230>" -// "SB\166n;C\173\155Dw\ETX\208\140\180\194\220t\241\213\148\&0\223n\230x\SYNmz\154"] +// SubscribeRequest 9248 [("\233\154\252\129\230\&9\142\177.,%\202H\EM",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("s\ETB\220\154j\DC1\149e\235\252\163\CANis@",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SOHz\161\174&\ESC;\181-\130",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\204l}DdML\130\250\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2})] [PropSubscriptionIdentifierAvailable 250,PropSessionExpiryInterval +// 30222,PropAssignedClientIdentifier "\143\US",PropPayloadFormatIndicator 66,PropUserProperty +// "\128\&8W!S;\202E\206]\220\147\228\227\178\233\252i\140:+\207\148\&1\242>\192\243\160" +// "\202\181\197",PropCorrelationData +// "\150\219\ETX\v\147\STX\205\228*\217\175\203S\170\196P\223\202\204\180f",PropPayloadFormatIndicator 80] TEST(Subscribe5QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0x99, 0x1, 0x16, 0x52, 0x54, 0x2, 0x0, 0x0, 0x6d, 0xe1, 0x18, 0x0, 0x0, 0x1d, 0x4f, - 0x2a, 0xd4, 0x1a, 0x0, 0x8, 0x6c, 0x36, 0xe1, 0x77, 0xaa, 0x34, 0xf1, 0xb6, 0xb, 0xc, 0x26, - 0x0, 0x19, 0xf8, 0xca, 0x64, 0x59, 0x66, 0x7f, 0x99, 0x98, 0x78, 0xd9, 0x22, 0x62, 0xdc, 0x4f, - 0x98, 0x72, 0x14, 0xe4, 0xe6, 0xd1, 0xb2, 0x50, 0xf0, 0xe6, 0x3e, 0x0, 0x1d, 0x53, 0x42, 0xa6, - 0x6e, 0x3b, 0x43, 0xad, 0x9b, 0x44, 0x77, 0x3, 0xd0, 0x8c, 0xb4, 0xc2, 0xdc, 0x74, 0xf1, 0xd5, - 0x94, 0x30, 0xdf, 0x6e, 0xe6, 0x78, 0x16, 0x6d, 0x7a, 0x9a, 0x0, 0x3, 0x5a, 0x9a, 0xc0, 0x0, - 0x0, 0x3, 0x6e, 0xd1, 0x83, 0x2, 0x0, 0x3, 0xec, 0x5b, 0x35, 0x1, 0x0, 0x1e, 0x2b, 0x6c, - 0xc1, 0xc0, 0x2d, 0x6d, 0x2e, 0x0, 0x80, 0x93, 0xbf, 0xc4, 0x14, 0xff, 0x20, 0xfa, 0xe9, 0x50, - 0xb7, 0x77, 0xc0, 0xb0, 0x46, 0x2d, 0xc0, 0xd0, 0x9e, 0xc9, 0xac, 0xe7, 0x1, 0x0, 0xc, 0x41, - 0xde, 0xd1, 0xdb, 0xe, 0xc, 0xd4, 0xf3, 0x6f, 0x72, 0xc8, 0x34, 0x1}; - - uint8_t buf[166] = {0}; - - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x5a, 0x9a, 0xc0}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x8d, 0x1, 0x24, 0x20, 0x4d, 0x29, 0xfa, 0x11, 0x0, 0x0, 0x76, 0xe, 0x12, 0x0, 0x2, + 0x8f, 0x1f, 0x1, 0x42, 0x26, 0x0, 0x1d, 0x80, 0x38, 0x57, 0x21, 0x53, 0x3b, 0xca, 0x45, 0xce, + 0x5d, 0xdc, 0x93, 0xe4, 0xe3, 0xb2, 0xe9, 0xfc, 0x69, 0x8c, 0x3a, 0x2b, 0xcf, 0x94, 0x31, 0xf2, + 0x3e, 0xc0, 0xf3, 0xa0, 0x0, 0x3, 0xca, 0xb5, 0xc5, 0x9, 0x0, 0x15, 0x96, 0xdb, 0x3, 0xb, + 0x93, 0x2, 0xcd, 0xe4, 0x2a, 0xd9, 0xaf, 0xcb, 0x53, 0xaa, 0xc4, 0x50, 0xdf, 0xca, 0xcc, 0xb4, + 0x66, 0x1, 0x50, 0x0, 0xe, 0xe9, 0x9a, 0xfc, 0x81, 0xe6, 0x39, 0x8e, 0xb1, 0x2e, 0x2c, 0x25, + 0xca, 0x48, 0x19, 0x2, 0x0, 0xf, 0x73, 0x17, 0xdc, 0x9a, 0x6a, 0x11, 0x95, 0x65, 0xeb, 0xfc, + 0xa3, 0x18, 0x69, 0x73, 0x40, 0x0, 0x0, 0xa, 0x1, 0x7a, 0xa1, 0xae, 0x26, 0x1b, 0x3b, 0xb5, + 0x2d, 0x82, 0x1, 0x0, 0xa, 0xcc, 0x6c, 0x7d, 0x44, 0x64, 0x4d, 0x4c, 0x82, 0xfa, 0x2, 0x2}; + + uint8_t buf[154] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xe9, 0x9a, 0xfc, 0x81, 0xe6, 0x39, 0x8e, + 0xb1, 0x2e, 0x2c, 0x25, 0xca, 0x48, 0x19}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6e, 0xd1, 0x83}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x73, 0x17, 0xdc, 0x9a, 0x6a, 0x11, 0x95, 0x65, + 0xeb, 0xfc, 0xa3, 0x18, 0x69, 0x73, 0x40}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xec, 0x5b, 0x35}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1, 0x7a, 0xa1, 0xae, 0x26, 0x1b, 0x3b, 0xb5, 0x2d, 0x82}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2b, 0x6c, 0xc1, 0xc0, 0x2d, 0x6d, 0x2e, 0x0, 0x80, 0x93, - 0xbf, 0xc4, 0x14, 0xff, 0x20, 0xfa, 0xe9, 0x50, 0xb7, 0x77, - 0xc0, 0xb0, 0x46, 0x2d, 0xc0, 0xd0, 0x9e, 0xc9, 0xac, 0xe7}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xcc, 0x6c, 0x7d, 0x44, 0x64, 0x4d, 0x4c, 0x82, 0xfa, 0x2}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x41, 0xde, 0xd1, 0xdb, 0xe, 0xc, 0xd4, 0xf3, 0x6f, 0x72, 0xc8, 0x34}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x6c, 0x36, 0xe1, 0x77, 0xaa, 0x34, 0xf1, 0xb6}; - uint8_t bytesprops2[] = {0x53, 0x42, 0xa6, 0x6e, 0x3b, 0x43, 0xad, 0x9b, 0x44, 0x77, 0x3, 0xd0, 0x8c, 0xb4, 0xc2, - 0xdc, 0x74, 0xf1, 0xd5, 0x94, 0x30, 0xdf, 0x6e, 0xe6, 0x78, 0x16, 0x6d, 0x7a, 0x9a}; - uint8_t bytesprops1[] = {0xf8, 0xca, 0x64, 0x59, 0x66, 0x7f, 0x99, 0x98, 0x78, 0xd9, 0x22, 0x62, 0xdc, - 0x4f, 0x98, 0x72, 0x14, 0xe4, 0xe6, 0xd1, 0xb2, 0x50, 0xf0, 0xe6, 0x3e}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x8f, 0x1f}; + uint8_t bytesprops2[] = {0xca, 0xb5, 0xc5}; + uint8_t bytesprops1[] = {0x80, 0x38, 0x57, 0x21, 0x53, 0x3b, 0xca, 0x45, 0xce, 0x5d, 0xdc, 0x93, 0xe4, 0xe3, 0xb2, + 0xe9, 0xfc, 0x69, 0x8c, 0x3a, 0x2b, 0xcf, 0x94, 0x31, 0xf2, 0x3e, 0xc0, 0xf3, 0xa0}; + uint8_t bytesprops3[] = {0x96, 0xdb, 0x3, 0xb, 0x93, 0x2, 0xcd, 0xe4, 0x2a, 0xd9, 0xaf, + 0xcb, 0x53, 0xaa, 0xc4, 0x50, 0xdf, 0xca, 0xcc, 0xb4, 0x66}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28129}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7503}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops1}, .v = {29, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30222}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {3, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 80}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5714, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9248, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3531 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\254\134x\175,x\231\DC3\SOHJ\EOT",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\132bW\232H.\t\251\ACK\185\246\221\163",SubOptions +// SubscribeRequest 22320 [("U\\Dd9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = +// QoS2}),("w\225r\ETB\229\148t\144\141\ETB\DC3\141\216\DEL\SYN7r^\157\169\201\222\240{\CAN\162",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\240\158)|E\240\&8\229\159#3\US$\GS\163\142\184\204\a\254\249\NAK\212}",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(".\US\239\142\182M\DC2\228v\142",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\145\239\128\212\215v\211R\239\248\165M\231oh\163\192PE\213\174\249\165\218\ETB\148",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("'\251\128\148 -// \133P@7h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\v\210V\DLE\245\137\166\n\v!:\NAK\231Y\SYN\215\n\247\191g\147\RS\STX",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("FH\178&\154",SubOptions +// QoS1}),("\144%\189P}R&]F\140hw\FS\134Pm\201\240\130#\185",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("6\155R=&\211a\DC3v\192\rP~\175",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\228\161\STXal\230\192\ETB\213\134\a\178a4",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\223\209\242\169\SO\193\&9\248\172\170\181\153\222E!\208\167mA\140\206\170\\\189-A\155",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropMaximumPacketSize 8327,PropSubscriptionIdentifierAvailable 142,PropContentType -// "\234VQb\ETB\227\144^\211\173\227\US\238\USE\CAN\149\134A",PropRetainAvailable 227,PropTopicAliasMaximum -// 1282,PropCorrelationData -// "\221i\226\245e\131b\248\157P\DEL\189\145!\ENQ[q\222+\212\SYN\231j\DC4\233\244A",PropAuthenticationMethod -// "\165HfSK.o\RS\169\ESC\238|l\238\134\148<\193\STXa#\198\SO>",PropUserProperty -// "_ws\206\209\223\224\214\207\182\179\147" "",PropMaximumPacketSize 6778,PropTopicAliasMaximum -// 3766,PropSharedSubscriptionAvailable 102,PropResponseTopic "",PropTopicAliasMaximum 4261,PropWillDelayInterval -// 21768,PropContentType -// "\ENQP\171\163\SUBQ\SYNf\225\158\223\214\171\a\r\218\245\231\213\163\DLE_\US\250\167\n1\206$",PropCorrelationData -// "\167\204\190C E\144Y\214\175\139\199r\v",PropServerReference -// "\RS\237\254\DC3\232\138\251c7\154R~\177\v)\170",PropMaximumQoS 8,PropResponseInformation -// "\180I\209d\175\SI?\132U\225)\175\141\179",PropRequestProblemInformation 155,PropTopicAlias -// 13440,PropSubscriptionIdentifierAvailable 115,PropCorrelationData -// "{Ha~\t\220\231\242\226\240G\157\146cY^'\SYN\243Q\211\241",PropReceiveMaximum 4880] +// [PropServerKeepAlive 312,PropAuthenticationMethod +// "T\235\205N\209*\217\253V\240W\162a;\134\180\147\n\153\228\226\DC1\171\201\fes\240\133",PropReasonString +// "C\SI\194\223i/\"\DC3hz+G\USq\147\&7\147\154\212\bf\206BBr@B",PropTopicAliasMaximum 14013,PropRetainAvailable +// 158,PropMaximumQoS 145,PropMaximumPacketSize 32295,PropResponseInformation +// "\187\182\174\136\132D\207\152\CAN\STX\193;\tGP\198\SOHi\205\181\232^\240\226D\137e\164",PropWildcardSubscriptionAvailable +// 44] TEST(Subscribe5QCTest, Encode10) { uint8_t pkt[] = { - 0x82, 0x97, 0x3, 0xd, 0xcb, 0xfb, 0x1, 0x27, 0x0, 0x0, 0x20, 0x87, 0x29, 0x8e, 0x3, 0x0, 0x13, 0xea, 0x56, - 0x51, 0x62, 0x17, 0xe3, 0x90, 0x5e, 0xd3, 0xad, 0xe3, 0x1f, 0xee, 0x1f, 0x45, 0x18, 0x95, 0x86, 0x41, 0x25, 0xe3, - 0x22, 0x5, 0x2, 0x9, 0x0, 0x1b, 0xdd, 0x69, 0xe2, 0xf5, 0x65, 0x83, 0x62, 0xf8, 0x9d, 0x50, 0x7f, 0xbd, 0x91, - 0x21, 0x5, 0x5b, 0x71, 0xde, 0x2b, 0xd4, 0x16, 0xe7, 0x6a, 0x14, 0xe9, 0xf4, 0x41, 0x15, 0x0, 0x18, 0xa5, 0x48, - 0x66, 0x53, 0x4b, 0x2e, 0x6f, 0x1e, 0xa9, 0x1b, 0xee, 0x7c, 0x6c, 0xee, 0x86, 0x94, 0x3c, 0xc1, 0x2, 0x61, 0x23, - 0xc6, 0xe, 0x3e, 0x26, 0x0, 0xc, 0x5f, 0x77, 0x73, 0xce, 0xd1, 0xdf, 0xe0, 0xd6, 0xcf, 0xb6, 0xb3, 0x93, 0x0, - 0x0, 0x27, 0x0, 0x0, 0x1a, 0x7a, 0x22, 0xe, 0xb6, 0x2a, 0x66, 0x8, 0x0, 0x0, 0x22, 0x10, 0xa5, 0x18, 0x0, - 0x0, 0x55, 0x8, 0x3, 0x0, 0x1d, 0x5, 0x50, 0xab, 0xa3, 0x1a, 0x51, 0x16, 0x66, 0xe1, 0x9e, 0xdf, 0xd6, 0xab, - 0x7, 0xd, 0xda, 0xf5, 0xe7, 0xd5, 0xa3, 0x10, 0x5f, 0x1f, 0xfa, 0xa7, 0xa, 0x31, 0xce, 0x24, 0x9, 0x0, 0xe, - 0xa7, 0xcc, 0xb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2, 0x0, - 0xa, 0x27, 0xfb, 0x80, 0x94, 0x20, 0x85, 0x50, 0x40, 0x37, 0x68, 0x2, 0x0, 0x17, 0xb, 0xd2, 0x56, 0x10, 0xf5, - 0x89, 0xa6, 0xa, 0xb, 0x21, 0x3a, 0x15, 0xe7, 0x59, 0x16, 0xd7, 0xa, 0xf7, 0xbf, 0x67, 0x93, 0x1e, 0x2, 0x2, - 0x0, 0x0, 0x0, 0x0, 0x5, 0x46, 0x48, 0xb2, 0x26, 0x9a, 0x2}; - - uint8_t buf[420] = {0}; - - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + 0x82, 0xee, 0x1, 0x57, 0x30, 0x6e, 0x13, 0x1, 0x38, 0x15, 0x0, 0x1d, 0x54, 0xeb, 0xcd, 0x4e, 0xd1, 0x2a, 0xd9, + 0xfd, 0x56, 0xf0, 0x57, 0xa2, 0x61, 0x3b, 0x86, 0xb4, 0x93, 0xa, 0x99, 0xe4, 0xe2, 0x11, 0xab, 0xc9, 0xc, 0x65, + 0x73, 0xf0, 0x85, 0x1f, 0x0, 0x1b, 0x43, 0xf, 0xc2, 0xdf, 0x69, 0x2f, 0x22, 0x13, 0x68, 0x7a, 0x2b, 0x47, 0x1f, + 0x71, 0x93, 0x37, 0x93, 0x9a, 0xd4, 0x8, 0x66, 0xce, 0x42, 0x42, 0x72, 0x40, 0x42, 0x22, 0x36, 0xbd, 0x25, 0x9e, + 0x24, 0x91, 0x27, 0x0, 0x0, 0x7e, 0x27, 0x1a, 0x0, 0x1c, 0xbb, 0xb6, 0xae, 0x88, 0x84, 0x44, 0xcf, 0x98, 0x18, + 0x2, 0xc1, 0x3b, 0x9, 0x47, 0x50, 0xc6, 0x1, 0x69, 0xcd, 0xb5, 0xe8, 0x5e, 0xf0, 0xe2, 0x44, 0x89, 0x65, 0xa4, + 0x28, 0x2c, 0x0, 0x5, 0x55, 0x5c, 0x44, 0x64, 0x39, 0x2, 0x0, 0x1a, 0x77, 0xe1, 0x72, 0x17, 0xe5, 0x94, 0x74, + 0x90, 0x8d, 0x17, 0x13, 0x8d, 0xd8, 0x7f, 0x16, 0x37, 0x72, 0x5e, 0x9d, 0xa9, 0xc9, 0xde, 0xf0, 0x7b, 0x18, 0xa2, + 0x1, 0x0, 0x15, 0x90, 0x25, 0xbd, 0x50, 0x7d, 0x52, 0x26, 0x5d, 0x46, 0x8c, 0x68, 0x77, 0x1c, 0x86, 0x50, 0x6d, + 0xc9, 0xf0, 0x82, 0x23, 0xb9, 0x1, 0x0, 0xe, 0x36, 0x9b, 0x52, 0x3d, 0x26, 0xd3, 0x61, 0x13, 0x76, 0xc0, 0xd, + 0x50, 0x7e, 0xaf, 0x0, 0x0, 0xe, 0xe4, 0xa1, 0x2, 0x61, 0x6c, 0xe6, 0xc0, 0x17, 0xd5, 0x86, 0x7, 0xb2, 0x61, + 0x34, 0x1, 0x0, 0x1b, 0xdf, 0xd1, 0xf2, 0xa9, 0xe, 0xc1, 0x39, 0xf8, 0xac, 0xaa, 0xb5, 0x99, 0xde, 0x45, 0x21, + 0xd0, 0xa7, 0x6d, 0x41, 0x8c, 0xce, 0xaa, 0x5c, 0xbd, 0x2d, 0x41, 0x9b, 0x2}; + + uint8_t buf[251] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x55, 0x5c, 0x44, 0x64, 0x39}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfe, 0x86, 0x78, 0xaf, 0x2c, 0x78, 0xe7, 0x13, 0x1, 0x4a, 0x4}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x77, 0xe1, 0x72, 0x17, 0xe5, 0x94, 0x74, 0x90, 0x8d, 0x17, 0x13, 0x8d, 0xd8, + 0x7f, 0x16, 0x37, 0x72, 0x5e, 0x9d, 0xa9, 0xc9, 0xde, 0xf0, 0x7b, 0x18, 0xa2}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x84, 0x62, 0x57, 0xe8, 0x48, 0x2e, 0x9, 0xfb, 0x6, 0xb9, 0xf6, 0xdd, 0xa3}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x90, 0x25, 0xbd, 0x50, 0x7d, 0x52, 0x26, 0x5d, 0x46, 0x8c, 0x68, + 0x77, 0x1c, 0x86, 0x50, 0x6d, 0xc9, 0xf0, 0x82, 0x23, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf0, 0x9e, 0x29, 0x7c, 0x45, 0xf0, 0x38, 0xe5, 0x9f, 0x23, 0x33, 0x1f, - 0x24, 0x1d, 0xa3, 0x8e, 0xb8, 0xcc, 0x7, 0xfe, 0xf9, 0x15, 0xd4, 0x7d}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x36, 0x9b, 0x52, 0x3d, 0x26, 0xd3, 0x61, 0x13, 0x76, 0xc0, 0xd, 0x50, 0x7e, 0xaf}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2e, 0x1f, 0xef, 0x8e, 0xb6, 0x4d, 0x12, 0xe4, 0x76, 0x8e}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xe4, 0xa1, 0x2, 0x61, 0x6c, 0xe6, 0xc0, 0x17, 0xd5, 0x86, 0x7, 0xb2, 0x61, 0x34}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x91, 0xef, 0x80, 0xd4, 0xd7, 0x76, 0xd3, 0x52, 0xef, 0xf8, 0xa5, 0x4d, 0xe7, - 0x6f, 0x68, 0xa3, 0xc0, 0x50, 0x45, 0xd5, 0xae, 0xf9, 0xa5, 0xda, 0x17, 0x94}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xdf, 0xd1, 0xf2, 0xa9, 0xe, 0xc1, 0x39, 0xf8, 0xac, 0xaa, 0xb5, 0x99, 0xde, 0x45, + 0x21, 0xd0, 0xa7, 0x6d, 0x41, 0x8c, 0xce, 0xaa, 0x5c, 0xbd, 0x2d, 0x41, 0x9b}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x27, 0xfb, 0x80, 0x94, 0x20, 0x85, 0x50, 0x40, 0x37, 0x68}; - lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb, 0xd2, 0x56, 0x10, 0xf5, 0x89, 0xa6, 0xa, 0xb, 0x21, 0x3a, 0x15, - 0xe7, 0x59, 0x16, 0xd7, 0xa, 0xf7, 0xbf, 0x67, 0x93, 0x1e, 0x2}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0}; - lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x46, 0x48, 0xb2, 0x26, 0x9a}; - lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0xea, 0x56, 0x51, 0x62, 0x17, 0xe3, 0x90, 0x5e, 0xd3, 0xad, - 0xe3, 0x1f, 0xee, 0x1f, 0x45, 0x18, 0x95, 0x86, 0x41}; - uint8_t bytesprops1[] = {0xdd, 0x69, 0xe2, 0xf5, 0x65, 0x83, 0x62, 0xf8, 0x9d, 0x50, 0x7f, 0xbd, 0x91, 0x21, - 0x5, 0x5b, 0x71, 0xde, 0x2b, 0xd4, 0x16, 0xe7, 0x6a, 0x14, 0xe9, 0xf4, 0x41}; - uint8_t bytesprops2[] = {0xa5, 0x48, 0x66, 0x53, 0x4b, 0x2e, 0x6f, 0x1e, 0xa9, 0x1b, 0xee, 0x7c, - 0x6c, 0xee, 0x86, 0x94, 0x3c, 0xc1, 0x2, 0x61, 0x23, 0xc6, 0xe, 0x3e}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops3[] = {0x5f, 0x77, 0x73, 0xce, 0xd1, 0xdf, 0xe0, 0xd6, 0xcf, 0xb6, 0xb3, 0x93}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0x5, 0x50, 0xab, 0xa3, 0x1a, 0x51, 0x16, 0x66, 0xe1, 0x9e, 0xdf, 0xd6, 0xab, 0x7, 0xd, - 0xda, 0xf5, 0xe7, 0xd5, 0xa3, 0x10, 0x5f, 0x1f, 0xfa, 0xa7, 0xa, 0x31, 0xce, 0x24}; - uint8_t bytesprops7[] = {0xa7, 0xcc, 0xbe, 0x43, 0x20, 0x45, 0x90, 0x59, 0xd6, 0xaf, 0x8b, 0xc7, 0x72, 0xb}; - uint8_t bytesprops8[] = {0x1e, 0xed, 0xfe, 0x13, 0xe8, 0x8a, 0xfb, 0x63, - 0x37, 0x9a, 0x52, 0x7e, 0xb1, 0xb, 0x29, 0xaa}; - uint8_t bytesprops9[] = {0xb4, 0x49, 0xd1, 0x64, 0xaf, 0xf, 0x3f, 0x84, 0x55, 0xe1, 0x29, 0xaf, 0x8d, 0xb3}; - uint8_t bytesprops10[] = {0x7b, 0x48, 0x61, 0x7e, 0x9, 0xdc, 0xe7, 0xf2, 0xe2, 0xf0, 0x47, - 0x9d, 0x92, 0x63, 0x59, 0x5e, 0x27, 0x16, 0xf3, 0x51, 0xd3, 0xf1}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x54, 0xeb, 0xcd, 0x4e, 0xd1, 0x2a, 0xd9, 0xfd, 0x56, 0xf0, 0x57, 0xa2, 0x61, 0x3b, 0x86, + 0xb4, 0x93, 0xa, 0x99, 0xe4, 0xe2, 0x11, 0xab, 0xc9, 0xc, 0x65, 0x73, 0xf0, 0x85}; + uint8_t bytesprops1[] = {0x43, 0xf, 0xc2, 0xdf, 0x69, 0x2f, 0x22, 0x13, 0x68, 0x7a, 0x2b, 0x47, 0x1f, 0x71, + 0x93, 0x37, 0x93, 0x9a, 0xd4, 0x8, 0x66, 0xce, 0x42, 0x42, 0x72, 0x40, 0x42}; + uint8_t bytesprops2[] = {0xbb, 0xb6, 0xae, 0x88, 0x84, 0x44, 0xcf, 0x98, 0x18, 0x2, 0xc1, 0x3b, 0x9, 0x47, + 0x50, 0xc6, 0x1, 0x69, 0xcd, 0xb5, 0xe8, 0x5e, 0xf0, 0xe2, 0x44, 0x89, 0x65, 0xa4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8327}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1282}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops3}, .v = {0, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6778}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3766}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4261}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21768}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13440}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4880}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 312}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14013}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32295}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 44}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3531, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22320, 6, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); From 1a69a14b04b3466594cca7292c8625616e4835eb Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 18 Sep 2019 14:33:16 -0700 Subject: [PATCH 14/26] Reuse more generator. --- gentests/app/Main.hs | 75 +- tests/generated.cpp | 7044 +++++++++++++++++++++--------------------- 2 files changed, 3528 insertions(+), 3591 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index e2bd39d..fdfed5a 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -146,17 +146,24 @@ encodeString name bytes = mconcat [ " lwmqtt_string_t " <> name <> " = {" <> show (BL.length bytes) <> ", (char*)&" <> name <> "_bytes};\n" ] -genPublishTest :: ProtocolLevel -> Int -> PublishRequest -> IO () +genTestFunc :: (Show a, ByteMe a) => String -> String -> ProtocolLevel -> Int -> a -> String -> String +genTestFunc tset tname prot i p body = let e = toByteString prot p in + mconcat [ + "// ", show p, "\n", + "TEST(", tset, shortprot prot, "QCTest, ", tname, show i <> ") {\n", + "uint8_t pkt[] = {" <> hexa e <> "};\n", + body, "\n", + "}\n\n" + ] + +genPublishTest :: ProtocolLevel -> Int -> PublishRequest -> String genPublishTest prot i p@PublishRequest{..} = - mapM_ (putStrLn . ($toByteString prot p)) [encTest, decTest] + mconcat [encTest, decTest] where - encTest e = mconcat [ - "// ", show p, "\n", - "TEST(Publish" <> shortprot prot <> "QCTest, Encode" <> show i <> ") {\n", - "uint8_t pkt[] = {" <> hexa e <> "};\n", - "\n uint8_t buf[" <> show (BL.length e + 10) <> "] = { 0 };\n", + encTest = genTestFunc "Publish" "Encode" prot i p $ mconcat [ encodeString "topic" _pubTopic, + "\n uint8_t buf[sizeof(pkt)+10] = { 0 };\n", "lwmqtt_message_t msg = lwmqtt_default_message;\n", "msg.qos = " <> qos _pubQoS <> ";\n", "msg.retained = " <> bool _pubRetain <> ";\n", @@ -168,14 +175,10 @@ genPublishTest prot i p@PublishRequest{..} = "lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, " <> protlvl prot <> ", ", bool _pubDup, ", ", show _pubPktID, ", topic, msg, props);\n\n", "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", - "EXPECT_ARRAY_EQ(pkt, buf, len);", - "}\n\n" + "EXPECT_ARRAY_EQ(pkt, buf, len);" ] - decTest e = mconcat [ - "// ", show p, "\n", - "TEST(Publish" <> shortprot prot <> "QCTest, Decode" <> show i <> ") {\n", - "uint8_t pkt[] = {" <> hexa e <> "};\n", + decTest = genTestFunc "Publish" "Decode" prot i p $ mconcat [ "bool dup;\n", "uint16_t packet_id;\n", "lwmqtt_string_t topic;\n", @@ -192,19 +195,14 @@ genPublishTest prot i p@PublishRequest{..} = "EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), ", show (BL.length _pubTopic), ");\n", "EXPECT_EQ(msg.payload_len, ", show (BL.length _pubBody), ");\n", "EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, ", show (BL.length _pubBody), ");\n", - "lwmqtt_string_t x = exp_topic;\nx = exp_body;\n", - "}\n\n" + "lwmqtt_string_t x = exp_topic;\nx = exp_body;\n" ] -genSubTest :: ProtocolLevel -> Int -> SubscribeRequest -> IO () +genSubTest :: ProtocolLevel -> Int -> SubscribeRequest -> String genSubTest prot i p@(SubscribeRequest pid subs props) = do - let e = toByteString prot p - putStrLn . mconcat $ [ - "// ", show p, "\n", - "TEST(Subscribe", shortprot prot, "QCTest, Encode" <> show i <> ") {\n", - "uint8_t pkt[] = {", hexa e, "};\n\n", - "uint8_t buf[", show (BL.length e + 10), "] = { 0 };\n", + genTestFunc "Subscribe" "Encode" prot i p $ mconcat [ + "uint8_t buf[sizeof(pkt)+10] = { 0 };\n", encodeFilters, encodeQos, genProperties "props" props, @@ -212,8 +210,7 @@ genSubTest prot i p@(SubscribeRequest pid subs props) = do " lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, ", protlvl prot, ", ", show pid, ", ", show (length subs), ", topic_filters, qos_levels, props);\n\n", " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", - " EXPECT_ARRAY_EQ(pkt, buf, len);\n", - "}\n" + " EXPECT_ARRAY_EQ(pkt, buf, len);\n" ] where @@ -230,14 +227,10 @@ genSubTest prot i p@(SubscribeRequest pid subs props) = do where aQ (_,SubOptions{..}) = qos _subQoS -genConnectTest :: ProtocolLevel -> Int -> ConnectRequest -> IO () +genConnectTest :: ProtocolLevel -> Int -> ConnectRequest -> String genConnectTest prot i p@ConnectRequest{..} = do - let e = toByteString prot p - putStrLn . mconcat $ [ - "// ", show p, "\n", - "TEST(Connect", shortprot prot, "QCTest, Encode" <> show i <> ") {\n", - "uint8_t pkt[] = {", hexa e, "};\n\n", - "uint8_t buf[", show (BL.length e + 10), "] = { 0 };\n", + genTestFunc "Connect" "Encode" prot i p $ mconcat [ + "uint8_t buf[sizeof(pkt)+10] = { 0 };\n", genProperties "props" _properties, encodeWill _lastWill, @@ -246,8 +239,8 @@ genConnectTest prot i p@ConnectRequest{..} = do "lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, " <> protlvl prot <> ", opts, ", if isJust _lastWill then "&will" else "NULL", ");\n\n", "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", - "EXPECT_ARRAY_EQ(pkt, buf, len);\n", - "}\n" + "EXPECT_EQ(len, sizeof(pkt));\n", + "EXPECT_ARRAY_EQ(pkt, buf, len);\n" ] where @@ -309,13 +302,17 @@ extern "C" { let numTests = 10 pubs <- replicateM numTests $ generate arbitrary - mapM_ (uncurry $ genPublishTest Protocol311) $ zip [1..] (v311PubReq <$> pubs) - mapM_ (uncurry $ genPublishTest Protocol50) $ zip [1..] pubs + f genPublishTest Protocol311 (v311PubReq <$> pubs) + f genPublishTest Protocol50 pubs conns <- replicateM numTests $ generate arbitrary - mapM_ (uncurry $ genConnectTest Protocol311) $ zip [1..] (userFix . v311ConnReq <$> conns) - mapM_ (uncurry $ genConnectTest Protocol50) $ zip [1..] (userFix <$> conns) + f genConnectTest Protocol311 (userFix . v311ConnReq <$> conns) + f genConnectTest Protocol50 (userFix <$> conns) subs <- replicateM numTests $ generate arbitrary - mapM_ (uncurry $ genSubTest Protocol311) $ zip [1..] (v311SubReq <$> subs) - mapM_ (uncurry $ genSubTest Protocol50) $ zip [1..] (simplifySubOptions <$> subs) + f genSubTest Protocol311 (v311SubReq <$> subs) + f genSubTest Protocol50 (simplifySubOptions <$> subs) + + where + f :: (ProtocolLevel -> Int -> a -> String) -> ProtocolLevel -> [a] -> IO () + f g pl l = mapM_ putStrLn $ map (uncurry $ g pl) $ zip [1..] l diff --git a/tests/generated.cpp b/tests/generated.cpp index 9d59501..dd52b9d 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,45 +21,45 @@ extern "C" { } \ } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\226\186&N9\161\169\214\183\fO\210\SYNC\190Hj\233\221\189\173D\191", _pubPktID = 1989, _pubBody = -// "P\197\196\209K[\SOH/\132\207R\165\&9\180D\DLE\250_G\130f\DC2)\140kR", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\225w\176\tH\164\231\182-s\240\201\201&@\253\162=", _pubPktID = 25394, _pubBody = +// "\185\216^\ACKI\148P\180>Z9\192\251\254\US\222C\159,\ACK\FS9\205\218@,o", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x35, 0x35, 0x0, 0x17, 0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, - 0x4f, 0xd2, 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf, 0x7, - 0xc5, 0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, - 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; - - uint8_t buf[65] = {0}; - uint8_t topic_bytes[] = {0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, 0x4f, 0xd2, - 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x31, 0x0, 0x12, 0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, + 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d, 0x63, 0x32, 0xb9, 0xd8, + 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, 0x1f, + 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; + uint8_t topic_bytes[] = {0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, + 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, - 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xb9, 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, + 0x1f, 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 27; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1989, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25394, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\226\186&N9\161\169\214\183\fO\210\SYNC\190Hj\233\221\189\173D\191", _pubPktID = 1989, _pubBody = -// "P\197\196\209K[\SOH/\132\207R\165\&9\180D\DLE\250_G\130f\DC2)\140kR", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\225w\176\tH\164\231\182-s\240\201\201&@\253\162=", _pubPktID = 25394, _pubBody = +// "\185\216^\ACKI\148P\180>Z9\192\251\254\US\222C\159,\ACK\FS9\205\218@,o", _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x35, 0x35, 0x0, 0x17, 0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, - 0x4f, 0xd2, 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf, 0x7, - 0xc5, 0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, - 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; + uint8_t pkt[] = {0x3a, 0x31, 0x0, 0x12, 0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, + 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d, 0x63, 0x32, 0xb9, 0xd8, + 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, 0x1f, + 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -67,59 +67,57 @@ TEST(Publish311QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, 0x4f, 0xd2, - 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, - 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 1989); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + uint8_t exp_topic_bytes[] = {0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, + 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb9, 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, + 0x1f, 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 25394); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\222\145Cc\220\210\226\245x\246qst\249\156\SUB\226\132\137Ys\173(topic.data), 29); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = ",f", _pubPktID = 3323, _pubBody = -// "\130\170\152", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\146,\173K\ETBBf8\150", _pubPktID = +// 137, _pubBody = "\EOTF\225\235\204\DC1\196\244\135L\239L|nO\178\220\210\173\181", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x3a, 0x9, 0x0, 0x2, 0x2c, 0x66, 0xc, 0xfb, 0x82, 0xaa, 0x98}; + uint8_t pkt[] = {0x33, 0x21, 0x0, 0x9, 0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, + 0x96, 0x0, 0x89, 0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, + 0x4c, 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; + uint8_t topic_bytes[] = {0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; - uint8_t buf[21] = {0}; - uint8_t topic_bytes[] = {0x2c, 0x66}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x82, 0xaa, 0x98}; + msg.retained = true; + uint8_t msg_bytes[] = {0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, 0x4c, + 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 20; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 3323, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 137, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = ",f", _pubPktID = 3323, _pubBody = -// "\130\170\152", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\146,\173K\ETBBf8\150", _pubPktID = +// 137, _pubBody = "\EOTF\225\235\204\DC1\196\244\135L\239L|nO\178\220\210\173\181", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x3a, 0x9, 0x0, 0x2, 0x2c, 0x66, 0xc, 0xfb, 0x82, 0xaa, 0x98}; + uint8_t pkt[] = {0x33, 0x21, 0x0, 0x9, 0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, + 0x96, 0x0, 0x89, 0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, + 0x4c, 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -179,36 +182,40 @@ TEST(Publish311QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x2c, 0x66}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x82, 0xaa, 0x98}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, 0x4c, + 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 3323); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 137); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "e\226\145", _pubPktID = 0, _pubBody = -// "\225?\246P\197\165t\243\173C\134\185", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\187\245\185\SOH\nLz\249\&84\221t4:\ACKMBL", _pubPktID = 0, _pubBody = +// "+\154\198\134\210\202d\129:\164\205\152\155'n", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x39, 0x11, 0x0, 0x3, 0x65, 0xe2, 0x91, 0xe1, 0x3f, 0xf6, - 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; - - uint8_t buf[29] = {0}; - uint8_t topic_bytes[] = {0x65, 0xe2, 0x91}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x23, 0x0, 0x12, 0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, + 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c, 0x2b, 0x9a, 0xc6, 0x86, + 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; + uint8_t topic_bytes[] = {0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, + 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; + msg.retained = false; + uint8_t msg_bytes[] = {0x2b, 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; @@ -220,11 +227,13 @@ TEST(Publish311QCTest, Encode4) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "e\226\145", _pubPktID = 0, _pubBody = -// "\225?\246P\197\165t\243\173C\134\185", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\187\245\185\SOH\nLz\249\&84\221t4:\ACKMBL", _pubPktID = 0, _pubBody = +// "+\154\198\134\210\202d\129:\164\205\152\155'n", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x39, 0x11, 0x0, 0x3, 0x65, 0xe2, 0x91, 0xe1, 0x3f, 0xf6, - 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; + uint8_t pkt[] = {0x38, 0x23, 0x0, 0x12, 0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, + 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c, 0x2b, 0x9a, 0xc6, 0x86, + 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -232,34 +241,38 @@ TEST(Publish311QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x65, 0xe2, 0x91}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, + 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2b, 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\191", _pubPktID = 26120, -// _pubBody = "_e(\238\187\252\234\241\201(topic.data), 2); + EXPECT_EQ(packet_id, 16832); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); EXPECT_EQ(msg.payload_len, 15); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\tz\186\176\196\148\DC1", _pubPktID -// = 10274, _pubBody = "\199\149\244", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\&6", _pubPktID = 0, _pubBody = +// "\147\221\242\207\140+To \247\210\244", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x3a, 0xe, 0x0, 0x7, 0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, 0x11, 0x28, 0x22, 0xc7, 0x95, 0xf4}; + uint8_t pkt[] = {0x31, 0x10, 0x0, 0x2, 0xdd, 0x36, 0x93, 0xdd, 0xf2, + 0xcf, 0x8c, 0x2b, 0x54, 0x6f, 0x20, 0xf7, 0xd2, 0xf4}; + uint8_t topic_bytes[] = {0xdd, 0x36}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; - uint8_t buf[26] = {0}; - uint8_t topic_bytes[] = {0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, 0x11}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xc7, 0x95, 0xf4}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x93, 0xdd, 0xf2, 0xcf, 0x8c, 0x2b, 0x54, 0x6f, 0x20, 0xf7, 0xd2, 0xf4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 12; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10274, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\tz\186\176\196\148\DC1", _pubPktID -// = 10274, _pubBody = "\199\149\244", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\&6", _pubPktID = 0, _pubBody = +// "\147\221\242\207\140+To \247\210\244", _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x3a, 0xe, 0x0, 0x7, 0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, 0x11, 0x28, 0x22, 0xc7, 0x95, 0xf4}; + uint8_t pkt[] = {0x31, 0x10, 0x0, 0x2, 0xdd, 0x36, 0x93, 0xdd, 0xf2, + 0xcf, 0x8c, 0x2b, 0x54, 0x6f, 0x20, 0xf7, 0xd2, 0xf4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -336,57 +354,58 @@ TEST(Publish311QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9, 0x7a, 0xba, 0xb0, 0xc4, 0x94, 0x11}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc7, 0x95, 0xf4}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10274); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + uint8_t exp_topic_bytes[] = {0xdd, 0x36}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x93, 0xdd, 0xf2, 0xcf, 0x8c, 0x2b, 0x54, 0x6f, 0x20, 0xf7, 0xd2, 0xf4}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "l\GS\SO\SI\176\NAKT\189\t0b\NUL\154#1", _pubPktID = 0, _pubBody = -// "\180v\132PX\145\222\160?9\205\204\241\168\&5<\235\222\160\\\190Tg\128", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\t[\147\134\211N\220\217R\CAN\NAK\\\186G\DLE\137\189\166\158\221=\171", _pubPktID = 2127, _pubBody = +// "n\\\\\STX\237\196\179\185\241\214\171\SO'\156\228!\240\230\146", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x31, 0x29, 0x0, 0xf, 0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, - 0x0, 0x9a, 0x23, 0x31, 0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, 0x3f, 0x39, 0xcd, - 0xcc, 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; - - uint8_t buf[53] = {0}; - uint8_t topic_bytes[] = {0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, 0x0, 0x9a, 0x23, 0x31}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x2d, 0x0, 0x16, 0x9, 0x5b, 0x93, 0x86, 0xd3, 0x4e, 0xdc, 0xd9, 0x52, 0x18, 0x15, 0x5c, + 0xba, 0x47, 0x10, 0x89, 0xbd, 0xa6, 0x9e, 0xdd, 0x3d, 0xab, 0x8, 0x4f, 0x6e, 0x5c, 0x5c, 0x2, + 0xed, 0xc4, 0xb3, 0xb9, 0xf1, 0xd6, 0xab, 0xe, 0x27, 0x9c, 0xe4, 0x21, 0xf0, 0xe6, 0x92}; + uint8_t topic_bytes[] = {0x9, 0x5b, 0x93, 0x86, 0xd3, 0x4e, 0xdc, 0xd9, 0x52, 0x18, 0x15, + 0x5c, 0xba, 0x47, 0x10, 0x89, 0xbd, 0xa6, 0x9e, 0xdd, 0x3d, 0xab}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, 0x3f, 0x39, 0xcd, 0xcc, - 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x6e, 0x5c, 0x5c, 0x2, 0xed, 0xc4, 0xb3, 0xb9, 0xf1, 0xd6, + 0xab, 0xe, 0x27, 0x9c, 0xe4, 0x21, 0xf0, 0xe6, 0x92}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2127, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "l\GS\SO\SI\176\NAKT\189\t0b\NUL\154#1", _pubPktID = 0, _pubBody = -// "\180v\132PX\145\222\160?9\205\204\241\168\&5<\235\222\160\\\190Tg\128", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\t[\147\134\211N\220\217R\CAN\NAK\\\186G\DLE\137\189\166\158\221=\171", _pubPktID = 2127, _pubBody = +// "n\\\\\STX\237\196\179\185\241\214\171\SO'\156\228!\240\230\146", _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x31, 0x29, 0x0, 0xf, 0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, - 0x0, 0x9a, 0x23, 0x31, 0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, 0x3f, 0x39, 0xcd, - 0xcc, 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; + uint8_t pkt[] = {0x3c, 0x2d, 0x0, 0x16, 0x9, 0x5b, 0x93, 0x86, 0xd3, 0x4e, 0xdc, 0xd9, 0x52, 0x18, 0x15, 0x5c, + 0xba, 0x47, 0x10, 0x89, 0xbd, 0xa6, 0x9e, 0xdd, 0x3d, 0xab, 0x8, 0x4f, 0x6e, 0x5c, 0x5c, 0x2, + 0xed, 0xc4, 0xb3, 0xb9, 0xf1, 0xd6, 0xab, 0xe, 0x27, 0x9c, 0xe4, 0x21, 0xf0, 0xe6, 0x92}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -394,54 +413,59 @@ TEST(Publish311QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, 0x0, 0x9a, 0x23, 0x31}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, 0x3f, 0x39, 0xcd, 0xcc, - 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + uint8_t exp_topic_bytes[] = {0x9, 0x5b, 0x93, 0x86, 0xd3, 0x4e, 0xdc, 0xd9, 0x52, 0x18, 0x15, + 0x5c, 0xba, 0x47, 0x10, 0x89, 0xbd, 0xa6, 0x9e, 0xdd, 0x3d, 0xab}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x6e, 0x5c, 0x5c, 0x2, 0xed, 0xc4, 0xb3, 0xb9, 0xf1, 0xd6, + 0xab, 0xe, 0x27, 0x9c, 0xe4, 0x21, 0xf0, 0xe6, 0x92}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 2127); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\244_\249R\255\232t\194", _pubPktID -// = 4521, _pubBody = "\213\SOQ\252\167\179#\DEL\SIc\223\EOT\156\210\214\bp", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\148\134\&7\254W\239\197z\v\194\253\227\173o\163\251m\138", _pubPktID = 0, _pubBody = +// "\136i\178\239\188AL\167x\230\227\NULnK\187", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x35, 0x1d, 0x0, 0x8, 0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2, 0x11, 0xa9, 0xd5, 0xe, - 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; - - uint8_t buf[41] = {0}; - uint8_t topic_bytes[] = {0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x23, 0x0, 0x12, 0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, + 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a, 0x88, 0x69, 0xb2, 0xef, + 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; + uint8_t topic_bytes[] = {0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, + 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xd5, 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, - 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x88, 0x69, 0xb2, 0xef, 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 4521, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\244_\249R\255\232t\194", _pubPktID -// = 4521, _pubBody = "\213\SOQ\252\167\179#\DEL\SIc\223\EOT\156\210\214\bp", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\148\134\&7\254W\239\197z\v\194\253\227\173o\163\251m\138", _pubPktID = 0, _pubBody = +// "\136i\178\239\188AL\167x\230\227\NULnK\187", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x35, 0x1d, 0x0, 0x8, 0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2, 0x11, 0xa9, 0xd5, 0xe, - 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; + uint8_t pkt[] = {0x30, 0x23, 0x0, 0x12, 0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, + 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a, 0x88, 0x69, 0xb2, 0xef, + 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -449,61 +473,55 @@ TEST(Publish311QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd5, 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, - 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, + 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x88, 0x69, 0xb2, 0xef, 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 4521); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "a\239\170\203|\"\t\198g\b\v[V\ETXkc\GS+\205\&5Q13M\196E", _pubPktID = 21638, _pubBody = -// "\NAK\153\221\DC3\250(2\DC2\166z\179\183Z\205>5\158\160\245", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "V\DC1\RS\130\DLE\233\142\210e4%k~\132\153", _pubPktID = 0, _pubBody = +// "\200\ENQr=\212\221i\147\216\&3\ENQpG\250\147", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x3d, 0x31, 0x0, 0x1a, 0x61, 0xef, 0xaa, 0xcb, 0x7c, 0x22, 0x9, 0xc6, 0x67, - 0x8, 0xb, 0x5b, 0x56, 0x3, 0x6b, 0x63, 0x1d, 0x2b, 0xcd, 0x35, 0x51, 0x31, - 0x33, 0x4d, 0xc4, 0x45, 0x54, 0x86, 0x15, 0x99, 0xdd, 0x13, 0xfa, 0x28, 0x32, - 0x12, 0xa6, 0x7a, 0xb3, 0xb7, 0x5a, 0xcd, 0x3e, 0x35, 0x9e, 0xa0, 0xf5}; - - uint8_t buf[61] = {0}; - uint8_t topic_bytes[] = {0x61, 0xef, 0xaa, 0xcb, 0x7c, 0x22, 0x9, 0xc6, 0x67, 0x8, 0xb, 0x5b, 0x56, - 0x3, 0x6b, 0x63, 0x1d, 0x2b, 0xcd, 0x35, 0x51, 0x31, 0x33, 0x4d, 0xc4, 0x45}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x20, 0x0, 0xf, 0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, 0x65, 0x34, 0x25, 0x6b, 0x7e, + 0x84, 0x99, 0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; + uint8_t topic_bytes[] = {0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, 0x65, 0x34, 0x25, 0x6b, 0x7e, 0x84, 0x99}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x15, 0x99, 0xdd, 0x13, 0xfa, 0x28, 0x32, 0x12, 0xa6, 0x7a, - 0xb3, 0xb7, 0x5a, 0xcd, 0x3e, 0x35, 0x9e, 0xa0, 0xf5}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 21638, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "a\239\170\203|\"\t\198g\b\v[V\ETXkc\GS+\205\&5Q13M\196E", _pubPktID = 21638, _pubBody = -// "\NAK\153\221\DC3\250(2\DC2\166z\179\183Z\205>5\158\160\245", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "V\DC1\RS\130\DLE\233\142\210e4%k~\132\153", _pubPktID = 0, _pubBody = +// "\200\ENQr=\212\221i\147\216\&3\ENQpG\250\147", _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x3d, 0x31, 0x0, 0x1a, 0x61, 0xef, 0xaa, 0xcb, 0x7c, 0x22, 0x9, 0xc6, 0x67, - 0x8, 0xb, 0x5b, 0x56, 0x3, 0x6b, 0x63, 0x1d, 0x2b, 0xcd, 0x35, 0x51, 0x31, - 0x33, 0x4d, 0xc4, 0x45, 0x54, 0x86, 0x15, 0x99, 0xdd, 0x13, 0xfa, 0x28, 0x32, - 0x12, 0xa6, 0x7a, 0xb3, 0xb7, 0x5a, 0xcd, 0x3e, 0x35, 0x9e, 0xa0, 0xf5}; + uint8_t pkt[] = {0x30, 0x20, 0x0, 0xf, 0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, 0x65, 0x34, 0x25, 0x6b, 0x7e, + 0x84, 0x99, 0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -511,62 +529,59 @@ TEST(Publish311QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x61, 0xef, 0xaa, 0xcb, 0x7c, 0x22, 0x9, 0xc6, 0x67, 0x8, 0xb, 0x5b, 0x56, - 0x3, 0x6b, 0x63, 0x1d, 0x2b, 0xcd, 0x35, 0x51, 0x31, 0x33, 0x4d, 0xc4, 0x45}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x15, 0x99, 0xdd, 0x13, 0xfa, 0x28, 0x32, 0x12, 0xa6, 0x7a, - 0xb3, 0xb7, 0x5a, 0xcd, 0x3e, 0x35, 0x9e, 0xa0, 0xf5}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 21638); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + uint8_t exp_topic_bytes[] = {0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, + 0x65, 0x34, 0x25, 0x6b, 0x7e, 0x84, 0x99}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "3\DC2\163\160\US\252\129\206\EMa\SYN\ESC\248J%\210\t0\224\159T\165\137&\153", _pubPktID = 14459, _pubBody = -// "\161;R\191\DC4\212,\ETB\168<\r}\244\250\&6\145_\153\241\218\175\133\NAK\SO\234\f", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\160\NAK\234\249\209\141\136\198?\243\245hW6\199=`\243C|RQ\216v@\r", _pubPktID = 19217, _pubBody = +// "\212m\146de\171\221qv\142\228\171\234S7\162", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x35, 0x37, 0x0, 0x19, 0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, - 0x1b, 0xf8, 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99, 0x38, - 0x7b, 0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, 0xfa, - 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; - - uint8_t buf[67] = {0}; - uint8_t topic_bytes[] = {0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, 0xf8, - 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x1a, 0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, + 0x57, 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd, 0x4b, 0x11, + 0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; + uint8_t topic_bytes[] = {0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, + 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, - 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; + msg.retained = false; + uint8_t msg_bytes[] = {0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, + 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 16; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 14459, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19217, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "3\DC2\163\160\US\252\129\206\EMa\SYN\ESC\248J%\210\t0\224\159T\165\137&\153", _pubPktID = 14459, _pubBody = -// "\161;R\191\DC4\212,\ETB\168<\r}\244\250\&6\145_\153\241\218\175\133\NAK\SO\234\f", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\160\NAK\234\249\209\141\136\198?\243\245hW6\199=`\243C|RQ\216v@\r", _pubPktID = 19217, _pubBody = +// "\212m\146de\171\221qv\142\228\171\234S7\162", _pubProps = []} TEST(Publish311QCTest, Decode10) { - uint8_t pkt[] = {0x35, 0x37, 0x0, 0x19, 0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, - 0x1b, 0xf8, 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99, 0x38, - 0x7b, 0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, 0xfa, - 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; + uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x1a, 0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, + 0x57, 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd, 0x4b, 0x11, + 0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -574,136 +589,111 @@ TEST(Publish311QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, 0xf8, - 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, - 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, + 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, + 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 14459); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 19217); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\226\186&N9\161\169\214\183\fO\210\SYNC\190Hj\233\221\189\173D\191", _pubPktID = 1989, _pubBody = -// "P\197\196\209K[\SOH/\132\207R\165\&9\180D\DLE\250_G\130f\DC2)\140kR", _pubProps = [PropResponseTopic -// "\225k\246\nM\143\253\170\FS\159\167\132G\185\152\160\223\196\218\223\217\252\137\223\157\DC2",PropRequestProblemInformation -// 123,PropTopicAlias 9167,PropReceiveMaximum 9103,PropRequestResponseInformation 66,PropMaximumQoS 202,PropUserProperty -// "\245\140L\167\136,6\243\248\200\229\211p'\139\t\CAN4\144\170\&5st\202\235\198o" -// "\159\133\232\&9\186?\GS9b\NAK\167\182\148\130\141\238=\152\217y\174\230\FSZi\235@\SI\129\198",PropSubscriptionIdentifier -// 15,PropUserProperty "\131\244\131Q\ENQ\ETB\170\172Ka\ENQU\r\DEL\bJ\181\DLE" -// "D\163z38\186\137\129\DC1\254\215\221\ETX\NUL9\183e\172\182\225\210 \239",PropMaximumPacketSize -// 2615,PropSessionExpiryInterval 1558,PropSessionExpiryInterval 31946,PropAssignedClientIdentifier -// ":}\236\160G\147\239n\209c\233d\133\230\188\196\&18\228\DLE/d\192|\222\NULMb\190",PropResponseInformation -// "hl]",PropMessageExpiryInterval 9713,PropWildcardSubscriptionAvailable 28,PropSessionExpiryInterval 14464]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\225w\176\tH\164\231\182-s\240\201\201&@\253\162=", _pubPktID = 25394, _pubBody = +// "\185\216^\ACKI\148P\180>Z9\192\251\254\US\222C\159,\ACK\FS9\205\218@,o", _pubProps = [PropMessageExpiryInterval +// 27711,PropContentType +// "\204\140N\146\vX\bI\130\SOH@'\ETX\182\153\228\142\DC1\247\199R\244",PropWildcardSubscriptionAvailable +// 60,PropWildcardSubscriptionAvailable 45,PropResponseTopic +// "\DEL%\181E\EOT\168\169W?u.;\167\236-\ETX$\USt@\189T\237p\210=",PropAuthenticationData "\161",PropTopicAliasMaximum +// 11625,PropMaximumPacketSize 920,PropSharedSubscriptionAvailable 60,PropWillDelayInterval +// 13422,PropSessionExpiryInterval 17640,PropWildcardSubscriptionAvailable 208,PropMaximumPacketSize +// 13876,PropMaximumQoS 30,PropAuthenticationData "P\128U\"\151\193\151D\169\&8"]} TEST(Publish5QCTest, Encode1) { - uint8_t pkt[] = { - 0x35, 0x8f, 0x2, 0x0, 0x17, 0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, 0x4f, 0xd2, 0x16, 0x43, - 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf, 0x7, 0xc5, 0xd8, 0x1, 0x8, 0x0, 0x1a, 0xe1, 0x6b, 0xf6, - 0xa, 0x4d, 0x8f, 0xfd, 0xaa, 0x1c, 0x9f, 0xa7, 0x84, 0x47, 0xb9, 0x98, 0xa0, 0xdf, 0xc4, 0xda, 0xdf, 0xd9, 0xfc, - 0x89, 0xdf, 0x9d, 0x12, 0x17, 0x7b, 0x23, 0x23, 0xcf, 0x21, 0x23, 0x8f, 0x19, 0x42, 0x24, 0xca, 0x26, 0x0, 0x1b, - 0xf5, 0x8c, 0x4c, 0xa7, 0x88, 0x2c, 0x36, 0xf3, 0xf8, 0xc8, 0xe5, 0xd3, 0x70, 0x27, 0x8b, 0x9, 0x18, 0x34, 0x90, - 0xaa, 0x35, 0x73, 0x74, 0xca, 0xeb, 0xc6, 0x6f, 0x0, 0x1e, 0x9f, 0x85, 0xe8, 0x39, 0xba, 0x3f, 0x1d, 0x39, 0x62, - 0x15, 0xa7, 0xb6, 0x94, 0x82, 0x8d, 0xee, 0x3d, 0x98, 0xd9, 0x79, 0xae, 0xe6, 0x1c, 0x5a, 0x69, 0xeb, 0x40, 0xf, - 0x81, 0xc6, 0xb, 0xf, 0x26, 0x0, 0x12, 0x83, 0xf4, 0x83, 0x51, 0x5, 0x17, 0xaa, 0xac, 0x4b, 0x61, 0x5, 0x55, - 0xd, 0x7f, 0x8, 0x4a, 0xb5, 0x10, 0x0, 0x17, 0x44, 0xa3, 0x7a, 0x33, 0x38, 0xba, 0x89, 0x81, 0x11, 0xfe, 0xd7, - 0xdd, 0x3, 0x0, 0x39, 0xb7, 0x65, 0xac, 0xb6, 0xe1, 0xd2, 0x20, 0xef, 0x27, 0x0, 0x0, 0xa, 0x37, 0x11, 0x0, - 0x0, 0x6, 0x16, 0x11, 0x0, 0x0, 0x7c, 0xca, 0x12, 0x0, 0x1d, 0x3a, 0x7d, 0xec, 0xa0, 0x47, 0x93, 0xef, 0x6e, - 0xd1, 0x63, 0xe9, 0x64, 0x85, 0xe6, 0xbc, 0xc4, 0x31, 0x38, 0xe4, 0x10, 0x2f, 0x64, 0xc0, 0x7c, 0xde, 0x0, 0x4d, - 0x62, 0xbe, 0x1a, 0x0, 0x3, 0x68, 0x6c, 0x5d, 0x2, 0x0, 0x0, 0x25, 0xf1, 0x28, 0x1c, 0x11, 0x0, 0x0, 0x38, - 0x80, 0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, 0xb4, 0x44, 0x10, 0xfa, 0x5f, - 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; - - uint8_t buf[284] = {0}; - uint8_t topic_bytes[] = {0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, 0x4f, 0xd2, - 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x9f, 0x1, 0x0, 0x12, 0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, 0x73, 0xf0, 0xc9, + 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d, 0x63, 0x32, 0x6d, 0x2, 0x0, 0x0, 0x6c, 0x3f, 0x3, 0x0, 0x16, + 0xcc, 0x8c, 0x4e, 0x92, 0xb, 0x58, 0x8, 0x49, 0x82, 0x1, 0x40, 0x27, 0x3, 0xb6, 0x99, 0xe4, 0x8e, + 0x11, 0xf7, 0xc7, 0x52, 0xf4, 0x28, 0x3c, 0x28, 0x2d, 0x8, 0x0, 0x1a, 0x7f, 0x25, 0xb5, 0x45, 0x4, + 0xa8, 0xa9, 0x57, 0x3f, 0x75, 0x2e, 0x3b, 0xa7, 0xec, 0x2d, 0x3, 0x24, 0x1f, 0x74, 0x40, 0xbd, 0x54, + 0xed, 0x70, 0xd2, 0x3d, 0x16, 0x0, 0x1, 0xa1, 0x22, 0x2d, 0x69, 0x27, 0x0, 0x0, 0x3, 0x98, 0x2a, + 0x3c, 0x18, 0x0, 0x0, 0x34, 0x6e, 0x11, 0x0, 0x0, 0x44, 0xe8, 0x28, 0xd0, 0x27, 0x0, 0x0, 0x36, + 0x34, 0x24, 0x1e, 0x16, 0x0, 0xa, 0x50, 0x80, 0x55, 0x22, 0x97, 0xc1, 0x97, 0x44, 0xa9, 0x38, 0xb9, + 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, 0x1f, 0xde, 0x43, 0x9f, + 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; + uint8_t topic_bytes[] = {0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, + 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, - 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xb9, 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, + 0x1f, 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; - - uint8_t bytesprops0[] = {0xe1, 0x6b, 0xf6, 0xa, 0x4d, 0x8f, 0xfd, 0xaa, 0x1c, 0x9f, 0xa7, 0x84, 0x47, - 0xb9, 0x98, 0xa0, 0xdf, 0xc4, 0xda, 0xdf, 0xd9, 0xfc, 0x89, 0xdf, 0x9d, 0x12}; - uint8_t bytesprops2[] = {0x9f, 0x85, 0xe8, 0x39, 0xba, 0x3f, 0x1d, 0x39, 0x62, 0x15, 0xa7, 0xb6, 0x94, 0x82, 0x8d, - 0xee, 0x3d, 0x98, 0xd9, 0x79, 0xae, 0xe6, 0x1c, 0x5a, 0x69, 0xeb, 0x40, 0xf, 0x81, 0xc6}; - uint8_t bytesprops1[] = {0xf5, 0x8c, 0x4c, 0xa7, 0x88, 0x2c, 0x36, 0xf3, 0xf8, 0xc8, 0xe5, 0xd3, 0x70, 0x27, - 0x8b, 0x9, 0x18, 0x34, 0x90, 0xaa, 0x35, 0x73, 0x74, 0xca, 0xeb, 0xc6, 0x6f}; - uint8_t bytesprops4[] = {0x44, 0xa3, 0x7a, 0x33, 0x38, 0xba, 0x89, 0x81, 0x11, 0xfe, 0xd7, 0xdd, - 0x3, 0x0, 0x39, 0xb7, 0x65, 0xac, 0xb6, 0xe1, 0xd2, 0x20, 0xef}; - uint8_t bytesprops3[] = {0x83, 0xf4, 0x83, 0x51, 0x5, 0x17, 0xaa, 0xac, 0x4b, - 0x61, 0x5, 0x55, 0xd, 0x7f, 0x8, 0x4a, 0xb5, 0x10}; - uint8_t bytesprops5[] = {0x3a, 0x7d, 0xec, 0xa0, 0x47, 0x93, 0xef, 0x6e, 0xd1, 0x63, 0xe9, 0x64, 0x85, 0xe6, 0xbc, - 0xc4, 0x31, 0x38, 0xe4, 0x10, 0x2f, 0x64, 0xc0, 0x7c, 0xde, 0x0, 0x4d, 0x62, 0xbe}; - uint8_t bytesprops6[] = {0x68, 0x6c, 0x5d}; + msg.payload_len = 27; + + uint8_t bytesprops0[] = {0xcc, 0x8c, 0x4e, 0x92, 0xb, 0x58, 0x8, 0x49, 0x82, 0x1, 0x40, + 0x27, 0x3, 0xb6, 0x99, 0xe4, 0x8e, 0x11, 0xf7, 0xc7, 0x52, 0xf4}; + uint8_t bytesprops1[] = {0x7f, 0x25, 0xb5, 0x45, 0x4, 0xa8, 0xa9, 0x57, 0x3f, 0x75, 0x2e, 0x3b, 0xa7, + 0xec, 0x2d, 0x3, 0x24, 0x1f, 0x74, 0x40, 0xbd, 0x54, 0xed, 0x70, 0xd2, 0x3d}; + uint8_t bytesprops2[] = {0xa1}; + uint8_t bytesprops3[] = {0x50, 0x80, 0x55, 0x22, 0x97, 0xc1, 0x97, 0x44, 0xa9, 0x38}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9167}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9103}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops3}, .v = {23, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2615}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1558}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31946}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9713}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14464}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27711}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11625}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 920}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13422}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17640}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13876}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1989, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25394, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\226\186&N9\161\169\214\183\fO\210\SYNC\190Hj\233\221\189\173D\191", _pubPktID = 1989, _pubBody = -// "P\197\196\209K[\SOH/\132\207R\165\&9\180D\DLE\250_G\130f\DC2)\140kR", _pubProps = [PropResponseTopic -// "\225k\246\nM\143\253\170\FS\159\167\132G\185\152\160\223\196\218\223\217\252\137\223\157\DC2",PropRequestProblemInformation -// 123,PropTopicAlias 9167,PropReceiveMaximum 9103,PropRequestResponseInformation 66,PropMaximumQoS 202,PropUserProperty -// "\245\140L\167\136,6\243\248\200\229\211p'\139\t\CAN4\144\170\&5st\202\235\198o" -// "\159\133\232\&9\186?\GS9b\NAK\167\182\148\130\141\238=\152\217y\174\230\FSZi\235@\SI\129\198",PropSubscriptionIdentifier -// 15,PropUserProperty "\131\244\131Q\ENQ\ETB\170\172Ka\ENQU\r\DEL\bJ\181\DLE" -// "D\163z38\186\137\129\DC1\254\215\221\ETX\NUL9\183e\172\182\225\210 \239",PropMaximumPacketSize -// 2615,PropSessionExpiryInterval 1558,PropSessionExpiryInterval 31946,PropAssignedClientIdentifier -// ":}\236\160G\147\239n\209c\233d\133\230\188\196\&18\228\DLE/d\192|\222\NULMb\190",PropResponseInformation -// "hl]",PropMessageExpiryInterval 9713,PropWildcardSubscriptionAvailable 28,PropSessionExpiryInterval 14464]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\225w\176\tH\164\231\182-s\240\201\201&@\253\162=", _pubPktID = 25394, _pubBody = +// "\185\216^\ACKI\148P\180>Z9\192\251\254\US\222C\159,\ACK\FS9\205\218@,o", _pubProps = [PropMessageExpiryInterval +// 27711,PropContentType +// "\204\140N\146\vX\bI\130\SOH@'\ETX\182\153\228\142\DC1\247\199R\244",PropWildcardSubscriptionAvailable +// 60,PropWildcardSubscriptionAvailable 45,PropResponseTopic +// "\DEL%\181E\EOT\168\169W?u.;\167\236-\ETX$\USt@\189T\237p\210=",PropAuthenticationData "\161",PropTopicAliasMaximum +// 11625,PropMaximumPacketSize 920,PropSharedSubscriptionAvailable 60,PropWillDelayInterval +// 13422,PropSessionExpiryInterval 17640,PropWildcardSubscriptionAvailable 208,PropMaximumPacketSize +// 13876,PropMaximumQoS 30,PropAuthenticationData "P\128U\"\151\193\151D\169\&8"]} TEST(Publish5QCTest, Decode1) { - uint8_t pkt[] = { - 0x35, 0x8f, 0x2, 0x0, 0x17, 0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, 0x4f, 0xd2, 0x16, 0x43, - 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf, 0x7, 0xc5, 0xd8, 0x1, 0x8, 0x0, 0x1a, 0xe1, 0x6b, 0xf6, - 0xa, 0x4d, 0x8f, 0xfd, 0xaa, 0x1c, 0x9f, 0xa7, 0x84, 0x47, 0xb9, 0x98, 0xa0, 0xdf, 0xc4, 0xda, 0xdf, 0xd9, 0xfc, - 0x89, 0xdf, 0x9d, 0x12, 0x17, 0x7b, 0x23, 0x23, 0xcf, 0x21, 0x23, 0x8f, 0x19, 0x42, 0x24, 0xca, 0x26, 0x0, 0x1b, - 0xf5, 0x8c, 0x4c, 0xa7, 0x88, 0x2c, 0x36, 0xf3, 0xf8, 0xc8, 0xe5, 0xd3, 0x70, 0x27, 0x8b, 0x9, 0x18, 0x34, 0x90, - 0xaa,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 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, 0x73, 0xf0, 0xc9, + 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d, 0x63, 0x32, 0x6d, 0x2, 0x0, 0x0, 0x6c, 0x3f, 0x3, 0x0, 0x16, + 0xcc, 0x8c, 0x4e, 0x92, 0xb, 0x58, 0x8, 0x49, 0x82, 0x1, 0x40, 0x27, 0x3, 0xb6, 0x99, 0xe4, 0x8e, + 0x11, 0xf7, 0xc7, 0x52, 0xf4, 0x28, 0x3c, 0x28, 0x2d, 0x8, 0x0, 0x1a, 0x7f, 0x25, 0xb5, 0x45, 0x4, + 0xa8, 0xa9, 0x57, 0x3f, 0x75, 0x2e, 0x3b, 0xa7, 0xec, 0x2d, 0x3, 0x24, 0x1f, 0x74, 0x40, 0xbd, 0x54, + 0xed, 0x70, 0xd2, 0x3d, 0x16, 0x0, 0x1, 0xa1, 0x22, 0x2d, 0x69, 0x27, 0x0, 0x0, 0x3, 0x98, 0x2a, + 0x3c, 0x18, 0x0, 0x0, 0x34, 0x6e, 0x11, 0x0, 0x0, 0x44, 0xe8, 0x28, 0xd0, 0x27, 0x0, 0x0, 0x36, + 0x34, 0x24, 0x1e, 0x16, 0x0, 0xa, 0x50, 0x80, 0x55, 0x22, 0x97, 0xc1, 0x97, 0x44, 0xa9, 0x38, 0xb9, + 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, 0x1f, 0xde, 0x43, 0x9f, + 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -711,149 +701,81 @@ TEST(Publish5QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe2, 0xba, 0x26, 0x4e, 0x39, 0xa1, 0xa9, 0xd6, 0xb7, 0xc, 0x4f, 0xd2, - 0x16, 0x43, 0xbe, 0x48, 0x6a, 0xe9, 0xdd, 0xbd, 0xad, 0x44, 0xbf}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x50, 0xc5, 0xc4, 0xd1, 0x4b, 0x5b, 0x1, 0x2f, 0x84, 0xcf, 0x52, 0xa5, 0x39, - 0xb4, 0x44, 0x10, 0xfa, 0x5f, 0x47, 0x82, 0x66, 0x12, 0x29, 0x8c, 0x6b, 0x52}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 1989); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + uint8_t exp_topic_bytes[] = {0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, + 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb9, 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, + 0x1f, 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 25394); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\222\145Cc\220\210\226\245x\246qst\249\156\SUB\226\132\137Ys\173\176\137-\176\137-(topic.data), 29); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = ",f", _pubPktID = 3323, _pubBody = -// "\130\170\152", _pubProps = [PropRetainAvailable 140,PropServerKeepAlive 6795,PropReceiveMaximum -// 17419,PropReasonString "\149",PropUserProperty "\172WQ\136i\193\150\253\185z\190\187\231Z\fn\RS\161\147\165 -// \186\&0\172\&7\164\228p\240\DC1" "/\SYN\163",PropServerReference "\149\ACKx\243_",PropAuthenticationData -// "\184\166\234,$\137\154Q",PropReceiveMaximum 29340,PropSessionExpiryInterval 4083,PropMaximumPacketSize -// 6103,PropServerReference -// "\233\214B\196'8\203\143=\215g\182\136\181\243K\218\ETB+\129\134v\SUBug}Dz^",PropResponseTopic -// "\SIg\r\141f\163J\DLEtR'\170\129\222\207\245\144\ETX\223=\227",PropTopicAliasMaximum 2774,PropUserProperty "\ETX" -// "\ETB\161\194\254\224\136\DEL\212\133\EOTif\249\234n\189\234\205h\EOT\196\134\&5\190\RS!O",PropSubscriptionIdentifierAvailable -// 229,PropTopicAliasMaximum 31358,PropMaximumQoS 169]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\146,\173K\ETBBf8\150", _pubPktID = +// 137, _pubBody = "\EOTF\225\235\204\DC1\196\244\135L\239L|nO\178\220\210\173\181", _pubProps = +// [PropResponseInformation +// "\168\187\241F\ETX\DC3\226\235\216?P\236\139p3\137\ENQG\US\171\182\201+U\227\FS\239S",PropReasonString +// "!\212\NAKt\223\170\223\228\158\216\161[@\235\207\t",PropSubscriptionIdentifier 7,PropMaximumPacketSize +// 1128,PropRequestResponseInformation 151,PropContentType +// "\\\182\217\180\DC3\144C\178\191w3\176\185w\187\176\213\164'B\157",PropResponseTopic +// "\213x\192RF\DLE\DC3\170\182Y\SON\132\170\221\FSG8R"]} TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = {0x3a, 0xc0, 0x1, 0x0, 0x2, 0x2c, 0x66, 0xc, 0xfb, 0xb5, 0x1, 0x25, 0x8c, 0x13, 0x1a, 0x8b, 0x21, - 0x44, 0xb, 0x1f, 0x0, 0x1, 0x95, 0x26, 0x0, 0x1e, 0xac, 0x57, 0x51, 0x88, 0x69, 0xc1, 0x96, 0xfd, - 0xb9, 0x7a, 0xbe, 0xbb, 0xe7, 0x5a, 0xc, 0x6e, 0x1e, 0xa1, 0x93, 0xa5, 0x20, 0xba, 0x30, 0xac, 0x37, - 0xa4, 0xe4, 0x70, 0xf0, 0x11, 0x0, 0x3, 0x2f, 0x16, 0xa3, 0x1c, 0x0, 0x5, 0x95, 0x6, 0x78, 0xf3, - 0x5f, 0x16, 0x0, 0x8, 0xb8, 0xa6, 0xea, 0x2c, 0x24, 0x89, 0x9a, 0x51, 0x21, 0x72, 0x9c, 0x11, 0x0, - 0x0, 0xf, 0xf3, 0x27, 0x0, 0x0, 0x17, 0xd7, 0x1c, 0x0, 0x1d, 0xe9, 0xd6, 0x42, 0xc4, 0x27, 0x38, - 0xcb, 0x8f, 0x3d, 0xd7, 0x67, 0xb6, 0x88, 0xb5, 0xf3, 0x4b, 0xda, 0x17, 0x2b, 0x81, 0x86, 0x76, 0x1a, - 0x75, 0x67, 0x7d, 0x44, 0x7a, 0x5e, 0x8, 0x0, 0x15, 0xf, 0x67, 0xd, 0x8d, 0x66, 0xa3, 0x4a, 0x10, - 0x74, 0x52, 0x27, 0xaa, 0x81, 0xde, 0xcf, 0xf5, 0x90, 0x3, 0xdf, 0x3d, 0xe3, 0x22, 0xa, 0xd6, 0x26, - 0x0, 0x1, 0x3, 0x0, 0x1b, 0x17, 0xa1, 0xc2, 0xfe, 0xe0, 0x88, 0x7f, 0xd4, 0x85, 0x4, 0x69, 0x66, - 0xf9, 0xea, 0x6e, 0xbd, 0xea, 0xcd, 0x68, 0x4, 0xc4, 0x86, 0x35, 0xbe, 0x1e, 0x21, 0x4f, 0x29, 0xe5, - 0x22, 0x7a, 0x7e, 0x24, 0xa9, 0x82, 0xaa, 0x98}; - - uint8_t buf[205] = {0}; - uint8_t topic_bytes[] = {0x2c, 0x66}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x8b, 0x1, 0x0, 0x9, 0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96, 0x0, 0x89, + 0x69, 0x1a, 0x0, 0x1c, 0xa8, 0xbb, 0xf1, 0x46, 0x3, 0x13, 0xe2, 0xeb, 0xd8, 0x3f, 0x50, 0xec, + 0x8b, 0x70, 0x33, 0x89, 0x5, 0x47, 0x1f, 0xab, 0xb6, 0xc9, 0x2b, 0x55, 0xe3, 0x1c, 0xef, 0x53, + 0x1f, 0x0, 0x10, 0x21, 0xd4, 0x15, 0x74, 0xdf, 0xaa, 0xdf, 0xe4, 0x9e, 0xd8, 0xa1, 0x5b, 0x40, + 0xeb, 0xcf, 0x9, 0xb, 0x7, 0x27, 0x0, 0x0, 0x4, 0x68, 0x19, 0x97, 0x3, 0x0, 0x15, 0x5c, + 0xb6, 0xd9, 0xb4, 0x13, 0x90, 0x43, 0xb2, 0xbf, 0x77, 0x33, 0xb0, 0xb9, 0x77, 0xbb, 0xb0, 0xd5, + 0xa4, 0x27, 0x42, 0x9d, 0x8, 0x0, 0x13, 0xd5, 0x78, 0xc0, 0x52, 0x46, 0x10, 0x13, 0xaa, 0xb6, + 0x59, 0xe, 0x4e, 0x84, 0xaa, 0xdd, 0x1c, 0x47, 0x38, 0x52, 0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, + 0xc4, 0xf4, 0x87, 0x4c, 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; + uint8_t topic_bytes[] = {0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x82, 0xaa, 0x98}; + msg.retained = true; + uint8_t msg_bytes[] = {0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, 0x4c, + 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; - - uint8_t bytesprops0[] = {0x95}; - uint8_t bytesprops2[] = {0x2f, 0x16, 0xa3}; - uint8_t bytesprops1[] = {0xac, 0x57, 0x51, 0x88, 0x69, 0xc1, 0x96, 0xfd, 0xb9, 0x7a, 0xbe, 0xbb, 0xe7, 0x5a, 0xc, - 0x6e, 0x1e, 0xa1, 0x93, 0xa5, 0x20, 0xba, 0x30, 0xac, 0x37, 0xa4, 0xe4, 0x70, 0xf0, 0x11}; - uint8_t bytesprops3[] = {0x95, 0x6, 0x78, 0xf3, 0x5f}; - uint8_t bytesprops4[] = {0xb8, 0xa6, 0xea, 0x2c, 0x24, 0x89, 0x9a, 0x51}; - uint8_t bytesprops5[] = {0xe9, 0xd6, 0x42, 0xc4, 0x27, 0x38, 0xcb, 0x8f, 0x3d, 0xd7, 0x67, 0xb6, 0x88, 0xb5, 0xf3, - 0x4b, 0xda, 0x17, 0x2b, 0x81, 0x86, 0x76, 0x1a, 0x75, 0x67, 0x7d, 0x44, 0x7a, 0x5e}; - uint8_t bytesprops6[] = {0xf, 0x67, 0xd, 0x8d, 0x66, 0xa3, 0x4a, 0x10, 0x74, 0x52, 0x27, - 0xaa, 0x81, 0xde, 0xcf, 0xf5, 0x90, 0x3, 0xdf, 0x3d, 0xe3}; - uint8_t bytesprops8[] = {0x17, 0xa1, 0xc2, 0xfe, 0xe0, 0x88, 0x7f, 0xd4, 0x85, 0x4, 0x69, 0x66, 0xf9, 0xea, - 0x6e, 0xbd, 0xea, 0xcd, 0x68, 0x4, 0xc4, 0x86, 0x35, 0xbe, 0x1e, 0x21, 0x4f}; - uint8_t bytesprops7[] = {0x3}; + msg.payload_len = 20; + + uint8_t bytesprops0[] = {0xa8, 0xbb, 0xf1, 0x46, 0x3, 0x13, 0xe2, 0xeb, 0xd8, 0x3f, 0x50, 0xec, 0x8b, 0x70, + 0x33, 0x89, 0x5, 0x47, 0x1f, 0xab, 0xb6, 0xc9, 0x2b, 0x55, 0xe3, 0x1c, 0xef, 0x53}; + uint8_t bytesprops1[] = {0x21, 0xd4, 0x15, 0x74, 0xdf, 0xaa, 0xdf, 0xe4, + 0x9e, 0xd8, 0xa1, 0x5b, 0x40, 0xeb, 0xcf, 0x9}; + uint8_t bytesprops2[] = {0x5c, 0xb6, 0xd9, 0xb4, 0x13, 0x90, 0x43, 0xb2, 0xbf, 0x77, 0x33, + 0xb0, 0xb9, 0x77, 0xbb, 0xb0, 0xd5, 0xa4, 0x27, 0x42, 0x9d}; + uint8_t bytesprops3[] = {0xd5, 0x78, 0xc0, 0x52, 0x46, 0x10, 0x13, 0xaa, 0xb6, 0x59, + 0xe, 0x4e, 0x84, 0xaa, 0xdd, 0x1c, 0x47, 0x38, 0x52}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6795}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17419}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops1}, .v = {3, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29340}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4083}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6103}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2774}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops7}, .v = {27, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31358}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1128}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 3323, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 137, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = ",f", _pubPktID = 3323, _pubBody = -// "\130\170\152", _pubProps = [PropRetainAvailable 140,PropServerKeepAlive 6795,PropReceiveMaximum -// 17419,PropReasonString "\149",PropUserProperty "\172WQ\136i\193\150\253\185z\190\187\231Z\fn\RS\161\147\165 -// \186\&0\172\&7\164\228p\240\DC1" "/\SYN\163",PropServerReference "\149\ACKx\243_",PropAuthenticationData -// "\184\166\234,$\137\154Q",PropReceiveMaximum 29340,PropSessionExpiryInterval 4083,PropMaximumPacketSize -// 6103,PropServerReference -// "\233\214B\196'8\203\143=\215g\182\136\181\243K\218\ETB+\129\134v\SUBug}Dz^",PropResponseTopic -// "\SIg\r\141f\163J\DLEtR'\170\129\222\207\245\144\ETX\223=\227",PropTopicAliasMaximum 2774,PropUserProperty "\ETX" -// "\ETB\161\194\254\224\136\DEL\212\133\EOTif\249\234n\189\234\205h\EOT\196\134\&5\190\RS!O",PropSubscriptionIdentifierAvailable -// 229,PropTopicAliasMaximum 31358,PropMaximumQoS 169]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\146,\173K\ETBBf8\150", _pubPktID = +// 137, _pubBody = "\EOTF\225\235\204\DC1\196\244\135L\239L|nO\178\220\210\173\181", _pubProps = +// [PropResponseInformation +// "\168\187\241F\ETX\DC3\226\235\216?P\236\139p3\137\ENQG\US\171\182\201+U\227\FS\239S",PropReasonString +// "!\212\NAKt\223\170\223\228\158\216\161[@\235\207\t",PropSubscriptionIdentifier 7,PropMaximumPacketSize +// 1128,PropRequestResponseInformation 151,PropContentType +// "\\\182\217\180\DC3\144C\178\191w3\176\185w\187\176\213\164'B\157",PropResponseTopic +// "\213x\192RF\DLE\DC3\170\182Y\SON\132\170\221\FSG8R"]} TEST(Publish5QCTest, Decode3) { - uint8_t pkt[] = {0x3a, 0xc0, 0x1, 0x0, 0x2, 0x2c, 0x66, 0xc, 0xfb, 0xb5, 0x1, 0x25, 0x8c, 0x13, 0x1a, 0x8b, 0x21, - 0x44, 0xb, 0x1f, 0x0, 0x1, 0x95, 0x26, 0x0, 0x1e, 0xac, 0x57, 0x51, 0x88, 0x69, 0xc1, 0x96, 0xfd, - 0xb9, 0x7a, 0xbe, 0xbb, 0xe7, 0x5a, 0xc, 0x6e, 0x1e, 0xa1, 0x93, 0xa5, 0x20, 0xba, 0x30, 0xac, 0x37, - 0xa4, 0xe4, 0x70, 0xf0, 0x11, 0x0, 0x3, 0x2f, 0x16, 0xa3, 0x1c, 0x0, 0x5, 0x95, 0x6, 0x78, 0xf3, - 0x5f, 0x16, 0x0, 0x8, 0xb8, 0xa6, 0xea, 0x2c, 0x24, 0x89, 0x9a, 0x51, 0x21, 0x72, 0x9c, 0x11, 0x0, - 0x0, 0xf, 0xf3, 0x27, 0x0, 0x0, 0x17, 0xd7, 0x1c, 0x0, 0x1d, 0xe9, 0xd6, 0x42, 0xc4, 0x27, 0x38, - 0xcb, 0x8f, 0x3d, 0xd7, 0x67, 0xb6, 0x88, 0xb5, 0xf3, 0x4b, 0xda, 0x17, 0x2b, 0x81, 0x86, 0x76, 0x1a, - 0x75, 0x67, 0x7d, 0x44, 0x7a, 0x5e, 0x8, 0x0, 0x15, 0xf, 0x67, 0xd, 0x8d, 0x66, 0xa3, 0x4a, 0x10, - 0x74, 0x52, 0x27, 0xaa, 0x81, 0xde, 0xcf, 0xf5, 0x90, 0x3, 0xdf, 0x3d, 0xe3, 0x22, 0xa, 0xd6, 0x26, - 0x0, 0x1, 0x3, 0x0, 0x1b, 0x17, 0xa1, 0xc2, 0xfe, 0xe0, 0x88, 0x7f, 0xd4, 0x85, 0x4, 0x69, 0x66, - 0xf9, 0xea, 0x6e, 0xbd, 0xea, 0xcd, 0x68, 0x4, 0xc4, 0x86, 0x35, 0xbe, 0x1e, 0x21, 0x4f, 0x29, 0xe5, - 0x22, 0x7a, 0x7e, 0x24, 0xa9, 0x82, 0xaa, 0x98}; + uint8_t pkt[] = {0x33, 0x8b, 0x1, 0x0, 0x9, 0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96, 0x0, 0x89, + 0x69, 0x1a, 0x0, 0x1c, 0xa8, 0xbb, 0xf1, 0x46, 0x3, 0x13, 0xe2, 0xeb, 0xd8, 0x3f, 0x50, 0xec, + 0x8b, 0x70, 0x33, 0x89, 0x5, 0x47, 0x1f, 0xab, 0xb6, 0xc9, 0x2b, 0x55, 0xe3, 0x1c, 0xef, 0x53, + 0x1f, 0x0, 0x10, 0x21, 0xd4, 0x15, 0x74, 0xdf, 0xaa, 0xdf, 0xe4, 0x9e, 0xd8, 0xa1, 0x5b, 0x40, + 0xeb, 0xcf, 0x9, 0xb, 0x7, 0x27, 0x0, 0x0, 0x4, 0x68, 0x19, 0x97, 0x3, 0x0, 0x15, 0x5c, + 0xb6, 0xd9, 0xb4, 0x13, 0x90, 0x43, 0xb2, 0xbf, 0x77, 0x33, 0xb0, 0xb9, 0x77, 0xbb, 0xb0, 0xd5, + 0xa4, 0x27, 0x42, 0x9d, 0x8, 0x0, 0x13, 0xd5, 0x78, 0xc0, 0x52, 0x46, 0x10, 0x13, 0xaa, 0xb6, + 0x59, 0xe, 0x4e, 0x84, 0xaa, 0xdd, 0x1c, 0x47, 0x38, 0x52, 0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, + 0xc4, 0xf4, 0x87, 0x4c, 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -983,114 +881,91 @@ TEST(Publish5QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x2c, 0x66}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x82, 0xaa, 0x98}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, 0x4c, + 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 3323); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 137); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "e\226\145", _pubPktID = 0, _pubBody = -// "\225?\246P\197\165t\243\173C\134\185", _pubProps = [PropUserProperty -// "\DLE8;\201\154\212Cf\233\255=\204\229>\145\245\166\144\EM\DC2B\DC4v< \GSvl" -// "\191Gn\251\a\EOTYm\220\SI|\213b\164\&1P\180\251\191\130\239\SYNv?^\159\189\180\144",PropPayloadFormatIndicator -// 100,PropAssignedClientIdentifier "\SIOT\211\182\253;r\SO\203",PropServerKeepAlive 24019,PropContentType -// "\209!\230\188\166< >e\n\233n\218\FS\212\205K7K\\H]\148X)v",PropAuthenticationMethod -// "\210e-\150\131\DC3\237\144\251}\179\141\ETB\151\184\b\146\202O|T\ACKOk\167\130xU\DC1\134",PropRequestResponseInformation -// 124,PropSessionExpiryInterval 27494,PropServerKeepAlive 22183,PropMessageExpiryInterval 32728,PropServerKeepAlive -// 31098,PropAuthenticationMethod "\153\210\196\v\200\163[/\212\155d9\239",PropSessionExpiryInterval -// 32275,PropContentType "\193\163\FS\205\133\&2\191\249;\v",PropSubscriptionIdentifier 29,PropAssignedClientIdentifier -// "}\SOH\DC2(\ESC\227\175\a\174\185\165\186",PropCorrelationData -// "\ENQ\238\250\159\219\247og\162\198$\NAKV\SYN\n",PropReceiveMaximum 28998,PropWildcardSubscriptionAvailable -// 146,PropWildcardSubscriptionAvailable 213,PropMaximumPacketSize 7834,PropSharedSubscriptionAvailable -// 250,PropServerKeepAlive 10556,PropReceiveMaximum 19508,PropRequestProblemInformation 187,PropServerReference -// "\246\190\241%\135\228\&2\NAKC\158\187N'\149\235\FS\225\245t\216p\128\132\147\221\206\188",PropSubscriptionIdentifierAvailable -// 115]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\187\245\185\SOH\nLz\249\&84\221t4:\ACKMBL", _pubPktID = 0, _pubBody = +// "+\154\198\134\210\202d\129:\164\205\152\155'n", _pubProps = [PropResponseTopic +// "|2\DC1,\157\216\160\155~B\255\169\245\132",PropServerReference +// "\138\205y\bC\181\165\157\235H\200\SOH\137\218\141qZ\243)\DEL\196\232\228<\164",PropRequestResponseInformation +// 183,PropCorrelationData "\247\163[\152\ETB\190t\f\193\SUB",PropMaximumPacketSize 11719,PropAuthenticationData +// "\134Xh\141eI",PropRequestProblemInformation 210,PropSubscriptionIdentifierAvailable 109,PropMessageExpiryInterval +// 25460,PropRetainAvailable 26,PropSubscriptionIdentifierAvailable 168,PropReasonString +// "\146\&8@\SYN\224G\185l\203\160\163\254\206\152",PropPayloadFormatIndicator 60,PropAuthenticationMethod +// "__]qE\180\\\169\199\183\237\&9VH!\151p\238\ETX\241",PropRequestResponseInformation +// 110,PropRequestResponseInformation 156,PropContentType "O",PropWildcardSubscriptionAvailable 11,PropWillDelayInterval +// 18099]} TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = {0x39, 0xae, 0x2, 0x0, 0x3, 0x65, 0xe2, 0x91, 0x9b, 0x2, 0x26, 0x0, 0x1c, 0x10, 0x38, 0x3b, 0xc9, - 0x9a, 0xd4, 0x43, 0x66, 0xe9, 0xff, 0x3d, 0xcc, 0xe5, 0x3e, 0x91, 0xf5, 0xa6, 0x90, 0x19, 0x12, 0x42, - 0x14, 0x76, 0x3c, 0x20, 0x1d, 0x76, 0x6c, 0x0, 0x1d, 0xbf, 0x47, 0x6e, 0xfb, 0x7, 0x4, 0x59, 0x6d, - 0xdc, 0xf, 0x7c, 0xd5, 0x62, 0xa4, 0x31, 0x50, 0xb4, 0xfb, 0xbf, 0x82, 0xef, 0x16, 0x76, 0x3f, 0x5e, - 0x9f, 0xbd, 0xb4, 0x90, 0x1, 0x64, 0x12, 0x0, 0xa, 0xf, 0x4f, 0x54, 0xd3, 0xb6, 0xfd, 0x3b, 0x72, - 0xe, 0xcb, 0x13, 0x5d, 0xd3, 0x3, 0x0, 0x1a, 0xd1, 0x21, 0xe6, 0xbc, 0xa6, 0x3c, 0x20, 0x3e, 0x65, - 0xa, 0xe9, 0x6e, 0xda, 0x1c, 0xd4, 0xcd, 0x4b, 0x37, 0x4b, 0x5c, 0x48, 0x5d, 0x94, 0x58, 0x29, 0x76, - 0x15, 0x0, 0x1e, 0xd2, 0x65, 0x2d, 0x96, 0x83, 0x13, 0xed, 0x90, 0xfb, 0x7d, 0xb3, 0x8d, 0x17, 0x97, - 0xb8, 0x8, 0x92, 0xca, 0x4f, 0x7c, 0x54, 0x6, 0x4f, 0x6b, 0xa7, 0x82, 0x78, 0x55, 0x11, 0x86, 0x19, - 0x7c, 0x11, 0x0, 0x0, 0x6b, 0x66, 0x13, 0x56, 0xa7, 0x2, 0x0, 0x0, 0x7f, 0xd8, 0x13, 0x79, 0x7a, - 0x15, 0x0, 0xd, 0x99, 0xd2, 0xc4, 0xb, 0xc8, 0xa3, 0x5b, 0x2f, 0xd4, 0x9b, 0x64, 0x39, 0xef, 0x11, - 0x0, 0x0, 0x7e, 0x13, 0x3, 0x0, 0xa, 0xc1, 0xa3, 0x1c, 0xcd, 0x85, 0x32, 0xbf, 0xf9, 0x3b, 0xb, - 0xb, 0x1d, 0x12, 0x0, 0xc, 0x7d, 0x1, 0x12, 0x28, 0x1b, 0xe3, 0xaf, 0x7, 0xae, 0xb9, 0xa5, 0xba, - 0x9, 0x0, 0xf, 0x5, 0xee, 0xfa, 0x9f, 0xdb, 0xf7, 0x6f, 0x67, 0xa2, 0xc6, 0x24, 0x15, 0x56, 0x16, - 0xa, 0x21, 0x71, 0x46, 0x28, 0x92, 0x28, 0xd5, 0x27, 0x0, 0x0, 0x1e, 0x9a, 0x2a, 0xfa, 0x13, 0x29, - 0x3c, 0x21, 0x4c, 0x34, 0x17, 0xbb, 0x1c, 0x0, 0x1b, 0xf6, 0xbe, 0xf1, 0x25, 0x87, 0xe4, 0x32, 0x15, - 0x43, 0x9e, 0xbb, 0x4e, 0x27, 0x95, 0xeb, 0x1c, 0xe1, 0xf5, 0x74, 0xd8, 0x70, 0x80, 0x84, 0x93, 0xdd, - 0xce, 0xbc, 0x29, 0x73, 0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; - - uint8_t buf[315] = {0}; - uint8_t topic_bytes[] = {0x65, 0xe2, 0x91}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0xb5, 0x1, 0x0, 0x12, 0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, 0x34, 0xdd, 0x74, + 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c, 0x90, 0x1, 0x8, 0x0, 0xe, 0x7c, 0x32, 0x11, 0x2c, 0x9d, 0xd8, + 0xa0, 0x9b, 0x7e, 0x42, 0xff, 0xa9, 0xf5, 0x84, 0x1c, 0x0, 0x19, 0x8a, 0xcd, 0x79, 0x8, 0x43, 0xb5, + 0xa5, 0x9d, 0xeb, 0x48, 0xc8, 0x1, 0x89, 0xda, 0x8d, 0x71, 0x5a, 0xf3, 0x29, 0x7f, 0xc4, 0xe8, 0xe4, + 0x3c, 0xa4, 0x19, 0xb7, 0x9, 0x0, 0xa, 0xf7, 0xa3, 0x5b, 0x98, 0x17, 0xbe, 0x74, 0xc, 0xc1, 0x1a, + 0x27, 0x0, 0x0, 0x2d, 0xc7, 0x16, 0x0, 0x6, 0x86, 0x58, 0x68, 0x8d, 0x65, 0x49, 0x17, 0xd2, 0x29, + 0x6d, 0x2, 0x0, 0x0, 0x63, 0x74, 0x25, 0x1a, 0x29, 0xa8, 0x1f, 0x0, 0xe, 0x92, 0x38, 0x40, 0x16, + 0xe0, 0x47, 0xb9, 0x6c, 0xcb, 0xa0, 0xa3, 0xfe, 0xce, 0x98, 0x1, 0x3c, 0x15, 0x0, 0x14, 0x5f, 0x5f, + 0x5d, 0x71, 0x45, 0xb4, 0x5c, 0xa9, 0xc7, 0xb7, 0xed, 0x39, 0x56, 0x48, 0x21, 0x97, 0x70, 0xee, 0x3, + 0xf1, 0x19, 0x6e, 0x19, 0x9c, 0x3, 0x0, 0x1, 0x4f, 0x28, 0xb, 0x18, 0x0, 0x0, 0x46, 0xb3, 0x2b, + 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; + uint8_t topic_bytes[] = {0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, + 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; + msg.retained = false; + uint8_t msg_bytes[] = {0x2b, 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 15; - uint8_t bytesprops1[] = {0xbf, 0x47, 0x6e, 0xfb, 0x7, 0x4, 0x59, 0x6d, 0xdc, 0xf, 0x7c, 0xd5, 0x62, 0xa4, 0x31, - 0x50, 0xb4, 0xfb, 0xbf, 0x82, 0xef, 0x16, 0x76, 0x3f, 0x5e, 0x9f, 0xbd, 0xb4, 0x90}; - uint8_t bytesprops0[] = {0x10, 0x38, 0x3b, 0xc9, 0x9a, 0xd4, 0x43, 0x66, 0xe9, 0xff, 0x3d, 0xcc, 0xe5, 0x3e, - 0x91, 0xf5, 0xa6, 0x90, 0x19, 0x12, 0x42, 0x14, 0x76, 0x3c, 0x20, 0x1d, 0x76, 0x6c}; - uint8_t bytesprops2[] = {0xf, 0x4f, 0x54, 0xd3, 0xb6, 0xfd, 0x3b, 0x72, 0xe, 0xcb}; - uint8_t bytesprops3[] = {0xd1, 0x21, 0xe6, 0xbc, 0xa6, 0x3c, 0x20, 0x3e, 0x65, 0xa, 0xe9, 0x6e, 0xda, - 0x1c, 0xd4, 0xcd, 0x4b, 0x37, 0x4b, 0x5c, 0x48, 0x5d, 0x94, 0x58, 0x29, 0x76}; - uint8_t bytesprops4[] = {0xd2, 0x65, 0x2d, 0x96, 0x83, 0x13, 0xed, 0x90, 0xfb, 0x7d, 0xb3, 0x8d, 0x17, 0x97, 0xb8, - 0x8, 0x92, 0xca, 0x4f, 0x7c, 0x54, 0x6, 0x4f, 0x6b, 0xa7, 0x82, 0x78, 0x55, 0x11, 0x86}; - uint8_t bytesprops5[] = {0x99, 0xd2, 0xc4, 0xb, 0xc8, 0xa3, 0x5b, 0x2f, 0xd4, 0x9b, 0x64, 0x39, 0xef}; - uint8_t bytesprops6[] = {0xc1, 0xa3, 0x1c, 0xcd, 0x85, 0x32, 0xbf, 0xf9, 0x3b, 0xb}; - uint8_t bytesprops7[] = {0x7d, 0x1, 0x12, 0x28, 0x1b, 0xe3, 0xaf, 0x7, 0xae, 0xb9, 0xa5, 0xba}; - uint8_t bytesprops8[] = {0x5, 0xee, 0xfa, 0x9f, 0xdb, 0xf7, 0x6f, 0x67, 0xa2, 0xc6, 0x24, 0x15, 0x56, 0x16, 0xa}; - uint8_t bytesprops9[] = {0xf6, 0xbe, 0xf1, 0x25, 0x87, 0xe4, 0x32, 0x15, 0x43, 0x9e, 0xbb, 0x4e, 0x27, 0x95, - 0xeb, 0x1c, 0xe1, 0xf5, 0x74, 0xd8, 0x70, 0x80, 0x84, 0x93, 0xdd, 0xce, 0xbc}; + uint8_t bytesprops0[] = {0x7c, 0x32, 0x11, 0x2c, 0x9d, 0xd8, 0xa0, 0x9b, 0x7e, 0x42, 0xff, 0xa9, 0xf5, 0x84}; + uint8_t bytesprops1[] = {0x8a, 0xcd, 0x79, 0x8, 0x43, 0xb5, 0xa5, 0x9d, 0xeb, 0x48, 0xc8, 0x1, 0x89, + 0xda, 0x8d, 0x71, 0x5a, 0xf3, 0x29, 0x7f, 0xc4, 0xe8, 0xe4, 0x3c, 0xa4}; + uint8_t bytesprops2[] = {0xf7, 0xa3, 0x5b, 0x98, 0x17, 0xbe, 0x74, 0xc, 0xc1, 0x1a}; + uint8_t bytesprops3[] = {0x86, 0x58, 0x68, 0x8d, 0x65, 0x49}; + uint8_t bytesprops4[] = {0x92, 0x38, 0x40, 0x16, 0xe0, 0x47, 0xb9, 0x6c, 0xcb, 0xa0, 0xa3, 0xfe, 0xce, 0x98}; + uint8_t bytesprops5[] = {0x5f, 0x5f, 0x5d, 0x71, 0x45, 0xb4, 0x5c, 0xa9, 0xc7, 0xb7, + 0xed, 0x39, 0x56, 0x48, 0x21, 0x97, 0x70, 0xee, 0x3, 0xf1}; + uint8_t bytesprops6[] = {0x4f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops0}, .v = {29, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24019}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27494}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22183}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32728}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31098}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32275}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28998}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7834}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10556}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19508}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11719}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25460}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18099}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); @@ -1098,41 +973,30 @@ TEST(Publish5QCTest, Encode4) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "e\226\145", _pubPktID = 0, _pubBody = -// "\225?\246P\197\165t\243\173C\134\185", _pubProps = [PropUserProperty -// "\DLE8;\201\154\212Cf\233\255=\204\229>\145\245\166\144\EM\DC2B\DC4v< \GSvl" -// "\191Gn\251\a\EOTYm\220\SI|\213b\164\&1P\180\251\191\130\239\SYNv?^\159\189\180\144",PropPayloadFormatIndicator -// 100,PropAssignedClientIdentifier "\SIOT\211\182\253;r\SO\203",PropServerKeepAlive 24019,PropContentType -// "\209!\230\188\166< >e\n\233n\218\FS\212\205K7K\\H]\148X)v",PropAuthenticationMethod -// "\210e-\150\131\DC3\237\144\251}\179\141\ETB\151\184\b\146\202O|T\ACKOk\167\130xU\DC1\134",PropRequestResponseInformation -// 124,PropSessionExpiryInterval 27494,PropServerKeepAlive 22183,PropMessageExpiryInterval 32728,PropServerKeepAlive -// 31098,PropAuthenticationMethod "\153\210\196\v\200\163[/\212\155d9\239",PropSessionExpiryInterval -// 32275,PropContentType "\193\163\FS\205\133\&2\191\249;\v",PropSubscriptionIdentifier 29,PropAssignedClientIdentifier -// "}\SOH\DC2(\ESC\227\175\a\174\185\165\186",PropCorrelationData -// "\ENQ\238\250\159\219\247og\162\198$\NAKV\SYN\n",PropReceiveMaximum 28998,PropWildcardSubscriptionAvailable -// 146,PropWildcardSubscriptionAvailable 213,PropMaximumPacketSize 7834,PropSharedSubscriptionAvailable -// 250,PropServerKeepAlive 10556,PropReceiveMaximum 19508,PropRequestProblemInformation 187,PropServerReference -// "\246\190\241%\135\228\&2\NAKC\158\187N'\149\235\FS\225\245t\216p\128\132\147\221\206\188",PropSubscriptionIdentifierAvailable -// 115]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\187\245\185\SOH\nLz\249\&84\221t4:\ACKMBL", _pubPktID = 0, _pubBody = +// "+\154\198\134\210\202d\129:\164\205\152\155'n", _pubProps = [PropResponseTopic +// "|2\DC1,\157\216\160\155~B\255\169\245\132",PropServerReference +// "\138\205y\bC\181\165\157\235H\200\SOH\137\218\141qZ\243)\DEL\196\232\228<\164",PropRequestResponseInformation +// 183,PropCorrelationData "\247\163[\152\ETB\190t\f\193\SUB",PropMaximumPacketSize 11719,PropAuthenticationData +// "\134Xh\141eI",PropRequestProblemInformation 210,PropSubscriptionIdentifierAvailable 109,PropMessageExpiryInterval +// 25460,PropRetainAvailable 26,PropSubscriptionIdentifierAvailable 168,PropReasonString +// "\146\&8@\SYN\224G\185l\203\160\163\254\206\152",PropPayloadFormatIndicator 60,PropAuthenticationMethod +// "__]qE\180\\\169\199\183\237\&9VH!\151p\238\ETX\241",PropRequestResponseInformation +// 110,PropRequestResponseInformation 156,PropContentType "O",PropWildcardSubscriptionAvailable 11,PropWillDelayInterval +// 18099]} TEST(Publish5QCTest, Decode4) { - uint8_t pkt[] = {0x39, 0xae, 0x2, 0x0, 0x3, 0x65, 0xe2, 0x91, 0x9b, 0x2, 0x26, 0x0, 0x1c, 0x10, 0x38, 0x3b, 0xc9, - 0x9a, 0xd4, 0x43, 0x66, 0xe9, 0xff, 0x3d, 0xcc, 0xe5, 0x3e, 0x91, 0xf5, 0xa6, 0x90, 0x19, 0x12, 0x42, - 0x14, 0x76, 0x3c, 0x20, 0x1d, 0x76, 0x6c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0, 0x0, 0x63, 0x74, 0x25, 0x1a, 0x29, 0xa8, 0x1f, 0x0, 0xe, 0x92, 0x38, 0x40, 0x16, + 0xe0, 0x47, 0xb9, 0x6c, 0xcb, 0xa0, 0xa3, 0xfe, 0xce, 0x98, 0x1, 0x3c, 0x15, 0x0, 0x14, 0x5f, 0x5f, + 0x5d, 0x71, 0x45, 0xb4, 0x5c, 0xa9, 0xc7, 0xb7, 0xed, 0x39, 0x56, 0x48, 0x21, 0x97, 0x70, 0xee, 0x3, + 0xf1, 0x19, 0x6e, 0x19, 0x9c, 0x3, 0x0, 0x1, 0x4f, 0x28, 0xb, 0x18, 0x0, 0x0, 0x46, 0xb3, 0x2b, + 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1140,134 +1004,65 @@ TEST(Publish5QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x65, 0xe2, 0x91}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xe1, 0x3f, 0xf6, 0x50, 0xc5, 0xa5, 0x74, 0xf3, 0xad, 0x43, 0x86, 0xb9}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, + 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2b, 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\191", _pubPktID = 26120, -// _pubBody = "_e(\238\187\252\234\241\201(topic.data), 2); + EXPECT_EQ(packet_id, 16832); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); EXPECT_EQ(msg.payload_len, 15); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\tz\186\176\196\148\DC1", _pubPktID -// = 10274, _pubBody = "\199\149\244", _pubProps = [PropPayloadFormatIndicator 131]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\&6", _pubPktID = 0, _pubBody = +// "\147\221\242\207\140+To \247\210\244", _pubProps = [PropAuthenticationMethod +// "@\158\&95?=\253\187X\243\172\248",PropPayloadFormatIndicator 13,PropResponseTopic +// "\223F|\CAN\162?\US(topic.data), 7); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "l\GS\SO\SI\176\NAKT\189\t0b\NUL\154#1", _pubPktID = 0, _pubBody = -// "\180v\132PX\145\222\160?9\205\204\241\168\&5<\235\222\160\\\190Tg\128", _pubProps = [PropResponseTopic -// "A\229\&5\242\b\DC4m\212]6\178\178\210\136WX\n\CAN",PropResponseInformation -// "\132^\\\136\159s\165\140\151o\195\227\170XR\197\247\145\ESC>2F\172\&2\189\\",PropMaximumPacketSize -// 21600,PropMaximumPacketSize 13269,PropRequestProblemInformation 94,PropWillDelayInterval -// 18146,PropRequestResponseInformation 220,PropSubscriptionIdentifierAvailable 112,PropSessionExpiryInterval -// 24193,PropMaximumQoS 254,PropAuthenticationMethod "L\DLE}",PropWildcardSubscriptionAvailable 171,PropResponseTopic -// "\252]\250\240\179\228\t\172\144\226\226\151(\214\156\225\210A\241.\198\DC2o\228W\223o_",PropContentType -// "\160\197\161\150W\179\181\&0b\DLEn\RS(\148ET|G",PropContentType -// "<@M\204\204\166[\SI\182\143\251S5\156\151|\176",PropCorrelationData -// "\189\CAN\EMA\188l\SUB\190",PropResponseInformation "\234f\205j\184j\238\243u\130\238",PropMessageExpiryInterval -// 23833,PropMaximumPacketSize 12844,PropMaximumQoS 135,PropAssignedClientIdentifier -// "\190JnM\190I\187*\213\221\178\168,1\175a\SUB\244\254\192",PropUserProperty -// "\236\ETB\235R\182d\242\184\217\214[>h\210\204\209\f\146\183\185\153\184\"\ESC\234" -// "?\DC4\SOHl\129\&2?L\US\ETX",PropRequestResponseInformation 19,PropWildcardSubscriptionAvailable -// 22,PropAssignedClientIdentifier "\234!ZGR\254\RS\US\183\135\191",PropReasonString -// "\217\141\153!V\187\216\148r\211\ACK\EM\197\183\&6\221&\180\237",PropResponseTopic "en\252!",PropWillDelayInterval -// 6918,PropRequestProblemInformation 173]} -TEST(Publish5QCTest, Encode7) { - uint8_t pkt[] = { - 0x31, 0xe3, 0x2, 0x0, 0xf, 0x6c, 0x1d, 0xe, 0xf, 0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x66, 0xcd, 0x6a, 0xb8, 0x6a, 0xee, 0xf3, 0x75, 0x82, 0xee, 0x2, 0x0, 0x0, 0x5d, - 0x19, 0x27, 0x0, 0x0, 0x32, 0x2c, 0x24, 0x87, 0x12, 0x0, 0x14, 0xbe, 0x4a, 0x6e, 0x4d, 0xbe, 0x49, 0xbb, 0x2a, - 0xd5, 0xdd, 0xb2, 0xa8, 0x2c, 0x31, 0xaf, 0x61, 0x1a, 0xf4, 0xfe, 0xc0, 0x26, 0x0, 0x19, 0xec, 0x17, 0xeb, 0x52, - 0xb6, 0x64, 0xf2, 0xb8, 0xd9, 0xd6, 0x5b, 0x3e, 0x68, 0xd2, 0xcc, 0xd1, 0xc, 0x92, 0xb7, 0xb9, 0x99, 0xb8, 0x22, - 0x1b, 0xea, 0x0, 0xa, 0x3f, 0x14, 0x1, 0x6c, 0x81, 0x32, 0x3f, 0x4c, 0x1f, 0x3, 0x19, 0x13, 0x28, 0x16, 0x12, - 0x0, 0xb, 0xea, 0x21, 0x5a, 0x47, 0x52, 0xfe, 0x1e, 0x1f, 0xb7, 0x87, 0xbf, 0x1f, 0x0, 0x13, 0xd9, 0x8d, 0x99, - 0x21, 0x56, 0xbb, 0xd8, 0x94, 0x72, 0xd3, 0x6, 0x19, 0xc5, 0xb7, 0x36, 0xdd, 0x26, 0xb4, 0xed, 0x8, 0x0, 0x4, - 0x65, 0x6e, 0xfc, 0x21, 0x18, 0x0, 0x0, 0x1b, 0x6, 0x17, 0xad, 0xb4, 0x76, 0x84, 0x50, 0x58, 0x91, 0xde, 0xa0, - 0x3f, 0x39, 0xcd, 0xcc, 0xf1, 0xa8, 0x35, 0x3c, 0xeb, 0xde, 0xa0, 0x5c, 0xbe, 0x54, 0x67, 0x80}; - - uint8_t buf[368] = {0}; - uint8_t topic_bytes[] = {0x6c, 0x1d, 0xe, 0xf, 0xb0, 0x15, 0x54, 0xbd, 0x9, 0x30, 0x62, 0x0, 0x9a, 0x23, 0x31}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t exp_topic_bytes[] = {0xdd, 0x36}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x93, 0xdd, 0xf2, 0xcf, 0x8c, 0x2b, 0x54, 0x6f, 0x20, 0xf7, 0xd2, 0xf4}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\t[\147\134\211N\220\217R\CAN\NAK\\\186G\DLE\137\189\166\158\221=\171", _pubPktID = 2127, _pubBody = +// "n\\\\\STX\237\196\179\185\241\214\171\SO'\156\228!\240\230\146", _pubProps = [PropAuthenticationMethod +// "}l\146\214\195on\142F\1542F\172\&2\189\\",PropMaximumPacketSize -// 21600,PropMaximumPacketSize 13269,PropRequestProblemInformation 94,PropWillDelayInterval -// 18146,PropRequestResponseInformation 220,PropSubscriptionIdentifierAvailable 112,PropSessionExpiryInterval -// 24193,PropMaximumQoS 254,PropAuthenticationMethod "L\DLE}",PropWildcardSubscriptionAvailable 171,PropResponseTopic -// "\252]\250\240\179\228\t\172\144\226\226\151(\214\156\225\210A\241.\198\DC2o\228W\223o_",PropContentType -// "\160\197\161\150W\179\181\&0b\DLEn\RS(\148ET|G",PropContentType -// "<@M\204\204\166[\SI\182\143\251S5\156\151|\176",PropCorrelationData -// "\189\CAN\EMA\188l\SUB\190",PropResponseInformation "\234f\205j\184j\238\243u\130\238",PropMessageExpiryInterval -// 23833,PropMaximumPacketSize 12844,PropMaximumQoS 135,PropAssignedClientIdentifier -// "\190JnM\190I\187*\213\221\178\168,1\175a\SUB\244\254\192",PropUserProperty -// "\236\ETB\235R\182d\242\184\217\214[>h\210\204\209\f\146\183\185\153\184\"\ESC\234" -// "?\DC4\SOHl\129\&2?L\US\ETX",PropRequestResponseInformation 19,PropWildcardSubscriptionAvailable -// 22,PropAssignedClientIdentifier "\234!ZGR\254\RS\US\183\135\191",PropReasonString -// "\217\141\153!V\187\216\148r\211\ACK\EM\197\183\&6\221&\180\237",PropResponseTopic "en\252!",PropWillDelayInterval -// 6918,PropRequestProblemInformation 173]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\t[\147\134\211N\220\217R\CAN\NAK\\\186G\DLE\137\189\166\158\221=\171", _pubPktID = 2127, _pubBody = +// "n\\\\\STX\237\196\179\185\241\214\171\SO'\156\228!\240\230\146", _pubProps = [PropAuthenticationMethod +// "}l\146\214\195on\142F\154(topic.data), 15); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + uint8_t exp_topic_bytes[] = {0x9, 0x5b, 0x93, 0x86, 0xd3, 0x4e, 0xdc, 0xd9, 0x52, 0x18, 0x15, + 0x5c, 0xba, 0x47, 0x10, 0x89, 0xbd, 0xa6, 0x9e, 0xdd, 0x3d, 0xab}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x6e, 0x5c, 0x5c, 0x2, 0xed, 0xc4, 0xb3, 0xb9, 0xf1, 0xd6, + 0xab, 0xe, 0x27, 0x9c, 0xe4, 0x21, 0xf0, 0xe6, 0x92}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 2127); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\244_\249R\255\232t\194", _pubPktID -// = 4521, _pubBody = "\213\SOQ\252\167\179#\DEL\SIc\223\EOT\156\210\214\bp", _pubProps = [PropRetainAvailable -// 141,PropAssignedClientIdentifier -// "\198\246L\228q\t\203\216\147\GS\"*\181\f\198\DELAn\SO\185\232\DC3\195\181\193",PropSessionExpiryInterval -// 28422,PropRetainAvailable 4,PropSharedSubscriptionAvailable 192,PropPayloadFormatIndicator 178,PropResponseTopic " -// \161\189",PropAssignedClientIdentifier "\142YT\144%\STX\bL\fK^\163\134^\212Z\199\234]"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\148\134\&7\254W\239\197z\v\194\253\227\173o\163\251m\138", _pubPktID = 0, _pubBody = +// "\136i\178\239\188AL\167x\230\227\NULnK\187", _pubProps = [PropAssignedClientIdentifier +// "\225\SO\FS\251vB\190\ETB\128\RS\134+o\138\US;\168\226Qn7\fFe\DC4\150\147\&4\145n",PropWildcardSubscriptionAvailable +// 225,PropReceiveMaximum 3746,PropReasonString "\223\163\173)L",PropRequestProblemInformation 142]} TEST(Publish5QCTest, Encode8) { - uint8_t pkt[] = {0x35, 0x63, 0x0, 0x8, 0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2, 0x11, 0xa9, 0x45, 0x25, 0x8d, - 0x12, 0x0, 0x19, 0xc6, 0xf6, 0x4c, 0xe4, 0x71, 0x9, 0xcb, 0xd8, 0x93, 0x1d, 0x22, 0x2a, 0xb5, 0xc, - 0xc6, 0x7f, 0x41, 0x6e, 0xe, 0xb9, 0xe8, 0x13, 0xc3, 0xb5, 0xc1, 0x11, 0x0, 0x0, 0x6f, 0x6, 0x25, - 0x4, 0x2a, 0xc0, 0x1, 0xb2, 0x8, 0x0, 0x3, 0x20, 0xa1, 0xbd, 0x12, 0x0, 0x13, 0x8e, 0x59, 0x54, - 0x90, 0x25, 0x2, 0x8, 0x4c, 0xc, 0x4b, 0x5e, 0xa3, 0x86, 0x5e, 0xd4, 0x5a, 0xc7, 0xea, 0x5d, 0xd5, - 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; - - uint8_t buf[111] = {0}; - uint8_t topic_bytes[] = {0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x54, 0x0, 0x12, 0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, 0xc2, 0xfd, + 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a, 0x30, 0x12, 0x0, 0x1e, 0xe1, 0xe, 0x1c, 0xfb, + 0x76, 0x42, 0xbe, 0x17, 0x80, 0x1e, 0x86, 0x2b, 0x6f, 0x8a, 0x1f, 0x3b, 0xa8, 0xe2, 0x51, + 0x6e, 0x37, 0xc, 0x46, 0x65, 0x14, 0x96, 0x93, 0x34, 0x91, 0x6e, 0x28, 0xe1, 0x21, 0xe, + 0xa2, 0x1f, 0x0, 0x5, 0xdf, 0xa3, 0xad, 0x29, 0x4c, 0x17, 0x8e, 0x88, 0x69, 0xb2, 0xef, + 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; + uint8_t topic_bytes[] = {0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, + 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xd5, 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, - 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x88, 0x69, 0xb2, 0xef, 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 15; - uint8_t bytesprops0[] = {0xc6, 0xf6, 0x4c, 0xe4, 0x71, 0x9, 0xcb, 0xd8, 0x93, 0x1d, 0x22, 0x2a, 0xb5, - 0xc, 0xc6, 0x7f, 0x41, 0x6e, 0xe, 0xb9, 0xe8, 0x13, 0xc3, 0xb5, 0xc1}; - uint8_t bytesprops1[] = {0x20, 0xa1, 0xbd}; - uint8_t bytesprops2[] = {0x8e, 0x59, 0x54, 0x90, 0x25, 0x2, 0x8, 0x4c, 0xc, 0x4b, - 0x5e, 0xa3, 0x86, 0x5e, 0xd4, 0x5a, 0xc7, 0xea, 0x5d}; + uint8_t bytesprops0[] = {0xe1, 0xe, 0x1c, 0xfb, 0x76, 0x42, 0xbe, 0x17, 0x80, 0x1e, 0x86, 0x2b, 0x6f, 0x8a, 0x1f, + 0x3b, 0xa8, 0xe2, 0x51, 0x6e, 0x37, 0xc, 0x46, 0x65, 0x14, 0x96, 0x93, 0x34, 0x91, 0x6e}; + uint8_t bytesprops1[] = {0xdf, 0xa3, 0xad, 0x29, 0x4c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28422}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3746}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 142}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 4521, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\244_\249R\255\232t\194", _pubPktID -// = 4521, _pubBody = "\213\SOQ\252\167\179#\DEL\SIc\223\EOT\156\210\214\bp", _pubProps = [PropRetainAvailable -// 141,PropAssignedClientIdentifier -// "\198\246L\228q\t\203\216\147\GS\"*\181\f\198\DELAn\SO\185\232\DC3\195\181\193",PropSessionExpiryInterval -// 28422,PropRetainAvailable 4,PropSharedSubscriptionAvailable 192,PropPayloadFormatIndicator 178,PropResponseTopic " -// \161\189",PropAssignedClientIdentifier "\142YT\144%\STX\bL\fK^\163\134^\212Z\199\234]"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\148\134\&7\254W\239\197z\v\194\253\227\173o\163\251m\138", _pubPktID = 0, _pubBody = +// "\136i\178\239\188AL\167x\230\227\NULnK\187", _pubProps = [PropAssignedClientIdentifier +// "\225\SO\FS\251vB\190\ETB\128\RS\134+o\138\US;\168\226Qn7\fFe\DC4\150\147\&4\145n",PropWildcardSubscriptionAvailable +// 225,PropReceiveMaximum 3746,PropReasonString "\223\163\173)L",PropRequestProblemInformation 142]} TEST(Publish5QCTest, Decode8) { - uint8_t pkt[] = {0x35, 0x63, 0x0, 0x8, 0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2, 0x11, 0xa9, 0x45, 0x25, 0x8d, - 0x12, 0x0, 0x19, 0xc6, 0xf6, 0x4c, 0xe4, 0x71, 0x9, 0xcb, 0xd8, 0x93, 0x1d, 0x22, 0x2a, 0xb5, 0xc, - 0xc6, 0x7f, 0x41, 0x6e, 0xe, 0xb9, 0xe8, 0x13, 0xc3, 0xb5, 0xc1, 0x11, 0x0, 0x0, 0x6f, 0x6, 0x25, - 0x4, 0x2a, 0xc0, 0x1, 0xb2, 0x8, 0x0, 0x3, 0x20, 0xa1, 0xbd, 0x12, 0x0, 0x13, 0x8e, 0x59, 0x54, - 0x90, 0x25, 0x2, 0x8, 0x4c, 0xc, 0x4b, 0x5e, 0xa3, 0x86, 0x5e, 0xd4, 0x5a, 0xc7, 0xea, 0x5d, 0xd5, - 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; + uint8_t pkt[] = {0x30, 0x54, 0x0, 0x12, 0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, 0xc2, 0xfd, + 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a, 0x30, 0x12, 0x0, 0x1e, 0xe1, 0xe, 0x1c, 0xfb, + 0x76, 0x42, 0xbe, 0x17, 0x80, 0x1e, 0x86, 0x2b, 0x6f, 0x8a, 0x1f, 0x3b, 0xa8, 0xe2, 0x51, + 0x6e, 0x37, 0xc, 0x46, 0x65, 0x14, 0x96, 0x93, 0x34, 0x91, 0x6e, 0x28, 0xe1, 0x21, 0xe, + 0xa2, 0x1f, 0x0, 0x5, 0xdf, 0xa3, 0xad, 0x29, 0x4c, 0x17, 0x8e, 0x88, 0x69, 0xb2, 0xef, + 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1593,100 +1388,80 @@ TEST(Publish5QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf4, 0x5f, 0xf9, 0x52, 0xff, 0xe8, 0x74, 0xc2}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd5, 0xe, 0x51, 0xfc, 0xa7, 0xb3, 0x23, 0x7f, 0xf, - 0x63, 0xdf, 0x4, 0x9c, 0xd2, 0xd6, 0x8, 0x70}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, + 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x88, 0x69, 0xb2, 0xef, 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 4521); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "a\239\170\203|\"\t\198g\b\v[V\ETXkc\GS+\205\&5Q13M\196E", _pubPktID = 21638, _pubBody = -// "\NAK\153\221\DC3\250(2\DC2\166z\179\183Z\205>5\158\160\245", _pubProps = [PropContentType -// "\176\254u\222\148\197\221B \168",PropTopicAliasMaximum 19316,PropCorrelationData "R\222g",PropAuthenticationData -// "q\219\133G\216b,p\148\GS\132\181\185\224\131\146\145.\NUL\149\253\GSPn\147#\236k\ACKI",PropMaximumPacketSize -// 11778,PropResponseTopic -// "\228\239I\244hm\STX\SOz\244\156\192#8\197\194\a\201T\176\254.\237\201\GS\EOT`S\248\RS",PropRequestResponseInformation -// 101,PropAssignedClientIdentifier "\164@\128\131B\169\131#D5\158\160\245", _pubProps = [PropContentType -// "\176\254u\222\148\197\221B \168",PropTopicAliasMaximum 19316,PropCorrelationData "R\222g",PropAuthenticationData -// "q\219\133G\216b,p\148\GS\132\181\185\224\131\146\145.\NUL\149\253\GSPn\147#\236k\ACKI",PropMaximumPacketSize -// 11778,PropResponseTopic -// "\228\239I\244hm\STX\SOz\244\156\192#8\197\194\a\201T\176\254.\237\201\GS\EOT`S\248\RS",PropRequestResponseInformation -// 101,PropAssignedClientIdentifier "\164@\128\131B\169\131#D(topic.data), 26); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + uint8_t exp_topic_bytes[] = {0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, + 0x65, 0x34, 0x25, 0x6b, 0x7e, 0x84, 0x99}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "3\DC2\163\160\US\252\129\206\EMa\SYN\ESC\248J%\210\t0\224\159T\165\137&\153", _pubPktID = 14459, _pubBody = -// "\161;R\191\DC4\212,\ETB\168<\r}\244\250\&6\145_\153\241\218\175\133\NAK\SO\234\f", _pubProps = -// [PropWillDelayInterval 19833,PropContentType "'f\225\ETB\202",PropServerKeepAlive 17420,PropPayloadFormatIndicator -// 155,PropServerKeepAlive 11561,PropTopicAliasMaximum 5638,PropResponseInformation -// "\FS\EM\145\217\SUB\GS_R\f\175",PropResponseTopic -// "k\ETB\180g\156\223\215\CAN[\207\188mH\200\ETB\230\203\220\177\173\158\149\178@",PropReasonString -// "\149\180\194\131T\234&\237\143\170\166",PropMaximumQoS 239,PropAssignedClientIdentifier -// "Z\233,B\231\vH\143\DC1d\SO\233\163\202\213",PropResponseInformation -// "\r\226jm\227\213A>N/\157\185F\164",PropTopicAliasMaximum 13496]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\160\NAK\234\249\209\141\136\198?\243\245hW6\199=`\243C|RQ\216v@\r", _pubPktID = 19217, _pubBody = +// "\212m\146de\171\221qv\142\228\171\234S7\162", _pubProps = [PropWillDelayInterval 18386,PropResponseInformation +// "\161\147\SOH\213o-\142\SO\193Kj\ACK\NAK\159\EM\SI\DC3Cz\ENQ\160\213H\173.\202\222Z\161",PropReasonString +// "\228wh?P\146\151\206\ETB\243SQ]\139D\173\183\132o",PropPayloadFormatIndicator 204,PropAuthenticationData +// "J\195\132\220\FS|\252<\153\147\ENQ\SUBo\225",PropAuthenticationData "\228\156\aHyS\251\241",PropServerKeepAlive +// 6048,PropServerKeepAlive 2861,PropReasonString "\154\&9\243\134\155\DC1]\171\&2",PropContentType +// "\191\193s\148\201\&2\246\&4\167\134\205vH;\205\186kO\ETX\168R\218\149",PropAuthenticationMethod +// "\ENQ`75\185\212\FSo\228\"\GS\196t\206\DC1\SYN\133s.q\141\132\STX\SYN\200\235r\135\176",PropRequestProblemInformation +// 187,PropSubscriptionIdentifier 3,PropMaximumPacketSize 21510,PropMessageExpiryInterval +// 28380,PropMessageExpiryInterval 16492,PropSubscriptionIdentifierAvailable 85,PropWildcardSubscriptionAvailable +// 173,PropMessageExpiryInterval 17645,PropContentType +// "W\226>\SUB\145\FS\US\202\207\164\128\196\249\212\172X[\202\RS\198\157\217\EM",PropCorrelationData +// "k\210\192J",PropRequestResponseInformation 169,PropWillDelayInterval 3416,PropMessageExpiryInterval +// 24592,PropSubscriptionIdentifier 27,PropSubscriptionIdentifier 28]} TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = {0x35, 0xae, 0x1, 0x0, 0x19, 0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, - 0xf8, 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99, 0x38, 0x7b, 0x76, 0x18, - 0x0, 0x0, 0x4d, 0x79, 0x3, 0x0, 0x5, 0x27, 0x66, 0xe1, 0x17, 0xca, 0x13, 0x44, 0xc, 0x1, 0x9b, - 0x13, 0x2d, 0x29, 0x22, 0x16, 0x6, 0x1a, 0x0, 0xa, 0x1c, 0x19, 0x91, 0xd9, 0x1a, 0x1d, 0x5f, 0x52, - 0xc, 0xaf, 0x8, 0x0, 0x18, 0x6b, 0x17, 0xb4, 0x67, 0x9c, 0xdf, 0xd7, 0x18, 0x5b, 0xcf, 0xbc, 0x6d, - 0x48, 0xc8, 0x17, 0xe6, 0xcb, 0xdc, 0xb1, 0xad, 0x9e, 0x95, 0xb2, 0x40, 0x1f, 0x0, 0xb, 0x95, 0xb4, - 0xc2, 0x83, 0x54, 0xea, 0x26, 0xed, 0x8f, 0xaa, 0xa6, 0x24, 0xef, 0x12, 0x0, 0xf, 0x5a, 0xe9, 0x2c, - 0x42, 0xe7, 0xb, 0x48, 0x8f, 0x11, 0x64, 0xe, 0xe9, 0xa3, 0xca, 0xd5, 0x1a, 0x0, 0xe, 0xd, 0xe2, - 0x6a, 0x6d, 0xe3, 0xd5, 0x41, 0x3e, 0x4e, 0x2f, 0x9d, 0xb9, 0x46, 0xa4, 0x22, 0x34, 0xb8, 0xa1, 0x3b, - 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, - 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; - - uint8_t buf[187] = {0}; - uint8_t topic_bytes[] = {0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, 0xf8, - 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x34, 0xa2, 0x2, 0x0, 0x1a, 0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, 0x36, + 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd, 0x4b, 0x11, 0xf2, 0x1, 0x18, 0x0, 0x0, + 0x47, 0xd2, 0x1a, 0x0, 0x1d, 0xa1, 0x93, 0x1, 0xd5, 0x6f, 0x2d, 0x8e, 0xe, 0xc1, 0x4b, 0x6a, 0x6, 0x15, 0x9f, + 0x19, 0xf, 0x13, 0x43, 0x7a, 0x5, 0xa0, 0xd5, 0x48, 0xad, 0x2e, 0xca, 0xde, 0x5a, 0xa1, 0x1f, 0x0, 0x13, 0xe4, + 0x77, 0x68, 0x3f, 0x50, 0x92, 0x97, 0xce, 0x17, 0xf3, 0x53, 0x51, 0x5d, 0x8b, 0x44, 0xad, 0xb7, 0x84, 0x6f, 0x1, + 0xcc, 0x16, 0x0, 0xe, 0x4a, 0xc3, 0x84, 0xdc, 0x1c, 0x7c, 0xfc, 0x3c, 0x99, 0x93, 0x5, 0x1a, 0x6f, 0xe1, 0x16, + 0x0, 0x8, 0xe4, 0x9c, 0x7, 0x48, 0x79, 0x53, 0xfb, 0xf1, 0x13, 0x17, 0xa0, 0x13, 0xb, 0x2d, 0x1f, 0x0, 0x9, + 0x9a, 0x39, 0xf3, 0x86, 0x9b, 0x11, 0x5d, 0xab, 0x32, 0x3, 0x0, 0x17, 0xbf, 0xc1, 0x73, 0x94, 0xc9, 0x32, 0xf6, + 0x34, 0xa7, 0x86, 0xcd, 0x76, 0x48, 0x3b, 0xcd, 0xba, 0x6b, 0x4f, 0x3, 0xa8, 0x52, 0xda, 0x95, 0x15, 0x0, 0x1d, + 0x5, 0x60, 0x37, 0x35, 0xb9, 0xd4, 0x1c, 0x6f, 0xe4, 0x22, 0x1d, 0xc4, 0x74, 0xce, 0x11, 0x16, 0x85, 0x73, 0x2e, + 0x71, 0x8d, 0x84, 0x2, 0x16, 0xc8, 0xeb, 0x72, 0x87, 0xb0, 0x17, 0xbb, 0xb, 0x3, 0x27, 0x0, 0x0, 0x54, 0x6, + 0x2, 0x0, 0x0, 0x6e, 0xdc, 0x2, 0x0, 0x0, 0x40, 0x6c, 0x29, 0x55, 0x28, 0xad, 0x2, 0x0, 0x0, 0x44, 0xed, + 0x3, 0x0, 0x17, 0x57, 0xe2, 0x3e, 0x1a, 0x91, 0x1c, 0x1f, 0xca, 0xcf, 0xa4, 0x80, 0xc4, 0xf9, 0xd4, 0xac, 0x58, + 0x5b, 0xca, 0x1e, 0xc6, 0x9d, 0xd9, 0x19, 0x9, 0x0, 0x4, 0x6b, 0xd2, 0xc0, 0x4a, 0x19, 0xa9, 0x18, 0x0, 0x0, + 0xd, 0x58, 0x2, 0x0, 0x0, 0x60, 0x10, 0xb, 0x1b, 0xb, 0x1c, 0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, + 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; + uint8_t topic_bytes[] = {0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, + 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, - 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; + msg.retained = false; + uint8_t msg_bytes[] = {0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, + 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; - - uint8_t bytesprops0[] = {0x27, 0x66, 0xe1, 0x17, 0xca}; - uint8_t bytesprops1[] = {0x1c, 0x19, 0x91, 0xd9, 0x1a, 0x1d, 0x5f, 0x52, 0xc, 0xaf}; - uint8_t bytesprops2[] = {0x6b, 0x17, 0xb4, 0x67, 0x9c, 0xdf, 0xd7, 0x18, 0x5b, 0xcf, 0xbc, 0x6d, - 0x48, 0xc8, 0x17, 0xe6, 0xcb, 0xdc, 0xb1, 0xad, 0x9e, 0x95, 0xb2, 0x40}; - uint8_t bytesprops3[] = {0x95, 0xb4, 0xc2, 0x83, 0x54, 0xea, 0x26, 0xed, 0x8f, 0xaa, 0xa6}; - uint8_t bytesprops4[] = {0x5a, 0xe9, 0x2c, 0x42, 0xe7, 0xb, 0x48, 0x8f, 0x11, 0x64, 0xe, 0xe9, 0xa3, 0xca, 0xd5}; - uint8_t bytesprops5[] = {0xd, 0xe2, 0x6a, 0x6d, 0xe3, 0xd5, 0x41, 0x3e, 0x4e, 0x2f, 0x9d, 0xb9, 0x46, 0xa4}; + msg.payload_len = 16; + + uint8_t bytesprops0[] = {0xa1, 0x93, 0x1, 0xd5, 0x6f, 0x2d, 0x8e, 0xe, 0xc1, 0x4b, 0x6a, 0x6, 0x15, 0x9f, 0x19, + 0xf, 0x13, 0x43, 0x7a, 0x5, 0xa0, 0xd5, 0x48, 0xad, 0x2e, 0xca, 0xde, 0x5a, 0xa1}; + uint8_t bytesprops1[] = {0xe4, 0x77, 0x68, 0x3f, 0x50, 0x92, 0x97, 0xce, 0x17, 0xf3, + 0x53, 0x51, 0x5d, 0x8b, 0x44, 0xad, 0xb7, 0x84, 0x6f}; + uint8_t bytesprops2[] = {0x4a, 0xc3, 0x84, 0xdc, 0x1c, 0x7c, 0xfc, 0x3c, 0x99, 0x93, 0x5, 0x1a, 0x6f, 0xe1}; + uint8_t bytesprops3[] = {0xe4, 0x9c, 0x7, 0x48, 0x79, 0x53, 0xfb, 0xf1}; + uint8_t bytesprops4[] = {0x9a, 0x39, 0xf3, 0x86, 0x9b, 0x11, 0x5d, 0xab, 0x32}; + uint8_t bytesprops5[] = {0xbf, 0xc1, 0x73, 0x94, 0xc9, 0x32, 0xf6, 0x34, 0xa7, 0x86, 0xcd, 0x76, + 0x48, 0x3b, 0xcd, 0xba, 0x6b, 0x4f, 0x3, 0xa8, 0x52, 0xda, 0x95}; + uint8_t bytesprops6[] = {0x5, 0x60, 0x37, 0x35, 0xb9, 0xd4, 0x1c, 0x6f, 0xe4, 0x22, 0x1d, 0xc4, 0x74, 0xce, 0x11, + 0x16, 0x85, 0x73, 0x2e, 0x71, 0x8d, 0x84, 0x2, 0x16, 0xc8, 0xeb, 0x72, 0x87, 0xb0}; + uint8_t bytesprops7[] = {0x57, 0xe2, 0x3e, 0x1a, 0x91, 0x1c, 0x1f, 0xca, 0xcf, 0xa4, 0x80, 0xc4, + 0xf9, 0xd4, 0xac, 0x58, 0x5b, 0xca, 0x1e, 0xc6, 0x9d, 0xd9, 0x19}; + uint8_t bytesprops8[] = {0x6b, 0xd2, 0xc0, 0x4a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19833}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17420}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11561}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5638}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13496}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18386}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6048}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2861}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21510}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28380}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16492}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17645}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3416}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24592}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14459, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19217, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "3\DC2\163\160\US\252\129\206\EMa\SYN\ESC\248J%\210\t0\224\159T\165\137&\153", _pubPktID = 14459, _pubBody = -// "\161;R\191\DC4\212,\ETB\168<\r}\244\250\&6\145_\153\241\218\175\133\NAK\SO\234\f", _pubProps = -// [PropWillDelayInterval 19833,PropContentType "'f\225\ETB\202",PropServerKeepAlive 17420,PropPayloadFormatIndicator -// 155,PropServerKeepAlive 11561,PropTopicAliasMaximum 5638,PropResponseInformation -// "\FS\EM\145\217\SUB\GS_R\f\175",PropResponseTopic -// "k\ETB\180g\156\223\215\CAN[\207\188mH\200\ETB\230\203\220\177\173\158\149\178@",PropReasonString -// "\149\180\194\131T\234&\237\143\170\166",PropMaximumQoS 239,PropAssignedClientIdentifier -// "Z\233,B\231\vH\143\DC1d\SO\233\163\202\213",PropResponseInformation -// "\r\226jm\227\213A>N/\157\185F\164",PropTopicAliasMaximum 13496]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\160\NAK\234\249\209\141\136\198?\243\245hW6\199=`\243C|RQ\216v@\r", _pubPktID = 19217, _pubBody = +// "\212m\146de\171\221qv\142\228\171\234S7\162", _pubProps = [PropWillDelayInterval 18386,PropResponseInformation +// "\161\147\SOH\213o-\142\SO\193Kj\ACK\NAK\159\EM\SI\DC3Cz\ENQ\160\213H\173.\202\222Z\161",PropReasonString +// "\228wh?P\146\151\206\ETB\243SQ]\139D\173\183\132o",PropPayloadFormatIndicator 204,PropAuthenticationData +// "J\195\132\220\FS|\252<\153\147\ENQ\SUBo\225",PropAuthenticationData "\228\156\aHyS\251\241",PropServerKeepAlive +// 6048,PropServerKeepAlive 2861,PropReasonString "\154\&9\243\134\155\DC1]\171\&2",PropContentType +// "\191\193s\148\201\&2\246\&4\167\134\205vH;\205\186kO\ETX\168R\218\149",PropAuthenticationMethod +// "\ENQ`75\185\212\FSo\228\"\GS\196t\206\DC1\SYN\133s.q\141\132\STX\SYN\200\235r\135\176",PropRequestProblemInformation +// 187,PropSubscriptionIdentifier 3,PropMaximumPacketSize 21510,PropMessageExpiryInterval +// 28380,PropMessageExpiryInterval 16492,PropSubscriptionIdentifierAvailable 85,PropWildcardSubscriptionAvailable +// 173,PropMessageExpiryInterval 17645,PropContentType +// "W\226>\SUB\145\FS\US\202\207\164\128\196\249\212\172X[\202\RS\198\157\217\EM",PropCorrelationData +// "k\210\192J",PropRequestResponseInformation 169,PropWillDelayInterval 3416,PropMessageExpiryInterval +// 24592,PropSubscriptionIdentifier 27,PropSubscriptionIdentifier 28]} TEST(Publish5QCTest, Decode10) { - uint8_t pkt[] = {0x35, 0xae, 0x1, 0x0, 0x19, 0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, - 0xf8, 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99, 0x38, 0x7b, 0x76, 0x18,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ed, + 0x3, 0x0, 0x17, 0x57, 0xe2, 0x3e, 0x1a, 0x91, 0x1c, 0x1f, 0xca, 0xcf, 0xa4, 0x80, 0xc4, 0xf9, 0xd4, 0xac, 0x58, + 0x5b, 0xca, 0x1e, 0xc6, 0x9d, 0xd9, 0x19, 0x9, 0x0, 0x4, 0x6b, 0xd2, 0xc0, 0x4a, 0x19, 0xa9, 0x18, 0x0, 0x0, + 0xd, 0x58, 0x2, 0x0, 0x0, 0x60, 0x10, 0xb, 0x1b, 0xb, 0x1c, 0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, + 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1807,38 +1623,34 @@ TEST(Publish5QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x33, 0x12, 0xa3, 0xa0, 0x1f, 0xfc, 0x81, 0xce, 0x19, 0x61, 0x16, 0x1b, 0xf8, - 0x4a, 0x25, 0xd2, 0x9, 0x30, 0xe0, 0x9f, 0x54, 0xa5, 0x89, 0x26, 0x99}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa1, 0x3b, 0x52, 0xbf, 0x14, 0xd4, 0x2c, 0x17, 0xa8, 0x3c, 0xd, 0x7d, 0xf4, - 0xfa, 0x36, 0x91, 0x5f, 0x99, 0xf1, 0xda, 0xaf, 0x85, 0x15, 0xe, 0xea, 0xc}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, + 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, + 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 14459); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 19217); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// ConnectRequest {_username = Just "\\$\245\DELg\180\&6\136n\177S\153", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = -// "\187\152\148yT\196\161\178\207\&7:s\148\144\169n\217\222n=u\190\f\147", _willMsg = -// "r\244\252S\171\236L\225\159\&2\192\246\223\255o)`\238\SOn\DC3", _willProps = []}), _cleanSession = False, _keepAlive -// = 12967, _connID = "\SI\255\178<\ETBPC\254\194 f:\152s}\165&\SO M`\251\NULx\STXiB", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "\207", _willMsg = "\237/\240\202>-v\139\210<\241\SOHK\239\SOHIk\183\205++\149GL\188\237\202", +// _willProps = []}), _cleanSession = True, _keepAlive = 14123, _connID = +// "\250\245\195\140\229m`\ETX\CAN9\SYN\SUBhP\159\204\202f\SOH\177f-\239", _properties = []} TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x66, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8c, 0x32, 0xa7, 0x0, 0x1b, 0xf, - 0xff, 0xb2, 0x3c, 0x17, 0x50, 0x43, 0xfe, 0xc2, 0x20, 0x66, 0x3a, 0x98, 0x73, 0x7d, 0xa5, - 0x26, 0xe, 0x20, 0x4d, 0x60, 0xfb, 0x0, 0x78, 0x2, 0x69, 0x42, 0x0, 0x18, 0xbb, 0x98, - 0x94, 0x79, 0x54, 0xc4, 0xa1, 0xb2, 0xcf, 0x37, 0x3a, 0x73, 0x94, 0x90, 0xa9, 0x6e, 0xd9, - 0xde, 0x6e, 0x3d, 0x75, 0xbe, 0xc, 0x93, 0x0, 0x15, 0x72, 0xf4, 0xfc, 0x53, 0xab, 0xec, - 0x4c, 0xe1, 0x9f, 0x32, 0xc0, 0xf6, 0xdf, 0xff, 0x6f, 0x29, 0x60, 0xee, 0xe, 0x6e, 0x13, - 0x0, 0xc, 0x5c, 0x24, 0xf5, 0x7f, 0x67, 0xb4, 0x36, 0x88, 0x6e, 0xb1, 0x53, 0x99}; - - uint8_t buf[114] = {0}; + uint8_t pkt[] = {0x10, 0x43, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x37, 0x2b, 0x0, 0x17, + 0xfa, 0xf5, 0xc3, 0x8c, 0xe5, 0x6d, 0x60, 0x3, 0x18, 0x39, 0x16, 0x1a, 0x68, 0x50, + 0x9f, 0xcc, 0xca, 0x66, 0x1, 0xb1, 0x66, 0x2d, 0xef, 0x0, 0x1, 0xcf, 0x0, 0x1b, + 0xed, 0x2f, 0xf0, 0xca, 0x3e, 0x2d, 0x76, 0x8b, 0xd2, 0x3c, 0xf1, 0x1, 0x4b, 0xef, + 0x1, 0x49, 0x6b, 0xb7, 0xcd, 0x2b, 0x2b, 0x95, 0x47, 0x4c, 0xbc, 0xed, 0xca}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -1848,12 +1660,11 @@ TEST(Connect311QCTest, Encode1) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbb, 0x98, 0x94, 0x79, 0x54, 0xc4, 0xa1, 0xb2, 0xcf, 0x37, 0x3a, 0x73, - 0x94, 0x90, 0xa9, 0x6e, 0xd9, 0xde, 0x6e, 0x3d, 0x75, 0xbe, 0xc, 0x93}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x72, 0xf4, 0xfc, 0x53, 0xab, 0xec, 0x4c, 0xe1, 0x9f, 0x32, 0xc0, - 0xf6, 0xdf, 0xff, 0x6f, 0x29, 0x60, 0xee, 0xe, 0x6e, 0x13}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xcf}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xed, 0x2f, 0xf0, 0xca, 0x3e, 0x2d, 0x76, 0x8b, 0xd2, 0x3c, 0xf1, 0x1, 0x4b, 0xef, + 0x1, 0x49, 0x6b, 0xb7, 0xcd, 0x2b, 0x2b, 0x95, 0x47, 0x4c, 0xbc, 0xed, 0xca}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -1861,83 +1672,67 @@ TEST(Connect311QCTest, Encode1) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12967; - uint8_t client_id_bytes[] = {0xf, 0xff, 0xb2, 0x3c, 0x17, 0x50, 0x43, 0xfe, 0xc2, 0x20, 0x66, 0x3a, 0x98, 0x73, - 0x7d, 0xa5, 0x26, 0xe, 0x20, 0x4d, 0x60, 0xfb, 0x0, 0x78, 0x2, 0x69, 0x42}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 14123; + uint8_t client_id_bytes[] = {0xfa, 0xf5, 0xc3, 0x8c, 0xe5, 0x6d, 0x60, 0x3, 0x18, 0x39, 0x16, 0x1a, + 0x68, 0x50, 0x9f, 0xcc, 0xca, 0x66, 0x1, 0xb1, 0x66, 0x2d, 0xef}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x5c, 0x24, 0xf5, 0x7f, 0x67, 0xb4, 0x36, 0x88, 0x6e, 0xb1, 0x53, 0x99}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "b\178\DC3\167\181\244O`\DLE\131\239\236)\NAK*\179`\210\203-\213\144\135\193\157\221\244\182", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "5m\FS[\176f\152", _willMsg = -// "y\STX\EM\232\172\190s\130\201\153\199L\132n\189", _willProps = []}), _cleanSession = True, _keepAlive = 11130, -// _connID = "\DELq\DLE\242s\179\EM\158\193\158\ACKPz", _properties = []} +// ConnectRequest {_username = Just "\v\155$4", _password = Just "\SUB\f~0\216\NAKr)Qx3B6E\SO\214\193", _lastWill = +// Nothing, _cleanSession = True, _keepAlive = 2824, _connID = +// "\151'V\147\201r\NAK\243\154p\179\129\"9\bk$\156#\v\157\187\150x\CAN2\217", _properties = []} TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x33, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x2b, 0x7a, 0x0, 0xd, - 0x7f, 0x71, 0x10, 0xf2, 0x73, 0xb3, 0x19, 0x9e, 0xc1, 0x9e, 0x6, 0x50, 0x7a, 0x0, - 0x7, 0x35, 0x6d, 0x1c, 0x5b, 0xb0, 0x66, 0x98, 0x0, 0xf, 0x79, 0x2, 0x19, 0xe8, - 0xac, 0xbe, 0x73, 0x82, 0xc9, 0x99, 0xc7, 0x4c, 0x84, 0x6e, 0xbd}; - - uint8_t buf[63] = {0}; + uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0xb, 0x8, 0x0, 0x1b, 0x97, 0x27, 0x56, + 0x93, 0xc9, 0x72, 0x15, 0xf3, 0x9a, 0x70, 0xb3, 0x81, 0x22, 0x39, 0x8, 0x6b, 0x24, 0x9c, 0x23, 0xb, + 0x9d, 0xbb, 0x96, 0x78, 0x18, 0x32, 0xd9, 0x0, 0x4, 0xb, 0x9b, 0x24, 0x34, 0x0, 0x11, 0x1a, 0xc, + 0x7e, 0x30, 0xd8, 0x15, 0x72, 0x29, 0x51, 0x78, 0x33, 0x42, 0x36, 0x45, 0xe, 0xd6, 0xc1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x35, 0x6d, 0x1c, 0x5b, 0xb0, 0x66, 0x98}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x79, 0x2, 0x19, 0xe8, 0xac, 0xbe, 0x73, 0x82, - 0xc9, 0x99, 0xc7, 0x4c, 0x84, 0x6e, 0xbd}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 11130; - uint8_t client_id_bytes[] = {0x7f, 0x71, 0x10, 0xf2, 0x73, 0xb3, 0x19, 0x9e, 0xc1, 0x9e, 0x6, 0x50, 0x7a}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.keep_alive = 2824; + uint8_t client_id_bytes[] = {0x97, 0x27, 0x56, 0x93, 0xc9, 0x72, 0x15, 0xf3, 0x9a, 0x70, 0xb3, 0x81, 0x22, 0x39, + 0x8, 0x6b, 0x24, 0x9c, 0x23, 0xb, 0x9d, 0xbb, 0x96, 0x78, 0x18, 0x32, 0xd9}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x62, 0xb2, 0x13, 0xa7, 0xb5, 0xf4, 0x4f, 0x60, 0x10, 0x83, 0xef, 0xec, 0x29, 0x15, - 0x2a, 0xb3, 0x60, 0xd2, 0xcb, 0x2d, 0xd5, 0x90, 0x87, 0xc1, 0x9d, 0xdd, 0xf4, 0xb6}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xb, 0x9b, 0x24, 0x34}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x1a, 0xc, 0x7e, 0x30, 0xd8, 0x15, 0x72, 0x29, 0x51, + 0x78, 0x33, 0x42, 0x36, 0x45, 0xe, 0xd6, 0xc1}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "$J\t\NUL\130\250\238\188R\250\153\177\ETB\216wo\RS9%X\251e#\SO\201\147", _password -// = Just "\\\218\240\185\155\162\192\252t\131\184HV\192\235", _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS2, _willTopic = "\157\174", _willMsg = "\147\218", _willProps = []}), _cleanSession = False, _keepAlive = 6678, -// _connID = "\179\rO`Y", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS0, _willTopic = "5kK\NUL\RS-\163\145\193\178\170I\198\175\DEL$\176\\\DLEo\DC46", _willMsg = +// "&\155\228\DC3\235\180\DC4#\220\198R\206\178[\NAK\149_\245\206\172\NUL\204\US\211UA", _willProps = []}), +// _cleanSession = True, _keepAlive = 32140, _connID = "vC\248\155\177\213g]\198", _properties = []} TEST(Connect311QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x1a, 0x16, 0x0, 0x5, 0xb3, - 0xd, 0x4f, 0x60, 0x59, 0x0, 0x2, 0x9d, 0xae, 0x0, 0x2, 0x93, 0xda, 0x0, 0x1a, 0x24, - 0x4a, 0x9, 0x0, 0x82, 0xfa, 0xee, 0xbc, 0x52, 0xfa, 0x99, 0xb1, 0x17, 0xd8, 0x77, 0x6f, - 0x1e, 0x39, 0x25, 0x58, 0xfb, 0x65, 0x23, 0xe, 0xc9, 0x93, 0x0, 0xf, 0x5c, 0xda, 0xf0, - 0xb9, 0x9b, 0xa2, 0xc0, 0xfc, 0x74, 0x83, 0xb8, 0x48, 0x56, 0xc0, 0xeb}; - - uint8_t buf[82] = {0}; + uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x7d, 0x8c, 0x0, 0x9, 0x76, + 0x43, 0xf8, 0x9b, 0xb1, 0xd5, 0x67, 0x5d, 0xc6, 0x0, 0x16, 0x35, 0x6b, 0x4b, 0x0, 0x1e, + 0x2d, 0xa3, 0x91, 0xc1, 0xb2, 0xaa, 0x49, 0xc6, 0xaf, 0x7f, 0x24, 0xb0, 0x5c, 0x10, 0x6f, + 0x14, 0x36, 0x0, 0x1a, 0x26, 0x9b, 0xe4, 0x13, 0xeb, 0xb4, 0x14, 0x23, 0xdc, 0xc6, 0x52, + 0xce, 0xb2, 0x5b, 0x15, 0x95, 0x5f, 0xf5, 0xce, 0xac, 0x0, 0xcc, 0x1f, 0xd3, 0x55, 0x41}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -1947,49 +1742,46 @@ TEST(Connect311QCTest, Encode3) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9d, 0xae}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x93, 0xda}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x35, 0x6b, 0x4b, 0x0, 0x1e, 0x2d, 0xa3, 0x91, 0xc1, 0xb2, 0xaa, + 0x49, 0xc6, 0xaf, 0x7f, 0x24, 0xb0, 0x5c, 0x10, 0x6f, 0x14, 0x36}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x26, 0x9b, 0xe4, 0x13, 0xeb, 0xb4, 0x14, 0x23, 0xdc, 0xc6, 0x52, 0xce, 0xb2, + 0x5b, 0x15, 0x95, 0x5f, 0xf5, 0xce, 0xac, 0x0, 0xcc, 0x1f, 0xd3, 0x55, 0x41}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 6678; - uint8_t client_id_bytes[] = {0xb3, 0xd, 0x4f, 0x60, 0x59}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 32140; + uint8_t client_id_bytes[] = {0x76, 0x43, 0xf8, 0x9b, 0xb1, 0xd5, 0x67, 0x5d, 0xc6}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x24, 0x4a, 0x9, 0x0, 0x82, 0xfa, 0xee, 0xbc, 0x52, 0xfa, 0x99, 0xb1, 0x17, - 0xd8, 0x77, 0x6f, 0x1e, 0x39, 0x25, 0x58, 0xfb, 0x65, 0x23, 0xe, 0xc9, 0x93}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x5c, 0xda, 0xf0, 0xb9, 0x9b, 0xa2, 0xc0, 0xfc, 0x74, 0x83, 0xb8, 0x48, 0x56, 0xc0, 0xeb}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\ETX\162\182\251\&5\254\129A\181!!/ -// \229\172\171\204\210R\201\DC1\250\190\&4_\"X\154", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = "\130\DEL/\236|]", _willMsg = "\161\186\166\161\248x\189;\ETX\167", _willProps = -// []}), _cleanSession = False, _keepAlive = 31398, _connID = "\165=K\CAN\208~\SYN\241*\f6#\208H\198\177p.", _properties -// = []} +// ConnectRequest {_username = Nothing, _password = Just "\181\188RC|\DELPc[\242A\194\140G\NAK\CANu\DC4\178\213\DC4", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "\249=\212\228i\201\&4\178&\RS)\DC4|\174\242w \201", _willMsg = +// "@\162c\242\CAN\208f\191d\161\222\184@fP\222\&7\204\176\212\227_\166\242\155W<\DC43", _willProps = []}), +// _cleanSession = True, _keepAlive = 8577, _connID = +// "\246\235\226\ACK\SI+\255\134\137\158\247\158\138X\147\188\139\218-\154", _properties = []} TEST(Connect311QCTest, Encode4) { - uint8_t pkt[] = {0x10, 0x50, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x94, 0x7a, 0xa6, 0x0, 0x12, 0xa5, 0x3d, 0x4b, - 0x18, 0xd0, 0x7e, 0x16, 0xf1, 0x2a, 0xc, 0x36, 0x23, 0xd0, 0x48, 0xc6, 0xb1, 0x70, 0x2e, 0x0, 0x6, - 0x82, 0x7f, 0x2f, 0xec, 0x7c, 0x5d, 0x0, 0xa, 0xa1, 0xba, 0xa6, 0xa1, 0xf8, 0x78, 0xbd, 0x3b, 0x3, - 0xa7, 0x0, 0x1c, 0x3, 0xa2, 0xb6, 0xfb, 0x35, 0xfe, 0x81, 0x41, 0xb5, 0x21, 0x21, 0x2f, 0x20, 0xe5, - 0xac, 0xab, 0xcc, 0xd2, 0x52, 0xc9, 0x11, 0xfa, 0xbe, 0x34, 0x5f, 0x22, 0x58, 0x9a}; - - uint8_t buf[92] = {0}; + uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x21, 0x81, 0x0, 0x14, 0xf6, + 0xeb, 0xe2, 0x6, 0xf, 0x2b, 0xff, 0x86, 0x89, 0x9e, 0xf7, 0x9e, 0x8a, 0x58, 0x93, 0xbc, + 0x8b, 0xda, 0x2d, 0x9a, 0x0, 0x12, 0xf9, 0x3d, 0xd4, 0xe4, 0x69, 0xc9, 0x34, 0xb2, 0x26, + 0x1e, 0x29, 0x14, 0x7c, 0xae, 0xf2, 0x77, 0x20, 0xc9, 0x0, 0x1d, 0x40, 0xa2, 0x63, 0xf2, + 0x18, 0xd0, 0x66, 0xbf, 0x64, 0xa1, 0xde, 0xb8, 0x40, 0x66, 0x50, 0xde, 0x37, 0xcc, 0xb0, + 0xd4, 0xe3, 0x5f, 0xa6, 0xf2, 0x9b, 0x57, 0x3c, 0x14, 0x33}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -1999,48 +1791,49 @@ TEST(Connect311QCTest, Encode4) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x82, 0x7f, 0x2f, 0xec, 0x7c, 0x5d}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa1, 0xba, 0xa6, 0xa1, 0xf8, 0x78, 0xbd, 0x3b, 0x3, 0xa7}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xf9, 0x3d, 0xd4, 0xe4, 0x69, 0xc9, 0x34, 0xb2, 0x26, + 0x1e, 0x29, 0x14, 0x7c, 0xae, 0xf2, 0x77, 0x20, 0xc9}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x40, 0xa2, 0x63, 0xf2, 0x18, 0xd0, 0x66, 0xbf, 0x64, 0xa1, + 0xde, 0xb8, 0x40, 0x66, 0x50, 0xde, 0x37, 0xcc, 0xb0, 0xd4, + 0xe3, 0x5f, 0xa6, 0xf2, 0x9b, 0x57, 0x3c, 0x14, 0x33}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 31398; - uint8_t client_id_bytes[] = {0xa5, 0x3d, 0x4b, 0x18, 0xd0, 0x7e, 0x16, 0xf1, 0x2a, - 0xc, 0x36, 0x23, 0xd0, 0x48, 0xc6, 0xb1, 0x70, 0x2e}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 8577; + uint8_t client_id_bytes[] = {0xf6, 0xeb, 0xe2, 0x6, 0xf, 0x2b, 0xff, 0x86, 0x89, 0x9e, + 0xf7, 0x9e, 0x8a, 0x58, 0x93, 0xbc, 0x8b, 0xda, 0x2d, 0x9a}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x3, 0xa2, 0xb6, 0xfb, 0x35, 0xfe, 0x81, 0x41, 0xb5, 0x21, 0x21, 0x2f, 0x20, 0xe5, - 0xac, 0xab, 0xcc, 0xd2, 0x52, 0xc9, 0x11, 0xfa, 0xbe, 0x34, 0x5f, 0x22, 0x58, 0x9a}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; - opts.username = username; + uint8_t password_bytes[] = {0xb5, 0xbc, 0x52, 0x43, 0x7c, 0x7f, 0x50, 0x63, 0x5b, 0xf2, 0x41, + 0xc2, 0x8c, 0x47, 0x15, 0x18, 0x75, 0x14, 0xb2, 0xd5, 0x14}; + lwmqtt_string_t password = {21, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "GM0)\182\157\&9s", _password = Just -// "nBK\142m\DEL\248~\175W\169oW\173\176\EM7\245\222c%\177", _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS0, _willTopic = "<\166\216{\222\a\STX\238\153\rd\166Zm\206JH\vO\242\143\&7\163\173\233\EOT&Q", _willMsg = -// "\243x\161_\SUB\249f\DC3", _willProps = []}), _cleanSession = True, _keepAlive = 11821, _connID = "\EOT", _properties -// = []} +// ConnectRequest {_username = Just "\ETB\185M\SUB\222\149", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\128\ETB\EOT\205\173", _willMsg = +// "\198\DC3l\140\230R!E$\SOH\229o,x\187~\139\202\"\DC4V\ACK)", _willProps = []}), _cleanSession = False, _keepAlive = +// 3023, _connID = "]l\128mk1J\129p\141\170Rw\178\NUL\171w\196\n", _properties = []} TEST(Connect311QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0x57, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x2e, 0x2d, 0x0, 0x1, 0x4, - 0x0, 0x1c, 0x3c, 0xa6, 0xd8, 0x7b, 0xde, 0x7, 0x2, 0xee, 0x99, 0xd, 0x64, 0xa6, 0x5a, - 0x6d, 0xce, 0x4a, 0x48, 0xb, 0x4f, 0xf2, 0x8f, 0x37, 0xa3, 0xad, 0xe9, 0x4, 0x26, 0x51, - 0x0, 0x8, 0xf3, 0x78, 0xa1, 0x5f, 0x1a, 0xf9, 0x66, 0x13, 0x0, 0x8, 0x47, 0x4d, 0x30, - 0x29, 0xb6, 0x9d, 0x39, 0x73, 0x0, 0x16, 0x6e, 0x42, 0x4b, 0x8e, 0x6d, 0x7f, 0xf8, 0x7e, - 0xaf, 0x57, 0xa9, 0x6f, 0x57, 0xad, 0xb0, 0x19, 0x37, 0xf5, 0xde, 0x63, 0x25, 0xb1}; - - uint8_t buf[99] = {0}; + uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb4, 0xb, 0xcf, 0x0, 0x13, 0x5d, + 0x6c, 0x80, 0x6d, 0x6b, 0x31, 0x4a, 0x81, 0x70, 0x8d, 0xaa, 0x52, 0x77, 0xb2, 0x0, 0xab, + 0x77, 0xc4, 0xa, 0x0, 0x5, 0x80, 0x17, 0x4, 0xcd, 0xad, 0x0, 0x17, 0xc6, 0x13, 0x6c, + 0x8c, 0xe6, 0x52, 0x21, 0x45, 0x24, 0x1, 0xe5, 0x6f, 0x2c, 0x78, 0xbb, 0x7e, 0x8b, 0xca, + 0x22, 0x14, 0x56, 0x6, 0x29, 0x0, 0x6, 0x17, 0xb9, 0x4d, 0x1a, 0xde, 0x95}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -2050,50 +1843,49 @@ TEST(Connect311QCTest, Encode5) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3c, 0xa6, 0xd8, 0x7b, 0xde, 0x7, 0x2, 0xee, 0x99, 0xd, 0x64, 0xa6, 0x5a, 0x6d, - 0xce, 0x4a, 0x48, 0xb, 0x4f, 0xf2, 0x8f, 0x37, 0xa3, 0xad, 0xe9, 0x4, 0x26, 0x51}; - lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf3, 0x78, 0xa1, 0x5f, 0x1a, 0xf9, 0x66, 0x13}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x80, 0x17, 0x4, 0xcd, 0xad}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc6, 0x13, 0x6c, 0x8c, 0xe6, 0x52, 0x21, 0x45, 0x24, 0x1, 0xe5, 0x6f, + 0x2c, 0x78, 0xbb, 0x7e, 0x8b, 0xca, 0x22, 0x14, 0x56, 0x6, 0x29}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS2; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 11821; - uint8_t client_id_bytes[] = {0x4}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 3023; + uint8_t client_id_bytes[] = {0x5d, 0x6c, 0x80, 0x6d, 0x6b, 0x31, 0x4a, 0x81, 0x70, 0x8d, + 0xaa, 0x52, 0x77, 0xb2, 0x0, 0xab, 0x77, 0xc4, 0xa}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x47, 0x4d, 0x30, 0x29, 0xb6, 0x9d, 0x39, 0x73}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x17, 0xb9, 0x4d, 0x1a, 0xde, 0x95}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x6e, 0x42, 0x4b, 0x8e, 0x6d, 0x7f, 0xf8, 0x7e, 0xaf, 0x57, 0xa9, - 0x6f, 0x57, 0xad, 0xb0, 0x19, 0x37, 0xf5, 0xde, 0x63, 0x25, 0xb1}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\213\218\180\190MN\136\210\233\DC2\224\201\191:0\161RI\197\210\192\GSV=", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\r|\168fB\231\&1h", _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "\196", _willMsg = "\189\206O\203\f\146\165\155D\200N\207\198\169;$\242\244\228", _willProps = +// []}), _cleanSession = True, _keepAlive = 14044, _connID = "\158\230\170S\NUL\239\ETB", _properties = []} TEST(Connect311QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x51, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x67, 0x72, 0x0, 0xb, 0xcb, 0x7c, 0x4d, - 0xfa, 0x72, 0x37, 0x66, 0x7c, 0x35, 0xb1, 0xef, 0x0, 0x3, 0x74, 0xa3, 0xe4, 0x0, 0x1c, 0x1c, 0xe3, - 0x97, 0xc, 0xbf, 0x20, 0x0, 0x91, 0xa6, 0x21, 0x9a, 0x9d, 0xcd, 0x3d, 0x93, 0x7c, 0x6f, 0x45, 0xe, - 0xa3, 0x13, 0xdd, 0x8b, 0x9c, 0xea, 0xf1, 0x5c, 0x28, 0x0, 0xb, 0xa6, 0x3, 0x22, 0xea, 0x44, 0xf9, - 0x4a, 0x38, 0xb0, 0xe6, 0x2d, 0x0, 0x8, 0xb5, 0x22, 0x5, 0x9d, 0x89, 0x4c, 0x1f, 0x2c}; - - uint8_t buf[93] = {0}; + uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x36, 0xdc, 0x0, 0x7, 0x9e, 0xe6, + 0xaa, 0x53, 0x0, 0xef, 0x17, 0x0, 0x1, 0xc4, 0x0, 0x13, 0xbd, 0xce, 0x4f, 0xcb, 0xc, 0x92, + 0xa5, 0x9b, 0x44, 0xc8, 0x4e, 0xcf, 0xc6, 0xa9, 0x3b, 0x24, 0xf2, 0xf4, 0xe4, 0x0, 0xc, 0xa4, + 0x1b, 0xb8, 0x8c, 0x72, 0xf9, 0xf3, 0x3a, 0x7e, 0xb6, 0xb1, 0xa1, 0x0, 0x12, 0x3d, 0x89, 0x98, + 0xc1, 0x1c, 0x8a, 0x18, 0xe, 0x1d, 0xac, 0x3d, 0x24, 0xb3, 0xb2, 0x3d, 0xe3, 0xd8, 0x3e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -2206,11 +1999,11 @@ TEST(Connect311QCTest, Encode8) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x74, 0xa3, 0xe4}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1c, 0xe3, 0x97, 0xc, 0xbf, 0x20, 0x0, 0x91, 0xa6, 0x21, 0x9a, 0x9d, 0xcd, 0x3d, - 0x93, 0x7c, 0x6f, 0x45, 0xe, 0xa3, 0x13, 0xdd, 0x8b, 0x9c, 0xea, 0xf1, 0x5c, 0x28}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xc4}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xbd, 0xce, 0x4f, 0xcb, 0xc, 0x92, 0xa5, 0x9b, 0x44, 0xc8, + 0x4e, 0xcf, 0xc6, 0xa9, 0x3b, 0x24, 0xf2, 0xf4, 0xe4}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -2218,85 +2011,75 @@ TEST(Connect311QCTest, Encode8) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 26482; - uint8_t client_id_bytes[] = {0xcb, 0x7c, 0x4d, 0xfa, 0x72, 0x37, 0x66, 0x7c, 0x35, 0xb1, 0xef}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 14044; + uint8_t client_id_bytes[] = {0x9e, 0xe6, 0xaa, 0x53, 0x0, 0xef, 0x17}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa6, 0x3, 0x22, 0xea, 0x44, 0xf9, 0x4a, 0x38, 0xb0, 0xe6, 0x2d}; - lwmqtt_string_t username = {11, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa4, 0x1b, 0xb8, 0x8c, 0x72, 0xf9, 0xf3, 0x3a, 0x7e, 0xb6, 0xb1, 0xa1}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xb5, 0x22, 0x5, 0x9d, 0x89, 0x4c, 0x1f, 0x2c}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x3d, 0x89, 0x98, 0xc1, 0x1c, 0x8a, 0x18, 0xe, 0x1d, + 0xac, 0x3d, 0x24, 0xb3, 0xb2, 0x3d, 0xe3, 0xd8, 0x3e}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\RSYG\vm5p\188\128\155\248\238J;\221\217B\211\170%\241\&9*R ", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\207\240\217\DLE\243\157", _willMsg = -// "\v\143\189\245\140\200_\255\201%\EOTa\240\ESC\170\&4\160\216\CAN\193O\ACK\245\EOT8vEam&", _willProps = []}), -// _cleanSession = False, _keepAlive = 4261, _connID = "T\208\249\166\143\DC3\200/\202", _properties = []} +// ConnectRequest {_username = Just "bl\173\212\183[K\243\204\225\r\255\210,\215\200\142\&1\181\SOH8\206\168", _password +// = Just "\NUL. m\211I\167\170\222\224%\253#\246", _lastWill = Nothing, _cleanSession = False, _keepAlive = 24572, +// _connID = "\182$y\234\226\247:S\142\"\245_\255\&0\203\191_\249P\SUB8\223\190]0\182\ETBg<", _properties = []} TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x10, 0xa5, 0x0, 0x9, 0x54, 0xd0, - 0xf9, 0xa6, 0x8f, 0x13, 0xc8, 0x2f, 0xca, 0x0, 0x6, 0xcf, 0xf0, 0xd9, 0x10, 0xf3, 0x9d, 0x0, - 0x1e, 0xb, 0x8f, 0xbd, 0xf5, 0x8c, 0xc8, 0x5f, 0xff, 0xc9, 0x25, 0x4, 0x61, 0xf0, 0x1b, 0xaa, - 0x34, 0xa0, 0xd8, 0x18, 0xc1, 0x4f, 0x6, 0xf5, 0x4, 0x38, 0x76, 0x45, 0x61, 0x6d, 0x26}; - - uint8_t buf[73] = {0}; + uint8_t pkt[] = {0x10, 0x52, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x5f, 0xfc, 0x0, 0x1d, 0xb6, 0x24, 0x79, + 0xea, 0xe2, 0xf7, 0x3a, 0x53, 0x8e, 0x22, 0xf5, 0x5f, 0xff, 0x30, 0xcb, 0xbf, 0x5f, 0xf9, 0x50, 0x1a, + 0x38, 0xdf, 0xbe, 0x5d, 0x30, 0xb6, 0x17, 0x67, 0x3c, 0x0, 0x17, 0x62, 0x6c, 0xad, 0xd4, 0xb7, 0x5b, + 0x4b, 0xf3, 0xcc, 0xe1, 0xd, 0xff, 0xd2, 0x2c, 0xd7, 0xc8, 0x8e, 0x31, 0xb5, 0x1, 0x38, 0xce, 0xa8, + 0x0, 0xe, 0x0, 0x2e, 0x20, 0x6d, 0xd3, 0x49, 0xa7, 0xaa, 0xde, 0xe0, 0x25, 0xfd, 0x23, 0xf6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xcf, 0xf0, 0xd9, 0x10, 0xf3, 0x9d}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb, 0x8f, 0xbd, 0xf5, 0x8c, 0xc8, 0x5f, 0xff, 0xc9, 0x25, - 0x4, 0x61, 0xf0, 0x1b, 0xaa, 0x34, 0xa0, 0xd8, 0x18, 0xc1, - 0x4f, 0x6, 0xf5, 0x4, 0x38, 0x76, 0x45, 0x61, 0x6d, 0x26}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 4261; - uint8_t client_id_bytes[] = {0x54, 0xd0, 0xf9, 0xa6, 0x8f, 0x13, 0xc8, 0x2f, 0xca}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.keep_alive = 24572; + uint8_t client_id_bytes[] = {0xb6, 0x24, 0x79, 0xea, 0xe2, 0xf7, 0x3a, 0x53, 0x8e, 0x22, 0xf5, 0x5f, 0xff, 0x30, 0xcb, + 0xbf, 0x5f, 0xf9, 0x50, 0x1a, 0x38, 0xdf, 0xbe, 0x5d, 0x30, 0xb6, 0x17, 0x67, 0x3c}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x1e, 0x59, 0x47, 0xb, 0x6d, 0x35, 0x70, 0xbc, 0x80, 0x9b, 0xf8, 0xee, 0x4a, - 0x3b, 0xdd, 0xd9, 0x42, 0xd3, 0xaa, 0x25, 0xf1, 0x39, 0x2a, 0x52, 0x20}; - lwmqtt_string_t password = {25, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x62, 0x6c, 0xad, 0xd4, 0xb7, 0x5b, 0x4b, 0xf3, 0xcc, 0xe1, 0xd, 0xff, + 0xd2, 0x2c, 0xd7, 0xc8, 0x8e, 0x31, 0xb5, 0x1, 0x38, 0xce, 0xa8}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x0, 0x2e, 0x20, 0x6d, 0xd3, 0x49, 0xa7, 0xaa, 0xde, 0xe0, 0x25, 0xfd, 0x23, 0xf6}; + lwmqtt_string_t password = {14, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\241\185^\SOH4\186U}I\208\137\131M\161C\190\134\174(B\181", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "8\\s\tW\213@\b\174\150", _willMsg = -// "\245\248\244q)\133\&9%\158\ESC\a\252]Rco'^\200;", _willProps = []}), _cleanSession = True, _keepAlive = 15075, -// _connID = "~g'\172", _properties = []} +// ConnectRequest {_username = Just "=\CANt\155_d\FS\f:\252", _password = Just "J\175\SI\188\240", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\181\230\197Xq\187C@;P\208\&1\CAN\191\152w[\185`UI\CAN", _willMsg = "\151\DC4y'PM^\214\&0<^k\179\179:|", _willProps +// = []}), _cleanSession = False, _keepAlive = 147, _connID = "\252{\206-]\238\&1\253 \RS\SIy\178", _properties = []} TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0x3a, 0xe3, 0x0, 0x4, 0x7e, - 0x67, 0x27, 0xac, 0x0, 0xa, 0x38, 0x5c, 0x73, 0x9, 0x57, 0xd5, 0x40, 0x8, 0xae, 0x96, - 0x0, 0x14, 0xf5, 0xf8, 0xf4, 0x71, 0x29, 0x85, 0x39, 0x25, 0x9e, 0x1b, 0x7, 0xfc, 0x5d, - 0x52, 0x63, 0x6f, 0x27, 0x5e, 0xc8, 0x3b, 0x0, 0x15, 0xf1, 0xb9, 0x5e, 0x1, 0x34, 0xba, - 0x55, 0x7d, 0x49, 0xd0, 0x89, 0x83, 0x4d, 0xa1, 0x43, 0xbe, 0x86, 0xae, 0x28, 0x42, 0xb5}; - - uint8_t buf[85] = {0}; + uint8_t pkt[] = {0x10, 0x56, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x0, 0x93, 0x0, 0xd, 0xfc, + 0x7b, 0xce, 0x2d, 0x5d, 0xee, 0x31, 0xfd, 0x20, 0x1e, 0xf, 0x79, 0xb2, 0x0, 0x16, 0xb5, + 0xe6, 0xc5, 0x58, 0x71, 0xbb, 0x43, 0x40, 0x3b, 0x50, 0xd0, 0x31, 0x18, 0xbf, 0x98, 0x77, + 0x5b, 0xb9, 0x60, 0x55, 0x49, 0x18, 0x0, 0x10, 0x97, 0x14, 0x79, 0x27, 0x50, 0x4d, 0x5e, + 0xd6, 0x30, 0x3c, 0x5e, 0x6b, 0xb3, 0xb3, 0x3a, 0x7c, 0x0, 0xa, 0x3d, 0x18, 0x74, 0x9b, + 0x5f, 0x64, 0x1c, 0xc, 0x3a, 0xfc, 0x0, 0x5, 0x4a, 0xaf, 0xf, 0xbc, 0xf0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -2306,141 +2089,170 @@ TEST(Connect311QCTest, Encode10) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x38, 0x5c, 0x73, 0x9, 0x57, 0xd5, 0x40, 0x8, 0xae, 0x96}; - lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf5, 0xf8, 0xf4, 0x71, 0x29, 0x85, 0x39, 0x25, 0x9e, 0x1b, - 0x7, 0xfc, 0x5d, 0x52, 0x63, 0x6f, 0x27, 0x5e, 0xc8, 0x3b}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xb5, 0xe6, 0xc5, 0x58, 0x71, 0xbb, 0x43, 0x40, 0x3b, 0x50, 0xd0, + 0x31, 0x18, 0xbf, 0x98, 0x77, 0x5b, 0xb9, 0x60, 0x55, 0x49, 0x18}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x97, 0x14, 0x79, 0x27, 0x50, 0x4d, 0x5e, 0xd6, + 0x30, 0x3c, 0x5e, 0x6b, 0xb3, 0xb3, 0x3a, 0x7c}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 15075; - uint8_t client_id_bytes[] = {0x7e, 0x67, 0x27, 0xac}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 147; + uint8_t client_id_bytes[] = {0xfc, 0x7b, 0xce, 0x2d, 0x5d, 0xee, 0x31, 0xfd, 0x20, 0x1e, 0xf, 0x79, 0xb2}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf1, 0xb9, 0x5e, 0x1, 0x34, 0xba, 0x55, 0x7d, 0x49, 0xd0, 0x89, - 0x83, 0x4d, 0xa1, 0x43, 0xbe, 0x86, 0xae, 0x28, 0x42, 0xb5}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x3d, 0x18, 0x74, 0x9b, 0x5f, 0x64, 0x1c, 0xc, 0x3a, 0xfc}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x4a, 0xaf, 0xf, 0xbc, 0xf0}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\\$\245\DELg\180\&6\136n\177S\153", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = -// "\187\152\148yT\196\161\178\207\&7:s\148\144\169n\217\222n=u\190\f\147", _willMsg = -// "r\244\252S\171\236L\225\159\&2\192\246\223\255o)`\238\SOn\DC3", _willProps = [PropUserProperty "\"\202\175\250\f1P" -// "#\146\&6\222V{\147\145o\145",PropSubscriptionIdentifier 12,PropMaximumQoS 242,PropSubscriptionIdentifierAvailable -// 227,PropPayloadFormatIndicator 225,PropServerKeepAlive 634,PropMessageExpiryInterval 17255,PropTopicAlias -// 6501,PropSubscriptionIdentifierAvailable 163,PropServerReference -// "\156\210\219\147|C-U\164\164\195^!$s\163\136O\162\b\164\177\177\a\ENQ\SI\176",PropSessionExpiryInterval -// 8407,PropReceiveMaximum 6195,PropAuthenticationMethod "'x\180\132\203\&7",PropMessageExpiryInterval -// 17356,PropTopicAlias 15658,PropPayloadFormatIndicator 33,PropAuthenticationData -// "\206z\211G\253\206\EOT\215\&8\145g\197",PropServerKeepAlive 15035,PropMaximumQoS 20,PropCorrelationData -// "2V:]\177\SOH\FSU\"#1p\v1\214\164\147\185\221p\176\186",PropRetainAvailable 125]}), _cleanSession = False, _keepAlive -// = 12967, _connID = "\SI\255\178<\ETBPC\254\194 f:\152s}\165&\SO M`\251\NULx\STXiB", _properties = [PropReceiveMaximum -// 20333,PropSubscriptionIdentifierAvailable 181,PropRequestProblemInformation 241,PropTopicAliasMaximum -// 19826,PropAssignedClientIdentifier "\STX&",PropWildcardSubscriptionAvailable 16,PropMessageExpiryInterval -// 2481,PropSubscriptionIdentifier 3,PropMessageExpiryInterval 29790,PropRetainAvailable 51,PropMaximumQoS -// 175,PropMessageExpiryInterval 25868,PropSubscriptionIdentifierAvailable 209,PropMessageExpiryInterval -// 4206,PropPayloadFormatIndicator 43,PropPayloadFormatIndicator 55,PropTopicAliasMaximum 10371,PropServerKeepAlive -// 14124,PropWillDelayInterval 5820]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "\207", _willMsg = "\237/\240\202>-v\139\210<\241\SOHK\239\SOHIk\183\205++\149GL\188\237\202", +// _willProps = [PropAuthenticationData "\141\155\&1z\248\251\RS\248#\160\153\235\152",PropServerKeepAlive +// 8955,PropResponseInformation "\"|\207\189\138",PropReasonString +// "\GS$s\149\191\171E\209\184)\ACK\130\DC2=\b",PropSubscriptionIdentifierAvailable 38,PropRequestResponseInformation +// 113,PropMaximumPacketSize 6795,PropSharedSubscriptionAvailable 150,PropMaximumPacketSize 6747,PropTopicAlias +// 13645,PropAssignedClientIdentifier +// "\DC4\DC3Q\196L(\167I,\233\183\237\228\200q\234\232D5\214(\211_xYp\237\226",PropSubscriptionIdentifierAvailable +// 36,PropTopicAliasMaximum 23245,PropContentType "\251XH\239\176\191M\SO\224f\191\173",PropCorrelationData +// "\RSk?:xldE\183",PropMessageExpiryInterval 14702,PropTopicAlias 20067,PropServerKeepAlive 20511,PropTopicAliasMaximum +// 10614,PropRequestProblemInformation 4,PropSubscriptionIdentifier 11,PropReceiveMaximum 28122]}), _cleanSession = +// True, _keepAlive = 14123, _connID = "\250\245\195\140\229m`\ETX\CAN9\SYN\SUBhP\159\204\202f\SOH\177f-\239", +// _properties = [PropWillDelayInterval 31589,PropRetainAvailable 153,PropRetainAvailable +// 231,PropSharedSubscriptionAvailable 208,PropAssignedClientIdentifier "\GSf",PropSharedSubscriptionAvailable +// 135,PropWildcardSubscriptionAvailable 0,PropReceiveMaximum 28907,PropReceiveMaximum 25980,PropAuthenticationData +// "\ESC\169\247\ENQ\244\199\&3\189\211\vU\135\210\152)",PropAssignedClientIdentifier +// ":\SYN\242\142\160ER\200\173n)\208\141\&3P\213\237\199",PropRequestResponseInformation +// 94,PropWildcardSubscriptionAvailable 154,PropTopicAliasMaximum 14579,PropAuthenticationMethod +// "\ETX\226P\160\250",PropContentType "~\249T\SYNVWo\219z,\205\&9o.*\214\208~",PropAuthenticationMethod +// "",PropServerKeepAlive 18921,PropMaximumPacketSize 31691,PropSubscriptionIdentifier 29,PropAuthenticationMethod +// "\DC4\242`)\177\183i?\241\228<3\252\&9\184E\128\169p\b?`\136\148\145\149\249\"",PropRetainAvailable +// 68,PropWillDelayInterval 9234,PropRetainAvailable 190,PropTopicAlias 133,PropCorrelationData +// "\172\ENQi\145t\130\199\199l\144\204\215",PropCorrelationData "\248\177\US\238\196%"]} TEST(Connect5QCTest, Encode1) { uint8_t pkt[] = { - 0x10, 0xb8, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8c, 0x32, 0xa7, 0x3c, 0x21, 0x4f, 0x6d, 0x29, 0xb5, - 0x17, 0xf1, 0x22, 0x4d, 0x72, 0x12, 0x0, 0x2, 0x2, 0x26, 0x28, 0x10, 0x2, 0x0, 0x0, 0x9, 0xb1, 0xb, 0x3, - 0x2, 0x0, 0x0, 0x74, 0x5e, 0x25, 0x33, 0x24, 0xaf, 0x2, 0x0, 0x0, 0x65, 0xc, 0x29, 0xd1, 0x2, 0x0, 0x0, - 0x10, 0x6e, 0x1, 0x2b, 0x1, 0x37, 0x22, 0x28, 0x83, 0x13, 0x37, 0x2c, 0x18, 0x0, 0x0, 0x16, 0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 0x37, 0x3a, 0x73, - 0x94, 0x90, 0xa9, 0x6e, 0xd9, 0xde, 0x6e, 0x3d, 0x75, 0xbe, 0xc, 0x93, 0x0, 0x15, 0x72, 0xf4, 0xfc, 0x53, 0xab, - 0xec, 0x4c, 0xe1, 0x9f, 0x32, 0xc0, 0xf6, 0xdf, 0xff, 0x6f, 0x29, 0x60, 0xee, 0xe, 0x6e, 0x13, 0x0, 0xc, 0x5c, - 0x24, 0xf5, 0x7f, 0x67, 0xb4, 0x36, 0x88, 0x6e, 0xb1, 0x53, 0x99}; - - uint8_t buf[325] = {0}; - uint8_t bytesprops0[] = {0x2, 0x26}; + 0x10, 0x90, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe, 0x37, 0x2b, 0xb5, 0x1, 0x18, 0x0, 0x0, 0x7b, + 0x65, 0x25, 0x99, 0x25, 0xe7, 0x2a, 0xd0, 0x12, 0x0, 0x2, 0x1d, 0x66, 0x2a, 0x87, 0x28, 0x0, 0x21, 0x70, 0xeb, + 0x21, 0x65, 0x7c, 0x16, 0x0, 0xf, 0x1b, 0xa9, 0xf7, 0x5, 0xf4, 0xc7, 0x33, 0xbd, 0xd3, 0xb, 0x55, 0x87, 0xd2, + 0x98, 0x29, 0x12, 0x0, 0x12, 0x3a, 0x16, 0xf2, 0x8e, 0xa0, 0x45, 0x52, 0xc8, 0xad, 0x6e, 0x29, 0xd0, 0x8d, 0x33, + 0x50, 0xd5, 0xed, 0xc7, 0x19, 0x5e, 0x28, 0x9a, 0x22, 0x38, 0xf3, 0x15, 0x0, 0x5, 0x3, 0xe2, 0x50, 0xa0, 0xfa, + 0x3, 0x0, 0x12, 0x7e, 0xf9, 0x54, 0x16, 0x56, 0x57, 0x6f, 0xdb, 0x7a, 0x2c, 0xcd, 0x39, 0x6f, 0x2e, 0x2a, 0xd6, + 0xd0, 0x7e, 0x15, 0x0, 0x0, 0x13, 0x49, 0xe9, 0x27, 0x0, 0x0, 0x7b, 0xcb, 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 0x70, 0xed, 0xe2, 0x29, 0x24, 0x22, 0x5a, 0xcd, + 0x3, 0x0, 0xc, 0xfb, 0x58, 0x48, 0xef, 0xb0, 0xbf, 0x4d, 0xe, 0xe0, 0x66, 0xbf, 0xad, 0x9, 0x0, 0x9, 0x1e, + 0x6b, 0x3f, 0x3a, 0x78, 0x6c, 0x64, 0x45, 0xb7, 0x2, 0x0, 0x0, 0x39, 0x6e, 0x23, 0x4e, 0x63, 0x13, 0x50, 0x1f, + 0x22, 0x29, 0x76, 0x17, 0x4, 0xb, 0xb, 0x21, 0x6d, 0xda, 0x0, 0x1, 0xcf, 0x0, 0x1b, 0xed, 0x2f, 0xf0, 0xca, + 0x3e, 0x2d, 0x76, 0x8b, 0xd2, 0x3c, 0xf1, 0x1, 0x4b, 0xef, 0x1, 0x49, 0x6b, 0xb7, 0xcd, 0x2b, 0x2b, 0x95, 0x47, + 0x4c, 0xbc, 0xed, 0xca}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1d, 0x66}; + uint8_t bytesprops1[] = {0x1b, 0xa9, 0xf7, 0x5, 0xf4, 0xc7, 0x33, 0xbd, 0xd3, 0xb, 0x55, 0x87, 0xd2, 0x98, 0x29}; + uint8_t bytesprops2[] = {0x3a, 0x16, 0xf2, 0x8e, 0xa0, 0x45, 0x52, 0xc8, 0xad, + 0x6e, 0x29, 0xd0, 0x8d, 0x33, 0x50, 0xd5, 0xed, 0xc7}; + uint8_t bytesprops3[] = {0x3, 0xe2, 0x50, 0xa0, 0xfa}; + uint8_t bytesprops4[] = {0x7e, 0xf9, 0x54, 0x16, 0x56, 0x57, 0x6f, 0xdb, 0x7a, + 0x2c, 0xcd, 0x39, 0x6f, 0x2e, 0x2a, 0xd6, 0xd0, 0x7e}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0x14, 0xf2, 0x60, 0x29, 0xb1, 0xb7, 0x69, 0x3f, 0xf1, 0xe4, 0x3c, 0x33, 0xfc, 0x39, + 0xb8, 0x45, 0x80, 0xa9, 0x70, 0x8, 0x3f, 0x60, 0x88, 0x94, 0x91, 0x95, 0xf9, 0x22}; + uint8_t bytesprops7[] = {0xac, 0x5, 0x69, 0x91, 0x74, 0x82, 0xc7, 0xc7, 0x6c, 0x90, 0xcc, 0xd7}; + uint8_t bytesprops8[] = {0xf8, 0xb1, 0x1f, 0xee, 0xc4, 0x25}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20333}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19826}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31589}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 208}}, {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2481}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29790}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25868}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4206}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10371}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14124}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5820}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28907}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25980}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14579}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18921}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31691}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9234}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 133}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x23, 0x92, 0x36, 0xde, 0x56, 0x7b, 0x93, 0x91, 0x6f, 0x91}; - uint8_t byteswillprops0[] = {0x22, 0xca, 0xaf, 0xfa, 0xc, 0x31, 0x50}; - uint8_t byteswillprops2[] = {0x9c, 0xd2, 0xdb, 0x93, 0x7c, 0x43, 0x2d, 0x55, 0xa4, 0xa4, 0xc3, 0x5e, 0x21, 0x24, - 0x73, 0xa3, 0x88, 0x4f, 0xa2, 0x8, 0xa4, 0xb1, 0xb1, 0x7, 0x5, 0xf, 0xb0}; - uint8_t byteswillprops3[] = {0x27, 0x78, 0xb4, 0x84, 0xcb, 0x37}; - uint8_t byteswillprops4[] = {0xce, 0x7a, 0xd3, 0x47, 0xfd, 0xce, 0x4, 0xd7, 0x38, 0x91, 0x67, 0xc5}; - uint8_t byteswillprops5[] = {0x32, 0x56, 0x3a, 0x5d, 0xb1, 0x1, 0x1c, 0x55, 0x22, 0x23, 0x31, - 0x70, 0xb, 0x31, 0xd6, 0xa4, 0x93, 0xb9, 0xdd, 0x70, 0xb0, 0xba}; + uint8_t byteswillprops0[] = {0x8d, 0x9b, 0x31, 0x7a, 0xf8, 0xfb, 0x1e, 0xf8, 0x23, 0xa0, 0x99, 0xeb, 0x98}; + uint8_t byteswillprops1[] = {0x22, 0x7c, 0xcf, 0xbd, 0x8a}; + uint8_t byteswillprops2[] = {0x1d, 0x24, 0x73, 0x95, 0xbf, 0xab, 0x45, 0xd1, 0xb8, 0x29, 0x6, 0x82, 0x12, 0x3d, 0x8}; + uint8_t byteswillprops3[] = {0x14, 0x13, 0x51, 0xc4, 0x4c, 0x28, 0xa7, 0x49, 0x2c, 0xe9, 0xb7, 0xed, 0xe4, 0xc8, + 0x71, 0xea, 0xe8, 0x44, 0x35, 0xd6, 0x28, 0xd3, 0x5f, 0x78, 0x59, 0x70, 0xed, 0xe2}; + uint8_t byteswillprops4[] = {0xfb, 0x58, 0x48, 0xef, 0xb0, 0xbf, 0x4d, 0xe, 0xe0, 0x66, 0xbf, 0xad}; + uint8_t byteswillprops5[] = {0x1e, 0x6b, 0x3f, 0x3a, 0x78, 0x6c, 0x64, 0x45, 0xb7}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {7, (char*)&byteswillprops0}, .v = {10, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 634}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17255}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6501}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8407}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6195}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17356}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15658}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15035}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8955}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6795}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6747}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13645}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23245}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14702}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20067}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20511}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10614}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28122}}, }; - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbb, 0x98, 0x94, 0x79, 0x54, 0xc4, 0xa1, 0xb2, 0xcf, 0x37, 0x3a, 0x73, - 0x94, 0x90, 0xa9, 0x6e, 0xd9, 0xde, 0x6e, 0x3d, 0x75, 0xbe, 0xc, 0x93}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x72, 0xf4, 0xfc, 0x53, 0xab, 0xec, 0x4c, 0xe1, 0x9f, 0x32, 0xc0, - 0xf6, 0xdf, 0xff, 0x6f, 0x29, 0x60, 0xee, 0xe, 0x6e, 0x13}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xcf}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xed, 0x2f, 0xf0, 0xca, 0x3e, 0x2d, 0x76, 0x8b, 0xd2, 0x3c, 0xf1, 0x1, 0x4b, 0xef, + 0x1, 0x49, 0x6b, 0xb7, 0xcd, 0x2b, 0x2b, 0x95, 0x47, 0x4c, 0xbc, 0xed, 0xca}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -2448,661 +2260,767 @@ TEST(Connect5QCTest, Encode1) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12967; - uint8_t client_id_bytes[] = {0xf, 0xff, 0xb2, 0x3c, 0x17, 0x50, 0x43, 0xfe, 0xc2, 0x20, 0x66, 0x3a, 0x98, 0x73, - 0x7d, 0xa5, 0x26, 0xe, 0x20, 0x4d, 0x60, 0xfb, 0x0, 0x78, 0x2, 0x69, 0x42}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 14123; + uint8_t client_id_bytes[] = {0xfa, 0xf5, 0xc3, 0x8c, 0xe5, 0x6d, 0x60, 0x3, 0x18, 0x39, 0x16, 0x1a, + 0x68, 0x50, 0x9f, 0xcc, 0xca, 0x66, 0x1, 0xb1, 0x66, 0x2d, 0xef}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x5c, 0x24, 0xf5, 0x7f, 0x67, 0xb4, 0x36, 0x88, 0x6e, 0xb1, 0x53, 0x99}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "b\178\DC3\167\181\244O`\DLE\131\239\236)\NAK*\179`\210\203-\213\144\135\193\157\221\244\182", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "5m\FS[\176f\152", _willMsg = -// "y\STX\EM\232\172\190s\130\201\153\199L\132n\189", _willProps = [PropUserProperty "\219\190\FS" ""]}), _cleanSession -// = True, _keepAlive = 11130, _connID = "\DELq\DLE\242s\179\EM\158\193\158\ACKPz", _properties = -// [PropResponseInformation "\150Z",PropAuthenticationData "\\\157",PropResponseTopic -// "=C\DC2\252\157P\DC1\FS\143\SUB\183\212%[s\221\242\150\246\170\159\180\221\ACK>4",PropRequestResponseInformation -// 187,PropSubscriptionIdentifier 14,PropUserProperty "\b3\241\"\155?\146\204+\204\236\203\ESCV" -// "n\193r\ESCA4\146\ESC\CAN\226\"\204\221\163c\224?\219]\229PD,\249\b\138",PropMaximumQoS -// 58,PropRequestProblemInformation 16,PropReceiveMaximum 8160,PropTopicAlias 23979]} +// ConnectRequest {_username = Just "\v\155$4", _password = Just "\SUB\f~0\216\NAKr)Qx3B6E\SO\214\193", _lastWill = +// Nothing, _cleanSession = True, _keepAlive = 2824, _connID = +// "\151'V\147\201r\NAK\243\154p\179\129\"9\bk$\156#\v\157\187\150x\CAN2\217", _properties = [PropCorrelationData +// "\DLE\166\170\155\161N/\SUB\181\153\226\153t\240\222z\162\r\GS\161\&4cD$\ACK",PropServerKeepAlive +// 28555,PropAssignedClientIdentifier +// "\ETB\148\169\SUB\174mP\209\&5\251yz\150>\"\165\NUL\226\GS\208\254\&0\204\135+[",PropCorrelationData +// "wSs\140l\224!\240m\GS\181q\174\US{\243",PropTopicAlias 13037,PropCorrelationData +// "P+",PropSubscriptionIdentifierAvailable 185,PropMessageExpiryInterval 9737,PropWillDelayInterval +// 23768,PropWillDelayInterval 2041,PropTopicAliasMaximum 10457,PropWildcardSubscriptionAvailable 148,PropReceiveMaximum +// 10040,PropAuthenticationMethod "\178\DEL=\250\SO\\d",PropResponseTopic +// "x&\DC3\154C+\DLE\208!\152\207\DEL\134[q\208\193",PropPayloadFormatIndicator 30,PropAuthenticationData +// "!\215\185",PropSubscriptionIdentifier 18,PropUserProperty +// "\247\EOT\221>\EMV\202\NAK(x\215\152\154/\248\199\ACK\131\EMc\176\nl\196Kg\164\fI" +// "'\237\DLE\241\SOH\237\EOT\148\NAK\182\147\218(\ETB\212p){\171\198\189?x\137$\DLEP"]} TEST(Connect5QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x9f, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x2b, 0x7a, 0x62, 0x1a, 0x0, 0x2, - 0x96, 0x5a, 0x16, 0x0, 0x2, 0x5c, 0x9d, 0x8, 0x0, 0x1a, 0x3d, 0x43, 0x12, 0xfc, 0x9d, 0x50, 0x11, - 0x1c, 0x8f, 0x1a, 0xb7, 0xd4, 0x25, 0x5b, 0x73, 0xdd, 0xf2, 0x96, 0xf6, 0xaa, 0x9f, 0xb4, 0xdd, 0x6, - 0x3e, 0x34, 0x19, 0xbb, 0xb, 0xe, 0x26, 0x0, 0xe, 0x8, 0x33, 0xf1, 0x22, 0x9b, 0x3f, 0x92, 0xcc, - 0x2b, 0xcc, 0xec, 0xcb, 0x1b, 0x56, 0x0, 0x1a, 0x6e, 0xc1, 0x72, 0x1b, 0x41, 0x34, 0x92, 0x1b, 0x18, - 0xe2, 0x22, 0xcc, 0xdd, 0xa3, 0x63, 0xe0, 0x3f, 0xdb, 0x5d, 0xe5, 0x50, 0x44, 0x2c, 0xf9, 0x8, 0x8a, - 0x24, 0x3a, 0x17, 0x10, 0x21, 0x1f, 0xe0, 0x23, 0x5d, 0xab, 0x0, 0xd, 0x7f, 0x71, 0x10, 0xf2, 0x73, - 0xb3, 0x19, 0x9e, 0xc1, 0x9e, 0x6, 0x50, 0x7a, 0x8, 0x26, 0x0, 0x3, 0xdb, 0xbe, 0x1c, 0x0, 0x0, - 0x0, 0x7, 0x35, 0x6d, 0x1c, 0x5b, 0xb0, 0x66, 0x98, 0x0, 0xf, 0x79, 0x2, 0x19, 0xe8, 0xac, 0xbe, - 0x73, 0x82, 0xc9, 0x99, 0xc7, 0x4c, 0x84, 0x6e, 0xbd}; - - uint8_t buf[172] = {0}; - uint8_t bytesprops0[] = {0x96, 0x5a}; - uint8_t bytesprops1[] = {0x5c, 0x9d}; - uint8_t bytesprops2[] = {0x3d, 0x43, 0x12, 0xfc, 0x9d, 0x50, 0x11, 0x1c, 0x8f, 0x1a, 0xb7, 0xd4, 0x25, - 0x5b, 0x73, 0xdd, 0xf2, 0x96, 0xf6, 0xaa, 0x9f, 0xb4, 0xdd, 0x6, 0x3e, 0x34}; - uint8_t bytesprops4[] = {0x6e, 0xc1, 0x72, 0x1b, 0x41, 0x34, 0x92, 0x1b, 0x18, 0xe2, 0x22, 0xcc, 0xdd, - 0xa3, 0x63, 0xe0, 0x3f, 0xdb, 0x5d, 0xe5, 0x50, 0x44, 0x2c, 0xf9, 0x8, 0x8a}; - uint8_t bytesprops3[] = {0x8, 0x33, 0xf1, 0x22, 0x9b, 0x3f, 0x92, 0xcc, 0x2b, 0xcc, 0xec, 0xcb, 0x1b, 0x56}; + uint8_t pkt[] = { + 0x10, 0x97, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0xb, 0x8, 0xd5, 0x1, 0x9, 0x0, 0x19, 0x10, + 0xa6, 0xaa, 0x9b, 0xa1, 0x4e, 0x2f, 0x1a, 0xb5, 0x99, 0xe2, 0x99, 0x74, 0xf0, 0xde, 0x7a, 0xa2, 0xd, 0x1d, 0xa1, + 0x34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x50, + 0x0, 0x1b, 0x97, 0x27, 0x56, 0x93, 0xc9, 0x72, 0x15, 0xf3, 0x9a, 0x70, 0xb3, 0x81, 0x22, 0x39, 0x8, 0x6b, 0x24, + 0x9c, 0x23, 0xb, 0x9d, 0xbb, 0x96, 0x78, 0x18, 0x32, 0xd9, 0x0, 0x4, 0xb, 0x9b, 0x24, 0x34, 0x0, 0x11, 0x1a, + 0xc, 0x7e, 0x30, 0xd8, 0x15, 0x72, 0x29, 0x51, 0x78, 0x33, 0x42, 0x36, 0x45, 0xe, 0xd6, 0xc1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x10, 0xa6, 0xaa, 0x9b, 0xa1, 0x4e, 0x2f, 0x1a, 0xb5, 0x99, 0xe2, 0x99, 0x74, + 0xf0, 0xde, 0x7a, 0xa2, 0xd, 0x1d, 0xa1, 0x34, 0x63, 0x44, 0x24, 0x6}; + uint8_t bytesprops1[] = {0x17, 0x94, 0xa9, 0x1a, 0xae, 0x6d, 0x50, 0xd1, 0x35, 0xfb, 0x79, 0x7a, 0x96, + 0x3e, 0x22, 0xa5, 0x0, 0xe2, 0x1d, 0xd0, 0xfe, 0x30, 0xcc, 0x87, 0x2b, 0x5b}; + uint8_t bytesprops2[] = {0x77, 0x53, 0x73, 0x8c, 0x6c, 0xe0, 0x21, 0xf0, + 0x6d, 0x1d, 0xb5, 0x71, 0xae, 0x1f, 0x7b, 0xf3}; + uint8_t bytesprops3[] = {0x50, 0x2b}; + uint8_t bytesprops4[] = {0xb2, 0x7f, 0x3d, 0xfa, 0xe, 0x5c, 0x64}; + uint8_t bytesprops5[] = {0x78, 0x26, 0x13, 0x9a, 0x43, 0x2b, 0x10, 0xd0, 0x21, + 0x98, 0xcf, 0x7f, 0x86, 0x5b, 0x71, 0xd0, 0xc1}; + uint8_t bytesprops6[] = {0x21, 0xd7, 0xb9}; + uint8_t bytesprops8[] = {0x27, 0xed, 0x10, 0xf1, 0x1, 0xed, 0x4, 0x94, 0x15, 0xb6, 0x93, 0xda, 0x28, 0x17, + 0xd4, 0x70, 0x29, 0x7b, 0xab, 0xc6, 0xbd, 0x3f, 0x78, 0x89, 0x24, 0x10, 0x50}; + uint8_t bytesprops7[] = {0xf7, 0x4, 0xdd, 0x3e, 0x19, 0x56, 0xca, 0x15, 0x28, 0x78, 0xd7, 0x98, 0x9a, 0x2f, 0xf8, + 0xc7, 0x6, 0x83, 0x19, 0x63, 0xb0, 0xa, 0x6c, 0xc4, 0x4b, 0x67, 0xa4, 0xc, 0x49}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops3}, .v = {26, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8160}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23979}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0}; - uint8_t byteswillprops0[] = {0xdb, 0xbe, 0x1c}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {3, (char*)&byteswillprops0}, .v = {0, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28555}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13037}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9737}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23768}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2041}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10457}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10040}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops7}, .v = {27, (char*)&bytesprops8}}}}, }; - lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x35, 0x6d, 0x1c, 0x5b, 0xb0, 0x66, 0x98}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x79, 0x2, 0x19, 0xe8, 0xac, 0xbe, 0x73, 0x82, - 0xc9, 0x99, 0xc7, 0x4c, 0x84, 0x6e, 0xbd}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 11130; - uint8_t client_id_bytes[] = {0x7f, 0x71, 0x10, 0xf2, 0x73, 0xb3, 0x19, 0x9e, 0xc1, 0x9e, 0x6, 0x50, 0x7a}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.keep_alive = 2824; + uint8_t client_id_bytes[] = {0x97, 0x27, 0x56, 0x93, 0xc9, 0x72, 0x15, 0xf3, 0x9a, 0x70, 0xb3, 0x81, 0x22, 0x39, + 0x8, 0x6b, 0x24, 0x9c, 0x23, 0xb, 0x9d, 0xbb, 0x96, 0x78, 0x18, 0x32, 0xd9}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x62, 0xb2, 0x13, 0xa7, 0xb5, 0xf4, 0x4f, 0x60, 0x10, 0x83, 0xef, 0xec, 0x29, 0x15, - 0x2a, 0xb3, 0x60, 0xd2, 0xcb, 0x2d, 0xd5, 0x90, 0x87, 0xc1, 0x9d, 0xdd, 0xf4, 0xb6}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xb, 0x9b, 0x24, 0x34}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x1a, 0xc, 0x7e, 0x30, 0xd8, 0x15, 0x72, 0x29, 0x51, + 0x78, 0x33, 0x42, 0x36, 0x45, 0xe, 0xd6, 0xc1}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "$J\t\NUL\130\250\238\188R\250\153\177\ETB\216wo\RS9%X\251e#\SO\201\147", _password -// = Just "\\\218\240\185\155\162\192\252t\131\184HV\192\235", _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS2, _willTopic = "\157\174", _willMsg = "\147\218", _willProps = [PropSubscriptionIdentifier -// 16,PropRequestProblemInformation 60,PropSharedSubscriptionAvailable 100,PropTopicAlias 27717,PropResponseInformation -// "A\\\245\160\210\f\181_\213mor\SO'h\213\182\187\172+9\183\214L",PropSessionExpiryInterval -// 1861,PropMessageExpiryInterval 9152,PropMaximumPacketSize 13235,PropWillDelayInterval 27953,PropWillDelayInterval -// 22815,PropSessionExpiryInterval 3149,PropServerKeepAlive 22221]}), _cleanSession = False, _keepAlive = 6678, _connID -// = "\179\rO`Y", _properties = [PropContentType "\186\149\132\SI\235\143\182\&8`\ENQ\146\150",PropMaximumQoS -// 120,PropMessageExpiryInterval 30,PropMaximumPacketSize 32305,PropAuthenticationData "\208\182e\180=a\205c\f\182Z)\DC3 -// Aw\208w\209",PropAuthenticationData "\173\169\231\202z\249\GS\221\139F\181\242\185\146o>\225\139",PropContentType -// "\SO\t\SOH\229z\220p9\184\f\242\RSw\185(u\f\175\146\240",PropPayloadFormatIndicator 198,PropContentType -// "\186\234c\225\&9h\194\175\188.8At`u\189\240\240\144\139\237\149T\154(\196\243",PropContentType -// "|`\150\246\\\DC1\163F ]\187S\198\139:\176\230\251\&6\199\131r\198\192",PropMaximumQoS 91,PropMaximumQoS -// 204,PropMaximumQoS 189,PropCorrelationData "\249\227",PropAssignedClientIdentifier -// "\151Bz*\131j\231\233\234\192\230g\191\245\207\237\217I[\217",PropRequestProblemInformation -// 174,PropResponseInformation "\218\187\242\230\225\164b",PropSessionExpiryInterval -// 6339,PropSubscriptionIdentifierAvailable 124,PropTopicAliasMaximum 968,PropSharedSubscriptionAvailable -// 75,PropSubscriptionIdentifierAvailable 75,PropMaximumQoS 227,PropReasonString "$\235 -// \255\DC4\151\179\FS_\181IR\152\183\218\204\&07\134\NAK\237s\131\252\&67\EM\169TC",PropMessageExpiryInterval 1337]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS0, _willTopic = "5kK\NUL\RS-\163\145\193\178\170I\198\175\DEL$\176\\\DLEo\DC46", _willMsg = +// "&\155\228\DC3\235\180\DC4#\220\198R\206\178[\NAK\149_\245\206\172\NUL\204\US\211UA", _willProps = [PropContentType +// "\DC3:\145S\n\235\164\187?",PropUserProperty "@\190\173$\255\232\248\199\208\132\231\130V" +// "\189\DELI\DC3\146\ENQ\241\&1\DC1\194;<\169&\199\191",PropRequestProblemInformation 157,PropSessionExpiryInterval +// 2676,PropRequestProblemInformation 219,PropSubscriptionIdentifierAvailable 138,PropUserProperty +// "\237N\198/\176\139N\222GF\240\144&\247%\EOT\254q\157{\200\\" "\177\&8\222\185z\\\174\254\134\ESC\229 +// \128\EM\226L%\146",PropMessageExpiryInterval 2260,PropResponseInformation "\133dOZ\217\140P*=",PropRetainAvailable +// 122,PropResponseInformation "\171\208\245",PropResponseInformation +// "\201\243\207kk\208\251\204\&6\221!\nb\227j1\181\195\254\146\CAN\255\211",PropResponseInformation +// "\252\249\US\EM\131\255\187\159\141\137\232by",PropSubscriptionIdentifier 1,PropResponseTopic +// "\210MN)n:\246J\201\236%\204\166\244\ACK\181g_\215\217&\236\234\213\b\223L\228\232\181",PropAuthenticationData +// "\249E\182\164\SYN'\238\&3\133\190\254\"t\241+\225\t-U\187\187#z\208\219",PropMaximumPacketSize +// 16575,PropPayloadFormatIndicator 242,PropSessionExpiryInterval 14364,PropWillDelayInterval 8517,PropServerReference +// "n)\186\130\&6\241\&0e\238\170\SOH\136",PropCorrelationData "\222O%",PropRequestResponseInformation +// 46,PropAuthenticationData "O\ETB\208()\DC3\250AI\US",PropServerKeepAlive 3459,PropAuthenticationMethod ".v"]}), +// _cleanSession = True, _keepAlive = 32140, _connID = "vC\248\155\177\213g]\198", _properties = [PropMaximumPacketSize +// 4625,PropCorrelationData +// "\189\FSf\211\&5\225\SOHr\231\205\CAN\"j\171\DC1%\225p{,\DLEB\227\STXk@\140,<\215",PropMaximumPacketSize +// 27111,PropPayloadFormatIndicator 21,PropSubscriptionIdentifierAvailable 88,PropRetainAvailable +// 56,PropSubscriptionIdentifierAvailable 37,PropSessionExpiryInterval 27408,PropTopicAlias 30555,PropTopicAliasMaximum +// 30910,PropMaximumQoS 162,PropSharedSubscriptionAvailable 219,PropMaximumPacketSize 27447,PropUserProperty +// "o\tf\145@&H\b\184\232\232\134\GS}\222s\216\205u\190" +// "\213^\222\132\163\132\195qUw7\241e=\209\DEL\221J\135",PropReceiveMaximum 13982,PropReasonString +// "\239\155d\217\165\168\194{\ENQ\SUB\196\&1",PropWillDelayInterval 27839,PropSubscriptionIdentifier 17]} TEST(Connect5QCTest, Encode3) { uint8_t pkt[] = { - 0x10, 0x8a, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x1a, 0x16, 0xfc, 0x1, 0x3, 0x0, 0xc, 0xba, - 0x95, 0x84, 0xf, 0xeb, 0x8f, 0xb6, 0x38, 0x60, 0x5, 0x92, 0x96, 0x24, 0x78, 0x2, 0x0, 0x0, 0x0, 0x1e, 0x27, - 0x0, 0x0, 0x7e, 0x31, 0x16, 0x0, 0x13, 0xd0, 0xb6, 0x65, 0xb4, 0x3d, 0x61, 0xcd, 0x63, 0xc, 0xb6, 0x5a, 0x29, - 0x13, 0x20, 0x41, 0x77, 0xd0, 0x77, 0xd1, 0x16, 0x0, 0x12, 0xad, 0xa9, 0xe7, 0xca, 0x7a, 0xf9, 0x1d, 0xdd, 0x8b, - 0x46, 0xb5, 0xf2, 0xb9, 0x92, 0x6f, 0x3e, 0xe1, 0x8b, 0x3, 0x0, 0x14, 0xe, 0x9, 0x1, 0xe5, 0x7a, 0xdc, 0x70, - 0x39, 0xb8, 0xc, 0xf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0x0, 0x18, 0x41, 0x5c, 0xf5, 0xa0, 0xd2, 0xc, 0xb5, 0x5f, 0xd5, 0x6d, 0x6f, 0x72, 0xe, 0x27, 0x68, 0xd5, 0xb6, - 0xbb, 0xac, 0x2b, 0x39, 0xb7, 0xd6, 0x4c, 0x11, 0x0, 0x0, 0x7, 0x45, 0x2, 0x0, 0x0, 0x23, 0xc0, 0x27, 0x0, - 0x0, 0x33, 0xb3, 0x18, 0x0, 0x0, 0x6d, 0x31, 0x18, 0x0, 0x0, 0x59, 0x1f, 0x11, 0x0, 0x0, 0xc, 0x4d, 0x13, - 0x56, 0xcd, 0x0, 0x2, 0x9d, 0xae, 0x0, 0x2, 0x93, 0xda, 0x0, 0x1a, 0x24, 0x4a, 0x9, 0x0, 0x82, 0xfa, 0xee, - 0xbc, 0x52, 0xfa, 0x99, 0xb1, 0x17, 0xd8, 0x77, 0x6f, 0x1e, 0x39, 0x25, 0x58, 0xfb, 0x65, 0x23, 0xe, 0xc9, 0x93, - 0x0, 0xf, 0x5c, 0xda, 0xf0, 0xb9, 0x9b, 0xa2, 0xc0, 0xfc, 0x74, 0x83, 0xb8, 0x48, 0x56, 0xc0, 0xeb}; - - uint8_t buf[407] = {0}; - uint8_t bytesprops0[] = {0xba, 0x95, 0x84, 0xf, 0xeb, 0x8f, 0xb6, 0x38, 0x60, 0x5, 0x92, 0x96}; - uint8_t bytesprops1[] = {0xd0, 0xb6, 0x65, 0xb4, 0x3d, 0x61, 0xcd, 0x63, 0xc, 0xb6, - 0x5a, 0x29, 0x13, 0x20, 0x41, 0x77, 0xd0, 0x77, 0xd1}; - uint8_t bytesprops2[] = {0xad, 0xa9, 0xe7, 0xca, 0x7a, 0xf9, 0x1d, 0xdd, 0x8b, - 0x46, 0xb5, 0xf2, 0xb9, 0x92, 0x6f, 0x3e, 0xe1, 0x8b}; - uint8_t bytesprops3[] = {0xe, 0x9, 0x1, 0xe5, 0x7a, 0xdc, 0x70, 0x39, 0xb8, 0xc, - 0xf2, 0x1e, 0x77, 0xb9, 0x28, 0x75, 0xc, 0xaf, 0x92, 0xf0}; - uint8_t bytesprops4[] = {0xba, 0xea, 0x63, 0xe1, 0x39, 0x68, 0xc2, 0xaf, 0xbc, 0x2e, 0x38, 0x41, 0x74, 0x60, - 0x75, 0xbd, 0xf0, 0xf0, 0x90, 0x8b, 0xed, 0x95, 0x54, 0x9a, 0x28, 0xc4, 0xf3}; - uint8_t bytesprops5[] = {0x7c, 0x60, 0x96, 0xf6, 0x5c, 0x11, 0xa3, 0x46, 0x20, 0x5d, 0xbb, 0x53, - 0xc6, 0x8b, 0x3a, 0xb0, 0xe6, 0xfb, 0x36, 0xc7, 0x83, 0x72, 0xc6, 0xc0}; - uint8_t bytesprops6[] = {0xf9, 0xe3}; - uint8_t bytesprops7[] = {0x97, 0x42, 0x7a, 0x2a, 0x83, 0x6a, 0xe7, 0xe9, 0xea, 0xc0, - 0xe6, 0x67, 0xbf, 0xf5, 0xcf, 0xed, 0xd9, 0x49, 0x5b, 0xd9}; - uint8_t bytesprops8[] = {0xda, 0xbb, 0xf2, 0xe6, 0xe1, 0xa4, 0x62}; - uint8_t bytesprops9[] = {0x24, 0xeb, 0x20, 0xff, 0x14, 0x97, 0xb3, 0x1c, 0x5f, 0xb5, 0x49, 0x52, 0x98, 0xb7, 0xda, - 0xcc, 0x30, 0x37, 0x86, 0x15, 0xed, 0x73, 0x83, 0xfc, 0x36, 0x37, 0x19, 0xa9, 0x54, 0x43}; + 0x10, 0xfe, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6, 0x7d, 0x8c, 0x8c, 0x1, 0x27, 0x0, 0x0, 0x12, + 0x11, 0x9, 0x0, 0x1e, 0xbd, 0x1c, 0x66, 0xd3, 0x35, 0xe1, 0x1, 0x72, 0xe7, 0xcd, 0x18, 0x22, 0x6a, 0xab, 0x11, + 0x25, 0xe1, 0x70, 0x7b, 0x2c, 0x10, 0x42, 0xe3, 0x2, 0x6b, 0x40, 0x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, 0x29, 0xba, 0x82, 0x36, 0xf1, 0x30, 0x65, 0xee, 0xaa, 0x1, 0x88, 0x9, 0x0, 0x3, 0xde, 0x4f, + 0x25, 0x19, 0x2e, 0x16, 0x0, 0xa, 0x4f, 0x17, 0xd0, 0x28, 0x29, 0x13, 0xfa, 0x41, 0x49, 0x1f, 0x13, 0xd, 0x83, + 0x15, 0x0, 0x2, 0x2e, 0x76, 0x0, 0x16, 0x35, 0x6b, 0x4b, 0x0, 0x1e, 0x2d, 0xa3, 0x91, 0xc1, 0xb2, 0xaa, 0x49, + 0xc6, 0xaf, 0x7f, 0x24, 0xb0, 0x5c, 0x10, 0x6f, 0x14, 0x36, 0x0, 0x1a, 0x26, 0x9b, 0xe4, 0x13, 0xeb, 0xb4, 0x14, + 0x23, 0xdc, 0xc6, 0x52, 0xce, 0xb2, 0x5b, 0x15, 0x95, 0x5f, 0xf5, 0xce, 0xac, 0x0, 0xcc, 0x1f, 0xd3, 0x55, 0x41}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbd, 0x1c, 0x66, 0xd3, 0x35, 0xe1, 0x1, 0x72, 0xe7, 0xcd, 0x18, 0x22, 0x6a, 0xab, 0x11, + 0x25, 0xe1, 0x70, 0x7b, 0x2c, 0x10, 0x42, 0xe3, 0x2, 0x6b, 0x40, 0x8c, 0x2c, 0x3c, 0xd7}; + uint8_t bytesprops2[] = {0xd5, 0x5e, 0xde, 0x84, 0xa3, 0x84, 0xc3, 0x71, 0x55, 0x77, + 0x37, 0xf1, 0x65, 0x3d, 0xd1, 0x7f, 0xdd, 0x4a, 0x87}; + uint8_t bytesprops1[] = {0x6f, 0x9, 0x66, 0x91, 0x40, 0x26, 0x48, 0x8, 0xb8, 0xe8, + 0xe8, 0x86, 0x1d, 0x7d, 0xde, 0x73, 0xd8, 0xcd, 0x75, 0xbe}; + uint8_t bytesprops3[] = {0xef, 0x9b, 0x64, 0xd9, 0xa5, 0xa8, 0xc2, 0x7b, 0x5, 0x1a, 0xc4, 0x31}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32305}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6339}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 968}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1337}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4625}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27111}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27408}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30555}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30910}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27447}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops1}, .v = {19, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13982}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27839}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x41, 0x5c, 0xf5, 0xa0, 0xd2, 0xc, 0xb5, 0x5f, 0xd5, 0x6d, 0x6f, 0x72, - 0xe, 0x27, 0x68, 0xd5, 0xb6, 0xbb, 0xac, 0x2b, 0x39, 0xb7, 0xd6, 0x4c}; + uint8_t byteswillprops0[] = {0x13, 0x3a, 0x91, 0x53, 0xa, 0xeb, 0xa4, 0xbb, 0x3f}; + uint8_t byteswillprops2[] = {0xbd, 0x7f, 0x49, 0x13, 0x92, 0x5, 0xf1, 0x31, + 0x11, 0xc2, 0x3b, 0x3c, 0xa9, 0x26, 0xc7, 0xbf}; + uint8_t byteswillprops1[] = {0x40, 0xbe, 0xad, 0x24, 0xff, 0xe8, 0xf8, 0xc7, 0xd0, 0x84, 0xe7, 0x82, 0x56}; + uint8_t byteswillprops4[] = {0xb1, 0x38, 0xde, 0xb9, 0x7a, 0x5c, 0xae, 0xfe, 0x86, + 0x1b, 0xe5, 0x20, 0x80, 0x19, 0xe2, 0x4c, 0x25, 0x92}; + uint8_t byteswillprops3[] = {0xed, 0x4e, 0xc6, 0x2f, 0xb0, 0x8b, 0x4e, 0xde, 0x47, 0x46, 0xf0, + 0x90, 0x26, 0xf7, 0x25, 0x4, 0xfe, 0x71, 0x9d, 0x7b, 0xc8, 0x5c}; + uint8_t byteswillprops5[] = {0x85, 0x64, 0x4f, 0x5a, 0xd9, 0x8c, 0x50, 0x2a, 0x3d}; + uint8_t byteswillprops6[] = {0xab, 0xd0, 0xf5}; + uint8_t byteswillprops7[] = {0xc9, 0xf3, 0xcf, 0x6b, 0x6b, 0xd0, 0xfb, 0xcc, 0x36, 0xdd, 0x21, 0xa, + 0x62, 0xe3, 0x6a, 0x31, 0xb5, 0xc3, 0xfe, 0x92, 0x18, 0xff, 0xd3}; + uint8_t byteswillprops8[] = {0xfc, 0xf9, 0x1f, 0x19, 0x83, 0xff, 0xbb, 0x9f, 0x8d, 0x89, 0xe8, 0x62, 0x79}; + uint8_t byteswillprops9[] = {0xd2, 0x4d, 0x4e, 0x29, 0x6e, 0x3a, 0xf6, 0x4a, 0xc9, 0xec, + 0x25, 0xcc, 0xa6, 0xf4, 0x6, 0xb5, 0x67, 0x5f, 0xd7, 0xd9, + 0x26, 0xec, 0xea, 0xd5, 0x8, 0xdf, 0x4c, 0xe4, 0xe8, 0xb5}; + uint8_t byteswillprops10[] = {0xf9, 0x45, 0xb6, 0xa4, 0x16, 0x27, 0xee, 0x33, 0x85, 0xbe, 0xfe, 0x22, 0x74, + 0xf1, 0x2b, 0xe1, 0x9, 0x2d, 0x55, 0xbb, 0xbb, 0x23, 0x7a, 0xd0, 0xdb}; + uint8_t byteswillprops11[] = {0x6e, 0x29, 0xba, 0x82, 0x36, 0xf1, 0x30, 0x65, 0xee, 0xaa, 0x1, 0x88}; + uint8_t byteswillprops12[] = {0xde, 0x4f, 0x25}; + uint8_t byteswillprops13[] = {0x4f, 0x17, 0xd0, 0x28, 0x29, 0x13, 0xfa, 0x41, 0x49, 0x1f}; + uint8_t byteswillprops14[] = {0x2e, 0x76}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27717}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1861}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9152}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13235}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27953}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22815}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3149}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22221}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {13, (char*)&byteswillprops1}, .v = {16, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2676}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {22, (char*)&byteswillprops3}, .v = {18, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2260}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16575}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14364}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8517}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&byteswillprops12}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&byteswillprops13}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3459}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&byteswillprops14}}}, }; - lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9d, 0xae}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x93, 0xda}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x35, 0x6b, 0x4b, 0x0, 0x1e, 0x2d, 0xa3, 0x91, 0xc1, 0xb2, 0xaa, + 0x49, 0xc6, 0xaf, 0x7f, 0x24, 0xb0, 0x5c, 0x10, 0x6f, 0x14, 0x36}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x26, 0x9b, 0xe4, 0x13, 0xeb, 0xb4, 0x14, 0x23, 0xdc, 0xc6, 0x52, 0xce, 0xb2, + 0x5b, 0x15, 0x95, 0x5f, 0xf5, 0xce, 0xac, 0x0, 0xcc, 0x1f, 0xd3, 0x55, 0x41}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 6678; - uint8_t client_id_bytes[] = {0xb3, 0xd, 0x4f, 0x60, 0x59}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 32140; + uint8_t client_id_bytes[] = {0x76, 0x43, 0xf8, 0x9b, 0xb1, 0xd5, 0x67, 0x5d, 0xc6}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x24, 0x4a, 0x9, 0x0, 0x82, 0xfa, 0xee, 0xbc, 0x52, 0xfa, 0x99, 0xb1, 0x17, - 0xd8, 0x77, 0x6f, 0x1e, 0x39, 0x25, 0x58, 0xfb, 0x65, 0x23, 0xe, 0xc9, 0x93}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x5c, 0xda, 0xf0, 0xb9, 0x9b, 0xa2, 0xc0, 0xfc, 0x74, 0x83, 0xb8, 0x48, 0x56, 0xc0, 0xeb}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\ETX\162\182\251\&5\254\129A\181!!/ -// \229\172\171\204\210R\201\DC1\250\190\&4_\"X\154", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = "\130\DEL/\236|]", _willMsg = "\161\186\166\161\248x\189;\ETX\167", _willProps = -// [PropRequestResponseInformation 130,PropServerReference -// "4\222\196\&3\DC3d]\170|P\DC4\202\227\155\132\186l\157\199\235\140y\SUB\240\&5\174i\200/",PropContentType -// "\153\136&9\RS\230dLF%MsS\174{\148",PropMessageExpiryInterval 1267,PropWillDelayInterval 6184,PropMaximumPacketSize -// 271,PropReceiveMaximum 8643,PropSessionExpiryInterval 24954,PropResponseTopic -// "+\170.#lf\189\RS);6\240\&7\158]\DC4g\DLE\219>\242\DC3\235",PropWildcardSubscriptionAvailable -// 62,PropSharedSubscriptionAvailable 46,PropUserProperty "s\196\SOH" -// "\128\168\193o\150\214\142\139p\130\181\147c\254w",PropRequestProblemInformation 181,PropMessageExpiryInterval -// 28708,PropResponseInformation "^@{g\166by\ENQ\250\196Y\141\164\161ft\161\190$M"]}), _cleanSession = False, _keepAlive -// = 31398, _connID = "\165=K\CAN\208~\SYN\241*\f6#\208H\198\177p.", _properties = [PropReceiveMaximum -// 30115,PropUserProperty "\ETX\163\192\tV\NUL:9\174\227\135\255\152p\234M\DC1\238%x9+\200\162?" -// "\145\175",PropContentType "h\187\229G\240gt\253\&1",PropAssignedClientIdentifier -// "b\200\188Y\152\218\153\228f\217",PropResponseTopic "\r^]\176\204\197\t\200m.@8s"]} +// ConnectRequest {_username = Nothing, _password = Just "\181\188RC|\DELPc[\242A\194\140G\NAK\CANu\DC4\178\213\DC4", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "\249=\212\228i\201\&4\178&\RS)\DC4|\174\242w \201", _willMsg = +// "@\162c\242\CAN\208f\191d\161\222\184@fP\222\&7\204\176\212\227_\166\242\155W<\DC43", _willProps = +// [PropAuthenticationData "",PropWillDelayInterval 21611,PropRequestResponseInformation 4,PropCorrelationData +// "\196w\189\139\135\209O\159~",PropSessionExpiryInterval 23150,PropMaximumQoS 17,PropPayloadFormatIndicator +// 173,PropRequestProblemInformation 74,PropSubscriptionIdentifierAvailable 11,PropUserProperty +// "\168R\218\128\144\140$G\245\176o\201B\155\&0\DC1\146" +// "\253\169\189S\248Pa\134\ETB\SYN=\ACK\173\177y(\208",PropReceiveMaximum 4756,PropReceiveMaximum +// 28950,PropMessageExpiryInterval 25517,PropMaximumQoS 253,PropResponseTopic +// "\217\212i\186\f\218K\ENQ|1\229\229=\188Q\145~\184\&1\241!\244\209\236\DC1;\189=\RSg"]}), _cleanSession = True, +// _keepAlive = 8577, _connID = "\246\235\226\ACK\SI+\255\134\137\158\247\158\138X\147\188\139\218-\154", _properties = +// [PropResponseTopic "1\245Am\193[\231\FS|\170\143\206\217M\128\181\EM\196\157\ESC\228\215\&7p",PropReasonString +// "x\240\133\&3\250\227b\239:\144\230\187\221"]} TEST(Connect5QCTest, Encode4) { - uint8_t pkt[] = { - 0x10, 0xbe, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x94, 0x7a, 0xa6, 0x4c, 0x21, 0x75, 0xa3, 0x26, 0x0, - 0x19, 0x3, 0xa3, 0xc0, 0x9, 0x56, 0x0, 0x3a, 0x39, 0xae, 0xe3, 0x87, 0xff, 0x98, 0x70, 0xea, 0x4d, 0x11, 0xee, - 0x25, 0x78, 0x39, 0x2b, 0xc8, 0xa2, 0x3f, 0x0, 0x2, 0x91, 0xaf, 0x3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 0x93, 0x63, 0xfe, 0x77, 0x17, 0xb5, 0x2, 0x0, 0x0, 0x70, - 0x24, 0x1a, 0x0, 0x14, 0x5e, 0x40, 0x7b, 0x67, 0xa6, 0x62, 0x79, 0x5, 0xfa, 0xc4, 0x59, 0x8d, 0xa4, 0xa1, 0x66, - 0x74, 0xa1, 0xbe, 0x24, 0x4d, 0x0, 0x6, 0x82, 0x7f, 0x2f, 0xec, 0x7c, 0x5d, 0x0, 0xa, 0xa1, 0xba, 0xa6, 0xa1, - 0xf8, 0x78, 0xbd, 0x3b, 0x3, 0xa7, 0x0, 0x1c, 0x3, 0xa2, 0xb6, 0xfb, 0x35, 0xfe, 0x81, 0x41, 0xb5, 0x21, 0x21, - 0x2f, 0x20, 0xe5, 0xac, 0xab, 0xcc, 0xd2, 0x52, 0xc9, 0x11, 0xfa, 0xbe, 0x34, 0x5f, 0x22, 0x58, 0x9a}; - - uint8_t buf[331] = {0}; - uint8_t bytesprops1[] = {0x91, 0xaf}; - uint8_t bytesprops0[] = {0x3, 0xa3, 0xc0, 0x9, 0x56, 0x0, 0x3a, 0x39, 0xae, 0xe3, 0x87, 0xff, 0x98, - 0x70, 0xea, 0x4d, 0x11, 0xee, 0x25, 0x78, 0x39, 0x2b, 0xc8, 0xa2, 0x3f}; - uint8_t bytesprops2[] = {0x68, 0xbb, 0xe5, 0x47, 0xf0, 0x67, 0x74, 0xfd, 0x31}; - uint8_t bytesprops3[] = {0x62, 0xc8, 0xbc, 0x59, 0x98, 0xda, 0x99, 0xe4, 0x66, 0xd9}; - uint8_t bytesprops4[] = {0xd, 0x5e, 0x5d, 0xb0, 0xcc, 0xc5, 0x9, 0xc8, 0x6d, 0x2e, 0x40, 0x38, 0x73}; + uint8_t pkt[] = {0x10, 0xf8, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6, 0x21, 0x81, 0x2b, 0x8, 0x0, 0x18, + 0x31, 0xf5, 0x41, 0x6d, 0xc1, 0x5b, 0xe7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 0x26, 0x1e, 0x29, 0x14, 0x7c, 0xae, 0xf2, 0x77, 0x20, 0xc9, 0x0, + 0x1d, 0x40, 0xa2, 0x63, 0xf2, 0x18, 0xd0, 0x66, 0xbf, 0x64, 0xa1, 0xde, 0xb8, 0x40, 0x66, 0x50, 0xde, + 0x37, 0xcc, 0xb0, 0xd4, 0xe3, 0x5f, 0xa6, 0xf2, 0x9b, 0x57, 0x3c, 0x14, 0x33}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x31, 0xf5, 0x41, 0x6d, 0xc1, 0x5b, 0xe7, 0x1c, 0x7c, 0xaa, 0x8f, 0xce, + 0xd9, 0x4d, 0x80, 0xb5, 0x19, 0xc4, 0x9d, 0x1b, 0xe4, 0xd7, 0x37, 0x70}; + uint8_t bytesprops1[] = {0x78, 0xf0, 0x85, 0x33, 0xfa, 0xe3, 0x62, 0xef, 0x3a, 0x90, 0xe6, 0xbb, 0xdd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30115}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops0}, .v = {2, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x34, 0xde, 0xc4, 0x33, 0x13, 0x64, 0x5d, 0xaa, 0x7c, 0x50, 0x14, 0xca, 0xe3, 0x9b, 0x84, - 0xba, 0x6c, 0x9d, 0xc7, 0xeb, 0x8c, 0x79, 0x1a, 0xf0, 0x35, 0xae, 0x69, 0xc8, 0x2f}; - uint8_t byteswillprops1[] = {0x99, 0x88, 0x26, 0x39, 0x1e, 0xe6, 0x64, 0x4c, - 0x46, 0x25, 0x4d, 0x73, 0x53, 0xae, 0x7b, 0x94}; - uint8_t byteswillprops2[] = {0x2b, 0xaa, 0x2e, 0x23, 0x6c, 0x66, 0xbd, 0x1e, 0x29, 0x3b, 0x36, 0xf0, - 0x37, 0x9e, 0x5d, 0x14, 0x67, 0x10, 0xdb, 0x3e, 0xf2, 0x13, 0xeb}; - uint8_t byteswillprops4[] = {0x80, 0xa8, 0xc1, 0x6f, 0x96, 0xd6, 0x8e, 0x8b, - 0x70, 0x82, 0xb5, 0x93, 0x63, 0xfe, 0x77}; - uint8_t byteswillprops3[] = {0x73, 0xc4, 0x1}; - uint8_t byteswillprops5[] = {0x5e, 0x40, 0x7b, 0x67, 0xa6, 0x62, 0x79, 0x5, 0xfa, 0xc4, - 0x59, 0x8d, 0xa4, 0xa1, 0x66, 0x74, 0xa1, 0xbe, 0x24, 0x4d}; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops1[] = {0xc4, 0x77, 0xbd, 0x8b, 0x87, 0xd1, 0x4f, 0x9f, 0x7e}; + uint8_t byteswillprops3[] = {0xfd, 0xa9, 0xbd, 0x53, 0xf8, 0x50, 0x61, 0x86, 0x17, + 0x16, 0x3d, 0x6, 0xad, 0xb1, 0x79, 0x28, 0xd0}; + uint8_t byteswillprops2[] = {0xa8, 0x52, 0xda, 0x80, 0x90, 0x8c, 0x24, 0x47, 0xf5, + 0xb0, 0x6f, 0xc9, 0x42, 0x9b, 0x30, 0x11, 0x92}; + uint8_t byteswillprops4[] = {0xd9, 0xd4, 0x69, 0xba, 0xc, 0xda, 0x4b, 0x5, 0x7c, 0x31, + 0xe5, 0xe5, 0x3d, 0xbc, 0x51, 0x91, 0x7e, 0xb8, 0x31, 0xf1, + 0x21, 0xf4, 0xd1, 0xec, 0x11, 0x3b, 0xbd, 0x3d, 0x1e, 0x67}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1267}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6184}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 271}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8643}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24954}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21611}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23150}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 11}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {3, (char*)&byteswillprops3}, .v = {15, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28708}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&byteswillprops5}}}, + .value = {.pair = {.k = {17, (char*)&byteswillprops2}, .v = {17, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4756}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28950}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25517}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops4}}}, }; lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x82, 0x7f, 0x2f, 0xec, 0x7c, 0x5d}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa1, 0xba, 0xa6, 0xa1, 0xf8, 0x78, 0xbd, 0x3b, 0x3, 0xa7}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xf9, 0x3d, 0xd4, 0xe4, 0x69, 0xc9, 0x34, 0xb2, 0x26, + 0x1e, 0x29, 0x14, 0x7c, 0xae, 0xf2, 0x77, 0x20, 0xc9}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x40, 0xa2, 0x63, 0xf2, 0x18, 0xd0, 0x66, 0xbf, 0x64, 0xa1, + 0xde, 0xb8, 0x40, 0x66, 0x50, 0xde, 0x37, 0xcc, 0xb0, 0xd4, + 0xe3, 0x5f, 0xa6, 0xf2, 0x9b, 0x57, 0x3c, 0x14, 0x33}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 31398; - uint8_t client_id_bytes[] = {0xa5, 0x3d, 0x4b, 0x18, 0xd0, 0x7e, 0x16, 0xf1, 0x2a, - 0xc, 0x36, 0x23, 0xd0, 0x48, 0xc6, 0xb1, 0x70, 0x2e}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 8577; + uint8_t client_id_bytes[] = {0xf6, 0xeb, 0xe2, 0x6, 0xf, 0x2b, 0xff, 0x86, 0x89, 0x9e, + 0xf7, 0x9e, 0x8a, 0x58, 0x93, 0xbc, 0x8b, 0xda, 0x2d, 0x9a}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x3, 0xa2, 0xb6, 0xfb, 0x35, 0xfe, 0x81, 0x41, 0xb5, 0x21, 0x21, 0x2f, 0x20, 0xe5, - 0xac, 0xab, 0xcc, 0xd2, 0x52, 0xc9, 0x11, 0xfa, 0xbe, 0x34, 0x5f, 0x22, 0x58, 0x9a}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; - opts.username = username; + uint8_t password_bytes[] = {0xb5, 0xbc, 0x52, 0x43, 0x7c, 0x7f, 0x50, 0x63, 0x5b, 0xf2, 0x41, + 0xc2, 0x8c, 0x47, 0x15, 0x18, 0x75, 0x14, 0xb2, 0xd5, 0x14}; + lwmqtt_string_t password = {21, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "GM0)\182\157\&9s", _password = Just -// "nBK\142m\DEL\248~\175W\169oW\173\176\EM7\245\222c%\177", _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS0, _willTopic = "<\166\216{\222\a\STX\238\153\rd\166Zm\206JH\vO\242\143\&7\163\173\233\EOT&Q", _willMsg = -// "\243x\161_\SUB\249f\DC3", _willProps = [PropTopicAlias 10344,PropResponseTopic "\155\GSe\SOH",PropServerKeepAlive -// 30085,PropSubscriptionIdentifierAvailable 184,PropContentType "nd\196\144",PropMaximumQoS 106,PropResponseInformation -// "\160\227\209\224CJR\217\216o\223\254\245m\156\216\207c",PropTopicAliasMaximum 22542,PropRetainAvailable -// 48,PropRequestResponseInformation 118,PropMessageExpiryInterval 7982,PropWillDelayInterval 11886]}), _cleanSession = -// True, _keepAlive = 11821, _connID = "\EOT", _properties = [PropReasonString -// "NIX$\246\251\&3\135\187#\132\212G\174\SUB\RS\246\201\157\DC2\155v\138\176=r\192\149\246",PropTopicAlias -// 8083,PropUserProperty "\129\205[0\239\164\254'x\139\197\216\161,\NUL\241<" -// "\140\SI\SO\197\&8\232\243h@\142\163,i\209\244\226B\STXk\255 ",PropAuthenticationMethod -// "\202\&6\ETB\DC4Q\137\197\195\v?\162\224\&5\152\130\217\195"]} +// ConnectRequest {_username = Just "\ETB\185M\SUB\222\149", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\128\ETB\EOT\205\173", _willMsg = +// "\198\DC3l\140\230R!E$\SOH\229o,x\187~\139\202\"\DC4V\ACK)", _willProps = [PropMessageExpiryInterval +// 30378,PropReasonString "\213P\189Yv\FS\DC3#\224\SI_\155\&5D# \187\201\204\178{\GS$:\251\213",PropRetainAvailable +// 181,PropReasonString "\246\182\199?5rh\a\129F`\163\NAKv\FS\130\249",PropCorrelationData +// ",\ENQ\146\197\197\SI\220y.\150",PropResponseTopic +// "\202\156\&7\199\244\162Cw3\"S\221\245\fi\181\DC2m\139\252\244i\175#",PropAuthenticationMethod +// "\205\228\ESC\n",PropSharedSubscriptionAvailable 45,PropContentType +// "\fILq\240~<+\226\137+O,\218QC\243\141r\154j\139\231=",PropServerReference "\141",PropMessageExpiryInterval +// 2987,PropSessionExpiryInterval 20482,PropTopicAlias 9401,PropRetainAvailable 46]}), _cleanSession = False, _keepAlive +// = 3023, _connID = "]l\128mk1J\129p\141\170Rw\178\NUL\171w\196\n", _properties = [PropPayloadFormatIndicator +// 86,PropMessageExpiryInterval 15264,PropSubscriptionIdentifier 11,PropResponseTopic +// "\ENQ+Vw\177T\218a7I\201\130|\\'Q\231=F\STX\DC3\SUB+E!\231",PropReceiveMaximum 4661,PropResponseInformation +// "\DC4f\213t\230",PropResponseInformation +// "\ENQ\247\209b\172\179\ETB\148\224\136\164o\171U\208\177\ETBJ\t\143\205&\251\152\rO\"\131",PropAuthenticationData +// "\SOHa\ESC\233\&8p\177\162\255\179\132\135",PropServerReference +// "\245\231\b\215}(\213\175\&2~s\128\174\DC4\201\235\250\EOT\214\142",PropUserProperty +// "\212k]b\SO;4\174\179\242\ENQ\135u,`8\204{:L\183a\SYNj\187s" "\235S\183P\187",PropSubscriptionIdentifierAvailable +// 48,PropAuthenticationMethod +// "\GS$\174\239\\S\248+;\145\231\225\231\155\RS\168L\227\247\197\145&",PropAssignedClientIdentifier +// "\171\162\ESC2\168gK\151>\177\147\130\SYN_\174",PropSubscriptionIdentifierAvailable 119,PropMaximumQoS +// 125,PropWildcardSubscriptionAvailable 12,PropRetainAvailable 247,PropSubscriptionIdentifierAvailable +// 152,PropSharedSubscriptionAvailable 76,PropResponseInformation +// "Q\a\236t\STX\128\215\159\\\226%82\DC4<",PropRequestProblemInformation 6,PropAuthenticationData +// "\213",PropWillDelayInterval 11360,PropTopicAliasMaximum 17881,PropServerReference +// "\235s't\243\130]2\206\NAKv\131\CANs\SOH\218\STX",PropWillDelayInterval 16307]} TEST(Connect5QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0xf9, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x2e, 0x2d, 0x62, 0x1f, 0x0, 0x1d, - 0x4e, 0x49, 0x58, 0x24, 0xf6, 0xfb, 0x33, 0x87, 0xbb, 0x23, 0x84, 0xd4, 0x47, 0xae, 0x1a, 0x1e, 0xf6, - 0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x47, - 0x4d, 0x30, 0x29, 0xb6, 0x9d, 0x39, 0x73, 0x0, 0x16, 0x6e, 0x42, 0x4b, 0x8e, 0x6d, 0x7f, 0xf8, 0x7e, - 0xaf, 0x57, 0xa9, 0x6f, 0x57, 0xad, 0xb0, 0x19, 0x37, 0xf5, 0xde, 0x63, 0x25, 0xb1}; - - uint8_t buf[262] = {0}; - uint8_t bytesprops0[] = {0x4e, 0x49, 0x58, 0x24, 0xf6, 0xfb, 0x33, 0x87, 0xbb, 0x23, 0x84, 0xd4, 0x47, 0xae, 0x1a, - 0x1e, 0xf6, 0xc9, 0x9d, 0x12, 0x9b, 0x76, 0x8a, 0xb0, 0x3d, 0x72, 0xc0, 0x95, 0xf6}; - uint8_t bytesprops2[] = {0x8c, 0xf, 0xe, 0xc5, 0x38, 0xe8, 0xf3, 0x68, 0x40, 0x8e, 0xa3, - 0x2c, 0x69, 0xd1, 0xf4, 0xe2, 0x42, 0x2, 0x6b, 0xff, 0x20}; - uint8_t bytesprops1[] = {0x81, 0xcd, 0x5b, 0x30, 0xef, 0xa4, 0xfe, 0x27, 0x78, - 0x8b, 0xc5, 0xd8, 0xa1, 0x2c, 0x0, 0xf1, 0x3c}; - uint8_t bytesprops3[] = {0xca, 0x36, 0x17, 0x14, 0x51, 0x89, 0xc5, 0xc3, 0xb, - 0x3f, 0xa2, 0xe0, 0x35, 0x98, 0x82, 0xd9, 0xc3}; + uint8_t pkt[] = { + 0x10, 0xee, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb4, 0xb, 0xcf, 0x8c, 0x2, 0x1, 0x56, 0x2, 0x0, + 0x0, 0x3b, 0xa0, 0xb, 0xb, 0x8, 0x0, 0x1a, 0x5, 0x2b, 0x56, 0x77, 0xb1, 0x54, 0xda, 0x61, 0x37, 0x49, 0xc9, + 0x82, 0x7c, 0x5c, 0x27, 0x51, 0xe7, 0x3d, 0x46, 0x2, 0x13, 0x1a, 0x2b, 0x45, 0x21, 0xe7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0x2c, 0xda, 0x51, 0x43, 0xf3, 0x8d, 0x72, 0x9a, 0x6a, 0x8b, 0xe7, + 0x3d, 0x1c, 0x0, 0x1, 0x8d, 0x2, 0x0, 0x0, 0xb, 0xab, 0x11, 0x0, 0x0, 0x50, 0x2, 0x23, 0x24, 0xb9, 0x25, + 0x2e, 0x0, 0x5, 0x80, 0x17, 0x4, 0xcd, 0xad, 0x0, 0x17, 0xc6, 0x13, 0x6c, 0x8c, 0xe6, 0x52, 0x21, 0x45, 0x24, + 0x1, 0xe5, 0x6f, 0x2c, 0x78, 0xbb, 0x7e, 0x8b, 0xca, 0x22, 0x14, 0x56, 0x6, 0x29, 0x0, 0x6, 0x17, 0xb9, 0x4d, + 0x1a, 0xde, 0x95}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x5, 0x2b, 0x56, 0x77, 0xb1, 0x54, 0xda, 0x61, 0x37, 0x49, 0xc9, 0x82, 0x7c, + 0x5c, 0x27, 0x51, 0xe7, 0x3d, 0x46, 0x2, 0x13, 0x1a, 0x2b, 0x45, 0x21, 0xe7}; + uint8_t bytesprops1[] = {0x14, 0x66, 0xd5, 0x74, 0xe6}; + uint8_t bytesprops2[] = {0x5, 0xf7, 0xd1, 0x62, 0xac, 0xb3, 0x17, 0x94, 0xe0, 0x88, 0xa4, 0x6f, 0xab, 0x55, + 0xd0, 0xb1, 0x17, 0x4a, 0x9, 0x8f, 0xcd, 0x26, 0xfb, 0x98, 0xd, 0x4f, 0x22, 0x83}; + uint8_t bytesprops3[] = {0x1, 0x61, 0x1b, 0xe9, 0x38, 0x70, 0xb1, 0xa2, 0xff, 0xb3, 0x84, 0x87}; + uint8_t bytesprops4[] = {0xf5, 0xe7, 0x8, 0xd7, 0x7d, 0x28, 0xd5, 0xaf, 0x32, 0x7e, + 0x73, 0x80, 0xae, 0x14, 0xc9, 0xeb, 0xfa, 0x4, 0xd6, 0x8e}; + uint8_t bytesprops6[] = {0xeb, 0x53, 0xb7, 0x50, 0xbb}; + uint8_t bytesprops5[] = {0xd4, 0x6b, 0x5d, 0x62, 0xe, 0x3b, 0x34, 0xae, 0xb3, 0xf2, 0x5, 0x87, 0x75, + 0x2c, 0x60, 0x38, 0xcc, 0x7b, 0x3a, 0x4c, 0xb7, 0x61, 0x16, 0x6a, 0xbb, 0x73}; + uint8_t bytesprops7[] = {0x1d, 0x24, 0xae, 0xef, 0x5c, 0x53, 0xf8, 0x2b, 0x3b, 0x91, 0xe7, + 0xe1, 0xe7, 0x9b, 0x1e, 0xa8, 0x4c, 0xe3, 0xf7, 0xc5, 0x91, 0x26}; + uint8_t bytesprops8[] = {0xab, 0xa2, 0x1b, 0x32, 0xa8, 0x67, 0x4b, 0x97, 0x3e, 0xb1, 0x93, 0x82, 0x16, 0x5f, 0xae}; + uint8_t bytesprops9[] = {0x51, 0x7, 0xec, 0x74, 0x2, 0x80, 0xd7, 0x9f, 0x5c, 0xe2, 0x25, 0x38, 0x32, 0x14, 0x3c}; + uint8_t bytesprops10[] = {0xd5}; + uint8_t bytesprops11[] = {0xeb, 0x73, 0x27, 0x74, 0xf3, 0x82, 0x5d, 0x32, 0xce, + 0x15, 0x76, 0x83, 0x18, 0x73, 0x1, 0xda, 0x2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8083}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {21, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15264}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4661}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops5}, .v = {5, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11360}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17881}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16307}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x9b, 0x1d, 0x65, 0x1}; - uint8_t byteswillprops1[] = {0x6e, 0x64, 0xc4, 0x90}; - uint8_t byteswillprops2[] = {0xa0, 0xe3, 0xd1, 0xe0, 0x43, 0x4a, 0x52, 0xd9, 0xd8, - 0x6f, 0xdf, 0xfe, 0xf5, 0x6d, 0x9c, 0xd8, 0xcf, 0x63}; + uint8_t byteswillprops0[] = {0xd5, 0x50, 0xbd, 0x59, 0x76, 0x1c, 0x13, 0x23, 0xe0, 0xf, 0x5f, 0x9b, 0x35, + 0x44, 0x23, 0x20, 0xbb, 0xc9, 0xcc, 0xb2, 0x7b, 0x1d, 0x24, 0x3a, 0xfb, 0xd5}; + uint8_t byteswillprops1[] = {0xf6, 0xb6, 0xc7, 0x3f, 0x35, 0x72, 0x68, 0x7, 0x81, + 0x46, 0x60, 0xa3, 0x15, 0x76, 0x1c, 0x82, 0xf9}; + uint8_t byteswillprops2[] = {0x2c, 0x5, 0x92, 0xc5, 0xc5, 0xf, 0xdc, 0x79, 0x2e, 0x96}; + uint8_t byteswillprops3[] = {0xca, 0x9c, 0x37, 0xc7, 0xf4, 0xa2, 0x43, 0x77, 0x33, 0x22, 0x53, 0xdd, + 0xf5, 0xc, 0x69, 0xb5, 0x12, 0x6d, 0x8b, 0xfc, 0xf4, 0x69, 0xaf, 0x23}; + uint8_t byteswillprops4[] = {0xcd, 0xe4, 0x1b, 0xa}; + uint8_t byteswillprops5[] = {0xc, 0x49, 0x4c, 0x71, 0xf0, 0x7e, 0x3c, 0x2b, 0xe2, 0x89, 0x2b, 0x4f, + 0x2c, 0xda, 0x51, 0x43, 0xf3, 0x8d, 0x72, 0x9a, 0x6a, 0x8b, 0xe7, 0x3d}; + uint8_t byteswillprops6[] = {0x8d}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10344}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30085}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22542}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7982}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11886}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30378}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2987}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20482}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9401}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 46}}, }; - lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3c, 0xa6, 0xd8, 0x7b, 0xde, 0x7, 0x2, 0xee, 0x99, 0xd, 0x64, 0xa6, 0x5a, 0x6d, - 0xce, 0x4a, 0x48, 0xb, 0x4f, 0xf2, 0x8f, 0x37, 0xa3, 0xad, 0xe9, 0x4, 0x26, 0x51}; - lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf3, 0x78, 0xa1, 0x5f, 0x1a, 0xf9, 0x66, 0x13}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x80, 0x17, 0x4, 0xcd, 0xad}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc6, 0x13, 0x6c, 0x8c, 0xe6, 0x52, 0x21, 0x45, 0x24, 0x1, 0xe5, 0x6f, + 0x2c, 0x78, 0xbb, 0x7e, 0x8b, 0xca, 0x22, 0x14, 0x56, 0x6, 0x29}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS2; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 11821; - uint8_t client_id_bytes[] = {0x4}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 3023; + uint8_t client_id_bytes[] = {0x5d, 0x6c, 0x80, 0x6d, 0x6b, 0x31, 0x4a, 0x81, 0x70, 0x8d, + 0xaa, 0x52, 0x77, 0xb2, 0x0, 0xab, 0x77, 0xc4, 0xa}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x47, 0x4d, 0x30, 0x29, 0xb6, 0x9d, 0x39, 0x73}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x17, 0xb9, 0x4d, 0x1a, 0xde, 0x95}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x6e, 0x42, 0x4b, 0x8e, 0x6d, 0x7f, 0xf8, 0x7e, 0xaf, 0x57, 0xa9, - 0x6f, 0x57, 0xad, 0xb0, 0x19, 0x37, 0xf5, 0xde, 0x63, 0x25, 0xb1}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\213\218\180\190MN\136\210\233\DC2\224\201\191:0\161RI\197\210\192\GSV=", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\r|\168fB\231\&1h",PropMaximumQoS 139,PropResponseTopic +// "<\184\227",PropCorrelationData "",PropMaximumPacketSize 22988,PropTopicAliasMaximum 16579,PropUserProperty +// "\237\214" "\179(\242\170\200\135\167B\159\EOT\129z\158l\233\156\182j\168\196_",PropSubscriptionIdentifier +// 10,PropRequestResponseInformation 133,PropRequestProblemInformation 76,PropTopicAliasMaximum 3903,PropUserProperty " +// \150\204\SYN\231[\131\207\&8o" +// "\194\138\CANn\137po\USO\SI\ETB\164\210\243\137\183/\178\ETB\151\142\a}\230\177\152\129\191\197\239"]}), +// _cleanSession = True, _keepAlive = 18606, _connID = "6", _properties = [PropResponseInformation +// "#\248\162",PropSubscriptionIdentifier 18,PropReceiveMaximum 19652,PropMaximumPacketSize +// 4736,PropMessageExpiryInterval 23889,PropMaximumQoS 178,PropMaximumQoS 151,PropPayloadFormatIndicator +// 229,PropMaximumPacketSize 15274,PropCorrelationData +// "$9@W\211`B\151\175\229\193\195\203\171\235\255\200\128nz{-\158\240",PropResponseInformation +// "+\ACKt\CAN\SUB\247_",PropRetainAvailable 28,PropTopicAliasMaximum 5862]} TEST(Connect5QCTest, Encode7) { uint8_t pkt[] = { - 0x10, 0xb9, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x37, 0x5a, 0xbf, 0x1, 0x25, 0x42, 0x17, 0x99, - 0x24, 0xfb, 0xb, 0x2, 0x1a, 0x0, 0x19, 0x2f, 0x92, 0x37, 0x3, 0x46, 0xe3, 0xe0, 0xc8, 0x10, 0x40, 0x87, 0x70, - 0x3, 0x41, 0x2, 0x44, 0x4b, 0x5, 0xd8, 0x3f, 0x5c, 0x87, 0x21, 0x9c, 0xb3, 0x3, 0x0, 0x18, 0xc3, 0xc, 0xee, - 0xc2, 0xa4, 0x5b, 0x1d, 0x10, 0x27, 0x20, 0x13, 0x64, 0xd2, 0x48, 0x98, 0x1f, 0x8, 0x7f, 0xc0, 0x98, 0xc5, 0x26, - 0xaf, 0x1f, 0x27, 0x0, 0x0, 0x48, 0x1d, 0x1c, 0x0, 0x3, 0x36, 0xf9, 0xa7, 0x11, 0x0, 0x0, 0x57, 0x6d, 0x15, - 0x0, 0x7, 0xdf, 0xcc, 0x27, 0x8c, 0x9f, 0x5b, 0x85, 0x15, 0x0, 0x1d, 0x6b, 0xa0, 0x87, 0xdb, 0x56, 0x2d, 0xa4, - 0xa6, 0x96, 0xa5, 0x50, 0x62, 0x2a, 0x8a, 0x2c, 0x7, 0x10, 0xe, 0x86, 0xbf, 0x26, 0x6, 0xfb, 0x42, 0x56, 0xb3, - 0xbe, 0xad, 0x66, 0x29, 0xb, 0x25, 0xea, 0x1, 0x22, 0x17, 0x1f, 0x2a, 0x90, 0x21, 0x31, 0x16, 0x22, 0x5b, 0x85, - 0x16, 0x0, 0xf, 0xb2, 0x57, 0xc7, 0x39, 0x89, 0x4d, 0x3c, 0x2d, 0x3, 0x3c, 0xfc, 0x29, 0xae, 0xdf, 0x61, 0x21, - 0xa, 0x48, 0x2, 0x0, 0x0, 0x7a, 0x9f, 0x16, 0x0, 0x19, 0xee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3, 0xb, 0x17, 0x24, 0xfc, 0x22, 0x16, 0x39, 0x13, 0x2b, 0x4c, 0x0, - 0x1d, 0xd, 0x7c, 0xa8, 0x66, 0x42, 0xe7, 0x31, 0x68, 0x3c, 0x79, 0x9, 0x1c, 0xc5, 0xf, 0x0, 0x7a, 0x33, 0x32, - 0xa2, 0xef, 0x73, 0x26, 0xc, 0xdb, 0xa9, 0xf, 0x47, 0x89, 0xa8, 0x0, 0x5, 0xc9, 0xbf, 0xaf, 0x83, 0x4d, 0x0, - 0x9, 0xb5, 0xe1, 0xf1, 0x25, 0x4b, 0x58, 0xb9, 0x27, 0x94, 0x0, 0xe, 0x18, 0x28, 0x22, 0x6, 0x49, 0x85, 0xef, - 0x36, 0x34, 0xfd, 0xf1, 0x2f, 0x3e, 0x3d}; - - uint8_t buf[454] = {0}; - uint8_t bytesprops0[] = {0x2f, 0x92, 0x37, 0x3, 0x46, 0xe3, 0xe0, 0xc8, 0x10, 0x40, 0x87, 0x70, 0x3, - 0x41, 0x2, 0x44, 0x4b, 0x5, 0xd8, 0x3f, 0x5c, 0x87, 0x21, 0x9c, 0xb3}; - uint8_t bytesprops1[] = {0xc3, 0xc, 0xee, 0xc2, 0xa4, 0x5b, 0x1d, 0x10, 0x27, 0x20, 0x13, 0x64, - 0xd2, 0x48, 0x98, 0x1f, 0x8, 0x7f, 0xc0, 0x98, 0xc5, 0x26, 0xaf, 0x1f}; - uint8_t bytesprops2[] = {0x36, 0xf9, 0xa7}; - uint8_t bytesprops3[] = {0xdf, 0xcc, 0x27, 0x8c, 0x9f, 0x5b, 0x85}; - uint8_t bytesprops4[] = {0x6b, 0xa0, 0x87, 0xdb, 0x56, 0x2d, 0xa4, 0xa6, 0x96, 0xa5, 0x50, 0x62, 0x2a, 0x8a, 0x2c, - 0x7, 0x10, 0xe, 0x86, 0xbf, 0x26, 0x6, 0xfb, 0x42, 0x56, 0xb3, 0xbe, 0xad, 0x66}; - uint8_t bytesprops5[] = {0xb2, 0x57, 0xc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85, 0x17, 0x4c, 0x22, 0xf, 0x3f, 0x26, 0x0, 0xa, 0x20, 0x96, + 0xcc, 0x16, 0xe7, 0x5b, 0x83, 0xcf, 0x38, 0x6f, 0x0, 0x1e, 0xc2, 0x8a, 0x18, 0x6e, 0x89, 0x70, 0x6f, 0x1f, 0x4f, + 0xf, 0x17, 0xa4, 0xd2, 0xf3, 0x89, 0xb7, 0x2f, 0xb2, 0x17, 0x97, 0x8e, 0x7, 0x7d, 0xe6, 0xb1, 0x98, 0x81, 0xbf, + 0xc5, 0xef, 0x0, 0x2, 0x25, 0x57, 0x0, 0x5, 0x6c, 0x18, 0x93, 0x52, 0x13, 0x0, 0xd, 0xf5, 0x48, 0x33, 0xb9, + 0xf9, 0x80, 0xac, 0xd5, 0x6f, 0xe2, 0x4e, 0x40, 0x11, 0x0, 0x1a, 0xab, 0xc3, 0x53, 0x96, 0xb3, 0xb7, 0xb8, 0xf7, + 0x2a, 0xb1, 0xd3, 0x6a, 0x2e, 0xe3, 0xef, 0xc7, 0x1a, 0xd, 0xbb, 0x83, 0x4c, 0x16, 0x18, 0xef, 0xc, 0x98}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x23, 0xf8, 0xa2}; + uint8_t bytesprops1[] = {0x24, 0x39, 0x40, 0x57, 0xd3, 0x60, 0x42, 0x97, 0xaf, 0xe5, 0xc1, 0xc3, + 0xcb, 0xab, 0xeb, 0xff, 0xc8, 0x80, 0x6e, 0x7a, 0x7b, 0x2d, 0x9e, 0xf0}; + uint8_t bytesprops2[] = {0x2b, 0x6, 0x74, 0x18, 0x1a, 0xf7, 0x5f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18461}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22381}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12566}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23429}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2632}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31391}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19652}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4736}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23889}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15274}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5862}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xf8, 0xdf, 0x29, 0x3b, 0x3b, 0x43, 0x87}; - uint8_t byteswillprops1[] = {0xef, 0x61, 0x3a, 0x2b, 0x8d, 0x7, 0x7d, 0x95, - 0xed, 0x24, 0x6f, 0xf1, 0x6f, 0x69, 0xb2, 0xa4}; - uint8_t byteswillprops3[] = {0x0, 0x2c, 0xce, 0x5d, 0xa7, 0x4f, 0x12, 0xd5, 0x87, 0x14, 0x55, 0x90, 0xa2, 0xa3, - 0xd4, 0xf, 0x30, 0x5f, 0xd6, 0x7b, 0x93, 0xc4, 0x8f, 0xae, 0xba, 0x52, 0x36, 0x34}; - uint8_t byteswillprops2[] = {0x23, 0x89, 0x48, 0x7d, 0xea, 0xf5}; - uint8_t byteswillprops4[] = {0x5a, 0x53, 0xf4, 0x6f, 0x26, 0x61, 0x8c, 0x54, 0x77, 0xc0, 0x31, 0xd2, 0x2a, 0x3a, - 0x9f, 0xc9, 0x3b, 0xef, 0x2c, 0x47, 0xf6, 0xe6, 0xbb, 0x9, 0x5a, 0xf5, 0x43, 0x1e}; - uint8_t byteswillprops5[] = {0x97, 0x54, 0xea, 0x7f, 0xc2, 0xe7, 0x11, 0x85, 0x9a, 0x5e, 0x61, 0x35, 0x6a, 0x32, - 0x3, 0xed, 0x7b, 0xb0, 0x25, 0x26, 0x5f, 0x39, 0x42, 0x46, 0xc1, 0x21, 0x35, 0xff}; + uint8_t byteswillprops0[] = {0x11, 0x2e, 0x6c, 0xf5, 0x17, 0xe3, 0x4d, 0x84, 0xd8, + 0xec, 0x3, 0xed, 0x72, 0x65, 0xf4, 0x5c, 0xdf, 0x61}; + uint8_t byteswillprops1[] = {0x5f, 0x3c, 0xc7, 0x10, 0x9c, 0x6b, 0xe5, 0x2e, 0xa0, 0x4b, 0xe0, 0x67}; + uint8_t byteswillprops2[] = {0x71, 0xa, 0x6f, 0x20, 0xd9, 0xe9, 0x6f, 0xec, + 0xf5, 0x1f, 0xe3, 0x8c, 0x44, 0x7d, 0xbb, 0x55}; + uint8_t byteswillprops4[] = {0x5c, 0xbb, 0xeb, 0x5a, 0x42, 0x4f, 0x19, 0x6c, 0xfa, 0x37, + 0xe8, 0xdc, 0x15, 0xd4, 0x47, 0x82, 0xcf, 0xfb, 0x86}; + uint8_t byteswillprops3[] = {0xd0, 0x27, 0xa7, 0xe3, 0xe8, 0xdf, 0xbe, 0xeb, 0x16, 0xcf, 0xd0, 0x12}; + uint8_t byteswillprops5[] = {0xe0, 0x48, 0xe5, 0x50, 0xb2, 0xc3, 0xfe, 0xd4, 0x1d, 0xf1, 0x32, 0xde, 0x25, + 0x1f, 0x82, 0x5c, 0xa4, 0x51, 0xa1, 0x69, 0x2e, 0x8e, 0x88, 0xc1, 0xda}; + uint8_t byteswillprops6[] = {0x34, 0x67, 0xa8, 0xb4, 0xfe, 0x92, 0xef}; + uint8_t byteswillprops7[] = {0x2a, 0xad}; + uint8_t byteswillprops8[] = {0xbe, 0x36, 0x4a, 0x6b, 0x44, 0x84, 0x57, 0x16, 0x2c, 0xeb, 0x58, + 0x60, 0x10, 0xa3, 0xbe, 0x53, 0x50, 0x6b, 0xf8, 0x8c, 0x77, 0x3e}; + uint8_t byteswillprops9[] = {0x3c, 0xb8, 0xe3}; + uint8_t byteswillprops10[] = {0}; + uint8_t byteswillprops12[] = {0xb3, 0x28, 0xf2, 0xaa, 0xc8, 0x87, 0xa7, 0x42, 0x9f, 0x4, 0x81, + 0x7a, 0x9e, 0x6c, 0xe9, 0x9c, 0xb6, 0x6a, 0xa8, 0xc4, 0x5f}; + uint8_t byteswillprops11[] = {0xed, 0xd6}; + uint8_t byteswillprops14[] = {0xc2, 0x8a, 0x18, 0x6e, 0x89, 0x70, 0x6f, 0x1f, 0x4f, 0xf, + 0x17, 0xa4, 0xd2, 0xf3, 0x89, 0xb7, 0x2f, 0xb2, 0x17, 0x97, + 0x8e, 0x7, 0x7d, 0xe6, 0xb1, 0x98, 0x81, 0xbf, 0xc5, 0xef}; + uint8_t byteswillprops13[] = {0x20, 0x96, 0xcc, 0x16, 0xe7, 0x5b, 0x83, 0xcf, 0x38, 0x6f}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12106}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1675}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20416}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {12, (char*)&byteswillprops3}, .v = {19, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4756}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15069}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22988}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16579}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {2, (char*)&byteswillprops11}, .v = {21, (char*)&byteswillprops12}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3903}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {6, (char*)&byteswillprops2}, .v = {28, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11895}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29891}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5689}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11084}}, + .value = {.pair = {.k = {10, (char*)&byteswillprops13}, .v = {30, (char*)&byteswillprops14}}}}, }; - lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd, 0x7c, 0xa8, 0x66, 0x42, 0xe7, 0x31, 0x68, 0x3c, 0x79, 0x9, 0x1c, 0xc5, 0xf, 0x0, - 0x7a, 0x33, 0x32, 0xa2, 0xef, 0x73, 0x26, 0xc, 0xdb, 0xa9, 0xf, 0x47, 0x89, 0xa8}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc9, 0xbf, 0xaf, 0x83, 0x4d}; + lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x25, 0x57}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6c, 0x18, 0x93, 0x52, 0x13}; lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; @@ -3112,92 +3030,94 @@ TEST(Connect5QCTest, Encode7) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 14170; - uint8_t client_id_bytes[] = {0x66, 0x2, 0xd9, 0x58, 0xcd, 0x70, 0x70, 0x83, 0x90, 0xd8, 0x75, 0x83, 0xde, 0xd3, 0xa1}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.keep_alive = 18606; + uint8_t client_id_bytes[] = {0x36}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb5, 0xe1, 0xf1, 0x25, 0x4b, 0x58, 0xb9, 0x27, 0x94}; - lwmqtt_string_t username = {9, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf5, 0x48, 0x33, 0xb9, 0xf9, 0x80, 0xac, 0xd5, 0x6f, 0xe2, 0x4e, 0x40, 0x11}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x18, 0x28, 0x22, 0x6, 0x49, 0x85, 0xef, 0x36, 0x34, 0xfd, 0xf1, 0x2f, 0x3e, 0x3d}; - lwmqtt_string_t password = {14, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xab, 0xc3, 0x53, 0x96, 0xb3, 0xb7, 0xb8, 0xf7, 0x2a, 0xb1, 0xd3, 0x6a, 0x2e, + 0xe3, 0xef, 0xc7, 0x1a, 0xd, 0xbb, 0x83, 0x4c, 0x16, 0x18, 0xef, 0xc, 0x98}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\166\ETX\"\234D\249J8\176\230-", _password = Just "\181\"\ENQ\157\137L\US,", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "t\163\228", _willMsg = -// "\FS\227\151\f\191 \NUL\145\166!\154\157\205=\147|oE\SO\163\DC3\221\139\156\234\241\\(", _willProps = -// [PropRequestProblemInformation 81,PropWillDelayInterval 3835,PropSubscriptionIdentifier -// 22,PropRequestProblemInformation 167,PropTopicAlias 28029,PropSubscriptionIdentifierAvailable -// 141,PropMessageExpiryInterval 14497,PropServerKeepAlive 9066,PropServerReference -// "\197\&0t\155\179\ETXa\137\&9\135\238\&7\222(\131Og",PropWillDelayInterval 2997]}), _cleanSession = False, _keepAlive -// = 26482, _connID = "\203|M\250r7f|5\177\239", _properties = [PropTopicAliasMaximum 28466,PropReceiveMaximum -// 20117,PropSubscriptionIdentifier 20,PropRequestProblemInformation 82,PropAuthenticationData -// "\EMj]\240&oI\138!\238\155\&1\DLE1\159\b\154|{\143",PropRequestResponseInformation -// 168,PropSubscriptionIdentifierAvailable 144,PropMaximumQoS 220,PropUserProperty -// "\vU\150\212\156\174\207w\DC2`\a\158\161\US\189A\158 \223\&6\146\182" "\231\180\226\180\238\210{D"]} +// ConnectRequest {_username = Just "\164\ESC\184\140r\249\243:~\182\177\161", _password = Just +// "=\137\152\193\FS\138\CAN\SO\GS\172=$\179\178=\227\216>", _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "\196", _willMsg = "\189\206O\203\f\146\165\155D\200N\207\198\169;$\242\244\228", _willProps = +// [PropServerKeepAlive 15818,PropUserProperty "\211%\162\170\155j\228\171" "0\140\234.\229v8S\179Q\198 +// \221\239\243I\199\189\179Um",PropTopicAliasMaximum 10841,PropSubscriptionIdentifier 19,PropPayloadFormatIndicator +// 208]}), _cleanSession = True, _keepAlive = 14044, _connID = "\158\230\170S\NUL\239\ETB", _properties = +// [PropTopicAlias 25138,PropAssignedClientIdentifier +// "\f\EOT\r@\224\&3\187.\166\145\144\DC2Y-`\228\&8",PropResponseInformation +// "_\by\141]]}\163\DC3\145\232\\m\184>\244\236",PropTopicAliasMaximum 28569,PropServerKeepAlive +// 12548,PropMessageExpiryInterval 20738,PropSessionExpiryInterval 2221,PropWillDelayInterval +// 29838,PropRequestResponseInformation 89,PropSubscriptionIdentifier 19,PropRetainAvailable 96,PropMaximumPacketSize +// 21169,PropTopicAlias 14616,PropSubscriptionIdentifierAvailable 146]} TEST(Connect5QCTest, Encode8) { uint8_t pkt[] = { - 0x10, 0xce, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x67, 0x72, 0x4a, 0x22, 0x6f, 0x32, 0x21, 0x4e, - 0x95, 0xb, 0x14, 0x17, 0x52, 0x16, 0x0, 0x14, 0x19, 0x6a, 0x5d, 0xf0, 0x26, 0x6f, 0x49, 0x8a, 0x21, 0xee, 0x9b, - 0x31, 0x10, 0x31, 0x9f, 0x8, 0x9a, 0x7c, 0x7b, 0x8f, 0x19, 0xa8, 0x29, 0x90, 0x24, 0xdc, 0x26, 0x0, 0x16, 0xb, - 0x55, 0x96, 0xd4, 0x9c, 0xae, 0xcf, 0x77, 0x12, 0x60, 0x7, 0x9e, 0xa1, 0x1f, 0xbd, 0x41, 0x9e, 0x20, 0xdf, 0x36, - 0x92, 0xb6, 0x0, 0x8, 0xe7, 0xb4, 0xe2, 0xb4, 0xee, 0xd2, 0x7b, 0x44, 0x0, 0xb, 0xcb, 0x7c, 0x4d, 0xfa, 0x72, - 0x37, 0x66, 0x7c, 0x35, 0xb1, 0xef, 0x31, 0x17, 0x51, 0x18, 0x0, 0x0, 0xe, 0xfb, 0xb, 0x16, 0x17, 0xa7, 0x23, - 0x6d, 0x7d, 0x29, 0x8d, 0x2, 0x0, 0x0, 0x38, 0xa1, 0x13, 0x23, 0x6a, 0x1c, 0x0, 0x11, 0xc5, 0x30, 0x74, 0x9b, - 0xb3, 0x3, 0x61, 0x89, 0x39, 0x87, 0xee, 0x37, 0xde, 0x28, 0x83, 0x4f, 0x67, 0x18, 0x0, 0x0, 0xb, 0xb5, 0x0, - 0x3, 0x74, 0xa3, 0xe4, 0x0, 0x1c, 0x1c, 0xe3, 0x97, 0xc, 0xbf, 0x20, 0x0, 0x91, 0xa6, 0x21, 0x9a, 0x9d, 0xcd, - 0x3d, 0x93, 0x7c, 0x6f, 0x45, 0xe, 0xa3, 0x13, 0xdd, 0x8b, 0x9c, 0xea, 0xf1, 0x5c, 0x28, 0x0, 0xb, 0xa6, 0x3, - 0x22, 0xea, 0x44, 0xf9, 0x4a, 0x38, 0xb0, 0xe6, 0x2d, 0x0, 0x8, 0xb5, 0x22, 0x5, 0x9d, 0x89, 0x4c, 0x1f, 0x2c}; - - uint8_t buf[219] = {0}; - uint8_t bytesprops0[] = {0x19, 0x6a, 0x5d, 0xf0, 0x26, 0x6f, 0x49, 0x8a, 0x21, 0xee, - 0x9b, 0x31, 0x10, 0x31, 0x9f, 0x8, 0x9a, 0x7c, 0x7b, 0x8f}; - uint8_t bytesprops2[] = {0xe7, 0xb4, 0xe2, 0xb4, 0xee, 0xd2, 0x7b, 0x44}; - uint8_t bytesprops1[] = {0xb, 0x55, 0x96, 0xd4, 0x9c, 0xae, 0xcf, 0x77, 0x12, 0x60, 0x7, - 0x9e, 0xa1, 0x1f, 0xbd, 0x41, 0x9e, 0x20, 0xdf, 0x36, 0x92, 0xb6}; + 0x10, 0xcb, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x36, 0xdc, 0x50, 0x23, 0x62, 0x32, 0x12, 0x0, + 0x11, 0xc, 0x4, 0xd, 0x40, 0xe0, 0x33, 0xbb, 0x2e, 0xa6, 0x91, 0x90, 0x12, 0x59, 0x2d, 0x60, 0xe4, 0x38, 0x1a, + 0x0, 0x11, 0x5f, 0x8, 0x79, 0x8d, 0x5d, 0x5d, 0x7d, 0xa3, 0x13, 0x91, 0xe8, 0x5c, 0x6d, 0xb8, 0x3e, 0xf4, 0xec, + 0x22, 0x6f, 0x99, 0x13, 0x31, 0x4, 0x2, 0x0, 0x0, 0x51, 0x2, 0x11, 0x0, 0x0, 0x8, 0xad, 0x18, 0x0, 0x0, + 0x74, 0x8e, 0x19, 0x59, 0xb, 0x13, 0x25, 0x60, 0x27, 0x0, 0x0, 0x52, 0xb1, 0x23, 0x39, 0x18, 0x29, 0x92, 0x0, + 0x7, 0x9e, 0xe6, 0xaa, 0x53, 0x0, 0xef, 0x17, 0x2c, 0x13, 0x3d, 0xca, 0x26, 0x0, 0x8, 0xd3, 0x25, 0xa2, 0xaa, + 0x9b, 0x6a, 0xe4, 0xab, 0x0, 0x15, 0x30, 0x8c, 0xea, 0x2e, 0xe5, 0x76, 0x38, 0x53, 0xb3, 0x51, 0xc6, 0x20, 0xdd, + 0xef, 0xf3, 0x49, 0xc7, 0xbd, 0xb3, 0x55, 0x6d, 0x22, 0x2a, 0x59, 0xb, 0x13, 0x1, 0xd0, 0x0, 0x1, 0xc4, 0x0, + 0x13, 0xbd, 0xce, 0x4f, 0xcb, 0xc, 0x92, 0xa5, 0x9b, 0x44, 0xc8, 0x4e, 0xcf, 0xc6, 0xa9, 0x3b, 0x24, 0xf2, 0xf4, + 0xe4, 0x0, 0xc, 0xa4, 0x1b, 0xb8, 0x8c, 0x72, 0xf9, 0xf3, 0x3a, 0x7e, 0xb6, 0xb1, 0xa1, 0x0, 0x12, 0x3d, 0x89, + 0x98, 0xc1, 0x1c, 0x8a, 0x18, 0xe, 0x1d, 0xac, 0x3d, 0x24, 0xb3, 0xb2, 0x3d, 0xe3, 0xd8, 0x3e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc, 0x4, 0xd, 0x40, 0xe0, 0x33, 0xbb, 0x2e, 0xa6, + 0x91, 0x90, 0x12, 0x59, 0x2d, 0x60, 0xe4, 0x38}; + uint8_t bytesprops1[] = {0x5f, 0x8, 0x79, 0x8d, 0x5d, 0x5d, 0x7d, 0xa3, 0x13, + 0x91, 0xe8, 0x5c, 0x6d, 0xb8, 0x3e, 0xf4, 0xec}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28466}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20117}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25138}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28569}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12548}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20738}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2221}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29838}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21169}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14616}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 146}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc5, 0x30, 0x74, 0x9b, 0xb3, 0x3, 0x61, 0x89, 0x39, - 0x87, 0xee, 0x37, 0xde, 0x28, 0x83, 0x4f, 0x67}; + uint8_t byteswillprops1[] = {0x30, 0x8c, 0xea, 0x2e, 0xe5, 0x76, 0x38, 0x53, 0xb3, 0x51, 0xc6, + 0x20, 0xdd, 0xef, 0xf3, 0x49, 0xc7, 0xbd, 0xb3, 0x55, 0x6d}; + uint8_t byteswillprops0[] = {0xd3, 0x25, 0xa2, 0xaa, 0x9b, 0x6a, 0xe4, 0xab}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3835}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28029}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14497}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9066}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2997}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15818}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {8, (char*)&byteswillprops0}, .v = {21, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10841}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, }; - lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x74, 0xa3, 0xe4}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1c, 0xe3, 0x97, 0xc, 0xbf, 0x20, 0x0, 0x91, 0xa6, 0x21, 0x9a, 0x9d, 0xcd, 0x3d, - 0x93, 0x7c, 0x6f, 0x45, 0xe, 0xa3, 0x13, 0xdd, 0x8b, 0x9c, 0xea, 0xf1, 0x5c, 0x28}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc4}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xbd, 0xce, 0x4f, 0xcb, 0xc, 0x92, 0xa5, 0x9b, 0x44, 0xc8, + 0x4e, 0xcf, 0xc6, 0xa9, 0x3b, 0x24, 0xf2, 0xf4, 0xe4}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -3205,1736 +3125,1756 @@ TEST(Connect5QCTest, Encode8) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 26482; - uint8_t client_id_bytes[] = {0xcb, 0x7c, 0x4d, 0xfa, 0x72, 0x37, 0x66, 0x7c, 0x35, 0xb1, 0xef}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 14044; + uint8_t client_id_bytes[] = {0x9e, 0xe6, 0xaa, 0x53, 0x0, 0xef, 0x17}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa6, 0x3, 0x22, 0xea, 0x44, 0xf9, 0x4a, 0x38, 0xb0, 0xe6, 0x2d}; - lwmqtt_string_t username = {11, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa4, 0x1b, 0xb8, 0x8c, 0x72, 0xf9, 0xf3, 0x3a, 0x7e, 0xb6, 0xb1, 0xa1}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xb5, 0x22, 0x5, 0x9d, 0x89, 0x4c, 0x1f, 0x2c}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x3d, 0x89, 0x98, 0xc1, 0x1c, 0x8a, 0x18, 0xe, 0x1d, + 0xac, 0x3d, 0x24, 0xb3, 0xb2, 0x3d, 0xe3, 0xd8, 0x3e}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\RSYG\vm5p\188\128\155\248\238J;\221\217B\211\170%\241\&9*R ", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\207\240\217\DLE\243\157", _willMsg = -// "\v\143\189\245\140\200_\255\201%\EOTa\240\ESC\170\&4\160\216\CAN\193O\ACK\245\EOT8vEam&", _willProps = -// [PropResponseTopic "%\172'\197`)\200\251\178\&0=X=\220\153\&9\204",PropServerReference -// ";\184B\132\243F\154R\201\172\128\224\207&U\151\172W\244+\ACKB\208\&2\191$\233\&5r",PropMaximumQoS -// 201,PropPayloadFormatIndicator 25,PropContentType "m\188\FS",PropSubscriptionIdentifierAvailable -// 143,PropTopicAliasMaximum 28176,PropContentType -// "6\154\153r_\138\159\207Z\b\143\SOH\245\168\th\190\216\NAK\195r9\ETX\195H\249/l\180\236",PropWillDelayInterval -// 20471,PropWillDelayInterval 26856,PropCorrelationData "\153\217\175\RSX\246\189",PropUserProperty -// "w\250\170L?\229(~MM\STX\223\b\163A\rt\f" -// "\175\226\206\165\172F-cT\157\240\FS\254^$\218\202{\EOT\219c\252\GS\190o",PropRetainAvailable -// 118,PropAssignedClientIdentifier "\231<^R[\132\&2=\154v",PropAssignedClientIdentifier -// "\150\173\182\139&\179\178s\226\217\198\240\131\207\139",PropReasonString -// "\131\&7x\SOH\202=\233\175\209\171o\143w\136\200\253\153\200':\254\187\RS#nO\204\213",PropReceiveMaximum 17699]}), -// _cleanSession = False, _keepAlive = 4261, _connID = "T\208\249\166\143\DC3\200/\202", _properties = -// [PropServerKeepAlive 21864,PropCorrelationData "\217\235\188\190\FSl\172\ENQ\231\146",PropMaximumPacketSize -// 5914,PropUserProperty "h\146\NUL\227UV\EOT\151\196\FS\171 \138\224\SIq\SYN" -// "Oi\213\n\192i\158",PropMessageExpiryInterval 5162,PropRequestProblemInformation 164,PropAssignedClientIdentifier -// "V\255\179\DC1\188\213\208\131\&5\235\SYND\174`\225\SOH\r\142\169#\RS\152W5\190",PropMaximumPacketSize -// 32764,PropRequestProblemInformation 216,PropReceiveMaximum 2749,PropContentType "\243",PropResponseTopic -// "\245\169t\215p\180?\ACK\139gJV\FSQ \182?\215N\242\147v\221u1R\212\USh\216",PropServerReference -// "\133\195b\217\133\224\&8\ENQo\140\223\156\155\&4\178\217\195",PropWildcardSubscriptionAvailable -// 75,PropTopicAliasMaximum 10186,PropMaximumPacketSize 24607,PropTopicAlias 21250,PropTopicAliasMaximum -// 23940,PropMessageExpiryInterval 31128,PropWildcardSubscriptionAvailable 87,PropMessageExpiryInterval 11982]} +// ConnectRequest {_username = Just "bl\173\212\183[K\243\204\225\r\255\210,\215\200\142\&1\181\SOH8\206\168", _password +// = Just "\NUL. m\211I\167\170\222\224%\253#\246", _lastWill = Nothing, _cleanSession = False, _keepAlive = 24572, +// _connID = "\182$y\234\226\247:S\142\"\245_\255\&0\203\191_\249P\SUB8\223\190]0\182\ETBg<", _properties = +// [PropWillDelayInterval 17579,PropMaximumPacketSize 32742,PropAssignedClientIdentifier +// "\DELR\EOT\188\DC4\DC2u\DC2\253",PropSubscriptionIdentifierAvailable 23,PropMaximumPacketSize +// 17824,PropSharedSubscriptionAvailable 192,PropAuthenticationData "s\195i\249C\205",PropSharedSubscriptionAvailable +// 233,PropServerReference "\v\141,\136\189]\149\150e\233\US\149 \241\GSw]\193\t",PropServerReference +// "\DC2\193R\ETB\176M\189\155\134\206\253e\153\EM\152",PropMaximumQoS 124,PropRequestProblemInformation +// 185,PropWillDelayInterval 23945,PropServerKeepAlive 11387,PropMaximumPacketSize 2848,PropAssignedClientIdentifier +// "\DC1\240\252\182N\207M\251\252\RSLoj\180",PropServerKeepAlive 503,PropMaximumPacketSize 19175,PropAuthenticationData +// "R\150\224\199\FSN7\164\DC1\255\v\184\SOH\216R\137\132E\132\ETBT4",PropRetainAvailable 14,PropWillDelayInterval +// 23960]} TEST(Connect5QCTest, Encode9) { uint8_t pkt[] = { - 0x10, 0xe0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x34, 0x10, 0xa5, 0xb4, 0x1, 0x13, 0x55, 0x68, 0x9, - 0x0, 0xa, 0xd9, 0xe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6, 0x8b, 0x26, - 0xb3, 0xb2, 0x73, 0xe2, 0xd9, 0xc6, 0xf0, 0x83, 0xcf, 0x8b, 0x1f, 0x0, 0x1c, 0x83, 0x37, 0x78, 0x1, 0xca, 0x3d, - 0xe9, 0xaf, 0xd1, 0xab, 0x6f, 0x8f, 0x77, 0x88, 0xc8, 0xfd, 0x99, 0xc8, 0x27, 0x3a, 0xfe, 0xbb, 0x1e, 0x23, 0x6e, - 0x4f, 0xcc, 0xd5, 0x21, 0x45, 0x23, 0x0, 0x6, 0xcf, 0xf0, 0xd9, 0x10, 0xf3, 0x9d, 0x0, 0x1e, 0xb, 0x8f, 0xbd, - 0xf5, 0x8c, 0xc8, 0x5f, 0xff, 0xc9, 0x25, 0x4, 0x61, 0xf0, 0x1b, 0xaa, 0x34, 0xa0, 0xd8, 0x18, 0xc1, 0x4f, 0x6, - 0xf5, 0x4, 0x38, 0x76, 0x45, 0x61, 0x6d, 0x26}; - - uint8_t buf[493] = {0}; - uint8_t bytesprops0[] = {0xd9, 0xeb, 0xbc, 0xbe, 0x1c, 0x6c, 0xac, 0x5, 0xe7, 0x92}; - uint8_t bytesprops2[] = {0x4f, 0x69, 0xd5, 0xa, 0xc0, 0x69, 0x9e}; - uint8_t bytesprops1[] = {0x68, 0x92, 0x0, 0xe3, 0x55, 0x56, 0x4, 0x97, 0xc4, - 0x1c, 0xab, 0x20, 0x8a, 0xe0, 0xf, 0x71, 0x16}; - uint8_t bytesprops3[] = {0x56, 0xff, 0xb3, 0x11, 0xbc, 0xd5, 0xd0, 0x83, 0x35, 0xeb, 0x16, 0x44, 0xae, - 0x60, 0xe1, 0x1, 0xd, 0x8e, 0xa9, 0x23, 0x1e, 0x98, 0x57, 0x35, 0xbe}; - uint8_t bytesprops4[] = {0xf3}; - uint8_t bytesprops5[] = {0xf5, 0xa9, 0x74, 0xd7, 0x70, 0xb4, 0x3f, 0x6, 0x8b, 0x67, 0x4a, 0x56, 0x1c, 0x51, 0x20, - 0xb6, 0x3f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 0xb8, 0x1, 0xd8, 0x52, 0x89, 0x84, 0x45, 0x84, 0x17, 0x54, 0x34, 0x25, 0xe, 0x18, 0x0, 0x0, 0x5d, 0x98, + 0x0, 0x1d, 0xb6, 0x24, 0x79, 0xea, 0xe2, 0xf7, 0x3a, 0x53, 0x8e, 0x22, 0xf5, 0x5f, 0xff, 0x30, 0xcb, 0xbf, 0x5f, + 0xf9, 0x50, 0x1a, 0x38, 0xdf, 0xbe, 0x5d, 0x30, 0xb6, 0x17, 0x67, 0x3c, 0x0, 0x17, 0x62, 0x6c, 0xad, 0xd4, 0xb7, + 0x5b, 0x4b, 0xf3, 0xcc, 0xe1, 0xd, 0xff, 0xd2, 0x2c, 0xd7, 0xc8, 0x8e, 0x31, 0xb5, 0x1, 0x38, 0xce, 0xa8, 0x0, + 0xe, 0x0, 0x2e, 0x20, 0x6d, 0xd3, 0x49, 0xa7, 0xaa, 0xde, 0xe0, 0x25, 0xfd, 0x23, 0xf6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7f, 0x52, 0x4, 0xbc, 0x14, 0x12, 0x75, 0x12, 0xfd}; + uint8_t bytesprops1[] = {0x73, 0xc3, 0x69, 0xf9, 0x43, 0xcd}; + uint8_t bytesprops2[] = {0xb, 0x8d, 0x2c, 0x88, 0xbd, 0x5d, 0x95, 0x96, 0x65, 0xe9, + 0x1f, 0x95, 0x20, 0xf1, 0x1d, 0x77, 0x5d, 0xc1, 0x9}; + uint8_t bytesprops3[] = {0x12, 0xc1, 0x52, 0x17, 0xb0, 0x4d, 0xbd, 0x9b, 0x86, 0xce, 0xfd, 0x65, 0x99, 0x19, 0x98}; + uint8_t bytesprops4[] = {0x11, 0xf0, 0xfc, 0xb6, 0x4e, 0xcf, 0x4d, 0xfb, 0xfc, 0x1e, 0x4c, 0x6f, 0x6a, 0xb4}; + uint8_t bytesprops5[] = {0x52, 0x96, 0xe0, 0xc7, 0x1c, 0x4e, 0x37, 0xa4, 0x11, 0xff, 0xb, + 0xb8, 0x1, 0xd8, 0x52, 0x89, 0x84, 0x45, 0x84, 0x17, 0x54, 0x34}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21864}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5914}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {7, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5162}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32764}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2749}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10186}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24607}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21250}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23940}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31128}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11982}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17579}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32742}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17824}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23945}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11387}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2848}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 503}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19175}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23960}}, }; lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x25, 0xac, 0x27, 0xc5, 0x60, 0x29, 0xc8, 0xfb, 0xb2, - 0x30, 0x3d, 0x58, 0x3d, 0xdc, 0x99, 0x39, 0xcc}; - uint8_t byteswillprops1[] = {0x3b, 0xb8, 0x42, 0x84, 0xf3, 0x46, 0x9a, 0x52, 0xc9, 0xac, 0x80, 0xe0, 0xcf, 0x26, 0x55, - 0x97, 0xac, 0x57, 0xf4, 0x2b, 0x6, 0x42, 0xd0, 0x32, 0xbf, 0x24, 0xe9, 0x35, 0x72}; - uint8_t byteswillprops2[] = {0x6d, 0xbc, 0x1c}; - uint8_t byteswillprops3[] = {0x36, 0x9a, 0x99, 0x72, 0x5f, 0x8a, 0x9f, 0xcf, 0x5a, 0x8, - 0x8f, 0x1, 0xf5, 0xa8, 0x9, 0x68, 0xbe, 0xd8, 0x15, 0xc3, - 0x72, 0x39, 0x3, 0xc3, 0x48, 0xf9, 0x2f, 0x6c, 0xb4, 0xec}; - uint8_t byteswillprops4[] = {0x99, 0xd9, 0xaf, 0x1e, 0x58, 0xf6, 0xbd}; - uint8_t byteswillprops6[] = {0xaf, 0xe2, 0xce, 0xa5, 0xac, 0x46, 0x2d, 0x63, 0x54, 0x9d, 0xf0, 0x1c, 0xfe, - 0x5e, 0x24, 0xda, 0xca, 0x7b, 0x4, 0xdb, 0x63, 0xfc, 0x1d, 0xbe, 0x6f}; - uint8_t byteswillprops5[] = {0x77, 0xfa, 0xaa, 0x4c, 0x3f, 0xe5, 0x28, 0x7e, 0x4d, - 0x4d, 0x2, 0xdf, 0x8, 0xa3, 0x41, 0xd, 0x74, 0xc}; - uint8_t byteswillprops7[] = {0xe7, 0x3c, 0x5e, 0x52, 0x5b, 0x84, 0x32, 0x3d, 0x9a, 0x76}; - uint8_t byteswillprops8[] = {0x96, 0xad, 0xb6, 0x8b, 0x26, 0xb3, 0xb2, 0x73, - 0xe2, 0xd9, 0xc6, 0xf0, 0x83, 0xcf, 0x8b}; - uint8_t byteswillprops9[] = {0x83, 0x37, 0x78, 0x1, 0xca, 0x3d, 0xe9, 0xaf, 0xd1, 0xab, 0x6f, 0x8f, 0x77, 0x88, - 0xc8, 0xfd, 0x99, 0xc8, 0x27, 0x3a, 0xfe, 0xbb, 0x1e, 0x23, 0x6e, 0x4f, 0xcc, 0xd5}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28176}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20471}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26856}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {18, (char*)&byteswillprops5}, .v = {25, (char*)&byteswillprops6}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17699}}, - }; - - lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xcf, 0xf0, 0xd9, 0x10, 0xf3, 0x9d}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb, 0x8f, 0xbd, 0xf5, 0x8c, 0xc8, 0x5f, 0xff, 0xc9, 0x25, - 0x4, 0x61, 0xf0, 0x1b, 0xaa, 0x34, 0xa0, 0xd8, 0x18, 0xc1, - 0x4f, 0x6, 0xf5, 0x4, 0x38, 0x76, 0x45, 0x61, 0x6d, 0x26}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 4261; - uint8_t client_id_bytes[] = {0x54, 0xd0, 0xf9, 0xa6, 0x8f, 0x13, 0xc8, 0x2f, 0xca}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.keep_alive = 24572; + uint8_t client_id_bytes[] = {0xb6, 0x24, 0x79, 0xea, 0xe2, 0xf7, 0x3a, 0x53, 0x8e, 0x22, 0xf5, 0x5f, 0xff, 0x30, 0xcb, + 0xbf, 0x5f, 0xf9, 0x50, 0x1a, 0x38, 0xdf, 0xbe, 0x5d, 0x30, 0xb6, 0x17, 0x67, 0x3c}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x1e, 0x59, 0x47, 0xb, 0x6d, 0x35, 0x70, 0xbc, 0x80, 0x9b, 0xf8, 0xee, 0x4a, - 0x3b, 0xdd, 0xd9, 0x42, 0xd3, 0xaa, 0x25, 0xf1, 0x39, 0x2a, 0x52, 0x20}; - lwmqtt_string_t password = {25, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x62, 0x6c, 0xad, 0xd4, 0xb7, 0x5b, 0x4b, 0xf3, 0xcc, 0xe1, 0xd, 0xff, + 0xd2, 0x2c, 0xd7, 0xc8, 0x8e, 0x31, 0xb5, 0x1, 0x38, 0xce, 0xa8}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x0, 0x2e, 0x20, 0x6d, 0xd3, 0x49, 0xa7, 0xaa, 0xde, 0xe0, 0x25, 0xfd, 0x23, 0xf6}; + lwmqtt_string_t password = {14, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\241\185^\SOH4\186U}I\208\137\131M\161C\190\134\174(B\181", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "8\\s\tW\213@\b\174\150", _willMsg = -// "\245\248\244q)\133\&9%\158\ESC\a\252]Rco'^\200;", _willProps = [PropRequestProblemInformation -// 112,PropRequestProblemInformation 179,PropWildcardSubscriptionAvailable 61,PropAuthenticationData -// "\213L\153\173\148Z\254\177\155\231\153F32\235'\176\195",PropServerKeepAlive 1358,PropSharedSubscriptionAvailable -// 250,PropResponseInformation "\b4\222\STXQ\253\188\252\140\ra\b\176\GSs",PropSessionExpiryInterval 5859]}), -// _cleanSession = True, _keepAlive = 15075, _connID = "~g'\172", _properties = [PropTopicAliasMaximum -// 13675,PropSubscriptionIdentifierAvailable 45,PropSubscriptionIdentifierAvailable 160,PropAuthenticationData -// "D\184\161\ETX\189\196W\233\EOT\DEL|\168\&7\232",PropAuthenticationMethod -// "e\225\186\240p\147\227U\188v\132\192\251s\SO!~?\154\246\203\237\241\145",PropWildcardSubscriptionAvailable -// 210,PropReceiveMaximum 19490,PropMessageExpiryInterval 17696,PropResponseInformation -// "\SI\237.3\208",PropServerReference -// "\228f&\209!\147\165\215W\149\128\172\174\240\177o\207\156\128#\184\&8+\219\210\173-\196C",PropTopicAliasMaximum -// 10620,PropRequestResponseInformation 178,PropServerKeepAlive 17815,PropSessionExpiryInterval -// 31669,PropSubscriptionIdentifierAvailable 37,PropSharedSubscriptionAvailable 196,PropSessionExpiryInterval -// 9649,PropRetainAvailable 115,PropAssignedClientIdentifier "k\NAKr\222\138\154U\249\&4 -// \ESC^o]\230",PropMaximumPacketSize 31762,PropSessionExpiryInterval 10448,PropServerReference -// "v\211F\243=3\195",PropRetainAvailable 125,PropRequestProblemInformation 76,PropSubscriptionIdentifier -// 0,PropAuthenticationData "\236YG\200IK\ESC2h\141w\186\191f\250p\165\232#\153\183\209yB\206\152\&8\230"]} +// ConnectRequest {_username = Just "=\CANt\155_d\FS\f:\252", _password = Just "J\175\SI\188\240", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\181\230\197Xq\187C@;P\208\&1\CAN\191\152w[\185`UI\CAN", _willMsg = "\151\DC4y'PM^\214\&0<^k\179\179:|", _willProps +// = [PropResponseInformation +// "w\DC2=\165M\231\238\NAK\162\240\206q\152\142\227\220\168\167,K\222y\240w\223\218`\248",PropMessageExpiryInterval +// 11399,PropSessionExpiryInterval 29117,PropAuthenticationData "\a\ENQ\194|\DC3 +// \229\186L?\155\167T\FSV\205\146$\166\195\EOT:\fo",PropWillDelayInterval 19781,PropResponseInformation +// ":\253$u\EM\144\&3\139",PropRetainAvailable 243,PropSubscriptionIdentifierAvailable 252,PropUserProperty +// "6\205}\204\235=aO,\v\200p\184b\189\165\ETBN\228-\240\161\233\247" "",PropMessageExpiryInterval +// 5382,PropServerReference "=\147\ETB",PropResponseTopic "~\170Ydd\SYNoj\198*2\187\206C +// O\236\v\223\250\223\222\249\191\170A",PropMessageExpiryInterval 12235,PropSubscriptionIdentifier +// 10,PropSubscriptionIdentifierAvailable 218,PropCorrelationData "K >zG\226d\219\FS\253 ",PropMaximumPacketSize +// 19752,PropAssignedClientIdentifier "\208\222r\156\DEL\206XE",PropMaximumQoS 211,PropMaximumQoS +// 34,PropTopicAliasMaximum 15201,PropSharedSubscriptionAvailable 156]}), _cleanSession = False, _keepAlive = 147, +// _connID = "\252{\206-]\238\&1\253 \RS\SIy\178", _properties = [PropMessageExpiryInterval 15650,PropCorrelationData +// "\168s\144\128\209P\198\193\146\140\173\206v\198\170\169n\EM\\+j-\198u\215\144\\\204\168\"",PropTopicAlias +// 6863,PropSharedSubscriptionAvailable 115,PropWillDelayInterval 9805,PropMessageExpiryInterval +// 13621,PropMaximumPacketSize 29496,PropSubscriptionIdentifierAvailable 181,PropAuthenticationData +// ">\161\NAK\175",PropSubscriptionIdentifier 13,PropMessageExpiryInterval 5726,PropMaximumQoS +// 52,PropAssignedClientIdentifier ")",PropSessionExpiryInterval 13529,PropMaximumQoS +// 103,PropWildcardSubscriptionAvailable 7,PropTopicAlias 4946,PropMaximumPacketSize 20204,PropRetainAvailable +// 45,PropTopicAlias 14764,PropSubscriptionIdentifier 13,PropSharedSubscriptionAvailable 253,PropResponseTopic +// "\145\b\215\250\196&\STX\199\253",PropMessageExpiryInterval 22286]} TEST(Connect5QCTest, Encode10) { uint8_t pkt[] = { - 0x10, 0xcb, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0x3a, 0xe3, 0xc8, 0x1, 0x22, 0x35, 0x6b, 0x29, - 0x2d, 0x29, 0xa0, 0x16, 0x0, 0xe, 0x44, 0xb8, 0xa1, 0x3, 0xbd, 0xc4, 0x57, 0xe9, 0x4, 0x7f, 0x7c, 0xa8, 0x37, - 0xe8, 0x15, 0x0, 0x18, 0x65, 0xe1, 0xba, 0xf0, 0x70, 0x93, 0xe3, 0x55, 0xbc, 0x76, 0x84, 0xc0, 0xfb, 0x73, 0xe, - 0x21, 0x7e, 0x3f, 0x9a, 0xf6, 0xcb, 0xed, 0xf1, 0x91, 0x28, 0xd2, 0x21, 0x4c, 0x22, 0x2, 0x0, 0x0, 0x45, 0x20, - 0x1a, 0x0, 0x5, 0xf, 0xed, 0x2e, 0x33, 0xd0, 0x1c, 0x0, 0x1d, 0xe4, 0x66, 0x26, 0xd1, 0x21, 0x93, 0xa5, 0xd7, - 0x57, 0x95, 0x80, 0xac, 0xae, 0xf0, 0xb1, 0x6f, 0xcf, 0x9c, 0x80, 0x23, 0xb8, 0x38, 0x2b, 0xdb, 0xd2, 0xad, 0x2d, - 0xc4, 0x43, 0x22, 0x29, 0x7c, 0x19, 0xb2, 0x13, 0x45, 0x97, 0x11, 0x0, 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xb9, 0x5e, 0x1, 0x34, 0xba, 0x55, 0x7d, 0x49, 0xd0, - 0x89, 0x83, 0x4d, 0xa1, 0x43, 0xbe, 0x86, 0xae, 0x28, 0x42, 0xb5}; - - uint8_t buf[344] = {0}; - uint8_t bytesprops0[] = {0x44, 0xb8, 0xa1, 0x3, 0xbd, 0xc4, 0x57, 0xe9, 0x4, 0x7f, 0x7c, 0xa8, 0x37, 0xe8}; - uint8_t bytesprops1[] = {0x65, 0xe1, 0xba, 0xf0, 0x70, 0x93, 0xe3, 0x55, 0xbc, 0x76, 0x84, 0xc0, - 0xfb, 0x73, 0xe, 0x21, 0x7e, 0x3f, 0x9a, 0xf6, 0xcb, 0xed, 0xf1, 0x91}; - uint8_t bytesprops2[] = {0xf, 0xed, 0x2e, 0x33, 0xd0}; - uint8_t bytesprops3[] = {0xe4, 0x66, 0x26, 0xd1, 0x21, 0x93, 0xa5, 0xd7, 0x57, 0x95, 0x80, 0xac, 0xae, 0xf0, 0xb1, - 0x6f, 0xcf, 0x9c, 0x80, 0x23, 0xb8, 0x38, 0x2b, 0xdb, 0xd2, 0xad, 0x2d, 0xc4, 0x43}; - uint8_t bytesprops4[] = {0x6b, 0x15, 0x72, 0xde, 0x8a, 0x9a, 0x55, 0xf9, 0x34, 0x20, 0x1b, 0x5e, 0x6f, 0x5d, 0xe6}; - uint8_t bytesprops5[] = {0x76, 0xd3, 0x46, 0xf3, 0x3d, 0x33, 0xc3}; - uint8_t bytesprops6[] = {0xec, 0x59, 0x47, 0xc8, 0x49, 0x4b, 0x1b, 0x32, 0x68, 0x8d, 0x77, 0xba, 0xbf, 0x66, - 0xfa, 0x70, 0xa5, 0xe8, 0x23, 0x99, 0xb7, 0xd1, 0x79, 0x42, 0xce, 0x98, 0x38, 0xe6}; + 0x10, 0xa1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x0, 0x93, 0x7b, 0x2, 0x0, 0x0, 0x3d, 0x22, + 0x9, 0x0,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x6b, 0xb3, 0xb3, + 0x3a, 0x7c, 0x0, 0xa, 0x3d, 0x18, 0x74, 0x9b, 0x5f, 0x64, 0x1c, 0xc, 0x3a, 0xfc, 0x0, 0x5, 0x4a, 0xaf, 0xf, + 0xbc, 0xf0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa8, 0x73, 0x90, 0x80, 0xd1, 0x50, 0xc6, 0xc1, 0x92, 0x8c, 0xad, 0xce, 0x76, 0xc6, 0xaa, + 0xa9, 0x6e, 0x19, 0x5c, 0x2b, 0x6a, 0x2d, 0xc6, 0x75, 0xd7, 0x90, 0x5c, 0xcc, 0xa8, 0x22}; + uint8_t bytesprops1[] = {0x3e, 0xa1, 0x15, 0xaf}; + uint8_t bytesprops2[] = {0x29}; + uint8_t bytesprops3[] = {0x91, 0x8, 0xd7, 0xfa, 0xc4, 0x26, 0x2, 0xc7, 0xfd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13675}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19490}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17696}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10620}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17815}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31669}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9649}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31762}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10448}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15650}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6863}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9805}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13621}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29496}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5726}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13529}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4946}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20204}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14764}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22286}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd5, 0x4c, 0x99, 0xad, 0x94, 0x5a, 0xfe, 0xb1, 0x9b, - 0xe7, 0x99, 0x46, 0x33, 0x32, 0xeb, 0x27, 0xb0, 0xc3}; - uint8_t byteswillprops1[] = {0x8, 0x34, 0xde, 0x2, 0x51, 0xfd, 0xbc, 0xfc, 0x8c, 0xd, 0x61, 0x8, 0xb0, 0x1d, 0x73}; + uint8_t byteswillprops0[] = {0x77, 0x12, 0x3d, 0xa5, 0x4d, 0xe7, 0xee, 0x15, 0xa2, 0xf0, 0xce, 0x71, 0x98, 0x8e, + 0xe3, 0xdc, 0xa8, 0xa7, 0x2c, 0x4b, 0xde, 0x79, 0xf0, 0x77, 0xdf, 0xda, 0x60, 0xf8}; + uint8_t byteswillprops1[] = {0x7, 0x5, 0xc2, 0x7c, 0x13, 0x20, 0xe5, 0xba, 0x4c, 0x3f, 0x9b, 0xa7, + 0x54, 0x1c, 0x56, 0xcd, 0x92, 0x24, 0xa6, 0xc3, 0x4, 0x3a, 0xc, 0x6f}; + uint8_t byteswillprops2[] = {0x3a, 0xfd, 0x24, 0x75, 0x19, 0x90, 0x33, 0x8b}; + uint8_t byteswillprops4[] = {0}; + uint8_t byteswillprops3[] = {0x36, 0xcd, 0x7d, 0xcc, 0xeb, 0x3d, 0x61, 0x4f, 0x2c, 0xb, 0xc8, 0x70, + 0xb8, 0x62, 0xbd, 0xa5, 0x17, 0x4e, 0xe4, 0x2d, 0xf0, 0xa1, 0xe9, 0xf7}; + uint8_t byteswillprops5[] = {0x3d, 0x93, 0x17}; + uint8_t byteswillprops6[] = {0x7e, 0xaa, 0x59, 0x64, 0x64, 0x16, 0x6f, 0x6a, 0xc6, 0x2a, 0x32, 0xbb, 0xce, + 0x43, 0x20, 0x4f, 0xec, 0xb, 0xdf, 0xfa, 0xdf, 0xde, 0xf9, 0xbf, 0xaa, 0x41}; + uint8_t byteswillprops7[] = {0x4b, 0x20, 0x3e, 0x7a, 0x47, 0xe2, 0x64, 0xdb, 0x1c, 0xfd, 0x20}; + uint8_t byteswillprops8[] = {0xd0, 0xde, 0x72, 0x9c, 0x7f, 0xce, 0x58, 0x45}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1358}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5859}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11399}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29117}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19781}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {24, (char*)&byteswillprops3}, .v = {0, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5382}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12235}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19752}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15201}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 156}}, }; - lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x38, 0x5c, 0x73, 0x9, 0x57, 0xd5, 0x40, 0x8, 0xae, 0x96}; - lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf5, 0xf8, 0xf4, 0x71, 0x29, 0x85, 0x39, 0x25, 0x9e, 0x1b, - 0x7, 0xfc, 0x5d, 0x52, 0x63, 0x6f, 0x27, 0x5e, 0xc8, 0x3b}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb5, 0xe6, 0xc5, 0x58, 0x71, 0xbb, 0x43, 0x40, 0x3b, 0x50, 0xd0, + 0x31, 0x18, 0xbf, 0x98, 0x77, 0x5b, 0xb9, 0x60, 0x55, 0x49, 0x18}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x97, 0x14, 0x79, 0x27, 0x50, 0x4d, 0x5e, 0xd6, + 0x30, 0x3c, 0x5e, 0x6b, 0xb3, 0xb3, 0x3a, 0x7c}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 15075; - uint8_t client_id_bytes[] = {0x7e, 0x67, 0x27, 0xac}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 147; + uint8_t client_id_bytes[] = {0xfc, 0x7b, 0xce, 0x2d, 0x5d, 0xee, 0x31, 0xfd, 0x20, 0x1e, 0xf, 0x79, 0xb2}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf1, 0xb9, 0x5e, 0x1, 0x34, 0xba, 0x55, 0x7d, 0x49, 0xd0, 0x89, - 0x83, 0x4d, 0xa1, 0x43, 0xbe, 0x86, 0xae, 0x28, 0x42, 0xb5}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x3d, 0x18, 0x74, 0x9b, 0x5f, 0x64, 0x1c, 0xc, 0x3a, 0xfc}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x4a, 0xaf, 0xf, 0xbc, 0xf0}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30493 [("\214C\211\153\&6\151\166\198\180w\131_\236",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\173\182\235`z\189",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\142J\163\SUB<\166\240y\176r\192",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS1}),("_\255]*t\ETB\162j\206\132\141\&3\169\148\170\217$H\SYN\255\187\131\233\244\159'\165\229M",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\CANY\SI2\187\199D\227G\253\202\CAN\208h\154h`\254\236\133/\200\173\163\158\208\238u>",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\237\ETB1\149\ETX\245\172\173\ETB\135\SOI",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS0}),("\245\157c\165h\181Ss\238\217\ESC\ENQ\206\225\171l\SUB\160A$\239\146pa\170\138",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\142\210",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 6101 [(",\ENQ\132\182e\220\SYN%\233\253\238",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\RSH\179\141\155\183W\DC3\253\169v6\193;\187`c\217\218\234",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0xa0, 0x1, 0x77, 0x1d, 0x0, 0xd, 0xd6, 0x43, 0xd3, 0x99, 0x36, 0x97, 0xa6, 0xc6, 0xb4, 0x77, - 0x83, 0x5f, 0xec, 0x2, 0x0, 0x0, 0x1, 0x0, 0x6, 0xad, 0xb6, 0xeb, 0x60, 0x7a, 0xbd, 0x0, 0x0, - 0xb, 0x8e, 0x4a, 0xa3, 0x1a, 0x3c, 0xa6, 0xf0, 0x79, 0xb0, 0x72, 0xc0, 0x1, 0x0, 0x1d, 0x5f, 0xff, - 0x5d, 0x2a, 0x74, 0x17, 0xa2, 0x6a, 0xce, 0x84, 0x8d, 0x33, 0xa9, 0x94, 0xaa, 0xd9, 0x24, 0x48, 0x16, - 0xff, 0xbb, 0x83, 0xe9, 0xf4, 0x9f, 0x27, 0xa5, 0xe5, 0x4d, 0x1, 0x0, 0x1d, 0x18, 0x59, 0xf, 0x32, - 0xbb, 0xc7, 0x44, 0xe3, 0x47, 0xfd, 0xca, 0x18, 0xd0, 0x68, 0x9a, 0x68, 0x60, 0xfe, 0xec, 0x85, 0x2f, - 0xc8, 0xad, 0xa3, 0x9e, 0xd0, 0xee, 0x75, 0x3e, 0x0, 0x0, 0xc, 0xed, 0x17, 0x31, 0x95, 0x3, 0xf5, - 0xac, 0xad, 0x17, 0x87, 0xe, 0x49, 0x0, 0x0, 0x1a, 0xf5, 0x9d, 0x63, 0xa5, 0x68, 0xb5, 0x53, 0x73, - 0xee, 0xd9, 0x1b, 0x5, 0xce, 0xe1, 0xab, 0x6c, 0x1a, 0xa0, 0x41, 0x24, 0xef, 0x92, 0x70, 0x61, 0xaa, - 0x8a, 0x2, 0x0, 0x0, 0x0, 0x0, 0x2, 0x8e, 0xd2, 0x0}; - - uint8_t buf[173] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd6, 0x43, 0xd3, 0x99, 0x36, 0x97, 0xa6, 0xc6, 0xb4, 0x77, 0x83, 0x5f, 0xec}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x27, 0x17, 0xd5, 0x0, 0xb, 0x2c, 0x5, 0x84, 0xb6, 0x65, 0xdc, 0x16, 0x25, + 0xe9, 0xfd, 0xee, 0x1, 0x0, 0x14, 0x1e, 0x48, 0xb3, 0x8d, 0x9b, 0xb7, 0x57, 0x13, + 0xfd, 0xa9, 0x76, 0x36, 0xc1, 0x3b, 0xbb, 0x60, 0x63, 0xd9, 0xda, 0xea, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x2c, 0x5, 0x84, 0xb6, 0x65, 0xdc, 0x16, 0x25, 0xe9, 0xfd, 0xee}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0x48, 0xb3, 0x8d, 0x9b, 0xb7, 0x57, 0x13, 0xfd, 0xa9, + 0x76, 0x36, 0xc1, 0x3b, 0xbb, 0x60, 0x63, 0xd9, 0xda, 0xea}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xad, 0xb6, 0xeb, 0x60, 0x7a, 0xbd}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8e, 0x4a, 0xa3, 0x1a, 0x3c, 0xa6, 0xf0, 0x79, 0xb0, 0x72, 0xc0}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5f, 0xff, 0x5d, 0x2a, 0x74, 0x17, 0xa2, 0x6a, 0xce, 0x84, - 0x8d, 0x33, 0xa9, 0x94, 0xaa, 0xd9, 0x24, 0x48, 0x16, 0xff, - 0xbb, 0x83, 0xe9, 0xf4, 0x9f, 0x27, 0xa5, 0xe5, 0x4d}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x18, 0x59, 0xf, 0x32, 0xbb, 0xc7, 0x44, 0xe3, 0x47, 0xfd, - 0xca, 0x18, 0xd0, 0x68, 0x9a, 0x68, 0x60, 0xfe, 0xec, 0x85, - 0x2f, 0xc8, 0xad, 0xa3, 0x9e, 0xd0, 0xee, 0x75, 0x3e}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xed, 0x17, 0x31, 0x95, 0x3, 0xf5, 0xac, 0xad, 0x17, 0x87, 0xe, 0x49}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf5, 0x9d, 0x63, 0xa5, 0x68, 0xb5, 0x53, 0x73, 0xee, 0xd9, 0x1b, 0x5, 0xce, - 0xe1, 0xab, 0x6c, 0x1a, 0xa0, 0x41, 0x24, 0xef, 0x92, 0x70, 0x61, 0xaa, 0x8a}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0}; - lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x8e, 0xd2}; - lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30493, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6101, 2, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20478 [("\184}2\DC2\bp#\148\f\DC1\208}\194",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\181\209\150\255\240\&5\243\DC2\SO\208ji\180\129&P\178\ENQ?\229W?\192\GS\185\211\166\213\&4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\248\196L\195\ESC\ETX\DC3N\135\&3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\198\170\141\229\221[\227KN\143Fw\153\t\163\203\n\181\151\147\170",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\160\253\207yPZ\a\211\172o\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\164s\134^.\223\218\240\197J\148\212",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\240\\\189j\185\226\139}",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("x\172\224\142\143\226\196Z\SYN0\229l\218\175u`\190\250.m\227\222\240\ACK\255\DC2\211W",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\197U\154\166\243\218<\211^f\176\170Y\DC3\162;9^\159\232\181\239\161D\179\&2",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 25296 [("\DC1\170f\212\242sLZ\148\SIg)\208\ACK\128U\161\186\NUL)\214\158",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode2) { - uint8_t pkt[] = { - 0x82, 0xbb, 0x1, 0x4f, 0xfe, 0x0, 0xd, 0xb8, 0x7d, 0x32, 0x12, 0x8, 0x70, 0x23, 0x94, 0xc, 0x11, 0xd0, 0x7d, - 0xc2, 0x1, 0x0, 0x1d, 0xb5, 0xd1, 0x96, 0xff, 0xf0, 0x35, 0xf3, 0x12, 0xe, 0xd0, 0x6a, 0x69, 0xb4, 0x81, 0x26, - 0x50, 0xb2, 0x5, 0x3f, 0xe5, 0x57, 0x3f, 0xc0, 0x1d, 0xb9, 0xd3, 0xa6, 0xd5, 0x34, 0x2, 0x0, 0xa, 0xf8, 0xc4, - 0x4c, 0xc3, 0x1b, 0x3, 0x13, 0x4e, 0x87, 0x33, 0x0, 0x0, 0x15, 0xc6, 0xaa, 0x8d, 0xe5, 0xdd, 0x5b, 0xe3, 0x4b, - 0x4e, 0x8f, 0x46, 0x77, 0x99, 0x9, 0xa3, 0xcb, 0xa, 0xb5, 0x97, 0x93, 0xaa, 0x1, 0x0, 0xb, 0xa0, 0xfd, 0xcf, - 0x79, 0x50, 0x5a, 0x7, 0xd3, 0xac, 0x6f, 0x94, 0x0, 0x0, 0xc, 0xa4, 0x73, 0x86, 0x5e, 0x2e, 0xdf, 0xda, 0xf0, - 0xc5, 0x4a, 0x94, 0xd4, 0x2, 0x0, 0x8, 0xf0, 0x5c, 0xbd, 0x6a, 0xb9, 0xe2, 0x8b, 0x7d, 0x2, 0x0, 0x1c, 0x78, - 0xac, 0xe0, 0x8e, 0x8f, 0xe2, 0xc4, 0x5a, 0x16, 0x30, 0xe5, 0x6c, 0xda, 0xaf, 0x75, 0x60, 0xbe, 0xfa, 0x2e, 0x6d, - 0xe3, 0xde, 0xf0, 0x6, 0xff, 0x12, 0xd3, 0x57, 0x0, 0x0, 0x1a, 0xc5, 0x55, 0x9a, 0xa6, 0xf3, 0xda, 0x3c, 0xd3, - 0x5e, 0x66, 0xb0, 0xaa, 0x59, 0x13, 0xa2, 0x3b, 0x39, 0x5e, 0x9f, 0xe8, 0xb5, 0xef, 0xa1, 0x44, 0xb3, 0x32, 0x2}; - - uint8_t buf[200] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xb8, 0x7d, 0x32, 0x12, 0x8, 0x70, 0x23, 0x94, 0xc, 0x11, 0xd0, 0x7d, 0xc2}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x1b, 0x62, 0xd0, 0x0, 0x16, 0x11, 0xaa, 0x66, 0xd4, 0xf2, 0x73, 0x4c, 0x5a, 0x94, + 0xf, 0x67, 0x29, 0xd0, 0x6, 0x80, 0x55, 0xa1, 0xba, 0x0, 0x29, 0xd6, 0x9e, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x11, 0xaa, 0x66, 0xd4, 0xf2, 0x73, 0x4c, 0x5a, 0x94, 0xf, 0x67, + 0x29, 0xd0, 0x6, 0x80, 0x55, 0xa1, 0xba, 0x0, 0x29, 0xd6, 0x9e}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb5, 0xd1, 0x96, 0xff, 0xf0, 0x35, 0xf3, 0x12, 0xe, 0xd0, - 0x6a, 0x69, 0xb4, 0x81, 0x26, 0x50, 0xb2, 0x5, 0x3f, 0xe5, - 0x57, 0x3f, 0xc0, 0x1d, 0xb9, 0xd3, 0xa6, 0xd5, 0x34}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf8, 0xc4, 0x4c, 0xc3, 0x1b, 0x3, 0x13, 0x4e, 0x87, 0x33}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc6, 0xaa, 0x8d, 0xe5, 0xdd, 0x5b, 0xe3, 0x4b, 0x4e, 0x8f, 0x46, - 0x77, 0x99, 0x9, 0xa3, 0xcb, 0xa, 0xb5, 0x97, 0x93, 0xaa}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa0, 0xfd, 0xcf, 0x79, 0x50, 0x5a, 0x7, 0xd3, 0xac, 0x6f, 0x94}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa4, 0x73, 0x86, 0x5e, 0x2e, 0xdf, 0xda, 0xf0, 0xc5, 0x4a, 0x94, 0xd4}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf0, 0x5c, 0xbd, 0x6a, 0xb9, 0xe2, 0x8b, 0x7d}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x78, 0xac, 0xe0, 0x8e, 0x8f, 0xe2, 0xc4, 0x5a, 0x16, 0x30, - 0xe5, 0x6c, 0xda, 0xaf, 0x75, 0x60, 0xbe, 0xfa, 0x2e, 0x6d, - 0xe3, 0xde, 0xf0, 0x6, 0xff, 0x12, 0xd3, 0x57}; - lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc5, 0x55, 0x9a, 0xa6, 0xf3, 0xda, 0x3c, 0xd3, 0x5e, 0x66, 0xb0, 0xaa, 0x59, - 0x13, 0xa2, 0x3b, 0x39, 0x5e, 0x9f, 0xe8, 0xb5, 0xef, 0xa1, 0x44, 0xb3, 0x32}; - lwmqtt_string_t topic_filter_s8 = {26, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20478, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25296, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 17981 -// [("\236?\165\226{\194\173tM\GS\148\201\167\221O\ENQ#ktu89\141",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("B\203O\166\SI\168J\185|\254\215>\177\156",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0x3d, 0x4b, 0x4c, 0x0, 0xc, 0x3b, 0x27, 0x44, 0xe7, 0xa3, 0x74, 0x83, 0x86, 0x11, 0xac, - 0x1d, 0x4, 0x2, 0x0, 0x8, 0x47, 0xa7, 0x43, 0xf5, 0x8a, 0xdd, 0x76, 0xf, 0x1, 0x0, 0xc, - 0x1b, 0xfa, 0xba, 0x4a, 0x6d, 0xfa, 0xee, 0xb4, 0xc7, 0x77, 0x84, 0xa6, 0x1, 0x0, 0xf, 0x34, - 0x2b, 0xb8, 0x39, 0x33, 0xe1, 0x47, 0x59, 0xc1, 0x3a, 0xb8, 0x8f, 0x25, 0x9b, 0x1, 0x2}; - - uint8_t buf[73] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x3b, 0x27, 0x44, 0xe7, 0xa3, 0x74, 0x83, 0x86, 0x11, 0xac, 0x1d, 0x4}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x92, 0x1, 0x22, 0x9, 0x0, 0x7, 0xc, 0x64, 0xd1, 0xef, 0x17, 0xbf, 0x45, 0x2, 0x0, 0x3, + 0xb7, 0xf8, 0x43, 0x2, 0x0, 0x1, 0x35, 0x2, 0x0, 0x1d, 0x17, 0x7a, 0x2b, 0x14, 0x17, 0xf4, 0x1, + 0xcb, 0x95, 0x3c, 0xe0, 0x67, 0xf7, 0x5e, 0xf3, 0xbb, 0x33, 0x1e, 0x3c, 0xa2, 0xb2, 0x53, 0x5d, 0x7b, + 0x7b, 0x8f, 0xe2, 0x63, 0x5f, 0x1, 0x0, 0x10, 0xee, 0x14, 0xd4, 0xe0, 0x67, 0x2e, 0x8e, 0x71, 0x60, + 0x38, 0x50, 0x3c, 0xa4, 0xac, 0xe5, 0xf8, 0x1, 0x0, 0x16, 0x8f, 0x49, 0x62, 0x33, 0xd4, 0xee, 0xde, + 0xd9, 0x6b, 0xdf, 0x5c, 0xe, 0xe, 0x78, 0x6d, 0xdc, 0x7d, 0x73, 0x3b, 0x5e, 0xa2, 0xe2, 0x1, 0x0, + 0x1c, 0x82, 0x19, 0x0, 0x81, 0xea, 0x8f, 0xc9, 0x78, 0x67, 0x3e, 0xc2, 0xad, 0x74, 0x4d, 0x1d, 0x94, + 0xc9, 0xa7, 0xdd, 0x4f, 0x5, 0x23, 0x6b, 0x74, 0x75, 0x38, 0x39, 0x8d, 0x0, 0x0, 0xe, 0x42, 0xcb, + 0x4f, 0xa6, 0xf, 0xa8, 0x4a, 0xb9, 0x7c, 0xfe, 0xd7, 0x3e, 0xb1, 0x9c, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xc, 0x64, 0xd1, 0xef, 0x17, 0xbf, 0x45}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x47, 0xa7, 0x43, 0xf5, 0x8a, 0xdd, 0x76, 0xf}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb7, 0xf8, 0x43}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1b, 0xfa, 0xba, 0x4a, 0x6d, 0xfa, 0xee, 0xb4, 0xc7, 0x77, 0x84, 0xa6}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x35}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x34, 0x2b, 0xb8, 0x39, 0x33, 0xe1, 0x47, 0x59, - 0xc1, 0x3a, 0xb8, 0x8f, 0x25, 0x9b, 0x1}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x17, 0x7a, 0x2b, 0x14, 0x17, 0xf4, 0x1, 0xcb, 0x95, 0x3c, + 0xe0, 0x67, 0xf7, 0x5e, 0xf3, 0xbb, 0x33, 0x1e, 0x3c, 0xa2, + 0xb2, 0x53, 0x5d, 0x7b, 0x7b, 0x8f, 0xe2, 0x63, 0x5f}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t topic_filter_s4_bytes[] = {0xee, 0x14, 0xd4, 0xe0, 0x67, 0x2e, 0x8e, 0x71, + 0x60, 0x38, 0x50, 0x3c, 0xa4, 0xac, 0xe5, 0xf8}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8f, 0x49, 0x62, 0x33, 0xd4, 0xee, 0xde, 0xd9, 0x6b, 0xdf, 0x5c, + 0xe, 0xe, 0x78, 0x6d, 0xdc, 0x7d, 0x73, 0x3b, 0x5e, 0xa2, 0xe2}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x82, 0x19, 0x0, 0x81, 0xea, 0x8f, 0xc9, 0x78, 0x67, 0x3e, + 0xc2, 0xad, 0x74, 0x4d, 0x1d, 0x94, 0xc9, 0xa7, 0xdd, 0x4f, + 0x5, 0x23, 0x6b, 0x74, 0x75, 0x38, 0x39, 0x8d}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x42, 0xcb, 0x4f, 0xa6, 0xf, 0xa8, 0x4a, 0xb9, 0x7c, 0xfe, 0xd7, 0x3e, 0xb1, 0x9c}; + lwmqtt_string_t topic_filter_s7 = {14, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19276, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8713, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 2713 [("\v\149\153&\227@\158",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\137\178V\240lc\224\b\175']\235\NUL$\243G\224_*\254",SubOptions +// SubscribeRequest 22186 [("\SOs\230\200\227!\208>\aj\134P\159@\b\245\135B\251\254\225\t\197\222\144",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("9\210TgR\152e\221\141\200\213\141\198U\DC3V5\226\221\190M\169",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS1}),("3\163Q\180\141+\131\234M\208\187:\NULW\165\227R1\198\131\168\176\185z\149w",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\131\140\149\244p\253\129\DC2\DC1c#h\224qu\128\166\SICd\174\138\185",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\ESCp",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("9\209\165\252Ue\146\138\159\n%\SOW\252D\212",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x3c, 0xa, 0x99, 0x0, 0x7, 0xb, 0x95, 0x99, 0x26, 0xe3, 0x40, 0x9e, 0x2, 0x0, 0x14, - 0x89, 0xb2, 0x56, 0xf0, 0x6c, 0x63, 0xe0, 0x8, 0xaf, 0x27, 0x5d, 0xeb, 0x0, 0x24, 0xf3, 0x47, - 0xe0, 0x5f, 0x2a, 0xfe, 0x0, 0x0, 0x16, 0x39, 0xd2, 0x54, 0x67, 0x52, 0x98, 0x65, 0xdd, 0x8d, - 0xc8, 0xd5, 0x8d, 0xc6, 0x55, 0x13, 0x56, 0x35, 0xe2, 0xdd, 0xbe, 0x4d, 0xa9, 0x1}; - - uint8_t buf[72] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xb, 0x95, 0x99, 0x26, 0xe3, 0x40, 0x9e}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x6d, 0x56, 0xaa, 0x0, 0x19, 0xe, 0x73, 0xe6, 0xc8, 0xe3, 0x21, 0xd0, 0x3e, 0x7, 0x6a, + 0x86, 0x50, 0x9f, 0x40, 0x8, 0xf5, 0x87, 0x42, 0xfb, 0xfe, 0xe1, 0x9, 0xc5, 0xde, 0x90, 0x1, + 0x0, 0x1a, 0x33, 0xa3, 0x51, 0xb4, 0x8d, 0x2b, 0x83, 0xea, 0x4d, 0xd0, 0xbb, 0x3a, 0x0, 0x57, + 0xa5, 0xe3, 0x52, 0x31, 0xc6, 0x83, 0xa8, 0xb0, 0xb9, 0x7a, 0x95, 0x77, 0x2, 0x0, 0x17, 0x83, + 0x8c, 0x95, 0xf4, 0x70, 0xfd, 0x81, 0x12, 0x11, 0x63, 0x23, 0x68, 0xe0, 0x71, 0x75, 0x80, 0xa6, + 0xf, 0x43, 0x64, 0xae, 0x8a, 0xb9, 0x2, 0x0, 0x2, 0x1b, 0x70, 0x1, 0x0, 0x10, 0x39, 0xd1, + 0xa5, 0xfc, 0x55, 0x65, 0x92, 0x8a, 0x9f, 0xa, 0x25, 0xe, 0x57, 0xfc, 0x44, 0xd4, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xe, 0x73, 0xe6, 0xc8, 0xe3, 0x21, 0xd0, 0x3e, 0x7, 0x6a, 0x86, 0x50, 0x9f, + 0x40, 0x8, 0xf5, 0x87, 0x42, 0xfb, 0xfe, 0xe1, 0x9, 0xc5, 0xde, 0x90}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x89, 0xb2, 0x56, 0xf0, 0x6c, 0x63, 0xe0, 0x8, 0xaf, 0x27, - 0x5d, 0xeb, 0x0, 0x24, 0xf3, 0x47, 0xe0, 0x5f, 0x2a, 0xfe}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x33, 0xa3, 0x51, 0xb4, 0x8d, 0x2b, 0x83, 0xea, 0x4d, 0xd0, 0xbb, 0x3a, 0x0, + 0x57, 0xa5, 0xe3, 0x52, 0x31, 0xc6, 0x83, 0xa8, 0xb0, 0xb9, 0x7a, 0x95, 0x77}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x39, 0xd2, 0x54, 0x67, 0x52, 0x98, 0x65, 0xdd, 0x8d, 0xc8, 0xd5, - 0x8d, 0xc6, 0x55, 0x13, 0x56, 0x35, 0xe2, 0xdd, 0xbe, 0x4d, 0xa9}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x83, 0x8c, 0x95, 0xf4, 0x70, 0xfd, 0x81, 0x12, 0x11, 0x63, 0x23, 0x68, + 0xe0, 0x71, 0x75, 0x80, 0xa6, 0xf, 0x43, 0x64, 0xae, 0x8a, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t topic_filter_s3_bytes[] = {0x1b, 0x70}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x39, 0xd1, 0xa5, 0xfc, 0x55, 0x65, 0x92, 0x8a, + 0x9f, 0xa, 0x25, 0xe, 0x57, 0xfc, 0x44, 0xd4}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2713, 3, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22186, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7741 [("7\233y\244\229-\244\179\172\&6\164H",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(")\139\210\DC4\162\189qQ\DC4\141\253\&8",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 16934 [("\ENQ\US\231\182\242\224Rp\134\v\227Heh\CAN\168\243\231\181k7&{\n",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("W\201\226%\229\246\253\183\\\FS\242-\246I\DC4\DLE\188y\234\&5\240\DC1\189u\152\SO\240_",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\196\155\175",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("s\255c&\US\DLE@u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("I4\236\129I\\c\187\205\211J",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("6\246\129_\248\224\199\160MK\168\141hr\171",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\251\&0:\197\176N\128\&0\194\204\246\NAK\236i}|\154\223c\f\220",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("Or\209\133\140\155\171\243\164J\229\235\242\246\132k}\ENQ\138\188\215\185\150%xv)P\ACK",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\169\247\243Q\241\192)\133%\156\243\251\169\\\239\187E\234\163\194\141\&2\246*v\192\175\ETX\201",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0x20, 0x1e, 0x3d, 0x0, 0xc, 0x37, 0xe9, 0x79, 0xf4, 0xe5, 0x2d, 0xf4, 0xb3, 0xac, 0x36, 0xa4, - 0x48, 0x1, 0x0, 0xc, 0x29, 0x8b, 0xd2, 0x14, 0xa2, 0xbd, 0x71, 0x51, 0x14, 0x8d, 0xfd, 0x38, 0x1}; - - uint8_t buf[44] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x37, 0xe9, 0x79, 0xf4, 0xe5, 0x2d, 0xf4, 0xb3, 0xac, 0x36, 0xa4, 0x48}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0xc8, 0x1, 0x42, 0x26, 0x0, 0x18, 0x5, 0x1f, 0xe7, 0xb6, 0xf2, 0xe0, 0x52, 0x70, 0x86, 0xb, + 0xe3, 0x48, 0x65, 0x68, 0x18, 0xa8, 0xf3, 0xe7, 0xb5, 0x6b, 0x37, 0x26, 0x7b, 0xa, 0x0, 0x0, 0x1c, + 0x57, 0xc9, 0xe2, 0x25, 0xe5, 0xf6, 0xfd, 0xb7, 0x5c, 0x1c, 0xf2, 0x2d, 0xf6, 0x49, 0x14, 0x10, 0xbc, + 0x79, 0xea, 0x35, 0xf0, 0x11, 0xbd, 0x75, 0x98, 0xe, 0xf0, 0x5f, 0x1, 0x0, 0x3, 0xc4, 0x9b, 0xaf, + 0x2, 0x0, 0x0, 0x2, 0x0, 0x8, 0x73, 0xff, 0x63, 0x26, 0x1f, 0x10, 0x40, 0x75, 0x0, 0x0, 0xb, + 0x49, 0x34, 0xec, 0x81, 0x49, 0x5c, 0x63, 0xbb, 0xcd, 0xd3, 0x4a, 0x1, 0x0, 0xf, 0x36, 0xf6, 0x81, + 0x5f, 0xf8, 0xe0, 0xc7, 0xa0, 0x4d, 0x4b, 0xa8, 0x8d, 0x68, 0x72, 0xab, 0x0, 0x0, 0x15, 0xfb, 0x30, + 0x3a, 0xc5, 0xb0, 0x4e, 0x80, 0x30, 0xc2, 0xcc, 0xf6, 0x15, 0xec, 0x69, 0x7d, 0x7c, 0x9a, 0xdf, 0x63, + 0xc, 0xdc, 0x0, 0x0, 0x1d, 0x4f, 0x72, 0xd1, 0x85, 0x8c, 0x9b, 0xab, 0xf3, 0xa4, 0x4a, 0xe5, 0xeb, + 0xf2, 0xf6, 0x84, 0x6b, 0x7d, 0x5, 0x8a, 0xbc, 0xd7, 0xb9, 0x96, 0x25, 0x78, 0x76, 0x29, 0x50, 0x6, + 0x0, 0x0, 0x1d, 0xa9, 0xf7, 0xf3, 0x51, 0xf1, 0xc0, 0x29, 0x85, 0x25, 0x9c, 0xf3, 0xfb, 0xa9, 0x5c, + 0xef, 0xbb, 0x45, 0xea, 0xa3, 0xc2, 0x8d, 0x32, 0xf6, 0x2a, 0x76, 0xc0, 0xaf, 0x3, 0xc9, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x5, 0x1f, 0xe7, 0xb6, 0xf2, 0xe0, 0x52, 0x70, 0x86, 0xb, 0xe3, 0x48, + 0x65, 0x68, 0x18, 0xa8, 0xf3, 0xe7, 0xb5, 0x6b, 0x37, 0x26, 0x7b, 0xa}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x29, 0x8b, 0xd2, 0x14, 0xa2, 0xbd, 0x71, 0x51, 0x14, 0x8d, 0xfd, 0x38}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x57, 0xc9, 0xe2, 0x25, 0xe5, 0xf6, 0xfd, 0xb7, 0x5c, 0x1c, + 0xf2, 0x2d, 0xf6, 0x49, 0x14, 0x10, 0xbc, 0x79, 0xea, 0x35, + 0xf0, 0x11, 0xbd, 0x75, 0x98, 0xe, 0xf0, 0x5f}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t topic_filter_s2_bytes[] = {0xc4, 0x9b, 0xaf}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x73, 0xff, 0x63, 0x26, 0x1f, 0x10, 0x40, 0x75}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x49, 0x34, 0xec, 0x81, 0x49, 0x5c, 0x63, 0xbb, 0xcd, 0xd3, 0x4a}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x36, 0xf6, 0x81, 0x5f, 0xf8, 0xe0, 0xc7, 0xa0, + 0x4d, 0x4b, 0xa8, 0x8d, 0x68, 0x72, 0xab}; + lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xfb, 0x30, 0x3a, 0xc5, 0xb0, 0x4e, 0x80, 0x30, 0xc2, 0xcc, 0xf6, + 0x15, 0xec, 0x69, 0x7d, 0x7c, 0x9a, 0xdf, 0x63, 0xc, 0xdc}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x4f, 0x72, 0xd1, 0x85, 0x8c, 0x9b, 0xab, 0xf3, 0xa4, 0x4a, + 0xe5, 0xeb, 0xf2, 0xf6, 0x84, 0x6b, 0x7d, 0x5, 0x8a, 0xbc, + 0xd7, 0xb9, 0x96, 0x25, 0x78, 0x76, 0x29, 0x50, 0x6}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa9, 0xf7, 0xf3, 0x51, 0xf1, 0xc0, 0x29, 0x85, 0x25, 0x9c, + 0xf3, 0xfb, 0xa9, 0x5c, 0xef, 0xbb, 0x45, 0xea, 0xa3, 0xc2, + 0x8d, 0x32, 0xf6, 0x2a, 0x76, 0xc0, 0xaf, 0x3, 0xc9}; + lwmqtt_string_t topic_filter_s9 = {29, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, + LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7741, 2, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16934, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11149 -// [("^\226\251\181\&2\156|t\151S\169\252\146\ETX\GS\172S\169\EOT\142\201\173\164=\170a",SubOptions {_retainHandling = +// SubscribeRequest 19450 [("-\157He_V\165gmY\135\DC1\242\b\132\141\234\205\247",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("X+\208\242 +// 0\199d9\203\NAK)\182AKX:\187*\247|\177\229",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("-\200\196\v\SON\152\156\131\233\ESC\181(\174\ESC_\182(",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\245",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\"\DLE\152\151\134\RS\b7\133\240",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("\155\200\218O\139Q\137\183r>\FSZ()\163@C\240\153\197\175\164w\237\244\214",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\225W3k!\151\245\228>\205\198\132\168,\142",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),(":%\214!\232hqh\239\137?\SYN\253\231\130\239Ki",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\FS\245\145\RS\166*\SOH\163\232\246[\204\144\192O\181\160",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\236\214\206\181\DC2\167\181k\255c\150C&X`R\250\150\SI\184G\241x\151\196\143R\144\210w",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS1}),("\211\242#\201}dL\240\189\150\251\185\231~?\227\158\152z\251\SUB\DELS\174E",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("%\GS>\174RN3\188KZ\169\ETB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0x66, 0x2b, 0x8d, 0x0, 0x1a, 0x5e, 0xe2, 0xfb, 0xb5, 0x32, 0x9c, 0x7c, 0x74, 0x97, - 0x53, 0xa9, 0xfc, 0x92, 0x3, 0x1d, 0xac, 0x53, 0xa9, 0x4, 0x8e, 0xc9, 0xad, 0xa4, 0x3d, - 0xaa, 0x61, 0x1, 0x0, 0xf, 0xe1, 0x57, 0x33, 0x6b, 0x21, 0x97, 0xf5, 0xe4, 0x3e, 0xcd, - 0xc6, 0x84, 0xa8, 0x2c, 0x8e, 0x0, 0x0, 0x11, 0x1c, 0xf5, 0x91, 0x1e, 0xa6, 0x2a, 0x1, - 0xa3, 0xe8, 0xf6, 0x5b, 0xcc, 0x90, 0xc0, 0x4f, 0xb5, 0xa0, 0x0, 0x0, 0x1e, 0xec, 0xd6, - 0xce, 0xb5, 0x12, 0xa7, 0xb5, 0x6b, 0xff, 0x63, 0x96, 0x43, 0x26, 0x58, 0x60, 0x52, 0xfa, - 0x96, 0xf, 0xb8, 0x47, 0xf1, 0x78, 0x97, 0xc4, 0x8f, 0x52, 0x90, 0xd2, 0x77, 0x0}; - - uint8_t buf[114] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x5e, 0xe2, 0xfb, 0xb5, 0x32, 0x9c, 0x7c, 0x74, 0x97, 0x53, 0xa9, 0xfc, 0x92, - 0x3, 0x1d, 0xac, 0x53, 0xa9, 0x4, 0x8e, 0xc9, 0xad, 0xa4, 0x3d, 0xaa, 0x61}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x4b, 0xfa, 0x0, 0x13, 0x2d, 0x9d, 0x48, 0x65, 0x5f, 0x56, 0xa5, 0x67, 0x6d, 0x59, + 0x87, 0x11, 0xf2, 0x8, 0x84, 0x8d, 0xea, 0xcd, 0xf7, 0x0, 0x0, 0x17, 0x58, 0x2b, 0xd0, 0xf2, 0x20, + 0x30, 0xc7, 0x64, 0x39, 0xcb, 0x15, 0x29, 0xb6, 0x41, 0x4b, 0x58, 0x3a, 0xbb, 0x2a, 0xf7, 0x7c, 0xb1, + 0xe5, 0x2, 0x0, 0x12, 0x2d, 0xc8, 0xc4, 0xb, 0xe, 0x4e, 0x98, 0x9c, 0x83, 0xe9, 0x1b, 0xb5, 0x28, + 0xae, 0x1b, 0x5f, 0xb6, 0x28, 0x1, 0x0, 0x1, 0xf5, 0x1, 0x0, 0xa, 0x22, 0x10, 0x98, 0x97, 0x86, + 0x1e, 0x8, 0x37, 0x85, 0xf0, 0x0, 0x0, 0x1a, 0x9b, 0xc8, 0xda, 0x4f, 0x8b, 0x51, 0x89, 0xb7, 0x72, + 0x3e, 0x1c, 0x5a, 0x28, 0x29, 0xa3, 0x40, 0x43, 0xf0, 0x99, 0xc5, 0xaf, 0xa4, 0x77, 0xed, 0xf4, 0xd6, + 0x2, 0x0, 0x12, 0x3a, 0x25, 0xd6, 0x21, 0xe8, 0x68, 0x71, 0x68, 0xef, 0x89, 0x3f, 0x16, 0xfd, 0xe7, + 0x82, 0xef, 0x4b, 0x69, 0x1, 0x0, 0x19, 0xd3, 0xf2, 0x23, 0xc9, 0x7d, 0x64, 0x4c, 0xf0, 0xbd, 0x96, + 0xfb, 0xb9, 0xe7, 0x7e, 0x3f, 0xe3, 0x9e, 0x98, 0x7a, 0xfb, 0x1a, 0x7f, 0x53, 0xae, 0x45, 0x1, 0x0, + 0xc, 0x25, 0x1d, 0x3e, 0xae, 0x52, 0x4e, 0x33, 0xbc, 0x4b, 0x5a, 0xa9, 0x17, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x2d, 0x9d, 0x48, 0x65, 0x5f, 0x56, 0xa5, 0x67, 0x6d, 0x59, + 0x87, 0x11, 0xf2, 0x8, 0x84, 0x8d, 0xea, 0xcd, 0xf7}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe1, 0x57, 0x33, 0x6b, 0x21, 0x97, 0xf5, 0xe4, - 0x3e, 0xcd, 0xc6, 0x84, 0xa8, 0x2c, 0x8e}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x58, 0x2b, 0xd0, 0xf2, 0x20, 0x30, 0xc7, 0x64, 0x39, 0xcb, 0x15, 0x29, + 0xb6, 0x41, 0x4b, 0x58, 0x3a, 0xbb, 0x2a, 0xf7, 0x7c, 0xb1, 0xe5}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1c, 0xf5, 0x91, 0x1e, 0xa6, 0x2a, 0x1, 0xa3, 0xe8, - 0xf6, 0x5b, 0xcc, 0x90, 0xc0, 0x4f, 0xb5, 0xa0}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2d, 0xc8, 0xc4, 0xb, 0xe, 0x4e, 0x98, 0x9c, 0x83, + 0xe9, 0x1b, 0xb5, 0x28, 0xae, 0x1b, 0x5f, 0xb6, 0x28}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xec, 0xd6, 0xce, 0xb5, 0x12, 0xa7, 0xb5, 0x6b, 0xff, 0x63, - 0x96, 0x43, 0x26, 0x58, 0x60, 0x52, 0xfa, 0x96, 0xf, 0xb8, - 0x47, 0xf1, 0x78, 0x97, 0xc4, 0x8f, 0x52, 0x90, 0xd2, 0x77}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf5}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t topic_filter_s4_bytes[] = {0x22, 0x10, 0x98, 0x97, 0x86, 0x1e, 0x8, 0x37, 0x85, 0xf0}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x9b, 0xc8, 0xda, 0x4f, 0x8b, 0x51, 0x89, 0xb7, 0x72, 0x3e, 0x1c, 0x5a, 0x28, + 0x29, 0xa3, 0x40, 0x43, 0xf0, 0x99, 0xc5, 0xaf, 0xa4, 0x77, 0xed, 0xf4, 0xd6}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3a, 0x25, 0xd6, 0x21, 0xe8, 0x68, 0x71, 0x68, 0xef, + 0x89, 0x3f, 0x16, 0xfd, 0xe7, 0x82, 0xef, 0x4b, 0x69}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xd3, 0xf2, 0x23, 0xc9, 0x7d, 0x64, 0x4c, 0xf0, 0xbd, 0x96, 0xfb, 0xb9, 0xe7, + 0x7e, 0x3f, 0xe3, 0x9e, 0x98, 0x7a, 0xfb, 0x1a, 0x7f, 0x53, 0xae, 0x45}; + lwmqtt_string_t topic_filter_s7 = {25, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x25, 0x1d, 0x3e, 0xae, 0x52, 0x4e, 0x33, 0xbc, 0x4b, 0x5a, 0xa9, 0x17}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11149, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19450, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 2269 [("\DC2\238\205\167\203qt\199%Vl\129\160y\134\175U^\144K\SYN\ENQ\155+\GSdIr",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\208\157\230h\219\215$\215\133\STXrRf\214m\159\156\229\196\139\223EF>1\n'",SubOptions {_retainHandling = +// SubscribeRequest 18336 [("M\159.\194\192\a\198\148]\234\233",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\189\222HE\204\236\228\133\ACK*\236X\128\&0\229;n\245ORb\196",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("!\228\203\199\141\147\FS\178d6\b\237y\140c\213\DEL\141D \168\b\t\231C\"\STX",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\195S:\237\&8\249\f\223\SOH\EOTZ?\209RD1\128I\133\205\137\135c",SubOptions {_retainHandling = +// QoS0}),("\208N\231\188\204\CANY\CAN+",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("1\138\249\166\182\244n<\189\SI\a\192\&8W~\SI",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("Nt",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\182",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\252\&2\240JZ\198a\161y\244\135\130Ki\174\129\150\137H\142\184\151\167",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("%m\230\152\&3B\177\207",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\SO\US\NUL\133[",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\SO|\177\228\ETB\214C\165`\152*\SOM\180y9\233\&3`",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\160\&8\129\v\DC4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\\z\220\157\147\201\254\SUB\195\158\139\t\158\140\173\133\r\233\175q\212\152\175B\181d\FS",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS0}),("1\NUL\n1\166lT'\255\146\189^\227\207\&3W\174*\171\194",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("O",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("^\230>\180\243\221\ENQ\146K\SYN\153i:\167\222\r",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0xc5, 0x1, 0x8, 0xdd, 0x0, 0x1c, 0x12, 0xee, 0xcd, 0xa7, 0xcb, 0x71, 0x74, 0xc7, 0x25, 0x56, - 0x6c, 0x81, 0xa0, 0x79, 0x86, 0xaf, 0x55, 0x5e, 0x90, 0x4b, 0x16, 0x5, 0x9b, 0x2b, 0x1d, 0x64, 0x49, - 0x72, 0x2, 0x0, 0x1b, 0xd0, 0x9d, 0xe6, 0x68, 0xdb, 0xd7, 0x24, 0xd7, 0x85, 0x2, 0x72, 0x52, 0x66, - 0xd6, 0x6d, 0x9f, 0x9c, 0xe5, 0xc4, 0x8b, 0xdf, 0x45, 0x46, 0x3e, 0x31, 0xa, 0x27, 0x0, 0x0, 0x17, - 0xc3, 0x53, 0x3a, 0xed, 0x38, 0xf9, 0xc, 0xdf, 0x1, 0x4, 0x5a, 0x3f, 0xd1, 0x52, 0x44, 0x31, 0x80, - 0x49, 0x85, 0xcd, 0x89, 0x87, 0x63, 0x1, 0x0, 0x17, 0xfc, 0x32, 0xf0, 0x4a, 0x5a, 0xc6, 0x61, 0xa1, - 0x79, 0xf4, 0x87, 0x82, 0x4b, 0x69, 0xae, 0x81, 0x96, 0x89, 0x48, 0x8e, 0xb8, 0x97, 0xa7, 0x0, 0x0, - 0x8, 0x25, 0x6d, 0xe6, 0x98, 0x33, 0x42, 0xb1, 0xcf, 0x0, 0x0, 0x5, 0xe, 0x1f, 0x0, 0x85, 0x5b, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x13, 0xe, 0x7c, 0xb1, 0xe4, 0x17, 0xd6, 0x43, 0xa5, 0x60, 0x98, 0x2a, - 0xe, 0x4d, 0xb4, 0x79, 0x39, 0xe9, 0x33, 0x60, 0x2, 0x0, 0x5, 0xa0, 0x38, 0x81, 0xb, 0x14, 0x2, - 0x0, 0x1b, 0x5c, 0x7a, 0xdc, 0x9d, 0x93, 0xc9, 0xfe, 0x1a, 0xc3, 0x9e, 0x8b, 0x9, 0x9e, 0x8c, 0xad, - 0x85, 0xd, 0xe9, 0xaf, 0x71, 0xd4, 0x98, 0xaf, 0x42, 0xb5, 0x64, 0x1c, 0x0}; - - uint8_t buf[210] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x12, 0xee, 0xcd, 0xa7, 0xcb, 0x71, 0x74, 0xc7, 0x25, 0x56, - 0x6c, 0x81, 0xa0, 0x79, 0x86, 0xaf, 0x55, 0x5e, 0x90, 0x4b, - 0x16, 0x5, 0x9b, 0x2b, 0x1d, 0x64, 0x49, 0x72}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0xa0, 0x1, 0x47, 0xa0, 0x0, 0xb, 0x4d, 0x9f, 0x2e, 0xc2, 0xc0, 0x7, 0xc6, 0x94, 0x5d, 0xea, + 0xe9, 0x0, 0x0, 0x16, 0xbd, 0xde, 0x48, 0x45, 0xcc, 0xec, 0xe4, 0x85, 0x6, 0x2a, 0xec, 0x58, 0x80, + 0x30, 0xe5, 0x3b, 0x6e, 0xf5, 0x4f, 0x52, 0x62, 0xc4, 0x0, 0x0, 0x1b, 0x21, 0xe4, 0xcb, 0xc7, 0x8d, + 0x93, 0x1c, 0xb2, 0x64, 0x36, 0x8, 0xed, 0x79, 0x8c, 0x63, 0xd5, 0x7f, 0x8d, 0x44, 0x20, 0xa8, 0x8, + 0x9, 0xe7, 0x43, 0x22, 0x2, 0x0, 0x0, 0x9, 0xd0, 0x4e, 0xe7, 0xbc, 0xcc, 0x18, 0x59, 0x18, 0x2b, + 0x1, 0x0, 0x10, 0x31, 0x8a, 0xf9, 0xa6, 0xb6, 0xf4, 0x6e, 0x3c, 0xbd, 0xf, 0x7, 0xc0, 0x38, 0x57, + 0x7e, 0xf, 0x0, 0x0, 0x2, 0x4e, 0x74, 0x0, 0x0, 0x1, 0xb6, 0x0, 0x0, 0x14, 0x31, 0x0, 0xa, + 0x31, 0xa6, 0x6c, 0x54, 0x27, 0xff, 0x92, 0xbd, 0x5e, 0xe3, 0xcf, 0x33, 0x57, 0xae, 0x2a, 0xab, 0xc2, + 0x1, 0x0, 0x1, 0x4f, 0x0, 0x0, 0x0, 0x2, 0x0, 0x10, 0x5e, 0xe6, 0x3e, 0xb4, 0xf3, 0xdd, 0x5, + 0x92, 0x4b, 0x16, 0x99, 0x69, 0x3a, 0xa7, 0xde, 0xd, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x4d, 0x9f, 0x2e, 0xc2, 0xc0, 0x7, 0xc6, 0x94, 0x5d, 0xea, 0xe9}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd0, 0x9d, 0xe6, 0x68, 0xdb, 0xd7, 0x24, 0xd7, 0x85, 0x2, 0x72, 0x52, 0x66, 0xd6, - 0x6d, 0x9f, 0x9c, 0xe5, 0xc4, 0x8b, 0xdf, 0x45, 0x46, 0x3e, 0x31, 0xa, 0x27}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbd, 0xde, 0x48, 0x45, 0xcc, 0xec, 0xe4, 0x85, 0x6, 0x2a, 0xec, + 0x58, 0x80, 0x30, 0xe5, 0x3b, 0x6e, 0xf5, 0x4f, 0x52, 0x62, 0xc4}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc3, 0x53, 0x3a, 0xed, 0x38, 0xf9, 0xc, 0xdf, 0x1, 0x4, 0x5a, 0x3f, - 0xd1, 0x52, 0x44, 0x31, 0x80, 0x49, 0x85, 0xcd, 0x89, 0x87, 0x63}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x21, 0xe4, 0xcb, 0xc7, 0x8d, 0x93, 0x1c, 0xb2, 0x64, 0x36, 0x8, 0xed, 0x79, 0x8c, + 0x63, 0xd5, 0x7f, 0x8d, 0x44, 0x20, 0xa8, 0x8, 0x9, 0xe7, 0x43, 0x22, 0x2}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfc, 0x32, 0xf0, 0x4a, 0x5a, 0xc6, 0x61, 0xa1, 0x79, 0xf4, 0x87, 0x82, - 0x4b, 0x69, 0xae, 0x81, 0x96, 0x89, 0x48, 0x8e, 0xb8, 0x97, 0xa7}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd0, 0x4e, 0xe7, 0xbc, 0xcc, 0x18, 0x59, 0x18, 0x2b}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x25, 0x6d, 0xe6, 0x98, 0x33, 0x42, 0xb1, 0xcf}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x8a, 0xf9, 0xa6, 0xb6, 0xf4, 0x6e, 0x3c, + 0xbd, 0xf, 0x7, 0xc0, 0x38, 0x57, 0x7e, 0xf}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe, 0x1f, 0x0, 0x85, 0x5b}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x4e, 0x74}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb6}; + lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe, 0x7c, 0xb1, 0xe4, 0x17, 0xd6, 0x43, 0xa5, 0x60, 0x98, - 0x2a, 0xe, 0x4d, 0xb4, 0x79, 0x39, 0xe9, 0x33, 0x60}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x31, 0x0, 0xa, 0x31, 0xa6, 0x6c, 0x54, 0x27, 0xff, 0x92, + 0xbd, 0x5e, 0xe3, 0xcf, 0x33, 0x57, 0xae, 0x2a, 0xab, 0xc2}; + lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa0, 0x38, 0x81, 0xb, 0x14}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x4f}; + lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x5c, 0x7a, 0xdc, 0x9d, 0x93, 0xc9, 0xfe, 0x1a, 0xc3, 0x9e, 0x8b, 0x9, 0x9e, 0x8c, - 0xad, 0x85, 0xd, 0xe9, 0xaf, 0x71, 0xd4, 0x98, 0xaf, 0x42, 0xb5, 0x64, 0x1c}; - lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0}; + lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; + uint8_t topic_filter_s10_bytes[] = {0x5e, 0xe6, 0x3e, 0xb4, 0xf3, 0xdd, 0x5, 0x92, + 0x4b, 0x16, 0x99, 0x69, 0x3a, 0xa7, 0xde, 0xd}; + lwmqtt_string_t topic_filter_s10 = {16, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2269, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18336, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9248 [("\233\154\252\129\230\&9\142\177.,%\202H\EM",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("s\ETB\220\154j\DC1\149e\235\252\163\CANis@",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SOHz\161\174&\ESC;\181-\130",SubOptions +// SubscribeRequest 3357 [("\203$[\200\&9\130F\142\249\232\189\167\148L",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("<\n\188 +// \193>c\237\242\202\GSX\216\222e\204\149;\226",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("(.\204\183\ESC\178*",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("fld~\ACK9Z//1\205\SUB~\211l\241D\196`T",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\204l}DdML\130\250\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2})] [] +// QoS0}),("<\215\129\217-\248\223\vA\CAN$\203\213IH\227)\200\233[\174/\236\234\235\206\245\154\236\253",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0x3f, 0x24, 0x20, 0x0, 0xe, 0xe9, 0x9a, 0xfc, 0x81, 0xe6, 0x39, 0x8e, 0xb1, 0x2e, 0x2c, 0x25, - 0xca, 0x48, 0x19, 0x2, 0x0, 0xf, 0x73, 0x17, 0xdc, 0x9a, 0x6a, 0x11, 0x95, 0x65, 0xeb, 0xfc, 0xa3, - 0x18, 0x69, 0x73, 0x40, 0x0, 0x0, 0xa, 0x1, 0x7a, 0xa1, 0xae, 0x26, 0x1b, 0x3b, 0xb5, 0x2d, 0x82, - 0x1, 0x0, 0xa, 0xcc, 0x6c, 0x7d, 0x44, 0x64, 0x4d, 0x4c, 0x82, 0xfa, 0x2, 0x2}; - - uint8_t buf[75] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xe9, 0x9a, 0xfc, 0x81, 0xe6, 0x39, 0x8e, - 0xb1, 0x2e, 0x2c, 0x25, 0xca, 0x48, 0x19}; + uint8_t pkt[] = {0x82, 0x6b, 0xd, 0x1d, 0x0, 0xe, 0xcb, 0x24, 0x5b, 0xc8, 0x39, 0x82, 0x46, 0x8e, 0xf9, 0xe8, + 0xbd, 0xa7, 0x94, 0x4c, 0x1, 0x0, 0x13, 0x3c, 0xa, 0xbc, 0x20, 0xc1, 0x3e, 0x63, 0xed, 0xf2, + 0xca, 0x1d, 0x58, 0xd8, 0xde, 0x65, 0xcc, 0x95, 0x3b, 0xe2, 0x2, 0x0, 0x7, 0x28, 0x2e, 0xcc, + 0xb7, 0x1b, 0xb2, 0x2a, 0x2, 0x0, 0x14, 0x66, 0x6c, 0x64, 0x7e, 0x6, 0x39, 0x5a, 0x2f, 0x2f, + 0x31, 0xcd, 0x1a, 0x7e, 0xd3, 0x6c, 0xf1, 0x44, 0xc4, 0x60, 0x54, 0x0, 0x0, 0x1e, 0x3c, 0xd7, + 0x81, 0xd9, 0x2d, 0xf8, 0xdf, 0xb, 0x41, 0x18, 0x24, 0xcb, 0xd5, 0x49, 0x48, 0xe3, 0x29, 0xc8, + 0xe9, 0x5b, 0xae, 0x2f, 0xec, 0xea, 0xeb, 0xce, 0xf5, 0x9a, 0xec, 0xfd, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xcb, 0x24, 0x5b, 0xc8, 0x39, 0x82, 0x46, + 0x8e, 0xf9, 0xe8, 0xbd, 0xa7, 0x94, 0x4c}; lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x73, 0x17, 0xdc, 0x9a, 0x6a, 0x11, 0x95, 0x65, - 0xeb, 0xfc, 0xa3, 0x18, 0x69, 0x73, 0x40}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x3c, 0xa, 0xbc, 0x20, 0xc1, 0x3e, 0x63, 0xed, 0xf2, 0xca, + 0x1d, 0x58, 0xd8, 0xde, 0x65, 0xcc, 0x95, 0x3b, 0xe2}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1, 0x7a, 0xa1, 0xae, 0x26, 0x1b, 0x3b, 0xb5, 0x2d, 0x82}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x28, 0x2e, 0xcc, 0xb7, 0x1b, 0xb2, 0x2a}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xcc, 0x6c, 0x7d, 0x44, 0x64, 0x4d, 0x4c, 0x82, 0xfa, 0x2}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x66, 0x6c, 0x64, 0x7e, 0x6, 0x39, 0x5a, 0x2f, 0x2f, 0x31, + 0xcd, 0x1a, 0x7e, 0xd3, 0x6c, 0xf1, 0x44, 0xc4, 0x60, 0x54}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t topic_filter_s4_bytes[] = {0x3c, 0xd7, 0x81, 0xd9, 0x2d, 0xf8, 0xdf, 0xb, 0x41, 0x18, + 0x24, 0xcb, 0xd5, 0x49, 0x48, 0xe3, 0x29, 0xc8, 0xe9, 0x5b, + 0xae, 0x2f, 0xec, 0xea, 0xeb, 0xce, 0xf5, 0x9a, 0xec, 0xfd}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9248, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3357, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22320 [("U\\Dd9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = -// QoS2}),("w\225r\ETB\229\148t\144\141\ETB\DC3\141\216\DEL\SYN7r^\157\169\201\222\240{\CAN\162",SubOptions +// SubscribeRequest 18395 [("v2\217\195\171\136\254\128:i",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\249i9\228\SII\156\192\&7/.\187\203%",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\144%\189P}R&]F\140hw\FS\134Pm\201\240\130#\185",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("6\155R=&\211a\DC3v\192\rP~\175",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\228\161\STXal\230\192\ETB\213\134\a\178a4",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\223\209\242\169\SO\193\&9\248\172\170\181\153\222E!\208\167mA\140\206\170\\\189-A\155",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS2}),("\245\205\t;\164#p\ESC\CAN\168,\134\NUL{\RS\164\CAN^\223\149",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SUB",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0x7f, 0x57, 0x30, 0x0, 0x5, 0x55, 0x5c, 0x44, 0x64, 0x39, 0x2, 0x0, 0x1a, 0x77, 0xe1, 0x72, - 0x17, 0xe5, 0x94, 0x74, 0x90, 0x8d, 0x17, 0x13, 0x8d, 0xd8, 0x7f, 0x16, 0x37, 0x72, 0x5e, 0x9d, 0xa9, - 0xc9, 0xde, 0xf0, 0x7b, 0x18, 0xa2, 0x1, 0x0, 0x15, 0x90, 0x25, 0xbd, 0x50, 0x7d, 0x52, 0x26, 0x5d, - 0x46, 0x8c, 0x68, 0x77, 0x1c, 0x86, 0x50, 0x6d, 0xc9, 0xf0, 0x82, 0x23, 0xb9, 0x1, 0x0, 0xe, 0x36, - 0x9b, 0x52, 0x3d, 0x26, 0xd3, 0x61, 0x13, 0x76, 0xc0, 0xd, 0x50, 0x7e, 0xaf, 0x0, 0x0, 0xe, 0xe4, - 0xa1, 0x2, 0x61, 0x6c, 0xe6, 0xc0, 0x17, 0xd5, 0x86, 0x7, 0xb2, 0x61, 0x34, 0x1, 0x0, 0x1b, 0xdf, - 0xd1, 0xf2, 0xa9, 0xe, 0xc1, 0x39, 0xf8, 0xac, 0xaa, 0xb5, 0x99, 0xde, 0x45, 0x21, 0xd0, 0xa7, 0x6d, - 0x41, 0x8c, 0xce, 0xaa, 0x5c, 0xbd, 0x2d, 0x41, 0x9b, 0x2}; - - uint8_t buf[139] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x55, 0x5c, 0x44, 0x64, 0x39}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x3b, 0x47, 0xdb, 0x0, 0xa, 0x76, 0x32, 0xd9, 0xc3, 0xab, 0x88, 0xfe, 0x80, 0x3a, 0x69, + 0x1, 0x0, 0xe, 0xf9, 0x69, 0x39, 0xe4, 0xf, 0x49, 0x9c, 0xc0, 0x37, 0x2f, 0x2e, 0xbb, 0xcb, + 0x25, 0x2, 0x0, 0x14, 0xf5, 0xcd, 0x9, 0x3b, 0xa4, 0x23, 0x70, 0x1b, 0x18, 0xa8, 0x2c, 0x86, + 0x0, 0x7b, 0x1e, 0xa4, 0x18, 0x5e, 0xdf, 0x95, 0x0, 0x0, 0x1, 0x1a, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x76, 0x32, 0xd9, 0xc3, 0xab, 0x88, 0xfe, 0x80, 0x3a, 0x69}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x77, 0xe1, 0x72, 0x17, 0xe5, 0x94, 0x74, 0x90, 0x8d, 0x17, 0x13, 0x8d, 0xd8, - 0x7f, 0x16, 0x37, 0x72, 0x5e, 0x9d, 0xa9, 0xc9, 0xde, 0xf0, 0x7b, 0x18, 0xa2}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf9, 0x69, 0x39, 0xe4, 0xf, 0x49, 0x9c, 0xc0, 0x37, 0x2f, 0x2e, 0xbb, 0xcb, 0x25}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x90, 0x25, 0xbd, 0x50, 0x7d, 0x52, 0x26, 0x5d, 0x46, 0x8c, 0x68, - 0x77, 0x1c, 0x86, 0x50, 0x6d, 0xc9, 0xf0, 0x82, 0x23, 0xb9}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf5, 0xcd, 0x9, 0x3b, 0xa4, 0x23, 0x70, 0x1b, 0x18, 0xa8, + 0x2c, 0x86, 0x0, 0x7b, 0x1e, 0xa4, 0x18, 0x5e, 0xdf, 0x95}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x36, 0x9b, 0x52, 0x3d, 0x26, 0xd3, 0x61, 0x13, 0x76, 0xc0, 0xd, 0x50, 0x7e, 0xaf}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1a}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe4, 0xa1, 0x2, 0x61, 0x6c, 0xe6, 0xc0, 0x17, 0xd5, 0x86, 0x7, 0xb2, 0x61, 0x34}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xdf, 0xd1, 0xf2, 0xa9, 0xe, 0xc1, 0x39, 0xf8, 0xac, 0xaa, 0xb5, 0x99, 0xde, 0x45, - 0x21, 0xd0, 0xa7, 0x6d, 0x41, 0x8c, 0xce, 0xaa, 0x5c, 0xbd, 0x2d, 0x41, 0x9b}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22320, 6, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18395, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30493 [("\214C\211\153\&6\151\166\198\180w\131_\236",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\173\182\235`z\189",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\142J\163\SUB<\166\240y\176r\192",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS1}),("_\255]*t\ETB\162j\206\132\141\&3\169\148\170\217$H\SYN\255\187\131\233\244\159'\165\229M",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\CANY\SI2\187\199D\227G\253\202\CAN\208h\154h`\254\236\133/\200\173\163\158\208\238u>",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\237\ETB1\149\ETX\245\172\173\ETB\135\SOI",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS0}),("\245\157c\165h\181Ss\238\217\ESC\ENQ\206\225\171l\SUB\160A$\239\146pa\170\138",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\142\210",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropRetainAvailable 254,PropContentType "a$\140\162\133`\134\\G\US\DLE\191",PropWildcardSubscriptionAvailable -// 25,PropMaximumPacketSize 16917,PropRequestResponseInformation 230,PropAssignedClientIdentifier -// "0d\171\242]\161B\161\213\166W\202v\128\147\240}aGG\161A\253\181\182\156"] +// SubscribeRequest 6101 [(",\ENQ\132\182e\220\SYN%\233\253\238",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\RSH\179\141\155\183W\DC3\253\169v6\193;\187`c\217\218\234",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropMessageExpiryInterval 19065,PropTopicAlias +// 12758,PropMaximumQoS 101,PropWillDelayInterval 331,PropWillDelayInterval 6082] TEST(Subscribe5QCTest, Encode1) { - uint8_t pkt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, - 0xa5, 0x68, 0xb5, 0x53, 0x73, 0xee, 0xd9, 0x1b, 0x5, 0xce, 0xe1, 0xab, 0x6c, 0x1a, 0xa0, 0x41, 0x24, - 0xef, 0x92, 0x70, 0x61, 0xaa, 0x8a, 0x2, 0x0, 0x0, 0x0, 0x0, 0x2, 0x8e, 0xd2, 0x0}; - - uint8_t buf[229] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd6, 0x43, 0xd3, 0x99, 0x36, 0x97, 0xa6, 0xc6, 0xb4, 0x77, 0x83, 0x5f, 0xec}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x3c, 0x17, 0xd5, 0x14, 0x2, 0x0, 0x0, 0x4a, 0x79, 0x23, 0x31, 0xd6, 0x24, 0x65, 0x18, + 0x0, 0x0, 0x1, 0x4b, 0x18, 0x0, 0x0, 0x17, 0xc2, 0x0, 0xb, 0x2c, 0x5, 0x84, 0xb6, 0x65, + 0xdc, 0x16, 0x25, 0xe9, 0xfd, 0xee, 0x1, 0x0, 0x14, 0x1e, 0x48, 0xb3, 0x8d, 0x9b, 0xb7, 0x57, + 0x13, 0xfd, 0xa9, 0x76, 0x36, 0xc1, 0x3b, 0xbb, 0x60, 0x63, 0xd9, 0xda, 0xea, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x2c, 0x5, 0x84, 0xb6, 0x65, 0xdc, 0x16, 0x25, 0xe9, 0xfd, 0xee}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0x48, 0xb3, 0x8d, 0x9b, 0xb7, 0x57, 0x13, 0xfd, 0xa9, + 0x76, 0x36, 0xc1, 0x3b, 0xbb, 0x60, 0x63, 0xd9, 0xda, 0xea}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xad, 0xb6, 0xeb, 0x60, 0x7a, 0xbd}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8e, 0x4a, 0xa3, 0x1a, 0x3c, 0xa6, 0xf0, 0x79, 0xb0, 0x72, 0xc0}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5f, 0xff, 0x5d, 0x2a, 0x74, 0x17, 0xa2, 0x6a, 0xce, 0x84, - 0x8d, 0x33, 0xa9, 0x94, 0xaa, 0xd9, 0x24, 0x48, 0x16, 0xff, - 0xbb, 0x83, 0xe9, 0xf4, 0x9f, 0x27, 0xa5, 0xe5, 0x4d}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x18, 0x59, 0xf, 0x32, 0xbb, 0xc7, 0x44, 0xe3, 0x47, 0xfd, - 0xca, 0x18, 0xd0, 0x68, 0x9a, 0x68, 0x60, 0xfe, 0xec, 0x85, - 0x2f, 0xc8, 0xad, 0xa3, 0x9e, 0xd0, 0xee, 0x75, 0x3e}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xed, 0x17, 0x31, 0x95, 0x3, 0xf5, 0xac, 0xad, 0x17, 0x87, 0xe, 0x49}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf5, 0x9d, 0x63, 0xa5, 0x68, 0xb5, 0x53, 0x73, 0xee, 0xd9, 0x1b, 0x5, 0xce, - 0xe1, 0xab, 0x6c, 0x1a, 0xa0, 0x41, 0x24, 0xef, 0x92, 0x70, 0x61, 0xaa, 0x8a}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0}; - lwmqtt_string_t topic_filter_s8 = {0, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x8e, 0xd2}; - lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x61, 0x24, 0x8c, 0xa2, 0x85, 0x60, 0x86, 0x5c, 0x47, 0x1f, 0x10, 0xbf}; - uint8_t bytesprops1[] = {0x30, 0x64, 0xab, 0xf2, 0x5d, 0xa1, 0x42, 0xa1, 0xd5, 0xa6, 0x57, 0xca, 0x76, - 0x80, 0x93, 0xf0, 0x7d, 0x61, 0x47, 0x47, 0xa1, 0x41, 0xfd, 0xb5, 0xb6, 0x9c}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16917}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19065}}, {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12758}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 101}}, {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 331}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6082}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30493, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6101, 2, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20478 [("\184}2\DC2\bp#\148\f\DC1\208}\194",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\181\209\150\255\240\&5\243\DC2\SO\208ji\180\129&P\178\ENQ?\229W?\192\GS\185\211\166\213\&4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\248\196L\195\ESC\ETX\DC3N\135\&3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\198\170\141\229\221[\227KN\143Fw\153\t\163\203\n\181\151\147\170",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\160\253\207yPZ\a\211\172o\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\164s\134^.\223\218\240\197J\148\212",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\240\\\189j\185\226\139}",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("x\172\224\142\143\226\196Z\SYN0\229l\218\175u`\190\250.m\227\222\240\ACK\255\DC2\211W",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\197U\154\166\243\218<\211^f\176\170Y\DC3\162;9^\159\232\181\239\161D\179\&2",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropReasonString -// "3\GS\220\243\DC3\147\SI\142r\SUBo\198\137\235\137t\217\223n\190m",PropTopicAlias 15148] +// SubscribeRequest 25296 [("\DC1\170f\212\242sLZ\148\SIg)\208\ACK\128U\161\186\NUL)\214\158",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropMaximumPacketSize 28140,PropSharedSubscriptionAvailable 62,PropAuthenticationMethod +// "\234\191Q\135\223\255\&4\216^",PropMessageExpiryInterval 588,PropResponseTopic +// "U\ETX\ACK\231\140\239\243\SYN\253\134\RS\136j",PropReceiveMaximum 21402,PropSubscriptionIdentifier +// 8,PropSharedSubscriptionAvailable 83,PropMaximumPacketSize 23375,PropTopicAliasMaximum +// 28613,PropRequestProblemInformation 212,PropTopicAlias 6168,PropAuthenticationMethod +// "#\147\231\SYNFp\218\170h\EM\137\192\241\176V\148N\255z\DC2)",PropWildcardSubscriptionAvailable +// 114,PropServerReference "",PropContentType "\139\237\217J\ne\152C\254\170\236\141\174\&1@\147\&8",PropMaximumQoS +// 64,PropMessageExpiryInterval 3635,PropMessageExpiryInterval 29474,PropRequestProblemInformation +// 130,PropSubscriptionIdentifier 18,PropMessageExpiryInterval 7025,PropTopicAlias 17854,PropMaximumPacketSize +// 13771,PropWildcardSubscriptionAvailable 166,PropWildcardSubscriptionAvailable 26,PropSubscriptionIdentifierAvailable +// 63,PropCorrelationData "\214\238\129dj\201_\a1\172\157\157\141'\201h\171\147!\162\&8\EM",PropSubscriptionIdentifier +// 0] TEST(Subscribe5QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0xd7, 0x1, 0x4f, 0xfe, 0x1b, 0x1f, 0x0, 0x15, 0x33, 0x1d, 0xdc, 0xf3, 0x13, 0x93, 0xf, 0x8e, - 0x72, 0x1a, 0x6f, 0xc6, 0x89, 0xeb, 0x89, 0x74, 0xd9, 0xdf, 0x6e, 0xbe, 0x6d, 0x23, 0x3b, 0x2c, 0x0, - 0xd, 0xb8, 0x7d, 0x32, 0x12, 0x8, 0x70, 0x23, 0x94, 0xc, 0x11, 0xd0, 0x7d, 0xc2, 0x1, 0x0, 0x1d, - 0xb5, 0xd1, 0x96, 0xff, 0xf0, 0x35, 0xf3, 0x12, 0xe, 0xd0, 0x6a, 0x69, 0xb4, 0x81, 0x26, 0x50, 0xb2, - 0x5, 0x3f, 0xe5, 0x57, 0x3f, 0xc0, 0x1d, 0xb9, 0xd3, 0xa6, 0xd5, 0x34, 0x2, 0x0, 0xa, 0xf8, 0xc4, - 0x4c, 0xc3, 0x1b, 0x3, 0x13, 0x4e, 0x87, 0x33, 0x0, 0x0, 0x15, 0xc6, 0xaa, 0x8d, 0xe5, 0xdd, 0x5b, - 0xe3, 0x4b, 0x4e, 0x8f, 0x46, 0x77, 0x99, 0x9, 0xa3, 0xcb, 0xa, 0xb5, 0x97, 0x93, 0xaa, 0x1, 0x0, - 0xb, 0xa0, 0xfd, 0xcf, 0x79, 0x50, 0x5a, 0x7, 0xd3, 0xac, 0x6f, 0x94, 0x0, 0x0, 0xc, 0xa4, 0x73, - 0x86, 0x5e, 0x2e, 0xdf, 0xda, 0xf0, 0xc5, 0x4a, 0x94, 0xd4, 0x2, 0x0, 0x8, 0xf0, 0x5c, 0xbd, 0x6a, - 0xb9, 0xe2, 0x8b, 0x7d, 0x2, 0x0, 0x1c, 0x78, 0xac, 0xe0, 0x8e, 0x8f, 0xe2, 0xc4, 0x5a, 0x16, 0x30, - 0xe5, 0x6c, 0xda, 0xaf, 0x75, 0x60, 0xbe, 0xfa, 0x2e, 0x6d, 0xe3, 0xde, 0xf0, 0x6, 0xff, 0x12, 0xd3, - 0x57, 0x0, 0x0, 0x1a, 0xc5, 0x55, 0x9a, 0xa6, 0xf3, 0xda, 0x3c, 0xd3, 0x5e, 0x66, 0xb0, 0xaa, 0x59, - 0x13, 0xa2, 0x3b, 0x39, 0x5e, 0x9f, 0xe8, 0xb5, 0xef, 0xa1, 0x44, 0xb3, 0x32, 0x2}; - - uint8_t buf[228] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xb8, 0x7d, 0x32, 0x12, 0x8, 0x70, 0x23, 0x94, 0xc, 0x11, 0xd0, 0x7d, 0xc2}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0xc8, 0x1, 0x62, 0xd0, 0xab, 0x1, 0x27, 0x0, 0x0, 0x6d, 0xec, 0x2a, 0x3e, 0x15, 0x0, 0x9, + 0xea, 0xbf, 0x51, 0x87, 0xdf, 0xff, 0x34, 0xd8, 0x5e, 0x2, 0x0, 0x0, 0x2, 0x4c, 0x8, 0x0, 0xd, + 0x55, 0x3, 0x6, 0xe7, 0x8c, 0xef, 0xf3, 0x16, 0xfd, 0x86, 0x1e, 0x88, 0x6a, 0x21, 0x53, 0x9a, 0xb, + 0x8, 0x2a, 0x53, 0x27, 0x0, 0x0, 0x5b, 0x4f, 0x22, 0x6f, 0xc5, 0x17, 0xd4, 0x23, 0x18, 0x18, 0x15, + 0x0, 0x15, 0x23, 0x93, 0xe7, 0x16, 0x46, 0x70, 0xda, 0xaa, 0x68, 0x19, 0x89, 0xc0, 0xf1, 0xb0, 0x56, + 0x94, 0x4e, 0xff, 0x7a, 0x12, 0x29, 0x28, 0x72, 0x1c, 0x0, 0x0, 0x3, 0x0, 0x11, 0x8b, 0xed, 0xd9, + 0x4a, 0xa, 0x65, 0x98, 0x43, 0xfe, 0xaa, 0xec, 0x8d, 0xae, 0x31, 0x40, 0x93, 0x38, 0x24, 0x40, 0x2, + 0x0, 0x0, 0xe, 0x33, 0x2, 0x0, 0x0, 0x73, 0x22, 0x17, 0x82, 0xb, 0x12, 0x2, 0x0, 0x0, 0x1b, + 0x71, 0x23, 0x45, 0xbe, 0x27, 0x0, 0x0, 0x35, 0xcb, 0x28, 0xa6, 0x28, 0x1a, 0x29, 0x3f, 0x9, 0x0, + 0x16, 0xd6, 0xee, 0x81, 0x64, 0x6a, 0xc9, 0x5f, 0x7, 0x31, 0xac, 0x9d, 0x9d, 0x8d, 0x27, 0xc9, 0x68, + 0xab, 0x93, 0x21, 0xa2, 0x38, 0x19, 0xb, 0x0, 0x0, 0x16, 0x11, 0xaa, 0x66, 0xd4, 0xf2, 0x73, 0x4c, + 0x5a, 0x94, 0xf, 0x67, 0x29, 0xd0, 0x6, 0x80, 0x55, 0xa1, 0xba, 0x0, 0x29, 0xd6, 0x9e, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x11, 0xaa, 0x66, 0xd4, 0xf2, 0x73, 0x4c, 0x5a, 0x94, 0xf, 0x67, + 0x29, 0xd0, 0x6, 0x80, 0x55, 0xa1, 0xba, 0x0, 0x29, 0xd6, 0x9e}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb5, 0xd1, 0x96, 0xff, 0xf0, 0x35, 0xf3, 0x12, 0xe, 0xd0, - 0x6a, 0x69, 0xb4, 0x81, 0x26, 0x50, 0xb2, 0x5, 0x3f, 0xe5, - 0x57, 0x3f, 0xc0, 0x1d, 0xb9, 0xd3, 0xa6, 0xd5, 0x34}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf8, 0xc4, 0x4c, 0xc3, 0x1b, 0x3, 0x13, 0x4e, 0x87, 0x33}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc6, 0xaa, 0x8d, 0xe5, 0xdd, 0x5b, 0xe3, 0x4b, 0x4e, 0x8f, 0x46, - 0x77, 0x99, 0x9, 0xa3, 0xcb, 0xa, 0xb5, 0x97, 0x93, 0xaa}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa0, 0xfd, 0xcf, 0x79, 0x50, 0x5a, 0x7, 0xd3, 0xac, 0x6f, 0x94}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa4, 0x73, 0x86, 0x5e, 0x2e, 0xdf, 0xda, 0xf0, 0xc5, 0x4a, 0x94, 0xd4}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf0, 0x5c, 0xbd, 0x6a, 0xb9, 0xe2, 0x8b, 0x7d}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x78, 0xac, 0xe0, 0x8e, 0x8f, 0xe2, 0xc4, 0x5a, 0x16, 0x30, - 0xe5, 0x6c, 0xda, 0xaf, 0x75, 0x60, 0xbe, 0xfa, 0x2e, 0x6d, - 0xe3, 0xde, 0xf0, 0x6, 0xff, 0x12, 0xd3, 0x57}; - lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc5, 0x55, 0x9a, 0xa6, 0xf3, 0xda, 0x3c, 0xd3, 0x5e, 0x66, 0xb0, 0xaa, 0x59, - 0x13, 0xa2, 0x3b, 0x39, 0x5e, 0x9f, 0xe8, 0xb5, 0xef, 0xa1, 0x44, 0xb3, 0x32}; - lwmqtt_string_t topic_filter_s8 = {26, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x33, 0x1d, 0xdc, 0xf3, 0x13, 0x93, 0xf, 0x8e, 0x72, 0x1a, 0x6f, - 0xc6, 0x89, 0xeb, 0x89, 0x74, 0xd9, 0xdf, 0x6e, 0xbe, 0x6d}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0xea, 0xbf, 0x51, 0x87, 0xdf, 0xff, 0x34, 0xd8, 0x5e}; + uint8_t bytesprops1[] = {0x55, 0x3, 0x6, 0xe7, 0x8c, 0xef, 0xf3, 0x16, 0xfd, 0x86, 0x1e, 0x88, 0x6a}; + uint8_t bytesprops2[] = {0x23, 0x93, 0xe7, 0x16, 0x46, 0x70, 0xda, 0xaa, 0x68, 0x19, 0x89, + 0xc0, 0xf1, 0xb0, 0x56, 0x94, 0x4e, 0xff, 0x7a, 0x12, 0x29}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x8b, 0xed, 0xd9, 0x4a, 0xa, 0x65, 0x98, 0x43, 0xfe, + 0xaa, 0xec, 0x8d, 0xae, 0x31, 0x40, 0x93, 0x38}; + uint8_t bytesprops5[] = {0xd6, 0xee, 0x81, 0x64, 0x6a, 0xc9, 0x5f, 0x7, 0x31, 0xac, 0x9d, + 0x9d, 0x8d, 0x27, 0xc9, 0x68, 0xab, 0x93, 0x21, 0xa2, 0x38, 0x19}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15148}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28140}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 588}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21402}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23375}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28613}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6168}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3635}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29474}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7025}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17854}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13771}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20478, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25296, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 17981 -// [("\236?\165\226{!\241\176\148uM",PropMaximumQoS 1,PropTopicAlias -// 9863,PropResponseTopic "\249O\221\134\STX*\131\148\136\ETB\220\238\213a'\174!\SUB.p",PropServerReference -// "\251){E?}\238y\USJ\132\193D\r\186\173p\174\r\244b\144",PropAssignedClientIdentifier -// "vD\148\RS`\189\228\247]%\236,\186W\NAK\203\198\250mx\172\230H\137\252T\222"] +// QoS0}),("yS\"\212\211\222\&7\144*K\137\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [PropCorrelationData " Ga\182 +// 7\156\&9\204\155\202d\148\&4\212a\206\255|\150\178\176\208b",PropAuthenticationData +// "\137\223P\139\214f\177\194\174\189\187\173\ETB",PropRequestResponseInformation 187,PropContentType +// "\144\192\&7b3\148\218\b\163!\235\130V\214\133f}S\GS\"\224\136\165\245\ESC;\147",PropServerReference +// "",PropAuthenticationData "~\EOT,\220D\184M\236\240\GS\231\213\202\&4a",PropSharedSubscriptionAvailable +// 178,PropReasonString "\255\201k \150\DC4\140\246k#^\157w\219\130\169\186\137",PropRetainAvailable 80,PropTopicAlias +// 4645,PropContentType "\212@\230+j\173ke",PropAuthenticationMethod +// "\248J\CAN\148\&0\180\208\181'\224,",PropMessageExpiryInterval 26316,PropPayloadFormatIndicator +// 218,PropRequestProblemInformation 99,PropMaximumPacketSize 5815,PropWildcardSubscriptionAvailable +// 167,PropAuthenticationMethod "\RSc\229\154",PropResponseInformation "b \147",PropPayloadFormatIndicator +// 236,PropAssignedClientIdentifier "*\233\189\219\157R",PropCorrelationData +// "\201;\128\&2:\162\r\SYNI\229\240\167\212i>B\155\&41\222\234\158EJX\187\188\236k\176",PropAuthenticationMethod +// "\173\145\DC3\NUL\RS\NAKn$\164]",PropTopicAliasMaximum 18831,PropReceiveMaximum 20663,PropServerReference +// "3w\150\205\244\251]\161\142\230\DC3\205\132\178\129\193uQ}^\199C[\"9\128\137v",PropReasonString +// "7C\227\DLE^;\211\r\245~\217ou\217\224vk",PropCorrelationData +// "h\211&C1\197IM\DC1N\187\240\135_\204\219\202\157\244\EM\138\176B\224B\150",PropAuthenticationData +// "\213\&6\250\ENQ\t\139\235\189\168K\178\222\205\144$\213\ENQ\169\206\185\188",PropWillDelayInterval 26355] TEST(Subscribe5QCTest, Encode3) { uint8_t pkt[] = { - 0x82, 0xe6, 0x2, 0x46, 0x3d, 0x94, 0x1, 0x17, 0x62, 0x25, 0x89, 0x2, 0x0, 0x0, 0x28, 0x56, 0x1f, 0x0, 0x1, - 0xc5, 0x26, 0x0, 0x2, 0xc7, 0xab, 0x0, 0xd, 0x66, 0x4e, 0x40, 0x32, 0xd2, 0x37, 0x58, 0x5f, 0x84, 0x5d, 0xbf, - 0xbd, 0x65, 0x26, 0x0, 0x5, 0x90, 0xfc, 0x6, 0xfd, 0xc0, 0x0, 0x16, 0x92, 0xfb, 0xe3, 0xf0, 0x30, 0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x82, 0xdd, 0xe5, 0xe4, 0x41, 0x1, - 0x0, 0x8, 0xb7, 0xeb, 0x84, 0x34, 0x2b, 0x5a, 0xf1, 0xf7, 0x2, 0x0, 0xe, 0xaf, 0x2d, 0x84, 0x4e, 0xe2, 0xb3, - 0xc7, 0x4d, 0x6b, 0x1e, 0x77, 0x6b, 0xbc, 0x94, 0x2, 0x0, 0xe, 0x13, 0xe5, 0x74, 0x5a, 0x77, 0xc6, 0x33, 0x21, - 0x64, 0x2b, 0xc6, 0x55, 0x85, 0xa2, 0x2, 0x0, 0xf, 0x1f, 0x33, 0x1f, 0xeb, 0xbc, 0xab, 0xe1, 0x9b, 0xd6, 0x9b, - 0xe8, 0x8d, 0x71, 0x88, 0x7e, 0x0, 0x0, 0x14, 0x19, 0x5b, 0xbc, 0x9f, 0xf4, 0x78, 0xde, 0xaa, 0x15, 0x23, 0x10, - 0x64, 0x6c, 0x3a, 0xda, 0xfd, 0x8b, 0xc4, 0x1d, 0xa8, 0x2, 0x0, 0x8, 0xf, 0x69, 0x61, 0xff, 0x89, 0x3d, 0xeb, - 0xc, 0x2, 0x0, 0xe, 0xf, 0x27, 0xef, 0xd6, 0xb7, 0xaf, 0xa, 0xf4, 0x50, 0x5, 0x7f, 0x91, 0x3, 0xb4, 0x2}; - - uint8_t buf[371] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xec, 0x3f, 0xa5, 0xe2, 0x7b, 0x3c, 0x79, 0x25, 0xdf, 0x2e, - 0x1d, 0x34, 0x67, 0x96, 0xc7, 0x31, 0x94, 0xf1, 0x10, 0x52, - 0x8a, 0x9e, 0xd0, 0x85, 0xf6, 0xc, 0x38, 0xf2, 0x1f, 0xe8}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + 0x82, 0x9c, 0x3, 0x6d, 0x84, 0xde, 0x2, 0x9, 0x0, 0x18, 0x20, 0x47, 0x61, 0xb6, 0x20, 0x37, 0x9c, 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, 0xc1, 0x1, 0x0, 0x5, 0x16, 0xf2, 0xf3, 0x9f, 0x1e, + 0x0, 0x0, 0xc, 0x79, 0x53, 0x22, 0xd4, 0xd3, 0xde, 0x37, 0x90, 0x2a, 0x4b, 0x89, 0xe1, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x50, 0x76, 0x88, 0x81, 0xea, 0xbc, 0xc5, 0x24}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa9, 0x89, 0xf8, 0x9c, 0x98, 0x1a, 0x26, 0x7, 0x84, 0x23, - 0x96, 0x8f, 0xf5, 0x60, 0x7b, 0xa9, 0x21, 0x61, 0xca, 0xa6, - 0x4f, 0x21, 0xd, 0x6e, 0x5c, 0xd5, 0xc3, 0x2d, 0x41, 0x55}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x84, 0x31, 0x2f, 0x9f, 0xb9, 0x37}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5b, 0x7, 0xe5, 0xce, 0xdf, 0x13, 0x5c, 0x83, 0x33, 0xc1, 0x27, 0x18, - 0xf0, 0x95, 0x1d, 0x8d, 0x49, 0x2b, 0x82, 0xdd, 0xe5, 0xe4, 0x41}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa1, 0xf8, 0xe9, 0xe7, 0xf3, 0x94, 0xee, 0xc1, 0x15, 0x1d, 0x78, 0xc1}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb7, 0xeb, 0x84, 0x34, 0x2b, 0x5a, 0xf1, 0xf7}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x16, 0xf2, 0xf3, 0x9f, 0x1e}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xaf, 0x2d, 0x84, 0x4e, 0xe2, 0xb3, 0xc7, - 0x4d, 0x6b, 0x1e, 0x77, 0x6b, 0xbc, 0x94}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x79, 0x53, 0x22, 0xd4, 0xd3, 0xde, 0x37, 0x90, 0x2a, 0x4b, 0x89, 0xe1}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x13, 0xe5, 0x74, 0x5a, 0x77, 0xc6, 0x33, - 0x21, 0x64, 0x2b, 0xc6, 0x55, 0x85, 0xa2}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x1f, 0x33, 0x1f, 0xeb, 0xbc, 0xab, 0xe1, 0x9b, - 0xd6, 0x9b, 0xe8, 0x8d, 0x71, 0x88, 0x7e}; - lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x19, 0x5b, 0xbc, 0x9f, 0xf4, 0x78, 0xde, 0xaa, 0x15, 0x23, - 0x10, 0x64, 0x6c, 0x3a, 0xda, 0xfd, 0x8b, 0xc4, 0x1d, 0xa8}; - lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xf, 0x69, 0x61, 0xff, 0x89, 0x3d, 0xeb, 0xc}; - lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xf, 0x27, 0xef, 0xd6, 0xb7, 0xaf, 0xa, 0xf4, 0x50, 0x5, 0x7f, 0x91, 0x3, 0xb4}; - lwmqtt_string_t topic_filter_s9 = {14, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0xc5}; - uint8_t bytesprops2[] = {0x66, 0x4e, 0x40, 0x32, 0xd2, 0x37, 0x58, 0x5f, 0x84, 0x5d, 0xbf, 0xbd, 0x65}; - uint8_t bytesprops1[] = {0xc7, 0xab}; - uint8_t bytesprops4[] = {0x92, 0xfb, 0xe3, 0xf0, 0x30, 0xb0, 0x33, 0x4d, 0xb5, 0xe9, 0x6e, - 0xf6, 0x76, 0x89, 0x9c, 0x3e, 0x21, 0xf1, 0xb0, 0x94, 0x75, 0x4d}; - uint8_t bytesprops3[] = {0x90, 0xfc, 0x6, 0xfd, 0xc0}; - uint8_t bytesprops5[] = {0xf9, 0x4f, 0xdd, 0x86, 0x2, 0x2a, 0x83, 0x94, 0x88, 0x17, - 0xdc, 0xee, 0xd5, 0x61, 0x27, 0xae, 0x21, 0x1a, 0x2e, 0x70}; - uint8_t bytesprops6[] = {0xfb, 0x29, 0x7b, 0x45, 0x3f, 0x7d, 0xee, 0x79, 0x1f, 0x4a, 0x84, - 0xc1, 0x44, 0xd, 0xba, 0xad, 0x70, 0xae, 0xd, 0xf4, 0x62, 0x90}; - uint8_t bytesprops7[] = {0x76, 0x44, 0x94, 0x1e, 0x60, 0xbd, 0xe4, 0xf7, 0x5d, 0x25, 0xec, 0x2c, 0xba, 0x57, - 0x15, 0xcb, 0xc6, 0xfa, 0x6d, 0x78, 0xac, 0xe6, 0x48, 0x89, 0xfc, 0x54, 0xde}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x20, 0x47, 0x61, 0xb6, 0x20, 0x37, 0x9c, 0x39, 0xcc, 0x9b, 0xca, 0x64, + 0x94, 0x34, 0xd4, 0x61, 0xce, 0xff, 0x7c, 0x96, 0xb2, 0xb0, 0xd0, 0x62}; + uint8_t bytesprops1[] = {0x89, 0xdf, 0x50, 0x8b, 0xd6, 0x66, 0xb1, 0xc2, 0xae, 0xbd, 0xbb, 0xad, 0x17}; + uint8_t bytesprops2[] = {0x90, 0xc0, 0x37, 0x62, 0x33, 0x94, 0xda, 0x8, 0xa3, 0x21, 0xeb, 0x82, 0x56, 0xd6, + 0x85, 0x66, 0x7d, 0x53, 0x1d, 0x22, 0xe0, 0x88, 0xa5, 0xf5, 0x1b, 0x3b, 0x93}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x7e, 0x4, 0x2c, 0xdc, 0x44, 0xb8, 0x4d, 0xec, 0xf0, 0x1d, 0xe7, 0xd5, 0xca, 0x34, 0x61}; + uint8_t bytesprops5[] = {0xff, 0xc9, 0x6b, 0x20, 0x96, 0x14, 0x8c, 0xf6, 0x6b, + 0x23, 0x5e, 0x9d, 0x77, 0xdb, 0x82, 0xa9, 0xba, 0x89}; + uint8_t bytesprops6[] = {0xd4, 0x40, 0xe6, 0x2b, 0x6a, 0xad, 0x6b, 0x65}; + uint8_t bytesprops7[] = {0xf8, 0x4a, 0x18, 0x94, 0x30, 0xb4, 0xd0, 0xb5, 0x27, 0xe0, 0x2c}; + uint8_t bytesprops8[] = {0x1e, 0x63, 0xe5, 0x9a}; + uint8_t bytesprops9[] = {0x62, 0x20, 0x93}; + uint8_t bytesprops10[] = {0x2a, 0xe9, 0xbd, 0xdb, 0x9d, 0x52}; + uint8_t bytesprops11[] = {0xc9, 0x3b, 0x80, 0x32, 0x3a, 0xa2, 0xd, 0x16, 0x49, 0xe5, 0xf0, 0xa7, 0xd4, 0x69, 0x3e, + 0x42, 0x9b, 0x34, 0x31, 0xde, 0xea, 0x9e, 0x45, 0x4a, 0x58, 0xbb, 0xbc, 0xec, 0x6b, 0xb0}; + uint8_t bytesprops12[] = {0xad, 0x91, 0x13, 0x0, 0x1e, 0x15, 0x6e, 0x24, 0xa4, 0x5d}; + uint8_t bytesprops13[] = {0x33, 0x77, 0x96, 0xcd, 0xf4, 0xfb, 0x5d, 0xa1, 0x8e, 0xe6, 0x13, 0xcd, 0x84, 0xb2, + 0x81, 0xc1, 0x75, 0x51, 0x7d, 0x5e, 0xc7, 0x43, 0x5b, 0x22, 0x39, 0x80, 0x89, 0x76}; + uint8_t bytesprops14[] = {0x37, 0x43, 0xe3, 0x10, 0x5e, 0x3b, 0xd3, 0xd, 0xf5, + 0x7e, 0xd9, 0x6f, 0x75, 0xd9, 0xe0, 0x76, 0x6b}; + uint8_t bytesprops15[] = {0x68, 0xd3, 0x26, 0x43, 0x31, 0xc5, 0x49, 0x4d, 0x11, 0x4e, 0xbb, 0xf0, 0x87, + 0x5f, 0xcc, 0xdb, 0xca, 0x9d, 0xf4, 0x19, 0x8a, 0xb0, 0x42, 0xe0, 0x42, 0x96}; + uint8_t bytesprops16[] = {0xd5, 0x36, 0xfa, 0x5, 0x9, 0x8b, 0xeb, 0xbd, 0xa8, 0x4b, 0xb2, + 0xde, 0xcd, 0x90, 0x24, 0xd5, 0x5, 0xa9, 0xce, 0xb9, 0xbc}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10326}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops1}, .v = {13, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops3}, .v = {22, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9863}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4645}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26316}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5815}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18831}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20663}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops16}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26355}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17981, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28036, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19276 [(";'D\231\163t\131\134\DC1\172\GS\EOT",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("G\167C\245\138\221v\SI",SubOptions {_retainHandling +// SubscribeRequest 8713 [("\fd\209\239\ETB\191E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\183\248C",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("5",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\ETBz+\DC4\ETB\244\SOH\203\149<\224g\247^\243\187\&3\RS<\162\178S]{{\143\226c_",SubOptions {_retainHandling // = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ESC\250\186Jm\250\238\180\199w\132\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("4+\184\&93\225GY\193:\184\143%\155\SOH",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropResponseTopic -// "7wH\235\154",PropMessageExpiryInterval 9779,PropTopicAliasMaximum 9795,PropRequestProblemInformation 193] +// QoS1}),("\238\DC4\212\224g.\142q`8P<\164\172\229\248",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\143Ib3\212\238\222\217k\223\\\SO\SOxm\220}s;^\162\226",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\130\EM\NUL\129\234\143\201xg>\194\173tM\GS\148\201\167\221O\ENQ#ktu89\141",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("B\203O\166\SI\168J\185|\254\215>\177\156",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS2})] [PropContentType "\"*8\173\t\"\NUL\161F\201\245\146P\ETX^"] TEST(Subscribe5QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0x50, 0x4b, 0x4c, 0x12, 0x8, 0x0, 0x5, 0x37, 0x77, 0x48, 0xeb, 0x9a, 0x2, 0x0, 0x0, 0x26, - 0x33, 0x22, 0x26, 0x43, 0x17, 0xc1, 0x0, 0xc, 0x3b, 0x27, 0x44, 0xe7, 0xa3, 0x74, 0x83, 0x86, 0x11, - 0xac, 0x1d, 0x4, 0x2, 0x0, 0x8, 0x47, 0xa7, 0x43, 0xf5, 0x8a, 0xdd, 0x76, 0xf, 0x1, 0x0, 0xc, - 0x1b, 0xfa, 0xba, 0x4a, 0x6d, 0xfa, 0xee, 0xb4, 0xc7, 0x77, 0x84, 0xa6, 0x1, 0x0, 0xf, 0x34, 0x2b, - 0xb8, 0x39, 0x33, 0xe1, 0x47, 0x59, 0xc1, 0x3a, 0xb8, 0x8f, 0x25, 0x9b, 0x1, 0x2}; - - uint8_t buf[92] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x3b, 0x27, 0x44, 0xe7, 0xa3, 0x74, 0x83, 0x86, 0x11, 0xac, 0x1d, 0x4}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0xa5, 0x1, 0x22, 0x9, 0x12, 0x3, 0x0, 0xf, 0x22, 0x2a, 0x38, 0xad, 0x9, 0x22, 0x0, 0xa1, + 0x46, 0xc9, 0xf5, 0x92, 0x50, 0x3, 0x5e, 0x0, 0x7, 0xc, 0x64, 0xd1, 0xef, 0x17, 0xbf, 0x45, 0x2, + 0x0, 0x3, 0xb7, 0xf8, 0x43, 0x2, 0x0, 0x1, 0x35, 0x2, 0x0, 0x1d, 0x17, 0x7a, 0x2b, 0x14, 0x17, + 0xf4, 0x1, 0xcb, 0x95, 0x3c, 0xe0, 0x67, 0xf7, 0x5e, 0xf3, 0xbb, 0x33, 0x1e, 0x3c, 0xa2, 0xb2, 0x53, + 0x5d, 0x7b, 0x7b, 0x8f, 0xe2, 0x63, 0x5f, 0x1, 0x0, 0x10, 0xee, 0x14, 0xd4, 0xe0, 0x67, 0x2e, 0x8e, + 0x71, 0x60, 0x38, 0x50, 0x3c, 0xa4, 0xac, 0xe5, 0xf8, 0x1, 0x0, 0x16, 0x8f, 0x49, 0x62, 0x33, 0xd4, + 0xee, 0xde, 0xd9, 0x6b, 0xdf, 0x5c, 0xe, 0xe, 0x78, 0x6d, 0xdc, 0x7d, 0x73, 0x3b, 0x5e, 0xa2, 0xe2, + 0x1, 0x0, 0x1c, 0x82, 0x19, 0x0, 0x81, 0xea, 0x8f, 0xc9, 0x78, 0x67, 0x3e, 0xc2, 0xad, 0x74, 0x4d, + 0x1d, 0x94, 0xc9, 0xa7, 0xdd, 0x4f, 0x5, 0x23, 0x6b, 0x74, 0x75, 0x38, 0x39, 0x8d, 0x0, 0x0, 0xe, + 0x42, 0xcb, 0x4f, 0xa6, 0xf, 0xa8, 0x4a, 0xb9, 0x7c, 0xfe, 0xd7, 0x3e, 0xb1, 0x9c, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xc, 0x64, 0xd1, 0xef, 0x17, 0xbf, 0x45}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x47, 0xa7, 0x43, 0xf5, 0x8a, 0xdd, 0x76, 0xf}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb7, 0xf8, 0x43}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1b, 0xfa, 0xba, 0x4a, 0x6d, 0xfa, 0xee, 0xb4, 0xc7, 0x77, 0x84, 0xa6}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x35}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x34, 0x2b, 0xb8, 0x39, 0x33, 0xe1, 0x47, 0x59, - 0xc1, 0x3a, 0xb8, 0x8f, 0x25, 0x9b, 0x1}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x17, 0x7a, 0x2b, 0x14, 0x17, 0xf4, 0x1, 0xcb, 0x95, 0x3c, + 0xe0, 0x67, 0xf7, 0x5e, 0xf3, 0xbb, 0x33, 0x1e, 0x3c, 0xa2, + 0xb2, 0x53, 0x5d, 0x7b, 0x7b, 0x8f, 0xe2, 0x63, 0x5f}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x37, 0x77, 0x48, 0xeb, 0x9a}; + uint8_t topic_filter_s4_bytes[] = {0xee, 0x14, 0xd4, 0xe0, 0x67, 0x2e, 0x8e, 0x71, + 0x60, 0x38, 0x50, 0x3c, 0xa4, 0xac, 0xe5, 0xf8}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8f, 0x49, 0x62, 0x33, 0xd4, 0xee, 0xde, 0xd9, 0x6b, 0xdf, 0x5c, + 0xe, 0xe, 0x78, 0x6d, 0xdc, 0x7d, 0x73, 0x3b, 0x5e, 0xa2, 0xe2}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x82, 0x19, 0x0, 0x81, 0xea, 0x8f, 0xc9, 0x78, 0x67, 0x3e, + 0xc2, 0xad, 0x74, 0x4d, 0x1d, 0x94, 0xc9, 0xa7, 0xdd, 0x4f, + 0x5, 0x23, 0x6b, 0x74, 0x75, 0x38, 0x39, 0x8d}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x42, 0xcb, 0x4f, 0xa6, 0xf, 0xa8, 0x4a, 0xb9, 0x7c, 0xfe, 0xd7, 0x3e, 0xb1, 0x9c}; + lwmqtt_string_t topic_filter_s7 = {14, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x22, 0x2a, 0x38, 0xad, 0x9, 0x22, 0x0, 0xa1, 0x46, 0xc9, 0xf5, 0x92, 0x50, 0x3, 0x5e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9779}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9795}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19276, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8713, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 2713 [("\v\149\153&\227@\158",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\137\178V\240lc\224\b\175']\235\NUL$\243G\224_*\254",SubOptions +// SubscribeRequest 22186 [("\SOs\230\200\227!\208>\aj\134P\159@\b\245\135B\251\254\225\t\197\222\144",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("9\210TgR\152e\221\141\200\213\141\198U\DC3V5\226\221\190M\169",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAuthenticationData -// "\132\&6vF\NUL\217\DEL^\246\DC3m5!\212\238\ESC\239[f",PropMaximumQoS 92,PropRequestResponseInformation -// 33,PropRequestProblemInformation 243,PropTopicAlias 1722,PropAssignedClientIdentifier -// "Q%\151\&1\226Z\147\153\247b",PropCorrelationData "\163",PropRequestProblemInformation 24,PropResponseInformation -// "\213\215\151\SOH",PropAuthenticationMethod "6\254t\b\241\&3\208"] +// QoS1}),("3\163Q\180\141+\131\234M\208\187:\NULW\165\227R1\198\131\168\176\185z\149w",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\131\140\149\244p\253\129\DC2\DC1c#h\224qu\128\166\SICd\174\138\185",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\ESCp",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("9\209\165\252Ue\146\138\159\n%\SOW\252D\212",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAuthenticationMethod "\209zPGD{e$"] TEST(Subscribe5QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x80, 0x1, 0xa, 0x99, 0x43, 0x16, 0x0, 0x13, 0x84, 0x36, 0x76, 0x46, 0x0, 0xd9, 0x7f, 0x5e, - 0xf6, 0x13, 0x6d, 0x35, 0x21, 0xd4, 0xee, 0x1b, 0xef, 0x5b, 0x66, 0x24, 0x5c, 0x19, 0x21, 0x17, 0xf3, - 0x23, 0x6, 0xba, 0x12, 0x0, 0xa, 0x51, 0x25, 0x97, 0x31, 0xe2, 0x5a, 0x93, 0x99, 0xf7, 0x62, 0x9, - 0x0, 0x1, 0xa3, 0x17, 0x18, 0x1a, 0x0, 0x4, 0xd5, 0xd7, 0x97, 0x1, 0x15, 0x0, 0x7, 0x36, 0xfe, - 0x74, 0x8, 0xf1, 0x33, 0xd0, 0x0, 0x7, 0xb, 0x95, 0x99, 0x26, 0xe3, 0x40, 0x9e, 0x2, 0x0, 0x14, - 0x89, 0xb2, 0x56, 0xf0, 0x6c, 0x63, 0xe0, 0x8, 0xaf, 0x27, 0x5d, 0xeb, 0x0, 0x24, 0xf3, 0x47, 0xe0, - 0x5f, 0x2a, 0xfe, 0x0, 0x0, 0x16, 0x39, 0xd2, 0x54, 0x67, 0x52, 0x98, 0x65, 0xdd, 0x8d, 0xc8, 0xd5, - 0x8d, 0xc6, 0x55, 0x13, 0x56, 0x35, 0xe2, 0xdd, 0xbe, 0x4d, 0xa9, 0x1}; - - uint8_t buf[141] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xb, 0x95, 0x99, 0x26, 0xe3, 0x40, 0x9e}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x79, 0x56, 0xaa, 0xb, 0x15, 0x0, 0x8, 0xd1, 0x7a, 0x50, 0x47, 0x44, 0x7b, 0x65, 0x24, + 0x0, 0x19, 0xe, 0x73, 0xe6, 0xc8, 0xe3, 0x21, 0xd0, 0x3e, 0x7, 0x6a, 0x86, 0x50, 0x9f, 0x40, + 0x8, 0xf5, 0x87, 0x42, 0xfb, 0xfe, 0xe1, 0x9, 0xc5, 0xde, 0x90, 0x1, 0x0, 0x1a, 0x33, 0xa3, + 0x51, 0xb4, 0x8d, 0x2b, 0x83, 0xea, 0x4d, 0xd0, 0xbb, 0x3a, 0x0, 0x57, 0xa5, 0xe3, 0x52, 0x31, + 0xc6, 0x83, 0xa8, 0xb0, 0xb9, 0x7a, 0x95, 0x77, 0x2, 0x0, 0x17, 0x83, 0x8c, 0x95, 0xf4, 0x70, + 0xfd, 0x81, 0x12, 0x11, 0x63, 0x23, 0x68, 0xe0, 0x71, 0x75, 0x80, 0xa6, 0xf, 0x43, 0x64, 0xae, + 0x8a, 0xb9, 0x2, 0x0, 0x2, 0x1b, 0x70, 0x1, 0x0, 0x10, 0x39, 0xd1, 0xa5, 0xfc, 0x55, 0x65, + 0x92, 0x8a, 0x9f, 0xa, 0x25, 0xe, 0x57, 0xfc, 0x44, 0xd4, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xe, 0x73, 0xe6, 0xc8, 0xe3, 0x21, 0xd0, 0x3e, 0x7, 0x6a, 0x86, 0x50, 0x9f, + 0x40, 0x8, 0xf5, 0x87, 0x42, 0xfb, 0xfe, 0xe1, 0x9, 0xc5, 0xde, 0x90}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x89, 0xb2, 0x56, 0xf0, 0x6c, 0x63, 0xe0, 0x8, 0xaf, 0x27, - 0x5d, 0xeb, 0x0, 0x24, 0xf3, 0x47, 0xe0, 0x5f, 0x2a, 0xfe}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x33, 0xa3, 0x51, 0xb4, 0x8d, 0x2b, 0x83, 0xea, 0x4d, 0xd0, 0xbb, 0x3a, 0x0, + 0x57, 0xa5, 0xe3, 0x52, 0x31, 0xc6, 0x83, 0xa8, 0xb0, 0xb9, 0x7a, 0x95, 0x77}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x39, 0xd2, 0x54, 0x67, 0x52, 0x98, 0x65, 0xdd, 0x8d, 0xc8, 0xd5, - 0x8d, 0xc6, 0x55, 0x13, 0x56, 0x35, 0xe2, 0xdd, 0xbe, 0x4d, 0xa9}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x83, 0x8c, 0x95, 0xf4, 0x70, 0xfd, 0x81, 0x12, 0x11, 0x63, 0x23, 0x68, + 0xe0, 0x71, 0x75, 0x80, 0xa6, 0xf, 0x43, 0x64, 0xae, 0x8a, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x84, 0x36, 0x76, 0x46, 0x0, 0xd9, 0x7f, 0x5e, 0xf6, 0x13, - 0x6d, 0x35, 0x21, 0xd4, 0xee, 0x1b, 0xef, 0x5b, 0x66}; - uint8_t bytesprops1[] = {0x51, 0x25, 0x97, 0x31, 0xe2, 0x5a, 0x93, 0x99, 0xf7, 0x62}; - uint8_t bytesprops2[] = {0xa3}; - uint8_t bytesprops3[] = {0xd5, 0xd7, 0x97, 0x1}; - uint8_t bytesprops4[] = {0x36, 0xfe, 0x74, 0x8, 0xf1, 0x33, 0xd0}; + uint8_t topic_filter_s3_bytes[] = {0x1b, 0x70}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x39, 0xd1, 0xa5, 0xfc, 0x55, 0x65, 0x92, 0x8a, + 0x9f, 0xa, 0x25, 0xe, 0x57, 0xfc, 0x44, 0xd4}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xd1, 0x7a, 0x50, 0x47, 0x44, 0x7b, 0x65, 0x24}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1722}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2713, 3, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22186, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7741 [("7\233y\244\229-\244\179\172\&6\164H",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(")\139\210\DC4\162\189qQ\DC4\141\253\&8",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropAuthenticationMethod "\227\ACK\144\181\222",PropTopicAliasMaximum 7962,PropResponseInformation -// "\137\132",PropMessageExpiryInterval 26117,PropMessageExpiryInterval 22772,PropResponseTopic -// "\166\249/hZ\139\DC4",PropUserProperty "i\a\140}\167\249k" -// "\196H\133j\236\STXd)\ESC\201{\207",PropAssignedClientIdentifier "H\196\239",PropReasonString "\NUL\DEL\176\252 -// \177\231@u-\144\NAK\220TiQ\128\144",PropSubscriptionIdentifierAvailable 188,PropAssignedClientIdentifier -// "\DC3ht\222\180\182\154\240\186J\135t\188=\SYN\212'\US:S\193h\ETX",PropServerKeepAlive -// 12221,PropMessageExpiryInterval 1211] +// SubscribeRequest 16934 [("\ENQ\US\231\182\242\224Rp\134\v\227Heh\CAN\168\243\231\181k7&{\n",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("W\201\226%\229\246\253\183\\\FS\242-\246I\DC4\DLE\188y\234\&5\240\DC1\189u\152\SO\240_",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\196\155\175",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("s\255c&\US\DLE@u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("I4\236\129I\\c\187\205\211J",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("6\246\129_\248\224\199\160MK\168\141hr\171",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\251\&0:\197\176N\128\&0\194\204\246\NAK\236i}|\154\223c\f\220",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("Or\209\133\140\155\171\243\164J\229\235\242\246\132k}\ENQ\138\188\215\185\150%xv)P\ACK",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\169\247\243Q\241\192)\133%\156\243\251\169\\\239\187E\234\163\194\141\&2\246*v\192\175\ETX\201",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropMaximumPacketSize 16232,PropRetainAvailable 225,PropSharedSubscriptionAvailable 54,PropRetainAvailable +// 75,PropMaximumPacketSize 25795,PropRetainAvailable 163,PropReceiveMaximum 32676,PropRequestResponseInformation +// 93,PropMaximumQoS 79,PropMessageExpiryInterval 4955,PropCorrelationData +// "5\SI\206\f\247\EM5",PropSharedSubscriptionAvailable 194,PropWillDelayInterval 26681,PropTopicAlias 16992] TEST(Subscribe5QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0x9c, 0x1, 0x1e, 0x3d, 0x7b, 0x15, 0x0, 0x5, 0xe3, 0x6, 0x90, 0xb5, 0xde, 0x22, 0x1f, - 0x1a, 0x1a, 0x0, 0x2, 0x89, 0x84, 0x2, 0x0, 0x0, 0x66, 0x5, 0x2, 0x0, 0x0, 0x58, 0xf4, - 0x8, 0x0, 0x7, 0xa6, 0xf9, 0x2f, 0x68, 0x5a, 0x8b, 0x14, 0x26, 0x0, 0x7, 0x69, 0x7, 0x8c, - 0x7d, 0xa7, 0xf9, 0x6b, 0x0, 0xc, 0xc4, 0x48, 0x85, 0x6a, 0xec, 0x2, 0x64, 0x29, 0x1b, 0xc9, - 0x7b, 0xcf, 0x12, 0x0, 0x3, 0x48, 0xc4, 0xef, 0x1f, 0x0, 0x12, 0x0, 0x7f, 0xb0, 0xfc, 0x20, - 0xb1, 0xe7, 0x40, 0x75, 0x2d, 0x90, 0x15, 0xdc, 0x54, 0x69, 0x51, 0x80, 0x90, 0x29, 0xbc, 0x12, - 0x0, 0x17, 0x13, 0x68, 0x74, 0xde, 0xb4, 0xb6, 0x9a, 0xf0, 0xba, 0x4a, 0x87, 0x74, 0xbc, 0x3d, - 0x16, 0xd4, 0x27, 0x1f, 0x3a, 0x53, 0xc1, 0x68, 0x3, 0x13, 0x2f, 0xbd, 0x2, 0x0, 0x0, 0x4, - 0xbb, 0x0, 0xc, 0x37, 0xe9, 0x79, 0xf4, 0xe5, 0x2d, 0xf4, 0xb3, 0xac, 0x36, 0xa4, 0x48, 0x1, - 0x0, 0xc, 0x29, 0x8b, 0xd2, 0x14, 0xa2, 0xbd, 0x71, 0x51, 0x14, 0x8d, 0xfd, 0x38, 0x1}; - - uint8_t buf[169] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x37, 0xe9, 0x79, 0xf4, 0xe5, 0x2d, 0xf4, 0xb3, 0xac, 0x36, 0xa4, 0x48}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0xfb, 0x1, 0x42, 0x26, 0x32, 0x27, 0x0, 0x0, 0x3f, 0x68, 0x25, 0xe1, 0x2a, 0x36, 0x25, 0x4b, + 0x27, 0x0, 0x0, 0x64, 0xc3, 0x25, 0xa3, 0x21, 0x7f, 0xa4, 0x19, 0x5d, 0x24, 0x4f, 0x2, 0x0, 0x0, + 0x13, 0x5b, 0x9, 0x0, 0x7, 0x35, 0xf, 0xce, 0xc, 0xf7, 0x19, 0x35, 0x2a, 0xc2, 0x18, 0x0, 0x0, + 0x68, 0x39, 0x23, 0x42, 0x60, 0x0, 0x18, 0x5, 0x1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, 0x8d, 0x32, 0xf6, 0x2a, 0x76, 0xc0, 0xaf, 0x3, 0xc9, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x5, 0x1f, 0xe7, 0xb6, 0xf2, 0xe0, 0x52, 0x70, 0x86, 0xb, 0xe3, 0x48, + 0x65, 0x68, 0x18, 0xa8, 0xf3, 0xe7, 0xb5, 0x6b, 0x37, 0x26, 0x7b, 0xa}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x29, 0x8b, 0xd2, 0x14, 0xa2, 0xbd, 0x71, 0x51, 0x14, 0x8d, 0xfd, 0x38}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x57, 0xc9, 0xe2, 0x25, 0xe5, 0xf6, 0xfd, 0xb7, 0x5c, 0x1c, + 0xf2, 0x2d, 0xf6, 0x49, 0x14, 0x10, 0xbc, 0x79, 0xea, 0x35, + 0xf0, 0x11, 0xbd, 0x75, 0x98, 0xe, 0xf0, 0x5f}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xe3, 0x6, 0x90, 0xb5, 0xde}; - uint8_t bytesprops1[] = {0x89, 0x84}; - uint8_t bytesprops2[] = {0xa6, 0xf9, 0x2f, 0x68, 0x5a, 0x8b, 0x14}; - uint8_t bytesprops4[] = {0xc4, 0x48, 0x85, 0x6a, 0xec, 0x2, 0x64, 0x29, 0x1b, 0xc9, 0x7b, 0xcf}; - uint8_t bytesprops3[] = {0x69, 0x7, 0x8c, 0x7d, 0xa7, 0xf9, 0x6b}; - uint8_t bytesprops5[] = {0x48, 0xc4, 0xef}; - uint8_t bytesprops6[] = {0x0, 0x7f, 0xb0, 0xfc, 0x20, 0xb1, 0xe7, 0x40, 0x75, - 0x2d, 0x90, 0x15, 0xdc, 0x54, 0x69, 0x51, 0x80, 0x90}; - uint8_t bytesprops7[] = {0x13, 0x68, 0x74, 0xde, 0xb4, 0xb6, 0x9a, 0xf0, 0xba, 0x4a, 0x87, 0x74, - 0xbc, 0x3d, 0x16, 0xd4, 0x27, 0x1f, 0x3a, 0x53, 0xc1, 0x68, 0x3}; + uint8_t topic_filter_s2_bytes[] = {0xc4, 0x9b, 0xaf}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x73, 0xff, 0x63, 0x26, 0x1f, 0x10, 0x40, 0x75}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x49, 0x34, 0xec, 0x81, 0x49, 0x5c, 0x63, 0xbb, 0xcd, 0xd3, 0x4a}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x36, 0xf6, 0x81, 0x5f, 0xf8, 0xe0, 0xc7, 0xa0, + 0x4d, 0x4b, 0xa8, 0x8d, 0x68, 0x72, 0xab}; + lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xfb, 0x30, 0x3a, 0xc5, 0xb0, 0x4e, 0x80, 0x30, 0xc2, 0xcc, 0xf6, + 0x15, 0xec, 0x69, 0x7d, 0x7c, 0x9a, 0xdf, 0x63, 0xc, 0xdc}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x4f, 0x72, 0xd1, 0x85, 0x8c, 0x9b, 0xab, 0xf3, 0xa4, 0x4a, + 0xe5, 0xeb, 0xf2, 0xf6, 0x84, 0x6b, 0x7d, 0x5, 0x8a, 0xbc, + 0xd7, 0xb9, 0x96, 0x25, 0x78, 0x76, 0x29, 0x50, 0x6}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa9, 0xf7, 0xf3, 0x51, 0xf1, 0xc0, 0x29, 0x85, 0x25, 0x9c, + 0xf3, 0xfb, 0xa9, 0x5c, 0xef, 0xbb, 0x45, 0xea, 0xa3, 0xc2, + 0x8d, 0x32, 0xf6, 0x2a, 0x76, 0xc0, 0xaf, 0x3, 0xc9}; + lwmqtt_string_t topic_filter_s9 = {29, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, + LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x35, 0xf, 0xce, 0xc, 0xf7, 0x19, 0x35}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7962}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26117}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22772}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {12, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12221}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1211}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16232}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25795}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32676}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4955}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26681}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16992}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7741, 2, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16934, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11149 -// [("^\226\251\181\&2\156|t\151S\169\252\146\ETX\GS\172S\169\EOT\142\201\173\164=\170a",SubOptions {_retainHandling = +// SubscribeRequest 19450 [("-\157He_V\165gmY\135\DC1\242\b\132\141\234\205\247",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("X+\208\242 +// 0\199d9\203\NAK)\182AKX:\187*\247|\177\229",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("-\200\196\v\SON\152\156\131\233\ESC\181(\174\ESC_\182(",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\245",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\"\DLE\152\151\134\RS\b7\133\240",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("\155\200\218O\139Q\137\183r>\FSZ()\163@C\240\153\197\175\164w\237\244\214",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\225W3k!\151\245\228>\205\198\132\168,\142",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\FS\245\145\RS\166*\SOH\163\232\246[\204\144\192O\181\160",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),(":%\214!\232hqh\239\137?\SYN\253\231\130\239Ki",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\236\214\206\181\DC2\167\181k\255c\150C&X`R\250\150\SI\184G\241x\151\196\143R\144\210w",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropAuthenticationData "^-u\FS\NAK\ACKO\170z\169\219\182\154\238\DC2\NAKB\134\158\v/\DC123\242t",PropServerReference -// "\DEL]\197\217\158)\RSC50\154\255\214E]\NAK\190\b\187f\217_\237\ACK\152*",PropSubscriptionIdentifierAvailable -// 78,PropTopicAlias 20242,PropReasonString "$\153K)mq\t\173>\194\168!\177=\GS\CAN",PropContentType -// "\184\217\179)7\168$~K\176'\205\159!\247\229\ACK\167F\ESC\223s\160",PropPayloadFormatIndicator -// 199,PropServerReference "\164",PropCorrelationData "+\229w^\235\r\172\245q\202\202\219b\151\155M\176?\224"] +// QoS1}),("\211\242#\201}dL\240\189\150\251\185\231~?\227\158\152z\251\SUB\DELS\174E",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("%\GS>\174RN3\188KZ\169\ETB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable 66,PropUserProperty +// "\239r\235n\146\&6\EOT\162\193z|\DC3l\176\217\238r|\138\249^\245\EM\207\215\228" +// "y\147c9\137j-\230\189\DLE/k\189\DLE}\134\240\SI\255>\140<",PropAuthenticationData +// "\US\210\SO*\139\EOT!\208\230\191\151\246\207\175\170\209\152C\220\DC2\146\FS\131\135",PropAuthenticationData +// "\196\157U\211\r\233\130\EM{\131\197%\\\168s",PropReasonString "\237\DC2\244\202\154\\\252\226\t",PropServerReference +// "\141g5\ETXV\193\"\r\218HU\ESCY\222+_\213\185\SO\188",PropAuthenticationData +// "\ETX\228\224\143\243\234\"ld\161\233\193\243W\187&\145\139y\195~1\202\255\254\231\&1",PropWillDelayInterval +// 16995,PropAuthenticationData "!\163\179\196OQ\201\234\147W\140\224",PropServerKeepAlive +// 9589,PropAssignedClientIdentifier +// "\218=\228~O\GSN\SYN\137\128tP\151\149\211$\197%\215a\249\135\162\167\230:^\142",PropAuthenticationData +// "\US\237\184s\148\161\162\FS{\204.@{N\151\146\DC4|\DC1\135v\138\209\199w\171aDK",PropRequestProblemInformation +// 225,PropWillDelayInterval 22189,PropRetainAvailable 69,PropCorrelationData +// "T|H${3\147\FSz\ESC<\199~\245\DC1t\159#\193\234\205\139.\DC3",PropSharedSubscriptionAvailable +// 87,PropSharedSubscriptionAvailable 195,PropWildcardSubscriptionAvailable 248,PropServerReference +// "\162y\196\223\GS\200\DC3\188\b\197yr\DC2\DC4}A\131\224M\151ND\NAK",PropRequestProblemInformation 2] TEST(Subscribe5QCTest, Encode7) { uint8_t pkt[] = { - 0x82, 0xf0, 0x1, 0x2b, 0x8d, 0x88, 0x1, 0x16, 0x0, 0x1a, 0x5e, 0x2d, 0x75, 0x1c, 0x15, 0x6, 0x4f, 0xaa, 0x7a, - 0xa9, 0xdb, 0xb6, 0x9a, 0xee, 0x12, 0x15, 0x42, 0x86, 0x9e, 0xb, 0x2f, 0x11, 0x32, 0x33, 0xf2, 0x74, 0x1c, 0x0, - 0x1a, 0x7f, 0x5d, 0xc5, 0xd9, 0x9e, 0x29, 0x1e, 0x43, 0x35, 0x30, 0x9a, 0xff, 0xd6, 0x45, 0x5d, 0x15, 0xbe, 0x8, - 0xbb, 0x66, 0xd9, 0x5f, 0xed, 0x6, 0x98, 0x2a, 0x29, 0x4e, 0x23, 0x4f, 0x12, 0x1f, 0x0, 0x10, 0x24, 0x99, 0x4b, - 0x29, 0x6d, 0x71, 0x9, 0xad, 0x3e, 0xc2, 0xa8, 0x21, 0xb1, 0x3d, 0x1d, 0x18, 0x3, 0x0, 0x17, 0xb8, 0xd9, 0xb3, - 0x29, 0x37, 0xa8, 0x24, 0x7e, 0x4b, 0xb0, 0x27, 0xcd, 0x9f, 0x21, 0xf7, 0xe5, 0x6, 0xa7, 0x46, 0x1b, 0xdf, 0x73, - 0xa0, 0x1, 0xc7, 0x1c, 0x0, 0x1, 0xa4, 0x9, 0x0, 0x13, 0x2b, 0xe5, 0x77, 0x5e, 0xeb, 0xd, 0xac, 0xf5, 0x71, - 0xca, 0xca, 0xdb, 0x62, 0x97, 0x9b, 0x4d, 0xb0, 0x3f, 0xe0, 0x0, 0x1a, 0x5e, 0xe2, 0xfb, 0xb5, 0x32, 0x9c, 0x7c, - 0x74, 0x97, 0x53, 0xa9, 0xfc, 0x92, 0x3, 0x1d, 0xac, 0x53, 0xa9, 0x4, 0x8e, 0xc9, 0xad, 0xa4, 0x3d, 0xaa, 0x61, - 0x1, 0x0, 0xf, 0xe1, 0x57, 0x33, 0x6b, 0x21, 0x97, 0xf5, 0xe4, 0x3e, 0xcd, 0xc6, 0x84, 0xa8, 0x2c, 0x8e, 0x0, - 0x0, 0x11, 0x1c, 0xf5, 0x91, 0x1e, 0xa6, 0x2a, 0x1, 0xa3, 0xe8, 0xf6, 0x5b, 0xcc, 0x90, 0xc0, 0x4f, 0xb5, 0xa0, - 0x0, 0x0, 0x1e, 0xec, 0xd6, 0xce, 0xb5, 0x12, 0xa7, 0xb5, 0x6b, 0xff, 0x63, 0x96, 0x43, 0x26, 0x58, 0x60, 0x52, - 0xfa, 0x96, 0xf, 0xb8, 0x47, 0xf1, 0x78, 0x97, 0xc4, 0x8f, 0x52, 0x90, 0xd2, 0x77, 0x0}; - - uint8_t buf[253] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x5e, 0xe2, 0xfb, 0xb5, 0x32, 0x9c, 0x7c, 0x74, 0x97, 0x53, 0xa9, 0xfc, 0x92, - 0x3, 0x1d, 0xac, 0x53, 0xa9, 0x4, 0x8e, 0xc9, 0xad, 0xa4, 0x3d, 0xaa, 0x61}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + 0x82, 0xf8, 0x3, 0x4b, 0xfa, 0xc1, 0x2, 0x2a, 0x42, 0x26, 0x0, 0x1a, 0xef, 0x72, 0xeb, 0x6e, 0x92, 0x36, 0x4, + 0xa2, 0xc1, 0x7a, 0x7c, 0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x5f, 0xb6, 0x28, 0x1, 0x0, 0x1, + 0xf5, 0x1, 0x0, 0xa, 0x22, 0x10, 0x98, 0x97, 0x86, 0x1e, 0x8, 0x37, 0x85, 0xf0, 0x0, 0x0, 0x1a, 0x9b, 0xc8, + 0xda, 0x4f, 0x8b, 0x51, 0x89, 0xb7, 0x72, 0x3e, 0x1c, 0x5a, 0x28, 0x29, 0xa3, 0x40, 0x43, 0xf0, 0x99, 0xc5, 0xaf, + 0xa4, 0x77, 0xed, 0xf4, 0xd6, 0x2, 0x0, 0x12, 0x3a, 0x25, 0xd6, 0x21, 0xe8, 0x68, 0x71, 0x68, 0xef, 0x89, 0x3f, + 0x16, 0xfd, 0xe7, 0x82, 0xef, 0x4b, 0x69, 0x1, 0x0, 0x19, 0xd3, 0xf2, 0x23, 0xc9, 0x7d, 0x64, 0x4c, 0xf0, 0xbd, + 0x96, 0xfb, 0xb9, 0xe7, 0x7e, 0x3f, 0xe3, 0x9e, 0x98, 0x7a, 0xfb, 0x1a, 0x7f, 0x53, 0xae, 0x45, 0x1, 0x0, 0xc, + 0x25, 0x1d, 0x3e, 0xae, 0x52, 0x4e, 0x33, 0xbc, 0x4b, 0x5a, 0xa9, 0x17, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x2d, 0x9d, 0x48, 0x65, 0x5f, 0x56, 0xa5, 0x67, 0x6d, 0x59, + 0x87, 0x11, 0xf2, 0x8, 0x84, 0x8d, 0xea, 0xcd, 0xf7}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe1, 0x57, 0x33, 0x6b, 0x21, 0x97, 0xf5, 0xe4, - 0x3e, 0xcd, 0xc6, 0x84, 0xa8, 0x2c, 0x8e}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x58, 0x2b, 0xd0, 0xf2, 0x20, 0x30, 0xc7, 0x64, 0x39, 0xcb, 0x15, 0x29, + 0xb6, 0x41, 0x4b, 0x58, 0x3a, 0xbb, 0x2a, 0xf7, 0x7c, 0xb1, 0xe5}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1c, 0xf5, 0x91, 0x1e, 0xa6, 0x2a, 0x1, 0xa3, 0xe8, - 0xf6, 0x5b, 0xcc, 0x90, 0xc0, 0x4f, 0xb5, 0xa0}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2d, 0xc8, 0xc4, 0xb, 0xe, 0x4e, 0x98, 0x9c, 0x83, + 0xe9, 0x1b, 0xb5, 0x28, 0xae, 0x1b, 0x5f, 0xb6, 0x28}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xec, 0xd6, 0xce, 0xb5, 0x12, 0xa7, 0xb5, 0x6b, 0xff, 0x63, - 0x96, 0x43, 0x26, 0x58, 0x60, 0x52, 0xfa, 0x96, 0xf, 0xb8, - 0x47, 0xf1, 0x78, 0x97, 0xc4, 0x8f, 0x52, 0x90, 0xd2, 0x77}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf5}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x5e, 0x2d, 0x75, 0x1c, 0x15, 0x6, 0x4f, 0xaa, 0x7a, 0xa9, 0xdb, 0xb6, 0x9a, - 0xee, 0x12, 0x15, 0x42, 0x86, 0x9e, 0xb, 0x2f, 0x11, 0x32, 0x33, 0xf2, 0x74}; - uint8_t bytesprops1[] = {0x7f, 0x5d, 0xc5, 0xd9, 0x9e, 0x29, 0x1e, 0x43, 0x35, 0x30, 0x9a, 0xff, 0xd6, - 0x45, 0x5d, 0x15, 0xbe, 0x8, 0xbb, 0x66, 0xd9, 0x5f, 0xed, 0x6, 0x98, 0x2a}; - uint8_t bytesprops2[] = {0x24, 0x99, 0x4b, 0x29, 0x6d, 0x71, 0x9, 0xad, - 0x3e, 0xc2, 0xa8, 0x21, 0xb1, 0x3d, 0x1d, 0x18}; - uint8_t bytesprops3[] = {0xb8, 0xd9, 0xb3, 0x29, 0x37, 0xa8, 0x24, 0x7e, 0x4b, 0xb0, 0x27, 0xcd, - 0x9f, 0x21, 0xf7, 0xe5, 0x6, 0xa7, 0x46, 0x1b, 0xdf, 0x73, 0xa0}; - uint8_t bytesprops4[] = {0xa4}; - uint8_t bytesprops5[] = {0x2b, 0xe5, 0x77, 0x5e, 0xeb, 0xd, 0xac, 0xf5, 0x71, 0xca, - 0xca, 0xdb, 0x62, 0x97, 0x9b, 0x4d, 0xb0, 0x3f, 0xe0}; + uint8_t topic_filter_s4_bytes[] = {0x22, 0x10, 0x98, 0x97, 0x86, 0x1e, 0x8, 0x37, 0x85, 0xf0}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x9b, 0xc8, 0xda, 0x4f, 0x8b, 0x51, 0x89, 0xb7, 0x72, 0x3e, 0x1c, 0x5a, 0x28, + 0x29, 0xa3, 0x40, 0x43, 0xf0, 0x99, 0xc5, 0xaf, 0xa4, 0x77, 0xed, 0xf4, 0xd6}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3a, 0x25, 0xd6, 0x21, 0xe8, 0x68, 0x71, 0x68, 0xef, + 0x89, 0x3f, 0x16, 0xfd, 0xe7, 0x82, 0xef, 0x4b, 0x69}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xd3, 0xf2, 0x23, 0xc9, 0x7d, 0x64, 0x4c, 0xf0, 0xbd, 0x96, 0xfb, 0xb9, 0xe7, + 0x7e, 0x3f, 0xe3, 0x9e, 0x98, 0x7a, 0xfb, 0x1a, 0x7f, 0x53, 0xae, 0x45}; + lwmqtt_string_t topic_filter_s7 = {25, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x25, 0x1d, 0x3e, 0xae, 0x52, 0x4e, 0x33, 0xbc, 0x4b, 0x5a, 0xa9, 0x17}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops1[] = {0x79, 0x93, 0x63, 0x39, 0x89, 0x6a, 0x2d, 0xe6, 0xbd, 0x10, 0x2f, + 0x6b, 0xbd, 0x10, 0x7d, 0x86, 0xf0, 0xf, 0xff, 0x3e, 0x8c, 0x3c}; + uint8_t bytesprops0[] = {0xef, 0x72, 0xeb, 0x6e, 0x92, 0x36, 0x4, 0xa2, 0xc1, 0x7a, 0x7c, 0x13, 0x6c, + 0xb0, 0xd9, 0xee, 0x72, 0x7c, 0x8a, 0xf9, 0x5e, 0xf5, 0x19, 0xcf, 0xd7, 0xe4}; + uint8_t bytesprops2[] = {0x1f, 0xd2, 0xe, 0x2a, 0x8b, 0x4, 0x21, 0xd0, 0xe6, 0xbf, 0x97, 0xf6, + 0xcf, 0xaf, 0xaa, 0xd1, 0x98, 0x43, 0xdc, 0x12, 0x92, 0x1c, 0x83, 0x87}; + uint8_t bytesprops3[] = {0xc4, 0x9d, 0x55, 0xd3, 0xd, 0xe9, 0x82, 0x19, 0x7b, 0x83, 0xc5, 0x25, 0x5c, 0xa8, 0x73}; + uint8_t bytesprops4[] = {0xed, 0x12, 0xf4, 0xca, 0x9a, 0x5c, 0xfc, 0xe2, 0x9}; + uint8_t bytesprops5[] = {0x8d, 0x67, 0x35, 0x3, 0x56, 0xc1, 0x22, 0xd, 0xda, 0x48, + 0x55, 0x1b, 0x59, 0xde, 0x2b, 0x5f, 0xd5, 0xb9, 0xe, 0xbc}; + uint8_t bytesprops6[] = {0x3, 0xe4, 0xe0, 0x8f, 0xf3, 0xea, 0x22, 0x6c, 0x64, 0xa1, 0xe9, 0xc1, 0xf3, 0x57, + 0xbb, 0x26, 0x91, 0x8b, 0x79, 0xc3, 0x7e, 0x31, 0xca, 0xff, 0xfe, 0xe7, 0x31}; + uint8_t bytesprops7[] = {0x21, 0xa3, 0xb3, 0xc4, 0x4f, 0x51, 0xc9, 0xea, 0x93, 0x57, 0x8c, 0xe0}; + uint8_t bytesprops8[] = {0xda, 0x3d, 0xe4, 0x7e, 0x4f, 0x1d, 0x4e, 0x16, 0x89, 0x80, 0x74, 0x50, 0x97, 0x95, + 0xd3, 0x24, 0xc5, 0x25, 0xd7, 0x61, 0xf9, 0x87, 0xa2, 0xa7, 0xe6, 0x3a, 0x5e, 0x8e}; + uint8_t bytesprops9[] = {0x1f, 0xed, 0xb8, 0x73, 0x94, 0xa1, 0xa2, 0x1c, 0x7b, 0xcc, 0x2e, 0x40, 0x7b, 0x4e, 0x97, + 0x92, 0x14, 0x7c, 0x11, 0x87, 0x76, 0x8a, 0xd1, 0xc7, 0x77, 0xab, 0x61, 0x44, 0x4b}; + uint8_t bytesprops10[] = {0x54, 0x7c, 0x48, 0x24, 0x7b, 0x33, 0x93, 0x1c, 0x7a, 0x1b, 0x3c, 0xc7, + 0x7e, 0xf5, 0x11, 0x74, 0x9f, 0x23, 0xc1, 0xea, 0xcd, 0x8b, 0x2e, 0x13}; + uint8_t bytesprops11[] = {0xa2, 0x79, 0xc4, 0xdf, 0x1d, 0xc8, 0x13, 0xbc, 0x8, 0xc5, 0x79, 0x72, + 0x12, 0x14, 0x7d, 0x41, 0x83, 0xe0, 0x4d, 0x97, 0x4e, 0x44, 0x15}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20242}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops0}, .v = {22, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16995}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9589}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22189}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11149, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19450, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 2269 [("\DC2\238\205\167\203qt\199%Vl\129\160y\134\175U^\144K\SYN\ENQ\155+\GSdIr",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\208\157\230h\219\215$\215\133\STXrRf\214m\159\156\229\196\139\223EF>1\n'",SubOptions {_retainHandling = +// SubscribeRequest 18336 [("M\159.\194\192\a\198\148]\234\233",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\189\222HE\204\236\228\133\ACK*\236X\128\&0\229;n\245ORb\196",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("!\228\203\199\141\147\FS\178d6\b\237y\140c\213\DEL\141D \168\b\t\231C\"\STX",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\195S:\237\&8\249\f\223\SOH\EOTZ?\209RD1\128I\133\205\137\135c",SubOptions {_retainHandling = +// QoS0}),("\208N\231\188\204\CANY\CAN+",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("1\138\249\166\182\244n<\189\SI\a\192\&8W~\SI",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("Nt",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\182",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\252\&2\240JZ\198a\161y\244\135\130Ki\174\129\150\137H\142\184\151\167",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("%m\230\152\&3B\177\207",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\SO\US\NUL\133[",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\SO|\177\228\ETB\214C\165`\152*\SOM\180y9\233\&3`",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\160\&8\129\v\DC4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\\z\220\157\147\201\254\SUB\195\158\139\t\158\140\173\133\r\233\175q\212\152\175B\181d\FS",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropAuthenticationData "\184\223\189Z\137\FS\218\128\216\&5\192\198Iw\207y4\232",PropRequestProblemInformation -// 197,PropMessageExpiryInterval 11093,PropRequestResponseInformation 99,PropTopicAliasMaximum 22661,PropUserProperty -// "K1\STX6Q\132\129}\t>G\233\&3KkU[\v\STXS" -// "\143g\145_\170\203\159\142\197\140\144{\ETB\STX\ETX<\"))\251G\GS\132\158K",PropMessageExpiryInterval -// 11179,PropResponseTopic "\NULk&8:\238H\174",PropMessageExpiryInterval 3353,PropReceiveMaximum -// 4866,PropWildcardSubscriptionAvailable 41,PropAssignedClientIdentifier -// "\194\201\&1\222\247\SYN\191T$@\155C\DEL\255\b\202g\194\240\148\167\&2",PropRetainAvailable -// 136,PropAssignedClientIdentifier "^\229\129!\196\185",PropRetainAvailable 99,PropWillDelayInterval -// 14562,PropSubscriptionIdentifierAvailable 215] +// QoS0}),("1\NUL\n1\166lT'\255\146\189^\227\207\&3W\174*\171\194",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("O",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("^\230>\180\243\221\ENQ\146K\SYN\153i:\167\222\r",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRetainAvailable 177,PropContentType +// "\177b\143\183U\DC2[&\221\SOH\241f",PropAssignedClientIdentifier +// "\173s\f\207k$\250\208\181\240\161\189\226\EOT\243?\140\US93",PropRequestProblemInformation +// 101,PropMessageExpiryInterval 27033,PropServerKeepAlive 14517,PropPayloadFormatIndicator 214,PropResponseTopic +// "O);NP\195\240\RS\b\145R\178\FS\236\254\\\"\244>\NAK\nV\132o\DC1\153\&1\249\&4\DC1",PropTopicAliasMaximum +// 24352,PropAuthenticationMethod "\197\134)\138\167\141\199\217\139%\167X\217q\192T\196\181\"F\NAK:",PropTopicAlias +// 15336,PropSharedSubscriptionAvailable 6,PropWillDelayInterval 30622,PropRequestProblemInformation +// 44,PropResponseInformation +// "k\134\199\247&g\215\191\209z\218\SO\161\167\204,\230\164\&0F\DC3\192w",PropServerReference +// "\156\244fb\141\233\a\186_|4>b\ETB\214Z\166",PropContentType +// "\242\&9\169\138D\138\EM\143%\193\238\213\216\&9\170\DC2\178(\173i[p\173~\CAN\CAN\171?\215",PropTopicAlias +// 13053,PropMessageExpiryInterval 7710,PropAssignedClientIdentifier +// "w\194\243\EM\ETB\218\196\US]\241\r\160\137\207x",PropServerKeepAlive 6792] TEST(Subscribe5QCTest, Encode8) { uint8_t pkt[] = { - 0x82, 0xe1, 0x2, 0x8, 0xdd, 0x9a, 0x1, 0x16, 0x0, 0x12, 0xb8, 0xdf, 0xbd, 0x5a, 0x89, 0x1c, 0xda, 0x80, 0xd8, - 0x35, 0xc0, 0xc6, 0x49, 0x77, 0xcf, 0x79, 0x34, 0xe8, 0x17, 0xc5, 0x2, 0x0, 0x0, 0x2b, 0x55, 0x19, 0x63, 0x22, - 0x58, 0x85, 0x26, 0x0, 0x14, 0x4b, 0x31, 0x2, 0x36, 0x51, 0x84, 0x81, 0x7d, 0x9, 0x3e, 0x47, 0xe9, 0x33, 0x4b, - 0x6b, 0x55, 0x5b, 0xb, 0x2, 0x53, 0x0, 0x19, 0x8f, 0x67, 0x91, 0x5f, 0xaa, 0xcb, 0x9f, 0x8e, 0xc5, 0x8c, 0x90, - 0x7b, 0x17, 0x2, 0x3, 0x3c, 0x22, 0x29, 0x29, 0xfb, 0x47, 0x1d, 0x84, 0x9e, 0x4b, 0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98, 0x33, 0x42, 0xb1, 0xcf, 0x0, - 0x0, 0x5, 0xe, 0x1f, 0x0, 0x85, 0x5b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x13, 0xe, 0x7c, 0xb1, 0xe4, 0x17, 0xd6, - 0x43, 0xa5, 0x60, 0x98, 0x2a, 0xe, 0x4d, 0xb4, 0x79, 0x39, 0xe9, 0x33, 0x60, 0x2, 0x0, 0x5, 0xa0, 0x38, 0x81, - 0xb, 0x14, 0x2, 0x0, 0x1b, 0x5c, 0x7a, 0xdc, 0x9d, 0x93, 0xc9, 0xfe, 0x1a, 0xc3, 0x9e, 0x8b, 0x9, 0x9e, 0x8c, - 0xad, 0x85, 0xd, 0xe9, 0xaf, 0x71, 0xd4, 0x98, 0xaf, 0x42, 0xb5, 0x64, 0x1c, 0x0}; - - uint8_t buf[366] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x12, 0xee, 0xcd, 0xa7, 0xcb, 0x71, 0x74, 0xc7, 0x25, 0x56, - 0x6c, 0x81, 0xa0, 0x79, 0x86, 0xaf, 0x55, 0x5e, 0x90, 0x4b, - 0x16, 0x5, 0x9b, 0x2b, 0x1d, 0x64, 0x49, 0x72}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + 0x82, 0x8a, 0x3, 0x47, 0xa0, 0xe8, 0x1, 0x25, 0xb1, 0x3, 0x0, 0xc, 0xb1, 0x62, 0x8f, 0xb7, 0x55, 0x12, 0x5b, + 0x26, 0xdd, 0x1, 0xf1, 0x66, 0x12, 0x0, 0x14, 0xad, 0x73, 0xc, 0xcf, 0x6b, 0x24, 0xfa, 0xd0, 0xb5, 0xf0, 0xa1, + 0xbd, 0xe2, 0x4, 0xf3, 0x3f, 0x8c, 0x1f, 0x39, 0x33, 0x17, 0x65, 0x2, 0x0, 0x0, 0x69, 0x99, 0x13, 0x38, 0xb5, + 0x1, 0xd6, 0x8, 0x0, 0x1e, 0x4f, 0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 0x94, 0x5d, 0xea, 0xe9, 0x0, 0x0, 0x16, 0xbd, 0xde, 0x48, 0x45, 0xcc, 0xec, 0xe4, 0x85, 0x6, 0x2a, 0xec, + 0x58, 0x80, 0x30, 0xe5, 0x3b, 0x6e, 0xf5, 0x4f, 0x52, 0x62, 0xc4, 0x0, 0x0, 0x1b, 0x21, 0xe4, 0xcb, 0xc7, 0x8d, + 0x93, 0x1c, 0xb2, 0x64, 0x36, 0x8, 0xed, 0x79, 0x8c, 0x63, 0xd5, 0x7f, 0x8d, 0x44, 0x20, 0xa8, 0x8, 0x9, 0xe7, + 0x43, 0x22, 0x2, 0x0, 0x0, 0x9, 0xd0, 0x4e, 0xe7, 0xbc, 0xcc, 0x18, 0x59, 0x18, 0x2b, 0x1, 0x0, 0x10, 0x31, + 0x8a, 0xf9, 0xa6, 0xb6, 0xf4, 0x6e, 0x3c, 0xbd, 0xf, 0x7, 0xc0, 0x38, 0x57, 0x7e, 0xf, 0x0, 0x0, 0x2, 0x4e, + 0x74, 0x0, 0x0, 0x1, 0xb6, 0x0, 0x0, 0x14, 0x31, 0x0, 0xa, 0x31, 0xa6, 0x6c, 0x54, 0x27, 0xff, 0x92, 0xbd, + 0x5e, 0xe3, 0xcf, 0x33, 0x57, 0xae, 0x2a, 0xab, 0xc2, 0x1, 0x0, 0x1, 0x4f, 0x0, 0x0, 0x0, 0x2, 0x0, 0x10, + 0x5e, 0xe6, 0x3e, 0xb4, 0xf3, 0xdd, 0x5, 0x92, 0x4b, 0x16, 0x99, 0x69, 0x3a, 0xa7, 0xde, 0xd, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x4d, 0x9f, 0x2e, 0xc2, 0xc0, 0x7, 0xc6, 0x94, 0x5d, 0xea, 0xe9}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd0, 0x9d, 0xe6, 0x68, 0xdb, 0xd7, 0x24, 0xd7, 0x85, 0x2, 0x72, 0x52, 0x66, 0xd6, - 0x6d, 0x9f, 0x9c, 0xe5, 0xc4, 0x8b, 0xdf, 0x45, 0x46, 0x3e, 0x31, 0xa, 0x27}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbd, 0xde, 0x48, 0x45, 0xcc, 0xec, 0xe4, 0x85, 0x6, 0x2a, 0xec, + 0x58, 0x80, 0x30, 0xe5, 0x3b, 0x6e, 0xf5, 0x4f, 0x52, 0x62, 0xc4}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc3, 0x53, 0x3a, 0xed, 0x38, 0xf9, 0xc, 0xdf, 0x1, 0x4, 0x5a, 0x3f, - 0xd1, 0x52, 0x44, 0x31, 0x80, 0x49, 0x85, 0xcd, 0x89, 0x87, 0x63}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x21, 0xe4, 0xcb, 0xc7, 0x8d, 0x93, 0x1c, 0xb2, 0x64, 0x36, 0x8, 0xed, 0x79, 0x8c, + 0x63, 0xd5, 0x7f, 0x8d, 0x44, 0x20, 0xa8, 0x8, 0x9, 0xe7, 0x43, 0x22, 0x2}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfc, 0x32, 0xf0, 0x4a, 0x5a, 0xc6, 0x61, 0xa1, 0x79, 0xf4, 0x87, 0x82, - 0x4b, 0x69, 0xae, 0x81, 0x96, 0x89, 0x48, 0x8e, 0xb8, 0x97, 0xa7}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd0, 0x4e, 0xe7, 0xbc, 0xcc, 0x18, 0x59, 0x18, 0x2b}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x25, 0x6d, 0xe6, 0x98, 0x33, 0x42, 0xb1, 0xcf}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x8a, 0xf9, 0xa6, 0xb6, 0xf4, 0x6e, 0x3c, + 0xbd, 0xf, 0x7, 0xc0, 0x38, 0x57, 0x7e, 0xf}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe, 0x1f, 0x0, 0x85, 0x5b}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x4e, 0x74}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb6}; + lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe, 0x7c, 0xb1, 0xe4, 0x17, 0xd6, 0x43, 0xa5, 0x60, 0x98, - 0x2a, 0xe, 0x4d, 0xb4, 0x79, 0x39, 0xe9, 0x33, 0x60}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x31, 0x0, 0xa, 0x31, 0xa6, 0x6c, 0x54, 0x27, 0xff, 0x92, + 0xbd, 0x5e, 0xe3, 0xcf, 0x33, 0x57, 0xae, 0x2a, 0xab, 0xc2}; + lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa0, 0x38, 0x81, 0xb, 0x14}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x4f}; + lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x5c, 0x7a, 0xdc, 0x9d, 0x93, 0xc9, 0xfe, 0x1a, 0xc3, 0x9e, 0x8b, 0x9, 0x9e, 0x8c, - 0xad, 0x85, 0xd, 0xe9, 0xaf, 0x71, 0xd4, 0x98, 0xaf, 0x42, 0xb5, 0x64, 0x1c}; - lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0}; + lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0xb8, 0xdf, 0xbd, 0x5a, 0x89, 0x1c, 0xda, 0x80, 0xd8, - 0x35, 0xc0, 0xc6, 0x49, 0x77, 0xcf, 0x79, 0x34, 0xe8}; - uint8_t bytesprops2[] = {0x8f, 0x67, 0x91, 0x5f, 0xaa, 0xcb, 0x9f, 0x8e, 0xc5, 0x8c, 0x90, 0x7b, 0x17, - 0x2, 0x3, 0x3c, 0x22, 0x29, 0x29, 0xfb, 0x47, 0x1d, 0x84, 0x9e, 0x4b}; - uint8_t bytesprops1[] = {0x4b, 0x31, 0x2, 0x36, 0x51, 0x84, 0x81, 0x7d, 0x9, 0x3e, - 0x47, 0xe9, 0x33, 0x4b, 0x6b, 0x55, 0x5b, 0xb, 0x2, 0x53}; - uint8_t bytesprops3[] = {0x0, 0x6b, 0x26, 0x38, 0x3a, 0xee, 0x48, 0xae}; - uint8_t bytesprops4[] = {0xc2, 0xc9, 0x31, 0xde, 0xf7, 0x16, 0xbf, 0x54, 0x24, 0x40, 0x9b, - 0x43, 0x7f, 0xff, 0x8, 0xca, 0x67, 0xc2, 0xf0, 0x94, 0xa7, 0x32}; - uint8_t bytesprops5[] = {0x5e, 0xe5, 0x81, 0x21, 0xc4, 0xb9}; + uint8_t topic_filter_s10_bytes[] = {0x5e, 0xe6, 0x3e, 0xb4, 0xf3, 0xdd, 0x5, 0x92, + 0x4b, 0x16, 0x99, 0x69, 0x3a, 0xa7, 0xde, 0xd}; + lwmqtt_string_t topic_filter_s10 = {16, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xb1, 0x62, 0x8f, 0xb7, 0x55, 0x12, 0x5b, 0x26, 0xdd, 0x1, 0xf1, 0x66}; + uint8_t bytesprops1[] = {0xad, 0x73, 0xc, 0xcf, 0x6b, 0x24, 0xfa, 0xd0, 0xb5, 0xf0, + 0xa1, 0xbd, 0xe2, 0x4, 0xf3, 0x3f, 0x8c, 0x1f, 0x39, 0x33}; + uint8_t bytesprops2[] = {0x4f, 0x29, 0x3b, 0x4e, 0x50, 0xc3, 0xf0, 0x1e, 0x8, 0x91, 0x52, 0xb2, 0x1c, 0xec, 0xfe, + 0x5c, 0x22, 0xf4, 0x3e, 0x15, 0xa, 0x56, 0x84, 0x6f, 0x11, 0x99, 0x31, 0xf9, 0x34, 0x11}; + uint8_t bytesprops3[] = {0xc5, 0x86, 0x29, 0x8a, 0xa7, 0x8d, 0xc7, 0xd9, 0x8b, 0x25, 0xa7, + 0x58, 0xd9, 0x71, 0xc0, 0x54, 0xc4, 0xb5, 0x22, 0x46, 0x15, 0x3a}; + uint8_t bytesprops4[] = {0x6b, 0x86, 0xc7, 0xf7, 0x26, 0x67, 0xd7, 0xbf, 0xd1, 0x7a, 0xda, 0xe, + 0xa1, 0xa7, 0xcc, 0x2c, 0xe6, 0xa4, 0x30, 0x46, 0x13, 0xc0, 0x77}; + uint8_t bytesprops5[] = {0x9c, 0xf4, 0x66, 0x62, 0x8d, 0xe9, 0x7, 0xba, 0x5f, + 0x7c, 0x34, 0x3e, 0x62, 0x17, 0xd6, 0x5a, 0xa6}; + uint8_t bytesprops6[] = {0xf2, 0x39, 0xa9, 0x8a, 0x44, 0x8a, 0x19, 0x8f, 0x25, 0xc1, 0xee, 0xd5, 0xd8, 0x39, 0xaa, + 0x12, 0xb2, 0x28, 0xad, 0x69, 0x5b, 0x70, 0xad, 0x7e, 0x18, 0x18, 0xab, 0x3f, 0xd7}; + uint8_t bytesprops7[] = {0x77, 0xc2, 0xf3, 0x19, 0x17, 0xda, 0xc4, 0x1f, 0x5d, 0xf1, 0xd, 0xa0, 0x89, 0xcf, 0x78}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11093}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22661}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops1}, .v = {25, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11179}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3353}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4866}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14562}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27033}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14517}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24352}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15336}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30622}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13053}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7710}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6792}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2269, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18336, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9248 [("\233\154\252\129\230\&9\142\177.,%\202H\EM",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("s\ETB\220\154j\DC1\149e\235\252\163\CANis@",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SOHz\161\174&\ESC;\181-\130",SubOptions +// SubscribeRequest 3357 [("\203$[\200\&9\130F\142\249\232\189\167\148L",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("<\n\188 +// \193>c\237\242\202\GSX\216\222e\204\149;\226",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("(.\204\183\ESC\178*",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("fld~\ACK9Z//1\205\SUB~\211l\241D\196`T",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\204l}DdML\130\250\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2})] [PropSubscriptionIdentifierAvailable 250,PropSessionExpiryInterval -// 30222,PropAssignedClientIdentifier "\143\US",PropPayloadFormatIndicator 66,PropUserProperty -// "\128\&8W!S;\202E\206]\220\147\228\227\178\233\252i\140:+\207\148\&1\242>\192\243\160" -// "\202\181\197",PropCorrelationData -// "\150\219\ETX\v\147\STX\205\228*\217\175\203S\170\196P\223\202\204\180f",PropPayloadFormatIndicator 80] +// QoS0}),("<\215\129\217-\248\223\vA\CAN$\203\213IH\227)\200\233[\174/\236\234\235\206\245\154\236\253",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropRequestProblemInformation 141,PropReasonString "\182",PropReasonString +// "\202\SI\202\227&\182\161X2u\219;\201\203",PropCorrelationData +// "]\144\214>\132\vl\239`\208,s\b\225\194\142 Date: Thu, 19 Sep 2019 09:25:12 -0700 Subject: [PATCH 15/26] MQTT 5 allows passwords without usernames. --- gentests/app/Main.hs | 2 +- src/packet.c | 17 +- tests/generated.cpp | 17139 ++++++++++++++++++++++++++++++++--------- 3 files changed, 13417 insertions(+), 3741 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index fdfed5a..74fbc63 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -299,7 +299,7 @@ extern "C" { } \ } |] - let numTests = 10 + let numTests = 30 pubs <- replicateM numTests $ generate arbitrary f genPublishTest Protocol311 (v311PubReq <$> pubs) diff --git a/src/packet.c b/src/packet.c index 1d4e54e..4b3d759 100644 --- a/src/packet.c +++ b/src/packet.c @@ -235,11 +235,11 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw // add username if present to remaining length if (options.username.len > 0) { rem_len += options.username.len + 2; + } - // add password if present to remaining length - if (options.password.len > 0) { - rem_len += options.password.len + 2; - } + // add password if present to remaining length + if ((options.username.len > 0 || protocol == LWMQTT_MQTT5) && options.password.len > 0) { + rem_len += options.password.len + 2; } // check remaining length length @@ -293,11 +293,10 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw // set username flag if present if (options.username.len > 0) { lwmqtt_write_bits(&flags, 1, 7, 1); + } - // set password flag if present - if (options.password.len > 0) { - lwmqtt_write_bits(&flags, 1, 6, 1); - } + if ((options.username.len > 0 || protocol == LWMQTT_MQTT5) && options.password.len > 0) { + lwmqtt_write_bits(&flags, 1, 6, 1); } // write flags @@ -359,7 +358,7 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw } // write password if present - if (options.username.len > 0 && options.password.len > 0) { + if ((options.username.len > 0 || protocol == LWMQTT_MQTT5) && options.password.len > 0) { err = lwmqtt_write_string(&buf_ptr, buf_end, options.password); if (err != LWMQTT_SUCCESS) { return err; diff --git a/tests/generated.cpp b/tests/generated.cpp index dd52b9d..ad11a7a 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,45 +21,40 @@ extern "C" { } \ } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\225w\176\tH\164\231\182-s\240\201\201&@\253\162=", _pubPktID = 25394, _pubBody = -// "\185\216^\ACKI\148P\180>Z9\192\251\254\US\222C\159,\ACK\FS9\205\218@,o", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = ";\152\218", _pubPktID = 5070, +// _pubBody = "]&\234\205\156\200\SYN\185\NUL\214}\239\191\&6\154waT{\246\173\DC4k\155\211\190", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x3a, 0x31, 0x0, 0x12, 0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, - 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d, 0x63, 0x32, 0xb9, 0xd8, - 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, 0x1f, - 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; - uint8_t topic_bytes[] = {0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, - 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x21, 0x0, 0x3, 0x3b, 0x98, 0xda, 0x13, 0xce, 0x5d, 0x26, 0xea, + 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, 0x36, 0x9a, + 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; + uint8_t topic_bytes[] = {0x3b, 0x98, 0xda}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xb9, 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, - 0x1f, 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, + 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 26; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25394, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5070, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\225w\176\tH\164\231\182-s\240\201\201&@\253\162=", _pubPktID = 25394, _pubBody = -// "\185\216^\ACKI\148P\180>Z9\192\251\254\US\222C\159,\ACK\FS9\205\218@,o", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = ";\152\218", _pubPktID = 5070, +// _pubBody = "]&\234\205\156\200\SYN\185\NUL\214}\239\191\&6\154waT{\246\173\DC4k\155\211\190", _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x3a, 0x31, 0x0, 0x12, 0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, - 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d, 0x63, 0x32, 0xb9, 0xd8, - 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, 0x1f, - 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; + uint8_t pkt[] = {0x3d, 0x21, 0x0, 0x3, 0x3b, 0x98, 0xda, 0x13, 0xce, 0x5d, 0x26, 0xea, + 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, 0x36, 0x9a, + 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -67,57 +62,56 @@ TEST(Publish311QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, - 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb9, 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, - 0x1f, 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3b, 0x98, 0xda}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, + 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 25394); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 27); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 5070); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\132\188b\134\236\255\196\158q\191pM\229*\v\144\145\160\165h&\195", _pubPktID = 0, _pubBody = "\ETB\218", _pubProps -// = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\156n m\218\DC4\ENQ\RS\r\221", +// _pubPktID = 29842, _pubBody = "\n\r\194\171\&847\188\r\239=\228G\244\204\183o\136\148\223SQ", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x31, 0x1a, 0x0, 0x16, 0x84, 0xbc, 0x62, 0x86, 0xec, 0xff, 0xc4, 0x9e, 0x71, 0xbf, - 0x70, 0x4d, 0xe5, 0x2a, 0xb, 0x90, 0x91, 0xa0, 0xa5, 0x68, 0x26, 0xc3, 0x17, 0xda}; - uint8_t topic_bytes[] = {0x84, 0xbc, 0x62, 0x86, 0xec, 0xff, 0xc4, 0x9e, 0x71, 0xbf, 0x70, - 0x4d, 0xe5, 0x2a, 0xb, 0x90, 0x91, 0xa0, 0xa5, 0x68, 0x26, 0xc3}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x24, 0x0, 0xa, 0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, + 0xdd, 0x74, 0x92, 0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, 0xbc, 0xd, 0xef, + 0x3d, 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; + uint8_t topic_bytes[] = {0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, 0xdd}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x17, 0xda}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, 0xbc, 0xd, 0xef, 0x3d, + 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29842, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\132\188b\134\236\255\196\158q\191pM\229*\v\144\145\160\165h&\195", _pubPktID = 0, _pubBody = "\ETB\218", _pubProps -// = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\156n m\218\DC4\ENQ\RS\r\221", +// _pubPktID = 29842, _pubBody = "\n\r\194\171\&847\188\r\239=\228G\244\204\183o\136\148\223SQ", _pubProps = []} TEST(Publish311QCTest, Decode2) { - uint8_t pkt[] = {0x31, 0x1a, 0x0, 0x16, 0x84, 0xbc, 0x62, 0x86, 0xec, 0xff, 0xc4, 0x9e, 0x71, 0xbf, - 0x70, 0x4d, 0xe5, 0x2a, 0xb, 0x90, 0x91, 0xa0, 0xa5, 0x68, 0x26, 0xc3, 0x17, 0xda}; + uint8_t pkt[] = {0x3c, 0x24, 0x0, 0xa, 0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, + 0xdd, 0x74, 0x92, 0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, 0xbc, 0xd, 0xef, + 0x3d, 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -125,56 +119,54 @@ TEST(Publish311QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x84, 0xbc, 0x62, 0x86, 0xec, 0xff, 0xc4, 0x9e, 0x71, 0xbf, 0x70, - 0x4d, 0xe5, 0x2a, 0xb, 0x90, 0x91, 0xa0, 0xa5, 0x68, 0x26, 0xc3}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x17, 0xda}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + uint8_t exp_topic_bytes[] = {0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, 0xdd}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, 0xbc, 0xd, 0xef, 0x3d, + 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 29842); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\146,\173K\ETBBf8\150", _pubPktID = -// 137, _pubBody = "\EOTF\225\235\204\DC1\196\244\135L\239L|nO\178\220\210\173\181", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\SUB\143\217", _pubPktID = 816, +// _pubBody = "\246^\255t\204\180\169\214\150&=\195\235\249\176Q\NAK\169\145", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x33, 0x21, 0x0, 0x9, 0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, - 0x96, 0x0, 0x89, 0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, - 0x4c, 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; - uint8_t topic_bytes[] = {0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x1a, 0x0, 0x3, 0x1a, 0x8f, 0xd9, 0x3, 0x30, 0xf6, 0x5e, 0xff, 0x74, 0xcc, + 0xb4, 0xa9, 0xd6, 0x96, 0x26, 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; + uint8_t topic_bytes[] = {0x1a, 0x8f, 0xd9}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, 0x4c, - 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; + uint8_t msg_bytes[] = {0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, 0x26, + 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 137, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 816, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\146,\173K\ETBBf8\150", _pubPktID = -// 137, _pubBody = "\EOTF\225\235\204\DC1\196\244\135L\239L|nO\178\220\210\173\181", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\SUB\143\217", _pubPktID = 816, +// _pubBody = "\246^\255t\204\180\169\214\150&=\195\235\249\176Q\NAK\169\145", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x33, 0x21, 0x0, 0x9, 0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, - 0x96, 0x0, 0x89, 0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, - 0x4c, 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; + uint8_t pkt[] = {0x35, 0x1a, 0x0, 0x3, 0x1a, 0x8f, 0xd9, 0x3, 0x30, 0xf6, 0x5e, 0xff, 0x74, 0xcc, + 0xb4, 0xa9, 0xd6, 0x96, 0x26, 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -182,58 +174,54 @@ TEST(Publish311QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, 0x4c, - 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x1a, 0x8f, 0xd9}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, 0x26, + 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 137); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_EQ(packet_id, 816); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\187\245\185\SOH\nLz\249\&84\221t4:\ACKMBL", _pubPktID = 0, _pubBody = -// "+\154\198\134\210\202d\129:\164\205\152\155'n", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "", _pubPktID = 31057, _pubBody = +// "\199\189\167\ETX\187.\248)\192z\ESC\250{\169\157\255\224d\204\159\r\239\ESC\154Q\171\168", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x38, 0x23, 0x0, 0x12, 0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, - 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c, 0x2b, 0x9a, 0xc6, 0x86, - 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; - uint8_t topic_bytes[] = {0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, - 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x0, 0x79, 0x51, 0xc7, 0xbd, 0xa7, 0x3, 0xbb, 0x2e, 0xf8, 0x29, 0xc0, 0x7a, 0x1b, + 0xfa, 0x7b, 0xa9, 0x9d, 0xff, 0xe0, 0x64, 0xcc, 0x9f, 0xd, 0xef, 0x1b, 0x9a, 0x51, 0xab, 0xa8}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x2b, 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; + uint8_t msg_bytes[] = {0xc7, 0xbd, 0xa7, 0x3, 0xbb, 0x2e, 0xf8, 0x29, 0xc0, 0x7a, 0x1b, 0xfa, 0x7b, 0xa9, + 0x9d, 0xff, 0xe0, 0x64, 0xcc, 0x9f, 0xd, 0xef, 0x1b, 0x9a, 0x51, 0xab, 0xa8}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 27; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 31057, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\187\245\185\SOH\nLz\249\&84\221t4:\ACKMBL", _pubPktID = 0, _pubBody = -// "+\154\198\134\210\202d\129:\164\205\152\155'n", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "", _pubPktID = 31057, _pubBody = +// "\199\189\167\ETX\187.\248)\192z\ESC\250{\169\157\255\224d\204\159\r\239\ESC\154Q\171\168", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x38, 0x23, 0x0, 0x12, 0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, - 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c, 0x2b, 0x9a, 0xc6, 0x86, - 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; + uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x0, 0x79, 0x51, 0xc7, 0xbd, 0xa7, 0x3, 0xbb, 0x2e, 0xf8, 0x29, 0xc0, 0x7a, 0x1b, + 0xfa, 0x7b, 0xa9, 0x9d, 0xff, 0xe0, 0x64, 0xcc, 0x9f, 0xd, 0xef, 0x1b, 0x9a, 0x51, 0xab, 0xa8}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -241,58 +229,61 @@ TEST(Publish311QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, - 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2b, 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc7, 0xbd, 0xa7, 0x3, 0xbb, 0x2e, 0xf8, 0x29, 0xc0, 0x7a, 0x1b, 0xfa, 0x7b, 0xa9, + 0x9d, 0xff, 0xe0, 0x64, 0xcc, 0x9f, 0xd, 0xef, 0x1b, 0x9a, 0x51, 0xab, 0xa8}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 31057); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\242a\252\132ky\210\DC1\220\251*\163s8\DC4@\147\193\170=\251\131\th\RS\SUB", _pubPktID = 16832, _pubBody = -// "\177\211\211/\228\228B\191\NUL\b'\216\220\236\184", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "V\129\199\DEL\236d\144\134\234\&2\161\f\158;^\GS\152", _pubPktID = 0, _pubBody = +// "\168#\DC4\164\152d\226\231\214\203.3\\K\148y\227\211\138\130B\160L0\153\231\154\201\v0", _pubProps = []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x35, 0x2d, 0x0, 0x1a, 0xf2, 0x61, 0xfc, 0x84, 0x6b, 0x79, 0xd2, 0x11, 0xdc, 0xfb, 0x2a, 0xa3, - 0x73, 0x38, 0x14, 0x40, 0x93, 0xc1, 0xaa, 0x3d, 0xfb, 0x83, 0x9, 0x68, 0x1e, 0x1a, 0x41, 0xc0, - 0xb1, 0xd3, 0xd3, 0x2f, 0xe4, 0xe4, 0x42, 0xbf, 0x0, 0x8, 0x27, 0xd8, 0xdc, 0xec, 0xb8}; - uint8_t topic_bytes[] = {0xf2, 0x61, 0xfc, 0x84, 0x6b, 0x79, 0xd2, 0x11, 0xdc, 0xfb, 0x2a, 0xa3, 0x73, - 0x38, 0x14, 0x40, 0x93, 0xc1, 0xaa, 0x3d, 0xfb, 0x83, 0x9, 0x68, 0x1e, 0x1a}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x31, 0x0, 0x11, 0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, + 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98, 0xa8, 0x23, 0x14, 0xa4, 0x98, + 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, 0x79, 0xe3, 0xd3, + 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; + uint8_t topic_bytes[] = {0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, + 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xb1, 0xd3, 0xd3, 0x2f, 0xe4, 0xe4, 0x42, 0xbf, 0x0, 0x8, 0x27, 0xd8, 0xdc, 0xec, 0xb8}; + uint8_t msg_bytes[] = {0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, + 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 30; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16832, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\242a\252\132ky\210\DC1\220\251*\163s8\DC4@\147\193\170=\251\131\th\RS\SUB", _pubPktID = 16832, _pubBody = -// "\177\211\211/\228\228B\191\NUL\b'\216\220\236\184", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "V\129\199\DEL\236d\144\134\234\&2\161\f\158;^\GS\152", _pubPktID = 0, _pubBody = +// "\168#\DC4\164\152d\226\231\214\203.3\\K\148y\227\211\138\130B\160L0\153\231\154\201\v0", _pubProps = []} TEST(Publish311QCTest, Decode5) { - uint8_t pkt[] = {0x35, 0x2d, 0x0, 0x1a, 0xf2, 0x61, 0xfc, 0x84, 0x6b, 0x79, 0xd2, 0x11, 0xdc, 0xfb, 0x2a, 0xa3, - 0x73, 0x38, 0x14, 0x40, 0x93, 0xc1, 0xaa, 0x3d, 0xfb, 0x83, 0x9, 0x68, 0x1e, 0x1a, 0x41, 0xc0, - 0xb1, 0xd3, 0xd3, 0x2f, 0xe4, 0xe4, 0x42, 0xbf, 0x0, 0x8, 0x27, 0xd8, 0xdc, 0xec, 0xb8}; + uint8_t pkt[] = {0x39, 0x31, 0x0, 0x11, 0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, + 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98, 0xa8, 0x23, 0x14, 0xa4, 0x98, + 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, 0x79, 0xe3, 0xd3, + 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -300,37 +291,38 @@ TEST(Publish311QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf2, 0x61, 0xfc, 0x84, 0x6b, 0x79, 0xd2, 0x11, 0xdc, 0xfb, 0x2a, 0xa3, 0x73, - 0x38, 0x14, 0x40, 0x93, 0xc1, 0xaa, 0x3d, 0xfb, 0x83, 0x9, 0x68, 0x1e, 0x1a}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb1, 0xd3, 0xd3, 0x2f, 0xe4, 0xe4, 0x42, 0xbf, 0x0, 0x8, 0x27, 0xd8, 0xdc, 0xec, 0xb8}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, + 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98}; + lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, + 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 16832); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\&6", _pubPktID = 0, _pubBody = -// "\147\221\242\207\140+To \247\210\244", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\ESC\176mM-\183\&6\136p\203\156\172", _pubPktID = 0, _pubBody = "\DC2\166\130\180V\157\163bV", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x31, 0x10, 0x0, 0x2, 0xdd, 0x36, 0x93, 0xdd, 0xf2, - 0xcf, 0x8c, 0x2b, 0x54, 0x6f, 0x20, 0xf7, 0xd2, 0xf4}; - uint8_t topic_bytes[] = {0xdd, 0x36}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x17, 0x0, 0xc, 0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, + 0xcb, 0x9c, 0xac, 0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; + uint8_t topic_bytes[] = {0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x93, 0xdd, 0xf2, 0xcf, 0x8c, 0x2b, 0x54, 0x6f, 0x20, 0xf7, 0xd2, 0xf4}; + uint8_t msg_bytes[] = {0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 9; lwmqtt_property_t propslist[] = {}; @@ -342,11 +334,11 @@ TEST(Publish311QCTest, Encode6) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\&6", _pubPktID = 0, _pubBody = -// "\147\221\242\207\140+To \247\210\244", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\ESC\176mM-\183\&6\136p\203\156\172", _pubPktID = 0, _pubBody = "\DC2\166\130\180V\157\163bV", _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x31, 0x10, 0x0, 0x2, 0xdd, 0x36, 0x93, 0xdd, 0xf2, - 0xcf, 0x8c, 0x2b, 0x54, 0x6f, 0x20, 0xf7, 0xd2, 0xf4}; + uint8_t pkt[] = {0x31, 0x17, 0x0, 0xc, 0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, + 0xcb, 0x9c, 0xac, 0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -354,58 +346,52 @@ TEST(Publish311QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xdd, 0x36}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x93, 0xdd, 0xf2, 0xcf, 0x8c, 0x2b, 0x54, 0x6f, 0x20, 0xf7, 0xd2, 0xf4}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\t[\147\134\211N\220\217R\CAN\NAK\\\186G\DLE\137\189\166\158\221=\171", _pubPktID = 2127, _pubBody = -// "n\\\\\STX\237\196\179\185\241\214\171\SO'\156\228!\240\230\146", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\178\SI\169\146\239\178\SYN\STX", +// _pubPktID = 0, _pubBody = "K\148\ETX%\135\&7\194\158\DLE\ENQ\215\157\176\ESCA\f", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x3c, 0x2d, 0x0, 0x16, 0x9, 0x5b, 0x93, 0x86, 0xd3, 0x4e, 0xdc, 0xd9, 0x52, 0x18, 0x15, 0x5c, - 0xba, 0x47, 0x10, 0x89, 0xbd, 0xa6, 0x9e, 0xdd, 0x3d, 0xab, 0x8, 0x4f, 0x6e, 0x5c, 0x5c, 0x2, - 0xed, 0xc4, 0xb3, 0xb9, 0xf1, 0xd6, 0xab, 0xe, 0x27, 0x9c, 0xe4, 0x21, 0xf0, 0xe6, 0x92}; - uint8_t topic_bytes[] = {0x9, 0x5b, 0x93, 0x86, 0xd3, 0x4e, 0xdc, 0xd9, 0x52, 0x18, 0x15, - 0x5c, 0xba, 0x47, 0x10, 0x89, 0xbd, 0xa6, 0x9e, 0xdd, 0x3d, 0xab}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x1a, 0x0, 0x8, 0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2, 0x4b, 0x94, + 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; + uint8_t topic_bytes[] = {0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x6e, 0x5c, 0x5c, 0x2, 0xed, 0xc4, 0xb3, 0xb9, 0xf1, 0xd6, - 0xab, 0xe, 0x27, 0x9c, 0xe4, 0x21, 0xf0, 0xe6, 0x92}; + uint8_t msg_bytes[] = {0x4b, 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 16; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2127, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\t[\147\134\211N\220\217R\CAN\NAK\\\186G\DLE\137\189\166\158\221=\171", _pubPktID = 2127, _pubBody = -// "n\\\\\STX\237\196\179\185\241\214\171\SO'\156\228!\240\230\146", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\178\SI\169\146\239\178\SYN\STX", +// _pubPktID = 0, _pubBody = "K\148\ETX%\135\&7\194\158\DLE\ENQ\215\157\176\ESCA\f", _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x3c, 0x2d, 0x0, 0x16, 0x9, 0x5b, 0x93, 0x86, 0xd3, 0x4e, 0xdc, 0xd9, 0x52, 0x18, 0x15, 0x5c, - 0xba, 0x47, 0x10, 0x89, 0xbd, 0xa6, 0x9e, 0xdd, 0x3d, 0xab, 0x8, 0x4f, 0x6e, 0x5c, 0x5c, 0x2, - 0xed, 0xc4, 0xb3, 0xb9, 0xf1, 0xd6, 0xab, 0xe, 0x27, 0x9c, 0xe4, 0x21, 0xf0, 0xe6, 0x92}; + uint8_t pkt[] = {0x30, 0x1a, 0x0, 0x8, 0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2, 0x4b, 0x94, + 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -413,39 +399,38 @@ TEST(Publish311QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9, 0x5b, 0x93, 0x86, 0xd3, 0x4e, 0xdc, 0xd9, 0x52, 0x18, 0x15, - 0x5c, 0xba, 0x47, 0x10, 0x89, 0xbd, 0xa6, 0x9e, 0xdd, 0x3d, 0xab}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x6e, 0x5c, 0x5c, 0x2, 0xed, 0xc4, 0xb3, 0xb9, 0xf1, 0xd6, - 0xab, 0xe, 0x27, 0x9c, 0xe4, 0x21, 0xf0, 0xe6, 0x92}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4b, 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, + 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2127); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\148\134\&7\254W\239\197z\v\194\253\227\173o\163\251m\138", _pubPktID = 0, _pubBody = -// "\136i\178\239\188AL\167x\230\227\NULnK\187", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\164Y\252JlD$\198\DC1l\vM\194\NAK\194I\144\STX:c\158)N*", _pubPktID = 7891, _pubBody = +// "\176\162\NAK'B\224M\185\SYNa\n\151\146\160U", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x30, 0x23, 0x0, 0x12, 0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, - 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a, 0x88, 0x69, 0xb2, 0xef, - 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; - uint8_t topic_bytes[] = {0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, - 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x2b, 0x0, 0x18, 0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, + 0x4d, 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a, 0x1e, 0xd3, + 0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; + uint8_t topic_bytes[] = {0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, 0x4d, + 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x88, 0x69, 0xb2, 0xef, 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 15; @@ -453,19 +438,19 @@ TEST(Publish311QCTest, Encode8) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7891, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\148\134\&7\254W\239\197z\v\194\253\227\173o\163\251m\138", _pubPktID = 0, _pubBody = -// "\136i\178\239\188AL\167x\230\227\NULnK\187", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\164Y\252JlD$\198\DC1l\vM\194\NAK\194I\144\STX:c\158)N*", _pubPktID = 7891, _pubBody = +// "\176\162\NAK'B\224M\185\SYNa\n\151\146\160U", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x30, 0x23, 0x0, 0x12, 0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, - 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a, 0x88, 0x69, 0xb2, 0xef, - 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; + uint8_t pkt[] = {0x35, 0x2b, 0x0, 0x18, 0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, + 0x4d, 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a, 0x1e, 0xd3, + 0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -473,38 +458,39 @@ TEST(Publish311QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, - 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x88, 0x69, 0xb2, 0xef, 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; + uint8_t exp_topic_bytes[] = {0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, 0x4d, + 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 7891); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); EXPECT_EQ(msg.payload_len, 15); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "V\DC1\RS\130\DLE\233\142\210e4%k~\132\153", _pubPktID = 0, _pubBody = -// "\200\ENQr=\212\221i\147\216\&3\ENQpG\250\147", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\168\NAKx\SI\199\207\184(\186\150r\FS\189\205\252\135\250\205\254\148\161\239\228\176s", _pubPktID = 0, _pubBody = +// "\135", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x30, 0x20, 0x0, 0xf, 0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, 0x65, 0x34, 0x25, 0x6b, 0x7e, - 0x84, 0x99, 0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; - uint8_t topic_bytes[] = {0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, 0x65, 0x34, 0x25, 0x6b, 0x7e, 0x84, 0x99}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x1c, 0x0, 0x19, 0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, + 0x1c, 0xbd, 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73, 0x87}; + uint8_t topic_bytes[] = {0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, 0xbd, + 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; + msg.retained = true; + uint8_t msg_bytes[] = {0x87}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 1; lwmqtt_property_t propslist[] = {}; @@ -516,12 +502,12 @@ TEST(Publish311QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "V\DC1\RS\130\DLE\233\142\210e4%k~\132\153", _pubPktID = 0, _pubBody = -// "\200\ENQr=\212\221i\147\216\&3\ENQpG\250\147", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\168\NAKx\SI\199\207\184(\186\150r\FS\189\205\252\135\250\205\254\148\161\239\228\176s", _pubPktID = 0, _pubBody = +// "\135", _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x30, 0x20, 0x0, 0xf, 0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, 0x65, 0x34, 0x25, 0x6b, 0x7e, - 0x84, 0x99, 0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; + uint8_t pkt[] = {0x31, 0x1c, 0x0, 0x19, 0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, + 0x1c, 0xbd, 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73, 0x87}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -529,59 +515,54 @@ TEST(Publish311QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, - 0x65, 0x34, 0x25, 0x6b, 0x7e, 0x84, 0x99}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, 0xbd, + 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x87}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\160\NAK\234\249\209\141\136\198?\243\245hW6\199=`\243C|RQ\216v@\r", _pubPktID = 19217, _pubBody = -// "\212m\146de\171\221qv\142\228\171\234S7\162", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\140r\DC3\130\161\ENQ", _pubPktID = +// 6491, _pubBody = "\241G\235!\175\252\158\183\145\224\246\172\SYN\130\131/\254\205\ENQ\GS?", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x1a, 0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, - 0x57, 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd, 0x4b, 0x11, - 0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; - uint8_t topic_bytes[] = {0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, - 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x6, 0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5, 0x19, 0x5b, 0xf1, 0x47, 0xeb, 0x21, 0xaf, + 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; + uint8_t topic_bytes[] = {0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, - 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; + uint8_t msg_bytes[] = {0xf1, 0x47, 0xeb, 0x21, 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, + 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19217, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6491, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\160\NAK\234\249\209\141\136\198?\243\245hW6\199=`\243C|RQ\216v@\r", _pubPktID = 19217, _pubBody = -// "\212m\146de\171\221qv\142\228\171\234S7\162", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\140r\DC3\130\161\ENQ", _pubPktID = +// 6491, _pubBody = "\241G\235!\175\252\158\183\145\224\246\172\SYN\130\131/\254\205\ENQ\GS?", _pubProps = []} TEST(Publish311QCTest, Decode10) { - uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x1a, 0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, - 0x57, 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd, 0x4b, 0x11, - 0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; + uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x6, 0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5, 0x19, 0x5b, 0xf1, 0x47, 0xeb, 0x21, 0xaf, + 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -589,2031 +570,9307 @@ TEST(Publish311QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, - 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, - 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf1, 0x47, 0xeb, 0x21, 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, + 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 19217); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(packet_id, 6491); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\225w\176\tH\164\231\182-s\240\201\201&@\253\162=", _pubPktID = 25394, _pubBody = -// "\185\216^\ACKI\148P\180>Z9\192\251\254\US\222C\159,\ACK\FS9\205\218@,o", _pubProps = [PropMessageExpiryInterval -// 27711,PropContentType -// "\204\140N\146\vX\bI\130\SOH@'\ETX\182\153\228\142\DC1\247\199R\244",PropWildcardSubscriptionAvailable -// 60,PropWildcardSubscriptionAvailable 45,PropResponseTopic -// "\DEL%\181E\EOT\168\169W?u.;\167\236-\ETX$\USt@\189T\237p\210=",PropAuthenticationData "\161",PropTopicAliasMaximum -// 11625,PropMaximumPacketSize 920,PropSharedSubscriptionAvailable 60,PropWillDelayInterval -// 13422,PropSessionExpiryInterval 17640,PropWildcardSubscriptionAvailable 208,PropMaximumPacketSize -// 13876,PropMaximumQoS 30,PropAuthenticationData "P\128U\"\151\193\151D\169\&8"]} -TEST(Publish5QCTest, Encode1) { - uint8_t pkt[] = {0x3a, 0x9f, 0x1, 0x0, 0x12, 0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, 0x73, 0xf0, 0xc9, - 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d, 0x63, 0x32, 0x6d, 0x2, 0x0, 0x0, 0x6c, 0x3f, 0x3, 0x0, 0x16, - 0xcc, 0x8c, 0x4e, 0x92, 0xb, 0x58, 0x8, 0x49, 0x82, 0x1, 0x40, 0x27, 0x3, 0xb6, 0x99, 0xe4, 0x8e, - 0x11, 0xf7, 0xc7, 0x52, 0xf4, 0x28, 0x3c, 0x28, 0x2d, 0x8, 0x0, 0x1a, 0x7f, 0x25, 0xb5, 0x45, 0x4, - 0xa8, 0xa9, 0x57, 0x3f, 0x75, 0x2e, 0x3b, 0xa7, 0xec, 0x2d, 0x3, 0x24, 0x1f, 0x74, 0x40, 0xbd, 0x54, - 0xed, 0x70, 0xd2, 0x3d, 0x16, 0x0, 0x1, 0xa1, 0x22, 0x2d, 0x69, 0x27, 0x0, 0x0, 0x3, 0x98, 0x2a, - 0x3c, 0x18, 0x0, 0x0, 0x34, 0x6e, 0x11, 0x0, 0x0, 0x44, 0xe8, 0x28, 0xd0, 0x27, 0x0, 0x0, 0x36, - 0x34, 0x24, 0x1e, 0x16, 0x0, 0xa, 0x50, 0x80, 0x55, 0x22, 0x97, 0xc1, 0x97, 0x44, 0xa9, 0x38, 0xb9, - 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, 0x1f, 0xde, 0x43, 0x9f, - 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; - uint8_t topic_bytes[] = {0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, - 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\239\238\236\203\SI", _pubPktID = +// 8912, _pubBody = "\fH\EOT\166q\ESC\ESC\185\177A", _pubProps = []} +TEST(Publish311QCTest, Encode11) { + uint8_t pkt[] = {0x32, 0x13, 0x0, 0x5, 0xef, 0xee, 0xec, 0xcb, 0xf, 0x22, 0xd0, + 0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; + uint8_t topic_bytes[] = {0xef, 0xee, 0xec, 0xcb, 0xf}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xb9, 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, - 0x1f, 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; + uint8_t msg_bytes[] = {0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; - - uint8_t bytesprops0[] = {0xcc, 0x8c, 0x4e, 0x92, 0xb, 0x58, 0x8, 0x49, 0x82, 0x1, 0x40, - 0x27, 0x3, 0xb6, 0x99, 0xe4, 0x8e, 0x11, 0xf7, 0xc7, 0x52, 0xf4}; - uint8_t bytesprops1[] = {0x7f, 0x25, 0xb5, 0x45, 0x4, 0xa8, 0xa9, 0x57, 0x3f, 0x75, 0x2e, 0x3b, 0xa7, - 0xec, 0x2d, 0x3, 0x24, 0x1f, 0x74, 0x40, 0xbd, 0x54, 0xed, 0x70, 0xd2, 0x3d}; - uint8_t bytesprops2[] = {0xa1}; - uint8_t bytesprops3[] = {0x50, 0x80, 0x55, 0x22, 0x97, 0xc1, 0x97, 0x44, 0xa9, 0x38}; + msg.payload_len = 10; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27711}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11625}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 920}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13422}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17640}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13876}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops3}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25394, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8912, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\225w\176\tH\164\231\182-s\240\201\201&@\253\162=", _pubPktID = 25394, _pubBody = -// "\185\216^\ACKI\148P\180>Z9\192\251\254\US\222C\159,\ACK\FS9\205\218@,o", _pubProps = [PropMessageExpiryInterval -// 27711,PropContentType -// "\204\140N\146\vX\bI\130\SOH@'\ETX\182\153\228\142\DC1\247\199R\244",PropWildcardSubscriptionAvailable -// 60,PropWildcardSubscriptionAvailable 45,PropResponseTopic -// "\DEL%\181E\EOT\168\169W?u.;\167\236-\ETX$\USt@\189T\237p\210=",PropAuthenticationData "\161",PropTopicAliasMaximum -// 11625,PropMaximumPacketSize 920,PropSharedSubscriptionAvailable 60,PropWillDelayInterval -// 13422,PropSessionExpiryInterval 17640,PropWildcardSubscriptionAvailable 208,PropMaximumPacketSize -// 13876,PropMaximumQoS 30,PropAuthenticationData "P\128U\"\151\193\151D\169\&8"]} -TEST(Publish5QCTest, Decode1) { - uint8_t pkt[] = {0x3a, 0x9f, 0x1, 0x0, 0x12, 0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, 0x73, 0xf0, 0xc9, - 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d, 0x63, 0x32, 0x6d, 0x2, 0x0, 0x0, 0x6c, 0x3f, 0x3, 0x0, 0x16, - 0xcc, 0x8c, 0x4e, 0x92, 0xb, 0x58, 0x8, 0x49, 0x82, 0x1, 0x40, 0x27, 0x3, 0xb6, 0x99, 0xe4, 0x8e, - 0x11, 0xf7, 0xc7, 0x52, 0xf4, 0x28, 0x3c, 0x28, 0x2d, 0x8, 0x0, 0x1a, 0x7f, 0x25, 0xb5, 0x45, 0x4, - 0xa8, 0xa9, 0x57, 0x3f, 0x75, 0x2e, 0x3b, 0xa7, 0xec, 0x2d, 0x3, 0x24, 0x1f, 0x74, 0x40, 0xbd, 0x54, - 0xed, 0x70, 0xd2, 0x3d, 0x16, 0x0, 0x1, 0xa1, 0x22, 0x2d, 0x69, 0x27, 0x0, 0x0, 0x3, 0x98, 0x2a, - 0x3c, 0x18, 0x0, 0x0, 0x34, 0x6e, 0x11, 0x0, 0x0, 0x44, 0xe8, 0x28, 0xd0, 0x27, 0x0, 0x0, 0x36, - 0x34, 0x24, 0x1e, 0x16, 0x0, 0xa, 0x50, 0x80, 0x55, 0x22, 0x97, 0xc1, 0x97, 0x44, 0xa9, 0x38, 0xb9, - 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, 0x1f, 0xde, 0x43, 0x9f, - 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\239\238\236\203\SI", _pubPktID = +// 8912, _pubBody = "\fH\EOT\166q\ESC\ESC\185\177A", _pubProps = []} +TEST(Publish311QCTest, Decode11) { + uint8_t pkt[] = {0x32, 0x13, 0x0, 0x5, 0xef, 0xee, 0xec, 0xcb, 0xf, 0x22, 0xd0, + 0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe1, 0x77, 0xb0, 0x9, 0x48, 0xa4, 0xe7, 0xb6, 0x2d, - 0x73, 0xf0, 0xc9, 0xc9, 0x26, 0x40, 0xfd, 0xa2, 0x3d}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb9, 0xd8, 0x5e, 0x6, 0x49, 0x94, 0x50, 0xb4, 0x3e, 0x5a, 0x39, 0xc0, 0xfb, 0xfe, - 0x1f, 0xde, 0x43, 0x9f, 0x2c, 0x6, 0x1c, 0x39, 0xcd, 0xda, 0x40, 0x2c, 0x6f}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xef, 0xee, 0xec, 0xcb, 0xf}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 25394); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 27); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + EXPECT_EQ(packet_id, 8912); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\132\188b\134\236\255\196\158q\191pM\229*\v\144\145\160\165h&\195", _pubPktID = 0, _pubBody = "\ETB\218", _pubProps -// = [PropSubscriptionIdentifier 19,PropMessageExpiryInterval 9382,PropMessageExpiryInterval 14873,PropContentType -// "2\144",PropSessionExpiryInterval 17417,PropServerReference "\239l\200n'",PropMaximumPacketSize -// 25096,PropSessionExpiryInterval 28634,PropReasonString "\182\181\RS\239"]} -TEST(Publish5QCTest, Encode2) { - uint8_t pkt[] = {0x31, 0x4a, 0x0, 0x16, 0x84, 0xbc, 0x62, 0x86, 0xec, 0xff, 0xc4, 0x9e, 0x71, 0xbf, 0x70, 0x4d, - 0xe5, 0x2a, 0xb, 0x90, 0x91, 0xa0, 0xa5, 0x68, 0x26, 0xc3, 0x2f, 0xb, 0x13, 0x2, 0x0, 0x0, - 0x24, 0xa6, 0x2, 0x0, 0x0, 0x3a, 0x19, 0x3, 0x0, 0x2, 0x32, 0x90, 0x11, 0x0, 0x0, 0x44, - 0x9, 0x1c, 0x0, 0x5, 0xef, 0x6c, 0xc8, 0x6e, 0x27, 0x27, 0x0, 0x0, 0x62, 0x8, 0x11, 0x0, - 0x0, 0x6f, 0xda, 0x1f, 0x0, 0x4, 0xb6, 0xb5, 0x1e, 0xef, 0x17, 0xda}; - uint8_t topic_bytes[] = {0x84, 0xbc, 0x62, 0x86, 0xec, 0xff, 0xc4, 0x9e, 0x71, 0xbf, 0x70, - 0x4d, 0xe5, 0x2a, 0xb, 0x90, 0x91, 0xa0, 0xa5, 0x68, 0x26, 0xc3}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "[", _pubPktID = 16570, _pubBody = +// "\173\247\147\148\f{|ku\211\&0\DC3\224\227di\ETX\214[\DEL\138I\133\r8{", _pubProps = []} +TEST(Publish311QCTest, Encode12) { + uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x1, 0x5b, 0x40, 0xba, 0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, + 0x30, 0x13, 0xe0, 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; + uint8_t topic_bytes[] = {0x5b}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x17, 0xda}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, 0x30, 0x13, 0xe0, + 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 26; - uint8_t bytesprops0[] = {0x32, 0x90}; - uint8_t bytesprops1[] = {0xef, 0x6c, 0xc8, 0x6e, 0x27}; - uint8_t bytesprops2[] = {0xb6, 0xb5, 0x1e, 0xef}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9382}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14873}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17417}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25096}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28634}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops2}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16570, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\132\188b\134\236\255\196\158q\191pM\229*\v\144\145\160\165h&\195", _pubPktID = 0, _pubBody = "\ETB\218", _pubProps -// = [PropSubscriptionIdentifier 19,PropMessageExpiryInterval 9382,PropMessageExpiryInterval 14873,PropContentType -// "2\144",PropSessionExpiryInterval 17417,PropServerReference "\239l\200n'",PropMaximumPacketSize -// 25096,PropSessionExpiryInterval 28634,PropReasonString "\182\181\RS\239"]} -TEST(Publish5QCTest, Decode2) { - uint8_t pkt[] = {0x31, 0x4a, 0x0, 0x16, 0x84, 0xbc, 0x62, 0x86, 0xec, 0xff, 0xc4, 0x9e, 0x71, 0xbf, 0x70, 0x4d, - 0xe5, 0x2a, 0xb, 0x90, 0x91, 0xa0, 0xa5, 0x68, 0x26, 0xc3, 0x2f, 0xb, 0x13, 0x2, 0x0, 0x0, - 0x24, 0xa6, 0x2, 0x0, 0x0, 0x3a, 0x19, 0x3, 0x0, 0x2, 0x32, 0x90, 0x11, 0x0, 0x0, 0x44, - 0x9, 0x1c, 0x0, 0x5, 0xef, 0x6c, 0xc8, 0x6e, 0x27, 0x27, 0x0, 0x0, 0x62, 0x8, 0x11, 0x0, - 0x0, 0x6f, 0xda, 0x1f, 0x0, 0x4, 0xb6, 0xb5, 0x1e, 0xef, 0x17, 0xda}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "[", _pubPktID = 16570, _pubBody = +// "\173\247\147\148\f{|ku\211\&0\DC3\224\227di\ETX\214[\DEL\138I\133\r8{", _pubProps = []} +TEST(Publish311QCTest, Decode12) { + uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x1, 0x5b, 0x40, 0xba, 0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, + 0x30, 0x13, 0xe0, 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x84, 0xbc, 0x62, 0x86, 0xec, 0xff, 0xc4, 0x9e, 0x71, 0xbf, 0x70, - 0x4d, 0xe5, 0x2a, 0xb, 0x90, 0x91, 0xa0, 0xa5, 0x68, 0x26, 0xc3}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x17, 0xda}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + uint8_t exp_topic_bytes[] = {0x5b}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, 0x30, 0x13, 0xe0, + 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 16570); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\146,\173K\ETBBf8\150", _pubPktID = -// 137, _pubBody = "\EOTF\225\235\204\DC1\196\244\135L\239L|nO\178\220\210\173\181", _pubProps = -// [PropResponseInformation -// "\168\187\241F\ETX\DC3\226\235\216?P\236\139p3\137\ENQG\US\171\182\201+U\227\FS\239S",PropReasonString -// "!\212\NAKt\223\170\223\228\158\216\161[@\235\207\t",PropSubscriptionIdentifier 7,PropMaximumPacketSize -// 1128,PropRequestResponseInformation 151,PropContentType -// "\\\182\217\180\DC3\144C\178\191w3\176\185w\187\176\213\164'B\157",PropResponseTopic -// "\213x\192RF\DLE\DC3\170\182Y\SON\132\170\221\FSG8R"]} -TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = {0x33, 0x8b, 0x1, 0x0, 0x9, 0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96, 0x0, 0x89, - 0x69, 0x1a, 0x0, 0x1c, 0xa8, 0xbb, 0xf1, 0x46, 0x3, 0x13, 0xe2, 0xeb, 0xd8, 0x3f, 0x50, 0xec, - 0x8b, 0x70, 0x33, 0x89, 0x5, 0x47, 0x1f, 0xab, 0xb6, 0xc9, 0x2b, 0x55, 0xe3, 0x1c, 0xef, 0x53, - 0x1f, 0x0, 0x10, 0x21, 0xd4, 0x15, 0x74, 0xdf, 0xaa, 0xdf, 0xe4, 0x9e, 0xd8, 0xa1, 0x5b, 0x40, - 0xeb, 0xcf, 0x9, 0xb, 0x7, 0x27, 0x0, 0x0, 0x4, 0x68, 0x19, 0x97, 0x3, 0x0, 0x15, 0x5c, - 0xb6, 0xd9, 0xb4, 0x13, 0x90, 0x43, 0xb2, 0xbf, 0x77, 0x33, 0xb0, 0xb9, 0x77, 0xbb, 0xb0, 0xd5, - 0xa4, 0x27, 0x42, 0x9d, 0x8, 0x0, 0x13, 0xd5, 0x78, 0xc0, 0x52, 0x46, 0x10, 0x13, 0xaa, 0xb6, - 0x59, 0xe, 0x4e, 0x84, 0xaa, 0xdd, 0x1c, 0x47, 0x38, 0x52, 0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, - 0xc4, 0xf4, 0x87, 0x4c, 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; - uint8_t topic_bytes[] = {0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\187Ue\150\168f\243G", _pubPktID = +// 0, _pubBody = "Y\133", _pubProps = []} +TEST(Publish311QCTest, Encode13) { + uint8_t pkt[] = {0x38, 0xc, 0x0, 0x8, 0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47, 0x59, 0x85}; + uint8_t topic_bytes[] = {0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, 0x4c, - 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x59, 0x85}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; - - uint8_t bytesprops0[] = {0xa8, 0xbb, 0xf1, 0x46, 0x3, 0x13, 0xe2, 0xeb, 0xd8, 0x3f, 0x50, 0xec, 0x8b, 0x70, - 0x33, 0x89, 0x5, 0x47, 0x1f, 0xab, 0xb6, 0xc9, 0x2b, 0x55, 0xe3, 0x1c, 0xef, 0x53}; - uint8_t bytesprops1[] = {0x21, 0xd4, 0x15, 0x74, 0xdf, 0xaa, 0xdf, 0xe4, - 0x9e, 0xd8, 0xa1, 0x5b, 0x40, 0xeb, 0xcf, 0x9}; - uint8_t bytesprops2[] = {0x5c, 0xb6, 0xd9, 0xb4, 0x13, 0x90, 0x43, 0xb2, 0xbf, 0x77, 0x33, - 0xb0, 0xb9, 0x77, 0xbb, 0xb0, 0xd5, 0xa4, 0x27, 0x42, 0x9d}; - uint8_t bytesprops3[] = {0xd5, 0x78, 0xc0, 0x52, 0x46, 0x10, 0x13, 0xaa, 0xb6, 0x59, - 0xe, 0x4e, 0x84, 0xaa, 0xdd, 0x1c, 0x47, 0x38, 0x52}; + msg.payload_len = 2; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1128}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops3}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 137, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\146,\173K\ETBBf8\150", _pubPktID = -// 137, _pubBody = "\EOTF\225\235\204\DC1\196\244\135L\239L|nO\178\220\210\173\181", _pubProps = -// [PropResponseInformation -// "\168\187\241F\ETX\DC3\226\235\216?P\236\139p3\137\ENQG\US\171\182\201+U\227\FS\239S",PropReasonString -// "!\212\NAKt\223\170\223\228\158\216\161[@\235\207\t",PropSubscriptionIdentifier 7,PropMaximumPacketSize -// 1128,PropRequestResponseInformation 151,PropContentType -// "\\\182\217\180\DC3\144C\178\191w3\176\185w\187\176\213\164'B\157",PropResponseTopic -// "\213x\192RF\DLE\DC3\170\182Y\SON\132\170\221\FSG8R"]} -TEST(Publish5QCTest, Decode3) { - uint8_t pkt[] = {0x33, 0x8b, 0x1, 0x0, 0x9, 0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96, 0x0, 0x89, - 0x69, 0x1a, 0x0, 0x1c, 0xa8, 0xbb, 0xf1, 0x46, 0x3, 0x13, 0xe2, 0xeb, 0xd8, 0x3f, 0x50, 0xec, - 0x8b, 0x70, 0x33, 0x89, 0x5, 0x47, 0x1f, 0xab, 0xb6, 0xc9, 0x2b, 0x55, 0xe3, 0x1c, 0xef, 0x53, - 0x1f, 0x0, 0x10, 0x21, 0xd4, 0x15, 0x74, 0xdf, 0xaa, 0xdf, 0xe4, 0x9e, 0xd8, 0xa1, 0x5b, 0x40, - 0xeb, 0xcf, 0x9, 0xb, 0x7, 0x27, 0x0, 0x0, 0x4, 0x68, 0x19, 0x97, 0x3, 0x0, 0x15, 0x5c, - 0xb6, 0xd9, 0xb4, 0x13, 0x90, 0x43, 0xb2, 0xbf, 0x77, 0x33, 0xb0, 0xb9, 0x77, 0xbb, 0xb0, 0xd5, - 0xa4, 0x27, 0x42, 0x9d, 0x8, 0x0, 0x13, 0xd5, 0x78, 0xc0, 0x52, 0x46, 0x10, 0x13, 0xaa, 0xb6, - 0x59, 0xe, 0x4e, 0x84, 0xaa, 0xdd, 0x1c, 0x47, 0x38, 0x52, 0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, - 0xc4, 0xf4, 0x87, 0x4c, 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\187Ue\150\168f\243G", _pubPktID = +// 0, _pubBody = "Y\133", _pubProps = []} +TEST(Publish311QCTest, Decode13) { + uint8_t pkt[] = {0x38, 0xc, 0x0, 0x8, 0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47, 0x59, 0x85}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x92, 0x2c, 0xad, 0x4b, 0x17, 0x42, 0x66, 0x38, 0x96}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4, 0x46, 0xe1, 0xeb, 0xcc, 0x11, 0xc4, 0xf4, 0x87, 0x4c, - 0xef, 0x4c, 0x7c, 0x6e, 0x4f, 0xb2, 0xdc, 0xd2, 0xad, 0xb5}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 137); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + uint8_t exp_topic_bytes[] = {0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x59, 0x85}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\187\245\185\SOH\nLz\249\&84\221t4:\ACKMBL", _pubPktID = 0, _pubBody = -// "+\154\198\134\210\202d\129:\164\205\152\155'n", _pubProps = [PropResponseTopic -// "|2\DC1,\157\216\160\155~B\255\169\245\132",PropServerReference -// "\138\205y\bC\181\165\157\235H\200\SOH\137\218\141qZ\243)\DEL\196\232\228<\164",PropRequestResponseInformation -// 183,PropCorrelationData "\247\163[\152\ETB\190t\f\193\SUB",PropMaximumPacketSize 11719,PropAuthenticationData -// "\134Xh\141eI",PropRequestProblemInformation 210,PropSubscriptionIdentifierAvailable 109,PropMessageExpiryInterval -// 25460,PropRetainAvailable 26,PropSubscriptionIdentifierAvailable 168,PropReasonString -// "\146\&8@\SYN\224G\185l\203\160\163\254\206\152",PropPayloadFormatIndicator 60,PropAuthenticationMethod -// "__]qE\180\\\169\199\183\237\&9VH!\151p\238\ETX\241",PropRequestResponseInformation -// 110,PropRequestResponseInformation 156,PropContentType "O",PropWildcardSubscriptionAvailable 11,PropWillDelayInterval -// 18099]} -TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = {0x38, 0xb5, 0x1, 0x0, 0x12, 0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, 0x34, 0xdd, 0x74, - 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c, 0x90, 0x1, 0x8, 0x0, 0xe, 0x7c, 0x32, 0x11, 0x2c, 0x9d, 0xd8, - 0xa0, 0x9b, 0x7e, 0x42, 0xff, 0xa9, 0xf5, 0x84, 0x1c, 0x0, 0x19, 0x8a, 0xcd, 0x79, 0x8, 0x43, 0xb5, - 0xa5, 0x9d, 0xeb, 0x48, 0xc8, 0x1, 0x89, 0xda, 0x8d, 0x71, 0x5a, 0xf3, 0x29, 0x7f, 0xc4, 0xe8, 0xe4, - 0x3c, 0xa4, 0x19, 0xb7, 0x9, 0x0, 0xa, 0xf7, 0xa3, 0x5b, 0x98, 0x17, 0xbe, 0x74, 0xc, 0xc1, 0x1a, - 0x27, 0x0, 0x0, 0x2d, 0xc7, 0x16, 0x0, 0x6, 0x86, 0x58, 0x68, 0x8d, 0x65, 0x49, 0x17, 0xd2, 0x29, - 0x6d, 0x2, 0x0, 0x0, 0x63, 0x74, 0x25, 0x1a, 0x29, 0xa8, 0x1f, 0x0, 0xe, 0x92, 0x38, 0x40, 0x16, - 0xe0, 0x47, 0xb9, 0x6c, 0xcb, 0xa0, 0xa3, 0xfe, 0xce, 0x98, 0x1, 0x3c, 0x15, 0x0, 0x14, 0x5f, 0x5f, - 0x5d, 0x71, 0x45, 0xb4, 0x5c, 0xa9, 0xc7, 0xb7, 0xed, 0x39, 0x56, 0x48, 0x21, 0x97, 0x70, 0xee, 0x3, - 0xf1, 0x19, 0x6e, 0x19, 0x9c, 0x3, 0x0, 0x1, 0x4f, 0x28, 0xb, 0x18, 0x0, 0x0, 0x46, 0xb3, 0x2b, - 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; - uint8_t topic_bytes[] = {0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, - 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\165\&4\a\246}\148\174\&8\186i\137\223\STX*Sv", _pubPktID = 0, _pubBody = "\243\233\SOH\134\243=c\212", _pubProps = +// []} +TEST(Publish311QCTest, Encode14) { + uint8_t pkt[] = {0x30, 0x1a, 0x0, 0x10, 0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, 0xba, 0x69, + 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76, 0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + uint8_t topic_bytes[] = {0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, + 0xba, 0x69, 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x2b, 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; + uint8_t msg_bytes[] = {0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0x7c, 0x32, 0x11, 0x2c, 0x9d, 0xd8, 0xa0, 0x9b, 0x7e, 0x42, 0xff, 0xa9, 0xf5, 0x84}; - uint8_t bytesprops1[] = {0x8a, 0xcd, 0x79, 0x8, 0x43, 0xb5, 0xa5, 0x9d, 0xeb, 0x48, 0xc8, 0x1, 0x89, - 0xda, 0x8d, 0x71, 0x5a, 0xf3, 0x29, 0x7f, 0xc4, 0xe8, 0xe4, 0x3c, 0xa4}; - uint8_t bytesprops2[] = {0xf7, 0xa3, 0x5b, 0x98, 0x17, 0xbe, 0x74, 0xc, 0xc1, 0x1a}; - uint8_t bytesprops3[] = {0x86, 0x58, 0x68, 0x8d, 0x65, 0x49}; - uint8_t bytesprops4[] = {0x92, 0x38, 0x40, 0x16, 0xe0, 0x47, 0xb9, 0x6c, 0xcb, 0xa0, 0xa3, 0xfe, 0xce, 0x98}; - uint8_t bytesprops5[] = {0x5f, 0x5f, 0x5d, 0x71, 0x45, 0xb4, 0x5c, 0xa9, 0xc7, 0xb7, - 0xed, 0x39, 0x56, 0x48, 0x21, 0x97, 0x70, 0xee, 0x3, 0xf1}; - uint8_t bytesprops6[] = {0x4f}; + msg.payload_len = 8; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11719}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25460}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18099}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\187\245\185\SOH\nLz\249\&84\221t4:\ACKMBL", _pubPktID = 0, _pubBody = -// "+\154\198\134\210\202d\129:\164\205\152\155'n", _pubProps = [PropResponseTopic -// "|2\DC1,\157\216\160\155~B\255\169\245\132",PropServerReference -// "\138\205y\bC\181\165\157\235H\200\SOH\137\218\141qZ\243)\DEL\196\232\228<\164",PropRequestResponseInformation -// 183,PropCorrelationData "\247\163[\152\ETB\190t\f\193\SUB",PropMaximumPacketSize 11719,PropAuthenticationData -// "\134Xh\141eI",PropRequestProblemInformation 210,PropSubscriptionIdentifierAvailable 109,PropMessageExpiryInterval -// 25460,PropRetainAvailable 26,PropSubscriptionIdentifierAvailable 168,PropReasonString -// "\146\&8@\SYN\224G\185l\203\160\163\254\206\152",PropPayloadFormatIndicator 60,PropAuthenticationMethod -// "__]qE\180\\\169\199\183\237\&9VH!\151p\238\ETX\241",PropRequestResponseInformation -// 110,PropRequestResponseInformation 156,PropContentType "O",PropWildcardSubscriptionAvailable 11,PropWillDelayInterval -// 18099]} -TEST(Publish5QCTest, Decode4) { - uint8_t pkt[] = {0x38, 0xb5, 0x1, 0x0, 0x12, 0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, 0x34, 0xdd, 0x74, - 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c, 0x90, 0x1, 0x8, 0x0, 0xe, 0x7c, 0x32, 0x11, 0x2c, 0x9d, 0xd8, - 0xa0, 0x9b, 0x7e, 0x42, 0xff, 0xa9, 0xf5, 0x84, 0x1c, 0x0, 0x19, 0x8a, 0xcd, 0x79, 0x8, 0x43, 0xb5, - 0xa5, 0x9d, 0xeb, 0x48, 0xc8, 0x1, 0x89, 0xda, 0x8d, 0x71, 0x5a, 0xf3, 0x29, 0x7f, 0xc4, 0xe8, 0xe4, - 0x3c, 0xa4, 0x19, 0xb7, 0x9, 0x0, 0xa, 0xf7, 0xa3, 0x5b, 0x98, 0x17, 0xbe, 0x74, 0xc, 0xc1, 0x1a, - 0x27, 0x0, 0x0, 0x2d, 0xc7, 0x16, 0x0, 0x6, 0x86, 0x58, 0x68, 0x8d, 0x65, 0x49, 0x17, 0xd2, 0x29, - 0x6d, 0x2, 0x0, 0x0, 0x63, 0x74, 0x25, 0x1a, 0x29, 0xa8, 0x1f, 0x0, 0xe, 0x92, 0x38, 0x40, 0x16, - 0xe0, 0x47, 0xb9, 0x6c, 0xcb, 0xa0, 0xa3, 0xfe, 0xce, 0x98, 0x1, 0x3c, 0x15, 0x0, 0x14, 0x5f, 0x5f, - 0x5d, 0x71, 0x45, 0xb4, 0x5c, 0xa9, 0xc7, 0xb7, 0xed, 0x39, 0x56, 0x48, 0x21, 0x97, 0x70, 0xee, 0x3, - 0xf1, 0x19, 0x6e, 0x19, 0x9c, 0x3, 0x0, 0x1, 0x4f, 0x28, 0xb, 0x18, 0x0, 0x0, 0x46, 0xb3, 0x2b, - 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\165\&4\a\246}\148\174\&8\186i\137\223\STX*Sv", _pubPktID = 0, _pubBody = "\243\233\SOH\134\243=c\212", _pubProps = +// []} +TEST(Publish311QCTest, Decode14) { + uint8_t pkt[] = {0x30, 0x1a, 0x0, 0x10, 0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, 0xba, 0x69, + 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76, 0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xbb, 0xf5, 0xb9, 0x1, 0xa, 0x4c, 0x7a, 0xf9, 0x38, - 0x34, 0xdd, 0x74, 0x34, 0x3a, 0x6, 0x4d, 0x42, 0x4c}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2b, 0x9a, 0xc6, 0x86, 0xd2, 0xca, 0x64, 0x81, 0x3a, 0xa4, 0xcd, 0x98, 0x9b, 0x27, 0x6e}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, + 0xba, 0x69, 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76}; + lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(msg.payload_len, 8); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\242a\252\132ky\210\DC1\220\251*\163s8\DC4@\147\193\170=\251\131\th\RS\SUB", _pubPktID = 16832, _pubBody = -// "\177\211\211/\228\228B\191\NUL\b'\216\220\236\184", _pubProps = [PropMessageExpiryInterval -// 3768,PropMessageExpiryInterval 28744]} -TEST(Publish5QCTest, Encode5) { - uint8_t pkt[] = {0x35, 0x38, 0x0, 0x1a, 0xf2, 0x61, 0xfc, 0x84, 0x6b, 0x79, 0xd2, 0x11, 0xdc, 0xfb, 0x2a, - 0xa3, 0x73, 0x38, 0x14, 0x40, 0x93, 0xc1, 0xaa, 0x3d, 0xfb, 0x83, 0x9, 0x68, 0x1e, 0x1a, - 0x41, 0xc0, 0xa, 0x2, 0x0, 0x0, 0xe, 0xb8, 0x2, 0x0, 0x0, 0x70, 0x48, 0xb1, 0xd3, - 0xd3, 0x2f, 0xe4, 0xe4, 0x42, 0xbf, 0x0, 0x8, 0x27, 0xd8, 0xdc, 0xec, 0xb8}; - uint8_t topic_bytes[] = {0xf2, 0x61, 0xfc, 0x84, 0x6b, 0x79, 0xd2, 0x11, 0xdc, 0xfb, 0x2a, 0xa3, 0x73, - 0x38, 0x14, 0x40, 0x93, 0xc1, 0xaa, 0x3d, 0xfb, 0x83, 0x9, 0x68, 0x1e, 0x1a}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 10766, _pubBody = +// "\178", _pubProps = []} +TEST(Publish311QCTest, Encode15) { + uint8_t pkt[] = {0x3b, 0x5, 0x0, 0x0, 0x2a, 0xe, 0xb2}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xb1, 0xd3, 0xd3, 0x2f, 0xe4, 0xe4, 0x42, 0xbf, 0x0, 0x8, 0x27, 0xd8, 0xdc, 0xec, 0xb8}; + uint8_t msg_bytes[] = {0xb2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 1; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3768}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28744}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16832, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10766, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\242a\252\132ky\210\DC1\220\251*\163s8\DC4@\147\193\170=\251\131\th\RS\SUB", _pubPktID = 16832, _pubBody = -// "\177\211\211/\228\228B\191\NUL\b'\216\220\236\184", _pubProps = [PropMessageExpiryInterval -// 3768,PropMessageExpiryInterval 28744]} -TEST(Publish5QCTest, Decode5) { - uint8_t pkt[] = {0x35, 0x38, 0x0, 0x1a, 0xf2, 0x61, 0xfc, 0x84, 0x6b, 0x79, 0xd2, 0x11, 0xdc, 0xfb, 0x2a, - 0xa3, 0x73, 0x38, 0x14, 0x40, 0x93, 0xc1, 0xaa, 0x3d, 0xfb, 0x83, 0x9, 0x68, 0x1e, 0x1a, - 0x41, 0xc0, 0xa, 0x2, 0x0, 0x0, 0xe, 0xb8, 0x2, 0x0, 0x0, 0x70, 0x48, 0xb1, 0xd3, - 0xd3, 0x2f, 0xe4, 0xe4, 0x42, 0xbf, 0x0, 0x8, 0x27, 0xd8, 0xdc, 0xec, 0xb8}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 10766, _pubBody = +// "\178", _pubProps = []} +TEST(Publish311QCTest, Decode15) { + uint8_t pkt[] = {0x3b, 0x5, 0x0, 0x0, 0x2a, 0xe, 0xb2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf2, 0x61, 0xfc, 0x84, 0x6b, 0x79, 0xd2, 0x11, 0xdc, 0xfb, 0x2a, 0xa3, 0x73, - 0x38, 0x14, 0x40, 0x93, 0xc1, 0xaa, 0x3d, 0xfb, 0x83, 0x9, 0x68, 0x1e, 0x1a}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb1, 0xd3, 0xd3, 0x2f, 0xe4, 0xe4, 0x42, 0xbf, 0x0, 0x8, 0x27, 0xd8, 0xdc, 0xec, 0xb8}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb2}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 16832); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 10766); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\&6", _pubPktID = 0, _pubBody = -// "\147\221\242\207\140+To \247\210\244", _pubProps = [PropAuthenticationMethod -// "@\158\&95?=\253\187X\243\172\248",PropPayloadFormatIndicator 13,PropResponseTopic -// "\223F|\CAN\162?\US(topic.data), 2); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + uint8_t exp_topic_bytes[] = {0x8a, 0x1d, 0x4a, 0x8f, 0xe9}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x89, 0x8b, 0xc0, 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 6943); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\t[\147\134\211N\220\217R\CAN\NAK\\\186G\DLE\137\189\166\158\221=\171", _pubPktID = 2127, _pubBody = -// "n\\\\\STX\237\196\179\185\241\214\171\SO'\156\228!\240\230\146", _pubProps = [PropAuthenticationMethod -// "}l\146\214\195on\142F\154(topic.data), 22); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\148\134\&7\254W\239\197z\v\194\253\227\173o\163\251m\138", _pubPktID = 0, _pubBody = -// "\136i\178\239\188AL\167x\230\227\NULnK\187", _pubProps = [PropAssignedClientIdentifier -// "\225\SO\FS\251vB\190\ETB\128\RS\134+o\138\US;\168\226Qn7\fFe\DC4\150\147\&4\145n",PropWildcardSubscriptionAvailable -// 225,PropReceiveMaximum 3746,PropReasonString "\223\163\173)L",PropRequestProblemInformation 142]} -TEST(Publish5QCTest, Encode8) { - uint8_t pkt[] = {0x30, 0x54, 0x0, 0x12, 0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, 0xc2, 0xfd, - 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a, 0x30, 0x12, 0x0, 0x1e, 0xe1, 0xe, 0x1c, 0xfb, - 0x76, 0x42, 0xbe, 0x17, 0x80, 0x1e, 0x86, 0x2b, 0x6f, 0x8a, 0x1f, 0x3b, 0xa8, 0xe2, 0x51, - 0x6e, 0x37, 0xc, 0x46, 0x65, 0x14, 0x96, 0x93, 0x34, 0x91, 0x6e, 0x28, 0xe1, 0x21, 0xe, - 0xa2, 0x1f, 0x0, 0x5, 0xdf, 0xa3, 0xad, 0x29, 0x4c, 0x17, 0x8e, 0x88, 0x69, 0xb2, 0xef, - 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; - uint8_t topic_bytes[] = {0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, - 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "6\218tea\v\174S\163\234\130\GS\208\155\GS\DLE\ENQ\ESC\178\165 \153\DC2\155v,\165", _pubPktID = 27993, _pubBody = +// "\158 %1\177\201\t\236L", _pubProps = []} +TEST(Publish311QCTest, Encode18) { + uint8_t pkt[] = {0x32, 0x28, 0x0, 0x1b, 0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, + 0x82, 0x1d, 0xd0, 0x9b, 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, + 0x76, 0x2c, 0xa5, 0x6d, 0x59, 0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; + uint8_t topic_bytes[] = {0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, 0xd0, 0x9b, + 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x88, 0x69, 0xb2, 0xef, 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; + uint8_t msg_bytes[] = {0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 9; - uint8_t bytesprops0[] = {0xe1, 0xe, 0x1c, 0xfb, 0x76, 0x42, 0xbe, 0x17, 0x80, 0x1e, 0x86, 0x2b, 0x6f, 0x8a, 0x1f, - 0x3b, 0xa8, 0xe2, 0x51, 0x6e, 0x37, 0xc, 0x46, 0x65, 0x14, 0x96, 0x93, 0x34, 0x91, 0x6e}; - uint8_t bytesprops1[] = {0xdf, 0xa3, 0xad, 0x29, 0x4c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3746}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 142}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 27993, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\148\134\&7\254W\239\197z\v\194\253\227\173o\163\251m\138", _pubPktID = 0, _pubBody = -// "\136i\178\239\188AL\167x\230\227\NULnK\187", _pubProps = [PropAssignedClientIdentifier -// "\225\SO\FS\251vB\190\ETB\128\RS\134+o\138\US;\168\226Qn7\fFe\DC4\150\147\&4\145n",PropWildcardSubscriptionAvailable -// 225,PropReceiveMaximum 3746,PropReasonString "\223\163\173)L",PropRequestProblemInformation 142]} -TEST(Publish5QCTest, Decode8) { - uint8_t pkt[] = {0x30, 0x54, 0x0, 0x12, 0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, 0xc2, 0xfd, - 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a, 0x30, 0x12, 0x0, 0x1e, 0xe1, 0xe, 0x1c, 0xfb, - 0x76, 0x42, 0xbe, 0x17, 0x80, 0x1e, 0x86, 0x2b, 0x6f, 0x8a, 0x1f, 0x3b, 0xa8, 0xe2, 0x51, - 0x6e, 0x37, 0xc, 0x46, 0x65, 0x14, 0x96, 0x93, 0x34, 0x91, 0x6e, 0x28, 0xe1, 0x21, 0xe, - 0xa2, 0x1f, 0x0, 0x5, 0xdf, 0xa3, 0xad, 0x29, 0x4c, 0x17, 0x8e, 0x88, 0x69, 0xb2, 0xef, - 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "6\218tea\v\174S\163\234\130\GS\208\155\GS\DLE\ENQ\ESC\178\165 \153\DC2\155v,\165", _pubPktID = 27993, _pubBody = +// "\158 %1\177\201\t\236L", _pubProps = []} +TEST(Publish311QCTest, Decode18) { + uint8_t pkt[] = {0x32, 0x28, 0x0, 0x1b, 0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, + 0x82, 0x1d, 0xd0, 0x9b, 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, + 0x76, 0x2c, 0xa5, 0x6d, 0x59, 0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x94, 0x86, 0x37, 0xfe, 0x57, 0xef, 0xc5, 0x7a, 0xb, - 0xc2, 0xfd, 0xe3, 0xad, 0x6f, 0xa3, 0xfb, 0x6d, 0x8a}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x88, 0x69, 0xb2, 0xef, 0xbc, 0x41, 0x4c, 0xa7, 0x78, 0xe6, 0xe3, 0x0, 0x6e, 0x4b, 0xbb}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, 0xd0, 0x9b, + 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 27993); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "V\DC1\RS\130\DLE\233\142\210e4%k~\132\153", _pubPktID = 0, _pubBody = -// "\200\ENQr=\212\221i\147\216\&3\ENQpG\250\147", _pubProps = [PropSessionExpiryInterval -// 29575,PropSubscriptionIdentifier 4,PropRequestResponseInformation 238,PropTopicAliasMaximum 7370,PropReceiveMaximum -// 13633,PropTopicAliasMaximum 8689,PropRequestProblemInformation 177,PropRetainAvailable 129,PropCorrelationData " -// z\224\136\241\DC4\164\173S\208\214\133f",PropPayloadFormatIndicator 196]} -TEST(Publish5QCTest, Encode9) { - uint8_t pkt[] = {0x30, 0x49, 0x0, 0xf, 0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, 0x65, 0x34, 0x25, - 0x6b, 0x7e, 0x84, 0x99, 0x28, 0x11, 0x0, 0x0, 0x73, 0x87, 0xb, 0x4, 0x19, 0xee, 0x22, - 0x1c, 0xca, 0x21, 0x35, 0x41, 0x22, 0x21, 0xf1, 0x17, 0xb1, 0x25, 0x81, 0x9, 0x0, 0xd, - 0x20, 0x7a, 0xe0, 0x88, 0xf1, 0x14, 0xa4, 0xad, 0x53, 0xd0, 0xd6, 0x85, 0x66, 0x1, 0xc4, - 0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; - uint8_t topic_bytes[] = {0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, 0x65, 0x34, 0x25, 0x6b, 0x7e, 0x84, 0x99}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "IP~U\245v\179O\ETB\247\SUB\152i\169\208", _pubPktID = 1633, _pubBody = +// "\164\215\&1Ym\133Ie\197\EOT\147\DC3}g\SUB\150\143", _pubProps = []} +TEST(Publish311QCTest, Encode19) { + uint8_t pkt[] = {0x3d, 0x24, 0x0, 0xf, 0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, + 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0, 0x6, 0x61, 0xa4, 0xd7, 0x31, 0x59, 0x6d, + 0x85, 0x49, 0x65, 0xc5, 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; + uint8_t topic_bytes[] = {0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0}; lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa4, 0xd7, 0x31, 0x59, 0x6d, 0x85, 0x49, 0x65, 0xc5, + 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0x20, 0x7a, 0xe0, 0x88, 0xf1, 0x14, 0xa4, 0xad, 0x53, 0xd0, 0xd6, 0x85, 0x66}; + msg.payload_len = 17; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29575}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7370}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13633}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8689}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 196}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1633, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "V\DC1\RS\130\DLE\233\142\210e4%k~\132\153", _pubPktID = 0, _pubBody = -// "\200\ENQr=\212\221i\147\216\&3\ENQpG\250\147", _pubProps = [PropSessionExpiryInterval -// 29575,PropSubscriptionIdentifier 4,PropRequestResponseInformation 238,PropTopicAliasMaximum 7370,PropReceiveMaximum -// 13633,PropTopicAliasMaximum 8689,PropRequestProblemInformation 177,PropRetainAvailable 129,PropCorrelationData " -// z\224\136\241\DC4\164\173S\208\214\133f",PropPayloadFormatIndicator 196]} -TEST(Publish5QCTest, Decode9) { - uint8_t pkt[] = {0x30, 0x49, 0x0, 0xf, 0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, 0x65, 0x34, 0x25, - 0x6b, 0x7e, 0x84, 0x99, 0x28, 0x11, 0x0, 0x0, 0x73, 0x87, 0xb, 0x4, 0x19, 0xee, 0x22, - 0x1c, 0xca, 0x21, 0x35, 0x41, 0x22, 0x21, 0xf1, 0x17, 0xb1, 0x25, 0x81, 0x9, 0x0, 0xd, - 0x20, 0x7a, 0xe0, 0x88, 0xf1, 0x14, 0xa4, 0xad, 0x53, 0xd0, 0xd6, 0x85, 0x66, 0x1, 0xc4, - 0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "IP~U\245v\179O\ETB\247\SUB\152i\169\208", _pubPktID = 1633, _pubBody = +// "\164\215\&1Ym\133Ie\197\EOT\147\DC3}g\SUB\150\143", _pubProps = []} +TEST(Publish311QCTest, Decode19) { + uint8_t pkt[] = {0x3d, 0x24, 0x0, 0xf, 0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, + 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0, 0x6, 0x61, 0xa4, 0xd7, 0x31, 0x59, 0x6d, + 0x85, 0x49, 0x65, 0xc5, 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x56, 0x11, 0x1e, 0x82, 0x10, 0xe9, 0x8e, 0xd2, - 0x65, 0x34, 0x25, 0x6b, 0x7e, 0x84, 0x99}; + uint8_t exp_topic_bytes[] = {0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, + 0x17, 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0}; lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc8, 0x5, 0x72, 0x3d, 0xd4, 0xdd, 0x69, 0x93, 0xd8, 0x33, 0x5, 0x70, 0x47, 0xfa, 0x93}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); + uint8_t exp_body_bytes[] = {0xa4, 0xd7, 0x31, 0x59, 0x6d, 0x85, 0x49, 0x65, 0xc5, + 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 1633); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\160\NAK\234\249\209\141\136\198?\243\245hW6\199=`\243C|RQ\216v@\r", _pubPktID = 19217, _pubBody = -// "\212m\146de\171\221qv\142\228\171\234S7\162", _pubProps = [PropWillDelayInterval 18386,PropResponseInformation -// "\161\147\SOH\213o-\142\SO\193Kj\ACK\NAK\159\EM\SI\DC3Cz\ENQ\160\213H\173.\202\222Z\161",PropReasonString -// "\228wh?P\146\151\206\ETB\243SQ]\139D\173\183\132o",PropPayloadFormatIndicator 204,PropAuthenticationData -// "J\195\132\220\FS|\252<\153\147\ENQ\SUBo\225",PropAuthenticationData "\228\156\aHyS\251\241",PropServerKeepAlive -// 6048,PropServerKeepAlive 2861,PropReasonString "\154\&9\243\134\155\DC1]\171\&2",PropContentType -// "\191\193s\148\201\&2\246\&4\167\134\205vH;\205\186kO\ETX\168R\218\149",PropAuthenticationMethod -// "\ENQ`75\185\212\FSo\228\"\GS\196t\206\DC1\SYN\133s.q\141\132\STX\SYN\200\235r\135\176",PropRequestProblemInformation -// 187,PropSubscriptionIdentifier 3,PropMaximumPacketSize 21510,PropMessageExpiryInterval -// 28380,PropMessageExpiryInterval 16492,PropSubscriptionIdentifierAvailable 85,PropWildcardSubscriptionAvailable -// 173,PropMessageExpiryInterval 17645,PropContentType -// "W\226>\SUB\145\FS\US\202\207\164\128\196\249\212\172X[\202\RS\198\157\217\EM",PropCorrelationData -// "k\210\192J",PropRequestResponseInformation 169,PropWillDelayInterval 3416,PropMessageExpiryInterval -// 24592,PropSubscriptionIdentifier 27,PropSubscriptionIdentifier 28]} -TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = { - 0x34, 0xa2, 0x2, 0x0, 0x1a, 0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, 0x36, - 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd, 0x4b, 0x11, 0xf2, 0x1, 0x18, 0x0, 0x0, - 0x47, 0xd2, 0x1a, 0x0, 0x1d, 0xa1, 0x93, 0x1, 0xd5, 0x6f, 0x2d, 0x8e, 0xe, 0xc1, 0x4b, 0x6a, 0x6, 0x15, 0x9f, - 0x19, 0xf, 0x13, 0x43, 0x7a, 0x5, 0xa0, 0xd5, 0x48, 0xad, 0x2e, 0xca, 0xde, 0x5a, 0xa1, 0x1f, 0x0, 0x13, 0xe4, - 0x77, 0x68, 0x3f, 0x50, 0x92, 0x97, 0xce, 0x17, 0xf3, 0x53, 0x51, 0x5d, 0x8b, 0x44, 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 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, - 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; - uint8_t topic_bytes[] = {0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, - 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\bm\162F\236O\211D\179\164@\195\244", _pubPktID = 19046, _pubBody = ".\167H\139", _pubProps = []} +TEST(Publish311QCTest, Encode20) { + uint8_t pkt[] = {0x35, 0x15, 0x0, 0xd, 0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, + 0xb3, 0xa4, 0x40, 0xc3, 0xf4, 0x4a, 0x66, 0x2e, 0xa7, 0x48, 0x8b}; + uint8_t topic_bytes[] = {0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, 0xb3, 0xa4, 0x40, 0xc3, 0xf4}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, - 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; + msg.retained = true; + uint8_t msg_bytes[] = {0x2e, 0xa7, 0x48, 0x8b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; - - uint8_t bytesprops0[] = {0xa1, 0x93, 0x1, 0xd5, 0x6f, 0x2d, 0x8e, 0xe, 0xc1, 0x4b, 0x6a, 0x6, 0x15, 0x9f, 0x19, - 0xf, 0x13, 0x43, 0x7a, 0x5, 0xa0, 0xd5, 0x48, 0xad, 0x2e, 0xca, 0xde, 0x5a, 0xa1}; - uint8_t bytesprops1[] = {0xe4, 0x77, 0x68, 0x3f, 0x50, 0x92, 0x97, 0xce, 0x17, 0xf3, - 0x53, 0x51, 0x5d, 0x8b, 0x44, 0xad, 0xb7, 0x84, 0x6f}; - uint8_t bytesprops2[] = {0x4a, 0xc3, 0x84, 0xdc, 0x1c, 0x7c, 0xfc, 0x3c, 0x99, 0x93, 0x5, 0x1a, 0x6f, 0xe1}; - uint8_t bytesprops3[] = {0xe4, 0x9c, 0x7, 0x48, 0x79, 0x53, 0xfb, 0xf1}; - uint8_t bytesprops4[] = {0x9a, 0x39, 0xf3, 0x86, 0x9b, 0x11, 0x5d, 0xab, 0x32}; - uint8_t bytesprops5[] = {0xbf, 0xc1, 0x73, 0x94, 0xc9, 0x32, 0xf6, 0x34, 0xa7, 0x86, 0xcd, 0x76, - 0x48, 0x3b, 0xcd, 0xba, 0x6b, 0x4f, 0x3, 0xa8, 0x52, 0xda, 0x95}; - uint8_t bytesprops6[] = {0x5, 0x60, 0x37, 0x35, 0xb9, 0xd4, 0x1c, 0x6f, 0xe4, 0x22, 0x1d, 0xc4, 0x74, 0xce, 0x11, - 0x16, 0x85, 0x73, 0x2e, 0x71, 0x8d, 0x84, 0x2, 0x16, 0xc8, 0xeb, 0x72, 0x87, 0xb0}; - uint8_t bytesprops7[] = {0x57, 0xe2, 0x3e, 0x1a, 0x91, 0x1c, 0x1f, 0xca, 0xcf, 0xa4, 0x80, 0xc4, - 0xf9, 0xd4, 0xac, 0x58, 0x5b, 0xca, 0x1e, 0xc6, 0x9d, 0xd9, 0x19}; - uint8_t bytesprops8[] = {0x6b, 0xd2, 0xc0, 0x4a}; + msg.payload_len = 4; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18386}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6048}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2861}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21510}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28380}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16492}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17645}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3416}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24592}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19217, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19046, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\160\NAK\234\249\209\141\136\198?\243\245hW6\199=`\243C|RQ\216v@\r", _pubPktID = 19217, _pubBody = -// "\212m\146de\171\221qv\142\228\171\234S7\162", _pubProps = [PropWillDelayInterval 18386,PropResponseInformation -// "\161\147\SOH\213o-\142\SO\193Kj\ACK\NAK\159\EM\SI\DC3Cz\ENQ\160\213H\173.\202\222Z\161",PropReasonString -// "\228wh?P\146\151\206\ETB\243SQ]\139D\173\183\132o",PropPayloadFormatIndicator 204,PropAuthenticationData -// "J\195\132\220\FS|\252<\153\147\ENQ\SUBo\225",PropAuthenticationData "\228\156\aHyS\251\241",PropServerKeepAlive -// 6048,PropServerKeepAlive 2861,PropReasonString "\154\&9\243\134\155\DC1]\171\&2",PropContentType -// "\191\193s\148\201\&2\246\&4\167\134\205vH;\205\186kO\ETX\168R\218\149",PropAuthenticationMethod -// "\ENQ`75\185\212\FSo\228\"\GS\196t\206\DC1\SYN\133s.q\141\132\STX\SYN\200\235r\135\176",PropRequestProblemInformation -// 187,PropSubscriptionIdentifier 3,PropMaximumPacketSize 21510,PropMessageExpiryInterval -// 28380,PropMessageExpiryInterval 16492,PropSubscriptionIdentifierAvailable 85,PropWildcardSubscriptionAvailable -// 173,PropMessageExpiryInterval 17645,PropContentType -// "W\226>\SUB\145\FS\US\202\207\164\128\196\249\212\172X[\202\RS\198\157\217\EM",PropCorrelationData -// "k\210\192J",PropRequestResponseInformation 169,PropWillDelayInterval 3416,PropMessageExpiryInterval -// 24592,PropSubscriptionIdentifier 27,PropSubscriptionIdentifier 28]} -TEST(Publish5QCTest, Decode10) { - uint8_t pkt[] = { - 0x34, 0xa2, 0x2, 0x0, 0x1a, 0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, 0x36, - 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd, 0x4b, 0x11, 0xf2, 0x1, 0x18, 0x0, 0x0, - 0x47, 0xd2, 0x1a, 0x0, 0x1d, 0xa1, 0x93, 0x1, 0xd5, 0x6f, 0x2d, 0x8e, 0xe, 0xc1, 0x4b, 0x6a, 0x6, 0x15, 0x9f, - 0x19, 0xf, 0x13, 0x43, 0x7a, 0x5, 0xa0, 0xd5, 0x48, 0xad, 0x2e, 0xca, 0xde, 0x5a, 0xa1, 0x1f, 0x0, 0x13, 0xe4, - 0x77, 0x68, 0x3f, 0x50, 0x92, 0x97, 0xce, 0x17, 0xf3, 0x53, 0x51, 0x5d, 0x8b, 0x44, 0xad, 0xb7, 0x84, 0x6f, 0x1, - 0xcc, 0x16, 0x0, 0xe, 0x4a, 0xc3, 0x84, 0xdc, 0x1c, 0x7c, 0xfc, 0x3c, 0x99, 0x93, 0x5, 0x1a, 0x6f, 0xe1, 0x16, - 0x0, 0x8, 0xe4, 0x9c, 0x7, 0x48, 0x79, 0x53, 0xfb, 0xf1, 0x13, 0x17, 0xa0, 0x13, 0xb, 0x2d, 0x1f, 0x0, 0x9, - 0x9a, 0x39, 0xf3, 0x86, 0x9b, 0x11, 0x5d, 0xab, 0x32, 0x3, 0x0, 0x17, 0xbf, 0xc1, 0x73, 0x94, 0xc9, 0x32, 0xf6, - 0x34, 0xa7, 0x86, 0xcd, 0x76, 0x48, 0x3b, 0xcd, 0xba, 0x6b, 0x4f, 0x3, 0xa8, 0x52, 0xda, 0x95, 0x15, 0x0, 0x1d, - 0x5, 0x60, 0x37, 0x35, 0xb9, 0xd4, 0x1c, 0x6f, 0xe4, 0x22, 0x1d, 0xc4, 0x74, 0xce, 0x11, 0x16, 0x85, 0x73, 0x2e, - 0x71, 0x8d, 0x84, 0x2, 0x16, 0xc8, 0xeb, 0x72, 0x87, 0xb0, 0x17, 0xbb, 0xb, 0x3, 0x27, 0x0, 0x0, 0x54, 0x6, - 0x2, 0x0, 0x0, 0x6e, 0xdc, 0x2, 0x0, 0x0, 0x40, 0x6c, 0x29, 0x55, 0x28, 0xad, 0x2, 0x0, 0x0, 0x44, 0xed, - 0x3, 0x0, 0x17, 0x57, 0xe2, 0x3e, 0x1a, 0x91, 0x1c, 0x1f, 0xca, 0xcf, 0xa4, 0x80, 0xc4, 0xf9, 0xd4, 0xac, 0x58, - 0x5b, 0xca, 0x1e, 0xc6, 0x9d, 0xd9, 0x19, 0x9, 0x0, 0x4, 0x6b, 0xd2, 0xc0, 0x4a, 0x19, 0xa9, 0x18, 0x0, 0x0, - 0xd, 0x58, 0x2, 0x0, 0x0, 0x60, 0x10, 0xb, 0x1b, 0xb, 0x1c, 0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, - 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\bm\162F\236O\211D\179\164@\195\244", _pubPktID = 19046, _pubBody = ".\167H\139", _pubProps = []} +TEST(Publish311QCTest, Decode20) { + uint8_t pkt[] = {0x35, 0x15, 0x0, 0xd, 0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, + 0xb3, 0xa4, 0x40, 0xc3, 0xf4, 0x4a, 0x66, 0x2e, 0xa7, 0x48, 0x8b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa0, 0x15, 0xea, 0xf9, 0xd1, 0x8d, 0x88, 0xc6, 0x3f, 0xf3, 0xf5, 0x68, 0x57, - 0x36, 0xc7, 0x3d, 0x60, 0xf3, 0x43, 0x7c, 0x52, 0x51, 0xd8, 0x76, 0x40, 0xd}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd4, 0x6d, 0x92, 0x64, 0x65, 0xab, 0xdd, 0x71, - 0x76, 0x8e, 0xe4, 0xab, 0xea, 0x53, 0x37, 0xa2}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, 0xb3, 0xa4, 0x40, 0xc3, 0xf4}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2e, 0xa7, 0x48, 0x8b}; + lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 19217); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 19046); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 4); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); lwmqtt_string_t x = exp_topic; x = exp_body; } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "\207", _willMsg = "\237/\240\202>-v\139\210<\241\SOHK\239\SOHIk\183\205++\149GL\188\237\202", -// _willProps = []}), _cleanSession = True, _keepAlive = 14123, _connID = -// "\250\245\195\140\229m`\ETX\CAN9\SYN\SUBhP\159\204\202f\SOH\177f-\239", _properties = []} -TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x43, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x37, 0x2b, 0x0, 0x17, - 0xfa, 0xf5, 0xc3, 0x8c, 0xe5, 0x6d, 0x60, 0x3, 0x18, 0x39, 0x16, 0x1a, 0x68, 0x50, - 0x9f, 0xcc, 0xca, 0x66, 0x1, 0xb1, 0x66, 0x2d, 0xef, 0x0, 0x1, 0xcf, 0x0, 0x1b, - 0xed, 0x2f, 0xf0, 0xca, 0x3e, 0x2d, 0x76, 0x8b, 0xd2, 0x3c, 0xf1, 0x1, 0x4b, 0xef, - 0x1, 0x49, 0x6b, 0xb7, 0xcd, 0x2b, 0x2b, 0x95, 0x47, 0x4c, 0xbc, 0xed, 0xca}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "%\134\216", _pubPktID = 0, _pubBody +// = "\ETB\162T\161\139s\238\233\229.\233\243\186", _pubProps = []} +TEST(Publish311QCTest, Encode21) { + uint8_t pkt[] = {0x38, 0x12, 0x0, 0x3, 0x25, 0x86, 0xd8, 0x17, 0xa2, 0x54, + 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + uint8_t topic_bytes[] = {0x25, 0x86, 0xd8}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x17, 0xa2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xcf}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xed, 0x2f, 0xf0, 0xca, 0x3e, 0x2d, 0x76, 0x8b, 0xd2, 0x3c, 0xf1, 0x1, 0x4b, 0xef, - 0x1, 0x49, 0x6b, 0xb7, 0xcd, 0x2b, 0x2b, 0x95, 0x47, 0x4c, 0xbc, 0xed, 0xca}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14123; - uint8_t client_id_bytes[] = {0xfa, 0xf5, 0xc3, 0x8c, 0xe5, 0x6d, 0x60, 0x3, 0x18, 0x39, 0x16, 0x1a, - 0x68, 0x50, 0x9f, 0xcc, 0xca, 0x66, 0x1, 0xb1, 0x66, 0x2d, 0xef}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; - opts.client_id = client_id; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\v\155$4", _password = Just "\SUB\f~0\216\NAKr)Qx3B6E\SO\214\193", _lastWill = -// Nothing, _cleanSession = True, _keepAlive = 2824, _connID = -// "\151'V\147\201r\NAK\243\154p\179\129\"9\bk$\156#\v\157\187\150x\CAN2\217", _properties = []} -TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0xb, 0x8, 0x0, 0x1b, 0x97, 0x27, 0x56, - 0x93, 0xc9, 0x72, 0x15, 0xf3, 0x9a, 0x70, 0xb3, 0x81, 0x22, 0x39, 0x8, 0x6b, 0x24, 0x9c, 0x23, 0xb, - 0x9d, 0xbb, 0x96, 0x78, 0x18, 0x32, 0xd9, 0x0, 0x4, 0xb, 0x9b, 0x24, 0x34, 0x0, 0x11, 0x1a, 0xc, - 0x7e, 0x30, 0xd8, 0x15, 0x72, 0x29, 0x51, 0x78, 0x33, 0x42, 0x36, 0x45, 0xe, 0xd6, 0xc1}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "%\134\216", _pubPktID = 0, _pubBody +// = "\ETB\162T\161\139s\238\233\229.\233\243\186", _pubProps = []} +TEST(Publish311QCTest, Decode21) { + uint8_t pkt[] = {0x38, 0x12, 0x0, 0x3, 0x25, 0x86, 0xd8, 0x17, 0xa2, 0x54, + 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x25, 0x86, 0xd8}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x17, 0xa2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\230\237\153c\242P\179\141\223\&2\205Z{\223\153", _pubPktID = 22947, _pubBody = +// "\195\148\247\&4\177\f%\149>q\236W\ETB-\a\209y\n\133o\172*:\131aY", _pubProps = []} +TEST(Publish311QCTest, Encode22) { + uint8_t pkt[] = {0x3a, 0x2d, 0x0, 0xf, 0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, + 0x7b, 0xdf, 0x99, 0x59, 0xa3, 0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, + 0x57, 0x17, 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + uint8_t topic_bytes[] = {0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, 0x7b, 0xdf, 0x99}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, + 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 2824; - uint8_t client_id_bytes[] = {0x97, 0x27, 0x56, 0x93, 0xc9, 0x72, 0x15, 0xf3, 0x9a, 0x70, 0xb3, 0x81, 0x22, 0x39, - 0x8, 0x6b, 0x24, 0x9c, 0x23, 0xb, 0x9d, 0xbb, 0x96, 0x78, 0x18, 0x32, 0xd9}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xb, 0x9b, 0x24, 0x34}; - lwmqtt_string_t username = {4, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x1a, 0xc, 0x7e, 0x30, 0xd8, 0x15, 0x72, 0x29, 0x51, - 0x78, 0x33, 0x42, 0x36, 0x45, 0xe, 0xd6, 0xc1}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 22947, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS0, _willTopic = "5kK\NUL\RS-\163\145\193\178\170I\198\175\DEL$\176\\\DLEo\DC46", _willMsg = -// "&\155\228\DC3\235\180\DC4#\220\198R\206\178[\NAK\149_\245\206\172\NUL\204\US\211UA", _willProps = []}), -// _cleanSession = True, _keepAlive = 32140, _connID = "vC\248\155\177\213g]\198", _properties = []} -TEST(Connect311QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x7d, 0x8c, 0x0, 0x9, 0x76, - 0x43, 0xf8, 0x9b, 0xb1, 0xd5, 0x67, 0x5d, 0xc6, 0x0, 0x16, 0x35, 0x6b, 0x4b, 0x0, 0x1e, - 0x2d, 0xa3, 0x91, 0xc1, 0xb2, 0xaa, 0x49, 0xc6, 0xaf, 0x7f, 0x24, 0xb0, 0x5c, 0x10, 0x6f, - 0x14, 0x36, 0x0, 0x1a, 0x26, 0x9b, 0xe4, 0x13, 0xeb, 0xb4, 0x14, 0x23, 0xdc, 0xc6, 0x52, - 0xce, 0xb2, 0x5b, 0x15, 0x95, 0x5f, 0xf5, 0xce, 0xac, 0x0, 0xcc, 0x1f, 0xd3, 0x55, 0x41}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\230\237\153c\242P\179\141\223\&2\205Z{\223\153", _pubPktID = 22947, _pubBody = +// "\195\148\247\&4\177\f%\149>q\236W\ETB-\a\209y\n\133o\172*:\131aY", _pubProps = []} +TEST(Publish311QCTest, Decode22) { + uint8_t pkt[] = {0x3a, 0x2d, 0x0, 0xf, 0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, + 0x7b, 0xdf, 0x99, 0x59, 0xa3, 0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, + 0x57, 0x17, 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, + 0xdf, 0x32, 0xcd, 0x5a, 0x7b, 0xdf, 0x99}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, + 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 22947); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\159q1\146\234\232\173\FS`\184\186\140\SYN=Z", _pubPktID = 12817, _pubBody = "EJwh\185\236\204#\166", _pubProps = +// []} +TEST(Publish311QCTest, Encode23) { + uint8_t pkt[] = {0x33, 0x1c, 0x0, 0xf, 0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, + 0x8c, 0x16, 0x3d, 0x5a, 0x32, 0x11, 0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + uint8_t topic_bytes[] = {0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, 0x8c, 0x16, 0x3d, 0x5a}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 9; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x35, 0x6b, 0x4b, 0x0, 0x1e, 0x2d, 0xa3, 0x91, 0xc1, 0xb2, 0xaa, - 0x49, 0xc6, 0xaf, 0x7f, 0x24, 0xb0, 0x5c, 0x10, 0x6f, 0x14, 0x36}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x26, 0x9b, 0xe4, 0x13, 0xeb, 0xb4, 0x14, 0x23, 0xdc, 0xc6, 0x52, 0xce, 0xb2, - 0x5b, 0x15, 0x95, 0x5f, 0xf5, 0xce, 0xac, 0x0, 0xcc, 0x1f, 0xd3, 0x55, 0x41}; - lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 32140; - uint8_t client_id_bytes[] = {0x76, 0x43, 0xf8, 0x9b, 0xb1, 0xd5, 0x67, 0x5d, 0xc6}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; - opts.client_id = client_id; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 12817, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\181\188RC|\DELPc[\242A\194\140G\NAK\CANu\DC4\178\213\DC4", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "\249=\212\228i\201\&4\178&\RS)\DC4|\174\242w \201", _willMsg = -// "@\162c\242\CAN\208f\191d\161\222\184@fP\222\&7\204\176\212\227_\166\242\155W<\DC43", _willProps = []}), -// _cleanSession = True, _keepAlive = 8577, _connID = -// "\246\235\226\ACK\SI+\255\134\137\158\247\158\138X\147\188\139\218-\154", _properties = []} -TEST(Connect311QCTest, Encode4) { - uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x21, 0x81, 0x0, 0x14, 0xf6, - 0xeb, 0xe2, 0x6, 0xf, 0x2b, 0xff, 0x86, 0x89, 0x9e, 0xf7, 0x9e, 0x8a, 0x58, 0x93, 0xbc, - 0x8b, 0xda, 0x2d, 0x9a, 0x0, 0x12, 0xf9, 0x3d, 0xd4, 0xe4, 0x69, 0xc9, 0x34, 0xb2, 0x26, - 0x1e, 0x29, 0x14, 0x7c, 0xae, 0xf2, 0x77, 0x20, 0xc9, 0x0, 0x1d, 0x40, 0xa2, 0x63, 0xf2, - 0x18, 0xd0, 0x66, 0xbf, 0x64, 0xa1, 0xde, 0xb8, 0x40, 0x66, 0x50, 0xde, 0x37, 0xcc, 0xb0, - 0xd4, 0xe3, 0x5f, 0xa6, 0xf2, 0x9b, 0x57, 0x3c, 0x14, 0x33}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\159q1\146\234\232\173\FS`\184\186\140\SYN=Z", _pubPktID = 12817, _pubBody = "EJwh\185\236\204#\166", _pubProps = +// []} +TEST(Publish311QCTest, Decode23) { + uint8_t pkt[] = {0x33, 0x1c, 0x0, 0xf, 0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, + 0x8c, 0x16, 0x3d, 0x5a, 0x32, 0x11, 0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, + 0x60, 0xb8, 0xba, 0x8c, 0x16, 0x3d, 0x5a}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 12817); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "7_", _pubPktID = 0, _pubBody = +// "1l\172\222\&2J\173\154BN|", _pubProps = []} +TEST(Publish311QCTest, Encode24) { + uint8_t pkt[] = {0x30, 0xf, 0x0, 0x2, 0x37, 0x5f, 0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + uint8_t topic_bytes[] = {0x37, 0x5f}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 11; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); - lwmqtt_property_t willpropslist[] = {}; + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf9, 0x3d, 0xd4, 0xe4, 0x69, 0xc9, 0x34, 0xb2, 0x26, - 0x1e, 0x29, 0x14, 0x7c, 0xae, 0xf2, 0x77, 0x20, 0xc9}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x40, 0xa2, 0x63, 0xf2, 0x18, 0xd0, 0x66, 0xbf, 0x64, 0xa1, - 0xde, 0xb8, 0x40, 0x66, 0x50, 0xde, 0x37, 0xcc, 0xb0, 0xd4, - 0xe3, 0x5f, 0xa6, 0xf2, 0x9b, 0x57, 0x3c, 0x14, 0x33}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 8577; - uint8_t client_id_bytes[] = {0xf6, 0xeb, 0xe2, 0x6, 0xf, 0x2b, 0xff, 0x86, 0x89, 0x9e, - 0xf7, 0x9e, 0x8a, 0x58, 0x93, 0xbc, 0x8b, 0xda, 0x2d, 0x9a}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xb5, 0xbc, 0x52, 0x43, 0x7c, 0x7f, 0x50, 0x63, 0x5b, 0xf2, 0x41, - 0xc2, 0x8c, 0x47, 0x15, 0x18, 0x75, 0x14, 0xb2, 0xd5, 0x14}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "7_", _pubPktID = 0, _pubBody = +// "1l\172\222\&2J\173\154BN|", _pubProps = []} +TEST(Publish311QCTest, Decode24) { + uint8_t pkt[] = {0x30, 0xf, 0x0, 0x2, 0x37, 0x5f, 0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); + uint8_t exp_topic_bytes[] = {0x37, 0x5f}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + lwmqtt_string_t x = exp_topic; + x = exp_body; } -// ConnectRequest {_username = Just "\ETB\185M\SUB\222\149", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\128\ETB\EOT\205\173", _willMsg = -// "\198\DC3l\140\230R!E$\SOH\229o,x\187~\139\202\"\DC4V\ACK)", _willProps = []}), _cleanSession = False, _keepAlive = -// 3023, _connID = "]l\128mk1J\129p\141\170Rw\178\NUL\171w\196\n", _properties = []} -TEST(Connect311QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb4, 0xb, 0xcf, 0x0, 0x13, 0x5d, - 0x6c, 0x80, 0x6d, 0x6b, 0x31, 0x4a, 0x81, 0x70, 0x8d, 0xaa, 0x52, 0x77, 0xb2, 0x0, 0xab, - 0x77, 0xc4, 0xa, 0x0, 0x5, 0x80, 0x17, 0x4, 0xcd, 0xad, 0x0, 0x17, 0xc6, 0x13, 0x6c, - 0x8c, 0xe6, 0x52, 0x21, 0x45, 0x24, 0x1, 0xe5, 0x6f, 0x2c, 0x78, 0xbb, 0x7e, 0x8b, 0xca, - 0x22, 0x14, 0x56, 0x6, 0x29, 0x0, 0x6, 0x17, 0xb9, 0x4d, 0x1a, 0xde, 0x95}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\246\202\200\133Ey", _pubPktID = +// 19152, _pubBody = "G\255\&5Bg\183\227x}.\158X\246mx\199u\250\US\ETXI\ENQ\249\155!rJ", _pubProps = []} +TEST(Publish311QCTest, Encode25) { + uint8_t pkt[] = {0x35, 0x25, 0x0, 0x6, 0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79, 0x4a, 0xd0, 0x47, + 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, + 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + uint8_t topic_bytes[] = {0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, + 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 27; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x80, 0x17, 0x4, 0xcd, 0xad}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc6, 0x13, 0x6c, 0x8c, 0xe6, 0x52, 0x21, 0x45, 0x24, 0x1, 0xe5, 0x6f, - 0x2c, 0x78, 0xbb, 0x7e, 0x8b, 0xca, 0x22, 0x14, 0x56, 0x6, 0x29}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3023; - uint8_t client_id_bytes[] = {0x5d, 0x6c, 0x80, 0x6d, 0x6b, 0x31, 0x4a, 0x81, 0x70, 0x8d, - 0xaa, 0x52, 0x77, 0xb2, 0x0, 0xab, 0x77, 0xc4, 0xa}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x17, 0xb9, 0x4d, 0x1a, 0xde, 0x95}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19152, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\FS\ACK\249\148\r\158\162\&8uP\173\212\135\254\214", _password = Just -// "\234\199:\176j\218\226\193U\206-\f\SOHRuz\167\199\196", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS1, _willTopic = "\176\DEL\SOH\132>\247\149\GSx", _willMsg = -// "\247Wdo3\141\135\211r\DC4B\b3\225<\247Y7\136\134\&5O\183", _willProps = []}), _cleanSession = True, _keepAlive = -// 13117, _connID = "\226s\168\NUL\201\208\250\224\r\SOZ\221X<[&\\\181\184?\168\RS", _properties = []} -TEST(Connect311QCTest, Encode6) { - uint8_t pkt[] = {0x10, 0x6c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x33, 0x3d, 0x0, 0x16, 0xe2, 0x73, - 0xa8, 0x0, 0xc9, 0xd0, 0xfa, 0xe0, 0xd, 0xe, 0x5a, 0xdd, 0x58, 0x3c, 0x5b, 0x26, 0x5c, 0xb5, - 0xb8, 0x3f, 0xa8, 0x1e, 0x0, 0x9, 0xb0, 0x7f, 0x1, 0x84, 0x3e, 0xf7, 0x95, 0x1d, 0x78, 0x0, - 0x17, 0xf7, 0x57, 0x64, 0x6f, 0x33, 0x8d, 0x87, 0xd3, 0x72, 0x14, 0x42, 0x8, 0x33, 0xe1, 0x3c, - 0xf7, 0x59, 0x37, 0x88, 0x86, 0x35, 0x4f, 0xb7, 0x0, 0xf, 0x1c, 0x6, 0xf9, 0x94, 0xd, 0x9e, - 0xa2, 0x38, 0x75, 0x50, 0xad, 0xd4, 0x87, 0xfe, 0xd6, 0x0, 0x13, 0xea, 0xc7, 0x3a, 0xb0, 0x6a, - 0xda, 0xe2, 0xc1, 0x55, 0xce, 0x2d, 0xc, 0x1, 0x52, 0x75, 0x7a, 0xa7, 0xc7, 0xc4}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\246\202\200\133Ey", _pubPktID = +// 19152, _pubBody = "G\255\&5Bg\183\227x}.\158X\246mx\199u\250\US\ETXI\ENQ\249\155!rJ", _pubProps = []} +TEST(Publish311QCTest, Decode25) { + uint8_t pkt[] = {0x35, 0x25, 0x0, 0x6, 0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79, 0x4a, 0xd0, 0x47, + 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, + 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, + 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 19152); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\\\211\215", _pubPktID = 7594, +// _pubBody = "\139\150\137\180\142\209{^\232\155\136\252\140\233\138", _pubProps = []} +TEST(Publish311QCTest, Encode26) { + uint8_t pkt[] = {0x3c, 0x16, 0x0, 0x3, 0x5c, 0xd3, 0xd7, 0x1d, 0xaa, 0x8b, 0x96, 0x89, + 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + uint8_t topic_bytes[] = {0x5c, 0xd3, 0xd7}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x8b, 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb0, 0x7f, 0x1, 0x84, 0x3e, 0xf7, 0x95, 0x1d, 0x78}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf7, 0x57, 0x64, 0x6f, 0x33, 0x8d, 0x87, 0xd3, 0x72, 0x14, 0x42, 0x8, - 0x33, 0xe1, 0x3c, 0xf7, 0x59, 0x37, 0x88, 0x86, 0x35, 0x4f, 0xb7}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 13117; - uint8_t client_id_bytes[] = {0xe2, 0x73, 0xa8, 0x0, 0xc9, 0xd0, 0xfa, 0xe0, 0xd, 0xe, 0x5a, - 0xdd, 0x58, 0x3c, 0x5b, 0x26, 0x5c, 0xb5, 0xb8, 0x3f, 0xa8, 0x1e}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x1c, 0x6, 0xf9, 0x94, 0xd, 0x9e, 0xa2, 0x38, 0x75, 0x50, 0xad, 0xd4, 0x87, 0xfe, 0xd6}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xea, 0xc7, 0x3a, 0xb0, 0x6a, 0xda, 0xe2, 0xc1, 0x55, 0xce, - 0x2d, 0xc, 0x1, 0x52, 0x75, 0x7a, 0xa7, 0xc7, 0xc4}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7594, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\245H3\185\249\128\172\213o\226N@\DC1", _password = Just -// "\171\195S\150\179\183\184\247*\177\211j.\227\239\199\SUB\r\187\131L\SYN\CAN\239\f\152", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "%W", _willMsg = "l\CAN\147R\DC3", _willProps = []}), -// _cleanSession = True, _keepAlive = 18606, _connID = "6", _properties = []} -TEST(Connect311QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0x43, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x48, 0xae, 0x0, 0x1, - 0x36, 0x0, 0x2, 0x25, 0x57, 0x0, 0x5, 0x6c, 0x18, 0x93, 0x52, 0x13, 0x0, 0xd, - 0xf5, 0x48, 0x33, 0xb9, 0xf9, 0x80, 0xac, 0xd5, 0x6f, 0xe2, 0x4e, 0x40, 0x11, 0x0, - 0x1a, 0xab, 0xc3, 0x53, 0x96, 0xb3, 0xb7, 0xb8, 0xf7, 0x2a, 0xb1, 0xd3, 0x6a, 0x2e, - 0xe3, 0xef, 0xc7, 0x1a, 0xd, 0xbb, 0x83, 0x4c, 0x16, 0x18, 0xef, 0xc, 0x98}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\\\211\215", _pubPktID = 7594, +// _pubBody = "\139\150\137\180\142\209{^\232\155\136\252\140\233\138", _pubProps = []} +TEST(Publish311QCTest, Decode26) { + uint8_t pkt[] = {0x3c, 0x16, 0x0, 0x3, 0x5c, 0xd3, 0xd7, 0x1d, 0xaa, 0x8b, 0x96, 0x89, + 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5c, 0xd3, 0xd7}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8b, 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7594); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "e9\242\201W\247\177\219AK\182\169", +// _pubPktID = 7929, _pubBody = "T\v\FS.x%\218\n\245\225\147\232\145qH\197\203m~\212\&0pk}\161\236\244$\162", _pubProps +// = []} +TEST(Publish311QCTest, Encode27) { + uint8_t pkt[] = {0x34, 0x2d, 0x0, 0xc, 0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9, + 0x1e, 0xf9, 0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, + 0x48, 0xc5, 0xcb, 0x6d, 0x7e, 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; + uint8_t topic_bytes[] = {0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, 0x48, + 0xc5, 0xcb, 0x6d, 0x7e, 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x25, 0x57}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6c, 0x18, 0x93, 0x52, 0x13}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 18606; - uint8_t client_id_bytes[] = {0x36}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xf5, 0x48, 0x33, 0xb9, 0xf9, 0x80, 0xac, 0xd5, 0x6f, 0xe2, 0x4e, 0x40, 0x11}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xab, 0xc3, 0x53, 0x96, 0xb3, 0xb7, 0xb8, 0xf7, 0x2a, 0xb1, 0xd3, 0x6a, 0x2e, - 0xe3, 0xef, 0xc7, 0x1a, 0xd, 0xbb, 0x83, 0x4c, 0x16, 0x18, 0xef, 0xc, 0x98}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7929, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\164\ESC\184\140r\249\243:~\182\177\161", _password = Just -// "=\137\152\193\FS\138\CAN\SO\GS\172=$\179\178=\227\216>", _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "\196", _willMsg = "\189\206O\203\f\146\165\155D\200N\207\198\169;$\242\244\228", _willProps = -// []}), _cleanSession = True, _keepAlive = 14044, _connID = "\158\230\170S\NUL\239\ETB", _properties = []} -TEST(Connect311QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x36, 0xdc, 0x0, 0x7, 0x9e, 0xe6, - 0xaa, 0x53, 0x0, 0xef, 0x17, 0x0, 0x1, 0xc4, 0x0, 0x13, 0xbd, 0xce, 0x4f, 0xcb, 0xc, 0x92, - 0xa5, 0x9b, 0x44, 0xc8, 0x4e, 0xcf, 0xc6, 0xa9, 0x3b, 0x24, 0xf2, 0xf4, 0xe4, 0x0, 0xc, 0xa4, - 0x1b, 0xb8, 0x8c, 0x72, 0xf9, 0xf3, 0x3a, 0x7e, 0xb6, 0xb1, 0xa1, 0x0, 0x12, 0x3d, 0x89, 0x98, - 0xc1, 0x1c, 0x8a, 0x18, 0xe, 0x1d, 0xac, 0x3d, 0x24, 0xb3, 0xb2, 0x3d, 0xe3, 0xd8, 0x3e}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "e9\242\201W\247\177\219AK\182\169", +// _pubPktID = 7929, _pubBody = "T\v\FS.x%\218\n\245\225\147\232\145qH\197\203m~\212\&0pk}\161\236\244$\162", _pubProps +// = []} +TEST(Publish311QCTest, Decode27) { + uint8_t pkt[] = {0x34, 0x2d, 0x0, 0xc, 0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9, + 0x1e, 0xf9, 0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, + 0x48, 0xc5, 0xcb, 0x6d, 0x7e, 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, 0x48, + 0xc5, 0xcb, 0x6d, 0x7e, 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7929); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\235\160n\156\199\DC14\f\233\197\243\207\145\204|J/\129\156\&5$&Z", _pubPktID = 0, _pubBody = +// "\143\195\191\225_\213\191E\230c\156\216\152\CAN\208\204-", _pubProps = []} +TEST(Publish311QCTest, Encode28) { + uint8_t pkt[] = {0x39, 0x2a, 0x0, 0x17, 0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, + 0xcf, 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a, 0x8f, 0xc3, 0xbf, + 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + uint8_t topic_bytes[] = {0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, 0xcf, + 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x8f, 0xc3, 0xbf, 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, + 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc4}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbd, 0xce, 0x4f, 0xcb, 0xc, 0x92, 0xa5, 0x9b, 0x44, 0xc8, - 0x4e, 0xcf, 0xc6, 0xa9, 0x3b, 0x24, 0xf2, 0xf4, 0xe4}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14044; - uint8_t client_id_bytes[] = {0x9e, 0xe6, 0xaa, 0x53, 0x0, 0xef, 0x17}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa4, 0x1b, 0xb8, 0x8c, 0x72, 0xf9, 0xf3, 0x3a, 0x7e, 0xb6, 0xb1, 0xa1}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x3d, 0x89, 0x98, 0xc1, 0x1c, 0x8a, 0x18, 0xe, 0x1d, - 0xac, 0x3d, 0x24, 0xb3, 0xb2, 0x3d, 0xe3, 0xd8, 0x3e}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "bl\173\212\183[K\243\204\225\r\255\210,\215\200\142\&1\181\SOH8\206\168", _password -// = Just "\NUL. m\211I\167\170\222\224%\253#\246", _lastWill = Nothing, _cleanSession = False, _keepAlive = 24572, -// _connID = "\182$y\234\226\247:S\142\"\245_\255\&0\203\191_\249P\SUB8\223\190]0\182\ETBg<", _properties = []} -TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x52, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x5f, 0xfc, 0x0, 0x1d, 0xb6, 0x24, 0x79, - 0xea, 0xe2, 0xf7, 0x3a, 0x53, 0x8e, 0x22, 0xf5, 0x5f, 0xff, 0x30, 0xcb, 0xbf, 0x5f, 0xf9, 0x50, 0x1a, - 0x38, 0xdf, 0xbe, 0x5d, 0x30, 0xb6, 0x17, 0x67, 0x3c, 0x0, 0x17, 0x62, 0x6c, 0xad, 0xd4, 0xb7, 0x5b, - 0x4b, 0xf3, 0xcc, 0xe1, 0xd, 0xff, 0xd2, 0x2c, 0xd7, 0xc8, 0x8e, 0x31, 0xb5, 0x1, 0x38, 0xce, 0xa8, - 0x0, 0xe, 0x0, 0x2e, 0x20, 0x6d, 0xd3, 0x49, 0xa7, 0xaa, 0xde, 0xe0, 0x25, 0xfd, 0x23, 0xf6}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\235\160n\156\199\DC14\f\233\197\243\207\145\204|J/\129\156\&5$&Z", _pubPktID = 0, _pubBody = +// "\143\195\191\225_\213\191E\230c\156\216\152\CAN\208\204-", _pubProps = []} +TEST(Publish311QCTest, Decode28) { + uint8_t pkt[] = {0x39, 0x2a, 0x0, 0x17, 0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, + 0xcf, 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a, 0x8f, 0xc3, 0xbf, + 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, 0xcf, + 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8f, 0xc3, 0xbf, 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, + 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\182~R\STX\198L\RS%^\137\162\228\&70", _pubPktID = 1453, _pubBody = "\188=\n\155\249", _pubProps = []} +TEST(Publish311QCTest, Encode29) { + uint8_t pkt[] = {0x3d, 0x17, 0x0, 0xe, 0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, + 0x89, 0xa2, 0xe4, 0x37, 0x30, 0x5, 0xad, 0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + uint8_t topic_bytes[] = {0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, 0x37, 0x30}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 5; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 24572; - uint8_t client_id_bytes[] = {0xb6, 0x24, 0x79, 0xea, 0xe2, 0xf7, 0x3a, 0x53, 0x8e, 0x22, 0xf5, 0x5f, 0xff, 0x30, 0xcb, - 0xbf, 0x5f, 0xf9, 0x50, 0x1a, 0x38, 0xdf, 0xbe, 0x5d, 0x30, 0xb6, 0x17, 0x67, 0x3c}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x62, 0x6c, 0xad, 0xd4, 0xb7, 0x5b, 0x4b, 0xf3, 0xcc, 0xe1, 0xd, 0xff, - 0xd2, 0x2c, 0xd7, 0xc8, 0x8e, 0x31, 0xb5, 0x1, 0x38, 0xce, 0xa8}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x0, 0x2e, 0x20, 0x6d, 0xd3, 0x49, 0xa7, 0xaa, 0xde, 0xe0, 0x25, 0xfd, 0x23, 0xf6}; - lwmqtt_string_t password = {14, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1453, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "=\CANt\155_d\FS\f:\252", _password = Just "J\175\SI\188\240", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\181\230\197Xq\187C@;P\208\&1\CAN\191\152w[\185`UI\CAN", _willMsg = "\151\DC4y'PM^\214\&0<^k\179\179:|", _willProps -// = []}), _cleanSession = False, _keepAlive = 147, _connID = "\252{\206-]\238\&1\253 \RS\SIy\178", _properties = []} -TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x56, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x0, 0x93, 0x0, 0xd, 0xfc, - 0x7b, 0xce, 0x2d, 0x5d, 0xee, 0x31, 0xfd, 0x20, 0x1e, 0xf, 0x79, 0xb2, 0x0, 0x16, 0xb5, - 0xe6, 0xc5, 0x58, 0x71, 0xbb, 0x43, 0x40, 0x3b, 0x50, 0xd0, 0x31, 0x18, 0xbf, 0x98, 0x77, - 0x5b, 0xb9, 0x60, 0x55, 0x49, 0x18, 0x0, 0x10, 0x97, 0x14, 0x79, 0x27, 0x50, 0x4d, 0x5e, - 0xd6, 0x30, 0x3c, 0x5e, 0x6b, 0xb3, 0xb3, 0x3a, 0x7c, 0x0, 0xa, 0x3d, 0x18, 0x74, 0x9b, - 0x5f, 0x64, 0x1c, 0xc, 0x3a, 0xfc, 0x0, 0x5, 0x4a, 0xaf, 0xf, 0xbc, 0xf0}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\182~R\STX\198L\RS%^\137\162\228\&70", _pubPktID = 1453, _pubBody = "\188=\n\155\249", _pubProps = []} +TEST(Publish311QCTest, Decode29) { + uint8_t pkt[] = {0x3d, 0x17, 0x0, 0xe, 0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, + 0x89, 0xa2, 0xe4, 0x37, 0x30, 0x5, 0xad, 0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, 0x37, 0x30}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 1453); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\191k-$.\245\SUB\192\234\155$", +// _pubPktID = 29170, _pubBody = "[F\181\186O\149", _pubProps = []} +TEST(Publish311QCTest, Encode30) { + uint8_t pkt[] = {0x33, 0x15, 0x0, 0xb, 0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, + 0xea, 0x9b, 0x24, 0x71, 0xf2, 0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + uint8_t topic_bytes[] = {0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 6; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb5, 0xe6, 0xc5, 0x58, 0x71, 0xbb, 0x43, 0x40, 0x3b, 0x50, 0xd0, - 0x31, 0x18, 0xbf, 0x98, 0x77, 0x5b, 0xb9, 0x60, 0x55, 0x49, 0x18}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x97, 0x14, 0x79, 0x27, 0x50, 0x4d, 0x5e, 0xd6, - 0x30, 0x3c, 0x5e, 0x6b, 0xb3, 0xb3, 0x3a, 0x7c}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 147; - uint8_t client_id_bytes[] = {0xfc, 0x7b, 0xce, 0x2d, 0x5d, 0xee, 0x31, 0xfd, 0x20, 0x1e, 0xf, 0x79, 0xb2}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x3d, 0x18, 0x74, 0x9b, 0x5f, 0x64, 0x1c, 0xc, 0x3a, 0xfc}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x4a, 0xaf, 0xf, 0xbc, 0xf0}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29170, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "\207", _willMsg = "\237/\240\202>-v\139\210<\241\SOHK\239\SOHIk\183\205++\149GL\188\237\202", -// _willProps = [PropAuthenticationData "\141\155\&1z\248\251\RS\248#\160\153\235\152",PropServerKeepAlive -// 8955,PropResponseInformation "\"|\207\189\138",PropReasonString -// "\GS$s\149\191\171E\209\184)\ACK\130\DC2=\b",PropSubscriptionIdentifierAvailable 38,PropRequestResponseInformation -// 113,PropMaximumPacketSize 6795,PropSharedSubscriptionAvailable 150,PropMaximumPacketSize 6747,PropTopicAlias -// 13645,PropAssignedClientIdentifier -// "\DC4\DC3Q\196L(\167I,\233\183\237\228\200q\234\232D5\214(\211_xYp\237\226",PropSubscriptionIdentifierAvailable -// 36,PropTopicAliasMaximum 23245,PropContentType "\251XH\239\176\191M\SO\224f\191\173",PropCorrelationData -// "\RSk?:xldE\183",PropMessageExpiryInterval 14702,PropTopicAlias 20067,PropServerKeepAlive 20511,PropTopicAliasMaximum -// 10614,PropRequestProblemInformation 4,PropSubscriptionIdentifier 11,PropReceiveMaximum 28122]}), _cleanSession = -// True, _keepAlive = 14123, _connID = "\250\245\195\140\229m`\ETX\CAN9\SYN\SUBhP\159\204\202f\SOH\177f-\239", -// _properties = [PropWillDelayInterval 31589,PropRetainAvailable 153,PropRetainAvailable -// 231,PropSharedSubscriptionAvailable 208,PropAssignedClientIdentifier "\GSf",PropSharedSubscriptionAvailable -// 135,PropWildcardSubscriptionAvailable 0,PropReceiveMaximum 28907,PropReceiveMaximum 25980,PropAuthenticationData -// "\ESC\169\247\ENQ\244\199\&3\189\211\vU\135\210\152)",PropAssignedClientIdentifier -// ":\SYN\242\142\160ER\200\173n)\208\141\&3P\213\237\199",PropRequestResponseInformation -// 94,PropWildcardSubscriptionAvailable 154,PropTopicAliasMaximum 14579,PropAuthenticationMethod -// "\ETX\226P\160\250",PropContentType "~\249T\SYNVWo\219z,\205\&9o.*\214\208~",PropAuthenticationMethod -// "",PropServerKeepAlive 18921,PropMaximumPacketSize 31691,PropSubscriptionIdentifier 29,PropAuthenticationMethod -// "\DC4\242`)\177\183i?\241\228<3\252\&9\184E\128\169p\b?`\136\148\145\149\249\"",PropRetainAvailable -// 68,PropWillDelayInterval 9234,PropRetainAvailable 190,PropTopicAlias 133,PropCorrelationData -// "\172\ENQi\145t\130\199\199l\144\204\215",PropCorrelationData "\248\177\US\238\196%"]} -TEST(Connect5QCTest, Encode1) { - uint8_t pkt[] = { - 0x10, 0x90, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe, 0x37, 0x2b, 0xb5, 0x1, 0x18, 0x0, 0x0, 0x7b, - 0x65, 0x25, 0x99, 0x25, 0xe7, 0x2a, 0xd0, 0x12, 0x0, 0x2, 0x1d, 0x66, 0x2a, 0x87, 0x28, 0x0, 0x21, 0x70, 0xeb, - 0x21, 0x65, 0x7c, 0x16, 0x0, 0xf, 0x1b, 0xa9, 0xf7, 0x5, 0xf4, 0xc7, 0x33, 0xbd, 0xd3, 0xb, 0x55, 0x87, 0xd2, - 0x98, 0x29, 0x12, 0x0, 0x12, 0x3a, 0x16, 0xf2, 0x8e, 0xa0, 0x45, 0x52, 0xc8, 0xad, 0x6e, 0x29, 0xd0,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 0xb8, 0x29, 0x6, 0x82, 0x12, - 0x3d, 0x8, 0x29, 0x26, 0x19, 0x71, 0x27, 0x0, 0x0, 0x1a, 0x8b, 0x2a, 0x96, 0x27, 0x0, 0x0, 0x1a, 0x5b, 0x23, - 0x35, 0x4d, 0x12, 0x0, 0x1c, 0x14, 0x13, 0x51, 0xc4, 0x4c, 0x28, 0xa7, 0x49, 0x2c, 0xe9, 0xb7, 0xed, 0xe4, 0xc8, - 0x71, 0xea, 0xe8, 0x44, 0x35, 0xd6, 0x28, 0xd3, 0x5f, 0x78, 0x59, 0x70, 0xed, 0xe2, 0x29, 0x24, 0x22, 0x5a, 0xcd, - 0x3, 0x0, 0xc, 0xfb, 0x58, 0x48, 0xef, 0xb0, 0xbf, 0x4d, 0xe, 0xe0, 0x66, 0xbf, 0xad, 0x9, 0x0, 0x9, 0x1e, - 0x6b, 0x3f, 0x3a, 0x78, 0x6c, 0x64, 0x45, 0xb7, 0x2, 0x0, 0x0, 0x39, 0x6e, 0x23, 0x4e, 0x63, 0x13, 0x50, 0x1f, - 0x22, 0x29, 0x76, 0x17, 0x4, 0xb, 0xb, 0x21, 0x6d, 0xda, 0x0, 0x1, 0xcf, 0x0, 0x1b, 0xed, 0x2f, 0xf0, 0xca, - 0x3e, 0x2d, 0x76, 0x8b, 0xd2, 0x3c, 0xf1, 0x1, 0x4b, 0xef, 0x1, 0x49, 0x6b, 0xb7, 0xcd, 0x2b, 0x2b, 0x95, 0x47, - 0x4c, 0xbc, 0xed, 0xca}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1d, 0x66}; - uint8_t bytesprops1[] = {0x1b, 0xa9, 0xf7, 0x5, 0xf4, 0xc7, 0x33, 0xbd, 0xd3, 0xb, 0x55, 0x87, 0xd2, 0x98, 0x29}; - uint8_t bytesprops2[] = {0x3a, 0x16, 0xf2, 0x8e, 0xa0, 0x45, 0x52, 0xc8, 0xad, - 0x6e, 0x29, 0xd0, 0x8d, 0x33, 0x50, 0xd5, 0xed, 0xc7}; - uint8_t bytesprops3[] = {0x3, 0xe2, 0x50, 0xa0, 0xfa}; - uint8_t bytesprops4[] = {0x7e, 0xf9, 0x54, 0x16, 0x56, 0x57, 0x6f, 0xdb, 0x7a, - 0x2c, 0xcd, 0x39, 0x6f, 0x2e, 0x2a, 0xd6, 0xd0, 0x7e}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0x14, 0xf2, 0x60, 0x29, 0xb1, 0xb7, 0x69, 0x3f, 0xf1, 0xe4, 0x3c, 0x33, 0xfc, 0x39, - 0xb8, 0x45, 0x80, 0xa9, 0x70, 0x8, 0x3f, 0x60, 0x88, 0x94, 0x91, 0x95, 0xf9, 0x22}; - uint8_t bytesprops7[] = {0xac, 0x5, 0x69, 0x91, 0x74, 0x82, 0xc7, 0xc7, 0x6c, 0x90, 0xcc, 0xd7}; - uint8_t bytesprops8[] = {0xf8, 0xb1, 0x1f, 0xee, 0xc4, 0x25}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\191k-$.\245\SUB\192\234\155$", +// _pubPktID = 29170, _pubBody = "[F\181\186O\149", _pubProps = []} +TEST(Publish311QCTest, Decode30) { + uint8_t pkt[] = {0x33, 0x15, 0x0, 0xb, 0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, + 0xea, 0x9b, 0x24, 0x71, 0xf2, 0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 29170); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = ";\152\218", _pubPktID = 5070, +// _pubBody = "]&\234\205\156\200\SYN\185\NUL\214}\239\191\&6\154waT{\246\173\DC4k\155\211\190", _pubProps = +// [PropPayloadFormatIndicator 221,PropMaximumPacketSize 3004,PropResponseInformation +// "<.\174Oy\SI&D{D\209\175\f\235\242\181\136\195\173*\ETB`\206\DC2",PropTopicAlias 16144]} +TEST(Publish5QCTest, Encode1) { + uint8_t pkt[] = {0x3d, 0x47, 0x0, 0x3, 0x3b, 0x98, 0xda, 0x13, 0xce, 0x25, 0x1, 0xdd, 0x27, 0x0, 0x0, + 0xb, 0xbc, 0x1a, 0x0, 0x18, 0x3c, 0x2e, 0xae, 0x4f, 0x79, 0xf, 0x26, 0x44, 0x7b, 0x44, + 0xd1, 0xaf, 0xc, 0xeb, 0xf2, 0xb5, 0x88, 0xc3, 0xad, 0x2a, 0x17, 0x60, 0xce, 0x12, 0x23, + 0x3f, 0x10, 0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, + 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; + uint8_t topic_bytes[] = {0x3b, 0x98, 0xda}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, + 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + uint8_t bytesprops0[] = {0x3c, 0x2e, 0xae, 0x4f, 0x79, 0xf, 0x26, 0x44, 0x7b, 0x44, 0xd1, 0xaf, + 0xc, 0xeb, 0xf2, 0xb5, 0x88, 0xc3, 0xad, 0x2a, 0x17, 0x60, 0xce, 0x12}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31589}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28907}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25980}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14579}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18921}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31691}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9234}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 133}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3004}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16144}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x8d, 0x9b, 0x31, 0x7a, 0xf8, 0xfb, 0x1e, 0xf8, 0x23, 0xa0, 0x99, 0xeb, 0x98}; - uint8_t byteswillprops1[] = {0x22, 0x7c, 0xcf, 0xbd, 0x8a}; - uint8_t byteswillprops2[] = {0x1d, 0x24, 0x73, 0x95, 0xbf, 0xab, 0x45, 0xd1, 0xb8, 0x29, 0x6, 0x82, 0x12, 0x3d, 0x8}; - uint8_t byteswillprops3[] = {0x14, 0x13, 0x51, 0xc4, 0x4c, 0x28, 0xa7, 0x49, 0x2c, 0xe9, 0xb7, 0xed, 0xe4, 0xc8, - 0x71, 0xea, 0xe8, 0x44, 0x35, 0xd6, 0x28, 0xd3, 0x5f, 0x78, 0x59, 0x70, 0xed, 0xe2}; - uint8_t byteswillprops4[] = {0xfb, 0x58, 0x48, 0xef, 0xb0, 0xbf, 0x4d, 0xe, 0xe0, 0x66, 0xbf, 0xad}; - uint8_t byteswillprops5[] = {0x1e, 0x6b, 0x3f, 0x3a, 0x78, 0x6c, 0x64, 0x45, 0xb7}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5070, topic, msg, props); - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8955}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6795}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6747}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13645}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23245}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14702}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20067}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20511}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10614}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28122}}, + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = ";\152\218", _pubPktID = 5070, +// _pubBody = "]&\234\205\156\200\SYN\185\NUL\214}\239\191\&6\154waT{\246\173\DC4k\155\211\190", _pubProps = +// [PropPayloadFormatIndicator 221,PropMaximumPacketSize 3004,PropResponseInformation +// "<.\174Oy\SI&D{D\209\175\f\235\242\181\136\195\173*\ETB`\206\DC2",PropTopicAlias 16144]} +TEST(Publish5QCTest, Decode1) { + uint8_t pkt[] = {0x3d, 0x47, 0x0, 0x3, 0x3b, 0x98, 0xda, 0x13, 0xce, 0x25, 0x1, 0xdd, 0x27, 0x0, 0x0, + 0xb, 0xbc, 0x1a, 0x0, 0x18, 0x3c, 0x2e, 0xae, 0x4f, 0x79, 0xf, 0x26, 0x44, 0x7b, 0x44, + 0xd1, 0xaf, 0xc, 0xeb, 0xf2, 0xb5, 0x88, 0xc3, 0xad, 0x2a, 0x17, 0x60, 0xce, 0x12, 0x23, + 0x3f, 0x10, 0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, + 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x3b, 0x98, 0xda}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, + 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 5070); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\156n m\218\DC4\ENQ\RS\r\221", +// _pubPktID = 29842, _pubBody = "\n\r\194\171\&847\188\r\239=\228G\244\204\183o\136\148\223SQ", _pubProps = +// [PropSubscriptionIdentifier 25,PropPayloadFormatIndicator 184,PropAuthenticationMethod +// "t\195I,\139+",PropWildcardSubscriptionAvailable 103,PropReasonString +// "B\241\187.\253b\145\f>~\159T`\201\NAK'm\222\t\153\160\136",PropMaximumQoS 116,PropPayloadFormatIndicator +// 39,PropReasonString ":\SUB\160#\206\247\173@\DLEP\243\176N\252Ag\149n\222",PropWildcardSubscriptionAvailable +// 101,PropSubscriptionIdentifier 14,PropTopicAliasMaximum 14696,PropReasonString "LN\176",PropRetainAvailable +// 253,PropPayloadFormatIndicator 106,PropServerReference +// "C\a\138X2S\225\157\222\187n\SYN\DEL\171\181\DEL\STXk\b\217",PropCorrelationData +// "\147\245\&8OJ\253",PropWildcardSubscriptionAvailable 8,PropWillDelayInterval +// 12301,PropSubscriptionIdentifierAvailable 138,PropSubscriptionIdentifier 31,PropRequestResponseInformation +// 103,PropMaximumPacketSize 8390,PropAuthenticationData "\EOT\253]\186J-K\206r;e\225\158",PropMessageExpiryInterval +// 26352,PropRequestResponseInformation 214,PropWillDelayInterval 13619]} +TEST(Publish5QCTest, Encode2) { + uint8_t pkt[] = {0x3c, 0xc7, 0x1, 0x0, 0xa, 0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, 0xdd, 0x74, 0x92, + 0xa1, 0x1, 0xb, 0x19, 0x1, 0xb8, 0x15, 0x0, 0x6, 0x74, 0xc3, 0x49, 0x2c, 0x8b, 0x2b, 0x28, 0x67, + 0x1f, 0x0, 0x16, 0x42, 0xf1, 0xbb, 0x2e, 0xfd, 0x62, 0x91, 0xc, 0x3e, 0x7e, 0x9f, 0x54, 0x60, 0xc9, + 0x15, 0x27, 0x6d, 0xde, 0x9, 0x99, 0xa0, 0x88, 0x24, 0x74, 0x1, 0x27, 0x1f, 0x0, 0x13, 0x3a, 0x1a, + 0xa0, 0x23, 0xce, 0xf7, 0xad, 0x40, 0x10, 0x50, 0xf3, 0xb0, 0x4e, 0xfc, 0x41, 0x67, 0x95, 0x6e, 0xde, + 0x28, 0x65, 0xb, 0xe, 0x22, 0x39, 0x68, 0x1f, 0x0, 0x3, 0x4c, 0x4e, 0xb0, 0x25, 0xfd, 0x1, 0x6a, + 0x1c, 0x0, 0x14, 0x43, 0x7, 0x8a, 0x58, 0x32, 0x53, 0xe1, 0x9d, 0xde, 0xbb, 0x6e, 0x16, 0x7f, 0xab, + 0xb5, 0x7f, 0x2, 0x6b, 0x8, 0xd9, 0x9, 0x0, 0x6, 0x93, 0xf5, 0x38, 0x4f, 0x4a, 0xfd, 0x28, 0x8, + 0x18, 0x0, 0x0, 0x30, 0xd, 0x29, 0x8a, 0xb, 0x1f, 0x19, 0x67, 0x27, 0x0, 0x0, 0x20, 0xc6, 0x16, + 0x0, 0xd, 0x4, 0xfd, 0x5d, 0xba, 0x4a, 0x2d, 0x4b, 0xce, 0x72, 0x3b, 0x65, 0xe1, 0x9e, 0x2, 0x0, + 0x0, 0x66, 0xf0, 0x19, 0xd6, 0x18, 0x0, 0x0, 0x35, 0x33, 0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, + 0xbc, 0xd, 0xef, 0x3d, 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; + uint8_t topic_bytes[] = {0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, 0xdd}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, 0xbc, 0xd, 0xef, 0x3d, + 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + uint8_t bytesprops0[] = {0x74, 0xc3, 0x49, 0x2c, 0x8b, 0x2b}; + uint8_t bytesprops1[] = {0x42, 0xf1, 0xbb, 0x2e, 0xfd, 0x62, 0x91, 0xc, 0x3e, 0x7e, 0x9f, + 0x54, 0x60, 0xc9, 0x15, 0x27, 0x6d, 0xde, 0x9, 0x99, 0xa0, 0x88}; + uint8_t bytesprops2[] = {0x3a, 0x1a, 0xa0, 0x23, 0xce, 0xf7, 0xad, 0x40, 0x10, 0x50, + 0xf3, 0xb0, 0x4e, 0xfc, 0x41, 0x67, 0x95, 0x6e, 0xde}; + uint8_t bytesprops3[] = {0x4c, 0x4e, 0xb0}; + uint8_t bytesprops4[] = {0x43, 0x7, 0x8a, 0x58, 0x32, 0x53, 0xe1, 0x9d, 0xde, 0xbb, + 0x6e, 0x16, 0x7f, 0xab, 0xb5, 0x7f, 0x2, 0x6b, 0x8, 0xd9}; + uint8_t bytesprops5[] = {0x93, 0xf5, 0x38, 0x4f, 0x4a, 0xfd}; + uint8_t bytesprops6[] = {0x4, 0xfd, 0x5d, 0xba, 0x4a, 0x2d, 0x4b, 0xce, 0x72, 0x3b, 0x65, 0xe1, 0x9e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14696}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12301}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8390}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26352}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13619}}, }; - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xcf}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xed, 0x2f, 0xf0, 0xca, 0x3e, 0x2d, 0x76, 0x8b, 0xd2, 0x3c, 0xf1, 0x1, 0x4b, 0xef, - 0x1, 0x49, 0x6b, 0xb7, 0xcd, 0x2b, 0x2b, 0x95, 0x47, 0x4c, 0xbc, 0xed, 0xca}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14123; - uint8_t client_id_bytes[] = {0xfa, 0xf5, 0xc3, 0x8c, 0xe5, 0x6d, 0x60, 0x3, 0x18, 0x39, 0x16, 0x1a, - 0x68, 0x50, 0x9f, 0xcc, 0xca, 0x66, 0x1, 0xb1, 0x66, 0x2d, 0xef}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; - opts.client_id = client_id; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29842, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\v\155$4", _password = Just "\SUB\f~0\216\NAKr)Qx3B6E\SO\214\193", _lastWill = -// Nothing, _cleanSession = True, _keepAlive = 2824, _connID = -// "\151'V\147\201r\NAK\243\154p\179\129\"9\bk$\156#\v\157\187\150x\CAN2\217", _properties = [PropCorrelationData -// "\DLE\166\170\155\161N/\SUB\181\153\226\153t\240\222z\162\r\GS\161\&4cD$\ACK",PropServerKeepAlive -// 28555,PropAssignedClientIdentifier -// "\ETB\148\169\SUB\174mP\209\&5\251yz\150>\"\165\NUL\226\GS\208\254\&0\204\135+[",PropCorrelationData -// "wSs\140l\224!\240m\GS\181q\174\US{\243",PropTopicAlias 13037,PropCorrelationData -// "P+",PropSubscriptionIdentifierAvailable 185,PropMessageExpiryInterval 9737,PropWillDelayInterval -// 23768,PropWillDelayInterval 2041,PropTopicAliasMaximum 10457,PropWildcardSubscriptionAvailable 148,PropReceiveMaximum -// 10040,PropAuthenticationMethod "\178\DEL=\250\SO\\d",PropResponseTopic -// "x&\DC3\154C+\DLE\208!\152\207\DEL\134[q\208\193",PropPayloadFormatIndicator 30,PropAuthenticationData -// "!\215\185",PropSubscriptionIdentifier 18,PropUserProperty -// "\247\EOT\221>\EMV\202\NAK(x\215\152\154/\248\199\ACK\131\EMc\176\nl\196Kg\164\fI" -// "'\237\DLE\241\SOH\237\EOT\148\NAK\182\147\218(\ETB\212p){\171\198\189?x\137$\DLEP"]} -TEST(Connect5QCTest, Encode2) { +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\156n m\218\DC4\ENQ\RS\r\221", +// _pubPktID = 29842, _pubBody = "\n\r\194\171\&847\188\r\239=\228G\244\204\183o\136\148\223SQ", _pubProps = +// [PropSubscriptionIdentifier 25,PropPayloadFormatIndicator 184,PropAuthenticationMethod +// "t\195I,\139+",PropWildcardSubscriptionAvailable 103,PropReasonString +// "B\241\187.\253b\145\f>~\159T`\201\NAK'm\222\t\153\160\136",PropMaximumQoS 116,PropPayloadFormatIndicator +// 39,PropReasonString ":\SUB\160#\206\247\173@\DLEP\243\176N\252Ag\149n\222",PropWildcardSubscriptionAvailable +// 101,PropSubscriptionIdentifier 14,PropTopicAliasMaximum 14696,PropReasonString "LN\176",PropRetainAvailable +// 253,PropPayloadFormatIndicator 106,PropServerReference +// "C\a\138X2S\225\157\222\187n\SYN\DEL\171\181\DEL\STXk\b\217",PropCorrelationData +// "\147\245\&8OJ\253",PropWildcardSubscriptionAvailable 8,PropWillDelayInterval +// 12301,PropSubscriptionIdentifierAvailable 138,PropSubscriptionIdentifier 31,PropRequestResponseInformation +// 103,PropMaximumPacketSize 8390,PropAuthenticationData "\EOT\253]\186J-K\206r;e\225\158",PropMessageExpiryInterval +// 26352,PropRequestResponseInformation 214,PropWillDelayInterval 13619]} +TEST(Publish5QCTest, Decode2) { + uint8_t pkt[] = {0x3c, 0xc7, 0x1, 0x0, 0xa, 0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, 0xdd, 0x74, 0x92, + 0xa1, 0x1, 0xb, 0x19, 0x1, 0xb8, 0x15, 0x0, 0x6, 0x74, 0xc3, 0x49, 0x2c, 0x8b, 0x2b, 0x28, 0x67, + 0x1f, 0x0, 0x16, 0x42, 0xf1, 0xbb, 0x2e, 0xfd, 0x62, 0x91, 0xc, 0x3e, 0x7e, 0x9f, 0x54, 0x60, 0xc9, + 0x15, 0x27, 0x6d, 0xde, 0x9, 0x99, 0xa0, 0x88, 0x24, 0x74, 0x1, 0x27, 0x1f, 0x0, 0x13, 0x3a, 0x1a, + 0xa0, 0x23, 0xce, 0xf7, 0xad, 0x40, 0x10, 0x50, 0xf3, 0xb0, 0x4e, 0xfc, 0x41, 0x67, 0x95, 0x6e, 0xde, + 0x28, 0x65, 0xb, 0xe, 0x22, 0x39, 0x68, 0x1f, 0x0, 0x3, 0x4c, 0x4e, 0xb0, 0x25, 0xfd, 0x1, 0x6a, + 0x1c, 0x0, 0x14, 0x43, 0x7, 0x8a, 0x58, 0x32, 0x53, 0xe1, 0x9d, 0xde, 0xbb, 0x6e, 0x16, 0x7f, 0xab, + 0xb5, 0x7f, 0x2, 0x6b, 0x8, 0xd9, 0x9, 0x0, 0x6, 0x93, 0xf5, 0x38, 0x4f, 0x4a, 0xfd, 0x28, 0x8, + 0x18, 0x0, 0x0, 0x30, 0xd, 0x29, 0x8a, 0xb, 0x1f, 0x19, 0x67, 0x27, 0x0, 0x0, 0x20, 0xc6, 0x16, + 0x0, 0xd, 0x4, 0xfd, 0x5d, 0xba, 0x4a, 0x2d, 0x4b, 0xce, 0x72, 0x3b, 0x65, 0xe1, 0x9e, 0x2, 0x0, + 0x0, 0x66, 0xf0, 0x19, 0xd6, 0x18, 0x0, 0x0, 0x35, 0x33, 0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, + 0xbc, 0xd, 0xef, 0x3d, 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, 0xdd}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, 0xbc, 0xd, 0xef, 0x3d, + 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 29842); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\SUB\143\217", _pubPktID = 816, +// _pubBody = "\246^\255t\204\180\169\214\150&=\195\235\249\176Q\NAK\169\145", _pubProps = [PropTopicAliasMaximum +// 31796,PropRequestProblemInformation 166,PropTopicAlias 26535,PropSubscriptionIdentifier 4,PropServerReference +// "\227\160T'4-\188\159&\235RN\181\179d\153,\237w\193\&3\145\136",PropSubscriptionIdentifier +// 25,PropSharedSubscriptionAvailable 1,PropServerKeepAlive 630,PropServerReference "\226",PropAssignedClientIdentifier +// "\211",PropContentType "X",PropReceiveMaximum 7394,PropMessageExpiryInterval 1294,PropAuthenticationMethod +// "s",PropPayloadFormatIndicator 99,PropResponseTopic +// "7Q\148\235\CAN\DLE\234X\GSQ\134U\204\214@\213\248\151\165\185X\SYN4\188\218\218\&0\193",PropRequestResponseInformation +// 163,PropAuthenticationMethod " 6\248\138\207\STXX\147\203\217}\173\SI2\175\150",PropReceiveMaximum +// 26236,PropUserProperty "\157\173\137\143\144\rgTd\DC4\164\202\&2\130\ESC2\157" +// "\161\177#\149\206m\b!\158\145/3\148+\246\171u\144\&2\219\156\232\249",PropRequestProblemInformation +// 16,PropCorrelationData "\214\ESC\207",PropTopicAlias 17977,PropContentType +// "\238\&7\DELe\172\181\189\178\187\ACKB\155Q\199?b\197",PropRequestResponseInformation +// 197,PropAssignedClientIdentifier "",PropAuthenticationMethod +// "\163\192\138\&2\t\136\129\137_H\ETB\190\234\128\198\227bE\216u\193\FST\230\227q\223\206\ACK",PropAuthenticationData +// "&m#",PropRequestResponseInformation 161]} +TEST(Publish5QCTest, Encode3) { uint8_t pkt[] = { - 0x10, 0x97, 0x2, 0x0, 0x4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0x6c, 0xc4, 0x4b, 0x67, 0xa4, 0xc, 0x49, 0x0, 0x1b, 0x27, 0xed, 0x10, 0xf1, 0x1, 0xed, 0x4, 0x94, - 0x15, 0xb6, 0x93, 0xda, 0x28, 0x17, 0xd4, 0x70, 0x29, 0x7b, 0xab, 0xc6, 0xbd, 0x3f, 0x78, 0x89, 0x24, 0x10, 0x50, - 0x0, 0x1b, 0x97, 0x27, 0x56, 0x93, 0xc9, 0x72, 0x15, 0xf3, 0x9a, 0x70, 0xb3, 0x81, 0x22, 0x39, 0x8, 0x6b, 0x24, - 0x9c, 0x23, 0xb, 0x9d, 0xbb, 0x96, 0x78, 0x18, 0x32, 0xd9, 0x0, 0x4, 0xb, 0x9b, 0x24, 0x34, 0x0, 0x11, 0x1a, - 0xc, 0x7e, 0x30, 0xd8, 0x15, 0x72, 0x29, 0x51, 0x78, 0x33, 0x42, 0x36, 0x45, 0xe, 0xd6, 0xc1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x10, 0xa6, 0xaa, 0x9b, 0xa1, 0x4e, 0x2f, 0x1a, 0xb5, 0x99, 0xe2, 0x99, 0x74, - 0xf0, 0xde, 0x7a, 0xa2, 0xd, 0x1d, 0xa1, 0x34, 0x63, 0x44, 0x24, 0x6}; - uint8_t bytesprops1[] = {0x17, 0x94, 0xa9, 0x1a, 0xae, 0x6d, 0x50, 0xd1, 0x35, 0xfb, 0x79, 0x7a, 0x96, - 0x3e, 0x22, 0xa5, 0x0, 0xe2, 0x1d, 0xd0, 0xfe, 0x30, 0xcc, 0x87, 0x2b, 0x5b}; - uint8_t bytesprops2[] = {0x77, 0x53, 0x73, 0x8c, 0x6c, 0xe0, 0x21, 0xf0, - 0x6d, 0x1d, 0xb5, 0x71, 0xae, 0x1f, 0x7b, 0xf3}; - uint8_t bytesprops3[] = {0x50, 0x2b}; - uint8_t bytesprops4[] = {0xb2, 0x7f, 0x3d, 0xfa, 0xe, 0x5c, 0x64}; - uint8_t bytesprops5[] = {0x78, 0x26, 0x13, 0x9a, 0x43, 0x2b, 0x10, 0xd0, 0x21, - 0x98, 0xcf, 0x7f, 0x86, 0x5b, 0x71, 0xd0, 0xc1}; - uint8_t bytesprops6[] = {0x21, 0xd7, 0xb9}; - uint8_t bytesprops8[] = {0x27, 0xed, 0x10, 0xf1, 0x1, 0xed, 0x4, 0x94, 0x15, 0xb6, 0x93, 0xda, 0x28, 0x17, - 0xd4, 0x70, 0x29, 0x7b, 0xab, 0xc6, 0xbd, 0x3f, 0x78, 0x89, 0x24, 0x10, 0x50}; - uint8_t bytesprops7[] = {0xf7, 0x4, 0xdd, 0x3e, 0x19, 0x56, 0xca, 0x15, 0x28, 0x78, 0xd7, 0x98, 0x9a, 0x2f, 0xf8, - 0xc7, 0x6, 0x83, 0x19, 0x63, 0xb0, 0xa, 0x6c, 0xc4, 0x4b, 0x67, 0xa4, 0xc, 0x49}; + 0x35, 0x91, 0x2, 0x0, 0x3, 0x1a, 0x8f, 0xd9, 0x3, 0x30, 0xf5, 0x1, 0x22, 0x7c, 0x34, 0x17, 0xa6, 0x23, 0x67, + 0xa7, 0xb, 0x4, 0x1c, 0x0, 0x17, 0xe3, 0xa0, 0x54, 0x27, 0x34, 0x2d, 0xbc, 0x9f, 0x26, 0xeb, 0x52, 0x4e, 0xb5, + 0xb3, 0x64, 0x99, 0x2c, 0xed, 0x77, 0xc1, 0x33, 0x91, 0x88, 0xb, 0x19, 0x2a, 0x1, 0x13, 0x2, 0x76, 0x1c, 0x0, + 0x1, 0xe2, 0x12, 0x0, 0x1, 0xd3, 0x3, 0x0, 0x1, 0x58, 0x21, 0x1c, 0xe2, 0x2, 0x0, 0x0, 0x5, 0xe, 0x15, + 0x0, 0x1, 0x73, 0x1, 0x63, 0x8, 0x0, 0x1c, 0x37, 0x51, 0x94, 0xeb, 0x18, 0x10, 0xea, 0x58, 0x1d, 0x51, 0x86, + 0x55, 0xcc, 0xd6, 0x40, 0xd5, 0xf8, 0x97, 0xa5, 0xb9, 0x58, 0x16, 0x34, 0xbc, 0xda, 0xda, 0x30, 0xc1, 0x19, 0xa3, + 0x15, 0x0, 0x10, 0x20, 0x36, 0xf8, 0x8a, 0xcf, 0x2, 0x58, 0x93, 0xcb, 0xd9, 0x7d, 0xad, 0xf, 0x32, 0xaf, 0x96, + 0x21, 0x66, 0x7c, 0x26, 0x0, 0x11, 0x9d, 0xad, 0x89, 0x8f, 0x90, 0xd, 0x67, 0x54, 0x64, 0x14, 0xa4, 0xca, 0x32, + 0x82, 0x1b, 0x32, 0x9d, 0x0, 0x17, 0xa1, 0xb1, 0x23, 0x95, 0xce, 0x6d, 0x8, 0x21, 0x9e, 0x91, 0x2f, 0x33, 0x94, + 0x2b, 0xf6, 0xab, 0x75, 0x90, 0x32, 0xdb, 0x9c, 0xe8, 0xf9, 0x17, 0x10, 0x9, 0x0, 0x3, 0xd6, 0x1b, 0xcf, 0x23, + 0x46, 0x39, 0x3, 0x0, 0x11, 0xee, 0x37, 0x7f, 0x65, 0xac, 0xb5, 0xbd, 0xb2, 0xbb, 0x6, 0x42, 0x9b, 0x51, 0xc7, + 0x3f, 0x62, 0xc5, 0x19, 0xc5, 0x12, 0x0, 0x0, 0x15, 0x0, 0x1d, 0xa3, 0xc0, 0x8a, 0x32, 0x9, 0x88, 0x81, 0x89, + 0x5f, 0x48, 0x17, 0xbe, 0xea, 0x80, 0xc6, 0xe3, 0x62, 0x45, 0xd8, 0x75, 0xc1, 0x1c, 0x54, 0xe6, 0xe3, 0x71, 0xdf, + 0xce, 0x6, 0x16, 0x0, 0x3, 0x26, 0x6d, 0x23, 0x19, 0xa1, 0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, + 0x26, 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; + uint8_t topic_bytes[] = {0x1a, 0x8f, 0xd9}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, 0x26, + 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 19; + + uint8_t bytesprops0[] = {0xe3, 0xa0, 0x54, 0x27, 0x34, 0x2d, 0xbc, 0x9f, 0x26, 0xeb, 0x52, 0x4e, + 0xb5, 0xb3, 0x64, 0x99, 0x2c, 0xed, 0x77, 0xc1, 0x33, 0x91, 0x88}; + uint8_t bytesprops1[] = {0xe2}; + uint8_t bytesprops2[] = {0xd3}; + uint8_t bytesprops3[] = {0x58}; + uint8_t bytesprops4[] = {0x73}; + uint8_t bytesprops5[] = {0x37, 0x51, 0x94, 0xeb, 0x18, 0x10, 0xea, 0x58, 0x1d, 0x51, 0x86, 0x55, 0xcc, 0xd6, + 0x40, 0xd5, 0xf8, 0x97, 0xa5, 0xb9, 0x58, 0x16, 0x34, 0xbc, 0xda, 0xda, 0x30, 0xc1}; + uint8_t bytesprops6[] = {0x20, 0x36, 0xf8, 0x8a, 0xcf, 0x2, 0x58, 0x93, + 0xcb, 0xd9, 0x7d, 0xad, 0xf, 0x32, 0xaf, 0x96}; + uint8_t bytesprops8[] = {0xa1, 0xb1, 0x23, 0x95, 0xce, 0x6d, 0x8, 0x21, 0x9e, 0x91, 0x2f, 0x33, + 0x94, 0x2b, 0xf6, 0xab, 0x75, 0x90, 0x32, 0xdb, 0x9c, 0xe8, 0xf9}; + uint8_t bytesprops7[] = {0x9d, 0xad, 0x89, 0x8f, 0x90, 0xd, 0x67, 0x54, 0x64, + 0x14, 0xa4, 0xca, 0x32, 0x82, 0x1b, 0x32, 0x9d}; + uint8_t bytesprops9[] = {0xd6, 0x1b, 0xcf}; + uint8_t bytesprops10[] = {0xee, 0x37, 0x7f, 0x65, 0xac, 0xb5, 0xbd, 0xb2, 0xbb, + 0x6, 0x42, 0x9b, 0x51, 0xc7, 0x3f, 0x62, 0xc5}; + uint8_t bytesprops11[] = {0}; + uint8_t bytesprops12[] = {0xa3, 0xc0, 0x8a, 0x32, 0x9, 0x88, 0x81, 0x89, 0x5f, 0x48, 0x17, 0xbe, 0xea, 0x80, 0xc6, + 0xe3, 0x62, 0x45, 0xd8, 0x75, 0xc1, 0x1c, 0x54, 0xe6, 0xe3, 0x71, 0xdf, 0xce, 0x6}; + uint8_t bytesprops13[] = {0x26, 0x6d, 0x23}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28555}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13037}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9737}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23768}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2041}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10457}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10040}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops7}, .v = {27, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31796}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26535}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 630}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7394}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1294}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26236}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops7}, .v = {23, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17977}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 161}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 2824; - uint8_t client_id_bytes[] = {0x97, 0x27, 0x56, 0x93, 0xc9, 0x72, 0x15, 0xf3, 0x9a, 0x70, 0xb3, 0x81, 0x22, 0x39, - 0x8, 0x6b, 0x24, 0x9c, 0x23, 0xb, 0x9d, 0xbb, 0x96, 0x78, 0x18, 0x32, 0xd9}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xb, 0x9b, 0x24, 0x34}; - lwmqtt_string_t username = {4, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x1a, 0xc, 0x7e, 0x30, 0xd8, 0x15, 0x72, 0x29, 0x51, - 0x78, 0x33, 0x42, 0x36, 0x45, 0xe, 0xd6, 0xc1}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 816, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS0, _willTopic = "5kK\NUL\RS-\163\145\193\178\170I\198\175\DEL$\176\\\DLEo\DC46", _willMsg = -// "&\155\228\DC3\235\180\DC4#\220\198R\206\178[\NAK\149_\245\206\172\NUL\204\US\211UA", _willProps = [PropContentType -// "\DC3:\145S\n\235\164\187?",PropUserProperty "@\190\173$\255\232\248\199\208\132\231\130V" -// "\189\DELI\DC3\146\ENQ\241\&1\DC1\194;<\169&\199\191",PropRequestProblemInformation 157,PropSessionExpiryInterval -// 2676,PropRequestProblemInformation 219,PropSubscriptionIdentifierAvailable 138,PropUserProperty -// "\237N\198/\176\139N\222GF\240\144&\247%\EOT\254q\157{\200\\" "\177\&8\222\185z\\\174\254\134\ESC\229 -// \128\EM\226L%\146",PropMessageExpiryInterval 2260,PropResponseInformation "\133dOZ\217\140P*=",PropRetainAvailable -// 122,PropResponseInformation "\171\208\245",PropResponseInformation -// "\201\243\207kk\208\251\204\&6\221!\nb\227j1\181\195\254\146\CAN\255\211",PropResponseInformation -// "\252\249\US\EM\131\255\187\159\141\137\232by",PropSubscriptionIdentifier 1,PropResponseTopic -// "\210MN)n:\246J\201\236%\204\166\244\ACK\181g_\215\217&\236\234\213\b\223L\228\232\181",PropAuthenticationData -// "\249E\182\164\SYN'\238\&3\133\190\254\"t\241+\225\t-U\187\187#z\208\219",PropMaximumPacketSize -// 16575,PropPayloadFormatIndicator 242,PropSessionExpiryInterval 14364,PropWillDelayInterval 8517,PropServerReference -// "n)\186\130\&6\241\&0e\238\170\SOH\136",PropCorrelationData "\222O%",PropRequestResponseInformation -// 46,PropAuthenticationData "O\ETB\208()\DC3\250AI\US",PropServerKeepAlive 3459,PropAuthenticationMethod ".v"]}), -// _cleanSession = True, _keepAlive = 32140, _connID = "vC\248\155\177\213g]\198", _properties = [PropMaximumPacketSize -// 4625,PropCorrelationData -// "\189\FSf\211\&5\225\SOHr\231\205\CAN\"j\171\DC1%\225p{,\DLEB\227\STXk@\140,<\215",PropMaximumPacketSize -// 27111,PropPayloadFormatIndicator 21,PropSubscriptionIdentifierAvailable 88,PropRetainAvailable -// 56,PropSubscriptionIdentifierAvailable 37,PropSessionExpiryInterval 27408,PropTopicAlias 30555,PropTopicAliasMaximum -// 30910,PropMaximumQoS 162,PropSharedSubscriptionAvailable 219,PropMaximumPacketSize 27447,PropUserProperty -// "o\tf\145@&H\b\184\232\232\134\GS}\222s\216\205u\190" -// "\213^\222\132\163\132\195qUw7\241e=\209\DEL\221J\135",PropReceiveMaximum 13982,PropReasonString -// "\239\155d\217\165\168\194{\ENQ\SUB\196\&1",PropWillDelayInterval 27839,PropSubscriptionIdentifier 17]} -TEST(Connect5QCTest, Encode3) { +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\SUB\143\217", _pubPktID = 816, +// _pubBody = "\246^\255t\204\180\169\214\150&=\195\235\249\176Q\NAK\169\145", _pubProps = [PropTopicAliasMaximum +// 31796,PropRequestProblemInformation 166,PropTopicAlias 26535,PropSubscriptionIdentifier 4,PropServerReference +// "\227\160T'4-\188\159&\235RN\181\179d\153,\237w\193\&3\145\136",PropSubscriptionIdentifier +// 25,PropSharedSubscriptionAvailable 1,PropServerKeepAlive 630,PropServerReference "\226",PropAssignedClientIdentifier +// "\211",PropContentType "X",PropReceiveMaximum 7394,PropMessageExpiryInterval 1294,PropAuthenticationMethod +// "s",PropPayloadFormatIndicator 99,PropResponseTopic +// "7Q\148\235\CAN\DLE\234X\GSQ\134U\204\214@\213\248\151\165\185X\SYN4\188\218\218\&0\193",PropRequestResponseInformation +// 163,PropAuthenticationMethod " 6\248\138\207\STXX\147\203\217}\173\SI2\175\150",PropReceiveMaximum +// 26236,PropUserProperty "\157\173\137\143\144\rgTd\DC4\164\202\&2\130\ESC2\157" +// "\161\177#\149\206m\b!\158\145/3\148+\246\171u\144\&2\219\156\232\249",PropRequestProblemInformation +// 16,PropCorrelationData "\214\ESC\207",PropTopicAlias 17977,PropContentType +// "\238\&7\DELe\172\181\189\178\187\ACKB\155Q\199?b\197",PropRequestResponseInformation +// 197,PropAssignedClientIdentifier "",PropAuthenticationMethod +// "\163\192\138\&2\t\136\129\137_H\ETB\190\234\128\198\227bE\216u\193\FST\230\227q\223\206\ACK",PropAuthenticationData +// "&m#",PropRequestResponseInformation 161]} +TEST(Publish5QCTest, Decode3) { uint8_t pkt[] = { - 0x10, 0xfe, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6, 0x7d, 0x8c, 0x8c, 0x1, 0x27, 0x0, 0x0, 0x12, - 0x11, 0x9, 0x0, 0x1e, 0xbd, 0x1c, 0x66, 0xd3, 0x35, 0xe1, 0x1, 0x72, 0xe7, 0xcd, 0x18, 0x22, 0x6a, 0xab, 0x11, - 0x25, 0xe1, 0x70, 0x7b, 0x2c, 0x10, 0x42, 0xe3, 0x2, 0x6b, 0x40, 0x8c, 0x2c, 0x3c, 0xd7, 0x27, 0x0, 0x0, 0x69, - 0xe7, 0x1, 0x15, 0x29, 0x58, 0x25, 0x38, 0x29, 0x25, 0x11, 0x0, 0x0, 0x6b, 0x10, 0x23, 0x77, 0x5b, 0x22, 0x78, - 0xbe, 0x24, 0xa2, 0x2a, 0xdb, 0x27, 0x0, 0x0, 0x6b, 0x37, 0x26, 0x0, 0x14, 0x6f, 0x9, 0x66, 0x91, 0x40, 0x26, - 0x48, 0x8, 0xb8, 0xe8, 0xe8, 0x86, 0x1d, 0x7d, 0xde, 0x73, 0xd8, 0xcd, 0x75, 0xbe, 0x0, 0x13, 0xd5, 0x5e, 0xde, - 0x84, 0xa3, 0x84, 0xc3, 0x71, 0x55, 0x77, 0x37, 0xf1, 0x65, 0x3d, 0xd1, 0x7f, 0xdd, 0x4a, 0x87, 0x21, 0x36, 0x9e, - 0x1f, 0x0, 0xc, 0xef, 0x9b, 0x64, 0xd9, 0xa5, 0xa8, 0xc2, 0x7b, 0x5, 0x1a, 0xc4, 0x31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ytesprops0[] = {0xbd, 0x1c, 0x66, 0xd3, 0x35, 0xe1, 0x1, 0x72, 0xe7, 0xcd, 0x18, 0x22, 0x6a, 0xab, 0x11, - 0x25, 0xe1, 0x70, 0x7b, 0x2c, 0x10, 0x42, 0xe3, 0x2, 0x6b, 0x40, 0x8c, 0x2c, 0x3c, 0xd7}; - uint8_t bytesprops2[] = {0xd5, 0x5e, 0xde, 0x84, 0xa3, 0x84, 0xc3, 0x71, 0x55, 0x77, - 0x37, 0xf1, 0x65, 0x3d, 0xd1, 0x7f, 0xdd, 0x4a, 0x87}; - uint8_t bytesprops1[] = {0x6f, 0x9, 0x66, 0x91, 0x40, 0x26, 0x48, 0x8, 0xb8, 0xe8, - 0xe8, 0x86, 0x1d, 0x7d, 0xde, 0x73, 0xd8, 0xcd, 0x75, 0xbe}; - uint8_t bytesprops3[] = {0xef, 0x9b, 0x64, 0xd9, 0xa5, 0xa8, 0xc2, 0x7b, 0x5, 0x1a, 0xc4, 0x31}; + 0x35, 0x91, 0x2, 0x0, 0x3, 0x1a, 0x8f, 0xd9, 0x3, 0x30, 0xf5, 0x1, 0x22, 0x7c, 0x34, 0x17, 0xa6, 0x23, 0x67, + 0xa7, 0xb, 0x4, 0x1c, 0x0, 0x17, 0xe3, 0xa0, 0x54, 0x27, 0x34, 0x2d, 0xbc, 0x9f, 0x26, 0xeb, 0x52, 0x4e, 0xb5, + 0xb3, 0x64, 0x99, 0x2c, 0xed, 0x77, 0xc1, 0x33, 0x91, 0x88, 0xb, 0x19, 0x2a, 0x1, 0x13, 0x2, 0x76, 0x1c, 0x0, + 0x1, 0xe2, 0x12, 0x0, 0x1, 0xd3, 0x3, 0x0, 0x1, 0x58, 0x21, 0x1c, 0xe2, 0x2, 0x0, 0x0, 0x5, 0xe, 0x15, + 0x0, 0x1, 0x73, 0x1, 0x63, 0x8, 0x0, 0x1c, 0x37, 0x51, 0x94, 0xeb, 0x18, 0x10, 0xea, 0x58, 0x1d, 0x51, 0x86, + 0x55, 0xcc, 0xd6, 0x40, 0xd5, 0xf8, 0x97, 0xa5, 0xb9, 0x58, 0x16, 0x34, 0xbc, 0xda, 0xda, 0x30, 0xc1, 0x19, 0xa3, + 0x15, 0x0, 0x10, 0x20, 0x36, 0xf8, 0x8a, 0xcf, 0x2, 0x58, 0x93, 0xcb, 0xd9, 0x7d, 0xad, 0xf, 0x32, 0xaf, 0x96, + 0x21, 0x66, 0x7c, 0x26, 0x0, 0x11, 0x9d, 0xad, 0x89, 0x8f, 0x90, 0xd, 0x67, 0x54, 0x64, 0x14, 0xa4, 0xca, 0x32, + 0x82, 0x1b, 0x32, 0x9d, 0x0, 0x17, 0xa1, 0xb1, 0x23, 0x95, 0xce, 0x6d, 0x8, 0x21, 0x9e, 0x91, 0x2f, 0x33, 0x94, + 0x2b, 0xf6, 0xab, 0x75, 0x90, 0x32, 0xdb, 0x9c, 0xe8, 0xf9, 0x17, 0x10, 0x9, 0x0, 0x3, 0xd6, 0x1b, 0xcf, 0x23, + 0x46, 0x39, 0x3, 0x0, 0x11, 0xee, 0x37, 0x7f, 0x65, 0xac, 0xb5, 0xbd, 0xb2, 0xbb, 0x6, 0x42, 0x9b, 0x51, 0xc7, + 0x3f, 0x62, 0xc5, 0x19, 0xc5, 0x12, 0x0, 0x0, 0x15, 0x0, 0x1d, 0xa3, 0xc0, 0x8a, 0x32, 0x9, 0x88, 0x81, 0x89, + 0x5f, 0x48, 0x17, 0xbe, 0xea, 0x80, 0xc6, 0xe3, 0x62, 0x45, 0xd8, 0x75, 0xc1, 0x1c, 0x54, 0xe6, 0xe3, 0x71, 0xdf, + 0xce, 0x6, 0x16, 0x0, 0x3, 0x26, 0x6d, 0x23, 0x19, 0xa1, 0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, + 0x26, 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x1a, 0x8f, 0xd9}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, 0x26, + 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 816); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "", _pubPktID = 31057, _pubBody = +// "\199\189\167\ETX\187.\248)\192z\ESC\250{\169\157\255\224d\204\159\r\239\ESC\154Q\171\168", _pubProps = +// [PropAssignedClientIdentifier "_\215U\142P\139~)\tU-",PropResponseInformation +// "\232,2\181O7B\252\204}\223o\147b\134s,\173\159\215\200%o$k\129\149",PropCorrelationData +// "\NUL\203\&7\ENQ\158\134\201\218\&9\192\221%3\172^\225[\186\235\EM2",PropSubscriptionIdentifier +// 29,PropResponseInformation +// "\193\224]\164i:\216}A\234D\203I9\222\&3\129\207e\216\SOHI\t\215\197",PropTopicAliasMaximum +// 26731,PropAuthenticationMethod +// "\ETB\224\178`k\159\206V\DELySa8t;\143!\214\173\202mAd\161\195",PropPayloadFormatIndicator +// 37,PropMessageExpiryInterval 23579,PropServerReference "R\246vJ\166\204\250\ACK\ACKIT\217\193",PropAuthenticationData +// "0\194Lkb\182\232(topic.data), 0); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "V\129\199\DEL\236d\144\134\234\&2\161\f\158;^\GS\152", _pubPktID = 0, _pubBody = +// "\168#\DC4\164\152d\226\231\214\203.3\\K\148y\227\211\138\130B\160L0\153\231\154\201\v0", _pubProps = +// [PropMessageExpiryInterval 7690,PropServerKeepAlive 8084,PropWildcardSubscriptionAvailable +// 145,PropAuthenticationMethod "\225\252\141\141\EOT.\243\188>",PropWildcardSubscriptionAvailable 224,PropTopicAlias +// 8626,PropUserProperty "/\223" +// "\194\201I\235\a\147\160j\157l\248\254[\206\210\DC4\184\140tE\t\130\ETB\234?\199\165\208\205",PropMessageExpiryInterval +// 12891,PropRequestProblemInformation 203,PropReceiveMaximum 28713,PropMaximumQoS 5,PropAuthenticationMethod +// "5]\139\214\162T\234\SO\ETB8\ENQ\243\217\151\rC\206\171\201",PropAssignedClientIdentifier +// "\228\213\164\148sUj\233P\251\DC1\239M\204\208@?0",PropPayloadFormatIndicator 124,PropResponseTopic +// "\165w\178\234\a\147",PropRequestProblemInformation 73,PropSharedSubscriptionAvailable 133,PropMaximumPacketSize +// 6940,PropMaximumQoS 27,PropCorrelationData +// "\141\STX\246\253\217B\210\170\196\142pT\200'\NUL\188\236\&5\216PP\224",PropPayloadFormatIndicator +// 189,PropWildcardSubscriptionAvailable 96,PropResponseInformation +// "\141\148\EOT\203",PropSubscriptionIdentifierAvailable 25,PropMessageExpiryInterval 17864]} +TEST(Publish5QCTest, Encode5) { + uint8_t pkt[] = {0x39, 0xea, 0x1, 0x0, 0x11, 0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, 0x32, 0xa1, 0xc, + 0x9e, 0x3b, 0x5e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, 0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, + 0x94, 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; + uint8_t topic_bytes[] = {0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, + 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, + 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 30; + + uint8_t bytesprops0[] = {0xe1, 0xfc, 0x8d, 0x8d, 0x4, 0x2e, 0xf3, 0xbc, 0x3e}; + uint8_t bytesprops2[] = {0xc2, 0xc9, 0x49, 0xeb, 0x7, 0x93, 0xa0, 0x6a, 0x9d, 0x6c, 0xf8, 0xfe, 0x5b, 0xce, 0xd2, + 0x14, 0xb8, 0x8c, 0x74, 0x45, 0x9, 0x82, 0x17, 0xea, 0x3f, 0xc7, 0xa5, 0xd0, 0xcd}; + uint8_t bytesprops1[] = {0x2f, 0xdf}; + uint8_t bytesprops3[] = {0x35, 0x5d, 0x8b, 0xd6, 0xa2, 0x54, 0xea, 0xe, 0x17, 0x38, + 0x5, 0xf3, 0xd9, 0x97, 0xd, 0x43, 0xce, 0xab, 0xc9}; + uint8_t bytesprops4[] = {0xe4, 0xd5, 0xa4, 0x94, 0x73, 0x55, 0x6a, 0xe9, 0x50, + 0xfb, 0x11, 0xef, 0x4d, 0xcc, 0xd0, 0x40, 0x3f, 0x30}; + uint8_t bytesprops5[] = {0xa5, 0x77, 0xb2, 0xea, 0x7, 0x93}; + uint8_t bytesprops6[] = {0x8d, 0x2, 0xf6, 0xfd, 0xd9, 0x42, 0xd2, 0xaa, 0xc4, 0x8e, 0x70, + 0x54, 0xc8, 0x27, 0x0, 0xbc, 0xec, 0x35, 0xd8, 0x50, 0x50, 0xe0}; + uint8_t bytesprops7[] = {0x8d, 0x94, 0x4, 0xcb}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7690}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8084}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8626}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops1}, .v = {29, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12891}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28713}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6940}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17864}}, }; - lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x35, 0x6b, 0x4b, 0x0, 0x1e, 0x2d, 0xa3, 0x91, 0xc1, 0xb2, 0xaa, - 0x49, 0xc6, 0xaf, 0x7f, 0x24, 0xb0, 0x5c, 0x10, 0x6f, 0x14, 0x36}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x26, 0x9b, 0xe4, 0x13, 0xeb, 0xb4, 0x14, 0x23, 0xdc, 0xc6, 0x52, 0xce, 0xb2, - 0x5b, 0x15, 0x95, 0x5f, 0xf5, 0xce, 0xac, 0x0, 0xcc, 0x1f, 0xd3, 0x55, 0x41}; - lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 32140; - uint8_t client_id_bytes[] = {0x76, 0x43, 0xf8, 0x9b, 0xb1, 0xd5, 0x67, 0x5d, 0xc6}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; - opts.client_id = client_id; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\181\188RC|\DELPc[\242A\194\140G\NAK\CANu\DC4\178\213\DC4", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "\249=\212\228i\201\&4\178&\RS)\DC4|\174\242w \201", _willMsg = -// "@\162c\242\CAN\208f\191d\161\222\184@fP\222\&7\204\176\212\227_\166\242\155W<\DC43", _willProps = -// [PropAuthenticationData "",PropWillDelayInterval 21611,PropRequestResponseInformation 4,PropCorrelationData -// "\196w\189\139\135\209O\159~",PropSessionExpiryInterval 23150,PropMaximumQoS 17,PropPayloadFormatIndicator -// 173,PropRequestProblemInformation 74,PropSubscriptionIdentifierAvailable 11,PropUserProperty -// "\168R\218\128\144\140$G\245\176o\201B\155\&0\DC1\146" -// "\253\169\189S\248Pa\134\ETB\SYN=\ACK\173\177y(\208",PropReceiveMaximum 4756,PropReceiveMaximum -// 28950,PropMessageExpiryInterval 25517,PropMaximumQoS 253,PropResponseTopic -// "\217\212i\186\f\218K\ENQ|1\229\229=\188Q\145~\184\&1\241!\244\209\236\DC1;\189=\RSg"]}), _cleanSession = True, -// _keepAlive = 8577, _connID = "\246\235\226\ACK\SI+\255\134\137\158\247\158\138X\147\188\139\218-\154", _properties = -// [PropResponseTopic "1\245Am\193[\231\FS|\170\143\206\217M\128\181\EM\196\157\ESC\228\215\&7p",PropReasonString -// "x\240\133\&3\250\227b\239:\144\230\187\221"]} -TEST(Connect5QCTest, Encode4) { - uint8_t pkt[] = {0x10, 0xf8, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6, 0x21, 0x81, 0x2b, 0x8, 0x0, 0x18, - 0x31, 0xf5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, 0xe4, 0x69, 0xc9, 0x34, 0xb2, 0x26, 0x1e, 0x29, 0x14, 0x7c, 0xae, 0xf2, 0x77, 0x20, 0xc9, 0x0, - 0x1d, 0x40, 0xa2, 0x63, 0xf2, 0x18, 0xd0, 0x66, 0xbf, 0x64, 0xa1, 0xde, 0xb8, 0x40, 0x66, 0x50, 0xde, - 0x37, 0xcc, 0xb0, 0xd4, 0xe3, 0x5f, 0xa6, 0xf2, 0x9b, 0x57, 0x3c, 0x14, 0x33}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x31, 0xf5, 0x41, 0x6d, 0xc1, 0x5b, 0xe7, 0x1c, 0x7c, 0xaa, 0x8f, 0xce, - 0xd9, 0x4d, 0x80, 0xb5, 0x19, 0xc4, 0x9d, 0x1b, 0xe4, 0xd7, 0x37, 0x70}; - uint8_t bytesprops1[] = {0x78, 0xf0, 0x85, 0x33, 0xfa, 0xe3, 0x62, 0xef, 0x3a, 0x90, 0xe6, 0xbb, 0xdd}; +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "V\129\199\DEL\236d\144\134\234\&2\161\f\158;^\GS\152", _pubPktID = 0, _pubBody = +// "\168#\DC4\164\152d\226\231\214\203.3\\K\148y\227\211\138\130B\160L0\153\231\154\201\v0", _pubProps = +// [PropMessageExpiryInterval 7690,PropServerKeepAlive 8084,PropWildcardSubscriptionAvailable +// 145,PropAuthenticationMethod "\225\252\141\141\EOT.\243\188>",PropWildcardSubscriptionAvailable 224,PropTopicAlias +// 8626,PropUserProperty "/\223" +// "\194\201I\235\a\147\160j\157l\248\254[\206\210\DC4\184\140tE\t\130\ETB\234?\199\165\208\205",PropMessageExpiryInterval +// 12891,PropRequestProblemInformation 203,PropReceiveMaximum 28713,PropMaximumQoS 5,PropAuthenticationMethod +// "5]\139\214\162T\234\SO\ETB8\ENQ\243\217\151\rC\206\171\201",PropAssignedClientIdentifier +// "\228\213\164\148sUj\233P\251\DC1\239M\204\208@?0",PropPayloadFormatIndicator 124,PropResponseTopic +// "\165w\178\234\a\147",PropRequestProblemInformation 73,PropSharedSubscriptionAvailable 133,PropMaximumPacketSize +// 6940,PropMaximumQoS 27,PropCorrelationData +// "\141\STX\246\253\217B\210\170\196\142pT\200'\NUL\188\236\&5\216PP\224",PropPayloadFormatIndicator +// 189,PropWildcardSubscriptionAvailable 96,PropResponseInformation +// "\141\148\EOT\203",PropSubscriptionIdentifierAvailable 25,PropMessageExpiryInterval 17864]} +TEST(Publish5QCTest, Decode5) { + uint8_t pkt[] = {0x39, 0xea, 0x1, 0x0, 0x11, 0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, 0x32, 0xa1, 0xc, + 0x9e, 0x3b, 0x5e, 0x1d, 0x98, 0xb7, 0x1, 0x2, 0x0, 0x0, 0x1e, 0xa, 0x13, 0x1f, 0x94, 0x28, 0x91, + 0x15, 0x0, 0x9, 0xe1, 0xfc, 0x8d, 0x8d, 0x4, 0x2e, 0xf3, 0xbc, 0x3e, 0x28, 0xe0, 0x23, 0x21, 0xb2, + 0x26, 0x0, 0x2, 0x2f, 0xdf, 0x0, 0x1d, 0xc2, 0xc9, 0x49, 0xeb, 0x7, 0x93, 0xa0, 0x6a, 0x9d, 0x6c, + 0xf8, 0xfe, 0x5b, 0xce, 0xd2, 0x14, 0xb8, 0x8c, 0x74, 0x45, 0x9, 0x82, 0x17, 0xea, 0x3f, 0xc7, 0xa5, + 0xd0, 0xcd, 0x2, 0x0, 0x0, 0x32, 0x5b, 0x17, 0xcb, 0x21, 0x70, 0x29, 0x24, 0x5, 0x15, 0x0, 0x13, + 0x35, 0x5d, 0x8b, 0xd6, 0xa2, 0x54, 0xea, 0xe, 0x17, 0x38, 0x5, 0xf3, 0xd9, 0x97, 0xd, 0x43, 0xce, + 0xab, 0xc9, 0x12, 0x0, 0x12, 0xe4, 0xd5, 0xa4, 0x94, 0x73, 0x55, 0x6a, 0xe9, 0x50, 0xfb, 0x11, 0xef, + 0x4d, 0xcc, 0xd0, 0x40, 0x3f, 0x30, 0x1, 0x7c, 0x8, 0x0, 0x6, 0xa5, 0x77, 0xb2, 0xea, 0x7, 0x93, + 0x17, 0x49, 0x2a, 0x85, 0x27, 0x0, 0x0, 0x1b, 0x1c, 0x24, 0x1b, 0x9, 0x0, 0x16, 0x8d, 0x2, 0xf6, + 0xfd, 0xd9, 0x42, 0xd2, 0xaa, 0xc4, 0x8e, 0x70, 0x54, 0xc8, 0x27, 0x0, 0xbc, 0xec, 0x35, 0xd8, 0x50, + 0x50, 0xe0, 0x1, 0xbd, 0x28, 0x60, 0x1a, 0x0, 0x4, 0x8d, 0x94, 0x4, 0xcb, 0x29, 0x19, 0x2, 0x0, + 0x0, 0x45, 0xc8, 0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, + 0x94, 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, + 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98}; + lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, + 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\ESC\176mM-\183\&6\136p\203\156\172", _pubPktID = 0, _pubBody = "\DC2\166\130\180V\157\163bV", _pubProps = +// [PropMessageExpiryInterval 17805,PropTopicAlias 29809,PropMaximumQoS 128,PropRetainAvailable 153,PropRetainAvailable +// 46,PropSharedSubscriptionAvailable 149,PropMaximumQoS 3,PropMaximumQoS 125,PropResponseInformation +// "\167C\211\194(\200\141(\149\DC2\219j\132\&2{\240\186\202L",PropRequestProblemInformation +// 248,PropAuthenticationMethod "\206",PropMaximumQoS 93,PropServerKeepAlive 14778,PropAuthenticationMethod +// "\213\&3i\218\248\201\195\&0\144\DC1\201X\v\ETX",PropContentType +// "=-f\157g\238l\191\136\191\SOH\189\&6t\225xbg",PropMessageExpiryInterval 10427,PropSubscriptionIdentifierAvailable +// 0,PropSessionExpiryInterval 10212,PropTopicAlias 2252,PropServerReference +// "\EM=\"\187\NUL\249;\128\224\141\226\215\213\ETX\ESC7\v0\205\191C\222k8",PropRequestProblemInformation +// 186,PropCorrelationData "\r\236\154\129\SUB\204W\142\209Vt3L\183@A\213y",PropAuthenticationData +// "\FS\156\229\253\233\&4\218\RS\196BB\SI\147\\7\254R-\USD\233q5",PropAuthenticationMethod +// "\249L|\175l\249\USC\CAN\252\EOT\139s",PropAuthenticationData "\147"]} +TEST(Publish5QCTest, Encode6) { + uint8_t pkt[] = {0x31, 0xe3, 0x1, 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c, 0x37, 0xfe, 0x52, 0x2d, 0x1f, 0x44, 0xe9, 0x71, 0x35, 0x15, 0x0, 0xd, + 0xf9, 0x4c, 0x7c, 0xaf, 0x6c, 0xf9, 0x1f, 0x43, 0x18, 0xfc, 0x4, 0x8b, 0x73, 0x16, 0x0, 0x1, 0x93, + 0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; + uint8_t topic_bytes[] = {0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 9; + + uint8_t bytesprops0[] = {0xa7, 0x43, 0xd3, 0xc2, 0x28, 0xc8, 0x8d, 0x28, 0x95, 0x12, + 0xdb, 0x6a, 0x84, 0x32, 0x7b, 0xf0, 0xba, 0xca, 0x4c}; + uint8_t bytesprops1[] = {0xce}; + uint8_t bytesprops2[] = {0xd5, 0x33, 0x69, 0xda, 0xf8, 0xc9, 0xc3, 0x30, 0x90, 0x11, 0xc9, 0x58, 0xb, 0x3}; + uint8_t bytesprops3[] = {0x3d, 0x2d, 0x66, 0x9d, 0x67, 0xee, 0x6c, 0xbf, 0x88, + 0xbf, 0x1, 0xbd, 0x36, 0x74, 0xe1, 0x78, 0x62, 0x67}; + uint8_t bytesprops4[] = {0x19, 0x3d, 0x22, 0xbb, 0x0, 0xf9, 0x3b, 0x80, 0xe0, 0x8d, 0xe2, 0xd7, + 0xd5, 0x3, 0x1b, 0x37, 0xb, 0x30, 0xcd, 0xbf, 0x43, 0xde, 0x6b, 0x38}; + uint8_t bytesprops5[] = {0xd, 0xec, 0x9a, 0x81, 0x1a, 0xcc, 0x57, 0x8e, 0xd1, + 0x56, 0x74, 0x33, 0x4c, 0xb7, 0x40, 0x41, 0xd5, 0x79}; + uint8_t bytesprops6[] = {0x1c, 0x9c, 0xe5, 0xfd, 0xe9, 0x34, 0xda, 0x1e, 0xc4, 0x42, 0x42, 0xf, + 0x93, 0x5c, 0x37, 0xfe, 0x52, 0x2d, 0x1f, 0x44, 0xe9, 0x71, 0x35}; + uint8_t bytesprops7[] = {0xf9, 0x4c, 0x7c, 0xaf, 0x6c, 0xf9, 0x1f, 0x43, 0x18, 0xfc, 0x4, 0x8b, 0x73}; + uint8_t bytesprops8[] = {0x93}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17805}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29809}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14778}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10427}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10212}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2252}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0}; - uint8_t byteswillprops1[] = {0xc4, 0x77, 0xbd, 0x8b, 0x87, 0xd1, 0x4f, 0x9f, 0x7e}; - uint8_t byteswillprops3[] = {0xfd, 0xa9, 0xbd, 0x53, 0xf8, 0x50, 0x61, 0x86, 0x17, - 0x16, 0x3d, 0x6, 0xad, 0xb1, 0x79, 0x28, 0xd0}; - uint8_t byteswillprops2[] = {0xa8, 0x52, 0xda, 0x80, 0x90, 0x8c, 0x24, 0x47, 0xf5, - 0xb0, 0x6f, 0xc9, 0x42, 0x9b, 0x30, 0x11, 0x92}; - uint8_t byteswillprops4[] = {0xd9, 0xd4, 0x69, 0xba, 0xc, 0xda, 0x4b, 0x5, 0x7c, 0x31, - 0xe5, 0xe5, 0x3d, 0xbc, 0x51, 0x91, 0x7e, 0xb8, 0x31, 0xf1, - 0x21, 0xf4, 0xd1, 0xec, 0x11, 0x3b, 0xbd, 0x3d, 0x1e, 0x67}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21611}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23150}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {17, (char*)&byteswillprops2}, .v = {17, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4756}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28950}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25517}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops4}}}, - }; + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf9, 0x3d, 0xd4, 0xe4, 0x69, 0xc9, 0x34, 0xb2, 0x26, - 0x1e, 0x29, 0x14, 0x7c, 0xae, 0xf2, 0x77, 0x20, 0xc9}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x40, 0xa2, 0x63, 0xf2, 0x18, 0xd0, 0x66, 0xbf, 0x64, 0xa1, - 0xde, 0xb8, 0x40, 0x66, 0x50, 0xde, 0x37, 0xcc, 0xb0, 0xd4, - 0xe3, 0x5f, 0xa6, 0xf2, 0x9b, 0x57, 0x3c, 0x14, 0x33}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\ESC\176mM-\183\&6\136p\203\156\172", _pubPktID = 0, _pubBody = "\DC2\166\130\180V\157\163bV", _pubProps = +// [PropMessageExpiryInterval 17805,PropTopicAlias 29809,PropMaximumQoS 128,PropRetainAvailable 153,PropRetainAvailable +// 46,PropSharedSubscriptionAvailable 149,PropMaximumQoS 3,PropMaximumQoS 125,PropResponseInformation +// "\167C\211\194(\200\141(\149\DC2\219j\132\&2{\240\186\202L",PropRequestProblemInformation +// 248,PropAuthenticationMethod "\206",PropMaximumQoS 93,PropServerKeepAlive 14778,PropAuthenticationMethod +// "\213\&3i\218\248\201\195\&0\144\DC1\201X\v\ETX",PropContentType +// "=-f\157g\238l\191\136\191\SOH\189\&6t\225xbg",PropMessageExpiryInterval 10427,PropSubscriptionIdentifierAvailable +// 0,PropSessionExpiryInterval 10212,PropTopicAlias 2252,PropServerReference +// "\EM=\"\187\NUL\249;\128\224\141\226\215\213\ETX\ESC7\v0\205\191C\222k8",PropRequestProblemInformation +// 186,PropCorrelationData "\r\236\154\129\SUB\204W\142\209Vt3L\183@A\213y",PropAuthenticationData +// "\FS\156\229\253\233\&4\218\RS\196BB\SI\147\\7\254R-\USD\233q5",PropAuthenticationMethod +// "\249L|\175l\249\USC\CAN\252\EOT\139s",PropAuthenticationData "\147"]} +TEST(Publish5QCTest, Decode6) { + uint8_t pkt[] = {0x31, 0xe3, 0x1, 0x0, 0xc, 0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac, + 0xca, 0x1, 0x2, 0x0, 0x0, 0x45, 0x8d, 0x23, 0x74, 0x71, 0x24, 0x80, 0x25, 0x99, 0x25, 0x2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x93, + 0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\178\SI\169\146\239\178\SYN\STX", +// _pubPktID = 0, _pubBody = "K\148\ETX%\135\&7\194\158\DLE\ENQ\215\157\176\ESCA\f", _pubProps = +// [PropSessionExpiryInterval 18509,PropWildcardSubscriptionAvailable 204,PropServerKeepAlive +// 24461,PropRequestResponseInformation 156,PropPayloadFormatIndicator 7,PropAssignedClientIdentifier "",PropTopicAlias +// 26242,PropTopicAlias 7376,PropServerReference "\145D\f",PropSubscriptionIdentifier 7]} +TEST(Publish5QCTest, Encode7) { + uint8_t pkt[] = {0x30, 0x3a, 0x0, 0x8, 0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2, 0x1f, 0x11, 0x0, + 0x0, 0x48, 0x4d, 0x28, 0xcc, 0x13, 0x5f, 0x8d, 0x19, 0x9c, 0x1, 0x7, 0x12, 0x0, 0x0, + 0x23, 0x66, 0x82, 0x23, 0x1c, 0xd0, 0x1c, 0x0, 0x3, 0x91, 0x44, 0xc, 0xb, 0x7, 0x4b, + 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; + uint8_t topic_bytes[] = {0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x4b, 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 16; + + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x91, 0x44, 0xc}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18509}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24461}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26242}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7376}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\178\SI\169\146\239\178\SYN\STX", +// _pubPktID = 0, _pubBody = "K\148\ETX%\135\&7\194\158\DLE\ENQ\215\157\176\ESCA\f", _pubProps = +// [PropSessionExpiryInterval 18509,PropWildcardSubscriptionAvailable 204,PropServerKeepAlive +// 24461,PropRequestResponseInformation 156,PropPayloadFormatIndicator 7,PropAssignedClientIdentifier "",PropTopicAlias +// 26242,PropTopicAlias 7376,PropServerReference "\145D\f",PropSubscriptionIdentifier 7]} +TEST(Publish5QCTest, Decode7) { + uint8_t pkt[] = {0x30, 0x3a, 0x0, 0x8, 0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2, 0x1f, 0x11, 0x0, + 0x0, 0x48, 0x4d, 0x28, 0xcc, 0x13, 0x5f, 0x8d, 0x19, 0x9c, 0x1, 0x7, 0x12, 0x0, 0x0, + 0x23, 0x66, 0x82, 0x23, 0x1c, 0xd0, 0x1c, 0x0, 0x3, 0x91, 0x44, 0xc, 0xb, 0x7, 0x4b, + 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4b, 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, + 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\164Y\252JlD$\198\DC1l\vM\194\NAK\194I\144\STX:c\158)N*", _pubPktID = 7891, _pubBody = +// "\176\162\NAK'B\224M\185\SYNa\n\151\146\160U", _pubProps = [PropSessionExpiryInterval 2392,PropServerReference +// "\153\182\131\197\135\174\198\132\EOT[\239\255F\240\196B\162",PropCorrelationData +// "\212",PropRequestResponseInformation 95,PropMessageExpiryInterval 25207,PropRetainAvailable +// 216,PropAssignedClientIdentifier "\149\164\215\200\249\n\RS\155{",PropAssignedClientIdentifier +// "\\\246\175\154*\160\ETB]mH\162\130\157\NUL\253\&2C\SO\\I",PropMaximumQoS 211,PropWillDelayInterval +// 18802,PropMaximumQoS 128,PropPayloadFormatIndicator 208,PropSharedSubscriptionAvailable 4,PropAuthenticationData +// "\150\167E\SIJ\131?\n\147\188\144\177\232\203\187\219\181\ESC\230!\250Xmb",PropSubscriptionIdentifier +// 12,PropMessageExpiryInterval 1249,PropSessionExpiryInterval 20430,PropReceiveMaximum +// 8060,PropWildcardSubscriptionAvailable 85]} +TEST(Publish5QCTest, Encode8) { + uint8_t pkt[] = {0x35, 0xaf, 0x1, 0x0, 0x18, 0xa4, 0x59, 0xfc, 0x4a, 0x6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49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 15; + + uint8_t bytesprops0[] = {0x99, 0xb6, 0x83, 0xc5, 0x87, 0xae, 0xc6, 0x84, 0x4, + 0x5b, 0xef, 0xff, 0x46, 0xf0, 0xc4, 0x42, 0xa2}; + uint8_t bytesprops1[] = {0xd4}; + uint8_t bytesprops2[] = {0x95, 0xa4, 0xd7, 0xc8, 0xf9, 0xa, 0x1e, 0x9b, 0x7b}; + uint8_t bytesprops3[] = {0x5c, 0xf6, 0xaf, 0x9a, 0x2a, 0xa0, 0x17, 0x5d, 0x6d, 0x48, + 0xa2, 0x82, 0x9d, 0x0, 0xfd, 0x32, 0x43, 0xe, 0x5c, 0x49}; + uint8_t bytesprops4[] = {0x96, 0xa7, 0x45, 0xf, 0x4a, 0x83, 0x3f, 0xa, 0x93, 0xbc, 0x90, 0xb1, + 0xe8, 0xcb, 0xbb, 0xdb, 0xb5, 0x1b, 0xe6, 0x21, 0xfa, 0x58, 0x6d, 0x62}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2392}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25207}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18802}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1249}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20430}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8060}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 85}}, + }; + + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7891, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\164Y\252JlD$\198\DC1l\vM\194\NAK\194I\144\STX:c\158)N*", _pubPktID = 7891, _pubBody = +// "\176\162\NAK'B\224M\185\SYNa\n\151\146\160U", _pubProps = [PropSessionExpiryInterval 2392,PropServerReference +// "\153\182\131\197\135\174\198\132\EOT[\239\255F\240\196B\162",PropCorrelationData +// "\212",PropRequestResponseInformation 95,PropMessageExpiryInterval 25207,PropRetainAvailable +// 216,PropAssignedClientIdentifier "\149\164\215\200\249\n\RS\155{",PropAssignedClientIdentifier +// "\\\246\175\154*\160\ETB]mH\162\130\157\NUL\253\&2C\SO\\I",PropMaximumQoS 211,PropWillDelayInterval +// 18802,PropMaximumQoS 128,PropPayloadFormatIndicator 208,PropSharedSubscriptionAvailable 4,PropAuthenticationData +// "\150\167E\SIJ\131?\n\147\188\144\177\232\203\187\219\181\ESC\230!\250Xmb",PropSubscriptionIdentifier +// 12,PropMessageExpiryInterval 1249,PropSessionExpiryInterval 20430,PropReceiveMaximum +// 8060,PropWildcardSubscriptionAvailable 85]} +TEST(Publish5QCTest, Decode8) { + uint8_t pkt[] = {0x35, 0xaf, 0x1, 0x0, 0x18, 0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, 0x4d, + 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a, 0x1e, 0xd3, 0x82, 0x1, 0x11, + 0x0, 0x0, 0x9, 0x58, 0x1c, 0x0, 0x11, 0x99, 0xb6, 0x83, 0xc5, 0x87, 0xae, 0xc6, 0x84, 0x4, 0x5b, + 0xef, 0xff, 0x46, 0xf0, 0xc4, 0x42, 0xa2, 0x9, 0x0, 0x1, 0xd4, 0x19, 0x5f, 0x2, 0x0, 0x0, 0x62, + 0x77, 0x25, 0xd8, 0x12, 0x0, 0x9, 0x95, 0xa4, 0xd7, 0xc8, 0xf9, 0xa, 0x1e, 0x9b, 0x7b, 0x12, 0x0, + 0x14, 0x5c, 0xf6, 0xaf, 0x9a, 0x2a, 0xa0, 0x17, 0x5d, 0x6d, 0x48, 0xa2, 0x82, 0x9d, 0x0, 0xfd, 0x32, + 0x43, 0xe, 0x5c, 0x49, 0x24, 0xd3, 0x18, 0x0, 0x0, 0x49, 0x72, 0x24, 0x80, 0x1, 0xd0, 0x2a, 0x4, + 0x16, 0x0, 0x18, 0x96, 0xa7, 0x45, 0xf, 0x4a, 0x83, 0x3f, 0xa, 0x93, 0xbc, 0x90, 0xb1, 0xe8, 0xcb, + 0xbb, 0xdb, 0xb5, 0x1b, 0xe6, 0x21, 0xfa, 0x58, 0x6d, 0x62, 0xb, 0xc, 0x2, 0x0, 0x0, 0x4, 0xe1, + 0x11, 0x0, 0x0, 0x4f, 0xce, 0x21, 0x1f, 0x7c, 0x28, 0x55, 0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, + 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, 0x4d, + 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 7891); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\168\NAKx\SI\199\207\184(\186\150r\FS\189\205\252\135\250\205\254\148\161\239\228\176s", _pubPktID = 0, _pubBody = +// "\135", _pubProps = [PropSharedSubscriptionAvailable 243,PropAuthenticationMethod +// "\EM\146\213\227R",PropSessionExpiryInterval 30811]} +TEST(Publish5QCTest, Encode9) { + uint8_t pkt[] = {0x31, 0x2c, 0x0, 0x19, 0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, + 0xbd, 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73, 0xf, 0x2a, 0xf3, + 0x15, 0x0, 0x5, 0x19, 0x92, 0xd5, 0xe3, 0x52, 0x11, 0x0, 0x0, 0x78, 0x5b, 0x87}; + uint8_t topic_bytes[] = {0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, 0xbd, + 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x87}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + uint8_t bytesprops0[] = {0x19, 0x92, 0xd5, 0xe3, 0x52}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30811}}, + }; + + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\168\NAKx\SI\199\207\184(\186\150r\FS\189\205\252\135\250\205\254\148\161\239\228\176s", _pubPktID = 0, _pubBody = +// "\135", _pubProps = [PropSharedSubscriptionAvailable 243,PropAuthenticationMethod +// "\EM\146\213\227R",PropSessionExpiryInterval 30811]} +TEST(Publish5QCTest, Decode9) { + uint8_t pkt[] = {0x31, 0x2c, 0x0, 0x19, 0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, + 0xbd, 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73, 0xf, 0x2a, 0xf3, + 0x15, 0x0, 0x5, 0x19, 0x92, 0xd5, 0xe3, 0x52, 0x11, 0x0, 0x0, 0x78, 0x5b, 0x87}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, 0xbd, + 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x87}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\140r\DC3\130\161\ENQ", _pubPktID = +// 6491, _pubBody = "\241G\235!\175\252\158\183\145\224\246\172\SYN\130\131/\254\205\ENQ\GS?", _pubProps = +// [PropResponseTopic "\131\205\&2\194yD\165\177\183\161\144z",PropReasonString +// "\229\216EX`\EOT\171\146\185\bl\224\&6VsG\200z0-]|",PropRequestResponseInformation 60,PropSessionExpiryInterval +// 21347,PropSubscriptionIdentifier 29,PropUserProperty +// "\207*\196\202)\141^C+\128\131\208\195[\ETB\136\184\SYN\243\206\DC4\168" +// "\236,\167o\134F\241\140\GS\187J\131\194\247f<\158{\189\ACK\SOHUk\192",PropAuthenticationData +// "\"Vf\232]\CAN\189=\235F\150c",PropSessionExpiryInterval 22735,PropServerKeepAlive 31363,PropRetainAvailable +// 54,PropAuthenticationMethod +// "\165\212~\DC4\a\227R\US\150\195\221\&4\145\220\&31yVM\226\SOH\188\190-\ETXV\196\236s",PropAuthenticationData +// "k\201W\138\129\r\135\146\166\233\214"]} +TEST(Publish5QCTest, Encode10) { + uint8_t pkt[] = { + 0x3a, 0xcc, 0x1, 0x0, 0x6, 0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5, 0x19, 0x5b, 0xab, 0x1, 0x8, 0x0, 0xc, 0x83, + 0xcd, 0x32, 0xc2, 0x79, 0x44, 0xa5, 0xb1, 0xb7, 0xa1, 0x90, 0x7a, 0x1f, 0x0, 0x16, 0xe5, 0xd8, 0x45, 0x58, 0x60, + 0x4, 0xab, 0x92, 0xb9, 0x8, 0x6c, 0xe0, 0x36, 0x56, 0x73, 0x47, 0xc8, 0x7a, 0x30, 0x2d, 0x5d, 0x7c, 0x19, 0x3c, + 0x11, 0x0, 0x0, 0x53, 0x63, 0xb, 0x1d, 0x26, 0x0, 0x16, 0xcf, 0x2a, 0xc4, 0xca, 0x29, 0x8d, 0x5e, 0x43, 0x2b, + 0x80, 0x83, 0xd0, 0xc3, 0x5b, 0x17, 0x88, 0xb8, 0x16, 0xf3, 0xce, 0x14, 0xa8, 0x0, 0x18, 0xec, 0x2c, 0xa7, 0x6f, + 0x86, 0x46, 0xf1, 0x8c, 0x1d, 0xbb, 0x4a, 0x83, 0xc2, 0xf7, 0x66, 0x3c, 0x9e, 0x7b, 0xbd, 0x6, 0x1, 0x55, 0x6b, + 0xc0, 0x16, 0x0, 0xc, 0x22, 0x56, 0x66, 0xe8, 0x5d, 0x18, 0xbd, 0x3d, 0xeb, 0x46, 0x96, 0x63, 0x11, 0x0, 0x0, + 0x58, 0xcf, 0x13, 0x7a, 0x83, 0x25, 0x36, 0x15, 0x0, 0x1d, 0xa5, 0xd4, 0x7e, 0x14, 0x7, 0xe3, 0x52, 0x1f, 0x96, + 0xc3, 0xdd, 0x34, 0x91, 0xdc, 0x33, 0x31, 0x79, 0x56, 0x4d, 0xe2, 0x1, 0xbc, 0xbe, 0x2d, 0x3, 0x56, 0xc4, 0xec, + 0x73, 0x16, 0x0, 0xb, 0x6b, 0xc9, 0x57, 0x8a, 0x81, 0xd, 0x87, 0x92, 0xa6, 0xe9, 0xd6, 0xf1, 0x47, 0xeb, 0x21, + 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; + uint8_t topic_bytes[] = {0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xf1, 0x47, 0xeb, 0x21, 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, + 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 21; + + uint8_t bytesprops0[] = {0x83, 0xcd, 0x32, 0xc2, 0x79, 0x44, 0xa5, 0xb1, 0xb7, 0xa1, 0x90, 0x7a}; + uint8_t bytesprops1[] = {0xe5, 0xd8, 0x45, 0x58, 0x60, 0x4, 0xab, 0x92, 0xb9, 0x8, 0x6c, + 0xe0, 0x36, 0x56, 0x73, 0x47, 0xc8, 0x7a, 0x30, 0x2d, 0x5d, 0x7c}; + uint8_t bytesprops3[] = {0xec, 0x2c, 0xa7, 0x6f, 0x86, 0x46, 0xf1, 0x8c, 0x1d, 0xbb, 0x4a, 0x83, + 0xc2, 0xf7, 0x66, 0x3c, 0x9e, 0x7b, 0xbd, 0x6, 0x1, 0x55, 0x6b, 0xc0}; + uint8_t bytesprops2[] = {0xcf, 0x2a, 0xc4, 0xca, 0x29, 0x8d, 0x5e, 0x43, 0x2b, 0x80, 0x83, + 0xd0, 0xc3, 0x5b, 0x17, 0x88, 0xb8, 0x16, 0xf3, 0xce, 0x14, 0xa8}; + uint8_t bytesprops4[] = {0x22, 0x56, 0x66, 0xe8, 0x5d, 0x18, 0xbd, 0x3d, 0xeb, 0x46, 0x96, 0x63}; + uint8_t bytesprops5[] = {0xa5, 0xd4, 0x7e, 0x14, 0x7, 0xe3, 0x52, 0x1f, 0x96, 0xc3, 0xdd, 0x34, 0x91, 0xdc, 0x33, + 0x31, 0x79, 0x56, 0x4d, 0xe2, 0x1, 0xbc, 0xbe, 0x2d, 0x3, 0x56, 0xc4, 0xec, 0x73}; + uint8_t bytesprops6[] = {0x6b, 0xc9, 0x57, 0x8a, 0x81, 0xd, 0x87, 0x92, 0xa6, 0xe9, 0xd6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21347}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops2}, .v = {24, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22735}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31363}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops6}}}, + }; + + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6491, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\140r\DC3\130\161\ENQ", _pubPktID = +// 6491, _pubBody = "\241G\235!\175\252\158\183\145\224\246\172\SYN\130\131/\254\205\ENQ\GS?", _pubProps = +// [PropResponseTopic "\131\205\&2\194yD\165\177\183\161\144z",PropReasonString +// "\229\216EX`\EOT\171\146\185\bl\224\&6VsG\200z0-]|",PropRequestResponseInformation 60,PropSessionExpiryInterval +// 21347,PropSubscriptionIdentifier 29,PropUserProperty +// "\207*\196\202)\141^C+\128\131\208\195[\ETB\136\184\SYN\243\206\DC4\168" +// "\236,\167o\134F\241\140\GS\187J\131\194\247f<\158{\189\ACK\SOHUk\192",PropAuthenticationData +// "\"Vf\232]\CAN\189=\235F\150c",PropSessionExpiryInterval 22735,PropServerKeepAlive 31363,PropRetainAvailable +// 54,PropAuthenticationMethod +// "\165\212~\DC4\a\227R\US\150\195\221\&4\145\220\&31yVM\226\SOH\188\190-\ETXV\196\236s",PropAuthenticationData +// "k\201W\138\129\r\135\146\166\233\214"]} +TEST(Publish5QCTest, Decode10) { + uint8_t pkt[] = { + 0x3a, 0xcc, 0x1, 0x0, 0x6, 0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5, 0x19, 0x5b, 0xab, 0x1, 0x8, 0x0, 0xc, 0x83, + 0xcd, 0x32, 0xc2, 0x79, 0x44, 0xa5, 0xb1, 0xb7, 0xa1, 0x90, 0x7a, 0x1f, 0x0, 0x16, 0xe5, 0xd8, 0x45, 0x58, 0x60, + 0x4, 0xab, 0x92, 0xb9, 0x8, 0x6c, 0xe0, 0x36, 0x56, 0x73, 0x47, 0xc8, 0x7a, 0x30, 0x2d, 0x5d, 0x7c, 0x19, 0x3c, + 0x11, 0x0, 0x0, 0x53, 0x63, 0xb, 0x1d, 0x26, 0x0, 0x16, 0xcf, 0x2a, 0xc4, 0xca, 0x29, 0x8d, 0x5e, 0x43, 0x2b, + 0x80, 0x83, 0xd0, 0xc3, 0x5b, 0x17, 0x88, 0xb8, 0x16, 0xf3, 0xce, 0x14, 0xa8, 0x0, 0x18, 0xec, 0x2c, 0xa7, 0x6f, + 0x86, 0x46, 0xf1, 0x8c, 0x1d, 0xbb, 0x4a, 0x83, 0xc2, 0xf7, 0x66, 0x3c, 0x9e, 0x7b, 0xbd, 0x6, 0x1, 0x55, 0x6b, + 0xc0, 0x16, 0x0, 0xc, 0x22, 0x56, 0x66, 0xe8, 0x5d, 0x18, 0xbd, 0x3d, 0xeb, 0x46, 0x96, 0x63, 0x11, 0x0, 0x0, + 0x58, 0xcf, 0x13, 0x7a, 0x83, 0x25, 0x36, 0x15, 0x0, 0x1d, 0xa5, 0xd4, 0x7e, 0x14, 0x7, 0xe3, 0x52, 0x1f, 0x96, + 0xc3, 0xdd, 0x34, 0x91, 0xdc, 0x33, 0x31, 0x79, 0x56, 0x4d, 0xe2, 0x1, 0xbc, 0xbe, 0x2d, 0x3, 0x56, 0xc4, 0xec, + 0x73, 0x16, 0x0, 0xb, 0x6b, 0xc9, 0x57, 0x8a, 0x81, 0xd, 0x87, 0x92, 0xa6, 0xe9, 0xd6, 0xf1, 0x47, 0xeb, 0x21, + 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf1, 0x47, 0xeb, 0x21, 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, + 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 6491); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\239\238\236\203\SI", _pubPktID = +// 8912, _pubBody = "\fH\EOT\166q\ESC\ESC\185\177A", _pubProps = [PropReasonString +// "\225\165\129\142\147\&7T\193\242o\a1\190\128@",PropWillDelayInterval 9183,PropResponseTopic +// "E{<",PropWildcardSubscriptionAvailable 82,PropSessionExpiryInterval 21830,PropSubscriptionIdentifier +// 4,PropResponseTopic "q\172\150W\180TB+\249?\228\223\&2h\162\149\ETX\EOT\217\179"]} +TEST(Publish5QCTest, Encode11) { + uint8_t pkt[] = {0x32, 0x51, 0x0, 0x5, 0xef, 0xee, 0xec, 0xcb, 0xf, 0x22, 0xd0, 0x3d, 0x1f, 0x0, 0xf, 0xe1, 0xa5, + 0x81, 0x8e, 0x93, 0x37, 0x54, 0xc1, 0xf2, 0x6f, 0x7, 0x31, 0xbe, 0x80, 0x40, 0x18, 0x0, 0x0, 0x23, + 0xdf, 0x8, 0x0, 0x3, 0x45, 0x7b, 0x3c, 0x28, 0x52, 0x11, 0x0, 0x0, 0x55, 0x46, 0xb, 0x4, 0x8, + 0x0, 0x14, 0x71, 0xac, 0x96, 0x57, 0xb4, 0x54, 0x42, 0x2b, 0xf9, 0x3f, 0xe4, 0xdf, 0x32, 0x68, 0xa2, + 0x95, 0x3, 0x4, 0xd9, 0xb3, 0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; + uint8_t topic_bytes[] = {0xef, 0xee, 0xec, 0xcb, 0xf}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 10; + + uint8_t bytesprops0[] = {0xe1, 0xa5, 0x81, 0x8e, 0x93, 0x37, 0x54, 0xc1, 0xf2, 0x6f, 0x7, 0x31, 0xbe, 0x80, 0x40}; + uint8_t bytesprops1[] = {0x45, 0x7b, 0x3c}; + uint8_t bytesprops2[] = {0x71, 0xac, 0x96, 0x57, 0xb4, 0x54, 0x42, 0x2b, 0xf9, 0x3f, + 0xe4, 0xdf, 0x32, 0x68, 0xa2, 0x95, 0x3, 0x4, 0xd9, 0xb3}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9183}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21830}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops2}}}, + }; + + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 8912, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\239\238\236\203\SI", _pubPktID = +// 8912, _pubBody = "\fH\EOT\166q\ESC\ESC\185\177A", _pubProps = [PropReasonString +// "\225\165\129\142\147\&7T\193\242o\a1\190\128@",PropWillDelayInterval 9183,PropResponseTopic +// "E{<",PropWildcardSubscriptionAvailable 82,PropSessionExpiryInterval 21830,PropSubscriptionIdentifier +// 4,PropResponseTopic "q\172\150W\180TB+\249?\228\223\&2h\162\149\ETX\EOT\217\179"]} +TEST(Publish5QCTest, Decode11) { + uint8_t pkt[] = {0x32, 0x51, 0x0, 0x5, 0xef, 0xee, 0xec, 0xcb, 0xf, 0x22, 0xd0, 0x3d, 0x1f, 0x0, 0xf, 0xe1, 0xa5, + 0x81, 0x8e, 0x93, 0x37, 0x54, 0xc1, 0xf2, 0x6f, 0x7, 0x31, 0xbe, 0x80, 0x40, 0x18, 0x0, 0x0, 0x23, + 0xdf, 0x8, 0x0, 0x3, 0x45, 0x7b, 0x3c, 0x28, 0x52, 0x11, 0x0, 0x0, 0x55, 0x46, 0xb, 0x4, 0x8, + 0x0, 0x14, 0x71, 0xac, 0x96, 0x57, 0xb4, 0x54, 0x42, 0x2b, 0xf9, 0x3f, 0xe4, 0xdf, 0x32, 0x68, 0xa2, + 0x95, 0x3, 0x4, 0xd9, 0xb3, 0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xef, 0xee, 0xec, 0xcb, 0xf}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 8912); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "[", _pubPktID = 16570, _pubBody = +// "\173\247\147\148\f{|ku\211\&0\DC3\224\227di\ETX\214[\DEL\138I\133\r8{", _pubProps = [PropAuthenticationData +// "\201\130\227x)\225\205\159\186k",PropMessageExpiryInterval 23158,PropMessageExpiryInterval +// 24649,PropTopicAliasMaximum 28197,PropTopicAliasMaximum 26355,PropContentType "\198\230\148 +// \ACK\252(\ENQo\237\214\224Zinzi\EOT\192\129T\147$",PropMaximumQoS 167,PropRetainAvailable 23,PropContentType +// "\250o\139\nJ\DC3\240\&6\180\159\247y\176p\198\SO\238\138A",PropReceiveMaximum 32721]} +TEST(Publish5QCTest, Encode12) { + uint8_t pkt[] = {0x3a, 0x74, 0x0, 0x1, 0x5b, 0x40, 0xba, 0x54, 0x16, 0x0, 0xa, 0xc9, 0x82, 0xe3, 0x78, 0x29, 0xe1, + 0xcd, 0x9f, 0xba, 0x6b, 0x2, 0x0, 0x0, 0x5a, 0x76, 0x2, 0x0, 0x0, 0x60, 0x49, 0x22, 0x6e, 0x25, + 0x22, 0x66, 0xf3, 0x3, 0x0, 0x17, 0xc6, 0xe6, 0x94, 0x20, 0x6, 0xfc, 0x28, 0x5, 0x6f, 0xed, 0xd6, + 0xe0, 0x5a, 0x69, 0x6e, 0x7a, 0x69, 0x4, 0xc0, 0x81, 0x54, 0x93, 0x24, 0x24, 0xa7, 0x25, 0x17, 0x3, + 0x0, 0x13, 0xfa, 0x6f, 0x8b, 0xa, 0x4a, 0x13, 0xf0, 0x36, 0xb4, 0x9f, 0xf7, 0x79, 0xb0, 0x70, 0xc6, + 0xe, 0xee, 0x8a, 0x41, 0x21, 0x7f, 0xd1, 0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, + 0x30, 0x13, 0xe0, 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; + uint8_t topic_bytes[] = {0x5b}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, 0x30, 0x13, 0xe0, + 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + uint8_t bytesprops0[] = {0xc9, 0x82, 0xe3, 0x78, 0x29, 0xe1, 0xcd, 0x9f, 0xba, 0x6b}; + uint8_t bytesprops1[] = {0xc6, 0xe6, 0x94, 0x20, 0x6, 0xfc, 0x28, 0x5, 0x6f, 0xed, 0xd6, 0xe0, + 0x5a, 0x69, 0x6e, 0x7a, 0x69, 0x4, 0xc0, 0x81, 0x54, 0x93, 0x24}; + uint8_t bytesprops2[] = {0xfa, 0x6f, 0x8b, 0xa, 0x4a, 0x13, 0xf0, 0x36, 0xb4, 0x9f, + 0xf7, 0x79, 0xb0, 0x70, 0xc6, 0xe, 0xee, 0x8a, 0x41}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23158}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24649}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28197}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26355}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32721}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16570, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "[", _pubPktID = 16570, _pubBody = +// "\173\247\147\148\f{|ku\211\&0\DC3\224\227di\ETX\214[\DEL\138I\133\r8{", _pubProps = [PropAuthenticationData +// "\201\130\227x)\225\205\159\186k",PropMessageExpiryInterval 23158,PropMessageExpiryInterval +// 24649,PropTopicAliasMaximum 28197,PropTopicAliasMaximum 26355,PropContentType "\198\230\148 +// \ACK\252(\ENQo\237\214\224Zinzi\EOT\192\129T\147$",PropMaximumQoS 167,PropRetainAvailable 23,PropContentType +// "\250o\139\nJ\DC3\240\&6\180\159\247y\176p\198\SO\238\138A",PropReceiveMaximum 32721]} +TEST(Publish5QCTest, Decode12) { + uint8_t pkt[] = {0x3a, 0x74, 0x0, 0x1, 0x5b, 0x40, 0xba, 0x54, 0x16, 0x0, 0xa, 0xc9, 0x82, 0xe3, 0x78, 0x29, 0xe1, + 0xcd, 0x9f, 0xba, 0x6b, 0x2, 0x0, 0x0, 0x5a, 0x76, 0x2, 0x0, 0x0, 0x60, 0x49, 0x22, 0x6e, 0x25, + 0x22, 0x66, 0xf3, 0x3, 0x0, 0x17, 0xc6, 0xe6, 0x94, 0x20, 0x6, 0xfc, 0x28, 0x5, 0x6f, 0xed, 0xd6, + 0xe0, 0x5a, 0x69, 0x6e, 0x7a, 0x69, 0x4, 0xc0, 0x81, 0x54, 0x93, 0x24, 0x24, 0xa7, 0x25, 0x17, 0x3, + 0x0, 0x13, 0xfa, 0x6f, 0x8b, 0xa, 0x4a, 0x13, 0xf0, 0x36, 0xb4, 0x9f, 0xf7, 0x79, 0xb0, 0x70, 0xc6, + 0xe, 0xee, 0x8a, 0x41, 0x21, 0x7f, 0xd1, 0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, + 0x30, 0x13, 0xe0, 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5b}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, 0x30, 0x13, 0xe0, + 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 16570); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\187Ue\150\168f\243G", _pubPktID = +// 0, _pubBody = "Y\133", _pubProps = [PropSessionExpiryInterval 5902,PropResponseInformation +// "\248\175\DC1n\150h\n#\US\SI\225\&1\t\139\161\215\254\240\177O@",PropReasonString +// "|\231\193\196\&3e\197",PropReasonString "7\218\ENQ\242\n`\221\140\158\184\235"]} +TEST(Publish5QCTest, Encode13) { + uint8_t pkt[] = {0x38, 0x42, 0x0, 0x8, 0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47, 0x35, 0x11, + 0x0, 0x0, 0x17, 0xe, 0x1a, 0x0, 0x15, 0xf8, 0xaf, 0x11, 0x6e, 0x96, 0x68, 0xa, + 0x23, 0x1f, 0xf, 0xe1, 0x31, 0x9, 0x8b, 0xa1, 0xd7, 0xfe, 0xf0, 0xb1, 0x4f, 0x40, + 0x1f, 0x0, 0x7, 0x7c, 0xe7, 0xc1, 0xc4, 0x33, 0x65, 0xc5, 0x1f, 0x0, 0xb, 0x37, + 0xda, 0x5, 0xf2, 0xa, 0x60, 0xdd, 0x8c, 0x9e, 0xb8, 0xeb, 0x59, 0x85}; + uint8_t topic_bytes[] = {0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x59, 0x85}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 2; + + uint8_t bytesprops0[] = {0xf8, 0xaf, 0x11, 0x6e, 0x96, 0x68, 0xa, 0x23, 0x1f, 0xf, 0xe1, + 0x31, 0x9, 0x8b, 0xa1, 0xd7, 0xfe, 0xf0, 0xb1, 0x4f, 0x40}; + uint8_t bytesprops1[] = {0x7c, 0xe7, 0xc1, 0xc4, 0x33, 0x65, 0xc5}; + uint8_t bytesprops2[] = {0x37, 0xda, 0x5, 0xf2, 0xa, 0x60, 0xdd, 0x8c, 0x9e, 0xb8, 0xeb}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5902}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops2}}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\187Ue\150\168f\243G", _pubPktID = +// 0, _pubBody = "Y\133", _pubProps = [PropSessionExpiryInterval 5902,PropResponseInformation +// "\248\175\DC1n\150h\n#\US\SI\225\&1\t\139\161\215\254\240\177O@",PropReasonString +// "|\231\193\196\&3e\197",PropReasonString "7\218\ENQ\242\n`\221\140\158\184\235"]} +TEST(Publish5QCTest, Decode13) { + uint8_t pkt[] = {0x38, 0x42, 0x0, 0x8, 0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47, 0x35, 0x11, + 0x0, 0x0, 0x17, 0xe, 0x1a, 0x0, 0x15, 0xf8, 0xaf, 0x11, 0x6e, 0x96, 0x68, 0xa, + 0x23, 0x1f, 0xf, 0xe1, 0x31, 0x9, 0x8b, 0xa1, 0xd7, 0xfe, 0xf0, 0xb1, 0x4f, 0x40, + 0x1f, 0x0, 0x7, 0x7c, 0xe7, 0xc1, 0xc4, 0x33, 0x65, 0xc5, 0x1f, 0x0, 0xb, 0x37, + 0xda, 0x5, 0xf2, 0xa, 0x60, 0xdd, 0x8c, 0x9e, 0xb8, 0xeb, 0x59, 0x85}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x59, 0x85}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\165\&4\a\246}\148\174\&8\186i\137\223\STX*Sv", _pubPktID = 0, _pubBody = "\243\233\SOH\134\243=c\212", _pubProps = +// [PropResponseInformation "\FSD'\182\202\140M\222[\r\156",PropCorrelationData +// "\CAN\164\185\bs\183\FS\163\b\\\ETB\255\156\164\193\SO\181\ESC\179\138\207rk\233\178Pb",PropUserProperty +// "\200\250\152\250\\\211\&2" "D\157HMnegk\131Q1F\EOTg\130\254\219\164\229",PropServerReference +// "9\133\188\151E\b\US\DEL8<8\154+\151>\209Q\DC4\185M\221\SYN\245\135M\239\238",PropResponseTopic +// "",PropResponseInformation "\142(\152<<\221\SI\GS\199",PropMaximumPacketSize 17129,PropResponseInformation +// "C\166'\167\137\221\199\226r\231\195\237\255`1\176\STX",PropSubscriptionIdentifierAvailable 198,PropServerReference +// "\177\139r\DLE\141\r\216\163l\196",PropMaximumPacketSize 27506,PropMessageExpiryInterval 15713,PropCorrelationData +// "h\184\199>SUY\163\163\244\201\152\f9\RS\151n\250O\218\182 \216\197c\226Nt",PropRequestResponseInformation +// 142,PropMessageExpiryInterval 21146,PropMessageExpiryInterval 2479,PropReceiveMaximum 14556,PropAuthenticationMethod +// "\SI\237\130%\ENQTo\141!^\FS\171+5&e\203l\CAN\137-,,",PropSessionExpiryInterval 8323,PropRequestResponseInformation +// 141,PropWillDelayInterval 32675]} +TEST(Publish5QCTest, Encode14) { + uint8_t pkt[] = { + 0x30, 0x9a, 0x2, 0x0, 0x10, 0xa5, 0x34, 0x7, 0xf6, 0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0x1c, 0x68, 0xb8, 0xc7, 0x3e, 0x53, 0x55, 0x59, 0xa3, 0xa3, 0xf4, 0xc9, 0x98, 0xc, + 0x39, 0x1e, 0x97, 0x6e, 0xfa, 0x4f, 0xda, 0xb6, 0x20, 0xd8, 0xc5, 0x63, 0xe2, 0x4e, 0x74, 0x19, 0x8e, 0x2, 0x0, + 0x0, 0x52, 0x9a, 0x2, 0x0, 0x0, 0x9, 0xaf, 0x21, 0x38, 0xdc, 0x15, 0x0, 0x17, 0xf, 0xed, 0x82, 0x25, 0x5, + 0x54, 0x6f, 0x8d, 0x21, 0x5e, 0x1c, 0xab, 0x2b, 0x35, 0x26, 0x65, 0xcb, 0x6c, 0x18, 0x89, 0x2d, 0x2c, 0x2c, 0x11, + 0x0, 0x0, 0x20, 0x83, 0x19, 0x8d, 0x18, 0x0, 0x0, 0x7f, 0xa3, 0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + uint8_t topic_bytes[] = {0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, + 0xba, 0x69, 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 8; + + uint8_t bytesprops0[] = {0x1c, 0x44, 0x27, 0xb6, 0xca, 0x8c, 0x4d, 0xde, 0x5b, 0xd, 0x9c}; + uint8_t bytesprops1[] = {0x18, 0xa4, 0xb9, 0x8, 0x73, 0xb7, 0x1c, 0xa3, 0x8, 0x5c, 0x17, 0xff, 0x9c, 0xa4, + 0xc1, 0xe, 0xb5, 0x1b, 0xb3, 0x8a, 0xcf, 0x72, 0x6b, 0xe9, 0xb2, 0x50, 0x62}; + uint8_t bytesprops3[] = {0x44, 0x9d, 0x48, 0x4d, 0x6e, 0x65, 0x67, 0x6b, 0x83, 0x51, + 0x31, 0x46, 0x4, 0x67, 0x82, 0xfe, 0xdb, 0xa4, 0xe5}; + uint8_t bytesprops2[] = {0xc8, 0xfa, 0x98, 0xfa, 0x5c, 0xd3, 0x32}; + uint8_t bytesprops4[] = {0x39, 0x85, 0xbc, 0x97, 0x45, 0x8, 0x1f, 0x7f, 0x38, 0x3c, 0x38, 0x9a, 0x2b, 0x97, + 0x3e, 0xd1, 0x51, 0x14, 0xb9, 0x4d, 0xdd, 0x16, 0xf5, 0x87, 0x4d, 0xef, 0xee}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0x8e, 0x28, 0x98, 0x3c, 0x3c, 0xdd, 0xf, 0x1d, 0xc7}; + uint8_t bytesprops7[] = {0x43, 0xa6, 0x27, 0xa7, 0x89, 0xdd, 0xc7, 0xe2, 0x72, + 0xe7, 0xc3, 0xed, 0xff, 0x60, 0x31, 0xb0, 0x2}; + uint8_t bytesprops8[] = {0xb1, 0x8b, 0x72, 0x10, 0x8d, 0xd, 0xd8, 0xa3, 0x6c, 0xc4}; + uint8_t bytesprops9[] = {0x68, 0xb8, 0xc7, 0x3e, 0x53, 0x55, 0x59, 0xa3, 0xa3, 0xf4, 0xc9, 0x98, 0xc, 0x39, + 0x1e, 0x97, 0x6e, 0xfa, 0x4f, 0xda, 0xb6, 0x20, 0xd8, 0xc5, 0x63, 0xe2, 0x4e, 0x74}; + uint8_t bytesprops10[] = {0xf, 0xed, 0x82, 0x25, 0x5, 0x54, 0x6f, 0x8d, 0x21, 0x5e, 0x1c, 0xab, + 0x2b, 0x35, 0x26, 0x65, 0xcb, 0x6c, 0x18, 0x89, 0x2d, 0x2c, 0x2c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops2}, .v = {19, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17129}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27506}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15713}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21146}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2479}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14556}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8323}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32675}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\165\&4\a\246}\148\174\&8\186i\137\223\STX*Sv", _pubPktID = 0, _pubBody = "\243\233\SOH\134\243=c\212", _pubProps = +// [PropResponseInformation "\FSD'\182\202\140M\222[\r\156",PropCorrelationData +// "\CAN\164\185\bs\183\FS\163\b\\\ETB\255\156\164\193\SO\181\ESC\179\138\207rk\233\178Pb",PropUserProperty +// "\200\250\152\250\\\211\&2" "D\157HMnegk\131Q1F\EOTg\130\254\219\164\229",PropServerReference +// "9\133\188\151E\b\US\DEL8<8\154+\151>\209Q\DC4\185M\221\SYN\245\135M\239\238",PropResponseTopic +// "",PropResponseInformation "\142(\152<<\221\SI\GS\199",PropMaximumPacketSize 17129,PropResponseInformation +// "C\166'\167\137\221\199\226r\231\195\237\255`1\176\STX",PropSubscriptionIdentifierAvailable 198,PropServerReference +// "\177\139r\DLE\141\r\216\163l\196",PropMaximumPacketSize 27506,PropMessageExpiryInterval 15713,PropCorrelationData +// "h\184\199>SUY\163\163\244\201\152\f9\RS\151n\250O\218\182 \216\197c\226Nt",PropRequestResponseInformation +// 142,PropMessageExpiryInterval 21146,PropMessageExpiryInterval 2479,PropReceiveMaximum 14556,PropAuthenticationMethod +// "\SI\237\130%\ENQTo\141!^\FS\171+5&e\203l\CAN\137-,,",PropSessionExpiryInterval 8323,PropRequestResponseInformation +// 141,PropWillDelayInterval 32675]} +TEST(Publish5QCTest, Decode14) { + uint8_t pkt[] = { + 0x30, 0x9a, 0x2, 0x0, 0x10, 0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, 0xba, 0x69, 0x89, 0xdf, 0x2, 0x2a, + 0x53, 0x76, 0xfe, 0x1, 0x1a, 0x0, 0xb, 0x1c, 0x44, 0x27, 0xb6, 0xca, 0x8c, 0x4d, 0xde, 0x5b, 0xd, 0x9c, 0x9, + 0x0, 0x1b, 0x18, 0xa4, 0xb9, 0x8, 0x73, 0xb7, 0x1c, 0xa3, 0x8, 0x5c, 0x17, 0xff, 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38, 0xdc, 0x15, 0x0, 0x17, 0xf, 0xed, 0x82, 0x25, 0x5, + 0x54, 0x6f, 0x8d, 0x21, 0x5e, 0x1c, 0xab, 0x2b, 0x35, 0x26, 0x65, 0xcb, 0x6c, 0x18, 0x89, 0x2d, 0x2c, 0x2c, 0x11, + 0x0, 0x0, 0x20, 0x83, 0x19, 0x8d, 0x18, 0x0, 0x0, 0x7f, 0xa3, 0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, + 0xba, 0x69, 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76}; + lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(msg.payload_len, 8); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 10766, _pubBody = +// "\178", _pubProps = []} +TEST(Publish5QCTest, Encode15) { + uint8_t pkt[] = {0x3b, 0x6, 0x0, 0x0, 0x2a, 0xe, 0x0, 0xb2}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xb2}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10766, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 10766, _pubBody = +// "\178", _pubProps = []} +TEST(Publish5QCTest, Decode15) { + uint8_t pkt[] = {0x3b, 0x6, 0x0, 0x0, 0x2a, 0xe, 0x0, 0xb2}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb2}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10766); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\138\GSJ\143\233", _pubPktID = 6943, +// _pubBody = "\137\139\192l\219\138Z\225\185\164}d\US[\179", _pubProps = [PropAuthenticationMethod +// "\140+fdg\201T\248\&2\167\255\&3\EMm\193\&0\EOT\187\147\215\EM",PropServerKeepAlive 19473,PropServerKeepAlive +// 30363,PropAssignedClientIdentifier "\193~?\213\&2M\211\160\235\255I\163VA\190\223\145\138",PropWillDelayInterval +// 5830,PropReasonString "\188\&0W\192\156\144\147\STX\203\254`\143qK/\247",PropSessionExpiryInterval +// 5743,PropResponseTopic "\213#*",PropUserProperty +// "\183\152L\208\228\254v\a\181I\137ew\161<`\136\228\US\185TV\147A\251\254" "\149x\ESC\239\142\128\v\209\EOT6 +// HP\205\139a\nD\165"]} +TEST(Publish5QCTest, Encode16) { + uint8_t pkt[] = {0x3c, 0xa2, 0x1, 0x0, 0x5, 0x8a, 0x1d, 0x4a, 0x8f, 0xe9, 0x1b, 0x1f, 0x88, 0x1, 0x15, 0x0, 0x15, + 0x8c, 0x2b, 0x66, 0x64, 0x67, 0xc9, 0x54, 0xf8, 0x32, 0xa7, 0xff, 0x33, 0x19, 0x6d, 0xc1, 0x30, 0x4, + 0xbb, 0x93, 0xd7, 0x19, 0x13, 0x4c, 0x11, 0x13, 0x76, 0x9b, 0x12, 0x0, 0x12, 0xc1, 0x7e, 0x3f, 0xd5, + 0x32, 0x4d, 0xd3, 0xa0, 0xeb, 0xff, 0x49, 0xa3, 0x56, 0x41, 0xbe, 0xdf, 0x91, 0x8a, 0x18, 0x0, 0x0, + 0x16, 0xc6, 0x1f, 0x0, 0x10, 0xbc, 0x30, 0x57, 0xc0, 0x9c, 0x90, 0x93, 0x2, 0xcb, 0xfe, 0x60, 0x8f, + 0x71, 0x4b, 0x2f, 0xf7, 0x11, 0x0, 0x0, 0x16, 0x6f, 0x8, 0x0, 0x3, 0xd5, 0x23, 0x2a, 0x26, 0x0, + 0x1a, 0xb7, 0x98, 0x4c, 0xd0, 0xe4, 0xfe, 0x76, 0x7, 0xb5, 0x49, 0x89, 0x65, 0x77, 0xa1, 0x3c, 0x60, + 0x88, 0xe4, 0x1f, 0xb9, 0x54, 0x56, 0x93, 0x41, 0xfb, 0xfe, 0x0, 0x13, 0x95, 0x78, 0x1b, 0xef, 0x8e, + 0x80, 0xb, 0xd1, 0x4, 0x36, 0x20, 0x48, 0x50, 0xcd, 0x8b, 0x61, 0xa, 0x44, 0xa5, 0x89, 0x8b, 0xc0, + 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; + uint8_t topic_bytes[] = {0x8a, 0x1d, 0x4a, 0x8f, 0xe9}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x89, 0x8b, 0xc0, 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 15; + + uint8_t bytesprops0[] = {0x8c, 0x2b, 0x66, 0x64, 0x67, 0xc9, 0x54, 0xf8, 0x32, 0xa7, 0xff, + 0x33, 0x19, 0x6d, 0xc1, 0x30, 0x4, 0xbb, 0x93, 0xd7, 0x19}; + uint8_t bytesprops1[] = {0xc1, 0x7e, 0x3f, 0xd5, 0x32, 0x4d, 0xd3, 0xa0, 0xeb, + 0xff, 0x49, 0xa3, 0x56, 0x41, 0xbe, 0xdf, 0x91, 0x8a}; + uint8_t bytesprops2[] = {0xbc, 0x30, 0x57, 0xc0, 0x9c, 0x90, 0x93, 0x2, + 0xcb, 0xfe, 0x60, 0x8f, 0x71, 0x4b, 0x2f, 0xf7}; + uint8_t bytesprops3[] = {0xd5, 0x23, 0x2a}; + uint8_t bytesprops5[] = {0x95, 0x78, 0x1b, 0xef, 0x8e, 0x80, 0xb, 0xd1, 0x4, 0x36, + 0x20, 0x48, 0x50, 0xcd, 0x8b, 0x61, 0xa, 0x44, 0xa5}; + uint8_t bytesprops4[] = {0xb7, 0x98, 0x4c, 0xd0, 0xe4, 0xfe, 0x76, 0x7, 0xb5, 0x49, 0x89, 0x65, 0x77, + 0xa1, 0x3c, 0x60, 0x88, 0xe4, 0x1f, 0xb9, 0x54, 0x56, 0x93, 0x41, 0xfb, 0xfe}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19473}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30363}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5830}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5743}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops4}, .v = {19, (char*)&bytesprops5}}}}, + }; + + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6943, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\138\GSJ\143\233", _pubPktID = 6943, +// _pubBody = "\137\139\192l\219\138Z\225\185\164}d\US[\179", _pubProps = [PropAuthenticationMethod +// "\140+fdg\201T\248\&2\167\255\&3\EMm\193\&0\EOT\187\147\215\EM",PropServerKeepAlive 19473,PropServerKeepAlive +// 30363,PropAssignedClientIdentifier "\193~?\213\&2M\211\160\235\255I\163VA\190\223\145\138",PropWillDelayInterval +// 5830,PropReasonString "\188\&0W\192\156\144\147\STX\203\254`\143qK/\247",PropSessionExpiryInterval +// 5743,PropResponseTopic "\213#*",PropUserProperty +// "\183\152L\208\228\254v\a\181I\137ew\161<`\136\228\US\185TV\147A\251\254" "\149x\ESC\239\142\128\v\209\EOT6 +// HP\205\139a\nD\165"]} +TEST(Publish5QCTest, Decode16) { + uint8_t pkt[] = {0x3c, 0xa2, 0x1, 0x0, 0x5, 0x8a, 0x1d, 0x4a, 0x8f, 0xe9, 0x1b, 0x1f, 0x88, 0x1, 0x15, 0x0, 0x15, + 0x8c, 0x2b, 0x66, 0x64, 0x67, 0xc9, 0x54, 0xf8, 0x32, 0xa7, 0xff, 0x33, 0x19, 0x6d, 0xc1, 0x30, 0x4, + 0xbb, 0x93, 0xd7, 0x19, 0x13, 0x4c, 0x11, 0x13, 0x76, 0x9b, 0x12, 0x0, 0x12, 0xc1, 0x7e, 0x3f, 0xd5, + 0x32, 0x4d, 0xd3, 0xa0, 0xeb, 0xff, 0x49, 0xa3, 0x56, 0x41, 0xbe, 0xdf, 0x91, 0x8a, 0x18, 0x0, 0x0, + 0x16, 0xc6, 0x1f, 0x0, 0x10, 0xbc, 0x30, 0x57, 0xc0, 0x9c, 0x90, 0x93, 0x2, 0xcb, 0xfe, 0x60, 0x8f, + 0x71, 0x4b, 0x2f, 0xf7, 0x11, 0x0, 0x0, 0x16, 0x6f, 0x8, 0x0, 0x3, 0xd5, 0x23, 0x2a, 0x26, 0x0, + 0x1a, 0xb7, 0x98, 0x4c, 0xd0, 0xe4, 0xfe, 0x76, 0x7, 0xb5, 0x49, 0x89, 0x65, 0x77, 0xa1, 0x3c, 0x60, + 0x88, 0xe4, 0x1f, 0xb9, 0x54, 0x56, 0x93, 0x41, 0xfb, 0xfe, 0x0, 0x13, 0x95, 0x78, 0x1b, 0xef, 0x8e, + 0x80, 0xb, 0xd1, 0x4, 0x36, 0x20, 0x48, 0x50, 0xcd, 0x8b, 0x61, 0xa, 0x44, 0xa5, 0x89, 0x8b, 0xc0, + 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x8a, 0x1d, 0x4a, 0x8f, 0xe9}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x89, 0x8b, 0xc0, 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 6943); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\225y\a\222\215\130\238h\b\159\152x\153\151\162\213\177\165X\184]\135\187\189 \214", _pubProps = +// [PropRequestResponseInformation 185,PropTopicAliasMaximum 14150,PropReasonString "\165,",PropAssignedClientIdentifier +// "\201\152\208!o\194:\DEL\185IC\SYN~\152NV\179\183\212\220a",PropTopicAliasMaximum 9681,PropServerReference +// "\138\&4@Q\n\225\185\166\153\164J\155H*\EOT\249\231\253\232\218\201\188",PropAuthenticationData +// "\184\EM\201\135<\189a}\146\DC2\135\245\f\US>\243C\253\197\134",PropPayloadFormatIndicator 248,PropServerKeepAlive +// 277,PropWillDelayInterval 13390,PropResponseTopic "V\b\193\\\236|\RS",PropResponseInformation +// "\177\216\175kf\FS\198\234\DEL\205:\STX\175\216Fq\242\DC20\152\253\142/",PropCorrelationData +// "\149\DC4\243\181\182:\ENQ\185\"d",PropMessageExpiryInterval 1713,PropAuthenticationData +// "\233\251",PropWildcardSubscriptionAvailable 169,PropTopicAliasMaximum 22382,PropReceiveMaximum +// 22362,PropServerKeepAlive 8489,PropMessageExpiryInterval 30880,PropRetainAvailable +// 14,PropWildcardSubscriptionAvailable 30,PropCorrelationData +// "@[i5\197\167\243C\253\197\134",PropPayloadFormatIndicator 248,PropServerKeepAlive +// 277,PropWillDelayInterval 13390,PropResponseTopic "V\b\193\\\236|\RS",PropResponseInformation +// "\177\216\175kf\FS\198\234\DEL\205:\STX\175\216Fq\242\DC20\152\253\142/",PropCorrelationData +// "\149\DC4\243\181\182:\ENQ\185\"d",PropMessageExpiryInterval 1713,PropAuthenticationData +// "\233\251",PropWildcardSubscriptionAvailable 169,PropTopicAliasMaximum 22382,PropReceiveMaximum +// 22362,PropServerKeepAlive 8489,PropMessageExpiryInterval 30880,PropRetainAvailable +// 14,PropWildcardSubscriptionAvailable 30,PropCorrelationData +// "@[i5\197\167(topic.data), 0); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "6\218tea\v\174S\163\234\130\GS\208\155\GS\DLE\ENQ\ESC\178\165 \153\DC2\155v,\165", _pubPktID = 27993, _pubBody = +// "\158 %1\177\201\t\236L", _pubProps = [PropServerKeepAlive 9153,PropMessageExpiryInterval 3494,PropContentType +// "P\141'\196\209\238\243\237\249?\SO\219x\162*\204",PropSharedSubscriptionAvailable 179,PropResponseInformation +// "\190\"(F\247\\\220y\190\242M\GS\223W\201\167\211p\222\DEL\170\237\f\219Z\163",PropRequestResponseInformation +// 202,PropMessageExpiryInterval 23742,PropResponseTopic +// "\255+^\145\153\SO\225\250!=#\217",PropRequestProblemInformation 8,PropSharedSubscriptionAvailable 68,PropTopicAlias +// 31091,PropContentType "\159\216\205\237\234\CAN\175_\190\248\189R\141\145\242]\174",PropServerKeepAlive +// 24225,PropContentType "\146b\132\218\243M\STX}\185>",PropAuthenticationMethod +// "\209^\237\138\b\196\153\128\168\175\184\198)\155\144\169[n\140\v\175\225",PropSubscriptionIdentifierAvailable +// 224,PropTopicAliasMaximum 20441,PropTopicAliasMaximum 31289]} +TEST(Publish5QCTest, Encode18) { + uint8_t pkt[] = {0x32, 0xc6, 0x1, 0x0, 0x1b, 0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, + 0xd0, 0x9b, 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5, 0x6d, 0x59, + 0x9c, 0x1, 0x13, 0x23, 0xc1, 0x2, 0x0, 0x0, 0xd, 0xa6, 0x3, 0x0, 0x10, 0x50, 0x8d, 0x27, 0xc4, + 0xd1, 0xee, 0xf3, 0xed, 0xf9, 0x3f, 0xe, 0xdb, 0x78, 0xa2, 0x2a, 0xcc, 0x2a, 0xb3, 0x1a, 0x0, 0x1a, + 0xbe, 0x22, 0x28, 0x46, 0xf7, 0x5c, 0xdc, 0x79, 0xbe, 0xf2, 0x4d, 0x1d, 0xdf, 0x57, 0xc9, 0xa7, 0xd3, + 0x70, 0xde, 0x7f, 0xaa, 0xed, 0xc, 0xdb, 0x5a, 0xa3, 0x19, 0xca, 0x2, 0x0, 0x0, 0x5c, 0xbe, 0x8, + 0x0, 0xc, 0xff, 0x2b, 0x5e, 0x91, 0x99, 0xe, 0xe1, 0xfa, 0x21, 0x3d, 0x23, 0xd9, 0x17, 0x8, 0x2a, + 0x44, 0x23, 0x79, 0x73, 0x3, 0x0, 0x11, 0x9f, 0xd8, 0xcd, 0xed, 0xea, 0x18, 0xaf, 0x5f, 0xbe, 0xf8, + 0xbd, 0x52, 0x8d, 0x91, 0xf2, 0x5d, 0xae, 0x13, 0x5e, 0xa1, 0x3, 0x0, 0xa, 0x92, 0x62, 0x84, 0xda, + 0xf3, 0x4d, 0x2, 0x7d, 0xb9, 0x3e, 0x15, 0x0, 0x16, 0xd1, 0x5e, 0xed, 0x8a, 0x8, 0xc4, 0x99, 0x80, + 0xa8, 0xaf, 0xb8, 0xc6, 0x29, 0x9b, 0x90, 0xa9, 0x5b, 0x6e, 0x8c, 0xb, 0xaf, 0xe1, 0x29, 0xe0, 0x22, + 0x4f, 0xd9, 0x22, 0x7a, 0x39, 0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; + uint8_t topic_bytes[] = {0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, 0xd0, 0x9b, + 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 9; + + uint8_t bytesprops0[] = {0x50, 0x8d, 0x27, 0xc4, 0xd1, 0xee, 0xf3, 0xed, + 0xf9, 0x3f, 0xe, 0xdb, 0x78, 0xa2, 0x2a, 0xcc}; + uint8_t bytesprops1[] = {0xbe, 0x22, 0x28, 0x46, 0xf7, 0x5c, 0xdc, 0x79, 0xbe, 0xf2, 0x4d, 0x1d, 0xdf, + 0x57, 0xc9, 0xa7, 0xd3, 0x70, 0xde, 0x7f, 0xaa, 0xed, 0xc, 0xdb, 0x5a, 0xa3}; + uint8_t bytesprops2[] = {0xff, 0x2b, 0x5e, 0x91, 0x99, 0xe, 0xe1, 0xfa, 0x21, 0x3d, 0x23, 0xd9}; + uint8_t bytesprops3[] = {0x9f, 0xd8, 0xcd, 0xed, 0xea, 0x18, 0xaf, 0x5f, 0xbe, + 0xf8, 0xbd, 0x52, 0x8d, 0x91, 0xf2, 0x5d, 0xae}; + uint8_t bytesprops4[] = {0x92, 0x62, 0x84, 0xda, 0xf3, 0x4d, 0x2, 0x7d, 0xb9, 0x3e}; + uint8_t bytesprops5[] = {0xd1, 0x5e, 0xed, 0x8a, 0x8, 0xc4, 0x99, 0x80, 0xa8, 0xaf, 0xb8, + 0xc6, 0x29, 0x9b, 0x90, 0xa9, 0x5b, 0x6e, 0x8c, 0xb, 0xaf, 0xe1}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9153}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3494}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23742}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31091}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24225}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20441}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31289}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 27993, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "6\218tea\v\174S\163\234\130\GS\208\155\GS\DLE\ENQ\ESC\178\165 \153\DC2\155v,\165", _pubPktID = 27993, _pubBody = +// "\158 %1\177\201\t\236L", _pubProps = [PropServerKeepAlive 9153,PropMessageExpiryInterval 3494,PropContentType +// "P\141'\196\209\238\243\237\249?\SO\219x\162*\204",PropSharedSubscriptionAvailable 179,PropResponseInformation +// "\190\"(F\247\\\220y\190\242M\GS\223W\201\167\211p\222\DEL\170\237\f\219Z\163",PropRequestResponseInformation +// 202,PropMessageExpiryInterval 23742,PropResponseTopic +// "\255+^\145\153\SO\225\250!=#\217",PropRequestProblemInformation 8,PropSharedSubscriptionAvailable 68,PropTopicAlias +// 31091,PropContentType "\159\216\205\237\234\CAN\175_\190\248\189R\141\145\242]\174",PropServerKeepAlive +// 24225,PropContentType "\146b\132\218\243M\STX}\185>",PropAuthenticationMethod +// "\209^\237\138\b\196\153\128\168\175\184\198)\155\144\169[n\140\v\175\225",PropSubscriptionIdentifierAvailable +// 224,PropTopicAliasMaximum 20441,PropTopicAliasMaximum 31289]} +TEST(Publish5QCTest, Decode18) { + u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 0xe1, 0x29, 0xe0, 0x22, + 0x4f, 0xd9, 0x22, 0x7a, 0x39, 0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, 0xd0, 0x9b, + 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 27993); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "IP~U\245v\179O\ETB\247\SUB\152i\169\208", _pubPktID = 1633, _pubBody = +// "\164\215\&1Ym\133Ie\197\EOT\147\DC3}g\SUB\150\143", _pubProps = [PropServerKeepAlive 425,PropAuthenticationMethod +// "#\147\225\221\EM\204,4\195\215\182\DC2\209h8\242=\131m\241]\223\&2B*\154A",PropReceiveMaximum +// 21231,PropCorrelationData "\185GM-\220p",PropTopicAliasMaximum 24215,PropMaximumPacketSize +// 32734,PropRequestResponseInformation 122,PropSubscriptionIdentifierAvailable 16,PropRequestResponseInformation +// 139,PropMessageExpiryInterval 14314]} +TEST(Publish5QCTest, Encode19) { + uint8_t pkt[] = {0x3d, 0x65, 0x0, 0xf, 0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, 0xf7, 0x1a, + 0x98, 0x69, 0xa9, 0xd0, 0x6, 0x61, 0x40, 0x13, 0x1, 0xa9, 0x15, 0x0, 0x1b, 0x23, 0x93, + 0xe1, 0xdd, 0x19, 0xcc, 0x2c, 0x34, 0xc3, 0xd7, 0xb6, 0x12, 0xd1, 0x68, 0x38, 0xf2, 0x3d, + 0x83, 0x6d, 0xf1, 0x5d, 0xdf, 0x32, 0x42, 0x2a, 0x9a, 0x41, 0x21, 0x52, 0xef, 0x9, 0x0, + 0x6, 0xb9, 0x47, 0x4d, 0x2d, 0xdc, 0x70, 0x22, 0x5e, 0x97, 0x27, 0x0, 0x0, 0x7f, 0xde, + 0x19, 0x7a, 0x29, 0x10, 0x19, 0x8b, 0x2, 0x0, 0x0, 0x37, 0xea, 0xa4, 0xd7, 0x31, 0x59, + 0x6d, 0x85, 0x49, 0x65, 0xc5, 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; + uint8_t topic_bytes[] = {0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa4, 0xd7, 0x31, 0x59, 0x6d, 0x85, 0x49, 0x65, 0xc5, + 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 17; + + uint8_t bytesprops0[] = {0x23, 0x93, 0xe1, 0xdd, 0x19, 0xcc, 0x2c, 0x34, 0xc3, 0xd7, 0xb6, 0x12, 0xd1, 0x68, + 0x38, 0xf2, 0x3d, 0x83, 0x6d, 0xf1, 0x5d, 0xdf, 0x32, 0x42, 0x2a, 0x9a, 0x41}; + uint8_t bytesprops1[] = {0xb9, 0x47, 0x4d, 0x2d, 0xdc, 0x70}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 425}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21231}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24215}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32734}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14314}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1633, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "IP~U\245v\179O\ETB\247\SUB\152i\169\208", _pubPktID = 1633, _pubBody = +// "\164\215\&1Ym\133Ie\197\EOT\147\DC3}g\SUB\150\143", _pubProps = [PropServerKeepAlive 425,PropAuthenticationMethod +// "#\147\225\221\EM\204,4\195\215\182\DC2\209h8\242=\131m\241]\223\&2B*\154A",PropReceiveMaximum +// 21231,PropCorrelationData "\185GM-\220p",PropTopicAliasMaximum 24215,PropMaximumPacketSize +// 32734,PropRequestResponseInformation 122,PropSubscriptionIdentifierAvailable 16,PropRequestResponseInformation +// 139,PropMessageExpiryInterval 14314]} +TEST(Publish5QCTest, Decode19) { + uint8_t pkt[] = {0x3d, 0x65, 0x0, 0xf, 0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, 0xf7, 0x1a, + 0x98, 0x69, 0xa9, 0xd0, 0x6, 0x61, 0x40, 0x13, 0x1, 0xa9, 0x15, 0x0, 0x1b, 0x23, 0x93, + 0xe1, 0xdd, 0x19, 0xcc, 0x2c, 0x34, 0xc3, 0xd7, 0xb6, 0x12, 0xd1, 0x68, 0x38, 0xf2, 0x3d, + 0x83, 0x6d, 0xf1, 0x5d, 0xdf, 0x32, 0x42, 0x2a, 0x9a, 0x41, 0x21, 0x52, 0xef, 0x9, 0x0, + 0x6, 0xb9, 0x47, 0x4d, 0x2d, 0xdc, 0x70, 0x22, 0x5e, 0x97, 0x27, 0x0, 0x0, 0x7f, 0xde, + 0x19, 0x7a, 0x29, 0x10, 0x19, 0x8b, 0x2, 0x0, 0x0, 0x37, 0xea, 0xa4, 0xd7, 0x31, 0x59, + 0x6d, 0x85, 0x49, 0x65, 0xc5, 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, + 0x17, 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa4, 0xd7, 0x31, 0x59, 0x6d, 0x85, 0x49, 0x65, 0xc5, + 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 1633); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\bm\162F\236O\211D\179\164@\195\244", _pubPktID = 19046, _pubBody = ".\167H\139", _pubProps = +// [PropAuthenticationMethod +// "\219\229\205\149\172\227\202\174\223\175\168\209\167y\200l\NAK\169\NUL!\234",PropTopicAlias 27954,PropContentType +// "\CAN\175Kb_\199\210\223\181~\239",PropAuthenticationMethod +// "\129=\FS\190\220\195\244\195\RS\235\203\248\239\154a\138\225\EOT\DC3",PropAssignedClientIdentifier +// "\194\237T\196\147\185\239\166",PropAuthenticationMethod +// "-U\247\206s\fm\SI\169\229\240\146I\ACK\132\237",PropServerKeepAlive 5221,PropRetainAvailable +// 36,PropMessageExpiryInterval 3914,PropResponseTopic +// ",\233\163\165e\195X\ACK\DC1\te\152^T\193\220\176",PropAuthenticationMethod +// "s\232\207Z\196\202*g\SYN\199\219\ay\224\191?gO(X\150\t\FS",PropSubscriptionIdentifier 2,PropTopicAlias +// 17849,PropContentType "\170\216\214\235\220e\250\177\142 +// \157\233\r4a\153\233\152)\236",PropWildcardSubscriptionAvailable 181,PropAuthenticationData +// "\139\254\154=\192#C\209\EOTU1U\162J[zj\238\168\203\DC2!",PropWillDelayInterval 20612,PropServerKeepAlive +// 16088,PropSubscriptionIdentifierAvailable 56]} +TEST(Publish5QCT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xeb, 0xdc, 0x65, 0xfa, 0xb1, 0x8e, 0x20, 0x9d, + 0xe9, 0xd, 0x34, 0x61, 0x99, 0xe9, 0x98, 0x29, 0xec, 0x28, 0xb5, 0x16, 0x0, 0x16, 0x8b, 0xfe, 0x9a, 0x3d, 0xc0, + 0x23, 0x43, 0xd1, 0x4, 0x55, 0x31, 0x55, 0xa2, 0x4a, 0x5b, 0x7a, 0x6a, 0xee, 0xa8, 0xcb, 0x12, 0x21, 0x18, 0x0, + 0x0, 0x50, 0x84, 0x13, 0x3e, 0xd8, 0x29, 0x38, 0x2e, 0xa7, 0x48, 0x8b}; + uint8_t topic_bytes[] = {0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, 0xb3, 0xa4, 0x40, 0xc3, 0xf4}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x2e, 0xa7, 0x48, 0x8b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; + + uint8_t bytesprops0[] = {0xdb, 0xe5, 0xcd, 0x95, 0xac, 0xe3, 0xca, 0xae, 0xdf, 0xaf, 0xa8, + 0xd1, 0xa7, 0x79, 0xc8, 0x6c, 0x15, 0xa9, 0x0, 0x21, 0xea}; + uint8_t bytesprops1[] = {0x18, 0xaf, 0x4b, 0x62, 0x5f, 0xc7, 0xd2, 0xdf, 0xb5, 0x7e, 0xef}; + uint8_t bytesprops2[] = {0x81, 0x3d, 0x1c, 0xbe, 0xdc, 0xc3, 0xf4, 0xc3, 0x1e, 0xeb, + 0xcb, 0xf8, 0xef, 0x9a, 0x61, 0x8a, 0xe1, 0x4, 0x13}; + uint8_t bytesprops3[] = {0xc2, 0xed, 0x54, 0xc4, 0x93, 0xb9, 0xef, 0xa6}; + uint8_t bytesprops4[] = {0x2d, 0x55, 0xf7, 0xce, 0x73, 0xc, 0x6d, 0xf, 0xa9, 0xe5, 0xf0, 0x92, 0x49, 0x6, 0x84, 0xed}; + uint8_t bytesprops5[] = {0x2c, 0xe9, 0xa3, 0xa5, 0x65, 0xc3, 0x58, 0x6, 0x11, + 0x9, 0x65, 0x98, 0x5e, 0x54, 0xc1, 0xdc, 0xb0}; + uint8_t bytesprops6[] = {0x73, 0xe8, 0xcf, 0x5a, 0xc4, 0xca, 0x2a, 0x67, 0x16, 0xc7, 0xdb, 0x7, + 0x79, 0xe0, 0xbf, 0x3f, 0x67, 0x4f, 0x28, 0x58, 0x96, 0x9, 0x1c}; + uint8_t bytesprops7[] = {0xaa, 0xd8, 0xd6, 0xeb, 0xdc, 0x65, 0xfa, 0xb1, 0x8e, 0x20, + 0x9d, 0xe9, 0xd, 0x34, 0x61, 0x99, 0xe9, 0x98, 0x29, 0xec}; + uint8_t bytesprops8[] = {0x8b, 0xfe, 0x9a, 0x3d, 0xc0, 0x23, 0x43, 0xd1, 0x4, 0x55, 0x31, + 0x55, 0xa2, 0x4a, 0x5b, 0x7a, 0x6a, 0xee, 0xa8, 0xcb, 0x12, 0x21}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27954}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5221}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3914}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17849}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20612}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16088}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, + }; + + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19046, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\bm\162F\236O\211D\179\164@\195\244", _pubPktID = 19046, _pubBody = ".\167H\139", _pubProps = +// [PropAuthenticationMethod +// "\219\229\205\149\172\227\202\174\223\175\168\209\167y\200l\NAK\169\NUL!\234",PropTopicAlias 27954,PropContentType +// "\CAN\175Kb_\199\210\223\181~\239",PropAuthenticationMethod +// "\129=\FS\190\220\195\244\195\RS\235\203\248\239\154a\138\225\EOT\DC3",PropAssignedClientIdentifier +// "\194\237T\196\147\185\239\166",PropAuthenticationMethod +// "-U\247\206s\fm\SI\169\229\240\146I\ACK\132\237",PropServerKeepAlive 5221,PropRetainAvailable +// 36,PropMessageExpiryInterval 3914,PropResponseTopic +// ",\233\163\165e\195X\ACK\DC1\te\152^T\193\220\176",PropAuthenticationMethod +// "s\232\207Z\196\202*g\SYN\199\219\ay\224\191?gO(X\150\t\FS",PropSubscriptionIdentifier 2,PropTopicAlias +// 17849,PropContentType "\170\216\214\235\220e\250\177\142 +// \157\233\r4a\153\233\152)\236",PropWildcardSubscriptionAvailable 181,PropAuthenticationData +// "\139\254\154=\192#C\209\EOTU1U\162J[zj\238\168\203\DC2!",PropWillDelayInterval 20612,PropServerKeepAlive +// 16088,PropSubscriptionIdentifierAvailable 56]} +TEST(Publish5QCTest, Decode20) { + uint8_t pkt[] = { + 0x35, 0xed, 0x1, 0x0, 0xd, 0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, 0xb3, 0xa4, 0x40, 0xc3, 0xf4, 0x4a, + 0x66, 0xd6, 0x1, 0x15, 0x0, 0x15, 0xdb, 0xe5, 0xcd, 0x95, 0xac, 0xe3, 0xca, 0xae, 0xdf, 0xaf, 0xa8, 0xd1, 0xa7, + 0x79, 0xc8, 0x6c, 0x15, 0xa9, 0x0, 0x21, 0xea, 0x23, 0x6d, 0x32, 0x3, 0x0, 0xb, 0x18, 0xaf, 0x4b, 0x62, 0x5f, + 0xc7, 0xd2, 0xdf, 0xb5, 0x7e, 0xef, 0x15, 0x0, 0x13, 0x81, 0x3d, 0x1c, 0xbe, 0xdc, 0xc3, 0xf4, 0xc3, 0x1e, 0xeb, + 0xcb, 0xf8, 0xef, 0x9a, 0x61, 0x8a, 0xe1, 0x4, 0x13, 0x12, 0x0, 0x8, 0xc2, 0xed, 0x54, 0xc4, 0x93, 0xb9, 0xef, + 0xa6, 0x15, 0x0, 0x10, 0x2d, 0x55, 0xf7, 0xce, 0x73, 0xc, 0x6d, 0xf, 0xa9, 0xe5, 0xf0, 0x92, 0x49, 0x6, 0x84, + 0xed, 0x13, 0x14, 0x65, 0x25, 0x24, 0x2, 0x0, 0x0, 0xf, 0x4a, 0x8, 0x0, 0x11, 0x2c, 0xe9, 0xa3, 0xa5, 0x65, + 0xc3, 0x58, 0x6, 0x11, 0x9, 0x65, 0x98, 0x5e, 0x54, 0xc1, 0xdc, 0xb0, 0x15, 0x0, 0x17, 0x73, 0xe8, 0xcf, 0x5a, + 0xc4, 0xca, 0x2a, 0x67, 0x16, 0xc7, 0xdb, 0x7, 0x79, 0xe0, 0xbf, 0x3f, 0x67, 0x4f, 0x28, 0x58, 0x96, 0x9, 0x1c, + 0xb, 0x2, 0x23, 0x45, 0xb9, 0x3, 0x0, 0x14, 0xaa, 0xd8, 0xd6, 0xeb, 0xdc, 0x65, 0xfa, 0xb1, 0x8e, 0x20, 0x9d, + 0xe9, 0xd, 0x34, 0x61, 0x99, 0xe9, 0x98, 0x29, 0xec, 0x28, 0xb5, 0x16, 0x0, 0x16, 0x8b, 0xfe, 0x9a, 0x3d, 0xc0, + 0x23, 0x43, 0xd1, 0x4, 0x55, 0x31, 0x55, 0xa2, 0x4a, 0x5b, 0x7a, 0x6a, 0xee, 0xa8, 0xcb, 0x12, 0x21, 0x18, 0x0, + 0x0, 0x50, 0x84, 0x13, 0x3e, 0xd8, 0x29, 0x38, 0x2e, 0xa7, 0x48, 0x8b}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, 0xb3, 0xa4, 0x40, 0xc3, 0xf4}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2e, 0xa7, 0x48, 0x8b}; + lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 19046); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 4); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "%\134\216", _pubPktID = 0, _pubBody +// = "\ETB\162T\161\139s\238\233\229.\233\243\186", _pubProps = [PropReceiveMaximum 13370,PropServerReference +// ";O\228n+\180\201\169\171\196\225 \EM\232\ETX\155#\SI(\t[Uu",PropPayloadFormatIndicator 134,PropUserProperty +// "\249\245\STXW\228J\157" +// "\231\255\213\ACK[2\204\&6\175\169\228\168\195\246\156\189)\255\&5\186\135\SO\210\246I\144C:\225\179",PropMaximumPacketSize +// 20364,PropUserProperty "\DC3{,\181\USP\229\211\FS\138\189-\240\220\205\128i\156`\ESC8" +// "ss\164\EOT\152",PropAuthenticationData "\221\220\186\194/\STX\246\189\ETX\SOH='\150\187$-",PropAuthenticationMethod +// "\187G\163\200\195[\211\203^\NUL\NAK\239\184\&6Q\176\v\255\t,\246\246\&1\172\216\207\t",PropReceiveMaximum +// 32386,PropRequestResponseInformation 185,PropServerReference +// "\248\181w\213\166\219\221\247\159\254\204\179\213|\243I\STXa\255\143w\SYN\208\223\218\185\ESC",PropMessageExpiryInterval +// 6843,PropRetainAvailable 210]} +TEST(Publish5QCTest, Encode21) { + uint8_t pkt[] = { + 0x38, 0xdc, 0x1, 0x0, 0x3, 0x25, 0x86, 0xd8, 0xc8, 0x1, 0x21, 0x34, 0x3a, 0x1c, 0x0, 0x17, 0x3b, 0x4f, 0xe4, + 0x6e, 0x2b, 0xb4, 0xc9, 0xa9, 0xab, 0xc4, 0xe1, 0x20, 0x19, 0xe8, 0x3, 0x9b, 0x23, 0xf, 0x28, 0x9, 0x5b, 0x55, + 0x75, 0x1, 0x86, 0x26, 0x0, 0x7, 0xf9, 0xf5, 0x2, 0x57, 0xe4, 0x4a, 0x9d, 0x0, 0x1e, 0xe7, 0xff, 0xd5, 0x6, + 0x5b, 0x32, 0xcc, 0x36, 0xaf, 0xa9, 0xe4, 0xa8, 0xc3, 0xf6, 0x9c, 0xbd, 0x29, 0xff, 0x35, 0xba, 0x87, 0xe, 0xd2, + 0xf6, 0x49, 0x90, 0x43, 0x3a, 0xe1, 0xb3, 0x27, 0x0, 0x0, 0x4f, 0x8c, 0x26, 0x0, 0x15, 0x13, 0x7b, 0x2c, 0xb5, + 0x1f, 0x50, 0xe5, 0xd3, 0x1c, 0x8a, 0xbd, 0x2d, 0xf0, 0xdc, 0xcd, 0x80, 0x69, 0x9c, 0x60, 0x1b, 0x38, 0x0, 0x5, + 0x73, 0x73, 0xa4, 0x4, 0x98, 0x16, 0x0, 0x10, 0xdd, 0xdc, 0xba, 0xc2, 0x2f, 0x2, 0xf6, 0xbd, 0x3, 0x1, 0x3d, + 0x27, 0x96, 0xbb, 0x24, 0x2d, 0x15, 0x0, 0x1b, 0xbb, 0x47, 0xa3, 0xc8, 0xc3, 0x5b, 0xd3, 0xcb, 0x5e, 0x0, 0x15, + 0xef, 0xb8, 0x36, 0x51, 0xb0, 0xb, 0xff, 0x9, 0x2c, 0xf6, 0xf6, 0x31, 0xac, 0xd8, 0xcf, 0x9, 0x21, 0x7e, 0x82, + 0x19, 0xb9, 0x1c, 0x0, 0x1b, 0xf8, 0xb5, 0x77, 0xd5, 0xa6, 0xdb, 0xdd, 0xf7, 0x9f, 0xfe, 0xcc, 0xb3, 0xd5, 0x7c, + 0xf3, 0x49, 0x2, 0x61, 0xff, 0x8f, 0x77, 0x16, 0xd0, 0xdf, 0xda, 0xb9, 0x1b, 0x2, 0x0, 0x0, 0x1a, 0xbb, 0x25, + 0xd2, 0x17, 0xa2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + uint8_t topic_bytes[] = {0x25, 0x86, 0xd8}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x17, 0xa2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; + + uint8_t bytesprops0[] = {0x3b, 0x4f, 0xe4, 0x6e, 0x2b, 0xb4, 0xc9, 0xa9, 0xab, 0xc4, 0xe1, 0x20, + 0x19, 0xe8, 0x3, 0x9b, 0x23, 0xf, 0x28, 0x9, 0x5b, 0x55, 0x75}; + uint8_t bytesprops2[] = {0xe7, 0xff, 0xd5, 0x6, 0x5b, 0x32, 0xcc, 0x36, 0xaf, 0xa9, 0xe4, 0xa8, 0xc3, 0xf6, 0x9c, + 0xbd, 0x29, 0xff, 0x35, 0xba, 0x87, 0xe, 0xd2, 0xf6, 0x49, 0x90, 0x43, 0x3a, 0xe1, 0xb3}; + uint8_t bytesprops1[] = {0xf9, 0xf5, 0x2, 0x57, 0xe4, 0x4a, 0x9d}; + uint8_t bytesprops4[] = {0x73, 0x73, 0xa4, 0x4, 0x98}; + uint8_t bytesprops3[] = {0x13, 0x7b, 0x2c, 0xb5, 0x1f, 0x50, 0xe5, 0xd3, 0x1c, 0x8a, 0xbd, + 0x2d, 0xf0, 0xdc, 0xcd, 0x80, 0x69, 0x9c, 0x60, 0x1b, 0x38}; + uint8_t bytesprops5[] = {0xdd, 0xdc, 0xba, 0xc2, 0x2f, 0x2, 0xf6, 0xbd, 0x3, 0x1, 0x3d, 0x27, 0x96, 0xbb, 0x24, 0x2d}; + uint8_t bytesprops6[] = {0xbb, 0x47, 0xa3, 0xc8, 0xc3, 0x5b, 0xd3, 0xcb, 0x5e, 0x0, 0x15, 0xef, 0xb8, 0x36, + 0x51, 0xb0, 0xb, 0xff, 0x9, 0x2c, 0xf6, 0xf6, 0x31, 0xac, 0xd8, 0xcf, 0x9}; + uint8_t bytesprops7[] = {0xf8, 0xb5, 0x77, 0xd5, 0xa6, 0xdb, 0xdd, 0xf7, 0x9f, 0xfe, 0xcc, 0xb3, 0xd5, 0x7c, + 0xf3, 0x49, 0x2, 0x61, 0xff, 0x8f, 0x77, 0x16, 0xd0, 0xdf, 0xda, 0xb9, 0x1b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13370}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20364}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32386}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6843}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "%\134\216", _pubPktID = 0, _pubBody +// = "\ETB\162T\161\139s\238\233\229.\233\243\186", _pubProps = [PropReceiveMaximum 13370,PropServerReference +// ";O\228n+\180\201\169\171\196\225 \EM\232\ETX\155#\SI(\t[Uu",PropPayloadFormatIndicator 134,PropUserProperty +// "\249\245\STXW\228J\157" +// "\231\255\213\ACK[2\204\&6\175\169\228\168\195\246\156\189)\255\&5\186\135\SO\210\246I\144C:\225\179",PropMaximumPacketSize +// 20364,PropUserProperty "\DC3{,\181\USP\229\211\FS\138\189-\240\220\205\128i\156`\ESC8" +// "ss\164\EOT\152",PropAuthenticationData "\221\220\186\194/\STX\246\189\ETX\SOH='\150\187$-",PropAuthenticationMethod +// "\187G\163\200\195[\211\203^\NUL\NAK\239\184\&6Q\176\v\255\t,\246\246\&1\172\216\207\t",PropReceiveMaximum +// 32386,PropRequestResponseInformation 185,PropServerReference +// "\248\181w\213\166\219\221\247\159\254\204\179\213|\243I\STXa\255\143w\SYN\208\223\218\185\ESC",PropMessageExpiryInterval +// 6843,PropRetainAvailable 210]} +TEST(Publish5QCTest, Decode21) { + uint8_t pkt[] = { + 0x38, 0xdc, 0x1, 0x0, 0x3, 0x25, 0x86, 0xd8, 0xc8, 0x1, 0x21, 0x34, 0x3a, 0x1c, 0x0, 0x17, 0x3b, 0x4f, 0xe4, + 0x6e, 0x2b, 0xb4, 0xc9, 0xa9, 0xab, 0xc4, 0xe1, 0x20, 0x19, 0xe8, 0x3, 0x9b, 0x23, 0xf, 0x28, 0x9, 0x5b, 0x55, + 0x75, 0x1, 0x86, 0x26, 0x0, 0x7, 0xf9, 0xf5, 0x2, 0x57, 0xe4, 0x4a, 0x9d, 0x0, 0x1e, 0xe7, 0xff, 0xd5, 0x6, + 0x5b, 0x32, 0xcc, 0x36, 0xaf, 0xa9, 0xe4, 0xa8, 0xc3, 0xf6, 0x9c, 0xbd, 0x29, 0xff, 0x35, 0xba, 0x87, 0xe, 0xd2, + 0xf6, 0x49, 0x90, 0x43, 0x3a, 0xe1, 0xb3, 0x27, 0x0, 0x0, 0x4f, 0x8c, 0x26, 0x0, 0x15, 0x13, 0x7b, 0x2c, 0xb5, + 0x1f, 0x50, 0xe5, 0xd3, 0x1c, 0x8a, 0xbd, 0x2d, 0xf0, 0xdc, 0xcd, 0x80, 0x69, 0x9c, 0x60, 0x1b, 0x38, 0x0, 0x5, + 0x73, 0x73, 0xa4, 0x4, 0x98, 0x16, 0x0, 0x10, 0xdd, 0xdc, 0xba, 0xc2, 0x2f, 0x2, 0xf6, 0xbd, 0x3, 0x1, 0x3d, + 0x27, 0x96, 0xbb, 0x24, 0x2d, 0x15, 0x0, 0x1b, 0xbb, 0x47, 0xa3, 0xc8, 0xc3, 0x5b, 0xd3, 0xcb, 0x5e, 0x0, 0x15, + 0xef, 0xb8, 0x36, 0x51, 0xb0, 0xb, 0xff, 0x9, 0x2c, 0xf6, 0xf6, 0x31, 0xac, 0xd8, 0xcf, 0x9, 0x21, 0x7e, 0x82, + 0x19, 0xb9, 0x1c, 0x0, 0x1b, 0xf8, 0xb5, 0x77, 0xd5, 0xa6, 0xdb, 0xdd, 0xf7, 0x9f, 0xfe, 0xcc, 0xb3, 0xd5, 0x7c, + 0xf3, 0x49, 0x2, 0x61, 0xff, 0x8f, 0x77, 0x16, 0xd0, 0xdf, 0xda, 0xb9, 0x1b, 0x2, 0x0, 0x0, 0x1a, 0xbb, 0x25, + 0xd2, 0x17, 0xa2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x25, 0x86, 0xd8}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x17, 0xa2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\230\237\153c\242P\179\141\223\&2\205Z{\223\153", _pubPktID = 22947, _pubBody = +// "\195\148\247\&4\177\f%\149>q\236W\ETB-\a\209y\n\133o\172*:\131aY", _pubProps = [PropServerReference +// "\198\&6(\SOHH}",PropTopicAliasMaximum 11940,PropRetainAvailable 229,PropResponseInformation +// "\128\171w\200\170x:n*T\DC47xe&T\214\243\196\145\224E\222\226\148[\148\&27",PropSubscriptionIdentifierAvailable +// 153,PropRetainAvailable 170]} +TEST(Publish5QCTest, Encode22) { + uint8_t pkt[] = {0x3a, 0x60, 0x0, 0xf, 0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, 0x7b, + 0xdf, 0x99, 0x59, 0xa3, 0x32, 0x1c, 0x0, 0x6, 0xc6, 0x36, 0x28, 0x1, 0x48, 0x7d, 0x22, 0x2e, 0xa4, + 0x25, 0xe5, 0x1a, 0x0, 0x1d, 0x80, 0xab, 0x77, 0xc8, 0xaa, 0x78, 0x3a, 0x6e, 0x2a, 0x54, 0x14, 0x37, + 0x78, 0x65, 0x26, 0x54, 0xd6, 0xf3, 0xc4, 0x91, 0xe0, 0x45, 0xde, 0xe2, 0x94, 0x5b, 0x94, 0x32, 0x37, + 0x29, 0x99, 0x25, 0xaa, 0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, + 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + uint8_t topic_bytes[] = {0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, 0x7b, 0xdf, 0x99}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, + 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + uint8_t bytesprops0[] = {0xc6, 0x36, 0x28, 0x1, 0x48, 0x7d}; + uint8_t bytesprops1[] = {0x80, 0xab, 0x77, 0xc8, 0xaa, 0x78, 0x3a, 0x6e, 0x2a, 0x54, 0x14, 0x37, 0x78, 0x65, 0x26, + 0x54, 0xd6, 0xf3, 0xc4, 0x91, 0xe0, 0x45, 0xde, 0xe2, 0x94, 0x5b, 0x94, 0x32, 0x37}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11940}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 22947, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\230\237\153c\242P\179\141\223\&2\205Z{\223\153", _pubPktID = 22947, _pubBody = +// "\195\148\247\&4\177\f%\149>q\236W\ETB-\a\209y\n\133o\172*:\131aY", _pubProps = [PropServerReference +// "\198\&6(\SOHH}",PropTopicAliasMaximum 11940,PropRetainAvailable 229,PropResponseInformation +// "\128\171w\200\170x:n*T\DC47xe&T\214\243\196\145\224E\222\226\148[\148\&27",PropSubscriptionIdentifierAvailable +// 153,PropRetainAvailable 170]} +TEST(Publish5QCTest, Decode22) { + uint8_t pkt[] = {0x3a, 0x60, 0x0, 0xf, 0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, 0x7b, + 0xdf, 0x99, 0x59, 0xa3, 0x32, 0x1c, 0x0, 0x6, 0xc6, 0x36, 0x28, 0x1, 0x48, 0x7d, 0x22, 0x2e, 0xa4, + 0x25, 0xe5, 0x1a, 0x0, 0x1d, 0x80, 0xab, 0x77, 0xc8, 0xaa, 0x78, 0x3a, 0x6e, 0x2a, 0x54, 0x14, 0x37, + 0x78, 0x65, 0x26, 0x54, 0xd6, 0xf3, 0xc4, 0x91, 0xe0, 0x45, 0xde, 0xe2, 0x94, 0x5b, 0x94, 0x32, 0x37, + 0x29, 0x99, 0x25, 0xaa, 0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, + 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, + 0xdf, 0x32, 0xcd, 0x5a, 0x7b, 0xdf, 0x99}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, + 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 22947); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\159q1\146\234\232\173\FS`\184\186\140\SYN=Z", _pubPktID = 12817, _pubBody = "EJwh\185\236\204#\166", _pubProps = +// [PropWildcardSubscriptionAvailable 230,PropTopicAliasMaximum 13164,PropResponseInformation +// "f(\159\149\STX\ETB\146r\b\228\&1Y\255\ENQ\161\133\189\239l\195\227s\192",PropSubscriptionIdentifier +// 13,PropCorrelationData ""]} +TEST(Publish5QCTest, Encode23) { + uint8_t pkt[] = {0x33, 0x41, 0x0, 0xf, 0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, 0x8c, 0x16, + 0x3d, 0x5a, 0x32, 0x11, 0x24, 0x28, 0xe6, 0x22, 0x33, 0x6c, 0x1a, 0x0, 0x17, 0x66, 0x28, 0x9f, 0x95, + 0x2, 0x17, 0x92, 0x72, 0x8, 0xe4, 0x31, 0x59, 0xff, 0x5, 0xa1, 0x85, 0xbd, 0xef, 0x6c, 0xc3, 0xe3, + 0x73, 0xc0, 0xb, 0xd, 0x9, 0x0, 0x0, 0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + uint8_t topic_bytes[] = {0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, 0x8c, 0x16, 0x3d, 0x5a}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 9; + + uint8_t bytesprops0[] = {0x66, 0x28, 0x9f, 0x95, 0x2, 0x17, 0x92, 0x72, 0x8, 0xe4, 0x31, 0x59, + 0xff, 0x5, 0xa1, 0x85, 0xbd, 0xef, 0x6c, 0xc3, 0xe3, 0x73, 0xc0}; + uint8_t bytesprops1[] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13164}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops1}}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 12817, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\159q1\146\234\232\173\FS`\184\186\140\SYN=Z", _pubPktID = 12817, _pubBody = "EJwh\185\236\204#\166", _pubProps = +// [PropWildcardSubscriptionAvailable 230,PropTopicAliasMaximum 13164,PropResponseInformation +// "f(\159\149\STX\ETB\146r\b\228\&1Y\255\ENQ\161\133\189\239l\195\227s\192",PropSubscriptionIdentifier +// 13,PropCorrelationData ""]} +TEST(Publish5QCTest, Decode23) { + uint8_t pkt[] = {0x33, 0x41, 0x0, 0xf, 0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, 0x8c, 0x16, + 0x3d, 0x5a, 0x32, 0x11, 0x24, 0x28, 0xe6, 0x22, 0x33, 0x6c, 0x1a, 0x0, 0x17, 0x66, 0x28, 0x9f, 0x95, + 0x2, 0x17, 0x92, 0x72, 0x8, 0xe4, 0x31, 0x59, 0xff, 0x5, 0xa1, 0x85, 0xbd, 0xef, 0x6c, 0xc3, 0xe3, + 0x73, 0xc0, 0xb, 0xd, 0x9, 0x0, 0x0, 0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, + 0x60, 0xb8, 0xba, 0x8c, 0x16, 0x3d, 0x5a}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 12817); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "7_", _pubPktID = 0, _pubBody = +// "1l\172\222\&2J\173\154BN|", _pubProps = [PropAuthenticationData "N\249\ESC\DC4\178\165l\GS\193 +// @\237\FSc\130\US\168L\221\212\134M\184\177",PropServerReference +// "\229\142\151\208\141\194\159xc\240\176\128+N\215xB>\239\174",PropTopicAliasMaximum 26288,PropCorrelationData +// "\ESCK\213\ETXj\232~\r\137\200>",PropMaximumPacketSize 9064,PropResponseTopic +// "\131\226]\251:\231\173\211:9^\ESC\153\165\ACK\175\199\CAN\248H[",PropUserProperty "C" +// "\SO\ETX\187\233\164mYM\130\&6\v\150\178\186K\203\179m\"\201\&6\129"]} +TEST(Publish5QCTest, Encode24) { + uint8_t pkt[] = {0x30, 0x8c, 0x1, 0x0, 0x2, 0x37, 0x5f, 0x7c, 0x16, 0x0, 0x18, 0x4e, 0xf9, 0x1b, 0x14, 0xb2, + 0xa5, 0x6c, 0x1d, 0xc1, 0x20, 0x40, 0xed, 0x1c, 0x63, 0x82, 0x1f, 0xa8, 0x4c, 0xdd, 0xd4, 0x86, + 0x4d, 0xb8, 0xb1, 0x1c, 0x0, 0x14, 0xe5, 0x8e, 0x97, 0xd0, 0x8d, 0xc2, 0x9f, 0x78, 0x63, 0xf0, + 0xb0, 0x80, 0x2b, 0x4e, 0xd7, 0x78, 0x42, 0x3e, 0xef, 0xae, 0x22, 0x66, 0xb0, 0x9, 0x0, 0xb, + 0x1b, 0x4b, 0xd5, 0x3, 0x6a, 0xe8, 0x7e, 0xd, 0x89, 0xc8, 0x3e, 0x27, 0x0, 0x0, 0x23, 0x68, + 0x8, 0x0, 0x15, 0x83, 0xe2, 0x5d, 0xfb, 0x3a, 0xe7, 0xad, 0xd3, 0x3a, 0x39, 0x5e, 0x1b, 0x99, + 0xa5, 0x6, 0xaf, 0xc7, 0x18, 0xf8, 0x48, 0x5b, 0x26, 0x0, 0x1, 0x43, 0x0, 0x16, 0xe, 0x3, + 0xbb, 0xe9, 0xa4, 0x6d, 0x59, 0x4d, 0x82, 0x36, 0xb, 0x96, 0xb2, 0xba, 0x4b, 0xcb, 0xb3, 0x6d, + 0x22, 0xc9, 0x36, 0x81, 0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + uint8_t topic_bytes[] = {0x37, 0x5f}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 11; + + uint8_t bytesprops0[] = {0x4e, 0xf9, 0x1b, 0x14, 0xb2, 0xa5, 0x6c, 0x1d, 0xc1, 0x20, 0x40, 0xed, + 0x1c, 0x63, 0x82, 0x1f, 0xa8, 0x4c, 0xdd, 0xd4, 0x86, 0x4d, 0xb8, 0xb1}; + uint8_t bytesprops1[] = {0xe5, 0x8e, 0x97, 0xd0, 0x8d, 0xc2, 0x9f, 0x78, 0x63, 0xf0, + 0xb0, 0x80, 0x2b, 0x4e, 0xd7, 0x78, 0x42, 0x3e, 0xef, 0xae}; + uint8_t bytesprops2[] = {0x1b, 0x4b, 0xd5, 0x3, 0x6a, 0xe8, 0x7e, 0xd, 0x89, 0xc8, 0x3e}; + uint8_t bytesprops3[] = {0x83, 0xe2, 0x5d, 0xfb, 0x3a, 0xe7, 0xad, 0xd3, 0x3a, 0x39, 0x5e, + 0x1b, 0x99, 0xa5, 0x6, 0xaf, 0xc7, 0x18, 0xf8, 0x48, 0x5b}; + uint8_t bytesprops5[] = {0xe, 0x3, 0xbb, 0xe9, 0xa4, 0x6d, 0x59, 0x4d, 0x82, 0x36, 0xb, + 0x96, 0xb2, 0xba, 0x4b, 0xcb, 0xb3, 0x6d, 0x22, 0xc9, 0x36, 0x81}; + uint8_t bytesprops4[] = {0x43}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26288}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9064}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops4}, .v = {22, (char*)&bytesprops5}}}}, + }; + + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "7_", _pubPktID = 0, _pubBody = +// "1l\172\222\&2J\173\154BN|", _pubProps = [PropAuthenticationData "N\249\ESC\DC4\178\165l\GS\193 +// @\237\FSc\130\US\168L\221\212\134M\184\177",PropServerReference +// "\229\142\151\208\141\194\159xc\240\176\128+N\215xB>\239\174",PropTopicAliasMaximum 26288,PropCorrelationData +// "\ESCK\213\ETXj\232~\r\137\200>",PropMaximumPacketSize 9064,PropResponseTopic +// "\131\226]\251:\231\173\211:9^\ESC\153\165\ACK\175\199\CAN\248H[",PropUserProperty "C" +// "\SO\ETX\187\233\164mYM\130\&6\v\150\178\186K\203\179m\"\201\&6\129"]} +TEST(Publish5QCTest, Decode24) { + uint8_t pkt[] = {0x30, 0x8c, 0x1, 0x0, 0x2, 0x37, 0x5f, 0x7c, 0x16, 0x0, 0x18, 0x4e, 0xf9, 0x1b, 0x14, 0xb2, + 0xa5, 0x6c, 0x1d, 0xc1, 0x20, 0x40, 0xed, 0x1c, 0x63, 0x82, 0x1f, 0xa8, 0x4c, 0xdd, 0xd4, 0x86, + 0x4d, 0xb8, 0xb1, 0x1c, 0x0, 0x14, 0xe5, 0x8e, 0x97, 0xd0, 0x8d, 0xc2, 0x9f, 0x78, 0x63, 0xf0, + 0xb0, 0x80, 0x2b, 0x4e, 0xd7, 0x78, 0x42, 0x3e, 0xef, 0xae, 0x22, 0x66, 0xb0, 0x9, 0x0, 0xb, + 0x1b, 0x4b, 0xd5, 0x3, 0x6a, 0xe8, 0x7e, 0xd, 0x89, 0xc8, 0x3e, 0x27, 0x0, 0x0, 0x23, 0x68, + 0x8, 0x0, 0x15, 0x83, 0xe2, 0x5d, 0xfb, 0x3a, 0xe7, 0xad, 0xd3, 0x3a, 0x39, 0x5e, 0x1b, 0x99, + 0xa5, 0x6, 0xaf, 0xc7, 0x18, 0xf8, 0x48, 0x5b, 0x26, 0x0, 0x1, 0x43, 0x0, 0x16, 0xe, 0x3, + 0xbb, 0xe9, 0xa4, 0x6d, 0x59, 0x4d, 0x82, 0x36, 0xb, 0x96, 0xb2, 0xba, 0x4b, 0xcb, 0xb3, 0x6d, + 0x22, 0xc9, 0x36, 0x81, 0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x37, 0x5f}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\246\202\200\133Ey", _pubPktID = +// 19152, _pubBody = "G\255\&5Bg\183\227x}.\158X\246mx\199u\250\US\ETXI\ENQ\249\155!rJ", _pubProps = +// [PropResponseInformation "L\GS\243\ACK\r\226\138b\173\209\243\214"]} +TEST(Publish5QCTest, Encode25) { + uint8_t pkt[] = {0x35, 0x35, 0x0, 0x6, 0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79, 0x4a, 0xd0, 0xf, 0x1a, + 0x0, 0xc, 0x4c, 0x1d, 0xf3, 0x6, 0xd, 0xe2, 0x8a, 0x62, 0xad, 0xd1, 0xf3, 0xd6, + 0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, + 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + uint8_t topic_bytes[] = {0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, + 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 27; + + uint8_t bytesprops0[] = {0x4c, 0x1d, 0xf3, 0x6, 0xd, 0xe2, 0x8a, 0x62, 0xad, 0xd1, 0xf3, 0xd6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops0}}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19152, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\246\202\200\133Ey", _pubPktID = +// 19152, _pubBody = "G\255\&5Bg\183\227x}.\158X\246mx\199u\250\US\ETXI\ENQ\249\155!rJ", _pubProps = +// [PropResponseInformation "L\GS\243\ACK\r\226\138b\173\209\243\214"]} +TEST(Publish5QCTest, Decode25) { + uint8_t pkt[] = {0x35, 0x35, 0x0, 0x6, 0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79, 0x4a, 0xd0, 0xf, 0x1a, + 0x0, 0xc, 0x4c, 0x1d, 0xf3, 0x6, 0xd, 0xe2, 0x8a, 0x62, 0xad, 0xd1, 0xf3, 0xd6, + 0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, + 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, + 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 19152); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\\\211\215", _pubPktID = 7594, +// _pubBody = "\139\150\137\180\142\209{^\232\155\136\252\140\233\138", _pubProps = [PropMaximumQoS +// 183,PropWildcardSubscriptionAvailable 166,PropResponseInformation +// "\NAK\a\164$\"\164\FS\183\221N\133Vq",PropResponseTopic +// "\181\172\134\252\225C\136I\NAKC\139\151\128F\139\ESCpr\219kB\GS",PropResponseInformation +// "xY\251\200Q*\230\222>\186X:\188\217\161f5#\186\186\249\DC3\142\137y\NAK",PropRequestResponseInformation +// 180,PropSubscriptionIdentifierAvailable 102,PropWillDelayInterval 18867,PropMessageExpiryInterval +// 9600,PropContentType "5G\139\SUB\SI%\246K+\166\181\SUB>\194\SOHSG\207,X\186l\DC2\164R",PropWillDelayInterval +// 11214,PropResponseTopic +// "8\225\206\&8\206P\134lK\153\143>\156\SYN\208]1\185\SOM\t\195r\219\&2\159\US\206\GS^",PropMessageExpiryInterval +// 24117,PropAuthenticationMethod "\DC2J\251\224p\NAK",PropTopicAlias 22040,PropWillDelayInterval +// 5953,PropMaximumPacketSize 17987,PropResponseTopic +// "\231\191\180\EM~\SYN\231\248&\228\173u'\186\217\200\239\210\209\154=8\RS\211\239?\212\202",PropAuthenticationMethod +// "\176\ETB\\z1\b\139\177{l\DC1\171T\154C\203&\201\242\142\201\151F\182##",PropContentType +// "\171(\154\&0\185i\161\209s\182\GS",PropMaximumQoS 189,PropWillDelayInterval 15657,PropMaximumQoS +// 121,PropReceiveMaximum 23342,PropUserProperty "\135\183u\196Q_\250\164\vvW\210A" +// ",_\CAN@\248\181^\174\176e1",PropCorrelationData "\247\167:\230\166\157",PropRequestResponseInformation +// 132,PropServerKeepAlive 19343]} +TEST(Publish5QCTest, Encode26) { + uint8_t pkt[] = { + 0x3c, 0xce, 0x2, 0x0, 0x3, 0x5c, 0xd3, 0xd7, 0x1d, 0xaa, 0xb6, 0x2, 0x24, 0xb7, 0x28, 0xa6, 0x1a, 0x0, 0xd, + 0x15, 0x7, 0xa4, 0x24, 0x22, 0xa4, 0x1c, 0xb7, 0xdd, 0x4e, 0x85, 0x56, 0x71, 0x8, 0x0, 0x16, 0xb5, 0xac, 0x86, + 0xfc, 0xe1, 0x43, 0x88, 0x49, 0x15, 0x43, 0x8b, 0x97, 0x80, 0x46, 0x8b, 0x1b,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, 0xab, 0x54, 0x9a, 0x43, 0xcb, 0x26, 0xc9, 0xf2, 0x8e, + 0xc9, 0x97, 0x46, 0xb6, 0x23, 0x23, 0x3, 0x0, 0xb, 0xab, 0x28, 0x9a, 0x30, 0xb9, 0x69, 0xa1, 0xd1, 0x73, 0xb6, + 0x1d, 0x24, 0xbd, 0x18, 0x0, 0x0, 0x3d, 0x29, 0x24, 0x79, 0x21, 0x5b, 0x2e, 0x26, 0x0, 0xd, 0x87, 0xb7, 0x75, + 0xc4, 0x51, 0x5f, 0xfa, 0xa4, 0xb, 0x76, 0x57, 0xd2, 0x41, 0x0, 0xb, 0x2c, 0x5f, 0x18, 0x40, 0xf8, 0xb5, 0x5e, + 0xae, 0xb0, 0x65, 0x31, 0x9, 0x0, 0x6, 0xf7, 0xa7, 0x3a, 0xe6, 0xa6, 0x9d, 0x19, 0x84, 0x13, 0x4b, 0x8f, 0x8b, + 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + uint8_t topic_bytes[] = {0x5c, 0xd3, 0xd7}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x8b, 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 15; + + uint8_t bytesprops0[] = {0x15, 0x7, 0xa4, 0x24, 0x22, 0xa4, 0x1c, 0xb7, 0xdd, 0x4e, 0x85, 0x56, 0x71}; + uint8_t bytesprops1[] = {0xb5, 0xac, 0x86, 0xfc, 0xe1, 0x43, 0x88, 0x49, 0x15, 0x43, 0x8b, + 0x97, 0x80, 0x46, 0x8b, 0x1b, 0x70, 0x72, 0xdb, 0x6b, 0x42, 0x1d}; + uint8_t bytesprops2[] = {0x78, 0x59, 0xfb, 0xc8, 0x51, 0x2a, 0xe6, 0xde, 0x3e, 0xba, 0x58, 0x3a, 0xbc, + 0xd9, 0xa1, 0x66, 0x35, 0x23, 0xba, 0xba, 0xf9, 0x13, 0x8e, 0x89, 0x79, 0x15}; + uint8_t bytesprops3[] = {0x35, 0x47, 0x8b, 0x1a, 0xf, 0x25, 0xf6, 0x4b, 0x2b, 0xa6, 0xb5, 0x1a, 0x3e, + 0xc2, 0x1, 0x53, 0x47, 0xcf, 0x2c, 0x58, 0xba, 0x6c, 0x12, 0xa4, 0x52}; + uint8_t bytesprops4[] = {0x38, 0xe1, 0xce, 0x38, 0xce, 0x50, 0x86, 0x6c, 0x4b, 0x99, 0x8f, 0x3e, 0x9c, 0x16, 0xd0, + 0x5d, 0x31, 0xb9, 0xe, 0x4d, 0x9, 0xc3, 0x72, 0xdb, 0x32, 0x9f, 0x1f, 0xce, 0x1d, 0x5e}; + uint8_t bytesprops5[] = {0x12, 0x4a, 0xfb, 0xe0, 0x70, 0x15}; + uint8_t bytesprops6[] = {0xe7, 0xbf, 0xb4, 0x19, 0x7e, 0x16, 0xe7, 0xf8, 0x26, 0xe4, 0xad, 0x75, 0x27, 0xba, + 0xd9, 0xc8, 0xef, 0xd2, 0xd1, 0x9a, 0x3d, 0x38, 0x1e, 0xd3, 0xef, 0x3f, 0xd4, 0xca}; + uint8_t bytesprops7[] = {0xb0, 0x17, 0x5c, 0x7a, 0x31, 0x8, 0x8b, 0xb1, 0x7b, 0x6c, 0x11, 0xab, 0x54, + 0x9a, 0x43, 0xcb, 0x26, 0xc9, 0xf2, 0x8e, 0xc9, 0x97, 0x46, 0xb6, 0x23, 0x23}; + uint8_t bytesprops8[] = {0xab, 0x28, 0x9a, 0x30, 0xb9, 0x69, 0xa1, 0xd1, 0x73, 0xb6, 0x1d}; + uint8_t bytesprops10[] = {0x2c, 0x5f, 0x18, 0x40, 0xf8, 0xb5, 0x5e, 0xae, 0xb0, 0x65, 0x31}; + uint8_t bytesprops9[] = {0x87, 0xb7, 0x75, 0xc4, 0x51, 0x5f, 0xfa, 0xa4, 0xb, 0x76, 0x57, 0xd2, 0x41}; + uint8_t bytesprops11[] = {0xf7, 0xa7, 0x3a, 0xe6, 0xa6, 0x9d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18867}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9600}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11214}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24117}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22040}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5953}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17987}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15657}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23342}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops9}, .v = {11, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19343}}, + }; + + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7594, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\\\211\215", _pubPktID = 7594, +// _pubBody = "\139\150\137\180\142\209{^\232\155\136\252\140\233\138", _pubProps = [PropMaximumQoS +// 183,PropWildcardSubscriptionAvailable 166,PropResponseInformation +// "\NAK\a\164$\"\164\FS\183\221N\133Vq",PropResponseTopic +// "\181\172\134\252\225C\136I\NAKC\139\151\128F\139\ESCpr\219kB\GS",PropResponseInformation +// "xY\251\200Q*\230\222>\186X:\188\217\161f5#\186\186\249\DC3\142\137y\NAK",PropRequestResponseInformation +// 180,PropSubscriptionIdentifierAvailable 102,PropWillDelayInterval 18867,PropMessageExpiryInterval +// 9600,PropContentType "5G\139\SUB\SI%\246K+\166\181\SUB>\194\SOHSG\207,X\186l\DC2\164R",PropWillDelayInterval +// 11214,PropResponseTopic +// "8\225\206\&8\206P\134lK\153\143>\156\SYN\208]1\185\SOM\t\195r\219\&2\159\US\206\GS^",PropMessageExpiryInterval +// 24117,PropAuthenticationMethod "\DC2J\251\224p\NAK",PropTopicAlias 22040,PropWillDelayInterval +// 5953,PropMaximumPacketSize 17987,PropResponseTopic +// "\231\191\180\EM~\SYN\231\248&\228\173u'\186\217\200\239\210\209\154=8\RS\211\239?\212\202",PropAuthenticationMethod +// "\176\ETB\\z1\b\139\177{l\DC1\171T\154C\203&\201\242\142\201\151F\182##",PropContentType +// "\171(\154\&0\185i\161\209s\182\GS",PropMaximumQoS 189,PropWillDelayInterval 15657,PropMaximumQoS +// 121,PropReceiveMaximum 23342,PropUserProperty "\135\183u\196Q_\250\164\vvW\210A" +// ",_\CAN@\248\181^\174\176e1",PropCorrelationData "\247\167:\230\166\157",PropRequestResponseInformation +// 132,PropServerKeepAlive 19343]} +TEST(Publish5QCTest, Decode26) { + uint8_t pkt[] = { + 0x3c, 0xce, 0x2, 0x0, 0x3, 0x5c, 0xd3, 0xd7, 0x1d, 0xaa, 0xb6, 0x2, 0x24, 0xb7, 0x28, 0xa6, 0x1a, 0x0, 0xd, + 0x15, 0x7, 0xa4, 0x24, 0x22, 0xa4, 0x1c, 0xb7, 0xdd, 0x4e, 0x85, 0x56, 0x71, 0x8, 0x0, 0x16, 0xb5, 0xac, 0x86, + 0xfc, 0xe1, 0x43, 0x88, 0x49, 0x15, 0x43, 0x8b, 0x97, 0x80, 0x46, 0x8b, 0x1b, 0x70, 0x72, 0xdb, 0x6b, 0x42, 0x1d, + 0x1a, 0x0, 0x1a, 0x78, 0x59, 0xfb, 0xc8, 0x51, 0x2a, 0xe6, 0xde, 0x3e, 0xba, 0x58, 0x3a, 0xbc, 0xd9, 0xa1, 0x66, + 0x35, 0x23, 0xba, 0xba, 0xf9, 0x13, 0x8e, 0x89, 0x79, 0x15, 0x19, 0xb4, 0x29, 0x66, 0x18, 0x0, 0x0, 0x49, 0xb3, + 0x2, 0x0, 0x0, 0x25, 0x80, 0x3, 0x0, 0x19, 0x35, 0x47, 0x8b, 0x1a, 0xf, 0x25, 0xf6, 0x4b, 0x2b, 0xa6, 0xb5, + 0x1a, 0x3e,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 0x5e, + 0xae, 0xb0, 0x65, 0x31, 0x9, 0x0, 0x6, 0xf7, 0xa7, 0x3a, 0xe6, 0xa6, 0x9d, 0x19, 0x84, 0x13, 0x4b, 0x8f, 0x8b, + 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5c, 0xd3, 0xd7}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8b, 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7594); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "e9\242\201W\247\177\219AK\182\169", +// _pubPktID = 7929, _pubBody = "T\v\FS.x%\218\n\245\225\147\232\145qH\197\203m~\212\&0pk}\161\236\244$\162", _pubProps +// = [PropTopicAliasMaximum 15774,PropCorrelationData "\SUBJV>\197X\v\196^(\197_\145M",PropRequestResponseInformation +// 244,PropMaximumQoS 66,PropWildcardSubscriptionAvailable 152,PropSessionExpiryInterval 15397,PropWillDelayInterval +// 765,PropResponseInformation +// "\SOH\255\DC4~PD{\209\153\229\224E\145s\216\156\199\162\182\171'\217`",PropWillDelayInterval +// 29588,PropAuthenticationData "[:\214\211\229\151\215",PropSubscriptionIdentifier 7,PropMaximumPacketSize +// 10099,PropMaximumQoS 105,PropServerKeepAlive 32351,PropUserProperty "\DC2\165" "\SUB;\228",PropMessageExpiryInterval +// 32078,PropUserProperty +// "\177u\217\166\246\144\225\128\137\217\182\219d\224\142\175\DC2;vI\213R\ACK\168\189\167\132\146-" +// "\179\NUL7\237\&7\151e:\188@\229\&7\DC4M#\r\187~\131\230v\182\244",PropTopicAliasMaximum +// 29830,PropAuthenticationMethod +// "}\188\US\189\196\165?\196/m\224\DC1\163`\186\165\US\222$",PropSharedSubscriptionAvailable 224]} +TEST(Publish5QCTest, Encode27) { + uint8_t pkt[] = { + 0x34, 0xeb, 0x1, 0x0, 0xc, 0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9, 0x1e, 0xf9, + 0xbc, 0x1, 0x22, 0x3d, 0x9e, 0x9, 0x0, 0xe, 0x1a, 0x4a, 0x56, 0x3e, 0xc5, 0x58, 0xb, 0xc4, 0x5e, 0x28, 0xc5, + 0x5f, 0x91, 0x4d, 0x19, 0xf4, 0x24, 0x42, 0x28, 0x98, 0x11, 0x0, 0x0, 0x3c, 0x25, 0x18, 0x0, 0x0, 0x2, 0xfd, + 0x1a, 0x0, 0x17, 0x1, 0xff, 0x14, 0x7e, 0x50, 0x44, 0x7b, 0xd1, 0x99, 0xe5, 0xe0, 0x45, 0x91, 0x73, 0xd8, 0x9c, + 0xc7, 0xa2, 0xb6, 0xab, 0x27, 0xd9, 0x60, 0x18, 0x0, 0x0, 0x73, 0x94, 0x16, 0x0, 0x7, 0x5b, 0x3a, 0xd6, 0xd3, + 0xe5, 0x97, 0xd7, 0xb, 0x7, 0x27, 0x0, 0x0, 0x27, 0x73, 0x24, 0x69, 0x13, 0x7e, 0x5f, 0x26, 0x0, 0x2, 0x12, + 0xa5, 0x0, 0x3, 0x1a, 0x3b, 0xe4, 0x2, 0x0, 0x0, 0x7d, 0x4e, 0x26, 0x0, 0x1d, 0xb1, 0x75, 0xd9, 0xa6, 0xf6, + 0x90, 0xe1, 0x80, 0x89, 0xd9, 0xb6, 0xdb, 0x64, 0xe0, 0x8e, 0xaf, 0x12, 0x3b, 0x76, 0x49, 0xd5, 0x52, 0x6, 0xa8, + 0xbd, 0xa7, 0x84, 0x92, 0x2d, 0x0, 0x17, 0xb3, 0x0, 0x37, 0xed, 0x37, 0x97, 0x65, 0x3a, 0xbc, 0x40, 0xe5, 0x37, + 0x14, 0x4d, 0x23, 0xd, 0xbb, 0x7e, 0x83, 0xe6, 0x76, 0xb6, 0xf4, 0x22, 0x74, 0x86, 0x15, 0x0, 0x13, 0x7d, 0xbc, + 0x1f, 0xbd, 0xc4, 0xa5, 0x3f, 0xc4, 0x2f, 0x6d, 0xe0, 0x11, 0xa3, 0x60, 0xba, 0xa5, 0x1f, 0xde, 0x24, 0x2a, 0xe0, + 0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, 0x48, 0xc5, 0xcb, 0x6d, 0x7e, + 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; + uint8_t topic_bytes[] = {0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, 0x48, + 0xc5, 0xcb, 0x6d, 0x7e, 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; + + uint8_t bytesprops0[] = {0x1a, 0x4a, 0x56, 0x3e, 0xc5, 0x58, 0xb, 0xc4, 0x5e, 0x28, 0xc5, 0x5f, 0x91, 0x4d}; + uint8_t bytesprops1[] = {0x1, 0xff, 0x14, 0x7e, 0x50, 0x44, 0x7b, 0xd1, 0x99, 0xe5, 0xe0, 0x45, + 0x91, 0x73, 0xd8, 0x9c, 0xc7, 0xa2, 0xb6, 0xab, 0x27, 0xd9, 0x60}; + uint8_t bytesprops2[] = {0x5b, 0x3a, 0xd6, 0xd3, 0xe5, 0x97, 0xd7}; + uint8_t bytesprops4[] = {0x1a, 0x3b, 0xe4}; + uint8_t bytesprops3[] = {0x12, 0xa5}; + uint8_t bytesprops6[] = {0xb3, 0x0, 0x37, 0xed, 0x37, 0x97, 0x65, 0x3a, 0xbc, 0x40, 0xe5, 0x37, + 0x14, 0x4d, 0x23, 0xd, 0xbb, 0x7e, 0x83, 0xe6, 0x76, 0xb6, 0xf4}; + uint8_t bytesprops5[] = {0xb1, 0x75, 0xd9, 0xa6, 0xf6, 0x90, 0xe1, 0x80, 0x89, 0xd9, 0xb6, 0xdb, 0x64, 0xe0, 0x8e, + 0xaf, 0x12, 0x3b, 0x76, 0x49, 0xd5, 0x52, 0x6, 0xa8, 0xbd, 0xa7, 0x84, 0x92, 0x2d}; + uint8_t bytesprops7[] = {0x7d, 0xbc, 0x1f, 0xbd, 0xc4, 0xa5, 0x3f, 0xc4, 0x2f, 0x6d, + 0xe0, 0x11, 0xa3, 0x60, 0xba, 0xa5, 0x1f, 0xde, 0x24}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15774}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15397}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 765}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29588}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10099}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32351}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops3}, .v = {3, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32078}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops5}, .v = {23, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29830}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 224}}, + }; + + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7929, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "e9\242\201W\247\177\219AK\182\169", +// _pubPktID = 7929, _pubBody = "T\v\FS.x%\218\n\245\225\147\232\145qH\197\203m~\212\&0pk}\161\236\244$\162", _pubProps +// = [PropTopicAliasMaximum 15774,PropCorrelationData "\SUBJV>\197X\v\196^(\197_\145M",PropRequestResponseInformation +// 244,PropMaximumQoS 66,PropWildcardSubscriptionAvailable 152,PropSessionExpiryInterval 15397,PropWillDelayInterval +// 765,PropResponseInformation +// "\SOH\255\DC4~PD{\209\153\229\224E\145s\216\156\199\162\182\171'\217`",PropWillDelayInterval +// 29588,PropAuthenticationData "[:\214\211\229\151\215",PropSubscriptionIdentifier 7,PropMaximumPacketSize +// 10099,PropMaximumQoS 105,PropServerKeepAlive 32351,PropUserProperty "\DC2\165" "\SUB;\228",PropMessageExpiryInterval +// 32078,PropUserProperty +// "\177u\217\166\246\144\225\128\137\217\182\219d\224\142\175\DC2;vI\213R\ACK\168\189\167\132\146-" +// "\179\NUL7\237\&7\151e:\188@\229\&7\DC4M#\r\187~\131\230v\182\244",PropTopicAliasMaximum +// 29830,PropAuthenticationMethod +// "}\188\US\189\196\165?\196/m\224\DC1\163`\186\165\US\222$",PropSharedSubscriptionAvailable 224]} +TEST(Publish5QCTest, Decode27) { + uint8_t pkt[] = { + 0x34, 0xeb, 0x1, 0x0, 0xc, 0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9, 0x1e, 0xf9, + 0xbc, 0x1, 0x22, 0x3d, 0x9e, 0x9, 0x0, 0xe, 0x1a, 0x4a, 0x56, 0x3e, 0xc5, 0x58, 0xb, 0xc4, 0x5e, 0x28, 0xc5, + 0x5f, 0x91, 0x4d, 0x19, 0xf4, 0x24, 0x42, 0x28, 0x98, 0x11, 0x0, 0x0, 0x3c, 0x25, 0x18, 0x0, 0x0, 0x2, 0xfd, + 0x1a, 0x0, 0x17, 0x1, 0xff, 0x14, 0x7e, 0x50, 0x44, 0x7b, 0xd1, 0x99, 0xe5, 0xe0, 0x45, 0x91, 0x73, 0xd8, 0x9c, + 0xc7, 0xa2, 0xb6, 0xab, 0x27, 0xd9, 0x60, 0x18, 0x0, 0x0, 0x73, 0x94, 0x16, 0x0, 0x7, 0x5b, 0x3a, 0xd6, 0xd3, + 0xe5, 0x97, 0xd7, 0xb, 0x7, 0x27, 0x0, 0x0, 0x27, 0x73, 0x24, 0x69, 0x13, 0x7e, 0x5f, 0x26, 0x0, 0x2, 0x12, + 0xa5, 0x0, 0x3, 0x1a, 0x3b, 0xe4, 0x2, 0x0, 0x0, 0x7d, 0x4e, 0x26, 0x0, 0x1d, 0xb1, 0x75, 0xd9, 0xa6, 0xf6, + 0x90, 0xe1, 0x80, 0x89, 0xd9, 0xb6, 0xdb, 0x64, 0xe0, 0x8e, 0xaf, 0x12, 0x3b, 0x76, 0x49, 0xd5, 0x52, 0x6, 0xa8, + 0xbd, 0xa7, 0x84, 0x92, 0x2d, 0x0, 0x17, 0xb3, 0x0, 0x37, 0xed, 0x37, 0x97, 0x65, 0x3a, 0xbc, 0x40, 0xe5, 0x37, + 0x14, 0x4d, 0x23, 0xd, 0xbb, 0x7e, 0x83, 0xe6, 0x76, 0xb6, 0xf4, 0x22, 0x74, 0x86, 0x15, 0x0, 0x13, 0x7d, 0xbc, + 0x1f, 0xbd, 0xc4, 0xa5, 0x3f, 0xc4, 0x2f, 0x6d, 0xe0, 0x11, 0xa3, 0x60, 0xba, 0xa5, 0x1f, 0xde, 0x24, 0x2a, 0xe0, + 0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, 0x48, 0xc5, 0xcb, 0x6d, 0x7e, + 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, 0x48, + 0xc5, 0xcb, 0x6d, 0x7e, 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7929); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\235\160n\156\199\DC14\f\233\197\243\207\145\204|J/\129\156\&5$&Z", _pubPktID = 0, _pubBody = +// "\143\195\191\225_\213\191E\230c\156\216\152\CAN\208\204-", _pubProps = [PropResponseTopic +// "\138zf\158h\178|\233}.\244\SO\DLE\137\211\206\134;y\223g\211\250\\\211\181\RSr\223Z",PropRequestResponseInformation +// 253,PropMaximumQoS 194,PropReceiveMaximum 22488,PropMaximumQoS 223]} +TEST(Publish5QCTest, Encode28) { + uint8_t pkt[] = {0x39, 0x55, 0x0, 0x17, 0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, + 0xcf, 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a, 0x2a, 0x8, 0x0, + 0x1e, 0x8a, 0x7a, 0x66, 0x9e, 0x68, 0xb2, 0x7c, 0xe9, 0x7d, 0x2e, 0xf4, 0xe, 0x10, 0x89, + 0xd3, 0xce, 0x86, 0x3b, 0x79, 0xdf, 0x67, 0xd3, 0xfa, 0x5c, 0xd3, 0xb5, 0x1e, 0x72, 0xdf, + 0x5a, 0x19, 0xfd, 0x24, 0xc2, 0x21, 0x57, 0xd8, 0x24, 0xdf, 0x8f, 0xc3, 0xbf, 0xe1, 0x5f, + 0xd5, 0xbf, 0x45, 0xe6, 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + uint8_t topic_bytes[] = {0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, 0xcf, + 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x8f, 0xc3, 0xbf, 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, + 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 17; + + uint8_t bytesprops0[] = {0x8a, 0x7a, 0x66, 0x9e, 0x68, 0xb2, 0x7c, 0xe9, 0x7d, 0x2e, 0xf4, 0xe, 0x10, 0x89, 0xd3, + 0xce, 0x86, 0x3b, 0x79, 0xdf, 0x67, 0xd3, 0xfa, 0x5c, 0xd3, 0xb5, 0x1e, 0x72, 0xdf, 0x5a}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22488}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\235\160n\156\199\DC14\f\233\197\243\207\145\204|J/\129\156\&5$&Z", _pubPktID = 0, _pubBody = +// "\143\195\191\225_\213\191E\230c\156\216\152\CAN\208\204-", _pubProps = [PropResponseTopic +// "\138zf\158h\178|\233}.\244\SO\DLE\137\211\206\134;y\223g\211\250\\\211\181\RSr\223Z",PropRequestResponseInformation +// 253,PropMaximumQoS 194,PropReceiveMaximum 22488,PropMaximumQoS 223]} +TEST(Publish5QCTest, Decode28) { + uint8_t pkt[] = {0x39, 0x55, 0x0, 0x17, 0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, + 0xcf, 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a, 0x2a, 0x8, 0x0, + 0x1e, 0x8a, 0x7a, 0x66, 0x9e, 0x68, 0xb2, 0x7c, 0xe9, 0x7d, 0x2e, 0xf4, 0xe, 0x10, 0x89, + 0xd3, 0xce, 0x86, 0x3b, 0x79, 0xdf, 0x67, 0xd3, 0xfa, 0x5c, 0xd3, 0xb5, 0x1e, 0x72, 0xdf, + 0x5a, 0x19, 0xfd, 0x24, 0xc2, 0x21, 0x57, 0xd8, 0x24, 0xdf, 0x8f, 0xc3, 0xbf, 0xe1, 0x5f, + 0xd5, 0xbf, 0x45, 0xe6, 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, 0xcf, + 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8f, 0xc3, 0xbf, 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, + 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\182~R\STX\198L\RS%^\137\162\228\&70", _pubPktID = 1453, _pubBody = "\188=\n\155\249", _pubProps = +// [PropMessageExpiryInterval 873,PropContentType "\223c\216uv$\144\223\ETXy",PropServerKeepAlive +// 8157,PropMaximumPacketSize 15512,PropRequestProblemInformation 78,PropServerReference +// "\169\&6\179\ACK\162;\179L?\164'\168\132\160\&9",PropMessageExpiryInterval 7902,PropAuthenticationData +// "}\206\145\216\182\173\&0B\ETXTC\207f3\136m",PropMessageExpiryInterval 27667,PropAuthenticationMethod +// "\239i$\175_\149;",PropRequestResponseInformation 21,PropSubscriptionIdentifierAvailable 5,PropUserProperty +// "\SI\vuX#66\184\165\147f\230I" "\132\164\151\233\200A A>Y\150\&4\145G\NAK\GS'2\136",PropWildcardSubscriptionAvailable +// 90,PropContentType "\189\227\153\SO\199\185\173V\ETB*.\224\168\142\n\191\166s\ACK\b"]} +TEST(Publish5QCTest, Encode29) { + uint8_t pkt[] = {0x3d, 0xb0, 0x1, 0x0, 0xe, 0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, + 0x37, 0x30, 0x5, 0xad, 0x97, 0x1, 0x2, 0x0, 0x0, 0x3, 0x69, 0x3, 0x0, 0xa, 0xdf, 0x63, 0xd8, + 0x75, 0x76, 0x24, 0x90, 0xdf, 0x3, 0x79, 0x13, 0x1f, 0xdd, 0x27, 0x0, 0x0, 0x3c, 0x98, 0x17, 0x4e, + 0x1c, 0x0, 0xf, 0xa9, 0x36, 0xb3, 0x6, 0xa2, 0x3b, 0xb3, 0x4c, 0x3f, 0xa4, 0x27, 0xa8, 0x84, 0xa0, + 0x39, 0x2, 0x0, 0x0, 0x1e, 0xde, 0x16, 0x0, 0x10, 0x7d, 0xce, 0x91, 0xd8, 0xb6, 0xad, 0x30, 0x42, + 0x3, 0x54, 0x43, 0xcf, 0x66, 0x33, 0x88, 0x6d, 0x2, 0x0, 0x0, 0x6c, 0x13, 0x15, 0x0, 0x7, 0xef, + 0x69, 0x24, 0xaf, 0x5f, 0x95, 0x3b, 0x19, 0x15, 0x29, 0x5, 0x26, 0x0, 0xd, 0xf, 0xb, 0x75, 0x58, + 0x23, 0x36, 0x36, 0xb8, 0xa5, 0x93, 0x66, 0xe6, 0x49, 0x0, 0x13, 0x84, 0xa4, 0x97, 0xe9, 0xc8, 0x41, + 0x20, 0x41, 0x3e, 0x59, 0x96, 0x34, 0x91, 0x47, 0x15, 0x1d, 0x27, 0x32, 0x88, 0x28, 0x5a, 0x3, 0x0, + 0x14, 0xbd, 0xe3, 0x99, 0xe, 0xc7, 0xb9, 0xad, 0x56, 0x17, 0x2a, 0x2e, 0xe0, 0xa8, 0x8e, 0xa, 0xbf, + 0xa6, 0x73, 0x6, 0x8, 0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + uint8_t topic_bytes[] = {0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, 0x37, 0x30}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 5; + + uint8_t bytesprops0[] = {0xdf, 0x63, 0xd8, 0x75, 0x76, 0x24, 0x90, 0xdf, 0x3, 0x79}; + uint8_t bytesprops1[] = {0xa9, 0x36, 0xb3, 0x6, 0xa2, 0x3b, 0xb3, 0x4c, 0x3f, 0xa4, 0x27, 0xa8, 0x84, 0xa0, 0x39}; + uint8_t bytesprops2[] = {0x7d, 0xce, 0x91, 0xd8, 0xb6, 0xad, 0x30, 0x42, + 0x3, 0x54, 0x43, 0xcf, 0x66, 0x33, 0x88, 0x6d}; + uint8_t bytesprops3[] = {0xef, 0x69, 0x24, 0xaf, 0x5f, 0x95, 0x3b}; + uint8_t bytesprops5[] = {0x84, 0xa4, 0x97, 0xe9, 0xc8, 0x41, 0x20, 0x41, 0x3e, 0x59, + 0x96, 0x34, 0x91, 0x47, 0x15, 0x1d, 0x27, 0x32, 0x88}; + uint8_t bytesprops4[] = {0xf, 0xb, 0x75, 0x58, 0x23, 0x36, 0x36, 0xb8, 0xa5, 0x93, 0x66, 0xe6, 0x49}; + uint8_t bytesprops6[] = {0xbd, 0xe3, 0x99, 0xe, 0xc7, 0xb9, 0xad, 0x56, 0x17, 0x2a, + 0x2e, 0xe0, 0xa8, 0x8e, 0xa, 0xbf, 0xa6, 0x73, 0x6, 0x8}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 873}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8157}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15512}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7902}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27667}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops4}, .v = {19, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops6}}}, + }; + + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1453, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\182~R\STX\198L\RS%^\137\162\228\&70", _pubPktID = 1453, _pubBody = "\188=\n\155\249", _pubProps = +// [PropMessageExpiryInterval 873,PropContentType "\223c\216uv$\144\223\ETXy",PropServerKeepAlive +// 8157,PropMaximumPacketSize 15512,PropRequestProblemInformation 78,PropServerReference +// "\169\&6\179\ACK\162;\179L?\164'\168\132\160\&9",PropMessageExpiryInterval 7902,PropAuthenticationData +// "}\206\145\216\182\173\&0B\ETXTC\207f3\136m",PropMessageExpiryInterval 27667,PropAuthenticationMethod +// "\239i$\175_\149;",PropRequestResponseInformation 21,PropSubscriptionIdentifierAvailable 5,PropUserProperty +// "\SI\vuX#66\184\165\147f\230I" "\132\164\151\233\200A A>Y\150\&4\145G\NAK\GS'2\136",PropWildcardSubscriptionAvailable +// 90,PropContentType "\189\227\153\SO\199\185\173V\ETB*.\224\168\142\n\191\166s\ACK\b"]} +TEST(Publish5QCTest, Decode29) { + uint8_t pkt[] = {0x3d, 0xb0, 0x1, 0x0, 0xe, 0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, + 0x37, 0x30, 0x5, 0xad, 0x97, 0x1, 0x2, 0x0, 0x0, 0x3, 0x69, 0x3, 0x0, 0xa, 0xdf, 0x63, 0xd8, + 0x75, 0x76, 0x24, 0x90, 0xdf, 0x3, 0x79, 0x13, 0x1f, 0xdd, 0x27, 0x0, 0x0, 0x3c, 0x98, 0x17, 0x4e, + 0x1c, 0x0, 0xf, 0xa9, 0x36, 0xb3, 0x6, 0xa2, 0x3b, 0xb3, 0x4c, 0x3f, 0xa4, 0x27, 0xa8, 0x84, 0xa0, + 0x39, 0x2, 0x0, 0x0, 0x1e, 0xde, 0x16, 0x0, 0x10, 0x7d, 0xce, 0x91, 0xd8, 0xb6, 0xad, 0x30, 0x42, + 0x3, 0x54, 0x43, 0xcf, 0x66, 0x33, 0x88, 0x6d, 0x2, 0x0, 0x0, 0x6c, 0x13, 0x15, 0x0, 0x7, 0xef, + 0x69, 0x24, 0xaf, 0x5f, 0x95, 0x3b, 0x19, 0x15, 0x29, 0x5, 0x26, 0x0, 0xd, 0xf, 0xb, 0x75, 0x58, + 0x23, 0x36, 0x36, 0xb8, 0xa5, 0x93, 0x66, 0xe6, 0x49, 0x0, 0x13, 0x84, 0xa4, 0x97, 0xe9, 0xc8, 0x41, + 0x20, 0x41, 0x3e, 0x59, 0x96, 0x34, 0x91, 0x47, 0x15, 0x1d, 0x27, 0x32, 0x88, 0x28, 0x5a, 0x3, 0x0, + 0x14, 0xbd, 0xe3, 0x99, 0xe, 0xc7, 0xb9, 0xad, 0x56, 0x17, 0x2a, 0x2e, 0xe0, 0xa8, 0x8e, 0xa, 0xbf, + 0xa6, 0x73, 0x6, 0x8, 0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, 0x37, 0x30}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 1453); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\191k-$.\245\SUB\192\234\155$", +// _pubPktID = 29170, _pubBody = "[F\181\186O\149", _pubProps = [PropRequestProblemInformation +// 119,PropPayloadFormatIndicator 239,PropWildcardSubscriptionAvailable 115,PropMaximumPacketSize +// 25304,PropAssignedClientIdentifier "n4\239\&8m\163\225T/\181\230\189",PropReasonString +// "\145\USv\152vy\DC1\a\131\&1\207",PropUserProperty +// "^\170=\229Z\DC4\241\181G\SI\146\253\ETX\f\136`\DEL6\239\165;7\130\DEL\224\198I-\184\229" +// "ab\181\192\DLEJ[\255v}\175\SI\131R^u\238:\ETB\144\186gW\STX\EM\152",PropServerKeepAlive 20060,PropReasonString +// "\221\&4'\184\&2\SI\207\234#",PropSharedSubscriptionAvailable 134,PropSubscriptionIdentifier +// 12,PropPayloadFormatIndicator 201,PropPayloadFormatIndicator 253,PropAuthenticationData +// "`N\249qh*\SI}\177\130\198",PropMessageExpiryInterval 20002,PropRequestProblemInformation +// 106,PropAuthenticationMethod "p\178[&s<[\130\212R\198\132\243\168\DC4",PropRequestResponseInformation +// 96,PropUserProperty "\139R\205\238/\177\235}\194\EM\179" +// "M-Zq\\\247H\ETX\210\222\182\&6w\182k&|\207\230f\ETX,\152G@\134",PropMaximumQoS 111,PropWillDelayInterval +// 24311,PropWildcardSubscriptionAvailable 44,PropRequestResponseInformation 218,PropMaximumPacketSize +// 29821,PropContentType "<"]} +TEST(Publish5QCTest, Encode30) { + uint8_t pkt[] = {0x33, 0xfa, 0x1, 0x0, 0xb, 0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24, 0x71, + 0xf2, 0xe3, 0x1, 0x17, 0x77, 0x1, 0xef, 0x28, 0x73, 0x27, 0x0, 0x0, 0x62, 0xd8, 0x12, 0x0, 0xc, + 0x6e, 0x34, 0xef, 0x38, 0x6d, 0xa3, 0xe1, 0x54, 0x2f, 0xb5, 0xe6, 0xbd, 0x1f, 0x0, 0xb, 0x91, 0x1f, + 0x76, 0x98, 0x76, 0x79, 0x11, 0x7, 0x83, 0x31, 0xcf, 0x26, 0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, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + uint8_t topic_bytes[] = {0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 6; + + uint8_t bytesprops0[] = {0x6e, 0x34, 0xef, 0x38, 0x6d, 0xa3, 0xe1, 0x54, 0x2f, 0xb5, 0xe6, 0xbd}; + uint8_t bytesprops1[] = {0x91, 0x1f, 0x76, 0x98, 0x76, 0x79, 0x11, 0x7, 0x83, 0x31, 0xcf}; + uint8_t bytesprops3[] = {0x61, 0x62, 0xb5, 0xc0, 0x10, 0x4a, 0x5b, 0xff, 0x76, 0x7d, 0xaf, 0xf, 0x83, + 0x52, 0x5e, 0x75, 0xee, 0x3a, 0x17, 0x90, 0xba, 0x67, 0x57, 0x2, 0x19, 0x98}; + uint8_t bytesprops2[] = {0x5e, 0xaa, 0x3d, 0xe5, 0x5a, 0x14, 0xf1, 0xb5, 0x47, 0xf, 0x92, 0xfd, 0x3, 0xc, 0x88, + 0x60, 0x7f, 0x36, 0xef, 0xa5, 0x3b, 0x37, 0x82, 0x7f, 0xe0, 0xc6, 0x49, 0x2d, 0xb8, 0xe5}; + uint8_t bytesprops4[] = {0xdd, 0x34, 0x27, 0xb8, 0x32, 0xf, 0xcf, 0xea, 0x23}; + uint8_t bytesprops5[] = {0x60, 0x4e, 0xf9, 0x71, 0x68, 0x2a, 0xf, 0x7d, 0xb1, 0x82, 0xc6}; + uint8_t bytesprops6[] = {0x70, 0xb2, 0x5b, 0x26, 0x73, 0x3c, 0x5b, 0x82, 0xd4, 0x52, 0xc6, 0x84, 0xf3, 0xa8, 0x14}; + uint8_t bytesprops8[] = {0x4d, 0x2d, 0x5a, 0x71, 0x5c, 0xf7, 0x48, 0x3, 0xd2, 0xde, 0xb6, 0x36, 0x77, + 0xb6, 0x6b, 0x26, 0x7c, 0xcf, 0xe6, 0x66, 0x3, 0x2c, 0x98, 0x47, 0x40, 0x86}; + uint8_t bytesprops7[] = {0x8b, 0x52, 0xcd, 0xee, 0x2f, 0xb1, 0xeb, 0x7d, 0xc2, 0x19, 0xb3}; + uint8_t bytesprops9[] = {0x3c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25304}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops2}, .v = {26, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20060}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20002}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops7}, .v = {26, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24311}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29821}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops9}}}, + }; + + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29170, topic, msg, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\191k-$.\245\SUB\192\234\155$", +// _pubPktID = 29170, _pubBody = "[F\181\186O\149", _pubProps = [PropRequestProblemInformation +// 119,PropPayloadFormatIndicator 239,PropWildcardSubscriptionAvailable 115,PropMaximumPacketSize +// 25304,PropAssignedClientIdentifier "n4\239\&8m\163\225T/\181\230\189",PropReasonString +// "\145\USv\152vy\DC1\a\131\&1\207",PropUserProperty +// "^\170=\229Z\DC4\241\181G\SI\146\253\ETX\f\136`\DEL6\239\165;7\130\DEL\224\198I-\184\229" +// "ab\181\192\DLEJ[\255v}\175\SI\131R^u\238:\ETB\144\186gW\STX\EM\152",PropServerKeepAlive 20060,PropReasonString +// "\221\&4'\184\&2\SI\207\234#",PropSharedSubscriptionAvailable 134,PropSubscriptionIdentifier +// 12,PropPayloadFormatIndicator 201,PropPayloadFormatIndicator 253,PropAuthenticationData +// "`N\249qh*\SI}\177\130\198",PropMessageExpiryInterval 20002,PropRequestProblemInformation +// 106,PropAuthenticationMethod "p\178[&s<[\130\212R\198\132\243\168\DC4",PropRequestResponseInformation +// 96,PropUserProperty "\139R\205\238/\177\235}\194\EM\179" +// "M-Zq\\\247H\ETX\210\222\182\&6w\182k&|\207\230f\ETX,\152G@\134",PropMaximumQoS 111,PropWillDelayInterval +// 24311,PropWildcardSubscriptionAvailable 44,PropRequestResponseInformation 218,PropMaximumPacketSize +// 29821,PropContentType "<"]} +TEST(Publish5QCTest, Decode30) { + uint8_t pkt[] = {0x33, 0xfa, 0x1, 0x0, 0xb, 0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24, 0x71, + 0xf2, 0xe3, 0x1, 0x17, 0x77, 0x1, 0xef, 0x28, 0x73, 0x27, 0x0, 0x0, 0x62, 0xd8, 0x12, 0x0, 0xc, + 0x6e, 0x34, 0xef, 0x38, 0x6d, 0xa3, 0xe1, 0x54, 0x2f, 0xb5, 0xe6, 0xbd, 0x1f, 0x0, 0xb, 0x91, 0x1f, + 0x76, 0x98, 0x76, 0x79, 0x11, 0x7, 0x83, 0x31, 0xcf, 0x26, 0x0, 0x1e, 0x5e, 0xaa, 0x3d, 0xe5, 0x5a, + 0x14, 0xf1, 0xb5, 0x47, 0xf, 0x92, 0xfd, 0x3, 0xc, 0x88, 0x60, 0x7f, 0x36, 0xef, 0xa5, 0x3b, 0x37, + 0x82, 0x7f, 0xe0, 0xc6, 0x49, 0x2d, 0xb8, 0xe5, 0x0, 0x1a, 0x61, 0x62, 0xb5, 0xc0, 0x10, 0x4a, 0x5b, + 0xff, 0x76, 0x7d, 0xaf, 0xf, 0x83, 0x52, 0x5e, 0x75, 0xee, 0x3a, 0x17, 0x90, 0xba, 0x67, 0x57, 0x2, + 0x19, 0x98, 0x13, 0x4e, 0x5c, 0x1f, 0x0, 0x9, 0xdd, 0x34, 0x27, 0xb8, 0x32, 0xf, 0xcf, 0xea, 0x23, + 0x2a, 0x86, 0xb, 0xc, 0x1, 0xc9, 0x1, 0xfd, 0x16, 0x0, 0xb, 0x60, 0x4e, 0xf9, 0x71, 0x68, 0x2a, + 0xf, 0x7d, 0xb1, 0x82, 0xc6, 0x2, 0x0, 0x0, 0x4e, 0x22, 0x17, 0x6a, 0x15, 0x0, 0xf, 0x70, 0xb2, + 0x5b, 0x26, 0x73, 0x3c, 0x5b, 0x82, 0xd4, 0x52, 0xc6, 0x84, 0xf3, 0xa8, 0x14, 0x19, 0x60, 0x26, 0x0, + 0xb, 0x8b, 0x52, 0xcd, 0xee, 0x2f, 0xb1, 0xeb, 0x7d, 0xc2, 0x19, 0xb3, 0x0, 0x1a, 0x4d, 0x2d, 0x5a, + 0x71, 0x5c, 0xf7, 0x48, 0x3, 0xd2, 0xde, 0xb6, 0x36, 0x77, 0xb6, 0x6b, 0x26, 0x7c, 0xcf, 0xe6, 0x66, + 0x3, 0x2c, 0x98, 0x47, 0x40, 0x86, 0x24, 0x6f, 0x18, 0x0, 0x0, 0x5e, 0xf7, 0x28, 0x2c, 0x19, 0xda, + 0x27, 0x0, 0x0, 0x74, 0x7d, 0x3, 0x0, 0x1, 0x3c, 0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 29170); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "\STXF\139\182d\236&\232\&0\220\246\150\CAN\210\147K\245O\160W*D\145\202", _willMsg = +// "\255\138T\159\195[tN\169\244\200*\226/\ENQ\238\251\DC3", _willProps = []}), _cleanSession = True, _keepAlive = +// 23007, _connID = "\172\233\209\170i\141", _properties = []} +TEST(Connect311QCTest, Encode1) { + uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x59, 0xdf, 0x0, 0x6, 0xac, 0xe9, 0xd1, + 0xaa, 0x69, 0x8d, 0x0, 0x18, 0x2, 0x46, 0x8b, 0xb6, 0x64, 0xec, 0x26, 0xe8, 0x30, 0xdc, 0xf6, 0x96, + 0x18, 0xd2, 0x93, 0x4b, 0xf5, 0x4f, 0xa0, 0x57, 0x2a, 0x44, 0x91, 0xca, 0x0, 0x12, 0xff, 0x8a, 0x54, + 0x9f, 0xc3, 0x5b, 0x74, 0x4e, 0xa9, 0xf4, 0xc8, 0x2a, 0xe2, 0x2f, 0x5, 0xee, 0xfb, 0x13}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2, 0x46, 0x8b, 0xb6, 0x64, 0xec, 0x26, 0xe8, 0x30, 0xdc, 0xf6, 0x96, + 0x18, 0xd2, 0x93, 0x4b, 0xf5, 0x4f, 0xa0, 0x57, 0x2a, 0x44, 0x91, 0xca}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xff, 0x8a, 0x54, 0x9f, 0xc3, 0x5b, 0x74, 0x4e, 0xa9, + 0xf4, 0xc8, 0x2a, 0xe2, 0x2f, 0x5, 0xee, 0xfb, 0x13}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23007; + uint8_t client_id_bytes[] = {0xac, 0xe9, 0xd1, 0xaa, 0x69, 0x8d}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\162\167;\233}\166*\194\SO5I", _password = Just +// "\206\SYN\252];b\f|\249\239\199!!\ETB\142fz\153\250>bv\DC1\ETX\134", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS1, _willTopic = "\DELF\240\209\&7W\203U~\ETBsd", _willMsg = "\146\191]\f|", _willProps = []}), +// _cleanSession = True, _keepAlive = 7161, _connID = "AG\180\214\&5\245\a\196\164Fq\209\141\250>\246\RS", _properties = +// []} +TEST(Connect311QCTest, Encode2) { + uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x1b, 0xf9, 0x0, 0x11, 0x41, 0x47, + 0xb4, 0xd6, 0x35, 0xf5, 0x7, 0xc4, 0xa4, 0x46, 0x71, 0xd1, 0x8d, 0xfa, 0x3e, 0xf6, 0x1e, 0x0, + 0xc, 0x7f, 0x46, 0xf0, 0xd1, 0x37, 0x57, 0xcb, 0x55, 0x7e, 0x17, 0x73, 0x64, 0x0, 0x5, 0x92, + 0xbf, 0x5d, 0xc, 0x7c, 0x0, 0xb, 0xa2, 0xa7, 0x3b, 0xe9, 0x7d, 0xa6, 0x2a, 0xc2, 0xe, 0x35, + 0x49, 0x0, 0x19, 0xce, 0x16, 0xfc, 0x5d, 0x3b, 0x62, 0xc, 0x7c, 0xf9, 0xef, 0xc7, 0x21, 0x21, + 0x17, 0x8e, 0x66, 0x7a, 0x99, 0xfa, 0x3e, 0x62, 0x76, 0x11, 0x3, 0x86}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x7f, 0x46, 0xf0, 0xd1, 0x37, 0x57, 0xcb, 0x55, 0x7e, 0x17, 0x73, 0x64}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x92, 0xbf, 0x5d, 0xc, 0x7c}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 7161; + uint8_t client_id_bytes[] = {0x41, 0x47, 0xb4, 0xd6, 0x35, 0xf5, 0x7, 0xc4, 0xa4, + 0x46, 0x71, 0xd1, 0x8d, 0xfa, 0x3e, 0xf6, 0x1e}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa2, 0xa7, 0x3b, 0xe9, 0x7d, 0xa6, 0x2a, 0xc2, 0xe, 0x35, 0x49}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xce, 0x16, 0xfc, 0x5d, 0x3b, 0x62, 0xc, 0x7c, 0xf9, 0xef, 0xc7, 0x21, 0x21, + 0x17, 0x8e, 0x66, 0x7a, 0x99, 0xfa, 0x3e, 0x62, 0x76, 0x11, 0x3, 0x86}; + lwmqtt_string_t password = {25, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\176gX", _password = Nothing, _lastWill = Nothing, _cleanSession = False, +// _keepAlive = 30736, _connID = "\211\169\254\161\DLE", _properties = []} +TEST(Connect311QCTest, Encode3) { + uint8_t pkt[] = {0x10, 0x16, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x78, 0x10, + 0x0, 0x5, 0xd3, 0xa9, 0xfe, 0xa1, 0x10, 0x0, 0x3, 0xb0, 0x67, 0x58}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 30736; + uint8_t client_id_bytes[] = {0xd3, 0xa9, 0xfe, 0xa1, 0x10}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xb0, 0x67, 0x58}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\152\194\245\253\174\&7\EMM!8\179\176,\247\240\DC1\231\RS", _password = Just +// "/\242\177\206\FS\170L\220\250@\fO\156+2\DLE\GS\141\&5\180!\168t\129\133\aA\SO\213T", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "r\EOTA\136\195\188\137\213\144A\186\189\243\169\226\204\252", +// _willMsg = "\182\NAK", _willProps = []}), _cleanSession = True, _keepAlive = 8837, _connID = +// "\229-\130\155\154a\214\248\214l\CAN\138\244\210%\168\154\156\DC1\241\133\227\&1", _properties = []} +TEST(Connect311QCTest, Encode4) { + uint8_t pkt[] = {0x10, 0x6e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x22, 0x85, 0x0, 0x17, 0xe5, 0x2d, + 0x82, 0x9b, 0x9a, 0x61, 0xd6, 0xf8, 0xd6, 0x6c, 0x18, 0x8a, 0xf4, 0xd2, 0x25, 0xa8, 0x9a, 0x9c, + 0x11, 0xf1, 0x85, 0xe3, 0x31, 0x0, 0x11, 0x72, 0x4, 0x41, 0x88, 0xc3, 0xbc, 0x89, 0xd5, 0x90, + 0x41, 0xba, 0xbd, 0xf3, 0xa9, 0xe2, 0xcc, 0xfc, 0x0, 0x2, 0xb6, 0x15, 0x0, 0x12, 0x98, 0xc2, + 0xf5, 0xfd, 0xae, 0x37, 0x19, 0x4d, 0x21, 0x38, 0xb3, 0xb0, 0x2c, 0xf7, 0xf0, 0x11, 0xe7, 0x1e, + 0x0, 0x1e, 0x2f, 0xf2, 0xb1, 0xce, 0x1c, 0xaa, 0x4c, 0xdc, 0xfa, 0x40, 0xc, 0x4f, 0x9c, 0x2b, + 0x32, 0x10, 0x1d, 0x8d, 0x35, 0xb4, 0x21, 0xa8, 0x74, 0x81, 0x85, 0x7, 0x41, 0xe, 0xd5, 0x54}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x72, 0x4, 0x41, 0x88, 0xc3, 0xbc, 0x89, 0xd5, 0x90, + 0x41, 0xba, 0xbd, 0xf3, 0xa9, 0xe2, 0xcc, 0xfc}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb6, 0x15}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 8837; + uint8_t client_id_bytes[] = {0xe5, 0x2d, 0x82, 0x9b, 0x9a, 0x61, 0xd6, 0xf8, 0xd6, 0x6c, 0x18, 0x8a, + 0xf4, 0xd2, 0x25, 0xa8, 0x9a, 0x9c, 0x11, 0xf1, 0x85, 0xe3, 0x31}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x98, 0xc2, 0xf5, 0xfd, 0xae, 0x37, 0x19, 0x4d, 0x21, + 0x38, 0xb3, 0xb0, 0x2c, 0xf7, 0xf0, 0x11, 0xe7, 0x1e}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x2f, 0xf2, 0xb1, 0xce, 0x1c, 0xaa, 0x4c, 0xdc, 0xfa, 0x40, 0xc, 0x4f, 0x9c, 0x2b, 0x32, + 0x10, 0x1d, 0x8d, 0x35, 0xb4, 0x21, 0xa8, 0x74, 0x81, 0x85, 0x7, 0x41, 0xe, 0xd5, 0x54}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Fl\165\191E\132:\161", _password = Nothing, _lastWill = Just (LastWill {_willRetain +// = True, _willQoS = QoS2, _willTopic = "\213\133\231\FS\130\ACKE\191\250\EM\neI\a\139\243\227\216J\222\222", _willMsg +// = "\247\199pz\189\158\163r[\131P\201w\133", _willProps = []}), _cleanSession = True, _keepAlive = 10218, _connID = +// "\242\150&X\DC2\211\232+\139", _properties = []} +TEST(Connect311QCTest, Encode5) { + uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb6, 0x27, 0xea, 0x0, 0x9, 0xf2, + 0x96, 0x26, 0x58, 0x12, 0xd3, 0xe8, 0x2b, 0x8b, 0x0, 0x15, 0xd5, 0x85, 0xe7, 0x1c, 0x82, + 0x6, 0x45, 0xbf, 0xfa, 0x19, 0xa, 0x65, 0x49, 0x7, 0x8b, 0xf3, 0xe3, 0xd8, 0x4a, 0xde, + 0xde, 0x0, 0xe, 0xf7, 0xc7, 0x70, 0x7a, 0xbd, 0x9e, 0xa3, 0x72, 0x5b, 0x83, 0x50, 0xc9, + 0x77, 0x85, 0x0, 0x8, 0x46, 0x6c, 0xa5, 0xbf, 0x45, 0x84, 0x3a, 0xa1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd5, 0x85, 0xe7, 0x1c, 0x82, 0x6, 0x45, 0xbf, 0xfa, 0x19, 0xa, + 0x65, 0x49, 0x7, 0x8b, 0xf3, 0xe3, 0xd8, 0x4a, 0xde, 0xde}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf7, 0xc7, 0x70, 0x7a, 0xbd, 0x9e, 0xa3, 0x72, 0x5b, 0x83, 0x50, 0xc9, 0x77, 0x85}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 10218; + uint8_t client_id_bytes[] = {0xf2, 0x96, 0x26, 0x58, 0x12, 0xd3, 0xe8, 0x2b, 0x8b}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x46, 0x6c, 0xa5, 0xbf, 0x45, 0x84, 0x3a, 0xa1}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Sz8i\155\185\247\FSM\223\r`\"\187\ACK\244\ETB7(\218^\ETX~\231o+\166\\", _password = +// Just "\254", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "\178\171\DC2\211\200\EM\184\SOH\SI1\182\142\236\165\201\180\217\179\236y\215\n", _willMsg = +// "\176\DC3\142\CAN5\229j\140\194\241\152", _willProps = []}), _cleanSession = True, _keepAlive = 13826, _connID = +// "eYUoE\DELM\180&\227\132\v\STX\ESC\198\183?\245\247n\197\DC1", _properties = []} +TEST(Connect311QCTest, Encode6) { + uint8_t pkt[] = {0x10, 0x68, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x36, 0x2, 0x0, 0x16, 0x65, 0x59, + 0x55, 0x6f, 0x45, 0x7f, 0x4d, 0xb4, 0x26, 0xe3, 0x84, 0xb, 0x2, 0x1b, 0xc6, 0xb7, 0x3f, 0xf5, + 0xf7, 0x6e, 0xc5, 0x11, 0x0, 0x16, 0xb2, 0xab, 0x12, 0xd3, 0xc8, 0x19, 0xb8, 0x1, 0xf, 0x31, + 0xb6, 0x8e, 0xec, 0xa5, 0xc9, 0xb4, 0xd9, 0xb3, 0xec, 0x79, 0xd7, 0xa, 0x0, 0xb, 0xb0, 0x13, + 0x8e, 0x18, 0x35, 0xe5, 0x6a, 0x8c, 0xc2, 0xf1, 0x98, 0x0, 0x1c, 0x53, 0x7a, 0x38, 0x69, 0x9b, + 0xb9, 0xf7, 0x1c, 0x4d, 0xdf, 0xd, 0x60, 0x22, 0xbb, 0x6, 0xf4, 0x17, 0x37, 0x28, 0xda, 0x5e, + 0x3, 0x7e, 0xe7, 0x6f, 0x2b, 0xa6, 0x5c, 0x0, 0x1, 0xfe}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb2, 0xab, 0x12, 0xd3, 0xc8, 0x19, 0xb8, 0x1, 0xf, 0x31, 0xb6, + 0x8e, 0xec, 0xa5, 0xc9, 0xb4, 0xd9, 0xb3, 0xec, 0x79, 0xd7, 0xa}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb0, 0x13, 0x8e, 0x18, 0x35, 0xe5, 0x6a, 0x8c, 0xc2, 0xf1, 0x98}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 13826; + uint8_t client_id_bytes[] = {0x65, 0x59, 0x55, 0x6f, 0x45, 0x7f, 0x4d, 0xb4, 0x26, 0xe3, 0x84, + 0xb, 0x2, 0x1b, 0xc6, 0xb7, 0x3f, 0xf5, 0xf7, 0x6e, 0xc5, 0x11}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x53, 0x7a, 0x38, 0x69, 0x9b, 0xb9, 0xf7, 0x1c, 0x4d, 0xdf, 0xd, 0x60, 0x22, 0xbb, + 0x6, 0xf4, 0x17, 0x37, 0x28, 0xda, 0x5e, 0x3, 0x7e, 0xe7, 0x6f, 0x2b, 0xa6, 0x5c}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xfe}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 28209, _connID = "\246\165\SI\142z\163\217\224;\170\DC1\145\161v\211e", _properties = []} +TEST(Connect311QCTest, Encode7) { + uint8_t pkt[] = {0x10, 0x1c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x6e, 0x31, 0x0, 0x10, 0xf6, + 0xa5, 0xf, 0x8e, 0x7a, 0xa3, 0xd9, 0xe0, 0x3b, 0xaa, 0x11, 0x91, 0xa1, 0x76, 0xd3, 0x65}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 28209; + uint8_t client_id_bytes[] = {0xf6, 0xa5, 0xf, 0x8e, 0x7a, 0xa3, 0xd9, 0xe0, + 0x3b, 0xaa, 0x11, 0x91, 0xa1, 0x76, 0xd3, 0x65}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\EOTj\208\234\&8&{\198\226R\a\248\140\138", _password = Just +// "]TT\227$0q<\DLE\201/\223\204\&4.\225\146v\209\240\154\SI\189O,\183\237", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS2, _willTopic = "\145\172\175\249\r\146", _willMsg = "\227:\v\SYNN\201\f", _willProps = []}), +// _cleanSession = False, _keepAlive = 12527, _connID = "7\EOT\224", _properties = []} +TEST(Connect311QCTest, Encode8) { + uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x30, 0xef, 0x0, 0x3, 0x37, 0x4, + 0xe0, 0x0, 0x6, 0x91, 0xac, 0xaf, 0xf9, 0xd, 0x92, 0x0, 0x7, 0xe3, 0x3a, 0xb, 0x16, 0x4e, + 0xc9, 0xc, 0x0, 0xe, 0x4, 0x6a, 0xd0, 0xea, 0x38, 0x26, 0x7b, 0xc6, 0xe2, 0x52, 0x7, 0xf8, + 0x8c, 0x8a, 0x0, 0x1b, 0x5d, 0x54, 0x54, 0xe3, 0x24, 0x30, 0x71, 0x3c, 0x10, 0xc9, 0x2f, 0xdf, + 0xcc, 0x34, 0x2e, 0xe1, 0x92, 0x76, 0xd1, 0xf0, 0x9a, 0xf, 0xbd, 0x4f, 0x2c, 0xb7, 0xed}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x91, 0xac, 0xaf, 0xf9, 0xd, 0x92}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe3, 0x3a, 0xb, 0x16, 0x4e, 0xc9, 0xc}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 12527; + uint8_t client_id_bytes[] = {0x37, 0x4, 0xe0}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x4, 0x6a, 0xd0, 0xea, 0x38, 0x26, 0x7b, 0xc6, 0xe2, 0x52, 0x7, 0xf8, 0x8c, 0x8a}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x5d, 0x54, 0x54, 0xe3, 0x24, 0x30, 0x71, 0x3c, 0x10, 0xc9, 0x2f, 0xdf, 0xcc, 0x34, + 0x2e, 0xe1, 0x92, 0x76, 0xd1, 0xf0, 0x9a, 0xf, 0xbd, 0x4f, 0x2c, 0xb7, 0xed}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\205!\164q;\149|\140\239|\234\FS\EOT", _password = Just +// "BE\v*U\EM'\159\157\SYNm\DLEn\192\136\vS\"\244\NUL9\228'\195\139\EOT\197\200\194", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "H", _willMsg = +// "\225\198\150\163\208W\238\146\FS\223_\201\251%\143\NUL\243\162\225ll\147\157Z\237\208\211W)", _willProps = []}), +// _cleanSession = True, _keepAlive = 13897, _connID = "\233\129 ", _properties = []} +TEST(Connect311QCTest, Encode9) { + uint8_t pkt[] = {0x10, 0x5f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x36, 0x49, 0x0, 0x3, 0xe9, 0x81, 0x20, + 0x0, 0x1, 0x48, 0x0, 0x1d, 0xe1, 0xc6, 0x96, 0xa3, 0xd0, 0x57, 0xee, 0x92, 0x1c, 0xdf, 0x5f, 0xc9, + 0xfb, 0x25, 0x8f, 0x0, 0xf3, 0xa2, 0xe1, 0x6c, 0x6c, 0x93, 0x9d, 0x5a, 0xed, 0xd0, 0xd3, 0x57, 0x29, + 0x0, 0xd, 0xcd, 0x21, 0xa4, 0x71, 0x3b, 0x95, 0x7c, 0x8c, 0xef, 0x7c, 0xea, 0x1c, 0x4, 0x0, 0x1d, + 0x42, 0x45, 0xb, 0x2a, 0x55, 0x19, 0x27, 0x9f, 0x9d, 0x16, 0x6d, 0x10, 0x6e, 0xc0, 0x88, 0xb, 0x53, + 0x22, 0xf4, 0x0, 0x39, 0xe4, 0x27, 0xc3, 0x8b, 0x4, 0xc5, 0xc8, 0xc2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x48}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe1, 0xc6, 0x96, 0xa3, 0xd0, 0x57, 0xee, 0x92, 0x1c, 0xdf, + 0x5f, 0xc9, 0xfb, 0x25, 0x8f, 0x0, 0xf3, 0xa2, 0xe1, 0x6c, + 0x6c, 0x93, 0x9d, 0x5a, 0xed, 0xd0, 0xd3, 0x57, 0x29}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 13897; + uint8_t client_id_bytes[] = {0xe9, 0x81, 0x20}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xcd, 0x21, 0xa4, 0x71, 0x3b, 0x95, 0x7c, 0x8c, 0xef, 0x7c, 0xea, 0x1c, 0x4}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x42, 0x45, 0xb, 0x2a, 0x55, 0x19, 0x27, 0x9f, 0x9d, 0x16, 0x6d, 0x10, 0x6e, 0xc0, 0x88, + 0xb, 0x53, 0x22, 0xf4, 0x0, 0x39, 0xe4, 0x27, 0xc3, 0x8b, 0x4, 0xc5, 0xc8, 0xc2}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// "B\186\246\255t\DC3^!\193Sq\185HB\196\232\246Y>p\ACK\187k\ETBu\142", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS1, _willTopic = "I;]\195\205\\\220z\EOT0:<'\ENQ\194D@1\238|", _willMsg = "`!\186\212fPy", _willProps = +// []}), _cleanSession = True, _keepAlive = 20788, _connID = +// "\155\US\157x\133\ESC,7_b\139\135\244\157VC<]\149\152\201\134x:\148\220\243T\\.", _password = +// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// ";\161U\195\&6\138\177I\129\195\USA\DC3", _willMsg = "I\DC1\210\DC3\FS\DC3\242\138\171\211\203\b\190", _willProps = +// []}), _cleanSession = True, _keepAlive = 22371, _connID = "\165\EM\181\CAN)62", _properties = []} +TEST(Connect311QCTest, Encode28) { + uint8_t pkt[] = {0x10, 0x51, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x86, 0x57, 0x63, 0x0, 0x7, 0xa5, 0x19, 0xb5, + 0x18, 0x29, 0x36, 0x32, 0x0, 0xd, 0x3b, 0xa1, 0x55, 0xc3, 0x36, 0x8a, 0xb1, 0x49, 0x81, 0xc3, 0x1f, + 0x41, 0x13, 0x0, 0xd, 0x49, 0x11, 0xd2, 0x13, 0x1c, 0x13, 0xf2, 0x8a, 0xab, 0xd3, 0xcb, 0x8, 0xbe, + 0x0, 0x1e, 0x5, 0x41, 0x41, 0x45, 0x6, 0xae, 0x26, 0x80, 0xa1, 0x77, 0x6d, 0x23, 0x57, 0x3e, 0x56, + 0x43, 0x3c, 0x5d, 0x95, 0x98, 0xc9, 0x86, 0x78, 0x3a, 0x94, 0xdc, 0xf3, 0x54, 0x5c, 0x2e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x3b, 0xa1, 0x55, 0xc3, 0x36, 0x8a, 0xb1, 0x49, 0x81, 0xc3, 0x1f, 0x41, 0x13}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x49, 0x11, 0xd2, 0x13, 0x1c, 0x13, 0xf2, 0x8a, 0xab, 0xd3, 0xcb, 0x8, 0xbe}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 22371; + uint8_t client_id_bytes[] = {0xa5, 0x19, 0xb5, 0x18, 0x29, 0x36, 0x32}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x5, 0x41, 0x41, 0x45, 0x6, 0xae, 0x26, 0x80, 0xa1, 0x77, 0x6d, 0x23, 0x57, 0x3e, 0x56, + 0x43, 0x3c, 0x5d, 0x95, 0x98, 0xc9, 0x86, 0x78, 0x3a, 0x94, 0xdc, 0xf3, 0x54, 0x5c, 0x2e}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "OX\145\244\252\182\254\FS\130\252\134@\172\223\164\157{X}\165\146\152~f\219", _willMsg = +// "@\129Q\244!\183oR", _willProps = []}), _cleanSession = False, _keepAlive = 30518, _connID = +// "W\161E\137\235\171\156\EM\227`e^\234\242\248\227rj\195\139\NAK", _properties = []} +TEST(Connect311QCTest, Encode29) { + uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0x77, 0x36, 0x0, 0x15, 0x57, + 0xa1, 0x45, 0x89, 0xeb, 0xab, 0x9c, 0x19, 0xe3, 0x60, 0x65, 0x5e, 0xea, 0xf2, 0xf8, 0xe3, + 0x72, 0x6a, 0xc3, 0x8b, 0x15, 0x0, 0x19, 0x4f, 0x58, 0x91, 0xf4, 0xfc, 0xb6, 0xfe, 0x1c, + 0x82, 0xfc, 0x86, 0x40, 0xac, 0xdf, 0xa4, 0x9d, 0x7b, 0x58, 0x7d, 0xa5, 0x92, 0x98, 0x7e, + 0x66, 0xdb, 0x0, 0x8, 0x40, 0x81, 0x51, 0xf4, 0x21, 0xb7, 0x6f, 0x52}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4f, 0x58, 0x91, 0xf4, 0xfc, 0xb6, 0xfe, 0x1c, 0x82, 0xfc, 0x86, 0x40, 0xac, + 0xdf, 0xa4, 0x9d, 0x7b, 0x58, 0x7d, 0xa5, 0x92, 0x98, 0x7e, 0x66, 0xdb}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x40, 0x81, 0x51, 0xf4, 0x21, 0xb7, 0x6f, 0x52}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 30518; + uint8_t client_id_bytes[] = {0x57, 0xa1, 0x45, 0x89, 0xeb, 0xab, 0x9c, 0x19, 0xe3, 0x60, 0x65, + 0x5e, 0xea, 0xf2, 0xf8, 0xe3, 0x72, 0x6a, 0xc3, 0x8b, 0x15}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "\233\DLEuz,\235\221\183\245C\171\219\241^\213\168\160\167\181<\210\175\201\225\241\132\251\229e\164", _password = +// Just "\240\180X}9\198\t\SUBK\211\ACK\179t\255\237\148 no\DC3\203\&3;\198", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS2, _willTopic = +// "\157\167S\173)\208\193\243\142\STX?\244\199<\DC3\202VL\215\218\215\162\174~\167G1\t\196)", _willMsg = "", _willProps +// = []}), _cleanSession = False, _keepAlive = 26007, _connID = "N\237\211", _properties = []} +TEST(Connect311QCTest, Encode30) { + uint8_t pkt[] = {0x10, 0x6b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x65, 0x97, 0x0, 0x3, 0x4e, 0xed, + 0xd3, 0x0, 0x1e, 0x9d, 0xa7, 0x53, 0xad, 0x29, 0xd0, 0xc1, 0xf3, 0x8e, 0x2, 0x3f, 0xf4, 0xc7, + 0x3c, 0x13, 0xca, 0x56, 0x4c, 0xd7, 0xda, 0xd7, 0xa2, 0xae, 0x7e, 0xa7, 0x47, 0x31, 0x9, 0xc4, + 0x29, 0x0, 0x0, 0x0, 0x1e, 0xe9, 0x10, 0x75, 0x7a, 0x2c, 0xeb, 0xdd, 0xb7, 0xf5, 0x43, 0xab, + 0xdb, 0xf1, 0x5e, 0xd5, 0xa8, 0xa0, 0xa7, 0xb5, 0x3c, 0xd2, 0xaf, 0xc9, 0xe1, 0xf1, 0x84, 0xfb, + 0xe5, 0x65, 0xa4, 0x0, 0x18, 0xf0, 0xb4, 0x58, 0x7d, 0x39, 0xc6, 0x9, 0x1a, 0x4b, 0xd3, 0x6, + 0xb3, 0x74, 0xff, 0xed, 0x94, 0x20, 0x6e, 0x6f, 0x13, 0xcb, 0x33, 0x3b, 0xc6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9d, 0xa7, 0x53, 0xad, 0x29, 0xd0, 0xc1, 0xf3, 0x8e, 0x2, + 0x3f, 0xf4, 0xc7, 0x3c, 0x13, 0xca, 0x56, 0x4c, 0xd7, 0xda, + 0xd7, 0xa2, 0xae, 0x7e, 0xa7, 0x47, 0x31, 0x9, 0xc4, 0x29}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 26007; + uint8_t client_id_bytes[] = {0x4e, 0xed, 0xd3}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xe9, 0x10, 0x75, 0x7a, 0x2c, 0xeb, 0xdd, 0xb7, 0xf5, 0x43, 0xab, 0xdb, 0xf1, 0x5e, 0xd5, + 0xa8, 0xa0, 0xa7, 0xb5, 0x3c, 0xd2, 0xaf, 0xc9, 0xe1, 0xf1, 0x84, 0xfb, 0xe5, 0x65, 0xa4}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf0, 0xb4, 0x58, 0x7d, 0x39, 0xc6, 0x9, 0x1a, 0x4b, 0xd3, 0x6, 0xb3, + 0x74, 0xff, 0xed, 0x94, 0x20, 0x6e, 0x6f, 0x13, 0xcb, 0x33, 0x3b, 0xc6}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "\STXF\139\182d\236&\232\&0\220\246\150\CAN\210\147K\245O\160W*D\145\202", _willMsg = +// "\255\138T\159\195[tN\169\244\200*\226/\ENQ\238\251\DC3", _willProps = [PropSessionExpiryInterval +// 12196,PropMessageExpiryInterval 25354,PropRequestResponseInformation 86,PropRetainAvailable +// 155,PropWildcardSubscriptionAvailable 202,PropMessageExpiryInterval 18349,PropResponseTopic +// "_\190#\130\SOH\138\181?\247H\172m~+(L\232",PropServerKeepAlive 22997,PropContentType +// "\189\233\205{d\138\230\239\207",PropAuthenticationData "",PropCorrelationData +// "\ETX\189f\190x\DLE\235\253u\175f\239.z\215\178P\150\183?\194#\192.-S\175Z",PropResponseTopic "\ESC"]}), +// _cleanSession = True, _keepAlive = 23007, _connID = "\172\233\209\170i\141", _properties = +// [PropPayloadFormatIndicator 1]} +TEST(Connect5QCTest, Encode1) { + uint8_t pkt[] = {0x10, 0xa2, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x59, 0xdf, 0x2, 0x1, 0x1, 0x0, + 0x6, 0xac, 0xe9, 0xd1, 0xaa, 0x69, 0x8d, 0x5e, 0x11, 0x0, 0x0, 0x2f, 0xa4, 0x2, 0x0, 0x0, 0x63, + 0xa, 0x19, 0x56, 0x25, 0x9b, 0x28, 0xca, 0x2, 0x0, 0x0, 0x47, 0xad, 0x8, 0x0, 0x11, 0x5f, 0xbe, + 0x23, 0x82, 0x1, 0x8a, 0xb5, 0x3f, 0xf7, 0x48, 0xac, 0x6d, 0x7e, 0x2b, 0x28, 0x4c, 0xe8, 0x13, 0x59, + 0xd5, 0x3, 0x0, 0x9, 0xbd, 0xe9, 0xcd, 0x7b, 0x64, 0x8a, 0xe6, 0xef, 0xcf, 0x16, 0x0, 0x0, 0x9, + 0x0, 0x1c, 0x3, 0xbd, 0x66, 0xbe, 0x78, 0x10, 0xeb, 0xfd, 0x75, 0xaf, 0x66, 0xef, 0x2e, 0x7a, 0xd7, + 0xb2, 0x50, 0x96, 0xb7, 0x3f, 0xc2, 0x23, 0xc0, 0x2e, 0x2d, 0x53, 0xaf, 0x5a, 0x8, 0x0, 0x1, 0x1b, + 0x0, 0x18, 0x2, 0x46, 0x8b, 0xb6, 0x64, 0xec, 0x26, 0xe8, 0x30, 0xdc, 0xf6, 0x96, 0x18, 0xd2, 0x93, + 0x4b, 0xf5, 0x4f, 0xa0, 0x57, 0x2a, 0x44, 0x91, 0xca, 0x0, 0x12, 0xff, 0x8a, 0x54, 0x9f, 0xc3, 0x5b, + 0x74, 0x4e, 0xa9, 0xf4, 0xc8, 0x2a, 0xe2, 0x2f, 0x5, 0xee, 0xfb, 0x13}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 1}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x5f, 0xbe, 0x23, 0x82, 0x1, 0x8a, 0xb5, 0x3f, 0xf7, + 0x48, 0xac, 0x6d, 0x7e, 0x2b, 0x28, 0x4c, 0xe8}; + uint8_t byteswillprops1[] = {0xbd, 0xe9, 0xcd, 0x7b, 0x64, 0x8a, 0xe6, 0xef, 0xcf}; + uint8_t byteswillprops2[] = {0}; + uint8_t byteswillprops3[] = {0x3, 0xbd, 0x66, 0xbe, 0x78, 0x10, 0xeb, 0xfd, 0x75, 0xaf, 0x66, 0xef, 0x2e, 0x7a, + 0xd7, 0xb2, 0x50, 0x96, 0xb7, 0x3f, 0xc2, 0x23, 0xc0, 0x2e, 0x2d, 0x53, 0xaf, 0x5a}; + uint8_t byteswillprops4[] = {0x1b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12196}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25354}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18349}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22997}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops4}}}, + }; + + lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2, 0x46, 0x8b, 0xb6, 0x64, 0xec, 0x26, 0xe8, 0x30, 0xdc, 0xf6, 0x96, + 0x18, 0xd2, 0x93, 0x4b, 0xf5, 0x4f, 0xa0, 0x57, 0x2a, 0x44, 0x91, 0xca}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xff, 0x8a, 0x54, 0x9f, 0xc3, 0x5b, 0x74, 0x4e, 0xa9, + 0xf4, 0xc8, 0x2a, 0xe2, 0x2f, 0x5, 0xee, 0xfb, 0x13}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23007; + uint8_t client_id_bytes[] = {0xac, 0xe9, 0xd1, 0xaa, 0x69, 0x8d}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\162\167;\233}\166*\194\SO5I", _password = Just +// "\206\SYN\252];b\f|\249\239\199!!\ETB\142fz\153\250>bv\DC1\ETX\134", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS1, _willTopic = "\DELF\240\209\&7W\203U~\ETBsd", _willMsg = "\146\191]\f|", _willProps = +// [PropResponseInformation "\r\f}~KATl\198M\RS.\204{\159",PropSessionExpiryInterval 25708,PropWillDelayInterval +// 17400,PropWillDelayInterval 9074,PropRequestProblemInformation 12,PropCorrelationData +// "ol\232jq`\145\138\242\162\147!\RSv\186",PropAuthenticationData "",PropMessageExpiryInterval 20784,PropUserProperty +// "\206?\SO\apG\213\229\214\155\a(\193\DEL\201\247\250\193\GSuVi\238\143x\178p" +// "\230\&1Q]\EOT5\219:\187Pk\247Maq\135\135\DLE\SYN\204",PropSubscriptionIdentifier 20,PropRequestResponseInformation +// 185,PropCorrelationData "T\147Q\177\191LL @\ESC1\SUB-K\154EI\218\SOH\171\227\160 \161\226",PropReasonString +// "\196\187G\239\175\202\139"]}), _cleanSession = True, _keepAlive = 7161, _connID = +// "AG\180\214\&5\245\a\196\164Fq\209\141\250>\246\RS", _properties = [PropMessageExpiryInterval +// 22623,PropWildcardSubscriptionAvailable 116,PropPayloadFormatIndicator 197,PropRetainAvailable +// 197,PropTopicAliasMaximum 15093,PropResponseTopic +// "\EOT$~\SO\186\t\152\162\237\149\&5\RS\178\131\135Va\211#+\185@\176?\186",PropReceiveMaximum 8870,PropRetainAvailable +// 250,PropWildcardSubscriptionAvailable 67,PropAuthenticationMethod "\169\239\RS\220",PropWillDelayInterval +// 6620,PropResponseInformation +// "\178\220E\ACK\196\DC4^\199=\251)]z\254M\254X\v\155d",PropSubscriptionIdentifierAvailable 152,PropTopicAliasMaximum +// 8982,PropAuthenticationMethod +// "L\226eG\159\233\153!\192p\234\&5\182\145\219h\171\"8\234fE$\225",PropPayloadFormatIndicator +// 10,PropSharedSubscriptionAvailable 82,PropUserProperty "\188\145\164" "\168\227\143z1\173",PropSubscriptionIdentifier +// 26,PropResponseTopic "\213x",PropResponseTopic "\230\145~\158\144\EM\175\129@\249",PropServerReference +// "\v\165+\ETX\DC3\161=\t5&]\181\148",PropRequestProblemInformation 160,PropResponseInformation +// "\213s\220\ENQ{DSet\243=w\218*\SOH\DC3\245\164\SYN\193q\DC4\133",PropAuthenticationData +// "\SUB\200\165\247\231\188\193\251\226\187\231\137\SO{\142x&u\183Z\235\177xkB\159",PropTopicAliasMaximum +// 27750,PropMaximumPacketSize 15510]} +TEST(Connect5QCTest, Encode2) { + uint8_t pkt[] = { + 0x10, 0xe4, 0x3, 0x0, 0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, 0x87, + 0x87, 0x10, 0x16, 0xcc, 0xb, 0x14, 0x19, 0xb9, 0x9, 0x0, 0x19, 0x54, 0x93, 0x51, 0xb1, 0xbf, 0x4c, 0x4c, 0x20, + 0x40, 0x1b, 0x31, 0x1a, 0x2d, 0x4b, 0x9a, 0x45, 0x49, 0xda, 0x1, 0xab, 0xe3, 0xa0, 0x20, 0xa1, 0xe2, 0x1f, 0x0, + 0x7, 0xc4, 0xbb, 0x47, 0xef, 0xaf, 0xca, 0x8b, 0x0, 0xc, 0x7f, 0x46, 0xf0, 0xd1, 0x37, 0x57, 0xcb, 0x55, 0x7e, + 0x17, 0x73, 0x64, 0x0, 0x5, 0x92, 0xbf, 0x5d, 0xc, 0x7c, 0x0, 0xb, 0xa2, 0xa7, 0x3b, 0xe9, 0x7d, 0xa6, 0x2a, + 0xc2, 0xe, 0x35, 0x49, 0x0, 0x19, 0xce, 0x16, 0xfc, 0x5d, 0x3b, 0x62, 0xc, 0x7c, 0xf9, 0xef, 0xc7, 0x21, 0x21, + 0x17, 0x8e, 0x66, 0x7a, 0x99, 0xfa, 0x3e, 0x62, 0x76, 0x11, 0x3, 0x86}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x4, 0x24, 0x7e, 0xe, 0xba, 0x9, 0x98, 0xa2, 0xed, 0x95, 0x35, 0x1e, 0xb2, + 0x83, 0x87, 0x56, 0x61, 0xd3, 0x23, 0x2b, 0xb9, 0x40, 0xb0, 0x3f, 0xba}; + uint8_t bytesprops1[] = {0xa9, 0xef, 0x1e, 0xdc}; + uint8_t bytesprops2[] = {0xb2, 0xdc, 0x45, 0x6, 0xc4, 0x14, 0x5e, 0xc7, 0x3d, 0xfb, + 0x29, 0x5d, 0x7a, 0xfe, 0x4d, 0xfe, 0x58, 0xb, 0x9b, 0x64}; + uint8_t bytesprops3[] = {0x4c, 0xe2, 0x65, 0x47, 0x9f, 0xe9, 0x99, 0x21, 0xc0, 0x70, 0xea, 0x35, + 0xb6, 0x91, 0xdb, 0x68, 0xab, 0x22, 0x38, 0xea, 0x66, 0x45, 0x24, 0xe1}; + uint8_t bytesprops5[] = {0xa8, 0xe3, 0x8f, 0x7a, 0x31, 0xad}; + uint8_t bytesprops4[] = {0xbc, 0x91, 0xa4}; + uint8_t bytesprops6[] = {0xd5, 0x78}; + uint8_t bytesprops7[] = {0xe6, 0x91, 0x7e, 0x9e, 0x90, 0x19, 0xaf, 0x81, 0x40, 0xf9}; + uint8_t bytesprops8[] = {0xb, 0xa5, 0x2b, 0x3, 0x13, 0xa1, 0x3d, 0x9, 0x35, 0x26, 0x5d, 0xb5, 0x94}; + uint8_t bytesprops9[] = {0xd5, 0x73, 0xdc, 0x5, 0x7b, 0x44, 0x53, 0x65, 0x74, 0xf3, 0x3d, 0x77, + 0xda, 0x2a, 0x1, 0x13, 0xf5, 0xa4, 0x16, 0xc1, 0x71, 0x14, 0x85}; + uint8_t bytesprops10[] = {0x1a, 0xc8, 0xa5, 0xf7, 0xe7, 0xbc, 0xc1, 0xfb, 0xe2, 0xbb, 0xe7, 0x89, 0xe, + 0x7b, 0x8e, 0x78, 0x26, 0x75, 0xb7, 0x5a, 0xeb, 0xb1, 0x78, 0x6b, 0x42, 0x9f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22623}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15093}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8870}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6620}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8982}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops4}, .v = {6, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27750}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15510}}, + }; + + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xd, 0xc, 0x7d, 0x7e, 0x4b, 0x41, 0x54, 0x6c, 0xc6, 0x4d, 0x1e, 0x2e, 0xcc, 0x7b, 0x9f}; + uint8_t byteswillprops1[] = {0x6f, 0x6c, 0xe8, 0x6a, 0x71, 0x60, 0x91, 0x8a, + 0xf2, 0xa2, 0x93, 0x21, 0x1e, 0x76, 0xba}; + uint8_t byteswillprops2[] = {0}; + uint8_t byteswillprops4[] = {0xe6, 0x31, 0x51, 0x5d, 0x4, 0x35, 0xdb, 0x3a, 0xbb, 0x50, + 0x6b, 0xf7, 0x4d, 0x61, 0x71, 0x87, 0x87, 0x10, 0x16, 0xcc}; + uint8_t byteswillprops3[] = {0xce, 0x3f, 0xe, 0x7, 0x70, 0x47, 0xd5, 0xe5, 0xd6, 0x9b, 0x7, 0x28, 0xc1, 0x7f, + 0xc9, 0xf7, 0xfa, 0xc1, 0x1d, 0x75, 0x56, 0x69, 0xee, 0x8f, 0x78, 0xb2, 0x70}; + uint8_t byteswillprops5[] = {0x54, 0x93, 0x51, 0xb1, 0xbf, 0x4c, 0x4c, 0x20, 0x40, 0x1b, 0x31, 0x1a, 0x2d, + 0x4b, 0x9a, 0x45, 0x49, 0xda, 0x1, 0xab, 0xe3, 0xa0, 0x20, 0xa1, 0xe2}; + uint8_t byteswillprops6[] = {0xc4, 0xbb, 0x47, 0xef, 0xaf, 0xca, 0x8b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25708}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17400}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9074}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20784}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {27, (char*)&byteswillprops3}, .v = {20, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&byteswillprops6}}}, + }; + + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x7f, 0x46, 0xf0, 0xd1, 0x37, 0x57, 0xcb, 0x55, 0x7e, 0x17, 0x73, 0x64}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x92, 0xbf, 0x5d, 0xc, 0x7c}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 7161; + uint8_t client_id_bytes[] = {0x41, 0x47, 0xb4, 0xd6, 0x35, 0xf5, 0x7, 0xc4, 0xa4, + 0x46, 0x71, 0xd1, 0x8d, 0xfa, 0x3e, 0xf6, 0x1e}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa2, 0xa7, 0x3b, 0xe9, 0x7d, 0xa6, 0x2a, 0xc2, 0xe, 0x35, 0x49}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xce, 0x16, 0xfc, 0x5d, 0x3b, 0x62, 0xc, 0x7c, 0xf9, 0xef, 0xc7, 0x21, 0x21, + 0x17, 0x8e, 0x66, 0x7a, 0x99, 0xfa, 0x3e, 0x62, 0x76, 0x11, 0x3, 0x86}; + lwmqtt_string_t password = {25, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\176gX", _password = Nothing, _lastWill = Nothing, _cleanSession = False, +// _keepAlive = 30736, _connID = "\211\169\254\161\DLE", _properties = [PropSubscriptionIdentifier 28,PropContentType +// "av~m\140\233\EM\143\233\209\192\167\211",PropResponseTopic +// "\238\189\189T\191\133\200\153\142\214\241yDC",PropTopicAliasMaximum 10527]} +TEST(Connect5QCTest, Encode3) { + uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x80, 0x78, 0x10, 0x26, 0xb, 0x1c, 0x3, + 0x0, 0xd, 0x61, 0x76, 0x7e, 0x6d, 0x8c, 0xe9, 0x19, 0x8f, 0xe9, 0xd1, 0xc0, 0xa7, 0xd3, 0x8, + 0x0, 0xe, 0xee, 0xbd, 0xbd, 0x54, 0xbf, 0x85, 0xc8, 0x99, 0x8e, 0xd6, 0xf1, 0x79, 0x44, 0x43, + 0x22, 0x29, 0x1f, 0x0, 0x5, 0xd3, 0xa9, 0xfe, 0xa1, 0x10, 0x0, 0x3, 0xb0, 0x67, 0x58}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x61, 0x76, 0x7e, 0x6d, 0x8c, 0xe9, 0x19, 0x8f, 0xe9, 0xd1, 0xc0, 0xa7, 0xd3}; + uint8_t bytesprops1[] = {0xee, 0xbd, 0xbd, 0x54, 0xbf, 0x85, 0xc8, 0x99, 0x8e, 0xd6, 0xf1, 0x79, 0x44, 0x43}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10527}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 30736; + uint8_t client_id_bytes[] = {0xd3, 0xa9, 0xfe, 0xa1, 0x10}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xb0, 0x67, 0x58}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\152\194\245\253\174\&7\EMM!8\179\176,\247\240\DC1\231\RS", _password = Just +// "/\242\177\206\FS\170L\220\250@\fO\156+2\DLE\GS\141\&5\180!\168t\129\133\aA\SO\213T", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "r\EOTA\136\195\188\137\213\144A\186\189\243\169\226\204\252", +// _willMsg = "\182\NAK", _willProps = [PropWildcardSubscriptionAvailable 103,PropAssignedClientIdentifier +// "D\255\207a\239K\166\248\143r\181&\232\167\n9j\140\1677\180\215wX\245",PropReasonString "",PropMaximumPacketSize +// 10882,PropSubscriptionIdentifierAvailable 84,PropAuthenticationMethod +// "d'v\161\242\222\155\141\236\225\180H\247B",PropAssignedClientIdentifier "\ACK\147}^]IXY%\RS\DC2|d\140"]}), +// _cleanSession = True, _keepAlive = 10218, _connID = "\242\150&X\DC2\211\232+\139", _properties = [PropMaximumQoS +// 211,PropSessionExpiryInterval 6199,PropMaximumPacketSize 19431,PropMessageExpiryInterval +// 20624,PropRequestResponseInformation 50,PropTopicAlias 28881,PropContentType +// "\187dw\204\ACK\253\134",PropAuthenticationData "\ETB\204%\fG\182\186^U\238\232\&6\146",PropPayloadFormatIndicator +// 69,PropRetainAvailable 103,PropContentType "p\247\181Gq\222t\t",PropUserProperty "N\154\ak\147\184\186K\DEL\SOHX\GS2" +// "p'\FSsI\ENQCUvg5#\253\252\NUL\207\175J\171\SINc\b\179\198n\USa\186\"",PropServerReference +// "\171-(\161\245\EM?\233\140\228\133Xg?\151\DC4-}\225\&9\246",PropSessionExpiryInterval 21133,PropAuthenticationData +// "?\ETB\ESC\159\213\STX\US\255[\b\RS0'JB\248",PropServerReference +// "\143z\192\143\133\235:L\146x\228\221\182\180\ETX\190\r\188H\244",PropMessageExpiryInterval +// 2372,PropSubscriptionIdentifier 23]} +TEST(Connect5QCTest, Encode5) { + uint8_t pkt[] = { + 0x10, 0xcb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb6, 0x27, 0xea, 0xbd, 0x1, 0x24, 0xd3, 0x11, 0x0, + 0x0, 0x18, 0x37, 0x27, 0x0, 0x0, 0x4b, 0xe7, 0x2, 0x0, 0x0, 0x50, 0x90, 0x19, 0x32, 0x23, 0x70, 0xd1, 0x3, + 0x0, 0x7, 0xbb, 0x64, 0x77, 0xcc, 0x6, 0xfd, 0x86, 0x16, 0x0, 0xd, 0x17, 0xcc, 0x25, 0xc, 0x47, 0xb6, 0xba, + 0x5e, 0x55, 0xee, 0xe8, 0x36, 0x92, 0x1, 0x45, 0x25, 0x67, 0x3, 0x0, 0x8, 0x70, 0xf7, 0xb5, 0x47, 0x71, 0xde, + 0x74, 0x9, 0x26, 0x0, 0xd, 0x4e, 0x9a, 0x7, 0x6b, 0x93, 0xb8, 0xba, 0x4b, 0x7f, 0x1, 0x58, 0x1d, 0x32, 0x0, + 0x1e, 0x70, 0x27, 0x1c, 0x73, 0x49, 0x5, 0x43, 0x55, 0x76, 0x67, 0x35, 0x23, 0xfd, 0xfc, 0x0, 0xcf, 0xaf, 0x4a, + 0xab, 0xf, 0x4e, 0x63, 0x8, 0xb3, 0xc6, 0x6e, 0x1f, 0x61, 0xba, 0x22, 0x1c, 0x0, 0x15, 0xab, 0x2d, 0x28, 0xa1, + 0xf5, 0x19, 0x3f, 0xe9, 0x8c, 0xe4, 0x85, 0x58, 0x67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0x8, 0x99, 0xaf, 0x9a, 0xbe, 0x19, 0x5d, 0x11, 0x0, 0x0, 0x9, 0x1a, 0x22, 0x14, + 0xb5, 0x13, 0x27, 0xe1, 0x15, 0x0, 0x14, 0x5e, 0xda, 0x90, 0xdb, 0x9, 0xd2, 0x3c, 0x8e, 0xb, 0xf0, 0xc0, 0xcd, + 0x14, 0x3e, 0x37, 0xb4, 0xd7, 0x77, 0x58, 0xf5, 0x1f, 0x0, 0x0, 0x27, 0x0, 0x0, 0x2a, 0x82, 0x29, 0x54, 0x15, + 0x0, 0xe, 0x64, 0x27, 0x76, 0xa1, 0xf2, 0xde, 0x9b, 0x8d, 0xec, 0xe1, 0xb4, 0x48, 0xf7, 0x42, 0x12, 0x0, 0xe, + 0x6, 0x93, 0x7d, 0x5e, 0x5d, 0x49, 0x58, 0x59, 0x25, 0x1e, 0x12, 0x7c, 0x64, 0x8c, 0x0, 0x15, 0xd5, 0x85, 0xe7, + 0x1c, 0x82, 0x6, 0x45, 0xbf, 0xfa, 0x19, 0xa, 0x65, 0x49, 0x7, 0x8b, 0xf3, 0xe3, 0xd8, 0x4a, 0xde, 0xde, 0x0, + 0xe, 0xf7, 0xc7, 0x70, 0x7a, 0xbd, 0x9e, 0xa3, 0x72, 0x5b, 0x83, 0x50, 0xc9, 0x77, 0x85, 0x0, 0x8, 0x46, 0x6c, + 0xa5, 0xbf, 0x45, 0x84, 0x3a, 0xa1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbb, 0x64, 0x77, 0xcc, 0x6, 0xfd, 0x86}; + uint8_t bytesprops1[] = {0x17, 0xcc, 0x25, 0xc, 0x47, 0xb6, 0xba, 0x5e, 0x55, 0xee, 0xe8, 0x36, 0x92}; + uint8_t bytesprops2[] = {0x70, 0xf7, 0xb5, 0x47, 0x71, 0xde, 0x74, 0x9}; + uint8_t bytesprops4[] = {0x70, 0x27, 0x1c, 0x73, 0x49, 0x5, 0x43, 0x55, 0x76, 0x67, 0x35, 0x23, 0xfd, 0xfc, 0x0, + 0xcf, 0xaf, 0x4a, 0xab, 0xf, 0x4e, 0x63, 0x8, 0xb3, 0xc6, 0x6e, 0x1f, 0x61, 0xba, 0x22}; + uint8_t bytesprops3[] = {0x4e, 0x9a, 0x7, 0x6b, 0x93, 0xb8, 0xba, 0x4b, 0x7f, 0x1, 0x58, 0x1d, 0x32}; + uint8_t bytesprops5[] = {0xab, 0x2d, 0x28, 0xa1, 0xf5, 0x19, 0x3f, 0xe9, 0x8c, 0xe4, 0x85, + 0x58, 0x67, 0x3f, 0x97, 0x14, 0x2d, 0x7d, 0xe1, 0x39, 0xf6}; + uint8_t bytesprops6[] = {0x3f, 0x17, 0x1b, 0x9f, 0xd5, 0x2, 0x1f, 0xff, + 0x5b, 0x8, 0x1e, 0x30, 0x27, 0x4a, 0x42, 0xf8}; + uint8_t bytesprops7[] = {0x8f, 0x7a, 0xc0, 0x8f, 0x85, 0xeb, 0x3a, 0x4c, 0x92, 0x78, + 0xe4, 0xdd, 0xb6, 0xb4, 0x3, 0xbe, 0xd, 0xbc, 0x48, 0xf4}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6199}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19431}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20624}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28881}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops3}, .v = {30, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21133}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2372}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xfc, 0xda, 0x86, 0x25, 0x20, 0x70, 0x2e, 0x87, + 0xd5, 0xcd, 0xdf, 0x6f, 0xdf, 0xe6, 0xf8}; + uint8_t byteswillprops1[] = {0xfe, 0xe2, 0xe1, 0xa3, 0xb3, 0xb2, 0x9d, 0xf3, 0xa6, 0x47, 0x3f, + 0x86, 0x5e, 0xf3, 0xc3, 0x77, 0xd5, 0x8, 0xe6, 0x74, 0xae, 0xb9}; + uint8_t byteswillprops2[] = {0x6d, 0xe7, 0x40, 0x25, 0x2c, 0x79, 0xce, 0xaf}; + uint8_t byteswillprops3[] = {0x9f, 0xb6, 0x8b, 0x33, 0x80, 0x6a, 0x8e, 0x7d, 0x8, 0x99, 0xaf, 0x9a, 0xbe}; + uint8_t byteswillprops4[] = {0x5e, 0xda, 0x90, 0xdb, 0x9, 0xd2, 0x3c, 0x8e, 0xb, 0xf0, + 0xc0, 0xcd, 0x14, 0x3e, 0x37, 0xb4, 0xd7, 0x77, 0x58, 0xf5}; + uint8_t byteswillprops5[] = {0}; + uint8_t byteswillprops6[] = {0x64, 0x27, 0x76, 0xa1, 0xf2, 0xde, 0x9b, 0x8d, 0xec, 0xe1, 0xb4, 0x48, 0xf7, 0x42}; + uint8_t byteswillprops7[] = {0x6, 0x93, 0x7d, 0x5e, 0x5d, 0x49, 0x58, 0x59, 0x25, 0x1e, 0x12, 0x7c, 0x64, 0x8c}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3225}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17734}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29099}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20232}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18654}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10509}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24719}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13466}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2330}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5301}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10209}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10882}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops7}}}, + }; + + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd5, 0x85, 0xe7, 0x1c, 0x82, 0x6, 0x45, 0xbf, 0xfa, 0x19, 0xa, + 0x65, 0x49, 0x7, 0x8b, 0xf3, 0xe3, 0xd8, 0x4a, 0xde, 0xde}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf7, 0xc7, 0x70, 0x7a, 0xbd, 0x9e, 0xa3, 0x72, 0x5b, 0x83, 0x50, 0xc9, 0x77, 0x85}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 10218; + uint8_t client_id_bytes[] = {0xf2, 0x96, 0x26, 0x58, 0x12, 0xd3, 0xe8, 0x2b, 0x8b}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x46, 0x6c, 0xa5, 0xbf, 0x45, 0x84, 0x3a, 0xa1}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Sz8i\155\185\247\FSM\223\r`\"\187\ACK\244\ETB7(\218^\ETX~\231o+\166\\", _password = +// Just "\254", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "\178\171\DC2\211\200\EM\184\SOH\SI1\182\142\236\165\201\180\217\179\236y\215\n", _willMsg = +// "\176\DC3\142\CAN5\229j\140\194\241\152", _willProps = [PropRequestProblemInformation 131,PropMaximumQoS +// 5,PropSessionExpiryInterval 25356,PropRequestProblemInformation 220,PropAssignedClientIdentifier +// "\247N:\229H>\180",PropAuthenticationData +// "\222\&4P\205\194<\166\217*\151\250\154\160J\212\220l\ETBc\142",PropServerReference +// "\SOH.%\177\191E$I\222\247m\147\230\186G\218\&4T\219C\221\242\&0\bX\217\ESC{",PropContentType +// "\197,\NAK\140\CAN\192\181\233\243\&3\EOTFs\190\185\255\152\232\ETB\DC1Mq\169\DEL",PropReasonString +// "\f\239}\153Tp`+\CANn\187\197s\245\CAN\246\151",PropUserProperty "\167-4\244" +// "\NULY\201\143\168x\214\198\142?\203$\159\137\210\&5)",PropRequestResponseInformation 39,PropUserProperty "s" +// "v\198\128\215\&1-9_\167\&8\129\\\250\220\STX\212;\215\228d",PropPayloadFormatIndicator 12,PropResponseInformation +// "Be\171\151\238\232\167#YV\133HcN\199\190\234J\166\176\167B+Y\v:",PropCorrelationData +// "5\157\228cG\224\152",PropServerKeepAlive 31492,PropTopicAlias 13537,PropRequestResponseInformation +// 163,PropAuthenticationData "S9L\176\223\EOTR\249.'C\188}",PropMaximumPacketSize 29119,PropAuthenticationData +// "\171{\DC3\240\194L\167\199\180\CANW\SYN\187\&2\173D\STX7\190\240!Cr\205\188\181\200_.\SO",PropUserProperty +// "x$QG\NAK\234\246\242\&2]\179a\235\216" "\225\144p\163cy\134\187>4\191 +// \143\ESC\215[#\246\166\154\ETXx|29l",PropRequestResponseInformation 126]}), _cleanSession = True, _keepAlive = 13826, +// _connID = "eYUoE\DELM\180&\227\132\v\STX\ESC\198\183?\245\247n\197\DC1", _properties = [PropMessageExpiryInterval +// 32766,PropSharedSubscriptionAvailable 26,PropTopicAlias 12471,PropSubscriptionIdentifierAvailable 210,PropContentType +// "\171wd\141\154h\DEL\215a\191i\b\235\SOt\169)\191",PropUserProperty "\176\SO\245" +// "\139\ACK\136\148\&9\138\&5\237\132\ETB1!!\193\SUBN`\145]",PropAuthenticationMethod +// "\181\166\205}\200\176?\210-\207\220v?X\212gX\187\&8\162",PropSharedSubscriptionAvailable +// 75,PropRequestProblemInformation 208,PropRequestProblemInformation 25,PropWillDelayInterval +// 27174,PropWildcardSubscriptionAvailable 127,PropPayloadFormatIndicator 5,PropAssignedClientIdentifier +// "/\SOHl\254\189\222\198x\219\180\188",PropRequestProblemInformation 198,PropReasonString +// "\240\nb\151\142\130\224ZbwA\SYN\1895\189\225\SO\175^\234s\EOT\183t\142\174\141*\161",PropMaximumQoS +// 133,PropMessageExpiryInterval 23894,PropRequestResponseInformation 67,PropReceiveMaximum 24058,PropContentType +// "\NAKYr\SYN",PropMaximumPacketSize 27205]} +TEST(Connect5QCTest, Encode7) { + uint8_t pkt[] = {0x10, 0x6d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x6e, 0x31, 0x50, 0x24, 0xf, 0x1f, + 0x0, 0x12, 0x7c, 0x75, 0x2a, 0x6d, 0xb2, 0xca, 0x7c, 0x9, 0x77, 0x68, 0x6c, 0xc4, 0xca, 0xf1, + 0x56, 0xe8, 0x39, 0x9d, 0x1f, 0x0, 0xa, 0x98, 0xa3, 0x31, 0x23, 0x7b, 0xb1, 0x7b, 0x42, 0x64, + 0x3c, 0x15, 0x0, 0x11, 0x3e, 0x35, 0xbd, 0xe1, 0xe, 0xaf, 0x5e, 0xea, 0x73, 0x4, 0xb7, 0x74, + 0x8e, 0xae, 0x8d, 0x2a, 0xa1, 0x24, 0x85, 0x2, 0x0, 0x0, 0x5d, 0x56, 0x19, 0x43, 0x21, 0x5d, + 0xfa, 0x3, 0x0, 0x4, 0x15, 0x59, 0x72, 0x16, 0x27, 0x0, 0x0, 0x6a, 0x45, 0x0, 0x10, 0xf6, + 0xa5, 0xf, 0x8e, 0x7a, 0xa3, 0xd9, 0xe0, 0x3b, 0xaa, 0x11, 0x91, 0xa1, 0x76, 0xd3, 0x65}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7c, 0x75, 0x2a, 0x6d, 0xb2, 0xca, 0x7c, 0x9, 0x77, + 0x68, 0x6c, 0xc4, 0xca, 0xf1, 0x56, 0xe8, 0x39, 0x9d}; + uint8_t bytesprops1[] = {0x98, 0xa3, 0x31, 0x23, 0x7b, 0xb1, 0x7b, 0x42, 0x64, 0x3c}; + uint8_t bytesprops2[] = {0x3e, 0x35, 0xbd, 0xe1, 0xe, 0xaf, 0x5e, 0xea, 0x73, + 0x4, 0xb7, 0x74, 0x8e, 0xae, 0x8d, 0x2a, 0xa1}; + uint8_t bytesprops3[] = {0x15, 0x59, 0x72, 0x16}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23894}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24058}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27205}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 28209; + uint8_t client_id_bytes[] = {0xf6, 0xa5, 0xf, 0x8e, 0x7a, 0xa3, 0xd9, 0xe0, + 0x3b, 0xaa, 0x11, 0x91, 0xa1, 0x76, 0xd3, 0x65}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\EOTj\208\234\&8&{\198\226R\a\248\140\138", _password = Just +// "]TT\227$0q<\DLE\201/\223\204\&4.\225\146v\209\240\154\SI\189O,\183\237", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS2, _willTopic = "\145\172\175\249\r\146", _willMsg = "\227:\v\SYNN\201\f", _willProps = +// [PropResponseTopic "X\152 <\n\135^\171\171;\nE",PropSessionExpiryInterval 22075,PropMessageExpiryInterval +// 4010,PropReceiveMaximum 25879,PropResponseTopic +// "n\239<\215q\137\138F\DC3\226z\194\CAN\230s]\198D\214",PropMessageExpiryInterval 10253,PropMaximumPacketSize +// 10461,PropAuthenticationMethod "\250|)\251Ae~\130/N\151\147\173",PropMessageExpiryInterval 20087,PropServerReference +// "\163\GSc\212\254\149\180Q\235I/\135`\143'\185\&7\233reH\252D\139\&5\203_\SYN",PropResponseInformation +// "v\DC4\STX\232\190\222\186O2",PropPayloadFormatIndicator 208,PropWildcardSubscriptionAvailable +// 125,PropSharedSubscriptionAvailable 127,PropUserProperty "N<\EM\170\156\227:\192\176" +// "u\157\229\222\SUB\255\DLE\174+|\182\228\226\143\248\250\156\240"]}), _cleanSession = False, _keepAlive = 12527, +// _connID = "7\EOT\224", _properties = [PropUserProperty "4\235z\197V\183\140{\249\DLE" "a\132\191R\144",PropTopicAlias +// 12939,PropRequestProblemInformation 86,PropWillDelayInterval 20660,PropSubscriptionIdentifierAvailable +// 84,PropRequestProblemInformation 66,PropReasonString +// "\210\225\186\225\241\GS\134\249\141F\239\DC3\246\&1",PropSubscriptionIdentifier 18,PropContentType +// "`\136\253\244\253\208\150\212\162vz}\177\&0#\132",PropPayloadFormatIndicator 80,PropRequestProblemInformation +// 43,PropCorrelationData "\193\177\210\217",PropWildcardSubscriptionAvailable 172,PropCorrelationData +// "5\f",PropWildcardSubscriptionAvailable 127,PropRequestProblemInformation 224,PropPayloadFormatIndicator +// 232,PropReasonString "\189x:\ETX>\176\239\SOa\167V\STX\147\SOH)\139",PropSharedSubscriptionAvailable 157]} +TEST(Connect5QCTest, Encode8) { + uint8_t pkt[] = { + 0x10, 0xe7, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x30, 0xef, 0x75, 0x26, 0x0, 0xa, 0x34, 0xeb, + 0x7a, 0xc5, 0x56, 0xb7, 0x8c, 0x7b, 0xf9, 0x10, 0x0, 0x5, 0x61, 0x84, 0xbf, 0x52, 0x90, 0x23, 0x32, 0x8b, 0x17, + 0x56, 0x18, 0x0, 0x0, 0x50, 0xb4, 0x29, 0x54, 0x17, 0x42, 0x1f, 0x0, 0xe, 0xd2, 0xe1, 0xba, 0xe1, 0xf1, 0x1d, + 0x86, 0xf9, 0x8d, 0x46, 0xef, 0x13, 0xf6, 0x31, 0xb, 0x12, 0x3, 0x0, 0x10, 0x60, 0x88, 0xfd, 0xf4, 0xfd, 0xd0, + 0x96, 0xd4, 0xa2, 0x76, 0x7a, 0x7d, 0xb1, 0x30, 0x23, 0x84, 0x1, 0x50, 0x17, 0x2b, 0x9, 0x0, 0x4, 0xc1, 0xb1, + 0xd2, 0xd9, 0x28, 0xac, 0x9, 0x0, 0x2, 0x35, 0xc, 0x28, 0x7f, 0x17, 0xe0, 0x1, 0xe8, 0x1f, 0x0, 0x10, 0xbd, + 0x78, 0x3a, 0x3, 0x3e, 0xb0, 0xef, 0xe, 0x61, 0xa7, 0x56, 0x2, 0x93, 0x1, 0x29, 0x8b, 0x2a, 0x9d, 0x0, 0x3, + 0x37, 0x4, 0xe0, 0xa2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0x26, 0x7b, 0xc6, 0xe2, 0x52, 0x7, 0xf8, 0x8c, 0x8a, 0x0, 0x1b, 0x5d, 0x54, 0x54, 0xe3, 0x24, 0x30, 0x71, + 0x3c, 0x10, 0xc9, 0x2f, 0xdf, 0xcc, 0x34, 0x2e, 0xe1, 0x92, 0x76, 0xd1, 0xf0, 0x9a, 0xf, 0xbd, 0x4f, 0x2c, 0xb7, + 0xed}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x61, 0x84, 0xbf, 0x52, 0x90}; + uint8_t bytesprops0[] = {0x34, 0xeb, 0x7a, 0xc5, 0x56, 0xb7, 0x8c, 0x7b, 0xf9, 0x10}; + uint8_t bytesprops2[] = {0xd2, 0xe1, 0xba, 0xe1, 0xf1, 0x1d, 0x86, 0xf9, 0x8d, 0x46, 0xef, 0x13, 0xf6, 0x31}; + uint8_t bytesprops3[] = {0x60, 0x88, 0xfd, 0xf4, 0xfd, 0xd0, 0x96, 0xd4, + 0xa2, 0x76, 0x7a, 0x7d, 0xb1, 0x30, 0x23, 0x84}; + uint8_t bytesprops4[] = {0xc1, 0xb1, 0xd2, 0xd9}; + uint8_t bytesprops5[] = {0x35, 0xc}; + uint8_t bytesprops6[] = {0xbd, 0x78, 0x3a, 0x3, 0x3e, 0xb0, 0xef, 0xe, 0x61, 0xa7, 0x56, 0x2, 0x93, 0x1, 0x29, 0x8b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {5, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12939}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20660}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 157}}, + }; + + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x58, 0x98, 0x20, 0x3c, 0xa, 0x87, 0x5e, 0xab, 0xab, 0x3b, 0xa, 0x45}; + uint8_t byteswillprops1[] = {0x6e, 0xef, 0x3c, 0xd7, 0x71, 0x89, 0x8a, 0x46, 0x13, 0xe2, + 0x7a, 0xc2, 0x18, 0xe6, 0x73, 0x5d, 0xc6, 0x44, 0xd6}; + uint8_t byteswillprops2[] = {0xfa, 0x7c, 0x29, 0xfb, 0x41, 0x65, 0x7e, 0x82, 0x2f, 0x4e, 0x97, 0x93, 0xad}; + uint8_t byteswillprops3[] = {0xa3, 0x1d, 0x63, 0xd4, 0xfe, 0x95, 0xb4, 0x51, 0xeb, 0x49, 0x2f, 0x87, 0x60, 0x8f, + 0x27, 0xb9, 0x37, 0xe9, 0x72, 0x65, 0x48, 0xfc, 0x44, 0x8b, 0x35, 0xcb, 0x5f, 0x16}; + uint8_t byteswillprops4[] = {0x76, 0x14, 0x2, 0xe8, 0xbe, 0xde, 0xba, 0x4f, 0x32}; + uint8_t byteswillprops6[] = {0x75, 0x9d, 0xe5, 0xde, 0x1a, 0xff, 0x10, 0xae, 0x2b, + 0x7c, 0xb6, 0xe4, 0xe2, 0x8f, 0xf8, 0xfa, 0x9c, 0xf0}; + uint8_t byteswillprops5[] = {0x4e, 0x3c, 0x19, 0xaa, 0x9c, 0xe3, 0x3a, 0xc0, 0xb0}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22075}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4010}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25879}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10253}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10461}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20087}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {9, (char*)&byteswillprops5}, .v = {18, (char*)&byteswillprops6}}}}, + }; + + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x91, 0xac, 0xaf, 0xf9, 0xd, 0x92}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe3, 0x3a, 0xb, 0x16, 0x4e, 0xc9, 0xc}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 12527; + uint8_t client_id_bytes[] = {0x37, 0x4, 0xe0}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x4, 0x6a, 0xd0, 0xea, 0x38, 0x26, 0x7b, 0xc6, 0xe2, 0x52, 0x7, 0xf8, 0x8c, 0x8a}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x5d, 0x54, 0x54, 0xe3, 0x24, 0x30, 0x71, 0x3c, 0x10, 0xc9, 0x2f, 0xdf, 0xcc, 0x34, + 0x2e, 0xe1, 0x92, 0x76, 0xd1, 0xf0, 0x9a, 0xf, 0xbd, 0x4f, 0x2c, 0xb7, 0xed}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\205!\164q;\149|\140\239|\234\FS\EOT", _password = Just +// "BE\v*U\EM'\159\157\SYNm\DLEn\192\136\vS\"\244\NUL9\228'\195\139\EOT\197\200\194", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "H", _willMsg = +// "\225\198\150\163\208W\238\146\FS\223_\201\251%\143\NUL\243\162\225ll\147\157Z\237\208\211W)", _willProps = +// [PropPayloadFormatIndicator 75,PropMessageExpiryInterval 10264,PropSessionExpiryInterval 20012,PropAuthenticationData +// "\198yy\237\252\180;\255%\236Q@\162\220\137",PropUserProperty "M%\161\219\DLES-\187\159\253Ek{\171d" +// "\178^R\250s\208M\207p\181",PropCorrelationData +// "2\143@\230Bz\186Bq\ACK\217\DC3\204\209\170p\f<\231]\212\249P\132\203\221\209Y",PropReceiveMaximum +// 24923,PropPayloadFormatIndicator 212,PropSubscriptionIdentifier 2,PropRequestProblemInformation 125,PropContentType +// "\DC4B\191\182\244\"",PropResponseInformation "O\166A\166@F\148\188@\136\228\160",PropSessionExpiryInterval +// 26416,PropMaximumQoS 146,PropCorrelationData "KJ\254\&6",PropMaximumQoS 108]}), _cleanSession = True, _keepAlive = +// 13897, _connID = "\233\129 ", _properties = [PropTopicAlias 21218,PropSessionExpiryInterval +// 25892,PropMessageExpiryInterval 14193,PropReceiveMaximum 4778,PropReceiveMaximum 20584,PropMaximumQoS +// 170,PropAuthenticationMethod "\165\183i\DLE\189\185\ETB\226\194\194W\191\ESC\184",PropContentType +// "\221Z]bNW\SO\179\US\189\&6\237%\240,%\169(\165\GSo\185\158\DELF\162\245\128",PropSessionExpiryInterval +// 12083,PropCorrelationData "\144Q\129C\194\SOH\146_\203v\ACK",PropMessageExpiryInterval 8095,PropServerReference +// ">\GS\206-\200\149\133\153\FS7|\213'W\229\v\150\242\&5\213L\231\179^\210\197\174",PropSharedSubscriptionAvailable +// 250,PropServerKeepAlive 22603,PropReasonString "\137\239\148D\243\130A\216",PropTopicAliasMaximum +// 17570,PropServerReference "A\243\199\228\241V",PropRetainAvailable 27,PropSubscriptionIdentifier +// 7,PropSubscriptionIdentifierAvailable 144,PropReceiveMaximum 22199,PropWillDelayInterval 25924,PropServerKeepAlive +// 20466,PropServerKeepAlive 19738,PropMessageExpiryInterval 23378,PropWildcardSubscriptionAvailable 159]} +TEST(Connect5QCTest, Encode9) { + uint8_t pkt[] = { + 0x10, 0xa1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x36, 0x49, 0xb2, 0x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c, 0x4, 0x0, 0x1d, 0x42, 0x45, 0xb, 0x2a, 0x55, 0x19, 0x27, 0x9f, + 0x9d, 0x16, 0x6d, 0x10, 0x6e, 0xc0, 0x88, 0xb, 0x53, 0x22, 0xf4, 0x0, 0x39, 0xe4, 0x27, 0xc3, 0x8b, 0x4, 0xc5, + 0xc8, 0xc2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa5, 0xb7, 0x69, 0x10, 0xbd, 0xb9, 0x17, 0xe2, 0xc2, 0xc2, 0x57, 0xbf, 0x1b, 0xb8}; + uint8_t bytesprops1[] = {0xdd, 0x5a, 0x5d, 0x62, 0x4e, 0x57, 0xe, 0xb3, 0x1f, 0xbd, 0x36, 0xed, 0x25, 0xf0, + 0x2c, 0x25, 0xa9, 0x28, 0xa5, 0x1d, 0x6f, 0xb9, 0x9e, 0x7f, 0x46, 0xa2, 0xf5, 0x80}; + uint8_t bytesprops2[] = {0x90, 0x51, 0x81, 0x43, 0xc2, 0x1, 0x92, 0x5f, 0xcb, 0x76, 0x6}; + uint8_t bytesprops3[] = {0x3e, 0x1d, 0xce, 0x2d, 0xc8, 0x95, 0x85, 0x99, 0x1c, 0x37, 0x7c, 0xd5, 0x27, 0x57, + 0xe5, 0xb, 0x96, 0xf2, 0x35, 0xd5, 0x4c, 0xe7, 0xb3, 0x5e, 0xd2, 0xc5, 0xae}; + uint8_t bytesprops4[] = {0x89, 0xef, 0x94, 0x44, 0xf3, 0x82, 0x41, 0xd8}; + uint8_t bytesprops5[] = {0x41, 0xf3, 0xc7, 0xe4, 0xf1, 0x56}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21218}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25892}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14193}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4778}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20584}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12083}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8095}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22603}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17570}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22199}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25924}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20466}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19738}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23378}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 159}}, + }; + + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xc6, 0x79, 0x79, 0xed, 0xfc, 0xb4, 0x3b, 0xff, + 0x25, 0xec, 0x51, 0x40, 0xa2, 0xdc, 0x89}; + uint8_t byteswillprops2[] = {0xb2, 0x5e, 0x52, 0xfa, 0x73, 0xd0, 0x4d, 0xcf, 0x70, 0xb5}; + uint8_t byteswillprops1[] = {0x4d, 0x25, 0xa1, 0xdb, 0x10, 0x53, 0x2d, 0xbb, + 0x9f, 0xfd, 0x45, 0x6b, 0x7b, 0xab, 0x64}; + uint8_t byteswillprops3[] = {0x32, 0x8f, 0x40, 0xe6, 0x42, 0x7a, 0xba, 0x42, 0x71, 0x6, 0xd9, 0x13, 0xcc, 0xd1, + 0xaa, 0x70, 0xc, 0x3c, 0xe7, 0x5d, 0xd4, 0xf9, 0x50, 0x84, 0xcb, 0xdd, 0xd1, 0x59}; + uint8_t byteswillprops4[] = {0x14, 0x42, 0xbf, 0xb6, 0xf4, 0x22}; + uint8_t byteswillprops5[] = {0x4f, 0xa6, 0x41, 0xa6, 0x40, 0x46, 0x94, 0xbc, 0x40, 0x88, 0xe4, 0xa0}; + uint8_t byteswillprops6[] = {0x4b, 0x4a, 0xfe, 0x36}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10264}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20012}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {15, (char*)&byteswillprops1}, .v = {10, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24923}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26416}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, + }; + + lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x48}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe1, 0xc6, 0x96, 0xa3, 0xd0, 0x57, 0xee, 0x92, 0x1c, 0xdf, + 0x5f, 0xc9, 0xfb, 0x25, 0x8f, 0x0, 0xf3, 0xa2, 0xe1, 0x6c, + 0x6c, 0x93, 0x9d, 0x5a, 0xed, 0xd0, 0xd3, 0x57, 0x29}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 13897; + uint8_t client_id_bytes[] = {0xe9, 0x81, 0x20}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xcd, 0x21, 0xa4, 0x71, 0x3b, 0x95, 0x7c, 0x8c, 0xef, 0x7c, 0xea, 0x1c, 0x4}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x42, 0x45, 0xb, 0x2a, 0x55, 0x19, 0x27, 0x9f, 0x9d, 0x16, 0x6d, 0x10, 0x6e, 0xc0, 0x88, + 0xb, 0x53, 0x22, 0xf4, 0x0, 0x39, 0xe4, 0x27, 0xc3, 0x8b, 0x4, 0xc5, 0xc8, 0xc2}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// "B\186\246\255t\DC3^!\193Sq\185HB\196\232\246Y>p\ACK\187k\ETBu\142", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS1, _willTopic = "I;]\195\205\\\220z\EOT0:<'\ENQ\194D@1\238|", _willMsg = "`!\186\212fPy", _willProps = +// [PropMessageExpiryInterval 28355,PropMaximumPacketSize 28742,PropSubscriptionIdentifierAvailable +// 107,PropMessageExpiryInterval 23830,PropSubscriptionIdentifier 31,PropCorrelationData +// "\179\166D\243"]} +TEST(Connect5QCTest, Encode10) { + uint8_t pkt[] = {0x10, 0xb7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6e, 0x51, 0x34, 0x8, 0x1a, 0x0, 0x5, + 0x3e, 0xb3, 0xa6, 0x44, 0xf3, 0x0, 0x16, 0x9b, 0x1f, 0x9d, 0x78, 0x85, 0x1b, 0x2c, 0x37, 0x5f, 0x62, + 0x8b, 0x87, 0xf4, 0x9d, 0x3c, 0x4a, 0x93, 0x2b, 0x95, 0x11, 0xe9, 0xf4, 0x50, 0x2, 0x0, 0x0, 0x6e, + 0xc3, 0x27, 0x0, 0x0, 0x70, 0x46, 0x29, 0x6b, 0x2, 0x0, 0x0, 0x5d, 0x16, 0xb, 0x1f, 0x9, 0x0, + 0x12, 0x3c, 0x44, 0xb, 0x34, 0x4b, 0xb4, 0x6, 0x4b, 0xc2, 0xd8, 0x94, 0x36, 0x9c, 0xd4, 0xb0, 0x37, + 0xff, 0x5f, 0x11, 0x0, 0x0, 0x26, 0x93, 0x22, 0x34, 0x98, 0x25, 0xcb, 0x27, 0x0, 0x0, 0x1a, 0xf1, + 0x25, 0xeb, 0x27, 0x0, 0x0, 0x63, 0x77, 0x22, 0x7e, 0x9, 0x25, 0x8d, 0x1c, 0x0, 0x7, 0x9f, 0xc6, + 0xf8, 0xf9, 0x45, 0xab, 0xdd, 0x13, 0x59, 0x1e, 0x0, 0x14, 0x49, 0x3b, 0x5d, 0xc3, 0xcd, 0x5c, 0xdc, + 0x7a, 0x4, 0x30, 0x3a, 0x3c, 0x27, 0x5, 0xc2, 0x44, 0x40, 0x31, 0xee, 0x7c, 0x0, 0x7, 0x60, 0x21, + 0xba, 0xd4, 0x66, 0x50, 0x79, 0x0, 0x1a, 0x42, 0xba, 0xf6, 0xff, 0x74, 0x13, 0x5e, 0x21, 0xc1, 0x53, + 0x71, 0xb9, 0x48, 0x42, 0xc4, 0xe8, 0xf6, 0x59, 0x3e, 0x70, 0x6, 0xbb, 0x6b, 0x17, 0x75, 0x8e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x3e, 0xb3, 0xa6, 0x44, 0xf3}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x3c, 0x44, 0xb, 0x34, 0x4b, 0xb4, 0x6, 0x4b, 0xc2, + 0xd8, 0x94, 0x36, 0x9c, 0xd4, 0xb0, 0x37, 0xff, 0x5f}; + uint8_t byteswillprops1[] = {0x9f, 0xc6, 0xf8, 0xf9, 0x45, 0xab, 0xdd}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28355}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28742}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23830}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9875}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13464}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6897}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25463}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32265}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22814}}, + }; + + lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x49, 0x3b, 0x5d, 0xc3, 0xcd, 0x5c, 0xdc, 0x7a, 0x4, 0x30, + 0x3a, 0x3c, 0x27, 0x5, 0xc2, 0x44, 0x40, 0x31, 0xee, 0x7c}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x60, 0x21, 0xba, 0xd4, 0x66, 0x50, 0x79}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 20788; + uint8_t client_id_bytes[] = {0x9b, 0x1f, 0x9d, 0x78, 0x85, 0x1b, 0x2c, 0x37, 0x5f, 0x62, 0x8b, + 0x87, 0xf4, 0x9d, 0x3c, 0x4a, 0x93, 0x2b, 0x95, 0x11, 0xe9, 0xf4}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x42, 0xba, 0xf6, 0xff, 0x74, 0x13, 0x5e, 0x21, 0xc1, 0x53, 0x71, 0xb9, 0x48, + 0x42, 0xc4, 0xe8, 0xf6, 0x59, 0x3e, 0x70, 0x6, 0xbb, 0x6b, 0x17, 0x75, 0x8e}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "dXU-\240\154\245]\DC3\246\178\132\200\255\147MJ\234\151\213\255\168\248\&0\142P\f\180\200", _password = Just +// "\128\DC1\b~e\198U\177\STX'\151\167\&5", _lastWill = Nothing, _cleanSession = True, _keepAlive = 18569, _connID = +// "\128S\EM\228\"K\171g\158}\227SV6\144\224\DC2\159\239\r0\n\156\140\DC3", _properties = [PropUserProperty "" +// "\205\237\173\DC39^\222\EM\168\252\&1-\199A\CAN\241\RS",PropReasonString +// "\RS\203~\182\155y\194\149t\182f\227\224]\187\253\183\225^\159\131i.p\192\174\144[\222\232",PropUserProperty +// "\200\130\155\243\240\DLE\242%\186\GS\168&\212\223\166\221b\SI \149\208\215>\207\156\173a\232<\220" +// ";\236\223\164\221\n;\v\216\RS'\251}n\239\ACK*\149\n9a\255\253\131gm",PropMessageExpiryInterval +// 23389,PropMaximumPacketSize 28026,PropSessionExpiryInterval 977,PropRequestResponseInformation 197,PropUserProperty +// "\233\224U\181Z\148b\EOT" "\168",PropReasonString "\DEL\SOl\RS",PropResponseInformation "",PropMaximumPacketSize +// 14063,PropRequestProblemInformation 214,PropWillDelayInterval 10568,PropTopicAlias +// 1756,PropRequestResponseInformation 234,PropMessageExpiryInterval 13813,PropRequestResponseInformation +// 255,PropServerReference "\149v\231F\US\ACK\178\175,m\132\216"]} +TEST(Connect5QCTest, Encode11) { + uint8_t pkt[] = { + 0x10, 0x99, 0x2, 0x0, 0x4, 0x4d, 0x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35, 0xf5, 0x19, 0xff, 0x1c, 0x0, 0xc, 0x95, 0x76, 0xe7, 0x46, 0x1f, 0x6, 0xb2, 0xaf, 0x2c, 0x6d, + 0x84, 0xd8, 0x0, 0x19, 0x80, 0x53, 0x19, 0xe4, 0x22, 0x4b, 0xab, 0x67, 0x9e, 0x7d, 0xe3, 0x53, 0x56, 0x36, 0x90, + 0xe0, 0x12, 0x9f, 0xef, 0xd, 0x30, 0xa, 0x9c, 0x8c, 0x13, 0x0, 0x1d, 0x64, 0x58, 0x55, 0x2d, 0xf0, 0x9a, 0xf5, + 0x5d, 0x13, 0xf6, 0xb2, 0x84, 0xc8, 0xff, 0x93, 0x4d, 0x4a, 0xea, 0x97, 0xd5, 0xff, 0xa8, 0xf8, 0x30, 0x8e, 0x50, + 0xc, 0xb4, 0xc8, 0x0, 0xd, 0x80, 0x11, 0x8, 0x7e, 0x65, 0xc6, 0x55, 0xb1, 0x2, 0x27, 0x97, 0xa7, 0x35}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0xcd, 0xed, 0xad, 0x13, 0x39, 0x5e, 0xde, 0x19, 0xa8, + 0xfc, 0x31, 0x2d, 0xc7, 0x41, 0x18, 0xf1, 0x1e}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops2[] = {0x1e, 0xcb, 0x7e, 0xb6, 0x9b, 0x79, 0xc2, 0x95, 0x74, 0xb6, 0x66, 0xe3, 0xe0, 0x5d, 0xbb, + 0xfd, 0xb7, 0xe1, 0x5e, 0x9f, 0x83, 0x69, 0x2e, 0x70, 0xc0, 0xae, 0x90, 0x5b, 0xde, 0xe8}; + uint8_t bytesprops4[] = {0x3b, 0xec, 0xdf, 0xa4, 0xdd, 0xa, 0x3b, 0xb, 0xd8, 0x1e, 0x27, 0xfb, 0x7d, + 0x6e, 0xef, 0x6, 0x2a, 0x95, 0xa, 0x39, 0x61, 0xff, 0xfd, 0x83, 0x67, 0x6d}; + uint8_t bytesprops3[] = {0xc8, 0x82, 0x9b, 0xf3, 0xf0, 0x10, 0xf2, 0x25, 0xba, 0x1d, 0xa8, 0x26, 0xd4, 0xdf, 0xa6, + 0xdd, 0x62, 0xf, 0x20, 0x95, 0xd0, 0xd7, 0x3e, 0xcf, 0x9c, 0xad, 0x61, 0xe8, 0x3c, 0xdc}; + uint8_t bytesprops6[] = {0xa8}; + uint8_t bytesprops5[] = {0xe9, 0xe0, 0x55, 0xb5, 0x5a, 0x94, 0x62, 0x4}; + uint8_t bytesprops7[] = {0x7f, 0xe, 0x6c, 0x1e}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0x95, 0x76, 0xe7, 0x46, 0x1f, 0x6, 0xb2, 0xaf, 0x2c, 0x6d, 0x84, 0xd8}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops0}, .v = {17, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops3}, .v = {26, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23389}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28026}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 977}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops5}, .v = {1, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14063}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10568}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1756}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13813}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops9}}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 18569; + uint8_t client_id_bytes[] = {0x80, 0x53, 0x19, 0xe4, 0x22, 0x4b, 0xab, 0x67, 0x9e, 0x7d, 0xe3, 0x53, 0x56, + 0x36, 0x90, 0xe0, 0x12, 0x9f, 0xef, 0xd, 0x30, 0xa, 0x9c, 0x8c, 0x13}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x64, 0x58, 0x55, 0x2d, 0xf0, 0x9a, 0xf5, 0x5d, 0x13, 0xf6, 0xb2, 0x84, 0xc8, 0xff, 0x93, + 0x4d, 0x4a, 0xea, 0x97, 0xd5, 0xff, 0xa8, 0xf8, 0x30, 0x8e, 0x50, 0xc, 0xb4, 0xc8}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x80, 0x11, 0x8, 0x7e, 0x65, 0xc6, 0x55, 0xb1, 0x2, 0x27, 0x97, 0xa7, 0x35}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "|\226c4\183\220\157\131j{\194\250\147\168\202\ENQ\ENQ`\238>SqVU",PropReasonString +// "\201_\157B+",PropServerKeepAlive 1610,PropTopicAlias 27154,PropSubscriptionIdentifier 26]}), _cleanSession = False, +// _keepAlive = 17650, _connID = "\227 s`,1\240\236z\182\167\209\132kvpp\167\174}6Z\207\&9\207%\227U ", _properties = +// [PropPayloadFormatIndicator 172,PropContentType +// "\GS\211|\185\GS\ACK\218\240\255\250\188\196+W_\250\238+(\187\203\162\226\215J",PropAuthenticationMethod +// "",PropMaximumQoS 89,PropTopicAlias 16426,PropResponseTopic " x\193\133\253\234",PropAuthenticationMethod +// "\EOT\164{\208\233\SO|\139\198\&6V\175\145\199W\SO7\ETXgf\182",PropContentType +// "\b\ESC\151\208\148^\US_g\166h8\202{\FS",PropReasonString +// "\164\173\150\207\US\190\&0ZD\FS\198\219\147\128\166\vH\168j\173",PropReasonString +// "\STX",PropSubscriptionIdentifierAvailable 19,PropTopicAliasMaximum 27264,PropSessionExpiryInterval +// 21980,PropReasonString "\SI\141\156\183\221\EOTi\137\131\SOH\179f",PropTopicAlias 25523,PropTopicAliasMaximum +// 31622,PropContentType "\ETB\215aY1\160\GS\129\CAN\202'\177\166\249\231s\138\172\181\252",PropCorrelationData +// "_\230\236\ETB\172\203\r\SOg\230M\134\242\189b\245]\DC1\207\184\212K\b\148",PropUserProperty +// "\155+\130\144\214Su\171\DC4\225(\EMG\128<\202\140\203C\GS\RS\255\253\198\&0" +// "\133d\DEL\149\184",PropAuthenticationData "?\186\229x\186\226\245g\ENQ\SOH\164q\SYN\153:",PropUserProperty +// ";\163\145:x\175j\172\242\160p\SO\212" "\ACK",PropSubscriptionIdentifier 20,PropMaximumPacketSize 14292]} +TEST(Connect5QCTest, Encode12) { + uint8_t pkt[] = { + 0x10, 0xc7, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x44, 0xf2, 0x94, 0x2, 0x1, 0xac, 0x3, 0x0, + 0x19, 0x1d, 0xd3, 0x7c, 0xb9, 0x1d, 0x6, 0xda, 0xf0, 0xff, 0xfa, 0xbc, 0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0x46, 0x98, 0xac, 0x94, 0x8c, 0x9c, 0x0, 0x13, 0x7c, 0xe2, 0x63, 0x34, 0xb7, + 0x3c, 0x78, 0x7f, 0x94, 0x3, 0xb7, 0xe, 0x21, 0x1c, 0xfa, 0x6, 0x1c, 0x5a, 0xe2, 0x0, 0x18, 0x77, 0xbb, 0xdc, + 0xfa, 0xb5, 0x6c, 0x78, 0xac, 0x37, 0x1, 0xc2, 0x8e, 0x5, 0x37, 0x1c, 0xcf, 0x58, 0x94, 0x17, 0xcc, 0xd, 0xd2, + 0x8, 0x1e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1d, 0xd3, 0x7c, 0xb9, 0x1d, 0x6, 0xda, 0xf0, 0xff, 0xfa, 0xbc, 0xc4, 0x2b, + 0x57, 0x5f, 0xfa, 0xee, 0x2b, 0x28, 0xbb, 0xcb, 0xa2, 0xe2, 0xd7, 0x4a}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x20, 0x78, 0xc1, 0x85, 0xfd, 0xea}; + uint8_t bytesprops3[] = {0x4, 0xa4, 0x7b, 0xd0, 0xe9, 0xe, 0x7c, 0x8b, 0xc6, 0x36, 0x56, + 0xaf, 0x91, 0xc7, 0x57, 0xe, 0x37, 0x3, 0x67, 0x66, 0xb6}; + uint8_t bytesprops4[] = {0x8, 0x1b, 0x97, 0xd0, 0x94, 0x5e, 0x1f, 0x5f, 0x67, 0xa6, 0x68, 0x38, 0xca, 0x7b, 0x1c}; + uint8_t bytesprops5[] = {0xa4, 0xad, 0x96, 0xcf, 0x1f, 0xbe, 0x30, 0x5a, 0x44, 0x1c, + 0xc6, 0xdb, 0x93, 0x80, 0xa6, 0xb, 0x48, 0xa8, 0x6a, 0xad}; + uint8_t bytesprops6[] = {0x2}; + uint8_t bytesprops7[] = {0xf, 0x8d, 0x9c, 0xb7, 0xdd, 0x4, 0x69, 0x89, 0x83, 0x1, 0xb3, 0x66}; + uint8_t bytesprops8[] = {0x17, 0xd7, 0x61, 0x59, 0x31, 0xa0, 0x1d, 0x81, 0x18, 0xca, + 0x27, 0xb1, 0xa6, 0xf9, 0xe7, 0x73, 0x8a, 0xac, 0xb5, 0xfc}; + uint8_t bytesprops9[] = {0x5f, 0xe6, 0xec, 0x17, 0xac, 0xcb, 0xd, 0xe, 0x67, 0xe6, 0x4d, 0x86, + 0xf2, 0xbd, 0x62, 0xf5, 0x5d, 0x11, 0xcf, 0xb8, 0xd4, 0x4b, 0x8, 0x94}; + uint8_t bytesprops11[] = {0x85, 0x64, 0x7f, 0x95, 0xb8}; + uint8_t bytesprops10[] = {0x9b, 0x2b, 0x82, 0x90, 0xd6, 0x53, 0x75, 0xab, 0x14, 0xe1, 0x28, 0x19, 0x47, + 0x80, 0x3c, 0xca, 0x8c, 0xcb, 0x43, 0x1d, 0x1e, 0xff, 0xfd, 0xc6, 0x30}; + uint8_t bytesprops12[] = {0x3f, 0xba, 0xe5, 0x78, 0xba, 0xe2, 0xf5, 0x67, 0x5, 0x1, 0xa4, 0x71, 0x16, 0x99, 0x3a}; + uint8_t bytesprops14[] = {0x6}; + uint8_t bytesprops13[] = {0x3b, 0xa3, 0x91, 0x3a, 0x78, 0xaf, 0x6a, 0xac, 0xf2, 0xa0, 0x70, 0xe, 0xd4}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16426}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27264}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21980}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25523}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31622}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops10}, .v = {5, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops13}, .v = {1, (char*)&bytesprops14}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14292}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x19, 0xbc, 0x86, 0x41, 0xea, 0x5d, 0xb6, 0x52, 0x3e, 0xdc, 0x9d, 0x83, 0x6a, 0x7b, + 0xc2, 0xfa, 0x93, 0xa8, 0xca, 0x5, 0x5, 0x60, 0xee, 0x3e, 0x53, 0x71, 0x56, 0x55}; + uint8_t byteswillprops1[] = {0xc9, 0x5f, 0x9d, 0x42, 0x2b}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10139}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1610}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27154}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, + }; + + lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xce, 0x7, 0x42, 0x5e, 0x50, 0x68, 0xbd, 0xc8, 0x9e, 0xdc, 0xe, 0x97, 0xf8, + 0x8e, 0x1b, 0xca, 0x24, 0x78, 0xbb, 0xf1, 0x2b, 0x5b, 0x3b, 0xa5, 0xa}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb7, 0x46, 0x98, 0xac, 0x94, 0x8c, 0x9c}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 17650; + uint8_t client_id_bytes[] = {0xe3, 0x20, 0x73, 0x60, 0x2c, 0x31, 0xf0, 0xec, 0x7a, 0xb6, 0xa7, 0xd1, 0x84, 0x6b, 0x76, + 0x70, 0x70, 0xa7, 0xae, 0x7d, 0x36, 0x5a, 0xcf, 0x39, 0xcf, 0x25, 0xe3, 0x55, 0x20}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x7c, 0xe2, 0x63, 0x34, 0xb7, 0x3c, 0x78, 0x7f, 0x94, 0x3, + 0xb7, 0xe, 0x21, 0x1c, 0xfa, 0x6, 0x1c, 0x5a, 0xe2}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x77, 0xbb, 0xdc, 0xfa, 0xb5, 0x6c, 0x78, 0xac, 0x37, 0x1, 0xc2, 0x8e, + 0x5, 0x37, 0x1c, 0xcf, 0x58, 0x94, 0x17, 0xcc, 0xd, 0xd2, 0x8, 0x1e}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\148q\203\&9\184:)\217]G\254\f`\208\248\&4\183\139 +// \RS\CAN\219\RS\133d\252H\220L\v", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS2, _willTopic = "u\187\\\\+\205\SOHy&{\228\219.\ETB\ENQ\219", _willMsg = "\147 +// !K\155\f\253\214\246hNm\ACK)\156\193\241$\198>\RSz", _willProps = [PropUserProperty "n\179)X" +// "\b1\221\191\STX\223etX_\186\246\146",PropContentType +// "\232\216.\186\132p\211\187\\\n\201\166\240T\131\238\224e",PropAssignedClientIdentifier +// "s\FS\181Te\a\231",PropTopicAlias 32238,PropServerKeepAlive 20424,PropContentType +// "\173\ETBO^\SOH\224\STX\171\STX\215\232",PropMaximumPacketSize 4132,PropRequestResponseInformation +// 174,PropAuthenticationMethod +// "\129+\a\238\194\199\RS\175\r\\\FS\226i\159\191\183)\141S_\SOH%\140\203a\SO\244\ETB",PropResponseInformation +// "\144\254\186D\222\220",PropSharedSubscriptionAvailable 25,PropServerReference +// "\151\191l\188\RS0q\131\NAK\149\&6}\240D\247\191\218\187_rW\246\191\138\250cD",PropSubscriptionIdentifier +// 8,PropResponseTopic ",B\DLE\157\215\&0\153\&2\255\f",PropAuthenticationMethod +// "^-o\195v\166\ao\207\203\139\249\SO\244\206le",PropUserProperty +// "$]\254\EOT\232^\153\201\238\&4\178j\195\233q~\RS\194\163" +// "I\DLEUZ\132Y\219\155\&5j\228&xf\225>\223\203\SUBX\153\246\190\NULB\133\202\198\242\245",PropUserProperty +// ":Y\213\240b" "0$W\185\144\240"]}), _cleanSession = False, _keepAlive = 20026, _connID = +// "_\DEL\aB\218\207H\EMs\SO\153b@\162", _properties = [PropRequestResponseInformation 246,PropTopicAliasMaximum 18904]} +TEST(Connect5QCTest, Encode13) { + uint8_t pkt[] = { + 0x10, 0xed, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb4, 0x4e, 0x3a, 0x5, 0x19, 0xf6, 0x22, 0x49, 0xd8, + 0x0, 0xe, 0x5f, 0x7f, 0x7, 0x42, 0xda, 0xcf, 0x48, 0x19, 0x73, 0xe, 0x99, 0x62, 0x40, 0xa2, 0x81, 0x2, 0x26, + 0x0, 0x4, 0x6e, 0xb3, 0x29, 0x58, 0x0, 0xd, 0x8, 0x31, 0xdd, 0xbf, 0x2, 0xdf, 0x65, 0x74, 0x58, 0x5f, 0xba, + 0xf6, 0x92, 0x3, 0x0, 0x12, 0xe8, 0xd8, 0x2e, 0xba, 0x84, 0x70, 0xd3, 0xbb, 0x5c, 0xa, 0xc9, 0xa6, 0xf0, 0x54, + 0x83, 0xee, 0xe0, 0x65, 0x12, 0x0, 0x7, 0x73, 0x1c, 0xb5, 0x54, 0x65, 0x7, 0xe7, 0x23, 0x7d, 0xee, 0x13, 0x4f, + 0xc8, 0x3, 0x0, 0xb, 0xad, 0x17, 0x4f, 0x5e, 0x1, 0xe0, 0x2, 0xab, 0x2, 0xd7, 0xe8, 0x27, 0x0, 0x0, 0x10, + 0x24, 0x19, 0xae, 0x15, 0x0, 0x1c, 0x81, 0x2b, 0x7, 0xee, 0xc2, 0xc7, 0x1e, 0xaf, 0xd, 0x5c, 0x1c, 0xe2, 0x69, + 0x9f, 0xbf, 0xb7, 0x29, 0x8d, 0x53, 0x5f, 0x1, 0x25, 0x8c, 0xcb, 0x61, 0xe, 0xf4, 0x17, 0x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x3e, 0x1e, 0x7a, 0x0, 0x1e, 0x94, 0x71, 0xcb, 0x39, + 0xb8, 0x3a, 0x29, 0xd9, 0x5d, 0x47, 0xfe, 0xc, 0x60, 0xd0, 0xf8, 0x34, 0xb7, 0x8b, 0x20, 0x1e, 0x18, 0xdb, 0x1e, + 0x85, 0x64, 0xfc, 0x48, 0xdc, 0x4c, 0xb}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18904}}, + }; + + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x8, 0x31, 0xdd, 0xbf, 0x2, 0xdf, 0x65, 0x74, 0x58, 0x5f, 0xba, 0xf6, 0x92}; + uint8_t byteswillprops0[] = {0x6e, 0xb3, 0x29, 0x58}; + uint8_t byteswillprops2[] = {0xe8, 0xd8, 0x2e, 0xba, 0x84, 0x70, 0xd3, 0xbb, 0x5c, + 0xa, 0xc9, 0xa6, 0xf0, 0x54, 0x83, 0xee, 0xe0, 0x65}; + uint8_t byteswillprops3[] = {0x73, 0x1c, 0xb5, 0x54, 0x65, 0x7, 0xe7}; + uint8_t byteswillprops4[] = {0xad, 0x17, 0x4f, 0x5e, 0x1, 0xe0, 0x2, 0xab, 0x2, 0xd7, 0xe8}; + uint8_t byteswillprops5[] = {0x81, 0x2b, 0x7, 0xee, 0xc2, 0xc7, 0x1e, 0xaf, 0xd, 0x5c, 0x1c, 0xe2, 0x69, 0x9f, + 0xbf, 0xb7, 0x29, 0x8d, 0x53, 0x5f, 0x1, 0x25, 0x8c, 0xcb, 0x61, 0xe, 0xf4, 0x17}; + uint8_t byteswillprops6[] = {0x90, 0xfe, 0xba, 0x44, 0xde, 0xdc}; + uint8_t byteswillprops7[] = {0x97, 0xbf, 0x6c, 0xbc, 0x1e, 0x30, 0x71, 0x83, 0x15, 0x95, 0x36, 0x7d, 0xf0, 0x44, + 0xf7, 0xbf, 0xda, 0xbb, 0x5f, 0x72, 0x57, 0xf6, 0xbf, 0x8a, 0xfa, 0x63, 0x44}; + uint8_t byteswillprops8[] = {0x2c, 0x42, 0x10, 0x9d, 0xd7, 0x30, 0x99, 0x32, 0xff, 0xc}; + uint8_t byteswillprops9[] = {0x5e, 0x2d, 0x6f, 0xc3, 0x76, 0xa6, 0x7, 0x6f, 0xcf, + 0xcb, 0x8b, 0xf9, 0xe, 0xf4, 0xce, 0x6c, 0x65}; + uint8_t byteswillprops11[] = {0x49, 0x10, 0x55, 0x5a, 0x84, 0x59, 0xdb, 0x9b, 0x35, 0x6a, + 0xe4, 0x26, 0x78, 0x66, 0xe1, 0x3e, 0xdf, 0xcb, 0x1a, 0x58, + 0x99, 0xf6, 0xbe, 0x0, 0x42, 0x85, 0xca, 0xc6, 0xf2, 0xf5}; + uint8_t byteswillprops10[] = {0x24, 0x5d, 0xfe, 0x4, 0xe8, 0x5e, 0x99, 0xc9, 0xee, 0x34, + 0xb2, 0x6a, 0xc3, 0xe9, 0x71, 0x7e, 0x1e, 0xc2, 0xa3}; + uint8_t byteswillprops13[] = {0x30, 0x24, 0x57, 0xb9, 0x90, 0xf0}; + uint8_t byteswillprops12[] = {0x3a, 0x59, 0xd5, 0xf0, 0x62}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {4, (char*)&byteswillprops0}, .v = {13, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32238}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20424}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4132}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {19, (char*)&byteswillprops10}, .v = {30, (char*)&byteswillprops11}}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {5, (char*)&byteswillprops12}, .v = {6, (char*)&byteswillprops13}}}}, + }; + + lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x75, 0xbb, 0x5c, 0x5c, 0x2b, 0xcd, 0x1, 0x79, + 0x26, 0x7b, 0xe4, 0xdb, 0x2e, 0x17, 0x5, 0xdb}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x93, 0x20, 0x21, 0x4b, 0x9b, 0xc, 0xfd, 0xd6, 0xf6, 0x68, 0x4e, + 0x6d, 0x6, 0x29, 0x9c, 0xc1, 0xf1, 0x24, 0xc6, 0x3e, 0x1e, 0x7a}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 20026; + uint8_t client_id_bytes[] = {0x5f, 0x7f, 0x7, 0x42, 0xda, 0xcf, 0x48, 0x19, 0x73, 0xe, 0x99, 0x62, 0x40, 0xa2}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x94, 0x71, 0xcb, 0x39, 0xb8, 0x3a, 0x29, 0xd9, 0x5d, 0x47, 0xfe, 0xc, 0x60, 0xd0, 0xf8, + 0x34, 0xb7, 0x8b, 0x20, 0x1e, 0x18, 0xdb, 0x1e, 0x85, 0x64, 0xfc, 0x48, 0xdc, 0x4c, 0xb}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "F|\\\193@", _lastWill = Nothing, _cleanSession = False, +// _keepAlive = 13766, _connID = "((\SOH\237M\220\167\ESC\241\249\138f\149\134\225\RS U!\133]\SO\204\&8D.g\154", +// _properties = [PropServerReference "\237\186\SIg\196\172\241",PropMessageExpiryInterval +// 12799,PropRequestResponseInformation 71,PropRequestResponseInformation 250,PropMessageExpiryInterval +// 30631,PropUserProperty "\213\"\193\183V2XH\144\169\EM" +// "\b&[\137B\243\207\224\US\165Q\128Q\164>\174W\150\174V\US\190\169\222\250\r\206\150",PropSessionExpiryInterval +// 24456,PropRequestResponseInformation 8,PropRetainAvailable 102,PropServerKeepAlive 18186,PropMessageExpiryInterval +// 23633]} +TEST(Connect5QCTest, Encode14) { + uint8_t pkt[] = {0x10, 0x85, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x40, 0x35, 0xc6, 0x55, 0x1c, 0x0, + 0x7, 0xed, 0xba, 0xf, 0x67, 0xc4, 0xac, 0xf1, 0x2, 0x0, 0x0, 0x31, 0xff, 0x19, 0x47, 0x19, + 0xfa, 0x2, 0x0, 0x0, 0x77, 0xa7, 0x26, 0x0, 0xb, 0xd5, 0x22, 0xc1, 0xb7, 0x56, 0x32, 0x58, + 0x48, 0x90, 0xa9, 0x19, 0x0, 0x1c, 0x8, 0x26, 0x5b, 0x89, 0x42, 0xf3, 0xcf, 0xe0, 0x1f, 0xa5, + 0x51, 0x80, 0x51, 0xa4, 0x3e, 0xae, 0x57, 0x96, 0xae, 0x56, 0x1f, 0xbe, 0xa9, 0xde, 0xfa, 0xd, + 0xce, 0x96, 0x11, 0x0, 0x0, 0x5f, 0x88, 0x19, 0x8, 0x25, 0x66, 0x13, 0x47, 0xa, 0x2, 0x0, + 0x0, 0x5c, 0x51, 0x0, 0x1c, 0x28, 0x28, 0x1, 0xed, 0x4d, 0xdc, 0xa7, 0x1b, 0xf1, 0xf9, 0x8a, + 0x66, 0x95, 0x86, 0xe1, 0x1e, 0x20, 0x55, 0x21, 0x85, 0x5d, 0xe, 0xcc, 0x38, 0x44, 0x2e, 0x67, + 0x9a, 0x0, 0x5, 0x46, 0x7c, 0x5c, 0xc1, 0x40}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xed, 0xba, 0xf, 0x67, 0xc4, 0xac, 0xf1}; + uint8_t bytesprops2[] = {0x8, 0x26, 0x5b, 0x89, 0x42, 0xf3, 0xcf, 0xe0, 0x1f, 0xa5, 0x51, 0x80, 0x51, 0xa4, + 0x3e, 0xae, 0x57, 0x96, 0xae, 0x56, 0x1f, 0xbe, 0xa9, 0xde, 0xfa, 0xd, 0xce, 0x96}; + uint8_t bytesprops1[] = {0xd5, 0x22, 0xc1, 0xb7, 0x56, 0x32, 0x58, 0x48, 0x90, 0xa9, 0x19}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12799}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30631}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {28, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24456}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18186}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23633}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 13766; + uint8_t client_id_bytes[] = {0x28, 0x28, 0x1, 0xed, 0x4d, 0xdc, 0xa7, 0x1b, 0xf1, 0xf9, 0x8a, 0x66, 0x95, 0x86, + 0xe1, 0x1e, 0x20, 0x55, 0x21, 0x85, 0x5d, 0xe, 0xcc, 0x38, 0x44, 0x2e, 0x67, 0x9a}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x46, 0x7c, 0x5c, 0xc1, 0x40}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "C\205.\143\174\198\137\162\176\DC1 \254/'\209\141o\153", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "H\153y\169d\249\209\v\245\233\238\223\202L\133\136\143\191\142\179FE )2\242\148k", _willMsg = +// "D\217",PropWildcardSubscriptionAvailable +// 188,PropTopicAlias 20412,PropMessageExpiryInterval 20838]}), _cleanSession = False, _keepAlive = 18040, _connID = +// "\244\188\144", _properties = [PropSessionExpiryInterval 482,PropTopicAlias 11370,PropSubscriptionIdentifier +// 4,PropTopicAlias 22548,PropServerKeepAlive 20135,PropMessageExpiryInterval 12819,PropResponseTopic +// "\a\172).\155_&\186\bT\213\171h\128\&3b",PropMessageExpiryInterval 10474,PropAuthenticationData +// "\179\ETX%<#\253\182",PropRequestProblemInformation 150]} +TEST(Connect5QCTest, Encode20) { + uint8_t pkt[] = {0x10, 0x9d, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x54, 0x46, 0x78, 0x39, 0x11, 0x0, 0x0, + 0x1, 0xe2, 0x23, 0x2c, 0x6a, 0xb, 0x4, 0x23, 0x58, 0x14, 0x13, 0x4e, 0xa7, 0x2, 0x0, 0x0, 0x32, + 0x13, 0x8, 0x0, 0x10, 0x7, 0xac, 0x29, 0x2e, 0x9b, 0x5f, 0x26, 0xba, 0x8, 0x54, 0xd5, 0xab, 0x68, + 0x80, 0x33, 0x62, 0x2, 0x0, 0x0, 0x28, 0xea, 0x16, 0x0, 0x7, 0xb3, 0x3, 0x25, 0x3c, 0x23, 0xfd, + 0xb6, 0x17, 0x96, 0x0, 0x3, 0xf4, 0xbc, 0x90, 0x90, 0x1, 0x21, 0x4a, 0xbe, 0x25, 0x7f, 0x1a, 0x0, + 0x14, 0x20, 0xdb, 0xe9, 0x1a, 0xf0, 0xed, 0xc3, 0x1f, 0xb8, 0xc9, 0xe7, 0x29, 0x20, 0x49, 0xd1, 0xb9, + 0xa3, 0xf5, 0x29, 0xb2, 0x21, 0x8, 0x3d, 0x22, 0x67, 0xc, 0x18, 0x0, 0x0, 0x62, 0x92, 0x2a, 0x69, + 0x1, 0xcb, 0x2, 0x0, 0x0, 0x18, 0xdb, 0x22, 0x72, 0xa, 0x27, 0x0, 0x0, 0x40, 0x15, 0x2a, 0xc8, + 0x23, 0x1, 0x23, 0x2, 0x0, 0x0, 0x53, 0xb8, 0x3, 0x0, 0x1b, 0xe4, 0x7d, 0xf8, 0x97, 0x16, 0xfb, + 0x97, 0xac, 0x72, 0xba, 0x9c, 0x44, 0x0, 0xf0, 0x2c, 0x9d, 0xcf, 0xea, 0x4a, 0xdb, 0x35, 0x88, 0x77, + 0x15, 0xc0, 0x2, 0xde, 0x24, 0x75, 0x24, 0xa4, 0x2, 0x0, 0x0, 0x31, 0xe1, 0x8, 0x0, 0x1a, 0x1c, + 0xd9, 0x4c, 0xda, 0x56, 0x31, 0x6a, 0x37, 0x57, 0xbf, 0x95, 0xd1, 0xcc, 0xd, 0x51, 0x8e, 0x1c, 0xd9, + 0xc3, 0xfe, 0x5a, 0xed, 0x46, 0xff, 0xc0, 0x3e, 0x28, 0xbc, 0x23, 0x4f, 0xbc, 0x2, 0x0, 0x0, 0x51, + 0x66, 0x0, 0x8, 0x63, 0xe4, 0x8d, 0x50, 0x6a, 0xe3, 0xc8, 0x1e, 0x0, 0x16, 0x4f, 0xb5, 0x92, 0xac, + 0x38, 0xc8, 0xa5, 0x70, 0x77, 0x9c, 0x3a, 0xe3, 0xa0, 0xcc, 0x22, 0xdb, 0x2d, 0x79, 0x1f, 0xd6, 0xa8, + 0x7b, 0x0, 0x1e, 0x49, 0x57, 0x5b, 0xf8, 0x2d, 0x5b, 0x2a, 0x15, 0x87, 0x6a, 0x4a, 0x4a, 0x90, 0x34, + 0x94, 0x83, 0x48, 0xf2, 0x49, 0x49, 0x64, 0xb8, 0xc4, 0x61, 0x7c, 0x43, 0x42, 0xf2, 0x15, 0xee}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7, 0xac, 0x29, 0x2e, 0x9b, 0x5f, 0x26, 0xba, + 0x8, 0x54, 0xd5, 0xab, 0x68, 0x80, 0x33, 0x62}; + uint8_t bytesprops1[] = {0xb3, 0x3, 0x25, 0x3c, 0x23, 0xfd, 0xb6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 482}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11370}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22548}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20135}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12819}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10474}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 150}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x20, 0xdb, 0xe9, 0x1a, 0xf0, 0xed, 0xc3, 0x1f, 0xb8, 0xc9, + 0xe7, 0x29, 0x20, 0x49, 0xd1, 0xb9, 0xa3, 0xf5, 0x29, 0xb2}; + uint8_t byteswillprops1[] = {0xe4, 0x7d, 0xf8, 0x97, 0x16, 0xfb, 0x97, 0xac, 0x72, 0xba, 0x9c, 0x44, 0x0, 0xf0, + 0x2c, 0x9d, 0xcf, 0xea, 0x4a, 0xdb, 0x35, 0x88, 0x77, 0x15, 0xc0, 0x2, 0xde}; + uint8_t byteswillprops2[] = {0x1c, 0xd9, 0x4c, 0xda, 0x56, 0x31, 0x6a, 0x37, 0x57, 0xbf, 0x95, 0xd1, 0xcc, + 0xd, 0x51, 0x8e, 0x1c, 0xd9, 0xc3, 0xfe, 0x5a, 0xed, 0x46, 0xff, 0xc0, 0x3e}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19134}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2109}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26380}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25234}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6363}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29194}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16405}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 291}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21432}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12769}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20412}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20838}}, + }; + + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x63, 0xe4, 0x8d, 0x50, 0x6a, 0xe3, 0xc8, 0x1e}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4f, 0xb5, 0x92, 0xac, 0x38, 0xc8, 0xa5, 0x70, 0x77, 0x9c, 0x3a, + 0xe3, 0xa0, 0xcc, 0x22, 0xdb, 0x2d, 0x79, 0x1f, 0xd6, 0xa8, 0x7b}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 18040; + uint8_t client_id_bytes[] = {0xf4, 0xbc, 0x90}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x49, 0x57, 0x5b, 0xf8, 0x2d, 0x5b, 0x2a, 0x15, 0x87, 0x6a, 0x4a, 0x4a, 0x90, 0x34, 0x94, + 0x83, 0x48, 0xf2, 0x49, 0x49, 0x64, 0xb8, 0xc4, 0x61, 0x7c, 0x43, 0x42, 0xf2, 0x15, 0xee}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "$\184\198/)\161\242\&4\202q.\235\175\183`h", _password = Nothing, _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\ETX-gs\242\r\246#:\255\212\251\221\STX#P", _willMsg = +// "\241\&7\183W", _willProps = [PropSubscriptionIdentifier 6,PropTopicAliasMaximum 26473,PropMaximumQoS +// 150,PropAssignedClientIdentifier "\244rQ",PropMaximumPacketSize 23974,PropSubscriptionIdentifierAvailable +// 160,PropAssignedClientIdentifier +// "*\160\213ln,\237\178\229\FS\213\146\212\253p\238\187m\STXK\212h\224\228\249\217\SI\239\ACK\224",PropWillDelayInterval +// 16452,PropResponseInformation +// "<\149\EOT\ETBRKz/V\224\147\196\r\161\137\241\141\198\216U\202w:1\164_\160\&0\191\169",PropPayloadFormatIndicator +// 66,PropRequestResponseInformation 230,PropResponseTopic +// "\208&\191:\194\ETB\254\252\246B\158\163\rD\169kV\EM\130T\227\201|g\164\US",PropReceiveMaximum +// 8181,PropSubscriptionIdentifier 22,PropSessionExpiryInterval 18537,PropWillDelayInterval 19433,PropUserProperty +// "\EOT\186\188\174\158C@\STXk" "\183\137~\242\139\&5\128\202\FSr\183\DLE\149|i\RSl\164",PropTopicAlias +// 17737,PropAuthenticationMethod "\145\240S!F\217\SYNH\173W\SOH",PropReasonString +// "\157m\SOH!",PropRequestProblemInformation 110,PropServerReference "\218m\SUB\253\206\137Vd\241",PropReasonString +// "\CANj\188\NAK\203\255k\243\211\237~\253\197\219x_0\207~\176\255\160\213\137S\168\146\DEL",PropContentType +// "\142<\128\\Y\158",PropWildcardSubscriptionAvailable 72,PropAuthenticationMethod +// ":o\163\244\234\212\131\157\DLE\252\160@\214\149\SOH\192\FSf\n\250:\220\206\219"]}), _cleanSession = False, +// _keepAlive = 6911, _connID = "Nr\151\198", _properties = [PropWildcardSubscriptionAvailable +// 158,PropSubscriptionIdentifier 17,PropContentType "\FS\226\218j\196",PropUserProperty "" +// "\174\242\166\220\171\RS\202\180T\ACK",PropMessageExpiryInterval 11680,PropContentType +// "\FS\NAK\FS!\226\242\237\179V\211i\198\206\138`\169zS\128\&3\130",PropRequestProblemInformation 175]} +TEST(Connect5QCTest, Encode21) { + uint8_t pkt[] = { + 0x10, 0x8d, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x84, 0x1a, 0xff, 0x3a, 0x28, 0x9e, 0xb, 0x11, 0x3, + 0x0, 0x5, 0x1c, 0xe2, 0xda, 0x6a, 0xc4, 0x26, 0x0, 0x0, 0x0, 0xa, 0xae, 0xf2, 0xa6, 0xdc, 0xab, 0x1e, 0xca, + 0xb4, 0x54, 0x6, 0x2, 0x0, 0x0, 0x2d, 0xa0, 0x3, 0x0, 0x15, 0x1c, 0x15, 0x1c, 0x21, 0xe2, 0xf2, 0xed, 0xb3,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0xb7, 0x10, 0x95, 0x7c, + 0x69, 0x1e, 0x6c, 0xa4, 0x23, 0x45, 0x49, 0x15, 0x0, 0xb, 0x91, 0xf0, 0x53, 0x21, 0x46, 0xd9, 0x16, 0x48, 0xad, + 0x57, 0x1, 0x1f, 0x0, 0x4, 0x9d, 0x6d, 0x1, 0x21, 0x17, 0x6e, 0x1c, 0x0, 0x9, 0xda, 0x6d, 0x1a, 0xfd, 0xce, + 0x89, 0x56, 0x64, 0xf1, 0x1f, 0x0, 0x1c, 0x18, 0x6a, 0xbc, 0x15, 0xcb, 0xff, 0x6b, 0xf3, 0xd3, 0xed, 0x7e, 0xfd, + 0xc5, 0xdb, 0x78, 0x5f, 0x30, 0xcf, 0x7e, 0xb0, 0xff, 0xa0, 0xd5, 0x89, 0x53, 0xa8, 0x92, 0x7f, 0x3, 0x0, 0x6, + 0x8e, 0x3c, 0x80, 0x5c, 0x59, 0x9e, 0x28, 0x48, 0x15, 0x0, 0x18, 0x3a, 0x6f, 0xa3, 0xf4, 0xea, 0xd4, 0x83, 0x9d, + 0x10, 0xfc, 0xa0, 0x40, 0xd6, 0x95, 0x1, 0xc0, 0x1c, 0x66, 0xa, 0xfa, 0x3a, 0xdc, 0xce, 0xdb, 0x0, 0x10, 0x3, + 0x2d, 0x67, 0x73, 0xf2, 0xd, 0xf6, 0x23, 0x3a, 0xff, 0xd4, 0xfb, 0xdd, 0x2, 0x23, 0x50, 0x0, 0x4, 0xf1, 0x37, + 0xb7, 0x57, 0x0, 0x10, 0x24, 0xb8, 0xc6, 0x2f, 0x29, 0xa1, 0xf2, 0x34, 0xca, 0x71, 0x2e, 0xeb, 0xaf, 0xb7, 0x60, + 0x68}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1c, 0xe2, 0xda, 0x6a, 0xc4}; + uint8_t bytesprops2[] = {0xae, 0xf2, 0xa6, 0xdc, 0xab, 0x1e, 0xca, 0xb4, 0x54, 0x6}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops3[] = {0x1c, 0x15, 0x1c, 0x21, 0xe2, 0xf2, 0xed, 0xb3, 0x56, 0xd3, 0x69, + 0xc6, 0xce, 0x8a, 0x60, 0xa9, 0x7a, 0x53, 0x80, 0x33, 0x82}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops1}, .v = {10, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11680}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 175}}, + }; + + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xf4, 0x72, 0x51}; + uint8_t byteswillprops1[] = {0x2a, 0xa0, 0xd5, 0x6c, 0x6e, 0x2c, 0xed, 0xb2, 0xe5, 0x1c, + 0xd5, 0x92, 0xd4, 0xfd, 0x70, 0xee, 0xbb, 0x6d, 0x2, 0x4b, + 0xd4, 0x68, 0xe0, 0xe4, 0xf9, 0xd9, 0xf, 0xef, 0x6, 0xe0}; + uint8_t byteswillprops2[] = {0x3c, 0x95, 0x4, 0x17, 0x52, 0x4b, 0x7a, 0x2f, 0x56, 0xe0, + 0x93, 0xc4, 0xd, 0xa1, 0x89, 0xf1, 0x8d, 0xc6, 0xd8, 0x55, + 0xca, 0x77, 0x3a, 0x31, 0xa4, 0x5f, 0xa0, 0x30, 0xbf, 0xa9}; + uint8_t byteswillprops3[] = {0xd0, 0x26, 0xbf, 0x3a, 0xc2, 0x17, 0xfe, 0xfc, 0xf6, 0x42, 0x9e, 0xa3, 0xd, + 0x44, 0xa9, 0x6b, 0x56, 0x19, 0x82, 0x54, 0xe3, 0xc9, 0x7c, 0x67, 0xa4, 0x1f}; + uint8_t byteswillprops5[] = {0xb7, 0x89, 0x7e, 0xf2, 0x8b, 0x35, 0x80, 0xca, 0x1c, + 0x72, 0xb7, 0x10, 0x95, 0x7c, 0x69, 0x1e, 0x6c, 0xa4}; + uint8_t byteswillprops4[] = {0x4, 0xba, 0xbc, 0xae, 0x9e, 0x43, 0x40, 0x2, 0x6b}; + uint8_t byteswillprops6[] = {0x91, 0xf0, 0x53, 0x21, 0x46, 0xd9, 0x16, 0x48, 0xad, 0x57, 0x1}; + uint8_t byteswillprops7[] = {0x9d, 0x6d, 0x1, 0x21}; + uint8_t byteswillprops8[] = {0xda, 0x6d, 0x1a, 0xfd, 0xce, 0x89, 0x56, 0x64, 0xf1}; + uint8_t byteswillprops9[] = {0x18, 0x6a, 0xbc, 0x15, 0xcb, 0xff, 0x6b, 0xf3, 0xd3, 0xed, 0x7e, 0xfd, 0xc5, 0xdb, + 0x78, 0x5f, 0x30, 0xcf, 0x7e, 0xb0, 0xff, 0xa0, 0xd5, 0x89, 0x53, 0xa8, 0x92, 0x7f}; + uint8_t byteswillprops10[] = {0x8e, 0x3c, 0x80, 0x5c, 0x59, 0x9e}; + uint8_t byteswillprops11[] = {0x3a, 0x6f, 0xa3, 0xf4, 0xea, 0xd4, 0x83, 0x9d, 0x10, 0xfc, 0xa0, 0x40, + 0xd6, 0x95, 0x1, 0xc0, 0x1c, 0x66, 0xa, 0xfa, 0x3a, 0xdc, 0xce, 0xdb}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26473}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23974}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16452}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8181}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18537}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19433}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {9, (char*)&byteswillprops4}, .v = {18, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17737}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&byteswillprops11}}}, + }; + + lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x3, 0x2d, 0x67, 0x73, 0xf2, 0xd, 0xf6, 0x23, + 0x3a, 0xff, 0xd4, 0xfb, 0xdd, 0x2, 0x23, 0x50}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf1, 0x37, 0xb7, 0x57}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 6911; + uint8_t client_id_bytes[] = {0x4e, 0x72, 0x97, 0xc6}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x24, 0xb8, 0xc6, 0x2f, 0x29, 0xa1, 0xf2, 0x34, + 0xca, 0x71, 0x2e, 0xeb, 0xaf, 0xb7, 0x60, 0x68}; + lwmqtt_string_t username = {16, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\178", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS0, _willTopic = "\196\v\202\168\"s\DC1+\222\128\&1\138Y\208Bp\178", _willMsg = "", _willProps = +// [PropRequestProblemInformation 63,PropMaximumPacketSize 20521,PropRequestResponseInformation +// 174,PropAuthenticationMethod "\211\191\181\RS\183z\227\179?1\STXq\206]\142\211vX",PropCorrelationData +// "\177\167\250\SOH\186\bE\SO@",PropSubscriptionIdentifier 3,PropAuthenticationData +// "\176\173@&C\EOT\253V\185\228\195\204\v\138a\176\r\162\227x\146\183\204\140!\184cd\CAN\191",PropMessageExpiryInterval +// 26988,PropResponseInformation "\222}\130\134\234l}\197,",PropRequestResponseInformation 46,PropResponseInformation +// "\v\207\GS\GS\232\164\227",PropTopicAliasMaximum 3468,PropMessageExpiryInterval 24720]}), _cleanSession = True, +// _keepAlive = 11823, _connID = "\r\173C5$+~D\ACK\169D\220\160\218\131!Bo\SO\159HN", _properties = +// [PropAssignedClientIdentifier "O\EM\140\ESCL\218\198\196\207Hn@\142\\\171\137\130\186\145@",PropMessageExpiryInterval +// 29289,PropReasonString "9\ENQ<\196\241\212D\182\152\136\&4\SI"]} +TEST(Connect5QCTest, Encode22) { + uint8_t pkt[] = {0x10, 0xd9, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xa6, 0x2e, 0x2f, 0x2b, 0x12, 0x0, 0x14, + 0x4f, 0x19, 0x8c, 0x1b, 0x4c, 0xda, 0xc6, 0xc4, 0xcf, 0x48, 0x6e, 0x40, 0x8e, 0x5c, 0xab, 0x89, 0x82, + 0xba, 0x91, 0x40, 0x2, 0x0, 0x0, 0x72, 0x69, 0x1f, 0x0, 0xc, 0x39, 0x5, 0x3c, 0xc4, 0xf1, 0xd4, + 0x44, 0xb6, 0x98, 0x88, 0x34, 0xf, 0x0, 0x16, 0xd, 0xad, 0x43, 0x35, 0x24, 0x2b, 0x7e, 0x44, 0x6, + 0xa9, 0x44, 0xdc, 0xa0, 0xda, 0x83, 0x21, 0x42, 0x6f, 0xe, 0x9f, 0x48, 0x4e, 0x72, 0x17, 0x3f, 0x27, + 0x0, 0x0, 0x50, 0x29, 0x19, 0xae, 0x15, 0x0, 0x12, 0xd3, 0xbf, 0xb5, 0x1e, 0xb7, 0x7a, 0xe3, 0xb3, + 0x3f, 0x31, 0x2, 0x71, 0xce, 0x5d, 0x8e, 0xd3, 0x76, 0x58, 0x9, 0x0, 0x9, 0xb1, 0xa7, 0xfa, 0x1, + 0xba, 0x8, 0x45, 0xe, 0x40, 0xb, 0x3, 0x16, 0x0, 0x1e, 0xb0, 0xad, 0x40, 0x26, 0x43, 0x4, 0xfd, + 0x56, 0xb9, 0xe4, 0xc3, 0xcc, 0xb, 0x8a, 0x61, 0xb0, 0xd, 0xa2, 0xe3, 0x78, 0x92, 0xb7, 0xcc, 0x8c, + 0x21, 0xb8, 0x63, 0x64, 0x18, 0xbf, 0x2, 0x0, 0x0, 0x69, 0x6c, 0x1a, 0x0, 0x9, 0xde, 0x7d, 0x82, + 0x86, 0xea, 0x6c, 0x7d, 0xc5, 0x2c, 0x19, 0x2e, 0x1a, 0x0, 0x7, 0xb, 0xcf, 0x1d, 0x1d, 0xe8, 0xa4, + 0xe3, 0x22, 0xd, 0x8c, 0x2, 0x0, 0x0, 0x60, 0x90, 0x0, 0x11, 0xc4, 0xb, 0xca, 0xa8, 0x22, 0x73, + 0x11, 0x2b, 0xde, 0x80, 0x31, 0x8a, 0x59, 0xd0, 0x42, 0x70, 0xb2, 0x0, 0x0, 0x0, 0x1, 0xb2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x4f, 0x19, 0x8c, 0x1b, 0x4c, 0xda, 0xc6, 0xc4, 0xcf, 0x48, + 0x6e, 0x40, 0x8e, 0x5c, 0xab, 0x89, 0x82, 0xba, 0x91, 0x40}; + uint8_t bytesprops1[] = {0x39, 0x5, 0x3c, 0xc4, 0xf1, 0xd4, 0x44, 0xb6, 0x98, 0x88, 0x34, 0xf}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29289}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops1}}}, + }; + + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xd3, 0xbf, 0xb5, 0x1e, 0xb7, 0x7a, 0xe3, 0xb3, 0x3f, + 0x31, 0x2, 0x71, 0xce, 0x5d, 0x8e, 0xd3, 0x76, 0x58}; + uint8_t byteswillprops1[] = {0xb1, 0xa7, 0xfa, 0x1, 0xba, 0x8, 0x45, 0xe, 0x40}; + uint8_t byteswillprops2[] = {0xb0, 0xad, 0x40, 0x26, 0x43, 0x4, 0xfd, 0x56, 0xb9, 0xe4, + 0xc3, 0xcc, 0xb, 0x8a, 0x61, 0xb0, 0xd, 0xa2, 0xe3, 0x78, + 0x92, 0xb7, 0xcc, 0x8c, 0x21, 0xb8, 0x63, 0x64, 0x18, 0xbf}; + uint8_t byteswillprops3[] = {0xde, 0x7d, 0x82, 0x86, 0xea, 0x6c, 0x7d, 0xc5, 0x2c}; + uint8_t byteswillprops4[] = {0xb, 0xcf, 0x1d, 0x1d, 0xe8, 0xa4, 0xe3}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20521}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26988}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3468}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24720}}, + }; + + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc4, 0xb, 0xca, 0xa8, 0x22, 0x73, 0x11, 0x2b, 0xde, + 0x80, 0x31, 0x8a, 0x59, 0xd0, 0x42, 0x70, 0xb2}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 11823; + uint8_t client_id_bytes[] = {0xd, 0xad, 0x43, 0x35, 0x24, 0x2b, 0x7e, 0x44, 0x6, 0xa9, 0x44, + 0xdc, 0xa0, 0xda, 0x83, 0x21, 0x42, 0x6f, 0xe, 0x9f, 0x48, 0x4e}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xb2}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just +// "M\162\184\&2\161L\154u\186\163\SYN\212\180\192S\137\a\169\&5\208Z\"\a\143{\DC1\246", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS0, _willTopic = +// "p\188\191\217S;m\n\EM\155\NAK\247\182\145\183\SYN\184\152\SUB\153\214-D\b\CAN\128", _willMsg = "\197p\131", +// _willProps = [PropAuthenticationData "BQ\128\208:t}\221E_\254m\210\231\202|qv",PropRequestResponseInformation +// 138,PropAuthenticationMethod +// "\208\240i\131\201msq\"A\NAK\157\EOT\250K\128\&9G\SUB\138i\"\247=\225*t;\191r",PropMessageExpiryInterval +// 26874,PropSubscriptionIdentifierAvailable 65,PropRetainAvailable 163,PropRetainAvailable 42,PropResponseInformation +// "\158\245'",PropWillDelayInterval 25424,PropResponseInformation +// "O\194\210\214\146_\"\198\186\160\ACK\254&\241\150\153\202\212\177`\183P\177\205\&2lW\148;\206",PropSubscriptionIdentifierAvailable +// 209,PropSubscriptionIdentifierAvailable 230,PropAuthenticationMethod +// "(\EOT\161RAV\133\DEL\188\197xc\177j\172R\146\130\220\238",PropTopicAliasMaximum 3668,PropResponseInformation +// "\230\247\249\170\237\ETB\145Y",PropReasonString +// "\173\166\137*,(\240)\226j6\245\146\211\149H\240\136{M\224\185\234",PropUserProperty +// "f\US\212\US\DC23\128a(\n\239\135\173\&2G\197P8" "\FS\212$U?\185V\n",PropMaximumQoS 190,PropServerReference +// "G\DC1\242\144~\188'f\STX&\175\SYN\187\&9J\131|P`\187j\239\163-;\GS\DLE\ETX",PropContentType "",PropRetainAvailable +// 40,PropMaximumQoS 215,PropSessionExpiryInterval 16670,PropAuthenticationMethod +// ">\DLE\193\229c}f;5\140\178\224\DEL`",PropSessionExpiryInterval 15432,PropServerKeepAlive 4678]}), _cleanSession = +// True, _keepAlive = 15472, _connID = "A\231\208\198C*2\172\&2\183\133\223\152\224(\129o\n\180MO\235Z\186\166\f", +// _properties = [PropReasonString +// "d\152+\222\212\199J\202o\181d\255\186\170qx\146y\\(\157\225G",PropMessageExpiryInterval 15061,PropRetainAvailable +// 245,PropMaximumPacketSize 383,PropSharedSubscriptionAvailable 221,PropSubscriptionIdentifierAvailable +// 102,PropTopicAlias 26828,PropRequestProblemInformation 207,PropSharedSubscriptionAvailable +// 151,PropSubscriptionIdentifier 1,PropTopicAliasMaximum 17,PropAuthenticationMethod +// "\ETXU#\142\201",PropAuthenticationData "\170\RSi\150\231\235O\a\SOr9",PropTopicAliasMaximum 3435,PropResponseTopic +// "B\152\165\&8\158\138\US\234\251'\214m\191\239\215\148)\195\245\b\240",PropTopicAlias 8929,PropTopicAliasMaximum +// 23322,PropResponseInformation "\187\178",PropWildcardSubscriptionAvailable 190,PropResponseInformation +// "\FSZb\238",PropReasonString "\160'\137\243\183|\137P\240\253\156\167|\168\158",PropUserProperty +// "\235\193G\GS\148\225vN\215~\233wk\130\131v&\251\243R5_\ncwOlK\212" +// "u\CAN\228\143\135\159\v\214\241\US\220\&1\248]\136",PropAuthenticationData "\DC2k%\nM\SOHc\RS\218\167\227"]} +TEST(Connect5QCTest, Encode23) { + uint8_t pkt[] = { + 0x10, 0xcb, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x66, 0x3c, 0x70, 0xcc, 0x1, 0x1f, 0x0, 0x17, 0x64, + 0x98, 0x2b, 0xde, 0xd4, 0xc7, 0x4a, 0xca, 0x6f, 0xb5, 0x64, 0xff, 0xba, 0xaa, 0x71, 0x78, 0x92, 0x79, 0x5c, 0x28, + 0x9d, 0xe1, 0x47, 0x2, 0x0, 0x0, 0x3a, 0xd5, 0x25, 0xf5, 0x27, 0x0, 0x0, 0x1, 0x7f, 0x2a, 0xdd, 0x29, 0x66, + 0x23, 0x68, 0xcc, 0x17, 0xcf, 0x2a, 0x97, 0xb, 0x1, 0x22, 0x0, 0x11, 0x15, 0x0, 0x5, 0x3, 0x55, 0x23, 0x8e, + 0xc9, 0x16, 0x0, 0xb, 0xaa, 0x1e, 0x69, 0x96, 0xe7, 0xeb, 0x4f, 0x7, 0xe, 0x72, 0x39, 0x22, 0xd, 0x6b, 0x8, + 0x0, 0x15, 0x42, 0x98, 0xa5, 0x38, 0x9e, 0x8a, 0x1f, 0xea, 0xfb, 0x27, 0xd6, 0x6d, 0xbf, 0xef, 0xd7, 0x94, 0x29, + 0xc3, 0xf5, 0x8, 0xf0, 0x23, 0x22, 0xe1, 0x22, 0x5b, 0x1a, 0x1a, 0x0, 0x2, 0xbb, 0xb2, 0x28, 0xbe, 0x1a, 0x0, + 0x4, 0x1c, 0x5a, 0x62, 0xee, 0x1f, 0x0, 0xf, 0xa0, 0x27, 0x89, 0xf3, 0xb7, 0x7c, 0x89, 0x50, 0xf0, 0xfd, 0x9c, + 0xa7, 0x7c, 0xa8, 0x9e, 0x26, 0x0, 0x1d, 0xeb, 0xc1, 0x47,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0x3b, 0x6d, 0xa, 0x19, 0x9b, 0x15, 0xf7, 0xb6, 0x91, 0xb7, 0x16, 0xb8, 0x98, 0x1a, 0x99, 0xd6, + 0x2d, 0x44, 0x8, 0x18, 0x80, 0x0, 0x3, 0xc5, 0x70, 0x83, 0x0, 0x1b, 0x4d, 0xa2, 0xb8, 0x32, 0xa1, 0x4c, 0x9a, + 0x75, 0xba, 0xa3, 0x16, 0xd4, 0xb4, 0xc0, 0x53, 0x89, 0x7, 0xa9, 0x35, 0xd0, 0x5a, 0x22, 0x7, 0x8f, 0x7b, 0x11, + 0xf6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x64, 0x98, 0x2b, 0xde, 0xd4, 0xc7, 0x4a, 0xca, 0x6f, 0xb5, 0x64, 0xff, + 0xba, 0xaa, 0x71, 0x78, 0x92, 0x79, 0x5c, 0x28, 0x9d, 0xe1, 0x47}; + uint8_t bytesprops1[] = {0x3, 0x55, 0x23, 0x8e, 0xc9}; + uint8_t bytesprops2[] = {0xaa, 0x1e, 0x69, 0x96, 0xe7, 0xeb, 0x4f, 0x7, 0xe, 0x72, 0x39}; + uint8_t bytesprops3[] = {0x42, 0x98, 0xa5, 0x38, 0x9e, 0x8a, 0x1f, 0xea, 0xfb, 0x27, 0xd6, + 0x6d, 0xbf, 0xef, 0xd7, 0x94, 0x29, 0xc3, 0xf5, 0x8, 0xf0}; + uint8_t bytesprops4[] = {0xbb, 0xb2}; + uint8_t bytesprops5[] = {0x1c, 0x5a, 0x62, 0xee}; + uint8_t bytesprops6[] = {0xa0, 0x27, 0x89, 0xf3, 0xb7, 0x7c, 0x89, 0x50, 0xf0, 0xfd, 0x9c, 0xa7, 0x7c, 0xa8, 0x9e}; + uint8_t bytesprops8[] = {0x75, 0x18, 0xe4, 0x8f, 0x87, 0x9f, 0xb, 0xd6, 0xf1, 0x1f, 0xdc, 0x31, 0xf8, 0x5d, 0x88}; + uint8_t bytesprops7[] = {0xeb, 0xc1, 0x47, 0x1d, 0x94, 0xe1, 0x76, 0x4e, 0xd7, 0x7e, 0xe9, 0x77, 0x6b, 0x82, 0x83, + 0x76, 0x26, 0xfb, 0xf3, 0x52, 0x35, 0x5f, 0xa, 0x63, 0x77, 0x4f, 0x6c, 0x4b, 0xd4}; + uint8_t bytesprops9[] = {0x12, 0x6b, 0x25, 0xa, 0x4d, 0x1, 0x63, 0x1e, 0xda, 0xa7, 0xe3}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15061}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 383}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26828}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3435}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8929}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23322}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops7}, .v = {15, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops9}}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x42, 0x51, 0x80, 0xd0, 0x3a, 0x74, 0x7d, 0xdd, 0x45, + 0x5f, 0xfe, 0x6d, 0xd2, 0xe7, 0xca, 0x7c, 0x71, 0x76}; + uint8_t byteswillprops1[] = {0xd0, 0xf0, 0x69, 0x83, 0xc9, 0x6d, 0x73, 0x71, 0x22, 0x41, + 0x15, 0x9d, 0x4, 0xfa, 0x4b, 0x80, 0x39, 0x47, 0x1a, 0x8a, + 0x69, 0x22, 0xf7, 0x3d, 0xe1, 0x2a, 0x74, 0x3b, 0xbf, 0x72}; + uint8_t byteswillprops2[] = {0x9e, 0xf5, 0x27}; + uint8_t byteswillprops3[] = {0x4f, 0xc2, 0xd2, 0xd6, 0x92, 0x5f, 0x22, 0xc6, 0xba, 0xa0, + 0x6, 0xfe, 0x26, 0xf1, 0x96, 0x99, 0xca, 0xd4, 0xb1, 0x60, + 0xb7, 0x50, 0xb1, 0xcd, 0x32, 0x6c, 0x57, 0x94, 0x3b, 0xce}; + uint8_t byteswillprops4[] = {0x28, 0x4, 0xa1, 0x52, 0x41, 0x56, 0x85, 0x7f, 0xbc, 0xc5, + 0x78, 0x63, 0xb1, 0x6a, 0xac, 0x52, 0x92, 0x82, 0xdc, 0xee}; + uint8_t byteswillprops5[] = {0xe6, 0xf7, 0xf9, 0xaa, 0xed, 0x17, 0x91, 0x59}; + uint8_t byteswillprops6[] = {0xad, 0xa6, 0x89, 0x2a, 0x2c, 0x28, 0xf0, 0x29, 0xe2, 0x6a, 0x36, 0xf5, + 0x92, 0xd3, 0x95, 0x48, 0xf0, 0x88, 0x7b, 0x4d, 0xe0, 0xb9, 0xea}; + uint8_t byteswillprops8[] = {0x1c, 0xd4, 0x24, 0x55, 0x3f, 0xb9, 0x56, 0xa}; + uint8_t byteswillprops7[] = {0x66, 0x1f, 0xd4, 0x1f, 0x12, 0x33, 0x80, 0x61, 0x28, + 0xa, 0xef, 0x87, 0xad, 0x32, 0x47, 0xc5, 0x50, 0x38}; + uint8_t byteswillprops9[] = {0x47, 0x11, 0xf2, 0x90, 0x7e, 0xbc, 0x27, 0x66, 0x2, 0x26, 0xaf, 0x16, 0xbb, 0x39, + 0x4a, 0x83, 0x7c, 0x50, 0x60, 0xbb, 0x6a, 0xef, 0xa3, 0x2d, 0x3b, 0x1d, 0x10, 0x3}; + uint8_t byteswillprops10[] = {0}; + uint8_t byteswillprops11[] = {0x3e, 0x10, 0xc1, 0xe5, 0x63, 0x7d, 0x66, 0x3b, 0x35, 0x8c, 0xb2, 0xe0, 0x7f, 0x60}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26874}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25424}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3668}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {18, (char*)&byteswillprops7}, .v = {8, (char*)&byteswillprops8}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16670}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15432}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4678}}, + }; + + lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x70, 0xbc, 0xbf, 0xd9, 0x53, 0x3b, 0x6d, 0xa, 0x19, 0x9b, 0x15, 0xf7, 0xb6, + 0x91, 0xb7, 0x16, 0xb8, 0x98, 0x1a, 0x99, 0xd6, 0x2d, 0x44, 0x8, 0x18, 0x80}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc5, 0x70, 0x83}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 15472; + uint8_t client_id_bytes[] = {0x41, 0xe7, 0xd0, 0xc6, 0x43, 0x2a, 0x32, 0xac, 0x32, 0xb7, 0x85, 0xdf, 0x98, + 0xe0, 0x28, 0x81, 0x6f, 0xa, 0xb4, 0x4d, 0x4f, 0xeb, 0x5a, 0xba, 0xa6, 0xc}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x4d, 0xa2, 0xb8, 0x32, 0xa1, 0x4c, 0x9a, 0x75, 0xba, 0xa3, 0x16, 0xd4, 0xb4, 0xc0, + 0x53, 0x89, 0x7, 0xa9, 0x35, 0xd0, 0x5a, 0x22, 0x7, 0x8f, 0x7b, 0x11, 0xf6}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\ni\175J\146\197o\130\201\&8@\212x\172\ENQ\SOH!\164dU\\M\248\216\189", _password = +// Just "\EOT\128\CAN\203[\240\SYN\b", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "\135\ESC\DLE|c.\180\189\232p\195\155\171=\246", _willMsg = +// "\137\150\171\227\191\DC2[m\203I\160\176\SO\193A\238\210F\180@$4\176\&8N\172\&5\234KO", _willProps = +// [PropSessionExpiryInterval 7133,PropUserProperty "\133Y?Y\179\206j\f\146\216L" +// "\243I\230",PropSubscriptionIdentifierAvailable 154,PropWildcardSubscriptionAvailable 226,PropAuthenticationMethod +// "\175\DC1\135\187\187\SOH\GS\FS\FSu'nj\129\240\&2&\233B\n\189\157",PropUserProperty +// "\EM\190{\130\213\171\144Ioy8\228\SIC\237\190;~\156{a\234" "\205*\174g\DC3",PropSubscriptionIdentifierAvailable +// 67,PropCorrelationData "E\243\234)n\145F\214\248F\214\182\190\ESC\GS\140{A",PropSubscriptionIdentifierAvailable +// 137,PropResponseInformation "f\DC1\227OJ\232k@r\178\STX\136\146M:)",PropMessageExpiryInterval +// 6568,PropPayloadFormatIndicator 105,PropResponseTopic "f",PropWillDelayInterval 30594,PropContentType +// "\245",PropRequestProblemInformation 216,PropAssignedClientIdentifier +// "\190\&9\vW~\162<\201\185\245j",PropResponseTopic +// "\189\186\246\132\145\NAKB\199\135r\148.\ACKs@[C(",PropMessageExpiryInterval 14746,PropMessageExpiryInterval +// 353,PropRetainAvailable 177,PropMaximumQoS 254,PropSessionExpiryInterval 5276,PropUserProperty +// "a\CAN^\200*\186\ETBb\211\239]%:\231\242" "",PropReasonString ";\191",PropContentType +// "72[9\149\CANs\178\&1\183\162\&0\238\151\ENQ\205cO\FS\235",PropAuthenticationMethod +// "C\223a\251\215\219UQ\138\&8\189",PropRequestResponseInformation 200]}), _cleanSession = True, _keepAlive = 17924, +// _connID = "a\NUL\161\b\145\247$\148\&9^N\209\CAN\SOHT\150\176%'\199\214\&5\131\202\185\208\145E1N", _properties = +// [PropRequestResponseInformation 82,PropAssignedClientIdentifier "i\141\231",PropAssignedClientIdentifier +// "@,L<\DC3\175\211q\162\&6?\tE",PropRetainAvailable 41,PropMaximumQoS 198,PropSubscriptionIdentifier +// 23,PropAssignedClientIdentifier +// "G\150\136\239$;\t\DC2\142\242k\NUL\FS[\239\STX\ESC\255KT\203\236\186&B",PropUserProperty "\241\244M\136.\242\167" +// "\188\143\"`\225K\207E\231\180\SUB9$M\147\193\142\174\230\231\t\SYNRS*\FS\235g,",PropServerReference +// "\t\192&\235\169\218\237\146\239u\201"]} +TEST(Connect5QCTest, Encode24) { + uint8_t pkt[] = { + 0x10, 0x81, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x46, 0x4, 0x71, 0x19, 0x52, 0x12, 0x0, 0x3, + 0x69, 0x8d, 0xe7, 0x12, 0x0, 0xd, 0x40, 0x2c, 0x4c, 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a2, 0x30, 0xee, 0x97, 0x5, 0xcd, 0x63, 0x4f, 0x1c, 0xeb, 0x15, 0x0, 0xb, 0x43, + 0xdf, 0x61, 0xfb, 0xd7, 0xdb, 0x55, 0x51, 0x8a, 0x38, 0xbd, 0x19, 0xc8, 0x0, 0xf, 0x87, 0x1b, 0x10, 0x7c, 0x63, + 0x2e, 0xb4, 0xbd, 0xe8, 0x70, 0xc3, 0x9b, 0xab, 0x3d, 0xf6, 0x0, 0x1e, 0x89, 0x96, 0xab, 0xe3, 0xbf, 0x12, 0x5b, + 0x6d, 0xcb, 0x49, 0xa0, 0xb0, 0xe, 0xc1, 0x41, 0xee, 0xd2, 0x46, 0xb4, 0x40, 0x24, 0x34, 0xb0, 0x38, 0x4e, 0xac, + 0x35, 0xea, 0x4b, 0x4f, 0x0, 0x19, 0xa, 0x69, 0xaf, 0x4a, 0x92, 0xc5, 0x6f, 0x82, 0xc9, 0x38, 0x40, 0xd4, 0x78, + 0xac, 0x5, 0x1, 0x21, 0xa4, 0x64, 0x55, 0x5c, 0x4d, 0xf8, 0xd8, 0xbd, 0x0, 0x8, 0x4, 0x80, 0x18, 0xcb, 0x5b, + 0xf0, 0x16, 0x8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x69, 0x8d, 0xe7}; + uint8_t bytesprops1[] = {0x40, 0x2c, 0x4c, 0x3c, 0x13, 0xaf, 0xd3, 0x71, 0xa2, 0x36, 0x3f, 0x9, 0x45}; + uint8_t bytesprops2[] = {0x47, 0x96, 0x88, 0xef, 0x24, 0x3b, 0x9, 0x12, 0x8e, 0xf2, 0x6b, 0x0, 0x1c, + 0x5b, 0xef, 0x2, 0x1b, 0xff, 0x4b, 0x54, 0xcb, 0xec, 0xba, 0x26, 0x42}; + uint8_t bytesprops4[] = {0xbc, 0x8f, 0x22, 0x60, 0xe1, 0x4b, 0xcf, 0x45, 0xe7, 0xb4, 0x1a, 0x39, 0x24, 0x4d, 0x93, + 0xc1, 0x8e, 0xae, 0xe6, 0xe7, 0x9, 0x16, 0x52, 0x53, 0x2a, 0x1c, 0xeb, 0x67, 0x2c}; + uint8_t bytesprops3[] = {0xf1, 0xf4, 0x4d, 0x88, 0x2e, 0xf2, 0xa7}; + uint8_t bytesprops5[] = {0x9, 0xc0, 0x26, 0xeb, 0xa9, 0xda, 0xed, 0x92, 0xef, 0x75, 0xc9}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {29, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops5}}}, + }; + + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xf3, 0x49, 0xe6}; + uint8_t byteswillprops0[] = {0x85, 0x59, 0x3f, 0x59, 0xb3, 0xce, 0x6a, 0xc, 0x92, 0xd8, 0x4c}; + uint8_t byteswillprops2[] = {0xaf, 0x11, 0x87, 0xbb, 0xbb, 0x1, 0x1d, 0x1c, 0x1c, 0x75, 0x27, + 0x6e, 0x6a, 0x81, 0xf0, 0x32, 0x26, 0xe9, 0x42, 0xa, 0xbd, 0x9d}; + uint8_t byteswillprops4[] = {0xcd, 0x2a, 0xae, 0x67, 0x13}; + uint8_t byteswillprops3[] = {0x19, 0xbe, 0x7b, 0x82, 0xd5, 0xab, 0x90, 0x49, 0x6f, 0x79, 0x38, + 0xe4, 0xf, 0x43, 0xed, 0xbe, 0x3b, 0x7e, 0x9c, 0x7b, 0x61, 0xea}; + uint8_t byteswillprops5[] = {0x45, 0xf3, 0xea, 0x29, 0x6e, 0x91, 0x46, 0xd6, 0xf8, + 0x46, 0xd6, 0xb6, 0xbe, 0x1b, 0x1d, 0x8c, 0x7b, 0x41}; + uint8_t byteswillprops6[] = {0x66, 0x11, 0xe3, 0x4f, 0x4a, 0xe8, 0x6b, 0x40, + 0x72, 0xb2, 0x2, 0x88, 0x92, 0x4d, 0x3a, 0x29}; + uint8_t byteswillprops7[] = {0x66}; + uint8_t byteswillprops8[] = {0xf5}; + uint8_t byteswillprops9[] = {0xbe, 0x39, 0xb, 0x57, 0x7e, 0xa2, 0x3c, 0xc9, 0xb9, 0xf5, 0x6a}; + uint8_t byteswillprops10[] = {0xbd, 0xba, 0xf6, 0x84, 0x91, 0x15, 0x42, 0xc7, 0x87, + 0x72, 0x94, 0x2e, 0x6, 0x73, 0x40, 0x5b, 0x43, 0x28}; + uint8_t byteswillprops12[] = {0}; + uint8_t byteswillprops11[] = {0x61, 0x18, 0x5e, 0xc8, 0x2a, 0xba, 0x17, 0x62, + 0xd3, 0xef, 0x5d, 0x25, 0x3a, 0xe7, 0xf2}; + uint8_t byteswillprops13[] = {0x3b, 0xbf}; + uint8_t byteswillprops14[] = {0x37, 0x32, 0x5b, 0x39, 0x95, 0x18, 0x73, 0xb2, 0x31, 0xb7, + 0xa2, 0x30, 0xee, 0x97, 0x5, 0xcd, 0x63, 0x4f, 0x1c, 0xeb}; + uint8_t byteswillprops15[] = {0x43, 0xdf, 0x61, 0xfb, 0xd7, 0xdb, 0x55, 0x51, 0x8a, 0x38, 0xbd}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7133}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {11, (char*)&byteswillprops0}, .v = {3, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {22, (char*)&byteswillprops3}, .v = {5, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6568}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30594}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14746}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 353}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5276}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {15, (char*)&byteswillprops11}, .v = {0, (char*)&byteswillprops12}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops13}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&byteswillprops14}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&byteswillprops15}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 200}}, + }; + + lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x87, 0x1b, 0x10, 0x7c, 0x63, 0x2e, 0xb4, 0xbd, + 0xe8, 0x70, 0xc3, 0x9b, 0xab, 0x3d, 0xf6}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x89, 0x96, 0xab, 0xe3, 0xbf, 0x12, 0x5b, 0x6d, 0xcb, 0x49, + 0xa0, 0xb0, 0xe, 0xc1, 0x41, 0xee, 0xd2, 0x46, 0xb4, 0x40, + 0x24, 0x34, 0xb0, 0x38, 0x4e, 0xac, 0x35, 0xea, 0x4b, 0x4f}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 17924; + uint8_t client_id_bytes[] = {0x61, 0x0, 0xa1, 0x8, 0x91, 0xf7, 0x24, 0x94, 0x39, 0x5e, + 0x4e, 0xd1, 0x18, 0x1, 0x54, 0x96, 0xb0, 0x25, 0x27, 0xc7, + 0xd6, 0x35, 0x83, 0xca, 0xb9, 0xd0, 0x91, 0x45, 0x31, 0x4e}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa, 0x69, 0xaf, 0x4a, 0x92, 0xc5, 0x6f, 0x82, 0xc9, 0x38, 0x40, 0xd4, 0x78, + 0xac, 0x5, 0x1, 0x21, 0xa4, 0x64, 0x55, 0x5c, 0x4d, 0xf8, 0xd8, 0xbd}; + lwmqtt_string_t username = {25, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x4, 0x80, 0x18, 0xcb, 0x5b, 0xf0, 0x16, 0x8}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "x\197,\208\aUF\242|z\244", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "9*J\v\172B:vV\252\US>YCPMxm", _willMsg = ">N", _willProps = +// [PropResponseTopic "Y\229",PropSharedSubscriptionAvailable 70,PropContentType +// "<}\160\148l\ETB\238\154\EOT\232\EM$}\231\218x\137\DC4\169\175\221\204\133\167\SOHS\145\147\240",PropRetainAvailable +// 142,PropServerKeepAlive 14211,PropMaximumPacketSize 12577,PropRequestProblemInformation 214,PropTopicAlias +// 18149,PropSessionExpiryInterval 6991,PropAuthenticationMethod "i\178",PropResponseTopic +// "\195\189\&2\183##\DLEC\198\145v\158\239\138\240\149\221\142_ep\229\192\252\252>\180",PropMaximumQoS +// 69,PropCorrelationData "y\STX\248",PropWillDelayInterval 2012,PropResponseTopic +// "\rB\197X\146\DLE\200\DC1#e\t\ACKz\v\141\229Kj\130\184\DC3",PropSubscriptionIdentifierAvailable 50,PropResponseTopic +// "\210\251wL \"\253\217\215\&5\191",PropWildcardSubscriptionAvailable 80]}), _cleanSession = False, _keepAlive = 8679, +// _connID = "\155\132j\168 \215\255w\SO\227", _properties = []} +TEST(Connect5QCTest, Encode25) { + uint8_t pkt[] = {0x10, 0xd3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x74, 0x21, 0xe7, 0x0, 0x0, 0xa, 0x9b, + 0x84, 0x6a, 0xa8, 0x20, 0xd7, 0xff, 0x77, 0xe, 0xe3, 0x95,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8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x59, 0xe5}; + uint8_t byteswillprops1[] = {0x3c, 0x7d, 0xa0, 0x94, 0x6c, 0x17, 0xee, 0x9a, 0x4, 0xe8, 0x19, 0x24, 0x7d, 0xe7, 0xda, + 0x78, 0x89, 0x14, 0xa9, 0xaf, 0xdd, 0xcc, 0x85, 0xa7, 0x1, 0x53, 0x91, 0x93, 0xf0}; + uint8_t byteswillprops2[] = {0x69, 0xb2}; + uint8_t byteswillprops3[] = {0xc3, 0xbd, 0x32, 0xb7, 0x23, 0x23, 0x10, 0x43, 0xc6, 0x91, 0x76, 0x9e, 0xef, 0x8a, + 0xf0, 0x95, 0xdd, 0x8e, 0x5f, 0x65, 0x70, 0xe5, 0xc0, 0xfc, 0xfc, 0x3e, 0xb4}; + uint8_t byteswillprops4[] = {0x79, 0x2, 0xf8}; + uint8_t byteswillprops5[] = {0xd, 0x42, 0xc5, 0x58, 0x92, 0x10, 0xc8, 0x11, 0x23, 0x65, 0x9, + 0x6, 0x7a, 0xb, 0x8d, 0xe5, 0x4b, 0x6a, 0x82, 0xb8, 0x13}; + uint8_t byteswillprops6[] = {0xd2, 0xfb, 0x77, 0x4c, 0x20, 0x22, 0xfd, 0xd9, 0xd7, 0x35, 0xbf}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14211}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12577}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18149}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6991}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2012}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 80}}, + }; + + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x39, 0x2a, 0x4a, 0xb, 0xac, 0x42, 0x3a, 0x76, 0x56, + 0xfc, 0x1f, 0x3e, 0x59, 0x43, 0x50, 0x4d, 0x78, 0x6d}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3e, 0x4e}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 8679; + uint8_t client_id_bytes[] = {0x9b, 0x84, 0x6a, 0xa8, 0x20, 0xd7, 0xff, 0x77, 0xe, 0xe3}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x78, 0xc5, 0x2c, 0xd0, 0x7, 0x55, 0x46, 0xf2, 0x7c, 0x7a, 0xf4}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "#*\SUB\197/r\203", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS0, _willTopic = "G@v wb\253\GSb\212", _willMsg = +// "\SYN\"mo\233lbY\DC3\160\156\230\206`\226J|\232", _willProps = [PropRetainAvailable 151,PropContentType +// "D\"\200\154\225\209\RS6t\244\230\STX\137\242\173Cr\DC2\187\244\140",PropAuthenticationData +// ".\171\DC3\196\128\139\146\170b\253\161",PropSharedSubscriptionAvailable 227,PropMessageExpiryInterval +// 4451,PropWildcardSubscriptionAvailable 107,PropSessionExpiryInterval 27000,PropRetainAvailable +// 98,PropPayloadFormatIndicator 23,PropUserProperty "\208y\151M\DC4\138\&6J$\170\DC1\152\208\243\ENQ\194\196\tm\SO789c" +// "\DC34\141\STX\SYNW\247\152r'\149\252Z\140$\t\ENQ[\143",PropResponseInformation +// "\STXq[\174\156\&0",PropResponseInformation "yl!\212\254 fp\180\ETBf\168j",PropResponseTopic +// "\254",PropRequestResponseInformation 67,PropRequestProblemInformation 67,PropPayloadFormatIndicator +// 234,PropCorrelationData "\128\189t\223\b\189\226\198p\131\173\224\225\249x\206\207DJ",PropContentType +// ">\185v\229I",PropReasonString "d\150\"\186\234\ESCxL9\167\144\217\SYN",PropReasonString +// "\254\205\DEL\181T\130$\200\SOH]\132\207",PropMaximumPacketSize 9973,PropAuthenticationMethod +// "\151s\235p\224\&1\t\222`\244JG\fu$\NUL\181\148\247\210\139\&3\157\255\b\239Z"]}), _cleanSession = True, _keepAlive = +// 17750, _connID = "\178Y\174\187MI\NAK\186F\SYN\139\138\235u\SOH\197Q", _properties = [PropPayloadFormatIndicator +// 184,PropRequestResponseInformation 159,PropReasonString "\234\166\&9\DLE\203",PropWildcardSubscriptionAvailable +// 49,PropMessageExpiryInterval 16879,PropWildcardSubscriptionAvailable 116,PropSubscriptionIdentifier +// 15,PropSharedSubscriptionAvailable 140,PropReasonString +// "!Roq\\\148%\240\243\ESC)\205\163\159\182\226\251\246\159",PropResponseTopic +// "\209Q",PropSubscriptionIdentifierAvailable 215,PropContentType "\203\&0\135\186J1i\167",PropResponseInformation +// "\138\aF\170\198\175\209 b\157\212k\223.\186zq\184\137\168\&6\189\EM?",PropSharedSubscriptionAvailable +// 47,PropContentType "\175}\128\GS\DLE}\163\188r]\239\SYN",PropWillDelayInterval 23909,PropMessageExpiryInterval +// 9674,PropServerReference "\203\197\148p\220\199)",PropServerReference "'8",PropMaximumPacketSize +// 16109,PropRequestResponseInformation 38,PropSubscriptionIdentifierAvailable 106,PropAuthenticationData +// "\193g1\210\244\177\149\194z\130\n\173\246\162\ETXv|0\212g6\173\180\202\128[m&",PropAuthenticationMethod +// "x\177\179T\138\255\213\255ge[\STX\179\211\145\201\195^",PropTopicAliasMaximum +// 30987,PropWildcardSubscriptionAvailable 116,PropTopicAliasMaximum 21660,PropSharedSubscriptionAvailable +// 115,PropCorrelationData "\152\159W\164&K\133q\208(\228",PropMessageExpiryInterval 21351]} +TEST(Connect5QCTest, Encode26) { + uint8_t pkt[] = { + 0x10, 0xc9, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x86, 0x45, 0x56, 0xe6, 0x1, 0x1, 0xb8, 0x19, 0x9f, + 0x1f, 0x0, 0x5, 0xea, 0xa6, 0x39, 0x10, 0xcb, 0x28, 0x31, 0x2, 0x0, 0x0, 0x41, 0xef, 0x28, 0x74, 0xb, 0xf, + 0x2a, 0x8c, 0x1f, 0x0, 0x19, 0x21, 0x52, 0x3c, 0x73, 0x61, 0x62, 0xe3, 0x3e, 0x6f, 0x71, 0x5c, 0x94, 0x25, 0xf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 0xfe, 0x20, 0x66, 0x70, 0xb4, + 0x17, 0x66, 0xa8, 0x6a, 0x8, 0x0, 0x1, 0xfe, 0x19, 0x43, 0x17, 0x43, 0x1, 0xea, 0x9, 0x0, 0x13, 0x80, 0xbd, + 0x74, 0xdf, 0x8, 0xbd, 0xe2, 0xc6, 0x70, 0x83, 0xad, 0xe0, 0xe1, 0xf9, 0x78, 0xce, 0xcf, 0x44, 0x4a, 0x3, 0x0, + 0x5, 0x3e, 0xb9, 0x76, 0xe5, 0x49, 0x1f, 0x0, 0xd, 0x64, 0x96, 0x22, 0xba, 0xea, 0x1b, 0x78, 0x4c, 0x39, 0xa7, + 0x90, 0xd9, 0x16, 0x1f, 0x0, 0xc, 0xfe, 0xcd, 0x7f, 0xb5, 0x54, 0x82, 0x24, 0xc8, 0x1, 0x5d, 0x84, 0xcf, 0x27, + 0x0, 0x0, 0x26, 0xf5, 0x15, 0x0, 0x1b, 0x97, 0x73, 0xeb, 0x70, 0xe0, 0x31, 0x9, 0xde, 0x60, 0xf4, 0x4a, 0x47, + 0xc, 0x75, 0x24, 0x0, 0xb5, 0x94, 0xf7, 0xd2, 0x8b, 0x33, 0x9d, 0xff, 0x8, 0xef, 0x5a, 0x0, 0xa, 0x47, 0x40, + 0x76, 0x20, 0x77, 0x62, 0xfd, 0x1d, 0x62, 0xd4, 0x0, 0x12, 0x16, 0x22, 0x6d, 0x6f, 0xe9, 0x6c, 0x62, 0x59, 0x13, + 0xa0, 0x9c, 0xe6, 0xce, 0x60, 0xe2, 0x4a, 0x7c, 0xe8, 0x0, 0x7, 0x23, 0x2a, 0x1a, 0xc5, 0x2f, 0x72, 0xcb}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xea, 0xa6, 0x39, 0x10, 0xcb}; + uint8_t bytesprops1[] = {0x21, 0x52, 0x3c, 0x73, 0x61, 0x62, 0xe3, 0x3e, 0x6f, 0x71, 0x5c, 0x94, 0x25, + 0xf0, 0xf3, 0x1b, 0x29, 0xcd, 0xa3, 0x9f, 0xb6, 0xe2, 0xfb, 0xf6, 0x9f}; + uint8_t bytesprops2[] = {0xd1, 0x51}; + uint8_t bytesprops3[] = {0xcb, 0x30, 0x87, 0xba, 0x4a, 0x31, 0x69, 0xa7}; + uint8_t bytesprops4[] = {0x8a, 0x7, 0x46, 0xaa, 0xc6, 0xaf, 0xd1, 0x20, 0x62, 0x9d, 0xd4, 0x6b, + 0xdf, 0x2e, 0xba, 0x7a, 0x71, 0xb8, 0x89, 0xa8, 0x36, 0xbd, 0x19, 0x3f}; + uint8_t bytesprops5[] = {0xaf, 0x7d, 0x80, 0x1d, 0x10, 0x7d, 0xa3, 0xbc, 0x72, 0x5d, 0xef, 0x16}; + uint8_t bytesprops6[] = {0xcb, 0xc5, 0x94, 0x70, 0xdc, 0xc7, 0x29}; + uint8_t bytesprops7[] = {0x27, 0x38}; + uint8_t bytesprops8[] = {0xc1, 0x67, 0x31, 0xd2, 0xf4, 0xb1, 0x95, 0xc2, 0x7a, 0x82, 0xa, 0xad, 0xf6, 0xa2, + 0x3, 0x76, 0x7c, 0x30, 0xd4, 0x67, 0x36, 0xad, 0xb4, 0xca, 0x80, 0x5b, 0x6d, 0x26}; + uint8_t bytesprops9[] = {0x78, 0xb1, 0xb3, 0x54, 0x8a, 0xff, 0xd5, 0xff, 0x67, + 0x65, 0x5b, 0x2, 0xb3, 0xd3, 0x91, 0xc9, 0xc3, 0x5e}; + uint8_t bytesprops10[] = {0x98, 0x9f, 0x57, 0xa4, 0x26, 0x4b, 0x85, 0x71, 0xd0, 0x28, 0xe4}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16879}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23909}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9674}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16109}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30987}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21660}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21351}}, + }; + + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x44, 0x22, 0xc8, 0x9a, 0xe1, 0xd1, 0x1e, 0x36, 0x74, 0xf4, 0x3c, 0x48, 0xd7, + 0xc7, 0xdc, 0x78, 0xed, 0x54, 0x51, 0xe6, 0xe0, 0xe, 0xae, 0xcb, 0x6d}; + uint8_t byteswillprops1[] = {0x25, 0x7e, 0x8e, 0x26, 0x4c, 0x11, 0x3, 0x9f, 0x69, 0xf5, 0x91, 0x90, 0x83, 0xd2, + 0xdb, 0x3e, 0xe6, 0x2, 0x89, 0xf2, 0xad, 0x43, 0x72, 0x12, 0xbb, 0xf4, 0x8c}; + uint8_t byteswillprops2[] = {0x2e, 0xab, 0x13, 0xc4, 0x80, 0x8b, 0x92, 0xaa, 0x62, 0xfd, 0xa1}; + uint8_t byteswillprops4[] = {0x13, 0x34, 0x8d, 0x2, 0x16, 0x57, 0xf7, 0x98, 0x72, 0x27, + 0x95, 0xfc, 0x5a, 0x8c, 0x24, 0x9, 0x5, 0x5b, 0x8f}; + uint8_t byteswillprops3[] = {0xd0, 0x79, 0x97, 0x4d, 0x14, 0x8a, 0x36, 0x4a, 0x24, 0xaa, 0x11, 0x98, + 0xd0, 0xf3, 0x5, 0xc2, 0xc4, 0x9, 0x6d, 0xe, 0x37, 0x38, 0x39, 0x63}; + uint8_t byteswillprops5[] = {0x2, 0x71, 0x5b, 0xae, 0x9c, 0x30}; + uint8_t byteswillprops6[] = {0x79, 0x6c, 0x21, 0xd4, 0xfe, 0x20, 0x66, 0x70, 0xb4, 0x17, 0x66, 0xa8, 0x6a}; + uint8_t byteswillprops7[] = {0xfe}; + uint8_t byteswillprops8[] = {0x80, 0xbd, 0x74, 0xdf, 0x8, 0xbd, 0xe2, 0xc6, 0x70, 0x83, + 0xad, 0xe0, 0xe1, 0xf9, 0x78, 0xce, 0xcf, 0x44, 0x4a}; + uint8_t byteswillprops9[] = {0x3e, 0xb9, 0x76, 0xe5, 0x49}; + uint8_t byteswillprops10[] = {0x64, 0x96, 0x22, 0xba, 0xea, 0x1b, 0x78, 0x4c, 0x39, 0xa7, 0x90, 0xd9, 0x16}; + uint8_t byteswillprops11[] = {0xfe, 0xcd, 0x7f, 0xb5, 0x54, 0x82, 0x24, 0xc8, 0x1, 0x5d, 0x84, 0xcf}; + uint8_t byteswillprops12[] = {0x97, 0x73, 0xeb, 0x70, 0xe0, 0x31, 0x9, 0xde, 0x60, 0xf4, 0x4a, 0x47, 0xc, 0x75, + 0x24, 0x0, 0xb5, 0x94, 0xf7, 0xd2, 0x8b, 0x33, 0x9d, 0xff, 0x8, 0xef, 0x5a}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22847}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27627}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4451}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27000}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {24, (char*)&byteswillprops3}, .v = {19, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9973}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&byteswillprops12}}}, + }; + + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x47, 0x40, 0x76, 0x20, 0x77, 0x62, 0xfd, 0x1d, 0x62, 0xd4}; + lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x16, 0x22, 0x6d, 0x6f, 0xe9, 0x6c, 0x62, 0x59, 0x13, + 0xa0, 0x9c, 0xe6, 0xce, 0x60, 0xe2, 0x4a, 0x7c, 0xe8}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 17750; + uint8_t client_id_bytes[] = {0xb2, 0x59, 0xae, 0xbb, 0x4d, 0x49, 0x15, 0xba, 0x46, + 0x16, 0x8b, 0x8a, 0xeb, 0x75, 0x1, 0xc5, 0x51}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x23, 0x2a, 0x1a, 0xc5, 0x2f, 0x72, 0xcb}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just ";<\132\244\&6\148W/\234\225\r\SIO\DC1", _password = Just +// "\243\ACK\180?\176\136\191]UDv\US\f\151|\209\150\NUL", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "\176\CAN\r\146\ESC\214\243U\141F\EM\253\149\231\131\182\203+\164\212'=\232\161\154L\219$", +// _willMsg = "\185\143G\243\136\166\&2xe\156z:|WI\175\185s([H\182\224\143", _willProps = [PropRequestProblemInformation +// 197,PropRetainAvailable 31,PropSessionExpiryInterval 14762,PropSharedSubscriptionAvailable 26,PropUserProperty +// "Ne\191\ACK\246\241\157\200\212" "\255\CANVG\237!\252\STX\238\DC3]'\SYN/\185\186\220?\222;",PropResponseInformation +// "|w\165|\151\164\225\151\181\194\207h\170k\240\SUB\SOH",PropPayloadFormatIndicator 205,PropUserProperty +// "\226\216\173\128\&9\238\156\168,\173G\236\190" "b(\237\195 +// \203\160>\238\174\ESC\167\DC3\217\169N\ESC\136\152L\SYN",PropMessageExpiryInterval 29064,PropMaximumPacketSize +// 25322,PropAssignedClientIdentifier "\207p\243\SOH\163>\148*0\208\224\191gD\174\136d\144\216",PropContentType +// "\ACK,v\177E\145q",PropRequestResponseInformation 19,PropWildcardSubscriptionAvailable 230,PropMaximumPacketSize +// 22647,PropSubscriptionIdentifier 1,PropMessageExpiryInterval 20367,PropRequestProblemInformation +// 27,PropServerKeepAlive 12457,PropRetainAvailable 129,PropTopicAliasMaximum 31953]}), _cleanSession = True, _keepAlive +// = 29887, _connID = "\136\132f\178\182\247\158\133\171t\131\148\168\fR\250d\235\253/\255Y\194\DLE\178", _properties = +// [PropSubscriptionIdentifierAvailable 51,PropServerReference +// "\192%\173\168jy\131\211s\174\228\223[\181\177\208\204+r/\135\245m\228Wew\171\DC1\ENQ",PropWillDelayInterval +// 5471,PropTopicAliasMaximum 27567,PropMessageExpiryInterval 15427,PropAuthenticationMethod "\ACK(\137)\146\128#~\212 +// \142\248\180\200u\195\141\DLE{:e9\209p\v\217\147\248\233",PropPayloadFormatIndicator 255,PropReasonString +// "~T\157I\v\198X\206N\184\NUL \EM\RS\230{\RS]a7\193\255\201",PropSharedSubscriptionAvailable 41,PropMaximumPacketSize +// 24039,PropReasonString "B\231^\138\250\225*>D\144`\185\192\128\173\167",PropMessageExpiryInterval +// 27240,PropPayloadFormatIndicator 135,PropUserProperty "(rRr\253 \148\132^\247V\183k\RS\180\240\163\200b\f\202" +// "N\ESC\RSk\201\164\&7\142\129\153\237\205F\223\242]\153~\235\SYNF\205\RS",PropRequestResponseInformation +// 244,PropSessionExpiryInterval 29932,PropSessionExpiryInterval 17734,PropReasonString +// "\197UBu\148oD\173\SIp\136$W\162\181\244e\153\192\131\189\232\129H\NAKU",PropSessionExpiryInterval +// 25285,PropMessageExpiryInterval 26956,PropAuthenticationData "\206\228\201\221\b\174\231$\140 \v\192\163="]} +TEST(Connect5QCTest, Encode27) { + uint8_t pkt[] = { + 0x10, 0xb5, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x74, 0xbf, 0x82, 0x2, 0x29, 0x33, 0x1c, 0x0, + 0x1e, 0xc0, 0x25, 0xad, 0xa8, 0x6a, 0x79, 0x83, 0xd3, 0x73, 0xae, 0xe4, 0xdf, 0x5b, 0xb5, 0xb1, 0xd0, 0xcc, 0x2b, + 0x72, 0x2f, 0x87, 0xf5, 0x6d, 0xe4, 0x57, 0x65, 0x77, 0xab, 0x11, 0x5, 0x18, 0x0, 0x0, 0x15, 0x5f, 0x22, 0x6b, + 0xaf,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0xbf, 0x67, 0x44, 0xae, 0x88, + 0x64, 0x90, 0xd8, 0x3, 0x0, 0x7, 0x6, 0x2c, 0x76, 0xb1, 0x45, 0x91, 0x71, 0x19, 0x13, 0x28, 0xe6, 0x27, 0x0, + 0x0, 0x58, 0x77, 0xb, 0x1, 0x2, 0x0, 0x0, 0x4f, 0x8f, 0x17, 0x1b, 0x13, 0x30, 0xa9, 0x25, 0x81, 0x22, 0x7c, + 0xd1, 0x0, 0x1c, 0xb0, 0x18, 0xd, 0x92, 0x1b, 0xd6, 0xf3, 0x55, 0x8d, 0x46, 0x19, 0xfd, 0x95, 0xe7, 0x83, 0xb6, + 0xcb, 0x2b, 0xa4, 0xd4, 0x27, 0x3d, 0xe8, 0xa1, 0x9a, 0x4c, 0xdb, 0x24, 0x0, 0x18, 0xb9, 0x8f, 0x47, 0xf3, 0x88, + 0xa6, 0x32, 0x78, 0x65, 0x9c, 0x7a, 0x3a, 0x7c, 0x57, 0x49, 0xaf, 0xb9, 0x73, 0x28, 0x5b, 0x48, 0xb6, 0xe0, 0x8f, + 0x0, 0xe, 0x3b, 0x3c, 0x84, 0xf4, 0x36, 0x94, 0x57, 0x2f, 0xea, 0xe1, 0xd, 0xf, 0x4f, 0x11, 0x0, 0x12, 0xf3, + 0x6, 0xb4, 0x3f, 0xb0, 0x88, 0xbf, 0x5d, 0x55, 0x44, 0x76, 0x1f, 0xc, 0x97, 0x7c, 0xd1, 0x96, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc0, 0x25, 0xad, 0xa8, 0x6a, 0x79, 0x83, 0xd3, 0x73, 0xae, 0xe4, 0xdf, 0x5b, 0xb5, 0xb1, + 0xd0, 0xcc, 0x2b, 0x72, 0x2f, 0x87, 0xf5, 0x6d, 0xe4, 0x57, 0x65, 0x77, 0xab, 0x11, 0x5}; + uint8_t bytesprops1[] = {0x6, 0x28, 0x89, 0x29, 0x92, 0x80, 0x23, 0x7e, 0xd4, 0x20, 0x8e, 0xf8, 0xb4, 0xc8, 0x75, + 0xc3, 0x8d, 0x10, 0x7b, 0x3a, 0x65, 0x39, 0xd1, 0x70, 0xb, 0xd9, 0x93, 0xf8, 0xe9}; + uint8_t bytesprops2[] = {0x7e, 0x54, 0x9d, 0x49, 0xb, 0xc6, 0x58, 0xce, 0x4e, 0xb8, 0x0, 0x20, + 0x19, 0x1e, 0xe6, 0x7b, 0x1e, 0x5d, 0x61, 0x37, 0xc1, 0xff, 0xc9}; + uint8_t bytesprops3[] = {0x42, 0xe7, 0x5e, 0x8a, 0xfa, 0xe1, 0x2a, 0x3e, + 0x44, 0x90, 0x60, 0xb9, 0xc0, 0x80, 0xad, 0xa7}; + uint8_t bytesprops5[] = {0x4e, 0x1b, 0x1e, 0x6b, 0xc9, 0xa4, 0x37, 0x8e, 0x81, 0x99, 0xed, 0xcd, + 0x46, 0xdf, 0xf2, 0x5d, 0x99, 0x7e, 0xeb, 0x16, 0x46, 0xcd, 0x1e}; + uint8_t bytesprops4[] = {0x28, 0x72, 0x52, 0x72, 0xfd, 0x20, 0x94, 0x84, 0x5e, 0xf7, 0x56, + 0xb7, 0x6b, 0x1e, 0xb4, 0xf0, 0xa3, 0xc8, 0x62, 0xc, 0xca}; + uint8_t bytesprops6[] = {0xc5, 0x55, 0x42, 0x75, 0x94, 0x6f, 0x44, 0xad, 0xf, 0x70, 0x88, 0x24, 0x57, + 0xa2, 0xb5, 0xf4, 0x65, 0x99, 0xc0, 0x83, 0xbd, 0xe8, 0x81, 0x48, 0x15, 0x55}; + uint8_t bytesprops7[] = {0xce, 0xe4, 0xc9, 0xdd, 0x8, 0xae, 0xe7, 0x24, 0x8c, 0x20, 0xb, 0xc0, 0xa3, 0x3d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5471}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27567}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15427}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24039}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27240}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops4}, .v = {23, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29932}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17734}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25285}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26956}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops7}}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xff, 0x18, 0x56, 0x47, 0xed, 0x21, 0xfc, 0x2, 0xee, 0x13, + 0x5d, 0x27, 0x16, 0x2f, 0xb9, 0xba, 0xdc, 0x3f, 0xde, 0x3b}; + uint8_t byteswillprops0[] = {0x4e, 0x65, 0xbf, 0x6, 0xf6, 0xf1, 0x9d, 0xc8, 0xd4}; + uint8_t byteswillprops2[] = {0x7c, 0x77, 0xa5, 0x7c, 0x97, 0xa4, 0xe1, 0x97, 0xb5, + 0xc2, 0xcf, 0x68, 0xaa, 0x6b, 0xf0, 0x1a, 0x1}; + uint8_t byteswillprops4[] = {0x62, 0x28, 0xed, 0xc3, 0x20, 0xcb, 0xa0, 0x3e, 0xee, 0xae, 0x1b, + 0xa7, 0x13, 0xd9, 0xa9, 0x4e, 0x1b, 0x88, 0x98, 0x4c, 0x16}; + uint8_t byteswillprops3[] = {0xe2, 0xd8, 0xad, 0x80, 0x39, 0xee, 0x9c, 0xa8, 0x2c, 0xad, 0x47, 0xec, 0xbe}; + uint8_t byteswillprops5[] = {0xcf, 0x70, 0xf3, 0x1, 0xa3, 0x3e, 0x94, 0x2a, 0x30, 0xd0, + 0xe0, 0xbf, 0x67, 0x44, 0xae, 0x88, 0x64, 0x90, 0xd8}; + uint8_t byteswillprops6[] = {0x6, 0x2c, 0x76, 0xb1, 0x45, 0x91, 0x71}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14762}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {9, (char*)&byteswillprops0}, .v = {20, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {13, (char*)&byteswillprops3}, .v = {21, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29064}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25322}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22647}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20367}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12457}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31953}}, + }; + + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb0, 0x18, 0xd, 0x92, 0x1b, 0xd6, 0xf3, 0x55, 0x8d, 0x46, 0x19, 0xfd, 0x95, 0xe7, + 0x83, 0xb6, 0xcb, 0x2b, 0xa4, 0xd4, 0x27, 0x3d, 0xe8, 0xa1, 0x9a, 0x4c, 0xdb, 0x24}; + lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb9, 0x8f, 0x47, 0xf3, 0x88, 0xa6, 0x32, 0x78, 0x65, 0x9c, 0x7a, 0x3a, + 0x7c, 0x57, 0x49, 0xaf, 0xb9, 0x73, 0x28, 0x5b, 0x48, 0xb6, 0xe0, 0x8f}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 29887; + uint8_t client_id_bytes[] = {0x88, 0x84, 0x66, 0xb2, 0xb6, 0xf7, 0x9e, 0x85, 0xab, 0x74, 0x83, 0x94, 0xa8, + 0xc, 0x52, 0xfa, 0x64, 0xeb, 0xfd, 0x2f, 0xff, 0x59, 0xc2, 0x10, 0xb2}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x3b, 0x3c, 0x84, 0xf4, 0x36, 0x94, 0x57, 0x2f, 0xea, 0xe1, 0xd, 0xf, 0x4f, 0x11}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf3, 0x6, 0xb4, 0x3f, 0xb0, 0x88, 0xbf, 0x5d, 0x55, + 0x44, 0x76, 0x1f, 0xc, 0x97, 0x7c, 0xd1, 0x96, 0x0}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\ENQAAE\ACK\174&\128\161wm#W>VC<]\149\152\201\134x:\148\220\243T\\.", _password = +// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// ";\161U\195\&6\138\177I\129\195\USA\DC3", _willMsg = "I\DC1\210\DC3\FS\DC3\242\138\171\211\203\b\190", _willProps = +// [PropRequestProblemInformation 76,PropAuthenticationData "=o(\183X\GS*5\239<\f63\ENQ",PropContentType +// "\159Q\190\186\211\ESC\236U\SO:\224\220GY\ENQ\FS\DC1\DC2\235\211[\SOHN.\233",PropAuthenticationMethod +// "ju\181\SO\DLE\b=\149\128\&1\US\228\128\156\249j",PropMessageExpiryInterval 15727,PropUserProperty "" +// "\ETX}\242\158\EOT^s\237{B\157\159\DC2\161\203\&16\145\DELry\239;\NAK",PropMessageExpiryInterval +// 17769,PropRetainAvailable 163,PropServerReference "A\231\200\&4|",PropAssignedClientIdentifier +// "",PropMaximumPacketSize 3021,PropSubscriptionIdentifierAvailable 79,PropMaximumPacketSize +// 6246,PropRequestProblemInformation 110,PropSubscriptionIdentifier 15,PropReasonString +// "\188@\234\245\138",PropRequestProblemInformation 149,PropWillDelayInterval 16414,PropReceiveMaximum +// 29477,PropRequestResponseInformation 172,PropMaximumQoS 199,PropMessageExpiryInterval 7605,PropTopicAlias +// 1346,PropMaximumPacketSize 9041,PropTopicAliasMaximum 20216,PropSessionExpiryInterval +// 23968,PropRequestProblemInformation 43]}), _cleanSession = True, _keepAlive = 22371, _connID = "\165\EM\181\CAN)62", +// _properties = [PropAuthenticationData "\189 +// \DC4>\197\212ol!\NAK\t%V\145%6S\137\134\230\194\158\SYN[\231\&1\159\DC1X",PropReasonString +// "\171\&6\148a\DC4\158A\SI>=*\255)",PropAuthenticationMethod +// ">\149\144:\222o=L\DC11\246\148\190_\140}V\223\166\195\173\180\240h\154\"\222\206",PropTopicAliasMaximum 5258]} +TEST(Connect5QCTest, Encode28) { + uint8_t pkt[] = { + 0x10, 0xd9, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x86, 0x57, 0x63, 0x52, 0x16, 0x0, 0x1d, 0xbd, 0x20, + 0x14, 0x3e, 0xc5, 0xd4, 0x6f, 0x6c, 0x21, 0x15, 0x9, 0x25, 0x56, 0x91, 0x25, 0x36, 0x53, 0x89, 0x86, 0xe6, 0xc2, + 0x9e, 0x16, 0x5b, 0xe7, 0x31, 0x9f, 0x11, 0x58, 0x1f, 0x0, 0xd, 0xab, 0x36, 0x94, 0x61, 0x14, 0x9e, 0x41, 0xf, + 0x3e, 0x3d, 0x2a, 0xff, 0x29, 0x15, 0x0, 0x1c, 0x3e, 0x95, 0x90, 0x3a, 0xde, 0x6f, 0x3d, 0x4c, 0x11, 0x31, 0xf6, + 0x94, 0xbe, 0x5f, 0x8c, 0x7d, 0x56, 0xdf, 0xa6, 0xc3, 0xad, 0xb4, 0xf0, 0x68, 0x9a, 0x22, 0xde, 0xce, 0x22, 0x14, + 0x8a, 0x0, 0x7, 0xa5, 0x19, 0xb5, 0x18, 0x29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0x36, 0x8a, 0xb1, 0x49, 0x81, 0xc3, 0x1f, 0x41, 0x13, 0x0, 0xd, 0x49, + 0x11, 0xd2, 0x13, 0x1c, 0x13, 0xf2, 0x8a, 0xab, 0xd3, 0xcb, 0x8, 0xbe, 0x0, 0x1e, 0x5, 0x41, 0x41, 0x45, 0x6, + 0xae, 0x26, 0x80, 0xa1, 0x77, 0x6d, 0x23, 0x57, 0x3e, 0x56, 0x43, 0x3c, 0x5d, 0x95, 0x98, 0xc9, 0x86, 0x78, 0x3a, + 0x94, 0xdc, 0xf3, 0x54, 0x5c, 0x2e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbd, 0x20, 0x14, 0x3e, 0xc5, 0xd4, 0x6f, 0x6c, 0x21, 0x15, 0x9, 0x25, 0x56, 0x91, 0x25, + 0x36, 0x53, 0x89, 0x86, 0xe6, 0xc2, 0x9e, 0x16, 0x5b, 0xe7, 0x31, 0x9f, 0x11, 0x58}; + uint8_t bytesprops1[] = {0xab, 0x36, 0x94, 0x61, 0x14, 0x9e, 0x41, 0xf, 0x3e, 0x3d, 0x2a, 0xff, 0x29}; + uint8_t bytesprops2[] = {0x3e, 0x95, 0x90, 0x3a, 0xde, 0x6f, 0x3d, 0x4c, 0x11, 0x31, 0xf6, 0x94, 0xbe, 0x5f, + 0x8c, 0x7d, 0x56, 0xdf, 0xa6, 0xc3, 0xad, 0xb4, 0xf0, 0x68, 0x9a, 0x22, 0xde, 0xce}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5258}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x3d, 0x6f, 0x28, 0xb7, 0x58, 0x1d, 0x2a, 0x35, 0xef, 0x3c, 0xc, 0x36, 0x33, 0x5}; + uint8_t byteswillprops1[] = {0x9f, 0x51, 0xbe, 0xba, 0xd3, 0x1b, 0xec, 0x55, 0xe, 0x3a, 0xe0, 0xdc, 0x47, + 0x59, 0x5, 0x1c, 0x11, 0x12, 0xeb, 0xd3, 0x5b, 0x1, 0x4e, 0x2e, 0xe9}; + uint8_t byteswillprops2[] = {0x6a, 0x75, 0xb5, 0xe, 0x10, 0x8, 0x3d, 0x95, + 0x80, 0x31, 0x1f, 0xe4, 0x80, 0x9c, 0xf9, 0x6a}; + uint8_t byteswillprops4[] = {0x3, 0x7d, 0xf2, 0x9e, 0x4, 0x5e, 0x73, 0xed, 0x7b, 0x42, 0x9d, 0x9f, + 0x12, 0xa1, 0xcb, 0x31, 0x36, 0x91, 0x7f, 0x72, 0x79, 0xef, 0x3b, 0x15}; + uint8_t byteswillprops3[] = {0}; + uint8_t byteswillprops5[] = {0x41, 0xe7, 0xc8, 0x34, 0x7c}; + uint8_t byteswillprops6[] = {0}; + uint8_t byteswillprops7[] = {0xbc, 0x40, 0xea, 0xf5, 0x8a}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15727}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {0, (char*)&byteswillprops3}, .v = {24, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17769}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3021}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6246}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16414}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29477}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7605}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1346}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9041}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20216}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23968}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, + }; + + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x3b, 0xa1, 0x55, 0xc3, 0x36, 0x8a, 0xb1, 0x49, 0x81, 0xc3, 0x1f, 0x41, 0x13}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x49, 0x11, 0xd2, 0x13, 0x1c, 0x13, 0xf2, 0x8a, 0xab, 0xd3, 0xcb, 0x8, 0xbe}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -2622,2259 +9879,4679 @@ TEST(Connect5QCTest, Encode4) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 8577; - uint8_t client_id_bytes[] = {0xf6, 0xeb, 0xe2, 0x6, 0xf, 0x2b, 0xff, 0x86, 0x89, 0x9e, - 0xf7, 0x9e, 0x8a, 0x58, 0x93, 0xbc, 0x8b, 0xda, 0x2d, 0x9a}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.keep_alive = 22371; + uint8_t client_id_bytes[] = {0xa5, 0x19, 0xb5, 0x18, 0x29, 0x36, 0x32}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xb5, 0xbc, 0x52, 0x43, 0x7c, 0x7f, 0x50, 0x63, 0x5b, 0xf2, 0x41, - 0xc2, 0x8c, 0x47, 0x15, 0x18, 0x75, 0x14, 0xb2, 0xd5, 0x14}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x5, 0x41, 0x41, 0x45, 0x6, 0xae, 0x26, 0x80, 0xa1, 0x77, 0x6d, 0x23, 0x57, 0x3e, 0x56, + 0x43, 0x3c, 0x5d, 0x95, 0x98, 0xc9, 0x86, 0x78, 0x3a, 0x94, 0xdc, 0xf3, 0x54, 0x5c, 0x2e}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "OX\145\244\252\182\254\FS\130\252\134@\172\223\164\157{X}\165\146\152~f\219", _willMsg = +// "@\129Q\244!\183oR", _willProps = [PropResponseTopic "\156@",PropCorrelationData +// "Dp\NAK\235T\197oT\186\NUL\nF=\233\\~[V\211\179`\SYN9i\217\184dvO",PropPayloadFormatIndicator 161,PropContentType +// "AfZ\168\242p\198\175\NAK]\185\FS\229D\ESC\251\168\164fe\SUB\246N\218w\ESCdot",PropSubscriptionIdentifier +// 29,PropServerReference "q\222h\158L\230\162\DC1\237\133",PropAuthenticationData +// "\SUB\155Wv\128y",PropWildcardSubscriptionAvailable 8,PropUserProperty +// "\165m\248\222>\"\SYNJ\213S\148\ENQ<\179T\157B\166\185\142\169\181\162\NULw\250\145\SYN\170f" +// ",\DC1vBU\246\159=\SUB%\\rFKB(aoC\DC3\166\132\RS\DC1^",PropCorrelationData +// "l\b\134\228\218\227\176s\138\151'hl\n",PropResponseTopic +// "\171|<3\155!E\169i\225\DELn\185\ETB\186zne\145\SO\181\236\150_\140\SUB\254\230",PropWildcardSubscriptionAvailable +// 1,PropServerKeepAlive 29600,PropAuthenticationData "\203B\r\RS\199\184\243\164`",PropWillDelayInterval +// 13457,PropWillDelayInterval 12828,PropMaximumPacketSize 9940,PropResponseTopic +// "\131|\174-\n\221\169\DEL\237\193\205\169\DLE`t\167",PropTopicAlias 3659,PropPayloadFormatIndicator +// 160,PropRetainAvailable 158,PropRequestProblemInformation 243,PropRetainAvailable 34,PropResponseTopic +// "\155\252\199\245\193\208U"]}), _cleanSession = False, _keepAlive = 30518, _connID = +// "W\161E\137\235\171\156\EM\227`e^\234\242\248\227rj\195\139\NAK", _properties = [PropReceiveMaximum +// 17590,PropMaximumPacketSize 26394,PropSessionExpiryInterval 21423,PropReceiveMaximum 6468,PropMessageExpiryInterval +// 23431,PropRequestResponseInformation 180,PropCorrelationData +// "\197\SYN~\191|\213\DC1b9t\243'\246\154",PropSubscriptionIdentifier 15,PropSubscriptionIdentifier +// 29,PropServerReference "z\152\203\191c\203\GS\251\243\170\247\159t\255u",PropContentType +// "\224\GS\196\245\232i",PropResponseInformation "\184\184\152'\199\187\&4\US\191\DLE\218\245\197]\233T\EM\153\245y\218 +// \230\210(\190\CAN\175\SO",PropTopicAlias 4418,PropServerKeepAlive 11532,PropServerReference +// "\245\148\RSX\234\243",PropAuthenticationData +// "\225\&6B>\DEL&\189\220\237\132v\"\177\226<1\136\173\154]\SOH\205\252\178\131",PropServerKeepAlive +// 31846,PropServerKeepAlive 25329,PropTopicAliasMaximum 26607,PropMessageExpiryInterval 29456,PropMaximumPacketSize +// 26694,PropSessionExpiryInterval 12931,PropContentType +// "Y\136\218Z\133T\174x\212r\f\"\137n}\162\137\254\206Z\249\129$oc",PropWildcardSubscriptionAvailable +// 193,PropSharedSubscriptionAvailable 186,PropAuthenticationData +// "\224\200\a\140\134\FS\172\171~&\DLE\154\246l5A3",PropMessageExpiryInterval 17774,PropSubscriptionIdentifierAvailable +// 142,PropReasonString "R&\173\137v\248]\157\164\r\143\163z\DLEL\250\136\136N\166\252\vG\140\&1\157\DLE,\156"]} +TEST(Connect5QCTest, Encode29) { + uint8_t pkt[] = { + 0x10, 0xe4, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x24, 0x77, 0x36, 0x85, 0x2, 0x21, 0x44, 0xb6, 0x27, + 0x0, 0x0, 0x67, 0x1a, 0x11, 0x0, 0x0, 0x53, 0xaf, 0x21, 0x19, 0x44, 0x2, 0x0, 0x0, 0x5b, 0x87, 0x19, 0xb4, + 0x9, 0x0, 0xe, 0xc5, 0x16, 0x7e, 0xbf, 0x7c, 0xd5, 0x11, 0x62, 0x39, 0x74, 0xf3, 0x27, 0xf6, 0x9a, 0xb, 0xf, + 0xb, 0x1d, 0x1c, 0x0, 0xf, 0x7a, 0x98, 0xcb, 0xbf, 0x63, 0xcb, 0x1d, 0xfb, 0xf3, 0xaa, 0xf7, 0x9f, 0x74, 0xff, + 0x75, 0x3, 0x0, 0x6, 0xe0, 0x1d, 0xc4, 0xf5, 0xe8, 0x69, 0x1a, 0x0, 0x1d, 0xb8, 0xb8, 0x98, 0x27, 0x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b0, 0x73, 0x8a, 0x97, 0x27, 0x68, 0x6c, 0xa, + 0x8, 0x0, 0x1c, 0xab, 0x7c, 0x3c, 0x33, 0x9b, 0x21, 0x45, 0xa9, 0x69, 0xe1, 0x7f, 0x6e, 0xb9, 0x17, 0xba, 0x7a, + 0x6e, 0x65, 0x91, 0xe, 0xb5, 0xec, 0x96, 0x5f, 0x8c, 0x1a, 0xfe, 0xe6, 0x28, 0x1, 0x13, 0x73, 0xa0, 0x16, 0x0, + 0x9, 0xcb, 0x42, 0xd, 0x1e, 0xc7, 0xb8, 0xf3, 0xa4, 0x60, 0x18, 0x0, 0x0, 0x34, 0x91, 0x18, 0x0, 0x0, 0x32, + 0x1c, 0x27, 0x0, 0x0, 0x26, 0xd4, 0x8, 0x0, 0x10, 0x83, 0x7c, 0xae, 0x2d, 0xa, 0xdd, 0xa9, 0x7f, 0xed, 0xc1, + 0xcd, 0xa9, 0x10, 0x60, 0x74, 0xa7, 0x23, 0xe, 0x4b, 0x1, 0xa0, 0x25, 0x9e, 0x17, 0xf3, 0x25, 0x22, 0x8, 0x0, + 0x7, 0x9b, 0xfc, 0xc7, 0xf5, 0xc1, 0xd0, 0x55, 0x0, 0x19, 0x4f, 0x58, 0x91, 0xf4, 0xfc, 0xb6, 0xfe, 0x1c, 0x82, + 0xfc, 0x86, 0x40, 0xac, 0xdf, 0xa4, 0x9d, 0x7b, 0x58, 0x7d, 0xa5, 0x92, 0x98, 0x7e, 0x66, 0xdb, 0x0, 0x8, 0x40, + 0x81, 0x51, 0xf4, 0x21, 0xb7, 0x6f, 0x52}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc5, 0x16, 0x7e, 0xbf, 0x7c, 0xd5, 0x11, 0x62, 0x39, 0x74, 0xf3, 0x27, 0xf6, 0x9a}; + uint8_t bytesprops1[] = {0x7a, 0x98, 0xcb, 0xbf, 0x63, 0xcb, 0x1d, 0xfb, 0xf3, 0xaa, 0xf7, 0x9f, 0x74, 0xff, 0x75}; + uint8_t bytesprops2[] = {0xe0, 0x1d, 0xc4, 0xf5, 0xe8, 0x69}; + uint8_t bytesprops3[] = {0xb8, 0xb8, 0x98, 0x27, 0xc7, 0xbb, 0x34, 0x1f, 0xbf, 0x10, 0xda, 0xf5, 0xc5, 0x5d, 0xe9, + 0x54, 0x19, 0x99, 0xf5, 0x79, 0xda, 0x20, 0xe6, 0xd2, 0x28, 0xbe, 0x18, 0xaf, 0xe}; + uint8_t bytesprops4[] = {0xf5, 0x94, 0x1e, 0x58, 0xea, 0xf3}; + uint8_t bytesprops5[] = {0xe1, 0x36, 0x42, 0x3e, 0x7f, 0x26, 0xbd, 0xdc, 0xed, 0x84, 0x76, 0x22, 0xb1, + 0xe2, 0x3c, 0x31, 0x88, 0xad, 0x9a, 0x5d, 0x1, 0xcd, 0xfc, 0xb2, 0x83}; + uint8_t bytesprops6[] = {0x59, 0x88, 0xda, 0x5a, 0x85, 0x54, 0xae, 0x78, 0xd4, 0x72, 0xc, 0x22, 0x89, + 0x6e, 0x7d, 0xa2, 0x89, 0xfe, 0xce, 0x5a, 0xf9, 0x81, 0x24, 0x6f, 0x63}; + uint8_t bytesprops7[] = {0xe0, 0xc8, 0x7, 0x8c, 0x86, 0x1c, 0xac, 0xab, 0x7e, + 0x26, 0x10, 0x9a, 0xf6, 0x6c, 0x35, 0x41, 0x33}; + uint8_t bytesprops8[] = {0x52, 0x26, 0xad, 0x89, 0x76, 0xf8, 0x5d, 0x9d, 0xa4, 0xd, 0x8f, 0xa3, 0x7a, 0x10, 0x4c, + 0xfa, 0x88, 0x88, 0x4e, 0xa6, 0xfc, 0xb, 0x47, 0x8c, 0x31, 0x9d, 0x10, 0x2c, 0x9c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17590}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26394}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21423}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6468}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23431}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4418}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11532}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31846}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25329}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26607}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29456}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26694}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12931}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17774}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops8}}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x9c, 0x40}; + uint8_t byteswillprops1[] = {0x44, 0x70, 0x15, 0xeb, 0x54, 0xc5, 0x6f, 0x54, 0xba, 0x0, 0xa, 0x46, 0x3d, 0xe9, 0x5c, + 0x7e, 0x5b, 0x56, 0xd3, 0xb3, 0x60, 0x16, 0x39, 0x69, 0xd9, 0xb8, 0x64, 0x76, 0x4f}; + uint8_t byteswillprops2[] = {0x41, 0x66, 0x5a, 0xa8, 0xf2, 0x70, 0xc6, 0xaf, 0x15, 0x5d, 0xb9, 0x1c, 0xe5, 0x44, 0x1b, + 0xfb, 0xa8, 0xa4, 0x66, 0x65, 0x1a, 0xf6, 0x4e, 0xda, 0x77, 0x1b, 0x64, 0x6f, 0x74}; + uint8_t byteswillprops3[] = {0x71, 0xde, 0x68, 0x9e, 0x4c, 0xe6, 0xa2, 0x11, 0xed, 0x85}; + uint8_t byteswillprops4[] = {0x1a, 0x9b, 0x57, 0x76, 0x80, 0x79}; + uint8_t byteswillprops6[] = {0x2c, 0x11, 0x76, 0x42, 0x55, 0xf6, 0x9f, 0x3d, 0x1a, 0x25, 0x5c, 0x72, 0x46, + 0x4b, 0x42, 0x28, 0x61, 0x6f, 0x43, 0x13, 0xa6, 0x84, 0x1e, 0x11, 0x5e}; + uint8_t byteswillprops5[] = {0xa5, 0x6d, 0xf8, 0xde, 0x3e, 0x22, 0x16, 0x4a, 0xd5, 0x53, + 0x94, 0x5, 0x3c, 0xb3, 0x54, 0x9d, 0x42, 0xa6, 0xb9, 0x8e, + 0xa9, 0xb5, 0xa2, 0x0, 0x77, 0xfa, 0x91, 0x16, 0xaa, 0x66}; + uint8_t byteswillprops7[] = {0x6c, 0x8, 0x86, 0xe4, 0xda, 0xe3, 0xb0, 0x73, 0x8a, 0x97, 0x27, 0x68, 0x6c, 0xa}; + uint8_t byteswillprops8[] = {0xab, 0x7c, 0x3c, 0x33, 0x9b, 0x21, 0x45, 0xa9, 0x69, 0xe1, 0x7f, 0x6e, 0xb9, 0x17, + 0xba, 0x7a, 0x6e, 0x65, 0x91, 0xe, 0xb5, 0xec, 0x96, 0x5f, 0x8c, 0x1a, 0xfe, 0xe6}; + uint8_t byteswillprops9[] = {0xcb, 0x42, 0xd, 0x1e, 0xc7, 0xb8, 0xf3, 0xa4, 0x60}; + uint8_t byteswillprops10[] = {0x83, 0x7c, 0xae, 0x2d, 0xa, 0xdd, 0xa9, 0x7f, + 0xed, 0xc1, 0xcd, 0xa9, 0x10, 0x60, 0x74, 0xa7}; + uint8_t byteswillprops11[] = {0x9b, 0xfc, 0xc7, 0xf5, 0xc1, 0xd0, 0x55}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {30, (char*)&byteswillprops5}, .v = {25, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29600}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13457}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12828}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9940}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3659}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops11}}}, + }; + + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4f, 0x58, 0x91, 0xf4, 0xfc, 0xb6, 0xfe, 0x1c, 0x82, 0xfc, 0x86, 0x40, 0xac, + 0xdf, 0xa4, 0x9d, 0x7b, 0x58, 0x7d, 0xa5, 0x92, 0x98, 0x7e, 0x66, 0xdb}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x40, 0x81, 0x51, 0xf4, 0x21, 0xb7, 0x6f, 0x52}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 30518; + uint8_t client_id_bytes[] = {0x57, 0xa1, 0x45, 0x89, 0xeb, 0xab, 0x9c, 0x19, 0xe3, 0x60, 0x65, + 0x5e, 0xea, 0xf2, 0xf8, 0xe3, 0x72, 0x6a, 0xc3, 0x8b, 0x15}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "\233\DLEuz,\235\221\183\245C\171\219\241^\213\168\160\167\181<\210\175\201\225\241\132\251\229e\164", _password = +// Just "\240\180X}9\198\t\SUBK\211\ACK\179t\255\237\148 no\DC3\203\&3;\198", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS2, _willTopic = +// "\157\167S\173)\208\193\243\142\STX?\244\199<\DC3\202VL\215\218\215\162\174~\167G1\t\196)", _willMsg = "", _willProps +// = [PropResponseInformation "\SI\170\241\213p6LF\SYN\129\135:",PropMaximumQoS 183,PropWildcardSubscriptionAvailable +// 207,PropSubscriptionIdentifier 18,PropResponseInformation +// "\213\165llx\EM\158\206\220\&3z~\140",PropAuthenticationMethod +// "\251\132\158\r\154\170<\243\247\140\178\151\DC3\230w\SUB\129SwA",PropMessageExpiryInterval +// 14841,PropAuthenticationData "\251a\SYN\181^\224\SO\163Q\n5\n\198\150Xe&\DLE",PropRequestResponseInformation +// 214,PropRequestProblemInformation 220,PropSharedSubscriptionAvailable 246,PropContentType +// "\169\194\DC2\SUB\199Qs]j\159P\239\223K\193V",PropRetainAvailable 115,PropMaximumQoS 207]}), _cleanSession = False, +// _keepAlive = 26007, _connID = "N\237\211", _properties = [PropTopicAlias 31274,PropUserProperty +// "S\ESCE\154\&9$\251\254\GS\193_\174\ETB-_\181GJ.A\221\\\187\230\SOH\201\255\200" +// "\144\211$\f\225\133\208s\159\162\171\254!\209\210\141\v\197\237\ENQ\253\169\247\224)\223",PropRetainAvailable +// 115,PropAuthenticationData "j",PropAuthenticationData +// "\154\r\138%\146`\147\197\145)9\185\176Z\ENQ9`\217\174\208|\193y",PropMessageExpiryInterval 206,PropContentType +// "#\219\&7\EMi\208\148\253H[c\209s\SOH\161\235w?\DEL\137\&7&9",PropWildcardSubscriptionAvailable 226,PropResponseTopic +// "\182{\212\195\n\209H\222zP){R\142\150\218$Oa\147K\173",PropRequestProblemInformation +// 145,PropSubscriptionIdentifierAvailable 20,PropRequestResponseInformation 22,PropTopicAlias +// 5924,PropPayloadFormatIndicator 84,PropMaximumPacketSize 26952,PropMaximumQoS 207,PropRetainAvailable +// 246,PropServerReference "&S\nC\169\RS\181dI\243/\252x",PropSharedSubscriptionAvailable 163,PropTopicAlias +// 19727,PropContentType "J\236jFj\207"]} +TEST(Connect5QCTest, Encode30) { + uint8_t pkt[] = { + 0x10, 0xab, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x65, 0x97, 0xca, 0x1, 0x23, 0x7a, 0x2a, 0x26, + 0x0, 0x1c, 0x53, 0x1b, 0x45, 0x9a, 0x39, 0x24, 0xfb, 0xfe, 0x1d, 0xc1, 0x5f, 0xae, 0x17, 0x2d, 0x5f, 0xb5, 0x47, + 0x4a, 0x2e, 0x41, 0xdd, 0x5c, 0xbb, 0xe6, 0x1, 0xc9, 0xff, 0xc8, 0x0, 0x1a, 0x90, 0xd3, 0x24, 0xc, 0xe1, 0x85, + 0xd0, 0x73, 0x9f, 0xa2, 0xab, 0xfe, 0x21, 0xd1, 0xd2, 0x8d, 0xb, 0xc5, 0xed, 0x5, 0xfd, 0xa9, 0xf7, 0xe0, 0x29, + 0xdf, 0x25, 0x73, 0x16, 0x0, 0x1, 0x6a, 0x16, 0x0, 0x17, 0x9a, 0xd, 0x8a, 0x25, 0x92, 0x60, 0x93, 0xc5, 0x91, + 0x29, 0x39, 0xb9, 0xb0, 0x5a, 0x5, 0x39, 0x60, 0xd9, 0xae, 0xd0, 0x7c, 0xc1, 0x79, 0x2, 0x0, 0x0, 0x0, 0xce, + 0x3, 0x0, 0x17, 0x23, 0xdb, 0x37, 0x19, 0x69, 0xd0, 0x94, 0xfd, 0x48, 0x5b, 0x63, 0xd1, 0x73, 0x1, 0xa1, 0xeb, + 0x77, 0x3f, 0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x51, 0x73, 0x5d, 0x6a, 0x9f, 0x50, 0xef, 0xdf, 0x4b, 0xc1, 0x56, 0x25, 0x73, 0x24, 0xcf, 0x0, 0x1e, 0x9d, 0xa7, + 0x53, 0xad, 0x29, 0xd0, 0xc1, 0xf3, 0x8e, 0x2, 0x3f, 0xf4, 0xc7, 0x3c, 0x13, 0xca, 0x56, 0x4c, 0xd7, 0xda, 0xd7, + 0xa2, 0xae, 0x7e, 0xa7, 0x47, 0x31, 0x9, 0xc4, 0x29, 0x0, 0x0, 0x0, 0x1e, 0xe9, 0x10, 0x75, 0x7a, 0x2c, 0xeb, + 0xdd, 0xb7, 0xf5, 0x43, 0xab, 0xdb, 0xf1, 0x5e, 0xd5, 0xa8, 0xa0, 0xa7, 0xb5, 0x3c, 0xd2, 0xaf, 0xc9, 0xe1, 0xf1, + 0x84, 0xfb, 0xe5, 0x65, 0xa4, 0x0, 0x18, 0xf0, 0xb4, 0x58, 0x7d, 0x39, 0xc6, 0x9, 0x1a, 0x4b, 0xd3, 0x6, 0xb3, + 0x74, 0xff, 0xed, 0x94, 0x20, 0x6e, 0x6f, 0x13, 0xcb, 0x33, 0x3b, 0xc6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x90, 0xd3, 0x24, 0xc, 0xe1, 0x85, 0xd0, 0x73, 0x9f, 0xa2, 0xab, 0xfe, 0x21, + 0xd1, 0xd2, 0x8d, 0xb, 0xc5, 0xed, 0x5, 0xfd, 0xa9, 0xf7, 0xe0, 0x29, 0xdf}; + uint8_t bytesprops0[] = {0x53, 0x1b, 0x45, 0x9a, 0x39, 0x24, 0xfb, 0xfe, 0x1d, 0xc1, 0x5f, 0xae, 0x17, 0x2d, + 0x5f, 0xb5, 0x47, 0x4a, 0x2e, 0x41, 0xdd, 0x5c, 0xbb, 0xe6, 0x1, 0xc9, 0xff, 0xc8}; + uint8_t bytesprops2[] = {0x6a}; + uint8_t bytesprops3[] = {0x9a, 0xd, 0x8a, 0x25, 0x92, 0x60, 0x93, 0xc5, 0x91, 0x29, 0x39, 0xb9, + 0xb0, 0x5a, 0x5, 0x39, 0x60, 0xd9, 0xae, 0xd0, 0x7c, 0xc1, 0x79}; + uint8_t bytesprops4[] = {0x23, 0xdb, 0x37, 0x19, 0x69, 0xd0, 0x94, 0xfd, 0x48, 0x5b, 0x63, 0xd1, + 0x73, 0x1, 0xa1, 0xeb, 0x77, 0x3f, 0x7f, 0x89, 0x37, 0x26, 0x39}; + uint8_t bytesprops5[] = {0xb6, 0x7b, 0xd4, 0xc3, 0xa, 0xd1, 0x48, 0xde, 0x7a, 0x50, 0x29, + 0x7b, 0x52, 0x8e, 0x96, 0xda, 0x24, 0x4f, 0x61, 0x93, 0x4b, 0xad}; + uint8_t bytesprops6[] = {0x26, 0x53, 0xa, 0x43, 0xa9, 0x1e, 0xb5, 0x64, 0x49, 0xf3, 0x2f, 0xfc, 0x78}; + uint8_t bytesprops7[] = {0x4a, 0xec, 0x6a, 0x46, 0x6a, 0xcf}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31274}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops0}, .v = {26, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 206}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5924}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26952}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19727}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops7}}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xf, 0xaa, 0xf1, 0xd5, 0x70, 0x36, 0x4c, 0x46, 0x16, 0x81, 0x87, 0x3a}; + uint8_t byteswillprops1[] = {0xd5, 0xa5, 0x6c, 0x6c, 0x78, 0x19, 0x9e, 0xce, 0xdc, 0x33, 0x7a, 0x7e, 0x8c}; + uint8_t byteswillprops2[] = {0xfb, 0x84, 0x9e, 0xd, 0x9a, 0xaa, 0x3c, 0xf3, 0xf7, 0x8c, + 0xb2, 0x97, 0x13, 0xe6, 0x77, 0x1a, 0x81, 0x53, 0x77, 0x41}; + uint8_t byteswillprops3[] = {0xfb, 0x61, 0x16, 0xb5, 0x5e, 0xe0, 0xe, 0xa3, 0x51, + 0xa, 0x35, 0xa, 0xc6, 0x96, 0x58, 0x65, 0x26, 0x10}; + uint8_t byteswillprops4[] = {0xa9, 0xc2, 0x12, 0x1a, 0xc7, 0x51, 0x73, 0x5d, + 0x6a, 0x9f, 0x50, 0xef, 0xdf, 0x4b, 0xc1, 0x56}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14841}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, + }; + + lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9d, 0xa7, 0x53, 0xad, 0x29, 0xd0, 0xc1, 0xf3, 0x8e, 0x2, + 0x3f, 0xf4, 0xc7, 0x3c, 0x13, 0xca, 0x56, 0x4c, 0xd7, 0xda, + 0xd7, 0xa2, 0xae, 0x7e, 0xa7, 0x47, 0x31, 0x9, 0xc4, 0x29}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 26007; + uint8_t client_id_bytes[] = {0x4e, 0xed, 0xd3}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xe9, 0x10, 0x75, 0x7a, 0x2c, 0xeb, 0xdd, 0xb7, 0xf5, 0x43, 0xab, 0xdb, 0xf1, 0x5e, 0xd5, + 0xa8, 0xa0, 0xa7, 0xb5, 0x3c, 0xd2, 0xaf, 0xc9, 0xe1, 0xf1, 0x84, 0xfb, 0xe5, 0x65, 0xa4}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf0, 0xb4, 0x58, 0x7d, 0x39, 0xc6, 0x9, 0x1a, 0x4b, 0xd3, 0x6, 0xb3, + 0x74, 0xff, 0xed, 0x94, 0x20, 0x6e, 0x6f, 0x13, 0xcb, 0x33, 0x3b, 0xc6}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 19824 [("\NUL\181VC\229\166\255j \b\FSg\134\253%\212u\175\246K)\203\142>\132\154`n",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("-e\131\&2\165",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("\229\164\170}\NUL6\248\\?V\138\161\245\251\178\192u$\205\204\GS\191",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\255\220\179G\GS\163\207k\"\197u@\218\v\133\aW\US\136\172j\231v",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("S\189\207H\v\DC4\186]k\202\252\ESC2\228w\158C|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode1) { + uint8_t pkt[] = {0x82, 0x71, 0x4d, 0x70, 0x0, 0x1c, 0x0, 0xb5, 0x56, 0x43, 0xe5, 0xa6, 0xff, 0x6a, 0x20, 0x8, 0x1c, + 0x67, 0x86, 0xfd, 0x25, 0xd4, 0x75, 0xaf, 0xf6, 0x4b, 0x29, 0xcb, 0x8e, 0x3e, 0x84, 0x9a, 0x60, 0x6e, + 0x2, 0x0, 0x5, 0x2d, 0x65, 0x83, 0x32, 0xa5, 0x0, 0x0, 0x16, 0xe5, 0xa4, 0xaa, 0x7d, 0x0, 0x36, + 0xf8, 0x5c, 0x3f, 0x56, 0x8a, 0xa1, 0xf5, 0xfb, 0xb2, 0xc0, 0x75, 0x24, 0xcd, 0xcc, 0x1d, 0xbf, 0x1, + 0x0, 0x17, 0xff, 0xdc, 0xb3, 0x47, 0x1d, 0xa3, 0xcf, 0x6b, 0x22, 0xc5, 0x75, 0x40, 0xda, 0xb, 0x85, + 0x7, 0x57, 0x1f, 0x88, 0xac, 0x6a, 0xe7, 0x76, 0x1, 0x0, 0x12, 0x53, 0xbd, 0xcf, 0x48, 0xb, 0x14, + 0xba, 0x5d, 0x6b, 0xca, 0xfc, 0x1b, 0x32, 0xe4, 0x77, 0x9e, 0x43, 0x7c, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x0, 0xb5, 0x56, 0x43, 0xe5, 0xa6, 0xff, 0x6a, 0x20, 0x8, + 0x1c, 0x67, 0x86, 0xfd, 0x25, 0xd4, 0x75, 0xaf, 0xf6, 0x4b, + 0x29, 0xcb, 0x8e, 0x3e, 0x84, 0x9a, 0x60, 0x6e}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2d, 0x65, 0x83, 0x32, 0xa5}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe5, 0xa4, 0xaa, 0x7d, 0x0, 0x36, 0xf8, 0x5c, 0x3f, 0x56, 0x8a, + 0xa1, 0xf5, 0xfb, 0xb2, 0xc0, 0x75, 0x24, 0xcd, 0xcc, 0x1d, 0xbf}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xff, 0xdc, 0xb3, 0x47, 0x1d, 0xa3, 0xcf, 0x6b, 0x22, 0xc5, 0x75, 0x40, + 0xda, 0xb, 0x85, 0x7, 0x57, 0x1f, 0x88, 0xac, 0x6a, 0xe7, 0x76}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x53, 0xbd, 0xcf, 0x48, 0xb, 0x14, 0xba, 0x5d, 0x6b, + 0xca, 0xfc, 0x1b, 0x32, 0xe4, 0x77, 0x9e, 0x43, 0x7c}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19824, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12399 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\250L\239\233\150\180y\246\174\156:\150\247RB",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\130/\NAKA~\213\CAN\RS\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("XMwO\188j\180\242\145D7\132\192e\183\EM\166$\183\158|5",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\167\200\ESC\147B\160\157\186\DC14\244.w#\196\246\200\226\230\EM\179\181\SI",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\f\211U\184\143\231\221\ETXl\181&\ENQ\214*.O\GS\206b\SOFx\v\132\&7\159\151r\238,",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\220\EOT\131\&0{\147\167b\132#\244\188\SUB\r\145\DLE\DELzD\133",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\211\177\223!\136x\241+?\150\246\199V+!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("U0\204\242VJa\154\135yp\US\150\210\212xUN\172=\"\161\134\239\238&\153M",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\226\ETX\215\DC2\164\133_g\140\144\NULo",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode2) { + uint8_t pkt[] = { + 0x82, 0xce, 0x1, 0x30, 0x6f, 0x0, 0x0, 0x0, 0x0, 0xf, 0xfa, 0x4c, 0xef, 0xe9, 0x96, 0xb4, 0x79, 0xf6, 0xae, + 0x9c, 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, 0x6f, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xfa, 0x4c, 0xef, 0xe9, 0x96, 0xb4, 0x79, 0xf6, + 0xae, 0x9c, 0x3a, 0x96, 0xf7, 0x52, 0x42}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x82, 0x2f, 0x15, 0x41, 0x7e, 0xd5, 0x18, 0x1e, 0xc5}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x58, 0x4d, 0x77, 0x4f, 0xbc, 0x6a, 0xb4, 0xf2, 0x91, 0x44, 0x37, + 0x84, 0xc0, 0x65, 0xb7, 0x19, 0xa6, 0x24, 0xb7, 0x9e, 0x7c, 0x35}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa7, 0xc8, 0x1b, 0x93, 0x42, 0xa0, 0x9d, 0xba, 0x11, 0x34, 0xf4, 0x2e, + 0x77, 0x23, 0xc4, 0xf6, 0xc8, 0xe2, 0xe6, 0x19, 0xb3, 0xb5, 0xf}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xc, 0xd3, 0x55, 0xb8, 0x8f, 0xe7, 0xdd, 0x3, 0x6c, 0xb5, + 0x26, 0x5, 0xd6, 0x2a, 0x2e, 0x4f, 0x1d, 0xce, 0x62, 0xe, + 0x46, 0x78, 0xb, 0x84, 0x37, 0x9f, 0x97, 0x72, 0xee, 0x2c}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xdc, 0x4, 0x83, 0x30, 0x7b, 0x93, 0xa7, 0x62, 0x84, 0x23, + 0xf4, 0xbc, 0x1a, 0xd, 0x91, 0x10, 0x7f, 0x7a, 0x44, 0x85}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xd3, 0xb1, 0xdf, 0x21, 0x88, 0x78, 0xf1, 0x2b, + 0x3f, 0x96, 0xf6, 0xc7, 0x56, 0x2b, 0x21}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x55, 0x30, 0xcc, 0xf2, 0x56, 0x4a, 0x61, 0x9a, 0x87, 0x79, + 0x70, 0x1f, 0x96, 0xd2, 0xd4, 0x78, 0x55, 0x4e, 0xac, 0x3d, + 0x22, 0xa1, 0x86, 0xef, 0xee, 0x26, 0x99, 0x4d}; + lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe2, 0x3, 0xd7, 0x12, 0xa4, 0x85, 0x5f, 0x67, 0x8c, 0x90, 0x0, 0x6f}; + lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12399, 10, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 23812 [("l\217\181\248\247R\218\132\148\US\247\151\130\255:P",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("B1X\194\172\224\"\188%\220\224\EM\208\234yj\214\&1I\202\199[\155",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("5)l@\241",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\169\t|)\195\169\b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("<\146&\226\RS\169\182\&62\t;\r\171K\170\204 x\140\&9V\245K(\SUB\SOe>\144\252",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\167\157\EOT\218\v\192%\143\217\155\202\224\246\137",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("n\153\194\225\207\165\197\160\213\NAK\182",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode3) { + uint8_t pkt[] = {0x82, 0x84, 0x1, 0x5d, 0x4, 0x0, 0x10, 0x6c, 0xd9, 0xb5, 0xf8, 0xf7, 0x52, 0xda, 0x84, 0x94, 0x1f, + 0xf7, 0x97, 0x82, 0xff, 0x3a, 0x50, 0x0, 0x0, 0x17, 0x42, 0x31, 0x58, 0xc2, 0xac, 0xe0, 0x22, 0xbc, + 0x25, 0xdc, 0xe0, 0x19, 0xd0, 0xea, 0x79, 0x6a, 0xd6, 0x31, 0x49, 0xca, 0xc7, 0x5b, 0x9b, 0x0, 0x0, + 0x5, 0x35, 0x29, 0x6c, 0x40, 0xf1, 0x2, 0x0, 0x7, 0xa9, 0x9, 0x7c, 0x29, 0xc3, 0xa9, 0x8, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x1e, 0x3c, 0x92, 0x26, 0xe2, 0x1e, 0xa9, 0xb6, 0x36, 0x32, 0x9, 0x3b, 0xd, + 0xab, 0x4b, 0xaa, 0xcc, 0x20, 0x78, 0x8c, 0x39, 0x56, 0xf5, 0x4b, 0x28, 0x1a, 0xe, 0x65, 0x3e, 0x90, + 0xfc, 0x0, 0x0, 0xe, 0xa7, 0x9d, 0x4, 0xda, 0xb, 0xc0, 0x25, 0x8f, 0xd9, 0x9b, 0xca, 0xe0, 0xf6, + 0x89, 0x1, 0x0, 0xb, 0x6e, 0x99, 0xc2, 0xe1, 0xcf, 0xa5, 0xc5, 0xa0, 0xd5, 0x15, 0xb6, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x6c, 0xd9, 0xb5, 0xf8, 0xf7, 0x52, 0xda, 0x84, + 0x94, 0x1f, 0xf7, 0x97, 0x82, 0xff, 0x3a, 0x50}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x42, 0x31, 0x58, 0xc2, 0xac, 0xe0, 0x22, 0xbc, 0x25, 0xdc, 0xe0, 0x19, + 0xd0, 0xea, 0x79, 0x6a, 0xd6, 0x31, 0x49, 0xca, 0xc7, 0x5b, 0x9b}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x35, 0x29, 0x6c, 0x40, 0xf1}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa9, 0x9, 0x7c, 0x29, 0xc3, 0xa9, 0x8}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x3c, 0x92, 0x26, 0xe2, 0x1e, 0xa9, 0xb6, 0x36, 0x32, 0x9, + 0x3b, 0xd, 0xab, 0x4b, 0xaa, 0xcc, 0x20, 0x78, 0x8c, 0x39, + 0x56, 0xf5, 0x4b, 0x28, 0x1a, 0xe, 0x65, 0x3e, 0x90, 0xfc}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa7, 0x9d, 0x4, 0xda, 0xb, 0xc0, 0x25, 0x8f, 0xd9, 0x9b, 0xca, 0xe0, 0xf6, 0x89}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6e, 0x99, 0xc2, 0xe1, 0xcf, 0xa5, 0xc5, 0xa0, 0xd5, 0x15, 0xb6}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23812, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 27610 [("\237%=A\255\167\&8",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode4) { + uint8_t pkt[] = {0x82, 0xf, 0x6b, 0xda, 0x0, 0x7, 0xed, 0x25, 0x3d, 0x41, 0xff, 0xa7, 0x38, 0x0, 0x0, 0x0, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xed, 0x25, 0x3d, 0x41, 0xff, 0xa7, 0x38}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27610, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 4069 [("k\212\217\191\167Z\148\215\216\238$0\DLE\138\137",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("f\DC3\GSt\DC4]e\t\EOTEx\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\148G\181",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("+\153\166\221\250\195|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\DC2L\210Q\212\131\223\205\220\163\&3\141\245\165T\235c5\168\229",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\DEL\129c\NAKgK\238]W\EM\132uT\138\249i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\158\182*d\178\184#\243a\207]\196\141\233\DEL\165)\DC4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\183\ETB\154u\225\161A@_\SYN\251\185%\179y\180A\ESC\b\143\SO",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode5) { + uint8_t pkt[] = {0x82, 0x8a, 0x1, 0xf, 0xe5, 0x0, 0xf, 0x6b, 0xd4, 0xd9, 0xbf, 0xa7, 0x5a, 0x94, 0xd7, 0xd8, + 0xee, 0x24, 0x30, 0x10, 0x8a, 0x89, 0x2, 0x0, 0xc, 0x66, 0x13, 0x1d, 0x74, 0x14, 0x5d, 0x65, + 0x9, 0x4, 0x45, 0x78, 0xd0, 0x0, 0x0, 0x3, 0x94, 0x47, 0xb5, 0x1, 0x0, 0x7, 0x2b, 0x99, + 0xa6, 0xdd, 0xfa, 0xc3, 0x7c, 0x2, 0x0, 0x14, 0x12, 0x4c, 0xd2, 0x51, 0xd4, 0x83, 0xdf, 0xcd, + 0xdc, 0xa3, 0x33, 0x8d, 0xf5, 0xa5, 0x54, 0xeb, 0x63, 0x35, 0xa8, 0xe5, 0x0, 0x0, 0x10, 0x7f, + 0x81, 0x63, 0x15, 0x67, 0x4b, 0xee, 0x5d, 0x57, 0x19, 0x84, 0x75, 0x54, 0x8a, 0xf9, 0x69, 0x2, + 0x0, 0x12, 0x9e, 0xb6, 0x2a, 0x64, 0xb2, 0xb8, 0x23, 0xf3, 0x61, 0xcf, 0x5d, 0xc4, 0x8d, 0xe9, + 0x7f, 0xa5, 0x29, 0x14, 0x2, 0x0, 0x15, 0xb7, 0x17, 0x9a, 0x75, 0xe1, 0xa1, 0x41, 0x40, 0x5f, + 0x16, 0xfb, 0xb9, 0x25, 0xb3, 0x79, 0xb4, 0x41, 0x1b, 0x8, 0x8f, 0xe, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x6b, 0xd4, 0xd9, 0xbf, 0xa7, 0x5a, 0x94, 0xd7, + 0xd8, 0xee, 0x24, 0x30, 0x10, 0x8a, 0x89}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x66, 0x13, 0x1d, 0x74, 0x14, 0x5d, 0x65, 0x9, 0x4, 0x45, 0x78, 0xd0}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x94, 0x47, 0xb5}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x2b, 0x99, 0xa6, 0xdd, 0xfa, 0xc3, 0x7c}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x12, 0x4c, 0xd2, 0x51, 0xd4, 0x83, 0xdf, 0xcd, 0xdc, 0xa3, + 0x33, 0x8d, 0xf5, 0xa5, 0x54, 0xeb, 0x63, 0x35, 0xa8, 0xe5}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x7f, 0x81, 0x63, 0x15, 0x67, 0x4b, 0xee, 0x5d, + 0x57, 0x19, 0x84, 0x75, 0x54, 0x8a, 0xf9, 0x69}; + lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x9e, 0xb6, 0x2a, 0x64, 0xb2, 0xb8, 0x23, 0xf3, 0x61, + 0xcf, 0x5d, 0xc4, 0x8d, 0xe9, 0x7f, 0xa5, 0x29, 0x14}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xb7, 0x17, 0x9a, 0x75, 0xe1, 0xa1, 0x41, 0x40, 0x5f, 0x16, 0xfb, + 0xb9, 0x25, 0xb3, 0x79, 0xb4, 0x41, 0x1b, 0x8, 0x8f, 0xe}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4069, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 4140 [("q\r\152^#\158\&0\215\239\148E\179M",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\178\RS\139\147\GS\136\&8\163^",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("8Y\221d\ETX\244\192\148\163\158\187\243$.X\166\202\211\153\209\237\218\248",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("yb\183l\128\223\ENQ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("Q\140AB*\199\195j\143@\USo\199\190aA\198\245\248\172E",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\205,\SI\FS\230\197\161j<\221\143",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("b",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("x\229\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode6) { + uint8_t pkt[] = {0x82, 0x72, 0x10, 0x2c, 0x0, 0xd, 0x71, 0xd, 0x98, 0x5e, 0x23, 0x9e, 0x30, 0xd7, 0xef, 0x94, 0x45, + 0xb3, 0x4d, 0x2, 0x0, 0x9, 0xb2, 0x1e, 0x8b, 0x93, 0x1d, 0x88, 0x38, 0xa3, 0x5e, 0x1, 0x0, 0x17, + 0x38, 0x59, 0xdd, 0x64, 0x3, 0xf4, 0xc0, 0x94, 0xa3, 0x9e, 0xbb, 0xf3, 0x24, 0x2e, 0x58, 0xa6, 0xca, + 0xd3, 0x99, 0xd1, 0xed, 0xda, 0xf8, 0x0, 0x0, 0x7, 0x79, 0x62, 0xb7, 0x6c, 0x80, 0xdf, 0x5, 0x1, + 0x0, 0x15, 0x51, 0x8c, 0x41, 0x42, 0x2a, 0xc7, 0xc3, 0x6a, 0x8f, 0x40, 0x1f, 0x6f, 0xc7, 0xbe, 0x61, + 0x41, 0xc6, 0xf5, 0xf8, 0xac, 0x45, 0x2, 0x0, 0xb, 0xcd, 0x2c, 0xf, 0x1c, 0xe6, 0xc5, 0xa1, 0x6a, + 0x3c, 0xdd, 0x8f, 0x1, 0x0, 0x1, 0x62, 0x0, 0x0, 0x3, 0x78, 0xe5, 0x32, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x71, 0xd, 0x98, 0x5e, 0x23, 0x9e, 0x30, 0xd7, 0xef, 0x94, 0x45, 0xb3, 0x4d}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb2, 0x1e, 0x8b, 0x93, 0x1d, 0x88, 0x38, 0xa3, 0x5e}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x38, 0x59, 0xdd, 0x64, 0x3, 0xf4, 0xc0, 0x94, 0xa3, 0x9e, 0xbb, 0xf3, + 0x24, 0x2e, 0x58, 0xa6, 0xca, 0xd3, 0x99, 0xd1, 0xed, 0xda, 0xf8}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x79, 0x62, 0xb7, 0x6c, 0x80, 0xdf, 0x5}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x51, 0x8c, 0x41, 0x42, 0x2a, 0xc7, 0xc3, 0x6a, 0x8f, 0x40, 0x1f, + 0x6f, 0xc7, 0xbe, 0x61, 0x41, 0xc6, 0xf5, 0xf8, 0xac, 0x45}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xcd, 0x2c, 0xf, 0x1c, 0xe6, 0xc5, 0xa1, 0x6a, 0x3c, 0xdd, 0x8f}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x62}; + lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x78, 0xe5, 0x32}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4140, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 32171 [("\235\179\143\169o\140~\246\145>\228z*M/\153\204\US@%",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("/ti-C\SUB\US\190\&4\138",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\GS\205\155",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\161\159\232{t\166\134\176\251\137\135\166\212",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("hO\199\173\182",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("E\SI\143~\248\185\255\166X\245\253\209\171\231\220\133\210\226\SO",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode7) { + uint8_t pkt[] = {0x82, 0x5d, 0x7d, 0xab, 0x0, 0x14, 0xeb, 0xb3, 0x8f, 0xa9, 0x6f, 0x8c, 0x7e, 0xf6, 0x91, 0x3e, + 0xe4, 0x7a, 0x2a, 0x4d, 0x2f, 0x99, 0xcc, 0x1f, 0x40, 0x25, 0x0, 0x0, 0xa, 0x2f, 0x74, 0x69, + 0x2d, 0x43, 0x1a, 0x1f, 0xbe, 0x34, 0x8a, 0x0, 0x0, 0x3, 0x1d, 0xcd, 0x9b, 0x1, 0x0, 0x0, + 0x1, 0x0, 0xd, 0xa1, 0x9f, 0xe8, 0x7b, 0x74, 0xa6, 0x86, 0xb0, 0xfb, 0x89, 0x87, 0xa6, 0xd4, + 0x0, 0x0, 0x5, 0x68, 0x4f, 0xc7, 0xad, 0xb6, 0x0, 0x0, 0x13, 0x45, 0xf, 0x8f, 0x7e, 0xf8, + 0xb9, 0xff, 0xa6, 0x58, 0xf5, 0xfd, 0xd1, 0xab, 0xe7, 0xdc, 0x85, 0xd2, 0xe2, 0xe, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xeb, 0xb3, 0x8f, 0xa9, 0x6f, 0x8c, 0x7e, 0xf6, 0x91, 0x3e, + 0xe4, 0x7a, 0x2a, 0x4d, 0x2f, 0x99, 0xcc, 0x1f, 0x40, 0x25}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2f, 0x74, 0x69, 0x2d, 0x43, 0x1a, 0x1f, 0xbe, 0x34, 0x8a}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1d, 0xcd, 0x9b}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa1, 0x9f, 0xe8, 0x7b, 0x74, 0xa6, 0x86, 0xb0, 0xfb, 0x89, 0x87, 0xa6, 0xd4}; + lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x68, 0x4f, 0xc7, 0xad, 0xb6}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x45, 0xf, 0x8f, 0x7e, 0xf8, 0xb9, 0xff, 0xa6, 0x58, 0xf5, + 0xfd, 0xd1, 0xab, 0xe7, 0xdc, 0x85, 0xd2, 0xe2, 0xe}; + lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32171, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 29078 [("\201\248\\\248\245\254b\200k\161O\234i|\156\CAN\154+$\r\DLEu\179\"_|S}",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("#\234t\173\SOH%\NUL\251\216}\164\226\144\198\195\234\174\FSJ\136\GS\239\130\227\136\NAK",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("A\129\149O\210j]Y\247\205{\133\US\158\220U\204Gq\195\159\200kM\141\DLE\155\245\175",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\RST\234",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("h\USN\NUL\199Ix\174\RS\FS#\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode8) { + uint8_t pkt[] = {0x82, 0x73, 0x71, 0x96, 0x0, 0x1c, 0xc9, 0xf8, 0x5c, 0xf8, 0xf5, 0xfe, 0x62, 0xc8, 0x6b, 0xa1, 0x4f, + 0xea, 0x69, 0x7c, 0x9c, 0x18, 0x9a, 0x2b, 0x24, 0xd, 0x10, 0x75, 0xb3, 0x22, 0x5f, 0x7c, 0x53, 0x7d, + 0x0, 0x0, 0x1a, 0x23, 0xea, 0x74, 0xad, 0x1, 0x25, 0x0, 0xfb, 0xd8, 0x7d, 0xa4, 0xe2, 0x90, 0xc6, + 0xc3, 0xea, 0xae, 0x1c, 0x4a, 0x88, 0x1d, 0xef, 0x82, 0xe3, 0x88, 0x15, 0x1, 0x0, 0x1d, 0x41, 0x81, + 0x95, 0x4f, 0xd2, 0x6a, 0x5d, 0x59, 0xf7, 0xcd, 0x7b, 0x85, 0x1f, 0x9e, 0xdc, 0x55, 0xcc, 0x47, 0x71, + 0xc3, 0x9f, 0xc8, 0x6b, 0x4d, 0x8d, 0x10, 0x9b, 0xf5, 0xaf, 0x0, 0x0, 0x3, 0x1e, 0x54, 0xea, 0x2, + 0x0, 0xc, 0x68, 0x1f, 0x4e, 0x0, 0xc7, 0x49, 0x78, 0xae, 0x1e, 0x1c, 0x23, 0xae, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xc9, 0xf8, 0x5c, 0xf8, 0xf5, 0xfe, 0x62, 0xc8, 0x6b, 0xa1, + 0x4f, 0xea, 0x69, 0x7c, 0x9c, 0x18, 0x9a, 0x2b, 0x24, 0xd, + 0x10, 0x75, 0xb3, 0x22, 0x5f, 0x7c, 0x53, 0x7d}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x23, 0xea, 0x74, 0xad, 0x1, 0x25, 0x0, 0xfb, 0xd8, 0x7d, 0xa4, 0xe2, 0x90, + 0xc6, 0xc3, 0xea, 0xae, 0x1c, 0x4a, 0x88, 0x1d, 0xef, 0x82, 0xe3, 0x88, 0x15}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x41, 0x81, 0x95, 0x4f, 0xd2, 0x6a, 0x5d, 0x59, 0xf7, 0xcd, + 0x7b, 0x85, 0x1f, 0x9e, 0xdc, 0x55, 0xcc, 0x47, 0x71, 0xc3, + 0x9f, 0xc8, 0x6b, 0x4d, 0x8d, 0x10, 0x9b, 0xf5, 0xaf}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x1e, 0x54, 0xea}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x68, 0x1f, 0x4e, 0x0, 0xc7, 0x49, 0x78, 0xae, 0x1e, 0x1c, 0x23, 0xae}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29078, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 756 [("F\229~\a\235\170;\164\DC1\152",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\208fV\240",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("X\FS\146$\204\DLE\249b\249R\142P\254No\129",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\212\SUB\138(T\SYN-\252",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\ETX\"\SUB\EM\ETB\133\248d\162\156\244\246",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("R\179\184\&9\148\238\184\166\149\"\208s&A\130\132s(\240\133\165\CAN\EMN",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\252\128\176 +// \139\212\226\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\154\137px\248W\245mK\174\255)oi\SOH\235\145\SO\t\EOT\190\144`%N\219\225\189\179",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("}\193\237\&6\129\180b\DEL\136\247\147W\ETX\229!\156\ACK\226fs\144+\DEL#'\202",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\203\203\184\175b\208n\245r\221R; +// \147\ACK%e9\161\NAKG:-fE\172\128",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode9) { + uint8_t pkt[] = {0x82, 0xc7, 0x1, 0x2, 0xf4, 0x0, 0xa, 0x46, 0xe5, 0x7e, 0x7, 0xeb, 0xaa, 0x3b, 0xa4, 0x11, 0x98, + 0x2, 0x0, 0x4, 0xd0, 0x66, 0x56, 0xf0, 0x0, 0x0, 0x10, 0x58, 0x1c, 0x92, 0x24, 0xcc, 0x10, 0xf9, + 0x62, 0xf9, 0x52, 0x8e, 0x50, 0xfe, 0x4e, 0x6f, 0x81, 0x1, 0x0, 0x8, 0xd4, 0x1a, 0x8a, 0x28, 0x54, + 0x16, 0x2d, 0xfc, 0x2, 0x0, 0xc, 0x3, 0x22, 0x1a, 0x19, 0x17, 0x85, 0xf8, 0x64, 0xa2, 0x9c, 0xf4, + 0xf6, 0x2, 0x0, 0x18, 0x52, 0xb3, 0xb8, 0x39, 0x94, 0xee, 0xb8, 0xa6, 0x95, 0x22, 0xd0, 0x73, 0x26, + 0x41, 0x82, 0x84, 0x73, 0x28, 0xf0, 0x85, 0xa5, 0x18, 0x19, 0x4e, 0x2, 0x0, 0x8, 0xfc, 0x80, 0xb0, + 0x20, 0x8b, 0xd4, 0xe2, 0xd0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1d, 0x9a, 0x89, 0x70, 0x78, 0xf8, 0x57, + 0xf5, 0x6d, 0x4b, 0xae, 0xff, 0x29, 0x6f, 0x69, 0x1, 0xeb, 0x91, 0xe, 0x9, 0x4, 0xbe, 0x90, 0x60, + 0x25, 0x4e, 0xdb, 0xe1, 0xbd, 0xb3, 0x0, 0x0, 0x1a, 0x7d, 0xc1, 0xed, 0x36, 0x81, 0xb4, 0x62, 0x7f, + 0x88, 0xf7, 0x93, 0x57, 0x3, 0xe5, 0x21, 0x9c, 0x6, 0xe2, 0x66, 0x73, 0x90, 0x2b, 0x7f, 0x23, 0x27, + 0xca, 0x2, 0x0, 0x1b, 0xcb, 0xcb, 0xb8, 0xaf, 0x62, 0xd0, 0x6e, 0xf5, 0x72, 0xdd, 0x52, 0x3b, 0x20, + 0x93, 0x6, 0x25, 0x65, 0x39, 0xa1, 0x15, 0x47, 0x3a, 0x2d, 0x66, 0x45, 0xac, 0x80, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x46, 0xe5, 0x7e, 0x7, 0xeb, 0xaa, 0x3b, 0xa4, 0x11, 0x98}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd0, 0x66, 0x56, 0xf0}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x58, 0x1c, 0x92, 0x24, 0xcc, 0x10, 0xf9, 0x62, + 0xf9, 0x52, 0x8e, 0x50, 0xfe, 0x4e, 0x6f, 0x81}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd4, 0x1a, 0x8a, 0x28, 0x54, 0x16, 0x2d, 0xfc}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x3, 0x22, 0x1a, 0x19, 0x17, 0x85, 0xf8, 0x64, 0xa2, 0x9c, 0xf4, 0xf6}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x52, 0xb3, 0xb8, 0x39, 0x94, 0xee, 0xb8, 0xa6, 0x95, 0x22, 0xd0, 0x73, + 0x26, 0x41, 0x82, 0x84, 0x73, 0x28, 0xf0, 0x85, 0xa5, 0x18, 0x19, 0x4e}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xfc, 0x80, 0xb0, 0x20, 0x8b, 0xd4, 0xe2, 0xd0}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x9a, 0x89, 0x70, 0x78, 0xf8, 0x57, 0xf5, 0x6d, 0x4b, 0xae, + 0xff, 0x29, 0x6f, 0x69, 0x1, 0xeb, 0x91, 0xe, 0x9, 0x4, + 0xbe, 0x90, 0x60, 0x25, 0x4e, 0xdb, 0xe1, 0xbd, 0xb3}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x7d, 0xc1, 0xed, 0x36, 0x81, 0xb4, 0x62, 0x7f, 0x88, 0xf7, 0x93, 0x57, 0x3, + 0xe5, 0x21, 0x9c, 0x6, 0xe2, 0x66, 0x73, 0x90, 0x2b, 0x7f, 0x23, 0x27, 0xca}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xcb, 0xcb, 0xb8, 0xaf, 0x62, 0xd0, 0x6e, 0xf5, 0x72, + 0xdd, 0x52, 0x3b, 0x20, 0x93, 0x6, 0x25, 0x65, 0x39, + 0xa1, 0x15, 0x47, 0x3a, 0x2d, 0x66, 0x45, 0xac, 0x80}; + lwmqtt_string_t topic_filter_s10 = {27, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 756, 11, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 16233 [("EBW",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("T\254+V h\152\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("3!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\DC3n;\202\230\SUB\132\139\138\185;\174&\231+wf\251U\f\EMGS\207\&0v\246",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\v\207\&8\151z2J\146\DC2;\214\252\DC3\139\b\232\242\&5\190\231\229~^\172\238\SI:e\SUB",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("4\212\138\243\171\200\217@\238\210[E\146\241\SO\183\128",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode10) { + uint8_t pkt[] = {0x82, 0x6e, 0x3f, 0x69, 0x0, 0x3, 0x45, 0x42, 0x57, 0x1, 0x0, 0x1, 0x6e, 0x0, 0x0, 0x8, + 0x54, 0xfe, 0x2b, 0x56, 0x20, 0x68, 0x98, 0xaa, 0x1, 0x0, 0x2, 0x33, 0x21, 0x0, 0x0, 0x1b, + 0x13, 0x6e, 0x3b, 0xca, 0xe6, 0x1a, 0x84, 0x8b, 0x8a, 0xb9, 0x3b, 0xae, 0x26, 0xe7, 0x2b, 0x77, + 0x66, 0xfb, 0x55, 0xc, 0x19, 0x47, 0x53, 0xcf, 0x30, 0x76, 0xf6, 0x0, 0x0, 0x1d, 0xb, 0xcf, + 0x38, 0x97, 0x7a, 0x32, 0x4a, 0x92, 0x12, 0x3b, 0xd6, 0xfc, 0x13, 0x8b, 0x8, 0xe8, 0xf2, 0x35, + 0xbe, 0xe7, 0xe5, 0x7e, 0x5e, 0xac, 0xee, 0xf, 0x3a, 0x65, 0x1a, 0x2, 0x0, 0x11, 0x34, 0xd4, + 0x8a, 0xf3, 0xab, 0xc8, 0xd9, 0x40, 0xee, 0xd2, 0x5b, 0x45, 0x92, 0xf1, 0xe, 0xb7, 0x80, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x45, 0x42, 0x57}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6e}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x54, 0xfe, 0x2b, 0x56, 0x20, 0x68, 0x98, 0xaa}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x33, 0x21}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x13, 0x6e, 0x3b, 0xca, 0xe6, 0x1a, 0x84, 0x8b, 0x8a, 0xb9, 0x3b, 0xae, 0x26, 0xe7, + 0x2b, 0x77, 0x66, 0xfb, 0x55, 0xc, 0x19, 0x47, 0x53, 0xcf, 0x30, 0x76, 0xf6}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb, 0xcf, 0x38, 0x97, 0x7a, 0x32, 0x4a, 0x92, 0x12, 0x3b, + 0xd6, 0xfc, 0x13, 0x8b, 0x8, 0xe8, 0xf2, 0x35, 0xbe, 0xe7, + 0xe5, 0x7e, 0x5e, 0xac, 0xee, 0xf, 0x3a, 0x65, 0x1a}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x34, 0xd4, 0x8a, 0xf3, 0xab, 0xc8, 0xd9, 0x40, 0xee, + 0xd2, 0x5b, 0x45, 0x92, 0xf1, 0xe, 0xb7, 0x80}; + lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16233, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 27988 [("\215:8'\163*\137K\190_\182*\204\144\ETX\186\242\234\173\138,f\158\190",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("P7\f\231T5\214\vP\216h\NUL\DC3\b\224\SI",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\132~\184",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\235\ESC\184\223^M\136\133\196\&6\247\CAN/M\231\201c\165j\230",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("1\153n\DC1\168\129\189\149\&7+F>\DC4d\249\172\130\DC4\ACK_\177*\237C\228\f\DC4\a<]",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\238E\134\179f\SOH\209\229\239w\165\242\181\DC4\182\139\180\ETX\178!1",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("k\222\133\254$\SYN\235\a\154\140U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\254",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode11) { + uint8_t pkt[] = {0x82, 0x98, 0x1, 0x6d, 0x54, 0x0, 0x18, 0xd7, 0x3a, 0x38, 0x27, 0xa3, 0x2a, 0x89, 0x4b, 0xbe, + 0x5f, 0xb6, 0x2a, 0xcc, 0x90, 0x3, 0xba, 0xf2, 0xea, 0xad, 0x8a, 0x2c, 0x66, 0x9e, 0xbe, 0x0, + 0x0, 0x10, 0x50, 0x37, 0xc, 0xe7, 0x54, 0x35, 0xd6, 0xb, 0x50, 0xd8, 0x68, 0x0, 0x13, 0x8, + 0xe0, 0xf, 0x0, 0x0, 0x3, 0x84, 0x7e, 0xb8, 0x0, 0x0, 0x14, 0xeb, 0x1b, 0xb8, 0xdf, 0x5e, + 0x4d, 0x88, 0x85, 0xc4, 0x36, 0xf7, 0x18, 0x2f, 0x4d, 0xe7, 0xc9, 0x63, 0xa5, 0x6a, 0xe6, 0x1, + 0x0, 0x1e, 0x31, 0x99, 0x6e, 0x11, 0xa8, 0x81, 0xbd, 0x95, 0x37, 0x2b, 0x46, 0x3e, 0x14, 0x64, + 0xf9, 0xac, 0x82, 0x14, 0x6, 0x5f, 0xb1, 0x2a, 0xed, 0x43, 0xe4, 0xc, 0x14, 0x7, 0x3c, 0x5d, + 0x1, 0x0, 0x15, 0xee, 0x45, 0x86, 0xb3, 0x66, 0x1, 0xd1, 0xe5, 0xef, 0x77, 0xa5, 0xf2, 0xb5, + 0x14, 0xb6, 0x8b, 0xb4, 0x3, 0xb2, 0x21, 0x31, 0x1, 0x0, 0xb, 0x6b, 0xde, 0x85, 0xfe, 0x24, + 0x16, 0xeb, 0x7, 0x9a, 0x8c, 0x55, 0x1, 0x0, 0x1, 0xfe, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xd7, 0x3a, 0x38, 0x27, 0xa3, 0x2a, 0x89, 0x4b, 0xbe, 0x5f, 0xb6, 0x2a, + 0xcc, 0x90, 0x3, 0xba, 0xf2, 0xea, 0xad, 0x8a, 0x2c, 0x66, 0x9e, 0xbe}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x50, 0x37, 0xc, 0xe7, 0x54, 0x35, 0xd6, 0xb, + 0x50, 0xd8, 0x68, 0x0, 0x13, 0x8, 0xe0, 0xf}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x84, 0x7e, 0xb8}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xeb, 0x1b, 0xb8, 0xdf, 0x5e, 0x4d, 0x88, 0x85, 0xc4, 0x36, + 0xf7, 0x18, 0x2f, 0x4d, 0xe7, 0xc9, 0x63, 0xa5, 0x6a, 0xe6}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x99, 0x6e, 0x11, 0xa8, 0x81, 0xbd, 0x95, 0x37, 0x2b, + 0x46, 0x3e, 0x14, 0x64, 0xf9, 0xac, 0x82, 0x14, 0x6, 0x5f, + 0xb1, 0x2a, 0xed, 0x43, 0xe4, 0xc, 0x14, 0x7, 0x3c, 0x5d}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xee, 0x45, 0x86, 0xb3, 0x66, 0x1, 0xd1, 0xe5, 0xef, 0x77, 0xa5, + 0xf2, 0xb5, 0x14, 0xb6, 0x8b, 0xb4, 0x3, 0xb2, 0x21, 0x31}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x6b, 0xde, 0x85, 0xfe, 0x24, 0x16, 0xeb, 0x7, 0x9a, 0x8c, 0x55}; + lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xfe}; + lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27988, 8, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 19880 [("\163\224\DC4H\243\234r\170\191\212<\172Q\159\207\205\131=\189\132W",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\DLE\190\ETXgAE\133z \251",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("4 ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\229\210&\235\147\255",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\GS{\223`IldKX@9",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\198W8*B\175+,@\234j\200\209\167\187",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("\203#\222\STX\217\221[6\138\196[\189\236\190\187Q\225\143+]\183U\141lq\242\SI\253",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode12) { + uint8_t pkt[] = {0x82, 0x74, 0x4d, 0xa8, 0x0, 0x15, 0xa3, 0xe0, 0x14, 0x48, 0xf3, 0xea, 0x72, 0xaa, 0xbf, 0xd4, 0x3c, + 0xac, 0x51, 0x9f, 0xcf, 0xcd, 0x83, 0x3d, 0xbd, 0x84, 0x57, 0x0, 0x0, 0xa, 0x10, 0xbe, 0x3, 0x67, + 0x41, 0x45, 0x85, 0x7a, 0x20, 0xfb, 0x0, 0x0, 0x2, 0x34, 0x20, 0x2, 0x0, 0x6, 0xe5, 0xd2, 0x26, + 0xeb, 0x93, 0xff, 0x0, 0x0, 0xb, 0x1d, 0x7b, 0xdf, 0x60, 0x49, 0x6c, 0x64, 0x4b, 0x58, 0x40, 0x39, + 0x0, 0x0, 0xf, 0xc6, 0x57, 0x38, 0x2a, 0x42, 0xaf, 0x2b, 0x2c, 0x40, 0xea, 0x6a, 0xc8, 0xd1, 0xa7, + 0xbb, 0x2, 0x0, 0x1c, 0xcb, 0x23, 0xde, 0x2, 0xd9, 0xdd, 0x5b, 0x36, 0x8a, 0xc4, 0x5b, 0xbd, 0xec, + 0xbe, 0xbb, 0x51, 0xe1, 0x8f, 0x2b, 0x5d, 0xb7, 0x55, 0x8d, 0x6c, 0x71, 0xf2, 0xf, 0xfd, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xa3, 0xe0, 0x14, 0x48, 0xf3, 0xea, 0x72, 0xaa, 0xbf, 0xd4, 0x3c, + 0xac, 0x51, 0x9f, 0xcf, 0xcd, 0x83, 0x3d, 0xbd, 0x84, 0x57}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x10, 0xbe, 0x3, 0x67, 0x41, 0x45, 0x85, 0x7a, 0x20, 0xfb}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x34, 0x20}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe5, 0xd2, 0x26, 0xeb, 0x93, 0xff}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x1d, 0x7b, 0xdf, 0x60, 0x49, 0x6c, 0x64, 0x4b, 0x58, 0x40, 0x39}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xc6, 0x57, 0x38, 0x2a, 0x42, 0xaf, 0x2b, 0x2c, + 0x40, 0xea, 0x6a, 0xc8, 0xd1, 0xa7, 0xbb}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xcb, 0x23, 0xde, 0x2, 0xd9, 0xdd, 0x5b, 0x36, 0x8a, 0xc4, + 0x5b, 0xbd, 0xec, 0xbe, 0xbb, 0x51, 0xe1, 0x8f, 0x2b, 0x5d, + 0xb7, 0x55, 0x8d, 0x6c, 0x71, 0xf2, 0xf, 0xfd}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19880, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 22493 [("\227\138\DC4\248mr\146&d\209\219",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode13) { + uint8_t pkt[] = {0x82, 0x10, 0x57, 0xdd, 0x0, 0xb, 0xe3, 0x8a, 0x14, + 0xf8, 0x6d, 0x72, 0x92, 0x26, 0x64, 0xd1, 0xdb, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xe3, 0x8a, 0x14, 0xf8, 0x6d, 0x72, 0x92, 0x26, 0x64, 0xd1, 0xdb}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22493, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 32664 [("\244\185\249\145\SUB\GS\167&\200\201\187E=\184\234\232",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("i\217U\176\198\245\226",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("[gE\131-\185\148\217\a\169\&5(\185\236?\187\171\208\130\242\SIdq\SO\USND",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(" +// Y\246\139\\xj\202)\182v\166\bFEb\245H\130",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\160\&3\132\234x\252\200\NUL]\134",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\211\139\255*\EOT\232\243\147D\252\SI\215\&5F\SIF[\209\SUBw\195I\130",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode14) { + uint8_t pkt[] = {0x82, 0x7a, 0x7f, 0x98, 0x0, 0x10, 0xf4, 0xb9, 0xf9, 0x91, 0x1a, 0x1d, 0xa7, 0x26, 0xc8, 0xc9, + 0xbb, 0x45, 0x3d, 0xb8, 0xea, 0xe8, 0x0, 0x0, 0x7, 0x69, 0xd9, 0x55, 0xb0, 0xc6, 0xf5, 0xe2, + 0x0, 0x0, 0x1b, 0x5b, 0x67, 0x45, 0x83, 0x2d, 0xb9, 0x94, 0xd9, 0x7, 0xa9, 0x35, 0x28, 0xb9, + 0xec, 0x3f, 0xbb, 0xab, 0xd0, 0x82, 0xf2, 0xf, 0x64, 0x71, 0xe, 0x1f, 0x4e, 0x44, 0x1, 0x0, + 0x13, 0x20, 0x59, 0xf6, 0x8b, 0x5c, 0x78, 0x6a, 0xca, 0x29, 0xb6, 0x76, 0xa6, 0x8, 0x46, 0x45, + 0x62, 0xf5, 0x48, 0x82, 0x2, 0x0, 0xa, 0xa0, 0x33, 0x84, 0xea, 0x78, 0xfc, 0xc8, 0x0, 0x5d, + 0x86, 0x0, 0x0, 0x17, 0xd3, 0x8b, 0xff, 0x2a, 0x4, 0xe8, 0xf3, 0x93, 0x44, 0xfc, 0xf, 0xd7, + 0x35, 0x46, 0xf, 0x46, 0x5b, 0xd1, 0x1a, 0x77, 0xc3, 0x49, 0x82, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xf4, 0xb9, 0xf9, 0x91, 0x1a, 0x1d, 0xa7, 0x26, + 0xc8, 0xc9, 0xbb, 0x45, 0x3d, 0xb8, 0xea, 0xe8}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x69, 0xd9, 0x55, 0xb0, 0xc6, 0xf5, 0xe2}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5b, 0x67, 0x45, 0x83, 0x2d, 0xb9, 0x94, 0xd9, 0x7, 0xa9, 0x35, 0x28, 0xb9, 0xec, + 0x3f, 0xbb, 0xab, 0xd0, 0x82, 0xf2, 0xf, 0x64, 0x71, 0xe, 0x1f, 0x4e, 0x44}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x20, 0x59, 0xf6, 0x8b, 0x5c, 0x78, 0x6a, 0xca, 0x29, 0xb6, + 0x76, 0xa6, 0x8, 0x46, 0x45, 0x62, 0xf5, 0x48, 0x82}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa0, 0x33, 0x84, 0xea, 0x78, 0xfc, 0xc8, 0x0, 0x5d, 0x86}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xd3, 0x8b, 0xff, 0x2a, 0x4, 0xe8, 0xf3, 0x93, 0x44, 0xfc, 0xf, 0xd7, + 0x35, 0x46, 0xf, 0x46, 0x5b, 0xd1, 0x1a, 0x77, 0xc3, 0x49, 0x82}; + lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32664, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 21953 [("\STX\245\160\232\SUB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),(",\r\215\243\217\137",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\ENQ\196M\SYN\244\173\DC2\170\SO\STXb\USw+z\173U\f\130\&4V\199\173\142\160\165\153\201\166\&4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode15) { + uint8_t pkt[] = {0x82, 0x34, 0x55, 0xc1, 0x0, 0x5, 0x2, 0xf5, 0xa0, 0xe8, 0x1a, 0x2, 0x0, 0x6, + 0x2c, 0xd, 0xd7, 0xf3, 0xd9, 0x89, 0x2, 0x0, 0x1e, 0x5, 0xc4, 0x4d, 0x16, 0xf4, + 0xad, 0x12, 0xaa, 0xe, 0x2, 0x62, 0x1f, 0x77, 0x2b, 0x7a, 0xad, 0x55, 0xc, 0x82, + 0x34, 0x56, 0xc7, 0xad, 0x8e, 0xa0, 0xa5, 0x99, 0xc9, 0xa6, 0x34, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x2, 0xf5, 0xa0, 0xe8, 0x1a}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2c, 0xd, 0xd7, 0xf3, 0xd9, 0x89}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5, 0xc4, 0x4d, 0x16, 0xf4, 0xad, 0x12, 0xaa, 0xe, 0x2, + 0x62, 0x1f, 0x77, 0x2b, 0x7a, 0xad, 0x55, 0xc, 0x82, 0x34, + 0x56, 0xc7, 0xad, 0x8e, 0xa0, 0xa5, 0x99, 0xc9, 0xa6, 0x34}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21953, 3, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 20725 [("\128b\134\ACK",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("e\184\fN\150\215\RSt\rh\167\248\DC1\152\SOH\247\EOT\209\136i\165",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode16) { + uint8_t pkt[] = {0x82, 0x21, 0x50, 0xf5, 0x0, 0x4, 0x80, 0x62, 0x86, 0x6, 0x2, 0x0, + 0x15, 0x65, 0xb8, 0xc, 0x4e, 0x96, 0xd7, 0x1e, 0x74, 0xd, 0x68, 0xa7, + 0xf8, 0x11, 0x98, 0x1, 0xf7, 0x4, 0xd1, 0x88, 0x69, 0xa5, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x80, 0x62, 0x86, 0x6}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x65, 0xb8, 0xc, 0x4e, 0x96, 0xd7, 0x1e, 0x74, 0xd, 0x68, 0xa7, + 0xf8, 0x11, 0x98, 0x1, 0xf7, 0x4, 0xd1, 0x88, 0x69, 0xa5}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20725, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 24375 [("Xx.\181I\175\249\174u\214\foC'\226e\196\233\RS\136\225[0\172-y\128",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\203Dra\249\DC2s\SOe\167\r}\158\ETX\128\141\242?5\203\239\147",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("Y\242H\243&V\212K2\185\&2sq\178\178c\194\230\214)\\\237\ETX\SO",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\rm3\DEL,+L\150\CAN|9j\159\255g\206\t\FS=\160\201\&1",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode17) { + uint8_t pkt[] = {0x82, 0x6d, 0x5f, 0x37, 0x0, 0x1b, 0x58, 0x78, 0x2e, 0xb5, 0x49, 0xaf, 0xf9, 0xae, 0x75, 0xd6, + 0xc, 0x6f, 0x43, 0x27, 0xe2, 0x65, 0xc4, 0xe9, 0x1e, 0x88, 0xe1, 0x5b, 0x30, 0xac, 0x2d, 0x79, + 0x80, 0x2, 0x0, 0x16, 0xcb, 0x44, 0x72, 0x61, 0xf9, 0x12, 0x73, 0xe, 0x65, 0xa7, 0xd, 0x7d, + 0x9e, 0x3, 0x80, 0x8d, 0xf2, 0x3f, 0x35, 0xcb, 0xef, 0x93, 0x0, 0x0, 0x18, 0x59, 0xf2, 0x48, + 0xf3, 0x26, 0x56, 0xd4, 0x4b, 0x32, 0xb9, 0x32, 0x73, 0x71, 0xb2, 0xb2, 0x63, 0xc2, 0xe6, 0xd6, + 0x29, 0x5c, 0xed, 0x3, 0xe, 0x2, 0x0, 0x16, 0xd, 0x6d, 0x33, 0x7f, 0x2c, 0x2b, 0x4c, 0x96, + 0x18, 0x7c, 0x39, 0x6a, 0x9f, 0xff, 0x67, 0xce, 0x9, 0x1c, 0x3d, 0xa0, 0xc9, 0x31, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x58, 0x78, 0x2e, 0xb5, 0x49, 0xaf, 0xf9, 0xae, 0x75, 0xd6, 0xc, 0x6f, 0x43, 0x27, + 0xe2, 0x65, 0xc4, 0xe9, 0x1e, 0x88, 0xe1, 0x5b, 0x30, 0xac, 0x2d, 0x79, 0x80}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xcb, 0x44, 0x72, 0x61, 0xf9, 0x12, 0x73, 0xe, 0x65, 0xa7, 0xd, + 0x7d, 0x9e, 0x3, 0x80, 0x8d, 0xf2, 0x3f, 0x35, 0xcb, 0xef, 0x93}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x59, 0xf2, 0x48, 0xf3, 0x26, 0x56, 0xd4, 0x4b, 0x32, 0xb9, 0x32, 0x73, + 0x71, 0xb2, 0xb2, 0x63, 0xc2, 0xe6, 0xd6, 0x29, 0x5c, 0xed, 0x3, 0xe}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd, 0x6d, 0x33, 0x7f, 0x2c, 0x2b, 0x4c, 0x96, 0x18, 0x7c, 0x39, + 0x6a, 0x9f, 0xff, 0x67, 0xce, 0x9, 0x1c, 0x3d, 0xa0, 0xc9, 0x31}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24375, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 15182 [("jX\253\212\226>%\234\136\158",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("wv\141n\252k\ESC\242,\211jBIr\ESC\nN\254\RSG\227C\180/A\174\244\STX\228\222",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("WE\f\171+\DC1\ETB\v\EOT\DLE\176\tw_\SYN/\ETX",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\161AM\198\RS6\146w\219\173\244\245J>\201",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS2}),("e\171N\STX\186ov\240\229\136D\\\234J\152e\217",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode18) { + uint8_t pkt[] = {0x82, 0x6a, 0x3b, 0x4e, 0x0, 0xa, 0x6a, 0x58, 0xfd, 0xd4, 0xe2, 0x3e, 0x25, 0xea, 0x88, 0x9e, + 0x1, 0x0, 0x1e, 0x77, 0x76, 0x8d, 0x6e, 0xfc, 0x6b, 0x1b, 0xf2, 0x2c, 0xd3, 0x6a, 0x42, 0x49, + 0x72, 0x1b, 0xa, 0x4e, 0xfe, 0x1e, 0x47, 0xe3, 0x43, 0xb4, 0x2f, 0x41, 0xae, 0xf4, 0x2, 0xe4, + 0xde, 0x1, 0x0, 0x11, 0x57, 0x45, 0xc, 0xab, 0x2b, 0x11, 0x17, 0xb, 0x4, 0x10, 0xb0, 0x9, + 0x77, 0x5f, 0x16, 0x2f, 0x3, 0x1, 0x0, 0xf, 0xa1, 0x41, 0x4d, 0xc6, 0x1e, 0x36, 0x92, 0x77, + 0xdb, 0xad, 0xf4, 0xf5, 0x4a, 0x3e, 0xc9, 0x2, 0x0, 0x11, 0x65, 0xab, 0x4e, 0x2, 0xba, 0x6f, + 0x76, 0xf0, 0xe5, 0x88, 0x44, 0x5c, 0xea, 0x4a, 0x98, 0x65, 0xd9, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x6a, 0x58, 0xfd, 0xd4, 0xe2, 0x3e, 0x25, 0xea, 0x88, 0x9e}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x77, 0x76, 0x8d, 0x6e, 0xfc, 0x6b, 0x1b, 0xf2, 0x2c, 0xd3, + 0x6a, 0x42, 0x49, 0x72, 0x1b, 0xa, 0x4e, 0xfe, 0x1e, 0x47, + 0xe3, 0x43, 0xb4, 0x2f, 0x41, 0xae, 0xf4, 0x2, 0xe4, 0xde}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x57, 0x45, 0xc, 0xab, 0x2b, 0x11, 0x17, 0xb, 0x4, + 0x10, 0xb0, 0x9, 0x77, 0x5f, 0x16, 0x2f, 0x3}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa1, 0x41, 0x4d, 0xc6, 0x1e, 0x36, 0x92, 0x77, + 0xdb, 0xad, 0xf4, 0xf5, 0x4a, 0x3e, 0xc9}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x65, 0xab, 0x4e, 0x2, 0xba, 0x6f, 0x76, 0xf0, 0xe5, + 0x88, 0x44, 0x5c, 0xea, 0x4a, 0x98, 0x65, 0xd9}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15182, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 29268 [("\142",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = +// QoS0}),("5\254\147\212\152\233@<\242\195\191\180#\\Sl\SI\249(\174P\136\239\"B\182\139\218",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\229\173x +// \159d\157\161F\133y\253\&4\185\191h\167\231\noU\SI/\158\193\239",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(";Q=\182\248\245\152C&\221k\173\153\ESC\151\156",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Q\168tf\193i\245\US\ENQ\177nl\202/\177",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\177\139\193I\228b\DLEvi\211\r{\aRg",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\195E\216",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("l\151\230\r\129\b\184\193\176\178\162\197\&5\188/\SO\187",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(" k\147",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode19) { + uint8_t pkt[] = {0x82, 0x99, 0x1, 0x72, 0x54, 0x0, 0x1, 0x8e, 0x0, 0x0, 0x1c, 0x35, 0xfe, 0x93, 0xd4, 0x98, + 0xe9, 0x40, 0x3c, 0xf2, 0xc3, 0xbf, 0xb4, 0x23, 0x5c, 0x53, 0x6c, 0xf, 0xf9, 0x28, 0xae, 0x50, + 0x88, 0xef, 0x22, 0x42, 0xb6, 0x8b, 0xda, 0x1, 0x0, 0x1a, 0xe5, 0xad, 0x78, 0x20, 0x9f, 0x64, + 0x9d, 0xa1, 0x46, 0x85, 0x79, 0xfd, 0x34, 0xb9, 0xbf, 0x68, 0xa7, 0xe7, 0xa, 0x6f, 0x55, 0xf, + 0x2f, 0x9e, 0xc1, 0xef, 0x0, 0x0, 0x10, 0x3b, 0x51, 0x3d, 0xb6, 0xf8, 0xf5, 0x98, 0x43, 0x26, + 0xdd, 0x6b, 0xad, 0x99, 0x1b, 0x97, 0x9c, 0x2, 0x0, 0xf, 0x51, 0xa8, 0x74, 0x66, 0xc1, 0x69, + 0xf5, 0x1f, 0x5, 0xb1, 0x6e, 0x6c, 0xca, 0x2f, 0xb1, 0x1, 0x0, 0xf, 0xb1, 0x8b, 0xc1, 0x49, + 0xe4, 0x62, 0x10, 0x76, 0x69, 0xd3, 0xd, 0x7b, 0x7, 0x52, 0x67, 0x1, 0x0, 0x3, 0xc3, 0x45, + 0xd8, 0x2, 0x0, 0x11, 0x6c, 0x97, 0xe6, 0xd, 0x81, 0x8, 0xb8, 0xc1, 0xb0, 0xb2, 0xa2, 0xc5, + 0x35, 0xbc, 0x2f, 0xe, 0xbb, 0x0, 0x0, 0x3, 0x20, 0x6b, 0x93, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x8e}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x35, 0xfe, 0x93, 0xd4, 0x98, 0xe9, 0x40, 0x3c, 0xf2, 0xc3, + 0xbf, 0xb4, 0x23, 0x5c, 0x53, 0x6c, 0xf, 0xf9, 0x28, 0xae, + 0x50, 0x88, 0xef, 0x22, 0x42, 0xb6, 0x8b, 0xda}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe5, 0xad, 0x78, 0x20, 0x9f, 0x64, 0x9d, 0xa1, 0x46, 0x85, 0x79, 0xfd, 0x34, + 0xb9, 0xbf, 0x68, 0xa7, 0xe7, 0xa, 0x6f, 0x55, 0xf, 0x2f, 0x9e, 0xc1, 0xef}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x3b, 0x51, 0x3d, 0xb6, 0xf8, 0xf5, 0x98, 0x43, + 0x26, 0xdd, 0x6b, 0xad, 0x99, 0x1b, 0x97, 0x9c}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x51, 0xa8, 0x74, 0x66, 0xc1, 0x69, 0xf5, 0x1f, + 0x5, 0xb1, 0x6e, 0x6c, 0xca, 0x2f, 0xb1}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb1, 0x8b, 0xc1, 0x49, 0xe4, 0x62, 0x10, 0x76, + 0x69, 0xd3, 0xd, 0x7b, 0x7, 0x52, 0x67}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc3, 0x45, 0xd8}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6c, 0x97, 0xe6, 0xd, 0x81, 0x8, 0xb8, 0xc1, 0xb0, + 0xb2, 0xa2, 0xc5, 0x35, 0xbc, 0x2f, 0xe, 0xbb}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x20, 0x6b, 0x93}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29268, 9, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 30528 [("Z7\246b'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\248\161\240\135Q\130\198oV\RS\187~7'\DC2@\ACK~i\213csX\200kE\240",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\248\215\167X\a\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("W\139~\240\234\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("\226\223\ETXA\170{\FS\197RN\147X\161\ESC\SI\a\197\vB3\232\220\160{\136\242\&5\150\150",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\134\236\184\180A/4\206\134\176p\163\&6\NUL\RS$\US\200\CAN\DELU\156\224",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ENQ\177",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\207\&1\134\149\169\137_\145\\\185,\187\242\226\135J>\203\203B\245\196\147\239\168\212\167\145\219",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(",\176\197p\224M\\\200",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\155w\224D\180\218\161\221r@3\"\131\FS\184\204\160",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode20) { + uint8_t pkt[] = {0x82, 0xb8, 0x1, 0x77, 0x40, 0x0, 0x5, 0x5a, 0x37, 0xf6, 0x62, 0x27, 0x1, 0x0, 0x1b, 0xf8, 0xa1, + 0xf0, 0x87, 0x51, 0x82, 0xc6, 0x6f, 0x56, 0x1e, 0xbb, 0x7e, 0x37, 0x27, 0x12, 0x40, 0x6, 0x7e, 0x69, + 0xd5, 0x63, 0x73, 0x58, 0xc8, 0x6b, 0x45, 0xf0, 0x2, 0x0, 0x6, 0xf8, 0xd7, 0xa7, 0x58, 0x7, 0xb8, + 0x1, 0x0, 0x6, 0x57, 0x8b, 0x7e, 0xf0, 0xea, 0xa, 0x2, 0x0, 0x1d, 0xe2, 0xdf, 0x3, 0x41, 0xaa, + 0x7b, 0x1c, 0xc5, 0x52, 0x4e, 0x93, 0x58, 0xa1, 0x1b, 0xf, 0x7, 0xc5, 0xb, 0x42, 0x33, 0xe8, 0xdc, + 0xa0, 0x7b, 0x88, 0xf2, 0x35, 0x96, 0x96, 0x2, 0x0, 0x17, 0x86, 0xec, 0xb8, 0xb4, 0x41, 0x2f, 0x34, + 0xce, 0x86, 0xb0, 0x70, 0xa3, 0x36, 0x0, 0x1e, 0x24, 0x1f, 0xc8, 0x18, 0x7f, 0x55, 0x9c, 0xe0, 0x0, + 0x0, 0x2, 0x5, 0xb1, 0x2, 0x0, 0x1d, 0xcf, 0x31, 0x86, 0x95, 0xa9, 0x89, 0x5f, 0x91, 0x5c, 0xb9, + 0x2c, 0xbb, 0xf2, 0xe2, 0x87, 0x4a, 0x3e, 0xcb, 0xcb, 0x42, 0xf5, 0xc4, 0x93, 0xef, 0xa8, 0xd4, 0xa7, + 0x91, 0xdb, 0x0, 0x0, 0x8, 0x2c, 0xb0, 0xc5, 0x70, 0xe0, 0x4d, 0x5c, 0xc8, 0x0, 0x0, 0x11, 0x9b, + 0x77, 0xe0, 0x44, 0xb4, 0xda, 0xa1, 0xdd, 0x72, 0x40, 0x33, 0x22, 0x83, 0x1c, 0xb8, 0xcc, 0xa0, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x5a, 0x37, 0xf6, 0x62, 0x27}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf8, 0xa1, 0xf0, 0x87, 0x51, 0x82, 0xc6, 0x6f, 0x56, 0x1e, 0xbb, 0x7e, 0x37, 0x27, + 0x12, 0x40, 0x6, 0x7e, 0x69, 0xd5, 0x63, 0x73, 0x58, 0xc8, 0x6b, 0x45, 0xf0}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf8, 0xd7, 0xa7, 0x58, 0x7, 0xb8}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x57, 0x8b, 0x7e, 0xf0, 0xea, 0xa}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe2, 0xdf, 0x3, 0x41, 0xaa, 0x7b, 0x1c, 0xc5, 0x52, 0x4e, + 0x93, 0x58, 0xa1, 0x1b, 0xf, 0x7, 0xc5, 0xb, 0x42, 0x33, + 0xe8, 0xdc, 0xa0, 0x7b, 0x88, 0xf2, 0x35, 0x96, 0x96}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x86, 0xec, 0xb8, 0xb4, 0x41, 0x2f, 0x34, 0xce, 0x86, 0xb0, 0x70, 0xa3, + 0x36, 0x0, 0x1e, 0x24, 0x1f, 0xc8, 0x18, 0x7f, 0x55, 0x9c, 0xe0}; + lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x5, 0xb1}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xcf, 0x31, 0x86, 0x95, 0xa9, 0x89, 0x5f, 0x91, 0x5c, 0xb9, + 0x2c, 0xbb, 0xf2, 0xe2, 0x87, 0x4a, 0x3e, 0xcb, 0xcb, 0x42, + 0xf5, 0xc4, 0x93, 0xef, 0xa8, 0xd4, 0xa7, 0x91, 0xdb}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x2c, 0xb0, 0xc5, 0x70, 0xe0, 0x4d, 0x5c, 0xc8}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x9b, 0x77, 0xe0, 0x44, 0xb4, 0xda, 0xa1, 0xdd, 0x72, + 0x40, 0x33, 0x22, 0x83, 0x1c, 0xb8, 0xcc, 0xa0}; + lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30528, 10, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 32298 [("\183B\236P\DC4\RS0\245>\186\t\170R\GS\ESC\SI\234\151\246\224",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode21) { + uint8_t pkt[] = {0x82, 0x19, 0x7e, 0x2a, 0x0, 0x14, 0xb7, 0x42, 0xec, 0x50, 0x14, 0x1e, 0x30, 0xf5, + 0x3e, 0xba, 0x9, 0xaa, 0x52, 0x1d, 0x1b, 0xf, 0xea, 0x97, 0xf6, 0xe0, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xb7, 0x42, 0xec, 0x50, 0x14, 0x1e, 0x30, 0xf5, 0x3e, 0xba, + 0x9, 0xaa, 0x52, 0x1d, 0x1b, 0xf, 0xea, 0x97, 0xf6, 0xe0}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32298, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 22169 [("\185n'\131\192M\162\EOTR\199\DC3\248G\138\NULjj\129\249\191\177\183D\200WU",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\247j\216\229\244\&4\DLEvoHjH\NUL\236\161\&64",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\130O\195\&2/BI\149/\183\137\146\218\179\CAN\198\212\174\&3a\191\158\214K\209\173p@\130",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\182g\162\186\175\184\210\ACKc>I\183\153\SO\176\v\255\221\&0L_\231Z",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\149\178\207\218V\235\209\189K6\143\DC3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode22) { + uint8_t pkt[] = {0x82, 0x7c, 0x56, 0x99, 0x0, 0x1a, 0xb9, 0x6e, 0x27, 0x83, 0xc0, 0x4d, 0xa2, 0x4, 0x52, 0xc7, + 0x13, 0xf8, 0x47, 0x8a, 0x0, 0x6a, 0x6a, 0x81, 0xf9, 0xbf, 0xb1, 0xb7, 0x44, 0xc8, 0x57, 0x55, + 0x1, 0x0, 0x11, 0xf7, 0x6a, 0xd8, 0xe5, 0xf4, 0x34, 0x10, 0x76, 0x6f, 0x48, 0x6a, 0x48, 0x0, + 0xec, 0xa1, 0x36, 0x34, 0x2, 0x0, 0x1d, 0x82, 0x4f, 0xc3, 0x32, 0x2f, 0x42, 0x49, 0x95, 0x2f, + 0xb7, 0x89, 0x92, 0xda, 0xb3, 0x18, 0xc6, 0xd4, 0xae, 0x33, 0x61, 0xbf, 0x9e, 0xd6, 0x4b, 0xd1, + 0xad, 0x70, 0x40, 0x82, 0x1, 0x0, 0x17, 0xb6, 0x67, 0xa2, 0xba, 0xaf, 0xb8, 0xd2, 0x6, 0x63, + 0x3e, 0x49, 0xb7, 0x99, 0xe, 0xb0, 0xb, 0xff, 0xdd, 0x30, 0x4c, 0x5f, 0xe7, 0x5a, 0x2, 0x0, + 0xc, 0x95, 0xb2, 0xcf, 0xda, 0x56, 0xeb, 0xd1, 0xbd, 0x4b, 0x36, 0x8f, 0x13, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xb9, 0x6e, 0x27, 0x83, 0xc0, 0x4d, 0xa2, 0x4, 0x52, 0xc7, 0x13, 0xf8, 0x47, + 0x8a, 0x0, 0x6a, 0x6a, 0x81, 0xf9, 0xbf, 0xb1, 0xb7, 0x44, 0xc8, 0x57, 0x55}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf7, 0x6a, 0xd8, 0xe5, 0xf4, 0x34, 0x10, 0x76, 0x6f, + 0x48, 0x6a, 0x48, 0x0, 0xec, 0xa1, 0x36, 0x34}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x82, 0x4f, 0xc3, 0x32, 0x2f, 0x42, 0x49, 0x95, 0x2f, 0xb7, + 0x89, 0x92, 0xda, 0xb3, 0x18, 0xc6, 0xd4, 0xae, 0x33, 0x61, + 0xbf, 0x9e, 0xd6, 0x4b, 0xd1, 0xad, 0x70, 0x40, 0x82}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb6, 0x67, 0xa2, 0xba, 0xaf, 0xb8, 0xd2, 0x6, 0x63, 0x3e, 0x49, 0xb7, + 0x99, 0xe, 0xb0, 0xb, 0xff, 0xdd, 0x30, 0x4c, 0x5f, 0xe7, 0x5a}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x95, 0xb2, 0xcf, 0xda, 0x56, 0xeb, 0xd1, 0xbd, 0x4b, 0x36, 0x8f, 0x13}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22169, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 26097 [("v\164\210X\179\135t\206\&0\177\165^\196\160\166\NUL78m}\195Z\147.rbC\177s9",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\255q\244\v\147\250\213/\143\151\&8\168\&9",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("l\168W:Wa\253\147\225\RS\164\242-;r')",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\DC15\NUL\236\249\231\210\141\246\n\ENQ\v\248\RS\USX\132\CAN\214\143w\202\139;]4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\231A\154h\ETX\223a\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0x6f, 0x65, 0xf1, 0x0, 0x1e, 0x76, 0xa4, 0xd2, 0x58, 0xb3, 0x87, 0x74, 0xce, 0x30, 0xb1, 0xa5, + 0x5e, 0xc4, 0xa0, 0xa6, 0x0, 0x37, 0x38, 0x6d, 0x7d, 0xc3, 0x5a, 0x93, 0x2e, 0x72, 0x62, 0x43, 0xb1, + 0x73, 0x39, 0x2, 0x0, 0xd, 0xff, 0x71, 0xf4, 0xb, 0x93, 0xfa, 0xd5, 0x2f, 0x8f, 0x97, 0x38, 0xa8, + 0x39, 0x0, 0x0, 0x11, 0x6c, 0xa8, 0x57, 0x3a, 0x57, 0x61, 0xfd, 0x93, 0xe1, 0x1e, 0xa4, 0xf2, 0x2d, + 0x3b, 0x72, 0x27, 0x29, 0x0, 0x0, 0x1a, 0x11, 0x35, 0x0, 0xec, 0xf9, 0xe7, 0xd2, 0x8d, 0xf6, 0xa, + 0x5, 0xb, 0xf8, 0x1e, 0x1f, 0x58, 0x84, 0x18, 0xd6, 0x8f, 0x77, 0xca, 0x8b, 0x3b, 0x5d, 0x34, 0x0, + 0x0, 0x8, 0xe7, 0x41, 0x9a, 0x68, 0x3, 0xdf, 0x61, 0xc5, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x76, 0xa4, 0xd2, 0x58, 0xb3, 0x87, 0x74, 0xce, 0x30, 0xb1, + 0xa5, 0x5e, 0xc4, 0xa0, 0xa6, 0x0, 0x37, 0x38, 0x6d, 0x7d, + 0xc3, 0x5a, 0x93, 0x2e, 0x72, 0x62, 0x43, 0xb1, 0x73, 0x39}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xff, 0x71, 0xf4, 0xb, 0x93, 0xfa, 0xd5, 0x2f, 0x8f, 0x97, 0x38, 0xa8, 0x39}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x6c, 0xa8, 0x57, 0x3a, 0x57, 0x61, 0xfd, 0x93, 0xe1, + 0x1e, 0xa4, 0xf2, 0x2d, 0x3b, 0x72, 0x27, 0x29}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x11, 0x35, 0x0, 0xec, 0xf9, 0xe7, 0xd2, 0x8d, 0xf6, 0xa, 0x5, 0xb, 0xf8, + 0x1e, 0x1f, 0x58, 0x84, 0x18, 0xd6, 0x8f, 0x77, 0xca, 0x8b, 0x3b, 0x5d, 0x34}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe7, 0x41, 0x9a, 0x68, 0x3, 0xdf, 0x61, 0xc5}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26097, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 25578 [("\151\169\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("\129L\179D\b\\\136\147\&3\187\140\205\216\221\151\ENQ\149\128\155\211\210E\ENQ\240\&8q\203\180",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("F\219rm{\255\FS\161\228\207\147\157(\236.\DC1\150\EM$|\138p\253$u\SYN8\237\ENQ",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\196\SO\SI\252\189a\168*\239<\226M(\228'\183H\223\&9\165\220\ACK\229R\158\151\209n\151\248",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode24) { + uint8_t pkt[] = {0x82, 0x68, 0x63, 0xea, 0x0, 0x3, 0x97, 0xa9, 0xa, 0x0, 0x0, 0x1c, 0x81, 0x4c, 0xb3, 0x44, + 0x8, 0x5c, 0x88, 0x93, 0x33, 0xbb, 0x8c, 0xcd, 0xd8, 0xdd, 0x97, 0x5, 0x95, 0x80, 0x9b, 0xd3, + 0xd2, 0x45, 0x5, 0xf0, 0x38, 0x71, 0xcb, 0xb4, 0x2, 0x0, 0x1d, 0x46, 0xdb, 0x72, 0x6d, 0x7b, + 0xff, 0x1c, 0xa1, 0xe4, 0xcf, 0x93, 0x9d, 0x28, 0xec, 0x2e, 0x11, 0x96, 0x19, 0x24, 0x7c, 0x8a, + 0x70, 0xfd, 0x24, 0x75, 0x16, 0x38, 0xed, 0x5, 0x0, 0x0, 0x1e, 0xc4, 0xe, 0xf, 0xfc, 0xbd, + 0x61, 0xa8, 0x2a, 0xef, 0x3c, 0xe2, 0x4d, 0x28, 0xe4, 0x27, 0xb7, 0x48, 0xdf, 0x39, 0xa5, 0xdc, + 0x6, 0xe5, 0x52, 0x9e, 0x97, 0xd1, 0x6e, 0x97, 0xf8, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x97, 0xa9, 0xa}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x81, 0x4c, 0xb3, 0x44, 0x8, 0x5c, 0x88, 0x93, 0x33, 0xbb, + 0x8c, 0xcd, 0xd8, 0xdd, 0x97, 0x5, 0x95, 0x80, 0x9b, 0xd3, + 0xd2, 0x45, 0x5, 0xf0, 0x38, 0x71, 0xcb, 0xb4}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x46, 0xdb, 0x72, 0x6d, 0x7b, 0xff, 0x1c, 0xa1, 0xe4, 0xcf, + 0x93, 0x9d, 0x28, 0xec, 0x2e, 0x11, 0x96, 0x19, 0x24, 0x7c, + 0x8a, 0x70, 0xfd, 0x24, 0x75, 0x16, 0x38, 0xed, 0x5}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc4, 0xe, 0xf, 0xfc, 0xbd, 0x61, 0xa8, 0x2a, 0xef, 0x3c, + 0xe2, 0x4d, 0x28, 0xe4, 0x27, 0xb7, 0x48, 0xdf, 0x39, 0xa5, + 0xdc, 0x6, 0xe5, 0x52, 0x9e, 0x97, 0xd1, 0x6e, 0x97, 0xf8}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25578, 4, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 14161 [("\242\138%q\US\GSY\176\129}=\247",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\STX\132g\171\169\132\132\181\237\223\182gx,",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("g\EMP\174+`\222\SUBP",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("b\255\135\184;\253\174\185R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\236:H\144\155\245+7\DLE\145K>\160Hi\229",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode25) { + uint8_t pkt[] = {0x82, 0x4d, 0x37, 0x51, 0x0, 0xc, 0xf2, 0x8a, 0x25, 0x71, 0x1f, 0x1d, 0x59, 0xb0, 0x81, 0x7d, + 0x3d, 0xf7, 0x1, 0x0, 0xe, 0x2, 0x84, 0x67, 0xab, 0xa9, 0x84, 0x84, 0xb5, 0xed, 0xdf, 0xb6, + 0x67, 0x78, 0x2c, 0x0, 0x0, 0x9, 0x67, 0x19, 0x50, 0xae, 0x2b, 0x60, 0xde, 0x1a, 0x50, 0x0, + 0x0, 0x9, 0x62, 0xff, 0x87, 0xb8, 0x3b, 0xfd, 0xae, 0xb9, 0x52, 0x2, 0x0, 0x10, 0xec, 0x3a, + 0x48, 0x90, 0x9b, 0xf5, 0x2b, 0x37, 0x10, 0x91, 0x4b, 0x3e, 0xa0, 0x48, 0x69, 0xe5, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xf2, 0x8a, 0x25, 0x71, 0x1f, 0x1d, 0x59, 0xb0, 0x81, 0x7d, 0x3d, 0xf7}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2, 0x84, 0x67, 0xab, 0xa9, 0x84, 0x84, 0xb5, 0xed, 0xdf, 0xb6, 0x67, 0x78, 0x2c}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x67, 0x19, 0x50, 0xae, 0x2b, 0x60, 0xde, 0x1a, 0x50}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x62, 0xff, 0x87, 0xb8, 0x3b, 0xfd, 0xae, 0xb9, 0x52}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xec, 0x3a, 0x48, 0x90, 0x9b, 0xf5, 0x2b, 0x37, + 0x10, 0x91, 0x4b, 0x3e, 0xa0, 0x48, 0x69, 0xe5}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14161, 5, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 3024 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\151\241\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("O\234$\nG\215\255\&2\ETB\153\&8\213\230\161zr\149C\SOH",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(".\ETB\199\SYN\173\&1M\183\r\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\RSe\157a\193\189\&8%\189\238lr\136\251\194l\\\219ii",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\n\222\134\168\193\203",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode26) { + uint8_t pkt[] = {0x82, 0x4e, 0xb, 0xd0, 0x0, 0x0, 0x1, 0x0, 0x3, 0x97, 0xf1, 0xd9, 0x1, 0x0, 0x13, 0x4f, + 0xea, 0x24, 0xa, 0x47, 0xd7, 0xff, 0x32, 0x17, 0x99, 0x38, 0xd5, 0xe6, 0xa1, 0x7a, 0x72, 0x95, + 0x43, 0x1, 0x0, 0x0, 0xa, 0x2e, 0x17, 0xc7, 0x16, 0xad, 0x31, 0x4d, 0xb7, 0xd, 0xe8, 0x1, + 0x0, 0x14, 0x1e, 0x65, 0x9d, 0x61, 0xc1, 0xbd, 0x38, 0x25, 0xbd, 0xee, 0x6c, 0x72, 0x88, 0xfb, + 0xc2, 0x6c, 0x5c, 0xdb, 0x69, 0x69, 0x0, 0x0, 0x6, 0xa, 0xde, 0x86, 0xa8, 0xc1, 0xcb, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x97, 0xf1, 0xd9}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4f, 0xea, 0x24, 0xa, 0x47, 0xd7, 0xff, 0x32, 0x17, 0x99, + 0x38, 0xd5, 0xe6, 0xa1, 0x7a, 0x72, 0x95, 0x43, 0x1}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x2e, 0x17, 0xc7, 0x16, 0xad, 0x31, 0x4d, 0xb7, 0xd, 0xe8}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x1e, 0x65, 0x9d, 0x61, 0xc1, 0xbd, 0x38, 0x25, 0xbd, 0xee, + 0x6c, 0x72, 0x88, 0xfb, 0xc2, 0x6c, 0x5c, 0xdb, 0x69, 0x69}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa, 0xde, 0x86, 0xa8, 0xc1, 0xcb}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3024, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 9912 [("\204\190\NUL\161\131\ETB\243~\129\US,\199",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DC1\203\202\209\&0T*Orh\223",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode27) { + uint8_t pkt[] = {0x82, 0x1f, 0x26, 0xb8, 0x0, 0xc, 0xcc, 0xbe, 0x0, 0xa1, 0x83, 0x17, 0xf3, 0x7e, 0x81, 0x1f, 0x2c, + 0xc7, 0x2, 0x0, 0xb, 0x11, 0xcb, 0xca, 0xd1, 0x30, 0x54, 0x2a, 0x4f, 0x72, 0x68, 0xdf, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xcc, 0xbe, 0x0, 0xa1, 0x83, 0x17, 0xf3, 0x7e, 0x81, 0x1f, 0x2c, 0xc7}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x11, 0xcb, 0xca, 0xd1, 0x30, 0x54, 0x2a, 0x4f, 0x72, 0x68, 0xdf}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9912, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 1301 [("\169n\168\166N\214\SUB\136\156\134\ETX\228",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\135#\130r\206\254\133s<\ACK\143\200\154\229\227\169\217\244'",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\fBj\fR\208\210\189\190\148\STX\164}\163\214\183[\143",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("k\172\154\253f\170\&7\CANjg\185\r\ESC\192\ENQQi}\209\SI",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\239\236Y\220\224\191\&6",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\SIw*X&\ty\181\188:}\219,}\247\219>\NAK\167\177j0\188\197L\232@EJ",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\ACK2c\237\191\199*",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\206Cz\139\148\189dN%",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\141=\196\133f1r\DELf#h\161,8\131",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode28) { + uint8_t pkt[] = {0x82, 0xa5, 0x1, 0x5, 0x15, 0x0, 0xc, 0xa9, 0x6e, 0xa8, 0xa6, 0x4e, 0xd6, 0x1a, 0x88, 0x9c, 0x86, + 0x3, 0xe4, 0x2, 0x0, 0x13, 0x87, 0x23, 0x82, 0x72, 0xce, 0xfe, 0x85, 0x73, 0x3c, 0x6, 0x8f, 0xc8, + 0x9a, 0xe5, 0xe3, 0xa9, 0xd9, 0xf4, 0x27, 0x2, 0x0, 0x12, 0xc, 0x42, 0x6a, 0xc, 0x52, 0xd0, 0xd2, + 0xbd, 0xbe, 0x94, 0x2, 0xa4, 0x7d, 0xa3, 0xd6, 0xb7, 0x5b, 0x8f, 0x2, 0x0, 0x14, 0x6b, 0xac, 0x9a, + 0xfd, 0x66, 0xaa, 0x37, 0x18, 0x6a, 0x67, 0xb9, 0xd, 0x1b, 0xc0, 0x5, 0x51, 0x69, 0x7d, 0xd1, 0xf, + 0x0, 0x0, 0x7, 0xef, 0xec, 0x59, 0xdc, 0xe0, 0xbf, 0x36, 0x1, 0x0, 0x1d, 0xf, 0x77, 0x2a, 0x58, + 0x26, 0x9, 0x79, 0xb5, 0xbc, 0x3a, 0x7d, 0xdb, 0x2c, 0x7d, 0xf7, 0xdb, 0x3e, 0x15, 0xa7, 0xb1, 0x6a, + 0x30, 0xbc, 0xc5, 0x4c, 0xe8, 0x40, 0x45, 0x4a, 0x2, 0x0, 0x7, 0x6, 0x32, 0x63, 0xed, 0xbf, 0xc7, + 0x2a, 0x1, 0x0, 0x9, 0xce, 0x43, 0x7a, 0x8b, 0x94, 0xbd, 0x64, 0x4e, 0x25, 0x2, 0x0, 0xf, 0x8d, + 0x3d, 0xc4, 0x85, 0x66, 0x31, 0x72, 0x7f, 0x66, 0x23, 0x68, 0xa1, 0x2c, 0x38, 0x83, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xa9, 0x6e, 0xa8, 0xa6, 0x4e, 0xd6, 0x1a, 0x88, 0x9c, 0x86, 0x3, 0xe4}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x87, 0x23, 0x82, 0x72, 0xce, 0xfe, 0x85, 0x73, 0x3c, 0x6, + 0x8f, 0xc8, 0x9a, 0xe5, 0xe3, 0xa9, 0xd9, 0xf4, 0x27}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc, 0x42, 0x6a, 0xc, 0x52, 0xd0, 0xd2, 0xbd, 0xbe, + 0x94, 0x2, 0xa4, 0x7d, 0xa3, 0xd6, 0xb7, 0x5b, 0x8f}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6b, 0xac, 0x9a, 0xfd, 0x66, 0xaa, 0x37, 0x18, 0x6a, 0x67, + 0xb9, 0xd, 0x1b, 0xc0, 0x5, 0x51, 0x69, 0x7d, 0xd1, 0xf}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xef, 0xec, 0x59, 0xdc, 0xe0, 0xbf, 0x36}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf, 0x77, 0x2a, 0x58, 0x26, 0x9, 0x79, 0xb5, 0xbc, 0x3a, + 0x7d, 0xdb, 0x2c, 0x7d, 0xf7, 0xdb, 0x3e, 0x15, 0xa7, 0xb1, + 0x6a, 0x30, 0xbc, 0xc5, 0x4c, 0xe8, 0x40, 0x45, 0x4a}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x6, 0x32, 0x63, 0xed, 0xbf, 0xc7, 0x2a}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xce, 0x43, 0x7a, 0x8b, 0x94, 0xbd, 0x64, 0x4e, 0x25}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x8d, 0x3d, 0xc4, 0x85, 0x66, 0x31, 0x72, 0x7f, + 0x66, 0x23, 0x68, 0xa1, 0x2c, 0x38, 0x83}; + lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1301, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\ETB\185M\SUB\222\149", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\128\ETB\EOT\205\173", _willMsg = -// "\198\DC3l\140\230R!E$\SOH\229o,x\187~\139\202\"\DC4V\ACK)", _willProps = [PropMessageExpiryInterval -// 30378,PropReasonString "\213P\189Yv\FS\DC3#\224\SI_\155\&5D# \187\201\204\178{\GS$:\251\213",PropRetainAvailable -// 181,PropReasonString "\246\182\199?5rh\a\129F`\163\NAKv\FS\130\249",PropCorrelationData -// ",\ENQ\146\197\197\SI\220y.\150",PropResponseTopic -// "\202\156\&7\199\244\162Cw3\"S\221\245\fi\181\DC2m\139\252\244i\175#",PropAuthenticationMethod -// "\205\228\ESC\n",PropSharedSubscriptionAvailable 45,PropContentType -// "\fILq\240~<+\226\137+O,\218QC\243\141r\154j\139\231=",PropServerReference "\141",PropMessageExpiryInterval -// 2987,PropSessionExpiryInterval 20482,PropTopicAlias 9401,PropRetainAvailable 46]}), _cleanSession = False, _keepAlive -// = 3023, _connID = "]l\128mk1J\129p\141\170Rw\178\NUL\171w\196\n", _properties = [PropPayloadFormatIndicator -// 86,PropMessageExpiryInterval 15264,PropSubscriptionIdentifier 11,PropResponseTopic -// "\ENQ+Vw\177T\218a7I\201\130|\\'Q\231=F\STX\DC3\SUB+E!\231",PropReceiveMaximum 4661,PropResponseInformation -// "\DC4f\213t\230",PropResponseInformation -// "\ENQ\247\209b\172\179\ETB\148\224\136\164o\171U\208\177\ETBJ\t\143\205&\251\152\rO\"\131",PropAuthenticationData -// "\SOHa\ESC\233\&8p\177\162\255\179\132\135",PropServerReference -// "\245\231\b\215}(\213\175\&2~s\128\174\DC4\201\235\250\EOT\214\142",PropUserProperty -// "\212k]b\SO;4\174\179\242\ENQ\135u,`8\204{:L\183a\SYNj\187s" "\235S\183P\187",PropSubscriptionIdentifierAvailable -// 48,PropAuthenticationMethod -// "\GS$\174\239\\S\248+;\145\231\225\231\155\RS\168L\227\247\197\145&",PropAssignedClientIdentifier -// "\171\162\ESC2\168gK\151>\177\147\130\SYN_\174",PropSubscriptionIdentifierAvailable 119,PropMaximumQoS -// 125,PropWildcardSubscriptionAvailable 12,PropRetainAvailable 247,PropSubscriptionIdentifierAvailable -// 152,PropSharedSubscriptionAvailable 76,PropResponseInformation -// "Q\a\236t\STX\128\215\159\\\226%82\DC4<",PropRequestProblemInformation 6,PropAuthenticationData -// "\213",PropWillDelayInterval 11360,PropTopicAliasMaximum 17881,PropServerReference -// "\235s't\243\130]2\206\NAKv\131\CANs\SOH\218\STX",PropWillDelayInterval 16307]} -TEST(Connect5QCTest, Encode5) { - uint8_t pkt[] = { - 0x10, 0xee, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb4, 0xb, 0xcf, 0x8c, 0x2, 0x1, 0x56, 0x2, 0x0, - 0x0, 0x3b, 0xa0, 0xb, 0xb, 0x8, 0x0, 0x1a, 0x5, 0x2b, 0x56, 0x77, 0xb1, 0x54, 0xda, 0x61, 0x37, 0x49, 0xc9, - 0x82, 0x7c, 0x5c, 0x27, 0x51, 0xe7, 0x3d, 0x46, 0x2, 0x13, 0x1a, 0x2b, 0x45, 0x21, 0xe7, 0x21, 0x12, 0x35, 0x1a, - 0x0, 0x5, 0x14, 0x66, 0xd5, 0x74, 0xe6, 0x1a, 0x0, 0x1c, 0x5, 0xf7, 0xd1, 0x62, 0xac, 0xb3, 0x17, 0x94, 0xe0, - 0x88, 0xa4, 0x6f, 0xab, 0x55, 0xd0, 0xb1, 0x17, 0x4a, 0x9, 0x8f, 0xcd, 0x26, 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0xad, 0x0, 0x17, 0xc6, 0x13, 0x6c, 0x8c, 0xe6, 0x52, 0x21, 0x45, 0x24, - 0x1, 0xe5, 0x6f, 0x2c, 0x78, 0xbb, 0x7e, 0x8b, 0xca, 0x22, 0x14, 0x56, 0x6, 0x29, 0x0, 0x6, 0x17, 0xb9, 0x4d, - 0x1a, 0xde, 0x95}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x5, 0x2b, 0x56, 0x77, 0xb1, 0x54, 0xda, 0x61, 0x37, 0x49, 0xc9, 0x82, 0x7c, - 0x5c, 0x27, 0x51, 0xe7, 0x3d, 0x46, 0x2, 0x13, 0x1a, 0x2b, 0x45, 0x21, 0xe7}; - uint8_t bytesprops1[] = {0x14, 0x66, 0xd5, 0x74, 0xe6}; - uint8_t bytesprops2[] = {0x5, 0xf7, 0xd1, 0x62, 0xac, 0xb3, 0x17, 0x94, 0xe0, 0x88, 0xa4, 0x6f, 0xab, 0x55, - 0xd0, 0xb1, 0x17, 0x4a, 0x9, 0x8f, 0xcd, 0x26, 0xfb, 0x98, 0xd, 0x4f, 0x22, 0x83}; - uint8_t bytesprops3[] = {0x1, 0x61, 0x1b, 0xe9, 0x38, 0x70, 0xb1, 0xa2, 0xff, 0xb3, 0x84, 0x87}; - uint8_t bytesprops4[] = {0xf5, 0xe7, 0x8, 0xd7, 0x7d, 0x28, 0xd5, 0xaf, 0x32, 0x7e, - 0x73, 0x80, 0xae, 0x14, 0xc9, 0xeb, 0xfa, 0x4, 0xd6, 0x8e}; - uint8_t bytesprops6[] = {0xeb, 0x53, 0xb7, 0x50, 0xbb}; - uint8_t bytesprops5[] = {0xd4, 0x6b, 0x5d, 0x62, 0xe, 0x3b, 0x34, 0xae, 0xb3, 0xf2, 0x5, 0x87, 0x75, - 0x2c, 0x60, 0x38, 0xcc, 0x7b, 0x3a, 0x4c, 0xb7, 0x61, 0x16, 0x6a, 0xbb, 0x73}; - uint8_t bytesprops7[] = {0x1d, 0x24, 0xae, 0xef, 0x5c, 0x53, 0xf8, 0x2b, 0x3b, 0x91, 0xe7, - 0xe1, 0xe7, 0x9b, 0x1e, 0xa8, 0x4c, 0xe3, 0xf7, 0xc5, 0x91, 0x26}; - uint8_t bytesprops8[] = {0xab, 0xa2, 0x1b, 0x32, 0xa8, 0x67, 0x4b, 0x97, 0x3e, 0xb1, 0x93, 0x82, 0x16, 0x5f, 0xae}; - uint8_t bytesprops9[] = {0x51, 0x7, 0xec, 0x74, 0x2, 0x80, 0xd7, 0x9f, 0x5c, 0xe2, 0x25, 0x38, 0x32, 0x14, 0x3c}; - uint8_t bytesprops10[] = {0xd5}; - uint8_t bytesprops11[] = {0xeb, 0x73, 0x27, 0x74, 0xf3, 0x82, 0x5d, 0x32, 0xce, - 0x15, 0x76, 0x83, 0x18, 0x73, 0x1, 0xda, 0x2}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15264}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4661}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops5}, .v = {5, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11360}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17881}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16307}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd5, 0x50, 0xbd, 0x59, 0x76, 0x1c, 0x13, 0x23, 0xe0, 0xf, 0x5f, 0x9b, 0x35, - 0x44, 0x23, 0x20, 0xbb, 0xc9, 0xcc, 0xb2, 0x7b, 0x1d, 0x24, 0x3a, 0xfb, 0xd5}; - uint8_t byteswillprops1[] = {0xf6, 0xb6, 0xc7, 0x3f, 0x35, 0x72, 0x68, 0x7, 0x81, - 0x46, 0x60, 0xa3, 0x15, 0x76, 0x1c, 0x82, 0xf9}; - uint8_t byteswillprops2[] = {0x2c, 0x5, 0x92, 0xc5, 0xc5, 0xf, 0xdc, 0x79, 0x2e, 0x96}; - uint8_t byteswillprops3[] = {0xca, 0x9c, 0x37, 0xc7, 0xf4, 0xa2, 0x43, 0x77, 0x33, 0x22, 0x53, 0xdd, - 0xf5, 0xc, 0x69, 0xb5, 0x12, 0x6d, 0x8b, 0xfc, 0xf4, 0x69, 0xaf, 0x23}; - uint8_t byteswillprops4[] = {0xcd, 0xe4, 0x1b, 0xa}; - uint8_t byteswillprops5[] = {0xc, 0x49, 0x4c, 0x71, 0xf0, 0x7e, 0x3c, 0x2b, 0xe2, 0x89, 0x2b, 0x4f, - 0x2c, 0xda, 0x51, 0x43, 0xf3, 0x8d, 0x72, 0x9a, 0x6a, 0x8b, 0xe7, 0x3d}; - uint8_t byteswillprops6[] = {0x8d}; +// SubscribeRequest 8636 [("\145uzU$\EOTvLk\130\217\133\&5f:\185\180q\t\227B\204\209^",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\185\215\&3\186z",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("5\240\228\136\145<\174p",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS1}),("\"\254g\248Z\ENQ\150\248I.\136:B\b\221BoA",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\155\131g\SOH\199\215Z\164\242\159",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("M\225pW\t\184D\fV\167\186\130\231o\189t\217\233\152\213I@\r\150\142c",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode29) { + uint8_t pkt[] = {0x82, 0x6f, 0x21, 0xbc, 0x0, 0x18, 0x91, 0x75, 0x7a, 0x55, 0x24, 0x4, 0x76, 0x4c, 0x6b, 0x82, 0xd9, + 0x85, 0x35, 0x66, 0x3a, 0xb9, 0xb4, 0x71, 0x9, 0xe3, 0x42, 0xcc, 0xd1, 0x5e, 0x1, 0x0, 0x5, 0xb9, + 0xd7, 0x33, 0xba, 0x7a, 0x0, 0x0, 0x8, 0x35, 0xf0, 0xe4, 0x88, 0x91, 0x3c, 0xae, 0x70, 0x1, 0x0, + 0x12, 0x22, 0xfe, 0x67, 0xf8, 0x5a, 0x5, 0x96, 0xf8, 0x49, 0x2e, 0x88, 0x3a, 0x42, 0x8, 0xdd, 0x42, + 0x6f, 0x41, 0x2, 0x0, 0xa, 0x9b, 0x83, 0x67, 0x1, 0xc7, 0xd7, 0x5a, 0xa4, 0xf2, 0x9f, 0x2, 0x0, + 0x1a, 0x4d, 0xe1, 0x70, 0x57, 0x9, 0xb8, 0x44, 0xc, 0x56, 0xa7, 0xba, 0x82, 0xe7, 0x6f, 0xbd, 0x74, + 0xd9, 0xe9, 0x98, 0xd5, 0x49, 0x40, 0xd, 0x96, 0x8e, 0x63, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x91, 0x75, 0x7a, 0x55, 0x24, 0x4, 0x76, 0x4c, 0x6b, 0x82, 0xd9, 0x85, + 0x35, 0x66, 0x3a, 0xb9, 0xb4, 0x71, 0x9, 0xe3, 0x42, 0xcc, 0xd1, 0x5e}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb9, 0xd7, 0x33, 0xba, 0x7a}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x35, 0xf0, 0xe4, 0x88, 0x91, 0x3c, 0xae, 0x70}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x22, 0xfe, 0x67, 0xf8, 0x5a, 0x5, 0x96, 0xf8, 0x49, + 0x2e, 0x88, 0x3a, 0x42, 0x8, 0xdd, 0x42, 0x6f, 0x41}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9b, 0x83, 0x67, 0x1, 0xc7, 0xd7, 0x5a, 0xa4, 0xf2, 0x9f}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x4d, 0xe1, 0x70, 0x57, 0x9, 0xb8, 0x44, 0xc, 0x56, 0xa7, 0xba, 0x82, 0xe7, + 0x6f, 0xbd, 0x74, 0xd9, 0xe9, 0x98, 0xd5, 0x49, 0x40, 0xd, 0x96, 0x8e, 0x63}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30378}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2987}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20482}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9401}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 46}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x80, 0x17, 0x4, 0xcd, 0xad}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc6, 0x13, 0x6c, 0x8c, 0xe6, 0x52, 0x21, 0x45, 0x24, 0x1, 0xe5, 0x6f, - 0x2c, 0x78, 0xbb, 0x7e, 0x8b, 0xca, 0x22, 0x14, 0x56, 0x6, 0x29}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3023; - uint8_t client_id_bytes[] = {0x5d, 0x6c, 0x80, 0x6d, 0x6b, 0x31, 0x4a, 0x81, 0x70, 0x8d, - 0xaa, 0x52, 0x77, 0xb2, 0x0, 0xab, 0x77, 0xc4, 0xa}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x17, 0xb9, 0x4d, 0x1a, 0xde, 0x95}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8636, 6, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\FS\ACK\249\148\r\158\162\&8uP\173\212\135\254\214", _password = Just -// "\234\199:\176j\218\226\193U\206-\f\SOHRuz\167\199\196", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS1, _willTopic = "\176\DEL\SOH\132>\247\149\GSx", _willMsg = -// "\247Wdo3\141\135\211r\DC4B\b3\225<\247Y7\136\134\&5O\183", _willProps = [PropServerReference -// "\231",PropResponseTopic "`\NAK\229\r\199e\"<\tn\255lp\211\136p\176W:2\181'",PropRequestResponseInformation -// 153,PropResponseInformation "\DLE\228k\188\169\GS",PropSubscriptionIdentifierAvailable 202,PropMaximumQoS -// 53,PropRequestProblemInformation 41]}), _cleanSession = True, _keepAlive = 13117, _connID = -// "\226s\168\NUL\201\208\250\224\r\SOZ\221X<[&\\\181\184?\168\RS", _properties = [PropAuthenticationData -// "\141\193\180\223\&8'\\\234\EMD\212\175\242b\175",PropAuthenticationData "\221\DLE\EOT\SO;\175",PropTopicAliasMaximum -// 7754]} -TEST(Connect5QCTest, Encode6) { - uint8_t pkt[] = { - 0x10, 0xba, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x33, 0x3d, 0x1e, 0x16, 0x0, 0xf, 0x8d, 0xc1, - 0xb4, 0xdf, 0x38, 0x27, 0x5c, 0xea, 0x19, 0x44, 0xd4, 0xaf, 0xf2, 0x62, 0xaf, 0x16, 0x0, 0x6, 0xdd, 0x10, 0x4, - 0xe, 0x3b, 0xaf, 0x22, 0x1e, 0x4a, 0x0, 0x16, 0xe2, 0x73, 0xa8, 0x0, 0xc9, 0xd0, 0xfa, 0xe0, 0xd, 0xe, 0x5a, - 0xdd, 0x58, 0x3c, 0x5b, 0x26, 0x5c, 0xb5, 0xb8, 0x3f, 0xa8, 0x1e, 0x2e, 0x1c, 0x0, 0x1, 0xe7, 0x8, 0x0, 0x16, - 0x60, 0x15, 0xe5, 0xd, 0xc7, 0x65, 0x22, 0x3c, 0x9, 0x6e, 0xff, 0x6c, 0x70, 0xd3, 0x88, 0x70, 0xb0, 0x57, 0x3a, - 0x32, 0xb5, 0x27, 0x19, 0x99, 0x1a, 0x0, 0x6, 0x10, 0xe4, 0x6b, 0xbc, 0xa9, 0x1d, 0x29, 0xca, 0x24, 0x35, 0x17, - 0x29, 0x0, 0x9, 0xb0, 0x7f, 0x1, 0x84, 0x3e, 0xf7, 0x95, 0x1d, 0x78, 0x0, 0x17, 0xf7, 0x57, 0x64, 0x6f, 0x33, - 0x8d, 0x87, 0xd3, 0x72, 0x14, 0x42, 0x8, 0x33, 0xe1, 0x3c, 0xf7, 0x59, 0x37, 0x88, 0x86, 0x35, 0x4f, 0xb7, 0x0, - 0xf, 0x1c, 0x6, 0xf9, 0x94, 0xd, 0x9e, 0xa2, 0x38, 0x75, 0x50, 0xad, 0xd4, 0x87, 0xfe, 0xd6, 0x0, 0x13, 0xea, - 0xc7, 0x3a, 0xb0, 0x6a, 0xda, 0xe2, 0xc1, 0x55, 0xce, 0x2d, 0xc, 0x1, 0x52, 0x75, 0x7a, 0xa7, 0xc7, 0xc4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x8d, 0xc1, 0xb4, 0xdf, 0x38, 0x27, 0x5c, 0xea, 0x19, 0x44, 0xd4, 0xaf, 0xf2, 0x62, 0xaf}; - uint8_t bytesprops1[] = {0xdd, 0x10, 0x4, 0xe, 0x3b, 0xaf}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7754}}, - }; - - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe7}; - uint8_t byteswillprops1[] = {0x60, 0x15, 0xe5, 0xd, 0xc7, 0x65, 0x22, 0x3c, 0x9, 0x6e, 0xff, - 0x6c, 0x70, 0xd3, 0x88, 0x70, 0xb0, 0x57, 0x3a, 0x32, 0xb5, 0x27}; - uint8_t byteswillprops2[] = {0x10, 0xe4, 0x6b, 0xbc, 0xa9, 0x1d}; +// SubscribeRequest 23343 [("\b\226\228",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),(",6p\US\ESC\233\166\168\SOb@\"\155\182\DEL\213\251\214/\233\209nSD\174Y\147\191",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("[1\251\168#\EOT\140\140\&0)\DC2\159\134\188aM\201\255y\207\149\DLE",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\189D\246\ETB\165\134\238\174\175E\220\240%\190\163\232>\190\rDH\156\&3\182\RS\240\&5w\200",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode30) { + uint8_t pkt[] = {0x82, 0x60, 0x5b, 0x2f, 0x0, 0x3, 0x8, 0xe2, 0xe4, 0x0, 0x0, 0x1c, 0x2c, 0x36, 0x70, 0x1f, 0x1b, + 0xe9, 0xa6, 0xa8, 0xe, 0x62, 0x40, 0x22, 0x9b, 0xb6, 0x7f, 0xd5, 0xfb, 0xd6, 0x2f, 0xe9, 0xd1, 0x6e, + 0x53, 0x44, 0xae, 0x59, 0x93, 0xbf, 0x1, 0x0, 0x16, 0x5b, 0x31, 0xfb, 0xa8, 0x23, 0x4, 0x8c, 0x8c, + 0x30, 0x29, 0x12, 0x9f, 0x86, 0xbc, 0x61, 0x4d, 0xc9, 0xff, 0x79, 0xcf, 0x95, 0x10, 0x0, 0x0, 0x1d, + 0xbd, 0x44, 0xf6, 0x17, 0xa5, 0x86, 0xee, 0xae, 0xaf, 0x45, 0xdc, 0xf0, 0x25, 0xbe, 0xa3, 0xe8, 0x3e, + 0xbe, 0xd, 0x44, 0x48, 0x9c, 0x33, 0xb6, 0x1e, 0xf0, 0x35, 0x77, 0xc8, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x8, 0xe2, 0xe4}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2c, 0x36, 0x70, 0x1f, 0x1b, 0xe9, 0xa6, 0xa8, 0xe, 0x62, + 0x40, 0x22, 0x9b, 0xb6, 0x7f, 0xd5, 0xfb, 0xd6, 0x2f, 0xe9, + 0xd1, 0x6e, 0x53, 0x44, 0xae, 0x59, 0x93, 0xbf}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5b, 0x31, 0xfb, 0xa8, 0x23, 0x4, 0x8c, 0x8c, 0x30, 0x29, 0x12, + 0x9f, 0x86, 0xbc, 0x61, 0x4d, 0xc9, 0xff, 0x79, 0xcf, 0x95, 0x10}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xbd, 0x44, 0xf6, 0x17, 0xa5, 0x86, 0xee, 0xae, 0xaf, 0x45, + 0xdc, 0xf0, 0x25, 0xbe, 0xa3, 0xe8, 0x3e, 0xbe, 0xd, 0x44, + 0x48, 0x9c, 0x33, 0xb6, 0x1e, 0xf0, 0x35, 0x77, 0xc8}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 41}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb0, 0x7f, 0x1, 0x84, 0x3e, 0xf7, 0x95, 0x1d, 0x78}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf7, 0x57, 0x64, 0x6f, 0x33, 0x8d, 0x87, 0xd3, 0x72, 0x14, 0x42, 0x8, - 0x33, 0xe1, 0x3c, 0xf7, 0x59, 0x37, 0x88, 0x86, 0x35, 0x4f, 0xb7}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 13117; - uint8_t client_id_bytes[] = {0xe2, 0x73, 0xa8, 0x0, 0xc9, 0xd0, 0xfa, 0xe0, 0xd, 0xe, 0x5a, - 0xdd, 0x58, 0x3c, 0x5b, 0x26, 0x5c, 0xb5, 0xb8, 0x3f, 0xa8, 0x1e}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x1c, 0x6, 0xf9, 0x94, 0xd, 0x9e, 0xa2, 0x38, 0x75, 0x50, 0xad, 0xd4, 0x87, 0xfe, 0xd6}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xea, 0xc7, 0x3a, 0xb0, 0x6a, 0xda, 0xe2, 0xc1, 0x55, 0xce, - 0x2d, 0xc, 0x1, 0x52, 0x75, 0x7a, 0xa7, 0xc7, 0xc4}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23343, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\245H3\185\249\128\172\213o\226N@\DC1", _password = Just -// "\171\195S\150\179\183\184\247*\177\211j.\227\239\199\SUB\r\187\131L\SYN\CAN\239\f\152", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "%W", _willMsg = "l\CAN\147R\DC3", _willProps = -// [PropAssignedClientIdentifier "\DC1.l\245\ETB\227M\132\216\236\ETX\237re\244\\\223a",PropResponseTopic -// "_<\199\DLE\156k\229.\160K\224g",PropMaximumQoS 37,PropWillDelayInterval 12106,PropAssignedClientIdentifier "q\no -// \217\233o\236\245\US\227\140D}\187U",PropRetainAvailable 63,PropTopicAlias 1675,PropWillDelayInterval -// 20416,PropUserProperty "\208'\167\227\232\223\190\235\SYN\207\208\DC2" -// "\\\187\235ZBO\EMl\250\&7\232\220\NAK\212G\130\207\251\134",PropTopicAliasMaximum -// 4756,PropWildcardSubscriptionAvailable 186,PropMessageExpiryInterval 15069,PropReasonString -// "\224H\229P\178\195\254\212\GS\241\&2\222%\US\130\\\164Q\161i.\142\136\193\218",PropResponseTopic -// "4g\168\180\254\146\239",PropReasonString "*\173",PropMaximumQoS 90,PropServerReference -// "\190\&6JkD\132W\SYN,\235X`\DLE\163\190SPk\248\140w>",PropMaximumQoS 139,PropResponseTopic -// "<\184\227",PropCorrelationData "",PropMaximumPacketSize 22988,PropTopicAliasMaximum 16579,PropUserProperty -// "\237\214" "\179(\242\170\200\135\167B\159\EOT\129z\158l\233\156\182j\168\196_",PropSubscriptionIdentifier -// 10,PropRequestResponseInformation 133,PropRequestProblemInformation 76,PropTopicAliasMaximum 3903,PropUserProperty " -// \150\204\SYN\231[\131\207\&8o" -// "\194\138\CANn\137po\USO\SI\ETB\164\210\243\137\183/\178\ETB\151\142\a}\230\177\152\129\191\197\239"]}), -// _cleanSession = True, _keepAlive = 18606, _connID = "6", _properties = [PropResponseInformation -// "#\248\162",PropSubscriptionIdentifier 18,PropReceiveMaximum 19652,PropMaximumPacketSize -// 4736,PropMessageExpiryInterval 23889,PropMaximumQoS 178,PropMaximumQoS 151,PropPayloadFormatIndicator -// 229,PropMaximumPacketSize 15274,PropCorrelationData -// "$9@W\211`B\151\175\229\193\195\203\171\235\255\200\128nz{-\158\240",PropResponseInformation -// "+\ACKt\CAN\SUB\247_",PropRetainAvailable 28,PropTopicAliasMaximum 5862]} -TEST(Connect5QCTest, Encode7) { +// SubscribeRequest 19824 [("\NUL\181VC\229\166\255j \b\FSg\134\253%\212u\175\246K)\203\142>\132\154`n",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("-e\131\&2\165",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("\229\164\170}\NUL6\248\\?V\138\161\245\251\178\192u$\205\204\GS\191",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\255\220\179G\GS\163\207k\"\197u@\218\v\133\aW\US\136\172j\231v",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("S\189\207H\v\DC4\186]k\202\252\ESC2\228w\158C|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropTopicAliasMaximum +// 5452,PropSharedSubscriptionAvailable 38,PropRequestResponseInformation 189,PropReasonString +// "\DC4q@\188r\ACKd\244\FSv\150\151\245CV!W\SYN",PropUserProperty +// "\242\151S\226\243\214\235\219\158\ACK\ESC|\184$\157\200\240\131\234\235V\RS~\r" "~O",PropReceiveMaximum +// 19316,PropTopicAlias 17157,PropSubscriptionIdentifier 14,PropAuthenticationData +// "\178\137\153\217c\148^\EM\205\&4)4^'\rf\197\SO\248\&3hg",PropTopicAlias 1176,PropRetainAvailable +// 247,PropSessionExpiryInterval 23735,PropSubscriptionIdentifier 27,PropSharedSubscriptionAvailable +// 222,PropResponseInformation +// "\157\ACK+\159\156\197\ETBF9\232A\DC1\204\220\192\ENQ\141\146\131x",PropSharedSubscriptionAvailable +// 76,PropWildcardSubscriptionAvailable 43,PropResponseInformation "F",PropSessionExpiryInterval +// 15558,PropServerReference "0\DLE\162S\233\166\166\249\239",PropServerKeepAlive 17064,PropUserProperty "\232\STX8E +// Fo\249" "\195(\130?\220\196\249\229\GSSB\209\GS-\DC3X\210\202\&2w5-RG\224\248\a\146\181\&6",PropRetainAvailable +// 104,PropAuthenticationMethod "\183\165d\217\185\182\246\ETB"] +TEST(Subscribe5QCTest, Encode1) { uint8_t pkt[] = { - 0x10, 0xb1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x48, 0xae, 0x4a, 0x1a, 0x0, 0x3, 0x23, 0xf8, - 0xa2, 0xb, 0x12, 0x21, 0x4c, 0xc4, 0x27, 0x0, 0x0, 0x12, 0x80, 0x2, 0x0, 0x0, 0x5d, 0x51, 0x24, 0xb2, 0x24, - 0x97, 0x1, 0xe5, 0x27, 0x0, 0x0, 0x3b, 0xaa, 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, 0xf7, - 0x2a, 0xb1, 0xd3, 0x6a, 0x2e, 0xe3, 0xef, 0xc7, 0x1a, 0xd, 0xbb, 0x83, 0x4c, 0x16, 0x18, 0xef, 0xc, 0x98}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x23, 0xf8, 0xa2}; - uint8_t bytesprops1[] = {0x24, 0x39, 0x40, 0x57, 0xd3, 0x60, 0x42, 0x97, 0xaf, 0xe5, 0xc1, 0xc3, - 0xcb, 0xab, 0xeb, 0xff, 0xc8, 0x80, 0x6e, 0x7a, 0x7b, 0x2d, 0x9e, 0xf0}; - uint8_t bytesprops2[] = {0x2b, 0x6, 0x74, 0x18, 0x1a, 0xf7, 0x5f}; + 0x82, 0xc8, 0x2, 0x4d, 0x70, 0xd5, 0x1, 0x22, 0x15, 0x4c, 0x2a, 0x26, 0x19, 0xbd, 0x1f, 0x0, 0x12, 0x14, 0x71, + 0x40, 0xbc, 0x72, 0x6, 0x64, 0xf4, 0x1c, 0x76, 0x96, 0x97, 0xf5, 0x43, 0x56, 0x21, 0x57, 0x16, 0x26, 0x0, 0x18, + 0xf2, 0x97, 0x53, 0xe2, 0xf3, 0xd6, 0xeb, 0xdb, 0x9e, 0x6, 0x1b, 0x7c, 0xb8, 0x24, 0x9d, 0xc8, 0xf0, 0x83, 0xea, + 0xeb, 0x56, 0x1e, 0x7e, 0xd, 0x0, 0x2, 0x7e, 0x4f, 0x21, 0x4b, 0x74, 0x23, 0x43, 0x5, 0xb, 0xe, 0x16, 0x0, + 0x16, 0xb2, 0x89, 0x99, 0xd9, 0x63, 0x94, 0x5e, 0x19, 0xcd, 0x34, 0x29, 0x34, 0x5e, 0x27, 0xd, 0x66, 0xc5, 0xe, + 0xf8, 0x33, 0x68, 0x67, 0x23, 0x4, 0x98, 0x25, 0xf7, 0x11, 0x0, 0x0, 0x5c, 0xb7, 0xb, 0x1b, 0x2a, 0xde, 0x1a, + 0x0, 0x14, 0x9d, 0x6, 0x2b, 0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x88, 0xac, 0x6a, 0xe7, 0x76, 0x1, 0x0, 0x12, 0x53, 0xbd, 0xcf, 0x48, 0xb, 0x14, 0xba, 0x5d, 0x6b, 0xca, 0xfc, + 0x1b, 0x32, 0xe4, 0x77, 0x9e, 0x43, 0x7c, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x0, 0xb5, 0x56, 0x43, 0xe5, 0xa6, 0xff, 0x6a, 0x20, 0x8, + 0x1c, 0x67, 0x86, 0xfd, 0x25, 0xd4, 0x75, 0xaf, 0xf6, 0x4b, + 0x29, 0xcb, 0x8e, 0x3e, 0x84, 0x9a, 0x60, 0x6e}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2d, 0x65, 0x83, 0x32, 0xa5}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe5, 0xa4, 0xaa, 0x7d, 0x0, 0x36, 0xf8, 0x5c, 0x3f, 0x56, 0x8a, + 0xa1, 0xf5, 0xfb, 0xb2, 0xc0, 0x75, 0x24, 0xcd, 0xcc, 0x1d, 0xbf}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xff, 0xdc, 0xb3, 0x47, 0x1d, 0xa3, 0xcf, 0x6b, 0x22, 0xc5, 0x75, 0x40, + 0xda, 0xb, 0x85, 0x7, 0x57, 0x1f, 0x88, 0xac, 0x6a, 0xe7, 0x76}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x53, 0xbd, 0xcf, 0x48, 0xb, 0x14, 0xba, 0x5d, 0x6b, + 0xca, 0xfc, 0x1b, 0x32, 0xe4, 0x77, 0x9e, 0x43, 0x7c}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x14, 0x71, 0x40, 0xbc, 0x72, 0x6, 0x64, 0xf4, 0x1c, + 0x76, 0x96, 0x97, 0xf5, 0x43, 0x56, 0x21, 0x57, 0x16}; + uint8_t bytesprops2[] = {0x7e, 0x4f}; + uint8_t bytesprops1[] = {0xf2, 0x97, 0x53, 0xe2, 0xf3, 0xd6, 0xeb, 0xdb, 0x9e, 0x6, 0x1b, 0x7c, + 0xb8, 0x24, 0x9d, 0xc8, 0xf0, 0x83, 0xea, 0xeb, 0x56, 0x1e, 0x7e, 0xd}; + uint8_t bytesprops3[] = {0xb2, 0x89, 0x99, 0xd9, 0x63, 0x94, 0x5e, 0x19, 0xcd, 0x34, 0x29, + 0x34, 0x5e, 0x27, 0xd, 0x66, 0xc5, 0xe, 0xf8, 0x33, 0x68, 0x67}; + uint8_t bytesprops4[] = {0x9d, 0x6, 0x2b, 0x9f, 0x9c, 0xc5, 0x17, 0x46, 0x39, 0xe8, + 0x41, 0x11, 0xcc, 0xdc, 0xc0, 0x5, 0x8d, 0x92, 0x83, 0x78}; + uint8_t bytesprops5[] = {0x46}; + uint8_t bytesprops6[] = {0x30, 0x10, 0xa2, 0x53, 0xe9, 0xa6, 0xa6, 0xf9, 0xef}; + uint8_t bytesprops8[] = {0xc3, 0x28, 0x82, 0x3f, 0xdc, 0xc4, 0xf9, 0xe5, 0x1d, 0x53, 0x42, 0xd1, 0x1d, 0x2d, 0x13, + 0x58, 0xd2, 0xca, 0x32, 0x77, 0x35, 0x2d, 0x52, 0x47, 0xe0, 0xf8, 0x7, 0x92, 0xb5, 0x36}; + uint8_t bytesprops7[] = {0xe8, 0x2, 0x38, 0x45, 0x20, 0x46, 0x6f, 0xf9}; + uint8_t bytesprops9[] = {0xb7, 0xa5, 0x64, 0xd9, 0xb9, 0xb6, 0xf6, 0x17}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19652}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4736}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23889}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15274}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5862}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x11, 0x2e, 0x6c, 0xf5, 0x17, 0xe3, 0x4d, 0x84, 0xd8, - 0xec, 0x3, 0xed, 0x72, 0x65, 0xf4, 0x5c, 0xdf, 0x61}; - uint8_t byteswillprops1[] = {0x5f, 0x3c, 0xc7, 0x10, 0x9c, 0x6b, 0xe5, 0x2e, 0xa0, 0x4b, 0xe0, 0x67}; - uint8_t byteswillprops2[] = {0x71, 0xa, 0x6f, 0x20, 0xd9, 0xe9, 0x6f, 0xec, - 0xf5, 0x1f, 0xe3, 0x8c, 0x44, 0x7d, 0xbb, 0x55}; - uint8_t byteswillprops4[] = {0x5c, 0xbb, 0xeb, 0x5a, 0x42, 0x4f, 0x19, 0x6c, 0xfa, 0x37, - 0xe8, 0xdc, 0x15, 0xd4, 0x47, 0x82, 0xcf, 0xfb, 0x86}; - uint8_t byteswillprops3[] = {0xd0, 0x27, 0xa7, 0xe3, 0xe8, 0xdf, 0xbe, 0xeb, 0x16, 0xcf, 0xd0, 0x12}; - uint8_t byteswillprops5[] = {0xe0, 0x48, 0xe5, 0x50, 0xb2, 0xc3, 0xfe, 0xd4, 0x1d, 0xf1, 0x32, 0xde, 0x25, - 0x1f, 0x82, 0x5c, 0xa4, 0x51, 0xa1, 0x69, 0x2e, 0x8e, 0x88, 0xc1, 0xda}; - uint8_t byteswillprops6[] = {0x34, 0x67, 0xa8, 0xb4, 0xfe, 0x92, 0xef}; - uint8_t byteswillprops7[] = {0x2a, 0xad}; - uint8_t byteswillprops8[] = {0xbe, 0x36, 0x4a, 0x6b, 0x44, 0x84, 0x57, 0x16, 0x2c, 0xeb, 0x58, - 0x60, 0x10, 0xa3, 0xbe, 0x53, 0x50, 0x6b, 0xf8, 0x8c, 0x77, 0x3e}; - uint8_t byteswillprops9[] = {0x3c, 0xb8, 0xe3}; - uint8_t byteswillprops10[] = {0}; - uint8_t byteswillprops12[] = {0xb3, 0x28, 0xf2, 0xaa, 0xc8, 0x87, 0xa7, 0x42, 0x9f, 0x4, 0x81, - 0x7a, 0x9e, 0x6c, 0xe9, 0x9c, 0xb6, 0x6a, 0xa8, 0xc4, 0x5f}; - uint8_t byteswillprops11[] = {0xed, 0xd6}; - uint8_t byteswillprops14[] = {0xc2, 0x8a, 0x18, 0x6e, 0x89, 0x70, 0x6f, 0x1f, 0x4f, 0xf, - 0x17, 0xa4, 0xd2, 0xf3, 0x89, 0xb7, 0x2f, 0xb2, 0x17, 0x97, - 0x8e, 0x7, 0x7d, 0xe6, 0xb1, 0x98, 0x81, 0xbf, 0xc5, 0xef}; - uint8_t byteswillprops13[] = {0x20, 0x96, 0xcc, 0x16, 0xe7, 0x5b, 0x83, 0xcf, 0x38, 0x6f}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12106}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1675}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20416}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {12, (char*)&byteswillprops3}, .v = {19, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4756}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15069}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22988}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16579}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {2, (char*)&byteswillprops11}, .v = {21, (char*)&byteswillprops12}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3903}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {10, (char*)&byteswillprops13}, .v = {30, (char*)&byteswillprops14}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5452}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops1}, .v = {2, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19316}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17157}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1176}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23735}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15558}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17064}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops7}, .v = {30, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x25, 0x57}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6c, 0x18, 0x93, 0x52, 0x13}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 18606; - uint8_t client_id_bytes[] = {0x36}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xf5, 0x48, 0x33, 0xb9, 0xf9, 0x80, 0xac, 0xd5, 0x6f, 0xe2, 0x4e, 0x40, 0x11}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xab, 0xc3, 0x53, 0x96, 0xb3, 0xb7, 0xb8, 0xf7, 0x2a, 0xb1, 0xd3, 0x6a, 0x2e, - 0xe3, 0xef, 0xc7, 0x1a, 0xd, 0xbb, 0x83, 0x4c, 0x16, 0x18, 0xef, 0xc, 0x98}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19824, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\164\ESC\184\140r\249\243:~\182\177\161", _password = Just -// "=\137\152\193\FS\138\CAN\SO\GS\172=$\179\178=\227\216>", _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "\196", _willMsg = "\189\206O\203\f\146\165\155D\200N\207\198\169;$\242\244\228", _willProps = -// [PropServerKeepAlive 15818,PropUserProperty "\211%\162\170\155j\228\171" "0\140\234.\229v8S\179Q\198 -// \221\239\243I\199\189\179Um",PropTopicAliasMaximum 10841,PropSubscriptionIdentifier 19,PropPayloadFormatIndicator -// 208]}), _cleanSession = True, _keepAlive = 14044, _connID = "\158\230\170S\NUL\239\ETB", _properties = -// [PropTopicAlias 25138,PropAssignedClientIdentifier -// "\f\EOT\r@\224\&3\187.\166\145\144\DC2Y-`\228\&8",PropResponseInformation -// "_\by\141]]}\163\DC3\145\232\\m\184>\244\236",PropTopicAliasMaximum 28569,PropServerKeepAlive -// 12548,PropMessageExpiryInterval 20738,PropSessionExpiryInterval 2221,PropWillDelayInterval -// 29838,PropRequestResponseInformation 89,PropSubscriptionIdentifier 19,PropRetainAvailable 96,PropMaximumPacketSize -// 21169,PropTopicAlias 14616,PropSubscriptionIdentifierAvailable 146]} -TEST(Connect5QCTest, Encode8) { +// SubscribeRequest 12399 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\250L\239\233\150\180y\246\174\156:\150\247RB",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\130/\NAKA~\213\CAN\RS\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("XMwO\188j\180\242\145D7\132\192e\183\EM\166$\183\158|5",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\167\200\ESC\147B\160\157\186\DC14\244.w#\196\246\200\226\230\EM\179\181\SI",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\f\211U\184\143\231\221\ETXl\181&\ENQ\214*.O\GS\206b\SOFx\v\132\&7\159\151r\238,",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\220\EOT\131\&0{\147\167b\132#\244\188\SUB\r\145\DLE\DELzD\133",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\211\177\223!\136x\241+?\150\246\199V+!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("U0\204\242VJa\154\135yp\US\150\210\212xUN\172=\"\161\134\239\238&\153M",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\226\ETX\215\DC2\164\133_g\140\144\NULo",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [PropSubscriptionIdentifierAvailable 24,PropReasonString +// "\230(\209\254(K\bL\255\t",PropServerKeepAlive 13153,PropAuthenticationMethod +// "\188|\226\242\&7\139",PropWildcardSubscriptionAvailable 151,PropAssignedClientIdentifier +// "@c\151\tz!}\168\NAK\206\217U\213Y\162\ESC\134\DC4\226\178c*\133",PropResponseInformation +// "\188\209\172",PropRetainAvailable 82,PropMessageExpiryInterval 7345,PropRequestResponseInformation +// 217,PropMaximumQoS 33,PropResponseInformation "[\223A\248\238\249\139\SYN\245\134\192\219",PropReasonString +// "y\187\SYN\134\236\NULo\246\130us\134Y\151j\243]4h\188\207",PropWillDelayInterval 20738] +TEST(Subscribe5QCTest, Encode2) { uint8_t pkt[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0x12, 0x3d, 0x89, - 0x98, 0xc1, 0x1c, 0x8a, 0x18, 0xe, 0x1d, 0xac, 0x3d, 0x24, 0xb3, 0xb2, 0x3d, 0xe3, 0xd8, 0x3e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xc, 0x4, 0xd, 0x40, 0xe0, 0x33, 0xbb, 0x2e, 0xa6, - 0x91, 0x90, 0x12, 0x59, 0x2d, 0x60, 0xe4, 0x38}; - uint8_t bytesprops1[] = {0x5f, 0x8, 0x79, 0x8d, 0x5d, 0x5d, 0x7d, 0xa3, 0x13, - 0x91, 0xe8, 0x5c, 0x6d, 0xb8, 0x3e, 0xf4, 0xec}; + 0x82, 0xc3, 0x2, 0x30, 0x6f, 0x74, 0x29, 0x18, 0x1f, 0x0, 0xa, 0xe6, 0x28, 0xd1, 0xfe, 0x28, 0x4b, 0x8, 0x4c, + 0xff, 0x9, 0x13, 0x33, 0x61, 0x15, 0x0, 0x6, 0xbc, 0x7c, 0xe2, 0xf2, 0x37, 0x8b, 0x28, 0x97, 0x12, 0x0, 0x17, + 0x40, 0x63, 0x97, 0x9, 0x7a, 0x21, 0x7d, 0xa8, 0x15, 0xce, 0xd9, 0x55, 0xd5, 0x59, 0xa2, 0x1b, 0x86, 0x14, 0xe2, + 0xb2, 0x63, 0x2a, 0x85, 0x1a, 0x0, 0x3, 0xbc, 0xd1, 0xac, 0x25, 0x52, 0x2, 0x0, 0x0, 0x1c, 0xb1, 0x19, 0xd9, + 0x24, 0x21, 0x1a, 0x0, 0xc, 0x5b, 0xdf, 0x41, 0xf8, 0xee, 0xf9, 0x8b, 0x16, 0xf5, 0x86, 0xc0, 0xdb, 0x1f, 0x0, + 0x15, 0x79, 0xbb, 0x16, 0x86, 0xec, 0x0, 0x6f, 0xf6, 0x82, 0x75, 0x73, 0x86, 0x59, 0x97, 0x6a, 0xf3, 0x5d, 0x34, + 0x68, 0xbc, 0xcf, 0x18, 0x0, 0x0, 0x51, 0x2, 0x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 0x4d, 0x1, 0x0, 0xc, 0xe2, 0x3, 0xd7, 0x12, 0xa4, 0x85, 0x5f, 0x67, 0x8c, 0x90, + 0x0, 0x6f, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xfa, 0x4c, 0xef, 0xe9, 0x96, 0xb4, 0x79, 0xf6, + 0xae, 0x9c, 0x3a, 0x96, 0xf7, 0x52, 0x42}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x82, 0x2f, 0x15, 0x41, 0x7e, 0xd5, 0x18, 0x1e, 0xc5}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x58, 0x4d, 0x77, 0x4f, 0xbc, 0x6a, 0xb4, 0xf2, 0x91, 0x44, 0x37, + 0x84, 0xc0, 0x65, 0xb7, 0x19, 0xa6, 0x24, 0xb7, 0x9e, 0x7c, 0x35}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa7, 0xc8, 0x1b, 0x93, 0x42, 0xa0, 0x9d, 0xba, 0x11, 0x34, 0xf4, 0x2e, + 0x77, 0x23, 0xc4, 0xf6, 0xc8, 0xe2, 0xe6, 0x19, 0xb3, 0xb5, 0xf}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xc, 0xd3, 0x55, 0xb8, 0x8f, 0xe7, 0xdd, 0x3, 0x6c, 0xb5, + 0x26, 0x5, 0xd6, 0x2a, 0x2e, 0x4f, 0x1d, 0xce, 0x62, 0xe, + 0x46, 0x78, 0xb, 0x84, 0x37, 0x9f, 0x97, 0x72, 0xee, 0x2c}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xdc, 0x4, 0x83, 0x30, 0x7b, 0x93, 0xa7, 0x62, 0x84, 0x23, + 0xf4, 0xbc, 0x1a, 0xd, 0x91, 0x10, 0x7f, 0x7a, 0x44, 0x85}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xd3, 0xb1, 0xdf, 0x21, 0x88, 0x78, 0xf1, 0x2b, + 0x3f, 0x96, 0xf6, 0xc7, 0x56, 0x2b, 0x21}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x55, 0x30, 0xcc, 0xf2, 0x56, 0x4a, 0x61, 0x9a, 0x87, 0x79, + 0x70, 0x1f, 0x96, 0xd2, 0xd4, 0x78, 0x55, 0x4e, 0xac, 0x3d, + 0x22, 0xa1, 0x86, 0xef, 0xee, 0x26, 0x99, 0x4d}; + lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe2, 0x3, 0xd7, 0x12, 0xa4, 0x85, 0x5f, 0x67, 0x8c, 0x90, 0x0, 0x6f}; + lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xe6, 0x28, 0xd1, 0xfe, 0x28, 0x4b, 0x8, 0x4c, 0xff, 0x9}; + uint8_t bytesprops1[] = {0xbc, 0x7c, 0xe2, 0xf2, 0x37, 0x8b}; + uint8_t bytesprops2[] = {0x40, 0x63, 0x97, 0x9, 0x7a, 0x21, 0x7d, 0xa8, 0x15, 0xce, 0xd9, 0x55, + 0xd5, 0x59, 0xa2, 0x1b, 0x86, 0x14, 0xe2, 0xb2, 0x63, 0x2a, 0x85}; + uint8_t bytesprops3[] = {0xbc, 0xd1, 0xac}; + uint8_t bytesprops4[] = {0x5b, 0xdf, 0x41, 0xf8, 0xee, 0xf9, 0x8b, 0x16, 0xf5, 0x86, 0xc0, 0xdb}; + uint8_t bytesprops5[] = {0x79, 0xbb, 0x16, 0x86, 0xec, 0x0, 0x6f, 0xf6, 0x82, 0x75, 0x73, + 0x86, 0x59, 0x97, 0x6a, 0xf3, 0x5d, 0x34, 0x68, 0xbc, 0xcf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25138}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28569}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12548}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20738}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2221}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29838}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21169}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14616}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13153}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7345}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20738}}, }; lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x30, 0x8c, 0xea, 0x2e, 0xe5, 0x76, 0x38, 0x53, 0xb3, 0x51, 0xc6, - 0x20, 0xdd, 0xef, 0xf3, 0x49, 0xc7, 0xbd, 0xb3, 0x55, 0x6d}; - uint8_t byteswillprops0[] = {0xd3, 0x25, 0xa2, 0xaa, 0x9b, 0x6a, 0xe4, 0xab}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12399, 10, topic_filters, qos_levels, props); - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15818}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {8, (char*)&byteswillprops0}, .v = {21, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10841}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 23812 [("l\217\181\248\247R\218\132\148\US\247\151\130\255:P",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("B1X\194\172\224\"\188%\220\224\EM\208\234yj\214\&1I\202\199[\155",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("5)l@\241",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\169\t|)\195\169\b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("<\146&\226\RS\169\182\&62\t;\r\171K\170\204 x\140\&9V\245K(\SUB\SOe>\144\252",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\167\157\EOT\218\v\192%\143\217\155\202\224\246\137",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("n\153\194\225\207\165\197\160\213\NAK\182",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic +// "\NULU\197U\159\205\ETB@\162u^Q\249\141\203\129h\180\226}",PropAuthenticationData +// "2\231\134)D\GSUy\134=u\a;w\193e\164\152*\173",PropCorrelationData +// ".\214m\158\230:\201\138\179\ACK\211UZ\173\r",PropAuthenticationData "h\163<\v\140\ETB`\195k",PropReceiveMaximum +// 162,PropRequestProblemInformation 210] +TEST(Subscribe5QCTest, Encode3) { + uint8_t pkt[] = {0x82, 0xd6, 0x1, 0x5d, 0x4, 0x51, 0x8, 0x0, 0x14, 0x0, 0x55, 0xc5, 0x55, 0x9f, 0xcd, 0x17, 0x40, + 0xa2, 0x75, 0x5e, 0x51, 0xf9, 0x8d, 0xcb, 0x81, 0x68, 0xb4, 0xe2, 0x7d, 0x16, 0x0, 0x14, 0x32, 0xe7, + 0x86, 0x29, 0x44, 0x1d, 0x55, 0x79, 0x86, 0x3d, 0x75, 0x7, 0x3b, 0x77, 0xc1, 0x65, 0xa4, 0x98, 0x2a, + 0xad, 0x9, 0x0, 0xf, 0x2e, 0xd6, 0x6d, 0x9e, 0xe6, 0x3a, 0xc9, 0x8a, 0xb3, 0x6, 0xd3, 0x55, 0x5a, + 0xad, 0xd, 0x16, 0x0, 0x9, 0x68, 0xa3, 0x3c, 0xb, 0x8c, 0x17, 0x60, 0xc3, 0x6b, 0x21, 0x0, 0xa2, + 0x17, 0xd2, 0x0, 0x10, 0x6c, 0xd9, 0xb5, 0xf8, 0xf7, 0x52, 0xda, 0x84, 0x94, 0x1f, 0xf7, 0x97, 0x82, + 0xff, 0x3a, 0x50, 0x0, 0x0, 0x17, 0x42, 0x31, 0x58, 0xc2, 0xac, 0xe0, 0x22, 0xbc, 0x25, 0xdc, 0xe0, + 0x19, 0xd0, 0xea, 0x79, 0x6a, 0xd6, 0x31, 0x49, 0xca, 0xc7, 0x5b, 0x9b, 0x0, 0x0, 0x5, 0x35, 0x29, + 0x6c, 0x40, 0xf1, 0x2, 0x0, 0x7, 0xa9, 0x9, 0x7c, 0x29, 0xc3, 0xa9, 0x8, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x1e, 0x3c, 0x92, 0x26, 0xe2, 0x1e, 0xa9, 0xb6, 0x36, 0x32, 0x9, 0x3b, 0xd, 0xab, 0x4b, 0xaa, + 0xcc, 0x20, 0x78, 0x8c, 0x39, 0x56, 0xf5, 0x4b, 0x28, 0x1a, 0xe, 0x65, 0x3e, 0x90, 0xfc, 0x0, 0x0, + 0xe, 0xa7, 0x9d, 0x4, 0xda, 0xb, 0xc0, 0x25, 0x8f, 0xd9, 0x9b, 0xca, 0xe0, 0xf6, 0x89, 0x1, 0x0, + 0xb, 0x6e, 0x99, 0xc2, 0xe1, 0xcf, 0xa5, 0xc5, 0xa0, 0xd5, 0x15, 0xb6, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x6c, 0xd9, 0xb5, 0xf8, 0xf7, 0x52, 0xda, 0x84, + 0x94, 0x1f, 0xf7, 0x97, 0x82, 0xff, 0x3a, 0x50}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x42, 0x31, 0x58, 0xc2, 0xac, 0xe0, 0x22, 0xbc, 0x25, 0xdc, 0xe0, 0x19, + 0xd0, 0xea, 0x79, 0x6a, 0xd6, 0x31, 0x49, 0xca, 0xc7, 0x5b, 0x9b}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x35, 0x29, 0x6c, 0x40, 0xf1}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa9, 0x9, 0x7c, 0x29, 0xc3, 0xa9, 0x8}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x3c, 0x92, 0x26, 0xe2, 0x1e, 0xa9, 0xb6, 0x36, 0x32, 0x9, + 0x3b, 0xd, 0xab, 0x4b, 0xaa, 0xcc, 0x20, 0x78, 0x8c, 0x39, + 0x56, 0xf5, 0x4b, 0x28, 0x1a, 0xe, 0x65, 0x3e, 0x90, 0xfc}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa7, 0x9d, 0x4, 0xda, 0xb, 0xc0, 0x25, 0x8f, 0xd9, 0x9b, 0xca, 0xe0, 0xf6, 0x89}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6e, 0x99, 0xc2, 0xe1, 0xcf, 0xa5, 0xc5, 0xa0, 0xd5, 0x15, 0xb6}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x0, 0x55, 0xc5, 0x55, 0x9f, 0xcd, 0x17, 0x40, 0xa2, 0x75, + 0x5e, 0x51, 0xf9, 0x8d, 0xcb, 0x81, 0x68, 0xb4, 0xe2, 0x7d}; + uint8_t bytesprops1[] = {0x32, 0xe7, 0x86, 0x29, 0x44, 0x1d, 0x55, 0x79, 0x86, 0x3d, + 0x75, 0x7, 0x3b, 0x77, 0xc1, 0x65, 0xa4, 0x98, 0x2a, 0xad}; + uint8_t bytesprops2[] = {0x2e, 0xd6, 0x6d, 0x9e, 0xe6, 0x3a, 0xc9, 0x8a, 0xb3, 0x6, 0xd3, 0x55, 0x5a, 0xad, 0xd}; + uint8_t bytesprops3[] = {0x68, 0xa3, 0x3c, 0xb, 0x8c, 0x17, 0x60, 0xc3, 0x6b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 162}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, }; - lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc4}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbd, 0xce, 0x4f, 0xcb, 0xc, 0x92, 0xa5, 0x9b, 0x44, 0xc8, - 0x4e, 0xcf, 0xc6, 0xa9, 0x3b, 0x24, 0xf2, 0xf4, 0xe4}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14044; - uint8_t client_id_bytes[] = {0x9e, 0xe6, 0xaa, 0x53, 0x0, 0xef, 0x17}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa4, 0x1b, 0xb8, 0x8c, 0x72, 0xf9, 0xf3, 0x3a, 0x7e, 0xb6, 0xb1, 0xa1}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x3d, 0x89, 0x98, 0xc1, 0x1c, 0x8a, 0x18, 0xe, 0x1d, - 0xac, 0x3d, 0x24, 0xb3, 0xb2, 0x3d, 0xe3, 0xd8, 0x3e}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23812, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "bl\173\212\183[K\243\204\225\r\255\210,\215\200\142\&1\181\SOH8\206\168", _password -// = Just "\NUL. m\211I\167\170\222\224%\253#\246", _lastWill = Nothing, _cleanSession = False, _keepAlive = 24572, -// _connID = "\182$y\234\226\247:S\142\"\245_\255\&0\203\191_\249P\SUB8\223\190]0\182\ETBg<", _properties = -// [PropWillDelayInterval 17579,PropMaximumPacketSize 32742,PropAssignedClientIdentifier -// "\DELR\EOT\188\DC4\DC2u\DC2\253",PropSubscriptionIdentifierAvailable 23,PropMaximumPacketSize -// 17824,PropSharedSubscriptionAvailable 192,PropAuthenticationData "s\195i\249C\205",PropSharedSubscriptionAvailable -// 233,PropServerReference "\v\141,\136\189]\149\150e\233\US\149 \241\GSw]\193\t",PropServerReference -// "\DC2\193R\ETB\176M\189\155\134\206\253e\153\EM\152",PropMaximumQoS 124,PropRequestProblemInformation -// 185,PropWillDelayInterval 23945,PropServerKeepAlive 11387,PropMaximumPacketSize 2848,PropAssignedClientIdentifier -// "\DC1\240\252\182N\207M\251\252\RSLoj\180",PropServerKeepAlive 503,PropMaximumPacketSize 19175,PropAuthenticationData -// "R\150\224\199\FSN7\164\DC1\255\v\184\SOH\216R\137\132E\132\ETBT4",PropRetainAvailable 14,PropWillDelayInterval -// 23960]} -TEST(Connect5QCTest, Encode9) { - u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, 0x30, 0xcb, 0xbf, 0x5f, - 0xf9, 0x50, 0x1a, 0x38, 0xdf, 0xbe, 0x5d, 0x30, 0xb6, 0x17, 0x67, 0x3c, 0x0, 0x17, 0x62, 0x6c, 0xad, 0xd4, 0xb7, - 0x5b, 0x4b, 0xf3, 0xcc, 0xe1, 0xd, 0xff, 0xd2, 0x2c, 0xd7, 0xc8, 0x8e, 0x31, 0xb5, 0x1, 0x38, 0xce, 0xa8, 0x0, - 0xe, 0x0, 0x2e, 0x20, 0x6d, 0xd3, 0x49, 0xa7, 0xaa, 0xde, 0xe0, 0x25, 0xfd, 0x23, 0xf6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7f, 0x52, 0x4, 0xbc, 0x14, 0x12, 0x75, 0x12, 0xfd}; - uint8_t bytesprops1[] = {0x73, 0xc3, 0x69, 0xf9, 0x43, 0xcd}; - uint8_t bytesprops2[] = {0xb, 0x8d, 0x2c, 0x88, 0xbd, 0x5d, 0x95, 0x96, 0x65, 0xe9, - 0x1f, 0x95, 0x20, 0xf1, 0x1d, 0x77, 0x5d, 0xc1, 0x9}; - uint8_t bytesprops3[] = {0x12, 0xc1, 0x52, 0x17, 0xb0, 0x4d, 0xbd, 0x9b, 0x86, 0xce, 0xfd, 0x65, 0x99, 0x19, 0x98}; - uint8_t bytesprops4[] = {0x11, 0xf0, 0xfc, 0xb6, 0x4e, 0xcf, 0x4d, 0xfb, 0xfc, 0x1e, 0x4c, 0x6f, 0x6a, 0xb4}; - uint8_t bytesprops5[] = {0x52, 0x96, 0xe0, 0xc7, 0x1c, 0x4e, 0x37, 0xa4, 0x11, 0xff, 0xb, - 0xb8, 0x1, 0xd8, 0x52, 0x89, 0x84, 0x45, 0x84, 0x17, 0x54, 0x34}; +// SubscribeRequest 27610 [("\237%=A\255\167\&8",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [PropWillDelayInterval 15551,PropCorrelationData "",PropAuthenticationData +// "\134\SI)%\209\199\157u\176\vB\DLElV\164GC=\210",PropSharedSubscriptionAvailable 240,PropResponseTopic +// "\152C\212I\164)\165\208\&5\GSD\DLE\170\&6\192\139",PropAuthenticationMethod "p\139",PropContentType +// "^\195H\250\238\&1c\138",PropSharedSubscriptionAvailable 151,PropRetainAvailable 104,PropAuthenticationMethod +// "h\191\175/\174\245=\140\DC4",PropReceiveMaximum 20504,PropMaximumQoS 50,PropResponseTopic +// "zG\226d\219\FS\253 ",PropMaximumPacketSize -// 19752,PropAssignedClientIdentifier "\208\222r\156\DEL\206XE",PropMaximumQoS 211,PropMaximumQoS -// 34,PropTopicAliasMaximum 15201,PropSharedSubscriptionAvailable 156]}), _cleanSession = False, _keepAlive = 147, -// _connID = "\252{\206-]\238\&1\253 \RS\SIy\178", _properties = [PropMessageExpiryInterval 15650,PropCorrelationData -// "\168s\144\128\209P\198\193\146\140\173\206v\198\170\169n\EM\\+j-\198u\215\144\\\204\168\"",PropTopicAlias -// 6863,PropSharedSubscriptionAvailable 115,PropWillDelayInterval 9805,PropMessageExpiryInterval -// 13621,PropMaximumPacketSize 29496,PropSubscriptionIdentifierAvailable 181,PropAuthenticationData -// ">\161\NAK\175",PropSubscriptionIdentifier 13,PropMessageExpiryInterval 5726,PropMaximumQoS -// 52,PropAssignedClientIdentifier ")",PropSessionExpiryInterval 13529,PropMaximumQoS -// 103,PropWildcardSubscriptionAvailable 7,PropTopicAlias 4946,PropMaximumPacketSize 20204,PropRetainAvailable -// 45,PropTopicAlias 14764,PropSubscriptionIdentifier 13,PropSharedSubscriptionAvailable 253,PropResponseTopic -// "\145\b\215\250\196&\STX\199\253",PropMessageExpiryInterval 22286]} -TEST(Connect5QCTest, Encode10) { +// SubscribeRequest 4069 [("k\212\217\191\167Z\148\215\216\238$0\DLE\138\137",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("f\DC3\GSt\DC4]e\t\EOTEx\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\148G\181",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("+\153\166\221\250\195|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\DC2L\210Q\212\131\223\205\220\163\&3\141\245\165T\235c5\168\229",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\DEL\129c\NAKgK\238]W\EM\132uT\138\249i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\158\182*d\178\184#\243a\207]\196\141\233\DEL\165)\DC4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\183\ETB\154u\225\161A@_\SYN\251\185%\179y\180A\ESC\b\143\SO",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRequestResponseInformation 20,PropReasonString +// "\147\176\141\212\255\&2\160\148\162\144\&5\134H\180{$f\153\228\207",PropMessageExpiryInterval +// 3689,PropServerKeepAlive 28576,PropAuthenticationData +// "O]zr/k7\163\DC181\186\139\142\171;=\182\236\t\250\174\&7\255h\204",PropPayloadFormatIndicator +// 14,PropSharedSubscriptionAvailable 171,PropUserProperty +// "\176\252\NUL\139x\164|\129\195\STX\207\250\&6[\SYN\GS\151\250\200\248\130\250" "\128",PropResponseTopic +// "\224\253\187;}$|\207",PropSharedSubscriptionAvailable 66,PropSessionExpiryInterval 21633,PropResponseTopic +// "'\240*-E\DC1\199\180\206\165hN%",PropRetainAvailable 93,PropMaximumPacketSize 22481] +TEST(Subscribe5QCTest, Encode5) { uint8_t pk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f, 0x98, 0x77, 0x5b, 0xb9, 0x60, - 0x55, 0x49, 0x18, 0x0, 0x10, 0x97, 0x14, 0x79, 0x27, 0x50, 0x4d, 0x5e, 0xd6, 0x30, 0x3c, 0x5e, 0x6b, 0xb3, 0xb3, - 0x3a, 0x7c, 0x0, 0xa, 0x3d, 0x18, 0x74, 0x9b, 0x5f, 0x64, 0x1c, 0xc, 0x3a, 0xfc, 0x0, 0x5, 0x4a, 0xaf, 0xf, - 0xbc, 0xf0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xa8, 0x73, 0x90, 0x80, 0xd1, 0x50, 0xc6, 0xc1, 0x92, 0x8c, 0xad, 0xce, 0x76, 0xc6, 0xaa, - 0xa9, 0x6e, 0x19, 0x5c, 0x2b, 0x6a, 0x2d, 0xc6, 0x75, 0xd7, 0x90, 0x5c, 0xcc, 0xa8, 0x22}; - uint8_t bytesprops1[] = {0x3e, 0xa1, 0x15, 0xaf}; - uint8_t bytesprops2[] = {0x29}; - uint8_t bytesprops3[] = {0x91, 0x8, 0xd7, 0xfa, 0xc4, 0x26, 0x2, 0xc7, 0xfd}; + 0x82, 0x93, 0x2, 0xf, 0xe5, 0x87, 0x1, 0x19, 0x14, 0x1f, 0x0, 0x14, 0x93, 0xb0, 0x8d, 0xd4, 0xff, 0x32, 0xa0, + 0x94, 0xa2, 0x90, 0x35, 0x86, 0x48, 0xb4, 0x7b, 0x24, 0x66, 0x99, 0xe4, 0xcf, 0x2, 0x0, 0x0, 0xe, 0x69, 0x13, + 0x6f, 0xa0, 0x16, 0x0, 0x1a, 0x4f, 0x5d, 0x7a, 0x72, 0x2f, 0x6b, 0x37, 0xa3, 0x11, 0x38, 0x31, 0xba, 0x8b, 0x8e, + 0xab, 0x3b, 0x3d, 0xb6, 0xec, 0x9, 0xfa, 0xae, 0x37, 0xff, 0x68, 0xcc, 0x1, 0xe, 0x2a, 0xab, 0x26, 0x0, 0x16, + 0xb0, 0xfc, 0x0, 0x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, + 0xfb, 0xb9, 0x25, 0xb3, 0x79, 0xb4, 0x41, 0x1b, 0x8, 0x8f, 0xe, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x6b, 0xd4, 0xd9, 0xbf, 0xa7, 0x5a, 0x94, 0xd7, + 0xd8, 0xee, 0x24, 0x30, 0x10, 0x8a, 0x89}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x66, 0x13, 0x1d, 0x74, 0x14, 0x5d, 0x65, 0x9, 0x4, 0x45, 0x78, 0xd0}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x94, 0x47, 0xb5}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x2b, 0x99, 0xa6, 0xdd, 0xfa, 0xc3, 0x7c}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x12, 0x4c, 0xd2, 0x51, 0xd4, 0x83, 0xdf, 0xcd, 0xdc, 0xa3, + 0x33, 0x8d, 0xf5, 0xa5, 0x54, 0xeb, 0x63, 0x35, 0xa8, 0xe5}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x7f, 0x81, 0x63, 0x15, 0x67, 0x4b, 0xee, 0x5d, + 0x57, 0x19, 0x84, 0x75, 0x54, 0x8a, 0xf9, 0x69}; + lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x9e, 0xb6, 0x2a, 0x64, 0xb2, 0xb8, 0x23, 0xf3, 0x61, + 0xcf, 0x5d, 0xc4, 0x8d, 0xe9, 0x7f, 0xa5, 0x29, 0x14}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xb7, 0x17, 0x9a, 0x75, 0xe1, 0xa1, 0x41, 0x40, 0x5f, 0x16, 0xfb, + 0xb9, 0x25, 0xb3, 0x79, 0xb4, 0x41, 0x1b, 0x8, 0x8f, 0xe}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x93, 0xb0, 0x8d, 0xd4, 0xff, 0x32, 0xa0, 0x94, 0xa2, 0x90, + 0x35, 0x86, 0x48, 0xb4, 0x7b, 0x24, 0x66, 0x99, 0xe4, 0xcf}; + uint8_t bytesprops1[] = {0x4f, 0x5d, 0x7a, 0x72, 0x2f, 0x6b, 0x37, 0xa3, 0x11, 0x38, 0x31, 0xba, 0x8b, + 0x8e, 0xab, 0x3b, 0x3d, 0xb6, 0xec, 0x9, 0xfa, 0xae, 0x37, 0xff, 0x68, 0xcc}; + uint8_t bytesprops3[] = {0x80}; + uint8_t bytesprops2[] = {0xb0, 0xfc, 0x0, 0x8b, 0x78, 0xa4, 0x7c, 0x81, 0xc3, 0x2, 0xcf, + 0xfa, 0x36, 0x5b, 0x16, 0x1d, 0x97, 0xfa, 0xc8, 0xf8, 0x82, 0xfa}; + uint8_t bytesprops4[] = {0xe0, 0xfd, 0xbb, 0x3b, 0x7d, 0x24, 0x7c, 0xcf}; + uint8_t bytesprops5[] = {0x27, 0xf0, 0x2a, 0x2d, 0x45, 0x11, 0xc7, 0xb4, 0xce, 0xa5, 0x68, 0x4e, 0x25}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15650}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6863}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9805}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13621}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29496}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5726}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13529}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4946}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20204}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14764}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22286}}, - }; - - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x77, 0x12, 0x3d, 0xa5, 0x4d, 0xe7, 0xee, 0x15, 0xa2, 0xf0, 0xce, 0x71, 0x98, 0x8e, - 0xe3, 0xdc, 0xa8, 0xa7, 0x2c, 0x4b, 0xde, 0x79, 0xf0, 0x77, 0xdf, 0xda, 0x60, 0xf8}; - uint8_t byteswillprops1[] = {0x7, 0x5, 0xc2, 0x7c, 0x13, 0x20, 0xe5, 0xba, 0x4c, 0x3f, 0x9b, 0xa7, - 0x54, 0x1c, 0x56, 0xcd, 0x92, 0x24, 0xa6, 0xc3, 0x4, 0x3a, 0xc, 0x6f}; - uint8_t byteswillprops2[] = {0x3a, 0xfd, 0x24, 0x75, 0x19, 0x90, 0x33, 0x8b}; - uint8_t byteswillprops4[] = {0}; - uint8_t byteswillprops3[] = {0x36, 0xcd, 0x7d, 0xcc, 0xeb, 0x3d, 0x61, 0x4f, 0x2c, 0xb, 0xc8, 0x70, - 0xb8, 0x62, 0xbd, 0xa5, 0x17, 0x4e, 0xe4, 0x2d, 0xf0, 0xa1, 0xe9, 0xf7}; - uint8_t byteswillprops5[] = {0x3d, 0x93, 0x17}; - uint8_t byteswillprops6[] = {0x7e, 0xaa, 0x59, 0x64, 0x64, 0x16, 0x6f, 0x6a, 0xc6, 0x2a, 0x32, 0xbb, 0xce, - 0x43, 0x20, 0x4f, 0xec, 0xb, 0xdf, 0xfa, 0xdf, 0xde, 0xf9, 0xbf, 0xaa, 0x41}; - uint8_t byteswillprops7[] = {0x4b, 0x20, 0x3e, 0x7a, 0x47, 0xe2, 0x64, 0xdb, 0x1c, 0xfd, 0x20}; - uint8_t byteswillprops8[] = {0xd0, 0xde, 0x72, 0x9c, 0x7f, 0xce, 0x58, 0x45}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11399}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29117}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19781}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {24, (char*)&byteswillprops3}, .v = {0, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5382}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12235}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19752}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15201}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3689}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28576}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops2}, .v = {1, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21633}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22481}}, }; - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb5, 0xe6, 0xc5, 0x58, 0x71, 0xbb, 0x43, 0x40, 0x3b, 0x50, 0xd0, - 0x31, 0x18, 0xbf, 0x98, 0x77, 0x5b, 0xb9, 0x60, 0x55, 0x49, 0x18}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x97, 0x14, 0x79, 0x27, 0x50, 0x4d, 0x5e, 0xd6, - 0x30, 0x3c, 0x5e, 0x6b, 0xb3, 0xb3, 0x3a, 0x7c}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 147; - uint8_t client_id_bytes[] = {0xfc, 0x7b, 0xce, 0x2d, 0x5d, 0xee, 0x31, 0xfd, 0x20, 0x1e, 0xf, 0x79, 0xb2}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x3d, 0x18, 0x74, 0x9b, 0x5f, 0x64, 0x1c, 0xc, 0x3a, 0xfc}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x4a, 0xaf, 0xf, 0xbc, 0xf0}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4069, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 6101 [(",\ENQ\132\182e\220\SYN%\233\253\238",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\RSH\179\141\155\183W\DC3\253\169v6\193;\187`c\217\218\234",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x27, 0x17, 0xd5, 0x0, 0xb, 0x2c, 0x5, 0x84, 0xb6, 0x65, 0xdc, 0x16, 0x25, - 0xe9, 0xfd, 0xee, 0x1, 0x0, 0x14, 0x1e, 0x48, 0xb3, 0x8d, 0x9b, 0xb7, 0x57, 0x13, - 0xfd, 0xa9, 0x76, 0x36, 0xc1, 0x3b, 0xbb, 0x60, 0x63, 0xd9, 0xda, 0xea, 0x2}; +// SubscribeRequest 4140 [("q\r\152^#\158\&0\215\239\148E\179M",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\178\RS\139\147\GS\136\&8\163^",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("8Y\221d\ETX\244\192\148\163\158\187\243$.X\166\202\211\153\209\237\218\248",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("yb\183l\128\223\ENQ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("Q\140AB*\199\195j\143@\USo\199\190aA\198\245\248\172E",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\205,\SI\FS\230\197\161j<\221\143",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("b",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("x\229\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1})] [PropSubscriptionIdentifierAvailable 232,PropSubscriptionIdentifier +// 24,PropWildcardSubscriptionAvailable 16,PropAuthenticationMethod "g\RS\216",PropServerReference +// "=\174\&2p\191\188\v\253\243\177@\181;\134\190\DC4\FS\206\200\ESC$\162\197\174",PropTopicAliasMaximum +// 24986,PropReasonString "\225\&4\133\139Z\140\FS\248[/\133\150\ESC\NUL\193M\178\FSr\207\190\ESCP, +// \232:",PropAuthenticationData +// ".\"\142I>\SIa\219s\228z*M/\153\204\US@%",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("/ti-C\SUB\US\190\&4\138",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\GS\205\155",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\161\159\232{t\166\134\176\251\137\135\166\212",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("hO\199\173\182",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("E\SI\143~\248\185\255\166X\245\253\209\171\231\220\133\210\226\SO",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSubscriptionIdentifier +// 24,PropCorrelationData "\196u\174\162\192\EOTP\194\232\221\ESCwC",PropTopicAlias 6660,PropSharedSubscriptionAvailable +// 18,PropReceiveMaximum 21591,PropMessageExpiryInterval 27385,PropAssignedClientIdentifier +// "*\172\236\193\DC1D\216p\205\ESCq\135\132\184\194\237",PropServerKeepAlive 24724,PropMaximumQoS 145,PropUserProperty +// "\223\&1>3\135\205" "<`R%\DC3\161\DC2\129R\141f\193d\202`\ACK",PropCorrelationData +// "\250^\241m\149\"\241V\168*f\CANC\183\212\165",PropRequestResponseInformation 39,PropReasonString +// "\156\130Z\174\131\252gT\241\SYNf\t\159o\128\144\US-r\193\184\223\152\ENQ"] +TEST(Subscribe5QCTest, Encode7) { + uint8_t pkt[] = { + 0x82, 0xe1, 0x1, 0x7d, 0xab, 0x82, 0x1, 0xb, 0x18, 0x9, 0x0, 0xd, 0xc4, 0x75, 0xae, 0xa2, 0xc0, 0x4, 0x50, + 0xc2, 0xe8, 0xdd, 0x1b, 0x77, 0x43, 0x23, 0x1a, 0x4, 0x2a, 0x12, 0x21, 0x54, 0x57, 0x2, 0x0, 0x0, 0x6a, 0xf9, + 0x12, 0x0, 0x10, 0x2a, 0xac, 0xec, 0xc1, 0x11, 0x44, 0xd8, 0x70, 0xcd, 0x1b, 0x71, 0x87, 0x84, 0xb8, 0xc2, 0xed, + 0x13, 0x60, 0x94, 0x24, 0x91, 0x26, 0x0, 0x6, 0xdf, 0x31, 0x3e, 0x33, 0x87, 0xcd, 0x0, 0x10, 0x3c, 0x60, 0x52, + 0x25, 0x13, 0xa1, 0x12, 0x81, 0x52, 0x8d, 0x66, 0xc1, 0x64, 0xca, 0x60, 0x6, 0x9, 0x0, 0x10, 0xfa, 0x5e, 0xf1, + 0x6d, 0x95, 0x22, 0xf1, 0x56, 0xa8, 0x2a, 0x66, 0x18, 0x43, 0xb7, 0xd4, 0xa5, 0x19, 0x27, 0x1f, 0x0, 0x18, 0x9c, + 0x82, 0x5a, 0xae, 0x83, 0xfc, 0x67, 0x54, 0xf1, 0x16, 0x66, 0x9, 0x9f, 0x6f, 0x80, 0x90, 0x1f, 0x2d, 0x72, 0xc1, + 0xb8, 0xdf, 0x98, 0x5, 0x0, 0x14, 0xeb, 0xb3, 0x8f, 0xa9, 0x6f, 0x8c, 0x7e, 0xf6, 0x91, 0x3e, 0xe4, 0x7a, 0x2a, + 0x4d, 0x2f, 0x99, 0xcc, 0x1f, 0x40, 0x25, 0x0, 0x0, 0xa, 0x2f, 0x74, 0x69, 0x2d, 0x43, 0x1a, 0x1f, 0xbe, 0x34, + 0x8a, 0x0, 0x0, 0x3, 0x1d, 0xcd, 0x9b, 0x1, 0x0, 0x0, 0x1, 0x0, 0xd, 0xa1, 0x9f, 0xe8, 0x7b, 0x74, 0xa6, + 0x86, 0xb0, 0xfb, 0x89, 0x87, 0xa6, 0xd4, 0x0, 0x0, 0x5, 0x68, 0x4f, 0xc7, 0xad, 0xb6, 0x0, 0x0, 0x13, 0x45, + 0xf, 0x8f, 0x7e, 0xf8, 0xb9, 0xff, 0xa6, 0x58, 0xf5, 0xfd, 0xd1, 0xab, 0xe7, 0xdc, 0x85, 0xd2, 0xe2, 0xe, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x11, 0xaa, 0x66, 0xd4, 0xf2, 0x73, 0x4c, 0x5a, 0x94, 0xf, 0x67, - 0x29, 0xd0, 0x6, 0x80, 0x55, 0xa1, 0xba, 0x0, 0x29, 0xd6, 0x9e}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xeb, 0xb3, 0x8f, 0xa9, 0x6f, 0x8c, 0x7e, 0xf6, 0x91, 0x3e, + 0xe4, 0x7a, 0x2a, 0x4d, 0x2f, 0x99, 0xcc, 0x1f, 0x40, 0x25}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; + uint8_t topic_filter_s1_bytes[] = {0x2f, 0x74, 0x69, 0x2d, 0x43, 0x1a, 0x1f, 0xbe, 0x34, 0x8a}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1d, 0xcd, 0x9b}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa1, 0x9f, 0xe8, 0x7b, 0x74, 0xa6, 0x86, 0xb0, 0xfb, 0x89, 0x87, 0xa6, 0xd4}; + lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x68, 0x4f, 0xc7, 0xad, 0xb6}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x45, 0xf, 0x8f, 0x7e, 0xf8, 0xb9, 0xff, 0xa6, 0x58, 0xf5, + 0xfd, 0xd1, 0xab, 0xe7, 0xdc, 0x85, 0xd2, 0xe2, 0xe}; + lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, + LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0xc4, 0x75, 0xae, 0xa2, 0xc0, 0x4, 0x50, 0xc2, 0xe8, 0xdd, 0x1b, 0x77, 0x43}; + uint8_t bytesprops1[] = {0x2a, 0xac, 0xec, 0xc1, 0x11, 0x44, 0xd8, 0x70, + 0xcd, 0x1b, 0x71, 0x87, 0x84, 0xb8, 0xc2, 0xed}; + uint8_t bytesprops3[] = {0x3c, 0x60, 0x52, 0x25, 0x13, 0xa1, 0x12, 0x81, + 0x52, 0x8d, 0x66, 0xc1, 0x64, 0xca, 0x60, 0x6}; + uint8_t bytesprops2[] = {0xdf, 0x31, 0x3e, 0x33, 0x87, 0xcd}; + uint8_t bytesprops4[] = {0xfa, 0x5e, 0xf1, 0x6d, 0x95, 0x22, 0xf1, 0x56, + 0xa8, 0x2a, 0x66, 0x18, 0x43, 0xb7, 0xd4, 0xa5}; + uint8_t bytesprops5[] = {0x9c, 0x82, 0x5a, 0xae, 0x83, 0xfc, 0x67, 0x54, 0xf1, 0x16, 0x66, 0x9, + 0x9f, 0x6f, 0x80, 0x90, 0x1f, 0x2d, 0x72, 0xc1, 0xb8, 0xdf, 0x98, 0x5}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6660}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21591}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27385}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24724}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops2}, .v = {16, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops5}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25296, 1, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32171, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28036 [("Pv\136\129\234\188\197$",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1}),("\132\&1/\159\185\&7",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\161\248\233\231\243\148\238\193\NAK\GSx\193",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SYN\242\243\159\RS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("yS\"\212\211\222\&7\144*K\137\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x3c, 0x6d, 0x84, 0x0, 0x8, 0x50, 0x76, 0x88, 0x81, 0xea, 0xbc, 0xc5, 0x24, 0x1, 0x0, - 0x6, 0x84, 0x31, 0x2f, 0x9f, 0xb9, 0x37, 0x1, 0x0, 0xc, 0xa1, 0xf8, 0xe9, 0xe7, 0xf3, 0x94, - 0xee, 0xc1, 0x15, 0x1d, 0x78, 0xc1, 0x1, 0x0, 0x5, 0x16, 0xf2, 0xf3, 0x9f, 0x1e, 0x0, 0x0, - 0xc, 0x79, 0x53, 0x22, 0xd4, 0xd3, 0xde, 0x37, 0x90, 0x2a, 0x4b, 0x89, 0xe1, 0x2}; +// SubscribeRequest 29078 [("\201\248\\\248\245\254b\200k\161O\234i|\156\CAN\154+$\r\DLEu\179\"_|S}",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("#\234t\173\SOH%\NUL\251\216}\164\226\144\198\195\234\174\FSJ\136\GS\239\130\227\136\NAK",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("A\129\149O\210j]Y\247\205{\133\US\158\220U\204Gq\195\159\200kM\141\DLE\155\245\175",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\RST\234",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("h\USN\NUL\199Ix\174\RS\FS#\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0})] [PropTopicAlias 28371,PropAssignedClientIdentifier +// "qa\234\216V\206\v\254\SO*\191\249\&9",PropMaximumPacketSize 29054,PropReceiveMaximum 18298,PropMessageExpiryInterval +// 12385,PropSharedSubscriptionAvailable 182] +TEST(Subscribe5QCTest, Encode8) { + uint8_t pkt[] = {0x82, 0x96, 0x1, 0x71, 0x96, 0x22, 0x23, 0x6e, 0xd3, 0x12, 0x0, 0xd, 0x71, 0x61, 0xea, 0xd8, 0x56, + 0xce, 0xb, 0xfe, 0xe, 0x2a, 0xbf, 0xf9, 0x39, 0x27, 0x0, 0x0, 0x71, 0x7e, 0x21, 0x47, 0x7a, 0x2, + 0x0, 0x0, 0x30, 0x61, 0x2a, 0xb6, 0x0, 0x1c, 0xc9, 0xf8, 0x5c, 0xf8, 0xf5, 0xfe, 0x62, 0xc8, 0x6b, + 0xa1, 0x4f, 0xea, 0x69, 0x7c, 0x9c, 0x18, 0x9a, 0x2b, 0x24, 0xd, 0x10, 0x75, 0xb3, 0x22, 0x5f, 0x7c, + 0x53, 0x7d, 0x0, 0x0, 0x1a, 0x23, 0xea, 0x74, 0xad, 0x1, 0x25, 0x0, 0xfb, 0xd8, 0x7d, 0xa4, 0xe2, + 0x90, 0xc6, 0xc3, 0xea, 0xae, 0x1c, 0x4a, 0x88, 0x1d, 0xef, 0x82, 0xe3, 0x88, 0x15, 0x1, 0x0, 0x1d, + 0x41, 0x81, 0x95, 0x4f, 0xd2, 0x6a, 0x5d, 0x59, 0xf7, 0xcd, 0x7b, 0x85, 0x1f, 0x9e, 0xdc, 0x55, 0xcc, + 0x47, 0x71, 0xc3, 0x9f, 0xc8, 0x6b, 0x4d, 0x8d, 0x10, 0x9b, 0xf5, 0xaf, 0x0, 0x0, 0x3, 0x1e, 0x54, + 0xea, 0x2, 0x0, 0xc, 0x68, 0x1f, 0x4e, 0x0, 0xc7, 0x49, 0x78, 0xae, 0x1e, 0x1c, 0x23, 0xae, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x50, 0x76, 0x88, 0x81, 0xea, 0xbc, 0xc5, 0x24}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xc9, 0xf8, 0x5c, 0xf8, 0xf5, 0xfe, 0x62, 0xc8, 0x6b, 0xa1, + 0x4f, 0xea, 0x69, 0x7c, 0x9c, 0x18, 0x9a, 0x2b, 0x24, 0xd, + 0x10, 0x75, 0xb3, 0x22, 0x5f, 0x7c, 0x53, 0x7d}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x84, 0x31, 0x2f, 0x9f, 0xb9, 0x37}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x23, 0xea, 0x74, 0xad, 0x1, 0x25, 0x0, 0xfb, 0xd8, 0x7d, 0xa4, 0xe2, 0x90, + 0xc6, 0xc3, 0xea, 0xae, 0x1c, 0x4a, 0x88, 0x1d, 0xef, 0x82, 0xe3, 0x88, 0x15}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa1, 0xf8, 0xe9, 0xe7, 0xf3, 0x94, 0xee, 0xc1, 0x15, 0x1d, 0x78, 0xc1}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x41, 0x81, 0x95, 0x4f, 0xd2, 0x6a, 0x5d, 0x59, 0xf7, 0xcd, + 0x7b, 0x85, 0x1f, 0x9e, 0xdc, 0x55, 0xcc, 0x47, 0x71, 0xc3, + 0x9f, 0xc8, 0x6b, 0x4d, 0x8d, 0x10, 0x9b, 0xf5, 0xaf}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x16, 0xf2, 0xf3, 0x9f, 0x1e}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1e, 0x54, 0xea}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x79, 0x53, 0x22, 0xd4, 0xd3, 0xde, 0x37, 0x90, 0x2a, 0x4b, 0x89, 0xe1}; + uint8_t topic_filter_s4_bytes[] = {0x68, 0x1f, 0x4e, 0x0, 0xc7, 0x49, 0x78, 0xae, 0x1e, 0x1c, 0x23, 0xae}; lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x71, 0x61, 0xea, 0xd8, 0x56, 0xce, 0xb, 0xfe, 0xe, 0x2a, 0xbf, 0xf9, 0x39}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28371}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29054}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18298}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12385}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 182}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28036, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29078, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8713 [("\fd\209\239\ETB\191E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\183\248C",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("5",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ETBz+\DC4\ETB\244\SOH\203\149<\224g\247^\243\187\&3\RS<\162\178S]{{\143\226c_",SubOptions {_retainHandling +// SubscribeRequest 756 [("F\229~\a\235\170;\164\DC1\152",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\208fV\240",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("X\FS\146$\204\DLE\249b\249R\142P\254No\129",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\212\SUB\138(T\SYN-\252",SubOptions {_retainHandling // = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\238\DC4\212\224g.\142q`8P<\164\172\229\248",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\143Ib3\212\238\222\217k\223\\\SO\SOxm\220}s;^\162\226",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("\ETX\"\SUB\EM\ETB\133\248d\162\156\244\246",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\130\EM\NUL\129\234\143\201xg>\194\173tM\GS\148\201\167\221O\ENQ#ktu89\141",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("B\203O\166\SI\168J\185|\254\215>\177\156",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0x92, 0x1, 0x22, 0x9, 0x0, 0x7, 0xc, 0x64, 0xd1, 0xef, 0x17, 0xbf, 0x45, 0x2, 0x0, 0x3, - 0xb7, 0xf8, 0x43, 0x2, 0x0, 0x1, 0x35, 0x2, 0x0, 0x1d, 0x17, 0x7a, 0x2b, 0x14, 0x17, 0xf4, 0x1, - 0xcb, 0x95, 0x3c, 0xe0, 0x67, 0xf7, 0x5e, 0xf3, 0xbb, 0x33, 0x1e, 0x3c, 0xa2, 0xb2, 0x53, 0x5d, 0x7b, - 0x7b, 0x8f, 0xe2, 0x63, 0x5f, 0x1, 0x0, 0x10, 0xee, 0x14, 0xd4, 0xe0, 0x67, 0x2e, 0x8e, 0x71, 0x60, - 0x38, 0x50, 0x3c, 0xa4, 0xac, 0xe5, 0xf8, 0x1, 0x0, 0x16, 0x8f, 0x49, 0x62, 0x33, 0xd4, 0xee, 0xde, - 0xd9, 0x6b, 0xdf, 0x5c, 0xe, 0xe, 0x78, 0x6d, 0xdc, 0x7d, 0x73, 0x3b, 0x5e, 0xa2, 0xe2, 0x1, 0x0, - 0x1c, 0x82, 0x19, 0x0, 0x81, 0xea, 0x8f, 0xc9, 0x78, 0x67, 0x3e, 0xc2, 0xad, 0x74, 0x4d, 0x1d, 0x94, - 0xc9, 0xa7, 0xdd, 0x4f, 0x5, 0x23, 0x6b, 0x74, 0x75, 0x38, 0x39, 0x8d, 0x0, 0x0, 0xe, 0x42, 0xcb, - 0x4f, 0xa6, 0xf, 0xa8, 0x4a, 0xb9, 0x7c, 0xfe, 0xd7, 0x3e, 0xb1, 0x9c, 0x2}; +// QoS2}),("R\179\184\&9\148\238\184\166\149\"\208s&A\130\132s(\240\133\165\CAN\EMN",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\252\128\176 +// \139\212\226\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\154\137px\248W\245mK\174\255)oi\SOH\235\145\SO\t\EOT\190\144`%N\219\225\189\179",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("}\193\237\&6\129\180b\DEL\136\247\147W\ETX\229!\156\ACK\226fs\144+\DEL#'\202",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\203\203\184\175b\208n\245r\221R; +// \147\ACK%e9\161\NAKG:-fE\172\128",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2})] [PropRequestResponseInformation 126,PropRequestResponseInformation +// 251,PropMaximumPacketSize 31944,PropRequestProblemInformation 20,PropRetainAvailable 197,PropMessageExpiryInterval +// 3295,PropRequestResponseInformation 141,PropServerReference "eJ\129\167\DC3\184\174*N\228",PropSessionExpiryInterval +// 1167,PropSharedSubscriptionAvailable 150,PropPayloadFormatIndicator 142,PropMessageExpiryInterval +// 12479,PropSubscriptionIdentifierAvailable 88,PropMessageExpiryInterval 4531] +TEST(Subscribe5QCTest, Encode9) { + uint8_t pkt[] = { + 0x82, 0xfe, 0x1, 0x2, 0xf4, 0x36, 0x19, 0x7e, 0x19, 0xfb, 0x27, 0x0, 0x0, 0x7c, 0xc8, 0x17, 0x14, 0x25, 0xc5, + 0x2, 0x0, 0x0, 0xc, 0xdf, 0x19, 0x8d, 0x1c, 0x0, 0xa, 0x65, 0x4a, 0x81, 0xa7, 0x13, 0xb8, 0xae, 0x2a, 0x4e, + 0xe4, 0x11, 0x0, 0x0, 0x4, 0x8f, 0x2a, 0x96, 0x1, 0x8e, 0x2, 0x0, 0x0, 0x30, 0xbf, 0x29, 0x58, 0x2, 0x0, + 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, 0x65, 0x39, + 0xa1, 0x15, 0x47, 0x3a, 0x2d, 0x66, 0x45, 0xac, 0x80, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xc, 0x64, 0xd1, 0xef, 0x17, 0xbf, 0x45}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x46, 0xe5, 0x7e, 0x7, 0xeb, 0xaa, 0x3b, 0xa4, 0x11, 0x98}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb7, 0xf8, 0x43}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd0, 0x66, 0x56, 0xf0}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x35}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x58, 0x1c, 0x92, 0x24, 0xcc, 0x10, 0xf9, 0x62, + 0xf9, 0x52, 0x8e, 0x50, 0xfe, 0x4e, 0x6f, 0x81}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x17, 0x7a, 0x2b, 0x14, 0x17, 0xf4, 0x1, 0xcb, 0x95, 0x3c, - 0xe0, 0x67, 0xf7, 0x5e, 0xf3, 0xbb, 0x33, 0x1e, 0x3c, 0xa2, - 0xb2, 0x53, 0x5d, 0x7b, 0x7b, 0x8f, 0xe2, 0x63, 0x5f}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd4, 0x1a, 0x8a, 0x28, 0x54, 0x16, 0x2d, 0xfc}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xee, 0x14, 0xd4, 0xe0, 0x67, 0x2e, 0x8e, 0x71, - 0x60, 0x38, 0x50, 0x3c, 0xa4, 0xac, 0xe5, 0xf8}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x3, 0x22, 0x1a, 0x19, 0x17, 0x85, 0xf8, 0x64, 0xa2, 0x9c, 0xf4, 0xf6}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8f, 0x49, 0x62, 0x33, 0xd4, 0xee, 0xde, 0xd9, 0x6b, 0xdf, 0x5c, - 0xe, 0xe, 0x78, 0x6d, 0xdc, 0x7d, 0x73, 0x3b, 0x5e, 0xa2, 0xe2}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x52, 0xb3, 0xb8, 0x39, 0x94, 0xee, 0xb8, 0xa6, 0x95, 0x22, 0xd0, 0x73, + 0x26, 0x41, 0x82, 0x84, 0x73, 0x28, 0xf0, 0x85, 0xa5, 0x18, 0x19, 0x4e}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x82, 0x19, 0x0, 0x81, 0xea, 0x8f, 0xc9, 0x78, 0x67, 0x3e, - 0xc2, 0xad, 0x74, 0x4d, 0x1d, 0x94, 0xc9, 0xa7, 0xdd, 0x4f, - 0x5, 0x23, 0x6b, 0x74, 0x75, 0x38, 0x39, 0x8d}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xfc, 0x80, 0xb0, 0x20, 0x8b, 0xd4, 0xe2, 0xd0}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x42, 0xcb, 0x4f, 0xa6, 0xf, 0xa8, 0x4a, 0xb9, 0x7c, 0xfe, 0xd7, 0x3e, 0xb1, 0x9c}; - lwmqtt_string_t topic_filter_s7 = {14, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t topic_filter_s8_bytes[] = {0x9a, 0x89, 0x70, 0x78, 0xf8, 0x57, 0xf5, 0x6d, 0x4b, 0xae, + 0xff, 0x29, 0x6f, 0x69, 0x1, 0xeb, 0x91, 0xe, 0x9, 0x4, + 0xbe, 0x90, 0x60, 0x25, 0x4e, 0xdb, 0xe1, 0xbd, 0xb3}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x7d, 0xc1, 0xed, 0x36, 0x81, 0xb4, 0x62, 0x7f, 0x88, 0xf7, 0x93, 0x57, 0x3, + 0xe5, 0x21, 0x9c, 0x6, 0xe2, 0x66, 0x73, 0x90, 0x2b, 0x7f, 0x23, 0x27, 0xca}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xcb, 0xcb, 0xb8, 0xaf, 0x62, 0xd0, 0x6e, 0xf5, 0x72, + 0xdd, 0x52, 0x3b, 0x20, 0x93, 0x6, 0x25, 0x65, 0x39, + 0xa1, 0x15, 0x47, 0x3a, 0x2d, 0x66, 0x45, 0xac, 0x80}; + lwmqtt_string_t topic_filter_s10 = {27, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x65, 0x4a, 0x81, 0xa7, 0x13, 0xb8, 0xae, 0x2a, 0x4e, 0xe4}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31944}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3295}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1167}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12479}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4531}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8713, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 756, 11, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22186 [("\SOs\230\200\227!\208>\aj\134P\159@\b\245\135B\251\254\225\t\197\222\144",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("3\163Q\180\141+\131\234M\208\187:\NULW\165\227R1\198\131\168\176\185z\149w",SubOptions {_retainHandling = +// SubscribeRequest 16233 [("EBW",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("T\254+V h\152\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("3!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\DC3n;\202\230\SUB\132\139\138\185;\174&\231+wf\251U\f\EMGS\207\&0v\246",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\131\140\149\244p\253\129\DC2\DC1c#h\224qu\128\166\SICd\174\138\185",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\ESCp",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("9\209\165\252Ue\146\138\159\n%\SOW\252D\212",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x6d, 0x56, 0xaa, 0x0, 0x19, 0xe, 0x73, 0xe6, 0xc8, 0xe3, 0x21, 0xd0, 0x3e, 0x7, 0x6a, - 0x86, 0x50, 0x9f, 0x40, 0x8, 0xf5, 0x87, 0x42, 0xfb, 0xfe, 0xe1, 0x9, 0xc5, 0xde, 0x90, 0x1, - 0x0, 0x1a, 0x33, 0xa3, 0x51, 0xb4, 0x8d, 0x2b, 0x83, 0xea, 0x4d, 0xd0, 0xbb, 0x3a, 0x0, 0x57, - 0xa5, 0xe3, 0x52, 0x31, 0xc6, 0x83, 0xa8, 0xb0, 0xb9, 0x7a, 0x95, 0x77, 0x2, 0x0, 0x17, 0x83, - 0x8c, 0x95, 0xf4, 0x70, 0xfd, 0x81, 0x12, 0x11, 0x63, 0x23, 0x68, 0xe0, 0x71, 0x75, 0x80, 0xa6, - 0xf, 0x43, 0x64, 0xae, 0x8a, 0xb9, 0x2, 0x0, 0x2, 0x1b, 0x70, 0x1, 0x0, 0x10, 0x39, 0xd1, - 0xa5, 0xfc, 0x55, 0x65, 0x92, 0x8a, 0x9f, 0xa, 0x25, 0xe, 0x57, 0xfc, 0x44, 0xd4, 0x1}; +// QoS0}),("\v\207\&8\151z2J\146\DC2;\214\252\DC3\139\b\232\242\&5\190\231\229~^\172\238\SI:e\SUB",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("4\212\138\243\171\200\217@\238\210[E\146\241\SO\183\128",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropMaximumPacketSize 4150,PropUserProperty "" +// "\225\134\191cV\156M\176\SUB6b\217\143\240\240\&7",PropUserProperty "\204\149" +// "\ETX\148^\149s\237\ENQ\169j\211\ETBu\248\174\143\USDT\EM\203\131\DC1r\189\&4L{\SO",PropSubscriptionIdentifier +// 30,PropTopicAliasMaximum 20950,PropMaximumQoS 106] +TEST(Subscribe5QCTest, Encode10) { + uint8_t pkt[] = {0x82, 0xb3, 0x1, 0x3f, 0x69, 0x44, 0x27, 0x0, 0x0, 0x10, 0x36, 0x26, 0x0, 0x0, 0x0, 0x10, 0xe1, + 0x86, 0xbf, 0x63, 0x56, 0x9c, 0x4d, 0xb0, 0x1a, 0x36, 0x62, 0xd9, 0x8f, 0xf0, 0xf0, 0x37, 0x26, 0x0, + 0x2, 0xcc, 0x95, 0x0, 0x1c, 0x3, 0x94, 0x5e, 0x95, 0x73, 0xed, 0x5, 0xa9, 0x6a, 0xd3, 0x17, 0x75, + 0xf8, 0xae, 0x8f, 0x1f, 0x44, 0x54, 0x19, 0xcb, 0x83, 0x11, 0x72, 0xbd, 0x34, 0x4c, 0x7b, 0xe, 0xb, + 0x1e, 0x22, 0x51, 0xd6, 0x24, 0x6a, 0x0, 0x3, 0x45, 0x42, 0x57, 0x1, 0x0, 0x1, 0x6e, 0x0, 0x0, + 0x8, 0x54, 0xfe, 0x2b, 0x56, 0x20, 0x68, 0x98, 0xaa, 0x1, 0x0, 0x2, 0x33, 0x21, 0x0, 0x0, 0x1b, + 0x13, 0x6e, 0x3b, 0xca, 0xe6, 0x1a, 0x84, 0x8b, 0x8a, 0xb9, 0x3b, 0xae, 0x26, 0xe7, 0x2b, 0x77, 0x66, + 0xfb, 0x55, 0xc, 0x19, 0x47, 0x53, 0xcf, 0x30, 0x76, 0xf6, 0x0, 0x0, 0x1d, 0xb, 0xcf, 0x38, 0x97, + 0x7a, 0x32, 0x4a, 0x92, 0x12, 0x3b, 0xd6, 0xfc, 0x13, 0x8b, 0x8, 0xe8, 0xf2, 0x35, 0xbe, 0xe7, 0xe5, + 0x7e, 0x5e, 0xac, 0xee, 0xf, 0x3a, 0x65, 0x1a, 0x2, 0x0, 0x11, 0x34, 0xd4, 0x8a, 0xf3, 0xab, 0xc8, + 0xd9, 0x40, 0xee, 0xd2, 0x5b, 0x45, 0x92, 0xf1, 0xe, 0xb7, 0x80, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xe, 0x73, 0xe6, 0xc8, 0xe3, 0x21, 0xd0, 0x3e, 0x7, 0x6a, 0x86, 0x50, 0x9f, - 0x40, 0x8, 0xf5, 0x87, 0x42, 0xfb, 0xfe, 0xe1, 0x9, 0xc5, 0xde, 0x90}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x45, 0x42, 0x57}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x33, 0xa3, 0x51, 0xb4, 0x8d, 0x2b, 0x83, 0xea, 0x4d, 0xd0, 0xbb, 0x3a, 0x0, - 0x57, 0xa5, 0xe3, 0x52, 0x31, 0xc6, 0x83, 0xa8, 0xb0, 0xb9, 0x7a, 0x95, 0x77}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6e}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x83, 0x8c, 0x95, 0xf4, 0x70, 0xfd, 0x81, 0x12, 0x11, 0x63, 0x23, 0x68, - 0xe0, 0x71, 0x75, 0x80, 0xa6, 0xf, 0x43, 0x64, 0xae, 0x8a, 0xb9}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x54, 0xfe, 0x2b, 0x56, 0x20, 0x68, 0x98, 0xaa}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1b, 0x70}; + uint8_t topic_filter_s3_bytes[] = {0x33, 0x21}; lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x39, 0xd1, 0xa5, 0xfc, 0x55, 0x65, 0x92, 0x8a, - 0x9f, 0xa, 0x25, 0xe, 0x57, 0xfc, 0x44, 0xd4}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x13, 0x6e, 0x3b, 0xca, 0xe6, 0x1a, 0x84, 0x8b, 0x8a, 0xb9, 0x3b, 0xae, 0x26, 0xe7, + 0x2b, 0x77, 0x66, 0xfb, 0x55, 0xc, 0x19, 0x47, 0x53, 0xcf, 0x30, 0x76, 0xf6}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; + uint8_t topic_filter_s5_bytes[] = {0xb, 0xcf, 0x38, 0x97, 0x7a, 0x32, 0x4a, 0x92, 0x12, 0x3b, + 0xd6, 0xfc, 0x13, 0x8b, 0x8, 0xe8, 0xf2, 0x35, 0xbe, 0xe7, + 0xe5, 0x7e, 0x5e, 0xac, 0xee, 0xf, 0x3a, 0x65, 0x1a}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x34, 0xd4, 0x8a, 0xf3, 0xab, 0xc8, 0xd9, 0x40, 0xee, + 0xd2, 0x5b, 0x45, 0x92, 0xf1, 0xe, 0xb7, 0x80}; + lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t bytesprops1[] = {0xe1, 0x86, 0xbf, 0x63, 0x56, 0x9c, 0x4d, 0xb0, + 0x1a, 0x36, 0x62, 0xd9, 0x8f, 0xf0, 0xf0, 0x37}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops3[] = {0x3, 0x94, 0x5e, 0x95, 0x73, 0xed, 0x5, 0xa9, 0x6a, 0xd3, 0x17, 0x75, 0xf8, 0xae, + 0x8f, 0x1f, 0x44, 0x54, 0x19, 0xcb, 0x83, 0x11, 0x72, 0xbd, 0x34, 0x4c, 0x7b, 0xe}; + uint8_t bytesprops2[] = {0xcc, 0x95}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4150}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops2}, .v = {28, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20950}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22186, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16233, 7, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 16934 [("\ENQ\US\231\182\242\224Rp\134\v\227Heh\CAN\168\243\231\181k7&{\n",SubOptions +// SubscribeRequest 27988 [("\215:8'\163*\137K\190_\182*\204\144\ETX\186\242\234\173\138,f\158\190",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("W\201\226%\229\246\253\183\\\FS\242-\246I\DC4\DLE\188y\234\&5\240\DC1\189u\152\SO\240_",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\196\155\175",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("s\255c&\US\DLE@u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("I4\236\129I\\c\187\205\211J",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("6\246\129_\248\224\199\160MK\168\141hr\171",SubOptions {_retainHandling = SendOnSubscribe, +// QoS0}),("P7\f\231T5\214\vP\216h\NUL\DC3\b\224\SI",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\132~\184",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\251\&0:\197\176N\128\&0\194\204\246\NAK\236i}|\154\223c\f\220",SubOptions {_retainHandling = +// QoS0}),("\235\ESC\184\223^M\136\133\196\&6\247\CAN/M\231\201c\165j\230",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("Or\209\133\140\155\171\243\164J\229\235\242\246\132k}\ENQ\138\188\215\185\150%xv)P\ACK",SubOptions +// QoS1}),("1\153n\DC1\168\129\189\149\&7+F>\DC4d\249\172\130\DC4\ACK_\177*\237C\228\f\DC4\a<]",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\169\247\243Q\241\192)\133%\156\243\251\169\\\239\187E\234\163\194\141\&2\246*v\192\175\ETX\201",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0xc8, 0x1, 0x42, 0x26, 0x0, 0x18, 0x5, 0x1f, 0xe7, 0xb6, 0xf2, 0xe0, 0x52, 0x70, 0x86, 0xb, - 0xe3, 0x48, 0x65, 0x68, 0x18, 0xa8, 0xf3, 0xe7, 0xb5, 0x6b, 0x37, 0x26, 0x7b, 0xa, 0x0, 0x0, 0x1c, - 0x57, 0xc9, 0xe2, 0x25, 0xe5, 0xf6, 0xfd, 0xb7, 0x5c, 0x1c, 0xf2, 0x2d, 0xf6, 0x49, 0x14, 0x10, 0xbc, - 0x79, 0xea, 0x35, 0xf0, 0x11, 0xbd, 0x75, 0x98, 0xe, 0xf0, 0x5f, 0x1, 0x0, 0x3, 0xc4, 0x9b, 0xaf, - 0x2, 0x0, 0x0, 0x2, 0x0, 0x8, 0x73, 0xff, 0x63, 0x26, 0x1f, 0x10, 0x40, 0x75, 0x0, 0x0, 0xb, - 0x49, 0x34, 0xec, 0x81, 0x49, 0x5c, 0x63, 0xbb, 0xcd, 0xd3, 0x4a, 0x1, 0x0, 0xf, 0x36, 0xf6, 0x81, - 0x5f, 0xf8, 0xe0, 0xc7, 0xa0, 0x4d, 0x4b, 0xa8, 0x8d, 0x68, 0x72, 0xab, 0x0, 0x0, 0x15, 0xfb, 0x30, - 0x3a, 0xc5, 0xb0, 0x4e, 0x80, 0x30, 0xc2, 0xcc, 0xf6, 0x15, 0xec, 0x69, 0x7d, 0x7c, 0x9a, 0xdf, 0x63, - 0xc, 0xdc, 0x0, 0x0, 0x1d, 0x4f, 0x72, 0xd1, 0x85, 0x8c, 0x9b, 0xab, 0xf3, 0xa4, 0x4a, 0xe5, 0xeb, - 0xf2, 0xf6, 0x84, 0x6b, 0x7d, 0x5, 0x8a, 0xbc, 0xd7, 0xb9, 0x96, 0x25, 0x78, 0x76, 0x29, 0x50, 0x6, - 0x0, 0x0, 0x1d, 0xa9, 0xf7, 0xf3, 0x51, 0xf1, 0xc0, 0x29, 0x85, 0x25, 0x9c, 0xf3, 0xfb, 0xa9, 0x5c, - 0xef, 0xbb, 0x45, 0xea, 0xa3, 0xc2, 0x8d, 0x32, 0xf6, 0x2a, 0x76, 0xc0, 0xaf, 0x3, 0xc9, 0x0}; +// QoS1}),("\238E\134\179f\SOH\209\229\239w\165\242\181\DC4\182\139\180\ETX\178!1",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("k\222\133\254$\SYN\235\a\154\140U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\254",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0})] [PropResponseTopic +// "d_\229#\234X\131\143.\233Vt\204\224\203\133",PropResponseTopic +// "\156L`\147\168\DEL\SYN\215\EOT?\193E\244\150U\255",PropReceiveMaximum 6381,PropWillDelayInterval +// 26365,PropWillDelayInterval 17069,PropServerKeepAlive 21809,PropAssignedClientIdentifier +// "J\156\247\254\ENQJ^\DC4=\f\147\232\177\128\232K\170y",PropContentType "E\144'\141\v\241~n\254\232\DLE +// \224A\170\176^\173P\133\215\220\131\244@",PropRequestProblemInformation 253,PropTopicAlias 6832,PropServerReference +// "\251m\246\246\\\215\DLE\187\238\DC3\145\232\167B|\194\207;\148\CAN\181\231\213(a:W\167\135s",PropTopicAliasMaximum +// 12908,PropResponseTopic "{\STX\231\171v\140{\b\143",PropResponseInformation +// "\\\219T\152bgR\150\139\149\255\255",PropWillDelayInterval 10586,PropMaximumQoS 183,PropServerReference +// "\217\&2\246\&5\253V\189\252\181\143\138^\DLE\150tgA\\8A",PropMaximumQoS 46,PropSubscriptionIdentifier +// 9,PropAuthenticationMethod "\204[E^\242\226\SYN!M+\216~\139O\166' y",PropReceiveMaximum +// 3271,PropMessageExpiryInterval 24796,PropSharedSubscriptionAvailable 167,PropRetainAvailable 237,PropReceiveMaximum +// 32101,PropRetainAvailable 130,PropRequestProblemInformation 100,PropReceiveMaximum 20262] +TEST(Subscribe5QCTest, Encode11) { + uint8_t pkt[] = { + 0x82, 0x92, 0x3, 0x6d, 0x54, 0xf8, 0x1, 0x8, 0x0, 0x10, 0x64, 0x5f, 0xe5, 0x23, 0xea, 0x58, 0x83, 0x8f, 0x2e, + 0xe9, 0x56, 0x74, 0xcc, 0xe0, 0xcb, 0x85, 0x8, 0x0, 0x10, 0x9c, 0x4c, 0x60, 0x93, 0xa8, 0x7f, 0x16, 0xd7, 0x4, + 0x3f, 0xc1, 0x45, 0xf4, 0x96, 0x55, 0xff, 0x21, 0x18, 0xed, 0x18, 0x0, 0x0, 0x66, 0xfd, 0x18, 0x0, 0x0, 0x42, + 0xad, 0x13, 0x55, 0x31, 0x12, 0x0, 0x12, 0x4a, 0x9c, 0xf7, 0xfe, 0x5, 0x4a, 0x5e, 0x14, 0x3d, 0xc, 0x93, 0xe8, + 0xb1, 0x80, 0xe8, 0x4b, 0xaa, 0x79, 0x3, 0x0, 0x19, 0x45, 0x90, 0x27, 0x8d, 0xb, 0xf1, 0x7e, 0x6e, 0xfe, 0xe8, + 0x10, 0x20, 0xe0, 0x41, 0xaa, 0xb0, 0x5e, 0xad, 0x50, 0x85, 0xd7, 0xdc, 0x83, 0xf4, 0x40, 0x17, 0xfd, 0x23, 0x1a, + 0xb0, 0x1c, 0x0, 0x1e, 0xfb, 0x6d, 0xf6, 0xf6, 0x5c, 0xd7, 0x10, 0xbb, 0xee, 0x13, 0x91, 0xe8, 0xa7, 0x42, 0x7c, + 0xc2, 0xcf, 0x3b, 0x94, 0x18, 0xb5, 0xe7, 0xd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a, 0xe6, 0x1, 0x0, 0x1e, 0x31, 0x99, 0x6e, 0x11, 0xa8, 0x81, 0xbd, 0x95, 0x37, 0x2b, + 0x46, 0x3e, 0x14, 0x64, 0xf9, 0xac, 0x82, 0x14, 0x6, 0x5f, 0xb1, 0x2a, 0xed, 0x43, 0xe4, 0xc, 0x14, 0x7, 0x3c, + 0x5d, 0x1, 0x0, 0x15, 0xee, 0x45, 0x86, 0xb3, 0x66, 0x1, 0xd1, 0xe5, 0xef, 0x77, 0xa5, 0xf2, 0xb5, 0x14, 0xb6, + 0x8b, 0xb4, 0x3, 0xb2, 0x21, 0x31, 0x1, 0x0, 0xb, 0x6b, 0xde, 0x85, 0xfe, 0x24, 0x16, 0xeb, 0x7, 0x9a, 0x8c, + 0x55, 0x1, 0x0, 0x1, 0xfe, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x5, 0x1f, 0xe7, 0xb6, 0xf2, 0xe0, 0x52, 0x70, 0x86, 0xb, 0xe3, 0x48, - 0x65, 0x68, 0x18, 0xa8, 0xf3, 0xe7, 0xb5, 0x6b, 0x37, 0x26, 0x7b, 0xa}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xd7, 0x3a, 0x38, 0x27, 0xa3, 0x2a, 0x89, 0x4b, 0xbe, 0x5f, 0xb6, 0x2a, + 0xcc, 0x90, 0x3, 0xba, 0xf2, 0xea, 0xad, 0x8a, 0x2c, 0x66, 0x9e, 0xbe}; lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x57, 0xc9, 0xe2, 0x25, 0xe5, 0xf6, 0xfd, 0xb7, 0x5c, 0x1c, - 0xf2, 0x2d, 0xf6, 0x49, 0x14, 0x10, 0xbc, 0x79, 0xea, 0x35, - 0xf0, 0x11, 0xbd, 0x75, 0x98, 0xe, 0xf0, 0x5f}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x50, 0x37, 0xc, 0xe7, 0x54, 0x35, 0xd6, 0xb, + 0x50, 0xd8, 0x68, 0x0, 0x13, 0x8, 0xe0, 0xf}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc4, 0x9b, 0xaf}; + uint8_t topic_filter_s2_bytes[] = {0x84, 0x7e, 0xb8}; lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xeb, 0x1b, 0xb8, 0xdf, 0x5e, 0x4d, 0x88, 0x85, 0xc4, 0x36, + 0xf7, 0x18, 0x2f, 0x4d, 0xe7, 0xc9, 0x63, 0xa5, 0x6a, 0xe6}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x73, 0xff, 0x63, 0x26, 0x1f, 0x10, 0x40, 0x75}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x99, 0x6e, 0x11, 0xa8, 0x81, 0xbd, 0x95, 0x37, 0x2b, + 0x46, 0x3e, 0x14, 0x64, 0xf9, 0xac, 0x82, 0x14, 0x6, 0x5f, + 0xb1, 0x2a, 0xed, 0x43, 0xe4, 0xc, 0x14, 0x7, 0x3c, 0x5d}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x49, 0x34, 0xec, 0x81, 0x49, 0x5c, 0x63, 0xbb, 0xcd, 0xd3, 0x4a}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xee, 0x45, 0x86, 0xb3, 0x66, 0x1, 0xd1, 0xe5, 0xef, 0x77, 0xa5, + 0xf2, 0xb5, 0x14, 0xb6, 0x8b, 0xb4, 0x3, 0xb2, 0x21, 0x31}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x36, 0xf6, 0x81, 0x5f, 0xf8, 0xe0, 0xc7, 0xa0, - 0x4d, 0x4b, 0xa8, 0x8d, 0x68, 0x72, 0xab}; - lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x6b, 0xde, 0x85, 0xfe, 0x24, 0x16, 0xeb, 0x7, 0x9a, 0x8c, 0x55}; + lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xfb, 0x30, 0x3a, 0xc5, 0xb0, 0x4e, 0x80, 0x30, 0xc2, 0xcc, 0xf6, - 0x15, 0xec, 0x69, 0x7d, 0x7c, 0x9a, 0xdf, 0x63, 0xc, 0xdc}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xfe}; + lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x4f, 0x72, 0xd1, 0x85, 0x8c, 0x9b, 0xab, 0xf3, 0xa4, 0x4a, - 0xe5, 0xeb, 0xf2, 0xf6, 0x84, 0x6b, 0x7d, 0x5, 0x8a, 0xbc, - 0xd7, 0xb9, 0x96, 0x25, 0x78, 0x76, 0x29, 0x50, 0x6}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa9, 0xf7, 0xf3, 0x51, 0xf1, 0xc0, 0x29, 0x85, 0x25, 0x9c, - 0xf3, 0xfb, 0xa9, 0x5c, 0xef, 0xbb, 0x45, 0xea, 0xa3, 0xc2, - 0x8d, 0x32, 0xf6, 0x2a, 0x76, 0xc0, 0xaf, 0x3, 0xc9}; - lwmqtt_string_t topic_filter_s9 = {29, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, - LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; + uint8_t bytesprops0[] = {0x64, 0x5f, 0xe5, 0x23, 0xea, 0x58, 0x83, 0x8f, + 0x2e, 0xe9, 0x56, 0x74, 0xcc, 0xe0, 0xcb, 0x85}; + uint8_t bytesprops1[] = {0x9c, 0x4c, 0x60, 0x93, 0xa8, 0x7f, 0x16, 0xd7, + 0x4, 0x3f, 0xc1, 0x45, 0xf4, 0x96, 0x55, 0xff}; + uint8_t bytesprops2[] = {0x4a, 0x9c, 0xf7, 0xfe, 0x5, 0x4a, 0x5e, 0x14, 0x3d, + 0xc, 0x93, 0xe8, 0xb1, 0x80, 0xe8, 0x4b, 0xaa, 0x79}; + uint8_t bytesprops3[] = {0x45, 0x90, 0x27, 0x8d, 0xb, 0xf1, 0x7e, 0x6e, 0xfe, 0xe8, 0x10, 0x20, 0xe0, + 0x41, 0xaa, 0xb0, 0x5e, 0xad, 0x50, 0x85, 0xd7, 0xdc, 0x83, 0xf4, 0x40}; + uint8_t bytesprops4[] = {0xfb, 0x6d, 0xf6, 0xf6, 0x5c, 0xd7, 0x10, 0xbb, 0xee, 0x13, 0x91, 0xe8, 0xa7, 0x42, 0x7c, + 0xc2, 0xcf, 0x3b, 0x94, 0x18, 0xb5, 0xe7, 0xd5, 0x28, 0x61, 0x3a, 0x57, 0xa7, 0x87, 0x73}; + uint8_t bytesprops5[] = {0x7b, 0x2, 0xe7, 0xab, 0x76, 0x8c, 0x7b, 0x8, 0x8f}; + uint8_t bytesprops6[] = {0x5c, 0xdb, 0x54, 0x98, 0x62, 0x67, 0x52, 0x96, 0x8b, 0x95, 0xff, 0xff}; + uint8_t bytesprops7[] = {0xd9, 0x32, 0xf6, 0x35, 0xfd, 0x56, 0xbd, 0xfc, 0xb5, 0x8f, + 0x8a, 0x5e, 0x10, 0x96, 0x74, 0x67, 0x41, 0x5c, 0x38, 0x41}; + uint8_t bytesprops8[] = {0xcc, 0x5b, 0x45, 0x5e, 0xf2, 0xe2, 0x16, 0x21, 0x4d, + 0x2b, 0xd8, 0x7e, 0x8b, 0x4f, 0xa6, 0x27, 0x20, 0x79}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6381}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26365}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17069}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21809}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6832}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12908}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10586}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3271}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24796}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32101}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20262}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16934, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27988, 8, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19450 [("-\157He_V\165gmY\135\DC1\242\b\132\141\234\205\247",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("X+\208\242 -// 0\199d9\203\NAK)\182AKX:\187*\247|\177\229",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("-\200\196\v\SON\152\156\131\233\ESC\181(\174\ESC_\182(",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\245",SubOptions +// SubscribeRequest 19880 [("\163\224\DC4H\243\234r\170\191\212<\172Q\159\207\205\131=\189\132W",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\"\DLE\152\151\134\RS\b7\133\240",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),("\155\200\218O\139Q\137\183r>\FSZ()\163@C\240\153\197\175\164w\237\244\214",SubOptions {_retainHandling = +// QoS0}),("\DLE\190\ETXgAE\133z \251",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("4 ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\229\210&\235\147\255",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\GS{\223`IldKX@9",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(":%\214!\232hqh\239\137?\SYN\253\231\130\239Ki",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\211\242#\201}dL\240\189\150\251\185\231~?\227\158\152z\251\SUB\DELS\174E",SubOptions {_retainHandling = +// QoS0}),("\198W8*B\175+,@\234j\200\209\167\187",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("\203#\222\STX\217\221[6\138\196[\189\236\190\187Q\225\143+]\183U\141lq\242\SI\253",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropTopicAlias +// 30972,PropReceiveMaximum 9117,PropServerKeepAlive 29875,PropMessageExpiryInterval +// 17362,PropWildcardSubscriptionAvailable 2,PropSubscriptionIdentifierAvailable 204,PropSharedSubscriptionAvailable +// 168,PropMaximumQoS 53,PropTopicAlias 30987,PropSharedSubscriptionAvailable 55,PropServerReference +// "\204q\192\US\138d\224\139j\162\NUL\240\b\EOT\227\\KP\157\148\198\135x\166\193]\ETB\198",PropWildcardSubscriptionAvailable +// 254,PropPayloadFormatIndicator 244,PropSessionExpiryInterval 21471] +TEST(Subscribe5QCTest, Encode12) { + uint8_t pkt[] = {0x82, 0xb8, 0x1, 0x4d, 0xa8, 0x43, 0x23, 0x78, 0xfc, 0x21, 0x23, 0x9d, 0x13, 0x74, 0xb3, 0x2, 0x0, + 0x0, 0x43, 0xd2, 0x28, 0x2, 0x29, 0xcc, 0x2a, 0xa8, 0x24, 0x35, 0x23, 0x79, 0xb, 0x2a, 0x37, 0x1c, + 0x0, 0x1c, 0xcc, 0x71, 0xc0, 0x1f, 0x8a, 0x64, 0xe0, 0x8b, 0x6a, 0xa2, 0x0, 0xf0, 0x8, 0x4, 0xe3, + 0x5c, 0x4b, 0x50, 0x9d, 0x94, 0xc6, 0x87, 0x78, 0xa6, 0xc1, 0x5d, 0x17, 0xc6, 0x28, 0xfe, 0x1, 0xf4, + 0x11, 0x0, 0x0, 0x53, 0xdf, 0x0, 0x15, 0xa3, 0xe0, 0x14, 0x48, 0xf3, 0xea, 0x72, 0xaa, 0xbf, 0xd4, + 0x3c, 0xac, 0x51, 0x9f, 0xcf, 0xcd, 0x83, 0x3d, 0xbd, 0x84, 0x57, 0x0, 0x0, 0xa, 0x10, 0xbe, 0x3, + 0x67, 0x41, 0x45, 0x85, 0x7a, 0x20, 0xfb, 0x0, 0x0, 0x2, 0x34, 0x20, 0x2, 0x0, 0x6, 0xe5, 0xd2, + 0x26, 0xeb, 0x93, 0xff, 0x0, 0x0, 0xb, 0x1d, 0x7b, 0xdf, 0x60, 0x49, 0x6c, 0x64, 0x4b, 0x58, 0x40, + 0x39, 0x0, 0x0, 0xf, 0xc6, 0x57, 0x38, 0x2a, 0x42, 0xaf, 0x2b, 0x2c, 0x40, 0xea, 0x6a, 0xc8, 0xd1, + 0xa7, 0xbb, 0x2, 0x0, 0x1c, 0xcb, 0x23, 0xde, 0x2, 0xd9, 0xdd, 0x5b, 0x36, 0x8a, 0xc4, 0x5b, 0xbd, + 0xec, 0xbe, 0xbb, 0x51, 0xe1, 0x8f, 0x2b, 0x5d, 0xb7, 0x55, 0x8d, 0x6c, 0x71, 0xf2, 0xf, 0xfd, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xa3, 0xe0, 0x14, 0x48, 0xf3, 0xea, 0x72, 0xaa, 0xbf, 0xd4, 0x3c, + 0xac, 0x51, 0x9f, 0xcf, 0xcd, 0x83, 0x3d, 0xbd, 0x84, 0x57}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x10, 0xbe, 0x3, 0x67, 0x41, 0x45, 0x85, 0x7a, 0x20, 0xfb}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x34, 0x20}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe5, 0xd2, 0x26, 0xeb, 0x93, 0xff}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x1d, 0x7b, 0xdf, 0x60, 0x49, 0x6c, 0x64, 0x4b, 0x58, 0x40, 0x39}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xc6, 0x57, 0x38, 0x2a, 0x42, 0xaf, 0x2b, 0x2c, + 0x40, 0xea, 0x6a, 0xc8, 0xd1, 0xa7, 0xbb}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xcb, 0x23, 0xde, 0x2, 0xd9, 0xdd, 0x5b, 0x36, 0x8a, 0xc4, + 0x5b, 0xbd, 0xec, 0xbe, 0xbb, 0x51, 0xe1, 0x8f, 0x2b, 0x5d, + 0xb7, 0x55, 0x8d, 0x6c, 0x71, 0xf2, 0xf, 0xfd}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xcc, 0x71, 0xc0, 0x1f, 0x8a, 0x64, 0xe0, 0x8b, 0x6a, 0xa2, 0x0, 0xf0, 0x8, 0x4, + 0xe3, 0x5c, 0x4b, 0x50, 0x9d, 0x94, 0xc6, 0x87, 0x78, 0xa6, 0xc1, 0x5d, 0x17, 0xc6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30972}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9117}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29875}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17362}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30987}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21471}}, + }; + + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19880, 7, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 22493 [("\227\138\DC4\248mr\146&d\209\219",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropSharedSubscriptionAvailable +// 208,PropResponseInformation "~(V\245\SOH\236\143",PropWildcardSubscriptionAvailable 201,PropUserProperty +// "\156\177I\194E\195\169\232V\196\166\&5\130\247#]\136\169u\ESC\DEL\184\166z\128[N\186" +// "\EM\144:p\228\231\FS\251\253~h\200",PropRequestProblemInformation 81,PropWildcardSubscriptionAvailable +// 59,PropRequestResponseInformation 245,PropServerReference +// "\170_\134\181idH\138\173\DC1\172\EMd\DC1i\130\189",PropRequestProblemInformation 89,PropRequestProblemInformation +// 41,PropServerKeepAlive 7095,PropResponseTopic +// "\165\137\t\r\225(G\179\185\EOT\248\DC1\243\169N\179\138\229",PropTopicAlias +// 13371,PropSubscriptionIdentifierAvailable 164,PropSharedSubscriptionAvailable 22,PropMessageExpiryInterval +// 4425,PropRequestResponseInformation 171,PropAuthenticationMethod +// "X\bf\198\173\241Q-\169h\140\220\n\131p\143\156\DLEx\215C",PropWillDelayInterval 31817,PropSessionExpiryInterval +// 18161,PropMessageExpiryInterval 28296] +TEST(Subscribe5QCTest, Encode13) { + uint8_t pkt[] = {0x82, 0xb8, 0x1, 0x57, 0xdd, 0xa6, 0x1, 0x2a, 0xd0, 0x1a, 0x0, 0x7, 0x7e, 0x28, 0x56, 0xf5, 0x1, + 0xec, 0x8f, 0x28, 0xc9, 0x26, 0x0, 0x1c, 0x9c, 0xb1, 0x49, 0xc2, 0x45, 0xc3, 0xa9, 0xe8, 0x56, 0xc4, + 0xa6, 0x35, 0x82, 0xf7, 0x23, 0x5d, 0x88, 0xa9, 0x75, 0x1b, 0x7f, 0xb8, 0xa6, 0x7a, 0x80, 0x5b, 0x4e, + 0xba, 0x0, 0xc, 0x19, 0x90, 0x3a, 0x70, 0xe4, 0xe7, 0x1c, 0xfb, 0xfd, 0x7e, 0x68, 0xc8, 0x17, 0x51, + 0x28, 0x3b, 0x19, 0xf5, 0x1c, 0x0, 0x11, 0xaa, 0x5f, 0x86, 0xb5, 0x69, 0x64, 0x48, 0x8a, 0xad, 0x11, + 0xac, 0x19, 0x64, 0x11, 0x69, 0x82, 0xbd, 0x17, 0x59, 0x17, 0x29, 0x13, 0x1b, 0xb7, 0x8, 0x0, 0x12, + 0xa5, 0x89, 0x9, 0xd, 0xe1, 0x28, 0x47, 0xb3, 0xb9, 0x4, 0xf8, 0x11, 0xf3, 0xa9, 0x4e, 0xb3, 0x8a, + 0xe5, 0x23, 0x34, 0x3b, 0x29, 0xa4, 0x2a, 0x16, 0x2, 0x0, 0x0, 0x11, 0x49, 0x19, 0xab, 0x15, 0x0, + 0x15, 0x58, 0x8, 0x66, 0xc6, 0xad, 0xf1, 0x51, 0x2d, 0xa9, 0x68, 0x8c, 0xdc, 0xa, 0x83, 0x70, 0x8f, + 0x9c, 0x10, 0x78, 0xd7, 0x43, 0x18, 0x0, 0x0, 0x7c, 0x49, 0x11, 0x0, 0x0, 0x46, 0xf1, 0x2, 0x0, + 0x0, 0x6e, 0x88, 0x0, 0xb, 0xe3, 0x8a, 0x14, 0xf8, 0x6d, 0x72, 0x92, 0x26, 0x64, 0xd1, 0xdb, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xe3, 0x8a, 0x14, 0xf8, 0x6d, 0x72, 0x92, 0x26, 0x64, 0xd1, 0xdb}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x7e, 0x28, 0x56, 0xf5, 0x1, 0xec, 0x8f}; + uint8_t bytesprops2[] = {0x19, 0x90, 0x3a, 0x70, 0xe4, 0xe7, 0x1c, 0xfb, 0xfd, 0x7e, 0x68, 0xc8}; + uint8_t bytesprops1[] = {0x9c, 0xb1, 0x49, 0xc2, 0x45, 0xc3, 0xa9, 0xe8, 0x56, 0xc4, 0xa6, 0x35, 0x82, 0xf7, + 0x23, 0x5d, 0x88, 0xa9, 0x75, 0x1b, 0x7f, 0xb8, 0xa6, 0x7a, 0x80, 0x5b, 0x4e, 0xba}; + uint8_t bytesprops3[] = {0xaa, 0x5f, 0x86, 0xb5, 0x69, 0x64, 0x48, 0x8a, 0xad, + 0x11, 0xac, 0x19, 0x64, 0x11, 0x69, 0x82, 0xbd}; + uint8_t bytesprops4[] = {0xa5, 0x89, 0x9, 0xd, 0xe1, 0x28, 0x47, 0xb3, 0xb9, + 0x4, 0xf8, 0x11, 0xf3, 0xa9, 0x4e, 0xb3, 0x8a, 0xe5}; + uint8_t bytesprops5[] = {0x58, 0x8, 0x66, 0xc6, 0xad, 0xf1, 0x51, 0x2d, 0xa9, 0x68, 0x8c, + 0xdc, 0xa, 0x83, 0x70, 0x8f, 0x9c, 0x10, 0x78, 0xd7, 0x43}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops1}, .v = {12, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7095}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13371}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4425}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31817}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18161}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28296}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22493, 1, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 32664 [("\244\185\249\145\SUB\GS\167&\200\201\187E=\184\234\232",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("i\217U\176\198\245\226",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("[gE\131-\185\148\217\a\169\&5(\185\236?\187\171\208\130\242\SIdq\SO\USND",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(" +// Y\246\139\\xj\202)\182v\166\bFEb\245H\130",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\160\&3\132\234x\252\200\NUL]\134",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("%\GS>\174RN3\188KZ\169\ETB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x4b, 0xfa, 0x0, 0x13, 0x2d, 0x9d, 0x48, 0x65, 0x5f, 0x56, 0xa5, 0x67, 0x6d, 0x59, - 0x87, 0x11, 0xf2, 0x8, 0x84, 0x8d, 0xea, 0xcd, 0xf7, 0x0, 0x0, 0x17, 0x58, 0x2b, 0xd0, 0xf2, 0x20, - 0x30, 0xc7, 0x64, 0x39, 0xcb, 0x15, 0x29, 0xb6, 0x41, 0x4b, 0x58, 0x3a, 0xbb, 0x2a, 0xf7, 0x7c, 0xb1, - 0xe5, 0x2, 0x0, 0x12, 0x2d, 0xc8, 0xc4, 0xb, 0xe, 0x4e, 0x98, 0x9c, 0x83, 0xe9, 0x1b, 0xb5, 0x28, - 0xae, 0x1b, 0x5f, 0xb6, 0x28, 0x1, 0x0, 0x1, 0xf5, 0x1, 0x0, 0xa, 0x22, 0x10, 0x98, 0x97, 0x86, - 0x1e, 0x8, 0x37, 0x85, 0xf0, 0x0, 0x0, 0x1a, 0x9b, 0xc8, 0xda, 0x4f, 0x8b, 0x51, 0x89, 0xb7, 0x72, - 0x3e, 0x1c, 0x5a, 0x28, 0x29, 0xa3, 0x40, 0x43, 0xf0, 0x99, 0xc5, 0xaf, 0xa4, 0x77, 0xed, 0xf4, 0xd6, - 0x2, 0x0, 0x12, 0x3a, 0x25, 0xd6, 0x21, 0xe8, 0x68, 0x71, 0x68, 0xef, 0x89, 0x3f, 0x16, 0xfd, 0xe7, - 0x82, 0xef, 0x4b, 0x69, 0x1, 0x0, 0x19, 0xd3, 0xf2, 0x23, 0xc9, 0x7d, 0x64, 0x4c, 0xf0, 0xbd, 0x96, - 0xfb, 0xb9, 0xe7, 0x7e, 0x3f, 0xe3, 0x9e, 0x98, 0x7a, 0xfb, 0x1a, 0x7f, 0x53, 0xae, 0x45, 0x1, 0x0, - 0xc, 0x25, 0x1d, 0x3e, 0xae, 0x52, 0x4e, 0x33, 0xbc, 0x4b, 0x5a, 0xa9, 0x17, 0x2}; +// QoS0}),("\211\139\255*\EOT\232\243\147D\252\SI\215\&5F\SIF[\209\SUBw\195I\130",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAuthenticationData +// "G\DC3\137\129k\175\DC3\204",PropAuthenticationMethod ""] +TEST(Subscribe5QCTest, Encode14) { + uint8_t pkt[] = {0x82, 0x89, 0x1, 0x7f, 0x98, 0xe, 0x16, 0x0, 0x8, 0x47, 0x13, 0x89, 0x81, 0x6b, 0xaf, 0x13, + 0xcc, 0x15, 0x0, 0x0, 0x0, 0x10, 0xf4, 0xb9, 0xf9, 0x91, 0x1a, 0x1d, 0xa7, 0x26, 0xc8, 0xc9, + 0xbb, 0x45, 0x3d, 0xb8, 0xea, 0xe8, 0x0, 0x0, 0x7, 0x69, 0xd9, 0x55, 0xb0, 0xc6, 0xf5, 0xe2, + 0x0, 0x0, 0x1b, 0x5b, 0x67, 0x45, 0x83, 0x2d, 0xb9, 0x94, 0xd9, 0x7, 0xa9, 0x35, 0x28, 0xb9, + 0xec, 0x3f, 0xbb, 0xab, 0xd0, 0x82, 0xf2, 0xf, 0x64, 0x71, 0xe, 0x1f, 0x4e, 0x44, 0x1, 0x0, + 0x13, 0x20, 0x59, 0xf6, 0x8b, 0x5c, 0x78, 0x6a, 0xca, 0x29, 0xb6, 0x76, 0xa6, 0x8, 0x46, 0x45, + 0x62, 0xf5, 0x48, 0x82, 0x2, 0x0, 0xa, 0xa0, 0x33, 0x84, 0xea, 0x78, 0xfc, 0xc8, 0x0, 0x5d, + 0x86, 0x0, 0x0, 0x17, 0xd3, 0x8b, 0xff, 0x2a, 0x4, 0xe8, 0xf3, 0x93, 0x44, 0xfc, 0xf, 0xd7, + 0x35, 0x46, 0xf, 0x46, 0x5b, 0xd1, 0x1a, 0x77, 0xc3, 0x49, 0x82, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x2d, 0x9d, 0x48, 0x65, 0x5f, 0x56, 0xa5, 0x67, 0x6d, 0x59, - 0x87, 0x11, 0xf2, 0x8, 0x84, 0x8d, 0xea, 0xcd, 0xf7}; - lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xf4, 0xb9, 0xf9, 0x91, 0x1a, 0x1d, 0xa7, 0x26, + 0xc8, 0xc9, 0xbb, 0x45, 0x3d, 0xb8, 0xea, 0xe8}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x58, 0x2b, 0xd0, 0xf2, 0x20, 0x30, 0xc7, 0x64, 0x39, 0xcb, 0x15, 0x29, - 0xb6, 0x41, 0x4b, 0x58, 0x3a, 0xbb, 0x2a, 0xf7, 0x7c, 0xb1, 0xe5}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x69, 0xd9, 0x55, 0xb0, 0xc6, 0xf5, 0xe2}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2d, 0xc8, 0xc4, 0xb, 0xe, 0x4e, 0x98, 0x9c, 0x83, - 0xe9, 0x1b, 0xb5, 0x28, 0xae, 0x1b, 0x5f, 0xb6, 0x28}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5b, 0x67, 0x45, 0x83, 0x2d, 0xb9, 0x94, 0xd9, 0x7, 0xa9, 0x35, 0x28, 0xb9, 0xec, + 0x3f, 0xbb, 0xab, 0xd0, 0x82, 0xf2, 0xf, 0x64, 0x71, 0xe, 0x1f, 0x4e, 0x44}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf5}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x20, 0x59, 0xf6, 0x8b, 0x5c, 0x78, 0x6a, 0xca, 0x29, 0xb6, + 0x76, 0xa6, 0x8, 0x46, 0x45, 0x62, 0xf5, 0x48, 0x82}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x22, 0x10, 0x98, 0x97, 0x86, 0x1e, 0x8, 0x37, 0x85, 0xf0}; + uint8_t topic_filter_s4_bytes[] = {0xa0, 0x33, 0x84, 0xea, 0x78, 0xfc, 0xc8, 0x0, 0x5d, 0x86}; lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x9b, 0xc8, 0xda, 0x4f, 0x8b, 0x51, 0x89, 0xb7, 0x72, 0x3e, 0x1c, 0x5a, 0x28, - 0x29, 0xa3, 0x40, 0x43, 0xf0, 0x99, 0xc5, 0xaf, 0xa4, 0x77, 0xed, 0xf4, 0xd6}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xd3, 0x8b, 0xff, 0x2a, 0x4, 0xe8, 0xf3, 0x93, 0x44, 0xfc, 0xf, 0xd7, + 0x35, 0x46, 0xf, 0x46, 0x5b, 0xd1, 0x1a, 0x77, 0xc3, 0x49, 0x82}; + lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3a, 0x25, 0xd6, 0x21, 0xe8, 0x68, 0x71, 0x68, 0xef, - 0x89, 0x3f, 0x16, 0xfd, 0xe7, 0x82, 0xef, 0x4b, 0x69}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xd3, 0xf2, 0x23, 0xc9, 0x7d, 0x64, 0x4c, 0xf0, 0xbd, 0x96, 0xfb, 0xb9, 0xe7, - 0x7e, 0x3f, 0xe3, 0x9e, 0x98, 0x7a, 0xfb, 0x1a, 0x7f, 0x53, 0xae, 0x45}; - lwmqtt_string_t topic_filter_s7 = {25, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x25, 0x1d, 0x3e, 0xae, 0x52, 0x4e, 0x33, 0xbc, 0x4b, 0x5a, 0xa9, 0x17}; - lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x47, 0x13, 0x89, 0x81, 0x6b, 0xaf, 0x13, 0xcc}; + uint8_t bytesprops1[] = {0}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops1}}}, + }; + + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32664, 6, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 21953 [("\STX\245\160\232\SUB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),(",\r\215\243\217\137",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\ENQ\196M\SYN\244\173\DC2\170\SO\STXb\USw+z\173U\f\130\&4V\199\173\142\160\165\153\201\166\&4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropReceiveMaximum 30193,PropSharedSubscriptionAvailable 155,PropReasonString +// "\186Q\212\162\132=\234r\225\249\&1\219f\163X\214\229<\147\152s\224\EOTy\SOqp\254",PropMessageExpiryInterval +// 6080,PropCorrelationData "\NUL\167\180\243\221\ENQ\146K\SYN\153i:\167\222\r",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0xa0, 0x1, 0x47, 0xa0, 0x0, 0xb, 0x4d, 0x9f, 0x2e, 0xc2, 0xc0, 0x7, 0xc6, 0x94, 0x5d, 0xea, - 0xe9, 0x0, 0x0, 0x16, 0xbd, 0xde, 0x48, 0x45, 0xcc, 0xec, 0xe4, 0x85, 0x6, 0x2a, 0xec, 0x58, 0x80, - 0x30, 0xe5, 0x3b, 0x6e, 0xf5, 0x4f, 0x52, 0x62, 0xc4, 0x0, 0x0, 0x1b, 0x21, 0xe4, 0xcb, 0xc7, 0x8d, - 0x93, 0x1c, 0xb2, 0x64, 0x36, 0x8, 0xed, 0x79, 0x8c, 0x63, 0xd5, 0x7f, 0x8d, 0x44, 0x20, 0xa8, 0x8, - 0x9, 0xe7, 0x43, 0x22, 0x2, 0x0, 0x0, 0x9, 0xd0, 0x4e, 0xe7, 0xbc, 0xcc, 0x18, 0x59, 0x18, 0x2b, - 0x1, 0x0, 0x10, 0x31, 0x8a, 0xf9, 0xa6, 0xb6, 0xf4, 0x6e, 0x3c, 0xbd, 0xf, 0x7, 0xc0, 0x38, 0x57, - 0x7e, 0xf, 0x0, 0x0, 0x2, 0x4e, 0x74, 0x0, 0x0, 0x1, 0xb6, 0x0, 0x0, 0x14, 0x31, 0x0, 0xa, - 0x31, 0xa6, 0x6c, 0x54, 0x27, 0xff, 0x92, 0xbd, 0x5e, 0xe3, 0xcf, 0x33, 0x57, 0xae, 0x2a, 0xab, 0xc2, - 0x1, 0x0, 0x1, 0x4f, 0x0, 0x0, 0x0, 0x2, 0x0, 0x10, 0x5e, 0xe6, 0x3e, 0xb4, 0xf3, 0xdd, 0x5, - 0x92, 0x4b, 0x16, 0x99, 0x69, 0x3a, 0xa7, 0xde, 0xd, 0x1}; +// QoS2}),("\rm3\DEL,+L\150\CAN|9j\159\255g\206\t\FS=\160\201\&1",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReceiveMaximum 17360,PropAuthenticationData +// "\177\138\226\210m\NAK~\NUL\207\ESC\SUB\236O\b\153\&1q",PropAuthenticationMethod +// "\178\233\240\SOHJZ\f\178\176eMt",PropPayloadFormatIndicator 232] +TEST(Subscribe5QCTest, Encode17) { + uint8_t pkt[] = {0x82, 0x96, 0x1, 0x5f, 0x37, 0x28, 0x21, 0x43, 0xd0, 0x16, 0x0, 0x11, 0xb1, 0x8a, 0xe2, 0xd2, 0x6d, + 0x15, 0x7e, 0x0, 0xcf, 0x1b, 0x1a, 0xec, 0x4f, 0x8, 0x99, 0x31, 0x71, 0x15, 0x0, 0xc, 0xb2, 0xe9, + 0xf0, 0x1, 0x4a, 0x5a, 0xc, 0xb2, 0xb0, 0x65, 0x4d, 0x74, 0x1, 0xe8, 0x0, 0x1b, 0x58, 0x78, 0x2e, + 0xb5, 0x49, 0xaf, 0xf9, 0xae, 0x75, 0xd6, 0xc, 0x6f, 0x43, 0x27, 0xe2, 0x65, 0xc4, 0xe9, 0x1e, 0x88, + 0xe1, 0x5b, 0x30, 0xac, 0x2d, 0x79, 0x80, 0x2, 0x0, 0x16, 0xcb, 0x44, 0x72, 0x61, 0xf9, 0x12, 0x73, + 0xe, 0x65, 0xa7, 0xd, 0x7d, 0x9e, 0x3, 0x80, 0x8d, 0xf2, 0x3f, 0x35, 0xcb, 0xef, 0x93, 0x0, 0x0, + 0x18, 0x59, 0xf2, 0x48, 0xf3, 0x26, 0x56, 0xd4, 0x4b, 0x32, 0xb9, 0x32, 0x73, 0x71, 0xb2, 0xb2, 0x63, + 0xc2, 0xe6, 0xd6, 0x29, 0x5c, 0xed, 0x3, 0xe, 0x2, 0x0, 0x16, 0xd, 0x6d, 0x33, 0x7f, 0x2c, 0x2b, + 0x4c, 0x96, 0x18, 0x7c, 0x39, 0x6a, 0x9f, 0xff, 0x67, 0xce, 0x9, 0x1c, 0x3d, 0xa0, 0xc9, 0x31, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x4d, 0x9f, 0x2e, 0xc2, 0xc0, 0x7, 0xc6, 0x94, 0x5d, 0xea, 0xe9}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x58, 0x78, 0x2e, 0xb5, 0x49, 0xaf, 0xf9, 0xae, 0x75, 0xd6, 0xc, 0x6f, 0x43, 0x27, + 0xe2, 0x65, 0xc4, 0xe9, 0x1e, 0x88, 0xe1, 0x5b, 0x30, 0xac, 0x2d, 0x79, 0x80}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbd, 0xde, 0x48, 0x45, 0xcc, 0xec, 0xe4, 0x85, 0x6, 0x2a, 0xec, - 0x58, 0x80, 0x30, 0xe5, 0x3b, 0x6e, 0xf5, 0x4f, 0x52, 0x62, 0xc4}; + uint8_t topic_filter_s1_bytes[] = {0xcb, 0x44, 0x72, 0x61, 0xf9, 0x12, 0x73, 0xe, 0x65, 0xa7, 0xd, + 0x7d, 0x9e, 0x3, 0x80, 0x8d, 0xf2, 0x3f, 0x35, 0xcb, 0xef, 0x93}; lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x21, 0xe4, 0xcb, 0xc7, 0x8d, 0x93, 0x1c, 0xb2, 0x64, 0x36, 0x8, 0xed, 0x79, 0x8c, - 0x63, 0xd5, 0x7f, 0x8d, 0x44, 0x20, 0xa8, 0x8, 0x9, 0xe7, 0x43, 0x22, 0x2}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x59, 0xf2, 0x48, 0xf3, 0x26, 0x56, 0xd4, 0x4b, 0x32, 0xb9, 0x32, 0x73, + 0x71, 0xb2, 0xb2, 0x63, 0xc2, 0xe6, 0xd6, 0x29, 0x5c, 0xed, 0x3, 0xe}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd0, 0x4e, 0xe7, 0xbc, 0xcc, 0x18, 0x59, 0x18, 0x2b}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd, 0x6d, 0x33, 0x7f, 0x2c, 0x2b, 0x4c, 0x96, 0x18, 0x7c, 0x39, + 0x6a, 0x9f, 0xff, 0x67, 0xce, 0x9, 0x1c, 0x3d, 0xa0, 0xc9, 0x31}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x31, 0x8a, 0xf9, 0xa6, 0xb6, 0xf4, 0x6e, 0x3c, - 0xbd, 0xf, 0x7, 0xc0, 0x38, 0x57, 0x7e, 0xf}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4e, 0x74}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb6}; - lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x31, 0x0, 0xa, 0x31, 0xa6, 0x6c, 0x54, 0x27, 0xff, 0x92, - 0xbd, 0x5e, 0xe3, 0xcf, 0x33, 0x57, 0xae, 0x2a, 0xab, 0xc2}; - lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x4f}; - lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0}; - lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x5e, 0xe6, 0x3e, 0xb4, 0xf3, 0xdd, 0x5, 0x92, - 0x4b, 0x16, 0x99, 0x69, 0x3a, 0xa7, 0xde, 0xd}; - lwmqtt_string_t topic_filter_s10 = {16, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xb1, 0x8a, 0xe2, 0xd2, 0x6d, 0x15, 0x7e, 0x0, 0xcf, + 0x1b, 0x1a, 0xec, 0x4f, 0x8, 0x99, 0x31, 0x71}; + uint8_t bytesprops1[] = {0xb2, 0xe9, 0xf0, 0x1, 0x4a, 0x5a, 0xc, 0xb2, 0xb0, 0x65, 0x4d, 0x74}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17360}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 232}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18336, 11, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24375, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3357 [("\203$[\200\&9\130F\142\249\232\189\167\148L",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("<\n\188 -// \193>c\237\242\202\GSX\216\222e\204\149;\226",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("(.\204\183\ESC\178*",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("fld~\ACK9Z//1\205\SUB~\211l\241D\196`T",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("<\215\129\217-\248\223\vA\CAN$\203\213IH\227)\200\233[\174/\236\234\235\206\245\154\236\253",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0x6b, 0xd, 0x1d, 0x0, 0xe, 0xcb, 0x24, 0x5b, 0xc8, 0x39, 0x82, 0x46, 0x8e, 0xf9, 0xe8, - 0xbd, 0xa7, 0x94, 0x4c, 0x1, 0x0, 0x13, 0x3c, 0xa, 0xbc, 0x20, 0xc1, 0x3e, 0x63, 0xed, 0xf2, - 0xca, 0x1d, 0x58, 0xd8, 0xde, 0x65, 0xcc, 0x95, 0x3b, 0xe2, 0x2, 0x0, 0x7, 0x28, 0x2e, 0xcc, - 0xb7, 0x1b, 0xb2, 0x2a, 0x2, 0x0, 0x14, 0x66, 0x6c, 0x64, 0x7e, 0x6, 0x39, 0x5a, 0x2f, 0x2f, - 0x31, 0xcd, 0x1a, 0x7e, 0xd3, 0x6c, 0xf1, 0x44, 0xc4, 0x60, 0x54, 0x0, 0x0, 0x1e, 0x3c, 0xd7, - 0x81, 0xd9, 0x2d, 0xf8, 0xdf, 0xb, 0x41, 0x18, 0x24, 0xcb, 0xd5, 0x49, 0x48, 0xe3, 0x29, 0xc8, - 0xe9, 0x5b, 0xae, 0x2f, 0xec, 0xea, 0xeb, 0xce, 0xf5, 0x9a, 0xec, 0xfd, 0x0}; +// SubscribeRequest 15182 [("jX\253\212\226>%\234\136\158",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("wv\141n\252k\ESC\242,\211jBIr\ESC\nN\254\RSG\227C\180/A\174\244\STX\228\222",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("WE\f\171+\DC1\ETB\v\EOT\DLE\176\tw_\SYN/\ETX",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\161AM\198\RS6\146w\219\173\244\245J>\201",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS2}),("e\171N\STX\186ov\240\229\136D\\\234J\152e\217",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] +// [PropPayloadFormatIndicator 22,PropReceiveMaximum 2396,PropSubscriptionIdentifierAvailable +// 176,PropAuthenticationMethod "e\214,\242:_\GS\141\NUL\208\RSf|?\EM\138j\234\138\220",PropMaximumPacketSize 12790] +TEST(Subscribe5QCTest, Encode18) { + uint8_t pkt[] = {0x82, 0x8e, 0x1, 0x3b, 0x4e, 0x23, 0x1, 0x16, 0x21, 0x9, 0x5c, 0x29, 0xb0, 0x15, 0x0, 0x14, 0x65, + 0xd6, 0x2c, 0xf2, 0x3a, 0x5f, 0x1d, 0x8d, 0x0, 0xd0, 0x1e, 0x66, 0x7c, 0x3f, 0x19, 0x8a, 0x6a, 0xea, + 0x8a, 0xdc, 0x27, 0x0, 0x0, 0x31, 0xf6, 0x0, 0xa, 0x6a, 0x58, 0xfd, 0xd4, 0xe2, 0x3e, 0x25, 0xea, + 0x88, 0x9e, 0x1, 0x0, 0x1e, 0x77, 0x76, 0x8d, 0x6e, 0xfc, 0x6b, 0x1b, 0xf2, 0x2c, 0xd3, 0x6a, 0x42, + 0x49, 0x72, 0x1b, 0xa, 0x4e, 0xfe, 0x1e, 0x47, 0xe3, 0x43, 0xb4, 0x2f, 0x41, 0xae, 0xf4, 0x2, 0xe4, + 0xde, 0x1, 0x0, 0x11, 0x57, 0x45, 0xc, 0xab, 0x2b, 0x11, 0x17, 0xb, 0x4, 0x10, 0xb0, 0x9, 0x77, + 0x5f, 0x16, 0x2f, 0x3, 0x1, 0x0, 0xf, 0xa1, 0x41, 0x4d, 0xc6, 0x1e, 0x36, 0x92, 0x77, 0xdb, 0xad, + 0xf4, 0xf5, 0x4a, 0x3e, 0xc9, 0x2, 0x0, 0x11, 0x65, 0xab, 0x4e, 0x2, 0xba, 0x6f, 0x76, 0xf0, 0xe5, + 0x88, 0x44, 0x5c, 0xea, 0x4a, 0x98, 0x65, 0xd9, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xcb, 0x24, 0x5b, 0xc8, 0x39, 0x82, 0x46, - 0x8e, 0xf9, 0xe8, 0xbd, 0xa7, 0x94, 0x4c}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x6a, 0x58, 0xfd, 0xd4, 0xe2, 0x3e, 0x25, 0xea, 0x88, 0x9e}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3c, 0xa, 0xbc, 0x20, 0xc1, 0x3e, 0x63, 0xed, 0xf2, 0xca, - 0x1d, 0x58, 0xd8, 0xde, 0x65, 0xcc, 0x95, 0x3b, 0xe2}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x77, 0x76, 0x8d, 0x6e, 0xfc, 0x6b, 0x1b, 0xf2, 0x2c, 0xd3, + 0x6a, 0x42, 0x49, 0x72, 0x1b, 0xa, 0x4e, 0xfe, 0x1e, 0x47, + 0xe3, 0x43, 0xb4, 0x2f, 0x41, 0xae, 0xf4, 0x2, 0xe4, 0xde}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x28, 0x2e, 0xcc, 0xb7, 0x1b, 0xb2, 0x2a}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x57, 0x45, 0xc, 0xab, 0x2b, 0x11, 0x17, 0xb, 0x4, + 0x10, 0xb0, 0x9, 0x77, 0x5f, 0x16, 0x2f, 0x3}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x66, 0x6c, 0x64, 0x7e, 0x6, 0x39, 0x5a, 0x2f, 0x2f, 0x31, - 0xcd, 0x1a, 0x7e, 0xd3, 0x6c, 0xf1, 0x44, 0xc4, 0x60, 0x54}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa1, 0x41, 0x4d, 0xc6, 0x1e, 0x36, 0x92, 0x77, + 0xdb, 0xad, 0xf4, 0xf5, 0x4a, 0x3e, 0xc9}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x3c, 0xd7, 0x81, 0xd9, 0x2d, 0xf8, 0xdf, 0xb, 0x41, 0x18, - 0x24, 0xcb, 0xd5, 0x49, 0x48, 0xe3, 0x29, 0xc8, 0xe9, 0x5b, - 0xae, 0x2f, 0xec, 0xea, 0xeb, 0xce, 0xf5, 0x9a, 0xec, 0xfd}; - lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x65, 0xab, 0x4e, 0x2, 0xba, 0x6f, 0x76, 0xf0, 0xe5, + 0x88, 0x44, 0x5c, 0xea, 0x4a, 0x98, 0x65, 0xd9}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x65, 0xd6, 0x2c, 0xf2, 0x3a, 0x5f, 0x1d, 0x8d, 0x0, 0xd0, + 0x1e, 0x66, 0x7c, 0x3f, 0x19, 0x8a, 0x6a, 0xea, 0x8a, 0xdc}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2396}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12790}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3357, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15182, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18395 [("v2\217\195\171\136\254\128:i",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\249i9\228\SII\156\192\&7/.\187\203%",SubOptions +// SubscribeRequest 29268 [("\142",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = +// QoS0}),("5\254\147\212\152\233@<\242\195\191\180#\\Sl\SI\249(\174P\136\239\"B\182\139\218",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\229\173x +// \159d\157\161F\133y\253\&4\185\191h\167\231\noU\SI/\158\193\239",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(";Q=\182\248\245\152C&\221k\173\153\ESC\151\156",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Q\168tf\193i\245\US\ENQ\177nl\202/\177",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\245\205\t;\164#p\ESC\CAN\168,\134\NUL{\RS\164\CAN^\223\149",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SUB",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0x3b, 0x47, 0xdb, 0x0, 0xa, 0x76, 0x32, 0xd9, 0xc3, 0xab, 0x88, 0xfe, 0x80, 0x3a, 0x69, - 0x1, 0x0, 0xe, 0xf9, 0x69, 0x39, 0xe4, 0xf, 0x49, 0x9c, 0xc0, 0x37, 0x2f, 0x2e, 0xbb, 0xcb, - 0x25, 0x2, 0x0, 0x14, 0xf5, 0xcd, 0x9, 0x3b, 0xa4, 0x23, 0x70, 0x1b, 0x18, 0xa8, 0x2c, 0x86, - 0x0, 0x7b, 0x1e, 0xa4, 0x18, 0x5e, 0xdf, 0x95, 0x0, 0x0, 0x1, 0x1a, 0x2}; +// QoS1}),("\177\139\193I\228b\DLEvi\211\r{\aRg",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\195E\216",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("l\151\230\r\129\b\184\193\176\178\162\197\&5\188/\SO\187",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(" k\147",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRetainAvailable +// 230,PropReceiveMaximum 11250,PropReceiveMaximum 12353,PropContentType +// "\NAK4\163\226\165\169z\SO\139\182w^\204",PropPayloadFormatIndicator 139,PropRequestProblemInformation +// 197,PropMaximumQoS 7,PropTopicAliasMaximum 7500,PropTopicAlias 27990,PropReceiveMaximum 17963,PropResponseTopic +// "\128\218\250Y\217\199\219\235 .\158\246\137\219\205",PropWildcardSubscriptionAvailable 69,PropTopicAliasMaximum +// 22545,PropTopicAliasMaximum 6468,PropSharedSubscriptionAvailable 80,PropSharedSubscriptionAvailable 228] +TEST(Subscribe5QCTest, Encode19) { + uint8_t pkt[] = { + 0x82, 0xdf, 0x1, 0x72, 0x54, 0x45, 0x25, 0xe6, 0x21, 0x2b, 0xf2, 0x21, 0x30, 0x41, 0x3, 0x0, 0xd, 0x15, 0x34, + 0xa3, 0xe2, 0xa5, 0xa9, 0x7a, 0xe, 0x8b, 0xb6, 0x77, 0x5e, 0xcc, 0x1, 0x8b, 0x17, 0xc5, 0x24, 0x7, 0x22, 0x1d, + 0x4c, 0x23, 0x6d, 0x56, 0x21, 0x46, 0x2b, 0x8, 0x0, 0xf, 0x80, 0xda, 0xfa, 0x59, 0xd9, 0xc7, 0xdb, 0xeb, 0x20, + 0x2e, 0x9e, 0xf6, 0x89, 0xdb, 0xcd, 0x28, 0x45, 0x22, 0x58, 0x11, 0x22, 0x19, 0x44, 0x2a, 0x50, 0x2a, 0xe4, 0x0, + 0x1, 0x8e, 0x0, 0x0, 0x1c, 0x35, 0xfe, 0x93, 0xd4, 0x98, 0xe9, 0x40, 0x3c, 0xf2, 0xc3, 0xbf, 0xb4, 0x23, 0x5c, + 0x53, 0x6c, 0xf, 0xf9, 0x28, 0xae, 0x50, 0x88, 0xef, 0x22, 0x42, 0xb6, 0x8b, 0xda, 0x1, 0x0, 0x1a, 0xe5, 0xad, + 0x78, 0x20, 0x9f, 0x64, 0x9d, 0xa1, 0x46, 0x85, 0x79, 0xfd, 0x34, 0xb9, 0xbf, 0x68, 0xa7, 0xe7, 0xa, 0x6f, 0x55, + 0xf, 0x2f, 0x9e, 0xc1, 0xef, 0x0, 0x0, 0x10, 0x3b, 0x51, 0x3d, 0xb6, 0xf8, 0xf5, 0x98, 0x43, 0x26, 0xdd, 0x6b, + 0xad, 0x99, 0x1b, 0x97, 0x9c, 0x2, 0x0, 0xf, 0x51, 0xa8, 0x74, 0x66, 0xc1, 0x69, 0xf5, 0x1f, 0x5, 0xb1, 0x6e, + 0x6c, 0xca, 0x2f, 0xb1, 0x1, 0x0, 0xf, 0xb1, 0x8b, 0xc1, 0x49, 0xe4, 0x62, 0x10, 0x76, 0x69, 0xd3, 0xd, 0x7b, + 0x7, 0x52, 0x67, 0x1, 0x0, 0x3, 0xc3, 0x45, 0xd8, 0x2, 0x0, 0x11, 0x6c, 0x97, 0xe6, 0xd, 0x81, 0x8, 0xb8, + 0xc1, 0xb0, 0xb2, 0xa2, 0xc5, 0x35, 0xbc, 0x2f, 0xe, 0xbb, 0x0, 0x0, 0x3, 0x20, 0x6b, 0x93, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x76, 0x32, 0xd9, 0xc3, 0xab, 0x88, 0xfe, 0x80, 0x3a, 0x69}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x8e}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf9, 0x69, 0x39, 0xe4, 0xf, 0x49, 0x9c, 0xc0, 0x37, 0x2f, 0x2e, 0xbb, 0xcb, 0x25}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x35, 0xfe, 0x93, 0xd4, 0x98, 0xe9, 0x40, 0x3c, 0xf2, 0xc3, + 0xbf, 0xb4, 0x23, 0x5c, 0x53, 0x6c, 0xf, 0xf9, 0x28, 0xae, + 0x50, 0x88, 0xef, 0x22, 0x42, 0xb6, 0x8b, 0xda}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf5, 0xcd, 0x9, 0x3b, 0xa4, 0x23, 0x70, 0x1b, 0x18, 0xa8, - 0x2c, 0x86, 0x0, 0x7b, 0x1e, 0xa4, 0x18, 0x5e, 0xdf, 0x95}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe5, 0xad, 0x78, 0x20, 0x9f, 0x64, 0x9d, 0xa1, 0x46, 0x85, 0x79, 0xfd, 0x34, + 0xb9, 0xbf, 0x68, 0xa7, 0xe7, 0xa, 0x6f, 0x55, 0xf, 0x2f, 0x9e, 0xc1, 0xef}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1a}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3b, 0x51, 0x3d, 0xb6, 0xf8, 0xf5, 0x98, 0x43, + 0x26, 0xdd, 0x6b, 0xad, 0x99, 0x1b, 0x97, 0x9c}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t topic_filter_s4_bytes[] = {0x51, 0xa8, 0x74, 0x66, 0xc1, 0x69, 0xf5, 0x1f, + 0x5, 0xb1, 0x6e, 0x6c, 0xca, 0x2f, 0xb1}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb1, 0x8b, 0xc1, 0x49, 0xe4, 0x62, 0x10, 0x76, + 0x69, 0xd3, 0xd, 0x7b, 0x7, 0x52, 0x67}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc3, 0x45, 0xd8}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6c, 0x97, 0xe6, 0xd, 0x81, 0x8, 0xb8, 0xc1, 0xb0, + 0xb2, 0xa2, 0xc5, 0x35, 0xbc, 0x2f, 0xe, 0xbb}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x20, 0x6b, 0x93}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, + LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x15, 0x34, 0xa3, 0xe2, 0xa5, 0xa9, 0x7a, 0xe, 0x8b, 0xb6, 0x77, 0x5e, 0xcc}; + uint8_t bytesprops1[] = {0x80, 0xda, 0xfa, 0x59, 0xd9, 0xc7, 0xdb, 0xeb, 0x20, 0x2e, 0x9e, 0xf6, 0x89, 0xdb, 0xcd}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11250}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12353}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7500}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27990}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17963}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22545}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6468}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 228}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18395, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29268, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 6101 [(",\ENQ\132\182e\220\SYN%\233\253\238",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\RSH\179\141\155\183W\DC3\253\169v6\193;\187`c\217\218\234",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropMessageExpiryInterval 19065,PropTopicAlias -// 12758,PropMaximumQoS 101,PropWillDelayInterval 331,PropWillDelayInterval 6082] -TEST(Subscribe5QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x3c, 0x17, 0xd5, 0x14, 0x2, 0x0, 0x0, 0x4a, 0x79, 0x23, 0x31, 0xd6, 0x24, 0x65, 0x18, - 0x0, 0x0, 0x1, 0x4b, 0x18, 0x0, 0x0, 0x17, 0xc2, 0x0, 0xb, 0x2c, 0x5, 0x84, 0xb6, 0x65, - 0xdc, 0x16, 0x25, 0xe9, 0xfd, 0xee, 0x1, 0x0, 0x14, 0x1e, 0x48, 0xb3, 0x8d, 0x9b, 0xb7, 0x57, - 0x13, 0xfd, 0xa9, 0x76, 0x36, 0xc1, 0x3b, 0xbb, 0x60, 0x63, 0xd9, 0xda, 0xea, 0x2}; +// SubscribeRequest 30528 [("Z7\246b'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\248\161\240\135Q\130\198oV\RS\187~7'\DC2@\ACK~i\213csX\200kE\240",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\248\215\167X\a\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("W\139~\240\234\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("\226\223\ETXA\170{\FS\197RN\147X\161\ESC\SI\a\197\vB3\232\220\160{\136\242\&5\150\150",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\134\236\184\180A/4\206\134\176p\163\&6\NUL\RS$\US\200\CAN\DELU\156\224",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ENQ\177",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\207\&1\134\149\169\137_\145\\\185,\187\242\226\135J>\203\203B\245\196\147\239\168\212\167\145\219",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(",\176\197p\224M\\\200",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\155w\224D\180\218\161\221r@3\"\131\FS\184\204\160",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerReference +// "\236.\US\173\184\196J\207\233*d\SO\SOAD\155\ba\r",PropPayloadFormatIndicator 174,PropAuthenticationData +// "\141\234\239\130"] +TEST(Subscribe5QCTest, Encode20) { + uint8_t pkt[] = {0x82, 0xd8, 0x1, 0x77, 0x40, 0x1f, 0x1c, 0x0, 0x13, 0xec, 0x2e, 0x1f, 0xad, 0xb8, 0xc4, 0x4a, 0xcf, + 0xe9, 0x2a, 0x64, 0xe, 0xe, 0x41, 0x44, 0x9b, 0x8, 0x61, 0xd, 0x1, 0xae, 0x16, 0x0, 0x4, 0x8d, + 0xea, 0xef, 0x82, 0x0, 0x5, 0x5a, 0x37, 0xf6, 0x62, 0x27, 0x1, 0x0, 0x1b, 0xf8, 0xa1, 0xf0, 0x87, + 0x51, 0x82, 0xc6, 0x6f, 0x56, 0x1e, 0xbb, 0x7e, 0x37, 0x27, 0x12, 0x40, 0x6, 0x7e, 0x69, 0xd5, 0x63, + 0x73, 0x58, 0xc8, 0x6b, 0x45, 0xf0, 0x2, 0x0, 0x6, 0xf8, 0xd7, 0xa7, 0x58, 0x7, 0xb8, 0x1, 0x0, + 0x6, 0x57, 0x8b, 0x7e, 0xf0, 0xea, 0xa, 0x2, 0x0, 0x1d, 0xe2, 0xdf, 0x3, 0x41, 0xaa, 0x7b, 0x1c, + 0xc5, 0x52, 0x4e, 0x93, 0x58, 0xa1, 0x1b, 0xf, 0x7, 0xc5, 0xb, 0x42, 0x33, 0xe8, 0xdc, 0xa0, 0x7b, + 0x88, 0xf2, 0x35, 0x96, 0x96, 0x2, 0x0, 0x17, 0x86, 0xec, 0xb8, 0xb4, 0x41, 0x2f, 0x34, 0xce, 0x86, + 0xb0, 0x70, 0xa3, 0x36, 0x0, 0x1e, 0x24, 0x1f, 0xc8, 0x18, 0x7f, 0x55, 0x9c, 0xe0, 0x0, 0x0, 0x2, + 0x5, 0xb1, 0x2, 0x0, 0x1d, 0xcf, 0x31, 0x86, 0x95, 0xa9, 0x89, 0x5f, 0x91, 0x5c, 0xb9, 0x2c, 0xbb, + 0xf2, 0xe2, 0x87, 0x4a, 0x3e, 0xcb, 0xcb, 0x42, 0xf5, 0xc4, 0x93, 0xef, 0xa8, 0xd4, 0xa7, 0x91, 0xdb, + 0x0, 0x0, 0x8, 0x2c, 0xb0, 0xc5, 0x70, 0xe0, 0x4d, 0x5c, 0xc8, 0x0, 0x0, 0x11, 0x9b, 0x77, 0xe0, + 0x44, 0xb4, 0xda, 0xa1, 0xdd, 0x72, 0x40, 0x33, 0x22, 0x83, 0x1c, 0xb8, 0xcc, 0xa0, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x2c, 0x5, 0x84, 0xb6, 0x65, 0xdc, 0x16, 0x25, 0xe9, 0xfd, 0xee}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x5a, 0x37, 0xf6, 0x62, 0x27}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1e, 0x48, 0xb3, 0x8d, 0x9b, 0xb7, 0x57, 0x13, 0xfd, 0xa9, - 0x76, 0x36, 0xc1, 0x3b, 0xbb, 0x60, 0x63, 0xd9, 0xda, 0xea}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf8, 0xa1, 0xf0, 0x87, 0x51, 0x82, 0xc6, 0x6f, 0x56, 0x1e, 0xbb, 0x7e, 0x37, 0x27, + 0x12, 0x40, 0x6, 0x7e, 0x69, 0xd5, 0x63, 0x73, 0x58, 0xc8, 0x6b, 0x45, 0xf0}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2}; + uint8_t topic_filter_s2_bytes[] = {0xf8, 0xd7, 0xa7, 0x58, 0x7, 0xb8}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x57, 0x8b, 0x7e, 0xf0, 0xea, 0xa}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe2, 0xdf, 0x3, 0x41, 0xaa, 0x7b, 0x1c, 0xc5, 0x52, 0x4e, + 0x93, 0x58, 0xa1, 0x1b, 0xf, 0x7, 0xc5, 0xb, 0x42, 0x33, + 0xe8, 0xdc, 0xa0, 0x7b, 0x88, 0xf2, 0x35, 0x96, 0x96}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x86, 0xec, 0xb8, 0xb4, 0x41, 0x2f, 0x34, 0xce, 0x86, 0xb0, 0x70, 0xa3, + 0x36, 0x0, 0x1e, 0x24, 0x1f, 0xc8, 0x18, 0x7f, 0x55, 0x9c, 0xe0}; + lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x5, 0xb1}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xcf, 0x31, 0x86, 0x95, 0xa9, 0x89, 0x5f, 0x91, 0x5c, 0xb9, + 0x2c, 0xbb, 0xf2, 0xe2, 0x87, 0x4a, 0x3e, 0xcb, 0xcb, 0x42, + 0xf5, 0xc4, 0x93, 0xef, 0xa8, 0xd4, 0xa7, 0x91, 0xdb}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x2c, 0xb0, 0xc5, 0x70, 0xe0, 0x4d, 0x5c, 0xc8}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x9b, 0x77, 0xe0, 0x44, 0xb4, 0xda, 0xa1, 0xdd, 0x72, + 0x40, 0x33, 0x22, 0x83, 0x1c, 0xb8, 0xcc, 0xa0}; + lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, + LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xec, 0x2e, 0x1f, 0xad, 0xb8, 0xc4, 0x4a, 0xcf, 0xe9, 0x2a, + 0x64, 0xe, 0xe, 0x41, 0x44, 0x9b, 0x8, 0x61, 0xd}; + uint8_t bytesprops1[] = {0x8d, 0xea, 0xef, 0x82}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19065}}, {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12758}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 101}}, {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 331}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6082}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6101, 2, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30528, 10, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25296 [("\DC1\170f\212\242sLZ\148\SIg)\208\ACK\128U\161\186\NUL)\214\158",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropMaximumPacketSize 28140,PropSharedSubscriptionAvailable 62,PropAuthenticationMethod -// "\234\191Q\135\223\255\&4\216^",PropMessageExpiryInterval 588,PropResponseTopic -// "U\ETX\ACK\231\140\239\243\SYN\253\134\RS\136j",PropReceiveMaximum 21402,PropSubscriptionIdentifier -// 8,PropSharedSubscriptionAvailable 83,PropMaximumPacketSize 23375,PropTopicAliasMaximum -// 28613,PropRequestProblemInformation 212,PropTopicAlias 6168,PropAuthenticationMethod -// "#\147\231\SYNFp\218\170h\EM\137\192\241\176V\148N\255z\DC2)",PropWildcardSubscriptionAvailable -// 114,PropServerReference "",PropContentType "\139\237\217J\ne\152C\254\170\236\141\174\&1@\147\&8",PropMaximumQoS -// 64,PropMessageExpiryInterval 3635,PropMessageExpiryInterval 29474,PropRequestProblemInformation -// 130,PropSubscriptionIdentifier 18,PropMessageExpiryInterval 7025,PropTopicAlias 17854,PropMaximumPacketSize -// 13771,PropWildcardSubscriptionAvailable 166,PropWildcardSubscriptionAvailable 26,PropSubscriptionIdentifierAvailable -// 63,PropCorrelationData "\214\238\129dj\201_\a1\172\157\157\141'\201h\171\147!\162\&8\EM",PropSubscriptionIdentifier -// 0] -TEST(Subscribe5QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0xc8, 0x1, 0x62, 0xd0, 0xab, 0x1, 0x27, 0x0, 0x0, 0x6d, 0xec,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; +// SubscribeRequest 32298 [("\183B\236P\DC4\RS0\245>\186\t\170R\GS\ESC\SI\234\151\246\224",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropRequestResponseInformation +// 237,PropServerReference ".]r\136\&1\229.",PropUserProperty "'\192\242\220\159\a\198\"\151\155\251\132yZ\223\135{" +// "\154\v\199\217\EM\FS/\179wz\184",PropMaximumPacketSize 16608,PropAssignedClientIdentifier +// "\207",PropSubscriptionIdentifierAvailable 150,PropServerKeepAlive 31252,PropSessionExpiryInterval +// 27950,PropResponseTopic "Pc<\170",PropMessageExpiryInterval 8676,PropServerKeepAlive 14073,PropReasonString +// "\CAN\DC2\DC4K\SI\212D\188\171\161+\133\SYNn&kS\218\223u]\161\198/",PropRequestProblemInformation +// 70,PropRetainAvailable 136] +TEST(Subscribe5QCTest, Encode21) { + uint8_t pkt[] = {0x82, 0x88, 0x1, 0x7e, 0x2a, 0x6e, 0x19, 0xed, 0x1c, 0x0, 0x7, 0x2e, 0x5d, 0x72, 0x88, 0x31, + 0xe5, 0x2e, 0x26, 0x0, 0x11, 0x27, 0xc0, 0xf2, 0xdc, 0x9f, 0x7, 0xc6, 0x22, 0x97, 0x9b, 0xfb, + 0x84, 0x79, 0x5a, 0xdf, 0x87, 0x7b, 0x0, 0xb, 0x9a, 0xb, 0xc7, 0xd9, 0x19, 0x1c, 0x2f, 0xb3, + 0x77, 0x7a, 0xb8, 0x27, 0x0, 0x0, 0x40, 0xe0, 0x12, 0x0, 0x1, 0xcf, 0x29, 0x96, 0x13, 0x7a, + 0x14, 0x11, 0x0, 0x0, 0x6d, 0x2e, 0x8, 0x0, 0x4, 0x50, 0x63, 0x3c, 0xaa, 0x2, 0x0, 0x0, + 0x21, 0xe4, 0x13, 0x36, 0xf9, 0x1f, 0x0, 0x18, 0x18, 0x12, 0x14, 0x4b, 0xf, 0xd4, 0x44, 0xbc, + 0xab, 0xa1, 0x2b, 0x85, 0x16, 0x6e, 0x26, 0x6b, 0x53, 0xda, 0xdf, 0x75, 0x5d, 0xa1, 0xc6, 0x2f, + 0x17, 0x46, 0x25, 0x88, 0x0, 0x14, 0xb7, 0x42, 0xec, 0x50, 0x14, 0x1e, 0x30, 0xf5, 0x3e, 0xba, + 0x9, 0xaa, 0x52, 0x1d, 0x1b, 0xf, 0xea, 0x97, 0xf6, 0xe0, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x11, 0xaa, 0x66, 0xd4, 0xf2, 0x73, 0x4c, 0x5a, 0x94, 0xf, 0x67, - 0x29, 0xd0, 0x6, 0x80, 0x55, 0xa1, 0xba, 0x0, 0x29, 0xd6, 0x9e}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xb7, 0x42, 0xec, 0x50, 0x14, 0x1e, 0x30, 0xf5, 0x3e, 0xba, + 0x9, 0xaa, 0x52, 0x1d, 0x1b, 0xf, 0xea, 0x97, 0xf6, 0xe0}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0xea, 0xbf, 0x51, 0x87, 0xdf, 0xff, 0x34, 0xd8, 0x5e}; - uint8_t bytesprops1[] = {0x55, 0x3, 0x6, 0xe7, 0x8c, 0xef, 0xf3, 0x16, 0xfd, 0x86, 0x1e, 0x88, 0x6a}; - uint8_t bytesprops2[] = {0x23, 0x93, 0xe7, 0x16, 0x46, 0x70, 0xda, 0xaa, 0x68, 0x19, 0x89, - 0xc0, 0xf1, 0xb0, 0x56, 0x94, 0x4e, 0xff, 0x7a, 0x12, 0x29}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x8b, 0xed, 0xd9, 0x4a, 0xa, 0x65, 0x98, 0x43, 0xfe, - 0xaa, 0xec, 0x8d, 0xae, 0x31, 0x40, 0x93, 0x38}; - uint8_t bytesprops5[] = {0xd6, 0xee, 0x81, 0x64, 0x6a, 0xc9, 0x5f, 0x7, 0x31, 0xac, 0x9d, - 0x9d, 0x8d, 0x27, 0xc9, 0x68, 0xab, 0x93, 0x21, 0xa2, 0x38, 0x19}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x2e, 0x5d, 0x72, 0x88, 0x31, 0xe5, 0x2e}; + uint8_t bytesprops2[] = {0x9a, 0xb, 0xc7, 0xd9, 0x19, 0x1c, 0x2f, 0xb3, 0x77, 0x7a, 0xb8}; + uint8_t bytesprops1[] = {0x27, 0xc0, 0xf2, 0xdc, 0x9f, 0x7, 0xc6, 0x22, 0x97, + 0x9b, 0xfb, 0x84, 0x79, 0x5a, 0xdf, 0x87, 0x7b}; + uint8_t bytesprops3[] = {0xcf}; + uint8_t bytesprops4[] = {0x50, 0x63, 0x3c, 0xaa}; + uint8_t bytesprops5[] = {0x18, 0x12, 0x14, 0x4b, 0xf, 0xd4, 0x44, 0xbc, 0xab, 0xa1, 0x2b, 0x85, + 0x16, 0x6e, 0x26, 0x6b, 0x53, 0xda, 0xdf, 0x75, 0x5d, 0xa1, 0xc6, 0x2f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28140}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 588}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21402}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23375}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28613}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6168}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3635}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29474}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7025}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17854}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13771}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16608}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31252}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27950}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8676}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14073}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 136}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25296, 1, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32298, 1, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28036 [("Pv\136\129\234\188\197$",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1}),("\132\&1/\159\185\&7",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 22169 [("\185n'\131\192M\162\EOTR\199\DC3\248G\138\NULjj\129\249\191\177\183D\200WU",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\247j\216\229\244\&4\DLEvoHjH\NUL\236\161\&64",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\161\248\233\231\243\148\238\193\NAK\GSx\193",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SYN\242\243\159\RS",SubOptions {_retainHandling = +// QoS2}),("\130O\195\&2/BI\149/\183\137\146\218\179\CAN\198\212\174\&3a\191\158\214K\209\173p@\130",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\182g\162\186\175\184\210\ACKc>I\183\153\SO\176\v\255\221\&0L_\231Z",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("yS\"\212\211\222\&7\144*K\137\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [PropCorrelationData " Ga\182 -// 7\156\&9\204\155\202d\148\&4\212a\206\255|\150\178\176\208b",PropAuthenticationData -// "\137\223P\139\214f\177\194\174\189\187\173\ETB",PropRequestResponseInformation 187,PropContentType -// "\144\192\&7b3\148\218\b\163!\235\130V\214\133f}S\GS\"\224\136\165\245\ESC;\147",PropServerReference -// "",PropAuthenticationData "~\EOT,\220D\184M\236\240\GS\231\213\202\&4a",PropSharedSubscriptionAvailable -// 178,PropReasonString "\255\201k \150\DC4\140\246k#^\157w\219\130\169\186\137",PropRetainAvailable 80,PropTopicAlias -// 4645,PropContentType "\212@\230+j\173ke",PropAuthenticationMethod -// "\248J\CAN\148\&0\180\208\181'\224,",PropMessageExpiryInterval 26316,PropPayloadFormatIndicator -// 218,PropRequestProblemInformation 99,PropMaximumPacketSize 5815,PropWildcardSubscriptionAvailable -// 167,PropAuthenticationMethod "\RSc\229\154",PropResponseInformation "b \147",PropPayloadFormatIndicator -// 236,PropAssignedClientIdentifier "*\233\189\219\157R",PropCorrelationData -// "\201;\128\&2:\162\r\SYNI\229\240\167\212i>B\155\&41\222\234\158EJX\187\188\236k\176",PropAuthenticationMethod -// "\173\145\DC3\NUL\RS\NAKn$\164]",PropTopicAliasMaximum 18831,PropReceiveMaximum 20663,PropServerReference -// "3w\150\205\244\251]\161\142\230\DC3\205\132\178\129\193uQ}^\199C[\"9\128\137v",PropReasonString -// "7C\227\DLE^;\211\r\245~\217ou\217\224vk",PropCorrelationData -// "h\211&C1\197IM\DC1N\187\240\135_\204\219\202\157\244\EM\138\176B\224B\150",PropAuthenticationData -// "\213\&6\250\ENQ\t\139\235\189\168K\178\222\205\144$\213\ENQ\169\206\185\188",PropWillDelayInterval 26355] -TEST(Subscribe5QCTest, Encode3) { +// QoS2}),("\149\178\207\218V\235\209\189K6\143\DC3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic "\202B\213%\169\204'",PropMessageExpiryInterval +// 8353,PropMaximumQoS 188,PropMaximumPacketSize 4183,PropWildcardSubscriptionAvailable 203,PropReceiveMaximum +// 12629,PropReceiveMaximum 28020,PropTopicAlias 3381,PropWildcardSubscriptionAvailable +// 6,PropSubscriptionIdentifierAvailable 228,PropAuthenticationMethod "\153\ETBl;",PropAuthenticationData +// "\235@RK\\]\199\t\184$\251\172\&1\248j\217\233\b\251_\DC3=p\150\178\220\200",PropPayloadFormatIndicator +// 232,PropMaximumPacketSize 26137,PropAuthenticationData +// "\DC3>\176\CANO\159\a\DC43\135-\173\136\249\158\&2\191\184X\192\180\213\DC4\141\\\207\234*u",PropResponseInformation +// "]PYw\173\ETXJ\131\128\184\&0\152\254\247\215",PropCorrelationData "\202*d\183F\147)",PropSessionExpiryInterval +// 18520,PropRetainAvailable 28,PropSharedSubscriptionAvailable 172,PropSharedSubscriptionAvailable +// 47,PropCorrelationData "\149C\STX\254\158\173\205k\166\141\159\200\DC2\145g\ETB\SO",PropPayloadFormatIndicator +// 7,PropMessageExpiryInterval 11013,PropWildcardSubscriptionAvailable 170,PropMaximumQoS 9] +TEST(Subscribe5QCTest, Encode22) { uint8_t pkt[] = { - 0x82, 0x9c, 0x3, 0x6d, 0x84, 0xde, 0x2, 0x9, 0x0, 0x18, 0x20, 0x47, 0x61, 0xb6, 0x20, 0x37, 0x9c, 0x39, 0xcc, - 0x9b, 0xca, 0x64, 0x94, 0x34, 0xd4, 0x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0x8d, 0x9f, 0xc8, 0x12, 0x91, 0x67, 0x17, 0xe, 0x1, 0x7, 0x2, 0x0, 0x0, 0x2b, 0x5, 0x28, 0xaa, 0x24, 0x9, + 0x0, 0x1a, 0xb9, 0x6e, 0x27, 0x83, 0xc0, 0x4d, 0xa2, 0x4, 0x52, 0xc7, 0x13, 0xf8, 0x47, 0x8a, 0x0, 0x6a, 0x6a, + 0x81, 0xf9, 0xbf, 0xb1, 0xb7, 0x44, 0xc8, 0x57, 0x55, 0x1, 0x0, 0x11, 0xf7, 0x6a, 0xd8, 0xe5, 0xf4, 0x34, 0x10, + 0x76, 0x6f, 0x48, 0x6a, 0x48, 0x0, 0xec, 0xa1, 0x36, 0x34, 0x2, 0x0, 0x1d, 0x82, 0x4f, 0xc3, 0x32, 0x2f, 0x42, + 0x49, 0x95, 0x2f, 0xb7, 0x89, 0x92, 0xda, 0xb3, 0x18, 0xc6, 0xd4, 0xae, 0x33, 0x61, 0xbf, 0x9e, 0xd6, 0x4b, 0xd1, + 0xad, 0x70, 0x40, 0x82, 0x1, 0x0, 0x17, 0xb6, 0x67, 0xa2, 0xba, 0xaf, 0xb8, 0xd2, 0x6, 0x63, 0x3e, 0x49, 0xb7, + 0x99, 0xe, 0xb0, 0xb, 0xff, 0xdd, 0x30, 0x4c, 0x5f, 0xe7, 0x5a, 0x2, 0x0, 0xc, 0x95, 0xb2, 0xcf, 0xda, 0x56, + 0xeb, 0xd1, 0xbd, 0x4b, 0x36, 0x8f, 0x13, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x50, 0x76, 0x88, 0x81, 0xea, 0xbc, 0xc5, 0x24}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xb9, 0x6e, 0x27, 0x83, 0xc0, 0x4d, 0xa2, 0x4, 0x52, 0xc7, 0x13, 0xf8, 0x47, + 0x8a, 0x0, 0x6a, 0x6a, 0x81, 0xf9, 0xbf, 0xb1, 0xb7, 0x44, 0xc8, 0x57, 0x55}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x84, 0x31, 0x2f, 0x9f, 0xb9, 0x37}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf7, 0x6a, 0xd8, 0xe5, 0xf4, 0x34, 0x10, 0x76, 0x6f, + 0x48, 0x6a, 0x48, 0x0, 0xec, 0xa1, 0x36, 0x34}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa1, 0xf8, 0xe9, 0xe7, 0xf3, 0x94, 0xee, 0xc1, 0x15, 0x1d, 0x78, 0xc1}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x82, 0x4f, 0xc3, 0x32, 0x2f, 0x42, 0x49, 0x95, 0x2f, 0xb7, + 0x89, 0x92, 0xda, 0xb3, 0x18, 0xc6, 0xd4, 0xae, 0x33, 0x61, + 0xbf, 0x9e, 0xd6, 0x4b, 0xd1, 0xad, 0x70, 0x40, 0x82}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x16, 0xf2, 0xf3, 0x9f, 0x1e}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xb6, 0x67, 0xa2, 0xba, 0xaf, 0xb8, 0xd2, 0x6, 0x63, 0x3e, 0x49, 0xb7, + 0x99, 0xe, 0xb0, 0xb, 0xff, 0xdd, 0x30, 0x4c, 0x5f, 0xe7, 0x5a}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x79, 0x53, 0x22, 0xd4, 0xd3, 0xde, 0x37, 0x90, 0x2a, 0x4b, 0x89, 0xe1}; + uint8_t topic_filter_s4_bytes[] = {0x95, 0xb2, 0xcf, 0xda, 0x56, 0xeb, 0xd1, 0xbd, 0x4b, 0x36, 0x8f, 0x13}; lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x20, 0x47, 0x61, 0xb6, 0x20, 0x37, 0x9c, 0x39, 0xcc, 0x9b, 0xca, 0x64, - 0x94, 0x34, 0xd4, 0x61, 0xce, 0xff, 0x7c, 0x96, 0xb2, 0xb0, 0xd0, 0x62}; - uint8_t bytesprops1[] = {0x89, 0xdf, 0x50, 0x8b, 0xd6, 0x66, 0xb1, 0xc2, 0xae, 0xbd, 0xbb, 0xad, 0x17}; - uint8_t bytesprops2[] = {0x90, 0xc0, 0x37, 0x62, 0x33, 0x94, 0xda, 0x8, 0xa3, 0x21, 0xeb, 0x82, 0x56, 0xd6, - 0x85, 0x66, 0x7d, 0x53, 0x1d, 0x22, 0xe0, 0x88, 0xa5, 0xf5, 0x1b, 0x3b, 0x93}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x7e, 0x4, 0x2c, 0xdc, 0x44, 0xb8, 0x4d, 0xec, 0xf0, 0x1d, 0xe7, 0xd5, 0xca, 0x34, 0x61}; - uint8_t bytesprops5[] = {0xff, 0xc9, 0x6b, 0x20, 0x96, 0x14, 0x8c, 0xf6, 0x6b, - 0x23, 0x5e, 0x9d, 0x77, 0xdb, 0x82, 0xa9, 0xba, 0x89}; - uint8_t bytesprops6[] = {0xd4, 0x40, 0xe6, 0x2b, 0x6a, 0xad, 0x6b, 0x65}; - uint8_t bytesprops7[] = {0xf8, 0x4a, 0x18, 0x94, 0x30, 0xb4, 0xd0, 0xb5, 0x27, 0xe0, 0x2c}; - uint8_t bytesprops8[] = {0x1e, 0x63, 0xe5, 0x9a}; - uint8_t bytesprops9[] = {0x62, 0x20, 0x93}; - uint8_t bytesprops10[] = {0x2a, 0xe9, 0xbd, 0xdb, 0x9d, 0x52}; - uint8_t bytesprops11[] = {0xc9, 0x3b, 0x80, 0x32, 0x3a, 0xa2, 0xd, 0x16, 0x49, 0xe5, 0xf0, 0xa7, 0xd4, 0x69, 0x3e, - 0x42, 0x9b, 0x34, 0x31, 0xde, 0xea, 0x9e, 0x45, 0x4a, 0x58, 0xbb, 0xbc, 0xec, 0x6b, 0xb0}; - uint8_t bytesprops12[] = {0xad, 0x91, 0x13, 0x0, 0x1e, 0x15, 0x6e, 0x24, 0xa4, 0x5d}; - uint8_t bytesprops13[] = {0x33, 0x77, 0x96, 0xcd, 0xf4, 0xfb, 0x5d, 0xa1, 0x8e, 0xe6, 0x13, 0xcd, 0x84, 0xb2, - 0x81, 0xc1, 0x75, 0x51, 0x7d, 0x5e, 0xc7, 0x43, 0x5b, 0x22, 0x39, 0x80, 0x89, 0x76}; - uint8_t bytesprops14[] = {0x37, 0x43, 0xe3, 0x10, 0x5e, 0x3b, 0xd3, 0xd, 0xf5, - 0x7e, 0xd9, 0x6f, 0x75, 0xd9, 0xe0, 0x76, 0x6b}; - uint8_t bytesprops15[] = {0x68, 0xd3, 0x26, 0x43, 0x31, 0xc5, 0x49, 0x4d, 0x11, 0x4e, 0xbb, 0xf0, 0x87, - 0x5f, 0xcc, 0xdb, 0xca, 0x9d, 0xf4, 0x19, 0x8a, 0xb0, 0x42, 0xe0, 0x42, 0x96}; - uint8_t bytesprops16[] = {0xd5, 0x36, 0xfa, 0x5, 0x9, 0x8b, 0xeb, 0xbd, 0xa8, 0x4b, 0xb2, - 0xde, 0xcd, 0x90, 0x24, 0xd5, 0x5, 0xa9, 0xce, 0xb9, 0xbc}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xca, 0x42, 0xd5, 0x25, 0xa9, 0xcc, 0x27}; + uint8_t bytesprops1[] = {0x99, 0x17, 0x6c, 0x3b}; + uint8_t bytesprops2[] = {0xeb, 0x40, 0x52, 0x4b, 0x5c, 0x5d, 0xc7, 0x9, 0xb8, 0x24, 0xfb, 0xac, 0x31, 0xf8, + 0x6a, 0xd9, 0xe9, 0x8, 0xfb, 0x5f, 0x13, 0x3d, 0x70, 0x96, 0xb2, 0xdc, 0xc8}; + uint8_t bytesprops3[] = {0x13, 0x3e, 0xb0, 0x18, 0x4f, 0x9f, 0x7, 0x14, 0x33, 0x87, 0x2d, 0xad, 0x88, 0xf9, 0x9e, + 0x32, 0xbf, 0xb8, 0x58, 0xc0, 0xb4, 0xd5, 0x14, 0x8d, 0x5c, 0xcf, 0xea, 0x2a, 0x75}; + uint8_t bytesprops4[] = {0x5d, 0x50, 0x59, 0x77, 0xad, 0x3, 0x4a, 0x83, 0x80, 0xb8, 0x30, 0x98, 0xfe, 0xf7, 0xd7}; + uint8_t bytesprops5[] = {0xca, 0x2a, 0x64, 0xb7, 0x46, 0x93, 0x29}; + uint8_t bytesprops6[] = {0x95, 0x43, 0x2, 0xfe, 0x9e, 0xad, 0xcd, 0x6b, 0xa6, + 0x8d, 0x9f, 0xc8, 0x12, 0x91, 0x67, 0x17, 0xe}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4645}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26316}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5815}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18831}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20663}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops15}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops16}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26355}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8353}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4183}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12629}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28020}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3381}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26137}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18520}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11013}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 9}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28036, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22169, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8713 [("\fd\209\239\ETB\191E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\183\248C",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("5",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ETBz+\DC4\ETB\244\SOH\203\149<\224g\247^\243\187\&3\RS<\162\178S]{{\143\226c_",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\238\DC4\212\224g.\142q`8P<\164\172\229\248",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\143Ib3\212\238\222\217k\223\\\SO\SOxm\220}s;^\162\226",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\130\EM\NUL\129\234\143\201xg>\194\173tM\GS\148\201\167\221O\ENQ#ktu89\141",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("B\203O\166\SI\168J\185|\254\215>\177\156",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS2})] [PropContentType "\"*8\173\t\"\NUL\161F\201\245\146P\ETX^"] -TEST(Subscribe5QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0xa5, 0x1, 0x22, 0x9, 0x12, 0x3, 0x0, 0xf, 0x22, 0x2a, 0x38, 0xad, 0x9, 0x22, 0x0, 0xa1, - 0x46, 0xc9, 0xf5, 0x92, 0x50, 0x3, 0x5e, 0x0, 0x7, 0xc, 0x64, 0xd1, 0xef, 0x17, 0xbf, 0x45, 0x2, - 0x0, 0x3, 0xb7, 0xf8, 0x43, 0x2, 0x0, 0x1, 0x35, 0x2, 0x0, 0x1d, 0x17, 0x7a, 0x2b, 0x14, 0x17, - 0xf4, 0x1, 0xcb, 0x95, 0x3c, 0xe0, 0x67, 0xf7, 0x5e, 0xf3, 0xbb, 0x33, 0x1e, 0x3c, 0xa2, 0xb2, 0x53, - 0x5d, 0x7b, 0x7b, 0x8f, 0xe2, 0x63, 0x5f, 0x1, 0x0, 0x10, 0xee, 0x14, 0xd4, 0xe0, 0x67, 0x2e, 0x8e, - 0x71, 0x60, 0x38, 0x50, 0x3c, 0xa4, 0xac, 0xe5, 0xf8, 0x1, 0x0, 0x16, 0x8f, 0x49, 0x62, 0x33, 0xd4, - 0xee, 0xde, 0xd9, 0x6b, 0xdf, 0x5c, 0xe, 0xe, 0x78, 0x6d, 0xdc, 0x7d, 0x73, 0x3b, 0x5e, 0xa2, 0xe2, - 0x1, 0x0, 0x1c, 0x82, 0x19, 0x0, 0x81, 0xea, 0x8f, 0xc9, 0x78, 0x67, 0x3e, 0xc2, 0xad, 0x74, 0x4d, - 0x1d, 0x94, 0xc9, 0xa7, 0xdd, 0x4f, 0x5, 0x23, 0x6b, 0x74, 0x75, 0x38, 0x39, 0x8d, 0x0, 0x0, 0xe, - 0x42, 0xcb, 0x4f, 0xa6, 0xf, 0xa8, 0x4a, 0xb9, 0x7c, 0xfe, 0xd7, 0x3e, 0xb1, 0x9c, 0x2}; +// SubscribeRequest 26097 [("v\164\210X\179\135t\206\&0\177\165^\196\160\166\NUL78m}\195Z\147.rbC\177s9",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\255q\244\v\147\250\213/\143\151\&8\168\&9",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("l\168W:Wa\253\147\225\RS\164\242-;r')",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\DC15\NUL\236\249\231\210\141\246\n\ENQ\v\248\RS\USX\132\CAN\214\143w\202\139;]4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\231A\154h\ETX\223a\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2})] [PropSubscriptionIdentifierAvailable 148,PropServerKeepAlive +// 6026,PropRequestProblemInformation 208,PropReceiveMaximum 1568,PropSessionExpiryInterval +// 6779,PropWildcardSubscriptionAvailable 41,PropCorrelationData +// "\161q\177U\178\194&M\208\&9\141\186\248\ACK\240\176\188q\226!\159\206\235\144\f",PropReasonString +// "",PropMessageExpiryInterval 26488,PropWillDelayInterval 12556] +TEST(Subscribe5QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0xaa, 0x1, 0x65, 0xf1, 0x3a, 0x29, 0x94, 0x13, 0x17, 0x8a, 0x17, 0xd0, 0x21, 0x6, 0x20, + 0x11, 0x0, 0x0, 0x1a, 0x7b, 0x28, 0x29, 0x9, 0x0, 0x19, 0xa1, 0x71, 0xb1, 0x55, 0xb2, 0xc2, + 0x26, 0x4d, 0xd0, 0x39, 0x8d, 0xba, 0xf8, 0x6, 0xf0, 0xb0, 0xbc, 0x71, 0xe2, 0x21, 0x9f, 0xce, + 0xeb, 0x90, 0xc, 0x1f, 0x0, 0x0, 0x2, 0x0, 0x0, 0x67, 0x78, 0x18, 0x0, 0x0, 0x31, 0xc, + 0x0, 0x1e, 0x76, 0xa4, 0xd2, 0x58, 0xb3, 0x87, 0x74, 0xce, 0x30, 0xb1, 0xa5, 0x5e, 0xc4, 0xa0, + 0xa6, 0x0, 0x37, 0x38, 0x6d, 0x7d, 0xc3, 0x5a, 0x93, 0x2e, 0x72, 0x62, 0x43, 0xb1, 0x73, 0x39, + 0x2, 0x0, 0xd, 0xff, 0x71, 0xf4, 0xb, 0x93, 0xfa, 0xd5, 0x2f, 0x8f, 0x97, 0x38, 0xa8, 0x39, + 0x0, 0x0, 0x11, 0x6c, 0xa8, 0x57, 0x3a, 0x57, 0x61, 0xfd, 0x93, 0xe1, 0x1e, 0xa4, 0xf2, 0x2d, + 0x3b, 0x72, 0x27, 0x29, 0x0, 0x0, 0x1a, 0x11, 0x35, 0x0, 0xec, 0xf9, 0xe7, 0xd2, 0x8d, 0xf6, + 0xa, 0x5, 0xb, 0xf8, 0x1e, 0x1f, 0x58, 0x84, 0x18, 0xd6, 0x8f, 0x77, 0xca, 0x8b, 0x3b, 0x5d, + 0x34, 0x0, 0x0, 0x8, 0xe7, 0x41, 0x9a, 0x68, 0x3, 0xdf, 0x61, 0xc5, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xc, 0x64, 0xd1, 0xef, 0x17, 0xbf, 0x45}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x76, 0xa4, 0xd2, 0x58, 0xb3, 0x87, 0x74, 0xce, 0x30, 0xb1, + 0xa5, 0x5e, 0xc4, 0xa0, 0xa6, 0x0, 0x37, 0x38, 0x6d, 0x7d, + 0xc3, 0x5a, 0x93, 0x2e, 0x72, 0x62, 0x43, 0xb1, 0x73, 0x39}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb7, 0xf8, 0x43}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xff, 0x71, 0xf4, 0xb, 0x93, 0xfa, 0xd5, 0x2f, 0x8f, 0x97, 0x38, 0xa8, 0x39}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x35}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6c, 0xa8, 0x57, 0x3a, 0x57, 0x61, 0xfd, 0x93, 0xe1, + 0x1e, 0xa4, 0xf2, 0x2d, 0x3b, 0x72, 0x27, 0x29}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x17, 0x7a, 0x2b, 0x14, 0x17, 0xf4, 0x1, 0xcb, 0x95, 0x3c, - 0xe0, 0x67, 0xf7, 0x5e, 0xf3, 0xbb, 0x33, 0x1e, 0x3c, 0xa2, - 0xb2, 0x53, 0x5d, 0x7b, 0x7b, 0x8f, 0xe2, 0x63, 0x5f}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x11, 0x35, 0x0, 0xec, 0xf9, 0xe7, 0xd2, 0x8d, 0xf6, 0xa, 0x5, 0xb, 0xf8, + 0x1e, 0x1f, 0x58, 0x84, 0x18, 0xd6, 0x8f, 0x77, 0xca, 0x8b, 0x3b, 0x5d, 0x34}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xee, 0x14, 0xd4, 0xe0, 0x67, 0x2e, 0x8e, 0x71, - 0x60, 0x38, 0x50, 0x3c, 0xa4, 0xac, 0xe5, 0xf8}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xe7, 0x41, 0x9a, 0x68, 0x3, 0xdf, 0x61, 0xc5}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8f, 0x49, 0x62, 0x33, 0xd4, 0xee, 0xde, 0xd9, 0x6b, 0xdf, 0x5c, - 0xe, 0xe, 0x78, 0x6d, 0xdc, 0x7d, 0x73, 0x3b, 0x5e, 0xa2, 0xe2}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x82, 0x19, 0x0, 0x81, 0xea, 0x8f, 0xc9, 0x78, 0x67, 0x3e, - 0xc2, 0xad, 0x74, 0x4d, 0x1d, 0x94, 0xc9, 0xa7, 0xdd, 0x4f, - 0x5, 0x23, 0x6b, 0x74, 0x75, 0x38, 0x39, 0x8d}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x42, 0xcb, 0x4f, 0xa6, 0xf, 0xa8, 0x4a, 0xb9, 0x7c, 0xfe, 0xd7, 0x3e, 0xb1, 0x9c}; - lwmqtt_string_t topic_filter_s7 = {14, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x22, 0x2a, 0x38, 0xad, 0x9, 0x22, 0x0, 0xa1, 0x46, 0xc9, 0xf5, 0x92, 0x50, 0x3, 0x5e}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0xa1, 0x71, 0xb1, 0x55, 0xb2, 0xc2, 0x26, 0x4d, 0xd0, 0x39, 0x8d, 0xba, 0xf8, + 0x6, 0xf0, 0xb0, 0xbc, 0x71, 0xe2, 0x21, 0x9f, 0xce, 0xeb, 0x90, 0xc}; + uint8_t bytesprops1[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6026}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1568}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6779}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26488}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12556}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8713, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26097, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22186 [("\SOs\230\200\227!\208>\aj\134P\159@\b\245\135B\251\254\225\t\197\222\144",SubOptions +// SubscribeRequest 25578 [("\151\169\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("\129L\179D\b\\\136\147\&3\187\140\205\216\221\151\ENQ\149\128\155\211\210E\ENQ\240\&8q\203\180",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("3\163Q\180\141+\131\234M\208\187:\NULW\165\227R1\198\131\168\176\185z\149w",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\131\140\149\244p\253\129\DC2\DC1c#h\224qu\128\166\SICd\174\138\185",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\ESCp",SubOptions {_retainHandling +// QoS2}),("F\219rm{\255\FS\161\228\207\147\157(\236.\DC1\150\EM$|\138p\253$u\SYN8\237\ENQ",SubOptions {_retainHandling // = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("9\209\165\252Ue\146\138\159\n%\SOW\252D\212",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAuthenticationMethod "\209zPGD{e$"] -TEST(Subscribe5QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x79, 0x56, 0xaa, 0xb, 0x15, 0x0, 0x8, 0xd1, 0x7a, 0x50, 0x47, 0x44, 0x7b, 0x65, 0x24, - 0x0, 0x19, 0xe, 0x73, 0xe6, 0xc8, 0xe3, 0x21, 0xd0, 0x3e, 0x7, 0x6a, 0x86, 0x50, 0x9f, 0x40, - 0x8, 0xf5, 0x87, 0x42, 0xfb, 0xfe, 0xe1, 0x9, 0xc5, 0xde, 0x90, 0x1, 0x0, 0x1a, 0x33, 0xa3, - 0x51, 0xb4, 0x8d, 0x2b, 0x83, 0xea, 0x4d, 0xd0, 0xbb, 0x3a, 0x0, 0x57, 0xa5, 0xe3, 0x52, 0x31, - 0xc6, 0x83, 0xa8, 0xb0, 0xb9, 0x7a, 0x95, 0x77, 0x2, 0x0, 0x17, 0x83, 0x8c, 0x95, 0xf4, 0x70, - 0xfd, 0x81, 0x12, 0x11, 0x63, 0x23, 0x68, 0xe0, 0x71, 0x75, 0x80, 0xa6, 0xf, 0x43, 0x64, 0xae, - 0x8a, 0xb9, 0x2, 0x0, 0x2, 0x1b, 0x70, 0x1, 0x0, 0x10, 0x39, 0xd1, 0xa5, 0xfc, 0x55, 0x65, - 0x92, 0x8a, 0x9f, 0xa, 0x25, 0xe, 0x57, 0xfc, 0x44, 0xd4, 0x1}; +// QoS0}),("\196\SO\SI\252\189a\168*\239<\226M(\228'\183H\223\&9\165\220\ACK\229R\158\151\209n\151\248",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReasonString +// "\211\230\aA;\158,;\159\208\233\171\239\224\206",PropRequestResponseInformation 10] +TEST(Subscribe5QCTest, Encode24) { + uint8_t pkt[] = {0x82, 0x7d, 0x63, 0xea, 0x14, 0x1f, 0x0, 0xf, 0xd3, 0xe6, 0x7, 0x41, 0x3b, 0x9e, 0x2c, 0x3b, + 0x9f, 0xd0, 0xe9, 0xab, 0xef, 0xe0, 0xce, 0x19, 0xa, 0x0, 0x3, 0x97, 0xa9, 0xa, 0x0, 0x0, + 0x1c, 0x81, 0x4c, 0xb3, 0x44, 0x8, 0x5c, 0x88, 0x93, 0x33, 0xbb, 0x8c, 0xcd, 0xd8, 0xdd, 0x97, + 0x5, 0x95, 0x80, 0x9b, 0xd3, 0xd2, 0x45, 0x5, 0xf0, 0x38, 0x71, 0xcb, 0xb4, 0x2, 0x0, 0x1d, + 0x46, 0xdb, 0x72, 0x6d, 0x7b, 0xff, 0x1c, 0xa1, 0xe4, 0xcf, 0x93, 0x9d, 0x28, 0xec, 0x2e, 0x11, + 0x96, 0x19, 0x24, 0x7c, 0x8a, 0x70, 0xfd, 0x24, 0x75, 0x16, 0x38, 0xed, 0x5, 0x0, 0x0, 0x1e, + 0xc4, 0xe, 0xf, 0xfc, 0xbd, 0x61, 0xa8, 0x2a, 0xef, 0x3c, 0xe2, 0x4d, 0x28, 0xe4, 0x27, 0xb7, + 0x48, 0xdf, 0x39, 0xa5, 0xdc, 0x6, 0xe5, 0x52, 0x9e, 0x97, 0xd1, 0x6e, 0x97, 0xf8, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xe, 0x73, 0xe6, 0xc8, 0xe3, 0x21, 0xd0, 0x3e, 0x7, 0x6a, 0x86, 0x50, 0x9f, - 0x40, 0x8, 0xf5, 0x87, 0x42, 0xfb, 0xfe, 0xe1, 0x9, 0xc5, 0xde, 0x90}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x97, 0xa9, 0xa}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x33, 0xa3, 0x51, 0xb4, 0x8d, 0x2b, 0x83, 0xea, 0x4d, 0xd0, 0xbb, 0x3a, 0x0, - 0x57, 0xa5, 0xe3, 0x52, 0x31, 0xc6, 0x83, 0xa8, 0xb0, 0xb9, 0x7a, 0x95, 0x77}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x81, 0x4c, 0xb3, 0x44, 0x8, 0x5c, 0x88, 0x93, 0x33, 0xbb, + 0x8c, 0xcd, 0xd8, 0xdd, 0x97, 0x5, 0x95, 0x80, 0x9b, 0xd3, + 0xd2, 0x45, 0x5, 0xf0, 0x38, 0x71, 0xcb, 0xb4}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x83, 0x8c, 0x95, 0xf4, 0x70, 0xfd, 0x81, 0x12, 0x11, 0x63, 0x23, 0x68, - 0xe0, 0x71, 0x75, 0x80, 0xa6, 0xf, 0x43, 0x64, 0xae, 0x8a, 0xb9}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x46, 0xdb, 0x72, 0x6d, 0x7b, 0xff, 0x1c, 0xa1, 0xe4, 0xcf, + 0x93, 0x9d, 0x28, 0xec, 0x2e, 0x11, 0x96, 0x19, 0x24, 0x7c, + 0x8a, 0x70, 0xfd, 0x24, 0x75, 0x16, 0x38, 0xed, 0x5}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1b, 0x70}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc4, 0xe, 0xf, 0xfc, 0xbd, 0x61, 0xa8, 0x2a, 0xef, 0x3c, + 0xe2, 0x4d, 0x28, 0xe4, 0x27, 0xb7, 0x48, 0xdf, 0x39, 0xa5, + 0xdc, 0x6, 0xe5, 0x52, 0x9e, 0x97, 0xd1, 0x6e, 0x97, 0xf8}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x39, 0xd1, 0xa5, 0xfc, 0x55, 0x65, 0x92, 0x8a, - 0x9f, 0xa, 0x25, 0xe, 0x57, 0xfc, 0x44, 0xd4}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xd1, 0x7a, 0x50, 0x47, 0x44, 0x7b, 0x65, 0x24}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xd3, 0xe6, 0x7, 0x41, 0x3b, 0x9e, 0x2c, 0x3b, 0x9f, 0xd0, 0xe9, 0xab, 0xef, 0xe0, 0xce}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 10}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22186, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25578, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 16934 [("\ENQ\US\231\182\242\224Rp\134\v\227Heh\CAN\168\243\231\181k7&{\n",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("W\201\226%\229\246\253\183\\\FS\242-\246I\DC4\DLE\188y\234\&5\240\DC1\189u\152\SO\240_",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\196\155\175",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("s\255c&\US\DLE@u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("I4\236\129I\\c\187\205\211J",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 14161 [("\242\138%q\US\GSY\176\129}=\247",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("6\246\129_\248\224\199\160MK\168\141hr\171",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\251\&0:\197\176N\128\&0\194\204\246\NAK\236i}|\154\223c\f\220",SubOptions {_retainHandling = +// QoS1}),("\STX\132g\171\169\132\132\181\237\223\182gx,",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("g\EMP\174+`\222\SUBP",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("Or\209\133\140\155\171\243\164J\229\235\242\246\132k}\ENQ\138\188\215\185\150%xv)P\ACK",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\169\247\243Q\241\192)\133%\156\243\251\169\\\239\187E\234\163\194\141\&2\246*v\192\175\ETX\201",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropMaximumPacketSize 16232,PropRetainAvailable 225,PropSharedSubscriptionAvailable 54,PropRetainAvailable -// 75,PropMaximumPacketSize 25795,PropRetainAvailable 163,PropReceiveMaximum 32676,PropRequestResponseInformation -// 93,PropMaximumQoS 79,PropMessageExpiryInterval 4955,PropCorrelationData -// "5\SI\206\f\247\EM5",PropSharedSubscriptionAvailable 194,PropWillDelayInterval 26681,PropTopicAlias 16992] -TEST(Subscribe5QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0xfb, 0x1, 0x42, 0x26, 0x32, 0x27, 0x0, 0x0, 0x3f, 0x68, 0x25, 0xe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f3, 0xa4, 0x4a, 0xe5, 0xeb, - 0xf2, 0xf6, 0x84, 0x6b, 0x7d, 0x5, 0x8a, 0xbc, 0xd7, 0xb9, 0x96, 0x25, 0x78, 0x76, 0x29, 0x50, 0x6, - 0x0, 0x0, 0x1d, 0xa9, 0xf7, 0xf3, 0x51, 0xf1, 0xc0, 0x29, 0x85, 0x25, 0x9c, 0xf3, 0xfb, 0xa9, 0x5c, - 0xef, 0xbb, 0x45, 0xea, 0xa3, 0xc2, 0x8d, 0x32, 0xf6, 0x2a, 0x76, 0xc0, 0xaf, 0x3, 0xc9, 0x0}; +// QoS0}),("b\255\135\184;\253\174\185R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\236:H\144\155\245+7\DLE\145K>\160Hi\229",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRetainAvailable +// 229,PropSharedSubscriptionAvailable 181,PropCorrelationData "\168@\222\135S\201,v\DC3\EMCs\188",PropServerReference +// "#\254\ETXo%\246\FS\140UU\199R",PropMaximumPacketSize 4981,PropRequestResponseInformation 181,PropResponseInformation +// "K\132N\150\155f, \ENQ",PropMaximumQoS 117,PropTopicAliasMaximum 19076,PropSharedSubscriptionAvailable +// 135,PropReceiveMaximum 2513,PropTopicAliasMaximum 21119,PropAuthenticationData +// "<\167\NUL6\EMj\162\178\172\131D\181\176\177",PropMaximumQoS 149,PropWillDelayInterval +// 14956,PropSubscriptionIdentifier 2,PropMessageExpiryInterval 1459,PropSubscriptionIdentifierAvailable +// 38,PropContentType "D\237w\230`^\229o\237\&2\185k",PropRetainAvailable 253,PropResponseInformation ""] +TEST(Subscribe5QCTest, Encode25) { + uint8_t pkt[] = {0x82, 0xc6, 0x1, 0x37, 0x51, 0x78, 0x25, 0xe5, 0x2a, 0xb5, 0x9, 0x0, 0xd, 0xa8, 0x40, 0xde, 0x87, + 0x53, 0xc9, 0x2c, 0x76, 0x13, 0x19, 0x43, 0x73, 0xbc, 0x1c, 0x0, 0xc, 0x23, 0xfe, 0x3, 0x6f, 0x25, + 0xf6, 0x1c, 0x8c, 0x55, 0x55, 0xc7, 0x52, 0x27, 0x0, 0x0, 0x13, 0x75, 0x19, 0xb5, 0x1a, 0x0, 0x9, + 0x4b, 0x84, 0x4e, 0x96, 0x9b, 0x66, 0x2c, 0x20, 0x5, 0x24, 0x75, 0x22, 0x4a, 0x84, 0x2a, 0x87, 0x21, + 0x9, 0xd1, 0x22, 0x52, 0x7f, 0x16, 0x0, 0xe, 0x3c, 0xa7, 0x0, 0x36, 0x19, 0x6a, 0xa2, 0xb2, 0xac, + 0x83, 0x44, 0xb5, 0xb0, 0xb1, 0x24, 0x95, 0x18, 0x0, 0x0, 0x3a, 0x6c, 0xb, 0x2, 0x2, 0x0, 0x0, + 0x5, 0xb3, 0x29, 0x26, 0x3, 0x0, 0xc, 0x44, 0xed, 0x77, 0xe6, 0x60, 0x5e, 0xe5, 0x6f, 0xed, 0x32, + 0xb9, 0x6b, 0x25, 0xfd, 0x1a, 0x0, 0x0, 0x0, 0xc, 0xf2, 0x8a, 0x25, 0x71, 0x1f, 0x1d, 0x59, 0xb0, + 0x81, 0x7d, 0x3d, 0xf7, 0x1, 0x0, 0xe, 0x2, 0x84, 0x67, 0xab, 0xa9, 0x84, 0x84, 0xb5, 0xed, 0xdf, + 0xb6, 0x67, 0x78, 0x2c, 0x0, 0x0, 0x9, 0x67, 0x19, 0x50, 0xae, 0x2b, 0x60, 0xde, 0x1a, 0x50, 0x0, + 0x0, 0x9, 0x62, 0xff, 0x87, 0xb8, 0x3b, 0xfd, 0xae, 0xb9, 0x52, 0x2, 0x0, 0x10, 0xec, 0x3a, 0x48, + 0x90, 0x9b, 0xf5, 0x2b, 0x37, 0x10, 0x91, 0x4b, 0x3e, 0xa0, 0x48, 0x69, 0xe5, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x5, 0x1f, 0xe7, 0xb6, 0xf2, 0xe0, 0x52, 0x70, 0x86, 0xb, 0xe3, 0x48, - 0x65, 0x68, 0x18, 0xa8, 0xf3, 0xe7, 0xb5, 0x6b, 0x37, 0x26, 0x7b, 0xa}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xf2, 0x8a, 0x25, 0x71, 0x1f, 0x1d, 0x59, 0xb0, 0x81, 0x7d, 0x3d, 0xf7}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x57, 0xc9, 0xe2, 0x25, 0xe5, 0xf6, 0xfd, 0xb7, 0x5c, 0x1c, - 0xf2, 0x2d, 0xf6, 0x49, 0x14, 0x10, 0xbc, 0x79, 0xea, 0x35, - 0xf0, 0x11, 0xbd, 0x75, 0x98, 0xe, 0xf0, 0x5f}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2, 0x84, 0x67, 0xab, 0xa9, 0x84, 0x84, 0xb5, 0xed, 0xdf, 0xb6, 0x67, 0x78, 0x2c}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc4, 0x9b, 0xaf}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x67, 0x19, 0x50, 0xae, 0x2b, 0x60, 0xde, 0x1a, 0x50}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x62, 0xff, 0x87, 0xb8, 0x3b, 0xfd, 0xae, 0xb9, 0x52}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x73, 0xff, 0x63, 0x26, 0x1f, 0x10, 0x40, 0x75}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xec, 0x3a, 0x48, 0x90, 0x9b, 0xf5, 0x2b, 0x37, + 0x10, 0x91, 0x4b, 0x3e, 0xa0, 0x48, 0x69, 0xe5}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x49, 0x34, 0xec, 0x81, 0x49, 0x5c, 0x63, 0xbb, 0xcd, 0xd3, 0x4a}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x36, 0xf6, 0x81, 0x5f, 0xf8, 0xe0, 0xc7, 0xa0, - 0x4d, 0x4b, 0xa8, 0x8d, 0x68, 0x72, 0xab}; - lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xfb, 0x30, 0x3a, 0xc5, 0xb0, 0x4e, 0x80, 0x30, 0xc2, 0xcc, 0xf6, - 0x15, 0xec, 0x69, 0x7d, 0x7c, 0x9a, 0xdf, 0x63, 0xc, 0xdc}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x4f, 0x72, 0xd1, 0x85, 0x8c, 0x9b, 0xab, 0xf3, 0xa4, 0x4a, - 0xe5, 0xeb, 0xf2, 0xf6, 0x84, 0x6b, 0x7d, 0x5, 0x8a, 0xbc, - 0xd7, 0xb9, 0x96, 0x25, 0x78, 0x76, 0x29, 0x50, 0x6}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa9, 0xf7, 0xf3, 0x51, 0xf1, 0xc0, 0x29, 0x85, 0x25, 0x9c, - 0xf3, 0xfb, 0xa9, 0x5c, 0xef, 0xbb, 0x45, 0xea, 0xa3, 0xc2, - 0x8d, 0x32, 0xf6, 0x2a, 0x76, 0xc0, 0xaf, 0x3, 0xc9}; - lwmqtt_string_t topic_filter_s9 = {29, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, - LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x35, 0xf, 0xce, 0xc, 0xf7, 0x19, 0x35}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xa8, 0x40, 0xde, 0x87, 0x53, 0xc9, 0x2c, 0x76, 0x13, 0x19, 0x43, 0x73, 0xbc}; + uint8_t bytesprops1[] = {0x23, 0xfe, 0x3, 0x6f, 0x25, 0xf6, 0x1c, 0x8c, 0x55, 0x55, 0xc7, 0x52}; + uint8_t bytesprops2[] = {0x4b, 0x84, 0x4e, 0x96, 0x9b, 0x66, 0x2c, 0x20, 0x5}; + uint8_t bytesprops3[] = {0x3c, 0xa7, 0x0, 0x36, 0x19, 0x6a, 0xa2, 0xb2, 0xac, 0x83, 0x44, 0xb5, 0xb0, 0xb1}; + uint8_t bytesprops4[] = {0x44, 0xed, 0x77, 0xe6, 0x60, 0x5e, 0xe5, 0x6f, 0xed, 0x32, 0xb9, 0x6b}; + uint8_t bytesprops5[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16232}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25795}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32676}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4955}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26681}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16992}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4981}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19076}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2513}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21119}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14956}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1459}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16934, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14161, 5, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19450 [("-\157He_V\165gmY\135\DC1\242\b\132\141\234\205\247",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("X+\208\242 -// 0\199d9\203\NAK)\182AKX:\187*\247|\177\229",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("-\200\196\v\SON\152\156\131\233\ESC\181(\174\ESC_\182(",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\245",SubOptions +// SubscribeRequest 3024 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\151\241\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("O\234$\nG\215\255\&2\ETB\153\&8\213\230\161zr\149C\SOH",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\"\DLE\152\151\134\RS\b7\133\240",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),("\155\200\218O\139Q\137\183r>\FSZ()\163@C\240\153\197\175\164w\237\244\214",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(":%\214!\232hqh\239\137?\SYN\253\231\130\239Ki",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\211\242#\201}dL\240\189\150\251\185\231~?\227\158\152z\251\SUB\DELS\174E",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("%\GS>\174RN3\188KZ\169\ETB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable 66,PropUserProperty -// "\239r\235n\146\&6\EOT\162\193z|\DC3l\176\217\238r|\138\249^\245\EM\207\215\228" -// "y\147c9\137j-\230\189\DLE/k\189\DLE}\134\240\SI\255>\140<",PropAuthenticationData -// "\US\210\SO*\139\EOT!\208\230\191\151\246\207\175\170\209\152C\220\DC2\146\FS\131\135",PropAuthenticationData -// "\196\157U\211\r\233\130\EM{\131\197%\\\168s",PropReasonString "\237\DC2\244\202\154\\\252\226\t",PropServerReference -// "\141g5\ETXV\193\"\r\218HU\ESCY\222+_\213\185\SO\188",PropAuthenticationData -// "\ETX\228\224\143\243\234\"ld\161\233\193\243W\187&\145\139y\195~1\202\255\254\231\&1",PropWillDelayInterval -// 16995,PropAuthenticationData "!\163\179\196OQ\201\234\147W\140\224",PropServerKeepAlive -// 9589,PropAssignedClientIdentifier -// "\218=\228~O\GSN\SYN\137\128tP\151\149\211$\197%\215a\249\135\162\167\230:^\142",PropAuthenticationData -// "\US\237\184s\148\161\162\FS{\204.@{N\151\146\DC4|\DC1\135v\138\209\199w\171aDK",PropRequestProblemInformation -// 225,PropWillDelayInterval 22189,PropRetainAvailable 69,PropCorrelationData -// "T|H${3\147\FSz\ESC<\199~\245\DC1t\159#\193\234\205\139.\DC3",PropSharedSubscriptionAvailable -// 87,PropSharedSubscriptionAvailable 195,PropWildcardSubscriptionAvailable 248,PropServerReference -// "\162y\196\223\GS\200\DC3\188\b\197yr\DC2\DC4}A\131\224M\151ND\NAK",PropRequestProblemInformation 2] -TEST(Subscribe5QCTest, Encode7) { - uint8_t pkt[] = { - 0x82, 0xf8, 0x3, 0x4b, 0xfa, 0xc1, 0x2, 0x2a, 0x42, 0x26, 0x0, 0x1a, 0xef, 0x72, 0xeb, 0x6e, 0x92, 0x36, 0x4, - 0xa2, 0xc1, 0x7a, 0x7c, 0x13, 0x6c, 0xb0, 0xd9, 0xee, 0x72, 0x7c, 0x8a, 0xf9, 0x5e, 0xf5, 0x19, 0xcf, 0xd7, 0xe4, - 0x0, 0x16, 0x79, 0x93, 0x63, 0x39, 0x89, 0x6a, 0x2d, 0xe6, 0xbd, 0x10, 0x2f, 0x6b, 0xbd, 0x10, 0x7d, 0x86, 0xf0, - 0xf, 0xff, 0x3e, 0x8c, 0x3c, 0x16, 0x0, 0x18, 0x1f, 0xd2, 0xe, 0x2a, 0x8b, 0x4, 0x21, 0xd0, 0xe6, 0xbf, 0x97, - 0xf6, 0xcf, 0xaf, 0xaa, 0xd1, 0x98, 0x43, 0xdc, 0x12, 0x92, 0x1c, 0x83, 0x87, 0x16, 0x0, 0xf, 0xc4, 0x9d, 0x55, - 0xd3, 0xd, 0xe9, 0x82, 0x19, 0x7b, 0x83, 0xc5, 0x25, 0x5c, 0xa8, 0x73, 0x1f, 0x0, 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x3f, 0xe3, 0x9e, 0x98, 0x7a, 0xfb, 0x1a, 0x7f, 0x53, 0xae, 0x45, 0x1, 0x0, 0xc, - 0x25, 0x1d, 0x3e, 0xae, 0x52, 0x4e, 0x33, 0xbc, 0x4b, 0x5a, 0xa9, 0x17, 0x2}; +// QoS0}),(".\ETB\199\SYN\173\&1M\183\r\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\RSe\157a\193\189\&8%\189\238lr\136\251\194l\\\219ii",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\n\222\134\168\193\203",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS1})] [PropSubscriptionIdentifier 22,PropSubscriptionIdentifierAvailable +// 190,PropSessionExpiryInterval 31925,PropRetainAvailable 98,PropRequestResponseInformation 158,PropMaximumPacketSize +// 29435,PropAssignedClientIdentifier +// "n\134\201Y\ACK\225;%\USv\239v$r\229H\247\255\155<\SYN\235K\233",PropServerKeepAlive +// 12673,PropRequestProblemInformation 198,PropReasonString +// "\203\253!A\ETX\198\166\145\160\215\147\f\170\EOT\216\168\230\245\SI",PropServerReference "\174'",PropTopicAlias +// 17867] +TEST(Subscribe5QCTest, Encode26) { + uint8_t pkt[] = {0x82, 0x9f, 0x1, 0xb, 0xd0, 0x50, 0xb, 0x16, 0x29, 0xbe, 0x11, 0x0, 0x0, 0x7c, 0xb5, 0x25, 0x62, + 0x19, 0x9e, 0x27, 0x0, 0x0, 0x72, 0xfb, 0x12, 0x0, 0x18, 0x6e, 0x86, 0xc9, 0x59, 0x6, 0xe1, 0x3b, + 0x25, 0x1f, 0x76, 0xef, 0x76, 0x24, 0x72, 0xe5, 0x48, 0xf7, 0xff, 0x9b, 0x3c, 0x16, 0xeb, 0x4b, 0xe9, + 0x13, 0x31, 0x81, 0x17, 0xc6, 0x1f, 0x0, 0x13, 0xcb, 0xfd, 0x21, 0x41, 0x3, 0xc6, 0xa6, 0x91, 0xa0, + 0xd7, 0x93, 0xc, 0xaa, 0x4, 0xd8, 0xa8, 0xe6, 0xf5, 0xf, 0x1c, 0x0, 0x2, 0xae, 0x27, 0x23, 0x45, + 0xcb, 0x0, 0x0, 0x1, 0x0, 0x3, 0x97, 0xf1, 0xd9, 0x1, 0x0, 0x13, 0x4f, 0xea, 0x24, 0xa, 0x47, + 0xd7, 0xff, 0x32, 0x17, 0x99, 0x38, 0xd5, 0xe6, 0xa1, 0x7a, 0x72, 0x95, 0x43, 0x1, 0x0, 0x0, 0xa, + 0x2e, 0x17, 0xc7, 0x16, 0xad, 0x31, 0x4d, 0xb7, 0xd, 0xe8, 0x1, 0x0, 0x14, 0x1e, 0x65, 0x9d, 0x61, + 0xc1, 0xbd, 0x38, 0x25, 0xbd, 0xee, 0x6c, 0x72, 0x88, 0xfb, 0xc2, 0x6c, 0x5c, 0xdb, 0x69, 0x69, 0x0, + 0x0, 0x6, 0xa, 0xde, 0x86, 0xa8, 0xc1, 0xcb, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x2d, 0x9d, 0x48, 0x65, 0x5f, 0x56, 0xa5, 0x67, 0x6d, 0x59, - 0x87, 0x11, 0xf2, 0x8, 0x84, 0x8d, 0xea, 0xcd, 0xf7}; - lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x58, 0x2b, 0xd0, 0xf2, 0x20, 0x30, 0xc7, 0x64, 0x39, 0xcb, 0x15, 0x29, - 0xb6, 0x41, 0x4b, 0x58, 0x3a, 0xbb, 0x2a, 0xf7, 0x7c, 0xb1, 0xe5}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x97, 0xf1, 0xd9}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2d, 0xc8, 0xc4, 0xb, 0xe, 0x4e, 0x98, 0x9c, 0x83, - 0xe9, 0x1b, 0xb5, 0x28, 0xae, 0x1b, 0x5f, 0xb6, 0x28}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4f, 0xea, 0x24, 0xa, 0x47, 0xd7, 0xff, 0x32, 0x17, 0x99, + 0x38, 0xd5, 0xe6, 0xa1, 0x7a, 0x72, 0x95, 0x43, 0x1}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf5}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x2e, 0x17, 0xc7, 0x16, 0xad, 0x31, 0x4d, 0xb7, 0xd, 0xe8}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x22, 0x10, 0x98, 0x97, 0x86, 0x1e, 0x8, 0x37, 0x85, 0xf0}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x1e, 0x65, 0x9d, 0x61, 0xc1, 0xbd, 0x38, 0x25, 0xbd, 0xee, + 0x6c, 0x72, 0x88, 0xfb, 0xc2, 0x6c, 0x5c, 0xdb, 0x69, 0x69}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x9b, 0xc8, 0xda, 0x4f, 0x8b, 0x51, 0x89, 0xb7, 0x72, 0x3e, 0x1c, 0x5a, 0x28, - 0x29, 0xa3, 0x40, 0x43, 0xf0, 0x99, 0xc5, 0xaf, 0xa4, 0x77, 0xed, 0xf4, 0xd6}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xa, 0xde, 0x86, 0xa8, 0xc1, 0xcb}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3a, 0x25, 0xd6, 0x21, 0xe8, 0x68, 0x71, 0x68, 0xef, - 0x89, 0x3f, 0x16, 0xfd, 0xe7, 0x82, 0xef, 0x4b, 0x69}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xd3, 0xf2, 0x23, 0xc9, 0x7d, 0x64, 0x4c, 0xf0, 0xbd, 0x96, 0xfb, 0xb9, 0xe7, - 0x7e, 0x3f, 0xe3, 0x9e, 0x98, 0x7a, 0xfb, 0x1a, 0x7f, 0x53, 0xae, 0x45}; - lwmqtt_string_t topic_filter_s7 = {25, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x25, 0x1d, 0x3e, 0xae, 0x52, 0x4e, 0x33, 0xbc, 0x4b, 0x5a, 0xa9, 0x17}; - lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops1[] = {0x79, 0x93, 0x63, 0x39, 0x89, 0x6a, 0x2d, 0xe6, 0xbd, 0x10, 0x2f, - 0x6b, 0xbd, 0x10, 0x7d, 0x86, 0xf0, 0xf, 0xff, 0x3e, 0x8c, 0x3c}; - uint8_t bytesprops0[] = {0xef, 0x72, 0xeb, 0x6e, 0x92, 0x36, 0x4, 0xa2, 0xc1, 0x7a, 0x7c, 0x13, 0x6c, - 0xb0, 0xd9, 0xee, 0x72, 0x7c, 0x8a, 0xf9, 0x5e, 0xf5, 0x19, 0xcf, 0xd7, 0xe4}; - uint8_t bytesprops2[] = {0x1f, 0xd2, 0xe, 0x2a, 0x8b, 0x4, 0x21, 0xd0, 0xe6, 0xbf, 0x97, 0xf6, - 0xcf, 0xaf, 0xaa, 0xd1, 0x98, 0x43, 0xdc, 0x12, 0x92, 0x1c, 0x83, 0x87}; - uint8_t bytesprops3[] = {0xc4, 0x9d, 0x55, 0xd3, 0xd, 0xe9, 0x82, 0x19, 0x7b, 0x83, 0xc5, 0x25, 0x5c, 0xa8, 0x73}; - uint8_t bytesprops4[] = {0xed, 0x12, 0xf4, 0xca, 0x9a, 0x5c, 0xfc, 0xe2, 0x9}; - uint8_t bytesprops5[] = {0x8d, 0x67, 0x35, 0x3, 0x56, 0xc1, 0x22, 0xd, 0xda, 0x48, - 0x55, 0x1b, 0x59, 0xde, 0x2b, 0x5f, 0xd5, 0xb9, 0xe, 0xbc}; - uint8_t bytesprops6[] = {0x3, 0xe4, 0xe0, 0x8f, 0xf3, 0xea, 0x22, 0x6c, 0x64, 0xa1, 0xe9, 0xc1, 0xf3, 0x57, - 0xbb, 0x26, 0x91, 0x8b, 0x79, 0xc3, 0x7e, 0x31, 0xca, 0xff, 0xfe, 0xe7, 0x31}; - uint8_t bytesprops7[] = {0x21, 0xa3, 0xb3, 0xc4, 0x4f, 0x51, 0xc9, 0xea, 0x93, 0x57, 0x8c, 0xe0}; - uint8_t bytesprops8[] = {0xda, 0x3d, 0xe4, 0x7e, 0x4f, 0x1d, 0x4e, 0x16, 0x89, 0x80, 0x74, 0x50, 0x97, 0x95, - 0xd3, 0x24, 0xc5, 0x25, 0xd7, 0x61, 0xf9, 0x87, 0xa2, 0xa7, 0xe6, 0x3a, 0x5e, 0x8e}; - uint8_t bytesprops9[] = {0x1f, 0xed, 0xb8, 0x73, 0x94, 0xa1, 0xa2, 0x1c, 0x7b, 0xcc, 0x2e, 0x40, 0x7b, 0x4e, 0x97, - 0x92, 0x14, 0x7c, 0x11, 0x87, 0x76, 0x8a, 0xd1, 0xc7, 0x77, 0xab, 0x61, 0x44, 0x4b}; - uint8_t bytesprops10[] = {0x54, 0x7c, 0x48, 0x24, 0x7b, 0x33, 0x93, 0x1c, 0x7a, 0x1b, 0x3c, 0xc7, - 0x7e, 0xf5, 0x11, 0x74, 0x9f, 0x23, 0xc1, 0xea, 0xcd, 0x8b, 0x2e, 0x13}; - uint8_t bytesprops11[] = {0xa2, 0x79, 0xc4, 0xdf, 0x1d, 0xc8, 0x13, 0xbc, 0x8, 0xc5, 0x79, 0x72, - 0x12, 0x14, 0x7d, 0x41, 0x83, 0xe0, 0x4d, 0x97, 0x4e, 0x44, 0x15}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0x6e, 0x86, 0xc9, 0x59, 0x6, 0xe1, 0x3b, 0x25, 0x1f, 0x76, 0xef, 0x76, + 0x24, 0x72, 0xe5, 0x48, 0xf7, 0xff, 0x9b, 0x3c, 0x16, 0xeb, 0x4b, 0xe9}; + uint8_t bytesprops1[] = {0xcb, 0xfd, 0x21, 0x41, 0x3, 0xc6, 0xa6, 0x91, 0xa0, 0xd7, + 0x93, 0xc, 0xaa, 0x4, 0xd8, 0xa8, 0xe6, 0xf5, 0xf}; + uint8_t bytesprops2[] = {0xae, 0x27}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops0}, .v = {22, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16995}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9589}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22189}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31925}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29435}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12673}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17867}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19450, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3024, 6, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18336 [("M\159.\194\192\a\198\148]\234\233",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\189\222HE\204\236\228\133\ACK*\236X\128\&0\229;n\245ORb\196",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 9912 [("\204\190\NUL\161\131\ETB\243~\129\US,\199",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DC1\203\202\209\&0T*Orh\223",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] +// [PropSessionExpiryInterval 23397,PropMessageExpiryInterval 16143,PropPayloadFormatIndicator +// 2,PropSubscriptionIdentifier 28,PropWildcardSubscriptionAvailable 213,PropAuthenticationData +// "\203\203\200",PropServerReference +// "\152$\189\SYN\199Nol\157q(\249\200\136\DC2;\183\188\182H\176\246\DC3\155\135\234\196\192f2",PropUserProperty +// "\177\250R\155\221\159" "\134\190V\142z\v\RS\fS\STX4\220\226(.\166@Y\DC4\161C\231f\188\245\NUL",PropMaximumPacketSize +// 31086,PropMessageExpiryInterval 23028,PropResponseInformation +// "}\137\226\219\STX\232\167}\186{7\207#\235\SO\141B\177\203\146m\199\DC2\SYN\164\207$@",PropCorrelationData +// "\200\141\155\249\214g\178\NAK\195HO\244J;\137\136\SYN\174y\216J\139\&5\198\232\247\171$\209",PropAssignedClientIdentifier +// "\254",PropCorrelationData ";W\145\174\193\229\224",PropAuthenticationMethod +// "\163\175\160\202\SYNo\SYN\226\220\235\208\r\183&&",PropServerKeepAlive 16294,PropTopicAliasMaximum +// 7201,PropRetainAvailable 72,PropAuthenticationData "_",PropServerKeepAlive 9880] +TEST(Subscribe5QCTest, Encode27) { + uint8_t pkt[] = {0x82, 0xf5, 0x1, 0x26, 0xb8, 0xd4, 0x1, 0x11, 0x0, 0x0, 0x5b, 0x65, 0x2, 0x0, 0x0, 0x3f, 0xf, + 0x1, 0x2, 0xb, 0x1c, 0x28, 0xd5, 0x16, 0x0, 0x3, 0xcb, 0xcb, 0xc8, 0x1c, 0x0, 0x1e, 0x98, 0x24, + 0xbd, 0x16, 0xc7, 0x4e, 0x6f, 0x6c, 0x9d, 0x71, 0x28, 0xf9, 0xc8, 0x88, 0x12, 0x3b, 0xb7, 0xbc, 0xb6, + 0x48, 0xb0, 0xf6, 0x13, 0x9b, 0x87, 0xea, 0xc4, 0xc0, 0x66, 0x32, 0x26, 0x0, 0x6, 0xb1, 0xfa, 0x52, + 0x9b, 0xdd, 0x9f, 0x0, 0x1a, 0x86, 0xbe, 0x56, 0x8e, 0x7a, 0xb, 0x1e, 0xc, 0x53, 0x2, 0x34, 0xdc, + 0xe2, 0x28, 0x2e, 0xa6, 0x40, 0x59, 0x14, 0xa1, 0x43, 0xe7, 0x66, 0xbc, 0xf5, 0x0, 0x27, 0x0, 0x0, + 0x79, 0x6e, 0x2, 0x0, 0x0, 0x59, 0xf4, 0x1a, 0x0, 0x1c, 0x7d, 0x89, 0xe2, 0xdb, 0x2, 0xe8, 0xa7, + 0x7d, 0xba, 0x7b, 0x37, 0xcf, 0x23, 0xeb, 0xe, 0x8d, 0x42, 0xb1, 0xcb, 0x92, 0x6d, 0xc7, 0x12, 0x16, + 0xa4, 0xcf, 0x24, 0x40, 0x9, 0x0, 0x1d, 0xc8, 0x8d, 0x9b, 0xf9, 0xd6, 0x67, 0xb2, 0x15, 0xc3, 0x48, + 0x4f, 0xf4, 0x4a, 0x3b, 0x89, 0x88, 0x16, 0xae, 0x79, 0xd8, 0x4a, 0x8b, 0x35, 0xc6, 0xe8, 0xf7, 0xab, + 0x24, 0xd1, 0x12, 0x0, 0x1, 0xfe, 0x9, 0x0, 0x7, 0x3b, 0x57, 0x91, 0xae, 0xc1, 0xe5, 0xe0, 0x15, + 0x0, 0xf, 0xa3, 0xaf, 0xa0, 0xca, 0x16, 0x6f, 0x16, 0xe2, 0xdc, 0xeb, 0xd0, 0xd, 0xb7, 0x26, 0x26, + 0x13, 0x3f, 0xa6, 0x22, 0x1c, 0x21, 0x25, 0x48, 0x16, 0x0, 0x1, 0x5f, 0x13, 0x26, 0x98, 0x0, 0xc, + 0xcc, 0xbe, 0x0, 0xa1, 0x83, 0x17, 0xf3, 0x7e, 0x81, 0x1f, 0x2c, 0xc7, 0x2, 0x0, 0xb, 0x11, 0xcb, + 0xca, 0xd1, 0x30, 0x54, 0x2a, 0x4f, 0x72, 0x68, 0xdf, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xcc, 0xbe, 0x0, 0xa1, 0x83, 0x17, 0xf3, 0x7e, 0x81, 0x1f, 0x2c, 0xc7}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x11, 0xcb, 0xca, 0xd1, 0x30, 0x54, 0x2a, 0x4f, 0x72, 0x68, 0xdf}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xcb, 0xcb, 0xc8}; + uint8_t bytesprops1[] = {0x98, 0x24, 0xbd, 0x16, 0xc7, 0x4e, 0x6f, 0x6c, 0x9d, 0x71, 0x28, 0xf9, 0xc8, 0x88, 0x12, + 0x3b, 0xb7, 0xbc, 0xb6, 0x48, 0xb0, 0xf6, 0x13, 0x9b, 0x87, 0xea, 0xc4, 0xc0, 0x66, 0x32}; + uint8_t bytesprops3[] = {0x86, 0xbe, 0x56, 0x8e, 0x7a, 0xb, 0x1e, 0xc, 0x53, 0x2, 0x34, 0xdc, 0xe2, + 0x28, 0x2e, 0xa6, 0x40, 0x59, 0x14, 0xa1, 0x43, 0xe7, 0x66, 0xbc, 0xf5, 0x0}; + uint8_t bytesprops2[] = {0xb1, 0xfa, 0x52, 0x9b, 0xdd, 0x9f}; + uint8_t bytesprops4[] = {0x7d, 0x89, 0xe2, 0xdb, 0x2, 0xe8, 0xa7, 0x7d, 0xba, 0x7b, 0x37, 0xcf, 0x23, 0xeb, + 0xe, 0x8d, 0x42, 0xb1, 0xcb, 0x92, 0x6d, 0xc7, 0x12, 0x16, 0xa4, 0xcf, 0x24, 0x40}; + uint8_t bytesprops5[] = {0xc8, 0x8d, 0x9b, 0xf9, 0xd6, 0x67, 0xb2, 0x15, 0xc3, 0x48, 0x4f, 0xf4, 0x4a, 0x3b, 0x89, + 0x88, 0x16, 0xae, 0x79, 0xd8, 0x4a, 0x8b, 0x35, 0xc6, 0xe8, 0xf7, 0xab, 0x24, 0xd1}; + uint8_t bytesprops6[] = {0xfe}; + uint8_t bytesprops7[] = {0x3b, 0x57, 0x91, 0xae, 0xc1, 0xe5, 0xe0}; + uint8_t bytesprops8[] = {0xa3, 0xaf, 0xa0, 0xca, 0x16, 0x6f, 0x16, 0xe2, 0xdc, 0xeb, 0xd0, 0xd, 0xb7, 0x26, 0x26}; + uint8_t bytesprops9[] = {0x5f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23397}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16143}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops2}, .v = {26, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31086}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23028}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16294}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7201}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9880}}, + }; + + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9912, 2, topic_filters, qos_levels, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 1301 [("\169n\168\166N\214\SUB\136\156\134\ETX\228",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("!\228\203\199\141\147\FS\178d6\b\237y\140c\213\DEL\141D \168\b\t\231C\"\STX",SubOptions {_retainHandling = +// QoS2}),("\135#\130r\206\254\133s<\ACK\143\200\154\229\227\169\217\244'",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\208N\231\188\204\CANY\CAN+",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("1\138\249\166\182\244n<\189\SI\a\192\&8W~\SI",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("Nt",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\182",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("1\NUL\n1\166lT'\255\146\189^\227\207\&3W\174*\171\194",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("O",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("\fBj\fR\208\210\189\190\148\STX\164}\163\214\183[\143",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("^\230>\180\243\221\ENQ\146K\SYN\153i:\167\222\r",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRetainAvailable 177,PropContentType -// "\177b\143\183U\DC2[&\221\SOH\241f",PropAssignedClientIdentifier -// "\173s\f\207k$\250\208\181\240\161\189\226\EOT\243?\140\US93",PropRequestProblemInformation -// 101,PropMessageExpiryInterval 27033,PropServerKeepAlive 14517,PropPayloadFormatIndicator 214,PropResponseTopic -// "O);NP\195\240\RS\b\145R\178\FS\236\254\\\"\244>\NAK\nV\132o\DC1\153\&1\249\&4\DC1",PropTopicAliasMaximum -// 24352,PropAuthenticationMethod "\197\134)\138\167\141\199\217\139%\167X\217q\192T\196\181\"F\NAK:",PropTopicAlias -// 15336,PropSharedSubscriptionAvailable 6,PropWillDelayInterval 30622,PropRequestProblemInformation -// 44,PropResponseInformation -// "k\134\199\247&g\215\191\209z\218\SO\161\167\204,\230\164\&0F\DC3\192w",PropServerReference -// "\156\244fb\141\233\a\186_|4>b\ETB\214Z\166",PropContentType -// "\242\&9\169\138D\138\EM\143%\193\238\213\216\&9\170\DC2\178(\173i[p\173~\CAN\CAN\171?\215",PropTopicAlias -// 13053,PropMessageExpiryInterval 7710,PropAssignedClientIdentifier -// "w\194\243\EM\ETB\218\196\US]\241\r\160\137\207x",PropServerKeepAlive 6792] -TEST(Subscribe5QCTest, Encode8) { +// QoS2}),("k\172\154\253f\170\&7\CANjg\185\r\ESC\192\ENQQi}\209\SI",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\239\236Y\220\224\191\&6",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\SIw*X&\ty\181\188:}\219,}\247\219>\NAK\167\177j0\188\197L\232@EJ",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\ACK2c\237\191\199*",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\206Cz\139\148\189dN%",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\141=\196\133f1r\DELf#h\161,8\131",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReceiveMaximum 25435,PropResponseInformation +// "\SO\202\a\208j",PropAssignedClientIdentifier +// "\140\131\133\CAN\r\193\218\195\205\167\RS\SOS5\153\226\197r\FS1^\186\DC4\148\162\194",PropMessageExpiryInterval +// 7651,PropMessageExpiryInterval 22861,PropRequestProblemInformation 27,PropServerKeepAlive +// 2068,PropMessageExpiryInterval 6609,PropWillDelayInterval 16160,PropWillDelayInterval 17380,PropResponseInformation +// "M",PropResponseInformation +// "\136\128\193\SYN\DEL(\245#\166\220\177\176\ESCT\211\249%\207dt\170\152\244\175\215K\t)\133",PropTopicAlias 14154] +TEST(Subscribe5QCTest, Encode28) { uint8_t pkt[] = { - 0x82, 0x8a, 0x3, 0x47, 0xa0, 0xe8, 0x1, 0x25, 0xb1, 0x3, 0x0, 0xc, 0xb1, 0x62, 0x8f, 0xb7, 0x55, 0x12, 0x5b, - 0x26, 0xdd, 0x1, 0xf1, 0x66, 0x12, 0x0, 0x14, 0xad, 0x73, 0xc, 0xcf, 0x6b, 0x24, 0xfa, 0xd0, 0xb5, 0xf0, 0xa1, - 0xbd, 0xe2, 0x4, 0xf3, 0x3f, 0x8c, 0x1f, 0x39, 0x33, 0x17, 0x65, 0x2, 0x0, 0x0, 0x69, 0x99, 0x13, 0x38, 0xb5, - 0x1, 0xd6, 0x8, 0x0, 0x1e, 0x4f, 0x29, 0x3b, 0x4e, 0x50, 0xc3, 0xf0, 0x1e, 0x8, 0x91, 0x52, 0xb2, 0x1c, 0xec, - 0xfe, 0x5c, 0x22, 0xf4, 0x3e, 0x15, 0xa, 0x56, 0x84, 0x6f, 0x11, 0x99, 0x31, 0xf9, 0x34, 0x11,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a, 0x8b, 0x94, 0xbd, 0x64, 0x4e, 0x25, 0x2, 0x0, 0xf, 0x8d, 0x3d, 0xc4, 0x85, + 0x66, 0x31, 0x72, 0x7f, 0x66, 0x23, 0x68, 0xa1, 0x2c, 0x38, 0x83, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x4d, 0x9f, 0x2e, 0xc2, 0xc0, 0x7, 0xc6, 0x94, 0x5d, 0xea, 0xe9}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xa9, 0x6e, 0xa8, 0xa6, 0x4e, 0xd6, 0x1a, 0x88, 0x9c, 0x86, 0x3, 0xe4}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbd, 0xde, 0x48, 0x45, 0xcc, 0xec, 0xe4, 0x85, 0x6, 0x2a, 0xec, - 0x58, 0x80, 0x30, 0xe5, 0x3b, 0x6e, 0xf5, 0x4f, 0x52, 0x62, 0xc4}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x87, 0x23, 0x82, 0x72, 0xce, 0xfe, 0x85, 0x73, 0x3c, 0x6, + 0x8f, 0xc8, 0x9a, 0xe5, 0xe3, 0xa9, 0xd9, 0xf4, 0x27}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x21, 0xe4, 0xcb, 0xc7, 0x8d, 0x93, 0x1c, 0xb2, 0x64, 0x36, 0x8, 0xed, 0x79, 0x8c, - 0x63, 0xd5, 0x7f, 0x8d, 0x44, 0x20, 0xa8, 0x8, 0x9, 0xe7, 0x43, 0x22, 0x2}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc, 0x42, 0x6a, 0xc, 0x52, 0xd0, 0xd2, 0xbd, 0xbe, + 0x94, 0x2, 0xa4, 0x7d, 0xa3, 0xd6, 0xb7, 0x5b, 0x8f}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd0, 0x4e, 0xe7, 0xbc, 0xcc, 0x18, 0x59, 0x18, 0x2b}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6b, 0xac, 0x9a, 0xfd, 0x66, 0xaa, 0x37, 0x18, 0x6a, 0x67, + 0xb9, 0xd, 0x1b, 0xc0, 0x5, 0x51, 0x69, 0x7d, 0xd1, 0xf}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x31, 0x8a, 0xf9, 0xa6, 0xb6, 0xf4, 0x6e, 0x3c, - 0xbd, 0xf, 0x7, 0xc0, 0x38, 0x57, 0x7e, 0xf}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xef, 0xec, 0x59, 0xdc, 0xe0, 0xbf, 0x36}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4e, 0x74}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf, 0x77, 0x2a, 0x58, 0x26, 0x9, 0x79, 0xb5, 0xbc, 0x3a, + 0x7d, 0xdb, 0x2c, 0x7d, 0xf7, 0xdb, 0x3e, 0x15, 0xa7, 0xb1, + 0x6a, 0x30, 0xbc, 0xc5, 0x4c, 0xe8, 0x40, 0x45, 0x4a}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb6}; - lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x6, 0x32, 0x63, 0xed, 0xbf, 0xc7, 0x2a}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x31, 0x0, 0xa, 0x31, 0xa6, 0x6c, 0x54, 0x27, 0xff, 0x92, - 0xbd, 0x5e, 0xe3, 0xcf, 0x33, 0x57, 0xae, 0x2a, 0xab, 0xc2}; - lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xce, 0x43, 0x7a, 0x8b, 0x94, 0xbd, 0x64, 0x4e, 0x25}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x4f}; - lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x8d, 0x3d, 0xc4, 0x85, 0x66, 0x31, 0x72, 0x7f, + 0x66, 0x23, 0x68, 0xa1, 0x2c, 0x38, 0x83}; + lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0}; - lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x5e, 0xe6, 0x3e, 0xb4, 0xf3, 0xdd, 0x5, 0x92, - 0x4b, 0x16, 0x99, 0x69, 0x3a, 0xa7, 0xde, 0xd}; - lwmqtt_string_t topic_filter_s10 = {16, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xb1, 0x62, 0x8f, 0xb7, 0x55, 0x12, 0x5b, 0x26, 0xdd, 0x1, 0xf1, 0x66}; - uint8_t bytesprops1[] = {0xad, 0x73, 0xc, 0xcf, 0x6b, 0x24, 0xfa, 0xd0, 0xb5, 0xf0, - 0xa1, 0xbd, 0xe2, 0x4, 0xf3, 0x3f, 0x8c, 0x1f, 0x39, 0x33}; - uint8_t bytesprops2[] = {0x4f, 0x29, 0x3b, 0x4e, 0x50, 0xc3, 0xf0, 0x1e, 0x8, 0x91, 0x52, 0xb2, 0x1c, 0xec, 0xfe, - 0x5c, 0x22, 0xf4, 0x3e, 0x15, 0xa, 0x56, 0x84, 0x6f, 0x11, 0x99, 0x31, 0xf9, 0x34, 0x11}; - uint8_t bytesprops3[] = {0xc5, 0x86, 0x29, 0x8a, 0xa7, 0x8d, 0xc7, 0xd9, 0x8b, 0x25, 0xa7, - 0x58, 0xd9, 0x71, 0xc0, 0x54, 0xc4, 0xb5, 0x22, 0x46, 0x15, 0x3a}; - uint8_t bytesprops4[] = {0x6b, 0x86, 0xc7, 0xf7, 0x26, 0x67, 0xd7, 0xbf, 0xd1, 0x7a, 0xda, 0xe, - 0xa1, 0xa7, 0xcc, 0x2c, 0xe6, 0xa4, 0x30, 0x46, 0x13, 0xc0, 0x77}; - uint8_t bytesprops5[] = {0x9c, 0xf4, 0x66, 0x62, 0x8d, 0xe9, 0x7, 0xba, 0x5f, - 0x7c, 0x34, 0x3e, 0x62, 0x17, 0xd6, 0x5a, 0xa6}; - uint8_t bytesprops6[] = {0xf2, 0x39, 0xa9, 0x8a, 0x44, 0x8a, 0x19, 0x8f, 0x25, 0xc1, 0xee, 0xd5, 0xd8, 0x39, 0xaa, - 0x12, 0xb2, 0x28, 0xad, 0x69, 0x5b, 0x70, 0xad, 0x7e, 0x18, 0x18, 0xab, 0x3f, 0xd7}; - uint8_t bytesprops7[] = {0x77, 0xc2, 0xf3, 0x19, 0x17, 0xda, 0xc4, 0x1f, 0x5d, 0xf1, 0xd, 0xa0, 0x89, 0xcf, 0x78}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, + LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t bytesprops0[] = {0xe, 0xca, 0x7, 0xd0, 0x6a}; + uint8_t bytesprops1[] = {0x8c, 0x83, 0x85, 0x18, 0xd, 0xc1, 0xda, 0xc3, 0xcd, 0xa7, 0x1e, 0xe, 0x53, + 0x35, 0x99, 0xe2, 0xc5, 0x72, 0x1c, 0x31, 0x5e, 0xba, 0x14, 0x94, 0xa2, 0xc2}; + uint8_t bytesprops2[] = {0x4d}; + uint8_t bytesprops3[] = {0x88, 0x80, 0xc1, 0x16, 0x7f, 0x28, 0xf5, 0x23, 0xa6, 0xdc, 0xb1, 0xb0, 0x1b, 0x54, 0xd3, + 0xf9, 0x25, 0xcf, 0x64, 0x74, 0xaa, 0x98, 0xf4, 0xaf, 0xd7, 0x4b, 0x9, 0x29, 0x85}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27033}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14517}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24352}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15336}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30622}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13053}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7710}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6792}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25435}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7651}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22861}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2068}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6609}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16160}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17380}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14154}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18336, 11, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1301, 9, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3357 [("\203$[\200\&9\130F\142\249\232\189\167\148L",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("<\n\188 -// \193>c\237\242\202\GSX\216\222e\204\149;\226",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("(.\204\183\ESC\178*",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("fld~\ACK9Z//1\205\SUB~\211l\241D\196`T",SubOptions +// SubscribeRequest 8636 [("\145uzU$\EOTvLk\130\217\133\&5f:\185\180q\t\227B\204\209^",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\185\215\&3\186z",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("<\215\129\217-\248\223\vA\CAN$\203\213IH\227)\200\233[\174/\236\234\235\206\245\154\236\253",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropRequestProblemInformation 141,PropReasonString "\182",PropReasonString -// "\202\SI\202\227&\182\161X2u\219;\201\203",PropCorrelationData -// "]\144\214>\132\vl\239`\208,s\b\225\194\142\190\rDH\156\&3\182\RS\240\&5w\200",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropRequestResponseInformation 165,PropResponseInformation "E\252\213\213",PropTopicAliasMaximum +// 24647,PropMaximumQoS 165,PropWildcardSubscriptionAvailable 139,PropSessionExpiryInterval +// 19464,PropAssignedClientIdentifier "\128QP\\`;\n8@NNs`\154\SUB\150\136t\231\250",PropRequestResponseInformation +// 67,PropRequestResponseInformation 96,PropResponseInformation "\191s\176\235\244\194",PropMaximumPacketSize +// 1055,PropWildcardSubscriptionAvailable 216,PropResponseTopic "\a)G\219\237j\200T",PropMaximumPacketSize +// 5417,PropRetainAvailable 166,PropMessageExpiryInterval 16062,PropSubscriptionIdentifier 1,PropServerKeepAlive +// 971,PropWildcardSubscriptionAvailable 107,PropMaximumQoS 46,PropSharedSubscriptionAvailable 72,PropReceiveMaximum +// 21423,PropAuthenticationMethod "Q\154V}\ACK@\152E\nK$\156}\188",PropMessageExpiryInterval 1756,PropReasonString +// "\187\DLE\SYN\a\175\159\199\&1_\190\172c\SI&\242\250H\167H\209\t",PropRequestResponseInformation +// 153,PropRetainAvailable 3,PropRequestProblemInformation 43,PropCorrelationData +// "\"T\133<\153\182\147\191\252:",PropUserProperty "!Fc" "\DC3W\163\165\224"] +TEST(Subscribe5QCTest, Encode30) { + uint8_t pkt[] = { + 0x82, 0x95, 0x2, 0x5b, 0x2f, 0xb3, 0x1, 0x19, 0xa5, 0x1a, 0x0, 0x4, 0x45, 0xfc, 0xd5, 0xd5, 0x22, 0x60, 0x47, + 0x24, 0xa5, 0x28, 0x8b, 0x11, 0x0, 0x0, 0x4c, 0x8, 0x12, 0x0, 0x14, 0x80, 0x51, 0x50, 0x5c, 0x60, 0x3b, 0xa, + 0x38, 0x40, 0x4e, 0x4e, 0x73, 0x60, 0x9a, 0x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30, 0x29, 0x12, 0x9f, 0x86, 0xbc, 0x61, 0x4d, 0xc9, 0xff, 0x79, 0xcf, 0x95, 0x10, + 0x0, 0x0, 0x1d, 0xbd, 0x44, 0xf6, 0x17, 0xa5, 0x86, 0xee, 0xae, 0xaf, 0x45, 0xdc, 0xf0, 0x25, 0xbe, 0xa3, 0xe8, + 0x3e, 0xbe, 0xd, 0x44, 0x48, 0x9c, 0x33, 0xb6, 0x1e, 0xf0, 0x35, 0x77, 0xc8, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x76, 0x32, 0xd9, 0xc3, 0xab, 0x88, 0xfe, 0x80, 0x3a, 0x69}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x8, 0xe2, 0xe4}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf9, 0x69, 0x39, 0xe4, 0xf, 0x49, 0x9c, 0xc0, 0x37, 0x2f, 0x2e, 0xbb, 0xcb, 0x25}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2c, 0x36, 0x70, 0x1f, 0x1b, 0xe9, 0xa6, 0xa8, 0xe, 0x62, + 0x40, 0x22, 0x9b, 0xb6, 0x7f, 0xd5, 0xfb, 0xd6, 0x2f, 0xe9, + 0xd1, 0x6e, 0x53, 0x44, 0xae, 0x59, 0x93, 0xbf}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf5, 0xcd, 0x9, 0x3b, 0xa4, 0x23, 0x70, 0x1b, 0x18, 0xa8, - 0x2c, 0x86, 0x0, 0x7b, 0x1e, 0xa4, 0x18, 0x5e, 0xdf, 0x95}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5b, 0x31, 0xfb, 0xa8, 0x23, 0x4, 0x8c, 0x8c, 0x30, 0x29, 0x12, + 0x9f, 0x86, 0xbc, 0x61, 0x4d, 0xc9, 0xff, 0x79, 0xcf, 0x95, 0x10}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1a}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xbd, 0x44, 0xf6, 0x17, 0xa5, 0x86, 0xee, 0xae, 0xaf, 0x45, + 0xdc, 0xf0, 0x25, 0xbe, 0xa3, 0xe8, 0x3e, 0xbe, 0xd, 0x44, + 0x48, 0x9c, 0x33, 0xb6, 0x1e, 0xf0, 0x35, 0x77, 0xc8}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x29, 0xb8, 0x6f, 0xf0, 0xfb, 0xa9, 0x1, 0xad, 0xd4, 0x53, 0xc7, 0x7e, 0xe5, 0xa9, - 0xbd, 0xa2, 0xfb, 0x5e, 0x33, 0xf1, 0xe9, 0x69, 0x5d, 0x9b, 0xe1, 0x46, 0x0}; - uint8_t bytesprops1[] = {0xfa, 0x6e, 0xd, 0x36, 0xdb, 0xf9, 0xfe, 0xcd, 0x93, 0x2a, - 0x19, 0xc7, 0x32, 0xc5, 0xd5, 0x4e, 0xf8, 0xb, 0xc6}; - uint8_t bytesprops2[] = {0x7b, 0xd2, 0x3f, 0xb3, 0xe6, 0xd5, 0x48, 0x9e}; - uint8_t bytesprops3[] = {0x50, 0x26, 0xf8, 0x12, 0x69, 0xf3, 0x2, 0x2d, 0xa2, 0xbd, 0xdf, 0xba, - 0x86, 0x3a, 0x9a, 0x39, 0xe1, 0x5e, 0xd6, 0xef, 0xff, 0xc4, 0x20}; + lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t bytesprops0[] = {0x45, 0xfc, 0xd5, 0xd5}; + uint8_t bytesprops1[] = {0x80, 0x51, 0x50, 0x5c, 0x60, 0x3b, 0xa, 0x38, 0x40, 0x4e, + 0x4e, 0x73, 0x60, 0x9a, 0x1a, 0x96, 0x88, 0x74, 0xe7, 0xfa}; + uint8_t bytesprops2[] = {0xbf, 0x73, 0xb0, 0xeb, 0xf4, 0xc2}; + uint8_t bytesprops3[] = {0x7, 0x29, 0x47, 0xdb, 0xed, 0x6a, 0xc8, 0x54}; + uint8_t bytesprops4[] = {0x51, 0x9a, 0x56, 0x7d, 0x6, 0x40, 0x98, 0x45, 0xa, 0x4b, 0x24, 0x9c, 0x7d, 0xbc}; + uint8_t bytesprops5[] = {0xbb, 0x10, 0x16, 0x7, 0xaf, 0x9f, 0xc7, 0x31, 0x5f, 0xbe, 0xac, + 0x63, 0xf, 0x26, 0xf2, 0xfa, 0x48, 0xa7, 0x48, 0xd1, 0x9}; + uint8_t bytesprops6[] = {0x22, 0x54, 0x85, 0x3c, 0x99, 0xb6, 0x93, 0xbf, 0xfc, 0x3a}; + uint8_t bytesprops8[] = {0x13, 0x57, 0xa3, 0xa5, 0xe0}; + uint8_t bytesprops7[] = {0x21, 0x46, 0x63}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17048}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24647}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19464}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1055}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5417}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16062}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 971}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21423}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1756}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops7}, .v = {5, (char*)&bytesprops8}}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18395, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23343, 4, topic_filters, qos_levels, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); From 56e2fc11da70afc4a93eef5ddfcdb39ba92afa70 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Thu, 19 Sep 2019 10:18:25 -0700 Subject: [PATCH 16/26] Support all subscription options. --- examples/async.c | 3 +- examples/sync.c | 3 +- gentests/app/Main.hs | 24 +- include/lwmqtt.h | 33 +- src/client.c | 10 +- src/packet.c | 11 +- src/packet.h | 4 +- tests/client.cpp | 23 +- tests/generated.cpp | 21975 ++++++++++++++++++++++------------------- tests/packet.cpp | 18 +- 10 files changed, 11706 insertions(+), 10398 deletions(-) diff --git a/examples/async.c b/examples/async.c index 810cecc..d4dee25 100644 --- a/examples/async.c +++ b/examples/async.c @@ -102,7 +102,8 @@ int main() { printf("connected!\n"); // subscribe to topic - err = lwmqtt_subscribe_one(&client, lwmqtt_string("hello"), LWMQTT_QOS0, COMMAND_TIMEOUT); + lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; + err = lwmqtt_subscribe_one(&client, lwmqtt_string("hello"), subopts, COMMAND_TIMEOUT); if (err != LWMQTT_SUCCESS) { printf("failed lwmqtt_subscribe: %d\n", err); exit(1); diff --git a/examples/sync.c b/examples/sync.c index edc3cc5..34008bd 100644 --- a/examples/sync.c +++ b/examples/sync.c @@ -57,7 +57,8 @@ int main() { printf("connected!\n"); // subscribe to topic - err = lwmqtt_subscribe_one(&client, lwmqtt_string("hello"), LWMQTT_QOS0, COMMAND_TIMEOUT); + lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; + err = lwmqtt_subscribe_one(&client, lwmqtt_string("hello"), subopts, COMMAND_TIMEOUT); if (err != LWMQTT_SUCCESS) { printf("failed lwmqtt_subscribe: %d\n", err); exit(1); diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 74fbc63..b876034 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -46,11 +46,6 @@ v311SubReq p50 = let (SubscribePkt p) = v311mask (SubscribePkt p50) in p v311ConnReq :: ConnectRequest -> ConnectRequest v311ConnReq p50 = let (ConnPkt p) = v311mask (ConnPkt p50) in p --- Not currently supporting most of the options. -simplifySubOptions :: SubscribeRequest -> SubscribeRequest -simplifySubOptions (SubscribeRequest w subs props) = SubscribeRequest w ssubs props - where ssubs = map (\(x,o@SubOptions{..}) -> (x,subOptions{_subQoS=_subQoS})) subs - userFix :: ConnectRequest -> ConnectRequest userFix = ufix . pfix where @@ -208,7 +203,7 @@ genSubTest prot i p@(SubscribeRequest pid subs props) = do genProperties "props" props, " size_t len = 0;\n", " lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, ", protlvl prot, ", ", - show pid, ", ", show (length subs), ", topic_filters, qos_levels, props);\n\n", + show pid, ", ", show (length subs), ", topic_filters, sub_opts, props);\n\n", " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", " EXPECT_ARRAY_EQ(pkt, buf, len);\n" ] @@ -223,9 +218,20 @@ genSubTest prot i p@(SubscribeRequest pid subs props) = do "topic_filters[", show i', "] = topic_filter_s", show i', ";\n" ] - encodeQos = "lwmqtt_qos_t qos_levels[] = {" <> intercalate ", " (map aQ subs) <> "};\n" + encodeQos = "lwmqtt_sub_options_t sub_opts["<> show (length subs) <> "];\n" <> (concatMap subvals $ zip [0..] subs) where - aQ (_,SubOptions{..}) = qos _subQoS + subvals :: (Int,(BL.ByteString, SubOptions)) -> String + subvals (subi,(_,SubOptions{..})) = mconcat [ + si, "qos = ", qos _subQoS, ";\n", + si, "retain_handling = ", rh _retainHandling, ";\n", + si, "retain_as_published = ", bool _retainAsPublished, ";\n", + si, "no_local = ", bool _noLocal, ";\n" + ] + where + si = "sub_opts[" <> show subi <> "]." + rh SendOnSubscribe = "LWMQTT_SUB_SEND_ON_SUB" + rh SendOnSubscribeNew = "LWMQTT_SUB_SEND_ON_SUB_NEW" + rh DoNotSendOnSubscribe = "LWMQTT_SUB_NO_SEND_ON_SUB" genConnectTest :: ProtocolLevel -> Int -> ConnectRequest -> String genConnectTest prot i p@ConnectRequest{..} = do @@ -311,7 +317,7 @@ extern "C" { subs <- replicateM numTests $ generate arbitrary f genSubTest Protocol311 (v311SubReq <$> subs) - f genSubTest Protocol50 (simplifySubOptions <$> subs) + f genSubTest Protocol50 subs where f :: (ProtocolLevel -> Int -> a -> String) -> ProtocolLevel -> [a] -> IO () diff --git a/include/lwmqtt.h b/include/lwmqtt.h index d186895..90c2401 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -65,7 +65,28 @@ int lwmqtt_strcmp(lwmqtt_string_t a, const char *b); /** * The available QOS levels. */ -typedef enum { LWMQTT_QOS0 = 0, LWMQTT_QOS1 = 1, LWMQTT_QOS2 = 2, LWMQTT_QOS_FAILURE = 128 } lwmqtt_qos_t; +typedef enum __attribute__((__packed__)) { + LWMQTT_QOS0 = 0, + LWMQTT_QOS1 = 1, + LWMQTT_QOS2 = 2, + LWMQTT_QOS_FAILURE = 128 +} lwmqtt_qos_t; + +typedef enum __attribute__((__packed__)) { + LWMQTT_SUB_SEND_ON_SUB = 0, + LWMQTT_SUB_SEND_ON_SUB_NEW = 1, + LWMQTT_SUB_NO_SEND_ON_SUB = 2 +} lwmqtt_retain_handling_t; + +typedef struct { + lwmqtt_qos_t qos : 3; + lwmqtt_retain_handling_t retain_handling : 3; + bool retain_as_published : 1; + bool no_local : 1; +} lwmqtt_sub_options_t; + +#define lwmqtt_default_sub_options \ + { LWMQTT_QOS0, LWMQTT_SUB_SEND_ON_SUB, false, false } typedef enum { LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR = 0x01, @@ -367,12 +388,12 @@ lwmqtt_err_t lwmqtt_publish(lwmqtt_client_t *client, lwmqtt_string_t topic, lwmq * @param client - The client object. * @param count - The number of topic filters and QOS levels. * @param topic_filter - The list of topic filters. - * @param qos - The list of QOS levels. + * @param opts - The list of subscription options. * @param timeout - The command timeout. * @return An error value. */ -lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, lwmqtt_qos_t *qos, - uint32_t timeout); +lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, + lwmqtt_sub_options_t *opts, uint32_t timeout); /** * Will send a subscribe packet with a single topic filter plus QOS level and wait for the suback to complete. @@ -381,11 +402,11 @@ lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_ * * @param client - The client object. * @param topic_filter - The topic filter. - * @param qos - The QOS level. + * @param qos - The subscription options. * @param timeout - The command timeout. * @return An error value. */ -lwmqtt_err_t lwmqtt_subscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, lwmqtt_qos_t qos, +lwmqtt_err_t lwmqtt_subscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, lwmqtt_sub_options_t opts, uint32_t timeout); /** diff --git a/src/client.c b/src/client.c index 2c79716..00b3d95 100644 --- a/src/client.c +++ b/src/client.c @@ -471,8 +471,8 @@ lwmqtt_err_t lwmqtt_connect(lwmqtt_client_t *client, lwmqtt_options_t options, l return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, lwmqtt_qos_t *qos, - uint32_t timeout) { +lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, + lwmqtt_sub_options_t *opts, uint32_t timeout) { // set command timer client->timer_set(client->command_timer, timeout); @@ -480,7 +480,7 @@ lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_ size_t len; lwmqtt_properties_t props = lwmqtt_empty_props; lwmqtt_err_t err = lwmqtt_encode_subscribe(client->write_buf, client->write_buf_size, &len, client->protocol, - lwmqtt_get_next_packet_id(client), count, topic_filter, qos, props); + lwmqtt_get_next_packet_id(client), count, topic_filter, opts, props); if (err != LWMQTT_SUCCESS) { return err; } @@ -520,9 +520,9 @@ lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_ return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_subscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, lwmqtt_qos_t qos, +lwmqtt_err_t lwmqtt_subscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, lwmqtt_sub_options_t opts, uint32_t timeout) { - return lwmqtt_subscribe(client, 1, &topic_filter, &qos, timeout); + return lwmqtt_subscribe(client, 1, &topic_filter, &opts, timeout); } lwmqtt_err_t lwmqtt_unsubscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, uint32_t timeout) { diff --git a/src/packet.c b/src/packet.c index 4b3d759..d5c743f 100644 --- a/src/packet.c +++ b/src/packet.c @@ -741,9 +741,14 @@ lwmqtt_err_t lwmqtt_encode_publish(uint8_t *buf, size_t buf_len, size_t *len, lw return LWMQTT_SUCCESS; } +static uint8_t encode_sub_opt(lwmqtt_sub_options_t opt) { + return (uint8_t)opt.qos | ((uint8_t)opt.retain_handling << 4) | (opt.retain_as_published ? 0x08 : 0) | + (opt.no_local ? 0x04 : 0); +} + lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, uint16_t packet_id, int count, lwmqtt_string_t *topic_filters, - lwmqtt_qos_t *qos_levels, lwmqtt_properties_t props) { + lwmqtt_sub_options_t *sub_options, lwmqtt_properties_t props) { // prepare pointer uint8_t *buf_ptr = buf; uint8_t *buf_end = buf + buf_len; @@ -801,8 +806,8 @@ lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, return err; } - // write qos level - err = lwmqtt_write_byte(&buf_ptr, buf_end, (uint8_t)qos_levels[i]); + // write subscription options + err = lwmqtt_write_byte(&buf_ptr, buf_end, encode_sub_opt(sub_options[i])); if (err != LWMQTT_SUCCESS) { return err; } diff --git a/src/packet.h b/src/packet.h index f4f11f1..a501c58 100644 --- a/src/packet.h +++ b/src/packet.h @@ -151,12 +151,12 @@ lwmqtt_err_t lwmqtt_encode_publish(uint8_t *buf, size_t buf_len, size_t *len, lw * @param packet_id - The packet id. * @param count - The number of members in the topic_filters and qos_levels array. * @param topic_filters - The array of topic filter. - * @param qos_levels - The array of requested QoS levels. + * @param sub_options - The array of requested subscription options. * @return An error value. */ lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t prototocol, uint16_t packet_id, int count, lwmqtt_string_t *topic_filters, - lwmqtt_qos_t *qos_levels, lwmqtt_properties_t props); + lwmqtt_sub_options_t *sub_options, lwmqtt_properties_t props); /** * Decodes a suback packet from the supplied buffer. diff --git a/tests/client.cpp b/tests/client.cpp index fc7fbaa..7bac121 100644 --- a/tests/client.cpp +++ b/tests/client.cpp @@ -69,7 +69,8 @@ TEST(Client, PublishSubscribeQOS0) { err = lwmqtt_connect(&client, data, nullptr, &return_code, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), LWMQTT_QOS0, COMMAND_TIMEOUT); + lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0; @@ -128,7 +129,9 @@ TEST(Client, PublishSubscribeQOS1) { err = lwmqtt_connect(&client, options, nullptr, &return_code, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), LWMQTT_QOS1, COMMAND_TIMEOUT); + lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; + subopts.qos = LWMQTT_QOS1; + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0; @@ -187,7 +190,9 @@ TEST(Client, PublishSubscribeQOS2) { err = lwmqtt_connect(&client, options, nullptr, &return_code, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), LWMQTT_QOS2, COMMAND_TIMEOUT); + lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; + subopts.qos = LWMQTT_QOS2; + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0; @@ -246,7 +251,8 @@ TEST(Client, BufferOverflow) { err = lwmqtt_connect(&client, options, nullptr, &return_code, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), LWMQTT_QOS0, COMMAND_TIMEOUT); + lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_message_t msg = lwmqtt_default_message; @@ -312,7 +318,8 @@ TEST(Client, OverflowDropping) { err = lwmqtt_connect(&client, options, nullptr, &return_code, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), LWMQTT_QOS0, COMMAND_TIMEOUT); + lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0; @@ -372,7 +379,8 @@ TEST(Client, BigBuffersAndPayload) { err = lwmqtt_connect(&client, options, nullptr, &return_code, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), LWMQTT_QOS0, COMMAND_TIMEOUT); + lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0; @@ -431,8 +439,9 @@ TEST(Client, MultipleSubscriptions) { err = lwmqtt_connect(&client, options, nullptr, &return_code, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); + lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; lwmqtt_string_t topic_filters[2] = {lwmqtt_string("foo"), lwmqtt_string("lwmqtt")}; - lwmqtt_qos_t qos_levels[2] = {LWMQTT_QOS0, LWMQTT_QOS0}; + lwmqtt_sub_options_t qos_levels[2] = {subopts, subopts}; err = lwmqtt_subscribe(&client, 2, topic_filters, qos_levels, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); diff --git a/tests/generated.cpp b/tests/generated.cpp index ad11a7a..f7c724e 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,40 +21,43 @@ extern "C" { } \ } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = ";\152\218", _pubPktID = 5070, -// _pubBody = "]&\234\205\156\200\SYN\185\NUL\214}\239\191\&6\154waT{\246\173\DC4k\155\211\190", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\DC1\"\211\207\n{Z%\217\200gfi\182\210US5", _pubPktID = 0, _pubBody = +// "\DEL\211\247\135\US>`\222\&5\231AJo1JP\244\231\252\&7\211\&32]", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x3d, 0x21, 0x0, 0x3, 0x3b, 0x98, 0xda, 0x13, 0xce, 0x5d, 0x26, 0xea, - 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, 0x36, 0x9a, - 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; - uint8_t topic_bytes[] = {0x3b, 0x98, 0xda}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x2c, 0x0, 0x12, 0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, 0xc8, 0x67, 0x66, + 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35, 0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, + 0x41, 0x4a, 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; + uint8_t topic_bytes[] = {0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, + 0xc8, 0x67, 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, - 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, 0x41, 0x4a, + 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 24; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5070, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = ";\152\218", _pubPktID = 5070, -// _pubBody = "]&\234\205\156\200\SYN\185\NUL\214}\239\191\&6\154waT{\246\173\DC4k\155\211\190", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\DC1\"\211\207\n{Z%\217\200gfi\182\210US5", _pubPktID = 0, _pubBody = +// "\DEL\211\247\135\US>`\222\&5\231AJo1JP\244\231\252\&7\211\&32]", _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x3d, 0x21, 0x0, 0x3, 0x3b, 0x98, 0xda, 0x13, 0xce, 0x5d, 0x26, 0xea, - 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, 0x36, 0x9a, - 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; + uint8_t pkt[] = {0x38, 0x2c, 0x0, 0x12, 0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, 0xc8, 0x67, 0x66, + 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35, 0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, + 0x41, 0x4a, 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -62,56 +65,52 @@ TEST(Publish311QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3b, 0x98, 0xda}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, - 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, + 0xc8, 0x67, 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, 0x41, 0x4a, + 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 5070); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\156n m\218\DC4\ENQ\RS\r\221", -// _pubPktID = 29842, _pubBody = "\n\r\194\171\&847\188\r\239=\228G\244\204\183o\136\148\223SQ", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\212", _pubPktID = 10216, +// _pubBody = "\241", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x3c, 0x24, 0x0, 0xa, 0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, - 0xdd, 0x74, 0x92, 0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, 0xbc, 0xd, 0xef, - 0x3d, 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; - uint8_t topic_bytes[] = {0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, 0xdd}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x7, 0x0, 0x2, 0xe9, 0xd4, 0x27, 0xe8, 0xf1}; + uint8_t topic_bytes[] = {0xe9, 0xd4}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, 0xbc, 0xd, 0xef, 0x3d, - 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; + uint8_t msg_bytes[] = {0xf1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 1; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29842, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10216, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\156n m\218\DC4\ENQ\RS\r\221", -// _pubPktID = 29842, _pubBody = "\n\r\194\171\&847\188\r\239=\228G\244\204\183o\136\148\223SQ", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\212", _pubPktID = 10216, +// _pubBody = "\241", _pubProps = []} TEST(Publish311QCTest, Decode2) { - uint8_t pkt[] = {0x3c, 0x24, 0x0, 0xa, 0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, - 0xdd, 0x74, 0x92, 0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, 0xbc, 0xd, 0xef, - 0x3d, 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; + uint8_t pkt[] = {0x32, 0x7, 0x0, 0x2, 0xe9, 0xd4, 0x27, 0xe8, 0xf1}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -119,54 +118,58 @@ TEST(Publish311QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9c, 0x6e, 0x20, 0x6d, 0xda, 0x14, 0x5, 0x1e, 0xd, 0xdd}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa, 0xd, 0xc2, 0xab, 0x38, 0x34, 0x37, 0xbc, 0xd, 0xef, 0x3d, - 0xe4, 0x47, 0xf4, 0xcc, 0xb7, 0x6f, 0x88, 0x94, 0xdf, 0x53, 0x51}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0xe9, 0xd4}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf1}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 29842); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(packet_id, 10216); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\SUB\143\217", _pubPktID = 816, -// _pubBody = "\246^\255t\204\180\169\214\150&=\195\235\249\176Q\NAK\169\145", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "}\162\DC3\157\161\140z\190\148\228\254\EOTk\211\&1\133\SI\188y\142\134e", _pubPktID = 11026, _pubBody = +// "\v/:\b\150\237Ih\224]\US\181R[r\179\234\185", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x35, 0x1a, 0x0, 0x3, 0x1a, 0x8f, 0xd9, 0x3, 0x30, 0xf6, 0x5e, 0xff, 0x74, 0xcc, - 0xb4, 0xa9, 0xd6, 0x96, 0x26, 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; - uint8_t topic_bytes[] = {0x1a, 0x8f, 0xd9}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x2c, 0x0, 0x16, 0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, 0x4, + 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65, 0x2b, 0x12, 0xb, 0x2f, 0x3a, 0x8, + 0x96, 0xed, 0x49, 0x68, 0xe0, 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; + uint8_t topic_bytes[] = {0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, + 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, 0x26, - 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xb, 0x2f, 0x3a, 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, + 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 18; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 816, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 11026, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\SUB\143\217", _pubPktID = 816, -// _pubBody = "\246^\255t\204\180\169\214\150&=\195\235\249\176Q\NAK\169\145", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "}\162\DC3\157\161\140z\190\148\228\254\EOTk\211\&1\133\SI\188y\142\134e", _pubPktID = 11026, _pubBody = +// "\v/:\b\150\237Ih\224]\US\181R[r\179\234\185", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x35, 0x1a, 0x0, 0x3, 0x1a, 0x8f, 0xd9, 0x3, 0x30, 0xf6, 0x5e, 0xff, 0x74, 0xcc, - 0xb4, 0xa9, 0xd6, 0x96, 0x26, 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; + uint8_t pkt[] = {0x3a, 0x2c, 0x0, 0x16, 0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, 0x4, + 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65, 0x2b, 0x12, 0xb, 0x2f, 0x3a, 0x8, + 0x96, 0xed, 0x49, 0x68, 0xe0, 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -174,54 +177,52 @@ TEST(Publish311QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x1a, 0x8f, 0xd9}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, 0x26, - 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 816); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + uint8_t exp_topic_bytes[] = {0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, + 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb, 0x2f, 0x3a, 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, + 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 11026); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "", _pubPktID = 31057, _pubBody = -// "\199\189\167\ETX\187.\248)\192z\ESC\250{\169\157\255\224d\204\159\r\239\ESC\154Q\171\168", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "'$k\221BT0a\ETB", _pubPktID = 21319, +// _pubBody = "\149", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x0, 0x79, 0x51, 0xc7, 0xbd, 0xa7, 0x3, 0xbb, 0x2e, 0xf8, 0x29, 0xc0, 0x7a, 0x1b, - 0xfa, 0x7b, 0xa9, 0x9d, 0xff, 0xe0, 0x64, 0xcc, 0x9f, 0xd, 0xef, 0x1b, 0x9a, 0x51, 0xab, 0xa8}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0xe, 0x0, 0x9, 0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17, 0x53, 0x47, 0x95}; + uint8_t topic_bytes[] = {0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xc7, 0xbd, 0xa7, 0x3, 0xbb, 0x2e, 0xf8, 0x29, 0xc0, 0x7a, 0x1b, 0xfa, 0x7b, 0xa9, - 0x9d, 0xff, 0xe0, 0x64, 0xcc, 0x9f, 0xd, 0xef, 0x1b, 0x9a, 0x51, 0xab, 0xa8}; + uint8_t msg_bytes[] = {0x95}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 1; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 31057, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 21319, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "", _pubPktID = 31057, _pubBody = -// "\199\189\167\ETX\187.\248)\192z\ESC\250{\169\157\255\224d\204\159\r\239\ESC\154Q\171\168", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "'$k\221BT0a\ETB", _pubPktID = 21319, +// _pubBody = "\149", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x0, 0x79, 0x51, 0xc7, 0xbd, 0xa7, 0x3, 0xbb, 0x2e, 0xf8, 0x29, 0xc0, 0x7a, 0x1b, - 0xfa, 0x7b, 0xa9, 0x9d, 0xff, 0xe0, 0x64, 0xcc, 0x9f, 0xd, 0xef, 0x1b, 0x9a, 0x51, 0xab, 0xa8}; + uint8_t pkt[] = {0x3a, 0xe, 0x0, 0x9, 0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17, 0x53, 0x47, 0x95}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -229,61 +230,55 @@ TEST(Publish311QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc7, 0xbd, 0xa7, 0x3, 0xbb, 0x2e, 0xf8, 0x29, 0xc0, 0x7a, 0x1b, 0xfa, 0x7b, 0xa9, - 0x9d, 0xff, 0xe0, 0x64, 0xcc, 0x9f, 0xd, 0xef, 0x1b, 0x9a, 0x51, 0xab, 0xa8}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x95}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 31057); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 27); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + EXPECT_EQ(packet_id, 21319); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "V\129\199\DEL\236d\144\134\234\&2\161\f\158;^\GS\152", _pubPktID = 0, _pubBody = -// "\168#\DC4\164\152d\226\231\214\203.3\\K\148y\227\211\138\130B\160L0\153\231\154\201\v0", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\US\134\217^\225\USI\SOH%\234]\SUB\251\158\ENQ\188\140@\224\ETX\185}", _pubPktID = 0, _pubBody = "\222", _pubProps = +// []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x39, 0x31, 0x0, 0x11, 0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, - 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98, 0xa8, 0x23, 0x14, 0xa4, 0x98, - 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, 0x79, 0xe3, 0xd3, - 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; - uint8_t topic_bytes[] = {0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, - 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x19, 0x0, 0x16, 0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, + 0x5d, 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d, 0xde}; + uint8_t topic_bytes[] = {0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, 0x5d, + 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, - 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; + msg.retained = false; + uint8_t msg_bytes[] = {0xde}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 1; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "V\129\199\DEL\236d\144\134\234\&2\161\f\158;^\GS\152", _pubPktID = 0, _pubBody = -// "\168#\DC4\164\152d\226\231\214\203.3\\K\148y\227\211\138\130B\160L0\153\231\154\201\v0", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\US\134\217^\225\USI\SOH%\234]\SUB\251\158\ENQ\188\140@\224\ETX\185}", _pubPktID = 0, _pubBody = "\222", _pubProps = +// []} TEST(Publish311QCTest, Decode5) { - uint8_t pkt[] = {0x39, 0x31, 0x0, 0x11, 0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, - 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98, 0xa8, 0x23, 0x14, 0xa4, 0x98, - 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, 0x79, 0xe3, 0xd3, - 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; + uint8_t pkt[] = {0x30, 0x19, 0x0, 0x16, 0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, + 0x5d, 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d, 0xde}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -291,54 +286,53 @@ TEST(Publish311QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, - 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98}; - lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, - 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, 0x5d, + 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xde}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\ESC\176mM-\183\&6\136p\203\156\172", _pubPktID = 0, _pubBody = "\DC2\166\130\180V\157\163bV", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\152\168e\228f1ic\227\250", _pubPktID +// = 0, _pubBody = "\195\&1\199\231\246bO,\"\146\SOE`:", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x31, 0x17, 0x0, 0xc, 0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, - 0xcb, 0x9c, 0xac, 0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; - uint8_t topic_bytes[] = {0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x1a, 0x0, 0xa, 0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa, + 0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; + uint8_t topic_bytes[] = {0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; + uint8_t msg_bytes[] = {0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 14; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\ESC\176mM-\183\&6\136p\203\156\172", _pubPktID = 0, _pubBody = "\DC2\166\130\180V\157\163bV", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\152\168e\228f1ic\227\250", _pubPktID +// = 0, _pubBody = "\195\&1\199\231\246bO,\"\146\SOE`:", _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x31, 0x17, 0x0, 0xc, 0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, - 0xcb, 0x9c, 0xac, 0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; + uint8_t pkt[] = {0x39, 0x1a, 0x0, 0xa, 0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa, + 0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -346,52 +340,52 @@ TEST(Publish311QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\178\SI\169\146\239\178\SYN\STX", -// _pubPktID = 0, _pubBody = "K\148\ETX%\135\&7\194\158\DLE\ENQ\215\157\176\ESCA\f", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\240\218\212Wy", _pubPktID = 11258, +// _pubBody = "\212F\158\240\144\160AN", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x30, 0x1a, 0x0, 0x8, 0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2, 0x4b, 0x94, - 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; - uint8_t topic_bytes[] = {0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x11, 0x0, 0x5, 0xf0, 0xda, 0xd4, 0x57, 0x79, 0x2b, + 0xfa, 0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; + uint8_t topic_bytes[] = {0xf0, 0xda, 0xd4, 0x57, 0x79}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x4b, 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 8; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 11258, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\178\SI\169\146\239\178\SYN\STX", -// _pubPktID = 0, _pubBody = "K\148\ETX%\135\&7\194\158\DLE\ENQ\215\157\176\ESCA\f", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\240\218\212Wy", _pubPktID = 11258, +// _pubBody = "\212F\158\240\144\160AN", _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x30, 0x1a, 0x0, 0x8, 0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2, 0x4b, 0x94, - 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; + uint8_t pkt[] = {0x33, 0x11, 0x0, 0x5, 0xf0, 0xda, 0xd4, 0x57, 0x79, 0x2b, + 0xfa, 0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -399,58 +393,57 @@ TEST(Publish311QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4b, 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, - 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xf0, 0xda, 0xd4, 0x57, 0x79}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; + lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 11258); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 8); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\164Y\252JlD$\198\DC1l\vM\194\NAK\194I\144\STX:c\158)N*", _pubPktID = 7891, _pubBody = -// "\176\162\NAK'B\224M\185\SYNa\n\151\146\160U", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\204s\226@u&7F!\EM\194o\133\175\187\203<\DC1;\239Q\RS\251\236J\167a\247\220", _pubPktID = 0, _pubBody = +// "\159(\138\244\237\128L\179\197a", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x35, 0x2b, 0x0, 0x18, 0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, - 0x4d, 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a, 0x1e, 0xd3, - 0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; - uint8_t topic_bytes[] = {0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, 0x4d, - 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x29, 0x0, 0x1d, 0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, + 0x6f, 0x85, 0xaf, 0xbb, 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, + 0x61, 0xf7, 0xdc, 0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; + uint8_t topic_bytes[] = {0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, 0x6f, 0x85, 0xaf, 0xbb, + 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, 0x61, 0xf7, 0xdc}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; + uint8_t msg_bytes[] = {0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 10; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7891, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\164Y\252JlD$\198\DC1l\vM\194\NAK\194I\144\STX:c\158)N*", _pubPktID = 7891, _pubBody = -// "\176\162\NAK'B\224M\185\SYNa\n\151\146\160U", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\204s\226@u&7F!\EM\194o\133\175\187\203<\DC1;\239Q\RS\251\236J\167a\247\220", _pubPktID = 0, _pubBody = +// "\159(\138\244\237\128L\179\197a", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x35, 0x2b, 0x0, 0x18, 0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, - 0x4d, 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a, 0x1e, 0xd3, - 0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; + uint8_t pkt[] = {0x31, 0x29, 0x0, 0x1d, 0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, + 0x6f, 0x85, 0xaf, 0xbb, 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, + 0x61, 0xf7, 0xdc, 0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -458,39 +451,40 @@ TEST(Publish311QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, 0x4d, - 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a}; - lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, 0x6f, 0x85, 0xaf, 0xbb, + 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, 0x61, 0xf7, 0xdc}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 7891); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } // PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\168\NAKx\SI\199\207\184(\186\150r\FS\189\205\252\135\250\205\254\148\161\239\228\176s", _pubPktID = 0, _pubBody = -// "\135", _pubProps = []} +// "~\237S\145l\t\ACK0\CAN\236\137G!\FS~l\156\DC3\n>\135", _pubPktID = 0, _pubBody = +// "\NAK\255WE\SIQC\246\161\173\128\&6", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x31, 0x1c, 0x0, 0x19, 0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, - 0x1c, 0xbd, 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73, 0x87}; - uint8_t topic_bytes[] = {0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, 0xbd, - 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x23, 0x0, 0x15, 0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, + 0xec, 0x89, 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87, 0x15, + 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; + uint8_t topic_bytes[] = {0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, + 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x87}; + uint8_t msg_bytes[] = {0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 12; lwmqtt_property_t propslist[] = {}; @@ -503,11 +497,12 @@ TEST(Publish311QCTest, Encode9) { } // PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\168\NAKx\SI\199\207\184(\186\150r\FS\189\205\252\135\250\205\254\148\161\239\228\176s", _pubPktID = 0, _pubBody = -// "\135", _pubProps = []} +// "~\237S\145l\t\ACK0\CAN\236\137G!\FS~l\156\DC3\n>\135", _pubPktID = 0, _pubBody = +// "\NAK\255WE\SIQC\246\161\173\128\&6", _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x31, 0x1c, 0x0, 0x19, 0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, - 0x1c, 0xbd, 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73, 0x87}; + uint8_t pkt[] = {0x31, 0x23, 0x0, 0x15, 0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, + 0xec, 0x89, 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87, 0x15, + 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -515,54 +510,61 @@ TEST(Publish311QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, 0xbd, - 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x87}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, + 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\140r\DC3\130\161\ENQ", _pubPktID = -// 6491, _pubBody = "\241G\235!\175\252\158\183\145\224\246\172\SYN\130\131/\254\205\ENQ\GS?", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\168q\180\235Y\176\233\DC2z6\175%\SOH\200c&\131\DC2\134#\151\139\&2\ETX\130\DC4", _pubPktID = 2807, _pubBody = +// "`\EOT\158\236\t\225\128\235\197\172aw\173\147\&8\DC3\EOT\244+\249C)zO\156\191\199", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x6, 0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5, 0x19, 0x5b, 0xf1, 0x47, 0xeb, 0x21, 0xaf, - 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; - uint8_t topic_bytes[] = {0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x39, 0x0, 0x1a, 0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, + 0x25, 0x1, 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14, + 0xa, 0xf7, 0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, + 0x93, 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; + uint8_t topic_bytes[] = {0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1, + 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xf1, 0x47, 0xeb, 0x21, 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, - 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; + uint8_t msg_bytes[] = {0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, + 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 27; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6491, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2807, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\140r\DC3\130\161\ENQ", _pubPktID = -// 6491, _pubBody = "\241G\235!\175\252\158\183\145\224\246\172\SYN\130\131/\254\205\ENQ\GS?", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\168q\180\235Y\176\233\DC2z6\175%\SOH\200c&\131\DC2\134#\151\139\&2\ETX\130\DC4", _pubPktID = 2807, _pubBody = +// "`\EOT\158\236\t\225\128\235\197\172aw\173\147\&8\DC3\EOT\244+\249C)zO\156\191\199", _pubProps = []} TEST(Publish311QCTest, Decode10) { - uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x6, 0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5, 0x19, 0x5b, 0xf1, 0x47, 0xeb, 0x21, 0xaf, - 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; + uint8_t pkt[] = {0x3a, 0x39, 0x0, 0x1a, 0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, + 0x25, 0x1, 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14, + 0xa, 0xf7, 0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, + 0x93, 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -570,53 +572,59 @@ TEST(Publish311QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf1, 0x47, 0xeb, 0x21, 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, - 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1, + 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, + 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 6491); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 2807); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\239\238\236\203\SI", _pubPktID = -// 8912, _pubBody = "\fH\EOT\166q\ESC\ESC\185\177A", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\207\198\194\214\STX\139\&4_\212\172\NAKu:\233\181_\247\164\SUB", _pubPktID = 13284, _pubBody = +// "\154\166c\188;\235r\148\223\SYN\DEL", _pubProps = []} TEST(Publish311QCTest, Encode11) { - uint8_t pkt[] = {0x32, 0x13, 0x0, 0x5, 0xef, 0xee, 0xec, 0xcb, 0xf, 0x22, 0xd0, - 0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; - uint8_t topic_bytes[] = {0xef, 0xee, 0xec, 0xcb, 0xf}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x13, 0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, + 0xd4, 0xac, 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a, 0x33, + 0xe4, 0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; + uint8_t topic_bytes[] = {0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, + 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; + uint8_t msg_bytes[] = {0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + msg.payload_len = 11; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8912, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13284, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\239\238\236\203\SI", _pubPktID = -// 8912, _pubBody = "\fH\EOT\166q\ESC\ESC\185\177A", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\207\198\194\214\STX\139\&4_\212\172\NAKu:\233\181_\247\164\SUB", _pubPktID = 13284, _pubBody = +// "\154\166c\188;\235r\148\223\SYN\DEL", _pubProps = []} TEST(Publish311QCTest, Decode11) { - uint8_t pkt[] = {0x32, 0x13, 0x0, 0x5, 0xef, 0xee, 0xec, 0xcb, 0xf, 0x22, 0xd0, - 0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; + uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x13, 0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, + 0xd4, 0xac, 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a, 0x33, + 0xe4, 0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -624,53 +632,58 @@ TEST(Publish311QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xef, 0xee, 0xec, 0xcb, 0xf}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; - lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, + 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a}; + lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 8912); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); + EXPECT_EQ(packet_id, 13284); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "[", _pubPktID = 16570, _pubBody = -// "\173\247\147\148\f{|ku\211\&0\DC3\224\227di\ETX\214[\DEL\138I\133\r8{", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\159\US\147\DC3i\FS\CAN@\178\DC2\202\145>\185\195\148\f3@ \SOH\202\166\182\STX\v\130\SYN", _pubPktID = 25675, +// _pubBody = "\138\158G\154\229\140)?>\221\211<\190", _pubProps = []} TEST(Publish311QCTest, Encode12) { - uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x1, 0x5b, 0x40, 0xba, 0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, - 0x30, 0x13, 0xe0, 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; - uint8_t topic_bytes[] = {0x5b}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x2d, 0x0, 0x1c, 0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, + 0x3e, 0xb9, 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16, + 0x64, 0x4b, 0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; + uint8_t topic_bytes[] = {0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, 0x3e, 0xb9, + 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, 0x30, 0x13, 0xe0, - 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 13; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16570, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25675, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "[", _pubPktID = 16570, _pubBody = -// "\173\247\147\148\f{|ku\211\&0\DC3\224\227di\ETX\214[\DEL\138I\133\r8{", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\159\US\147\DC3i\FS\CAN@\178\DC2\202\145>\185\195\148\f3@ \SOH\202\166\182\STX\v\130\SYN", _pubPktID = 25675, +// _pubBody = "\138\158G\154\229\140)?>\221\211<\190", _pubProps = []} TEST(Publish311QCTest, Decode12) { - uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0x1, 0x5b, 0x40, 0xba, 0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, - 0x30, 0x13, 0xe0, 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; + uint8_t pkt[] = {0x3d, 0x2d, 0x0, 0x1c, 0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, + 0x3e, 0xb9, 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16, + 0x64, 0x4b, 0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -678,51 +691,56 @@ TEST(Publish311QCTest, Decode12) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5b}; - lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xad, 0xf7, 0x93, 0x94, 0xc, 0x7b, 0x7c, 0x6b, 0x75, 0xd3, 0x30, 0x13, 0xe0, - 0xe3, 0x64, 0x69, 0x3, 0xd6, 0x5b, 0x7f, 0x8a, 0x49, 0x85, 0xd, 0x38, 0x7b}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, 0x3e, 0xb9, + 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 16570); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 25675); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\187Ue\150\168f\243G", _pubPktID = -// 0, _pubBody = "Y\133", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\185\246\SOH*\248(\178k\\\215\174", +// _pubPktID = 11115, _pubBody = ".\DC1\fEQhj\183\224@\215\"\231B\243L\206 \210\231\178", _pubProps = []} TEST(Publish311QCTest, Encode13) { - uint8_t pkt[] = {0x38, 0xc, 0x0, 0x8, 0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47, 0x59, 0x85}; - uint8_t topic_bytes[] = {0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x24, 0x0, 0xb, 0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, + 0xd7, 0xae, 0x2b, 0x6b, 0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, + 0x40, 0xd7, 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; + uint8_t topic_bytes[] = {0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, 0xd7, 0xae}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x59, 0x85}; + uint8_t msg_bytes[] = {0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, 0x40, 0xd7, + 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 11115, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\187Ue\150\168f\243G", _pubPktID = -// 0, _pubBody = "Y\133", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\185\246\SOH*\248(\178k\\\215\174", +// _pubPktID = 11115, _pubBody = ".\DC1\fEQhj\183\224@\215\"\231B\243L\206 \210\231\178", _pubProps = []} TEST(Publish311QCTest, Decode13) { - uint8_t pkt[] = {0x38, 0xc, 0x0, 0x8, 0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47, 0x59, 0x85}; + uint8_t pkt[] = {0x32, 0x24, 0x0, 0xb, 0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, + 0xd7, 0xae, 0x2b, 0x6b, 0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, + 0x40, 0xd7, 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -730,36 +748,35 @@ TEST(Publish311QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x59, 0x85}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + uint8_t exp_topic_bytes[] = {0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, 0xd7, 0xae}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, 0x40, 0xd7, + 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(packet_id, 11115); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\165\&4\a\246}\148\174\&8\186i\137\223\STX*Sv", _pubPktID = 0, _pubBody = "\243\233\SOH\134\243=c\212", _pubProps = -// []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\186\171$\215\213", _pubPktID = +// 24590, _pubBody = "En.&\166\184\215\153", _pubProps = []} TEST(Publish311QCTest, Encode14) { - uint8_t pkt[] = {0x30, 0x1a, 0x0, 0x10, 0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, 0xba, 0x69, - 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76, 0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; - uint8_t topic_bytes[] = {0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, - 0xba, 0x69, 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x11, 0x0, 0x5, 0xba, 0xab, 0x24, 0xd7, 0xd5, 0x60, + 0xe, 0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; + uint8_t topic_bytes[] = {0xba, 0xab, 0x24, 0xd7, 0xd5}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + uint8_t msg_bytes[] = {0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 8; @@ -767,18 +784,17 @@ TEST(Publish311QCTest, Encode14) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24590, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\165\&4\a\246}\148\174\&8\186i\137\223\STX*Sv", _pubPktID = 0, _pubBody = "\243\233\SOH\134\243=c\212", _pubProps = -// []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\186\171$\215\213", _pubPktID = +// 24590, _pubBody = "En.&\166\184\215\153", _pubProps = []} TEST(Publish311QCTest, Decode14) { - uint8_t pkt[] = {0x30, 0x1a, 0x0, 0x10, 0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, 0xba, 0x69, - 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76, 0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + uint8_t pkt[] = {0x34, 0x11, 0x0, 0x5, 0xba, 0xab, 0x24, 0xd7, 0xd5, 0x60, + 0xe, 0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -786,51 +802,55 @@ TEST(Publish311QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, - 0xba, 0x69, 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76}; - lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + uint8_t exp_topic_bytes[] = {0xba, 0xab, 0x24, 0xd7, 0xd5}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(packet_id, 24590); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); EXPECT_EQ(msg.payload_len, 8); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 10766, _pubBody = -// "\178", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\197R\255Y+\ACK", _pubPktID = 17354, +// _pubBody = "_\191\168\153\207\229\204<\169\234j\153A\153/^I\217,\159/\161\222\252?6", _pubProps = []} TEST(Publish311QCTest, Encode15) { - uint8_t pkt[] = {0x3b, 0x5, 0x0, 0x0, 0x2a, 0xe, 0xb2}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x24, 0x0, 0x6, 0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6, 0x43, 0xca, 0x5f, + 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, 0x99, + 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; + uint8_t topic_bytes[] = {0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xb2}; + uint8_t msg_bytes[] = {0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, + 0x99, 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 26; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10766, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 17354, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 10766, _pubBody = -// "\178", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\197R\255Y+\ACK", _pubPktID = 17354, +// _pubBody = "_\191\168\153\207\229\204<\169\234j\153A\153/^I\217,\159/\161\222\252?6", _pubProps = []} TEST(Publish311QCTest, Decode15) { - uint8_t pkt[] = {0x3b, 0x5, 0x0, 0x0, 0x2a, 0xe, 0xb2}; + uint8_t pkt[] = {0x3b, 0x24, 0x0, 0x6, 0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6, 0x43, 0xca, 0x5f, + 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, 0x99, + 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -838,52 +858,58 @@ TEST(Publish311QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb2}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, + 0x99, 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 10766); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(packet_id, 17354); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\138\GSJ\143\233", _pubPktID = 6943, -// _pubBody = "\137\139\192l\219\138Z\225\185\164}d\US[\179", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\181h\206\206#\148<\227\196\202?\ENQ\255\RSp\196\162\184\171\224", _pubPktID = 9053, _pubBody = +// "W\232(5\208_\210\199B\249E\178\157\128", _pubProps = []} TEST(Publish311QCTest, Encode16) { - uint8_t pkt[] = {0x3c, 0x18, 0x0, 0x5, 0x8a, 0x1d, 0x4a, 0x8f, 0xe9, 0x1b, 0x1f, 0x89, 0x8b, - 0xc0, 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; - uint8_t topic_bytes[] = {0x8a, 0x1d, 0x4a, 0x8f, 0xe9}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x26, 0x0, 0x14, 0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, + 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0, 0x23, 0x5d, 0x57, 0xe8, + 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; + uint8_t topic_bytes[] = {0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, + 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x89, 0x8b, 0xc0, 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; + uint8_t msg_bytes[] = {0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 14; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6943, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 9053, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\138\GSJ\143\233", _pubPktID = 6943, -// _pubBody = "\137\139\192l\219\138Z\225\185\164}d\US[\179", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\181h\206\206#\148<\227\196\202?\ENQ\255\RSp\196\162\184\171\224", _pubPktID = 9053, _pubBody = +// "W\232(5\208_\210\199B\249E\178\157\128", _pubProps = []} TEST(Publish311QCTest, Decode16) { - uint8_t pkt[] = {0x3c, 0x18, 0x0, 0x5, 0x8a, 0x1d, 0x4a, 0x8f, 0xe9, 0x1b, 0x1f, 0x89, 0x8b, - 0xc0, 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; + uint8_t pkt[] = {0x3c, 0x26, 0x0, 0x14, 0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, + 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0, 0x23, 0x5d, 0x57, 0xe8, + 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -891,37 +917,38 @@ TEST(Publish311QCTest, Decode16) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8a, 0x1d, 0x4a, 0x8f, 0xe9}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x89, 0x8b, 0xc0, 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, + 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 6943); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 9053); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\225y\a\222\215\130\238h\b\159\152x\153\151\162\213\177\165X\184]\135\187\189 \214", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\147\174\SYN ", _pubPktID = 0, +// _pubBody = "\155\DC3A*\157dh!\177=7\233\225\DLE|\EM\145", _pubProps = []} TEST(Publish311QCTest, Encode17) { - uint8_t pkt[] = {0x38, 0x1c, 0x0, 0x0, 0xe1, 0x79, 0x7, 0xde, 0xd7, 0x82, 0xee, 0x68, 0x8, 0x9f, 0x98, - 0x78, 0x99, 0x97, 0xa2, 0xd5, 0xb1, 0xa5, 0x58, 0xb8, 0x5d, 0x87, 0xbb, 0xbd, 0x20, 0xd6}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x17, 0x0, 0x4, 0x93, 0xae, 0x16, 0x20, 0x9b, 0x13, 0x41, 0x2a, 0x9d, + 0x64, 0x68, 0x21, 0xb1, 0x3d, 0x37, 0xe9, 0xe1, 0x10, 0x7c, 0x19, 0x91}; + uint8_t topic_bytes[] = {0x93, 0xae, 0x16, 0x20}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xe1, 0x79, 0x7, 0xde, 0xd7, 0x82, 0xee, 0x68, 0x8, 0x9f, 0x98, 0x78, 0x99, - 0x97, 0xa2, 0xd5, 0xb1, 0xa5, 0x58, 0xb8, 0x5d, 0x87, 0xbb, 0xbd, 0x20, 0xd6}; + msg.retained = true; + uint8_t msg_bytes[] = {0x9b, 0x13, 0x41, 0x2a, 0x9d, 0x64, 0x68, 0x21, 0xb1, + 0x3d, 0x37, 0xe9, 0xe1, 0x10, 0x7c, 0x19, 0x91}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; @@ -933,11 +960,11 @@ TEST(Publish311QCTest, Encode17) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\225y\a\222\215\130\238h\b\159\152x\153\151\162\213\177\165X\184]\135\187\189 \214", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\147\174\SYN ", _pubPktID = 0, +// _pubBody = "\155\DC3A*\157dh!\177=7\233\225\DLE|\EM\145", _pubProps = []} TEST(Publish311QCTest, Decode17) { - uint8_t pkt[] = {0x38, 0x1c, 0x0, 0x0, 0xe1, 0x79, 0x7, 0xde, 0xd7, 0x82, 0xee, 0x68, 0x8, 0x9f, 0x98, - 0x78, 0x99, 0x97, 0xa2, 0xd5, 0xb1, 0xa5, 0x58, 0xb8, 0x5d, 0x87, 0xbb, 0xbd, 0x20, 0xd6}; + uint8_t pkt[] = {0x39, 0x17, 0x0, 0x4, 0x93, 0xae, 0x16, 0x20, 0x9b, 0x13, 0x41, 0x2a, 0x9d, + 0x64, 0x68, 0x21, 0xb1, 0x3d, 0x37, 0xe9, 0xe1, 0x10, 0x7c, 0x19, 0x91}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -945,58 +972,59 @@ TEST(Publish311QCTest, Decode17) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xe1, 0x79, 0x7, 0xde, 0xd7, 0x82, 0xee, 0x68, 0x8, 0x9f, 0x98, 0x78, 0x99, - 0x97, 0xa2, 0xd5, 0xb1, 0xa5, 0x58, 0xb8, 0x5d, 0x87, 0xbb, 0xbd, 0x20, 0xd6}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x93, 0xae, 0x16, 0x20}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9b, 0x13, 0x41, 0x2a, 0x9d, 0x64, 0x68, 0x21, 0xb1, + 0x3d, 0x37, 0xe9, 0xe1, 0x10, 0x7c, 0x19, 0x91}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "6\218tea\v\174S\163\234\130\GS\208\155\GS\DLE\ENQ\ESC\178\165 \153\DC2\155v,\165", _pubPktID = 27993, _pubBody = -// "\158 %1\177\201\t\236L", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "t\183\232G\148\143\148J\151\141\197\&0\196\244?(x\225\237\EM", _pubPktID = 0, _pubBody = +// "\ESC\231\EM\255\149&\\p\RS\173+\194\173\204\183u\131G\218", _pubProps = []} TEST(Publish311QCTest, Encode18) { - uint8_t pkt[] = {0x32, 0x28, 0x0, 0x1b, 0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, - 0x82, 0x1d, 0xd0, 0x9b, 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, - 0x76, 0x2c, 0xa5, 0x6d, 0x59, 0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; - uint8_t topic_bytes[] = {0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, 0xd0, 0x9b, - 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x29, 0x0, 0x14, 0x74, 0xb7, 0xe8, 0x47, 0x94, 0x8f, 0x94, 0x4a, 0x97, 0x8d, 0xc5, + 0x30, 0xc4, 0xf4, 0x3f, 0x28, 0x78, 0xe1, 0xed, 0x19, 0x1b, 0xe7, 0x19, 0xff, 0x95, 0x26, + 0x5c, 0x70, 0x1e, 0xad, 0x2b, 0xc2, 0xad, 0xcc, 0xb7, 0x75, 0x83, 0x47, 0xda}; + uint8_t topic_bytes[] = {0x74, 0xb7, 0xe8, 0x47, 0x94, 0x8f, 0x94, 0x4a, 0x97, 0x8d, + 0xc5, 0x30, 0xc4, 0xf4, 0x3f, 0x28, 0x78, 0xe1, 0xed, 0x19}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; + uint8_t msg_bytes[] = {0x1b, 0xe7, 0x19, 0xff, 0x95, 0x26, 0x5c, 0x70, 0x1e, 0xad, + 0x2b, 0xc2, 0xad, 0xcc, 0xb7, 0x75, 0x83, 0x47, 0xda}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 27993, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "6\218tea\v\174S\163\234\130\GS\208\155\GS\DLE\ENQ\ESC\178\165 \153\DC2\155v,\165", _pubPktID = 27993, _pubBody = -// "\158 %1\177\201\t\236L", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "t\183\232G\148\143\148J\151\141\197\&0\196\244?(x\225\237\EM", _pubPktID = 0, _pubBody = +// "\ESC\231\EM\255\149&\\p\RS\173+\194\173\204\183u\131G\218", _pubProps = []} TEST(Publish311QCTest, Decode18) { - uint8_t pkt[] = {0x32, 0x28, 0x0, 0x1b, 0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, - 0x82, 0x1d, 0xd0, 0x9b, 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, - 0x76, 0x2c, 0xa5, 0x6d, 0x59, 0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; + uint8_t pkt[] = {0x38, 0x29, 0x0, 0x14, 0x74, 0xb7, 0xe8, 0x47, 0x94, 0x8f, 0x94, 0x4a, 0x97, 0x8d, 0xc5, + 0x30, 0xc4, 0xf4, 0x3f, 0x28, 0x78, 0xe1, 0xed, 0x19, 0x1b, 0xe7, 0x19, 0xff, 0x95, 0x26, + 0x5c, 0x70, 0x1e, 0xad, 0x2b, 0xc2, 0xad, 0xcc, 0xb7, 0x75, 0x83, 0x47, 0xda}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1004,58 +1032,55 @@ TEST(Publish311QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, 0xd0, 0x9b, - 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x74, 0xb7, 0xe8, 0x47, 0x94, 0x8f, 0x94, 0x4a, 0x97, 0x8d, + 0xc5, 0x30, 0xc4, 0xf4, 0x3f, 0x28, 0x78, 0xe1, 0xed, 0x19}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1b, 0xe7, 0x19, 0xff, 0x95, 0x26, 0x5c, 0x70, 0x1e, 0xad, + 0x2b, 0xc2, 0xad, 0xcc, 0xb7, 0x75, 0x83, 0x47, 0xda}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 27993); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "IP~U\245v\179O\ETB\247\SUB\152i\169\208", _pubPktID = 1633, _pubBody = -// "\164\215\&1Ym\133Ie\197\EOT\147\DC3}g\SUB\150\143", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\245l-\185\147\\\ai\199\183\216s\232\\\248\DC4\199\231[\DC4\139", _pubProps = []} TEST(Publish311QCTest, Encode19) { - uint8_t pkt[] = {0x3d, 0x24, 0x0, 0xf, 0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, - 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0, 0x6, 0x61, 0xa4, 0xd7, 0x31, 0x59, 0x6d, - 0x85, 0x49, 0x65, 0xc5, 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; - uint8_t topic_bytes[] = {0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x17, 0x0, 0x0, 0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, + 0xb7, 0xd8, 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa4, 0xd7, 0x31, 0x59, 0x6d, 0x85, 0x49, 0x65, 0xc5, - 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, 0xd8, + 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1633, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "IP~U\245v\179O\ETB\247\SUB\152i\169\208", _pubPktID = 1633, _pubBody = -// "\164\215\&1Ym\133Ie\197\EOT\147\DC3}g\SUB\150\143", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\245l-\185\147\\\ai\199\183\216s\232\\\248\DC4\199\231[\DC4\139", _pubProps = []} TEST(Publish311QCTest, Decode19) { - uint8_t pkt[] = {0x3d, 0x24, 0x0, 0xf, 0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, - 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0, 0x6, 0x61, 0xa4, 0xd7, 0x31, 0x59, 0x6d, - 0x85, 0x49, 0x65, 0xc5, 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; + uint8_t pkt[] = {0x30, 0x17, 0x0, 0x0, 0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, + 0xb7, 0xd8, 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1063,54 +1088,59 @@ TEST(Publish311QCTest, Decode19) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, - 0x17, 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa4, 0xd7, 0x31, 0x59, 0x6d, 0x85, 0x49, 0x65, 0xc5, - 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 1633); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, 0xd8, + 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\bm\162F\236O\211D\179\164@\195\244", _pubPktID = 19046, _pubBody = ".\167H\139", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "B&&P~\USwi\200\237U\SI0[8\205\ETX\US\171\236", _pubPktID = 20579, _pubBody = +// "\160|,\236\153`\132S\ETBj\210-v\ETB\US\246\DC4>iK\158\SOH\141\250", _pubProps = []} TEST(Publish311QCTest, Encode20) { - uint8_t pkt[] = {0x35, 0x15, 0x0, 0xd, 0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, - 0xb3, 0xa4, 0x40, 0xc3, 0xf4, 0x4a, 0x66, 0x2e, 0xa7, 0x48, 0x8b}; - uint8_t topic_bytes[] = {0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, 0xb3, 0xa4, 0x40, 0xc3, 0xf4}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x30, 0x0, 0x14, 0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, 0x55, 0xf, 0x30, + 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec, 0x50, 0x63, 0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, + 0x17, 0x6a, 0xd2, 0x2d, 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; + uint8_t topic_bytes[] = {0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, + 0x55, 0xf, 0x30, 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x2e, 0xa7, 0x48, 0x8b}; + uint8_t msg_bytes[] = {0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, 0x2d, + 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 24; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19046, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 20579, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\bm\162F\236O\211D\179\164@\195\244", _pubPktID = 19046, _pubBody = ".\167H\139", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "B&&P~\USwi\200\237U\SI0[8\205\ETX\US\171\236", _pubPktID = 20579, _pubBody = +// "\160|,\236\153`\132S\ETBj\210-v\ETB\US\246\DC4>iK\158\SOH\141\250", _pubProps = []} TEST(Publish311QCTest, Decode20) { - uint8_t pkt[] = {0x35, 0x15, 0x0, 0xd, 0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, - 0xb3, 0xa4, 0x40, 0xc3, 0xf4, 0x4a, 0x66, 0x2e, 0xa7, 0x48, 0x8b}; + uint8_t pkt[] = {0x3d, 0x30, 0x0, 0x14, 0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, 0x55, 0xf, 0x30, + 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec, 0x50, 0x63, 0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, + 0x17, 0x6a, 0xd2, 0x2d, 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1118,52 +1148,59 @@ TEST(Publish311QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, 0xb3, 0xa4, 0x40, 0xc3, 0xf4}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2e, 0xa7, 0x48, 0x8b}; - lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, + 0x55, 0xf, 0x30, 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, 0x2d, + 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 19046); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 4); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + EXPECT_EQ(packet_id, 20579); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "%\134\216", _pubPktID = 0, _pubBody -// = "\ETB\162T\161\139s\238\233\229.\233\243\186", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "Wo\249\180\STXZ\FS\218Co_\137a\140\&9^\232\186\143\230", _pubPktID = 10935, _pubBody = +// "\US\177vw\219K\147TS\150\&9", _pubProps = []} TEST(Publish311QCTest, Encode21) { - uint8_t pkt[] = {0x38, 0x12, 0x0, 0x3, 0x25, 0x86, 0xd8, 0x17, 0xa2, 0x54, - 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; - uint8_t topic_bytes[] = {0x25, 0x86, 0xd8}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x23, 0x0, 0x14, 0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, + 0x6f, 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6, 0x2a, 0xb7, + 0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; + uint8_t topic_bytes[] = {0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, + 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x17, 0xa2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 11; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10935, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "%\134\216", _pubPktID = 0, _pubBody -// = "\ETB\162T\161\139s\238\233\229.\233\243\186", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "Wo\249\180\STXZ\FS\218Co_\137a\140\&9^\232\186\143\230", _pubPktID = 10935, _pubBody = +// "\US\177vw\219K\147TS\150\&9", _pubProps = []} TEST(Publish311QCTest, Decode21) { - uint8_t pkt[] = {0x38, 0x12, 0x0, 0x3, 0x25, 0x86, 0xd8, 0x17, 0xa2, 0x54, - 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + uint8_t pkt[] = {0x3d, 0x23, 0x0, 0x14, 0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, + 0x6f, 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6, 0x2a, 0xb7, + 0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1171,57 +1208,54 @@ TEST(Publish311QCTest, Decode21) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x25, 0x86, 0xd8}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x17, 0xa2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, + 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 13); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10935); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\230\237\153c\242P\179\141\223\&2\205Z{\223\153", _pubPktID = 22947, _pubBody = -// "\195\148\247\&4\177\f%\149>q\236W\ETB-\a\209y\n\133o\172*:\131aY", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "z\187}l", _pubPktID = 11378, +// _pubBody = "\186\&7\190\f\178\235\212\242\166(\ENQ\181\SUB\234\&4\149H\SYN6\197\247\207", _pubProps = []} TEST(Publish311QCTest, Encode22) { - uint8_t pkt[] = {0x3a, 0x2d, 0x0, 0xf, 0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, - 0x7b, 0xdf, 0x99, 0x59, 0xa3, 0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, - 0x57, 0x17, 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; - uint8_t topic_bytes[] = {0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, 0x7b, 0xdf, 0x99}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x1e, 0x0, 0x4, 0x7a, 0xbb, 0x7d, 0x6c, 0x2c, 0x72, 0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, + 0xd4, 0xf2, 0xa6, 0x28, 0x5, 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; + uint8_t topic_bytes[] = {0x7a, 0xbb, 0x7d, 0x6c}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, - 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + uint8_t msg_bytes[] = {0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, 0xf2, 0xa6, 0x28, 0x5, + 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 22947, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 11378, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\230\237\153c\242P\179\141\223\&2\205Z{\223\153", _pubPktID = 22947, _pubBody = -// "\195\148\247\&4\177\f%\149>q\236W\ETB-\a\209y\n\133o\172*:\131aY", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "z\187}l", _pubPktID = 11378, +// _pubBody = "\186\&7\190\f\178\235\212\242\166(\ENQ\181\SUB\234\&4\149H\SYN6\197\247\207", _pubProps = []} TEST(Publish311QCTest, Decode22) { - uint8_t pkt[] = {0x3a, 0x2d, 0x0, 0xf, 0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, - 0x7b, 0xdf, 0x99, 0x59, 0xa3, 0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, - 0x57, 0x17, 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + uint8_t pkt[] = {0x34, 0x1e, 0x0, 0x4, 0x7a, 0xbb, 0x7d, 0x6c, 0x2c, 0x72, 0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, + 0xd4, 0xf2, 0xa6, 0x28, 0x5, 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1229,56 +1263,61 @@ TEST(Publish311QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, - 0xdf, 0x32, 0xcd, 0x5a, 0x7b, 0xdf, 0x99}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, - 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x7a, 0xbb, 0x7d, 0x6c}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, 0xf2, 0xa6, 0x28, 0x5, + 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 22947); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(packet_id, 11378); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\159q1\146\234\232\173\FS`\184\186\140\SYN=Z", _pubPktID = 12817, _pubBody = "EJwh\185\236\204#\166", _pubProps = -// []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\252\190\&8\149\&2\128\192{C\128\194\197\170g\a_\DC4\DELI(\151\218\172\vBJ\234\221", _pubPktID = 0, _pubBody = +// "q\145\203\144\245\153\&3\220g\186\&9YVh\DEL\232\&2V\212\201\&4\172?\189S\159<\187W", _pubProps = []} TEST(Publish311QCTest, Encode23) { - uint8_t pkt[] = {0x33, 0x1c, 0x0, 0xf, 0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, - 0x8c, 0x16, 0x3d, 0x5a, 0x32, 0x11, 0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; - uint8_t topic_bytes[] = {0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, 0x8c, 0x16, 0x3d, 0x5a}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x3b, 0x0, 0x1c, 0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, + 0xaa, 0x67, 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd, + 0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, 0xe8, + 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; + uint8_t topic_bytes[] = {0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, 0xaa, 0x67, + 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + uint8_t msg_bytes[] = {0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, + 0xe8, 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 29; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 12817, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\159q1\146\234\232\173\FS`\184\186\140\SYN=Z", _pubPktID = 12817, _pubBody = "EJwh\185\236\204#\166", _pubProps = -// []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\252\190\&8\149\&2\128\192{C\128\194\197\170g\a_\DC4\DELI(\151\218\172\vBJ\234\221", _pubPktID = 0, _pubBody = +// "q\145\203\144\245\153\&3\220g\186\&9YVh\DEL\232\&2V\212\201\&4\172?\189S\159<\187W", _pubProps = []} TEST(Publish311QCTest, Decode23) { - uint8_t pkt[] = {0x33, 0x1c, 0x0, 0xf, 0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, - 0x8c, 0x16, 0x3d, 0x5a, 0x32, 0x11, 0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + uint8_t pkt[] = {0x39, 0x3b, 0x0, 0x1c, 0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, + 0xaa, 0x67, 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd, + 0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, 0xe8, + 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1286,51 +1325,62 @@ TEST(Publish311QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, - 0x60, 0xb8, 0xba, 0x8c, 0x16, 0x3d, 0x5a}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, 0xaa, 0x67, + 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, + 0xe8, 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 12817); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "7_", _pubPktID = 0, _pubBody = -// "1l\172\222\&2J\173\154BN|", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\a\159\222j\236\175\242\&158\148@P\139o\150c\EOT\191\131\204\SUB\205\201\135W\193a", _pubPktID = 24983, _pubBody = +// "\214M\130;K\239#\136V\STX\242C\n\153\208l\129s\196\171\DC1P\193\218\128", _pubProps = []} TEST(Publish311QCTest, Encode24) { - uint8_t pkt[] = {0x30, 0xf, 0x0, 0x2, 0x37, 0x5f, 0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; - uint8_t topic_bytes[] = {0x37, 0x5f}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x39, 0x0, 0x1c, 0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, + 0x40, 0x50, 0x8b, 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, + 0xc1, 0x61, 0x61, 0x97, 0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, + 0x43, 0xa, 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; + uint8_t topic_bytes[] = {0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, 0x50, 0x8b, + 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, 0xa, + 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 25; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24983, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "7_", _pubPktID = 0, _pubBody = -// "1l\172\222\&2J\173\154BN|", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\a\159\222j\236\175\242\&158\148@P\139o\150c\EOT\191\131\204\SUB\205\201\135W\193a", _pubPktID = 24983, _pubBody = +// "\214M\130;K\239#\136V\STX\242C\n\153\208l\129s\196\171\DC1P\193\218\128", _pubProps = []} TEST(Publish311QCTest, Decode24) { - uint8_t pkt[] = {0x30, 0xf, 0x0, 0x2, 0x37, 0x5f, 0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + uint8_t pkt[] = {0x35, 0x39, 0x0, 0x1c, 0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, + 0x40, 0x50, 0x8b, 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, + 0xc1, 0x61, 0x61, 0x97, 0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, + 0x43, 0xa, 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1338,55 +1388,59 @@ TEST(Publish311QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x37, 0x5f}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, 0x50, 0x8b, + 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, 0xa, + 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 24983); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\246\202\200\133Ey", _pubPktID = -// 19152, _pubBody = "G\255\&5Bg\183\227x}.\158X\246mx\199u\250\US\ETXI\ENQ\249\155!rJ", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "[5,\230\144\137\236\202\179\STX\t\201\234\136\166", _pubPktID = 10487, _pubBody = +// "\DLE\ACK\165~\155\217?\249\195\GS\145\179=i'\223Wd\159\248<\223$", _pubProps = []} TEST(Publish311QCTest, Encode25) { - uint8_t pkt[] = {0x35, 0x25, 0x0, 0x6, 0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79, 0x4a, 0xd0, 0x47, - 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, - 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; - uint8_t topic_bytes[] = {0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x2a, 0x0, 0xf, 0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, + 0xc9, 0xea, 0x88, 0xa6, 0x28, 0xf7, 0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, + 0x1d, 0x91, 0xb3, 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; + uint8_t topic_bytes[] = {0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, 0xc9, 0xea, 0x88, 0xa6}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, - 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + msg.retained = false; + uint8_t msg_bytes[] = {0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, 0x1d, 0x91, 0xb3, + 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 23; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19152, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10487, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\246\202\200\133Ey", _pubPktID = -// 19152, _pubBody = "G\255\&5Bg\183\227x}.\158X\246mx\199u\250\US\ETXI\ENQ\249\155!rJ", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "[5,\230\144\137\236\202\179\STX\t\201\234\136\166", _pubPktID = 10487, _pubBody = +// "\DLE\ACK\165~\155\217?\249\195\GS\145\179=i'\223Wd\159\248<\223$", _pubProps = []} TEST(Publish311QCTest, Decode25) { - uint8_t pkt[] = {0x35, 0x25, 0x0, 0x6, 0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79, 0x4a, 0xd0, 0x47, - 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, - 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + uint8_t pkt[] = {0x34, 0x2a, 0x0, 0xf, 0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, + 0xc9, 0xea, 0x88, 0xa6, 0x28, 0xf7, 0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, + 0x1d, 0x91, 0xb3, 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1394,53 +1448,56 @@ TEST(Publish311QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, - 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, 0xc9, 0xea, 0x88, 0xa6}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, 0x1d, 0x91, 0xb3, + 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 19152); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 27); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 10487); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\\\211\215", _pubPktID = 7594, -// _pubBody = "\139\150\137\180\142\209{^\232\155\136\252\140\233\138", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "n\145", _pubPktID = 14089, _pubBody +// = "\210\210>L\150\rD\161j\204SG\219\226\165\205k\208\&4\ENQ\154t\DC1\148D:\US<\141\149", _pubProps = []} TEST(Publish311QCTest, Encode26) { - uint8_t pkt[] = {0x3c, 0x16, 0x0, 0x3, 0x5c, 0xd3, 0xd7, 0x1d, 0xaa, 0x8b, 0x96, 0x89, - 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; - uint8_t topic_bytes[] = {0x5c, 0xd3, 0xd7}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x24, 0x0, 0x2, 0x6e, 0x91, 0x37, 0x9, 0xd2, 0xd2, 0x3e, 0x4c, 0x96, + 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, 0xcd, 0x6b, 0xd0, + 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; + uint8_t topic_bytes[] = {0x6e, 0x91}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x8b, 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + msg.retained = true; + uint8_t msg_bytes[] = {0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, + 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 30; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7594, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 14089, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\\\211\215", _pubPktID = 7594, -// _pubBody = "\139\150\137\180\142\209{^\232\155\136\252\140\233\138", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "n\145", _pubPktID = 14089, _pubBody +// = "\210\210>L\150\rD\161j\204SG\219\226\165\205k\208\&4\ENQ\154t\DC1\148D:\US<\141\149", _pubProps = []} TEST(Publish311QCTest, Decode26) { - uint8_t pkt[] = {0x3c, 0x16, 0x0, 0x3, 0x5c, 0xd3, 0xd7, 0x1d, 0xaa, 0x8b, 0x96, 0x89, - 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + uint8_t pkt[] = {0x35, 0x24, 0x0, 0x2, 0x6e, 0x91, 0x37, 0x9, 0xd2, 0xd2, 0x3e, 0x4c, 0x96, + 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, 0xcd, 0x6b, 0xd0, + 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1448,57 +1505,56 @@ TEST(Publish311QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5c, 0xd3, 0xd7}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8b, 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x6e, 0x91}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, + 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 7594); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 14089); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "e9\242\201W\247\177\219AK\182\169", -// _pubPktID = 7929, _pubBody = "T\v\FS.x%\218\n\245\225\147\232\145qH\197\203m~\212\&0pk}\161\236\244$\162", _pubProps -// = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\199d\158\162p\SYNZ2{\228j\t\233'\211K\254\FSK\133%\252", _pubPktID = 0, _pubBody = "\SYN\ESC\r\233\&1\216\237", +// _pubProps = []} TEST(Publish311QCTest, Encode27) { - uint8_t pkt[] = {0x34, 0x2d, 0x0, 0xc, 0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9, - 0x1e, 0xf9, 0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, - 0x48, 0xc5, 0xcb, 0x6d, 0x7e, 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; - uint8_t topic_bytes[] = {0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x1f, 0x0, 0x16, 0xc7, 0x64, 0x9e, 0xa2, 0x70, 0x16, 0x5a, 0x32, 0x7b, 0xe4, 0x6a, 0x9, 0xe9, + 0x27, 0xd3, 0x4b, 0xfe, 0x1c, 0x4b, 0x85, 0x25, 0xfc, 0x16, 0x1b, 0xd, 0xe9, 0x31, 0xd8, 0xed}; + uint8_t topic_bytes[] = {0xc7, 0x64, 0x9e, 0xa2, 0x70, 0x16, 0x5a, 0x32, 0x7b, 0xe4, 0x6a, + 0x9, 0xe9, 0x27, 0xd3, 0x4b, 0xfe, 0x1c, 0x4b, 0x85, 0x25, 0xfc}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, 0x48, - 0xc5, 0xcb, 0x6d, 0x7e, 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; + uint8_t msg_bytes[] = {0x16, 0x1b, 0xd, 0xe9, 0x31, 0xd8, 0xed}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 7; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7929, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "e9\242\201W\247\177\219AK\182\169", -// _pubPktID = 7929, _pubBody = "T\v\FS.x%\218\n\245\225\147\232\145qH\197\203m~\212\&0pk}\161\236\244$\162", _pubProps -// = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\199d\158\162p\SYNZ2{\228j\t\233'\211K\254\FSK\133%\252", _pubPktID = 0, _pubBody = "\SYN\ESC\r\233\&1\216\237", +// _pubProps = []} TEST(Publish311QCTest, Decode27) { - uint8_t pkt[] = {0x34, 0x2d, 0x0, 0xc, 0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9, - 0x1e, 0xf9, 0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, - 0x48, 0xc5, 0xcb, 0x6d, 0x7e, 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; + uint8_t pkt[] = {0x38, 0x1f, 0x0, 0x16, 0xc7, 0x64, 0x9e, 0xa2, 0x70, 0x16, 0x5a, 0x32, 0x7b, 0xe4, 0x6a, 0x9, 0xe9, + 0x27, 0xd3, 0x4b, 0xfe, 0x1c, 0x4b, 0x85, 0x25, 0xfc, 0x16, 0x1b, 0xd, 0xe9, 0x31, 0xd8, 0xed}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1506,59 +1562,51 @@ TEST(Publish311QCTest, Decode27) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x65, 0x39, 0xf2, 0xc9, 0x57, 0xf7, 0xb1, 0xdb, 0x41, 0x4b, 0xb6, 0xa9}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x54, 0xb, 0x1c, 0x2e, 0x78, 0x25, 0xda, 0xa, 0xf5, 0xe1, 0x93, 0xe8, 0x91, 0x71, 0x48, - 0xc5, 0xcb, 0x6d, 0x7e, 0xd4, 0x30, 0x70, 0x6b, 0x7d, 0xa1, 0xec, 0xf4, 0x24, 0xa2}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0xc7, 0x64, 0x9e, 0xa2, 0x70, 0x16, 0x5a, 0x32, 0x7b, 0xe4, 0x6a, + 0x9, 0xe9, 0x27, 0xd3, 0x4b, 0xfe, 0x1c, 0x4b, 0x85, 0x25, 0xfc}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x16, 0x1b, 0xd, 0xe9, 0x31, 0xd8, 0xed}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 7929); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\235\160n\156\199\DC14\f\233\197\243\207\145\204|J/\129\156\&5$&Z", _pubPktID = 0, _pubBody = -// "\143\195\191\225_\213\191E\230c\156\216\152\CAN\208\204-", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\DELB\171!\189\RS\129\132", _pubPktID +// = 1997, _pubBody = "P\169", _pubProps = []} TEST(Publish311QCTest, Encode28) { - uint8_t pkt[] = {0x39, 0x2a, 0x0, 0x17, 0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, - 0xcf, 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a, 0x8f, 0xc3, 0xbf, - 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; - uint8_t topic_bytes[] = {0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, 0xcf, - 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0xe, 0x0, 0x8, 0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84, 0x7, 0xcd, 0x50, 0xa9}; + uint8_t topic_bytes[] = {0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x8f, 0xc3, 0xbf, 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, - 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + uint8_t msg_bytes[] = {0x50, 0xa9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 2; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1997, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\235\160n\156\199\DC14\f\233\197\243\207\145\204|J/\129\156\&5$&Z", _pubPktID = 0, _pubBody = -// "\143\195\191\225_\213\191E\230c\156\216\152\CAN\208\204-", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\DELB\171!\189\RS\129\132", _pubPktID +// = 1997, _pubBody = "P\169", _pubProps = []} TEST(Publish311QCTest, Decode28) { - uint8_t pkt[] = {0x39, 0x2a, 0x0, 0x17, 0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, - 0xcf, 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a, 0x8f, 0xc3, 0xbf, - 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + uint8_t pkt[] = {0x3d, 0xe, 0x0, 0x8, 0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84, 0x7, 0xcd, 0x50, 0xa9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1566,54 +1614,52 @@ TEST(Publish311QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, 0xcf, - 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8f, 0xc3, 0xbf, 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, - 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x50, 0xa9}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(packet_id, 1997); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\182~R\STX\198L\RS%^\137\162\228\&70", _pubPktID = 1453, _pubBody = "\188=\n\155\249", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\138.\149\DC3{U\CANP\144", +// _pubPktID = 16970, _pubBody = "4\163\252\250\166\SUB\245\158", _pubProps = []} TEST(Publish311QCTest, Encode29) { - uint8_t pkt[] = {0x3d, 0x17, 0x0, 0xe, 0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, - 0x89, 0xa2, 0xe4, 0x37, 0x30, 0x5, 0xad, 0xbc, 0x3d, 0xa, 0x9b, 0xf9}; - uint8_t topic_bytes[] = {0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, 0x37, 0x30}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x15, 0x0, 0x9, 0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, + 0x90, 0x42, 0x4a, 0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; + uint8_t topic_bytes[] = {0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, 0x90}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + msg.payload_len = 8; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1453, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16970, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\182~R\STX\198L\RS%^\137\162\228\&70", _pubPktID = 1453, _pubBody = "\188=\n\155\249", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\138.\149\DC3{U\CANP\144", +// _pubPktID = 16970, _pubBody = "4\163\252\250\166\SUB\245\158", _pubProps = []} TEST(Publish311QCTest, Decode29) { - uint8_t pkt[] = {0x3d, 0x17, 0x0, 0xe, 0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, - 0x89, 0xa2, 0xe4, 0x37, 0x30, 0x5, 0xad, 0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + uint8_t pkt[] = {0x32, 0x15, 0x0, 0x9, 0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, + 0x90, 0x42, 0x4a, 0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1621,52 +1667,55 @@ TEST(Publish311QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, 0x37, 0x30}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbc, 0x3d, 0xa, 0x9b, 0xf9}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 1453); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + uint8_t exp_topic_bytes[] = {0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, 0x90}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; + lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 16970); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 8); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\191k-$.\245\SUB\192\234\155$", -// _pubPktID = 29170, _pubBody = "[F\181\186O\149", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3r\ETX\ETXZ\SOH", _pubPktID = 0, +// _pubBody = "\129\209\171[\DC4B\234\ETX\ACK\177\133\&9\ENQf\128\DC1A\185\236M\134qT}\\g\159&;g", _pubProps = []} TEST(Publish311QCTest, Encode30) { - uint8_t pkt[] = {0x33, 0x15, 0x0, 0xb, 0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, - 0xea, 0x9b, 0x24, 0x71, 0xf2, 0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; - uint8_t topic_bytes[] = {0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x26, 0x0, 0x6, 0x13, 0x72, 0x3, 0x3, 0x5a, 0x1, 0x81, 0xd1, 0xab, 0x5b, + 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, 0x11, 0x41, 0xb9, + 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; + uint8_t topic_bytes[] = {0x13, 0x72, 0x3, 0x3, 0x5a, 0x1}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + uint8_t msg_bytes[] = {0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, + 0x11, 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 30; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29170, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\191k-$.\245\SUB\192\234\155$", -// _pubPktID = 29170, _pubBody = "[F\181\186O\149", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3r\ETX\ETXZ\SOH", _pubPktID = 0, +// _pubBody = "\129\209\171[\DC4B\234\ETX\ACK\177\133\&9\ENQf\128\DC1A\185\236M\134qT}\\g\159&;g", _pubProps = []} TEST(Publish311QCTest, Decode30) { - uint8_t pkt[] = {0x33, 0x15, 0x0, 0xb, 0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, - 0xea, 0x9b, 0x24, 0x71, 0xf2, 0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + uint8_t pkt[] = {0x31, 0x26, 0x0, 0x6, 0x13, 0x72, 0x3, 0x3, 0x5a, 0x1, 0x81, 0xd1, 0xab, 0x5b, + 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, 0x11, 0x41, 0xb9, + 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1674,71 +1723,95 @@ TEST(Publish311QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; - lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x13, 0x72, 0x3, 0x3, 0x5a, 0x1}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, + 0x11, 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29170); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 6); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = ";\152\218", _pubPktID = 5070, -// _pubBody = "]&\234\205\156\200\SYN\185\NUL\214}\239\191\&6\154waT{\246\173\DC4k\155\211\190", _pubProps = -// [PropPayloadFormatIndicator 221,PropMaximumPacketSize 3004,PropResponseInformation -// "<.\174Oy\SI&D{D\209\175\f\235\242\181\136\195\173*\ETB`\206\DC2",PropTopicAlias 16144]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\DC1\"\211\207\n{Z%\217\200gfi\182\210US5", _pubPktID = 0, _pubBody = +// "\DEL\211\247\135\US>`\222\&5\231AJo1JP\244\231\252\&7\211\&32]", _pubProps = [PropReasonString +// "\167\252e\ESC7\188\&2\r\174\255\205\221",PropWillDelayInterval 4231,PropTopicAlias 29603,PropSubscriptionIdentifier +// 14,PropReasonString "\"\168\DC1x;\218\STX\SUBa\230\159\222\187",PropTopicAlias 3637,PropResponseTopic +// "{\166\r\223\SYN\221",PropTopicAliasMaximum 29040,PropTopicAlias 10048,PropAssignedClientIdentifier +// "\198&\152",PropTopicAliasMaximum 2366,PropMessageExpiryInterval 5348]} TEST(Publish5QCTest, Encode1) { - uint8_t pkt[] = {0x3d, 0x47, 0x0, 0x3, 0x3b, 0x98, 0xda, 0x13, 0xce, 0x25, 0x1, 0xdd, 0x27, 0x0, 0x0, - 0xb, 0xbc, 0x1a, 0x0, 0x18, 0x3c, 0x2e, 0xae, 0x4f, 0x79, 0xf, 0x26, 0x44, 0x7b, 0x44, - 0xd1, 0xaf, 0xc, 0xeb, 0xf2, 0xb5, 0x88, 0xc3, 0xad, 0x2a, 0x17, 0x60, 0xce, 0x12, 0x23, - 0x3f, 0x10, 0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, - 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; - uint8_t topic_bytes[] = {0x3b, 0x98, 0xda}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x76, 0x0, 0x12, 0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, 0xc8, 0x67, + 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35, 0x49, 0x1f, 0x0, 0xc, 0xa7, 0xfc, 0x65, 0x1b, + 0x37, 0xbc, 0x32, 0xd, 0xae, 0xff, 0xcd, 0xdd, 0x18, 0x0, 0x0, 0x10, 0x87, 0x23, 0x73, + 0xa3, 0xb, 0xe, 0x1f, 0x0, 0xd, 0x22, 0xa8, 0x11, 0x78, 0x3b, 0xda, 0x2, 0x1a, 0x61, + 0xe6, 0x9f, 0xde, 0xbb, 0x23, 0xe, 0x35, 0x8, 0x0, 0x6, 0x7b, 0xa6, 0xd, 0xdf, 0x16, + 0xdd, 0x22, 0x71, 0x70, 0x23, 0x27, 0x40, 0x12, 0x0, 0x3, 0xc6, 0x26, 0x98, 0x22, 0x9, + 0x3e, 0x2, 0x0, 0x0, 0x14, 0xe4, 0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, + 0xe7, 0x41, 0x4a, 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; + uint8_t topic_bytes[] = {0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, + 0xc8, 0x67, 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, - 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, 0x41, 0x4a, + 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 24; - uint8_t bytesprops0[] = {0x3c, 0x2e, 0xae, 0x4f, 0x79, 0xf, 0x26, 0x44, 0x7b, 0x44, 0xd1, 0xaf, - 0xc, 0xeb, 0xf2, 0xb5, 0x88, 0xc3, 0xad, 0x2a, 0x17, 0x60, 0xce, 0x12}; + uint8_t bytesprops0[] = {0xa7, 0xfc, 0x65, 0x1b, 0x37, 0xbc, 0x32, 0xd, 0xae, 0xff, 0xcd, 0xdd}; + uint8_t bytesprops1[] = {0x22, 0xa8, 0x11, 0x78, 0x3b, 0xda, 0x2, 0x1a, 0x61, 0xe6, 0x9f, 0xde, 0xbb}; + uint8_t bytesprops2[] = {0x7b, 0xa6, 0xd, 0xdf, 0x16, 0xdd}; + uint8_t bytesprops3[] = {0xc6, 0x26, 0x98}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3004}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16144}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4231}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29603}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3637}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29040}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10048}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2366}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5348}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5070, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = ";\152\218", _pubPktID = 5070, -// _pubBody = "]&\234\205\156\200\SYN\185\NUL\214}\239\191\&6\154waT{\246\173\DC4k\155\211\190", _pubProps = -// [PropPayloadFormatIndicator 221,PropMaximumPacketSize 3004,PropResponseInformation -// "<.\174Oy\SI&D{D\209\175\f\235\242\181\136\195\173*\ETB`\206\DC2",PropTopicAlias 16144]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\DC1\"\211\207\n{Z%\217\200gfi\182\210US5", _pubPktID = 0, _pubBody = +// "\DEL\211\247\135\US>`\222\&5\231AJo1JP\244\231\252\&7\211\&32]", _pubProps = [PropReasonString +// "\167\252e\ESC7\188\&2\r\174\255\205\221",PropWillDelayInterval 4231,PropTopicAlias 29603,PropSubscriptionIdentifier +// 14,PropReasonString "\"\168\DC1x;\218\STX\SUBa\230\159\222\187",PropTopicAlias 3637,PropResponseTopic +// "{\166\r\223\SYN\221",PropTopicAliasMaximum 29040,PropTopicAlias 10048,PropAssignedClientIdentifier +// "\198&\152",PropTopicAliasMaximum 2366,PropMessageExpiryInterval 5348]} TEST(Publish5QCTest, Decode1) { - uint8_t pkt[] = {0x3d, 0x47, 0x0, 0x3, 0x3b, 0x98, 0xda, 0x13, 0xce, 0x25, 0x1, 0xdd, 0x27, 0x0, 0x0, - 0xb, 0xbc, 0x1a, 0x0, 0x18, 0x3c, 0x2e, 0xae, 0x4f, 0x79, 0xf, 0x26, 0x44, 0x7b, 0x44, - 0xd1, 0xaf, 0xc, 0xeb, 0xf2, 0xb5, 0x88, 0xc3, 0xad, 0x2a, 0x17, 0x60, 0xce, 0x12, 0x23, - 0x3f, 0x10, 0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, - 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; + uint8_t pkt[] = {0x38, 0x76, 0x0, 0x12, 0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, 0xc8, 0x67, + 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35, 0x49, 0x1f, 0x0, 0xc, 0xa7, 0xfc, 0x65, 0x1b, + 0x37, 0xbc, 0x32, 0xd, 0xae, 0xff, 0xcd, 0xdd, 0x18, 0x0, 0x0, 0x10, 0x87, 0x23, 0x73, + 0xa3, 0xb, 0xe, 0x1f, 0x0, 0xd, 0x22, 0xa8, 0x11, 0x78, 0x3b, 0xda, 0x2, 0x1a, 0x61, + 0xe6, 0x9f, 0xde, 0xbb, 0x23, 0xe, 0x35, 0x8, 0x0, 0x6, 0x7b, 0xa6, 0xd, 0xdf, 0x16, + 0xdd, 0x22, 0x71, 0x70, 0x23, 0x27, 0x40, 0x12, 0x0, 0x3, 0xc6, 0x26, 0x98, 0x22, 0x9, + 0x3e, 0x2, 0x0, 0x0, 0x14, 0xe4, 0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, + 0xe7, 0x41, 0x4a, 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1746,134 +1819,187 @@ TEST(Publish5QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3b, 0x98, 0xda}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5d, 0x26, 0xea, 0xcd, 0x9c, 0xc8, 0x16, 0xb9, 0x0, 0xd6, 0x7d, 0xef, 0xbf, - 0x36, 0x9a, 0x77, 0x61, 0x54, 0x7b, 0xf6, 0xad, 0x14, 0x6b, 0x9b, 0xd3, 0xbe}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, + 0xc8, 0x67, 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, 0x41, 0x4a, + 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 5070); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\156n m\218\DC4\ENQ\RS\r\221", -// _pubPktID = 29842, _pubBody = "\n\r\194\171\&847\188\r\239=\228G\244\204\183o\136\148\223SQ", _pubProps = -// [PropSubscriptionIdentifier 25,PropPayloadFormatIndicator 184,PropAuthenticationMethod -// "t\195I,\139+",PropWildcardSubscriptionAvailable 103,PropReasonString -// "B\241\187.\253b\145\f>~\159T`\201\NAK'm\222\t\153\160\136",PropMaximumQoS 116,PropPayloadFormatIndicator -// 39,PropReasonString ":\SUB\160#\206\247\173@\DLEP\243\176N\252Ag\149n\222",PropWildcardSubscriptionAvailable -// 101,PropSubscriptionIdentifier 14,PropTopicAliasMaximum 14696,PropReasonString "LN\176",PropRetainAvailable -// 253,PropPayloadFormatIndicator 106,PropServerReference -// "C\a\138X2S\225\157\222\187n\SYN\DEL\171\181\DEL\STXk\b\217",PropCorrelationData -// "\147\245\&8OJ\253",PropWildcardSubscriptionAvailable 8,PropWillDelayInterval -// 12301,PropSubscriptionIdentifierAvailable 138,PropSubscriptionIdentifier 31,PropRequestResponseInformation -// 103,PropMaximumPacketSize 8390,PropAuthenticationData "\EOT\253]\186J-K\206r;e\225\158",PropMessageExpiryInterval -// 26352,PropRequestResponseInformation 214,PropWillDelayInterval 13619]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\212", _pubPktID = 10216, +// _pubBody = "\241", _pubProps = [PropWillDelayInterval 6725,PropServerReference +// "\253w#\215\181Z\189\135\196H",PropAuthenticationMethod +// "\ESC\160\"S\250R\161\NAK\131\"\214\v\134Nd\199\219\230\139",PropAssignedClientIdentifier +// "e\233/\167Z\187uF\NUL\241\128q+YFH\146\241\224\147\245\223",PropReasonString +// "JJ{'\161\&7\EOTV\160\165xP\DLE-h\193[\129\198\168\180U\152\ETX\171\236G\199",PropMessageExpiryInterval +// 26844,PropResponseInformation +// "\201\213\DC3\149s\201\&0m\159\210A$\212L\DC1\145B\ESC\250\205'm\US\149\144\\\147ZH",PropContentType +// "\235\134\253Y\255\148#F\192\SUB\152<\174na\254\ETB\251\EOT",PropAssignedClientIdentifier +// "\200\147_\194\170\201n`",PropServerKeepAlive 31945,PropPayloadFormatIndicator 36,PropSubscriptionIdentifierAvailable +// 90,PropAuthenticationMethod "t\218\147\160\172\128mZ\DC33R<`\165u\GSrdF\128",PropReasonString +// "\227\144#\DC2\203\195\162\194#X\"c_]}\201\216\181\&4\187\146rO\187,\244+\213%\163",PropWillDelayInterval +// 31366,PropAuthenticationMethod "\144\FS\227\199J\218\161\154_\130J\195Yt\187\197\170tV",PropRetainAvailable +// 210,PropResponseTopic "\148\ESCo\217\v",PropUserProperty +// "\"W\172\182\156\221\151\EOTC\165\207\&6\231\193\222S\ETB\ESCu" +// "\253\128\231=\172\CANT\f\139\202\236iE\157\177'b~\159T`\201\NAK'm\222\t\153\160\136",PropMaximumQoS 116,PropPayloadFormatIndicator -// 39,PropReasonString ":\SUB\160#\206\247\173@\DLEP\243\176N\252Ag\149n\222",PropWildcardSubscriptionAvailable -// 101,PropSubscriptionIdentifier 14,PropTopicAliasMaximum 14696,PropReasonString "LN\176",PropRetainAvailable -// 253,PropPayloadFormatIndicator 106,PropServerReference -// "C\a\138X2S\225\157\222\187n\SYN\DEL\171\181\DEL\STXk\b\217",PropCorrelationData -// "\147\245\&8OJ\253",PropWildcardSubscriptionAvailable 8,PropWillDelayInterval -// 12301,PropSubscriptionIdentifierAvailable 138,PropSubscriptionIdentifier 31,PropRequestResponseInformation -// 103,PropMaximumPacketSize 8390,PropAuthenticationData "\EOT\253]\186J-K\206r;e\225\158",PropMessageExpiryInterval -// 26352,PropRequestResponseInformation 214,PropWillDelayInterval 13619]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\212", _pubPktID = 10216, +// _pubBody = "\241", _pubProps = [PropWillDelayInterval 6725,PropServerReference +// "\253w#\215\181Z\189\135\196H",PropAuthenticationMethod +// "\ESC\160\"S\250R\161\NAK\131\"\214\v\134Nd\199\219\230\139",PropAssignedClientIdentifier +// "e\233/\167Z\187uF\NUL\241\128q+YFH\146\241\224\147\245\223",PropReasonString +// "JJ{'\161\&7\EOTV\160\165xP\DLE-h\193[\129\198\168\180U\152\ETX\171\236G\199",PropMessageExpiryInterval +// 26844,PropResponseInformation +// "\201\213\DC3\149s\201\&0m\159\210A$\212L\DC1\145B\ESC\250\205'm\US\149\144\\\147ZH",PropContentType +// "\235\134\253Y\255\148#F\192\SUB\152<\174na\254\ETB\251\EOT",PropAssignedClientIdentifier +// "\200\147_\194\170\201n`",PropServerKeepAlive 31945,PropPayloadFormatIndicator 36,PropSubscriptionIdentifierAvailable +// 90,PropAuthenticationMethod "t\218\147\160\172\128mZ\DC33R<`\165u\GSrdF\128",PropReasonString +// "\227\144#\DC2\203\195\162\194#X\"c_]}\201\216\181\&4\187\146rO\187,\244+\213%\163",PropWillDelayInterval +// 31366,PropAuthenticationMethod "\144\FS\227\199J\218\161\154_\130J\195Yt\187\197\170tV",PropRetainAvailable +// 210,PropResponseTopic "\148\ESCo\217\v",PropUserProperty +// "\"W\172\182\156\221\151\EOTC\165\207\&6\231\193\222S\ETB\ESCu" +// "\253\128\231=\172\CANT\f\139\202\236iE\157\177'b(topic.data), 10); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(packet_id, 10216); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\SUB\143\217", _pubPktID = 816, -// _pubBody = "\246^\255t\204\180\169\214\150&=\195\235\249\176Q\NAK\169\145", _pubProps = [PropTopicAliasMaximum -// 31796,PropRequestProblemInformation 166,PropTopicAlias 26535,PropSubscriptionIdentifier 4,PropServerReference -// "\227\160T'4-\188\159&\235RN\181\179d\153,\237w\193\&3\145\136",PropSubscriptionIdentifier -// 25,PropSharedSubscriptionAvailable 1,PropServerKeepAlive 630,PropServerReference "\226",PropAssignedClientIdentifier -// "\211",PropContentType "X",PropReceiveMaximum 7394,PropMessageExpiryInterval 1294,PropAuthenticationMethod -// "s",PropPayloadFormatIndicator 99,PropResponseTopic -// "7Q\148\235\CAN\DLE\234X\GSQ\134U\204\214@\213\248\151\165\185X\SYN4\188\218\218\&0\193",PropRequestResponseInformation -// 163,PropAuthenticationMethod " 6\248\138\207\STXX\147\203\217}\173\SI2\175\150",PropReceiveMaximum -// 26236,PropUserProperty "\157\173\137\143\144\rgTd\DC4\164\202\&2\130\ESC2\157" -// "\161\177#\149\206m\b!\158\145/3\148+\246\171u\144\&2\219\156\232\249",PropRequestProblemInformation -// 16,PropCorrelationData "\214\ESC\207",PropTopicAlias 17977,PropContentType -// "\238\&7\DELe\172\181\189\178\187\ACKB\155Q\199?b\197",PropRequestResponseInformation -// 197,PropAssignedClientIdentifier "",PropAuthenticationMethod -// "\163\192\138\&2\t\136\129\137_H\ETB\190\234\128\198\227bE\216u\193\FST\230\227q\223\206\ACK",PropAuthenticationData -// "&m#",PropRequestResponseInformation 161]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "}\162\DC3\157\161\140z\190\148\228\254\EOTk\211\&1\133\SI\188y\142\134e", _pubPktID = 11026, _pubBody = +// "\v/:\b\150\237Ih\224]\US\181R[r\179\234\185", _pubProps = [PropReasonString +// "\148P\EOT\247]b\DC3U,`3\DC4\207t\225\232",PropMessageExpiryInterval 23350,PropPayloadFormatIndicator +// 78,PropMessageExpiryInterval 19240,PropResponseInformation "\211\SOH\185\161",PropServerKeepAlive +// 24528,PropMaximumQoS 25]} TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = { - 0x35, 0x91, 0x2, 0x0, 0x3, 0x1a, 0x8f, 0xd9, 0x3, 0x30, 0xf5, 0x1, 0x22, 0x7c, 0x34, 0x17, 0xa6, 0x23, 0x67, - 0xa7, 0xb, 0x4, 0x1c, 0x0, 0x17, 0xe3, 0xa0, 0x54, 0x27, 0x34, 0x2d, 0xbc, 0x9f, 0x26, 0xeb, 0x52, 0x4e, 0xb5, - 0xb3, 0x64, 0x99, 0x2c, 0xed, 0x77, 0xc1, 0x33, 0x91, 0x88, 0xb, 0x19, 0x2a, 0x1, 0x13, 0x2, 0x76, 0x1c, 0x0, - 0x1, 0xe2, 0x12, 0x0, 0x1, 0xd3, 0x3, 0x0, 0x1, 0x58, 0x21, 0x1c, 0xe2, 0x2, 0x0, 0x0, 0x5, 0xe, 0x15, - 0x0, 0x1, 0x73, 0x1, 0x63, 0x8, 0x0, 0x1c, 0x37, 0x51, 0x94, 0xeb, 0x18, 0x10, 0xea, 0x58, 0x1d, 0x51, 0x86, - 0x55, 0xcc, 0xd6, 0x40, 0xd5, 0xf8, 0x97, 0xa5, 0xb9, 0x58, 0x16, 0x34, 0xbc, 0xda, 0xda, 0x30, 0xc1, 0x19, 0xa3, - 0x15, 0x0, 0x10, 0x20, 0x36, 0xf8, 0x8a, 0xcf, 0x2, 0x58, 0x93, 0xcb, 0xd9, 0x7d, 0xad, 0xf, 0x32, 0xaf, 0x96, - 0x21, 0x66, 0x7c, 0x26, 0x0, 0x11, 0x9d, 0xad, 0x89, 0x8f, 0x90, 0xd, 0x67, 0x54, 0x64, 0x14, 0xa4, 0xca, 0x32, - 0x82, 0x1b, 0x32, 0x9d, 0x0, 0x17, 0xa1, 0xb1, 0x23, 0x95, 0xce, 0x6d, 0x8, 0x21, 0x9e, 0x91, 0x2f, 0x33, 0x94, - 0x2b, 0xf6, 0xab, 0x75, 0x90, 0x32, 0xdb, 0x9c, 0xe8, 0xf9, 0x17, 0x10, 0x9, 0x0, 0x3, 0xd6, 0x1b, 0xcf, 0x23, - 0x46, 0x39, 0x3, 0x0, 0x11, 0xee, 0x37, 0x7f, 0x65, 0xac, 0xb5, 0xbd, 0xb2, 0xbb, 0x6, 0x42, 0x9b, 0x51, 0xc7, - 0x3f, 0x62, 0xc5, 0x19, 0xc5, 0x12, 0x0, 0x0, 0x15, 0x0, 0x1d, 0xa3, 0xc0, 0x8a, 0x32, 0x9, 0x88, 0x81, 0x89, - 0x5f, 0x48, 0x17, 0xbe, 0xea, 0x80, 0xc6, 0xe3, 0x62, 0x45, 0xd8, 0x75, 0xc1, 0x1c, 0x54, 0xe6, 0xe3, 0x71, 0xdf, - 0xce, 0x6, 0x16, 0x0, 0x3, 0x26, 0x6d, 0x23, 0x19, 0xa1, 0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, - 0x26, 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; - uint8_t topic_bytes[] = {0x1a, 0x8f, 0xd9}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x58, 0x0, 0x16, 0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, + 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65, 0x2b, 0x12, 0x2b, 0x1f, + 0x0, 0x10, 0x94, 0x50, 0x4, 0xf7, 0x5d, 0x62, 0x13, 0x55, 0x2c, 0x60, 0x33, 0x14, 0xcf, + 0x74, 0xe1, 0xe8, 0x2, 0x0, 0x0, 0x5b, 0x36, 0x1, 0x4e, 0x2, 0x0, 0x0, 0x4b, 0x28, + 0x1a, 0x0, 0x4, 0xd3, 0x1, 0xb9, 0xa1, 0x13, 0x5f, 0xd0, 0x24, 0x19, 0xb, 0x2f, 0x3a, + 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; + uint8_t topic_bytes[] = {0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, + 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, 0x26, - 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xb, 0x2f, 0x3a, 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, + 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 18; - uint8_t bytesprops0[] = {0xe3, 0xa0, 0x54, 0x27, 0x34, 0x2d, 0xbc, 0x9f, 0x26, 0xeb, 0x52, 0x4e, - 0xb5, 0xb3, 0x64, 0x99, 0x2c, 0xed, 0x77, 0xc1, 0x33, 0x91, 0x88}; - uint8_t bytesprops1[] = {0xe2}; - uint8_t bytesprops2[] = {0xd3}; - uint8_t bytesprops3[] = {0x58}; - uint8_t bytesprops4[] = {0x73}; - uint8_t bytesprops5[] = {0x37, 0x51, 0x94, 0xeb, 0x18, 0x10, 0xea, 0x58, 0x1d, 0x51, 0x86, 0x55, 0xcc, 0xd6, - 0x40, 0xd5, 0xf8, 0x97, 0xa5, 0xb9, 0x58, 0x16, 0x34, 0xbc, 0xda, 0xda, 0x30, 0xc1}; - uint8_t bytesprops6[] = {0x20, 0x36, 0xf8, 0x8a, 0xcf, 0x2, 0x58, 0x93, - 0xcb, 0xd9, 0x7d, 0xad, 0xf, 0x32, 0xaf, 0x96}; - uint8_t bytesprops8[] = {0xa1, 0xb1, 0x23, 0x95, 0xce, 0x6d, 0x8, 0x21, 0x9e, 0x91, 0x2f, 0x33, - 0x94, 0x2b, 0xf6, 0xab, 0x75, 0x90, 0x32, 0xdb, 0x9c, 0xe8, 0xf9}; - uint8_t bytesprops7[] = {0x9d, 0xad, 0x89, 0x8f, 0x90, 0xd, 0x67, 0x54, 0x64, - 0x14, 0xa4, 0xca, 0x32, 0x82, 0x1b, 0x32, 0x9d}; - uint8_t bytesprops9[] = {0xd6, 0x1b, 0xcf}; - uint8_t bytesprops10[] = {0xee, 0x37, 0x7f, 0x65, 0xac, 0xb5, 0xbd, 0xb2, 0xbb, - 0x6, 0x42, 0x9b, 0x51, 0xc7, 0x3f, 0x62, 0xc5}; - uint8_t bytesprops11[] = {0}; - uint8_t bytesprops12[] = {0xa3, 0xc0, 0x8a, 0x32, 0x9, 0x88, 0x81, 0x89, 0x5f, 0x48, 0x17, 0xbe, 0xea, 0x80, 0xc6, - 0xe3, 0x62, 0x45, 0xd8, 0x75, 0xc1, 0x1c, 0x54, 0xe6, 0xe3, 0x71, 0xdf, 0xce, 0x6}; - uint8_t bytesprops13[] = {0x26, 0x6d, 0x23}; + uint8_t bytesprops0[] = {0x94, 0x50, 0x4, 0xf7, 0x5d, 0x62, 0x13, 0x55, + 0x2c, 0x60, 0x33, 0x14, 0xcf, 0x74, 0xe1, 0xe8}; + uint8_t bytesprops1[] = {0xd3, 0x1, 0xb9, 0xa1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31796}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26535}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 630}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7394}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1294}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26236}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops7}, .v = {23, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17977}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23350}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19240}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24528}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 25}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 816, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 11026, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\SUB\143\217", _pubPktID = 816, -// _pubBody = "\246^\255t\204\180\169\214\150&=\195\235\249\176Q\NAK\169\145", _pubProps = [PropTopicAliasMaximum -// 31796,PropRequestProblemInformation 166,PropTopicAlias 26535,PropSubscriptionIdentifier 4,PropServerReference -// "\227\160T'4-\188\159&\235RN\181\179d\153,\237w\193\&3\145\136",PropSubscriptionIdentifier -// 25,PropSharedSubscriptionAvailable 1,PropServerKeepAlive 630,PropServerReference "\226",PropAssignedClientIdentifier -// "\211",PropContentType "X",PropReceiveMaximum 7394,PropMessageExpiryInterval 1294,PropAuthenticationMethod -// "s",PropPayloadFormatIndicator 99,PropResponseTopic -// "7Q\148\235\CAN\DLE\234X\GSQ\134U\204\214@\213\248\151\165\185X\SYN4\188\218\218\&0\193",PropRequestResponseInformation -// 163,PropAuthenticationMethod " 6\248\138\207\STXX\147\203\217}\173\SI2\175\150",PropReceiveMaximum -// 26236,PropUserProperty "\157\173\137\143\144\rgTd\DC4\164\202\&2\130\ESC2\157" -// "\161\177#\149\206m\b!\158\145/3\148+\246\171u\144\&2\219\156\232\249",PropRequestProblemInformation -// 16,PropCorrelationData "\214\ESC\207",PropTopicAlias 17977,PropContentType -// "\238\&7\DELe\172\181\189\178\187\ACKB\155Q\199?b\197",PropRequestResponseInformation -// 197,PropAssignedClientIdentifier "",PropAuthenticationMethod -// "\163\192\138\&2\t\136\129\137_H\ETB\190\234\128\198\227bE\216u\193\FST\230\227q\223\206\ACK",PropAuthenticationData -// "&m#",PropRequestResponseInformation 161]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "}\162\DC3\157\161\140z\190\148\228\254\EOTk\211\&1\133\SI\188y\142\134e", _pubPktID = 11026, _pubBody = +// "\v/:\b\150\237Ih\224]\US\181R[r\179\234\185", _pubProps = [PropReasonString +// "\148P\EOT\247]b\DC3U,`3\DC4\207t\225\232",PropMessageExpiryInterval 23350,PropPayloadFormatIndicator +// 78,PropMessageExpiryInterval 19240,PropResponseInformation "\211\SOH\185\161",PropServerKeepAlive +// 24528,PropMaximumQoS 25]} TEST(Publish5QCTest, Decode3) { - uint8_t pkt[] = { - 0x35, 0x91, 0x2, 0x0, 0x3, 0x1a, 0x8f, 0xd9, 0x3, 0x30, 0xf5, 0x1, 0x22, 0x7c, 0x34, 0x17, 0xa6, 0x23, 0x67, - 0xa7, 0xb, 0x4, 0x1c, 0x0, 0x17, 0xe3,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, 0x0, 0x15, 0x0, 0x1d, 0xa3, 0xc0, 0x8a, 0x32, 0x9, 0x88, 0x81, 0x89, - 0x5f, 0x48, 0x17, 0xbe, 0xea, 0x80, 0xc6, 0xe3, 0x62, 0x45, 0xd8, 0x75, 0xc1, 0x1c, 0x54, 0xe6, 0xe3, 0x71, 0xdf, - 0xce, 0x6, 0x16, 0x0, 0x3, 0x26, 0x6d, 0x23, 0x19, 0xa1, 0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, - 0x26, 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; + uint8_t pkt[] = {0x3a, 0x58, 0x0, 0x16, 0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, + 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65, 0x2b, 0x12, 0x2b, 0x1f, + 0x0, 0x10, 0x94, 0x50, 0x4, 0xf7, 0x5d, 0x62, 0x13, 0x55, 0x2c, 0x60, 0x33, 0x14, 0xcf, + 0x74, 0xe1, 0xe8, 0x2, 0x0, 0x0, 0x5b, 0x36, 0x1, 0x4e, 0x2, 0x0, 0x0, 0x4b, 0x28, + 0x1a, 0x0, 0x4, 0xd3, 0x1, 0xb9, 0xa1, 0x13, 0x5f, 0xd0, 0x24, 0x19, 0xb, 0x2f, 0x3a, + 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2044,132 +2090,107 @@ TEST(Publish5QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x1a, 0x8f, 0xd9}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf6, 0x5e, 0xff, 0x74, 0xcc, 0xb4, 0xa9, 0xd6, 0x96, 0x26, - 0x3d, 0xc3, 0xeb, 0xf9, 0xb0, 0x51, 0x15, 0xa9, 0x91}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 816); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + uint8_t exp_topic_bytes[] = {0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, + 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb, 0x2f, 0x3a, 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, + 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 11026); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "", _pubPktID = 31057, _pubBody = -// "\199\189\167\ETX\187.\248)\192z\ESC\250{\169\157\255\224d\204\159\r\239\ESC\154Q\171\168", _pubProps = -// [PropAssignedClientIdentifier "_\215U\142P\139~)\tU-",PropResponseInformation -// "\232,2\181O7B\252\204}\223o\147b\134s,\173\159\215\200%o$k\129\149",PropCorrelationData -// "\NUL\203\&7\ENQ\158\134\201\218\&9\192\221%3\172^\225[\186\235\EM2",PropSubscriptionIdentifier -// 29,PropResponseInformation -// "\193\224]\164i:\216}A\234D\203I9\222\&3\129\207e\216\SOHI\t\215\197",PropTopicAliasMaximum -// 26731,PropAuthenticationMethod -// "\ETB\224\178`k\159\206V\DELySa8t;\143!\214\173\202mAd\161\195",PropPayloadFormatIndicator -// 37,PropMessageExpiryInterval 23579,PropServerReference "R\246vJ\166\204\250\ACK\ACKIT\217\193",PropAuthenticationData -// "0\194Lkb\182\232(topic.data), 0); - EXPECT_EQ(msg.payload_len, 27); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + EXPECT_EQ(packet_id, 21319); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "V\129\199\DEL\236d\144\134\234\&2\161\f\158;^\GS\152", _pubPktID = 0, _pubBody = -// "\168#\DC4\164\152d\226\231\214\203.3\\K\148y\227\211\138\130B\160L0\153\231\154\201\v0", _pubProps = -// [PropMessageExpiryInterval 7690,PropServerKeepAlive 8084,PropWildcardSubscriptionAvailable -// 145,PropAuthenticationMethod "\225\252\141\141\EOT.\243\188>",PropWildcardSubscriptionAvailable 224,PropTopicAlias -// 8626,PropUserProperty "/\223" -// "\194\201I\235\a\147\160j\157l\248\254[\206\210\DC4\184\140tE\t\130\ETB\234?\199\165\208\205",PropMessageExpiryInterval -// 12891,PropRequestProblemInformation 203,PropReceiveMaximum 28713,PropMaximumQoS 5,PropAuthenticationMethod -// "5]\139\214\162T\234\SO\ETB8\ENQ\243\217\151\rC\206\171\201",PropAssignedClientIdentifier -// "\228\213\164\148sUj\233P\251\DC1\239M\204\208@?0",PropPayloadFormatIndicator 124,PropResponseTopic -// "\165w\178\234\a\147",PropRequestProblemInformation 73,PropSharedSubscriptionAvailable 133,PropMaximumPacketSize -// 6940,PropMaximumQoS 27,PropCorrelationData -// "\141\STX\246\253\217B\210\170\196\142pT\200'\NUL\188\236\&5\216PP\224",PropPayloadFormatIndicator -// 189,PropWildcardSubscriptionAvailable 96,PropResponseInformation -// "\141\148\EOT\203",PropSubscriptionIdentifierAvailable 25,PropMessageExpiryInterval 17864]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\US\134\217^\225\USI\SOH%\234]\SUB\251\158\ENQ\188\140@\224\ETX\185}", _pubPktID = 0, _pubBody = "\222", _pubProps = +// [PropSubscriptionIdentifierAvailable 189,PropRequestResponseInformation 84,PropSubscriptionIdentifier +// 29,PropServerReference +// "E\131\240\200\175\198\SOH\248\231\188\133\224\237\b\SO\242\185\202(T\241\211\nXIr\138\242\237",PropReasonString +// "\159k\129\206^!,'\165\215",PropSharedSubscriptionAvailable 210,PropAssignedClientIdentifier +// "\168\200\213T1\213\CAN]",PropServerKeepAlive 27765,PropMaximumQoS 169,PropAssignedClientIdentifier +// "?\229\ESC\252\208\157\225\210\157H\254\133\209\229l\172\215\151\152",PropCorrelationData +// "\200\181\202`V\b<\200\134\154m?Oq&G\143\246\243\NUL\185\218\143\&5~gO\254\DC4",PropServerKeepAlive +// 27340,PropWillDelayInterval 3446,PropMaximumQoS 186,PropCorrelationData +// "\SIU\r\146@\227\184\154\163cF\206T2\197\218\231",PropMaximumQoS 85,PropSubscriptionIdentifier 28,PropRetainAvailable +// 137,PropRequestProblemInformation 19,PropCorrelationData "\255\237\186*\177\171\132\FS\172\201\194",PropTopicAlias +// 26253,PropSubscriptionIdentifierAvailable 72,PropRequestProblemInformation 78,PropWildcardSubscriptionAvailable +// 25,PropPayloadFormatIndicator 173,PropWildcardSubscriptionAvailable 192,PropMaximumQoS 143,PropReceiveMaximum +// 23224,PropAuthenticationMethod "]Y\239\223\215\SO\FS`\EOT\242\236\218<\251\&3"]} TEST(Publish5QCTest, Encode5) { - uint8_t pkt[] = {0x39, 0xea, 0x1, 0x0, 0x11, 0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, 0x32, 0xa1, 0xc, - 0x9e, 0x3b, 0x5e, 0x1d, 0x98, 0xb7, 0x1, 0x2, 0x0, 0x0, 0x1e, 0xa, 0x13, 0x1f, 0x94, 0x28, 0x91, - 0x15, 0x0, 0x9, 0xe1, 0xfc, 0x8d, 0x8d, 0x4, 0x2e, 0xf3, 0xbc, 0x3e, 0x28, 0xe0, 0x23, 0x21, 0xb2, - 0x26, 0x0, 0x2, 0x2f, 0xdf, 0x0, 0x1d, 0xc2, 0xc9, 0x49, 0xeb, 0x7, 0x93, 0xa0, 0x6a, 0x9d, 0x6c, - 0xf8, 0xfe, 0x5b, 0xce, 0xd2, 0x14, 0xb8, 0x8c, 0x74, 0x45, 0x9, 0x82, 0x17, 0xea, 0x3f, 0xc7, 0xa5, - 0xd0, 0xcd, 0x2, 0x0, 0x0, 0x32, 0x5b, 0x17, 0xcb, 0x21, 0x70, 0x29, 0x24, 0x5, 0x15, 0x0, 0x13, - 0x35, 0x5d, 0x8b, 0xd6, 0xa2, 0x54, 0xea, 0xe, 0x17, 0x38, 0x5, 0xf3, 0xd9, 0x97, 0xd, 0x43, 0xce, - 0xab, 0xc9, 0x12, 0x0, 0x12, 0xe4, 0xd5, 0xa4, 0x94, 0x73, 0x55, 0x6a, 0xe9, 0x50, 0xfb, 0x11, 0xef, - 0x4d, 0xcc, 0xd0, 0x40, 0x3f, 0x30, 0x1, 0x7c, 0x8, 0x0, 0x6, 0xa5, 0x77, 0xb2, 0xea, 0x7, 0x93, - 0x17, 0x49, 0x2a, 0x85, 0x27, 0x0, 0x0, 0x1b, 0x1c, 0x24, 0x1b, 0x9, 0x0, 0x16, 0x8d, 0x2, 0xf6, - 0xfd, 0xd9, 0x42, 0xd2, 0xaa, 0xc4, 0x8e, 0x70, 0x54, 0xc8, 0x27, 0x0, 0xbc, 0xec, 0x35, 0xd8, 0x50, - 0x50, 0xe0, 0x1, 0xbd, 0x28, 0x60, 0x1a, 0x0, 0x4, 0x8d, 0x94, 0x4, 0xcb, 0x29, 0x19, 0x2, 0x0, - 0x0, 0x45, 0xc8, 0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, - 0x94, 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; - uint8_t topic_bytes[] = {0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, - 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x30, 0xee, 0x1, 0x0, 0x16, 0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, 0x5d, 0x1a, 0xfb, 0x9e, + 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d, 0xd3, 0x1, 0x29, 0xbd, 0x19, 0x54, 0xb, 0x1d, 0x1c, 0x0, 0x1d, + 0x45, 0x83, 0xf0, 0xc8, 0xaf, 0xc6, 0x1, 0xf8, 0xe7, 0xbc, 0x85, 0xe0, 0xed, 0x8, 0xe, 0xf2, 0xb9, 0xca, 0x28, + 0x54, 0xf1, 0xd3, 0xa, 0x58, 0x49, 0x72, 0x8a, 0xf2, 0xed, 0x1f, 0x0, 0xa, 0x9f, 0x6b, 0x81, 0xce,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x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, - 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; + msg.retained = false; + uint8_t msg_bytes[] = {0xde}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 1; - uint8_t bytesprops0[] = {0xe1, 0xfc, 0x8d, 0x8d, 0x4, 0x2e, 0xf3, 0xbc, 0x3e}; - uint8_t bytesprops2[] = {0xc2, 0xc9, 0x49, 0xeb, 0x7, 0x93, 0xa0, 0x6a, 0x9d, 0x6c, 0xf8, 0xfe, 0x5b, 0xce, 0xd2, - 0x14, 0xb8, 0x8c, 0x74, 0x45, 0x9, 0x82, 0x17, 0xea, 0x3f, 0xc7, 0xa5, 0xd0, 0xcd}; - uint8_t bytesprops1[] = {0x2f, 0xdf}; - uint8_t bytesprops3[] = {0x35, 0x5d, 0x8b, 0xd6, 0xa2, 0x54, 0xea, 0xe, 0x17, 0x38, - 0x5, 0xf3, 0xd9, 0x97, 0xd, 0x43, 0xce, 0xab, 0xc9}; - uint8_t bytesprops4[] = {0xe4, 0xd5, 0xa4, 0x94, 0x73, 0x55, 0x6a, 0xe9, 0x50, - 0xfb, 0x11, 0xef, 0x4d, 0xcc, 0xd0, 0x40, 0x3f, 0x30}; - uint8_t bytesprops5[] = {0xa5, 0x77, 0xb2, 0xea, 0x7, 0x93}; - uint8_t bytesprops6[] = {0x8d, 0x2, 0xf6, 0xfd, 0xd9, 0x42, 0xd2, 0xaa, 0xc4, 0x8e, 0x70, - 0x54, 0xc8, 0x27, 0x0, 0xbc, 0xec, 0x35, 0xd8, 0x50, 0x50, 0xe0}; - uint8_t bytesprops7[] = {0x8d, 0x94, 0x4, 0xcb}; + uint8_t bytesprops0[] = {0x45, 0x83, 0xf0, 0xc8, 0xaf, 0xc6, 0x1, 0xf8, 0xe7, 0xbc, 0x85, 0xe0, 0xed, 0x8, 0xe, + 0xf2, 0xb9, 0xca, 0x28, 0x54, 0xf1, 0xd3, 0xa, 0x58, 0x49, 0x72, 0x8a, 0xf2, 0xed}; + uint8_t bytesprops1[] = {0x9f, 0x6b, 0x81, 0xce, 0x5e, 0x21, 0x2c, 0x27, 0xa5, 0xd7}; + uint8_t bytesprops2[] = {0xa8, 0xc8, 0xd5, 0x54, 0x31, 0xd5, 0x18, 0x5d}; + uint8_t bytesprops3[] = {0x3f, 0xe5, 0x1b, 0xfc, 0xd0, 0x9d, 0xe1, 0xd2, 0x9d, 0x48, + 0xfe, 0x85, 0xd1, 0xe5, 0x6c, 0xac, 0xd7, 0x97, 0x98}; + uint8_t bytesprops4[] = {0xc8, 0xb5, 0xca, 0x60, 0x56, 0x8, 0x3c, 0xc8, 0x86, 0x9a, 0x6d, 0x3f, 0x4f, 0x71, 0x26, + 0x47, 0x8f, 0xf6, 0xf3, 0x0, 0xb9, 0xda, 0x8f, 0x35, 0x7e, 0x67, 0x4f, 0xfe, 0x14}; + uint8_t bytesprops5[] = {0xf, 0x55, 0xd, 0x92, 0x40, 0xe3, 0xb8, 0x9a, 0xa3, + 0x63, 0x46, 0xce, 0x54, 0x32, 0xc5, 0xda, 0xe7}; + uint8_t bytesprops6[] = {0xff, 0xed, 0xba, 0x2a, 0xb1, 0xab, 0x84, 0x1c, 0xac, 0xc9, 0xc2}; + uint8_t bytesprops7[] = {0x5d, 0x59, 0xef, 0xdf, 0xd7, 0xe, 0x1c, 0x60, 0x4, 0xf2, 0xec, 0xda, 0x3c, 0xfb, 0x33}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7690}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8084}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8626}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops1}, .v = {29, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12891}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28713}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6940}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17864}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27765}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27340}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3446}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26253}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23224}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "V\129\199\DEL\236d\144\134\234\&2\161\f\158;^\GS\152", _pubPktID = 0, _pubBody = -// "\168#\DC4\164\152d\226\231\214\203.3\\K\148y\227\211\138\130B\160L0\153\231\154\201\v0", _pubProps = -// [PropMessageExpiryInterval 7690,PropServerKeepAlive 8084,PropWildcardSubscriptionAvailable -// 145,PropAuthenticationMethod "\225\252\141\141\EOT.\243\188>",PropWildcardSubscriptionAvailable 224,PropTopicAlias -// 8626,PropUserProperty "/\223" -// "\194\201I\235\a\147\160j\157l\248\254[\206\210\DC4\184\140tE\t\130\ETB\234?\199\165\208\205",PropMessageExpiryInterval -// 12891,PropRequestProblemInformation 203,PropReceiveMaximum 28713,PropMaximumQoS 5,PropAuthenticationMethod -// "5]\139\214\162T\234\SO\ETB8\ENQ\243\217\151\rC\206\171\201",PropAssignedClientIdentifier -// "\228\213\164\148sUj\233P\251\DC1\239M\204\208@?0",PropPayloadFormatIndicator 124,PropResponseTopic -// "\165w\178\234\a\147",PropRequestProblemInformation 73,PropSharedSubscriptionAvailable 133,PropMaximumPacketSize -// 6940,PropMaximumQoS 27,PropCorrelationData -// "\141\STX\246\253\217B\210\170\196\142pT\200'\NUL\188\236\&5\216PP\224",PropPayloadFormatIndicator -// 189,PropWildcardSubscriptionAvailable 96,PropResponseInformation -// "\141\148\EOT\203",PropSubscriptionIdentifierAvailable 25,PropMessageExpiryInterval 17864]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\US\134\217^\225\USI\SOH%\234]\SUB\251\158\ENQ\188\140@\224\ETX\185}", _pubPktID = 0, _pubBody = "\222", _pubProps = +// [PropSubscriptionIdentifierAvailable 189,PropRequestResponseInformation 84,PropSubscriptionIdentifier +// 29,PropServerReference +// "E\131\240\200\175\198\SOH\248\231\188\133\224\237\b\SO\242\185\202(T\241\211\nXIr\138\242\237",PropReasonString +// "\159k\129\206^!,'\165\215",PropSharedSubscriptionAvailable 210,PropAssignedClientIdentifier +// "\168\200\213T1\213\CAN]",PropServerKeepAlive 27765,PropMaximumQoS 169,PropAssignedClientIdentifier +// "?\229\ESC\252\208\157\225\210\157H\254\133\209\229l\172\215\151\152",PropCorrelationData +// "\200\181\202`V\b<\200\134\154m?Oq&G\143\246\243\NUL\185\218\143\&5~gO\254\DC4",PropServerKeepAlive +// 27340,PropWillDelayInterval 3446,PropMaximumQoS 186,PropCorrelationData +// "\SIU\r\146@\227\184\154\163cF\206T2\197\218\231",PropMaximumQoS 85,PropSubscriptionIdentifier 28,PropRetainAvailable +// 137,PropRequestProblemInformation 19,PropCorrelationData "\255\237\186*\177\171\132\FS\172\201\194",PropTopicAlias +// 26253,PropSubscriptionIdentifierAvailable 72,PropRequestProblemInformation 78,PropWildcardSubscriptionAvailable +// 25,PropPayloadFormatIndicator 173,PropWildcardSubscriptionAvailable 192,PropMaximumQoS 143,PropReceiveMaximum +// 23224,PropAuthenticationMethod "]Y\239\223\215\SO\FS`\EOT\242\236\218<\251\&3"]} TEST(Publish5QCTest, Decode5) { - uint8_t pkt[] = {0x39, 0xea, 0x1, 0x0, 0x11, 0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, 0x32, 0xa1, 0xc, - 0x9e, 0x3b, 0x5e, 0x1d, 0x98, 0xb7, 0x1, 0x2, 0x0, 0x0, 0x1e, 0xa, 0x13, 0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0xba, 0x9, 0x0, 0x11, 0xf, 0x55, 0xd, 0x92, 0x40, 0xe3, + 0xb8, 0x9a, 0xa3, 0x63, 0x46, 0xce, 0x54, 0x32, 0xc5, 0xda, 0xe7, 0x24, 0x55, 0xb, 0x1c, 0x25, 0x89, 0x17, 0x13, + 0x9, 0x0, 0xb, 0xff, 0xed, 0xba, 0x2a, 0xb1, 0xab, 0x84, 0x1c, 0xac, 0xc9, 0xc2, 0x23, 0x66, 0x8d, 0x29, 0x48, + 0x17, 0x4e, 0x28, 0x19, 0x1, 0xad, 0x28, 0xc0, 0x24, 0x8f, 0x21, 0x5a, 0xb8, 0x15, 0x0, 0xf, 0x5d, 0x59, 0xef, + 0xdf, 0xd7, 0xe, 0x1c, 0x60, 0x4, 0xf2, 0xec, 0xda, 0x3c, 0xfb, 0x33, 0xde}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2322,141 +2345,112 @@ TEST(Publish5QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x56, 0x81, 0xc7, 0x7f, 0xec, 0x64, 0x90, 0x86, 0xea, - 0x32, 0xa1, 0xc, 0x9e, 0x3b, 0x5e, 0x1d, 0x98}; - lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa8, 0x23, 0x14, 0xa4, 0x98, 0x64, 0xe2, 0xe7, 0xd6, 0xcb, 0x2e, 0x33, 0x5c, 0x4b, 0x94, - 0x79, 0xe3, 0xd3, 0x8a, 0x82, 0x42, 0xa0, 0x4c, 0x30, 0x99, 0xe7, 0x9a, 0xc9, 0xb, 0x30}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, 0x5d, + 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xde}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\ESC\176mM-\183\&6\136p\203\156\172", _pubPktID = 0, _pubBody = "\DC2\166\130\180V\157\163bV", _pubProps = -// [PropMessageExpiryInterval 17805,PropTopicAlias 29809,PropMaximumQoS 128,PropRetainAvailable 153,PropRetainAvailable -// 46,PropSharedSubscriptionAvailable 149,PropMaximumQoS 3,PropMaximumQoS 125,PropResponseInformation -// "\167C\211\194(\200\141(\149\DC2\219j\132\&2{\240\186\202L",PropRequestProblemInformation -// 248,PropAuthenticationMethod "\206",PropMaximumQoS 93,PropServerKeepAlive 14778,PropAuthenticationMethod -// "\213\&3i\218\248\201\195\&0\144\DC1\201X\v\ETX",PropContentType -// "=-f\157g\238l\191\136\191\SOH\189\&6t\225xbg",PropMessageExpiryInterval 10427,PropSubscriptionIdentifierAvailable -// 0,PropSessionExpiryInterval 10212,PropTopicAlias 2252,PropServerReference -// "\EM=\"\187\NUL\249;\128\224\141\226\215\213\ETX\ESC7\v0\205\191C\222k8",PropRequestProblemInformation -// 186,PropCorrelationData "\r\236\154\129\SUB\204W\142\209Vt3L\183@A\213y",PropAuthenticationData -// "\FS\156\229\253\233\&4\218\RS\196BB\SI\147\\7\254R-\USD\233q5",PropAuthenticationMethod -// "\249L|\175l\249\USC\CAN\252\EOT\139s",PropAuthenticationData "\147"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\152\168e\228f1ic\227\250", _pubPktID +// = 0, _pubBody = "\195\&1\199\231\246bO,\"\146\SOE`:", _pubProps = [PropSubscriptionIdentifierAvailable +// 203,PropReasonString "\209\254\145\232aU\n\196\215",PropRequestResponseInformation 200,PropAssignedClientIdentifier +// "\EOT\r7\USQ>\207\178\FS\138Zh5\ETX\251X\136\164\177G\161\ff\131\221{\205\&1L",PropContentType +// "\156\215\NAK\179\178\130\169\180<\DC2\181\253x\SUB\232*P?\237\242h)\148\199Q!\FS\150\n",PropContentType +// "BB\183\248\147\230\184Nw\193\&8\178\DEL\DC2\153\&9zV{\250B\151a",PropMaximumPacketSize +// 3529,PropSubscriptionIdentifier 5,PropMaximumPacketSize 9765,PropAssignedClientIdentifier +// "\153\248\251\172\181/\247\138!?\200\250j\191\242\193s\145f\232\187\192\249\238\190",PropTopicAliasMaximum +// 18828,PropMessageExpiryInterval 17667,PropWillDelayInterval 6761,PropTopicAlias 26579]} TEST(Publish5QCTest, Encode6) { - uint8_t pkt[] = {0x31, 0xe3, 0x1, 0x0, 0xc, 0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac, - 0xca, 0x1, 0x2, 0x0, 0x0, 0x45, 0x8d, 0x23, 0x74, 0x71, 0x24, 0x80, 0x25, 0x99, 0x25, 0x2e, 0x2a, - 0x95, 0x24, 0x3, 0x24, 0x7d, 0x1a, 0x0, 0x13, 0xa7, 0x43, 0xd3, 0xc2, 0x28, 0xc8, 0x8d, 0x28, 0x95, - 0x12, 0xdb, 0x6a, 0x84, 0x32, 0x7b, 0xf0, 0xba, 0xca, 0x4c, 0x17, 0xf8, 0x15, 0x0, 0x1, 0xce, 0x24, - 0x5d, 0x13, 0x39, 0xba, 0x15, 0x0, 0xe, 0xd5, 0x33, 0x69, 0xda, 0xf8, 0xc9, 0xc3, 0x30, 0x90, 0x11, - 0xc9, 0x58, 0xb, 0x3, 0x3, 0x0, 0x12, 0x3d, 0x2d, 0x66, 0x9d, 0x67, 0xee, 0x6c, 0xbf, 0x88, 0xbf, - 0x1, 0xbd, 0x36, 0x74, 0xe1, 0x78, 0x62, 0x67, 0x2, 0x0, 0x0, 0x28, 0xbb, 0x29, 0x0, 0x11, 0x0, - 0x0, 0x27, 0xe4, 0x23, 0x8, 0xcc, 0x1c, 0x0, 0x18, 0x19, 0x3d, 0x22, 0xbb, 0x0, 0xf9, 0x3b, 0x80, - 0xe0, 0x8d, 0xe2, 0xd7, 0xd5, 0x3, 0x1b, 0x37, 0xb, 0x30, 0xcd, 0xbf, 0x43, 0xde, 0x6b, 0x38, 0x17, - 0xba, 0x9, 0x0, 0x12, 0xd, 0xec, 0x9a, 0x81, 0x1a, 0xcc, 0x57, 0x8e, 0xd1, 0x56, 0x74, 0x33, 0x4c, - 0xb7, 0x40, 0x41, 0xd5, 0x79, 0x16, 0x0, 0x17, 0x1c, 0x9c, 0xe5, 0xfd, 0xe9, 0x34, 0xda, 0x1e, 0xc4, - 0x42, 0x42, 0xf, 0x93, 0x5c, 0x37, 0xfe, 0x52, 0x2d, 0x1f, 0x44, 0xe9, 0x71, 0x35, 0x15, 0x0, 0xd, - 0xf9, 0x4c, 0x7c, 0xaf, 0x6c, 0xf9, 0x1f, 0x43, 0x18, 0xfc, 0x4, 0x8b, 0x73, 0x16, 0x0, 0x1, 0x93, - 0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; - uint8_t topic_bytes[] = {0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0xbe, 0x1, 0x0, 0xa, 0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa, 0xa2, 0x1, + 0x29, 0xcb, 0x1f, 0x0, 0x9, 0xd1, 0xfe, 0x91, 0xe8, 0x61, 0x55, 0xa, 0xc4, 0xd7, 0x19, 0xc8, 0x12, + 0x0, 0x1d, 0x4, 0xd, 0x37, 0x1f, 0x51, 0x3e, 0xcf, 0xb2, 0x1c, 0x8a, 0x5a, 0x68, 0x35, 0x3, 0xfb, + 0x58, 0x88, 0xa4, 0xb1, 0x47, 0xa1, 0xc, 0x66, 0x83, 0xdd, 0x7b, 0xcd, 0x31, 0x4c, 0x3, 0x0, 0x1d, + 0x9c, 0xd7, 0x15, 0xb3, 0xb2, 0x82, 0xa9, 0xb4, 0x3c, 0x12, 0xb5, 0xfd, 0x78, 0x1a, 0xe8, 0x2a, 0x50, + 0x3f, 0xed, 0xf2, 0x68, 0x29, 0x94, 0xc7, 0x51, 0x21, 0x1c, 0x96, 0xa, 0x3, 0x0, 0x17, 0x42, 0x42, + 0xb7, 0xf8, 0x93, 0xe6, 0xb8, 0x4e, 0x77, 0xc1, 0x38, 0xb2, 0x7f, 0x12, 0x99, 0x39, 0x7a, 0x56, 0x7b, + 0xfa, 0x42, 0x97, 0x61, 0x27, 0x0, 0x0, 0xd, 0xc9, 0xb, 0x5, 0x27, 0x0, 0x0, 0x26, 0x25, 0x12, + 0x0, 0x19, 0x99, 0xf8, 0xfb, 0xac, 0xb5, 0x2f, 0xf7, 0x8a, 0x21, 0x3f, 0xc8, 0xfa, 0x6a, 0xbf, 0xf2, + 0xc1, 0x73, 0x91, 0x66, 0xe8, 0xbb, 0xc0, 0xf9, 0xee, 0xbe, 0x22, 0x49, 0x8c, 0x2, 0x0, 0x0, 0x45, + 0x3, 0x18, 0x0, 0x0, 0x1a, 0x69, 0x23, 0x67, 0xd3, 0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, + 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; + uint8_t topic_bytes[] = {0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; + uint8_t msg_bytes[] = {0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; - - uint8_t bytesprops0[] = {0xa7, 0x43, 0xd3, 0xc2, 0x28, 0xc8, 0x8d, 0x28, 0x95, 0x12, - 0xdb, 0x6a, 0x84, 0x32, 0x7b, 0xf0, 0xba, 0xca, 0x4c}; - uint8_t bytesprops1[] = {0xce}; - uint8_t bytesprops2[] = {0xd5, 0x33, 0x69, 0xda, 0xf8, 0xc9, 0xc3, 0x30, 0x90, 0x11, 0xc9, 0x58, 0xb, 0x3}; - uint8_t bytesprops3[] = {0x3d, 0x2d, 0x66, 0x9d, 0x67, 0xee, 0x6c, 0xbf, 0x88, - 0xbf, 0x1, 0xbd, 0x36, 0x74, 0xe1, 0x78, 0x62, 0x67}; - uint8_t bytesprops4[] = {0x19, 0x3d, 0x22, 0xbb, 0x0, 0xf9, 0x3b, 0x80, 0xe0, 0x8d, 0xe2, 0xd7, - 0xd5, 0x3, 0x1b, 0x37, 0xb, 0x30, 0xcd, 0xbf, 0x43, 0xde, 0x6b, 0x38}; - uint8_t bytesprops5[] = {0xd, 0xec, 0x9a, 0x81, 0x1a, 0xcc, 0x57, 0x8e, 0xd1, - 0x56, 0x74, 0x33, 0x4c, 0xb7, 0x40, 0x41, 0xd5, 0x79}; - uint8_t bytesprops6[] = {0x1c, 0x9c, 0xe5, 0xfd, 0xe9, 0x34, 0xda, 0x1e, 0xc4, 0x42, 0x42, 0xf, - 0x93, 0x5c, 0x37, 0xfe, 0x52, 0x2d, 0x1f, 0x44, 0xe9, 0x71, 0x35}; - uint8_t bytesprops7[] = {0xf9, 0x4c, 0x7c, 0xaf, 0x6c, 0xf9, 0x1f, 0x43, 0x18, 0xfc, 0x4, 0x8b, 0x73}; - uint8_t bytesprops8[] = {0x93}; + msg.payload_len = 14; + + uint8_t bytesprops0[] = {0xd1, 0xfe, 0x91, 0xe8, 0x61, 0x55, 0xa, 0xc4, 0xd7}; + uint8_t bytesprops1[] = {0x4, 0xd, 0x37, 0x1f, 0x51, 0x3e, 0xcf, 0xb2, 0x1c, 0x8a, 0x5a, 0x68, 0x35, 0x3, 0xfb, + 0x58, 0x88, 0xa4, 0xb1, 0x47, 0xa1, 0xc, 0x66, 0x83, 0xdd, 0x7b, 0xcd, 0x31, 0x4c}; + uint8_t bytesprops2[] = {0x9c, 0xd7, 0x15, 0xb3, 0xb2, 0x82, 0xa9, 0xb4, 0x3c, 0x12, 0xb5, 0xfd, 0x78, 0x1a, 0xe8, + 0x2a, 0x50, 0x3f, 0xed, 0xf2, 0x68, 0x29, 0x94, 0xc7, 0x51, 0x21, 0x1c, 0x96, 0xa}; + uint8_t bytesprops3[] = {0x42, 0x42, 0xb7, 0xf8, 0x93, 0xe6, 0xb8, 0x4e, 0x77, 0xc1, 0x38, 0xb2, + 0x7f, 0x12, 0x99, 0x39, 0x7a, 0x56, 0x7b, 0xfa, 0x42, 0x97, 0x61}; + uint8_t bytesprops4[] = {0x99, 0xf8, 0xfb, 0xac, 0xb5, 0x2f, 0xf7, 0x8a, 0x21, 0x3f, 0xc8, 0xfa, 0x6a, + 0xbf, 0xf2, 0xc1, 0x73, 0x91, 0x66, 0xe8, 0xbb, 0xc0, 0xf9, 0xee, 0xbe}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17805}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29809}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14778}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10427}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10212}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2252}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3529}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9765}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18828}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17667}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6761}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26579}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\ESC\176mM-\183\&6\136p\203\156\172", _pubPktID = 0, _pubBody = "\DC2\166\130\180V\157\163bV", _pubProps = -// [PropMessageExpiryInterval 17805,PropTopicAlias 29809,PropMaximumQoS 128,PropRetainAvailable 153,PropRetainAvailable -// 46,PropSharedSubscriptionAvailable 149,PropMaximumQoS 3,PropMaximumQoS 125,PropResponseInformation -// "\167C\211\194(\200\141(\149\DC2\219j\132\&2{\240\186\202L",PropRequestProblemInformation -// 248,PropAuthenticationMethod "\206",PropMaximumQoS 93,PropServerKeepAlive 14778,PropAuthenticationMethod -// "\213\&3i\218\248\201\195\&0\144\DC1\201X\v\ETX",PropContentType -// "=-f\157g\238l\191\136\191\SOH\189\&6t\225xbg",PropMessageExpiryInterval 10427,PropSubscriptionIdentifierAvailable -// 0,PropSessionExpiryInterval 10212,PropTopicAlias 2252,PropServerReference -// "\EM=\"\187\NUL\249;\128\224\141\226\215\213\ETX\ESC7\v0\205\191C\222k8",PropRequestProblemInformation -// 186,PropCorrelationData "\r\236\154\129\SUB\204W\142\209Vt3L\183@A\213y",PropAuthenticationData -// "\FS\156\229\253\233\&4\218\RS\196BB\SI\147\\7\254R-\USD\233q5",PropAuthenticationMethod -// "\249L|\175l\249\USC\CAN\252\EOT\139s",PropAuthenticationData "\147"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\152\168e\228f1ic\227\250", _pubPktID +// = 0, _pubBody = "\195\&1\199\231\246bO,\"\146\SOE`:", _pubProps = [PropSubscriptionIdentifierAvailable +// 203,PropReasonString "\209\254\145\232aU\n\196\215",PropRequestResponseInformation 200,PropAssignedClientIdentifier +// "\EOT\r7\USQ>\207\178\FS\138Zh5\ETX\251X\136\164\177G\161\ff\131\221{\205\&1L",PropContentType +// "\156\215\NAK\179\178\130\169\180<\DC2\181\253x\SUB\232*P?\237\242h)\148\199Q!\FS\150\n",PropContentType +// "BB\183\248\147\230\184Nw\193\&8\178\DEL\DC2\153\&9zV{\250B\151a",PropMaximumPacketSize +// 3529,PropSubscriptionIdentifier 5,PropMaximumPacketSize 9765,PropAssignedClientIdentifier +// "\153\248\251\172\181/\247\138!?\200\250j\191\242\193s\145f\232\187\192\249\238\190",PropTopicAliasMaximum +// 18828,PropMessageExpiryInterval 17667,PropWillDelayInterval 6761,PropTopicAlias 26579]} TEST(Publish5QCTest, Decode6) { - uint8_t pkt[] = {0x31, 0xe3, 0x1, 0x0, 0xc, 0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac, - 0xca, 0x1, 0x2, 0x0, 0x0, 0x45, 0x8d, 0x23, 0x74, 0x71, 0x24, 0x80, 0x25, 0x99, 0x25, 0x2e, 0x2a, - 0x95, 0x24, 0x3, 0x24, 0x7d, 0x1a, 0x0, 0x13, 0xa7, 0x43, 0xd3, 0xc2, 0x28, 0xc8, 0x8d, 0x28, 0x95, - 0x12, 0xdb, 0x6a, 0x84, 0x32, 0x7b, 0xf0, 0xba, 0xca, 0x4c, 0x17, 0xf8, 0x15, 0x0, 0x1, 0xce, 0x24, - 0x5d, 0x13, 0x39, 0xba, 0x15, 0x0, 0xe, 0xd5, 0x33, 0x69, 0xda, 0xf8, 0xc9, 0xc3, 0x30, 0x90, 0x11, - 0xc9, 0x58, 0xb, 0x3, 0x3, 0x0, 0x12, 0x3d, 0x2d, 0x66, 0x9d, 0x67, 0xee, 0x6c, 0xbf, 0x88, 0xbf, - 0x1, 0xbd, 0x36, 0x74, 0xe1, 0x78, 0x62, 0x67, 0x2, 0x0, 0x0, 0x28, 0xbb, 0x29, 0x0, 0x11, 0x0, - 0x0, 0x27, 0xe4, 0x23, 0x8, 0xcc, 0x1c, 0x0, 0x18, 0x19, 0x3d, 0x22, 0xbb, 0x0, 0xf9, 0x3b, 0x80, - 0xe0, 0x8d, 0xe2, 0xd7, 0xd5, 0x3, 0x1b, 0x37, 0xb, 0x30, 0xcd, 0xbf, 0x43, 0xde, 0x6b, 0x38, 0x17, - 0xba, 0x9, 0x0, 0x12, 0xd, 0xec, 0x9a, 0x81, 0x1a, 0xcc, 0x57, 0x8e, 0xd1, 0x56, 0x74, 0x33, 0x4c, - 0xb7, 0x40, 0x41, 0xd5, 0x79, 0x16, 0x0, 0x17, 0x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 0x0, 0x26, 0x25, 0x12, + 0x0, 0x19, 0x99, 0xf8, 0xfb, 0xac, 0xb5, 0x2f, 0xf7, 0x8a, 0x21, 0x3f, 0xc8, 0xfa, 0x6a, 0xbf, 0xf2, + 0xc1, 0x73, 0x91, 0x66, 0xe8, 0xbb, 0xc0, 0xf9, 0xee, 0xbe, 0x22, 0x49, 0x8c, 0x2, 0x0, 0x0, 0x45, + 0x3, 0x18, 0x0, 0x0, 0x1a, 0x69, 0x23, 0x67, 0xd3, 0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, + 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2464,76 +2458,52 @@ TEST(Publish5QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x1b, 0xb0, 0x6d, 0x4d, 0x2d, 0xb7, 0x36, 0x88, 0x70, 0xcb, 0x9c, 0xac}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x12, 0xa6, 0x82, 0xb4, 0x56, 0x9d, 0xa3, 0x62, 0x56}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\178\SI\169\146\239\178\SYN\STX", -// _pubPktID = 0, _pubBody = "K\148\ETX%\135\&7\194\158\DLE\ENQ\215\157\176\ESCA\f", _pubProps = -// [PropSessionExpiryInterval 18509,PropWildcardSubscriptionAvailable 204,PropServerKeepAlive -// 24461,PropRequestResponseInformation 156,PropPayloadFormatIndicator 7,PropAssignedClientIdentifier "",PropTopicAlias -// 26242,PropTopicAlias 7376,PropServerReference "\145D\f",PropSubscriptionIdentifier 7]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\240\218\212Wy", _pubPktID = 11258, +// _pubBody = "\212F\158\240\144\160AN", _pubProps = []} TEST(Publish5QCTest, Encode7) { - uint8_t pkt[] = {0x30, 0x3a, 0x0, 0x8, 0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2, 0x1f, 0x11, 0x0, - 0x0, 0x48, 0x4d, 0x28, 0xcc, 0x13, 0x5f, 0x8d, 0x19, 0x9c, 0x1, 0x7, 0x12, 0x0, 0x0, - 0x23, 0x66, 0x82, 0x23, 0x1c, 0xd0, 0x1c, 0x0, 0x3, 0x91, 0x44, 0xc, 0xb, 0x7, 0x4b, - 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; - uint8_t topic_bytes[] = {0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x12, 0x0, 0x5, 0xf0, 0xda, 0xd4, 0x57, 0x79, 0x2b, + 0xfa, 0x0, 0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; + uint8_t topic_bytes[] = {0xf0, 0xda, 0xd4, 0x57, 0x79}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x4b, 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; - - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x91, 0x44, 0xc}; + msg.payload_len = 8; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18509}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24461}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26242}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7376}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 11258, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\178\SI\169\146\239\178\SYN\STX", -// _pubPktID = 0, _pubBody = "K\148\ETX%\135\&7\194\158\DLE\ENQ\215\157\176\ESCA\f", _pubProps = -// [PropSessionExpiryInterval 18509,PropWildcardSubscriptionAvailable 204,PropServerKeepAlive -// 24461,PropRequestResponseInformation 156,PropPayloadFormatIndicator 7,PropAssignedClientIdentifier "",PropTopicAlias -// 26242,PropTopicAlias 7376,PropServerReference "\145D\f",PropSubscriptionIdentifier 7]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\240\218\212Wy", _pubPktID = 11258, +// _pubBody = "\212F\158\240\144\160AN", _pubProps = []} TEST(Publish5QCTest, Decode7) { - uint8_t pkt[] = {0x30, 0x3a, 0x0, 0x8, 0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2, 0x1f, 0x11, 0x0, - 0x0, 0x48, 0x4d, 0x28, 0xcc, 0x13, 0x5f, 0x8d, 0x19, 0x9c, 0x1, 0x7, 0x12, 0x0, 0x0, - 0x23, 0x66, 0x82, 0x23, 0x1c, 0xd0, 0x1c, 0x0, 0x3, 0x91, 0x44, 0xc, 0xb, 0x7, 0x4b, - 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; + uint8_t pkt[] = {0x33, 0x12, 0x0, 0x5, 0xf0, 0xda, 0xd4, 0x57, 0x79, 0x2b, + 0xfa, 0x0, 0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2541,119 +2511,151 @@ TEST(Publish5QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb2, 0xf, 0xa9, 0x92, 0xef, 0xb2, 0x16, 0x2}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4b, 0x94, 0x3, 0x25, 0x87, 0x37, 0xc2, 0x9e, - 0x10, 0x5, 0xd7, 0x9d, 0xb0, 0x1b, 0x41, 0xc}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xf0, 0xda, 0xd4, 0x57, 0x79}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; + lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 11258); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 8); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\164Y\252JlD$\198\DC1l\vM\194\NAK\194I\144\STX:c\158)N*", _pubPktID = 7891, _pubBody = -// "\176\162\NAK'B\224M\185\SYNa\n\151\146\160U", _pubProps = [PropSessionExpiryInterval 2392,PropServerReference -// "\153\182\131\197\135\174\198\132\EOT[\239\255F\240\196B\162",PropCorrelationData -// "\212",PropRequestResponseInformation 95,PropMessageExpiryInterval 25207,PropRetainAvailable -// 216,PropAssignedClientIdentifier "\149\164\215\200\249\n\RS\155{",PropAssignedClientIdentifier -// "\\\246\175\154*\160\ETB]mH\162\130\157\NUL\253\&2C\SO\\I",PropMaximumQoS 211,PropWillDelayInterval -// 18802,PropMaximumQoS 128,PropPayloadFormatIndicator 208,PropSharedSubscriptionAvailable 4,PropAuthenticationData -// "\150\167E\SIJ\131?\n\147\188\144\177\232\203\187\219\181\ESC\230!\250Xmb",PropSubscriptionIdentifier -// 12,PropMessageExpiryInterval 1249,PropSessionExpiryInterval 20430,PropReceiveMaximum -// 8060,PropWildcardSubscriptionAvailable 85]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\204s\226@u&7F!\EM\194o\133\175\187\203<\DC1;\239Q\RS\251\236J\167a\247\220", _pubPktID = 0, _pubBody = +// "\159(\138\244\237\128L\179\197a", _pubProps = [PropSubscriptionIdentifierAvailable 15,PropSessionExpiryInterval +// 22119,PropRetainAvailable 152,PropServerKeepAlive 26069,PropRequestResponseInformation 142,PropReceiveMaximum +// 4901,PropAssignedClientIdentifier +// "\145\&2B\192\177\230\ACK\US\157\197f$\209\239m\146\139R\183\159;$\231(\SI\158\185\144\135\191",PropAuthenticationMethod +// "\196\173q\132\199f|\DC1\218fj\224\195\&0\195{\150\190\226]\158\ESC@\146d\150\&4\130",PropContentType +// "t\135(\163",PropSubscriptionIdentifierAvailable 37,PropReceiveMaximum 6908,PropResponseTopic +// "\213#",PropUserProperty "K\190\162H\152\253\130>g\136\128\188" "\181i\180dT",PropUserProperty +// "\ETB\\l\148\&0\t\224\135\204\172\255V\US\133\187\235\&6q;\t\129\200l\252D\220^\160" +// "\EM\129\234\177\251\243\234\226\251\137jf\169d\246\254V\158\160\138Ohw\220\202^E'W",PropReasonString +// "\235\\\229\154\205\241\&3O\242\170\NAK+q\129\210\205\203\DC45\249\145<\181\206",PropWillDelayInterval +// 3396,PropTopicAlias 6285,PropAuthenticationMethod +// "\167\NAK\250x\146Nx\225\233\247%\197\t\245\221Mn}\158\168A2",PropAuthenticationMethod +// "\194\149\137\STX\166\bH\212e\184\142\222\158\158\194N\172\ETX^\SUBI\NUL\EM/\137",PropRetainAvailable 82]} TEST(Publish5QCTest, Encode8) { - uint8_t pkt[] = {0x35, 0xaf, 0x1, 0x0, 0x18, 0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, 0x4d, - 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a, 0x1e, 0xd3, 0x82, 0x1, 0x11, - 0x0, 0x0, 0x9, 0x58, 0x1c, 0x0, 0x11, 0x99, 0xb6, 0x83, 0xc5, 0x87, 0xae, 0xc6, 0x84, 0x4, 0x5b, - 0xef, 0xff, 0x46, 0xf0, 0xc4, 0x42, 0xa2, 0x9, 0x0, 0x1, 0xd4, 0x19, 0x5f, 0x2, 0x0, 0x0, 0x62, - 0x77, 0x25, 0xd8, 0x12, 0x0, 0x9, 0x95, 0xa4, 0xd7, 0xc8, 0xf9, 0xa, 0x1e, 0x9b, 0x7b, 0x12, 0x0, - 0x14, 0x5c, 0xf6, 0xaf, 0x9a, 0x2a, 0xa0, 0x17, 0x5d, 0x6d, 0x48, 0xa2, 0x82, 0x9d, 0x0, 0xfd, 0x32, - 0x43, 0xe, 0x5c, 0x49, 0x24, 0xd3, 0x18, 0x0, 0x0, 0x49, 0x72, 0x24, 0x80, 0x1, 0xd0, 0x2a, 0x4, - 0x16, 0x0, 0x18, 0x96, 0xa7, 0x45, 0xf, 0x4a, 0x83, 0x3f, 0xa, 0x93, 0xbc, 0x90, 0xb1, 0xe8, 0xcb, - 0xbb, 0xdb, 0xb5, 0x1b, 0xe6, 0x21, 0xfa, 0x58, 0x6d, 0x62, 0xb, 0xc, 0x2, 0x0, 0x0, 0x4, 0xe1, - 0x11, 0x0, 0x0, 0x4f, 0xce, 0x21, 0x1f, 0x7c, 0x28, 0x55, 0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, - 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; - uint8_t topic_bytes[] = {0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, 0x4d, - 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x31, 0xbb, 0x2, 0x0, 0x1d, 0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, 0x6f, 0x85, 0xaf, + 0xbb, 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, 0x61, 0xf7, 0xdc, 0x90, 0x2, 0x29, 0xf, + 0x11, 0x0, 0x0, 0x56, 0x67, 0x25, 0x98, 0x13, 0x65, 0xd5, 0x19, 0x8e, 0x21, 0x13, 0x25, 0x12, 0x0, 0x1e, 0x91, + 0x32, 0x42, 0xc0, 0xb1, 0xe6, 0x6, 0x1f, 0x9d, 0xc5, 0x66, 0x24, 0xd1, 0xef, 0x6d, 0x92, 0x8b, 0x52, 0xb7, 0x9f, + 0x3b, 0x24, 0xe7,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xf7, + 0x25, 0xc5, 0x9, 0xf5, 0xdd, 0x4d, 0x6e, 0x7d, 0x9e, 0xa8, 0x41, 0x32, 0x15, 0x0, 0x19, 0xc2, 0x95, 0x89, 0x2, + 0xa6, 0x8, 0x48, 0xd4, 0x65, 0xb8, 0x8e, 0xde, 0x9e, 0x9e, 0xc2, 0x4e, 0xac, 0x3, 0x5e, 0x1a, 0x49, 0x0, 0x19, + 0x2f, 0x89, 0x25, 0x52, 0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; + uint8_t topic_bytes[] = {0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, 0x6f, 0x85, 0xaf, 0xbb, + 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, 0x61, 0xf7, 0xdc}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; + uint8_t msg_bytes[] = {0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 10; - uint8_t bytesprops0[] = {0x99, 0xb6, 0x83, 0xc5, 0x87, 0xae, 0xc6, 0x84, 0x4, - 0x5b, 0xef, 0xff, 0x46, 0xf0, 0xc4, 0x42, 0xa2}; - uint8_t bytesprops1[] = {0xd4}; - uint8_t bytesprops2[] = {0x95, 0xa4, 0xd7, 0xc8, 0xf9, 0xa, 0x1e, 0x9b, 0x7b}; - uint8_t bytesprops3[] = {0x5c, 0xf6, 0xaf, 0x9a, 0x2a, 0xa0, 0x17, 0x5d, 0x6d, 0x48, - 0xa2, 0x82, 0x9d, 0x0, 0xfd, 0x32, 0x43, 0xe, 0x5c, 0x49}; - uint8_t bytesprops4[] = {0x96, 0xa7, 0x45, 0xf, 0x4a, 0x83, 0x3f, 0xa, 0x93, 0xbc, 0x90, 0xb1, - 0xe8, 0xcb, 0xbb, 0xdb, 0xb5, 0x1b, 0xe6, 0x21, 0xfa, 0x58, 0x6d, 0x62}; + uint8_t bytesprops0[] = {0x91, 0x32, 0x42, 0xc0, 0xb1, 0xe6, 0x6, 0x1f, 0x9d, 0xc5, 0x66, 0x24, 0xd1, 0xef, 0x6d, + 0x92, 0x8b, 0x52, 0xb7, 0x9f, 0x3b, 0x24, 0xe7, 0x28, 0xf, 0x9e, 0xb9, 0x90, 0x87, 0xbf}; + uint8_t bytesprops1[] = {0xc4, 0xad, 0x71, 0x84, 0xc7, 0x66, 0x7c, 0x11, 0xda, 0x66, 0x6a, 0xe0, 0xc3, 0x30, + 0xc3, 0x7b, 0x96, 0xbe, 0xe2, 0x5d, 0x9e, 0x1b, 0x40, 0x92, 0x64, 0x96, 0x34, 0x82}; + uint8_t bytesprops2[] = {0x74, 0x87, 0x28, 0xa3}; + uint8_t bytesprops3[] = {0xd5, 0x23}; + uint8_t bytesprops5[] = {0xb5, 0x69, 0xb4, 0x64, 0x54}; + uint8_t bytesprops4[] = {0x4b, 0xbe, 0xa2, 0x48, 0x98, 0xfd, 0x82, 0x3e, 0x67, 0x88, 0x80, 0xbc}; + uint8_t bytesprops7[] = {0x19, 0x81, 0xea, 0xb1, 0xfb, 0xf3, 0xea, 0xe2, 0xfb, 0x89, 0x6a, 0x66, 0xa9, 0x64, 0xf6, + 0xfe, 0x56, 0x9e, 0xa0, 0x8a, 0x4f, 0x68, 0x77, 0xdc, 0xca, 0x5e, 0x45, 0x27, 0x57}; + uint8_t bytesprops6[] = {0x17, 0x5c, 0x6c, 0x94, 0x30, 0x9, 0xe0, 0x87, 0xcc, 0xac, 0xff, 0x56, 0x1f, 0x85, + 0xbb, 0xeb, 0x36, 0x71, 0x3b, 0x9, 0x81, 0xc8, 0x6c, 0xfc, 0x44, 0xdc, 0x5e, 0xa0}; + uint8_t bytesprops8[] = {0xeb, 0x5c, 0xe5, 0x9a, 0xcd, 0xf1, 0x33, 0x4f, 0xf2, 0xaa, 0x15, 0x2b, + 0x71, 0x81, 0xd2, 0xcd, 0xcb, 0x14, 0x35, 0xf9, 0x91, 0x3c, 0xb5, 0xce}; + uint8_t bytesprops9[] = {0xa7, 0x15, 0xfa, 0x78, 0x92, 0x4e, 0x78, 0xe1, 0xe9, 0xf7, 0x25, + 0xc5, 0x9, 0xf5, 0xdd, 0x4d, 0x6e, 0x7d, 0x9e, 0xa8, 0x41, 0x32}; + uint8_t bytesprops10[] = {0xc2, 0x95, 0x89, 0x2, 0xa6, 0x8, 0x48, 0xd4, 0x65, 0xb8, 0x8e, 0xde, 0x9e, + 0x9e, 0xc2, 0x4e, 0xac, 0x3, 0x5e, 0x1a, 0x49, 0x0, 0x19, 0x2f, 0x89}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2392}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25207}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18802}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1249}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20430}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8060}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22119}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26069}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4901}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6908}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops4}, .v = {5, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops6}, .v = {29, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3396}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6285}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 82}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7891, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\164Y\252JlD$\198\DC1l\vM\194\NAK\194I\144\STX:c\158)N*", _pubPktID = 7891, _pubBody = -// "\176\162\NAK'B\224M\185\SYNa\n\151\146\160U", _pubProps = [PropSessionExpiryInterval 2392,PropServerReference -// "\153\182\131\197\135\174\198\132\EOT[\239\255F\240\196B\162",PropCorrelationData -// "\212",PropRequestResponseInformation 95,PropMessageExpiryInterval 25207,PropRetainAvailable -// 216,PropAssignedClientIdentifier "\149\164\215\200\249\n\RS\155{",PropAssignedClientIdentifier -// "\\\246\175\154*\160\ETB]mH\162\130\157\NUL\253\&2C\SO\\I",PropMaximumQoS 211,PropWillDelayInterval -// 18802,PropMaximumQoS 128,PropPayloadFormatIndicator 208,PropSharedSubscriptionAvailable 4,PropAuthenticationData -// "\150\167E\SIJ\131?\n\147\188\144\177\232\203\187\219\181\ESC\230!\250Xmb",PropSubscriptionIdentifier -// 12,PropMessageExpiryInterval 1249,PropSessionExpiryInterval 20430,PropReceiveMaximum -// 8060,PropWildcardSubscriptionAvailable 85]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\204s\226@u&7F!\EM\194o\133\175\187\203<\DC1;\239Q\RS\251\236J\167a\247\220", _pubPktID = 0, _pubBody = +// "\159(\138\244\237\128L\179\197a", _pubProps = [PropSubscriptionIdentifierAvailable 15,PropSessionExpiryInterval +// 22119,PropRetainAvailable 152,PropServerKeepAlive 26069,PropRequestResponseInformation 142,PropReceiveMaximum +// 4901,PropAssignedClientIdentifier +// "\145\&2B\192\177\230\ACK\US\157\197f$\209\239m\146\139R\183\159;$\231(\SI\158\185\144\135\191",PropAuthenticationMethod +// "\196\173q\132\199f|\DC1\218fj\224\195\&0\195{\150\190\226]\158\ESC@\146d\150\&4\130",PropContentType +// "t\135(\163",PropSubscriptionIdentifierAvailable 37,PropReceiveMaximum 6908,PropResponseTopic +// "\213#",PropUserProperty "K\190\162H\152\253\130>g\136\128\188" "\181i\180dT",PropUserProperty +// "\ETB\\l\148\&0\t\224\135\204\172\255V\US\133\187\235\&6q;\t\129\200l\252D\220^\160" +// "\EM\129\234\177\251\243\234\226\251\137jf\169d\246\254V\158\160\138Ohw\220\202^E'W",PropReasonString +// "\235\\\229\154\205\241\&3O\242\170\NAK+q\129\210\205\203\DC45\249\145<\181\206",PropWillDelayInterval +// 3396,PropTopicAlias 6285,PropAuthenticationMethod +// "\167\NAK\250x\146Nx\225\233\247%\197\t\245\221Mn}\158\168A2",PropAuthenticationMethod +// "\194\149\137\STX\166\bH\212e\184\142\222\158\158\194N\172\ETX^\SUBI\NUL\EM/\137",PropRetainAvailable 82]} TEST(Publish5QCTest, Decode8) { - uint8_t pkt[] = {0x35, 0xaf, 0x1, 0x0, 0x18, 0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, 0x4d, - 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a, 0x1e, 0xd3, 0x82, 0x1, 0x11, - 0x0, 0x0, 0x9, 0x58, 0x1c, 0x0, 0x11, 0x99, 0xb6, 0x83, 0x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 0xcb, 0x14, 0x35, 0xf9, 0x91, 0x3c, 0xb5, 0xce, 0x18, 0x0, + 0x0, 0xd, 0x44, 0x23, 0x18, 0x8d, 0x15, 0x0, 0x16, 0xa7, 0x15, 0xfa, 0x78, 0x92, 0x4e, 0x78, 0xe1, 0xe9, 0xf7, + 0x25, 0xc5, 0x9, 0xf5, 0xdd, 0x4d, 0x6e, 0x7d, 0x9e, 0xa8, 0x41, 0x32, 0x15, 0x0, 0x19, 0xc2, 0x95, 0x89, 0x2, + 0xa6, 0x8, 0x48, 0xd4, 0x65, 0xb8, 0x8e, 0xde, 0x9e, 0x9e, 0xc2, 0x4e, 0xac, 0x3, 0x5e, 0x1a, 0x49, 0x0, 0x19, + 0x2f, 0x89, 0x25, 0x52, 0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2661,51 +2663,57 @@ TEST(Publish5QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa4, 0x59, 0xfc, 0x4a, 0x6c, 0x44, 0x24, 0xc6, 0x11, 0x6c, 0xb, 0x4d, - 0xc2, 0x15, 0xc2, 0x49, 0x90, 0x2, 0x3a, 0x63, 0x9e, 0x29, 0x4e, 0x2a}; - lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb0, 0xa2, 0x15, 0x27, 0x42, 0xe0, 0x4d, 0xb9, 0x16, 0x61, 0xa, 0x97, 0x92, 0xa0, 0x55}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, 0x6f, 0x85, 0xaf, 0xbb, + 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, 0x61, 0xf7, 0xdc}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 7891); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } // PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\168\NAKx\SI\199\207\184(\186\150r\FS\189\205\252\135\250\205\254\148\161\239\228\176s", _pubPktID = 0, _pubBody = -// "\135", _pubProps = [PropSharedSubscriptionAvailable 243,PropAuthenticationMethod -// "\EM\146\213\227R",PropSessionExpiryInterval 30811]} +// "~\237S\145l\t\ACK0\CAN\236\137G!\FS~l\156\DC3\n>\135", _pubPktID = 0, _pubBody = +// "\NAK\255WE\SIQC\246\161\173\128\&6", _pubProps = [PropRetainAvailable 118,PropRequestResponseInformation +// 19,PropResponseInformation +// "b\240U45\182\253\195v\145\159\162\a\237\172\138\251\240\234J\203HA\184\&87\150\241\212",PropMessageExpiryInterval +// 6795]} TEST(Publish5QCTest, Encode9) { - uint8_t pkt[] = {0x31, 0x2c, 0x0, 0x19, 0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, - 0xbd, 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73, 0xf, 0x2a, 0xf3, - 0x15, 0x0, 0x5, 0x19, 0x92, 0xd5, 0xe3, 0x52, 0x11, 0x0, 0x0, 0x78, 0x5b, 0x87}; - uint8_t topic_bytes[] = {0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, 0xbd, - 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x4d, 0x0, 0x15, 0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, 0x47, + 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87, 0x29, 0x25, 0x76, 0x19, 0x13, 0x1a, 0x0, + 0x1d, 0x62, 0xf0, 0x55, 0x34, 0x35, 0xb6, 0xfd, 0xc3, 0x76, 0x91, 0x9f, 0xa2, 0x7, 0xed, 0xac, + 0x8a, 0xfb, 0xf0, 0xea, 0x4a, 0xcb, 0x48, 0x41, 0xb8, 0x38, 0x37, 0x96, 0xf1, 0xd4, 0x2, 0x0, + 0x0, 0x1a, 0x8b, 0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; + uint8_t topic_bytes[] = {0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, + 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x87}; + uint8_t msg_bytes[] = {0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 12; - uint8_t bytesprops0[] = {0x19, 0x92, 0xd5, 0xe3, 0x52}; + uint8_t bytesprops0[] = {0x62, 0xf0, 0x55, 0x34, 0x35, 0xb6, 0xfd, 0xc3, 0x76, 0x91, 0x9f, 0xa2, 0x7, 0xed, 0xac, + 0x8a, 0xfb, 0xf0, 0xea, 0x4a, 0xcb, 0x48, 0x41, 0xb8, 0x38, 0x37, 0x96, 0xf1, 0xd4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30811}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6795}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); @@ -2714,13 +2722,17 @@ TEST(Publish5QCTest, Encode9) { } // PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\168\NAKx\SI\199\207\184(\186\150r\FS\189\205\252\135\250\205\254\148\161\239\228\176s", _pubPktID = 0, _pubBody = -// "\135", _pubProps = [PropSharedSubscriptionAvailable 243,PropAuthenticationMethod -// "\EM\146\213\227R",PropSessionExpiryInterval 30811]} +// "~\237S\145l\t\ACK0\CAN\236\137G!\FS~l\156\DC3\n>\135", _pubPktID = 0, _pubBody = +// "\NAK\255WE\SIQC\246\161\173\128\&6", _pubProps = [PropRetainAvailable 118,PropRequestResponseInformation +// 19,PropResponseInformation +// "b\240U45\182\253\195v\145\159\162\a\237\172\138\251\240\234J\203HA\184\&87\150\241\212",PropMessageExpiryInterval +// 6795]} TEST(Publish5QCTest, Decode9) { - uint8_t pkt[] = {0x31, 0x2c, 0x0, 0x19, 0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, - 0xbd, 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73, 0xf, 0x2a, 0xf3, - 0x15, 0x0, 0x5, 0x19, 0x92, 0xd5, 0xe3, 0x52, 0x11, 0x0, 0x0, 0x78, 0x5b, 0x87}; + uint8_t pkt[] = {0x31, 0x4d, 0x0, 0x15, 0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, 0x47, + 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87, 0x29, 0x25, 0x76, 0x19, 0x13, 0x1a, 0x0, + 0x1d, 0x62, 0xf0, 0x55, 0x34, 0x35, 0xb6, 0xfd, 0xc3, 0x76, 0x91, 0x9f, 0xa2, 0x7, 0xed, 0xac, + 0x8a, 0xfb, 0xf0, 0xea, 0x4a, 0xcb, 0x48, 0x41, 0xb8, 0x38, 0x37, 0x96, 0xf1, 0xd4, 0x2, 0x0, + 0x0, 0x1a, 0x8b, 0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2728,117 +2740,128 @@ TEST(Publish5QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa8, 0x15, 0x78, 0xf, 0xc7, 0xcf, 0xb8, 0x28, 0xba, 0x96, 0x72, 0x1c, 0xbd, - 0xcd, 0xfc, 0x87, 0xfa, 0xcd, 0xfe, 0x94, 0xa1, 0xef, 0xe4, 0xb0, 0x73}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x87}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, + 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\140r\DC3\130\161\ENQ", _pubPktID = -// 6491, _pubBody = "\241G\235!\175\252\158\183\145\224\246\172\SYN\130\131/\254\205\ENQ\GS?", _pubProps = -// [PropResponseTopic "\131\205\&2\194yD\165\177\183\161\144z",PropReasonString -// "\229\216EX`\EOT\171\146\185\bl\224\&6VsG\200z0-]|",PropRequestResponseInformation 60,PropSessionExpiryInterval -// 21347,PropSubscriptionIdentifier 29,PropUserProperty -// "\207*\196\202)\141^C+\128\131\208\195[\ETB\136\184\SYN\243\206\DC4\168" -// "\236,\167o\134F\241\140\GS\187J\131\194\247f<\158{\189\ACK\SOHUk\192",PropAuthenticationData -// "\"Vf\232]\CAN\189=\235F\150c",PropSessionExpiryInterval 22735,PropServerKeepAlive 31363,PropRetainAvailable -// 54,PropAuthenticationMethod -// "\165\212~\DC4\a\227R\US\150\195\221\&4\145\220\&31yVM\226\SOH\188\190-\ETXV\196\236s",PropAuthenticationData -// "k\201W\138\129\r\135\146\166\233\214"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\168q\180\235Y\176\233\DC2z6\175%\SOH\200c&\131\DC2\134#\151\139\&2\ETX\130\DC4", _pubPktID = 2807, _pubBody = +// "`\EOT\158\236\t\225\128\235\197\172aw\173\147\&8\DC3\EOT\244+\249C)zO\156\191\199", _pubProps = [PropCorrelationData +// "\136\230\t\187\137\198\220",PropMaximumPacketSize 335,PropUserProperty "{\ESC\177\148e\157" +// "I&\137*\206Xi\190k_\247n\251\209w\210C\237e/S\195,\224\176\ESC",PropWildcardSubscriptionAvailable +// 90,PropReceiveMaximum 24643,PropServerReference "o\f\189",PropResponseTopic "\174O\SYNA,",PropRetainAvailable +// 70,PropWildcardSubscriptionAvailable 4,PropResponseInformation +// "\DC4\255y*:\\\234\&6\193]\216\147\155\175\246\224\233+\171",PropSessionExpiryInterval 8433,PropMaximumQoS +// 76,PropMessageExpiryInterval 29147,PropAuthenticationData "\218\250/\142\237\164\161\SO\180\DC3",PropUserProperty +// "\212\185" "\132\231D\242\154\DLE\248",PropSubscriptionIdentifier 9,PropAuthenticationData +// "u\217\159\174>\148\252\SI\\y\156P~\185p",PropMessageExpiryInterval 5756,PropSessionExpiryInterval 27296]} TEST(Publish5QCTest, Encode10) { uint8_t pkt[] = { - 0x3a, 0xcc, 0x1, 0x0, 0x6, 0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5, 0x19, 0x5b, 0xab, 0x1, 0x8, 0x0, 0xc, 0x83, - 0xcd, 0x32, 0xc2, 0x79, 0x44, 0xa5, 0xb1, 0xb7, 0xa1, 0x90, 0x7a, 0x1f, 0x0, 0x16, 0xe5, 0xd8, 0x45, 0x58, 0x60, - 0x4, 0xab, 0x92, 0xb9, 0x8, 0x6c, 0xe0, 0x36, 0x56, 0x73, 0x47, 0xc8, 0x7a, 0x30, 0x2d, 0x5d, 0x7c, 0x19, 0x3c, - 0x11, 0x0, 0x0, 0x53, 0x63, 0xb, 0x1d, 0x26, 0x0, 0x16, 0xcf, 0x2a, 0xc4, 0xca, 0x29, 0x8d, 0x5e, 0x43, 0x2b, - 0x80, 0x83, 0xd0, 0xc3, 0x5b, 0x17, 0x88, 0xb8, 0x16, 0xf3, 0xce, 0x14, 0xa8, 0x0, 0x18, 0xec, 0x2c, 0xa7, 0x6f, - 0x86, 0x46, 0xf1, 0x8c, 0x1d, 0xbb, 0x4a, 0x83, 0xc2, 0xf7, 0x66, 0x3c, 0x9e, 0x7b, 0xbd, 0x6, 0x1, 0x55, 0x6b, - 0xc0, 0x16, 0x0, 0xc, 0x22, 0x56, 0x66, 0xe8, 0x5d, 0x18, 0xbd, 0x3d, 0xeb, 0x46, 0x96, 0x63, 0x11, 0x0, 0x0, - 0x58, 0xcf, 0x13, 0x7a, 0x83, 0x25, 0x36, 0x15, 0x0, 0x1d, 0xa5, 0xd4, 0x7e, 0x14, 0x7, 0xe3, 0x52, 0x1f, 0x96, - 0xc3, 0xdd, 0x34, 0x91, 0xdc, 0x33, 0x31, 0x79, 0x56, 0x4d, 0xe2, 0x1, 0xbc, 0xbe, 0x2d, 0x3, 0x56, 0xc4, 0xec, - 0x73, 0x16, 0x0, 0xb, 0x6b, 0xc9, 0x57, 0x8a, 0x81, 0xd, 0x87, 0x92, 0xa6, 0xe9, 0xd6, 0xf1, 0x47, 0xeb, 0x21, - 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; - uint8_t topic_bytes[] = {0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + 0x3a, 0xe1, 0x1, 0x0, 0x1a, 0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1, 0xc8, + 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14, 0xa, 0xf7, 0xa6, 0x1, 0x9, 0x0, 0x7, + 0x88, 0xe6, 0x9, 0xbb, 0x89, 0xc6, 0xdc, 0x27, 0x0, 0x0, 0x1, 0x4f, 0x26, 0x0, 0x6, 0x7b, 0x1b, 0xb1, 0x94, + 0x65, 0x9d, 0x0, 0x1a, 0x49, 0x26, 0x89, 0x2a, 0xce, 0x58, 0x69, 0xbe, 0x6b, 0x5f, 0xf7, 0x6e, 0xfb, 0xd1, 0x77, + 0xd2, 0x43, 0xed, 0x65, 0x2f, 0x53, 0xc3, 0x2c, 0xe0, 0xb0, 0x1b, 0x28, 0x5a, 0x21, 0x60, 0x43, 0x1c, 0x0, 0x3, + 0x6f, 0xc, 0xbd, 0x8, 0x0, 0x5, 0xae, 0x4f, 0x16, 0x41, 0x2c, 0x25, 0x46, 0x28, 0x4, 0x1a, 0x0, 0x13, 0x14, + 0xff, 0x79, 0x2a, 0x3a, 0x5c, 0xea, 0x36, 0xc1, 0x5d, 0xd8, 0x93, 0x9b, 0xaf, 0xf6, 0xe0, 0xe9, 0x2b, 0xab, 0x11, + 0x0, 0x0, 0x20, 0xf1, 0x24, 0x4c, 0x2, 0x0, 0x0, 0x71, 0xdb, 0x16, 0x0, 0xa, 0xda, 0xfa, 0x2f, 0x8e, 0xed, + 0xa4, 0xa1, 0xe, 0xb4, 0x13, 0x26, 0x0, 0x2, 0xd4, 0xb9, 0x0, 0x7, 0x84, 0xe7, 0x44, 0xf2, 0x9a, 0x10, 0xf8, + 0xb, 0x9, 0x16, 0x0, 0xf, 0x75, 0xd9, 0x9f, 0xae, 0x3e, 0x94, 0xfc, 0xf, 0x5c, 0x79, 0x9c, 0x50, 0x7e, 0xb9, + 0x70, 0x2, 0x0, 0x0, 0x16, 0x7c, 0x11, 0x0, 0x0, 0x6a, 0xa0, 0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, + 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; + uint8_t topic_bytes[] = {0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1, + 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xf1, 0x47, 0xeb, 0x21, 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, - 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; + uint8_t msg_bytes[] = {0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, + 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 27; - uint8_t bytesprops0[] = {0x83, 0xcd, 0x32, 0xc2, 0x79, 0x44, 0xa5, 0xb1, 0xb7, 0xa1, 0x90, 0x7a}; - uint8_t bytesprops1[] = {0xe5, 0xd8, 0x45, 0x58, 0x60, 0x4, 0xab, 0x92, 0xb9, 0x8, 0x6c, - 0xe0, 0x36, 0x56, 0x73, 0x47, 0xc8, 0x7a, 0x30, 0x2d, 0x5d, 0x7c}; - uint8_t bytesprops3[] = {0xec, 0x2c, 0xa7, 0x6f, 0x86, 0x46, 0xf1, 0x8c, 0x1d, 0xbb, 0x4a, 0x83, - 0xc2, 0xf7, 0x66, 0x3c, 0x9e, 0x7b, 0xbd, 0x6, 0x1, 0x55, 0x6b, 0xc0}; - uint8_t bytesprops2[] = {0xcf, 0x2a, 0xc4, 0xca, 0x29, 0x8d, 0x5e, 0x43, 0x2b, 0x80, 0x83, - 0xd0, 0xc3, 0x5b, 0x17, 0x88, 0xb8, 0x16, 0xf3, 0xce, 0x14, 0xa8}; - uint8_t bytesprops4[] = {0x22, 0x56, 0x66, 0xe8, 0x5d, 0x18, 0xbd, 0x3d, 0xeb, 0x46, 0x96, 0x63}; - uint8_t bytesprops5[] = {0xa5, 0xd4, 0x7e, 0x14, 0x7, 0xe3, 0x52, 0x1f, 0x96, 0xc3, 0xdd, 0x34, 0x91, 0xdc, 0x33, - 0x31, 0x79, 0x56, 0x4d, 0xe2, 0x1, 0xbc, 0xbe, 0x2d, 0x3, 0x56, 0xc4, 0xec, 0x73}; - uint8_t bytesprops6[] = {0x6b, 0xc9, 0x57, 0x8a, 0x81, 0xd, 0x87, 0x92, 0xa6, 0xe9, 0xd6}; + uint8_t bytesprops0[] = {0x88, 0xe6, 0x9, 0xbb, 0x89, 0xc6, 0xdc}; + uint8_t bytesprops2[] = {0x49, 0x26, 0x89, 0x2a, 0xce, 0x58, 0x69, 0xbe, 0x6b, 0x5f, 0xf7, 0x6e, 0xfb, + 0xd1, 0x77, 0xd2, 0x43, 0xed, 0x65, 0x2f, 0x53, 0xc3, 0x2c, 0xe0, 0xb0, 0x1b}; + uint8_t bytesprops1[] = {0x7b, 0x1b, 0xb1, 0x94, 0x65, 0x9d}; + uint8_t bytesprops3[] = {0x6f, 0xc, 0xbd}; + uint8_t bytesprops4[] = {0xae, 0x4f, 0x16, 0x41, 0x2c}; + uint8_t bytesprops5[] = {0x14, 0xff, 0x79, 0x2a, 0x3a, 0x5c, 0xea, 0x36, 0xc1, 0x5d, + 0xd8, 0x93, 0x9b, 0xaf, 0xf6, 0xe0, 0xe9, 0x2b, 0xab}; + uint8_t bytesprops6[] = {0xda, 0xfa, 0x2f, 0x8e, 0xed, 0xa4, 0xa1, 0xe, 0xb4, 0x13}; + uint8_t bytesprops8[] = {0x84, 0xe7, 0x44, 0xf2, 0x9a, 0x10, 0xf8}; + uint8_t bytesprops7[] = {0xd4, 0xb9}; + uint8_t bytesprops9[] = {0x75, 0xd9, 0x9f, 0xae, 0x3e, 0x94, 0xfc, 0xf, 0x5c, 0x79, 0x9c, 0x50, 0x7e, 0xb9, 0x70}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21347}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops2}, .v = {24, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22735}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31363}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 335}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {26, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24643}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8433}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29147}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops7}, .v = {7, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5756}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27296}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6491, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2807, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\140r\DC3\130\161\ENQ", _pubPktID = -// 6491, _pubBody = "\241G\235!\175\252\158\183\145\224\246\172\SYN\130\131/\254\205\ENQ\GS?", _pubProps = -// [PropResponseTopic "\131\205\&2\194yD\165\177\183\161\144z",PropReasonString -// "\229\216EX`\EOT\171\146\185\bl\224\&6VsG\200z0-]|",PropRequestResponseInformation 60,PropSessionExpiryInterval -// 21347,PropSubscriptionIdentifier 29,PropUserProperty -// "\207*\196\202)\141^C+\128\131\208\195[\ETB\136\184\SYN\243\206\DC4\168" -// "\236,\167o\134F\241\140\GS\187J\131\194\247f<\158{\189\ACK\SOHUk\192",PropAuthenticationData -// "\"Vf\232]\CAN\189=\235F\150c",PropSessionExpiryInterval 22735,PropServerKeepAlive 31363,PropRetainAvailable -// 54,PropAuthenticationMethod -// "\165\212~\DC4\a\227R\US\150\195\221\&4\145\220\&31yVM\226\SOH\188\190-\ETXV\196\236s",PropAuthenticationData -// "k\201W\138\129\r\135\146\166\233\214"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\168q\180\235Y\176\233\DC2z6\175%\SOH\200c&\131\DC2\134#\151\139\&2\ETX\130\DC4", _pubPktID = 2807, _pubBody = +// "`\EOT\158\236\t\225\128\235\197\172aw\173\147\&8\DC3\EOT\244+\249C)zO\156\191\199", _pubProps = [PropCorrelationData +// "\136\230\t\187\137\198\220",PropMaximumPacketSize 335,PropUserProperty "{\ESC\177\148e\157" +// "I&\137*\206Xi\190k_\247n\251\209w\210C\237e/S\195,\224\176\ESC",PropWildcardSubscriptionAvailable +// 90,PropReceiveMaximum 24643,PropServerReference "o\f\189",PropResponseTopic "\174O\SYNA,",PropRetainAvailable +// 70,PropWildcardSubscriptionAvailable 4,PropResponseInformation +// "\DC4\255y*:\\\234\&6\193]\216\147\155\175\246\224\233+\171",PropSessionExpiryInterval 8433,PropMaximumQoS +// 76,PropMessageExpiryInterval 29147,PropAuthenticationData "\218\250/\142\237\164\161\SO\180\DC3",PropUserProperty +// "\212\185" "\132\231D\242\154\DLE\248",PropSubscriptionIdentifier 9,PropAuthenticationData +// "u\217\159\174>\148\252\SI\\y\156P~\185p",PropMessageExpiryInterval 5756,PropSessionExpiryInterval 27296]} TEST(Publish5QCTest, Decode10) { uint8_t pkt[] = { - 0x3a, 0xcc, 0x1, 0x0, 0x6, 0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5, 0x19, 0x5b, 0xab, 0x1, 0x8, 0x0, 0xc, 0x83, - 0xcd, 0x32, 0xc2, 0x79, 0x44, 0xa5, 0xb1, 0xb7, 0xa1, 0x90, 0x7a, 0x1f, 0x0, 0x16, 0xe5, 0xd8, 0x45, 0x58, 0x60, - 0x4, 0xab, 0x92, 0xb9, 0x8, 0x6c, 0xe0, 0x36, 0x56, 0x73, 0x47, 0xc8, 0x7a, 0x30, 0x2d, 0x5d, 0x7c, 0x19, 0x3c, - 0x11, 0x0, 0x0, 0x53, 0x63, 0xb, 0x1d, 0x26, 0x0, 0x16, 0xcf, 0x2a, 0xc4, 0xca, 0x29, 0x8d, 0x5e, 0x43, 0x2b, - 0x80, 0x83, 0xd0, 0xc3, 0x5b, 0x17, 0x88, 0xb8, 0x16, 0xf3, 0xce, 0x14, 0xa8, 0x0, 0x18, 0xec, 0x2c, 0xa7, 0x6f, - 0x86, 0x46, 0xf1, 0x8c, 0x1d, 0xbb, 0x4a, 0x83, 0xc2, 0xf7, 0x66, 0x3c, 0x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x1b, 0x28, 0x5a, 0x21, 0x60, 0x43, 0x1c, 0x0, 0x3, + 0x6f, 0xc, 0xbd, 0x8, 0x0, 0x5, 0xae, 0x4f, 0x16, 0x41, 0x2c, 0x25, 0x46, 0x28, 0x4, 0x1a, 0x0, 0x13, 0x14, + 0xff, 0x79, 0x2a, 0x3a, 0x5c, 0xea, 0x36, 0xc1, 0x5d, 0xd8, 0x93, 0x9b, 0xaf, 0xf6, 0xe0, 0xe9, 0x2b, 0xab, 0x11, + 0x0, 0x0, 0x20, 0xf1, 0x24, 0x4c, 0x2, 0x0, 0x0, 0x71, 0xdb, 0x16, 0x0, 0xa, 0xda, 0xfa, 0x2f, 0x8e, 0xed, + 0xa4, 0xa1, 0xe, 0xb4, 0x13, 0x26, 0x0, 0x2, 0xd4, 0xb9, 0x0, 0x7, 0x84, 0xe7, 0x44, 0xf2, 0x9a, 0x10, 0xf8, + 0xb, 0x9, 0x16, 0x0, 0xf, 0x75, 0xd9, 0x9f, 0xae, 0x3e, 0x94, 0xfc, 0xf, 0x5c, 0x79, 0x9c, 0x50, 0x7e, 0xb9, + 0x70, 0x2, 0x0, 0x0, 0x16, 0x7c, 0x11, 0x0, 0x0, 0x6a, 0xa0, 0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, + 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2846,78 +2869,136 @@ TEST(Publish5QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8c, 0x72, 0x13, 0x82, 0xa1, 0x5}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf1, 0x47, 0xeb, 0x21, 0xaf, 0xfc, 0x9e, 0xb7, 0x91, 0xe0, 0xf6, - 0xac, 0x16, 0x82, 0x83, 0x2f, 0xfe, 0xcd, 0x5, 0x1d, 0x3f}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1, + 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, + 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 6491); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 2807); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\239\238\236\203\SI", _pubPktID = -// 8912, _pubBody = "\fH\EOT\166q\ESC\ESC\185\177A", _pubProps = [PropReasonString -// "\225\165\129\142\147\&7T\193\242o\a1\190\128@",PropWillDelayInterval 9183,PropResponseTopic -// "E{<",PropWildcardSubscriptionAvailable 82,PropSessionExpiryInterval 21830,PropSubscriptionIdentifier -// 4,PropResponseTopic "q\172\150W\180TB+\249?\228\223\&2h\162\149\ETX\EOT\217\179"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\207\198\194\214\STX\139\&4_\212\172\NAKu:\233\181_\247\164\SUB", _pubPktID = 13284, _pubBody = +// "\154\166c\188;\235r\148\223\SYN\DEL", _pubProps = [PropRetainAvailable 21,PropSubscriptionIdentifier +// 31,PropReceiveMaximum 2517,PropServerKeepAlive 6414,PropResponseTopic +// "^\249\195\230\169\EM\192Y\DC4\182\188\253\197\198\132\132g\155u\227\SYN\230",PropAuthenticationData +// "\184\146\134G\DLE\SO\198sbit\220\245\201$\205V\174\212\DLE\169\214\145",PropMaximumQoS +// 155,PropSharedSubscriptionAvailable 149,PropContentType +// "\248\149\156\240\161PC\142\179N\201\219\225\a\229q\238\207\235",PropServerKeepAlive 9191,PropReasonString +// "\251\190\196B\191",PropServerKeepAlive 25660,PropWillDelayInterval 13246,PropCorrelationData +// "\208\216nK\n\"\164cO\154\CAN\189Q\146\216'\SYNHF\ENQ\133\166\207\207\174\182\DC2",PropWillDelayInterval +// 4856,PropServerKeepAlive 31311,PropSubscriptionIdentifier 4,PropWildcardSubscriptionAvailable +// 100,PropAuthenticationMethod "W\223\&5\204\212\216K\NAKz\148\231S;",PropSharedSubscriptionAvailable +// 94,PropResponseTopic "\216\198b\180\207\199\206\200\166\190\220\242\167\SUB\169\196st\138\255\234\193"]} TEST(Publish5QCTest, Encode11) { - uint8_t pkt[] = {0x32, 0x51, 0x0, 0x5, 0xef, 0xee, 0xec, 0xcb, 0xf, 0x22, 0xd0, 0x3d, 0x1f, 0x0, 0xf, 0xe1, 0xa5, - 0x81, 0x8e, 0x93, 0x37, 0x54, 0xc1, 0xf2, 0x6f, 0x7, 0x31, 0xbe, 0x80, 0x40, 0x18, 0x0, 0x0, 0x23, - 0xdf, 0x8, 0x0, 0x3, 0x45, 0x7b, 0x3c, 0x28, 0x52, 0x11, 0x0, 0x0, 0x55, 0x46, 0xb, 0x4, 0x8, - 0x0, 0x14, 0x71, 0xac, 0x96, 0x57, 0xb4, 0x54, 0x42, 0x2b, 0xf9, 0x3f, 0xe4, 0xdf, 0x32, 0x68, 0xa2, - 0x95, 0x3, 0x4, 0xd9, 0xb3, 0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; - uint8_t topic_bytes[] = {0xef, 0xee, 0xec, 0xcb, 0xf}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0xe3, 0x1, 0x0, 0x13, 0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, 0x15, 0x75, + 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a, 0x33, 0xe4, 0xbf, 0x1, 0x25, 0x15, 0xb, 0x1f, 0x21, 0x9, + 0xd5, 0x13, 0x19, 0xe, 0x8, 0x0, 0x16, 0x5e, 0xf9, 0xc3, 0xe6, 0xa9, 0x19, 0xc0, 0x59, 0x14, 0xb6, + 0xbc, 0xfd, 0xc5, 0xc6, 0x84, 0x84, 0x67, 0x9b, 0x75, 0xe3, 0x16, 0xe6, 0x16, 0x0, 0x17, 0xb8, 0x92, + 0x86, 0x47, 0x10, 0xe, 0xc6, 0x73, 0x62, 0x69, 0x74, 0xdc, 0xf5, 0xc9, 0x24, 0xcd, 0x56, 0xae, 0xd4, + 0x10, 0xa9, 0xd6, 0x91, 0x24, 0x9b, 0x2a, 0x95, 0x3, 0x0, 0x13, 0xf8, 0x95, 0x9c, 0xf0, 0xa1, 0x50, + 0x43, 0x8e, 0xb3, 0x4e, 0xc9, 0xdb, 0xe1, 0x7, 0xe5, 0x71, 0xee, 0xcf, 0xeb, 0x13, 0x23, 0xe7, 0x1f, + 0x0, 0x5, 0xfb, 0xbe, 0xc4, 0x42, 0xbf, 0x13, 0x64, 0x3c, 0x18, 0x0, 0x0, 0x33, 0xbe, 0x9, 0x0, + 0x1b, 0xd0, 0xd8, 0x6e, 0x4b, 0xa, 0x22, 0xa4, 0x63, 0x4f, 0x9a, 0x18, 0xbd, 0x51, 0x92, 0xd8, 0x27, + 0x16, 0x48, 0x46, 0x5, 0x85, 0xa6, 0xcf, 0xcf, 0xae, 0xb6, 0x12, 0x18, 0x0, 0x0, 0x12, 0xf8, 0x13, + 0x7a, 0x4f, 0xb, 0x4, 0x28, 0x64, 0x15, 0x0, 0xd, 0x57, 0xdf, 0x35, 0xcc, 0xd4, 0xd8, 0x4b, 0x15, + 0x7a, 0x94, 0xe7, 0x53, 0x3b, 0x2a, 0x5e, 0x8, 0x0, 0x16, 0xd8, 0xc6, 0x62, 0xb4, 0xcf, 0xc7, 0xce, + 0xc8, 0xa6, 0xbe, 0xdc, 0xf2, 0xa7, 0x1a, 0xa9, 0xc4, 0x73, 0x74, 0x8a, 0xff, 0xea, 0xc1, 0x9a, 0xa6, + 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; + uint8_t topic_bytes[] = {0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, + 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; + uint8_t msg_bytes[] = {0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + msg.payload_len = 11; - uint8_t bytesprops0[] = {0xe1, 0xa5, 0x81, 0x8e, 0x93, 0x37, 0x54, 0xc1, 0xf2, 0x6f, 0x7, 0x31, 0xbe, 0x80, 0x40}; - uint8_t bytesprops1[] = {0x45, 0x7b, 0x3c}; - uint8_t bytesprops2[] = {0x71, 0xac, 0x96, 0x57, 0xb4, 0x54, 0x42, 0x2b, 0xf9, 0x3f, - 0xe4, 0xdf, 0x32, 0x68, 0xa2, 0x95, 0x3, 0x4, 0xd9, 0xb3}; + uint8_t bytesprops0[] = {0x5e, 0xf9, 0xc3, 0xe6, 0xa9, 0x19, 0xc0, 0x59, 0x14, 0xb6, 0xbc, + 0xfd, 0xc5, 0xc6, 0x84, 0x84, 0x67, 0x9b, 0x75, 0xe3, 0x16, 0xe6}; + uint8_t bytesprops1[] = {0xb8, 0x92, 0x86, 0x47, 0x10, 0xe, 0xc6, 0x73, 0x62, 0x69, 0x74, 0xdc, + 0xf5, 0xc9, 0x24, 0xcd, 0x56, 0xae, 0xd4, 0x10, 0xa9, 0xd6, 0x91}; + uint8_t bytesprops2[] = {0xf8, 0x95, 0x9c, 0xf0, 0xa1, 0x50, 0x43, 0x8e, 0xb3, 0x4e, + 0xc9, 0xdb, 0xe1, 0x7, 0xe5, 0x71, 0xee, 0xcf, 0xeb}; + uint8_t bytesprops3[] = {0xfb, 0xbe, 0xc4, 0x42, 0xbf}; + uint8_t bytesprops4[] = {0xd0, 0xd8, 0x6e, 0x4b, 0xa, 0x22, 0xa4, 0x63, 0x4f, 0x9a, 0x18, 0xbd, 0x51, 0x92, + 0xd8, 0x27, 0x16, 0x48, 0x46, 0x5, 0x85, 0xa6, 0xcf, 0xcf, 0xae, 0xb6, 0x12}; + uint8_t bytesprops5[] = {0x57, 0xdf, 0x35, 0xcc, 0xd4, 0xd8, 0x4b, 0x15, 0x7a, 0x94, 0xe7, 0x53, 0x3b}; + uint8_t bytesprops6[] = {0xd8, 0xc6, 0x62, 0xb4, 0xcf, 0xc7, 0xce, 0xc8, 0xa6, 0xbe, 0xdc, + 0xf2, 0xa7, 0x1a, 0xa9, 0xc4, 0x73, 0x74, 0x8a, 0xff, 0xea, 0xc1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9183}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21830}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2517}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6414}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9191}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25660}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13246}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4856}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31311}}, {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 8912, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 13284, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\239\238\236\203\SI", _pubPktID = -// 8912, _pubBody = "\fH\EOT\166q\ESC\ESC\185\177A", _pubProps = [PropReasonString -// "\225\165\129\142\147\&7T\193\242o\a1\190\128@",PropWillDelayInterval 9183,PropResponseTopic -// "E{<",PropWildcardSubscriptionAvailable 82,PropSessionExpiryInterval 21830,PropSubscriptionIdentifier -// 4,PropResponseTopic "q\172\150W\180TB+\249?\228\223\&2h\162\149\ETX\EOT\217\179"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\207\198\194\214\STX\139\&4_\212\172\NAKu:\233\181_\247\164\SUB", _pubPktID = 13284, _pubBody = +// "\154\166c\188;\235r\148\223\SYN\DEL", _pubProps = [PropRetainAvailable 21,PropSubscriptionIdentifier +// 31,PropReceiveMaximum 2517,PropServerKeepAlive 6414,PropResponseTopic +// "^\249\195\230\169\EM\192Y\DC4\182\188\253\197\198\132\132g\155u\227\SYN\230",PropAuthenticationData +// "\184\146\134G\DLE\SO\198sbit\220\245\201$\205V\174\212\DLE\169\214\145",PropMaximumQoS +// 155,PropSharedSubscriptionAvailable 149,PropContentType +// "\248\149\156\240\161PC\142\179N\201\219\225\a\229q\238\207\235",PropServerKeepAlive 9191,PropReasonString +// "\251\190\196B\191",PropServerKeepAlive 25660,PropWillDelayInterval 13246,PropCorrelationData +// "\208\216nK\n\"\164cO\154\CAN\189Q\146\216'\SYNHF\ENQ\133\166\207\207\174\182\DC2",PropWillDelayInterval +// 4856,PropServerKeepAlive 31311,PropSubscriptionIdentifier 4,PropWildcardSubscriptionAvailable +// 100,PropAuthenticationMethod "W\223\&5\204\212\216K\NAKz\148\231S;",PropSharedSubscriptionAvailable +// 94,PropResponseTopic "\216\198b\180\207\199\206\200\166\190\220\242\167\SUB\169\196st\138\255\234\193"]} TEST(Publish5QCTest, Decode11) { - uint8_t pkt[] = {0x32, 0x51, 0x0, 0x5, 0xef, 0xee, 0xec, 0xcb, 0xf, 0x22, 0xd0, 0x3d, 0x1f, 0x0, 0xf, 0xe1, 0xa5, - 0x81, 0x8e, 0x93, 0x37, 0x54, 0xc1, 0xf2, 0x6f, 0x7, 0x31, 0xbe, 0x80, 0x40, 0x18, 0x0, 0x0, 0x23, - 0xdf, 0x8, 0x0, 0x3, 0x45, 0x7b, 0x3c, 0x28, 0x52, 0x11, 0x0, 0x0, 0x55, 0x46, 0xb, 0x4, 0x8, - 0x0, 0x14, 0x71, 0xac, 0x96, 0x57, 0xb4, 0x54, 0x42, 0x2b, 0xf9, 0x3f, 0xe4, 0xdf, 0x32, 0x68, 0xa2, - 0x95, 0x3, 0x4, 0xd9, 0xb3, 0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; + uint8_t pkt[] = {0x3c, 0xe3, 0x1, 0x0, 0x13, 0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, 0x15, 0x75, + 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa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, 0xf2, 0xa7, 0x1a, 0xa9, 0xc4, 0x73, 0x74, 0x8a, 0xff, 0xea, 0xc1, 0x9a, 0xa6, + 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2925,88 +3006,145 @@ TEST(Publish5QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xef, 0xee, 0xec, 0xcb, 0xf}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc, 0x48, 0x4, 0xa6, 0x71, 0x1b, 0x1b, 0xb9, 0xb1, 0x41}; - lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, + 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a}; + lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 8912); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); + EXPECT_EQ(packet_id, 13284); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "[", _pubPktID = 16570, _pubBody = -// "\173\247\147\148\f{|ku\211\&0\DC3\224\227di\ETX\214[\DEL\138I\133\r8{", _pubProps = [PropAuthenticationData -// "\201\130\227x)\225\205\159\186k",PropMessageExpiryInterval 23158,PropMessageExpiryInterval -// 24649,PropTopicAliasMaximum 28197,PropTopicAliasMaximum 26355,PropContentType "\198\230\148 -// \ACK\252(\ENQo\237\214\224Zinzi\EOT\192\129T\147$",PropMaximumQoS 167,PropRetainAvailable 23,PropContentType -// "\250o\139\nJ\DC3\240\&6\180\159\247y\176p\198\SO\238\138A",PropReceiveMaximum 32721]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\159\US\147\DC3i\FS\CAN@\178\DC2\202\145>\185\195\148\f3@ \SOH\202\166\182\STX\v\130\SYN", _pubPktID = 25675, +// _pubBody = "\138\158G\154\229\140)?>\221\211<\190", _pubProps = [PropReasonString +// "C\179\185>\185\233>\221\ETB\210\ESC1\191\222\\t34\204\243\130\DLE\ETB1\179\164\168X",PropMessageExpiryInterval +// 21252,PropRequestProblemInformation 18,PropWildcardSubscriptionAvailable 23,PropTopicAlias 2791,PropCorrelationData +// "\195Q\228\179\197%\222\222\ESC#^\237kK\168",PropSubscriptionIdentifierAvailable 244,PropServerReference +// "G[\234\142T\228\212",PropResponseTopic "Ae\168\145\b",PropWillDelayInterval 30687,PropAssignedClientIdentifier +// "o\NUL\156\185\195\148\f3@ \SOH\202\166\182\STX\v\130\SYN", _pubPktID = 25675, +// _pubBody = "\138\158G\154\229\140)?>\221\211<\190", _pubProps = [PropReasonString +// "C\179\185>\185\233>\221\ETB\210\ESC1\191\222\\t34\204\243\130\DLE\ETB1\179\164\168X",PropMessageExpiryInterval +// 21252,PropRequestProblemInformation 18,PropWildcardSubscriptionAvailable 23,PropTopicAlias 2791,PropCorrelationData +// "\195Q\228\179\197%\222\222\ESC#^\237kK\168",PropSubscriptionIdentifierAvailable 244,PropServerReference +// "G[\234\142T\228\212",PropResponseTopic "Ae\168\145\b",PropWillDelayInterval 30687,PropAssignedClientIdentifier +// "o\NUL\156(topic.data), 1); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 25675); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\187Ue\150\168f\243G", _pubPktID = -// 0, _pubBody = "Y\133", _pubProps = [PropSessionExpiryInterval 5902,PropResponseInformation -// "\248\175\DC1n\150h\n#\US\SI\225\&1\t\139\161\215\254\240\177O@",PropReasonString -// "|\231\193\196\&3e\197",PropReasonString "7\218\ENQ\242\n`\221\140\158\184\235"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\185\246\SOH*\248(\178k\\\215\174", +// _pubPktID = 11115, _pubBody = ".\DC1\fEQhj\183\224@\215\"\231B\243L\206 \210\231\178", _pubProps = +// [PropTopicAliasMaximum 12234,PropServerKeepAlive 26536,PropWildcardSubscriptionAvailable +// 235,PropWildcardSubscriptionAvailable 3,PropSubscriptionIdentifier 21]} TEST(Publish5QCTest, Encode13) { - uint8_t pkt[] = {0x38, 0x42, 0x0, 0x8, 0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47, 0x35, 0x11, - 0x0, 0x0, 0x17, 0xe, 0x1a, 0x0, 0x15, 0xf8, 0xaf, 0x11, 0x6e, 0x96, 0x68, 0xa, - 0x23, 0x1f, 0xf, 0xe1, 0x31, 0x9, 0x8b, 0xa1, 0xd7, 0xfe, 0xf0, 0xb1, 0x4f, 0x40, - 0x1f, 0x0, 0x7, 0x7c, 0xe7, 0xc1, 0xc4, 0x33, 0x65, 0xc5, 0x1f, 0x0, 0xb, 0x37, - 0xda, 0x5, 0xf2, 0xa, 0x60, 0xdd, 0x8c, 0x9e, 0xb8, 0xeb, 0x59, 0x85}; - uint8_t topic_bytes[] = {0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x31, 0x0, 0xb, 0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, + 0xd7, 0xae, 0x2b, 0x6b, 0xc, 0x22, 0x2f, 0xca, 0x13, 0x67, 0xa8, 0x28, 0xeb, + 0x28, 0x3, 0xb, 0x15, 0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, + 0x40, 0xd7, 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; + uint8_t topic_bytes[] = {0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, 0xd7, 0xae}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x59, 0x85}; + uint8_t msg_bytes[] = {0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, 0x40, 0xd7, + 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; - - uint8_t bytesprops0[] = {0xf8, 0xaf, 0x11, 0x6e, 0x96, 0x68, 0xa, 0x23, 0x1f, 0xf, 0xe1, - 0x31, 0x9, 0x8b, 0xa1, 0xd7, 0xfe, 0xf0, 0xb1, 0x4f, 0x40}; - uint8_t bytesprops1[] = {0x7c, 0xe7, 0xc1, 0xc4, 0x33, 0x65, 0xc5}; - uint8_t bytesprops2[] = {0x37, 0xda, 0x5, 0xf2, 0xa, 0x60, 0xdd, 0x8c, 0x9e, 0xb8, 0xeb}; + msg.payload_len = 21; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5902}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12234}}, {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26536}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 235}}, {.prop = (lwmqtt_prop_t)40, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 11115, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\187Ue\150\168f\243G", _pubPktID = -// 0, _pubBody = "Y\133", _pubProps = [PropSessionExpiryInterval 5902,PropResponseInformation -// "\248\175\DC1n\150h\n#\US\SI\225\&1\t\139\161\215\254\240\177O@",PropReasonString -// "|\231\193\196\&3e\197",PropReasonString "7\218\ENQ\242\n`\221\140\158\184\235"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\185\246\SOH*\248(\178k\\\215\174", +// _pubPktID = 11115, _pubBody = ".\DC1\fEQhj\183\224@\215\"\231B\243L\206 \210\231\178", _pubProps = +// [PropTopicAliasMaximum 12234,PropServerKeepAlive 26536,PropWildcardSubscriptionAvailable +// 235,PropWildcardSubscriptionAvailable 3,PropSubscriptionIdentifier 21]} TEST(Publish5QCTest, Decode13) { - uint8_t pkt[] = {0x38, 0x42, 0x0, 0x8, 0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47, 0x35, 0x11, - 0x0, 0x0, 0x17, 0xe, 0x1a, 0x0, 0x15, 0xf8, 0xaf, 0x11, 0x6e, 0x96, 0x68, 0xa, - 0x23, 0x1f, 0xf, 0xe1, 0x31, 0x9, 0x8b, 0xa1, 0xd7, 0xfe, 0xf0, 0xb1, 0x4f, 0x40, - 0x1f, 0x0, 0x7, 0x7c, 0xe7, 0xc1, 0xc4, 0x33, 0x65, 0xc5, 0x1f, 0x0, 0xb, 0x37, - 0xda, 0x5, 0xf2, 0xa, 0x60, 0xdd, 0x8c, 0x9e, 0xb8, 0xeb, 0x59, 0x85}; + uint8_t pkt[] = {0x32, 0x31, 0x0, 0xb, 0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, + 0xd7, 0xae, 0x2b, 0x6b, 0xc, 0x22, 0x2f, 0xca, 0x13, 0x67, 0xa8, 0x28, 0xeb, + 0x28, 0x3, 0xb, 0x15, 0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, + 0x40, 0xd7, 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3088,143 +3219,122 @@ TEST(Publish5QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xbb, 0x55, 0x65, 0x96, 0xa8, 0x66, 0xf3, 0x47}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x59, 0x85}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + uint8_t exp_topic_bytes[] = {0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, 0xd7, 0xae}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, 0x40, 0xd7, + 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 11115); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\165\&4\a\246}\148\174\&8\186i\137\223\STX*Sv", _pubPktID = 0, _pubBody = "\243\233\SOH\134\243=c\212", _pubProps = -// [PropResponseInformation "\FSD'\182\202\140M\222[\r\156",PropCorrelationData -// "\CAN\164\185\bs\183\FS\163\b\\\ETB\255\156\164\193\SO\181\ESC\179\138\207rk\233\178Pb",PropUserProperty -// "\200\250\152\250\\\211\&2" "D\157HMnegk\131Q1F\EOTg\130\254\219\164\229",PropServerReference -// "9\133\188\151E\b\US\DEL8<8\154+\151>\209Q\DC4\185M\221\SYN\245\135M\239\238",PropResponseTopic -// "",PropResponseInformation "\142(\152<<\221\SI\GS\199",PropMaximumPacketSize 17129,PropResponseInformation -// "C\166'\167\137\221\199\226r\231\195\237\255`1\176\STX",PropSubscriptionIdentifierAvailable 198,PropServerReference -// "\177\139r\DLE\141\r\216\163l\196",PropMaximumPacketSize 27506,PropMessageExpiryInterval 15713,PropCorrelationData -// "h\184\199>SUY\163\163\244\201\152\f9\RS\151n\250O\218\182 \216\197c\226Nt",PropRequestResponseInformation -// 142,PropMessageExpiryInterval 21146,PropMessageExpiryInterval 2479,PropReceiveMaximum 14556,PropAuthenticationMethod -// "\SI\237\130%\ENQTo\141!^\FS\171+5&e\203l\CAN\137-,,",PropSessionExpiryInterval 8323,PropRequestResponseInformation -// 141,PropWillDelayInterval 32675]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\186\171$\215\213", _pubPktID = +// 24590, _pubBody = "En.&\166\184\215\153", _pubProps = [PropSubscriptionIdentifier 22,PropReceiveMaximum +// 18265,PropContentType "\139]D_a&\176\214\131\207\205\219\SUBf\a=8\213\134\227",PropTopicAlias 25478,PropResponseTopic +// "\DEL+\SUB \185\244\146K\147J\168s\\\220\142\&7@-i\161\160\151.\148;J",PropReceiveMaximum 22318,PropTopicAliasMaximum +// 20907,PropPayloadFormatIndicator 158,PropTopicAlias 25235,PropSharedSubscriptionAvailable 149,PropReasonString +// "+E\197\223\235\RS\234e,S\NUL\247U,J\240yR",PropUserProperty +// "4-\152'\221\247\253?&\a?\r\224\NAK\222\254\137\NUL\ETX\216`h\EOT" +// "\175\&6\240\&2\240,\186\137\204?\133\201\255\169\219\GS2VM\ETB\204%\160\150b\180",PropAssignedClientIdentifier +// "\223\135\244\158\174\162F\232\205\CANE\199\ACK\SUB\STXF\216\235=#)&\182\221",PropMessageExpiryInterval +// 18609,PropReasonString "F\EOT\ACK\209WCS\EOT\223\171\232\158\254\&5\178\184\209\CAN\165\251G\226Y"]} TEST(Publish5QCTest, Encode14) { uint8_t pkt[] = { - 0x30, 0x9a, 0x2, 0x0, 0x10, 0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, 0xba, 0x69, 0x89, 0xdf, 0x2, 0x2a, - 0x53, 0x76, 0xfe, 0x1, 0x1a, 0x0, 0xb, 0x1c, 0x44, 0x27, 0xb6, 0xca, 0x8c, 0x4d, 0xde, 0x5b, 0xd, 0x9c, 0x9, - 0x0, 0x1b, 0x18, 0xa4, 0xb9, 0x8, 0x73, 0xb7, 0x1c, 0xa3, 0x8, 0x5c, 0x17, 0xff, 0x9c, 0xa4, 0xc1, 0xe, 0xb5, - 0x1b, 0xb3, 0x8a, 0xcf, 0x72, 0x6b, 0xe9, 0xb2, 0x50, 0x62, 0x26, 0x0, 0x7, 0xc8, 0xfa, 0x98, 0xfa, 0x5c, 0xd3, - 0x32, 0x0, 0x13, 0x44, 0x9d, 0x48, 0x4d, 0x6e, 0x65, 0x67, 0x6b, 0x83, 0x51, 0x31, 0x46, 0x4, 0x67, 0x82, 0xfe, - 0xdb, 0xa4, 0xe5, 0x1c, 0x0, 0x1b, 0x39, 0x85, 0xbc, 0x97, 0x45, 0x8, 0x1f, 0x7f, 0x38, 0x3c, 0x38, 0x9a, 0x2b, - 0x97, 0x3e, 0xd1, 0x51, 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_string_t topic = {16, (char*)&topic_bytes}; + 0x34, 0xe1, 0x1, 0x0, 0x5, 0xba, 0xab, 0x24, 0xd7, 0xd5, 0x60, 0xe, 0xce, 0x1, 0xb, 0x16, 0x21, 0x47, 0x59, + 0x3, 0x0, 0x14, 0x8b, 0x5d, 0x44, 0x5f, 0x61, 0x26, 0xb0, 0xd6, 0x83, 0xcf, 0xcd, 0xdb, 0x1a, 0x66, 0x7, 0x3d, + 0x38, 0xd5, 0x86, 0xe3, 0x23, 0x63, 0x86, 0x8, 0x0, 0x1a, 0x7f, 0x2b, 0x1a, 0x20, 0xb9, 0xf4, 0x92, 0x4b, 0x93, + 0x4a, 0xa8, 0x73, 0x5c, 0xdc, 0x8e, 0x37, 0x40, 0x2d, 0x69, 0xa1, 0xa0, 0x97, 0x2e, 0x94, 0x3b, 0x4a, 0x21, 0x57, + 0x2e, 0x22, 0x51, 0xab, 0x1, 0x9e, 0x23, 0x62, 0x93, 0x2a, 0x95, 0x1f, 0x0, 0x12, 0x2b, 0x45, 0xc5, 0xdf, 0xeb, + 0x1e, 0xea, 0x65, 0x2c, 0x53, 0x0, 0xf7, 0x55, 0x2c, 0x4a, 0xf0, 0x79, 0x52, 0x26, 0x0, 0x17, 0x34, 0x2d, 0x98, + 0x27, 0xdd, 0xf7, 0xfd, 0x3f, 0x26, 0x7, 0x3f, 0xd, 0xe0, 0x15, 0xde, 0xfe, 0x89, 0x0, 0x3, 0xd8, 0x60, 0x68, + 0x4, 0x0, 0x1a, 0xaf, 0x36, 0xf0, 0x32, 0xf0, 0x2c, 0xba, 0x89, 0xcc, 0x3f, 0x85, 0xc9, 0xff, 0xa9, 0xdb, 0x1d, + 0x32, 0x56, 0x4d, 0x17, 0xcc, 0x25, 0xa0, 0x96, 0x62, 0xb4, 0x12, 0x0, 0x18, 0xdf, 0x87, 0xf4, 0x9e, 0xae, 0xa2, + 0x46, 0xe8, 0xcd, 0x18, 0x45, 0xc7, 0x6, 0x1a, 0x2, 0x46, 0xd8, 0xeb, 0x3d, 0x23, 0x29, 0x26, 0xb6, 0xdd, 0x2, + 0x0, 0x0, 0x48, 0xb1, 0x1f, 0x0, 0x17, 0x46, 0x4, 0x6, 0xd1, 0x57, 0x43, 0x53, 0x4, 0xdf, 0xab, 0xe8, 0x9e, + 0xfe, 0x35, 0xb2, 0xb8, 0xd1, 0x18, 0xa5, 0xfb, 0x47, 0xe2, 0x59, 0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; + uint8_t topic_bytes[] = {0xba, 0xab, 0x24, 0xd7, 0xd5}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + uint8_t msg_bytes[] = {0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 8; - uint8_t bytesprops0[] = {0x1c, 0x44, 0x27, 0xb6, 0xca, 0x8c, 0x4d, 0xde, 0x5b, 0xd, 0x9c}; - uint8_t bytesprops1[] = {0x18, 0xa4, 0xb9, 0x8, 0x73, 0xb7, 0x1c, 0xa3, 0x8, 0x5c, 0x17, 0xff, 0x9c, 0xa4, - 0xc1, 0xe, 0xb5, 0x1b, 0xb3, 0x8a, 0xcf, 0x72, 0x6b, 0xe9, 0xb2, 0x50, 0x62}; - uint8_t bytesprops3[] = {0x44, 0x9d, 0x48, 0x4d, 0x6e, 0x65, 0x67, 0x6b, 0x83, 0x51, - 0x31, 0x46, 0x4, 0x67, 0x82, 0xfe, 0xdb, 0xa4, 0xe5}; - uint8_t bytesprops2[] = {0xc8, 0xfa, 0x98, 0xfa, 0x5c, 0xd3, 0x32}; - uint8_t bytesprops4[] = {0x39, 0x85, 0xbc, 0x97, 0x45, 0x8, 0x1f, 0x7f, 0x38, 0x3c, 0x38, 0x9a, 0x2b, 0x97, - 0x3e, 0xd1, 0x51, 0x14, 0xb9, 0x4d, 0xdd, 0x16, 0xf5, 0x87, 0x4d, 0xef, 0xee}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0x8e, 0x28, 0x98, 0x3c, 0x3c, 0xdd, 0xf, 0x1d, 0xc7}; - uint8_t bytesprops7[] = {0x43, 0xa6, 0x27, 0xa7, 0x89, 0xdd, 0xc7, 0xe2, 0x72, - 0xe7, 0xc3, 0xed, 0xff, 0x60, 0x31, 0xb0, 0x2}; - uint8_t bytesprops8[] = {0xb1, 0x8b, 0x72, 0x10, 0x8d, 0xd, 0xd8, 0xa3, 0x6c, 0xc4}; - uint8_t bytesprops9[] = {0x68, 0xb8, 0xc7, 0x3e, 0x53, 0x55, 0x59, 0xa3, 0xa3, 0xf4, 0xc9, 0x98, 0xc, 0x39, - 0x1e, 0x97, 0x6e, 0xfa, 0x4f, 0xda, 0xb6, 0x20, 0xd8, 0xc5, 0x63, 0xe2, 0x4e, 0x74}; - uint8_t bytesprops10[] = {0xf, 0xed, 0x82, 0x25, 0x5, 0x54, 0x6f, 0x8d, 0x21, 0x5e, 0x1c, 0xab, - 0x2b, 0x35, 0x26, 0x65, 0xcb, 0x6c, 0x18, 0x89, 0x2d, 0x2c, 0x2c}; + uint8_t bytesprops0[] = {0x8b, 0x5d, 0x44, 0x5f, 0x61, 0x26, 0xb0, 0xd6, 0x83, 0xcf, + 0xcd, 0xdb, 0x1a, 0x66, 0x7, 0x3d, 0x38, 0xd5, 0x86, 0xe3}; + uint8_t bytesprops1[] = {0x7f, 0x2b, 0x1a, 0x20, 0xb9, 0xf4, 0x92, 0x4b, 0x93, 0x4a, 0xa8, 0x73, 0x5c, + 0xdc, 0x8e, 0x37, 0x40, 0x2d, 0x69, 0xa1, 0xa0, 0x97, 0x2e, 0x94, 0x3b, 0x4a}; + uint8_t bytesprops2[] = {0x2b, 0x45, 0xc5, 0xdf, 0xeb, 0x1e, 0xea, 0x65, 0x2c, + 0x53, 0x0, 0xf7, 0x55, 0x2c, 0x4a, 0xf0, 0x79, 0x52}; + uint8_t bytesprops4[] = {0xaf, 0x36, 0xf0, 0x32, 0xf0, 0x2c, 0xba, 0x89, 0xcc, 0x3f, 0x85, 0xc9, 0xff, + 0xa9, 0xdb, 0x1d, 0x32, 0x56, 0x4d, 0x17, 0xcc, 0x25, 0xa0, 0x96, 0x62, 0xb4}; + uint8_t bytesprops3[] = {0x34, 0x2d, 0x98, 0x27, 0xdd, 0xf7, 0xfd, 0x3f, 0x26, 0x7, 0x3f, 0xd, + 0xe0, 0x15, 0xde, 0xfe, 0x89, 0x0, 0x3, 0xd8, 0x60, 0x68, 0x4}; + uint8_t bytesprops5[] = {0xdf, 0x87, 0xf4, 0x9e, 0xae, 0xa2, 0x46, 0xe8, 0xcd, 0x18, 0x45, 0xc7, + 0x6, 0x1a, 0x2, 0x46, 0xd8, 0xeb, 0x3d, 0x23, 0x29, 0x26, 0xb6, 0xdd}; + uint8_t bytesprops6[] = {0x46, 0x4, 0x6, 0xd1, 0x57, 0x43, 0x53, 0x4, 0xdf, 0xab, 0xe8, 0x9e, + 0xfe, 0x35, 0xb2, 0xb8, 0xd1, 0x18, 0xa5, 0xfb, 0x47, 0xe2, 0x59}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops2}, .v = {19, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17129}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27506}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15713}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21146}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2479}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14556}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8323}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32675}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18265}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25478}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22318}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20907}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25235}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops3}, .v = {26, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18609}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24590, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\165\&4\a\246}\148\174\&8\186i\137\223\STX*Sv", _pubPktID = 0, _pubBody = "\243\233\SOH\134\243=c\212", _pubProps = -// [PropResponseInformation "\FSD'\182\202\140M\222[\r\156",PropCorrelationData -// "\CAN\164\185\bs\183\FS\163\b\\\ETB\255\156\164\193\SO\181\ESC\179\138\207rk\233\178Pb",PropUserProperty -// "\200\250\152\250\\\211\&2" "D\157HMnegk\131Q1F\EOTg\130\254\219\164\229",PropServerReference -// "9\133\188\151E\b\US\DEL8<8\154+\151>\209Q\DC4\185M\221\SYN\245\135M\239\238",PropResponseTopic -// "",PropResponseInformation "\142(\152<<\221\SI\GS\199",PropMaximumPacketSize 17129,PropResponseInformation -// "C\166'\167\137\221\199\226r\231\195\237\255`1\176\STX",PropSubscriptionIdentifierAvailable 198,PropServerReference -// "\177\139r\DLE\141\r\216\163l\196",PropMaximumPacketSize 27506,PropMessageExpiryInterval 15713,PropCorrelationData -// "h\184\199>SUY\163\163\244\201\152\f9\RS\151n\250O\218\182 \216\197c\226Nt",PropRequestResponseInformation -// 142,PropMessageExpiryInterval 21146,PropMessageExpiryInterval 2479,PropReceiveMaximum 14556,PropAuthenticationMethod -// "\SI\237\130%\ENQTo\141!^\FS\171+5&e\203l\CAN\137-,,",PropSessionExpiryInterval 8323,PropRequestResponseInformation -// 141,PropWillDelayInterval 32675]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\186\171$\215\213", _pubPktID = +// 24590, _pubBody = "En.&\166\184\215\153", _pubProps = [PropSubscriptionIdentifier 22,PropReceiveMaximum +// 18265,PropContentType "\139]D_a&\176\214\131\207\205\219\SUBf\a=8\213\134\227",PropTopicAlias 25478,PropResponseTopic +// "\DEL+\SUB \185\244\146K\147J\168s\\\220\142\&7@-i\161\160\151.\148;J",PropReceiveMaximum 22318,PropTopicAliasMaximum +// 20907,PropPayloadFormatIndicator 158,PropTopicAlias 25235,PropSharedSubscriptionAvailable 149,PropReasonString +// "+E\197\223\235\RS\234e,S\NUL\247U,J\240yR",PropUserProperty +// "4-\152'\221\247\253?&\a?\r\224\NAK\222\254\137\NUL\ETX\216`h\EOT" +// "\175\&6\240\&2\240,\186\137\204?\133\201\255\169\219\GS2VM\ETB\204%\160\150b\180",PropAssignedClientIdentifier +// "\223\135\244\158\174\162F\232\205\CANE\199\ACK\SUB\STXF\216\235=#)&\182\221",PropMessageExpiryInterval +// 18609,PropReasonString "F\EOT\ACK\209WCS\EOT\223\171\232\158\254\&5\178\184\209\CAN\165\251G\226Y"]} TEST(Publish5QCTest, Decode14) { uint8_t pkt[] = { - 0x30, 0x9a, 0x2, 0x0, 0x10, 0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, 0xba, 0x69, 0x89, 0xdf, 0x2, 0x2a, - 0x53, 0x76, 0xfe, 0x1, 0x1a, 0x0, 0xb, 0x1c, 0x44, 0x27, 0xb6, 0xca, 0x8c, 0x4d, 0xde, 0x5b, 0xd, 0x9c, 0x9, - 0x0, 0x1b, 0x18, 0xa4, 0xb9, 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8, 0x60, 0x68, + 0x4, 0x0, 0x1a, 0xaf, 0x36, 0xf0, 0x32, 0xf0, 0x2c, 0xba, 0x89, 0xcc, 0x3f, 0x85, 0xc9, 0xff, 0xa9, 0xdb, 0x1d, + 0x32, 0x56, 0x4d, 0x17, 0xcc, 0x25, 0xa0, 0x96, 0x62, 0xb4, 0x12, 0x0, 0x18, 0xdf, 0x87, 0xf4, 0x9e, 0xae, 0xa2, + 0x46, 0xe8, 0xcd, 0x18, 0x45, 0xc7, 0x6, 0x1a, 0x2, 0x46, 0xd8, 0xeb, 0x3d, 0x23, 0x29, 0x26, 0xb6, 0xdd, 0x2, + 0x0, 0x0, 0x48, 0xb1, 0x1f, 0x0, 0x17, 0x46, 0x4, 0x6, 0xd1, 0x57, 0x43, 0x53, 0x4, 0xdf, 0xab, 0xe8, 0x9e, + 0xfe, 0x35, 0xb2, 0xb8, 0xd1, 0x18, 0xa5, 0xfb, 0x47, 0xe2, 0x59, 0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3232,51 +3342,115 @@ TEST(Publish5QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa5, 0x34, 0x7, 0xf6, 0x7d, 0x94, 0xae, 0x38, - 0xba, 0x69, 0x89, 0xdf, 0x2, 0x2a, 0x53, 0x76}; - lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf3, 0xe9, 0x1, 0x86, 0xf3, 0x3d, 0x63, 0xd4}; + uint8_t exp_topic_bytes[] = {0xba, 0xab, 0x24, 0xd7, 0xd5}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(packet_id, 24590); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); EXPECT_EQ(msg.payload_len, 8); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 10766, _pubBody = -// "\178", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\197R\255Y+\ACK", _pubPktID = 17354, +// _pubBody = "_\191\168\153\207\229\204<\169\234j\153A\153/^I\217,\159/\161\222\252?6", _pubProps = +// [PropRequestResponseInformation 184,PropSessionExpiryInterval 21029,PropMaximumQoS +// 50,PropWildcardSubscriptionAvailable 238,PropSubscriptionIdentifier 14,PropTopicAlias +// 19933,PropWildcardSubscriptionAvailable 68,PropAuthenticationData +// "\232\214\&2\254\DLE\242",PropAssignedClientIdentifier "\173\233",PropSharedSubscriptionAvailable +// 228,PropReceiveMaximum 25696,PropMessageExpiryInterval 21838,PropSubscriptionIdentifierAvailable 255,PropUserProperty +// "L\246\166@\169\SO8T\SO\233" ",\141c\RSw",PropTopicAliasMaximum 19135,PropWillDelayInterval +// 27308,PropMaximumPacketSize 28029,PropRequestResponseInformation 109,PropSubscriptionIdentifier +// 12,PropRetainAvailable 74,PropRetainAvailable 73,PropSessionExpiryInterval 27517,PropResponseInformation +// "\194\161=H\b}"]} TEST(Publish5QCTest, Encode15) { - uint8_t pkt[] = {0x3b, 0x6, 0x0, 0x0, 0x2a, 0xe, 0x0, 0xb2}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x88, 0x1, 0x0, 0x6, 0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6, 0x43, 0xca, 0x63, 0x19, 0xb8, + 0x11, 0x0, 0x0, 0x52, 0x25, 0x24, 0x32, 0x28, 0xee, 0xb, 0xe, 0x23, 0x4d, 0xdd, 0x28, 0x44, + 0x16, 0x0, 0x6, 0xe8, 0xd6, 0x32, 0xfe, 0x10, 0xf2, 0x12, 0x0, 0x2, 0xad, 0xe9, 0x2a, 0xe4, + 0x21, 0x64, 0x60, 0x2, 0x0, 0x0, 0x55, 0x4e, 0x29, 0xff, 0x26, 0x0, 0xa, 0x4c, 0xf6, 0xa6, + 0x40, 0xa9, 0xe, 0x38, 0x54, 0xe, 0xe9, 0x0, 0x5, 0x2c, 0x8d, 0x63, 0x1e, 0x77, 0x22, 0x4a, + 0xbf, 0x18, 0x0, 0x0, 0x6a, 0xac, 0x27, 0x0, 0x0, 0x6d, 0x7d, 0x19, 0x6d, 0xb, 0xc, 0x25, + 0x4a, 0x25, 0x49, 0x11, 0x0, 0x0, 0x6b, 0x7d, 0x1a, 0x0, 0x6, 0xc2, 0xa1, 0x3d, 0x48, 0x8, + 0x7d, 0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, 0x99, 0x2f, + 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; + uint8_t topic_bytes[] = {0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xb2}; + uint8_t msg_bytes[] = {0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, + 0x99, 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 26; - lwmqtt_property_t propslist[] = {}; + uint8_t bytesprops0[] = {0xe8, 0xd6, 0x32, 0xfe, 0x10, 0xf2}; + uint8_t bytesprops1[] = {0xad, 0xe9}; + uint8_t bytesprops3[] = {0x2c, 0x8d, 0x63, 0x1e, 0x77}; + uint8_t bytesprops2[] = {0x4c, 0xf6, 0xa6, 0x40, 0xa9, 0xe, 0x38, 0x54, 0xe, 0xe9}; + uint8_t bytesprops4[] = {0xc2, 0xa1, 0x3d, 0x48, 0x8, 0x7d}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21029}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19933}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25696}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21838}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {5, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19135}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27308}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28029}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27517}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops4}}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10766, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 17354, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 10766, _pubBody = -// "\178", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\197R\255Y+\ACK", _pubPktID = 17354, +// _pubBody = "_\191\168\153\207\229\204<\169\234j\153A\153/^I\217,\159/\161\222\252?6", _pubProps = +// [PropRequestResponseInformation 184,PropSessionExpiryInterval 21029,PropMaximumQoS +// 50,PropWildcardSubscriptionAvailable 238,PropSubscriptionIdentifier 14,PropTopicAlias +// 19933,PropWildcardSubscriptionAvailable 68,PropAuthenticationData +// "\232\214\&2\254\DLE\242",PropAssignedClientIdentifier "\173\233",PropSharedSubscriptionAvailable +// 228,PropReceiveMaximum 25696,PropMessageExpiryInterval 21838,PropSubscriptionIdentifierAvailable 255,PropUserProperty +// "L\246\166@\169\SO8T\SO\233" ",\141c\RSw",PropTopicAliasMaximum 19135,PropWillDelayInterval +// 27308,PropMaximumPacketSize 28029,PropRequestResponseInformation 109,PropSubscriptionIdentifier +// 12,PropRetainAvailable 74,PropRetainAvailable 73,PropSessionExpiryInterval 27517,PropResponseInformation +// "\194\161=H\b}"]} TEST(Publish5QCTest, Decode15) { - uint8_t pkt[] = {0x3b, 0x6, 0x0, 0x0, 0x2a, 0xe, 0x0, 0xb2}; + uint8_t pkt[] = {0x3b, 0x88, 0x1, 0x0, 0x6, 0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6, 0x43, 0xca, 0x63, 0x19, 0xb8, + 0x11, 0x0, 0x0, 0x52, 0x25, 0x24, 0x32, 0x28, 0xee, 0xb, 0xe, 0x23, 0x4d, 0xdd, 0x28, 0x44, + 0x16, 0x0, 0x6, 0xe8, 0xd6, 0x32, 0xfe, 0x10, 0xf2, 0x12, 0x0, 0x2, 0xad, 0xe9, 0x2a, 0xe4, + 0x21, 0x64, 0x60, 0x2, 0x0, 0x0, 0x55, 0x4e, 0x29, 0xff, 0x26, 0x0, 0xa, 0x4c, 0xf6, 0xa6, + 0x40, 0xa9, 0xe, 0x38, 0x54, 0xe, 0xe9, 0x0, 0x5, 0x2c, 0x8d, 0x63, 0x1e, 0x77, 0x22, 0x4a, + 0xbf, 0x18, 0x0, 0x0, 0x6a, 0xac, 0x27, 0x0, 0x0, 0x6d, 0x7d, 0x19, 0x6d, 0xb, 0xc, 0x25, + 0x4a, 0x25, 0x49, 0x11, 0x0, 0x0, 0x6b, 0x7d, 0x1a, 0x0, 0x6, 0xc2, 0xa1, 0x3d, 0x48, 0x8, + 0x7d, 0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, 0x99, 0x2f, + 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3284,102 +3458,60 @@ TEST(Publish5QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb2}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, + 0x99, 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 10766); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(packet_id, 17354); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\138\GSJ\143\233", _pubPktID = 6943, -// _pubBody = "\137\139\192l\219\138Z\225\185\164}d\US[\179", _pubProps = [PropAuthenticationMethod -// "\140+fdg\201T\248\&2\167\255\&3\EMm\193\&0\EOT\187\147\215\EM",PropServerKeepAlive 19473,PropServerKeepAlive -// 30363,PropAssignedClientIdentifier "\193~?\213\&2M\211\160\235\255I\163VA\190\223\145\138",PropWillDelayInterval -// 5830,PropReasonString "\188\&0W\192\156\144\147\STX\203\254`\143qK/\247",PropSessionExpiryInterval -// 5743,PropResponseTopic "\213#*",PropUserProperty -// "\183\152L\208\228\254v\a\181I\137ew\161<`\136\228\US\185TV\147A\251\254" "\149x\ESC\239\142\128\v\209\EOT6 -// HP\205\139a\nD\165"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\181h\206\206#\148<\227\196\202?\ENQ\255\RSp\196\162\184\171\224", _pubPktID = 9053, _pubBody = +// "W\232(5\208_\210\199B\249E\178\157\128", _pubProps = [PropReceiveMaximum 12053]} TEST(Publish5QCTest, Encode16) { - uint8_t pkt[] = {0x3c, 0xa2, 0x1, 0x0, 0x5, 0x8a, 0x1d, 0x4a, 0x8f, 0xe9, 0x1b, 0x1f, 0x88, 0x1, 0x15, 0x0, 0x15, - 0x8c, 0x2b, 0x66, 0x64, 0x67, 0xc9, 0x54, 0xf8, 0x32, 0xa7, 0xff, 0x33, 0x19, 0x6d, 0xc1, 0x30, 0x4, - 0xbb, 0x93, 0xd7, 0x19, 0x13, 0x4c, 0x11, 0x13, 0x76, 0x9b, 0x12, 0x0, 0x12, 0xc1, 0x7e, 0x3f, 0xd5, - 0x32, 0x4d, 0xd3, 0xa0, 0xeb, 0xff, 0x49, 0xa3, 0x56, 0x41, 0xbe, 0xdf, 0x91, 0x8a, 0x18, 0x0, 0x0, - 0x16, 0xc6, 0x1f, 0x0, 0x10, 0xbc, 0x30, 0x57, 0xc0, 0x9c, 0x90, 0x93, 0x2, 0xcb, 0xfe, 0x60, 0x8f, - 0x71, 0x4b, 0x2f, 0xf7, 0x11, 0x0, 0x0, 0x16, 0x6f, 0x8, 0x0, 0x3, 0xd5, 0x23, 0x2a, 0x26, 0x0, - 0x1a, 0xb7, 0x98, 0x4c, 0xd0, 0xe4, 0xfe, 0x76, 0x7, 0xb5, 0x49, 0x89, 0x65, 0x77, 0xa1, 0x3c, 0x60, - 0x88, 0xe4, 0x1f, 0xb9, 0x54, 0x56, 0x93, 0x41, 0xfb, 0xfe, 0x0, 0x13, 0x95, 0x78, 0x1b, 0xef, 0x8e, - 0x80, 0xb, 0xd1, 0x4, 0x36, 0x20, 0x48, 0x50, 0xcd, 0x8b, 0x61, 0xa, 0x44, 0xa5, 0x89, 0x8b, 0xc0, - 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; - uint8_t topic_bytes[] = {0x8a, 0x1d, 0x4a, 0x8f, 0xe9}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x2a, 0x0, 0x14, 0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, 0x3f, + 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0, 0x23, 0x5d, 0x3, 0x21, 0x2f, 0x15, + 0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; + uint8_t topic_bytes[] = {0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, + 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x89, 0x8b, 0xc0, 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; + uint8_t msg_bytes[] = {0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0x8c, 0x2b, 0x66, 0x64, 0x67, 0xc9, 0x54, 0xf8, 0x32, 0xa7, 0xff, - 0x33, 0x19, 0x6d, 0xc1, 0x30, 0x4, 0xbb, 0x93, 0xd7, 0x19}; - uint8_t bytesprops1[] = {0xc1, 0x7e, 0x3f, 0xd5, 0x32, 0x4d, 0xd3, 0xa0, 0xeb, - 0xff, 0x49, 0xa3, 0x56, 0x41, 0xbe, 0xdf, 0x91, 0x8a}; - uint8_t bytesprops2[] = {0xbc, 0x30, 0x57, 0xc0, 0x9c, 0x90, 0x93, 0x2, - 0xcb, 0xfe, 0x60, 0x8f, 0x71, 0x4b, 0x2f, 0xf7}; - uint8_t bytesprops3[] = {0xd5, 0x23, 0x2a}; - uint8_t bytesprops5[] = {0x95, 0x78, 0x1b, 0xef, 0x8e, 0x80, 0xb, 0xd1, 0x4, 0x36, - 0x20, 0x48, 0x50, 0xcd, 0x8b, 0x61, 0xa, 0x44, 0xa5}; - uint8_t bytesprops4[] = {0xb7, 0x98, 0x4c, 0xd0, 0xe4, 0xfe, 0x76, 0x7, 0xb5, 0x49, 0x89, 0x65, 0x77, - 0xa1, 0x3c, 0x60, 0x88, 0xe4, 0x1f, 0xb9, 0x54, 0x56, 0x93, 0x41, 0xfb, 0xfe}; + msg.payload_len = 14; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19473}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30363}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5830}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5743}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops4}, .v = {19, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12053}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6943, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 9053, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\138\GSJ\143\233", _pubPktID = 6943, -// _pubBody = "\137\139\192l\219\138Z\225\185\164}d\US[\179", _pubProps = [PropAuthenticationMethod -// "\140+fdg\201T\248\&2\167\255\&3\EMm\193\&0\EOT\187\147\215\EM",PropServerKeepAlive 19473,PropServerKeepAlive -// 30363,PropAssignedClientIdentifier "\193~?\213\&2M\211\160\235\255I\163VA\190\223\145\138",PropWillDelayInterval -// 5830,PropReasonString "\188\&0W\192\156\144\147\STX\203\254`\143qK/\247",PropSessionExpiryInterval -// 5743,PropResponseTopic "\213#*",PropUserProperty -// "\183\152L\208\228\254v\a\181I\137ew\161<`\136\228\US\185TV\147A\251\254" "\149x\ESC\239\142\128\v\209\EOT6 -// HP\205\139a\nD\165"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\181h\206\206#\148<\227\196\202?\ENQ\255\RSp\196\162\184\171\224", _pubPktID = 9053, _pubBody = +// "W\232(5\208_\210\199B\249E\178\157\128", _pubProps = [PropReceiveMaximum 12053]} TEST(Publish5QCTest, Decode16) { - uint8_t pkt[] = {0x3c, 0xa2, 0x1, 0x0, 0x5, 0x8a, 0x1d, 0x4a, 0x8f, 0xe9, 0x1b, 0x1f, 0x88, 0x1, 0x15, 0x0, 0x15, - 0x8c, 0x2b, 0x66, 0x64, 0x67, 0xc9, 0x54, 0xf8, 0x32, 0xa7, 0xff, 0x33, 0x19, 0x6d, 0xc1, 0x30, 0x4, - 0xbb, 0x93, 0xd7, 0x19, 0x13, 0x4c, 0x11, 0x13, 0x76, 0x9b, 0x12, 0x0, 0x12, 0xc1, 0x7e, 0x3f, 0xd5, - 0x32, 0x4d, 0xd3, 0xa0, 0xeb, 0xff, 0x49, 0xa3, 0x56, 0x41, 0xbe, 0xdf, 0x91, 0x8a, 0x18, 0x0, 0x0, - 0x16, 0xc6, 0x1f, 0x0, 0x10, 0xbc, 0x30, 0x57, 0xc0, 0x9c, 0x90, 0x93, 0x2, 0xcb, 0xfe, 0x60, 0x8f, - 0x71, 0x4b, 0x2f, 0xf7, 0x11, 0x0, 0x0, 0x16, 0x6f, 0x8, 0x0, 0x3, 0xd5, 0x23, 0x2a, 0x26, 0x0, - 0x1a, 0xb7, 0x98, 0x4c, 0xd0, 0xe4, 0xfe, 0x76, 0x7, 0xb5, 0x49, 0x89, 0x65, 0x77, 0xa1, 0x3c, 0x60, - 0x88, 0xe4, 0x1f, 0xb9, 0x54, 0x56, 0x93, 0x41, 0xfb, 0xfe, 0x0, 0x13, 0x95, 0x78, 0x1b, 0xef, 0x8e, - 0x80, 0xb, 0xd1, 0x4, 0x36, 0x20, 0x48, 0x50, 0xcd, 0x8b, 0x61, 0xa, 0x44, 0xa5, 0x89, 0x8b, 0xc0, - 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; + uint8_t pkt[] = {0x3c, 0x2a, 0x0, 0x14, 0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, 0x3f, + 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0, 0x23, 0x5d, 0x3, 0x21, 0x2f, 0x15, + 0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3387,111 +3519,64 @@ TEST(Publish5QCTest, Decode16) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8a, 0x1d, 0x4a, 0x8f, 0xe9}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x89, 0x8b, 0xc0, 0x6c, 0xdb, 0x8a, 0x5a, 0xe1, 0xb9, 0xa4, 0x7d, 0x64, 0x1f, 0x5b, 0xb3}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, + 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 6943); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 9053); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\225y\a\222\215\130\238h\b\159\152x\153\151\162\213\177\165X\184]\135\187\189 \214", _pubProps = -// [PropRequestResponseInformation 185,PropTopicAliasMaximum 14150,PropReasonString "\165,",PropAssignedClientIdentifier -// "\201\152\208!o\194:\DEL\185IC\SYN~\152NV\179\183\212\220a",PropTopicAliasMaximum 9681,PropServerReference -// "\138\&4@Q\n\225\185\166\153\164J\155H*\EOT\249\231\253\232\218\201\188",PropAuthenticationData -// "\184\EM\201\135<\189a}\146\DC2\135\245\f\US>\243C\253\197\134",PropPayloadFormatIndicator 248,PropServerKeepAlive -// 277,PropWillDelayInterval 13390,PropResponseTopic "V\b\193\\\236|\RS",PropResponseInformation -// "\177\216\175kf\FS\198\234\DEL\205:\STX\175\216Fq\242\DC20\152\253\142/",PropCorrelationData -// "\149\DC4\243\181\182:\ENQ\185\"d",PropMessageExpiryInterval 1713,PropAuthenticationData -// "\233\251",PropWildcardSubscriptionAvailable 169,PropTopicAliasMaximum 22382,PropReceiveMaximum -// 22362,PropServerKeepAlive 8489,PropMessageExpiryInterval 30880,PropRetainAvailable -// 14,PropWildcardSubscriptionAvailable 30,PropCorrelationData -// "@[i5\197\167\243C\253\197\134",PropPayloadFormatIndicator 248,PropServerKeepAlive -// 277,PropWillDelayInterval 13390,PropResponseTopic "V\b\193\\\236|\RS",PropResponseInformation -// "\177\216\175kf\FS\198\234\DEL\205:\STX\175\216Fq\242\DC20\152\253\142/",PropCorrelationData -// "\149\DC4\243\181\182:\ENQ\185\"d",PropMessageExpiryInterval 1713,PropAuthenticationData -// "\233\251",PropWildcardSubscriptionAvailable 169,PropTopicAliasMaximum 22382,PropReceiveMaximum -// 22362,PropServerKeepAlive 8489,PropMessageExpiryInterval 30880,PropRetainAvailable -// 14,PropWildcardSubscriptionAvailable 30,PropCorrelationData -// "@[i5\197\167(topic.data), 0); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "6\218tea\v\174S\163\234\130\GS\208\155\GS\DLE\ENQ\ESC\178\165 \153\DC2\155v,\165", _pubPktID = 27993, _pubBody = -// "\158 %1\177\201\t\236L", _pubProps = [PropServerKeepAlive 9153,PropMessageExpiryInterval 3494,PropContentType -// "P\141'\196\209\238\243\237\249?\SO\219x\162*\204",PropSharedSubscriptionAvailable 179,PropResponseInformation -// "\190\"(F\247\\\220y\190\242M\GS\223W\201\167\211p\222\DEL\170\237\f\219Z\163",PropRequestResponseInformation -// 202,PropMessageExpiryInterval 23742,PropResponseTopic -// "\255+^\145\153\SO\225\250!=#\217",PropRequestProblemInformation 8,PropSharedSubscriptionAvailable 68,PropTopicAlias -// 31091,PropContentType "\159\216\205\237\234\CAN\175_\190\248\189R\141\145\242]\174",PropServerKeepAlive -// 24225,PropContentType "\146b\132\218\243M\STX}\185>",PropAuthenticationMethod -// "\209^\237\138\b\196\153\128\168\175\184\198)\155\144\169[n\140\v\175\225",PropSubscriptionIdentifierAvailable -// 224,PropTopicAliasMaximum 20441,PropTopicAliasMaximum 31289]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "t\183\232G\148\143\148J\151\141\197\&0\196\244?(x\225\237\EM", _pubPktID = 0, _pubBody = +// "\ESC\231\EM\255\149&\\p\RS\173+\194\173\204\183u\131G\218", _pubProps = [PropRequestProblemInformation +// 130,PropResponseInformation +// "\174\168\140`\EOT\176O.\214\156J\176\132\232~\220B\208I\SOH\240\&9\183",PropRequestResponseInformation +// 222,PropPayloadFormatIndicator 65,PropRequestResponseInformation 53,PropResponseInformation +// "\245\153\155\DC4\146\172\231\195\176\169\ESC\138t3*\251\246\188",PropSessionExpiryInterval +// 2403,PropSessionExpiryInterval 7061,PropMaximumQoS 225,PropRequestResponseInformation 155,PropSubscriptionIdentifier +// 26,PropAssignedClientIdentifier "\SI",PropMaximumPacketSize 7091,PropContentType +// "'\CANh)\213|\160\a\DC3R\146v\218\&8}\EOTa6I\137\250;\233\228U\251x\252",PropMaximumPacketSize +// 1488,PropAuthenticationMethod "\CAN\221rv\175\198\190\n\DC2\178b\ENQ\208@Ky\246\225\156\227S"]} TEST(Publish5QCTest, Encode18) { - uint8_t pkt[] = {0x32, 0xc6, 0x1, 0x0, 0x1b, 0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, - 0xd0, 0x9b, 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5, 0x6d, 0x59, - 0x9c, 0x1, 0x13, 0x23, 0xc1, 0x2, 0x0, 0x0, 0xd, 0xa6, 0x3, 0x0, 0x10, 0x50, 0x8d, 0x27, 0xc4, - 0xd1, 0xee, 0xf3, 0xed, 0xf9, 0x3f, 0xe, 0xdb, 0x78, 0xa2, 0x2a, 0xcc, 0x2a, 0xb3, 0x1a, 0x0, 0x1a, - 0xbe, 0x22, 0x28, 0x46, 0xf7, 0x5c, 0xdc, 0x79, 0xbe, 0xf2, 0x4d, 0x1d, 0xdf, 0x57, 0xc9, 0xa7, 0xd3, - 0x70, 0xde, 0x7f, 0xaa, 0xed, 0xc, 0xdb, 0x5a, 0xa3, 0x19, 0xca, 0x2, 0x0, 0x0, 0x5c, 0xbe, 0x8, - 0x0, 0xc, 0xff, 0x2b, 0x5e, 0x91, 0x99, 0xe, 0xe1, 0xfa, 0x21, 0x3d, 0x23, 0xd9, 0x17, 0x8, 0x2a, - 0x44, 0x23, 0x79, 0x73, 0x3, 0x0, 0x11, 0x9f, 0xd8, 0xcd, 0xed, 0xea, 0x18, 0xaf, 0x5f, 0xbe, 0xf8, - 0xbd, 0x52, 0x8d, 0x91, 0xf2, 0x5d, 0xae, 0x13, 0x5e, 0xa1, 0x3, 0x0, 0xa, 0x92, 0x62, 0x84, 0xda, - 0xf3, 0x4d, 0x2, 0x7d, 0xb9, 0x3e, 0x15, 0x0, 0x16, 0xd1, 0x5e, 0xed, 0x8a, 0x8, 0xc4, 0x99, 0x80, - 0xa8, 0xaf, 0xb8, 0xc6, 0x29, 0x9b, 0x90, 0xa9, 0x5b, 0x6e, 0x8c, 0xb, 0xaf, 0xe1, 0x29, 0xe0, 0x22, - 0x4f, 0xd9, 0x22, 0x7a, 0x39, 0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; - uint8_t topic_bytes[] = {0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, 0xd0, 0x9b, - 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0xb7, 0x1, 0x0, 0x14, 0x74, 0xb7, 0xe8, 0x47, 0x94, 0x8f, 0x94, 0x4a, 0x97, 0x8d, 0xc5, 0x30, + 0xc4, 0xf4, 0x3f, 0x28, 0x78, 0xe1, 0xed, 0x19, 0x8c, 0x1, 0x17, 0x82, 0x1a, 0x0, 0x17, 0xae, 0xa8, + 0x8c, 0x60, 0x4, 0xb0, 0x4f, 0x2e, 0xd6, 0x9c, 0x4a, 0xb0, 0x84, 0xe8, 0x7e, 0xdc, 0x42, 0xd0, 0x49, + 0x1, 0xf0, 0x39, 0xb7, 0x19, 0xde, 0x1, 0x41, 0x19, 0x35, 0x1a, 0x0, 0x12, 0xf5, 0x99, 0x9b, 0x14, + 0x92, 0xac, 0xe7, 0xc3, 0xb0, 0xa9, 0x1b, 0x8a, 0x74, 0x33, 0x2a, 0xfb, 0xf6, 0xbc, 0x11, 0x0, 0x0, + 0x9, 0x63, 0x11, 0x0, 0x0, 0x1b, 0x95, 0x24, 0xe1, 0x19, 0x9b, 0xb, 0x1a, 0x12, 0x0, 0x1, 0xf, + 0x27, 0x0, 0x0, 0x1b, 0xb3, 0x3, 0x0, 0x1c, 0x27, 0x18, 0x68, 0x29, 0xd5, 0x7c, 0xa0, 0x7, 0x13, + 0x52, 0x92, 0x76, 0xda, 0x38, 0x7d, 0x4, 0x61, 0x36, 0x49, 0x89, 0xfa, 0x3b, 0xe9, 0xe4, 0x55, 0xfb, + 0x78, 0xfc, 0x27, 0x0, 0x0, 0x5, 0xd0, 0x15, 0x0, 0x15, 0x18, 0xdd, 0x72, 0x76, 0xaf, 0xc6, 0xbe, + 0xa, 0x12, 0xb2, 0x62, 0x5, 0xd0, 0x40, 0x4b, 0x79, 0xf6, 0xe1, 0x9c, 0xe3, 0x53, 0x1b, 0xe7, 0x19, + 0xff, 0x95, 0x26, 0x5c, 0x70, 0x1e, 0xad, 0x2b, 0xc2, 0xad, 0xcc, 0xb7, 0x75, 0x83, 0x47, 0xda}; + uint8_t topic_bytes[] = {0x74, 0xb7, 0xe8, 0x47, 0x94, 0x8f, 0x94, 0x4a, 0x97, 0x8d, + 0xc5, 0x30, 0xc4, 0xf4, 0x3f, 0x28, 0x78, 0xe1, 0xed, 0x19}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; + uint8_t msg_bytes[] = {0x1b, 0xe7, 0x19, 0xff, 0x95, 0x26, 0x5c, 0x70, 0x1e, 0xad, + 0x2b, 0xc2, 0xad, 0xcc, 0xb7, 0x75, 0x83, 0x47, 0xda}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; - - uint8_t bytesprops0[] = {0x50, 0x8d, 0x27, 0xc4, 0xd1, 0xee, 0xf3, 0xed, - 0xf9, 0x3f, 0xe, 0xdb, 0x78, 0xa2, 0x2a, 0xcc}; - uint8_t bytesprops1[] = {0xbe, 0x22, 0x28, 0x46, 0xf7, 0x5c, 0xdc, 0x79, 0xbe, 0xf2, 0x4d, 0x1d, 0xdf, - 0x57, 0xc9, 0xa7, 0xd3, 0x70, 0xde, 0x7f, 0xaa, 0xed, 0xc, 0xdb, 0x5a, 0xa3}; - uint8_t bytesprops2[] = {0xff, 0x2b, 0x5e, 0x91, 0x99, 0xe, 0xe1, 0xfa, 0x21, 0x3d, 0x23, 0xd9}; - uint8_t bytesprops3[] = {0x9f, 0xd8, 0xcd, 0xed, 0xea, 0x18, 0xaf, 0x5f, 0xbe, - 0xf8, 0xbd, 0x52, 0x8d, 0x91, 0xf2, 0x5d, 0xae}; - uint8_t bytesprops4[] = {0x92, 0x62, 0x84, 0xda, 0xf3, 0x4d, 0x2, 0x7d, 0xb9, 0x3e}; - uint8_t bytesprops5[] = {0xd1, 0x5e, 0xed, 0x8a, 0x8, 0xc4, 0x99, 0x80, 0xa8, 0xaf, 0xb8, - 0xc6, 0x29, 0x9b, 0x90, 0xa9, 0x5b, 0x6e, 0x8c, 0xb, 0xaf, 0xe1}; + msg.payload_len = 19; + + uint8_t bytesprops0[] = {0xae, 0xa8, 0x8c, 0x60, 0x4, 0xb0, 0x4f, 0x2e, 0xd6, 0x9c, 0x4a, 0xb0, + 0x84, 0xe8, 0x7e, 0xdc, 0x42, 0xd0, 0x49, 0x1, 0xf0, 0x39, 0xb7}; + uint8_t bytesprops1[] = {0xf5, 0x99, 0x9b, 0x14, 0x92, 0xac, 0xe7, 0xc3, 0xb0, + 0xa9, 0x1b, 0x8a, 0x74, 0x33, 0x2a, 0xfb, 0xf6, 0xbc}; + uint8_t bytesprops2[] = {0xf}; + uint8_t bytesprops3[] = {0x27, 0x18, 0x68, 0x29, 0xd5, 0x7c, 0xa0, 0x7, 0x13, 0x52, 0x92, 0x76, 0xda, 0x38, + 0x7d, 0x4, 0x61, 0x36, 0x49, 0x89, 0xfa, 0x3b, 0xe9, 0xe4, 0x55, 0xfb, 0x78, 0xfc}; + uint8_t bytesprops4[] = {0x18, 0xdd, 0x72, 0x76, 0xaf, 0xc6, 0xbe, 0xa, 0x12, 0xb2, 0x62, + 0x5, 0xd0, 0x40, 0x4b, 0x79, 0xf6, 0xe1, 0x9c, 0xe3, 0x53}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9153}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3494}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23742}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31091}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24225}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20441}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31289}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2403}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7061}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7091}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1488}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 27993, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "6\218tea\v\174S\163\234\130\GS\208\155\GS\DLE\ENQ\ESC\178\165 \153\DC2\155v,\165", _pubPktID = 27993, _pubBody = -// "\158 %1\177\201\t\236L", _pubProps = [PropServerKeepAlive 9153,PropMessageExpiryInterval 3494,PropContentType -// "P\141'\196\209\238\243\237\249?\SO\219x\162*\204",PropSharedSubscriptionAvailable 179,PropResponseInformation -// "\190\"(F\247\\\220y\190\242M\GS\223W\201\167\211p\222\DEL\170\237\f\219Z\163",PropRequestResponseInformation -// 202,PropMessageExpiryInterval 23742,PropResponseTopic -// "\255+^\145\153\SO\225\250!=#\217",PropRequestProblemInformation 8,PropSharedSubscriptionAvailable 68,PropTopicAlias -// 31091,PropContentType "\159\216\205\237\234\CAN\175_\190\248\189R\141\145\242]\174",PropServerKeepAlive -// 24225,PropContentType "\146b\132\218\243M\STX}\185>",PropAuthenticationMethod -// "\209^\237\138\b\196\153\128\168\175\184\198)\155\144\169[n\140\v\175\225",PropSubscriptionIdentifierAvailable -// 224,PropTopicAliasMaximum 20441,PropTopicAliasMaximum 31289]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "t\183\232G\148\143\148J\151\141\197\&0\196\244?(x\225\237\EM", _pubPktID = 0, _pubBody = +// "\ESC\231\EM\255\149&\\p\RS\173+\194\173\204\183u\131G\218", _pubProps = [PropRequestProblemInformation +// 130,PropResponseInformation +// "\174\168\140`\EOT\176O.\214\156J\176\132\232~\220B\208I\SOH\240\&9\183",PropRequestResponseInformation +// 222,PropPayloadFormatIndicator 65,PropRequestResponseInformation 53,PropResponseInformation +// "\245\153\155\DC4\146\172\231\195\176\169\ESC\138t3*\251\246\188",PropSessionExpiryInterval +// 2403,PropSessionExpiryInterval 7061,PropMaximumQoS 225,PropRequestResponseInformation 155,PropSubscriptionIdentifier +// 26,PropAssignedClientIdentifier "\SI",PropMaximumPacketSize 7091,PropContentType +// "'\CANh)\213|\160\a\DC3R\146v\218\&8}\EOTa6I\137\250;\233\228U\251x\252",PropMaximumPacketSize +// 1488,PropAuthenticationMethod "\CAN\221rv\175\198\190\n\DC2\178b\ENQ\208@Ky\246\225\156\227S"]} TEST(Publish5QCTest, Decode18) { - uint8_t pkt[] = {0x32, 0xc6, 0x1, 0x0, 0x1b, 0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, - 0xd0, 0x9b, 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5, 0x6d, 0x59, - 0x9c, 0x1, 0x13, 0x23, 0xc1, 0x2, 0x0, 0x0, 0xd, 0xa6, 0x3, 0x0, 0x10, 0x50, 0x8d, 0x27, 0xc4, - 0xd1, 0xee, 0xf3, 0xed, 0xf9, 0x3f, 0xe, 0xdb, 0x78, 0xa2, 0x2a, 0xcc, 0x2a, 0xb3, 0x1a, 0x0, 0x1a, - 0xbe, 0x22, 0x28, 0x46, 0xf7, 0x5c, 0xdc, 0x79, 0xbe, 0xf2, 0x4d, 0x1d, 0xdf, 0x57, 0xc9, 0xa7, 0xd3, - 0x70, 0xde, 0x7f, 0xaa, 0xed, 0xc, 0xdb, 0x5a, 0xa3, 0x19, 0xca, 0x2, 0x0, 0x0, 0x5c, 0xbe, 0x8, - 0x0, 0xc, 0xff, 0x2b, 0x5e, 0x91, 0x99, 0xe, 0xe1, 0xfa, 0x21, 0x3d, 0x23, 0xd9, 0x17, 0x8, 0x2a, - 0x44, 0x23, 0x79, 0x73, 0x3, 0x0, 0x11, 0x9f, 0xd8, 0xcd, 0xed, 0xea, 0x18, 0xaf, 0x5f, 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0xa0, 0x7, 0x13, + 0x52, 0x92, 0x76, 0xda, 0x38, 0x7d, 0x4, 0x61, 0x36, 0x49, 0x89, 0xfa, 0x3b, 0xe9, 0xe4, 0x55, 0xfb, + 0x78, 0xfc, 0x27, 0x0, 0x0, 0x5, 0xd0, 0x15, 0x0, 0x15, 0x18, 0xdd, 0x72, 0x76, 0xaf, 0xc6, 0xbe, + 0xa, 0x12, 0xb2, 0x62, 0x5, 0xd0, 0x40, 0x4b, 0x79, 0xf6, 0xe1, 0x9c, 0xe3, 0x53, 0x1b, 0xe7, 0x19, + 0xff, 0x95, 0x26, 0x5c, 0x70, 0x1e, 0xad, 0x2b, 0xc2, 0xad, 0xcc, 0xb7, 0x75, 0x83, 0x47, 0xda}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3659,89 +3723,157 @@ TEST(Publish5QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x36, 0xda, 0x74, 0x65, 0x61, 0xb, 0xae, 0x53, 0xa3, 0xea, 0x82, 0x1d, 0xd0, 0x9b, - 0x1d, 0x10, 0x5, 0x1b, 0xb2, 0xa5, 0x20, 0x99, 0x12, 0x9b, 0x76, 0x2c, 0xa5}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9e, 0x20, 0x25, 0x31, 0xb1, 0xc9, 0x9, 0xec, 0x4c}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x74, 0xb7, 0xe8, 0x47, 0x94, 0x8f, 0x94, 0x4a, 0x97, 0x8d, + 0xc5, 0x30, 0xc4, 0xf4, 0x3f, 0x28, 0x78, 0xe1, 0xed, 0x19}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1b, 0xe7, 0x19, 0xff, 0x95, 0x26, 0x5c, 0x70, 0x1e, 0xad, + 0x2b, 0xc2, 0xad, 0xcc, 0xb7, 0x75, 0x83, 0x47, 0xda}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 27993); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "IP~U\245v\179O\ETB\247\SUB\152i\169\208", _pubPktID = 1633, _pubBody = -// "\164\215\&1Ym\133Ie\197\EOT\147\DC3}g\SUB\150\143", _pubProps = [PropServerKeepAlive 425,PropAuthenticationMethod -// "#\147\225\221\EM\204,4\195\215\182\DC2\209h8\242=\131m\241]\223\&2B*\154A",PropReceiveMaximum -// 21231,PropCorrelationData "\185GM-\220p",PropTopicAliasMaximum 24215,PropMaximumPacketSize -// 32734,PropRequestResponseInformation 122,PropSubscriptionIdentifierAvailable 16,PropRequestResponseInformation -// 139,PropMessageExpiryInterval 14314]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\245l-\185\147\\\ai\199\183\216s\232\\\248\DC4\199\231[\DC4\139", _pubProps = [PropAuthenticationMethod +// "rC\184\SI\211\138\216kp\140\252\ACK2",PropMessageExpiryInterval 14395,PropSharedSubscriptionAvailable +// 182,PropMaximumQoS 230,PropServerReference +// "z\215\224\187zZ\ETB$\137\164\235\133\143\SI\228\232\242\130R\188\b\242\228\131\179\br",PropReasonString +// "\205\&6\ENQWp\149\176\186\202",PropPayloadFormatIndicator 91,PropRequestResponseInformation +// 166,PropResponseInformation +// "\US\220\207\205\200\162\141U\254\SOH\204\ng\156*\133h\228\198\152\CANhb",PropWildcardSubscriptionAvailable +// 52,PropSubscriptionIdentifier 17,PropRequestProblemInformation 195,PropTopicAlias 28295,PropMessageExpiryInterval +// 25451,PropReasonString "W",PropSessionExpiryInterval 13393,PropAssignedClientIdentifier +// "\146P\DC3`xR\ETX\t\161p\199",PropRetainAvailable 160,PropMessageExpiryInterval 16943,PropUserProperty +// "\212z\240\193\227\DC4\196,\RS?\198I\145[H\136\236\&39\254" +// "\154n2\180\135\194\227\149\178\151\152\216'",PropContentType "",PropAuthenticationData +// "\\@T\206\SOH,v\220\160dU?\218\RSM\250\181e\199",PropTopicAliasMaximum 7139,PropSessionExpiryInterval +// 27556,PropAuthenticationMethod "j\194\EOT\206w",PropUserProperty "W\150m\239\193e\141\197\242" +// "\200z{\236=*\134\210\160\237\t\n2",PropWildcardSubscriptionAvailable 5]} TEST(Publish5QCTest, Encode19) { - uint8_t pkt[] = {0x3d, 0x65, 0x0, 0xf, 0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, 0xf7, 0x1a, - 0x98, 0x69, 0xa9, 0xd0, 0x6, 0x61, 0x40, 0x13, 0x1, 0xa9, 0x15, 0x0, 0x1b, 0x23, 0x93, - 0xe1, 0xdd, 0x19, 0xcc, 0x2c, 0x34, 0xc3, 0xd7, 0xb6, 0x12, 0xd1, 0x68, 0x38, 0xf2, 0x3d, - 0x83, 0x6d, 0xf1, 0x5d, 0xdf, 0x32, 0x42, 0x2a, 0x9a, 0x41, 0x21, 0x52, 0xef, 0x9, 0x0, - 0x6, 0xb9, 0x47, 0x4d, 0x2d, 0xdc, 0x70, 0x22, 0x5e, 0x97, 0x27, 0x0, 0x0, 0x7f, 0xde, - 0x19, 0x7a, 0x29, 0x10, 0x19, 0x8b, 0x2, 0x0, 0x0, 0x37, 0xea, 0xa4, 0xd7, 0x31, 0x59, - 0x6d, 0x85, 0x49, 0x65, 0xc5, 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; - uint8_t topic_bytes[] = {0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x30, 0x92, 0x2, 0x0, 0x0, 0xf9, 0x1, 0x15, 0x0, 0xd, 0x72, 0x43, 0xb8, 0xf, 0xd3, 0x8a, 0xd8, 0x6b, 0x70, + 0x8c, 0xfc, 0x6, 0x32, 0x2, 0x0, 0x0, 0x38, 0x3b, 0x2a, 0xb6, 0x24, 0xe6, 0x1c, 0x0, 0x1b, 0x7a, 0xd7, 0xe0, + 0xbb, 0x7a, 0x5a, 0x17, 0x24, 0x89, 0xa4, 0xeb, 0x85, 0x8f, 0xf, 0xe4, 0xe8, 0xf2, 0x82, 0x52, 0xbc, 0x8, 0xf2, + 0xe4, 0x83, 0xb3, 0x8, 0x72, 0x1f, 0x0, 0x9, 0xcd, 0x36, 0x5, 0x57, 0x70, 0x95, 0xb0, 0xba, 0xca, 0x1, 0x5b, + 0x19, 0xa6, 0x1a, 0x0, 0x17, 0x1f, 0xdc, 0xcf, 0xcd, 0xc8, 0xa2, 0x8d, 0x55, 0xfe, 0x1, 0xcc, 0xa, 0x67, 0x9c, + 0x2a, 0x85, 0x68, 0xe4, 0xc6, 0x98, 0x18, 0x68, 0x62, 0x28, 0x34, 0xb, 0x11, 0x17, 0xc3, 0x23, 0x6e, 0x87, 0x2, + 0x0, 0x0, 0x63, 0x6b, 0x1f, 0x0, 0x1, 0x57, 0x11, 0x0, 0x0, 0x34, 0x51, 0x12, 0x0, 0xb, 0x92, 0x50, 0x13, + 0x60, 0x78, 0x52, 0x3, 0x9, 0xa1, 0x70, 0xc7, 0x25, 0xa0, 0x2, 0x0, 0x0, 0x42, 0x2f, 0x26, 0x0, 0x14, 0xd4, + 0x7a, 0xf0, 0xc1, 0xe3, 0x14, 0xc4, 0x2c, 0x1e, 0x3f, 0xc6, 0x49, 0x91, 0x5b, 0x48, 0x88, 0xec, 0x33, 0x39, 0xfe, + 0x0, 0xd, 0x9a, 0x6e, 0x32, 0xb4, 0x87, 0xc2, 0xe3, 0x95, 0xb2, 0x97, 0x98, 0xd8, 0x27, 0x3, 0x0, 0x0, 0x16, + 0x0, 0x13, 0x5c, 0x40, 0x54, 0xce, 0x1, 0x2c, 0x76, 0xdc, 0xa0, 0x64, 0x55, 0x3f, 0xda, 0x1e, 0x4d, 0xfa, 0xb5, + 0x65, 0xc7, 0x22, 0x1b, 0xe3, 0x11, 0x0, 0x0, 0x6b, 0xa4, 0x15, 0x0, 0x5, 0x6a, 0xc2, 0x4, 0xce, 0x77, 0x26, + 0x0, 0x9, 0x57, 0x96, 0x6d, 0xef, 0xc1, 0x65, 0x8d, 0xc5, 0xf2, 0x0, 0xd, 0xc8, 0x7a, 0x7b, 0xec, 0x3d, 0x2a, + 0x86, 0xd2, 0xa0, 0xed, 0x9, 0xa, 0x32, 0x28, 0x5, 0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, + 0xd8, 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa4, 0xd7, 0x31, 0x59, 0x6d, 0x85, 0x49, 0x65, 0xc5, - 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, 0xd8, + 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 21; - uint8_t bytesprops0[] = {0x23, 0x93, 0xe1, 0xdd, 0x19, 0xcc, 0x2c, 0x34, 0xc3, 0xd7, 0xb6, 0x12, 0xd1, 0x68, - 0x38, 0xf2, 0x3d, 0x83, 0x6d, 0xf1, 0x5d, 0xdf, 0x32, 0x42, 0x2a, 0x9a, 0x41}; - uint8_t bytesprops1[] = {0xb9, 0x47, 0x4d, 0x2d, 0xdc, 0x70}; + uint8_t bytesprops0[] = {0x72, 0x43, 0xb8, 0xf, 0xd3, 0x8a, 0xd8, 0x6b, 0x70, 0x8c, 0xfc, 0x6, 0x32}; + uint8_t bytesprops1[] = {0x7a, 0xd7, 0xe0, 0xbb, 0x7a, 0x5a, 0x17, 0x24, 0x89, 0xa4, 0xeb, 0x85, 0x8f, 0xf, + 0xe4, 0xe8, 0xf2, 0x82, 0x52, 0xbc, 0x8, 0xf2, 0xe4, 0x83, 0xb3, 0x8, 0x72}; + uint8_t bytesprops2[] = {0xcd, 0x36, 0x5, 0x57, 0x70, 0x95, 0xb0, 0xba, 0xca}; + uint8_t bytesprops3[] = {0x1f, 0xdc, 0xcf, 0xcd, 0xc8, 0xa2, 0x8d, 0x55, 0xfe, 0x1, 0xcc, 0xa, + 0x67, 0x9c, 0x2a, 0x85, 0x68, 0xe4, 0xc6, 0x98, 0x18, 0x68, 0x62}; + uint8_t bytesprops4[] = {0x57}; + uint8_t bytesprops5[] = {0x92, 0x50, 0x13, 0x60, 0x78, 0x52, 0x3, 0x9, 0xa1, 0x70, 0xc7}; + uint8_t bytesprops7[] = {0x9a, 0x6e, 0x32, 0xb4, 0x87, 0xc2, 0xe3, 0x95, 0xb2, 0x97, 0x98, 0xd8, 0x27}; + uint8_t bytesprops6[] = {0xd4, 0x7a, 0xf0, 0xc1, 0xe3, 0x14, 0xc4, 0x2c, 0x1e, 0x3f, + 0xc6, 0x49, 0x91, 0x5b, 0x48, 0x88, 0xec, 0x33, 0x39, 0xfe}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0x5c, 0x40, 0x54, 0xce, 0x1, 0x2c, 0x76, 0xdc, 0xa0, 0x64, + 0x55, 0x3f, 0xda, 0x1e, 0x4d, 0xfa, 0xb5, 0x65, 0xc7}; + uint8_t bytesprops10[] = {0x6a, 0xc2, 0x4, 0xce, 0x77}; + uint8_t bytesprops12[] = {0xc8, 0x7a, 0x7b, 0xec, 0x3d, 0x2a, 0x86, 0xd2, 0xa0, 0xed, 0x9, 0xa, 0x32}; + uint8_t bytesprops11[] = {0x57, 0x96, 0x6d, 0xef, 0xc1, 0x65, 0x8d, 0xc5, 0xf2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 425}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21231}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24215}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32734}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14314}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14395}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28295}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25451}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13393}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16943}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops6}, .v = {13, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7139}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27556}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops11}, .v = {13, (char*)&bytesprops12}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 5}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1633, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "IP~U\245v\179O\ETB\247\SUB\152i\169\208", _pubPktID = 1633, _pubBody = -// "\164\215\&1Ym\133Ie\197\EOT\147\DC3}g\SUB\150\143", _pubProps = [PropServerKeepAlive 425,PropAuthenticationMethod -// "#\147\225\221\EM\204,4\195\215\182\DC2\209h8\242=\131m\241]\223\&2B*\154A",PropReceiveMaximum -// 21231,PropCorrelationData "\185GM-\220p",PropTopicAliasMaximum 24215,PropMaximumPacketSize -// 32734,PropRequestResponseInformation 122,PropSubscriptionIdentifierAvailable 16,PropRequestResponseInformation -// 139,PropMessageExpiryInterval 14314]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\245l-\185\147\\\ai\199\183\216s\232\\\248\DC4\199\231[\DC4\139", _pubProps = [PropAuthenticationMethod +// "rC\184\SI\211\138\216kp\140\252\ACK2",PropMessageExpiryInterval 14395,PropSharedSubscriptionAvailable +// 182,PropMaximumQoS 230,PropServerReference +// "z\215\224\187zZ\ETB$\137\164\235\133\143\SI\228\232\242\130R\188\b\242\228\131\179\br",PropReasonString +// "\205\&6\ENQWp\149\176\186\202",PropPayloadFormatIndicator 91,PropRequestResponseInformation +// 166,PropResponseInformation +// "\US\220\207\205\200\162\141U\254\SOH\204\ng\156*\133h\228\198\152\CANhb",PropWildcardSubscriptionAvailable +// 52,PropSubscriptionIdentifier 17,PropRequestProblemInformation 195,PropTopicAlias 28295,PropMessageExpiryInterval +// 25451,PropReasonString "W",PropSessionExpiryInterval 13393,PropAssignedClientIdentifier +// "\146P\DC3`xR\ETX\t\161p\199",PropRetainAvailable 160,PropMessageExpiryInterval 16943,PropUserProperty +// "\212z\240\193\227\DC4\196,\RS?\198I\145[H\136\236\&39\254" +// "\154n2\180\135\194\227\149\178\151\152\216'",PropContentType "",PropAuthenticationData +// "\\@T\206\SOH,v\220\160dU?\218\RSM\250\181e\199",PropTopicAliasMaximum 7139,PropSessionExpiryInterval +// 27556,PropAuthenticationMethod "j\194\EOT\206w",PropUserProperty "W\150m\239\193e\141\197\242" +// "\200z{\236=*\134\210\160\237\t\n2",PropWildcardSubscriptionAvailable 5]} TEST(Publish5QCTest, Decode19) { - uint8_t pkt[] = {0x3d, 0x65, 0x0, 0xf, 0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, 0x17, 0xf7, 0x1a, - 0x98, 0x69, 0xa9, 0xd0, 0x6, 0x61, 0x40, 0x13, 0x1, 0xa9, 0x15, 0x0, 0x1b, 0x23, 0x93, - 0xe1, 0xdd, 0x19, 0xcc, 0x2c, 0x34, 0xc3, 0xd7, 0xb6, 0x12, 0xd1, 0x68, 0x38, 0xf2, 0x3d, - 0x83, 0x6d, 0xf1, 0x5d, 0xdf, 0x32, 0x42, 0x2a, 0x9a, 0x41, 0x21, 0x52, 0xef, 0x9, 0x0, - 0x6, 0xb9, 0x47, 0x4d, 0x2d, 0xdc, 0x70, 0x22, 0x5e, 0x97, 0x27, 0x0, 0x0, 0x7f, 0xde, - 0x19, 0x7a, 0x29, 0x10, 0x19, 0x8b, 0x2, 0x0, 0x0, 0x37, 0xea, 0xa4, 0xd7, 0x31, 0x59, - 0x6d, 0x85, 0x49, 0x65, 0xc5, 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x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x98, 0xd8, 0x27, 0x3, 0x0, 0x0, 0x16, + 0x0, 0x13, 0x5c, 0x40, 0x54, 0xce, 0x1, 0x2c, 0x76, 0xdc, 0xa0, 0x64, 0x55, 0x3f, 0xda, 0x1e, 0x4d, 0xfa, 0xb5, + 0x65, 0xc7, 0x22, 0x1b, 0xe3, 0x11, 0x0, 0x0, 0x6b, 0xa4, 0x15, 0x0, 0x5, 0x6a, 0xc2, 0x4, 0xce, 0x77, 0x26, + 0x0, 0x9, 0x57, 0x96, 0x6d, 0xef, 0xc1, 0x65, 0x8d, 0xc5, 0xf2, 0x0, 0xd, 0xc8, 0x7a, 0x7b, 0xec, 0x3d, 0x2a, + 0x86, 0xd2, 0xa0, 0xed, 0x9, 0xa, 0x32, 0x28, 0x5, 0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, + 0xd8, 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3749,140 +3881,146 @@ TEST(Publish5QCTest, Decode19) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x49, 0x50, 0x7e, 0x55, 0xf5, 0x76, 0xb3, 0x4f, - 0x17, 0xf7, 0x1a, 0x98, 0x69, 0xa9, 0xd0}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa4, 0xd7, 0x31, 0x59, 0x6d, 0x85, 0x49, 0x65, 0xc5, - 0x4, 0x93, 0x13, 0x7d, 0x67, 0x1a, 0x96, 0x8f}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 1633); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, 0xd8, + 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\bm\162F\236O\211D\179\164@\195\244", _pubPktID = 19046, _pubBody = ".\167H\139", _pubProps = -// [PropAuthenticationMethod -// "\219\229\205\149\172\227\202\174\223\175\168\209\167y\200l\NAK\169\NUL!\234",PropTopicAlias 27954,PropContentType -// "\CAN\175Kb_\199\210\223\181~\239",PropAuthenticationMethod -// "\129=\FS\190\220\195\244\195\RS\235\203\248\239\154a\138\225\EOT\DC3",PropAssignedClientIdentifier -// "\194\237T\196\147\185\239\166",PropAuthenticationMethod -// "-U\247\206s\fm\SI\169\229\240\146I\ACK\132\237",PropServerKeepAlive 5221,PropRetainAvailable -// 36,PropMessageExpiryInterval 3914,PropResponseTopic -// ",\233\163\165e\195X\ACK\DC1\te\152^T\193\220\176",PropAuthenticationMethod -// "s\232\207Z\196\202*g\SYN\199\219\ay\224\191?gO(X\150\t\FS",PropSubscriptionIdentifier 2,PropTopicAlias -// 17849,PropContentType "\170\216\214\235\220e\250\177\142 -// \157\233\r4a\153\233\152)\236",PropWildcardSubscriptionAvailable 181,PropAuthenticationData -// "\139\254\154=\192#C\209\EOTU1U\162J[zj\238\168\203\DC2!",PropWillDelayInterval 20612,PropServerKeepAlive -// 16088,PropSubscriptionIdentifierAvailable 56]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "B&&P~\USwi\200\237U\SI0[8\205\ETX\US\171\236", _pubPktID = 20579, _pubBody = +// "\160|,\236\153`\132S\ETBj\210-v\ETB\US\246\DC4>iK\158\SOH\141\250", _pubProps = [PropAuthenticationData +// "\189\ETX\233\254\CAN\DLEh\194\167\169\ENQ\189R\142\208\219K_L\142<",PropMessageExpiryInterval +// 5515,PropReceiveMaximum 2239,PropContentType +// "\na\143g\245\241\131\129S\235:S\134\\Y\EM\178jo\176\254~\160\244b\153=O\219\134",PropRequestResponseInformation +// 81,PropTopicAliasMaximum 31006,PropRequestProblemInformation 9,PropServerKeepAlive +// 14324,PropSharedSubscriptionAvailable 46,PropMaximumPacketSize 2368,PropContentType "+\149\163\222\141\174\179\ETB +// \216r.RR\180#f\226(\156;",PropResponseTopic +// "}\EM\250f\EOT4\216\187s\219\209\136\147\216`\224\ACK\232yt\231\173n\248\183\197",PropMaximumPacketSize +// 27506,PropReceiveMaximum 3430,PropRetainAvailable 154,PropResponseTopic +// "-~\ESC\222E\156\152\245b\135",PropUserProperty "\217U\GS2\234\145" +// "\249\151\166\171\245N.<\164x\194",PropWillDelayInterval 13052,PropSharedSubscriptionAvailable +// 178,PropAssignedClientIdentifier "\248\EMC8m,8I\t\252\215",PropAssignedClientIdentifier +// "\v\140\238\&9\136e=\239\143>Qi\219\130\251T\251\143\244d\ETX\251"]} TEST(Publish5QCTest, Encode20) { uint8_t pkt[] = { - 0x35, 0xed, 0x1, 0x0, 0xd, 0x8, 0x6d,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x34, 0x61, 0x99, 0xe9, 0x98, 0x29, 0xec, 0x28, 0xb5, 0x16, 0x0, 0x16, 0x8b, 0xfe, 0x9a, 0x3d, 0xc0, - 0x23, 0x43, 0xd1, 0x4, 0x55, 0x31, 0x55, 0xa2, 0x4a, 0x5b, 0x7a, 0x6a, 0xee, 0xa8, 0xcb, 0x12, 0x21, 0x18, 0x0, - 0x0, 0x50, 0x84, 0x13, 0x3e, 0xd8, 0x29, 0x38, 0x2e, 0xa7, 0x48, 0x8b}; - uint8_t topic_bytes[] = {0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, 0xb3, 0xa4, 0x40, 0xc3, 0xf4}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + 0x3d, 0x94, 0x2, 0x0, 0x14, 0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, 0x55, 0xf, 0x30, 0x5b, + 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec, 0x50, 0x63, 0xe2, 0x1, 0x16, 0x0, 0x15, 0xbd, 0x3, 0xe9, 0xfe, 0x18, 0x10, + 0x68, 0xc2, 0xa7, 0xa9, 0x5, 0xbd, 0x52, 0x8e, 0xd0, 0xdb, 0x4b, 0x5f, 0x4c, 0x8e, 0x3c, 0x2, 0x0, 0x0, 0x15, + 0x8b, 0x21, 0x8, 0xbf, 0x3, 0x0, 0x1e, 0xa, 0x61, 0x8f, 0x67, 0xf5, 0xf1, 0x83, 0x81, 0x53, 0xeb, 0x3a, 0x53, + 0x86, 0x5c, 0x59, 0x19, 0xb2, 0x6a, 0x6f, 0xb0, 0xfe, 0x7e, 0xa0, 0xf4, 0x62, 0x99, 0x3d, 0x4f, 0xdb, 0x86, 0x19, + 0x51, 0x22, 0x79, 0x1e, 0x17, 0x9, 0x13, 0x37, 0xf4, 0x2a, 0x2e, 0x27, 0x0, 0x0, 0x9, 0x40, 0x3, 0x0, 0x15, + 0x2b, 0x95, 0xa3, 0xde, 0x8d, 0xae, 0xb3, 0x17, 0x20, 0xd8, 0x72, 0x2e, 0x52, 0x52, 0xb4, 0x23, 0x66, 0xe2, 0x28, + 0x9c, 0x3b, 0x8, 0x0, 0x1a, 0x7d, 0x19, 0xfa, 0x66, 0x4, 0x34, 0xd8, 0xbb, 0x73, 0xdb, 0xd1, 0x88, 0x93, 0xd8, + 0x60, 0xe0, 0x6, 0xe8, 0x79, 0x74, 0xe7, 0xad, 0x6e, 0xf8, 0xb7, 0xc5, 0x27, 0x0, 0x0, 0x6b, 0x72, 0x21, 0xd, + 0x66, 0x25, 0x9a, 0x8, 0x0, 0xa, 0x2d, 0x7e, 0x1b, 0xde, 0x45, 0x9c, 0x98, 0xf5, 0x62, 0x87, 0x26, 0x0, 0x6, + 0xd9, 0x55, 0x1d, 0x32, 0xea, 0x91, 0x0, 0xb, 0xf9, 0x97, 0xa6, 0xab, 0xf5, 0x4e, 0x2e, 0x3c, 0xa4, 0x78, 0xc2, + 0x18, 0x0, 0x0, 0x32, 0xfc, 0x2a, 0xb2, 0x12, 0x0, 0xb, 0xf8, 0x19, 0x43, 0x38, 0x6d, 0x2c, 0x38, 0x49, 0x9, + 0xfc, 0xd7, 0x12, 0x0, 0x16, 0xb, 0x8c, 0xee, 0x39, 0x88, 0x65, 0x3d, 0xef, 0x8f, 0x3e, 0x51, 0x69, 0xdb, 0x82, + 0xfb, 0x54, 0xfb, 0x8f, 0xf4, 0x64, 0x3, 0xfb, 0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, + 0x2d, 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; + uint8_t topic_bytes[] = {0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, + 0x55, 0xf, 0x30, 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x2e, 0xa7, 0x48, 0x8b}; + uint8_t msg_bytes[] = {0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, 0x2d, + 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; - - uint8_t bytesprops0[] = {0xdb, 0xe5, 0xcd, 0x95, 0xac, 0xe3, 0xca, 0xae, 0xdf, 0xaf, 0xa8, - 0xd1, 0xa7, 0x79, 0xc8, 0x6c, 0x15, 0xa9, 0x0, 0x21, 0xea}; - uint8_t bytesprops1[] = {0x18, 0xaf, 0x4b, 0x62, 0x5f, 0xc7, 0xd2, 0xdf, 0xb5, 0x7e, 0xef}; - uint8_t bytesprops2[] = {0x81, 0x3d, 0x1c, 0xbe, 0xdc, 0xc3, 0xf4, 0xc3, 0x1e, 0xeb, - 0xcb, 0xf8, 0xef, 0x9a, 0x61, 0x8a, 0xe1, 0x4, 0x13}; - uint8_t bytesprops3[] = {0xc2, 0xed, 0x54, 0xc4, 0x93, 0xb9, 0xef, 0xa6}; - uint8_t bytesprops4[] = {0x2d, 0x55, 0xf7, 0xce, 0x73, 0xc, 0x6d, 0xf, 0xa9, 0xe5, 0xf0, 0x92, 0x49, 0x6, 0x84, 0xed}; - uint8_t bytesprops5[] = {0x2c, 0xe9, 0xa3, 0xa5, 0x65, 0xc3, 0x58, 0x6, 0x11, - 0x9, 0x65, 0x98, 0x5e, 0x54, 0xc1, 0xdc, 0xb0}; - uint8_t bytesprops6[] = {0x73, 0xe8, 0xcf, 0x5a, 0xc4, 0xca, 0x2a, 0x67, 0x16, 0xc7, 0xdb, 0x7, - 0x79, 0xe0, 0xbf, 0x3f, 0x67, 0x4f, 0x28, 0x58, 0x96, 0x9, 0x1c}; - uint8_t bytesprops7[] = {0xaa, 0xd8, 0xd6, 0xeb, 0xdc, 0x65, 0xfa, 0xb1, 0x8e, 0x20, - 0x9d, 0xe9, 0xd, 0x34, 0x61, 0x99, 0xe9, 0x98, 0x29, 0xec}; - uint8_t bytesprops8[] = {0x8b, 0xfe, 0x9a, 0x3d, 0xc0, 0x23, 0x43, 0xd1, 0x4, 0x55, 0x31, - 0x55, 0xa2, 0x4a, 0x5b, 0x7a, 0x6a, 0xee, 0xa8, 0xcb, 0x12, 0x21}; + msg.payload_len = 24; + + uint8_t bytesprops0[] = {0xbd, 0x3, 0xe9, 0xfe, 0x18, 0x10, 0x68, 0xc2, 0xa7, 0xa9, 0x5, + 0xbd, 0x52, 0x8e, 0xd0, 0xdb, 0x4b, 0x5f, 0x4c, 0x8e, 0x3c}; + uint8_t bytesprops1[] = {0xa, 0x61, 0x8f, 0x67, 0xf5, 0xf1, 0x83, 0x81, 0x53, 0xeb, 0x3a, 0x53, 0x86, 0x5c, 0x59, + 0x19, 0xb2, 0x6a, 0x6f, 0xb0, 0xfe, 0x7e, 0xa0, 0xf4, 0x62, 0x99, 0x3d, 0x4f, 0xdb, 0x86}; + uint8_t bytesprops2[] = {0x2b, 0x95, 0xa3, 0xde, 0x8d, 0xae, 0xb3, 0x17, 0x20, 0xd8, 0x72, + 0x2e, 0x52, 0x52, 0xb4, 0x23, 0x66, 0xe2, 0x28, 0x9c, 0x3b}; + uint8_t bytesprops3[] = {0x7d, 0x19, 0xfa, 0x66, 0x4, 0x34, 0xd8, 0xbb, 0x73, 0xdb, 0xd1, 0x88, 0x93, + 0xd8, 0x60, 0xe0, 0x6, 0xe8, 0x79, 0x74, 0xe7, 0xad, 0x6e, 0xf8, 0xb7, 0xc5}; + uint8_t bytesprops4[] = {0x2d, 0x7e, 0x1b, 0xde, 0x45, 0x9c, 0x98, 0xf5, 0x62, 0x87}; + uint8_t bytesprops6[] = {0xf9, 0x97, 0xa6, 0xab, 0xf5, 0x4e, 0x2e, 0x3c, 0xa4, 0x78, 0xc2}; + uint8_t bytesprops5[] = {0xd9, 0x55, 0x1d, 0x32, 0xea, 0x91}; + uint8_t bytesprops7[] = {0xf8, 0x19, 0x43, 0x38, 0x6d, 0x2c, 0x38, 0x49, 0x9, 0xfc, 0xd7}; + uint8_t bytesprops8[] = {0xb, 0x8c, 0xee, 0x39, 0x88, 0x65, 0x3d, 0xef, 0x8f, 0x3e, 0x51, + 0x69, 0xdb, 0x82, 0xfb, 0x54, 0xfb, 0x8f, 0xf4, 0x64, 0x3, 0xfb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27954}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5221}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3914}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17849}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20612}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16088}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5515}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2239}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31006}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14324}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2368}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27506}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3430}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops5}, .v = {11, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13052}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19046, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 20579, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\bm\162F\236O\211D\179\164@\195\244", _pubPktID = 19046, _pubBody = ".\167H\139", _pubProps = -// [PropAuthenticationMethod -// "\219\229\205\149\172\227\202\174\223\175\168\209\167y\200l\NAK\169\NUL!\234",PropTopicAlias 27954,PropContentType -// "\CAN\175Kb_\199\210\223\181~\239",PropAuthenticationMethod -// "\129=\FS\190\220\195\244\195\RS\235\203\248\239\154a\138\225\EOT\DC3",PropAssignedClientIdentifier -// "\194\237T\196\147\185\239\166",PropAuthenticationMethod -// "-U\247\206s\fm\SI\169\229\240\146I\ACK\132\237",PropServerKeepAlive 5221,PropRetainAvailable -// 36,PropMessageExpiryInterval 3914,PropResponseTopic -// ",\233\163\165e\195X\ACK\DC1\te\152^T\193\220\176",PropAuthenticationMethod -// "s\232\207Z\196\202*g\SYN\199\219\ay\224\191?gO(X\150\t\FS",PropSubscriptionIdentifier 2,PropTopicAlias -// 17849,PropContentType "\170\216\214\235\220e\250\177\142 -// \157\233\r4a\153\233\152)\236",PropWildcardSubscriptionAvailable 181,PropAuthenticationData -// "\139\254\154=\192#C\209\EOTU1U\162J[zj\238\168\203\DC2!",PropWillDelayInterval 20612,PropServerKeepAlive -// 16088,PropSubscriptionIdentifierAvailable 56]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "B&&P~\USwi\200\237U\SI0[8\205\ETX\US\171\236", _pubPktID = 20579, _pubBody = +// "\160|,\236\153`\132S\ETBj\210-v\ETB\US\246\DC4>iK\158\SOH\141\250", _pubProps = [PropAuthenticationData +// "\189\ETX\233\254\CAN\DLEh\194\167\169\ENQ\189R\142\208\219K_L\142<",PropMessageExpiryInterval +// 5515,PropReceiveMaximum 2239,PropContentType +// "\na\143g\245\241\131\129S\235:S\134\\Y\EM\178jo\176\254~\160\244b\153=O\219\134",PropRequestResponseInformation +// 81,PropTopicAliasMaximum 31006,PropRequestProblemInformation 9,PropServerKeepAlive +// 14324,PropSharedSubscriptionAvailable 46,PropMaximumPacketSize 2368,PropContentType "+\149\163\222\141\174\179\ETB +// \216r.RR\180#f\226(\156;",PropResponseTopic +// "}\EM\250f\EOT4\216\187s\219\209\136\147\216`\224\ACK\232yt\231\173n\248\183\197",PropMaximumPacketSize +// 27506,PropReceiveMaximum 3430,PropRetainAvailable 154,PropResponseTopic +// "-~\ESC\222E\156\152\245b\135",PropUserProperty "\217U\GS2\234\145" +// "\249\151\166\171\245N.<\164x\194",PropWillDelayInterval 13052,PropSharedSubscriptionAvailable +// 178,PropAssignedClientIdentifier "\248\EMC8m,8I\t\252\215",PropAssignedClientIdentifier +// "\v\140\238\&9\136e=\239\143>Qi\219\130\251T\251\143\244d\ETX\251"]} TEST(Publish5QCTest, Decode20) { uint8_t pkt[] = { - 0x35, 0xed, 0x1, 0x0, 0xd, 0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, 0xb3, 0xa4, 0x40, 0xc3, 0xf4, 0x4a, - 0x66, 0xd6, 0x1, 0x15, 0x0, 0x15, 0xdb, 0xe5, 0xcd, 0x95, 0xac, 0xe3, 0xca, 0xae, 0xdf, 0xaf, 0xa8, 0xd1, 0xa7, - 0x79, 0xc8, 0x6c, 0x15, 0xa9, 0x0, 0x21, 0xea, 0x23, 0x6d, 0x32, 0x3, 0x0, 0xb, 0x18, 0xaf, 0x4b, 0x62, 0x5f, - 0xc7, 0xd2, 0xdf, 0xb5, 0x7e, 0xef, 0x15, 0x0, 0x13, 0x81, 0x3d, 0x1c, 0xbe, 0xdc, 0xc3, 0xf4, 0xc3, 0x1e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2, + 0x18, 0x0, 0x0, 0x32, 0xfc, 0x2a, 0xb2, 0x12, 0x0, 0xb, 0xf8, 0x19, 0x43, 0x38, 0x6d, 0x2c, 0x38, 0x49, 0x9, + 0xfc, 0xd7, 0x12, 0x0, 0x16, 0xb, 0x8c, 0xee, 0x39, 0x88, 0x65, 0x3d, 0xef, 0x8f, 0x3e, 0x51, 0x69, 0xdb, 0x82, + 0xfb, 0x54, 0xfb, 0x8f, 0xf4, 0x64, 0x3, 0xfb, 0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, + 0x2d, 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3890,120 +4028,159 @@ TEST(Publish5QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8, 0x6d, 0xa2, 0x46, 0xec, 0x4f, 0xd3, 0x44, 0xb3, 0xa4, 0x40, 0xc3, 0xf4}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2e, 0xa7, 0x48, 0x8b}; - lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, + 0x55, 0xf, 0x30, 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, 0x2d, + 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 19046); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 4); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + EXPECT_EQ(packet_id, 20579); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "%\134\216", _pubPktID = 0, _pubBody -// = "\ETB\162T\161\139s\238\233\229.\233\243\186", _pubProps = [PropReceiveMaximum 13370,PropServerReference -// ";O\228n+\180\201\169\171\196\225 \EM\232\ETX\155#\SI(\t[Uu",PropPayloadFormatIndicator 134,PropUserProperty -// "\249\245\STXW\228J\157" -// "\231\255\213\ACK[2\204\&6\175\169\228\168\195\246\156\189)\255\&5\186\135\SO\210\246I\144C:\225\179",PropMaximumPacketSize -// 20364,PropUserProperty "\DC3{,\181\USP\229\211\FS\138\189-\240\220\205\128i\156`\ESC8" -// "ss\164\EOT\152",PropAuthenticationData "\221\220\186\194/\STX\246\189\ETX\SOH='\150\187$-",PropAuthenticationMethod -// "\187G\163\200\195[\211\203^\NUL\NAK\239\184\&6Q\176\v\255\t,\246\246\&1\172\216\207\t",PropReceiveMaximum -// 32386,PropRequestResponseInformation 185,PropServerReference -// "\248\181w\213\166\219\221\247\159\254\204\179\213|\243I\STXa\255\143w\SYN\208\223\218\185\ESC",PropMessageExpiryInterval -// 6843,PropRetainAvailable 210]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "Wo\249\180\STXZ\FS\218Co_\137a\140\&9^\232\186\143\230", _pubPktID = 10935, _pubBody = +// "\US\177vw\219K\147TS\150\&9", _pubProps = [PropRequestProblemInformation 50,PropMaximumQoS +// 128,PropRequestProblemInformation 117,PropSharedSubscriptionAvailable 34,PropRequestProblemInformation +// 176,PropResponseTopic "\138\239\224\170\217\195W\DLE\247\243\229\144JC\206\214\157\210\140y",PropServerReference +// "\GS{\211\DEL%TI\RS\240\157\133\241",PropCorrelationData "^\ENQ\SIt\179\r\175",PropTopicAliasMaximum +// 9980,PropSubscriptionIdentifier 13,PropRequestProblemInformation 141,PropRequestProblemInformation +// 157,PropServerKeepAlive 25125,PropServerReference +// "\152\177nW\NAK\203\176X0\170X\164\187\ACK\228H4\157F\245\SYN\206\164",PropAuthenticationData +// "\229OD^\140\223\EOT\DLE!=\183\138_\187\233.\162\v\166\131\221\fk@\205\251\219\225]",PropRequestProblemInformation +// 89,PropSharedSubscriptionAvailable 29,PropReasonString +// "2\EOT\150\DEL\143J\160\249\203\DC4K\228\210\181",PropServerReference +// "\218iml`u\n\149\238u\199\US\SYNP\STX\\\142~\232\237\DC12\249",PropReceiveMaximum +// 9895,PropSharedSubscriptionAvailable 120,PropSessionExpiryInterval 11586,PropMessageExpiryInterval +// 30889,PropSessionExpiryInterval 28738,PropReceiveMaximum 1634,PropUserProperty +// ".\171\187d\NUL\164\234?\f2\DLE\STXi\NULL\169\ENQh" "\183\140ND\184/\134",PropServerReference +// "\216\204\231\214^\SYNL\179",PropRetainAvailable 88,PropServerKeepAlive 19095]} TEST(Publish5QCTest, Encode21) { uint8_t pkt[] = { - 0x38, 0xdc, 0x1, 0x0, 0x3, 0x25, 0x86, 0xd8, 0xc8, 0x1, 0x21, 0x34, 0x3a, 0x1c, 0x0, 0x17, 0x3b, 0x4f, 0xe4, - 0x6e, 0x2b, 0xb4, 0xc9, 0xa9, 0xab, 0xc4, 0xe1, 0x20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a2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; - uint8_t topic_bytes[] = {0x25, 0x86, 0xd8}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + 0x3d, 0x99, 0x2, 0x0, 0x14, 0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, 0x5f, 0x89, 0x61, 0x8c, + 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6, 0x2a, 0xb7, 0xf4, 0x1, 0x17, 0x32, 0x24, 0x80, 0x17, 0x75, 0x2a, 0x22, 0x17, + 0xb0, 0x8, 0x0, 0x14, 0x8a, 0xef, 0xe0, 0xaa, 0xd9, 0xc3, 0x57, 0x10, 0xf7, 0xf3, 0xe5, 0x90, 0x4a, 0x43, 0xce, + 0xd6, 0x9d, 0xd2, 0x8c, 0x79, 0x1c, 0x0, 0xc, 0x1d, 0x7b, 0xd3, 0x7f, 0x25, 0x54, 0x49, 0x1e, 0xf0, 0x9d, 0x85, + 0xf1, 0x9, 0x0, 0x7, 0x5e, 0x5, 0xf, 0x74, 0xb3, 0xd, 0xaf, 0x22, 0x26, 0xfc, 0xb, 0xd, 0x17, 0x8d, 0x17, + 0x9d, 0x13, 0x62, 0x25, 0x1c, 0x0, 0x17, 0x98, 0xb1, 0x6e, 0x57, 0x15, 0xcb, 0xb0, 0x58, 0x30, 0xaa, 0x58, 0xa4, + 0xbb, 0x6, 0xe4, 0x48, 0x34, 0x9d, 0x46, 0xf5, 0x16, 0xce, 0xa4, 0x16, 0x0, 0x1d, 0xe5, 0x4f, 0x44, 0x5e, 0x8c, + 0xdf, 0x4, 0x10, 0x21, 0x3d, 0xb7, 0x8a, 0x5f, 0xbb, 0xe9, 0x2e, 0xa2, 0xb, 0xa6, 0x83, 0xdd, 0xc, 0x6b, 0x40, + 0xcd, 0xfb, 0xdb, 0xe1, 0x5d, 0x17, 0x59, 0x2a, 0x1d, 0x1f, 0x0, 0xe, 0x32, 0x4, 0x96, 0x7f, 0x8f, 0x4a, 0xa0, + 0xf9, 0xcb, 0x14, 0x4b, 0xe4, 0xd2, 0xb5, 0x1c, 0x0, 0x17, 0xda, 0x69, 0x6d, 0x6c, 0x60, 0x75, 0xa, 0x95, 0xee, + 0x75, 0xc7, 0x1f, 0x16, 0x50, 0x2, 0x5c, 0x8e, 0x7e, 0xe8, 0xed, 0x11, 0x32, 0xf9, 0x21, 0x26, 0xa7, 0x2a, 0x78, + 0x11, 0x0, 0x0, 0x2d, 0x42, 0x2, 0x0, 0x0, 0x78, 0xa9, 0x11, 0x0, 0x0, 0x70, 0x42, 0x21, 0x6, 0x62, 0x26, + 0x0, 0x12, 0x2e, 0xab, 0xbb, 0x64, 0x0, 0xa4, 0xea, 0x3f, 0xc, 0x32, 0x10, 0x2, 0x69, 0x0, 0x4c, 0xa9, 0x5, + 0x68, 0x0, 0x7, 0xb7, 0x8c, 0x4e, 0x44, 0xb8, 0x2f, 0x86, 0x1c, 0x0, 0x8, 0xd8, 0xcc, 0xe7, 0xd6, 0x5e, 0x16, + 0x4c, 0xb3, 0x25, 0x58, 0x13, 0x4a, 0x97, 0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; + uint8_t topic_bytes[] = {0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, + 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x17, 0xa2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 11; - uint8_t bytesprops0[] = {0x3b, 0x4f, 0xe4, 0x6e, 0x2b, 0xb4, 0xc9, 0xa9, 0xab, 0xc4, 0xe1, 0x20, - 0x19, 0xe8, 0x3, 0x9b, 0x23, 0xf, 0x28, 0x9, 0x5b, 0x55, 0x75}; - uint8_t bytesprops2[] = {0xe7, 0xff, 0xd5, 0x6, 0x5b, 0x32, 0xcc, 0x36, 0xaf, 0xa9, 0xe4, 0xa8, 0xc3, 0xf6, 0x9c, - 0xbd, 0x29, 0xff, 0x35, 0xba, 0x87, 0xe, 0xd2, 0xf6, 0x49, 0x90, 0x43, 0x3a, 0xe1, 0xb3}; - uint8_t bytesprops1[] = {0xf9, 0xf5, 0x2, 0x57, 0xe4, 0x4a, 0x9d}; - uint8_t bytesprops4[] = {0x73, 0x73, 0xa4, 0x4, 0x98}; - uint8_t bytesprops3[] = {0x13, 0x7b, 0x2c, 0xb5, 0x1f, 0x50, 0xe5, 0xd3, 0x1c, 0x8a, 0xbd, - 0x2d, 0xf0, 0xdc, 0xcd, 0x80, 0x69, 0x9c, 0x60, 0x1b, 0x38}; - uint8_t bytesprops5[] = {0xdd, 0xdc, 0xba, 0xc2, 0x2f, 0x2, 0xf6, 0xbd, 0x3, 0x1, 0x3d, 0x27, 0x96, 0xbb, 0x24, 0x2d}; - uint8_t bytesprops6[] = {0xbb, 0x47, 0xa3, 0xc8, 0xc3, 0x5b, 0xd3, 0xcb, 0x5e, 0x0, 0x15, 0xef, 0xb8, 0x36, - 0x51, 0xb0, 0xb, 0xff, 0x9, 0x2c, 0xf6, 0xf6, 0x31, 0xac, 0xd8, 0xcf, 0x9}; - uint8_t bytesprops7[] = {0xf8, 0xb5, 0x77, 0xd5, 0xa6, 0xdb, 0xdd, 0xf7, 0x9f, 0xfe, 0xcc, 0xb3, 0xd5, 0x7c, - 0xf3, 0x49, 0x2, 0x61, 0xff, 0x8f, 0x77, 0x16, 0xd0, 0xdf, 0xda, 0xb9, 0x1b}; + uint8_t bytesprops0[] = {0x8a, 0xef, 0xe0, 0xaa, 0xd9, 0xc3, 0x57, 0x10, 0xf7, 0xf3, + 0xe5, 0x90, 0x4a, 0x43, 0xce, 0xd6, 0x9d, 0xd2, 0x8c, 0x79}; + uint8_t bytesprops1[] = {0x1d, 0x7b, 0xd3, 0x7f, 0x25, 0x54, 0x49, 0x1e, 0xf0, 0x9d, 0x85, 0xf1}; + uint8_t bytesprops2[] = {0x5e, 0x5, 0xf, 0x74, 0xb3, 0xd, 0xaf}; + uint8_t bytesprops3[] = {0x98, 0xb1, 0x6e, 0x57, 0x15, 0xcb, 0xb0, 0x58, 0x30, 0xaa, 0x58, 0xa4, + 0xbb, 0x6, 0xe4, 0x48, 0x34, 0x9d, 0x46, 0xf5, 0x16, 0xce, 0xa4}; + uint8_t bytesprops4[] = {0xe5, 0x4f, 0x44, 0x5e, 0x8c, 0xdf, 0x4, 0x10, 0x21, 0x3d, 0xb7, 0x8a, 0x5f, 0xbb, 0xe9, + 0x2e, 0xa2, 0xb, 0xa6, 0x83, 0xdd, 0xc, 0x6b, 0x40, 0xcd, 0xfb, 0xdb, 0xe1, 0x5d}; + uint8_t bytesprops5[] = {0x32, 0x4, 0x96, 0x7f, 0x8f, 0x4a, 0xa0, 0xf9, 0xcb, 0x14, 0x4b, 0xe4, 0xd2, 0xb5}; + uint8_t bytesprops6[] = {0xda, 0x69, 0x6d, 0x6c, 0x60, 0x75, 0xa, 0x95, 0xee, 0x75, 0xc7, 0x1f, + 0x16, 0x50, 0x2, 0x5c, 0x8e, 0x7e, 0xe8, 0xed, 0x11, 0x32, 0xf9}; + uint8_t bytesprops8[] = {0xb7, 0x8c, 0x4e, 0x44, 0xb8, 0x2f, 0x86}; + uint8_t bytesprops7[] = {0x2e, 0xab, 0xbb, 0x64, 0x0, 0xa4, 0xea, 0x3f, 0xc, + 0x32, 0x10, 0x2, 0x69, 0x0, 0x4c, 0xa9, 0x5, 0x68}; + uint8_t bytesprops9[] = {0xd8, 0xcc, 0xe7, 0xd6, 0x5e, 0x16, 0x4c, 0xb3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13370}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20364}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32386}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6843}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9980}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25125}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9895}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11586}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30889}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28738}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1634}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops7}, .v = {7, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19095}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10935, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "%\134\216", _pubPktID = 0, _pubBody -// = "\ETB\162T\161\139s\238\233\229.\233\243\186", _pubProps = [PropReceiveMaximum 13370,PropServerReference -// ";O\228n+\180\201\169\171\196\225 \EM\232\ETX\155#\SI(\t[Uu",PropPayloadFormatIndicator 134,PropUserProperty -// "\249\245\STXW\228J\157" -// "\231\255\213\ACK[2\204\&6\175\169\228\168\195\246\156\189)\255\&5\186\135\SO\210\246I\144C:\225\179",PropMaximumPacketSize -// 20364,PropUserProperty "\DC3{,\181\USP\229\211\FS\138\189-\240\220\205\128i\156`\ESC8" -// "ss\164\EOT\152",PropAuthenticationData "\221\220\186\194/\STX\246\189\ETX\SOH='\150\187$-",PropAuthenticationMethod -// "\187G\163\200\195[\211\203^\NUL\NAK\239\184\&6Q\176\v\255\t,\246\246\&1\172\216\207\t",PropReceiveMaximum -// 32386,PropRequestResponseInformation 185,PropServerReference -// "\248\181w\213\166\219\221\247\159\254\204\179\213|\243I\STXa\255\143w\SYN\208\223\218\185\ESC",PropMessageExpiryInterval -// 6843,PropRetainAvailable 210]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "Wo\249\180\STXZ\FS\218Co_\137a\140\&9^\232\186\143\230", _pubPktID = 10935, _pubBody = +// "\US\177vw\219K\147TS\150\&9", _pubProps = [PropRequestProblemInformation 50,PropMaximumQoS +// 128,PropRequestProblemInformation 117,PropSharedSubscriptionAvailable 34,PropRequestProblemInformation +// 176,PropResponseTopic "\138\239\224\170\217\195W\DLE\247\243\229\144JC\206\214\157\210\140y",PropServerReference +// "\GS{\211\DEL%TI\RS\240\157\133\241",PropCorrelationData "^\ENQ\SIt\179\r\175",PropTopicAliasMaximum +// 9980,PropSubscriptionIdentifier 13,PropRequestProblemInformation 141,PropRequestProblemInformation +// 157,PropServerKeepAlive 25125,PropServerReference +// "\152\177nW\NAK\203\176X0\170X\164\187\ACK\228H4\157F\245\SYN\206\164",PropAuthenticationData +// "\229OD^\140\223\EOT\DLE!=\183\138_\187\233.\162\v\166\131\221\fk@\205\251\219\225]",PropRequestProblemInformation +// 89,PropSharedSubscriptionAvailable 29,PropReasonString +// "2\EOT\150\DEL\143J\160\249\203\DC4K\228\210\181",PropServerReference +// "\218iml`u\n\149\238u\199\US\SYNP\STX\\\142~\232\237\DC12\249",PropReceiveMaximum +// 9895,PropSharedSubscriptionAvailable 120,PropSessionExpiryInterval 11586,PropMessageExpiryInterval +// 30889,PropSessionExpiryInterval 28738,PropReceiveMaximum 1634,PropUserProperty +// ".\171\187d\NUL\164\234?\f2\DLE\STXi\NULL\169\ENQh" "\183\140ND\184/\134",PropServerReference +// "\216\204\231\214^\SYNL\179",PropRetainAvailable 88,PropServerKeepAlive 19095]} TEST(Publish5QCTest, Decode21) { uint8_t pkt[] = { - 0x38, 0xdc, 0x1, 0x0, 0x3, 0x25, 0x86, 0xd8, 0xc8, 0x1, 0x21, 0x34, 0x3a, 0x1c, 0x0, 0x17, 0x3b, 0x4f, 0xe4, - 0x6e, 0x2b, 0xb4, 0xc9, 0xa9, 0xab, 0xc4, 0xe1, 0x20, 0x19, 0xe8, 0x3, 0x9b, 0x23, 0xf, 0x28, 0x9, 0x5b, 0x55, - 0x75, 0x1, 0x86, 0x26, 0x0, 0x7, 0xf9, 0xf5, 0x2, 0x57, 0xe4, 0x4a, 0x9d, 0x0, 0x1e, 0xe7, 0xff, 0xd5, 0x6, - 0x5b, 0x32, 0xcc, 0x36, 0xaf, 0xa9, 0xe4, 0xa8, 0xc3, 0xf6, 0x9c, 0xbd, 0x29, 0xff, 0x35, 0xba, 0x87, 0xe, 0xd2, - 0xf6, 0x49, 0x90, 0x43, 0x3a, 0xe1, 0xb3, 0x27, 0x0, 0x0, 0x4f, 0x8c, 0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 0x0, 0xa4, 0xea, 0x3f, 0xc, 0x32, 0x10, 0x2, 0x69, 0x0, 0x4c, 0xa9, 0x5, + 0x68, 0x0, 0x7, 0xb7, 0x8c, 0x4e, 0x44, 0xb8, 0x2f, 0x86, 0x1c, 0x0, 0x8, 0xd8, 0xcc, 0xe7, 0xd6, 0x5e, 0x16, + 0x4c, 0xb3, 0x25, 0x58, 0x13, 0x4a, 0x97, 0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4011,80 +4188,72 @@ TEST(Publish5QCTest, Decode21) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x25, 0x86, 0xd8}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x17, 0xa2, 0x54, 0xa1, 0x8b, 0x73, 0xee, 0xe9, 0xe5, 0x2e, 0xe9, 0xf3, 0xba}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, + 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 13); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10935); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\230\237\153c\242P\179\141\223\&2\205Z{\223\153", _pubPktID = 22947, _pubBody = -// "\195\148\247\&4\177\f%\149>q\236W\ETB-\a\209y\n\133o\172*:\131aY", _pubProps = [PropServerReference -// "\198\&6(\SOHH}",PropTopicAliasMaximum 11940,PropRetainAvailable 229,PropResponseInformation -// "\128\171w\200\170x:n*T\DC47xe&T\214\243\196\145\224E\222\226\148[\148\&27",PropSubscriptionIdentifierAvailable -// 153,PropRetainAvailable 170]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "z\187}l", _pubPktID = 11378, +// _pubBody = "\186\&7\190\f\178\235\212\242\166(\ENQ\181\SUB\234\&4\149H\SYN6\197\247\207", _pubProps = +// [PropMessageExpiryInterval 17405,PropTopicAlias 796,PropSubscriptionIdentifier 9,PropReasonString +// "\189\150\149\164v",PropMaximumPacketSize 27577,PropRetainAvailable 102,PropMaximumPacketSize 1224]} TEST(Publish5QCTest, Encode22) { - uint8_t pkt[] = {0x3a, 0x60, 0x0, 0xf, 0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, 0x7b, - 0xdf, 0x99, 0x59, 0xa3, 0x32, 0x1c, 0x0, 0x6, 0xc6, 0x36, 0x28, 0x1, 0x48, 0x7d, 0x22, 0x2e, 0xa4, - 0x25, 0xe5, 0x1a, 0x0, 0x1d, 0x80, 0xab, 0x77, 0xc8, 0xaa, 0x78, 0x3a, 0x6e, 0x2a, 0x54, 0x14, 0x37, - 0x78, 0x65, 0x26, 0x54, 0xd6, 0xf3, 0xc4, 0x91, 0xe0, 0x45, 0xde, 0xe2, 0x94, 0x5b, 0x94, 0x32, 0x37, - 0x29, 0x99, 0x25, 0xaa, 0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, - 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; - uint8_t topic_bytes[] = {0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, 0x7b, 0xdf, 0x99}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x3d, 0x0, 0x4, 0x7a, 0xbb, 0x7d, 0x6c, 0x2c, 0x72, 0x1e, 0x2, 0x0, 0x0, 0x43, 0xfd, + 0x23, 0x3, 0x1c, 0xb, 0x9, 0x1f, 0x0, 0x5, 0xbd, 0x96, 0x95, 0xa4, 0x76, 0x27, 0x0, 0x0, + 0x6b, 0xb9, 0x25, 0x66, 0x27, 0x0, 0x0, 0x4, 0xc8, 0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, + 0xf2, 0xa6, 0x28, 0x5, 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; + uint8_t topic_bytes[] = {0x7a, 0xbb, 0x7d, 0x6c}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, - 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + uint8_t msg_bytes[] = {0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, 0xf2, 0xa6, 0x28, 0x5, + 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 22; - uint8_t bytesprops0[] = {0xc6, 0x36, 0x28, 0x1, 0x48, 0x7d}; - uint8_t bytesprops1[] = {0x80, 0xab, 0x77, 0xc8, 0xaa, 0x78, 0x3a, 0x6e, 0x2a, 0x54, 0x14, 0x37, 0x78, 0x65, 0x26, - 0x54, 0xd6, 0xf3, 0xc4, 0x91, 0xe0, 0x45, 0xde, 0xe2, 0x94, 0x5b, 0x94, 0x32, 0x37}; + uint8_t bytesprops0[] = {0xbd, 0x96, 0x95, 0xa4, 0x76}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11940}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17405}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 796}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27577}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1224}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 22947, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 11378, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\230\237\153c\242P\179\141\223\&2\205Z{\223\153", _pubPktID = 22947, _pubBody = -// "\195\148\247\&4\177\f%\149>q\236W\ETB-\a\209y\n\133o\172*:\131aY", _pubProps = [PropServerReference -// "\198\&6(\SOHH}",PropTopicAliasMaximum 11940,PropRetainAvailable 229,PropResponseInformation -// "\128\171w\200\170x:n*T\DC47xe&T\214\243\196\145\224E\222\226\148[\148\&27",PropSubscriptionIdentifierAvailable -// 153,PropRetainAvailable 170]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "z\187}l", _pubPktID = 11378, +// _pubBody = "\186\&7\190\f\178\235\212\242\166(\ENQ\181\SUB\234\&4\149H\SYN6\197\247\207", _pubProps = +// [PropMessageExpiryInterval 17405,PropTopicAlias 796,PropSubscriptionIdentifier 9,PropReasonString +// "\189\150\149\164v",PropMaximumPacketSize 27577,PropRetainAvailable 102,PropMaximumPacketSize 1224]} TEST(Publish5QCTest, Decode22) { - uint8_t pkt[] = {0x3a, 0x60, 0x0, 0xf, 0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, 0xdf, 0x32, 0xcd, 0x5a, 0x7b, - 0xdf, 0x99, 0x59, 0xa3, 0x32, 0x1c, 0x0, 0x6, 0xc6, 0x36, 0x28, 0x1, 0x48, 0x7d, 0x22, 0x2e, 0xa4, - 0x25, 0xe5, 0x1a, 0x0, 0x1d, 0x80, 0xab, 0x77, 0xc8, 0xaa, 0x78, 0x3a, 0x6e, 0x2a, 0x54, 0x14, 0x37, - 0x78, 0x65, 0x26, 0x54, 0xd6, 0xf3, 0xc4, 0x91, 0xe0, 0x45, 0xde, 0xe2, 0x94, 0x5b, 0x94, 0x32, 0x37, - 0x29, 0x99, 0x25, 0xaa, 0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, - 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; + uint8_t pkt[] = {0x34, 0x3d, 0x0, 0x4, 0x7a, 0xbb, 0x7d, 0x6c, 0x2c, 0x72, 0x1e, 0x2, 0x0, 0x0, 0x43, 0xfd, + 0x23, 0x3, 0x1c, 0xb, 0x9, 0x1f, 0x0, 0x5, 0xbd, 0x96, 0x95, 0xa4, 0x76, 0x27, 0x0, 0x0, + 0x6b, 0xb9, 0x25, 0x66, 0x27, 0x0, 0x0, 0x4, 0xc8, 0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, + 0xf2, 0xa6, 0x28, 0x5, 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4092,74 +4261,151 @@ TEST(Publish5QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe6, 0xed, 0x99, 0x63, 0xf2, 0x50, 0xb3, 0x8d, - 0xdf, 0x32, 0xcd, 0x5a, 0x7b, 0xdf, 0x99}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc3, 0x94, 0xf7, 0x34, 0xb1, 0xc, 0x25, 0x95, 0x3e, 0x71, 0xec, 0x57, 0x17, - 0x2d, 0x7, 0xd1, 0x79, 0xa, 0x85, 0x6f, 0xac, 0x2a, 0x3a, 0x83, 0x61, 0x59}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x7a, 0xbb, 0x7d, 0x6c}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, 0xf2, 0xa6, 0x28, 0x5, + 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 22947); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(packet_id, 11378); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\159q1\146\234\232\173\FS`\184\186\140\SYN=Z", _pubPktID = 12817, _pubBody = "EJwh\185\236\204#\166", _pubProps = -// [PropWildcardSubscriptionAvailable 230,PropTopicAliasMaximum 13164,PropResponseInformation -// "f(\159\149\STX\ETB\146r\b\228\&1Y\255\ENQ\161\133\189\239l\195\227s\192",PropSubscriptionIdentifier -// 13,PropCorrelationData ""]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\252\190\&8\149\&2\128\192{C\128\194\197\170g\a_\DC4\DELI(\151\218\172\vBJ\234\221", _pubPktID = 0, _pubBody = +// "q\145\203\144\245\153\&3\220g\186\&9YVh\DEL\232\&2V\212\201\&4\172?\189S\159<\187W", _pubProps = +// [PropWildcardSubscriptionAvailable 68,PropReasonString "\231\STX\217\206C\164",PropServerKeepAlive +// 28798,PropAuthenticationData "\202\ETX1\130\NUL\184r\147\SYN\162\182)\226\v!m",PropRequestResponseInformation +// 255,PropContentType "\RS\STX\200B\190",PropResponseTopic "\218{",PropTopicAlias +// 31640,PropSubscriptionIdentifierAvailable 99,PropServerKeepAlive 9138,PropAuthenticationMethod +// "\240'\176\DC2=\ENQ\247H\176`\247\SOH\151Dj\220\GS4\132",PropUserProperty +// "`\157;)\RS\168\170G\SI\131\204z\251\SO#-\221tq\224" +// "DQ\194\246\165\220\230\217\222\SUB\160E\213P\"\156\211",PropWillDelayInterval 4096,PropRequestResponseInformation +// 25,PropReceiveMaximum 26707,PropAssignedClientIdentifier "e]\166a",PropAuthenticationMethod +// "\236\135\179\164I\DLEm\GS\189\155inmB",PropMessageExpiryInterval 8438,PropSharedSubscriptionAvailable +// 26,PropSubscriptionIdentifierAvailable 221,PropUserProperty "Q&z\242\130#\206\&2\225N\236\181d\233" +// "\182/^\246\211CZ\255",PropContentType +// "n\219S\144\134\181\223\145\184\193X\245\193\231\186\&3k\159\188\218\252\SUB\221\244zbNt3"]} TEST(Publish5QCTest, Encode23) { - uint8_t pkt[] = {0x33, 0x41, 0x0, 0xf, 0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, 0x8c, 0x16, - 0x3d, 0x5a, 0x32, 0x11, 0x24, 0x28, 0xe6, 0x22, 0x33, 0x6c, 0x1a, 0x0, 0x17, 0x66, 0x28, 0x9f, 0x95, - 0x2, 0x17, 0x92, 0x72, 0x8, 0xe4, 0x31, 0x59, 0xff, 0x5, 0xa1, 0x85, 0xbd, 0xef, 0x6c, 0xc3, 0xe3, - 0x73, 0xc0, 0xb, 0xd, 0x9, 0x0, 0x0, 0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; - uint8_t topic_bytes[] = {0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, 0x8c, 0x16, 0x3d, 0x5a}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x9b, 0x2, 0x0, 0x1c, 0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, + 0xaa, 0x67, 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd, 0xde, + 0x1, 0x28, 0x44, 0x1f, 0x0, 0x6, 0xe7, 0x2, 0xd9, 0xce, 0x43, 0xa4, 0x13, 0x70, 0x7e, 0x16, 0x0, + 0x10, 0xca, 0x3, 0x31, 0x82, 0x0, 0xb8, 0x72, 0x93, 0x16, 0xa2, 0xb6, 0x29, 0xe2, 0xb, 0x21, 0x6d, + 0x19, 0xff, 0x3, 0x0, 0x5, 0x1e, 0x2, 0xc8, 0x42, 0xbe, 0x8, 0x0, 0x2, 0xda, 0x7b, 0x23, 0x7b, + 0x98, 0x29, 0x63, 0x13, 0x23, 0xb2, 0x15, 0x0, 0x13, 0xf0, 0x27, 0xb0, 0x12, 0x3d, 0x5, 0xf7, 0x48, + 0xb0, 0x60, 0xf7, 0x1, 0x97, 0x44, 0x6a, 0xdc, 0x1d, 0x34, 0x84, 0x26, 0x0, 0x14, 0x60, 0x9d, 0x3b, + 0x29, 0x1e, 0xa8, 0xaa, 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0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + uint8_t msg_bytes[] = {0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, + 0xe8, 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 29; - uint8_t bytesprops0[] = {0x66, 0x28, 0x9f, 0x95, 0x2, 0x17, 0x92, 0x72, 0x8, 0xe4, 0x31, 0x59, - 0xff, 0x5, 0xa1, 0x85, 0xbd, 0xef, 0x6c, 0xc3, 0xe3, 0x73, 0xc0}; - uint8_t bytesprops1[] = {0}; + uint8_t bytesprops0[] = {0xe7, 0x2, 0xd9, 0xce, 0x43, 0xa4}; + uint8_t bytesprops1[] = {0xca, 0x3, 0x31, 0x82, 0x0, 0xb8, 0x72, 0x93, 0x16, 0xa2, 0xb6, 0x29, 0xe2, 0xb, 0x21, 0x6d}; + uint8_t bytesprops2[] = {0x1e, 0x2, 0xc8, 0x42, 0xbe}; + uint8_t bytesprops3[] = {0xda, 0x7b}; + uint8_t bytesprops4[] = {0xf0, 0x27, 0xb0, 0x12, 0x3d, 0x5, 0xf7, 0x48, 0xb0, 0x60, + 0xf7, 0x1, 0x97, 0x44, 0x6a, 0xdc, 0x1d, 0x34, 0x84}; + uint8_t bytesprops6[] = {0x44, 0x51, 0xc2, 0xf6, 0xa5, 0xdc, 0xe6, 0xd9, 0xde, + 0x1a, 0xa0, 0x45, 0xd5, 0x50, 0x22, 0x9c, 0xd3}; + uint8_t bytesprops5[] = {0x60, 0x9d, 0x3b, 0x29, 0x1e, 0xa8, 0xaa, 0x47, 0xf, 0x83, + 0xcc, 0x7a, 0xfb, 0xe, 0x23, 0x2d, 0xdd, 0x74, 0x71, 0xe0}; + uint8_t bytesprops7[] = {0x65, 0x5d, 0xa6, 0x61}; + uint8_t bytesprops8[] = {0xec, 0x87, 0xb3, 0xa4, 0x49, 0x10, 0x6d, 0x1d, 0xbd, 0x9b, 0x69, 0x6e, 0x6d, 0x42}; + uint8_t bytesprops10[] = {0xb6, 0x2f, 0x5e, 0xf6, 0xd3, 0x43, 0x5a, 0xff}; + uint8_t bytesprops9[] = {0x51, 0x26, 0x7a, 0xf2, 0x82, 0x23, 0xce, 0x32, 0xe1, 0x4e, 0xec, 0xb5, 0x64, 0xe9}; + uint8_t bytesprops11[] = {0x6e, 0xdb, 0x53, 0x90, 0x86, 0xb5, 0xdf, 0x91, 0xb8, 0xc1, 0x58, 0xf5, 0xc1, 0xe7, 0xba, + 0x33, 0x6b, 0x9f, 0xbc, 0xda, 0xfc, 0x1a, 0xdd, 0xf4, 0x7a, 0x62, 0x4e, 0x74, 0x33}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13164}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28798}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31640}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9138}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops5}, .v = {17, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4096}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26707}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8438}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops9}, .v = {8, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 12817, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\159q1\146\234\232\173\FS`\184\186\140\SYN=Z", _pubPktID = 12817, _pubBody = "EJwh\185\236\204#\166", _pubProps = -// [PropWildcardSubscriptionAvailable 230,PropTopicAliasMaximum 13164,PropResponseInformation -// "f(\159\149\STX\ETB\146r\b\228\&1Y\255\ENQ\161\133\189\239l\195\227s\192",PropSubscriptionIdentifier -// 13,PropCorrelationData ""]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\252\190\&8\149\&2\128\192{C\128\194\197\170g\a_\DC4\DELI(\151\218\172\vBJ\234\221", _pubPktID = 0, _pubBody = +// "q\145\203\144\245\153\&3\220g\186\&9YVh\DEL\232\&2V\212\201\&4\172?\189S\159<\187W", _pubProps = +// [PropWildcardSubscriptionAvailable 68,PropReasonString "\231\STX\217\206C\164",PropServerKeepAlive +// 28798,PropAuthenticationData "\202\ETX1\130\NUL\184r\147\SYN\162\182)\226\v!m",PropRequestResponseInformation +// 255,PropContentType "\RS\STX\200B\190",PropResponseTopic "\218{",PropTopicAlias +// 31640,PropSubscriptionIdentifierAvailable 99,PropServerKeepAlive 9138,PropAuthenticationMethod +// "\240'\176\DC2=\ENQ\247H\176`\247\SOH\151Dj\220\GS4\132",PropUserProperty +// "`\157;)\RS\168\170G\SI\131\204z\251\SO#-\221tq\224" +// "DQ\194\246\165\220\230\217\222\SUB\160E\213P\"\156\211",PropWillDelayInterval 4096,PropRequestResponseInformation +// 25,PropReceiveMaximum 26707,PropAssignedClientIdentifier "e]\166a",PropAuthenticationMethod +// "\236\135\179\164I\DLEm\GS\189\155inmB",PropMessageExpiryInterval 8438,PropSharedSubscriptionAvailable +// 26,PropSubscriptionIdentifierAvailable 221,PropUserProperty "Q&z\242\130#\206\&2\225N\236\181d\233" +// "\182/^\246\211CZ\255",PropContentType +// "n\219S\144\134\181\223\145\184\193X\245\193\231\186\&3k\159\188\218\252\SUB\221\244zbNt3"]} TEST(Publish5QCTest, Decode23) { - uint8_t pkt[] = {0x33, 0x41, 0x0, 0xf, 0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, 0x60, 0xb8, 0xba, 0x8c, 0x16, - 0x3d, 0x5a, 0x32, 0x11, 0x24, 0x28, 0xe6, 0x22, 0x33, 0x6c, 0x1a, 0x0, 0x17, 0x66, 0x28, 0x9f, 0x95, - 0x2, 0x17, 0x92, 0x72, 0x8, 0xe4, 0x31, 0x59, 0xff, 0x5, 0xa1, 0x85, 0xbd, 0xef, 0x6c, 0xc3, 0xe3, - 0x73, 0xc0, 0xb, 0xd, 0x9, 0x0, 0x0, 0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; + uint8_t pkt[] = {0x39, 0x9b, 0x2, 0x0, 0x1c, 0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, + 0xaa, 0x67, 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd, 0xde, + 0x1, 0x28, 0x44, 0x1f, 0x0, 0x6, 0xe7, 0x2, 0xd9, 0xce, 0x43, 0xa4, 0x13, 0x70, 0x7e, 0x16, 0x0, + 0x10, 0xca, 0x3, 0x31, 0x82, 0x0, 0xb8, 0x72, 0x93, 0x16, 0xa2, 0xb6, 0x29, 0xe2, 0xb, 0x21, 0x6d, + 0x19, 0xff, 0x3, 0x0, 0x5, 0x1e, 0x2, 0xc8, 0x42, 0xbe, 0x8, 0x0, 0x2, 0xda, 0x7b, 0x23, 0x7b, + 0x98, 0x29, 0x63, 0x13, 0x23, 0xb2, 0x15, 0x0, 0x13, 0xf0, 0x27, 0xb0, 0x12, 0x3d, 0x5, 0xf7, 0x48, + 0xb0, 0x60, 0xf7, 0x1, 0x97, 0x44, 0x6a, 0xdc, 0x1d, 0x34, 0x84, 0x26, 0x0, 0x14, 0x60, 0x9d, 0x3b, + 0x29, 0x1e, 0xa8, 0xaa, 0x47, 0xf, 0x83, 0xcc, 0x7a, 0xfb, 0xe, 0x23, 0x2d, 0xdd, 0x74, 0x71, 0xe0, + 0x0, 0x11, 0x44, 0x51, 0xc2, 0xf6, 0xa5, 0xdc, 0xe6, 0xd9, 0xde, 0x1a, 0xa0, 0x45, 0xd5, 0x50, 0x22, + 0x9c, 0xd3, 0x18, 0x0, 0x0, 0x10, 0x0, 0x19, 0x19, 0x21, 0x68, 0x53, 0x12, 0x0, 0x4, 0x65, 0x5d, + 0xa6, 0x61, 0x15, 0x0, 0xe, 0xec, 0x87, 0xb3, 0xa4, 0x49, 0x10, 0x6d, 0x1d, 0xbd, 0x9b, 0x69, 0x6e, + 0x6d, 0x42, 0x2, 0x0, 0x0, 0x20, 0xf6, 0x2a, 0x1a, 0x29, 0xdd, 0x26, 0x0, 0xe, 0x51, 0x26, 0x7a, + 0xf2, 0x82, 0x23, 0xce, 0x32, 0xe1, 0x4e, 0xec, 0xb5, 0x64, 0xe9, 0x0, 0x8, 0xb6, 0x2f, 0x5e, 0xf6, + 0xd3, 0x43, 0x5a, 0xff, 0x3, 0x0, 0x1d, 0x6e, 0xdb, 0x53, 0x90, 0x86, 0xb5, 0xdf, 0x91, 0xb8, 0xc1, + 0x58, 0xf5, 0xc1, 0xe7, 0xba, 0x33, 0x6b, 0x9f, 0xbc, 0xda, 0xfc, 0x1a, 0xdd, 0xf4, 0x7a, 0x62, 0x4e, + 0x74, 0x33, 0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, + 0xe8, 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4167,96 +4413,90 @@ TEST(Publish5QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9f, 0x71, 0x31, 0x92, 0xea, 0xe8, 0xad, 0x1c, - 0x60, 0xb8, 0xba, 0x8c, 0x16, 0x3d, 0x5a}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x45, 0x4a, 0x77, 0x68, 0xb9, 0xec, 0xcc, 0x23, 0xa6}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, 0xaa, 0x67, + 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, + 0xe8, 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 12817); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "7_", _pubPktID = 0, _pubBody = -// "1l\172\222\&2J\173\154BN|", _pubProps = [PropAuthenticationData "N\249\ESC\DC4\178\165l\GS\193 -// @\237\FSc\130\US\168L\221\212\134M\184\177",PropServerReference -// "\229\142\151\208\141\194\159xc\240\176\128+N\215xB>\239\174",PropTopicAliasMaximum 26288,PropCorrelationData -// "\ESCK\213\ETXj\232~\r\137\200>",PropMaximumPacketSize 9064,PropResponseTopic -// "\131\226]\251:\231\173\211:9^\ESC\153\165\ACK\175\199\CAN\248H[",PropUserProperty "C" -// "\SO\ETX\187\233\164mYM\130\&6\v\150\178\186K\203\179m\"\201\&6\129"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\a\159\222j\236\175\242\&158\148@P\139o\150c\EOT\191\131\204\SUB\205\201\135W\193a", _pubPktID = 24983, _pubBody = +// "\214M\130;K\239#\136V\STX\242C\n\153\208l\129s\196\171\DC1P\193\218\128", _pubProps = [PropMaximumPacketSize +// 32111,PropRetainAvailable 32,PropRetainAvailable 253,PropTopicAliasMaximum 1404,PropCorrelationData +// "x\249\211d\150\172<\EM\159*\CAN\172\\\145\178\202jA",PropWillDelayInterval 999,PropTopicAliasMaximum +// 3052,PropResponseInformation "\244\153\172\&7\n\136=_\169\156S2\183\143\167S\185\220O\133\144\252\&4\230\180W\202"]} TEST(Publish5QCTest, Encode24) { - uint8_t pkt[] = {0x30, 0x8c, 0x1, 0x0, 0x2, 0x37, 0x5f, 0x7c, 0x16, 0x0, 0x18, 0x4e, 0xf9, 0x1b, 0x14, 0xb2, - 0xa5, 0x6c, 0x1d, 0xc1, 0x20, 0x40, 0xed, 0x1c, 0x63, 0x82, 0x1f, 0xa8, 0x4c, 0xdd, 0xd4, 0x86, - 0x4d, 0xb8, 0xb1, 0x1c, 0x0, 0x14, 0xe5, 0x8e, 0x97, 0xd0, 0x8d, 0xc2, 0x9f, 0x78, 0x63, 0xf0, - 0xb0, 0x80, 0x2b, 0x4e, 0xd7, 0x78, 0x42, 0x3e, 0xef, 0xae, 0x22, 0x66, 0xb0, 0x9, 0x0, 0xb, - 0x1b, 0x4b, 0xd5, 0x3, 0x6a, 0xe8, 0x7e, 0xd, 0x89, 0xc8, 0x3e, 0x27, 0x0, 0x0, 0x23, 0x68, - 0x8, 0x0, 0x15, 0x83, 0xe2, 0x5d, 0xfb, 0x3a, 0xe7, 0xad, 0xd3, 0x3a, 0x39, 0x5e, 0x1b, 0x99, - 0xa5, 0x6, 0xaf, 0xc7, 0x18, 0xf8, 0x48, 0x5b, 0x26, 0x0, 0x1, 0x43, 0x0, 0x16, 0xe, 0x3, - 0xbb, 0xe9, 0xa4, 0x6d, 0x59, 0x4d, 0x82, 0x36, 0xb, 0x96, 0xb2, 0xba, 0x4b, 0xcb, 0xb3, 0x6d, - 0x22, 0xc9, 0x36, 0x81, 0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; - uint8_t topic_bytes[] = {0x37, 0x5f}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x81, 0x1, 0x0, 0x1c, 0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, + 0x50, 0x8b, 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61, 0x61, + 0x97, 0x47, 0x27, 0x0, 0x0, 0x7d, 0x6f, 0x25, 0x20, 0x25, 0xfd, 0x22, 0x5, 0x7c, 0x9, 0x0, 0x12, + 0x78, 0xf9, 0xd3, 0x64, 0x96, 0xac, 0x3c, 0x19, 0x9f, 0x2a, 0x18, 0xac, 0x5c, 0x91, 0xb2, 0xca, 0x6a, + 0x41, 0x18, 0x0, 0x0, 0x3, 0xe7, 0x22, 0xb, 0xec, 0x1a, 0x0, 0x1b, 0xf4, 0x99, 0xac, 0x37, 0xa, + 0x88, 0x3d, 0x5f, 0xa9, 0x9c, 0x53, 0x32, 0xb7, 0x8f, 0xa7, 0x53, 0xb9, 0xdc, 0x4f, 0x85, 0x90, 0xfc, + 0x34, 0xe6, 0xb4, 0x57, 0xca, 0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, + 0xa, 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; + uint8_t topic_bytes[] = {0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, 0x50, 0x8b, + 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, 0xa, + 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 25; - uint8_t bytesprops0[] = {0x4e, 0xf9, 0x1b, 0x14, 0xb2, 0xa5, 0x6c, 0x1d, 0xc1, 0x20, 0x40, 0xed, - 0x1c, 0x63, 0x82, 0x1f, 0xa8, 0x4c, 0xdd, 0xd4, 0x86, 0x4d, 0xb8, 0xb1}; - uint8_t bytesprops1[] = {0xe5, 0x8e, 0x97, 0xd0, 0x8d, 0xc2, 0x9f, 0x78, 0x63, 0xf0, - 0xb0, 0x80, 0x2b, 0x4e, 0xd7, 0x78, 0x42, 0x3e, 0xef, 0xae}; - uint8_t bytesprops2[] = {0x1b, 0x4b, 0xd5, 0x3, 0x6a, 0xe8, 0x7e, 0xd, 0x89, 0xc8, 0x3e}; - uint8_t bytesprops3[] = {0x83, 0xe2, 0x5d, 0xfb, 0x3a, 0xe7, 0xad, 0xd3, 0x3a, 0x39, 0x5e, - 0x1b, 0x99, 0xa5, 0x6, 0xaf, 0xc7, 0x18, 0xf8, 0x48, 0x5b}; - uint8_t bytesprops5[] = {0xe, 0x3, 0xbb, 0xe9, 0xa4, 0x6d, 0x59, 0x4d, 0x82, 0x36, 0xb, - 0x96, 0xb2, 0xba, 0x4b, 0xcb, 0xb3, 0x6d, 0x22, 0xc9, 0x36, 0x81}; - uint8_t bytesprops4[] = {0x43}; + uint8_t bytesprops0[] = {0x78, 0xf9, 0xd3, 0x64, 0x96, 0xac, 0x3c, 0x19, 0x9f, + 0x2a, 0x18, 0xac, 0x5c, 0x91, 0xb2, 0xca, 0x6a, 0x41}; + uint8_t bytesprops1[] = {0xf4, 0x99, 0xac, 0x37, 0xa, 0x88, 0x3d, 0x5f, 0xa9, 0x9c, 0x53, 0x32, 0xb7, 0x8f, + 0xa7, 0x53, 0xb9, 0xdc, 0x4f, 0x85, 0x90, 0xfc, 0x34, 0xe6, 0xb4, 0x57, 0xca}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26288}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9064}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops4}, .v = {22, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32111}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1404}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 999}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3052}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24983, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "7_", _pubPktID = 0, _pubBody = -// "1l\172\222\&2J\173\154BN|", _pubProps = [PropAuthenticationData "N\249\ESC\DC4\178\165l\GS\193 -// @\237\FSc\130\US\168L\221\212\134M\184\177",PropServerReference -// "\229\142\151\208\141\194\159xc\240\176\128+N\215xB>\239\174",PropTopicAliasMaximum 26288,PropCorrelationData -// "\ESCK\213\ETXj\232~\r\137\200>",PropMaximumPacketSize 9064,PropResponseTopic -// "\131\226]\251:\231\173\211:9^\ESC\153\165\ACK\175\199\CAN\248H[",PropUserProperty "C" -// "\SO\ETX\187\233\164mYM\130\&6\v\150\178\186K\203\179m\"\201\&6\129"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\a\159\222j\236\175\242\&158\148@P\139o\150c\EOT\191\131\204\SUB\205\201\135W\193a", _pubPktID = 24983, _pubBody = +// "\214M\130;K\239#\136V\STX\242C\n\153\208l\129s\196\171\DC1P\193\218\128", _pubProps = [PropMaximumPacketSize +// 32111,PropRetainAvailable 32,PropRetainAvailable 253,PropTopicAliasMaximum 1404,PropCorrelationData +// "x\249\211d\150\172<\EM\159*\CAN\172\\\145\178\202jA",PropWillDelayInterval 999,PropTopicAliasMaximum +// 3052,PropResponseInformation "\244\153\172\&7\n\136=_\169\156S2\183\143\167S\185\220O\133\144\252\&4\230\180W\202"]} TEST(Publish5QCTest, Decode24) { - uint8_t pkt[] = {0x30, 0x8c, 0x1, 0x0, 0x2, 0x37, 0x5f, 0x7c, 0x16, 0x0, 0x18, 0x4e, 0xf9, 0x1b, 0x14, 0xb2, - 0xa5, 0x6c, 0x1d, 0xc1, 0x20, 0x40, 0xed, 0x1c, 0x63, 0x82, 0x1f, 0xa8, 0x4c, 0xdd, 0xd4, 0x86, - 0x4d, 0xb8, 0xb1, 0x1c, 0x0, 0x14, 0xe5, 0x8e, 0x97, 0xd0, 0x8d, 0xc2, 0x9f, 0x78, 0x63, 0xf0, - 0xb0, 0x80, 0x2b, 0x4e, 0xd7, 0x78, 0x42, 0x3e, 0xef, 0xae, 0x22, 0x66, 0xb0, 0x9, 0x0, 0xb, - 0x1b, 0x4b, 0xd5, 0x3, 0x6a, 0xe8, 0x7e, 0xd, 0x89, 0xc8, 0x3e, 0x27, 0x0, 0x0, 0x23, 0x68, - 0x8, 0x0, 0x15, 0x83, 0xe2, 0x5d, 0xfb, 0x3a, 0xe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da, 0x80}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4264,63 +4504,97 @@ TEST(Publish5QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x37, 0x5f}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x31, 0x6c, 0xac, 0xde, 0x32, 0x4a, 0xad, 0x9a, 0x42, 0x4e, 0x7c}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, 0x50, 0x8b, + 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, 0xa, + 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 24983); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\246\202\200\133Ey", _pubPktID = -// 19152, _pubBody = "G\255\&5Bg\183\227x}.\158X\246mx\199u\250\US\ETXI\ENQ\249\155!rJ", _pubProps = -// [PropResponseInformation "L\GS\243\ACK\r\226\138b\173\209\243\214"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "[5,\230\144\137\236\202\179\STX\t\201\234\136\166", _pubPktID = 10487, _pubBody = +// "\DLE\ACK\165~\155\217?\249\195\GS\145\179=i'\223Wd\159\248<\223$", _pubProps = [PropRequestProblemInformation +// 2,PropMessageExpiryInterval 7090,PropReceiveMaximum 29985,PropAssignedClientIdentifier +// "\160C\a\133\158\SIJ\234\136\148+\213\192\173\145\229\SYN\DC3\207",PropMaximumPacketSize +// 1098,PropSubscriptionIdentifier 14,PropCorrelationData +// "\134\FS\151\177\150V\134V6K\226\159\253\151|\130",PropResponseInformation +// "Xy\206_\178c\154\197\a\227<\169\NAK\CAN\178\ETX",PropMessageExpiryInterval 11931,PropTopicAlias 6873]} TEST(Publish5QCTest, Encode25) { - uint8_t pkt[] = {0x35, 0x35, 0x0, 0x6, 0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79, 0x4a, 0xd0, 0xf, 0x1a, - 0x0, 0xc, 0x4c, 0x1d, 0xf3, 0x6, 0xd, 0xe2, 0x8a, 0x62, 0xad, 0xd1, 0xf3, 0xd6, - 0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, - 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; - uint8_t topic_bytes[] = {0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x80, 0x1, 0x0, 0xf, 0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, 0xc9, + 0xea, 0x88, 0xa6, 0x28, 0xf7, 0x55, 0x17, 0x2, 0x2, 0x0, 0x0, 0x1b, 0xb2, 0x21, 0x75, 0x21, 0x12, + 0x0, 0x13, 0xa0, 0x43, 0x7, 0x85, 0x9e, 0xf, 0x4a, 0xea, 0x88, 0x94, 0x2b, 0xd5, 0xc0, 0xad, 0x91, + 0xe5, 0x16, 0x13, 0xcf, 0x27, 0x0, 0x0, 0x4, 0x4a, 0xb, 0xe, 0x9, 0x0, 0x10, 0x86, 0x1c, 0x97, + 0xb1, 0x96, 0x56, 0x86, 0x56, 0x36, 0x4b, 0xe2, 0x9f, 0xfd, 0x97, 0x7c, 0x82, 0x1a, 0x0, 0x10, 0x58, + 0x79, 0xce, 0x5f, 0xb2, 0x63, 0x9a, 0xc5, 0x7, 0xe3, 0x3c, 0xa9, 0x15, 0x18, 0xb2, 0x3, 0x2, 0x0, + 0x0, 0x2e, 0x9b, 0x23, 0x1a, 0xd9, 0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, 0x1d, 0x91, + 0xb3, 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; + uint8_t topic_bytes[] = {0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, 0xc9, 0xea, 0x88, 0xa6}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, - 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; + msg.retained = false; + uint8_t msg_bytes[] = {0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, 0x1d, 0x91, 0xb3, + 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 23; - uint8_t bytesprops0[] = {0x4c, 0x1d, 0xf3, 0x6, 0xd, 0xe2, 0x8a, 0x62, 0xad, 0xd1, 0xf3, 0xd6}; + uint8_t bytesprops0[] = {0xa0, 0x43, 0x7, 0x85, 0x9e, 0xf, 0x4a, 0xea, 0x88, 0x94, + 0x2b, 0xd5, 0xc0, 0xad, 0x91, 0xe5, 0x16, 0x13, 0xcf}; + uint8_t bytesprops1[] = {0x86, 0x1c, 0x97, 0xb1, 0x96, 0x56, 0x86, 0x56, + 0x36, 0x4b, 0xe2, 0x9f, 0xfd, 0x97, 0x7c, 0x82}; + uint8_t bytesprops2[] = {0x58, 0x79, 0xce, 0x5f, 0xb2, 0x63, 0x9a, 0xc5, + 0x7, 0xe3, 0x3c, 0xa9, 0x15, 0x18, 0xb2, 0x3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7090}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29985}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1098}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11931}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6873}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19152, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10487, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\246\202\200\133Ey", _pubPktID = -// 19152, _pubBody = "G\255\&5Bg\183\227x}.\158X\246mx\199u\250\US\ETXI\ENQ\249\155!rJ", _pubProps = -// [PropResponseInformation "L\GS\243\ACK\r\226\138b\173\209\243\214"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "[5,\230\144\137\236\202\179\STX\t\201\234\136\166", _pubPktID = 10487, _pubBody = +// "\DLE\ACK\165~\155\217?\249\195\GS\145\179=i'\223Wd\159\248<\223$", _pubProps = [PropRequestProblemInformation +// 2,PropMessageExpiryInterval 7090,PropReceiveMaximum 29985,PropAssignedClientIdentifier +// "\160C\a\133\158\SIJ\234\136\148+\213\192\173\145\229\SYN\DC3\207",PropMaximumPacketSize +// 1098,PropSubscriptionIdentifier 14,PropCorrelationData +// "\134\FS\151\177\150V\134V6K\226\159\253\151|\130",PropResponseInformation +// "Xy\206_\178c\154\197\a\227<\169\NAK\CAN\178\ETX",PropMessageExpiryInterval 11931,PropTopicAlias 6873]} TEST(Publish5QCTest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x9f, 0xf8, 0x3c, 0xdf, 0x24}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4328,167 +4602,124 @@ TEST(Publish5QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf6, 0xca, 0xc8, 0x85, 0x45, 0x79}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x47, 0xff, 0x35, 0x42, 0x67, 0xb7, 0xe3, 0x78, 0x7d, 0x2e, 0x9e, 0x58, 0xf6, 0x6d, - 0x78, 0xc7, 0x75, 0xfa, 0x1f, 0x3, 0x49, 0x5, 0xf9, 0x9b, 0x21, 0x72, 0x4a}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, 0xc9, 0xea, 0x88, 0xa6}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, 0x1d, 0x91, 0xb3, + 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 19152); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 27); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 10487); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\\\211\215", _pubPktID = 7594, -// _pubBody = "\139\150\137\180\142\209{^\232\155\136\252\140\233\138", _pubProps = [PropMaximumQoS -// 183,PropWildcardSubscriptionAvailable 166,PropResponseInformation -// "\NAK\a\164$\"\164\FS\183\221N\133Vq",PropResponseTopic -// "\181\172\134\252\225C\136I\NAKC\139\151\128F\139\ESCpr\219kB\GS",PropResponseInformation -// "xY\251\200Q*\230\222>\186X:\188\217\161f5#\186\186\249\DC3\142\137y\NAK",PropRequestResponseInformation -// 180,PropSubscriptionIdentifierAvailable 102,PropWillDelayInterval 18867,PropMessageExpiryInterval -// 9600,PropContentType "5G\139\SUB\SI%\246K+\166\181\SUB>\194\SOHSG\207,X\186l\DC2\164R",PropWillDelayInterval -// 11214,PropResponseTopic -// "8\225\206\&8\206P\134lK\153\143>\156\SYN\208]1\185\SOM\t\195r\219\&2\159\US\206\GS^",PropMessageExpiryInterval -// 24117,PropAuthenticationMethod "\DC2J\251\224p\NAK",PropTopicAlias 22040,PropWillDelayInterval -// 5953,PropMaximumPacketSize 17987,PropResponseTopic -// "\231\191\180\EM~\SYN\231\248&\228\173u'\186\217\200\239\210\209\154=8\RS\211\239?\212\202",PropAuthenticationMethod -// "\176\ETB\\z1\b\139\177{l\DC1\171T\154C\203&\201\242\142\201\151F\182##",PropContentType -// "\171(\154\&0\185i\161\209s\182\GS",PropMaximumQoS 189,PropWillDelayInterval 15657,PropMaximumQoS -// 121,PropReceiveMaximum 23342,PropUserProperty "\135\183u\196Q_\250\164\vvW\210A" -// ",_\CAN@\248\181^\174\176e1",PropCorrelationData "\247\167:\230\166\157",PropRequestResponseInformation -// 132,PropServerKeepAlive 19343]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "n\145", _pubPktID = 14089, _pubBody +// = "\210\210>L\150\rD\161j\204SG\219\226\165\205k\208\&4\ENQ\154t\DC1\148D:\US<\141\149", _pubProps = +// [PropPayloadFormatIndicator 11,PropAssignedClientIdentifier "\165\GSO\DELW\209\USY^",PropRequestResponseInformation +// 199,PropSubscriptionIdentifier 7,PropAssignedClientIdentifier "\233e\ACK\242\245\135\207\178\189",PropReasonString +// "\159+\203\173\DC3\r\216\165\200\SOH\226$h\171U\179=\189Pq%\211\188x\238\176\169a\201\DC3",PropResponseTopic +// "\ETX\231w+ \ETX\128\252W-\164\228FQ\198\231\140\149\128\US",PropWildcardSubscriptionAvailable +// 86,PropPayloadFormatIndicator 11,PropSubscriptionIdentifierAvailable 130,PropMessageExpiryInterval +// 14783,PropSubscriptionIdentifierAvailable 113,PropRetainAvailable 223,PropResponseInformation +// "\130\SYN2\226\210\n\165\220\STX\175\235j\STX\US",PropRequestProblemInformation 97,PropCorrelationData +// "t\237j\DLE6\227\210\EM\STX\NUL]\FS\215\FS\202w\250N\CAN\217\199\192+",PropReasonString +// "\176\vb\216s\FS\175cQIq6t\183#\170\149\149\218o"]} TEST(Publish5QCTest, Encode26) { - uint8_t pkt[] = { - 0x3c, 0xce, 0x2, 0x0, 0x3, 0x5c, 0xd3, 0xd7, 0x1d, 0xaa, 0xb6, 0x2, 0x24, 0xb7, 0x28, 0xa6, 0x1a, 0x0, 0xd, - 0x15, 0x7, 0xa4, 0x24, 0x22, 0xa4, 0x1c, 0xb7, 0xdd, 0x4e, 0x85, 0x56, 0x71, 0x8, 0x0, 0x16, 0xb5, 0xac, 0x86, - 0xfc, 0xe1, 0x43, 0x88, 0x49, 0x15, 0x43, 0x8b, 0x97, 0x80, 0x46, 0x8b, 0x1b, 0x70, 0x72, 0xdb, 0x6b, 0x42, 0x1d, - 0x1a, 0x0, 0x1a, 0x78, 0x59, 0xfb, 0xc8, 0x51, 0x2a, 0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x3, 0x0, 0xb, 0xab, 0x28, 0x9a, 0x30, 0xb9, 0x69, 0xa1, 0xd1, 0x73, 0xb6, - 0x1d, 0x24, 0xbd, 0x18, 0x0, 0x0, 0x3d, 0x29, 0x24, 0x79, 0x21, 0x5b, 0x2e, 0x26, 0x0, 0xd, 0x87, 0xb7, 0x75, - 0xc4, 0x51, 0x5f, 0xfa, 0xa4, 0xb, 0x76, 0x57, 0xd2, 0x41, 0x0, 0xb, 0x2c, 0x5f, 0x18, 0x40, 0xf8, 0xb5, 0x5e, - 0xae, 0xb0, 0x65, 0x31, 0x9, 0x0, 0x6, 0xf7, 0xa7, 0x3a, 0xe6, 0xa6, 0x9d, 0x19, 0x84, 0x13, 0x4b, 0x8f, 0x8b, - 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; - uint8_t topic_bytes[] = {0x5c, 0xd3, 0xd7}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0xcf, 0x1, 0x0, 0x2, 0x6e, 0x91, 0x37, 0x9, 0xa9, 0x1, 0x1, 0xb, 0x12, 0x0, 0x9, 0xa5, + 0x1d, 0x4f, 0x7f, 0x57, 0xd1, 0x1f, 0x59, 0x5e, 0x19, 0xc7, 0xb, 0x7, 0x12, 0x0, 0x9, 0xe9, 0x65, + 0x6, 0xf2, 0xf5, 0x87, 0xcf, 0xb2, 0xbd, 0x1f, 0x0, 0x1e, 0x9f, 0x2b, 0xcb, 0xad, 0x13, 0xd, 0xd8, + 0xa5, 0xc8, 0x1, 0xe2, 0x24, 0x68, 0xab, 0x55, 0xb3, 0x3d, 0xbd, 0x50, 0x71, 0x25, 0xd3, 0xbc, 0x78, + 0xee, 0xb0, 0xa9, 0x61, 0xc9, 0x13, 0x8, 0x0, 0x14, 0x3, 0xe7, 0x77, 0x2b, 0x20, 0x3, 0x80, 0xfc, + 0x57, 0x2d, 0xa4, 0xe4, 0x46, 0x51, 0xc6, 0xe7, 0x8c, 0x95, 0x80, 0x1f, 0x28, 0x56, 0x1, 0xb, 0x29, + 0x82, 0x2, 0x0, 0x0, 0x39, 0xbf, 0x29, 0x71, 0x25, 0xdf, 0x1a, 0x0, 0xe, 0x82, 0x16, 0x32, 0xe2, + 0xd2, 0xa, 0xa5, 0xdc, 0x2, 0xaf, 0xeb, 0x6a, 0x2, 0x1f, 0x17, 0x61, 0x9, 0x0, 0x17, 0x74, 0xed, + 0x6a, 0x10, 0x36, 0xe3, 0xd2, 0x19, 0x2, 0x0, 0x5d, 0x1c, 0xd7, 0x1c, 0xca, 0x77, 0xfa, 0x4e, 0x18, + 0xd9, 0xc7, 0xc0, 0x2b, 0x1f, 0x0, 0x14, 0xb0, 0xb, 0x62, 0xd8, 0x73, 0x1c, 0xaf, 0x63, 0x51, 0x49, + 0x71, 0x36, 0x74, 0xb7, 0x23, 0xaa, 0x95, 0x95, 0xda, 0x6f, 0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, + 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, + 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; + uint8_t topic_bytes[] = {0x6e, 0x91}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x8b, 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; + msg.retained = true; + uint8_t msg_bytes[] = {0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, + 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0x15, 0x7, 0xa4, 0x24, 0x22, 0xa4, 0x1c, 0xb7, 0xdd, 0x4e, 0x85, 0x56, 0x71}; - uint8_t bytesprops1[] = {0xb5, 0xac, 0x86, 0xfc, 0xe1, 0x43, 0x88, 0x49, 0x15, 0x43, 0x8b, - 0x97, 0x80, 0x46, 0x8b, 0x1b, 0x70, 0x72, 0xdb, 0x6b, 0x42, 0x1d}; - uint8_t bytesprops2[] = {0x78, 0x59, 0xfb, 0xc8, 0x51, 0x2a, 0xe6, 0xde, 0x3e, 0xba, 0x58, 0x3a, 0xbc, - 0xd9, 0xa1, 0x66, 0x35, 0x23, 0xba, 0xba, 0xf9, 0x13, 0x8e, 0x89, 0x79, 0x15}; - uint8_t bytesprops3[] = {0x35, 0x47, 0x8b, 0x1a, 0xf, 0x25, 0xf6, 0x4b, 0x2b, 0xa6, 0xb5, 0x1a, 0x3e, - 0xc2, 0x1, 0x53, 0x47, 0xcf, 0x2c, 0x58, 0xba, 0x6c, 0x12, 0xa4, 0x52}; - uint8_t bytesprops4[] = {0x38, 0xe1, 0xce, 0x38, 0xce, 0x50, 0x86, 0x6c, 0x4b, 0x99, 0x8f, 0x3e, 0x9c, 0x16, 0xd0, - 0x5d, 0x31, 0xb9, 0xe, 0x4d, 0x9, 0xc3, 0x72, 0xdb, 0x32, 0x9f, 0x1f, 0xce, 0x1d, 0x5e}; - uint8_t bytesprops5[] = {0x12, 0x4a, 0xfb, 0xe0, 0x70, 0x15}; - uint8_t bytesprops6[] = {0xe7, 0xbf, 0xb4, 0x19, 0x7e, 0x16, 0xe7, 0xf8, 0x26, 0xe4, 0xad, 0x75, 0x27, 0xba, - 0xd9, 0xc8, 0xef, 0xd2, 0xd1, 0x9a, 0x3d, 0x38, 0x1e, 0xd3, 0xef, 0x3f, 0xd4, 0xca}; - uint8_t bytesprops7[] = {0xb0, 0x17, 0x5c, 0x7a, 0x31, 0x8, 0x8b, 0xb1, 0x7b, 0x6c, 0x11, 0xab, 0x54, - 0x9a, 0x43, 0xcb, 0x26, 0xc9, 0xf2, 0x8e, 0xc9, 0x97, 0x46, 0xb6, 0x23, 0x23}; - uint8_t bytesprops8[] = {0xab, 0x28, 0x9a, 0x30, 0xb9, 0x69, 0xa1, 0xd1, 0x73, 0xb6, 0x1d}; - uint8_t bytesprops10[] = {0x2c, 0x5f, 0x18, 0x40, 0xf8, 0xb5, 0x5e, 0xae, 0xb0, 0x65, 0x31}; - uint8_t bytesprops9[] = {0x87, 0xb7, 0x75, 0xc4, 0x51, 0x5f, 0xfa, 0xa4, 0xb, 0x76, 0x57, 0xd2, 0x41}; - uint8_t bytesprops11[] = {0xf7, 0xa7, 0x3a, 0xe6, 0xa6, 0x9d}; + msg.payload_len = 30; + + uint8_t bytesprops0[] = {0xa5, 0x1d, 0x4f, 0x7f, 0x57, 0xd1, 0x1f, 0x59, 0x5e}; + uint8_t bytesprops1[] = {0xe9, 0x65, 0x6, 0xf2, 0xf5, 0x87, 0xcf, 0xb2, 0xbd}; + uint8_t bytesprops2[] = {0x9f, 0x2b, 0xcb, 0xad, 0x13, 0xd, 0xd8, 0xa5, 0xc8, 0x1, 0xe2, 0x24, 0x68, 0xab, 0x55, + 0xb3, 0x3d, 0xbd, 0x50, 0x71, 0x25, 0xd3, 0xbc, 0x78, 0xee, 0xb0, 0xa9, 0x61, 0xc9, 0x13}; + uint8_t bytesprops3[] = {0x3, 0xe7, 0x77, 0x2b, 0x20, 0x3, 0x80, 0xfc, 0x57, 0x2d, + 0xa4, 0xe4, 0x46, 0x51, 0xc6, 0xe7, 0x8c, 0x95, 0x80, 0x1f}; + uint8_t bytesprops4[] = {0x82, 0x16, 0x32, 0xe2, 0xd2, 0xa, 0xa5, 0xdc, 0x2, 0xaf, 0xeb, 0x6a, 0x2, 0x1f}; + uint8_t bytesprops5[] = {0x74, 0xed, 0x6a, 0x10, 0x36, 0xe3, 0xd2, 0x19, 0x2, 0x0, 0x5d, 0x1c, + 0xd7, 0x1c, 0xca, 0x77, 0xfa, 0x4e, 0x18, 0xd9, 0xc7, 0xc0, 0x2b}; + uint8_t bytesprops6[] = {0xb0, 0xb, 0x62, 0xd8, 0x73, 0x1c, 0xaf, 0x63, 0x51, 0x49, + 0x71, 0x36, 0x74, 0xb7, 0x23, 0xaa, 0x95, 0x95, 0xda, 0x6f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18867}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9600}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11214}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24117}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22040}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5953}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17987}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15657}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23342}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops9}, .v = {11, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19343}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14783}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7594, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14089, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\\\211\215", _pubPktID = 7594, -// _pubBody = "\139\150\137\180\142\209{^\232\155\136\252\140\233\138", _pubProps = [PropMaximumQoS -// 183,PropWildcardSubscriptionAvailable 166,PropResponseInformation -// "\NAK\a\164$\"\164\FS\183\221N\133Vq",PropResponseTopic -// "\181\172\134\252\225C\136I\NAKC\139\151\128F\139\ESCpr\219kB\GS",PropResponseInformation -// "xY\251\200Q*\230\222>\186X:\188\217\161f5#\186\186\249\DC3\142\137y\NAK",PropRequestResponseInformation -// 180,PropSubscriptionIdentifierAvailable 102,PropWillDelayInterval 18867,PropMessageExpiryInterval -// 9600,PropContentType "5G\139\SUB\SI%\246K+\166\181\SUB>\194\SOHSG\207,X\186l\DC2\164R",PropWillDelayInterval -// 11214,PropResponseTopic -// "8\225\206\&8\206P\134lK\153\143>\156\SYN\208]1\185\SOM\t\195r\219\&2\159\US\206\GS^",PropMessageExpiryInterval -// 24117,PropAuthenticationMethod "\DC2J\251\224p\NAK",PropTopicAlias 22040,PropWillDelayInterval -// 5953,PropMaximumPacketSize 17987,PropResponseTopic -// "\231\191\180\EM~\SYN\231\248&\228\173u'\186\217\200\239\210\209\154=8\RS\211\239?\212\202",PropAuthenticationMethod -// "\176\ETB\\z1\b\139\177{l\DC1\171T\154C\203&\201\242\142\201\151F\182##",PropContentType -// "\171(\154\&0\185i\161\209s\182\GS",PropMaximumQoS 189,PropWillDelayInterval 15657,PropMaximumQoS -// 121,PropReceiveMaximum 23342,PropUserProperty "\135\183u\196Q_\250\164\vvW\210A" -// ",_\CAN@\248\181^\174\176e1",PropCorrelationData "\247\167:\230\166\157",PropRequestResponseInformation -// 132,PropServerKeepAlive 19343]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "n\145", _pubPktID = 14089, _pubBody +// = "\210\210>L\150\rD\161j\204SG\219\226\165\205k\208\&4\ENQ\154t\DC1\148D:\US<\141\149", _pubProps = +// [PropPayloadFormatIndicator 11,PropAssignedClientIdentifier "\165\GSO\DELW\209\USY^",PropRequestResponseInformation +// 199,PropSubscriptionIdentifier 7,PropAssignedClientIdentifier "\233e\ACK\242\245\135\207\178\189",PropReasonString +// "\159+\203\173\DC3\r\216\165\200\SOH\226$h\171U\179=\189Pq%\211\188x\238\176\169a\201\DC3",PropResponseTopic +// "\ETX\231w+ \ETX\128\252W-\164\228FQ\198\231\140\149\128\US",PropWildcardSubscriptionAvailable +// 86,PropPayloadFormatIndicator 11,PropSubscriptionIdentifierAvailable 130,PropMessageExpiryInterval +// 14783,PropSubscriptionIdentifierAvailable 113,PropRetainAvailable 223,PropResponseInformation +// "\130\SYN2\226\210\n\165\220\STX\175\235j\STX\US",PropRequestProblemInformation 97,PropCorrelationData +// "t\237j\DLE6\227\210\EM\STX\NUL]\FS\215\FS\202w\250N\CAN\217\199\192+",PropReasonString +// "\176\vb\216s\FS\175cQIq6t\183#\170\149\149\218o"]} TEST(Publish5QCTest, Decode26) { - uint8_t pkt[] = { - 0x3c, 0xce, 0x2, 0x0, 0x3, 0x5c, 0xd3, 0xd7, 0x1d, 0xaa, 0xb6, 0x2, 0x24, 0xb7, 0x28, 0xa6, 0x1a, 0x0, 0xd, - 0x15, 0x7, 0xa4, 0x24, 0x22, 0xa4, 0x1c, 0xb7, 0xdd, 0x4e, 0x85, 0x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 0x25, 0xd3, 0xbc, 0x78, + 0xee, 0xb0, 0xa9, 0x61, 0xc9, 0x13, 0x8, 0x0, 0x14, 0x3, 0xe7, 0x77, 0x2b, 0x20, 0x3, 0x80, 0xfc, + 0x57, 0x2d, 0xa4, 0xe4, 0x46, 0x51, 0xc6, 0xe7, 0x8c, 0x95, 0x80, 0x1f, 0x28, 0x56, 0x1, 0xb, 0x29, + 0x82, 0x2, 0x0, 0x0, 0x39, 0xbf, 0x29, 0x71, 0x25, 0xdf, 0x1a, 0x0, 0xe, 0x82, 0x16, 0x32, 0xe2, + 0xd2, 0xa, 0xa5, 0xdc, 0x2, 0xaf, 0xeb, 0x6a, 0x2, 0x1f, 0x17, 0x61, 0x9, 0x0, 0x17, 0x74, 0xed, + 0x6a, 0x10, 0x36, 0xe3, 0xd2, 0x19, 0x2, 0x0, 0x5d, 0x1c, 0xd7, 0x1c, 0xca, 0x77, 0xfa, 0x4e, 0x18, + 0xd9, 0xc7, 0xc0, 0x2b, 0x1f, 0x0, 0x14, 0xb0, 0xb, 0x62, 0xd8, 0x73, 0x1c, 0xaf, 0x63, 0x51, 0x49, + 0x71, 0x36, 0x74, 0xb7, 0x23, 0xaa, 0x95, 0x95, 0xda, 0x6f, 0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, + 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, + 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4496,133 +4727,160 @@ TEST(Publish5QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5c, 0xd3, 0xd7}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8b, 0x96, 0x89, 0xb4, 0x8e, 0xd1, 0x7b, 0x5e, 0xe8, 0x9b, 0x88, 0xfc, 0x8c, 0xe9, 0x8a}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x6e, 0x91}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, + 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 7594); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 14089); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "e9\242\201W\247\177\219AK\182\169", -// _pubPktID = 7929, _pubBody = "T\v\FS.x%\218\n\245\225\147\232\145qH\197\203m~\212\&0pk}\161\236\244$\162", _pubProps -// = [PropTopicAliasMaximum 15774,PropCorrelationData "\SUBJV>\197X\v\196^(\197_\145M",PropRequestResponseInformation -// 244,PropMaximumQoS 66,PropWildcardSubscriptionAvailable 152,PropSessionExpiryInterval 15397,PropWillDelayInterval -// 765,PropResponseInformation -// "\SOH\255\DC4~PD{\209\153\229\224E\145s\216\156\199\162\182\171'\217`",PropWillDelayInterval -// 29588,PropAuthenticationData "[:\214\211\229\151\215",PropSubscriptionIdentifier 7,PropMaximumPacketSize -// 10099,PropMaximumQoS 105,PropServerKeepAlive 32351,PropUserProperty "\DC2\165" "\SUB;\228",PropMessageExpiryInterval -// 32078,PropUserProperty -// "\177u\217\166\246\144\225\128\137\217\182\219d\224\142\175\DC2;vI\213R\ACK\168\189\167\132\146-" -// "\179\NUL7\237\&7\151e:\188@\229\&7\DC4M#\r\187~\131\230v\182\244",PropTopicAliasMaximum -// 29830,PropAuthenticationMethod -// "}\188\US\189\196\165?\196/m\224\DC1\163`\186\165\US\222$",PropSharedSubscriptionAvailable 224]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\199d\158\162p\SYNZ2{\228j\t\233'\211K\254\FSK\133%\252", _pubPktID = 0, _pubBody = "\SYN\ESC\r\233\&1\216\237", +// _pubProps = [PropMaximumPacketSize 22909,PropUserProperty "\213;\180\149" +// "\142\f\137prd\141\&6\DC4\237\252G\248Ot\200\SUB;5\204",PropWillDelayInterval +// 4294,PropSubscriptionIdentifierAvailable 78,PropRetainAvailable 105,PropServerKeepAlive 18960,PropTopicAlias +// 32368,PropWildcardSubscriptionAvailable 111,PropAuthenticationData +// "\135\147Z\181\250\224\250\DC1E\ETB?B\229TNp{\140\&2\220R\STX*\177f\251",PropContentType +// "!\197X\v\196^(\197_\145M",PropRequestResponseInformation -// 244,PropMaximumQoS 66,PropWildcardSubscriptionAvailable 152,PropSessionExpiryInterval 15397,PropWillDelayInterval -// 765,PropResponseInformation -// "\SOH\255\DC4~PD{\209\153\229\224E\145s\216\156\199\162\182\171'\217`",PropWillDelayInterval -// 29588,PropAuthenticationData "[:\214\211\229\151\215",PropSubscriptionIdentifier 7,PropMaximumPacketSize -// 10099,PropMaximumQoS 105,PropServerKeepAlive 32351,PropUserProperty "\DC2\165" "\SUB;\228",PropMessageExpiryInterval -// 32078,PropUserProperty -// "\177u\217\166\246\144\225\128\137\217\182\219d\224\142\175\DC2;vI\213R\ACK\168\189\167\132\146-" -// "\179\NUL7\237\&7\151e:\188@\229\&7\DC4M#\r\187~\131\230v\182\244",PropTopicAliasMaximum -// 29830,PropAuthenticationMethod -// "}\188\US\189\196\165?\196/m\224\DC1\163`\186\165\US\222$",PropSharedSubscriptionAvailable 224]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\199d\158\162p\SYNZ2{\228j\t\233'\211K\254\FSK\133%\252", _pubPktID = 0, _pubBody = "\SYN\ESC\r\233\&1\216\237", +// _pubProps = [PropMaximumPacketSize 22909,PropUserProperty "\213;\180\149" +// "\142\f\137prd\141\&6\DC4\237\252G\248Ot\200\SUB;5\204",PropWillDelayInterval +// 4294,PropSubscriptionIdentifierAvailable 78,PropRetainAvailable 105,PropServerKeepAlive 18960,PropTopicAlias +// 32368,PropWildcardSubscriptionAvailable 111,PropAuthenticationData +// "\135\147Z\181\250\224\250\DC1E\ETB?B\229TNp{\140\&2\220R\STX*\177f\251",PropContentType +// "!(topic.data), 12); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\235\160n\156\199\DC14\f\233\197\243\207\145\204|J/\129\156\&5$&Z", _pubPktID = 0, _pubBody = -// "\143\195\191\225_\213\191E\230c\156\216\152\CAN\208\204-", _pubProps = [PropResponseTopic -// "\138zf\158h\178|\233}.\244\SO\DLE\137\211\206\134;y\223g\211\250\\\211\181\RSr\223Z",PropRequestResponseInformation -// 253,PropMaximumQoS 194,PropReceiveMaximum 22488,PropMaximumQoS 223]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\DELB\171!\189\RS\129\132", _pubPktID +// = 1997, _pubBody = "P\169", _pubProps = [PropAuthenticationData +// "\133\226\151X\185\146s\RS\226zw'\244o\251\141(\250i\128\254\&2:\180\156\235\145\241\185\139",PropAuthenticationMethod +// "l\204\131\167\192P\220\ACK8\v\136\\G\230\166~6L\ETX\138",PropPayloadFormatIndicator 188,PropTopicAliasMaximum +// 2470,PropContentType "\184\147Y`}\SYN\\P\168\r\148\152\&7\148\175i\188hp\SO6",PropWillDelayInterval +// 8842,PropTopicAliasMaximum 3096,PropServerReference +// "\NAK\208\185@\138*\ETX'\243v\196S\FS\134.\193\230pMQ\134\245\185\249\225",PropSharedSubscriptionAvailable +// 205,PropServerReference +// "\r$\r\196\230\134\188I\a\252\231Q\240\215\185\190\175\&4\v\242\212\248\145c\251\221\254",PropServerKeepAlive +// 260,PropAuthenticationMethod +// "8L\222\GS\144C\180Q\168\135\152\179\187\ESC\191\&6|1\152\192\149\215\t\DLE\162\169\213\187\221\186",PropMaximumQoS +// 30,PropAuthenticationData "C\f\fx\t\186\166\215\SUB\156\136\236\222\238~\165#p\237\199O\237",PropReasonString +// "\206\b\FS\218",PropMessageExpiryInterval 21627,PropWildcardSubscriptionAvailable 124,PropServerReference +// "\192\DC3\ESC\SI",PropRequestProblemInformation 114,PropSubscriptionIdentifierAvailable +// 10,PropRequestResponseInformation 197]} TEST(Publish5QCTest, Encode28) { - uint8_t pkt[] = {0x39, 0x55, 0x0, 0x17, 0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, - 0xcf, 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a, 0x2a, 0x8, 0x0, - 0x1e, 0x8a, 0x7a, 0x66, 0x9e, 0x68, 0xb2, 0x7c, 0xe9, 0x7d, 0x2e, 0xf4, 0xe, 0x10, 0x89, - 0xd3, 0xce, 0x86, 0x3b, 0x79, 0xdf, 0x67, 0xd3, 0xfa, 0x5c, 0xd3, 0xb5, 0x1e, 0x72, 0xdf, - 0x5a, 0x19, 0xfd, 0x24, 0xc2, 0x21, 0x57, 0xd8, 0x24, 0xdf, 0x8f, 0xc3, 0xbf, 0xe1, 0x5f, - 0xd5, 0xbf, 0x45, 0xe6, 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; - uint8_t topic_bytes[] = {0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, 0xcf, - 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x3d, 0x83, 0x2, 0x0, 0x8, 0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84, 0x7, 0xcd, 0xf3, 0x1, 0x16, 0x0, + 0x1e, 0x85, 0xe2, 0x97, 0x58, 0xb9, 0x92, 0x73, 0x1e, 0xe2, 0x7a, 0x77, 0x27, 0xf4, 0x6f, 0xfb, 0x8d, 0x28, 0xfa, + 0x69, 0x80, 0xfe, 0x32, 0x3a, 0xb4, 0x9c, 0xeb, 0x91, 0xf1, 0xb9, 0x8b, 0x15, 0x0, 0x14, 0x6c, 0xcc, 0x83, 0xa7, + 0xc0, 0x50, 0xdc, 0x6, 0x38, 0xb, 0x88, 0x5c, 0x47, 0xe6, 0xa6, 0x7e, 0x36, 0x4c, 0x3, 0x8a, 0x1, 0xbc, 0x22, + 0x9, 0xa6, 0x3, 0x0, 0x15, 0xb8, 0x93, 0x59, 0x60, 0x7d, 0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lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x8f, 0xc3, 0xbf, 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, - 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; + uint8_t msg_bytes[] = {0x50, 0xa9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 2; - uint8_t bytesprops0[] = {0x8a, 0x7a, 0x66, 0x9e, 0x68, 0xb2, 0x7c, 0xe9, 0x7d, 0x2e, 0xf4, 0xe, 0x10, 0x89, 0xd3, - 0xce, 0x86, 0x3b, 0x79, 0xdf, 0x67, 0xd3, 0xfa, 0x5c, 0xd3, 0xb5, 0x1e, 0x72, 0xdf, 0x5a}; + uint8_t bytesprops0[] = {0x85, 0xe2, 0x97, 0x58, 0xb9, 0x92, 0x73, 0x1e, 0xe2, 0x7a, 0x77, 0x27, 0xf4, 0x6f, 0xfb, + 0x8d, 0x28, 0xfa, 0x69, 0x80, 0xfe, 0x32, 0x3a, 0xb4, 0x9c, 0xeb, 0x91, 0xf1, 0xb9, 0x8b}; + uint8_t bytesprops1[] = {0x6c, 0xcc, 0x83, 0xa7, 0xc0, 0x50, 0xdc, 0x6, 0x38, 0xb, + 0x88, 0x5c, 0x47, 0xe6, 0xa6, 0x7e, 0x36, 0x4c, 0x3, 0x8a}; + uint8_t bytesprops2[] = {0xb8, 0x93, 0x59, 0x60, 0x7d, 0x16, 0x5c, 0x50, 0xa8, 0xd, 0x94, + 0x98, 0x37, 0x94, 0xaf, 0x69, 0xbc, 0x68, 0x70, 0xe, 0x36}; + uint8_t bytesprops3[] = {0x15, 0xd0, 0xb9, 0x40, 0x8a, 0x2a, 0x3, 0x27, 0xf3, 0x76, 0xc4, 0x53, 0x1c, + 0x86, 0x2e, 0xc1, 0xe6, 0x70, 0x4d, 0x51, 0x86, 0xf5, 0xb9, 0xf9, 0xe1}; + uint8_t bytesprops4[] = {0xd, 0x24, 0xd, 0xc4, 0xe6, 0x86, 0xbc, 0x49, 0x7, 0xfc, 0xe7, 0x51, 0xf0, 0xd7, + 0xb9, 0xbe, 0xaf, 0x34, 0xb, 0xf2, 0xd4, 0xf8, 0x91, 0x63, 0xfb, 0xdd, 0xfe}; + uint8_t bytesprops5[] = {0x38, 0x4c, 0xde, 0x1d, 0x90, 0x43, 0xb4, 0x51, 0xa8, 0x87, 0x98, 0xb3, 0xbb, 0x1b, 0xbf, + 0x36, 0x7c, 0x31, 0x98, 0xc0, 0x95, 0xd7, 0x9, 0x10, 0xa2, 0xa9, 0xd5, 0xbb, 0xdd, 0xba}; + uint8_t bytesprops6[] = {0x43, 0xc, 0xc, 0x78, 0x9, 0xba, 0xa6, 0xd7, 0x1a, 0x9c, 0x88, + 0xec, 0xde, 0xee, 0x7e, 0xa5, 0x23, 0x70, 0xed, 0xc7, 0x4f, 0xed}; + uint8_t bytesprops7[] = {0xce, 0x8, 0x1c, 0xda}; + uint8_t bytesprops8[] = {0xc0, 0x13, 0x1b, 0xf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22488}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2470}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8842}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3096}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 260}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21627}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1997, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\235\160n\156\199\DC14\f\233\197\243\207\145\204|J/\129\156\&5$&Z", _pubPktID = 0, _pubBody = -// "\143\195\191\225_\213\191E\230c\156\216\152\CAN\208\204-", _pubProps = [PropResponseTopic -// "\138zf\158h\178|\233}.\244\SO\DLE\137\211\206\134;y\223g\211\250\\\211\181\RSr\223Z",PropRequestResponseInformation -// 253,PropMaximumQoS 194,PropReceiveMaximum 22488,PropMaximumQoS 223]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\DELB\171!\189\RS\129\132", _pubPktID +// = 1997, _pubBody = "P\169", _pubProps = [PropAuthenticationData +// "\133\226\151X\185\146s\RS\226zw'\244o\251\141(\250i\128\254\&2:\180\156\235\145\241\185\139",PropAuthenticationMethod +// "l\204\131\167\192P\220\ACK8\v\136\\G\230\166~6L\ETX\138",PropPayloadFormatIndicator 188,PropTopicAliasMaximum +// 2470,PropContentType "\184\147Y`}\SYN\\P\168\r\148\152\&7\148\175i\188hp\SO6",PropWillDelayInterval +// 8842,PropTopicAliasMaximum 3096,PropServerReference +// "\NAK\208\185@\138*\ETX'\243v\196S\FS\134.\193\230pMQ\134\245\185\249\225",PropSharedSubscriptionAvailable +// 205,PropServerReference +// "\r$\r\196\230\134\188I\a\252\231Q\240\215\185\190\175\&4\v\242\212\248\145c\251\221\254",PropServerKeepAlive +// 260,PropAuthenticationMethod +// "8L\222\GS\144C\180Q\168\135\152\179\187\ESC\191\&6|1\152\192\149\215\t\DLE\162\169\213\187\221\186",PropMaximumQoS +// 30,PropAuthenticationData "C\f\fx\t\186\166\215\SUB\156\136\236\222\238~\165#p\237\199O\237",PropReasonString +// "\206\b\FS\218",PropMessageExpiryInterval 21627,PropWildcardSubscriptionAvailable 124,PropServerReference +// "\192\DC3\ESC\SI",PropRequestProblemInformation 114,PropSubscriptionIdentifierAvailable +// 10,PropRequestResponseInformation 197]} TEST(Publish5QCTest, Decode28) { - uint8_t pkt[] = {0x39, 0x55, 0x0, 0x17, 0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, - 0xcf,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, 0x0, 0x19, 0x15, + 0xd0, 0xb9, 0x40, 0x8a, 0x2a, 0x3, 0x27, 0xf3, 0x76, 0xc4, 0x53, 0x1c, 0x86, 0x2e, 0xc1, 0xe6, 0x70, 0x4d, 0x51, + 0x86, 0xf5, 0xb9, 0xf9, 0xe1, 0x2a, 0xcd, 0x1c, 0x0, 0x1b, 0xd, 0x24, 0xd, 0xc4, 0xe6, 0x86, 0xbc, 0x49, 0x7, + 0xfc, 0xe7, 0x51, 0xf0, 0xd7, 0xb9, 0xbe, 0xaf, 0x34, 0xb, 0xf2, 0xd4, 0xf8, 0x91, 0x63, 0xfb, 0xdd, 0xfe, 0x13, + 0x1, 0x4, 0x15, 0x0, 0x1e, 0x38, 0x4c, 0xde, 0x1d, 0x90, 0x43, 0xb4, 0x51, 0xa8, 0x87, 0x98, 0xb3, 0xbb, 0x1b, + 0xbf, 0x36, 0x7c, 0x31, 0x98, 0xc0, 0x95, 0xd7, 0x9, 0x10, 0xa2, 0xa9, 0xd5, 0xbb, 0xdd, 0xba, 0x24, 0x1e, 0x16, + 0x0, 0x16, 0x43, 0xc, 0xc, 0x78, 0x9, 0xba, 0xa6, 0xd7, 0x1a, 0x9c, 0x88, 0xec, 0xde, 0xee, 0x7e, 0xa5, 0x23, + 0x70, 0xed, 0xc7, 0x4f, 0xed, 0x1f, 0x0, 0x4, 0xce, 0x8, 0x1c, 0xda, 0x2, 0x0, 0x0, 0x54, 0x7b, 0x28, 0x7c, + 0x1c, 0x0, 0x4, 0xc0, 0x13, 0x1b, 0xf, 0x17, 0x72, 0x29, 0xa, 0x19, 0xc5, 0x50, 0xa9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4709,113 +5033,149 @@ TEST(Publish5QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xeb, 0xa0, 0x6e, 0x9c, 0xc7, 0x11, 0x34, 0xc, 0xe9, 0xc5, 0xf3, 0xcf, - 0x91, 0xcc, 0x7c, 0x4a, 0x2f, 0x81, 0x9c, 0x35, 0x24, 0x26, 0x5a}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8f, 0xc3, 0xbf, 0xe1, 0x5f, 0xd5, 0xbf, 0x45, 0xe6, - 0x63, 0x9c, 0xd8, 0x98, 0x18, 0xd0, 0xcc, 0x2d}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x50, 0xa9}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(packet_id, 1997); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\182~R\STX\198L\RS%^\137\162\228\&70", _pubPktID = 1453, _pubBody = "\188=\n\155\249", _pubProps = -// [PropMessageExpiryInterval 873,PropContentType "\223c\216uv$\144\223\ETXy",PropServerKeepAlive -// 8157,PropMaximumPacketSize 15512,PropRequestProblemInformation 78,PropServerReference -// "\169\&6\179\ACK\162;\179L?\164'\168\132\160\&9",PropMessageExpiryInterval 7902,PropAuthenticationData -// "}\206\145\216\182\173\&0B\ETXTC\207f3\136m",PropMessageExpiryInterval 27667,PropAuthenticationMethod -// "\239i$\175_\149;",PropRequestResponseInformation 21,PropSubscriptionIdentifierAvailable 5,PropUserProperty -// "\SI\vuX#66\184\165\147f\230I" "\132\164\151\233\200A A>Y\150\&4\145G\NAK\GS'2\136",PropWildcardSubscriptionAvailable -// 90,PropContentType "\189\227\153\SO\199\185\173V\ETB*.\224\168\142\n\191\166s\ACK\b"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\138.\149\DC3{U\CANP\144", +// _pubPktID = 16970, _pubBody = "4\163\252\250\166\SUB\245\158", _pubProps = [PropContentType +// "\RS\247\FS\142\143@3\238U\203",PropReasonString +// "\157\230\ACK\171\149\165\250\147L\227{\131\252Y\140",PropAuthenticationData +// "R,\224\163\177\231\185\n\202\160\162\180gn\a\r{\192\135\ETX\145\151\136\211",PropTopicAlias +// 31483,PropAssignedClientIdentifier +// "\SIV\223\185\223X\244\197\182\220\DEL{\247\214\153\"\193\246W\247\r\220",PropTopicAlias +// 20925,PropResponseInformation "O\252\147\164\145",PropServerReference +// "\"\237\153*\136\152\192\190\201\147\186\219\DEL",PropAuthenticationMethod "CN\207\218 +// \169\210\143\ACK[\174\157O\212\135\185\&6",PropReasonString +// "\177(\200\154|\245\236\153\249\251C\212\DC3\183\179\255\143\183-w",PropSharedSubscriptionAvailable +// 31,PropPayloadFormatIndicator 157,PropPayloadFormatIndicator 10,PropSubscriptionIdentifier +// 11,PropSessionExpiryInterval 11032,PropContentType "-X8\172\&4\167\USO",PropTopicAliasMaximum +// 27140,PropAuthenticationMethod "\167\249X\STX&\r\194t\166\135\246\&54L",PropRetainAvailable +// 64,PropMessageExpiryInterval 28215,PropServerKeepAlive 19907,PropUserProperty "\206z\147Gp\187\243\215" +// "]\194s\253\226\204\203NP\234Y;t0\183\236\128\211\155\EM\184\b"]} TEST(Publish5QCTest, Encode29) { - uint8_t pkt[] = {0x3d, 0xb0, 0x1, 0x0, 0xe, 0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, - 0x37, 0x30, 0x5, 0xad, 0x97, 0x1, 0x2, 0x0, 0x0, 0x3, 0x69, 0x3, 0x0, 0xa, 0xdf, 0x63, 0xd8, - 0x75, 0x76, 0x24, 0x90, 0xdf, 0x3, 0x79, 0x13, 0x1f, 0xdd, 0x27, 0x0, 0x0, 0x3c, 0x98, 0x17, 0x4e, - 0x1c, 0x0, 0xf, 0xa9, 0x36, 0xb3, 0x6, 0xa2, 0x3b, 0xb3, 0x4c, 0x3f, 0xa4, 0x27, 0xa8, 0x84, 0xa0, - 0x39, 0x2, 0x0, 0x0, 0x1e, 0xde, 0x16, 0x0, 0x10, 0x7d, 0xce, 0x91, 0xd8, 0xb6, 0xad, 0x30, 0x42, - 0x3, 0x54, 0x43, 0xcf, 0x66, 0x33, 0x88, 0x6d, 0x2, 0x0, 0x0, 0x6c, 0x13, 0x15, 0x0, 0x7, 0xef, - 0x69, 0x24, 0xaf, 0x5f, 0x95, 0x3b, 0x19, 0x15, 0x29, 0x5, 0x26, 0x0, 0xd, 0xf, 0xb, 0x75, 0x58, - 0x23, 0x36, 0x36, 0xb8, 0xa5, 0x93, 0x66, 0xe6, 0x49, 0x0, 0x13, 0x84, 0xa4, 0x97, 0xe9, 0xc8, 0x41, - 0x20, 0x41, 0x3e, 0x59, 0x96, 0x34, 0x91, 0x47, 0x15, 0x1d, 0x27, 0x32, 0x88, 0x28, 0x5a, 0x3, 0x0, - 0x14, 0xbd, 0xe3, 0x99, 0xe, 0xc7, 0xb9, 0xad, 0x56, 0x17, 0x2a, 0x2e, 0xe0, 0xa8, 0x8e, 0xa, 0xbf, - 0xa6, 0x73, 0x6, 0x8, 0xbc, 0x3d, 0xa, 0x9b, 0xf9}; - uint8_t topic_bytes[] = {0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, 0x37, 0x30}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x8c, 0x2, 0x0, 0x9, 0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, 0x90, 0x42, 0x4a, 0xf5, + 0x1, 0x3, 0x0, 0xa, 0x1e, 0xf7, 0x1c, 0x8e, 0x8f, 0x40, 0x33, 0xee, 0x55, 0xcb, 0x1f, 0x0, 0xf, + 0x9d, 0xe6, 0x6, 0xab, 0x95, 0xa5, 0xfa, 0x93, 0x4c, 0xe3, 0x7b, 0x83, 0xfc, 0x59, 0x8c, 0x16, 0x0, + 0x18, 0x52, 0x2c, 0xe0, 0xa3, 0xb1, 0xe7, 0xb9, 0xa, 0xca, 0xa0, 0xa2, 0xb4, 0x67, 0x6e, 0x7, 0xd, + 0x7b, 0xc0, 0x87, 0x3, 0x91, 0x97, 0x88, 0xd3, 0x23, 0x7a, 0xfb, 0x12, 0x0, 0x16, 0xf, 0x56, 0xdf, + 0xb9, 0xdf, 0x58, 0xf4, 0xc5, 0xb6, 0xdc, 0x7f, 0x7b, 0xf7, 0xd6, 0x99, 0x22, 0xc1, 0xf6, 0x57, 0xf7, + 0xd, 0xdc, 0x23, 0x51, 0xbd, 0x1a, 0x0, 0x5, 0x4f, 0xfc, 0x93, 0xa4, 0x91, 0x1c, 0x0, 0xd, 0x22, + 0xed, 0x99, 0x2a, 0x88, 0x98, 0xc0, 0xbe, 0xc9, 0x93, 0xba, 0xdb, 0x7f, 0x15, 0x0, 0x11, 0x43, 0x4e, + 0xcf, 0xda, 0x20, 0xa9, 0xd2, 0x8f, 0x6, 0x5b, 0xae, 0x9d, 0x4f, 0xd4, 0x87, 0xb9, 0x36, 0x1f, 0x0, + 0x14, 0xb1, 0x28, 0xc8, 0x9a, 0x7c, 0xf5, 0xec, 0x99, 0xf9, 0xfb, 0x43, 0xd4, 0x13, 0xb7, 0xb3, 0xff, + 0x8f, 0xb7, 0x2d, 0x77, 0x2a, 0x1f, 0x1, 0x9d, 0x1, 0xa, 0xb, 0xb, 0x11, 0x0, 0x0, 0x2b, 0x18, + 0x3, 0x0, 0x8, 0x2d, 0x58, 0x38, 0xac, 0x34, 0xa7, 0x1f, 0x4f, 0x22, 0x6a, 0x4, 0x15, 0x0, 0xe, + 0xa7, 0xf9, 0x58, 0x2, 0x26, 0xd, 0xc2, 0x74, 0xa6, 0x87, 0xf6, 0x35, 0x34, 0x4c, 0x25, 0x40, 0x2, + 0x0, 0x0, 0x6e, 0x37, 0x13, 0x4d, 0xc3, 0x26, 0x0, 0x8, 0xce, 0x7a, 0x93, 0x47, 0x70, 0xbb, 0xf3, + 0xd7, 0x0, 0x16, 0x5d, 0xc2, 0x73, 0xfd, 0xe2, 0xcc, 0xcb, 0x4e, 0x50, 0xea, 0x59, 0x3b, 0x74, 0x30, + 0xb7, 0xec, 0x80, 0xd3, 0x9b, 0x19, 0xb8, 0x8, 0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; + uint8_t topic_bytes[] = {0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, 0x90}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xbc, 0x3d, 0xa, 0x9b, 0xf9}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; - - uint8_t bytesprops0[] = {0xdf, 0x63, 0xd8, 0x75, 0x76, 0x24, 0x90, 0xdf, 0x3, 0x79}; - uint8_t bytesprops1[] = {0xa9, 0x36, 0xb3, 0x6, 0xa2, 0x3b, 0xb3, 0x4c, 0x3f, 0xa4, 0x27, 0xa8, 0x84, 0xa0, 0x39}; - uint8_t bytesprops2[] = {0x7d, 0xce, 0x91, 0xd8, 0xb6, 0xad, 0x30, 0x42, - 0x3, 0x54, 0x43, 0xcf, 0x66, 0x33, 0x88, 0x6d}; - uint8_t bytesprops3[] = {0xef, 0x69, 0x24, 0xaf, 0x5f, 0x95, 0x3b}; - uint8_t bytesprops5[] = {0x84, 0xa4, 0x97, 0xe9, 0xc8, 0x41, 0x20, 0x41, 0x3e, 0x59, - 0x96, 0x34, 0x91, 0x47, 0x15, 0x1d, 0x27, 0x32, 0x88}; - uint8_t bytesprops4[] = {0xf, 0xb, 0x75, 0x58, 0x23, 0x36, 0x36, 0xb8, 0xa5, 0x93, 0x66, 0xe6, 0x49}; - uint8_t bytesprops6[] = {0xbd, 0xe3, 0x99, 0xe, 0xc7, 0xb9, 0xad, 0x56, 0x17, 0x2a, - 0x2e, 0xe0, 0xa8, 0x8e, 0xa, 0xbf, 0xa6, 0x73, 0x6, 0x8}; + msg.payload_len = 8; + + uint8_t bytesprops0[] = {0x1e, 0xf7, 0x1c, 0x8e, 0x8f, 0x40, 0x33, 0xee, 0x55, 0xcb}; + uint8_t bytesprops1[] = {0x9d, 0xe6, 0x6, 0xab, 0x95, 0xa5, 0xfa, 0x93, 0x4c, 0xe3, 0x7b, 0x83, 0xfc, 0x59, 0x8c}; + uint8_t bytesprops2[] = {0x52, 0x2c, 0xe0, 0xa3, 0xb1, 0xe7, 0xb9, 0xa, 0xca, 0xa0, 0xa2, 0xb4, + 0x67, 0x6e, 0x7, 0xd, 0x7b, 0xc0, 0x87, 0x3, 0x91, 0x97, 0x88, 0xd3}; + uint8_t bytesprops3[] = {0xf, 0x56, 0xdf, 0xb9, 0xdf, 0x58, 0xf4, 0xc5, 0xb6, 0xdc, 0x7f, + 0x7b, 0xf7, 0xd6, 0x99, 0x22, 0xc1, 0xf6, 0x57, 0xf7, 0xd, 0xdc}; + uint8_t bytesprops4[] = {0x4f, 0xfc, 0x93, 0xa4, 0x91}; + uint8_t bytesprops5[] = {0x22, 0xed, 0x99, 0x2a, 0x88, 0x98, 0xc0, 0xbe, 0xc9, 0x93, 0xba, 0xdb, 0x7f}; + uint8_t bytesprops6[] = {0x43, 0x4e, 0xcf, 0xda, 0x20, 0xa9, 0xd2, 0x8f, 0x6, + 0x5b, 0xae, 0x9d, 0x4f, 0xd4, 0x87, 0xb9, 0x36}; + uint8_t bytesprops7[] = {0xb1, 0x28, 0xc8, 0x9a, 0x7c, 0xf5, 0xec, 0x99, 0xf9, 0xfb, + 0x43, 0xd4, 0x13, 0xb7, 0xb3, 0xff, 0x8f, 0xb7, 0x2d, 0x77}; + uint8_t bytesprops8[] = {0x2d, 0x58, 0x38, 0xac, 0x34, 0xa7, 0x1f, 0x4f}; + uint8_t bytesprops9[] = {0xa7, 0xf9, 0x58, 0x2, 0x26, 0xd, 0xc2, 0x74, 0xa6, 0x87, 0xf6, 0x35, 0x34, 0x4c}; + uint8_t bytesprops11[] = {0x5d, 0xc2, 0x73, 0xfd, 0xe2, 0xcc, 0xcb, 0x4e, 0x50, 0xea, 0x59, + 0x3b, 0x74, 0x30, 0xb7, 0xec, 0x80, 0xd3, 0x9b, 0x19, 0xb8, 0x8}; + uint8_t bytesprops10[] = {0xce, 0x7a, 0x93, 0x47, 0x70, 0xbb, 0xf3, 0xd7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 873}}, {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8157}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15512}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7902}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27667}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops4}, .v = {19, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31483}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20925}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11032}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27140}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28215}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19907}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops10}, .v = {22, (char*)&bytesprops11}}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1453, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16970, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\182~R\STX\198L\RS%^\137\162\228\&70", _pubPktID = 1453, _pubBody = "\188=\n\155\249", _pubProps = -// [PropMessageExpiryInterval 873,PropContentType "\223c\216uv$\144\223\ETXy",PropServerKeepAlive -// 8157,PropMaximumPacketSize 15512,PropRequestProblemInformation 78,PropServerReference -// "\169\&6\179\ACK\162;\179L?\164'\168\132\160\&9",PropMessageExpiryInterval 7902,PropAuthenticationData -// "}\206\145\216\182\173\&0B\ETXTC\207f3\136m",PropMessageExpiryInterval 27667,PropAuthenticationMethod -// "\239i$\175_\149;",PropRequestResponseInformation 21,PropSubscriptionIdentifierAvailable 5,PropUserProperty -// "\SI\vuX#66\184\165\147f\230I" "\132\164\151\233\200A A>Y\150\&4\145G\NAK\GS'2\136",PropWildcardSubscriptionAvailable -// 90,PropContentType "\189\227\153\SO\199\185\173V\ETB*.\224\168\142\n\191\166s\ACK\b"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\138.\149\DC3{U\CANP\144", +// _pubPktID = 16970, _pubBody = "4\163\252\250\166\SUB\245\158", _pubProps = [PropContentType +// "\RS\247\FS\142\143@3\238U\203",PropReasonString +// "\157\230\ACK\171\149\165\250\147L\227{\131\252Y\140",PropAuthenticationData +// "R,\224\163\177\231\185\n\202\160\162\180gn\a\r{\192\135\ETX\145\151\136\211",PropTopicAlias +// 31483,PropAssignedClientIdentifier +// "\SIV\223\185\223X\244\197\182\220\DEL{\247\214\153\"\193\246W\247\r\220",PropTopicAlias +// 20925,PropResponseInformation "O\252\147\164\145",PropServerReference +// "\"\237\153*\136\152\192\190\201\147\186\219\DEL",PropAuthenticationMethod "CN\207\218 +// \169\210\143\ACK[\174\157O\212\135\185\&6",PropReasonString +// "\177(\200\154|\245\236\153\249\251C\212\DC3\183\179\255\143\183-w",PropSharedSubscriptionAvailable +// 31,PropPayloadFormatIndicator 157,PropPayloadFormatIndicator 10,PropSubscriptionIdentifier +// 11,PropSessionExpiryInterval 11032,PropContentType "-X8\172\&4\167\USO",PropTopicAliasMaximum +// 27140,PropAuthenticationMethod "\167\249X\STX&\r\194t\166\135\246\&54L",PropRetainAvailable +// 64,PropMessageExpiryInterval 28215,PropServerKeepAlive 19907,PropUserProperty "\206z\147Gp\187\243\215" +// "]\194s\253\226\204\203NP\234Y;t0\183\236\128\211\155\EM\184\b"]} TEST(Publish5QCTest, Decode29) { - uint8_t pkt[] = {0x3d, 0xb0, 0x1, 0x0, 0xe, 0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, - 0x37, 0x30, 0x5, 0xad, 0x97, 0x1, 0x2, 0x0, 0x0, 0x3, 0x69, 0x3, 0x0, 0xa, 0xdf, 0x63, 0xd8, - 0x75, 0x76, 0x24, 0x90, 0xdf, 0x3, 0x79, 0x13, 0x1f, 0xdd, 0x27, 0x0, 0x0, 0x3c, 0x98, 0x17, 0x4e, - 0x1c,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fd, 0xe2, 0xcc, 0xcb, 0x4e, 0x50, 0xea, 0x59, 0x3b, 0x74, 0x30, + 0xb7, 0xec, 0x80, 0xd3, 0x9b, 0x19, 0xb8, 0x8, 0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4823,144 +5183,139 @@ TEST(Publish5QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb6, 0x7e, 0x52, 0x2, 0xc6, 0x4c, 0x1e, 0x25, 0x5e, 0x89, 0xa2, 0xe4, 0x37, 0x30}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbc, 0x3d, 0xa, 0x9b, 0xf9}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 1453); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + uint8_t exp_topic_bytes[] = {0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, 0x90}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; + lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 16970); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 8); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\191k-$.\245\SUB\192\234\155$", -// _pubPktID = 29170, _pubBody = "[F\181\186O\149", _pubProps = [PropRequestProblemInformation -// 119,PropPayloadFormatIndicator 239,PropWildcardSubscriptionAvailable 115,PropMaximumPacketSize -// 25304,PropAssignedClientIdentifier "n4\239\&8m\163\225T/\181\230\189",PropReasonString -// "\145\USv\152vy\DC1\a\131\&1\207",PropUserProperty -// "^\170=\229Z\DC4\241\181G\SI\146\253\ETX\f\136`\DEL6\239\165;7\130\DEL\224\198I-\184\229" -// "ab\181\192\DLEJ[\255v}\175\SI\131R^u\238:\ETB\144\186gW\STX\EM\152",PropServerKeepAlive 20060,PropReasonString -// "\221\&4'\184\&2\SI\207\234#",PropSharedSubscriptionAvailable 134,PropSubscriptionIdentifier -// 12,PropPayloadFormatIndicator 201,PropPayloadFormatIndicator 253,PropAuthenticationData -// "`N\249qh*\SI}\177\130\198",PropMessageExpiryInterval 20002,PropRequestProblemInformation -// 106,PropAuthenticationMethod "p\178[&s<[\130\212R\198\132\243\168\DC4",PropRequestResponseInformation -// 96,PropUserProperty "\139R\205\238/\177\235}\194\EM\179" -// "M-Zq\\\247H\ETX\210\222\182\&6w\182k&|\207\230f\ETX,\152G@\134",PropMaximumQoS 111,PropWillDelayInterval -// 24311,PropWildcardSubscriptionAvailable 44,PropRequestResponseInformation 218,PropMaximumPacketSize -// 29821,PropContentType "<"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3r\ETX\ETXZ\SOH", _pubPktID = 0, +// _pubBody = "\129\209\171[\DC4B\234\ETX\ACK\177\133\&9\ENQf\128\DC1A\185\236M\134qT}\\g\159&;g", _pubProps = +// [PropUserProperty "\170\GS.\n\219\236\177\210s\166\241\227W\204" "\138\222S4\176\f\137%(\176\NUL",PropServerKeepAlive +// 3685,PropSharedSubscriptionAvailable 95,PropAssignedClientIdentifier +// "\204t1\215\220\133gm\202?bYl\134\DELH1I\STXd\GSJ_\FS\193H",PropMessageExpiryInterval 26825,PropReasonString +// "\205\198\163\206\251\192U\133\236&\189\177\ACK\181!\144",PropWildcardSubscriptionAvailable +// 188,PropRequestProblemInformation 198,PropMessageExpiryInterval 32203,PropWillDelayInterval 11069,PropContentType +// "\194\215\241\163\165\RS\241\222D\"\224^\219\154C\190\143r^yd\167\192)\223\195\171",PropUserProperty +// "5[\142(\199<\131\133\160\154\160|A\162U" +// "\179\156\146i\228\241\139\226\190\239]\vt{\230X\179",PropSubscriptionIdentifier 29,PropSharedSubscriptionAvailable +// 236,PropTopicAlias 9579,PropPayloadFormatIndicator 184,PropResponseTopic +// "\146\160\174;-\NUL\223#7j\"%\221n",PropMessageExpiryInterval 13344,PropAssignedClientIdentifier +// "(\235\t\133\216\230\STX@``\180\190\238\&6\246l\156_",PropMessageExpiryInterval 26407]} TEST(Publish5QCTest, Encode30) { - uint8_t pkt[] = {0x33, 0xfa, 0x1, 0x0, 0xb, 0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24, 0x71, - 0xf2, 0xe3, 0x1, 0x17, 0x77, 0x1, 0xef, 0x28, 0x73, 0x27, 0x0, 0x0, 0x62, 0xd8, 0x12, 0x0, 0xc, - 0x6e, 0x34, 0xef, 0x38, 0x6d, 0xa3, 0xe1, 0x54, 0x2f, 0xb5, 0xe6, 0xbd, 0x1f, 0x0, 0xb, 0x91, 0x1f, - 0x76, 0x98, 0x76, 0x79, 0x11, 0x7, 0x83, 0x31, 0xcf, 0x26, 0x0, 0x1e, 0x5e, 0xaa, 0x3d, 0xe5, 0x5a, - 0x14, 0xf1, 0xb5, 0x47, 0xf, 0x92, 0xfd, 0x3, 0xc, 0x88, 0x60, 0x7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b, 0x74, 0x7b, 0xe6, 0x58, 0xb3, 0xb, 0x1d, 0x2a, 0xec, 0x23, + 0x25, 0x6b, 0x1, 0xb8, 0x8, 0x0, 0xe, 0x92, 0xa0, 0xae, 0x3b, 0x2d, 0x0, 0xdf, 0x23, 0x37, 0x6a, + 0x22, 0x25, 0xdd, 0x6e, 0x2, 0x0, 0x0, 0x34, 0x20, 0x12, 0x0, 0x12, 0x28, 0xeb, 0x9, 0x85, 0xd8, + 0xe6, 0x2, 0x40, 0x60, 0x60, 0xb4, 0xbe, 0xee, 0x36, 0xf6, 0x6c, 0x9c, 0x5f, 0x2, 0x0, 0x0, 0x67, + 0x27, 0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, 0x11, + 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; + uint8_t topic_bytes[] = {0x13, 0x72, 0x3, 0x3, 0x5a, 0x1}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; + uint8_t msg_bytes[] = {0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, + 0x11, 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; - - uint8_t bytesprops0[] = {0x6e, 0x34, 0xef, 0x38, 0x6d, 0xa3, 0xe1, 0x54, 0x2f, 0xb5, 0xe6, 0xbd}; - uint8_t bytesprops1[] = {0x91, 0x1f, 0x76, 0x98, 0x76, 0x79, 0x11, 0x7, 0x83, 0x31, 0xcf}; - uint8_t bytesprops3[] = {0x61, 0x62, 0xb5, 0xc0, 0x10, 0x4a, 0x5b, 0xff, 0x76, 0x7d, 0xaf, 0xf, 0x83, - 0x52, 0x5e, 0x75, 0xee, 0x3a, 0x17, 0x90, 0xba, 0x67, 0x57, 0x2, 0x19, 0x98}; - uint8_t bytesprops2[] = {0x5e, 0xaa, 0x3d, 0xe5, 0x5a, 0x14, 0xf1, 0xb5, 0x47, 0xf, 0x92, 0xfd, 0x3, 0xc, 0x88, - 0x60, 0x7f, 0x36, 0xef, 0xa5, 0x3b, 0x37, 0x82, 0x7f, 0xe0, 0xc6, 0x49, 0x2d, 0xb8, 0xe5}; - uint8_t bytesprops4[] = {0xdd, 0x34, 0x27, 0xb8, 0x32, 0xf, 0xcf, 0xea, 0x23}; - uint8_t bytesprops5[] = {0x60, 0x4e, 0xf9, 0x71, 0x68, 0x2a, 0xf, 0x7d, 0xb1, 0x82, 0xc6}; - uint8_t bytesprops6[] = {0x70, 0xb2, 0x5b, 0x26, 0x73, 0x3c, 0x5b, 0x82, 0xd4, 0x52, 0xc6, 0x84, 0xf3, 0xa8, 0x14}; - uint8_t bytesprops8[] = {0x4d, 0x2d, 0x5a, 0x71, 0x5c, 0xf7, 0x48, 0x3, 0xd2, 0xde, 0xb6, 0x36, 0x77, - 0xb6, 0x6b, 0x26, 0x7c, 0xcf, 0xe6, 0x66, 0x3, 0x2c, 0x98, 0x47, 0x40, 0x86}; - uint8_t bytesprops7[] = {0x8b, 0x52, 0xcd, 0xee, 0x2f, 0xb1, 0xeb, 0x7d, 0xc2, 0x19, 0xb3}; - uint8_t bytesprops9[] = {0x3c}; + msg.payload_len = 30; + + uint8_t bytesprops1[] = {0x8a, 0xde, 0x53, 0x34, 0xb0, 0xc, 0x89, 0x25, 0x28, 0xb0, 0x0}; + uint8_t bytesprops0[] = {0xaa, 0x1d, 0x2e, 0xa, 0xdb, 0xec, 0xb1, 0xd2, 0x73, 0xa6, 0xf1, 0xe3, 0x57, 0xcc}; + uint8_t bytesprops2[] = {0xcc, 0x74, 0x31, 0xd7, 0xdc, 0x85, 0x67, 0x6d, 0xca, 0x3f, 0x62, 0x59, 0x6c, + 0x86, 0x7f, 0x48, 0x31, 0x49, 0x2, 0x64, 0x1d, 0x4a, 0x5f, 0x1c, 0xc1, 0x48}; + uint8_t bytesprops3[] = {0xcd, 0xc6, 0xa3, 0xce, 0xfb, 0xc0, 0x55, 0x85, + 0xec, 0x26, 0xbd, 0xb1, 0x6, 0xb5, 0x21, 0x90}; + uint8_t bytesprops4[] = {0xc2, 0xd7, 0xf1, 0xa3, 0xa5, 0x1e, 0xf1, 0xde, 0x44, 0x22, 0xe0, 0x5e, 0xdb, 0x9a, + 0x43, 0xbe, 0x8f, 0x72, 0x5e, 0x79, 0x64, 0xa7, 0xc0, 0x29, 0xdf, 0xc3, 0xab}; + uint8_t bytesprops6[] = {0xb3, 0x9c, 0x92, 0x69, 0xe4, 0xf1, 0x8b, 0xe2, 0xbe, + 0xef, 0x5d, 0xb, 0x74, 0x7b, 0xe6, 0x58, 0xb3}; + uint8_t bytesprops5[] = {0x35, 0x5b, 0x8e, 0x28, 0xc7, 0x3c, 0x83, 0x85, 0xa0, 0x9a, 0xa0, 0x7c, 0x41, 0xa2, 0x55}; + uint8_t bytesprops7[] = {0x92, 0xa0, 0xae, 0x3b, 0x2d, 0x0, 0xdf, 0x23, 0x37, 0x6a, 0x22, 0x25, 0xdd, 0x6e}; + uint8_t bytesprops8[] = {0x28, 0xeb, 0x9, 0x85, 0xd8, 0xe6, 0x2, 0x40, 0x60, + 0x60, 0xb4, 0xbe, 0xee, 0x36, 0xf6, 0x6c, 0x9c, 0x5f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25304}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops2}, .v = {26, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20060}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20002}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops7}, .v = {26, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24311}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29821}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops0}, .v = {11, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3685}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26825}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32203}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11069}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops5}, .v = {17, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9579}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13344}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26407}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29170, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\191k-$.\245\SUB\192\234\155$", -// _pubPktID = 29170, _pubBody = "[F\181\186O\149", _pubProps = [PropRequestProblemInformation -// 119,PropPayloadFormatIndicator 239,PropWildcardSubscriptionAvailable 115,PropMaximumPacketSize -// 25304,PropAssignedClientIdentifier "n4\239\&8m\163\225T/\181\230\189",PropReasonString -// "\145\USv\152vy\DC1\a\131\&1\207",PropUserProperty -// "^\170=\229Z\DC4\241\181G\SI\146\253\ETX\f\136`\DEL6\239\165;7\130\DEL\224\198I-\184\229" -// "ab\181\192\DLEJ[\255v}\175\SI\131R^u\238:\ETB\144\186gW\STX\EM\152",PropServerKeepAlive 20060,PropReasonString -// "\221\&4'\184\&2\SI\207\234#",PropSharedSubscriptionAvailable 134,PropSubscriptionIdentifier -// 12,PropPayloadFormatIndicator 201,PropPayloadFormatIndicator 253,PropAuthenticationData -// "`N\249qh*\SI}\177\130\198",PropMessageExpiryInterval 20002,PropRequestProblemInformation -// 106,PropAuthenticationMethod "p\178[&s<[\130\212R\198\132\243\168\DC4",PropRequestResponseInformation -// 96,PropUserProperty "\139R\205\238/\177\235}\194\EM\179" -// "M-Zq\\\247H\ETX\210\222\182\&6w\182k&|\207\230f\ETX,\152G@\134",PropMaximumQoS 111,PropWillDelayInterval -// 24311,PropWildcardSubscriptionAvailable 44,PropRequestResponseInformation 218,PropMaximumPacketSize -// 29821,PropContentType "<"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3r\ETX\ETXZ\SOH", _pubPktID = 0, +// _pubBody = "\129\209\171[\DC4B\234\ETX\ACK\177\133\&9\ENQf\128\DC1A\185\236M\134qT}\\g\159&;g", _pubProps = +// [PropUserProperty "\170\GS.\n\219\236\177\210s\166\241\227W\204" "\138\222S4\176\f\137%(\176\NUL",PropServerKeepAlive +// 3685,PropSharedSubscriptionAvailable 95,PropAssignedClientIdentifier +// "\204t1\215\220\133gm\202?bYl\134\DELH1I\STXd\GSJ_\FS\193H",PropMessageExpiryInterval 26825,PropReasonString +// "\205\198\163\206\251\192U\133\236&\189\177\ACK\181!\144",PropWildcardSubscriptionAvailable +// 188,PropRequestProblemInformation 198,PropMessageExpiryInterval 32203,PropWillDelayInterval 11069,PropContentType +// "\194\215\241\163\165\RS\241\222D\"\224^\219\154C\190\143r^yd\167\192)\223\195\171",PropUserProperty +// "5[\142(\199<\131\133\160\154\160|A\162U" +// "\179\156\146i\228\241\139\226\190\239]\vt{\230X\179",PropSubscriptionIdentifier 29,PropSharedSubscriptionAvailable +// 236,PropTopicAlias 9579,PropPayloadFormatIndicator 184,PropResponseTopic +// "\146\160\174;-\NUL\223#7j\"%\221n",PropMessageExpiryInterval 13344,PropAssignedClientIdentifier +// "(\235\t\133\216\230\STX@``\180\190\238\&6\246l\156_",PropMessageExpiryInterval 26407]} TEST(Publish5QCTest, Decode30) { - uint8_t pkt[] = {0x33, 0xfa, 0x1, 0x0, 0xb, 0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24, 0x71, - 0xf2, 0xe3, 0x1, 0x17, 0x77, 0x1, 0xef, 0x28, 0x73, 0x27, 0x0, 0x0, 0x62, 0xd8, 0x12, 0x0, 0xc, - 0x6e, 0x34, 0xef, 0x38, 0x6d, 0xa3, 0xe1, 0x54, 0x2f, 0xb5, 0xe6, 0xbd, 0x1f, 0x0, 0xb, 0x91, 0x1f, - 0x76, 0x98, 0x76, 0x79, 0x11, 0x7, 0x83, 0x31, 0xcf, 0x26, 0x0, 0x1e, 0x5e, 0xaa, 0x3d, 0xe5, 0x5a, - 0x14, 0xf1, 0xb5, 0x47, 0xf, 0x92, 0xfd, 0x3, 0xc, 0x88, 0x60, 0x7f, 0x36, 0xef, 0xa5, 0x3b, 0x37, - 0x82, 0x7f, 0xe0, 0xc6, 0x49, 0x2d, 0xb8, 0xe5, 0x0, 0x1a, 0x61, 0x62, 0xb5, 0xc0, 0x10, 0x4a, 0x5b, - 0xff,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 0xe6, 0x2, 0x40, 0x60, 0x60, 0xb4, 0xbe, 0xee, 0x36, 0xf6, 0x6c, 0x9c, 0x5f, 0x2, 0x0, 0x0, 0x67, + 0x27, 0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, 0x11, + 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4968,30 +5323,32 @@ TEST(Publish5QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xbf, 0x6b, 0x2d, 0x24, 0x2e, 0xf5, 0x1a, 0xc0, 0xea, 0x9b, 0x24}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5b, 0x46, 0xb5, 0xba, 0x4f, 0x95}; - lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x13, 0x72, 0x3, 0x3, 0x5a, 0x1}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, + 0x11, 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29170); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 6); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\STXF\139\182d\236&\232\&0\220\246\150\CAN\210\147K\245O\160W*D\145\202", _willMsg = -// "\255\138T\159\195[tN\169\244\200*\226/\ENQ\238\251\DC3", _willProps = []}), _cleanSession = True, _keepAlive = -// 23007, _connID = "\172\233\209\170i\141", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "Ke\173x'\220\170U\137[)Z\178\208[", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "M\150!\226\146b.\172]E2\203\181H\189\229`\158", _willMsg = +// "\254\224C\179\DC48p\a%0\153A\138\190\225Yw(dG\204\187\t5w\154\138F\208", _willProps = []}), _cleanSession = True, +// _keepAlive = 3972, _connID = "j\165k\247>\ENQ\145Xh\181N\246!\SUBX\201", _properties = []} TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x59, 0xdf, 0x0, 0x6, 0xac, 0xe9, 0xd1, - 0xaa, 0x69, 0x8d, 0x0, 0x18, 0x2, 0x46, 0x8b, 0xb6, 0x64, 0xec, 0x26, 0xe8, 0x30, 0xdc, 0xf6, 0x96, - 0x18, 0xd2, 0x93, 0x4b, 0xf5, 0x4f, 0xa0, 0x57, 0x2a, 0x44, 0x91, 0xca, 0x0, 0x12, 0xff, 0x8a, 0x54, - 0x9f, 0xc3, 0x5b, 0x74, 0x4e, 0xa9, 0xf4, 0xc8, 0x2a, 0xe2, 0x2f, 0x5, 0xee, 0xfb, 0x13}; + uint8_t pkt[] = {0x10, 0x4f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0xf, 0x84, 0x0, 0x10, 0x6a, 0xa5, 0x6b, + 0xf7, 0x3e, 0x5, 0x91, 0x58, 0x68, 0xb5, 0x4e, 0xf6, 0x21, 0x1a, 0x58, 0xc9, 0x0, 0x12, 0x4d, 0x96, + 0x21, 0xe2, 0x92, 0x62, 0x2e, 0xac, 0x5d, 0x45, 0x32, 0xcb, 0xb5, 0x48, 0xbd, 0xe5, 0x60, 0x9e, 0x0, + 0x1d, 0xfe, 0xe0, 0x43, 0xb3, 0x14, 0x38, 0x70, 0x7, 0x25, 0x30, 0x99, 0x41, 0x8a, 0xbe, 0xe1, 0x59, + 0x77, 0x28, 0x64, 0x47, 0xcc, 0xbb, 0x9, 0x35, 0x77, 0x9a, 0x8a, 0x46, 0xd0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5002,24 +5359,29 @@ TEST(Connect311QCTest, Encode1) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2, 0x46, 0x8b, 0xb6, 0x64, 0xec, 0x26, 0xe8, 0x30, 0xdc, 0xf6, 0x96, - 0x18, 0xd2, 0x93, 0x4b, 0xf5, 0x4f, 0xa0, 0x57, 0x2a, 0x44, 0x91, 0xca}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xff, 0x8a, 0x54, 0x9f, 0xc3, 0x5b, 0x74, 0x4e, 0xa9, - 0xf4, 0xc8, 0x2a, 0xe2, 0x2f, 0x5, 0xee, 0xfb, 0x13}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x4d, 0x96, 0x21, 0xe2, 0x92, 0x62, 0x2e, 0xac, 0x5d, + 0x45, 0x32, 0xcb, 0xb5, 0x48, 0xbd, 0xe5, 0x60, 0x9e}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfe, 0xe0, 0x43, 0xb3, 0x14, 0x38, 0x70, 0x7, 0x25, 0x30, + 0x99, 0x41, 0x8a, 0xbe, 0xe1, 0x59, 0x77, 0x28, 0x64, 0x47, + 0xcc, 0xbb, 0x9, 0x35, 0x77, 0x9a, 0x8a, 0x46, 0xd0}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 23007; - uint8_t client_id_bytes[] = {0xac, 0xe9, 0xd1, 0xaa, 0x69, 0x8d}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.keep_alive = 3972; + uint8_t client_id_bytes[] = {0x6a, 0xa5, 0x6b, 0xf7, 0x3e, 0x5, 0x91, 0x58, + 0x68, 0xb5, 0x4e, 0xf6, 0x21, 0x1a, 0x58, 0xc9}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t password_bytes[] = {0x4b, 0x65, 0xad, 0x78, 0x27, 0xdc, 0xaa, 0x55, 0x89, 0x5b, 0x29, 0x5a, 0xb2, 0xd0, 0x5b}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5028,18 +5390,19 @@ TEST(Connect311QCTest, Encode1) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\162\167;\233}\166*\194\SO5I", _password = Just -// "\206\SYN\252];b\f|\249\239\199!!\ETB\142fz\153\250>bv\DC1\ETX\134", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS1, _willTopic = "\DELF\240\209\&7W\203U~\ETBsd", _willMsg = "\146\191]\f|", _willProps = []}), -// _cleanSession = True, _keepAlive = 7161, _connID = "AG\180\214\&5\245\a\196\164Fq\209\141\250>\246\RS", _properties = +// ConnectRequest {_username = Just "+\217\245\132J\219\160\139\232\213\SO\189\NUL-\DC3", _password = Nothing, _lastWill +// = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "O\SOH\173\164\238\248\f&\NULP\175\136/,\ETB\255\GS\208\247\DELt\129\193\169\EOT", _willMsg = +// "\138\229\222\220\216/\219\197\224\ETB\177\DEL.\165<\210\150\182\209\222\SOH\NAK(R\177\134\ETX\ETB", _willProps = +// []}), _cleanSession = True, _keepAlive = 20710, _connID = "\153\186\STX-\152\157\214\157\245\"4\"\ETX", _properties = // []} TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x1b, 0xf9, 0x0, 0x11, 0x41, 0x47, - 0xb4, 0xd6, 0x35, 0xf5, 0x7, 0xc4, 0xa4, 0x46, 0x71, 0xd1, 0x8d, 0xfa, 0x3e, 0xf6, 0x1e, 0x0, - 0xc, 0x7f, 0x46, 0xf0, 0xd1, 0x37, 0x57, 0xcb, 0x55, 0x7e, 0x17, 0x73, 0x64, 0x0, 0x5, 0x92, - 0xbf, 0x5d, 0xc, 0x7c, 0x0, 0xb, 0xa2, 0xa7, 0x3b, 0xe9, 0x7d, 0xa6, 0x2a, 0xc2, 0xe, 0x35, - 0x49, 0x0, 0x19, 0xce, 0x16, 0xfc, 0x5d, 0x3b, 0x62, 0xc, 0x7c, 0xf9, 0xef, 0xc7, 0x21, 0x21, - 0x17, 0x8e, 0x66, 0x7a, 0x99, 0xfa, 0x3e, 0x62, 0x76, 0x11, 0x3, 0x86}; + uint8_t pkt[] = {0x10, 0x63, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb6, 0x50, 0xe6, 0x0, 0xd, 0x99, 0xba, 0x2, + 0x2d, 0x98, 0x9d, 0xd6, 0x9d, 0xf5, 0x22, 0x34, 0x22, 0x3, 0x0, 0x19, 0x4f, 0x1, 0xad, 0xa4, 0xee, + 0xf8, 0xc, 0x26, 0x0, 0x50, 0xaf, 0x88, 0x2f, 0x2c, 0x17, 0xff, 0x1d, 0xd0, 0xf7, 0x7f, 0x74, 0x81, + 0xc1, 0xa9, 0x4, 0x0, 0x1c, 0x8a, 0xe5, 0xde, 0xdc, 0xd8, 0x2f, 0xdb, 0xc5, 0xe0, 0x17, 0xb1, 0x7f, + 0x2e, 0xa5, 0x3c, 0xd2, 0x96, 0xb6, 0xd1, 0xde, 0x1, 0x15, 0x28, 0x52, 0xb1, 0x86, 0x3, 0x17, 0x0, + 0xf, 0x2b, 0xd9, 0xf5, 0x84, 0x4a, 0xdb, 0xa0, 0x8b, 0xe8, 0xd5, 0xe, 0xbd, 0x0, 0x2d, 0x13}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5050,30 +5413,27 @@ TEST(Connect311QCTest, Encode2) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x7f, 0x46, 0xf0, 0xd1, 0x37, 0x57, 0xcb, 0x55, 0x7e, 0x17, 0x73, 0x64}; - lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x92, 0xbf, 0x5d, 0xc, 0x7c}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x4f, 0x1, 0xad, 0xa4, 0xee, 0xf8, 0xc, 0x26, 0x0, 0x50, 0xaf, 0x88, 0x2f, + 0x2c, 0x17, 0xff, 0x1d, 0xd0, 0xf7, 0x7f, 0x74, 0x81, 0xc1, 0xa9, 0x4}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x8a, 0xe5, 0xde, 0xdc, 0xd8, 0x2f, 0xdb, 0xc5, 0xe0, 0x17, 0xb1, 0x7f, 0x2e, 0xa5, + 0x3c, 0xd2, 0x96, 0xb6, 0xd1, 0xde, 0x1, 0x15, 0x28, 0x52, 0xb1, 0x86, 0x3, 0x17}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 7161; - uint8_t client_id_bytes[] = {0x41, 0x47, 0xb4, 0xd6, 0x35, 0xf5, 0x7, 0xc4, 0xa4, - 0x46, 0x71, 0xd1, 0x8d, 0xfa, 0x3e, 0xf6, 0x1e}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.keep_alive = 20710; + uint8_t client_id_bytes[] = {0x99, 0xba, 0x2, 0x2d, 0x98, 0x9d, 0xd6, 0x9d, 0xf5, 0x22, 0x34, 0x22, 0x3}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa2, 0xa7, 0x3b, 0xe9, 0x7d, 0xa6, 0x2a, 0xc2, 0xe, 0x35, 0x49}; - lwmqtt_string_t username = {11, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x2b, 0xd9, 0xf5, 0x84, 0x4a, 0xdb, 0xa0, 0x8b, 0xe8, 0xd5, 0xe, 0xbd, 0x0, 0x2d, 0x13}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xce, 0x16, 0xfc, 0x5d, 0x3b, 0x62, 0xc, 0x7c, 0xf9, 0xef, 0xc7, 0x21, 0x21, - 0x17, 0x8e, 0x66, 0x7a, 0x99, 0xfa, 0x3e, 0x62, 0x76, 0x11, 0x3, 0x86}; - lwmqtt_string_t password = {25, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5082,11 +5442,11 @@ TEST(Connect311QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\176gX", _password = Nothing, _lastWill = Nothing, _cleanSession = False, -// _keepAlive = 30736, _connID = "\211\169\254\161\DLE", _properties = []} +// ConnectRequest {_username = Just "\242\212u]\129\203\157", _password = Nothing, _lastWill = Nothing, _cleanSession = +// True, _keepAlive = 23152, _connID = "*\194\151\224rT\148\208", _properties = []} TEST(Connect311QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0x16, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x78, 0x10, - 0x0, 0x5, 0xd3, 0xa9, 0xfe, 0xa1, 0x10, 0x0, 0x3, 0xb0, 0x67, 0x58}; + uint8_t pkt[] = {0x10, 0x1d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x82, 0x5a, 0x70, 0x0, 0x8, 0x2a, 0xc2, + 0x97, 0xe0, 0x72, 0x54, 0x94, 0xd0, 0x0, 0x7, 0xf2, 0xd4, 0x75, 0x5d, 0x81, 0xcb, 0x9d}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5094,13 +5454,13 @@ TEST(Connect311QCTest, Encode3) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 30736; - uint8_t client_id_bytes[] = {0xd3, 0xa9, 0xfe, 0xa1, 0x10}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 23152; + uint8_t client_id_bytes[] = {0x2a, 0xc2, 0x97, 0xe0, 0x72, 0x54, 0x94, 0xd0}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb0, 0x67, 0x58}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf2, 0xd4, 0x75, 0x5d, 0x81, 0xcb, 0x9d}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); @@ -5110,19 +5470,17 @@ TEST(Connect311QCTest, Encode3) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\152\194\245\253\174\&7\EMM!8\179\176,\247\240\DC1\231\RS", _password = Just -// "/\242\177\206\FS\170L\220\250@\fO\156+2\DLE\GS\141\&5\180!\168t\129\133\aA\SO\213T", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "r\EOTA\136\195\188\137\213\144A\186\189\243\169\226\204\252", -// _willMsg = "\182\NAK", _willProps = []}), _cleanSession = True, _keepAlive = 8837, _connID = -// "\229-\130\155\154a\214\248\214l\CAN\138\244\210%\168\154\156\DC1\241\133\227\&1", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\DLEv\182\131p6", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS0, _willTopic = +// "\CAN=S\217\STX\226v\251\&6\161\SYN\168\SO:\DC2P\198\184\217\161\221\199\148\168\142\ETB\245\178", _willMsg = +// "f\241\n]\DC4\198\146\187\\\239\149x\163\194\179?\132\207S", _willProps = []}), _cleanSession = True, _keepAlive = +// 29624, _connID = "\ETX\151\174C\139\235\225Y\221\247r\201\167\189j\NUL", _properties = []} TEST(Connect311QCTest, Encode4) { - uint8_t pkt[] =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 0x5c, 0xef, 0x95, 0x78, 0xa3, 0xc2, 0xb3, 0x3f, 0x84, 0xcf, 0x53}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5133,31 +5491,27 @@ TEST(Connect311QCTest, Encode4) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x72, 0x4, 0x41, 0x88, 0xc3, 0xbc, 0x89, 0xd5, 0x90, - 0x41, 0xba, 0xbd, 0xf3, 0xa9, 0xe2, 0xcc, 0xfc}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb6, 0x15}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x18, 0x3d, 0x53, 0xd9, 0x2, 0xe2, 0x76, 0xfb, 0x36, 0xa1, 0x16, 0xa8, 0xe, 0x3a, + 0x12, 0x50, 0xc6, 0xb8, 0xd9, 0xa1, 0xdd, 0xc7, 0x94, 0xa8, 0x8e, 0x17, 0xf5, 0xb2}; + lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x66, 0xf1, 0xa, 0x5d, 0x14, 0xc6, 0x92, 0xbb, 0x5c, 0xef, + 0x95, 0x78, 0xa3, 0xc2, 0xb3, 0x3f, 0x84, 0xcf, 0x53}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 8837; - uint8_t client_id_bytes[] = {0xe5, 0x2d, 0x82, 0x9b, 0x9a, 0x61, 0xd6, 0xf8, 0xd6, 0x6c, 0x18, 0x8a, - 0xf4, 0xd2, 0x25, 0xa8, 0x9a, 0x9c, 0x11, 0xf1, 0x85, 0xe3, 0x31}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 29624; + uint8_t client_id_bytes[] = {0x3, 0x97, 0xae, 0x43, 0x8b, 0xeb, 0xe1, 0x59, + 0xdd, 0xf7, 0x72, 0xc9, 0xa7, 0xbd, 0x6a, 0x0}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x98, 0xc2, 0xf5, 0xfd, 0xae, 0x37, 0x19, 0x4d, 0x21, - 0x38, 0xb3, 0xb0, 0x2c, 0xf7, 0xf0, 0x11, 0xe7, 0x1e}; - lwmqtt_string_t username = {18, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x2f, 0xf2, 0xb1, 0xce, 0x1c, 0xaa, 0x4c, 0xdc, 0xfa, 0x40, 0xc, 0x4f, 0x9c, 0x2b, 0x32, - 0x10, 0x1d, 0x8d, 0x35, 0xb4, 0x21, 0xa8, 0x74, 0x81, 0x85, 0x7, 0x41, 0xe, 0xd5, 0x54}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x10, 0x76, 0xb6, 0x83, 0x70, 0x36}; + lwmqtt_string_t password = {6, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5167,67 +5521,48 @@ TEST(Connect311QCTest, Encode4) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "Fl\165\191E\132:\161", _password = Nothing, _lastWill = Just (LastWill {_willRetain -// = True, _willQoS = QoS2, _willTopic = "\213\133\231\FS\130\ACKE\191\250\EM\neI\a\139\243\227\216J\222\222", _willMsg -// = "\247\199pz\189\158\163r[\131P\201w\133", _willProps = []}), _cleanSession = True, _keepAlive = 10218, _connID = -// "\242\150&X\DC2\211\232+\139", _properties = []} +// ConnectRequest {_username = Just "K\229g\209}\210\138\137T;\154Eh", _password = Nothing, _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 31695, _connID = "cG\191s\155\131\202\186\155\&5C\DC2\207\217\173\144 +// \248\248\148", _properties = []} TEST(Connect311QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb6, 0x27, 0xea, 0x0, 0x9, 0xf2, - 0x96, 0x26, 0x58, 0x12, 0xd3, 0xe8, 0x2b, 0x8b, 0x0, 0x15, 0xd5, 0x85, 0xe7, 0x1c, 0x82, - 0x6, 0x45, 0xbf, 0xfa, 0x19, 0xa, 0x65, 0x49, 0x7, 0x8b, 0xf3, 0xe3, 0xd8, 0x4a, 0xde, - 0xde, 0x0, 0xe, 0xf7, 0xc7, 0x70, 0x7a, 0xbd, 0x9e, 0xa3, 0x72, 0x5b, 0x83, 0x50, 0xc9, - 0x77, 0x85, 0x0, 0x8, 0x46, 0x6c, 0xa5, 0xbf, 0x45, 0x84, 0x3a, 0xa1}; + uint8_t pkt[] = {0x10, 0x2f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x82, 0x7b, 0xcf, 0x0, 0x14, 0x63, 0x47, 0xbf, + 0x73, 0x9b, 0x83, 0xca, 0xba, 0x9b, 0x35, 0x43, 0x12, 0xcf, 0xd9, 0xad, 0x90, 0x20, 0xf8, 0xf8, 0x94, + 0x0, 0xd, 0x4b, 0xe5, 0x67, 0xd1, 0x7d, 0xd2, 0x8a, 0x89, 0x54, 0x3b, 0x9a, 0x45, 0x68}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd5, 0x85, 0xe7, 0x1c, 0x82, 0x6, 0x45, 0xbf, 0xfa, 0x19, 0xa, - 0x65, 0x49, 0x7, 0x8b, 0xf3, 0xe3, 0xd8, 0x4a, 0xde, 0xde}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf7, 0xc7, 0x70, 0x7a, 0xbd, 0x9e, 0xa3, 0x72, 0x5b, 0x83, 0x50, 0xc9, 0x77, 0x85}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 10218; - uint8_t client_id_bytes[] = {0xf2, 0x96, 0x26, 0x58, 0x12, 0xd3, 0xe8, 0x2b, 0x8b}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.keep_alive = 31695; + uint8_t client_id_bytes[] = {0x63, 0x47, 0xbf, 0x73, 0x9b, 0x83, 0xca, 0xba, 0x9b, 0x35, + 0x43, 0x12, 0xcf, 0xd9, 0xad, 0x90, 0x20, 0xf8, 0xf8, 0x94}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x46, 0x6c, 0xa5, 0xbf, 0x45, 0x84, 0x3a, 0xa1}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x4b, 0xe5, 0x67, 0xd1, 0x7d, 0xd2, 0x8a, 0x89, 0x54, 0x3b, 0x9a, 0x45, 0x68}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "Sz8i\155\185\247\FSM\223\r`\"\187\ACK\244\ETB7(\218^\ETX~\231o+\166\\", _password = -// Just "\254", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "\178\171\DC2\211\200\EM\184\SOH\SI1\182\142\236\165\201\180\217\179\236y\215\n", _willMsg = -// "\176\DC3\142\CAN5\229j\140\194\241\152", _willProps = []}), _cleanSession = True, _keepAlive = 13826, _connID = -// "eYUoE\DELM\180&\227\132\v\STX\ESC\198\183?\245\247n\197\DC1", _properties = []} +// ConnectRequest {_username = Just +// "\175'\US7>\EOT-K\160\NUL\SO\134T\148\232\194\132b\218\SIE\241L\156\204\169\145X3\250", _password = Nothing, +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\CANf\159\155m", _willMsg = +// "\155)T\206\250\163y-\213[_\a\159\GS=\195L\155L\164\220\243\225)\208p", _willProps = []}), _cleanSession = True, +// _keepAlive = 11529, _connID = "", _properties = []} TEST(Connect311QCTest, Encode6) { - uint8_t pkt[] = {0x10, 0x68, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x36, 0x2, 0x0, 0x16, 0x65, 0x59, - 0x55, 0x6f, 0x45, 0x7f, 0x4d, 0xb4, 0x26, 0xe3, 0x84, 0xb, 0x2, 0x1b, 0xc6, 0xb7, 0x3f, 0xf5, - 0xf7, 0x6e, 0xc5, 0x11, 0x0, 0x16, 0xb2, 0xab, 0x12, 0xd3, 0xc8, 0x19, 0xb8, 0x1, 0xf, 0x31, - 0xb6, 0x8e, 0xec, 0xa5, 0xc9, 0xb4, 0xd9, 0xb3, 0xec, 0x79, 0xd7, 0xa, 0x0, 0xb, 0xb0, 0x13, - 0x8e, 0x18, 0x35, 0xe5, 0x6a, 0x8c, 0xc2, 0xf1, 0x98, 0x0, 0x1c, 0x53, 0x7a, 0x38, 0x69, 0x9b, - 0xb9, 0xf7, 0x1c, 0x4d, 0xdf, 0xd, 0x60, 0x22, 0xbb, 0x6, 0xf4, 0x17, 0x37, 0x28, 0xda, 0x5e, - 0x3, 0x7e, 0xe7, 0x6f, 0x2b, 0xa6, 0x5c, 0x0, 0x1, 0xfe}; + uint8_t pkt[] = {0x10, 0x4f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x96, 0x2d, 0x9, 0x0, 0x0, 0x0, 0x5, 0x18, + 0x66, 0x9f, 0x9b, 0x6d, 0x0, 0x1a, 0x9b, 0x29, 0x54, 0xce, 0xfa, 0xa3, 0x79, 0x2d, 0xd5, 0x5b, 0x5f, + 0x7, 0x9f, 0x1d, 0x3d, 0xc3, 0x4c, 0x9b, 0x4c, 0xa4, 0xdc, 0xf3, 0xe1, 0x29, 0xd0, 0x70, 0x0, 0x1e, + 0xaf, 0x27, 0x1f, 0x37, 0x3e, 0x4, 0x2d, 0x4b, 0xa0, 0x0, 0xe, 0x86, 0x54, 0x94, 0xe8, 0xc2, 0x84, + 0x62, 0xda, 0xf, 0x45, 0xf1, 0x4c, 0x9c, 0xcc, 0xa9, 0x91, 0x58, 0x33, 0xfa}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5238,31 +5573,27 @@ TEST(Connect311QCTest, Encode6) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb2, 0xab, 0x12, 0xd3, 0xc8, 0x19, 0xb8, 0x1, 0xf, 0x31, 0xb6, - 0x8e, 0xec, 0xa5, 0xc9, 0xb4, 0xd9, 0xb3, 0xec, 0x79, 0xd7, 0xa}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb0, 0x13, 0x8e, 0x18, 0x35, 0xe5, 0x6a, 0x8c, 0xc2, 0xf1, 0x98}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x18, 0x66, 0x9f, 0x9b, 0x6d}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x9b, 0x29, 0x54, 0xce, 0xfa, 0xa3, 0x79, 0x2d, 0xd5, 0x5b, 0x5f, 0x7, 0x9f, + 0x1d, 0x3d, 0xc3, 0x4c, 0x9b, 0x4c, 0xa4, 0xdc, 0xf3, 0xe1, 0x29, 0xd0, 0x70}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 13826; - uint8_t client_id_bytes[] = {0x65, 0x59, 0x55, 0x6f, 0x45, 0x7f, 0x4d, 0xb4, 0x26, 0xe3, 0x84, - 0xb, 0x2, 0x1b, 0xc6, 0xb7, 0x3f, 0xf5, 0xf7, 0x6e, 0xc5, 0x11}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.keep_alive = 11529; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x53, 0x7a, 0x38, 0x69, 0x9b, 0xb9, 0xf7, 0x1c, 0x4d, 0xdf, 0xd, 0x60, 0x22, 0xbb, - 0x6, 0xf4, 0x17, 0x37, 0x28, 0xda, 0x5e, 0x3, 0x7e, 0xe7, 0x6f, 0x2b, 0xa6, 0x5c}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xaf, 0x27, 0x1f, 0x37, 0x3e, 0x4, 0x2d, 0x4b, 0xa0, 0x0, 0xe, 0x86, 0x54, 0x94, 0xe8, + 0xc2, 0x84, 0x62, 0xda, 0xf, 0x45, 0xf1, 0x4c, 0x9c, 0xcc, 0xa9, 0x91, 0x58, 0x33, 0xfa}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xfe}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5271,42 +5602,19 @@ TEST(Connect311QCTest, Encode6) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 28209, _connID = "\246\165\SI\142z\163\217\224;\170\DC1\145\161v\211e", _properties = []} +// ConnectRequest {_username = Just ")\212\206\157>[\161\161\240\140\191\206", _password = Just +// "\175\183\193,\\>\244\ESCS\204\NULC\a\SOH\235\t\US\NAK\DC3", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS0, _willTopic = "8m\ETB\253\&5\"\149h\193\210!\DC2\192\173\163\v\157\214z\231?", _willMsg = +// "~\239s\199\207\DLE\137)\195w\DEL\200D\166\195y\230\ETX\179\187\224\188\198@\212\ESC", _willProps = []}), +// _cleanSession = True, _keepAlive = 1137, _connID = "H\161", _properties = []} TEST(Connect311QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0x1c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x6e, 0x31, 0x0, 0x10, 0xf6, - 0xa5, 0xf, 0x8e, 0x7a, 0xa3, 0xd9, 0xe0, 0x3b, 0xaa, 0x11, 0x91, 0xa1, 0x76, 0xd3, 0x65}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 28209; - uint8_t client_id_bytes[] = {0xf6, 0xa5, 0xf, 0x8e, 0x7a, 0xa3, 0xd9, 0xe0, - 0x3b, 0xaa, 0x11, 0x91, 0xa1, 0x76, 0xd3, 0x65}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\EOTj\208\234\&8&{\198\226R\a\248\140\138", _password = Just -// "]TT\227$0q<\DLE\201/\223\204\&4.\225\146v\209\240\154\SI\189O,\183\237", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS2, _willTopic = "\145\172\175\249\r\146", _willMsg = "\227:\v\SYNN\201\f", _willProps = []}), -// _cleanSession = False, _keepAlive = 12527, _connID = "7\EOT\224", _properties = []} -TEST(Connect311QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x30, 0xef, 0x0, 0x3, 0x37, 0x4, - 0xe0, 0x0, 0x6, 0x91, 0xac, 0xaf, 0xf9, 0xd, 0x92, 0x0, 0x7, 0xe3, 0x3a, 0xb, 0x16, 0x4e, - 0xc9, 0xc, 0x0, 0xe, 0x4, 0x6a, 0xd0, 0xea, 0x38, 0x26, 0x7b, 0xc6, 0xe2, 0x52, 0x7, 0xf8, - 0x8c, 0x8a, 0x0, 0x1b, 0x5d, 0x54, 0x54, 0xe3, 0x24, 0x30, 0x71, 0x3c, 0x10, 0xc9, 0x2f, 0xdf, - 0xcc, 0x34, 0x2e, 0xe1, 0x92, 0x76, 0xd1, 0xf0, 0x9a, 0xf, 0xbd, 0x4f, 0x2c, 0xb7, 0xed}; + uint8_t pkt[] = {0x10, 0x64, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x4, 0x71, 0x0, 0x2, 0x48, + 0xa1, 0x0, 0x15, 0x38, 0x6d, 0x17, 0xfd, 0x35, 0x22, 0x95, 0x68, 0xc1, 0xd2, 0x21, 0x12, + 0xc0, 0xad, 0xa3, 0xb, 0x9d, 0xd6, 0x7a, 0xe7, 0x3f, 0x0, 0x1a, 0x7e, 0xef, 0x73, 0xc7, + 0xcf, 0x10, 0x89, 0x29, 0xc3, 0x77, 0x7f, 0xc8, 0x44, 0xa6, 0xc3, 0x79, 0xe6, 0x3, 0xb3, + 0xbb, 0xe0, 0xbc, 0xc6, 0x40, 0xd4, 0x1b, 0x0, 0xc, 0x29, 0xd4, 0xce, 0x9d, 0x3e, 0x5b, + 0xa1, 0xa1, 0xf0, 0x8c, 0xbf, 0xce, 0x0, 0x13, 0xaf, 0xb7, 0xc1, 0x2c, 0x5c, 0x3e, 0xf4, + 0x1b, 0x53, 0xcc, 0x0, 0x43, 0x7, 0x1, 0xeb, 0x9, 0x1f, 0x15, 0x13}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5317,28 +5625,30 @@ TEST(Connect311QCTest, Encode8) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x91, 0xac, 0xaf, 0xf9, 0xd, 0x92}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe3, 0x3a, 0xb, 0x16, 0x4e, 0xc9, 0xc}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x38, 0x6d, 0x17, 0xfd, 0x35, 0x22, 0x95, 0x68, 0xc1, 0xd2, 0x21, + 0x12, 0xc0, 0xad, 0xa3, 0xb, 0x9d, 0xd6, 0x7a, 0xe7, 0x3f}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7e, 0xef, 0x73, 0xc7, 0xcf, 0x10, 0x89, 0x29, 0xc3, 0x77, 0x7f, 0xc8, 0x44, + 0xa6, 0xc3, 0x79, 0xe6, 0x3, 0xb3, 0xbb, 0xe0, 0xbc, 0xc6, 0x40, 0xd4, 0x1b}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12527; - uint8_t client_id_bytes[] = {0x37, 0x4, 0xe0}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 1137; + uint8_t client_id_bytes[] = {0x48, 0xa1}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x4, 0x6a, 0xd0, 0xea, 0x38, 0x26, 0x7b, 0xc6, 0xe2, 0x52, 0x7, 0xf8, 0x8c, 0x8a}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x29, 0xd4, 0xce, 0x9d, 0x3e, 0x5b, 0xa1, 0xa1, 0xf0, 0x8c, 0xbf, 0xce}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x5d, 0x54, 0x54, 0xe3, 0x24, 0x30, 0x71, 0x3c, 0x10, 0xc9, 0x2f, 0xdf, 0xcc, 0x34, - 0x2e, 0xe1, 0x92, 0x76, 0xd1, 0xf0, 0x9a, 0xf, 0xbd, 0x4f, 0x2c, 0xb7, 0xed}; - lwmqtt_string_t password = {27, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xaf, 0xb7, 0xc1, 0x2c, 0x5c, 0x3e, 0xf4, 0x1b, 0x53, 0xcc, + 0x0, 0x43, 0x7, 0x1, 0xeb, 0x9, 0x1f, 0x15, 0x13}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5348,18 +5658,17 @@ TEST(Connect311QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\205!\164q;\149|\140\239|\234\FS\EOT", _password = Just -// "BE\v*U\EM'\159\157\SYNm\DLEn\192\136\vS\"\244\NUL9\228'\195\139\EOT\197\200\194", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "H", _willMsg = -// "\225\198\150\163\208W\238\146\FS\223_\201\251%\143\NUL\243\162\225ll\147\157Z\237\208\211W)", _willProps = []}), -// _cleanSession = True, _keepAlive = 13897, _connID = "\233\129 ", _properties = []} -TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x5f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x36, 0x49, 0x0, 0x3, 0xe9, 0x81, 0x20, - 0x0, 0x1, 0x48, 0x0, 0x1d, 0xe1, 0xc6, 0x96, 0xa3, 0xd0, 0x57, 0xee, 0x92, 0x1c, 0xdf, 0x5f, 0xc9, - 0xfb, 0x25, 0x8f, 0x0, 0xf3, 0xa2, 0xe1, 0x6c, 0x6c, 0x93, 0x9d, 0x5a, 0xed, 0xd0, 0xd3, 0x57, 0x29, - 0x0, 0xd, 0xcd, 0x21, 0xa4, 0x71, 0x3b, 0x95, 0x7c, 0x8c, 0xef, 0x7c, 0xea, 0x1c, 0x4, 0x0, 0x1d, - 0x42, 0x45, 0xb, 0x2a, 0x55, 0x19, 0x27, 0x9f, 0x9d, 0x16, 0x6d, 0x10, 0x6e, 0xc0, 0x88, 0xb, 0x53, - 0x22, 0xf4, 0x0, 0x39, 0xe4, 0x27, 0xc3, 0x8b, 0x4, 0xc5, 0xc8, 0xc2}; +// ConnectRequest {_username = Just "\144", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS2, _willTopic = "\ACKb<[2\a\182/h\252g\145S\156\179?6\NAK\232/\SO\241\213P\bk", _willMsg = +// "\EM\140\168c\240\ESC]:\250l\160>CT\DC4\ETB\209\DC2", _willProps = []}), _cleanSession = False, _keepAlive = 1187, +// _connID = "\162\135\139O\243\166\t(\204\167\213e\215\220d\185\n\149\233\144\b\218\229\235,", _properties = []} +TEST(Connect311QCTest, Encode8) { + uint8_t pkt[] = {0x10, 0x58, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x94, 0x4, 0xa3, 0x0, 0x19, 0xa2, + 0x87, 0x8b, 0x4f, 0xf3, 0xa6, 0x9, 0x28, 0xcc, 0xa7, 0xd5, 0x65, 0xd7, 0xdc, 0x64, 0xb9, + 0xa, 0x95, 0xe9, 0x90, 0x8, 0xda, 0xe5, 0xeb, 0x2c, 0x0, 0x1a, 0x6, 0x62, 0x3c, 0x5b, + 0x32, 0x7, 0xb6, 0x2f, 0x68, 0xfc, 0x67, 0x91, 0x53, 0x9c, 0xb3, 0x3f, 0x36, 0x15, 0xe8, + 0x2f, 0xe, 0xf1, 0xd5, 0x50, 0x8, 0x6b, 0x0, 0x12, 0x19, 0x8c, 0xa8, 0x63, 0xf0, 0x1b, + 0x5d, 0x3a, 0xfa, 0x6c, 0xa0, 0x3e, 0x43, 0x54, 0x14, 0x17, 0xd1, 0x12, 0x0, 0x1, 0x90}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5370,12 +5679,12 @@ TEST(Connect311QCTest, Encode9) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x48}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe1, 0xc6, 0x96, 0xa3, 0xd0, 0x57, 0xee, 0x92, 0x1c, 0xdf, - 0x5f, 0xc9, 0xfb, 0x25, 0x8f, 0x0, 0xf3, 0xa2, 0xe1, 0x6c, - 0x6c, 0x93, 0x9d, 0x5a, 0xed, 0xd0, 0xd3, 0x57, 0x29}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x6, 0x62, 0x3c, 0x5b, 0x32, 0x7, 0xb6, 0x2f, 0x68, 0xfc, 0x67, 0x91, 0x53, + 0x9c, 0xb3, 0x3f, 0x36, 0x15, 0xe8, 0x2f, 0xe, 0xf1, 0xd5, 0x50, 0x8, 0x6b}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x19, 0x8c, 0xa8, 0x63, 0xf0, 0x1b, 0x5d, 0x3a, 0xfa, + 0x6c, 0xa0, 0x3e, 0x43, 0x54, 0x14, 0x17, 0xd1, 0x12}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; @@ -5383,18 +5692,15 @@ TEST(Connect311QCTest, Encode9) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 13897; - uint8_t client_id_bytes[] = {0xe9, 0x81, 0x20}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 1187; + uint8_t client_id_bytes[] = {0xa2, 0x87, 0x8b, 0x4f, 0xf3, 0xa6, 0x9, 0x28, 0xcc, 0xa7, 0xd5, 0x65, 0xd7, + 0xdc, 0x64, 0xb9, 0xa, 0x95, 0xe9, 0x90, 0x8, 0xda, 0xe5, 0xeb, 0x2c}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xcd, 0x21, 0xa4, 0x71, 0x3b, 0x95, 0x7c, 0x8c, 0xef, 0x7c, 0xea, 0x1c, 0x4}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x90}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x42, 0x45, 0xb, 0x2a, 0x55, 0x19, 0x27, 0x9f, 0x9d, 0x16, 0x6d, 0x10, 0x6e, 0xc0, 0x88, - 0xb, 0x53, 0x22, 0xf4, 0x0, 0x39, 0xe4, 0x27, 0xc3, 0x8b, 0x4, 0xc5, 0xc8, 0xc2}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5403,16 +5709,15 @@ TEST(Connect311QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "B\186\246\255t\DC3^!\193Sq\185HB\196\232\246Y>p\ACK\187k\ETBu\142", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS1, _willTopic = "I;]\195\205\\\220z\EOT0:<'\ENQ\194D@1\238|", _willMsg = "`!\186\212fPy", _willProps = -// []}), _cleanSession = True, _keepAlive = 20788, _connID = -// "\155\US\157x\133\ESC,7_b\139\135\244\157\FS\201_\239D\203\r", _password = Just +// "\230WH\211", _lastWill = Nothing, _cleanSession = False, _keepAlive = 22088, _connID = "nx\237\250`\150", +// _properties = []} +TEST(Connect311QCTest, Encode10) { + uint8_t pkt[] = {0x10, 0x2e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x56, 0x48, 0x0, 0x6, 0x6e, 0x78, + 0xed, 0xfa, 0x60, 0x96, 0x0, 0x14, 0xc3, 0xe1, 0x5a, 0xf8, 0xa5, 0x53, 0xc9, 0x47, 0xa, 0x65, + 0x39, 0xa1, 0x3e, 0x1c, 0xc9, 0x5f, 0xef, 0x44, 0xcb, 0xd, 0x0, 0x4, 0xe6, 0x57, 0x48, 0xd3}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5471,18 +5768,17 @@ TEST(Connect311QCTest, Encode11) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 18569; - uint8_t client_id_bytes[] = {0x80, 0x53, 0x19, 0xe4, 0x22, 0x4b, 0xab, 0x67, 0x9e, 0x7d, 0xe3, 0x53, 0x56, - 0x36, 0x90, 0xe0, 0x12, 0x9f, 0xef, 0xd, 0x30, 0xa, 0x9c, 0x8c, 0x13}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 22088; + uint8_t client_id_bytes[] = {0x6e, 0x78, 0xed, 0xfa, 0x60, 0x96}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x64, 0x58, 0x55, 0x2d, 0xf0, 0x9a, 0xf5, 0x5d, 0x13, 0xf6, 0xb2, 0x84, 0xc8, 0xff, 0x93, - 0x4d, 0x4a, 0xea, 0x97, 0xd5, 0xff, 0xa8, 0xf8, 0x30, 0x8e, 0x50, 0xc, 0xb4, 0xc8}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xc3, 0xe1, 0x5a, 0xf8, 0xa5, 0x53, 0xc9, 0x47, 0xa, 0x65, + 0x39, 0xa1, 0x3e, 0x1c, 0xc9, 0x5f, 0xef, 0x44, 0xcb, 0xd}; + lwmqtt_string_t username = {20, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x80, 0x11, 0x8, 0x7e, 0x65, 0xc6, 0x55, 0xb1, 0x2, 0x27, 0x97, 0xa7, 0x35}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe6, 0x57, 0x48, 0xd3}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); @@ -5492,20 +5788,18 @@ TEST(Connect311QCTest, Encode11) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "|\226c4\183\131\239\242>\206\FS\195\145\176\134\EM4", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS0, _willTopic = "\254", _willMsg = "\ETXm\199\156Oznd*\US\135*", _willProps = []}), _cleanSession = +// True, _keepAlive = 17571, _connID = "}\227/\252\245n]F\190\242|\141\194\180\DLE\194\190\226W", _properties = []} +TEST(Connect311QCTest, Encode18) { + uint8_t pkt[] = {0x10, 0x50, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe6, 0x44, 0xa3, 0x0, 0x13, 0x7d, 0xe3, 0x2f, + 0xfc, 0xf5, 0x6e, 0x5d, 0x46, 0xbe, 0xf2, 0x7c, 0x8d, 0xc2, 0xb4, 0x10, 0xc2, 0xbe, 0xe2, 0x57, 0x0, + 0x1, 0xfe, 0x0, 0xc, 0x3, 0x6d, 0xc7, 0x9c, 0x4f, 0x7a, 0x6e, 0x64, 0x2a, 0x1f, 0x87, 0x2a, 0x0, + 0x8, 0x4a, 0x1, 0x49, 0x2d, 0x7, 0x29, 0xf4, 0x65, 0x0, 0x14, 0x6f, 0xf9, 0xa, 0xef, 0x4a, 0xf9, + 0x44, 0x3e, 0x83, 0xef, 0xf2, 0x3e, 0xce, 0x1c, 0xc3, 0x91, 0xb0, 0x86, 0x19, 0x34}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5823,11 +6142,10 @@ TEST(Connect311QCTest, Encode19) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8d, 0xd5, 0xda, 0x3d, 0x3f, 0x15, 0xc3, 0x3f, 0x26, 0x2c, 0xf6}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x66, 0xbc, 0x72, 0x3, 0xa0, 0x7e, 0x5f, 0x68, 0x29, 0x60, - 0x69, 0x7f, 0x6a, 0xe6, 0x27, 0x79, 0xc6, 0x12, 0xf8, 0x65}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xfe}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3, 0x6d, 0xc7, 0x9c, 0x4f, 0x7a, 0x6e, 0x64, 0x2a, 0x1f, 0x87, 0x2a}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -5836,16 +6154,17 @@ TEST(Connect311QCTest, Encode19) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 31425; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.keep_alive = 17571; + uint8_t client_id_bytes[] = {0x7d, 0xe3, 0x2f, 0xfc, 0xf5, 0x6e, 0x5d, 0x46, 0xbe, 0xf2, + 0x7c, 0x8d, 0xc2, 0xb4, 0x10, 0xc2, 0xbe, 0xe2, 0x57}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xfd, 0x8, 0xe6, 0xe0, 0xa0, 0x9a, 0x8a, 0xae}; + uint8_t username_bytes[] = {0x4a, 0x1, 0x49, 0x2d, 0x7, 0x29, 0xf4, 0x65}; lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x62, 0x3b, 0x38, 0x7b, 0x20, 0x90, 0xb7, 0xa1, 0xc6, 0x61, 0x3, - 0x3c, 0x47, 0x8e, 0x1, 0xd9, 0x18, 0x62, 0xe, 0xda, 0xea}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x6f, 0xf9, 0xa, 0xef, 0x4a, 0xf9, 0x44, 0x3e, 0x83, 0xef, + 0xf2, 0x3e, 0xce, 0x1c, 0xc3, 0x91, 0xb0, 0x86, 0x19, 0x34}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5855,16 +6174,16 @@ TEST(Connect311QCTest, Encode19) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "IW[\248-[*\NAK\135jJJ\144\&4\148\131H\242IId\184\196a|CB\242\NAK\238", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = "c\228\141Pj\227\200\RS", _willMsg = -// "O\181\146\172\&8\200\165pw\156:\227\160\204\"\219-y\US\214\168{", _willProps = []}), _cleanSession = False, -// _keepAlive = 18040, _connID = "\244\188\144", _properties = []} -TEST(Connect311QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0x31, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x14, 0x46, 0x78, 0x0, - 0x3, 0xf4, 0xbc, 0x90, 0x0, 0x8, 0x63, 0xe4, 0x8d, 0x50, 0x6a, 0xe3, 0xc8, - 0x1e, 0x0, 0x16, 0x4f, 0xb5, 0x92, 0xac, 0x38, 0xc8, 0xa5, 0x70, 0x77, 0x9c, - 0x3a, 0xe3, 0xa0, 0xcc, 0x22, 0xdb, 0x2d, 0x79, 0x1f, 0xd6, 0xa8, 0x7b}; +// ConnectRequest {_username = Nothing, _password = Just "\185\234\165\192W\204egO", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = +// "\254\234\SUB6\251\190\216\209\209\149\ETX\168\240\240\209\216\198rh\ETX\182!\187\172\232D", _willMsg = +// "\178\150\146w\234\131bw", _willProps = []}), _cleanSession = True, _keepAlive = 26206, _connID = +// "\225\SOY\244\214&\"\224\224\202\NAK\196\174", _properties = []} +TEST(Connect311QCTest, Encode19) { + uint8_t pkt[] = {0x10, 0x3f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x66, 0x5e, 0x0, 0xd, 0xe1, 0xe, 0x59, + 0xf4, 0xd6, 0x26, 0x22, 0xe0, 0xe0, 0xca, 0x15, 0xc4, 0xae, 0x0, 0x1a, 0xfe, 0xea, 0x1a, 0x36, 0xfb, + 0xbe, 0xd8, 0xd1, 0xd1, 0x95, 0x3, 0xa8, 0xf0, 0xf0, 0xd1, 0xd8, 0xc6, 0x72, 0x68, 0x3, 0xb6, 0x21, + 0xbb, 0xac, 0xe8, 0x44, 0x0, 0x8, 0xb2, 0x96, 0x92, 0x77, 0xea, 0x83, 0x62, 0x77}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5875,26 +6194,25 @@ TEST(Connect311QCTest, Encode20) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x63, 0xe4, 0x8d, 0x50, 0x6a, 0xe3, 0xc8, 0x1e}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4f, 0xb5, 0x92, 0xac, 0x38, 0xc8, 0xa5, 0x70, 0x77, 0x9c, 0x3a, - 0xe3, 0xa0, 0xcc, 0x22, 0xdb, 0x2d, 0x79, 0x1f, 0xd6, 0xa8, 0x7b}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xfe, 0xea, 0x1a, 0x36, 0xfb, 0xbe, 0xd8, 0xd1, 0xd1, 0x95, 0x3, 0xa8, 0xf0, + 0xf0, 0xd1, 0xd8, 0xc6, 0x72, 0x68, 0x3, 0xb6, 0x21, 0xbb, 0xac, 0xe8, 0x44}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb2, 0x96, 0x92, 0x77, 0xea, 0x83, 0x62, 0x77}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 18040; - uint8_t client_id_bytes[] = {0xf4, 0xbc, 0x90}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 26206; + uint8_t client_id_bytes[] = {0xe1, 0xe, 0x59, 0xf4, 0xd6, 0x26, 0x22, 0xe0, 0xe0, 0xca, 0x15, 0xc4, 0xae}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x49, 0x57, 0x5b, 0xf8, 0x2d, 0x5b, 0x2a, 0x15, 0x87, 0x6a, 0x4a, 0x4a, 0x90, 0x34, 0x94, - 0x83, 0x48, 0xf2, 0x49, 0x49, 0x64, 0xb8, 0xc4, 0x61, 0x7c, 0x43, 0x42, 0xf2, 0x15, 0xee}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xb9, 0xea, 0xa5, 0xc0, 0x57, 0xcc, 0x65, 0x67, 0x4f}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5904,15 +6222,16 @@ TEST(Connect311QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "$\184\198/)\161\242\&4\202q.\235\175\183`h", _password = Nothing, _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\ETX-gs\242\r\246#:\255\212\251\221\STX#P", _willMsg = -// "\241\&7\183W", _willProps = []}), _cleanSession = False, _keepAlive = 6911, _connID = "Nr\151\198", _properties = -// []} -TEST(Connect311QCTest, Encode21) { - uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x84, 0x1a, 0xff, 0x0, 0x4, 0x4e, - 0x72, 0x97, 0xc6, 0x0, 0x10, 0x3, 0x2d, 0x67, 0x73, 0xf2, 0xd, 0xf6, 0x23, 0x3a, 0xff, - 0xd4, 0xfb, 0xdd, 0x2, 0x23, 0x50, 0x0, 0x4, 0xf1, 0x37, 0xb7, 0x57, 0x0, 0x10, 0x24, - 0xb8, 0xc6, 0x2f, 0x29, 0xa1, 0xf2, 0x34, 0xca, 0x71, 0x2e, 0xeb, 0xaf, 0xb7, 0x60, 0x68}; +// ConnectRequest {_username = Just "\204\&9\146\248Z\193\151\237F\231u\205\207?\138\180*}\164\191\"\DEL\198$\DC3", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\DC2L", _willMsg +// = "\187\173\179\182\226\182\159\197\SO<\158\197/\170\130\157\210\201\222", _willProps = []}), _cleanSession = False, +// _keepAlive = 15691, _connID = ",\205\DC2;&\213%\165D\167", _properties = []} +TEST(Connect311QCTest, Encode20) { + uint8_t pkt[] = {0x10, 0x4a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x84, 0x3d, 0x4b, 0x0, 0xa, 0x2c, 0xcd, + 0x12, 0x3b, 0x26, 0xd5, 0x25, 0xa5, 0x44, 0xa7, 0x0, 0x2, 0x12, 0x4c, 0x0, 0x13, 0xbb, 0xad, + 0xb3, 0xb6, 0xe2, 0xb6, 0x9f, 0xc5, 0xe, 0x3c, 0x9e, 0xc5, 0x2f, 0xaa, 0x82, 0x9d, 0xd2, 0xc9, + 0xde, 0x0, 0x19, 0xcc, 0x39, 0x92, 0xf8, 0x5a, 0xc1, 0x97, 0xed, 0x46, 0xe7, 0x75, 0xcd, 0xcf, + 0x3f, 0x8a, 0xb4, 0x2a, 0x7d, 0xa4, 0xbf, 0x22, 0x7f, 0xc6, 0x24, 0x13}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5923,11 +6242,11 @@ TEST(Connect311QCTest, Encode21) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3, 0x2d, 0x67, 0x73, 0xf2, 0xd, 0xf6, 0x23, - 0x3a, 0xff, 0xd4, 0xfb, 0xdd, 0x2, 0x23, 0x50}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf1, 0x37, 0xb7, 0x57}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x12, 0x4c}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xbb, 0xad, 0xb3, 0xb6, 0xe2, 0xb6, 0x9f, 0xc5, 0xe, 0x3c, + 0x9e, 0xc5, 0x2f, 0xaa, 0x82, 0x9d, 0xd2, 0xc9, 0xde}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -5936,13 +6255,13 @@ TEST(Connect311QCTest, Encode21) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 6911; - uint8_t client_id_bytes[] = {0x4e, 0x72, 0x97, 0xc6}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.keep_alive = 15691; + uint8_t client_id_bytes[] = {0x2c, 0xcd, 0x12, 0x3b, 0x26, 0xd5, 0x25, 0xa5, 0x44, 0xa7}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x24, 0xb8, 0xc6, 0x2f, 0x29, 0xa1, 0xf2, 0x34, - 0xca, 0x71, 0x2e, 0xeb, 0xaf, 0xb7, 0x60, 0x68}; - lwmqtt_string_t username = {16, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xcc, 0x39, 0x92, 0xf8, 0x5a, 0xc1, 0x97, 0xed, 0x46, 0xe7, 0x75, 0xcd, 0xcf, + 0x3f, 0x8a, 0xb4, 0x2a, 0x7d, 0xa4, 0xbf, 0x22, 0x7f, 0xc6, 0x24, 0x13}; + lwmqtt_string_t username = {25, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5952,15 +6271,19 @@ TEST(Connect311QCTest, Encode21) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\178", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS0, _willTopic = "\196\v\202\168\"s\DC1+\222\128\&1\138Y\208Bp\178", _willMsg = "", _willProps = []}), -// _cleanSession = True, _keepAlive = 11823, _connID = "\r\173C5$+~D\ACK\169D\220\160\218\131!Bo\SO\159HN", _properties -// = []} -TEST(Connect311QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa6, 0x2e, 0x2f, 0x0, 0x16, 0xd, - 0xad, 0x43, 0x35, 0x24, 0x2b, 0x7e, 0x44, 0x6, 0xa9, 0x44, 0xdc, 0xa0, 0xda, 0x83, 0x21, - 0x42, 0x6f, 0xe, 0x9f, 0x48, 0x4e, 0x0, 0x11, 0xc4, 0xb, 0xca, 0xa8, 0x22, 0x73, 0x11, - 0x2b, 0xde, 0x80, 0x31, 0x8a, 0x59, 0xd0, 0x42, 0x70, 0xb2, 0x0, 0x0, 0x0, 0x1, 0xb2}; +// ConnectRequest {_username = Just "T>\158;\152\162\180\181\207:\ETB{u\142\245\154\140w", _password = Just +// "\220\STXp\210}\178\179y\171", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "\187\ACK\FS\183\136\196\202@\150G&%;\224\149\140\ETB\223] \145\&61:y\199", _willMsg = "\218\200 +// \235O\SYN\vs\250\233G\156\217.\200\235x\198r\202fF\SUB\147\252\255\197", _willProps = []}), _cleanSession = True, +// _keepAlive = 7593, _connID = "-e~\r", _properties = []} +TEST(Connect311QCTest, Encode21) { + uint8_t pkt[] = {0x10, 0x68, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x1d, 0xa9, 0x0, 0x4, 0x2d, 0x65, + 0x7e, 0xd, 0x0, 0x1a, 0xbb, 0x6, 0x1c, 0xb7, 0x88, 0xc4, 0xca, 0x40, 0x96, 0x47, 0x26, 0x25, + 0x3b, 0xe0, 0x95, 0x8c, 0x17, 0xdf, 0x5d, 0x20, 0x91, 0x36, 0x31, 0x3a, 0x79, 0xc7, 0x0, 0x1b, + 0xda, 0xc8, 0x20, 0xeb, 0x4f, 0x16, 0xb, 0x73, 0xfa, 0xe9, 0x47, 0x9c, 0xd9, 0x2e, 0xc8, 0xeb, + 0x78, 0xc6, 0x72, 0xca, 0x66, 0x46, 0x1a, 0x93, 0xfc, 0xff, 0xc5, 0x0, 0x12, 0x54, 0x3e, 0x9e, + 0x3b, 0x98, 0xa2, 0xb4, 0xb5, 0xcf, 0x3a, 0x17, 0x7b, 0x75, 0x8e, 0xf5, 0x9a, 0x8c, 0x77, 0x0, + 0x9, 0xdc, 0x2, 0x70, 0xd2, 0x7d, 0xb2, 0xb3, 0x79, 0xab}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5971,27 +6294,31 @@ TEST(Connect311QCTest, Encode22) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc4, 0xb, 0xca, 0xa8, 0x22, 0x73, 0x11, 0x2b, 0xde, - 0x80, 0x31, 0x8a, 0x59, 0xd0, 0x42, 0x70, 0xb2}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xbb, 0x6, 0x1c, 0xb7, 0x88, 0xc4, 0xca, 0x40, 0x96, 0x47, 0x26, 0x25, 0x3b, + 0xe0, 0x95, 0x8c, 0x17, 0xdf, 0x5d, 0x20, 0x91, 0x36, 0x31, 0x3a, 0x79, 0xc7}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xda, 0xc8, 0x20, 0xeb, 0x4f, 0x16, 0xb, 0x73, 0xfa, 0xe9, 0x47, 0x9c, 0xd9, 0x2e, + 0xc8, 0xeb, 0x78, 0xc6, 0x72, 0xca, 0x66, 0x46, 0x1a, 0x93, 0xfc, 0xff, 0xc5}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 11823; - uint8_t client_id_bytes[] = {0xd, 0xad, 0x43, 0x35, 0x24, 0x2b, 0x7e, 0x44, 0x6, 0xa9, 0x44, - 0xdc, 0xa0, 0xda, 0x83, 0x21, 0x42, 0x6f, 0xe, 0x9f, 0x48, 0x4e}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.keep_alive = 7593; + uint8_t client_id_bytes[] = {0x2d, 0x65, 0x7e, 0xd}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb2}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x54, 0x3e, 0x9e, 0x3b, 0x98, 0xa2, 0xb4, 0xb5, 0xcf, + 0x3a, 0x17, 0x7b, 0x75, 0x8e, 0xf5, 0x9a, 0x8c, 0x77}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0xdc, 0x2, 0x70, 0xd2, 0x7d, 0xb2, 0xb3, 0x79, 0xab}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6000,18 +6327,58 @@ TEST(Connect311QCTest, Encode22) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "M\162\184\&2\161L\154u\186\163\SYN\212\180\192S\137\a\169\&5\208Z\"\a\143{\DC1\246", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS0, _willTopic = -// "p\188\191\217S;m\n\EM\155\NAK\247\182\145\183\SYN\184\152\SUB\153\214-D\b\CAN\128", _willMsg = "\197p\131", -// _willProps = []}), _cleanSession = True, _keepAlive = 15472, _connID = -// "A\231\208\198C*2\172\&2\183\133\223\152\224(\129o\n\180MO\235Z\186\166\f", _properties = []} +// ConnectRequest {_username = Just "/O\134\NAKdJ", _password = Just +// "\196\156\220\155\135\182\vb\vM\183\205\156r\135f`\148\245\162\148\&5\243`G\196\184*\154", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 23419, _connID = "\138\r,\181sl\193\231\232\198\"\231/\251W\218!s", _properties = +// []} +TEST(Connect311QCTest, Encode22) { + uint8_t pkt[] = {0x10, 0x45, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x5b, 0x7b, 0x0, 0x12, 0x8a, + 0xd, 0x2c, 0xb5, 0x73, 0x6c, 0xc1, 0xe7, 0xe8, 0xc6, 0x22, 0xe7, 0x2f, 0xfb, 0x57, 0xda, + 0x21, 0x73, 0x0, 0x6, 0x2f, 0x4f, 0x86, 0x15, 0x64, 0x4a, 0x0, 0x1d, 0xc4, 0x9c, 0xdc, + 0x9b, 0x87, 0xb6, 0xb, 0x62, 0xb, 0x4d, 0xb7, 0xcd, 0x9c, 0x72, 0x87, 0x66, 0x60, 0x94, + 0xf5, 0xa2, 0x94, 0x35, 0xf3, 0x60, 0x47, 0xc4, 0xb8, 0x2a, 0x9a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 23419; + uint8_t client_id_bytes[] = {0x8a, 0xd, 0x2c, 0xb5, 0x73, 0x6c, 0xc1, 0xe7, 0xe8, + 0xc6, 0x22, 0xe7, 0x2f, 0xfb, 0x57, 0xda, 0x21, 0x73}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x2f, 0x4f, 0x86, 0x15, 0x64, 0x4a}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xc4, 0x9c, 0xdc, 0x9b, 0x87, 0xb6, 0xb, 0x62, 0xb, 0x4d, 0xb7, 0xcd, 0x9c, 0x72, 0x87, + 0x66, 0x60, 0x94, 0xf5, 0xa2, 0x94, 0x35, 0xf3, 0x60, 0x47, 0xc4, 0xb8, 0x2a, 0x9a}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\247\SI;~\246\226", _password = Just +// "\182\193\204\184\SI\251\239\221G\188,\207\181\222\169\DC2a\166\156\180\a\253\242", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\149\199O\138Vs\224&_\202\180\SYN\148\241G3\232\196)$~\216\157\181\176!", _willMsg = +// "_\241\DC4V97\239\206\170C\b\207\&9\170\141\GS3\216\234\DC4\141", _willProps = []}), _cleanSession = True, _keepAlive +// = 7, _connID = "G\\kY\SOH\242", _properties = []} TEST(Connect311QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x3c, 0x70, 0x0, 0x1a, 0x41, - 0xe7, 0xd0, 0xc6, 0x43, 0x2a, 0x32, 0xac, 0x32, 0xb7, 0x85, 0xdf, 0x98, 0xe0, 0x28, 0x81, - 0x6f, 0xa, 0xb4, 0x4d, 0x4f, 0xeb, 0x5a, 0xba, 0xa6, 0xc, 0x0, 0x1a, 0x70, 0xbc, 0xbf, - 0xd9, 0x53, 0x3b, 0x6d, 0xa, 0x19, 0x9b, 0x15, 0xf7, 0xb6, 0x91, 0xb7, 0x16, 0xb8, 0x98, - 0x1a, 0x99, 0xd6, 0x2d, 0x44, 0x8, 0x18, 0x80, 0x0, 0x3, 0xc5, 0x70, 0x83}; + uint8_t pkt[] = {0x10, 0x66, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x0, 0x7, 0x0, 0x6, 0x47, + 0x5c, 0x6b, 0x59, 0x1, 0xf2, 0x0, 0x1a, 0x95, 0xc7, 0x4f, 0x8a, 0x56, 0x73, 0xe0, 0x26, + 0x5f, 0xca, 0xb4, 0x16, 0x94, 0xf1, 0x47, 0x33, 0xe8, 0xc4, 0x29, 0x24, 0x7e, 0xd8, 0x9d, + 0xb5, 0xb0, 0x21, 0x0, 0x15, 0x5f, 0xf1, 0x14, 0x56, 0x39, 0x37, 0xef, 0xce, 0xaa, 0x43, + 0x8, 0xcf, 0x39, 0xaa, 0x8d, 0x1d, 0x33, 0xd8, 0xea, 0x14, 0x8d, 0x0, 0x6, 0xf7, 0xf, + 0x3b, 0x7e, 0xf6, 0xe2, 0x0, 0x17, 0xb6, 0xc1, 0xcc, 0xb8, 0xf, 0xfb, 0xef, 0xdd, 0x47, + 0xbc, 0x2c, 0xcf, 0xb5, 0xde, 0xa9, 0x12, 0x61, 0xa6, 0x9c, 0xb4, 0x7, 0xfd, 0xf2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6022,27 +6389,30 @@ TEST(Connect311QCTest, Encode23) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x70, 0xbc, 0xbf, 0xd9, 0x53, 0x3b, 0x6d, 0xa, 0x19, 0x9b, 0x15, 0xf7, 0xb6, - 0x91, 0xb7, 0x16, 0xb8, 0x98, 0x1a, 0x99, 0xd6, 0x2d, 0x44, 0x8, 0x18, 0x80}; + uint8_t will_topic_bytes[] = {0x95, 0xc7, 0x4f, 0x8a, 0x56, 0x73, 0xe0, 0x26, 0x5f, 0xca, 0xb4, 0x16, 0x94, + 0xf1, 0x47, 0x33, 0xe8, 0xc4, 0x29, 0x24, 0x7e, 0xd8, 0x9d, 0xb5, 0xb0, 0x21}; lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc5, 0x70, 0x83}; - lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + uint8_t will_payload_bytes[] = {0x5f, 0xf1, 0x14, 0x56, 0x39, 0x37, 0xef, 0xce, 0xaa, 0x43, 0x8, + 0xcf, 0x39, 0xaa, 0x8d, 0x1d, 0x33, 0xd8, 0xea, 0x14, 0x8d}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS1; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 15472; - uint8_t client_id_bytes[] = {0x41, 0xe7, 0xd0, 0xc6, 0x43, 0x2a, 0x32, 0xac, 0x32, 0xb7, 0x85, 0xdf, 0x98, - 0xe0, 0x28, 0x81, 0x6f, 0xa, 0xb4, 0x4d, 0x4f, 0xeb, 0x5a, 0xba, 0xa6, 0xc}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; + opts.keep_alive = 7; + uint8_t client_id_bytes[] = {0x47, 0x5c, 0x6b, 0x59, 0x1, 0xf2}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x4d, 0xa2, 0xb8, 0x32, 0xa1, 0x4c, 0x9a, 0x75, 0xba, 0xa3, 0x16, 0xd4, 0xb4, 0xc0, - 0x53, 0x89, 0x7, 0xa9, 0x35, 0xd0, 0x5a, 0x22, 0x7, 0x8f, 0x7b, 0x11, 0xf6}; - lwmqtt_string_t password = {27, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xf7, 0xf, 0x3b, 0x7e, 0xf6, 0xe2}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xb6, 0xc1, 0xcc, 0xb8, 0xf, 0xfb, 0xef, 0xdd, 0x47, 0xbc, 0x2c, 0xcf, + 0xb5, 0xde, 0xa9, 0x12, 0x61, 0xa6, 0x9c, 0xb4, 0x7, 0xfd, 0xf2}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6052,122 +6422,87 @@ TEST(Connect311QCTest, Encode23) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\ni\175J\146\197o\130\201\&8@\212x\172\ENQ\SOH!\164dU\\M\248\216\189", _password = -// Just "\EOT\128\CAN\203[\240\SYN\b", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\135\ESC\DLE|c.\180\189\232p\195\155\171=\246", _willMsg = -// "\137\150\171\227\191\DC2[m\203I\160\176\SO\193A\238\210F\180@$4\176\&8N\172\&5\234KO", _willProps = []}), -// _cleanSession = True, _keepAlive = 17924, _connID = -// "a\NUL\161\b\145\247$\148\&9^N\209\CAN\SOHT\150\176%'\199\214\&5\131\202\185\208\145E1N", _properties = []} +// ConnectRequest {_username = Just "{?~\139\226tEG\tA\FSI\236\230e<\SOH", _password = Just +// "\203)t\136\")\169\SID\246\237\158\241\231\162>!\140", _lastWill = Nothing, _cleanSession = True, _keepAlive = 8810, +// _connID = "n\253\208>\v\187pU\197NY\228\&5w!\237\179\179\SI\213", _properties = []} TEST(Connect311QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x80, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe6, 0x46, 0x4, 0x0, 0x1e, 0x61, 0x0, - 0xa1, 0x8, 0x91, 0xf7, 0x24, 0x94, 0x39, 0x5e, 0x4e, 0xd1, 0x18, 0x1, 0x54, 0x96, 0xb0, 0x25, 0x27, - 0xc7, 0xd6, 0x35, 0x83, 0xca, 0xb9, 0xd0, 0x91, 0x45, 0x31, 0x4e, 0x0, 0xf, 0x87, 0x1b, 0x10, 0x7c, - 0x63, 0x2e, 0xb4, 0xbd, 0xe8, 0x70, 0xc3, 0x9b, 0xab, 0x3d, 0xf6, 0x0, 0x1e, 0x89, 0x96, 0xab, 0xe3, - 0xbf, 0x12, 0x5b, 0x6d, 0xcb, 0x49, 0xa0, 0xb0, 0xe, 0xc1, 0x41, 0xee, 0xd2, 0x46, 0xb4, 0x40, 0x24, - 0x34, 0xb0, 0x38, 0x4e, 0xac, 0x35, 0xea, 0x4b, 0x4f, 0x0, 0x19, 0xa, 0x69, 0xaf, 0x4a, 0x92, 0xc5, - 0x6f, 0x82, 0xc9, 0x38, 0x40, 0xd4, 0x78, 0xac, 0x5, 0x1, 0x21, 0xa4, 0x64, 0x55, 0x5c, 0x4d, 0xf8, - 0xd8, 0xbd, 0x0, 0x8, 0x4, 0x80, 0x18, 0xcb, 0x5b, 0xf0, 0x16, 0x8}; + uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x22, 0x6a, 0x0, 0x14, 0x6e, + 0xfd, 0xd0, 0x3e, 0xb, 0xbb, 0x70, 0x55, 0xc5, 0x4e, 0x59, 0xe4, 0x35, 0x77, 0x21, 0xed, + 0xb3, 0xb3, 0xf, 0xd5, 0x0, 0x11, 0x7b, 0x3f, 0x7e, 0x8b, 0xe2, 0x74, 0x45, 0x47, 0x9, + 0x41, 0x1c, 0x49, 0xec, 0xe6, 0x65, 0x3c, 0x1, 0x0, 0x12, 0xcb, 0x29, 0x74, 0x88, 0x22, + 0x29, 0xa9, 0xf, 0x44, 0xf6, 0xed, 0x9e, 0xf1, 0xe7, 0xa2, 0x3e, 0x21, 0x8c}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x87, 0x1b, 0x10, 0x7c, 0x63, 0x2e, 0xb4, 0xbd, - 0xe8, 0x70, 0xc3, 0x9b, 0xab, 0x3d, 0xf6}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x89, 0x96, 0xab, 0xe3, 0xbf, 0x12, 0x5b, 0x6d, 0xcb, 0x49, - 0xa0, 0xb0, 0xe, 0xc1, 0x41, 0xee, 0xd2, 0x46, 0xb4, 0x40, - 0x24, 0x34, 0xb0, 0x38, 0x4e, 0xac, 0x35, 0xea, 0x4b, 0x4f}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 17924; - uint8_t client_id_bytes[] = {0x61, 0x0, 0xa1, 0x8, 0x91, 0xf7, 0x24, 0x94, 0x39, 0x5e, - 0x4e, 0xd1, 0x18, 0x1, 0x54, 0x96, 0xb0, 0x25, 0x27, 0xc7, - 0xd6, 0x35, 0x83, 0xca, 0xb9, 0xd0, 0x91, 0x45, 0x31, 0x4e}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.keep_alive = 8810; + uint8_t client_id_bytes[] = {0x6e, 0xfd, 0xd0, 0x3e, 0xb, 0xbb, 0x70, 0x55, 0xc5, 0x4e, + 0x59, 0xe4, 0x35, 0x77, 0x21, 0xed, 0xb3, 0xb3, 0xf, 0xd5}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa, 0x69, 0xaf, 0x4a, 0x92, 0xc5, 0x6f, 0x82, 0xc9, 0x38, 0x40, 0xd4, 0x78, - 0xac, 0x5, 0x1, 0x21, 0xa4, 0x64, 0x55, 0x5c, 0x4d, 0xf8, 0xd8, 0xbd}; - lwmqtt_string_t username = {25, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x7b, 0x3f, 0x7e, 0x8b, 0xe2, 0x74, 0x45, 0x47, 0x9, + 0x41, 0x1c, 0x49, 0xec, 0xe6, 0x65, 0x3c, 0x1}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x4, 0x80, 0x18, 0xcb, 0x5b, 0xf0, 0x16, 0x8}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xcb, 0x29, 0x74, 0x88, 0x22, 0x29, 0xa9, 0xf, 0x44, + 0xf6, 0xed, 0x9e, 0xf1, 0xe7, 0xa2, 0x3e, 0x21, 0x8c}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "x\197,\208\aUF\242|z\244", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "9*J\v\172B:vV\252\US>YCPMxm", _willMsg = ">N", _willProps = []}), -// _cleanSession = False, _keepAlive = 8679, _connID = "\155\132j\168 \215\255w\SO\227", _properties = []} +// ConnectRequest {_username = Just "\132\241o\219m\247lL]\193i\175", _password = Just "\CANv\229k\211\205", _lastWill = +// Nothing, _cleanSession = True, _keepAlive = 7935, _connID = "\ETB\208H\169\248J\183R\169p\FS\190\DEL\182~\SYN", +// _properties = []} TEST(Connect311QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0x2e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x21, 0xe7, 0x0, 0xa, 0x9b, 0x84, - 0x6a, 0xa8, 0x20, 0xd7, 0xff, 0x77, 0xe, 0xe3, 0x0, 0x12, 0x39, 0x2a, 0x4a, 0xb, 0xac, 0x42, - 0x3a, 0x76, 0x56, 0xfc, 0x1f, 0x3e, 0x59, 0x43, 0x50, 0x4d, 0x78, 0x6d, 0x0, 0x2, 0x3e, 0x4e}; + uint8_t pkt[] = {0x10, 0x32, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x1e, 0xff, 0x0, + 0x10, 0x17, 0xd0, 0x48, 0xa9, 0xf8, 0x4a, 0xb7, 0x52, 0xa9, 0x70, 0x1c, 0xbe, + 0x7f, 0xb6, 0x7e, 0x16, 0x0, 0xc, 0x84, 0xf1, 0x6f, 0xdb, 0x6d, 0xf7, 0x6c, + 0x4c, 0x5d, 0xc1, 0x69, 0xaf, 0x0, 0x6, 0x18, 0x76, 0xe5, 0x6b, 0xd3, 0xcd}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x39, 0x2a, 0x4a, 0xb, 0xac, 0x42, 0x3a, 0x76, 0x56, - 0xfc, 0x1f, 0x3e, 0x59, 0x43, 0x50, 0x4d, 0x78, 0x6d}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3e, 0x4e}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 8679; - uint8_t client_id_bytes[] = {0x9b, 0x84, 0x6a, 0xa8, 0x20, 0xd7, 0xff, 0x77, 0xe, 0xe3}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 7935; + uint8_t client_id_bytes[] = {0x17, 0xd0, 0x48, 0xa9, 0xf8, 0x4a, 0xb7, 0x52, + 0xa9, 0x70, 0x1c, 0xbe, 0x7f, 0xb6, 0x7e, 0x16}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x78, 0xc5, 0x2c, 0xd0, 0x7, 0x55, 0x46, 0xf2, 0x7c, 0x7a, 0xf4}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x84, 0xf1, 0x6f, 0xdb, 0x6d, 0xf7, 0x6c, 0x4c, 0x5d, 0xc1, 0x69, 0xaf}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x18, 0x76, 0xe5, 0x6b, 0xd3, 0xcd}; + lwmqtt_string_t password = {6, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "#*\SUB\197/r\203", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS0, _willTopic = "G@v wb\253\GSb\212", _willMsg = -// "\SYN\"mo\233lbY\DC3\160\156\230\206`\226J|\232", _willProps = []}), _cleanSession = True, _keepAlive = 17750, -// _connID = "\178Y\174\187MI\NAK\186F\SYN\139\138\235u\SOH\197Q", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "d\140\&3,\181\151\SI[\ACK\153\237\181<<\225\185\SO", _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "N\173\211", _willMsg = "c\251\173\SOHT\f\251", +// _willProps = []}), _cleanSession = True, _keepAlive = 10911, _connID = "\137\138\233WV \249\146:\152V\141\176'z", +// _properties = []} TEST(Connect311QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x86, 0x45, 0x56, 0x0, 0x11, 0xb2, - 0x59, 0xae, 0xbb, 0x4d, 0x49, 0x15, 0xba, 0x46, 0x16, 0x8b, 0x8a, 0xeb, 0x75, 0x1, 0xc5, - 0x51, 0x0, 0xa, 0x47, 0x40, 0x76, 0x20, 0x77, 0x62, 0xfd, 0x1d, 0x62, 0xd4, 0x0, 0x12, - 0x16, 0x22, 0x6d, 0x6f, 0xe9, 0x6c, 0x62, 0x59, 0x13, 0xa0, 0x9c, 0xe6, 0xce, 0x60, 0xe2, - 0x4a, 0x7c, 0xe8, 0x0, 0x7, 0x23, 0x2a, 0x1a, 0xc5, 0x2f, 0x72, 0xcb}; + uint8_t pkt[] = {0x10, 0x29, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x2a, 0x9f, 0x0, 0xf, 0x89, + 0x8a, 0xe9, 0x57, 0x56, 0x20, 0xf9, 0x92, 0x3a, 0x98, 0x56, 0x8d, 0xb0, 0x27, 0x7a, 0x0, + 0x3, 0x4e, 0xad, 0xd3, 0x0, 0x7, 0x63, 0xfb, 0xad, 0x1, 0x54, 0xc, 0xfb}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6178,11 +6513,10 @@ TEST(Connect311QCTest, Encode26) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x47, 0x40, 0x76, 0x20, 0x77, 0x62, 0xfd, 0x1d, 0x62, 0xd4}; - lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x16, 0x22, 0x6d, 0x6f, 0xe9, 0x6c, 0x62, 0x59, 0x13, - 0xa0, 0x9c, 0xe6, 0xce, 0x60, 0xe2, 0x4a, 0x7c, 0xe8}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x4e, 0xad, 0xd3}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x63, 0xfb, 0xad, 0x1, 0x54, 0xc, 0xfb}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -6191,14 +6525,15 @@ TEST(Connect311QCTest, Encode26) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 17750; - uint8_t client_id_bytes[] = {0xb2, 0x59, 0xae, 0xbb, 0x4d, 0x49, 0x15, 0xba, 0x46, - 0x16, 0x8b, 0x8a, 0xeb, 0x75, 0x1, 0xc5, 0x51}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.keep_alive = 10911; + uint8_t client_id_bytes[] = {0x89, 0x8a, 0xe9, 0x57, 0x56, 0x20, 0xf9, 0x92, + 0x3a, 0x98, 0x56, 0x8d, 0xb0, 0x27, 0x7a}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x23, 0x2a, 0x1a, 0xc5, 0x2f, 0x72, 0xcb}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; - opts.username = username; + uint8_t password_bytes[] = {0x64, 0x8c, 0x33, 0x2c, 0xb5, 0x97, 0xf, 0x5b, 0x6, + 0x99, 0xed, 0xb5, 0x3c, 0x3c, 0xe1, 0xb9, 0xe}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6207,21 +6542,18 @@ TEST(Connect311QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just ";<\132\244\&6\148W/\234\225\r\SIO\DC1", _password = Just -// "\243\ACK\180?\176\136\191]UDv\US\f\151|\209\150\NUL", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\176\CAN\r\146\ESC\214\243U\141F\EM\253\149\231\131\182\203+\164\212'=\232\161\154L\219$", -// _willMsg = "\185\143G\243\136\166\&2xe\156z:|WI\175\185s([H\182\224\143", _willProps = []}), _cleanSession = True, -// _keepAlive = 29887, _connID = "\136\132f\178\182\247\158\133\171t\131\148\168\fR\250d\235\253/\255Y\194\DLE\178", -// _properties = []} +// ConnectRequest {_username = Just "\190\254\vG\140\DLEq\206\199\&1\235y\135a\b", _password = Just +// "(\ESC\DC14\172tH/\136\240\225", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "'\SOH\141M", _willMsg = "\199I\t\155\SOHg\135,\200F\135\EM;\233J\152\NAK\ESCD\SUB\t\193M\DEL\220^\163\214", +// _willProps = []}), _cleanSession = True, _keepAlive = 14063, _connID = +// "\137\196\DC1\230\"\199\249,\241\a\f\239\159\223\170N\240\248\184\172", _properties = []} TEST(Connect311QCTest, Encode27) { - uint8_t pkt[] = {0x10, 0x81, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe6, 0x74, 0xbf, 0x0, 0x19, 0x88, 0x84, - 0x66, 0xb2, 0xb6, 0xf7, 0x9e, 0x85, 0xab, 0x74, 0x83, 0x94, 0xa8, 0xc, 0x52, 0xfa, 0x64, 0xeb, 0xfd, - 0x2f, 0xff, 0x59, 0xc2, 0x10, 0xb2, 0x0, 0x1c, 0xb0, 0x18, 0xd, 0x92, 0x1b, 0xd6, 0xf3, 0x55, 0x8d, - 0x46, 0x19, 0xfd, 0x95, 0xe7, 0x83, 0xb6, 0xcb, 0x2b, 0xa4, 0xd4, 0x27, 0x3d, 0xe8, 0xa1, 0x9a, 0x4c, - 0xdb, 0x24, 0x0, 0x18, 0xb9, 0x8f, 0x47, 0xf3, 0x88, 0xa6, 0x32, 0x78, 0x65, 0x9c, 0x7a, 0x3a, 0x7c, - 0x57, 0x49, 0xaf, 0xb9, 0x73, 0x28, 0x5b, 0x48, 0xb6, 0xe0, 0x8f, 0x0, 0xe, 0x3b, 0x3c, 0x84, 0xf4, - 0x36, 0x94, 0x57, 0x2f, 0xea, 0xe1, 0xd, 0xf, 0x4f, 0x11, 0x0, 0x12, 0xf3, 0x6, 0xb4, 0x3f, 0xb0, - 0x88, 0xbf, 0x5d, 0x55, 0x44, 0x76, 0x1f, 0xc, 0x97, 0x7c, 0xd1, 0x96, 0x0}; + uint8_t pkt[] = {0x10, 0x62, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x36, 0xef, 0x0, 0x14, 0x89, 0xc4, 0x11, + 0xe6, 0x22, 0xc7, 0xf9, 0x2c, 0xf1, 0x7, 0xc, 0xef, 0x9f, 0xdf, 0xaa, 0x4e, 0xf0, 0xf8, 0xb8, 0xac, + 0x0, 0x4, 0x27, 0x1, 0x8d, 0x4d, 0x0, 0x1c, 0xc7, 0x49, 0x9, 0x9b, 0x1, 0x67, 0x87, 0x2c, 0xc8, + 0x46, 0x87, 0x19, 0x3b, 0xe9, 0x4a, 0x98, 0x15, 0x1b, 0x44, 0x1a, 0x9, 0xc1, 0x4d, 0x7f, 0xdc, 0x5e, + 0xa3, 0xd6, 0x0, 0xf, 0xbe, 0xfe, 0xb, 0x47, 0x8c, 0x10, 0x71, 0xce, 0xc7, 0x31, 0xeb, 0x79, 0x87, + 0x61, 0x8, 0x0, 0xb, 0x28, 0x1b, 0x11, 0x34, 0xac, 0x74, 0x48, 0x2f, 0x88, 0xf0, 0xe1}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6232,31 +6564,29 @@ TEST(Connect311QCTest, Encode27) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb0, 0x18, 0xd, 0x92, 0x1b, 0xd6, 0xf3, 0x55, 0x8d, 0x46, 0x19, 0xfd, 0x95, 0xe7, - 0x83, 0xb6, 0xcb, 0x2b, 0xa4, 0xd4, 0x27, 0x3d, 0xe8, 0xa1, 0x9a, 0x4c, 0xdb, 0x24}; - lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb9, 0x8f, 0x47, 0xf3, 0x88, 0xa6, 0x32, 0x78, 0x65, 0x9c, 0x7a, 0x3a, - 0x7c, 0x57, 0x49, 0xaf, 0xb9, 0x73, 0x28, 0x5b, 0x48, 0xb6, 0xe0, 0x8f}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x27, 0x1, 0x8d, 0x4d}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc7, 0x49, 0x9, 0x9b, 0x1, 0x67, 0x87, 0x2c, 0xc8, 0x46, 0x87, 0x19, 0x3b, 0xe9, + 0x4a, 0x98, 0x15, 0x1b, 0x44, 0x1a, 0x9, 0xc1, 0x4d, 0x7f, 0xdc, 0x5e, 0xa3, 0xd6}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 29887; - uint8_t client_id_bytes[] = {0x88, 0x84, 0x66, 0xb2, 0xb6, 0xf7, 0x9e, 0x85, 0xab, 0x74, 0x83, 0x94, 0xa8, - 0xc, 0x52, 0xfa, 0x64, 0xeb, 0xfd, 0x2f, 0xff, 0x59, 0xc2, 0x10, 0xb2}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.keep_alive = 14063; + uint8_t client_id_bytes[] = {0x89, 0xc4, 0x11, 0xe6, 0x22, 0xc7, 0xf9, 0x2c, 0xf1, 0x7, + 0xc, 0xef, 0x9f, 0xdf, 0xaa, 0x4e, 0xf0, 0xf8, 0xb8, 0xac}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x3b, 0x3c, 0x84, 0xf4, 0x36, 0x94, 0x57, 0x2f, 0xea, 0xe1, 0xd, 0xf, 0x4f, 0x11}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xbe, 0xfe, 0xb, 0x47, 0x8c, 0x10, 0x71, 0xce, 0xc7, 0x31, 0xeb, 0x79, 0x87, 0x61, 0x8}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xf3, 0x6, 0xb4, 0x3f, 0xb0, 0x88, 0xbf, 0x5d, 0x55, - 0x44, 0x76, 0x1f, 0xc, 0x97, 0x7c, 0xd1, 0x96, 0x0}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x28, 0x1b, 0x11, 0x34, 0xac, 0x74, 0x48, 0x2f, 0x88, 0xf0, 0xe1}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6266,16 +6596,18 @@ TEST(Connect311QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\ENQAAE\ACK\174&\128\161wm#W>VC<]\149\152\201\134x:\148\220\243T\\.", _password = -// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// ";\161U\195\&6\138\177I\129\195\USA\DC3", _willMsg = "I\DC1\210\DC3\FS\DC3\242\138\171\211\203\b\190", _willProps = -// []}), _cleanSession = True, _keepAlive = 22371, _connID = "\165\EM\181\CAN)62", _properties = []} +// ConnectRequest {_username = Just "%\DC3/-\bG2\192\137\196&\128\209\143\235\SI\201\&6\r\216vK\196dI\195\144G", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "\132~x\156KS\246y\137\249\SYN\154%\145\149T\195\188", _willMsg = +// "X\195\&0\237\DC1l\222\ETX\219\&9\128\"\210/\254\243Q\204\169^H", _willProps = []}), _cleanSession = False, +// _keepAlive = 9629, _connID = "u\226c\130\167Y\128L\255\&1\SI\232\190", _properties = []} TEST(Connect311QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0x51, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x86, 0x57, 0x63, 0x0, 0x7, 0xa5, 0x19, 0xb5, - 0x18, 0x29, 0x36, 0x32, 0x0, 0xd, 0x3b, 0xa1, 0x55, 0xc3, 0x36, 0x8a, 0xb1, 0x49, 0x81, 0xc3, 0x1f, - 0x41, 0x13, 0x0, 0xd, 0x49, 0x11, 0xd2, 0x13, 0x1c, 0x13, 0xf2, 0x8a, 0xab, 0xd3, 0xcb, 0x8, 0xbe, - 0x0, 0x1e, 0x5, 0x41, 0x41, 0x45, 0x6, 0xae, 0x26, 0x80, 0xa1, 0x77, 0x6d, 0x23, 0x57, 0x3e, 0x56, - 0x43, 0x3c, 0x5d, 0x95, 0x98, 0xc9, 0x86, 0x78, 0x3a, 0x94, 0xdc, 0xf3, 0x54, 0x5c, 0x2e}; + uint8_t pkt[] = {0x10, 0x62, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa4, 0x25, 0x9d, 0x0, 0xd, 0x75, 0xe2, 0x63, + 0x82, 0xa7, 0x59, 0x80, 0x4c, 0xff, 0x31, 0xf, 0xe8, 0xbe, 0x0, 0x12, 0x84, 0x7e, 0x78, 0x9c, 0x4b, + 0x53, 0xf6, 0x79, 0x89, 0xf9, 0x16, 0x9a, 0x25, 0x91, 0x95, 0x54, 0xc3, 0xbc, 0x0, 0x15, 0x58, 0xc3, + 0x30, 0xed, 0x11, 0x6c, 0xde, 0x3, 0xdb, 0x39, 0x80, 0x22, 0xd2, 0x2f, 0xfe, 0xf3, 0x51, 0xcc, 0xa9, + 0x5e, 0x48, 0x0, 0x1c, 0x25, 0x13, 0x2f, 0x2d, 0x8, 0x47, 0x32, 0xc0, 0x89, 0xc4, 0x26, 0x80, 0xd1, + 0x8f, 0xeb, 0xf, 0xc9, 0x36, 0xd, 0xd8, 0x76, 0x4b, 0xc4, 0x64, 0x49, 0xc3, 0x90, 0x47}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6286,25 +6618,27 @@ TEST(Connect311QCTest, Encode28) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3b, 0xa1, 0x55, 0xc3, 0x36, 0x8a, 0xb1, 0x49, 0x81, 0xc3, 0x1f, 0x41, 0x13}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x49, 0x11, 0xd2, 0x13, 0x1c, 0x13, 0xf2, 0x8a, 0xab, 0xd3, 0xcb, 0x8, 0xbe}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x84, 0x7e, 0x78, 0x9c, 0x4b, 0x53, 0xf6, 0x79, 0x89, + 0xf9, 0x16, 0x9a, 0x25, 0x91, 0x95, 0x54, 0xc3, 0xbc}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x58, 0xc3, 0x30, 0xed, 0x11, 0x6c, 0xde, 0x3, 0xdb, 0x39, 0x80, + 0x22, 0xd2, 0x2f, 0xfe, 0xf3, 0x51, 0xcc, 0xa9, 0x5e, 0x48}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 22371; - uint8_t client_id_bytes[] = {0xa5, 0x19, 0xb5, 0x18, 0x29, 0x36, 0x32}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 9629; + uint8_t client_id_bytes[] = {0x75, 0xe2, 0x63, 0x82, 0xa7, 0x59, 0x80, 0x4c, 0xff, 0x31, 0xf, 0xe8, 0xbe}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x5, 0x41, 0x41, 0x45, 0x6, 0xae, 0x26, 0x80, 0xa1, 0x77, 0x6d, 0x23, 0x57, 0x3e, 0x56, - 0x43, 0x3c, 0x5d, 0x95, 0x98, 0xc9, 0x86, 0x78, 0x3a, 0x94, 0xdc, 0xf3, 0x54, 0x5c, 0x2e}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x25, 0x13, 0x2f, 0x2d, 0x8, 0x47, 0x32, 0xc0, 0x89, 0xc4, 0x26, 0x80, 0xd1, 0x8f, + 0xeb, 0xf, 0xc9, 0x36, 0xd, 0xd8, 0x76, 0x4b, 0xc4, 0x64, 0x49, 0xc3, 0x90, 0x47}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6314,16 +6648,16 @@ TEST(Connect311QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "OX\145\244\252\182\254\FS\130\252\134@\172\223\164\157{X}\165\146\152~f\219", _willMsg = -// "@\129Q\244!\183oR", _willProps = []}), _cleanSession = False, _keepAlive = 30518, _connID = -// "W\161E\137\235\171\156\EM\227`e^\234\242\248\227rj\195\139\NAK", _properties = []} +// ConnectRequest {_username = Just "A\215\192x\237\STX\181-", _password = Just "\148", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "\222\FS4[\199l\134\149\221T_=\130G\192\&4\179\205S>O", _willMsg +// = "\244\177\ETB\252l\159# _\EM\n\226\148\240e\135\229\SUB\SUB5", _properties = []} TEST(Connect311QCTest, Encode30) { - uint8_t pkt[] = {0x10, 0x6b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x65, 0x97, 0x0, 0x3, 0x4e, 0xed, - 0xd3, 0x0, 0x1e, 0x9d, 0xa7, 0x53, 0xad, 0x29, 0xd0, 0xc1, 0xf3, 0x8e, 0x2, 0x3f, 0xf4, 0xc7, - 0x3c, 0x13, 0xca, 0x56, 0x4c, 0xd7, 0xda, 0xd7, 0xa2, 0xae, 0x7e, 0xa7, 0x47, 0x31, 0x9, 0xc4, - 0x29, 0x0, 0x0, 0x0, 0x1e, 0xe9, 0x10, 0x75, 0x7a, 0x2c, 0xeb, 0xdd, 0xb7, 0xf5, 0x43, 0xab, - 0xdb, 0xf1, 0x5e, 0xd5, 0xa8, 0xa0, 0xa7, 0xb5, 0x3c, 0xd2, 0xaf, 0xc9, 0xe1, 0xf1, 0x84, 0xfb, - 0xe5, 0x65, 0xa4, 0x0, 0x18, 0xf0, 0xb4, 0x58, 0x7d, 0x39, 0xc6, 0x9, 0x1a, 0x4b, 0xd3, 0x6, - 0xb3, 0x74, 0xff, 0xed, 0x94, 0x20, 0x6e, 0x6f, 0x13, 0xcb, 0x33, 0x3b, 0xc6}; + uint8_t pkt[] = {0x10, 0x45, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x68, 0xd4, 0x0, 0x12, 0xcb, + 0x2c, 0x10, 0xff, 0x4, 0xf5, 0x92, 0xea, 0x3e, 0xe2, 0x94, 0xf0, 0x65, 0x87, 0xe5, 0x1a, + 0x1a, 0x35, 0x0, 0x1a, 0xbb, 0xfc, 0x1, 0x66, 0xe8, 0x6, 0xd5, 0xf5, 0xb0, 0xfc, 0xc3, + 0xeb, 0xf2, 0x39, 0xb6, 0xab, 0xa, 0x7, 0xde, 0x48, 0x41, 0xf, 0xba, 0x87, 0x9, 0x69, + 0x0, 0x9, 0x50, 0xf1, 0x26, 0x66, 0xec, 0x97, 0x43, 0xaf, 0xab}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9d, 0xa7, 0x53, 0xad, 0x29, 0xd0, 0xc1, 0xf3, 0x8e, 0x2, - 0x3f, 0xf4, 0xc7, 0x3c, 0x13, 0xca, 0x56, 0x4c, 0xd7, 0xda, - 0xd7, 0xa2, 0xae, 0x7e, 0xa7, 0x47, 0x31, 0x9, 0xc4, 0x29}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 26007; - uint8_t client_id_bytes[] = {0x4e, 0xed, 0xd3}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 26836; + uint8_t client_id_bytes[] = {0xcb, 0x2c, 0x10, 0xff, 0x4, 0xf5, 0x92, 0xea, 0x3e, + 0xe2, 0x94, 0xf0, 0x65, 0x87, 0xe5, 0x1a, 0x1a, 0x35}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xe9, 0x10, 0x75, 0x7a, 0x2c, 0xeb, 0xdd, 0xb7, 0xf5, 0x43, 0xab, 0xdb, 0xf1, 0x5e, 0xd5, - 0xa8, 0xa0, 0xa7, 0xb5, 0x3c, 0xd2, 0xaf, 0xc9, 0xe1, 0xf1, 0x84, 0xfb, 0xe5, 0x65, 0xa4}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xbb, 0xfc, 0x1, 0x66, 0xe8, 0x6, 0xd5, 0xf5, 0xb0, 0xfc, 0xc3, 0xeb, 0xf2, + 0x39, 0xb6, 0xab, 0xa, 0x7, 0xde, 0x48, 0x41, 0xf, 0xba, 0x87, 0x9, 0x69}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xf0, 0xb4, 0x58, 0x7d, 0x39, 0xc6, 0x9, 0x1a, 0x4b, 0xd3, 0x6, 0xb3, - 0x74, 0xff, 0xed, 0x94, 0x20, 0x6e, 0x6f, 0x13, 0xcb, 0x33, 0x3b, 0xc6}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x50, 0xf1, 0x26, 0x66, 0xec, 0x97, 0x43, 0xaf, 0xab}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\STXF\139\182d\236&\232\&0\220\246\150\CAN\210\147K\245O\160W*D\145\202", _willMsg = -// "\255\138T\159\195[tN\169\244\200*\226/\ENQ\238\251\DC3", _willProps = [PropSessionExpiryInterval -// 12196,PropMessageExpiryInterval 25354,PropRequestResponseInformation 86,PropRetainAvailable -// 155,PropWildcardSubscriptionAvailable 202,PropMessageExpiryInterval 18349,PropResponseTopic -// "_\190#\130\SOH\138\181?\247H\172m~+(L\232",PropServerKeepAlive 22997,PropContentType -// "\189\233\205{d\138\230\239\207",PropAuthenticationData "",PropCorrelationData -// "\ETX\189f\190x\DLE\235\253u\175f\239.z\215\178P\150\183?\194#\192.-S\175Z",PropResponseTopic "\ESC"]}), -// _cleanSession = True, _keepAlive = 23007, _connID = "\172\233\209\170i\141", _properties = -// [PropPayloadFormatIndicator 1]} +// ConnectRequest {_username = Nothing, _password = Just "Ke\173x'\220\170U\137[)Z\178\208[", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "M\150!\226\146b.\172]E2\203\181H\189\229`\158", _willMsg = +// "\254\224C\179\DC48p\a%0\153A\138\190\225Yw(dG\204\187\t5w\154\138F\208", _willProps = [PropServerKeepAlive 18831]}), +// _cleanSession = True, _keepAlive = 3972, _connID = "j\165k\247>\ENQ\145Xh\181N\246!\SUBX\201", _properties = +// [PropContentType "X\SO0j\160R\151\150\US\SIF\219\240L\205",PropMessageExpiryInterval +// 698,PropWildcardSubscriptionAvailable 200,PropAssignedClientIdentifier "\v^\213\173@\135:\208B\ENQQ\146DY\b"]} TEST(Connect5QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0xa2, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x59, 0xdf, 0x2, 0x1, 0x1, 0x0, - 0x6, 0xac, 0xe9, 0xd1, 0xaa, 0x69, 0x8d, 0x5e, 0x11, 0x0, 0x0, 0x2f, 0xa4, 0x2, 0x0, 0x0, 0x63, - 0xa, 0x19, 0x56, 0x25, 0x9b, 0x28, 0xca, 0x2, 0x0, 0x0, 0x47, 0xad, 0x8, 0x0, 0x11, 0x5f, 0xbe, - 0x23, 0x82, 0x1, 0x8a, 0xb5, 0x3f, 0xf7, 0x48, 0xac, 0x6d, 0x7e, 0x2b, 0x28, 0x4c, 0xe8, 0x13, 0x59, - 0xd5, 0x3, 0x0, 0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, 0x62, 0x2e, 0xac, 0x5d, 0x45, 0x32, 0xcb, 0xb5, 0x48, 0xbd, 0xe5, 0x60, 0x9e, 0x0, 0x1d, 0xfe, + 0xe0, 0x43, 0xb3, 0x14, 0x38, 0x70, 0x7, 0x25, 0x30, 0x99, 0x41, 0x8a, 0xbe, 0xe1, 0x59, 0x77, 0x28, + 0x64, 0x47, 0xcc, 0xbb, 0x9, 0x35, 0x77, 0x9a, 0x8a, 0x46, 0xd0, 0x0, 0xf, 0x4b, 0x65, 0xad, 0x78, + 0x27, 0xdc, 0xaa, 0x55, 0x89, 0x5b, 0x29, 0x5a, 0xb2, 0xd0, 0x5b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x58, 0xe, 0x30, 0x6a, 0xa0, 0x52, 0x97, 0x96, 0x1f, 0xf, 0x46, 0xdb, 0xf0, 0x4c, 0xcd}; + uint8_t bytesprops1[] = {0xb, 0x5e, 0xd5, 0xad, 0x40, 0x87, 0x3a, 0xd0, 0x42, 0x5, 0x51, 0x92, 0x44, 0x59, 0x8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 698}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x5f, 0xbe, 0x23, 0x82, 0x1, 0x8a, 0xb5, 0x3f, 0xf7, - 0x48, 0xac, 0x6d, 0x7e, 0x2b, 0x28, 0x4c, 0xe8}; - uint8_t byteswillprops1[] = {0xbd, 0xe9, 0xcd, 0x7b, 0x64, 0x8a, 0xe6, 0xef, 0xcf}; - uint8_t byteswillprops2[] = {0}; - uint8_t byteswillprops3[] = {0x3, 0xbd, 0x66, 0xbe, 0x78, 0x10, 0xeb, 0xfd, 0x75, 0xaf, 0x66, 0xef, 0x2e, 0x7a, - 0xd7, 0xb2, 0x50, 0x96, 0xb7, 0x3f, 0xc2, 0x23, 0xc0, 0x2e, 0x2d, 0x53, 0xaf, 0x5a}; - uint8_t byteswillprops4[] = {0x1b}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12196}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25354}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18349}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22997}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18831}}, }; - lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2, 0x46, 0x8b, 0xb6, 0x64, 0xec, 0x26, 0xe8, 0x30, 0xdc, 0xf6, 0x96, - 0x18, 0xd2, 0x93, 0x4b, 0xf5, 0x4f, 0xa0, 0x57, 0x2a, 0x44, 0x91, 0xca}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xff, 0x8a, 0x54, 0x9f, 0xc3, 0x5b, 0x74, 0x4e, 0xa9, - 0xf4, 0xc8, 0x2a, 0xe2, 0x2f, 0x5, 0xee, 0xfb, 0x13}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4d, 0x96, 0x21, 0xe2, 0x92, 0x62, 0x2e, 0xac, 0x5d, + 0x45, 0x32, 0xcb, 0xb5, 0x48, 0xbd, 0xe5, 0x60, 0x9e}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfe, 0xe0, 0x43, 0xb3, 0x14, 0x38, 0x70, 0x7, 0x25, 0x30, + 0x99, 0x41, 0x8a, 0xbe, 0xe1, 0x59, 0x77, 0x28, 0x64, 0x47, + 0xcc, 0xbb, 0x9, 0x35, 0x77, 0x9a, 0x8a, 0x46, 0xd0}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 23007; - uint8_t client_id_bytes[] = {0xac, 0xe9, 0xd1, 0xaa, 0x69, 0x8d}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.keep_alive = 3972; + uint8_t client_id_bytes[] = {0x6a, 0xa5, 0x6b, 0xf7, 0x3e, 0x5, 0x91, 0x58, + 0x68, 0xb5, 0x4e, 0xf6, 0x21, 0x1a, 0x58, 0xc9}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t password_bytes[] = {0x4b, 0x65, 0xad, 0x78, 0x27, 0xdc, 0xaa, 0x55, 0x89, 0x5b, 0x29, 0x5a, 0xb2, 0xd0, 0x5b}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -6497,163 +6804,164 @@ TEST(Connect5QCTest, Encode1) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\162\167;\233}\166*\194\SO5I", _password = Just -// "\206\SYN\252];b\f|\249\239\199!!\ETB\142fz\153\250>bv\DC1\ETX\134", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS1, _willTopic = "\DELF\240\209\&7W\203U~\ETBsd", _willMsg = "\146\191]\f|", _willProps = -// [PropResponseInformation "\r\f}~KATl\198M\RS.\204{\159",PropSessionExpiryInterval 25708,PropWillDelayInterval -// 17400,PropWillDelayInterval 9074,PropRequestProblemInformation 12,PropCorrelationData -// "ol\232jq`\145\138\242\162\147!\RSv\186",PropAuthenticationData "",PropMessageExpiryInterval 20784,PropUserProperty -// "\206?\SO\apG\213\229\214\155\a(\193\DEL\201\247\250\193\GSuVi\238\143x\178p" -// "\230\&1Q]\EOT5\219:\187Pk\247Maq\135\135\DLE\SYN\204",PropSubscriptionIdentifier 20,PropRequestResponseInformation -// 185,PropCorrelationData "T\147Q\177\191LL @\ESC1\SUB-K\154EI\218\SOH\171\227\160 \161\226",PropReasonString -// "\196\187G\239\175\202\139"]}), _cleanSession = True, _keepAlive = 7161, _connID = -// "AG\180\214\&5\245\a\196\164Fq\209\141\250>\246\RS", _properties = [PropMessageExpiryInterval -// 22623,PropWildcardSubscriptionAvailable 116,PropPayloadFormatIndicator 197,PropRetainAvailable -// 197,PropTopicAliasMaximum 15093,PropResponseTopic -// "\EOT$~\SO\186\t\152\162\237\149\&5\RS\178\131\135Va\211#+\185@\176?\186",PropReceiveMaximum 8870,PropRetainAvailable -// 250,PropWildcardSubscriptionAvailable 67,PropAuthenticationMethod "\169\239\RS\220",PropWillDelayInterval -// 6620,PropResponseInformation -// "\178\220E\ACK\196\DC4^\199=\251)]z\254M\254X\v\155d",PropSubscriptionIdentifierAvailable 152,PropTopicAliasMaximum -// 8982,PropAuthenticationMethod -// "L\226eG\159\233\153!\192p\234\&5\182\145\219h\171\"8\234fE$\225",PropPayloadFormatIndicator -// 10,PropSharedSubscriptionAvailable 82,PropUserProperty "\188\145\164" "\168\227\143z1\173",PropSubscriptionIdentifier -// 26,PropResponseTopic "\213x",PropResponseTopic "\230\145~\158\144\EM\175\129@\249",PropServerReference -// "\v\165+\ETX\DC3\161=\t5&]\181\148",PropRequestProblemInformation 160,PropResponseInformation -// "\213s\220\ENQ{DSet\243=w\218*\SOH\DC3\245\164\SYN\193q\DC4\133",PropAuthenticationData -// "\SUB\200\165\247\231\188\193\251\226\187\231\137\SO{\142x&u\183Z\235\177xkB\159",PropTopicAliasMaximum -// 27750,PropMaximumPacketSize 15510]} +// ConnectRequest {_username = Just "+\217\245\132J\219\160\139\232\213\SO\189\NUL-\DC3", _password = Nothing, _lastWill +// = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "O\SOH\173\164\238\248\f&\NULP\175\136/,\ETB\255\GS\208\247\DELt\129\193\169\EOT", _willMsg = +// "\138\229\222\220\216/\219\197\224\ETB\177\DEL.\165<\210\150\182\209\222\SOH\NAK(R\177\134\ETX\ETB", _willProps = +// [PropReasonString "G\177d\171\171%\182\166\&1\144d\254A\205\254\147\184s{",PropWillDelayInterval +// 4326,PropAuthenticationData "\185zr.\142\188v8RKO\v\134S|\206\239\237\159\254ot\185E",PropSubscriptionIdentifier +// 13,PropAuthenticationMethod "\140\USat\236)d \SUB_\186\&9\247\172I\235F\201a\ACK\v\247",PropMaximumPacketSize +// 12309,PropMessageExpiryInterval 1142,PropWillDelayInterval 16673,PropRetainAvailable 197,PropRetainAvailable +// 160,PropResponseInformation "(v\"*\236\229\223\a\t\177/\149j\236\245\NAK\nC\EOT",PropServerReference +// "\250\r\248\157",PropMaximumPacketSize 17709,PropRequestProblemInformation 93,PropAuthenticationData +// "W\218|\207\156;\200\DC4\181t9\202/\180-c\226\f\202\240\142L\216\&6\194\232",PropMaximumPacketSize +// 9332,PropContentType "/\158\139\227P\ETB\174F[w\177\168<\251\242",PropServerReference +// "-\197\220\155\189pHp\STX\165\147\133w\201A",PropTopicAliasMaximum 22350,PropWillDelayInterval 4774,PropResponseTopic +// ">0p\251\232\185Xt\247\191\150\214u\FS\241\&0\208\&1B\191\255GmL",PropServerReference +// "\198\205\&73\171\GS\197\210\194\137\133\147S\150\223\188",PropAuthenticationMethod +// "9\220\237\141\190",PropTopicAliasMaximum 28999]}), _cleanSession = True, _keepAlive = 20710, _connID = +// "\153\186\STX-\152\157\214\157\245\"4\"\ETX", _properties = [PropUserProperty +// "\SUB\133\220E\183N\ETB\163\187\132K\128\169\234\\\fP6" +// "=[a\250\190Un\205I\154\&7H\150zo\NUL\166K\130\148\168",PropServerReference +// "\171\163`\204p\246\171",PropTopicAliasMaximum 11152,PropWillDelayInterval 11062,PropSharedSubscriptionAvailable +// 203,PropAuthenticationData "\DEL\212\DC1\UST\190\&2\160\152\&5\140\191\252\bz\173r\RS\155",PropWillDelayInterval +// 3785,PropTopicAliasMaximum 11255,PropServerReference +// "j\DC42\228ZG\246\181|\189\169\236\&3\227\152\f\236\207U/\183\"W",PropRequestResponseInformation +// 26,PropSharedSubscriptionAvailable 74,PropAssignedClientIdentifier +// "\132*\197\184\US\199~\178\237\234\b\227u\220J~L\197",PropTopicAlias 3113,PropReceiveMaximum +// 28559,PropSubscriptionIdentifier 12]} TEST(Connect5QCTest, Encode2) { uint8_t pkt[] = { - 0x10, 0xe4, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x1b, 0xf9, 0xeb, 0x1, 0x2, 0x0, 0x0, 0x58, - 0x5f, 0x28, 0x74, 0x1, 0xc5, 0x25, 0xc5, 0x22, 0x3a, 0xf5, 0x8, 0x0, 0x19, 0x4, 0x24, 0x7e, 0xe, 0xba, 0x9, - 0x98, 0x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x20, 0xa1, 0xe2, 0x1f, 0x0, - 0x7, 0xc4, 0xbb, 0x47, 0xef, 0xaf, 0xca, 0x8b, 0x0, 0xc, 0x7f, 0x46, 0xf0, 0xd1, 0x37, 0x57, 0xcb, 0x55, 0x7e, - 0x17, 0x73, 0x64, 0x0, 0x5, 0x92, 0xbf, 0x5d, 0xc, 0x7c, 0x0, 0xb, 0xa2, 0xa7, 0x3b, 0xe9, 0x7d, 0xa6, 0x2a, - 0xc2, 0xe, 0x35, 0x49, 0x0, 0x19, 0xce, 0x16, 0xfc, 0x5d, 0x3b, 0x62, 0xc, 0x7c, 0xf9, 0xef, 0xc7, 0x21, 0x21, - 0x17, 0x8e, 0x66, 0x7a, 0x99, 0xfa, 0x3e, 0x62, 0x76, 0x11, 0x3, 0x86}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x4, 0x24, 0x7e, 0xe, 0xba, 0x9, 0x98, 0xa2, 0xed, 0x95, 0x35, 0x1e, 0xb2, - 0x83, 0x87, 0x56, 0x61, 0xd3, 0x23, 0x2b, 0xb9, 0x40, 0xb0, 0x3f, 0xba}; - uint8_t bytesprops1[] = {0xa9, 0xef, 0x1e, 0xdc}; - uint8_t bytesprops2[] = {0xb2, 0xdc, 0x45, 0x6, 0xc4, 0x14, 0x5e, 0xc7, 0x3d, 0xfb, - 0x29, 0x5d, 0x7a, 0xfe, 0x4d, 0xfe, 0x58, 0xb, 0x9b, 0x64}; - uint8_t bytesprops3[] = {0x4c, 0xe2, 0x65, 0x47, 0x9f, 0xe9, 0x99, 0x21, 0xc0, 0x70, 0xea, 0x35, - 0xb6, 0x91, 0xdb, 0x68, 0xab, 0x22, 0x38, 0xea, 0x66, 0x45, 0x24, 0xe1}; - uint8_t bytesprops5[] = {0xa8, 0xe3, 0x8f, 0x7a, 0x31, 0xad}; - uint8_t bytesprops4[] = {0xbc, 0x91, 0xa4}; - uint8_t bytesprops6[] = {0xd5, 0x78}; - uint8_t bytesprops7[] = {0xe6, 0x91, 0x7e, 0x9e, 0x90, 0x19, 0xaf, 0x81, 0x40, 0xf9}; - uint8_t bytesprops8[] = {0xb, 0xa5, 0x2b, 0x3, 0x13, 0xa1, 0x3d, 0x9, 0x35, 0x26, 0x5d, 0xb5, 0x94}; - uint8_t bytesprops9[] = {0xd5, 0x73, 0xdc, 0x5, 0x7b, 0x44, 0x53, 0x65, 0x74, 0xf3, 0x3d, 0x77, - 0xda, 0x2a, 0x1, 0x13, 0xf5, 0xa4, 0x16, 0xc1, 0x71, 0x14, 0x85}; - uint8_t bytesprops10[] = {0x1a, 0xc8, 0xa5, 0xf7, 0xe7, 0xbc, 0xc1, 0xfb, 0xe2, 0xbb, 0xe7, 0x89, 0xe, - 0x7b, 0x8e, 0x78, 0x26, 0x75, 0xb7, 0x5a, 0xeb, 0xb1, 0x78, 0x6b, 0x42, 0x9f}; + 0x10, 0x8f, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb6, 0x50, 0xe6, 0x99, 0x1, 0x26, 0x0, 0x12, 0x1a, + 0x85, 0xdc, 0x45, 0xb7, 0x4e, 0x17, 0xa3, 0xbb, 0x84, 0x4b, 0x80, 0xa9, 0xea, 0x5c, 0xc, 0x50, 0x36, 0x0, 0x15, + 0x3d, 0x5b, 0x61, 0xfa, 0xbe, 0x55, 0x6e, 0xcd, 0x49, 0x9a, 0x37, 0x48, 0x96, 0x7a, 0x6f, 0x0, 0xa6, 0x4b, 0x82, + 0x94, 0xa8, 0x1c, 0x0, 0x7, 0xab, 0xa3, 0x60, 0xcc, 0x70, 0xf6, 0xab, 0x22, 0x2b, 0x90, 0x18, 0x0, 0x0, 0x2b, + 0x36, 0x2a, 0xcb, 0x16, 0x0, 0x13, 0x7f, 0xd4, 0x11, 0x1f, 0x54, 0xbe, 0x32, 0xa0, 0x98, 0x35, 0x8c, 0xbf, 0xfc, + 0x8, 0x7a, 0xad, 0x72, 0x1e, 0x9b, 0x18, 0x0, 0x0, 0xe,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 0x81, 0xc1, 0xa9, 0x4, 0x0, 0x1c, 0x8a, 0xe5, 0xde, 0xdc, 0xd8, 0x2f, 0xdb, 0xc5, 0xe0, + 0x17, 0xb1, 0x7f, 0x2e, 0xa5, 0x3c, 0xd2, 0x96, 0xb6, 0xd1, 0xde, 0x1, 0x15, 0x28, 0x52, 0xb1, 0x86, 0x3, 0x17, + 0x0, 0xf, 0x2b, 0xd9, 0xf5, 0x84, 0x4a, 0xdb, 0xa0, 0x8b, 0xe8, 0xd5, 0xe, 0xbd, 0x0, 0x2d, 0x13}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x3d, 0x5b, 0x61, 0xfa, 0xbe, 0x55, 0x6e, 0xcd, 0x49, 0x9a, 0x37, + 0x48, 0x96, 0x7a, 0x6f, 0x0, 0xa6, 0x4b, 0x82, 0x94, 0xa8}; + uint8_t bytesprops0[] = {0x1a, 0x85, 0xdc, 0x45, 0xb7, 0x4e, 0x17, 0xa3, 0xbb, + 0x84, 0x4b, 0x80, 0xa9, 0xea, 0x5c, 0xc, 0x50, 0x36}; + uint8_t bytesprops2[] = {0xab, 0xa3, 0x60, 0xcc, 0x70, 0xf6, 0xab}; + uint8_t bytesprops3[] = {0x7f, 0xd4, 0x11, 0x1f, 0x54, 0xbe, 0x32, 0xa0, 0x98, 0x35, + 0x8c, 0xbf, 0xfc, 0x8, 0x7a, 0xad, 0x72, 0x1e, 0x9b}; + uint8_t bytesprops4[] = {0x6a, 0x14, 0x32, 0xe4, 0x5a, 0x47, 0xf6, 0xb5, 0x7c, 0xbd, 0xa9, 0xec, + 0x33, 0xe3, 0x98, 0xc, 0xec, 0xcf, 0x55, 0x2f, 0xb7, 0x22, 0x57}; + uint8_t bytesprops5[] = {0x84, 0x2a, 0xc5, 0xb8, 0x1f, 0xc7, 0x7e, 0xb2, 0xed, + 0xea, 0x8, 0xe3, 0x75, 0xdc, 0x4a, 0x7e, 0x4c, 0xc5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22623}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15093}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8870}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6620}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8982}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops4}, .v = {6, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27750}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15510}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops0}, .v = {21, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11152}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11062}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3785}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11255}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3113}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28559}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd, 0xc, 0x7d, 0x7e, 0x4b, 0x41, 0x54, 0x6c, 0xc6, 0x4d, 0x1e, 0x2e, 0xcc, 0x7b, 0x9f}; - uint8_t byteswillprops1[] = {0x6f, 0x6c, 0xe8, 0x6a, 0x71, 0x60, 0x91, 0x8a, - 0xf2, 0xa2, 0x93, 0x21, 0x1e, 0x76, 0xba}; - uint8_t byteswillprops2[] = {0}; - uint8_t byteswillprops4[] = {0xe6, 0x31, 0x51, 0x5d, 0x4, 0x35, 0xdb, 0x3a, 0xbb, 0x50, - 0x6b, 0xf7, 0x4d, 0x61, 0x71, 0x87, 0x87, 0x10, 0x16, 0xcc}; - uint8_t byteswillprops3[] = {0xce, 0x3f, 0xe, 0x7, 0x70, 0x47, 0xd5, 0xe5, 0xd6, 0x9b, 0x7, 0x28, 0xc1, 0x7f, - 0xc9, 0xf7, 0xfa, 0xc1, 0x1d, 0x75, 0x56, 0x69, 0xee, 0x8f, 0x78, 0xb2, 0x70}; - uint8_t byteswillprops5[] = {0x54, 0x93, 0x51, 0xb1, 0xbf, 0x4c, 0x4c, 0x20, 0x40, 0x1b, 0x31, 0x1a, 0x2d, - 0x4b, 0x9a, 0x45, 0x49, 0xda, 0x1, 0xab, 0xe3, 0xa0, 0x20, 0xa1, 0xe2}; - uint8_t byteswillprops6[] = {0xc4, 0xbb, 0x47, 0xef, 0xaf, 0xca, 0x8b}; + uint8_t byteswillprops0[] = {0x47, 0xb1, 0x64, 0xab, 0xab, 0x25, 0xb6, 0xa6, 0x31, 0x90, + 0x64, 0xfe, 0x41, 0xcd, 0xfe, 0x93, 0xb8, 0x73, 0x7b}; + uint8_t byteswillprops1[] = {0xb9, 0x7a, 0x72, 0x2e, 0x8e, 0xbc, 0x76, 0x38, 0x52, 0x4b, 0x4f, 0xb, + 0x86, 0x53, 0x7c, 0xce, 0xef, 0xed, 0x9f, 0xfe, 0x6f, 0x74, 0xb9, 0x45}; + uint8_t byteswillprops2[] = {0x8c, 0x1f, 0x61, 0x74, 0xec, 0x29, 0x64, 0x20, 0x1a, 0x5f, 0xba, + 0x39, 0xf7, 0xac, 0x49, 0xeb, 0x46, 0xc9, 0x61, 0x6, 0xb, 0xf7}; + uint8_t byteswillprops3[] = {0x28, 0x76, 0x22, 0x2a, 0xec, 0xe5, 0xdf, 0x7, 0x9, 0xb1, + 0x2f, 0x95, 0x6a, 0xec, 0xf5, 0x15, 0xa, 0x43, 0x4}; + uint8_t byteswillprops4[] = {0xfa, 0xd, 0xf8, 0x9d}; + uint8_t byteswillprops5[] = {0x57, 0xda, 0x7c, 0xcf, 0x9c, 0x3b, 0xc8, 0x14, 0xb5, 0x74, 0x39, 0xca, 0x2f, + 0xb4, 0x2d, 0x63, 0xe2, 0xc, 0xca, 0xf0, 0x8e, 0x4c, 0xd8, 0x36, 0xc2, 0xe8}; + uint8_t byteswillprops6[] = {0x2f, 0x9e, 0x8b, 0xe3, 0x50, 0x17, 0xae, 0x46, + 0x5b, 0x77, 0xb1, 0xa8, 0x3c, 0xfb, 0xf2}; + uint8_t byteswillprops7[] = {0x2d, 0xc5, 0xdc, 0x9b, 0xbd, 0x70, 0x48, 0x70, 0x2, 0xa5, 0x93, 0x85, 0x77, 0xc9, 0x41}; + uint8_t byteswillprops8[] = {0x3e, 0x30, 0x70, 0xfb, 0xe8, 0xb9, 0x58, 0x74, 0xf7, 0xbf, 0x96, 0xd6, + 0x75, 0x1c, 0xf1, 0x30, 0xd0, 0x31, 0x42, 0xbf, 0xff, 0x47, 0x6d, 0x4c}; + uint8_t byteswillprops9[] = {0xc6, 0xcd, 0x37, 0x33, 0xab, 0x1d, 0xc5, 0xd2, + 0xc2, 0x89, 0x85, 0x93, 0x53, 0x96, 0xdf, 0xbc}; + uint8_t byteswillprops10[] = {0x39, 0xdc, 0xed, 0x8d, 0xbe}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25708}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17400}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9074}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20784}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {27, (char*)&byteswillprops3}, .v = {20, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4326}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12309}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1142}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16673}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17709}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9332}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22350}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4774}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28999}}, }; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x7f, 0x46, 0xf0, 0xd1, 0x37, 0x57, 0xcb, 0x55, 0x7e, 0x17, 0x73, 0x64}; - lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x92, 0xbf, 0x5d, 0xc, 0x7c}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4f, 0x1, 0xad, 0xa4, 0xee, 0xf8, 0xc, 0x26, 0x0, 0x50, 0xaf, 0x88, 0x2f, + 0x2c, 0x17, 0xff, 0x1d, 0xd0, 0xf7, 0x7f, 0x74, 0x81, 0xc1, 0xa9, 0x4}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x8a, 0xe5, 0xde, 0xdc, 0xd8, 0x2f, 0xdb, 0xc5, 0xe0, 0x17, 0xb1, 0x7f, 0x2e, 0xa5, + 0x3c, 0xd2, 0x96, 0xb6, 0xd1, 0xde, 0x1, 0x15, 0x28, 0x52, 0xb1, 0x86, 0x3, 0x17}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 7161; - uint8_t client_id_bytes[] = {0x41, 0x47, 0xb4, 0xd6, 0x35, 0xf5, 0x7, 0xc4, 0xa4, - 0x46, 0x71, 0xd1, 0x8d, 0xfa, 0x3e, 0xf6, 0x1e}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.keep_alive = 20710; + uint8_t client_id_bytes[] = {0x99, 0xba, 0x2, 0x2d, 0x98, 0x9d, 0xd6, 0x9d, 0xf5, 0x22, 0x34, 0x22, 0x3}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa2, 0xa7, 0x3b, 0xe9, 0x7d, 0xa6, 0x2a, 0xc2, 0xe, 0x35, 0x49}; - lwmqtt_string_t username = {11, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x2b, 0xd9, 0xf5, 0x84, 0x4a, 0xdb, 0xa0, 0x8b, 0xe8, 0xd5, 0xe, 0xbd, 0x0, 0x2d, 0x13}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xce, 0x16, 0xfc, 0x5d, 0x3b, 0x62, 0xc, 0x7c, 0xf9, 0xef, 0xc7, 0x21, 0x21, - 0x17, 0x8e, 0x66, 0x7a, 0x99, 0xfa, 0x3e, 0x62, 0x76, 0x11, 0x3, 0x86}; - lwmqtt_string_t password = {25, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -6662,36 +6970,86 @@ TEST(Connect5QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\176gX", _password = Nothing, _lastWill = Nothing, _cleanSession = False, -// _keepAlive = 30736, _connID = "\211\169\254\161\DLE", _properties = [PropSubscriptionIdentifier 28,PropContentType -// "av~m\140\233\EM\143\233\209\192\167\211",PropResponseTopic -// "\238\189\189T\191\133\200\153\142\214\241yDC",PropTopicAliasMaximum 10527]} +// ConnectRequest {_username = Just "\242\212u]\129\203\157", _password = Nothing, _lastWill = Nothing, _cleanSession = +// True, _keepAlive = 23152, _connID = "*\194\151\224rT\148\208", _properties = [PropTopicAliasMaximum +// 21505,PropPayloadFormatIndicator 227,PropRetainAvailable 225,PropContentType +// "\233\174\193r\132}5\ak!D'\164\142W\FS\195\&9\249\159\&4]\130\200$\DELk\153\254",PropServerKeepAlive +// 18739,PropMessageExpiryInterval 10105,PropTopicAliasMaximum 18324,PropTopicAlias 28758,PropRequestResponseInformation +// 153,PropSubscriptionIdentifier 1,PropPayloadFormatIndicator 236,PropMaximumQoS 0,PropCorrelationData +// "\205S2\232x\219O\128\141@\231\ETBq\187;\209\191\163",PropMessageExpiryInterval 1902,PropResponseInformation +// "\224\231\237\174\246\194F\227\147\140\170\190",PropMaximumQoS 219,PropMessageExpiryInterval +// 13875,PropRequestResponseInformation 124,PropSessionExpiryInterval 11378,PropWillDelayInterval +// 20615,PropRetainAvailable 181,PropResponseTopic "\US\146A\225\211\138\251\SOH\225\170",PropPayloadFormatIndicator +// 214,PropCorrelationData "\190\SUBb\CAN4D\197",PropAssignedClientIdentifier "\137TD.\ETX\181\131\144\&2m\"l\192"]} TEST(Connect5QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x80, 0x78, 0x10, 0x26, 0xb, 0x1c, 0x3, - 0x0, 0xd, 0x61, 0x76, 0x7e, 0x6d, 0x8c, 0xe9, 0x19, 0x8f, 0xe9, 0xd1, 0xc0, 0xa7, 0xd3, 0x8, - 0x0, 0xe, 0xee, 0xbd, 0xbd, 0x54, 0xbf, 0x85, 0xc8, 0x99, 0x8e, 0xd6, 0xf1, 0x79, 0x44, 0x43, - 0x22, 0x29, 0x1f, 0x0, 0x5, 0xd3, 0xa9, 0xfe, 0xa1, 0x10, 0x0, 0x3, 0xb0, 0x67, 0x58}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x61, 0x76, 0x7e, 0x6d, 0x8c, 0xe9, 0x19, 0x8f, 0xe9, 0xd1, 0xc0, 0xa7, 0xd3}; - uint8_t bytesprops1[] = {0xee, 0xbd, 0xbd, 0x54, 0xbf, 0x85, 0xc8, 0x99, 0x8e, 0xd6, 0xf1, 0x79, 0x44, 0x43}; + uint8_t pkt[] = { + 0x10, 0xde, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x82, 0x5a, 0x70, 0xbf, 0x1, 0x22, 0x54, 0x1, 0x1, + 0xe3, 0x25, 0xe1, 0x3, 0x0, 0x1d, 0xe9, 0xae, 0xc1, 0x72, 0x84, 0x7d, 0x35, 0x7, 0x6b, 0x21, 0x44, 0x27, 0xa4, + 0x8e, 0x57, 0x1c, 0xc3, 0x39, 0xf9, 0x9f, 0x34, 0x5d, 0x82, 0xc8, 0x24, 0x7f, 0x6b, 0x99, 0xfe, 0x13, 0x49, 0x33, + 0x2, 0x0, 0x0, 0x27, 0x79, 0x22, 0x47, 0x94, 0x23, 0x70, 0x56, 0x19, 0x99, 0xb, 0x1, 0x1, 0xec, 0x24, 0x0, + 0x9, 0x0, 0x12, 0xcd, 0x53, 0x32, 0xe8, 0x78, 0xdb, 0x4f, 0x80, 0x8d, 0x40, 0xe7, 0x17, 0x71, 0xbb, 0x3b, 0xd1, + 0xbf, 0xa3, 0x2, 0x0, 0x0, 0x7, 0x6e, 0x1a, 0x0, 0xc, 0xe0, 0xe7, 0xed, 0xae, 0xf6, 0xc2, 0x46, 0xe3, 0x93, + 0x8c, 0xaa, 0xbe, 0x24, 0xdb, 0x2, 0x0, 0x0, 0x36, 0x33, 0x19, 0x7c, 0x11, 0x0, 0x0, 0x2c, 0x72, 0x18, 0x0, + 0x0, 0x50, 0x87, 0x25, 0xb5, 0x8, 0x0, 0x5, 0x1f, 0x92, 0x41, 0x3c, 0x45, 0x1c, 0x0, 0x7, 0x85, 0x81, 0xb9, + 0x42, 0x6, 0x8c, 0x2e, 0x3, 0x0, 0x13, 0xcd, 0x5a, 0xf5, 0x9d, 0xfe, 0x5d, 0xf8, 0x90, 0xb1, 0x10, 0x16, 0x3e, + 0xe1, 0xd3, 0x8a, 0xfb, 0x1, 0xe1, 0xaa, 0x1, 0xd6, 0x9, 0x0, 0x7, 0xbe, 0x1a, 0x62, 0x18, 0x34, 0x44, 0xc5, + 0x12, 0x0, 0xd, 0x89, 0x54, 0x44, 0x2e, 0x3, 0xb5, 0x83, 0x90, 0x32, 0x6d, 0x22, 0x6c, 0xc0, 0x0, 0x8, 0x2a, + 0xc2, 0x97, 0xe0, 0x72, 0x54, 0x94, 0xd0, 0x0, 0x7, 0xf2, 0xd4, 0x75, 0x5d, 0x81, 0xcb, 0x9d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe9, 0xae, 0xc1, 0x72, 0x84, 0x7d, 0x35, 0x7, 0x6b, 0x21, 0x44, 0x27, 0xa4, 0x8e, 0x57, + 0x1c, 0xc3, 0x39, 0xf9, 0x9f, 0x34, 0x5d, 0x82, 0xc8, 0x24, 0x7f, 0x6b, 0x99, 0xfe}; + uint8_t bytesprops1[] = {0xcd, 0x53, 0x32, 0xe8, 0x78, 0xdb, 0x4f, 0x80, 0x8d, + 0x40, 0xe7, 0x17, 0x71, 0xbb, 0x3b, 0xd1, 0xbf, 0xa3}; + uint8_t bytesprops2[] = {0xe0, 0xe7, 0xed, 0xae, 0xf6, 0xc2, 0x46, 0xe3, 0x93, 0x8c, 0xaa, 0xbe}; + uint8_t bytesprops3[] = {0x1f, 0x92, 0x41, 0x3c, 0x45}; + uint8_t bytesprops4[] = {0x85, 0x81, 0xb9, 0x42, 0x6, 0x8c, 0x2e}; + uint8_t bytesprops5[] = {0xcd, 0x5a, 0xf5, 0x9d, 0xfe, 0x5d, 0xf8, 0x90, 0xb1, 0x10, + 0x16, 0x3e, 0xe1, 0xd3, 0x8a, 0xfb, 0x1, 0xe1, 0xaa}; + uint8_t bytesprops6[] = {0xbe, 0x1a, 0x62, 0x18, 0x34, 0x44, 0xc5}; + uint8_t bytesprops7[] = {0x89, 0x54, 0x44, 0x2e, 0x3, 0xb5, 0x83, 0x90, 0x32, 0x6d, 0x22, 0x6c, 0xc0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10527}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21505}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18739}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10105}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18324}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28758}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1902}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13875}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11378}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20615}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 30736; - uint8_t client_id_bytes[] = {0xd3, 0xa9, 0xfe, 0xa1, 0x10}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 23152; + uint8_t client_id_bytes[] = {0x2a, 0xc2, 0x97, 0xe0, 0x72, 0x54, 0x94, 0xd0}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb0, 0x67, 0x58}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf2, 0xd4, 0x75, 0x5d, 0x81, 0xcb, 0x9d}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); @@ -6701,114 +7059,153 @@ TEST(Connect5QCTest, Encode3) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\152\194\245\253\174\&7\EMM!8\179\176,\247\240\DC1\231\RS", _password = Just -// "/\242\177\206\FS\170L\220\250@\fO\156+2\DLE\GS\141\&5\180!\168t\129\133\aA\SO\213T", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "r\EOTA\136\195\188\137\213\144A\186\189\243\169\226\204\252", -// _willMsg = "\182\NAK", _willProps = [PropWildcardSubscriptionAvailable 103,PropAssignedClientIdentifier -// "D\255\207a\239K\166\248\143r\181&\232\167\n9j\140\167\166\135Zy(\217(2\229\188\152\140\&1\232d",PropTopicAlias +// 11543,PropUserProperty "\207\166S=eV-\136\154" +// "(w\159O\RS\128I#\140y\168\RS\217\v\SOH:\164\158\176\191",PropReasonString +// "\232\&5\177\241\186R2\130ys\DLEK\144k0\237}\163\236\169r|'\173\234\175X\209\US",PropMessageExpiryInterval +// 28516,PropServerReference +// "Ri}\167\197\208`KZ\233\146\"14\136\&9\169\171\187\f\192\164\145\SUB4",PropMaximumPacketSize 4874,PropReasonString +// "\134E:?\154\214\188\245\179i\144-NUy\213",PropAssignedClientIdentifier "\246\182@] +// \194P\245'\240\178\STX\132\162\184",PropReceiveMaximum 8768,PropServerReference +// "\222\175\169)\175\225\245&\237\231\NAK\131 \ETB\239y\254\159;\DC2",PropServerKeepAlive +// 27108,PropAuthenticationMethod "\DLE\152\NUL\199",PropResponseInformation +// "T\163S\147\149Wg\187_\160\196\228\t\239\172\"\231\NUL\208\150\138",PropRequestResponseInformation +// 157,PropSubscriptionIdentifier 12,PropServerReference "\143\233=",PropAssignedClientIdentifier +// "!\180\236\154F\169&\232J\136L\252\249]\ENQ\185pd\f\NAK\134\242 SN",PropCorrelationData +// "\156{\DC1>M\217\147\176?\247\196D\232\147\219N",PropSessionExpiryInterval 11271,PropSharedSubscriptionAvailable +// 207,PropResponseInformation "\aK_\SYNa\240\247\208\180\173{\ACK9\183\SOH\160\254EW'",PropMaximumPacketSize +// 18340,PropMessageExpiryInterval 10654,PropWillDelayInterval 13204,PropRetainAvailable 102]}), _cleanSession = True, +// _keepAlive = 29624, _connID = "\ETX\151\174C\139\235\225Y\221\247r\201\167\189j\NUL", _properties = +// [PropAuthenticationMethod "\176\DC1)\201\&4m)\DEL\222(\210\130\203",PropTopicAlias 23869,PropReceiveMaximum +// 14408,PropRetainAvailable 90,PropSessionExpiryInterval 22019,PropRequestProblemInformation +// 68,PropAuthenticationMethod "W\194\221\205\129\174h3\222",PropRequestResponseInformation 39]} TEST(Connect5QCTest, Encode4) { uint8_t pkt[] = { - 0x10, 0xbb, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x22, 0x85, 0x7b, 0x24, 0xfc, 0x29, 0x1b, 0x19, - 0x96, 0xb, 0xf, 0x11, 0x0, 0x0, 0xd, 0x76, 0x27, 0x0, 0x0, 0x7, 0x5c, 0x16, 0x0, 0x3, 0x32, 0x8, 0xcf, - 0x26, 0x0, 0x14, 0xcc, 0x1a, 0xe3, 0x79, 0x42, 0x14, 0xb, 0x43, 0x46, 0xa1, 0xb8, 0x60, 0x1e, 0xee, 0x62, 0x62, - 0xc6, 0xaf, 0xb2, 0x4f, 0x0, 0x0, 0x19, 0xb5, 0x15, 0x0, 0x5, 0x1d, 0xc1, 0xa5, 0xe8, 0x6a, 0x3, 0x0, 0x17, - 0x8a, 0xcf, 0xa6, 0xff, 0x57, 0x1c, 0x9d, 0x12, 0x5d, 0x7c, 0xa2, 0x2b, 0x77, 0xad, 0xa1, 0x8a, 0x99, 0x35, 0xca, - 0x96, 0xa, 0x71, 0xb6, 0x13, 0x24, 0x92, 0x9, 0x0, 0x1e, 0x28, 0x9a, 0x3b, 0x39, 0x14, 0x1b, 0x6a, 0x86, 0x59, - 0x16, 0x41, 0xaf, 0x91, 0x71, 0x8a, 0x55, 0x76, 0x5e, 0x83, 0x59, 0x27, 0xc7, 0xc9, 0x46, 0xb9, 0xd8, 0xb8, 0x53, - 0xfc, 0x68, 0xb, 0x18, 0x0, 0x17, 0xe5, 0x2d, 0x82, 0x9b, 0x9a, 0x61, 0xd6, 0xf8, 0xd6, 0x6c, 0x18, 0x8a, 0xf4, - 0xd2, 0x25, 0xa8, 0x9a, 0x9c, 0x11, 0xf1, 0x85, 0xe3, 0x31, 0x50, 0x28, 0x67, 0x12, 0x0, 0x1b, 0x44, 0xff, 0xcf, - 0x61, 0xef, 0x4b, 0xa6, 0xf8, 0x8f, 0x72, 0xb5, 0x26, 0xe8, 0xa7, 0xa, 0x39, 0x6a, 0x8c, 0xa7, 0x3c, 0x70, 0x6f, - 0x3c, 0x4a, 0xe5, 0xc, 0xae, 0x22, 0x2e, 0x8d, 0x1f, 0x0, 0xb, 0x8e, 0x88, 0x67, 0xf2, 0xaf, 0x17, 0x3, 0x1, - 0x2b, 0xea, 0x77, 0x12, 0x0, 0x11, 0xce, 0xc8, 0xdc, 0xe3, 0x66, 0xa3, 0x6b, 0xfc, 0x4c, 0xb1, 0xfc, 0x90, 0x2e, - 0x50, 0xd4, 0x8b, 0x78, 0x11, 0x0, 0x0, 0x66, 0x5b, 0x19, 0x9e, 0x17, 0x27, 0x24, 0xb3, 0x0, 0x11, 0x72, 0x4, - 0x41, 0x88, 0xc3, 0xbc, 0x89, 0xd5, 0x90, 0x41, 0xba, 0xbd, 0xf3, 0xa9, 0xe2, 0xcc, 0xfc, 0x0, 0x2, 0xb6, 0x15, - 0x0, 0x12, 0x98, 0xc2, 0xf5, 0xfd, 0xae, 0x37, 0x19, 0x4d, 0x21, 0x38, 0xb3, 0xb0, 0x2c, 0xf7, 0xf0, 0x11, 0xe7, - 0x1e, 0x0, 0x1e, 0x2f, 0xf2, 0xb1, 0xce, 0x1c, 0xaa, 0x4c, 0xdc, 0xfa, 0x40, 0xc, 0x4f, 0x9c, 0x2b, 0x32, 0x10, - 0x1d, 0x8d, 0x35, 0xb4, 0x21, 0xa8, 0x74, 0x81, 0x85, 0x7, 0x41, 0xe, 0xd5, 0x54}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x32, 0x8, 0xcf}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops1[] = {0xcc, 0x1a, 0xe3, 0x79, 0x42, 0x14, 0xb, 0x43, 0x46, 0xa1, - 0xb8, 0x60, 0x1e, 0xee, 0x62, 0x62, 0xc6, 0xaf, 0xb2, 0x4f}; - uint8_t bytesprops3[] = {0x1d, 0xc1, 0xa5, 0xe8, 0x6a}; - uint8_t bytesprops4[] = {0x8a, 0xcf, 0xa6, 0xff, 0x57, 0x1c, 0x9d, 0x12, 0x5d, 0x7c, 0xa2, 0x2b, - 0x77, 0xad, 0xa1, 0x8a, 0x99, 0x35, 0xca, 0x96, 0xa, 0x71, 0xb6}; - uint8_t bytesprops5[] = {0x28, 0x9a, 0x3b, 0x39, 0x14, 0x1b, 0x6a, 0x86, 0x59, 0x16, 0x41, 0xaf, 0x91, 0x71, 0x8a, - 0x55, 0x76, 0x5e, 0x83, 0x59, 0x27, 0xc7, 0xc9, 0x46, 0xb9, 0xd8, 0xb8, 0x53, 0xfc, 0x68}; + 0x10, 0xdc, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x66, 0x73, 0xb8, 0x2d, 0x15, 0x0, 0xd, 0xb0, 0x11, + 0x29, 0xc9, 0x34, 0x6d, 0x29, 0x7f, 0xde, 0x28, 0xd2, 0x82, 0xcb, 0x23, 0x5d, 0x3d, 0x21, 0x38, 0x48, 0x25, 0x5a, + 0x11, 0x0, 0x0, 0x56, 0x3, 0x17, 0x44, 0x15, 0x0, 0x9, 0x57, 0xc2, 0xdd, 0xcd, 0x81, 0xae, 0x68, 0x33, 0xde, + 0x19, 0x27, 0x0, 0x10, 0x3, 0x97, 0xae, 0x43, 0x8b, 0xeb, 0xe1, 0x59, 0xdd, 0xf7, 0x72, 0xc9, 0xa7, 0xbd, 0x6a, + 0x0, 0xd5, 0x2, 0x28, 0x0, 0x1c, 0x0, 0x1c, 0xa0, 0xd0, 0x2f, 0x31, 0x7b, 0x29, 0x36, 0x5e, 0x18, 0xdc, 0xa6, + 0x45, 0x3e, 0xa6, 0x87, 0x5a, 0x79, 0x28, 0xd9, 0x28, 0x32,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x70, 0x36}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb0, 0x11, 0x29, 0xc9, 0x34, 0x6d, 0x29, 0x7f, 0xde, 0x28, 0xd2, 0x82, 0xcb}; + uint8_t bytesprops1[] = {0x57, 0xc2, 0xdd, 0xcd, 0x81, 0xae, 0x68, 0x33, 0xde}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3446}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1884}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops1}, .v = {0, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9362}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23869}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14408}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22019}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x44, 0xff, 0xcf, 0x61, 0xef, 0x4b, 0xa6, 0xf8, 0x8f, 0x72, 0xb5, 0x26, 0xe8, 0xa7, - 0xa, 0x39, 0x6a, 0x8c, 0xa7, 0x3c, 0x70, 0x6f, 0x3c, 0x4a, 0xe5, 0xc, 0xae}; - uint8_t byteswillprops1[] = {0x8e, 0x88, 0x67, 0xf2, 0xaf, 0x17, 0x3, 0x1, 0x2b, 0xea, 0x77}; - uint8_t byteswillprops2[] = {0xce, 0xc8, 0xdc, 0xe3, 0x66, 0xa3, 0x6b, 0xfc, 0x4c, - 0xb1, 0xfc, 0x90, 0x2e, 0x50, 0xd4, 0x8b, 0x78}; + uint8_t byteswillprops0[] = {0xa0, 0xd0, 0x2f, 0x31, 0x7b, 0x29, 0x36, 0x5e, 0x18, 0xdc, 0xa6, 0x45, 0x3e, 0xa6, + 0x87, 0x5a, 0x79, 0x28, 0xd9, 0x28, 0x32, 0xe5, 0xbc, 0x98, 0x8c, 0x31, 0xe8, 0x64}; + uint8_t byteswillprops2[] = {0x28, 0x77, 0x9f, 0x4f, 0x1e, 0x80, 0x49, 0x23, 0x8c, 0x79, + 0xa8, 0x1e, 0xd9, 0xb, 0x1, 0x3a, 0xa4, 0x9e, 0xb0, 0xbf}; + uint8_t byteswillprops1[] = {0xcf, 0xa6, 0x53, 0x3d, 0x65, 0x56, 0x2d, 0x88, 0x9a}; + uint8_t byteswillprops3[] = {0xe8, 0x35, 0xb1, 0xf1, 0xba, 0x52, 0x32, 0x82, 0x79, 0x73, 0x10, 0x4b, 0x90, 0x6b, 0x30, + 0xed, 0x7d, 0xa3, 0xec, 0xa9, 0x72, 0x7c, 0x27, 0xad, 0xea, 0xaf, 0x58, 0xd1, 0x1f}; + uint8_t byteswillprops4[] = {0x52, 0x69, 0x7d, 0xa7, 0xc5, 0xd0, 0x60, 0x4b, 0x5a, 0xe9, 0x92, 0x22, 0x31, + 0x34, 0x88, 0x39, 0xa9, 0xab, 0xbb, 0xc, 0xc0, 0xa4, 0x91, 0x1a, 0x34}; + uint8_t byteswillprops5[] = {0x86, 0x45, 0x3a, 0x3f, 0x9a, 0xd6, 0xbc, 0xf5, + 0xb3, 0x69, 0x90, 0x2d, 0x4e, 0x55, 0x79, 0xd5}; + uint8_t byteswillprops6[] = {0xf6, 0xb6, 0x40, 0x5d, 0x20, 0xc2, 0x50, 0xf5, 0x27, 0xf0, 0xb2, 0x2, 0x84, 0xa2, 0xb8}; + uint8_t byteswillprops7[] = {0xde, 0xaf, 0xa9, 0x29, 0xaf, 0xe1, 0xf5, 0x26, 0xed, 0xe7, + 0x15, 0x83, 0x20, 0x17, 0xef, 0x79, 0xfe, 0x9f, 0x3b, 0x12}; + uint8_t byteswillprops8[] = {0x10, 0x98, 0x0, 0xc7}; + uint8_t byteswillprops9[] = {0x54, 0xa3, 0x53, 0x93, 0x95, 0x57, 0x67, 0xbb, 0x5f, 0xa0, 0xc4, + 0xe4, 0x9, 0xef, 0xac, 0x22, 0xe7, 0x0, 0xd0, 0x96, 0x8a}; + uint8_t byteswillprops10[] = {0x8f, 0xe9, 0x3d}; + uint8_t byteswillprops11[] = {0x21, 0xb4, 0xec, 0x9a, 0x46, 0xa9, 0x26, 0xe8, 0x4a, 0x88, 0x4c, 0xfc, 0xf9, + 0x5d, 0x5, 0xb9, 0x70, 0x64, 0xc, 0x15, 0x86, 0xf2, 0x20, 0x53, 0x4e}; + uint8_t byteswillprops12[] = {0x9c, 0x7b, 0x11, 0x3e, 0x4d, 0xd9, 0x93, 0xb0, + 0x3f, 0xf7, 0xc4, 0x44, 0xe8, 0x93, 0xdb, 0x4e}; + uint8_t byteswillprops13[] = {0x7, 0x4b, 0x5f, 0x16, 0x61, 0xf0, 0xf7, 0xd0, 0xb4, 0xad, + 0x7b, 0x6, 0x39, 0xb7, 0x1, 0xa0, 0xfe, 0x45, 0x57, 0x27}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11917}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26203}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11543}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {9, (char*)&byteswillprops1}, .v = {20, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28516}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4874}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8768}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27108}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&byteswillprops12}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11271}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&byteswillprops13}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18340}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10654}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13204}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, }; - lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x72, 0x4, 0x41, 0x88, 0xc3, 0xbc, 0x89, 0xd5, 0x90, - 0x41, 0xba, 0xbd, 0xf3, 0xa9, 0xe2, 0xcc, 0xfc}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb6, 0x15}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x18, 0x3d, 0x53, 0xd9, 0x2, 0xe2, 0x76, 0xfb, 0x36, 0xa1, 0x16, 0xa8, 0xe, 0x3a, + 0x12, 0x50, 0xc6, 0xb8, 0xd9, 0xa1, 0xdd, 0xc7, 0x94, 0xa8, 0x8e, 0x17, 0xf5, 0xb2}; + lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x66, 0xf1, 0xa, 0x5d, 0x14, 0xc6, 0x92, 0xbb, 0x5c, 0xef, + 0x95, 0x78, 0xa3, 0xc2, 0xb3, 0x3f, 0x84, 0xcf, 0x53}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 8837; - uint8_t client_id_bytes[] = {0xe5, 0x2d, 0x82, 0x9b, 0x9a, 0x61, 0xd6, 0xf8, 0xd6, 0x6c, 0x18, 0x8a, - 0xf4, 0xd2, 0x25, 0xa8, 0x9a, 0x9c, 0x11, 0xf1, 0x85, 0xe3, 0x31}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 29624; + uint8_t client_id_bytes[] = {0x3, 0x97, 0xae, 0x43, 0x8b, 0xeb, 0xe1, 0x59, + 0xdd, 0xf7, 0x72, 0xc9, 0xa7, 0xbd, 0x6a, 0x0}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x98, 0xc2, 0xf5, 0xfd, 0xae, 0x37, 0x19, 0x4d, 0x21, - 0x38, 0xb3, 0xb0, 0x2c, 0xf7, 0xf0, 0x11, 0xe7, 0x1e}; - lwmqtt_string_t username = {18, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x2f, 0xf2, 0xb1, 0xce, 0x1c, 0xaa, 0x4c, 0xdc, 0xfa, 0x40, 0xc, 0x4f, 0x9c, 0x2b, 0x32, - 0x10, 0x1d, 0x8d, 0x35, 0xb4, 0x21, 0xa8, 0x74, 0x81, 0x85, 0x7, 0x41, 0xe, 0xd5, 0x54}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x10, 0x76, 0xb6, 0x83, 0x70, 0x36}; + lwmqtt_string_t password = {6, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -6818,347 +7215,147 @@ TEST(Connect5QCTest, Encode4) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "Fl\165\191E\132:\161", _password = Nothing, _lastWill = Just (LastWill {_willRetain -// = True, _willQoS = QoS2, _willTopic = "\213\133\231\FS\130\ACKE\191\250\EM\neI\a\139\243\227\216J\222\222", _willMsg -// = "\247\199pz\189\158\163r[\131P\201w\133", _willProps = [PropServerReference "\252\218\134% -// p.\135\213\205\223o\223\230\248",PropPayloadFormatIndicator 226,PropContentType -// "\254\226\225\163\179\178\157\243\166G?\134^\243\195w\213\b\230t\174\185",PropMessageExpiryInterval -// 3225,PropMessageExpiryInterval 17734,PropReceiveMaximum 29099,PropSharedSubscriptionAvailable 174,PropReasonString -// "m\231@%,y\206\175",PropSubscriptionIdentifier 18,PropSessionExpiryInterval 20232,PropSharedSubscriptionAvailable -// 160,PropRetainAvailable 228,PropWillDelayInterval 18654,PropSessionExpiryInterval 10509,PropMessageExpiryInterval -// 24719,PropTopicAlias 13466,PropReasonString -// "\159\182\139\&3\128j\142}\b\153\175\154\190",PropRequestResponseInformation 93,PropSessionExpiryInterval -// 2330,PropTopicAliasMaximum 5301,PropServerKeepAlive 10209,PropAuthenticationMethod -// "^\218\144\219\t\210<\142\v\240\192\205\DC4>7\180\215wX\245",PropReasonString "",PropMaximumPacketSize -// 10882,PropSubscriptionIdentifierAvailable 84,PropAuthenticationMethod -// "d'v\161\242\222\155\141\236\225\180H\247B",PropAssignedClientIdentifier "\ACK\147}^]IXY%\RS\DC2|d\140"]}), -// _cleanSession = True, _keepAlive = 10218, _connID = "\242\150&X\DC2\211\232+\139", _properties = [PropMaximumQoS -// 211,PropSessionExpiryInterval 6199,PropMaximumPacketSize 19431,PropMessageExpiryInterval -// 20624,PropRequestResponseInformation 50,PropTopicAlias 28881,PropContentType -// "\187dw\204\ACK\253\134",PropAuthenticationData "\ETB\204%\fG\182\186^U\238\232\&6\146",PropPayloadFormatIndicator -// 69,PropRetainAvailable 103,PropContentType "p\247\181Gq\222t\t",PropUserProperty "N\154\ak\147\184\186K\DEL\SOHX\GS2" -// "p'\FSsI\ENQCUvg5#\253\252\NUL\207\175J\171\SINc\b\179\198n\USa\186\"",PropServerReference -// "\171-(\161\245\EM?\233\140\228\133Xg?\151\DC4-}\225\&9\246",PropSessionExpiryInterval 21133,PropAuthenticationData -// "?\ETB\ESC\159\213\STX\US\255[\b\RS0'JB\248",PropServerReference -// "\143z\192\143\133\235:L\146x\228\221\182\180\ETX\190\r\188H\244",PropMessageExpiryInterval -// 2372,PropSubscriptionIdentifier 23]} +// ConnectRequest {_username = Just "K\229g\209}\210\138\137T;\154Eh", _password = Nothing, _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 31695, _connID = "cG\191s\155\131\202\186\155\&5C\DC2\207\217\173\144 +// \248\248\148", _properties = [PropTopicAliasMaximum 1156,PropRetainAvailable 243,PropCorrelationData +// "\194^}\DLE\199\252\216\&0\DC1z\r\t\216\187\FS\238\SO\236\240\163h\r\195\254\132\229t\244",PropWillDelayInterval +// 21486]} TEST(Connect5QCTest, Encode5) { - uint8_t pkt[] = { - 0x10, 0xcb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb6, 0x27, 0xea, 0xbd, 0x1, 0x24, 0xd3, 0x11, 0x0, - 0x0, 0x18, 0x37, 0x27, 0x0, 0x0, 0x4b, 0xe7, 0x2, 0x0, 0x0, 0x50, 0x90, 0x19, 0x32, 0x23, 0x70, 0xd1, 0x3, - 0x0, 0x7, 0xbb, 0x64, 0x77, 0xcc, 0x6, 0xfd, 0x86, 0x16, 0x0, 0xd, 0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0xa, 0x65, 0x49, 0x7, 0x8b, 0xf3, 0xe3, 0xd8, 0x4a, 0xde, 0xde, 0x0, - 0xe, 0xf7, 0xc7, 0x70, 0x7a, 0xbd, 0x9e, 0xa3, 0x72, 0x5b, 0x83, 0x50, 0xc9, 0x77, 0x85, 0x0, 0x8, 0x46, 0x6c, - 0xa5, 0xbf, 0x45, 0x84, 0x3a, 0xa1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xbb, 0x64, 0x77, 0xcc, 0x6, 0xfd, 0x86}; - uint8_t bytesprops1[] = {0x17, 0xcc, 0x25, 0xc, 0x47, 0xb6, 0xba, 0x5e, 0x55, 0xee, 0xe8, 0x36, 0x92}; - uint8_t bytesprops2[] = {0x70, 0xf7, 0xb5, 0x47, 0x71, 0xde, 0x74, 0x9}; - uint8_t bytesprops4[] = {0x70, 0x27, 0x1c, 0x73, 0x49, 0x5, 0x43, 0x55, 0x76, 0x67, 0x35, 0x23, 0xfd, 0xfc, 0x0, - 0xcf, 0xaf, 0x4a, 0xab, 0xf, 0x4e, 0x63, 0x8, 0xb3, 0xc6, 0x6e, 0x1f, 0x61, 0xba, 0x22}; - uint8_t bytesprops3[] = {0x4e, 0x9a, 0x7, 0x6b, 0x93, 0xb8, 0xba, 0x4b, 0x7f, 0x1, 0x58, 0x1d, 0x32}; - uint8_t bytesprops5[] = {0xab, 0x2d, 0x28, 0xa1, 0xf5, 0x19, 0x3f, 0xe9, 0x8c, 0xe4, 0x85, - 0x58, 0x67, 0x3f, 0x97, 0x14, 0x2d, 0x7d, 0xe1, 0x39, 0xf6}; - uint8_t bytesprops6[] = {0x3f, 0x17, 0x1b, 0x9f, 0xd5, 0x2, 0x1f, 0xff, - 0x5b, 0x8, 0x1e, 0x30, 0x27, 0x4a, 0x42, 0xf8}; - uint8_t bytesprops7[] = {0x8f, 0x7a, 0xc0, 0x8f, 0x85, 0xeb, 0x3a, 0x4c, 0x92, 0x78, - 0xe4, 0xdd, 0xb6, 0xb4, 0x3, 0xbe, 0xd, 0xbc, 0x48, 0xf4}; + uint8_t pkt[] = {0x10, 0x59, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x82, 0x7b, 0xcf, 0x29, 0x22, 0x4, 0x84, + 0x25, 0xf3, 0x9, 0x0, 0x1c, 0xc2, 0x5e, 0x7d, 0x10, 0xc7, 0xfc, 0xd8, 0x30, 0x11, 0x7a, 0xd, + 0x9, 0xd8, 0xbb, 0x1c, 0xee, 0xe, 0xec, 0xf0, 0xa3, 0x68, 0xd, 0xc3, 0xfe, 0x84, 0xe5, 0x74, + 0xf4, 0x18, 0x0, 0x0, 0x53, 0xee, 0x0, 0x14, 0x63, 0x47, 0xbf, 0x73, 0x9b, 0x83, 0xca, 0xba, + 0x9b, 0x35, 0x43, 0x12, 0xcf, 0xd9, 0xad, 0x90, 0x20, 0xf8, 0xf8, 0x94, 0x0, 0xd, 0x4b, 0xe5, + 0x67, 0xd1, 0x7d, 0xd2, 0x8a, 0x89, 0x54, 0x3b, 0x9a, 0x45, 0x68}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc2, 0x5e, 0x7d, 0x10, 0xc7, 0xfc, 0xd8, 0x30, 0x11, 0x7a, 0xd, 0x9, 0xd8, 0xbb, + 0x1c, 0xee, 0xe, 0xec, 0xf0, 0xa3, 0x68, 0xd, 0xc3, 0xfe, 0x84, 0xe5, 0x74, 0xf4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6199}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19431}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20624}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28881}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops3}, .v = {30, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21133}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2372}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xfc, 0xda, 0x86, 0x25, 0x20, 0x70, 0x2e, 0x87, - 0xd5, 0xcd, 0xdf, 0x6f, 0xdf, 0xe6, 0xf8}; - uint8_t byteswillprops1[] = {0xfe, 0xe2, 0xe1, 0xa3, 0xb3, 0xb2, 0x9d, 0xf3, 0xa6, 0x47, 0x3f, - 0x86, 0x5e, 0xf3, 0xc3, 0x77, 0xd5, 0x8, 0xe6, 0x74, 0xae, 0xb9}; - uint8_t byteswillprops2[] = {0x6d, 0xe7, 0x40, 0x25, 0x2c, 0x79, 0xce, 0xaf}; - uint8_t byteswillprops3[] = {0x9f, 0xb6, 0x8b, 0x33, 0x80, 0x6a, 0x8e, 0x7d, 0x8, 0x99, 0xaf, 0x9a, 0xbe}; - uint8_t byteswillprops4[] = {0x5e, 0xda, 0x90, 0xdb, 0x9, 0xd2, 0x3c, 0x8e, 0xb, 0xf0, - 0xc0, 0xcd, 0x14, 0x3e, 0x37, 0xb4, 0xd7, 0x77, 0x58, 0xf5}; - uint8_t byteswillprops5[] = {0}; - uint8_t byteswillprops6[] = {0x64, 0x27, 0x76, 0xa1, 0xf2, 0xde, 0x9b, 0x8d, 0xec, 0xe1, 0xb4, 0x48, 0xf7, 0x42}; - uint8_t byteswillprops7[] = {0x6, 0x93, 0x7d, 0x5e, 0x5d, 0x49, 0x58, 0x59, 0x25, 0x1e, 0x12, 0x7c, 0x64, 0x8c}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3225}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17734}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29099}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20232}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18654}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10509}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24719}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13466}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2330}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5301}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10209}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10882}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1156}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21486}}, }; - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd5, 0x85, 0xe7, 0x1c, 0x82, 0x6, 0x45, 0xbf, 0xfa, 0x19, 0xa, - 0x65, 0x49, 0x7, 0x8b, 0xf3, 0xe3, 0xd8, 0x4a, 0xde, 0xde}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf7, 0xc7, 0x70, 0x7a, 0xbd, 0x9e, 0xa3, 0x72, 0x5b, 0x83, 0x50, 0xc9, 0x77, 0x85}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 10218; - uint8_t client_id_bytes[] = {0xf2, 0x96, 0x26, 0x58, 0x12, 0xd3, 0xe8, 0x2b, 0x8b}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.keep_alive = 31695; + uint8_t client_id_bytes[] = {0x63, 0x47, 0xbf, 0x73, 0x9b, 0x83, 0xca, 0xba, 0x9b, 0x35, + 0x43, 0x12, 0xcf, 0xd9, 0xad, 0x90, 0x20, 0xf8, 0xf8, 0x94}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x46, 0x6c, 0xa5, 0xbf, 0x45, 0x84, 0x3a, 0xa1}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x4b, 0xe5, 0x67, 0xd1, 0x7d, 0xd2, 0x8a, 0x89, 0x54, 0x3b, 0x9a, 0x45, 0x68}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "Sz8i\155\185\247\FSM\223\r`\"\187\ACK\244\ETB7(\218^\ETX~\231o+\166\\", _password = -// Just "\254", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "\178\171\DC2\211\200\EM\184\SOH\SI1\182\142\236\165\201\180\217\179\236y\215\n", _willMsg = -// "\176\DC3\142\CAN5\229j\140\194\241\152", _willProps = [PropRequestProblemInformation 131,PropMaximumQoS -// 5,PropSessionExpiryInterval 25356,PropRequestProblemInformation 220,PropAssignedClientIdentifier -// "\247N:\229H>\180",PropAuthenticationData -// "\222\&4P\205\194<\166\217*\151\250\154\160J\212\220l\ETBc\142",PropServerReference -// "\SOH.%\177\191E$I\222\247m\147\230\186G\218\&4T\219C\221\242\&0\bX\217\ESC{",PropContentType -// "\197,\NAK\140\CAN\192\181\233\243\&3\EOTFs\190\185\255\152\232\ETB\DC1Mq\169\DEL",PropReasonString -// "\f\239}\153Tp`+\CANn\187\197s\245\CAN\246\151",PropUserProperty "\167-4\244" -// "\NULY\201\143\168x\214\198\142?\203$\159\137\210\&5)",PropRequestResponseInformation 39,PropUserProperty "s" -// "v\198\128\215\&1-9_\167\&8\129\\\250\220\STX\212;\215\228d",PropPayloadFormatIndicator 12,PropResponseInformation -// "Be\171\151\238\232\167#YV\133HcN\199\190\234J\166\176\167B+Y\v:",PropCorrelationData -// "5\157\228cG\224\152",PropServerKeepAlive 31492,PropTopicAlias 13537,PropRequestResponseInformation -// 163,PropAuthenticationData "S9L\176\223\EOTR\249.'C\188}",PropMaximumPacketSize 29119,PropAuthenticationData -// "\171{\DC3\240\194L\167\199\180\CANW\SYN\187\&2\173D\STX7\190\240!Cr\205\188\181\200_.\SO",PropUserProperty -// "x$QG\NAK\234\246\242\&2]\179a\235\216" "\225\144p\163cy\134\187>4\191 -// \143\ESC\215[#\246\166\154\ETXx|29l",PropRequestResponseInformation 126]}), _cleanSession = True, _keepAlive = 13826, -// _connID = "eYUoE\DELM\180&\227\132\v\STX\ESC\198\183?\245\247n\197\DC1", _properties = [PropMessageExpiryInterval -// 32766,PropSharedSubscriptionAvailable 26,PropTopicAlias 12471,PropSubscriptionIdentifierAvailable 210,PropContentType -// "\171wd\141\154h\DEL\215a\191i\b\235\SOt\169)\191",PropUserProperty "\176\SO\245" -// "\139\ACK\136\148\&9\138\&5\237\132\ETB1!!\193\SUBN`\145]",PropAuthenticationMethod -// "\181\166\205}\200\176?\210-\207\220v?X\212gX\187\&8\162",PropSharedSubscriptionAvailable -// 75,PropRequestProblemInformation 208,PropRequestProblemInformation 25,PropWillDelayInterval -// 27174,PropWildcardSubscriptionAvailable 127,PropPayloadFormatIndicator 5,PropAssignedClientIdentifier -// "/\SOHl\254\189\222\198x\219\180\188",PropRequestProblemInformation 198,PropReasonString -// "\240\nb\151\142\130\224ZbwA\SYN\189\EOT-K\160\NUL\SO\134T\148\232\194\132b\218\SIE\241L\156\204\169\145X3\250", _password = Nothing, +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\CANf\159\155m", _willMsg = +// "\155)T\206\250\163y-\213[_\a\159\GS=\195L\155L\164\220\243\225)\208p", _willProps = [PropContentType +// "\157S\144\253Y|<\129I\STXt\204\255\142Y\166H\ETX\219qj<"]}), _cleanSession = True, _keepAlive = 11529, _connID = "", +// _properties = [PropPayloadFormatIndicator 16,PropSessionExpiryInterval 23466,PropUserProperty +// "\DC2\GS\USW\133\DC2\RSc\r\133l\175\152\146\DELY\219\190\209\216\157~\240\203r" +// "\137\152\v\218\152\134\FS0\DC3\204b\DC4\216\b:\151\188\165\248\&2\ESC\142\186\ayv\168",PropAssignedClientIdentifier +// "`r\229\GS\159\v\241\179e",PropTopicAlias 4328,PropWildcardSubscriptionAvailable 130,PropPayloadFormatIndicator +// 239,PropWillDelayInterval 18921,PropTopicAlias 12433,PropTopicAlias 2560,PropTopicAlias 3720,PropTopicAliasMaximum +// 3890,PropReasonString "5\205a\143!\211[\209hz\\\246\154\221nZ",PropTopicAliasMaximum +// 10484,PropRequestResponseInformation 247,PropSharedSubscriptionAvailable 91,PropReasonString +// "\141\226v",PropServerKeepAlive 676,PropUserProperty "\158\SUB@\177\137*\190\160j\203\r\160" +// "\189\221\157j1]\FSt\217\168Zo\202\228\173",PropWildcardSubscriptionAvailable 176,PropRetainAvailable 67]} TEST(Connect5QCTest, Encode6) { uint8_t pkt[] = { - 0x10, 0xd9, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x36, 0x2, 0xa7, 0x1, 0x2, 0x0, 0x0, 0x7f, - 0xfe, 0x2a, 0x1a, 0x23, 0x30, 0xb7, 0x29, 0xd2, 0x3, 0x0, 0x12, 0xab, 0x77, 0x64, 0x8d, 0x9a, 0x68, 0x7f, 0xd7, - 0x61, 0xbf, 0x69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b, 0xa6, 0x5c, 0x0, 0x1, 0xfe}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xab, 0x77, 0x64, 0x8d, 0x9a, 0x68, 0x7f, 0xd7, 0x61, - 0xbf, 0x69, 0x8, 0xeb, 0xe, 0x74, 0xa9, 0x29, 0xbf}; - uint8_t bytesprops2[] = {0x8b, 0x6, 0x88, 0x94, 0x39, 0x8a, 0x35, 0xed, 0x84, 0x17, - 0x31, 0x21, 0x21, 0xc1, 0x1a, 0x4e, 0x60, 0x91, 0x5d}; - uint8_t bytesprops1[] = {0xb0, 0xe, 0xf5}; - uint8_t bytesprops3[] = {0xb5, 0xa6, 0xcd, 0x7d, 0xc8, 0xb0, 0x3f, 0xd2, 0x2d, 0xcf, - 0xdc, 0x76, 0x3f, 0x58, 0xd4, 0x67, 0x58, 0xbb, 0x38, 0xa2}; - uint8_t bytesprops4[] = {0x2f, 0x1, 0x6c, 0xfe, 0xbd, 0xde, 0xc6, 0x78, 0xdb, 0xb4, 0xbc}; - uint8_t bytesprops5[] = {0xf0, 0xa, 0x62, 0x97, 0x8e, 0x82, 0xe0, 0x5a, 0x62, 0x77, 0x41, 0x16, 0xbd, 0x3c, 0x45}; - uint8_t bytesprops7[] = {0xa5, 0x80, 0x19, 0x86, 0xf2, 0x88, 0xe7, 0x7d}; - uint8_t bytesprops6[] = {0xe6, 0xfa, 0xa7, 0xca, 0xac, 0x14, 0x61, 0x77, 0x36, 0xea, 0xb, 0x7b, 0x73, 0x8f, 0x4e}; + 0x10, 0x96, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x96, 0x2d, 0x9, 0xab, 0x1, 0x1, 0x10, 0x11, 0x0, + 0x0, 0x5b, 0xaa, 0x26, 0x0, 0x19, 0x12, 0x1d, 0x1f, 0x57, 0x85, 0x12, 0x1e, 0x63, 0xd, 0x85, 0x6c, 0xaf, 0x98, + 0x92, 0x7f, 0x59, 0xdb, 0xbe, 0xd1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0x2d, 0xd5, 0x5b, 0x5f, 0x7, 0x9f, 0x1d, 0x3d, 0xc3, 0x4c, 0x9b, 0x4c, 0xa4, 0xdc, 0xf3, 0xe1, 0x29, + 0xd0, 0x70, 0x0, 0x1e, 0xaf, 0x27, 0x1f, 0x37, 0x3e, 0x4, 0x2d, 0x4b, 0xa0, 0x0, 0xe, 0x86, 0x54, 0x94, 0xe8, + 0xc2, 0x84, 0x62, 0xda, 0xf, 0x45, 0xf1, 0x4c, 0x9c, 0xcc, 0xa9, 0x91, 0x58, 0x33, 0xfa}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x89, 0x98, 0xb, 0xda, 0x98, 0x86, 0x1c, 0x30, 0x13, 0xcc, 0x62, 0x14, 0xd8, 0x8, + 0x3a, 0x97, 0xbc, 0xa5, 0xf8, 0x32, 0x1b, 0x8e, 0xba, 0x7, 0x79, 0x76, 0xa8}; + uint8_t bytesprops0[] = {0x12, 0x1d, 0x1f, 0x57, 0x85, 0x12, 0x1e, 0x63, 0xd, 0x85, 0x6c, 0xaf, 0x98, + 0x92, 0x7f, 0x59, 0xdb, 0xbe, 0xd1, 0xd8, 0x9d, 0x7e, 0xf0, 0xcb, 0x72}; + uint8_t bytesprops2[] = {0x60, 0x72, 0xe5, 0x1d, 0x9f, 0xb, 0xf1, 0xb3, 0x65}; + uint8_t bytesprops3[] = {0x35, 0xcd, 0x61, 0x8f, 0x21, 0xd3, 0x5b, 0xd1, + 0x68, 0x7a, 0x5c, 0xf6, 0x9a, 0xdd, 0x6e, 0x5a}; + uint8_t bytesprops4[] = {0x8d, 0xe2, 0x76}; + uint8_t bytesprops6[] = {0xbd, 0xdd, 0x9d, 0x6a, 0x31, 0x5d, 0x1c, 0x74, 0xd9, 0xa8, 0x5a, 0x6f, 0xca, 0xe4, 0xad}; + uint8_t bytesprops5[] = {0x9e, 0x1a, 0x40, 0xb1, 0x89, 0x2a, 0xbe, 0xa0, 0x6a, 0xcb, 0xd, 0xa0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32766}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12471}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops1}, .v = {19, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27174}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops6}, .v = {8, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14655}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23466}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops0}, .v = {27, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4328}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18921}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12433}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2560}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3720}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3890}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10484}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 676}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops5}, .v = {15, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 67}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xf7, 0x4e, 0x3a, 0xe5, 0x48, 0x3e, 0xb4}; - uint8_t byteswillprops1[] = {0xde, 0x34, 0x50, 0xcd, 0xc2, 0x3c, 0xa6, 0xd9, 0x2a, 0x97, - 0xfa, 0x9a, 0xa0, 0x4a, 0xd4, 0xdc, 0x6c, 0x17, 0x63, 0x8e}; - uint8_t byteswillprops2[] = {0x1, 0x2e, 0x25, 0xb1, 0xbf, 0x45, 0x24, 0x49, 0xde, 0xf7, 0x6d, 0x93, 0xe6, 0xba, - 0x47, 0xda, 0x34, 0x54, 0xdb, 0x43, 0xdd, 0xf2, 0x30, 0x8, 0x58, 0xd9, 0x1b, 0x7b}; - uint8_t byteswillprops3[] = {0xc5, 0x2c, 0x15, 0x8c, 0x18, 0xc0, 0xb5, 0xe9, 0xf3, 0x33, 0x4, 0x46, - 0x73, 0xbe, 0xb9, 0xff, 0x98, 0xe8, 0x17, 0x11, 0x4d, 0x71, 0xa9, 0x7f}; - uint8_t byteswillprops4[] = {0xc, 0xef, 0x7d, 0x99, 0x54, 0x70, 0x60, 0x2b, 0x18, - 0x6e, 0xbb, 0xc5, 0x73, 0xf5, 0x18, 0xf6, 0x97}; - uint8_t byteswillprops6[] = {0x0, 0x59, 0xc9, 0x8f, 0xa8, 0x78, 0xd6, 0xc6, 0x8e, - 0x3f, 0xcb, 0x24, 0x9f, 0x89, 0xd2, 0x35, 0x29}; - uint8_t byteswillprops5[] = {0xa7, 0x2d, 0x34, 0xf4}; - uint8_t byteswillprops8[] = {0x76, 0xc6, 0x80, 0xd7, 0x31, 0x2d, 0x39, 0x5f, 0xa7, 0x38, - 0x81, 0x5c, 0xfa, 0xdc, 0x2, 0xd4, 0x3b, 0xd7, 0xe4, 0x64}; - uint8_t byteswillprops7[] = {0x73}; - uint8_t byteswillprops9[] = {0x42, 0x65, 0xab, 0x97, 0xee, 0xe8, 0xa7, 0x23, 0x59, 0x56, 0x85, 0x48, 0x63, - 0x4e, 0xc7, 0xbe, 0xea, 0x4a, 0xa6, 0xb0, 0xa7, 0x42, 0x2b, 0x59, 0xb, 0x3a}; - uint8_t byteswillprops10[] = {0x35, 0x9d, 0xe4, 0x63, 0x47, 0xe0, 0x98}; - uint8_t byteswillprops11[] = {0x53, 0x39, 0x4c, 0xb0, 0xdf, 0x4, 0x52, 0xf9, 0x2e, 0x27, 0x43, 0xbc, 0x7d}; - uint8_t byteswillprops12[] = {0xab, 0x7b, 0x13, 0xf0, 0xc2, 0x4c, 0xa7, 0xc7, 0xb4, 0x18, - 0x57, 0x16, 0xbb, 0x32, 0xad, 0x44, 0x2, 0x37, 0xbe, 0xf0, - 0x21, 0x43, 0x72, 0xcd, 0xbc, 0xb5, 0xc8, 0x5f, 0x2e, 0xe}; - uint8_t byteswillprops14[] = {0xe1, 0x90, 0x70, 0xa3, 0x63, 0x79, 0x86, 0xbb, 0x3e, 0x34, 0xbf, 0x20, 0x8f, - 0x1b, 0xd7, 0x5b, 0x23, 0xf6, 0xa6, 0x9a, 0x3, 0x78, 0x7c, 0x32, 0x39, 0x6c}; - uint8_t byteswillprops13[] = {0x78, 0x24, 0x51, 0x47, 0x15, 0xea, 0xf6, 0xf2, 0x32, 0x5d, 0xb3, 0x61, 0xeb, 0xd8}; + uint8_t byteswillprops0[] = {0x9d, 0x53, 0x90, 0xfd, 0x59, 0x7c, 0x3c, 0x81, 0x49, 0x2, 0x74, + 0xcc, 0xff, 0x8e, 0x59, 0xa6, 0x48, 0x3, 0xdb, 0x71, 0x6a, 0x3c}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25356}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {4, (char*)&byteswillprops5}, .v = {17, (char*)&byteswillprops6}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {1, (char*)&byteswillprops7}, .v = {20, (char*)&byteswillprops8}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31492}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13537}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29119}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops12}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {14, (char*)&byteswillprops13}, .v = {26, (char*)&byteswillprops14}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&byteswillprops0}}}, }; - lwmqtt_properties_t willprops = {23, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb2, 0xab, 0x12, 0xd3, 0xc8, 0x19, 0xb8, 0x1, 0xf, 0x31, 0xb6, - 0x8e, 0xec, 0xa5, 0xc9, 0xb4, 0xd9, 0xb3, 0xec, 0x79, 0xd7, 0xa}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb0, 0x13, 0x8e, 0x18, 0x35, 0xe5, 0x6a, 0x8c, 0xc2, 0xf1, 0x98}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x18, 0x66, 0x9f, 0x9b, 0x6d}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x9b, 0x29, 0x54, 0xce, 0xfa, 0xa3, 0x79, 0x2d, 0xd5, 0x5b, 0x5f, 0x7, 0x9f, + 0x1d, 0x3d, 0xc3, 0x4c, 0x9b, 0x4c, 0xa4, 0xdc, 0xf3, 0xe1, 0x29, 0xd0, 0x70}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 13826; - uint8_t client_id_bytes[] = {0x65, 0x59, 0x55, 0x6f, 0x45, 0x7f, 0x4d, 0xb4, 0x26, 0xe3, 0x84, - 0xb, 0x2, 0x1b, 0xc6, 0xb7, 0x3f, 0xf5, 0xf7, 0x6e, 0xc5, 0x11}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.keep_alive = 11529; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x53, 0x7a, 0x38, 0x69, 0x9b, 0xb9, 0xf7, 0x1c, 0x4d, 0xdf, 0xd, 0x60, 0x22, 0xbb, - 0x6, 0xf4, 0x17, 0x37, 0x28, 0xda, 0x5e, 0x3, 0x7e, 0xe7, 0x6f, 0x2b, 0xa6, 0x5c}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xaf, 0x27, 0x1f, 0x37, 0x3e, 0x4, 0x2d, 0x4b, 0xa0, 0x0, 0xe, 0x86, 0x54, 0x94, 0xe8, + 0xc2, 0x84, 0x62, 0xda, 0xf, 0x45, 0xf1, 0x4c, 0x9c, 0xcc, 0xa9, 0x91, 0x58, 0x33, 0xfa}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xfe}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7167,186 +7364,158 @@ TEST(Connect5QCTest, Encode6) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 28209, _connID = "\246\165\SI\142z\163\217\224;\170\DC1\145\161v\211e", _properties = [PropMaximumQoS -// 15,PropReasonString "|u*m\178\202|\twhl\196\202\241V\232\&9\157",PropReasonString -// "\152\163\&1#{\177{Bd<",PropAuthenticationMethod ">5\189\225\SO\175^\234s\EOT\183t\142\174\141*\161",PropMaximumQoS -// 133,PropMessageExpiryInterval 23894,PropRequestResponseInformation 67,PropReceiveMaximum 24058,PropContentType -// "\NAKYr\SYN",PropMaximumPacketSize 27205]} +// ConnectRequest {_username = Just ")\212\206\157>[\161\161\240\140\191\206", _password = Just +// "\175\183\193,\\>\244\ESCS\204\NULC\a\SOH\235\t\US\NAK\DC3", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS0, _willTopic = "8m\ETB\253\&5\"\149h\193\210!\DC2\192\173\163\v\157\214z\231?", _willMsg = +// "~\239s\199\207\DLE\137)\195w\DEL\200D\166\195y\230\ETX\179\187\224\188\198@\212\ESC", _willProps = +// [PropMessageExpiryInterval 4271,PropMessageExpiryInterval 6823,PropCorrelationData "(0\151\DC1\137 +// Jeg6\197\239E^\162\253i\211_\138i';d",PropRequestResponseInformation 145,PropAssignedClientIdentifier +// "6_\203\&0\142+4\178\193\178\b\221\233-\SUB|R\215\DC4\146c\183\ETB\148\210\209\191\DEL\f\236",PropReceiveMaximum +// 17759,PropTopicAliasMaximum 16206,PropMessageExpiryInterval 21818,PropPayloadFormatIndicator 130,PropCorrelationData +// "\211\161\189\133\232r\155:\133\238\239\201'\175*i\SUBl\SYN.r\172@\220\251\US",PropTopicAliasMaximum +// 29128,PropSubscriptionIdentifier 23,PropReasonString +// "\ESC?\213\147\182v\225\188\182\177\210\207,\ENQ|\247\185\229\197\255\165\253\135*Y\156\185\168\129\242",PropServerReference +// "w\207\&2\178\158G\153\226\SYNCVfh\198\176\252\EM",PropResponseInformation +// ">p~\254\186\236\237\231\SYN\161&\DLE\254S\163XW\143\175\&9\182\215\"",PropReasonString +// "9\132\250\181\230\208\254\&3\237\131\DELz{\217\183\156\n[",PropServerKeepAlive 14862,PropRequestResponseInformation +// 252,PropWillDelayInterval 26059,PropAssignedClientIdentifier "\157Z\vwb",PropMessageExpiryInterval +// 15429,PropAssignedClientIdentifier +// "\SO=\SO\165\159\255\DC1G\215\245A\223\163k=\181\164\242w\141t\251\166\&9",PropRequestProblemInformation +// 147,PropSessionExpiryInterval 29456,PropSessionExpiryInterval 11046]}), _cleanSession = True, _keepAlive = 1137, +// _connID = "H\161", _properties = [PropSubscriptionIdentifier 1,PropAssignedClientIdentifier +// "\224\225\217",PropSubscriptionIdentifier 8,PropSubscriptionIdentifierAvailable 172,PropRequestProblemInformation +// 231,PropMessageExpiryInterval 18221,PropReasonString "y\136\156\212K\150\176\201D",PropUserProperty +// "\145\250\EOT\NUL\171\165\ENQ\185r\138\142.\v\US\EOTNp\139\r\191O@\145\153]5r:e" "\152\NUL\161^q",PropUserProperty +// "XK$\161\247\t\DEL\191\ACK\137-\218\SUB\155rp\214\200\194\STX" +// "\153A{l\242%\185\202\164\220\205\210E\131\241\ACK+\\\235\165",PropSessionExpiryInterval 11196]} TEST(Connect5QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0x6d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x0, 0x6e, 0x31, 0x50, 0x24, 0xf, 0x1f, - 0x0, 0x12, 0x7c, 0x75, 0x2a, 0x6d, 0xb2, 0xca, 0x7c, 0x9, 0x77, 0x68, 0x6c, 0xc4, 0xca, 0xf1, - 0x56, 0xe8, 0x39, 0x9d, 0x1f, 0x0, 0xa, 0x98, 0xa3, 0x31, 0x23, 0x7b, 0xb1, 0x7b, 0x42, 0x64, - 0x3c, 0x15, 0x0, 0x11, 0x3e, 0x35, 0xbd, 0xe1, 0xe, 0xaf, 0x5e, 0xea, 0x73, 0x4, 0xb7, 0x74, - 0x8e, 0xae, 0x8d, 0x2a, 0xa1, 0x24, 0x85, 0x2, 0x0, 0x0, 0x5d, 0x56, 0x19, 0x43, 0x21, 0x5d, - 0xfa, 0x3, 0x0, 0x4, 0x15, 0x59, 0x72, 0x16, 0x27, 0x0, 0x0, 0x6a, 0x45, 0x0, 0x10, 0xf6, - 0xa5, 0xf, 0x8e, 0x7a, 0xa3, 0xd9, 0xe0, 0x3b, 0xaa, 0x11, 0x91, 0xa1, 0x76, 0xd3, 0x65}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7c, 0x75, 0x2a, 0x6d, 0xb2, 0xca, 0x7c, 0x9, 0x77, - 0x68, 0x6c, 0xc4, 0xca, 0xf1, 0x56, 0xe8, 0x39, 0x9d}; - uint8_t bytesprops1[] = {0x98, 0xa3, 0x31, 0x23, 0x7b, 0xb1, 0x7b, 0x42, 0x64, 0x3c}; - uint8_t bytesprops2[] = {0x3e, 0x35, 0xbd, 0xe1, 0xe, 0xaf, 0x5e, 0xea, 0x73, - 0x4, 0xb7, 0x74, 0x8e, 0xae, 0x8d, 0x2a, 0xa1}; - uint8_t bytesprops3[] = {0x15, 0x59, 0x72, 0x16}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23894}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24058}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27205}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 28209; - uint8_t client_id_bytes[] = {0xf6, 0xa5, 0xf, 0x8e, 0x7a, 0xa3, 0xd9, 0xe0, - 0x3b, 0xaa, 0x11, 0x91, 0xa1, 0x76, 0xd3, 0x65}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\EOTj\208\234\&8&{\198\226R\a\248\140\138", _password = Just -// "]TT\227$0q<\DLE\201/\223\204\&4.\225\146v\209\240\154\SI\189O,\183\237", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS2, _willTopic = "\145\172\175\249\r\146", _willMsg = "\227:\v\SYNN\201\f", _willProps = -// [PropResponseTopic "X\152 <\n\135^\171\171;\nE",PropSessionExpiryInterval 22075,PropMessageExpiryInterval -// 4010,PropReceiveMaximum 25879,PropResponseTopic -// "n\239<\215q\137\138F\DC3\226z\194\CAN\230s]\198D\214",PropMessageExpiryInterval 10253,PropMaximumPacketSize -// 10461,PropAuthenticationMethod "\250|)\251Ae~\130/N\151\147\173",PropMessageExpiryInterval 20087,PropServerReference -// "\163\GSc\212\254\149\180Q\235I/\135`\143'\185\&7\233reH\252D\139\&5\203_\SYN",PropResponseInformation -// "v\DC4\STX\232\190\222\186O2",PropPayloadFormatIndicator 208,PropWildcardSubscriptionAvailable -// 125,PropSharedSubscriptionAvailable 127,PropUserProperty "N<\EM\170\156\227:\192\176" -// "u\157\229\222\SUB\255\DLE\174+|\182\228\226\143\248\250\156\240"]}), _cleanSession = False, _keepAlive = 12527, -// _connID = "7\EOT\224", _properties = [PropUserProperty "4\235z\197V\183\140{\249\DLE" "a\132\191R\144",PropTopicAlias -// 12939,PropRequestProblemInformation 86,PropWillDelayInterval 20660,PropSubscriptionIdentifierAvailable -// 84,PropRequestProblemInformation 66,PropReasonString -// "\210\225\186\225\241\GS\134\249\141F\239\DC3\246\&1",PropSubscriptionIdentifier 18,PropContentType -// "`\136\253\244\253\208\150\212\162vz}\177\&0#\132",PropPayloadFormatIndicator 80,PropRequestProblemInformation -// 43,PropCorrelationData "\193\177\210\217",PropWildcardSubscriptionAvailable 172,PropCorrelationData -// "5\f",PropWildcardSubscriptionAvailable 127,PropRequestProblemInformation 224,PropPayloadFormatIndicator -// 232,PropReasonString "\189x:\ETX>\176\239\SOa\167V\STX\147\SOH)\139",PropSharedSubscriptionAvailable 157]} -TEST(Connect5QCTest, Encode8) { uint8_t pkt[] = { - 0x10, 0xe7, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x30, 0xef, 0x75, 0x26, 0x0, 0xa, 0x34, 0xeb, - 0x7a, 0xc5, 0x56, 0xb7, 0x8c, 0x7b, 0xf9, 0x10, 0x0, 0x5, 0x61, 0x84, 0xbf, 0x52, 0x90, 0x23, 0x32, 0x8b, 0x17, - 0x56, 0x18, 0x0, 0x0, 0x50, 0xb4, 0x29, 0x54, 0x17, 0x42, 0x1f, 0x0, 0xe, 0xd2, 0xe1, 0xba, 0xe1, 0xf1, 0x1d, - 0x86, 0xf9, 0x8d, 0x46, 0xef, 0x13, 0xf6, 0x31, 0xb, 0x12, 0x3, 0x0, 0x10, 0x60, 0x88, 0xfd, 0xf4, 0xfd, 0xd0, - 0x96, 0xd4, 0xa2, 0x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x26, 0x0, 0x9, 0x4e, 0x3c, 0x19, 0xaa, 0x9c, 0xe3, 0x3a, 0xc0, 0xb0, 0x0, 0x12, 0x75, 0x9d, 0xe5, - 0xde, 0x1a, 0xff, 0x10, 0xae, 0x2b, 0x7c, 0xb6, 0xe4, 0xe2, 0x8f, 0xf8, 0xfa, 0x9c, 0xf0, 0x0, 0x6, 0x91, 0xac, - 0xaf, 0xf9, 0xd, 0x92, 0x0, 0x7, 0xe3, 0x3a, 0xb, 0x16, 0x4e, 0xc9, 0xc, 0x0, 0xe, 0x4, 0x6a, 0xd0, 0xea, - 0x38, 0x26, 0x7b, 0xc6, 0xe2, 0x52, 0x7, 0xf8, 0x8c, 0x8a, 0x0, 0x1b, 0x5d, 0x54, 0x54, 0xe3, 0x24, 0x30, 0x71, - 0x3c, 0x10, 0xc9, 0x2f, 0xdf, 0xcc, 0x34, 0x2e, 0xe1, 0x92, 0x76, 0xd1, 0xf0, 0x9a, 0xf, 0xbd, 0x4f, 0x2c, 0xb7, - 0xed}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x61, 0x84, 0xbf, 0x52, 0x90}; - uint8_t bytesprops0[] = {0x34, 0xeb, 0x7a, 0xc5, 0x56, 0xb7, 0x8c, 0x7b, 0xf9, 0x10}; - uint8_t bytesprops2[] = {0xd2, 0xe1, 0xba, 0xe1, 0xf1, 0x1d, 0x86, 0xf9, 0x8d, 0x46, 0xef, 0x13, 0xf6, 0x31}; - uint8_t bytesprops3[] = {0x60, 0x88, 0xfd, 0xf4, 0xfd, 0xd0, 0x96, 0xd4, - 0xa2, 0x76, 0x7a, 0x7d, 0xb1, 0x30, 0x23, 0x84}; - uint8_t bytesprops4[] = {0xc1, 0xb1, 0xd2, 0xd9}; - uint8_t bytesprops5[] = {0x35, 0xc}; - uint8_t bytesprops6[] = {0xbd, 0x78, 0x3a, 0x3, 0x3e, 0xb0, 0xef, 0xe, 0x61, 0xa7, 0x56, 0x2, 0x93, 0x1,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0x12, 0x0, 0x5, 0x9d, 0x5a, 0xb, 0x77, 0x62, 0x2, 0x0, 0x0, + 0x3c, 0x45, 0x12, 0x0, 0x18, 0xe, 0x3d, 0xe, 0xa5, 0x9f, 0xff, 0x11, 0x47, 0xd7, 0xf5, 0x41, 0xdf, 0xa3, 0x6b, + 0x3d, 0xb5, 0xa4, 0xf2, 0x77, 0x8d, 0x74, 0xfb, 0xa6, 0x39, 0x17, 0x93, 0x11, 0x0, 0x0, 0x73, 0x10, 0x11, 0x0, + 0x0, 0x2b, 0x26, 0x0, 0x15, 0x38, 0x6d, 0x17, 0xfd, 0x35, 0x22, 0x95, 0x68, 0xc1, 0xd2, 0x21, 0x12, 0xc0, 0xad, + 0xa3, 0xb, 0x9d, 0xd6, 0x7a, 0xe7, 0x3f, 0x0, 0x1a, 0x7e, 0xef, 0x73, 0xc7, 0xcf, 0x10, 0x89, 0x29, 0xc3, 0x77, + 0x7f, 0xc8, 0x44, 0xa6, 0xc3, 0x79, 0xe6, 0x3, 0xb3, 0xbb, 0xe0, 0xbc, 0xc6, 0x40, 0xd4, 0x1b, 0x0, 0xc, 0x29, + 0xd4, 0xce, 0x9d, 0x3e, 0x5b, 0xa1, 0xa1, 0xf0, 0x8c, 0xbf, 0xce, 0x0, 0x13, 0xaf, 0xb7, 0xc1, 0x2c, 0x5c, 0x3e, + 0xf4, 0x1b, 0x53, 0xcc, 0x0, 0x43, 0x7, 0x1, 0xeb, 0x9, 0x1f, 0x15, 0x13}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe0, 0xe1, 0xd9}; + uint8_t bytesprops1[] = {0x79, 0x88, 0x9c, 0xd4, 0x4b, 0x96, 0xb0, 0xc9, 0x44}; + uint8_t bytesprops3[] = {0x98, 0x0, 0xa1, 0x5e, 0x71}; + uint8_t bytesprops2[] = {0x91, 0xfa, 0x4, 0x0, 0xab, 0xa5, 0x5, 0xb9, 0x72, 0x8a, 0x8e, 0x2e, 0xb, 0x1f, 0x4, + 0x4e, 0x70, 0x8b, 0xd, 0xbf, 0x4f, 0x40, 0x91, 0x99, 0x5d, 0x35, 0x72, 0x3a, 0x65}; + uint8_t bytesprops5[] = {0x99, 0x41, 0x7b, 0x6c, 0xf2, 0x25, 0xb9, 0xca, 0xa4, 0xdc, + 0xcd, 0xd2, 0x45, 0x83, 0xf1, 0x6, 0x2b, 0x5c, 0xeb, 0xa5}; + uint8_t bytesprops4[] = {0x58, 0x4b, 0x24, 0xa1, 0xf7, 0x9, 0x7f, 0xbf, 0x6, 0x89, + 0x2d, 0xda, 0x1a, 0x9b, 0x72, 0x70, 0xd6, 0xc8, 0xc2, 0x2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {5, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12939}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20660}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18221}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops2}, .v = {5, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops4}, .v = {20, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11196}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x58, 0x98, 0x20, 0x3c, 0xa, 0x87, 0x5e, 0xab, 0xab, 0x3b, 0xa, 0x45}; - uint8_t byteswillprops1[] = {0x6e, 0xef, 0x3c, 0xd7, 0x71, 0x89, 0x8a, 0x46, 0x13, 0xe2, - 0x7a, 0xc2, 0x18, 0xe6, 0x73, 0x5d, 0xc6, 0x44, 0xd6}; - uint8_t byteswillprops2[] = {0xfa, 0x7c, 0x29, 0xfb, 0x41, 0x65, 0x7e, 0x82, 0x2f, 0x4e, 0x97, 0x93, 0xad}; - uint8_t byteswillprops3[] = {0xa3, 0x1d, 0x63, 0xd4, 0xfe, 0x95, 0xb4, 0x51, 0xeb, 0x49, 0x2f, 0x87, 0x60, 0x8f, - 0x27, 0xb9, 0x37, 0xe9, 0x72, 0x65, 0x48, 0xfc, 0x44, 0x8b, 0x35, 0xcb, 0x5f, 0x16}; - uint8_t byteswillprops4[] = {0x76, 0x14, 0x2, 0xe8, 0xbe, 0xde, 0xba, 0x4f, 0x32}; - uint8_t byteswillprops6[] = {0x75, 0x9d, 0xe5, 0xde, 0x1a, 0xff, 0x10, 0xae, 0x2b, - 0x7c, 0xb6, 0xe4, 0xe2, 0x8f, 0xf8, 0xfa, 0x9c, 0xf0}; - uint8_t byteswillprops5[] = {0x4e, 0x3c, 0x19, 0xaa, 0x9c, 0xe3, 0x3a, 0xc0, 0xb0}; + uint8_t byteswillprops0[] = {0x28, 0x30, 0x97, 0x11, 0x89, 0x20, 0x4a, 0x65, 0x67, 0x36, 0xc5, 0xef, + 0x45, 0x5e, 0xa2, 0xfd, 0x69, 0xd3, 0x5f, 0x8a, 0x69, 0x27, 0x3b, 0x64}; + uint8_t byteswillprops1[] = {0x36, 0x5f, 0xcb, 0x30, 0x8e, 0x2b, 0x34, 0xb2, 0xc1, 0xb2, + 0x8, 0xdd, 0xe9, 0x2d, 0x1a, 0x7c, 0x52, 0xd7, 0x14, 0x92, + 0x63, 0xb7, 0x17, 0x94, 0xd2, 0xd1, 0xbf, 0x7f, 0xc, 0xec}; + uint8_t byteswillprops2[] = {0xd3, 0xa1, 0xbd, 0x85, 0xe8, 0x72, 0x9b, 0x3a, 0x85, 0xee, 0xef, 0xc9, 0x27, + 0xaf, 0x2a, 0x69, 0x1a, 0x6c, 0x16, 0x2e, 0x72, 0xac, 0x40, 0xdc, 0xfb, 0x1f}; + uint8_t byteswillprops3[] = {0x1b, 0x3f, 0xd5, 0x93, 0xb6, 0x76, 0xe1, 0xbc, 0xb6, 0xb1, + 0xd2, 0xcf, 0x2c, 0x5, 0x7c, 0xf7, 0xb9, 0xe5, 0xc5, 0xff, + 0xa5, 0xfd, 0x87, 0x2a, 0x59, 0x9c, 0xb9, 0xa8, 0x81, 0xf2}; + uint8_t byteswillprops4[] = {0x77, 0xcf, 0x32, 0xb2, 0x9e, 0x47, 0x99, 0xe2, 0x16, + 0x43, 0x56, 0x66, 0x68, 0xc6, 0xb0, 0xfc, 0x19}; + uint8_t byteswillprops5[] = {0x3e, 0x70, 0x7e, 0xfe, 0xba, 0xec, 0xed, 0xe7, 0x16, 0xa1, 0x26, 0x10, + 0xfe, 0x53, 0xa3, 0x58, 0x57, 0x8f, 0xaf, 0x39, 0xb6, 0xd7, 0x22}; + uint8_t byteswillprops6[] = {0x39, 0x84, 0xfa, 0xb5, 0xe6, 0xd0, 0xfe, 0x33, 0xed, + 0x83, 0x7f, 0x7a, 0x7b, 0xd9, 0xb7, 0x9c, 0xa, 0x5b}; + uint8_t byteswillprops7[] = {0x9d, 0x5a, 0xb, 0x77, 0x62}; + uint8_t byteswillprops8[] = {0xe, 0x3d, 0xe, 0xa5, 0x9f, 0xff, 0x11, 0x47, 0xd7, 0xf5, 0x41, 0xdf, + 0xa3, 0x6b, 0x3d, 0xb5, 0xa4, 0xf2, 0x77, 0x8d, 0x74, 0xfb, 0xa6, 0x39}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22075}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4010}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25879}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10253}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10461}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20087}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {9, (char*)&byteswillprops5}, .v = {18, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4271}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6823}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17759}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16206}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21818}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29128}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14862}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26059}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15429}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29456}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11046}}, }; - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x91, 0xac, 0xaf, 0xf9, 0xd, 0x92}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe3, 0x3a, 0xb, 0x16, 0x4e, 0xc9, 0xc}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x38, 0x6d, 0x17, 0xfd, 0x35, 0x22, 0x95, 0x68, 0xc1, 0xd2, 0x21, + 0x12, 0xc0, 0xad, 0xa3, 0xb, 0x9d, 0xd6, 0x7a, 0xe7, 0x3f}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7e, 0xef, 0x73, 0xc7, 0xcf, 0x10, 0x89, 0x29, 0xc3, 0x77, 0x7f, 0xc8, 0x44, + 0xa6, 0xc3, 0x79, 0xe6, 0x3, 0xb3, 0xbb, 0xe0, 0xbc, 0xc6, 0x40, 0xd4, 0x1b}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12527; - uint8_t client_id_bytes[] = {0x37, 0x4, 0xe0}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 1137; + uint8_t client_id_bytes[] = {0x48, 0xa1}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x4, 0x6a, 0xd0, 0xea, 0x38, 0x26, 0x7b, 0xc6, 0xe2, 0x52, 0x7, 0xf8, 0x8c, 0x8a}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x29, 0xd4, 0xce, 0x9d, 0x3e, 0x5b, 0xa1, 0xa1, 0xf0, 0x8c, 0xbf, 0xce}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x5d, 0x54, 0x54, 0xe3, 0x24, 0x30, 0x71, 0x3c, 0x10, 0xc9, 0x2f, 0xdf, 0xcc, 0x34, - 0x2e, 0xe1, 0x92, 0x76, 0xd1, 0xf0, 0x9a, 0xf, 0xbd, 0x4f, 0x2c, 0xb7, 0xed}; - lwmqtt_string_t password = {27, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xaf, 0xb7, 0xc1, 0x2c, 0x5c, 0x3e, 0xf4, 0x1b, 0x53, 0xcc, + 0x0, 0x43, 0x7, 0x1, 0xeb, 0x9, 0x1f, 0x15, 0x13}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7356,131 +7525,174 @@ TEST(Connect5QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\205!\164q;\149|\140\239|\234\FS\EOT", _password = Just -// "BE\v*U\EM'\159\157\SYNm\DLEn\192\136\vS\"\244\NUL9\228'\195\139\EOT\197\200\194", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "H", _willMsg = -// "\225\198\150\163\208W\238\146\FS\223_\201\251%\143\NUL\243\162\225ll\147\157Z\237\208\211W)", _willProps = -// [PropPayloadFormatIndicator 75,PropMessageExpiryInterval 10264,PropSessionExpiryInterval 20012,PropAuthenticationData -// "\198yy\237\252\180;\255%\236Q@\162\220\137",PropUserProperty "M%\161\219\DLES-\187\159\253Ek{\171d" -// "\178^R\250s\208M\207p\181",PropCorrelationData -// "2\143@\230Bz\186Bq\ACK\217\DC3\204\209\170p\f<\231]\212\249P\132\203\221\209Y",PropReceiveMaximum -// 24923,PropPayloadFormatIndicator 212,PropSubscriptionIdentifier 2,PropRequestProblemInformation 125,PropContentType -// "\DC4B\191\182\244\"",PropResponseInformation "O\166A\166@F\148\188@\136\228\160",PropSessionExpiryInterval -// 26416,PropMaximumQoS 146,PropCorrelationData "KJ\254\&6",PropMaximumQoS 108]}), _cleanSession = True, _keepAlive = -// 13897, _connID = "\233\129 ", _properties = [PropTopicAlias 21218,PropSessionExpiryInterval -// 25892,PropMessageExpiryInterval 14193,PropReceiveMaximum 4778,PropReceiveMaximum 20584,PropMaximumQoS -// 170,PropAuthenticationMethod "\165\183i\DLE\189\185\ETB\226\194\194W\191\ESC\184",PropContentType -// "\221Z]bNW\SO\179\US\189\&6\237%\240,%\169(\165\GSo\185\158\DELF\162\245\128",PropSessionExpiryInterval -// 12083,PropCorrelationData "\144Q\129C\194\SOH\146_\203v\ACK",PropMessageExpiryInterval 8095,PropServerReference -// ">\GS\206-\200\149\133\153\FS7|\213'W\229\v\150\242\&5\213L\231\179^\210\197\174",PropSharedSubscriptionAvailable -// 250,PropServerKeepAlive 22603,PropReasonString "\137\239\148D\243\130A\216",PropTopicAliasMaximum -// 17570,PropServerReference "A\243\199\228\241V",PropRetainAvailable 27,PropSubscriptionIdentifier -// 7,PropSubscriptionIdentifierAvailable 144,PropReceiveMaximum 22199,PropWillDelayInterval 25924,PropServerKeepAlive -// 20466,PropServerKeepAlive 19738,PropMessageExpiryInterval 23378,PropWildcardSubscriptionAvailable 159]} -TEST(Connect5QCTest, Encode9) { +// ConnectRequest {_username = Just "\144", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS2, _willTopic = "\ACKb<[2\a\182/h\252g\145S\156\179?6\NAK\232/\SO\241\213P\bk", _willMsg = +// "\EM\140\168c\240\ESC]:\250l\160>CT\DC4\ETB\209\DC2", _willProps = [PropReasonString +// "\167H\170W\158\144\163\232\187\DC1",PropReceiveMaximum 24898,PropTopicAliasMaximum 14664,PropAuthenticationData +// "\156U2",PropPayloadFormatIndicator 193,PropRetainAvailable 135,PropAuthenticationMethod +// "}\215\208\160n9\164\213\191h\143\165Bp\145D\SOH\208\217\200W7\DEL5X\236",PropAuthenticationMethod +// "\128\CANSS\201\197",PropServerReference +// "\233M\ESC\142\137:\r\190\144\SUB\230\173\EOT\173\227\211l\USv\\\162\169\252\192\t\208",PropRequestProblemInformation +// 186,PropSessionExpiryInterval 25634,PropReceiveMaximum 28271,PropMaximumQoS 167,PropRequestProblemInformation +// 243,PropWildcardSubscriptionAvailable 11,PropReasonString "x0'D\ACK\SO\248l$\130I_\144",PropAuthenticationData +// "h\154B2\234\SOHOW\254",PropResponseTopic "8\185 ~\138\240\192<",PropRequestResponseInformation +// 34,PropAuthenticationMethod "tv\233J",PropServerReference +// "~\170&\236\138{\ENQSr_\174+",PropSharedSubscriptionAvailable 77,PropServerReference +// "\253\152\149r\201;M\188\r\215c\248\SYNS\195\234j\228\202\142\251\211\230",PropAssignedClientIdentifier +// "\244Q\159\RS",PropPayloadFormatIndicator 83]}), _cleanSession = False, _keepAlive = 1187, _connID = +// "\162\135\139O\243\166\t(\204\167\213e\215\220d\185\n\149\233\144\b\218\229\235,", _properties = +// [PropAuthenticationMethod "H\207\251Jy\208P\176.",PropMaximumPacketSize 23348,PropAuthenticationData +// "\221\DC2\SOH\184\ACKY\232@\183\&0\DLE\187\NUL=\174\223\175\228\223-\137-+\131\\\246\180t\192\n",PropTopicAliasMaximum +// 14884,PropServerReference +// "g\143\174S\166\139\SO>\131\160.\141O\199\168\SO\US=m\EOT\200\149\158\174\&9y\143\182",PropTopicAlias +// 13879,PropAuthenticationMethod "\229\227\252\174\233\&40\227\190\225q\CAN",PropTopicAliasMaximum +// 27692,PropServerReference "\f#\160",PropTopicAlias 17970,PropAuthenticationData "r\246\196,?g",PropReasonString +// "\214C\f",PropMessageExpiryInterval 5452,PropAssignedClientIdentifier "\224\231\214=\SYNSJ",PropWillDelayInterval +// 17062,PropSubscriptionIdentifierAvailable 81,PropTopicAlias 30262,PropUserProperty "\176\244\188\242" +// "&\168W\EOT=X\160\t\145OZ\DLE\174\246\185\128\NUL\219]\139\196s\RS\182",PropRequestProblemInformation +// 158,PropPayloadFormatIndicator 158,PropContentType "\235\187\129F\198",PropAuthenticationData +// "8\DC39A\191\202\&6Q\216\229C\136_\244\166\220\194\186w\DC4J\t",PropMaximumQoS 87,PropMaximumPacketSize +// 25405,PropMaximumQoS 210,PropAuthenticationMethod "\180i\239\ENQ",PropRequestResponseInformation +// 90,PropAuthenticationMethod "e\n[\187Nh\143l;\ESC\223>'\133\ACKw1Nc\218\171",PropReceiveMaximum 24426]} +TEST(Connect5QCTest, Encode8) { uint8_t pkt[] = { - 0x10, 0xa1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x36, 0x49, 0xb2, 0x1, 0x23, 0x52, 0xe2, 0x11, - 0x0, 0x0, 0x65, 0x24, 0x2, 0x0, 0x0, 0x37, 0x71, 0x21, 0x12, 0xaa, 0x21, 0x50, 0x68, 0x24, 0xaa, 0x15, 0x0, - 0xe, 0xa5, 0xb7, 0x69, 0x10, 0xbd, 0xb9, 0x17, 0xe2, 0xc2, 0xc2, 0x57, 0xbf, 0x1b, 0xb8, 0x3, 0x0, 0x1c, 0xdd, - 0x5a, 0x5d, 0x62, 0x4e, 0x57, 0xe, 0xb3, 0x1f, 0xbd, 0x36, 0xed, 0x25, 0xf0, 0x2c, 0x25, 0xa9, 0x28, 0xa5, 0x1d, - 0x6f, 0xb9, 0x9e, 0x7f, 0x46, 0xa2, 0xf5, 0x80, 0x11, 0x0, 0x0, 0x2f, 0x33, 0x9, 0x0, 0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70, 0xc, 0x3c, 0xe7, 0x5d, 0xd4, 0xf9, - 0x50, 0x84, 0xcb, 0xdd, 0xd1, 0x59, 0x21, 0x61, 0x5b, 0x1, 0xd4, 0xb, 0x2, 0x17, 0x7d, 0x3, 0x0, 0x6, 0x14, - 0x42, 0xbf, 0xb6, 0xf4, 0x22, 0x1a, 0x0, 0xc, 0x4f, 0xa6, 0x41, 0xa6, 0x40, 0x46, 0x94, 0xbc, 0x40, 0x88, 0xe4, - 0xa0, 0x11, 0x0, 0x0, 0x67, 0x30, 0x24, 0x92, 0x9, 0x0, 0x4, 0x4b, 0x4a, 0xfe, 0x36, 0x24, 0x6c, 0x0, 0x1, - 0x48, 0x0, 0x1d, 0xe1, 0xc6, 0x96, 0xa3, 0xd0, 0x57, 0xee, 0x92, 0x1c, 0xdf, 0x5f, 0xc9, 0xfb, 0x25, 0x8f, 0x0, - 0xf3, 0xa2, 0xe1, 0x6c, 0x6c, 0x93, 0x9d, 0x5a, 0xed, 0xd0, 0xd3, 0x57, 0x29, 0x0, 0xd, 0xcd, 0x21, 0xa4, 0x71, - 0x3b, 0x95, 0x7c, 0x8c, 0xef, 0x7c, 0xea, 0x1c, 0x4, 0x0, 0x1d, 0x42, 0x45, 0xb, 0x2a, 0x55, 0x19, 0x27, 0x9f, - 0x9d, 0x16, 0x6d, 0x10, 0x6e, 0xc0, 0x88, 0xb, 0x53, 0x22, 0xf4, 0x0, 0x39, 0xe4, 0x27, 0xc3, 0x8b, 0x4, 0xc5, - 0xc8, 0xc2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xa5, 0xb7, 0x69, 0x10, 0xbd, 0xb9, 0x17, 0xe2, 0xc2, 0xc2, 0x57, 0xbf, 0x1b, 0xb8}; - uint8_t bytesprops1[] = {0xdd, 0x5a, 0x5d, 0x62, 0x4e, 0x57, 0xe, 0xb3, 0x1f, 0xbd, 0x36, 0xed, 0x25, 0xf0, - 0x2c, 0x25, 0xa9, 0x28, 0xa5, 0x1d, 0x6f, 0xb9, 0x9e, 0x7f, 0x46, 0xa2, 0xf5, 0x80}; - uint8_t bytesprops2[] = {0x90, 0x51, 0x81, 0x43, 0xc2, 0x1, 0x92, 0x5f, 0xcb, 0x76, 0x6}; - uint8_t bytesprops3[] = {0x3e, 0x1d, 0xce, 0x2d, 0xc8, 0x95, 0x85, 0x99, 0x1c, 0x37, 0x7c, 0xd5, 0x27, 0x57, - 0xe5, 0xb, 0x96, 0xf2, 0x35, 0xd5, 0x4c, 0xe7, 0xb3, 0x5e, 0xd2, 0xc5, 0xae}; - uint8_t bytesprops4[] = {0x89, 0xef, 0x94, 0x44, 0xf3, 0x82, 0x41, 0xd8}; - uint8_t bytesprops5[] = {0x41, 0xf3, 0xc7, 0xe4, 0xf1, 0x56}; + 0x10, 0xbd, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x94, 0x4, 0xa3, 0x8d, 0x2, 0x15, 0x0, 0x9, 0x48, + 0xcf, 0xfb, 0x4a, 0x79, 0xd0, 0x50, 0xb0, 0x2e, 0x27, 0x0, 0x0, 0x5b, 0x34, 0x16, 0x0, 0x1e, 0xdd, 0x12, 0x1, + 0xb8, 0x6, 0x59, 0xe8, 0x40, 0xb7, 0x30, 0x10, 0xbb, 0x0, 0x3d, 0xae, 0xdf, 0xaf, 0xe4, 0xdf, 0x2d, 0x89, 0x2d, + 0x2b, 0x83, 0x5c, 0xf6, 0xb4, 0x74, 0xc0, 0xa, 0x22, 0x3a, 0x24, 0x1c, 0x0, 0x1c, 0x67, 0x8f, 0xae, 0x53, 0xa6, + 0x8b, 0xe, 0x3e, 0x83, 0xa0, 0x2e, 0x8d, 0x4f, 0xc7, 0xa8, 0xe, 0x1f, 0x3d, 0x6d, 0x4, 0xc8, 0x95, 0x9e, 0xae, + 0x39, 0x79, 0x8f, 0xb6, 0x23, 0x36, 0x37, 0x15, 0x0, 0xc, 0xe5, 0xe3, 0xfc, 0xae, 0xe9, 0x34, 0x30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ae, 0x2b, 0x2a, 0x4d, 0x1c, 0x0, 0x17, 0xfd, + 0x98, 0x95, 0x72, 0xc9, 0x3b, 0x4d, 0xbc, 0xd, 0xd7, 0x63, 0xf8, 0x16, 0x53, 0xc3, 0xea, 0x6a, 0xe4, 0xca, 0x8e, + 0xfb, 0xd3, 0xe6, 0x12, 0x0, 0x4, 0xf4, 0x51, 0x9f, 0x1e, 0x1, 0x53, 0x0, 0x1a, 0x6, 0x62, 0x3c, 0x5b, 0x32, + 0x7, 0xb6, 0x2f, 0x68, 0xfc, 0x67, 0x91, 0x53, 0x9c, 0xb3, 0x3f, 0x36, 0x15, 0xe8, 0x2f, 0xe, 0xf1, 0xd5, 0x50, + 0x8, 0x6b, 0x0, 0x12, 0x19, 0x8c, 0xa8, 0x63, 0xf0, 0x1b, 0x5d, 0x3a, 0xfa, 0x6c, 0xa0, 0x3e, 0x43, 0x54, 0x14, + 0x17, 0xd1, 0x12, 0x0, 0x1, 0x90}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x48, 0xcf, 0xfb, 0x4a, 0x79, 0xd0, 0x50, 0xb0, 0x2e}; + uint8_t bytesprops1[] = {0xdd, 0x12, 0x1, 0xb8, 0x6, 0x59, 0xe8, 0x40, 0xb7, 0x30, 0x10, 0xbb, 0x0, 0x3d, 0xae, + 0xdf, 0xaf, 0xe4, 0xdf, 0x2d, 0x89, 0x2d, 0x2b, 0x83, 0x5c, 0xf6, 0xb4, 0x74, 0xc0, 0xa}; + uint8_t bytesprops2[] = {0x67, 0x8f, 0xae, 0x53, 0xa6, 0x8b, 0xe, 0x3e, 0x83, 0xa0, 0x2e, 0x8d, 0x4f, 0xc7, + 0xa8, 0xe, 0x1f, 0x3d, 0x6d, 0x4, 0xc8, 0x95, 0x9e, 0xae, 0x39, 0x79, 0x8f, 0xb6}; + uint8_t bytesprops3[] = {0xe5, 0xe3, 0xfc, 0xae, 0xe9, 0x34, 0x30, 0xe3, 0xbe, 0xe1, 0x71, 0x18}; + uint8_t bytesprops4[] = {0xc, 0x23, 0xa0}; + uint8_t bytesprops5[] = {0x72, 0xf6, 0xc4, 0x2c, 0x3f, 0x67}; + uint8_t bytesprops6[] = {0xd6, 0x43, 0xc}; + uint8_t bytesprops7[] = {0xe0, 0xe7, 0xd6, 0x3d, 0x16, 0x53, 0x4a}; + uint8_t bytesprops9[] = {0x26, 0xa8, 0x57, 0x4, 0x3d, 0x58, 0xa0, 0x9, 0x91, 0x4f, 0x5a, 0x10, + 0xae, 0xf6, 0xb9, 0x80, 0x0, 0xdb, 0x5d, 0x8b, 0xc4, 0x73, 0x1e, 0xb6}; + uint8_t bytesprops8[] = {0xb0, 0xf4, 0xbc, 0xf2}; + uint8_t bytesprops10[] = {0xeb, 0xbb, 0x81, 0x46, 0xc6}; + uint8_t bytesprops11[] = {0x38, 0x13, 0x39, 0x41, 0xbf, 0xca, 0x36, 0x51, 0xd8, 0xe5, 0x43, + 0x88, 0x5f, 0xf4, 0xa6, 0xdc, 0xc2, 0xba, 0x77, 0x14, 0x4a, 0x9}; + uint8_t bytesprops12[] = {0xb4, 0x69, 0xef, 0x5}; + uint8_t bytesprops13[] = {0x65, 0xa, 0x5b, 0xbb, 0x4e, 0x68, 0x8f, 0x6c, 0x3b, 0x1b, 0xdf, + 0x3e, 0x27, 0x85, 0x6, 0x77, 0x31, 0x4e, 0x63, 0xda, 0xab}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21218}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25892}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14193}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4778}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20584}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12083}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8095}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22603}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17570}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22199}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25924}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20466}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19738}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23378}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23348}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14884}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13879}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27692}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17970}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5452}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17062}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30262}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops8}, .v = {24, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25405}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24426}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc6, 0x79, 0x79, 0xed, 0xfc, 0xb4, 0x3b, 0xff, - 0x25, 0xec, 0x51, 0x40, 0xa2, 0xdc, 0x89}; - uint8_t byteswillprops2[] = {0xb2, 0x5e, 0x52, 0xfa, 0x73, 0xd0, 0x4d, 0xcf, 0x70, 0xb5}; - uint8_t byteswillprops1[] = {0x4d, 0x25, 0xa1, 0xdb, 0x10, 0x53, 0x2d, 0xbb, - 0x9f, 0xfd, 0x45, 0x6b, 0x7b, 0xab, 0x64}; - uint8_t byteswillprops3[] = {0x32, 0x8f, 0x40, 0xe6, 0x42, 0x7a, 0xba, 0x42, 0x71, 0x6, 0xd9, 0x13, 0xcc, 0xd1, - 0xaa, 0x70, 0xc, 0x3c, 0xe7, 0x5d, 0xd4, 0xf9, 0x50, 0x84, 0xcb, 0xdd, 0xd1, 0x59}; - uint8_t byteswillprops4[] = {0x14, 0x42, 0xbf, 0xb6, 0xf4, 0x22}; - uint8_t byteswillprops5[] = {0x4f, 0xa6, 0x41, 0xa6, 0x40, 0x46, 0x94, 0xbc, 0x40, 0x88, 0xe4, 0xa0}; - uint8_t byteswillprops6[] = {0x4b, 0x4a, 0xfe, 0x36}; + uint8_t byteswillprops0[] = {0xa7, 0x48, 0xaa, 0x57, 0x9e, 0x90, 0xa3, 0xe8, 0xbb, 0x11}; + uint8_t byteswillprops1[] = {0x9c, 0x55, 0x32}; + uint8_t byteswillprops2[] = {0x7d, 0xd7, 0xd0, 0xa0, 0x6e, 0x39, 0xa4, 0xd5, 0xbf, 0x68, 0x8f, 0xa5, 0x42, + 0x70, 0x91, 0x44, 0x1, 0xd0, 0xd9, 0xc8, 0x57, 0x37, 0x7f, 0x35, 0x58, 0xec}; + uint8_t byteswillprops3[] = {0x80, 0x18, 0x53, 0x53, 0xc9, 0xc5}; + uint8_t byteswillprops4[] = {0xe9, 0x4d, 0x1b, 0x8e, 0x89, 0x3a, 0xd, 0xbe, 0x90, 0x1a, 0xe6, 0xad, 0x4, + 0xad, 0xe3, 0xd3, 0x6c, 0x1f, 0x76, 0x5c, 0xa2, 0xa9, 0xfc, 0xc0, 0x9, 0xd0}; + uint8_t byteswillprops5[] = {0x78, 0x30, 0x27, 0x44, 0x6, 0xe, 0xf8, 0x6c, 0x24, 0x82, 0x49, 0x5f, 0x90}; + uint8_t byteswillprops6[] = {0x68, 0x9a, 0x42, 0x32, 0xea, 0x1, 0x4f, 0x57, 0xfe}; + uint8_t byteswillprops7[] = {0x38, 0xb9, 0x20, 0x7e, 0x8a, 0xf0, 0xc0, 0x3c}; + uint8_t byteswillprops8[] = {0x74, 0x76, 0xe9, 0x4a}; + uint8_t byteswillprops9[] = {0x7e, 0xaa, 0x26, 0xec, 0x8a, 0x7b, 0x5, 0x53, 0x72, 0x5f, 0xae, 0x2b}; + uint8_t byteswillprops10[] = {0xfd, 0x98, 0x95, 0x72, 0xc9, 0x3b, 0x4d, 0xbc, 0xd, 0xd7, 0x63, 0xf8, + 0x16, 0x53, 0xc3, 0xea, 0x6a, 0xe4, 0xca, 0x8e, 0xfb, 0xd3, 0xe6}; + uint8_t byteswillprops11[] = {0xf4, 0x51, 0x9f, 0x1e}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10264}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20012}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {15, (char*)&byteswillprops1}, .v = {10, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24923}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26416}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24898}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14664}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25634}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28271}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, }; - lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x48}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe1, 0xc6, 0x96, 0xa3, 0xd0, 0x57, 0xee, 0x92, 0x1c, 0xdf, - 0x5f, 0xc9, 0xfb, 0x25, 0x8f, 0x0, 0xf3, 0xa2, 0xe1, 0x6c, - 0x6c, 0x93, 0x9d, 0x5a, 0xed, 0xd0, 0xd3, 0x57, 0x29}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x6, 0x62, 0x3c, 0x5b, 0x32, 0x7, 0xb6, 0x2f, 0x68, 0xfc, 0x67, 0x91, 0x53, + 0x9c, 0xb3, 0x3f, 0x36, 0x15, 0xe8, 0x2f, 0xe, 0xf1, 0xd5, 0x50, 0x8, 0x6b}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x19, 0x8c, 0xa8, 0x63, 0xf0, 0x1b, 0x5d, 0x3a, 0xfa, + 0x6c, 0xa0, 0x3e, 0x43, 0x54, 0x14, 0x17, 0xd1, 0x12}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; @@ -7488,18 +7700,15 @@ TEST(Connect5QCTest, Encode9) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 13897; - uint8_t client_id_bytes[] = {0xe9, 0x81, 0x20}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 1187; + uint8_t client_id_bytes[] = {0xa2, 0x87, 0x8b, 0x4f, 0xf3, 0xa6, 0x9, 0x28, 0xcc, 0xa7, 0xd5, 0x65, 0xd7, + 0xdc, 0x64, 0xb9, 0xa, 0x95, 0xe9, 0x90, 0x8, 0xda, 0xe5, 0xeb, 0x2c}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xcd, 0x21, 0xa4, 0x71, 0x3b, 0x95, 0x7c, 0x8c, 0xef, 0x7c, 0xea, 0x1c, 0x4}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x90}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x42, 0x45, 0xb, 0x2a, 0x55, 0x19, 0x27, 0x9f, 0x9d, 0x16, 0x6d, 0x10, 0x6e, 0xc0, 0x88, - 0xb, 0x53, 0x22, 0xf4, 0x0, 0x39, 0xe4, 0x27, 0xc3, 0x8b, 0x4, 0xc5, 0xc8, 0xc2}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7508,84 +7717,102 @@ TEST(Connect5QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "B\186\246\255t\DC3^!\193Sq\185HB\196\232\246Y>p\ACK\187k\ETBu\142", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS1, _willTopic = "I;]\195\205\\\220z\EOT0:<'\ENQ\194D@1\238|", _willMsg = "`!\186\212fPy", _willProps = -// [PropMessageExpiryInterval 28355,PropMaximumPacketSize 28742,PropSubscriptionIdentifierAvailable -// 107,PropMessageExpiryInterval 23830,PropSubscriptionIdentifier 31,PropCorrelationData -// "\179\166D\243"]} -TEST(Connect5QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0xb7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6e, 0x51, 0x34, 0x8, 0x1a, 0x0, 0x5, - 0x3e, 0xb3, 0xa6, 0x44, 0xf3, 0x0, 0x16, 0x9b, 0x1f, 0x9d, 0x78, 0x85, 0x1b, 0x2c, 0x37, 0x5f, 0x62, - 0x8b, 0x87, 0xf4, 0x9d, 0x3c, 0x4a, 0x93, 0x2b, 0x95, 0x11, 0xe9, 0xf4, 0x50, 0x2, 0x0, 0x0, 0x6e, - 0xc3, 0x27, 0x0, 0x0, 0x70, 0x46, 0x29, 0x6b, 0x2, 0x0, 0x0, 0x5d, 0x16, 0xb, 0x1f, 0x9, 0x0, - 0x12, 0x3c, 0x44, 0xb, 0x34, 0x4b, 0xb4, 0x6, 0x4b, 0xc2, 0xd8, 0x94, 0x36, 0x9c, 0xd4, 0xb0, 0x37, - 0xff, 0x5f, 0x11, 0x0, 0x0, 0x26, 0x93, 0x22, 0x34, 0x98, 0x25, 0xcb, 0x27, 0x0, 0x0, 0x1a, 0xf1, - 0x25, 0xeb, 0x27, 0x0, 0x0, 0x63, 0x77, 0x22, 0x7e, 0x9, 0x25, 0x8d, 0x1c, 0x0, 0x7, 0x9f, 0xc6, - 0xf8, 0xf9, 0x45, 0xab, 0xdd, 0x13, 0x59, 0x1e, 0x0, 0x14, 0x49, 0x3b, 0x5d, 0xc3, 0xcd, 0x5c, 0xdc, - 0x7a, 0x4, 0x30, 0x3a, 0x3c, 0x27, 0x5, 0xc2, 0x44, 0x40, 0x31, 0xee, 0x7c, 0x0, 0x7, 0x60, 0x21, - 0xba, 0xd4, 0x66, 0x50, 0x79, 0x0, 0x1a, 0x42, 0xba, 0xf6, 0xff, 0x74, 0x13, 0x5e, 0x21, 0xc1, 0x53, - 0x71, 0xb9, 0x48, 0x42, 0xc4, 0xe8, 0xf6, 0x59, 0x3e, 0x70, 0x6, 0xbb, 0x6b, 0x17, 0x75, 0x8e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x3e, 0xb3, 0xa6, 0x44, 0xf3}; +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS0, _willTopic = "$`\SYN}79\139\SUB\138\ETX\146\rK\199\236*\DC2`D\178", _willMsg = +// "\146\226\241\226\SUB$6\236\236\SYN_\134\252\240\ACK\220_\158~\191\130\215\178", _willProps = []}), _cleanSession = +// False, _keepAlive = 6339, _connID = "", _properties = [PropAuthenticationData "\147\n",PropWillDelayInterval +// 11436,PropAssignedClientIdentifier "M\SO\165eHS-\SUB\180o\161> \152\230\205",PropSubscriptionIdentifier +// 18,PropSubscriptionIdentifierAvailable 233,PropMessageExpiryInterval 7344,PropRequestProblemInformation +// 222,PropServerReference ",\207\232\227\134\215\231\254x!\182",PropWildcardSubscriptionAvailable +// 195,PropAssignedClientIdentifier "\182%\233s\174\148\136IZ.",PropAuthenticationMethod +// "\235L7(\"\141\194\192\245F\164\USf\189\211\163\225}z\251\212\199t\DC2az\ETB",PropSubscriptionIdentifier +// 19,PropRetainAvailable 112,PropResponseTopic +// "\215\ETX5l9r\161\a\NUL\171\218\250\159$\250d\136Wn*|H\CAN\229\246\NUL8\186",PropTopicAliasMaximum +// 8032,PropReasonString "\\l\154\131\224\221yH\135CY\174\149\a\177;F\238\138\167\" \133/\147",PropAuthenticationData +// "\ETB\212\224\RSb\213-\212\230\188O\229",PropResponseInformation +// "\216\189\232g\v\190\208n\NULOXzK\SO\135\221y\156\143I\154'%\255",PropMessageExpiryInterval +// 23716,PropSubscriptionIdentifierAvailable 208,PropServerKeepAlive 14535]} +TEST(Connect5QCTest, Encode9) { + uint8_t pkt[] = { + 0x10, 0x97, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0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1a, 0x0, 0x18, 0xd8, 0xbd, 0xe8, 0x67, 0xb, 0xbe, 0xd0, 0x6e, 0x0, 0x4f, 0x58, + 0x7a, 0x4b, 0xe, 0x87, 0xdd, 0x79, 0x9c, 0x8f, 0x49, 0x9a, 0x27, 0x25, 0xff, 0x2, 0x0, 0x0, 0x5c, 0xa4, 0x29, + 0xd0, 0x13, 0x38, 0xc7, 0x0, 0x0, 0x0, 0x0, 0x14, 0x24, 0x60, 0x16, 0x7d, 0x37, 0x39, 0x8b, 0x1a, 0x8a, 0x3, + 0x92, 0xd, 0x4b, 0xc7, 0xec, 0x2a, 0x12, 0x60, 0x44, 0xb2, 0x0, 0x17, 0x92, 0xe2, 0xf1, 0xe2, 0x1a, 0x24, 0x36, + 0xec, 0xec, 0x16, 0x5f, 0x86, 0xfc, 0xf0, 0x6, 0xdc, 0x5f, 0x9e, 0x7e, 0xbf, 0x82, 0xd7, 0xb2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x93, 0xa}; + uint8_t bytesprops1[] = {0x4d, 0xe, 0xa5, 0x65, 0x48, 0x53, 0x2d, 0x1a, + 0xb4, 0x6f, 0xa1, 0x3e, 0x20, 0x98, 0xe6, 0xcd}; + uint8_t bytesprops2[] = {0x2c, 0xcf, 0xe8, 0xe3, 0x86, 0xd7, 0xe7, 0xfe, 0x78, 0x21, 0xb6}; + uint8_t bytesprops3[] = {0xb6, 0x25, 0xe9, 0x73, 0xae, 0x94, 0x88, 0x49, 0x5a, 0x2e}; + uint8_t bytesprops4[] = {0xeb, 0x4c, 0x37, 0x28, 0x22, 0x8d, 0xc2, 0xc0, 0xf5, 0x46, 0xa4, 0x1f, 0x66, 0xbd, + 0xd3, 0xa3, 0xe1, 0x7d, 0x7a, 0xfb, 0xd4, 0xc7, 0x74, 0x12, 0x61, 0x7a, 0x17}; + uint8_t bytesprops5[] = {0xd7, 0x3, 0x35, 0x6c, 0x39, 0x72, 0xa1, 0x7, 0x0, 0xab, 0xda, 0xfa, 0x9f, 0x24, + 0xfa, 0x64, 0x88, 0x57, 0x6e, 0x2a, 0x7c, 0x48, 0x18, 0xe5, 0xf6, 0x0, 0x38, 0xba}; + uint8_t bytesprops6[] = {0x5c, 0x6c, 0x9a, 0x83, 0xe0, 0xdd, 0x79, 0x48, 0x87, 0x43, 0x59, 0xae, 0x95, + 0x7, 0xb1, 0x3b, 0x46, 0xee, 0x8a, 0xa7, 0x22, 0x20, 0x85, 0x2f, 0x93}; + uint8_t bytesprops7[] = {0x17, 0xd4, 0xe0, 0x1e, 0x62, 0xd5, 0x2d, 0xd4, 0xe6, 0xbc, 0x4f, 0xe5}; + uint8_t bytesprops8[] = {0xd8, 0xbd, 0xe8, 0x67, 0xb, 0xbe, 0xd0, 0x6e, 0x0, 0x4f, 0x58, 0x7a, + 0x4b, 0xe, 0x87, 0xdd, 0x79, 0x9c, 0x8f, 0x49, 0x9a, 0x27, 0x25, 0xff}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11436}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7344}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8032}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23716}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14535}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x3c, 0x44, 0xb, 0x34, 0x4b, 0xb4, 0x6, 0x4b, 0xc2, - 0xd8, 0x94, 0x36, 0x9c, 0xd4, 0xb0, 0x37, 0xff, 0x5f}; - uint8_t byteswillprops1[] = {0x9f, 0xc6, 0xf8, 0xf9, 0x45, 0xab, 0xdd}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28355}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28742}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23830}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9875}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13464}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6897}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25463}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32265}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22814}}, - }; + lwmqtt_property_t willpropslist[] = {}; - lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x49, 0x3b, 0x5d, 0xc3, 0xcd, 0x5c, 0xdc, 0x7a, 0x4, 0x30, - 0x3a, 0x3c, 0x27, 0x5, 0xc2, 0x44, 0x40, 0x31, 0xee, 0x7c}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x24, 0x60, 0x16, 0x7d, 0x37, 0x39, 0x8b, 0x1a, 0x8a, 0x3, + 0x92, 0xd, 0x4b, 0xc7, 0xec, 0x2a, 0x12, 0x60, 0x44, 0xb2}; lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x60, 0x21, 0xba, 0xd4, 0x66, 0x50, 0x79}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + uint8_t will_payload_bytes[] = {0x92, 0xe2, 0xf1, 0xe2, 0x1a, 0x24, 0x36, 0xec, 0xec, 0x16, 0x5f, 0x86, + 0xfc, 0xf0, 0x6, 0xdc, 0x5f, 0x9e, 0x7e, 0xbf, 0x82, 0xd7, 0xb2}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 20788; - uint8_t client_id_bytes[] = {0x9b, 0x1f, 0x9d, 0x78, 0x85, 0x1b, 0x2c, 0x37, 0x5f, 0x62, 0x8b, - 0x87, 0xf4, 0x9d, 0x3c, 0x4a, 0x93, 0x2b, 0x95, 0x11, 0xe9, 0xf4}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 6339; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x42, 0xba, 0xf6, 0xff, 0x74, 0x13, 0x5e, 0x21, 0xc1, 0x53, 0x71, 0xb9, 0x48, - 0x42, 0xc4, 0xe8, 0xf6, 0x59, 0x3e, 0x70, 0x6, 0xbb, 0x6b, 0x17, 0x75, 0x8e}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7594,88 +7821,100 @@ TEST(Connect5QCTest, Encode10) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "dXU-\240\154\245]\DC3\246\178\132\200\255\147MJ\234\151\213\255\168\248\&0\142P\f\180\200", _password = Just -// "\128\DC1\b~e\198U\177\STX'\151\167\&5", _lastWill = Nothing, _cleanSession = True, _keepAlive = 18569, _connID = -// "\128S\EM\228\"K\171g\158}\227SV6\144\224\DC2\159\239\r0\n\156\140\DC3", _properties = [PropUserProperty "" -// "\205\237\173\DC39^\222\EM\168\252\&1-\199A\CAN\241\RS",PropReasonString -// "\RS\203~\182\155y\194\149t\182f\227\224]\187\253\183\225^\159\131i.p\192\174\144[\222\232",PropUserProperty -// "\200\130\155\243\240\DLE\242%\186\GS\168&\212\223\166\221b\SI \149\208\215>\207\156\173a\232<\220" -// ";\236\223\164\221\n;\v\216\RS'\251}n\239\ACK*\149\n9a\255\253\131gm",PropMessageExpiryInterval -// 23389,PropMaximumPacketSize 28026,PropSessionExpiryInterval 977,PropRequestResponseInformation 197,PropUserProperty -// "\233\224U\181Z\148b\EOT" "\168",PropReasonString "\DEL\SOl\RS",PropResponseInformation "",PropMaximumPacketSize -// 14063,PropRequestProblemInformation 214,PropWillDelayInterval 10568,PropTopicAlias -// 1756,PropRequestResponseInformation 234,PropMessageExpiryInterval 13813,PropRequestResponseInformation -// 255,PropServerReference "\149v\231F\US\ACK\178\175,m\132\216"]} -TEST(Connect5QCTest, Encode11) { +// ConnectRequest {_username = Just "\195\225Z\248\165S\201G\ne9\161>\FS\201_\239D\203\r", _password = Just +// "\230WH\211", _lastWill = Nothing, _cleanSession = False, _keepAlive = 22088, _connID = "nx\237\250`\150", +// _properties = [PropRequestResponseInformation 102,PropPayloadFormatIndicator 219,PropWildcardSubscriptionAvailable +// 12,PropCorrelationData ";\169?\SOH\186p\248\140B\DC3@~r\148\227\162\153e\FSgP",PropRetainAvailable +// 64,PropRetainAvailable 132,PropUserProperty "F." "\174G\250\234\t\DC4\141\200",PropRetainAvailable +// 216,PropSharedSubscriptionAvailable 239,PropSubscriptionIdentifierAvailable 91,PropTopicAliasMaximum +// 16140,PropRequestProblemInformation 171,PropReasonString +// "\na\208\187h6d|%\250q*\171F\245\178\160\147\&9r\144s\237\ETB\170gO\253",PropMessageExpiryInterval +// 27214,PropCorrelationData "\206\195\196\195\n|\215\ETX\173\243\218\240v\197\234O\225\248",PropPayloadFormatIndicator +// 68,PropSessionExpiryInterval 3981,PropAssignedClientIdentifier +// "\215\147\\m\215\186\217S\tI\147n\NAK",PropAssignedClientIdentifier +// "\"@\193\135\139\179\157\252:\193\NULV(\SO\156",PropCorrelationData +// "\DC3\180\&73Y\209o\255\DC4\158\135fc\219nub.\204N\159\200\143\136",PropRequestResponseInformation 139,PropTopicAlias +// 7297,PropAuthenticationData "}U@\204\189\190\253\204\139#\v\164",PropServerReference "{S\167\DC1\\MI +// Z\STX\ACKK\198\180",PropSubscriptionIdentifier 10,PropWillDelayInterval 2992,PropReceiveMaximum +// 14476,PropPayloadFormatIndicator 15]} +TEST(Connect5QCTest, Encode10) { uint8_t pkt[] = { - 0x10, 0x99, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x48, 0x89, 0xc4, 0x1, 0x26, 0x0, 0x0, 0x0, - 0x11, 0xcd, 0xed, 0xad, 0x13, 0x39, 0x5e, 0xde, 0x19, 0xa8, 0xfc, 0x31, 0x2d, 0xc7, 0x41, 0x18, 0xf1, 0x1e, 0x1f, - 0x0, 0x1e, 0x1e, 0xcb, 0x7e, 0xb6, 0x9b, 0x79, 0xc2, 0x95, 0x74, 0xb6, 0x66, 0xe3, 0xe0, 0x5d, 0xbb, 0xfd, 0xb7, - 0xe1, 0x5e, 0x9f, 0x83, 0x69, 0x2e, 0x70, 0xc0, 0xae, 0x90, 0x5b, 0xde, 0xe8, 0x26, 0x0, 0x1e, 0xc8, 0x82, 0x9b, - 0xf3, 0xf0, 0x10, 0xf2, 0x25, 0xba, 0x1d, 0xa8, 0x26, 0xd4, 0xdf, 0xa6, 0xdd, 0x62, 0xf, 0x20, 0x95, 0xd0, 0xd7, - 0x3e, 0xcf, 0x9c, 0xad, 0x61, 0xe8, 0x3c, 0xdc, 0x0, 0x1a, 0x3b, 0xec, 0xdf, 0xa4, 0xdd, 0xa, 0x3b, 0xb, 0xd8, - 0x1e, 0x27, 0xfb, 0x7d, 0x6e, 0xef, 0x6, 0x2a, 0x95, 0xa, 0x39, 0x61, 0xff, 0xfd, 0x83, 0x67, 0x6d, 0x2, 0x0, - 0x0, 0x5b, 0x5d, 0x27, 0x0, 0x0, 0x6d, 0x7a, 0x11, 0x0, 0x0, 0x3, 0xd1, 0x19, 0xc5, 0x26, 0x0, 0x8, 0xe9, - 0xe0, 0x55, 0xb5, 0x5a, 0x94, 0x62, 0x4, 0x0, 0x1, 0xa8, 0x1f, 0x0, 0x4, 0x7f, 0xe, 0x6c, 0x1e, 0x1a, 0x0, - 0x0, 0x27, 0x0, 0x0, 0x36, 0xef, 0x17, 0xd6, 0x18, 0x0, 0x0, 0x29, 0x48, 0x23, 0x6, 0xdc, 0x19, 0xea, 0x2, - 0x0, 0x0, 0x35, 0xf5, 0x19, 0xff, 0x1c, 0x0, 0xc, 0x95, 0x76, 0xe7, 0x46, 0x1f, 0x6, 0xb2, 0xaf, 0x2c, 0x6d, - 0x84, 0xd8, 0x0, 0x19, 0x80, 0x53, 0x19, 0xe4, 0x22, 0x4b, 0xab, 0x67, 0x9e, 0x7d, 0xe3, 0x53, 0x56, 0x36, 0x90, - 0xe0, 0x12, 0x9f, 0xef, 0xd, 0x30, 0xa, 0x9c, 0x8c, 0x13, 0x0, 0x1d, 0x64, 0x58, 0x55, 0x2d, 0xf0, 0x9a, 0xf5, - 0x5d, 0x13, 0xf6, 0xb2, 0x84, 0xc8, 0xff, 0x93, 0x4d, 0x4a, 0xea, 0x97, 0xd5, 0xff, 0xa8, 0xf8, 0x30, 0x8e, 0x50, - 0xc, 0xb4, 0xc8, 0x0, 0xd, 0x80, 0x11, 0x8, 0x7e, 0x65, 0xc6, 0x55, 0xb1, 0x2, 0x27, 0x97, 0xa7, 0x35}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0xcd, 0xed, 0xad, 0x13, 0x39, 0x5e, 0xde, 0x19, 0xa8, - 0xfc, 0x31, 0x2d, 0xc7, 0x41, 0x18, 0xf1, 0x1e}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops2[] = {0x1e, 0xcb, 0x7e, 0xb6, 0x9b, 0x79, 0xc2, 0x95, 0x74, 0xb6, 0x66, 0xe3, 0xe0, 0x5d, 0xbb, - 0xfd, 0xb7, 0xe1, 0x5e, 0x9f, 0x83, 0x69, 0x2e, 0x70, 0xc0, 0xae, 0x90, 0x5b, 0xde, 0xe8}; - uint8_t bytesprops4[] = {0x3b, 0xec, 0xdf, 0xa4, 0xdd, 0xa, 0x3b, 0xb, 0xd8, 0x1e, 0x27, 0xfb, 0x7d, - 0x6e, 0xef, 0x6, 0x2a, 0x95, 0xa, 0x39, 0x61, 0xff, 0xfd, 0x83, 0x67, 0x6d}; - uint8_t bytesprops3[] = {0xc8, 0x82, 0x9b, 0xf3, 0xf0, 0x10, 0xf2, 0x25, 0xba, 0x1d, 0xa8, 0x26, 0xd4, 0xdf, 0xa6, - 0xdd, 0x62, 0xf, 0x20, 0x95, 0xd0, 0xd7, 0x3e, 0xcf, 0x9c, 0xad, 0x61, 0xe8, 0x3c, 0xdc}; - uint8_t bytesprops6[] = {0xa8}; - uint8_t bytesprops5[] = {0xe9, 0xe0, 0x55, 0xb5, 0x5a, 0x94, 0x62, 0x4}; - uint8_t bytesprops7[] = {0x7f, 0xe, 0x6c, 0x1e}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops9[] = {0x95, 0x76, 0xe7, 0x46, 0x1f, 0x6, 0xb2, 0xaf, 0x2c, 0x6d, 0x84, 0xd8}; + 0x10, 0x9a, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x56, 0x48, 0xea, 0x1, 0x19, 0x66, 0x1, 0xdb, + 0x28, 0xc, 0x9, 0x0, 0x15, 0x3b, 0xa9, 0x3f, 0x1, 0xba, 0x70, 0xf8, 0x8c, 0x42, 0x13, 0x40, 0x7e, 0x72, 0x94, + 0xe3, 0xa2, 0x99, 0x65, 0x1c, 0x67, 0x50, 0x25, 0x40, 0x25, 0x84, 0x26, 0x0, 0x2, 0x46, 0x2e, 0x0, 0x8, 0xae, + 0x47, 0xfa, 0xea, 0x9, 0x14, 0x8d, 0xc8, 0x25, 0xd8, 0x2a, 0xef, 0x29, 0x5b, 0x22, 0x3f, 0xc, 0x17, 0xab, 0x1f, + 0x0, 0x1c, 0xa, 0x61, 0xd0, 0xbb, 0x68, 0x36, 0x64, 0x7c, 0x25, 0xfa, 0x71, 0x2a, 0xab, 0x46, 0xf5, 0xb2, 0xa0, + 0x93, 0x39, 0x72, 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+ uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x3b, 0xa9, 0x3f, 0x1, 0xba, 0x70, 0xf8, 0x8c, 0x42, 0x13, 0x40, + 0x7e, 0x72, 0x94, 0xe3, 0xa2, 0x99, 0x65, 0x1c, 0x67, 0x50}; + uint8_t bytesprops2[] = {0xae, 0x47, 0xfa, 0xea, 0x9, 0x14, 0x8d, 0xc8}; + uint8_t bytesprops1[] = {0x46, 0x2e}; + uint8_t bytesprops3[] = {0xa, 0x61, 0xd0, 0xbb, 0x68, 0x36, 0x64, 0x7c, 0x25, 0xfa, 0x71, 0x2a, 0xab, 0x46, + 0xf5, 0xb2, 0xa0, 0x93, 0x39, 0x72, 0x90, 0x73, 0xed, 0x17, 0xaa, 0x67, 0x4f, 0xfd}; + uint8_t bytesprops4[] = {0xce, 0xc3, 0xc4, 0xc3, 0xa, 0x7c, 0xd7, 0x3, 0xad, + 0xf3, 0xda, 0xf0, 0x76, 0xc5, 0xea, 0x4f, 0xe1, 0xf8}; + uint8_t bytesprops5[] = {0xd7, 0x93, 0x5c, 0x6d, 0xd7, 0xba, 0xd9, 0x53, 0x9, 0x49, 0x93, 0x6e, 0x15}; + uint8_t bytesprops6[] = {0x22, 0x40, 0xc1, 0x87, 0x8b, 0xb3, 0x9d, 0xfc, 0x3a, 0xc1, 0x0, 0x56, 0x28, 0xe, 0x9c}; + uint8_t bytesprops7[] = {0x13, 0xb4, 0x37, 0x33, 0x59, 0xd1, 0x6f, 0xff, 0x14, 0x9e, 0x87, 0x66, + 0x63, 0xdb, 0x6e, 0x75, 0x62, 0x2e, 0xcc, 0x4e, 0x9f, 0xc8, 0x8f, 0x88}; + uint8_t bytesprops8[] = {0x7d, 0x55, 0x40, 0xcc, 0xbd, 0xbe, 0xfd, 0xcc, 0x8b, 0x23, 0xb, 0xa4}; + uint8_t bytesprops9[] = {0x7b, 0x53, 0xa7, 0x11, 0x5c, 0x4d, 0x49, 0x20, 0x5a, 0x2, 0x6, 0x4b, 0xc6, 0xb4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops0}, .v = {17, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops3}, .v = {26, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23389}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28026}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 977}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops5}, .v = {1, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14063}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10568}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1756}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13813}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16140}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27214}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3981}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7297}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2992}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14476}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 15}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 18569; - uint8_t client_id_bytes[] = {0x80, 0x53, 0x19, 0xe4, 0x22, 0x4b, 0xab, 0x67, 0x9e, 0x7d, 0xe3, 0x53, 0x56, - 0x36, 0x90, 0xe0, 0x12, 0x9f, 0xef, 0xd, 0x30, 0xa, 0x9c, 0x8c, 0x13}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 22088; + uint8_t client_id_bytes[] = {0x6e, 0x78, 0xed, 0xfa, 0x60, 0x96}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x64, 0x58, 0x55, 0x2d, 0xf0, 0x9a, 0xf5, 0x5d, 0x13, 0xf6, 0xb2, 0x84, 0xc8, 0xff, 0x93, - 0x4d, 0x4a, 0xea, 0x97, 0xd5, 0xff, 0xa8, 0xf8, 0x30, 0x8e, 0x50, 0xc, 0xb4, 0xc8}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xc3, 0xe1, 0x5a, 0xf8, 0xa5, 0x53, 0xc9, 0x47, 0xa, 0x65, + 0x39, 0xa1, 0x3e, 0x1c, 0xc9, 0x5f, 0xef, 0x44, 0xcb, 0xd}; + lwmqtt_string_t username = {20, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x80, 0x11, 0x8, 0x7e, 0x65, 0xc6, 0x55, 0xb1, 0x2, 0x27, 0x97, 0xa7, 0x35}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe6, 0x57, 0x48, 0xd3}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); @@ -7685,143 +7924,164 @@ TEST(Connect5QCTest, Encode11) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "|\226c4\183\220\157\131j{\194\250\147\168\202\ENQ\ENQ`\238>SqVU",PropReasonString -// "\201_\157B+",PropServerKeepAlive 1610,PropTopicAlias 27154,PropSubscriptionIdentifier 26]}), _cleanSession = False, -// _keepAlive = 17650, _connID = "\227 s`,1\240\236z\182\167\209\132kvpp\167\174}6Z\207\&9\207%\227U ", _properties = -// [PropPayloadFormatIndicator 172,PropContentType -// "\GS\211|\185\GS\ACK\218\240\255\250\188\196+W_\250\238+(\187\203\162\226\215J",PropAuthenticationMethod -// "",PropMaximumQoS 89,PropTopicAlias 16426,PropResponseTopic " x\193\133\253\234",PropAuthenticationMethod -// "\EOT\164{\208\233\SO|\139\198\&6V\175\145\199W\SO7\ETXgf\182",PropContentType -// "\b\ESC\151\208\148^\US_g\166h8\202{\FS",PropReasonString -// "\164\173\150\207\US\190\&0ZD\FS\198\219\147\128\166\vH\168j\173",PropReasonString -// "\STX",PropSubscriptionIdentifierAvailable 19,PropTopicAliasMaximum 27264,PropSessionExpiryInterval -// 21980,PropReasonString "\SI\141\156\183\221\EOTi\137\131\SOH\179f",PropTopicAlias 25523,PropTopicAliasMaximum -// 31622,PropContentType "\ETB\215aY1\160\GS\129\CAN\202'\177\166\249\231s\138\172\181\252",PropCorrelationData -// "_\230\236\ETB\172\203\r\SOg\230M\134\242\189b\245]\DC1\207\184\212K\b\148",PropUserProperty -// "\155+\130\144\214Su\171\DC4\225(\EMG\128<\202\140\203C\GS\RS\255\253\198\&0" -// "\133d\DEL\149\184",PropAuthenticationData "?\186\229x\186\226\245g\ENQ\SOH\164q\SYN\153:",PropUserProperty -// ";\163\145:x\175j\172\242\160p\SO\212" "\ACK",PropSubscriptionIdentifier 20,PropMaximumPacketSize 14292]} -TEST(Connect5QCTest, Encode12) { +// ConnectRequest {_username = Just "7{\215\177Q\252!\233\141P\206\242", _password = Just +// "\ETX\fegm\236K\157\249\140\DC3\144\186-9\156\238\222\167\138\202\SYN", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS1, _willTopic = "j&\214\247\206Z\212\219\RS\US-,\155\190e!\\\142\GS\243X\241", _willMsg = +// "\SYN\183\156\207\209\215", _willProps = [PropReceiveMaximum 31818,PropWildcardSubscriptionAvailable +// 224,PropServerKeepAlive 8513,PropRetainAvailable 133,PropSubscriptionIdentifierAvailable 169,PropServerKeepAlive +// 16360,PropAssignedClientIdentifier +// "7\243\131\187\GSgs\132\148\245" +// "\NULA\ACK\207bc\214\161\190\248o\171M\149\142r\135\205\SI\131x\132"]}), _cleanSession = True, _keepAlive = 26306, +// _connID = "\SI&\208\136\142lJ|\nQ\231\&2,\161\FS\184", _properties = [PropCorrelationData +// "kC8\129\150/\197\176\179\200\140\159\183\203\154\NUL\135\DC4_w\157\158\v\247\213`U(\209\n",PropMessageExpiryInterval +// 3478,PropMaximumQoS 222,PropMessageExpiryInterval 23782,PropResponseTopic "\157",PropSubscriptionIdentifierAvailable +// 187,PropMessageExpiryInterval 25410,PropPayloadFormatIndicator 1,PropResponseInformation +// "\174\220\196\192t\230\196yu\199\201\244j\218\&5\184zZbT6\SUB[\245\221\a",PropResponseInformation +// "\227\184\FS\f0[\203f\192\DC3\179;\\K",PropCorrelationData "*\235`\150\210\ACK?",PropServerKeepAlive +// 705,PropTopicAlias 31472,PropReasonString +// "\234\212\DC1\232\222q\r\234k\130\242;\239V\DC2DA\152T\131\212\RS\213\180\208\220\RS",PropMessageExpiryInterval +// 24407,PropWillDelayInterval 28666,PropMessageExpiryInterval 24637,PropAuthenticationData +// "\226iup\252\137\163\218\135\203'",PropRetainAvailable 75,PropSubscriptionIdentifierAvailable +// 132,PropAuthenticationMethod "\vG\212aW\r2\230\DC4\176\145\237\DLE'",PropMaximumQoS 134,PropContentType +// "\225\182\179\141\168\&0\133\165\130\152P\175\229\213P",PropRetainAvailable 220]} +TEST(Connect5QCTest, Encode11) { uint8_t pkt[] = { - 0x10, 0xc7, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x44, 0xf2, 0x94, 0x2, 0x1, 0xac, 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 0x1b, 0xca, 0x24, 0x78, 0xbb, 0xf1, 0x2b, 0x5b, - 0x3b, 0xa5, 0xa, 0x0, 0x7, 0xb7, 0x46, 0x98, 0xac, 0x94, 0x8c, 0x9c, 0x0, 0x13, 0x7c, 0xe2, 0x63, 0x34, 0xb7, - 0x3c, 0x78, 0x7f, 0x94, 0x3, 0xb7, 0xe, 0x21, 0x1c, 0xfa, 0x6, 0x1c, 0x5a, 0xe2, 0x0, 0x18, 0x77, 0xbb, 0xdc, - 0xfa, 0xb5, 0x6c, 0x78, 0xac, 0x37, 0x1, 0xc2, 0x8e, 0x5, 0x37, 0x1c, 0xcf, 0x58, 0x94, 0x17, 0xcc, 0xd, 0xd2, - 0x8, 0x1e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1d, 0xd3, 0x7c, 0xb9, 0x1d, 0x6, 0xda, 0xf0, 0xff, 0xfa, 0xbc, 0xc4, 0x2b, - 0x57, 0x5f, 0xfa, 0xee, 0x2b, 0x28, 0xbb, 0xcb, 0xa2, 0xe2, 0xd7, 0x4a}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x20, 0x78, 0xc1, 0x85, 0xfd, 0xea}; - uint8_t bytesprops3[] = {0x4, 0xa4, 0x7b, 0xd0, 0xe9, 0xe, 0x7c, 0x8b, 0xc6, 0x36, 0x56, - 0xaf, 0x91, 0xc7, 0x57, 0xe, 0x37, 0x3, 0x67, 0x66, 0xb6}; - uint8_t bytesprops4[] = {0x8, 0x1b, 0x97, 0xd0, 0x94, 0x5e, 0x1f, 0x5f, 0x67, 0xa6, 0x68, 0x38, 0xca, 0x7b, 0x1c}; - uint8_t bytesprops5[] = {0xa4, 0xad, 0x96, 0xcf, 0x1f, 0xbe, 0x30, 0x5a, 0x44, 0x1c, - 0xc6, 0xdb, 0x93, 0x80, 0xa6, 0xb, 0x48, 0xa8, 0x6a, 0xad}; - uint8_t bytesprops6[] = {0x2}; - uint8_t bytesprops7[] = {0xf, 0x8d, 0x9c, 0xb7, 0xdd, 0x4, 0x69, 0x89, 0x83, 0x1, 0xb3, 0x66}; - uint8_t bytesprops8[] = {0x17, 0xd7, 0x61, 0x59, 0x31, 0xa0, 0x1d, 0x81, 0x18, 0xca, - 0x27, 0xb1, 0xa6, 0xf9, 0xe7, 0x73, 0x8a, 0xac, 0xb5, 0xfc}; - uint8_t bytesprops9[] = {0x5f, 0xe6, 0xec, 0x17, 0xac, 0xcb, 0xd, 0xe, 0x67, 0xe6, 0x4d, 0x86, - 0xf2, 0xbd, 0x62, 0xf5, 0x5d, 0x11, 0xcf, 0xb8, 0xd4, 0x4b, 0x8, 0x94}; - uint8_t bytesprops11[] = {0x85, 0x64, 0x7f, 0x95, 0xb8}; - uint8_t bytesprops10[] = {0x9b, 0x2b, 0x82, 0x90, 0xd6, 0x53, 0x75, 0xab, 0x14, 0xe1, 0x28, 0x19, 0x47, - 0x80, 0x3c, 0xca, 0x8c, 0xcb, 0x43, 0x1d, 0x1e, 0xff, 0xfd, 0xc6, 0x30}; - uint8_t bytesprops12[] = {0x3f, 0xba, 0xe5, 0x78, 0xba, 0xe2, 0xf5, 0x67, 0x5, 0x1, 0xa4, 0x71, 0x16, 0x99, 0x3a}; - uint8_t bytesprops14[] = {0x6}; - uint8_t bytesprops13[] = {0x3b, 0xa3, 0x91, 0x3a, 0x78, 0xaf, 0x6a, 0xac, 0xf2, 0xa0, 0x70, 0xe, 0xd4}; + 0x10, 0xfa, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x66, 0xc2, 0xde, 0x1, 0x9, 0x0, 0x1e, 0x6b, + 0x43, 0x38, 0x81, 0x96, 0x2f, 0xc5, 0xb0, 0xb3, 0xc8, 0x8c, 0x9f, 0xb7, 0xcb, 0x9a, 0x0, 0x87, 0x14, 0x5f, 0x77, + 0x9d, 0x9e, 0xb, 0xf7, 0xd5, 0x60, 0x55, 0x28, 0xd1, 0xa, 0x2, 0x0, 0x0,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a1, 0xbe, 0xf8, 0x6f, 0xab, 0x4d, 0x95, 0x8e, 0x72, 0x87, 0xcd, 0xf, 0x83, + 0x78, 0x84, 0x0, 0x16, 0x6a, 0x26, 0xd6, 0xf7, 0xce, 0x5a, 0xd4, 0xdb, 0x1e, 0x1f, 0x2d, 0x2c, 0x9b, 0xbe, 0x65, + 0x21, 0x5c, 0x8e, 0x1d, 0xf3, 0x58, 0xf1, 0x0, 0x6, 0x16, 0xb7, 0x9c, 0xcf, 0xd1, 0xd7, 0x0, 0xc, 0x37, 0x7b, + 0xd7, 0xb1, 0x51, 0xfc, 0x21, 0xe9, 0x8d, 0x50, 0xce, 0xf2, 0x0, 0x16, 0x3, 0xc, 0x65, 0x67, 0x6d, 0xec, 0x4b, + 0x9d, 0xf9, 0x8c, 0x13, 0x90, 0xba, 0x2d, 0x39, 0x9c, 0xee, 0xde, 0xa7, 0x8a, 0xca, 0x16}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x6b, 0x43, 0x38, 0x81, 0x96, 0x2f, 0xc5, 0xb0, 0xb3, 0xc8, 0x8c, 0x9f, 0xb7, 0xcb, 0x9a, + 0x0, 0x87, 0x14, 0x5f, 0x77, 0x9d, 0x9e, 0xb, 0xf7, 0xd5, 0x60, 0x55, 0x28, 0xd1, 0xa}; + uint8_t bytesprops1[] = {0x9d}; + uint8_t bytesprops2[] = {0xae, 0xdc, 0xc4, 0xc0, 0x74, 0xe6, 0xc4, 0x79, 0x75, 0xc7, 0xc9, 0xf4, 0x6a, + 0xda, 0x35, 0xb8, 0x7a, 0x5a, 0x62, 0x54, 0x36, 0x1a, 0x5b, 0xf5, 0xdd, 0x7}; + uint8_t bytesprops3[] = {0xe3, 0xb8, 0x1c, 0xc, 0x30, 0x5b, 0xcb, 0x66, 0xc0, 0x13, 0xb3, 0x3b, 0x5c, 0x4b}; + uint8_t bytesprops4[] = {0x2a, 0xeb, 0x60, 0x96, 0xd2, 0x6, 0x3f}; + uint8_t bytesprops5[] = {0xea, 0xd4, 0x11, 0xe8, 0xde, 0x71, 0xd, 0xea, 0x6b, 0x82, 0xf2, 0x3b, 0xef, 0x56, + 0x12, 0x44, 0x41, 0x98, 0x54, 0x83, 0xd4, 0x1e, 0xd5, 0xb4, 0xd0, 0xdc, 0x1e}; + uint8_t bytesprops6[] = {0xe2, 0x69, 0x75, 0x70, 0xfc, 0x89, 0xa3, 0xda, 0x87, 0xcb, 0x27}; + uint8_t bytesprops7[] = {0xb, 0x47, 0xd4, 0x61, 0x57, 0xd, 0x32, 0xe6, 0x14, 0xb0, 0x91, 0xed, 0x10, 0x27}; + uint8_t bytesprops8[] = {0xe1, 0xb6, 0xb3, 0x8d, 0xa8, 0x30, 0x85, 0xa5, 0x82, 0x98, 0x50, 0xaf, 0xe5, 0xd5, 0x50}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16426}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27264}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21980}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25523}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31622}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops10}, .v = {5, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops13}, .v = {1, (char*)&bytesprops14}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14292}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3478}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23782}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25410}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 705}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31472}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24407}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28666}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24637}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 220}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x19, 0xbc, 0x86, 0x41, 0xea, 0x5d, 0xb6, 0x52, 0x3e, 0xdc, 0x9d, 0x83, 0x6a, 0x7b, - 0xc2, 0xfa, 0x93, 0xa8, 0xca, 0x5, 0x5, 0x60, 0xee, 0x3e, 0x53, 0x71, 0x56, 0x55}; - uint8_t byteswillprops1[] = {0xc9, 0x5f, 0x9d, 0x42, 0x2b}; + uint8_t byteswillprops0[] = {0x37, 0xf3, 0x3c, 0x2f, 0x60, 0x2, 0x64, 0xd0, 0x36, 0x62, 0xbf, + 0x79, 0xec, 0x10, 0x8, 0xe4, 0xe7, 0x1, 0xf1, 0x8a, 0xc, 0x2e}; + uint8_t byteswillprops1[] = {0xce, 0xf3, 0x7f, 0xfe, 0x5c, 0x9b, 0x40, 0xfa, 0xd8, 0xeb, 0x6, 0x94, 0x2b, 0xd3}; + uint8_t byteswillprops2[] = {0xdf, 0xd7, 0xc4, 0xe8, 0x3b, 0x2c, 0xc3, 0xe9, 0x40, 0xd4, + 0xda, 0xe0, 0xeb, 0x3c, 0xf8, 0xc4, 0x71, 0x6d, 0xb7, 0xc2, + 0x30, 0x1c, 0x4, 0x17, 0x5d, 0x61, 0xab, 0xd7, 0xb9, 0x2f}; + uint8_t byteswillprops3[] = {0x70, 0x3f, 0x92, 0xa, 0xf, 0x24, 0x9c, 0x50, 0x0, 0xa0, 0xd9, 0x32, + 0x80, 0xbd, 0x2d, 0x49, 0x1, 0xa2, 0xbe, 0x90, 0x57, 0x97, 0xd6}; + uint8_t byteswillprops4[] = {0x3}; + uint8_t byteswillprops5[] = {0xc8, 0x71}; + uint8_t byteswillprops7[] = {0x0, 0x41, 0x6, 0xcf, 0x62, 0x63, 0xd6, 0xa1, 0xbe, 0xf8, 0x6f, + 0xab, 0x4d, 0x95, 0x8e, 0x72, 0x87, 0xcd, 0xf, 0x83, 0x78, 0x84}; + uint8_t byteswillprops6[] = {0xf6, 0x47, 0x77, 0x92, 0x3e, 0x83, 0xbb, 0x1d, 0x67, 0x73, 0x84, 0x94, 0xf5}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10139}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1610}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27154}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31818}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8513}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16360}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22714}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1969}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24092}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {13, (char*)&byteswillprops6}, .v = {22, (char*)&byteswillprops7}}}}, }; - lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xce, 0x7, 0x42, 0x5e, 0x50, 0x68, 0xbd, 0xc8, 0x9e, 0xdc, 0xe, 0x97, 0xf8, - 0x8e, 0x1b, 0xca, 0x24, 0x78, 0xbb, 0xf1, 0x2b, 0x5b, 0x3b, 0xa5, 0xa}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb7, 0x46, 0x98, 0xac, 0x94, 0x8c, 0x9c}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x6a, 0x26, 0xd6, 0xf7, 0xce, 0x5a, 0xd4, 0xdb, 0x1e, 0x1f, 0x2d, + 0x2c, 0x9b, 0xbe, 0x65, 0x21, 0x5c, 0x8e, 0x1d, 0xf3, 0x58, 0xf1}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x16, 0xb7, 0x9c, 0xcf, 0xd1, 0xd7}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 17650; - uint8_t client_id_bytes[] = {0xe3, 0x20, 0x73, 0x60, 0x2c, 0x31, 0xf0, 0xec, 0x7a, 0xb6, 0xa7, 0xd1, 0x84, 0x6b, 0x76, - 0x70, 0x70, 0xa7, 0xae, 0x7d, 0x36, 0x5a, 0xcf, 0x39, 0xcf, 0x25, 0xe3, 0x55, 0x20}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 26306; + uint8_t client_id_bytes[] = {0xf, 0x26, 0xd0, 0x88, 0x8e, 0x6c, 0x4a, 0x7c, + 0xa, 0x51, 0xe7, 0x32, 0x2c, 0xa1, 0x1c, 0xb8}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x7c, 0xe2, 0x63, 0x34, 0xb7, 0x3c, 0x78, 0x7f, 0x94, 0x3, - 0xb7, 0xe, 0x21, 0x1c, 0xfa, 0x6, 0x1c, 0x5a, 0xe2}; - lwmqtt_string_t username = {19, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x37, 0x7b, 0xd7, 0xb1, 0x51, 0xfc, 0x21, 0xe9, 0x8d, 0x50, 0xce, 0xf2}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x77, 0xbb, 0xdc, 0xfa, 0xb5, 0x6c, 0x78, 0xac, 0x37, 0x1, 0xc2, 0x8e, - 0x5, 0x37, 0x1c, 0xcf, 0x58, 0x94, 0x17, 0xcc, 0xd, 0xd2, 0x8, 0x1e}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x3, 0xc, 0x65, 0x67, 0x6d, 0xec, 0x4b, 0x9d, 0xf9, 0x8c, 0x13, + 0x90, 0xba, 0x2d, 0x39, 0x9c, 0xee, 0xde, 0xa7, 0x8a, 0xca, 0x16}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7831,123 +8091,105 @@ TEST(Connect5QCTest, Encode12) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\148q\203\&9\184:)\217]G\254\f`\208\248\&4\183\139 -// \RS\CAN\219\RS\133d\252H\220L\v", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS2, _willTopic = "u\187\\\\+\205\SOHy&{\228\219.\ETB\ENQ\219", _willMsg = "\147 -// !K\155\f\253\214\246hNm\ACK)\156\193\241$\198>\RSz", _willProps = [PropUserProperty "n\179)X" -// "\b1\221\191\STX\223etX_\186\246\146",PropContentType -// "\232\216.\186\132p\211\187\\\n\201\166\240T\131\238\224e",PropAssignedClientIdentifier -// "s\FS\181Te\a\231",PropTopicAlias 32238,PropServerKeepAlive 20424,PropContentType -// "\173\ETBO^\SOH\224\STX\171\STX\215\232",PropMaximumPacketSize 4132,PropRequestResponseInformation -// 174,PropAuthenticationMethod -// "\129+\a\238\194\199\RS\175\r\\\FS\226i\159\191\183)\141S_\SOH%\140\203a\SO\244\ETB",PropResponseInformation -// "\144\254\186D\222\220",PropSharedSubscriptionAvailable 25,PropServerReference -// "\151\191l\188\RS0q\131\NAK\149\&6}\240D\247\191\218\187_rW\246\191\138\250cD",PropSubscriptionIdentifier -// 8,PropResponseTopic ",B\DLE\157\215\&0\153\&2\255\f",PropAuthenticationMethod -// "^-o\195v\166\ao\207\203\139\249\SO\244\206le",PropUserProperty -// "$]\254\EOT\232^\153\201\238\&4\178j\195\233q~\RS\194\163" -// "I\DLEUZ\132Y\219\155\&5j\228&xf\225>\223\203\SUBX\153\246\190\NULB\133\202\198\242\245",PropUserProperty -// ":Y\213\240b" "0$W\185\144\240"]}), _cleanSession = False, _keepAlive = 20026, _connID = -// "_\DEL\aB\218\207H\EMs\SO\153b@\162", _properties = [PropRequestResponseInformation 246,PropTopicAliasMaximum 18904]} -TEST(Connect5QCTest, Encode13) { +// ConnectRequest {_username = Just "\169\190fw\241\246)\vwT\139\DC3xx\216\189\225\158\213x\238\179\140", _password = +// Just "q\230-\213\ENQ5-T\188\DEL\b\213\155+\SO`m\GS \242\165#\\", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS0, _willTopic = "\217 \214\EM\178\ACK\155", _willMsg = +// "\245)\238j2\DC2\161\134.\140\147HX\198`\252\237D\164\157*", _willProps = [PropAuthenticationMethod +// "\154\133en<\173\aS",PropCorrelationData "/L\159\131\US\180\n\145Yq",PropRequestProblemInformation +// 88,PropRetainAvailable 40,PropTopicAlias 5030,PropSharedSubscriptionAvailable 42,PropMaximumPacketSize +// 18739,PropSubscriptionIdentifierAvailable 50,PropMessageExpiryInterval 19443,PropPayloadFormatIndicator +// 181,PropCorrelationData "\186\CAN\164\193\133\210)$\182p\184\215\ESC",PropTopicAlias 8775,PropCorrelationData +// "W\ETB\137\143\130\NUL,\168\ETB\203\148",PropWildcardSubscriptionAvailable 107,PropWildcardSubscriptionAvailable +// 71,PropMaximumQoS 251]}), _cleanSession = False, _keepAlive = 19404, _connID = +// "#f\162\233\167\DEL?\182\198\174aF\143S\150\160\186\DC2JqI\244\199\152\&3", _properties = [PropSubscriptionIdentifier +// 30,PropWildcardSubscriptionAvailable 54,PropSubscriptionIdentifierAvailable 173,PropServerReference +// "\220>\CAN\188\191\155+C\205D\175\188\162\163\&3\171\DC3\EOT\196\138&",PropReasonString +// "\159\154\255\SO\211\201\179l\130\187i~!q",PropMaximumQoS 56,PropTopicAlias 11834,PropTopicAlias 30167]} +TEST(Connect5QCTest, Encode12) { uint8_t pkt[] = { - 0x10, 0xed, 0x2, 0x0, 0x4, 0x4d, 0x51, 0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f5, 0x29, 0xee, 0x6a, 0x32, 0x12, 0xa1, 0x86, 0x2e, 0x8c, 0x93, 0x48, 0x58, 0xc6, 0x60, + 0xfc, 0xed, 0x44, 0xa4, 0x9d, 0x2a, 0x0, 0x17, 0xa9, 0xbe, 0x66, 0x77, 0xf1, 0xf6, 0x29, 0xb, 0x77, 0x54, 0x8b, + 0x13, 0x78, 0x78, 0xd8, 0xbd, 0xe1, 0x9e, 0xd5, 0x78, 0xee, 0xb3, 0x8c, 0x0, 0x17, 0x71, 0xe6, 0x2d, 0xd5, 0x5, + 0x35, 0x2d, 0x54, 0xbc, 0x7f, 0x8, 0xd5, 0x9b, 0x2b, 0xe, 0x60, 0x6d, 0x1d, 0x20, 0xf2, 0xa5, 0x23, 0x5c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xdc, 0x3e, 0x18, 0xbc, 0xbf, 0x9b, 0x2b, 0x43, 0xcd, 0x44, 0xaf, + 0xbc, 0xa2, 0xa3, 0x33, 0xab, 0x13, 0x4, 0xc4, 0x8a, 0x26}; + uint8_t bytesprops1[] = {0x9f, 0x9a, 0xff, 0xe, 0xd3, 0xc9, 0xb3, 0x6c, 0x82, 0xbb, 0x69, 0x7e, 0x21, 0x71}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18904}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11834}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30167}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x8, 0x31, 0xdd, 0xbf, 0x2, 0xdf, 0x65, 0x74, 0x58, 0x5f, 0xba, 0xf6, 0x92}; - uint8_t byteswillprops0[] = {0x6e, 0xb3, 0x29, 0x58}; - uint8_t byteswillprops2[] = {0xe8, 0xd8, 0x2e, 0xba, 0x84, 0x70, 0xd3, 0xbb, 0x5c, - 0xa, 0xc9, 0xa6, 0xf0, 0x54, 0x83, 0xee, 0xe0, 0x65}; - uint8_t byteswillprops3[] = {0x73, 0x1c, 0xb5, 0x54, 0x65, 0x7, 0xe7}; - uint8_t byteswillprops4[] = {0xad, 0x17, 0x4f, 0x5e, 0x1, 0xe0, 0x2, 0xab, 0x2, 0xd7, 0xe8}; - uint8_t byteswillprops5[] = {0x81, 0x2b, 0x7, 0xee, 0xc2, 0xc7, 0x1e, 0xaf, 0xd, 0x5c, 0x1c, 0xe2, 0x69, 0x9f, - 0xbf, 0xb7, 0x29, 0x8d, 0x53, 0x5f, 0x1, 0x25, 0x8c, 0xcb, 0x61, 0xe, 0xf4, 0x17}; - uint8_t byteswillprops6[] = {0x90, 0xfe, 0xba, 0x44, 0xde, 0xdc}; - uint8_t byteswillprops7[] = {0x97, 0xbf, 0x6c, 0xbc, 0x1e, 0x30, 0x71, 0x83, 0x15, 0x95, 0x36, 0x7d, 0xf0, 0x44, - 0xf7, 0xbf, 0xda, 0xbb, 0x5f, 0x72, 0x57, 0xf6, 0xbf, 0x8a, 0xfa, 0x63, 0x44}; - uint8_t byteswillprops8[] = {0x2c, 0x42, 0x10, 0x9d, 0xd7, 0x30, 0x99, 0x32, 0xff, 0xc}; - uint8_t byteswillprops9[] = {0x5e, 0x2d, 0x6f, 0xc3, 0x76, 0xa6, 0x7, 0x6f, 0xcf, - 0xcb, 0x8b, 0xf9, 0xe, 0xf4, 0xce, 0x6c, 0x65}; - uint8_t byteswillprops11[] = {0x49, 0x10, 0x55, 0x5a, 0x84, 0x59, 0xdb, 0x9b, 0x35, 0x6a, - 0xe4, 0x26, 0x78, 0x66, 0xe1, 0x3e, 0xdf, 0xcb, 0x1a, 0x58, - 0x99, 0xf6, 0xbe, 0x0, 0x42, 0x85, 0xca, 0xc6, 0xf2, 0xf5}; - uint8_t byteswillprops10[] = {0x24, 0x5d, 0xfe, 0x4, 0xe8, 0x5e, 0x99, 0xc9, 0xee, 0x34, - 0xb2, 0x6a, 0xc3, 0xe9, 0x71, 0x7e, 0x1e, 0xc2, 0xa3}; - uint8_t byteswillprops13[] = {0x30, 0x24, 0x57, 0xb9, 0x90, 0xf0}; - uint8_t byteswillprops12[] = {0x3a, 0x59, 0xd5, 0xf0, 0x62}; + uint8_t byteswillprops0[] = {0x9a, 0x85, 0x65, 0x6e, 0x3c, 0xad, 0x7, 0x53}; + uint8_t byteswillprops1[] = {0x2f, 0x4c, 0x9f, 0x83, 0x1f, 0xb4, 0xa, 0x91, 0x59, 0x71}; + uint8_t byteswillprops2[] = {0xba, 0x18, 0xa4, 0xc1, 0x85, 0xd2, 0x29, 0x24, 0xb6, 0x70, 0xb8, 0xd7, 0x1b}; + uint8_t byteswillprops3[] = {0x57, 0x17, 0x89, 0x8f, 0x82, 0x0, 0x2c, 0xa8, 0x17, 0xcb, 0x94}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {4, (char*)&byteswillprops0}, .v = {13, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32238}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20424}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4132}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {19, (char*)&byteswillprops10}, .v = {30, (char*)&byteswillprops11}}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {5, (char*)&byteswillprops12}, .v = {6, (char*)&byteswillprops13}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5030}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18739}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19443}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8775}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 251}}, }; - lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x75, 0xbb, 0x5c, 0x5c, 0x2b, 0xcd, 0x1, 0x79, - 0x26, 0x7b, 0xe4, 0xdb, 0x2e, 0x17, 0x5, 0xdb}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x93, 0x20, 0x21, 0x4b, 0x9b, 0xc, 0xfd, 0xd6, 0xf6, 0x68, 0x4e, - 0x6d, 0x6, 0x29, 0x9c, 0xc1, 0xf1, 0x24, 0xc6, 0x3e, 0x1e, 0x7a}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd9, 0x20, 0xd6, 0x19, 0xb2, 0x6, 0x9b}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf5, 0x29, 0xee, 0x6a, 0x32, 0x12, 0xa1, 0x86, 0x2e, 0x8c, 0x93, + 0x48, 0x58, 0xc6, 0x60, 0xfc, 0xed, 0x44, 0xa4, 0x9d, 0x2a}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 20026; - uint8_t client_id_bytes[] = {0x5f, 0x7f, 0x7, 0x42, 0xda, 0xcf, 0x48, 0x19, 0x73, 0xe, 0x99, 0x62, 0x40, 0xa2}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.keep_alive = 19404; + uint8_t client_id_bytes[] = {0x23, 0x66, 0xa2, 0xe9, 0xa7, 0x7f, 0x3f, 0xb6, 0xc6, 0xae, 0x61, 0x46, 0x8f, + 0x53, 0x96, 0xa0, 0xba, 0x12, 0x4a, 0x71, 0x49, 0xf4, 0xc7, 0x98, 0x33}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x94, 0x71, 0xcb, 0x39, 0xb8, 0x3a, 0x29, 0xd9, 0x5d, 0x47, 0xfe, 0xc, 0x60, 0xd0, 0xf8, - 0x34, 0xb7, 0x8b, 0x20, 0x1e, 0x18, 0xdb, 0x1e, 0x85, 0x64, 0xfc, 0x48, 0xdc, 0x4c, 0xb}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa9, 0xbe, 0x66, 0x77, 0xf1, 0xf6, 0x29, 0xb, 0x77, 0x54, 0x8b, 0x13, + 0x78, 0x78, 0xd8, 0xbd, 0xe1, 0x9e, 0xd5, 0x78, 0xee, 0xb3, 0x8c}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x71, 0xe6, 0x2d, 0xd5, 0x5, 0x35, 0x2d, 0x54, 0xbc, 0x7f, 0x8, 0xd5, + 0x9b, 0x2b, 0xe, 0x60, 0x6d, 0x1d, 0x20, 0xf2, 0xa5, 0x23, 0x5c}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7956,168 +8198,94 @@ TEST(Connect5QCTest, Encode13) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "F|\\\193@", _lastWill = Nothing, _cleanSession = False, -// _keepAlive = 13766, _connID = "((\SOH\237M\220\167\ESC\241\249\138f\149\134\225\RS U!\133]\SO\204\&8D.g\154", -// _properties = [PropServerReference "\237\186\SIg\196\172\241",PropMessageExpiryInterval -// 12799,PropRequestResponseInformation 71,PropRequestResponseInformation 250,PropMessageExpiryInterval -// 30631,PropUserProperty "\213\"\193\183V2XH\144\169\EM" -// "\b&[\137B\243\207\224\US\165Q\128Q\164>\174W\150\174V\US\190\169\222\250\r\206\150",PropSessionExpiryInterval -// 24456,PropRequestResponseInformation 8,PropRetainAvailable 102,PropServerKeepAlive 18186,PropMessageExpiryInterval -// 23633]} -TEST(Connect5QCTest, Encode14) { - uint8_t pkt[] = {0x10, 0x85, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x40, 0x35, 0xc6, 0x55, 0x1c, 0x0, - 0x7, 0xed, 0xba, 0xf, 0x67, 0xc4, 0xac, 0xf1, 0x2, 0x0, 0x0, 0x31, 0xff, 0x19, 0x47, 0x19, - 0xfa, 0x2, 0x0, 0x0, 0x77, 0xa7, 0x26, 0x0, 0xb, 0xd5, 0x22, 0xc1, 0xb7, 0x56, 0x32, 0x58, - 0x48, 0x90, 0xa9, 0x19, 0x0, 0x1c, 0x8, 0x26, 0x5b, 0x89, 0x42, 0xf3, 0xcf, 0xe0, 0x1f, 0xa5, - 0x51, 0x80, 0x51, 0xa4, 0x3e, 0xae, 0x57, 0x96, 0xae, 0x56, 0x1f, 0xbe, 0xa9, 0xde, 0xfa, 0xd, - 0xce, 0x96, 0x11, 0x0, 0x0, 0x5f, 0x88, 0x19, 0x8, 0x25, 0x66, 0x13, 0x47, 0xa, 0x2, 0x0, - 0x0, 0x5c, 0x51, 0x0, 0x1c, 0x28, 0x28, 0x1, 0xed, 0x4d, 0xdc, 0xa7, 0x1b, 0xf1, 0xf9, 0x8a, - 0x66, 0x95, 0x86, 0xe1, 0x1e, 0x20, 0x55, 0x21, 0x85, 0x5d, 0xe, 0xcc, 0x38, 0x44, 0x2e, 0x67, - 0x9a, 0x0, 0x5, 0x46, 0x7c, 0x5c, 0xc1, 0x40}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xed, 0xba, 0xf, 0x67, 0xc4, 0xac, 0xf1}; - uint8_t bytesprops2[] = {0x8, 0x26, 0x5b, 0x89, 0x42, 0xf3, 0xcf, 0xe0, 0x1f, 0xa5, 0x51, 0x80, 0x51, 0xa4, - 0x3e, 0xae, 0x57, 0x96, 0xae, 0x56, 0x1f, 0xbe, 0xa9, 0xde, 0xfa, 0xd, 0xce, 0x96}; - uint8_t bytesprops1[] = {0xd5, 0x22, 0xc1, 0xb7, 0x56, 0x32, 0x58, 0x48, 0x90, 0xa9, 0x19}; +// ConnectRequest {_username = Just "\SIu}\231\235\&7\157S\163\235u\157\206\215Gn\180\152\STX\142\225\150\&0\244B0", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "\173\184D\250<\252,\186c\146\178T!\ETXkKR\SO\139\253\&6", _willMsg = "h\144\228&\249\240u\248L", _willProps = +// [PropMessageExpiryInterval 22862,PropWillDelayInterval 19734,PropAuthenticationData +// "\EM\130\170\b\133\219\DC3+\245\ETX\146\158\241\129\&8\251\236\229\&4\229\STXo\143\204\SIe\232D\146",PropRequestProblemInformation +// 66,PropMessageExpiryInterval 15740,PropAuthenticationData "21",PropWildcardSubscriptionAvailable 134,PropContentType +// "\230\ENQ\SUB\FS\213\137r\a@\251EYX\218\ETX>q\DC4R/W>\250",PropMessageExpiryInterval 11158,PropAuthenticationData +// "g",PropResponseTopic "\144nN\DC2u\207\STX\199Dp\NUL\167{",PropMessageExpiryInterval 12811]}), _cleanSession = True, +// _keepAlive = 14654, _connID = "b!\199C\NAK8m\183\ETB\162\161\131\255\f\236\203\165\189\153\b\v\b\ACK", _properties = +// [PropCorrelationData "\DC2\207K\144\b\232\205v\229\\\176\218",PropWillDelayInterval 392,PropSessionExpiryInterval +// 27867,PropWillDelayInterval 21051,PropPayloadFormatIndicator 146,PropAuthenticationData ""]} +T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32, 0xb, + 0x0, 0x15, 0xad, 0xb8, 0x44, 0xfa, 0x3c, 0xfc, 0x2c, 0xba, 0x63, 0x92, 0xb2, 0x54, 0x21, 0x3, 0x6b, + 0x4b, 0x52, 0xe, 0x8b, 0xfd, 0x36, 0x0, 0x9, 0x68, 0x90, 0xe4, 0x26, 0xf9, 0xf0, 0x75, 0xf8, 0x4c, + 0x0, 0x1a, 0xf, 0x75, 0x7d, 0xe7, 0xeb, 0x37, 0x9d, 0x53, 0xa3, 0xeb, 0x75, 0x9d, 0xce, 0xd7, 0x47, + 0x6e, 0xb4, 0x98, 0x2, 0x8e, 0xe1, 0x96, 0x30, 0xf4, 0x42, 0x30}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x12, 0xcf, 0x4b, 0x90, 0x8, 0xe8, 0xcd, 0x76, 0xe5, 0x5c, 0xb0, 0xda}; + uint8_t bytesprops1[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12799}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30631}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {28, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24456}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18186}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23633}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 392}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27867}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21051}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 13766; - uint8_t client_id_bytes[] = {0x28, 0x28, 0x1, 0xed, 0x4d, 0xdc, 0xa7, 0x1b, 0xf1, 0xf9, 0x8a, 0x66, 0x95, 0x86, - 0xe1, 0x1e, 0x20, 0x55, 0x21, 0x85, 0x5d, 0xe, 0xcc, 0x38, 0x44, 0x2e, 0x67, 0x9a}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x46, 0x7c, 0x5c, 0xc1, 0x40}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Nothing, _password = Just "C\205.\143\174\198\137\162\176\DC1 \254/'\209\141o\153", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "H\153y\169d\249\209\v\245\233\238\223\202L\133\136\143\191\142\179FE )2\242\148k", _willMsg = -// "D\217\194\192\ENQ\DC1\147^?N(\146~Lo?\159\155",PropUserProperty "" +// "0\194\201X\235\140\248\&1Q\231\205-\180\150\RSDihoD\211\&9\134",PropCorrelationData +// "\236T",PropPayloadFormatIndicator 49,PropRequestResponseInformation 252,PropServerKeepAlive +// 18380,PropWildcardSubscriptionAvailable 130,PropSharedSubscriptionAvailable 94,PropUserProperty +// "=\192x\217w^\130RI!\DEL>Y>C\198\233D\220`\\,!\196\ESC" "v'\179\180\190\161,}I\226\201*\225",PropWillDelayInterval +// 12704,PropPayloadFormatIndicator 191,PropRetainAvailable 29,PropAssignedClientIdentifier +// "\252\"0\167U\250#|",PropPayloadFormatIndicator 132,PropRetainAvailable 176,PropPayloadFormatIndicator +// 247,PropUserProperty ",\156\241\149" "^,\133\158\130$&\SUB\192\236\ENQ0\231\158"]}), _cleanSession = True, _keepAlive +// = 9686, _connID = "\242\&1\174", _properties = [PropAuthenticationMethod +// "u\156Z\244$",PropSharedSubscriptionAvailable 158,PropMessageExpiryInterval 5802,PropUserProperty +// "\207\161\140T\DC4\144N6u$\166\140\214\183\&0;\199\149" +// "\231\222\233\157c\176p\179\128\220#-iA\211\219\SI",PropAuthenticationData +// "[\ACK\211\232\214\FS\140\EOT\DC2\EMp\232",PropMessageExpiryInterval 9094,PropReasonString +// "\139\DC2\"\172\rq\172,^;X\143\167i\226\231\220\ACK\\",PropRetainAvailable 107,PropRequestProblemInformation +// 232,PropMaximumPacketSize 21936,PropServerReference "\141\SO\199\ACK\217\200\235\180"]} +TEST(Connect5QCTest, Encode14) { uint8_t pkt[] = { - 0x10, 0xbd, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x74, 0x2e, 0xf7, 0x6e, 0x25, 0x9c, 0x12, 0x0, 0xc, - 0x8a, 0xc8, 0x5b, 0x7, 0x97, 0xa2, 0xa8, 0x84, 0xb2, 0x3b, 0xe1, 0xf4, 0x29, 0x51, 0x8, 0x0, 0x7, 0xd9, 0xff, - 0xb5, 0x6d, 0x61, 0x7a, 0x1a, 0x1, 0x11, 0x3, 0x0, 0x13, 0xec, 0xcc, 0x73, 0x8a, 0xc5, 0x58, 0xff, 0xfb, 0xaf, - 0xe9, 0x77, 0xb5, 0x2a, 0xa3, 0x7b, 0x99, 0x77, 0x9d, 0xba, 0x21, 0x6e, 0xde, 0x21, 0x6f, 0x8e, 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xb7, 0x7b, 0x76, 0x20, 0x99, 0x12, - 0xd1, 0xea, 0xb7, 0x82, 0x60, 0xb, 0x15, 0x93, 0xba, 0xf3, 0x66, 0xb6, 0xbd, 0xea, 0x0, 0xb, 0xe8, 0xf2, 0xda, - 0xfc, 0x4b, 0xc9, 0xb4, 0x80, 0x32, 0xf7, 0xbe, 0x0, 0x19, 0x4d, 0x88, 0x65, 0x22, 0xdb, 0x95, 0x7f, 0x5d, 0xd9, - 0x71, 0xbd, 0xcb, 0x6, 0xf6, 0x9f, 0x45, 0x9c, 0xa9, 0x8c, 0x1, 0x57, 0x73, 0x1f, 0xa5, 0xbe}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x8a, 0xc8, 0x5b, 0x7, 0x97, 0xa2, 0xa8, 0x84, 0xb2, 0x3b, 0xe1, 0xf4}; - uint8_t bytesprops1[] = {0xd9, 0xff, 0xb5, 0x6d, 0x61, 0x7a, 0x1a}; - uint8_t bytesprops2[] = {0xec, 0xcc, 0x73, 0x8a, 0xc5, 0x58, 0xff, 0xfb, 0xaf, 0xe9, - 0x77, 0xb5, 0x2a, 0xa3, 0x7b, 0x99, 0x77, 0x9d, 0xba}; - uint8_t bytesprops3[] = {0xc7, 0x80, 0x2d, 0x5b, 0x1e, 0x65, 0x43, 0x0, 0x75, 0x76}; - uint8_t bytesprops4[] = {0x5c, 0x0, 0x5a, 0xa6, 0x9f, 0x63, 0xa5, 0x2b, 0x44, 0xd0, 0xae}; + 0x10, 0xea, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x66, 0x25, 0xd6, 0x75, 0x15, 0x0, 0x5, 0x75, 0x9c, + 0x5a, 0xf4, 0x24, 0x2a, 0x9e, 0x2, 0x0, 0x0, 0x16, 0xaa, 0x26, 0x0, 0x12, 0xcf, 0xa1, 0x8c, 0x54, 0x14, 0x90, + 0x4e, 0x36, 0x75, 0x24, 0xa6, 0x8c, 0xd6, 0xb7, 0x30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e, 0x5e, 0x2c, 0x85, 0x9e, 0x82, 0x24, 0x26, 0x1a, 0xc0, 0xec, 0x5, 0x30, 0xe7, 0x9e, 0x0, 0xf, 0x83, + 0x3, 0xd3, 0x24, 0x14, 0xa2, 0x82, 0xb7, 0x1a, 0xbb, 0x59, 0xee, 0xc4, 0x17, 0x36, 0x0, 0x13, 0xf2, 0xd6, 0xc8, + 0x5c, 0x37, 0x77, 0xd1, 0x64, 0x4b, 0x63, 0x45, 0x7, 0x82, 0xce, 0x6, 0x73, 0x6a, 0xab, 0x9, 0x0, 0x13, 0x45, + 0xe9, 0x59, 0x21, 0x3b, 0x30, 0xb7, 0x58, 0xac, 0xed, 0xed, 0xfc, 0x39, 0x9, 0x2c, 0x12, 0xdd, 0x64, 0x5e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x75, 0x9c, 0x5a, 0xf4, 0x24}; + uint8_t bytesprops2[] = {0xe7, 0xde, 0xe9, 0x9d, 0x63, 0xb0, 0x70, 0xb3, 0x80, + 0xdc, 0x23, 0x2d, 0x69, 0x41, 0xd3, 0xdb, 0xf}; + uint8_t bytesprops1[] = {0xcf, 0xa1, 0x8c, 0x54, 0x14, 0x90, 0x4e, 0x36, 0x75, + 0x24, 0xa6, 0x8c, 0xd6, 0xb7, 0x30, 0x3b, 0xc7, 0x95}; + uint8_t bytesprops3[] = {0x5b, 0x6, 0xd3, 0xe8, 0xd6, 0x1c, 0x8c, 0x4, 0x12, 0x19, 0x70, 0xe8}; + uint8_t bytesprops4[] = {0x8b, 0x12, 0x22, 0xac, 0xd, 0x71, 0xac, 0x2c, 0x5e, 0x3b, + 0x58, 0x8f, 0xa7, 0x69, 0xe2, 0xe7, 0xdc, 0x6, 0x5c}; + uint8_t bytesprops5[] = {0x8d, 0xe, 0xc7, 0x6, 0xd9, 0xc8, 0xeb, 0xb4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28382}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28558}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21413}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6189}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5802}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {17, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9094}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21936}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc0, 0x70, 0x14, 0x59, 0xa, 0x99, 0x72, 0x16, 0xa2, 0xe3, 0x53, 0xa}; - uint8_t byteswillprops2[] = {0x76, 0xab, 0x3d, 0x8c, 0xe7, 0xb, 0x58, 0x5c, 0x43, - 0xf3, 0x70, 0xff, 0x3c, 0x54, 0xa, 0x53, 0x58}; - uint8_t byteswillprops1[] = {0x4, 0x81, 0x3c, 0x6c, 0x73, 0x61, 0xf2, 0x51, 0xea, 0x6d, - 0xf1, 0xb3, 0x5e, 0x54, 0x84, 0x1f, 0xf9, 0x7, 0x44, 0x9c}; - uint8_t byteswillprops3[] = {0xe5, 0xb7, 0xaf, 0xe6, 0x3a, 0x65, 0x66, 0x18, 0x3a, 0x42, 0x27, 0x26, 0xa3, 0xb7, - 0xd7, 0x6f, 0x2f, 0x74, 0x6e, 0x64, 0x67, 0x7a, 0x92, 0xa5, 0xef, 0xa2, 0xcd}; - uint8_t byteswillprops4[] = {0}; + uint8_t byteswillprops1[] = {0x5, 0x8e, 0x5d, 0x4c, 0x30, 0x62, 0xc9, 0xab, 0xfc, 0x14, 0x5c, 0x90, 0x7c, 0xa3, + 0xcb, 0x47, 0x1a, 0x78, 0xd6, 0xe8, 0xf3, 0x41, 0xc2, 0xd5, 0x9, 0x5d, 0x6}; + uint8_t byteswillprops0[] = {0x59, 0xcf, 0x0, 0x56}; + uint8_t byteswillprops2[] = {0xcf, 0x23, 0x9c, 0xfd, 0x69, 0x10, 0x38, 0xb1, + 0xfa, 0x74, 0xea, 0x40, 0x5e, 0xb, 0x38, 0x4a}; + uint8_t byteswillprops4[] = {0x15, 0xd0, 0xd, 0x2e, 0xf0, 0x5b, 0xde, 0x18, 0x82, 0xea, 0xe4, 0x93}; + uint8_t byteswillprops3[] = {0}; + uint8_t byteswillprops5[] = {0x1a, 0x45, 0xbf, 0x56, 0x1f, 0x45, 0x5e, 0xde, 0x7c, 0xd9, 0xcc, 0x27, 0x5f, 0xcc}; + uint8_t byteswillprops7[] = {0xfe, 0x79, 0x33, 0xfc, 0x2, 0x98, 0xb, 0x5f, 0x4b, 0x3e, 0xc2, 0xc0, 0x5, + 0x11, 0x93, 0x5e, 0x3f, 0x4e, 0x28, 0x92, 0x7e, 0x4c, 0x6f, 0x3f, 0x9f, 0x9b}; + uint8_t byteswillprops6[] = {0x3b, 0x2b, 0x9, 0x21, 0xe8, 0x7c, 0xba, 0x49, 0x8a, 0xc1, + 0x75, 0xb, 0x7e, 0xca, 0xb7, 0xe4, 0xac, 0x73, 0x5f, 0xae}; + uint8_t byteswillprops9[] = {0x30, 0xc2, 0xc9, 0x58, 0xeb, 0x8c, 0xf8, 0x31, 0x51, 0xe7, 0xcd, 0x2d, + 0xb4, 0x96, 0x1e, 0x44, 0x69, 0x68, 0x6f, 0x44, 0xd3, 0x39, 0x86}; + uint8_t byteswillprops8[] = {0}; + uint8_t byteswillprops10[] = {0xec, 0x54}; + uint8_t byteswillprops12[] = {0x76, 0x27, 0xb3, 0xb4, 0xbe, 0xa1, 0x2c, 0x7d, 0x49, 0xe2, 0xc9, 0x2a, 0xe1}; + uint8_t byteswillprops11[] = {0x3d, 0xc0, 0x78, 0xd9, 0x77, 0x5e, 0x82, 0x52, 0x49, 0x21, 0x7f, 0x3e, 0x59, + 0x3e, 0x43, 0xc6, 0xe9, 0x44, 0xdc, 0x60, 0x5c, 0x2c, 0x21, 0xc4, 0x1b}; + uint8_t byteswillprops13[] = {0xfc, 0x22, 0x30, 0xa7, 0x55, 0xfa, 0x23, 0x7c}; + uint8_t byteswillprops15[] = {0x5e, 0x2c, 0x85, 0x9e, 0x82, 0x24, 0x26, 0x1a, 0xc0, 0xec, 0x5, 0x30, 0xe7, 0x9e}; + uint8_t byteswillprops14[] = {0x2c, 0x9c, 0xf1, 0x95}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8921}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18066}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {4, (char*)&byteswillprops0}, .v = {27, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {0, (char*)&byteswillprops3}, .v = {12, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10395}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {20, (char*)&byteswillprops6}, .v = {26, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {0, (char*)&byteswillprops8}, .v = {23, (char*)&byteswillprops9}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18380}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 94}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {20, (char*)&byteswillprops1}, .v = {17, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops4}}}, + .value = {.pair = {.k = {25, (char*)&byteswillprops11}, .v = {13, (char*)&byteswillprops12}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12704}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&byteswillprops13}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {4, (char*)&byteswillprops14}, .v = {14, (char*)&byteswillprops15}}}}, }; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd9, 0x2b, 0x5c, 0x22, 0x2c, 0x73, 0x89, 0x19, 0xa5, 0xb7, - 0x7b, 0x76, 0x20, 0x99, 0x12, 0xd1, 0xea, 0xb7, 0x82, 0x60, - 0xb, 0x15, 0x93, 0xba, 0xf3, 0x66, 0xb6, 0xbd, 0xea}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe8, 0xf2, 0xda, 0xfc, 0x4b, 0xc9, 0xb4, 0x80, 0x32, 0xf7, 0xbe}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x83, 0x3, 0xd3, 0x24, 0x14, 0xa2, 0x82, 0xb7, + 0x1a, 0xbb, 0x59, 0xee, 0xc4, 0x17, 0x36}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf2, 0xd6, 0xc8, 0x5c, 0x37, 0x77, 0xd1, 0x64, 0x4b, 0x63, + 0x45, 0x7, 0x82, 0xce, 0x6, 0x73, 0x6a, 0xab, 0x9}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12023; - uint8_t client_id_bytes[] = {0xe4, 0x48, 0xa6, 0x8a, 0xd4, 0xfa, 0x63, 0xb4, 0x6a, 0x7e, 0x54}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 9686; + uint8_t client_id_bytes[] = {0xf2, 0x31, 0xae}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x4d, 0x88, 0x65, 0x22, 0xdb, 0x95, 0x7f, 0x5d, 0xd9, 0x71, 0xbd, 0xcb, 0x6, - 0xf6, 0x9f, 0x45, 0x9c, 0xa9, 0x8c, 0x1, 0x57, 0x73, 0x1f, 0xa5, 0xbe}; - lwmqtt_string_t password = {25, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x45, 0xe9, 0x59, 0x21, 0x3b, 0x30, 0xb7, 0x58, 0xac, 0xed, + 0xed, 0xfc, 0x39, 0x9, 0x2c, 0x12, 0xdd, 0x64, 0x5e}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8253,140 +8466,93 @@ TEST(Connect5QCTest, Encode16) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "|\155\165C", _willMsg = "\178\238\129\175W", _willProps = [PropWillDelayInterval -// 22403,PropMessageExpiryInterval 24373,PropServerReference "@\226\247\b\234\SUB",PropResponseTopic -// "5\"\218=Q&\194\GSBS,(\230\204\198\228\147\142.\200\180\240]\229\160\ETX\171\215B\199\214\&4\ETB",PropAssignedClientIdentifier "Re +// \SO?R",PropSessionExpiryInterval 14304,PropMessageExpiryInterval 23156,PropReasonString "D\"V"]} +TEST(Connect5QCTest, Encode16) { + uint8_t pkt[] = {0x10, 0x92, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x6c, 0x45, 0x66, 0x12, 0x0, 0x8, + 0xe5, 0x87, 0xb2, 0x1e, 0xc9, 0x37, 0x1f, 0xb4, 0x13, 0x10, 0x5e, 0x25, 0xe7, 0x18, 0x0, 0x0, 0x7b, + 0x8e, 0x27, 0x0, 0x0, 0x63, 0x5f, 0x1c, 0x0, 0x11, 0xea, 0x4c, 0xcd, 0x7f, 0x7e, 0x65, 0x64, 0xe1, + 0x5c, 0x86, 0x35, 0x35, 0x4d, 0x31, 0xbb, 0xee, 0x7f, 0x28, 0x52, 0x28, 0x14, 0x1c, 0x0, 0x18, 0xfc, + 0x3, 0x4, 0x70, 0x4d, 0x3e, 0xe4, 0x93, 0x8e, 0x2e, 0xc8, 0xb4, 0xf0, 0x5d, 0xe5, 0xa0, 0x3, 0xab, + 0xd7, 0x42, 0xc7, 0xd6, 0x34, 0x17, 0x12, 0x0, 0x6, 0x52, 0x65, 0x20, 0xe, 0x3f, 0x52, 0x11, 0x0, + 0x0, 0x37, 0xe0, 0x2, 0x0, 0x0, 0x5a, 0x74, 0x1f, 0x0, 0x3, 0x44, 0x22, 0x56, 0x0, 0x0, 0x0, + 0x7, 0xb2, 0xdd, 0xf8, 0x43, 0x8b, 0x38, 0x46, 0x0, 0x14, 0x5f, 0x18, 0xd0, 0x77, 0xef, 0xa, 0x1c, + 0x2a, 0xa8, 0x2a, 0x55, 0x1f, 0x11, 0x92, 0x3, 0x96, 0x12, 0xe, 0xf4, 0x45}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe5, 0x87, 0xb2, 0x1e, 0xc9, 0x37, 0x1f, 0xb4}; + uint8_t bytesprops1[] = {0xea, 0x4c, 0xcd, 0x7f, 0x7e, 0x65, 0x64, 0xe1, 0x5c, + 0x86, 0x35, 0x35, 0x4d, 0x31, 0xbb, 0xee, 0x7f}; + uint8_t bytesprops2[] = {0xfc, 0x3, 0x4, 0x70, 0x4d, 0x3e, 0xe4, 0x93, 0x8e, 0x2e, 0xc8, 0xb4, + 0xf0, 0x5d, 0xe5, 0xa0, 0x3, 0xab, 0xd7, 0x42, 0xc7, 0xd6, 0x34, 0x17}; + uint8_t bytesprops3[] = {0x52, 0x65, 0x20, 0xe, 0x3f, 0x52}; + uint8_t bytesprops4[] = {0x44, 0x22, 0x56}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16768}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6893}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30431}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17079}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16187}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4190}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31630}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25439}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14304}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23156}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops4}}}, }; lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 25768; - uint8_t client_id_bytes[] = {0xb1}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 27717; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xb2, 0xdd, 0xf8, 0x43, 0x8b, 0x38, 0x46}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x5f, 0x18, 0xd0, 0x77, 0xef, 0xa, 0x1c, 0x2a, 0xa8, 0x2a, + 0x55, 0x1f, 0x11, 0x92, 0x3, 0x96, 0x12, 0xe, 0xf4, 0x45}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "J\158\167\177\&3=j\176\214\201\193\&6w\169}", _password = Just +// "aA\246Ml\170b\195\217\197\232\210\143/A\222\200\147", _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 16521, _connID = "\186\RS\SYN\164\190\223\&0\237:(\242m\129\163\SIz\146x~R\202Dc\184\223\169\230\163", _properties = +// [PropServerReference "\149lz\STX3{]\194\249\&1\172\212E",PropAuthenticationData +// "L\233\DC4J\185\158\173Gc\237\184\206\140y\177\129\247\183bt\237~\236\207Z\236",PropCorrelationData +// "\151\191\170`\131\239\242>\206\FS\195\145\176\134\EM4", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS0, _willTopic = "\254", _willMsg = "\ETXm\199\156Oznd*\US\135*", _willProps = [PropMaximumQoS +// 208,PropSubscriptionIdentifierAvailable 66,PropContentType +// "\\=\188\DEL\a\ETB{\162\176\166\213\204C\204/",PropMessageExpiryInterval 17231,PropAuthenticationData +// "\191\SUBv\SYN\194X\240\233`\n",PropContentType "\232",PropAuthenticationMethod +// "j\202~%\186\ACKO\191\176\228S\US\204&\EOTI\218j\174\157\182\SI",PropServerReference +// "\US\DEL\EM\n\191\"\192\210z\NUL9\188\EOT\SO",PropTopicAliasMaximum 1458,PropRequestProblemInformation +// 2,PropReceiveMaximum 9909,PropWillDelayInterval 15809,PropMaximumQoS 199,PropReasonString +// "w\150S\a!0\188",PropCorrelationData "\180\226\b^\SYN\SYNO\242\132P]\152m\254G",PropSessionExpiryInterval +// 6495,PropServerReference "\217(Y\146C\165~zra",PropResponseTopic "\128",PropAssignedClientIdentifier +// "\DC4bJ\SUB\143\161\213\234\140y\248\219\227w+\230",PropWildcardSubscriptionAvailable 226,PropAuthenticationData +// "\163`\196Y\132\230\226\ENQ",PropReasonString +// "7\243\132x\205\248DI1\232\157\250ONuh\135%)J\242@\251Wu.\nP\160",PropResponseInformation +// "J\169",PropAuthenticationMethod "\249\173\EM.>\253\182/",PropTopicAlias 7781,PropRetainAvailable 43,PropUserProperty +// "w\231\170#\132>\GS\129F\186" "\229\177\182\139"]}), _cleanSession = True, _keepAlive = 17571, _connID = +// "}\227/\252\245n]F\190\242|\141\194\180\DLE\194\190\226W", _properties = [PropRequestResponseInformation +// 43,PropAssignedClientIdentifier +// "\238\145\253Gn\171\250\184\EOT\134\229\136\150\EOT\ENQb\155\236\CAN\b",PropWildcardSubscriptionAvailable +// 71,PropServerReference "\154\246\ENQ\207,_U\SI\180#d\210\243\193\223e\EOT\189J\141~",PropCorrelationData +// "n9\214\149h\205-D\172\228 ~\169\222\132w \141z",PropAssignedClientIdentifier +// "j\208\253Bb\237IT\147g\196\221\&5\229\129\205\152m\nZX",PropTopicAlias 31605,PropMessageExpiryInterval +// 32174,PropServerReference +// "\148\218\SUBe\215\194;L\138\224Z\182\ESC%-\154\243\135\DC4+\184\&0\ETX\189\254\224\195",PropWillDelayInterval +// 18475,PropWildcardSubscriptionAvailable 78,PropMaximumQoS 136,PropSessionExpiryInterval 372,PropTopicAlias +// 23001,PropContentType "I\188&\DC2YH\NULm\a\218#La\SYN3\225n\246\DC3\217&\SOc\143!\165x!\SOH",PropMaximumPacketSize +// 24916,PropSubscriptionIdentifier 10,PropRetainAvailable 242,PropUserProperty "" +// "\144f\168`\158Q\bo\234u\STX\131\223\175\FS`\140\223\199\246\142\134\168u\149\SI\SO\217",PropRequestProblemInformation +// 225,PropResponseInformation +// "\191\225\147\248H\136\196.iOA\173\CAN\133*\208\144\137\139'\233&",PropResponseInformation +// "\ACK{",PropSubscriptionIdentifierAvailable 203,PropRequestProblemInformation 90,PropServerKeepAlive +// 9708,PropServerReference "\230\199\140\GS,#\147\ESCYM\t\249"]} +TEST(Connect5QCTest, Encode18) { uint8_t pkt[] = { - 0x10, 0xdc, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x7a, 0xc1, 0x5e, 0x12, 0x0, 0xc, 0x94, 0x56, - 0x3a, 0x47, 0xd2, 0xb2, 0xfe, 0x55, 0x97, 0x18, 0x29, 0x31, 0x24, 0x7a, 0x19, 0x3d, 0x1a, 0x0, 0x9, 0x40, 0x69, - 0x21, 0x2e, 0x7e, 0xf, 0x1, 0xa2, 0x47, 0x25, 0xe8, 0x12, 0x0, 0x8, 0xb, 0x22, 0xb, 0xa0, 0x8e, 0xbf, 0x8c, - 0x1d, 0x28, 0x11, 0x3, 0x0, 0xc, 0x63, 0xbe, 0xdc, 0xe6, 0xc, 0x35, 0x2, 0x36, 0x6, 0x84, 0xdc, 0x6c, 0x28, - 0xdc, 0x28, 0xd1, 0x23, 0x10, 0x2c, 0x28, 0x2e, 0xb, 0x1c, 0x15, 0x0, 0x5, 0x8, 0xeb, 0x99, 0x47, 0x38, 0x2, - 0x0, 0x0, 0x30, 0xa3, 0x12, 0x0, 0x6, 0xb9, 0x3f, 0xcc, 0xc3, 0x20, 0x8f, 0x0, 0x0, 0xab, 0x1, 0x18, 0x0, - 0x0, 0x21, 0x4c, 0x26, 0x0, 0x15, 0x11, 0x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60, 0x69, 0x7f, 0x6a, 0xe6, 0x27, 0x79, 0xc6, 0x12, 0xf8, 0x65, 0x0, 0x8, 0xfd, 0x8, 0xe6, - 0xe0, 0xa0, 0x9a, 0x8a, 0xae, 0x0, 0x15, 0x62, 0x3b, 0x38, 0x7b, 0x20, 0x90, 0xb7, 0xa1, 0xc6, 0x61, 0x3, 0x3c, - 0x47, 0x8e, 0x1, 0xd9, 0x18, 0x62, 0xe, 0xda, 0xea}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x94, 0x56, 0x3a, 0x47, 0xd2, 0xb2, 0xfe, 0x55, 0x97, 0x18, 0x29, 0x31}; - uint8_t bytesprops1[] = {0x40, 0x69, 0x21, 0x2e, 0x7e, 0xf, 0x1, 0xa2, 0x47}; - uint8_t bytesprops2[] = {0xb, 0x22, 0xb, 0xa0, 0x8e, 0xbf, 0x8c, 0x1d}; - uint8_t bytesprops3[] = {0x63, 0xbe, 0xdc, 0xe6, 0xc, 0x35, 0x2, 0x36, 0x6, 0x84, 0xdc, 0x6c}; - uint8_t bytesprops4[] = {0x8, 0xeb, 0x99, 0x47, 0x38}; - uint8_t bytesprops5[] = {0xb9, 0x3f, 0xcc, 0xc3, 0x20, 0x8f}; + 0x10, 0xeb, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x44, 0xa3, 0x98, 0x2, 0x19, 0x2b, 0x12, 0x0, + 0x14, 0xee, 0x91, 0xfd, 0x47, 0x6e, 0xab, 0xfa, 0xb8, 0x4, 0x86, 0xe5, 0x88, 0x96, 0x4, 0x5, 0x62, 0x9b, 0xec, + 0x18, 0x8, 0x28, 0x47, 0x1c, 0x0, 0x15, 0x9a, 0xf6, 0x5, 0xcf, 0x2c, 0x5f, 0x55, 0xf, 0xb4, 0x23, 0x64, 0xd2, + 0xf3, 0xc1, 0xdf, 0x65, 0x4, 0xbd, 0x4a, 0x8d, 0x7e, 0x9, 0x0, 0x13, 0x6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0[] = {0xee, 0x91, 0xfd, 0x47, 0x6e, 0xab, 0xfa, 0xb8, 0x4, 0x86, + 0xe5, 0x88, 0x96, 0x4, 0x5, 0x62, 0x9b, 0xec, 0x18, 0x8}; + uint8_t bytesprops1[] = {0x9a, 0xf6, 0x5, 0xcf, 0x2c, 0x5f, 0x55, 0xf, 0xb4, 0x23, 0x64, + 0xd2, 0xf3, 0xc1, 0xdf, 0x65, 0x4, 0xbd, 0x4a, 0x8d, 0x7e}; + uint8_t bytesprops2[] = {0x6e, 0x39, 0xd6, 0x95, 0x68, 0xcd, 0x2d, 0x44, 0xac, 0xe4, + 0x20, 0x7e, 0xa9, 0xde, 0x84, 0x77, 0x20, 0x8d, 0x7a}; + uint8_t bytesprops3[] = {0x6a, 0xd0, 0xfd, 0x42, 0x62, 0xed, 0x49, 0x54, 0x93, 0x67, 0xc4, + 0xdd, 0x35, 0xe5, 0x81, 0xcd, 0x98, 0x6d, 0xa, 0x5a, 0x58}; + uint8_t bytesprops4[] = {0x94, 0xda, 0x1a, 0x65, 0xd7, 0xc2, 0x3b, 0x4c, 0x8a, 0xe0, 0x5a, 0xb6, 0x1b, 0x25, + 0x2d, 0x9a, 0xf3, 0x87, 0x14, 0x2b, 0xb8, 0x30, 0x3, 0xbd, 0xfe, 0xe0, 0xc3}; + uint8_t bytesprops5[] = {0x49, 0xbc, 0x26, 0x12, 0x59, 0x48, 0x0, 0x6d, 0x7, 0xda, 0x23, 0x4c, 0x61, 0x16, 0x33, + 0xe1, 0x6e, 0xf6, 0x13, 0xd9, 0x26, 0xe, 0x63, 0x8f, 0x21, 0xa5, 0x78, 0x21, 0x1}; + uint8_t bytesprops7[] = {0x90, 0x66, 0xa8, 0x60, 0x9e, 0x51, 0x8, 0x6f, 0xea, 0x75, 0x2, 0x83, 0xdf, 0xaf, + 0x1c, 0x60, 0x8c, 0xdf, 0xc7, 0xf6, 0x8e, 0x86, 0xa8, 0x75, 0x95, 0xf, 0xe, 0xd9}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops8[] = {0xbf, 0xe1, 0x93, 0xf8, 0x48, 0x88, 0xc4, 0x2e, 0x69, 0x4f, 0x41, + 0xad, 0x18, 0x85, 0x2a, 0xd0, 0x90, 0x89, 0x8b, 0x27, 0xe9, 0x26}; + uint8_t bytesprops9[] = {0x6, 0x7b}; + uint8_t bytesprops10[] = {0xe6, 0xc7, 0x8c, 0x1d, 0x2c, 0x23, 0x93, 0x1b, 0x59, 0x4d, 0x9, 0xf9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4140}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12451}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31605}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32174}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18475}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 372}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23001}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24916}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops6}, .v = {28, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9708}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x3, 0x2c, 0x2f, 0xb7, 0x75, 0x58, 0x91, 0xd4, 0x11, 0x78, 0xa6, 0x62, 0x5f, 0xfa, 0xbc, - 0xd2, 0x25, 0x46, 0xba, 0xf6, 0x66, 0x55, 0x62, 0xbc, 0xc4, 0x8c, 0xff, 0x18, 0xcc}; - uint8_t byteswillprops0[] = {0x11, 0x2c, 0xab, 0x4b, 0x43, 0x95, 0xa8, 0x6b, 0xb8, 0xbf, 0xa1, - 0x26, 0x34, 0x1e, 0x92, 0x19, 0xd8, 0x9f, 0xaa, 0x93, 0xb5}; - uint8_t byteswillprops2[] = {0xa7, 0xd4, 0x66, 0x5d, 0x81, 0x7a, 0xcb, 0xe2, 0x18, 0x81}; - uint8_t byteswillprops3[] = {0xed, 0x28, 0xbf, 0x15, 0xbe, 0xfa, 0x7b, 0xb6, 0x6e, 0x92}; - uint8_t byteswillprops4[] = {0xc3, 0x2b, 0x1b, 0x8d, 0x6c, 0xd2, 0x98, 0xf4, 0xa4, 0x5c, 0x3, 0xae, 0x95, 0xc, - 0x93, 0x17, 0x2c, 0x29, 0xdc, 0x18, 0x42, 0x35, 0x15, 0x6c, 0xc0, 0x9f, 0xbb, 0x8c}; - uint8_t byteswillprops5[] = {0x5, 0x67, 0x2f, 0x1a, 0xdc, 0x5b, 0x4f, 0x11}; - uint8_t byteswillprops6[] = {0x2d, 0x4d, 0x26, 0xbb, 0xd9, 0x31, 0xcd, 0x2}; + uint8_t byteswillprops0[] = {0x5c, 0x3d, 0xbc, 0x7f, 0x7, 0x17, 0x7b, 0xa2, 0xb0, 0xa6, 0xd5, 0xcc, 0x43, 0xcc, 0x2f}; + uint8_t byteswillprops1[] = {0xbf, 0x1a, 0x76, 0x16, 0xc2, 0x58, 0xf0, 0xe9, 0x60, 0xa}; + uint8_t byteswillprops2[] = {0xe8}; + uint8_t byteswillprops3[] = {0x6a, 0xca, 0x7e, 0x25, 0xba, 0x6, 0x4f, 0xbf, 0xb0, 0xe4, 0x53, + 0x1f, 0xcc, 0x26, 0x4, 0x49, 0xda, 0x6a, 0xae, 0x9d, 0xb6, 0xf}; + uint8_t byteswillprops4[] = {0x1f, 0x7f, 0x19, 0xa, 0xbf, 0x22, 0xc0, 0xd2, 0x7a, 0x0, 0x39, 0xbc, 0x4, 0xe}; + uint8_t byteswillprops5[] = {0x77, 0x96, 0x53, 0x7, 0x21, 0x30, 0xbc}; + uint8_t byteswillprops6[] = {0xb4, 0xe2, 0x8, 0x5e, 0x16, 0x16, 0x4f, 0xf2, 0x84, 0x50, 0x5d, 0x98, 0x6d, 0xfe, 0x47}; + uint8_t byteswillprops7[] = {0xd9, 0x28, 0x59, 0x92, 0x43, 0xa5, 0x7e, 0x7a, 0x72, 0x61}; + uint8_t byteswillprops8[] = {0x80}; + uint8_t byteswillprops9[] = {0x14, 0x62, 0x4a, 0x1a, 0x8f, 0xa1, 0xd5, 0xea, + 0x8c, 0x79, 0xf8, 0xdb, 0xe3, 0x77, 0x2b, 0xe6}; + uint8_t byteswillprops10[] = {0xa3, 0x60, 0xc4, 0x59, 0x84, 0xe6, 0xe2, 0x5}; + uint8_t byteswillprops11[] = {0x37, 0xf3, 0x84, 0x78, 0xcd, 0xf8, 0x44, 0x49, 0x31, 0xe8, + 0x9d, 0xfa, 0x4f, 0x4e, 0x75, 0x68, 0x87, 0x25, 0x29, 0x4a, + 0xf2, 0x40, 0xfb, 0x57, 0x75, 0x2e, 0xa, 0x50, 0xa0}; + uint8_t byteswillprops12[] = {0x4a, 0xa9}; + uint8_t byteswillprops13[] = {0xf9, 0xad, 0x19, 0x2e, 0x3e, 0xfd, 0xb6, 0x2f}; + uint8_t byteswillprops15[] = {0xe5, 0xb1, 0xb6, 0x8b}; + uint8_t byteswillprops14[] = {0x77, 0xe7, 0xaa, 0x23, 0x84, 0x3e, 0x1d, 0x81, 0x46, 0xba}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8524}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17231}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1458}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9909}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15809}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6495}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&byteswillprops12}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops13}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7781}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {21, (char*)&byteswillprops0}, .v = {29, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 400}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8793}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20707}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7219}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7627}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16916}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&byteswillprops6}}}, + .value = {.pair = {.k = {10, (char*)&byteswillprops14}, .v = {4, (char*)&byteswillprops15}}}}, }; - lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8d, 0xd5, 0xda, 0x3d, 0x3f, 0x15, 0xc3, 0x3f, 0x26, 0x2c, 0xf6}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x66, 0xbc, 0x72, 0x3, 0xa0, 0x7e, 0x5f, 0x68, 0x29, 0x60, - 0x69, 0x7f, 0x6a, 0xe6, 0x27, 0x79, 0xc6, 0x12, 0xf8, 0x65}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xfe}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3, 0x6d, 0xc7, 0x9c, 0x4f, 0x7a, 0x6e, 0x64, 0x2a, 0x1f, 0x87, 0x2a}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -8569,16 +8888,17 @@ TEST(Connect5QCTest, Encode19) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 31425; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.keep_alive = 17571; + uint8_t client_id_bytes[] = {0x7d, 0xe3, 0x2f, 0xfc, 0xf5, 0x6e, 0x5d, 0x46, 0xbe, 0xf2, + 0x7c, 0x8d, 0xc2, 0xb4, 0x10, 0xc2, 0xbe, 0xe2, 0x57}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xfd, 0x8, 0xe6, 0xe0, 0xa0, 0x9a, 0x8a, 0xae}; + uint8_t username_bytes[] = {0x4a, 0x1, 0x49, 0x2d, 0x7, 0x29, 0xf4, 0x65}; lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x62, 0x3b, 0x38, 0x7b, 0x20, 0x90, 0xb7, 0xa1, 0xc6, 0x61, 0x3, - 0x3c, 0x47, 0x8e, 0x1, 0xd9, 0x18, 0x62, 0xe, 0xda, 0xea}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x6f, 0xf9, 0xa, 0xef, 0x4a, 0xf9, 0x44, 0x3e, 0x83, 0xef, + 0xf2, 0x3e, 0xce, 0x1c, 0xc3, 0x91, 0xb0, 0x86, 0x19, 0x34}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8588,114 +8908,89 @@ TEST(Connect5QCTest, Encode19) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "IW[\248-[*\NAK\135jJJ\144\&4\148\131H\242IId\184\196a|CB\242\NAK\238", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = "c\228\141Pj\227\200\RS", _willMsg = -// "O\181\146\172\&8\200\165pw\156:\227\160\204\"\219-y\US\214\168{", _willProps = [PropReceiveMaximum -// 19134,PropRetainAvailable 127,PropResponseInformation " \219\233\SUB\240\237\195\US\184\201\231) -// I\209\185\163\245)\178",PropReceiveMaximum 2109,PropTopicAliasMaximum 26380,PropWillDelayInterval -// 25234,PropSharedSubscriptionAvailable 105,PropPayloadFormatIndicator 203,PropMessageExpiryInterval -// 6363,PropTopicAliasMaximum 29194,PropMaximumPacketSize 16405,PropSharedSubscriptionAvailable 200,PropTopicAlias -// 291,PropMessageExpiryInterval 21432,PropContentType -// "\228}\248\151\SYN\251\151\172r\186\156D\NUL\240,\157\207\234J\219\&5\136w\NAK\192\STX\222",PropMaximumQoS -// 117,PropMaximumQoS 164,PropMessageExpiryInterval 12769,PropResponseTopic -// "\FS\217L\218V1j7W\191\149\209\204\rQ\142\FS\217\195\254Z\237F\255\192>",PropWildcardSubscriptionAvailable -// 188,PropTopicAlias 20412,PropMessageExpiryInterval 20838]}), _cleanSession = False, _keepAlive = 18040, _connID = -// "\244\188\144", _properties = [PropSessionExpiryInterval 482,PropTopicAlias 11370,PropSubscriptionIdentifier -// 4,PropTopicAlias 22548,PropServerKeepAlive 20135,PropMessageExpiryInterval 12819,PropResponseTopic -// "\a\172).\155_&\186\bT\213\171h\128\&3b",PropMessageExpiryInterval 10474,PropAuthenticationData -// "\179\ETX%<#\253\182",PropRequestProblemInformation 150]} -TEST(Connect5QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0x9d, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x54, 0x46, 0x78, 0x39, 0x11, 0x0, 0x0, - 0x1, 0xe2, 0x23, 0x2c, 0x6a, 0xb, 0x4, 0x23, 0x58, 0x14, 0x13, 0x4e, 0xa7, 0x2, 0x0, 0x0, 0x32, - 0x13, 0x8, 0x0, 0x10, 0x7, 0xac, 0x29, 0x2e, 0x9b, 0x5f, 0x26, 0xba, 0x8, 0x54, 0xd5, 0xab, 0x68, - 0x80, 0x33, 0x62, 0x2, 0x0, 0x0, 0x28, 0xea, 0x16, 0x0, 0x7, 0xb3, 0x3, 0x25, 0x3c, 0x23, 0xfd, - 0xb6, 0x17, 0x96, 0x0, 0x3, 0xf4, 0xbc, 0x90, 0x90, 0x1, 0x21, 0x4a, 0xbe, 0x25, 0x7f, 0x1a, 0x0, - 0x14, 0x20, 0xdb, 0xe9, 0x1a, 0xf0, 0xed, 0xc3, 0x1f, 0xb8, 0xc9, 0xe7, 0x29, 0x20, 0x49, 0xd1, 0xb9, - 0xa3, 0xf5, 0x29, 0xb2, 0x21, 0x8, 0x3d, 0x22, 0x67, 0xc, 0x18, 0x0, 0x0, 0x62, 0x92, 0x2a, 0x69, - 0x1, 0xcb, 0x2, 0x0, 0x0, 0x18, 0xdb, 0x22, 0x72, 0xa, 0x27, 0x0, 0x0, 0x40, 0x15, 0x2a, 0xc8, - 0x23, 0x1, 0x23, 0x2, 0x0, 0x0, 0x53, 0xb8, 0x3, 0x0, 0x1b, 0xe4, 0x7d, 0xf8, 0x97, 0x16, 0xfb, - 0x97, 0xac, 0x72, 0xba, 0x9c, 0x44, 0x0, 0xf0, 0x2c, 0x9d, 0xcf, 0xea, 0x4a, 0xdb, 0x35, 0x88, 0x77, - 0x15, 0xc0, 0x2, 0xde, 0x24, 0x75, 0x24, 0xa4, 0x2, 0x0, 0x0, 0x31, 0xe1, 0x8, 0x0, 0x1a, 0x1c, - 0xd9, 0x4c, 0xda, 0x56, 0x31, 0x6a, 0x37, 0x57, 0xbf, 0x95, 0xd1, 0xcc, 0xd, 0x51, 0x8e, 0x1c, 0xd9, - 0xc3, 0xfe, 0x5a, 0xed, 0x46, 0xff, 0xc0, 0x3e, 0x28, 0xbc, 0x23, 0x4f, 0xbc, 0x2, 0x0, 0x0, 0x51, - 0x66, 0x0, 0x8, 0x63, 0xe4, 0x8d, 0x50, 0x6a, 0xe3, 0xc8, 0x1e, 0x0, 0x16, 0x4f, 0xb5, 0x92, 0xac, - 0x38, 0xc8, 0xa5, 0x70, 0x77, 0x9c, 0x3a, 0xe3, 0xa0, 0xcc, 0x22, 0xdb, 0x2d, 0x79, 0x1f, 0xd6, 0xa8, - 0x7b, 0x0, 0x1e, 0x49, 0x57, 0x5b, 0xf8, 0x2d, 0x5b, 0x2a, 0x15, 0x87, 0x6a, 0x4a, 0x4a, 0x90, 0x34, - 0x94, 0x83, 0x48, 0xf2, 0x49, 0x49, 0x64, 0xb8, 0xc4, 0x61, 0x7c, 0x43, 0x42, 0xf2, 0x15, 0xee}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7, 0xac, 0x29, 0x2e, 0x9b, 0x5f, 0x26, 0xba, - 0x8, 0x54, 0xd5, 0xab, 0x68, 0x80, 0x33, 0x62}; - uint8_t bytesprops1[] = {0xb3, 0x3, 0x25, 0x3c, 0x23, 0xfd, 0xb6}; +// ConnectRequest {_username = Nothing, _password = Just "\185\234\165\192W\204egO", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = +// "\254\234\SUB6\251\190\216\209\209\149\ETX\168\240\240\209\216\198rh\ETX\182!\187\172\232D", _willMsg = +// "\178\150\146w\234\131bw", _willProps = [PropMessageExpiryInterval 4700]}), _cleanSession = True, _keepAlive = 26206, +// _connID = "\225\SOY\244\214&\"\224\224\202\NAK\196\174", _properties = [PropPayloadFormatIndicator 165,PropMaximumQoS +// 15,PropReceiveMaximum 16602,PropServerKeepAlive 13964,PropServerKeepAlive 31602,PropUserProperty +// "\225\174\228\134A\183\144Y" +// "0\196\152\230\136!5.j\219a\216\192\190\&1\238\234g\DC2\166\217\204A\USb;",PropTopicAliasMaximum +// 28403,PropReceiveMaximum 24001,PropRetainAvailable 144,PropMaximumQoS 45,PropReceiveMaximum +// 6896,PropSubscriptionIdentifierAvailable 166,PropRetainAvailable 121,PropReceiveMaximum 4838,PropMaximumQoS +// 231,PropSharedSubscriptionAvailable 227,PropResponseInformation +// "\218\205\245\149\170m\201)WO\134\204\210",PropCorrelationData +// "\200\227!\\~\157\144\DC1\SOH",PropMessageExpiryInterval 24616,PropRetainAvailable 122]} +TEST(Connect5QCTest, Encode19) { + uint8_t pkt[] = {0x10, 0xc0, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x66, 0x5e, 0x6f, 0x1, 0xa5, 0x24, + 0xf, 0x21, 0x40, 0xda, 0x13, 0x36, 0x8c, 0x13, 0x7b, 0x72, 0x26, 0x0, 0x8, 0xe1, 0xae, 0xe4, 0x86, + 0x41, 0xb7, 0x90, 0x59, 0x0, 0x1a, 0x30, 0xc4, 0x98, 0xe6, 0x88, 0x21, 0x35, 0x2e, 0x6a, 0xdb, 0x61, + 0xd8, 0xc0, 0xbe, 0x31, 0xee, 0xea, 0x67, 0x12, 0xa6, 0xd9, 0xcc, 0x41, 0x1f, 0x62, 0x3b, 0x22, 0x6e, + 0xf3, 0x21, 0x5d, 0xc1, 0x25, 0x90, 0x24, 0x2d, 0x21, 0x1a, 0xf0, 0x29, 0xa6, 0x25, 0x79, 0x21, 0x12, + 0xe6, 0x24, 0xe7, 0x2a, 0xe3, 0x1a, 0x0, 0xd, 0xda, 0xcd, 0xf5, 0x95, 0xaa, 0x6d, 0xc9, 0x29, 0x57, + 0x4f, 0x86, 0xcc, 0xd2, 0x9, 0x0, 0x9, 0xc8, 0xe3, 0x21, 0x5c, 0x7e, 0x9d, 0x90, 0x11, 0x1, 0x2, + 0x0, 0x0, 0x60, 0x28, 0x25, 0x7a, 0x0, 0xd, 0xe1, 0xe, 0x59, 0xf4, 0xd6, 0x26, 0x22, 0xe0, 0xe0, + 0xca, 0x15, 0xc4, 0xae, 0x5, 0x2, 0x0, 0x0, 0x12, 0x5c, 0x0, 0x1a, 0xfe, 0xea, 0x1a, 0x36, 0xfb, + 0xbe, 0xd8, 0xd1, 0xd1, 0x95, 0x3, 0xa8, 0xf0, 0xf0, 0xd1, 0xd8, 0xc6, 0x72, 0x68, 0x3, 0xb6, 0x21, + 0xbb, 0xac, 0xe8, 0x44, 0x0, 0x8, 0xb2, 0x96, 0x92, 0x77, 0xea, 0x83, 0x62, 0x77, 0x0, 0x9, 0xb9, + 0xea, 0xa5, 0xc0, 0x57, 0xcc, 0x65, 0x67, 0x4f}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x30, 0xc4, 0x98, 0xe6, 0x88, 0x21, 0x35, 0x2e, 0x6a, 0xdb, 0x61, 0xd8, 0xc0, + 0xbe, 0x31, 0xee, 0xea, 0x67, 0x12, 0xa6, 0xd9, 0xcc, 0x41, 0x1f, 0x62, 0x3b}; + uint8_t bytesprops0[] = {0xe1, 0xae, 0xe4, 0x86, 0x41, 0xb7, 0x90, 0x59}; + uint8_t bytesprops2[] = {0xda, 0xcd, 0xf5, 0x95, 0xaa, 0x6d, 0xc9, 0x29, 0x57, 0x4f, 0x86, 0xcc, 0xd2}; + uint8_t bytesprops3[] = {0xc8, 0xe3, 0x21, 0x5c, 0x7e, 0x9d, 0x90, 0x11, 0x1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 482}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11370}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22548}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20135}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12819}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10474}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16602}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13964}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31602}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {26, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28403}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24001}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6896}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4838}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24616}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x20, 0xdb, 0xe9, 0x1a, 0xf0, 0xed, 0xc3, 0x1f, 0xb8, 0xc9, - 0xe7, 0x29, 0x20, 0x49, 0xd1, 0xb9, 0xa3, 0xf5, 0x29, 0xb2}; - uint8_t byteswillprops1[] = {0xe4, 0x7d, 0xf8, 0x97, 0x16, 0xfb, 0x97, 0xac, 0x72, 0xba, 0x9c, 0x44, 0x0, 0xf0, - 0x2c, 0x9d, 0xcf, 0xea, 0x4a, 0xdb, 0x35, 0x88, 0x77, 0x15, 0xc0, 0x2, 0xde}; - uint8_t byteswillprops2[] = {0x1c, 0xd9, 0x4c, 0xda, 0x56, 0x31, 0x6a, 0x37, 0x57, 0xbf, 0x95, 0xd1, 0xcc, - 0xd, 0x51, 0x8e, 0x1c, 0xd9, 0xc3, 0xfe, 0x5a, 0xed, 0x46, 0xff, 0xc0, 0x3e}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19134}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2109}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26380}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25234}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6363}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29194}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16405}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 291}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21432}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12769}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20412}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20838}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4700}}, }; - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x63, 0xe4, 0x8d, 0x50, 0x6a, 0xe3, 0xc8, 0x1e}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4f, 0xb5, 0x92, 0xac, 0x38, 0xc8, 0xa5, 0x70, 0x77, 0x9c, 0x3a, - 0xe3, 0xa0, 0xcc, 0x22, 0xdb, 0x2d, 0x79, 0x1f, 0xd6, 0xa8, 0x7b}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xfe, 0xea, 0x1a, 0x36, 0xfb, 0xbe, 0xd8, 0xd1, 0xd1, 0x95, 0x3, 0xa8, 0xf0, + 0xf0, 0xd1, 0xd8, 0xc6, 0x72, 0x68, 0x3, 0xb6, 0x21, 0xbb, 0xac, 0xe8, 0x44}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb2, 0x96, 0x92, 0x77, 0xea, 0x83, 0x62, 0x77}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 18040; - uint8_t client_id_bytes[] = {0xf4, 0xbc, 0x90}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 26206; + uint8_t client_id_bytes[] = {0xe1, 0xe, 0x59, 0xf4, 0xd6, 0x26, 0x22, 0xe0, 0xe0, 0xca, 0x15, 0xc4, 0xae}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x49, 0x57, 0x5b, 0xf8, 0x2d, 0x5b, 0x2a, 0x15, 0x87, 0x6a, 0x4a, 0x4a, 0x90, 0x34, 0x94, - 0x83, 0x48, 0xf2, 0x49, 0x49, 0x64, 0xb8, 0xc4, 0x61, 0x7c, 0x43, 0x42, 0xf2, 0x15, 0xee}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xb9, 0xea, 0xa5, 0xc0, 0x57, 0xcc, 0x65, 0x67, 0x4f}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8705,127 +9000,174 @@ TEST(Connect5QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "$\184\198/)\161\242\&4\202q.\235\175\183`h", _password = Nothing, _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\ETX-gs\242\r\246#:\255\212\251\221\STX#P", _willMsg = -// "\241\&7\183W", _willProps = [PropSubscriptionIdentifier 6,PropTopicAliasMaximum 26473,PropMaximumQoS -// 150,PropAssignedClientIdentifier "\244rQ",PropMaximumPacketSize 23974,PropSubscriptionIdentifierAvailable -// 160,PropAssignedClientIdentifier -// "*\160\213ln,\237\178\229\FS\213\146\212\253p\238\187m\STXK\212h\224\228\249\217\SI\239\ACK\224",PropWillDelayInterval -// 16452,PropResponseInformation -// "<\149\EOT\ETBRKz/V\224\147\196\r\161\137\241\141\198\216U\202w:1\164_\160\&0\191\169",PropPayloadFormatIndicator -// 66,PropRequestResponseInformation 230,PropResponseTopic -// "\208&\191:\194\ETB\254\252\246B\158\163\rD\169kV\EM\130T\227\201|g\164\US",PropReceiveMaximum -// 8181,PropSubscriptionIdentifier 22,PropSessionExpiryInterval 18537,PropWillDelayInterval 19433,PropUserProperty -// "\EOT\186\188\174\158C@\STXk" "\183\137~\242\139\&5\128\202\FSr\183\DLE\149|i\RSl\164",PropTopicAlias -// 17737,PropAuthenticationMethod "\145\240S!F\217\SYNH\173W\SOH",PropReasonString -// "\157m\SOH!",PropRequestProblemInformation 110,PropServerReference "\218m\SUB\253\206\137Vd\241",PropReasonString -// "\CANj\188\NAK\203\255k\243\211\237~\253\197\219x_0\207~\176\255\160\213\137S\168\146\DEL",PropContentType -// "\142<\128\\Y\158",PropWildcardSubscriptionAvailable 72,PropAuthenticationMethod -// ":o\163\244\234\212\131\157\DLE\252\160@\214\149\SOH\192\FSf\n\250:\220\206\219"]}), _cleanSession = False, -// _keepAlive = 6911, _connID = "Nr\151\198", _properties = [PropWildcardSubscriptionAvailable -// 158,PropSubscriptionIdentifier 17,PropContentType "\FS\226\218j\196",PropUserProperty "" -// "\174\242\166\220\171\RS\202\180T\ACK",PropMessageExpiryInterval 11680,PropContentType -// "\FS\NAK\FS!\226\242\237\179V\211i\198\206\138`\169zS\128\&3\130",PropRequestProblemInformation 175]} -TEST(Connect5QCTest, Encode21) { +// ConnectRequest {_username = Just "\204\&9\146\248Z\193\151\237F\231u\205\207?\138\180*}\164\191\"\DEL\198$\DC3", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\DC2L", _willMsg +// = "\187\173\179\182\226\182\159\197\SO<\158\197/\170\130\157\210\201\222", _willProps = +// [PropWildcardSubscriptionAvailable 155,PropReceiveMaximum 13368,PropTopicAlias 1094,PropPayloadFormatIndicator +// 168,PropServerReference ">N\140\223\STX\191\188",PropAuthenticationMethod +// "[?\151\222\162~-\216\151\207\220I\ENQ}\158\245\165Gz\180b\145\ETX\236G8",PropReceiveMaximum +// 18277,PropWildcardSubscriptionAvailable 8,PropContentType "\167\r\255F",PropServerKeepAlive 12961,PropServerReference +// "<^Z\144\US\193\139\172\RSI\136\207\251\199\a\SOHN\160\\6\131\138F3#",PropMaximumPacketSize +// 21589,PropRequestProblemInformation 203,PropContentType "<\159B\t\165\SI",PropResponseTopic +// "e\216\&8\CAN\ENQo\200\181:",PropWillDelayInterval 29867,PropRequestProblemInformation 101,PropSessionExpiryInterval +// 28255,PropTopicAlias 4921,PropReasonString +// "\168\r\255\184\180\\F=oR\250\150\&0\146E\210\246(\243O\a|\242\229\160\&3\249\179",PropCorrelationData +// "7\179B\155P\183M\203\129\DC3\182}]\205\218d\DC4WK\238\242\SYN(\155\134\NAK",PropMessageExpiryInterval +// 3794,PropReasonString "r\162\244\209\231\193\171\186\196\135\154\231\148\205\222",PropResponseTopic +// "An\155\199\233\172/\176\244\n\250\217\224\171\253\155\134\207Y\131\158\250\218",PropUserProperty +// "-\226qm\253\254\150\&1\141*.\158\195WHW\212\229" "u\183/`\160J",PropWillDelayInterval 29343,PropTopicAlias +// 28208,PropSessionExpiryInterval 21834,PropMaximumQoS 123]}), _cleanSession = False, _keepAlive = 15691, _connID = +// ",\205\DC2;&\213%\165D\167", _properties = [PropContentType +// "AN\t\205}\198'\191Fu\251\162\238\156\RSW\213o\241\&0n0G\210\134\211",PropServerReference +// "\ETB9~\206\US@\167\NAKl\139\DC1 \158;\152\162\180\181\207:\ETB{u\142\245\154\140w", _password = Just +// "\220\STXp\210}\178\179y\171", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "\187\ACK\FS\183\136\196\202@\150G&%;\224\149\140\ETB\223] \145\&61:y\199", _willMsg = "\218\200 +// \235O\SYN\vs\250\233G\156\217.\200\235x\198r\202fF\SUB\147\252\255\197", _willProps = [PropTopicAliasMaximum +// 23455,PropContentType "\137P\DEL\143\230",PropSessionExpiryInterval 23587,PropResponseTopic +// "\253::\n\226\&0A\247\244\238h?\DLE\SI$\224f\223\&3j",PropSubscriptionIdentifierAvailable +// 38,PropWildcardSubscriptionAvailable 173]}), _cleanSession = True, _keepAlive = 7593, _connID = "-e~\r", _properties +// = [PropAssignedClientIdentifier +// "6\206\179q\RS\212\246\&3\SOHS\244\200\172g\233\174\146\253S>",PropSubscriptionIdentifierAvailable +// 136,PropTopicAliasMaximum 12556,PropUserProperty "`t\aOK\207\193\250\244\175p0s\188\187\US\222\138\182\DLE\146YO'P&S" +// "\161\196ZR\186\EOTdx",PropRetainAvailable 66,PropMessageExpiryInterval 24590,PropAuthenticationData +// "\b\241\238\ETB&\234\134\SOHJ7f",PropSessionExpiryInterval 9944,PropPayloadFormatIndicator 154,PropMaximumPacketSize +// 3417,PropReasonString "\180\133\139i\197\205\201\193%\205\196m|\NAK\197\151-\a"]} +TEST(Connect5QCTest, Encode21) { + uint8_t pkt[] = { + 0x10, 0x8f, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x1d, 0xa9, 0x7a, 0x12, 0x0, 0x14, 0x36, 0xce, + 0xb3, 0x71, 0x1e, 0xd4, 0xf6, 0x33, 0x1, 0x53, 0xf4, 0xc8, 0xac, 0x67, 0xe9, 0xae, 0x92, 0xfd, 0x53, 0x3e, 0x29, + 0x88, 0x22, 0x31, 0xc, 0x26, 0x0, 0x1b, 0x60, 0x74, 0x7, 0x4f, 0x4b, 0xcf, 0xc1, 0xfa, 0xf4, 0xaf, 0x70, 0x30, + 0x73, 0xbc, 0xbb, 0x1f, 0xde, 0x8a, 0xb6, 0x10, 0x92, 0x59, 0x4f, 0x27, 0x50, 0x26, 0x53, 0x0, 0x8, 0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8c, 0x77, 0x0, 0x9, 0xdc, + 0x2, 0x70, 0xd2, 0x7d, 0xb2, 0xb3, 0x79, 0xab}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x36, 0xce, 0xb3, 0x71, 0x1e, 0xd4, 0xf6, 0x33, 0x1, 0x53, + 0xf4, 0xc8, 0xac, 0x67, 0xe9, 0xae, 0x92, 0xfd, 0x53, 0x3e}; + uint8_t bytesprops2[] = {0xa1, 0xc4, 0x5a, 0x52, 0xba, 0x4, 0x64, 0x78}; + uint8_t bytesprops1[] = {0x60, 0x74, 0x7, 0x4f, 0x4b, 0xcf, 0xc1, 0xfa, 0xf4, 0xaf, 0x70, 0x30, 0x73, 0xbc, + 0xbb, 0x1f, 0xde, 0x8a, 0xb6, 0x10, 0x92, 0x59, 0x4f, 0x27, 0x50, 0x26, 0x53}; + uint8_t bytesprops3[] = {0x8, 0xf1, 0xee, 0x17, 0x26, 0xea, 0x86, 0x1, 0x4a, 0x37, 0x66}; + uint8_t bytesprops4[] = {0xb4, 0x85, 0x8b, 0x69, 0xc5, 0xcd, 0xc9, 0xc1, 0x25, + 0xcd, 0xc4, 0x6d, 0x7c, 0x15, 0xc5, 0x97, 0x2d, 0x7}; lwmqtt_property_t propslist[] = { {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29289}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12556}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24590}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9944}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3417}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd3, 0xbf, 0xb5, 0x1e, 0xb7, 0x7a, 0xe3, 0xb3, 0x3f, - 0x31, 0x2, 0x71, 0xce, 0x5d, 0x8e, 0xd3, 0x76, 0x58}; - uint8_t byteswillprops1[] = {0xb1, 0xa7, 0xfa, 0x1, 0xba, 0x8, 0x45, 0xe, 0x40}; - uint8_t byteswillprops2[] = {0xb0, 0xad, 0x40, 0x26, 0x43, 0x4, 0xfd, 0x56, 0xb9, 0xe4, - 0xc3, 0xcc, 0xb, 0x8a, 0x61, 0xb0, 0xd, 0xa2, 0xe3, 0x78, - 0x92, 0xb7, 0xcc, 0x8c, 0x21, 0xb8, 0x63, 0x64, 0x18, 0xbf}; - uint8_t byteswillprops3[] = {0xde, 0x7d, 0x82, 0x86, 0xea, 0x6c, 0x7d, 0xc5, 0x2c}; - uint8_t byteswillprops4[] = {0xb, 0xcf, 0x1d, 0x1d, 0xe8, 0xa4, 0xe3}; + uint8_t byteswillprops0[] = {0x89, 0x50, 0x7f, 0x8f, 0xe6}; + uint8_t byteswillprops1[] = {0xfd, 0x3a, 0x3a, 0xa, 0xe2, 0x30, 0x41, 0xf7, 0xf4, 0xee, + 0x68, 0x3f, 0x10, 0xf, 0x24, 0xe0, 0x66, 0xdf, 0x33, 0x6a}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20521}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26988}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3468}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24720}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23455}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23587}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 173}}, }; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc4, 0xb, 0xca, 0xa8, 0x22, 0x73, 0x11, 0x2b, 0xde, - 0x80, 0x31, 0x8a, 0x59, 0xd0, 0x42, 0x70, 0xb2}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xbb, 0x6, 0x1c, 0xb7, 0x88, 0xc4, 0xca, 0x40, 0x96, 0x47, 0x26, 0x25, 0x3b, + 0xe0, 0x95, 0x8c, 0x17, 0xdf, 0x5d, 0x20, 0x91, 0x36, 0x31, 0x3a, 0x79, 0xc7}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xda, 0xc8, 0x20, 0xeb, 0x4f, 0x16, 0xb, 0x73, 0xfa, 0xe9, 0x47, 0x9c, 0xd9, 0x2e, + 0xc8, 0xeb, 0x78, 0xc6, 0x72, 0xca, 0x66, 0x46, 0x1a, 0x93, 0xfc, 0xff, 0xc5}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 11823; - uint8_t client_id_bytes[] = {0xd, 0xad, 0x43, 0x35, 0x24, 0x2b, 0x7e, 0x44, 0x6, 0xa9, 0x44, - 0xdc, 0xa0, 0xda, 0x83, 0x21, 0x42, 0x6f, 0xe, 0x9f, 0x48, 0x4e}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.keep_alive = 7593; + uint8_t client_id_bytes[] = {0x2d, 0x65, 0x7e, 0xd}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb2}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x54, 0x3e, 0x9e, 0x3b, 0x98, 0xa2, 0xb4, 0xb5, 0xcf, + 0x3a, 0x17, 0x7b, 0x75, 0x8e, 0xf5, 0x9a, 0x8c, 0x77}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0xdc, 0x2, 0x70, 0xd2, 0x7d, 0xb2, 0xb3, 0x79, 0xab}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8943,361 +9295,218 @@ TEST(Connect5QCTest, Encode22) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "M\162\184\&2\161L\154u\186\163\SYN\212\180\192S\137\a\169\&5\208Z\"\a\143{\DC1\246", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS0, _willTopic = -// "p\188\191\217S;m\n\EM\155\NAK\247\182\145\183\SYN\184\152\SUB\153\214-D\b\CAN\128", _willMsg = "\197p\131", -// _willProps = [PropAuthenticationData "BQ\128\208:t}\221E_\254m\210\231\202|qv",PropRequestResponseInformation -// 138,PropAuthenticationMethod -// "\208\240i\131\201msq\"A\NAK\157\EOT\250K\128\&9G\SUB\138i\"\247=\225*t;\191r",PropMessageExpiryInterval -// 26874,PropSubscriptionIdentifierAvailable 65,PropRetainAvailable 163,PropRetainAvailable 42,PropResponseInformation -// "\158\245'",PropWillDelayInterval 25424,PropResponseInformation -// "O\194\210\214\146_\"\198\186\160\ACK\254&\241\150\153\202\212\177`\183P\177\205\&2lW\148;\206",PropSubscriptionIdentifierAvailable -// 209,PropSubscriptionIdentifierAvailable 230,PropAuthenticationMethod -// "(\EOT\161RAV\133\DEL\188\197xc\177j\172R\146\130\220\238",PropTopicAliasMaximum 3668,PropResponseInformation -// "\230\247\249\170\237\ETB\145Y",PropReasonString -// "\173\166\137*,(\240)\226j6\245\146\211\149H\240\136{M\224\185\234",PropUserProperty -// "f\US\212\US\DC23\128a(\n\239\135\173\&2G\197P8" "\FS\212$U?\185V\n",PropMaximumQoS 190,PropServerReference -// "G\DC1\242\144~\188'f\STX&\175\SYN\187\&9J\131|P`\187j\239\163-;\GS\DLE\ETX",PropContentType "",PropRetainAvailable -// 40,PropMaximumQoS 215,PropSessionExpiryInterval 16670,PropAuthenticationMethod -// ">\DLE\193\229c}f;5\140\178\224\DEL`",PropSessionExpiryInterval 15432,PropServerKeepAlive 4678]}), _cleanSession = -// True, _keepAlive = 15472, _connID = "A\231\208\198C*2\172\&2\183\133\223\152\224(\129o\n\180MO\235Z\186\166\f", -// _properties = [PropReasonString -// "d\152+\222\212\199J\202o\181d\255\186\170qx\146y\\(\157\225G",PropMessageExpiryInterval 15061,PropRetainAvailable -// 245,PropMaximumPacketSize 383,PropSharedSubscriptionAvailable 221,PropSubscriptionIdentifierAvailable -// 102,PropTopicAlias 26828,PropRequestProblemInformation 207,PropSharedSubscriptionAvailable -// 151,PropSubscriptionIdentifier 1,PropTopicAliasMaximum 17,PropAuthenticationMethod -// "\ETXU#\142\201",PropAuthenticationData "\170\RSi\150\231\235O\a\SOr9",PropTopicAliasMaximum 3435,PropResponseTopic -// "B\152\165\&8\158\138\US\234\251'\214m\191\239\215\148)\195\245\b\240",PropTopicAlias 8929,PropTopicAliasMaximum -// 23322,PropResponseInformation "\187\178",PropWildcardSubscriptionAvailable 190,PropResponseInformation -// "\FSZb\238",PropReasonString "\160'\137\243\183|\137P\240\253\156\167|\168\158",PropUserProperty -// "\235\193G\GS\148\225vN\215~\233wk\130\131v&\251\243R5_\ncwOlK\212" -// "u\CAN\228\143\135\159\v\214\241\US\220\&1\248]\136",PropAuthenticationData "\DC2k%\nM\SOHc\RS\218\167\227"]} -TEST(Connect5QCTest, Encode23) { - uint8_t pkt[] = { - 0x10, 0xcb, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x66, 0x3c, 0x70, 0xcc, 0x1, 0x1f, 0x0, 0x17, 0x64, - 0x98, 0x2b, 0xde, 0xd4, 0xc7, 0x4a, 0xca, 0x6f, 0xb5, 0x64, 0xff, 0xba, 0xaa, 0x71, 0x78, 0x92, 0x79, 0x5c, 0x28, - 0x9d, 0xe1, 0x47, 0x2, 0x0, 0x0, 0x3a, 0xd5, 0x25, 0xf5, 0x27, 0x0, 0x0, 0x1, 0x7f, 0x2a, 0xdd, 0x29, 0x66, - 0x23, 0x68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66, 0x1f, 0xd4, 0x1f, 0x12, 0x33, 0x80, - 0x61, 0x28, 0xa, 0xef, 0x87, 0xad, 0x32, 0x47, 0xc5, 0x50, 0x38, 0x0, 0x8, 0x1c, 0xd4, 0x24, 0x55, 0x3f, 0xb9, - 0x56, 0xa, 0x24, 0xbe, 0x1c, 0x0, 0x1c, 0x47, 0x11, 0xf2, 0x90, 0x7e, 0xbc, 0x27, 0x66, 0x2, 0x26, 0xaf, 0x16, - 0xbb, 0x39, 0x4a, 0x83, 0x7c, 0x50, 0x60, 0xbb, 0x6a, 0xef, 0xa3, 0x2d, 0x3b, 0x1d, 0x10, 0x3, 0x3, 0x0, 0x0, - 0x25, 0x28, 0x24, 0xd7, 0x11, 0x0, 0x0, 0x41, 0x1e, 0x15, 0x0, 0xe, 0x3e, 0x10, 0xc1, 0xe5, 0x63, 0x7d, 0x66, - 0x3b, 0x35, 0x8c, 0xb2, 0xe0, 0x7f, 0x60, 0x11, 0x0, 0x0, 0x3c, 0x48, 0x13, 0x12, 0x46, 0x0, 0x1a, 0x70, 0xbc, - 0xbf, 0xd9, 0x53, 0x3b, 0x6d, 0xa, 0x19, 0x9b, 0x15, 0xf7, 0xb6, 0x91, 0xb7, 0x16, 0xb8, 0x98, 0x1a, 0x99, 0xd6, - 0x2d, 0x44, 0x8, 0x18, 0x80, 0x0, 0x3, 0xc5, 0x70, 0x83, 0x0, 0x1b, 0x4d, 0xa2, 0xb8, 0x32, 0xa1, 0x4c, 0x9a, - 0x75, 0xba, 0xa3, 0x16, 0xd4, 0xb4, 0xc0, 0x53, 0x89, 0x7, 0xa9, 0x35, 0xd0, 0x5a, 0x22, 0x7, 0x8f, 0x7b, 0x11, - 0xf6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x64, 0x98, 0x2b, 0xde, 0xd4, 0xc7, 0x4a, 0xca, 0x6f, 0xb5, 0x64, 0xff, - 0xba, 0xaa, 0x71, 0x78, 0x92, 0x79, 0x5c, 0x28, 0x9d, 0xe1, 0x47}; - uint8_t bytesprops1[] = {0x3, 0x55, 0x23, 0x8e, 0xc9}; - uint8_t bytesprops2[] = {0xaa, 0x1e, 0x69, 0x96, 0xe7, 0xeb, 0x4f, 0x7, 0xe, 0x72, 0x39}; - uint8_t bytesprops3[] = {0x42, 0x98, 0xa5, 0x38, 0x9e, 0x8a, 0x1f, 0xea, 0xfb, 0x27, 0xd6, - 0x6d, 0xbf, 0xef, 0xd7, 0x94, 0x29, 0xc3, 0xf5, 0x8, 0xf0}; - uint8_t bytesprops4[] = {0xbb, 0xb2}; - uint8_t bytesprops5[] = {0x1c, 0x5a, 0x62, 0xee}; - uint8_t bytesprops6[] = {0xa0, 0x27, 0x89, 0xf3, 0xb7, 0x7c, 0x89, 0x50, 0xf0, 0xfd, 0x9c, 0xa7, 0x7c, 0xa8, 0x9e}; - uint8_t bytesprops8[] = {0x75, 0x18, 0xe4, 0x8f, 0x87, 0x9f, 0xb, 0xd6, 0xf1, 0x1f, 0xdc, 0x31, 0xf8, 0x5d, 0x88}; - uint8_t bytesprops7[] = {0xeb, 0xc1, 0x47, 0x1d, 0x94, 0xe1, 0x76, 0x4e, 0xd7, 0x7e, 0xe9, 0x77, 0x6b, 0x82, 0x83, - 0x76, 0x26, 0xfb, 0xf3, 0x52, 0x35, 0x5f, 0xa, 0x63, 0x77, 0x4f, 0x6c, 0x4b, 0xd4}; - uint8_t bytesprops9[] = {0x12, 0x6b, 0x25, 0xa, 0x4d, 0x1, 0x63, 0x1e, 0xda, 0xa7, 0xe3}; +// ConnectRequest {_username = Just "/O\134\NAKdJ", _password = Just +// "\196\156\220\155\135\182\vb\vM\183\205\156r\135f`\148\245\162\148\&5\243`G\196\184*\154", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 23419, _connID = "\138\r,\181sl\193\231\232\198\"\231/\251W\218!s", _properties = +// [PropCorrelationData "\GS5\254T\162HT\191\187\252\211\216\254\DLE\220G\231\139s@\205\vW",PropSessionExpiryInterval +// 5360,PropAuthenticationMethod "\n$\206\231\251\249\174\STX+d@",PropCorrelationData +// "\136\156lg\DC1\184\233\219\242Ni\145\SO(\231",PropMessageExpiryInterval 5401,PropUserProperty +// "\n\237J\219o\201\186\n\242\238L\193\161\164\SOH\ACK\151\198" +// "1?\178\249\157\250l\128\169\186{\140\133\201ug\227\202\147\232t,\235\DC1\"\188\SOH"]} +TEST(Connect5QCTest, Encode22) { + uint8_t pkt[] = {0x10, 0xbc, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x5b, 0x7b, 0x76, 0x9, 0x0, + 0x17, 0x1d, 0x35, 0xfe, 0x54, 0xa2, 0x48, 0x54, 0xbf, 0xbb, 0xfc, 0xd3, 0xd8, 0xfe, 0x10, 0xdc, + 0x47, 0xe7, 0x8b, 0x73, 0x40, 0xcd, 0xb, 0x57, 0x11, 0x0, 0x0, 0x14, 0xf0, 0x15, 0x0, 0xb, + 0xa, 0x24, 0xce, 0xe7, 0xfb, 0xf9, 0xae, 0x2, 0x2b, 0x64, 0x40, 0x9, 0x0, 0xf, 0x88, 0x9c, + 0x6c, 0x67, 0x11, 0xb8, 0xe9, 0xdb, 0xf2, 0x4e, 0x69, 0x91, 0xe, 0x28, 0xe7, 0x2, 0x0, 0x0, + 0x15, 0x19, 0x26, 0x0, 0x12, 0xa, 0xed, 0x4a, 0xdb, 0x6f, 0xc9, 0xba, 0xa, 0xf2, 0xee, 0x4c, + 0xc1, 0xa1, 0xa4, 0x1, 0x6, 0x97, 0xc6, 0x0, 0x1b, 0x31, 0x3f, 0xb2, 0xf9, 0x9d, 0xfa, 0x6c, + 0x80, 0xa9, 0xba, 0x7b, 0x8c, 0x85, 0xc9, 0x75, 0x67, 0xe3, 0xca, 0x93, 0xe8, 0x74, 0x2c, 0xeb, + 0x11, 0x22, 0xbc, 0x1, 0x0, 0x12, 0x8a, 0xd, 0x2c, 0xb5, 0x73, 0x6c, 0xc1, 0xe7, 0xe8, 0xc6, + 0x22, 0xe7, 0x2f, 0xfb, 0x57, 0xda, 0x21, 0x73, 0x0, 0x6, 0x2f, 0x4f, 0x86, 0x15, 0x64, 0x4a, + 0x0, 0x1d, 0xc4, 0x9c, 0xdc, 0x9b, 0x87, 0xb6, 0xb, 0x62, 0xb, 0x4d, 0xb7, 0xcd, 0x9c, 0x72, + 0x87, 0x66, 0x60, 0x94, 0xf5, 0xa2, 0x94, 0x35, 0xf3, 0x60, 0x47, 0xc4, 0xb8, 0x2a, 0x9a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1d, 0x35, 0xfe, 0x54, 0xa2, 0x48, 0x54, 0xbf, 0xbb, 0xfc, 0xd3, 0xd8, + 0xfe, 0x10, 0xdc, 0x47, 0xe7, 0x8b, 0x73, 0x40, 0xcd, 0xb, 0x57}; + uint8_t bytesprops1[] = {0xa, 0x24, 0xce, 0xe7, 0xfb, 0xf9, 0xae, 0x2, 0x2b, 0x64, 0x40}; + uint8_t bytesprops2[] = {0x88, 0x9c, 0x6c, 0x67, 0x11, 0xb8, 0xe9, 0xdb, 0xf2, 0x4e, 0x69, 0x91, 0xe, 0x28, 0xe7}; + uint8_t bytesprops4[] = {0x31, 0x3f, 0xb2, 0xf9, 0x9d, 0xfa, 0x6c, 0x80, 0xa9, 0xba, 0x7b, 0x8c, 0x85, 0xc9, + 0x75, 0x67, 0xe3, 0xca, 0x93, 0xe8, 0x74, 0x2c, 0xeb, 0x11, 0x22, 0xbc, 0x1}; + uint8_t bytesprops3[] = {0xa, 0xed, 0x4a, 0xdb, 0x6f, 0xc9, 0xba, 0xa, 0xf2, + 0xee, 0x4c, 0xc1, 0xa1, 0xa4, 0x1, 0x6, 0x97, 0xc6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15061}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 383}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26828}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3435}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8929}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23322}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops7}, .v = {15, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops9}}}, - }; - - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x42, 0x51, 0x80, 0xd0, 0x3a, 0x74, 0x7d, 0xdd, 0x45, - 0x5f, 0xfe, 0x6d, 0xd2, 0xe7, 0xca, 0x7c, 0x71, 0x76}; - uint8_t byteswillprops1[] = {0xd0, 0xf0, 0x69, 0x83, 0xc9, 0x6d, 0x73, 0x71, 0x22, 0x41, - 0x15, 0x9d, 0x4, 0xfa, 0x4b, 0x80, 0x39, 0x47, 0x1a, 0x8a, - 0x69, 0x22, 0xf7, 0x3d, 0xe1, 0x2a, 0x74, 0x3b, 0xbf, 0x72}; - uint8_t byteswillprops2[] = {0x9e, 0xf5, 0x27}; - uint8_t byteswillprops3[] = {0x4f, 0xc2, 0xd2, 0xd6, 0x92, 0x5f, 0x22, 0xc6, 0xba, 0xa0, - 0x6, 0xfe, 0x26, 0xf1, 0x96, 0x99, 0xca, 0xd4, 0xb1, 0x60, - 0xb7, 0x50, 0xb1, 0xcd, 0x32, 0x6c, 0x57, 0x94, 0x3b, 0xce}; - uint8_t byteswillprops4[] = {0x28, 0x4, 0xa1, 0x52, 0x41, 0x56, 0x85, 0x7f, 0xbc, 0xc5, - 0x78, 0x63, 0xb1, 0x6a, 0xac, 0x52, 0x92, 0x82, 0xdc, 0xee}; - uint8_t byteswillprops5[] = {0xe6, 0xf7, 0xf9, 0xaa, 0xed, 0x17, 0x91, 0x59}; - uint8_t byteswillprops6[] = {0xad, 0xa6, 0x89, 0x2a, 0x2c, 0x28, 0xf0, 0x29, 0xe2, 0x6a, 0x36, 0xf5, - 0x92, 0xd3, 0x95, 0x48, 0xf0, 0x88, 0x7b, 0x4d, 0xe0, 0xb9, 0xea}; - uint8_t byteswillprops8[] = {0x1c, 0xd4, 0x24, 0x55, 0x3f, 0xb9, 0x56, 0xa}; - uint8_t byteswillprops7[] = {0x66, 0x1f, 0xd4, 0x1f, 0x12, 0x33, 0x80, 0x61, 0x28, - 0xa, 0xef, 0x87, 0xad, 0x32, 0x47, 0xc5, 0x50, 0x38}; - uint8_t byteswillprops9[] = {0x47, 0x11, 0xf2, 0x90, 0x7e, 0xbc, 0x27, 0x66, 0x2, 0x26, 0xaf, 0x16, 0xbb, 0x39, - 0x4a, 0x83, 0x7c, 0x50, 0x60, 0xbb, 0x6a, 0xef, 0xa3, 0x2d, 0x3b, 0x1d, 0x10, 0x3}; - uint8_t byteswillprops10[] = {0}; - uint8_t byteswillprops11[] = {0x3e, 0x10, 0xc1, 0xe5, 0x63, 0x7d, 0x66, 0x3b, 0x35, 0x8c, 0xb2, 0xe0, 0x7f, 0x60}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26874}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25424}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3668}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {18, (char*)&byteswillprops7}, .v = {8, (char*)&byteswillprops8}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16670}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15432}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4678}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5360}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5401}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops3}, .v = {27, (char*)&bytesprops4}}}}, }; - lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x70, 0xbc, 0xbf, 0xd9, 0x53, 0x3b, 0x6d, 0xa, 0x19, 0x9b, 0x15, 0xf7, 0xb6, - 0x91, 0xb7, 0x16, 0xb8, 0x98, 0x1a, 0x99, 0xd6, 0x2d, 0x44, 0x8, 0x18, 0x80}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc5, 0x70, 0x83}; - lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 15472; - uint8_t client_id_bytes[] = {0x41, 0xe7, 0xd0, 0xc6, 0x43, 0x2a, 0x32, 0xac, 0x32, 0xb7, 0x85, 0xdf, 0x98, - 0xe0, 0x28, 0x81, 0x6f, 0xa, 0xb4, 0x4d, 0x4f, 0xeb, 0x5a, 0xba, 0xa6, 0xc}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 23419; + uint8_t client_id_bytes[] = {0x8a, 0xd, 0x2c, 0xb5, 0x73, 0x6c, 0xc1, 0xe7, 0xe8, + 0xc6, 0x22, 0xe7, 0x2f, 0xfb, 0x57, 0xda, 0x21, 0x73}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x4d, 0xa2, 0xb8, 0x32, 0xa1, 0x4c, 0x9a, 0x75, 0xba, 0xa3, 0x16, 0xd4, 0xb4, 0xc0, - 0x53, 0x89, 0x7, 0xa9, 0x35, 0xd0, 0x5a, 0x22, 0x7, 0x8f, 0x7b, 0x11, 0xf6}; - lwmqtt_string_t password = {27, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x2f, 0x4f, 0x86, 0x15, 0x64, 0x4a}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xc4, 0x9c, 0xdc, 0x9b, 0x87, 0xb6, 0xb, 0x62, 0xb, 0x4d, 0xb7, 0xcd, 0x9c, 0x72, 0x87, + 0x66, 0x60, 0x94, 0xf5, 0xa2, 0x94, 0x35, 0xf3, 0x60, 0x47, 0xc4, 0xb8, 0x2a, 0x9a}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\ni\175J\146\197o\130\201\&8@\212x\172\ENQ\SOH!\164dU\\M\248\216\189", _password = -// Just "\EOT\128\CAN\203[\240\SYN\b", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\135\ESC\DLE|c.\180\189\232p\195\155\171=\246", _willMsg = -// "\137\150\171\227\191\DC2[m\203I\160\176\SO\193A\238\210F\180@$4\176\&8N\172\&5\234KO", _willProps = -// [PropSessionExpiryInterval 7133,PropUserProperty "\133Y?Y\179\206j\f\146\216L" -// "\243I\230",PropSubscriptionIdentifierAvailable 154,PropWildcardSubscriptionAvailable 226,PropAuthenticationMethod -// "\175\DC1\135\187\187\SOH\GS\FS\FSu'nj\129\240\&2&\233B\n\189\157",PropUserProperty -// "\EM\190{\130\213\171\144Ioy8\228\SIC\237\190;~\156{a\234" "\205*\174g\DC3",PropSubscriptionIdentifierAvailable -// 67,PropCorrelationData "E\243\234)n\145F\214\248F\214\182\190\ESC\GS\140{A",PropSubscriptionIdentifierAvailable -// 137,PropResponseInformation "f\DC1\227OJ\232k@r\178\STX\136\146M:)",PropMessageExpiryInterval -// 6568,PropPayloadFormatIndicator 105,PropResponseTopic "f",PropWillDelayInterval 30594,PropContentType -// "\245",PropRequestProblemInformation 216,PropAssignedClientIdentifier -// "\190\&9\vW~\162<\201\185\245j",PropResponseTopic -// "\189\186\246\132\145\NAKB\199\135r\148.\ACKs@[C(",PropMessageExpiryInterval 14746,PropMessageExpiryInterval -// 353,PropRetainAvailable 177,PropMaximumQoS 254,PropSessionExpiryInterval 5276,PropUserProperty -// "a\CAN^\200*\186\ETBb\211\239]%:\231\242" "",PropReasonString ";\191",PropContentType -// "72[9\149\CANs\178\&1\183\162\&0\238\151\ENQ\205cO\FS\235",PropAuthenticationMethod -// "C\223a\251\215\219UQ\138\&8\189",PropRequestResponseInformation 200]}), _cleanSession = True, _keepAlive = 17924, -// _connID = "a\NUL\161\b\145\247$\148\&9^N\209\CAN\SOHT\150\176%'\199\214\&5\131\202\185\208\145E1N", _properties = -// [PropRequestResponseInformation 82,PropAssignedClientIdentifier "i\141\231",PropAssignedClientIdentifier -// "@,L<\DC3\175\211q\162\&6?\tE",PropRetainAvailable 41,PropMaximumQoS 198,PropSubscriptionIdentifier -// 23,PropAssignedClientIdentifier -// "G\150\136\239$;\t\DC2\142\242k\NUL\FS[\239\STX\ESC\255KT\203\236\186&B",PropUserProperty "\241\244M\136.\242\167" -// "\188\143\"`\225K\207E\231\180\SUB9$M\147\193\142\174\230\231\t\SYNRS*\FS\235g,",PropServerReference -// "\t\192&\235\169\218\237\146\239u\201"]} -TEST(Connect5QCTest, Encode24) { +// ConnectRequest {_username = Just "\247\SI;~\246\226", _password = Just +// "\182\193\204\184\SI\251\239\221G\188,\207\181\222\169\DC2a\166\156\180\a\253\242", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\149\199O\138Vs\224&_\202\180\SYN\148\241G3\232\196)$~\216\157\181\176!", _willMsg = +// "_\241\DC4V97\239\206\170C\b\207\&9\170\141\GS3\216\234\DC4\141", _willProps = [PropServerKeepAlive +// 4144,PropServerReference "\228\t\\|9p\177cY\201",PropPayloadFormatIndicator 17,PropMaximumPacketSize +// 20879,PropSharedSubscriptionAvailable 15,PropSubscriptionIdentifierAvailable 73,PropSharedSubscriptionAvailable +// 183,PropSharedSubscriptionAvailable 31,PropRetainAvailable 84,PropContentType "",PropMaximumQoS +// 100,PropTopicAliasMaximum 28424,PropAuthenticationData +// "b`\DC1\163\155\163\176\237ey~\165\t\160\ETX\236Uz\228g\167\184=",PropReceiveMaximum 9949,PropAuthenticationData +// "\139i",PropSessionExpiryInterval 12502,PropReceiveMaximum 21847,PropMessageExpiryInterval +// 22456,PropResponseInformation "]Ygv\176G\225\v",PropReasonString "\153\DC2\173\149\144U"]}), _cleanSession = True, +// _keepAlive = 7, _connID = "G\\kY\SOH\242", _properties = [PropReceiveMaximum +// 28332,PropSubscriptionIdentifierAvailable 65,PropRetainAvailable 40,PropSharedSubscriptionAvailable +// 92,PropReasonString "v\166Gl>\177$\240",PropWillDelayInterval 25126,PropResponseInformation +// "\232a\180\140\245\200/Xo\187\138Cu.\212j\143",PropCorrelationData "z[T",PropSharedSubscriptionAvailable +// 108,PropRequestResponseInformation 45,PropMessageExpiryInterval 23632,PropCorrelationData +// "\132(\ETXKN\156p\142)\250\246o",PropMaximumQoS 78,PropResponseTopic +// "\148\173\132\171\SOH\232\rf\243\162nX\136\ETB",PropRequestResponseInformation 237,PropReasonString +// "\184\254\197\130\223LN\SYN\217\212\177\210g",PropAuthenticationMethod +// "\148\159&P\CAN\ACK\132\177x\182H\ENQ",PropSubscriptionIdentifierAvailable 126,PropWildcardSubscriptionAvailable +// 118,PropUserProperty "\238\192T\SO\250\171r!\208\DC3+\214\207\230\217Sj\nU<\232" +// "\141\&8\243\227f\229m",PropTopicAlias 1412,PropRequestProblemInformation 88,PropResponseTopic +// ".\242\156\164\DC1e%7]\200\201\NAK\212\211\&0t\230\CAN",PropReceiveMaximum 11196]} +TEST(Connect5QCTest, Encode23) { uint8_t pkt[] = { - 0x10, 0x81, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x46, 0x4, 0x71, 0x19, 0x52, 0x12, 0x0, 0x3, - 0x69, 0x8d, 0xe7, 0x12, 0x0, 0xd, 0x40, 0x2c, 0x4c, 0x3c, 0x13, 0xaf, 0xd3, 0x71, 0xa2, 0x36, 0x3f, 0x9, 0x45, - 0x25, 0x29, 0x24, 0xc6, 0xb, 0x17, 0x12, 0x0, 0x19, 0x47, 0x96, 0x88, 0xef, 0x24, 0x3b, 0x9, 0x12, 0x8e, 0xf2, - 0x6b, 0x0, 0x1c, 0x5b, 0xef, 0x2, 0x1b, 0xff, 0x4b, 0x54, 0xcb, 0xec, 0xba, 0x26, 0x42, 0x26, 0x0, 0x7, 0xf1, - 0xf4, 0x4d, 0x88, 0x2e, 0xf2, 0xa7, 0x0, 0x1d, 0xbc, 0x8f, 0x22, 0x60, 0xe1, 0x4b, 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d2, 0x46, 0xb4, 0x40, 0x24, 0x34, 0xb0, 0x38, 0x4e, 0xac, - 0x35, 0xea, 0x4b, 0x4f, 0x0, 0x19, 0xa, 0x69, 0xaf, 0x4a, 0x92, 0xc5, 0x6f, 0x82, 0xc9, 0x38, 0x40, 0xd4, 0x78, - 0xac, 0x5, 0x1, 0x21, 0xa4, 0x64, 0x55, 0x5c, 0x4d, 0xf8, 0xd8, 0xbd, 0x0, 0x8, 0x4, 0x80, 0x18, 0xcb, 0x5b, - 0xf0, 0x16, 0x8}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x69, 0x8d, 0xe7}; - uint8_t bytesprops1[] = {0x40, 0x2c, 0x4c, 0x3c, 0x13, 0xaf, 0xd3, 0x71, 0xa2, 0x36, 0x3f, 0x9, 0x45}; - uint8_t bytesprops2[] = {0x47, 0x96, 0x88, 0xef, 0x24, 0x3b, 0x9, 0x12, 0x8e, 0xf2, 0x6b, 0x0, 0x1c, - 0x5b, 0xef, 0x2, 0x1b, 0xff, 0x4b, 0x54, 0xcb, 0xec, 0xba, 0x26, 0x42}; - uint8_t bytesprops4[] = {0xbc, 0x8f, 0x22, 0x60, 0xe1, 0x4b, 0xcf, 0x45, 0xe7, 0xb4, 0x1a, 0x39, 0x24, 0x4d, 0x93, - 0xc1, 0x8e, 0xae, 0xe6, 0xe7, 0x9, 0x16, 0x52, 0x53, 0x2a, 0x1c, 0xeb, 0x67, 0x2c}; - uint8_t bytesprops3[] = {0xf1, 0xf4, 0x4d, 0x88, 0x2e, 0xf2, 0xa7}; - uint8_t bytesprops5[] = {0x9, 0xc0, 0x26, 0xeb, 0xa9, 0xda, 0xed, 0x92, 0xef, 0x75, 0xc9}; + 0x10, 0x96, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x0, 0x7, 0xc1, 0x1, 0x21, 0x6e, 0xac, 0x29, + 0x41, 0x25, 0x28, 0x2a, 0x5c, 0x1f, 0x0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 0xa9, 0x12, 0x61, 0xa6, 0x9c, 0xb4, 0x7, 0xfd, 0xf2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x76, 0xa6, 0x47, 0x6c, 0x3e, 0xb1, 0x24, 0xf0}; + uint8_t bytesprops1[] = {0xe8, 0x61, 0xb4, 0x8c, 0xf5, 0xc8, 0x2f, 0x58, 0x6f, + 0xbb, 0x8a, 0x43, 0x75, 0x2e, 0xd4, 0x6a, 0x8f}; + uint8_t bytesprops2[] = {0x7a, 0x5b, 0x54}; + uint8_t bytesprops3[] = {0x84, 0x28, 0x3, 0x4b, 0x4e, 0x9c, 0x70, 0x8e, 0x29, 0xfa, 0xf6, 0x6f}; + uint8_t bytesprops4[] = {0x94, 0xad, 0x84, 0xab, 0x1, 0xe8, 0xd, 0x66, 0xf3, 0xa2, 0x6e, 0x58, 0x88, 0x17}; + uint8_t bytesprops5[] = {0xb8, 0xfe, 0xc5, 0x82, 0xdf, 0x4c, 0x4e, 0x16, 0xd9, 0xd4, 0xb1, 0xd2, 0x67}; + uint8_t bytesprops6[] = {0x94, 0x9f, 0x26, 0x50, 0x18, 0x6, 0x84, 0xb1, 0x78, 0xb6, 0x48, 0x5}; + uint8_t bytesprops8[] = {0x8d, 0x38, 0xf3, 0xe3, 0x66, 0xe5, 0x6d}; + uint8_t bytesprops7[] = {0xee, 0xc0, 0x54, 0xe, 0xfa, 0xab, 0x72, 0x21, 0xd0, 0x13, 0x2b, + 0xd6, 0xcf, 0xe6, 0xd9, 0x53, 0x6a, 0xa, 0x55, 0x3c, 0xe8}; + uint8_t bytesprops9[] = {0x2e, 0xf2, 0x9c, 0xa4, 0x11, 0x65, 0x25, 0x37, 0x5d, + 0xc8, 0xc9, 0x15, 0xd4, 0xd3, 0x30, 0x74, 0xe6, 0x18}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {29, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28332}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25126}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23632}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops7}, .v = {7, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1412}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11196}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xf3, 0x49, 0xe6}; - uint8_t byteswillprops0[] = {0x85, 0x59, 0x3f, 0x59, 0xb3, 0xce, 0x6a, 0xc, 0x92, 0xd8, 0x4c}; - uint8_t byteswillprops2[] = {0xaf, 0x11, 0x87, 0xbb, 0xbb, 0x1, 0x1d, 0x1c, 0x1c, 0x75, 0x27, - 0x6e, 0x6a, 0x81, 0xf0, 0x32, 0x26, 0xe9, 0x42, 0xa, 0xbd, 0x9d}; - uint8_t byteswillprops4[] = {0xcd, 0x2a, 0xae, 0x67, 0x13}; - uint8_t byteswillprops3[] = {0x19, 0xbe, 0x7b, 0x82, 0xd5, 0xab, 0x90, 0x49, 0x6f, 0x79, 0x38, - 0xe4, 0xf, 0x43, 0xed, 0xbe, 0x3b, 0x7e, 0x9c, 0x7b, 0x61, 0xea}; - uint8_t byteswillprops5[] = {0x45, 0xf3, 0xea, 0x29, 0x6e, 0x91, 0x46, 0xd6, 0xf8, - 0x46, 0xd6, 0xb6, 0xbe, 0x1b, 0x1d, 0x8c, 0x7b, 0x41}; - uint8_t byteswillprops6[] = {0x66, 0x11, 0xe3, 0x4f, 0x4a, 0xe8, 0x6b, 0x40, - 0x72, 0xb2, 0x2, 0x88, 0x92, 0x4d, 0x3a, 0x29}; - uint8_t byteswillprops7[] = {0x66}; - uint8_t byteswillprops8[] = {0xf5}; - uint8_t byteswillprops9[] = {0xbe, 0x39, 0xb, 0x57, 0x7e, 0xa2, 0x3c, 0xc9, 0xb9, 0xf5, 0x6a}; - uint8_t byteswillprops10[] = {0xbd, 0xba, 0xf6, 0x84, 0x91, 0x15, 0x42, 0xc7, 0x87, - 0x72, 0x94, 0x2e, 0x6, 0x73, 0x40, 0x5b, 0x43, 0x28}; - uint8_t byteswillprops12[] = {0}; - uint8_t byteswillprops11[] = {0x61, 0x18, 0x5e, 0xc8, 0x2a, 0xba, 0x17, 0x62, - 0xd3, 0xef, 0x5d, 0x25, 0x3a, 0xe7, 0xf2}; - uint8_t byteswillprops13[] = {0x3b, 0xbf}; - uint8_t byteswillprops14[] = {0x37, 0x32, 0x5b, 0x39, 0x95, 0x18, 0x73, 0xb2, 0x31, 0xb7, - 0xa2, 0x30, 0xee, 0x97, 0x5, 0xcd, 0x63, 0x4f, 0x1c, 0xeb}; - uint8_t byteswillprops15[] = {0x43, 0xdf, 0x61, 0xfb, 0xd7, 0xdb, 0x55, 0x51, 0x8a, 0x38, 0xbd}; + uint8_t byteswillprops0[] = {0xe4, 0x9, 0x5c, 0x7c, 0x39, 0x70, 0xb1, 0x63, 0x59, 0xc9}; + uint8_t byteswillprops1[] = {0}; + uint8_t byteswillprops2[] = {0x62, 0x60, 0x11, 0xa3, 0x9b, 0xa3, 0xb0, 0xed, 0x65, 0x79, 0x7e, 0xa5, + 0x9, 0xa0, 0x3, 0xec, 0x55, 0x7a, 0xe4, 0x67, 0xa7, 0xb8, 0x3d}; + uint8_t byteswillprops3[] = {0x8b, 0x69}; + uint8_t byteswillprops4[] = {0x5d, 0x59, 0x67, 0x76, 0xb0, 0x47, 0xe1, 0xb}; + uint8_t byteswillprops5[] = {0x99, 0x12, 0xad, 0x95, 0x90, 0x55}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7133}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {11, (char*)&byteswillprops0}, .v = {3, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {22, (char*)&byteswillprops3}, .v = {5, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6568}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30594}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14746}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 353}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5276}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {15, (char*)&byteswillprops11}, .v = {0, (char*)&byteswillprops12}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops13}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&byteswillprops14}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&byteswillprops15}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4144}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20879}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28424}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9949}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12502}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21847}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22456}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&byteswillprops5}}}, }; - lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x87, 0x1b, 0x10, 0x7c, 0x63, 0x2e, 0xb4, 0xbd, - 0xe8, 0x70, 0xc3, 0x9b, 0xab, 0x3d, 0xf6}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x89, 0x96, 0xab, 0xe3, 0xbf, 0x12, 0x5b, 0x6d, 0xcb, 0x49, - 0xa0, 0xb0, 0xe, 0xc1, 0x41, 0xee, 0xd2, 0x46, 0xb4, 0x40, - 0x24, 0x34, 0xb0, 0x38, 0x4e, 0xac, 0x35, 0xea, 0x4b, 0x4f}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x95, 0xc7, 0x4f, 0x8a, 0x56, 0x73, 0xe0, 0x26, 0x5f, 0xca, 0xb4, 0x16, 0x94, + 0xf1, 0x47, 0x33, 0xe8, 0xc4, 0x29, 0x24, 0x7e, 0xd8, 0x9d, 0xb5, 0xb0, 0x21}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5f, 0xf1, 0x14, 0x56, 0x39, 0x37, 0xef, 0xce, 0xaa, 0x43, 0x8, + 0xcf, 0x39, 0xaa, 0x8d, 0x1d, 0x33, 0xd8, 0xea, 0x14, 0x8d}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS1; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 17924; - uint8_t client_id_bytes[] = {0x61, 0x0, 0xa1, 0x8, 0x91, 0xf7, 0x24, 0x94, 0x39, 0x5e, - 0x4e, 0xd1, 0x18, 0x1, 0x54, 0x96, 0xb0, 0x25, 0x27, 0xc7, - 0xd6, 0x35, 0x83, 0xca, 0xb9, 0xd0, 0x91, 0x45, 0x31, 0x4e}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.keep_alive = 7; + uint8_t client_id_bytes[] = {0x47, 0x5c, 0x6b, 0x59, 0x1, 0xf2}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa, 0x69, 0xaf, 0x4a, 0x92, 0xc5, 0x6f, 0x82, 0xc9, 0x38, 0x40, 0xd4, 0x78, - 0xac, 0x5, 0x1, 0x21, 0xa4, 0x64, 0x55, 0x5c, 0x4d, 0xf8, 0xd8, 0xbd}; - lwmqtt_string_t username = {25, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf7, 0xf, 0x3b, 0x7e, 0xf6, 0xe2}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x4, 0x80, 0x18, 0xcb, 0x5b, 0xf0, 0x16, 0x8}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xb6, 0xc1, 0xcc, 0xb8, 0xf, 0xfb, 0xef, 0xdd, 0x47, 0xbc, 0x2c, 0xcf, + 0xb5, 0xde, 0xa9, 0x12, 0x61, 0xa6, 0x9c, 0xb4, 0x7, 0xfd, 0xf2}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9307,270 +9516,233 @@ TEST(Connect5QCTest, Encode24) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "x\197,\208\aUF\242|z\244", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "9*J\v\172B:vV\252\US>YCPMxm", _willMsg = ">N", _willProps = -// [PropResponseTopic "Y\229",PropSharedSubscriptionAvailable 70,PropContentType -// "<}\160\148l\ETB\238\154\EOT\232\EM$}\231\218x\137\DC4\169\175\221\204\133\167\SOHS\145\147\240",PropRetainAvailable -// 142,PropServerKeepAlive 14211,PropMaximumPacketSize 12577,PropRequestProblemInformation 214,PropTopicAlias -// 18149,PropSessionExpiryInterval 6991,PropAuthenticationMethod "i\178",PropResponseTopic -// "\195\189\&2\183##\DLEC\198\145v\158\239\138\240\149\221\142_ep\229\192\252\252>\180",PropMaximumQoS -// 69,PropCorrelationData "y\STX\248",PropWillDelayInterval 2012,PropResponseTopic -// "\rB\197X\146\DLE\200\DC1#e\t\ACKz\v\141\229Kj\130\184\DC3",PropSubscriptionIdentifierAvailable 50,PropResponseTopic -// "\210\251wL \"\253\217\215\&5\191",PropWildcardSubscriptionAvailable 80]}), _cleanSession = False, _keepAlive = 8679, -// _connID = "\155\132j\168 \215\255w\SO\227", _properties = []} -TEST(Connect5QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0xd3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x74, 0x21, 0xe7, 0x0, 0x0, 0xa, 0x9b, - 0x84, 0x6a, 0xa8, 0x20, 0xd7, 0xff, 0x77, 0xe, 0xe3, 0x95, 0x1, 0x8, 0x0, 0x2, 0x59, 0xe5, 0x2a, - 0x46, 0x3, 0x0, 0x1d, 0x3c, 0x7d, 0xa0, 0x94, 0x6c, 0x17, 0xee, 0x9a, 0x4, 0xe8, 0x19, 0x24, 0x7d, - 0xe7, 0xda, 0x78, 0x89, 0x14, 0xa9, 0xaf, 0xdd, 0xcc, 0x85, 0xa7, 0x1, 0x53, 0x91, 0x93, 0xf0, 0x25, - 0x8e, 0x13, 0x37, 0x83, 0x27, 0x0, 0x0, 0x31, 0x21, 0x17, 0xd6, 0x23, 0x46, 0xe5, 0x11, 0x0, 0x0, - 0x1b, 0x4f, 0x15, 0x0, 0x2, 0x69, 0xb2, 0x8, 0x0, 0x1b, 0xc3, 0xbd, 0x32, 0xb7, 0x23, 0x23, 0x10, - 0x43, 0xc6, 0x91, 0x76, 0x9e, 0xef, 0x8a, 0xf0, 0x95, 0xdd, 0x8e, 0x5f, 0x65, 0x70, 0xe5, 0xc0, 0xfc, - 0xfc, 0x3e, 0xb4, 0x24, 0x45, 0x9, 0x0, 0x3, 0x79, 0x2, 0xf8, 0x18, 0x0, 0x0, 0x7, 0xdc, 0x8, - 0x0, 0x15, 0xd, 0x42, 0xc5, 0x58, 0x92, 0x10, 0xc8, 0x11, 0x23, 0x65, 0x9, 0x6, 0x7a, 0xb, 0x8d, - 0xe5, 0x4b, 0x6a, 0x82, 0xb8, 0x13, 0x29, 0x32, 0x8, 0x0, 0xb, 0xd2, 0xfb, 0x77, 0x4c, 0x20, 0x22, - 0xfd, 0xd9, 0xd7, 0x35, 0xbf, 0x28, 0x50, 0x0, 0x12, 0x39, 0x2a, 0x4a, 0xb, 0xac, 0x42, 0x3a, 0x76, - 0x56, 0xfc, 0x1f, 0x3e, 0x59, 0x43, 0x50, 0x4d, 0x78, 0x6d, 0x0, 0x2, 0x3e, 0x4e, 0x0, 0xb, 0x78, - 0xc5, 0x2c, 0xd0, 0x7, 0x55, 0x46, 0xf2, 0x7c, 0x7a, 0xf4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "{?~\139\226tEG\tA\FSI\236\230e<\SOH", _password = Just +// "\203)t\136\")\169\SID\246\237\158\241\231\162>!\140", _lastWill = Nothing, _cleanSession = True, _keepAlive = 8810, +// _connID = "n\253\208>\v\187pU\197NY\228\&5w!\237\179\179\SI\213", _properties = [PropCorrelationData +// "B\236?\nv",PropRetainAvailable 20,PropRetainAvailable 236,PropCorrelationData "",PropCorrelationData +// "\194\208\144\170\133[{\239\209\177\248\176\210\142\SUB\202\181\170",PropMessageExpiryInterval +// 17662,PropAuthenticationData "\203\150S\135\&7S",PropSessionExpiryInterval 20993,PropRequestProblemInformation +// 178,PropServerKeepAlive 2714,PropReasonString "`\141\230\192 \243p\233,b\nP\DC4\199\n}"]} +TEST(Connect5QCTest, Encode24) { + uint8_t pkt[] = {0x10, 0x97, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x22, 0x6a, 0x4f, 0x9, 0x0, + 0x5, 0x42, 0xec, 0x3f, 0xa, 0x76, 0x25, 0x14, 0x25, 0xec, 0x9, 0x0, 0x0, 0x9, 0x0, 0x12, + 0xc2, 0xd0, 0x90, 0xaa, 0x85, 0x5b, 0x7b, 0xef, 0xd1, 0xb1, 0xf8, 0xb0, 0xd2, 0x8e, 0x1a, 0xca, + 0xb5, 0xaa, 0x2, 0x0, 0x0, 0x44, 0xfe, 0x16, 0x0, 0x6, 0xcb, 0x96, 0x53, 0x87, 0x37, 0x53, + 0x11, 0x0, 0x0, 0x52, 0x1, 0x17, 0xb2, 0x13, 0xa, 0x9a, 0x1f, 0x0, 0x10, 0x60, 0x8d, 0xe6, + 0xc0, 0x20, 0xf3, 0x70, 0xe9, 0x2c, 0x62, 0xa, 0x50, 0x14, 0xc7, 0xa, 0x7d, 0x0, 0x14, 0x6e, + 0xfd, 0xd0, 0x3e, 0xb, 0xbb, 0x70, 0x55, 0xc5, 0x4e, 0x59, 0xe4, 0x35, 0x77, 0x21, 0xed, 0xb3, + 0xb3, 0xf, 0xd5, 0x0, 0x11, 0x7b, 0x3f, 0x7e, 0x8b, 0xe2, 0x74, 0x45, 0x47, 0x9, 0x41, 0x1c, + 0x49, 0xec, 0xe6, 0x65, 0x3c, 0x1, 0x0, 0x12, 0xcb, 0x29, 0x74, 0x88, 0x22, 0x29, 0xa9, 0xf, + 0x44, 0xf6, 0xed, 0x9e, 0xf1, 0xe7, 0xa2, 0x3e, 0x21, 0x8c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x42, 0xec, 0x3f, 0xa, 0x76}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0xc2, 0xd0, 0x90, 0xaa, 0x85, 0x5b, 0x7b, 0xef, 0xd1, + 0xb1, 0xf8, 0xb0, 0xd2, 0x8e, 0x1a, 0xca, 0xb5, 0xaa}; + uint8_t bytesprops3[] = {0xcb, 0x96, 0x53, 0x87, 0x37, 0x53}; + uint8_t bytesprops4[] = {0x60, 0x8d, 0xe6, 0xc0, 0x20, 0xf3, 0x70, 0xe9, + 0x2c, 0x62, 0xa, 0x50, 0x14, 0xc7, 0xa, 0x7d}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x59, 0xe5}; - uint8_t byteswillprops1[] = {0x3c, 0x7d, 0xa0, 0x94, 0x6c, 0x17, 0xee, 0x9a, 0x4, 0xe8, 0x19, 0x24, 0x7d, 0xe7, 0xda, - 0x78, 0x89, 0x14, 0xa9, 0xaf, 0xdd, 0xcc, 0x85, 0xa7, 0x1, 0x53, 0x91, 0x93, 0xf0}; - uint8_t byteswillprops2[] = {0x69, 0xb2}; - uint8_t byteswillprops3[] = {0xc3, 0xbd, 0x32, 0xb7, 0x23, 0x23, 0x10, 0x43, 0xc6, 0x91, 0x76, 0x9e, 0xef, 0x8a, - 0xf0, 0x95, 0xdd, 0x8e, 0x5f, 0x65, 0x70, 0xe5, 0xc0, 0xfc, 0xfc, 0x3e, 0xb4}; - uint8_t byteswillprops4[] = {0x79, 0x2, 0xf8}; - uint8_t byteswillprops5[] = {0xd, 0x42, 0xc5, 0x58, 0x92, 0x10, 0xc8, 0x11, 0x23, 0x65, 0x9, - 0x6, 0x7a, 0xb, 0x8d, 0xe5, 0x4b, 0x6a, 0x82, 0xb8, 0x13}; - uint8_t byteswillprops6[] = {0xd2, 0xfb, 0x77, 0x4c, 0x20, 0x22, 0xfd, 0xd9, 0xd7, 0x35, 0xbf}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17662}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20993}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2714}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops4}}}, + }; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14211}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12577}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18149}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6991}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2012}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 80}}, + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 8810; + uint8_t client_id_bytes[] = {0x6e, 0xfd, 0xd0, 0x3e, 0xb, 0xbb, 0x70, 0x55, 0xc5, 0x4e, + 0x59, 0xe4, 0x35, 0x77, 0x21, 0xed, 0xb3, 0xb3, 0xf, 0xd5}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x7b, 0x3f, 0x7e, 0x8b, 0xe2, 0x74, 0x45, 0x47, 0x9, + 0x41, 0x1c, 0x49, 0xec, 0xe6, 0x65, 0x3c, 0x1}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xcb, 0x29, 0x74, 0x88, 0x22, 0x29, 0xa9, 0xf, 0x44, + 0xf6, 0xed, 0x9e, 0xf1, 0xe7, 0xa2, 0x3e, 0x21, 0x8c}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\132\241o\219m\247lL]\193i\175", _password = Just "\CANv\229k\211\205", _lastWill = +// Nothing, _cleanSession = True, _keepAlive = 7935, _connID = "\ETB\208H\169\248J\183R\169p\FS\190\DEL\182~\SYN", +// _properties = [PropResponseTopic +// "i*\133\206UW\139\190%\GS\165k\201\235\SUB6\SI\144_\163\253\202\213\166\195\142b\129",PropTopicAlias +// 10431,PropSharedSubscriptionAvailable 196,PropRequestResponseInformation 254,PropRetainAvailable +// 177,PropRetainAvailable 212,PropSubscriptionIdentifierAvailable 115,PropMessageExpiryInterval +// 29471,PropSubscriptionIdentifierAvailable 136,PropMessageExpiryInterval 6213,PropSubscriptionIdentifierAvailable +// 83,PropRequestResponseInformation 215,PropUserProperty "\168+0\142;\DC3\NUL\213}\187\n^W\132[MN\234" +// "\165\138\213",PropContentType "-n\146f'\180h\159\250F\157d8$\177\210JU\SO\197",PropCorrelationData +// "",PropServerKeepAlive 30727,PropRequestProblemInformation 223,PropSubscriptionIdentifier 17,PropServerKeepAlive +// 5564,PropWildcardSubscriptionAvailable 12]} +TEST(Connect5QCTest, Encode25) { + uint8_t pkt[] = {0x10, 0xaf, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x1e, 0xff, 0x7c, 0x8, 0x0, 0x1c, + 0x69, 0x2a, 0x85, 0xce, 0x55, 0x57, 0x8b, 0xbe, 0x25, 0x1d, 0xa5, 0x6b, 0xc9, 0xeb, 0x1a, 0x36, 0xf, + 0x90, 0x5f, 0xa3, 0xfd, 0xca, 0xd5, 0xa6, 0xc3, 0x8e, 0x62, 0x81, 0x23, 0x28, 0xbf, 0x2a, 0xc4, 0x19, + 0xfe, 0x25, 0xb1, 0x25, 0xd4, 0x29, 0x73, 0x2, 0x0, 0x0, 0x73, 0x1f, 0x29, 0x88, 0x2, 0x0, 0x0, + 0x18, 0x45, 0x29, 0x53, 0x19, 0xd7, 0x26, 0x0, 0x12, 0xa8, 0x2b, 0x30, 0x8e, 0x3b, 0x13, 0x0, 0xd5, + 0x7d, 0xbb, 0xa, 0x5e, 0x57, 0x84, 0x5b, 0x4d, 0x4e, 0xea, 0x0, 0x3, 0xa5, 0x8a, 0xd5, 0x3, 0x0, + 0x14, 0x2d, 0x6e, 0x92, 0x66, 0x27, 0xb4, 0x68, 0x9f, 0xfa, 0x46, 0x9d, 0x64, 0x38, 0x24, 0xb1, 0xd2, + 0x4a, 0x55, 0xe, 0xc5, 0x9, 0x0, 0x0, 0x13, 0x78, 0x7, 0x17, 0xdf, 0xb, 0x11, 0x13, 0x15, 0xbc, + 0x28, 0xc, 0x0, 0x10, 0x17, 0xd0, 0x48, 0xa9, 0xf8, 0x4a, 0xb7, 0x52, 0xa9, 0x70, 0x1c, 0xbe, 0x7f, + 0xb6, 0x7e, 0x16, 0x0, 0xc, 0x84, 0xf1, 0x6f, 0xdb, 0x6d, 0xf7, 0x6c, 0x4c, 0x5d, 0xc1, 0x69, 0xaf, + 0x0, 0x6, 0x18, 0x76, 0xe5, 0x6b, 0xd3, 0xcd}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x69, 0x2a, 0x85, 0xce, 0x55, 0x57, 0x8b, 0xbe, 0x25, 0x1d, 0xa5, 0x6b, 0xc9, 0xeb, + 0x1a, 0x36, 0xf, 0x90, 0x5f, 0xa3, 0xfd, 0xca, 0xd5, 0xa6, 0xc3, 0x8e, 0x62, 0x81}; + uint8_t bytesprops2[] = {0xa5, 0x8a, 0xd5}; + uint8_t bytesprops1[] = {0xa8, 0x2b, 0x30, 0x8e, 0x3b, 0x13, 0x0, 0xd5, 0x7d, + 0xbb, 0xa, 0x5e, 0x57, 0x84, 0x5b, 0x4d, 0x4e, 0xea}; + uint8_t bytesprops3[] = {0x2d, 0x6e, 0x92, 0x66, 0x27, 0xb4, 0x68, 0x9f, 0xfa, 0x46, + 0x9d, 0x64, 0x38, 0x24, 0xb1, 0xd2, 0x4a, 0x55, 0xe, 0xc5}; + uint8_t bytesprops4[] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10431}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29471}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6213}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {3, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30727}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5564}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 12}}, }; - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x39, 0x2a, 0x4a, 0xb, 0xac, 0x42, 0x3a, 0x76, 0x56, - 0xfc, 0x1f, 0x3e, 0x59, 0x43, 0x50, 0x4d, 0x78, 0x6d}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3e, 0x4e}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 8679; - uint8_t client_id_bytes[] = {0x9b, 0x84, 0x6a, 0xa8, 0x20, 0xd7, 0xff, 0x77, 0xe, 0xe3}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 7935; + uint8_t client_id_bytes[] = {0x17, 0xd0, 0x48, 0xa9, 0xf8, 0x4a, 0xb7, 0x52, + 0xa9, 0x70, 0x1c, 0xbe, 0x7f, 0xb6, 0x7e, 0x16}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x78, 0xc5, 0x2c, 0xd0, 0x7, 0x55, 0x46, 0xf2, 0x7c, 0x7a, 0xf4}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x84, 0xf1, 0x6f, 0xdb, 0x6d, 0xf7, 0x6c, 0x4c, 0x5d, 0xc1, 0x69, 0xaf}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x18, 0x76, 0xe5, 0x6b, 0xd3, 0xcd}; + lwmqtt_string_t password = {6, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "#*\SUB\197/r\203", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS0, _willTopic = "G@v wb\253\GSb\212", _willMsg = -// "\SYN\"mo\233lbY\DC3\160\156\230\206`\226J|\232", _willProps = [PropRetainAvailable 151,PropContentType -// "D\"\200\154\225\209\RS6t\244\230\STX\137\242\173Cr\DC2\187\244\140",PropAuthenticationData -// ".\171\DC3\196\128\139\146\170b\253\161",PropSharedSubscriptionAvailable 227,PropMessageExpiryInterval -// 4451,PropWildcardSubscriptionAvailable 107,PropSessionExpiryInterval 27000,PropRetainAvailable -// 98,PropPayloadFormatIndicator 23,PropUserProperty "\208y\151M\DC4\138\&6J$\170\DC1\152\208\243\ENQ\194\196\tm\SO789c" -// "\DC34\141\STX\SYNW\247\152r'\149\252Z\140$\t\ENQ[\143",PropResponseInformation -// "\STXq[\174\156\&0",PropResponseInformation "yl!\212\254 fp\180\ETBf\168j",PropResponseTopic -// "\254",PropRequestResponseInformation 67,PropRequestProblemInformation 67,PropPayloadFormatIndicator -// 234,PropCorrelationData "\128\189t\223\b\189\226\198p\131\173\224\225\249x\206\207DJ",PropContentType -// ">\185v\229I",PropReasonString "d\150\"\186\234\ESCxL9\167\144\217\SYN",PropReasonString -// "\254\205\DEL\181T\130$\200\SOH]\132\207",PropMaximumPacketSize 9973,PropAuthenticationMethod -// "\151s\235p\224\&1\t\222`\244JG\fu$\NUL\181\148\247\210\139\&3\157\255\b\239Z"]}), _cleanSession = True, _keepAlive = -// 17750, _connID = "\178Y\174\187MI\NAK\186F\SYN\139\138\235u\SOH\197Q", _properties = [PropPayloadFormatIndicator -// 184,PropRequestResponseInformation 159,PropReasonString "\234\166\&9\DLE\203",PropWildcardSubscriptionAvailable -// 49,PropMessageExpiryInterval 16879,PropWildcardSubscriptionAvailable 116,PropSubscriptionIdentifier -// 15,PropSharedSubscriptionAvailable 140,PropReasonString -// "!Roq\\\148%\240\243\ESC)\205\163\159\182\226\251\246\159",PropResponseTopic -// "\209Q",PropSubscriptionIdentifierAvailable 215,PropContentType "\203\&0\135\186J1i\167",PropResponseInformation -// "\138\aF\170\198\175\209 b\157\212k\223.\186zq\184\137\168\&6\189\EM?",PropSharedSubscriptionAvailable -// 47,PropContentType "\175}\128\GS\DLE}\163\188r]\239\SYN",PropWillDelayInterval 23909,PropMessageExpiryInterval -// 9674,PropServerReference "\203\197\148p\220\199)",PropServerReference "'8",PropMaximumPacketSize -// 16109,PropRequestResponseInformation 38,PropSubscriptionIdentifierAvailable 106,PropAuthenticationData -// "\193g1\210\244\177\149\194z\130\n\173\246\162\ETXv|0\212g6\173\180\202\128[m&",PropAuthenticationMethod -// "x\177\179T\138\255\213\255ge[\STX\179\211\145\201\195^",PropTopicAliasMaximum -// 30987,PropWildcardSubscriptionAvailable 116,PropTopicAliasMaximum 21660,PropSharedSubscriptionAvailable -// 115,PropCorrelationData "\152\159W\164&K\133q\208(\228",PropMessageExpiryInterval 21351]} +// ConnectRequest {_username = Nothing, _password = Just "d\140\&3,\181\151\SI[\ACK\153\237\181<<\225\185\SO", _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "N\173\211", _willMsg = "c\251\173\SOHT\f\251", +// _willProps = [PropAssignedClientIdentifier +// "\205;\219v\156S\248O;T\CAN\246\178\ETB\186\217R\191\EOT\183\DC1b",PropRetainAvailable 103,PropSessionExpiryInterval +// 14021,PropReceiveMaximum 4410,PropMaximumPacketSize 23922,PropSessionExpiryInterval 13791,PropWillDelayInterval +// 27674,PropMessageExpiryInterval 21160,PropServerKeepAlive 5476,PropUserProperty +// "\a/.~L\186\223\167\157\168j\CANVm\180\245\149\163\&3y\157\179\143\144a" "\179\253\ENQ6tb\DC2\rI\180"]}), +// _cleanSession = True, _keepAlive = 10911, _connID = "\137\138\233WV \249\146:\152V\141\176'z", _properties = +// [PropTopicAlias 1198,PropMessageExpiryInterval 15224,PropCorrelationData +// "\135\213\131F\208\201\&4\240\162\206\NAK\161\193\207\202\129\242",PropServerReference +// "\156&I\211\220~\154\230\206\241\203\153h&6\190P\208",PropMessageExpiryInterval 14430,PropReasonString +// "\207Fj\143\140\223\244V\a\DELv\201\188\ENQ\238\ENQ\EM\219\245(\186\223",PropRequestProblemInformation +// 157,PropMessageExpiryInterval 16144,PropMaximumPacketSize 13260,PropRequestProblemInformation 25,PropReasonString +// "\235\244\141W\185\220\235\&4hH^1\ESC\165\253\ACKr\200\201\r\208p\253\184\201"]} TEST(Connect5QCTest, Encode26) { uint8_t pkt[] = { - 0x10, 0xc9, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x86, 0x45, 0x56, 0xe6, 0x1, 0x1, 0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x7, 0x23, 0x2a, 0x1a, 0xc5, 0x2f, 0x72, 0xcb}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xea, 0xa6, 0x39, 0x10, 0xcb}; - uint8_t bytesprops1[] = {0x21, 0x52, 0x3c, 0x73, 0x61, 0x62, 0xe3, 0x3e, 0x6f, 0x71, 0x5c, 0x94, 0x25, - 0xf0, 0xf3, 0x1b, 0x29, 0xcd, 0xa3, 0x9f, 0xb6, 0xe2, 0xfb, 0xf6, 0x9f}; - uint8_t bytesprops2[] = {0xd1, 0x51}; - uint8_t bytesprops3[] = {0xcb, 0x30, 0x87, 0xba, 0x4a, 0x31, 0x69, 0xa7}; - uint8_t bytesprops4[] = {0x8a, 0x7, 0x46, 0xaa, 0xc6, 0xaf, 0xd1, 0x20, 0x62, 0x9d, 0xd4, 0x6b, - 0xdf, 0x2e, 0xba, 0x7a, 0x71, 0xb8, 0x89, 0xa8, 0x36, 0xbd, 0x19, 0x3f}; - uint8_t bytesprops5[] = {0xaf, 0x7d, 0x80, 0x1d, 0x10, 0x7d, 0xa3, 0xbc, 0x72, 0x5d, 0xef, 0x16}; - uint8_t bytesprops6[] = {0xcb, 0xc5, 0x94, 0x70, 0xdc, 0xc7, 0x29}; - uint8_t bytesprops7[] = {0x27, 0x38}; - uint8_t bytesprops8[] = {0xc1, 0x67, 0x31, 0xd2, 0xf4, 0xb1, 0x95, 0xc2, 0x7a, 0x82, 0xa, 0xad, 0xf6, 0xa2, - 0x3, 0x76, 0x7c, 0x30, 0xd4, 0x67, 0x36, 0xad, 0xb4, 0xca, 0x80, 0x5b, 0x6d, 0x26}; - uint8_t bytesprops9[] = {0x78, 0xb1, 0xb3, 0x54, 0x8a, 0xff, 0xd5, 0xff, 0x67, - 0x65, 0x5b, 0x2, 0xb3, 0xd3, 0x91, 0xc9, 0xc3, 0x5e}; - uint8_t bytesprops10[] = {0x98, 0x9f, 0x57, 0xa4, 0x26, 0x4b, 0x85, 0x71, 0xd0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5, 0x21, 0x11, 0x3a, 0x27, 0x0, + 0x0, 0x5d, 0x72, 0x11, 0x0, 0x0, 0x35, 0xdf, 0x18, 0x0, 0x0, 0x6c, 0x1a, 0x2, 0x0, 0x0, 0x52, 0xa8, 0x13, + 0x15, 0x64, 0x26, 0x0, 0x19, 0x7, 0x2f, 0x2e, 0x7e, 0x4c, 0xba, 0xdf, 0xa7, 0x9d, 0xa8, 0x6a, 0x18, 0x56, 0x6d, + 0xb4, 0xf5, 0x95, 0xa3, 0x33, 0x79, 0x9d, 0xb3, 0x8f, 0x90, 0x61, 0x0, 0xa, 0xb3, 0xfd, 0x5, 0x36, 0x74, 0x62, + 0x12, 0xd, 0x49, 0xb4, 0x0, 0x3, 0x4e, 0xad, 0xd3, 0x0, 0x7, 0x63, 0xfb, 0xad, 0x1, 0x54, 0xc, 0xfb, 0x0, + 0x11, 0x64, 0x8c, 0x33, 0x2c, 0xb5, 0x97, 0xf, 0x5b, 0x6, 0x99, 0xed, 0xb5, 0x3c, 0x3c, 0xe1, 0xb9, 0xe}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x87, 0xd5, 0x83, 0x46, 0xd0, 0xc9, 0x34, 0xf0, 0xa2, + 0xce, 0x15, 0xa1, 0xc1, 0xcf, 0xca, 0x81, 0xf2}; + uint8_t bytesprops1[] = {0x9c, 0x26, 0x49, 0xd3, 0xdc, 0x7e, 0x9a, 0xe6, 0xce, + 0xf1, 0xcb, 0x99, 0x68, 0x26, 0x36, 0xbe, 0x50, 0xd0}; + uint8_t bytesprops2[] = {0xcf, 0x46, 0x6a, 0x8f, 0x8c, 0xdf, 0xf4, 0x56, 0x7, 0x7f, 0x76, + 0xc9, 0xbc, 0x5, 0xee, 0x5, 0x19, 0xdb, 0xf5, 0x28, 0xba, 0xdf}; + uint8_t bytesprops3[] = {0xeb, 0xf4, 0x8d, 0x57, 0xb9, 0xdc, 0xeb, 0x34, 0x68, 0x48, 0x5e, 0x31, 0x1b, + 0xa5, 0xfd, 0x6, 0x72, 0xc8, 0xc9, 0xd, 0xd0, 0x70, 0xfd, 0xb8, 0xc9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16879}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23909}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9674}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16109}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30987}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21660}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21351}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1198}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15224}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14430}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16144}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13260}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x44, 0x22, 0xc8, 0x9a, 0xe1, 0xd1, 0x1e, 0x36, 0x74, 0xf4, 0x3c, 0x48, 0xd7, - 0xc7, 0xdc, 0x78, 0xed, 0x54, 0x51, 0xe6, 0xe0, 0xe, 0xae, 0xcb, 0x6d}; - uint8_t byteswillprops1[] = {0x25, 0x7e, 0x8e, 0x26, 0x4c, 0x11, 0x3, 0x9f, 0x69, 0xf5, 0x91, 0x90, 0x83, 0xd2, - 0xdb, 0x3e, 0xe6, 0x2, 0x89, 0xf2, 0xad, 0x43, 0x72, 0x12, 0xbb, 0xf4, 0x8c}; - uint8_t byteswillprops2[] = {0x2e, 0xab, 0x13, 0xc4, 0x80, 0x8b, 0x92, 0xaa, 0x62, 0xfd, 0xa1}; - uint8_t byteswillprops4[] = {0x13, 0x34, 0x8d, 0x2, 0x16, 0x57, 0xf7, 0x98, 0x72, 0x27, - 0x95, 0xfc, 0x5a, 0x8c, 0x24, 0x9, 0x5, 0x5b, 0x8f}; - uint8_t byteswillprops3[] = {0xd0, 0x79, 0x97, 0x4d, 0x14, 0x8a, 0x36, 0x4a, 0x24, 0xaa, 0x11, 0x98, - 0xd0, 0xf3, 0x5, 0xc2, 0xc4, 0x9, 0x6d, 0xe, 0x37, 0x38, 0x39, 0x63}; - uint8_t byteswillprops5[] = {0x2, 0x71, 0x5b, 0xae, 0x9c, 0x30}; - uint8_t byteswillprops6[] = {0x79, 0x6c, 0x21, 0xd4, 0xfe, 0x20, 0x66, 0x70, 0xb4, 0x17, 0x66, 0xa8, 0x6a}; - uint8_t byteswillprops7[] = {0xfe}; - uint8_t byteswillprops8[] = {0x80, 0xbd, 0x74, 0xdf, 0x8, 0xbd, 0xe2, 0xc6, 0x70, 0x83, - 0xad, 0xe0, 0xe1, 0xf9, 0x78, 0xce, 0xcf, 0x44, 0x4a}; - uint8_t byteswillprops9[] = {0x3e, 0xb9, 0x76, 0xe5, 0x49}; - uint8_t byteswillprops10[] = {0x64, 0x96, 0x22, 0xba, 0xea, 0x1b, 0x78, 0x4c, 0x39, 0xa7, 0x90, 0xd9, 0x16}; - uint8_t byteswillprops11[] = {0xfe, 0xcd, 0x7f, 0xb5, 0x54, 0x82, 0x24, 0xc8, 0x1, 0x5d, 0x84, 0xcf}; - uint8_t byteswillprops12[] = {0x97, 0x73, 0xeb, 0x70, 0xe0, 0x31, 0x9, 0xde, 0x60, 0xf4, 0x4a, 0x47, 0xc, 0x75, - 0x24, 0x0, 0xb5, 0x94, 0xf7, 0xd2, 0x8b, 0x33, 0x9d, 0xff, 0x8, 0xef, 0x5a}; + uint8_t byteswillprops0[] = {0xcd, 0x3b, 0xdb, 0x76, 0x9c, 0x53, 0xf8, 0x4f, 0x3b, 0x54, 0x18, + 0xf6, 0xb2, 0x17, 0xba, 0xd9, 0x52, 0xbf, 0x4, 0xb7, 0x11, 0x62}; + uint8_t byteswillprops2[] = {0xb3, 0xfd, 0x5, 0x36, 0x74, 0x62, 0x12, 0xd, 0x49, 0xb4}; + uint8_t byteswillprops1[] = {0x7, 0x2f, 0x2e, 0x7e, 0x4c, 0xba, 0xdf, 0xa7, 0x9d, 0xa8, 0x6a, 0x18, 0x56, + 0x6d, 0xb4, 0xf5, 0x95, 0xa3, 0x33, 0x79, 0x9d, 0xb3, 0x8f, 0x90, 0x61}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22847}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27627}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4451}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27000}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14021}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4410}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23922}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13791}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27674}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21160}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5476}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {24, (char*)&byteswillprops3}, .v = {19, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9973}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&byteswillprops12}}}, + .value = {.pair = {.k = {25, (char*)&byteswillprops1}, .v = {10, (char*)&byteswillprops2}}}}, }; - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x47, 0x40, 0x76, 0x20, 0x77, 0x62, 0xfd, 0x1d, 0x62, 0xd4}; - lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x16, 0x22, 0x6d, 0x6f, 0xe9, 0x6c, 0x62, 0x59, 0x13, - 0xa0, 0x9c, 0xe6, 0xce, 0x60, 0xe2, 0x4a, 0x7c, 0xe8}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4e, 0xad, 0xd3}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x63, 0xfb, 0xad, 0x1, 0x54, 0xc, 0xfb}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -9579,14 +9751,15 @@ TEST(Connect5QCTest, Encode26) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 17750; - uint8_t client_id_bytes[] = {0xb2, 0x59, 0xae, 0xbb, 0x4d, 0x49, 0x15, 0xba, 0x46, - 0x16, 0x8b, 0x8a, 0xeb, 0x75, 0x1, 0xc5, 0x51}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.keep_alive = 10911; + uint8_t client_id_bytes[] = {0x89, 0x8a, 0xe9, 0x57, 0x56, 0x20, 0xf9, 0x92, + 0x3a, 0x98, 0x56, 0x8d, 0xb0, 0x27, 0x7a}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x23, 0x2a, 0x1a, 0xc5, 0x2f, 0x72, 0xcb}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; - opts.username = username; + uint8_t password_bytes[] = {0x64, 0x8c, 0x33, 0x2c, 0xb5, 0x97, 0xf, 0x5b, 0x6, + 0x99, 0xed, 0xb5, 0x3c, 0x3c, 0xe1, 0xb9, 0xe}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9595,170 +9768,94 @@ TEST(Connect5QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just ";<\132\244\&6\148W/\234\225\r\SIO\DC1", _password = Just -// "\243\ACK\180?\176\136\191]UDv\US\f\151|\209\150\NUL", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\176\CAN\r\146\ESC\214\243U\141F\EM\253\149\231\131\182\203+\164\212'=\232\161\154L\219$", -// _willMsg = "\185\143G\243\136\166\&2xe\156z:|WI\175\185s([H\182\224\143", _willProps = [PropRequestProblemInformation -// 197,PropRetainAvailable 31,PropSessionExpiryInterval 14762,PropSharedSubscriptionAvailable 26,PropUserProperty -// "Ne\191\ACK\246\241\157\200\212" "\255\CANVG\237!\252\STX\238\DC3]'\SYN/\185\186\220?\222;",PropResponseInformation -// "|w\165|\151\164\225\151\181\194\207h\170k\240\SUB\SOH",PropPayloadFormatIndicator 205,PropUserProperty -// "\226\216\173\128\&9\238\156\168,\173G\236\190" "b(\237\195 -// \203\160>\238\174\ESC\167\DC3\217\169N\ESC\136\152L\SYN",PropMessageExpiryInterval 29064,PropMaximumPacketSize -// 25322,PropAssignedClientIdentifier "\207p\243\SOH\163>\148*0\208\224\191gD\174\136d\144\216",PropContentType -// "\ACK,v\177E\145q",PropRequestResponseInformation 19,PropWildcardSubscriptionAvailable 230,PropMaximumPacketSize -// 22647,PropSubscriptionIdentifier 1,PropMessageExpiryInterval 20367,PropRequestProblemInformation -// 27,PropServerKeepAlive 12457,PropRetainAvailable 129,PropTopicAliasMaximum 31953]}), _cleanSession = True, _keepAlive -// = 29887, _connID = "\136\132f\178\182\247\158\133\171t\131\148\168\fR\250d\235\253/\255Y\194\DLE\178", _properties = -// [PropSubscriptionIdentifierAvailable 51,PropServerReference -// "\192%\173\168jy\131\211s\174\228\223[\181\177\208\204+r/\135\245m\228Wew\171\DC1\ENQ",PropWillDelayInterval -// 5471,PropTopicAliasMaximum 27567,PropMessageExpiryInterval 15427,PropAuthenticationMethod "\ACK(\137)\146\128#~\212 -// \142\248\180\200u\195\141\DLE{:e9\209p\v\217\147\248\233",PropPayloadFormatIndicator 255,PropReasonString -// "~T\157I\v\198X\206N\184\NUL \EM\RS\230{\RS]a7\193\255\201",PropSharedSubscriptionAvailable 41,PropMaximumPacketSize -// 24039,PropReasonString "B\231^\138\250\225*>D\144`\185\192\128\173\167",PropMessageExpiryInterval -// 27240,PropPayloadFormatIndicator 135,PropUserProperty "(rRr\253 \148\132^\247V\183k\RS\180\240\163\200b\f\202" -// "N\ESC\RSk\201\164\&7\142\129\153\237\205F\223\242]\153~\235\SYNF\205\RS",PropRequestResponseInformation -// 244,PropSessionExpiryInterval 29932,PropSessionExpiryInterval 17734,PropReasonString -// "\197UBu\148oD\173\SIp\136$W\162\181\244e\153\192\131\189\232\129H\NAKU",PropSessionExpiryInterval -// 25285,PropMessageExpiryInterval 26956,PropAuthenticationData "\206\228\201\221\b\174\231$\140 \v\192\163="]} +// ConnectRequest {_username = Just "\190\254\vG\140\DLEq\206\199\&1\235y\135a\b", _password = Just +// "(\ESC\DC14\172tH/\136\240\225", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "'\SOH\141M", _willMsg = "\199I\t\155\SOHg\135,\200F\135\EM;\233J\152\NAK\ESCD\SUB\t\193M\DEL\220^\163\214", +// _willProps = [PropMaximumPacketSize 24417,PropTopicAlias 17524,PropMessageExpiryInterval 20187,PropServerReference +// "\f\209s`\249\163\r\214\139\205\DC4",PropAssignedClientIdentifier +// "\238\230\251\142\160\EM\160\RSQ!9ni,J'\170\241%wB\148?\250\208s\210\215\209",PropWillDelayInterval +// 26133,PropUserProperty "\217b9\a\DC31\191\128\FSM\DC4\223\131U\aN\145D\143" +// "\233Ag\229R<\190\192V\ETX\233%\168rg\194\186.`OV\146\161b\149",PropMaximumQoS 16,PropCorrelationData +// "\190\SOH]\241\CAN\148@\249\150\153@\175\245z\215\v\NUL*X\a\209G0\156\SYNu'",PropServerKeepAlive +// 24125,PropReceiveMaximum 22673]}), _cleanSession = True, _keepAlive = 14063, _connID = +// "\137\196\DC1\230\"\199\249,\241\a\f\239\159\223\170N\240\248\184\172", _properties = [PropRequestProblemInformation +// 41,PropContentType "=",PropPayloadFormatIndicator 203]} TEST(Connect5QCTest, Encode27) { uint8_t pkt[] = { - 0x10, 0xb5, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x74, 0xbf, 0x82, 0x2, 0x29, 0x33, 0x1c, 0x0, - 0x1e, 0xc0, 0x25, 0xad, 0xa8, 0x6a, 0x79, 0x83, 0xd3, 0x73, 0xae, 0xe4, 0xdf, 0x5b, 0xb5, 0xb1, 0xd0, 0xcc, 0x2b, - 0x72, 0x2f, 0x87, 0xf5, 0x6d, 0xe4, 0x57, 0x65, 0x77, 0xab, 0x11, 0x5, 0x18, 0x0, 0x0, 0x15, 0x5f, 0x22, 0x6b, - 0xaf, 0x2, 0x0, 0x0, 0x3c, 0x43, 0x15, 0x0, 0x1d, 0x6, 0x28, 0x89, 0x29, 0x92, 0x80, 0x23, 0x7e, 0xd4, 0x20, - 0x8e, 0xf8, 0xb4, 0xc8, 0x75, 0xc3, 0x8d, 0x10, 0x7b, 0x3a, 0x65, 0x39, 0xd1, 0x70, 0xb, 0xd9, 0x93, 0xf8, 0xe9, - 0x1, 0xff, 0x1f, 0x0, 0x17, 0x7e, 0x54, 0x9d, 0x49, 0xb, 0xc6, 0x58, 0xce, 0x4e, 0xb8, 0x0, 0x20, 0x19, 0x1e, - 0xe6, 0x7b, 0x1e, 0x5d, 0x61, 0x37, 0xc1, 0xff, 0xc9, 0x2a, 0x29, 0x27, 0x0, 0x0, 0x5d, 0xe7, 0x1f, 0x0, 0x10, - 0x42, 0xe7, 0x5e, 0x8a, 0xf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88, - 0xa6, 0x32, 0x78, 0x65, 0x9c, 0x7a, 0x3a, 0x7c, 0x57, 0x49, 0xaf, 0xb9, 0x73, 0x28, 0x5b, 0x48, 0xb6, 0xe0, 0x8f, - 0x0, 0xe, 0x3b, 0x3c, 0x84, 0xf4, 0x36, 0x94, 0x57, 0x2f, 0xea, 0xe1, 0xd, 0xf, 0x4f, 0x11, 0x0, 0x12, 0xf3, - 0x6, 0xb4, 0x3f, 0xb0, 0x88, 0xbf, 0x5d, 0x55, 0x44, 0x76, 0x1f, 0xc, 0x97, 0x7c, 0xd1, 0x96, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xc0, 0x25, 0xad, 0xa8, 0x6a, 0x79, 0x83, 0xd3, 0x73, 0xae, 0xe4, 0xdf, 0x5b, 0xb5, 0xb1, - 0xd0, 0xcc, 0x2b, 0x72, 0x2f, 0x87, 0xf5, 0x6d, 0xe4, 0x57, 0x65, 0x77, 0xab, 0x11, 0x5}; - uint8_t bytesprops1[] = {0x6, 0x28, 0x89, 0x29, 0x92, 0x80, 0x23, 0x7e, 0xd4, 0x20, 0x8e, 0xf8, 0xb4, 0xc8, 0x75, - 0xc3, 0x8d, 0x10, 0x7b, 0x3a, 0x65, 0x39, 0xd1, 0x70, 0xb, 0xd9, 0x93, 0xf8, 0xe9}; - uint8_t bytesprops2[] = {0x7e, 0x54, 0x9d, 0x49, 0xb, 0xc6, 0x58, 0xce, 0x4e, 0xb8, 0x0, 0x20, - 0x19, 0x1e, 0xe6, 0x7b, 0x1e, 0x5d, 0x61, 0x37, 0xc1, 0xff, 0xc9}; - uint8_t bytesprops3[] = {0x42, 0xe7, 0x5e, 0x8a, 0xfa, 0xe1, 0x2a, 0x3e, - 0x44, 0x90, 0x60, 0xb9, 0xc0, 0x80, 0xad, 0xa7}; - uint8_t bytesprops5[] = {0x4e, 0x1b, 0x1e, 0x6b, 0xc9, 0xa4, 0x37, 0x8e, 0x81, 0x99, 0xed, 0xcd, - 0x46, 0xdf, 0xf2, 0x5d, 0x99, 0x7e, 0xeb, 0x16, 0x46, 0xcd, 0x1e}; - uint8_t bytesprops4[] = {0x28, 0x72, 0x52, 0x72, 0xfd, 0x20, 0x94, 0x84, 0x5e, 0xf7, 0x56, - 0xb7, 0x6b, 0x1e, 0xb4, 0xf0, 0xa3, 0xc8, 0x62, 0xc, 0xca}; - uint8_t bytesprops6[] = {0xc5, 0x55, 0x42, 0x75, 0x94, 0x6f, 0x44, 0xad, 0xf, 0x70, 0x88, 0x24, 0x57, - 0xa2, 0xb5, 0xf4, 0x65, 0x99, 0xc0, 0x83, 0xbd, 0xe8, 0x81, 0x48, 0x15, 0x55}; - uint8_t bytesprops7[] = {0xce, 0xe4, 0xc9, 0xdd, 0x8, 0xae, 0xe7, 0x24, 0x8c, 0x20, 0xb, 0xc0, 0xa3, 0x3d}; + 0x10, 0x84, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x36, 0xef, 0x8, 0x17, 0x29, 0x3, 0x0, 0x1, + 0x3d, 0x1, 0xcb, 0x0, 0x14, 0x89, 0xc4, 0x11, 0xe6, 0x22, 0xc7, 0xf9, 0x2c, 0xf1, 0x7, 0xc, 0xef, 0x9f, 0xdf, + 0xaa, 0x4e, 0xf0, 0xf8, 0xb8, 0xac, 0x97, 0x1, 0x27, 0x0, 0x0, 0x5f, 0x61, 0x23, 0x44, 0x74, 0x2, 0x0, 0x0, + 0x4e, 0xdb, 0x1c, 0x0, 0xb, 0xc, 0xd1, 0x73, 0x60, 0xf9, 0xa3, 0xd, 0xd6, 0x8b, 0xcd, 0x14, 0x12, 0x0, 0x1d, + 0xee, 0xe6, 0xfb, 0x8e, 0xa0, 0x19, 0xa0, 0x1e, 0x51, 0x21, 0x39, 0x6e, 0x69, 0x2c, 0x4a, 0x27, 0xaa, 0xf1, 0x25, + 0x77, 0x42, 0x94, 0x3f, 0xfa, 0xd0, 0x73, 0xd2, 0xd7, 0xd1, 0x18, 0x0, 0x0, 0x66, 0x15, 0x26, 0x0, 0x13, 0xd9, + 0x62, 0x39, 0x7, 0x13, 0x31, 0xbf, 0x80, 0x1c, 0x4d, 0x14, 0xdf, 0x83, 0x55, 0x7, 0x4e, 0x91, 0x44, 0x8f, 0x0, + 0x19, 0xe9, 0x41, 0x67, 0xe5, 0x52, 0x3c, 0xbe, 0xc0, 0x56, 0x3, 0xe9, 0x25, 0xa8, 0x72, 0x67, 0xc2, 0xba, 0x2e, + 0x60, 0x4f, 0x56, 0x92, 0xa1, 0x62, 0x95, 0x24, 0x10, 0x9, 0x0, 0x1b, 0xbe, 0x1, 0x5d, 0xf1, 0x18, 0x94, 0x40, + 0xf9, 0x96, 0x99, 0x40, 0xaf, 0xf5, 0x7a, 0xd7, 0xb, 0x0, 0x2a, 0x58, 0x7, 0xd1, 0x47, 0x30, 0x9c, 0x16, 0x75, + 0x27, 0x13, 0x5e, 0x3d, 0x21, 0x58, 0x91, 0x0, 0x4, 0x27, 0x1, 0x8d, 0x4d, 0x0, 0x1c, 0xc7, 0x49, 0x9, 0x9b, + 0x1, 0x67, 0x87, 0x2c, 0xc8, 0x46, 0x87, 0x19, 0x3b, 0xe9, 0x4a, 0x98, 0x15, 0x1b, 0x44, 0x1a, 0x9, 0xc1, 0x4d, + 0x7f, 0xdc, 0x5e, 0xa3, 0xd6, 0x0, 0xf, 0xbe, 0xfe, 0xb, 0x47, 0x8c, 0x10, 0x71, 0xce, 0xc7, 0x31, 0xeb, 0x79, + 0x87, 0x61, 0x8, 0x0, 0xb, 0x28, 0x1b, 0x11, 0x34, 0xac, 0x74, 0x48, 0x2f, 0x88, 0xf0, 0xe1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x3d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5471}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27567}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15427}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24039}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27240}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops4}, .v = {23, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29932}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17734}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25285}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26956}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 203}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xff, 0x18, 0x56, 0x47, 0xed, 0x21, 0xfc, 0x2, 0xee, 0x13, - 0x5d, 0x27, 0x16, 0x2f, 0xb9, 0xba, 0xdc, 0x3f, 0xde, 0x3b}; - uint8_t byteswillprops0[] = {0x4e, 0x65, 0xbf, 0x6, 0xf6, 0xf1, 0x9d, 0xc8, 0xd4}; - uint8_t byteswillprops2[] = {0x7c, 0x77, 0xa5, 0x7c, 0x97, 0xa4, 0xe1, 0x97, 0xb5, - 0xc2, 0xcf, 0x68, 0xaa, 0x6b, 0xf0, 0x1a, 0x1}; - uint8_t byteswillprops4[] = {0x62, 0x28, 0xed, 0xc3, 0x20, 0xcb, 0xa0, 0x3e, 0xee, 0xae, 0x1b, - 0xa7, 0x13, 0xd9, 0xa9, 0x4e, 0x1b, 0x88, 0x98, 0x4c, 0x16}; - uint8_t byteswillprops3[] = {0xe2, 0xd8, 0xad, 0x80, 0x39, 0xee, 0x9c, 0xa8, 0x2c, 0xad, 0x47, 0xec, 0xbe}; - uint8_t byteswillprops5[] = {0xcf, 0x70, 0xf3, 0x1, 0xa3, 0x3e, 0x94, 0x2a, 0x30, 0xd0, - 0xe0, 0xbf, 0x67, 0x44, 0xae, 0x88, 0x64, 0x90, 0xd8}; - uint8_t byteswillprops6[] = {0x6, 0x2c, 0x76, 0xb1, 0x45, 0x91, 0x71}; + uint8_t byteswillprops0[] = {0xc, 0xd1, 0x73, 0x60, 0xf9, 0xa3, 0xd, 0xd6, 0x8b, 0xcd, 0x14}; + uint8_t byteswillprops1[] = {0xee, 0xe6, 0xfb, 0x8e, 0xa0, 0x19, 0xa0, 0x1e, 0x51, 0x21, 0x39, 0x6e, 0x69, 0x2c, 0x4a, + 0x27, 0xaa, 0xf1, 0x25, 0x77, 0x42, 0x94, 0x3f, 0xfa, 0xd0, 0x73, 0xd2, 0xd7, 0xd1}; + uint8_t byteswillprops3[] = {0xe9, 0x41, 0x67, 0xe5, 0x52, 0x3c, 0xbe, 0xc0, 0x56, 0x3, 0xe9, 0x25, 0xa8, + 0x72, 0x67, 0xc2, 0xba, 0x2e, 0x60, 0x4f, 0x56, 0x92, 0xa1, 0x62, 0x95}; + uint8_t byteswillprops2[] = {0xd9, 0x62, 0x39, 0x7, 0x13, 0x31, 0xbf, 0x80, 0x1c, 0x4d, + 0x14, 0xdf, 0x83, 0x55, 0x7, 0x4e, 0x91, 0x44, 0x8f}; + uint8_t byteswillprops4[] = {0xbe, 0x1, 0x5d, 0xf1, 0x18, 0x94, 0x40, 0xf9, 0x96, 0x99, 0x40, 0xaf, 0xf5, 0x7a, + 0xd7, 0xb, 0x0, 0x2a, 0x58, 0x7, 0xd1, 0x47, 0x30, 0x9c, 0x16, 0x75, 0x27}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14762}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {9, (char*)&byteswillprops0}, .v = {20, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24417}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17524}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20187}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26133}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {13, (char*)&byteswillprops3}, .v = {21, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29064}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25322}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22647}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20367}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12457}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31953}}, + .value = {.pair = {.k = {19, (char*)&byteswillprops2}, .v = {25, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24125}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22673}}, }; - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb0, 0x18, 0xd, 0x92, 0x1b, 0xd6, 0xf3, 0x55, 0x8d, 0x46, 0x19, 0xfd, 0x95, 0xe7, - 0x83, 0xb6, 0xcb, 0x2b, 0xa4, 0xd4, 0x27, 0x3d, 0xe8, 0xa1, 0x9a, 0x4c, 0xdb, 0x24}; - lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb9, 0x8f, 0x47, 0xf3, 0x88, 0xa6, 0x32, 0x78, 0x65, 0x9c, 0x7a, 0x3a, - 0x7c, 0x57, 0x49, 0xaf, 0xb9, 0x73, 0x28, 0x5b, 0x48, 0xb6, 0xe0, 0x8f}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {11, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x27, 0x1, 0x8d, 0x4d}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc7, 0x49, 0x9, 0x9b, 0x1, 0x67, 0x87, 0x2c, 0xc8, 0x46, 0x87, 0x19, 0x3b, 0xe9, + 0x4a, 0x98, 0x15, 0x1b, 0x44, 0x1a, 0x9, 0xc1, 0x4d, 0x7f, 0xdc, 0x5e, 0xa3, 0xd6}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 29887; - uint8_t client_id_bytes[] = {0x88, 0x84, 0x66, 0xb2, 0xb6, 0xf7, 0x9e, 0x85, 0xab, 0x74, 0x83, 0x94, 0xa8, - 0xc, 0x52, 0xfa, 0x64, 0xeb, 0xfd, 0x2f, 0xff, 0x59, 0xc2, 0x10, 0xb2}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.keep_alive = 14063; + uint8_t client_id_bytes[] = {0x89, 0xc4, 0x11, 0xe6, 0x22, 0xc7, 0xf9, 0x2c, 0xf1, 0x7, + 0xc, 0xef, 0x9f, 0xdf, 0xaa, 0x4e, 0xf0, 0xf8, 0xb8, 0xac}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x3b, 0x3c, 0x84, 0xf4, 0x36, 0x94, 0x57, 0x2f, 0xea, 0xe1, 0xd, 0xf, 0x4f, 0x11}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xbe, 0xfe, 0xb, 0x47, 0x8c, 0x10, 0x71, 0xce, 0xc7, 0x31, 0xeb, 0x79, 0x87, 0x61, 0x8}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xf3, 0x6, 0xb4, 0x3f, 0xb0, 0x88, 0xbf, 0x5d, 0x55, - 0x44, 0x76, 0x1f, 0xc, 0x97, 0x7c, 0xd1, 0x96, 0x0}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x28, 0x1b, 0x11, 0x34, 0xac, 0x74, 0x48, 0x2f, 0x88, 0xf0, 0xe1}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9768,124 +9865,72 @@ TEST(Connect5QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\ENQAAE\ACK\174&\128\161wm#W>VC<]\149\152\201\134x:\148\220\243T\\.", _password = -// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// ";\161U\195\&6\138\177I\129\195\USA\DC3", _willMsg = "I\DC1\210\DC3\FS\DC3\242\138\171\211\203\b\190", _willProps = -// [PropRequestProblemInformation 76,PropAuthenticationData "=o(\183X\GS*5\239<\f63\ENQ",PropContentType -// "\159Q\190\186\211\ESC\236U\SO:\224\220GY\ENQ\FS\DC1\DC2\235\211[\SOHN.\233",PropAuthenticationMethod -// "ju\181\SO\DLE\b=\149\128\&1\US\228\128\156\249j",PropMessageExpiryInterval 15727,PropUserProperty "" -// "\ETX}\242\158\EOT^s\237{B\157\159\DC2\161\203\&16\145\DELry\239;\NAK",PropMessageExpiryInterval -// 17769,PropRetainAvailable 163,PropServerReference "A\231\200\&4|",PropAssignedClientIdentifier -// "",PropMaximumPacketSize 3021,PropSubscriptionIdentifierAvailable 79,PropMaximumPacketSize -// 6246,PropRequestProblemInformation 110,PropSubscriptionIdentifier 15,PropReasonString -// "\188@\234\245\138",PropRequestProblemInformation 149,PropWillDelayInterval 16414,PropReceiveMaximum -// 29477,PropRequestResponseInformation 172,PropMaximumQoS 199,PropMessageExpiryInterval 7605,PropTopicAlias -// 1346,PropMaximumPacketSize 9041,PropTopicAliasMaximum 20216,PropSessionExpiryInterval -// 23968,PropRequestProblemInformation 43]}), _cleanSession = True, _keepAlive = 22371, _connID = "\165\EM\181\CAN)62", -// _properties = [PropAuthenticationData "\189 -// \DC4>\197\212ol!\NAK\t%V\145%6S\137\134\230\194\158\SYN[\231\&1\159\DC1X",PropReasonString -// "\171\&6\148a\DC4\158A\SI>=*\255)",PropAuthenticationMethod -// ">\149\144:\222o=L\DC11\246\148\190_\140}V\223\166\195\173\180\240h\154\"\222\206",PropTopicAliasMaximum 5258]} +// ConnectRequest {_username = Just "%\DC3/-\bG2\192\137\196&\128\209\143\235\SI\201\&6\r\216vK\196dI\195\144G", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "\132~x\156KS\246y\137\249\SYN\154%\145\149T\195\188", _willMsg = +// "X\195\&0\237\DC1l\222\ETX\219\&9\128\"\210/\254\243Q\204\169^H", _willProps = [PropServerKeepAlive +// 7936,PropResponseTopic "\202z\237\NULa\195\199"]}), _cleanSession = False, _keepAlive = 9629, _connID = +// "u\226c\130\167Y\128L\255\&1\SI\232\190", _properties = [PropResponseInformation +// "\217f\236\222\208\152\142\202\SOQ\236g\195\DLE\DC2",PropSubscriptionIdentifierAvailable 203,PropReceiveMaximum +// 2798,PropSharedSubscriptionAvailable 222,PropRequestResponseInformation 46,PropTopicAliasMaximum +// 2552,PropAuthenticationData "/\SO8\235}\188\229\156\147}\151^Or",PropTopicAliasMaximum 31519]} TEST(Connect5QCTest, Encode28) { - uint8_t pkt[] = { - 0x10, 0xd9, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x86, 0x57, 0x63, 0x52, 0x16, 0x0, 0x1d, 0xbd, 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x3b, 0x15, 0x2, 0x0, - 0x0, 0x45, 0x69, 0x25, 0xa3, 0x1c, 0x0, 0x5, 0x41, 0xe7, 0xc8, 0x34, 0x7c, 0x12, 0x0, 0x0, 0x27, 0x0, 0x0, - 0xb, 0xcd, 0x29, 0x4f, 0x27, 0x0, 0x0, 0x18, 0x66, 0x17, 0x6e, 0xb, 0xf, 0x1f, 0x0, 0x5, 0xbc, 0x40, 0xea, - 0xf5, 0x8a, 0x17, 0x95, 0x18, 0x0, 0x0, 0x40, 0x1e, 0x21, 0x73, 0x25, 0x19, 0xac, 0x24, 0xc7, 0x2, 0x0, 0x0, - 0x1d, 0xb5, 0x23, 0x5, 0x42, 0x27, 0x0, 0x0, 0x23, 0x51, 0x22, 0x4e, 0xf8, 0x11, 0x0, 0x0, 0x5d, 0xa0, 0x17, - 0x2b, 0x0, 0xd, 0x3b, 0xa1, 0x55, 0xc3, 0x36, 0x8a, 0xb1, 0x49, 0x81, 0xc3, 0x1f, 0x41, 0x13, 0x0, 0xd, 0x49, - 0x11, 0xd2, 0x13, 0x1c, 0x13, 0xf2, 0x8a, 0xab, 0xd3, 0xcb, 0x8, 0xbe, 0x0, 0x1e, 0x5, 0x41, 0x41, 0x45, 0x6, - 0xae, 0x26, 0x80, 0xa1, 0x77, 0x6d, 0x23, 0x57, 0x3e, 0x56, 0x43, 0x3c, 0x5d, 0x95, 0x98, 0xc9, 0x86, 0x78, 0x3a, - 0x94, 0xdc, 0xf3, 0x54, 0x5c, 0x2e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xbd, 0x20, 0x14, 0x3e, 0xc5, 0xd4, 0x6f, 0x6c, 0x21, 0x15, 0x9, 0x25, 0x56, 0x91, 0x25, - 0x36, 0x53, 0x89, 0x86, 0xe6, 0xc2, 0x9e, 0x16, 0x5b, 0xe7, 0x31, 0x9f, 0x11, 0x58}; - uint8_t bytesprops1[] = {0xab, 0x36, 0x94, 0x61, 0x14, 0x9e, 0x41, 0xf, 0x3e, 0x3d, 0x2a, 0xff, 0x29}; - uint8_t bytesprops2[] = {0x3e, 0x95, 0x90, 0x3a, 0xde, 0x6f, 0x3d, 0x4c, 0x11, 0x31, 0xf6, 0x94, 0xbe, 0x5f, - 0x8c, 0x7d, 0x56, 0xdf, 0xa6, 0xc3, 0xad, 0xb4, 0xf0, 0x68, 0x9a, 0x22, 0xde, 0xce}; + uint8_t pkt[] = {0x10, 0xa3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xa4, 0x25, 0x9d, 0x32, 0x1a, 0x0, 0xf, + 0xd9, 0x66, 0xec, 0xde, 0xd0, 0x98, 0x8e, 0xca, 0xe, 0x51, 0xec, 0x67, 0xc3, 0x10, 0x12, 0x29, 0xcb, + 0x21, 0xa, 0xee, 0x2a, 0xde, 0x19, 0x2e, 0x22, 0x9, 0xf8, 0x16, 0x0, 0xe, 0x2f, 0xe, 0x38, 0xeb, + 0x7d, 0xbc, 0xe5, 0x9c, 0x93, 0x7d, 0x97, 0x5e, 0x4f, 0x72, 0x22, 0x7b, 0x1f, 0x0, 0xd, 0x75, 0xe2, + 0x63, 0x82, 0xa7, 0x59, 0x80, 0x4c, 0xff, 0x31, 0xf, 0xe8, 0xbe, 0xd, 0x13, 0x1f, 0x0, 0x8, 0x0, + 0x7, 0xca, 0x7a, 0xed, 0x0, 0x61, 0xc3, 0xc7, 0x0, 0x12, 0x84, 0x7e, 0x78, 0x9c, 0x4b, 0x53, 0xf6, + 0x79, 0x89, 0xf9, 0x16, 0x9a, 0x25, 0x91, 0x95, 0x54, 0xc3, 0xbc, 0x0, 0x15, 0x58, 0xc3, 0x30, 0xed, + 0x11, 0x6c, 0xde, 0x3, 0xdb, 0x39, 0x80, 0x22, 0xd2, 0x2f, 0xfe, 0xf3, 0x51, 0xcc, 0xa9, 0x5e, 0x48, + 0x0, 0x1c, 0x25, 0x13, 0x2f, 0x2d, 0x8, 0x47, 0x32, 0xc0, 0x89, 0xc4, 0x26, 0x80, 0xd1, 0x8f, 0xeb, + 0xf, 0xc9, 0x36, 0xd, 0xd8, 0x76, 0x4b, 0xc4, 0x64, 0x49, 0xc3, 0x90, 0x47}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xd9, 0x66, 0xec, 0xde, 0xd0, 0x98, 0x8e, 0xca, 0xe, 0x51, 0xec, 0x67, 0xc3, 0x10, 0x12}; + uint8_t bytesprops1[] = {0x2f, 0xe, 0x38, 0xeb, 0x7d, 0xbc, 0xe5, 0x9c, 0x93, 0x7d, 0x97, 0x5e, 0x4f, 0x72}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5258}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2798}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2552}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31519}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x3d, 0x6f, 0x28, 0xb7, 0x58, 0x1d, 0x2a, 0x35, 0xef, 0x3c, 0xc, 0x36, 0x33, 0x5}; - uint8_t byteswillprops1[] = {0x9f, 0x51, 0xbe, 0xba, 0xd3, 0x1b, 0xec, 0x55, 0xe, 0x3a, 0xe0, 0xdc, 0x47, - 0x59, 0x5, 0x1c, 0x11, 0x12, 0xeb, 0xd3, 0x5b, 0x1, 0x4e, 0x2e, 0xe9}; - uint8_t byteswillprops2[] = {0x6a, 0x75, 0xb5, 0xe, 0x10, 0x8, 0x3d, 0x95, - 0x80, 0x31, 0x1f, 0xe4, 0x80, 0x9c, 0xf9, 0x6a}; - uint8_t byteswillprops4[] = {0x3, 0x7d, 0xf2, 0x9e, 0x4, 0x5e, 0x73, 0xed, 0x7b, 0x42, 0x9d, 0x9f, - 0x12, 0xa1, 0xcb, 0x31, 0x36, 0x91, 0x7f, 0x72, 0x79, 0xef, 0x3b, 0x15}; - uint8_t byteswillprops3[] = {0}; - uint8_t byteswillprops5[] = {0x41, 0xe7, 0xc8, 0x34, 0x7c}; - uint8_t byteswillprops6[] = {0}; - uint8_t byteswillprops7[] = {0xbc, 0x40, 0xea, 0xf5, 0x8a}; + uint8_t byteswillprops0[] = {0xca, 0x7a, 0xed, 0x0, 0x61, 0xc3, 0xc7}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15727}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {0, (char*)&byteswillprops3}, .v = {24, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17769}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3021}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6246}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16414}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29477}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7605}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1346}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9041}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20216}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23968}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7936}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops0}}}, }; - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3b, 0xa1, 0x55, 0xc3, 0x36, 0x8a, 0xb1, 0x49, 0x81, 0xc3, 0x1f, 0x41, 0x13}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x49, 0x11, 0xd2, 0x13, 0x1c, 0x13, 0xf2, 0x8a, 0xab, 0xd3, 0xcb, 0x8, 0xbe}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x84, 0x7e, 0x78, 0x9c, 0x4b, 0x53, 0xf6, 0x79, 0x89, + 0xf9, 0x16, 0x9a, 0x25, 0x91, 0x95, 0x54, 0xc3, 0xbc}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x58, 0xc3, 0x30, 0xed, 0x11, 0x6c, 0xde, 0x3, 0xdb, 0x39, 0x80, + 0x22, 0xd2, 0x2f, 0xfe, 0xf3, 0x51, 0xcc, 0xa9, 0x5e, 0x48}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 22371; - uint8_t client_id_bytes[] = {0xa5, 0x19, 0xb5, 0x18, 0x29, 0x36, 0x32}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 9629; + uint8_t client_id_bytes[] = {0x75, 0xe2, 0x63, 0x82, 0xa7, 0x59, 0x80, 0x4c, 0xff, 0x31, 0xf, 0xe8, 0xbe}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x5, 0x41, 0x41, 0x45, 0x6, 0xae, 0x26, 0x80, 0xa1, 0x77, 0x6d, 0x23, 0x57, 0x3e, 0x56, - 0x43, 0x3c, 0x5d, 0x95, 0x98, 0xc9, 0x86, 0x78, 0x3a, 0x94, 0xdc, 0xf3, 0x54, 0x5c, 0x2e}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x25, 0x13, 0x2f, 0x2d, 0x8, 0x47, 0x32, 0xc0, 0x89, 0xc4, 0x26, 0x80, 0xd1, 0x8f, + 0xeb, 0xf, 0xc9, 0x36, 0xd, 0xd8, 0x76, 0x4b, 0xc4, 0x64, 0x49, 0xc3, 0x90, 0x47}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9895,189 +9940,205 @@ TEST(Connect5QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "OX\145\244\252\182\254\FS\130\252\134@\172\223\164\157{X}\165\146\152~f\219", _willMsg = -// "@\129Q\244!\183oR", _willProps = [PropResponseTopic "\156@",PropCorrelationData -// "Dp\NAK\235T\197oT\186\NUL\nF=\233\\~[V\211\179`\SYN9i\217\184dvO",PropPayloadFormatIndicator 161,PropContentType -// "AfZ\168\242p\198\175\NAK]\185\FS\229D\ESC\251\168\164fe\SUB\246N\218w\ESCdot",PropSubscriptionIdentifier -// 29,PropServerReference "q\222h\158L\230\162\DC1\237\133",PropAuthenticationData -// "\SUB\155Wv\128y",PropWildcardSubscriptionAvailable 8,PropUserProperty -// "\165m\248\222>\"\SYNJ\213S\148\ENQ<\179T\157B\166\185\142\169\181\162\NULw\250\145\SYN\170f" -// ",\DC1vBU\246\159=\SUB%\\rFKB(aoC\DC3\166\132\RS\DC1^",PropCorrelationData -// "l\b\134\228\218\227\176s\138\151'hl\n",PropResponseTopic -// "\171|<3\155!E\169i\225\DELn\185\ETB\186zne\145\SO\181\236\150_\140\SUB\254\230",PropWildcardSubscriptionAvailable -// 1,PropServerKeepAlive 29600,PropAuthenticationData "\203B\r\RS\199\184\243\164`",PropWillDelayInterval -// 13457,PropWillDelayInterval 12828,PropMaximumPacketSize 9940,PropResponseTopic -// "\131|\174-\n\221\169\DEL\237\193\205\169\DLE`t\167",PropTopicAlias 3659,PropPayloadFormatIndicator -// 160,PropRetainAvailable 158,PropRequestProblemInformation 243,PropRetainAvailable 34,PropResponseTopic -// "\155\252\199\245\193\208U"]}), _cleanSession = False, _keepAlive = 30518, _connID = -// "W\161E\137\235\171\156\EM\227`e^\234\242\248\227rj\195\139\NAK", _properties = [PropReceiveMaximum -// 17590,PropMaximumPacketSize 26394,PropSessionExpiryInterval 21423,PropReceiveMaximum 6468,PropMessageExpiryInterval -// 23431,PropRequestResponseInformation 180,PropCorrelationData -// "\197\SYN~\191|\213\DC1b9t\243'\246\154",PropSubscriptionIdentifier 15,PropSubscriptionIdentifier -// 29,PropServerReference "z\152\203\191c\203\GS\251\243\170\247\159t\255u",PropContentType -// "\224\GS\196\245\232i",PropResponseInformation "\184\184\152'\199\187\&4\US\191\DLE\218\245\197]\233T\EM\153\245y\218 -// \230\210(\190\CAN\175\SO",PropTopicAlias 4418,PropServerKeepAlive 11532,PropServerReference -// "\245\148\RSX\234\243",PropAuthenticationData -// "\225\&6B>\DEL&\189\220\237\132v\"\177\226<1\136\173\154]\SOH\205\252\178\131",PropServerKeepAlive -// 31846,PropServerKeepAlive 25329,PropTopicAliasMaximum 26607,PropMessageExpiryInterval 29456,PropMaximumPacketSize -// 26694,PropSessionExpiryInterval 12931,PropContentType -// "Y\136\218Z\133T\174x\212r\f\"\137n}\162\137\254\206Z\249\129$oc",PropWildcardSubscriptionAvailable -// 193,PropSharedSubscriptionAvailable 186,PropAuthenticationData -// "\224\200\a\140\134\FS\172\171~&\DLE\154\246l5A3",PropMessageExpiryInterval 17774,PropSubscriptionIdentifierAvailable -// 142,PropReasonString "R&\173\137v\248]\157\164\r\143\163z\DLEL\250\136\136N\166\252\vG\140\&1\157\DLE,\156"]} +// ConnectRequest {_username = Just "A\215\192x\237\STX\181-", _password = Just "\148", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "\222\FS4[\199l\134\149\221T_=\130G\192\&4\179\205S>O", _willMsg +// = "\244\177\ETB\252l\159# _\EM\n\239X\ETB\156m",PropSessionExpiryInterval +// 3800,PropAuthenticationData +// "\246\198\195\DEL\241\DEL\251FU\136\141\144\"\EMg>Cm\183\152\f\225s\242\152p\207#\161\177",PropSharedSubscriptionAvailable +// 89,PropServerReference "\130\b\168",PropCorrelationData "k\SOH\215t\247*(!\242\156",PropRetainAvailable +// 112,PropContentType "U\182\229\154\DC4\245\NAK\248Q\250Q}",PropPayloadFormatIndicator 148,PropUserProperty +// "\fB\253\254\159\131\142iMU\198\171\151\ENQne\221`Y\192\"\EM<\158#g" +// "\222\239,1\GS\148\253$\227\254\231+\176\145\241\DC4\206ED\155\163\226\254\199\170:\239\168\248\EM",PropReceiveMaximum +// 13798,PropAuthenticationData +// "\208gik_\195}\f\131\181\GSL\140\132;\168\&81\212\143\225\149\236",PropPayloadFormatIndicator +// 86,PropResponseInformation +// "\201\\\ETX\NUL\171\f\\/\186\159\153\SYN\157y\191_\FS\163\167\144\223?\164\&8\168&",PropRequestProblemInformation +// 86,PropRetainAvailable 121,PropCorrelationData "\f\133\190\191.\r\244&D/$s\226r\a_\246",PropMessageExpiryInterval +// 31196]}), _cleanSession = False, _keepAlive = 4049, _connID = "\209\185#Y\198\163T\169S\ETX", _properties = +// [PropResponseInformation "\133\131\216",PropReasonString "\186\SYN\250F\DC3\144",PropMaximumPacketSize +// 29022,PropMaximumQoS 88,PropAuthenticationMethod "\185f\RSc\195\DC1D\240",PropCorrelationData +// "\254-}\r\"r\GSjh(\223\GS\NAK\242X\t0s\245\184\141\135\128t\225\209JA]d",PropRequestProblemInformation +// 128,PropSubscriptionIdentifier 29,PropSubscriptionIdentifierAvailable 57,PropServerKeepAlive +// 2265,PropAuthenticationData +// "\235\208\NUL\151-zx\DC4\143\US\247\ETX\137\222\254\146M\190\165\183",PropResponseInformation +// "",PropWillDelayInterval 29590,PropTopicAlias 12605,PropSubscriptionIdentifier 0,PropAuthenticationMethod +// "i\234/",PropResponseTopic +// "\222U\134\254\212\202\205$\"\202\138\SOH,\227\220'2\233\162\135l\199D\237",PropAuthenticationData +// "grt\SOH&*\246-\229N\218\167>J\181",PropAuthenticationData +// "\155\161\242\128\197\157\ETX;\229m\238\198\&1",PropTopicAliasMaximum 15991,PropRetainAvailable 101,PropTopicAlias +// 15725,PropAuthenticationMethod "9)^\145;/iwN:\149\251\245y\DC2\ACK\205\191X\250\219\145"]} TEST(Connect5QCTest, Encode29) { uint8_t pkt[] = { - 0x10, 0xe4, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x24, 0x77, 0x36, 0x85, 0x2, 0x21, 0x44, 0xb6, 0x27, - 0x0, 0x0, 0x67, 0x1a, 0x11, 0x0, 0x0, 0x53, 0xaf, 0x21, 0x19, 0x44, 0x2, 0x0, 0x0, 0x5b, 0x87, 0x19, 0xb4, - 0x9, 0x0, 0xe, 0xc5, 0x16, 0x7e, 0xbf, 0x7c, 0xd5, 0x11, 0x62, 0x39, 0x74, 0xf3, 0x27, 0xf6, 0x9a, 0xb, 0xf, - 0xb, 0x1d, 0x1c, 0x0, 0xf, 0x7a, 0x98, 0xcb, 0xbf, 0x63, 0xcb, 0x1d, 0xfb, 0xf3, 0xaa, 0xf7, 0x9f, 0x74, 0xff, - 0x75, 0x3, 0x0, 0x6, 0xe0, 0x1d, 0xc4, 0xf5, 0xe8, 0x69, 0x1a, 0x0, 0x1d, 0xb8, 0xb8, 0x98, 0x27, 0xc7, 0xbb, - 0x34, 0x1f, 0xbf, 0x10, 0xda, 0xf5, 0xc5, 0x5d, 0xe9, 0x54, 0x19, 0x99, 0xf5, 0x79, 0xda, 0x20, 0xe6, 0xd2, 0x28, - 0xbe, 0x18, 0xaf, 0xe, 0x23, 0x11, 0x42, 0x13, 0x2d, 0xc, 0x1c, 0x0, 0x6, 0xf5, 0x94, 0x1e, 0x58, 0xea, 0xf3, - 0x16, 0x0, 0x19, 0xe1, 0x36, 0x42, 0x3e, 0x7f, 0x26, 0xbd, 0xdc, 0xed, 0x84, 0x76, 0x22, 0xb1, 0xe2, 0x3c, 0x31, - 0x88, 0xad, 0x9a, 0x5d, 0x1, 0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, - 0x1c, 0x27, 0x0, 0x0, 0x26, 0xd4, 0x8, 0x0, 0x10, 0x83, 0x7c, 0xae, 0x2d, 0xa, 0xdd, 0xa9, 0x7f, 0xed, 0xc1, - 0xcd, 0xa9, 0x10, 0x60, 0x74, 0xa7, 0x23, 0xe, 0x4b, 0x1, 0xa0, 0x25, 0x9e, 0x17, 0xf3, 0x25, 0x22, 0x8, 0x0, - 0x7, 0x9b, 0xfc, 0xc7, 0xf5, 0xc1, 0xd0, 0x55, 0x0, 0x19, 0x4f, 0x58, 0x91, 0xf4, 0xfc, 0xb6, 0xfe, 0x1c, 0x82, - 0xfc, 0x86, 0x40, 0xac, 0xdf, 0xa4, 0x9d, 0x7b, 0x58, 0x7d, 0xa5, 0x92, 0x98, 0x7e, 0x66, 0xdb, 0x0, 0x8, 0x40, - 0x81, 0x51, 0xf4, 0x21, 0xb7, 0x6f, 0x52}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xc5, 0x16, 0x7e, 0xbf, 0x7c, 0xd5, 0x11, 0x62, 0x39, 0x74, 0xf3, 0x27, 0xf6, 0x9a}; - uint8_t bytesprops1[] = {0x7a, 0x98, 0xcb, 0xbf, 0x63, 0xcb, 0x1d, 0xfb, 0xf3, 0xaa, 0xf7, 0x9f, 0x74, 0xff, 0x75}; - uint8_t bytesprops2[] = {0xe0, 0x1d, 0xc4, 0xf5, 0xe8, 0x69}; - uint8_t bytesprops3[] = {0xb8, 0xb8, 0x98, 0x27, 0xc7, 0xbb, 0x34, 0x1f, 0xbf, 0x10, 0xda, 0xf5, 0xc5, 0x5d, 0xe9, - 0x54, 0x19, 0x99, 0xf5, 0x79, 0xda, 0x20, 0xe6, 0xd2, 0x28, 0xbe, 0x18, 0xaf, 0xe}; - uint8_t bytesprops4[] = {0xf5, 0x94, 0x1e, 0x58, 0xea, 0xf3}; - uint8_t bytesprops5[] = {0xe1, 0x36, 0x42, 0x3e, 0x7f, 0x26, 0xbd, 0xdc, 0xed, 0x84, 0x76, 0x22, 0xb1, - 0xe2, 0x3c, 0x31, 0x88, 0xad, 0x9a, 0x5d, 0x1, 0xcd, 0xfc, 0xb2, 0x83}; - uint8_t bytesprops6[] = {0x59, 0x88, 0xda, 0x5a, 0x85, 0x54, 0xae, 0x78, 0xd4, 0x72, 0xc, 0x22, 0x89, - 0x6e, 0x7d, 0xa2, 0x89, 0xfe, 0xce, 0x5a, 0xf9, 0x81, 0x24, 0x6f, 0x63}; - uint8_t bytesprops7[] = {0xe0, 0xc8, 0x7, 0x8c, 0x86, 0x1c, 0xac, 0xab, 0x7e, - 0x26, 0x10, 0x9a, 0xf6, 0x6c, 0x35, 0x41, 0x33}; - uint8_t bytesprops8[] = {0x52, 0x26, 0xad, 0x89, 0x76, 0xf8, 0x5d, 0x9d, 0xa4, 0xd, 0x8f, 0xa3, 0x7a, 0x10, 0x4c, - 0xfa, 0x88, 0x88, 0x4e, 0xa6, 0xfc, 0xb, 0x47, 0x8c, 0x31, 0x9d, 0x10, 0x2c, 0x9c}; + 0x10, 0x86, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0xf, 0xd1, 0xd3, 0x1, 0x1a, 0x0, 0x3, 0x85, + 0x83, 0xd8, 0x1f, 0x0, 0x6, 0xba, 0x16, 0xfa, 0x46, 0x13, 0x90, 0x27, 0x0, 0x0, 0x71, 0x5e, 0x24, 0x58, 0x15, + 0x0, 0x8, 0xb9, 0x66, 0x1e, 0x63, 0xc3, 0x11, 0x44, 0xf0, 0x9, 0x0, 0x1e, 0xfe, 0x2d, 0x7d, 0xd, 0x22, 0x72, + 0x1d, 0x6a, 0x68, 0x28, 0xdf, 0x1d, 0x15, 0xf2, 0x58, 0x9, 0x30, 0x73, 0xf5, 0xb8, 0x8d, 0x87, 0x80, 0x74, 0xe1, + 0xd1, 0x4a, 0x41, 0x5d, 0x64, 0x17, 0x80, 0xb, 0x1d, 0x29, 0x39, 0x13, 0x8, 0xd9, 0x16, 0x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+ uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x85, 0x83, 0xd8}; + uint8_t bytesprops1[] = {0xba, 0x16, 0xfa, 0x46, 0x13, 0x90}; + uint8_t bytesprops2[] = {0xb9, 0x66, 0x1e, 0x63, 0xc3, 0x11, 0x44, 0xf0}; + uint8_t bytesprops3[] = {0xfe, 0x2d, 0x7d, 0xd, 0x22, 0x72, 0x1d, 0x6a, 0x68, 0x28, 0xdf, 0x1d, 0x15, 0xf2, 0x58, + 0x9, 0x30, 0x73, 0xf5, 0xb8, 0x8d, 0x87, 0x80, 0x74, 0xe1, 0xd1, 0x4a, 0x41, 0x5d, 0x64}; + uint8_t bytesprops4[] = {0xeb, 0xd0, 0x0, 0x97, 0x2d, 0x7a, 0x78, 0x14, 0x8f, 0x1f, + 0xf7, 0x3, 0x89, 0xde, 0xfe, 0x92, 0x4d, 0xbe, 0xa5, 0xb7}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0x69, 0xea, 0x2f}; + uint8_t bytesprops7[] = {0xde, 0x55, 0x86, 0xfe, 0xd4, 0xca, 0xcd, 0x24, 0x22, 0xca, 0x8a, 0x1, + 0x2c, 0xe3, 0xdc, 0x27, 0x32, 0xe9, 0xa2, 0x87, 0x6c, 0xc7, 0x44, 0xed}; + uint8_t bytesprops8[] = {0x67, 0x72, 0x74, 0x1, 0x26, 0x2a, 0xf6, 0x2d, 0xe5, 0x4e, 0xda, 0xa7, 0x3e, 0x4a, 0xb5}; + uint8_t bytesprops9[] = {0x9b, 0xa1, 0xf2, 0x80, 0xc5, 0x9d, 0x3, 0x3b, 0xe5, 0x6d, 0xee, 0xc6, 0x31}; + uint8_t bytesprops10[] = {0x39, 0x29, 0x5e, 0x91, 0x3b, 0x2f, 0x69, 0x77, 0x4e, 0x3a, 0x95, + 0xfb, 0xf5, 0x79, 0x12, 0x6, 0xcd, 0xbf, 0x58, 0xfa, 0xdb, 0x91}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17590}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26394}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21423}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6468}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23431}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29022}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 128}}, {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4418}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11532}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31846}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25329}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26607}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29456}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26694}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12931}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17774}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2265}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29590}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12605}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15991}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15725}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x9c, 0x40}; - uint8_t byteswillprops1[] = {0x44, 0x70, 0x15, 0xeb, 0x54, 0xc5, 0x6f, 0x54, 0xba, 0x0, 0xa, 0x46, 0x3d, 0xe9, 0x5c, - 0x7e, 0x5b, 0x56, 0xd3, 0xb3, 0x60, 0x16, 0x39, 0x69, 0xd9, 0xb8, 0x64, 0x76, 0x4f}; - uint8_t byteswillprops2[] = {0x41, 0x66, 0x5a, 0xa8, 0xf2, 0x70, 0xc6, 0xaf, 0x15, 0x5d, 0xb9, 0x1c, 0xe5, 0x44, 0x1b, - 0xfb, 0xa8, 0xa4, 0x66, 0x65, 0x1a, 0xf6, 0x4e, 0xda, 0x77, 0x1b, 0x64, 0x6f, 0x74}; - uint8_t byteswillprops3[] = {0x71, 0xde, 0x68, 0x9e, 0x4c, 0xe6, 0xa2, 0x11, 0xed, 0x85}; - uint8_t byteswillprops4[] = {0x1a, 0x9b, 0x57, 0x76, 0x80, 0x79}; - uint8_t byteswillprops6[] = {0x2c, 0x11, 0x76, 0x42, 0x55, 0xf6, 0x9f, 0x3d, 0x1a, 0x25, 0x5c, 0x72, 0x46, - 0x4b, 0x42, 0x28, 0x61, 0x6f, 0x43, 0x13, 0xa6, 0x84, 0x1e, 0x11, 0x5e}; - uint8_t byteswillprops5[] = {0xa5, 0x6d, 0xf8, 0xde, 0x3e, 0x22, 0x16, 0x4a, 0xd5, 0x53, - 0x94, 0x5, 0x3c, 0xb3, 0x54, 0x9d, 0x42, 0xa6, 0xb9, 0x8e, - 0xa9, 0xb5, 0xa2, 0x0, 0x77, 0xfa, 0x91, 0x16, 0xaa, 0x66}; - uint8_t byteswillprops7[] = {0x6c, 0x8, 0x86, 0xe4, 0xda, 0xe3, 0xb0, 0x73, 0x8a, 0x97, 0x27, 0x68, 0x6c, 0xa}; - uint8_t byteswillprops8[] = {0xab, 0x7c, 0x3c, 0x33, 0x9b, 0x21, 0x45, 0xa9, 0x69, 0xe1, 0x7f, 0x6e, 0xb9, 0x17, - 0xba, 0x7a, 0x6e, 0x65, 0x91, 0xe, 0xb5, 0xec, 0x96, 0x5f, 0x8c, 0x1a, 0xfe, 0xe6}; - uint8_t byteswillprops9[] = {0xcb, 0x42, 0xd, 0x1e, 0xc7, 0xb8, 0xf3, 0xa4, 0x60}; - uint8_t byteswillprops10[] = {0x83, 0x7c, 0xae, 0x2d, 0xa, 0xdd, 0xa9, 0x7f, - 0xed, 0xc1, 0xcd, 0xa9, 0x10, 0x60, 0x74, 0xa7}; - uint8_t byteswillprops11[] = {0x9b, 0xfc, 0xc7, 0xf5, 0xc1, 0xd0, 0x55}; + uint8_t byteswillprops1[] = {0xbd, 0x2e, 0xb7, 0x2f, 0xe4, 0xcc, 0x4f, 0x1f, 0xe0, 0x76, 0x61, 0x6a}; + uint8_t byteswillprops0[] = {0xb9, 0x7b, 0x94, 0x19, 0xa6, 0x7b, 0x67, 0x93, 0x4f, 0x18, 0x95, 0xa, 0xa0, 0x3a}; + uint8_t byteswillprops2[] = {0xa6, 0xa0, 0x3a, 0xdf, 0xdd, 0xfd, 0x18, 0x7d, 0x64}; + uint8_t byteswillprops3[] = {0xc3, 0xdc, 0x87, 0xae, 0x71, 0xd7, 0x84}; + uint8_t byteswillprops5[] = {0x9b, 0xf9, 0x27, 0xb, 0x3d, 0x49, 0xa5, 0x1f, 0xa8, 0x3a, 0x7f, 0xe5, 0x75, + 0x97, 0x92, 0xb6, 0xf8, 0xe0, 0x97, 0x3e, 0xef, 0x58, 0x17, 0x9c, 0x6d}; + uint8_t byteswillprops4[] = {0xb4, 0x86, 0x20, 0xfa, 0xdb, 0xaf, 0x9d, 0xc6, 0x6, 0x81, 0x28, 0xa2, 0xd1, + 0xf9, 0x9d, 0x34, 0xb7, 0x48, 0x86, 0x41, 0x2c, 0xd7, 0xf1, 0x10, 0xdf}; + uint8_t byteswillprops6[] = {0xf6, 0xc6, 0xc3, 0x7f, 0xf1, 0x7f, 0xfb, 0x46, 0x55, 0x88, + 0x8d, 0x90, 0x22, 0x19, 0x67, 0x3e, 0x43, 0x6d, 0xb7, 0x98, + 0xc, 0xe1, 0x73, 0xf2, 0x98, 0x70, 0xcf, 0x23, 0xa1, 0xb1}; + uint8_t byteswillprops7[] = {0x82, 0x8, 0xa8}; + uint8_t byteswillprops8[] = {0x6b, 0x1, 0xd7, 0x74, 0xf7, 0x2a, 0x28, 0x21, 0xf2, 0x9c}; + uint8_t byteswillprops9[] = {0x55, 0xb6, 0xe5, 0x9a, 0x14, 0xf5, 0x15, 0xf8, 0x51, 0xfa, 0x51, 0x7d}; + uint8_t byteswillprops11[] = {0xde, 0xef, 0x2c, 0x31, 0x1d, 0x94, 0xfd, 0x24, 0xe3, 0xfe, + 0xe7, 0x2b, 0xb0, 0x91, 0xf1, 0x14, 0xce, 0x45, 0x44, 0x9b, + 0xa3, 0xe2, 0xfe, 0xc7, 0xaa, 0x3a, 0xef, 0xa8, 0xf8, 0x19}; + uint8_t byteswillprops10[] = {0xc, 0x42, 0xfd, 0xfe, 0x9f, 0x83, 0x8e, 0x69, 0x4d, 0x55, 0xc6, 0xab, 0x97, + 0x5, 0x6e, 0x65, 0xdd, 0x60, 0x59, 0xc0, 0x22, 0x19, 0x3c, 0x9e, 0x23, 0x67}; + uint8_t byteswillprops12[] = {0xd0, 0x67, 0x69, 0x6b, 0x5f, 0xc3, 0x7d, 0xc, 0x83, 0xb5, 0x1d, 0x4c, + 0x8c, 0x84, 0x3b, 0xa8, 0x38, 0x31, 0xd4, 0x8f, 0xe1, 0x95, 0xec}; + uint8_t byteswillprops13[] = {0xc9, 0x5c, 0x3, 0x0, 0xab, 0xc, 0x5c, 0x2f, 0xba, 0x9f, 0x99, 0x16, 0x9d, + 0x79, 0xbf, 0x5f, 0x1c, 0xa3, 0xa7, 0x90, 0xdf, 0x3f, 0xa4, 0x38, 0xa8, 0x26}; + uint8_t byteswillprops14[] = {0xc, 0x85, 0xbe, 0xbf, 0x2e, 0xd, 0xf4, 0x26, 0x44, + 0x2f, 0x24, 0x73, 0xe2, 0x72, 0x7, 0x5f, 0xf6}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 8}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {30, (char*)&byteswillprops5}, .v = {25, (char*)&byteswillprops6}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29600}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13457}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12828}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9940}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3659}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops11}}}, + .value = {.pair = {.k = {14, (char*)&byteswillprops0}, .v = {12, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31819}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13095}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {25, (char*)&byteswillprops4}, .v = {25, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3800}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {26, (char*)&byteswillprops10}, .v = {30, (char*)&byteswillprops11}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13798}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops12}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops13}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&byteswillprops14}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31196}}, }; - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4f, 0x58, 0x91, 0xf4, 0xfc, 0xb6, 0xfe, 0x1c, 0x82, 0xfc, 0x86, 0x40, 0xac, - 0xdf, 0xa4, 0x9d, 0x7b, 0x58, 0x7d, 0xa5, 0x92, 0x98, 0x7e, 0x66, 0xdb}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x40, 0x81, 0x51, 0xf4, 0x21, 0xb7, 0x6f, 0x52}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xde, 0x1c, 0x34, 0x5b, 0xc7, 0x6c, 0x86, 0x95, 0xdd, 0x54, 0x5f, + 0x3d, 0x82, 0x47, 0xc0, 0x34, 0xb3, 0xcd, 0x53, 0x3e, 0x4f}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf4, 0xb1, 0x17, 0xfc, 0x6c, 0x9f, 0x23, 0x20, + 0x5f, 0x19, 0xa, 0x3c, 0x43, 0x85, 0xa3}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 30518; - uint8_t client_id_bytes[] = {0x57, 0xa1, 0x45, 0x89, 0xeb, 0xab, 0x9c, 0x19, 0xe3, 0x60, 0x65, - 0x5e, 0xea, 0xf2, 0xf8, 0xe3, 0x72, 0x6a, 0xc3, 0x8b, 0x15}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.keep_alive = 4049; + uint8_t client_id_bytes[] = {0xd1, 0xb9, 0x23, 0x59, 0xc6, 0xa3, 0x54, 0xa9, 0x53, 0x3}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t username_bytes[] = {0x41, 0xd7, 0xc0, 0x78, 0xed, 0x2, 0xb5, 0x2d}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x94}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10087,4471 +10148,5669 @@ TEST(Connect5QCTest, Encode29) { } // ConnectRequest {_username = Just -// "\233\DLEuz,\235\221\183\245C\171\219\241^\213\168\160\167\181<\210\175\201\225\241\132\251\229e\164", _password = -// Just "\240\180X}9\198\t\SUBK\211\ACK\179t\255\237\148 no\DC3\203\&3;\198", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS2, _willTopic = -// "\157\167S\173)\208\193\243\142\STX?\244\199<\DC3\202VL\215\218\215\162\174~\167G1\t\196)", _willMsg = "", _willProps -// = [PropResponseInformation "\SI\170\241\213p6LF\SYN\129\135:",PropMaximumQoS 183,PropWildcardSubscriptionAvailable -// 207,PropSubscriptionIdentifier 18,PropResponseInformation -// "\213\165llx\EM\158\206\220\&3z~\140",PropAuthenticationMethod -// "\251\132\158\r\154\170<\243\247\140\178\151\DC3\230w\SUB\129SwA",PropMessageExpiryInterval -// 14841,PropAuthenticationData "\251a\SYN\181^\224\SO\163Q\n5\n\198\150Xe&\DLE",PropRequestResponseInformation -// 214,PropRequestProblemInformation 220,PropSharedSubscriptionAvailable 246,PropContentType -// "\169\194\DC2\SUB\199Qs]j\159P\239\223K\193V",PropRetainAvailable 115,PropMaximumQoS 207]}), _cleanSession = False, -// _keepAlive = 26007, _connID = "N\237\211", _properties = [PropTopicAlias 31274,PropUserProperty -// "S\ESCE\154\&9$\251\254\GS\193_\174\ETB-_\181GJ.A\221\\\187\230\SOH\201\255\200" -// "\144\211$\f\225\133\208s\159\162\171\254!\209\210\141\v\197\237\ENQ\253\169\247\224)\223",PropRetainAvailable -// 115,PropAuthenticationData "j",PropAuthenticationData -// "\154\r\138%\146`\147\197\145)9\185\176Z\ENQ9`\217\174\208|\193y",PropMessageExpiryInterval 206,PropContentType -// "#\219\&7\EMi\208\148\253H[c\209s\SOH\161\235w?\DEL\137\&7&9",PropWildcardSubscriptionAvailable 226,PropResponseTopic -// "\182{\212\195\n\209H\222zP){R\142\150\218$Oa\147K\173",PropRequestProblemInformation -// 145,PropSubscriptionIdentifierAvailable 20,PropRequestResponseInformation 22,PropTopicAlias -// 5924,PropPayloadFormatIndicator 84,PropMaximumPacketSize 26952,PropMaximumQoS 207,PropRetainAvailable -// 246,PropServerReference "&S\nC\169\RS\181dI\243/\252x",PropSharedSubscriptionAvailable 163,PropTopicAlias -// 19727,PropContentType "J\236jFj\207"]} +// "\187\252\SOHf\232\ACK\213\245\176\252\195\235\242\&9\182\171\n\a\222HA\SI\186\135\ti", _password = Just +// "P\241&f\236\151C\175\171", _lastWill = Nothing, _cleanSession = True, _keepAlive = 26836, _connID = +// "\203,\DLE\255\EOT\245\146\234>\226\148\240e\135\229\SUB\SUB5", _properties = [PropPayloadFormatIndicator +// 97,PropResponseInformation "&\151E\158\144\186\180k\214'\202\&3\"x%vh=\SI\166\250W\219\202",PropTopicAliasMaximum +// 12587,PropAuthenticationMethod +// "1\180\243\SI\STX\f\188\249\225\155\152\&3)UlV3\155\232\211\SYN\243~3\CAN9",PropUserProperty +// "\199\187@\252\233r\a9\153\213t\251\&4\233\244" +// "\255s\163\178\&2\176\213\172\&9\157\253~,\RSE\CANj6P;B",PropSessionExpiryInterval 31793,PropAuthenticationData +// "\ETBBp\181k\135\193\"\DC2`",PropWildcardSubscriptionAvailable 59,PropSharedSubscriptionAvailable +// 138,PropRequestProblemInformation 105,PropRequestResponseInformation 131,PropSubscriptionIdentifier +// 33,PropWildcardSubscriptionAvailable 16,PropContentType "M\199\154",PropAuthenticationData +// "\ETX8C*\243\140\SI\227\184\129\182\181l",PropReceiveMaximum 5301,PropContentType +// "\157\SI\202\168\a\NAK\196tI\133\218W",PropRequestResponseInformation 173,PropRequestResponseInformation +// 206,PropTopicAlias 31868,PropRequestResponseInformation 241,PropMessageExpiryInterval 22153,PropUserProperty +// "\209\168\230" "B\180\184gppr\GS\182\RS\154p\157\NUL]rj9\SO\249)\SI:"]} TEST(Connect5QCTest, Encode30) { uint8_t pkt[] = { - 0x10, 0xab, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x65, 0x97, 0xca, 0x1, 0x23, 0x7a, 0x2a, 0x26, - 0x0, 0x1c, 0x53, 0x1b, 0x45, 0x9a, 0x39, 0x24, 0xfb, 0xfe, 0x1d, 0xc1, 0x5f, 0xae, 0x17, 0x2d, 0x5f, 0xb5, 0x47, - 0x4a, 0x2e, 0x41, 0xdd, 0x5c, 0xbb, 0xe6, 0x1, 0xc9, 0xff, 0xc8, 0x0, 0x1a, 0x90, 0xd3, 0x24, 0xc, 0xe1, 0x85, - 0xd0, 0x73, 0x9f, 0xa2, 0xab, 0xfe, 0x21, 0xd1, 0xd2, 0x8d, 0xb, 0xc5, 0xed, 0x5, 0xfd, 0xa9, 0xf7, 0xe0, 0x29, - 0xdf, 0x25, 0x73, 0x16, 0x0, 0x1, 0x6a, 0x16, 0x0, 0x17, 0x9a, 0xd, 0x8a, 0x25, 0x92, 0x60, 0x93, 0xc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bytesprops0[] = {0x53, 0x1b, 0x45, 0x9a, 0x39, 0x24, 0xfb, 0xfe, 0x1d, 0xc1, 0x5f, 0xae, 0x17, 0x2d, - 0x5f, 0xb5, 0x47, 0x4a, 0x2e, 0x41, 0xdd, 0x5c, 0xbb, 0xe6, 0x1, 0xc9, 0xff, 0xc8}; - uint8_t bytesprops2[] = {0x6a}; - uint8_t bytesprops3[] = {0x9a, 0xd, 0x8a, 0x25, 0x92, 0x60, 0x93, 0xc5, 0x91, 0x29, 0x39, 0xb9, - 0xb0, 0x5a, 0x5, 0x39, 0x60, 0xd9, 0xae, 0xd0, 0x7c, 0xc1, 0x79}; - uint8_t bytesprops4[] = {0x23, 0xdb, 0x37, 0x19, 0x69, 0xd0, 0x94, 0xfd, 0x48, 0x5b, 0x63, 0xd1, - 0x73, 0x1, 0xa1, 0xeb, 0x77, 0x3f, 0x7f, 0x89, 0x37, 0x26, 0x39}; - uint8_t bytesprops5[] = {0xb6, 0x7b, 0xd4, 0xc3, 0xa, 0xd1, 0x48, 0xde, 0x7a, 0x50, 0x29, - 0x7b, 0x52, 0x8e, 0x96, 0xda, 0x24, 0x4f, 0x61, 0x93, 0x4b, 0xad}; - uint8_t bytesprops6[] = {0x26, 0x53, 0xa, 0x43, 0xa9, 0x1e, 0xb5, 0x64, 0x49, 0xf3, 0x2f, 0xfc, 0x78}; - uint8_t bytesprops7[] = {0x4a, 0xec, 0x6a, 0x46, 0x6a, 0xcf}; + 0x10, 0xa0, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x68, 0xd4, 0xd9, 0x1, 0x1, 0x61, 0x1a, 0x0, + 0x18, 0x26, 0x97, 0x45, 0x9e, 0x90, 0xba, 0xb4, 0x6b, 0xd6, 0x27, 0xca, 0x33, 0x22, 0x78, 0x25, 0x76, 0x68, 0x3d, + 0xf, 0xa6, 0xfa, 0x57, 0xdb, 0xca, 0x22, 0x31, 0x2b, 0x15, 0x0, 0x1a, 0x31, 0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5, 0x92, 0xea, 0x3e, 0xe2, 0x94, 0xf0, 0x65, + 0x87, 0xe5, 0x1a, 0x1a, 0x35, 0x0, 0x1a, 0xbb, 0xfc, 0x1, 0x66, 0xe8, 0x6, 0xd5, 0xf5, 0xb0, 0xfc, 0xc3, 0xeb, + 0xf2, 0x39, 0xb6, 0xab, 0xa, 0x7, 0xde, 0x48, 0x41, 0xf, 0xba, 0x87, 0x9, 0x69, 0x0, 0x9, 0x50, 0xf1, 0x26, + 0x66, 0xec, 0x97, 0x43, 0xaf, 0xab}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x26, 0x97, 0x45, 0x9e, 0x90, 0xba, 0xb4, 0x6b, 0xd6, 0x27, 0xca, 0x33, + 0x22, 0x78, 0x25, 0x76, 0x68, 0x3d, 0xf, 0xa6, 0xfa, 0x57, 0xdb, 0xca}; + uint8_t bytesprops1[] = {0x31, 0xb4, 0xf3, 0xf, 0x2, 0xc, 0xbc, 0xf9, 0xe1, 0x9b, 0x98, 0x33, 0x29, + 0x55, 0x6c, 0x56, 0x33, 0x9b, 0xe8, 0xd3, 0x16, 0xf3, 0x7e, 0x33, 0x18, 0x39}; + uint8_t bytesprops3[] = {0xff, 0x73, 0xa3, 0xb2, 0x32, 0xb0, 0xd5, 0xac, 0x39, 0x9d, 0xfd, + 0x7e, 0x2c, 0x1e, 0x45, 0x18, 0x6a, 0x36, 0x50, 0x3b, 0x42}; + uint8_t bytesprops2[] = {0xc7, 0xbb, 0x40, 0xfc, 0xe9, 0x72, 0x7, 0x39, 0x99, 0xd5, 0x74, 0xfb, 0x34, 0xe9, 0xf4}; + uint8_t bytesprops4[] = {0x17, 0x42, 0x70, 0xb5, 0x6b, 0x87, 0xc1, 0x22, 0x12, 0x60}; + uint8_t bytesprops5[] = {0x4d, 0xc7, 0x9a}; + uint8_t bytesprops6[] = {0x3, 0x38, 0x43, 0x2a, 0xf3, 0x8c, 0xf, 0xe3, 0xb8, 0x81, 0xb6, 0xb5, 0x6c}; + uint8_t bytesprops7[] = {0x9d, 0xf, 0xca, 0xa8, 0x7, 0x15, 0xc4, 0x74, 0x49, 0x85, 0xda, 0x57}; + uint8_t bytesprops9[] = {0x42, 0xb4, 0xb8, 0x67, 0x70, 0x70, 0x72, 0x1d, 0xb6, 0x1e, 0x9a, 0x70, + 0x9d, 0x0, 0x5d, 0x72, 0x6a, 0x39, 0xe, 0xf9, 0x29, 0xf, 0x3a}; + uint8_t bytesprops8[] = {0xd1, 0xa8, 0xe6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31274}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops0}, .v = {26, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 206}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5924}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26952}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19727}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops7}}}, - }; - - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xf, 0xaa, 0xf1, 0xd5, 0x70, 0x36, 0x4c, 0x46, 0x16, 0x81, 0x87, 0x3a}; - uint8_t byteswillprops1[] = {0xd5, 0xa5, 0x6c, 0x6c, 0x78, 0x19, 0x9e, 0xce, 0xdc, 0x33, 0x7a, 0x7e, 0x8c}; - uint8_t byteswillprops2[] = {0xfb, 0x84, 0x9e, 0xd, 0x9a, 0xaa, 0x3c, 0xf3, 0xf7, 0x8c, - 0xb2, 0x97, 0x13, 0xe6, 0x77, 0x1a, 0x81, 0x53, 0x77, 0x41}; - uint8_t byteswillprops3[] = {0xfb, 0x61, 0x16, 0xb5, 0x5e, 0xe0, 0xe, 0xa3, 0x51, - 0xa, 0x35, 0xa, 0xc6, 0x96, 0x58, 0x65, 0x26, 0x10}; - uint8_t byteswillprops4[] = {0xa9, 0xc2, 0x12, 0x1a, 0xc7, 0x51, 0x73, 0x5d, - 0x6a, 0x9f, 0x50, 0xef, 0xdf, 0x4b, 0xc1, 0x56}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14841}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12587}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops2}, .v = {21, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31793}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 33}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5301}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31868}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22153}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops8}, .v = {23, (char*)&bytesprops9}}}}, }; - lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9d, 0xa7, 0x53, 0xad, 0x29, 0xd0, 0xc1, 0xf3, 0x8e, 0x2, - 0x3f, 0xf4, 0xc7, 0x3c, 0x13, 0xca, 0x56, 0x4c, 0xd7, 0xda, - 0xd7, 0xa2, 0xae, 0x7e, 0xa7, 0x47, 0x31, 0x9, 0xc4, 0x29}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 26007; - uint8_t client_id_bytes[] = {0x4e, 0xed, 0xd3}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 26836; + uint8_t client_id_bytes[] = {0xcb, 0x2c, 0x10, 0xff, 0x4, 0xf5, 0x92, 0xea, 0x3e, + 0xe2, 0x94, 0xf0, 0x65, 0x87, 0xe5, 0x1a, 0x1a, 0x35}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xe9, 0x10, 0x75, 0x7a, 0x2c, 0xeb, 0xdd, 0xb7, 0xf5, 0x43, 0xab, 0xdb, 0xf1, 0x5e, 0xd5, - 0xa8, 0xa0, 0xa7, 0xb5, 0x3c, 0xd2, 0xaf, 0xc9, 0xe1, 0xf1, 0x84, 0xfb, 0xe5, 0x65, 0xa4}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xbb, 0xfc, 0x1, 0x66, 0xe8, 0x6, 0xd5, 0xf5, 0xb0, 0xfc, 0xc3, 0xeb, 0xf2, + 0x39, 0xb6, 0xab, 0xa, 0x7, 0xde, 0x48, 0x41, 0xf, 0xba, 0x87, 0x9, 0x69}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xf0, 0xb4, 0x58, 0x7d, 0x39, 0xc6, 0x9, 0x1a, 0x4b, 0xd3, 0x6, 0xb3, - 0x74, 0xff, 0xed, 0x94, 0x20, 0x6e, 0x6f, 0x13, 0xcb, 0x33, 0x3b, 0xc6}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x50, 0xf1, 0x26, 0x66, 0xec, 0x97, 0x43, 0xaf, 0xab}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19824 [("\NUL\181VC\229\166\255j \b\FSg\134\253%\212u\175\246K)\203\142>\132\154`n",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("-e\131\&2\165",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("\229\164\170}\NUL6\248\\?V\138\161\245\251\178\192u$\205\204\GS\191",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\255\220\179G\GS\163\207k\"\197u@\218\v\133\aW\US\136\172j\231v",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("S\189\207H\v\DC4\186]k\202\252\ESC2\228w\158C|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 7633 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x71, 0x4d, 0x70, 0x0, 0x1c, 0x0, 0xb5, 0x56, 0x43, 0xe5, 0xa6, 0xff, 0x6a, 0x20, 0x8, 0x1c, - 0x67, 0x86, 0xfd, 0x25, 0xd4, 0x75, 0xaf, 0xf6, 0x4b, 0x29, 0xcb, 0x8e, 0x3e, 0x84, 0x9a, 0x60, 0x6e, - 0x2, 0x0, 0x5, 0x2d, 0x65, 0x83, 0x32, 0xa5, 0x0, 0x0, 0x16, 0xe5, 0xa4, 0xaa, 0x7d, 0x0, 0x36, - 0xf8, 0x5c, 0x3f, 0x56, 0x8a, 0xa1, 0xf5, 0xfb, 0xb2, 0xc0, 0x75, 0x24, 0xcd, 0xcc, 0x1d, 0xbf, 0x1, - 0x0, 0x17, 0xff, 0xdc, 0xb3, 0x47, 0x1d, 0xa3, 0xcf, 0x6b, 0x22, 0xc5, 0x75, 0x40, 0xda, 0xb, 0x85, - 0x7, 0x57, 0x1f, 0x88, 0xac, 0x6a, 0xe7, 0x76, 0x1, 0x0, 0x12, 0x53, 0xbd, 0xcf, 0x48, 0xb, 0x14, - 0xba, 0x5d, 0x6b, 0xca, 0xfc, 0x1b, 0x32, 0xe4, 0x77, 0x9e, 0x43, 0x7c, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x0, 0xb5, 0x56, 0x43, 0xe5, 0xa6, 0xff, 0x6a, 0x20, 0x8, - 0x1c, 0x67, 0x86, 0xfd, 0x25, 0xd4, 0x75, 0xaf, 0xf6, 0x4b, - 0x29, 0xcb, 0x8e, 0x3e, 0x84, 0x9a, 0x60, 0x6e}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x5, 0x1d, 0xd1, 0x0, 0x0, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2d, 0x65, 0x83, 0x32, 0xa5}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe5, 0xa4, 0xaa, 0x7d, 0x0, 0x36, 0xf8, 0x5c, 0x3f, 0x56, 0x8a, - 0xa1, 0xf5, 0xfb, 0xb2, 0xc0, 0x75, 0x24, 0xcd, 0xcc, 0x1d, 0xbf}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xff, 0xdc, 0xb3, 0x47, 0x1d, 0xa3, 0xcf, 0x6b, 0x22, 0xc5, 0x75, 0x40, - 0xda, 0xb, 0x85, 0x7, 0x57, 0x1f, 0x88, 0xac, 0x6a, 0xe7, 0x76}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x53, 0xbd, 0xcf, 0x48, 0xb, 0x14, 0xba, 0x5d, 0x6b, - 0xca, 0xfc, 0x1b, 0x32, 0xe4, 0x77, 0x9e, 0x43, 0x7c}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19824, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7633, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12399 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\250L\239\233\150\180y\246\174\156:\150\247RB",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\130/\NAKA~\213\CAN\RS\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("XMwO\188j\180\242\145D7\132\192e\183\EM\166$\183\158|5",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\167\200\ESC\147B\160\157\186\DC14\244.w#\196\246\200\226\230\EM\179\181\SI",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\f\211U\184\143\231\221\ETXl\181&\ENQ\214*.O\GS\206b\SOFx\v\132\&7\159\151r\238,",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\220\EOT\131\&0{\147\167b\132#\244\188\SUB\r\145\DLE\DELzD\133",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\211\177\223!\136x\241+?\150\246\199V+!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("U0\204\242VJa\154\135yp\US\150\210\212xUN\172=\"\161\134\239\238&\153M",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\226\ETX\215\DC2\164\133_g\140\144\NULo",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 29762 [("J\239",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode2) { - uint8_t pkt[] = { - 0x82, 0xce, 0x1, 0x30, 0x6f, 0x0, 0x0, 0x0, 0x0, 0xf, 0xfa, 0x4c, 0xef, 0xe9, 0x96, 0xb4, 0x79, 0xf6, 0xae, - 0x9c, 0x3a, 0x96, 0xf7, 0x52, 0x42, 0x1, 0x0, 0x9, 0x82, 0x2f, 0x15, 0x41, 0x7e, 0xd5, 0x18, 0x1e, 0xc5, 0x0, - 0x0, 0x16, 0x58, 0x4d, 0x77, 0x4f, 0xbc, 0x6a, 0xb4, 0xf2, 0x91, 0x44, 0x37, 0x84, 0xc0, 0x65, 0xb7, 0x19, 0xa6, - 0x24, 0xb7, 0x9e, 0x7c, 0x35, 0x0, 0x0, 0x17, 0xa7, 0xc8, 0x1b, 0x93, 0x42, 0xa0, 0x9d, 0xba, 0x11, 0x34, 0xf4, - 0x2e, 0x77, 0x23, 0xc4, 0xf6, 0xc8, 0xe2, 0xe6, 0x19, 0xb3, 0xb5, 0xf, 0x2, 0x0, 0x1e, 0xc, 0xd3, 0x55, 0xb8, - 0x8f, 0xe7, 0xdd, 0x3, 0x6c, 0xb5, 0x26, 0x5, 0xd6, 0x2a, 0x2e, 0x4f, 0x1d, 0xce, 0x62, 0xe, 0x46, 0x78, 0xb, - 0x84, 0x37, 0x9f, 0x97, 0x72, 0xee, 0x2c, 0x0, 0x0, 0x14, 0xdc, 0x4, 0x83, 0x30, 0x7b, 0x93, 0xa7, 0x62, 0x84, - 0x23, 0xf4, 0xbc, 0x1a, 0xd, 0x91, 0x10, 0x7f, 0x7a, 0x44, 0x85, 0x2, 0x0, 0xf, 0xd3, 0xb1, 0xdf, 0x21, 0x88, - 0x78, 0xf1, 0x2b, 0x3f, 0x96, 0xf6, 0xc7, 0x56, 0x2b, 0x21, 0x2, 0x0, 0x1c, 0x55, 0x30, 0xcc, 0xf2, 0x56, 0x4a, - 0x61, 0x9a, 0x87, 0x79, 0x70, 0x1f, 0x96, 0xd2, 0xd4, 0x78, 0x55, 0x4e, 0xac, 0x3d, 0x22, 0xa1, 0x86, 0xef, 0xee, - 0x26, 0x99, 0x4d, 0x1, 0x0, 0xc, 0xe2, 0x3, 0xd7, 0x12, 0xa4, 0x85, 0x5f, 0x67, 0x8c, 0x90, 0x0, 0x6f, 0x1}; + uint8_t pkt[] = {0x82, 0x7, 0x74, 0x42, 0x0, 0x2, 0x4a, 0xef, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x4a, 0xef}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfa, 0x4c, 0xef, 0xe9, 0x96, 0xb4, 0x79, 0xf6, - 0xae, 0x9c, 0x3a, 0x96, 0xf7, 0x52, 0x42}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x82, 0x2f, 0x15, 0x41, 0x7e, 0xd5, 0x18, 0x1e, 0xc5}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x58, 0x4d, 0x77, 0x4f, 0xbc, 0x6a, 0xb4, 0xf2, 0x91, 0x44, 0x37, - 0x84, 0xc0, 0x65, 0xb7, 0x19, 0xa6, 0x24, 0xb7, 0x9e, 0x7c, 0x35}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa7, 0xc8, 0x1b, 0x93, 0x42, 0xa0, 0x9d, 0xba, 0x11, 0x34, 0xf4, 0x2e, - 0x77, 0x23, 0xc4, 0xf6, 0xc8, 0xe2, 0xe6, 0x19, 0xb3, 0xb5, 0xf}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc, 0xd3, 0x55, 0xb8, 0x8f, 0xe7, 0xdd, 0x3, 0x6c, 0xb5, - 0x26, 0x5, 0xd6, 0x2a, 0x2e, 0x4f, 0x1d, 0xce, 0x62, 0xe, - 0x46, 0x78, 0xb, 0x84, 0x37, 0x9f, 0x97, 0x72, 0xee, 0x2c}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xdc, 0x4, 0x83, 0x30, 0x7b, 0x93, 0xa7, 0x62, 0x84, 0x23, - 0xf4, 0xbc, 0x1a, 0xd, 0x91, 0x10, 0x7f, 0x7a, 0x44, 0x85}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xd3, 0xb1, 0xdf, 0x21, 0x88, 0x78, 0xf1, 0x2b, - 0x3f, 0x96, 0xf6, 0xc7, 0x56, 0x2b, 0x21}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x55, 0x30, 0xcc, 0xf2, 0x56, 0x4a, 0x61, 0x9a, 0x87, 0x79, - 0x70, 0x1f, 0x96, 0xd2, 0xd4, 0x78, 0x55, 0x4e, 0xac, 0x3d, - 0x22, 0xa1, 0x86, 0xef, 0xee, 0x26, 0x99, 0x4d}; - lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe2, 0x3, 0xd7, 0x12, 0xa4, 0x85, 0x5f, 0x67, 0x8c, 0x90, 0x0, 0x6f}; - lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12399, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29762, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23812 [("l\217\181\248\247R\218\132\148\US\247\151\130\255:P",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("B1X\194\172\224\"\188%\220\224\EM\208\234yj\214\&1I\202\199[\155",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("5)l@\241",SubOptions +// SubscribeRequest 30334 [("/\SUB\DC2:k\140\DC3\184\237\130\214-\204\144j\179\231\244\242tp@\RSZx\ENQX",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\169\t|)\195\169\b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("<\146&\226\RS\169\182\&62\t;\r\171K\170\204 x\140\&9V\245K(\SUB\SOe>\144\252",SubOptions +// QoS2}),("T\210\128\148\230\144\147\&2&+N\138\198\129\156\149",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\a[}\129\251}\153\232\133",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\167\157\EOT\218\v\192%\143\217\155\202\224\246\137",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("n\153\194\225\207\165\197\160\213\NAK\182",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS1}),("\156\198\198\142\194\236T\189\228\175e\155\ETX\145\225\\:\SUB\131\221",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("D\174\175\216\224\ETB\193\170\214\231",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\207\193\224w'\248\246",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x84, 0x1, 0x5d, 0x4, 0x0, 0x10, 0x6c, 0xd9, 0xb5, 0xf8, 0xf7, 0x52, 0xda, 0x84, 0x94, 0x1f, - 0xf7, 0x97, 0x82, 0xff, 0x3a, 0x50, 0x0, 0x0, 0x17, 0x42, 0x31, 0x58, 0xc2, 0xac, 0xe0, 0x22, 0xbc, - 0x25, 0xdc, 0xe0, 0x19, 0xd0, 0xea, 0x79, 0x6a, 0xd6, 0x31, 0x49, 0xca, 0xc7, 0x5b, 0x9b, 0x0, 0x0, - 0x5, 0x35, 0x29, 0x6c, 0x40, 0xf1, 0x2, 0x0, 0x7, 0xa9, 0x9, 0x7c, 0x29, 0xc3, 0xa9, 0x8, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x1e, 0x3c, 0x92, 0x26, 0xe2, 0x1e, 0xa9, 0xb6, 0x36, 0x32, 0x9, 0x3b, 0xd, - 0xab, 0x4b, 0xaa, 0xcc, 0x20, 0x78, 0x8c, 0x39, 0x56, 0xf5, 0x4b, 0x28, 0x1a, 0xe, 0x65, 0x3e, 0x90, - 0xfc, 0x0, 0x0, 0xe, 0xa7, 0x9d, 0x4, 0xda, 0xb, 0xc0, 0x25, 0x8f, 0xd9, 0x9b, 0xca, 0xe0, 0xf6, - 0x89, 0x1, 0x0, 0xb, 0x6e, 0x99, 0xc2, 0xe1, 0xcf, 0xa5, 0xc5, 0xa0, 0xd5, 0x15, 0xb6, 0x1}; + uint8_t pkt[] = {0x82, 0x6d, 0x76, 0x7e, 0x0, 0x1b, 0x2f, 0x1a, 0x12, 0x3a, 0x6b, 0x8c, 0x13, 0xb8, 0xed, 0x82, + 0xd6, 0x2d, 0xcc, 0x90, 0x6a, 0xb3, 0xe7, 0xf4, 0xf2, 0x74, 0x70, 0x40, 0x1e, 0x5a, 0x78, 0x5, + 0x58, 0x2, 0x0, 0x10, 0x54, 0xd2, 0x80, 0x94, 0xe6, 0x90, 0x93, 0x32, 0x26, 0x2b, 0x4e, 0x8a, + 0xc6, 0x81, 0x9c, 0x95, 0x0, 0x0, 0x9, 0x7, 0x5b, 0x7d, 0x81, 0xfb, 0x7d, 0x99, 0xe8, 0x85, + 0x1, 0x0, 0x14, 0x9c, 0xc6, 0xc6, 0x8e, 0xc2, 0xec, 0x54, 0xbd, 0xe4, 0xaf, 0x65, 0x9b, 0x3, + 0x91, 0xe1, 0x5c, 0x3a, 0x1a, 0x83, 0xdd, 0x1, 0x0, 0xa, 0x44, 0xae, 0xaf, 0xd8, 0xe0, 0x17, + 0xc1, 0xaa, 0xd6, 0xe7, 0x2, 0x0, 0x7, 0xcf, 0xc1, 0xe0, 0x77, 0x27, 0xf8, 0xf6, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x6c, 0xd9, 0xb5, 0xf8, 0xf7, 0x52, 0xda, 0x84, - 0x94, 0x1f, 0xf7, 0x97, 0x82, 0xff, 0x3a, 0x50}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x2f, 0x1a, 0x12, 0x3a, 0x6b, 0x8c, 0x13, 0xb8, 0xed, 0x82, 0xd6, 0x2d, 0xcc, 0x90, + 0x6a, 0xb3, 0xe7, 0xf4, 0xf2, 0x74, 0x70, 0x40, 0x1e, 0x5a, 0x78, 0x5, 0x58}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x42, 0x31, 0x58, 0xc2, 0xac, 0xe0, 0x22, 0xbc, 0x25, 0xdc, 0xe0, 0x19, - 0xd0, 0xea, 0x79, 0x6a, 0xd6, 0x31, 0x49, 0xca, 0xc7, 0x5b, 0x9b}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x54, 0xd2, 0x80, 0x94, 0xe6, 0x90, 0x93, 0x32, + 0x26, 0x2b, 0x4e, 0x8a, 0xc6, 0x81, 0x9c, 0x95}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x35, 0x29, 0x6c, 0x40, 0xf1}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7, 0x5b, 0x7d, 0x81, 0xfb, 0x7d, 0x99, 0xe8, 0x85}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa9, 0x9, 0x7c, 0x29, 0xc3, 0xa9, 0x8}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9c, 0xc6, 0xc6, 0x8e, 0xc2, 0xec, 0x54, 0xbd, 0xe4, 0xaf, + 0x65, 0x9b, 0x3, 0x91, 0xe1, 0x5c, 0x3a, 0x1a, 0x83, 0xdd}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x44, 0xae, 0xaf, 0xd8, 0xe0, 0x17, 0xc1, 0xaa, 0xd6, 0xe7}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x3c, 0x92, 0x26, 0xe2, 0x1e, 0xa9, 0xb6, 0x36, 0x32, 0x9, - 0x3b, 0xd, 0xab, 0x4b, 0xaa, 0xcc, 0x20, 0x78, 0x8c, 0x39, - 0x56, 0xf5, 0x4b, 0x28, 0x1a, 0xe, 0x65, 0x3e, 0x90, 0xfc}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xcf, 0xc1, 0xe0, 0x77, 0x27, 0xf8, 0xf6}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa7, 0x9d, 0x4, 0xda, 0xb, 0xc0, 0x25, 0x8f, 0xd9, 0x9b, 0xca, 0xe0, 0xf6, 0x89}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6e, 0x99, 0xc2, 0xe1, 0xcf, 0xa5, 0xc5, 0xa0, 0xd5, 0x15, 0xb6}; - lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23812, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30334, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27610 [("\237%=A\255\167\&8",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 26291 [("\SI\235&\DLEy\150\n\207\212>H\132",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("@\181\178*D\211",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("5\138\164\236\175\v\154\215\DLE\DC1\250Z\168N\145\228\235C\186\rrf\247\243",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("o\235s\DC1p\179\196\&3\216n\ENQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0xf, 0x6b, 0xda, 0x0, 0x7, 0xed, 0x25, 0x3d, 0x41, 0xff, 0xa7, 0x38, 0x0, 0x0, 0x0, 0x2}; + uint8_t pkt[] = {0x82, 0x43, 0x66, 0xb3, 0x0, 0xc, 0xf, 0xeb, 0x26, 0x10, 0x79, 0x96, 0xa, 0xcf, + 0xd4, 0x3e, 0x48, 0x84, 0x2, 0x0, 0x6, 0x40, 0xb5, 0xb2, 0x2a, 0x44, 0xd3, 0x2, + 0x0, 0x18, 0x35, 0x8a, 0xa4, 0xec, 0xaf, 0xb, 0x9a, 0xd7, 0x10, 0x11, 0xfa, 0x5a, + 0xa8, 0x4e, 0x91, 0xe4, 0xeb, 0x43, 0xba, 0xd, 0x72, 0x66, 0xf7, 0xf3, 0x2, 0x0, + 0xb, 0x6f, 0xeb, 0x73, 0x11, 0x70, 0xb3, 0xc4, 0x33, 0xd8, 0x6e, 0x5, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x25, 0x3d, 0x41, 0xff, 0xa7, 0x38}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xf, 0xeb, 0x26, 0x10, 0x79, 0x96, 0xa, 0xcf, 0xd4, 0x3e, 0x48, 0x84}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x40, 0xb5, 0xb2, 0x2a, 0x44, 0xd3}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2}; + uint8_t topic_filter_s2_bytes[] = {0x35, 0x8a, 0xa4, 0xec, 0xaf, 0xb, 0x9a, 0xd7, 0x10, 0x11, 0xfa, 0x5a, + 0xa8, 0x4e, 0x91, 0xe4, 0xeb, 0x43, 0xba, 0xd, 0x72, 0x66, 0xf7, 0xf3}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6f, 0xeb, 0x73, 0x11, 0x70, 0xb3, 0xc4, 0x33, 0xd8, 0x6e, 0x5}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27610, 2, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26291, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4069 [("k\212\217\191\167Z\148\215\216\238$0\DLE\138\137",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("f\DC3\GSt\DC4]e\t\EOTEx\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\148G\181",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("+\153\166\221\250\195|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\DC2L\210Q\212\131\223\205\220\163\&3\141\245\165T\235c5\168\229",SubOptions {_retainHandling = +// SubscribeRequest 29015 [("\163\tU\254\239\150/*\157\226\191\&1a\DC3\227{",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\DEL\129c\NAKgK\238]W\EM\132uT\138\249i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\158\182*d\178\184#\243a\207]\196\141\233\DEL\165)\DC4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\183\ETB\154u\225\161A@_\SYN\251\185%\179y\180A\ESC\b\143\SO",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS1}),("\213\SUB\207\229\DC3\246\243\142",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x8a, 0x1, 0xf, 0xe5, 0x0, 0xf, 0x6b, 0xd4, 0xd9, 0xbf, 0xa7, 0x5a, 0x94, 0xd7, 0xd8, - 0xee, 0x24, 0x30, 0x10, 0x8a, 0x89, 0x2, 0x0, 0xc, 0x66, 0x13, 0x1d, 0x74, 0x14, 0x5d, 0x65, - 0x9, 0x4, 0x45, 0x78, 0xd0, 0x0, 0x0, 0x3, 0x94, 0x47, 0xb5, 0x1, 0x0, 0x7, 0x2b, 0x99, - 0xa6, 0xdd, 0xfa, 0xc3, 0x7c, 0x2, 0x0, 0x14, 0x12, 0x4c, 0xd2, 0x51, 0xd4, 0x83, 0xdf, 0xcd, - 0xdc, 0xa3, 0x33, 0x8d, 0xf5, 0xa5, 0x54, 0xeb, 0x63, 0x35, 0xa8, 0xe5, 0x0, 0x0, 0x10, 0x7f, - 0x81, 0x63, 0x15, 0x67, 0x4b, 0xee, 0x5d, 0x57, 0x19, 0x84, 0x75, 0x54, 0x8a, 0xf9, 0x69, 0x2, - 0x0, 0x12, 0x9e, 0xb6, 0x2a, 0x64, 0xb2, 0xb8, 0x23, 0xf3, 0x61, 0xcf, 0x5d, 0xc4, 0x8d, 0xe9, - 0x7f, 0xa5, 0x29, 0x14, 0x2, 0x0, 0x15, 0xb7, 0x17, 0x9a, 0x75, 0xe1, 0xa1, 0x41, 0x40, 0x5f, - 0x16, 0xfb, 0xb9, 0x25, 0xb3, 0x79, 0xb4, 0x41, 0x1b, 0x8, 0x8f, 0xe, 0x1}; + uint8_t pkt[] = {0x82, 0x20, 0x71, 0x57, 0x0, 0x10, 0xa3, 0x9, 0x55, 0xfe, 0xef, 0x96, 0x2f, 0x2a, 0x9d, 0xe2, 0xbf, + 0x31, 0x61, 0x13, 0xe3, 0x7b, 0x1, 0x0, 0x8, 0xd5, 0x1a, 0xcf, 0xe5, 0x13, 0xf6, 0xf3, 0x8e, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x6b, 0xd4, 0xd9, 0xbf, 0xa7, 0x5a, 0x94, 0xd7, - 0xd8, 0xee, 0x24, 0x30, 0x10, 0x8a, 0x89}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xa3, 0x9, 0x55, 0xfe, 0xef, 0x96, 0x2f, 0x2a, + 0x9d, 0xe2, 0xbf, 0x31, 0x61, 0x13, 0xe3, 0x7b}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x66, 0x13, 0x1d, 0x74, 0x14, 0x5d, 0x65, 0x9, 0x4, 0x45, 0x78, 0xd0}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd5, 0x1a, 0xcf, 0xe5, 0x13, 0xf6, 0xf3, 0x8e}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x94, 0x47, 0xb5}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2b, 0x99, 0xa6, 0xdd, 0xfa, 0xc3, 0x7c}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x12, 0x4c, 0xd2, 0x51, 0xd4, 0x83, 0xdf, 0xcd, 0xdc, 0xa3, - 0x33, 0x8d, 0xf5, 0xa5, 0x54, 0xeb, 0x63, 0x35, 0xa8, 0xe5}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7f, 0x81, 0x63, 0x15, 0x67, 0x4b, 0xee, 0x5d, - 0x57, 0x19, 0x84, 0x75, 0x54, 0x8a, 0xf9, 0x69}; - lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x9e, 0xb6, 0x2a, 0x64, 0xb2, 0xb8, 0x23, 0xf3, 0x61, - 0xcf, 0x5d, 0xc4, 0x8d, 0xe9, 0x7f, 0xa5, 0x29, 0x14}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb7, 0x17, 0x9a, 0x75, 0xe1, 0xa1, 0x41, 0x40, 0x5f, 0x16, 0xfb, - 0xb9, 0x25, 0xb3, 0x79, 0xb4, 0x41, 0x1b, 0x8, 0x8f, 0xe}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4069, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29015, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4140 [("q\r\152^#\158\&0\215\239\148E\179M",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\178\RS\139\147\GS\136\&8\163^",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("8Y\221d\ETX\244\192\148\163\158\187\243$.X\166\202\211\153\209\237\218\248",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("yb\183l\128\223\ENQ",SubOptions +// SubscribeRequest 24249 [("\133\139\\\225\188\f;\\\232=\247\f\131i3BK7cp\150l\FSc",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\173$rH\250",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("Q\140AB*\199\195j\143@\USo\199\190aA\198\245\248\172E",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\205,\SI\FS\230\197\161j<\221\143",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("b",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("x\229\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1})] [] +// QoS2}),("\169\145\164k\139\246",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\US\DEL\ffL]\EMM4V |1\RS\169\151\NAK\246",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\190\200Cvj\152\154\218\249x\STX\251}`\168\156\182>]`r\175",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\248\&3\182",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0x72, 0x10, 0x2c, 0x0, 0xd, 0x71, 0xd, 0x98, 0x5e, 0x23, 0x9e, 0x30, 0xd7, 0xef, 0x94, 0x45, - 0xb3, 0x4d, 0x2, 0x0, 0x9, 0xb2, 0x1e, 0x8b, 0x93, 0x1d, 0x88, 0x38, 0xa3, 0x5e, 0x1, 0x0, 0x17, - 0x38, 0x59, 0xdd, 0x64, 0x3, 0xf4, 0xc0, 0x94, 0xa3, 0x9e, 0xbb, 0xf3, 0x24, 0x2e, 0x58, 0xa6, 0xca, - 0xd3, 0x99, 0xd1, 0xed, 0xda, 0xf8, 0x0, 0x0, 0x7, 0x79, 0x62, 0xb7, 0x6c, 0x80, 0xdf, 0x5, 0x1, - 0x0, 0x15, 0x51, 0x8c, 0x41, 0x42, 0x2a, 0xc7, 0xc3, 0x6a, 0x8f, 0x40, 0x1f, 0x6f, 0xc7, 0xbe, 0x61, - 0x41, 0xc6, 0xf5, 0xf8, 0xac, 0x45, 0x2, 0x0, 0xb, 0xcd, 0x2c, 0xf, 0x1c, 0xe6, 0xc5, 0xa1, 0x6a, - 0x3c, 0xdd, 0x8f, 0x1, 0x0, 0x1, 0x62, 0x0, 0x0, 0x3, 0x78, 0xe5, 0x32, 0x1}; + uint8_t pkt[] = {0x82, 0x62, 0x5e, 0xb9, 0x0, 0x18, 0x85, 0x8b, 0x5c, 0xe1, 0xbc, 0xc, 0x3b, 0x5c, 0xe8, 0x3d, 0xf7, + 0xc, 0x83, 0x69, 0x33, 0x42, 0x4b, 0x37, 0x63, 0x70, 0x96, 0x6c, 0x1c, 0x63, 0x1, 0x0, 0x5, 0xad, + 0x24, 0x72, 0x48, 0xfa, 0x2, 0x0, 0x6, 0xa9, 0x91, 0xa4, 0x6b, 0x8b, 0xf6, 0x0, 0x0, 0x12, 0x1f, + 0x7f, 0xc, 0x66, 0x4c, 0x5d, 0x19, 0x4d, 0x34, 0x56, 0x20, 0x7c, 0x31, 0x1e, 0xa9, 0x97, 0x15, 0xf6, + 0x2, 0x0, 0x16, 0xbe, 0xc8, 0x43, 0x76, 0x6a, 0x98, 0x9a, 0xda, 0xf9, 0x78, 0x2, 0xfb, 0x7d, 0x60, + 0xa8, 0x9c, 0xb6, 0x3e, 0x5d, 0x60, 0x72, 0xaf, 0x1, 0x0, 0x3, 0xf8, 0x33, 0xb6, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x71, 0xd, 0x98, 0x5e, 0x23, 0x9e, 0x30, 0xd7, 0xef, 0x94, 0x45, 0xb3, 0x4d}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x85, 0x8b, 0x5c, 0xe1, 0xbc, 0xc, 0x3b, 0x5c, 0xe8, 0x3d, 0xf7, 0xc, + 0x83, 0x69, 0x33, 0x42, 0x4b, 0x37, 0x63, 0x70, 0x96, 0x6c, 0x1c, 0x63}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb2, 0x1e, 0x8b, 0x93, 0x1d, 0x88, 0x38, 0xa3, 0x5e}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xad, 0x24, 0x72, 0x48, 0xfa}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x38, 0x59, 0xdd, 0x64, 0x3, 0xf4, 0xc0, 0x94, 0xa3, 0x9e, 0xbb, 0xf3, - 0x24, 0x2e, 0x58, 0xa6, 0xca, 0xd3, 0x99, 0xd1, 0xed, 0xda, 0xf8}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa9, 0x91, 0xa4, 0x6b, 0x8b, 0xf6}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x79, 0x62, 0xb7, 0x6c, 0x80, 0xdf, 0x5}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1f, 0x7f, 0xc, 0x66, 0x4c, 0x5d, 0x19, 0x4d, 0x34, + 0x56, 0x20, 0x7c, 0x31, 0x1e, 0xa9, 0x97, 0x15, 0xf6}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x51, 0x8c, 0x41, 0x42, 0x2a, 0xc7, 0xc3, 0x6a, 0x8f, 0x40, 0x1f, - 0x6f, 0xc7, 0xbe, 0x61, 0x41, 0xc6, 0xf5, 0xf8, 0xac, 0x45}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xbe, 0xc8, 0x43, 0x76, 0x6a, 0x98, 0x9a, 0xda, 0xf9, 0x78, 0x2, + 0xfb, 0x7d, 0x60, 0xa8, 0x9c, 0xb6, 0x3e, 0x5d, 0x60, 0x72, 0xaf}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xcd, 0x2c, 0xf, 0x1c, 0xe6, 0xc5, 0xa1, 0x6a, 0x3c, 0xdd, 0x8f}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf8, 0x33, 0xb6}; + lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x62}; - lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x78, 0xe5, 0x32}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4140, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24249, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32171 [("\235\179\143\169o\140~\246\145>\228z*M/\153\204\US@%",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("/ti-C\SUB\US\190\&4\138",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\GS\205\155",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\161\159\232{t\166\134\176\251\137\135\166\212",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("hO\199\173\182",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("E\SI\143~\248\185\255\166X\245\253\209\171\231\220\133\210\226\SO",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 18033 [("\181\STX\205 B\134&\195T\EOT\226\245Is\192\233\ETBM\ENQ\150\240\161",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0x5d, 0x7d, 0xab, 0x0, 0x14, 0xeb, 0xb3, 0x8f, 0xa9, 0x6f, 0x8c, 0x7e, 0xf6, 0x91, 0x3e, - 0xe4, 0x7a, 0x2a, 0x4d, 0x2f, 0x99, 0xcc, 0x1f, 0x40, 0x25, 0x0, 0x0, 0xa, 0x2f, 0x74, 0x69, - 0x2d, 0x43, 0x1a, 0x1f, 0xbe, 0x34, 0x8a, 0x0, 0x0, 0x3, 0x1d, 0xcd, 0x9b, 0x1, 0x0, 0x0, - 0x1, 0x0, 0xd, 0xa1, 0x9f, 0xe8, 0x7b, 0x74, 0xa6, 0x86, 0xb0, 0xfb, 0x89, 0x87, 0xa6, 0xd4, - 0x0, 0x0, 0x5, 0x68, 0x4f, 0xc7, 0xad, 0xb6, 0x0, 0x0, 0x13, 0x45, 0xf, 0x8f, 0x7e, 0xf8, - 0xb9, 0xff, 0xa6, 0x58, 0xf5, 0xfd, 0xd1, 0xab, 0xe7, 0xdc, 0x85, 0xd2, 0xe2, 0xe, 0x2}; + uint8_t pkt[] = {0x82, 0x1b, 0x46, 0x71, 0x0, 0x16, 0xb5, 0x2, 0xcd, 0x20, 0x42, 0x86, 0x26, 0xc3, 0x54, + 0x4, 0xe2, 0xf5, 0x49, 0x73, 0xc0, 0xe9, 0x17, 0x4d, 0x5, 0x96, 0xf0, 0xa1, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xeb, 0xb3, 0x8f, 0xa9, 0x6f, 0x8c, 0x7e, 0xf6, 0x91, 0x3e, - 0xe4, 0x7a, 0x2a, 0x4d, 0x2f, 0x99, 0xcc, 0x1f, 0x40, 0x25}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xb5, 0x2, 0xcd, 0x20, 0x42, 0x86, 0x26, 0xc3, 0x54, 0x4, 0xe2, + 0xf5, 0x49, 0x73, 0xc0, 0xe9, 0x17, 0x4d, 0x5, 0x96, 0xf0, 0xa1}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2f, 0x74, 0x69, 0x2d, 0x43, 0x1a, 0x1f, 0xbe, 0x34, 0x8a}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1d, 0xcd, 0x9b}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa1, 0x9f, 0xe8, 0x7b, 0x74, 0xa6, 0x86, 0xb0, 0xfb, 0x89, 0x87, 0xa6, 0xd4}; - lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x68, 0x4f, 0xc7, 0xad, 0xb6}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x45, 0xf, 0x8f, 0x7e, 0xf8, 0xb9, 0xff, 0xa6, 0x58, 0xf5, - 0xfd, 0xd1, 0xab, 0xe7, 0xdc, 0x85, 0xd2, 0xe2, 0xe}; - lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32171, 7, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18033, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29078 [("\201\248\\\248\245\254b\200k\161O\234i|\156\CAN\154+$\r\DLEu\179\"_|S}",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("#\234t\173\SOH%\NUL\251\216}\164\226\144\198\195\234\174\FSJ\136\GS\239\130\227\136\NAK",SubOptions +// SubscribeRequest 22392 +// [("G\SO_\r\DLE\244.\250W\133;\154\229\255\200(\128({\RS\DEL\205\&3\233\NAK\158\197\191l",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\233\157F\ACK\128m\130\216\142\NUL\197\184\&8\243\248\SIvz\CAN\229w\US\EM\159\141",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("A\129\149O\210j]Y\247\205{\133\US\158\220U\204Gq\195\159\200kM\141\DLE\155\245\175",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\RST\234",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("h\USN\NUL\199Ix\174\RS\FS#\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS0}),("\146\&0m\DC3J\242\217\STXV\251\177G\241m?\246\228",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\t\190\224d\180\148N\147{\128\156",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x73, 0x71, 0x96, 0x0, 0x1c, 0xc9, 0xf8, 0x5c, 0xf8, 0xf5, 0xfe, 0x62, 0xc8, 0x6b, 0xa1, 0x4f, - 0xea, 0x69, 0x7c, 0x9c, 0x18, 0x9a, 0x2b, 0x24, 0xd, 0x10, 0x75, 0xb3, 0x22, 0x5f, 0x7c, 0x53, 0x7d, - 0x0, 0x0, 0x1a, 0x23, 0xea, 0x74, 0xad, 0x1, 0x25, 0x0, 0xfb, 0xd8, 0x7d, 0xa4, 0xe2, 0x90, 0xc6, - 0xc3, 0xea, 0xae, 0x1c, 0x4a, 0x88, 0x1d, 0xef, 0x82, 0xe3, 0x88, 0x15, 0x1, 0x0, 0x1d, 0x41, 0x81, - 0x95, 0x4f, 0xd2, 0x6a, 0x5d, 0x59, 0xf7, 0xcd, 0x7b, 0x85, 0x1f, 0x9e, 0xdc, 0x55, 0xcc, 0x47, 0x71, - 0xc3, 0x9f, 0xc8, 0x6b, 0x4d, 0x8d, 0x10, 0x9b, 0xf5, 0xaf, 0x0, 0x0, 0x3, 0x1e, 0x54, 0xea, 0x2, - 0x0, 0xc, 0x68, 0x1f, 0x4e, 0x0, 0xc7, 0x49, 0x78, 0xae, 0x1e, 0x1c, 0x23, 0xae, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xc9, 0xf8, 0x5c, 0xf8, 0xf5, 0xfe, 0x62, 0xc8, 0x6b, 0xa1, - 0x4f, 0xea, 0x69, 0x7c, 0x9c, 0x18, 0x9a, 0x2b, 0x24, 0xd, - 0x10, 0x75, 0xb3, 0x22, 0x5f, 0x7c, 0x53, 0x7d}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x60, 0x57, 0x78, 0x0, 0x1d, 0x47, 0xe, 0x5f, 0xd, 0x10, 0xf4, 0x2e, 0xfa, 0x57, 0x85, 0x3b, + 0x9a, 0xe5, 0xff, 0xc8, 0x28, 0x80, 0x28, 0x7b, 0x1e, 0x7f, 0xcd, 0x33, 0xe9, 0x15, 0x9e, 0xc5, 0xbf, + 0x6c, 0x2, 0x0, 0x19, 0xe9, 0x9d, 0x46, 0x6, 0x80, 0x6d, 0x82, 0xd8, 0x8e, 0x0, 0xc5, 0xb8, 0x38, + 0xf3, 0xf8, 0xf, 0x76, 0x7a, 0x18, 0xe5, 0x77, 0x1f, 0x19, 0x9f, 0x8d, 0x0, 0x0, 0x11, 0x92, 0x30, + 0x6d, 0x13, 0x4a, 0xf2, 0xd9, 0x2, 0x56, 0xfb, 0xb1, 0x47, 0xf1, 0x6d, 0x3f, 0xf6, 0xe4, 0x2, 0x0, + 0xb, 0x9, 0xbe, 0xe0, 0x64, 0xb4, 0x94, 0x4e, 0x93, 0x7b, 0x80, 0x9c, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x47, 0xe, 0x5f, 0xd, 0x10, 0xf4, 0x2e, 0xfa, 0x57, 0x85, + 0x3b, 0x9a, 0xe5, 0xff, 0xc8, 0x28, 0x80, 0x28, 0x7b, 0x1e, + 0x7f, 0xcd, 0x33, 0xe9, 0x15, 0x9e, 0xc5, 0xbf, 0x6c}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x23, 0xea, 0x74, 0xad, 0x1, 0x25, 0x0, 0xfb, 0xd8, 0x7d, 0xa4, 0xe2, 0x90, - 0xc6, 0xc3, 0xea, 0xae, 0x1c, 0x4a, 0x88, 0x1d, 0xef, 0x82, 0xe3, 0x88, 0x15}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe9, 0x9d, 0x46, 0x6, 0x80, 0x6d, 0x82, 0xd8, 0x8e, 0x0, 0xc5, 0xb8, 0x38, + 0xf3, 0xf8, 0xf, 0x76, 0x7a, 0x18, 0xe5, 0x77, 0x1f, 0x19, 0x9f, 0x8d}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x41, 0x81, 0x95, 0x4f, 0xd2, 0x6a, 0x5d, 0x59, 0xf7, 0xcd, - 0x7b, 0x85, 0x1f, 0x9e, 0xdc, 0x55, 0xcc, 0x47, 0x71, 0xc3, - 0x9f, 0xc8, 0x6b, 0x4d, 0x8d, 0x10, 0x9b, 0xf5, 0xaf}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x92, 0x30, 0x6d, 0x13, 0x4a, 0xf2, 0xd9, 0x2, 0x56, + 0xfb, 0xb1, 0x47, 0xf1, 0x6d, 0x3f, 0xf6, 0xe4}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1e, 0x54, 0xea}; - lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9, 0xbe, 0xe0, 0x64, 0xb4, 0x94, 0x4e, 0x93, 0x7b, 0x80, 0x9c}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x68, 0x1f, 0x4e, 0x0, 0xc7, 0x49, 0x78, 0xae, 0x1e, 0x1c, 0x23, 0xae}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0}; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29078, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22392, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 756 [("F\229~\a\235\170;\164\DC1\152",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\208fV\240",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("X\FS\146$\204\DLE\249b\249R\142P\254No\129",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\212\SUB\138(T\SYN-\252",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ETX\"\SUB\EM\ETB\133\248d\162\156\244\246",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("R\179\184\&9\148\238\184\166\149\"\208s&A\130\132s(\240\133\165\CAN\EMN",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\252\128\176 -// \139\212\226\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\154\137px\248W\245mK\174\255)oi\SOH\235\145\SO\t\EOT\190\144`%N\219\225\189\179",SubOptions +// SubscribeRequest 26543 [("\249\201\SUB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\219\159\230|\181\144-\SUB\144",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\220\152\146\130\197\251\SOH\226+",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("}\193\237\&6\129\180b\DEL\136\247\147W\ETX\229!\156\ACK\226fs\144+\DEL#'\202",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\203\203\184\175b\208n\245r\221R; -// \147\ACK%e9\161\NAKG:-fE\172\128",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2})] [] +// QoS1}),("\143\200\174\222\226\&4\142+",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\145\228A\244\158\b\173fY&\220q\DC4\161\\\174\199\&7\172#",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\138\DC1\164\194\ETB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("C\139\178\210\217U(S\133\a",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("MU:H5\202\246\247!\NUL\169",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0xc7, 0x1, 0x2, 0xf4, 0x0, 0xa, 0x46, 0xe5, 0x7e, 0x7, 0xeb, 0xaa, 0x3b, 0xa4, 0x11, 0x98, - 0x2, 0x0, 0x4, 0xd0, 0x66, 0x56, 0xf0, 0x0, 0x0, 0x10, 0x58, 0x1c, 0x92, 0x24, 0xcc, 0x10, 0xf9, - 0x62, 0xf9, 0x52, 0x8e, 0x50, 0xfe, 0x4e, 0x6f, 0x81, 0x1, 0x0, 0x8, 0xd4, 0x1a, 0x8a, 0x28, 0x54, - 0x16, 0x2d, 0xfc, 0x2, 0x0, 0xc, 0x3, 0x22, 0x1a, 0x19, 0x17, 0x85, 0xf8, 0x64, 0xa2, 0x9c, 0xf4, - 0xf6, 0x2, 0x0, 0x18, 0x52, 0xb3, 0xb8, 0x39, 0x94, 0xee, 0xb8, 0xa6, 0x95, 0x22, 0xd0, 0x73, 0x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37, 0xac, 0x23, 0x2, 0x0, 0x5, 0x8a, 0x11, 0xa4, 0xc2, 0x17, 0x2, 0x0, + 0xa, 0x43, 0x8b, 0xb2, 0xd2, 0xd9, 0x55, 0x28, 0x53, 0x85, 0x7, 0x1, 0x0, 0xb, 0x4d, 0x55, + 0x3a, 0x48, 0x35, 0xca, 0xf6, 0xf7, 0x21, 0x0, 0xa9, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x46, 0xe5, 0x7e, 0x7, 0xeb, 0xaa, 0x3b, 0xa4, 0x11, 0x98}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xf9, 0xc9, 0x1a}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd0, 0x66, 0x56, 0xf0}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xdb, 0x9f, 0xe6, 0x7c, 0xb5, 0x90, 0x2d, 0x1a, 0x90}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x58, 0x1c, 0x92, 0x24, 0xcc, 0x10, 0xf9, 0x62, - 0xf9, 0x52, 0x8e, 0x50, 0xfe, 0x4e, 0x6f, 0x81}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xdc, 0x98, 0x92, 0x82, 0xc5, 0xfb, 0x1, 0xe2, 0x2b}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd4, 0x1a, 0x8a, 0x28, 0x54, 0x16, 0x2d, 0xfc}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x3, 0x22, 0x1a, 0x19, 0x17, 0x85, 0xf8, 0x64, 0xa2, 0x9c, 0xf4, 0xf6}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x8f, 0xc8, 0xae, 0xde, 0xe2, 0x34, 0x8e, 0x2b}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x52, 0xb3, 0xb8, 0x39, 0x94, 0xee, 0xb8, 0xa6, 0x95, 0x22, 0xd0, 0x73, - 0x26, 0x41, 0x82, 0x84, 0x73, 0x28, 0xf0, 0x85, 0xa5, 0x18, 0x19, 0x4e}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x91, 0xe4, 0x41, 0xf4, 0x9e, 0x8, 0xad, 0x66, 0x59, 0x26, + 0xdc, 0x71, 0x14, 0xa1, 0x5c, 0xae, 0xc7, 0x37, 0xac, 0x23}; + lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xfc, 0x80, 0xb0, 0x20, 0x8b, 0xd4, 0xe2, 0xd0}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x8a, 0x11, 0xa4, 0xc2, 0x17}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0}; - lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x43, 0x8b, 0xb2, 0xd2, 0xd9, 0x55, 0x28, 0x53, 0x85, 0x7}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x9a, 0x89, 0x70, 0x78, 0xf8, 0x57, 0xf5, 0x6d, 0x4b, 0xae, - 0xff, 0x29, 0x6f, 0x69, 0x1, 0xeb, 0x91, 0xe, 0x9, 0x4, - 0xbe, 0x90, 0x60, 0x25, 0x4e, 0xdb, 0xe1, 0xbd, 0xb3}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x4d, 0x55, 0x3a, 0x48, 0x35, 0xca, 0xf6, 0xf7, 0x21, 0x0, 0xa9}; + lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x7d, 0xc1, 0xed, 0x36, 0x81, 0xb4, 0x62, 0x7f, 0x88, 0xf7, 0x93, 0x57, 0x3, - 0xe5, 0x21, 0x9c, 0x6, 0xe2, 0x66, 0x73, 0x90, 0x2b, 0x7f, 0x23, 0x27, 0xca}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xcb, 0xcb, 0xb8, 0xaf, 0x62, 0xd0, 0x6e, 0xf5, 0x72, - 0xdd, 0x52, 0x3b, 0x20, 0x93, 0x6, 0x25, 0x65, 0x39, - 0xa1, 0x15, 0x47, 0x3a, 0x2d, 0x66, 0x45, 0xac, 0x80}; - lwmqtt_string_t topic_filter_s10 = {27, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 756, 11, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26543, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 16233 [("EBW",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("T\254+V h\152\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("3!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\DC3n;\202\230\SUB\132\139\138\185;\174&\231+wf\251U\f\EMGS\207\&0v\246",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\v\207\&8\151z2J\146\DC2;\214\252\DC3\139\b\232\242\&5\190\231\229~^\172\238\SI:e\SUB",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("4\212\138\243\171\200\217@\238\210[E\146\241\SO\183\128",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 14708 [("\NULK\203\169*aQ\217\USt\161",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("1\DLE\243[3\NUL\FS\CAN\220\179\247u\159Kf\236\149\FS\231\156*w\170",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0x6e, 0x3f, 0x69, 0x0, 0x3, 0x45, 0x42, 0x57, 0x1, 0x0, 0x1, 0x6e, 0x0, 0x0, 0x8, - 0x54, 0xfe, 0x2b, 0x56, 0x20, 0x68, 0x98, 0xaa, 0x1, 0x0, 0x2, 0x33, 0x21, 0x0, 0x0, 0x1b, - 0x13, 0x6e, 0x3b, 0xca, 0xe6, 0x1a, 0x84, 0x8b, 0x8a, 0xb9, 0x3b, 0xae, 0x26, 0xe7, 0x2b, 0x77, - 0x66, 0xfb, 0x55, 0xc, 0x19, 0x47, 0x53, 0xcf, 0x30, 0x76, 0xf6, 0x0, 0x0, 0x1d, 0xb, 0xcf, - 0x38, 0x97, 0x7a, 0x32, 0x4a, 0x92, 0x12, 0x3b, 0xd6, 0xfc, 0x13, 0x8b, 0x8, 0xe8, 0xf2, 0x35, - 0xbe, 0xe7, 0xe5, 0x7e, 0x5e, 0xac, 0xee, 0xf, 0x3a, 0x65, 0x1a, 0x2, 0x0, 0x11, 0x34, 0xd4, - 0x8a, 0xf3, 0xab, 0xc8, 0xd9, 0x40, 0xee, 0xd2, 0x5b, 0x45, 0x92, 0xf1, 0xe, 0xb7, 0x80, 0x2}; + uint8_t pkt[] = {0x82, 0x2a, 0x39, 0x74, 0x0, 0xb, 0x0, 0x4b, 0xcb, 0xa9, 0x2a, 0x61, 0x51, 0xd9, 0x1f, + 0x74, 0xa1, 0x1, 0x0, 0x17, 0x31, 0x10, 0xf3, 0x5b, 0x33, 0x0, 0x1c, 0x18, 0xdc, 0xb3, + 0xf7, 0x75, 0x9f, 0x4b, 0x66, 0xec, 0x95, 0x1c, 0xe7, 0x9c, 0x2a, 0x77, 0xaa, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x45, 0x42, 0x57}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x0, 0x4b, 0xcb, 0xa9, 0x2a, 0x61, 0x51, 0xd9, 0x1f, 0x74, 0xa1}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6e}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x31, 0x10, 0xf3, 0x5b, 0x33, 0x0, 0x1c, 0x18, 0xdc, 0xb3, 0xf7, 0x75, + 0x9f, 0x4b, 0x66, 0xec, 0x95, 0x1c, 0xe7, 0x9c, 0x2a, 0x77, 0xaa}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x54, 0xfe, 0x2b, 0x56, 0x20, 0x68, 0x98, 0xaa}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x33, 0x21}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x13, 0x6e, 0x3b, 0xca, 0xe6, 0x1a, 0x84, 0x8b, 0x8a, 0xb9, 0x3b, 0xae, 0x26, 0xe7, - 0x2b, 0x77, 0x66, 0xfb, 0x55, 0xc, 0x19, 0x47, 0x53, 0xcf, 0x30, 0x76, 0xf6}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb, 0xcf, 0x38, 0x97, 0x7a, 0x32, 0x4a, 0x92, 0x12, 0x3b, - 0xd6, 0xfc, 0x13, 0x8b, 0x8, 0xe8, 0xf2, 0x35, 0xbe, 0xe7, - 0xe5, 0x7e, 0x5e, 0xac, 0xee, 0xf, 0x3a, 0x65, 0x1a}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x34, 0xd4, 0x8a, 0xf3, 0xab, 0xc8, 0xd9, 0x40, 0xee, - 0xd2, 0x5b, 0x45, 0x92, 0xf1, 0xe, 0xb7, 0x80}; - lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16233, 7, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14708, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27988 [("\215:8'\163*\137K\190_\182*\204\144\ETX\186\242\234\173\138,f\158\190",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("P7\f\231T5\214\vP\216h\NUL\DC3\b\224\SI",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\132~\184",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 24735 [("I\184\193",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("C\231x)\"5\EOT\146\158\NAK\181,",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\235\ESC\184\223^M\136\133\196\&6\247\CAN/M\231\201c\165j\230",SubOptions {_retainHandling = +// QoS2}),("\251\n(!k\205\193u\208<\205g.\223Q\US\187[\232\\\206\DLE\148\202",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(")",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("1\153n\DC1\168\129\189\149\&7+F>\DC4d\249\172\130\DC4\ACK_\177*\237C\228\f\DC4\a<]",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\238E\134\179f\SOH\209\229\239w\165\242\181\DC4\182\139\180\ETX\178!1",SubOptions {_retainHandling = +// QoS0}),("_\204\209\225{\194\165\&4\222'\DLE\217\157Vu6G7\181\189\DC3)q",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("k\222\133\254$\SYN\235\a\154\140U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\254",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0})] [] +// QoS2}),("_6\149\215\&3\ENQ\133\244<\b!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0x98, 0x1, 0x6d, 0x54, 0x0, 0x18, 0xd7, 0x3a, 0x38, 0x27, 0xa3, 0x2a, 0x89, 0x4b, 0xbe, - 0x5f, 0xb6, 0x2a, 0xcc, 0x90, 0x3, 0xba, 0xf2, 0xea, 0xad, 0x8a, 0x2c, 0x66, 0x9e, 0xbe, 0x0, - 0x0, 0x10, 0x50, 0x37, 0xc, 0xe7, 0x54, 0x35, 0xd6, 0xb, 0x50, 0xd8, 0x68, 0x0, 0x13, 0x8, - 0xe0, 0xf, 0x0, 0x0, 0x3, 0x84, 0x7e, 0xb8, 0x0, 0x0, 0x14, 0xeb, 0x1b, 0xb8, 0xdf, 0x5e, - 0x4d, 0x88, 0x85, 0xc4, 0x36, 0xf7, 0x18, 0x2f, 0x4d, 0xe7, 0xc9, 0x63, 0xa5, 0x6a, 0xe6, 0x1, - 0x0, 0x1e, 0x31, 0x99, 0x6e, 0x11, 0xa8, 0x81, 0xbd, 0x95, 0x37, 0x2b, 0x46, 0x3e, 0x14, 0x64, - 0xf9, 0xac, 0x82, 0x14, 0x6, 0x5f, 0xb1, 0x2a, 0xed, 0x43, 0xe4, 0xc, 0x14, 0x7, 0x3c, 0x5d, - 0x1, 0x0, 0x15, 0xee, 0x45, 0x86, 0xb3, 0x66, 0x1, 0xd1, 0xe5, 0xef, 0x77, 0xa5, 0xf2, 0xb5, - 0x14, 0xb6, 0x8b, 0xb4, 0x3, 0xb2, 0x21, 0x31, 0x1, 0x0, 0xb, 0x6b, 0xde, 0x85, 0xfe, 0x24, - 0x16, 0xeb, 0x7, 0x9a, 0x8c, 0x55, 0x1, 0x0, 0x1, 0xfe, 0x0}; + uint8_t pkt[] = {0x82, 0x5e, 0x60, 0x9f, 0x0, 0x3, 0x49, 0xb8, 0xc1, 0x2, 0x0, 0xc, 0x43, 0xe7, 0x78, 0x29, + 0x22, 0x35, 0x4, 0x92, 0x9e, 0x15, 0xb5, 0x2c, 0x2, 0x0, 0x18, 0xfb, 0xa, 0x28, 0x21, 0x6b, + 0xcd, 0xc1, 0x75, 0xd0, 0x3c, 0xcd, 0x67, 0x2e, 0xdf, 0x51, 0x1f, 0xbb, 0x5b, 0xe8, 0x5c, 0xce, + 0x10, 0x94, 0xca, 0x1, 0x0, 0x1, 0x29, 0x0, 0x0, 0x17, 0x5f, 0xcc, 0xd1, 0xe1, 0x7b, 0xc2, + 0xa5, 0x34, 0xde, 0x27, 0x10, 0xd9, 0x9d, 0x56, 0x75, 0x36, 0x47, 0x37, 0xb5, 0xbd, 0x13, 0x29, + 0x71, 0x2, 0x0, 0xb, 0x5f, 0x36, 0x95, 0xd7, 0x33, 0x5, 0x85, 0xf4, 0x3c, 0x8, 0x21, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xd7, 0x3a, 0x38, 0x27, 0xa3, 0x2a, 0x89, 0x4b, 0xbe, 0x5f, 0xb6, 0x2a, - 0xcc, 0x90, 0x3, 0xba, 0xf2, 0xea, 0xad, 0x8a, 0x2c, 0x66, 0x9e, 0xbe}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x49, 0xb8, 0xc1}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x50, 0x37, 0xc, 0xe7, 0x54, 0x35, 0xd6, 0xb, - 0x50, 0xd8, 0x68, 0x0, 0x13, 0x8, 0xe0, 0xf}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x43, 0xe7, 0x78, 0x29, 0x22, 0x35, 0x4, 0x92, 0x9e, 0x15, 0xb5, 0x2c}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x84, 0x7e, 0xb8}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xfb, 0xa, 0x28, 0x21, 0x6b, 0xcd, 0xc1, 0x75, 0xd0, 0x3c, 0xcd, 0x67, + 0x2e, 0xdf, 0x51, 0x1f, 0xbb, 0x5b, 0xe8, 0x5c, 0xce, 0x10, 0x94, 0xca}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xeb, 0x1b, 0xb8, 0xdf, 0x5e, 0x4d, 0x88, 0x85, 0xc4, 0x36, - 0xf7, 0x18, 0x2f, 0x4d, 0xe7, 0xc9, 0x63, 0xa5, 0x6a, 0xe6}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x29}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x31, 0x99, 0x6e, 0x11, 0xa8, 0x81, 0xbd, 0x95, 0x37, 0x2b, - 0x46, 0x3e, 0x14, 0x64, 0xf9, 0xac, 0x82, 0x14, 0x6, 0x5f, - 0xb1, 0x2a, 0xed, 0x43, 0xe4, 0xc, 0x14, 0x7, 0x3c, 0x5d}; - lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x5f, 0xcc, 0xd1, 0xe1, 0x7b, 0xc2, 0xa5, 0x34, 0xde, 0x27, 0x10, 0xd9, + 0x9d, 0x56, 0x75, 0x36, 0x47, 0x37, 0xb5, 0xbd, 0x13, 0x29, 0x71}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xee, 0x45, 0x86, 0xb3, 0x66, 0x1, 0xd1, 0xe5, 0xef, 0x77, 0xa5, - 0xf2, 0xb5, 0x14, 0xb6, 0x8b, 0xb4, 0x3, 0xb2, 0x21, 0x31}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x5f, 0x36, 0x95, 0xd7, 0x33, 0x5, 0x85, 0xf4, 0x3c, 0x8, 0x21}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6b, 0xde, 0x85, 0xfe, 0x24, 0x16, 0xeb, 0x7, 0x9a, 0x8c, 0x55}; - lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xfe}; - lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27988, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24735, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19880 [("\163\224\DC4H\243\234r\170\191\212<\172Q\159\207\205\131=\189\132W",SubOptions +// SubscribeRequest 31752 [("_\219L\240F\160\245'\201\213\145D\221\235\219\250\233\&8\211\&6\154\154\235",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\DLE\190\ETXgAE\133z \251",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("4 ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\229\210&\235\147\255",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\GS{\223`IldKX@9",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\198W8*B\175+,@\234j\200\209\167\187",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("\203#\222\STX\217\221[6\138\196[\189\236\190\187Q\225\143+]\183U\141lq\242\SI\253",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS1}),("\205g~\180H*@/\252|\213\208\227\DC1\184-\238\128\169\237E",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\186\144",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("p\172",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("E\ETB\215\130\164\130",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\v\203N\139\228\165wx\175\155\n\231\195\176",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode12) { - uint8_t pkt[] = {0x82, 0x74, 0x4d, 0xa8, 0x0, 0x15, 0xa3, 0xe0, 0x14, 0x48, 0xf3, 0xea, 0x72, 0xaa, 0xbf, 0xd4, 0x3c, - 0xac, 0x51, 0x9f, 0xcf, 0xcd, 0x83, 0x3d, 0xbd, 0x84, 0x57, 0x0, 0x0, 0xa, 0x10, 0xbe, 0x3, 0x67, - 0x41, 0x45, 0x85, 0x7a, 0x20, 0xfb, 0x0, 0x0, 0x2, 0x34, 0x20, 0x2, 0x0, 0x6, 0xe5, 0xd2, 0x26, - 0xeb, 0x93, 0xff, 0x0, 0x0, 0xb, 0x1d, 0x7b, 0xdf, 0x60, 0x49, 0x6c, 0x64, 0x4b, 0x58, 0x40, 0x39, - 0x0, 0x0, 0xf, 0xc6, 0x57, 0x38, 0x2a, 0x42, 0xaf, 0x2b, 0x2c, 0x40, 0xea, 0x6a, 0xc8, 0xd1, 0xa7, - 0xbb, 0x2, 0x0, 0x1c, 0xcb, 0x23, 0xde, 0x2, 0xd9, 0xdd, 0x5b, 0x36, 0x8a, 0xc4, 0x5b, 0xbd, 0xec, - 0xbe, 0xbb, 0x51, 0xe1, 0x8f, 0x2b, 0x5d, 0xb7, 0x55, 0x8d, 0x6c, 0x71, 0xf2, 0xf, 0xfd, 0x1}; + uint8_t pkt[] = {0x82, 0x58, 0x7c, 0x8, 0x0, 0x17, 0x5f, 0xdb, 0x4c, 0xf0, 0x46, 0xa0, 0xf5, 0x27, 0xc9, + 0xd5, 0x91, 0x44, 0xdd, 0xeb, 0xdb, 0xfa, 0xe9, 0x38, 0xd3, 0x36, 0x9a, 0x9a, 0xeb, 0x1, + 0x0, 0x15, 0xcd, 0x67, 0x7e, 0xb4, 0x48, 0x2a, 0x40, 0x2f, 0xfc, 0x7c, 0xd5, 0xd0, 0xe3, + 0x11, 0xb8, 0x2d, 0xee, 0x80, 0xa9, 0xed, 0x45, 0x1, 0x0, 0x2, 0xba, 0x90, 0x0, 0x0, + 0x2, 0x70, 0xac, 0x1, 0x0, 0x6, 0x45, 0x17, 0xd7, 0x82, 0xa4, 0x82, 0x0, 0x0, 0xe, + 0xb, 0xcb, 0x4e, 0x8b, 0xe4, 0xa5, 0x77, 0x78, 0xaf, 0x9b, 0xa, 0xe7, 0xc3, 0xb0, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xa3, 0xe0, 0x14, 0x48, 0xf3, 0xea, 0x72, 0xaa, 0xbf, 0xd4, 0x3c, - 0xac, 0x51, 0x9f, 0xcf, 0xcd, 0x83, 0x3d, 0xbd, 0x84, 0x57}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x5f, 0xdb, 0x4c, 0xf0, 0x46, 0xa0, 0xf5, 0x27, 0xc9, 0xd5, 0x91, 0x44, + 0xdd, 0xeb, 0xdb, 0xfa, 0xe9, 0x38, 0xd3, 0x36, 0x9a, 0x9a, 0xeb}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x10, 0xbe, 0x3, 0x67, 0x41, 0x45, 0x85, 0x7a, 0x20, 0xfb}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xcd, 0x67, 0x7e, 0xb4, 0x48, 0x2a, 0x40, 0x2f, 0xfc, 0x7c, 0xd5, + 0xd0, 0xe3, 0x11, 0xb8, 0x2d, 0xee, 0x80, 0xa9, 0xed, 0x45}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x34, 0x20}; + uint8_t topic_filter_s2_bytes[] = {0xba, 0x90}; lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe5, 0xd2, 0x26, 0xeb, 0x93, 0xff}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x70, 0xac}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x1d, 0x7b, 0xdf, 0x60, 0x49, 0x6c, 0x64, 0x4b, 0x58, 0x40, 0x39}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x45, 0x17, 0xd7, 0x82, 0xa4, 0x82}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc6, 0x57, 0x38, 0x2a, 0x42, 0xaf, 0x2b, 0x2c, - 0x40, 0xea, 0x6a, 0xc8, 0xd1, 0xa7, 0xbb}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xb, 0xcb, 0x4e, 0x8b, 0xe4, 0xa5, 0x77, 0x78, 0xaf, 0x9b, 0xa, 0xe7, 0xc3, 0xb0}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xcb, 0x23, 0xde, 0x2, 0xd9, 0xdd, 0x5b, 0x36, 0x8a, 0xc4, - 0x5b, 0xbd, 0xec, 0xbe, 0xbb, 0x51, 0xe1, 0x8f, 0x2b, 0x5d, - 0xb7, 0x55, 0x8d, 0x6c, 0x71, 0xf2, 0xf, 0xfd}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19880, 7, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31752, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22493 [("\227\138\DC4\248mr\146&d\209\219",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 12709 [("\132\197\232\176\128>\167\NAKa",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\178\242Do\205\129\176\135\169\245\194\STXX|\196\207\227\196\169\\\DLE\175\138\200\v\186\135yL\172",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("@f\171\247\189\153\191\162\&66\248\191:\167\234nw\220R\195\&3\SOH72\235\a\EOTx",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\241\135Z\182\210O\202\248\&6\NAK\215\DC2\217\EOT\171\128\173.\183\138qM]l\198_",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("{\ESCA\ETX\233J}\147\DC3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\242L\245\r\189\187\206",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("{4\GS\t\194H\206\FS\176",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\203\247\\`[\193",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\153\164\176\228\218\162\198\231\SI\135_\\P\249\176\169\200S",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("8\193\250\178\180`\161\204\240\245\129/\NAK\137\242\233f\NUL\179\171\US\157\197tX'",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\193\229\147&\176\150P\DC1}\195\SI\203!V\185\SO-YK\193\131K\195\149\211",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0x10, 0x57, 0xdd, 0x0, 0xb, 0xe3, 0x8a, 0x14, - 0xf8, 0x6d, 0x72, 0x92, 0x26, 0x64, 0xd1, 0xdb, 0x1}; + uint8_t pkt[] = {0x82, 0xe4, 0x1, 0x31, 0xa5, 0x0, 0x9, 0x84, 0xc5, 0xe8, 0xb0, 0x80, 0x3e, 0xa7, 0x15, 0x61, 0x1, + 0x0, 0x1e, 0xb2, 0xf2, 0x44, 0x6f, 0xcd, 0x81, 0xb0, 0x87, 0xa9, 0xf5, 0xc2, 0x2, 0x58, 0x7c, 0xc4, + 0xcf, 0xe3, 0xc4, 0xa9, 0x5c, 0x10, 0xaf, 0x8a, 0xc8, 0xb, 0xba, 0x87, 0x79, 0x4c, 0xac, 0x0, 0x0, + 0x1c, 0x40, 0x66, 0x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ters[1]; - uint8_t topic_filter_s0_bytes[] = {0xe3, 0x8a, 0x14, 0xf8, 0x6d, 0x72, 0x92, 0x26, 0x64, 0xd1, 0xdb}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x84, 0xc5, 0xe8, 0xb0, 0x80, 0x3e, 0xa7, 0x15, 0x61}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; + uint8_t topic_filter_s1_bytes[] = {0xb2, 0xf2, 0x44, 0x6f, 0xcd, 0x81, 0xb0, 0x87, 0xa9, 0xf5, + 0xc2, 0x2, 0x58, 0x7c, 0xc4, 0xcf, 0xe3, 0xc4, 0xa9, 0x5c, + 0x10, 0xaf, 0x8a, 0xc8, 0xb, 0xba, 0x87, 0x79, 0x4c, 0xac}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x40, 0x66, 0xab, 0xf7, 0xbd, 0x99, 0xbf, 0xa2, 0x36, 0x36, + 0xf8, 0xbf, 0x3a, 0xa7, 0xea, 0x6e, 0x77, 0xdc, 0x52, 0xc3, + 0x33, 0x1, 0x37, 0x32, 0xeb, 0x7, 0x4, 0x78}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf1, 0x87, 0x5a, 0xb6, 0xd2, 0x4f, 0xca, 0xf8, 0x36, 0x15, 0xd7, 0x12, 0xd9, + 0x4, 0xab, 0x80, 0xad, 0x2e, 0xb7, 0x8a, 0x71, 0x4d, 0x5d, 0x6c, 0xc6, 0x5f}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x7b, 0x1b, 0x41, 0x3, 0xe9, 0x4a, 0x7d, 0x93, 0x13}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf2, 0x4c, 0xf5, 0xd, 0xbd, 0xbb, 0xce}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x7b, 0x34, 0x1d, 0x9, 0xc2, 0x48, 0xce, 0x1c, 0xb0}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xcb, 0xf7, 0x5c, 0x60, 0x5b, 0xc1}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x99, 0xa4, 0xb0, 0xe4, 0xda, 0xa2, 0xc6, 0xe7, 0xf, + 0x87, 0x5f, 0x5c, 0x50, 0xf9, 0xb0, 0xa9, 0xc8, 0x53}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x38, 0xc1, 0xfa, 0xb2, 0xb4, 0x60, 0xa1, 0xcc, 0xf0, 0xf5, 0x81, 0x2f, 0x15, + 0x89, 0xf2, 0xe9, 0x66, 0x0, 0xb3, 0xab, 0x1f, 0x9d, 0xc5, 0x74, 0x58, 0x27}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xc1, 0xe5, 0x93, 0x26, 0xb0, 0x96, 0x50, 0x11, 0x7d, 0xc3, 0xf, 0xcb, 0x21, + 0x56, 0xb9, 0xe, 0x2d, 0x59, 0x4b, 0xc1, 0x83, 0x4b, 0xc3, 0x95, 0xd3}; + lwmqtt_string_t topic_filter_s10 = {25, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22493, 1, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12709, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32664 [("\244\185\249\145\SUB\GS\167&\200\201\187E=\184\234\232",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("i\217U\176\198\245\226",SubOptions +// SubscribeRequest 14473 [("\173\230\ESC\133\246\196\156\135\200q|\DC2\188\236\FS\153\183\SO\142b",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("[gE\131-\185\148\217\a\169\&5(\185\236?\187\171\208\130\242\SIdq\SO\USND",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(" -// Y\246\139\\xj\202)\182v\166\bFEb\245H\130",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\160\&3\132\234x\252\200\NUL]\134",SubOptions {_retainHandling = +// QoS0}),("\CAN\192\&41\164\131Z8\251)\173>\128\193\211\222\167G\162\167\149}\129\174",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\211\139\255*\EOT\232\243\147D\252\SI\215\&5F\SIF[\209\SUBw\195I\130",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS2}),("g\226\&6wT\129\254\179\NUL\228\163\218\238\131\130\198\131\172\r\"\223\195\172\130",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("u\138\167\DEL\SI\167\172\136\244\217\249\185\239B\228y",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\193\254#\159\210\150\130\"\250",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\236\179\227\206P\141i\DC3\EM\237\243\232\"cG\151\199\190I",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0x7a, 0x7f, 0x98, 0x0, 0x10, 0xf4, 0xb9, 0xf9, 0x91, 0x1a, 0x1d, 0xa7, 0x26, 0xc8, 0xc9, - 0xbb, 0x45, 0x3d, 0xb8, 0xea, 0xe8, 0x0, 0x0, 0x7, 0x69, 0xd9, 0x55, 0xb0, 0xc6, 0xf5, 0xe2, - 0x0, 0x0, 0x1b, 0x5b, 0x67, 0x45, 0x83, 0x2d, 0xb9, 0x94, 0xd9, 0x7, 0xa9, 0x35, 0x28, 0xb9, - 0xec, 0x3f, 0xbb, 0xab, 0xd0, 0x82, 0xf2, 0xf, 0x64, 0x71, 0xe, 0x1f, 0x4e, 0x44, 0x1, 0x0, - 0x13, 0x20, 0x59, 0xf6, 0x8b, 0x5c, 0x78, 0x6a, 0xca, 0x29, 0xb6, 0x76, 0xa6, 0x8, 0x46, 0x45, - 0x62, 0xf5, 0x48, 0x82, 0x2, 0x0, 0xa, 0xa0, 0x33, 0x84, 0xea, 0x78, 0xfc, 0xc8, 0x0, 0x5d, - 0x86, 0x0, 0x0, 0x17, 0xd3, 0x8b, 0xff, 0x2a, 0x4, 0xe8, 0xf3, 0x93, 0x44, 0xfc, 0xf, 0xd7, - 0x35, 0x46, 0xf, 0x46, 0x5b, 0xd1, 0x1a, 0x77, 0xc3, 0x49, 0x82, 0x1}; + uint8_t pkt[] = {0x82, 0x84, 0x1, 0x38, 0x89, 0x0, 0x14, 0xad, 0xe6, 0x1b, 0x85, 0xf6, 0xc4, 0x9c, 0x87, 0xc8, 0x71, + 0x7c, 0x12, 0xbc, 0xec, 0x1c, 0x99, 0xb7, 0xe, 0x8e, 0x62, 0x0, 0x0, 0x18, 0x18, 0xc0, 0x34, 0x31, + 0xa4, 0x83, 0x5a, 0x38, 0xfb, 0x29, 0xad, 0x3e, 0x80, 0xc1, 0xd3, 0xde, 0xa7, 0x47, 0xa2, 0xa7, 0x95, + 0x7d, 0x81, 0xae, 0x2, 0x0, 0x18, 0x67, 0xe2, 0x36, 0x77, 0x54, 0x81, 0xfe, 0xb3, 0x0, 0xe4, 0xa3, + 0xda, 0xee, 0x83, 0x82, 0xc6, 0x83, 0xac, 0xd, 0x22, 0xdf, 0xc3, 0xac, 0x82, 0x1, 0x0, 0x10, 0x75, + 0x8a, 0xa7, 0x7f, 0xf, 0xa7, 0xac, 0x88, 0xf4, 0xd9, 0xf9, 0xb9, 0xef, 0x42, 0xe4, 0x79, 0x0, 0x0, + 0x9, 0xc1, 0xfe, 0x23, 0x9f, 0xd2, 0x96, 0x82, 0x22, 0xfa, 0x0, 0x0, 0x13, 0xec, 0xb3, 0xe3, 0xce, + 0x50, 0x8d, 0x69, 0x13, 0x19, 0xed, 0xf3, 0xe8, 0x22, 0x63, 0x47, 0x97, 0xc7, 0xbe, 0x49, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xf4, 0xb9, 0xf9, 0x91, 0x1a, 0x1d, 0xa7, 0x26, - 0xc8, 0xc9, 0xbb, 0x45, 0x3d, 0xb8, 0xea, 0xe8}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xad, 0xe6, 0x1b, 0x85, 0xf6, 0xc4, 0x9c, 0x87, 0xc8, 0x71, + 0x7c, 0x12, 0xbc, 0xec, 0x1c, 0x99, 0xb7, 0xe, 0x8e, 0x62}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x69, 0xd9, 0x55, 0xb0, 0xc6, 0xf5, 0xe2}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x18, 0xc0, 0x34, 0x31, 0xa4, 0x83, 0x5a, 0x38, 0xfb, 0x29, 0xad, 0x3e, + 0x80, 0xc1, 0xd3, 0xde, 0xa7, 0x47, 0xa2, 0xa7, 0x95, 0x7d, 0x81, 0xae}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5b, 0x67, 0x45, 0x83, 0x2d, 0xb9, 0x94, 0xd9, 0x7, 0xa9, 0x35, 0x28, 0xb9, 0xec, - 0x3f, 0xbb, 0xab, 0xd0, 0x82, 0xf2, 0xf, 0x64, 0x71, 0xe, 0x1f, 0x4e, 0x44}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x67, 0xe2, 0x36, 0x77, 0x54, 0x81, 0xfe, 0xb3, 0x0, 0xe4, 0xa3, 0xda, + 0xee, 0x83, 0x82, 0xc6, 0x83, 0xac, 0xd, 0x22, 0xdf, 0xc3, 0xac, 0x82}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x20, 0x59, 0xf6, 0x8b, 0x5c, 0x78, 0x6a, 0xca, 0x29, 0xb6, - 0x76, 0xa6, 0x8, 0x46, 0x45, 0x62, 0xf5, 0x48, 0x82}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x75, 0x8a, 0xa7, 0x7f, 0xf, 0xa7, 0xac, 0x88, + 0xf4, 0xd9, 0xf9, 0xb9, 0xef, 0x42, 0xe4, 0x79}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa0, 0x33, 0x84, 0xea, 0x78, 0xfc, 0xc8, 0x0, 0x5d, 0x86}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc1, 0xfe, 0x23, 0x9f, 0xd2, 0x96, 0x82, 0x22, 0xfa}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xd3, 0x8b, 0xff, 0x2a, 0x4, 0xe8, 0xf3, 0x93, 0x44, 0xfc, 0xf, 0xd7, - 0x35, 0x46, 0xf, 0x46, 0x5b, 0xd1, 0x1a, 0x77, 0xc3, 0x49, 0x82}; - lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xec, 0xb3, 0xe3, 0xce, 0x50, 0x8d, 0x69, 0x13, 0x19, 0xed, + 0xf3, 0xe8, 0x22, 0x63, 0x47, 0x97, 0xc7, 0xbe, 0x49}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32664, 6, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14473, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21953 [("\STX\245\160\232\SUB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),(",\r\215\243\217\137",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 3580 [("\244E\204\&6O\ACKRSi\250\193:i*L\v{\159\212\243!\DLE\200o\175\172\236d\232\RS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("N\248\172\a7\159\250\EM\227{\179\201O\161ZR\140\251\188\207\144\212\STX\173\150w",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\155W\251\fk<\195p\184\253\175A\162\210\ETB",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ENQ\196M\SYN\244\173\DC2\170\SO\STXb\USw+z\173U\f\130\&4V\199\173\142\160\165\153\201\166\&4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS0}),("v\DLE\188\STXG!\142W\193\182\236H\NUL\fO$`\253e+\SO\214",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\163+\244m +// 1\138n\233\129sR\182\CAN\137\199(BB}\202\196m\231\208XEz\148",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("j\148\131KK\155",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Y\f\153\US\197\228\\\211\233\&9\CAN>\237\190\193\v\239\GSb",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("/\r\190",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("yL\254\155\&0U{\DLE\199\211\253\189\183F\149\222\US\218\186\b\175\DC2\252'\156",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\US&\190d\ETX~\239/\NAK\128\228\240io\227\DC1\SUB6\DC1\175 \153",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode15) { - uint8_t pkt[] = {0x82, 0x34, 0x55, 0xc1, 0x0, 0x5, 0x2, 0xf5, 0xa0, 0xe8, 0x1a, 0x2, 0x0, 0x6, - 0x2c, 0xd, 0xd7, 0xf3, 0xd9, 0x89, 0x2, 0x0, 0x1e, 0x5, 0xc4, 0x4d, 0x16, 0xf4, - 0xad, 0x12, 0xaa, 0xe, 0x2, 0x62, 0x1f, 0x77, 0x2b, 0x7a, 0xad, 0x55, 0xc, 0x82, - 0x34, 0x56, 0xc7, 0xad, 0x8e, 0xa0, 0xa5, 0x99, 0xc9, 0xa6, 0x34, 0x2}; + uint8_t pkt[] = {0x82, 0xe5, 0x1, 0xd, 0xfc, 0x0, 0x1e, 0xf4, 0x45, 0xcc, 0x36, 0x4f, 0x6, 0x52, 0x53, 0x69, 0xfa, + 0xc1, 0x3a, 0x69, 0x2a, 0x4c, 0xb, 0x7b, 0x9f, 0xd4, 0xf3, 0x21, 0x10, 0xc8, 0x6f, 0xaf, 0xac, 0xec, + 0x64, 0xe8, 0x1e, 0x2, 0x0, 0x1a, 0x4e, 0xf8, 0xac, 0x7, 0x37, 0x9f, 0xfa, 0x19, 0xe3, 0x7b, 0xb3, + 0xc9, 0x4f, 0xa1, 0x5a, 0x52, 0x8c, 0xfb, 0xbc, 0xcf, 0x90, 0xd4, 0x2, 0xad, 0x96, 0x77, 0x0, 0x0, + 0xf, 0x9b, 0x57, 0xfb, 0xc, 0x6b, 0x3c, 0xc3, 0x70, 0xb8, 0xfd, 0xaf, 0x41, 0xa2, 0xd2, 0x17, 0x0, + 0x0, 0x16, 0x76, 0x10, 0xbc, 0x2, 0x47, 0x21, 0x8e, 0x57, 0xc1, 0xb6, 0xec, 0x48, 0x0, 0xc, 0x4f, + 0x24, 0x60, 0xfd, 0x65, 0x2b, 0xe, 0xd6, 0x1, 0x0, 0x1d, 0xa3, 0x2b, 0xf4, 0x6d, 0x20, 0x31, 0x8a, + 0x6e, 0xe9, 0x81, 0x73, 0x52, 0xb6, 0x18, 0x89, 0xc7, 0x28, 0x42, 0x42, 0x7d, 0xca, 0xc4, 0x6d, 0xe7, + 0xd0, 0x58, 0x45, 0x7a, 0x94, 0x1, 0x0, 0x6, 0x6a, 0x94, 0x83, 0x4b, 0x4b, 0x9b, 0x2, 0x0, 0x13, + 0x59, 0xc, 0x99, 0x1f, 0xc5, 0xe4, 0x5c, 0xd3, 0xe9, 0x39, 0x18, 0x3e, 0xed, 0xbe, 0xc1, 0xb, 0xef, + 0x1d, 0x62, 0x1, 0x0, 0x3, 0x2f, 0xd, 0xbe, 0x0, 0x0, 0x19, 0x79, 0x4c, 0xfe, 0x9b, 0x30, 0x55, + 0x7b, 0x10, 0xc7, 0xd3, 0xfd, 0xbd, 0xb7, 0x46, 0x95, 0xde, 0x1f, 0xda, 0xba, 0x8, 0xaf, 0x12, 0xfc, + 0x27, 0x9c, 0x2, 0x0, 0x16, 0x1f, 0x26, 0xbe, 0x64, 0x3, 0x7e, 0xef, 0x2f, 0x15, 0x80, 0xe4, 0xf0, + 0x69, 0x6f, 0xe3, 0x11, 0x1a, 0x36, 0x11, 0xaf, 0x20, 0x99, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x2, 0xf5, 0xa0, 0xe8, 0x1a}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xf4, 0x45, 0xcc, 0x36, 0x4f, 0x6, 0x52, 0x53, 0x69, 0xfa, + 0xc1, 0x3a, 0x69, 0x2a, 0x4c, 0xb, 0x7b, 0x9f, 0xd4, 0xf3, + 0x21, 0x10, 0xc8, 0x6f, 0xaf, 0xac, 0xec, 0x64, 0xe8, 0x1e}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2c, 0xd, 0xd7, 0xf3, 0xd9, 0x89}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4e, 0xf8, 0xac, 0x7, 0x37, 0x9f, 0xfa, 0x19, 0xe3, 0x7b, 0xb3, 0xc9, 0x4f, + 0xa1, 0x5a, 0x52, 0x8c, 0xfb, 0xbc, 0xcf, 0x90, 0xd4, 0x2, 0xad, 0x96, 0x77}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5, 0xc4, 0x4d, 0x16, 0xf4, 0xad, 0x12, 0xaa, 0xe, 0x2, - 0x62, 0x1f, 0x77, 0x2b, 0x7a, 0xad, 0x55, 0xc, 0x82, 0x34, - 0x56, 0xc7, 0xad, 0x8e, 0xa0, 0xa5, 0x99, 0xc9, 0xa6, 0x34}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x9b, 0x57, 0xfb, 0xc, 0x6b, 0x3c, 0xc3, 0x70, + 0xb8, 0xfd, 0xaf, 0x41, 0xa2, 0xd2, 0x17}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t topic_filter_s3_bytes[] = {0x76, 0x10, 0xbc, 0x2, 0x47, 0x21, 0x8e, 0x57, 0xc1, 0xb6, 0xec, + 0x48, 0x0, 0xc, 0x4f, 0x24, 0x60, 0xfd, 0x65, 0x2b, 0xe, 0xd6}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa3, 0x2b, 0xf4, 0x6d, 0x20, 0x31, 0x8a, 0x6e, 0xe9, 0x81, + 0x73, 0x52, 0xb6, 0x18, 0x89, 0xc7, 0x28, 0x42, 0x42, 0x7d, + 0xca, 0xc4, 0x6d, 0xe7, 0xd0, 0x58, 0x45, 0x7a, 0x94}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6a, 0x94, 0x83, 0x4b, 0x4b, 0x9b}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x59, 0xc, 0x99, 0x1f, 0xc5, 0xe4, 0x5c, 0xd3, 0xe9, 0x39, + 0x18, 0x3e, 0xed, 0xbe, 0xc1, 0xb, 0xef, 0x1d, 0x62}; + lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x2f, 0xd, 0xbe}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x79, 0x4c, 0xfe, 0x9b, 0x30, 0x55, 0x7b, 0x10, 0xc7, 0xd3, 0xfd, 0xbd, 0xb7, + 0x46, 0x95, 0xde, 0x1f, 0xda, 0xba, 0x8, 0xaf, 0x12, 0xfc, 0x27, 0x9c}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x1f, 0x26, 0xbe, 0x64, 0x3, 0x7e, 0xef, 0x2f, 0x15, 0x80, 0xe4, + 0xf0, 0x69, 0x6f, 0xe3, 0x11, 0x1a, 0x36, 0x11, 0xaf, 0x20, 0x99}; + lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21953, 3, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3580, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20725 [("\128b\134\ACK",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("e\184\fN\150\215\RSt\rh\167\248\DC1\152\SOH\247\EOT\209\136i\165",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 8671 [("\137/\167\132\169\250\&8Z\230",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("vQ\229\222\160\&5\214\180",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\227~\DC4\240\205\167\163\150\&9\US\197\SIO\186>\237\168\235[",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\197\199!H\185\STX\187\SI4oM\179\237 \167(vk\193\195\&4\208\205*^\161\153\178\RS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\166\188\156I\185\220\&3S#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),(".\204\SYNt\DEL\ETXV\"6\RS\192\193\199\228\130\160",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("f\186\US\183;a^\179\132Wd\CAN\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),(",\166\140N",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\175\142\248\&0\231s\212\169^s\151\213\133[J\153L=\USc3",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("J\227\239\US\219\166\EM\235K\b8G@\158\156l\216xH\131\&5{\174\253",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0x21, 0x50, 0xf5, 0x0, 0x4, 0x80, 0x62, 0x86, 0x6, 0x2, 0x0, - 0x15, 0x65, 0xb8, 0xc, 0x4e, 0x96, 0xd7, 0x1e, 0x74, 0xd, 0x68, 0xa7, - 0xf8, 0x11, 0x98, 0x1, 0xf7, 0x4, 0xd1, 0x88, 0x69, 0xa5, 0x0}; + uint8_t pkt[] = {0x82, 0xb8, 0x1, 0x21, 0xdf, 0x0, 0x9, 0x89, 0x2f, 0xa7, 0x84, 0xa9, 0xfa, 0x38, 0x5a, 0xe6, 0x1, + 0x0, 0x8, 0x76, 0x51, 0xe5, 0xde, 0xa0, 0x35, 0xd6, 0xb4, 0x1, 0x0, 0x13, 0xe3, 0x7e, 0x14, 0xf0, + 0xcd, 0xa7, 0xa3, 0x96, 0x39, 0x1f, 0xc5, 0xf, 0x4f, 0xba, 0x3e, 0xed, 0xa8, 0xeb, 0x5b, 0x0, 0x0, + 0x1d, 0xc5, 0xc7, 0x21, 0x48, 0xb9, 0x2, 0xbb, 0xf, 0x34, 0x6f, 0x4d, 0xb3, 0xed, 0x20, 0xa7, 0x28, + 0x76, 0x6b, 0xc1, 0xc3, 0x34, 0xd0, 0xcd, 0x2a, 0x5e, 0xa1, 0x99, 0xb2, 0x1e, 0x1, 0x0, 0x9, 0xa6, + 0xbc, 0x9c, 0x49, 0xb9, 0xdc, 0x33, 0x53, 0x23, 0x2, 0x0, 0x10, 0x2e, 0xcc, 0x16, 0x74, 0x7f, 0x3, + 0x56, 0x22, 0x36, 0x1e, 0xc0, 0xc1, 0xc7, 0xe4, 0x82, 0xa0, 0x1, 0x0, 0xd, 0x66, 0xba, 0x1f, 0xb7, + 0x3b, 0x61, 0x5e, 0xb3, 0x84, 0x57, 0x64, 0x18, 0xdb, 0x2, 0x0, 0x4, 0x2c, 0xa6, 0x8c, 0x4e, 0x2, + 0x0, 0x15, 0xaf, 0x8e, 0xf8, 0x30, 0xe7, 0x73, 0xd4, 0xa9, 0x5e, 0x73, 0x97, 0xd5, 0x85, 0x5b, 0x4a, + 0x99, 0x4c, 0x3d, 0x1f, 0x63, 0x33, 0x1, 0x0, 0x18, 0x4a, 0xe3, 0xef, 0x1f, 0xdb, 0xa6, 0x19, 0xeb, + 0x4b, 0x8, 0x38, 0x47, 0x40, 0x9e, 0x9c, 0x6c, 0xd8, 0x78, 0x48, 0x83, 0x35, 0x7b, 0xae, 0xfd, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x80, 0x62, 0x86, 0x6}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x89, 0x2f, 0xa7, 0x84, 0xa9, 0xfa, 0x38, 0x5a, 0xe6}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x65, 0xb8, 0xc, 0x4e, 0x96, 0xd7, 0x1e, 0x74, 0xd, 0x68, 0xa7, - 0xf8, 0x11, 0x98, 0x1, 0xf7, 0x4, 0xd1, 0x88, 0x69, 0xa5}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x76, 0x51, 0xe5, 0xde, 0xa0, 0x35, 0xd6, 0xb4}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0}; + uint8_t topic_filter_s2_bytes[] = {0xe3, 0x7e, 0x14, 0xf0, 0xcd, 0xa7, 0xa3, 0x96, 0x39, 0x1f, + 0xc5, 0xf, 0x4f, 0xba, 0x3e, 0xed, 0xa8, 0xeb, 0x5b}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc5, 0xc7, 0x21, 0x48, 0xb9, 0x2, 0xbb, 0xf, 0x34, 0x6f, + 0x4d, 0xb3, 0xed, 0x20, 0xa7, 0x28, 0x76, 0x6b, 0xc1, 0xc3, + 0x34, 0xd0, 0xcd, 0x2a, 0x5e, 0xa1, 0x99, 0xb2, 0x1e}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa6, 0xbc, 0x9c, 0x49, 0xb9, 0xdc, 0x33, 0x53, 0x23}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x2e, 0xcc, 0x16, 0x74, 0x7f, 0x3, 0x56, 0x22, + 0x36, 0x1e, 0xc0, 0xc1, 0xc7, 0xe4, 0x82, 0xa0}; + lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x66, 0xba, 0x1f, 0xb7, 0x3b, 0x61, 0x5e, 0xb3, 0x84, 0x57, 0x64, 0x18, 0xdb}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x2c, 0xa6, 0x8c, 0x4e}; + lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xaf, 0x8e, 0xf8, 0x30, 0xe7, 0x73, 0xd4, 0xa9, 0x5e, 0x73, 0x97, + 0xd5, 0x85, 0x5b, 0x4a, 0x99, 0x4c, 0x3d, 0x1f, 0x63, 0x33}; + lwmqtt_string_t topic_filter_s8 = {21, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x4a, 0xe3, 0xef, 0x1f, 0xdb, 0xa6, 0x19, 0xeb, 0x4b, 0x8, 0x38, 0x47, + 0x40, 0x9e, 0x9c, 0x6c, 0xd8, 0x78, 0x48, 0x83, 0x35, 0x7b, 0xae, 0xfd}; + lwmqtt_string_t topic_filter_s9 = {24, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20725, 2, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8671, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 24375 [("Xx.\181I\175\249\174u\214\foC'\226e\196\233\RS\136\225[0\172-y\128",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\203Dra\249\DC2s\SOe\167\r}\158\ETX\128\141\242?5\203\239\147",SubOptions {_retainHandling = +// SubscribeRequest 12528 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\148\&2\192\239\ETBl1G.]3f\EOT\158\156\169i\146#uO\217",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\225L\215\SOHGKI\217p5\225\219\187\228,p\ENQ*\218I\194\153q",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("S\231ewx\206\160\202P",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("Y\242H\243&V\212K2\185\&2sq\178\178c\194\230\214)\\\237\ETX\SO",SubOptions {_retainHandling = +// QoS0}),("\171Kky\198c\184w\165e^\140n\236\SI\DEL\157d;\186d\234\NUL]\161",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\183",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\rm3\DEL,+L\150\CAN|9j\159\255g\206\t\FS=\160\201\&1",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS1}),(";\246\134\170\224\207z\RSCq",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS1}),("J\FS\206NB\154\253\b\US\197\172*=\232CO\212\210\181\202\&0,&>\135\&4\224\226\170\203",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode17) { - uint8_t pkt[] = {0x82, 0x6d, 0x5f, 0x37, 0x0, 0x1b, 0x58, 0x78, 0x2e, 0xb5, 0x49, 0xaf, 0xf9, 0xae, 0x75, 0xd6, - 0xc, 0x6f, 0x43, 0x27, 0xe2, 0x65, 0xc4, 0xe9, 0x1e, 0x88, 0xe1, 0x5b, 0x30, 0xac, 0x2d, 0x79, - 0x80, 0x2,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a, 0xe0, 0xcf, 0x7a, 0x1e, 0x43, 0x71, 0x1, 0x0, 0x1e, 0x4a, + 0x1c, 0xce, 0x4e, 0x42, 0x9a, 0xfd, 0x8, 0x1f, 0xc5, 0xac, 0x2a, 0x3d, 0xe8, 0x43, 0x4f, 0xd4, 0xd2, + 0xb5, 0xca, 0x30, 0x2c, 0x26, 0x3e, 0x87, 0x34, 0xe0, 0xe2, 0xaa, 0xcb, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x58, 0x78, 0x2e, 0xb5, 0x49, 0xaf, 0xf9, 0xae, 0x75, 0xd6, 0xc, 0x6f, 0x43, 0x27, - 0xe2, 0x65, 0xc4, 0xe9, 0x1e, 0x88, 0xe1, 0x5b, 0x30, 0xac, 0x2d, 0x79, 0x80}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcb, 0x44, 0x72, 0x61, 0xf9, 0x12, 0x73, 0xe, 0x65, 0xa7, 0xd, - 0x7d, 0x9e, 0x3, 0x80, 0x8d, 0xf2, 0x3f, 0x35, 0xcb, 0xef, 0x93}; + uint8_t topic_filter_s1_bytes[] = {0x94, 0x32, 0xc0, 0xef, 0x17, 0x6c, 0x31, 0x47, 0x2e, 0x5d, 0x33, + 0x66, 0x4, 0x9e, 0x9c, 0xa9, 0x69, 0x92, 0x23, 0x75, 0x4f, 0xd9}; lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x59, 0xf2, 0x48, 0xf3, 0x26, 0x56, 0xd4, 0x4b, 0x32, 0xb9, 0x32, 0x73, - 0x71, 0xb2, 0xb2, 0x63, 0xc2, 0xe6, 0xd6, 0x29, 0x5c, 0xed, 0x3, 0xe}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe1, 0x4c, 0xd7, 0x1, 0x47, 0x4b, 0x49, 0xd9, 0x70, 0x35, 0xe1, 0xdb, + 0xbb, 0xe4, 0x2c, 0x70, 0x5, 0x2a, 0xda, 0x49, 0xc2, 0x99, 0x71}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd, 0x6d, 0x33, 0x7f, 0x2c, 0x2b, 0x4c, 0x96, 0x18, 0x7c, 0x39, - 0x6a, 0x9f, 0xff, 0x67, 0xce, 0x9, 0x1c, 0x3d, 0xa0, 0xc9, 0x31}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x53, 0xe7, 0x65, 0x77, 0x78, 0xce, 0xa0, 0xca, 0x50}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t topic_filter_s4_bytes[] = {0xab, 0x4b, 0x6b, 0x79, 0xc6, 0x63, 0xb8, 0x77, 0xa5, 0x65, 0x5e, 0x8c, 0x6e, + 0xec, 0xf, 0x7f, 0x9d, 0x64, 0x3b, 0xba, 0x64, 0xea, 0x0, 0x5d, 0xa1}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb7}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3b, 0xf6, 0x86, 0xaa, 0xe0, 0xcf, 0x7a, 0x1e, 0x43, 0x71}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x4a, 0x1c, 0xce, 0x4e, 0x42, 0x9a, 0xfd, 0x8, 0x1f, 0xc5, + 0xac, 0x2a, 0x3d, 0xe8, 0x43, 0x4f, 0xd4, 0xd2, 0xb5, 0xca, + 0x30, 0x2c, 0x26, 0x3e, 0x87, 0x34, 0xe0, 0xe2, 0xaa, 0xcb}; + lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24375, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12528, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15182 [("jX\253\212\226>%\234\136\158",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("wv\141n\252k\ESC\242,\211jBIr\ESC\nN\254\RSG\227C\180/A\174\244\STX\228\222",SubOptions {_retainHandling = +// SubscribeRequest 9386 [("\209\EM\NUL~%q\250\200\SYNf]\226\199+9\165'\162\178V\208\DLE",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("WE\f\171+\DC1\ETB\v\EOT\DLE\176\tw_\SYN/\ETX",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\161AM\198\RS6\146w\219\173\244\245J>\201",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS2}),("e\171N\STX\186ov\240\229\136D\\\234J\152e\217",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS1}),("\n\ETB\130\245\135\213\245\138\&6E\221M\DC2]\175\198\214CL8\139",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("(pn\242\166\175uq\214\245\142\vZR\209",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode18) { - uint8_t pkt[] = {0x82, 0x6a, 0x3b, 0x4e, 0x0, 0xa, 0x6a, 0x58, 0xfd, 0xd4, 0xe2, 0x3e, 0x25, 0xea, 0x88, 0x9e, - 0x1, 0x0, 0x1e, 0x77, 0x76, 0x8d, 0x6e, 0xfc, 0x6b, 0x1b, 0xf2, 0x2c, 0xd3, 0x6a, 0x42, 0x49, - 0x72, 0x1b, 0xa, 0x4e, 0xfe, 0x1e, 0x47, 0xe3, 0x43, 0xb4, 0x2f, 0x41, 0xae, 0xf4, 0x2, 0xe4, - 0xde, 0x1, 0x0, 0x11, 0x57, 0x45, 0xc, 0xab, 0x2b, 0x11, 0x17, 0xb, 0x4, 0x10, 0xb0, 0x9, - 0x77, 0x5f, 0x16, 0x2f, 0x3, 0x1, 0x0, 0xf, 0xa1, 0x41, 0x4d, 0xc6, 0x1e, 0x36, 0x92, 0x77, - 0xdb, 0xad, 0xf4, 0xf5, 0x4a, 0x3e, 0xc9, 0x2, 0x0, 0x11, 0x65, 0xab, 0x4e, 0x2, 0xba, 0x6f, - 0x76, 0xf0, 0xe5, 0x88, 0x44, 0x5c, 0xea, 0x4a, 0x98, 0x65, 0xd9, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x6a, 0x58, 0xfd, 0xd4, 0xe2, 0x3e, 0x25, 0xea, 0x88, 0x9e}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x45, 0x24, 0xaa, 0x0, 0x16, 0xd1, 0x19, 0x0, 0x7e, 0x25, 0x71, 0xfa, 0xc8, 0x16, + 0x66, 0x5d, 0xe2, 0xc7, 0x2b, 0x39, 0xa5, 0x27, 0xa2, 0xb2, 0x56, 0xd0, 0x10, 0x1, 0x0, + 0x15, 0xa, 0x17, 0x82, 0xf5, 0x87, 0xd5, 0xf5, 0x8a, 0x36, 0x45, 0xdd, 0x4d, 0x12, 0x5d, + 0xaf, 0xc6, 0xd6, 0x43, 0x4c, 0x38, 0x8b, 0x0, 0x0, 0xf, 0x28, 0x70, 0x6e, 0xf2, 0xa6, + 0xaf, 0x75, 0x71, 0xd6, 0xf5, 0x8e, 0xb, 0x5a, 0x52, 0xd1, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xd1, 0x19, 0x0, 0x7e, 0x25, 0x71, 0xfa, 0xc8, 0x16, 0x66, 0x5d, + 0xe2, 0xc7, 0x2b, 0x39, 0xa5, 0x27, 0xa2, 0xb2, 0x56, 0xd0, 0x10}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x77, 0x76, 0x8d, 0x6e, 0xfc, 0x6b, 0x1b, 0xf2, 0x2c, 0xd3, - 0x6a, 0x42, 0x49, 0x72, 0x1b, 0xa, 0x4e, 0xfe, 0x1e, 0x47, - 0xe3, 0x43, 0xb4, 0x2f, 0x41, 0xae, 0xf4, 0x2, 0xe4, 0xde}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa, 0x17, 0x82, 0xf5, 0x87, 0xd5, 0xf5, 0x8a, 0x36, 0x45, 0xdd, + 0x4d, 0x12, 0x5d, 0xaf, 0xc6, 0xd6, 0x43, 0x4c, 0x38, 0x8b}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x57, 0x45, 0xc, 0xab, 0x2b, 0x11, 0x17, 0xb, 0x4, - 0x10, 0xb0, 0x9, 0x77, 0x5f, 0x16, 0x2f, 0x3}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x28, 0x70, 0x6e, 0xf2, 0xa6, 0xaf, 0x75, 0x71, + 0xd6, 0xf5, 0x8e, 0xb, 0x5a, 0x52, 0xd1}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa1, 0x41, 0x4d, 0xc6, 0x1e, 0x36, 0x92, 0x77, - 0xdb, 0xad, 0xf4, 0xf5, 0x4a, 0x3e, 0xc9}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x65, 0xab, 0x4e, 0x2, 0xba, 0x6f, 0x76, 0xf0, 0xe5, - 0x88, 0x44, 0x5c, 0xea, 0x4a, 0x98, 0x65, 0xd9}; - lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15182, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9386, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29268 [("\142",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = -// QoS0}),("5\254\147\212\152\233@<\242\195\191\180#\\Sl\SI\249(\174P\136\239\"B\182\139\218",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\229\173x -// \159d\157\161F\133y\253\&4\185\191h\167\231\noU\SI/\158\193\239",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(";Q=\182\248\245\152C&\221k\173\153\ESC\151\156",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Q\168tf\193i\245\US\ENQ\177nl\202/\177",SubOptions +// SubscribeRequest 17533 [("(\v5\187IR\198\&8\215Mh\DC1\234\194",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("_E",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\166GM",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\216\209{\247V0\206\253\155\DC4\CAN",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),(",\170\200\239\ETX\218}\155\195\194\177faHsp\134\SI",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\177\139\193I\228b\DLEvi\211\r{\aRg",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\195E\216",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("l\151\230\r\129\b\184\193\176\178\162\197\&5\188/\SO\187",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(" k\147",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS0}),("\140\140\rH\207f*P<\249\191k\ETB\229\141\224Y\138\SI\SYN\251;\DC12M",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("j\234\196n\SUB\146\132\168?\155F\190)\137\235.\233\224\135\138\DC1\a#\GS",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("83\213v",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode19) { - uint8_t pkt[] = {0x82, 0x99, 0x1, 0x72, 0x54, 0x0, 0x1, 0x8e, 0x0, 0x0, 0x1c, 0x35, 0xfe, 0x93, 0xd4, 0x98, - 0xe9, 0x40, 0x3c, 0xf2, 0xc3, 0xbf, 0xb4, 0x23, 0x5c, 0x53, 0x6c, 0xf, 0xf9, 0x28, 0xae, 0x50, - 0x88, 0xef, 0x22, 0x42, 0xb6, 0x8b, 0xda, 0x1, 0x0, 0x1a, 0xe5, 0xad, 0x78, 0x20, 0x9f, 0x64, - 0x9d, 0xa1, 0x46, 0x85, 0x79, 0xfd, 0x34, 0xb9, 0xbf, 0x68, 0xa7, 0xe7, 0xa, 0x6f, 0x55, 0xf, - 0x2f, 0x9e, 0xc1, 0xef, 0x0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6a, 0xea, 0xc4, 0x6e, 0x1a, + 0x92, 0x84, 0xa8, 0x3f, 0x9b, 0x46, 0xbe, 0x29, 0x89, 0xeb, 0x2e, 0xe9, 0xe0, 0x87, 0x8a, 0x11, 0x7, + 0x23, 0x1d, 0x1, 0x0, 0x4, 0x38, 0x33, 0xd5, 0x76, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x8e}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x28, 0xb, 0x35, 0xbb, 0x49, 0x52, 0xc6, 0x38, 0xd7, 0x4d, 0x68, 0x11, 0xea, 0xc2}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x35, 0xfe, 0x93, 0xd4, 0x98, 0xe9, 0x40, 0x3c, 0xf2, 0xc3, - 0xbf, 0xb4, 0x23, 0x5c, 0x53, 0x6c, 0xf, 0xf9, 0x28, 0xae, - 0x50, 0x88, 0xef, 0x22, 0x42, 0xb6, 0x8b, 0xda}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5f, 0x45}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe5, 0xad, 0x78, 0x20, 0x9f, 0x64, 0x9d, 0xa1, 0x46, 0x85, 0x79, 0xfd, 0x34, - 0xb9, 0xbf, 0x68, 0xa7, 0xe7, 0xa, 0x6f, 0x55, 0xf, 0x2f, 0x9e, 0xc1, 0xef}; - lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa6, 0x47, 0x4d}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3b, 0x51, 0x3d, 0xb6, 0xf8, 0xf5, 0x98, 0x43, - 0x26, 0xdd, 0x6b, 0xad, 0x99, 0x1b, 0x97, 0x9c}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd8, 0xd1, 0x7b, 0xf7, 0x56, 0x30, 0xce, 0xfd, 0x9b, 0x14, 0x18}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x51, 0xa8, 0x74, 0x66, 0xc1, 0x69, 0xf5, 0x1f, - 0x5, 0xb1, 0x6e, 0x6c, 0xca, 0x2f, 0xb1}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2c, 0xaa, 0xc8, 0xef, 0x3, 0xda, 0x7d, 0x9b, 0xc3, + 0xc2, 0xb1, 0x66, 0x61, 0x48, 0x73, 0x70, 0x86, 0xf}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb1, 0x8b, 0xc1, 0x49, 0xe4, 0x62, 0x10, 0x76, - 0x69, 0xd3, 0xd, 0x7b, 0x7, 0x52, 0x67}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x8c, 0x8c, 0xd, 0x48, 0xcf, 0x66, 0x2a, 0x50, 0x3c, 0xf9, 0xbf, 0x6b, 0x17, + 0xe5, 0x8d, 0xe0, 0x59, 0x8a, 0xf, 0x16, 0xfb, 0x3b, 0x11, 0x32, 0x4d}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc3, 0x45, 0xd8}; - lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x6a, 0xea, 0xc4, 0x6e, 0x1a, 0x92, 0x84, 0xa8, 0x3f, 0x9b, 0x46, 0xbe, + 0x29, 0x89, 0xeb, 0x2e, 0xe9, 0xe0, 0x87, 0x8a, 0x11, 0x7, 0x23, 0x1d}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6c, 0x97, 0xe6, 0xd, 0x81, 0x8, 0xb8, 0xc1, 0xb0, - 0xb2, 0xa2, 0xc5, 0x35, 0xbc, 0x2f, 0xe, 0xbb}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x38, 0x33, 0xd5, 0x76}; + lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x20, 0x6b, 0x93}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29268, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17533, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30528 [("Z7\246b'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\248\161\240\135Q\130\198oV\RS\187~7'\DC2@\ACK~i\213csX\200kE\240",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\248\215\167X\a\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("W\139~\240\234\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("\226\223\ETXA\170{\FS\197RN\147X\161\ESC\SI\a\197\vB3\232\220\160{\136\242\&5\150\150",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\134\236\184\180A/4\206\134\176p\163\&6\NUL\RS$\US\200\CAN\DELU\156\224",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ENQ\177",SubOptions +// SubscribeRequest 1875 [("\131\239*\255VM\230[\170\a\ACK|\132\249\176v\212",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode20) { + uint8_t pkt[] = {0x82, 0x16, 0x7, 0x53, 0x0, 0x11, 0x83, 0xef, 0x2a, 0xff, 0x56, 0x4d, + 0xe6, 0x5b, 0xaa, 0x7, 0x6, 0x7c, 0x84, 0xf9, 0xb0, 0x76, 0xd4, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x83, 0xef, 0x2a, 0xff, 0x56, 0x4d, 0xe6, 0x5b, 0xaa, + 0x7, 0x6, 0x7c, 0x84, 0xf9, 0xb0, 0x76, 0xd4}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1875, 1, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 14558 [("\253\195\NUL\169\SUB\205/\SYNc\168\233|a\172\161\187\236\149\159 \222\215$\195<",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\207\&1\134\149\169\137_\145\\\185,\187\242\226\135J>\203\203B\245\196\147\239\168\212\167\145\219",SubOptions +// QoS1}),("E\201R^&\SUB,\148vp@\224",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\215\136.^@|s6\135?U\231\230Q{\238d\161\131\NUL\177M\\\DC1",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(",\176\197p\224M\\\200",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\155w\224D\180\218\161\221r@3\"\131\FS\184\204\160",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode20) { - uint8_t pkt[] = {0x82, 0xb8, 0x1, 0x77, 0x40, 0x0, 0x5, 0x5a, 0x37, 0xf6, 0x62, 0x27, 0x1, 0x0, 0x1b, 0xf8, 0xa1, - 0xf0, 0x87, 0x51, 0x82, 0xc6, 0x6f, 0x56, 0x1e, 0xbb, 0x7e, 0x37, 0x27, 0x12, 0x40, 0x6, 0x7e, 0x69, - 0xd5, 0x63, 0x73, 0x58, 0xc8, 0x6b, 0x45, 0xf0, 0x2, 0x0, 0x6, 0xf8, 0xd7, 0xa7, 0x58, 0x7, 0xb8, - 0x1, 0x0, 0x6, 0x57, 0x8b, 0x7e, 0xf0, 0xea, 0xa, 0x2, 0x0, 0x1d, 0xe2, 0xdf, 0x3, 0x41, 0xaa, - 0x7b, 0x1c, 0xc5, 0x52, 0x4e, 0x93, 0x58, 0xa1, 0x1b, 0xf, 0x7, 0xc5, 0xb, 0x42, 0x33, 0xe8, 0xdc, - 0xa0, 0x7b, 0x88, 0xf2, 0x35, 0x96, 0x96, 0x2, 0x0, 0x17, 0x86, 0xec, 0xb8, 0xb4, 0x41, 0x2f, 0x34, - 0xce, 0x86, 0xb0, 0x70, 0xa3, 0x36, 0x0, 0x1e, 0x24, 0x1f, 0xc8, 0x18, 0x7f, 0x55, 0x9c, 0xe0, 0x0, - 0x0, 0x2, 0x5, 0xb1, 0x2, 0x0, 0x1d, 0xcf, 0x31, 0x86, 0x95, 0xa9, 0x89, 0x5f, 0x91, 0x5c, 0xb9, - 0x2c, 0xbb, 0xf2, 0xe2, 0x87, 0x4a, 0x3e, 0xcb, 0xcb, 0x42, 0xf5, 0xc4, 0x93, 0xef, 0xa8, 0xd4, 0xa7, - 0x91, 0xdb, 0x0, 0x0, 0x8, 0x2c, 0xb0, 0xc5, 0x70, 0xe0, 0x4d, 0x5c, 0xc8, 0x0, 0x0, 0x11, 0x9b, - 0x77, 0xe0, 0x44, 0xb4, 0xda, 0xa1, 0xdd, 0x72, 0x40, 0x33, 0x22, 0x83, 0x1c, 0xb8, 0xcc, 0xa0, 0x1}; +// QoS2}),("\136\133c\130\ACK\ETX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),(")\171\146\187\241\153\239",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\141\248\DC2\161?,jC\203G\198\135\203\134=\157\192\221\249~\246",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\189M!|\178~\166\141rn\247w\234",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode21) { + uint8_t pkt[] = {0x82, 0x83, 0x1, 0x38, 0xde, 0x0, 0x19, 0xfd, 0xc3, 0x0, 0xa9, 0x1a, 0xcd, 0x2f, 0x16, 0x63, 0xa8, + 0xe9, 0x7c, 0x61, 0xac, 0xa1, 0xbb, 0xec, 0x95, 0x9f, 0x20, 0xde, 0xd7, 0x24, 0xc3, 0x3c, 0x1, 0x0, + 0xc, 0x45, 0xc9, 0x52, 0x5e, 0x26, 0x1a, 0x2c, 0x94, 0x76, 0x70, 0x40, 0xe0, 0x1, 0x0, 0x18, 0xd7, + 0x88, 0x2e, 0x5e, 0x40, 0x7c, 0x73, 0x36, 0x87, 0x3f, 0x55, 0xe7, 0xe6, 0x51, 0x7b, 0xee, 0x64, 0xa1, + 0x83, 0x0, 0xb1, 0x4d, 0x5c, 0x11, 0x2, 0x0, 0x6, 0x88, 0x85, 0x63, 0x82, 0x6, 0x3, 0x0, 0x0, + 0x7, 0x29, 0xab, 0x92, 0xbb, 0xf1, 0x99, 0xef, 0x0, 0x0, 0x15, 0x8d, 0xf8, 0x12, 0xa1, 0x3f, 0x2c, + 0x6a, 0x43, 0xcb, 0x47, 0xc6, 0x87, 0xcb, 0x86, 0x3d, 0x9d, 0xc0, 0xdd, 0xf9, 0x7e, 0xf6, 0x1, 0x0, + 0xd, 0xbd, 0x4d, 0x21, 0x7c, 0xb2, 0x7e, 0xa6, 0x8d, 0x72, 0x6e, 0xf7, 0x77, 0xea, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x5a, 0x37, 0xf6, 0x62, 0x27}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xfd, 0xc3, 0x0, 0xa9, 0x1a, 0xcd, 0x2f, 0x16, 0x63, 0xa8, 0xe9, 0x7c, 0x61, + 0xac, 0xa1, 0xbb, 0xec, 0x95, 0x9f, 0x20, 0xde, 0xd7, 0x24, 0xc3, 0x3c}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf8, 0xa1, 0xf0, 0x87, 0x51, 0x82, 0xc6, 0x6f, 0x56, 0x1e, 0xbb, 0x7e, 0x37, 0x27, - 0x12, 0x40, 0x6, 0x7e, 0x69, 0xd5, 0x63, 0x73, 0x58, 0xc8, 0x6b, 0x45, 0xf0}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x45, 0xc9, 0x52, 0x5e, 0x26, 0x1a, 0x2c, 0x94, 0x76, 0x70, 0x40, 0xe0}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf8, 0xd7, 0xa7, 0x58, 0x7, 0xb8}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd7, 0x88, 0x2e, 0x5e, 0x40, 0x7c, 0x73, 0x36, 0x87, 0x3f, 0x55, 0xe7, + 0xe6, 0x51, 0x7b, 0xee, 0x64, 0xa1, 0x83, 0x0, 0xb1, 0x4d, 0x5c, 0x11}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x57, 0x8b, 0x7e, 0xf0, 0xea, 0xa}; + uint8_t topic_filter_s3_bytes[] = {0x88, 0x85, 0x63, 0x82, 0x6, 0x3}; lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe2, 0xdf, 0x3, 0x41, 0xaa, 0x7b, 0x1c, 0xc5, 0x52, 0x4e, - 0x93, 0x58, 0xa1, 0x1b, 0xf, 0x7, 0xc5, 0xb, 0x42, 0x33, - 0xe8, 0xdc, 0xa0, 0x7b, 0x88, 0xf2, 0x35, 0x96, 0x96}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x29, 0xab, 0x92, 0xbb, 0xf1, 0x99, 0xef}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x86, 0xec, 0xb8, 0xb4, 0x41, 0x2f, 0x34, 0xce, 0x86, 0xb0, 0x70, 0xa3, - 0x36, 0x0, 0x1e, 0x24, 0x1f, 0xc8, 0x18, 0x7f, 0x55, 0x9c, 0xe0}; - lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x8d, 0xf8, 0x12, 0xa1, 0x3f, 0x2c, 0x6a, 0x43, 0xcb, 0x47, 0xc6, + 0x87, 0xcb, 0x86, 0x3d, 0x9d, 0xc0, 0xdd, 0xf9, 0x7e, 0xf6}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5, 0xb1}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xbd, 0x4d, 0x21, 0x7c, 0xb2, 0x7e, 0xa6, 0x8d, 0x72, 0x6e, 0xf7, 0x77, 0xea}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xcf, 0x31, 0x86, 0x95, 0xa9, 0x89, 0x5f, 0x91, 0x5c, 0xb9, - 0x2c, 0xbb, 0xf2, 0xe2, 0x87, 0x4a, 0x3e, 0xcb, 0xcb, 0x42, - 0xf5, 0xc4, 0x93, 0xef, 0xa8, 0xd4, 0xa7, 0x91, 0xdb}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x2c, 0xb0, 0xc5, 0x70, 0xe0, 0x4d, 0x5c, 0xc8}; - lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x9b, 0x77, 0xe0, 0x44, 0xb4, 0xda, 0xa1, 0xdd, 0x72, - 0x40, 0x33, 0x22, 0x83, 0x1c, 0xb8, 0xcc, 0xa0}; - lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30528, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14558, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32298 [("\183B\236P\DC4\RS0\245>\186\t\170R\GS\ESC\SI\234\151\246\224",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode21) { - uint8_t pkt[] = {0x82, 0x19, 0x7e, 0x2a, 0x0, 0x14, 0xb7, 0x42, 0xec, 0x50, 0x14, 0x1e, 0x30, 0xf5, - 0x3e, 0xba, 0x9, 0xaa, 0x52, 0x1d, 0x1b, 0xf, 0xea, 0x97, 0xf6, 0xe0, 0x2}; +// SubscribeRequest 14679 [("\207`\174\172K_\ENQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),(";\232\&5\184JOL\164\ETX\139\154`\228+\DC23`\228",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode22) { + uint8_t pkt[] = {0x82, 0x21, 0x39, 0x57, 0x0, 0x7, 0xcf, 0x60, 0xae, 0xac, 0x4b, 0x5f, + 0x5, 0x2, 0x0, 0x12, 0x3b, 0xe8, 0x35, 0xb8, 0x4a, 0x4f, 0x4c, 0xa4, + 0x3, 0x8b, 0x9a, 0x60, 0xe4, 0x2b, 0x12, 0x33, 0x60, 0xe4, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xb7, 0x42, 0xec, 0x50, 0x14, 0x1e, 0x30, 0xf5, 0x3e, 0xba, - 0x9, 0xaa, 0x52, 0x1d, 0x1b, 0xf, 0xea, 0x97, 0xf6, 0xe0}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xcf, 0x60, 0xae, 0xac, 0x4b, 0x5f, 0x5}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; + uint8_t topic_filter_s1_bytes[] = {0x3b, 0xe8, 0x35, 0xb8, 0x4a, 0x4f, 0x4c, 0xa4, 0x3, + 0x8b, 0x9a, 0x60, 0xe4, 0x2b, 0x12, 0x33, 0x60, 0xe4}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32298, 1, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14679, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22169 [("\185n'\131\192M\162\EOTR\199\DC3\248G\138\NULjj\129\249\191\177\183D\200WU",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\247j\216\229\244\&4\DLEvoHjH\NUL\236\161\&64",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\130O\195\&2/BI\149/\183\137\146\218\179\CAN\198\212\174\&3a\191\158\214K\209\173p@\130",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\182g\162\186\175\184\210\ACKc>I\183\153\SO\176\v\255\221\&0L_\231Z",SubOptions {_retainHandling = +// SubscribeRequest 12650 [("\128\169\159\162P\211\&9;",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\208m\216",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\149\178\207\218V\235\209\189K6\143\DC3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode22) { - uint8_t pkt[] = {0x82, 0x7c, 0x56, 0x99, 0x0, 0x1a, 0xb9, 0x6e, 0x27, 0x83, 0xc0, 0x4d, 0xa2, 0x4, 0x52, 0xc7, - 0x13, 0xf8, 0x47, 0x8a, 0x0, 0x6a, 0x6a, 0x81, 0xf9, 0xbf, 0xb1, 0xb7, 0x44, 0xc8, 0x57, 0x55, - 0x1, 0x0, 0x11, 0xf7, 0x6a, 0xd8, 0xe5, 0xf4, 0x34, 0x10, 0x76, 0x6f, 0x48, 0x6a, 0x48, 0x0, - 0xec, 0xa1, 0x36, 0x34, 0x2, 0x0, 0x1d, 0x82, 0x4f, 0xc3, 0x32, 0x2f, 0x42, 0x49, 0x95, 0x2f, - 0xb7, 0x89, 0x92, 0xda, 0xb3, 0x18, 0xc6, 0xd4, 0xae, 0x33, 0x61, 0xbf, 0x9e, 0xd6, 0x4b, 0xd1, - 0xad, 0x70, 0x40, 0x82, 0x1, 0x0, 0x17, 0xb6, 0x67, 0xa2, 0xba, 0xaf, 0xb8, 0xd2, 0x6, 0x63, - 0x3e, 0x49, 0xb7, 0x99, 0xe, 0xb0, 0xb, 0xff, 0xdd, 0x30, 0x4c, 0x5f, 0xe7, 0x5a, 0x2, 0x0, - 0xc, 0x95, 0xb2, 0xcf, 0xda, 0x56, 0xeb, 0xd1, 0xbd, 0x4b, 0x36, 0x8f, 0x13, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xb9, 0x6e, 0x27, 0x83, 0xc0, 0x4d, 0xa2, 0x4, 0x52, 0xc7, 0x13, 0xf8, 0x47, - 0x8a, 0x0, 0x6a, 0x6a, 0x81, 0xf9, 0xbf, 0xb1, 0xb7, 0x44, 0xc8, 0x57, 0x55}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; +// QoS2}),("\236_\171\216\143\"\186H\168\235\192<\204\ACK\DEL[h\235\178@\147",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\216\RS\142\&4\175O\SOHGI9M\r\US\159\148,2\RS\196\SUB\136\EM\176\GS\129",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(",V\156\135\DC1\226\RS\199Z\rf\r\191.\220.\204\243\227\NAK\198\232\&6$@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\172\192\171\236\193\&0\139\ENQvR\250\SOH6\160\NAK\191\&9u",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\194\ETXM3U\240\EM\243\176\SO/\205H\143\242wn\138\199\137\156\211\175",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0x92, 0x1, 0x31, 0x6a, 0x0, 0x8, 0x80, 0xa9, 0x9f, 0xa2, 0x50, 0xd3, 0x39, 0x3b, 0x1, 0x0, + 0x3, 0xd0, 0x6d, 0xd8, 0x2, 0x0, 0x15, 0xec, 0x5f, 0xab, 0xd8, 0x8f, 0x22, 0xba, 0x48, 0xa8, 0xeb, + 0xc0, 0x3c, 0xcc, 0x6, 0x7f, 0x5b, 0x68, 0xeb, 0xb2, 0x40, 0x93, 0x0, 0x0, 0x19, 0xd8, 0x1e, 0x8e, + 0x34, 0xaf, 0x4f, 0x1, 0x47, 0x49, 0x39, 0x4d, 0xd, 0x1f, 0x9f, 0x94, 0x2c, 0x32, 0x1e, 0xc4, 0x1a, + 0x88, 0x19, 0xb0, 0x1d, 0x81, 0x0, 0x0, 0x19, 0x2c, 0x56, 0x9c, 0x87, 0x11, 0xe2, 0x1e, 0xc7, 0x5a, + 0xd, 0x66, 0xd, 0xbf, 0x2e, 0xdc, 0x2e, 0xcc, 0xf3, 0xe3, 0x15, 0xc6, 0xe8, 0x36, 0x24, 0x40, 0x2, + 0x0, 0x12, 0xac, 0xc0, 0xab, 0xec, 0xc1, 0x30, 0x8b, 0x5, 0x76, 0x52, 0xfa, 0x1, 0x36, 0xa0, 0x15, + 0xbf, 0x39, 0x75, 0x2, 0x0, 0x17, 0xc2, 0x3, 0x4d, 0x33, 0x55, 0xf0, 0x19, 0xf3, 0xb0, 0xe, 0x2f, + 0xcd, 0x48, 0x8f, 0xf2, 0x77, 0x6e, 0x8a, 0xc7, 0x89, 0x9c, 0xd3, 0xaf, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x80, 0xa9, 0x9f, 0xa2, 0x50, 0xd3, 0x39, 0x3b}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf7, 0x6a, 0xd8, 0xe5, 0xf4, 0x34, 0x10, 0x76, 0x6f, - 0x48, 0x6a, 0x48, 0x0, 0xec, 0xa1, 0x36, 0x34}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd0, 0x6d, 0xd8}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x82, 0x4f, 0xc3, 0x32, 0x2f, 0x42, 0x49, 0x95, 0x2f, 0xb7, - 0x89, 0x92, 0xda, 0xb3, 0x18, 0xc6, 0xd4, 0xae, 0x33, 0x61, - 0xbf, 0x9e, 0xd6, 0x4b, 0xd1, 0xad, 0x70, 0x40, 0x82}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xec, 0x5f, 0xab, 0xd8, 0x8f, 0x22, 0xba, 0x48, 0xa8, 0xeb, 0xc0, + 0x3c, 0xcc, 0x6, 0x7f, 0x5b, 0x68, 0xeb, 0xb2, 0x40, 0x93}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb6, 0x67, 0xa2, 0xba, 0xaf, 0xb8, 0xd2, 0x6, 0x63, 0x3e, 0x49, 0xb7, - 0x99, 0xe, 0xb0, 0xb, 0xff, 0xdd, 0x30, 0x4c, 0x5f, 0xe7, 0x5a}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd8, 0x1e, 0x8e, 0x34, 0xaf, 0x4f, 0x1, 0x47, 0x49, 0x39, 0x4d, 0xd, 0x1f, + 0x9f, 0x94, 0x2c, 0x32, 0x1e, 0xc4, 0x1a, 0x88, 0x19, 0xb0, 0x1d, 0x81}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x95, 0xb2, 0xcf, 0xda, 0x56, 0xeb, 0xd1, 0xbd, 0x4b, 0x36, 0x8f, 0x13}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2c, 0x56, 0x9c, 0x87, 0x11, 0xe2, 0x1e, 0xc7, 0x5a, 0xd, 0x66, 0xd, 0xbf, + 0x2e, 0xdc, 0x2e, 0xcc, 0xf3, 0xe3, 0x15, 0xc6, 0xe8, 0x36, 0x24, 0x40}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t topic_filter_s5_bytes[] = {0xac, 0xc0, 0xab, 0xec, 0xc1, 0x30, 0x8b, 0x5, 0x76, + 0x52, 0xfa, 0x1, 0x36, 0xa0, 0x15, 0xbf, 0x39, 0x75}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc2, 0x3, 0x4d, 0x33, 0x55, 0xf0, 0x19, 0xf3, 0xb0, 0xe, 0x2f, 0xcd, + 0x48, 0x8f, 0xf2, 0x77, 0x6e, 0x8a, 0xc7, 0x89, 0x9c, 0xd3, 0xaf}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22169, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12650, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26097 [("v\164\210X\179\135t\206\&0\177\165^\196\160\166\NUL78m}\195Z\147.rbC\177s9",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\255q\244\v\147\250\213/\143\151\&8\168\&9",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("l\168W:Wa\253\147\225\RS\164\242-;r')",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\DC15\NUL\236\249\231\210\141\246\n\ENQ\v\248\RS\USX\132\CAN\214\143w\202\139;]4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\231A\154h\ETX\223a\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode23) { - uint8_t pkt[] = {0x82, 0x6f, 0x65, 0xf1, 0x0, 0x1e, 0x76, 0xa4, 0xd2, 0x58, 0xb3, 0x87, 0x74, 0xce, 0x30, 0xb1, 0xa5, - 0x5e, 0xc4, 0xa0, 0xa6, 0x0, 0x37, 0x38, 0x6d, 0x7d, 0xc3, 0x5a, 0x93, 0x2e, 0x72, 0x62, 0x43, 0xb1, - 0x73, 0x39, 0x2, 0x0, 0xd, 0xff, 0x71, 0xf4, 0xb, 0x93, 0xfa, 0xd5, 0x2f, 0x8f, 0x97, 0x38, 0xa8, - 0x39, 0x0, 0x0, 0x11, 0x6c, 0xa8, 0x57, 0x3a, 0x57, 0x61, 0xfd, 0x93, 0xe1, 0x1e, 0xa4, 0xf2, 0x2d, - 0x3b, 0x72, 0x27, 0x29, 0x0, 0x0, 0x1a, 0x11, 0x35, 0x0, 0xec, 0xf9, 0xe7, 0xd2, 0x8d, 0xf6, 0xa, - 0x5, 0xb, 0xf8, 0x1e, 0x1f, 0x58, 0x84, 0x18, 0xd6, 0x8f, 0x77, 0xca, 0x8b, 0x3b, 0x5d, 0x34, 0x0, - 0x0, 0x8, 0xe7, 0x41, 0x9a, 0x68, 0x3, 0xdf, 0x61, 0xc5, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x76, 0xa4, 0xd2, 0x58, 0xb3, 0x87, 0x74, 0xce, 0x30, 0xb1, - 0xa5, 0x5e, 0xc4, 0xa0, 0xa6, 0x0, 0x37, 0x38, 0x6d, 0x7d, - 0xc3, 0x5a, 0x93, 0x2e, 0x72, 0x62, 0x43, 0xb1, 0x73, 0x39}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xff, 0x71, 0xf4, 0xb, 0x93, 0xfa, 0xd5, 0x2f, 0x8f, 0x97, 0x38, 0xa8, 0x39}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6c, 0xa8, 0x57, 0x3a, 0x57, 0x61, 0xfd, 0x93, 0xe1, - 0x1e, 0xa4, 0xf2, 0x2d, 0x3b, 0x72, 0x27, 0x29}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x11, 0x35, 0x0, 0xec, 0xf9, 0xe7, 0xd2, 0x8d, 0xf6, 0xa, 0x5, 0xb, 0xf8, - 0x1e, 0x1f, 0x58, 0x84, 0x18, 0xd6, 0x8f, 0x77, 0xca, 0x8b, 0x3b, 0x5d, 0x34}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe7, 0x41, 0x9a, 0x68, 0x3, 0xdf, 0x61, 0xc5}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26097, 5, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 25578 [("\151\169\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),("\129L\179D\b\\\136\147\&3\187\140\205\216\221\151\ENQ\149\128\155\211\210E\ENQ\240\&8q\203\180",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("F\219rm{\255\FS\161\228\207\147\157(\236.\DC1\150\EM$|\138p\253$u\SYN8\237\ENQ",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\196\SO\SI\252\189a\168*\239<\226M(\228'\183H\223\&9\165\220\ACK\229R\158\151\209n\151\248",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 3665 [("\RS2\128\242",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x68, 0x63, 0xea, 0x0, 0x3, 0x97, 0xa9, 0xa, 0x0, 0x0, 0x1c, 0x81, 0x4c, 0xb3, 0x44, - 0x8, 0x5c, 0x88, 0x93, 0x33, 0xbb, 0x8c, 0xcd, 0xd8, 0xdd, 0x97, 0x5, 0x95, 0x80, 0x9b, 0xd3, - 0xd2, 0x45, 0x5, 0xf0, 0x38, 0x71, 0xcb, 0xb4, 0x2, 0x0, 0x1d, 0x46, 0xdb, 0x72, 0x6d, 0x7b, - 0xff, 0x1c, 0xa1, 0xe4, 0xcf, 0x93, 0x9d, 0x28, 0xec, 0x2e, 0x11, 0x96, 0x19, 0x24, 0x7c, 0x8a, - 0x70, 0xfd, 0x24, 0x75, 0x16, 0x38, 0xed, 0x5, 0x0, 0x0, 0x1e, 0xc4, 0xe, 0xf, 0xfc, 0xbd, - 0x61, 0xa8, 0x2a, 0xef, 0x3c, 0xe2, 0x4d, 0x28, 0xe4, 0x27, 0xb7, 0x48, 0xdf, 0x39, 0xa5, 0xdc, - 0x6, 0xe5, 0x52, 0x9e, 0x97, 0xd1, 0x6e, 0x97, 0xf8, 0x1}; + uint8_t pkt[] = {0x82, 0x9, 0xe, 0x51, 0x0, 0x4, 0x1e, 0x32, 0x80, 0xf2, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x97, 0xa9, 0xa}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x1e, 0x32, 0x80, 0xf2}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x81, 0x4c, 0xb3, 0x44, 0x8, 0x5c, 0x88, 0x93, 0x33, 0xbb, - 0x8c, 0xcd, 0xd8, 0xdd, 0x97, 0x5, 0x95, 0x80, 0x9b, 0xd3, - 0xd2, 0x45, 0x5, 0xf0, 0x38, 0x71, 0xcb, 0xb4}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x46, 0xdb, 0x72, 0x6d, 0x7b, 0xff, 0x1c, 0xa1, 0xe4, 0xcf, - 0x93, 0x9d, 0x28, 0xec, 0x2e, 0x11, 0x96, 0x19, 0x24, 0x7c, - 0x8a, 0x70, 0xfd, 0x24, 0x75, 0x16, 0x38, 0xed, 0x5}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc4, 0xe, 0xf, 0xfc, 0xbd, 0x61, 0xa8, 0x2a, 0xef, 0x3c, - 0xe2, 0x4d, 0x28, 0xe4, 0x27, 0xb7, 0x48, 0xdf, 0x39, 0xa5, - 0xdc, 0x6, 0xe5, 0x52, 0x9e, 0x97, 0xd1, 0x6e, 0x97, 0xf8}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25578, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3665, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14161 [("\242\138%q\US\GSY\176\129}=\247",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\STX\132g\171\169\132\132\181\237\223\182gx,",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("g\EMP\174+`\222\SUBP",SubOptions {_retainHandling = +// SubscribeRequest 23603 [("\197\163\195D\141\173\234\249,\160]\180\nZ\t\FS\244Iu\131s[\184\\",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\182\253\219\136*\159\139\DC1\249\240$r\252\233",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\219\DC4\184\&5M\153\135\234\188\ENQ\184",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\218\185}\160^\f\252\130\170}\"u\132m\185\FS\250\157-\169o\DC4",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("b\255\135\184;\253\174\185R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\236:H\144\155\245+7\DLE\145K>\160Hi\229",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS0}),("\128\158`\237A\207\227\151P\STX\248\177\n\202\STX\130N\183\169\198^",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\207\255b\143\CAN\FS\140\203!\SYN<\138\131V\187.Y\252\186\253\DC1\150",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\191h",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("PsYa\175\245B\255\RS\136\128\GS\201\201wA\\\198\&3tES\184+\244\&5\SYN5",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\224\CAN\160\211\DLE",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0x4d, 0x37, 0x51, 0x0, 0xc, 0xf2, 0x8a, 0x25, 0x71, 0x1f, 0x1d, 0x59, 0xb0, 0x81, 0x7d, - 0x3d, 0xf7, 0x1, 0x0, 0xe, 0x2, 0x84, 0x67, 0xab, 0xa9, 0x84, 0x84, 0xb5, 0xed, 0xdf, 0xb6, - 0x67, 0x78, 0x2c, 0x0, 0x0, 0x9, 0x67, 0x19, 0x50, 0xae, 0x2b, 0x60, 0xde, 0x1a, 0x50, 0x0, - 0x0, 0x9, 0x62, 0xff, 0x87, 0xb8, 0x3b, 0xfd, 0xae, 0xb9, 0x52, 0x2, 0x0, 0x10, 0xec, 0x3a, - 0x48, 0x90, 0x9b, 0xf5, 0x2b, 0x37, 0x10, 0x91, 0x4b, 0x3e, 0xa0, 0x48, 0x69, 0xe5, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xf2, 0x8a, 0x25, 0x71, 0x1f, 0x1d, 0x59, 0xb0, 0x81, 0x7d, 0x3d, 0xf7}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x5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wmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xc5, 0xa3, 0xc3, 0x44, 0x8d, 0xad, 0xea, 0xf9, 0x2c, 0xa0, 0x5d, 0xb4, + 0xa, 0x5a, 0x9, 0x1c, 0xf4, 0x49, 0x75, 0x83, 0x73, 0x5b, 0xb8, 0x5c}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2, 0x84, 0x67, 0xab, 0xa9, 0x84, 0x84, 0xb5, 0xed, 0xdf, 0xb6, 0x67, 0x78, 0x2c}; + uint8_t topic_filter_s1_bytes[] = {0xb6, 0xfd, 0xdb, 0x88, 0x2a, 0x9f, 0x8b, + 0x11, 0xf9, 0xf0, 0x24, 0x72, 0xfc, 0xe9}; lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x67, 0x19, 0x50, 0xae, 0x2b, 0x60, 0xde, 0x1a, 0x50}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xdb, 0x14, 0xb8, 0x35, 0x4d, 0x99, 0x87, 0xea, 0xbc, 0x5, 0xb8}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x62, 0xff, 0x87, 0xb8, 0x3b, 0xfd, 0xae, 0xb9, 0x52}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xda, 0xb9, 0x7d, 0xa0, 0x5e, 0xc, 0xfc, 0x82, 0xaa, 0x7d, 0x22, + 0x75, 0x84, 0x6d, 0xb9, 0x1c, 0xfa, 0x9d, 0x2d, 0xa9, 0x6f, 0x14}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xec, 0x3a, 0x48, 0x90, 0x9b, 0xf5, 0x2b, 0x37, - 0x10, 0x91, 0x4b, 0x3e, 0xa0, 0x48, 0x69, 0xe5}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x80, 0x9e, 0x60, 0xed, 0x41, 0xcf, 0xe3, 0x97, 0x50, 0x2, 0xf8, + 0xb1, 0xa, 0xca, 0x2, 0x82, 0x4e, 0xb7, 0xa9, 0xc6, 0x5e}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t topic_filter_s5_bytes[] = {0xcf, 0xff, 0x62, 0x8f, 0x18, 0x1c, 0x8c, 0xcb, 0x21, 0x16, 0x3c, + 0x8a, 0x83, 0x56, 0xbb, 0x2e, 0x59, 0xfc, 0xba, 0xfd, 0x11, 0x96}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xbf, 0x68}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x50, 0x73, 0x59, 0x61, 0xaf, 0xf5, 0x42, 0xff, 0x1e, 0x88, + 0x80, 0x1d, 0xc9, 0xc9, 0x77, 0x41, 0x5c, 0xc6, 0x33, 0x74, + 0x45, 0x53, 0xb8, 0x2b, 0xf4, 0x35, 0x16, 0x35}; + lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe0, 0x18, 0xa0, 0xd3, 0x10}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0}; + lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14161, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23603, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3024 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("\151\241\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("O\234$\nG\215\255\&2\ETB\153\&8\213\230\161zr\149C\SOH",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(".\ETB\199\SYN\173\&1M\183\r\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\RSe\157a\193\189\&8%\189\238lr\136\251\194l\\\219ii",SubOptions +// SubscribeRequest 26458 [("\183`M\228xY\249D",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\237\157\196\228p\189\168\211",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\255\152\155\238\160\241#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\221\172",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\212\176\130\245\147\226D\DC1\170\164\SOH\210`>\241\244\135\149\243\210\198#\166\227\243\195\ACK",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\n\222\134\168\193\203",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS1})] [] +// QoS0}),("S/\168!^A\129\141\161\212\235\177",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\160\228\STX\163#\156\211",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\131(\196qI\152p\148\234\235i\148\219\186\139A\137\SI\188\207\164\132%.\135G_\229\211\254",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x4e, 0xb, 0xd0, 0x0, 0x0, 0x1, 0x0, 0x3, 0x97, 0xf1, 0xd9, 0x1, 0x0, 0x13, 0x4f, - 0xea, 0x24, 0xa, 0x47, 0xd7, 0xff, 0x32, 0x17, 0x99, 0x38, 0xd5, 0xe6, 0xa1, 0x7a, 0x72, 0x95, - 0x43, 0x1, 0x0, 0x0, 0xa, 0x2e, 0x17, 0xc7, 0x16, 0xad, 0x31, 0x4d, 0xb7, 0xd, 0xe8, 0x1, - 0x0, 0x14, 0x1e, 0x65, 0x9d, 0x61, 0xc1, 0xbd, 0x38, 0x25, 0xbd, 0xee, 0x6c, 0x72, 0x88, 0xfb, - 0xc2, 0x6c, 0x5c, 0xdb, 0x69, 0x69, 0x0, 0x0, 0x6, 0xa, 0xde, 0x86, 0xa8, 0xc1, 0xcb, 0x1}; + uint8_t pkt[] = {0x82, 0x7f, 0x67, 0x5a, 0x0, 0x8, 0xb7, 0x60, 0x4d, 0xe4, 0x78, 0x59, 0xf9, 0x44, 0x1, 0x0, 0x8, + 0xed, 0x9d, 0xc4, 0xe4, 0x70, 0xbd, 0xa8, 0xd3, 0x1, 0x0, 0x7, 0xff, 0x98, 0x9b, 0xee, 0xa0, 0xf1, + 0x23, 0x1, 0x0, 0x2, 0xdd, 0xac, 0x1, 0x0, 0x1b, 0xd4, 0xb0, 0x82, 0xf5, 0x93, 0xe2, 0x44, 0x11, + 0xaa, 0xa4, 0x1, 0xd2, 0x60, 0x3e, 0xf1, 0xf4, 0x87, 0x95, 0xf3, 0xd2, 0xc6, 0x23, 0xa6, 0xe3, 0xf3, + 0xc3, 0x6, 0x0, 0x0, 0xc, 0x53, 0x2f, 0xa8, 0x21, 0x5e, 0x41, 0x81, 0x8d, 0xa1, 0xd4, 0xeb, 0xb1, + 0x1, 0x0, 0x7, 0xa0, 0xe4, 0x2, 0xa3, 0x23, 0x9c, 0xd3, 0x0, 0x0, 0x1e, 0x83, 0x28, 0xc4, 0x71, + 0x49, 0x98, 0x70, 0x94, 0xea, 0xeb, 0x69, 0x94, 0xdb, 0xba, 0x8b, 0x41, 0x89, 0xf, 0xbc, 0xcf, 0xa4, + 0x84, 0x25, 0x2e, 0x87, 0x47, 0x5f, 0xe5, 0xd3, 0xfe, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xb7, 0x60, 0x4d, 0xe4, 0x78, 0x59, 0xf9, 0x44}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x97, 0xf1, 0xd9}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xed, 0x9d, 0xc4, 0xe4, 0x70, 0xbd, 0xa8, 0xd3}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4f, 0xea, 0x24, 0xa, 0x47, 0xd7, 0xff, 0x32, 0x17, 0x99, - 0x38, 0xd5, 0xe6, 0xa1, 0x7a, 0x72, 0x95, 0x43, 0x1}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xff, 0x98, 0x9b, 0xee, 0xa0, 0xf1, 0x23}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2e, 0x17, 0xc7, 0x16, 0xad, 0x31, 0x4d, 0xb7, 0xd, 0xe8}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xdd, 0xac}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x1e, 0x65, 0x9d, 0x61, 0xc1, 0xbd, 0x38, 0x25, 0xbd, 0xee, - 0x6c, 0x72, 0x88, 0xfb, 0xc2, 0x6c, 0x5c, 0xdb, 0x69, 0x69}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd4, 0xb0, 0x82, 0xf5, 0x93, 0xe2, 0x44, 0x11, 0xaa, 0xa4, 0x1, 0xd2, 0x60, 0x3e, + 0xf1, 0xf4, 0x87, 0x95, 0xf3, 0xd2, 0xc6, 0x23, 0xa6, 0xe3, 0xf3, 0xc3, 0x6}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa, 0xde, 0x86, 0xa8, 0xc1, 0xcb}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x53, 0x2f, 0xa8, 0x21, 0x5e, 0x41, 0x81, 0x8d, 0xa1, 0xd4, 0xeb, 0xb1}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; + uint8_t topic_filter_s6_bytes[] = {0xa0, 0xe4, 0x2, 0xa3, 0x23, 0x9c, 0xd3}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x83, 0x28, 0xc4, 0x71, 0x49, 0x98, 0x70, 0x94, 0xea, 0xeb, + 0x69, 0x94, 0xdb, 0xba, 0x8b, 0x41, 0x89, 0xf, 0xbc, 0xcf, + 0xa4, 0x84, 0x25, 0x2e, 0x87, 0x47, 0x5f, 0xe5, 0xd3, 0xfe}; + lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3024, 6, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26458, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9912 [("\204\190\NUL\161\131\ETB\243~\129\US,\199",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DC1\203\202\209\&0T*Orh\223",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 4488 [("y\134]",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2}),("M\251\156z\tw\201\201\201\b\244\145\253\166",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\207h\177E\207\162\163\233\143",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\CAN\241\ENQ/\"M\212\227\&2\237\164<\230\204\237\206eX\208\194\&7.",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\234\233uo\245\154\131\&5#\223~@\NAKY\140\175\191\179\141\129\166)\188k",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\233:\215\250\&2\131\227\DLE^\175J",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0x1f, 0x26, 0xb8, 0x0, 0xc, 0xcc, 0xbe, 0x0, 0xa1, 0x83, 0x17, 0xf3, 0x7e, 0x81, 0x1f, 0x2c, - 0xc7, 0x2, 0x0, 0xb, 0x11, 0xcb, 0xca, 0xd1, 0x30, 0x54, 0x2a, 0x4f, 0x72, 0x68, 0xdf, 0x1}; + uint8_t pkt[] = {0x82, 0x67, 0x11, 0x88, 0x0, 0x3, 0x79, 0x86, 0x5d, 0x2, 0x0, 0xe, 0x4d, 0xfb, 0x9c, + 0x7a, 0x9, 0x77, 0xc9, 0xc9, 0xc9, 0x8, 0xf4, 0x91, 0xfd, 0xa6, 0x0, 0x0, 0x9, 0xcf, + 0x68, 0xb1, 0x45, 0xcf, 0xa2, 0xa3, 0xe9, 0x8f, 0x0, 0x0, 0x16, 0x18, 0xf1, 0x5, 0x2f, + 0x22, 0x4d, 0xd4, 0xe3, 0x32, 0xed, 0xa4, 0x3c, 0xe6, 0xcc, 0xed, 0xce, 0x65, 0x58, 0xd0, + 0xc2, 0x37, 0x2e, 0x1, 0x0, 0x18, 0xea, 0xe9, 0x75, 0x6f, 0xf5, 0x9a, 0x83, 0x35, 0x23, + 0xdf, 0x7e, 0x40, 0x15, 0x59, 0x8c, 0xaf, 0xbf, 0xb3, 0x8d, 0x81, 0xa6, 0x29, 0xbc, 0x6b, + 0x0, 0x0, 0xb, 0xe9, 0x3a, 0xd7, 0xfa, 0x32, 0x83, 0xe3, 0x10, 0x5e, 0xaf, 0x4a, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xcc, 0xbe, 0x0, 0xa1, 0x83, 0x17, 0xf3, 0x7e, 0x81, 0x1f, 0x2c, 0xc7}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x79, 0x86, 0x5d}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x11, 0xcb, 0xca, 0xd1, 0x30, 0x54, 0x2a, 0x4f, 0x72, 0x68, 0xdf}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4d, 0xfb, 0x9c, 0x7a, 0x9, 0x77, 0xc9, 0xc9, 0xc9, 0x8, 0xf4, 0x91, 0xfd, 0xa6}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1}; + uint8_t topic_filter_s2_bytes[] = {0xcf, 0x68, 0xb1, 0x45, 0xcf, 0xa2, 0xa3, 0xe9, 0x8f}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x18, 0xf1, 0x5, 0x2f, 0x22, 0x4d, 0xd4, 0xe3, 0x32, 0xed, 0xa4, + 0x3c, 0xe6, 0xcc, 0xed, 0xce, 0x65, 0x58, 0xd0, 0xc2, 0x37, 0x2e}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xea, 0xe9, 0x75, 0x6f, 0xf5, 0x9a, 0x83, 0x35, 0x23, 0xdf, 0x7e, 0x40, + 0x15, 0x59, 0x8c, 0xaf, 0xbf, 0xb3, 0x8d, 0x81, 0xa6, 0x29, 0xbc, 0x6b}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe9, 0x3a, 0xd7, 0xfa, 0x32, 0x83, 0xe3, 0x10, 0x5e, 0xaf, 0x4a}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9912, 2, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4488, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 1301 [("\169n\168\166N\214\SUB\136\156\134\ETX\228",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\135#\130r\206\254\133s<\ACK\143\200\154\229\227\169\217\244'",SubOptions {_retainHandling = +// SubscribeRequest 28692 +// [("a^z\164{\209P\192\235d\163\187\135\198\205\238\DC4\185h\146\199\197\&9\223\220\253",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\fBj\fR\208\210\189\190\148\STX\164}\163\214\183[\143",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("k\172\154\253f\170\&7\CANjg\185\r\ESC\192\ENQQi}\209\SI",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\239\236Y\220\224\191\&6",SubOptions +// QoS2}),("]\163\DC3\140]\129\245\224\164\163S",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("\171\&1\208\132\SI\194\193m\ACK\203\239\SIx\ENQ\218\160O|1\235Y:\184\174",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\176\STX\244\239\208df\183(B\197x;\189\224\232 Y\218\155f\135\149v\249d\245\FS\208L",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\SIw*X&\ty\181\188:}\219,}\247\219>\NAK\167\177j0\188\197L\232@EJ",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\ACK2c\237\191\199*",SubOptions +// QoS2}),("\n#\223\137\184\136\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS1}),("`\RS8\b\137\129\FS#\SO\234\SYN\192\217\144A'\216\235\227\226\ai\205\207}c",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\206Cz\139\148\189dN%",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\141=\196\133f1r\DELf#h\161,8\131",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS0}),("V\224\171\163j",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0xa5, 0x1, 0x5, 0x15, 0x0, 0xc, 0xa9, 0x6e, 0xa8, 0xa6, 0x4e, 0xd6, 0x1a, 0x88, 0x9c, 0x86, - 0x3, 0xe4, 0x2, 0x0, 0x13, 0x87, 0x23, 0x82, 0x72, 0xce, 0xfe, 0x85, 0x73, 0x3c, 0x6, 0x8f, 0xc8, - 0x9a, 0xe5, 0xe3, 0xa9, 0xd9, 0xf4, 0x27, 0x2, 0x0, 0x12, 0xc, 0x42, 0x6a, 0xc, 0x52, 0xd0, 0xd2, - 0xbd, 0xbe, 0x94, 0x2, 0xa4, 0x7d, 0xa3, 0xd6, 0xb7, 0x5b, 0x8f, 0x2, 0x0, 0x14, 0x6b, 0xac, 0x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x64, 0x66, 0xb7, 0x28, 0x42, 0xc5, 0x78, 0x3b, 0xbd, 0xe0, 0xe8, 0x20, 0x59, 0xda, + 0x9b, 0x66, 0x87, 0x95, 0x76, 0xf9, 0x64, 0xf5, 0x1c, 0xd0, 0x4c, 0x2, 0x0, 0x7, 0xa, 0x23, + 0xdf, 0x89, 0xb8, 0x88, 0xe1, 0x1, 0x0, 0x1a, 0x60, 0x1e, 0x38, 0x8, 0x89, 0x81, 0x1c, 0x23, + 0xe, 0xea, 0x16, 0xc0, 0xd9, 0x90, 0x41, 0x27, 0xd8, 0xeb, 0xe3, 0xe2, 0x7, 0x69, 0xcd, 0xcf, + 0x7d, 0x63, 0x0, 0x0, 0x5, 0x56, 0xe0, 0xab, 0xa3, 0x6a, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xa9, 0x6e, 0xa8, 0xa6, 0x4e, 0xd6, 0x1a, 0x88, 0x9c, 0x86, 0x3, 0xe4}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x61, 0x5e, 0x7a, 0xa4, 0x7b, 0xd1, 0x50, 0xc0, 0xeb, 0x64, 0xa3, 0xbb, 0x87, + 0xc6, 0xcd, 0xee, 0x14, 0xb9, 0x68, 0x92, 0xc7, 0xc5, 0x39, 0xdf, 0xdc, 0xfd}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x87, 0x23, 0x82, 0x72, 0xce, 0xfe, 0x85, 0x73, 0x3c, 0x6, - 0x8f, 0xc8, 0x9a, 0xe5, 0xe3, 0xa9, 0xd9, 0xf4, 0x27}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5d, 0xa3, 0x13, 0x8c, 0x5d, 0x81, 0xf5, 0xe0, 0xa4, 0xa3, 0x53}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc, 0x42, 0x6a, 0xc, 0x52, 0xd0, 0xd2, 0xbd, 0xbe, - 0x94, 0x2, 0xa4, 0x7d, 0xa3, 0xd6, 0xb7, 0x5b, 0x8f}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xab, 0x31, 0xd0, 0x84, 0xf, 0xc2, 0xc1, 0x6d, 0x6, 0xcb, 0xef, 0xf, + 0x78, 0x5, 0xda, 0xa0, 0x4f, 0x7c, 0x31, 0xeb, 0x59, 0x3a, 0xb8, 0xae}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6b, 0xac, 0x9a, 0xfd, 0x66, 0xaa, 0x37, 0x18, 0x6a, 0x67, - 0xb9, 0xd, 0x1b, 0xc0, 0x5, 0x51, 0x69, 0x7d, 0xd1, 0xf}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xb0, 0x2, 0xf4, 0xef, 0xd0, 0x64, 0x66, 0xb7, 0x28, 0x42, + 0xc5, 0x78, 0x3b, 0xbd, 0xe0, 0xe8, 0x20, 0x59, 0xda, 0x9b, + 0x66, 0x87, 0x95, 0x76, 0xf9, 0x64, 0xf5, 0x1c, 0xd0, 0x4c}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xef, 0xec, 0x59, 0xdc, 0xe0, 0xbf, 0x36}; + uint8_t topic_filter_s4_bytes[] = {0xa, 0x23, 0xdf, 0x89, 0xb8, 0x88, 0xe1}; lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf, 0x77, 0x2a, 0x58, 0x26, 0x9, 0x79, 0xb5, 0xbc, 0x3a, - 0x7d, 0xdb, 0x2c, 0x7d, 0xf7, 0xdb, 0x3e, 0x15, 0xa7, 0xb1, - 0x6a, 0x30, 0xbc, 0xc5, 0x4c, 0xe8, 0x40, 0x45, 0x4a}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x60, 0x1e, 0x38, 0x8, 0x89, 0x81, 0x1c, 0x23, 0xe, 0xea, 0x16, 0xc0, 0xd9, + 0x90, 0x41, 0x27, 0xd8, 0xeb, 0xe3, 0xe2, 0x7, 0x69, 0xcd, 0xcf, 0x7d, 0x63}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6, 0x32, 0x63, 0xed, 0xbf, 0xc7, 0x2a}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x56, 0xe0, 0xab, 0xa3, 0x6a}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xce, 0x43, 0x7a, 0x8b, 0x94, 0xbd, 0x64, 0x4e, 0x25}; - lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x8d, 0x3d, 0xc4, 0x85, 0x66, 0x31, 0x72, 0x7f, - 0x66, 0x23, 0x68, 0xa1, 0x2c, 0x38, 0x83}; - lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1301, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28692, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8636 [("\145uzU$\EOTvLk\130\217\133\&5f:\185\180q\t\227B\204\209^",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\185\215\&3\186z",SubOptions +// SubscribeRequest 11607 [("\200P\177\221",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("A\173\ETX\f\226l\DELM\233\194ndO4\248\238\130\173\224\214",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("5\240\228\136\145<\174p",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS1}),("\"\254g\248Z\ENQ\150\248I.\136:B\b\221BoA",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\155\131g\SOH\199\215Z\164\242\159",SubOptions +// QoS0}),("\246\222N\189z",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("\216\NAKQ\172\ACK\138\167\168\&5&",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SYN\130\197\169\254\\\180\144\164g\158k",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("M\225pW\t\184D\fV\167\186\130\231o\189t\217\233\152\213I@\r\150\142c",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS0}),("\NUL\214a\170\SOH\192\ETX\136M\252\SOH\238q\183\ETX\172\138\213$]\154J\166\142\232R",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Mu-|\132\218\214j\253",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = +// QoS0}),("\240\161\131\US\213\DC1\239\222\n\133\218\180j\176p\215\204s\138t\154N\163!\227y(\233l\166",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\237\136f\131sp\148i\158+cYt\ESC;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0x6f, 0x21, 0xbc, 0x0, 0x18, 0x91, 0x75, 0x7a, 0x55, 0x24, 0x4, 0x76, 0x4c, 0x6b, 0x82, 0xd9, - 0x85, 0x35, 0x66, 0x3a, 0xb9, 0xb4, 0x71, 0x9, 0xe3, 0x42, 0xcc, 0xd1, 0x5e, 0x1, 0x0, 0x5, 0xb9, - 0xd7, 0x33, 0xba, 0x7a, 0x0, 0x0, 0x8, 0x35, 0xf0, 0xe4, 0x88, 0x91, 0x3c, 0xae, 0x70, 0x1, 0x0, - 0x12, 0x22, 0xfe, 0x67, 0xf8, 0x5a, 0x5, 0x96, 0xf8, 0x49, 0x2e, 0x88, 0x3a, 0x42, 0x8, 0xdd, 0x42, - 0x6f, 0x41, 0x2, 0x0, 0xa, 0x9b, 0x83, 0x67, 0x1, 0xc7, 0xd7, 0x5a, 0xa4, 0xf2, 0x9f, 0x2, 0x0, - 0x1a, 0x4d, 0xe1, 0x70, 0x57, 0x9, 0xb8, 0x44, 0xc, 0x56, 0xa7, 0xba, 0x82, 0xe7, 0x6f, 0xbd, 0x74, - 0xd9, 0xe9, 0x98, 0xd5, 0x49, 0x40, 0xd, 0x96, 0x8e, 0x63, 0x2}; + uint8_t pkt[] = {0x82, 0xa0, 0x1, 0x2d, 0x57, 0x0, 0x4, 0xc8, 0x50, 0xb1, 0xdd, 0x2, 0x0, 0x14, 0x41, 0xad, 0x3, + 0xc, 0xe2, 0x6c, 0x7f, 0x4d, 0xe9, 0xc2, 0x6e, 0x64, 0x4f, 0x34, 0xf8, 0xee, 0x82, 0xad, 0xe0, 0xd6, + 0x0, 0x0, 0x5, 0xf6, 0xde, 0x4e, 0xbd, 0x7a, 0x2, 0x0, 0xa, 0xd8, 0x15, 0x51, 0xac, 0x6, 0x8a, + 0xa7, 0xa8, 0x35, 0x26, 0x1, 0x0, 0xc, 0x16, 0x82, 0xc5, 0xa9, 0xfe, 0x5c, 0xb4, 0x90, 0xa4, 0x67, + 0x9e, 0x6b, 0x0, 0x0, 0x1a, 0x0, 0xd6, 0x61, 0xaa, 0x1, 0xc0, 0x3, 0x88, 0x4d, 0xfc, 0x1, 0xee, + 0x71, 0xb7, 0x3, 0xac, 0x8a, 0xd5, 0x24, 0x5d, 0x9a, 0x4a, 0xa6, 0x8e, 0xe8, 0x52, 0x2, 0x0, 0x9, + 0x4d, 0x75, 0x2d, 0x7c, 0x84, 0xda, 0xd6, 0x6a, 0xfd, 0x0, 0x0, 0x1e, 0xf0, 0xa1, 0x83, 0x1f, 0xd5, + 0x11, 0xef, 0xde, 0xa, 0x85, 0xda, 0xb4, 0x6a, 0xb0, 0x70, 0xd7, 0xcc, 0x73, 0x8a, 0x74, 0x9a, 0x4e, + 0xa3, 0x21, 0xe3, 0x79, 0x28, 0xe9, 0x6c, 0xa6, 0x0, 0x0, 0xf, 0xed, 0x88, 0x66, 0x83, 0x73, 0x70, + 0x94, 0x69, 0x9e, 0x2b, 0x63, 0x59, 0x74, 0x1b, 0x3b, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x91, 0x75, 0x7a, 0x55, 0x24, 0x4, 0x76, 0x4c, 0x6b, 0x82, 0xd9, 0x85, - 0x35, 0x66, 0x3a, 0xb9, 0xb4, 0x71, 0x9, 0xe3, 0x42, 0xcc, 0xd1, 0x5e}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xc8, 0x50, 0xb1, 0xdd}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb9, 0xd7, 0x33, 0xba, 0x7a}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x41, 0xad, 0x3, 0xc, 0xe2, 0x6c, 0x7f, 0x4d, 0xe9, 0xc2, + 0x6e, 0x64, 0x4f, 0x34, 0xf8, 0xee, 0x82, 0xad, 0xe0, 0xd6}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x35, 0xf0, 0xe4, 0x88, 0x91, 0x3c, 0xae, 0x70}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf6, 0xde, 0x4e, 0xbd, 0x7a}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x22, 0xfe, 0x67, 0xf8, 0x5a, 0x5, 0x96, 0xf8, 0x49, - 0x2e, 0x88, 0x3a, 0x42, 0x8, 0xdd, 0x42, 0x6f, 0x41}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd8, 0x15, 0x51, 0xac, 0x6, 0x8a, 0xa7, 0xa8, 0x35, 0x26}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9b, 0x83, 0x67, 0x1, 0xc7, 0xd7, 0x5a, 0xa4, 0xf2, 0x9f}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x16, 0x82, 0xc5, 0xa9, 0xfe, 0x5c, 0xb4, 0x90, 0xa4, 0x67, 0x9e, 0x6b}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4d, 0xe1, 0x70, 0x57, 0x9, 0xb8, 0x44, 0xc, 0x56, 0xa7, 0xba, 0x82, 0xe7, - 0x6f, 0xbd, 0x74, 0xd9, 0xe9, 0x98, 0xd5, 0x49, 0x40, 0xd, 0x96, 0x8e, 0x63}; + uint8_t topic_filter_s5_bytes[] = {0x0, 0xd6, 0x61, 0xaa, 0x1, 0xc0, 0x3, 0x88, 0x4d, 0xfc, 0x1, 0xee, 0x71, + 0xb7, 0x3, 0xac, 0x8a, 0xd5, 0x24, 0x5d, 0x9a, 0x4a, 0xa6, 0x8e, 0xe8, 0x52}; lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; + uint8_t topic_filter_s6_bytes[] = {0x4d, 0x75, 0x2d, 0x7c, 0x84, 0xda, 0xd6, 0x6a, 0xfd}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf0, 0xa1, 0x83, 0x1f, 0xd5, 0x11, 0xef, 0xde, 0xa, 0x85, + 0xda, 0xb4, 0x6a, 0xb0, 0x70, 0xd7, 0xcc, 0x73, 0x8a, 0x74, + 0x9a, 0x4e, 0xa3, 0x21, 0xe3, 0x79, 0x28, 0xe9, 0x6c, 0xa6}; + lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xed, 0x88, 0x66, 0x83, 0x73, 0x70, 0x94, 0x69, + 0x9e, 0x2b, 0x63, 0x59, 0x74, 0x1b, 0x3b}; + lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8636, 6, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11607, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23343 [("\b\226\228",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),(",6p\US\ESC\233\166\168\SOb@\"\155\182\DEL\213\251\214/\233\209nSD\174Y\147\191",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("[1\251\168#\EOT\140\140\&0)\DC2\159\134\188aM\201\255y\207\149\DLE",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\189D\246\ETB\165\134\238\174\175E\220\240%\190\163\232>\190\rDH\156\&3\182\RS\240\&5w\200",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 22426 [("\FS\227\218",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x60, 0x5b, 0x2f, 0x0, 0x3, 0x8, 0xe2, 0xe4, 0x0, 0x0, 0x1c, 0x2c, 0x36, 0x70, 0x1f, 0x1b, - 0xe9, 0xa6, 0xa8, 0xe, 0x62, 0x40, 0x22, 0x9b, 0xb6, 0x7f, 0xd5, 0xfb, 0xd6, 0x2f, 0xe9, 0xd1, 0x6e, - 0x53, 0x44, 0xae, 0x59, 0x93, 0xbf, 0x1, 0x0, 0x16, 0x5b, 0x31, 0xfb, 0xa8, 0x23, 0x4, 0x8c, 0x8c, - 0x30, 0x29, 0x12, 0x9f, 0x86, 0xbc, 0x61, 0x4d, 0xc9, 0xff, 0x79, 0xcf, 0x95, 0x10, 0x0, 0x0, 0x1d, - 0xbd, 0x44, 0xf6, 0x17, 0xa5, 0x86, 0xee, 0xae, 0xaf, 0x45, 0xdc, 0xf0, 0x25, 0xbe, 0xa3, 0xe8, 0x3e, - 0xbe, 0xd, 0x44, 0x48, 0x9c, 0x33, 0xb6, 0x1e, 0xf0, 0x35, 0x77, 0xc8, 0x2}; + uint8_t pkt[] = {0x82, 0x8, 0x57, 0x9a, 0x0, 0x3, 0x1c, 0xe3, 0xda, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x8, 0xe2, 0xe4}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x1c, 0xe3, 0xda}; lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2c, 0x36, 0x70, 0x1f, 0x1b, 0xe9, 0xa6, 0xa8, 0xe, 0x62, - 0x40, 0x22, 0x9b, 0xb6, 0x7f, 0xd5, 0xfb, 0xd6, 0x2f, 0xe9, - 0xd1, 0x6e, 0x53, 0x44, 0xae, 0x59, 0x93, 0xbf}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5b, 0x31, 0xfb, 0xa8, 0x23, 0x4, 0x8c, 0x8c, 0x30, 0x29, 0x12, - 0x9f, 0x86, 0xbc, 0x61, 0x4d, 0xc9, 0xff, 0x79, 0xcf, 0x95, 0x10}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xbd, 0x44, 0xf6, 0x17, 0xa5, 0x86, 0xee, 0xae, 0xaf, 0x45, - 0xdc, 0xf0, 0x25, 0xbe, 0xa3, 0xe8, 0x3e, 0xbe, 0xd, 0x44, - 0x48, 0x9c, 0x33, 0xb6, 0x1e, 0xf0, 0x35, 0x77, 0xc8}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23343, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22426, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19824 [("\NUL\181VC\229\166\255j \b\FSg\134\253%\212u\175\246K)\203\142>\132\154`n",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("-e\131\&2\165",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("\229\164\170}\NUL6\248\\?V\138\161\245\251\178\192u$\205\204\GS\191",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\255\220\179G\GS\163\207k\"\197u@\218\v\133\aW\US\136\172j\231v",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("S\189\207H\v\DC4\186]k\202\252\ESC2\228w\158C|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropTopicAliasMaximum -// 5452,PropSharedSubscriptionAvailable 38,PropRequestResponseInformation 189,PropReasonString -// "\DC4q@\188r\ACKd\244\FSv\150\151\245CV!W\SYN",PropUserProperty -// "\242\151S\226\243\214\235\219\158\ACK\ESC|\184$\157\200\240\131\234\235V\RS~\r" "~O",PropReceiveMaximum -// 19316,PropTopicAlias 17157,PropSubscriptionIdentifier 14,PropAuthenticationData -// "\178\137\153\217c\148^\EM\205\&4)4^'\rf\197\SO\248\&3hg",PropTopicAlias 1176,PropRetainAvailable -// 247,PropSessionExpiryInterval 23735,PropSubscriptionIdentifier 27,PropSharedSubscriptionAvailable -// 222,PropResponseInformation -// "\157\ACK+\159\156\197\ETBF9\232A\DC1\204\220\192\ENQ\141\146\131x",PropSharedSubscriptionAvailable -// 76,PropWildcardSubscriptionAvailable 43,PropResponseInformation "F",PropSessionExpiryInterval -// 15558,PropServerReference "0\DLE\162S\233\166\166\249\239",PropServerKeepAlive 17064,PropUserProperty "\232\STX8E -// Fo\249" "\195(\130?\220\196\249\229\GSSB\209\GS-\DC3X\210\202\&2w5-RG\224\248\a\146\181\&6",PropRetainAvailable -// 104,PropAuthenticationMethod "\183\165d\217\185\182\246\ETB"] +// SubscribeRequest 7633 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2})] [PropReasonString +// "\155\148e\NUL\226\147\"\165\SOb\167\&5\a\163\145\131\145\a{7\255\&4\252\182",PropWillDelayInterval +// 24271,PropTopicAlias 3636] TEST(Subscribe5QCTest, Encode1) { - uint8_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, 0x53, 0x42, 0xd1, 0x1d, - 0x2d, 0x13, 0x58, 0xd2, 0xca, 0x32, 0x77, 0x35, 0x2d, 0x52, 0x47, 0xe0, 0xf8, 0x7, 0x92, 0xb5, 0x36, 0x25, 0x68, - 0x15, 0x0, 0x8, 0xb7, 0xa5, 0x64, 0xd9, 0xb9, 0xb6, 0xf6, 0x17, 0x0, 0x1c, 0x0, 0xb5, 0x56, 0x43, 0xe5, 0xa6, - 0xff, 0x6a, 0x20, 0x8, 0x1c, 0x67, 0x86, 0xfd, 0x25, 0xd4, 0x75, 0xaf, 0xf6, 0x4b, 0x29, 0xcb, 0x8e, 0x3e, 0x84, - 0x9a, 0x60, 0x6e, 0x2, 0x0, 0x5, 0x2d, 0x65, 0x83, 0x32, 0xa5, 0x0, 0x0, 0x16, 0xe5, 0xa4, 0xaa, 0x7d, 0x0, - 0x36, 0xf8, 0x5c, 0x3f, 0x56, 0x8a, 0xa1, 0xf5, 0xfb, 0xb2, 0xc0, 0x75, 0x24, 0xcd, 0xcc, 0x1d, 0xbf, 0x1, 0x0, - 0x17, 0xff, 0xdc, 0xb3, 0x47, 0x1d, 0xa3, 0xcf, 0x6b, 0x22, 0xc5, 0x75, 0x40, 0xda, 0xb, 0x85, 0x7, 0x57, 0x1f, - 0x88, 0xac, 0x6a, 0xe7, 0x76, 0x1, 0x0, 0x12, 0x53, 0xbd, 0xcf, 0x48, 0xb, 0x14, 0xba, 0x5d, 0x6b, 0xca, 0xfc, - 0x1b, 0x32, 0xe4, 0x77, 0x9e, 0x43, 0x7c, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x0, 0xb5, 0x56, 0x43, 0xe5, 0xa6, 0xff, 0x6a, 0x20, 0x8, - 0x1c, 0x67, 0x86, 0xfd, 0x25, 0xd4, 0x75, 0xaf, 0xf6, 0x4b, - 0x29, 0xcb, 0x8e, 0x3e, 0x84, 0x9a, 0x60, 0x6e}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = {0x82, 0x29, 0x1d, 0xd1, 0x23, 0x1f, 0x0, 0x18, 0x9b, 0x94, 0x65, 0x0, 0xe2, 0x93, 0x22, + 0xa5, 0xe, 0x62, 0xa7, 0x35, 0x7, 0xa3, 0x91, 0x83, 0x91, 0x7, 0x7b, 0x37, 0xff, 0x34, + 0xfc, 0xb6, 0x18, 0x0, 0x0, 0x5e, 0xcf, 0x23, 0xe, 0x34, 0x0, 0x0, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2d, 0x65, 0x83, 0x32, 0xa5}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe5, 0xa4, 0xaa, 0x7d, 0x0, 0x36, 0xf8, 0x5c, 0x3f, 0x56, 0x8a, - 0xa1, 0xf5, 0xfb, 0xb2, 0xc0, 0x75, 0x24, 0xcd, 0xcc, 0x1d, 0xbf}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xff, 0xdc, 0xb3, 0x47, 0x1d, 0xa3, 0xcf, 0x6b, 0x22, 0xc5, 0x75, 0x40, - 0xda, 0xb, 0x85, 0x7, 0x57, 0x1f, 0x88, 0xac, 0x6a, 0xe7, 0x76}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x53, 0xbd, 0xcf, 0x48, 0xb, 0x14, 0xba, 0x5d, 0x6b, - 0xca, 0xfc, 0x1b, 0x32, 0xe4, 0x77, 0x9e, 0x43, 0x7c}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x14, 0x71, 0x40, 0xbc, 0x72, 0x6, 0x64, 0xf4, 0x1c, - 0x76, 0x96, 0x97, 0xf5, 0x43, 0x56, 0x21, 0x57, 0x16}; - uint8_t bytesprops2[] = {0x7e, 0x4f}; - uint8_t bytesprops1[] = {0xf2, 0x97, 0x53, 0xe2, 0xf3, 0xd6, 0xeb, 0xdb, 0x9e, 0x6, 0x1b, 0x7c, - 0xb8, 0x24, 0x9d, 0xc8, 0xf0, 0x83, 0xea, 0xeb, 0x56, 0x1e, 0x7e, 0xd}; - uint8_t bytesprops3[] = {0xb2, 0x89, 0x99, 0xd9, 0x63, 0x94, 0x5e, 0x19, 0xcd, 0x34, 0x29, - 0x34, 0x5e, 0x27, 0xd, 0x66, 0xc5, 0xe, 0xf8, 0x33, 0x68, 0x67}; - uint8_t bytesprops4[] = {0x9d, 0x6, 0x2b, 0x9f, 0x9c, 0xc5, 0x17, 0x46, 0x39, 0xe8, - 0x41, 0x11, 0xcc, 0xdc, 0xc0, 0x5, 0x8d, 0x92, 0x83, 0x78}; - uint8_t bytesprops5[] = {0x46}; - uint8_t bytesprops6[] = {0x30, 0x10, 0xa2, 0x53, 0xe9, 0xa6, 0xa6, 0xf9, 0xef}; - uint8_t bytesprops8[] = {0xc3, 0x28, 0x82, 0x3f, 0xdc, 0xc4, 0xf9, 0xe5, 0x1d, 0x53, 0x42, 0xd1, 0x1d, 0x2d, 0x13, - 0x58, 0xd2, 0xca, 0x32, 0x77, 0x35, 0x2d, 0x52, 0x47, 0xe0, 0xf8, 0x7, 0x92, 0xb5, 0x36}; - uint8_t bytesprops7[] = {0xe8, 0x2, 0x38, 0x45, 0x20, 0x46, 0x6f, 0xf9}; - uint8_t bytesprops9[] = {0xb7, 0xa5, 0x64, 0xd9, 0xb9, 0xb6, 0xf6, 0x17}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0x9b, 0x94, 0x65, 0x0, 0xe2, 0x93, 0x22, 0xa5, 0xe, 0x62, 0xa7, 0x35, + 0x7, 0xa3, 0x91, 0x83, 0x91, 0x7, 0x7b, 0x37, 0xff, 0x34, 0xfc, 0xb6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5452}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops1}, .v = {2, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19316}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17157}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1176}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23735}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15558}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17064}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops7}, .v = {30, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24271}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3636}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19824, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7633, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12399 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\250L\239\233\150\180y\246\174\156:\150\247RB",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\130/\NAKA~\213\CAN\RS\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("XMwO\188j\180\242\145D7\132\192e\183\EM\166$\183\158|5",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\167\200\ESC\147B\160\157\186\DC14\244.w#\196\246\200\226\230\EM\179\181\SI",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\f\211U\184\143\231\221\ETXl\181&\ENQ\214*.O\GS\206b\SOFx\v\132\&7\159\151r\238,",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\220\EOT\131\&0{\147\167b\132#\244\188\SUB\r\145\DLE\DELzD\133",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\211\177\223!\136x\241+?\150\246\199V+!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("U0\204\242VJa\154\135yp\US\150\210\212xUN\172=\"\161\134\239\238&\153M",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\226\ETX\215\DC2\164\133_g\140\144\NULo",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [PropSubscriptionIdentifierAvailable 24,PropReasonString -// "\230(\209\254(K\bL\255\t",PropServerKeepAlive 13153,PropAuthenticationMethod -// "\188|\226\242\&7\139",PropWildcardSubscriptionAvailable 151,PropAssignedClientIdentifier -// "@c\151\tz!}\168\NAK\206\217U\213Y\162\ESC\134\DC4\226\178c*\133",PropResponseInformation -// "\188\209\172",PropRetainAvailable 82,PropMessageExpiryInterval 7345,PropRequestResponseInformation -// 217,PropMaximumQoS 33,PropResponseInformation "[\223A\248\238\249\139\SYN\245\134\192\219",PropReasonString -// "y\187\SYN\134\236\NULo\246\130us\134Y\151j\243]4h\188\207",PropWillDelayInterval 20738] +// SubscribeRequest 29762 [("J\239",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable 164,PropPayloadFormatIndicator +// 175,PropMessageExpiryInterval 7362,PropMaximumPacketSize 25435,PropMessageExpiryInterval 15479,PropServerReference +// "\FS\169\DC1\163\242\224",PropAssignedClientIdentifier "\SUB\154 k#\250t\128\242HQ\209$\173\SI",PropTopicAlias +// 7747,PropMessageExpiryInterval 3634,PropAuthenticationMethod +// "2vE\128\215\138rD\242\243\211\202\STX]\"!\238\159%\174\243",PropWildcardSubscriptionAvailable +// 141,PropTopicAliasMaximum 21116,PropSessionExpiryInterval 14836] TEST(Subscribe5QCTest, Encode2) { - uint8_t pkt[] = { - 0x82, 0xc3, 0x2, 0x30, 0x6f, 0x74, 0x29, 0x18, 0x1f, 0x0, 0xa, 0xe6, 0x28, 0xd1, 0xfe, 0x28, 0x4b, 0x8, 0x4c, - 0xff, 0x9, 0x13, 0x33, 0x61, 0x15, 0x0, 0x6, 0xbc, 0x7c, 0xe2, 0xf2, 0x37, 0x8b, 0x28, 0x97, 0x12, 0x0, 0x17, - 0x40, 0x63, 0x97, 0x9, 0x7a, 0x21, 0x7d, 0xa8, 0x15, 0xce, 0xd9, 0x55, 0xd5, 0x59, 0xa2, 0x1b, 0x86, 0x14, 0xe2, - 0xb2, 0x63, 0x2a, 0x85, 0x1a, 0x0, 0x3, 0xbc, 0xd1, 0xac, 0x25, 0x52, 0x2, 0x0, 0x0, 0x1c, 0xb1, 0x19, 0xd9, - 0x24, 0x21, 0x1a, 0x0, 0xc, 0x5b, 0xdf, 0x41, 0xf8, 0xee, 0xf9, 0x8b, 0x16, 0xf5, 0x86, 0xc0, 0xdb, 0x1f, 0x0, - 0x15, 0x79, 0xbb, 0x16, 0x86, 0xec, 0x0, 0x6f, 0xf6, 0x82, 0x75, 0x73, 0x86, 0x59, 0x97, 0x6a, 0xf3, 0x5d, 0x34, - 0x68, 0xbc, 0xcf, 0x18, 0x0, 0x0, 0x51, 0x2, 0x0, 0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d, 0x1, 0x0, 0xc, 0xe2, 0x3, 0xd7, 0x12, 0xa4, 0x85, 0x5f, 0x67, 0x8c, 0x90, - 0x0, 0x6f, 0x1}; + uint8_t pkt[] = {0x82, 0x60, 0x74, 0x42, 0x58, 0x2a, 0xa4, 0x1, 0xaf, 0x2, 0x0, 0x0, 0x1c, 0xc2, 0x27, 0x0, 0x0, + 0x63, 0x5b, 0x2, 0x0, 0x0, 0x3c, 0x77, 0x1c, 0x0, 0x6, 0x1c, 0xa9, 0x11, 0xa3, 0xf2, 0xe0, 0x12, + 0x0, 0xf, 0x1a, 0x9a, 0x20, 0x6b, 0x23, 0xfa, 0x74, 0x80, 0xf2, 0x48, 0x51, 0xd1, 0x24, 0xad, 0xf, + 0x23, 0x1e, 0x43, 0x2, 0x0, 0x0, 0xe, 0x32, 0x15, 0x0, 0x15, 0x32, 0x76, 0x45, 0x80, 0xd7, 0x8a, + 0x72, 0x44, 0xf2, 0xf3, 0xd3, 0xca, 0x2, 0x5d, 0x22, 0x21, 0xee, 0x9f, 0x25, 0xae, 0xf3, 0x28, 0x8d, + 0x22, 0x52, 0x7c, 0x11, 0x0, 0x0, 0x39, 0xf4, 0x0, 0x2, 0x4a, 0xef, 0x22}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x4a, 0xef}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfa, 0x4c, 0xef, 0xe9, 0x96, 0xb4, 0x79, 0xf6, - 0xae, 0x9c, 0x3a, 0x96, 0xf7, 0x52, 0x42}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x82, 0x2f, 0x15, 0x41, 0x7e, 0xd5, 0x18, 0x1e, 0xc5}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x58, 0x4d, 0x77, 0x4f, 0xbc, 0x6a, 0xb4, 0xf2, 0x91, 0x44, 0x37, - 0x84, 0xc0, 0x65, 0xb7, 0x19, 0xa6, 0x24, 0xb7, 0x9e, 0x7c, 0x35}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa7, 0xc8, 0x1b, 0x93, 0x42, 0xa0, 0x9d, 0xba, 0x11, 0x34, 0xf4, 0x2e, - 0x77, 0x23, 0xc4, 0xf6, 0xc8, 0xe2, 0xe6, 0x19, 0xb3, 0xb5, 0xf}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc, 0xd3, 0x55, 0xb8, 0x8f, 0xe7, 0xdd, 0x3, 0x6c, 0xb5, - 0x26, 0x5, 0xd6, 0x2a, 0x2e, 0x4f, 0x1d, 0xce, 0x62, 0xe, - 0x46, 0x78, 0xb, 0x84, 0x37, 0x9f, 0x97, 0x72, 0xee, 0x2c}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xdc, 0x4, 0x83, 0x30, 0x7b, 0x93, 0xa7, 0x62, 0x84, 0x23, - 0xf4, 0xbc, 0x1a, 0xd, 0x91, 0x10, 0x7f, 0x7a, 0x44, 0x85}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xd3, 0xb1, 0xdf, 0x21, 0x88, 0x78, 0xf1, 0x2b, - 0x3f, 0x96, 0xf6, 0xc7, 0x56, 0x2b, 0x21}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x55, 0x30, 0xcc, 0xf2, 0x56, 0x4a, 0x61, 0x9a, 0x87, 0x79, - 0x70, 0x1f, 0x96, 0xd2, 0xd4, 0x78, 0x55, 0x4e, 0xac, 0x3d, - 0x22, 0xa1, 0x86, 0xef, 0xee, 0x26, 0x99, 0x4d}; - lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe2, 0x3, 0xd7, 0x12, 0xa4, 0x85, 0x5f, 0x67, 0x8c, 0x90, 0x0, 0x6f}; - lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xe6, 0x28, 0xd1, 0xfe, 0x28, 0x4b, 0x8, 0x4c, 0xff, 0x9}; - uint8_t bytesprops1[] = {0xbc, 0x7c, 0xe2, 0xf2, 0x37, 0x8b}; - uint8_t bytesprops2[] = {0x40, 0x63, 0x97, 0x9, 0x7a, 0x21, 0x7d, 0xa8, 0x15, 0xce, 0xd9, 0x55, - 0xd5, 0x59, 0xa2, 0x1b, 0x86, 0x14, 0xe2, 0xb2, 0x63, 0x2a, 0x85}; - uint8_t bytesprops3[] = {0xbc, 0xd1, 0xac}; - uint8_t bytesprops4[] = {0x5b, 0xdf, 0x41, 0xf8, 0xee, 0xf9, 0x8b, 0x16, 0xf5, 0x86, 0xc0, 0xdb}; - uint8_t bytesprops5[] = {0x79, 0xbb, 0x16, 0x86, 0xec, 0x0, 0x6f, 0xf6, 0x82, 0x75, 0x73, - 0x86, 0x59, 0x97, 0x6a, 0xf3, 0x5d, 0x34, 0x68, 0xbc, 0xcf}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0x1c, 0xa9, 0x11, 0xa3, 0xf2, 0xe0}; + uint8_t bytesprops1[] = {0x1a, 0x9a, 0x20, 0x6b, 0x23, 0xfa, 0x74, 0x80, 0xf2, 0x48, 0x51, 0xd1, 0x24, 0xad, 0xf}; + uint8_t bytesprops2[] = {0x32, 0x76, 0x45, 0x80, 0xd7, 0x8a, 0x72, 0x44, 0xf2, 0xf3, 0xd3, + 0xca, 0x2, 0x5d, 0x22, 0x21, 0xee, 0x9f, 0x25, 0xae, 0xf3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13153}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7345}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20738}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7362}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25435}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15479}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7747}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3634}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21116}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14836}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12399, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29762, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23812 [("l\217\181\248\247R\218\132\148\US\247\151\130\255:P",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("B1X\194\172\224\"\188%\220\224\EM\208\234yj\214\&1I\202\199[\155",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("5)l@\241",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\169\t|)\195\169\b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("<\146&\226\RS\169\182\&62\t;\r\171K\170\204 x\140\&9V\245K(\SUB\SOe>\144\252",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\167\157\EOT\218\v\192%\143\217\155\202\224\246\137",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("n\153\194\225\207\165\197\160\213\NAK\182",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic -// "\NULU\197U\159\205\ETB@\162u^Q\249\141\203\129h\180\226}",PropAuthenticationData -// "2\231\134)D\GSUy\134=u\a;w\193e\164\152*\173",PropCorrelationData -// ".\214m\158\230:\201\138\179\ACK\211UZ\173\r",PropAuthenticationData "h\163<\v\140\ETB`\195k",PropReceiveMaximum -// 162,PropRequestProblemInformation 210] +// SubscribeRequest 30334 [("/\SUB\DC2:k\140\DC3\184\237\130\214-\204\144j\179\231\244\242tp@\RSZx\ENQX",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("T\210\128\148\230\144\147\&2&+N\138\198\129\156\149",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\a[}\129\251}\153\232\133",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\156\198\198\142\194\236T\189\228\175e\155\ETX\145\225\\:\SUB\131\221",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("D\174\175\216\224\ETB\193\170\214\231",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = False, _noLocal = True, _subQoS = QoS2}),("\207\193\224w'\248\246",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropSessionExpiryInterval +// 18702,PropReceiveMaximum 21620,PropSharedSubscriptionAvailable 214] TEST(Subscribe5QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0xd6, 0x1, 0x5d, 0x4, 0x51, 0x8, 0x0, 0x14, 0x0, 0x55, 0xc5, 0x55, 0x9f, 0xcd, 0x17, 0x40, - 0xa2, 0x75, 0x5e, 0x51, 0xf9, 0x8d, 0xcb, 0x81, 0x68, 0xb4, 0xe2, 0x7d, 0x16, 0x0, 0x14, 0x32, 0xe7, - 0x86, 0x29, 0x44, 0x1d, 0x55, 0x79, 0x86, 0x3d, 0x75, 0x7, 0x3b, 0x77, 0xc1, 0x65, 0xa4, 0x98, 0x2a, - 0xad, 0x9, 0x0, 0xf, 0x2e, 0xd6, 0x6d, 0x9e, 0xe6, 0x3a, 0xc9, 0x8a, 0xb3, 0x6, 0xd3, 0x55, 0x5a, - 0xad, 0xd, 0x16, 0x0, 0x9, 0x68, 0xa3, 0x3c, 0xb, 0x8c, 0x17, 0x60, 0xc3, 0x6b, 0x21, 0x0, 0xa2, - 0x17, 0xd2, 0x0, 0x10, 0x6c, 0xd9, 0xb5, 0xf8, 0xf7, 0x52, 0xda, 0x84, 0x94, 0x1f, 0xf7, 0x97, 0x82, - 0xff, 0x3a, 0x50, 0x0, 0x0, 0x17, 0x42, 0x31, 0x58, 0xc2, 0xac, 0xe0, 0x22, 0xbc, 0x25, 0xdc, 0xe0, - 0x19, 0xd0, 0xea, 0x79, 0x6a, 0xd6, 0x31, 0x49,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0x5c, 0x3a, 0x1a, + 0x83, 0xdd, 0x5, 0x0, 0xa, 0x44, 0xae, 0xaf, 0xd8, 0xe0, 0x17, 0xc1, 0xaa, 0xd6, 0xe7, 0x16, + 0x0, 0x7, 0xcf, 0xc1, 0xe0, 0x77, 0x27, 0xf8, 0xf6, 0x2c}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x6c, 0xd9, 0xb5, 0xf8, 0xf7, 0x52, 0xda, 0x84, - 0x94, 0x1f, 0xf7, 0x97, 0x82, 0xff, 0x3a, 0x50}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x2f, 0x1a, 0x12, 0x3a, 0x6b, 0x8c, 0x13, 0xb8, 0xed, 0x82, 0xd6, 0x2d, 0xcc, 0x90, + 0x6a, 0xb3, 0xe7, 0xf4, 0xf2, 0x74, 0x70, 0x40, 0x1e, 0x5a, 0x78, 0x5, 0x58}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x42, 0x31, 0x58, 0xc2, 0xac, 0xe0, 0x22, 0xbc, 0x25, 0xdc, 0xe0, 0x19, - 0xd0, 0xea, 0x79, 0x6a, 0xd6, 0x31, 0x49, 0xca, 0xc7, 0x5b, 0x9b}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x54, 0xd2, 0x80, 0x94, 0xe6, 0x90, 0x93, 0x32, + 0x26, 0x2b, 0x4e, 0x8a, 0xc6, 0x81, 0x9c, 0x95}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x35, 0x29, 0x6c, 0x40, 0xf1}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7, 0x5b, 0x7d, 0x81, 0xfb, 0x7d, 0x99, 0xe8, 0x85}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa9, 0x9, 0x7c, 0x29, 0xc3, 0xa9, 0x8}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9c, 0xc6, 0xc6, 0x8e, 0xc2, 0xec, 0x54, 0xbd, 0xe4, 0xaf, + 0x65, 0x9b, 0x3, 0x91, 0xe1, 0x5c, 0x3a, 0x1a, 0x83, 0xdd}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x44, 0xae, 0xaf, 0xd8, 0xe0, 0x17, 0xc1, 0xaa, 0xd6, 0xe7}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x3c, 0x92, 0x26, 0xe2, 0x1e, 0xa9, 0xb6, 0x36, 0x32, 0x9, - 0x3b, 0xd, 0xab, 0x4b, 0xaa, 0xcc, 0x20, 0x78, 0x8c, 0x39, - 0x56, 0xf5, 0x4b, 0x28, 0x1a, 0xe, 0x65, 0x3e, 0x90, 0xfc}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xcf, 0xc1, 0xe0, 0x77, 0x27, 0xf8, 0xf6}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa7, 0x9d, 0x4, 0xda, 0xb, 0xc0, 0x25, 0x8f, 0xd9, 0x9b, 0xca, 0xe0, 0xf6, 0x89}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6e, 0x99, 0xc2, 0xe1, 0xcf, 0xa5, 0xc5, 0xa0, 0xd5, 0x15, 0xb6}; - lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x0, 0x55, 0xc5, 0x55, 0x9f, 0xcd, 0x17, 0x40, 0xa2, 0x75, - 0x5e, 0x51, 0xf9, 0x8d, 0xcb, 0x81, 0x68, 0xb4, 0xe2, 0x7d}; - uint8_t bytesprops1[] = {0x32, 0xe7, 0x86, 0x29, 0x44, 0x1d, 0x55, 0x79, 0x86, 0x3d, - 0x75, 0x7, 0x3b, 0x77, 0xc1, 0x65, 0xa4, 0x98, 0x2a, 0xad}; - uint8_t bytesprops2[] = {0x2e, 0xd6, 0x6d, 0x9e, 0xe6, 0x3a, 0xc9, 0x8a, 0xb3, 0x6, 0xd3, 0x55, 0x5a, 0xad, 0xd}; - uint8_t bytesprops3[] = {0x68, 0xa3, 0x3c, 0xb, 0x8c, 0x17, 0x60, 0xc3, 0x6b}; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 162}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18702}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21620}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 214}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23812, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30334, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27610 [("\237%=A\255\167\&8",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [PropWillDelayInterval 15551,PropCorrelationData "",PropAuthenticationData -// "\134\SI)%\209\199\157u\176\vB\DLElV\164GC=\210",PropSharedSubscriptionAvailable 240,PropResponseTopic -// "\152C\212I\164)\165\208\&5\GSD\DLE\170\&6\192\139",PropAuthenticationMethod "p\139",PropContentType -// "^\195H\250\238\&1c\138",PropSharedSubscriptionAvailable 151,PropRetainAvailable 104,PropAuthenticationMethod -// "h\191\175/\174\245=\140\DC4",PropReceiveMaximum 20504,PropMaximumQoS 50,PropResponseTopic -// "H\132",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("@\181\178*D\211",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("5\138\164\236\175\v\154\215\DLE\DC1\250Z\168N\145\228\235C\186\rrf\247\243",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("o\235s\DC1p\179\196\&3\216n\ENQ",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS2})] [PropAuthenticationData +// "3\STX\146(\244\153@\186\251\SUBcG1\191\223Z\SUBh\221C\203>",PropServerKeepAlive 986,PropTopicAlias +// 9329,PropWillDelayInterval 3455,PropAssignedClientIdentifier +// "\211Rp\255\FS\FS\238\&6",PropWildcardSubscriptionAvailable 228,PropRequestResponseInformation +// 250,PropServerReference "",PropMessageExpiryInterval 13564,PropReceiveMaximum 10366,PropSubscriptionIdentifier +// 27,PropServerKeepAlive 6764,PropWillDelayInterval 29672,PropSessionExpiryInterval 3082,PropTopicAlias +// 11165,PropWillDelayInterval 28623,PropSessionExpiryInterval 10852,PropResponseInformation +// "I",PropRequestProblemInformation 98,PropMaximumQoS 75,PropMaximumQoS 88,PropMessageExpiryInterval +// 1740,PropReceiveMaximum 21047,PropSubscriptionIdentifier 28] TEST(Subscribe5QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0x95, 0x1, 0x6b, 0xda, 0x84, 0x1, 0x18, 0x0, 0x0, 0x3c, 0xbf, 0x9, 0x0, 0x0, 0x16, 0x0, - 0x13, 0x86, 0xf, 0x29, 0x25, 0xd1, 0xc7, 0x9d, 0x75, 0xb0, 0xb, 0x42, 0x10, 0x6c, 0x56, 0xa4, 0x47, - 0x43, 0x3d, 0xd2, 0x2a, 0xf0, 0x8, 0x0, 0x10, 0x98, 0x43, 0xd4, 0x49, 0xa4, 0x29, 0xa5, 0xd0, 0x35, - 0x1d, 0x44, 0x10, 0xaa, 0x36, 0xc0, 0x8b, 0x15, 0x0, 0x2, 0x70, 0x8b, 0x3, 0x0, 0x8, 0x5e, 0xc3, - 0x48, 0xfa, 0xee, 0x31, 0x63, 0x8a, 0x2a, 0x97, 0x25, 0x68, 0x15, 0x0, 0x9, 0x68, 0xbf, 0xaf, 0x2f, - 0xae, 0xf5, 0x3d, 0x8c, 0x14, 0x21, 0x50, 0x18, 0x24, 0x32, 0x8, 0x0, 0x18, 0x3c, 0x70, 0x8d, 0x3d, - 0x4e, 0xfb, 0xd8, 0xe4, 0xe9, 0xf4, 0x88, 0x5c, 0xd7, 0x95, 0x72, 0xf0, 0x93, 0x61, 0x69, 0xd5, 0xbd, - 0xde, 0xf8, 0xac, 0x27, 0x0, 0x0, 0x6d, 0x1a, 0x27, 0x0, 0x0, 0x62, 0x83, 0x24, 0x33, 0x27, 0x0, - 0x0, 0x3e, 0xa, 0x0, 0x7, 0xed, 0x25, 0x3d, 0x41, 0xff, 0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t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x25, 0x3d, 0x41, 0xff, 0xa7, 0x38}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xf, 0xeb, 0x26, 0x10, 0x79, 0x96, 0xa, 0xcf, 0xd4, 0x3e, 0x48, 0x84}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x40, 0xb5, 0xb2, 0x2a, 0x44, 0xd3}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x86, 0xf, 0x29, 0x25, 0xd1, 0xc7, 0x9d, 0x75, 0xb0, 0xb, - 0x42, 0x10, 0x6c, 0x56, 0xa4, 0x47, 0x43, 0x3d, 0xd2}; - uint8_t bytesprops2[] = {0x98, 0x43, 0xd4, 0x49, 0xa4, 0x29, 0xa5, 0xd0, - 0x35, 0x1d, 0x44, 0x10, 0xaa, 0x36, 0xc0, 0x8b}; - uint8_t bytesprops3[] = {0x70, 0x8b}; - uint8_t bytesprops4[] = {0x5e, 0xc3, 0x48, 0xfa, 0xee, 0x31, 0x63, 0x8a}; - uint8_t bytesprops5[] = {0x68, 0xbf, 0xaf, 0x2f, 0xae, 0xf5, 0x3d, 0x8c, 0x14}; - uint8_t bytesprops6[] = {0x3c, 0x70, 0x8d, 0x3d, 0x4e, 0xfb, 0xd8, 0xe4, 0xe9, 0xf4, 0x88, 0x5c, - 0xd7, 0x95, 0x72, 0xf0, 0x93, 0x61, 0x69, 0xd5, 0xbd, 0xde, 0xf8, 0xac}; + uint8_t topic_filter_s2_bytes[] = {0x35, 0x8a, 0xa4, 0xec, 0xaf, 0xb, 0x9a, 0xd7, 0x10, 0x11, 0xfa, 0x5a, + 0xa8, 0x4e, 0x91, 0xe4, 0xeb, 0x43, 0xba, 0xd, 0x72, 0x66, 0xf7, 0xf3}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6f, 0xeb, 0x73, 0x11, 0x70, 0xb3, 0xc4, 0x33, 0xd8, 0x6e, 0x5}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + uint8_t bytesprops0[] = {0x33, 0x2, 0x92, 0x28, 0xf4, 0x99, 0x40, 0xba, 0xfb, 0x1a, 0x63, + 0x47, 0x31, 0xbf, 0xdf, 0x5a, 0x1a, 0x68, 0xdd, 0x43, 0xcb, 0x3e}; + uint8_t bytesprops1[] = {0xd3, 0x52, 0x70, 0xff, 0x1c, 0x1c, 0xee, 0x36}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x49}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15551}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20504}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27930}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25219}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15882}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 986}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9329}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3455}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13564}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10366}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6764}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29672}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3082}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11165}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28623}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10852}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1740}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21047}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27610, 2, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26291, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4069 [("k\212\217\191\167Z\148\215\216\238$0\DLE\138\137",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("f\DC3\GSt\DC4]e\t\EOTEx\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\148G\181",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("+\153\166\221\250\195|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\DC2L\210Q\212\131\223\205\220\163\&3\141\245\165T\235c5\168\229",SubOptions {_retainHandling = +// SubscribeRequest 29015 [("\163\tU\254\239\150/*\157\226\191\&1a\DC3\227{",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\DEL\129c\NAKgK\238]W\EM\132uT\138\249i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\158\182*d\178\184#\243a\207]\196\141\233\DEL\165)\DC4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\183\ETB\154u\225\161A@_\SYN\251\185%\179y\180A\ESC\b\143\SO",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRequestResponseInformation 20,PropReasonString -// "\147\176\141\212\255\&2\160\148\162\144\&5\134H\180{$f\153\228\207",PropMessageExpiryInterval -// 3689,PropServerKeepAlive 28576,PropAuthenticationData -// "O]zr/k7\163\DC181\186\139\142\171;=\182\236\t\250\174\&7\255h\204",PropPayloadFormatIndicator -// 14,PropSharedSubscriptionAvailable 171,PropUserProperty -// "\176\252\NUL\139x\164|\129\195\STX\207\250\&6[\SYN\GS\151\250\200\248\130\250" "\128",PropResponseTopic -// "\224\253\187;}$|\207",PropSharedSubscriptionAvailable 66,PropSessionExpiryInterval 21633,PropResponseTopic -// "'\240*-E\DC1\199\180\206\165hN%",PropRetainAvailable 93,PropMaximumPacketSize 22481] +// QoS1}),("\213\SUB\207\229\DC3\246\243\142",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [PropRequestResponseInformation 223,PropServerReference +// "\239\139\206\179\GS\133jT&p\150\232\206\CAN\217",PropSharedSubscriptionAvailable 72,PropServerKeepAlive +// 10269,PropServerReference "CP",PropPayloadFormatIndicator 144,PropWillDelayInterval 20331,PropAuthenticationData +// "\222\SI\128\ETXF\194\249O\180'\198\192\&9\233\163\217\189\239\GS\223\DC2\b\130Ou]=\142\\Q",PropSessionExpiryInterval +// 14899,PropRetainAvailable 53,PropRetainAvailable 23,PropSharedSubscriptionAvailable 74,PropPayloadFormatIndicator +// 90,PropMessageExpiryInterval 26931,PropRequestProblemInformation 202,PropSubscriptionIdentifierAvailable +// 70,PropMaximumQoS 160,PropServerReference +// "\196\207\143&\235@\178\248\154\190\163\201\153M\148\168",PropWillDelayInterval 24816,PropMaximumPacketSize +// 26054,PropCorrelationData "\243?H\SYN\181w\130R/\146\NULcpF\182\219.\181\232\200\220\a\255G8",PropServerKeepAlive +// 12011,PropRetainAvailable 29,PropSubscriptionIdentifier 6,PropMaximumQoS 2,PropRequestProblemInformation 42] TEST(Subscribe5QCTest, Encode5) { - uint8_t pkt[] = { - 0x82, 0x93, 0x2, 0xf, 0xe5, 0x87, 0x1, 0x19, 0x14, 0x1f, 0x0, 0x14, 0x93, 0xb0, 0x8d, 0xd4, 0xff, 0x32, 0xa0, - 0x94, 0xa2, 0x90, 0x35, 0x86, 0x48, 0xb4, 0x7b, 0x24, 0x66, 0x99, 0xe4, 0xcf, 0x2, 0x0, 0x0, 0xe, 0x69, 0x13, - 0x6f, 0xa0, 0x16, 0x0, 0x1a, 0x4f, 0x5d, 0x7a, 0x72, 0x2f, 0x6b, 0x37, 0xa3, 0x11, 0x38, 0x31, 0xba, 0x8b, 0x8e, - 0xab, 0x3b, 0x3d, 0xb6, 0xec, 0x9, 0xfa, 0xae, 0x37, 0xff, 0x68, 0xcc, 0x1, 0xe, 0x2a, 0xab, 0x26, 0x0,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0x2a, 0x0, + 0x10, 0xa3, 0x9, 0x55, 0xfe, 0xef, 0x96, 0x2f, 0x2a, 0x9d, 0xe2, 0xbf, 0x31, 0x61, 0x13, 0xe3, 0x7b, + 0x1, 0x0, 0x8, 0xd5, 0x1a, 0xcf, 0xe5, 0x13, 0xf6, 0xf3, 0x8e, 0x22}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x6b, 0xd4, 0xd9, 0xbf, 0xa7, 0x5a, 0x94, 0xd7, - 0xd8, 0xee, 0x24, 0x30, 0x10, 0x8a, 0x89}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xa3, 0x9, 0x55, 0xfe, 0xef, 0x96, 0x2f, 0x2a, + 0x9d, 0xe2, 0xbf, 0x31, 0x61, 0x13, 0xe3, 0x7b}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x66, 0x13, 0x1d, 0x74, 0x14, 0x5d, 0x65, 0x9, 0x4, 0x45, 0x78, 0xd0}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd5, 0x1a, 0xcf, 0xe5, 0x13, 0xf6, 0xf3, 0x8e}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x94, 0x47, 0xb5}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2b, 0x99, 0xa6, 0xdd, 0xfa, 0xc3, 0x7c}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x12, 0x4c, 0xd2, 0x51, 0xd4, 0x83, 0xdf, 0xcd, 0xdc, 0xa3, - 0x33, 0x8d, 0xf5, 0xa5, 0x54, 0xeb, 0x63, 0x35, 0xa8, 0xe5}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7f, 0x81, 0x63, 0x15, 0x67, 0x4b, 0xee, 0x5d, - 0x57, 0x19, 0x84, 0x75, 0x54, 0x8a, 0xf9, 0x69}; - lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x9e, 0xb6, 0x2a, 0x64, 0xb2, 0xb8, 0x23, 0xf3, 0x61, - 0xcf, 0x5d, 0xc4, 0x8d, 0xe9, 0x7f, 0xa5, 0x29, 0x14}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb7, 0x17, 0x9a, 0x75, 0xe1, 0xa1, 0x41, 0x40, 0x5f, 0x16, 0xfb, - 0xb9, 0x25, 0xb3, 0x79, 0xb4, 0x41, 0x1b, 0x8, 0x8f, 0xe}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x93, 0xb0, 0x8d, 0xd4, 0xff, 0x32, 0xa0, 0x94, 0xa2, 0x90, - 0x35, 0x86, 0x48, 0xb4, 0x7b, 0x24, 0x66, 0x99, 0xe4, 0xcf}; - uint8_t bytesprops1[] = {0x4f, 0x5d, 0x7a, 0x72, 0x2f, 0x6b, 0x37, 0xa3, 0x11, 0x38, 0x31, 0xba, 0x8b, - 0x8e, 0xab, 0x3b, 0x3d, 0xb6, 0xec, 0x9, 0xfa, 0xae, 0x37, 0xff, 0x68, 0xcc}; - uint8_t bytesprops3[] = {0x80}; - uint8_t bytesprops2[] = {0xb0, 0xfc, 0x0, 0x8b, 0x78, 0xa4, 0x7c, 0x81, 0xc3, 0x2, 0xcf, - 0xfa, 0x36, 0x5b, 0x16, 0x1d, 0x97, 0xfa, 0xc8, 0xf8, 0x82, 0xfa}; - uint8_t bytesprops4[] = {0xe0, 0xfd, 0xbb, 0x3b, 0x7d, 0x24, 0x7c, 0xcf}; - uint8_t bytesprops5[] = {0x27, 0xf0, 0x2a, 0x2d, 0x45, 0x11, 0xc7, 0xb4, 0xce, 0xa5, 0x68, 0x4e, 0x25}; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + uint8_t bytesprops0[] = {0xef, 0x8b, 0xce, 0xb3, 0x1d, 0x85, 0x6a, 0x54, 0x26, 0x70, 0x96, 0xe8, 0xce, 0x18, 0xd9}; + uint8_t bytesprops1[] = {0x43, 0x50}; + uint8_t bytesprops2[] = {0xde, 0xf, 0x80, 0x3, 0x46, 0xc2, 0xf9, 0x4f, 0xb4, 0x27, 0xc6, 0xc0, 0x39, 0xe9, 0xa3, + 0xd9, 0xbd, 0xef, 0x1d, 0xdf, 0x12, 0x8, 0x82, 0x4f, 0x75, 0x5d, 0x3d, 0x8e, 0x5c, 0x51}; + uint8_t bytesprops3[] = {0xc4, 0xcf, 0x8f, 0x26, 0xeb, 0x40, 0xb2, 0xf8, + 0x9a, 0xbe, 0xa3, 0xc9, 0x99, 0x4d, 0x94, 0xa8}; + uint8_t bytesprops4[] = {0xf3, 0x3f, 0x48, 0x16, 0xb5, 0x77, 0x82, 0x52, 0x2f, 0x92, 0x0, 0x63, 0x70, + 0x46, 0xb6, 0xdb, 0x2e, 0xb5, 0xe8, 0xc8, 0xdc, 0x7, 0xff, 0x47, 0x38}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3689}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28576}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops2}, .v = {1, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21633}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22481}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10269}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20331}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14899}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26931}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24816}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26054}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12011}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 42}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4069, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29015, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4140 [("q\r\152^#\158\&0\215\239\148E\179M",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\178\RS\139\147\GS\136\&8\163^",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("8Y\221d\ETX\244\192\148\163\158\187\243$.X\166\202\211\153\209\237\218\248",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("yb\183l\128\223\ENQ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("Q\140AB*\199\195j\143@\USo\199\190aA\198\245\248\172E",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\205,\SI\FS\230\197\161j<\221\143",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("b",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("x\229\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1})] [PropSubscriptionIdentifierAvailable 232,PropSubscriptionIdentifier -// 24,PropWildcardSubscriptionAvailable 16,PropAuthenticationMethod "g\RS\216",PropServerReference -// "=\174\&2p\191\188\v\253\243\177@\181;\134\190\DC4\FS\206\200\ESC$\162\197\174",PropTopicAliasMaximum -// 24986,PropReasonString "\225\&4\133\139Z\140\FS\248[/\133\150\ESC\NUL\193M\178\FSr\207\190\ESCP, -// \232:",PropAuthenticationData -// ".\"\142I>\SIa\219s]`r\175",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\248\&3\182",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] +// [PropSessionExpiryInterval 15919,PropMessageExpiryInterval 13210,PropSharedSubscriptionAvailable +// 2,PropResponseInformation +// "\173p\184\166Z\174\249\226\182\211Z\\\231\136^\240y\243\186\SUB\DLE\247,\167{\172V\203",PropPayloadFormatIndicator +// 57,PropTopicAliasMaximum 16229,PropMaximumQoS 46,PropSubscriptionIdentifier 32,PropUserProperty +// "\ru\135\v@\145\160\215\177\&4EQ\150\138\&3;\225\222\217" "\SI\195\SO\DLE\228",PropCorrelationData +// "\EM\229\DC3\222B\172m\DC2\230\238",PropMessageExpiryInterval 7126,PropSubscriptionIdentifier 10,PropRetainAvailable +// 192,PropResponseTopic "\168\184\&9l\238\DC1\ACK\185&\179*{\DC1-\187\DLE11N$n\138\151\GS`^y\152A"] TEST(Subscribe5QCTest, Encode6) { uint8_t pkt[] = { - 0x82, 0x9e, 0x3, 0x10, 0x2c, 0xaa, 0x2, 0x29, 0xe8, 0xb, 0x18, 0x28, 0x10, 0x15, 0x0, 0x3, 0x67, 0x1e, 0xd8, - 0x1c, 0x0, 0x18, 0x3d, 0xae, 0x32, 0x70, 0xbf, 0xbc, 0xb, 0xfd, 0xf3, 0xb1, 0x40, 0xb5, 0x3b, 0x86, 0xbe, 0x14, - 0x1c, 0xce, 0xc8, 0x1b, 0x24, 0xa2, 0xc5, 0xae, 0x22, 0x61, 0x9a, 0x1f, 0x0, 0x1b, 0xe1, 0x34, 0x85, 0x8b, 0x5a, - 0x8c, 0x1c, 0xf8, 0x5b, 0x2f, 0x85, 0x96, 0x1b, 0x0, 0xc1, 0x4d, 0xb2, 0x1c, 0x72, 0xcf, 0xbe, 0x1b, 0x50, 0x2c, - 0x20, 0xe8, 0x3a, 0x16, 0x0, 0x1a, 0x2e, 0x22, 0x8e, 0x49, 0x3e, 0xf, 0x61, 0xdb, 0x73, 0x3c, 0x3f, 0x56, 0x48, - 0xd1, 0x9e, 0x19, 0xef, 0x95, 0xa4, 0x3, 0x55, 0xf9, 0xf6, 0xd5, 0x73, 0x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d, 0x75, 0x87, 0xb, 0x40, 0x91, 0xa0, 0xd7, 0xb1, 0x34, 0x45, 0x51, 0x96, 0x8a, + 0x33, 0x3b, 0xe1, 0xde, 0xd9, 0x0, 0x5, 0xf, 0xc3, 0xe, 0x10, 0xe4, 0x9, 0x0, 0xa, 0x19, 0xe5, 0x13, 0xde, + 0x42, 0xac, 0x6d, 0x12, 0xe6, 0xee, 0x2, 0x0, 0x0, 0x1b, 0xd6, 0xb, 0xa, 0x25, 0xc0, 0x8, 0x0, 0x1d, 0xa8, + 0xb8, 0x39, 0x6c, 0xee, 0x11, 0x6, 0xb9, 0x26, 0xb3, 0x2a, 0x7b, 0x11, 0x2d, 0xbb, 0x10, 0x31, 0x31, 0x4e, 0x24, + 0x6e, 0x8a, 0x97, 0x1d, 0x60, 0x5e, 0x79, 0x98, 0x41, 0x0, 0x18, 0x85, 0x8b, 0x5c, 0xe1, 0xbc, 0xc, 0x3b, 0x5c, + 0xe8, 0x3d, 0xf7, 0xc, 0x83, 0x69, 0x33, 0x42, 0x4b, 0x37, 0x63, 0x70, 0x96, 0x6c, 0x1c, 0x63, 0x21, 0x0, 0x5, + 0xad, 0x24, 0x72, 0x48, 0xfa, 0x22, 0x0, 0x6, 0xa9, 0x91, 0xa4, 0x6b, 0x8b, 0xf6, 0x0, 0x0, 0x12, 0x1f, 0x7f, + 0xc, 0x66, 0x4c, 0x5d, 0x19, 0x4d, 0x34, 0x56, 0x20, 0x7c, 0x31, 0x1e, 0xa9, 0x97, 0x15, 0xf6, 0x12, 0x0, 0x16, + 0xbe, 0xc8, 0x43, 0x76, 0x6a, 0x98, 0x9a, 0xda, 0xf9, 0x78, 0x2, 0xfb, 0x7d, 0x60, 0xa8, 0x9c, 0xb6, 0x3e, 0x5d, + 0x60, 0x72, 0xaf, 0x19, 0x0, 0x3, 0xf8, 0x33, 0xb6, 0x2c}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x71, 0xd, 0x98, 0x5e, 0x23, 0x9e, 0x30, 0xd7, 0xef, 0x94, 0x45, 0xb3, 0x4d}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x85, 0x8b, 0x5c, 0xe1, 0xbc, 0xc, 0x3b, 0x5c, 0xe8, 0x3d, 0xf7, 0xc, + 0x83, 0x69, 0x33, 0x42, 0x4b, 0x37, 0x63, 0x70, 0x96, 0x6c, 0x1c, 0x63}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb2, 0x1e, 0x8b, 0x93, 0x1d, 0x88, 0x38, 0xa3, 0x5e}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xad, 0x24, 0x72, 0x48, 0xfa}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x38, 0x59, 0xdd, 0x64, 0x3, 0xf4, 0xc0, 0x94, 0xa3, 0x9e, 0xbb, 0xf3, - 0x24, 0x2e, 0x58, 0xa6, 0xca, 0xd3, 0x99, 0xd1, 0xed, 0xda, 0xf8}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa9, 0x91, 0xa4, 0x6b, 0x8b, 0xf6}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x79, 0x62, 0xb7, 0x6c, 0x80, 0xdf, 0x5}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1f, 0x7f, 0xc, 0x66, 0x4c, 0x5d, 0x19, 0x4d, 0x34, + 0x56, 0x20, 0x7c, 0x31, 0x1e, 0xa9, 0x97, 0x15, 0xf6}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x51, 0x8c, 0x41, 0x42, 0x2a, 0xc7, 0xc3, 0x6a, 0x8f, 0x40, 0x1f, - 0x6f, 0xc7, 0xbe, 0x61, 0x41, 0xc6, 0xf5, 0xf8, 0xac, 0x45}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xbe, 0xc8, 0x43, 0x76, 0x6a, 0x98, 0x9a, 0xda, 0xf9, 0x78, 0x2, + 0xfb, 0x7d, 0x60, 0xa8, 0x9c, 0xb6, 0x3e, 0x5d, 0x60, 0x72, 0xaf}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xcd, 0x2c, 0xf, 0x1c, 0xe6, 0xc5, 0xa1, 0x6a, 0x3c, 0xdd, 0x8f}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf8, 0x33, 0xb6}; + lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x62}; - lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x78, 0xe5, 0x32}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x67, 0x1e, 0xd8}; - uint8_t bytesprops1[] = {0x3d, 0xae, 0x32, 0x70, 0xbf, 0xbc, 0xb, 0xfd, 0xf3, 0xb1, 0x40, 0xb5, - 0x3b, 0x86, 0xbe, 0x14, 0x1c, 0xce, 0xc8, 0x1b, 0x24, 0xa2, 0xc5, 0xae}; - uint8_t bytesprops2[] = {0xe1, 0x34, 0x85, 0x8b, 0x5a, 0x8c, 0x1c, 0xf8, 0x5b, 0x2f, 0x85, 0x96, 0x1b, 0x0, - 0xc1, 0x4d, 0xb2, 0x1c, 0x72, 0xcf, 0xbe, 0x1b, 0x50, 0x2c, 0x20, 0xe8, 0x3a}; - uint8_t bytesprops3[] = {0x2e, 0x22, 0x8e, 0x49, 0x3e, 0xf, 0x61, 0xdb, 0x73, 0x3c, 0x3f, 0x56, 0x48, - 0xd1, 0x9e, 0x19, 0xef, 0x95, 0xa4, 0x3, 0x55, 0xf9, 0xf6, 0xd5, 0x73, 0x77}; - uint8_t bytesprops4[] = {0xde, 0xfe, 0x50, 0xba, 0x66, 0x23, 0x4a, 0x98, 0xae, 0x7d, - 0x3d, 0xca, 0xe4, 0x9, 0xe0, 0x7b, 0xa8, 0xa0, 0x74}; - uint8_t bytesprops5[] = {0x2e, 0x8, 0x52, 0xeb, 0xbe, 0xbd, 0x7e, 0x7c, 0xf5, 0x45, 0x81, 0x98, - 0xad, 0x53, 0x48, 0x77, 0x61, 0x6b, 0xbd, 0x0, 0x71, 0xd, 0x18, 0x8c}; - uint8_t bytesprops6[] = {0x4b, 0x7c, 0x48, 0xcd, 0xa5, 0x3, 0x7, 0xc7, 0x60, 0xa1, 0xe3, 0xff}; - uint8_t bytesprops7[] = {0x30, 0x6c, 0x4e}; - uint8_t bytesprops8[] = {0x9f, 0x88, 0xce, 0x8c, 0xdb, 0xdd, 0x89, 0xdb, 0xce, 0xa2, 0x85, 0x19, 0x66, 0x5f}; - uint8_t bytesprops9[] = {0xd4, 0x91, 0xf1, 0xa6, 0x43, 0xd5, 0xb4}; - uint8_t bytesprops10[] = {0xf0, 0xed, 0xf, 0xe7, 0x95, 0x6, 0x67, 0x4d, 0x83, 0x9c, 0xfa, 0x65, 0x5d, - 0xa1, 0x2c, 0x9f, 0x12, 0x92, 0xf7, 0x4f, 0x65, 0x6d, 0x91, 0xfa, 0xb0}; - uint8_t bytesprops11[] = {0x91, 0x6e, 0x10, 0xd0, 0x5b, 0x8e, 0xdd, 0x3c, 0xcd, 0xf9, 0x6c, 0x8c, 0x6, 0xeb, 0x9d, - 0x86, 0x4d, 0x53, 0xd8, 0xc4, 0x5a, 0x36, 0x82, 0xb2, 0xab, 0x92, 0xbf, 0xbb, 0xb}; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + uint8_t bytesprops0[] = {0xad, 0x70, 0xb8, 0xa6, 0x5a, 0xae, 0xf9, 0xe2, 0xb6, 0xd3, 0x5a, 0x5c, 0xe7, 0x88, + 0x5e, 0xf0, 0x79, 0xf3, 0xba, 0x1a, 0x10, 0xf7, 0x2c, 0xa7, 0x7b, 0xac, 0x56, 0xcb}; + uint8_t bytesprops2[] = {0xf, 0xc3, 0xe, 0x10, 0xe4}; + uint8_t bytesprops1[] = {0xd, 0x75, 0x87, 0xb, 0x40, 0x91, 0xa0, 0xd7, 0xb1, 0x34, + 0x45, 0x51, 0x96, 0x8a, 0x33, 0x3b, 0xe1, 0xde, 0xd9}; + uint8_t bytesprops3[] = {0x19, 0xe5, 0x13, 0xde, 0x42, 0xac, 0x6d, 0x12, 0xe6, 0xee}; + uint8_t bytesprops4[] = {0xa8, 0xb8, 0x39, 0x6c, 0xee, 0x11, 0x6, 0xb9, 0x26, 0xb3, 0x2a, 0x7b, 0x11, 0x2d, 0xbb, + 0x10, 0x31, 0x31, 0x4e, 0x24, 0x6e, 0x8a, 0x97, 0x1d, 0x60, 0x5e, 0x79, 0x98, 0x41}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24986}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29781}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4559}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27338}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 870}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16841}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3658}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15919}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13210}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16229}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 32}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops1}, .v = {5, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7126}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4140, 8, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24249, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32171 [("\235\179\143\169o\140~\246\145>\228z*M/\153\204\US@%",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("/ti-C\SUB\US\190\&4\138",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\GS\205\155",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\161\159\232{t\166\134\176\251\137\135\166\212",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("hO\199\173\182",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("E\SI\143~\248\185\255\166X\245\253\209\171\231\220\133\210\226\SO",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSubscriptionIdentifier -// 24,PropCorrelationData "\196u\174\162\192\EOTP\194\232\221\ESCwC",PropTopicAlias 6660,PropSharedSubscriptionAvailable -// 18,PropReceiveMaximum 21591,PropMessageExpiryInterval 27385,PropAssignedClientIdentifier -// "*\172\236\193\DC1D\216p\205\ESCq\135\132\184\194\237",PropServerKeepAlive 24724,PropMaximumQoS 145,PropUserProperty -// "\223\&1>3\135\205" "<`R%\DC3\161\DC2\129R\141f\193d\202`\ACK",PropCorrelationData -// "\250^\241m\149\"\241V\168*f\CANC\183\212\165",PropRequestResponseInformation 39,PropReasonString -// "\156\130Z\174\131\252gT\241\SYNf\t\159o\128\144\US-r\193\184\223\152\ENQ"] +// SubscribeRequest 18033 [("\181\STX\205 B\134&\195T\EOT\226\245Is\192\233\ETBM\ENQ\150\240\161",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropMaximumQoS +// 84,PropRequestProblemInformation 130,PropRetainAvailable 128,PropAuthenticationMethod +// "\196\133\ETB\SO\225\&9d\226\251\210-\210$",PropSubscriptionIdentifierAvailable 223,PropWillDelayInterval +// 11937,PropServerKeepAlive 5382,PropSubscriptionIdentifier 8,PropWildcardSubscriptionAvailable +// 247,PropMessageExpiryInterval 19198,PropAuthenticationData +// "\200\157p\189e\ENQ\197DJa]\244-?",PropMessageExpiryInterval 9872,PropAuthenticationMethod +// "s\215\231\243m\159\&9~\190\139 \ACK",PropPayloadFormatIndicator 197,PropReceiveMaximum 26191,PropServerKeepAlive +// 20944,PropSubscriptionIdentifier 14,PropMaximumPacketSize 22810,PropWildcardSubscriptionAvailable 26,PropContentType +// "\177I",PropResponseTopic +// "\DLE\b\147\161\SOH\213\183\228qi\129\FS\160\149\CAN\224\v\177\r\NUL4t",PropWillDelayInterval +// 10334,PropPayloadFormatIndicator 136,PropSubscriptionIdentifierAvailable 203,PropUserProperty +// "\247h%\SOH\244\150{\163\&5Ji;7ey\161;s%!\231\193D\215\232\129\214\181" +// "&\148\155\CAN\242ap\SOl\137\STX\191B\204\135\199U\EOT\148\RS\174",PropSubscriptionIdentifierAvailable 192] TEST(Subscribe5QCTest, Encode7) { uint8_t pkt[] = { - 0x82, 0xe1, 0x1, 0x7d, 0xab, 0x82, 0x1, 0xb, 0x18, 0x9, 0x0, 0xd, 0xc4, 0x75, 0xae, 0xa2, 0xc0, 0x4, 0x50, - 0xc2, 0xe8, 0xdd, 0x1b, 0x77, 0x43, 0x23, 0x1a, 0x4, 0x2a, 0x12, 0x21, 0x54, 0x57, 0x2, 0x0, 0x0, 0x6a, 0xf9, - 0x12, 0x0, 0x10, 0x2a, 0xac, 0xec, 0xc1, 0x11, 0x44, 0xd8, 0x70, 0xcd, 0x1b, 0x71, 0x87, 0x84, 0xb8, 0xc2, 0xed, - 0x13, 0x60, 0x94, 0x24, 0x91, 0x26, 0x0, 0x6, 0xdf, 0x31, 0x3e, 0x33, 0x87, 0xcd, 0x0, 0x10, 0x3c, 0x60, 0x52, - 0x25, 0x13, 0xa1, 0x12, 0x81, 0x52, 0x8d, 0x66, 0xc1, 0x64, 0xca, 0x60, 0x6, 0x9, 0x0, 0x10, 0xfa, 0x5e, 0xf1, - 0x6d, 0x95, 0x22, 0xf1, 0x56, 0xa8, 0x2a, 0x66, 0x18, 0x43, 0xb7, 0xd4, 0xa5, 0x19, 0x27, 0x1f, 0x0, 0x18, 0x9c, - 0x82, 0x5a, 0xae, 0x83, 0xfc, 0x67, 0x54, 0xf1, 0x16, 0x66, 0x9, 0x9f, 0x6f, 0x80, 0x90, 0x1f, 0x2d, 0x72, 0xc1, - 0xb8, 0xdf, 0x98, 0x5, 0x0, 0x14, 0xeb, 0xb3, 0x8f, 0xa9, 0x6f, 0x8c, 0x7e, 0xf6, 0x91, 0x3e, 0xe4, 0x7a, 0x2a, - 0x4d, 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0xa1, + 0x1, 0xd5, 0xb7, 0xe4, 0x71, 0x69, 0x81, 0x1c, 0xa0, 0x95, 0x18, 0xe0, 0xb, 0xb1, 0xd, 0x0, 0x34, 0x74, 0x18, + 0x0, 0x0, 0x28, 0x5e, 0x1, 0x88, 0x29, 0xcb, 0x26, 0x0, 0x1c, 0xf7, 0x68, 0x25, 0x1, 0xf4, 0x96, 0x7b, 0xa3, + 0x35, 0x4a, 0x69, 0x3b, 0x37, 0x65, 0x79, 0xa1, 0x3b, 0x73, 0x25, 0x21, 0xe7, 0xc1, 0x44, 0xd7, 0xe8, 0x81, 0xd6, + 0xb5, 0x0, 0x15, 0x26, 0x94, 0x9b, 0x18, 0xf2, 0x61, 0x70, 0xe, 0x6c, 0x89, 0x2, 0xbf, 0x42, 0xcc, 0x87, 0xc7, + 0x55, 0x4, 0x94, 0x1e, 0xae, 0x29, 0xc0, 0x0, 0x16, 0xb5, 0x2, 0xcd, 0x20, 0x42, 0x86, 0x26, 0xc3, 0x54, 0x4, + 0xe2, 0xf5, 0x49, 0x73, 0xc0, 0xe9, 0x17, 0x4d, 0x5, 0x96, 0xf0, 0xa1, 0x4}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xeb, 0xb3, 0x8f, 0xa9, 0x6f, 0x8c, 0x7e, 0xf6, 0x91, 0x3e, - 0xe4, 0x7a, 0x2a, 0x4d, 0x2f, 0x99, 0xcc, 0x1f, 0x40, 0x25}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xb5, 0x2, 0xcd, 0x20, 0x42, 0x86, 0x26, 0xc3, 0x54, 0x4, 0xe2, + 0xf5, 0x49, 0x73, 0xc0, 0xe9, 0x17, 0x4d, 0x5, 0x96, 0xf0, 0xa1}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2f, 0x74, 0x69, 0x2d, 0x43, 0x1a, 0x1f, 0xbe, 0x34, 0x8a}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1d, 0xcd, 0x9b}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa1, 0x9f, 0xe8, 0x7b, 0x74, 0xa6, 0x86, 0xb0, 0xfb, 0x89, 0x87, 0xa6, 0xd4}; - lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x68, 0x4f, 0xc7, 0xad, 0xb6}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x45, 0xf, 0x8f, 0x7e, 0xf8, 0xb9, 0xff, 0xa6, 0x58, 0xf5, - 0xfd, 0xd1, 0xab, 0xe7, 0xdc, 0x85, 0xd2, 0xe2, 0xe}; - lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS1, - LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0xc4, 0x75, 0xae, 0xa2, 0xc0, 0x4, 0x50, 0xc2, 0xe8, 0xdd, 0x1b, 0x77, 0x43}; - uint8_t bytesprops1[] = {0x2a, 0xac, 0xec, 0xc1, 0x11, 0x44, 0xd8, 0x70, - 0xcd, 0x1b, 0x71, 0x87, 0x84, 0xb8, 0xc2, 0xed}; - uint8_t bytesprops3[] = {0x3c, 0x60, 0x52, 0x25, 0x13, 0xa1, 0x12, 0x81, - 0x52, 0x8d, 0x66, 0xc1, 0x64, 0xca, 0x60, 0x6}; - uint8_t bytesprops2[] = {0xdf, 0x31, 0x3e, 0x33, 0x87, 0xcd}; - uint8_t bytesprops4[] = {0xfa, 0x5e, 0xf1, 0x6d, 0x95, 0x22, 0xf1, 0x56, - 0xa8, 0x2a, 0x66, 0x18, 0x43, 0xb7, 0xd4, 0xa5}; - uint8_t bytesprops5[] = {0x9c, 0x82, 0x5a, 0xae, 0x83, 0xfc, 0x67, 0x54, 0xf1, 0x16, 0x66, 0x9, - 0x9f, 0x6f, 0x80, 0x90, 0x1f, 0x2d, 0x72, 0xc1, 0xb8, 0xdf, 0x98, 0x5}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + uint8_t bytesprops0[] = {0xc4, 0x85, 0x17, 0xe, 0xe1, 0x39, 0x64, 0xe2, 0xfb, 0xd2, 0x2d, 0xd2, 0x24}; + uint8_t bytesprops1[] = {0xc8, 0x9d, 0x70, 0xbd, 0x65, 0x5, 0xc5, 0x44, 0x4a, 0x61, 0x5d, 0xf4, 0x2d, 0x3f}; + uint8_t bytesprops2[] = {0x73, 0xd7, 0xe7, 0xf3, 0x6d, 0x9f, 0x39, 0x7e, 0xbe, 0x8b, 0x20, 0x6}; + uint8_t bytesprops3[] = {0xb1, 0x49}; + uint8_t bytesprops4[] = {0x10, 0x8, 0x93, 0xa1, 0x1, 0xd5, 0xb7, 0xe4, 0x71, 0x69, 0x81, + 0x1c, 0xa0, 0x95, 0x18, 0xe0, 0xb, 0xb1, 0xd, 0x0, 0x34, 0x74}; + uint8_t bytesprops6[] = {0x26, 0x94, 0x9b, 0x18, 0xf2, 0x61, 0x70, 0xe, 0x6c, 0x89, 0x2, + 0xbf, 0x42, 0xcc, 0x87, 0xc7, 0x55, 0x4, 0x94, 0x1e, 0xae}; + uint8_t bytesprops5[] = {0xf7, 0x68, 0x25, 0x1, 0xf4, 0x96, 0x7b, 0xa3, 0x35, 0x4a, 0x69, 0x3b, 0x37, 0x65, + 0x79, 0xa1, 0x3b, 0x73, 0x25, 0x21, 0xe7, 0xc1, 0x44, 0xd7, 0xe8, 0x81, 0xd6, 0xb5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6660}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21591}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27385}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24724}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops2}, .v = {16, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11937}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5382}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19198}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9872}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26191}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20944}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22810}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10334}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops5}, .v = {21, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 192}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32171, 7, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 29078 [("\201\248\\\248\245\254b\200k\161O\234i|\156\CAN\154+$\r\DLEu\179\"_|S}",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("#\234t\173\SOH%\NUL\251\216}\164\226\144\198\195\234\174\FSJ\136\GS\239\130\227\136\NAK",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("A\129\149O\210j]Y\247\205{\133\US\158\220U\204Gq\195\159\200kM\141\DLE\155\245\175",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\RST\234",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("h\USN\NUL\199Ix\174\RS\FS#\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS0})] [PropTopicAlias 28371,PropAssignedClientIdentifier -// "qa\234\216V\206\v\254\SO*\191\249\&9",PropMaximumPacketSize 29054,PropReceiveMaximum 18298,PropMessageExpiryInterval -// 12385,PropSharedSubscriptionAvailable 182] + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18033, 1, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 22392 +// [("G\SO_\r\DLE\244.\250W\133;\154\229\255\200(\128({\RS\DEL\205\&3\233\NAK\158\197\191l",SubOptions {_retainHandling +// = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\233\157F\ACK\128m\130\216\142\NUL\197\184\&8\243\248\SIvz\CAN\229w\US\EM\159\141",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\146\&0m\DC3J\242\217\STXV\251\177G\241m?\246\228",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\t\190\224d\180\148N\147{\128\156",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] +// [PropRetainAvailable 105,PropSubscriptionIdentifier 12,PropAssignedClientIdentifier +// "\149\161{\161n\129\147\142\198",PropAuthenticationMethod +// "\ETXU]n%\ETX\DC2\238'\140R\211])>\ACK\146{e\162\147+A\142\153",PropWillDelayInterval 1145,PropReasonString +// "\206\149\GS\232\&4\247\&9\251\FS\210\190\DC2\255\145\156\f\251\233K",PropAssignedClientIdentifier +// "\f\196\248\244\ACK",PropMessageExpiryInterval 30990,PropSubscriptionIdentifierAvailable 170,PropUserProperty +// "\183\&5\171\213)\200\214\b2OqE\236l\173\154\198X\236\191^\201\182\153\142\238\SYNe\145" +// "Nv\132\199S\234s\f\162ts\186\198f\242\a\183\SO\SO 1\n\182",PropResponseTopic +// "&\245\218\227R\v\246Jw}\182\143O\208O\186%\170\197\236\238",PropResponseInformation +// "\ETB6\187\EOT\188\159c\209Pm)e\185\160\198\214Q\n\ETB\EOTb\am\227\FS,\224\&5",PropServerReference +// "\f\190\148X\243\178mC\136",PropServerKeepAlive 3868,PropContentType "\227\141\154\US\235 +// \224~\153",PropMessageExpiryInterval 14518,PropAssignedClientIdentifier +// "\151x\165\132Z\217\tU0x,\ETX\163\154",PropAuthenticationData +// "\157\146[\237y\154\156\b\221f\178\181\136w\232&\193\r"] TEST(Subscribe5QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x96, 0x1, 0x71, 0x96, 0x22, 0x23, 0x6e, 0xd3, 0x12, 0x0, 0xd, 0x71, 0x61, 0xea, 0xd8, 0x56, - 0xce, 0xb, 0xfe, 0xe, 0x2a, 0xbf, 0xf9, 0x39, 0x27, 0x0, 0x0, 0x71, 0x7e, 0x21, 0x47, 0x7a, 0x2, - 0x0, 0x0, 0x30, 0x61, 0x2a, 0xb6, 0x0, 0x1c, 0xc9, 0xf8, 0x5c, 0xf8, 0xf5, 0xfe, 0x62, 0xc8, 0x6b, - 0xa1, 0x4f, 0xea, 0x69, 0x7c, 0x9c, 0x18, 0x9a, 0x2b, 0x24, 0xd, 0x10, 0x75, 0xb3, 0x22, 0x5f, 0x7c, - 0x53, 0x7d, 0x0, 0x0, 0x1a, 0x23, 0xea, 0x74, 0xad, 0x1, 0x25, 0x0, 0xfb, 0xd8, 0x7d, 0xa4, 0xe2, - 0x90, 0xc6, 0xc3, 0xea, 0xae, 0x1c, 0x4a, 0x88, 0x1d, 0xef, 0x82, 0xe3, 0x88, 0x15, 0x1, 0x0, 0x1d, - 0x41, 0x81, 0x95, 0x4f, 0xd2, 0x6a, 0x5d, 0x59, 0xf7, 0xcd, 0x7b, 0x85, 0x1f, 0x9e, 0xdc, 0x55, 0xcc, - 0x47, 0x71, 0xc3, 0x9f, 0xc8, 0x6b, 0x4d, 0x8d, 0x10, 0x9b, 0xf5, 0xaf, 0x0, 0x0, 0x3, 0x1e, 0x54, - 0xea, 0x2, 0x0, 0xc, 0x68, 0x1f, 0x4e, 0x0, 0xc7, 0x49, 0x78, 0xae, 0x1e, 0x1c, 0x23, 0xae, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xc9, 0xf8, 0x5c, 0xf8, 0xf5, 0xfe, 0x62, 0xc8, 0x6b, 0xa1, - 0x4f, 0xea, 0x69, 0x7c, 0x9c, 0x18, 0x9a, 0x2b, 0x24, 0xd, - 0x10, 0x75, 0xb3, 0x22, 0x5f, 0x7c, 0x53, 0x7d}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = { + 0x82, 0xee, 0x2, 0x57, 0x78, 0x8c, 0x2, 0x25, 0x69, 0xb, 0xc, 0x12, 0x0, 0x9, 0x95,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 0x2c, 0xe0, 0x35, 0x1c, 0x0, 0x9, 0xc, + 0xbe, 0x94, 0x58, 0xf3, 0xb2, 0x6d, 0x43, 0x88, 0x13, 0xf, 0x1c, 0x3, 0x0, 0x9, 0xe3, 0x8d, 0x9a, 0x1f, 0xeb, + 0x20, 0xe0, 0x7e, 0x99, 0x2, 0x0, 0x0, 0x38, 0xb6, 0x12, 0x0, 0xe, 0x97, 0x78, 0xa5, 0x84, 0x5a, 0xd9, 0x9, + 0x55, 0x30, 0x78, 0x2c, 0x3, 0xa3, 0x9a, 0x16, 0x0, 0x12, 0x9d, 0x92, 0x5b, 0xed, 0x79, 0x9a, 0x9c, 0x8, 0xdd, + 0x66, 0xb2, 0xb5, 0x88, 0x77, 0xe8, 0x26, 0xc1, 0xd, 0x0, 0x1d, 0x47, 0xe, 0x5f, 0xd, 0x10, 0xf4, 0x2e, 0xfa, + 0x57, 0x85, 0x3b, 0x9a, 0xe5, 0xff, 0xc8, 0x28, 0x80, 0x28, 0x7b, 0x1e, 0x7f, 0xcd, 0x33, 0xe9, 0x15, 0x9e, 0xc5, + 0xbf, 0x6c, 0x2a, 0x0, 0x19, 0xe9, 0x9d, 0x46, 0x6, 0x80, 0x6d, 0x82, 0xd8, 0x8e, 0x0, 0xc5, 0xb8, 0x38, 0xf3, + 0xf8, 0xf, 0x76, 0x7a, 0x18, 0xe5, 0x77, 0x1f, 0x19, 0x9f, 0x8d, 0x2c, 0x0, 0x11, 0x92, 0x30, 0x6d, 0x13, 0x4a, + 0xf2, 0xd9, 0x2, 0x56, 0xfb, 0xb1, 0x47, 0xf1, 0x6d, 0x3f, 0xf6, 0xe4, 0xe, 0x0, 0xb, 0x9, 0xbe, 0xe0, 0x64, + 0xb4, 0x94, 0x4e, 0x93, 0x7b, 0x80, 0x9c, 0xd}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x47, 0xe, 0x5f, 0xd, 0x10, 0xf4, 0x2e, 0xfa, 0x57, 0x85, + 0x3b, 0x9a, 0xe5, 0xff, 0xc8, 0x28, 0x80, 0x28, 0x7b, 0x1e, + 0x7f, 0xcd, 0x33, 0xe9, 0x15, 0x9e, 0xc5, 0xbf, 0x6c}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x23, 0xea, 0x74, 0xad, 0x1, 0x25, 0x0, 0xfb, 0xd8, 0x7d, 0xa4, 0xe2, 0x90, - 0xc6, 0xc3, 0xea, 0xae, 0x1c, 0x4a, 0x88, 0x1d, 0xef, 0x82, 0xe3, 0x88, 0x15}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe9, 0x9d, 0x46, 0x6, 0x80, 0x6d, 0x82, 0xd8, 0x8e, 0x0, 0xc5, 0xb8, 0x38, + 0xf3, 0xf8, 0xf, 0x76, 0x7a, 0x18, 0xe5, 0x77, 0x1f, 0x19, 0x9f, 0x8d}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x41, 0x81, 0x95, 0x4f, 0xd2, 0x6a, 0x5d, 0x59, 0xf7, 0xcd, - 0x7b, 0x85, 0x1f, 0x9e, 0xdc, 0x55, 0xcc, 0x47, 0x71, 0xc3, - 0x9f, 0xc8, 0x6b, 0x4d, 0x8d, 0x10, 0x9b, 0xf5, 0xaf}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x92, 0x30, 0x6d, 0x13, 0x4a, 0xf2, 0xd9, 0x2, 0x56, + 0xfb, 0xb1, 0x47, 0xf1, 0x6d, 0x3f, 0xf6, 0xe4}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1e, 0x54, 0xea}; - lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9, 0xbe, 0xe0, 0x64, 0xb4, 0x94, 0x4e, 0x93, 0x7b, 0x80, 0x9c}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x68, 0x1f, 0x4e, 0x0, 0xc7, 0x49, 0x78, 0xae, 0x1e, 0x1c, 0x23, 0xae}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x71, 0x61, 0xea, 0xd8, 0x56, 0xce, 0xb, 0xfe, 0xe, 0x2a, 0xbf, 0xf9, 0x39}; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + uint8_t bytesprops0[] = {0x95, 0xa1, 0x7b, 0xa1, 0x6e, 0x81, 0x93, 0x8e, 0xc6}; + uint8_t bytesprops1[] = {0x3, 0x55, 0x5d, 0x6e, 0x25, 0x3, 0x12, 0xee, 0x27, 0x8c, 0x52, 0xd3, 0x5d, + 0x29, 0x3e, 0x6, 0x92, 0x7b, 0x65, 0xa2, 0x93, 0x2b, 0x41, 0x8e, 0x99}; + uint8_t bytesprops2[] = {0xce, 0x95, 0x1d, 0xe8, 0x34, 0xf7, 0x39, 0xfb, 0x1c, 0xd2, + 0xbe, 0x12, 0xff, 0x91, 0x9c, 0xc, 0xfb, 0xe9, 0x4b}; + uint8_t bytesprops3[] = {0xc, 0xc4, 0xf8, 0xf4, 0x6}; + uint8_t bytesprops5[] = {0x4e, 0x76, 0x84, 0xc7, 0x53, 0xea, 0x73, 0xc, 0xa2, 0x74, 0x73, 0xba, + 0xc6, 0x66, 0xf2, 0x7, 0xb7, 0xe, 0xe, 0x20, 0x31, 0xa, 0xb6}; + uint8_t bytesprops4[] = {0xb7, 0x35, 0xab, 0xd5, 0x29, 0xc8, 0xd6, 0x8, 0x32, 0x4f, 0x71, 0x45, 0xec, 0x6c, 0xad, + 0x9a, 0xc6, 0x58, 0xec, 0xbf, 0x5e, 0xc9, 0xb6, 0x99, 0x8e, 0xee, 0x16, 0x65, 0x91}; + uint8_t bytesprops6[] = {0x26, 0xf5, 0xda, 0xe3, 0x52, 0xb, 0xf6, 0x4a, 0x77, 0x7d, 0xb6, + 0x8f, 0x4f, 0xd0, 0x4f, 0xba, 0x25, 0xaa, 0xc5, 0xec, 0xee}; + uint8_t bytesprops7[] = {0x17, 0x36, 0xbb, 0x4, 0xbc, 0x9f, 0x63, 0xd1, 0x50, 0x6d, 0x29, 0x65, 0xb9, 0xa0, + 0xc6, 0xd6, 0x51, 0xa, 0x17, 0x4, 0x62, 0x7, 0x6d, 0xe3, 0x1c, 0x2c, 0xe0, 0x35}; + uint8_t bytesprops8[] = {0xc, 0xbe, 0x94, 0x58, 0xf3, 0xb2, 0x6d, 0x43, 0x88}; + uint8_t bytesprops9[] = {0xe3, 0x8d, 0x9a, 0x1f, 0xeb, 0x20, 0xe0, 0x7e, 0x99}; + uint8_t bytesprops10[] = {0x97, 0x78, 0xa5, 0x84, 0x5a, 0xd9, 0x9, 0x55, 0x30, 0x78, 0x2c, 0x3, 0xa3, 0x9a}; + uint8_t bytesprops11[] = {0x9d, 0x92, 0x5b, 0xed, 0x79, 0x9a, 0x9c, 0x8, 0xdd, + 0x66, 0xb2, 0xb5, 0x88, 0x77, 0xe8, 0x26, 0xc1, 0xd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28371}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29054}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18298}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12385}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1145}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30990}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {23, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3868}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14518}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29078, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22392, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 756 [("F\229~\a\235\170;\164\DC1\152",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\208fV\240",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("X\FS\146$\204\DLE\249b\249R\142P\254No\129",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\212\SUB\138(T\SYN-\252",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ETX\"\SUB\EM\ETB\133\248d\162\156\244\246",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("R\179\184\&9\148\238\184\166\149\"\208s&A\130\132s(\240\133\165\CAN\EMN",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\252\128\176 -// \139\212\226\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\154\137px\248W\245mK\174\255)oi\SOH\235\145\SO\t\EOT\190\144`%N\219\225\189\179",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("}\193\237\&6\129\180b\DEL\136\247\147W\ETX\229!\156\ACK\226fs\144+\DEL#'\202",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\203\203\184\175b\208n\245r\221R; -// \147\ACK%e9\161\NAKG:-fE\172\128",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2})] [PropRequestResponseInformation 126,PropRequestResponseInformation -// 251,PropMaximumPacketSize 31944,PropRequestProblemInformation 20,PropRetainAvailable 197,PropMessageExpiryInterval -// 3295,PropRequestResponseInformation 141,PropServerReference "eJ\129\167\DC3\184\174*N\228",PropSessionExpiryInterval -// 1167,PropSharedSubscriptionAvailable 150,PropPayloadFormatIndicator 142,PropMessageExpiryInterval -// 12479,PropSubscriptionIdentifierAvailable 88,PropMessageExpiryInterval 4531] +// SubscribeRequest 26543 [("\249\201\SUB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS2}),("\219\159\230|\181\144-\SUB\144",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\220\152\146\130\197\251\SOH\226+",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\143\200\174\222\226\&4\142+",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS1}),("\145\228A\244\158\b\173fY&\220q\DC4\161\\\174\199\&7\172#",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\138\DC1\164\194\ETB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// True, _subQoS = QoS2}),("C\139\178\210\217U(S\133\a",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("MU:H5\202\246\247!\NUL\169",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe5QCTest, Encode9) { - uint8_t pkt[] = { - 0x82, 0xfe, 0x1, 0x2, 0xf4, 0x36, 0x19, 0x7e, 0x19, 0xfb, 0x27, 0x0, 0x0, 0x7c, 0xc8, 0x17, 0x14, 0x25, 0xc5, - 0x2, 0x0, 0x0, 0xc, 0xdf, 0x19, 0x8d, 0x1c, 0x0, 0xa, 0x65, 0x4a, 0x81, 0xa7, 0x13, 0xb8, 0xae, 0x2a, 0x4e, - 0xe4, 0x11, 0x0, 0x0, 0x4, 0x8f, 0x2a, 0x96, 0x1, 0x8e, 0x2, 0x0, 0x0, 0x30, 0xbf, 0x29, 0x58, 0x2, 0x0, - 0x0, 0x11, 0xb3, 0x0, 0xa, 0x46, 0xe5, 0x7e, 0x7, 0xeb, 0xaa, 0x3b, 0xa4, 0x11, 0x98, 0x2, 0x0, 0x4, 0xd0, - 0x66, 0x56, 0xf0, 0x0, 0x0, 0x10, 0x58, 0x1c, 0x92, 0x24, 0xcc, 0x10, 0xf9, 0x62, 0xf9, 0x52, 0x8e, 0x50, 0xfe, - 0x4e, 0x6f, 0x81, 0x1, 0x0, 0x8, 0xd4, 0x1a, 0x8a, 0x28, 0x54, 0x16, 0x2d, 0xfc, 0x2, 0x0, 0xc, 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8f, 0xc8, 0xae, 0xde, 0xe2, 0x34, 0x8e, 0x2b, + 0x9, 0x0, 0x14, 0x91, 0xe4, 0x41, 0xf4, 0x9e, 0x8, 0xad, 0x66, 0x59, 0x26, 0xdc, 0x71, 0x14, + 0xa1, 0x5c, 0xae, 0xc7, 0x37, 0xac, 0x23, 0x16, 0x0, 0x5, 0x8a, 0x11, 0xa4, 0xc2, 0x17, 0x6, + 0x0, 0xa, 0x43, 0x8b, 0xb2, 0xd2, 0xd9, 0x55, 0x28, 0x53, 0x85, 0x7, 0x9, 0x0, 0xb, 0x4d, + 0x55, 0x3a, 0x48, 0x35, 0xca, 0xf6, 0xf7, 0x21, 0x0, 0xa9, 0x8}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x46, 0xe5, 0x7e, 0x7, 0xeb, 0xaa, 0x3b, 0xa4, 0x11, 0x98}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xf9, 0xc9, 0x1a}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd0, 0x66, 0x56, 0xf0}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xdb, 0x9f, 0xe6, 0x7c, 0xb5, 0x90, 0x2d, 0x1a, 0x90}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x58, 0x1c, 0x92, 0x24, 0xcc, 0x10, 0xf9, 0x62, - 0xf9, 0x52, 0x8e, 0x50, 0xfe, 0x4e, 0x6f, 0x81}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xdc, 0x98, 0x92, 0x82, 0xc5, 0xfb, 0x1, 0xe2, 0x2b}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd4, 0x1a, 0x8a, 0x28, 0x54, 0x16, 0x2d, 0xfc}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x3, 0x22, 0x1a, 0x19, 0x17, 0x85, 0xf8, 0x64, 0xa2, 0x9c, 0xf4, 0xf6}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x8f, 0xc8, 0xae, 0xde, 0xe2, 0x34, 0x8e, 0x2b}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x52, 0xb3, 0xb8, 0x39, 0x94, 0xee, 0xb8, 0xa6, 0x95, 0x22, 0xd0, 0x73, - 0x26, 0x41, 0x82, 0x84, 0x73, 0x28, 0xf0, 0x85, 0xa5, 0x18, 0x19, 0x4e}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x91, 0xe4, 0x41, 0xf4, 0x9e, 0x8, 0xad, 0x66, 0x59, 0x26, + 0xdc, 0x71, 0x14, 0xa1, 0x5c, 0xae, 0xc7, 0x37, 0xac, 0x23}; + lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xfc, 0x80, 0xb0, 0x20, 0x8b, 0xd4, 0xe2, 0xd0}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x8a, 0x11, 0xa4, 0xc2, 0x17}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0}; - lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x43, 0x8b, 0xb2, 0xd2, 0xd9, 0x55, 0x28, 0x53, 0x85, 0x7}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x9a, 0x89, 0x70, 0x78, 0xf8, 0x57, 0xf5, 0x6d, 0x4b, 0xae, - 0xff, 0x29, 0x6f, 0x69, 0x1, 0xeb, 0x91, 0xe, 0x9, 0x4, - 0xbe, 0x90, 0x60, 0x25, 0x4e, 0xdb, 0xe1, 0xbd, 0xb3}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x4d, 0x55, 0x3a, 0x48, 0x35, 0xca, 0xf6, 0xf7, 0x21, 0x0, 0xa9}; + lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x7d, 0xc1, 0xed, 0x36, 0x81, 0xb4, 0x62, 0x7f, 0x88, 0xf7, 0x93, 0x57, 0x3, - 0xe5, 0x21, 0x9c, 0x6, 0xe2, 0x66, 0x73, 0x90, 0x2b, 0x7f, 0x23, 0x27, 0xca}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xcb, 0xcb, 0xb8, 0xaf, 0x62, 0xd0, 0x6e, 0xf5, 0x72, - 0xdd, 0x52, 0x3b, 0x20, 0x93, 0x6, 0x25, 0x65, 0x39, - 0xa1, 0x15, 0x47, 0x3a, 0x2d, 0x66, 0x45, 0xac, 0x80}; - lwmqtt_string_t topic_filter_s10 = {27, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x65, 0x4a, 0x81, 0xa7, 0x13, 0xb8, 0xae, 0x2a, 0x4e, 0xe4}; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = false; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31944}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3295}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1167}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12479}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4531}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 756, 11, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26543, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 16233 [("EBW",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("T\254+V h\152\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("3!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\DC3n;\202\230\SUB\132\139\138\185;\174&\231+wf\251U\f\EMGS\207\&0v\246",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\v\207\&8\151z2J\146\DC2;\214\252\DC3\139\b\232\242\&5\190\231\229~^\172\238\SI:e\SUB",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("4\212\138\243\171\200\217@\238\210[E\146\241\SO\183\128",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropMaximumPacketSize 4150,PropUserProperty "" -// "\225\134\191cV\156M\176\SUB6b\217\143\240\240\&7",PropUserProperty "\204\149" -// "\ETX\148^\149s\237\ENQ\169j\211\ETBu\248\174\143\USDT\EM\203\131\DC1r\189\&4L{\SO",PropSubscriptionIdentifier -// 30,PropTopicAliasMaximum 20950,PropMaximumQoS 106] +// SubscribeRequest 14708 [("\NULK\203\169*aQ\217\USt\161",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("1\DLE\243[3\NUL\FS\CAN\220\179\247u\159Kf\236\149\FS\231\156*w\170",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable +// 49,PropUserProperty "\b\DC4\193\219<\164\227l" "u\184N\223\&9\166\246\139P\139J\233\210\ny"] TEST(Subscribe5QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0xb3, 0x1, 0x3f, 0x69, 0x44, 0x27, 0x0, 0x0, 0x10, 0x36, 0x26, 0x0, 0x0, 0x0, 0x10, 0xe1, - 0x86, 0xbf, 0x63, 0x56, 0x9c, 0x4d, 0xb0, 0x1a, 0x36, 0x62, 0xd9, 0x8f, 0xf0, 0xf0, 0x37, 0x26, 0x0, - 0x2, 0xcc, 0x95, 0x0, 0x1c, 0x3, 0x94, 0x5e, 0x95, 0x73, 0xed, 0x5, 0xa9, 0x6a, 0xd3, 0x17, 0x75, - 0xf8, 0xae, 0x8f, 0x1f, 0x44, 0x54, 0x19, 0xcb, 0x83, 0x11, 0x72, 0xbd, 0x34, 0x4c, 0x7b, 0xe, 0xb, - 0x1e, 0x22, 0x51, 0xd6, 0x24, 0x6a, 0x0, 0x3, 0x45, 0x42, 0x57, 0x1, 0x0, 0x1, 0x6e, 0x0, 0x0, - 0x8, 0x54, 0xfe, 0x2b, 0x56, 0x20, 0x68, 0x98, 0xaa, 0x1, 0x0, 0x2, 0x33, 0x21, 0x0, 0x0, 0x1b, - 0x13, 0x6e, 0x3b, 0xca, 0xe6, 0x1a, 0x84, 0x8b, 0x8a, 0xb9, 0x3b, 0xae, 0x26, 0xe7, 0x2b, 0x77, 0x66, - 0xfb, 0x55, 0xc, 0x19, 0x47, 0x53, 0xcf, 0x30, 0x76, 0xf6, 0x0, 0x0, 0x1d, 0xb, 0xcf, 0x38, 0x97, - 0x7a, 0x32, 0x4a, 0x92, 0x12, 0x3b, 0xd6, 0xfc, 0x13, 0x8b, 0x8, 0xe8, 0xf2, 0x35, 0xbe, 0xe7, 0xe5, - 0x7e, 0x5e, 0xac, 0xee, 0xf, 0x3a, 0x65, 0x1a, 0x2, 0x0, 0x11, 0x34, 0xd4, 0x8a, 0xf3, 0xab, 0xc8, - 0xd9, 0x40, 0xee, 0xd2, 0x5b, 0x45, 0x92, 0xf1, 0xe, 0xb7, 0x80, 0x2}; + uint8_t pkt[] = {0x82, 0x49, 0x39, 0x74, 0x1e, 0x2a, 0x31, 0x26, 0x0, 0x8, 0x8, 0x14, 0xc1, 0xdb, 0x3c, + 0xa4, 0xe3, 0x6c, 0x0, 0xf, 0x75, 0xb8, 0x4e, 0xdf, 0x39, 0xa6, 0xf6, 0x8b, 0x50, 0x8b, + 0x4a, 0xe9, 0xd2, 0xa, 0x79, 0x0, 0xb, 0x0, 0x4b, 0xcb, 0xa9, 0x2a, 0x61, 0x51, 0xd9, + 0x1f, 0x74, 0xa1, 0x15, 0x0, 0x17, 0x31, 0x10, 0xf3, 0x5b, 0x33, 0x0, 0x1c, 0x18, 0xdc, + 0xb3, 0xf7, 0x75, 0x9f, 0x4b, 0x66, 0xec, 0x95, 0x1c, 0xe7, 0x9c, 0x2a, 0x77, 0xaa, 0xa}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x45, 0x42, 0x57}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x0, 0x4b, 0xcb, 0xa9, 0x2a, 0x61, 0x51, 0xd9, 0x1f, 0x74, 0xa1}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6e}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x31, 0x10, 0xf3, 0x5b, 0x33, 0x0, 0x1c, 0x18, 0xdc, 0xb3, 0xf7, 0x75, + 0x9f, 0x4b, 0x66, 0xec, 0x95, 0x1c, 0xe7, 0x9c, 0x2a, 0x77, 0xaa}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x54, 0xfe, 0x2b, 0x56, 0x20, 0x68, 0x98, 0xaa}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x33, 0x21}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x13, 0x6e, 0x3b, 0xca, 0xe6, 0x1a, 0x84, 0x8b, 0x8a, 0xb9, 0x3b, 0xae, 0x26, 0xe7, - 0x2b, 0x77, 0x66, 0xfb, 0x55, 0xc, 0x19, 0x47, 0x53, 0xcf, 0x30, 0x76, 0xf6}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb, 0xcf, 0x38, 0x97, 0x7a, 0x32, 0x4a, 0x92, 0x12, 0x3b, - 0xd6, 0xfc, 0x13, 0x8b, 0x8, 0xe8, 0xf2, 0x35, 0xbe, 0xe7, - 0xe5, 0x7e, 0x5e, 0xac, 0xee, 0xf, 0x3a, 0x65, 0x1a}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x34, 0xd4, 0x8a, 0xf3, 0xab, 0xc8, 0xd9, 0x40, 0xee, - 0xd2, 0x5b, 0x45, 0x92, 0xf1, 0xe, 0xb7, 0x80}; - lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops1[] = {0xe1, 0x86, 0xbf, 0x63, 0x56, 0x9c, 0x4d, 0xb0, - 0x1a, 0x36, 0x62, 0xd9, 0x8f, 0xf0, 0xf0, 0x37}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops3[] = {0x3, 0x94, 0x5e, 0x95, 0x73, 0xed, 0x5, 0xa9, 0x6a, 0xd3, 0x17, 0x75, 0xf8, 0xae, - 0x8f, 0x1f, 0x44, 0x54, 0x19, 0xcb, 0x83, 0x11, 0x72, 0xbd, 0x34, 0x4c, 0x7b, 0xe}; - uint8_t bytesprops2[] = {0xcc, 0x95}; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + uint8_t bytesprops1[] = {0x75, 0xb8, 0x4e, 0xdf, 0x39, 0xa6, 0xf6, 0x8b, 0x50, 0x8b, 0x4a, 0xe9, 0xd2, 0xa, 0x79}; + uint8_t bytesprops0[] = {0x8, 0x14, 0xc1, 0xdb, 0x3c, 0xa4, 0xe3, 0x6c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4150}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops2}, .v = {28, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20950}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {15, (char*)&bytesprops1}}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16233, 7, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14708, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27988 [("\215:8'\163*\137K\190_\182*\204\144\ETX\186\242\234\173\138,f\158\190",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("P7\f\231T5\214\vP\216h\NUL\DC3\b\224\SI",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\132~\184",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\235\ESC\184\223^M\136\133\196\&6\247\CAN/M\231\201c\165j\230",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("1\153n\DC1\168\129\189\149\&7+F>\DC4d\249\172\130\DC4\ACK_\177*\237C\228\f\DC4\a<]",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\238E\134\179f\SOH\209\229\239w\165\242\181\DC4\182\139\180\ETX\178!1",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("k\222\133\254$\SYN\235\a\154\140U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\254",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0})] [PropResponseTopic -// "d_\229#\234X\131\143.\233Vt\204\224\203\133",PropResponseTopic -// "\156L`\147\168\DEL\SYN\215\EOT?\193E\244\150U\255",PropReceiveMaximum 6381,PropWillDelayInterval -// 26365,PropWillDelayInterval 17069,PropServerKeepAlive 21809,PropAssignedClientIdentifier -// "J\156\247\254\ENQJ^\DC4=\f\147\232\177\128\232K\170y",PropContentType "E\144'\141\v\241~n\254\232\DLE -// \224A\170\176^\173P\133\215\220\131\244@",PropRequestProblemInformation 253,PropTopicAlias 6832,PropServerReference -// "\251m\246\246\\\215\DLE\187\238\DC3\145\232\167B|\194\207;\148\CAN\181\231\213(a:W\167\135s",PropTopicAliasMaximum -// 12908,PropResponseTopic "{\STX\231\171v\140{\b\143",PropResponseInformation -// "\\\219T\152bgR\150\139\149\255\255",PropWillDelayInterval 10586,PropMaximumQoS 183,PropServerReference -// "\217\&2\246\&5\253V\189\252\181\143\138^\DLE\150tgA\\8A",PropMaximumQoS 46,PropSubscriptionIdentifier -// 9,PropAuthenticationMethod "\204[E^\242\226\SYN!M+\216~\139O\166' y",PropReceiveMaximum -// 3271,PropMessageExpiryInterval 24796,PropSharedSubscriptionAvailable 167,PropRetainAvailable 237,PropReceiveMaximum -// 32101,PropRetainAvailable 130,PropRequestProblemInformation 100,PropReceiveMaximum 20262] +// SubscribeRequest 24735 [("I\184\193",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS2}),("C\231x)\"5\EOT\146\158\NAK\181,",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\251\n(!k\205\193u\208<\205g.\223Q\US\187[\232\\\206\DLE\148\202",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),(")",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("_\204\209\225{\194\165\&4\222'\DLE\217\157Vu6G7\181\189\DC3)q",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("_6\149\215\&3\ENQ\133\244<\b!",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS1})] [PropResponseTopic +// "`eE\153\SUBC\179\SYN\203\221\CAN\209\t\ACK",PropSharedSubscriptionAvailable 132,PropTopicAliasMaximum +// 3544,PropUserProperty "\189\234X\244\ETB\192\216" "",PropSubscriptionIdentifier 4,PropSessionExpiryInterval +// 7130,PropSessionExpiryInterval 22723,PropAuthenticationData ":\GSnz\203iH\213\136\159",PropRetainAvailable +// 210,PropTopicAlias 27169,PropSubscriptionIdentifier 10,PropResponseTopic +// "\148\US\206\ETB\251\154o\244\168\150p\199r\196\185-\178\253\&3\a\196P\r \253\220\a\SOH\192"] TEST(Subscribe5QCTest, Encode11) { - uint8_t pkt[] = { - 0x82, 0x92, 0x3, 0x6d, 0x54, 0xf8, 0x1, 0x8, 0x0, 0x10, 0x64, 0x5f, 0xe5, 0x23, 0xea, 0x58, 0x83, 0x8f, 0x2e, - 0xe9, 0x56, 0x74, 0xcc, 0xe0, 0xcb, 0x85, 0x8, 0x0, 0x10, 0x9c, 0x4c, 0x60, 0x93, 0xa8, 0x7f, 0x16, 0xd7, 0x4, - 0x3f, 0xc1, 0x45, 0xf4, 0x96, 0x55, 0xff, 0x21, 0x18, 0xed, 0x18, 0x0, 0x0, 0x66, 0xfd, 0x18, 0x0, 0x0, 0x42, - 0xad, 0x13, 0x55, 0x31, 0x12, 0x0, 0x12, 0x4a, 0x9c, 0xf7, 0xfe, 0x5, 0x4a, 0x5e, 0x14, 0x3d, 0xc, 0x93, 0xe8, - 0xb1, 0x80, 0xe8, 0x4b, 0xaa, 0x79, 0x3, 0x0, 0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 0xc3, 0x16, 0x0, 0xa, 0x3a, 0x1d, 0x6e, 0x7a, 0xcb, 0x69, 0x48, 0xd5, 0x88, 0x9f, 0x25, 0xd2, 0x23, + 0x6a, 0x21, 0xb, 0xa, 0x8, 0x0, 0x1d, 0x94, 0x1f, 0xce, 0x17, 0xfb, 0x9a, 0x6f, 0xf4, 0xa8, 0x96, + 0x70, 0xc7, 0x72, 0xc4, 0xb9, 0x2d, 0xb2, 0xfd, 0x33, 0x7, 0xc4, 0x50, 0xd, 0x20, 0xfd, 0xdc, 0x7, + 0x1, 0xc0, 0x0, 0x3, 0x49, 0xb8, 0xc1, 0x6, 0x0, 0xc, 0x43, 0xe7, 0x78, 0x29, 0x22, 0x35, 0x4, + 0x92, 0x9e, 0x15, 0xb5, 0x2c, 0x26, 0x0, 0x18, 0xfb, 0xa, 0x28, 0x21, 0x6b, 0xcd, 0xc1, 0x75, 0xd0, + 0x3c, 0xcd, 0x67, 0x2e, 0xdf, 0x51, 0x1f, 0xbb, 0x5b, 0xe8, 0x5c, 0xce, 0x10, 0x94, 0xca, 0x19, 0x0, + 0x1, 0x29, 0xc, 0x0, 0x17, 0x5f, 0xcc, 0xd1, 0xe1, 0x7b, 0xc2, 0xa5, 0x34, 0xde, 0x27, 0x10, 0xd9, + 0x9d, 0x56, 0x75, 0x36, 0x47, 0x37, 0xb5, 0xbd, 0x13, 0x29, 0x71, 0x2e, 0x0, 0xb, 0x5f, 0x36, 0x95, + 0xd7, 0x33, 0x5, 0x85, 0xf4, 0x3c, 0x8, 0x21, 0x25}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xd7, 0x3a, 0x38, 0x27, 0xa3, 0x2a, 0x89, 0x4b, 0xbe, 0x5f, 0xb6, 0x2a, - 0xcc, 0x90, 0x3, 0xba, 0xf2, 0xea, 0xad, 0x8a, 0x2c, 0x66, 0x9e, 0xbe}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x49, 0xb8, 0xc1}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x50, 0x37, 0xc, 0xe7, 0x54, 0x35, 0xd6, 0xb, - 0x50, 0xd8, 0x68, 0x0, 0x13, 0x8, 0xe0, 0xf}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x43, 0xe7, 0x78, 0x29, 0x22, 0x35, 0x4, 0x92, 0x9e, 0x15, 0xb5, 0x2c}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x84, 0x7e, 0xb8}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xfb, 0xa, 0x28, 0x21, 0x6b, 0xcd, 0xc1, 0x75, 0xd0, 0x3c, 0xcd, 0x67, + 0x2e, 0xdf, 0x51, 0x1f, 0xbb, 0x5b, 0xe8, 0x5c, 0xce, 0x10, 0x94, 0xca}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xeb, 0x1b, 0xb8, 0xdf, 0x5e, 0x4d, 0x88, 0x85, 0xc4, 0x36, - 0xf7, 0x18, 0x2f, 0x4d, 0xe7, 0xc9, 0x63, 0xa5, 0x6a, 0xe6}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x29}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x31, 0x99, 0x6e, 0x11, 0xa8, 0x81, 0xbd, 0x95, 0x37, 0x2b, - 0x46, 0x3e, 0x14, 0x64, 0xf9, 0xac, 0x82, 0x14, 0x6, 0x5f, - 0xb1, 0x2a, 0xed, 0x43, 0xe4, 0xc, 0x14, 0x7, 0x3c, 0x5d}; - lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x5f, 0xcc, 0xd1, 0xe1, 0x7b, 0xc2, 0xa5, 0x34, 0xde, 0x27, 0x10, 0xd9, + 0x9d, 0x56, 0x75, 0x36, 0x47, 0x37, 0xb5, 0xbd, 0x13, 0x29, 0x71}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xee, 0x45, 0x86, 0xb3, 0x66, 0x1, 0xd1, 0xe5, 0xef, 0x77, 0xa5, - 0xf2, 0xb5, 0x14, 0xb6, 0x8b, 0xb4, 0x3, 0xb2, 0x21, 0x31}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x5f, 0x36, 0x95, 0xd7, 0x33, 0x5, 0x85, 0xf4, 0x3c, 0x8, 0x21}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6b, 0xde, 0x85, 0xfe, 0x24, 0x16, 0xeb, 0x7, 0x9a, 0x8c, 0x55}; - lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xfe}; - lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0}; - uint8_t bytesprops0[] = {0x64, 0x5f, 0xe5, 0x23, 0xea, 0x58, 0x83, 0x8f, - 0x2e, 0xe9, 0x56, 0x74, 0xcc, 0xe0, 0xcb, 0x85}; - uint8_t bytesprops1[] = {0x9c, 0x4c, 0x60, 0x93, 0xa8, 0x7f, 0x16, 0xd7, - 0x4, 0x3f, 0xc1, 0x45, 0xf4, 0x96, 0x55, 0xff}; - uint8_t bytesprops2[] = {0x4a, 0x9c, 0xf7, 0xfe, 0x5, 0x4a, 0x5e, 0x14, 0x3d, - 0xc, 0x93, 0xe8, 0xb1, 0x80, 0xe8, 0x4b, 0xaa, 0x79}; - uint8_t bytesprops3[] = {0x45, 0x90, 0x27, 0x8d, 0xb, 0xf1, 0x7e, 0x6e, 0xfe, 0xe8, 0x10, 0x20, 0xe0, - 0x41, 0xaa, 0xb0, 0x5e, 0xad, 0x50, 0x85, 0xd7, 0xdc, 0x83, 0xf4, 0x40}; - uint8_t bytesprops4[] = {0xfb, 0x6d, 0xf6, 0xf6, 0x5c, 0xd7, 0x10, 0xbb, 0xee, 0x13, 0x91, 0xe8, 0xa7, 0x42, 0x7c, - 0xc2, 0xcf, 0x3b, 0x94, 0x18, 0xb5, 0xe7, 0xd5, 0x28, 0x61, 0x3a, 0x57, 0xa7, 0x87, 0x73}; - uint8_t bytesprops5[] = {0x7b, 0x2, 0xe7, 0xab, 0x76, 0x8c, 0x7b, 0x8, 0x8f}; - uint8_t bytesprops6[] = {0x5c, 0xdb, 0x54, 0x98, 0x62, 0x67, 0x52, 0x96, 0x8b, 0x95, 0xff, 0xff}; - uint8_t bytesprops7[] = {0xd9, 0x32, 0xf6, 0x35, 0xfd, 0x56, 0xbd, 0xfc, 0xb5, 0x8f, - 0x8a, 0x5e, 0x10, 0x96, 0x74, 0x67, 0x41, 0x5c, 0x38, 0x41}; - uint8_t bytesprops8[] = {0xcc, 0x5b, 0x45, 0x5e, 0xf2, 0xe2, 0x16, 0x21, 0x4d, - 0x2b, 0xd8, 0x7e, 0x8b, 0x4f, 0xa6, 0x27, 0x20, 0x79}; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + uint8_t bytesprops0[] = {0x60, 0x65, 0x45, 0x99, 0x1a, 0x43, 0xb3, 0x16, 0xcb, 0xdd, 0x18, 0xd1, 0x9, 0x6}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops1[] = {0xbd, 0xea, 0x58, 0xf4, 0x17, 0xc0, 0xd8}; + uint8_t bytesprops3[] = {0x3a, 0x1d, 0x6e, 0x7a, 0xcb, 0x69, 0x48, 0xd5, 0x88, 0x9f}; + uint8_t bytesprops4[] = {0x94, 0x1f, 0xce, 0x17, 0xfb, 0x9a, 0x6f, 0xf4, 0xa8, 0x96, 0x70, 0xc7, 0x72, 0xc4, 0xb9, + 0x2d, 0xb2, 0xfd, 0x33, 0x7, 0xc4, 0x50, 0xd, 0x20, 0xfd, 0xdc, 0x7, 0x1, 0xc0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6381}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26365}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17069}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21809}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6832}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12908}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10586}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3271}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24796}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32101}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20262}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3544}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops1}, .v = {0, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7130}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22723}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27169}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27988, 8, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 19880 [("\163\224\DC4H\243\234r\170\191\212<\172Q\159\207\205\131=\189\132W",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\DLE\190\ETXgAE\133z \251",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("4 ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\229\210&\235\147\255",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\GS{\223`IldKX@9",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\198W8*B\175+,@\234j\200\209\167\187",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("\203#\222\STX\217\221[6\138\196[\189\236\190\187Q\225\143+]\183U\141lq\242\SI\253",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropTopicAlias -// 30972,PropReceiveMaximum 9117,PropServerKeepAlive 29875,PropMessageExpiryInterval -// 17362,PropWildcardSubscriptionAvailable 2,PropSubscriptionIdentifierAvailable 204,PropSharedSubscriptionAvailable -// 168,PropMaximumQoS 53,PropTopicAlias 30987,PropSharedSubscriptionAvailable 55,PropServerReference -// "\204q\192\US\138d\224\139j\162\NUL\240\b\EOT\227\\KP\157\148\198\135x\166\193]\ETB\198",PropWildcardSubscriptionAvailable -// 254,PropPayloadFormatIndicator 244,PropSessionExpiryInterval 21471] + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24735, 6, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 31752 [("_\219L\240F\160\245'\201\213\145D\221\235\219\250\233\&8\211\&6\154\154\235",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\205g~\180H*@/\252|\213\208\227\DC1\184-\238\128\169\237E",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\186\144",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("p\172",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("E\ETB\215\130\164\130",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal +// = False, _subQoS = QoS0}),("\v\203N\139\228\165wx\175\155\n\231\195\176",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropSubscriptionIdentifier +// 2,PropTopicAliasMaximum 19084,PropSharedSubscriptionAvailable 18,PropAssignedClientIdentifier +// "\183\tTVl\186\181\247\178\171\165\229r}\218\&2F\219\173a",PropWillDelayInterval 16542,PropResponseTopic +// "<\242n,\241U\149\STX\148`\177\157n\252%\164'\187\187\165q\a\SYNz\178d",PropUserProperty +// "!\231\NAKl\161jI\130\&5\151z\237\142\STX\239\137\165N\235\202\216\DC4\150\224\164o\167Y\SYN\v" +// "\176\NAK\174&\SOH\149\188\225\DELr`1\DC4?\144<\194\244\133\168,CrG",PropCorrelationData +// "\171\171\133Z?ge!p4S\FSV\231\169\183\170\190b\201\ETX!\128\\",PropAuthenticationMethod +// "e^}v\204\245\205\vic\130@:\185 W\230\225)\ESCY!RP",PropResponseTopic "0N\168\235\166\216>\165\ACKg",PropTopicAlias +// 14415,PropServerKeepAlive 16075,PropSessionExpiryInterval 7034,PropAssignedClientIdentifier "",PropCorrelationData +// ".\184l$\168\168\209\&5Na\ETX",PropRetainAvailable 204,PropAuthenticationData "",PropContentType +// "\130\NUL\215\NAK\197\154\172\188F\200z\RS\131,1\200mng",PropTopicAliasMaximum 20411,PropRetainAvailable +// 78,PropSharedSubscriptionAvailable 227,PropWildcardSubscriptionAvailable 58,PropMessageExpiryInterval 9835] TEST(Subscribe5QCTest, Encode12) { - uint8_t pkt[] = {0x82, 0xb8, 0x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 0xa, 0x30, 0x4e, 0xa8, + 0xeb, 0xa6, 0xd8, 0x3e, 0xa5, 0x6, 0x67, 0x23, 0x38, 0x4f, 0x13, 0x3e, 0xcb, 0x11, 0x0, 0x0, 0x1b, 0x7a, 0x12, + 0x0, 0x0, 0x9, 0x0, 0xb, 0x2e, 0xb8, 0x6c, 0x24, 0xa8, 0xa8, 0xd1, 0x35, 0x4e, 0x61, 0x3, 0x25, 0xcc, 0x16, + 0x0, 0x0, 0x3, 0x0, 0x13, 0x82, 0x0, 0xd7, 0x15, 0xc5, 0x9a, 0xac, 0xbc, 0x46, 0xc8, 0x7a, 0x1e, 0x83, 0x2c, + 0x31, 0xc8, 0x6d, 0x6e, 0x67, 0x22, 0x4f, 0xbb, 0x25, 0x4e, 0x2a, 0xe3, 0x28, 0x3a, 0x2, 0x0, 0x0, 0x26, 0x6b, + 0x0, 0x17, 0x5f, 0xdb, 0x4c, 0xf0, 0x46, 0xa0, 0xf5, 0x27, 0xc9, 0xd5, 0x91, 0x44, 0xdd, 0xeb, 0xdb, 0xfa, 0xe9, + 0x38, 0xd3, 0x36, 0x9a, 0x9a, 0xeb, 0x5, 0x0, 0x15, 0xcd, 0x67, 0x7e, 0xb4, 0x48, 0x2a, 0x40, 0x2f, 0xfc, 0x7c, + 0xd5, 0xd0, 0xe3, 0x11, 0xb8, 0x2d, 0xee, 0x80, 0xa9, 0xed, 0x45, 0x19, 0x0, 0x2, 0xba, 0x90, 0x4, 0x0, 0x2, + 0x70, 0xac, 0x11, 0x0, 0x6, 0x45, 0x17, 0xd7, 0x82, 0xa4, 0x82, 0x18, 0x0, 0xe, 0xb, 0xcb, 0x4e, 0x8b, 0xe4, + 0xa5, 0x77, 0x78, 0xaf, 0x9b, 0xa, 0xe7, 0xc3, 0xb0, 0x8}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xa3, 0xe0, 0x14, 0x48, 0xf3, 0xea, 0x72, 0xaa, 0xbf, 0xd4, 0x3c, - 0xac, 0x51, 0x9f, 0xcf, 0xcd, 0x83, 0x3d, 0xbd, 0x84, 0x57}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x5f, 0xdb, 0x4c, 0xf0, 0x46, 0xa0, 0xf5, 0x27, 0xc9, 0xd5, 0x91, 0x44, + 0xdd, 0xeb, 0xdb, 0xfa, 0xe9, 0x38, 0xd3, 0x36, 0x9a, 0x9a, 0xeb}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x10, 0xbe, 0x3, 0x67, 0x41, 0x45, 0x85, 0x7a, 0x20, 0xfb}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xcd, 0x67, 0x7e, 0xb4, 0x48, 0x2a, 0x40, 0x2f, 0xfc, 0x7c, 0xd5, + 0xd0, 0xe3, 0x11, 0xb8, 0x2d, 0xee, 0x80, 0xa9, 0xed, 0x45}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x34, 0x20}; + uint8_t topic_filter_s2_bytes[] = {0xba, 0x90}; lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe5, 0xd2, 0x26, 0xeb, 0x93, 0xff}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x70, 0xac}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x1d, 0x7b, 0xdf, 0x60, 0x49, 0x6c, 0x64, 0x4b, 0x58, 0x40, 0x39}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x45, 0x17, 0xd7, 0x82, 0xa4, 0x82}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc6, 0x57, 0x38, 0x2a, 0x42, 0xaf, 0x2b, 0x2c, - 0x40, 0xea, 0x6a, 0xc8, 0xd1, 0xa7, 0xbb}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xb, 0xcb, 0x4e, 0x8b, 0xe4, 0xa5, 0x77, 0x78, 0xaf, 0x9b, 0xa, 0xe7, 0xc3, 0xb0}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xcb, 0x23, 0xde, 0x2, 0xd9, 0xdd, 0x5b, 0x36, 0x8a, 0xc4, - 0x5b, 0xbd, 0xec, 0xbe, 0xbb, 0x51, 0xe1, 0x8f, 0x2b, 0x5d, - 0xb7, 0x55, 0x8d, 0x6c, 0x71, 0xf2, 0xf, 0xfd}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xcc, 0x71, 0xc0, 0x1f, 0x8a, 0x64, 0xe0, 0x8b, 0x6a, 0xa2, 0x0, 0xf0, 0x8, 0x4, - 0xe3, 0x5c, 0x4b, 0x50, 0x9d, 0x94, 0xc6, 0x87, 0x78, 0xa6, 0xc1, 0x5d, 0x17, 0xc6}; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + uint8_t bytesprops0[] = {0xb7, 0x9, 0x54, 0x56, 0x6c, 0xba, 0xb5, 0xf7, 0xb2, 0xab, + 0xa5, 0xe5, 0x72, 0x7d, 0xda, 0x32, 0x46, 0xdb, 0xad, 0x61}; + uint8_t bytesprops1[] = {0x3c, 0xf2, 0x6e, 0x2c, 0xf1, 0x55, 0x95, 0x2, 0x94, 0x60, 0xb1, 0x9d, 0x6e, + 0xfc, 0x25, 0xa4, 0x27, 0xbb, 0xbb, 0xa5, 0x71, 0x7, 0x16, 0x7a, 0xb2, 0x64}; + uint8_t bytesprops3[] = {0xb0, 0x15, 0xae, 0x26, 0x1, 0x95, 0xbc, 0xe1, 0x7f, 0x72, 0x60, 0x31, + 0x14, 0x3f, 0x90, 0x3c, 0xc2, 0xf4, 0x85, 0xa8, 0x2c, 0x43, 0x72, 0x47}; + uint8_t bytesprops2[] = {0x21, 0xe7, 0x15, 0x6c, 0xa1, 0x6a, 0x49, 0x82, 0x35, 0x97, 0x7a, 0xed, 0x8e, 0x2, 0xef, + 0x89, 0xa5, 0x4e, 0xeb, 0xca, 0xd8, 0x14, 0x96, 0xe0, 0xa4, 0x6f, 0xa7, 0x59, 0x16, 0xb}; + uint8_t bytesprops4[] = {0xab, 0xab, 0x85, 0x5a, 0x3f, 0x67, 0x65, 0x21, 0x70, 0x34, 0x53, 0x1c, + 0x56, 0xe7, 0xa9, 0xb7, 0xaa, 0xbe, 0x62, 0xc9, 0x3, 0x21, 0x80, 0x5c}; + uint8_t bytesprops5[] = {0x65, 0x5e, 0x7d, 0x76, 0xcc, 0xf5, 0xcd, 0xb, 0x69, 0x63, 0x82, 0x40, + 0x3a, 0xb9, 0x20, 0x57, 0xe6, 0xe1, 0x29, 0x1b, 0x59, 0x21, 0x52, 0x50}; + uint8_t bytesprops6[] = {0x30, 0x4e, 0xa8, 0xeb, 0xa6, 0xd8, 0x3e, 0xa5, 0x6, 0x67}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops8[] = {0x2e, 0xb8, 0x6c, 0x24, 0xa8, 0xa8, 0xd1, 0x35, 0x4e, 0x61, 0x3}; + uint8_t bytesprops9[] = {0}; + uint8_t bytesprops10[] = {0x82, 0x0, 0xd7, 0x15, 0xc5, 0x9a, 0xac, 0xbc, 0x46, 0xc8, + 0x7a, 0x1e, 0x83, 0x2c, 0x31, 0xc8, 0x6d, 0x6e, 0x67}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30972}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9117}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29875}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17362}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30987}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21471}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19084}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16542}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops2}, .v = {24, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14415}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16075}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7034}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20411}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9835}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19880, 7, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31752, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22493 [("\227\138\DC4\248mr\146&d\209\219",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropSharedSubscriptionAvailable -// 208,PropResponseInformation "~(V\245\SOH\236\143",PropWildcardSubscriptionAvailable 201,PropUserProperty -// "\156\177I\194E\195\169\232V\196\166\&5\130\247#]\136\169u\ESC\DEL\184\166z\128[N\186" -// "\EM\144:p\228\231\FS\251\253~h\200",PropRequestProblemInformation 81,PropWildcardSubscriptionAvailable -// 59,PropRequestResponseInformation 245,PropServerReference -// "\170_\134\181idH\138\173\DC1\172\EMd\DC1i\130\189",PropRequestProblemInformation 89,PropRequestProblemInformation -// 41,PropServerKeepAlive 7095,PropResponseTopic -// "\165\137\t\r\225(G\179\185\EOT\248\DC1\243\169N\179\138\229",PropTopicAlias -// 13371,PropSubscriptionIdentifierAvailable 164,PropSharedSubscriptionAvailable 22,PropMessageExpiryInterval -// 4425,PropRequestResponseInformation 171,PropAuthenticationMethod -// "X\bf\198\173\241Q-\169h\140\220\n\131p\143\156\DLEx\215C",PropWillDelayInterval 31817,PropSessionExpiryInterval -// 18161,PropMessageExpiryInterval 28296] +// SubscribeRequest 12709 [("\132\197\232\176\128>\167\NAKa",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\178\242Do\205\129\176\135\169\245\194\STXX|\196\207\227\196\169\\\DLE\175\138\200\v\186\135yL\172",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("@f\171\247\189\153\191\162\&66\248\191:\167\234nw\220R\195\&3\SOH72\235\a\EOTx",SubOptions {_retainHandling +// = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\241\135Z\182\210O\202\248\&6\NAK\215\DC2\217\EOT\171\128\173.\183\138qM]l\198_",SubOptions {_retainHandling +// = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("{\ESCA\ETX\233J}\147\DC3",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\242L\245\r\189\187\206",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("{4\GS\t\194H\206\FS\176",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\203\247\\`[\193",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\153\164\176\228\218\162\198\231\SI\135_\\P\249\176\169\200S",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("8\193\250\178\180`\161\204\240\245\129/\NAK\137\242\233f\NUL\179\171\US\157\197tX'",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\193\229\147&\176\150P\DC1}\195\SI\203!V\185\SO-YK\193\131K\195\149\211",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropWillDelayInterval +// 2229,PropSubscriptionIdentifier 19,PropRequestResponseInformation 88,PropSessionExpiryInterval +// 25640,PropWillDelayInterval 29275,PropResponseInformation +// "\DC4\240\232\247\149\179\237\218xHW\DLEp\157\171\&3\NAKs\129P~\174",PropRequestProblemInformation +// 118,PropRequestResponseInformation 219,PropCorrelationData "*\250\201h\v",PropAssignedClientIdentifier +// "",PropServerReference "@\245\220\131\163\182Q~\134\RS\220\&2\138+Le!H\155\152\187\195",PropWillDelayInterval +// 27690,PropMessageExpiryInterval 15595,PropUserProperty "" +// "\199_\140\137\236\USt\188c\249n\137kF#\r\153e\157RqA}\165\235\232",PropServerReference "K\n\SYN",PropServerReference +// "\239\162\DC1\229i\233\150\187=\n\204\226\153\243\199\234\167N+jY\136\214\175\155\182",PropSubscriptionIdentifierAvailable +// 171,PropTopicAliasMaximum 22343,PropUserProperty "\SYN\134g,,\177" +// "*<\184i\157@\NUL\249\137\171e]\196\235\151./>!*\FS'\170\252\252\213#",PropUserProperty +// "&\134\v\150^\SOo{\209\211l\229\239^:" +// "9\140\NUL\248A\DEL\199F\246\130\DC2\138Qt\233\DELY\187\DELON\229\199\&6E\149\172",PropWillDelayInterval +// 26714,PropSessionExpiryInterval 31256,PropTopicAliasMaximum 6163,PropAssignedClientIdentifier +// "\178\FS\211\248\191\&8\154\186\134Fv\163\199X\235\196/\236\164\SYN\152\192\232'\251PJ)W",PropMessageExpiryInterval +// 16327,PropReasonString "DH\248\248x\174\176\191 \155\128\t\237\140\191\239",PropWildcardSubscriptionAvailable +// 228,PropTopicAliasMaximum 3438,PropContentType "\173$\173\240\178\187\171\nJ\172~8\\",PropPayloadFormatIndicator 150] TEST(Subscribe5QCTest, Encode13) { - uint8_t pkt[] = {0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0x96, 0x50, 0x11, 0x7d, 0xc3, 0xf, 0xcb, 0x21, 0x56, 0xb9, 0xe, 0x2d, 0x59, 0x4b, 0xc1, 0x83, + 0x4b, 0xc3, 0x95, 0xd3, 0x15}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xe3, 0x8a, 0x14, 0xf8, 0x6d, 0x72, 0x92, 0x26, 0x64, 0xd1, 0xdb}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x84, 0xc5, 0xe8, 0xb0, 0x80, 0x3e, 0xa7, 0x15, 0x61}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x7e, 0x28, 0x56, 0xf5, 0x1, 0xec, 0x8f}; - uint8_t bytesprops2[] = {0x19, 0x90, 0x3a, 0x70, 0xe4, 0xe7, 0x1c, 0xfb, 0xfd, 0x7e, 0x68, 0xc8}; - uint8_t bytesprops1[] = {0x9c, 0xb1, 0x49, 0xc2, 0x45, 0xc3, 0xa9, 0xe8, 0x56, 0xc4, 0xa6, 0x35, 0x82, 0xf7, - 0x23, 0x5d, 0x88, 0xa9, 0x75, 0x1b, 0x7f, 0xb8, 0xa6, 0x7a, 0x80, 0x5b, 0x4e, 0xba}; - uint8_t bytesprops3[] = {0xaa, 0x5f, 0x86, 0xb5, 0x69, 0x64, 0x48, 0x8a, 0xad, - 0x11, 0xac, 0x19, 0x64, 0x11, 0x69, 0x82, 0xbd}; - uint8_t bytesprops4[] = {0xa5, 0x89, 0x9, 0xd, 0xe1, 0x28, 0x47, 0xb3, 0xb9, - 0x4, 0xf8, 0x11, 0xf3, 0xa9, 0x4e, 0xb3, 0x8a, 0xe5}; - uint8_t bytesprops5[] = {0x58, 0x8, 0x66, 0xc6, 0xad, 0xf1, 0x51, 0x2d, 0xa9, 0x68, 0x8c, - 0xdc, 0xa, 0x83, 0x70, 0x8f, 0x9c, 0x10, 0x78, 0xd7, 0x43}; + uint8_t topic_filter_s1_bytes[] = {0xb2, 0xf2, 0x44, 0x6f, 0xcd, 0x81, 0xb0, 0x87, 0xa9, 0xf5, + 0xc2, 0x2, 0x58, 0x7c, 0xc4, 0xcf, 0xe3, 0xc4, 0xa9, 0x5c, + 0x10, 0xaf, 0x8a, 0xc8, 0xb, 0xba, 0x87, 0x79, 0x4c, 0xac}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x40, 0x66, 0xab, 0xf7, 0xbd, 0x99, 0xbf, 0xa2, 0x36, 0x36, + 0xf8, 0xbf, 0x3a, 0xa7, 0xea, 0x6e, 0x77, 0xdc, 0x52, 0xc3, + 0x33, 0x1, 0x37, 0x32, 0xeb, 0x7, 0x4, 0x78}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf1, 0x87, 0x5a, 0xb6, 0xd2, 0x4f, 0xca, 0xf8, 0x36, 0x15, 0xd7, 0x12, 0xd9, + 0x4, 0xab, 0x80, 0xad, 0x2e, 0xb7, 0x8a, 0x71, 0x4d, 0x5d, 0x6c, 0xc6, 0x5f}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x7b, 0x1b, 0x41, 0x3, 0xe9, 0x4a, 0x7d, 0x93, 0x13}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf2, 0x4c, 0xf5, 0xd, 0xbd, 0xbb, 0xce}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x7b, 0x34, 0x1d, 0x9, 0xc2, 0x48, 0xce, 0x1c, 0xb0}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xcb, 0xf7, 0x5c, 0x60, 0x5b, 0xc1}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x99, 0xa4, 0xb0, 0xe4, 0xda, 0xa2, 0xc6, 0xe7, 0xf, + 0x87, 0x5f, 0x5c, 0x50, 0xf9, 0xb0, 0xa9, 0xc8, 0x53}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x38, 0xc1, 0xfa, 0xb2, 0xb4, 0x60, 0xa1, 0xcc, 0xf0, 0xf5, 0x81, 0x2f, 0x15, + 0x89, 0xf2, 0xe9, 0x66, 0x0, 0xb3, 0xab, 0x1f, 0x9d, 0xc5, 0x74, 0x58, 0x27}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xc1, 0xe5, 0x93, 0x26, 0xb0, 0x96, 0x50, 0x11, 0x7d, 0xc3, 0xf, 0xcb, 0x21, + 0x56, 0xb9, 0xe, 0x2d, 0x59, 0x4b, 0xc1, 0x83, 0x4b, 0xc3, 0x95, 0xd3}; + lwmqtt_string_t topic_filter_s10 = {25, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = true; + uint8_t bytesprops0[] = {0x14, 0xf0, 0xe8, 0xf7, 0x95, 0xb3, 0xed, 0xda, 0x78, 0x48, 0x57, + 0x10, 0x70, 0x9d, 0xab, 0x33, 0x15, 0x73, 0x81, 0x50, 0x7e, 0xae}; + uint8_t bytesprops1[] = {0x2a, 0xfa, 0xc9, 0x68, 0xb}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x40, 0xf5, 0xdc, 0x83, 0xa3, 0xb6, 0x51, 0x7e, 0x86, 0x1e, 0xdc, + 0x32, 0x8a, 0x2b, 0x4c, 0x65, 0x21, 0x48, 0x9b, 0x98, 0xbb, 0xc3}; + uint8_t bytesprops5[] = {0xc7, 0x5f, 0x8c, 0x89, 0xec, 0x1f, 0x74, 0xbc, 0x63, 0xf9, 0x6e, 0x89, 0x6b, + 0x46, 0x23, 0xd, 0x99, 0x65, 0x9d, 0x52, 0x71, 0x41, 0x7d, 0xa5, 0xeb, 0xe8}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops6[] = {0x4b, 0xa, 0x16}; + uint8_t bytesprops7[] = {0xef, 0xa2, 0x11, 0xe5, 0x69, 0xe9, 0x96, 0xbb, 0x3d, 0xa, 0xcc, 0xe2, 0x99, + 0xf3, 0xc7, 0xea, 0xa7, 0x4e, 0x2b, 0x6a, 0x59, 0x88, 0xd6, 0xaf, 0x9b, 0xb6}; + uint8_t bytesprops9[] = {0x2a, 0x3c, 0xb8, 0x69, 0x9d, 0x40, 0x0, 0xf9, 0x89, 0xab, 0x65, 0x5d, 0xc4, 0xeb, + 0x97, 0x2e, 0x2f, 0x3e, 0x21, 0x2a, 0x1c, 0x27, 0xaa, 0xfc, 0xfc, 0xd5, 0x23}; + uint8_t bytesprops8[] = {0x16, 0x86, 0x67, 0x2c, 0x2c, 0xb1}; + uint8_t bytesprops11[] = {0x39, 0x8c, 0x0, 0xf8, 0x41, 0x7f, 0xc7, 0x46, 0xf6, 0x82, 0x12, 0x8a, 0x51, 0x74, + 0xe9, 0x7f, 0x59, 0xbb, 0x7f, 0x4f, 0x4e, 0xe5, 0xc7, 0x36, 0x45, 0x95, 0xac}; + uint8_t bytesprops10[] = {0x26, 0x86, 0xb, 0x96, 0x5e, 0xe, 0x6f, 0x7b, 0xd1, 0xd3, 0x6c, 0xe5, 0xef, 0x5e, 0x3a}; + uint8_t bytesprops12[] = {0xb2, 0x1c, 0xd3, 0xf8, 0xbf, 0x38, 0x9a, 0xba, 0x86, 0x46, 0x76, 0xa3, 0xc7, 0x58, 0xeb, + 0xc4, 0x2f, 0xec, 0xa4, 0x16, 0x98, 0xc0, 0xe8, 0x27, 0xfb, 0x50, 0x4a, 0x29, 0x57}; + uint8_t bytesprops13[] = {0x44, 0x48, 0xf8, 0xf8, 0x78, 0xae, 0xb0, 0xbf, + 0x20, 0x9b, 0x80, 0x9, 0xed, 0x8c, 0xbf, 0xef}; + uint8_t bytesprops14[] = {0xad, 0x24, 0xad, 0xf0, 0xb2, 0xbb, 0xab, 0xa, 0x4a, 0xac, 0x7e, 0x38, 0x5c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops1}, .v = {12, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7095}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13371}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4425}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31817}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18161}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28296}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2229}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25640}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29275}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27690}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15595}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops4}, .v = {26, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22343}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops8}, .v = {27, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {15, (char*)&bytesprops10}, .v = {27, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26714}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31256}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6163}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16327}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3438}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 150}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22493, 1, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 32664 [("\244\185\249\145\SUB\GS\167&\200\201\187E=\184\234\232",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("i\217U\176\198\245\226",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("[gE\131-\185\148\217\a\169\&5(\185\236?\187\171\208\130\242\SIdq\SO\USND",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(" -// Y\246\139\\xj\202)\182v\166\bFEb\245H\130",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\160\&3\132\234x\252\200\NUL]\134",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\211\139\255*\EOT\232\243\147D\252\SI\215\&5F\SIF[\209\SUBw\195I\130",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAuthenticationData -// "G\DC3\137\129k\175\DC3\204",PropAuthenticationMethod ""] + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12709, 11, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 14473 [("\173\230\ESC\133\246\196\156\135\200q|\DC2\188\236\FS\153\183\SO\142b",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\CAN\192\&41\164\131Z8\251)\173>\128\193\211\222\167G\162\167\149}\129\174",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("g\226\&6wT\129\254\179\NUL\228\163\218\238\131\130\198\131\172\r\"\223\195\172\130",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("u\138\167\DEL\SI\167\172\136\244\217\249\185\239B\228y",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\193\254#\159\210\150\130\"\250",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\236\179\227\206P\141i\DC3\EM\237\243\232\"cG\151\199\190I",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropTopicAliasMaximum +// 7848,PropSessionExpiryInterval 28305,PropRetainAvailable 225,PropMessageExpiryInterval +// 4567,PropAssignedClientIdentifier "G\192\174\165~\DEL",PropMaximumQoS 183,PropUserProperty +// "\185\193\SYN\221\SO\a\200\192\139\162\DLE\160\&0\203\246\212Qi" +// "?\213\174\bf\SIV!ZS\175zUv\EOT\151\&3&",PropSessionExpiryInterval 20670,PropReasonString +// "y\USs\152\220fZ\248\SUB\128\213",PropSharedSubscriptionAvailable 149,PropCorrelationData +// "\249\154\ETB]\205\222(\249^\178\147+}E\244%\DLE\187y\250\&6\173\ENQa\228",PropAssignedClientIdentifier +// "\217\199\GS\158\EOTt\213Un@H\EOT\191",PropAuthenticationMethod +// "\186\&9\SI\210!\245\STX\153T\243X\250;\199\177Z\204\208\238\227ub\SUB6\STXyg\207G",PropRequestResponseInformation +// 63,PropMaximumPacketSize 31623,PropAuthenticationData +// "\228M\248\139\SO\177l\213A=\140\215\202\189\&8\a\149\241\DC1^0\185p\134\130\140B9",PropAssignedClientIdentifier +// "\255\&4\168\224_#\149\SO\EOT\245",PropServerReference +// "\201*n_\186\138hW\237\196<\177nD\174\153\203B\230^\236\151\DC4\SUB\n]\235\240\146\216",PropRequestResponseInformation +// 82,PropCorrelationData "\ESC\155E:\153\195\130\ETB^0\249}\SUB\185=n",PropRequestResponseInformation +// 153,PropReasonString "\240\&3\t5",PropTopicAlias 29714,PropWillDelayInterval 22439,PropTopicAlias +// 29750,PropRequestResponseInformation 201,PropSubscriptionIdentifierAvailable 27] TEST(Subscribe5QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0x89, 0x1, 0x7f, 0x98, 0xe, 0x16, 0x0, 0x8, 0x47, 0x13, 0x89, 0x81, 0x6b, 0xaf, 0x13, - 0xcc, 0x15, 0x0, 0x0, 0x0, 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b, 0xf0, 0x92, 0xd8, 0x19, 0x52, 0x9, 0x0, 0x10, 0x1b, 0x9b, 0x45, 0x3a, 0x99, 0xc3, + 0x82, 0x17, 0x5e, 0x30, 0xf9, 0x7d, 0x1a, 0xb9, 0x3d, 0x6e, 0x19, 0x99, 0x1f, 0x0, 0x4, 0xf0, 0x33, 0x9, 0x35, + 0x23, 0x74, 0x12, 0x18, 0x0, 0x0, 0x57, 0xa7, 0x23, 0x74, 0x36, 0x19, 0xc9, 0x29, 0x1b, 0x0, 0x14, 0xad, 0xe6, + 0x1b, 0x85, 0xf6, 0xc4, 0x9c, 0x87, 0xc8, 0x71, 0x7c, 0x12, 0xbc, 0xec, 0x1c, 0x99, 0xb7, 0xe, 0x8e, 0x62, 0x18, + 0x0, 0x18, 0x18, 0xc0, 0x34, 0x31, 0xa4, 0x83, 0x5a, 0x38, 0xfb, 0x29, 0xad, 0x3e, 0x80, 0xc1, 0xd3, 0xde, 0xa7, + 0x47, 0xa2, 0xa7, 0x95, 0x7d, 0x81, 0xae, 0x6, 0x0, 0x18, 0x67, 0xe2, 0x36, 0x77, 0x54, 0x81, 0xfe, 0xb3, 0x0, + 0xe4, 0xa3, 0xda, 0xee, 0x83, 0x82, 0xc6, 0x83, 0xac, 0xd, 0x22, 0xdf, 0xc3, 0xac, 0x82, 0x29, 0x0, 0x10, 0x75, + 0x8a, 0xa7, 0x7f, 0xf, 0xa7, 0xac, 0x88, 0xf4, 0xd9, 0xf9, 0xb9, 0xef, 0x42, 0xe4, 0x79, 0x18, 0x0, 0x9, 0xc1, + 0xfe, 0x23, 0x9f, 0xd2, 0x96, 0x82, 0x22, 0xfa, 0x2c, 0x0, 0x13, 0xec, 0xb3, 0xe3, 0xce, 0x50, 0x8d, 0x69, 0x13, + 0x19, 0xed, 0xf3, 0xe8, 0x22, 0x63, 0x47, 0x97, 0xc7, 0xbe, 0x49, 0x20}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xf4, 0xb9, 0xf9, 0x91, 0x1a, 0x1d, 0xa7, 0x26, - 0xc8, 0xc9, 0xbb, 0x45, 0x3d, 0xb8, 0xea, 0xe8}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xad, 0xe6, 0x1b, 0x85, 0xf6, 0xc4, 0x9c, 0x87, 0xc8, 0x71, + 0x7c, 0x12, 0xbc, 0xec, 0x1c, 0x99, 0xb7, 0xe, 0x8e, 0x62}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x69, 0xd9, 0x55, 0xb0, 0xc6, 0xf5, 0xe2}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x18, 0xc0, 0x34, 0x31, 0xa4, 0x83, 0x5a, 0x38, 0xfb, 0x29, 0xad, 0x3e, + 0x80, 0xc1, 0xd3, 0xde, 0xa7, 0x47, 0xa2, 0xa7, 0x95, 0x7d, 0x81, 0xae}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5b, 0x67, 0x45, 0x83, 0x2d, 0xb9, 0x94, 0xd9, 0x7, 0xa9, 0x35, 0x28, 0xb9, 0xec, - 0x3f, 0xbb, 0xab, 0xd0, 0x82, 0xf2, 0xf, 0x64, 0x71, 0xe, 0x1f, 0x4e, 0x44}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x67, 0xe2, 0x36, 0x77, 0x54, 0x81, 0xfe, 0xb3, 0x0, 0xe4, 0xa3, 0xda, + 0xee, 0x83, 0x82, 0xc6, 0x83, 0xac, 0xd, 0x22, 0xdf, 0xc3, 0xac, 0x82}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x20, 0x59, 0xf6, 0x8b, 0x5c, 0x78, 0x6a, 0xca, 0x29, 0xb6, - 0x76, 0xa6, 0x8, 0x46, 0x45, 0x62, 0xf5, 0x48, 0x82}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x75, 0x8a, 0xa7, 0x7f, 0xf, 0xa7, 0xac, 0x88, + 0xf4, 0xd9, 0xf9, 0xb9, 0xef, 0x42, 0xe4, 0x79}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa0, 0x33, 0x84, 0xea, 0x78, 0xfc, 0xc8, 0x0, 0x5d, 0x86}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc1, 0xfe, 0x23, 0x9f, 0xd2, 0x96, 0x82, 0x22, 0xfa}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xd3, 0x8b, 0xff, 0x2a, 0x4, 0xe8, 0xf3, 0x93, 0x44, 0xfc, 0xf, 0xd7, - 0x35, 0x46, 0xf, 0x46, 0x5b, 0xd1, 0x1a, 0x77, 0xc3, 0x49, 0x82}; - lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xec, 0xb3, 0xe3, 0xce, 0x50, 0x8d, 0x69, 0x13, 0x19, 0xed, + 0xf3, 0xe8, 0x22, 0x63, 0x47, 0x97, 0xc7, 0xbe, 0x49}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x47, 0x13, 0x89, 0x81, 0x6b, 0xaf, 0x13, 0xcc}; - uint8_t bytesprops1[] = {0}; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + uint8_t bytesprops0[] = {0x47, 0xc0, 0xae, 0xa5, 0x7e, 0x7f}; + uint8_t bytesprops2[] = {0x3f, 0xd5, 0xae, 0x8, 0x66, 0xf, 0x56, 0x21, 0x5a, + 0x53, 0xaf, 0x7a, 0x55, 0x76, 0x4, 0x97, 0x33, 0x26}; + uint8_t bytesprops1[] = {0xb9, 0xc1, 0x16, 0xdd, 0xe, 0x7, 0xc8, 0xc0, 0x8b, + 0xa2, 0x10, 0xa0, 0x30, 0xcb, 0xf6, 0xd4, 0x51, 0x69}; + uint8_t bytesprops3[] = {0x79, 0x1f, 0x73, 0x98, 0xdc, 0x66, 0x5a, 0xf8, 0x1a, 0x80, 0xd5}; + uint8_t bytesprops4[] = {0xf9, 0x9a, 0x17, 0x5d, 0xcd, 0xde, 0x28, 0xf9, 0x5e, 0xb2, 0x93, 0x2b, 0x7d, + 0x45, 0xf4, 0x25, 0x10, 0xbb, 0x79, 0xfa, 0x36, 0xad, 0x5, 0x61, 0xe4}; + uint8_t bytesprops5[] = {0xd9, 0xc7, 0x1d, 0x9e, 0x4, 0x74, 0xd5, 0x55, 0x6e, 0x40, 0x48, 0x4, 0xbf}; + uint8_t bytesprops6[] = {0xba, 0x39, 0xf, 0xd2, 0x21, 0xf5, 0x2, 0x99, 0x54, 0xf3, 0x58, 0xfa, 0x3b, 0xc7, 0xb1, + 0x5a, 0xcc, 0xd0, 0xee, 0xe3, 0x75, 0x62, 0x1a, 0x36, 0x2, 0x79, 0x67, 0xcf, 0x47}; + uint8_t bytesprops7[] = {0xe4, 0x4d, 0xf8, 0x8b, 0xe, 0xb1, 0x6c, 0xd5, 0x41, 0x3d, 0x8c, 0xd7, 0xca, 0xbd, + 0x38, 0x7, 0x95, 0xf1, 0x11, 0x5e, 0x30, 0xb9, 0x70, 0x86, 0x82, 0x8c, 0x42, 0x39}; + uint8_t bytesprops8[] = {0xff, 0x34, 0xa8, 0xe0, 0x5f, 0x23, 0x95, 0xe, 0x4, 0xf5}; + uint8_t bytesprops9[] = {0xc9, 0x2a, 0x6e, 0x5f, 0xba, 0x8a, 0x68, 0x57, 0xed, 0xc4, 0x3c, 0xb1, 0x6e, 0x44, 0xae, + 0x99, 0xcb, 0x42, 0xe6, 0x5e, 0xec, 0x97, 0x14, 0x1a, 0xa, 0x5d, 0xeb, 0xf0, 0x92, 0xd8}; + uint8_t bytesprops10[] = {0x1b, 0x9b, 0x45, 0x3a, 0x99, 0xc3, 0x82, 0x17, + 0x5e, 0x30, 0xf9, 0x7d, 0x1a, 0xb9, 0x3d, 0x6e}; + uint8_t bytesprops11[] = {0xf0, 0x33, 0x9, 0x35}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7848}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28305}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4567}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20670}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31623}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29714}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22439}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29750}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 27}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32664, 6, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14473, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21953 [("\STX\245\160\232\SUB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),(",\r\215\243\217\137",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ENQ\196M\SYN\244\173\DC2\170\SO\STXb\USw+z\173U\f\130\&4V\199\173\142\160\165\153\201\166\&4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropReceiveMaximum 30193,PropSharedSubscriptionAvailable 155,PropReasonString -// "\186Q\212\162\132=\234r\225\249\&1\219f\163X\214\229<\147\152s\224\EOTy\SOqp\254",PropMessageExpiryInterval -// 6080,PropCorrelationData "\NUL\167\237\190\193\v\239\GSb",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("/\r\190",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("yL\254\155\&0U{\DLE\199\211\253\189\183F\149\222\US\218\186\b\175\DC2\252'\156",SubOptions {_retainHandling +// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\US&\190d\ETX~\239/\NAK\128\228\240io\227\DC1\SUB6\DC1\175 \153",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropTopicAliasMaximum +// 25272,PropTopicAliasMaximum 14579,PropRequestResponseInformation 189,PropTopicAlias 14505,PropReasonString +// "\163^'\163\136\DC3n\145k\214\ACK\250`\155",PropServerReference +// "\DC4\154\NUL\159v\144-\213\246\128\192nF\b{\CAN}P>\162Yw",PropResponseInformation +// "\NULn~})5",PropRequestProblemInformation 59,PropPayloadFormatIndicator 184,PropResponseTopic +// "\EOT\180V\182x;\252\163\&0\131\n8\EM\232",PropRequestProblemInformation 113,PropCorrelationData +// "2",PropWildcardSubscriptionAvailable 43,PropMaximumQoS 237,PropRequestResponseInformation +// 20,PropWildcardSubscriptionAvailable 253,PropAuthenticationData "h!Q,\206\184\215\128G\ETX",PropTopicAliasMaximum +// 7133,PropWillDelayInterval 32528,PropWildcardSubscriptionAvailable 162,PropRequestResponseInformation +// 48,PropServerKeepAlive 28613,PropMessageExpiryInterval 6419,PropContentType +// "\157Z\149\DC3\213\174\231\241\&1[\225\151\DEL+]\fT[\FS\243\198\206'sI\252>\148\ETB\194",PropResponseInformation +// ")v\160\t\228\210(VA\142\ESC\r\253Uw(so\248\244U\201K",PropServerKeepAlive 13558,PropSubscriptionIdentifierAvailable +// 122,PropRequestProblemInformation 192] TEST(Subscribe5QCTest, Encode15) { uint8_t pkt[] = { - 0x82, 0xee, 0x1, 0x55, 0xc1, 0xb8, 0x1, 0x21, 0x75, 0xf1, 0x2a, 0x9b, 0x1f, 0x0, 0x1c, 0xba, 0x51, 0x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0x58, 0x45, 0x7a, 0x94, 0x21, 0x0, 0x6, + 0x6a, 0x94, 0x83, 0x4b, 0x4b, 0x9b, 0x2, 0x0, 0x13, 0x59, 0xc, 0x99, 0x1f, 0xc5, 0xe4, 0x5c, 0xd3, 0xe9, 0x39, + 0x18, 0x3e, 0xed, 0xbe, 0xc1, 0xb, 0xef, 0x1d, 0x62, 0x9, 0x0, 0x3, 0x2f, 0xd, 0xbe, 0x8, 0x0, 0x19, 0x79, + 0x4c, 0xfe, 0x9b, 0x30, 0x55, 0x7b, 0x10, 0xc7, 0xd3, 0xfd, 0xbd, 0xb7, 0x46, 0x95, 0xde, 0x1f, 0xda, 0xba, 0x8, + 0xaf, 0x12, 0xfc, 0x27, 0x9c, 0x1a, 0x0, 0x16, 0x1f, 0x26, 0xbe, 0x64, 0x3, 0x7e, 0xef, 0x2f, 0x15, 0x80, 0xe4, + 0xf0, 0x69, 0x6f, 0xe3, 0x11, 0x1a, 0x36, 0x11, 0xaf, 0x20, 0x99, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x2, 0xf5, 0xa0, 0xe8, 0x1a}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xf4, 0x45, 0xcc, 0x36, 0x4f, 0x6, 0x52, 0x53, 0x69, 0xfa, + 0xc1, 0x3a, 0x69, 0x2a, 0x4c, 0xb, 0x7b, 0x9f, 0xd4, 0xf3, + 0x21, 0x10, 0xc8, 0x6f, 0xaf, 0xac, 0xec, 0x64, 0xe8, 0x1e}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2c, 0xd, 0xd7, 0xf3, 0xd9, 0x89}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4e, 0xf8, 0xac, 0x7, 0x37, 0x9f, 0xfa, 0x19, 0xe3, 0x7b, 0xb3, 0xc9, 0x4f, + 0xa1, 0x5a, 0x52, 0x8c, 0xfb, 0xbc, 0xcf, 0x90, 0xd4, 0x2, 0xad, 0x96, 0x77}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5, 0xc4, 0x4d, 0x16, 0xf4, 0xad, 0x12, 0xaa, 0xe, 0x2, - 0x62, 0x1f, 0x77, 0x2b, 0x7a, 0xad, 0x55, 0xc, 0x82, 0x34, - 0x56, 0xc7, 0xad, 0x8e, 0xa0, 0xa5, 0x99, 0xc9, 0xa6, 0x34}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x9b, 0x57, 0xfb, 0xc, 0x6b, 0x3c, 0xc3, 0x70, + 0xb8, 0xfd, 0xaf, 0x41, 0xa2, 0xd2, 0x17}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0xba, 0x51, 0xd4, 0xa2, 0x84, 0x3d, 0xea, 0x72, 0xe1, 0xf9, 0x31, 0xdb, 0x66, 0xa3, - 0x58, 0xd6, 0xe5, 0x3c, 0x93, 0x98, 0x73, 0xe0, 0x4, 0x79, 0xe, 0x71, 0x70, 0xfe}; - uint8_t bytesprops1[] = {0x0, 0xa7, 0x3c, 0x4b, 0x69, 0x67, 0x33, 0xa, 0x4, 0xa8, 0x6b, 0x7f, 0x91, - 0xeb, 0x66, 0xe8, 0x74, 0xed, 0xb0, 0xd1, 0x7c, 0xf1, 0x23, 0x57, 0xf8, 0xda}; - uint8_t bytesprops2[] = {0x8f, 0xbc}; - uint8_t bytesprops4[] = {0xf5, 0x6c, 0xae, 0xab, 0xb6, 0x78, 0x96, 0x19, 0xdf, 0x4d, - 0x94, 0xcf, 0x3, 0xb9, 0x93, 0xac, 0x8b, 0x82, 0x23, 0x7}; - uint8_t bytesprops3[] = {0xbe, 0xbf, 0x18, 0xf, 0xba, 0xd5, 0xf0, 0xfb, 0x62, 0x15, 0x83, 0xdb, 0x5c, - 0x68, 0xe2, 0x23, 0x59, 0xeb, 0xda, 0x87, 0x25, 0xb5, 0x7f, 0x6f, 0xca}; - uint8_t bytesprops5[] = {0xa3, 0xb4, 0xc9, 0xc5, 0x7f, 0xbe, 0x31, 0x27, 0x2c, 0xf4, 0x6e, - 0xea, 0x46, 0xc0, 0x6e, 0xec, 0x76, 0x35, 0xed, 0xc1, 0x8b, 0xc5}; + uint8_t topic_filter_s3_bytes[] = {0x76, 0x10, 0xbc, 0x2, 0x47, 0x21, 0x8e, 0x57, 0xc1, 0xb6, 0xec, + 0x48, 0x0, 0xc, 0x4f, 0x24, 0x60, 0xfd, 0x65, 0x2b, 0xe, 0xd6}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa3, 0x2b, 0xf4, 0x6d, 0x20, 0x31, 0x8a, 0x6e, 0xe9, 0x81, + 0x73, 0x52, 0xb6, 0x18, 0x89, 0xc7, 0x28, 0x42, 0x42, 0x7d, + 0xca, 0xc4, 0x6d, 0xe7, 0xd0, 0x58, 0x45, 0x7a, 0x94}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6a, 0x94, 0x83, 0x4b, 0x4b, 0x9b}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x59, 0xc, 0x99, 0x1f, 0xc5, 0xe4, 0x5c, 0xd3, 0xe9, 0x39, + 0x18, 0x3e, 0xed, 0xbe, 0xc1, 0xb, 0xef, 0x1d, 0x62}; + lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x2f, 0xd, 0xbe}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x79, 0x4c, 0xfe, 0x9b, 0x30, 0x55, 0x7b, 0x10, 0xc7, 0xd3, 0xfd, 0xbd, 0xb7, + 0x46, 0x95, 0xde, 0x1f, 0xda, 0xba, 0x8, 0xaf, 0x12, 0xfc, 0x27, 0x9c}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x1f, 0x26, 0xbe, 0x64, 0x3, 0x7e, 0xef, 0x2f, 0x15, 0x80, 0xe4, + 0xf0, 0x69, 0x6f, 0xe3, 0x11, 0x1a, 0x36, 0x11, 0xaf, 0x20, 0x99}; + lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + uint8_t bytesprops0[] = {0xa3, 0x5e, 0x27, 0xa3, 0x88, 0x13, 0x6e, 0x91, 0x6b, 0xd6, 0x6, 0xfa, 0x60, 0x9b}; + uint8_t bytesprops1[] = {0x14, 0x9a, 0x0, 0x9f, 0x76, 0x90, 0x2d, 0xd5, 0xf6, 0x80, 0xc0, + 0x6e, 0x46, 0x8, 0x7b, 0x18, 0x7d, 0x50, 0x3e, 0xa2, 0x59, 0x77}; + uint8_t bytesprops2[] = {0x0, 0x6e, 0x7e, 0x7d, 0x29, 0x35}; + uint8_t bytesprops3[] = {0x4, 0xb4, 0x56, 0xb6, 0x78, 0x3b, 0xfc, 0xa3, 0x30, 0x83, 0xa, 0x38, 0x19, 0xe8}; + uint8_t bytesprops4[] = {0x32}; + uint8_t bytesprops5[] = {0x68, 0x21, 0x51, 0x2c, 0xce, 0xb8, 0xd7, 0x80, 0x47, 0x3}; + uint8_t bytesprops6[] = {0x9d, 0x5a, 0x95, 0x13, 0xd5, 0xae, 0xe7, 0xf1, 0x31, 0x5b, 0xe1, 0x97, 0x7f, 0x2b, 0x5d, + 0xc, 0x54, 0x5b, 0x1c, 0xf3, 0xc6, 0xce, 0x27, 0x73, 0x49, 0xfc, 0x3e, 0x94, 0x17, 0xc2}; + uint8_t bytesprops7[] = {0x29, 0x76, 0xa0, 0x9, 0xe4, 0xd2, 0x28, 0x56, 0x41, 0x8e, 0x1b, 0xd, + 0xfd, 0x55, 0x77, 0x28, 0x73, 0x6f, 0xf8, 0xf4, 0x55, 0xc9, 0x4b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30193}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6080}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops3}, .v = {20, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12201}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21133}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20595}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 754}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26754}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18986}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25272}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14579}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14505}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7133}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32528}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28613}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6419}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13558}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 192}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21953, 3, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3580, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20725 [("\128b\134\ACK",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("e\184\fN\150\215\RSt\rh\167\248\DC1\152\SOH\247\EOT\209\136i\165",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropTopicAlias -// 14680,PropPayloadFormatIndicator 0,PropUserProperty "IS\SOH\230\233C\252\184\FS\220\US\\\235\&3a" -// "lD\236_\EOT\167",PropResponseInformation "R\212\205\237\\_\214\ACK\235Y\238\GS",PropRequestResponseInformation -// 191,PropResponseTopic -// "LQF\172b)2\131\SYN\164P}Lj\ESC\156\SOA\172\168U:\198\166\172x\151",PropSharedSubscriptionAvailable -// 208,PropServerKeepAlive 22506,PropTopicAlias 9830,PropAuthenticationMethod -// "\229\136\136R\144\210",PropSharedSubscriptionAvailable 204,PropSubscriptionIdentifier 29,PropMaximumQoS -// 236,PropMaximumQoS 243,PropSessionExpiryInterval 26039,PropSessionExpiryInterval 24855,PropMessageExpiryInterval -// 24941,PropRequestResponseInformation 207,PropResponseInformation -// "\160+8aU\141\140\231\CAN\185\219'\168o\191Me{p",PropMessageExpiryInterval 7768,PropReasonString -// "\253P\217\133\245\SUBy\160I?\211o\135!A\166:\237\205A\175n\243\176",PropMessageExpiryInterval 30412,PropContentType -// "\242\184z\NAK\ETB2\174\243\DC4D\216\181\242{\154\204\RS\187\ESC\fF\251\135\195*\180B\ETB",PropWildcardSubscriptionAvailable -// 92,PropSessionExpiryInterval 12455,PropSessionExpiryInterval 19717,PropSessionExpiryInterval -// 2146,PropSubscriptionIdentifier 30] +// SubscribeRequest 8671 [("\137/\167\132\169\250\&8Z\230",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("vQ\229\222\160\&5\214\180",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\227~\DC4\240\205\167\163\150\&9\US\197\SIO\186>\237\168\235[",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\197\199!H\185\STX\187\SI4oM\179\237 \167(vk\193\195\&4\208\205*^\161\153\178\RS",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\166\188\156I\185\220\&3S#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),(".\204\SYNt\DEL\ETXV\"6\RS\192\193\199\228\130\160",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("f\186\US\183;a^\179\132Wd\CAN\219",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),(",\166\140N",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\175\142\248\&0\231s\212\169^s\151\213\133[J\153L=\USc3",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("J\227\239\US\219\166\EM\235K\b8G@\158\156l\216xH\131\&5{\174\253",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropPayloadFormatIndicator +// 50,PropUserProperty "\166\224\204\NAK$q\182\171\SYNz^\206\&0x\SOH7\170D" +// "d\163i.\246\242\145\163\212",PropMaximumPacketSize 26490,PropReasonString +// "\ESC\236:\166N\DC1\b\231\231\128\237\174\253+\165u\f\138\184'\DC3\161\188\222P\172Hq\222",PropAssignedClientIdentifier +// "\180\131N?\ENQI\222\202x",PropCorrelationData +// "\229$z^]\135\SYN?]\188CR\163\198X9\239\219\GSo\175\SO:,\192\169\241\SO\228\183",PropAuthenticationMethod +// "\141\SUB@\DC29z\187",PropRequestProblemInformation 190,PropMessageExpiryInterval 31181,PropResponseTopic +// "\239\176t\186\179d\181\213\195x+n#\249\&7\SYNT\203\SO+b>\187\FS\201\180\223\156\vw",PropReceiveMaximum +// 3626,PropAuthenticationMethod "\158\253\DELH\181y\163\SI\161\136\137",PropUserProperty +// "O\181\137\208\192\&4\145Z\f'`\207'\213\&9++\187\SOx" "U=",PropWillDelayInterval +// 9887,PropWildcardSubscriptionAvailable 228,PropMaximumPacketSize 19549,PropAuthenticationMethod +// "\218\RS\SYN\DC3\b\CAN\220_\237\209\US\230\191\231t\129\159s$\US\\M\142&2",PropSubscriptionIdentifierAvailable 52] TEST(Subscribe5QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0x88, 0x2, 0x50, 0xf5, 0xe5, 0x1, 0x23, 0x39, 0x58, 0x1, 0x0, 0x26, 0x0, 0xf, 0x49, 0x53, - 0x1, 0xe6, 0xe9, 0x43, 0xfc, 0xb8, 0x1c, 0xdc, 0x1f, 0x5c, 0xeb, 0x33, 0x61, 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, 0xa7, 0x28, 0x76, + 0x6b, 0xc1, 0xc3, 0x34, 0xd0, 0xcd, 0x2a, 0x5e, 0xa1, 0x99, 0xb2, 0x1e, 0x21, 0x0, 0x9, 0xa6, 0xbc, 0x9c, 0x49, + 0xb9, 0xdc, 0x33, 0x53, 0x23, 0x2, 0x0, 0x10, 0x2e, 0xcc, 0x16, 0x74, 0x7f, 0x3, 0x56, 0x22, 0x36, 0x1e, 0xc0, + 0xc1, 0xc7, 0xe4, 0x82, 0xa0, 0x21, 0x0, 0xd, 0x66, 0xba, 0x1f, 0xb7, 0x3b, 0x61, 0x5e, 0xb3, 0x84, 0x57, 0x64, + 0x18, 0xdb, 0x12, 0x0, 0x4, 0x2c, 0xa6, 0x8c, 0x4e, 0xe, 0x0, 0x15, 0xaf, 0x8e, 0xf8, 0x30, 0xe7, 0x73, 0xd4, + 0xa9, 0x5e, 0x73, 0x97, 0xd5, 0x85, 0x5b, 0x4a, 0x99, 0x4c, 0x3d, 0x1f, 0x63, 0x33, 0x11, 0x0, 0x18, 0x4a, 0xe3, + 0xef, 0x1f, 0xdb, 0xa6, 0x19, 0xeb, 0x4b, 0x8, 0x38, 0x47, 0x40, 0x9e, 0x9c, 0x6c, 0xd8, 0x78, 0x48, 0x83, 0x35, + 0x7b, 0xae, 0xfd, 0x2a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x80, 0x62, 0x86, 0x6}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x89, 0x2f, 0xa7, 0x84, 0xa9, 0xfa, 0x38, 0x5a, 0xe6}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x65, 0xb8, 0xc, 0x4e, 0x96, 0xd7, 0x1e, 0x74, 0xd, 0x68, 0xa7, - 0xf8, 0x11, 0x98, 0x1, 0xf7, 0x4, 0xd1, 0x88, 0x69, 0xa5}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x76, 0x51, 0xe5, 0xde, 0xa0, 0x35, 0xd6, 0xb4}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0}; - uint8_t bytesprops1[] = {0x6c, 0x44, 0xec, 0x5f, 0x4, 0xa7}; - uint8_t bytesprops0[] = {0x49, 0x53, 0x1, 0xe6, 0xe9, 0x43, 0xfc, 0xb8, 0x1c, 0xdc, 0x1f, 0x5c, 0xeb, 0x33, 0x61}; - uint8_t bytesprops2[] = {0x52, 0xd4, 0xcd, 0xed, 0x5c, 0x5f, 0xd6, 0x6, 0xeb, 0x59, 0xee, 0x1d}; - uint8_t bytesprops3[] = {0x4c, 0x51, 0x46, 0xac, 0x62, 0x29, 0x32, 0x83, 0x16, 0xa4, 0x50, 0x7d, 0x4c, 0x6a, - 0x1b, 0x9c, 0xe, 0x41, 0xac, 0xa8, 0x55, 0x3a, 0xc6, 0xa6, 0xac, 0x78, 0x97}; - uint8_t bytesprops4[] = {0xe5, 0x88, 0x88, 0x52, 0x90, 0xd2}; - uint8_t bytesprops5[] = {0xa0, 0x2b, 0x38, 0x61, 0x55, 0x8d, 0x8c, 0xe7, 0x18, 0xb9, - 0xdb, 0x27, 0xa8, 0x6f, 0xbf, 0x4d, 0x65, 0x7b, 0x70}; - uint8_t bytesprops6[] = {0xfd, 0x50, 0xd9, 0x85, 0xf5, 0x1a, 0x79, 0xa0, 0x49, 0x3f, 0xd3, 0x6f, - 0x87, 0x21, 0x41, 0xa6, 0x3a, 0xed, 0xcd, 0x41, 0xaf, 0x6e, 0xf3, 0xb0}; - uint8_t bytesprops7[] = {0xf2, 0xb8, 0x7a, 0x15, 0x17, 0x32, 0xae, 0xf3, 0x14, 0x44, 0xd8, 0xb5, 0xf2, 0x7b, - 0x9a, 0xcc, 0x1e, 0xbb, 0x1b, 0xc, 0x46, 0xfb, 0x87, 0xc3, 0x2a, 0xb4, 0x42, 0x17}; + uint8_t topic_filter_s2_bytes[] = {0xe3, 0x7e, 0x14, 0xf0, 0xcd, 0xa7, 0xa3, 0x96, 0x39, 0x1f, + 0xc5, 0xf, 0x4f, 0xba, 0x3e, 0xed, 0xa8, 0xeb, 0x5b}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc5, 0xc7, 0x21, 0x48, 0xb9, 0x2, 0xbb, 0xf, 0x34, 0x6f, + 0x4d, 0xb3, 0xed, 0x20, 0xa7, 0x28, 0x76, 0x6b, 0xc1, 0xc3, + 0x34, 0xd0, 0xcd, 0x2a, 0x5e, 0xa1, 0x99, 0xb2, 0x1e}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa6, 0xbc, 0x9c, 0x49, 0xb9, 0xdc, 0x33, 0x53, 0x23}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x2e, 0xcc, 0x16, 0x74, 0x7f, 0x3, 0x56, 0x22, + 0x36, 0x1e, 0xc0, 0xc1, 0xc7, 0xe4, 0x82, 0xa0}; + lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x66, 0xba, 0x1f, 0xb7, 0x3b, 0x61, 0x5e, 0xb3, 0x84, 0x57, 0x64, 0x18, 0xdb}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x2c, 0xa6, 0x8c, 0x4e}; + lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xaf, 0x8e, 0xf8, 0x30, 0xe7, 0x73, 0xd4, 0xa9, 0x5e, 0x73, 0x97, + 0xd5, 0x85, 0x5b, 0x4a, 0x99, 0x4c, 0x3d, 0x1f, 0x63, 0x33}; + lwmqtt_string_t topic_filter_s8 = {21, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x4a, 0xe3, 0xef, 0x1f, 0xdb, 0xa6, 0x19, 0xeb, 0x4b, 0x8, 0x38, 0x47, + 0x40, 0x9e, 0x9c, 0x6c, 0xd8, 0x78, 0x48, 0x83, 0x35, 0x7b, 0xae, 0xfd}; + lwmqtt_string_t topic_filter_s9 = {24, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = false; + uint8_t bytesprops1[] = {0x64, 0xa3, 0x69, 0x2e, 0xf6, 0xf2, 0x91, 0xa3, 0xd4}; + uint8_t bytesprops0[] = {0xa6, 0xe0, 0xcc, 0x15, 0x24, 0x71, 0xb6, 0xab, 0x16, + 0x7a, 0x5e, 0xce, 0x30, 0x78, 0x1, 0x37, 0xaa, 0x44}; + uint8_t bytesprops2[] = {0x1b, 0xec, 0x3a, 0xa6, 0x4e, 0x11, 0x8, 0xe7, 0xe7, 0x80, 0xed, 0xae, 0xfd, 0x2b, 0xa5, + 0x75, 0xc, 0x8a, 0xb8, 0x27, 0x13, 0xa1, 0xbc, 0xde, 0x50, 0xac, 0x48, 0x71, 0xde}; + uint8_t bytesprops3[] = {0xb4, 0x83, 0x4e, 0x3f, 0x5, 0x49, 0xde, 0xca, 0x78}; + uint8_t bytesprops4[] = {0xe5, 0x24, 0x7a, 0x5e, 0x5d, 0x87, 0x16, 0x3f, 0x5d, 0xbc, 0x43, 0x52, 0xa3, 0xc6, 0x58, + 0x39, 0xef, 0xdb, 0x1d, 0x6f, 0xaf, 0xe, 0x3a, 0x2c, 0xc0, 0xa9, 0xf1, 0xe, 0xe4, 0xb7}; + uint8_t bytesprops5[] = {0x8d, 0x1a, 0x40, 0x12, 0x39, 0x7a, 0xbb}; + uint8_t bytesprops6[] = {0xef, 0xb0, 0x74, 0xba, 0xb3, 0x64, 0xb5, 0xd5, 0xc3, 0x78, 0x2b, 0x6e, 0x23, 0xf9, 0x37, + 0x16, 0x54, 0xcb, 0xe, 0x2b, 0x62, 0x3e, 0xbb, 0x1c, 0xc9, 0xb4, 0xdf, 0x9c, 0xb, 0x77}; + uint8_t bytesprops7[] = {0x9e, 0xfd, 0x7f, 0x48, 0xb5, 0x79, 0xa3, 0xf, 0xa1, 0x88, 0x89}; + uint8_t bytesprops9[] = {0x55, 0x3d}; + uint8_t bytesprops8[] = {0x4f, 0xb5, 0x89, 0xd0, 0xc0, 0x34, 0x91, 0x5a, 0xc, 0x27, + 0x60, 0xcf, 0x27, 0xd5, 0x39, 0x2b, 0x2b, 0xbb, 0xe, 0x78}; + uint8_t bytesprops10[] = {0xda, 0x1e, 0x16, 0x13, 0x8, 0x18, 0xdc, 0x5f, 0xed, 0xd1, 0x1f, 0xe6, 0xbf, + 0xe7, 0x74, 0x81, 0x9f, 0x73, 0x24, 0x1f, 0x5c, 0x4d, 0x8e, 0x26, 0x32}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14680}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {6, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22506}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9830}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26039}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24855}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24941}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7768}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30412}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12455}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19717}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2146}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops0}, .v = {9, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26490}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31181}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3626}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops8}, .v = {2, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9887}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19549}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 52}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20725, 2, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 24375 [("Xx.\181I\175\249\174u\214\foC'\226e\196\233\RS\136\225[0\172-y\128",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\203Dra\249\DC2s\SOe\167\r}\158\ETX\128\141\242?5\203\239\147",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("Y\242H\243&V\212K2\185\&2sq\178\178c\194\230\214)\\\237\ETX\SO",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\rm3\DEL,+L\150\CAN|9j\159\255g\206\t\FS=\160\201\&1",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReceiveMaximum 17360,PropAuthenticationData -// "\177\138\226\210m\NAK~\NUL\207\ESC\SUB\236O\b\153\&1q",PropAuthenticationMethod -// "\178\233\240\SOHJZ\f\178\176eMt",PropPayloadFormatIndicator 232] + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8671, 10, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12528 [("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\148\&2\192\239\ETBl1G.]3f\EOT\158\156\169i\146#uO\217",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\225L\215\SOHGKI\217p5\225\219\187\228,p\ENQ*\218I\194\153q",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("S\231ewx\206\160\202P",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\171Kky\198c\184w\165e^\140n\236\SI\DEL\157d;\186d\234\NUL]\161",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\183",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),(";\246\134\170\224\207z\RSCq",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = +// QoS1}),("J\FS\206NB\154\253\b\US\197\172*=\232CO\212\210\181\202\&0,&>\135\&4\224\226\170\203",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] +// [PropUserProperty "\NAK\DC1\136*\192>}\148\128\143\182\248\143\167\164\161R\143\135\SO\175zc#\DLE\167\182`{V" +// "z\RS\ESC\186\247\DC48\177",PropPayloadFormatIndicator 150,PropAuthenticationData +// "\216\234\232|\237\f\154C\179/.\217\238\166\NUL\240\174}{\139\167\223\DLE4",PropReasonString +// "]\131\200\238\255\&2\207s\EM>I\183\218\ETB\DEL\186\251\196\251Ux\248\180\132k\ETBb\227\231\214",PropContentType +// "\NAKo|\144\202XH\163\243\SOH\fM\254\184v\222\180c\163\NUL\252\247\198_S\233",PropWillDelayInterval +// 16406,PropRetainAvailable 34,PropCorrelationData "\164\164\142\237V\166\188w",PropMaximumQoS 215,PropUserProperty +// "\225\214\210\224\STX\246<\162\SYN<\209\&5!j\194\176\128\SOH\DEL<=\178" +// "P\250\214\251RO\172y\128\245G",PropResponseTopic "Tn",PropSubscriptionIdentifierAvailable 104,PropTopicAlias +// 14762,PropSubscriptionIdentifierAvailable 31,PropResponseTopic +// "[,\v\255{|py$\184NX\148\DC1|\235\225\251h\159\GSw1\211\221\EOT",PropWillDelayInterval +// 17498,PropSubscriptionIdentifierAvailable 184,PropCorrelationData +// "=\223\226S\134r\134\SIe\185\192(\130",PropServerReference +// "-\164\233J\197\192\200\216\US3%\131\156\235\b\USQ\162\SYN\215,=\GS\DC4\212",PropSessionExpiryInterval +// 9456,PropReceiveMaximum 17438,PropMessageExpiryInterval 14322,PropTopicAliasMaximum 14800,PropReasonString +// "\216B\148X\191\STX\196\231\221q\EMO\145.\216\175\150\147\176\229^\nK\228\166cJ\203|",PropServerReference "\199\225"] TEST(Subscribe5QCTest, Encode17) { - uint8_t pkt[] = {0x82, 0x96, 0x1, 0x5f, 0x37, 0x28, 0x21, 0x43, 0xd0, 0x16, 0x0, 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19, 0xab, 0x4b, 0x6b, 0x79, 0xc6, 0x63, + 0xb8, 0x77, 0xa5, 0x65, 0x5e, 0x8c, 0x6e, 0xec, 0xf, 0x7f, 0x9d, 0x64, 0x3b, 0xba, 0x64, 0xea, 0x0, 0x5d, 0xa1, + 0x28, 0x0, 0x1, 0xb7, 0x1d, 0x0, 0xa, 0x3b, 0xf6, 0x86, 0xaa, 0xe0, 0xcf, 0x7a, 0x1e, 0x43, 0x71, 0x5, 0x0, + 0x1e, 0x4a, 0x1c, 0xce, 0x4e, 0x42, 0x9a, 0xfd, 0x8, 0x1f, 0xc5, 0xac, 0x2a, 0x3d, 0xe8, 0x43, 0x4f, 0xd4, 0xd2, + 0xb5, 0xca, 0x30, 0x2c, 0x26, 0x3e, 0x87, 0x34, 0xe0, 0xe2, 0xaa, 0xcb, 0x18}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x58, 0x78, 0x2e, 0xb5, 0x49, 0xaf, 0xf9, 0xae, 0x75, 0xd6, 0xc, 0x6f, 0x43, 0x27, - 0xe2, 0x65, 0xc4, 0xe9, 0x1e, 0x88, 0xe1, 0x5b, 0x30, 0xac, 0x2d, 0x79, 0x80}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcb, 0x44, 0x72, 0x61, 0xf9, 0x12, 0x73, 0xe, 0x65, 0xa7, 0xd, - 0x7d, 0x9e, 0x3, 0x80, 0x8d, 0xf2, 0x3f, 0x35, 0xcb, 0xef, 0x93}; + uint8_t topic_filter_s1_bytes[] = {0x94, 0x32, 0xc0, 0xef, 0x17, 0x6c, 0x31, 0x47, 0x2e, 0x5d, 0x33, + 0x66, 0x4, 0x9e, 0x9c, 0xa9, 0x69, 0x92, 0x23, 0x75, 0x4f, 0xd9}; lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x59, 0xf2, 0x48, 0xf3, 0x26, 0x56, 0xd4, 0x4b, 0x32, 0xb9, 0x32, 0x73, - 0x71, 0xb2, 0xb2, 0x63, 0xc2, 0xe6, 0xd6, 0x29, 0x5c, 0xed, 0x3, 0xe}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd, 0x6d, 0x33, 0x7f, 0x2c, 0x2b, 0x4c, 0x96, 0x18, 0x7c, 0x39, - 0x6a, 0x9f, 0xff, 0x67, 0xce, 0x9, 0x1c, 0x3d, 0xa0, 0xc9, 0x31}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xb1, 0x8a, 0xe2, 0xd2, 0x6d, 0x15, 0x7e, 0x0, 0xcf, - 0x1b, 0x1a, 0xec, 0x4f, 0x8, 0x99, 0x31, 0x71}; - uint8_t bytesprops1[] = {0xb2, 0xe9, 0xf0, 0x1, 0x4a, 0x5a, 0xc, 0xb2, 0xb0, 0x65, 0x4d, 0x74}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17360}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 232}}, - }; - - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24375, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 15182 [("jX\253\212\226>%\234\136\158",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("wv\141n\252k\ESC\242,\211jBIr\ESC\nN\254\RSG\227C\180/A\174\244\STX\228\222",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("WE\f\171+\DC1\ETB\v\EOT\DLE\176\tw_\SYN/\ETX",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\161AM\198\RS6\146w\219\173\244\245J>\201",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS2}),("e\171N\STX\186ov\240\229\136D\\\234J\152e\217",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropPayloadFormatIndicator 22,PropReceiveMaximum 2396,PropSubscriptionIdentifierAvailable -// 176,PropAuthenticationMethod "e\214,\242:_\GS\141\NUL\208\RSf|?\EM\138j\234\138\220",PropMaximumPacketSize 12790] -TEST(Subscribe5QCTest, Encode18) { - uint8_t pkt[] = {0x82, 0x8e, 0x1, 0x3b, 0x4e, 0x23, 0x1, 0x16, 0x21, 0x9, 0x5c, 0x29, 0xb0, 0x15, 0x0, 0x14, 0x65, - 0xd6, 0x2c, 0xf2, 0x3a, 0x5f, 0x1d, 0x8d, 0x0, 0xd0, 0x1e, 0x66, 0x7c, 0x3f, 0x19, 0x8a, 0x6a, 0xea, - 0x8a, 0xdc, 0x27, 0x0, 0x0, 0x31, 0xf6, 0x0, 0xa, 0x6a, 0x58, 0xfd, 0xd4, 0xe2, 0x3e, 0x25, 0xea, - 0x88, 0x9e, 0x1, 0x0, 0x1e, 0x77, 0x76, 0x8d, 0x6e, 0xfc, 0x6b, 0x1b, 0xf2, 0x2c, 0xd3, 0x6a, 0x42, - 0x49, 0x72, 0x1b, 0xa, 0x4e, 0xfe, 0x1e, 0x47, 0xe3, 0x43, 0xb4, 0x2f, 0x41, 0xae, 0xf4, 0x2, 0xe4, - 0xde, 0x1, 0x0, 0x11, 0x57, 0x45, 0xc, 0xab, 0x2b, 0x11, 0x17, 0xb, 0x4, 0x10, 0xb0, 0x9, 0x77, - 0x5f, 0x16, 0x2f, 0x3, 0x1, 0x0, 0xf, 0xa1, 0x41, 0x4d, 0xc6, 0x1e, 0x36, 0x92, 0x77, 0xdb, 0xad, - 0xf4, 0xf5, 0x4a, 0x3e, 0xc9, 0x2, 0x0, 0x11, 0x65, 0xab, 0x4e, 0x2, 0xba, 0x6f, 0x76, 0xf0, 0xe5, - 0x88, 0x44, 0x5c, 0xea, 0x4a, 0x98, 0x65, 0xd9, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x6a, 0x58, 0xfd, 0xd4, 0xe2, 0x3e, 0x25, 0xea, 0x88, 0x9e}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x77, 0x76, 0x8d, 0x6e, 0xfc, 0x6b, 0x1b, 0xf2, 0x2c, 0xd3, - 0x6a, 0x42, 0x49, 0x72, 0x1b, 0xa, 0x4e, 0xfe, 0x1e, 0x47, - 0xe3, 0x43, 0xb4, 0x2f, 0x41, 0xae, 0xf4, 0x2, 0xe4, 0xde}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x57, 0x45, 0xc, 0xab, 0x2b, 0x11, 0x17, 0xb, 0x4, - 0x10, 0xb0, 0x9, 0x77, 0x5f, 0x16, 0x2f, 0x3}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe1, 0x4c, 0xd7, 0x1, 0x47, 0x4b, 0x49, 0xd9, 0x70, 0x35, 0xe1, 0xdb, + 0xbb, 0xe4, 0x2c, 0x70, 0x5, 0x2a, 0xda, 0x49, 0xc2, 0x99, 0x71}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa1, 0x41, 0x4d, 0xc6, 0x1e, 0x36, 0x92, 0x77, - 0xdb, 0xad, 0xf4, 0xf5, 0x4a, 0x3e, 0xc9}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x53, 0xe7, 0x65, 0x77, 0x78, 0xce, 0xa0, 0xca, 0x50}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x65, 0xab, 0x4e, 0x2, 0xba, 0x6f, 0x76, 0xf0, 0xe5, - 0x88, 0x44, 0x5c, 0xea, 0x4a, 0x98, 0x65, 0xd9}; - lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xab, 0x4b, 0x6b, 0x79, 0xc6, 0x63, 0xb8, 0x77, 0xa5, 0x65, 0x5e, 0x8c, 0x6e, + 0xec, 0xf, 0x7f, 0x9d, 0x64, 0x3b, 0xba, 0x64, 0xea, 0x0, 0x5d, 0xa1}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x65, 0xd6, 0x2c, 0xf2, 0x3a, 0x5f, 0x1d, 0x8d, 0x0, 0xd0, - 0x1e, 0x66, 0x7c, 0x3f, 0x19, 0x8a, 0x6a, 0xea, 0x8a, 0xdc}; + uint8_t topic_filter_s5_bytes[] = {0xb7}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3b, 0xf6, 0x86, 0xaa, 0xe0, 0xcf, 0x7a, 0x1e, 0x43, 0x71}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x4a, 0x1c, 0xce, 0x4e, 0x42, 0x9a, 0xfd, 0x8, 0x1f, 0xc5, + 0xac, 0x2a, 0x3d, 0xe8, 0x43, 0x4f, 0xd4, 0xd2, 0xb5, 0xca, + 0x30, 0x2c, 0x26, 0x3e, 0x87, 0x34, 0xe0, 0xe2, 0xaa, 0xcb}; + lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + uint8_t bytesprops1[] = {0x7a, 0x1e, 0x1b, 0xba, 0xf7, 0x14, 0x38, 0xb1}; + uint8_t bytesprops0[] = {0x15, 0x11, 0x88, 0x2a, 0xc0, 0x3e, 0x7d, 0x94, 0x80, 0x8f, 0xb6, 0xf8, 0x8f, 0xa7, 0xa4, + 0xa1, 0x52, 0x8f, 0x87, 0xe, 0xaf, 0x7a, 0x63, 0x23, 0x10, 0xa7, 0xb6, 0x60, 0x7b, 0x56}; + uint8_t bytesprops2[] = {0xd8, 0xea, 0xe8, 0x7c, 0xed, 0xc, 0x9a, 0x43, 0xb3, 0x2f, 0x2e, 0xd9, + 0xee, 0xa6, 0x0, 0xf0, 0xae, 0x7d, 0x7b, 0x8b, 0xa7, 0xdf, 0x10, 0x34}; + uint8_t bytesprops3[] = {0x5d, 0x83, 0xc8, 0xee, 0xff, 0x32, 0xcf, 0x73, 0x19, 0x3e, 0x49, 0xb7, 0xda, 0x17, 0x7f, + 0xba, 0xfb, 0xc4, 0xfb, 0x55, 0x78, 0xf8, 0xb4, 0x84, 0x6b, 0x17, 0x62, 0xe3, 0xe7, 0xd6}; + uint8_t bytesprops4[] = {0x15, 0x6f, 0x7c, 0x90, 0xca, 0x58, 0x48, 0xa3, 0xf3, 0x1, 0xc, 0x4d, 0xfe, + 0xb8, 0x76, 0xde, 0xb4, 0x63, 0xa3, 0x0, 0xfc, 0xf7, 0xc6, 0x5f, 0x53, 0xe9}; + uint8_t bytesprops5[] = {0xa4, 0xa4, 0x8e, 0xed, 0x56, 0xa6, 0xbc, 0x77}; + uint8_t bytesprops7[] = {0x50, 0xfa, 0xd6, 0xfb, 0x52, 0x4f, 0xac, 0x79, 0x80, 0xf5, 0x47}; + uint8_t bytesprops6[] = {0xe1, 0xd6, 0xd2, 0xe0, 0x2, 0xf6, 0x3c, 0xa2, 0x16, 0x3c, 0xd1, + 0x35, 0x21, 0x6a, 0xc2, 0xb0, 0x80, 0x1, 0x7f, 0x3c, 0x3d, 0xb2}; + uint8_t bytesprops8[] = {0x54, 0x6e}; + uint8_t bytesprops9[] = {0x5b, 0x2c, 0xb, 0xff, 0x7b, 0x7c, 0x70, 0x79, 0x24, 0xb8, 0x4e, 0x58, 0x94, + 0x11, 0x7c, 0xeb, 0xe1, 0xfb, 0x68, 0x9f, 0x1d, 0x77, 0x31, 0xd3, 0xdd, 0x4}; + uint8_t bytesprops10[] = {0x3d, 0xdf, 0xe2, 0x53, 0x86, 0x72, 0x86, 0xf, 0x65, 0xb9, 0xc0, 0x28, 0x82}; + uint8_t bytesprops11[] = {0x2d, 0xa4, 0xe9, 0x4a, 0xc5, 0xc0, 0xc8, 0xd8, 0x1f, 0x33, 0x25, 0x83, 0x9c, + 0xeb, 0x8, 0x1f, 0x51, 0xa2, 0x16, 0xd7, 0x2c, 0x3d, 0x1d, 0x14, 0xd4}; + uint8_t bytesprops12[] = {0xd8, 0x42, 0x94, 0x58, 0xbf, 0x2, 0xc4, 0xe7, 0xdd, 0x71, 0x19, 0x4f, 0x91, 0x2e, 0xd8, + 0xaf, 0x96, 0x93, 0xb0, 0xe5, 0x5e, 0xa, 0x4b, 0xe4, 0xa6, 0x63, 0x4a, 0xcb, 0x7c}; + uint8_t bytesprops13[] = {0xc7, 0xe1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2396}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12790}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16406}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops6}, .v = {11, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14762}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17498}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9456}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17438}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14322}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14800}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops13}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15182, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12528, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29268 [("\142",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = -// QoS0}),("5\254\147\212\152\233@<\242\195\191\180#\\Sl\SI\249(\174P\136\239\"B\182\139\218",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\229\173x -// \159d\157\161F\133y\253\&4\185\191h\167\231\noU\SI/\158\193\239",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(";Q=\182\248\245\152C&\221k\173\153\ESC\151\156",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Q\168tf\193i\245\US\ENQ\177nl\202/\177",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\177\139\193I\228b\DLEvi\211\r{\aRg",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\195E\216",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("l\151\230\r\129\b\184\193\176\178\162\197\&5\188/\SO\187",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(" k\147",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRetainAvailable -// 230,PropReceiveMaximum 11250,PropReceiveMaximum 12353,PropContentType -// "\NAK4\163\226\165\169z\SO\139\182w^\204",PropPayloadFormatIndicator 139,PropRequestProblemInformation -// 197,PropMaximumQoS 7,PropTopicAliasMaximum 7500,PropTopicAlias 27990,PropReceiveMaximum 17963,PropResponseTopic -// "\128\218\250Y\217\199\219\235 .\158\246\137\219\205",PropWildcardSubscriptionAvailable 69,PropTopicAliasMaximum -// 22545,PropTopicAliasMaximum 6468,PropSharedSubscriptionAvailable 80,PropSharedSubscriptionAvailable 228] -TEST(Subscribe5QCTest, Encode19) { +// SubscribeRequest 9386 [("\209\EM\NUL~%q\250\200\SYNf]\226\199+9\165'\162\178V\208\DLE",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\n\ETB\130\245\135\213\245\138\&6E\221M\DC2]\175\198\214CL8\139",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("(pn\242\166\175uq\214\245\142\vZR\209",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = True, _noLocal = False, _subQoS = QoS2})] [PropResponseTopic +// "\133=\EM\229\SUB\162\252K\172v\240\a\194P\134X\255>u#\177Q[\204\&6\241v\167J\b",PropCorrelationData +// "\254\218+C@/\128\231}\222\129\132G\228\DC3\199]w\137\NAK\158$@B\206",PropMessageExpiryInterval +// 5811,PropServerReference +// "\221\254\174Z\158\172\228_\241e#\EOTa\168\245j\219\159\FS\n\175n\NUL\184\241",PropCorrelationData +// "*\163A\181|\130\233l\145H\201\ETB\166\178x\161\"\aTU",PropAuthenticationMethod "",PropWillDelayInterval +// 25248,PropSubscriptionIdentifierAvailable 210,PropWildcardSubscriptionAvailable 146,PropAuthenticationMethod +// "\244V\207\207\n'1\ACK\169\DC2=\173\140\231\197G\DC2M5+\DC3"] +TEST(Subscribe5QCTest, Encode18) { uint8_t pkt[] = { - 0x82, 0xdf, 0x1, 0x72, 0x54, 0x45, 0x25, 0xe6, 0x21, 0x2b, 0xf2, 0x21, 0x30, 0x41, 0x3, 0x0, 0xd, 0x15, 0x34, - 0xa3, 0xe2, 0xa5, 0xa9, 0x7a, 0xe, 0x8b, 0xb6, 0x77, 0x5e, 0xcc, 0x1, 0x8b, 0x17, 0xc5, 0x24, 0x7, 0x22, 0x1d, - 0x4c, 0x23, 0x6d, 0x56, 0x21, 0x46, 0x2b, 0x8, 0x0, 0xf, 0x80, 0xda, 0xfa, 0x59, 0xd9, 0xc7, 0xdb, 0xeb, 0x20, - 0x2e, 0x9e, 0xf6, 0x89, 0xdb, 0xcd, 0x28, 0x45, 0x22, 0x58, 0x11, 0x22, 0x19, 0x44, 0x2a, 0x50, 0x2a, 0xe4, 0x0, - 0x1, 0x8e, 0x0, 0x0, 0x1c, 0x35, 0xfe, 0x93, 0xd4, 0x98, 0xe9, 0x40, 0x3c, 0xf2, 0xc3, 0xbf, 0xb4, 0x23, 0x5c, - 0x53, 0x6c, 0xf, 0xf9, 0x28, 0xae, 0x50, 0x88, 0xef, 0x22, 0x42, 0xb6, 0x8b, 0xda, 0x1, 0x0, 0x1a, 0xe5, 0xad, - 0x78, 0x20, 0x9f, 0x64, 0x9d, 0xa1, 0x46, 0x85, 0x79, 0xfd, 0x34, 0xb9, 0xbf, 0x68, 0xa7, 0xe7,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5, 0x6a, 0xdb, 0x9f, 0x1c, + 0xa, 0xaf, 0x6e, 0x0, 0xb8, 0xf1, 0x9, 0x0, 0x14, 0x2a, 0xa3, 0x41, 0xb5, 0x7c, 0x82, 0xe9, 0x6c, 0x91, 0x48, + 0xc9, 0x17, 0xa6, 0xb2, 0x78, 0xa1, 0x22, 0x7, 0x54, 0x55, 0x15, 0x0, 0x0, 0x18, 0x0, 0x0, 0x62, 0xa0, 0x29, + 0xd2, 0x28, 0x92, 0x15, 0x0, 0x15, 0xf4, 0x56, 0xcf, 0xcf, 0xa, 0x27, 0x31, 0x6, 0xa9, 0x12, 0x3d, 0xad, 0x8c, + 0xe7, 0xc5, 0x47, 0x12, 0x4d, 0x35, 0x2b, 0x13, 0x0, 0x16, 0xd1, 0x19, 0x0, 0x7e, 0x25, 0x71, 0xfa, 0xc8, 0x16, + 0x66, 0x5d, 0xe2, 0xc7, 0x2b, 0x39, 0xa5, 0x27, 0xa2, 0xb2, 0x56, 0xd0, 0x10, 0x2d, 0x0, 0x15, 0xa, 0x17, 0x82, + 0xf5, 0x87, 0xd5, 0xf5, 0x8a, 0x36, 0x45, 0xdd, 0x4d, 0x12, 0x5d, 0xaf, 0xc6, 0xd6, 0x43, 0x4c, 0x38, 0x8b, 0x14, + 0x0, 0xf, 0x28, 0x70, 0x6e, 0xf2, 0xa6, 0xaf, 0x75, 0x71, 0xd6, 0xf5, 0x8e, 0xb, 0x5a, 0x52, 0xd1, 0x1a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x8e}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xd1, 0x19, 0x0, 0x7e, 0x25, 0x71, 0xfa, 0xc8, 0x16, 0x66, 0x5d, + 0xe2, 0xc7, 0x2b, 0x39, 0xa5, 0x27, 0xa2, 0xb2, 0x56, 0xd0, 0x10}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x35, 0xfe, 0x93, 0xd4, 0x98, 0xe9, 0x40, 0x3c, 0xf2, 0xc3, - 0xbf, 0xb4, 0x23, 0x5c, 0x53, 0x6c, 0xf, 0xf9, 0x28, 0xae, - 0x50, 0x88, 0xef, 0x22, 0x42, 0xb6, 0x8b, 0xda}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa, 0x17, 0x82, 0xf5, 0x87, 0xd5, 0xf5, 0x8a, 0x36, 0x45, 0xdd, + 0x4d, 0x12, 0x5d, 0xaf, 0xc6, 0xd6, 0x43, 0x4c, 0x38, 0x8b}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe5, 0xad, 0x78, 0x20, 0x9f, 0x64, 0x9d, 0xa1, 0x46, 0x85, 0x79, 0xfd, 0x34, - 0xb9, 0xbf, 0x68, 0xa7, 0xe7, 0xa, 0x6f, 0x55, 0xf, 0x2f, 0x9e, 0xc1, 0xef}; - lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x28, 0x70, 0x6e, 0xf2, 0xa6, 0xaf, 0x75, 0x71, + 0xd6, 0xf5, 0x8e, 0xb, 0x5a, 0x52, 0xd1}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3b, 0x51, 0x3d, 0xb6, 0xf8, 0xf5, 0x98, 0x43, - 0x26, 0xdd, 0x6b, 0xad, 0x99, 0x1b, 0x97, 0x9c}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x51, 0xa8, 0x74, 0x66, 0xc1, 0x69, 0xf5, 0x1f, - 0x5, 0xb1, 0x6e, 0x6c, 0xca, 0x2f, 0xb1}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb1, 0x8b, 0xc1, 0x49, 0xe4, 0x62, 0x10, 0x76, - 0x69, 0xd3, 0xd, 0x7b, 0x7, 0x52, 0x67}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc3, 0x45, 0xd8}; - lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6c, 0x97, 0xe6, 0xd, 0x81, 0x8, 0xb8, 0xc1, 0xb0, - 0xb2, 0xa2, 0xc5, 0x35, 0xbc, 0x2f, 0xe, 0xbb}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x20, 0x6b, 0x93}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1, - LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x15, 0x34, 0xa3, 0xe2, 0xa5, 0xa9, 0x7a, 0xe, 0x8b, 0xb6, 0x77, 0x5e, 0xcc}; - uint8_t bytesprops1[] = {0x80, 0xda, 0xfa, 0x59, 0xd9, 0xc7, 0xdb, 0xeb, 0x20, 0x2e, 0x9e, 0xf6, 0x89, 0xdb, 0xcd}; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + uint8_t bytesprops0[] = {0x85, 0x3d, 0x19, 0xe5, 0x1a, 0xa2, 0xfc, 0x4b, 0xac, 0x76, 0xf0, 0x7, 0xc2, 0x50, 0x86, + 0x58, 0xff, 0x3e, 0x75, 0x23, 0xb1, 0x51, 0x5b, 0xcc, 0x36, 0xf1, 0x76, 0xa7, 0x4a, 0x8}; + uint8_t bytesprops1[] = {0xfe, 0xda, 0x2b, 0x43, 0x40, 0x2f, 0x80, 0xe7, 0x7d, 0xde, 0x81, 0x84, 0x47, + 0xe4, 0x13, 0xc7, 0x5d, 0x77, 0x89, 0x15, 0x9e, 0x24, 0x40, 0x42, 0xce}; + uint8_t bytesprops2[] = {0xdd, 0xfe, 0xae, 0x5a, 0x9e, 0xac, 0xe4, 0x5f, 0xf1, 0x65, 0x23, 0x4, 0x61, + 0xa8, 0xf5, 0x6a, 0xdb, 0x9f, 0x1c, 0xa, 0xaf, 0x6e, 0x0, 0xb8, 0xf1}; + uint8_t bytesprops3[] = {0x2a, 0xa3, 0x41, 0xb5, 0x7c, 0x82, 0xe9, 0x6c, 0x91, 0x48, + 0xc9, 0x17, 0xa6, 0xb2, 0x78, 0xa1, 0x22, 0x7, 0x54, 0x55}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0xf4, 0x56, 0xcf, 0xcf, 0xa, 0x27, 0x31, 0x6, 0xa9, 0x12, 0x3d, + 0xad, 0x8c, 0xe7, 0xc5, 0x47, 0x12, 0x4d, 0x35, 0x2b, 0x13}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11250}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12353}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7500}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27990}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17963}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22545}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6468}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5811}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25248}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29268, 9, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9386, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30528 [("Z7\246b'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\248\161\240\135Q\130\198oV\RS\187~7'\DC2@\ACK~i\213csX\200kE\240",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\248\215\167X\a\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("W\139~\240\234\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("\226\223\ETXA\170{\FS\197RN\147X\161\ESC\SI\a\197\vB3\232\220\160{\136\242\&5\150\150",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\134\236\184\180A/4\206\134\176p\163\&6\NUL\RS$\US\200\CAN\DELU\156\224",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ENQ\177",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\207\&1\134\149\169\137_\145\\\185,\187\242\226\135J>\203\203B\245\196\147\239\168\212\167\145\219",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(",\176\197p\224M\\\200",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\155w\224D\180\218\161\221r@3\"\131\FS\184\204\160",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerReference -// "\236.\US\173\184\196J\207\233*d\SO\SOAD\155\ba\r",PropPayloadFormatIndicator 174,PropAuthenticationData -// "\141\234\239\130"] -TEST(Subscribe5QCTest, Encode20) { - uint8_t pkt[] = {0x82, 0xd8, 0x1, 0x77, 0x40, 0x1f, 0x1c, 0x0, 0x13, 0xec, 0x2e, 0x1f, 0xad, 0xb8, 0xc4, 0x4a, 0xcf, - 0xe9, 0x2a, 0x64, 0xe, 0xe, 0x41, 0x44, 0x9b, 0x8, 0x61, 0xd, 0x1, 0xae, 0x16, 0x0, 0x4, 0x8d, - 0xea, 0xef, 0x82, 0x0, 0x5, 0x5a, 0x37, 0xf6, 0x62, 0x27, 0x1, 0x0, 0x1b, 0xf8, 0xa1, 0xf0, 0x87, - 0x51, 0x82, 0xc6, 0x6f, 0x56, 0x1e, 0xbb, 0x7e, 0x37, 0x27, 0x12, 0x40, 0x6, 0x7e, 0x69, 0xd5, 0x63, - 0x73, 0x58, 0xc8, 0x6b, 0x45, 0xf0, 0x2, 0x0, 0x6, 0xf8, 0xd7, 0xa7, 0x58, 0x7, 0xb8, 0x1, 0x0, - 0x6, 0x57, 0x8b, 0x7e, 0xf0, 0xea, 0xa, 0x2, 0x0, 0x1d, 0xe2, 0xdf, 0x3, 0x41, 0xaa, 0x7b, 0x1c, - 0xc5, 0x52, 0x4e, 0x93, 0x58, 0xa1, 0x1b, 0xf, 0x7, 0xc5, 0xb, 0x42, 0x33, 0xe8, 0xdc, 0xa0, 0x7b, - 0x88, 0xf2, 0x35, 0x96, 0x96, 0x2, 0x0, 0x17, 0x86, 0xec, 0xb8, 0xb4, 0x41, 0x2f, 0x34, 0xce, 0x86, - 0xb0, 0x70, 0xa3, 0x36, 0x0, 0x1e, 0x24, 0x1f, 0xc8, 0x18, 0x7f, 0x55, 0x9c, 0xe0, 0x0, 0x0, 0x2, - 0x5, 0xb1, 0x2, 0x0, 0x1d, 0xcf, 0x31, 0x86, 0x95, 0xa9, 0x89, 0x5f, 0x91, 0x5c, 0xb9, 0x2c, 0xbb, - 0xf2, 0xe2, 0x87, 0x4a, 0x3e, 0xcb, 0xcb, 0x42, 0xf5, 0xc4, 0x93, 0xef, 0xa8, 0xd4, 0xa7, 0x91, 0xdb, - 0x0, 0x0, 0x8, 0x2c, 0xb0, 0xc5, 0x70, 0xe0, 0x4d, 0x5c, 0xc8, 0x0, 0x0, 0x11, 0x9b, 0x77, 0xe0, - 0x44, 0xb4, 0xda, 0xa1, 0xdd, 0x72, 0x40, 0x33, 0x22, 0x83, 0x1c, 0xb8, 0xcc, 0xa0, 0x1}; +// SubscribeRequest 17533 [("(\v5\187IR\198\&8\215Mh\DC1\234\194",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("_E",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\166GM",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\216\209{\247V0\206\253\155\DC4\CAN",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = True, _subQoS = QoS2}),(",\170\200\239\ETX\218}\155\195\194\177faHsp\134\SI",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\140\140\rH\207f*P<\249\191k\ETB\229\141\224Y\138\SI\SYN\251;\DC12M",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("j\234\196n\SUB\146\132\168?\155F\190)\137\235.\233\224\135\138\DC1\a#\GS",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("83\213v",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropResponseInformation "\r\163U7\225\141/\215\229\216\162",PropAuthenticationData +// "\204V\133\RS{k\233\236\248!:\CAN\DEL\GS\189",PropRetainAvailable 207,PropPayloadFormatIndicator +// 122,PropWillDelayInterval 24641,PropAssignedClientIdentifier +// "\ESC\180\219\212\&2#]8\129\US?",PropSessionExpiryInterval 29296,PropContentType +// "\190\CAN\221U\133P",PropSharedSubscriptionAvailable 51,PropRequestProblemInformation 42,PropWillDelayInterval +// 6999,PropMaximumPacketSize 24918,PropUserProperty +// "SE\183+\172\213\142>\SIL0\153q\166\229\172\224K\171\144\145>\233a\132%\181\r" +// "\216\141\145\210\176{\195",PropRequestResponseInformation 108,PropUserProperty "|\SYN\EMo\214\192\154M\235" +// "\196p\SI\230\158\207\157\196\252\211\175\143p",PropSubscriptionIdentifier 9,PropMaximumPacketSize +// 28386,PropReceiveMaximum 8213,PropSharedSubscriptionAvailable 114,PropSharedSubscriptionAvailable +// 174,PropTopicAliasMaximum 14924] +TEST(Subscribe5QCTest, Encode19) { + uint8_t pkt[] = { + 0x82, 0xaa, 0x2, 0x44, 0x7d, 0xa9, 0x1, 0x1a, 0x0, 0xb, 0xd, 0xa3, 0x55, 0x37, 0xe1, 0x8d, 0x2f, 0xd7, 0xe5, + 0xd8, 0xa2, 0x16, 0x0, 0xf, 0xcc, 0x56, 0x85, 0x1e, 0x7b, 0x6b, 0xe9, 0xec, 0xf8, 0x21, 0x3a, 0x18, 0x7f, 0x1d, + 0xbd, 0x25, 0xcf, 0x1, 0x7a, 0x18, 0x0, 0x0, 0x60, 0x41, 0x12, 0x0, 0xb, 0x1b, 0xb4,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0x19, 0x8c, 0x8c, 0xd, 0x48, 0xcf, 0x66, + 0x2a, 0x50, 0x3c, 0xf9, 0xbf, 0x6b, 0x17, 0xe5, 0x8d, 0xe0, 0x59, 0x8a, 0xf, 0x16, 0xfb, 0x3b, 0x11, 0x32, 0x4d, + 0x1e, 0x0, 0x18, 0x6a, 0xea, 0xc4, 0x6e, 0x1a, 0x92, 0x84, 0xa8, 0x3f, 0x9b, 0x46, 0xbe, 0x29, 0x89, 0xeb, 0x2e, + 0xe9, 0xe0, 0x87, 0x8a, 0x11, 0x7, 0x23, 0x1d, 0x29, 0x0, 0x4, 0x38, 0x33, 0xd5, 0x76, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x5a, 0x37, 0xf6, 0x62, 0x27}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x28, 0xb, 0x35, 0xbb, 0x49, 0x52, 0xc6, 0x38, 0xd7, 0x4d, 0x68, 0x11, 0xea, 0xc2}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf8, 0xa1, 0xf0, 0x87, 0x51, 0x82, 0xc6, 0x6f, 0x56, 0x1e, 0xbb, 0x7e, 0x37, 0x27, - 0x12, 0x40, 0x6, 0x7e, 0x69, 0xd5, 0x63, 0x73, 0x58, 0xc8, 0x6b, 0x45, 0xf0}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5f, 0x45}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf8, 0xd7, 0xa7, 0x58, 0x7, 0xb8}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa6, 0x47, 0x4d}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x57, 0x8b, 0x7e, 0xf0, 0xea, 0xa}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd8, 0xd1, 0x7b, 0xf7, 0x56, 0x30, 0xce, 0xfd, 0x9b, 0x14, 0x18}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe2, 0xdf, 0x3, 0x41, 0xaa, 0x7b, 0x1c, 0xc5, 0x52, 0x4e, - 0x93, 0x58, 0xa1, 0x1b, 0xf, 0x7, 0xc5, 0xb, 0x42, 0x33, - 0xe8, 0xdc, 0xa0, 0x7b, 0x88, 0xf2, 0x35, 0x96, 0x96}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2c, 0xaa, 0xc8, 0xef, 0x3, 0xda, 0x7d, 0x9b, 0xc3, + 0xc2, 0xb1, 0x66, 0x61, 0x48, 0x73, 0x70, 0x86, 0xf}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x86, 0xec, 0xb8, 0xb4, 0x41, 0x2f, 0x34, 0xce, 0x86, 0xb0, 0x70, 0xa3, - 0x36, 0x0, 0x1e, 0x24, 0x1f, 0xc8, 0x18, 0x7f, 0x55, 0x9c, 0xe0}; - lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x8c, 0x8c, 0xd, 0x48, 0xcf, 0x66, 0x2a, 0x50, 0x3c, 0xf9, 0xbf, 0x6b, 0x17, + 0xe5, 0x8d, 0xe0, 0x59, 0x8a, 0xf, 0x16, 0xfb, 0x3b, 0x11, 0x32, 0x4d}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5, 0xb1}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x6a, 0xea, 0xc4, 0x6e, 0x1a, 0x92, 0x84, 0xa8, 0x3f, 0x9b, 0x46, 0xbe, + 0x29, 0x89, 0xeb, 0x2e, 0xe9, 0xe0, 0x87, 0x8a, 0x11, 0x7, 0x23, 0x1d}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xcf, 0x31, 0x86, 0x95, 0xa9, 0x89, 0x5f, 0x91, 0x5c, 0xb9, - 0x2c, 0xbb, 0xf2, 0xe2, 0x87, 0x4a, 0x3e, 0xcb, 0xcb, 0x42, - 0xf5, 0xc4, 0x93, 0xef, 0xa8, 0xd4, 0xa7, 0x91, 0xdb}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x38, 0x33, 0xd5, 0x76}; + lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x2c, 0xb0, 0xc5, 0x70, 0xe0, 0x4d, 0x5c, 0xc8}; - lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x9b, 0x77, 0xe0, 0x44, 0xb4, 0xda, 0xa1, 0xdd, 0x72, - 0x40, 0x33, 0x22, 0x83, 0x1c, 0xb8, 0xcc, 0xa0}; - lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, - LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xec, 0x2e, 0x1f, 0xad, 0xb8, 0xc4, 0x4a, 0xcf, 0xe9, 0x2a, - 0x64, 0xe, 0xe, 0x41, 0x44, 0x9b, 0x8, 0x61, 0xd}; - uint8_t bytesprops1[] = {0x8d, 0xea, 0xef, 0x82}; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + uint8_t bytesprops0[] = {0xd, 0xa3, 0x55, 0x37, 0xe1, 0x8d, 0x2f, 0xd7, 0xe5, 0xd8, 0xa2}; + uint8_t bytesprops1[] = {0xcc, 0x56, 0x85, 0x1e, 0x7b, 0x6b, 0xe9, 0xec, 0xf8, 0x21, 0x3a, 0x18, 0x7f, 0x1d, 0xbd}; + uint8_t bytesprops2[] = {0x1b, 0xb4, 0xdb, 0xd4, 0x32, 0x23, 0x5d, 0x38, 0x81, 0x1f, 0x3f}; + uint8_t bytesprops3[] = {0xbe, 0x18, 0xdd, 0x55, 0x85, 0x50}; + uint8_t bytesprops5[] = {0xd8, 0x8d, 0x91, 0xd2, 0xb0, 0x7b, 0xc3}; + uint8_t bytesprops4[] = {0x53, 0x45, 0xb7, 0x2b, 0xac, 0xd5, 0x8e, 0x3e, 0xf, 0x4c, 0x30, 0x99, 0x71, 0xa6, + 0xe5, 0xac, 0xe0, 0x4b, 0xab, 0x90, 0x91, 0x3e, 0xe9, 0x61, 0x84, 0x25, 0xb5, 0xd}; + uint8_t bytesprops7[] = {0xc4, 0x70, 0xf, 0xe6, 0x9e, 0xcf, 0x9d, 0xc4, 0xfc, 0xd3, 0xaf, 0x8f, 0x70}; + uint8_t bytesprops6[] = {0x7c, 0x16, 0x19, 0x6f, 0xd6, 0xc0, 0x9a, 0x4d, 0xeb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24641}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29296}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6999}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24918}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops4}, .v = {7, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops6}, .v = {13, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28386}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8213}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14924}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30528, 10, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17533, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32298 [("\183B\236P\DC4\RS0\245>\186\t\170R\GS\ESC\SI\234\151\246\224",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropRequestResponseInformation -// 237,PropServerReference ".]r\136\&1\229.",PropUserProperty "'\192\242\220\159\a\198\"\151\155\251\132yZ\223\135{" -// "\154\v\199\217\EM\FS/\179wz\184",PropMaximumPacketSize 16608,PropAssignedClientIdentifier -// "\207",PropSubscriptionIdentifierAvailable 150,PropServerKeepAlive 31252,PropSessionExpiryInterval -// 27950,PropResponseTopic "Pc<\170",PropMessageExpiryInterval 8676,PropServerKeepAlive 14073,PropReasonString -// "\CAN\DC2\DC4K\SI\212D\188\171\161+\133\SYNn&kS\218\223u]\161\198/",PropRequestProblemInformation -// 70,PropRetainAvailable 136] -TEST(Subscribe5QCTest, Encode21) { - uint8_t pkt[] = {0x82, 0x88, 0x1, 0x7e, 0x2a, 0x6e, 0x19, 0xed, 0x1c, 0x0, 0x7, 0x2e, 0x5d, 0x72, 0x88, 0x31, - 0xe5, 0x2e, 0x26, 0x0, 0x11, 0x27, 0xc0, 0xf2, 0xdc, 0x9f, 0x7, 0xc6, 0x22, 0x97, 0x9b, 0xfb, - 0x84, 0x79, 0x5a, 0xdf, 0x87, 0x7b, 0x0, 0xb, 0x9a, 0xb, 0xc7, 0xd9, 0x19, 0x1c, 0x2f, 0xb3, - 0x77, 0x7a, 0xb8, 0x27, 0x0, 0x0, 0x40, 0xe0, 0x12, 0x0, 0x1, 0xcf, 0x29, 0x96, 0x13, 0x7a, - 0x14, 0x11, 0x0, 0x0, 0x6d, 0x2e, 0x8, 0x0, 0x4, 0x50, 0x63, 0x3c, 0xaa, 0x2, 0x0, 0x0, - 0x21, 0xe4, 0x13, 0x36, 0xf9, 0x1f, 0x0, 0x18, 0x18, 0x12, 0x14, 0x4b, 0xf, 0xd4, 0x44, 0xbc, - 0xab, 0xa1, 0x2b, 0x85, 0x16, 0x6e, 0x26, 0x6b, 0x53, 0xda, 0xdf, 0x75, 0x5d, 0xa1, 0xc6, 0x2f, - 0x17, 0x46, 0x25, 0x88, 0x0, 0x14, 0xb7, 0x42, 0xec, 0x50, 0x14, 0x1e, 0x30, 0xf5, 0x3e, 0xba, - 0x9, 0xaa, 0x52, 0x1d, 0x1b, 0xf, 0xea, 0x97, 0xf6, 0xe0, 0x2}; +// SubscribeRequest 1875 [("\131\239*\255VM\230[\170\a\ACK|\132\249\176v\212",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropResponseInformation +// "Z\196",PropWildcardSubscriptionAvailable 183,PropServerKeepAlive 24665,PropWillDelayInterval 7907,PropMaximumQoS +// 22,PropPayloadFormatIndicator 100,PropRequestProblemInformation 248,PropWillDelayInterval 3496,PropMaximumPacketSize +// 21061,PropTopicAliasMaximum 21354,PropResponseTopic "\247\227\&7",PropSubscriptionIdentifier 15,PropWillDelayInterval +// 24629,PropUserProperty "\234\140\175<\234#\180\&0\FS\249!\169\243\165\210\240\ACK\200" +// "N\GS\CAN\160\219\167D\169\223\160\164\"\222\153\192~\235\131\&6p\248\a\246\162",PropAuthenticationMethod +// "\193\252\143U}\151+=\249i5\DC2;\149g\183\a]",PropSubscriptionIdentifier 0,PropWildcardSubscriptionAvailable +// 237,PropWillDelayInterval 6547,PropServerReference +// "sa\133\247\251\132\245\185\148\232\145F?\181",PropRequestResponseInformation 207,PropTopicAliasMaximum +// 12816,PropRetainAvailable 145,PropTopicAliasMaximum 27568,PropMaximumPacketSize 25047,PropMessageExpiryInterval +// 18783,PropSubscriptionIdentifier 6,PropMaximumPacketSize 32075,PropUserProperty "\a\185\225\135Q&\200" +// "\247\191\178F",PropMessageExpiryInterval 13005,PropMaximumQoS 23] +TEST(Subscribe5QCTest, Enc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 0x4, + 0xf7, 0xbf, 0xb2, 0x46, 0x2, 0x0, 0x0, 0x32, 0xcd, 0x24, 0x17, 0x0, 0x11, 0x83, 0xef, 0x2a, 0xff, + 0x56, 0x4d, 0xe6, 0x5b, 0xaa, 0x7, 0x6, 0x7c, 0x84, 0xf9, 0xb0, 0x76, 0xd4, 0x6}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xb7, 0x42, 0xec, 0x50, 0x14, 0x1e, 0x30, 0xf5, 0x3e, 0xba, - 0x9, 0xaa, 0x52, 0x1d, 0x1b, 0xf, 0xea, 0x97, 0xf6, 0xe0}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x83, 0xef, 0x2a, 0xff, 0x56, 0x4d, 0xe6, 0x5b, 0xaa, + 0x7, 0x6, 0x7c, 0x84, 0xf9, 0xb0, 0x76, 0xd4}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x2e, 0x5d, 0x72, 0x88, 0x31, 0xe5, 0x2e}; - uint8_t bytesprops2[] = {0x9a, 0xb, 0xc7, 0xd9, 0x19, 0x1c, 0x2f, 0xb3, 0x77, 0x7a, 0xb8}; - uint8_t bytesprops1[] = {0x27, 0xc0, 0xf2, 0xdc, 0x9f, 0x7, 0xc6, 0x22, 0x97, - 0x9b, 0xfb, 0x84, 0x79, 0x5a, 0xdf, 0x87, 0x7b}; - uint8_t bytesprops3[] = {0xcf}; - uint8_t bytesprops4[] = {0x50, 0x63, 0x3c, 0xaa}; - uint8_t bytesprops5[] = {0x18, 0x12, 0x14, 0x4b, 0xf, 0xd4, 0x44, 0xbc, 0xab, 0xa1, 0x2b, 0x85, - 0x16, 0x6e, 0x26, 0x6b, 0x53, 0xda, 0xdf, 0x75, 0x5d, 0xa1, 0xc6, 0x2f}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + uint8_t bytesprops0[] = {0x5a, 0xc4}; + uint8_t bytesprops1[] = {0xf7, 0xe3, 0x37}; + uint8_t bytesprops3[] = {0x4e, 0x1d, 0x18, 0xa0, 0xdb, 0xa7, 0x44, 0xa9, 0xdf, 0xa0, 0xa4, 0x22, + 0xde, 0x99, 0xc0, 0x7e, 0xeb, 0x83, 0x36, 0x70, 0xf8, 0x7, 0xf6, 0xa2}; + uint8_t bytesprops2[] = {0xea, 0x8c, 0xaf, 0x3c, 0xea, 0x23, 0xb4, 0x30, 0x1c, + 0xf9, 0x21, 0xa9, 0xf3, 0xa5, 0xd2, 0xf0, 0x6, 0xc8}; + uint8_t bytesprops4[] = {0xc1, 0xfc, 0x8f, 0x55, 0x7d, 0x97, 0x2b, 0x3d, 0xf9, + 0x69, 0x35, 0x12, 0x3b, 0x95, 0x67, 0xb7, 0x7, 0x5d}; + uint8_t bytesprops5[] = {0x73, 0x61, 0x85, 0xf7, 0xfb, 0x84, 0xf5, 0xb9, 0x94, 0xe8, 0x91, 0x46, 0x3f, 0xb5}; + uint8_t bytesprops7[] = {0xf7, 0xbf, 0xb2, 0x46}; + uint8_t bytesprops6[] = {0x7, 0xb9, 0xe1, 0x87, 0x51, 0x26, 0xc8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16608}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31252}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27950}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8676}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14073}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24665}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7907}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3496}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21061}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21354}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24629}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops2}, .v = {24, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6547}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12816}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27568}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25047}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18783}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32075}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops6}, .v = {4, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13005}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 23}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32298, 1, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1875, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22169 [("\185n'\131\192M\162\EOTR\199\DC3\248G\138\NULjj\129\249\191\177\183D\200WU",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\247j\216\229\244\&4\DLEvoHjH\NUL\236\161\&64",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\130O\195\&2/BI\149/\183\137\146\218\179\CAN\198\212\174\&3a\191\158\214K\209\173p@\130",SubOptions +// SubscribeRequest 14558 [("\253\195\NUL\169\SUB\205/\SYNc\168\233|a\172\161\187\236\149\159 \222\215$\195<",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\182g\162\186\175\184\210\ACKc>I\183\153\SO\176\v\255\221\&0L_\231Z",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\149\178\207\218V\235\209\189K6\143\DC3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic "\202B\213%\169\204'",PropMessageExpiryInterval -// 8353,PropMaximumQoS 188,PropMaximumPacketSize 4183,PropWildcardSubscriptionAvailable 203,PropReceiveMaximum -// 12629,PropReceiveMaximum 28020,PropTopicAlias 3381,PropWildcardSubscriptionAvailable -// 6,PropSubscriptionIdentifierAvailable 228,PropAuthenticationMethod "\153\ETBl;",PropAuthenticationData -// "\235@RK\\]\199\t\184$\251\172\&1\248j\217\233\b\251_\DC3=p\150\178\220\200",PropPayloadFormatIndicator -// 232,PropMaximumPacketSize 26137,PropAuthenticationData -// "\DC3>\176\CANO\159\a\DC43\135-\173\136\249\158\&2\191\184X\192\180\213\DC4\141\\\207\234*u",PropResponseInformation -// "]PYw\173\ETXJ\131\128\184\&0\152\254\247\215",PropCorrelationData "\202*d\183F\147)",PropSessionExpiryInterval -// 18520,PropRetainAvailable 28,PropSharedSubscriptionAvailable 172,PropSharedSubscriptionAvailable -// 47,PropCorrelationData "\149C\STX\254\158\173\205k\166\141\159\200\DC2\145g\ETB\SO",PropPayloadFormatIndicator -// 7,PropMessageExpiryInterval 11013,PropWildcardSubscriptionAvailable 170,PropMaximumQoS 9] -TEST(Subscribe5QCTest, Encode22) { +// QoS1}),("E\201R^&\SUB,\148vp@\224",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\215\136.^@|s6\135?U\231\230Q{\238d\161\131\NUL\177M\\\DC1",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\136\133c\130\ACK\ETX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// True, _subQoS = QoS0}),(")\171\146\187\241\153\239",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\141\248\DC2\161?,jC\203G\198\135\203\134=\157\192\221\249~\246",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\189M!|\178~\166\141rn\247w\234",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// True, _noLocal = True, _subQoS = QoS1})] [PropServerReference "\142a\DC42\194\234\191\169",PropSubscriptionIdentifier +// 21,PropSessionExpiryInterval 5774,PropAssignedClientIdentifier "\SI[\204\129<\184S\EOTS*",PropServerReference +// "\219\196\196\212\134\r\150\238L",PropServerReference +// "\131E\208\SI%\246y\DLE*\137\208\168\153\&5\189\182\226xO\238H\231\148",PropWillDelayInterval +// 22265,PropSharedSubscriptionAvailable 169,PropServerKeepAlive 768,PropSubscriptionIdentifier +// 25,PropSessionExpiryInterval 2168,PropWillDelayInterval 19691,PropRequestResponseInformation +// 117,PropSubscriptionIdentifierAvailable 178,PropResponseInformation +// "g\155\DC17\251\131S\142^\211\143L\STXG4\ETX\SYN\146a\207\160",PropContentType "\246",PropWillDelayInterval +// 6475,PropSubscriptionIdentifier 17,PropContentType "\255\240\185\STXEt\192R",PropSubscriptionIdentifierAvailable +// 189,PropCorrelationData "\146(U*\249\225Y\215\215y\232\213\ACK3\217\234\202\146?\151t"] +TEST(Subscribe5QCTest, Encode21) { uint8_t pkt[] = { - 0x82, 0xb5, 0x2, 0x56, 0x99, 0xb7, 0x1, 0x8, 0x0, 0x7, 0xca, 0x42, 0xd5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, 0xc7, 0x13, 0xf8, 0x47, 0x8a, 0x0, 0x6a, 0x6a, - 0x81, 0xf9, 0xbf, 0xb1, 0xb7, 0x44, 0xc8, 0x57, 0x55, 0x1, 0x0, 0x11, 0xf7, 0x6a, 0xd8, 0xe5, 0xf4, 0x34, 0x10, - 0x76, 0x6f, 0x48, 0x6a, 0x48, 0x0, 0xec, 0xa1, 0x36, 0x34, 0x2, 0x0, 0x1d, 0x82, 0x4f, 0xc3, 0x32, 0x2f, 0x42, - 0x49, 0x95, 0x2f, 0xb7, 0x89, 0x92, 0xda, 0xb3, 0x18, 0xc6, 0xd4, 0xae, 0x33, 0x61, 0xbf, 0x9e, 0xd6, 0x4b, 0xd1, - 0xad, 0x70, 0x40, 0x82, 0x1, 0x0, 0x17, 0xb6, 0x67, 0xa2, 0xba, 0xaf, 0xb8, 0xd2, 0x6, 0x63, 0x3e, 0x49, 0xb7, - 0x99, 0xe, 0xb0, 0xb, 0xff, 0xdd, 0x30, 0x4c, 0x5f, 0xe7, 0x5a, 0x2, 0x0, 0xc, 0x95, 0xb2, 0xcf, 0xda, 0x56, - 0xeb, 0xd1, 0xbd, 0x4b, 0x36, 0x8f, 0x13, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xb9, 0x6e, 0x27, 0x83, 0xc0, 0x4d, 0xa2, 0x4, 0x52, 0xc7, 0x13, 0xf8, 0x47, - 0x8a, 0x0, 0x6a, 0x6a, 0x81, 0xf9, 0xbf, 0xb1, 0xb7, 0x44, 0xc8, 0x57, 0x55}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + 0x82, 0xac, 0x2, 0x38, 0xde, 0xa7, 0x1, 0x1c, 0x0, 0x8, 0x8e, 0x61, 0x14, 0x32, 0xc2, 0xea, 0xbf, 0xa9, 0xb, + 0x15, 0x11, 0x0, 0x0, 0x16, 0x8e, 0x12, 0x0, 0xa, 0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1, 0x0, 0x18, 0xd7, 0x88, 0x2e, 0x5e, 0x40, 0x7c, 0x73, 0x36, 0x87, + 0x3f, 0x55, 0xe7, 0xe6, 0x51, 0x7b, 0xee, 0x64, 0xa1, 0x83, 0x0, 0xb1, 0x4d, 0x5c, 0x11, 0xe, 0x0, 0x6, 0x88, + 0x85, 0x63, 0x82, 0x6, 0x3, 0x4, 0x0, 0x7, 0x29, 0xab, 0x92, 0xbb, 0xf1, 0x99, 0xef, 0x2c, 0x0, 0x15, 0x8d, + 0xf8, 0x12, 0xa1, 0x3f, 0x2c, 0x6a, 0x43, 0xcb, 0x47, 0xc6, 0x87, 0xcb, 0x86, 0x3d, 0x9d, 0xc0, 0xdd, 0xf9, 0x7e, + 0xf6, 0x9, 0x0, 0xd, 0xbd, 0x4d, 0x21, 0x7c, 0xb2, 0x7e, 0xa6, 0x8d, 0x72, 0x6e, 0xf7, 0x77, 0xea, 0x1d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xfd, 0xc3, 0x0, 0xa9, 0x1a, 0xcd, 0x2f, 0x16, 0x63, 0xa8, 0xe9, 0x7c, 0x61, + 0xac, 0xa1, 0xbb, 0xec, 0x95, 0x9f, 0x20, 0xde, 0xd7, 0x24, 0xc3, 0x3c}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf7, 0x6a, 0xd8, 0xe5, 0xf4, 0x34, 0x10, 0x76, 0x6f, - 0x48, 0x6a, 0x48, 0x0, 0xec, 0xa1, 0x36, 0x34}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x45, 0xc9, 0x52, 0x5e, 0x26, 0x1a, 0x2c, 0x94, 0x76, 0x70, 0x40, 0xe0}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x82, 0x4f, 0xc3, 0x32, 0x2f, 0x42, 0x49, 0x95, 0x2f, 0xb7, - 0x89, 0x92, 0xda, 0xb3, 0x18, 0xc6, 0xd4, 0xae, 0x33, 0x61, - 0xbf, 0x9e, 0xd6, 0x4b, 0xd1, 0xad, 0x70, 0x40, 0x82}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd7, 0x88, 0x2e, 0x5e, 0x40, 0x7c, 0x73, 0x36, 0x87, 0x3f, 0x55, 0xe7, + 0xe6, 0x51, 0x7b, 0xee, 0x64, 0xa1, 0x83, 0x0, 0xb1, 0x4d, 0x5c, 0x11}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb6, 0x67, 0xa2, 0xba, 0xaf, 0xb8, 0xd2, 0x6, 0x63, 0x3e, 0x49, 0xb7, - 0x99, 0xe, 0xb0, 0xb, 0xff, 0xdd, 0x30, 0x4c, 0x5f, 0xe7, 0x5a}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x88, 0x85, 0x63, 0x82, 0x6, 0x3}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x95, 0xb2, 0xcf, 0xda, 0x56, 0xeb, 0xd1, 0xbd, 0x4b, 0x36, 0x8f, 0x13}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x29, 0xab, 0x92, 0xbb, 0xf1, 0x99, 0xef}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xca, 0x42, 0xd5, 0x25, 0xa9, 0xcc, 0x27}; - uint8_t bytesprops1[] = {0x99, 0x17, 0x6c, 0x3b}; - uint8_t bytesprops2[] = {0xeb, 0x40, 0x52, 0x4b, 0x5c, 0x5d, 0xc7, 0x9, 0xb8, 0x24, 0xfb, 0xac, 0x31, 0xf8, - 0x6a, 0xd9, 0xe9, 0x8, 0xfb, 0x5f, 0x13, 0x3d, 0x70, 0x96, 0xb2, 0xdc, 0xc8}; - uint8_t bytesprops3[] = {0x13, 0x3e, 0xb0, 0x18, 0x4f, 0x9f, 0x7, 0x14, 0x33, 0x87, 0x2d, 0xad, 0x88, 0xf9, 0x9e, - 0x32, 0xbf, 0xb8, 0x58, 0xc0, 0xb4, 0xd5, 0x14, 0x8d, 0x5c, 0xcf, 0xea, 0x2a, 0x75}; - uint8_t bytesprops4[] = {0x5d, 0x50, 0x59, 0x77, 0xad, 0x3, 0x4a, 0x83, 0x80, 0xb8, 0x30, 0x98, 0xfe, 0xf7, 0xd7}; - uint8_t bytesprops5[] = {0xca, 0x2a, 0x64, 0xb7, 0x46, 0x93, 0x29}; - uint8_t bytesprops6[] = {0x95, 0x43, 0x2, 0xfe, 0x9e, 0xad, 0xcd, 0x6b, 0xa6, - 0x8d, 0x9f, 0xc8, 0x12, 0x91, 0x67, 0x17, 0xe}; + uint8_t topic_filter_s5_bytes[] = {0x8d, 0xf8, 0x12, 0xa1, 0x3f, 0x2c, 0x6a, 0x43, 0xcb, 0x47, 0xc6, + 0x87, 0xcb, 0x86, 0x3d, 0x9d, 0xc0, 0xdd, 0xf9, 0x7e, 0xf6}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xbd, 0x4d, 0x21, 0x7c, 0xb2, 0x7e, 0xa6, 0x8d, 0x72, 0x6e, 0xf7, 0x77, 0xea}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + uint8_t bytesprops0[] = {0x8e, 0x61, 0x14, 0x32, 0xc2, 0xea, 0xbf, 0xa9}; + uint8_t bytesprops1[] = {0xf, 0x5b, 0xcc, 0x81, 0x3c, 0xb8, 0x53, 0x4, 0x53, 0x2a}; + uint8_t bytesprops2[] = {0xdb, 0xc4, 0xc4, 0xd4, 0x86, 0xd, 0x96, 0xee, 0x4c}; + uint8_t bytesprops3[] = {0x83, 0x45, 0xd0, 0xf, 0x25, 0xf6, 0x79, 0x10, 0x2a, 0x89, 0xd0, 0xa8, + 0x99, 0x35, 0xbd, 0xb6, 0xe2, 0x78, 0x4f, 0xee, 0x48, 0xe7, 0x94}; + uint8_t bytesprops4[] = {0x67, 0x9b, 0x11, 0x37, 0xfb, 0x83, 0x53, 0x8e, 0x5e, 0xd3, 0x8f, + 0x4c, 0x2, 0x47, 0x34, 0x3, 0x16, 0x92, 0x61, 0xcf, 0xa0}; + uint8_t bytesprops5[] = {0xf6}; + uint8_t bytesprops6[] = {0xff, 0xf0, 0xb9, 0x2, 0x45, 0x74, 0xc0, 0x52}; + uint8_t bytesprops7[] = {0x92, 0x28, 0x55, 0x2a, 0xf9, 0xe1, 0x59, 0xd7, 0xd7, 0x79, 0xe8, + 0xd5, 0x6, 0x33, 0xd9, 0xea, 0xca, 0x92, 0x3f, 0x97, 0x74}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8353}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4183}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12629}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28020}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3381}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26137}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18520}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11013}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5774}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22265}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 768}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2168}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19691}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6475}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22169, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14558, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26097 [("v\164\210X\179\135t\206\&0\177\165^\196\160\166\NUL78m}\195Z\147.rbC\177s9",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\255q\244\v\147\250\213/\143\151\&8\168\&9",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("l\168W:Wa\253\147\225\RS\164\242-;r')",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\DC15\NUL\236\249\231\210\141\246\n\ENQ\v\248\RS\USX\132\CAN\214\143w\202\139;]4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\231A\154h\ETX\223a\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2})] [PropSubscriptionIdentifierAvailable 148,PropServerKeepAlive -// 6026,PropRequestProblemInformation 208,PropReceiveMaximum 1568,PropSessionExpiryInterval -// 6779,PropWildcardSubscriptionAvailable 41,PropCorrelationData -// "\161q\177U\178\194&M\208\&9\141\186\248\ACK\240\176\188q\226!\159\206\235\144\f",PropReasonString -// "",PropMessageExpiryInterval 26488,PropWillDelayInterval 12556] +// SubscribeRequest 14679 [("\207`\174\172K_\ENQ",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = True, _subQoS = QoS2}),(";\232\&5\184JOL\164\ETX\139\154`\228+\DC23`\228",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropUserProperty +// "\185\227\SO.\161\152\a4\DEL\215\158\230U" +// "\213a\t\153\169\&3\128\173\135\197\254x\135!\229on9z\246L\224\&2U\151",PropAuthenticationData +// "1\131\187;\SOH\241\172",PropMessageExpiryInterval 23772,PropWillDelayInterval 2648,PropSessionExpiryInterval +// 32304,PropAssignedClientIdentifier "",PropAssignedClientIdentifier "\206\152&",PropUserProperty "\231x" +// "\169\253\236\RS\208\&7!\196\137\230~d}\STX\140\203o\228\188Z\231\146@",PropCorrelationData +// "\228\204e\240y\176\160\143]",PropMessageExpiryInterval 30439] +TEST(Subscribe5QCTest, Encode22) { + uint8_t pkt[] = {0x82, 0x9e, 0x1, 0x39, 0x57, 0x7c, 0x26, 0x0, 0xd, 0xb9, 0xe3, 0xe, 0x2e, 0xa1, 0x98, 0x7, 0x34, + 0x7f, 0xd7, 0x9e, 0xe6, 0x55, 0x0, 0x19, 0xd5, 0x61, 0x9, 0x99, 0xa9, 0x33, 0x80, 0xad, 0x87, 0xc5, + 0xfe, 0x78, 0x87, 0x21, 0xe5, 0x6f, 0x6e, 0x39, 0x7a, 0xf6, 0x4c, 0xe0, 0x32, 0x55, 0x97, 0x16, 0x0, + 0x7, 0x31, 0x83, 0xbb, 0x3b, 0x1, 0xf1, 0xac, 0x2, 0x0, 0x0, 0x5c, 0xdc, 0x18, 0x0, 0x0, 0xa, + 0x58, 0x11, 0x0, 0x0, 0x7e, 0x30, 0x12, 0x0, 0x0, 0x12, 0x0, 0x3, 0xce, 0x98, 0x26, 0x26, 0x0, + 0x2, 0xe7, 0x78, 0x0, 0x17, 0xa9, 0xfd, 0xec, 0x1e, 0xd0, 0x37, 0x21, 0xc4, 0x89, 0xe6, 0x7e, 0x64, + 0x7d, 0x2, 0x8c, 0xcb, 0x6f, 0xe4, 0xbc, 0x5a, 0xe7, 0x92, 0x40, 0x9, 0x0, 0x9, 0xe4, 0xcc, 0x65, + 0xf0, 0x79, 0xb0, 0xa0, 0x8f, 0x5d, 0x2, 0x0, 0x0, 0x76, 0xe7, 0x0, 0x7, 0xcf, 0x60, 0xae, 0xac, + 0x4b, 0x5f, 0x5, 0x2e, 0x0, 0x12, 0x3b, 0xe8, 0x35, 0xb8, 0x4a, 0x4f, 0x4c, 0xa4, 0x3, 0x8b, 0x9a, + 0x60, 0xe4, 0x2b, 0x12, 0x33, 0x60, 0xe4, 0xa}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xcf, 0x60, 0xae, 0xac, 0x4b, 0x5f, 0x5}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x3b, 0xe8, 0x35, 0xb8, 0x4a, 0x4f, 0x4c, 0xa4, 0x3, + 0x8b, 0x9a, 0x60, 0xe4, 0x2b, 0x12, 0x33, 0x60, 0xe4}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + uint8_t bytesprops1[] = {0xd5, 0x61, 0x9, 0x99, 0xa9, 0x33, 0x80, 0xad, 0x87, 0xc5, 0xfe, 0x78, 0x87, + 0x21, 0xe5, 0x6f, 0x6e, 0x39, 0x7a, 0xf6, 0x4c, 0xe0, 0x32, 0x55, 0x97}; + uint8_t bytesprops0[] = {0xb9, 0xe3, 0xe, 0x2e, 0xa1, 0x98, 0x7, 0x34, 0x7f, 0xd7, 0x9e, 0xe6, 0x55}; + uint8_t bytesprops2[] = {0x31, 0x83, 0xbb, 0x3b, 0x1, 0xf1, 0xac}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0xce, 0x98, 0x26}; + uint8_t bytesprops6[] = {0xa9, 0xfd, 0xec, 0x1e, 0xd0, 0x37, 0x21, 0xc4, 0x89, 0xe6, 0x7e, 0x64, + 0x7d, 0x2, 0x8c, 0xcb, 0x6f, 0xe4, 0xbc, 0x5a, 0xe7, 0x92, 0x40}; + uint8_t bytesprops5[] = {0xe7, 0x78}; + uint8_t bytesprops7[] = {0xe4, 0xcc, 0x65, 0xf0, 0x79, 0xb0, 0xa0, 0x8f, 0x5d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23772}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2648}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32304}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops5}, .v = {23, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30439}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14679, 2, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 12650 [("\128\169\159\162P\211\&9;",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\208m\216",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\236_\171\216\143\"\186H\168\235\192<\204\ACK\DEL[h\235\178@\147",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\216\RS\142\&4\175O\SOHGI9M\r\US\159\148,2\RS\196\SUB\136\EM\176\GS\129",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(",V\156\135\DC1\226\RS\199Z\rf\r\191.\220.\204\243\227\NAK\198\232\&6$@",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\172\192\171\236\193\&0\139\ENQvR\250\SOH6\160\NAK\191\&9u",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\194\ETXM3U\240\EM\243\176\SO/\205H\143\242wn\138\199\137\156\211\175",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropSessionExpiryInterval +// 1524,PropReceiveMaximum 18350,PropRetainAvailable 238,PropRetainAvailable 182,PropTopicAliasMaximum +// 26470,PropTopicAlias 3473,PropTopicAlias 25376,PropReasonString +// "\139\197G\238\254\211\135\143#\208\159l\178\DC3;\138\220\143",PropContentType +// "3\164f\169Hz\250\131\DC3\129E\SYN\nD\206[\244\192\210",PropSharedSubscriptionAvailable +// 33,PropSharedSubscriptionAvailable 219,PropReceiveMaximum 21214,PropRequestProblemInformation +// 29,PropWillDelayInterval 21731,PropMessageExpiryInterval 7458,PropResponseInformation +// "\ENQ\f\CAN\STXj\237\148\199",PropWildcardSubscriptionAvailable 244,PropContentType +// "=\209\191N\169\248_\245J9\235\197d\244\190\136\185\164\&2\205e\200\251",PropMessageExpiryInterval +// 20023,PropMessageExpiryInterval 19469,PropTopicAlias 12641,PropMaximumQoS 15,PropSubscriptionIdentifierAvailable +// 193,PropMessageExpiryInterval 3100,PropResponseInformation "Nk\142=&1\154/#\251\231\153I",PropWillDelayInterval 6949] TEST(Subscribe5QCTest, Encode23) { - uint8_t pkt[] = {0x82, 0xaa, 0x1, 0x65, 0xf1, 0x3a, 0x29, 0x94, 0x13, 0x17, 0x8a, 0x17, 0xd0, 0x21, 0x6, 0x20, - 0x11, 0x0, 0x0, 0x1a, 0x7b, 0x28, 0x29, 0x9, 0x0, 0x19, 0xa1, 0x71, 0xb1, 0x55, 0xb2, 0xc2, - 0x26, 0x4d, 0xd0, 0x39, 0x8d, 0xba, 0xf8, 0x6, 0xf0, 0xb0, 0xbc, 0x71, 0xe2, 0x21, 0x9f, 0xce, - 0xeb, 0x90, 0xc, 0x1f, 0x0, 0x0, 0x2, 0x0, 0x0, 0x67, 0x78, 0x18, 0x0, 0x0, 0x31, 0xc, - 0x0, 0x1e, 0x76, 0xa4, 0xd2, 0x58, 0xb3, 0x87, 0x74, 0xce, 0x30, 0xb1, 0xa5, 0x5e, 0xc4, 0xa0, - 0xa6, 0x0, 0x37, 0x38, 0x6d, 0x7d, 0xc3, 0x5a, 0x93, 0x2e, 0x72, 0x62, 0x43, 0xb1, 0x73, 0x39, - 0x2, 0x0, 0xd, 0xff, 0x71, 0xf4, 0xb, 0x93, 0xfa, 0xd5, 0x2f, 0x8f, 0x97, 0x38, 0xa8, 0x39, - 0x0, 0x0, 0x11, 0x6c, 0xa8, 0x57, 0x3a, 0x57, 0x61, 0xfd, 0x93, 0xe1, 0x1e, 0xa4, 0xf2, 0x2d, - 0x3b, 0x72, 0x27, 0x29, 0x0, 0x0, 0x1a, 0x11, 0x35, 0x0, 0xec, 0xf9, 0xe7, 0xd2, 0x8d, 0xf6, - 0xa, 0x5, 0xb, 0xf8, 0x1e, 0x1f, 0x58, 0x84, 0x18, 0xd6, 0x8f, 0x77, 0xca, 0x8b, 0x3b, 0x5d, - 0x34, 0x0, 0x0, 0x8, 0xe7, 0x41, 0x9a, 0x68, 0x3, 0xdf, 0x61, 0xc5, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x76, 0xa4, 0xd2, 0x58, 0xb3, 0x87, 0x74, 0xce, 0x30, 0xb1, - 0xa5, 0x5e, 0xc4, 0xa0, 0xa6, 0x0, 0x37, 0x38, 0x6d, 0x7d, - 0xc3, 0x5a, 0x93, 0x2e, 0x72, 0x62, 0x43, 0xb1, 0x73, 0x39}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + uint8_t pkt[] = { + 0x82, 0xb9, 0x2, 0x31, 0x6a, 0xa5, 0x1, 0x11, 0x0, 0x0, 0x5, 0xf4, 0x21, 0x47, 0xae, 0x25, 0xee, 0x25, 0xb6, + 0x22, 0x67, 0x66, 0x23, 0xd, 0x91, 0x23, 0x63, 0x20, 0x1f, 0x0, 0x12, 0x8b, 0xc5, 0x47, 0xee, 0xfe, 0xd3, 0x87, + 0x8f, 0x23, 0xd0, 0x9f, 0x6c, 0xb2, 0x13, 0x3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, 0x1e, 0xc4, 0x1a, 0x88, 0x19, 0xb0, 0x1d, 0x81, 0x20, 0x0, 0x19, 0x2c, 0x56, 0x9c, 0x87, + 0x11, 0xe2, 0x1e, 0xc7, 0x5a, 0xd, 0x66, 0xd, 0xbf, 0x2e, 0xdc, 0x2e, 0xcc, 0xf3, 0xe3, 0x15, 0xc6, 0xe8, 0x36, + 0x24, 0x40, 0x2e, 0x0, 0x12, 0xac, 0xc0, 0xab, 0xec, 0xc1, 0x30, 0x8b, 0x5, 0x76, 0x52, 0xfa, 0x1, 0x36, 0xa0, + 0x15, 0xbf, 0x39, 0x75, 0x1a, 0x0, 0x17, 0xc2, 0x3, 0x4d, 0x33, 0x55, 0xf0, 0x19, 0xf3, 0xb0, 0xe, 0x2f, 0xcd, + 0x48, 0x8f, 0xf2, 0x77, 0x6e, 0x8a, 0xc7, 0x89, 0x9c, 0xd3, 0xaf, 0x1a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x80, 0xa9, 0x9f, 0xa2, 0x50, 0xd3, 0x39, 0x3b}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xff, 0x71, 0xf4, 0xb, 0x93, 0xfa, 0xd5, 0x2f, 0x8f, 0x97, 0x38, 0xa8, 0x39}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd0, 0x6d, 0xd8}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6c, 0xa8, 0x57, 0x3a, 0x57, 0x61, 0xfd, 0x93, 0xe1, - 0x1e, 0xa4, 0xf2, 0x2d, 0x3b, 0x72, 0x27, 0x29}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xec, 0x5f, 0xab, 0xd8, 0x8f, 0x22, 0xba, 0x48, 0xa8, 0xeb, 0xc0, + 0x3c, 0xcc, 0x6, 0x7f, 0x5b, 0x68, 0xeb, 0xb2, 0x40, 0x93}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x11, 0x35, 0x0, 0xec, 0xf9, 0xe7, 0xd2, 0x8d, 0xf6, 0xa, 0x5, 0xb, 0xf8, - 0x1e, 0x1f, 0x58, 0x84, 0x18, 0xd6, 0x8f, 0x77, 0xca, 0x8b, 0x3b, 0x5d, 0x34}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd8, 0x1e, 0x8e, 0x34, 0xaf, 0x4f, 0x1, 0x47, 0x49, 0x39, 0x4d, 0xd, 0x1f, + 0x9f, 0x94, 0x2c, 0x32, 0x1e, 0xc4, 0x1a, 0x88, 0x19, 0xb0, 0x1d, 0x81}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe7, 0x41, 0x9a, 0x68, 0x3, 0xdf, 0x61, 0xc5}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2c, 0x56, 0x9c, 0x87, 0x11, 0xe2, 0x1e, 0xc7, 0x5a, 0xd, 0x66, 0xd, 0xbf, + 0x2e, 0xdc, 0x2e, 0xcc, 0xf3, 0xe3, 0x15, 0xc6, 0xe8, 0x36, 0x24, 0x40}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0xa1, 0x71, 0xb1, 0x55, 0xb2, 0xc2, 0x26, 0x4d, 0xd0, 0x39, 0x8d, 0xba, 0xf8, - 0x6, 0xf0, 0xb0, 0xbc, 0x71, 0xe2, 0x21, 0x9f, 0xce, 0xeb, 0x90, 0xc}; - uint8_t bytesprops1[] = {0}; + uint8_t topic_filter_s5_bytes[] = {0xac, 0xc0, 0xab, 0xec, 0xc1, 0x30, 0x8b, 0x5, 0x76, + 0x52, 0xfa, 0x1, 0x36, 0xa0, 0x15, 0xbf, 0x39, 0x75}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc2, 0x3, 0x4d, 0x33, 0x55, 0xf0, 0x19, 0xf3, 0xb0, 0xe, 0x2f, 0xcd, + 0x48, 0x8f, 0xf2, 0x77, 0x6e, 0x8a, 0xc7, 0x89, 0x9c, 0xd3, 0xaf}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + uint8_t bytesprops0[] = {0x8b, 0xc5, 0x47, 0xee, 0xfe, 0xd3, 0x87, 0x8f, 0x23, + 0xd0, 0x9f, 0x6c, 0xb2, 0x13, 0x3b, 0x8a, 0xdc, 0x8f}; + uint8_t bytesprops1[] = {0x33, 0xa4, 0x66, 0xa9, 0x48, 0x7a, 0xfa, 0x83, 0x13, 0x81, + 0x45, 0x16, 0xa, 0x44, 0xce, 0x5b, 0xf4, 0xc0, 0xd2}; + uint8_t bytesprops2[] = {0x5, 0xc, 0x18, 0x2, 0x6a, 0xed, 0x94, 0xc7}; + uint8_t bytesprops3[] = {0x3d, 0xd1, 0xbf, 0x4e, 0xa9, 0xf8, 0x5f, 0xf5, 0x4a, 0x39, 0xeb, 0xc5, + 0x64, 0xf4, 0xbe, 0x88, 0xb9, 0xa4, 0x32, 0xcd, 0x65, 0xc8, 0xfb}; + uint8_t bytesprops4[] = {0x4e, 0x6b, 0x8e, 0x3d, 0x26, 0x31, 0x9a, 0x2f, 0x23, 0xfb, 0xe7, 0x99, 0x49}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6026}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1568}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6779}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26488}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12556}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1524}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18350}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26470}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3473}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25376}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21214}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21731}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7458}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20023}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19469}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12641}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3100}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6949}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26097, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12650, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25578 [("\151\169\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),("\129L\179D\b\\\136\147\&3\187\140\205\216\221\151\ENQ\149\128\155\211\210E\ENQ\240\&8q\203\180",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("F\219rm{\255\FS\161\228\207\147\157(\236.\DC1\150\EM$|\138p\253$u\SYN8\237\ENQ",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\196\SO\SI\252\189a\168*\239<\226M(\228'\183H\223\&9\165\220\ACK\229R\158\151\209n\151\248",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReasonString -// "\211\230\aA;\158,;\159\208\233\171\239\224\206",PropRequestResponseInformation 10] +// SubscribeRequest 3665 [("\RS2\128\242",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [PropAuthenticationData +// "P\197\SUB\SOH\205\194X\150\224[\222\f\SO(\161\145D\CAN\233\ACKy\204\243@\149\164",PropSubscriptionIdentifier 10] TEST(Subscribe5QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x7d, 0x63, 0xea, 0x14, 0x1f, 0x0, 0xf, 0xd3, 0xe6, 0x7, 0x41, 0x3b, 0x9e, 0x2c, 0x3b, - 0x9f, 0xd0, 0xe9, 0xab, 0xef, 0xe0, 0xce, 0x19, 0xa, 0x0, 0x3, 0x97, 0xa9, 0xa, 0x0, 0x0, - 0x1c, 0x81, 0x4c, 0xb3, 0x44, 0x8, 0x5c, 0x88, 0x93, 0x33, 0xbb, 0x8c, 0xcd, 0xd8, 0xdd, 0x97, - 0x5, 0x95, 0x80, 0x9b, 0xd3, 0xd2, 0x45, 0x5, 0xf0, 0x38, 0x71, 0xcb, 0xb4, 0x2, 0x0, 0x1d, - 0x46, 0xdb, 0x72, 0x6d, 0x7b, 0xff, 0x1c, 0xa1, 0xe4, 0xcf, 0x93, 0x9d, 0x28, 0xec, 0x2e, 0x11, - 0x96, 0x19, 0x24, 0x7c, 0x8a, 0x70, 0xfd, 0x24, 0x75, 0x16, 0x38, 0xed, 0x5, 0x0, 0x0, 0x1e, - 0xc4, 0xe, 0xf, 0xfc, 0xbd, 0x61, 0xa8, 0x2a, 0xef, 0x3c, 0xe2, 0x4d, 0x28, 0xe4, 0x27, 0xb7, - 0x48, 0xdf, 0x39, 0xa5, 0xdc, 0x6, 0xe5, 0x52, 0x9e, 0x97, 0xd1, 0x6e, 0x97, 0xf8, 0x1}; + uint8_t pkt[] = {0x82, 0x29, 0xe, 0x51, 0x1f, 0x16, 0x0, 0x1a, 0x50, 0xc5, 0x1a, 0x1, 0xcd, 0xc2, 0x58, + 0x96, 0xe0, 0x5b, 0xde, 0xc, 0xe, 0x28, 0xa1, 0x91, 0x44, 0x18, 0xe9, 0x6, 0x79, 0xcc, + 0xf3, 0x40, 0x95, 0xa4, 0xb, 0xa, 0x0, 0x4, 0x1e, 0x32, 0x80, 0xf2, 0x10}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x97, 0xa9, 0xa}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x1e, 0x32, 0x80, 0xf2}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x81, 0x4c, 0xb3, 0x44, 0x8, 0x5c, 0x88, 0x93, 0x33, 0xbb, - 0x8c, 0xcd, 0xd8, 0xdd, 0x97, 0x5, 0x95, 0x80, 0x9b, 0xd3, - 0xd2, 0x45, 0x5, 0xf0, 0x38, 0x71, 0xcb, 0xb4}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x46, 0xdb, 0x72, 0x6d, 0x7b, 0xff, 0x1c, 0xa1, 0xe4, 0xcf, - 0x93, 0x9d, 0x28, 0xec, 0x2e, 0x11, 0x96, 0x19, 0x24, 0x7c, - 0x8a, 0x70, 0xfd, 0x24, 0x75, 0x16, 0x38, 0xed, 0x5}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc4, 0xe, 0xf, 0xfc, 0xbd, 0x61, 0xa8, 0x2a, 0xef, 0x3c, - 0xe2, 0x4d, 0x28, 0xe4, 0x27, 0xb7, 0x48, 0xdf, 0x39, 0xa5, - 0xdc, 0x6, 0xe5, 0x52, 0x9e, 0x97, 0xd1, 0x6e, 0x97, 0xf8}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xd3, 0xe6, 0x7, 0x41, 0x3b, 0x9e, 0x2c, 0x3b, 0x9f, 0xd0, 0xe9, 0xab, 0xef, 0xe0, 0xce}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0x50, 0xc5, 0x1a, 0x1, 0xcd, 0xc2, 0x58, 0x96, 0xe0, 0x5b, 0xde, 0xc, 0xe, + 0x28, 0xa1, 0x91, 0x44, 0x18, 0xe9, 0x6, 0x79, 0xcc, 0xf3, 0x40, 0x95, 0xa4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, }; lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25578, 4, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14161 [("\242\138%q\US\GSY\176\129}=\247",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\STX\132g\171\169\132\132\181\237\223\182gx,",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("g\EMP\174+`\222\SUBP",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("b\255\135\184;\253\174\185R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\236:H\144\155\245+7\DLE\145K>\160Hi\229",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropRetainAvailable -// 229,PropSharedSubscriptionAvailable 181,PropCorrelationData "\168@\222\135S\201,v\DC3\EMCs\188",PropServerReference -// "#\254\ETXo%\246\FS\140UU\199R",PropMaximumPacketSize 4981,PropRequestResponseInformation 181,PropResponseInformation -// "K\132N\150\155f, \ENQ",PropMaximumQoS 117,PropTopicAliasMaximum 19076,PropSharedSubscriptionAvailable -// 135,PropReceiveMaximum 2513,PropTopicAliasMaximum 21119,PropAuthenticationData -// "<\167\NUL6\EMj\162\178\172\131D\181\176\177",PropMaximumQoS 149,PropWillDelayInterval -// 14956,PropSubscriptionIdentifier 2,PropMessageExpiryInterval 1459,PropSubscriptionIdentifierAvailable -// 38,PropContentType "D\237w\230`^\229o\237\&2\185k",PropRetainAvailable 253,PropResponseInformation ""] + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3665, 1, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 23603 [("\197\163\195D\141\173\234\249,\160]\180\nZ\t\FS\244Iu\131s[\184\\",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\182\253\219\136*\159\139\DC1\249\240$r\252\233",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\219\DC4\184\&5M\153\135\234\188\ENQ\184",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\218\185}\160^\f\252\130\170}\"u\132m\185\FS\250\157-\169o\DC4",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\128\158`\237A\207\227\151P\STX\248\177\n\202\STX\130N\183\169\198^",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\207\255b\143\CAN\FS\140\203!\SYN<\138\131V\187.Y\252\186\253\DC1\150",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\191h",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("PsYa\175\245B\255\RS\136\128\GS\201\201wA\\\198\&3tES\184+\244\&5\SYN5",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\224\CAN\160\211\DLE",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropMaximumQoS +// 61,PropTopicAlias 25005,PropSubscriptionIdentifierAvailable 85,PropPayloadFormatIndicator +// 45,PropMessageExpiryInterval 32022,PropWillDelayInterval 2228,PropServerKeepAlive 1756,PropResponseTopic +// "dV",PropRequestResponseInformation 183,PropWillDelayInterval 19475,PropMessageExpiryInterval +// 12359,PropServerKeepAlive 707] TEST(Subscribe5QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0xc6, 0x1, 0x37, 0x51, 0x78, 0x25, 0xe5, 0x2a, 0xb5, 0x9, 0x0, 0xd, 0xa8, 0x40, 0xde, 0x87, - 0x53, 0xc9, 0x2c, 0x76, 0x13, 0x19, 0x43, 0x73, 0xbc, 0x1c, 0x0, 0xc, 0x23, 0xfe, 0x3, 0x6f, 0x25, - 0xf6, 0x1c, 0x8c, 0x55, 0x55, 0xc7, 0x52, 0x27, 0x0, 0x0, 0x13, 0x75, 0x19, 0xb5, 0x1a, 0x0, 0x9, - 0x4b, 0x84, 0x4e, 0x96, 0x9b, 0x66, 0x2c, 0x20, 0x5, 0x24, 0x75, 0x22, 0x4a, 0x84, 0x2a, 0x87, 0x21, - 0x9, 0xd1, 0x22, 0x52, 0x7f, 0x16, 0x0, 0xe, 0x3c, 0xa7, 0x0, 0x36, 0x19, 0x6a, 0xa2, 0xb2, 0xac, - 0x83, 0x44, 0xb5, 0xb0, 0xb1, 0x24, 0x95, 0x18, 0x0, 0x0, 0x3a, 0x6c, 0xb, 0x2, 0x2, 0x0, 0x0, - 0x5, 0xb3, 0x29, 0x26, 0x3, 0x0, 0xc, 0x44, 0xed, 0x77, 0xe6, 0x60, 0x5e, 0xe5, 0x6f, 0xed, 0x32, - 0xb9, 0x6b, 0x25, 0xfd, 0x1a, 0x0, 0x0, 0x0, 0xc, 0xf2, 0x8a, 0x25, 0x71, 0x1f, 0x1d, 0x59, 0xb0, - 0x81, 0x7d, 0x3d, 0xf7, 0x1, 0x0, 0xe, 0x2, 0x84, 0x67, 0xab, 0xa9, 0x84, 0x84, 0xb5, 0xed, 0xdf, - 0xb6, 0x67, 0x78, 0x2c, 0x0, 0x0, 0x9, 0x67, 0x19, 0x50, 0xae, 0x2b, 0x60, 0xde, 0x1a, 0x50, 0x0, - 0x0, 0x9, 0x62, 0xff, 0x87, 0xb8, 0x3b, 0xfd, 0xae, 0xb9, 0x52, 0x2, 0x0, 0x10, 0xec, 0x3a, 0x48, - 0x90, 0x9b, 0xf5, 0x2b, 0x37, 0x10, 0x91, 0x4b, 0x3e, 0xa0, 0x48, 0x69, 0xe5, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xf2, 0x8a, 0x25, 0x71, 0x1f, 0x1d, 0x59, 0xb0, 0x81, 0x7d, 0x3d, 0xf7}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_byt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, 0x28, 0x0, 0x1c, 0x50, 0x73, 0x59, + 0x61, 0xaf, 0xf5, 0x42, 0xff, 0x1e, 0x88, 0x80, 0x1d, 0xc9, 0xc9, 0x77, 0x41, 0x5c, 0xc6, 0x33, 0x74, 0x45, 0x53, + 0xb8, 0x2b, 0xf4, 0x35, 0x16, 0x35, 0x16, 0x0, 0x5, 0xe0, 0x18, 0xa0, 0xd3, 0x10, 0x12, 0x0, 0x0, 0x1e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xc5, 0xa3, 0xc3, 0x44, 0x8d, 0xad, 0xea, 0xf9, 0x2c, 0xa0, 0x5d, 0xb4, + 0xa, 0x5a, 0x9, 0x1c, 0xf4, 0x49, 0x75, 0x83, 0x73, 0x5b, 0xb8, 0x5c}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2, 0x84, 0x67, 0xab, 0xa9, 0x84, 0x84, 0xb5, 0xed, 0xdf, 0xb6, 0x67, 0x78, 0x2c}; + uint8_t topic_filter_s1_bytes[] = {0xb6, 0xfd, 0xdb, 0x88, 0x2a, 0x9f, 0x8b, + 0x11, 0xf9, 0xf0, 0x24, 0x72, 0xfc, 0xe9}; lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x67, 0x19, 0x50, 0xae, 0x2b, 0x60, 0xde, 0x1a, 0x50}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xdb, 0x14, 0xb8, 0x35, 0x4d, 0x99, 0x87, 0xea, 0xbc, 0x5, 0xb8}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x62, 0xff, 0x87, 0xb8, 0x3b, 0xfd, 0xae, 0xb9, 0x52}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xda, 0xb9, 0x7d, 0xa0, 0x5e, 0xc, 0xfc, 0x82, 0xaa, 0x7d, 0x22, + 0x75, 0x84, 0x6d, 0xb9, 0x1c, 0xfa, 0x9d, 0x2d, 0xa9, 0x6f, 0x14}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xec, 0x3a, 0x48, 0x90, 0x9b, 0xf5, 0x2b, 0x37, - 0x10, 0x91, 0x4b, 0x3e, 0xa0, 0x48, 0x69, 0xe5}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x80, 0x9e, 0x60, 0xed, 0x41, 0xcf, 0xe3, 0x97, 0x50, 0x2, 0xf8, + 0xb1, 0xa, 0xca, 0x2, 0x82, 0x4e, 0xb7, 0xa9, 0xc6, 0x5e}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS0, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xa8, 0x40, 0xde, 0x87, 0x53, 0xc9, 0x2c, 0x76, 0x13, 0x19, 0x43, 0x73, 0xbc}; - uint8_t bytesprops1[] = {0x23, 0xfe, 0x3, 0x6f, 0x25, 0xf6, 0x1c, 0x8c, 0x55, 0x55, 0xc7, 0x52}; - uint8_t bytesprops2[] = {0x4b, 0x84, 0x4e, 0x96, 0x9b, 0x66, 0x2c, 0x20, 0x5}; - uint8_t bytesprops3[] = {0x3c, 0xa7, 0x0, 0x36, 0x19, 0x6a, 0xa2, 0xb2, 0xac, 0x83, 0x44, 0xb5, 0xb0, 0xb1}; - uint8_t bytesprops4[] = {0x44, 0xed, 0x77, 0xe6, 0x60, 0x5e, 0xe5, 0x6f, 0xed, 0x32, 0xb9, 0x6b}; - uint8_t bytesprops5[] = {0}; + uint8_t topic_filter_s5_bytes[] = {0xcf, 0xff, 0x62, 0x8f, 0x18, 0x1c, 0x8c, 0xcb, 0x21, 0x16, 0x3c, + 0x8a, 0x83, 0x56, 0xbb, 0x2e, 0x59, 0xfc, 0xba, 0xfd, 0x11, 0x96}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xbf, 0x68}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x50, 0x73, 0x59, 0x61, 0xaf, 0xf5, 0x42, 0xff, 0x1e, 0x88, + 0x80, 0x1d, 0xc9, 0xc9, 0x77, 0x41, 0x5c, 0xc6, 0x33, 0x74, + 0x45, 0x53, 0xb8, 0x2b, 0xf4, 0x35, 0x16, 0x35}; + lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe0, 0x18, 0xa0, 0xd3, 0x10}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0}; + lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = true; + uint8_t bytesprops0[] = {0x64, 0x56}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4981}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19076}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2513}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21119}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14956}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1459}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25005}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32022}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2228}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1756}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19475}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12359}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 707}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14161, 5, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23603, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3024 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("\151\241\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("O\234$\nG\215\255\&2\ETB\153\&8\213\230\161zr\149C\SOH",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(".\ETB\199\SYN\173\&1M\183\r\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\RSe\157a\193\189\&8%\189\238lr\136\251\194l\\\219ii",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\n\222\134\168\193\203",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS1})] [PropSubscriptionIdentifier 22,PropSubscriptionIdentifierAvailable -// 190,PropSessionExpiryInterval 31925,PropRetainAvailable 98,PropRequestResponseInformation 158,PropMaximumPacketSize -// 29435,PropAssignedClientIdentifier -// "n\134\201Y\ACK\225;%\USv\239v$r\229H\247\255\155<\SYN\235K\233",PropServerKeepAlive -// 12673,PropRequestProblemInformation 198,PropReasonString -// "\203\253!A\ETX\198\166\145\160\215\147\f\170\EOT\216\168\230\245\SI",PropServerReference "\174'",PropTopicAlias -// 17867] +// SubscribeRequest 26458 [("\183`M\228xY\249D",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS1}),("\237\157\196\228p\189\168\211",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\255\152\155\238\160\241#",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS1}),("\221\172",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// True, _noLocal = True, _subQoS = +// QoS1}),("\212\176\130\245\147\226D\DC1\170\164\SOH\210`>\241\244\135\149\243\210\198#\166\227\243\195\ACK",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("S/\168!^A\129\141\161\212\235\177",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// True, _noLocal = True, _subQoS = QoS1}),("\160\228\STX\163#\156\211",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\131(\196qI\152p\148\234\235i\148\219\186\139A\137\SI\188\207\164\132%.\135G_\229\211\254",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropTopicAlias +// 19703] TEST(Subscribe5QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x9f, 0x1, 0xb, 0xd0, 0x50, 0xb, 0x16, 0x29, 0xbe, 0x11, 0x0, 0x0, 0x7c, 0xb5, 0x25, 0x62, - 0x19, 0x9e, 0x27, 0x0, 0x0, 0x72, 0xfb, 0x12, 0x0, 0x18, 0x6e, 0x86, 0xc9, 0x59, 0x6, 0xe1, 0x3b, - 0x25, 0x1f, 0x76, 0xef, 0x76, 0x24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1, 0xf4, 0x87, 0x95, 0xf3, 0xd2, + 0xc6, 0x23, 0xa6, 0xe3, 0xf3, 0xc3, 0x6, 0x8, 0x0, 0xc, 0x53, 0x2f, 0xa8, 0x21, 0x5e, 0x41, 0x81, + 0x8d, 0xa1, 0xd4, 0xeb, 0xb1, 0x1d, 0x0, 0x7, 0xa0, 0xe4, 0x2, 0xa3, 0x23, 0x9c, 0xd3, 0x10, 0x0, + 0x1e, 0x83, 0x28, 0xc4, 0x71, 0x49, 0x98, 0x70, 0x94, 0xea, 0xeb, 0x69, 0x94, 0xdb, 0xba, 0x8b, 0x41, + 0x89, 0xf, 0xbc, 0xcf, 0xa4, 0x84, 0x25, 0x2e, 0x87, 0x47, 0x5f, 0xe5, 0xd3, 0xfe, 0xd}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xb7, 0x60, 0x4d, 0xe4, 0x78, 0x59, 0xf9, 0x44}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x97, 0xf1, 0xd9}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xed, 0x9d, 0xc4, 0xe4, 0x70, 0xbd, 0xa8, 0xd3}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4f, 0xea, 0x24, 0xa, 0x47, 0xd7, 0xff, 0x32, 0x17, 0x99, - 0x38, 0xd5, 0xe6, 0xa1, 0x7a, 0x72, 0x95, 0x43, 0x1}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xff, 0x98, 0x9b, 0xee, 0xa0, 0xf1, 0x23}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2e, 0x17, 0xc7, 0x16, 0xad, 0x31, 0x4d, 0xb7, 0xd, 0xe8}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xdd, 0xac}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x1e, 0x65, 0x9d, 0x61, 0xc1, 0xbd, 0x38, 0x25, 0xbd, 0xee, - 0x6c, 0x72, 0x88, 0xfb, 0xc2, 0x6c, 0x5c, 0xdb, 0x69, 0x69}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd4, 0xb0, 0x82, 0xf5, 0x93, 0xe2, 0x44, 0x11, 0xaa, 0xa4, 0x1, 0xd2, 0x60, 0x3e, + 0xf1, 0xf4, 0x87, 0x95, 0xf3, 0xd2, 0xc6, 0x23, 0xa6, 0xe3, 0xf3, 0xc3, 0x6}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa, 0xde, 0x86, 0xa8, 0xc1, 0xcb}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x53, 0x2f, 0xa8, 0x21, 0x5e, 0x41, 0x81, 0x8d, 0xa1, 0xd4, 0xeb, 0xb1}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0x6e, 0x86, 0xc9, 0x59, 0x6, 0xe1, 0x3b, 0x25, 0x1f, 0x76, 0xef, 0x76, - 0x24, 0x72, 0xe5, 0x48, 0xf7, 0xff, 0x9b, 0x3c, 0x16, 0xeb, 0x4b, 0xe9}; - uint8_t bytesprops1[] = {0xcb, 0xfd, 0x21, 0x41, 0x3, 0xc6, 0xa6, 0x91, 0xa0, 0xd7, - 0x93, 0xc, 0xaa, 0x4, 0xd8, 0xa8, 0xe6, 0xf5, 0xf}; - uint8_t bytesprops2[] = {0xae, 0x27}; + uint8_t topic_filter_s6_bytes[] = {0xa0, 0xe4, 0x2, 0xa3, 0x23, 0x9c, 0xd3}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x83, 0x28, 0xc4, 0x71, 0x49, 0x98, 0x70, 0x94, 0xea, 0xeb, + 0x69, 0x94, 0xdb, 0xba, 0x8b, 0x41, 0x89, 0xf, 0xbc, 0xcf, + 0xa4, 0x84, 0x25, 0x2e, 0x87, 0x47, 0x5f, 0xe5, 0xd3, 0xfe}; + lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31925}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29435}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12673}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17867}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19703}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3024, 6, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26458, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9912 [("\204\190\NUL\161\131\ETB\243~\129\US,\199",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DC1\203\202\209\&0T*Orh\223",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropSessionExpiryInterval 23397,PropMessageExpiryInterval 16143,PropPayloadFormatIndicator -// 2,PropSubscriptionIdentifier 28,PropWildcardSubscriptionAvailable 213,PropAuthenticationData -// "\203\203\200",PropServerReference -// "\152$\189\SYN\199Nol\157q(\249\200\136\DC2;\183\188\182H\176\246\DC3\155\135\234\196\192f2",PropUserProperty -// "\177\250R\155\221\159" "\134\190V\142z\v\RS\fS\STX4\220\226(.\166@Y\DC4\161C\231f\188\245\NUL",PropMaximumPacketSize -// 31086,PropMessageExpiryInterval 23028,PropResponseInformation -// "}\137\226\219\STX\232\167}\186{7\207#\235\SO\141B\177\203\146m\199\DC2\SYN\164\207$@",PropCorrelationData -// "\200\141\155\249\214g\178\NAK\195HO\244J;\137\136\SYN\174y\216J\139\&5\198\232\247\171$\209",PropAssignedClientIdentifier -// "\254",PropCorrelationData ";W\145\174\193\229\224",PropAuthenticationMethod -// "\163\175\160\202\SYNo\SYN\226\220\235\208\r\183&&",PropServerKeepAlive 16294,PropTopicAliasMaximum -// 7201,PropRetainAvailable 72,PropAuthenticationData "_",PropServerKeepAlive 9880] +// SubscribeRequest 4488 [("y\134]",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = +// True, _subQoS = QoS2}),("M\251\156z\tw\201\201\201\b\244\145\253\166",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\207h\177E\207\162\163\233\143",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\CAN\241\ENQ/\"M\212\227\&2\237\164<\230\204\237\206eX\208\194\&7.",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\234\233uo\245\154\131\&5#\223~@\NAKY\140\175\191\179\141\129\166)\188k",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\233:\215\250\&2\131\227\DLE^\175J",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// True, _noLocal = False, _subQoS = QoS1})] [PropUserProperty "X\209\219\188\147\227\"\178Px\134" +// "_\162Wd#\149\162B%w",PropUserProperty "\157@\128\203\184\135K\181\ENQ\218\192" +// "\159\221\165\223\247\US\209;c\STX,\250\\8\178f\ENQ}\247\145\211\243e\137\189\DC2\128Tp",PropServerKeepAlive +// 4430,PropRetainAvailable 20,PropServerKeepAlive 12100,PropAssignedClientIdentifier +// "\a\146\174gc\227\SYNX\144\191\&4@\220UV\227QtI\146\CAN\130\152<:\ENQ",PropMessageExpiryInterval +// 27248,PropResponseInformation "\234\243\SI\212",PropSubscriptionIdentifier 4] TEST(Subscribe5QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0xf5, 0x1, 0x26, 0xb8, 0xd4, 0x1, 0x11, 0x0, 0x0, 0x5b, 0x65, 0x2, 0x0, 0x0, 0x3f, 0xf, - 0x1, 0x2, 0xb, 0x1c, 0x28, 0xd5, 0x16, 0x0, 0x3, 0xcb, 0xcb, 0xc8, 0x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x0, 0x9, + 0xcf, 0x68, 0xb1, 0x45, 0xcf, 0xa2, 0xa3, 0xe9, 0x8f, 0x24, 0x0, 0x16, 0x18, 0xf1, 0x5, 0x2f, 0x22, + 0x4d, 0xd4, 0xe3, 0x32, 0xed, 0xa4, 0x3c, 0xe6, 0xcc, 0xed, 0xce, 0x65, 0x58, 0xd0, 0xc2, 0x37, 0x2e, + 0x1d, 0x0, 0x18, 0xea, 0xe9, 0x75, 0x6f, 0xf5, 0x9a, 0x83, 0x35, 0x23, 0xdf, 0x7e, 0x40, 0x15, 0x59, + 0x8c, 0xaf, 0xbf, 0xb3, 0x8d, 0x81, 0xa6, 0x29, 0xbc, 0x6b, 0x18, 0x0, 0xb, 0xe9, 0x3a, 0xd7, 0xfa, + 0x32, 0x83, 0xe3, 0x10, 0x5e, 0xaf, 0x4a, 0x19}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xcc, 0xbe, 0x0, 0xa1, 0x83, 0x17, 0xf3, 0x7e, 0x81, 0x1f, 0x2c, 0xc7}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x79, 0x86, 0x5d}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x11, 0xcb, 0xca, 0xd1, 0x30, 0x54, 0x2a, 0x4f, 0x72, 0x68, 0xdf}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4d, 0xfb, 0x9c, 0x7a, 0x9, 0x77, 0xc9, 0xc9, 0xc9, 0x8, 0xf4, 0x91, 0xfd, 0xa6}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xcb, 0xcb, 0xc8}; - uint8_t bytesprops1[] = {0x98, 0x24, 0xbd, 0x16, 0xc7, 0x4e, 0x6f, 0x6c, 0x9d, 0x71, 0x28, 0xf9, 0xc8, 0x88, 0x12, - 0x3b, 0xb7, 0xbc, 0xb6, 0x48, 0xb0, 0xf6, 0x13, 0x9b, 0x87, 0xea, 0xc4, 0xc0, 0x66, 0x32}; - uint8_t bytesprops3[] = {0x86, 0xbe, 0x56, 0x8e, 0x7a, 0xb, 0x1e, 0xc, 0x53, 0x2, 0x34, 0xdc, 0xe2, - 0x28, 0x2e, 0xa6, 0x40, 0x59, 0x14, 0xa1, 0x43, 0xe7, 0x66, 0xbc, 0xf5, 0x0}; - uint8_t bytesprops2[] = {0xb1, 0xfa, 0x52, 0x9b, 0xdd, 0x9f}; - uint8_t bytesprops4[] = {0x7d, 0x89, 0xe2, 0xdb, 0x2, 0xe8, 0xa7, 0x7d, 0xba, 0x7b, 0x37, 0xcf, 0x23, 0xeb, - 0xe, 0x8d, 0x42, 0xb1, 0xcb, 0x92, 0x6d, 0xc7, 0x12, 0x16, 0xa4, 0xcf, 0x24, 0x40}; - uint8_t bytesprops5[] = {0xc8, 0x8d, 0x9b, 0xf9, 0xd6, 0x67, 0xb2, 0x15, 0xc3, 0x48, 0x4f, 0xf4, 0x4a, 0x3b, 0x89, - 0x88, 0x16, 0xae, 0x79, 0xd8, 0x4a, 0x8b, 0x35, 0xc6, 0xe8, 0xf7, 0xab, 0x24, 0xd1}; - uint8_t bytesprops6[] = {0xfe}; - uint8_t bytesprops7[] = {0x3b, 0x57, 0x91, 0xae, 0xc1, 0xe5, 0xe0}; - uint8_t bytesprops8[] = {0xa3, 0xaf, 0xa0, 0xca, 0x16, 0x6f, 0x16, 0xe2, 0xdc, 0xeb, 0xd0, 0xd, 0xb7, 0x26, 0x26}; - uint8_t bytesprops9[] = {0x5f}; + uint8_t topic_filter_s2_bytes[] = {0xcf, 0x68, 0xb1, 0x45, 0xcf, 0xa2, 0xa3, 0xe9, 0x8f}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x18, 0xf1, 0x5, 0x2f, 0x22, 0x4d, 0xd4, 0xe3, 0x32, 0xed, 0xa4, + 0x3c, 0xe6, 0xcc, 0xed, 0xce, 0x65, 0x58, 0xd0, 0xc2, 0x37, 0x2e}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xea, 0xe9, 0x75, 0x6f, 0xf5, 0x9a, 0x83, 0x35, 0x23, 0xdf, 0x7e, 0x40, + 0x15, 0x59, 0x8c, 0xaf, 0xbf, 0xb3, 0x8d, 0x81, 0xa6, 0x29, 0xbc, 0x6b}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe9, 0x3a, 0xd7, 0xfa, 0x32, 0x83, 0xe3, 0x10, 0x5e, 0xaf, 0x4a}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + uint8_t bytesprops1[] = {0x5f, 0xa2, 0x57, 0x64, 0x23, 0x95, 0xa2, 0x42, 0x25, 0x77}; + uint8_t bytesprops0[] = {0x58, 0xd1, 0xdb, 0xbc, 0x93, 0xe3, 0x22, 0xb2, 0x50, 0x78, 0x86}; + uint8_t bytesprops3[] = {0x9f, 0xdd, 0xa5, 0xdf, 0xf7, 0x1f, 0xd1, 0x3b, 0x63, 0x2, 0x2c, 0xfa, 0x5c, 0x38, 0xb2, + 0x66, 0x5, 0x7d, 0xf7, 0x91, 0xd3, 0xf3, 0x65, 0x89, 0xbd, 0x12, 0x80, 0x54, 0x70}; + uint8_t bytesprops2[] = {0x9d, 0x40, 0x80, 0xcb, 0xb8, 0x87, 0x4b, 0xb5, 0x5, 0xda, 0xc0}; + uint8_t bytesprops4[] = {0x7, 0x92, 0xae, 0x67, 0x63, 0xe3, 0x16, 0x58, 0x90, 0xbf, 0x34, 0x40, 0xdc, + 0x55, 0x56, 0xe3, 0x51, 0x74, 0x49, 0x92, 0x18, 0x82, 0x98, 0x3c, 0x3a, 0x5}; + uint8_t bytesprops5[] = {0xea, 0xf3, 0xf, 0xd4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23397}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16143}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops2}, .v = {26, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31086}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23028}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16294}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7201}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9880}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops2}, .v = {29, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4430}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12100}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27248}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9912, 2, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4488, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 1301 [("\169n\168\166N\214\SUB\136\156\134\ETX\228",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\135#\130r\206\254\133s<\ACK\143\200\154\229\227\169\217\244'",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\fBj\fR\208\210\189\190\148\STX\164}\163\214\183[\143",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("k\172\154\253f\170\&7\CANjg\185\r\ESC\192\ENQQi}\209\SI",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\239\236Y\220\224\191\&6",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\SIw*X&\ty\181\188:}\219,}\247\219>\NAK\167\177j0\188\197L\232@EJ",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\ACK2c\237\191\199*",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\206Cz\139\148\189dN%",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\141=\196\133f1r\DELf#h\161,8\131",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReceiveMaximum 25435,PropResponseInformation -// "\SO\202\a\208j",PropAssignedClientIdentifier -// "\140\131\133\CAN\r\193\218\195\205\167\RS\SOS5\153\226\197r\FS1^\186\DC4\148\162\194",PropMessageExpiryInterval -// 7651,PropMessageExpiryInterval 22861,PropRequestProblemInformation 27,PropServerKeepAlive -// 2068,PropMessageExpiryInterval 6609,PropWillDelayInterval 16160,PropWillDelayInterval 17380,PropResponseInformation -// "M",PropResponseInformation -// "\136\128\193\SYN\DEL(\245#\166\220\177\176\ESCT\211\249%\207dt\170\152\244\175\215K\t)\133",PropTopicAlias 14154] +// SubscribeRequest 28692 +// [("a^z\164{\209P\192\235d\163\187\135\198\205\238\DC4\185h\146\199\197\&9\223\220\253",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("]\163\DC3\140]\129\245\224\164\163S",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = True, _subQoS = +// QoS2}),("\171\&1\208\132\SI\194\193m\ACK\203\239\SIx\ENQ\218\160O|1\235Y:\184\174",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\176\STX\244\239\208df\183(B\197x;\189\224\232 Y\218\155f\135\149v\249d\245\FS\208L",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\n#\223\137\184\136\225",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = +// QoS1}),("`\RS8\b\137\129\FS#\SO\234\SYN\192\217\144A'\216\235\227\226\ai\205\207}c",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("V\224\171\163j",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe5QCTest, Encode28) { - uint8_t pkt[] = { - 0x82, 0x93, 0x2, 0x5, 0x15, 0x6d, 0x21, 0x63, 0x5b, 0x1a, 0x0, 0x5, 0xe, 0xca, 0x7, 0xd0, 0x6a, 0x12, 0x0, - 0x1a, 0x8c, 0x83, 0x85, 0x18, 0xd, 0xc1, 0xda, 0xc3, 0xcd, 0xa7, 0x1e, 0xe, 0x53, 0x35, 0x99, 0xe2, 0xc5, 0x72, - 0x1c, 0x31, 0x5e, 0xba, 0x14, 0x94, 0xa2, 0xc2, 0x2, 0x0, 0x0, 0x1d, 0xe3, 0x2, 0x0, 0x0, 0x59, 0x4d, 0x17, - 0x1b, 0x13, 0x8, 0x14, 0x2, 0x0, 0x0, 0x19, 0xd1, 0x18, 0x0, 0x0, 0x3f, 0x20, 0x18, 0x0, 0x0, 0x43, 0xe4, - 0x1a, 0x0, 0x1, 0x4d, 0x1a, 0x0, 0x1d, 0x88, 0x80, 0xc1, 0x16, 0x7f, 0x28, 0xf5, 0x23, 0xa6, 0xdc, 0xb1, 0xb0, - 0x1b, 0x54, 0xd3, 0xf9, 0x25, 0xcf, 0x64, 0x74, 0xaa, 0x98, 0xf4, 0xaf, 0xd7, 0x4b, 0x9, 0x29, 0x85, 0x23, 0x37, - 0x4a, 0x0, 0xc, 0xa9, 0x6e, 0xa8, 0xa6, 0x4e, 0xd6, 0x1a, 0x88, 0x9c, 0x86, 0x3, 0xe4, 0x2, 0x0, 0x13, 0x87, - 0x23, 0x82, 0x72, 0xce, 0xfe, 0x85, 0x73, 0x3c, 0x6, 0x8f, 0xc8, 0x9a, 0xe5, 0xe3, 0xa9, 0xd9, 0xf4, 0x27, 0x2, - 0x0, 0x12, 0xc, 0x42, 0x6a, 0xc, 0x52, 0xd0, 0xd2,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, 0xa0, 0x4f, 0x7c, 0x31, 0xeb, 0x59, 0x3a, 0xb8, 0xae, 0x22, 0x0, 0x1e, 0xb0, 0x2, + 0xf4, 0xef, 0xd0, 0x64, 0x66, 0xb7, 0x28, 0x42, 0xc5, 0x78, 0x3b, 0xbd, 0xe0, 0xe8, 0x20, 0x59, + 0xda, 0x9b, 0x66, 0x87, 0x95, 0x76, 0xf9, 0x64, 0xf5, 0x1c, 0xd0, 0x4c, 0x22, 0x0, 0x7, 0xa, + 0x23, 0xdf, 0x89, 0xb8, 0x88, 0xe1, 0x29, 0x0, 0x1a, 0x60, 0x1e, 0x38, 0x8, 0x89, 0x81, 0x1c, + 0x23, 0xe, 0xea, 0x16, 0xc0, 0xd9, 0x90, 0x41, 0x27, 0xd8, 0xeb, 0xe3, 0xe2, 0x7, 0x69, 0xcd, + 0xcf, 0x7d, 0x63, 0x24, 0x0, 0x5, 0x56, 0xe0, 0xab, 0xa3, 0x6a, 0x10}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xa9, 0x6e, 0xa8, 0xa6, 0x4e, 0xd6, 0x1a, 0x88, 0x9c, 0x86, 0x3, 0xe4}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x61, 0x5e, 0x7a, 0xa4, 0x7b, 0xd1, 0x50, 0xc0, 0xeb, 0x64, 0xa3, 0xbb, 0x87, + 0xc6, 0xcd, 0xee, 0x14, 0xb9, 0x68, 0x92, 0xc7, 0xc5, 0x39, 0xdf, 0xdc, 0xfd}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x87, 0x23, 0x82, 0x72, 0xce, 0xfe, 0x85, 0x73, 0x3c, 0x6, - 0x8f, 0xc8, 0x9a, 0xe5, 0xe3, 0xa9, 0xd9, 0xf4, 0x27}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5d, 0xa3, 0x13, 0x8c, 0x5d, 0x81, 0xf5, 0xe0, 0xa4, 0xa3, 0x53}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc, 0x42, 0x6a, 0xc, 0x52, 0xd0, 0xd2, 0xbd, 0xbe, - 0x94, 0x2, 0xa4, 0x7d, 0xa3, 0xd6, 0xb7, 0x5b, 0x8f}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xab, 0x31, 0xd0, 0x84, 0xf, 0xc2, 0xc1, 0x6d, 0x6, 0xcb, 0xef, 0xf, + 0x78, 0x5, 0xda, 0xa0, 0x4f, 0x7c, 0x31, 0xeb, 0x59, 0x3a, 0xb8, 0xae}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6b, 0xac, 0x9a, 0xfd, 0x66, 0xaa, 0x37, 0x18, 0x6a, 0x67, - 0xb9, 0xd, 0x1b, 0xc0, 0x5, 0x51, 0x69, 0x7d, 0xd1, 0xf}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xb0, 0x2, 0xf4, 0xef, 0xd0, 0x64, 0x66, 0xb7, 0x28, 0x42, + 0xc5, 0x78, 0x3b, 0xbd, 0xe0, 0xe8, 0x20, 0x59, 0xda, 0x9b, + 0x66, 0x87, 0x95, 0x76, 0xf9, 0x64, 0xf5, 0x1c, 0xd0, 0x4c}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xef, 0xec, 0x59, 0xdc, 0xe0, 0xbf, 0x36}; + uint8_t topic_filter_s4_bytes[] = {0xa, 0x23, 0xdf, 0x89, 0xb8, 0x88, 0xe1}; lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf, 0x77, 0x2a, 0x58, 0x26, 0x9, 0x79, 0xb5, 0xbc, 0x3a, - 0x7d, 0xdb, 0x2c, 0x7d, 0xf7, 0xdb, 0x3e, 0x15, 0xa7, 0xb1, - 0x6a, 0x30, 0xbc, 0xc5, 0x4c, 0xe8, 0x40, 0x45, 0x4a}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x60, 0x1e, 0x38, 0x8, 0x89, 0x81, 0x1c, 0x23, 0xe, 0xea, 0x16, 0xc0, 0xd9, + 0x90, 0x41, 0x27, 0xd8, 0xeb, 0xe3, 0xe2, 0x7, 0x69, 0xcd, 0xcf, 0x7d, 0x63}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6, 0x32, 0x63, 0xed, 0xbf, 0xc7, 0x2a}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x56, 0xe0, 0xab, 0xa3, 0x6a}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xce, 0x43, 0x7a, 0x8b, 0x94, 0xbd, 0x64, 0x4e, 0x25}; - lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x8d, 0x3d, 0xc4, 0x85, 0x66, 0x31, 0x72, 0x7f, - 0x66, 0x23, 0x68, 0xa1, 0x2c, 0x38, 0x83}; - lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS0, LWMQTT_QOS1, - LWMQTT_QOS2, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS1}; - uint8_t bytesprops0[] = {0xe, 0xca, 0x7, 0xd0, 0x6a}; - uint8_t bytesprops1[] = {0x8c, 0x83, 0x85, 0x18, 0xd, 0xc1, 0xda, 0xc3, 0xcd, 0xa7, 0x1e, 0xe, 0x53, - 0x35, 0x99, 0xe2, 0xc5, 0x72, 0x1c, 0x31, 0x5e, 0xba, 0x14, 0x94, 0xa2, 0xc2}; - uint8_t bytesprops2[] = {0x4d}; - uint8_t bytesprops3[] = {0x88, 0x80, 0xc1, 0x16, 0x7f, 0x28, 0xf5, 0x23, 0xa6, 0xdc, 0xb1, 0xb0, 0x1b, 0x54, 0xd3, - 0xf9, 0x25, 0xcf, 0x64, 0x74, 0xaa, 0x98, 0xf4, 0xaf, 0xd7, 0x4b, 0x9, 0x29, 0x85}; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25435}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7651}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22861}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2068}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6609}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16160}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17380}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14154}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1301, 9, topic_filters, qos_levels, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 8636 [("\145uzU$\EOTvLk\130\217\133\&5f:\185\180q\t\227B\204\209^",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\185\215\&3\186z",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("5\240\228\136\145<\174p",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS1}),("\"\254g\248Z\ENQ\150\248I.\136:B\b\221BoA",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\155\131g\SOH\199\215Z\164\242\159",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("M\225pW\t\184D\fV\167\186\130\231o\189t\217\233\152\213I@\r\150\142c",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSubscriptionIdentifierAvailable -// 62,PropTopicAlias 25483,PropMaximumQoS 171,PropResponseTopic "]Q[}\219\128\134\170\173\"",PropContentType -// "XXlf1\154\"\130@\204LDr\EMR\233\139\176\DEL=",PropSubscriptionIdentifier 15,PropMaximumPacketSize -// 21894,PropWillDelayInterval 8279,PropCorrelationData "\193\EOT;\210^\219y\bm \250\249\214V_-\248 \STX\244\STX:)"] + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28692, 7, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 11607 [("\200P\177\221",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("A\173\ETX\f\226l\DELM\233\194ndO4\248\238\130\173\224\214",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\246\222N\189z",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, +// _subQoS = QoS2}),("\216\NAKQ\172\ACK\138\167\168\&5&",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\SYN\130\197\169\254\\\180\144\164g\158k",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\NUL\214a\170\SOH\192\ETX\136M\252\SOH\238q\183\ETX\172\138\213$]\154J\166\142\232R",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Mu-|\132\218\214j\253",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = +// QoS0}),("\240\161\131\US\213\DC1\239\222\n\133\218\180j\176p\215\204s\138t\154N\163!\227y(\233l\166",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\237\136f\131sp\148i\158+cYt\ESC;",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// True, _noLocal = True, _subQoS = QoS1})] [PropServerReference "0\150\153\ETBu\184\244",PropAssignedClientIdentifier +// "\187\&9c\"\178\219\255",PropSubscriptionIdentifierAvailable 204,PropAuthenticationMethod +// "0\158\176\141Ot\197\133\129\145){t\158\164\133\192\233\135\251bC",PropServerKeepAlive +// 16637,PropWildcardSubscriptionAvailable 86,PropUserProperty +// "\227\EM\189\244\157\SIuP\206?R\205b\208\187\144W9\179\239S\190\214\DC3\FS=3\249" +// "(\n\t\145\179<\162\157-\n\173\254\225j\148 \176\157",PropTopicAliasMaximum 11024,PropWildcardSubscriptionAvailable +// 220,PropResponseInformation "'\255\218N\162",PropAuthenticationData "\188\220\225\157\193",PropReasonString +// "\236\223KC\DC1\142\140\217\v\229{\182eY\204]",PropReceiveMaximum 11339,PropMessageExpiryInterval +// 12885,PropResponseInformation "\242\227#\150\130\226\178\215>",PropSubscriptionIdentifier 8] TEST(Subscribe5QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0xc1, 0x1, 0x21, 0xbc, 0x51, 0x29, 0x3e, 0x23, 0x63, 0x8b, 0x24, 0xab, 0x8, 0x0, 0xa, 0x5d, - 0x51, 0x5b, 0x7d, 0xdb, 0x80, 0x86, 0xaa, 0xad, 0x22, 0x3, 0x0, 0x14, 0x58, 0x58, 0x6c, 0x66, 0x31, - 0x9a, 0x22, 0x82, 0x40, 0xcc, 0x4c, 0x44, 0x72, 0x19, 0x52, 0xe9, 0x8b, 0xb0, 0x7f, 0x3d, 0xb, 0xf, - 0x27, 0x0, 0x0, 0x55, 0x86, 0x18, 0x0, 0x0, 0x20, 0x57, 0x9, 0x0, 0x17, 0xc1, 0x4, 0x3b, 0xd2, - 0x5e, 0xdb, 0x79, 0x8, 0x6d, 0x20, 0xfa, 0xf9, 0xd6, 0x56, 0x5f, 0x2d, 0xf8, 0x20, 0x2, 0xf4, 0x2, - 0x3a, 0x29, 0x0, 0x18, 0x91, 0x75, 0x7a, 0x55, 0x24, 0x4, 0x76, 0x4c, 0x6b, 0x82, 0xd9, 0x85, 0x35, - 0x66, 0x3a, 0xb9, 0xb4, 0x71, 0x9, 0xe3, 0x42, 0xcc, 0xd1, 0x5e, 0x1, 0x0, 0x5, 0xb9, 0xd7, 0x33, - 0xba, 0x7a, 0x0, 0x0, 0x8, 0x35, 0xf0, 0xe4, 0x88, 0x91, 0x3c, 0xae, 0x70, 0x1, 0x0, 0x12, 0x22, - 0xfe, 0x67, 0xf8, 0x5a, 0x5, 0x96, 0xf8, 0x49, 0x2e, 0x88, 0x3a, 0x42, 0x8, 0xdd, 0x42, 0x6f, 0x41, - 0x2, 0x0, 0xa, 0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 0x2d}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x91, 0x75, 0x7a, 0x55, 0x24, 0x4, 0x76, 0x4c, 0x6b, 0x82, 0xd9, 0x85, - 0x35, 0x66, 0x3a, 0xb9, 0xb4, 0x71, 0x9, 0xe3, 0x42, 0xcc, 0xd1, 0x5e}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xc8, 0x50, 0xb1, 0xdd}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb9, 0xd7, 0x33, 0xba, 0x7a}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x41, 0xad, 0x3, 0xc, 0xe2, 0x6c, 0x7f, 0x4d, 0xe9, 0xc2, + 0x6e, 0x64, 0x4f, 0x34, 0xf8, 0xee, 0x82, 0xad, 0xe0, 0xd6}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x35, 0xf0, 0xe4, 0x88, 0x91, 0x3c, 0xae, 0x70}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf6, 0xde, 0x4e, 0xbd, 0x7a}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x22, 0xfe, 0x67, 0xf8, 0x5a, 0x5, 0x96, 0xf8, 0x49, - 0x2e, 0x88, 0x3a, 0x42, 0x8, 0xdd, 0x42, 0x6f, 0x41}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd8, 0x15, 0x51, 0xac, 0x6, 0x8a, 0xa7, 0xa8, 0x35, 0x26}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9b, 0x83, 0x67, 0x1, 0xc7, 0xd7, 0x5a, 0xa4, 0xf2, 0x9f}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x16, 0x82, 0xc5, 0xa9, 0xfe, 0x5c, 0xb4, 0x90, 0xa4, 0x67, 0x9e, 0x6b}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4d, 0xe1, 0x70, 0x57, 0x9, 0xb8, 0x44, 0xc, 0x56, 0xa7, 0xba, 0x82, 0xe7, - 0x6f, 0xbd, 0x74, 0xd9, 0xe9, 0x98, 0xd5, 0x49, 0x40, 0xd, 0x96, 0x8e, 0x63}; + uint8_t topic_filter_s5_bytes[] = {0x0, 0xd6, 0x61, 0xaa, 0x1, 0xc0, 0x3, 0x88, 0x4d, 0xfc, 0x1, 0xee, 0x71, + 0xb7, 0x3, 0xac, 0x8a, 0xd5, 0x24, 0x5d, 0x9a, 0x4a, 0xa6, 0x8e, 0xe8, 0x52}; lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2, LWMQTT_QOS2, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x5d, 0x51, 0x5b, 0x7d, 0xdb, 0x80, 0x86, 0xaa, 0xad, 0x22}; - uint8_t bytesprops1[] = {0x58, 0x58, 0x6c, 0x66, 0x31, 0x9a, 0x22, 0x82, 0x40, 0xcc, - 0x4c, 0x44, 0x72, 0x19, 0x52, 0xe9, 0x8b, 0xb0, 0x7f, 0x3d}; - uint8_t bytesprops2[] = {0xc1, 0x4, 0x3b, 0xd2, 0x5e, 0xdb, 0x79, 0x8, 0x6d, 0x20, 0xfa, 0xf9, - 0xd6, 0x56, 0x5f, 0x2d, 0xf8, 0x20, 0x2, 0xf4, 0x2, 0x3a, 0x29}; + uint8_t topic_filter_s6_bytes[] = {0x4d, 0x75, 0x2d, 0x7c, 0x84, 0xda, 0xd6, 0x6a, 0xfd}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf0, 0xa1, 0x83, 0x1f, 0xd5, 0x11, 0xef, 0xde, 0xa, 0x85, + 0xda, 0xb4, 0x6a, 0xb0, 0x70, 0xd7, 0xcc, 0x73, 0x8a, 0x74, + 0x9a, 0x4e, 0xa3, 0x21, 0xe3, 0x79, 0x28, 0xe9, 0x6c, 0xa6}; + lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xed, 0x88, 0x66, 0x83, 0x73, 0x70, 0x94, 0x69, + 0x9e, 0x2b, 0x63, 0x59, 0x74, 0x1b, 0x3b}; + lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + uint8_t bytesprops0[] = {0x30, 0x96, 0x99, 0x17, 0x75, 0xb8, 0xf4}; + uint8_t bytesprops1[] = {0xbb, 0x39, 0x63, 0x22, 0xb2, 0xdb, 0xff}; + uint8_t bytesprops2[] = {0x30, 0x9e, 0xb0, 0x8d, 0x4f, 0x74, 0xc5, 0x85, 0x81, 0x91, 0x29, + 0x7b, 0x74, 0x9e, 0xa4, 0x85, 0xc0, 0xe9, 0x87, 0xfb, 0x62, 0x43}; + uint8_t bytesprops4[] = {0x28, 0xa, 0x9, 0x91, 0xb3, 0x3c, 0xa2, 0x9d, 0x2d, + 0xa, 0xad, 0xfe, 0xe1, 0x6a, 0x94, 0x20, 0xb0, 0x9d}; + uint8_t bytesprops3[] = {0xe3, 0x19, 0xbd, 0xf4, 0x9d, 0xf, 0x75, 0x50, 0xce, 0x3f, 0x52, 0xcd, 0x62, 0xd0, + 0xbb, 0x90, 0x57, 0x39, 0xb3, 0xef, 0x53, 0xbe, 0xd6, 0x13, 0x1c, 0x3d, 0x33, 0xf9}; + uint8_t bytesprops5[] = {0x27, 0xff, 0xda, 0x4e, 0xa2}; + uint8_t bytesprops6[] = {0xbc, 0xdc, 0xe1, 0x9d, 0xc1}; + uint8_t bytesprops7[] = {0xec, 0xdf, 0x4b, 0x43, 0x11, 0x8e, 0x8c, 0xd9, + 0xb, 0xe5, 0x7b, 0xb6, 0x65, 0x59, 0xcc, 0x5d}; + uint8_t bytesprops8[] = {0xf2, 0xe3, 0x23, 0x96, 0x82, 0xe2, 0xb2, 0xd7, 0x3e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25483}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21894}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8279}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16637}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops3}, .v = {18, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11024}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11339}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12885}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8636, 6, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11607, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23343 [("\b\226\228",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),(",6p\US\ESC\233\166\168\SOb@\"\155\182\DEL\213\251\214/\233\209nSD\174Y\147\191",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("[1\251\168#\EOT\140\140\&0)\DC2\159\134\188aM\201\255y\207\149\DLE",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\189D\246\ETB\165\134\238\174\175E\220\240%\190\163\232>\190\rDH\156\&3\182\RS\240\&5w\200",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropRequestResponseInformation 165,PropResponseInformation "E\252\213\213",PropTopicAliasMaximum -// 24647,PropMaximumQoS 165,PropWildcardSubscriptionAvailable 139,PropSessionExpiryInterval -// 19464,PropAssignedClientIdentifier "\128QP\\`;\n8@NNs`\154\SUB\150\136t\231\250",PropRequestResponseInformation -// 67,PropRequestResponseInformation 96,PropResponseInformation "\191s\176\235\244\194",PropMaximumPacketSize -// 1055,PropWildcardSubscriptionAvailable 216,PropResponseTopic "\a)G\219\237j\200T",PropMaximumPacketSize -// 5417,PropRetainAvailable 166,PropMessageExpiryInterval 16062,PropSubscriptionIdentifier 1,PropServerKeepAlive -// 971,PropWildcardSubscriptionAvailable 107,PropMaximumQoS 46,PropSharedSubscriptionAvailable 72,PropReceiveMaximum -// 21423,PropAuthenticationMethod "Q\154V}\ACK@\152E\nK$\156}\188",PropMessageExpiryInterval 1756,PropReasonString -// "\187\DLE\SYN\a\175\159\199\&1_\190\172c\SI&\242\250H\167H\209\t",PropRequestResponseInformation -// 153,PropRetainAvailable 3,PropRequestProblemInformation 43,PropCorrelationData -// "\"T\133<\153\182\147\191\252:",PropUserProperty "!Fc" "\DC3W\163\165\224"] +// SubscribeRequest 22426 [("\FS\227\218",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [PropMaximumPacketSize 19858,PropAuthenticationMethod +// "\217<\SIme\220j\224Wj{\233\SIuW@&\133\254\155;\199\177\173",PropTopicAlias 574,PropSubscriptionIdentifierAvailable +// 218,PropReasonString "\253",PropReasonString "*\240\251\250S\202`\218",PropContentType +// "\SID`\\\150(\v\RSL\198\"r\141Do\247\CANP\193\230\189\ETX\161u",PropServerReference "\191",PropWillDelayInterval +// 12739,PropMaximumPacketSize 16985] TEST(Subscribe5QCTest,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x0, + 0x0, 0x31, 0xc3, 0x27, 0x0, 0x0, 0x42, 0x59, 0x0, 0x3, 0x1c, 0xe3, 0xda, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x8, 0xe2, 0xe4}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x1c, 0xe3, 0xda}; lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2c, 0x36, 0x70, 0x1f, 0x1b, 0xe9, 0xa6, 0xa8, 0xe, 0x62, - 0x40, 0x22, 0x9b, 0xb6, 0x7f, 0xd5, 0xfb, 0xd6, 0x2f, 0xe9, - 0xd1, 0x6e, 0x53, 0x44, 0xae, 0x59, 0x93, 0xbf}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5b, 0x31, 0xfb, 0xa8, 0x23, 0x4, 0x8c, 0x8c, 0x30, 0x29, 0x12, - 0x9f, 0x86, 0xbc, 0x61, 0x4d, 0xc9, 0xff, 0x79, 0xcf, 0x95, 0x10}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xbd, 0x44, 0xf6, 0x17, 0xa5, 0x86, 0xee, 0xae, 0xaf, 0x45, - 0xdc, 0xf0, 0x25, 0xbe, 0xa3, 0xe8, 0x3e, 0xbe, 0xd, 0x44, - 0x48, 0x9c, 0x33, 0xb6, 0x1e, 0xf0, 0x35, 0x77, 0xc8}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_qos_t qos_levels[] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS0, LWMQTT_QOS2}; - uint8_t bytesprops0[] = {0x45, 0xfc, 0xd5, 0xd5}; - uint8_t bytesprops1[] = {0x80, 0x51, 0x50, 0x5c, 0x60, 0x3b, 0xa, 0x38, 0x40, 0x4e, - 0x4e, 0x73, 0x60, 0x9a, 0x1a, 0x96, 0x88, 0x74, 0xe7, 0xfa}; - uint8_t bytesprops2[] = {0xbf, 0x73, 0xb0, 0xeb, 0xf4, 0xc2}; - uint8_t bytesprops3[] = {0x7, 0x29, 0x47, 0xdb, 0xed, 0x6a, 0xc8, 0x54}; - uint8_t bytesprops4[] = {0x51, 0x9a, 0x56, 0x7d, 0x6, 0x40, 0x98, 0x45, 0xa, 0x4b, 0x24, 0x9c, 0x7d, 0xbc}; - uint8_t bytesprops5[] = {0xbb, 0x10, 0x16, 0x7, 0xaf, 0x9f, 0xc7, 0x31, 0x5f, 0xbe, 0xac, - 0x63, 0xf, 0x26, 0xf2, 0xfa, 0x48, 0xa7, 0x48, 0xd1, 0x9}; - uint8_t bytesprops6[] = {0x22, 0x54, 0x85, 0x3c, 0x99, 0xb6, 0x93, 0xbf, 0xfc, 0x3a}; - uint8_t bytesprops8[] = {0x13, 0x57, 0xa3, 0xa5, 0xe0}; - uint8_t bytesprops7[] = {0x21, 0x46, 0x63}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0xd9, 0x3c, 0xf, 0x6d, 0x65, 0xdc, 0x6a, 0xe0, 0x57, 0x6a, 0x7b, 0xe9, + 0xf, 0x75, 0x57, 0x40, 0x26, 0x85, 0xfe, 0x9b, 0x3b, 0xc7, 0xb1, 0xad}; + uint8_t bytesprops1[] = {0xfd}; + uint8_t bytesprops2[] = {0x2a, 0xf0, 0xfb, 0xfa, 0x53, 0xca, 0x60, 0xda}; + uint8_t bytesprops3[] = {0xf, 0x44, 0x60, 0x5c, 0x96, 0x28, 0xb, 0x1e, 0x4c, 0xc6, 0x22, 0x72, + 0x8d, 0x44, 0x6f, 0xf7, 0x18, 0x50, 0xc1, 0xe6, 0xbd, 0x3, 0xa1, 0x75}; + uint8_t bytesprops4[] = {0xbf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24647}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19464}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1055}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5417}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16062}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 971}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21423}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1756}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops7}, .v = {5, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19858}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 574}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12739}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16985}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23343, 4, topic_filters, qos_levels, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22426, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); diff --git a/tests/packet.cpp b/tests/packet.cpp index 28c2628..7d849c4 100644 --- a/tests/packet.cpp +++ b/tests/packet.cpp @@ -631,6 +631,11 @@ TEST(SubackTest, DecodeError1) { EXPECT_EQ(err, LWMQTT_REMAINING_LENGTH_MISMATCH); } +TEST(SubscribeTest, OptionSize) { + lwmqtt_sub_options_t subopts = {LWMQTT_QOS0, LWMQTT_SUB_SEND_ON_SUB, 0, 0}; + EXPECT_EQ(sizeof(subopts), 1); +} + TEST(SubscribeTest, Encode1) { uint8_t pkt[38] = { LWMQTT_SUBSCRIBE_PACKET << 4u | 2, @@ -680,11 +685,13 @@ TEST(SubscribeTest, Encode1) { topic_filters[1] = lwmqtt_string("/a/b/#/c"); topic_filters[2] = lwmqtt_string("/a/b/#/cdd"); - lwmqtt_qos_t qos_levels[3] = {LWMQTT_QOS0, LWMQTT_QOS1, LWMQTT_QOS2}; + lwmqtt_sub_options_t sub_opts[3] = {lwmqtt_default_sub_options, lwmqtt_default_sub_options, + lwmqtt_default_sub_options}; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, 38, &len, LWMQTT_MQTT311, 7, 3, topic_filters, qos_levels, empty_props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, 38, &len, LWMQTT_MQTT311, 7, 3, topic_filters, sub_opts, empty_props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); @@ -696,11 +703,10 @@ TEST(SubscribeTest, EncodeError1) { lwmqtt_string_t topic_filters[1]; topic_filters[0] = lwmqtt_string("surgemq"); - lwmqtt_qos_t qos_levels[1] = {LWMQTT_QOS0}; + lwmqtt_sub_options_t sub_opts[1] = {lwmqtt_default_sub_options}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, 2, &len, LWMQTT_MQTT311, 7, 1, topic_filters, qos_levels, empty_props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, 2, &len, LWMQTT_MQTT311, 7, 1, topic_filters, sub_opts, empty_props); EXPECT_EQ(err, LWMQTT_BUFFER_TOO_SHORT); } From 96ce2f84acd6cdd1becee08d8f6d6652c4d1bef5 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Thu, 19 Sep 2019 23:24:34 -0700 Subject: [PATCH 17/26] Fix suback parsing for v5. --- gentests/app/Main.hs | 40 + src/packet.c | 13 +- tests/generated.cpp | 23802 ++++++++++++++++++++++------------------- 3 files changed, 12892 insertions(+), 10963 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index b876034..54e3ce2 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -43,6 +43,9 @@ v311PubReq p50 = let (PublishPkt p) = v311mask (PublishPkt p50) in p v311SubReq :: SubscribeRequest -> SubscribeRequest v311SubReq p50 = let (SubscribePkt p) = v311mask (SubscribePkt p50) in p +v311SubACKReq :: SubscribeResponse -> SubscribeResponse +v311SubACKReq p50 = let (SubACKPkt p) = v311mask (SubACKPkt p50) in p + v311ConnReq :: ConnectRequest -> ConnectRequest v311ConnReq p50 = let (ConnPkt p) = v311mask (ConnPkt p50) in p @@ -280,6 +283,38 @@ genConnectTest prot i p@ConnectRequest{..} = do "opts.", n, " = ", n, ";\n" ] +genSubACKTest :: ProtocolLevel -> Int -> SubscribeResponse -> String +genSubACKTest prot i p@(SubscribeResponse pid res _props) = do + let ll = show (length res) + genTestFunc "SubACK" "Decode" prot i p $ mconcat [ + "uint16_t packet_id;\n", + "int count;\n", + "lwmqtt_qos_t granted_qos_levels[", ll, "];\n", + "lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,", + protlvl prot, ", ", ll, ", &count, granted_qos_levels);\n", + "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + "EXPECT_EQ(packet_id, ", show pid, ");\n", + "EXPECT_EQ(count, ", ll, ");\n", + concatMap checkQos (zip [0..] res) + ] + + where + checkQos :: (Int,Either SubErr QoS) -> String + checkQos (qi,q) = "EXPECT_EQ(granted_qos_levels[" <> show qi <> "], " <> qq prot q <> ");\n" + qq Protocol311 (Left _) = "0x80" + qq Protocol50 (Left x) = q5 x + qq _ (Right q) = qos q + + q5 SubErrUnspecifiedError = "0x80" + q5 SubErrImplementationSpecificError = "0x83" + q5 SubErrNotAuthorized = "0x87" + q5 SubErrTopicFilterInvalid = "0x8F" + q5 SubErrPacketIdentifierInUse = "0x91" + q5 SubErrQuotaExceeded = "0x97" + q5 SubErrSharedSubscriptionsNotSupported = "0x9E" + q5 SubErrSubscriptionIdentifiersNotSupported = "0xA1" + q5 SubErrWildcardSubscriptionsNotSupported = "0xA2" + main :: IO () main = do putStrLn [r|#include @@ -319,6 +354,11 @@ extern "C" { f genSubTest Protocol311 (v311SubReq <$> subs) f genSubTest Protocol50 subs + subax <- replicateM numTests $ generate arbitrary + f genSubACKTest Protocol311 (v311SubACKReq <$> subax) + f genSubACKTest Protocol50 subax + + where f :: (ProtocolLevel -> Int -> a -> String) -> ProtocolLevel -> [a] -> IO () f g pl l = mapM_ putStrLn $ map (uncurry $ g pl) $ zip [1..] l diff --git a/src/packet.c b/src/packet.c index d5c743f..b89bb69 100644 --- a/src/packet.c +++ b/src/packet.c @@ -843,9 +843,10 @@ lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet if (err != LWMQTT_SUCCESS) { return err; } + uint8_t *end = buf_ptr + rem_len; // check remaining length (packet id + min. one suback code) - if (protocol == LWMQTT_MQTT311 && rem_len < 3) { + if (rem_len < 3) { return LWMQTT_REMAINING_LENGTH_MISMATCH; } @@ -855,8 +856,14 @@ lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet return err; } + lwmqtt_properties_t props; + err = decode_props(&buf_ptr, buf_end, protocol, &props); + if (err != LWMQTT_SUCCESS) { + return err; + } + // read all suback codes - for (*count = 0; *count < (int)rem_len - 2; (*count)++) { + for (*count = 0; buf_ptr < end; (*count)++) { // check max count if (*count > max_count) { return LWMQTT_SUBACK_ARRAY_OVERFLOW; @@ -881,7 +888,7 @@ lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet granted_qos_levels[*count] = LWMQTT_QOS2; break; default: - granted_qos_levels[*count] = LWMQTT_QOS_FAILURE; + granted_qos_levels[*count] = protocol == LWMQTT_MQTT311 ? 0x80 : (lwmqtt_qos_t)raw_qos_level; break; } } diff --git a/tests/generated.cpp b/tests/generated.cpp index f7c724e..2d618d9 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,43 +21,42 @@ extern "C" { } \ } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\DC1\"\211\207\n{Z%\217\200gfi\182\210US5", _pubPktID = 0, _pubBody = -// "\DEL\211\247\135\US>`\222\&5\231AJo1JP\244\231\252\&7\211\&32]", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\162[\135Y\179\166\248\129\206{\238\216oc:{M\ESC \SI\180[fv\192\SO", _pubPktID = 0, _pubBody = +// "\129\ETB\238\SYN)\SI\254", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x38, 0x2c, 0x0, 0x12, 0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, 0xc8, 0x67, 0x66, - 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35, 0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, - 0x41, 0x4a, 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; - uint8_t topic_bytes[] = {0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, - 0xc8, 0x67, 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x23, 0x0, 0x1a, 0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, + 0x7b, 0xee, 0xd8, 0x6f, 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, + 0x66, 0x76, 0xc0, 0xe, 0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; + uint8_t topic_bytes[] = {0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, 0xee, 0xd8, 0x6f, + 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, 0xc0, 0xe}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, 0x41, 0x4a, - 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; + msg.retained = true; + uint8_t msg_bytes[] = {0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 7; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\DC1\"\211\207\n{Z%\217\200gfi\182\210US5", _pubPktID = 0, _pubBody = -// "\DEL\211\247\135\US>`\222\&5\231AJo1JP\244\231\252\&7\211\&32]", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\162[\135Y\179\166\248\129\206{\238\216oc:{M\ESC \SI\180[fv\192\SO", _pubPktID = 0, _pubBody = +// "\129\ETB\238\SYN)\SI\254", _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x38, 0x2c, 0x0, 0x12, 0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, 0xc8, 0x67, 0x66, - 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35, 0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, - 0x41, 0x4a, 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; + uint8_t pkt[] = {0x31, 0x23, 0x0, 0x1a, 0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, + 0x7b, 0xee, 0xd8, 0x6f, 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, + 0x66, 0x76, 0xc0, 0xe, 0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -65,52 +64,53 @@ TEST(Publish311QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, - 0xc8, 0x67, 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, 0x41, 0x4a, - 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, 0xee, 0xd8, 0x6f, + 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, 0xc0, 0xe}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\212", _pubPktID = 10216, -// _pubBody = "\241", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\"\225\135\&6h>|U\199", _pubPktID = +// 10161, _pubBody = "\240\177C\238jP+", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x32, 0x7, 0x0, 0x2, 0xe9, 0xd4, 0x27, 0xe8, 0xf1}; - uint8_t topic_bytes[] = {0xe9, 0xd4}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x14, 0x0, 0x9, 0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, + 0x55, 0xc7, 0x27, 0xb1, 0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; + uint8_t topic_bytes[] = {0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, 0x55, 0xc7}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xf1}; + msg.retained = true; + uint8_t msg_bytes[] = {0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 7; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10216, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10161, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\212", _pubPktID = 10216, -// _pubBody = "\241", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\"\225\135\&6h>|U\199", _pubPktID = +// 10161, _pubBody = "\240\177C\238jP+", _pubProps = []} TEST(Publish311QCTest, Decode2) { - uint8_t pkt[] = {0x32, 0x7, 0x0, 0x2, 0xe9, 0xd4, 0x27, 0xe8, 0xf1}; + uint8_t pkt[] = {0x3b, 0x14, 0x0, 0x9, 0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, + 0x55, 0xc7, 0x27, 0xb1, 0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -118,58 +118,57 @@ TEST(Publish311QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe9, 0xd4}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf1}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, 0x55, 0xc7}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10216); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10161); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "}\162\DC3\157\161\140z\190\148\228\254\EOTk\211\&1\133\SI\188y\142\134e", _pubPktID = 11026, _pubBody = -// "\v/:\b\150\237Ih\224]\US\181R[r\179\234\185", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\\\247{A0\nX.\STX\243\151\STX\230}\221\144D<\209\NAKM\153\192\209=d\148\179\231", _pubPktID = 26319, _pubBody = +// "\166\229\136\206\180b\149", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x3a, 0x2c, 0x0, 0x16, 0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, 0x4, - 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65, 0x2b, 0x12, 0xb, 0x2f, 0x3a, 0x8, - 0x96, 0xed, 0x49, 0x68, 0xe0, 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; - uint8_t topic_bytes[] = {0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, - 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x28, 0x0, 0x1d, 0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, + 0x97, 0x2, 0xe6, 0x7d, 0xdd, 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, + 0x3d, 0x64, 0x94, 0xb3, 0xe7, 0x66, 0xcf, 0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; + uint8_t topic_bytes[] = {0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, 0x7d, 0xdd, + 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xb, 0x2f, 0x3a, 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, - 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; + uint8_t msg_bytes[] = {0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 7; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 11026, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 26319, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "}\162\DC3\157\161\140z\190\148\228\254\EOTk\211\&1\133\SI\188y\142\134e", _pubPktID = 11026, _pubBody = -// "\v/:\b\150\237Ih\224]\US\181R[r\179\234\185", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\\\247{A0\nX.\STX\243\151\STX\230}\221\144D<\209\NAKM\153\192\209=d\148\179\231", _pubPktID = 26319, _pubBody = +// "\166\229\136\206\180b\149", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x3a, 0x2c, 0x0, 0x16, 0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, 0x4, - 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65, 0x2b, 0x12, 0xb, 0x2f, 0x3a, 0x8, - 0x96, 0xed, 0x49, 0x68, 0xe0, 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; + uint8_t pkt[] = {0x3c, 0x28, 0x0, 0x1d, 0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, + 0x97, 0x2, 0xe6, 0x7d, 0xdd, 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, + 0x3d, 0x64, 0x94, 0xb3, 0xe7, 0x66, 0xcf, 0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -177,52 +176,51 @@ TEST(Publish311QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, - 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb, 0x2f, 0x3a, 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, - 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, 0x7d, 0xdd, + 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 11026); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + EXPECT_EQ(packet_id, 26319); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "'$k\221BT0a\ETB", _pubPktID = 21319, -// _pubBody = "\149", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ETXTx", _pubPktID = 0, _pubBody = +// "Ei\SI", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x3a, 0xe, 0x0, 0x9, 0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17, 0x53, 0x47, 0x95}; - uint8_t topic_bytes[] = {0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x8, 0x0, 0x3, 0x3, 0x54, 0x78, 0x45, 0x69, 0xf}; + uint8_t topic_bytes[] = {0x3, 0x54, 0x78}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x95}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x45, 0x69, 0xf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 3; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 21319, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "'$k\221BT0a\ETB", _pubPktID = 21319, -// _pubBody = "\149", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ETXTx", _pubPktID = 0, _pubBody = +// "Ei\SI", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x3a, 0xe, 0x0, 0x9, 0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17, 0x53, 0x47, 0x95}; + uint8_t pkt[] = {0x39, 0x8, 0x0, 0x3, 0x3, 0x54, 0x78, 0x45, 0x69, 0xf}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -230,55 +228,50 @@ TEST(Publish311QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x95}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3, 0x54, 0x78}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x45, 0x69, 0xf}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 21319); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\US\134\217^\225\USI\SOH%\234]\SUB\251\158\ENQ\188\140@\224\ETX\185}", _pubPktID = 0, _pubBody = "\222", _pubProps = -// []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 7815, _pubBody = +// "\168\142\FS", _pubProps = []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x30, 0x19, 0x0, 0x16, 0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, - 0x5d, 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d, 0xde}; - uint8_t topic_bytes[] = {0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, 0x5d, - 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x7, 0x0, 0x0, 0x1e, 0x87, 0xa8, 0x8e, 0x1c}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xde}; + uint8_t msg_bytes[] = {0xa8, 0x8e, 0x1c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 3; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7815, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\US\134\217^\225\USI\SOH%\234]\SUB\251\158\ENQ\188\140@\224\ETX\185}", _pubPktID = 0, _pubBody = "\222", _pubProps = -// []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 7815, _pubBody = +// "\168\142\FS", _pubProps = []} TEST(Publish311QCTest, Decode5) { - uint8_t pkt[] = {0x30, 0x19, 0x0, 0x16, 0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, - 0x5d, 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d, 0xde}; + uint8_t pkt[] = {0x34, 0x7, 0x0, 0x0, 0x1e, 0x87, 0xa8, 0x8e, 0x1c}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -286,53 +279,57 @@ TEST(Publish311QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, 0x5d, - 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xde}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa8, 0x8e, 0x1c}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(packet_id, 7815); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\152\168e\228f1ic\227\250", _pubPktID -// = 0, _pubBody = "\195\&1\199\231\246bO,\"\146\SOE`:", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\174\208\231e\229\225\201\ENQS\217\DEL\146\214\ENQ\145", _pubPktID = 25416, _pubBody = +// "\151\234\215\234\133\219\164\174\221\&1\EOTCs\212\"\141`\135\243\236q}6", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x39, 0x1a, 0x0, 0xa, 0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa, - 0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; - uint8_t topic_bytes[] = {0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x2a, 0x0, 0xf, 0xae, 0xd0, 0xe7, 0x65, 0xe5, 0xe1, 0xc9, 0x5, 0x53, 0xd9, 0x7f, + 0x92, 0xd6, 0x5, 0x91, 0x63, 0x48, 0x97, 0xea, 0xd7, 0xea, 0x85, 0xdb, 0xa4, 0xae, 0xdd, + 0x31, 0x4, 0x43, 0x73, 0xd4, 0x22, 0x8d, 0x60, 0x87, 0xf3, 0xec, 0x71, 0x7d, 0x36}; + uint8_t topic_bytes[] = {0xae, 0xd0, 0xe7, 0x65, 0xe5, 0xe1, 0xc9, 0x5, 0x53, 0xd9, 0x7f, 0x92, 0xd6, 0x5, 0x91}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; + uint8_t msg_bytes[] = {0x97, 0xea, 0xd7, 0xea, 0x85, 0xdb, 0xa4, 0xae, 0xdd, 0x31, 0x4, 0x43, + 0x73, 0xd4, 0x22, 0x8d, 0x60, 0x87, 0xf3, 0xec, 0x71, 0x7d, 0x36}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 23; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25416, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\152\168e\228f1ic\227\250", _pubPktID -// = 0, _pubBody = "\195\&1\199\231\246bO,\"\146\SOE`:", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\174\208\231e\229\225\201\ENQS\217\DEL\146\214\ENQ\145", _pubPktID = 25416, _pubBody = +// "\151\234\215\234\133\219\164\174\221\&1\EOTCs\212\"\141`\135\243\236q}6", _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x39, 0x1a, 0x0, 0xa, 0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa, - 0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; + uint8_t pkt[] = {0x33, 0x2a, 0x0, 0xf, 0xae, 0xd0, 0xe7, 0x65, 0xe5, 0xe1, 0xc9, 0x5, 0x53, 0xd9, 0x7f, + 0x92, 0xd6, 0x5, 0x91, 0x63, 0x48, 0x97, 0xea, 0xd7, 0xea, 0x85, 0xdb, 0xa4, 0xae, 0xdd, + 0x31, 0x4, 0x43, 0x73, 0xd4, 0x22, 0x8d, 0x60, 0x87, 0xf3, 0xec, 0x71, 0x7d, 0x36}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -340,52 +337,58 @@ TEST(Publish311QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x98, 0xa8, 0x65, 0xe4, 0x66, 0x31, 0x69, 0x63, 0xe3, 0xfa}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc3, 0x31, 0xc7, 0xe7, 0xf6, 0x62, 0x4f, 0x2c, 0x22, 0x92, 0xe, 0x45, 0x60, 0x3a}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + uint8_t exp_topic_bytes[] = {0xae, 0xd0, 0xe7, 0x65, 0xe5, 0xe1, 0xc9, 0x5, 0x53, 0xd9, 0x7f, 0x92, 0xd6, 0x5, 0x91}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x97, 0xea, 0xd7, 0xea, 0x85, 0xdb, 0xa4, 0xae, 0xdd, 0x31, 0x4, 0x43, + 0x73, 0xd4, 0x22, 0x8d, 0x60, 0x87, 0xf3, 0xec, 0x71, 0x7d, 0x36}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_EQ(packet_id, 25416); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\240\218\212Wy", _pubPktID = 11258, -// _pubBody = "\212F\158\240\144\160AN", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "=\178\242\158\145\238\151\166;*4)", +// _pubPktID = 0, _pubBody = "s\252\179R\CANz\233E\191\b\150\SYN\142G\217\188\190\148z\234#\250\177\240\254m\219\SOH", +// _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x33, 0x11, 0x0, 0x5, 0xf0, 0xda, 0xd4, 0x57, 0x79, 0x2b, - 0xfa, 0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; - uint8_t topic_bytes[] = {0xf0, 0xda, 0xd4, 0x57, 0x79}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x2a, 0x0, 0xc, 0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, + 0x29, 0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, + 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; + uint8_t topic_bytes[] = {0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, 0x29}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, + 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 8; + msg.payload_len = 28; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 11258, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\240\218\212Wy", _pubPktID = 11258, -// _pubBody = "\212F\158\240\144\160AN", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "=\178\242\158\145\238\151\166;*4)", +// _pubPktID = 0, _pubBody = "s\252\179R\CANz\233E\191\b\150\SYN\142G\217\188\190\148z\234#\250\177\240\254m\219\SOH", +// _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x33, 0x11, 0x0, 0x5, 0xf0, 0xda, 0xd4, 0x57, 0x79, 0x2b, - 0xfa, 0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; + uint8_t pkt[] = {0x30, 0x2a, 0x0, 0xc, 0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, + 0x29, 0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, + 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -393,39 +396,38 @@ TEST(Publish311QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf0, 0xda, 0xd4, 0x57, 0x79}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; - lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, 0x29}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, + 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 11258); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 8); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\204s\226@u&7F!\EM\194o\133\175\187\203<\DC1;\239Q\RS\251\236J\167a\247\220", _pubPktID = 0, _pubBody = -// "\159(\138\244\237\128L\179\197a", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\148\\\SUBg||N\DC41_\225\t\200Db_\163g\147\140\150]\254\216", _pubPktID = 0, _pubBody = "\130", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x31, 0x29, 0x0, 0x1d, 0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, - 0x6f, 0x85, 0xaf, 0xbb, 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, - 0x61, 0xf7, 0xdc, 0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; - uint8_t topic_bytes[] = {0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, 0x6f, 0x85, 0xaf, 0xbb, - 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, 0x61, 0xf7, 0xdc}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x1b, 0x0, 0x18, 0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, + 0x9, 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8, 0x82}; + uint8_t topic_bytes[] = {0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, + 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; + msg.retained = false; + uint8_t msg_bytes[] = {0x82}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + msg.payload_len = 1; lwmqtt_property_t propslist[] = {}; @@ -437,13 +439,11 @@ TEST(Publish311QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\204s\226@u&7F!\EM\194o\133\175\187\203<\DC1;\239Q\RS\251\236J\167a\247\220", _pubPktID = 0, _pubBody = -// "\159(\138\244\237\128L\179\197a", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\148\\\SUBg||N\DC41_\225\t\200Db_\163g\147\140\150]\254\216", _pubPktID = 0, _pubBody = "\130", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x31, 0x29, 0x0, 0x1d, 0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, - 0x6f, 0x85, 0xaf, 0xbb, 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, - 0x61, 0xf7, 0xdc, 0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; + uint8_t pkt[] = {0x30, 0x1b, 0x0, 0x18, 0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, + 0x9, 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8, 0x82}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -451,58 +451,58 @@ TEST(Publish311QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, 0x6f, 0x85, 0xaf, 0xbb, - 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, 0x61, 0xf7, 0xdc}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; - lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, + 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x82}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "~\237S\145l\t\ACK0\CAN\236\137G!\FS~l\156\DC3\n>\135", _pubPktID = 0, _pubBody = -// "\NAK\255WE\SIQC\246\161\173\128\&6", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\167a*\t\248\248\176\&7", _pubPktID +// = 3229, _pubBody = "q\NUL\185\ACK\181\209\244d\DC1\207\251\203\230\128\DC1A(\215\169\248\224\136EM\156.\EOT\f", +// _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x31, 0x23, 0x0, 0x15, 0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, - 0xec, 0x89, 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87, 0x15, - 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; - uint8_t topic_bytes[] = {0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, - 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x28, 0x0, 0x8, 0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37, 0xc, 0x9d, + 0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, + 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; + uint8_t topic_bytes[] = {0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, + 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 28; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 3229, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "~\237S\145l\t\ACK0\CAN\236\137G!\FS~l\156\DC3\n>\135", _pubPktID = 0, _pubBody = -// "\NAK\255WE\SIQC\246\161\173\128\&6", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\167a*\t\248\248\176\&7", _pubPktID +// = 3229, _pubBody = "q\NUL\185\ACK\181\209\244d\DC1\207\251\203\230\128\DC1A(\215\169\248\224\136EM\156.\EOT\f", +// _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x31, 0x23, 0x0, 0x15, 0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, - 0xec, 0x89, 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87, 0x15, - 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; + uint8_t pkt[] = {0x3c, 0x28, 0x0, 0x8, 0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37, 0xc, 0x9d, + 0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, + 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -510,61 +510,51 @@ TEST(Publish311QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, - 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + uint8_t exp_topic_bytes[] = {0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, + 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 3229); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\168q\180\235Y\176\233\DC2z6\175%\SOH\200c&\131\DC2\134#\151\139\&2\ETX\130\DC4", _pubPktID = 2807, _pubBody = -// "`\EOT\158\236\t\225\128\235\197\172aw\173\147\&8\DC3\EOT\244+\249C)zO\156\191\199", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[Q\172\216\185:|\162\194", _pubPktID +// = 10305, _pubBody = "\238\134", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x3a, 0x39, 0x0, 0x1a, 0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, - 0x25, 0x1, 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14, - 0xa, 0xf7, 0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, - 0x93, 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; - uint8_t topic_bytes[] = {0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1, - 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0xf, 0x0, 0x9, 0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2, 0x28, 0x41, 0xee, 0x86}; + uint8_t topic_bytes[] = {0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, - 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; + msg.retained = true; + uint8_t msg_bytes[] = {0xee, 0x86}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 2; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2807, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10305, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\168q\180\235Y\176\233\DC2z6\175%\SOH\200c&\131\DC2\134#\151\139\&2\ETX\130\DC4", _pubPktID = 2807, _pubBody = -// "`\EOT\158\236\t\225\128\235\197\172aw\173\147\&8\DC3\EOT\244+\249C)zO\156\191\199", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[Q\172\216\185:|\162\194", _pubPktID +// = 10305, _pubBody = "\238\134", _pubProps = []} TEST(Publish311QCTest, Decode10) { - uint8_t pkt[] = {0x3a, 0x39, 0x0, 0x1a, 0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, - 0x25, 0x1, 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14, - 0xa, 0xf7, 0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, - 0x93, 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; + uint8_t pkt[] = {0x3b, 0xf, 0x0, 0x9, 0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2, 0x28, 0x41, 0xee, 0x86}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -572,59 +562,53 @@ TEST(Publish311QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1, - 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, - 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xee, 0x86}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2807); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 27); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10305); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\207\198\194\214\STX\139\&4_\212\172\NAKu:\233\181_\247\164\SUB", _pubPktID = 13284, _pubBody = -// "\154\166c\188;\235r\148\223\SYN\DEL", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ESC\169\150\136?o\142\230\b", +// _pubPktID = 0, _pubBody = "\203\ENQ\254)\215\158R\255\SOH\SOHM8\245\234\222t\225\187\175", _pubProps = []} TEST(Publish311QCTest, Encode11) { - uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x13, 0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, - 0xd4, 0xac, 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a, 0x33, - 0xe4, 0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; - uint8_t topic_bytes[] = {0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, - 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x9, 0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8, 0xcb, 0x5, 0xfe, + 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; + uint8_t topic_bytes[] = {0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xcb, 0x5, 0xfe, 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, + 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13284, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\207\198\194\214\STX\139\&4_\212\172\NAKu:\233\181_\247\164\SUB", _pubPktID = 13284, _pubBody = -// "\154\166c\188;\235r\148\223\SYN\DEL", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ESC\169\150\136?o\142\230\b", +// _pubPktID = 0, _pubBody = "\203\ENQ\254)\215\158R\255\SOH\SOHM8\245\234\222t\225\187\175", _pubProps = []} TEST(Publish311QCTest, Decode11) { - uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x13, 0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, - 0xd4, 0xac, 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a, 0x33, - 0xe4, 0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; + uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x9, 0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8, 0xcb, 0x5, 0xfe, + 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -632,58 +616,56 @@ TEST(Publish311QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, - 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a}; - lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 13284); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + uint8_t exp_topic_bytes[] = {0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcb, 0x5, 0xfe, 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, + 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\159\US\147\DC3i\FS\CAN@\178\DC2\202\145>\185\195\148\f3@ \SOH\202\166\182\STX\v\130\SYN", _pubPktID = 25675, -// _pubBody = "\138\158G\154\229\140)?>\221\211<\190", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\186\b\221\f\178D\188&~\248P\ENQ\134\167\n\241\196v\203\245_\206\177\208\SI\FS", _pubPktID = 16783, _pubBody = "", +// _pubProps = []} TEST(Publish311QCTest, Encode12) { - uint8_t pkt[] = {0x3d, 0x2d, 0x0, 0x1c, 0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, - 0x3e, 0xb9, 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16, - 0x64, 0x4b, 0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; - uint8_t topic_bytes[] = {0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, 0x3e, 0xb9, - 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x1e, 0x0, 0x1a, 0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, + 0x86, 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c, 0x41, 0x8f}; + uint8_t topic_bytes[] = {0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, 0x86, + 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 0; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25675, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16783, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\159\US\147\DC3i\FS\CAN@\178\DC2\202\145>\185\195\148\f3@ \SOH\202\166\182\STX\v\130\SYN", _pubPktID = 25675, -// _pubBody = "\138\158G\154\229\140)?>\221\211<\190", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\186\b\221\f\178D\188&~\248P\ENQ\134\167\n\241\196v\203\245_\206\177\208\SI\FS", _pubPktID = 16783, _pubBody = "", +// _pubProps = []} TEST(Publish311QCTest, Decode12) { - uint8_t pkt[] = {0x3d, 0x2d, 0x0, 0x1c, 0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, - 0x3e, 0xb9, 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16, - 0x64, 0x4b, 0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; + uint8_t pkt[] = {0x3a, 0x1e, 0x0, 0x1a, 0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, + 0x86, 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c, 0x41, 0x8f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -691,56 +673,59 @@ TEST(Publish311QCTest, Decode12) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, 0x3e, 0xb9, - 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, 0x86, + 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 25675); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 13); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 16783); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\185\246\SOH*\248(\178k\\\215\174", -// _pubPktID = 11115, _pubBody = ".\DC1\fEQhj\183\224@\215\"\231B\243L\206 \210\231\178", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// ";V\193\141}\175x\217i^\231g\247\v\203\183_\151\EM\\", _pubPktID = 0, _pubBody = +// "\162\166\173\187\NAK){\138\210Q^p+\SI\145Q\165\GS\166\249CG", _pubProps = []} TEST(Publish311QCTest, Encode13) { - uint8_t pkt[] = {0x32, 0x24, 0x0, 0xb, 0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, - 0xd7, 0xae, 0x2b, 0x6b, 0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, - 0x40, 0xd7, 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; - uint8_t topic_bytes[] = {0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, 0xd7, 0xae}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x2c, 0x0, 0x14, 0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, 0xe7, 0x67, + 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c, 0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, + 0xd2, 0x51, 0x5e, 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; + uint8_t topic_bytes[] = {0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, + 0xe7, 0x67, 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, 0x40, 0xd7, - 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, 0xd2, 0x51, 0x5e, + 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 11115, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\185\246\SOH*\248(\178k\\\215\174", -// _pubPktID = 11115, _pubBody = ".\DC1\fEQhj\183\224@\215\"\231B\243L\206 \210\231\178", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// ";V\193\141}\175x\217i^\231g\247\v\203\183_\151\EM\\", _pubPktID = 0, _pubBody = +// "\162\166\173\187\NAK){\138\210Q^p+\SI\145Q\165\GS\166\249CG", _pubProps = []} TEST(Publish311QCTest, Decode13) { - uint8_t pkt[] = {0x32, 0x24, 0x0, 0xb, 0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, - 0xd7, 0xae, 0x2b, 0x6b, 0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, - 0x40, 0xd7, 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; + uint8_t pkt[] = {0x31, 0x2c, 0x0, 0x14, 0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, 0xe7, 0x67, + 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c, 0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, + 0xd2, 0x51, 0x5e, 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -748,53 +733,54 @@ TEST(Publish311QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, 0xd7, 0xae}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, 0x40, 0xd7, - 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 11115); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + uint8_t exp_topic_bytes[] = {0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, + 0xe7, 0x67, 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, 0xd2, 0x51, 0x5e, + 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\186\171$\215\213", _pubPktID = -// 24590, _pubBody = "En.&\166\184\215\153", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\141\253\251\DC4\210]", _pubPktID = +// 0, _pubBody = "a#\200\US\234\221\168\235\213|\205w", _pubProps = []} TEST(Publish311QCTest, Encode14) { - uint8_t pkt[] = {0x34, 0x11, 0x0, 0x5, 0xba, 0xab, 0x24, 0xd7, 0xd5, 0x60, - 0xe, 0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; - uint8_t topic_bytes[] = {0xba, 0xab, 0x24, 0xd7, 0xd5}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x14, 0x0, 0x6, 0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d, 0x61, + 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; + uint8_t topic_bytes[] = {0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x61, 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 8; + msg.payload_len = 12; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24590, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\186\171$\215\213", _pubPktID = -// 24590, _pubBody = "En.&\166\184\215\153", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\141\253\251\DC4\210]", _pubPktID = +// 0, _pubBody = "a#\200\US\234\221\168\235\213|\205w", _pubProps = []} TEST(Publish311QCTest, Decode14) { - uint8_t pkt[] = {0x34, 0x11, 0x0, 0x5, 0xba, 0xab, 0x24, 0xd7, 0xd5, 0x60, - 0xe, 0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; + uint8_t pkt[] = {0x31, 0x14, 0x0, 0x6, 0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d, 0x61, + 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -802,55 +788,53 @@ TEST(Publish311QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xba, 0xab, 0x24, 0xd7, 0xd5}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; - lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x61, 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 24590); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 8); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\197R\255Y+\ACK", _pubPktID = 17354, -// _pubBody = "_\191\168\153\207\229\204<\169\234j\153A\153/^I\217,\159/\161\222\252?6", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\n", _pubPktID = 15576, _pubBody = +// "\SYN\168.K\212\233\154\159\233j\172\130\DC2\187\203\187\155\ETX", _pubProps = []} TEST(Publish311QCTest, Encode15) { - uint8_t pkt[] = {0x3b, 0x24, 0x0, 0x6, 0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6, 0x43, 0xca, 0x5f, - 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, 0x99, - 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; - uint8_t topic_bytes[] = {0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x17, 0x0, 0x1, 0xa, 0x3c, 0xd8, 0x16, 0xa8, 0x2e, 0x4b, 0xd4, 0xe9, + 0x9a, 0x9f, 0xe9, 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; + uint8_t topic_bytes[] = {0xa}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, - 0x99, 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x16, 0xa8, 0x2e, 0x4b, 0xd4, 0xe9, 0x9a, 0x9f, 0xe9, + 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 18; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 17354, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 15576, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\197R\255Y+\ACK", _pubPktID = 17354, -// _pubBody = "_\191\168\153\207\229\204<\169\234j\153A\153/^I\217,\159/\161\222\252?6", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\n", _pubPktID = 15576, _pubBody = +// "\SYN\168.K\212\233\154\159\233j\172\130\DC2\187\203\187\155\ETX", _pubProps = []} TEST(Publish311QCTest, Decode15) { - uint8_t pkt[] = {0x3b, 0x24, 0x0, 0x6, 0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6, 0x43, 0xca, 0x5f, - 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, 0x99, - 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; + uint8_t pkt[] = {0x3c, 0x17, 0x0, 0x1, 0xa, 0x3c, 0xd8, 0x16, 0xa8, 0x2e, 0x4b, 0xd4, 0xe9, + 0x9a, 0x9f, 0xe9, 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -858,58 +842,56 @@ TEST(Publish311QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, - 0x99, 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x16, 0xa8, 0x2e, 0x4b, 0xd4, 0xe9, 0x9a, 0x9f, 0xe9, + 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 17354); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 15576); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\181h\206\206#\148<\227\196\202?\ENQ\255\RSp\196\162\184\171\224", _pubPktID = 9053, _pubBody = -// "W\232(5\208_\210\199B\249E\178\157\128", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\195\214\220\150\206L\a\225", +// _pubPktID = 0, _pubBody = "\203\137\DC3y\ETBf\GS\255}~\231\217kJ\ESCI\193\148\254p\247\ACKB\245", _pubProps = []} TEST(Publish311QCTest, Encode16) { - uint8_t pkt[] = {0x3c, 0x26, 0x0, 0x14, 0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, - 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0, 0x23, 0x5d, 0x57, 0xe8, - 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; - uint8_t topic_bytes[] = {0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, - 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x22, 0x0, 0x8, 0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1, + 0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, + 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; + uint8_t topic_bytes[] = {0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; + uint8_t msg_bytes[] = {0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, + 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 24; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 9053, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\181h\206\206#\148<\227\196\202?\ENQ\255\RSp\196\162\184\171\224", _pubPktID = 9053, _pubBody = -// "W\232(5\208_\210\199B\249E\178\157\128", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\195\214\220\150\206L\a\225", +// _pubPktID = 0, _pubBody = "\203\137\DC3y\ETBf\GS\255}~\231\217kJ\ESCI\193\148\254p\247\ACKB\245", _pubProps = []} TEST(Publish311QCTest, Decode16) { - uint8_t pkt[] = {0x3c, 0x26, 0x0, 0x14, 0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, - 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0, 0x23, 0x5d, 0x57, 0xe8, - 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; + uint8_t pkt[] = {0x30, 0x22, 0x0, 0x8, 0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1, + 0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, + 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -917,38 +899,38 @@ TEST(Publish311QCTest, Decode16) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, - 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, + 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 9053); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\147\174\SYN ", _pubPktID = 0, -// _pubBody = "\155\DC3A*\157dh!\177=7\233\225\DLE|\EM\145", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\NUL=U\137\224\247\192", _pubPktID = +// 0, _pubBody = "\142\160\202\237f\186\202Fc1p\\\ACK\231J\193%\250kl", _pubProps = []} TEST(Publish311QCTest, Encode17) { - uint8_t pkt[] = {0x39, 0x17, 0x0, 0x4, 0x93, 0xae, 0x16, 0x20, 0x9b, 0x13, 0x41, 0x2a, 0x9d, - 0x64, 0x68, 0x21, 0xb1, 0x3d, 0x37, 0xe9, 0xe1, 0x10, 0x7c, 0x19, 0x91}; - uint8_t topic_bytes[] = {0x93, 0xae, 0x16, 0x20}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x1d, 0x0, 0x7, 0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0, 0x8e, 0xa0, 0xca, 0xed, 0x66, + 0xba, 0xca, 0x46, 0x63, 0x31, 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, 0x25, 0xfa, 0x6b, 0x6c}; + uint8_t topic_bytes[] = {0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x9b, 0x13, 0x41, 0x2a, 0x9d, 0x64, 0x68, 0x21, 0xb1, - 0x3d, 0x37, 0xe9, 0xe1, 0x10, 0x7c, 0x19, 0x91}; + uint8_t msg_bytes[] = {0x8e, 0xa0, 0xca, 0xed, 0x66, 0xba, 0xca, 0x46, 0x63, 0x31, + 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, 0x25, 0xfa, 0x6b, 0x6c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 20; lwmqtt_property_t propslist[] = {}; @@ -960,11 +942,11 @@ TEST(Publish311QCTest, Encode17) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\147\174\SYN ", _pubPktID = 0, -// _pubBody = "\155\DC3A*\157dh!\177=7\233\225\DLE|\EM\145", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\NUL=U\137\224\247\192", _pubPktID = +// 0, _pubBody = "\142\160\202\237f\186\202Fc1p\\\ACK\231J\193%\250kl", _pubProps = []} TEST(Publish311QCTest, Decode17) { - uint8_t pkt[] = {0x39, 0x17, 0x0, 0x4, 0x93, 0xae, 0x16, 0x20, 0x9b, 0x13, 0x41, 0x2a, 0x9d, - 0x64, 0x68, 0x21, 0xb1, 0x3d, 0x37, 0xe9, 0xe1, 0x10, 0x7c, 0x19, 0x91}; + uint8_t pkt[] = {0x39, 0x1d, 0x0, 0x7, 0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0, 0x8e, 0xa0, 0xca, 0xed, 0x66, + 0xba, 0xca, 0x46, 0x63, 0x31, 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, 0x25, 0xfa, 0x6b, 0x6c}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -972,41 +954,40 @@ TEST(Publish311QCTest, Decode17) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x93, 0xae, 0x16, 0x20}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9b, 0x13, 0x41, 0x2a, 0x9d, 0x64, 0x68, 0x21, 0xb1, - 0x3d, 0x37, 0xe9, 0xe1, 0x10, 0x7c, 0x19, 0x91}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8e, 0xa0, 0xca, 0xed, 0x66, 0xba, 0xca, 0x46, 0x63, 0x31, + 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, 0x25, 0xfa, 0x6b, 0x6c}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "t\183\232G\148\143\148J\151\141\197\&0\196\244?(x\225\237\EM", _pubPktID = 0, _pubBody = -// "\ESC\231\EM\255\149&\\p\RS\173+\194\173\204\183u\131G\218", _pubProps = []} +// "\192\226\177\DC3\178\200n\184h\162\210\RS\153\149\253\&1\132\250\156\\\190\ETB\149 \192\247C\203", _pubPktID = 0, +// _pubBody = "\243(topic.data), 20); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\245l-\185\147\\\ai\199\183\216s\232\\\248\DC4\199\231[\DC4\139", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "Q\144\172\176:\255\255\236\209\134\204", _pubPktID = 29463, _pubBody = +// "\135s\STX\155A\v\217\&8\EOT^,\220\194\183\195\251\223H9g\164", _pubProps = []} TEST(Publish311QCTest, Encode19) { - uint8_t pkt[] = {0x30, 0x17, 0x0, 0x0, 0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, - 0xb7, 0xd8, 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x24, 0x0, 0xb, 0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, + 0x86, 0xcc, 0x73, 0x17, 0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, + 0x5e, 0x2c, 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; + uint8_t topic_bytes[] = {0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, 0xd8, - 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, 0x5e, 0x2c, + 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 21; @@ -1070,17 +1052,19 @@ TEST(Publish311QCTest, Encode19) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29463, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\245l-\185\147\\\ai\199\183\216s\232\\\248\DC4\199\231[\DC4\139", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "Q\144\172\176:\255\255\236\209\134\204", _pubPktID = 29463, _pubBody = +// "\135s\STX\155A\v\217\&8\EOT^,\220\194\183\195\251\223H9g\164", _pubProps = []} TEST(Publish311QCTest, Decode19) { - uint8_t pkt[] = {0x30, 0x17, 0x0, 0x0, 0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, - 0xb7, 0xd8, 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; + uint8_t pkt[] = {0x3b, 0x24, 0x0, 0xb, 0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, + 0x86, 0xcc, 0x73, 0x17, 0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, + 0x5e, 0x2c, 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1088,59 +1072,56 @@ TEST(Publish311QCTest, Decode19) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, 0xd8, - 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; + uint8_t exp_topic_bytes[] = {0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, 0x5e, 0x2c, + 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 29463); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); EXPECT_EQ(msg.payload_len, 21); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "B&&P~\USwi\200\237U\SI0[8\205\ETX\US\171\236", _pubPktID = 20579, _pubBody = -// "\160|,\236\153`\132S\ETBj\210-v\ETB\US\246\DC4>iK\158\SOH\141\250", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\220\&2\138\ETX\145\167\209n\146\EOT\ACK\187\213\216b\156\231@\149\194\129", _pubPktID = 25900, _pubBody = "+;\SYN", +// _pubProps = []} TEST(Publish311QCTest, Encode20) { - uint8_t pkt[] = {0x3d, 0x30, 0x0, 0x14, 0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, 0x55, 0xf, 0x30, - 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec, 0x50, 0x63, 0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, - 0x17, 0x6a, 0xd2, 0x2d, 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; - uint8_t topic_bytes[] = {0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, - 0x55, 0xf, 0x30, 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x1c, 0x0, 0x15, 0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, + 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81, 0x65, 0x2c, 0x2b, 0x3b, 0x16}; + uint8_t topic_bytes[] = {0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, + 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, 0x2d, - 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; + msg.retained = false; + uint8_t msg_bytes[] = {0x2b, 0x3b, 0x16}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 3; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 20579, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25900, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "B&&P~\USwi\200\237U\SI0[8\205\ETX\US\171\236", _pubPktID = 20579, _pubBody = -// "\160|,\236\153`\132S\ETBj\210-v\ETB\US\246\DC4>iK\158\SOH\141\250", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\220\&2\138\ETX\145\167\209n\146\EOT\ACK\187\213\216b\156\231@\149\194\129", _pubPktID = 25900, _pubBody = "+;\SYN", +// _pubProps = []} TEST(Publish311QCTest, Decode20) { - uint8_t pkt[] = {0x3d, 0x30, 0x0, 0x14, 0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, 0x55, 0xf, 0x30, - 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec, 0x50, 0x63, 0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, - 0x17, 0x6a, 0xd2, 0x2d, 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; + uint8_t pkt[] = {0x34, 0x1c, 0x0, 0x15, 0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, + 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81, 0x65, 0x2c, 0x2b, 0x3b, 0x16}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1148,59 +1129,51 @@ TEST(Publish311QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, - 0x55, 0xf, 0x30, 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, 0x2d, - 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, + 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2b, 0x3b, 0x16}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 20579); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 25900); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "Wo\249\180\STXZ\FS\218Co_\137a\140\&9^\232\186\143\230", _pubPktID = 10935, _pubBody = -// "\US\177vw\219K\147TS\150\&9", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\224", _pubPktID = 936, _pubBody = +// "6\245", _pubProps = []} TEST(Publish311QCTest, Encode21) { - uint8_t pkt[] = {0x3d, 0x23, 0x0, 0x14, 0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, - 0x6f, 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6, 0x2a, 0xb7, - 0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; - uint8_t topic_bytes[] = {0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, - 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x7, 0x0, 0x1, 0xe0, 0x3, 0xa8, 0x36, 0xf5}; + uint8_t topic_bytes[] = {0xe0}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x36, 0xf5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 2; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10935, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 936, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "Wo\249\180\STXZ\FS\218Co_\137a\140\&9^\232\186\143\230", _pubPktID = 10935, _pubBody = -// "\US\177vw\219K\147TS\150\&9", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\224", _pubPktID = 936, _pubBody = +// "6\245", _pubProps = []} TEST(Publish311QCTest, Decode21) { - uint8_t pkt[] = {0x3d, 0x23, 0x0, 0x14, 0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, - 0x6f, 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6, 0x2a, 0xb7, - 0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; + uint8_t pkt[] = {0x3a, 0x7, 0x0, 0x1, 0xe0, 0x3, 0xa8, 0x36, 0xf5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1208,54 +1181,60 @@ TEST(Publish311QCTest, Decode21) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, - 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xe0}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x36, 0xf5}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 10935); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 936); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "z\187}l", _pubPktID = 11378, -// _pubBody = "\186\&7\190\f\178\235\212\242\166(\ENQ\181\SUB\234\&4\149H\SYN6\197\247\207", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "E\177\160\226\133O\252!\"\251\129\164{\STX\178\165g\229E\168\162\209>N\STXWn\191\235", _pubPktID = 0, _pubBody = +// "t\139\164\144a\157:\239\157\145M\SI\t\162\DC1\194D\143\134", _pubProps = []} TEST(Publish311QCTest, Encode22) { - uint8_t pkt[] = {0x34, 0x1e, 0x0, 0x4, 0x7a, 0xbb, 0x7d, 0x6c, 0x2c, 0x72, 0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, - 0xd4, 0xf2, 0xa6, 0x28, 0x5, 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; - uint8_t topic_bytes[] = {0x7a, 0xbb, 0x7d, 0x6c}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x32, 0x0, 0x1d, 0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, + 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, + 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb, 0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, + 0x3a, 0xef, 0x9d, 0x91, 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; + uint8_t topic_bytes[] = {0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, + 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, 0xf2, 0xa6, 0x28, 0x5, - 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; + uint8_t msg_bytes[] = {0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, 0x3a, 0xef, 0x9d, 0x91, + 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 11378, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "z\187}l", _pubPktID = 11378, -// _pubBody = "\186\&7\190\f\178\235\212\242\166(\ENQ\181\SUB\234\&4\149H\SYN6\197\247\207", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "E\177\160\226\133O\252!\"\251\129\164{\STX\178\165g\229E\168\162\209>N\STXWn\191\235", _pubPktID = 0, _pubBody = +// "t\139\164\144a\157:\239\157\145M\SI\t\162\DC1\194D\143\134", _pubProps = []} TEST(Publish311QCTest, Decode22) { - uint8_t pkt[] = {0x34, 0x1e, 0x0, 0x4, 0x7a, 0xbb, 0x7d, 0x6c, 0x2c, 0x72, 0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, - 0xd4, 0xf2, 0xa6, 0x28, 0x5, 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; + uint8_t pkt[] = {0x30, 0x32, 0x0, 0x1d, 0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, + 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, + 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb, 0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, + 0x3a, 0xef, 0x9d, 0x91, 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1263,61 +1242,59 @@ TEST(Publish311QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7a, 0xbb, 0x7d, 0x6c}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, 0xf2, 0xa6, 0x28, 0x5, - 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, + 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, 0x3a, 0xef, 0x9d, 0x91, + 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 11378); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\252\190\&8\149\&2\128\192{C\128\194\197\170g\a_\DC4\DELI(\151\218\172\vBJ\234\221", _pubPktID = 0, _pubBody = -// "q\145\203\144\245\153\&3\220g\186\&9YVh\DEL\232\&2V\212\201\&4\172?\189S\159<\187W", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\208\167\232\STX\DLE\GSQr\146|", +// _pubPktID = 8189, _pubBody = "c`\ESC\156x\229(\255\178\168\214\240a\217\197\224\170\174\&48pk\NAK\200\ETX\130\235", +// _pubProps = []} TEST(Publish311QCTest, Encode23) { - uint8_t pkt[] = {0x39, 0x3b, 0x0, 0x1c, 0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, - 0xaa, 0x67, 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd, - 0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, 0xe8, - 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; - uint8_t topic_bytes[] = {0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, 0xaa, 0x67, - 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x29, 0x0, 0xa, 0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c, 0x1f, + 0xfd, 0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, + 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; + uint8_t topic_bytes[] = {0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, - 0xe8, 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, + 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 27; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 8189, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\252\190\&8\149\&2\128\192{C\128\194\197\170g\a_\DC4\DELI(\151\218\172\vBJ\234\221", _pubPktID = 0, _pubBody = -// "q\145\203\144\245\153\&3\220g\186\&9YVh\DEL\232\&2V\212\201\&4\172?\189S\159<\187W", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\208\167\232\STX\DLE\GSQr\146|", +// _pubPktID = 8189, _pubBody = "c`\ESC\156x\229(\255\178\168\214\240a\217\197\224\170\174\&48pk\NAK\200\ETX\130\235", +// _pubProps = []} TEST(Publish311QCTest, Decode23) { - uint8_t pkt[] = {0x39, 0x3b, 0x0, 0x1c, 0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, - 0xaa, 0x67, 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd, - 0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, 0xe8, - 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; + uint8_t pkt[] = {0x3a, 0x29, 0x0, 0xa, 0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c, 0x1f, + 0xfd, 0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, + 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1325,62 +1302,51 @@ TEST(Publish311QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, 0xaa, 0x67, - 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, - 0xe8, 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, + 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 8189); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\a\159\222j\236\175\242\&158\148@P\139o\150c\EOT\191\131\204\SUB\205\201\135W\193a", _pubPktID = 24983, _pubBody = -// "\214M\130;K\239#\136V\STX\242C\n\153\208l\129s\196\171\DC1P\193\218\128", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "b\245\197\244\&04\214\&6*\178", +// _pubPktID = 0, _pubBody = "\184", _pubProps = []} TEST(Publish311QCTest, Encode24) { - uint8_t pkt[] = {0x35, 0x39, 0x0, 0x1c, 0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, - 0x40, 0x50, 0x8b, 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, - 0xc1, 0x61, 0x61, 0x97, 0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, - 0x43, 0xa, 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; - uint8_t topic_bytes[] = {0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, 0x50, 0x8b, - 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0xd, 0x0, 0xa, 0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2, 0xb8}; + uint8_t topic_bytes[] = {0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, 0xa, - 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xb8}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 1; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24983, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\a\159\222j\236\175\242\&158\148@P\139o\150c\EOT\191\131\204\SUB\205\201\135W\193a", _pubPktID = 24983, _pubBody = -// "\214M\130;K\239#\136V\STX\242C\n\153\208l\129s\196\171\DC1P\193\218\128", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "b\245\197\244\&04\214\&6*\178", +// _pubPktID = 0, _pubBody = "\184", _pubProps = []} TEST(Publish311QCTest, Decode24) { - uint8_t pkt[] = {0x35, 0x39, 0x0, 0x1c, 0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, - 0x40, 0x50, 0x8b, 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, - 0xc1, 0x61, 0x61, 0x97, 0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, - 0x43, 0xa, 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; + uint8_t pkt[] = {0x38, 0xd, 0x0, 0xa, 0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2, 0xb8}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1388,59 +1354,55 @@ TEST(Publish311QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, 0x50, 0x8b, - 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, 0xa, - 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 24983); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + uint8_t exp_topic_bytes[] = {0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb8}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "[5,\230\144\137\236\202\179\STX\t\201\234\136\166", _pubPktID = 10487, _pubBody = -// "\DLE\ACK\165~\155\217?\249\195\GS\145\179=i'\223Wd\159\248<\223$", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\200\170v\196", _pubPktID = 30063, +// _pubBody = "\RS(g\190(g%\FS\249\135\DC1S\250\ACK(N\CANHC\157\RSK\175\DEL\225\159", _pubProps = []} TEST(Publish311QCTest, Encode25) { - uint8_t pkt[] = {0x34, 0x2a, 0x0, 0xf, 0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, - 0xc9, 0xea, 0x88, 0xa6, 0x28, 0xf7, 0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, - 0x1d, 0x91, 0xb3, 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; - uint8_t topic_bytes[] = {0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, 0xc9, 0xea, 0x88, 0xa6}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x4, 0xc8, 0xaa, 0x76, 0xc4, 0x75, 0x6f, 0x1e, 0x28, + 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, 0x6, + 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; + uint8_t topic_bytes[] = {0xc8, 0xaa, 0x76, 0xc4}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, 0x1d, 0x91, 0xb3, - 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; + uint8_t msg_bytes[] = {0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, + 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 26; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10487, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30063, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "[5,\230\144\137\236\202\179\STX\t\201\234\136\166", _pubPktID = 10487, _pubBody = -// "\DLE\ACK\165~\155\217?\249\195\GS\145\179=i'\223Wd\159\248<\223$", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\200\170v\196", _pubPktID = 30063, +// _pubBody = "\RS(g\190(g%\FS\249\135\DC1S\250\ACK(N\CANHC\157\RSK\175\DEL\225\159", _pubProps = []} TEST(Publish311QCTest, Decode25) { - uint8_t pkt[] = {0x34, 0x2a, 0x0, 0xf, 0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, - 0xc9, 0xea, 0x88, 0xa6, 0x28, 0xf7, 0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, - 0x1d, 0x91, 0xb3, 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; + uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x4, 0xc8, 0xaa, 0x76, 0xc4, 0x75, 0x6f, 0x1e, 0x28, + 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, 0x6, + 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1448,56 +1410,54 @@ TEST(Publish311QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, 0xc9, 0xea, 0x88, 0xa6}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, 0x1d, 0x91, 0xb3, - 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xc8, 0xaa, 0x76, 0xc4}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, + 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10487); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 23); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); + EXPECT_EQ(packet_id, 30063); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "n\145", _pubPktID = 14089, _pubBody -// = "\210\210>L\150\rD\161j\204SG\219\226\165\205k\208\&4\ENQ\154t\DC1\148D:\US<\141\149", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\229<<\234;", _pubPktID = 0, +// _pubBody = "+ eK\208\CAN\232\179\167\129\227'Hqi\SO\163\r\168\188\157\247", _pubProps = []} TEST(Publish311QCTest, Encode26) { - uint8_t pkt[] = {0x35, 0x24, 0x0, 0x2, 0x6e, 0x91, 0x37, 0x9, 0xd2, 0xd2, 0x3e, 0x4c, 0x96, - 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, 0xcd, 0x6b, 0xd0, - 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; - uint8_t topic_bytes[] = {0x6e, 0x91}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x1d, 0x0, 0x5, 0xe5, 0x3c, 0x3c, 0xea, 0x3b, 0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, + 0xb3, 0xa7, 0x81, 0xe3, 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; + uint8_t topic_bytes[] = {0xe5, 0x3c, 0x3c, 0xea, 0x3b}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, - 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; + uint8_t msg_bytes[] = {0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, + 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 14089, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "n\145", _pubPktID = 14089, _pubBody -// = "\210\210>L\150\rD\161j\204SG\219\226\165\205k\208\&4\ENQ\154t\DC1\148D:\US<\141\149", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\229<<\234;", _pubPktID = 0, +// _pubBody = "+ eK\208\CAN\232\179\167\129\227'Hqi\SO\163\r\168\188\157\247", _pubProps = []} TEST(Publish311QCTest, Decode26) { - uint8_t pkt[] = {0x35, 0x24, 0x0, 0x2, 0x6e, 0x91, 0x37, 0x9, 0xd2, 0xd2, 0x3e, 0x4c, 0x96, - 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, 0xcd, 0x6b, 0xd0, - 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; + uint8_t pkt[] = {0x31, 0x1d, 0x0, 0x5, 0xe5, 0x3c, 0x3c, 0xea, 0x3b, 0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, + 0xb3, 0xa7, 0x81, 0xe3, 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1505,56 +1465,58 @@ TEST(Publish311QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x6e, 0x91}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, - 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xe5, 0x3c, 0x3c, 0xea, 0x3b}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, + 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 14089); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\199d\158\162p\SYNZ2{\228j\t\233'\211K\254\FSK\133%\252", _pubPktID = 0, _pubBody = "\SYN\ESC\r\233\&1\216\237", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\ETX[\136\204X%(topic.data), 22); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\DELB\171!\189\RS\129\132", _pubPktID -// = 1997, _pubBody = "P\169", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201eh\234\223\242\222", _pubPktID = +// 0, _pubBody = " .@o\137\224\135\201\224\168\\&%,\220\&6\DC2\SI\209\132J\DC2]\FS\210\132\134\189\b~", _pubProps = []} TEST(Publish311QCTest, Encode28) { - uint8_t pkt[] = {0x3d, 0xe, 0x0, 0x8, 0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84, 0x7, 0xcd, 0x50, 0xa9}; - uint8_t topic_bytes[] = {0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x27, 0x0, 0x7, 0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde, 0x20, 0x2e, 0x40, + 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, 0x36, 0x12, + 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; + uint8_t topic_bytes[] = {0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x50, 0xa9}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, + 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 30; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 1997, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\DELB\171!\189\RS\129\132", _pubPktID -// = 1997, _pubBody = "P\169", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201eh\234\223\242\222", _pubPktID = +// 0, _pubBody = " .@o\137\224\135\201\224\168\\&%,\220\&6\DC2\SI\209\132J\DC2]\FS\210\132\134\189\b~", _pubProps = []} TEST(Publish311QCTest, Decode28) { - uint8_t pkt[] = {0x3d, 0xe, 0x0, 0x8, 0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84, 0x7, 0xcd, 0x50, 0xa9}; + uint8_t pkt[] = {0x38, 0x27, 0x0, 0x7, 0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde, 0x20, 0x2e, 0x40, + 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, 0x36, 0x12, + 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1614,52 +1581,61 @@ TEST(Publish311QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x50, 0xa9}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, + 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 1997); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\138.\149\DC3{U\CANP\144", -// _pubPktID = 16970, _pubBody = "4\163\252\250\166\SUB\245\158", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "{\200\227JE\EM6\185bARg\185\190\226e\205R\n\v\167\CAN\DC3~\152nd8\155'", _pubPktID = 24808, _pubBody = +// "\FS\196\NUL\238\180K\252nl\r\235$v\169K\163\182\254\134\186", _pubProps = []} TEST(Publish311QCTest, Encode29) { - uint8_t pkt[] = {0x32, 0x15, 0x0, 0x9, 0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, - 0x90, 0x42, 0x4a, 0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; - uint8_t topic_bytes[] = {0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, 0x90}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x36, 0x0, 0x1e, 0x7b, 0xc8, 0xe3, 0x4a, 0x45, 0x19, 0x36, 0xb9, 0x62, 0x41, + 0x52, 0x67, 0xb9, 0xbe, 0xe2, 0x65, 0xcd, 0x52, 0xa, 0xb, 0xa7, 0x18, 0x13, 0x7e, + 0x98, 0x6e, 0x64, 0x38, 0x9b, 0x27, 0x60, 0xe8, 0x1c, 0xc4, 0x0, 0xee, 0xb4, 0x4b, + 0xfc, 0x6e, 0x6c, 0xd, 0xeb, 0x24, 0x76, 0xa9, 0x4b, 0xa3, 0xb6, 0xfe, 0x86, 0xba}; + uint8_t topic_bytes[] = {0x7b, 0xc8, 0xe3, 0x4a, 0x45, 0x19, 0x36, 0xb9, 0x62, 0x41, 0x52, 0x67, 0xb9, 0xbe, 0xe2, + 0x65, 0xcd, 0x52, 0xa, 0xb, 0xa7, 0x18, 0x13, 0x7e, 0x98, 0x6e, 0x64, 0x38, 0x9b, 0x27}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; + uint8_t msg_bytes[] = {0x1c, 0xc4, 0x0, 0xee, 0xb4, 0x4b, 0xfc, 0x6e, 0x6c, 0xd, + 0xeb, 0x24, 0x76, 0xa9, 0x4b, 0xa3, 0xb6, 0xfe, 0x86, 0xba}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 8; + msg.payload_len = 20; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16970, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24808, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\138.\149\DC3{U\CANP\144", -// _pubPktID = 16970, _pubBody = "4\163\252\250\166\SUB\245\158", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "{\200\227JE\EM6\185bARg\185\190\226e\205R\n\v\167\CAN\DC3~\152nd8\155'", _pubPktID = 24808, _pubBody = +// "\FS\196\NUL\238\180K\252nl\r\235$v\169K\163\182\254\134\186", _pubProps = []} TEST(Publish311QCTest, Decode29) { - uint8_t pkt[] = {0x32, 0x15, 0x0, 0x9, 0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, - 0x90, 0x42, 0x4a, 0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; + uint8_t pkt[] = {0x34, 0x36, 0x0, 0x1e, 0x7b, 0xc8, 0xe3, 0x4a, 0x45, 0x19, 0x36, 0xb9, 0x62, 0x41, + 0x52, 0x67, 0xb9, 0xbe, 0xe2, 0x65, 0xcd, 0x52, 0xa, 0xb, 0xa7, 0x18, 0x13, 0x7e, + 0x98, 0x6e, 0x64, 0x38, 0x9b, 0x27, 0x60, 0xe8, 0x1c, 0xc4, 0x0, 0xee, 0xb4, 0x4b, + 0xfc, 0x6e, 0x6c, 0xd, 0xeb, 0x24, 0x76, 0xa9, 0x4b, 0xa3, 0xb6, 0xfe, 0x86, 0xba}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1667,55 +1643,60 @@ TEST(Publish311QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8a, 0x2e, 0x95, 0x13, 0x7b, 0x55, 0x18, 0x50, 0x90}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x34, 0xa3, 0xfc, 0xfa, 0xa6, 0x1a, 0xf5, 0x9e}; - lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7b, 0xc8, 0xe3, 0x4a, 0x45, 0x19, 0x36, 0xb9, 0x62, 0x41, + 0x52, 0x67, 0xb9, 0xbe, 0xe2, 0x65, 0xcd, 0x52, 0xa, 0xb, + 0xa7, 0x18, 0x13, 0x7e, 0x98, 0x6e, 0x64, 0x38, 0x9b, 0x27}; + lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1c, 0xc4, 0x0, 0xee, 0xb4, 0x4b, 0xfc, 0x6e, 0x6c, 0xd, + 0xeb, 0x24, 0x76, 0xa9, 0x4b, 0xa3, 0xb6, 0xfe, 0x86, 0xba}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 16970); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 8); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); + EXPECT_EQ(packet_id, 24808); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3r\ETX\ETXZ\SOH", _pubPktID = 0, -// _pubBody = "\129\209\171[\DC4B\234\ETX\ACK\177\133\&9\ENQf\128\DC1A\185\236M\134qT}\\g\159&;g", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\218\139Q\DC1\195\175\199\249J\b\183\226\228\185\ESC\245\128\130\166\n]\133:\228\231$K*v", _pubPktID = 0, _pubBody = +// "\SOH\135h\234D\134\149\210zy\n\143\141\&7Q", _pubProps = []} TEST(Publish311QCTest, Encode30) { - uint8_t pkt[] = {0x31, 0x26, 0x0, 0x6, 0x13, 0x72, 0x3, 0x3, 0x5a, 0x1, 0x81, 0xd1, 0xab, 0x5b, - 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, 0x11, 0x41, 0xb9, - 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; - uint8_t topic_bytes[] = {0x13, 0x72, 0x3, 0x3, 0x5a, 0x1}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x2e, 0x0, 0x1d, 0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, + 0xe4, 0xb9, 0x1b, 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, + 0x76, 0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; + uint8_t topic_bytes[] = {0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, 0xe4, 0xb9, 0x1b, + 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, 0x76}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, - 0x11, 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; + uint8_t msg_bytes[] = {0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3r\ETX\ETXZ\SOH", _pubPktID = 0, -// _pubBody = "\129\209\171[\DC4B\234\ETX\ACK\177\133\&9\ENQf\128\DC1A\185\236M\134qT}\\g\159&;g", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\218\139Q\DC1\195\175\199\249J\b\183\226\228\185\ESC\245\128\130\166\n]\133:\228\231$K*v", _pubPktID = 0, _pubBody = +// "\SOH\135h\234D\134\149\210zy\n\143\141\&7Q", _pubProps = []} TEST(Publish311QCTest, Decode30) { - uint8_t pkt[] = {0x31, 0x26, 0x0, 0x6, 0x13, 0x72, 0x3, 0x3, 0x5a, 0x1, 0x81, 0xd1, 0xab, 0x5b, - 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, 0x11, 0x41, 0xb9, - 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; + uint8_t pkt[] = {0x39, 0x2e, 0x0, 0x1d, 0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, + 0xe4, 0xb9, 0x1b, 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, + 0x76, 0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1723,95 +1704,71 @@ TEST(Publish311QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x13, 0x72, 0x3, 0x3, 0x5a, 0x1}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, - 0x11, 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, 0xe4, 0xb9, 0x1b, + 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, 0x76}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\DC1\"\211\207\n{Z%\217\200gfi\182\210US5", _pubPktID = 0, _pubBody = -// "\DEL\211\247\135\US>`\222\&5\231AJo1JP\244\231\252\&7\211\&32]", _pubProps = [PropReasonString -// "\167\252e\ESC7\188\&2\r\174\255\205\221",PropWillDelayInterval 4231,PropTopicAlias 29603,PropSubscriptionIdentifier -// 14,PropReasonString "\"\168\DC1x;\218\STX\SUBa\230\159\222\187",PropTopicAlias 3637,PropResponseTopic -// "{\166\r\223\SYN\221",PropTopicAliasMaximum 29040,PropTopicAlias 10048,PropAssignedClientIdentifier -// "\198&\152",PropTopicAliasMaximum 2366,PropMessageExpiryInterval 5348]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\162[\135Y\179\166\248\129\206{\238\216oc:{M\ESC \SI\180[fv\192\SO", _pubPktID = 0, _pubBody = +// "\129\ETB\238\SYN)\SI\254", _pubProps = [PropAuthenticationData +// "\187\151\183'\US\238\213\205\t8u\181\SYNw",PropReasonString "\216\248-8Y\248\175",PropMessageExpiryInterval 8175]} TEST(Publish5QCTest, Encode1) { - uint8_t pkt[] = {0x38, 0x76, 0x0, 0x12, 0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, 0xc8, 0x67, - 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35, 0x49, 0x1f, 0x0, 0xc, 0xa7, 0xfc, 0x65, 0x1b, - 0x37, 0xbc, 0x32, 0xd, 0xae, 0xff, 0xcd, 0xdd, 0x18, 0x0, 0x0, 0x10, 0x87, 0x23, 0x73, - 0xa3, 0xb, 0xe, 0x1f, 0x0, 0xd, 0x22, 0xa8, 0x11, 0x78, 0x3b, 0xda, 0x2, 0x1a, 0x61, - 0xe6, 0x9f, 0xde, 0xbb, 0x23, 0xe, 0x35, 0x8, 0x0, 0x6, 0x7b, 0xa6, 0xd, 0xdf, 0x16, - 0xdd, 0x22, 0x71, 0x70, 0x23, 0x27, 0x40, 0x12, 0x0, 0x3, 0xc6, 0x26, 0x98, 0x22, 0x9, - 0x3e, 0x2, 0x0, 0x0, 0x14, 0xe4, 0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, - 0xe7, 0x41, 0x4a, 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; - uint8_t topic_bytes[] = {0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, - 0xc8, 0x67, 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x44, 0x0, 0x1a, 0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, + 0xee, 0xd8, 0x6f, 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, + 0xc0, 0xe, 0x20, 0x16, 0x0, 0xe, 0xbb, 0x97, 0xb7, 0x27, 0x1f, 0xee, 0xd5, 0xcd, + 0x9, 0x38, 0x75, 0xb5, 0x16, 0x77, 0x1f, 0x0, 0x7, 0xd8, 0xf8, 0x2d, 0x38, 0x59, + 0xf8, 0xaf, 0x2, 0x0, 0x0, 0x1f, 0xef, 0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; + uint8_t topic_bytes[] = {0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, 0xee, 0xd8, 0x6f, + 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, 0xc0, 0xe}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, 0x41, 0x4a, - 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; + msg.retained = true; + uint8_t msg_bytes[] = {0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 7; - uint8_t bytesprops0[] = {0xa7, 0xfc, 0x65, 0x1b, 0x37, 0xbc, 0x32, 0xd, 0xae, 0xff, 0xcd, 0xdd}; - uint8_t bytesprops1[] = {0x22, 0xa8, 0x11, 0x78, 0x3b, 0xda, 0x2, 0x1a, 0x61, 0xe6, 0x9f, 0xde, 0xbb}; - uint8_t bytesprops2[] = {0x7b, 0xa6, 0xd, 0xdf, 0x16, 0xdd}; - uint8_t bytesprops3[] = {0xc6, 0x26, 0x98}; + uint8_t bytesprops0[] = {0xbb, 0x97, 0xb7, 0x27, 0x1f, 0xee, 0xd5, 0xcd, 0x9, 0x38, 0x75, 0xb5, 0x16, 0x77}; + uint8_t bytesprops1[] = {0xd8, 0xf8, 0x2d, 0x38, 0x59, 0xf8, 0xaf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4231}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29603}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3637}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29040}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10048}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2366}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5348}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8175}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\DC1\"\211\207\n{Z%\217\200gfi\182\210US5", _pubPktID = 0, _pubBody = -// "\DEL\211\247\135\US>`\222\&5\231AJo1JP\244\231\252\&7\211\&32]", _pubProps = [PropReasonString -// "\167\252e\ESC7\188\&2\r\174\255\205\221",PropWillDelayInterval 4231,PropTopicAlias 29603,PropSubscriptionIdentifier -// 14,PropReasonString "\"\168\DC1x;\218\STX\SUBa\230\159\222\187",PropTopicAlias 3637,PropResponseTopic -// "{\166\r\223\SYN\221",PropTopicAliasMaximum 29040,PropTopicAlias 10048,PropAssignedClientIdentifier -// "\198&\152",PropTopicAliasMaximum 2366,PropMessageExpiryInterval 5348]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\162[\135Y\179\166\248\129\206{\238\216oc:{M\ESC \SI\180[fv\192\SO", _pubPktID = 0, _pubBody = +// "\129\ETB\238\SYN)\SI\254", _pubProps = [PropAuthenticationData +// "\187\151\183'\US\238\213\205\t8u\181\SYNw",PropReasonString "\216\248-8Y\248\175",PropMessageExpiryInterval 8175]} TEST(Publish5QCTest, Decode1) { - uint8_t pkt[] = {0x38, 0x76, 0x0, 0x12, 0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, 0xc8, 0x67, - 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35, 0x49, 0x1f, 0x0, 0xc, 0xa7, 0xfc, 0x65, 0x1b, - 0x37, 0xbc, 0x32, 0xd, 0xae, 0xff, 0xcd, 0xdd, 0x18, 0x0, 0x0, 0x10, 0x87, 0x23, 0x73, - 0xa3, 0xb, 0xe, 0x1f, 0x0, 0xd, 0x22, 0xa8, 0x11, 0x78, 0x3b, 0xda, 0x2, 0x1a, 0x61, - 0xe6, 0x9f, 0xde, 0xbb, 0x23, 0xe, 0x35, 0x8, 0x0, 0x6, 0x7b, 0xa6, 0xd, 0xdf, 0x16, - 0xdd, 0x22, 0x71, 0x70, 0x23, 0x27, 0x40, 0x12, 0x0, 0x3, 0xc6, 0x26, 0x98, 0x22, 0x9, - 0x3e, 0x2, 0x0, 0x0, 0x14, 0xe4, 0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, - 0xe7, 0x41, 0x4a, 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; + uint8_t pkt[] = {0x31, 0x44, 0x0, 0x1a, 0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, + 0xee, 0xd8, 0x6f, 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, + 0xc0, 0xe, 0x20, 0x16, 0x0, 0xe, 0xbb, 0x97, 0xb7, 0x27, 0x1f, 0xee, 0xd5, 0xcd, + 0x9, 0x38, 0x75, 0xb5, 0x16, 0x77, 0x1f, 0x0, 0x7, 0xd8, 0xf8, 0x2d, 0x38, 0x59, + 0xf8, 0xaf, 0x2, 0x0, 0x0, 0x1f, 0xef, 0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1819,187 +1776,144 @@ TEST(Publish5QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x11, 0x22, 0xd3, 0xcf, 0xa, 0x7b, 0x5a, 0x25, 0xd9, - 0xc8, 0x67, 0x66, 0x69, 0xb6, 0xd2, 0x55, 0x53, 0x35}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7f, 0xd3, 0xf7, 0x87, 0x1f, 0x3e, 0x60, 0xde, 0x35, 0xe7, 0x41, 0x4a, - 0x6f, 0x31, 0x4a, 0x50, 0xf4, 0xe7, 0xfc, 0x37, 0xd3, 0x33, 0x32, 0x5d}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, 0xee, 0xd8, 0x6f, + 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, 0xc0, 0xe}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\212", _pubPktID = 10216, -// _pubBody = "\241", _pubProps = [PropWillDelayInterval 6725,PropServerReference -// "\253w#\215\181Z\189\135\196H",PropAuthenticationMethod -// "\ESC\160\"S\250R\161\NAK\131\"\214\v\134Nd\199\219\230\139",PropAssignedClientIdentifier -// "e\233/\167Z\187uF\NUL\241\128q+YFH\146\241\224\147\245\223",PropReasonString -// "JJ{'\161\&7\EOTV\160\165xP\DLE-h\193[\129\198\168\180U\152\ETX\171\236G\199",PropMessageExpiryInterval -// 26844,PropResponseInformation -// "\201\213\DC3\149s\201\&0m\159\210A$\212L\DC1\145B\ESC\250\205'm\US\149\144\\\147ZH",PropContentType -// "\235\134\253Y\255\148#F\192\SUB\152<\174na\254\ETB\251\EOT",PropAssignedClientIdentifier -// "\200\147_\194\170\201n`",PropServerKeepAlive 31945,PropPayloadFormatIndicator 36,PropSubscriptionIdentifierAvailable -// 90,PropAuthenticationMethod "t\218\147\160\172\128mZ\DC33R<`\165u\GSrdF\128",PropReasonString -// "\227\144#\DC2\203\195\162\194#X\"c_]}\201\216\181\&4\187\146rO\187,\244+\213%\163",PropWillDelayInterval -// 31366,PropAuthenticationMethod "\144\FS\227\199J\218\161\154_\130J\195Yt\187\197\170tV",PropRetainAvailable -// 210,PropResponseTopic "\148\ESCo\217\v",PropUserProperty -// "\"W\172\182\156\221\151\EOTC\165\207\&6\231\193\222S\ETB\ESCu" -// "\253\128\231=\172\CANT\f\139\202\236iE\157\177'b|U\199", _pubPktID = +// 10161, _pubBody = "\240\177C\238jP+", _pubProps = [PropResponseInformation +// "\164L\197\211\149]\171\198\206\DEL\197",PropMaximumQoS 193,PropSubscriptionIdentifier 3,PropTopicAliasMaximum +// 19390,PropWillDelayInterval 23674,PropUserProperty "\168\245W" +// "\233\191\155/\NAK\138,\217\ETXK\203\f",PropAuthenticationMethod +// "\253\176O^\233P\174\DEL\205\160\STX\"N\228X9\141\&9\158\169]5\SYN",PropRequestResponseInformation +// 94,PropAssignedClientIdentifier "\233\243\203\207,",PropSubscriptionIdentifierAvailable 130,PropAuthenticationData +// "\161\213\202\DLE\202]\US\212-\166\238\145",PropPayloadFormatIndicator 9,PropRequestProblemInformation +// 208,PropTopicAlias 6428,PropServerReference "\173L\148\243dc\RS\141fFs\180%U3\135\250",PropReceiveMaximum +// 986,PropTopicAliasMaximum 26453,PropWillDelayInterval 7668,PropMaximumQoS 42,PropMessageExpiryInterval +// 18158,PropRetainAvailable 76,PropMessageExpiryInterval 5254,PropReceiveMaximum 28353,PropResponseInformation +// "\175dT\170H\161\242c\203\213\133\153\144\188\171~N\198+\252\156\171\NUL\227\224\135\221\180",PropCorrelationData +// "\DC3\227\186%;_\238\160",PropAuthenticationMethod "\247?\214",PropRequestProblemInformation +// 76,PropSubscriptionIdentifier 20]} TEST(Publish5QCTest, Encode2) { - uint8_t pkt[] = { - 0x32, 0x82, 0x3, 0x0, 0x2, 0xe9, 0xd4, 0x27, 0xe8, 0xf9, 0x2, 0x18, 0x0, 0x0, 0x1a, 0x45, 0x1c, 0x0, 0xa, - 0xfd, 0x77, 0x23, 0xd7, 0xb5, 0x5a, 0xbd, 0x87, 0xc4, 0x48, 0x15, 0x0, 0x13, 0x1b, 0xa0, 0x22, 0x53, 0xfa, 0x52, - 0xa1, 0x15, 0x83, 0x22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5, - 0x34, 0xbb, 0x92, 0x72, 0x4f, 0xbb, 0x2c, 0xf4, 0x2b, 0xd5, 0x25, 0xa3, 0x18, 0x0, 0x0, 0x7a, 0x86, 0x15, 0x0, - 0x13, 0x90, 0x1c, 0xe3, 0xc7, 0x4a, 0xda, 0xa1, 0x9a, 0x5f, 0x82, 0x4a, 0xc3, 0x59, 0x74, 0xbb, 0xc5, 0xaa, 0x74, - 0x56, 0x25, 0xd2, 0x8, 0x0, 0x5, 0x94, 0x1b, 0x6f, 0xd9, 0xb, 0x26, 0x0, 0x13, 0x22, 0x57, 0xac, 0xb6, 0x9c, - 0xdd, 0x97, 0x4, 0x43, 0xa5, 0xcf, 0x36, 0xe7, 0xc1, 0xde, 0x53, 0x17, 0x1b, 0x75, 0x0, 0x15, 0xfd, 0x80, 0xe7, - 0x3d, 0xac, 0x18, 0x54, 0xc, 0x8b, 0xca, 0xec, 0x69, 0x45, 0x9d, 0xb1, 0x27, 0x62, 0x3c, 0x78, 0xf7, 0x77, 0x12, - 0x0, 0x8, 0x7e, 0xaa, 0xf7, 0xde, 0x84, 0x4a, 0xd, 0x9f, 0x26, 0x0, 0xa, 0x6e, 0xf3, 0x26, 0x0, 0x78, 0xdd, - 0x9b, 0xb9, 0xae, 0xf8, 0x0, 0x15, 0xf8, 0xb1, 0xdb, 0xcd, 0x7f, 0xb5, 0xf0, 0x7e, 0x81, 0x42, 0xf0, 0x11, 0x47, - 0x88, 0x3c, 0x41, 0xe6, 0x51, 0xb0, 0x71, 0xa3, 0x22, 0xd, 0x87, 0x2a, 0xf0, 0x15, 0x0, 0x8, 0x7e, 0xe1, 0xf8, - 0xdd, 0x12, 0xa6, 0x39, 0x31, 0x13, 0x5b, 0xb2, 0xf1}; - uint8_t topic_bytes[] = {0xe9, 0xd4}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0xe4, 0x1, 0x0, 0x9, 0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x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0x0, 0xe3, 0xe0, 0x87, 0xdd, 0xb4, 0x9, + 0x0, 0x8, 0x13, 0xe3, 0xba, 0x25, 0x3b, 0x5f, 0xee, 0xa0, 0x15, 0x0, 0x3, 0xf7, 0x3f, 0xd6, 0x17, + 0x4c, 0xb, 0x14, 0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; + uint8_t topic_bytes[] = {0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, 0x55, 0xc7}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xf1}; + msg.retained = true; + uint8_t msg_bytes[] = {0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 7; - uint8_t bytesprops0[] = {0xfd, 0x77, 0x23, 0xd7, 0xb5, 0x5a, 0xbd, 0x87, 0xc4, 0x48}; - uint8_t bytesprops1[] = {0x1b, 0xa0, 0x22, 0x53, 0xfa, 0x52, 0xa1, 0x15, 0x83, 0x22, - 0xd6, 0xb, 0x86, 0x4e, 0x64, 0xc7, 0xdb, 0xe6, 0x8b}; - uint8_t bytesprops2[] = {0x65, 0xe9, 0x2f, 0xa7, 0x5a, 0xbb, 0x75, 0x46, 0x0, 0xf1, 0x80, - 0x71, 0x2b, 0x59, 0x46, 0x48, 0x92, 0xf1, 0xe0, 0x93, 0xf5, 0xdf}; - uint8_t bytesprops3[] = {0x4a, 0x4a, 0x7b, 0x27, 0xa1, 0x37, 0x4, 0x56, 0xa0, 0xa5, 0x78, 0x50, 0x10, 0x2d, - 0x68, 0xc1, 0x5b, 0x81, 0xc6, 0xa8, 0xb4, 0x55, 0x98, 0x3, 0xab, 0xec, 0x47, 0xc7}; - uint8_t bytesprops4[] = {0xc9, 0xd5, 0x13, 0x95, 0x73, 0xc9, 0x30, 0x6d, 0x9f, 0xd2, 0x41, 0x24, 0xd4, 0x4c, 0x11, - 0x91, 0x42, 0x1b, 0xfa, 0xcd, 0x27, 0x6d, 0x1f, 0x95, 0x90, 0x5c, 0x93, 0x5a, 0x48}; - uint8_t bytesprops5[] = {0xeb, 0x86, 0xfd, 0x59, 0xff, 0x94, 0x23, 0x46, 0xc0, 0x1a, - 0x98, 0x3c, 0xae, 0x6e, 0x61, 0xfe, 0x17, 0xfb, 0x4}; - uint8_t bytesprops6[] = {0xc8, 0x93, 0x5f, 0xc2, 0xaa, 0xc9, 0x6e, 0x60}; - uint8_t bytesprops7[] = {0x74, 0xda, 0x93, 0xa0, 0xac, 0x80, 0x6d, 0x5a, 0x13, 0x33, - 0x52, 0x3c, 0x60, 0xa5, 0x75, 0x1d, 0x72, 0x64, 0x46, 0x80}; - uint8_t bytesprops8[] = {0xe3, 0x90, 0x23, 0x12, 0xcb, 0xc3, 0xa2, 0xc2, 0x23, 0x58, 0x22, 0x63, 0x5f, 0x5d, 0x7d, - 0xc9, 0xd8, 0xb5, 0x34, 0xbb, 0x92, 0x72, 0x4f, 0xbb, 0x2c, 0xf4, 0x2b, 0xd5, 0x25, 0xa3}; - uint8_t bytesprops9[] = {0x90, 0x1c, 0xe3, 0xc7, 0x4a, 0xda, 0xa1, 0x9a, 0x5f, 0x82, - 0x4a, 0xc3, 0x59, 0x74, 0xbb, 0xc5, 0xaa, 0x74, 0x56}; - uint8_t bytesprops10[] = {0x94, 0x1b, 0x6f, 0xd9, 0xb}; - uint8_t bytesprops12[] = {0xfd, 0x80, 0xe7, 0x3d, 0xac, 0x18, 0x54, 0xc, 0x8b, 0xca, 0xec, - 0x69, 0x45, 0x9d, 0xb1, 0x27, 0x62, 0x3c, 0x78, 0xf7, 0x77}; - uint8_t bytesprops11[] = {0x22, 0x57, 0xac, 0xb6, 0x9c, 0xdd, 0x97, 0x4, 0x43, 0xa5, - 0xcf, 0x36, 0xe7, 0xc1, 0xde, 0x53, 0x17, 0x1b, 0x75}; - uint8_t bytesprops13[] = {0x7e, 0xaa, 0xf7, 0xde, 0x84, 0x4a, 0xd, 0x9f}; - uint8_t bytesprops15[] = {0xf8, 0xb1, 0xdb, 0xcd, 0x7f, 0xb5, 0xf0, 0x7e, 0x81, 0x42, 0xf0, - 0x11, 0x47, 0x88, 0x3c, 0x41, 0xe6, 0x51, 0xb0, 0x71, 0xa3}; - uint8_t bytesprops14[] = {0x6e, 0xf3, 0x26, 0x0, 0x78, 0xdd, 0x9b, 0xb9, 0xae, 0xf8}; - uint8_t bytesprops16[] = {0x7e, 0xe1, 0xf8, 0xdd, 0x12, 0xa6, 0x39, 0x31}; + uint8_t bytesprops0[] = {0xa4, 0x4c, 0xc5, 0xd3, 0x95, 0x5d, 0xab, 0xc6, 0xce, 0x7f, 0xc5}; + uint8_t bytesprops2[] = {0xe9, 0xbf, 0x9b, 0x2f, 0x15, 0x8a, 0x2c, 0xd9, 0x3, 0x4b, 0xcb, 0xc}; + uint8_t bytesprops1[] = {0xa8, 0xf5, 0x57}; + uint8_t bytesprops3[] = {0xfd, 0xb0, 0x4f, 0x5e, 0xe9, 0x50, 0xae, 0x7f, 0xcd, 0xa0, 0x2, 0x22, + 0x4e, 0xe4, 0x58, 0x39, 0x8d, 0x39, 0x9e, 0xa9, 0x5d, 0x35, 0x16}; + uint8_t bytesprops4[] = {0xe9, 0xf3, 0xcb, 0xcf, 0x2c}; + uint8_t bytesprops5[] = {0xa1, 0xd5, 0xca, 0x10, 0xca, 0x5d, 0x1f, 0xd4, 0x2d, 0xa6, 0xee, 0x91}; + uint8_t bytesprops6[] = {0xad, 0x4c, 0x94, 0xf3, 0x64, 0x63, 0x1e, 0x8d, 0x66, + 0x46, 0x73, 0xb4, 0x25, 0x55, 0x33, 0x87, 0xfa}; + uint8_t bytesprops7[] = {0xaf, 0x64, 0x54, 0xaa, 0x48, 0xa1, 0xf2, 0x63, 0xcb, 0xd5, 0x85, 0x99, 0x90, 0xbc, + 0xab, 0x7e, 0x4e, 0xc6, 0x2b, 0xfc, 0x9c, 0xab, 0x0, 0xe3, 0xe0, 0x87, 0xdd, 0xb4}; + uint8_t bytesprops8[] = {0x13, 0xe3, 0xba, 0x25, 0x3b, 0x5f, 0xee, 0xa0}; + uint8_t bytesprops9[] = {0xf7, 0x3f, 0xd6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6725}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26844}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31945}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31366}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {19, (char*)&bytesprops11}, .v = {21, (char*)&bytesprops12}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {10, (char*)&bytesprops14}, .v = {21, (char*)&bytesprops15}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3463}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops16}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23474}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19390}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23674}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops1}, .v = {12, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6428}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 986}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26453}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7668}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18158}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5254}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28353}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10216, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10161, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\212", _pubPktID = 10216, -// _pubBody = "\241", _pubProps = [PropWillDelayInterval 6725,PropServerReference -// "\253w#\215\181Z\189\135\196H",PropAuthenticationMethod -// "\ESC\160\"S\250R\161\NAK\131\"\214\v\134Nd\199\219\230\139",PropAssignedClientIdentifier -// "e\233/\167Z\187uF\NUL\241\128q+YFH\146\241\224\147\245\223",PropReasonString -// "JJ{'\161\&7\EOTV\160\165xP\DLE-h\193[\129\198\168\180U\152\ETX\171\236G\199",PropMessageExpiryInterval -// 26844,PropResponseInformation -// "\201\213\DC3\149s\201\&0m\159\210A$\212L\DC1\145B\ESC\250\205'm\US\149\144\\\147ZH",PropContentType -// "\235\134\253Y\255\148#F\192\SUB\152<\174na\254\ETB\251\EOT",PropAssignedClientIdentifier -// "\200\147_\194\170\201n`",PropServerKeepAlive 31945,PropPayloadFormatIndicator 36,PropSubscriptionIdentifierAvailable -// 90,PropAuthenticationMethod "t\218\147\160\172\128mZ\DC33R<`\165u\GSrdF\128",PropReasonString -// "\227\144#\DC2\203\195\162\194#X\"c_]}\201\216\181\&4\187\146rO\187,\244+\213%\163",PropWillDelayInterval -// 31366,PropAuthenticationMethod "\144\FS\227\199J\218\161\154_\130J\195Yt\187\197\170tV",PropRetainAvailable -// 210,PropResponseTopic "\148\ESCo\217\v",PropUserProperty -// "\"W\172\182\156\221\151\EOTC\165\207\&6\231\193\222S\ETB\ESCu" -// "\253\128\231=\172\CANT\f\139\202\236iE\157\177'b|U\199", _pubPktID = +// 10161, _pubBody = "\240\177C\238jP+", _pubProps = [PropResponseInformation +// "\164L\197\211\149]\171\198\206\DEL\197",PropMaximumQoS 193,PropSubscriptionIdentifier 3,PropTopicAliasMaximum +// 19390,PropWillDelayInterval 23674,PropUserProperty "\168\245W" +// "\233\191\155/\NAK\138,\217\ETXK\203\f",PropAuthenticationMethod +// "\253\176O^\233P\174\DEL\205\160\STX\"N\228X9\141\&9\158\169]5\SYN",PropRequestResponseInformation +// 94,PropAssignedClientIdentifier "\233\243\203\207,",PropSubscriptionIdentifierAvailable 130,PropAuthenticationData +// "\161\213\202\DLE\202]\US\212-\166\238\145",PropPayloadFormatIndicator 9,PropRequestProblemInformation +// 208,PropTopicAlias 6428,PropServerReference "\173L\148\243dc\RS\141fFs\180%U3\135\250",PropReceiveMaximum +// 986,PropTopicAliasMaximum 26453,PropWillDelayInterval 7668,PropMaximumQoS 42,PropMessageExpiryInterval +// 18158,PropRetainAvailable 76,PropMessageExpiryInterval 5254,PropReceiveMaximum 28353,PropResponseInformation +// "\175dT\170H\161\242c\203\213\133\153\144\188\171~N\198+\252\156\171\NUL\227\224\135\221\180",PropCorrelationData +// "\DC3\227\186%;_\238\160",PropAuthenticationMethod "\247?\214",PropRequestProblemInformation +// 76,PropSubscriptionIdentifier 20]} TEST(Publish5QCTest, Decode2) { - uint8_t pkt[] = { - 0x32, 0x82, 0x3, 0x0, 0x2, 0xe9, 0xd4, 0x27, 0xe8, 0xf9, 0x2, 0x18, 0x0, 0x0, 0x1a, 0x45, 0x1c, 0x0, 0xa, - 0xfd, 0x77, 0x23, 0xd7, 0xb5, 0x5a, 0xbd, 0x87, 0xc4, 0x48, 0x15, 0x0, 0x13, 0x1b, 0xa0, 0x22, 0x53, 0xfa, 0x52, - 0xa1, 0x15, 0x83, 0x22, 0xd6, 0xb, 0x86, 0x4e, 0x64, 0xc7, 0xdb, 0xe6, 0x8b, 0x12, 0x0, 0x16, 0x65, 0xe9, 0x2f, - 0xa7, 0x5a, 0xbb, 0x75, 0x46, 0x0, 0xf1, 0x80, 0x71, 0x2b, 0x59, 0x46, 0x48, 0x92, 0xf1, 0xe0, 0x93, 0xf5, 0xdf, - 0x1f, 0x0, 0x1c, 0x4a, 0x4a, 0x7b, 0x27, 0xa1, 0x37, 0x4, 0x56, 0xa0, 0xa5, 0x78, 0x50, 0x10, 0x2d, 0x68, 0xc1, - 0x5b, 0x81, 0xc6, 0xa8, 0xb4, 0x55, 0x98, 0x3, 0xab, 0xec, 0x47, 0xc7, 0x2, 0x0, 0x0, 0x68, 0xdc, 0x1a, 0x0, - 0x1d, 0xc9, 0xd5, 0x13, 0x95, 0x73, 0xc9, 0x30, 0x6d, 0x9f, 0xd2, 0x41, 0x24, 0xd4, 0x4c, 0x11, 0x91, 0x42, 0x1b, - 0xfa, 0xcd, 0x27, 0x6d, 0x1f, 0x95, 0x90, 0x5c, 0x93, 0x5a, 0x48, 0x3, 0x0, 0x13, 0xeb, 0x86, 0xfd, 0x59, 0xff, - 0x94, 0x23, 0x46, 0xc0, 0x1a, 0x98, 0x3c, 0xae, 0x6e, 0x61, 0xfe, 0x17, 0xfb, 0x4, 0x12, 0x0, 0x8, 0xc8, 0x93, - 0x5f, 0xc2, 0xa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 0xf4, 0x24, 0x2a, 0x2, 0x0, 0x0, 0x46, 0xee, 0x25, 0x4c, 0x2, 0x0, 0x0, 0x14, 0x86, 0x21, + 0x6e, 0xc1, 0x1a, 0x0, 0x1c, 0xaf, 0x64, 0x54, 0xaa, 0x48, 0xa1, 0xf2, 0x63, 0xcb, 0xd5, 0x85, 0x99, + 0x90, 0xbc, 0xab, 0x7e, 0x4e, 0xc6, 0x2b, 0xfc, 0x9c, 0xab, 0x0, 0xe3, 0xe0, 0x87, 0xdd, 0xb4, 0x9, + 0x0, 0x8, 0x13, 0xe3, 0xba, 0x25, 0x3b, 0x5f, 0xee, 0xa0, 0x15, 0x0, 0x3, 0xf7, 0x3f, 0xd6, 0x17, + 0x4c, 0xb, 0x14, 0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2007,82 +1921,60 @@ TEST(Publish5QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe9, 0xd4}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf1}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, 0x55, 0xc7}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10216); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10161); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "}\162\DC3\157\161\140z\190\148\228\254\EOTk\211\&1\133\SI\188y\142\134e", _pubPktID = 11026, _pubBody = -// "\v/:\b\150\237Ih\224]\US\181R[r\179\234\185", _pubProps = [PropReasonString -// "\148P\EOT\247]b\DC3U,`3\DC4\207t\225\232",PropMessageExpiryInterval 23350,PropPayloadFormatIndicator -// 78,PropMessageExpiryInterval 19240,PropResponseInformation "\211\SOH\185\161",PropServerKeepAlive -// 24528,PropMaximumQoS 25]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\\\247{A0\nX.\STX\243\151\STX\230}\221\144D<\209\NAKM\153\192\209=d\148\179\231", _pubPktID = 26319, _pubBody = +// "\166\229\136\206\180b\149", _pubProps = [PropWillDelayInterval 6188,PropPayloadFormatIndicator 235]} TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = {0x3a, 0x58, 0x0, 0x16, 0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, - 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65, 0x2b, 0x12, 0x2b, 0x1f, - 0x0, 0x10, 0x94, 0x50, 0x4, 0xf7, 0x5d, 0x62, 0x13, 0x55, 0x2c, 0x60, 0x33, 0x14, 0xcf, - 0x74, 0xe1, 0xe8, 0x2, 0x0, 0x0, 0x5b, 0x36, 0x1, 0x4e, 0x2, 0x0, 0x0, 0x4b, 0x28, - 0x1a, 0x0, 0x4, 0xd3, 0x1, 0xb9, 0xa1, 0x13, 0x5f, 0xd0, 0x24, 0x19, 0xb, 0x2f, 0x3a, - 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; - uint8_t topic_bytes[] = {0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, - 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x30, 0x0, 0x1d, 0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, + 0x7d, 0xdd, 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7, 0x66, + 0xcf, 0x7, 0x18, 0x0, 0x0, 0x18, 0x2c, 0x1, 0xeb, 0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; + uint8_t topic_bytes[] = {0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, 0x7d, 0xdd, + 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xb, 0x2f, 0x3a, 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, - 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; + uint8_t msg_bytes[] = {0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; - - uint8_t bytesprops0[] = {0x94, 0x50, 0x4, 0xf7, 0x5d, 0x62, 0x13, 0x55, - 0x2c, 0x60, 0x33, 0x14, 0xcf, 0x74, 0xe1, 0xe8}; - uint8_t bytesprops1[] = {0xd3, 0x1, 0xb9, 0xa1}; + msg.payload_len = 7; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23350}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19240}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24528}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6188}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 235}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 11026, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 26319, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "}\162\DC3\157\161\140z\190\148\228\254\EOTk\211\&1\133\SI\188y\142\134e", _pubPktID = 11026, _pubBody = -// "\v/:\b\150\237Ih\224]\US\181R[r\179\234\185", _pubProps = [PropReasonString -// "\148P\EOT\247]b\DC3U,`3\DC4\207t\225\232",PropMessageExpiryInterval 23350,PropPayloadFormatIndicator -// 78,PropMessageExpiryInterval 19240,PropResponseInformation "\211\SOH\185\161",PropServerKeepAlive -// 24528,PropMaximumQoS 25]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\\\247{A0\nX.\STX\243\151\STX\230}\221\144D<\209\NAKM\153\192\209=d\148\179\231", _pubPktID = 26319, _pubBody = +// "\166\229\136\206\180b\149", _pubProps = [PropWillDelayInterval 6188,PropPayloadFormatIndicator 235]} TEST(Publish5QCTest, Decode3) { - uint8_t pkt[] = {0x3a, 0x58, 0x0, 0x16, 0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, - 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65, 0x2b, 0x12, 0x2b, 0x1f, - 0x0, 0x10, 0x94, 0x50, 0x4, 0xf7, 0x5d, 0x62, 0x13, 0x55, 0x2c, 0x60, 0x33, 0x14, 0xcf, - 0x74, 0xe1, 0xe8, 0x2, 0x0, 0x0, 0x5b, 0x36, 0x1, 0x4e, 0x2, 0x0, 0x0, 0x4b, 0x28, - 0x1a, 0x0, 0x4, 0xd3, 0x1, 0xb9, 0xa1, 0x13, 0x5f, 0xd0, 0x24, 0x19, 0xb, 0x2f, 0x3a, - 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; + uint8_t pkt[] = {0x3c, 0x30, 0x0, 0x1d, 0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, + 0x7d, 0xdd, 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7, 0x66, + 0xcf, 0x7, 0x18, 0x0, 0x0, 0x18, 0x2c, 0x1, 0xeb, 0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2090,107 +1982,142 @@ TEST(Publish5QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7d, 0xa2, 0x13, 0x9d, 0xa1, 0x8c, 0x7a, 0xbe, 0x94, 0xe4, 0xfe, - 0x4, 0x6b, 0xd3, 0x31, 0x85, 0xf, 0xbc, 0x79, 0x8e, 0x86, 0x65}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb, 0x2f, 0x3a, 0x8, 0x96, 0xed, 0x49, 0x68, 0xe0, - 0x5d, 0x1f, 0xb5, 0x52, 0x5b, 0x72, 0xb3, 0xea, 0xb9}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, 0x7d, 0xdd, + 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 11026); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + EXPECT_EQ(packet_id, 26319); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "'$k\221BT0a\ETB", _pubPktID = 21319, -// _pubBody = "\149", _pubProps = [PropWildcardSubscriptionAvailable 115,PropRequestResponseInformation -// 247,PropRequestResponseInformation 157,PropCorrelationData "\EM\163",PropSubscriptionIdentifier -// 22,PropCorrelationData ".u\174d\144%\173\196\173\228\STX\SUB#\235\173w\178\250\200\173",PropAuthenticationData -// "lY$\NULV\DC3\170",PropContentType "",PropSubscriptionIdentifierAvailable 53,PropPayloadFormatIndicator -// 94,PropMaximumQoS 144,PropCorrelationData -// "\136\236\145\"\241\190[\239\217aJ&\EM\159\233\US\133\182\NUL\170H\SI6\129\158\CAN",PropSharedSubscriptionAvailable -// 18,PropResponseTopic "\\M\232\148\v\225~\150\171=\129R\229\&4T\176\195",PropMaximumPacketSize -// 6451,PropServerKeepAlive 3476]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ETXTx", _pubPktID = 0, _pubBody = +// "Ei\SI", _pubProps = [PropAssignedClientIdentifier +// "\247P\DC3-\230\239\243.\bn\"k\DC4\253\149",PropMessageExpiryInterval 25436,PropMessageExpiryInterval +// 27046,PropServerKeepAlive 53,PropServerReference +// "t\f\"t\SYN\215\SI\136j\245\255\SI\ENQj\166U\206\169\151\177\254\197sv\206\&2V\DC3\221\DC2",PropMaximumQoS +// 25,PropResponseTopic "\153\231\234\251P\160\250\135\163\DLE\166C\234JZ\184\226A",PropAuthenticationMethod +// "\218\175u@J\220\235\149(^\192\SOH\148\r;\153\222\134Z\237Xr\r\136 ",PropUserProperty +// "\239\&6\163'\244\&2\255\GSpmxEb\146\142\156\215\235t" +// "\175\&2\225\245\240\&2\DC1^\135\156\197\164\202",PropMessageExpiryInterval 31197,PropResponseInformation +// "#Jq\213\243K\217\176\&5\165\146\CAN^\204\216\ESC\218e[",PropMaximumPacketSize 11704,PropSharedSubscriptionAvailable +// 116,PropContentType +// "\DC4\t\166B1\168\252\NUL<;\vp\aI\194\175`\t+\170\tG\212\136\191\&8\203%\207Q",PropRequestResponseInformation +// 182,PropTopicAlias 22990,PropMaximumPacketSize 5336,PropTopicAlias 26427,PropContentType +// "\176\252\ETX\245\224\182T\227kK\198%\204V\a0\194\174\&5y\240\205\131\196"]} TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = {0x3a, 0x81, 0x1, 0x0, 0x9, 0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17, 0x53, 0x47, 0x72, - 0x28, 0x73, 0x19, 0xf7, 0x19, 0x9d, 0x9, 0x0, 0x2, 0x19, 0xa3, 0xb, 0x16, 0x9, 0x0, 0x14, 0x2e, - 0x75, 0xae, 0x64, 0x90, 0x25, 0xad, 0xc4, 0xad, 0xe4, 0x2, 0x1a, 0x23, 0xeb, 0xad, 0x77, 0xb2, 0xfa, - 0xc8, 0xad, 0x16, 0x0, 0x7, 0x6c, 0x59, 0x24, 0x0, 0x56, 0x13, 0xaa, 0x3, 0x0, 0x0, 0x29, 0x35, - 0x1, 0x5e, 0x24, 0x90, 0x9, 0x0, 0x1a, 0x88, 0xec, 0x91, 0x22, 0xf1, 0xbe, 0x5b, 0xef, 0xd9, 0x61, - 0x4a, 0x26, 0x19, 0x9f, 0xe9, 0x1f, 0x85, 0xb6, 0x0, 0xaa, 0x48, 0xf, 0x36, 0x81, 0x9e, 0x18, 0x2a, - 0x12, 0x8, 0x0, 0x11, 0x5c, 0x4d, 0xe8, 0x94, 0xb, 0xe1, 0x7e, 0x96, 0xab, 0x3d, 0x81, 0x52, 0xe5, - 0x34, 0x54, 0xb0, 0xc3, 0x27, 0x0, 0x0, 0x19, 0x33, 0x13, 0xd, 0x94, 0x95}; - uint8_t topic_bytes[] = {0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x8d, 0x2, 0x0, 0x3, 0x3, 0x54, 0x78, 0x83, 0x2, 0x12, 0x0, 0xf, 0xf7, 0x50, 0x13, 0x2d, + 0xe6, 0xef, 0xf3, 0x2e, 0x8, 0x6e, 0x22, 0x6b, 0x14, 0xfd, 0x95, 0x2, 0x0, 0x0, 0x63, 0x5c, 0x2, + 0x0, 0x0, 0x69, 0xa6, 0x13, 0x0, 0x35, 0x1c, 0x0, 0x1e, 0x74, 0xc, 0x22, 0x74, 0x16, 0xd7, 0xf, + 0x88, 0x6a, 0xf5, 0xff, 0xf, 0x5, 0x6a, 0xa6, 0x55, 0xce, 0xa9, 0x97, 0xb1, 0xfe, 0xc5, 0x73, 0x76, + 0xce, 0x32, 0x56, 0x13, 0xdd, 0x12, 0x24, 0x19, 0x8, 0x0, 0x12, 0x99, 0xe7, 0xea, 0xfb, 0x50, 0xa0, + 0xfa, 0x87, 0xa3, 0x10, 0xa6, 0x43, 0xea, 0x4a, 0x5a, 0xb8, 0xe2, 0x41, 0x15, 0x0, 0x19, 0xda, 0xaf, + 0x75, 0x40, 0x4a, 0xdc, 0xeb, 0x95, 0x28, 0x5e, 0xc0, 0x1, 0x94, 0xd, 0x3b, 0x99, 0xde, 0x86, 0x5a, + 0xed, 0x58, 0x72, 0xd, 0x88, 0x20, 0x26, 0x0, 0x13, 0xef, 0x36, 0xa3, 0x27, 0xf4, 0x32, 0xff, 0x1d, + 0x70, 0x6d, 0x78, 0x45, 0x62, 0x92, 0x8e, 0x9c, 0xd7, 0xeb, 0x74, 0x0, 0xd, 0xaf, 0x32, 0xe1, 0xf5, + 0xf0, 0x32, 0x11, 0x5e, 0x87, 0x9c, 0xc5, 0xa4, 0xca, 0x2, 0x0, 0x0, 0x79, 0xdd, 0x1a, 0x0, 0x13, + 0x23, 0x4a, 0x71, 0xd5, 0xf3, 0x4b, 0xd9, 0xb0, 0x35, 0xa5, 0x92, 0x18, 0x5e, 0xcc, 0xd8, 0x1b, 0xda, + 0x65, 0x5b, 0x27, 0x0, 0x0, 0x2d, 0xb8, 0x2a, 0x74, 0x3, 0x0, 0x1e, 0x14, 0x9, 0xa6, 0x42, 0x31, + 0xa8, 0xfc, 0x0, 0x3c, 0x3b, 0xb, 0x70, 0x7, 0x49, 0xc2, 0xaf, 0x60, 0x9, 0x2b, 0xaa, 0x9, 0x47, + 0xd4, 0x88, 0xbf, 0x38, 0xcb, 0x25, 0xcf, 0x51, 0x19, 0xb6, 0x23, 0x59, 0xce, 0x27, 0x0, 0x0, 0x14, + 0xd8, 0x23, 0x67, 0x3b, 0x3, 0x0, 0x18, 0xb0, 0xfc, 0x3, 0xf5, 0xe0, 0xb6, 0x54, 0xe3, 0x6b, 0x4b, + 0xc6, 0x25, 0xcc, 0x56, 0x7, 0x30, 0xc2, 0xae, 0x35, 0x79, 0xf0, 0xcd, 0x83, 0xc4, 0x45, 0x69, 0xf}; + uint8_t topic_bytes[] = {0x3, 0x54, 0x78}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x95}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x45, 0x69, 0xf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; - - uint8_t bytesprops0[] = {0x19, 0xa3}; - uint8_t bytesprops1[] = {0x2e, 0x75, 0xae, 0x64, 0x90, 0x25, 0xad, 0xc4, 0xad, 0xe4, - 0x2, 0x1a, 0x23, 0xeb, 0xad, 0x77, 0xb2, 0xfa, 0xc8, 0xad}; - uint8_t bytesprops2[] = {0x6c, 0x59, 0x24, 0x0, 0x56, 0x13, 0xaa}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x88, 0xec, 0x91, 0x22, 0xf1, 0xbe, 0x5b, 0xef, 0xd9, 0x61, 0x4a, 0x26, 0x19, - 0x9f, 0xe9, 0x1f, 0x85, 0xb6, 0x0, 0xaa, 0x48, 0xf, 0x36, 0x81, 0x9e, 0x18}; - uint8_t bytesprops5[] = {0x5c, 0x4d, 0xe8, 0x94, 0xb, 0xe1, 0x7e, 0x96, 0xab, - 0x3d, 0x81, 0x52, 0xe5, 0x34, 0x54, 0xb0, 0xc3}; + msg.payload_len = 3; + + uint8_t bytesprops0[] = {0xf7, 0x50, 0x13, 0x2d, 0xe6, 0xef, 0xf3, 0x2e, 0x8, 0x6e, 0x22, 0x6b, 0x14, 0xfd, 0x95}; + uint8_t bytesprops1[] = {0x74, 0xc, 0x22, 0x74, 0x16, 0xd7, 0xf, 0x88, 0x6a, 0xf5, 0xff, 0xf, 0x5, 0x6a, 0xa6, + 0x55, 0xce, 0xa9, 0x97, 0xb1, 0xfe, 0xc5, 0x73, 0x76, 0xce, 0x32, 0x56, 0x13, 0xdd, 0x12}; + uint8_t bytesprops2[] = {0x99, 0xe7, 0xea, 0xfb, 0x50, 0xa0, 0xfa, 0x87, 0xa3, + 0x10, 0xa6, 0x43, 0xea, 0x4a, 0x5a, 0xb8, 0xe2, 0x41}; + uint8_t bytesprops3[] = {0xda, 0xaf, 0x75, 0x40, 0x4a, 0xdc, 0xeb, 0x95, 0x28, 0x5e, 0xc0, 0x1, 0x94, + 0xd, 0x3b, 0x99, 0xde, 0x86, 0x5a, 0xed, 0x58, 0x72, 0xd, 0x88, 0x20}; + uint8_t bytesprops5[] = {0xaf, 0x32, 0xe1, 0xf5, 0xf0, 0x32, 0x11, 0x5e, 0x87, 0x9c, 0xc5, 0xa4, 0xca}; + uint8_t bytesprops4[] = {0xef, 0x36, 0xa3, 0x27, 0xf4, 0x32, 0xff, 0x1d, 0x70, 0x6d, + 0x78, 0x45, 0x62, 0x92, 0x8e, 0x9c, 0xd7, 0xeb, 0x74}; + uint8_t bytesprops6[] = {0x23, 0x4a, 0x71, 0xd5, 0xf3, 0x4b, 0xd9, 0xb0, 0x35, 0xa5, + 0x92, 0x18, 0x5e, 0xcc, 0xd8, 0x1b, 0xda, 0x65, 0x5b}; + uint8_t bytesprops7[] = {0x14, 0x9, 0xa6, 0x42, 0x31, 0xa8, 0xfc, 0x0, 0x3c, 0x3b, 0xb, 0x70, 0x7, 0x49, 0xc2, + 0xaf, 0x60, 0x9, 0x2b, 0xaa, 0x9, 0x47, 0xd4, 0x88, 0xbf, 0x38, 0xcb, 0x25, 0xcf, 0x51}; + uint8_t bytesprops8[] = {0xb0, 0xfc, 0x3, 0xf5, 0xe0, 0xb6, 0x54, 0xe3, 0x6b, 0x4b, 0xc6, 0x25, + 0xcc, 0x56, 0x7, 0x30, 0xc2, 0xae, 0x35, 0x79, 0xf0, 0xcd, 0x83, 0xc4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6451}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3476}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25436}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27046}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 53}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops4}, .v = {13, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31197}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11704}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22990}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5336}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26427}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 21319, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "'$k\221BT0a\ETB", _pubPktID = 21319, -// _pubBody = "\149", _pubProps = [PropWildcardSubscriptionAvailable 115,PropRequestResponseInformation -// 247,PropRequestResponseInformation 157,PropCorrelationData "\EM\163",PropSubscriptionIdentifier -// 22,PropCorrelationData ".u\174d\144%\173\196\173\228\STX\SUB#\235\173w\178\250\200\173",PropAuthenticationData -// "lY$\NULV\DC3\170",PropContentType "",PropSubscriptionIdentifierAvailable 53,PropPayloadFormatIndicator -// 94,PropMaximumQoS 144,PropCorrelationData -// "\136\236\145\"\241\190[\239\217aJ&\EM\159\233\US\133\182\NUL\170H\SI6\129\158\CAN",PropSharedSubscriptionAvailable -// 18,PropResponseTopic "\\M\232\148\v\225~\150\171=\129R\229\&4T\176\195",PropMaximumPacketSize -// 6451,PropServerKeepAlive 3476]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ETXTx", _pubPktID = 0, _pubBody = +// "Ei\SI", _pubProps = [PropAssignedClientIdentifier +// "\247P\DC3-\230\239\243.\bn\"k\DC4\253\149",PropMessageExpiryInterval 25436,PropMessageExpiryInterval +// 27046,PropServerKeepAlive 53,PropServerReference +// "t\f\"t\SYN\215\SI\136j\245\255\SI\ENQj\166U\206\169\151\177\254\197sv\206\&2V\DC3\221\DC2",PropMaximumQoS +// 25,PropResponseTopic "\153\231\234\251P\160\250\135\163\DLE\166C\234JZ\184\226A",PropAuthenticationMethod +// "\218\175u@J\220\235\149(^\192\SOH\148\r;\153\222\134Z\237Xr\r\136 ",PropUserProperty +// "\239\&6\163'\244\&2\255\GSpmxEb\146\142\156\215\235t" +// "\175\&2\225\245\240\&2\DC1^\135\156\197\164\202",PropMessageExpiryInterval 31197,PropResponseInformation +// "#Jq\213\243K\217\176\&5\165\146\CAN^\204\216\ESC\218e[",PropMaximumPacketSize 11704,PropSharedSubscriptionAvailable +// 116,PropContentType +// "\DC4\t\166B1\168\252\NUL<;\vp\aI\194\175`\t+\170\tG\212\136\191\&8\203%\207Q",PropRequestResponseInformation +// 182,PropTopicAlias 22990,PropMaximumPacketSize 5336,PropTopicAlias 26427,PropContentType +// "\176\252\ETX\245\224\182T\227kK\198%\204V\a0\194\174\&5y\240\205\131\196"]} TEST(Publish5QCTest, Decode4) { - uint8_t pkt[] = {0x3a, 0x81, 0x1, 0x0, 0x9, 0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17, 0x53, 0x47, 0x72, - 0x28, 0x73, 0x19, 0xf7, 0x19, 0x9d, 0x9, 0x0, 0x2, 0x19, 0xa3, 0xb, 0x16, 0x9, 0x0, 0x14, 0x2e, - 0x75, 0xae, 0x64, 0x90, 0x25, 0xad, 0xc4, 0xad, 0xe4, 0x2, 0x1a, 0x23, 0xeb, 0xad, 0x77, 0xb2, 0xfa, - 0xc8, 0xad, 0x16, 0x0, 0x7, 0x6c, 0x59, 0x24, 0x0, 0x56, 0x13, 0xaa, 0x3, 0x0, 0x0, 0x29, 0x35, - 0x1, 0x5e, 0x24, 0x90, 0x9, 0x0, 0x1a, 0x88, 0xec, 0x91, 0x22, 0xf1, 0xbe, 0x5b, 0xef, 0xd9, 0x61, - 0x4a, 0x26, 0x19, 0x9f, 0xe9, 0x1f, 0x85, 0xb6, 0x0, 0xaa, 0x48, 0xf, 0x36, 0x81, 0x9e, 0x18, 0x2a, - 0x12, 0x8, 0x0, 0x11, 0x5c, 0x4d, 0xe8, 0x94, 0xb, 0xe1, 0x7e, 0x96, 0xab, 0x3d, 0x81, 0x52, 0xe5, - 0x34, 0x54, 0xb0, 0xc3, 0x27, 0x0, 0x0, 0x19, 0x33, 0x13, 0xd, 0x94, 0x95}; + uint8_t pkt[] = {0x39, 0x8d, 0x2, 0x0, 0x3, 0x3, 0x54, 0x78, 0x83, 0x2, 0x12, 0x0, 0xf, 0xf7, 0x50, 0x13, 0x2d, + 0xe6, 0xef, 0xf3, 0x2e, 0x8, 0x6e, 0x22, 0x6b, 0x14, 0xfd, 0x95, 0x2, 0x0, 0x0, 0x63, 0x5c, 0x2, + 0x0, 0x0, 0x69, 0xa6, 0x13, 0x0, 0x35, 0x1c, 0x0, 0x1e, 0x74, 0xc, 0x22, 0x74, 0x16, 0xd7, 0xf, + 0x88, 0x6a, 0xf5, 0xff, 0xf, 0x5, 0x6a, 0xa6, 0x55, 0xce, 0xa9, 0x97, 0xb1, 0xfe, 0xc5, 0x73, 0x76, + 0xce, 0x32, 0x56, 0x13, 0xdd, 0x12, 0x24, 0x19, 0x8, 0x0, 0x12, 0x99, 0xe7, 0xea, 0xfb, 0x50, 0xa0, + 0xfa, 0x87, 0xa3, 0x10, 0xa6, 0x43, 0xea, 0x4a, 0x5a, 0xb8, 0xe2, 0x41, 0x15, 0x0, 0x19, 0xda, 0xaf, + 0x75, 0x40, 0x4a, 0xdc, 0xeb, 0x95, 0x28, 0x5e, 0xc0, 0x1, 0x94, 0xd, 0x3b, 0x99, 0xde, 0x86, 0x5a, + 0xed, 0x58, 0x72, 0xd, 0x88, 0x20, 0x26, 0x0, 0x13, 0xef, 0x36, 0xa3, 0x27, 0xf4, 0x32, 0xff, 0x1d, + 0x70, 0x6d, 0x78, 0x45, 0x62, 0x92, 0x8e, 0x9c, 0xd7, 0xeb, 0x74, 0x0, 0xd, 0xaf, 0x32, 0xe1, 0xf5, + 0xf0, 0x32, 0x11, 0x5e, 0x87, 0x9c, 0xc5, 0xa4, 0xca, 0x2, 0x0, 0x0, 0x79, 0xdd, 0x1a, 0x0, 0x13, + 0x23, 0x4a, 0x71, 0xd5, 0xf3, 0x4b, 0xd9, 0xb0, 0x35, 0xa5, 0x92, 0x18, 0x5e, 0xcc, 0xd8, 0x1b, 0xda, + 0x65, 0x5b, 0x27, 0x0, 0x0, 0x2d, 0xb8, 0x2a, 0x74, 0x3, 0x0, 0x1e, 0x14, 0x9, 0xa6, 0x42, 0x31, + 0xa8, 0xfc, 0x0, 0x3c, 0x3b, 0xb, 0x70, 0x7, 0x49, 0xc2, 0xaf, 0x60, 0x9, 0x2b, 0xaa, 0x9, 0x47, + 0xd4, 0x88, 0xbf, 0x38, 0xcb, 0x25, 0xcf, 0x51, 0x19, 0xb6, 0x23, 0x59, 0xce, 0x27, 0x0, 0x0, 0x14, + 0xd8, 0x23, 0x67, 0x3b, 0x3, 0x0, 0x18, 0xb0, 0xfc, 0x3, 0xf5, 0xe0, 0xb6, 0x54, 0xe3, 0x6b, 0x4b, + 0xc6, 0x25, 0xcc, 0x56, 0x7, 0x30, 0xc2, 0xae, 0x35, 0x79, 0xf0, 0xcd, 0x83, 0xc4, 0x45, 0x69, 0xf}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2198,146 +2125,154 @@ TEST(Publish5QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x27, 0x24, 0x6b, 0xdd, 0x42, 0x54, 0x30, 0x61, 0x17}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x95}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3, 0x54, 0x78}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x45, 0x69, 0xf}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 21319); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\US\134\217^\225\USI\SOH%\234]\SUB\251\158\ENQ\188\140@\224\ETX\185}", _pubPktID = 0, _pubBody = "\222", _pubProps = -// [PropSubscriptionIdentifierAvailable 189,PropRequestResponseInformation 84,PropSubscriptionIdentifier -// 29,PropServerReference -// "E\131\240\200\175\198\SOH\248\231\188\133\224\237\b\SO\242\185\202(T\241\211\nXIr\138\242\237",PropReasonString -// "\159k\129\206^!,'\165\215",PropSharedSubscriptionAvailable 210,PropAssignedClientIdentifier -// "\168\200\213T1\213\CAN]",PropServerKeepAlive 27765,PropMaximumQoS 169,PropAssignedClientIdentifier -// "?\229\ESC\252\208\157\225\210\157H\254\133\209\229l\172\215\151\152",PropCorrelationData -// "\200\181\202`V\b<\200\134\154m?Oq&G\143\246\243\NUL\185\218\143\&5~gO\254\DC4",PropServerKeepAlive -// 27340,PropWillDelayInterval 3446,PropMaximumQoS 186,PropCorrelationData -// "\SIU\r\146@\227\184\154\163cF\206T2\197\218\231",PropMaximumQoS 85,PropSubscriptionIdentifier 28,PropRetainAvailable -// 137,PropRequestProblemInformation 19,PropCorrelationData "\255\237\186*\177\171\132\FS\172\201\194",PropTopicAlias -// 26253,PropSubscriptionIdentifierAvailable 72,PropRequestProblemInformation 78,PropWildcardSubscriptionAvailable -// 25,PropPayloadFormatIndicator 173,PropWildcardSubscriptionAvailable 192,PropMaximumQoS 143,PropReceiveMaximum -// 23224,PropAuthenticationMethod "]Y\239\223\215\SO\FS`\EOT\242\236\218<\251\&3"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 7815, _pubBody = +// "\168\142\FS", _pubProps = [PropResponseInformation "\208/+\158\144\255\SYN\SO\243Inw",PropTopicAliasMaximum +// 18437,PropTopicAliasMaximum 1104,PropSessionExpiryInterval 27902,PropServerReference +// "\134\174\231\235\232\CAN\178\130\CAN\216f\166 \145\172\141",PropTopicAliasMaximum 8918,PropMessageExpiryInterval +// 27657,PropAuthenticationMethod "\196'\\-",PropContentType +// "\150\\\188\244\131\167\193\136\DC4\CANB\v",PropSessionExpiryInterval 7240,PropAuthenticationMethod +// "\155\v:@\NAK\193\248M*",PropRetainAvailable 253,PropContentType +// "\NUL\252knZ\139JD\239\242%.\144\DC2\185\132R\f\244?",PropAssignedClientIdentifier +// "\209G\149\221\188\138*\FS\ACKu\181\161z\208\169\197\RS\250`r\213\168\237\&4H\174\245",PropReasonString +// "\238q\162m\237\204\214\246[\SI\DC3\151\142k\140\&8 a\SI\GS",PropSharedSubscriptionAvailable 1,PropTopicAliasMaximum +// 3287,PropMessageExpiryInterval 7895,PropRequestResponseInformation 238,PropRequestResponseInformation +// 247,PropRequestProblemInformation 76,PropCorrelationData +// "\194\211\165\148fO\208\198\167Xk\134w\255U`\169\EOT\133I\179u\241\ETXx\254",PropWillDelayInterval +// 20602,PropMessageExpiryInterval 24630,PropContentType +// "2\248\130\228\STX\203\237\146\161\153\250z\160H",PropMaximumPacketSize 18994,PropReasonString +// "\140-\216\252\240u\246\234\213\233y\253\167\196\223:\151"]} T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c5, 0xda, 0xe7, 0x24, 0x55, 0xb, 0x1c, 0x25, 0x89, 0x17, 0x13, - 0x9, 0x0, 0xb, 0xff, 0xed, 0xba, 0x2a, 0xb1, 0xab, 0x84, 0x1c, 0xac, 0xc9, 0xc2, 0x23, 0x66, 0x8d, 0x29, 0x48, - 0x17, 0x4e, 0x28, 0x19, 0x1, 0xad, 0x28, 0xc0, 0x24, 0x8f, 0x21, 0x5a, 0xb8, 0x15, 0x0, 0xf, 0x5d, 0x59, 0xef, - 0xdf, 0xd7, 0xe, 0x1c, 0x60, 0x4, 0xf2, 0xec, 0xda, 0x3c, 0xfb, 0x33, 0xde}; - uint8_t topic_bytes[] = {0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, 0x5d, - 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + 0x34, 0x94, 0x2, 0x0, 0x0, 0x1e, 0x87, 0x8b, 0x2, 0x1a, 0x0, 0xc, 0xd0, 0x2f, 0x2b, 0x9e, 0x90, 0xff, 0x16, + 0xe, 0xf3, 0x49, 0x6e, 0x77, 0x22, 0x48, 0x5, 0x22, 0x4, 0x50, 0x11, 0x0, 0x0, 0x6c, 0xfe, 0x1c, 0x0, 0x10, + 0x86, 0xae, 0xe7, 0xeb, 0xe8, 0x18, 0xb2, 0x82, 0x18, 0xd8, 0x66, 0xa6, 0x20, 0x91, 0xac, 0x8d, 0x22, 0x22, 0xd6, + 0x2, 0x0, 0x0, 0x6c, 0x9, 0x15, 0x0, 0x4, 0xc4, 0x27, 0x5c, 0x2d, 0x3, 0x0, 0xc, 0x96, 0x5c, 0xbc, 0xf4, + 0x83, 0xa7, 0xc1, 0x88, 0x14, 0x18, 0x42, 0xb, 0x11, 0x0, 0x0, 0x1c, 0x48, 0x15, 0x0, 0x9, 0x9b, 0xb, 0x3a, + 0x40, 0x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[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xde}; + uint8_t msg_bytes[] = {0xa8, 0x8e, 0x1c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; - - uint8_t bytesprops0[] = {0x45, 0x83, 0xf0, 0xc8, 0xaf, 0xc6, 0x1, 0xf8, 0xe7, 0xbc, 0x85, 0xe0, 0xed, 0x8, 0xe, - 0xf2, 0xb9, 0xca, 0x28, 0x54, 0xf1, 0xd3, 0xa, 0x58, 0x49, 0x72, 0x8a, 0xf2, 0xed}; - uint8_t bytesprops1[] = {0x9f, 0x6b, 0x81, 0xce, 0x5e, 0x21, 0x2c, 0x27, 0xa5, 0xd7}; - uint8_t bytesprops2[] = {0xa8, 0xc8, 0xd5, 0x54, 0x31, 0xd5, 0x18, 0x5d}; - uint8_t bytesprops3[] = {0x3f, 0xe5, 0x1b, 0xfc, 0xd0, 0x9d, 0xe1, 0xd2, 0x9d, 0x48, - 0xfe, 0x85, 0xd1, 0xe5, 0x6c, 0xac, 0xd7, 0x97, 0x98}; - uint8_t bytesprops4[] = {0xc8, 0xb5, 0xca, 0x60, 0x56, 0x8, 0x3c, 0xc8, 0x86, 0x9a, 0x6d, 0x3f, 0x4f, 0x71, 0x26, - 0x47, 0x8f, 0xf6, 0xf3, 0x0, 0xb9, 0xda, 0x8f, 0x35, 0x7e, 0x67, 0x4f, 0xfe, 0x14}; - uint8_t bytesprops5[] = {0xf, 0x55, 0xd, 0x92, 0x40, 0xe3, 0xb8, 0x9a, 0xa3, - 0x63, 0x46, 0xce, 0x54, 0x32, 0xc5, 0xda, 0xe7}; - uint8_t bytesprops6[] = {0xff, 0xed, 0xba, 0x2a, 0xb1, 0xab, 0x84, 0x1c, 0xac, 0xc9, 0xc2}; - uint8_t bytesprops7[] = {0x5d, 0x59, 0xef, 0xdf, 0xd7, 0xe, 0x1c, 0x60, 0x4, 0xf2, 0xec, 0xda, 0x3c, 0xfb, 0x33}; + msg.payload_len = 3; + + uint8_t bytesprops0[] = {0xd0, 0x2f, 0x2b, 0x9e, 0x90, 0xff, 0x16, 0xe, 0xf3, 0x49, 0x6e, 0x77}; + uint8_t bytesprops1[] = {0x86, 0xae, 0xe7, 0xeb, 0xe8, 0x18, 0xb2, 0x82, + 0x18, 0xd8, 0x66, 0xa6, 0x20, 0x91, 0xac, 0x8d}; + uint8_t bytesprops2[] = {0xc4, 0x27, 0x5c, 0x2d}; + uint8_t bytesprops3[] = {0x96, 0x5c, 0xbc, 0xf4, 0x83, 0xa7, 0xc1, 0x88, 0x14, 0x18, 0x42, 0xb}; + uint8_t bytesprops4[] = {0x9b, 0xb, 0x3a, 0x40, 0x15, 0xc1, 0xf8, 0x4d, 0x2a}; + uint8_t bytesprops5[] = {0x0, 0xfc, 0x6b, 0x6e, 0x5a, 0x8b, 0x4a, 0x44, 0xef, 0xf2, + 0x25, 0x2e, 0x90, 0x12, 0xb9, 0x84, 0x52, 0xc, 0xf4, 0x3f}; + uint8_t bytesprops6[] = {0xd1, 0x47, 0x95, 0xdd, 0xbc, 0x8a, 0x2a, 0x1c, 0x6, 0x75, 0xb5, 0xa1, 0x7a, 0xd0, + 0xa9, 0xc5, 0x1e, 0xfa, 0x60, 0x72, 0xd5, 0xa8, 0xed, 0x34, 0x48, 0xae, 0xf5}; + uint8_t bytesprops7[] = {0xee, 0x71, 0xa2, 0x6d, 0xed, 0xcc, 0xd6, 0xf6, 0x5b, 0xf, + 0x13, 0x97, 0x8e, 0x6b, 0x8c, 0x38, 0x20, 0x61, 0xf, 0x1d}; + uint8_t bytesprops8[] = {0xc2, 0xd3, 0xa5, 0x94, 0x66, 0x4f, 0xd0, 0xc6, 0xa7, 0x58, 0x6b, 0x86, 0x77, + 0xff, 0x55, 0x60, 0xa9, 0x4, 0x85, 0x49, 0xb3, 0x75, 0xf1, 0x3, 0x78, 0xfe}; + uint8_t bytesprops9[] = {0x32, 0xf8, 0x82, 0xe4, 0x2, 0xcb, 0xed, 0x92, 0xa1, 0x99, 0xfa, 0x7a, 0xa0, 0x48}; + uint8_t bytesprops10[] = {0x8c, 0x2d, 0xd8, 0xfc, 0xf0, 0x75, 0xf6, 0xea, 0xd5, + 0xe9, 0x79, 0xfd, 0xa7, 0xc4, 0xdf, 0x3a, 0x97}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27765}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27340}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3446}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26253}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23224}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18437}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1104}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27902}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8918}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27657}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7240}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3287}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7895}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20602}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24630}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18994}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7815, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\US\134\217^\225\USI\SOH%\234]\SUB\251\158\ENQ\188\140@\224\ETX\185}", _pubPktID = 0, _pubBody = "\222", _pubProps = -// [PropSubscriptionIdentifierAvailable 189,PropRequestResponseInformation 84,PropSubscriptionIdentifier -// 29,PropServerReference -// "E\131\240\200\175\198\SOH\248\231\188\133\224\237\b\SO\242\185\202(T\241\211\nXIr\138\242\237",PropReasonString -// "\159k\129\206^!,'\165\215",PropSharedSubscriptionAvailable 210,PropAssignedClientIdentifier -// "\168\200\213T1\213\CAN]",PropServerKeepAlive 27765,PropMaximumQoS 169,PropAssignedClientIdentifier -// "?\229\ESC\252\208\157\225\210\157H\254\133\209\229l\172\215\151\152",PropCorrelationData -// "\200\181\202`V\b<\200\134\154m?Oq&G\143\246\243\NUL\185\218\143\&5~gO\254\DC4",PropServerKeepAlive -// 27340,PropWillDelayInterval 3446,PropMaximumQoS 186,PropCorrelationData -// "\SIU\r\146@\227\184\154\163cF\206T2\197\218\231",PropMaximumQoS 85,PropSubscriptionIdentifier 28,PropRetainAvailable -// 137,PropRequestProblemInformation 19,PropCorrelationData "\255\237\186*\177\171\132\FS\172\201\194",PropTopicAlias -// 26253,PropSubscriptionIdentifierAvailable 72,PropRequestProblemInformation 78,PropWildcardSubscriptionAvailable -// 25,PropPayloadFormatIndicator 173,PropWildcardSubscriptionAvailable 192,PropMaximumQoS 143,PropReceiveMaximum -// 23224,PropAuthenticationMethod "]Y\239\223\215\SO\FS`\EOT\242\236\218<\251\&3"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 7815, _pubBody = +// "\168\142\FS", _pubProps = [PropResponseInformation "\208/+\158\144\255\SYN\SO\243Inw",PropTopicAliasMaximum +// 18437,PropTopicAliasMaximum 1104,PropSessionExpiryInterval 27902,PropServerReference +// "\134\174\231\235\232\CAN\178\130\CAN\216f\166 \145\172\141",PropTopicAliasMaximum 8918,PropMessageExpiryInterval +// 27657,PropAuthenticationMethod "\196'\\-",PropContentType +// "\150\\\188\244\131\167\193\136\DC4\CANB\v",PropSessionExpiryInterval 7240,PropAuthenticationMethod +// "\155\v:@\NAK\193\248M*",PropRetainAvailable 253,PropContentType +// "\NUL\252knZ\139JD\239\242%.\144\DC2\185\132R\f\244?",PropAssignedClientIdentifier +// "\209G\149\221\188\138*\FS\ACKu\181\161z\208\169\197\RS\250`r\213\168\237\&4H\174\245",PropReasonString +// "\238q\162m\237\204\214\246[\SI\DC3\151\142k\140\&8 a\SI\GS",PropSharedSubscriptionAvailable 1,PropTopicAliasMaximum +// 3287,PropMessageExpiryInterval 7895,PropRequestResponseInformation 238,PropRequestResponseInformation +// 247,PropRequestProblemInformation 76,PropCorrelationData +// "\194\211\165\148fO\208\198\167Xk\134w\255U`\169\EOT\133I\179u\241\ETXx\254",PropWillDelayInterval +// 20602,PropMessageExpiryInterval 24630,PropContentType +// "2\248\130\228\STX\203\237\146\161\153\250z\160H",PropMaximumPacketSize 18994,PropReasonString +// "\140-\216\252\240u\246\234\213\233y\253\167\196\223:\151"]} TEST(Publish5QCTest, Decode5) { uint8_t pkt[] = { - 0x30, 0xee, 0x1, 0x0, 0x16, 0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, 0x5d, 0x1a, 0xfb, 0x9e, - 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d, 0xd3, 0x1, 0x29, 0xbd, 0x19, 0x54, 0xb, 0x1d, 0x1c, 0x0, 0x1d, - 0x45, 0x83, 0xf0, 0xc8, 0xaf, 0xc6, 0x1, 0xf8, 0xe7, 0xbc, 0x85, 0xe0, 0xed, 0x8, 0xe, 0xf2, 0xb9, 0xca, 0x28, - 0x54, 0xf1, 0xd3, 0xa, 0x58, 0x49, 0x72, 0x8a, 0xf2, 0xed, 0x1f, 0x0, 0xa, 0x9f, 0x6b, 0x81, 0xce, 0x5e, 0x21, - 0x2c, 0x27, 0xa5, 0xd7, 0x2a, 0xd2, 0x12, 0x0, 0x8, 0xa8, 0xc8, 0xd5, 0x54, 0x31, 0xd5, 0x18, 0x5d, 0x13, 0x6c, - 0x75, 0x24, 0xa9, 0x12, 0x0, 0x13, 0x3f, 0xe5, 0x1b, 0xfc, 0xd0, 0x9d, 0xe1, 0xd2, 0x9d, 0x48, 0xfe, 0x85, 0xd1, - 0xe5, 0x6c, 0xac, 0xd7, 0x97, 0x98, 0x9, 0x0, 0x1d, 0xc8, 0xb5, 0xca, 0x60, 0x56, 0x8, 0x3c, 0xc8, 0x86, 0x9a, - 0x6d, 0x3f, 0x4f, 0x71, 0x26, 0x47, 0x8f, 0xf6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, 0x97, 0xa8, 0x8e, 0x1c}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2345,112 +2280,164 @@ TEST(Publish5QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x1f, 0x86, 0xd9, 0x5e, 0xe1, 0x1f, 0x49, 0x1, 0x25, 0xea, 0x5d, - 0x1a, 0xfb, 0x9e, 0x5, 0xbc, 0x8c, 0x40, 0xe0, 0x3, 0xb9, 0x7d}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xde}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa8, 0x8e, 0x1c}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(packet_id, 7815); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\152\168e\228f1ic\227\250", _pubPktID -// = 0, _pubBody = "\195\&1\199\231\246bO,\"\146\SOE`:", _pubProps = [PropSubscriptionIdentifierAvailable -// 203,PropReasonString "\209\254\145\232aU\n\196\215",PropRequestResponseInformation 200,PropAssignedClientIdentifier -// "\EOT\r7\USQ>\207\178\FS\138Zh5\ETX\251X\136\164\177G\161\ff\131\221{\205\&1L",PropContentType -// "\156\215\NAK\179\178\130\169\180<\DC2\181\253x\SUB\232*P?\237\242h)\148\199Q!\FS\150\n",PropContentType -// "BB\183\248\147\230\184Nw\193\&8\178\DEL\DC2\153\&9zV{\250B\151a",PropMaximumPacketSize -// 3529,PropSubscriptionIdentifier 5,PropMaximumPacketSize 9765,PropAssignedClientIdentifier -// "\153\248\251\172\181/\247\138!?\200\250j\191\242\193s\145f\232\187\192\249\238\190",PropTopicAliasMaximum -// 18828,PropMessageExpiryInterval 17667,PropWillDelayInterval 6761,PropTopicAlias 26579]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\174\208\231e\229\225\201\ENQS\217\DEL\146\214\ENQ\145", _pubPktID = 25416, _pubBody = +// "\151\234\215\234\133\219\164\174\221\&1\EOTCs\212\"\141`\135\243\236q}6", _pubProps = [PropSubscriptionIdentifier +// 25,PropTopicAlias 29625,PropSubscriptionIdentifier 0,PropSharedSubscriptionAvailable 209,PropServerReference +// "\vG\165\&1\148\EM.\205\130\USV\158\132\251\187",PropMaximumQoS 91,PropRequestResponseInformation 123,PropTopicAlias +// 17527,PropServerReference +// "T\226\150\184\232\235\133\234\223\158\137\DLE\142\\\225\134\223\209\252\FSn\204]\177\249",PropMessageExpiryInterval +// 987,PropMaximumQoS 227,PropMaximumQoS 97,PropRetainAvailable 25,PropResponseInformation +// "\221\233[\240\SYN\187\242~\196\STX\136\165\198\&5\207\178\FS\138Zh5\ETX\251X\136\164\177G\161\ff\131\221{\205\&1L",PropContentType -// "\156\215\NAK\179\178\130\169\180<\DC2\181\253x\SUB\232*P?\237\242h)\148\199Q!\FS\150\n",PropContentType -// "BB\183\248\147\230\184Nw\193\&8\178\DEL\DC2\153\&9zV{\250B\151a",PropMaximumPacketSize -// 3529,PropSubscriptionIdentifier 5,PropMaximumPacketSize 9765,PropAssignedClientIdentifier -// "\153\248\251\172\181/\247\138!?\200\250j\191\242\193s\145f\232\187\192\249\238\190",PropTopicAliasMaximum -// 18828,PropMessageExpiryInterval 17667,PropWillDelayInterval 6761,PropTopicAlias 26579]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\174\208\231e\229\225\201\ENQS\217\DEL\146\214\ENQ\145", _pubPktID = 25416, _pubBody = +// "\151\234\215\234\133\219\164\174\221\&1\EOTCs\212\"\141`\135\243\236q}6", _pubProps = [PropSubscriptionIdentifier +// 25,PropTopicAlias 29625,PropSubscriptionIdentifier 0,PropSharedSubscriptionAvailable 209,PropServerReference +// "\vG\165\&1\148\EM.\205\130\USV\158\132\251\187",PropMaximumQoS 91,PropRequestResponseInformation 123,PropTopicAlias +// 17527,PropServerReference +// "T\226\150\184\232\235\133\234\223\158\137\DLE\142\\\225\134\223\209\252\FSn\204]\177\249",PropMessageExpiryInterval +// 987,PropMaximumQoS 227,PropMaximumQoS 97,PropRetainAvailable 25,PropResponseInformation +// "\221\233[\240\SYN\187\242~\196\STX\136\165\198\&5(topic.data), 10); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_EQ(packet_id, 25416); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\240\218\212Wy", _pubPktID = 11258, -// _pubBody = "\212F\158\240\144\160AN", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "=\178\242\158\145\238\151\166;*4)", +// _pubPktID = 0, _pubBody = "s\252\179R\CANz\233E\191\b\150\SYN\142G\217\188\190\148z\234#\250\177\240\254m\219\SOH", +// _pubProps = [PropRequestProblemInformation 201,PropServerKeepAlive 21147,PropTopicAlias +// 25249,PropMessageExpiryInterval 11702,PropReceiveMaximum 5760,PropMessageExpiryInterval 638,PropAuthenticationData +// "\147\157\151\rj:\\\132\228^\228",PropAuthenticationMethod +// "\136\193\v0%\ESC\167\153_\US\238G\SOH\239\214\227\&4\132\221\181\177\162?\\",PropWildcardSubscriptionAvailable +// 210,PropCorrelationData "\FS\v\214",PropAuthenticationData "\214>?=\242{L\234h\ENQx \165v|\148\"v\173x\215\230 +// \249VF\142h}X",PropResponseTopic "\211\169\238n",PropSubscriptionIdentifier 24,PropServerKeepAlive +// 32603,PropMessageExpiryInterval 25708,PropRequestResponseInformation 57,PropResponseInformation +// "n\204\214\143\194\223\149(to\129",PropAuthenticationData +// "+\141q\161\DC1\228\160C\191[vZ:\212\137\150\190[\SUBv\204\&6d\f?y\am",PropMessageExpiryInterval 15130]} TEST(Publish5QCTest, Encode7) { - uint8_t pkt[] = {0x33, 0x12, 0x0, 0x5, 0xf0, 0xda, 0xd4, 0x57, 0x79, 0x2b, - 0xfa, 0x0, 0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; - uint8_t topic_bytes[] = {0xf0, 0xda, 0xd4, 0x57, 0x79}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0xd8, 0x1, 0x0, 0xc, 0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, 0x29, + 0xac, 0x1, 0x17, 0xc9, 0x13, 0x52, 0x9b, 0x23, 0x62, 0xa1, 0x2, 0x0, 0x0, 0x2d, 0xb6, 0x21, 0x16, + 0x80, 0x2, 0x0, 0x0, 0x2, 0x7e, 0x16, 0x0, 0xb, 0x93, 0x9d, 0x97, 0xd, 0x6a, 0x3a, 0x5c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lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, + 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 8; + msg.payload_len = 28; + + uint8_t bytesprops0[] = {0x93, 0x9d, 0x97, 0xd, 0x6a, 0x3a, 0x5c, 0x84, 0xe4, 0x5e, 0xe4}; + uint8_t bytesprops1[] = {0x88, 0xc1, 0xb, 0x30, 0x25, 0x1b, 0xa7, 0x99, 0x5f, 0x1f, 0xee, 0x47, + 0x1, 0xef, 0xd6, 0xe3, 0x34, 0x84, 0xdd, 0xb5, 0xb1, 0xa2, 0x3f, 0x5c}; + uint8_t bytesprops2[] = {0x1c, 0xb, 0xd6}; + uint8_t bytesprops3[] = {0xd6, 0x3e, 0x3f, 0x3d, 0xf2, 0x7b, 0x4c, 0xea, 0x68, 0x5, 0x78, 0x20, 0xa5, 0x76, 0x7c, + 0x94, 0x22, 0x76, 0xad, 0x78, 0xd7, 0xe6, 0x20, 0xf9, 0x56, 0x46, 0x8e, 0x68, 0x7d, 0x58}; + uint8_t bytesprops4[] = {0xd3, 0xa9, 0xee, 0x6e}; + uint8_t bytesprops5[] = {0x6e, 0xcc, 0xd6, 0x8f, 0xc2, 0xdf, 0x95, 0x28, 0x74, 0x6f, 0x81}; + uint8_t bytesprops6[] = {0x2b, 0x8d, 0x71, 0xa1, 0x11, 0xe4, 0xa0, 0x43, 0xbf, 0x5b, 0x76, 0x5a, 0x3a, 0xd4, + 0x89, 0x96, 0xbe, 0x5b, 0x1a, 0x76, 0xcc, 0x36, 0x64, 0xc, 0x3f, 0x79, 0x7, 0x6d}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21147}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25249}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11702}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5760}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 638}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32603}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25708}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15130}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 11258, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\240\218\212Wy", _pubPktID = 11258, -// _pubBody = "\212F\158\240\144\160AN", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "=\178\242\158\145\238\151\166;*4)", +// _pubPktID = 0, _pubBody = "s\252\179R\CANz\233E\191\b\150\SYN\142G\217\188\190\148z\234#\250\177\240\254m\219\SOH", +// _pubProps = [PropRequestProblemInformation 201,PropServerKeepAlive 21147,PropTopicAlias +// 25249,PropMessageExpiryInterval 11702,PropReceiveMaximum 5760,PropMessageExpiryInterval 638,PropAuthenticationData +// "\147\157\151\rj:\\\132\228^\228",PropAuthenticationMethod +// "\136\193\v0%\ESC\167\153_\US\238G\SOH\239\214\227\&4\132\221\181\177\162?\\",PropWildcardSubscriptionAvailable +// 210,PropCorrelationData "\FS\v\214",PropAuthenticationData "\214>?=\242{L\234h\ENQx \165v|\148\"v\173x\215\230 +// \249VF\142h}X",PropResponseTopic "\211\169\238n",PropSubscriptionIdentifier 24,PropServerKeepAlive +// 32603,PropMessageExpiryInterval 25708,PropRequestResponseInformation 57,PropResponseInformation +// "n\204\214\143\194\223\149(to\129",PropAuthenticationData +// "+\141q\161\DC1\228\160C\191[vZ:\212\137\150\190[\SUBv\204\&6d\f?y\am",PropMessageExpiryInterval 15130]} TEST(Publish5QCTest, Decode7) { - uint8_t pkt[] = {0x33, 0x12, 0x0, 0x5, 0xf0, 0xda, 0xd4, 0x57, 0x79, 0x2b, - 0xfa, 0x0, 0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; + uint8_t pkt[] = {0x30, 0xd8,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0x0, 0x3b, 0x1a, 0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, + 0x47, 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2511,110 +2571,45 @@ TEST(Publish5QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf0, 0xda, 0xd4, 0x57, 0x79}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd4, 0x46, 0x9e, 0xf0, 0x90, 0xa0, 0x41, 0x4e}; - lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, 0x29}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, + 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 11258); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 8); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\204s\226@u&7F!\EM\194o\133\175\187\203<\DC1;\239Q\RS\251\236J\167a\247\220", _pubPktID = 0, _pubBody = -// "\159(\138\244\237\128L\179\197a", _pubProps = [PropSubscriptionIdentifierAvailable 15,PropSessionExpiryInterval -// 22119,PropRetainAvailable 152,PropServerKeepAlive 26069,PropRequestResponseInformation 142,PropReceiveMaximum -// 4901,PropAssignedClientIdentifier -// "\145\&2B\192\177\230\ACK\US\157\197f$\209\239m\146\139R\183\159;$\231(\SI\158\185\144\135\191",PropAuthenticationMethod -// "\196\173q\132\199f|\DC1\218fj\224\195\&0\195{\150\190\226]\158\ESC@\146d\150\&4\130",PropContentType -// "t\135(\163",PropSubscriptionIdentifierAvailable 37,PropReceiveMaximum 6908,PropResponseTopic -// "\213#",PropUserProperty "K\190\162H\152\253\130>g\136\128\188" "\181i\180dT",PropUserProperty -// "\ETB\\l\148\&0\t\224\135\204\172\255V\US\133\187\235\&6q;\t\129\200l\252D\220^\160" -// "\EM\129\234\177\251\243\234\226\251\137jf\169d\246\254V\158\160\138Ohw\220\202^E'W",PropReasonString -// "\235\\\229\154\205\241\&3O\242\170\NAK+q\129\210\205\203\DC45\249\145<\181\206",PropWillDelayInterval -// 3396,PropTopicAlias 6285,PropAuthenticationMethod -// "\167\NAK\250x\146Nx\225\233\247%\197\t\245\221Mn}\158\168A2",PropAuthenticationMethod -// "\194\149\137\STX\166\bH\212e\184\142\222\158\158\194N\172\ETX^\SUBI\NUL\EM/\137",PropRetainAvailable 82]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\148\\\SUBg||N\DC41_\225\t\200Db_\163g\147\140\150]\254\216", _pubPktID = 0, _pubBody = "\130", _pubProps = +// [PropRequestProblemInformation 232]} TEST(Publish5QCTest, Encode8) { - uint8_t pkt[] = { - 0x31, 0xbb, 0x2, 0x0, 0x1d, 0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, 0x6f, 0x85, 0xaf, - 0xbb, 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, 0x61, 0xf7, 0xdc, 0x90, 0x2, 0x29, 0xf, - 0x11, 0x0, 0x0, 0x56, 0x67, 0x25, 0x98, 0x13, 0x65, 0xd5, 0x19, 0x8e, 0x21, 0x13, 0x25, 0x12, 0x0, 0x1e, 0x91, - 0x32, 0x42, 0xc0, 0xb1, 0xe6, 0x6, 0x1f, 0x9d, 0xc5, 0x66, 0x24, 0xd1, 0xef, 0x6d, 0x92, 0x8b, 0x52, 0xb7, 0x9f, - 0x3b, 0x24, 0xe7, 0x28, 0xf, 0x9e, 0xb9, 0x90, 0x87, 0xbf, 0x15, 0x0, 0x1c, 0xc4, 0xad, 0x71, 0x84, 0xc7, 0x66, - 0x7c, 0x11, 0xda, 0x66, 0x6a, 0xe0, 0xc3, 0x30, 0xc3, 0x7b, 0x96, 0xbe, 0xe2, 0x5d, 0x9e, 0x1b, 0x40, 0x92, 0x64, - 0x96, 0x34, 0x82, 0x3, 0x0, 0x4, 0x74, 0x87, 0x28, 0xa3, 0x29, 0x25, 0x21, 0x1a, 0xfc, 0x8, 0x0, 0x2, 0xd5, - 0x23, 0x26, 0x0, 0xc, 0x4b, 0xbe, 0xa2, 0x48, 0x98, 0xfd, 0x82, 0x3e, 0x67, 0x88, 0x80, 0xbc, 0x0, 0x5, 0xb5, - 0x69, 0xb4, 0x64, 0x54, 0x26, 0x0, 0x1c, 0x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0xec, 0x4a, 0xa7, 0x61, 0xf7, 0xdc}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x1e, 0x0, 0x18, 0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, + 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8, 0x2, 0x17, 0xe8, 0x82}; + uint8_t topic_bytes[] = {0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, + 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; + msg.retained = false; + uint8_t msg_bytes[] = {0x82}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; - - uint8_t bytesprops0[] = {0x91, 0x32, 0x42, 0xc0, 0xb1, 0xe6, 0x6, 0x1f, 0x9d, 0xc5, 0x66, 0x24, 0xd1, 0xef, 0x6d, - 0x92, 0x8b, 0x52, 0xb7, 0x9f, 0x3b, 0x24, 0xe7, 0x28, 0xf, 0x9e, 0xb9, 0x90, 0x87, 0xbf}; - uint8_t bytesprops1[] = {0xc4, 0xad, 0x71, 0x84, 0xc7, 0x66, 0x7c, 0x11, 0xda, 0x66, 0x6a, 0xe0, 0xc3, 0x30, - 0xc3, 0x7b, 0x96, 0xbe, 0xe2, 0x5d, 0x9e, 0x1b, 0x40, 0x92, 0x64, 0x96, 0x34, 0x82}; - uint8_t bytesprops2[] = {0x74, 0x87, 0x28, 0xa3}; - uint8_t bytesprops3[] = {0xd5, 0x23}; - uint8_t bytesprops5[] = {0xb5, 0x69, 0xb4, 0x64, 0x54}; - uint8_t bytesprops4[] = {0x4b, 0xbe, 0xa2, 0x48, 0x98, 0xfd, 0x82, 0x3e, 0x67, 0x88, 0x80, 0xbc}; - uint8_t bytesprops7[] = {0x19, 0x81, 0xea, 0xb1, 0xfb, 0xf3, 0xea, 0xe2, 0xfb, 0x89, 0x6a, 0x66, 0xa9, 0x64, 0xf6, - 0xfe, 0x56, 0x9e, 0xa0, 0x8a, 0x4f, 0x68, 0x77, 0xdc, 0xca, 0x5e, 0x45, 0x27, 0x57}; - uint8_t bytesprops6[] = {0x17, 0x5c, 0x6c, 0x94, 0x30, 0x9, 0xe0, 0x87, 0xcc, 0xac, 0xff, 0x56, 0x1f, 0x85, - 0xbb, 0xeb, 0x36, 0x71, 0x3b, 0x9, 0x81, 0xc8, 0x6c, 0xfc, 0x44, 0xdc, 0x5e, 0xa0}; - uint8_t bytesprops8[] = {0xeb, 0x5c, 0xe5, 0x9a, 0xcd, 0xf1, 0x33, 0x4f, 0xf2, 0xaa, 0x15, 0x2b, - 0x71, 0x81, 0xd2, 0xcd, 0xcb, 0x14, 0x35, 0xf9, 0x91, 0x3c, 0xb5, 0xce}; - uint8_t bytesprops9[] = {0xa7, 0x15, 0xfa, 0x78, 0x92, 0x4e, 0x78, 0xe1, 0xe9, 0xf7, 0x25, - 0xc5, 0x9, 0xf5, 0xdd, 0x4d, 0x6e, 0x7d, 0x9e, 0xa8, 0x41, 0x32}; - uint8_t bytesprops10[] = {0xc2, 0x95, 0x89, 0x2, 0xa6, 0x8, 0x48, 0xd4, 0x65, 0xb8, 0x8e, 0xde, 0x9e, - 0x9e, 0xc2, 0x4e, 0xac, 0x3, 0x5e, 0x1a, 0x49, 0x0, 0x19, 0x2f, 0x89}; + msg.payload_len = 1; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22119}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26069}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4901}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6908}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops4}, .v = {5, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops6}, .v = {29, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3396}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6285}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); @@ -2622,40 +2617,12 @@ TEST(Publish5QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\204s\226@u&7F!\EM\194o\133\175\187\203<\DC1;\239Q\RS\251\236J\167a\247\220", _pubPktID = 0, _pubBody = -// "\159(\138\244\237\128L\179\197a", _pubProps = [PropSubscriptionIdentifierAvailable 15,PropSessionExpiryInterval -// 22119,PropRetainAvailable 152,PropServerKeepAlive 26069,PropRequestResponseInformation 142,PropReceiveMaximum -// 4901,PropAssignedClientIdentifier -// "\145\&2B\192\177\230\ACK\US\157\197f$\209\239m\146\139R\183\159;$\231(\SI\158\185\144\135\191",PropAuthenticationMethod -// "\196\173q\132\199f|\DC1\218fj\224\195\&0\195{\150\190\226]\158\ESC@\146d\150\&4\130",PropContentType -// "t\135(\163",PropSubscriptionIdentifierAvailable 37,PropReceiveMaximum 6908,PropResponseTopic -// "\213#",PropUserProperty "K\190\162H\152\253\130>g\136\128\188" "\181i\180dT",PropUserProperty -// "\ETB\\l\148\&0\t\224\135\204\172\255V\US\133\187\235\&6q;\t\129\200l\252D\220^\160" -// "\EM\129\234\177\251\243\234\226\251\137jf\169d\246\254V\158\160\138Ohw\220\202^E'W",PropReasonString -// "\235\\\229\154\205\241\&3O\242\170\NAK+q\129\210\205\203\DC45\249\145<\181\206",PropWillDelayInterval -// 3396,PropTopicAlias 6285,PropAuthenticationMethod -// "\167\NAK\250x\146Nx\225\233\247%\197\t\245\221Mn}\158\168A2",PropAuthenticationMethod -// "\194\149\137\STX\166\bH\212e\184\142\222\158\158\194N\172\ETX^\SUBI\NUL\EM/\137",PropRetainAvailable 82]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\148\\\SUBg||N\DC41_\225\t\200Db_\163g\147\140\150]\254\216", _pubPktID = 0, _pubBody = "\130", _pubProps = +// [PropRequestProblemInformation 232]} TEST(Publish5QCTest, Decode8) { - uint8_t pkt[] = { - 0x31,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1d, 0x19, - 0x81, 0xea, 0xb1, 0xfb, 0xf3, 0xea, 0xe2, 0xfb, 0x89, 0x6a, 0x66, 0xa9, 0x64, 0xf6, 0xfe, 0x56, 0x9e, 0xa0, 0x8a, - 0x4f, 0x68, 0x77, 0xdc, 0xca, 0x5e, 0x45, 0x27, 0x57, 0x1f, 0x0, 0x18, 0xeb, 0x5c, 0xe5, 0x9a, 0xcd, 0xf1, 0x33, - 0x4f, 0xf2, 0xaa, 0x15, 0x2b, 0x71, 0x81, 0xd2, 0xcd, 0xcb, 0x14, 0x35, 0xf9, 0x91, 0x3c, 0xb5, 0xce, 0x18, 0x0, - 0x0, 0xd, 0x44, 0x23, 0x18, 0x8d, 0x15, 0x0, 0x16, 0xa7, 0x15, 0xfa, 0x78, 0x92, 0x4e, 0x78, 0xe1, 0xe9, 0xf7, - 0x25, 0xc5, 0x9, 0xf5, 0xdd, 0x4d, 0x6e, 0x7d, 0x9e, 0xa8, 0x41, 0x32, 0x15, 0x0, 0x19, 0xc2, 0x95, 0x89, 0x2, - 0xa6, 0x8, 0x48, 0xd4, 0x65, 0xb8, 0x8e, 0xde, 0x9e, 0x9e, 0xc2, 0x4e, 0xac, 0x3, 0x5e, 0x1a, 0x49, 0x0, 0x19, - 0x2f, 0x89, 0x25, 0x52, 0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; + uint8_t pkt[] = {0x30, 0x1e, 0x0, 0x18, 0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, + 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8, 0x2, 0x17, 0xe8, 0x82}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2663,76 +2630,140 @@ TEST(Publish5QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xcc, 0x73, 0xe2, 0x40, 0x75, 0x26, 0x37, 0x46, 0x21, 0x19, 0xc2, 0x6f, 0x85, 0xaf, 0xbb, - 0xcb, 0x3c, 0x11, 0x3b, 0xef, 0x51, 0x1e, 0xfb, 0xec, 0x4a, 0xa7, 0x61, 0xf7, 0xdc}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9f, 0x28, 0x8a, 0xf4, 0xed, 0x80, 0x4c, 0xb3, 0xc5, 0x61}; - lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, + 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x82}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "~\237S\145l\t\ACK0\CAN\236\137G!\FS~l\156\DC3\n>\135", _pubPktID = 0, _pubBody = -// "\NAK\255WE\SIQC\246\161\173\128\&6", _pubProps = [PropRetainAvailable 118,PropRequestResponseInformation -// 19,PropResponseInformation -// "b\240U45\182\253\195v\145\159\162\a\237\172\138\251\240\234J\203HA\184\&87\150\241\212",PropMessageExpiryInterval -// 6795]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\167a*\t\248\248\176\&7", _pubPktID +// = 3229, _pubBody = "q\NUL\185\ACK\181\209\244d\DC1\207\251\203\230\128\DC1A(\215\169\248\224\136EM\156.\EOT\f", +// _pubProps = [PropUserProperty "\171\178\180\177L\237\232\133" +// "\160\195\DLE\252\209\152\141p\DC2e\DC1\219\169",PropPayloadFormatIndicator 186,PropServerKeepAlive +// 22704,PropContentType "=\160\248h\156\&2\SOH\176S\176\145\NUL",PropUserProperty +// ":\ENQs\245\&6\252%}\133P!\201\213\155\179\215" +// "\162i\190\175\233]`\SOM,hBP\137\225\141\SUB\179)\180\229\183\154\233>\201\SYN\178",PropAssignedClientIdentifier +// "\153AI\128\142\&7\DC1\SIF]\189a\177\DC2\144{S\239)\240h\219\189\196\200\&4\238l",PropServerReference +// "\166\149\f_[\161\240\254\249\222\225\&2\EOT3\228+\140\144\218,\148\224\157h\181\248\207\213",PropTopicAlias +// 32605,PropTopicAliasMaximum 9453,PropResponseTopic +// "$\197\180\139\138\130\157\168PBR4\211\STXy\229\147\&9\253%\227\189\177\192",PropSubscriptionIdentifierAvailable +// 137,PropMessageExpiryInterval 31937,PropResponseInformation "\b",PropAssignedClientIdentifier +// "\196JG}\164\236Z\\\175\158o\160\169",PropWildcardSubscriptionAvailable 98,PropRequestResponseInformation +// 49,PropRequestProblemInformation 110]} TEST(Publish5QCTest, Encode9) { - uint8_t pkt[] = {0x31, 0x4d, 0x0, 0x15, 0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, 0x47, - 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87, 0x29, 0x25, 0x76, 0x19, 0x13, 0x1a, 0x0, - 0x1d, 0x62, 0xf0, 0x55, 0x34, 0x35, 0xb6, 0xfd, 0xc3, 0x76, 0x91, 0x9f, 0xa2, 0x7, 0xed, 0xac, - 0x8a, 0xfb, 0xf0, 0xea, 0x4a, 0xcb, 0x48, 0x41, 0xb8, 0x38, 0x37, 0x96, 0xf1, 0xd4, 0x2, 0x0, - 0x0, 0x1a, 0x8b, 0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; - uint8_t topic_bytes[] = {0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, - 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x89, 0x2, 0x0, 0x8, 0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37, 0xc, 0x9d, 0xdf, 0x1, + 0x26, 0x0, 0x8, 0xab, 0xb2, 0xb4, 0xb1, 0x4c, 0xed, 0xe8, 0x85, 0x0, 0xd, 0xa0, 0xc3, 0x10, 0xfc, + 0xd1, 0x98, 0x8d, 0x70, 0x12, 0x65, 0x11, 0xdb, 0xa9, 0x1, 0xba, 0x13, 0x58, 0xb0, 0x3, 0x0, 0xc, + 0x3d, 0xa0, 0xf8, 0x68, 0x9c, 0x32, 0x1, 0xb0, 0x53, 0xb0, 0x91, 0x0, 0x26, 0x0, 0x10, 0x3a, 0x5, + 0x73, 0xf5, 0x36, 0xfc, 0x25, 0x7d, 0x85, 0x50, 0x21, 0xc9, 0xd5, 0x9b, 0xb3, 0xd7, 0x0, 0x1c, 0xa2, + 0x69, 0xbe, 0xaf, 0xe9, 0x5d, 0x60, 0xe, 0x4d, 0x2c, 0x68,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}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, + 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; - - uint8_t bytesprops0[] = {0x62, 0xf0, 0x55, 0x34, 0x35, 0xb6, 0xfd, 0xc3, 0x76, 0x91, 0x9f, 0xa2, 0x7, 0xed, 0xac, - 0x8a, 0xfb, 0xf0, 0xea, 0x4a, 0xcb, 0x48, 0x41, 0xb8, 0x38, 0x37, 0x96, 0xf1, 0xd4}; + msg.payload_len = 28; + + uint8_t bytesprops1[] = {0xa0, 0xc3, 0x10, 0xfc, 0xd1, 0x98, 0x8d, 0x70, 0x12, 0x65, 0x11, 0xdb, 0xa9}; + uint8_t bytesprops0[] = {0xab, 0xb2, 0xb4, 0xb1, 0x4c, 0xed, 0xe8, 0x85}; + uint8_t bytesprops2[] = {0x3d, 0xa0, 0xf8, 0x68, 0x9c, 0x32, 0x1, 0xb0, 0x53, 0xb0, 0x91, 0x0}; + uint8_t bytesprops4[] = {0xa2, 0x69, 0xbe, 0xaf, 0xe9, 0x5d, 0x60, 0xe, 0x4d, 0x2c, 0x68, 0x42, 0x50, 0x89, + 0xe1, 0x8d, 0x1a, 0xb3, 0x29, 0xb4, 0xe5, 0xb7, 0x9a, 0xe9, 0x3e, 0xc9, 0x16, 0xb2}; + uint8_t bytesprops3[] = {0x3a, 0x5, 0x73, 0xf5, 0x36, 0xfc, 0x25, 0x7d, + 0x85, 0x50, 0x21, 0xc9, 0xd5, 0x9b, 0xb3, 0xd7}; + uint8_t bytesprops5[] = {0x99, 0x41, 0x49, 0x80, 0x8e, 0x37, 0x11, 0xf, 0x46, 0x5d, 0xbd, 0x61, 0xb1, 0x12, + 0x90, 0x7b, 0x53, 0xef, 0x29, 0xf0, 0x68, 0xdb, 0xbd, 0xc4, 0xc8, 0x34, 0xee, 0x6c}; + uint8_t bytesprops6[] = {0xa6, 0x95, 0xc, 0x5f, 0x5b, 0xa1, 0xf0, 0xfe, 0xf9, 0xde, 0xe1, 0x32, 0x4, 0x33, + 0xe4, 0x2b, 0x8c, 0x90, 0xda, 0x2c, 0x94, 0xe0, 0x9d, 0x68, 0xb5, 0xf8, 0xcf, 0xd5}; + uint8_t bytesprops7[] = {0x24, 0xc5, 0xb4, 0x8b, 0x8a, 0x82, 0x9d, 0xa8, 0x50, 0x42, 0x52, 0x34, + 0xd3, 0x2, 0x79, 0xe5, 0x93, 0x39, 0xfd, 0x25, 0xe3, 0xbd, 0xb1, 0xc0}; + uint8_t bytesprops8[] = {0x8}; + uint8_t bytesprops9[] = {0xc4, 0x4a, 0x47, 0x7d, 0xa4, 0xec, 0x5a, 0x5c, 0xaf, 0x9e, 0x6f, 0xa0, 0xa9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6795}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22704}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32605}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9453}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31937}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 3229, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "~\237S\145l\t\ACK0\CAN\236\137G!\FS~l\156\DC3\n>\135", _pubPktID = 0, _pubBody = -// "\NAK\255WE\SIQC\246\161\173\128\&6", _pubProps = [PropRetainAvailable 118,PropRequestResponseInformation -// 19,PropResponseInformation -// "b\240U45\182\253\195v\145\159\162\a\237\172\138\251\240\234J\203HA\184\&87\150\241\212",PropMessageExpiryInterval -// 6795]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\167a*\t\248\248\176\&7", _pubPktID +// = 3229, _pubBody = "q\NUL\185\ACK\181\209\244d\DC1\207\251\203\230\128\DC1A(\215\169\248\224\136EM\156.\EOT\f", +// _pubProps = [PropUserProperty "\171\178\180\177L\237\232\133" +// "\160\195\DLE\252\209\152\141p\DC2e\DC1\219\169",PropPayloadFormatIndicator 186,PropServerKeepAlive +// 22704,PropContentType "=\160\248h\156\&2\SOH\176S\176\145\NUL",PropUserProperty +// ":\ENQs\245\&6\252%}\133P!\201\213\155\179\215" +// "\162i\190\175\233]`\SOM,hBP\137\225\141\SUB\179)\180\229\183\154\233>\201\SYN\178",PropAssignedClientIdentifier +// "\153AI\128\142\&7\DC1\SIF]\189a\177\DC2\144{S\239)\240h\219\189\196\200\&4\238l",PropServerReference +// "\166\149\f_[\161\240\254\249\222\225\&2\EOT3\228+\140\144\218,\148\224\157h\181\248\207\213",PropTopicAlias +// 32605,PropTopicAliasMaximum 9453,PropResponseTopic +// "$\197\180\139\138\130\157\168PBR4\211\STXy\229\147\&9\253%\227\189\177\192",PropSubscriptionIdentifierAvailable +// 137,PropMessageExpiryInterval 31937,PropResponseInformation "\b",PropAssignedClientIdentifier +// "\196JG}\164\236Z\\\175\158o\160\169",PropWildcardSubscriptionAvailable 98,PropRequestResponseInformation +// 49,PropRequestProblemInformation 110]} TEST(Publish5QCTest, Decode9) { - uint8_t pkt[] = {0x31, 0x4d, 0x0, 0x15, 0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, 0x47, - 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87, 0x29, 0x25, 0x76, 0x19, 0x13, 0x1a, 0x0, - 0x1d, 0x62, 0xf0, 0x55, 0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, 0xee, 0x6c, 0x1c, 0x0, 0x1c, 0xa6, 0x95, 0xc, 0x5f, 0x5b, 0xa1, 0xf0, + 0xfe, 0xf9, 0xde, 0xe1, 0x32, 0x4, 0x33, 0xe4, 0x2b, 0x8c, 0x90, 0xda, 0x2c, 0x94, 0xe0, 0x9d, 0x68, + 0xb5, 0xf8, 0xcf, 0xd5, 0x23, 0x7f, 0x5d, 0x22, 0x24, 0xed, 0x8, 0x0, 0x18, 0x24, 0xc5, 0xb4, 0x8b, + 0x8a, 0x82, 0x9d, 0xa8, 0x50, 0x42, 0x52, 0x34, 0xd3, 0x2, 0x79, 0xe5, 0x93, 0x39, 0xfd, 0x25, 0xe3, + 0xbd, 0xb1, 0xc0, 0x29, 0x89, 0x2, 0x0, 0x0, 0x7c, 0xc1, 0x1a, 0x0, 0x1, 0x8, 0x12, 0x0, 0xd, + 0xc4, 0x4a, 0x47, 0x7d, 0xa4, 0xec, 0x5a, 0x5c, 0xaf, 0x9e, 0x6f, 0xa0, 0xa9, 0x28, 0x62, 0x19, 0x31, + 0x17, 0x6e, 0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, 0x11, + 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2740,128 +2771,135 @@ TEST(Publish5QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7e, 0xed, 0x53, 0x91, 0x6c, 0x9, 0x6, 0x30, 0x18, 0xec, 0x89, - 0x47, 0x21, 0x1c, 0x7e, 0x6c, 0x9c, 0x13, 0xa, 0x3e, 0x87}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x15, 0xff, 0x57, 0x45, 0xf, 0x51, 0x43, 0xf6, 0xa1, 0xad, 0x80, 0x36}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + uint8_t exp_topic_bytes[] = {0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, + 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 3229); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\168q\180\235Y\176\233\DC2z6\175%\SOH\200c&\131\DC2\134#\151\139\&2\ETX\130\DC4", _pubPktID = 2807, _pubBody = -// "`\EOT\158\236\t\225\128\235\197\172aw\173\147\&8\DC3\EOT\244+\249C)zO\156\191\199", _pubProps = [PropCorrelationData -// "\136\230\t\187\137\198\220",PropMaximumPacketSize 335,PropUserProperty "{\ESC\177\148e\157" -// "I&\137*\206Xi\190k_\247n\251\209w\210C\237e/S\195,\224\176\ESC",PropWildcardSubscriptionAvailable -// 90,PropReceiveMaximum 24643,PropServerReference "o\f\189",PropResponseTopic "\174O\SYNA,",PropRetainAvailable -// 70,PropWildcardSubscriptionAvailable 4,PropResponseInformation -// "\DC4\255y*:\\\234\&6\193]\216\147\155\175\246\224\233+\171",PropSessionExpiryInterval 8433,PropMaximumQoS -// 76,PropMessageExpiryInterval 29147,PropAuthenticationData "\218\250/\142\237\164\161\SO\180\DC3",PropUserProperty -// "\212\185" "\132\231D\242\154\DLE\248",PropSubscriptionIdentifier 9,PropAuthenticationData -// "u\217\159\174>\148\252\SI\\y\156P~\185p",PropMessageExpiryInterval 5756,PropSessionExpiryInterval 27296]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[Q\172\216\185:|\162\194", _pubPktID +// = 10305, _pubBody = "\238\134", _pubProps = [PropReceiveMaximum 10817,PropReceiveMaximum +// 24022,PropMessageExpiryInterval 23639,PropUserProperty "H\173\DC3" "\225\CAN|w\147\168K\247(} +// \132\196\t^L",PropMessageExpiryInterval 16643,PropWildcardSubscriptionAvailable 163,PropWillDelayInterval +// 22770,PropUserProperty "m1A\161\&5e\159-\215\178" +// "<\206L{\DEL\177M^m\142S\SYN\200\&2\158\DC2:\242",PropWillDelayInterval 28106,PropWildcardSubscriptionAvailable +// 221,PropTopicAliasMaximum 13801,PropSubscriptionIdentifier 11,PropWillDelayInterval 19944,PropMaximumQoS +// 186,PropWillDelayInterval 5955,PropSessionExpiryInterval 6777,PropSessionExpiryInterval 22897,PropTopicAlias +// 6180,PropRetainAvailable 93,PropResponseTopic +// "\177\232\138\239\152\219;\164\229C\151'\224\&7\251\199\204R/\SO\nu\142\158\SI\DC1%\231",PropSessionExpiryInterval +// 22932,PropUserProperty "\191p" "\195\DC2\240Y\184\ENQ\150\163\180\173\217\198\ACKa\149N\252\\/\v\170\218 +// ,\206\166",PropSharedSubscriptionAvailable 241,PropContentType "",PropReceiveMaximum 8513,PropRetainAvailable 77]} TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = { - 0x3a, 0xe1, 0x1, 0x0, 0x1a, 0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1, 0xc8, - 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14, 0xa, 0xf7, 0xa6, 0x1, 0x9, 0x0, 0x7, - 0x88, 0xe6, 0x9, 0xbb, 0x89, 0xc6, 0xdc, 0x27, 0x0, 0x0, 0x1, 0x4f, 0x26, 0x0, 0x6, 0x7b, 0x1b, 0xb1, 0x94, - 0x65, 0x9d, 0x0, 0x1a, 0x49, 0x26, 0x89, 0x2a, 0xce, 0x58, 0x69, 0xbe, 0x6b, 0x5f, 0xf7, 0x6e, 0xfb, 0xd1, 0x77, - 0xd2, 0x43, 0xed, 0x65, 0x2f, 0x53, 0xc3, 0x2c, 0xe0, 0xb0, 0x1b, 0x28, 0x5a, 0x21, 0x60, 0x43, 0x1c, 0x0, 0x3, - 0x6f, 0xc, 0xbd, 0x8, 0x0, 0x5, 0xae, 0x4f, 0x16, 0x41, 0x2c, 0x25, 0x46, 0x28, 0x4, 0x1a, 0x0, 0x13, 0x14, - 0xff, 0x79, 0x2a, 0x3a, 0x5c, 0xea, 0x36, 0xc1, 0x5d, 0xd8, 0x93, 0x9b, 0xaf, 0xf6, 0xe0, 0xe9, 0x2b, 0xab, 0x11, - 0x0, 0x0, 0x20, 0xf1, 0x24, 0x4c, 0x2, 0x0, 0x0, 0x71, 0xdb, 0x16, 0x0, 0xa, 0xda, 0xfa, 0x2f, 0x8e, 0xed, - 0xa4, 0xa1, 0xe, 0xb4, 0x13, 0x26, 0x0, 0x2, 0xd4, 0xb9, 0x0, 0x7, 0x84, 0xe7, 0x44, 0xf2, 0x9a, 0x10, 0xf8, - 0xb, 0x9, 0x16, 0x0, 0xf, 0x75, 0xd9, 0x9f, 0xae, 0x3e, 0x94, 0xfc, 0xf, 0x5c, 0x79, 0x9c, 0x50, 0x7e, 0xb9, - 0x70, 0x2, 0x0, 0x0, 0x16, 0x7c, 0x11, 0x0, 0x0, 0x6a, 0xa0, 0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, - 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; - uint8_t topic_bytes[] = {0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1, - 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0xd7, 0x1, 0x0, 0x9, 0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2, 0x28, 0x41, 0xc6, + 0x1, 0x21, 0x2a, 0x41, 0x21, 0x5d, 0xd6, 0x2, 0x0, 0x0, 0x5c, 0x57, 0x26, 0x0, 0x3, 0x48, 0xad, + 0x13, 0x0, 0x10, 0xe1, 0x18, 0x7c, 0x77, 0x93, 0xa8, 0x4b, 0xf7, 0x28, 0x7d, 0x20, 0x84, 0xc4, 0x9, + 0x5e, 0x4c, 0x2, 0x0, 0x0, 0x41, 0x3, 0x28, 0xa3, 0x18, 0x0, 0x0, 0x58, 0xf2, 0x26, 0x0, 0xa, + 0x6d, 0x31, 0x41, 0xa1, 0x35, 0x65, 0x9f, 0x2d, 0xd7, 0xb2, 0x0, 0x12, 0x3c, 0xce, 0x4c, 0x7b, 0x7f, + 0xb1, 0x4d, 0x5e, 0x6d, 0x8e, 0x53, 0x16, 0xc8, 0x32, 0x9e, 0x12, 0x3a, 0xf2, 0x18, 0x0, 0x0, 0x6d, + 0xca, 0x28, 0xdd, 0x22, 0x35, 0xe9, 0xb, 0xb, 0x18, 0x0, 0x0, 0x4d, 0xe8, 0x24, 0xba, 0x18, 0x0, + 0x0, 0x17, 0x43, 0x11, 0x0, 0x0, 0x1a, 0x79, 0x11, 0x0, 0x0, 0x59, 0x71, 0x23, 0x18, 0x24, 0x25, + 0x5d, 0x8, 0x0, 0x1c, 0xb1, 0xe8, 0x8a, 0xef, 0x98, 0xdb, 0x3b, 0xa4, 0xe5, 0x43, 0x97, 0x27, 0xe0, + 0x37, 0xfb, 0xc7, 0xcc, 0x52, 0x2f, 0xe, 0xa, 0x75, 0x8e, 0x9e, 0xf, 0x11, 0x25, 0xe7, 0x11, 0x0, + 0x0, 0x59, 0x94, 0x26, 0x0, 0x2, 0xbf, 0x70, 0x0, 0x1a, 0xc3, 0x12, 0xf0, 0x59, 0xb8, 0x5, 0x96, + 0xa3, 0xb4, 0xad, 0xd9, 0xc6, 0x6, 0x61, 0x95, 0x4e, 0xfc, 0x5c, 0x2f, 0xb, 0xaa, 0xda, 0x20, 0x2c, + 0xce, 0xa6, 0x2a, 0xf1, 0x3, 0x0, 0x0, 0x21, 0x21, 0x41, 0x25, 0x4d, 0xee, 0x86}; + uint8_t topic_bytes[] = {0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, - 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; + msg.retained = true; + uint8_t msg_bytes[] = {0xee, 0x86}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 2; - uint8_t bytesprops0[] = {0x88, 0xe6, 0x9, 0xbb, 0x89, 0xc6, 0xdc}; - uint8_t bytesprops2[] = {0x49, 0x26, 0x89, 0x2a, 0xce, 0x58, 0x69, 0xbe, 0x6b, 0x5f, 0xf7, 0x6e, 0xfb, - 0xd1, 0x77, 0xd2, 0x43, 0xed, 0x65, 0x2f, 0x53, 0xc3, 0x2c, 0xe0, 0xb0, 0x1b}; - uint8_t bytesprops1[] = {0x7b, 0x1b, 0xb1, 0x94, 0x65, 0x9d}; - uint8_t bytesprops3[] = {0x6f, 0xc, 0xbd}; - uint8_t bytesprops4[] = {0xae, 0x4f, 0x16, 0x41, 0x2c}; - uint8_t bytesprops5[] = {0x14, 0xff, 0x79, 0x2a, 0x3a, 0x5c, 0xea, 0x36, 0xc1, 0x5d, - 0xd8, 0x93, 0x9b, 0xaf, 0xf6, 0xe0, 0xe9, 0x2b, 0xab}; - uint8_t bytesprops6[] = {0xda, 0xfa, 0x2f, 0x8e, 0xed, 0xa4, 0xa1, 0xe, 0xb4, 0x13}; - uint8_t bytesprops8[] = {0x84, 0xe7, 0x44, 0xf2, 0x9a, 0x10, 0xf8}; - uint8_t bytesprops7[] = {0xd4, 0xb9}; - uint8_t bytesprops9[] = {0x75, 0xd9, 0x9f, 0xae, 0x3e, 0x94, 0xfc, 0xf, 0x5c, 0x79, 0x9c, 0x50, 0x7e, 0xb9, 0x70}; + uint8_t bytesprops1[] = {0xe1, 0x18, 0x7c, 0x77, 0x93, 0xa8, 0x4b, 0xf7, + 0x28, 0x7d, 0x20, 0x84, 0xc4, 0x9, 0x5e, 0x4c}; + uint8_t bytesprops0[] = {0x48, 0xad, 0x13}; + uint8_t bytesprops3[] = {0x3c, 0xce, 0x4c, 0x7b, 0x7f, 0xb1, 0x4d, 0x5e, 0x6d, + 0x8e, 0x53, 0x16, 0xc8, 0x32, 0x9e, 0x12, 0x3a, 0xf2}; + uint8_t bytesprops2[] = {0x6d, 0x31, 0x41, 0xa1, 0x35, 0x65, 0x9f, 0x2d, 0xd7, 0xb2}; + uint8_t bytesprops4[] = {0xb1, 0xe8, 0x8a, 0xef, 0x98, 0xdb, 0x3b, 0xa4, 0xe5, 0x43, 0x97, 0x27, 0xe0, 0x37, + 0xfb, 0xc7, 0xcc, 0x52, 0x2f, 0xe, 0xa, 0x75, 0x8e, 0x9e, 0xf, 0x11, 0x25, 0xe7}; + uint8_t bytesprops6[] = {0xc3, 0x12, 0xf0, 0x59, 0xb8, 0x5, 0x96, 0xa3, 0xb4, 0xad, 0xd9, 0xc6, 0x6, + 0x61, 0x95, 0x4e, 0xfc, 0x5c, 0x2f, 0xb, 0xaa, 0xda, 0x20, 0x2c, 0xce, 0xa6}; + uint8_t bytesprops5[] = {0xbf, 0x70}; + uint8_t bytesprops7[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 335}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {26, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24643}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8433}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29147}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops7}, .v = {7, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5756}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27296}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10817}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24022}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23639}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16643}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22770}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {18, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28106}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13801}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19944}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5955}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6777}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22897}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6180}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22932}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops5}, .v = {26, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8513}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 77}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2807, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10305, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\168q\180\235Y\176\233\DC2z6\175%\SOH\200c&\131\DC2\134#\151\139\&2\ETX\130\DC4", _pubPktID = 2807, _pubBody = -// "`\EOT\158\236\t\225\128\235\197\172aw\173\147\&8\DC3\EOT\244+\249C)zO\156\191\199", _pubProps = [PropCorrelationData -// "\136\230\t\187\137\198\220",PropMaximumPacketSize 335,PropUserProperty "{\ESC\177\148e\157" -// "I&\137*\206Xi\190k_\247n\251\209w\210C\237e/S\195,\224\176\ESC",PropWildcardSubscriptionAvailable -// 90,PropReceiveMaximum 24643,PropServerReference "o\f\189",PropResponseTopic "\174O\SYNA,",PropRetainAvailable -// 70,PropWildcardSubscriptionAvailable 4,PropResponseInformation -// "\DC4\255y*:\\\234\&6\193]\216\147\155\175\246\224\233+\171",PropSessionExpiryInterval 8433,PropMaximumQoS -// 76,PropMessageExpiryInterval 29147,PropAuthenticationData "\218\250/\142\237\164\161\SO\180\DC3",PropUserProperty -// "\212\185" "\132\231D\242\154\DLE\248",PropSubscriptionIdentifier 9,PropAuthenticationData -// "u\217\159\174>\148\252\SI\\y\156P~\185p",PropMessageExpiryInterval 5756,PropSessionExpiryInterval 27296]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[Q\172\216\185:|\162\194", _pubPktID +// = 10305, _pubBody = "\238\134", _pubProps = [PropReceiveMaximum 10817,PropReceiveMaximum +// 24022,PropMessageExpiryInterval 23639,PropUserProperty "H\173\DC3" "\225\CAN|w\147\168K\247(} +// \132\196\t^L",PropMessageExpiryInterval 16643,PropWildcardSubscriptionAvailable 163,PropWillDelayInterval +// 22770,PropUserProperty "m1A\161\&5e\159-\215\178" +// "<\206L{\DEL\177M^m\142S\SYN\200\&2\158\DC2:\242",PropWillDelayInterval 28106,PropWildcardSubscriptionAvailable +// 221,PropTopicAliasMaximum 13801,PropSubscriptionIdentifier 11,PropWillDelayInterval 19944,PropMaximumQoS +// 186,PropWillDelayInterval 5955,PropSessionExpiryInterval 6777,PropSessionExpiryInterval 22897,PropTopicAlias +// 6180,PropRetainAvailable 93,PropResponseTopic +// "\177\232\138\239\152\219;\164\229C\151'\224\&7\251\199\204R/\SO\nu\142\158\SI\DC1%\231",PropSessionExpiryInterval +// 22932,PropUserProperty "\191p" "\195\DC2\240Y\184\ENQ\150\163\180\173\217\198\ACKa\149N\252\\/\v\170\218 +// ,\206\166",PropSharedSubscriptionAvailable 241,PropContentType "",PropReceiveMaximum 8513,PropRetainAvailable 77]} TEST(Publish5QCTest, Decode10) { - uint8_t pkt[] = { - 0x3a, 0xe1, 0x1, 0x0, 0x1a, 0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1,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, 0x9e, 0xf, 0x11, 0x25, 0xe7, 0x11, 0x0, + 0x0, 0x59, 0x94, 0x26, 0x0, 0x2, 0xbf, 0x70, 0x0, 0x1a, 0xc3, 0x12, 0xf0, 0x59, 0xb8, 0x5, 0x96, + 0xa3, 0xb4, 0xad, 0xd9, 0xc6, 0x6, 0x61, 0x95, 0x4e, 0xfc, 0x5c, 0x2f, 0xb, 0xaa, 0xda, 0x20, 0x2c, + 0xce, 0xa6, 0x2a, 0xf1, 0x3, 0x0, 0x0, 0x21, 0x21, 0x41, 0x25, 0x4d, 0xee, 0x86}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2869,136 +2907,121 @@ TEST(Publish5QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa8, 0x71, 0xb4, 0xeb, 0x59, 0xb0, 0xe9, 0x12, 0x7a, 0x36, 0xaf, 0x25, 0x1, - 0xc8, 0x63, 0x26, 0x83, 0x12, 0x86, 0x23, 0x97, 0x8b, 0x32, 0x3, 0x82, 0x14}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x60, 0x4, 0x9e, 0xec, 0x9, 0xe1, 0x80, 0xeb, 0xc5, 0xac, 0x61, 0x77, 0xad, 0x93, - 0x38, 0x13, 0x4, 0xf4, 0x2b, 0xf9, 0x43, 0x29, 0x7a, 0x4f, 0x9c, 0xbf, 0xc7}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xee, 0x86}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2807); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 27); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10305); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\207\198\194\214\STX\139\&4_\212\172\NAKu:\233\181_\247\164\SUB", _pubPktID = 13284, _pubBody = -// "\154\166c\188;\235r\148\223\SYN\DEL", _pubProps = [PropRetainAvailable 21,PropSubscriptionIdentifier -// 31,PropReceiveMaximum 2517,PropServerKeepAlive 6414,PropResponseTopic -// "^\249\195\230\169\EM\192Y\DC4\182\188\253\197\198\132\132g\155u\227\SYN\230",PropAuthenticationData -// "\184\146\134G\DLE\SO\198sbit\220\245\201$\205V\174\212\DLE\169\214\145",PropMaximumQoS -// 155,PropSharedSubscriptionAvailable 149,PropContentType -// "\248\149\156\240\161PC\142\179N\201\219\225\a\229q\238\207\235",PropServerKeepAlive 9191,PropReasonString -// "\251\190\196B\191",PropServerKeepAlive 25660,PropWillDelayInterval 13246,PropCorrelationData -// "\208\216nK\n\"\164cO\154\CAN\189Q\146\216'\SYNHF\ENQ\133\166\207\207\174\182\DC2",PropWillDelayInterval -// 4856,PropServerKeepAlive 31311,PropSubscriptionIdentifier 4,PropWildcardSubscriptionAvailable -// 100,PropAuthenticationMethod "W\223\&5\204\212\216K\NAKz\148\231S;",PropSharedSubscriptionAvailable -// 94,PropResponseTopic "\216\198b\180\207\199\206\200\166\190\220\242\167\SUB\169\196st\138\255\234\193"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ESC\169\150\136?o\142\230\b", +// _pubPktID = 0, _pubBody = "\203\ENQ\254)\215\158R\255\SOH\SOHM8\245\234\222t\225\187\175", _pubProps = +// [PropSessionExpiryInterval 22238,PropAssignedClientIdentifier +// "\223\149\250\ETB\ETB\143\248\212\164\252\226\221\172\237\180\&1\255\219\198\140\182\224\253\210\b",PropSharedSubscriptionAvailable +// 194,PropContentType "8!",PropPayloadFormatIndicator 206,PropContentType +// "M\176\177\DC2\aN\210\NAK\207c\144\219\EMH[",PropResponseInformation "S",PropReceiveMaximum +// 24749,PropTopicAliasMaximum 10148,PropRetainAvailable 247,PropMaximumQoS 100,PropReceiveMaximum +// 2658,PropPayloadFormatIndicator 72,PropReceiveMaximum 18557,PropWillDelayInterval 16949,PropAssignedClientIdentifier +// "bz\192\140\235\209<\DLE\174\237P\184h",PropSessionExpiryInterval 3362,PropServerReference +// "T\178\147.\154\&4u\178\217\222\DLE\131\132\142a\DC4\224\158\215\224}\SYN\208\175p\203\240\240p'",PropSharedSubscriptionAvailable +// 250,PropTopicAliasMaximum 27083,PropMaximumQoS 140,PropTopicAliasMaximum 17705]} TEST(Publish5QCTest, Encode11) { - uint8_t pkt[] = {0x3c, 0xe3, 0x1, 0x0, 0x13, 0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, 0x15, 0x75, - 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a, 0x33, 0xe4, 0xbf, 0x1, 0x25, 0x15, 0xb, 0x1f, 0x21, 0x9, - 0xd5, 0x13, 0x19, 0xe, 0x8, 0x0, 0x16, 0x5e, 0xf9, 0xc3, 0xe6, 0xa9, 0x19, 0xc0, 0x59, 0x14, 0xb6, - 0xbc, 0xfd, 0xc5, 0xc6, 0x84, 0x84, 0x67, 0x9b, 0x75, 0xe3, 0x16, 0xe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, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0xb7, 0x1, 0x0, 0x9, 0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8, 0x97, 0x1, 0x11, + 0x0, 0x0, 0x56, 0xde, 0x12, 0x0, 0x19, 0xdf, 0x95, 0xfa, 0x17, 0x17, 0x8f, 0xf8, 0xd4, 0xa4, 0xfc, + 0xe2, 0xdd, 0xac, 0xed, 0xb4, 0x31, 0xff, 0xdb, 0xc6, 0x8c, 0xb6, 0xe0, 0xfd, 0xd2, 0x8, 0x2a, 0xc2, + 0x3, 0x0, 0x2, 0x38, 0x21, 0x1, 0xce, 0x3, 0x0, 0xf, 0x4d, 0xb0, 0xb1, 0x12, 0x7, 0x4e, 0xd2, + 0x15, 0xcf, 0x63, 0x90, 0xdb, 0x19, 0x48, 0x5b, 0x1a, 0x0, 0x1, 0x53, 0x21, 0x60, 0xad, 0x22, 0x27, + 0xa4, 0x25, 0xf7, 0x24, 0x64, 0x21, 0xa, 0x62, 0x1, 0x48, 0x21, 0x48, 0x7d, 0x18, 0x0, 0x0, 0x42, + 0x35, 0x12, 0x0, 0xd, 0x62, 0x7a, 0xc0, 0x8c, 0xeb, 0xd1, 0x3c, 0x10, 0xae, 0xed, 0x50, 0xb8, 0x68, + 0x11, 0x0, 0x0, 0xd, 0x22, 0x1c, 0x0, 0x1e, 0x54, 0xb2, 0x93, 0x2e, 0x9a, 0x34, 0x75, 0xb2, 0xd9, + 0xde, 0x10, 0x83, 0x84, 0x8e, 0x61, 0x14, 0xe0, 0x9e, 0xd7, 0xe0, 0x7d, 0x16, 0xd0, 0xaf, 0x70, 0xcb, + 0xf0, 0xf0, 0x70, 0x27, 0x2a, 0xfa, 0x22, 0x69, 0xcb, 0x24, 0x8c, 0x22, 0x45, 0x29, 0xcb, 0x5, 0xfe, + 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; + uint8_t topic_bytes[] = {0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xcb, 0x5, 0xfe, 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, + 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 19; - uint8_t bytesprops0[] = {0x5e, 0xf9, 0xc3, 0xe6, 0xa9, 0x19, 0xc0, 0x59, 0x14, 0xb6, 0xbc, - 0xfd, 0xc5, 0xc6, 0x84, 0x84, 0x67, 0x9b, 0x75, 0xe3, 0x16, 0xe6}; - uint8_t bytesprops1[] = {0xb8, 0x92, 0x86, 0x47, 0x10, 0xe, 0xc6, 0x73, 0x62, 0x69, 0x74, 0xdc, - 0xf5, 0xc9, 0x24, 0xcd, 0x56, 0xae, 0xd4, 0x10, 0xa9, 0xd6, 0x91}; - uint8_t bytesprops2[] = {0xf8, 0x95, 0x9c, 0xf0, 0xa1, 0x50, 0x43, 0x8e, 0xb3, 0x4e, - 0xc9, 0xdb, 0xe1, 0x7, 0xe5, 0x71, 0xee, 0xcf, 0xeb}; - uint8_t bytesprops3[] = {0xfb, 0xbe, 0xc4, 0x42, 0xbf}; - uint8_t bytesprops4[] = {0xd0, 0xd8, 0x6e, 0x4b, 0xa, 0x22, 0xa4, 0x63, 0x4f, 0x9a, 0x18, 0xbd, 0x51, 0x92, - 0xd8, 0x27, 0x16, 0x48, 0x46, 0x5, 0x85, 0xa6, 0xcf, 0xcf, 0xae, 0xb6, 0x12}; - uint8_t bytesprops5[] = {0x57, 0xdf, 0x35, 0xcc, 0xd4, 0xd8, 0x4b, 0x15, 0x7a, 0x94, 0xe7, 0x53, 0x3b}; - uint8_t bytesprops6[] = {0xd8, 0xc6, 0x62, 0xb4, 0xcf, 0xc7, 0xce, 0xc8, 0xa6, 0xbe, 0xdc, - 0xf2, 0xa7, 0x1a, 0xa9, 0xc4, 0x73, 0x74, 0x8a, 0xff, 0xea, 0xc1}; + uint8_t bytesprops0[] = {0xdf, 0x95, 0xfa, 0x17, 0x17, 0x8f, 0xf8, 0xd4, 0xa4, 0xfc, 0xe2, 0xdd, 0xac, + 0xed, 0xb4, 0x31, 0xff, 0xdb, 0xc6, 0x8c, 0xb6, 0xe0, 0xfd, 0xd2, 0x8}; + uint8_t bytesprops1[] = {0x38, 0x21}; + uint8_t bytesprops2[] = {0x4d, 0xb0, 0xb1, 0x12, 0x7, 0x4e, 0xd2, 0x15, 0xcf, 0x63, 0x90, 0xdb, 0x19, 0x48, 0x5b}; + uint8_t bytesprops3[] = {0x53}; + uint8_t bytesprops4[] = {0x62, 0x7a, 0xc0, 0x8c, 0xeb, 0xd1, 0x3c, 0x10, 0xae, 0xed, 0x50, 0xb8, 0x68}; + uint8_t bytesprops5[] = {0x54, 0xb2, 0x93, 0x2e, 0x9a, 0x34, 0x75, 0xb2, 0xd9, 0xde, 0x10, 0x83, 0x84, 0x8e, 0x61, + 0x14, 0xe0, 0x9e, 0xd7, 0xe0, 0x7d, 0x16, 0xd0, 0xaf, 0x70, 0xcb, 0xf0, 0xf0, 0x70, 0x27}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2517}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6414}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9191}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25660}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13246}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4856}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31311}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22238}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24749}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10148}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2658}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18557}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16949}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3362}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27083}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17705}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 13284, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\207\198\194\214\STX\139\&4_\212\172\NAKu:\233\181_\247\164\SUB", _pubPktID = 13284, _pubBody = -// "\154\166c\188;\235r\148\223\SYN\DEL", _pubProps = [PropRetainAvailable 21,PropSubscriptionIdentifier -// 31,PropReceiveMaximum 2517,PropServerKeepAlive 6414,PropResponseTopic -// "^\249\195\230\169\EM\192Y\DC4\182\188\253\197\198\132\132g\155u\227\SYN\230",PropAuthenticationData -// "\184\146\134G\DLE\SO\198sbit\220\245\201$\205V\174\212\DLE\169\214\145",PropMaximumQoS -// 155,PropSharedSubscriptionAvailable 149,PropContentType -// "\248\149\156\240\161PC\142\179N\201\219\225\a\229q\238\207\235",PropServerKeepAlive 9191,PropReasonString -// "\251\190\196B\191",PropServerKeepAlive 25660,PropWillDelayInterval 13246,PropCorrelationData -// "\208\216nK\n\"\164cO\154\CAN\189Q\146\216'\SYNHF\ENQ\133\166\207\207\174\182\DC2",PropWillDelayInterval -// 4856,PropServerKeepAlive 31311,PropSubscriptionIdentifier 4,PropWildcardSubscriptionAvailable -// 100,PropAuthenticationMethod "W\223\&5\204\212\216K\NAKz\148\231S;",PropSharedSubscriptionAvailable -// 94,PropResponseTopic "\216\198b\180\207\199\206\200\166\190\220\242\167\SUB\169\196st\138\255\234\193"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ESC\169\150\136?o\142\230\b", +// _pubPktID = 0, _pubBody = "\203\ENQ\254)\215\158R\255\SOH\SOHM8\245\234\222t\225\187\175", _pubProps = +// [PropSessionExpiryInterval 22238,PropAssignedClientIdentifier +// "\223\149\250\ETB\ETB\143\248\212\164\252\226\221\172\237\180\&1\255\219\198\140\182\224\253\210\b",PropSharedSubscriptionAvailable +// 194,PropContentType "8!",PropPayloadFormatIndicator 206,PropContentType +// "M\176\177\DC2\aN\210\NAK\207c\144\219\EMH[",PropResponseInformation "S",PropReceiveMaximum +// 24749,PropTopicAliasMaximum 10148,PropRetainAvailable 247,PropMaximumQoS 100,PropReceiveMaximum +// 2658,PropPayloadFormatIndicator 72,PropReceiveMaximum 18557,PropWillDelayInterval 16949,PropAssignedClientIdentifier +// "bz\192\140\235\209<\DLE\174\237P\184h",PropSessionExpiryInterval 3362,PropServerReference +// "T\178\147.\154\&4u\178\217\222\DLE\131\132\142a\DC4\224\158\215\224}\SYN\208\175p\203\240\240p'",PropSharedSubscriptionAvailable +// 250,PropTopicAliasMaximum 27083,PropMaximumQoS 140,PropTopicAliasMaximum 17705]} TEST(Publish5QCTest, Decode11) { - uint8_t pkt[] = {0x3c, 0xe3, 0x1, 0x0, 0x13, 0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, 0x15, 0x75, - 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a, 0x33, 0xe4, 0xbf, 0x1, 0x25, 0x15, 0xb, 0x1f, 0x21, 0x9, - 0xd5, 0x13, 0x19, 0xe, 0x8, 0x0, 0x16, 0x5e, 0xf9, 0xc3, 0xe6, 0xa9, 0x19, 0xc0, 0x59, 0x14, 0xb6, - 0xbc, 0xfd, 0xc5, 0xc6, 0x84, 0x84, 0x67, 0x9b, 0x75, 0xe3, 0x16, 0xe6, 0x16, 0x0, 0x17, 0xb8, 0x92, - 0x86, 0x47, 0x10, 0xe, 0xc6, 0x73, 0x62, 0x69, 0x74, 0xdc, 0xf5, 0xc9, 0x24, 0xcd, 0x56, 0xae, 0xd4, - 0x10, 0xa9, 0xd6, 0x91, 0x24, 0x9b, 0x2a, 0x95, 0x3, 0x0, 0x13, 0xf8, 0x95, 0x9c, 0xf0, 0xa1, 0x50, - 0x43, 0x8e, 0xb3, 0x4e, 0xc9, 0xdb, 0xe1, 0x7, 0xe5, 0x71, 0xee, 0xcf, 0xeb, 0x13, 0x23, 0xe7, 0x1f, - 0x0, 0x5, 0xfb, 0xbe, 0xc4, 0x42, 0xbf, 0x13, 0x64, 0x3c, 0x18, 0x0, 0x0, 0x33, 0xbe, 0x9, 0x0, - 0x1b, 0xd0, 0xd8, 0x6e, 0x4b, 0xa, 0x22, 0xa4, 0x63, 0x4f, 0x9a, 0x18, 0xbd, 0x51, 0x92, 0xd8, 0x27, - 0x16, 0x48, 0x46, 0x5, 0x85, 0xa6, 0xcf, 0xcf, 0xae, 0xb6, 0x12, 0x18, 0x0, 0x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x0, 0x0, 0xd, 0x22, 0x1c, 0x0, 0x1e, 0x54, 0xb2, 0x93, 0x2e, 0x9a, 0x34, 0x75, 0xb2, 0xd9, + 0xde, 0x10, 0x83, 0x84, 0x8e, 0x61, 0x14, 0xe0, 0x9e, 0xd7, 0xe0, 0x7d, 0x16, 0xd0, 0xaf, 0x70, 0xcb, + 0xf0, 0xf0, 0x70, 0x27, 0x2a, 0xfa, 0x22, 0x69, 0xcb, 0x24, 0x8c, 0x22, 0x45, 0x29, 0xcb, 0x5, 0xfe, + 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3006,145 +3029,95 @@ TEST(Publish5QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xcf, 0xc6, 0xc2, 0xd6, 0x2, 0x8b, 0x34, 0x5f, 0xd4, 0xac, - 0x15, 0x75, 0x3a, 0xe9, 0xb5, 0x5f, 0xf7, 0xa4, 0x1a}; - lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9a, 0xa6, 0x63, 0xbc, 0x3b, 0xeb, 0x72, 0x94, 0xdf, 0x16, 0x7f}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 13284); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + uint8_t exp_topic_bytes[] = {0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcb, 0x5, 0xfe, 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, + 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\159\US\147\DC3i\FS\CAN@\178\DC2\202\145>\185\195\148\f3@ \SOH\202\166\182\STX\v\130\SYN", _pubPktID = 25675, -// _pubBody = "\138\158G\154\229\140)?>\221\211<\190", _pubProps = [PropReasonString -// "C\179\185>\185\233>\221\ETB\210\ESC1\191\222\\t34\204\243\130\DLE\ETB1\179\164\168X",PropMessageExpiryInterval -// 21252,PropRequestProblemInformation 18,PropWildcardSubscriptionAvailable 23,PropTopicAlias 2791,PropCorrelationData -// "\195Q\228\179\197%\222\222\ESC#^\237kK\168",PropSubscriptionIdentifierAvailable 244,PropServerReference -// "G[\234\142T\228\212",PropResponseTopic "Ae\168\145\b",PropWillDelayInterval 30687,PropAssignedClientIdentifier -// "o\NUL\156i\191o\US\240\162\EM\EMN\241\&02c\244-\143/\225",PropWillDelayInterval +// 3283,PropRetainAvailable 193,PropServerReference "\b\147\130\231\SI\200&\v.2T\164T\176\186\GS",PropMaximumQoS 109]} TEST(Publish5QCTest, Encode12) { - uint8_t pkt[] = { - 0x3d, 0x84, 0x2, 0x0, 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xa8, 0x6c, 0xf7, 0xb6, 0x8a, 0xdc, 0x69, 0x8d, 0x7b, 0xd0, 0xdf, 0x2, 0x0, 0x0, 0x18, 0x2d, 0x13, - 0x6, 0xb0, 0x22, 0x21, 0xe0, 0x1, 0x3e, 0x28, 0x5a, 0x16, 0x0, 0xc, 0x32, 0x20, 0x56, 0x11, 0xbd, 0x27, 0x77, - 0x85, 0xb7, 0x16, 0x67, 0xe, 0x25, 0xd7, 0x27, 0x0, 0x0, 0x4a, 0x8e, 0x26, 0x0, 0x5, 0xbd, 0x6c, 0xd0, 0x48, - 0x77, 0x0, 0x0, 0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; - uint8_t topic_bytes[] = {0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, 0x3e, 0xb9, - 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x7a, 0x0, 0x1a, 0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, + 0x86, 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c, 0x41, 0x8f, + 0x5b, 0x13, 0x6b, 0xc, 0x21, 0x65, 0x90, 0x19, 0xc2, 0x2, 0x0, 0x0, 0x2f, 0xc3, 0x2, 0x0, + 0x0, 0xd, 0x76, 0x23, 0x3f, 0x93, 0x1c, 0x0, 0x7, 0x52, 0xef, 0x1d, 0x1c, 0xb9, 0xa7, 0x28, + 0x22, 0x7d, 0x9c, 0x1a, 0x0, 0x1a, 0x13, 0xd9, 0x85, 0x23, 0x6, 0x61, 0x82, 0x3e, 0x69, 0xbf, + 0x6f, 0x1f, 0xf0, 0xa2, 0x19, 0x19, 0x4e, 0xf1, 0x30, 0x32, 0x63, 0xf4, 0x2d, 0x8f, 0x2f, 0xe1, + 0x18, 0x0, 0x0, 0xc, 0xd3, 0x25, 0xc1, 0x1c, 0x0, 0x10, 0x8, 0x93, 0x82, 0xe7, 0xf, 0xc8, + 0x26, 0xb, 0x2e, 0x32, 0x54, 0xa4, 0x54, 0xb0, 0xba, 0x1d, 0x24, 0x6d}; + uint8_t topic_bytes[] = {0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, 0x86, + 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; - - uint8_t bytesprops0[] = {0x43, 0xb3, 0xb9, 0x3e, 0xb9, 0xe9, 0x3e, 0xdd, 0x17, 0xd2, 0x1b, 0x31, 0xbf, 0xde, - 0x5c, 0x74, 0x33, 0x34, 0xcc, 0xf3, 0x82, 0x10, 0x17, 0x31, 0xb3, 0xa4, 0xa8, 0x58}; - uint8_t bytesprops1[] = {0xc3, 0x51, 0xe4, 0xb3, 0xc5, 0x25, 0xde, 0xde, 0x1b, 0x23, 0x5e, 0xed, 0x6b, 0x4b, 0xa8}; - uint8_t bytesprops2[] = {0x47, 0x5b, 0xea, 0x8e, 0x54, 0xe4, 0xd4}; - uint8_t bytesprops3[] = {0x41, 0x65, 0xa8, 0x91, 0x8}; - uint8_t bytesprops4[] = {0x6f, 0x0, 0x9c, 0x3c, 0x42, 0xe3, 0xe1, 0x89, - 0xbf, 0xf8, 0xe1, 0x51, 0x39, 0xd, 0xee, 0x19}; - uint8_t bytesprops5[] = {0x5b, 0x22}; - uint8_t bytesprops6[] = {0x84, 0x17, 0x8e, 0x67, 0x21, 0xda, 0x55, 0x10, 0xe6, 0xa1, 0x9d, 0xa6, 0x68, 0x11, - 0x37, 0xf0, 0xbf, 0x3d, 0xd8, 0x11, 0x7, 0x87, 0xf0, 0x52, 0xa, 0xc9, 0x86, 0xe}; - uint8_t bytesprops7[] = {0x85, 0x8e, 0xe, 0x4f, 0xe, 0x48, 0x83, 0x26, 0xfc, 0xa8, - 0x6c, 0xf7, 0xb6, 0x8a, 0xdc, 0x69, 0x8d, 0x7b, 0xd0, 0xdf}; - uint8_t bytesprops8[] = {0x32, 0x20, 0x56, 0x11, 0xbd, 0x27, 0x77, 0x85, 0xb7, 0x16, 0x67, 0xe}; - uint8_t bytesprops10[] = {0}; - uint8_t bytesprops9[] = {0xbd, 0x6c, 0xd0, 0x48, 0x77}; + msg.payload_len = 0; + + uint8_t bytesprops0[] = {0x52, 0xef, 0x1d, 0x1c, 0xb9, 0xa7, 0x28}; + uint8_t bytesprops1[] = {0x13, 0xd9, 0x85, 0x23, 0x6, 0x61, 0x82, 0x3e, 0x69, 0xbf, 0x6f, 0x1f, 0xf0, + 0xa2, 0x19, 0x19, 0x4e, 0xf1, 0x30, 0x32, 0x63, 0xf4, 0x2d, 0x8f, 0x2f, 0xe1}; + uint8_t bytesprops2[] = {0x8, 0x93, 0x82, 0xe7, 0xf, 0xc8, 0x26, 0xb, 0x2e, 0x32, 0x54, 0xa4, 0x54, 0xb0, 0xba, 0x1d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21252}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2791}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30687}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6189}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1712}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8672}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19086}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops9}, .v = {0, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27404}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26000}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12227}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3446}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16275}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32156}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3283}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 109}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25675, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16783, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\159\US\147\DC3i\FS\CAN@\178\DC2\202\145>\185\195\148\f3@ \SOH\202\166\182\STX\v\130\SYN", _pubPktID = 25675, -// _pubBody = "\138\158G\154\229\140)?>\221\211<\190", _pubProps = [PropReasonString -// "C\179\185>\185\233>\221\ETB\210\ESC1\191\222\\t34\204\243\130\DLE\ETB1\179\164\168X",PropMessageExpiryInterval -// 21252,PropRequestProblemInformation 18,PropWildcardSubscriptionAvailable 23,PropTopicAlias 2791,PropCorrelationData -// "\195Q\228\179\197%\222\222\ESC#^\237kK\168",PropSubscriptionIdentifierAvailable 244,PropServerReference -// "G[\234\142T\228\212",PropResponseTopic "Ae\168\145\b",PropWillDelayInterval 30687,PropAssignedClientIdentifier -// "o\NUL\156i\191o\US\240\162\EM\EMN\241\&02c\244-\143/\225",PropWillDelayInterval +// 3283,PropRetainAvailable 193,PropServerReference "\b\147\130\231\SI\200&\v.2T\164T\176\186\GS",PropMaximumQoS 109]} TEST(Publish5QCTest, Decode12) { - uint8_t pkt[] = { - 0x3d, 0x84, 0x2, 0x0, 0x1c, 0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, 0x3e, 0xb9, - 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16, 0x64, 0x4b, 0xd5, 0x1, 0x1f, - 0x0, 0x1c, 0x43, 0xb3, 0xb9, 0x3e, 0xb9, 0xe9, 0x3e, 0xdd, 0x17, 0xd2, 0x1b, 0x31, 0xbf, 0xde, 0x5c, 0x74, 0x33, - 0x34, 0xcc, 0xf3, 0x82, 0x10, 0x17, 0x31, 0xb3, 0xa4, 0xa8, 0x58, 0x2, 0x0, 0x0, 0x53, 0x4, 0x17, 0x12, 0x28, - 0x17, 0x23, 0xa, 0xe7, 0x9, 0x0, 0xf, 0xc3, 0x51, 0xe4, 0xb3, 0xc5, 0x25, 0xde, 0xde, 0x1b, 0x23, 0x5e, 0xed, - 0x6b, 0x4b, 0xa8, 0x29, 0xf4, 0x1c, 0x0, 0x7, 0x47, 0x5b, 0xea, 0x8e, 0x54, 0xe4, 0xd4, 0x8, 0x0, 0x5, 0x41, - 0x65, 0xa8, 0x91, 0x8, 0x18, 0x0, 0x0, 0x77, 0xdf, 0x12, 0x0, 0x10, 0x6f, 0x0, 0x9c, 0x3c, 0x42, 0xe3, 0xe1, - 0x89, 0xbf, 0xf8, 0xe1, 0x51, 0x39, 0xd, 0xee, 0x19, 0x8, 0x0, 0x2, 0x5b, 0x22, 0x2a, 0x93, 0x16, 0x0, 0x1c,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, 0x23, 0x6, 0x61, 0x82, 0x3e, 0x69, 0xbf, + 0x6f, 0x1f, 0xf0, 0xa2, 0x19, 0x19, 0x4e, 0xf1, 0x30, 0x32, 0x63, 0xf4, 0x2d, 0x8f, 0x2f, 0xe1, + 0x18, 0x0, 0x0, 0xc, 0xd3, 0x25, 0xc1, 0x1c, 0x0, 0x10, 0x8, 0x93, 0x82, 0xe7, 0xf, 0xc8, + 0x26, 0xb, 0x2e, 0x32, 0x54, 0xa4, 0x54, 0xb0, 0xba, 0x1d, 0x24, 0x6d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3152,66 +3125,112 @@ TEST(Publish5QCTest, Decode12) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9f, 0x1f, 0x93, 0x13, 0x69, 0x1c, 0x18, 0x40, 0xb2, 0x12, 0xca, 0x91, 0x3e, 0xb9, - 0xc3, 0x94, 0xc, 0x33, 0x40, 0x20, 0x1, 0xca, 0xa6, 0xb6, 0x2, 0xb, 0x82, 0x16}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8a, 0x9e, 0x47, 0x9a, 0xe5, 0x8c, 0x29, 0x3f, 0x3e, 0xdd, 0xd3, 0x3c, 0xbe}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, 0x86, + 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 25675); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 13); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 16783); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\185\246\SOH*\248(\178k\\\215\174", -// _pubPktID = 11115, _pubBody = ".\DC1\fEQhj\183\224@\215\"\231B\243L\206 \210\231\178", _pubProps = -// [PropTopicAliasMaximum 12234,PropServerKeepAlive 26536,PropWildcardSubscriptionAvailable -// 235,PropWildcardSubscriptionAvailable 3,PropSubscriptionIdentifier 21]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// ";V\193\141}\175x\217i^\231g\247\v\203\183_\151\EM\\", _pubPktID = 0, _pubBody = +// "\162\166\173\187\NAK){\138\210Q^p+\SI\145Q\165\GS\166\249CG", _pubProps = [PropResponseTopic +// "\DC1",PropAssignedClientIdentifier "\241\167*\EM\224*\174z\a\192\192\236_\177G\STX+\224\213/\SI",PropServerReference +// ">\191\&29\210.y\158\162\248b\185\171\255\SUBs\SI\167\243\142\&0@\210\DC1\214\132\SYNl`",PropMessageExpiryInterval +// 19534,PropTopicAliasMaximum 1048,PropCorrelationData +// "\190\248P&\175Y\199\166yC\188\237\252\&7Q2\215d",PropPayloadFormatIndicator 150,PropRequestProblemInformation +// 178,PropWildcardSubscriptionAvailable 154,PropWildcardSubscriptionAvailable 38,PropTopicAlias +// 4361,PropWillDelayInterval 18009,PropMaximumQoS 185,PropAuthenticationMethod +// ",\172\253\251\160\243",PropSessionExpiryInterval 23756]} TEST(Publish5QCTest, Encode13) { - uint8_t pkt[] = {0x32, 0x31, 0x0, 0xb, 0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, - 0xd7, 0xae, 0x2b, 0x6b, 0xc, 0x22, 0x2f, 0xca, 0x13, 0x67, 0xa8, 0x28, 0xeb, - 0x28, 0x3, 0xb, 0x15, 0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, - 0x40, 0xd7, 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; - uint8_t topic_bytes[] = {0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, 0xd7, 0xae}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0xa6, 0x1, 0x0, 0x14, 0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, 0xe7, 0x67, + 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c, 0x79, 0x8, 0x0, 0x1, 0x11, 0x12, 0x0, 0x15, 0xf1, + 0xa7, 0x2a, 0x19, 0xe0, 0x2a, 0xae, 0x7a, 0x7, 0xc0, 0xc0, 0xec, 0x5f, 0xb1, 0x47, 0x2, 0x2b, 0xe0, + 0xd5, 0x2f, 0xf, 0x1c, 0x0, 0x1d, 0x3e, 0xbf, 0x32, 0x39, 0xd2, 0x2e, 0x79, 0x9e, 0xa2, 0xf8, 0x62, + 0xb9, 0xab, 0xff, 0x1a, 0x73, 0xf, 0xa7, 0xf3, 0x8e, 0x30, 0x40, 0xd2, 0x11, 0xd6, 0x84, 0x16, 0x6c, + 0x60, 0x2, 0x0, 0x0, 0x4c, 0x4e, 0x22, 0x4, 0x18, 0x9, 0x0, 0x12, 0xbe, 0xf8, 0x50, 0x26, 0xaf, + 0x59, 0xc7, 0xa6, 0x79, 0x43, 0xbc, 0xed, 0xfc, 0x37, 0x51, 0x32, 0xd7, 0x64, 0x1, 0x96, 0x17, 0xb2, + 0x28, 0x9a, 0x28, 0x26, 0x23, 0x11, 0x9, 0x18, 0x0, 0x0, 0x46, 0x59, 0x24, 0xb9, 0x15, 0x0, 0x6, + 0x2c, 0xac, 0xfd, 0xfb, 0xa0, 0xf3, 0x11, 0x0, 0x0, 0x5c, 0xcc, 0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, + 0x7b, 0x8a, 0xd2, 0x51, 0x5e, 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; + uint8_t topic_bytes[] = {0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, + 0xe7, 0x67, 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, 0x40, 0xd7, - 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, 0xd2, 0x51, 0x5e, + 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 22; + + uint8_t bytesprops0[] = {0x11}; + uint8_t bytesprops1[] = {0xf1, 0xa7, 0x2a, 0x19, 0xe0, 0x2a, 0xae, 0x7a, 0x7, 0xc0, 0xc0, + 0xec, 0x5f, 0xb1, 0x47, 0x2, 0x2b, 0xe0, 0xd5, 0x2f, 0xf}; + uint8_t bytesprops2[] = {0x3e, 0xbf, 0x32, 0x39, 0xd2, 0x2e, 0x79, 0x9e, 0xa2, 0xf8, 0x62, 0xb9, 0xab, 0xff, 0x1a, + 0x73, 0xf, 0xa7, 0xf3, 0x8e, 0x30, 0x40, 0xd2, 0x11, 0xd6, 0x84, 0x16, 0x6c, 0x60}; + uint8_t bytesprops3[] = {0xbe, 0xf8, 0x50, 0x26, 0xaf, 0x59, 0xc7, 0xa6, 0x79, + 0x43, 0xbc, 0xed, 0xfc, 0x37, 0x51, 0x32, 0xd7, 0x64}; + uint8_t bytesprops4[] = {0x2c, 0xac, 0xfd, 0xfb, 0xa0, 0xf3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12234}}, {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26536}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 235}}, {.prop = (lwmqtt_prop_t)40, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19534}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1048}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4361}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18009}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23756}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 11115, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\185\246\SOH*\248(\178k\\\215\174", -// _pubPktID = 11115, _pubBody = ".\DC1\fEQhj\183\224@\215\"\231B\243L\206 \210\231\178", _pubProps = -// [PropTopicAliasMaximum 12234,PropServerKeepAlive 26536,PropWildcardSubscriptionAvailable -// 235,PropWildcardSubscriptionAvailable 3,PropSubscriptionIdentifier 21]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// ";V\193\141}\175x\217i^\231g\247\v\203\183_\151\EM\\", _pubPktID = 0, _pubBody = +// "\162\166\173\187\NAK){\138\210Q^p+\SI\145Q\165\GS\166\249CG", _pubProps = [PropResponseTopic +// "\DC1",PropAssignedClientIdentifier "\241\167*\EM\224*\174z\a\192\192\236_\177G\STX+\224\213/\SI",PropServerReference +// ">\191\&29\210.y\158\162\248b\185\171\255\SUBs\SI\167\243\142\&0@\210\DC1\214\132\SYNl`",PropMessageExpiryInterval +// 19534,PropTopicAliasMaximum 1048,PropCorrelationData +// "\190\248P&\175Y\199\166yC\188\237\252\&7Q2\215d",PropPayloadFormatIndicator 150,PropRequestProblemInformation +// 178,PropWildcardSubscriptionAvailable 154,PropWildcardSubscriptionAvailable 38,PropTopicAlias +// 4361,PropWillDelayInterval 18009,PropMaximumQoS 185,PropAuthenticationMethod +// ",\172\253\251\160\243",PropSessionExpiryInterval 23756]} TEST(Publish5QCTest, Decode13) { - uint8_t pkt[] = {0x32, 0x31, 0x0, 0xb, 0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, - 0xd7, 0xae, 0x2b, 0x6b, 0xc, 0x22, 0x2f, 0xca, 0x13, 0x67, 0xa8, 0x28, 0xeb, - 0x28, 0x3, 0xb, 0x15, 0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, - 0x40, 0xd7, 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; + uint8_t pkt[] = {0x31, 0xa6, 0x1, 0x0, 0x14, 0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, 0xe7, 0x67, + 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c, 0x79, 0x8, 0x0, 0x1, 0x11, 0x12, 0x0, 0x15, 0xf1, + 0xa7, 0x2a, 0x19, 0xe0, 0x2a, 0xae, 0x7a, 0x7, 0xc0, 0xc0, 0xec, 0x5f, 0xb1, 0x47, 0x2, 0x2b, 0xe0, + 0xd5, 0x2f, 0xf, 0x1c, 0x0, 0x1d, 0x3e, 0xbf, 0x32, 0x39, 0xd2, 0x2e, 0x79, 0x9e, 0xa2, 0xf8, 0x62, + 0xb9, 0xab, 0xff, 0x1a, 0x73, 0xf, 0xa7, 0xf3, 0x8e, 0x30, 0x40, 0xd2, 0x11, 0xd6, 0x84, 0x16, 0x6c, + 0x60, 0x2, 0x0, 0x0, 0x4c, 0x4e, 0x22, 0x4, 0x18, 0x9, 0x0, 0x12, 0xbe, 0xf8, 0x50, 0x26, 0xaf, + 0x59, 0xc7, 0xa6, 0x79, 0x43, 0xbc, 0xed, 0xfc, 0x37, 0x51, 0x32, 0xd7, 0x64, 0x1, 0x96, 0x17, 0xb2, + 0x28, 0x9a, 0x28, 0x26, 0x23, 0x11, 0x9, 0x18, 0x0, 0x0, 0x46, 0x59, 0x24, 0xb9, 0x15, 0x0, 0x6, + 0x2c, 0xac, 0xfd, 0xfb, 0xa0, 0xf3, 0x11, 0x0, 0x0, 0x5c, 0xcc, 0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, + 0x7b, 0x8a, 0xd2, 0x51, 0x5e, 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3219,122 +3238,163 @@ TEST(Publish5QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb9, 0xf6, 0x1, 0x2a, 0xf8, 0x28, 0xb2, 0x6b, 0x5c, 0xd7, 0xae}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2e, 0x11, 0xc, 0x45, 0x51, 0x68, 0x6a, 0xb7, 0xe0, 0x40, 0xd7, - 0x22, 0xe7, 0x42, 0xf3, 0x4c, 0xce, 0x20, 0xd2, 0xe7, 0xb2}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, + 0xe7, 0x67, 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, 0xd2, 0x51, 0x5e, + 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 11115); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\186\171$\215\213", _pubPktID = -// 24590, _pubBody = "En.&\166\184\215\153", _pubProps = [PropSubscriptionIdentifier 22,PropReceiveMaximum -// 18265,PropContentType "\139]D_a&\176\214\131\207\205\219\SUBf\a=8\213\134\227",PropTopicAlias 25478,PropResponseTopic -// "\DEL+\SUB \185\244\146K\147J\168s\\\220\142\&7@-i\161\160\151.\148;J",PropReceiveMaximum 22318,PropTopicAliasMaximum -// 20907,PropPayloadFormatIndicator 158,PropTopicAlias 25235,PropSharedSubscriptionAvailable 149,PropReasonString -// "+E\197\223\235\RS\234e,S\NUL\247U,J\240yR",PropUserProperty -// "4-\152'\221\247\253?&\a?\r\224\NAK\222\254\137\NUL\ETX\216`h\EOT" -// "\175\&6\240\&2\240,\186\137\204?\133\201\255\169\219\GS2VM\ETB\204%\160\150b\180",PropAssignedClientIdentifier -// "\223\135\244\158\174\162F\232\205\CANE\199\ACK\SUB\STXF\216\235=#)&\182\221",PropMessageExpiryInterval -// 18609,PropReasonString "F\EOT\ACK\209WCS\EOT\223\171\232\158\254\&5\178\184\209\CAN\165\251G\226Y"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\141\253\251\DC4\210]", _pubPktID = +// 0, _pubBody = "a#\200\US\234\221\168\235\213|\205w", _pubProps = [PropResponseTopic +// "\EM\166\243\154!\131e6!cq%;\221x\190J\250\206\170\189\a\172G\220c\195\US?\186",PropMessageExpiryInterval +// 9099,PropTopicAliasMaximum 17515,PropUserProperty "\184\130kV\184c\196:'\ESC\DC4\131\206@\133" +// "\197\140st\149{3W\157\FS\NUL\153\128\133+y\150)Gcz^l\140a\161<",PropTopicAliasMaximum 6907,PropServerKeepAlive +// 14769,PropPayloadFormatIndicator 38,PropAuthenticationMethod +// "\240\ETX\248\&6gl\v\216\200\212D\RSe\170\198\&8[(\GSx",PropMaximumPacketSize 29348,PropAuthenticationData +// "\178\153\146_\192=\f\143\178?4Ck/M",PropRequestProblemInformation 49,PropCorrelationData +// "\ETXd\nV\130\181L\167\137\251\174I\199\&2V\130\215\225\r\209k\141\162U\181"]} TEST(Publish5QCTest, Encode14) { uint8_t pkt[] = { - 0x34, 0xe1, 0x1, 0x0, 0x5, 0xba, 0xab, 0x24, 0xd7, 0xd5, 0x60, 0xe, 0xce, 0x1, 0xb, 0x16, 0x21, 0x47, 0x59, - 0x3, 0x0, 0x14, 0x8b, 0x5d, 0x44, 0x5f, 0x61, 0x26, 0xb0, 0xd6, 0x83, 0xcf, 0xcd, 0xdb, 0x1a, 0x66, 0x7, 0x3d, - 0x38, 0xd5, 0x86, 0xe3, 0x23, 0x63, 0x86, 0x8, 0x0, 0x1a, 0x7f, 0x2b, 0x1a, 0x20, 0xb9, 0xf4, 0x92, 0x4b, 0x93, - 0x4a, 0xa8, 0x73, 0x5c, 0xdc, 0x8e, 0x37, 0x40, 0x2d, 0x69, 0xa1, 0xa0, 0x97, 0x2e, 0x94, 0x3b, 0x4a, 0x21, 0x57, - 0x2e, 0x22, 0x51, 0xab, 0x1, 0x9e, 0x23, 0x62, 0x93, 0x2a, 0x95, 0x1f, 0x0, 0x12, 0x2b, 0x45, 0xc5, 0xdf, 0xeb, - 0x1e, 0xea, 0x65, 0x2c, 0x53, 0x0, 0xf7, 0x55, 0x2c, 0x4a, 0xf0, 0x79, 0x52, 0x26, 0x0, 0x17, 0x34, 0x2d, 0x98, - 0x27, 0xdd, 0xf7, 0xfd, 0x3f, 0x26, 0x7, 0x3f, 0xd, 0xe0, 0x15, 0xde, 0xfe, 0x89, 0x0, 0x3, 0xd8, 0x60, 0x68, - 0x4, 0x0, 0x1a, 0xaf, 0x36, 0xf0, 0x32, 0xf0, 0x2c, 0xba, 0x89, 0xcc, 0x3f, 0x85, 0xc9, 0xff, 0xa9, 0xdb, 0x1d, - 0x32, 0x56, 0x4d, 0x17, 0xcc, 0x25, 0xa0, 0x96, 0x62, 0xb4, 0x12, 0x0, 0x18, 0xdf, 0x87, 0xf4, 0x9e, 0xae, 0xa2, - 0x46, 0xe8, 0xcd, 0x18, 0x45, 0xc7, 0x6, 0x1a, 0x2, 0x46, 0xd8, 0xeb, 0x3d, 0x23, 0x29, 0x26, 0xb6, 0xdd, 0x2, - 0x0, 0x0, 0x48, 0xb1, 0x1f, 0x0, 0x17, 0x46, 0x4, 0x6, 0xd1, 0x57, 0x43, 0x53, 0x4, 0xdf, 0xab, 0xe8, 0x9e, - 0xfe, 0x35, 0xb2, 0xb8, 0xd1, 0x18, 0xa5, 0xfb, 0x47, 0xe2, 0x59, 0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; - uint8_t topic_bytes[] = {0xba, 0xab, 0x24, 0xd7, 0xd5}; - lwmqtt_string_t topic = {5, (char*)&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topic = {6, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x61, 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 8; - - uint8_t bytesprops0[] = {0x8b, 0x5d, 0x44, 0x5f, 0x61, 0x26, 0xb0, 0xd6, 0x83, 0xcf, - 0xcd, 0xdb, 0x1a, 0x66, 0x7, 0x3d, 0x38, 0xd5, 0x86, 0xe3}; - uint8_t bytesprops1[] = {0x7f, 0x2b, 0x1a, 0x20, 0xb9, 0xf4, 0x92, 0x4b, 0x93, 0x4a, 0xa8, 0x73, 0x5c, - 0xdc, 0x8e, 0x37, 0x40, 0x2d, 0x69, 0xa1, 0xa0, 0x97, 0x2e, 0x94, 0x3b, 0x4a}; - uint8_t bytesprops2[] = {0x2b, 0x45, 0xc5, 0xdf, 0xeb, 0x1e, 0xea, 0x65, 0x2c, - 0x53, 0x0, 0xf7, 0x55, 0x2c, 0x4a, 0xf0, 0x79, 0x52}; - uint8_t bytesprops4[] = {0xaf, 0x36, 0xf0, 0x32, 0xf0, 0x2c, 0xba, 0x89, 0xcc, 0x3f, 0x85, 0xc9, 0xff, - 0xa9, 0xdb, 0x1d, 0x32, 0x56, 0x4d, 0x17, 0xcc, 0x25, 0xa0, 0x96, 0x62, 0xb4}; - uint8_t bytesprops3[] = {0x34, 0x2d, 0x98, 0x27, 0xdd, 0xf7, 0xfd, 0x3f, 0x26, 0x7, 0x3f, 0xd, - 0xe0, 0x15, 0xde, 0xfe, 0x89, 0x0, 0x3, 0xd8, 0x60, 0x68, 0x4}; - uint8_t bytesprops5[] = {0xdf, 0x87, 0xf4, 0x9e, 0xae, 0xa2, 0x46, 0xe8, 0xcd, 0x18, 0x45, 0xc7, - 0x6, 0x1a, 0x2, 0x46, 0xd8, 0xeb, 0x3d, 0x23, 0x29, 0x26, 0xb6, 0xdd}; - uint8_t bytesprops6[] = {0x46, 0x4, 0x6, 0xd1, 0x57, 0x43, 0x53, 0x4, 0xdf, 0xab, 0xe8, 0x9e, - 0xfe, 0x35, 0xb2, 0xb8, 0xd1, 0x18, 0xa5, 0xfb, 0x47, 0xe2, 0x59}; + msg.payload_len = 12; + + uint8_t bytesprops0[] = {0x19, 0xa6, 0xf3, 0x9a, 0x21, 0x83, 0x65, 0x36, 0x21, 0x63, 0x71, 0x25, 0x3b, 0xdd, 0x78, + 0xbe, 0x4a, 0xfa, 0xce, 0xaa, 0xbd, 0x7, 0xac, 0x47, 0xdc, 0x63, 0xc3, 0x1f, 0x3f, 0xba}; + uint8_t bytesprops2[] = {0xc5, 0x8c, 0x73, 0x74, 0x95, 0x7b, 0x33, 0x57, 0x9d, 0x1c, 0x0, 0x99, 0x80, 0x85, + 0x2b, 0x79, 0x96, 0x29, 0x47, 0x63, 0x7a, 0x5e, 0x6c, 0x8c, 0x61, 0xa1, 0x3c}; + uint8_t bytesprops1[] = {0xb8, 0x82, 0x6b, 0x56, 0xb8, 0x63, 0xc4, 0x3a, 0x27, 0x1b, 0x14, 0x83, 0xce, 0x40, 0x85}; + uint8_t bytesprops3[] = {0xf0, 0x3, 0xf8, 0x36, 0x67, 0x6c, 0xb, 0xd8, 0xc8, 0xd4, + 0x44, 0x1e, 0x65, 0xaa, 0xc6, 0x38, 0x5b, 0x28, 0x1d, 0x78}; + uint8_t bytesprops4[] = {0xb2, 0x99, 0x92, 0x5f, 0xc0, 0x3d, 0xc, 0x8f, 0xb2, 0x3f, 0x34, 0x43, 0x6b, 0x2f, 0x4d}; + uint8_t bytesprops5[] = {0x3, 0x64, 0xa, 0x56, 0x82, 0xb5, 0x4c, 0xa7, 0x89, 0xfb, 0xae, 0x49, + 0xc7, 0x32, 0x56, 0x82, 0xd7, 0xe1, 0xd, 0xd1, 0x3c, 0x64, 0x30}; + uint8_t bytesprops6[] = {0xb3, 0xa0, 0xa7, 0xa1, 0x29, 0x18, 0xab, 0xb5, 0x23, 0xd5, 0xd8, 0x98, 0x9d, 0x7c, 0x62, + 0x8c, 0xd8, 0xc8, 0x91, 0x39, 0x47, 0x96, 0x64, 0x9b, 0x7c, 0x39, 0x1b, 0xff, 0x4f}; + uint8_t bytesprops7[] = {0xf8, 0xc9, 0x4d, 0xeb, 0x5c, 0xe2, 0x34, 0xc2, 0x53, 0xcd, 0x9f, 0x68, 0x8b, 0x8, 0x81, + 0xc, 0x95, 0x75, 0xa1, 0x54, 0x15, 0x47, 0xba, 0x6b, 0xf, 0xf7, 0xb5, 0xd7, 0x98, 0xf4}; + uint8_t bytesprops9[] = {0x9, 0x50, 0x61, 0x3b, 0x10, 0x5c, 0x14, 0xa8, 0xb9, 0x23, 0x54, 0x4a, 0x96, 0x8c, + 0x4, 0x88, 0x5d, 0xc8, 0xf3, 0x74, 0x2e, 0x3c, 0x16, 0xd2, 0x42, 0x3b, 0x20}; + uint8_t bytesprops8[] = {0x62, 0x8, 0x49, 0x13, 0x99, 0x65, 0xcd, 0xcb, 0xc0, + 0xd2, 0x5, 0x21, 0x22, 0x92, 0x9c, 0xb5, 0x7c}; + uint8_t bytesprops10[] = {0x88, 0x31, 0xaa, 0x91, 0x24, 0xfc, 0x16, 0x98, 0xc3, 0xac, 0x49, 0xb2, 0x79, + 0x42, 0xd, 0x69, 0xdb, 0xc5, 0xb2, 0xb6, 0xb8, 0xb5, 0xc6, 0xe2, 0xd0}; + uint8_t bytesprops11[] = {0x5f, 0xf, 0x3e, 0x6b, 0x8d, 0xa2, 0x55, 0xb5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18265}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25478}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22318}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20907}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25235}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops3}, .v = {26, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18609}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9099}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17515}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops1}, .v = {27, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6907}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14769}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29348}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7990}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops8}, .v = {27, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24590, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\186\171$\215\213", _pubPktID = -// 24590, _pubBody = "En.&\166\184\215\153", _pubProps = [PropSubscriptionIdentifier 22,PropReceiveMaximum -// 18265,PropContentType "\139]D_a&\176\214\131\207\205\219\SUBf\a=8\213\134\227",PropTopicAlias 25478,PropResponseTopic -// "\DEL+\SUB \185\244\146K\147J\168s\\\220\142\&7@-i\161\160\151.\148;J",PropReceiveMaximum 22318,PropTopicAliasMaximum -// 20907,PropPayloadFormatIndicator 158,PropTopicAlias 25235,PropSharedSubscriptionAvailable 149,PropReasonString -// "+E\197\223\235\RS\234e,S\NUL\247U,J\240yR",PropUserProperty -// "4-\152'\221\247\253?&\a?\r\224\NAK\222\254\137\NUL\ETX\216`h\EOT" -// "\175\&6\240\&2\240,\186\137\204?\133\201\255\169\219\GS2VM\ETB\204%\160\150b\180",PropAssignedClientIdentifier -// "\223\135\244\158\174\162F\232\205\CANE\199\ACK\SUB\STXF\216\235=#)&\182\221",PropMessageExpiryInterval -// 18609,PropReasonString "F\EOT\ACK\209WCS\EOT\223\171\232\158\254\&5\178\184\209\CAN\165\251G\226Y"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\141\253\251\DC4\210]", _pubPktID = +// 0, _pubBody = "a#\200\US\234\221\168\235\213|\205w", _pubProps = [PropResponseTopic +// "\EM\166\243\154!\131e6!cq%;\221x\190J\250\206\170\189\a\172G\220c\195\US?\186",PropMessageExpiryInterval +// 9099,PropTopicAliasMaximum 17515,PropUserProperty "\184\130kV\184c\196:'\ESC\DC4\131\206@\133" +// "\197\140st\149{3W\157\FS\NUL\153\128\133+y\150)Gcz^l\140a\161<",PropTopicAliasMaximum 6907,PropServerKeepAlive +// 14769,PropPayloadFormatIndicator 38,PropAuthenticationMethod +// "\240\ETX\248\&6gl\v\216\200\212D\RSe\170\198\&8[(\GSx",PropMaximumPacketSize 29348,PropAuthenticationData +// "\178\153\146_\192=\f\143\178?4Ck/M",PropRequestProblemInformation 49,PropCorrelationData +// "\ETXd\nV\130\181L\167\137\251\174I\199\&2V\130\215\225\r\209k\141\162U\181"]} TEST(Publish5QCTest, Decode14) { uint8_t pkt[] = { - 0x34, 0xe1, 0x1, 0x0, 0x5, 0xba, 0xab, 0x24, 0xd7, 0xd5, 0x60, 0xe, 0xce, 0x1, 0xb, 0x16, 0x21, 0x47, 0x59, - 0x3, 0x0, 0x14, 0x8b, 0x5d, 0x44, 0x5f, 0x61, 0x26, 0xb0, 0xd6, 0x83, 0xcf, 0xc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; lwmqtt_string_t topic; @@ -3342,115 +3402,119 @@ TEST(Publish5QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xba, 0xab, 0x24, 0xd7, 0xd5}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x45, 0x6e, 0x2e, 0x26, 0xa6, 0xb8, 0xd7, 0x99}; - lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x61, 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 24590); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 8); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\197R\255Y+\ACK", _pubPktID = 17354, -// _pubBody = "_\191\168\153\207\229\204<\169\234j\153A\153/^I\217,\159/\161\222\252?6", _pubProps = -// [PropRequestResponseInformation 184,PropSessionExpiryInterval 21029,PropMaximumQoS -// 50,PropWildcardSubscriptionAvailable 238,PropSubscriptionIdentifier 14,PropTopicAlias -// 19933,PropWildcardSubscriptionAvailable 68,PropAuthenticationData -// "\232\214\&2\254\DLE\242",PropAssignedClientIdentifier "\173\233",PropSharedSubscriptionAvailable -// 228,PropReceiveMaximum 25696,PropMessageExpiryInterval 21838,PropSubscriptionIdentifierAvailable 255,PropUserProperty -// "L\246\166@\169\SO8T\SO\233" ",\141c\RSw",PropTopicAliasMaximum 19135,PropWillDelayInterval -// 27308,PropMaximumPacketSize 28029,PropRequestResponseInformation 109,PropSubscriptionIdentifier -// 12,PropRetainAvailable 74,PropRetainAvailable 73,PropSessionExpiryInterval 27517,PropResponseInformation -// "\194\161=H\b}"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\n", _pubPktID = 15576, _pubBody = +// "\SYN\168.K\212\233\154\159\233j\172\130\DC2\187\203\187\155\ETX", _pubProps = [PropMaximumQoS +// 93,PropPayloadFormatIndicator 146,PropReceiveMaximum 21533,PropWillDelayInterval 20406,PropMaximumPacketSize +// 22453,PropMessageExpiryInterval 7551,PropRequestResponseInformation 41,PropMaximumQoS 142,PropResponseInformation +// "\198I\SI\ACK\152p\128",PropUserProperty +// "\157\178l\206\ETBB\132\174\235P\204\151\NAK\239\\^\177v/:\\\243Q\148\153\178{\205" +// "\DEL\158\131",PropRequestResponseInformation 90,PropMaximumQoS 159,PropTopicAlias 22855,PropMessageExpiryInterval +// 24420,PropWillDelayInterval 10065,PropSessionExpiryInterval 18232,PropAssignedClientIdentifier +// "\147\185\FS\bn\205\194\143\SYN",PropSessionExpiryInterval 13363,PropMessageExpiryInterval +// 26041,PropSubscriptionIdentifierAvailable 166,PropResponseInformation "F\157",PropWillDelayInterval +// 26757,PropServerReference "\209\247\248\150\ACKW}"]} TEST(Publish5QCTest, Encode15) { - uint8_t pkt[] = {0x3b, 0x88, 0x1, 0x0, 0x6, 0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6, 0x43, 0xca, 0x63, 0x19, 0xb8, - 0x11, 0x0, 0x0, 0x52, 0x25, 0x24, 0x32, 0x28, 0xee, 0xb, 0xe, 0x23, 0x4d, 0xdd, 0x28, 0x44, - 0x16, 0x0, 0x6, 0xe8, 0xd6, 0x32, 0xfe, 0x10, 0xf2, 0x12, 0x0, 0x2, 0xad, 0xe9, 0x2a, 0xe4, - 0x21, 0x64, 0x60, 0x2, 0x0, 0x0, 0x55, 0x4e, 0x29, 0xff, 0x26, 0x0, 0xa, 0x4c, 0xf6, 0xa6, - 0x40, 0xa9, 0xe, 0x38, 0x54, 0xe, 0xe9, 0x0, 0x5, 0x2c, 0x8d, 0x63, 0x1e, 0x77, 0x22, 0x4a, - 0xbf, 0x18, 0x0, 0x0, 0x6a, 0xac, 0x27, 0x0, 0x0, 0x6d, 0x7d, 0x19, 0x6d, 0xb, 0xc, 0x25, - 0x4a, 0x25, 0x49, 0x11, 0x0, 0x0, 0x6b, 0x7d, 0x1a, 0x0, 0x6, 0xc2, 0xa1, 0x3d, 0x48, 0x8, - 0x7d, 0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, 0x99, 0x2f, - 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; - uint8_t topic_bytes[] = {0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0xa3, 0x1, 0x0, 0x1, 0xa, 0x3c, 0xd8, 0x8a, 0x1, 0x24, 0x5d, 0x1, 0x92, 0x21, 0x54, 0x1d, + 0x18, 0x0, 0x0, 0x4f, 0xb6, 0x27, 0x0, 0x0, 0x57, 0xb5, 0x2, 0x0, 0x0, 0x1d, 0x7f, 0x19, 0x29, + 0x24, 0x8e, 0x1a, 0x0, 0x7, 0xc6, 0x49, 0xf, 0x6, 0x98, 0x70, 0x80, 0x26, 0x0, 0x1c, 0x9d, 0xb2, + 0x6c, 0xce, 0x17, 0x42, 0x84, 0xae, 0xeb, 0x50, 0xcc, 0x97, 0x15, 0xef, 0x5c, 0x5e, 0xb1, 0x76, 0x2f, + 0x3a, 0x5c, 0xf3, 0x51, 0x94, 0x99, 0xb2, 0x7b, 0xcd, 0x0, 0x3, 0x7f, 0x9e, 0x83, 0x19, 0x5a, 0x24, + 0x9f, 0x23, 0x59, 0x47, 0x2, 0x0, 0x0, 0x5f, 0x64, 0x18, 0x0, 0x0, 0x27, 0x51, 0x11, 0x0, 0x0, + 0x47, 0x38, 0x12, 0x0, 0x9, 0x93, 0xb9, 0x1c, 0x8, 0x6e, 0xcd, 0xc2, 0x8f, 0x16, 0x11, 0x0, 0x0, + 0x34, 0x33, 0x2, 0x0, 0x0, 0x65, 0xb9, 0x29, 0xa6, 0x1a, 0x0, 0x2, 0x46, 0x9d, 0x18, 0x0, 0x0, + 0x68, 0x85, 0x1c, 0x0, 0x7, 0xd1, 0xf7, 0xf8, 0x96, 0x6, 0x57, 0x7d, 0x16, 0xa8, 0x2e, 0x4b, 0xd4, + 0xe9, 0x9a, 0x9f, 0xe9, 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; + uint8_t topic_bytes[] = {0xa}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, - 0x99, 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x16, 0xa8, 0x2e, 0x4b, 0xd4, 0xe9, 0x9a, 0x9f, 0xe9, + 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 18; - uint8_t bytesprops0[] = {0xe8, 0xd6, 0x32, 0xfe, 0x10, 0xf2}; - uint8_t bytesprops1[] = {0xad, 0xe9}; - uint8_t bytesprops3[] = {0x2c, 0x8d, 0x63, 0x1e, 0x77}; - uint8_t bytesprops2[] = {0x4c, 0xf6, 0xa6, 0x40, 0xa9, 0xe, 0x38, 0x54, 0xe, 0xe9}; - uint8_t bytesprops4[] = {0xc2, 0xa1, 0x3d, 0x48, 0x8, 0x7d}; + uint8_t bytesprops0[] = {0xc6, 0x49, 0xf, 0x6, 0x98, 0x70, 0x80}; + uint8_t bytesprops2[] = {0x7f, 0x9e, 0x83}; + uint8_t bytesprops1[] = {0x9d, 0xb2, 0x6c, 0xce, 0x17, 0x42, 0x84, 0xae, 0xeb, 0x50, 0xcc, 0x97, 0x15, 0xef, + 0x5c, 0x5e, 0xb1, 0x76, 0x2f, 0x3a, 0x5c, 0xf3, 0x51, 0x94, 0x99, 0xb2, 0x7b, 0xcd}; + uint8_t bytesprops3[] = {0x93, 0xb9, 0x1c, 0x8, 0x6e, 0xcd, 0xc2, 0x8f, 0x16}; + uint8_t bytesprops4[] = {0x46, 0x9d}; + uint8_t bytesprops5[] = {0xd1, 0xf7, 0xf8, 0x96, 0x6, 0x57, 0x7d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21029}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19933}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25696}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21838}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {5, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19135}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27308}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28029}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27517}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21533}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20406}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22453}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7551}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops1}, .v = {3, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22855}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24420}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10065}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18232}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13363}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26041}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26757}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops5}}}, }; lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 17354, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15576, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\197R\255Y+\ACK", _pubPktID = 17354, -// _pubBody = "_\191\168\153\207\229\204<\169\234j\153A\153/^I\217,\159/\161\222\252?6", _pubProps = -// [PropRequestResponseInformation 184,PropSessionExpiryInterval 21029,PropMaximumQoS -// 50,PropWildcardSubscriptionAvailable 238,PropSubscriptionIdentifier 14,PropTopicAlias -// 19933,PropWildcardSubscriptionAvailable 68,PropAuthenticationData -// "\232\214\&2\254\DLE\242",PropAssignedClientIdentifier "\173\233",PropSharedSubscriptionAvailable -// 228,PropReceiveMaximum 25696,PropMessageExpiryInterval 21838,PropSubscriptionIdentifierAvailable 255,PropUserProperty -// "L\246\166@\169\SO8T\SO\233" ",\141c\RSw",PropTopicAliasMaximum 19135,PropWillDelayInterval -// 27308,PropMaximumPacketSize 28029,PropRequestResponseInformation 109,PropSubscriptionIdentifier -// 12,PropRetainAvailable 74,PropRetainAvailable 73,PropSessionExpiryInterval 27517,PropResponseInformation -// "\194\161=H\b}"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\n", _pubPktID = 15576, _pubBody = +// "\SYN\168.K\212\233\154\159\233j\172\130\DC2\187\203\187\155\ETX", _pubProps = [PropMaximumQoS +// 93,PropPayloadFormatIndicator 146,PropReceiveMaximum 21533,PropWillDelayInterval 20406,PropMaximumPacketSize +// 22453,PropMessageExpiryInterval 7551,PropRequestResponseInformation 41,PropMaximumQoS 142,PropResponseInformation +// "\198I\SI\ACK\152p\128",PropUserProperty +// "\157\178l\206\ETBB\132\174\235P\204\151\NAK\239\\^\177v/:\\\243Q\148\153\178{\205" +// "\DEL\158\131",PropRequestResponseInformation 90,PropMaximumQoS 159,PropTopicAlias 22855,PropMessageExpiryInterval +// 24420,PropWillDelayInterval 10065,PropSessionExpiryInterval 18232,PropAssignedClientIdentifier +// "\147\185\FS\bn\205\194\143\SYN",PropSessionExpiryInterval 13363,PropMessageExpiryInterval +// 26041,PropSubscriptionIdentifierAvailable 166,PropResponseInformation "F\157",PropWillDelayInterval +// 26757,PropServerReference "\209\247\248\150\ACKW}"]} TEST(Publish5QCTest, Decode15) { - uint8_t pkt[] = {0x3b, 0x88, 0x1, 0x0, 0x6, 0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6, 0x43, 0xca, 0x63, 0x19, 0xb8, - 0x11, 0x0, 0x0, 0x52, 0x25, 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2f, + 0x3a, 0x5c, 0xf3, 0x51, 0x94, 0x99, 0xb2, 0x7b, 0xcd, 0x0, 0x3, 0x7f, 0x9e, 0x83, 0x19, 0x5a, 0x24, + 0x9f, 0x23, 0x59, 0x47, 0x2, 0x0, 0x0, 0x5f, 0x64, 0x18, 0x0, 0x0, 0x27, 0x51, 0x11, 0x0, 0x0, + 0x47, 0x38, 0x12, 0x0, 0x9, 0x93, 0xb9, 0x1c, 0x8, 0x6e, 0xcd, 0xc2, 0x8f, 0x16, 0x11, 0x0, 0x0, + 0x34, 0x33, 0x2, 0x0, 0x0, 0x65, 0xb9, 0x29, 0xa6, 0x1a, 0x0, 0x2, 0x46, 0x9d, 0x18, 0x0, 0x0, + 0x68, 0x85, 0x1c, 0x0, 0x7, 0xd1, 0xf7, 0xf8, 0x96, 0x6, 0x57, 0x7d, 0x16, 0xa8, 0x2e, 0x4b, 0xd4, + 0xe9, 0x9a, 0x9f, 0xe9, 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3458,60 +3522,109 @@ TEST(Publish5QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc5, 0x52, 0xff, 0x59, 0x2b, 0x6}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5f, 0xbf, 0xa8, 0x99, 0xcf, 0xe5, 0xcc, 0x3c, 0xa9, 0xea, 0x6a, 0x99, 0x41, - 0x99, 0x2f, 0x5e, 0x49, 0xd9, 0x2c, 0x9f, 0x2f, 0xa1, 0xde, 0xfc, 0x3f, 0x36}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x16, 0xa8, 0x2e, 0x4b, 0xd4, 0xe9, 0x9a, 0x9f, 0xe9, + 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 17354); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 15576); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\181h\206\206#\148<\227\196\202?\ENQ\255\RSp\196\162\184\171\224", _pubPktID = 9053, _pubBody = -// "W\232(5\208_\210\199B\249E\178\157\128", _pubProps = [PropReceiveMaximum 12053]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\195\214\220\150\206L\a\225", +// _pubPktID = 0, _pubBody = "\203\137\DC3y\ETBf\GS\255}~\231\217kJ\ESCI\193\148\254p\247\ACKB\245", _pubProps = +// [PropMaximumQoS 244,PropCorrelationData +// "\181\249\159\175\155\170\r\191X\253\226\180\181\235\168\\\165\195f\NAK",PropSubscriptionIdentifierAvailable +// 149,PropWildcardSubscriptionAvailable 9,PropTopicAliasMaximum 27472,PropMessageExpiryInterval 269,PropReasonString +// "\230o\STX{l\138p",PropMessageExpiryInterval 32244,PropWillDelayInterval 26373,PropTopicAliasMaximum +// 26296,PropWillDelayInterval 17842,PropMessageExpiryInterval 14239,PropRetainAvailable 179,PropUserProperty +// "\222\211\187\&9\254\208\239" +// "\n\t\224E\NAK\195\SUB\209@\235\214\182\ETBn%_$o\159\v\206\254",PropSubscriptionIdentifierAvailable +// 94,PropServerKeepAlive 3204,PropTopicAlias 992]} TEST(Publish5QCTest, Encode16) { - uint8_t pkt[] = {0x3c, 0x2a, 0x0, 0x14, 0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, 0x3f, - 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0, 0x23, 0x5d, 0x3, 0x21, 0x2f, 0x15, - 0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; - uint8_t topic_bytes[] = {0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, - 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x95, 0x1, 0x0, 0x8, 0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1, 0x72, 0x24, 0xf4, 0x9, + 0x0, 0x14, 0xb5, 0xf9, 0x9f, 0xaf, 0x9b, 0xaa, 0xd, 0xbf, 0x58, 0xfd, 0xe2, 0xb4, 0xb5, 0xeb, 0xa8, + 0x5c, 0xa5, 0xc3, 0x66, 0x15, 0x29, 0x95, 0x28, 0x9, 0x22, 0x6b, 0x50, 0x2, 0x0, 0x0, 0x1, 0xd, + 0x1f, 0x0, 0x7, 0xe6, 0x6f, 0x2, 0x7b, 0x6c, 0x8a, 0x70, 0x2, 0x0, 0x0, 0x7d, 0xf4, 0x18, 0x0, + 0x0, 0x67, 0x5, 0x22, 0x66, 0xb8, 0x18, 0x0, 0x0, 0x45, 0xb2, 0x2, 0x0, 0x0, 0x37, 0x9f, 0x25, + 0xb3, 0x26, 0x0, 0x7, 0xde, 0xd3, 0xbb, 0x39, 0xfe, 0xd0, 0xef, 0x0, 0x16, 0xa, 0x9, 0xe0, 0x45, + 0x15, 0xc3, 0x1a, 0xd1, 0x40, 0xeb, 0xd6, 0xb6, 0x17, 0x6e, 0x25, 0x5f, 0x24, 0x6f, 0x9f, 0xb, 0xce, + 0xfe, 0x29, 0x5e, 0x13, 0xc, 0x84, 0x23, 0x3, 0xe0, 0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, + 0x7d, 0x7e, 0xe7, 0xd9, 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; + uint8_t topic_bytes[] = {0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; + uint8_t msg_bytes[] = {0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, + 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 24; + + uint8_t bytesprops0[] = {0xb5, 0xf9, 0x9f, 0xaf, 0x9b, 0xaa, 0xd, 0xbf, 0x58, 0xfd, + 0xe2, 0xb4, 0xb5, 0xeb, 0xa8, 0x5c, 0xa5, 0xc3, 0x66, 0x15}; + uint8_t bytesprops1[] = {0xe6, 0x6f, 0x2, 0x7b, 0x6c, 0x8a, 0x70}; + uint8_t bytesprops3[] = {0xa, 0x9, 0xe0, 0x45, 0x15, 0xc3, 0x1a, 0xd1, 0x40, 0xeb, 0xd6, + 0xb6, 0x17, 0x6e, 0x25, 0x5f, 0x24, 0x6f, 0x9f, 0xb, 0xce, 0xfe}; + uint8_t bytesprops2[] = {0xde, 0xd3, 0xbb, 0x39, 0xfe, 0xd0, 0xef}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12053}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27472}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 269}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32244}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26373}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26296}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17842}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14239}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops2}, .v = {22, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3204}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 992}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 9053, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\181h\206\206#\148<\227\196\202?\ENQ\255\RSp\196\162\184\171\224", _pubPktID = 9053, _pubBody = -// "W\232(5\208_\210\199B\249E\178\157\128", _pubProps = [PropReceiveMaximum 12053]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\195\214\220\150\206L\a\225", +// _pubPktID = 0, _pubBody = "\203\137\DC3y\ETBf\GS\255}~\231\217kJ\ESCI\193\148\254p\247\ACKB\245", _pubProps = +// [PropMaximumQoS 244,PropCorrelationData +// "\181\249\159\175\155\170\r\191X\253\226\180\181\235\168\\\165\195f\NAK",PropSubscriptionIdentifierAvailable +// 149,PropWildcardSubscriptionAvailable 9,PropTopicAliasMaximum 27472,PropMessageExpiryInterval 269,PropReasonString +// "\230o\STX{l\138p",PropMessageExpiryInterval 32244,PropWillDelayInterval 26373,PropTopicAliasMaximum +// 26296,PropWillDelayInterval 17842,PropMessageExpiryInterval 14239,PropRetainAvailable 179,PropUserProperty +// "\222\211\187\&9\254\208\239" +// "\n\t\224E\NAK\195\SUB\209@\235\214\182\ETBn%_$o\159\v\206\254",PropSubscriptionIdentifierAvailable +// 94,PropServerKeepAlive 3204,PropTopicAlias 992]} TEST(Publish5QCTest, Decode16) { - uint8_t pkt[] = {0x3c, 0x2a, 0x0, 0x14, 0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, 0x3f, - 0x5, 0xff,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topic; @@ -3519,64 +3632,122 @@ TEST(Publish5QCTest, Decode16) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb5, 0x68, 0xce, 0xce, 0x23, 0x94, 0x3c, 0xe3, 0xc4, 0xca, - 0x3f, 0x5, 0xff, 0x1e, 0x70, 0xc4, 0xa2, 0xb8, 0xab, 0xe0}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x57, 0xe8, 0x28, 0x35, 0xd0, 0x5f, 0xd2, 0xc7, 0x42, 0xf9, 0x45, 0xb2, 0x9d, 0x80}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, + 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 9053); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\147\174\SYN ", _pubPktID = 0, -// _pubBody = "\155\DC3A*\157dh!\177=7\233\225\DLE|\EM\145", _pubProps = [PropSessionExpiryInterval -// 30284,PropWildcardSubscriptionAvailable 74,PropServerReference -// "\191\&6\231s\t;%\213@\215a\162\165[\253",PropSubscriptionIdentifier 29,PropTopicAliasMaximum -// 9684,PropSharedSubscriptionAvailable 165,PropSharedSubscriptionAvailable 144,PropTopicAlias -// 8584,PropAuthenticationMethod "!(\253\175\DLEK\SYN\EM\149S\205\205\"\151#\v\240\DC4,w{\180\247\&7\US\209\213X"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\NUL=U\137\224\247\192", _pubPktID = +// 0, _pubBody = "\142\160\202\237f\186\202Fc1p\\\ACK\231J\193%\250kl", _pubProps = [PropResponseTopic +// "O\141*\235\&3\DC4\168\162\EOT;\RS\229",PropAuthenticationMethod +// "\131\STX\192\RSs)\157\145\222\238\178\137\162\244&\161\157\221mfd\201G\253\147S",PropPayloadFormatIndicator +// 181,PropRetainAvailable 216,PropContentType +// "\241\roz\NAK\216\238\192\155\249\200\211\129\f$*\175\147",PropReasonString +// "b\ta\190\187\148\DEL\170L\215e\197\240\151\DLE\223\SO\232\153\&9\155'r\207\168\210i",PropWildcardSubscriptionAvailable +// 225,PropMaximumPacketSize 26717,PropMaximumQoS 92,PropMaximumQoS 102,PropUserProperty +// "\196\FS\172\\\213+m\242\DLEo=\189=\213\218\243<\188\253\152F\209\133\252\139\170\159\207V" +// "\202\129\NULU\177\233\203\246hv\ETX\240\&9E\229B6\252\&4\155\136\r\231\229",PropMessageExpiryInterval +// 20811,PropAuthenticationMethod +// "\CAN8\213\197#\136\254\192\152I\237_n{9X/t\152\a+\165\&8\181\&2\226\151",PropMessageExpiryInterval +// 24371,PropSubscriptionIdentifier 27,PropUserProperty "\136" +// "yb\RS\DEL)\198o\EOTs\180\DC1e\213\214!\182Ql\251\137\154\165\137\216\144\218\247\130+\227",PropUserProperty +// "\177\132U^\v\249\252\145]\v\250b\184\US5zN\STX\195m" +// "\173\n\156\165\GS\255\195u\181\142\178\134\252kX\220*\RSm",PropSubscriptionIdentifier 16,PropResponseInformation +// "\149l&~\225\129\140f.\206\195p\152\156\202(topic.data), 4); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "t\183\232G\148\143\148J\151\141\197\&0\196\244?(x\225\237\EM", _pubPktID = 0, _pubBody = -// "\ESC\231\EM\255\149&\\p\RS\173+\194\173\204\183u\131G\218", _pubProps = [PropRequestProblemInformation -// 130,PropResponseInformation -// "\174\168\140`\EOT\176O.\214\156J\176\132\232~\220B\208I\SOH\240\&9\183",PropRequestResponseInformation -// 222,PropPayloadFormatIndicator 65,PropRequestResponseInformation 53,PropResponseInformation -// "\245\153\155\DC4\146\172\231\195\176\169\ESC\138t3*\251\246\188",PropSessionExpiryInterval -// 2403,PropSessionExpiryInterval 7061,PropMaximumQoS 225,PropRequestResponseInformation 155,PropSubscriptionIdentifier -// 26,PropAssignedClientIdentifier "\SI",PropMaximumPacketSize 7091,PropContentType -// "'\CANh)\213|\160\a\DC3R\146v\218\&8}\EOTa6I\137\250;\233\228U\251x\252",PropMaximumPacketSize -// 1488,PropAuthenticationMethod "\CAN\221rv\175\198\190\n\DC2\178b\ENQ\208@Ky\246\225\156\227S"]} +// "\192\226\177\DC3\178\200n\184h\162\210\RS\153\149\253\&1\132\250\156\\\190\ETB\149 \192\247C\203", _pubPktID = 0, +// _pubBody = "\243(topic.data), 20); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\245l-\185\147\\\ai\199\183\216s\232\\\248\DC4\199\231[\DC4\139", _pubProps = [PropAuthenticationMethod -// "rC\184\SI\211\138\216kp\140\252\ACK2",PropMessageExpiryInterval 14395,PropSharedSubscriptionAvailable -// 182,PropMaximumQoS 230,PropServerReference -// "z\215\224\187zZ\ETB$\137\164\235\133\143\SI\228\232\242\130R\188\b\242\228\131\179\br",PropReasonString -// "\205\&6\ENQWp\149\176\186\202",PropPayloadFormatIndicator 91,PropRequestResponseInformation -// 166,PropResponseInformation -// "\US\220\207\205\200\162\141U\254\SOH\204\ng\156*\133h\228\198\152\CANhb",PropWildcardSubscriptionAvailable -// 52,PropSubscriptionIdentifier 17,PropRequestProblemInformation 195,PropTopicAlias 28295,PropMessageExpiryInterval -// 25451,PropReasonString "W",PropSessionExpiryInterval 13393,PropAssignedClientIdentifier -// "\146P\DC3`xR\ETX\t\161p\199",PropRetainAvailable 160,PropMessageExpiryInterval 16943,PropUserProperty -// "\212z\240\193\227\DC4\196,\RS?\198I\145[H\136\236\&39\254" -// "\154n2\180\135\194\227\149\178\151\152\216'",PropContentType "",PropAuthenticationData -// "\\@T\206\SOH,v\220\160dU?\218\RSM\250\181e\199",PropTopicAliasMaximum 7139,PropSessionExpiryInterval -// 27556,PropAuthenticationMethod "j\194\EOT\206w",PropUserProperty "W\150m\239\193e\141\197\242" -// "\200z{\236=*\134\210\160\237\t\n2",PropWildcardSubscriptionAvailable 5]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "Q\144\172\176:\255\255\236\209\134\204", _pubPktID = 29463, _pubBody = +// "\135s\STX\155A\v\217\&8\EOT^,\220\194\183\195\251\223H9g\164", _pubProps = [PropSubscriptionIdentifierAvailable +// 1,PropSharedSubscriptionAvailable 127,PropAssignedClientIdentifier +// "\SI\NULB[\DC3\137\155\255\ENQ\SUBqa\DC3\234%\158\184\200\129\155",PropSubscriptionIdentifierAvailable +// 246,PropTopicAliasMaximum 4016,PropTopicAliasMaximum 9506]} TEST(Publish5QCTest, Encode19) { - uint8_t pkt[] = { - 0x30, 0x92, 0x2, 0x0, 0x0, 0xf9, 0x1, 0x15, 0x0, 0xd, 0x72, 0x43, 0xb8, 0xf, 0xd3, 0x8a, 0xd8, 0x6b, 0x70, - 0x8c, 0xfc, 0x6, 0x32, 0x2, 0x0, 0x0, 0x38, 0x3b, 0x2a, 0xb6, 0x24, 0xe6, 0x1c, 0x0, 0x1b, 0x7a, 0xd7, 0xe0, - 0xbb, 0x7a, 0x5a, 0x17, 0x24, 0x89, 0xa4, 0xeb, 0x85, 0x8f, 0xf, 0xe4, 0xe8, 0xf2, 0x82, 0x52, 0xbc, 0x8, 0xf2, - 0xe4, 0x83, 0xb3, 0x8, 0x72, 0x1f, 0x0, 0x9, 0xcd, 0x36, 0x5, 0x57, 0x70, 0x95, 0xb0, 0xba, 0xca, 0x1, 0x5b, - 0x19, 0xa6, 0x1a, 0x0, 0x17, 0x1f, 0xdc, 0xcf, 0xcd, 0xc8, 0xa2, 0x8d, 0x55, 0xfe, 0x1, 0xcc, 0xa, 0x67, 0x9c, - 0x2a, 0x85, 0x68, 0xe4, 0xc6, 0x98, 0x18, 0x68, 0x62, 0x28, 0x34, 0xb, 0x11, 0x17, 0xc3, 0x23, 0x6e, 0x87, 0x2, - 0x0, 0x0, 0x63, 0x6b, 0x1f, 0x0, 0x1, 0x57, 0x11, 0x0, 0x0, 0x34, 0x51, 0x12, 0x0, 0xb, 0x92, 0x50, 0x13, - 0x60, 0x78, 0x52, 0x3, 0x9, 0xa1, 0x70, 0xc7, 0x25, 0xa0, 0x2, 0x0, 0x0, 0x42, 0x2f, 0x26, 0x0, 0x14, 0xd4, - 0x7a, 0xf0, 0xc1, 0xe3, 0x14, 0xc4, 0x2c, 0x1e, 0x3f, 0xc6, 0x49, 0x91, 0x5b, 0x48, 0x88, 0xec, 0x33, 0x39, 0xfe, - 0x0, 0xd, 0x9a, 0x6e, 0x32, 0xb4, 0x87, 0xc2, 0xe3, 0x95, 0xb2, 0x97, 0x98, 0xd8, 0x27, 0x3, 0x0, 0x0, 0x16, - 0x0, 0x13, 0x5c, 0x40, 0x54, 0xce, 0x1, 0x2c, 0x76, 0xdc, 0xa0, 0x64, 0x55, 0x3f, 0xda, 0x1e, 0x4d, 0xfa, 0xb5, - 0x65, 0xc7, 0x22, 0x1b, 0xe3, 0x11, 0x0, 0x0, 0x6b, 0xa4, 0x15, 0x0, 0x5, 0x6a, 0xc2, 0x4, 0xce, 0x77, 0x26, - 0x0, 0x9, 0x57, 0x96, 0x6d, 0xef, 0xc1, 0x65, 0x8d, 0xc5, 0xf2, 0x0, 0xd, 0xc8, 0x7a, 0x7b, 0xec, 0x3d, 0x2a, - 0x86, 0xd2, 0xa0, 0xed, 0x9, 0xa, 0x32, 0x28, 0x5, 0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, - 0xd8, 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x48, 0x0, 0xb, 0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc, + 0x73, 0x17, 0x23, 0x29, 0x1, 0x2a, 0x7f, 0x12, 0x0, 0x14, 0xf, 0x0, 0x42, 0x5b, 0x13, + 0x89, 0x9b, 0xff, 0x5, 0x1a, 0x71, 0x61, 0x13, 0xea, 0x25, 0x9e, 0xb8, 0xc8, 0x81, 0x9b, + 0x29, 0xf6, 0x22, 0xf, 0xb0, 0x22, 0x25, 0x22, 0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, + 0x38, 0x4, 0x5e, 0x2c, 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; + uint8_t topic_bytes[] = {0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, 0xd8, - 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, 0x5e, 0x2c, + 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 21; - uint8_t bytesprops0[] = {0x72, 0x43, 0xb8, 0xf, 0xd3, 0x8a, 0xd8, 0x6b, 0x70, 0x8c, 0xfc, 0x6, 0x32}; - uint8_t bytesprops1[] = {0x7a, 0xd7, 0xe0, 0xbb, 0x7a, 0x5a, 0x17, 0x24, 0x89, 0xa4, 0xeb, 0x85, 0x8f, 0xf, - 0xe4, 0xe8, 0xf2, 0x82, 0x52, 0xbc, 0x8, 0xf2, 0xe4, 0x83, 0xb3, 0x8, 0x72}; - uint8_t bytesprops2[] = {0xcd, 0x36, 0x5, 0x57, 0x70, 0x95, 0xb0, 0xba, 0xca}; - uint8_t bytesprops3[] = {0x1f, 0xdc, 0xcf, 0xcd, 0xc8, 0xa2, 0x8d, 0x55, 0xfe, 0x1, 0xcc, 0xa, - 0x67, 0x9c, 0x2a, 0x85, 0x68, 0xe4, 0xc6, 0x98, 0x18, 0x68, 0x62}; - uint8_t bytesprops4[] = {0x57}; - uint8_t bytesprops5[] = {0x92, 0x50, 0x13, 0x60, 0x78, 0x52, 0x3, 0x9, 0xa1, 0x70, 0xc7}; - uint8_t bytesprops7[] = {0x9a, 0x6e, 0x32, 0xb4, 0x87, 0xc2, 0xe3, 0x95, 0xb2, 0x97, 0x98, 0xd8, 0x27}; - uint8_t bytesprops6[] = {0xd4, 0x7a, 0xf0, 0xc1, 0xe3, 0x14, 0xc4, 0x2c, 0x1e, 0x3f, - 0xc6, 0x49, 0x91, 0x5b, 0x48, 0x88, 0xec, 0x33, 0x39, 0xfe}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops9[] = {0x5c, 0x40, 0x54, 0xce, 0x1, 0x2c, 0x76, 0xdc, 0xa0, 0x64, - 0x55, 0x3f, 0xda, 0x1e, 0x4d, 0xfa, 0xb5, 0x65, 0xc7}; - uint8_t bytesprops10[] = {0x6a, 0xc2, 0x4, 0xce, 0x77}; - uint8_t bytesprops12[] = {0xc8, 0x7a, 0x7b, 0xec, 0x3d, 0x2a, 0x86, 0xd2, 0xa0, 0xed, 0x9, 0xa, 0x32}; - uint8_t bytesprops11[] = {0x57, 0x96, 0x6d, 0xef, 0xc1, 0x65, 0x8d, 0xc5, 0xf2}; + uint8_t bytesprops0[] = {0xf, 0x0, 0x42, 0x5b, 0x13, 0x89, 0x9b, 0xff, 0x5, 0x1a, + 0x71, 0x61, 0x13, 0xea, 0x25, 0x9e, 0xb8, 0xc8, 0x81, 0x9b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14395}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28295}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25451}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13393}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16943}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops6}, .v = {13, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7139}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27556}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops11}, .v = {13, (char*)&bytesprops12}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4016}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9506}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29463, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\245l-\185\147\\\ai\199\183\216s\232\\\248\DC4\199\231[\DC4\139", _pubProps = [PropAuthenticationMethod -// "rC\184\SI\211\138\216kp\140\252\ACK2",PropMessageExpiryInterval 14395,PropSharedSubscriptionAvailable -// 182,PropMaximumQoS 230,PropServerReference -// "z\215\224\187zZ\ETB$\137\164\235\133\143\SI\228\232\242\130R\188\b\242\228\131\179\br",PropReasonString -// "\205\&6\ENQWp\149\176\186\202",PropPayloadFormatIndicator 91,PropRequestResponseInformation -// 166,PropResponseInformation -// "\US\220\207\205\200\162\141U\254\SOH\204\ng\156*\133h\228\198\152\CANhb",PropWildcardSubscriptionAvailable -// 52,PropSubscriptionIdentifier 17,PropRequestProblemInformation 195,PropTopicAlias 28295,PropMessageExpiryInterval -// 25451,PropReasonString "W",PropSessionExpiryInterval 13393,PropAssignedClientIdentifier -// "\146P\DC3`xR\ETX\t\161p\199",PropRetainAvailable 160,PropMessageExpiryInterval 16943,PropUserProperty -// "\212z\240\193\227\DC4\196,\RS?\198I\145[H\136\236\&39\254" -// "\154n2\180\135\194\227\149\178\151\152\216'",PropContentType "",PropAuthenticationData -// "\\@T\206\SOH,v\220\160dU?\218\RSM\250\181e\199",PropTopicAliasMaximum 7139,PropSessionExpiryInterval -// 27556,PropAuthenticationMethod "j\194\EOT\206w",PropUserProperty "W\150m\239\193e\141\197\242" -// "\200z{\236=*\134\210\160\237\t\n2",PropWildcardSubscriptionAvailable 5]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "Q\144\172\176:\255\255\236\209\134\204", _pubPktID = 29463, _pubBody = +// "\135s\STX\155A\v\217\&8\EOT^,\220\194\183\195\251\223H9g\164", _pubProps = [PropSubscriptionIdentifierAvailable +// 1,PropSharedSubscriptionAvailable 127,PropAssignedClientIdentifier +// "\SI\NULB[\DC3\137\155\255\ENQ\SUBqa\DC3\234%\158\184\200\129\155",PropSubscriptionIdentifierAvailable +// 246,PropTopicAliasMaximum 4016,PropTopicAliasMaximum 9506]} TEST(Publish5QCTest, Decode19) { - uint8_t pkt[] = { - 0x30, 0x92, 0x2, 0x0, 0x0, 0xf9, 0x1, 0x15, 0x0, 0xd, 0x72, 0x43, 0xb8, 0xf, 0xd3, 0x8a, 0xd8, 0x6b, 0x70, - 0x8c, 0xfc, 0x6, 0x32, 0x2, 0x0, 0x0, 0x38, 0x3b, 0x2a, 0xb6, 0x24, 0xe6, 0x1c, 0x0, 0x1b, 0x7a, 0xd7, 0xe0, - 0xbb, 0x7a, 0x5a, 0x17, 0x24, 0x89, 0xa4, 0xeb, 0x85, 0x8f, 0xf, 0xe4, 0xe8, 0xf2, 0x82, 0x52, 0xbc, 0x8, 0xf2, - 0xe4, 0x83, 0xb3, 0x8,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0xa0, 0xed, 0x9, 0xa, 0x32, 0x28, 0x5, 0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, - 0xd8, 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; + uint8_t pkt[] = {0x3b, 0x48, 0x0, 0xb, 0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc, + 0x73, 0x17, 0x23, 0x29, 0x1, 0x2a, 0x7f, 0x12, 0x0, 0x14, 0xf, 0x0, 0x42, 0x5b, 0x13, + 0x89, 0x9b, 0xff, 0x5, 0x1a, 0x71, 0x61, 0x13, 0xea, 0x25, 0x9e, 0xb8, 0xc8, 0x81, 0x9b, + 0x29, 0xf6, 0x22, 0xf, 0xb0, 0x22, 0x25, 0x22, 0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, + 0x38, 0x4, 0x5e, 0x2c, 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3881,146 +4007,125 @@ TEST(Publish5QCTest, Decode19) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf5, 0x6c, 0x2d, 0xb9, 0x93, 0x5c, 0x7, 0x69, 0xc7, 0xb7, 0xd8, - 0x73, 0xe8, 0x5c, 0xf8, 0x14, 0xc7, 0xe7, 0x5b, 0x14, 0x8b}; + uint8_t exp_topic_bytes[] = {0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, 0x5e, 0x2c, + 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 29463); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); EXPECT_EQ(msg.payload_len, 21); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "B&&P~\USwi\200\237U\SI0[8\205\ETX\US\171\236", _pubPktID = 20579, _pubBody = -// "\160|,\236\153`\132S\ETBj\210-v\ETB\US\246\DC4>iK\158\SOH\141\250", _pubProps = [PropAuthenticationData -// "\189\ETX\233\254\CAN\DLEh\194\167\169\ENQ\189R\142\208\219K_L\142<",PropMessageExpiryInterval -// 5515,PropReceiveMaximum 2239,PropContentType -// "\na\143g\245\241\131\129S\235:S\134\\Y\EM\178jo\176\254~\160\244b\153=O\219\134",PropRequestResponseInformation -// 81,PropTopicAliasMaximum 31006,PropRequestProblemInformation 9,PropServerKeepAlive -// 14324,PropSharedSubscriptionAvailable 46,PropMaximumPacketSize 2368,PropContentType "+\149\163\222\141\174\179\ETB -// \216r.RR\180#f\226(\156;",PropResponseTopic -// "}\EM\250f\EOT4\216\187s\219\209\136\147\216`\224\ACK\232yt\231\173n\248\183\197",PropMaximumPacketSize -// 27506,PropReceiveMaximum 3430,PropRetainAvailable 154,PropResponseTopic -// "-~\ESC\222E\156\152\245b\135",PropUserProperty "\217U\GS2\234\145" -// "\249\151\166\171\245N.<\164x\194",PropWillDelayInterval 13052,PropSharedSubscriptionAvailable -// 178,PropAssignedClientIdentifier "\248\EMC8m,8I\t\252\215",PropAssignedClientIdentifier -// "\v\140\238\&9\136e=\239\143>Qi\219\130\251T\251\143\244d\ETX\251"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\220\&2\138\ETX\145\167\209n\146\EOT\ACK\187\213\216b\156\231@\149\194\129", _pubPktID = 25900, _pubBody = "+;\SYN", +// _pubProps = [PropAuthenticationMethod "\195\EOT\243\165\152",PropSubscriptionIdentifierAvailable +// 98,PropAuthenticationMethod "\215\SI\221\162#\222\249#\131",PropReasonString +// "u\140\147\SYN\247ur\254\171\128\227R\ENQ\231\"\rG\225\198\217\205G/\173",PropResponseInformation +// "\206P\163",PropReasonString "(UAe\DEL\234\160\&4R\GS#q\218L\DC4\135H\129",PropSubscriptionIdentifierAvailable +// 81,PropResponseInformation "\232\189",PropAssignedClientIdentifier "\228.B\224Ey$g\202f",PropAuthenticationData +// "\149\ACK\139'\236\239m\191",PropMaximumQoS 220,PropAssignedClientIdentifier +// "b@\DEL\EM\144[-\181\162\157\199=\204",PropAuthenticationMethod +// "\169\&6\a\197\ACKV{C~\ACK\166\216u",PropServerReference +// "\148w%aR,\ENQh=1K\DC2\252\251\132\166LA",PropAssignedClientIdentifier "/\212]\208",PropReceiveMaximum 28597]} TEST(Publish5QCTest, Encode20) { uint8_t pkt[] = { - 0x3d, 0x94, 0x2, 0x0, 0x14, 0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, 0x55, 0xf, 0x30, 0x5b, - 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec, 0x50, 0x63, 0xe2, 0x1, 0x16, 0x0, 0x15,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 0xb, 0xf8, 0x19, 0x43, 0x38, 0x6d, 0x2c, 0x38, 0x49, 0x9, - 0xfc, 0xd7, 0x12, 0x0, 0x16, 0xb, 0x8c, 0xee, 0x39, 0x88, 0x65, 0x3d, 0xef, 0x8f, 0x3e, 0x51, 0x69, 0xdb, 0x82, - 0xfb, 0x54, 0xfb, 0x8f, 0xf4, 0x64, 0x3, 0xfb, 0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, - 0x2d, 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; - uint8_t topic_bytes[] = {0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, - 0x55, 0xf, 0x30, 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + 0x34, 0xca, 0x1, 0x0, 0x15, 0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, 0xbb, 0xd5, 0xd8, + 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81, 0x65, 0x2c, 0xac, 0x1, 0x15, 0x0, 0x5, 0xc3, 0x4, 0xf3, 0xa5, 0x98, + 0x29, 0x62, 0x15, 0x0, 0x9, 0xd7, 0xf, 0xdd, 0xa2, 0x23, 0xde, 0xf9, 0x23, 0x83, 0x1f, 0x0, 0x18, 0x75, 0x8c, + 0x93, 0x16, 0xf7, 0x75, 0x72, 0xfe, 0xab, 0x80, 0xe3, 0x52, 0x5, 0xe7, 0x22, 0xd, 0x47, 0xe1, 0xc6, 0xd9, 0xcd, + 0x47, 0x2f, 0xad, 0x1a, 0x0, 0x3, 0xce, 0x50, 0xa3, 0x1f, 0x0, 0x12, 0x28, 0x55, 0x41, 0x65, 0x7f, 0xea, 0xa0, + 0x34, 0x52, 0x1d, 0x23, 0x71, 0xda, 0x4c, 0x14, 0x87, 0x48, 0x81, 0x29, 0x51, 0x1a, 0x0, 0x2, 0xe8, 0xbd, 0x12, + 0x0, 0xa, 0xe4, 0x2e, 0x42, 0xe0, 0x45, 0x79, 0x24, 0x67, 0xca, 0x66, 0x16, 0x0, 0x8, 0x95, 0x6, 0x8b, 0x27, + 0xec, 0xef, 0x6d, 0xbf, 0x24, 0xdc, 0x12, 0x0, 0xd, 0x62, 0x40, 0x7f, 0x19, 0x90, 0x5b, 0x2d, 0xb5, 0xa2, 0x9d, + 0xc7, 0x3d, 0xcc, 0x15, 0x0, 0xd, 0xa9, 0x36, 0x7, 0xc5, 0x6, 0x56, 0x7b, 0x43, 0x7e, 0x6, 0xa6, 0xd8, 0x75, + 0x1c, 0x0, 0x12, 0x94, 0x77, 0x25, 0x61, 0x52, 0x2c, 0x5, 0x68, 0x3d, 0x31, 0x4b, 0x12, 0xfc, 0xfb, 0x84, 0xa6, + 0x4c, 0x41, 0x12, 0x0, 0x4, 0x2f, 0xd4, 0x5d, 0xd0, 0x21, 0x6f, 0xb5, 0x2b, 0x3b, 0x16}; + uint8_t topic_bytes[] = {0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, + 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, 0x2d, - 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; + msg.retained = false; + uint8_t msg_bytes[] = {0x2b, 0x3b, 0x16}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; - - uint8_t bytesprops0[] = {0xbd, 0x3, 0xe9, 0xfe, 0x18, 0x10, 0x68, 0xc2, 0xa7, 0xa9, 0x5, - 0xbd, 0x52, 0x8e, 0xd0, 0xdb, 0x4b, 0x5f, 0x4c, 0x8e, 0x3c}; - uint8_t bytesprops1[] = {0xa, 0x61, 0x8f, 0x67, 0xf5, 0xf1, 0x83, 0x81, 0x53, 0xeb, 0x3a, 0x53, 0x86, 0x5c, 0x59, - 0x19, 0xb2, 0x6a, 0x6f, 0xb0, 0xfe, 0x7e, 0xa0, 0xf4, 0x62, 0x99, 0x3d, 0x4f, 0xdb, 0x86}; - uint8_t bytesprops2[] = {0x2b, 0x95, 0xa3, 0xde, 0x8d, 0xae, 0xb3, 0x17, 0x20, 0xd8, 0x72, - 0x2e, 0x52, 0x52, 0xb4, 0x23, 0x66, 0xe2, 0x28, 0x9c, 0x3b}; - uint8_t bytesprops3[] = {0x7d, 0x19, 0xfa, 0x66, 0x4, 0x34, 0xd8, 0xbb, 0x73, 0xdb, 0xd1, 0x88, 0x93, - 0xd8, 0x60, 0xe0, 0x6, 0xe8, 0x79, 0x74, 0xe7, 0xad, 0x6e, 0xf8, 0xb7, 0xc5}; - uint8_t bytesprops4[] = {0x2d, 0x7e, 0x1b, 0xde, 0x45, 0x9c, 0x98, 0xf5, 0x62, 0x87}; - uint8_t bytesprops6[] = {0xf9, 0x97, 0xa6, 0xab, 0xf5, 0x4e, 0x2e, 0x3c, 0xa4, 0x78, 0xc2}; - uint8_t bytesprops5[] = {0xd9, 0x55, 0x1d, 0x32, 0xea, 0x91}; - uint8_t bytesprops7[] = {0xf8, 0x19, 0x43, 0x38, 0x6d, 0x2c, 0x38, 0x49, 0x9, 0xfc, 0xd7}; - uint8_t bytesprops8[] = {0xb, 0x8c, 0xee, 0x39, 0x88, 0x65, 0x3d, 0xef, 0x8f, 0x3e, 0x51, - 0x69, 0xdb, 0x82, 0xfb, 0x54, 0xfb, 0x8f, 0xf4, 0x64, 0x3, 0xfb}; + msg.payload_len = 3; + + uint8_t bytesprops0[] = {0xc3, 0x4, 0xf3, 0xa5, 0x98}; + uint8_t bytesprops1[] = {0xd7, 0xf, 0xdd, 0xa2, 0x23, 0xde, 0xf9, 0x23, 0x83}; + uint8_t bytesprops2[] = {0x75, 0x8c, 0x93, 0x16, 0xf7, 0x75, 0x72, 0xfe, 0xab, 0x80, 0xe3, 0x52, + 0x5, 0xe7, 0x22, 0xd, 0x47, 0xe1, 0xc6, 0xd9, 0xcd, 0x47, 0x2f, 0xad}; + uint8_t bytesprops3[] = {0xce, 0x50, 0xa3}; + uint8_t bytesprops4[] = {0x28, 0x55, 0x41, 0x65, 0x7f, 0xea, 0xa0, 0x34, 0x52, + 0x1d, 0x23, 0x71, 0xda, 0x4c, 0x14, 0x87, 0x48, 0x81}; + uint8_t bytesprops5[] = {0xe8, 0xbd}; + uint8_t bytesprops6[] = {0xe4, 0x2e, 0x42, 0xe0, 0x45, 0x79, 0x24, 0x67, 0xca, 0x66}; + uint8_t bytesprops7[] = {0x95, 0x6, 0x8b, 0x27, 0xec, 0xef, 0x6d, 0xbf}; + uint8_t bytesprops8[] = {0x62, 0x40, 0x7f, 0x19, 0x90, 0x5b, 0x2d, 0xb5, 0xa2, 0x9d, 0xc7, 0x3d, 0xcc}; + uint8_t bytesprops9[] = {0xa9, 0x36, 0x7, 0xc5, 0x6, 0x56, 0x7b, 0x43, 0x7e, 0x6, 0xa6, 0xd8, 0x75}; + uint8_t bytesprops10[] = {0x94, 0x77, 0x25, 0x61, 0x52, 0x2c, 0x5, 0x68, 0x3d, + 0x31, 0x4b, 0x12, 0xfc, 0xfb, 0x84, 0xa6, 0x4c, 0x41}; + uint8_t bytesprops11[] = {0x2f, 0xd4, 0x5d, 0xd0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5515}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2239}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31006}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14324}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2368}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27506}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3430}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops5}, .v = {11, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13052}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28597}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 20579, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 25900, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "B&&P~\USwi\200\237U\SI0[8\205\ETX\US\171\236", _pubPktID = 20579, _pubBody = -// "\160|,\236\153`\132S\ETBj\210-v\ETB\US\246\DC4>iK\158\SOH\141\250", _pubProps = [PropAuthenticationData -// "\189\ETX\233\254\CAN\DLEh\194\167\169\ENQ\189R\142\208\219K_L\142<",PropMessageExpiryInterval -// 5515,PropReceiveMaximum 2239,PropContentType -// "\na\143g\245\241\131\129S\235:S\134\\Y\EM\178jo\176\254~\160\244b\153=O\219\134",PropRequestResponseInformation -// 81,PropTopicAliasMaximum 31006,PropRequestProblemInformation 9,PropServerKeepAlive -// 14324,PropSharedSubscriptionAvailable 46,PropMaximumPacketSize 2368,PropContentType "+\149\163\222\141\174\179\ETB -// \216r.RR\180#f\226(\156;",PropResponseTopic -// "}\EM\250f\EOT4\216\187s\219\209\136\147\216`\224\ACK\232yt\231\173n\248\183\197",PropMaximumPacketSize -// 27506,PropReceiveMaximum 3430,PropRetainAvailable 154,PropResponseTopic -// "-~\ESC\222E\156\152\245b\135",PropUserProperty "\217U\GS2\234\145" -// "\249\151\166\171\245N.<\164x\194",PropWillDelayInterval 13052,PropSharedSubscriptionAvailable -// 178,PropAssignedClientIdentifier "\248\EMC8m,8I\t\252\215",PropAssignedClientIdentifier -// "\v\140\238\&9\136e=\239\143>Qi\219\130\251T\251\143\244d\ETX\251"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\220\&2\138\ETX\145\167\209n\146\EOT\ACK\187\213\216b\156\231@\149\194\129", _pubPktID = 25900, _pubBody = "+;\SYN", +// _pubProps = [PropAuthenticationMethod "\195\EOT\243\165\152",PropSubscriptionIdentifierAvailable +// 98,PropAuthenticationMethod "\215\SI\221\162#\222\249#\131",PropReasonString +// "u\140\147\SYN\247ur\254\171\128\227R\ENQ\231\"\rG\225\198\217\205G/\173",PropResponseInformation +// "\206P\163",PropReasonString "(UAe\DEL\234\160\&4R\GS#q\218L\DC4\135H\129",PropSubscriptionIdentifierAvailable +// 81,PropResponseInformation "\232\189",PropAssignedClientIdentifier "\228.B\224Ey$g\202f",PropAuthenticationData +// "\149\ACK\139'\236\239m\191",PropMaximumQoS 220,PropAssignedClientIdentifier +// "b@\DEL\EM\144[-\181\162\157\199=\204",PropAuthenticationMethod +// "\169\&6\a\197\ACKV{C~\ACK\166\216u",PropServerReference +// "\148w%aR,\ENQh=1K\DC2\252\251\132\166LA",PropAssignedClientIdentifier "/\212]\208",PropReceiveMaximum 28597]} TEST(Publish5QCTest, Decode20) { uint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ea, 0xa0, + 0x34, 0x52, 0x1d, 0x23, 0x71, 0xda, 0x4c, 0x14, 0x87, 0x48, 0x81, 0x29, 0x51, 0x1a, 0x0, 0x2, 0xe8, 0xbd, 0x12, + 0x0, 0xa, 0xe4, 0x2e, 0x42, 0xe0, 0x45, 0x79, 0x24, 0x67, 0xca, 0x66, 0x16, 0x0, 0x8, 0x95, 0x6, 0x8b, 0x27, + 0xec, 0xef, 0x6d, 0xbf, 0x24, 0xdc, 0x12, 0x0, 0xd, 0x62, 0x40, 0x7f, 0x19, 0x90, 0x5b, 0x2d, 0xb5, 0xa2, 0x9d, + 0xc7, 0x3d, 0xcc, 0x15, 0x0, 0xd, 0xa9, 0x36, 0x7, 0xc5, 0x6, 0x56, 0x7b, 0x43, 0x7e, 0x6, 0xa6, 0xd8, 0x75, + 0x1c, 0x0, 0x12, 0x94, 0x77, 0x25, 0x61, 0x52, 0x2c, 0x5, 0x68, 0x3d, 0x31, 0x4b, 0x12, 0xfc, 0xfb, 0x84, 0xa6, + 0x4c, 0x41, 0x12, 0x0, 0x4, 0x2f, 0xd4, 0x5d, 0xd0, 0x21, 0x6f, 0xb5, 0x2b, 0x3b, 0x16}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4028,159 +4133,136 @@ TEST(Publish5QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x42, 0x26, 0x26, 0x50, 0x7e, 0x1f, 0x77, 0x69, 0xc8, 0xed, - 0x55, 0xf, 0x30, 0x5b, 0x38, 0xcd, 0x3, 0x1f, 0xab, 0xec}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa0, 0x7c, 0x2c, 0xec, 0x99, 0x60, 0x84, 0x53, 0x17, 0x6a, 0xd2, 0x2d, - 0x76, 0x17, 0x1f, 0xf6, 0x14, 0x3e, 0x69, 0x4b, 0x9e, 0x1, 0x8d, 0xfa}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, + 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2b, 0x3b, 0x16}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 20579); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 25900); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "Wo\249\180\STXZ\FS\218Co_\137a\140\&9^\232\186\143\230", _pubPktID = 10935, _pubBody = -// "\US\177vw\219K\147TS\150\&9", _pubProps = [PropRequestProblemInformation 50,PropMaximumQoS -// 128,PropRequestProblemInformation 117,PropSharedSubscriptionAvailable 34,PropRequestProblemInformation -// 176,PropResponseTopic "\138\239\224\170\217\195W\DLE\247\243\229\144JC\206\214\157\210\140y",PropServerReference -// "\GS{\211\DEL%TI\RS\240\157\133\241",PropCorrelationData "^\ENQ\SIt\179\r\175",PropTopicAliasMaximum -// 9980,PropSubscriptionIdentifier 13,PropRequestProblemInformation 141,PropRequestProblemInformation -// 157,PropServerKeepAlive 25125,PropServerReference -// "\152\177nW\NAK\203\176X0\170X\164\187\ACK\228H4\157F\245\SYN\206\164",PropAuthenticationData -// "\229OD^\140\223\EOT\DLE!=\183\138_\187\233.\162\v\166\131\221\fk@\205\251\219\225]",PropRequestProblemInformation -// 89,PropSharedSubscriptionAvailable 29,PropReasonString -// "2\EOT\150\DEL\143J\160\249\203\DC4K\228\210\181",PropServerReference -// "\218iml`u\n\149\238u\199\US\SYNP\STX\\\142~\232\237\DC12\249",PropReceiveMaximum -// 9895,PropSharedSubscriptionAvailable 120,PropSessionExpiryInterval 11586,PropMessageExpiryInterval -// 30889,PropSessionExpiryInterval 28738,PropReceiveMaximum 1634,PropUserProperty -// ".\171\187d\NUL\164\234?\f2\DLE\STXi\NULL\169\ENQh" "\183\140ND\184/\134",PropServerReference -// "\216\204\231\214^\SYNL\179",PropRetainAvailable 88,PropServerKeepAlive 19095]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\224", _pubPktID = 936, _pubBody = +// "6\245", _pubProps = [PropReasonString "\166\240\229cSm\228\224\238\155\244\a(\172",PropResponseInformation +// "\\\186\146\160mi\GS\217\ETXf\DEL\228\160\183\156\204\&7\a\152\232\179\253\182\246",PropAuthenticationData +// "\243*\210\USHX\142\129\193\167o\235}c\199\141",PropCorrelationData "\166\203\246\255\206@\180\228\188\EM7\211v +// ",PropSharedSubscriptionAvailable 173,PropSharedSubscriptionAvailable 56,PropWillDelayInterval +// 2519,PropAssignedClientIdentifier "",PropMaximumQoS 178,PropResponseInformation +// "\160n\142\131\154}\138\192\ETB}",PropUserProperty +// "8?\242\247\156CD\"\192\&4\222\175U\207&\186\231j\190Rx\202\220\151\192?\215\162" +// "\229'\225\142s\204\144\195\235*O\SOH8\a;8\183",PropWildcardSubscriptionAvailable 173,PropRetainAvailable +// 124,PropResponseInformation +// "\DLE)\214\150;\SO\249-.\150%\159\ETX@\SYN\131\ACK\229\248\ESC\208\&4s\182\ETB[A\r\187\235",PropUserProperty +// "\216\188\208\242\r\SUB\234\133\254\RS\254V\178T" +// "\174\142V^C\145\&0\DELy\176w\141\174\138i\251~\\Ui\132'",PropMaximumQoS 247]} TEST(Publish5QCTest, Encode21) { - uint8_t pkt[] = { - 0x3d, 0x99, 0x2, 0x0, 0x14, 0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, 0x5f, 0x89, 0x61, 0x8c, - 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6, 0x2a, 0xb7, 0xf4, 0x1, 0x17, 0x32, 0x24, 0x80, 0x17, 0x75, 0x2a, 0x22, 0x17, - 0xb0, 0x8, 0x0, 0x14, 0x8a, 0xef, 0xe0, 0xaa, 0xd9, 0xc3, 0x57, 0x10, 0xf7, 0xf3, 0xe5, 0x90, 0x4a, 0x43, 0xce, - 0xd6, 0x9d, 0xd2, 0x8c, 0x79, 0x1c, 0x0, 0xc, 0x1d, 0x7b, 0xd3, 0x7f, 0x25, 0x54, 0x49, 0x1e, 0xf0, 0x9d, 0x85, - 0xf1, 0x9, 0x0, 0x7, 0x5e, 0x5, 0xf, 0x74, 0xb3, 0xd, 0xaf, 0x22, 0x26, 0xfc, 0xb, 0xd, 0x17, 0x8d, 0x17, - 0x9d, 0x13, 0x62, 0x25, 0x1c, 0x0, 0x17, 0x98, 0xb1, 0x6e, 0x57, 0x15, 0xcb, 0xb0, 0x58, 0x30, 0xaa, 0x58, 0xa4, - 0xbb, 0x6, 0xe4, 0x48, 0x34, 0x9d, 0x46, 0xf5, 0x16, 0xce, 0xa4, 0x16, 0x0, 0x1d, 0xe5, 0x4f, 0x44, 0x5e, 0x8c, - 0xdf, 0x4, 0x10, 0x21, 0x3d, 0xb7, 0x8a, 0x5f, 0xbb, 0xe9, 0x2e, 0xa2, 0xb, 0xa6, 0x83, 0xdd, 0xc, 0x6b, 0x40, - 0xcd, 0xfb, 0xdb, 0xe1, 0x5d, 0x17, 0x59, 0x2a, 0x1d, 0x1f, 0x0, 0xe, 0x32, 0x4, 0x96, 0x7f, 0x8f, 0x4a, 0xa0, - 0xf9, 0xcb, 0x14, 0x4b, 0xe4, 0xd2, 0xb5, 0x1c, 0x0, 0x17, 0xda, 0x69, 0x6d, 0x6c, 0x60, 0x75, 0xa, 0x95, 0xee, - 0x75, 0xc7, 0x1f, 0x16, 0x50, 0x2, 0x5c, 0x8e, 0x7e, 0xe8, 0xed, 0x11, 0x32, 0xf9, 0x21, 0x26, 0xa7, 0x2a, 0x78, - 0x11, 0x0, 0x0, 0x2d, 0x42, 0x2, 0x0, 0x0, 0x78, 0xa9, 0x11, 0x0, 0x0, 0x70, 0x42, 0x21, 0x6, 0x62, 0x26, - 0x0, 0x12, 0x2e, 0xab, 0xbb, 0x64, 0x0, 0xa4, 0xea, 0x3f, 0xc, 0x32, 0x10, 0x2, 0x69, 0x0, 0x4c, 0xa9, 0x5, - 0x68, 0x0, 0x7, 0xb7, 0x8c, 0x4e, 0x44, 0xb8, 0x2f, 0x86, 0x1c, 0x0, 0x8, 0xd8, 0xcc, 0xe7, 0xd6, 0x5e, 0x16, - 0x4c, 0xb3, 0x25, 0x58, 0x13, 0x4a, 0x97, 0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; - uint8_t topic_bytes[] = {0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, - 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0xf6, 0x1, 0x0, 0x1, 0xe0, 0x3, 0xa8, 0xed, 0x1, 0x1f, 0x0, 0xe, 0xa6, 0xf0, 0xe5, 0x63, + 0x53, 0x6d, 0xe4, 0xe0, 0xee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0, 0xe, 0xd8, 0xbc, 0xd0, 0xf2, 0xd, 0x1a, 0xea, 0x85, 0xfe, 0x1e, 0xfe, 0x56, 0xb2, 0x54, + 0x0, 0x16, 0xae, 0x8e, 0x56, 0x5e, 0x43, 0x91, 0x30, 0x7f, 0x79, 0xb0, 0x77, 0x8d, 0xae, 0x8a, 0x69, + 0xfb, 0x7e, 0x5c, 0x55, 0x69, 0x84, 0x27, 0x24, 0xf7, 0x36, 0xf5}; + uint8_t topic_bytes[] = {0xe0}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x36, 0xf5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 2; - uint8_t bytesprops0[] = {0x8a, 0xef, 0xe0, 0xaa, 0xd9, 0xc3, 0x57, 0x10, 0xf7, 0xf3, - 0xe5, 0x90, 0x4a, 0x43, 0xce, 0xd6, 0x9d, 0xd2, 0x8c, 0x79}; - uint8_t bytesprops1[] = {0x1d, 0x7b, 0xd3, 0x7f, 0x25, 0x54, 0x49, 0x1e, 0xf0, 0x9d, 0x85, 0xf1}; - uint8_t bytesprops2[] = {0x5e, 0x5, 0xf, 0x74, 0xb3, 0xd, 0xaf}; - uint8_t bytesprops3[] = {0x98, 0xb1, 0x6e, 0x57, 0x15, 0xcb, 0xb0, 0x58, 0x30, 0xaa, 0x58, 0xa4, - 0xbb, 0x6, 0xe4, 0x48, 0x34, 0x9d, 0x46, 0xf5, 0x16, 0xce, 0xa4}; - uint8_t bytesprops4[] = {0xe5, 0x4f, 0x44, 0x5e, 0x8c, 0xdf, 0x4, 0x10, 0x21, 0x3d, 0xb7, 0x8a, 0x5f, 0xbb, 0xe9, - 0x2e, 0xa2, 0xb, 0xa6, 0x83, 0xdd, 0xc, 0x6b, 0x40, 0xcd, 0xfb, 0xdb, 0xe1, 0x5d}; - uint8_t bytesprops5[] = {0x32, 0x4, 0x96, 0x7f, 0x8f, 0x4a, 0xa0, 0xf9, 0xcb, 0x14, 0x4b, 0xe4, 0xd2, 0xb5}; - uint8_t bytesprops6[] = {0xda, 0x69, 0x6d, 0x6c, 0x60, 0x75, 0xa, 0x95, 0xee, 0x75, 0xc7, 0x1f, - 0x16, 0x50, 0x2, 0x5c, 0x8e, 0x7e, 0xe8, 0xed, 0x11, 0x32, 0xf9}; - uint8_t bytesprops8[] = {0xb7, 0x8c, 0x4e, 0x44, 0xb8, 0x2f, 0x86}; - uint8_t bytesprops7[] = {0x2e, 0xab, 0xbb, 0x64, 0x0, 0xa4, 0xea, 0x3f, 0xc, - 0x32, 0x10, 0x2, 0x69, 0x0, 0x4c, 0xa9, 0x5, 0x68}; - uint8_t bytesprops9[] = {0xd8, 0xcc, 0xe7, 0xd6, 0x5e, 0x16, 0x4c, 0xb3}; + uint8_t bytesprops0[] = {0xa6, 0xf0, 0xe5, 0x63, 0x53, 0x6d, 0xe4, 0xe0, 0xee, 0x9b, 0xf4, 0x7, 0x28, 0xac}; + uint8_t bytesprops1[] = {0x5c, 0xba, 0x92, 0xa0, 0x6d, 0x69, 0x1d, 0xd9, 0x3, 0x66, 0x7f, 0xe4, + 0xa0, 0xb7, 0x9c, 0xcc, 0x37, 0x7, 0x98, 0xe8, 0xb3, 0xfd, 0xb6, 0xf6}; + uint8_t bytesprops2[] = {0xf3, 0x2a, 0xd2, 0x1f, 0x48, 0x58, 0x8e, 0x81, + 0xc1, 0xa7, 0x6f, 0xeb, 0x7d, 0x63, 0xc7, 0x8d}; + uint8_t bytesprops3[] = {0xa6, 0xcb, 0xf6, 0xff, 0xce, 0x40, 0xb4, 0xe4, 0xbc, 0x19, 0x37, 0xd3, 0x76, 0x20}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0xa0, 0x6e, 0x8e, 0x83, 0x9a, 0x7d, 0x8a, 0xc0, 0x17, 0x7d}; + uint8_t bytesprops7[] = {0xe5, 0x27, 0xe1, 0x8e, 0x73, 0xcc, 0x90, 0xc3, 0xeb, + 0x2a, 0x4f, 0x1, 0x38, 0x7, 0x3b, 0x38, 0xb7}; + uint8_t bytesprops6[] = {0x38, 0x3f, 0xf2, 0xf7, 0x9c, 0x43, 0x44, 0x22, 0xc0, 0x34, 0xde, 0xaf, 0x55, 0xcf, + 0x26, 0xba, 0xe7, 0x6a, 0xbe, 0x52, 0x78, 0xca, 0xdc, 0x97, 0xc0, 0x3f, 0xd7, 0xa2}; + uint8_t bytesprops8[] = {0x10, 0x29, 0xd6, 0x96, 0x3b, 0xe, 0xf9, 0x2d, 0x2e, 0x96, 0x25, 0x9f, 0x3, 0x40, 0x16, + 0x83, 0x6, 0xe5, 0xf8, 0x1b, 0xd0, 0x34, 0x73, 0xb6, 0x17, 0x5b, 0x41, 0xd, 0xbb, 0xeb}; + uint8_t bytesprops10[] = {0xae, 0x8e, 0x56, 0x5e, 0x43, 0x91, 0x30, 0x7f, 0x79, 0xb0, 0x77, + 0x8d, 0xae, 0x8a, 0x69, 0xfb, 0x7e, 0x5c, 0x55, 0x69, 0x84, 0x27}; + uint8_t bytesprops9[] = {0xd8, 0xbc, 0xd0, 0xf2, 0xd, 0x1a, 0xea, 0x85, 0xfe, 0x1e, 0xfe, 0x56, 0xb2, 0x54}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9980}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25125}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9895}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11586}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30889}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28738}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1634}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops7}, .v = {7, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19095}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2519}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops6}, .v = {17, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops9}, .v = {22, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 247}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10935, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 936, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "Wo\249\180\STXZ\FS\218Co_\137a\140\&9^\232\186\143\230", _pubPktID = 10935, _pubBody = -// "\US\177vw\219K\147TS\150\&9", _pubProps = [PropRequestProblemInformation 50,PropMaximumQoS -// 128,PropRequestProblemInformation 117,PropSharedSubscriptionAvailable 34,PropRequestProblemInformation -// 176,PropResponseTopic "\138\239\224\170\217\195W\DLE\247\243\229\144JC\206\214\157\210\140y",PropServerReference -// "\GS{\211\DEL%TI\RS\240\157\133\241",PropCorrelationData "^\ENQ\SIt\179\r\175",PropTopicAliasMaximum -// 9980,PropSubscriptionIdentifier 13,PropRequestProblemInformation 141,PropRequestProblemInformation -// 157,PropServerKeepAlive 25125,PropServerReference -// "\152\177nW\NAK\203\176X0\170X\164\187\ACK\228H4\157F\245\SYN\206\164",PropAuthenticationData -// "\229OD^\140\223\EOT\DLE!=\183\138_\187\233.\162\v\166\131\221\fk@\205\251\219\225]",PropRequestProblemInformation -// 89,PropSharedSubscriptionAvailable 29,PropReasonString -// "2\EOT\150\DEL\143J\160\249\203\DC4K\228\210\181",PropServerReference -// "\218iml`u\n\149\238u\199\US\SYNP\STX\\\142~\232\237\DC12\249",PropReceiveMaximum -// 9895,PropSharedSubscriptionAvailable 120,PropSessionExpiryInterval 11586,PropMessageExpiryInterval -// 30889,PropSessionExpiryInterval 28738,PropReceiveMaximum 1634,PropUserProperty -// ".\171\187d\NUL\164\234?\f2\DLE\STXi\NULL\169\ENQh" "\183\140ND\184/\134",PropServerReference -// "\216\204\231\214^\SYNL\179",PropRetainAvailable 88,PropServerKeepAlive 19095]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\224", _pubPktID = 936, _pubBody = +// "6\245", _pubProps = [PropReasonString "\166\240\229cSm\228\224\238\155\244\a(\172",PropResponseInformation +// "\\\186\146\160mi\GS\217\ETXf\DEL\228\160\183\156\204\&7\a\152\232\179\253\182\246",PropAuthenticationData +// "\243*\210\USHX\142\129\193\167o\235}c\199\141",PropCorrelationData "\166\203\246\255\206@\180\228\188\EM7\211v +// ",PropSharedSubscriptionAvailable 173,PropSharedSubscriptionAvailable 56,PropWillDelayInterval +// 2519,PropAssignedClientIdentifier "",PropMaximumQoS 178,PropResponseInformation +// "\160n\142\131\154}\138\192\ETB}",PropUserProperty +// "8?\242\247\156CD\"\192\&4\222\175U\207&\186\231j\190Rx\202\220\151\192?\215\162" +// "\229'\225\142s\204\144\195\235*O\SOH8\a;8\183",PropWildcardSubscriptionAvailable 173,PropRetainAvailable +// 124,PropResponseInformation +// "\DLE)\214\150;\SO\249-.\150%\159\ETX@\SYN\131\ACK\229\248\ESC\208\&4s\182\ETB[A\r\187\235",PropUserProperty +// "\216\188\208\242\r\SUB\234\133\254\RS\254V\178T" +// "\174\142V^C\145\&0\DELy\176w\141\174\138i\251~\\Ui\132'",PropMaximumQoS 247]} TEST(Publish5QCTest, Decode21) { - uint8_t pkt[] = { - 0x3d, 0x99, 0x2, 0x0, 0x14, 0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, 0x5f, 0x89, 0x61, 0x8c, - 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6, 0x2a, 0xb7, 0xf4, 0x1, 0x17, 0x32, 0x24, 0x80, 0x17, 0x75, 0x2a, 0x22, 0x17, - 0xb0, 0x8, 0x0, 0x14, 0x8a, 0xef, 0xe0, 0xaa, 0xd9, 0xc3, 0x57, 0x10, 0xf7, 0xf3, 0xe5, 0x90, 0x4a, 0x43, 0xce, - 0xd6, 0x9d, 0xd2, 0x8c, 0x79, 0x1c, 0x0, 0xc, 0x1d, 0x7b, 0xd3, 0x7f, 0x25, 0x54, 0x49, 0x1e, 0xf0, 0x9d, 0x85, - 0xf1, 0x9, 0x0, 0x7, 0x5e, 0x5, 0xf, 0x74, 0xb3, 0xd, 0xaf, 0x22, 0x26, 0xfc, 0xb, 0xd, 0x17, 0x8d, 0x17, - 0x9d, 0x13, 0x62, 0x25, 0x1c, 0x0, 0x17, 0x98, 0xb1, 0x6e, 0x57, 0x15, 0xcb, 0xb0, 0x58, 0x30, 0xaa, 0x58, 0xa4, - 0xbb, 0x6, 0xe4, 0x48, 0x34, 0x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, 0xeb, + 0x26, 0x0, 0xe, 0xd8, 0xbc, 0xd0, 0xf2, 0xd, 0x1a, 0xea, 0x85, 0xfe, 0x1e, 0xfe, 0x56, 0xb2, 0x54, + 0x0, 0x16, 0xae, 0x8e, 0x56, 0x5e, 0x43, 0x91, 0x30, 0x7f, 0x79, 0xb0, 0x77, 0x8d, 0xae, 0x8a, 0x69, + 0xfb, 0x7e, 0x5c, 0x55, 0x69, 0x84, 0x27, 0x24, 0xf7, 0x36, 0xf5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4188,72 +4270,96 @@ TEST(Publish5QCTest, Decode21) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x57, 0x6f, 0xf9, 0xb4, 0x2, 0x5a, 0x1c, 0xda, 0x43, 0x6f, - 0x5f, 0x89, 0x61, 0x8c, 0x39, 0x5e, 0xe8, 0xba, 0x8f, 0xe6}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1f, 0xb1, 0x76, 0x77, 0xdb, 0x4b, 0x93, 0x54, 0x53, 0x96, 0x39}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xe0}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x36, 0xf5}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 10935); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 936); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "z\187}l", _pubPktID = 11378, -// _pubBody = "\186\&7\190\f\178\235\212\242\166(\ENQ\181\SUB\234\&4\149H\SYN6\197\247\207", _pubProps = -// [PropMessageExpiryInterval 17405,PropTopicAlias 796,PropSubscriptionIdentifier 9,PropReasonString -// "\189\150\149\164v",PropMaximumPacketSize 27577,PropRetainAvailable 102,PropMaximumPacketSize 1224]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "E\177\160\226\133O\252!\"\251\129\164{\STX\178\165g\229E\168\162\209>N\STXWn\191\235", _pubPktID = 0, _pubBody = +// "t\139\164\144a\157:\239\157\145M\SI\t\162\DC1\194D\143\134", _pubProps = [PropContentType +// "\aB\249\179\ESC\SOH\193\252\164f\136\224",PropRequestResponseInformation 214,PropReceiveMaximum +// 4070,PropSubscriptionIdentifierAvailable 193,PropRequestProblemInformation 237,PropSharedSubscriptionAvailable +// 176,PropPayloadFormatIndicator 69,PropSessionExpiryInterval 30221,PropSubscriptionIdentifierAvailable +// 79,PropMessageExpiryInterval 25509,PropAuthenticationData +// "\131\231\181\168G\US>\238V\138\\F>B|\133\233\175",PropTopicAliasMaximum 2402,PropRetainAvailable 204]} TEST(Publish5QCTest, Encode22) { - uint8_t pkt[] = {0x34, 0x3d, 0x0, 0x4, 0x7a, 0xbb, 0x7d, 0x6c, 0x2c, 0x72, 0x1e, 0x2, 0x0, 0x0, 0x43, 0xfd, - 0x23, 0x3, 0x1c, 0xb, 0x9, 0x1f, 0x0, 0x5, 0xbd, 0x96, 0x95, 0xa4, 0x76, 0x27, 0x0, 0x0, - 0x6b, 0xb9, 0x25, 0x66, 0x27, 0x0, 0x0, 0x4, 0xc8, 0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, - 0xf2, 0xa6, 0x28, 0x5, 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; - uint8_t topic_bytes[] = {0x7a, 0xbb, 0x7d, 0x6c}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x75, 0x0, 0x1d, 0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, + 0xa4, 0x7b, 0x2, 0xb2, 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, + 0x6e, 0xbf, 0xeb, 0x42, 0x3, 0x0, 0xc, 0x7, 0x42, 0xf9, 0xb3, 0x1b, 0x1, 0xc1, 0xfc, + 0xa4, 0x66, 0x88, 0xe0, 0x19, 0xd6, 0x21, 0xf, 0xe6, 0x29, 0xc1, 0x17, 0xed, 0x2a, 0xb0, + 0x1, 0x45, 0x11, 0x0, 0x0, 0x76, 0xd, 0x29, 0x4f, 0x2, 0x0, 0x0, 0x63, 0xa5, 0x16, + 0x0, 0x12, 0x83, 0xe7, 0xb5, 0xa8, 0x47, 0x1f, 0x3e, 0xee, 0x56, 0x8a, 0x5c, 0x46, 0x3e, + 0x42, 0x7c, 0x85, 0xe9, 0xaf, 0x22, 0x9, 0x62, 0x25, 0xcc, 0x74, 0x8b, 0xa4, 0x90, 0x61, + 0x9d, 0x3a, 0xef, 0x9d, 0x91, 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; + uint8_t topic_bytes[] = {0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, + 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, 0xf2, 0xa6, 0x28, 0x5, - 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; + uint8_t msg_bytes[] = {0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, 0x3a, 0xef, 0x9d, 0x91, + 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 19; - uint8_t bytesprops0[] = {0xbd, 0x96, 0x95, 0xa4, 0x76}; + uint8_t bytesprops0[] = {0x7, 0x42, 0xf9, 0xb3, 0x1b, 0x1, 0xc1, 0xfc, 0xa4, 0x66, 0x88, 0xe0}; + uint8_t bytesprops1[] = {0x83, 0xe7, 0xb5, 0xa8, 0x47, 0x1f, 0x3e, 0xee, 0x56, + 0x8a, 0x5c, 0x46, 0x3e, 0x42, 0x7c, 0x85, 0xe9, 0xaf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17405}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 796}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27577}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1224}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4070}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30221}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25509}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2402}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 11378, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "z\187}l", _pubPktID = 11378, -// _pubBody = "\186\&7\190\f\178\235\212\242\166(\ENQ\181\SUB\234\&4\149H\SYN6\197\247\207", _pubProps = -// [PropMessageExpiryInterval 17405,PropTopicAlias 796,PropSubscriptionIdentifier 9,PropReasonString -// "\189\150\149\164v",PropMaximumPacketSize 27577,PropRetainAvailable 102,PropMaximumPacketSize 1224]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "E\177\160\226\133O\252!\"\251\129\164{\STX\178\165g\229E\168\162\209>N\STXWn\191\235", _pubPktID = 0, _pubBody = +// "t\139\164\144a\157:\239\157\145M\SI\t\162\DC1\194D\143\134", _pubProps = [PropContentType +// "\aB\249\179\ESC\SOH\193\252\164f\136\224",PropRequestResponseInformation 214,PropReceiveMaximum +// 4070,PropSubscriptionIdentifierAvailable 193,PropRequestProblemInformation 237,PropSharedSubscriptionAvailable +// 176,PropPayloadFormatIndicator 69,PropSessionExpiryInterval 30221,PropSubscriptionIdentifierAvailable +// 79,PropMessageExpiryInterval 25509,PropAuthenticationData +// "\131\231\181\168G\US>\238V\138\\F>B|\133\233\175",PropTopicAliasMaximum 2402,PropRetainAvailable 204]} TEST(Publish5QCTest, Decode22) { - uint8_t pkt[] = {0x34, 0x3d, 0x0, 0x4, 0x7a, 0xbb, 0x7d, 0x6c, 0x2c, 0x72, 0x1e, 0x2, 0x0, 0x0, 0x43, 0xfd, - 0x23, 0x3, 0x1c, 0xb, 0x9, 0x1f, 0x0, 0x5, 0xbd, 0x96, 0x95, 0xa4, 0x76, 0x27, 0x0, 0x0, - 0x6b, 0xb9, 0x25, 0x66, 0x27, 0x0, 0x0, 0x4, 0xc8, 0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, - 0xf2, 0xa6, 0x28, 0x5, 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; + uint8_t pkt[] = {0x30, 0x75, 0x0, 0x1d, 0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, + 0xa4, 0x7b, 0x2, 0xb2, 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, + 0x6e, 0xbf, 0xeb, 0x42, 0x3, 0x0, 0xc, 0x7, 0x42, 0xf9, 0xb3, 0x1b, 0x1, 0xc1, 0xfc, + 0xa4, 0x66, 0x88, 0xe0, 0x19, 0xd6, 0x21, 0xf, 0xe6, 0x29, 0xc1, 0x17, 0xed, 0x2a, 0xb0, + 0x1, 0x45, 0x11, 0x0, 0x0, 0x76, 0xd, 0x29, 0x4f, 0x2, 0x0, 0x0, 0x63, 0xa5, 0x16, + 0x0, 0x12, 0x83, 0xe7, 0xb5, 0xa8, 0x47, 0x1f, 0x3e, 0xee, 0x56, 0x8a, 0x5c, 0x46, 0x3e, + 0x42, 0x7c, 0x85, 0xe9, 0xaf, 0x22, 0x9, 0x62, 0x25, 0xcc, 0x74, 0x8b, 0xa4, 0x90, 0x61, + 0x9d, 0x3a, 0xef, 0x9d, 0x91, 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4261,151 +4367,90 @@ TEST(Publish5QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7a, 0xbb, 0x7d, 0x6c}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xba, 0x37, 0xbe, 0xc, 0xb2, 0xeb, 0xd4, 0xf2, 0xa6, 0x28, 0x5, - 0xb5, 0x1a, 0xea, 0x34, 0x95, 0x48, 0x16, 0x36, 0xc5, 0xf7, 0xcf}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, + 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, 0x3a, 0xef, 0x9d, 0x91, + 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 11378); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\252\190\&8\149\&2\128\192{C\128\194\197\170g\a_\DC4\DELI(\151\218\172\vBJ\234\221", _pubPktID = 0, _pubBody = -// "q\145\203\144\245\153\&3\220g\186\&9YVh\DEL\232\&2V\212\201\&4\172?\189S\159<\187W", _pubProps = -// [PropWildcardSubscriptionAvailable 68,PropReasonString "\231\STX\217\206C\164",PropServerKeepAlive -// 28798,PropAuthenticationData "\202\ETX1\130\NUL\184r\147\SYN\162\182)\226\v!m",PropRequestResponseInformation -// 255,PropContentType "\RS\STX\200B\190",PropResponseTopic "\218{",PropTopicAlias -// 31640,PropSubscriptionIdentifierAvailable 99,PropServerKeepAlive 9138,PropAuthenticationMethod -// "\240'\176\DC2=\ENQ\247H\176`\247\SOH\151Dj\220\GS4\132",PropUserProperty -// "`\157;)\RS\168\170G\SI\131\204z\251\SO#-\221tq\224" -// "DQ\194\246\165\220\230\217\222\SUB\160E\213P\"\156\211",PropWillDelayInterval 4096,PropRequestResponseInformation -// 25,PropReceiveMaximum 26707,PropAssignedClientIdentifier "e]\166a",PropAuthenticationMethod -// "\236\135\179\164I\DLEm\GS\189\155inmB",PropMessageExpiryInterval 8438,PropSharedSubscriptionAvailable -// 26,PropSubscriptionIdentifierAvailable 221,PropUserProperty "Q&z\242\130#\206\&2\225N\236\181d\233" -// "\182/^\246\211CZ\255",PropContentType -// "n\219S\144\134\181\223\145\184\193X\245\193\231\186\&3k\159\188\218\252\SUB\221\244zbNt3"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\208\167\232\STX\DLE\GSQr\146|", +// _pubPktID = 8189, _pubBody = "c`\ESC\156x\229(\255\178\168\214\240a\217\197\224\170\174\&48pk\NAK\200\ETX\130\235", +// _pubProps = [PropPayloadFormatIndicator 219,PropServerKeepAlive 25155,PropCorrelationData +// "\v\224\240\182",PropRetainAvailable 10,PropAssignedClientIdentifier +// "\173\DEL\168\159v\DLEi\203\212\235@\221\181c\129\178\201\251\135\NUL\190\188bc>\195c",PropTopicAlias +// 18173,PropSessionExpiryInterval 627,PropResponseInformation "[j\202B\212|\237\252\207",PropRequestResponseInformation +// 209]} TEST(Publish5QCTest, Encode23) { - uint8_t pkt[] = {0x39, 0x9b, 0x2, 0x0, 0x1c, 0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, - 0xaa, 0x67, 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd, 0xde, - 0x1, 0x28, 0x44, 0x1f, 0x0, 0x6, 0xe7, 0x2, 0xd9, 0xce, 0x43, 0xa4, 0x13, 0x70, 0x7e, 0x16, 0x0, - 0x10, 0xca, 0x3, 0x31, 0x82, 0x0, 0xb8, 0x72, 0x93, 0x16, 0xa2, 0xb6, 0x29, 0xe2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xf4, 0x7a, 0x62, 0x4e, - 0x74, 0x33, 0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, - 0xe8, 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; - uint8_t topic_bytes[] = {0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, 0xaa, 0x67, - 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x6c, 0x0, 0xa, 0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c, 0x1f, 0xfd, + 0x42, 0x1, 0xdb, 0x13, 0x62, 0x43, 0x9, 0x0, 0x4, 0xb, 0xe0, 0xf0, 0xb6, 0x25, 0xa, 0x12, + 0x0, 0x1b, 0xad, 0x7f, 0xa8, 0x9f, 0x76, 0x10, 0x69, 0xcb, 0xd4, 0xeb, 0x40, 0xdd, 0xb5, 0x63, + 0x81, 0xb2, 0xc9, 0xfb, 0x87, 0x0, 0xbe, 0xbc, 0x62, 0x63, 0x3e, 0xc3, 0x63, 0x23, 0x46, 0xfd, + 0x11, 0x0, 0x0, 0x2, 0x73, 0x1a, 0x0, 0x9, 0x5b, 0x6a, 0xca, 0x42, 0xd4, 0x7c, 0xed, 0xfc, + 0xcf, 0x19, 0xd1, 0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, + 0xd9, 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; + uint8_t topic_bytes[] = {0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, - 0xe8, 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, + 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; - - uint8_t bytesprops0[] = {0xe7, 0x2, 0xd9, 0xce, 0x43, 0xa4}; - uint8_t bytesprops1[] = {0xca, 0x3, 0x31, 0x82, 0x0, 0xb8, 0x72, 0x93, 0x16, 0xa2, 0xb6, 0x29, 0xe2, 0xb, 0x21, 0x6d}; - uint8_t bytesprops2[] = {0x1e, 0x2, 0xc8, 0x42, 0xbe}; - uint8_t bytesprops3[] = {0xda, 0x7b}; - uint8_t bytesprops4[] = {0xf0, 0x27, 0xb0, 0x12, 0x3d, 0x5, 0xf7, 0x48, 0xb0, 0x60, - 0xf7, 0x1, 0x97, 0x44, 0x6a, 0xdc, 0x1d, 0x34, 0x84}; - uint8_t bytesprops6[] = {0x44, 0x51, 0xc2, 0xf6, 0xa5, 0xdc, 0xe6, 0xd9, 0xde, - 0x1a, 0xa0, 0x45, 0xd5, 0x50, 0x22, 0x9c, 0xd3}; - uint8_t bytesprops5[] = {0x60, 0x9d, 0x3b, 0x29, 0x1e, 0xa8, 0xaa, 0x47, 0xf, 0x83, - 0xcc, 0x7a, 0xfb, 0xe, 0x23, 0x2d, 0xdd, 0x74, 0x71, 0xe0}; - uint8_t bytesprops7[] = {0x65, 0x5d, 0xa6, 0x61}; - uint8_t bytesprops8[] = {0xec, 0x87, 0xb3, 0xa4, 0x49, 0x10, 0x6d, 0x1d, 0xbd, 0x9b, 0x69, 0x6e, 0x6d, 0x42}; - uint8_t bytesprops10[] = {0xb6, 0x2f, 0x5e, 0xf6, 0xd3, 0x43, 0x5a, 0xff}; - uint8_t bytesprops9[] = {0x51, 0x26, 0x7a, 0xf2, 0x82, 0x23, 0xce, 0x32, 0xe1, 0x4e, 0xec, 0xb5, 0x64, 0xe9}; - uint8_t bytesprops11[] = {0x6e, 0xdb, 0x53, 0x90, 0x86, 0xb5, 0xdf, 0x91, 0xb8, 0xc1, 0x58, 0xf5, 0xc1, 0xe7, 0xba, - 0x33, 0x6b, 0x9f, 0xbc, 0xda, 0xfc, 0x1a, 0xdd, 0xf4, 0x7a, 0x62, 0x4e, 0x74, 0x33}; + msg.payload_len = 27; + + uint8_t bytesprops0[] = {0xb, 0xe0, 0xf0, 0xb6}; + uint8_t bytesprops1[] = {0xad, 0x7f, 0xa8, 0x9f, 0x76, 0x10, 0x69, 0xcb, 0xd4, 0xeb, 0x40, 0xdd, 0xb5, 0x63, + 0x81, 0xb2, 0xc9, 0xfb, 0x87, 0x0, 0xbe, 0xbc, 0x62, 0x63, 0x3e, 0xc3, 0x63}; + uint8_t bytesprops2[] = {0x5b, 0x6a, 0xca, 0x42, 0xd4, 0x7c, 0xed, 0xfc, 0xcf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28798}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31640}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9138}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops5}, .v = {17, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4096}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26707}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8438}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops9}, .v = {8, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25155}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18173}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 627}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 209}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 8189, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\252\190\&8\149\&2\128\192{C\128\194\197\170g\a_\DC4\DELI(\151\218\172\vBJ\234\221", _pubPktID = 0, _pubBody = -// "q\145\203\144\245\153\&3\220g\186\&9YVh\DEL\232\&2V\212\201\&4\172?\189S\159<\187W", _pubProps = -// [PropWildcardSubscriptionAvailable 68,PropReasonString "\231\STX\217\206C\164",PropServerKeepAlive -// 28798,PropAuthenticationData "\202\ETX1\130\NUL\184r\147\SYN\162\182)\226\v!m",PropRequestResponseInformation -// 255,PropContentType "\RS\STX\200B\190",PropResponseTopic "\218{",PropTopicAlias -// 31640,PropSubscriptionIdentifierAvailable 99,PropServerKeepAlive 9138,PropAuthenticationMethod -// "\240'\176\DC2=\ENQ\247H\176`\247\SOH\151Dj\220\GS4\132",PropUserProperty -// "`\157;)\RS\168\170G\SI\131\204z\251\SO#-\221tq\224" -// "DQ\194\246\165\220\230\217\222\SUB\160E\213P\"\156\211",PropWillDelayInterval 4096,PropRequestResponseInformation -// 25,PropReceiveMaximum 26707,PropAssignedClientIdentifier "e]\166a",PropAuthenticationMethod -// "\236\135\179\164I\DLEm\GS\189\155inmB",PropMessageExpiryInterval 8438,PropSharedSubscriptionAvailable -// 26,PropSubscriptionIdentifierAvailable 221,PropUserProperty "Q&z\242\130#\206\&2\225N\236\181d\233" -// "\182/^\246\211CZ\255",PropContentType -// "n\219S\144\134\181\223\145\184\193X\245\193\231\186\&3k\159\188\218\252\SUB\221\244zbNt3"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\208\167\232\STX\DLE\GSQr\146|", +// _pubPktID = 8189, _pubBody = "c`\ESC\156x\229(\255\178\168\214\240a\217\197\224\170\174\&48pk\NAK\200\ETX\130\235", +// _pubProps = [PropPayloadFormatIndicator 219,PropServerKeepAlive 25155,PropCorrelationData +// "\v\224\240\182",PropRetainAvailable 10,PropAssignedClientIdentifier +// "\173\DEL\168\159v\DLEi\203\212\235@\221\181c\129\178\201\251\135\NUL\190\188bc>\195c",PropTopicAlias +// 18173,PropSessionExpiryInterval 627,PropResponseInformation "[j\202B\212|\237\252\207",PropRequestResponseInformation +// 209]} TEST(Publish5QCTest, Decode23) { - uint8_t pkt[] = {0x39, 0x9b, 0x2, 0x0, 0x1c, 0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, - 0xaa, 0x67, 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd, 0xde, - 0x1, 0x28, 0x44, 0x1f, 0x0, 0x6, 0xe7, 0x2, 0xd9, 0xce, 0x43, 0xa4, 0x13, 0x70, 0x7e, 0x16, 0x0, - 0x10, 0xca, 0x3, 0x31, 0x82, 0x0, 0xb8, 0x72, 0x93, 0x16, 0xa2, 0xb6, 0x29, 0xe2, 0xb, 0x21, 0x6d, - 0x19, 0xff, 0x3, 0x0, 0x5, 0x1e, 0x2, 0xc8, 0x42, 0xbe, 0x8, 0x0, 0x2, 0xda, 0x7b, 0x23, 0x7b, - 0x98, 0x29, 0x63, 0x13, 0x23, 0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xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; + uint8_t pkt[] = {0x3a, 0x6c, 0x0, 0xa, 0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c, 0x1f, 0xfd, + 0x42, 0x1, 0xdb, 0x13, 0x62, 0x43, 0x9, 0x0, 0x4, 0xb, 0xe0, 0xf0, 0xb6, 0x25, 0xa, 0x12, + 0x0, 0x1b, 0xad, 0x7f, 0xa8, 0x9f, 0x76, 0x10, 0x69, 0xcb, 0xd4, 0xeb, 0x40, 0xdd, 0xb5, 0x63, + 0x81, 0xb2, 0xc9, 0xfb, 0x87, 0x0, 0xbe, 0xbc, 0x62, 0x63, 0x3e, 0xc3, 0x63, 0x23, 0x46, 0xfd, + 0x11, 0x0, 0x0, 0x2, 0x73, 0x1a, 0x0, 0x9, 0x5b, 0x6a, 0xca, 0x42, 0xd4, 0x7c, 0xed, 0xfc, + 0xcf, 0x19, 0xd1, 0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, + 0xd9, 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4413,90 +4458,69 @@ TEST(Publish5QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xfc, 0xbe, 0x38, 0x95, 0x32, 0x80, 0xc0, 0x7b, 0x43, 0x80, 0xc2, 0xc5, 0xaa, 0x67, - 0x7, 0x5f, 0x14, 0x7f, 0x49, 0x28, 0x97, 0xda, 0xac, 0xb, 0x42, 0x4a, 0xea, 0xdd}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x71, 0x91, 0xcb, 0x90, 0xf5, 0x99, 0x33, 0xdc, 0x67, 0xba, 0x39, 0x59, 0x56, 0x68, 0x7f, - 0xe8, 0x32, 0x56, 0xd4, 0xc9, 0x34, 0xac, 0x3f, 0xbd, 0x53, 0x9f, 0x3c, 0xbb, 0x57}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, + 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 8189); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\a\159\222j\236\175\242\&158\148@P\139o\150c\EOT\191\131\204\SUB\205\201\135W\193a", _pubPktID = 24983, _pubBody = -// "\214M\130;K\239#\136V\STX\242C\n\153\208l\129s\196\171\DC1P\193\218\128", _pubProps = [PropMaximumPacketSize -// 32111,PropRetainAvailable 32,PropRetainAvailable 253,PropTopicAliasMaximum 1404,PropCorrelationData -// "x\249\211d\150\172<\EM\159*\CAN\172\\\145\178\202jA",PropWillDelayInterval 999,PropTopicAliasMaximum -// 3052,PropResponseInformation "\244\153\172\&7\n\136=_\169\156S2\183\143\167S\185\220O\133\144\252\&4\230\180W\202"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "b\245\197\244\&04\214\&6*\178", +// _pubPktID = 0, _pubBody = "\184", _pubProps = [PropSubscriptionIdentifier 30,PropReasonString +// "7c\157K\v\162l\155?\162\133\203o\236\152!4\149\249\160\US\139\DEL^\130^\130",PropMessageExpiryInterval +// 346,PropTopicAliasMaximum 7985]} TEST(Publish5QCTest, Encode24) { - uint8_t pkt[] = {0x35, 0x81, 0x1, 0x0, 0x1c, 0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, - 0x50, 0x8b, 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61, 0x61, - 0x97, 0x47, 0x27, 0x0, 0x0, 0x7d, 0x6f, 0x25, 0x20, 0x25, 0xfd, 0x22, 0x5, 0x7c, 0x9, 0x0, 0x12, - 0x78, 0xf9, 0xd3, 0x64, 0x96, 0xac, 0x3c, 0x19, 0x9f, 0x2a, 0x18, 0xac, 0x5c, 0x91, 0xb2, 0xca, 0x6a, - 0x41, 0x18, 0x0, 0x0, 0x3, 0xe7, 0x22, 0xb, 0xec, 0x1a, 0x0, 0x1b, 0xf4, 0x99, 0xac, 0x37, 0xa, - 0x88, 0x3d, 0x5f, 0xa9, 0x9c, 0x53, 0x32, 0xb7, 0x8f, 0xa7, 0x53, 0xb9, 0xdc, 0x4f, 0x85, 0x90, 0xfc, - 0x34, 0xe6, 0xb4, 0x57, 0xca, 0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, - 0xa, 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; - uint8_t topic_bytes[] = {0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, 0x50, 0x8b, - 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x36, 0x0, 0xa, 0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2, + 0x28, 0xb, 0x1e, 0x1f, 0x0, 0x1b, 0x37, 0x63, 0x9d, 0x4b, 0xb, 0xa2, 0x6c, 0x9b, + 0x3f, 0xa2, 0x85, 0xcb, 0x6f, 0xec, 0x98, 0x21, 0x34, 0x95, 0xf9, 0xa0, 0x1f, 0x8b, + 0x7f, 0x5e, 0x82, 0x5e, 0x82, 0x2, 0x0, 0x0, 0x1, 0x5a, 0x22, 0x1f, 0x31, 0xb8}; + uint8_t topic_bytes[] = {0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, 0xa, - 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xb8}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 1; - uint8_t bytesprops0[] = {0x78, 0xf9, 0xd3, 0x64, 0x96, 0xac, 0x3c, 0x19, 0x9f, - 0x2a, 0x18, 0xac, 0x5c, 0x91, 0xb2, 0xca, 0x6a, 0x41}; - uint8_t bytesprops1[] = {0xf4, 0x99, 0xac, 0x37, 0xa, 0x88, 0x3d, 0x5f, 0xa9, 0x9c, 0x53, 0x32, 0xb7, 0x8f, - 0xa7, 0x53, 0xb9, 0xdc, 0x4f, 0x85, 0x90, 0xfc, 0x34, 0xe6, 0xb4, 0x57, 0xca}; + uint8_t bytesprops0[] = {0x37, 0x63, 0x9d, 0x4b, 0xb, 0xa2, 0x6c, 0x9b, 0x3f, 0xa2, 0x85, 0xcb, 0x6f, 0xec, + 0x98, 0x21, 0x34, 0x95, 0xf9, 0xa0, 0x1f, 0x8b, 0x7f, 0x5e, 0x82, 0x5e, 0x82}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32111}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1404}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 999}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3052}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 346}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7985}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24983, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\a\159\222j\236\175\242\&158\148@P\139o\150c\EOT\191\131\204\SUB\205\201\135W\193a", _pubPktID = 24983, _pubBody = -// "\214M\130;K\239#\136V\STX\242C\n\153\208l\129s\196\171\DC1P\193\218\128", _pubProps = [PropMaximumPacketSize -// 32111,PropRetainAvailable 32,PropRetainAvailable 253,PropTopicAliasMaximum 1404,PropCorrelationData -// "x\249\211d\150\172<\EM\159*\CAN\172\\\145\178\202jA",PropWillDelayInterval 999,PropTopicAliasMaximum -// 3052,PropResponseInformation "\244\153\172\&7\n\136=_\169\156S2\183\143\167S\185\220O\133\144\252\&4\230\180W\202"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "b\245\197\244\&04\214\&6*\178", +// _pubPktID = 0, _pubBody = "\184", _pubProps = [PropSubscriptionIdentifier 30,PropReasonString +// "7c\157K\v\162l\155?\162\133\203o\236\152!4\149\249\160\US\139\DEL^\130^\130",PropMessageExpiryInterval +// 346,PropTopicAliasMaximum 7985]} TEST(Publish5QCTest, Decode24) { - uint8_t pkt[] = {0x35, 0x81, 0x1, 0x0, 0x1c, 0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, - 0x50, 0x8b, 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61, 0x61, - 0x97, 0x47, 0x27, 0x0, 0x0, 0x7d, 0x6f, 0x25, 0x20, 0x25, 0xfd, 0x22, 0x5, 0x7c, 0x9, 0x0, 0x12, - 0x78, 0xf9, 0xd3, 0x64, 0x96, 0xac, 0x3c, 0x19, 0x9f, 0x2a, 0x18, 0xac, 0x5c, 0x91, 0xb2, 0xca, 0x6a, - 0x41, 0x18, 0x0, 0x0, 0x3, 0xe7, 0x22, 0xb, 0xec, 0x1a, 0x0, 0x1b, 0xf4, 0x99, 0xac, 0x37, 0xa, - 0x88, 0x3d, 0x5f, 0xa9, 0x9c, 0x53, 0x32, 0xb7, 0x8f, 0xa7, 0x53, 0xb9, 0xdc, 0x4f, 0x85, 0x90, 0xfc, - 0x34, 0xe6, 0xb4, 0x57, 0xca, 0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, - 0xa, 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; + uint8_t pkt[] = {0x38, 0x36, 0x0, 0xa, 0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2, + 0x28, 0xb, 0x1e, 0x1f, 0x0, 0x1b, 0x37, 0x63, 0x9d, 0x4b, 0xb, 0xa2, 0x6c, 0x9b, + 0x3f, 0xa2, 0x85, 0xcb, 0x6f, 0xec, 0x98, 0x21, 0x34, 0x95, 0xf9, 0xa0, 0x1f, 0x8b, + 0x7f, 0x5e, 0x82, 0x5e, 0x82, 0x2, 0x0, 0x0, 0x1, 0x5a, 0x22, 0x1f, 0x31, 0xb8}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4504,97 +4528,85 @@ TEST(Publish5QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7, 0x9f, 0xde, 0x6a, 0xec, 0xaf, 0xf2, 0x31, 0x35, 0x38, 0x94, 0x40, 0x50, 0x8b, - 0x6f, 0x96, 0x63, 0x4, 0xbf, 0x83, 0xcc, 0x1a, 0xcd, 0xc9, 0x87, 0x57, 0xc1, 0x61}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd6, 0x4d, 0x82, 0x3b, 0x4b, 0xef, 0x23, 0x88, 0x56, 0x2, 0xf2, 0x43, 0xa, - 0x99, 0xd0, 0x6c, 0x81, 0x73, 0xc4, 0xab, 0x11, 0x50, 0xc1, 0xda, 0x80}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 24983); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + uint8_t exp_topic_bytes[] = {0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb8}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "[5,\230\144\137\236\202\179\STX\t\201\234\136\166", _pubPktID = 10487, _pubBody = -// "\DLE\ACK\165~\155\217?\249\195\GS\145\179=i'\223Wd\159\248<\223$", _pubProps = [PropRequestProblemInformation -// 2,PropMessageExpiryInterval 7090,PropReceiveMaximum 29985,PropAssignedClientIdentifier -// "\160C\a\133\158\SIJ\234\136\148+\213\192\173\145\229\SYN\DC3\207",PropMaximumPacketSize -// 1098,PropSubscriptionIdentifier 14,PropCorrelationData -// "\134\FS\151\177\150V\134V6K\226\159\253\151|\130",PropResponseInformation -// "Xy\206_\178c\154\197\a\227<\169\NAK\CAN\178\ETX",PropMessageExpiryInterval 11931,PropTopicAlias 6873]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\200\170v\196", _pubPktID = 30063, +// _pubBody = "\RS(g\190(g%\FS\249\135\DC1S\250\ACK(N\CANHC\157\RSK\175\DEL\225\159", _pubProps = [PropRetainAvailable +// 155,PropRequestResponseInformation 86,PropResponseInformation "e\216\214f\152\213C\173",PropReasonString +// "(\131\DEL\DC12\229E\233\146$6\164\165\SO\148",PropResponseTopic +// "\248y\172\190\154^\221\DC3/\166\SO\193N3\164@HN\203\185\247\168\USR\RS\248R\241i\217",PropSharedSubscriptionAvailable +// 148,PropWildcardSubscriptionAvailable 183,PropWillDelayInterval 14294]} TEST(Publish5QCTest, Encode25) { - uint8_t pkt[] = {0x34, 0x80, 0x1, 0x0, 0xf, 0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, 0xc9, - 0xea, 0x88, 0xa6, 0x28, 0xf7, 0x55, 0x17, 0x2, 0x2, 0x0, 0x0, 0x1b, 0xb2, 0x21, 0x75, 0x21, 0x12, - 0x0, 0x13, 0xa0, 0x43, 0x7, 0x85, 0x9e, 0xf, 0x4a, 0xea, 0x88, 0x94, 0x2b, 0xd5, 0xc0, 0xad, 0x91, - 0xe5, 0x16, 0x13, 0xcf, 0x27, 0x0, 0x0, 0x4, 0x4a, 0xb, 0xe, 0x9, 0x0, 0x10, 0x86, 0x1c, 0x97, - 0xb1, 0x96, 0x56, 0x86, 0x56, 0x36, 0x4b, 0xe2, 0x9f, 0xfd, 0x97, 0x7c, 0x82, 0x1a, 0x0, 0x10, 0x58, - 0x79, 0xce, 0x5f, 0xb2, 0x63, 0x9a, 0xc5, 0x7, 0xe3, 0x3c, 0xa9, 0x15, 0x18, 0xb2, 0x3, 0x2, 0x0, - 0x0, 0x2e, 0x9b, 0x23, 0x1a, 0xd9, 0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, 0x1d, 0x91, - 0xb3, 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; - uint8_t topic_bytes[] = {0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, 0xc9, 0xea, 0x88, 0xa6}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x6e, 0x0, 0x4, 0xc8, 0xaa, 0x76, 0xc4, 0x75, 0x6f, 0x4b, 0x25, 0x9b, 0x19, 0x56, 0x1a, + 0x0, 0x8, 0x65, 0xd8, 0xd6, 0x66, 0x98, 0xd5, 0x43, 0xad, 0x1f, 0x0, 0xf, 0x28, 0x83, 0x7f, + 0x11, 0x32, 0xe5, 0x45, 0xe9, 0x92, 0x24, 0x36, 0xa4, 0xa5, 0xe, 0x94, 0x8, 0x0, 0x1e, 0xf8, + 0x79, 0xac, 0xbe, 0x9a, 0x5e, 0xdd, 0x13, 0x2f, 0xa6, 0xe, 0xc1, 0x4e, 0x33, 0xa4, 0x40, 0x48, + 0x4e, 0xcb, 0xb9, 0xf7, 0xa8, 0x1f, 0x52, 0x1e, 0xf8, 0x52, 0xf1, 0x69, 0xd9, 0x2a, 0x94, 0x28, + 0xb7, 0x18, 0x0, 0x0, 0x37, 0xd6, 0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, + 0x11, 0x53, 0xfa, 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; + uint8_t topic_bytes[] = {0xc8, 0xaa, 0x76, 0xc4}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, 0x1d, 0x91, 0xb3, - 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; + uint8_t msg_bytes[] = {0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, + 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 26; - uint8_t bytesprops0[] = {0xa0, 0x43, 0x7, 0x85, 0x9e, 0xf, 0x4a, 0xea, 0x88, 0x94, - 0x2b, 0xd5, 0xc0, 0xad, 0x91, 0xe5, 0x16, 0x13, 0xcf}; - uint8_t bytesprops1[] = {0x86, 0x1c, 0x97, 0xb1, 0x96, 0x56, 0x86, 0x56, - 0x36, 0x4b, 0xe2, 0x9f, 0xfd, 0x97, 0x7c, 0x82}; - uint8_t bytesprops2[] = {0x58, 0x79, 0xce, 0x5f, 0xb2, 0x63, 0x9a, 0xc5, - 0x7, 0xe3, 0x3c, 0xa9, 0x15, 0x18, 0xb2, 0x3}; + uint8_t bytesprops0[] = {0x65, 0xd8, 0xd6, 0x66, 0x98, 0xd5, 0x43, 0xad}; + uint8_t bytesprops1[] = {0x28, 0x83, 0x7f, 0x11, 0x32, 0xe5, 0x45, 0xe9, 0x92, 0x24, 0x36, 0xa4, 0xa5, 0xe, 0x94}; + uint8_t bytesprops2[] = {0xf8, 0x79, 0xac, 0xbe, 0x9a, 0x5e, 0xdd, 0x13, 0x2f, 0xa6, 0xe, 0xc1, 0x4e, 0x33, 0xa4, + 0x40, 0x48, 0x4e, 0xcb, 0xb9, 0xf7, 0xa8, 0x1f, 0x52, 0x1e, 0xf8, 0x52, 0xf1, 0x69, 0xd9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7090}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29985}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1098}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11931}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6873}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14294}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10487, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 30063, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "[5,\230\144\137\236\202\179\STX\t\201\234\136\166", _pubPktID = 10487, _pubBody = -// "\DLE\ACK\165~\155\217?\249\195\GS\145\179=i'\223Wd\159\248<\223$", _pubProps = [PropRequestProblemInformation -// 2,PropMessageExpiryInterval 7090,PropReceiveMaximum 29985,PropAssignedClientIdentifier -// "\160C\a\133\158\SIJ\234\136\148+\213\192\173\145\229\SYN\DC3\207",PropMaximumPacketSize -// 1098,PropSubscriptionIdentifier 14,PropCorrelationData -// "\134\FS\151\177\150V\134V6K\226\159\253\151|\130",PropResponseInformation -// "Xy\206_\178c\154\197\a\227<\169\NAK\CAN\178\ETX",PropMessageExpiryInterval 11931,PropTopicAlias 6873]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\200\170v\196", _pubPktID = 30063, +// _pubBody = "\RS(g\190(g%\FS\249\135\DC1S\250\ACK(N\CANHC\157\RSK\175\DEL\225\159", _pubProps = [PropRetainAvailable +// 155,PropRequestResponseInformation 86,PropResponseInformation "e\216\214f\152\213C\173",PropReasonString +// "(\131\DEL\DC12\229E\233\146$6\164\165\SO\148",PropResponseTopic +// "\248y\172\190\154^\221\DC3/\166\SO\193N3\164@HN\203\185\247\168\USR\RS\248R\241i\217",PropSharedSubscriptionAvailable +// 148,PropWildcardSubscriptionAvailable 183,PropWillDelayInterval 14294]} TEST(Publish5QCTest, Decode25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9a, 0x5e, 0xdd, 0x13, 0x2f, 0xa6, 0xe, 0xc1, 0x4e, 0x33, 0xa4, 0x40, 0x48, + 0x4e, 0xcb, 0xb9, 0xf7, 0xa8, 0x1f, 0x52, 0x1e, 0xf8, 0x52, 0xf1, 0x69, 0xd9, 0x2a, 0x94, 0x28, + 0xb7, 0x18, 0x0, 0x0, 0x37, 0xd6, 0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, + 0x11, 0x53, 0xfa, 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4602,124 +4614,136 @@ TEST(Publish5QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5b, 0x35, 0x2c, 0xe6, 0x90, 0x89, 0xec, 0xca, 0xb3, 0x2, 0x9, 0xc9, 0xea, 0x88, 0xa6}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x10, 0x6, 0xa5, 0x7e, 0x9b, 0xd9, 0x3f, 0xf9, 0xc3, 0x1d, 0x91, 0xb3, - 0x3d, 0x69, 0x27, 0xdf, 0x57, 0x64, 0x9f, 0xf8, 0x3c, 0xdf, 0x24}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xc8, 0xaa, 0x76, 0xc4}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, + 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10487); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 23); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); + EXPECT_EQ(packet_id, 30063); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "n\145", _pubPktID = 14089, _pubBody -// = "\210\210>L\150\rD\161j\204SG\219\226\165\205k\208\&4\ENQ\154t\DC1\148D:\US<\141\149", _pubProps = -// [PropPayloadFormatIndicator 11,PropAssignedClientIdentifier "\165\GSO\DELW\209\USY^",PropRequestResponseInformation -// 199,PropSubscriptionIdentifier 7,PropAssignedClientIdentifier "\233e\ACK\242\245\135\207\178\189",PropReasonString -// "\159+\203\173\DC3\r\216\165\200\SOH\226$h\171U\179=\189Pq%\211\188x\238\176\169a\201\DC3",PropResponseTopic -// "\ETX\231w+ \ETX\128\252W-\164\228FQ\198\231\140\149\128\US",PropWildcardSubscriptionAvailable -// 86,PropPayloadFormatIndicator 11,PropSubscriptionIdentifierAvailable 130,PropMessageExpiryInterval -// 14783,PropSubscriptionIdentifierAvailable 113,PropRetainAvailable 223,PropResponseInformation -// "\130\SYN2\226\210\n\165\220\STX\175\235j\STX\US",PropRequestProblemInformation 97,PropCorrelationData -// "t\237j\DLE6\227\210\EM\STX\NUL]\FS\215\FS\202w\250N\CAN\217\199\192+",PropReasonString -// "\176\vb\216s\FS\175cQIq6t\183#\170\149\149\218o"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\229<<\234;", _pubPktID = 0, +// _pubBody = "+ eK\208\CAN\232\179\167\129\227'Hqi\SO\163\r\168\188\157\247", _pubProps = [PropReasonString +// "\218&",PropMaximumQoS 139,PropUserProperty "u9\246l\ETB\227?V@~" +// "\246\248KBQ\ACK",PropSubscriptionIdentifierAvailable 161,PropRetainAvailable 146,PropAssignedClientIdentifier +// "\189\233\146\140Ir\207px9\172g\193\216Z\243\244\133\137\RSybT\172E\133L",PropRequestProblemInformation +// 56,PropSharedSubscriptionAvailable 91,PropAssignedClientIdentifier "\DC2\146",PropResponseInformation +// "A\250\217\RS\228v\ACK30rj\157\222\181\181#LE\221!\234\DC28\151\129\211\156\210\183",PropReasonString +// "\SO",PropReceiveMaximum 9804,PropSessionExpiryInterval 21555,PropSessionExpiryInterval 19432,PropUserProperty +// "\202pV\252{\200\197\154\140\US\154\157\184\183\218\213\171" +// "\189\DC2\143\236\177\153\SOH6\227\246f\SUB\191\143`",PropTopicAliasMaximum 19556,PropTopicAlias 6627,PropMaximumQoS +// 46,PropAuthenticationData "\241\\\130\DC1\172\ETX\RS\128y\ENQ\211\138V\255\RS\199u\222w\241\219\178",PropMaximumQoS +// 40,PropAuthenticationMethod "Q\171"]} TEST(Publish5QCTest, Encode26) { - uint8_t pkt[] = {0x35, 0xcf, 0x1, 0x0, 0x2, 0x6e, 0x91, 0x37, 0x9, 0xa9, 0x1, 0x1, 0xb, 0x12, 0x0, 0x9, 0xa5, - 0x1d, 0x4f, 0x7f, 0x57, 0xd1, 0x1f, 0x59, 0x5e, 0x19, 0xc7, 0xb, 0x7, 0x12, 0x0, 0x9, 0xe9, 0x65, - 0x6, 0xf2, 0xf5, 0x87, 0xcf, 0xb2, 0xbd, 0x1f, 0x0, 0x1e, 0x9f, 0x2b, 0xcb, 0xad, 0x13, 0xd, 0xd8, - 0xa5, 0xc8, 0x1, 0xe2, 0x24, 0x68, 0xab, 0x55, 0xb3, 0x3d, 0xbd, 0x50, 0x71, 0x25, 0xd3, 0xbc, 0x78, - 0xee, 0xb0, 0xa9, 0x61, 0xc9, 0x13, 0x8, 0x0, 0x14, 0x3, 0xe7, 0x77, 0x2b, 0x20, 0x3, 0x80, 0xfc, - 0x57, 0x2d, 0xa4, 0xe4, 0x46, 0x51, 0xc6, 0xe7, 0x8c, 0x95, 0x80, 0x1f, 0x28, 0x56, 0x1, 0xb, 0x29, - 0x82, 0x2, 0x0, 0x0, 0x39, 0xbf, 0x29, 0x71, 0x25, 0xdf, 0x1a, 0x0, 0xe, 0x82, 0x16, 0x32, 0xe2, - 0xd2, 0xa, 0xa5, 0xdc, 0x2, 0xaf, 0xeb, 0x6a, 0x2, 0x1f, 0x17, 0x61, 0x9, 0x0, 0x17, 0x74, 0xed, - 0x6a, 0x10, 0x36, 0xe3, 0xd2, 0x19, 0x2, 0x0, 0x5d, 0x1c, 0xd7, 0x1c, 0xca, 0x77, 0xfa, 0x4e, 0x18, - 0xd9, 0xc7, 0xc0, 0x2b, 0x1f, 0x0, 0x14, 0xb0, 0xb, 0x62, 0xd8, 0x73, 0x1c, 0xaf, 0x63, 0x51, 0x49, - 0x71, 0x36, 0x74, 0xb7, 0x23, 0xaa, 0x95, 0x95, 0xda, 0x6f, 0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, - 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, - 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; - uint8_t topic_bytes[] = {0x6e, 0x91}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0xe4, 0x1, 0x0, 0x5, 0xe5, 0x3c, 0x3c, 0xea, 0x3b, 0xc5, 0x1, 0x1f, 0x0, 0x2, 0xda, 0x26, + 0x24, 0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0, 0x2, 0x51, 0xab, 0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, 0x27, + 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; + uint8_t topic_bytes[] = {0xe5, 0x3c, 0x3c, 0xea, 0x3b}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, - 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; + uint8_t msg_bytes[] = {0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, + 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 22; - uint8_t bytesprops0[] = {0xa5, 0x1d, 0x4f, 0x7f, 0x57, 0xd1, 0x1f, 0x59, 0x5e}; - uint8_t bytesprops1[] = {0xe9, 0x65, 0x6, 0xf2, 0xf5, 0x87, 0xcf, 0xb2, 0xbd}; - uint8_t bytesprops2[] = {0x9f, 0x2b, 0xcb, 0xad, 0x13, 0xd, 0xd8, 0xa5, 0xc8, 0x1, 0xe2, 0x24, 0x68, 0xab, 0x55, - 0xb3, 0x3d, 0xbd, 0x50, 0x71, 0x25, 0xd3, 0xbc, 0x78, 0xee, 0xb0, 0xa9, 0x61, 0xc9, 0x13}; - uint8_t bytesprops3[] = {0x3, 0xe7, 0x77, 0x2b, 0x20, 0x3, 0x80, 0xfc, 0x57, 0x2d, - 0xa4, 0xe4, 0x46, 0x51, 0xc6, 0xe7, 0x8c, 0x95, 0x80, 0x1f}; - uint8_t bytesprops4[] = {0x82, 0x16, 0x32, 0xe2, 0xd2, 0xa, 0xa5, 0xdc, 0x2, 0xaf, 0xeb, 0x6a, 0x2, 0x1f}; - uint8_t bytesprops5[] = {0x74, 0xed, 0x6a, 0x10, 0x36, 0xe3, 0xd2, 0x19, 0x2, 0x0, 0x5d, 0x1c, - 0xd7, 0x1c, 0xca, 0x77, 0xfa, 0x4e, 0x18, 0xd9, 0xc7, 0xc0, 0x2b}; - uint8_t bytesprops6[] = {0xb0, 0xb, 0x62, 0xd8, 0x73, 0x1c, 0xaf, 0x63, 0x51, 0x49, - 0x71, 0x36, 0x74, 0xb7, 0x23, 0xaa, 0x95, 0x95, 0xda, 0x6f}; + uint8_t bytesprops0[] = {0xda, 0x26}; + uint8_t bytesprops2[] = {0xf6, 0xf8, 0x4b, 0x42, 0x51, 0x6}; + uint8_t bytesprops1[] = {0x75, 0x39, 0xf6, 0x6c, 0x17, 0xe3, 0x3f, 0x56, 0x40, 0x7e}; + uint8_t bytesprops3[] = {0xbd, 0xe9, 0x92, 0x8c, 0x49, 0x72, 0xcf, 0x70, 0x78, 0x39, 0xac, 0x67, 0xc1, 0xd8, + 0x5a, 0xf3, 0xf4, 0x85, 0x89, 0x1e, 0x79, 0x62, 0x54, 0xac, 0x45, 0x85, 0x4c}; + uint8_t bytesprops4[] = {0x12, 0x92}; + uint8_t bytesprops5[] = {0x41, 0xfa, 0xd9, 0x1e, 0xe4, 0x76, 0x6, 0x33, 0x30, 0x72, 0x6a, 0x9d, 0xde, 0xb5, 0xb5, + 0x23, 0x4c, 0x45, 0xdd, 0x21, 0xea, 0x12, 0x38, 0x97, 0x81, 0xd3, 0x9c, 0xd2, 0xb7}; + uint8_t bytesprops6[] = {0xe}; + uint8_t bytesprops8[] = {0xbd, 0x12, 0x8f, 0xec, 0xb1, 0x99, 0x1, 0x36, 0xe3, 0xf6, 0x66, 0x1a, 0xbf, 0x8f, 0x60}; + uint8_t bytesprops7[] = {0xca, 0x70, 0x56, 0xfc, 0x7b, 0xc8, 0xc5, 0x9a, 0x8c, + 0x1f, 0x9a, 0x9d, 0xb8, 0xb7, 0xda, 0xd5, 0xab}; + uint8_t bytesprops9[] = {0xf1, 0x5c, 0x82, 0x11, 0xac, 0x3, 0x1e, 0x80, 0x79, 0x5, 0xd3, + 0x8a, 0x56, 0xff, 0x1e, 0xc7, 0x75, 0xde, 0x77, 0xf1, 0xdb, 0xb2}; + uint8_t bytesprops10[] = {0x51, 0xab}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14783}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9804}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21555}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19432}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops7}, .v = {15, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19556}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6627}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14089, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "n\145", _pubPktID = 14089, _pubBody -// = "\210\210>L\150\rD\161j\204SG\219\226\165\205k\208\&4\ENQ\154t\DC1\148D:\US<\141\149", _pubProps = -// [PropPayloadFormatIndicator 11,PropAssignedClientIdentifier "\165\GSO\DELW\209\USY^",PropRequestResponseInformation -// 199,PropSubscriptionIdentifier 7,PropAssignedClientIdentifier "\233e\ACK\242\245\135\207\178\189",PropReasonString -// "\159+\203\173\DC3\r\216\165\200\SOH\226$h\171U\179=\189Pq%\211\188x\238\176\169a\201\DC3",PropResponseTopic -// "\ETX\231w+ \ETX\128\252W-\164\228FQ\198\231\140\149\128\US",PropWildcardSubscriptionAvailable -// 86,PropPayloadFormatIndicator 11,PropSubscriptionIdentifierAvailable 130,PropMessageExpiryInterval -// 14783,PropSubscriptionIdentifierAvailable 113,PropRetainAvailable 223,PropResponseInformation -// "\130\SYN2\226\210\n\165\220\STX\175\235j\STX\US",PropRequestProblemInformation 97,PropCorrelationData -// "t\237j\DLE6\227\210\EM\STX\NUL]\FS\215\FS\202w\250N\CAN\217\199\192+",PropReasonString -// "\176\vb\216s\FS\175cQIq6t\183#\170\149\149\218o"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\229<<\234;", _pubPktID = 0, +// _pubBody = "+ eK\208\CAN\232\179\167\129\227'Hqi\SO\163\r\168\188\157\247", _pubProps = [PropReasonString +// "\218&",PropMaximumQoS 139,PropUserProperty "u9\246l\ETB\227?V@~" +// "\246\248KBQ\ACK",PropSubscriptionIdentifierAvailable 161,PropRetainAvailable 146,PropAssignedClientIdentifier +// "\189\233\146\140Ir\207px9\172g\193\216Z\243\244\133\137\RSybT\172E\133L",PropRequestProblemInformation +// 56,PropSharedSubscriptionAvailable 91,PropAssignedClientIdentifier "\DC2\146",PropResponseInformation +// "A\250\217\RS\228v\ACK30rj\157\222\181\181#LE\221!\234\DC28\151\129\211\156\210\183",PropReasonString +// "\SO",PropReceiveMaximum 9804,PropSessionExpiryInterval 21555,PropSessionExpiryInterval 19432,PropUserProperty +// "\202pV\252{\200\197\154\140\US\154\157\184\183\218\213\171" +// "\189\DC2\143\236\177\153\SOH6\227\246f\SUB\191\143`",PropTopicAliasMaximum 19556,PropTopicAlias 6627,PropMaximumQoS +// 46,PropAuthenticationData "\241\\\130\DC1\172\ETX\RS\128y\ENQ\211\138V\255\RS\199u\222w\241\219\178",PropMaximumQoS +// 40,PropAuthenticationMethod "Q\171"]} TEST(Publish5QCTest, Decode26) { - uint8_t pkt[] = {0x35, 0xcf, 0x1, 0x0, 0x2, 0x6e, 0x91, 0x37, 0x9, 0xa9, 0x1, 0x1, 0xb, 0x12, 0x0, 0x9, 0xa5, - 0x1d, 0x4f, 0x7f, 0x57, 0xd1, 0x1f, 0x59, 0x5e, 0x19, 0xc7, 0xb, 0x7, 0x12, 0x0, 0x9, 0xe9, 0x65, - 0x6, 0xf2, 0xf5, 0x87, 0xcf, 0xb2, 0xbd, 0x1f, 0x0, 0x1e, 0x9f, 0x2b, 0xcb, 0xad, 0x13, 0xd, 0xd8, - 0xa5, 0xc8, 0x1, 0xe2, 0x24, 0x68, 0xab, 0x55, 0xb3, 0x3d, 0xbd, 0x50, 0x71, 0x25, 0xd3, 0xbc, 0x78, - 0xee, 0xb0, 0xa9, 0x61, 0xc9, 0x13, 0x8, 0x0, 0x14, 0x3, 0xe7, 0x77, 0x2b, 0x20, 0x3, 0x80, 0xfc, - 0x57, 0x2d, 0xa4, 0xe4, 0x46, 0x51, 0xc6, 0xe7, 0x8c, 0x95, 0x80, 0x1f, 0x28, 0x56, 0x1, 0xb, 0x29, - 0x82, 0x2, 0x0, 0x0, 0x39, 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0x12, 0x92, 0x1a, 0x0, + 0x1d, 0x41, 0xfa, 0xd9, 0x1e, 0xe4, 0x76, 0x6, 0x33, 0x30, 0x72, 0x6a, 0x9d, 0xde, 0xb5, 0xb5, 0x23, + 0x4c, 0x45, 0xdd, 0x21, 0xea, 0x12, 0x38, 0x97, 0x81, 0xd3, 0x9c, 0xd2, 0xb7, 0x1f, 0x0, 0x1, 0xe, + 0x21, 0x26, 0x4c, 0x11, 0x0, 0x0, 0x54, 0x33, 0x11, 0x0, 0x0, 0x4b, 0xe8, 0x26, 0x0, 0x11, 0xca, + 0x70, 0x56, 0xfc, 0x7b, 0xc8, 0xc5, 0x9a, 0x8c, 0x1f, 0x9a, 0x9d, 0xb8, 0xb7, 0xda, 0xd5, 0xab, 0x0, + 0xf, 0xbd, 0x12, 0x8f, 0xec, 0xb1, 0x99, 0x1, 0x36, 0xe3, 0xf6, 0x66, 0x1a, 0xbf, 0x8f, 0x60, 0x22, + 0x4c, 0x64, 0x23, 0x19, 0xe3, 0x24, 0x2e, 0x16, 0x0, 0x16, 0xf1, 0x5c, 0x82, 0x11, 0xac, 0x3, 0x1e, + 0x80, 0x79, 0x5, 0xd3, 0x8a, 0x56, 0xff, 0x1e, 0xc7, 0x75, 0xde, 0x77, 0xf1, 0xdb, 0xb2, 0x24, 0x28, + 0x15, 0x0, 0x2, 0x51, 0xab, 0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, 0x27, + 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4727,160 +4751,75 @@ TEST(Publish5QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x6e, 0x91}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd2, 0xd2, 0x3e, 0x4c, 0x96, 0xd, 0x44, 0xa1, 0x6a, 0xcc, 0x53, 0x47, 0xdb, 0xe2, 0xa5, - 0xcd, 0x6b, 0xd0, 0x34, 0x5, 0x9a, 0x74, 0x11, 0x94, 0x44, 0x3a, 0x1f, 0x3c, 0x8d, 0x95}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xe5, 0x3c, 0x3c, 0xea, 0x3b}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, + 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 14089); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\199d\158\162p\SYNZ2{\228j\t\233'\211K\254\FSK\133%\252", _pubPktID = 0, _pubBody = "\SYN\ESC\r\233\&1\216\237", -// _pubProps = [PropMaximumPacketSize 22909,PropUserProperty "\213;\180\149" -// "\142\f\137prd\141\&6\DC4\237\252G\248Ot\200\SUB;5\204",PropWillDelayInterval -// 4294,PropSubscriptionIdentifierAvailable 78,PropRetainAvailable 105,PropServerKeepAlive 18960,PropTopicAlias -// 32368,PropWildcardSubscriptionAvailable 111,PropAuthenticationData -// "\135\147Z\181\250\224\250\DC1E\ETB?B\229TNp{\140\&2\220R\STX*\177f\251",PropContentType -// "!(topic.data), 22); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\DELB\171!\189\RS\129\132", _pubPktID -// = 1997, _pubBody = "P\169", _pubProps = [PropAuthenticationData -// "\133\226\151X\185\146s\RS\226zw'\244o\251\141(\250i\128\254\&2:\180\156\235\145\241\185\139",PropAuthenticationMethod -// "l\204\131\167\192P\220\ACK8\v\136\\G\230\166~6L\ETX\138",PropPayloadFormatIndicator 188,PropTopicAliasMaximum -// 2470,PropContentType "\184\147Y`}\SYN\\P\168\r\148\152\&7\148\175i\188hp\SO6",PropWillDelayInterval -// 8842,PropTopicAliasMaximum 3096,PropServerReference -// "\NAK\208\185@\138*\ETX'\243v\196S\FS\134.\193\230pMQ\134\245\185\249\225",PropSharedSubscriptionAvailable -// 205,PropServerReference -// "\r$\r\196\230\134\188I\a\252\231Q\240\215\185\190\175\&4\v\242\212\248\145c\251\221\254",PropServerKeepAlive -// 260,PropAuthenticationMethod -// "8L\222\GS\144C\180Q\168\135\152\179\187\ESC\191\&6|1\152\192\149\215\t\DLE\162\169\213\187\221\186",PropMaximumQoS -// 30,PropAuthenticationData "C\f\fx\t\186\166\215\SUB\156\136\236\222\238~\165#p\237\199O\237",PropReasonString -// "\206\b\FS\218",PropMessageExpiryInterval 21627,PropWildcardSubscriptionAvailable 124,PropServerReference -// "\192\DC3\ESC\SI",PropRequestProblemInformation 114,PropSubscriptionIdentifierAvailable -// 10,PropRequestResponseInformation 197]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201eh\234\223\242\222", _pubPktID = +// 0, _pubBody = " .@o\137\224\135\201\224\168\\&%,\220\&6\DC2\SI\209\132J\DC2]\FS\210\132\134\189\b~", _pubProps = +// [PropAssignedClientIdentifier "\t",PropAssignedClientIdentifier "\173\246$\137\207\204\GSg\192{\"5\ACKp\140\FSf"]} TEST(Publish5QCTest, Encode28) { - uint8_t pkt[] = { - 0x3d, 0x83, 0x2, 0x0, 0x8, 0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84, 0x7, 0xcd, 0xf3, 0x1, 0x16, 0x0, - 0x1e, 0x85, 0xe2, 0x97, 0x58, 0xb9, 0x92, 0x73, 0x1e, 0xe2, 0x7a, 0x77, 0x27, 0xf4, 0x6f, 0xfb, 0x8d, 0x28, 0xfa, - 0x69, 0x80, 0xfe, 0x32, 0x3a, 0xb4, 0x9c, 0xeb, 0x91, 0xf1, 0xb9, 0x8b, 0x15, 0x0, 0x14, 0x6c, 0xcc, 0x83, 0xa7, - 0xc0, 0x50, 0xdc, 0x6, 0x38, 0xb, 0x88, 0x5c, 0x47, 0xe6, 0xa6, 0x7e, 0x36, 0x4c, 0x3, 0x8a, 0x1, 0xbc, 0x22, - 0x9, 0xa6, 0x3, 0x0, 0x15, 0xb8, 0x93, 0x59, 0x60, 0x7d, 0x16, 0x5c, 0x50, 0xa8, 0xd, 0x94, 0x98, 0x37, 0x94, - 0xaf, 0x69, 0xbc, 0x68, 0x70, 0xe, 0x36, 0x18, 0x0, 0x0, 0x22, 0x8a, 0x22, 0xc, 0x18, 0x1c, 0x0, 0x19, 0x15, - 0xd0, 0xb9, 0x40, 0x8a, 0x2a, 0x3, 0x27, 0xf3, 0x76, 0xc4, 0x53, 0x1c, 0x86, 0x2e, 0xc1, 0xe6, 0x70, 0x4d, 0x51, - 0x86, 0xf5, 0xb9, 0xf9, 0xe1, 0x2a, 0xcd, 0x1c, 0x0, 0x1b, 0xd, 0x24, 0xd, 0xc4, 0xe6, 0x86, 0xbc, 0x49, 0x7, - 0xfc, 0xe7, 0x51, 0xf0, 0xd7, 0xb9, 0xbe, 0xaf, 0x34, 0xb, 0xf2, 0xd4, 0xf8, 0x91, 0x63, 0xfb, 0xdd, 0xfe, 0x13, - 0x1, 0x4, 0x15, 0x0, 0x1e, 0x38, 0x4c, 0xde, 0x1d, 0x90, 0x43, 0xb4, 0x51, 0xa8, 0x87, 0x98, 0xb3, 0xbb, 0x1b, - 0xbf, 0x36, 0x7c, 0x31, 0x98, 0xc0, 0x95, 0xd7, 0x9, 0x10, 0xa2, 0xa9, 0xd5, 0xbb, 0xdd, 0xba, 0x24, 0x1e, 0x16, - 0x0, 0x16, 0x43, 0xc, 0xc, 0x78, 0x9, 0xba, 0xa6, 0xd7, 0x1a, 0x9c, 0x88, 0xec, 0xde, 0xee, 0x7e, 0xa5, 0x23, - 0x70, 0xed, 0xc7, 0x4f, 0xed, 0x1f, 0x0, 0x4, 0xce, 0x8, 0x1c, 0xda, 0x2, 0x0, 0x0, 0x54, 0x7b, 0x28, 0x7c, - 0x1c, 0x0, 0x4, 0xc0, 0x13, 0x1b, 0xf, 0x17, 0x72, 0x29, 0xa, 0x19, 0xc5, 0x50, 0xa9}; - uint8_t topic_bytes[] = {0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x40, 0x0, 0x7, 0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde, 0x18, 0x12, 0x0, 0x1, 0x9, 0x12, + 0x0, 0x11, 0xad, 0xf6, 0x24, 0x89, 0xcf, 0xcc, 0x1d, 0x67, 0xc0, 0x7b, 0x22, 0x35, 0x6, 0x70, 0x8c, + 0x1c, 0x66, 0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, + 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; + uint8_t topic_bytes[] = {0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x50, 0xa9}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, + 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 30; - uint8_t bytesprops0[] = {0x85, 0xe2, 0x97, 0x58, 0xb9, 0x92, 0x73, 0x1e, 0xe2, 0x7a, 0x77, 0x27, 0xf4, 0x6f, 0xfb, - 0x8d, 0x28, 0xfa, 0x69, 0x80, 0xfe, 0x32, 0x3a, 0xb4, 0x9c, 0xeb, 0x91, 0xf1, 0xb9, 0x8b}; - uint8_t bytesprops1[] = {0x6c, 0xcc, 0x83, 0xa7, 0xc0, 0x50, 0xdc, 0x6, 0x38, 0xb, - 0x88, 0x5c, 0x47, 0xe6, 0xa6, 0x7e, 0x36, 0x4c, 0x3, 0x8a}; - uint8_t bytesprops2[] = {0xb8, 0x93, 0x59, 0x60, 0x7d, 0x16, 0x5c, 0x50, 0xa8, 0xd, 0x94, - 0x98, 0x37, 0x94, 0xaf, 0x69, 0xbc, 0x68, 0x70, 0xe, 0x36}; - uint8_t bytesprops3[] = {0x15, 0xd0, 0xb9, 0x40, 0x8a, 0x2a, 0x3, 0x27, 0xf3, 0x76, 0xc4, 0x53, 0x1c, - 0x86, 0x2e, 0xc1, 0xe6, 0x70, 0x4d, 0x51, 0x86, 0xf5, 0xb9, 0xf9, 0xe1}; - uint8_t bytesprops4[] = {0xd, 0x24, 0xd, 0xc4, 0xe6, 0x86, 0xbc, 0x49, 0x7, 0xfc, 0xe7, 0x51, 0xf0, 0xd7, - 0xb9, 0xbe, 0xaf, 0x34, 0xb, 0xf2, 0xd4, 0xf8, 0x91, 0x63, 0xfb, 0xdd, 0xfe}; - uint8_t bytesprops5[] = {0x38, 0x4c, 0xde, 0x1d, 0x90, 0x43, 0xb4, 0x51, 0xa8, 0x87, 0x98, 0xb3, 0xbb, 0x1b, 0xbf, - 0x36, 0x7c, 0x31, 0x98, 0xc0, 0x95, 0xd7, 0x9, 0x10, 0xa2, 0xa9, 0xd5, 0xbb, 0xdd, 0xba}; - uint8_t bytesprops6[] = {0x43, 0xc, 0xc, 0x78, 0x9, 0xba, 0xa6, 0xd7, 0x1a, 0x9c, 0x88, - 0xec, 0xde, 0xee, 0x7e, 0xa5, 0x23, 0x70, 0xed, 0xc7, 0x4f, 0xed}; - uint8_t bytesprops7[] = {0xce, 0x8, 0x1c, 0xda}; - uint8_t bytesprops8[] = {0xc0, 0x13, 0x1b, 0xf}; + uint8_t bytesprops0[] = {0x9}; + uint8_t bytesprops1[] = {0xad, 0xf6, 0x24, 0x89, 0xcf, 0xcc, 0x1d, 0x67, 0xc0, + 0x7b, 0x22, 0x35, 0x6, 0x70, 0x8c, 0x1c, 0x66}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2470}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8842}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3096}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 260}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21627}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 1997, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\DELB\171!\189\RS\129\132", _pubPktID -// = 1997, _pubBody = "P\169", _pubProps = [PropAuthenticationData -// "\133\226\151X\185\146s\RS\226zw'\244o\251\141(\250i\128\254\&2:\180\156\235\145\241\185\139",PropAuthenticationMethod -// "l\204\131\167\192P\220\ACK8\v\136\\G\230\166~6L\ETX\138",PropPayloadFormatIndicator 188,PropTopicAliasMaximum -// 2470,PropContentType "\184\147Y`}\SYN\\P\168\r\148\152\&7\148\175i\188hp\SO6",PropWillDelayInterval -// 8842,PropTopicAliasMaximum 3096,PropServerReference -// "\NAK\208\185@\138*\ETX'\243v\196S\FS\134.\193\230pMQ\134\245\185\249\225",PropSharedSubscriptionAvailable -// 205,PropServerReference -// "\r$\r\196\230\134\188I\a\252\231Q\240\215\185\190\175\&4\v\242\212\248\145c\251\221\254",PropServerKeepAlive -// 260,PropAuthenticationMethod -// "8L\222\GS\144C\180Q\168\135\152\179\187\ESC\191\&6|1\152\192\149\215\t\DLE\162\169\213\187\221\186",PropMaximumQoS -// 30,PropAuthenticationData "C\f\fx\t\186\166\215\SUB\156\136\236\222\238~\165#p\237\199O\237",PropReasonString -// "\206\b\FS\218",PropMessageExpiryInterval 21627,PropWildcardSubscriptionAvailable 124,PropServerReference -// "\192\DC3\ESC\SI",PropRequestProblemInformation 114,PropSubscriptionIdentifierAvailable -// 10,PropRequestResponseInformation 197]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201eh\234\223\242\222", _pubPktID = +// 0, _pubBody = " .@o\137\224\135\201\224\168\\&%,\220\&6\DC2\SI\209\132J\DC2]\FS\210\132\134\189\b~", _pubProps = +// [PropAssignedClientIdentifier "\t",PropAssignedClientIdentifier "\173\246$\137\207\204\GSg\192{\"5\ACKp\140\FSf"]} TEST(Publish5QCTest, Decode28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, 0x51, 0xa8, 0x87, 0x98, 0xb3, 0xbb, 0x1b, - 0xbf, 0x36, 0x7c, 0x31, 0x98, 0xc0, 0x95, 0xd7, 0x9, 0x10, 0xa2, 0xa9, 0xd5, 0xbb, 0xdd, 0xba, 0x24, 0x1e, 0x16, - 0x0, 0x16, 0x43, 0xc, 0xc, 0x78, 0x9, 0xba, 0xa6, 0xd7, 0x1a, 0x9c, 0x88, 0xec, 0xde, 0xee, 0x7e, 0xa5, 0x23, - 0x70, 0xed, 0xc7, 0x4f, 0xed, 0x1f, 0x0, 0x4, 0xce, 0x8, 0x1c, 0xda, 0x2, 0x0, 0x0, 0x54, 0x7b, 0x28, 0x7c, - 0x1c, 0x0, 0x4, 0xc0, 0x13, 0x1b, 0xf, 0x17, 0x72, 0x29, 0xa, 0x19, 0xc5, 0x50, 0xa9}; + uint8_t pkt[] = {0x38, 0x40, 0x0, 0x7, 0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde, 0x18, 0x12, 0x0, 0x1, 0x9, 0x12, + 0x0, 0x11, 0xad, 0xf6, 0x24, 0x89, 0xcf, 0xcc, 0x1d, 0x67, 0xc0, 0x7b, 0x22, 0x35, 0x6, 0x70, 0x8c, + 0x1c, 0x66, 0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, + 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -5033,149 +4895,131 @@ TEST(Publish5QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7f, 0x42, 0xab, 0x21, 0xbd, 0x1e, 0x81, 0x84}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x50, 0xa9}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, + 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 1997); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\138.\149\DC3{U\CANP\144", -// _pubPktID = 16970, _pubBody = "4\163\252\250\166\SUB\245\158", _pubProps = [PropContentType -// "\RS\247\FS\142\143@3\238U\203",PropReasonString -// "\157\230\ACK\171\149\165\250\147L\227{\131\252Y\140",PropAuthenticationData -// "R,\224\163\177\231\185\n\202\160\162\180gn\a\r{\192\135\ETX\145\151\136\211",PropTopicAlias -// 31483,PropAssignedClientIdentifier -// "\SIV\223\185\223X\244\197\182\220\DEL{\247\214\153\"\193\246W\247\r\220",PropTopicAlias -// 20925,PropResponseInformation "O\252\147\164\145",PropServerReference -// "\"\237\153*\136\152\192\190\201\147\186\219\DEL",PropAuthenticationMethod "CN\207\218 -// \169\210\143\ACK[\174\157O\212\135\185\&6",PropReasonString -// "\177(\200\154|\245\236\153\249\251C\212\DC3\183\179\255\143\183-w",PropSharedSubscriptionAvailable -// 31,PropPayloadFormatIndicator 157,PropPayloadFormatIndicator 10,PropSubscriptionIdentifier -// 11,PropSessionExpiryInterval 11032,PropContentType "-X8\172\&4\167\USO",PropTopicAliasMaximum -// 27140,PropAuthenticationMethod "\167\249X\STX&\r\194t\166\135\246\&54L",PropRetainAvailable -// 64,PropMessageExpiryInterval 28215,PropServerKeepAlive 19907,PropUserProperty "\206z\147Gp\187\243\215" -// "]\194s\253\226\204\203NP\234Y;t0\183\236\128\211\155\EM\184\b"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "{\200\227JE\EM6\185bARg\185\190\226e\205R\n\v\167\CAN\DC3~\152nd8\155'", _pubPktID = 24808, _pubBody = +// "\FS\196\NUL\238\180K\252nl\r\235$v\169K\163\182\254\134\186", _pubProps = [PropTopicAliasMaximum +// 26688,PropRetainAvailable 162,PropServerReference "\253u\144\199x\215\&0\142\v\161\177\US",PropMessageExpiryInterval +// 14586,PropCorrelationData +// "A\158C\241A\224\156\198'oa\227\&2(topic.data), 9); - EXPECT_EQ(msg.payload_len, 8); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); + EXPECT_EQ(packet_id, 24808); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3r\ETX\ETXZ\SOH", _pubPktID = 0, -// _pubBody = "\129\209\171[\DC4B\234\ETX\ACK\177\133\&9\ENQf\128\DC1A\185\236M\134qT}\\g\159&;g", _pubProps = -// [PropUserProperty "\170\GS.\n\219\236\177\210s\166\241\227W\204" "\138\222S4\176\f\137%(\176\NUL",PropServerKeepAlive -// 3685,PropSharedSubscriptionAvailable 95,PropAssignedClientIdentifier -// "\204t1\215\220\133gm\202?bYl\134\DELH1I\STXd\GSJ_\FS\193H",PropMessageExpiryInterval 26825,PropReasonString -// "\205\198\163\206\251\192U\133\236&\189\177\ACK\181!\144",PropWildcardSubscriptionAvailable -// 188,PropRequestProblemInformation 198,PropMessageExpiryInterval 32203,PropWillDelayInterval 11069,PropContentType -// "\194\215\241\163\165\RS\241\222D\"\224^\219\154C\190\143r^yd\167\192)\223\195\171",PropUserProperty -// "5[\142(\199<\131\133\160\154\160|A\162U" -// "\179\156\146i\228\241\139\226\190\239]\vt{\230X\179",PropSubscriptionIdentifier 29,PropSharedSubscriptionAvailable -// 236,PropTopicAlias 9579,PropPayloadFormatIndicator 184,PropResponseTopic -// "\146\160\174;-\NUL\223#7j\"%\221n",PropMessageExpiryInterval 13344,PropAssignedClientIdentifier -// "(\235\t\133\216\230\STX@``\180\190\238\&6\246l\156_",PropMessageExpiryInterval 26407]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\218\139Q\DC1\195\175\199\249J\b\183\226\228\185\ESC\245\128\130\166\n]\133:\228\231$K*v", _pubPktID = 0, _pubBody = +// "\SOH\135h\234D\134\149\210zy\n\143\141\&7Q", _pubProps = [PropSharedSubscriptionAvailable +// 210,PropRequestResponseInformation 98,PropCorrelationData "\234\138CL\DC24qZ\195\134Qu\ETB +// \178\t\242\247\SYNGi\147z\DC1j",PropMaximumPacketSize 9483,PropWildcardSubscriptionAvailable +// 51,PropWildcardSubscriptionAvailable 35,PropUserProperty "\NUL\rw\164\th\199|\158$\164\222}\175\219" +// "",PropPayloadFormatIndicator 231,PropMaximumQoS 8,PropRequestProblemInformation 148,PropMaximumPacketSize +// 21886,PropReceiveMaximum 28042,PropRetainAvailable 68,PropRequestProblemInformation 3,PropMaximumQoS +// 58,PropRequestResponseInformation 255,PropRequestResponseInformation 253,PropWildcardSubscriptionAvailable +// 15,PropRetainAvailable 71,PropSessionExpiryInterval 22458,PropMessageExpiryInterval 15175,PropReceiveMaximum +// 13058,PropResponseInformation "\150Z(\215\v0"]} TEST(Publish5QCTest, Encode30) { - uint8_t pkt[] = {0x31, 0x8a, 0x2, 0x0, 0x6, 0x13, 0x72, 0x3, 0x3, 0x5a, 0x1, 0xe2, 0x1, 0x26, 0x0, 0xe, 0xaa, - 0x1d, 0x2e, 0xa, 0xdb, 0xec, 0xb1, 0xd2, 0x73, 0xa6, 0xf1, 0xe3, 0x57, 0xcc, 0x0, 0xb, 0x8a, 0xde, - 0x53, 0x34, 0xb0, 0xc, 0x89, 0x25, 0x28, 0xb0, 0x0, 0x13, 0xe, 0x65, 0x2a, 0x5f, 0x12, 0x0, 0x1a, - 0xcc, 0x74, 0x31, 0xd7, 0xdc, 0x85, 0x67, 0x6d, 0xca, 0x3f, 0x62, 0x59, 0x6c, 0x86, 0x7f, 0x48, 0x31, - 0x49, 0x2, 0x64, 0x1d, 0x4a, 0x5f, 0x1c, 0xc1, 0x48, 0x2, 0x0, 0x0, 0x68, 0xc9, 0x1f, 0x0, 0x10, - 0xcd, 0xc6, 0xa3, 0xce, 0xfb, 0xc0, 0x55, 0x85, 0xec, 0x26, 0xbd, 0xb1, 0x6, 0xb5, 0x21, 0x90, 0x28, - 0xbc, 0x17, 0xc6, 0x2, 0x0, 0x0, 0x7d, 0xcb, 0x18, 0x0, 0x0, 0x2b, 0x3d, 0x3, 0x0, 0x1b, 0xc2, - 0xd7, 0xf1, 0xa3, 0xa5, 0x1e, 0xf1, 0xde, 0x44, 0x22, 0xe0, 0x5e, 0xdb, 0x9a, 0x43, 0xbe, 0x8f, 0x72, - 0x5e, 0x79, 0x64, 0xa7, 0xc0, 0x29, 0xdf, 0xc3, 0xab, 0x26, 0x0, 0xf, 0x35, 0x5b, 0x8e, 0x28, 0xc7, - 0x3c, 0x83, 0x85, 0xa0, 0x9a, 0xa0, 0x7c, 0x41, 0xa2, 0x55, 0x0, 0x11, 0xb3, 0x9c, 0x92, 0x69, 0xe4, - 0xf1, 0x8b, 0xe2, 0xbe, 0xef, 0x5d, 0xb, 0x74, 0x7b, 0xe6, 0x58, 0xb3, 0xb, 0x1d, 0x2a, 0xec, 0x23, - 0x25, 0x6b, 0x1, 0xb8, 0x8, 0x0, 0xe, 0x92, 0xa0, 0xae, 0x3b, 0x2d, 0x0, 0xdf, 0x23, 0x37, 0x6a, - 0x22, 0x25, 0xdd, 0x6e, 0x2, 0x0, 0x0, 0x34, 0x20, 0x12, 0x0, 0x12, 0x28, 0xeb, 0x9, 0x85, 0xd8, - 0xe6, 0x2, 0x40, 0x60, 0x60, 0xb4, 0xbe, 0xee, 0x36, 0xf6, 0x6c, 0x9c, 0x5f, 0x2, 0x0, 0x0, 0x67, - 0x27, 0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, 0x11, - 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; - uint8_t topic_bytes[] = {0x13, 0x72, 0x3, 0x3, 0x5a, 0x1}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x9e, 0x1, 0x0, 0x1d, 0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, + 0xe4, 0xb9, 0x1b, 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, 0x76, + 0x6f, 0x2a, 0xd2, 0x19, 0x62, 0x9, 0x0, 0x19, 0xea, 0x8a, 0x43, 0x4c, 0x12, 0x34, 0x71, 0x5a, 0xc3, + 0x86, 0x51, 0x75, 0x17, 0x20, 0xb2, 0x9, 0xf2, 0xf7, 0x16, 0x47, 0x69, 0x93, 0x7a, 0x11, 0x6a, 0x27, + 0x0, 0x0, 0x25, 0xb, 0x28, 0x33, 0x28, 0x23, 0x26, 0x0, 0xf, 0x0, 0xd, 0x77, 0xa4, 0x9, 0x68, + 0xc7, 0x7c, 0x9e, 0x24, 0xa4, 0xde, 0x7d, 0xaf, 0xdb, 0x0, 0x0, 0x1, 0xe7, 0x24, 0x8, 0x17, 0x94, + 0x27, 0x0, 0x0, 0x55, 0x7e, 0x21, 0x6d, 0x8a, 0x25, 0x44, 0x17, 0x3, 0x24, 0x3a, 0x19, 0xff, 0x19, + 0xfd, 0x28, 0xf, 0x25, 0x47, 0x11, 0x0, 0x0, 0x57, 0xba, 0x2, 0x0, 0x0, 0x3b, 0x47, 0x21, 0x33, + 0x2, 0x1a, 0x0, 0x6, 0x96, 0x5a, 0x28, 0xd7, 0xb, 0x30, 0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, + 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; + uint8_t topic_bytes[] = {0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, 0xe4, 0xb9, 0x1b, + 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, 0x76}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, - 0x11, 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; + uint8_t msg_bytes[] = {0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 15; - uint8_t bytesprops1[] = {0x8a, 0xde, 0x53, 0x34, 0xb0, 0xc, 0x89, 0x25, 0x28, 0xb0, 0x0}; - uint8_t bytesprops0[] = {0xaa, 0x1d, 0x2e, 0xa, 0xdb, 0xec, 0xb1, 0xd2, 0x73, 0xa6, 0xf1, 0xe3, 0x57, 0xcc}; - uint8_t bytesprops2[] = {0xcc, 0x74, 0x31, 0xd7, 0xdc, 0x85, 0x67, 0x6d, 0xca, 0x3f, 0x62, 0x59, 0x6c, - 0x86, 0x7f, 0x48, 0x31, 0x49, 0x2, 0x64, 0x1d, 0x4a, 0x5f, 0x1c, 0xc1, 0x48}; - uint8_t bytesprops3[] = {0xcd, 0xc6, 0xa3, 0xce, 0xfb, 0xc0, 0x55, 0x85, - 0xec, 0x26, 0xbd, 0xb1, 0x6, 0xb5, 0x21, 0x90}; - uint8_t bytesprops4[] = {0xc2, 0xd7, 0xf1, 0xa3, 0xa5, 0x1e, 0xf1, 0xde, 0x44, 0x22, 0xe0, 0x5e, 0xdb, 0x9a, - 0x43, 0xbe, 0x8f, 0x72, 0x5e, 0x79, 0x64, 0xa7, 0xc0, 0x29, 0xdf, 0xc3, 0xab}; - uint8_t bytesprops6[] = {0xb3, 0x9c, 0x92, 0x69, 0xe4, 0xf1, 0x8b, 0xe2, 0xbe, - 0xef, 0x5d, 0xb, 0x74, 0x7b, 0xe6, 0x58, 0xb3}; - uint8_t bytesprops5[] = {0x35, 0x5b, 0x8e, 0x28, 0xc7, 0x3c, 0x83, 0x85, 0xa0, 0x9a, 0xa0, 0x7c, 0x41, 0xa2, 0x55}; - uint8_t bytesprops7[] = {0x92, 0xa0, 0xae, 0x3b, 0x2d, 0x0, 0xdf, 0x23, 0x37, 0x6a, 0x22, 0x25, 0xdd, 0x6e}; - uint8_t bytesprops8[] = {0x28, 0xeb, 0x9, 0x85, 0xd8, 0xe6, 0x2, 0x40, 0x60, - 0x60, 0xb4, 0xbe, 0xee, 0x36, 0xf6, 0x6c, 0x9c, 0x5f}; + uint8_t bytesprops0[] = {0xea, 0x8a, 0x43, 0x4c, 0x12, 0x34, 0x71, 0x5a, 0xc3, 0x86, 0x51, 0x75, 0x17, + 0x20, 0xb2, 0x9, 0xf2, 0xf7, 0x16, 0x47, 0x69, 0x93, 0x7a, 0x11, 0x6a}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops1[] = {0x0, 0xd, 0x77, 0xa4, 0x9, 0x68, 0xc7, 0x7c, 0x9e, 0x24, 0xa4, 0xde, 0x7d, 0xaf, 0xdb}; + uint8_t bytesprops3[] = {0x96, 0x5a, 0x28, 0xd7, 0xb, 0x30}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops0}, .v = {11, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3685}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26825}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32203}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11069}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops5}, .v = {17, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9579}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13344}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26407}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9483}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops1}, .v = {0, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21886}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28042}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22458}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15175}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13058}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3r\ETX\ETXZ\SOH", _pubPktID = 0, -// _pubBody = "\129\209\171[\DC4B\234\ETX\ACK\177\133\&9\ENQf\128\DC1A\185\236M\134qT}\\g\159&;g", _pubProps = -// [PropUserProperty "\170\GS.\n\219\236\177\210s\166\241\227W\204" "\138\222S4\176\f\137%(\176\NUL",PropServerKeepAlive -// 3685,PropSharedSubscriptionAvailable 95,PropAssignedClientIdentifier -// "\204t1\215\220\133gm\202?bYl\134\DELH1I\STXd\GSJ_\FS\193H",PropMessageExpiryInterval 26825,PropReasonString -// "\205\198\163\206\251\192U\133\236&\189\177\ACK\181!\144",PropWildcardSubscriptionAvailable -// 188,PropRequestProblemInformation 198,PropMessageExpiryInterval 32203,PropWillDelayInterval 11069,PropContentType -// "\194\215\241\163\165\RS\241\222D\"\224^\219\154C\190\143r^yd\167\192)\223\195\171",PropUserProperty -// "5[\142(\199<\131\133\160\154\160|A\162U" -// "\179\156\146i\228\241\139\226\190\239]\vt{\230X\179",PropSubscriptionIdentifier 29,PropSharedSubscriptionAvailable -// 236,PropTopicAlias 9579,PropPayloadFormatIndicator 184,PropResponseTopic -// "\146\160\174;-\NUL\223#7j\"%\221n",PropMessageExpiryInterval 13344,PropAssignedClientIdentifier -// "(\235\t\133\216\230\STX@``\180\190\238\&6\246l\156_",PropMessageExpiryInterval 26407]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\218\139Q\DC1\195\175\199\249J\b\183\226\228\185\ESC\245\128\130\166\n]\133:\228\231$K*v", _pubPktID = 0, _pubBody = +// "\SOH\135h\234D\134\149\210zy\n\143\141\&7Q", _pubProps = [PropSharedSubscriptionAvailable +// 210,PropRequestResponseInformation 98,PropCorrelationData "\234\138CL\DC24qZ\195\134Qu\ETB +// \178\t\242\247\SYNGi\147z\DC1j",PropMaximumPacketSize 9483,PropWildcardSubscriptionAvailable +// 51,PropWildcardSubscriptionAvailable 35,PropUserProperty "\NUL\rw\164\th\199|\158$\164\222}\175\219" +// "",PropPayloadFormatIndicator 231,PropMaximumQoS 8,PropRequestProblemInformation 148,PropMaximumPacketSize +// 21886,PropReceiveMaximum 28042,PropRetainAvailable 68,PropRequestProblemInformation 3,PropMaximumQoS +// 58,PropRequestResponseInformation 255,PropRequestResponseInformation 253,PropWildcardSubscriptionAvailable +// 15,PropRetainAvailable 71,PropSessionExpiryInterval 22458,PropMessageExpiryInterval 15175,PropReceiveMaximum +// 13058,PropResponseInformation "\150Z(\215\v0"]} TEST(Publish5QCTest, Decode30) { - uint8_t pkt[] = {0x31, 0x8a, 0x2, 0x0, 0x6, 0x13, 0x72, 0x3, 0x3, 0x5a, 0x1, 0xe2, 0x1, 0x26, 0x0, 0xe, 0xaa, - 0x1d, 0x2e, 0xa, 0xdb, 0xec, 0xb1, 0xd2, 0x73, 0xa6, 0xf1, 0xe3, 0x57, 0xcc, 0x0, 0xb, 0x8a, 0xde, - 0x53, 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 0x6, 0x96, 0x5a, 0x28, 0xd7, 0xb, 0x30, 0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, + 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -5323,32 +5148,33 @@ TEST(Publish5QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x13, 0x72, 0x3, 0x3, 0x5a, 0x1}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x81, 0xd1, 0xab, 0x5b, 0x14, 0x42, 0xea, 0x3, 0x6, 0xb1, 0x85, 0x39, 0x5, 0x66, 0x80, - 0x11, 0x41, 0xb9, 0xec, 0x4d, 0x86, 0x71, 0x54, 0x7d, 0x5c, 0x67, 0x9f, 0x26, 0x3b, 0x67}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, 0xe4, 0xb9, 0x1b, + 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, 0x76}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// ConnectRequest {_username = Nothing, _password = Just "Ke\173x'\220\170U\137[)Z\178\208[", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "M\150!\226\146b.\172]E2\203\181H\189\229`\158", _willMsg = -// "\254\224C\179\DC48p\a%0\153A\138\190\225Yw(dG\204\187\t5w\154\138F\208", _willProps = []}), _cleanSession = True, -// _keepAlive = 3972, _connID = "j\165k\247>\ENQ\145Xh\181N\246!\SUBX\201", _properties = []} +// ConnectRequest {_username = Just "\247\bJ@ON", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS0, _willTopic = "\200\&8\143\219\210\&8\154\ETB\191\209\ENQ\247\151j\ETX\STX\DLEwW\DC4(\171\239", +// _willMsg = "\239\163,\150S\ETXA\235Q\144\193p~G\249\214\218Wh\175\200\235;\235np\154t", _willProps = []}), +// _cleanSession = True, _keepAlive = 24957, _connID = "\SUB\DC4P\DC4\ENQ\160\SO\226\141\r\251", _properties = []} TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x4f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0xf, 0x84, 0x0, 0x10, 0x6a, 0xa5, 0x6b, - 0xf7, 0x3e, 0x5, 0x91, 0x58, 0x68, 0xb5, 0x4e, 0xf6, 0x21, 0x1a, 0x58, 0xc9, 0x0, 0x12, 0x4d, 0x96, - 0x21, 0xe2, 0x92, 0x62, 0x2e, 0xac, 0x5d, 0x45, 0x32, 0xcb, 0xb5, 0x48, 0xbd, 0xe5, 0x60, 0x9e, 0x0, - 0x1d, 0xfe, 0xe0, 0x43, 0xb3, 0x14, 0x38, 0x70, 0x7, 0x25, 0x30, 0x99, 0x41, 0x8a, 0xbe, 0xe1, 0x59, - 0x77, 0x28, 0x64, 0x47, 0xcc, 0xbb, 0x9, 0x35, 0x77, 0x9a, 0x8a, 0x46, 0xd0}; + uint8_t pkt[] = {0x10, 0x56, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa6, 0x61, 0x7d, 0x0, 0xb, 0x1a, + 0x14, 0x50, 0x14, 0x5, 0xa0, 0xe, 0xe2, 0x8d, 0xd, 0xfb, 0x0, 0x17, 0xc8, 0x38, 0x8f, + 0xdb, 0xd2, 0x38, 0x9a, 0x17, 0xbf, 0xd1, 0x5, 0xf7, 0x97, 0x6a, 0x3, 0x2, 0x10, 0x77, + 0x57, 0x14, 0x28, 0xab, 0xef, 0x0, 0x1c, 0xef, 0xa3, 0x2c, 0x96, 0x53, 0x3, 0x41, 0xeb, + 0x51, 0x90, 0xc1, 0x70, 0x7e, 0x47, 0xf9, 0xd6, 0xda, 0x57, 0x68, 0xaf, 0xc8, 0xeb, 0x3b, + 0xeb, 0x6e, 0x70, 0x9a, 0x74, 0x0, 0x6, 0xf7, 0x8, 0x4a, 0x40, 0x4f, 0x4e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5359,29 +5185,27 @@ TEST(Connect311QCTest, Encode1) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4d, 0x96, 0x21, 0xe2, 0x92, 0x62, 0x2e, 0xac, 0x5d, - 0x45, 0x32, 0xcb, 0xb5, 0x48, 0xbd, 0xe5, 0x60, 0x9e}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfe, 0xe0, 0x43, 0xb3, 0x14, 0x38, 0x70, 0x7, 0x25, 0x30, - 0x99, 0x41, 0x8a, 0xbe, 0xe1, 0x59, 0x77, 0x28, 0x64, 0x47, - 0xcc, 0xbb, 0x9, 0x35, 0x77, 0x9a, 0x8a, 0x46, 0xd0}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xc8, 0x38, 0x8f, 0xdb, 0xd2, 0x38, 0x9a, 0x17, 0xbf, 0xd1, 0x5, 0xf7, + 0x97, 0x6a, 0x3, 0x2, 0x10, 0x77, 0x57, 0x14, 0x28, 0xab, 0xef}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xef, 0xa3, 0x2c, 0x96, 0x53, 0x3, 0x41, 0xeb, 0x51, 0x90, 0xc1, 0x70, 0x7e, 0x47, + 0xf9, 0xd6, 0xda, 0x57, 0x68, 0xaf, 0xc8, 0xeb, 0x3b, 0xeb, 0x6e, 0x70, 0x9a, 0x74}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 3972; - uint8_t client_id_bytes[] = {0x6a, 0xa5, 0x6b, 0xf7, 0x3e, 0x5, 0x91, 0x58, - 0x68, 0xb5, 0x4e, 0xf6, 0x21, 0x1a, 0x58, 0xc9}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.keep_alive = 24957; + uint8_t client_id_bytes[] = {0x1a, 0x14, 0x50, 0x14, 0x5, 0xa0, 0xe, 0xe2, 0x8d, 0xd, 0xfb}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x4b, 0x65, 0xad, 0x78, 0x27, 0xdc, 0xaa, 0x55, 0x89, 0x5b, 0x29, 0x5a, 0xb2, 0xd0, 0x5b}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; - opts.password = password; + uint8_t username_bytes[] = {0xf7, 0x8, 0x4a, 0x40, 0x4f, 0x4e}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; + opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5390,19 +5214,17 @@ TEST(Connect311QCTest, Encode1) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "+\217\245\132J\219\160\139\232\213\SO\189\NUL-\DC3", _password = Nothing, _lastWill -// = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "O\SOH\173\164\238\248\f&\NULP\175\136/,\ETB\255\GS\208\247\DELt\129\193\169\EOT", _willMsg = -// "\138\229\222\220\216/\219\197\224\ETB\177\DEL.\165<\210\150\182\209\222\SOH\NAK(R\177\134\ETX\ETB", _willProps = -// []}), _cleanSession = True, _keepAlive = 20710, _connID = "\153\186\STX-\152\157\214\157\245\"4\"\ETX", _properties = -// []} +// ConnectRequest {_username = Just "\DC4\245qv", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "\132\165\SUB\228Tg9\NULV.~\142\194\226:", _willMsg = +// "\176\179\172\a1r\164{\SOH\143\130V5\US-ElV\146\EOT-K\160\NUL\SO\134T\148\232\194\132b\218\SIE\241L\156\204\169\145X3\250", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\CANf\159\155m", _willMsg = -// "\155)T\206\250\163y-\213[_\a\159\GS=\195L\155L\164\220\243\225)\208p", _willProps = []}), _cleanSession = True, -// _keepAlive = 11529, _connID = "", _properties = []} +// ConnectRequest {_username = Just "\ETX\167/\DLE?I\DEL\214T$", _password = Just +// "\SUB\181v\f\SO\128\188\245\DEL\145\178\224\247\166\&8", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS1, _willTopic = "\212\201\CANR|p\199", _willMsg = +// "\171\188\151\239\EM#[\DC3\EM\SI1F0\134S8\195:\144\207\US\CANc\209?\213\190@\186", _willProps = []}), _cleanSession = +// True, _keepAlive = 14165, _connID = "s@\"\140E\205\ESCb\193\200%\173\206\NAK)\152s", _properties = []} TEST(Connect311QCTest, Encode6) { - uint8_t pkt[] = {0x10, 0x4f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x96, 0x2d, 0x9, 0x0, 0x0, 0x0, 0x5, 0x18, - 0x66, 0x9f, 0x9b, 0x6d, 0x0, 0x1a, 0x9b, 0x29, 0x54, 0xce, 0xfa, 0xa3, 0x79, 0x2d, 0xd5, 0x5b, 0x5f, - 0x7, 0x9f, 0x1d, 0x3d, 0xc3, 0x4c, 0x9b, 0x4c, 0xa4, 0xdc, 0xf3, 0xe1, 0x29, 0xd0, 0x70, 0x0, 0x1e, - 0xaf, 0x27, 0x1f, 0x37, 0x3e, 0x4, 0x2d, 0x4b, 0xa0, 0x0, 0xe, 0x86, 0x54, 0x94, 0xe8, 0xc2, 0x84, - 0x62, 0xda, 0xf, 0x45, 0xf1, 0x4c, 0x9c, 0xcc, 0xa9, 0x91, 0x58, 0x33, 0xfa}; + uint8_t pkt[] = {0x10, 0x62, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x37, 0x55, 0x0, 0x11, 0x73, 0x40, 0x22, + 0x8c, 0x45, 0xcd, 0x1b, 0x62, 0xc1, 0xc8, 0x25, 0xad, 0xce, 0x15, 0x29, 0x98, 0x73, 0x0, 0x7, 0xd4, + 0xc9, 0x18, 0x52, 0x7c, 0x70, 0xc7, 0x0, 0x1d, 0xab, 0xbc, 0x97, 0xef, 0x19, 0x23, 0x5b, 0x13, 0x19, + 0xf, 0x31, 0x46, 0x30, 0x86, 0x53, 0x38, 0xc3, 0x3a, 0x90, 0xcf, 0x1f, 0x18, 0x63, 0xd1, 0x3f, 0xd5, + 0xbe, 0x40, 0xba, 0x0, 0xa, 0x3, 0xa7, 0x2f, 0x10, 0x3f, 0x49, 0x7f, 0xd6, 0x54, 0x24, 0x0, 0xf, + 0x1a, 0xb5, 0x76, 0xc, 0xe, 0x80, 0xbc, 0xf5, 0x7f, 0x91, 0xb2, 0xe0, 0xf7, 0xa6, 0x38}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5573,27 +5391,31 @@ TEST(Connect311QCTest, Encode6) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x18, 0x66, 0x9f, 0x9b, 0x6d}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x9b, 0x29, 0x54, 0xce, 0xfa, 0xa3, 0x79, 0x2d, 0xd5, 0x5b, 0x5f, 0x7, 0x9f, - 0x1d, 0x3d, 0xc3, 0x4c, 0x9b, 0x4c, 0xa4, 0xdc, 0xf3, 0xe1, 0x29, 0xd0, 0x70}; - lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xd4, 0xc9, 0x18, 0x52, 0x7c, 0x70, 0xc7}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xab, 0xbc, 0x97, 0xef, 0x19, 0x23, 0x5b, 0x13, 0x19, 0xf, + 0x31, 0x46, 0x30, 0x86, 0x53, 0x38, 0xc3, 0x3a, 0x90, 0xcf, + 0x1f, 0x18, 0x63, 0xd1, 0x3f, 0xd5, 0xbe, 0x40, 0xba}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS1; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 11529; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.keep_alive = 14165; + uint8_t client_id_bytes[] = {0x73, 0x40, 0x22, 0x8c, 0x45, 0xcd, 0x1b, 0x62, 0xc1, + 0xc8, 0x25, 0xad, 0xce, 0x15, 0x29, 0x98, 0x73}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xaf, 0x27, 0x1f, 0x37, 0x3e, 0x4, 0x2d, 0x4b, 0xa0, 0x0, 0xe, 0x86, 0x54, 0x94, 0xe8, - 0xc2, 0x84, 0x62, 0xda, 0xf, 0x45, 0xf1, 0x4c, 0x9c, 0xcc, 0xa9, 0x91, 0x58, 0x33, 0xfa}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x3, 0xa7, 0x2f, 0x10, 0x3f, 0x49, 0x7f, 0xd6, 0x54, 0x24}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x1a, 0xb5, 0x76, 0xc, 0xe, 0x80, 0xbc, 0xf5, 0x7f, 0x91, 0xb2, 0xe0, 0xf7, 0xa6, 0x38}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5602,19 +5424,12 @@ TEST(Connect311QCTest, Encode6) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just ")\212\206\157>[\161\161\240\140\191\206", _password = Just -// "\175\183\193,\\>\244\ESCS\204\NULC\a\SOH\235\t\US\NAK\DC3", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS0, _willTopic = "8m\ETB\253\&5\"\149h\193\210!\DC2\192\173\163\v\157\214z\231?", _willMsg = -// "~\239s\199\207\DLE\137)\195w\DEL\200D\166\195y\230\ETX\179\187\224\188\198@\212\ESC", _willProps = []}), -// _cleanSession = True, _keepAlive = 1137, _connID = "H\161", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\223\&2\199@j\160\253\250\206\223!\137Hi\230\SUB`\181\222", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\217", _willMsg = "D~6I\EOT\181", +// _willProps = []}), _cleanSession = False, _keepAlive = 27312, _connID = "\179\202\212\v\189N", _properties = []} TEST(Connect311QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0x64, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x4, 0x71, 0x0, 0x2, 0x48, - 0xa1, 0x0, 0x15, 0x38, 0x6d, 0x17, 0xfd, 0x35, 0x22, 0x95, 0x68, 0xc1, 0xd2, 0x21, 0x12, - 0xc0, 0xad, 0xa3, 0xb, 0x9d, 0xd6, 0x7a, 0xe7, 0x3f, 0x0, 0x1a, 0x7e, 0xef, 0x73, 0xc7, - 0xcf, 0x10, 0x89, 0x29, 0xc3, 0x77, 0x7f, 0xc8, 0x44, 0xa6, 0xc3, 0x79, 0xe6, 0x3, 0xb3, - 0xbb, 0xe0, 0xbc, 0xc6, 0x40, 0xd4, 0x1b, 0x0, 0xc, 0x29, 0xd4, 0xce, 0x9d, 0x3e, 0x5b, - 0xa1, 0xa1, 0xf0, 0x8c, 0xbf, 0xce, 0x0, 0x13, 0xaf, 0xb7, 0xc1, 0x2c, 0x5c, 0x3e, 0xf4, - 0x1b, 0x53, 0xcc, 0x0, 0x43, 0x7, 0x1, 0xeb, 0x9, 0x1f, 0x15, 0x13}; + uint8_t pkt[] = {0x10, 0x1d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x14, 0x6a, 0xb0, 0x0, 0x6, 0xb3, 0xca, + 0xd4, 0xb, 0xbd, 0x4e, 0x0, 0x1, 0xd9, 0x0, 0x6, 0x44, 0x7e, 0x36, 0x49, 0x4, 0xb5}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5625,29 +5440,24 @@ TEST(Connect311QCTest, Encode7) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x38, 0x6d, 0x17, 0xfd, 0x35, 0x22, 0x95, 0x68, 0xc1, 0xd2, 0x21, - 0x12, 0xc0, 0xad, 0xa3, 0xb, 0x9d, 0xd6, 0x7a, 0xe7, 0x3f}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7e, 0xef, 0x73, 0xc7, 0xcf, 0x10, 0x89, 0x29, 0xc3, 0x77, 0x7f, 0xc8, 0x44, - 0xa6, 0xc3, 0x79, 0xe6, 0x3, 0xb3, 0xbb, 0xe0, 0xbc, 0xc6, 0x40, 0xd4, 0x1b}; - lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xd9}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x44, 0x7e, 0x36, 0x49, 0x4, 0xb5}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1137; - uint8_t client_id_bytes[] = {0x48, 0xa1}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 27312; + uint8_t client_id_bytes[] = {0xb3, 0xca, 0xd4, 0xb, 0xbd, 0x4e}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x29, 0xd4, 0xce, 0x9d, 0x3e, 0x5b, 0xa1, 0xa1, 0xf0, 0x8c, 0xbf, 0xce}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xaf, 0xb7, 0xc1, 0x2c, 0x5c, 0x3e, 0xf4, 0x1b, 0x53, 0xcc, - 0x0, 0x43, 0x7, 0x1, 0xeb, 0x9, 0x1f, 0x15, 0x13}; + uint8_t password_bytes[] = {0xdf, 0x32, 0xc7, 0x40, 0x6a, 0xa0, 0xfd, 0xfa, 0xce, 0xdf, + 0x21, 0x89, 0x48, 0x69, 0xe6, 0x1a, 0x60, 0xb5, 0xde}; lwmqtt_string_t password = {19, (char*)&password_bytes}; opts.password = password; size_t len = 0; @@ -5658,17 +5468,15 @@ TEST(Connect311QCTest, Encode7) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\144", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS2, _willTopic = "\ACKb<[2\a\182/h\252g\145S\156\179?6\NAK\232/\SO\241\213P\bk", _willMsg = -// "\EM\140\168c\240\ESC]:\250l\160>CT\DC4\ETB\209\DC2", _willProps = []}), _cleanSession = False, _keepAlive = 1187, -// _connID = "\162\135\139O\243\166\t(\204\167\213e\215\220d\185\n\149\233\144\b\218\229\235,", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\EMS\165f>\192\196\FS\155\179\128]\225\223\DLE\151e@\159h\136\238\221\&9\205\DEL", _willMsg = +// "\DLE\ETB\v\131b\241\161<\217", _willProps = []}), _cleanSession = True, _keepAlive = 20507, _connID = +// "-\202\240\v`\SOH\255oj\230\172\EM\212J", _properties = []} TEST(Connect311QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x58, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x94, 0x4, 0xa3, 0x0, 0x19, 0xa2, - 0x87, 0x8b, 0x4f, 0xf3, 0xa6, 0x9, 0x28, 0xcc, 0xa7, 0xd5, 0x65, 0xd7, 0xdc, 0x64, 0xb9, - 0xa, 0x95, 0xe9, 0x90, 0x8, 0xda, 0xe5, 0xeb, 0x2c, 0x0, 0x1a, 0x6, 0x62, 0x3c, 0x5b, - 0x32, 0x7, 0xb6, 0x2f, 0x68, 0xfc, 0x67, 0x91, 0x53, 0x9c, 0xb3, 0x3f, 0x36, 0x15, 0xe8, - 0x2f, 0xe, 0xf1, 0xd5, 0x50, 0x8, 0x6b, 0x0, 0x12, 0x19, 0x8c, 0xa8, 0x63, 0xf0, 0x1b, - 0x5d, 0x3a, 0xfa, 0x6c, 0xa0, 0x3e, 0x43, 0x54, 0x14, 0x17, 0xd1, 0x12, 0x0, 0x1, 0x90}; + uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x50, 0x1b, 0x0, 0xe, 0x2d, 0xca, 0xf0, + 0xb, 0x60, 0x1, 0xff, 0x6f, 0x6a, 0xe6, 0xac, 0x19, 0xd4, 0x4a, 0x0, 0x1a, 0x19, 0x53, 0xa5, 0x66, + 0x3e, 0xc0, 0xc4, 0x1c, 0x9b, 0xb3, 0x80, 0x5d, 0xe1, 0xdf, 0x10, 0x97, 0x65, 0x40, 0x9f, 0x68, 0x88, + 0xee, 0xdd, 0x39, 0xcd, 0x7f, 0x0, 0x9, 0x10, 0x17, 0xb, 0x83, 0x62, 0xf1, 0xa1, 0x3c, 0xd9}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5679,12 +5487,11 @@ TEST(Connect311QCTest, Encode8) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6, 0x62, 0x3c, 0x5b, 0x32, 0x7, 0xb6, 0x2f, 0x68, 0xfc, 0x67, 0x91, 0x53, - 0x9c, 0xb3, 0x3f, 0x36, 0x15, 0xe8, 0x2f, 0xe, 0xf1, 0xd5, 0x50, 0x8, 0x6b}; + uint8_t will_topic_bytes[] = {0x19, 0x53, 0xa5, 0x66, 0x3e, 0xc0, 0xc4, 0x1c, 0x9b, 0xb3, 0x80, 0x5d, 0xe1, + 0xdf, 0x10, 0x97, 0x65, 0x40, 0x9f, 0x68, 0x88, 0xee, 0xdd, 0x39, 0xcd, 0x7f}; lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x19, 0x8c, 0xa8, 0x63, 0xf0, 0x1b, 0x5d, 0x3a, 0xfa, - 0x6c, 0xa0, 0x3e, 0x43, 0x54, 0x14, 0x17, 0xd1, 0x12}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + uint8_t will_payload_bytes[] = {0x10, 0x17, 0xb, 0x83, 0x62, 0xf1, 0xa1, 0x3c, 0xd9}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; @@ -5692,15 +5499,11 @@ TEST(Connect311QCTest, Encode8) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 1187; - uint8_t client_id_bytes[] = {0xa2, 0x87, 0x8b, 0x4f, 0xf3, 0xa6, 0x9, 0x28, 0xcc, 0xa7, 0xd5, 0x65, 0xd7, - 0xdc, 0x64, 0xb9, 0xa, 0x95, 0xe9, 0x90, 0x8, 0xda, 0xe5, 0xeb, 0x2c}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 20507; + uint8_t client_id_bytes[] = {0x2d, 0xca, 0xf0, 0xb, 0x60, 0x1, 0xff, 0x6f, 0x6a, 0xe6, 0xac, 0x19, 0xd4, 0x4a}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x90}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5709,15 +5512,20 @@ TEST(Connect311QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS0, _willTopic = "$`\SYN}79\139\SUB\138\ETX\146\rK\199\236*\DC2`D\178", _willMsg = -// "\146\226\241\226\SUB$6\236\236\SYN_\134\252\240\ACK\220_\158~\191\130\215\178", _willProps = []}), _cleanSession = -// False, _keepAlive = 6339, _connID = "", _properties = []} +// ConnectRequest {_username = Just "\207\218?<\130\251\SI\189E\184\US\216$Z{?\252|\252", _password = Just +// "\184b#\224}]\DC4\210", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "J=\ESCG\249 +// t\STX\247m\RS\147\RS\157\225K\NUL\148G\203", _willMsg = +// "q\155\"+\180\161,\176\&9D\251\159!\164(|\235\247\178\213p\208\"\199~%X\226\251", _willProps = []}), _cleanSession = +// False, _keepAlive = 8484, _connID = "\219\138\191|*\231\ACK\191WZCrWZ\r\ETXLA\247|6", _properties = []} TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x3b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x4, 0x18, 0xc3, 0x0, 0x0, 0x0, 0x14, - 0x24, 0x60, 0x16, 0x7d, 0x37, 0x39, 0x8b, 0x1a, 0x8a, 0x3, 0x92, 0xd, 0x4b, 0xc7, 0xec, 0x2a, - 0x12, 0x60, 0x44, 0xb2, 0x0, 0x17, 0x92, 0xe2, 0xf1, 0xe2, 0x1a, 0x24, 0x36, 0xec, 0xec, 0x16, - 0x5f, 0x86, 0xfc, 0xf0, 0x6, 0xdc, 0x5f, 0x9e, 0x7e, 0xbf, 0x82, 0xd7, 0xb2}; + uint8_t pkt[] = {0x10, 0x75, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x21, 0x24, 0x0, 0x15, 0xdb, + 0x8a, 0xbf, 0x7c, 0x2a, 0xe7, 0x6, 0xbf, 0x57, 0x5a, 0x43, 0x72, 0x57, 0x5a, 0xd, 0x3, + 0x4c, 0x41, 0xf7, 0x7c, 0x36, 0x0, 0x14, 0x4a, 0x3d, 0x1b, 0x47, 0xf9, 0x20, 0x74, 0x2, + 0xf7, 0x6d, 0x1e, 0x93, 0x1e, 0x9d, 0xe1, 0x4b, 0x0, 0x94, 0x47, 0xcb, 0x0, 0x1d, 0x71, + 0x9b, 0x22, 0x2b, 0xb4, 0xa1, 0x2c, 0xb0, 0x39, 0x44, 0xfb, 0x9f, 0x21, 0xa4, 0x28, 0x7c, + 0xeb, 0xf7, 0xb2, 0xd5, 0x70, 0xd0, 0x22, 0xc7, 0x7e, 0x25, 0x58, 0xe2, 0xfb, 0x0, 0x13, + 0xcf, 0xda, 0x3f, 0x3c, 0x82, 0xfb, 0xf, 0xbd, 0x45, 0xb8, 0x1f, 0xd8, 0x24, 0x5a, 0x7b, + 0x3f, 0xfc, 0x7c, 0xfc, 0x0, 0x8, 0xb8, 0x62, 0x23, 0xe0, 0x7d, 0x5d, 0x14, 0xd2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5728,78 +5536,55 @@ TEST(Connect311QCTest, Encode9) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x24, 0x60, 0x16, 0x7d, 0x37, 0x39, 0x8b, 0x1a, 0x8a, 0x3, - 0x92, 0xd, 0x4b, 0xc7, 0xec, 0x2a, 0x12, 0x60, 0x44, 0xb2}; + uint8_t will_topic_bytes[] = {0x4a, 0x3d, 0x1b, 0x47, 0xf9, 0x20, 0x74, 0x2, 0xf7, 0x6d, + 0x1e, 0x93, 0x1e, 0x9d, 0xe1, 0x4b, 0x0, 0x94, 0x47, 0xcb}; lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x92, 0xe2, 0xf1, 0xe2, 0x1a, 0x24, 0x36, 0xec, 0xec, 0x16, 0x5f, 0x86, - 0xfc, 0xf0, 0x6, 0xdc, 0x5f, 0x9e, 0x7e, 0xbf, 0x82, 0xd7, 0xb2}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + uint8_t will_payload_bytes[] = {0x71, 0x9b, 0x22, 0x2b, 0xb4, 0xa1, 0x2c, 0xb0, 0x39, 0x44, + 0xfb, 0x9f, 0x21, 0xa4, 0x28, 0x7c, 0xeb, 0xf7, 0xb2, 0xd5, + 0x70, 0xd0, 0x22, 0xc7, 0x7e, 0x25, 0x58, 0xe2, 0xfb}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 6339; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\195\225Z\248\165S\201G\ne9\161>\FS\201_\239D\203\r", _password = Just -// "\230WH\211", _lastWill = Nothing, _cleanSession = False, _keepAlive = 22088, _connID = "nx\237\250`\150", -// _properties = []} -TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x2e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x56, 0x48, 0x0, 0x6, 0x6e, 0x78, - 0xed, 0xfa, 0x60, 0x96, 0x0, 0x14, 0xc3, 0xe1, 0x5a, 0xf8, 0xa5, 0x53, 0xc9, 0x47, 0xa, 0x65, - 0x39, 0xa1, 0x3e, 0x1c, 0xc9, 0x5f, 0xef, 0x44, 0xcb, 0xd, 0x0, 0x4, 0xe6, 0x57, 0x48, 0xd3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 22088; - uint8_t client_id_bytes[] = {0x6e, 0x78, 0xed, 0xfa, 0x60, 0x96}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.keep_alive = 8484; + uint8_t client_id_bytes[] = {0xdb, 0x8a, 0xbf, 0x7c, 0x2a, 0xe7, 0x6, 0xbf, 0x57, 0x5a, 0x43, + 0x72, 0x57, 0x5a, 0xd, 0x3, 0x4c, 0x41, 0xf7, 0x7c, 0x36}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xc3, 0xe1, 0x5a, 0xf8, 0xa5, 0x53, 0xc9, 0x47, 0xa, 0x65, - 0x39, 0xa1, 0x3e, 0x1c, 0xc9, 0x5f, 0xef, 0x44, 0xcb, 0xd}; - lwmqtt_string_t username = {20, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xcf, 0xda, 0x3f, 0x3c, 0x82, 0xfb, 0xf, 0xbd, 0x45, 0xb8, + 0x1f, 0xd8, 0x24, 0x5a, 0x7b, 0x3f, 0xfc, 0x7c, 0xfc}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xe6, 0x57, 0x48, 0xd3}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xb8, 0x62, 0x23, 0xe0, 0x7d, 0x5d, 0x14, 0xd2}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "7{\215\177Q\252!\233\141P\206\242", _password = Just -// "\ETX\fegm\236K\157\249\140\DC3\144\186-9\156\238\222\167\138\202\SYN", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "j&\214\247\206Z\212\219\RS\US-,\155\190e!\\\142\GS\243X\241", _willMsg = -// "\SYN\183\156\207\209\215", _willProps = []}), _cleanSession = True, _keepAlive = 26306, _connID = -// "\SI&\208\136\142lJ|\nQ\231\&2,\161\FS\184", _properties = []} -TEST(Connect311QCTest, Encode11) { - uint8_t pkt[] = {0x10, 0x62, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x66, 0xc2, 0x0, 0x10, 0xf, 0x26, 0xd0, - 0x88, 0x8e, 0x6c, 0x4a, 0x7c, 0xa, 0x51, 0xe7, 0x32, 0x2c, 0xa1, 0x1c, 0xb8, 0x0, 0x16, 0x6a, 0x26, - 0xd6, 0xf7, 0xce, 0x5a, 0xd4, 0xdb, 0x1e, 0x1f, 0x2d, 0x2c, 0x9b, 0xbe, 0x65, 0x21, 0x5c, 0x8e, 0x1d, - 0xf3, 0x58, 0xf1, 0x0, 0x6, 0x16, 0xb7, 0x9c, 0xcf, 0xd1, 0xd7, 0x0, 0xc, 0x37, 0x7b, 0xd7, 0xb1, - 0x51, 0xfc, 0x21, 0xe9, 0x8d, 0x50, 0xce, 0xf2, 0x0, 0x16, 0x3, 0xc, 0x65, 0x67, 0x6d, 0xec, 0x4b, - 0x9d, 0xf9, 0x8c, 0x13, 0x90, 0xba, 0x2d, 0x39, 0x9c, 0xee, 0xde, 0xa7, 0x8a, 0xca, 0x16}; +// ConnectRequest {_username = Just "\204\DC2Bw\158G\232{\204\238N\218\&9\f\150", _password = Just +// "/ME\221/\224L\203\216\150\t=\195a\169\197P[\251\137\DC3\219\152\253\ENQL\153\239", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\160TX\134\176\USa\167\209[\146\&0", _willMsg = +// "\130\128b\DC1U\178\198J:\"\154\&9\174\144\&79\222\DEL\212\204'\ENQ\227\139\&7\132", _willProps = []}), _cleanSession +// = True, _keepAlive = 18071, _connID = "\150\237n\166\229\ETBi;m\233\SYN,\137\212\196\218", _properties = []} +TEST(Connect311QCTest, Encode10) { + uint8_t pkt[] = {0x10, 0x75, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x46, 0x97, 0x0, 0x10, 0x96, + 0xed, 0x6e, 0xa6, 0xe5, 0x17, 0x69, 0x3b, 0x6d, 0xe9, 0x16, 0x2c, 0x89, 0xd4, 0xc4, 0xda, + 0x0, 0xc, 0xa0, 0x54, 0x58, 0x86, 0xb0, 0x1f, 0x61, 0xa7, 0xd1, 0x5b, 0x92, 0x30, 0x0, + 0x1a, 0x82, 0x80, 0x62, 0x11, 0x55, 0xb2, 0xc6, 0x4a, 0x3a, 0x22, 0x9a, 0x39, 0xae, 0x90, + 0x37, 0x39, 0xde, 0x7f, 0xd4, 0xcc, 0x27, 0x5, 0xe3, 0x8b, 0x37, 0x84, 0x0, 0xf, 0xcc, + 0x12, 0x42, 0x77, 0x9e, 0x47, 0xe8, 0x7b, 0xcc, 0xee, 0x4e, 0xda, 0x39, 0xc, 0x96, 0x0, + 0x1c, 0x2f, 0x4d, 0x45, 0xdd, 0x2f, 0xe0, 0x4c, 0xcb, 0xd8, 0x96, 0x9, 0x3d, 0xc3, 0x61, + 0xa9, 0xc5, 0x50, 0x5b, 0xfb, 0x89, 0x13, 0xdb, 0x98, 0xfd, 0x5, 0x4c, 0x99, 0xef}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5810,11 +5595,11 @@ TEST(Connect311QCTest, Encode11) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6a, 0x26, 0xd6, 0xf7, 0xce, 0x5a, 0xd4, 0xdb, 0x1e, 0x1f, 0x2d, - 0x2c, 0x9b, 0xbe, 0x65, 0x21, 0x5c, 0x8e, 0x1d, 0xf3, 0x58, 0xf1}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x16, 0xb7, 0x9c, 0xcf, 0xd1, 0xd7}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xa0, 0x54, 0x58, 0x86, 0xb0, 0x1f, 0x61, 0xa7, 0xd1, 0x5b, 0x92, 0x30}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x82, 0x80, 0x62, 0x11, 0x55, 0xb2, 0xc6, 0x4a, 0x3a, 0x22, 0x9a, 0x39, 0xae, + 0x90, 0x37, 0x39, 0xde, 0x7f, 0xd4, 0xcc, 0x27, 0x5, 0xe3, 0x8b, 0x37, 0x84}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -5823,17 +5608,17 @@ TEST(Connect311QCTest, Encode11) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 26306; - uint8_t client_id_bytes[] = {0xf, 0x26, 0xd0, 0x88, 0x8e, 0x6c, 0x4a, 0x7c, - 0xa, 0x51, 0xe7, 0x32, 0x2c, 0xa1, 0x1c, 0xb8}; + opts.keep_alive = 18071; + uint8_t client_id_bytes[] = {0x96, 0xed, 0x6e, 0xa6, 0xe5, 0x17, 0x69, 0x3b, + 0x6d, 0xe9, 0x16, 0x2c, 0x89, 0xd4, 0xc4, 0xda}; lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x37, 0x7b, 0xd7, 0xb1, 0x51, 0xfc, 0x21, 0xe9, 0x8d, 0x50, 0xce, 0xf2}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xcc, 0x12, 0x42, 0x77, 0x9e, 0x47, 0xe8, 0x7b, 0xcc, 0xee, 0x4e, 0xda, 0x39, 0xc, 0x96}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x3, 0xc, 0x65, 0x67, 0x6d, 0xec, 0x4b, 0x9d, 0xf9, 0x8c, 0x13, - 0x90, 0xba, 0x2d, 0x39, 0x9c, 0xee, 0xde, 0xa7, 0x8a, 0xca, 0x16}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x2f, 0x4d, 0x45, 0xdd, 0x2f, 0xe0, 0x4c, 0xcb, 0xd8, 0x96, 0x9, 0x3d, 0xc3, 0x61, + 0xa9, 0xc5, 0x50, 0x5b, 0xfb, 0x89, 0x13, 0xdb, 0x98, 0xfd, 0x5, 0x4c, 0x99, 0xef}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5843,20 +5628,16 @@ TEST(Connect311QCTest, Encode11) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\169\190fw\241\246)\vwT\139\DC3xx\216\189\225\158\213x\238\179\140", _password = -// Just "q\230-\213\ENQ5-T\188\DEL\b\213\155+\SO`m\GS \242\165#\\", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS0, _willTopic = "\217 \214\EM\178\ACK\155", _willMsg = -// "\245)\238j2\DC2\161\134.\140\147HX\198`\252\237D\164\157*", _willProps = []}), _cleanSession = False, _keepAlive = -// 19404, _connID = "#f\162\233\167\DEL?\182\198\174aF\143S\150\160\186\DC2JqI\244\199\152\&3", _properties = []} -TEST(Connect311QCTest, Encode12) { - uint8_t pkt[] = {0x10, 0x77, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x4b, 0xcc, 0x0, 0x19, 0x23, 0x66, - 0xa2, 0xe9, 0xa7, 0x7f, 0x3f, 0xb6, 0xc6, 0xae, 0x61, 0x46, 0x8f, 0x53, 0x96, 0xa0, 0xba, 0x12, - 0x4a, 0x71, 0x49, 0xf4, 0xc7, 0x98, 0x33, 0x0, 0x7, 0xd9, 0x20, 0xd6, 0x19, 0xb2, 0x6, 0x9b, - 0x0, 0x15, 0xf5, 0x29, 0xee, 0x6a, 0x32, 0x12, 0xa1, 0x86, 0x2e, 0x8c, 0x93, 0x48, 0x58, 0xc6, - 0x60, 0xfc, 0xed, 0x44, 0xa4, 0x9d, 0x2a, 0x0, 0x17, 0xa9, 0xbe, 0x66, 0x77, 0xf1, 0xf6, 0x29, - 0xb, 0x77, 0x54, 0x8b, 0x13, 0x78, 0x78, 0xd8, 0xbd, 0xe1, 0x9e, 0xd5, 0x78, 0xee, 0xb3, 0x8c, - 0x0, 0x17, 0x71, 0xe6, 0x2d, 0xd5, 0x5, 0x35, 0x2d, 0x54, 0xbc, 0x7f, 0x8, 0xd5, 0x9b, 0x2b, - 0xe, 0x60, 0x6d, 0x1d, 0x20, 0xf2, 0xa5, 0x23, 0x5c}; +// ConnectRequest {_username = Just "\170\169T\181z[8\SOH\237A\171\211\161", _password = Just "\216/I\167", _lastWill = +// Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "i\\\223d\254\201\208#u\SUB\184\178\254^g", +// _willMsg = "\130\b\SOHn\241D<\208", _willProps = []}), _cleanSession = False, _keepAlive = 20715, _connID = +// "\238Vc]\r\147\142\177>\228\133\&4\185\GS", _properties = []} +TEST(Connect311QCTest, Encode11) { + uint8_t pkt[] = {0x10, 0x4a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x50, 0xeb, 0x0, 0xe, 0xee, 0x56, + 0x63, 0x5d, 0xd, 0x93, 0x8e, 0xb1, 0x3e, 0xe4, 0x85, 0x34, 0xb9, 0x1d, 0x0, 0xf, 0x69, 0x5c, + 0xdf, 0x64, 0xfe, 0xc9, 0xd0, 0x23, 0x75, 0x1a, 0xb8, 0xb2, 0xfe, 0x5e, 0x67, 0x0, 0x8, 0x82, + 0x8, 0x1, 0x6e, 0xf1, 0x44, 0x3c, 0xd0, 0x0, 0xd, 0xaa, 0xa9, 0x54, 0xb5, 0x7a, 0x5b, 0x38, + 0x1, 0xed, 0x41, 0xab, 0xd3, 0xa1, 0x0, 0x4, 0xd8, 0x2f, 0x49, 0xa7}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5867,31 +5648,28 @@ TEST(Connect311QCTest, Encode12) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd9, 0x20, 0xd6, 0x19, 0xb2, 0x6, 0x9b}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf5, 0x29, 0xee, 0x6a, 0x32, 0x12, 0xa1, 0x86, 0x2e, 0x8c, 0x93, - 0x48, 0x58, 0xc6, 0x60, 0xfc, 0xed, 0x44, 0xa4, 0x9d, 0x2a}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x69, 0x5c, 0xdf, 0x64, 0xfe, 0xc9, 0xd0, 0x23, + 0x75, 0x1a, 0xb8, 0xb2, 0xfe, 0x5e, 0x67}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x82, 0x8, 0x1, 0x6e, 0xf1, 0x44, 0x3c, 0xd0}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 19404; - uint8_t client_id_bytes[] = {0x23, 0x66, 0xa2, 0xe9, 0xa7, 0x7f, 0x3f, 0xb6, 0xc6, 0xae, 0x61, 0x46, 0x8f, - 0x53, 0x96, 0xa0, 0xba, 0x12, 0x4a, 0x71, 0x49, 0xf4, 0xc7, 0x98, 0x33}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.keep_alive = 20715; + uint8_t client_id_bytes[] = {0xee, 0x56, 0x63, 0x5d, 0xd, 0x93, 0x8e, 0xb1, 0x3e, 0xe4, 0x85, 0x34, 0xb9, 0x1d}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa9, 0xbe, 0x66, 0x77, 0xf1, 0xf6, 0x29, 0xb, 0x77, 0x54, 0x8b, 0x13, - 0x78, 0x78, 0xd8, 0xbd, 0xe1, 0x9e, 0xd5, 0x78, 0xee, 0xb3, 0x8c}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xaa, 0xa9, 0x54, 0xb5, 0x7a, 0x5b, 0x38, 0x1, 0xed, 0x41, 0xab, 0xd3, 0xa1}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x71, 0xe6, 0x2d, 0xd5, 0x5, 0x35, 0x2d, 0x54, 0xbc, 0x7f, 0x8, 0xd5, - 0x9b, 0x2b, 0xe, 0x60, 0x6d, 0x1d, 0x20, 0xf2, 0xa5, 0x23, 0x5c}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xd8, 0x2f, 0x49, 0xa7}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5901,18 +5679,12 @@ TEST(Connect311QCTest, Encode12) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\SIu}\231\235\&7\157S\163\235u\157\206\215Gn\180\152\STX\142\225\150\&0\244B0", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\173\184D\250<\252,\186c\146\178T!\ETXkKR\SO\139\253\&6", _willMsg = "h\144\228&\249\240u\248L", _willProps = []}), -// _cleanSession = True, _keepAlive = 14654, _connID = -// "b!\199C\NAK8m\183\ETB\162\161\131\255\f\236\203\165\189\153\b\v\b\ACK", _properties = []} -TEST(Connect311QCTest, Encode13) { - uint8_t pkt[] = {0x10, 0x61, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa6, 0x39, 0x3e, 0x0, 0x17, 0x62, 0x21, 0xc7, - 0x43, 0x15, 0x38, 0x6d, 0xb7, 0x17, 0xa2, 0xa1, 0x83, 0xff, 0xc, 0xec, 0xcb, 0xa5, 0xbd, 0x99, 0x8, - 0xb, 0x8, 0x6, 0x0, 0x15, 0xad, 0xb8, 0x44, 0xfa, 0x3c, 0xfc, 0x2c, 0xba, 0x63, 0x92, 0xb2, 0x54, - 0x21, 0x3, 0x6b, 0x4b, 0x52, 0xe, 0x8b, 0xfd, 0x36, 0x0, 0x9, 0x68, 0x90, 0xe4, 0x26, 0xf9, 0xf0, - 0x75, 0xf8, 0x4c, 0x0, 0x1a, 0xf, 0x75, 0x7d, 0xe7, 0xeb, 0x37, 0x9d, 0x53, 0xa3, 0xeb, 0x75, 0x9d, - 0xce, 0xd7, 0x47, 0x6e, 0xb4, 0x98, 0x2, 0x8e, 0xe1, 0x96, 0x30, 0xf4, 0x42, 0x30}; +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\128", _willMsg = "G\244\250\238\173\220\204", _willProps = []}), _cleanSession = True, +// _keepAlive = 28847, _connID = "IP", _properties = []} +TEST(Connect311QCTest, Encode12) { + uint8_t pkt[] = {0x10, 0x1a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x70, 0xaf, 0x0, 0x2, + 0x49, 0x50, 0x0, 0x1, 0x80, 0x0, 0x7, 0x47, 0xf4, 0xfa, 0xee, 0xad, 0xdc, 0xcc}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5923,28 +5695,22 @@ TEST(Connect311QCTest, Encode13) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xad, 0xb8, 0x44, 0xfa, 0x3c, 0xfc, 0x2c, 0xba, 0x63, 0x92, 0xb2, - 0x54, 0x21, 0x3, 0x6b, 0x4b, 0x52, 0xe, 0x8b, 0xfd, 0x36}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x68, 0x90, 0xe4, 0x26, 0xf9, 0xf0, 0x75, 0xf8, 0x4c}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x80}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x47, 0xf4, 0xfa, 0xee, 0xad, 0xdc, 0xcc}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 14654; - uint8_t client_id_bytes[] = {0x62, 0x21, 0xc7, 0x43, 0x15, 0x38, 0x6d, 0xb7, 0x17, 0xa2, 0xa1, 0x83, - 0xff, 0xc, 0xec, 0xcb, 0xa5, 0xbd, 0x99, 0x8, 0xb, 0x8, 0x6}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 28847; + uint8_t client_id_bytes[] = {0x49, 0x50}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf, 0x75, 0x7d, 0xe7, 0xeb, 0x37, 0x9d, 0x53, 0xa3, 0xeb, 0x75, 0x9d, 0xce, - 0xd7, 0x47, 0x6e, 0xb4, 0x98, 0x2, 0x8e, 0xe1, 0x96, 0x30, 0xf4, 0x42, 0x30}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5953,15 +5719,17 @@ TEST(Connect311QCTest, Encode13) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "E\233Y!;0\183X\172\237\237\252\&9\t,\DC2\221d^", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\131\ETX\211$\DC4\162\130\183\SUB\187Y\238\196\ETB6", _willMsg = "\242\214\200\\7w\209dKcE\a\130\206\ACKsj\171\t", -// _willProps = []}), _cleanSession = True, _keepAlive = 9686, _connID = "\242\&1\174", _properties = []} -TEST(Connect311QCTest, Encode14) { - uint8_t pkt[] = {0x10, 0x35, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x25, 0xd6, 0x0, 0x3, - 0xf2, 0x31, 0xae, 0x0, 0xf, 0x83, 0x3, 0xd3, 0x24, 0x14, 0xa2, 0x82, 0xb7, 0x1a, - 0xbb, 0x59, 0xee, 0xc4, 0x17, 0x36, 0x0, 0x13, 0xf2, 0xd6, 0xc8, 0x5c, 0x37, 0x77, - 0xd1, 0x64, 0x4b, 0x63, 0x45, 0x7, 0x82, 0xce, 0x6, 0x73, 0x6a, 0xab, 0x9}; +// ConnectRequest {_username = Just "hWE\168_M\187,\211\130\251B\217\\\139X\246p\GSUQ\252\&7\198\223\143}\191\164", +// _password = Just "\221\"\180", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "/\161\ETX\236\174\202\142\ACK\ENQ&\231\230Zg", _willMsg = "\164:(\192D\224", _willProps = []}), _cleanSession = +// False, _keepAlive = 7983, _connID = "\255\v<\218q\253\223)BQ\136u\236\220\156&\164\".", _properties = []} +TEST(Connect311QCTest, Encode13) { + uint8_t pkt[] = {0x10, 0x5b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x1f, 0x2f, 0x0, 0x13, 0xff, 0xb, + 0x3c, 0xda, 0x71, 0xfd, 0xdf, 0x29, 0x42, 0x51, 0x88, 0x75, 0xec, 0xdc, 0x9c, 0x26, 0xa4, 0x22, + 0x2e, 0x0, 0xe, 0x2f, 0xa1, 0x3, 0xec, 0xae, 0xca, 0x8e, 0x6, 0x5, 0x26, 0xe7, 0xe6, 0x5a, + 0x67, 0x0, 0x6, 0xa4, 0x3a, 0x28, 0xc0, 0x44, 0xe0, 0x0, 0x1d, 0x68, 0x57, 0x45, 0xa8, 0x5f, + 0x4d, 0xbb, 0x2c, 0xd3, 0x82, 0xfb, 0x42, 0xd9, 0x5c, 0x8b, 0x58, 0xf6, 0x70, 0x1d, 0x55, 0x51, + 0xfc, 0x37, 0xc6, 0xdf, 0x8f, 0x7d, 0xbf, 0xa4, 0x0, 0x3, 0xdd, 0x22, 0xb4}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5972,27 +5740,29 @@ TEST(Connect311QCTest, Encode14) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x83, 0x3, 0xd3, 0x24, 0x14, 0xa2, 0x82, 0xb7, - 0x1a, 0xbb, 0x59, 0xee, 0xc4, 0x17, 0x36}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf2, 0xd6, 0xc8, 0x5c, 0x37, 0x77, 0xd1, 0x64, 0x4b, 0x63, - 0x45, 0x7, 0x82, 0xce, 0x6, 0x73, 0x6a, 0xab, 0x9}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x2f, 0xa1, 0x3, 0xec, 0xae, 0xca, 0x8e, 0x6, 0x5, 0x26, 0xe7, 0xe6, 0x5a, 0x67}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa4, 0x3a, 0x28, 0xc0, 0x44, 0xe0}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 9686; - uint8_t client_id_bytes[] = {0xf2, 0x31, 0xae}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 7983; + uint8_t client_id_bytes[] = {0xff, 0xb, 0x3c, 0xda, 0x71, 0xfd, 0xdf, 0x29, 0x42, 0x51, + 0x88, 0x75, 0xec, 0xdc, 0x9c, 0x26, 0xa4, 0x22, 0x2e}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x45, 0xe9, 0x59, 0x21, 0x3b, 0x30, 0xb7, 0x58, 0xac, 0xed, - 0xed, 0xfc, 0x39, 0x9, 0x2c, 0x12, 0xdd, 0x64, 0x5e}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x68, 0x57, 0x45, 0xa8, 0x5f, 0x4d, 0xbb, 0x2c, 0xd3, 0x82, 0xfb, 0x42, 0xd9, 0x5c, 0x8b, + 0x58, 0xf6, 0x70, 0x1d, 0x55, 0x51, 0xfc, 0x37, 0xc6, 0xdf, 0x8f, 0x7d, 0xbf, 0xa4}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xdd, 0x22, 0xb4}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6002,30 +5772,61 @@ TEST(Connect311QCTest, Encode14) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\133\RS\ACKX^\249Y\190\f(u\241", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "-\244b\239\\\168\251\255\247\DC2\234\150\&8\242", _willMsg = -// "\GS\ACK\135\190\RS\238", _willProps = []}), _cleanSession = True, _keepAlive = 7105, _connID = -// "xW\GSn\170\158vUz\227\172\SI\145Z2\174\&2\235G\137\154\141F\204", _properties = []} -TEST(Connect311QCTest, Encode15) { - uint8_t pkt[] = {0x10, 0x4a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x96, 0x1b, 0xc1, 0x0, 0x18, 0x78, 0x57, - 0x1d, 0x6e, 0xaa, 0x9e, 0x76, 0x55, 0x7a, 0xe3, 0xac, 0xf, 0x91, 0x5a, 0x32, 0xae, 0x32, 0xeb, - 0x47, 0x89, 0x9a, 0x8d, 0x46, 0xcc, 0x0, 0xe, 0x2d, 0xf4, 0x62, 0xef, 0x5c, 0xa8, 0xfb, 0xff, - 0xf7, 0x12, 0xea, 0x96, 0x38, 0xf2, 0x0, 0x6, 0x1d, 0x6, 0x87, 0xbe, 0x1e, 0xee, 0x0, 0xc, - 0x85, 0x1e, 0x6, 0x58, 0x5e, 0xf9, 0x59, 0xbe, 0xc, 0x28, 0x75, 0xf1}; +// ConnectRequest {_username = Nothing, _password = Just "I\SI\221-\132?i\130\DC4\231\186", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 15604, _connID = "\246\207\188\170T\240a\203\184x\230X\199\147{8_\SO;\188)", +// _properties = []} +TEST(Connect311QCTest, Encode14) { + uint8_t pkt[] = {0x10, 0x21, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x3c, 0xf4, + 0x0, 0x15, 0xf6, 0xcf, 0xbc, 0xaa, 0x54, 0xf0, 0x61, 0xcb, 0xb8, 0x78, + 0xe6, 0x58, 0xc7, 0x93, 0x7b, 0x38, 0x5f, 0xe, 0x3b, 0xbc, 0x29}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2d, 0xf4, 0x62, 0xef, 0x5c, 0xa8, 0xfb, 0xff, 0xf7, 0x12, 0xea, 0x96, 0x38, 0xf2}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1d, 0x6, 0x87, 0xbe, 0x1e, 0xee}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 15604; + uint8_t client_id_bytes[] = {0xf6, 0xcf, 0xbc, 0xaa, 0x54, 0xf0, 0x61, 0xcb, 0xb8, 0x78, 0xe6, + 0x58, 0xc7, 0x93, 0x7b, 0x38, 0x5f, 0xe, 0x3b, 0xbc, 0x29}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x49, 0xf, 0xdd, 0x2d, 0x84, 0x3f, 0x69, 0x82, 0x14, 0xe7, 0xba}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "Y4l\EOT[\245\243\233\211\199c\CANhx\DC4\190g\175\RS\147\191'\223\137<6", _willMsg = +// "\139|6\245\194\246\236j", _willProps = []}), _cleanSession = True, _keepAlive = 1098, _connID = +// "\242\250\148C\fX\219\222", _properties = []} +TEST(Connect311QCTest, Encode15) { + uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x4, 0x4a, 0x0, 0x8, 0xf2, + 0xfa, 0x94, 0x43, 0xc, 0x58, 0xdb, 0xde, 0x0, 0x1a, 0x59, 0x34, 0x6c, 0x4, 0x5b, 0xf5, + 0xf3, 0xe9, 0xd3, 0xc7, 0x63, 0x18, 0x68, 0x78, 0x14, 0xbe, 0x67, 0xaf, 0x1e, 0x93, 0xbf, + 0x27, 0xdf, 0x89, 0x3c, 0x36, 0x0, 0x8, 0x8b, 0x7c, 0x36, 0xf5, 0xc2, 0xf6, 0xec, 0x6a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x59, 0x34, 0x6c, 0x4, 0x5b, 0xf5, 0xf3, 0xe9, 0xd3, 0xc7, 0x63, 0x18, 0x68, + 0x78, 0x14, 0xbe, 0x67, 0xaf, 0x1e, 0x93, 0xbf, 0x27, 0xdf, 0x89, 0x3c, 0x36}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x8b, 0x7c, 0x36, 0xf5, 0xc2, 0xf6, 0xec, 0x6a}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; @@ -6034,14 +5835,10 @@ TEST(Connect311QCTest, Encode15) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 7105; - uint8_t client_id_bytes[] = {0x78, 0x57, 0x1d, 0x6e, 0xaa, 0x9e, 0x76, 0x55, 0x7a, 0xe3, 0xac, 0xf, - 0x91, 0x5a, 0x32, 0xae, 0x32, 0xeb, 0x47, 0x89, 0x9a, 0x8d, 0x46, 0xcc}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.keep_alive = 1098; + uint8_t client_id_bytes[] = {0xf2, 0xfa, 0x94, 0x43, 0xc, 0x58, 0xdb, 0xde}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x85, 0x1e, 0x6, 0x58, 0x5e, 0xf9, 0x59, 0xbe, 0xc, 0x28, 0x75, 0xf1}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6050,50 +5847,67 @@ TEST(Connect311QCTest, Encode15) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\178\221\248C\139\&8F", _password = Just -// "_\CAN\208w\239\n\FS*\168*U\US\DC1\146\ETX\150\DC2\SO\244E", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 27717, _connID = "", _properties = []} +// ConnectRequest {_username = Just +// "\DC3\243\159\217u&\163Y\NAKhh\155\169\&4\142\166\213k\248t\130\212\216\DC3\173\140\DLE\DC4R:", _password = Just +// "&m\142x\192", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "\146\238\tq\148_\147\ENQ", _willMsg = "\251", _willProps = []}), _cleanSession = True, _keepAlive = 25890, _connID = +// "\r\156\147\220\152hj\136^\SUB\177\ETX>i", _properties = []} TEST(Connect311QCTest, Encode16) { - uint8_t pkt[] = {0x10, 0x2b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x6c, 0x45, 0x0, 0x0, 0x0, - 0x7, 0xb2, 0xdd, 0xf8, 0x43, 0x8b, 0x38, 0x46, 0x0, 0x14, 0x5f, 0x18, 0xd0, 0x77, 0xef, - 0xa, 0x1c, 0x2a, 0xa8, 0x2a, 0x55, 0x1f, 0x11, 0x92, 0x3, 0x96, 0x12, 0xe, 0xf4, 0x45}; + uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe6, 0x65, 0x22, 0x0, 0xe, 0xd, 0x9c, + 0x93, 0xdc, 0x98, 0x68, 0x6a, 0x88, 0x5e, 0x1a, 0xb1, 0x3, 0x3e, 0x69, 0x0, 0x8, 0x92, 0xee, + 0x9, 0x71, 0x94, 0x5f, 0x93, 0x5, 0x0, 0x1, 0xfb, 0x0, 0x1e, 0x13, 0xf3, 0x9f, 0xd9, 0x75, + 0x26, 0xa3, 0x59, 0x15, 0x68, 0x68, 0x9b, 0xa9, 0x34, 0x8e, 0xa6, 0xd5, 0x6b, 0xf8, 0x74, 0x82, + 0xd4, 0xd8, 0x13, 0xad, 0x8c, 0x10, 0x14, 0x52, 0x3a, 0x0, 0x5, 0x26, 0x6d, 0x8e, 0x78, 0xc0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x92, 0xee, 0x9, 0x71, 0x94, 0x5f, 0x93, 0x5}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfb}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 27717; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 25890; + uint8_t client_id_bytes[] = {0xd, 0x9c, 0x93, 0xdc, 0x98, 0x68, 0x6a, 0x88, 0x5e, 0x1a, 0xb1, 0x3, 0x3e, 0x69}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb2, 0xdd, 0xf8, 0x43, 0x8b, 0x38, 0x46}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x13, 0xf3, 0x9f, 0xd9, 0x75, 0x26, 0xa3, 0x59, 0x15, 0x68, 0x68, 0x9b, 0xa9, 0x34, 0x8e, + 0xa6, 0xd5, 0x6b, 0xf8, 0x74, 0x82, 0xd4, 0xd8, 0x13, 0xad, 0x8c, 0x10, 0x14, 0x52, 0x3a}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x5f, 0x18, 0xd0, 0x77, 0xef, 0xa, 0x1c, 0x2a, 0xa8, 0x2a, - 0x55, 0x1f, 0x11, 0x92, 0x3, 0x96, 0x12, 0xe, 0xf4, 0x45}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x26, 0x6d, 0x8e, 0x78, 0xc0}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "J\158\167\177\&3=j\176\214\201\193\&6w\169}", _password = Just -// "aA\246Ml\170b\195\217\197\232\210\143/A\222\200\147", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 16521, _connID = "\186\RS\SYN\164\190\223\&0\237:(\242m\129\163\SIz\146x~R\202Dc\184\223\169\230\163", _properties = -// []} +// ConnectRequest {_username = Just "\193<~>\224\218\213\230+\253\204S21l", _password = Just "\208`1MG\177\a\230\254", +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 24689, _connID = +// "\215'G$\ESCg\194\223\191:\ETX\166\139\193n\180\156\140\165\209\206\tj\241\ETB\237\210\212Jt", _properties = []} TEST(Connect311QCTest, Encode17) { - uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x40, 0x89, 0x0, 0x1c, 0xba, 0x1e, - 0x16, 0xa4, 0xbe, 0xdf, 0x30, 0xed, 0x3a, 0x28, 0xf2, 0x6d, 0x81, 0xa3, 0xf, 0x7a, 0x92, 0x78, - 0x7e, 0x52, 0xca, 0x44, 0x63, 0xb8, 0xdf, 0xa9, 0xe6, 0xa3, 0x0, 0xf, 0x4a, 0x9e, 0xa7, 0xb1, - 0x33, 0x3d, 0x6a, 0xb0, 0xd6, 0xc9, 0xc1, 0x36, 0x77, 0xa9, 0x7d, 0x0, 0x12, 0x61, 0x41, 0xf6, - 0x4d, 0x6c, 0xaa, 0x62, 0xc3, 0xd9, 0xc5, 0xe8, 0xd2, 0x8f, 0x2f, 0x41, 0xde, 0xc8, 0x93}; + uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x60, 0x71, 0x0, 0x1e, 0xd7, + 0x27, 0x47, 0x24, 0x1b, 0x67, 0xc2, 0xdf, 0xbf, 0x3a, 0x3, 0xa6, 0x8b, 0xc1, 0x6e, 0xb4, + 0x9c, 0x8c, 0xa5, 0xd1, 0xce, 0x9, 0x6a, 0xf1, 0x17, 0xed, 0xd2, 0xd4, 0x4a, 0x74, 0x0, + 0xf, 0xc1, 0x3c, 0x7e, 0x3e, 0xe0, 0xda, 0xd5, 0xe6, 0x2b, 0xfd, 0xcc, 0x53, 0x32, 0x31, + 0x6c, 0x0, 0x9, 0xd0, 0x60, 0x31, 0x4d, 0x47, 0xb1, 0x7, 0xe6, 0xfe}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6102,17 +5916,17 @@ TEST(Connect311QCTest, Encode17) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 16521; - uint8_t client_id_bytes[] = {0xba, 0x1e, 0x16, 0xa4, 0xbe, 0xdf, 0x30, 0xed, 0x3a, 0x28, 0xf2, 0x6d, 0x81, 0xa3, - 0xf, 0x7a, 0x92, 0x78, 0x7e, 0x52, 0xca, 0x44, 0x63, 0xb8, 0xdf, 0xa9, 0xe6, 0xa3}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.keep_alive = 24689; + uint8_t client_id_bytes[] = {0xd7, 0x27, 0x47, 0x24, 0x1b, 0x67, 0xc2, 0xdf, 0xbf, 0x3a, + 0x3, 0xa6, 0x8b, 0xc1, 0x6e, 0xb4, 0x9c, 0x8c, 0xa5, 0xd1, + 0xce, 0x9, 0x6a, 0xf1, 0x17, 0xed, 0xd2, 0xd4, 0x4a, 0x74}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x4a, 0x9e, 0xa7, 0xb1, 0x33, 0x3d, 0x6a, 0xb0, 0xd6, 0xc9, 0xc1, 0x36, 0x77, 0xa9, 0x7d}; + uint8_t username_bytes[] = {0xc1, 0x3c, 0x7e, 0x3e, 0xe0, 0xda, 0xd5, 0xe6, 0x2b, 0xfd, 0xcc, 0x53, 0x32, 0x31, 0x6c}; lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x61, 0x41, 0xf6, 0x4d, 0x6c, 0xaa, 0x62, 0xc3, 0xd9, - 0xc5, 0xe8, 0xd2, 0x8f, 0x2f, 0x41, 0xde, 0xc8, 0x93}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xd0, 0x60, 0x31, 0x4d, 0x47, 0xb1, 0x7, 0xe6, 0xfe}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); @@ -6122,16 +5936,17 @@ TEST(Connect311QCTest, Encode17) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "J\SOHI-\a)\244e", _password = Just -// "o\249\n\239J\249D>\131\239\242>\206\FS\195\145\176\134\EM4", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS0, _willTopic = "\254", _willMsg = "\ETXm\199\156Oznd*\US\135*", _willProps = []}), _cleanSession = -// True, _keepAlive = 17571, _connID = "}\227/\252\245n]F\190\242|\141\194\180\DLE\194\190\226W", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just +// "\163}\NULy\RS\158NX4\187\195\203rzn\170(\172\129\146(]jr\168Q\169 \195\200", _lastWill = Just (LastWill {_willRetain +// = True, _willQoS = QoS2, _willTopic = "", _willMsg = "\244~\217'Tx\238\164\179\193!,\167", _willProps = []}), +// _cleanSession = False, _keepAlive = 26060, _connID = +// "ta\163\130\232\170\157\144\190\ETB\172\170g\"\136\233\NAK\NAK\231\ETX\160\SYN~\ENQG\220\208\150\241", _properties = +// []} TEST(Connect311QCTest, Encode18) { - uint8_t pkt[] = {0x10, 0x50, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe6, 0x44, 0xa3, 0x0, 0x13, 0x7d, 0xe3, 0x2f, - 0xfc, 0xf5, 0x6e, 0x5d, 0x46, 0xbe, 0xf2, 0x7c, 0x8d, 0xc2, 0xb4, 0x10, 0xc2, 0xbe, 0xe2, 0x57, 0x0, - 0x1, 0xfe, 0x0, 0xc, 0x3, 0x6d, 0xc7, 0x9c, 0x4f, 0x7a, 0x6e, 0x64, 0x2a, 0x1f, 0x87, 0x2a, 0x0, - 0x8, 0x4a, 0x1, 0x49, 0x2d, 0x7, 0x29, 0xf4, 0x65, 0x0, 0x14, 0x6f, 0xf9, 0xa, 0xef, 0x4a, 0xf9, - 0x44, 0x3e, 0x83, 0xef, 0xf2, 0x3e, 0xce, 0x1c, 0xc3, 0x91, 0xb0, 0x86, 0x19, 0x34}; + uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x65, 0xcc, 0x0, 0x1d, 0x74, + 0x61, 0xa3, 0x82, 0xe8, 0xaa, 0x9d, 0x90, 0xbe, 0x17, 0xac, 0xaa, 0x67, 0x22, 0x88, 0xe9, + 0x15, 0x15, 0xe7, 0x3, 0xa0, 0x16, 0x7e, 0x5, 0x47, 0xdc, 0xd0, 0x96, 0xf1, 0x0, 0x0, + 0x0, 0xd, 0xf4, 0x7e, 0xd9, 0x27, 0x54, 0x78, 0xee, 0xa4, 0xb3, 0xc1, 0x21, 0x2c, 0xa7}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6142,29 +5957,26 @@ TEST(Connect311QCTest, Encode18) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xfe}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3, 0x6d, 0xc7, 0x9c, 0x4f, 0x7a, 0x6e, 0x64, 0x2a, 0x1f, 0x87, 0x2a}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf4, 0x7e, 0xd9, 0x27, 0x54, 0x78, 0xee, 0xa4, 0xb3, 0xc1, 0x21, 0x2c, 0xa7}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 17571; - uint8_t client_id_bytes[] = {0x7d, 0xe3, 0x2f, 0xfc, 0xf5, 0x6e, 0x5d, 0x46, 0xbe, 0xf2, - 0x7c, 0x8d, 0xc2, 0xb4, 0x10, 0xc2, 0xbe, 0xe2, 0x57}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 26060; + uint8_t client_id_bytes[] = {0x74, 0x61, 0xa3, 0x82, 0xe8, 0xaa, 0x9d, 0x90, 0xbe, 0x17, 0xac, 0xaa, 0x67, 0x22, 0x88, + 0xe9, 0x15, 0x15, 0xe7, 0x3, 0xa0, 0x16, 0x7e, 0x5, 0x47, 0xdc, 0xd0, 0x96, 0xf1}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x4a, 0x1, 0x49, 0x2d, 0x7, 0x29, 0xf4, 0x65}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6f, 0xf9, 0xa, 0xef, 0x4a, 0xf9, 0x44, 0x3e, 0x83, 0xef, - 0xf2, 0x3e, 0xce, 0x1c, 0xc3, 0x91, 0xb0, 0x86, 0x19, 0x34}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xa3, 0x7d, 0x0, 0x79, 0x1e, 0x9e, 0x4e, 0x58, 0x34, 0xbb, 0xc3, 0xcb, 0x72, 0x7a, 0x6e, + 0xaa, 0x28, 0xac, 0x81, 0x92, 0x28, 0x5d, 0x6a, 0x72, 0xa8, 0x51, 0xa9, 0x20, 0xc3, 0xc8}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6174,16 +5986,21 @@ TEST(Connect311QCTest, Encode18) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\185\234\165\192W\204egO", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = -// "\254\234\SUB6\251\190\216\209\209\149\ETX\168\240\240\209\216\198rh\ETX\182!\187\172\232D", _willMsg = -// "\178\150\146w\234\131bw", _willProps = []}), _cleanSession = True, _keepAlive = 26206, _connID = -// "\225\SOY\244\214&\"\224\224\202\NAK\196\174", _properties = []} +// ConnectRequest {_username = Just +// "b\218e\239\183\CAN\191\&2\226\216\211h\139\177i\206P\217\216\241\162\247\&3Q0\255G", _password = Just +// "\134h4\201\252\b\204\DC1\165,\191\253\vJ\240X^\167\US\159\224(\229f\223c", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS0, _willTopic = "\165Ue\188\167\r\197\235M\161$\227j)\243\233e!X\DC2M\158}", _willMsg = +// ":])y\210Yhl\128}\247\163hG", _willProps = []}), _cleanSession = False, _keepAlive = 4784, _connID = +// "o\EOT\144\EOTo`,\SIr\191\185\&6i\246\150\254", _properties = []} TEST(Connect311QCTest, Encode19) { - uint8_t pkt[] = {0x10, 0x3f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x66, 0x5e, 0x0, 0xd, 0xe1, 0xe, 0x59, - 0xf4, 0xd6, 0x26, 0x22, 0xe0, 0xe0, 0xca, 0x15, 0xc4, 0xae, 0x0, 0x1a, 0xfe, 0xea, 0x1a, 0x36, 0xfb, - 0xbe, 0xd8, 0xd1, 0xd1, 0x95, 0x3, 0xa8, 0xf0, 0xf0, 0xd1, 0xd8, 0xc6, 0x72, 0x68, 0x3, 0xb6, 0x21, - 0xbb, 0xac, 0xe8, 0x44, 0x0, 0x8, 0xb2, 0x96, 0x92, 0x77, 0xea, 0x83, 0x62, 0x77}; + uint8_t pkt[] = {0x10, 0x7e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x12, 0xb0, 0x0, 0x10, 0x6f, 0x4, + 0x90, 0x4, 0x6f, 0x60, 0x2c, 0xf, 0x72, 0xbf, 0xb9, 0x36, 0x69, 0xf6, 0x96, 0xfe, 0x0, 0x17, + 0xa5, 0x55, 0x65, 0xbc, 0xa7, 0xd, 0xc5, 0xeb, 0x4d, 0xa1, 0x24, 0xe3, 0x6a, 0x29, 0xf3, 0xe9, + 0x65, 0x21, 0x58, 0x12, 0x4d, 0x9e, 0x7d, 0x0, 0xe, 0x3a, 0x5d, 0x29, 0x79, 0xd2, 0x59, 0x68, + 0x6c, 0x80, 0x7d, 0xf7, 0xa3, 0x68, 0x47, 0x0, 0x1b, 0x62, 0xda, 0x65, 0xef, 0xb7, 0x18, 0xbf, + 0x32, 0xe2, 0xd8, 0xd3, 0x68, 0x8b, 0xb1, 0x69, 0xce, 0x50, 0xd9, 0xd8, 0xf1, 0xa2, 0xf7, 0x33, + 0x51, 0x30, 0xff, 0x47, 0x0, 0x1a, 0x86, 0x68, 0x34, 0xc9, 0xfc, 0x8, 0xcc, 0x11, 0xa5, 0x2c, + 0xbf, 0xfd, 0xb, 0x4a, 0xf0, 0x58, 0x5e, 0xa7, 0x1f, 0x9f, 0xe0, 0x28, 0xe5, 0x66, 0xdf, 0x63}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6194,25 +6011,31 @@ TEST(Connect311QCTest, Encode19) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xfe, 0xea, 0x1a, 0x36, 0xfb, 0xbe, 0xd8, 0xd1, 0xd1, 0x95, 0x3, 0xa8, 0xf0, - 0xf0, 0xd1, 0xd8, 0xc6, 0x72, 0x68, 0x3, 0xb6, 0x21, 0xbb, 0xac, 0xe8, 0x44}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb2, 0x96, 0x92, 0x77, 0xea, 0x83, 0x62, 0x77}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xa5, 0x55, 0x65, 0xbc, 0xa7, 0xd, 0xc5, 0xeb, 0x4d, 0xa1, 0x24, 0xe3, + 0x6a, 0x29, 0xf3, 0xe9, 0x65, 0x21, 0x58, 0x12, 0x4d, 0x9e, 0x7d}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3a, 0x5d, 0x29, 0x79, 0xd2, 0x59, 0x68, 0x6c, 0x80, 0x7d, 0xf7, 0xa3, 0x68, 0x47}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 26206; - uint8_t client_id_bytes[] = {0xe1, 0xe, 0x59, 0xf4, 0xd6, 0x26, 0x22, 0xe0, 0xe0, 0xca, 0x15, 0xc4, 0xae}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 4784; + uint8_t client_id_bytes[] = {0x6f, 0x4, 0x90, 0x4, 0x6f, 0x60, 0x2c, 0xf, + 0x72, 0xbf, 0xb9, 0x36, 0x69, 0xf6, 0x96, 0xfe}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xb9, 0xea, 0xa5, 0xc0, 0x57, 0xcc, 0x65, 0x67, 0x4f}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x62, 0xda, 0x65, 0xef, 0xb7, 0x18, 0xbf, 0x32, 0xe2, 0xd8, 0xd3, 0x68, 0x8b, 0xb1, + 0x69, 0xce, 0x50, 0xd9, 0xd8, 0xf1, 0xa2, 0xf7, 0x33, 0x51, 0x30, 0xff, 0x47}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x86, 0x68, 0x34, 0xc9, 0xfc, 0x8, 0xcc, 0x11, 0xa5, 0x2c, 0xbf, 0xfd, 0xb, + 0x4a, 0xf0, 0x58, 0x5e, 0xa7, 0x1f, 0x9f, 0xe0, 0x28, 0xe5, 0x66, 0xdf, 0x63}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6222,16 +6045,14 @@ TEST(Connect311QCTest, Encode19) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\204\&9\146\248Z\193\151\237F\231u\205\207?\138\180*}\164\191\"\DEL\198$\DC3", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\DC2L", _willMsg -// = "\187\173\179\182\226\182\159\197\SO<\158\197/\170\130\157\210\201\222", _willProps = []}), _cleanSession = False, -// _keepAlive = 15691, _connID = ",\205\DC2;&\213%\165D\167", _properties = []} +// ConnectRequest {_username = Just "%0V8\236", _password = Just "Q\245\GS\148#\160\195\156\184jCX\DC3\EM4k", _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "w%h\153A\237", _willMsg = "\GS\201n\b\226\NUL", +// _willProps = []}), _cleanSession = True, _keepAlive = 17312, _connID = "\201\234;\NAKS", _properties = []} TEST(Connect311QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0x4a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x84, 0x3d, 0x4b, 0x0, 0xa, 0x2c, 0xcd, - 0x12, 0x3b, 0x26, 0xd5, 0x25, 0xa5, 0x44, 0xa7, 0x0, 0x2, 0x12, 0x4c, 0x0, 0x13, 0xbb, 0xad, - 0xb3, 0xb6, 0xe2, 0xb6, 0x9f, 0xc5, 0xe, 0x3c, 0x9e, 0xc5, 0x2f, 0xaa, 0x82, 0x9d, 0xd2, 0xc9, - 0xde, 0x0, 0x19, 0xcc, 0x39, 0x92, 0xf8, 0x5a, 0xc1, 0x97, 0xed, 0x46, 0xe7, 0x75, 0xcd, 0xcf, - 0x3f, 0x8a, 0xb4, 0x2a, 0x7d, 0xa4, 0xbf, 0x22, 0x7f, 0xc6, 0x24, 0x13}; + uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x43, 0xa0, 0x0, 0x5, 0xc9, + 0xea, 0x3b, 0x15, 0x53, 0x0, 0x6, 0x77, 0x25, 0x68, 0x99, 0x41, 0xed, 0x0, 0x6, 0x1d, + 0xc9, 0x6e, 0x8, 0xe2, 0x0, 0x0, 0x5, 0x25, 0x30, 0x56, 0x38, 0xec, 0x0, 0x10, 0x51, + 0xf5, 0x1d, 0x94, 0x23, 0xa0, 0xc3, 0x9c, 0xb8, 0x6a, 0x43, 0x58, 0x13, 0x19, 0x34, 0x6b}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6242,11 +6063,10 @@ TEST(Connect311QCTest, Encode20) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x12, 0x4c}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbb, 0xad, 0xb3, 0xb6, 0xe2, 0xb6, 0x9f, 0xc5, 0xe, 0x3c, - 0x9e, 0xc5, 0x2f, 0xaa, 0x82, 0x9d, 0xd2, 0xc9, 0xde}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x77, 0x25, 0x68, 0x99, 0x41, 0xed}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1d, 0xc9, 0x6e, 0x8, 0xe2, 0x0}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -6254,15 +6074,18 @@ TEST(Connect311QCTest, Encode20) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 15691; - uint8_t client_id_bytes[] = {0x2c, 0xcd, 0x12, 0x3b, 0x26, 0xd5, 0x25, 0xa5, 0x44, 0xa7}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 17312; + uint8_t client_id_bytes[] = {0xc9, 0xea, 0x3b, 0x15, 0x53}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xcc, 0x39, 0x92, 0xf8, 0x5a, 0xc1, 0x97, 0xed, 0x46, 0xe7, 0x75, 0xcd, 0xcf, - 0x3f, 0x8a, 0xb4, 0x2a, 0x7d, 0xa4, 0xbf, 0x22, 0x7f, 0xc6, 0x24, 0x13}; - lwmqtt_string_t username = {25, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x25, 0x30, 0x56, 0x38, 0xec}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x51, 0xf5, 0x1d, 0x94, 0x23, 0xa0, 0xc3, 0x9c, + 0xb8, 0x6a, 0x43, 0x58, 0x13, 0x19, 0x34, 0x6b}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6271,19 +6094,17 @@ TEST(Connect311QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "T>\158;\152\162\180\181\207:\ETB{u\142\245\154\140w", _password = Just -// "\220\STXp\210}\178\179y\171", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "\187\ACK\FS\183\136\196\202@\150G&%;\224\149\140\ETB\223] \145\&61:y\199", _willMsg = "\218\200 -// \235O\SYN\vs\250\233G\156\217.\200\235x\198r\202fF\SUB\147\252\255\197", _willProps = []}), _cleanSession = True, -// _keepAlive = 7593, _connID = "-e~\r", _properties = []} +// ConnectRequest {_username = Just "\n\216?v+\184\ACKT", _password = Just "f\232\200\n", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "R\180\EM\225w\208\US\DC2X5\243[\225:a\225\DC17\225BK4", _willMsg +// = "\SUB\214\DC3\210\166<\201\147Vy\142\f\161\223BFAO,\EOT\178OU", _willProps = []}), _cleanSession = True, _keepAlive +// = 20729, _connID = ")\f6\175\243\RS\147wQ\178\140rR", _properties = []} TEST(Connect311QCTest, Encode21) { - uint8_t pkt[] = {0x10, 0x68, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x1d, 0xa9, 0x0, 0x4, 0x2d, 0x65, - 0x7e, 0xd, 0x0, 0x1a, 0xbb, 0x6, 0x1c, 0xb7, 0x88, 0xc4, 0xca, 0x40, 0x96, 0x47, 0x26, 0x25, - 0x3b, 0xe0, 0x95, 0x8c, 0x17, 0xdf, 0x5d, 0x20, 0x91, 0x36, 0x31, 0x3a, 0x79, 0xc7, 0x0, 0x1b, - 0xda, 0xc8, 0x20, 0xeb, 0x4f, 0x16, 0xb, 0x73, 0xfa, 0xe9, 0x47, 0x9c, 0xd9, 0x2e, 0xc8, 0xeb, - 0x78, 0xc6, 0x72, 0xca, 0x66, 0x46, 0x1a, 0x93, 0xfc, 0xff, 0xc5, 0x0, 0x12, 0x54, 0x3e, 0x9e, - 0x3b, 0x98, 0xa2, 0xb4, 0xb5, 0xcf, 0x3a, 0x17, 0x7b, 0x75, 0x8e, 0xf5, 0x9a, 0x8c, 0x77, 0x0, - 0x9, 0xdc, 0x2, 0x70, 0xd2, 0x7d, 0xb2, 0xb3, 0x79, 0xab}; + uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x50, 0xf9, 0x0, 0xd, 0x29, 0xc, + 0x36, 0xaf, 0xf3, 0x1e, 0x93, 0x77, 0x51, 0xb2, 0x8c, 0x72, 0x52, 0x0, 0x16, 0x52, 0xb4, 0x19, + 0xe1, 0x77, 0xd0, 0x1f, 0x12, 0x58, 0x35, 0xf3, 0x5b, 0xe1, 0x3a, 0x61, 0xe1, 0x11, 0x37, 0xe1, + 0x42, 0x4b, 0x34, 0x0, 0x17, 0x1a, 0xd6, 0x13, 0xd2, 0xa6, 0x3c, 0xc9, 0x93, 0x56, 0x79, 0x8e, + 0xc, 0xa1, 0xdf, 0x42, 0x46, 0x41, 0x4f, 0x2c, 0x4, 0xb2, 0x4f, 0x55, 0x0, 0x8, 0xa, 0xd8, + 0x3f, 0x76, 0x2b, 0xb8, 0x6, 0x54, 0x0, 0x4, 0x66, 0xe8, 0xc8, 0xa}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6294,30 +6115,29 @@ TEST(Connect311QCTest, Encode21) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbb, 0x6, 0x1c, 0xb7, 0x88, 0xc4, 0xca, 0x40, 0x96, 0x47, 0x26, 0x25, 0x3b, - 0xe0, 0x95, 0x8c, 0x17, 0xdf, 0x5d, 0x20, 0x91, 0x36, 0x31, 0x3a, 0x79, 0xc7}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xda, 0xc8, 0x20, 0xeb, 0x4f, 0x16, 0xb, 0x73, 0xfa, 0xe9, 0x47, 0x9c, 0xd9, 0x2e, - 0xc8, 0xeb, 0x78, 0xc6, 0x72, 0xca, 0x66, 0x46, 0x1a, 0x93, 0xfc, 0xff, 0xc5}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x52, 0xb4, 0x19, 0xe1, 0x77, 0xd0, 0x1f, 0x12, 0x58, 0x35, 0xf3, + 0x5b, 0xe1, 0x3a, 0x61, 0xe1, 0x11, 0x37, 0xe1, 0x42, 0x4b, 0x34}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1a, 0xd6, 0x13, 0xd2, 0xa6, 0x3c, 0xc9, 0x93, 0x56, 0x79, 0x8e, 0xc, + 0xa1, 0xdf, 0x42, 0x46, 0x41, 0x4f, 0x2c, 0x4, 0xb2, 0x4f, 0x55}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 7593; - uint8_t client_id_bytes[] = {0x2d, 0x65, 0x7e, 0xd}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.keep_alive = 20729; + uint8_t client_id_bytes[] = {0x29, 0xc, 0x36, 0xaf, 0xf3, 0x1e, 0x93, 0x77, 0x51, 0xb2, 0x8c, 0x72, 0x52}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x54, 0x3e, 0x9e, 0x3b, 0x98, 0xa2, 0xb4, 0xb5, 0xcf, - 0x3a, 0x17, 0x7b, 0x75, 0x8e, 0xf5, 0x9a, 0x8c, 0x77}; - lwmqtt_string_t username = {18, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa, 0xd8, 0x3f, 0x76, 0x2b, 0xb8, 0x6, 0x54}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xdc, 0x2, 0x70, 0xd2, 0x7d, 0xb2, 0xb3, 0x79, 0xab}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x66, 0xe8, 0xc8, 0xa}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6327,16 +6147,14 @@ TEST(Connect311QCTest, Encode21) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "/O\134\NAKdJ", _password = Just -// "\196\156\220\155\135\182\vb\vM\183\205\156r\135f`\148\245\162\148\&5\243`G\196\184*\154", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 23419, _connID = "\138\r,\181sl\193\231\232\198\"\231/\251W\218!s", _properties = -// []} +// ConnectRequest {_username = Just "\218", _password = Just +// "\157\199_\231w\v\CAN\198\175\204\172\255\223\220\130\250!\147\249\203$a\136\131\EMn\SOHO\252", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 1033, _connID = "\252\aa\128~\196\ESC\154\131\&6\174", _properties = []} TEST(Connect311QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0x45, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x5b, 0x7b, 0x0, 0x12, 0x8a, - 0xd, 0x2c, 0xb5, 0x73, 0x6c, 0xc1, 0xe7, 0xe8, 0xc6, 0x22, 0xe7, 0x2f, 0xfb, 0x57, 0xda, - 0x21, 0x73, 0x0, 0x6, 0x2f, 0x4f, 0x86, 0x15, 0x64, 0x4a, 0x0, 0x1d, 0xc4, 0x9c, 0xdc, - 0x9b, 0x87, 0xb6, 0xb, 0x62, 0xb, 0x4d, 0xb7, 0xcd, 0x9c, 0x72, 0x87, 0x66, 0x60, 0x94, - 0xf5, 0xa2, 0x94, 0x35, 0xf3, 0x60, 0x47, 0xc4, 0xb8, 0x2a, 0x9a}; + uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x4, 0x9, 0x0, 0xb, 0xfc, + 0x7, 0x61, 0x80, 0x7e, 0xc4, 0x1b, 0x9a, 0x83, 0x36, 0xae, 0x0, 0x1, 0xda, 0x0, 0x1d, + 0x9d, 0xc7, 0x5f, 0xe7, 0x77, 0xb, 0x18, 0xc6, 0xaf, 0xcc, 0xac, 0xff, 0xdf, 0xdc, 0x82, + 0xfa, 0x21, 0x93, 0xf9, 0xcb, 0x24, 0x61, 0x88, 0x83, 0x19, 0x6e, 0x1, 0x4f, 0xfc}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6345,16 +6163,15 @@ TEST(Connect311QCTest, Encode22) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 23419; - uint8_t client_id_bytes[] = {0x8a, 0xd, 0x2c, 0xb5, 0x73, 0x6c, 0xc1, 0xe7, 0xe8, - 0xc6, 0x22, 0xe7, 0x2f, 0xfb, 0x57, 0xda, 0x21, 0x73}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.keep_alive = 1033; + uint8_t client_id_bytes[] = {0xfc, 0x7, 0x61, 0x80, 0x7e, 0xc4, 0x1b, 0x9a, 0x83, 0x36, 0xae}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2f, 0x4f, 0x86, 0x15, 0x64, 0x4a}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xda}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xc4, 0x9c, 0xdc, 0x9b, 0x87, 0xb6, 0xb, 0x62, 0xb, 0x4d, 0xb7, 0xcd, 0x9c, 0x72, 0x87, - 0x66, 0x60, 0x94, 0xf5, 0xa2, 0x94, 0x35, 0xf3, 0x60, 0x47, 0xc4, 0xb8, 0x2a, 0x9a}; + uint8_t password_bytes[] = {0x9d, 0xc7, 0x5f, 0xe7, 0x77, 0xb, 0x18, 0xc6, 0xaf, 0xcc, 0xac, 0xff, 0xdf, 0xdc, 0x82, + 0xfa, 0x21, 0x93, 0xf9, 0xcb, 0x24, 0x61, 0x88, 0x83, 0x19, 0x6e, 0x1, 0x4f, 0xfc}; lwmqtt_string_t password = {29, (char*)&password_bytes}; opts.password = password; size_t len = 0; @@ -6365,20 +6182,16 @@ TEST(Connect311QCTest, Encode22) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\247\SI;~\246\226", _password = Just -// "\182\193\204\184\SI\251\239\221G\188,\207\181\222\169\DC2a\166\156\180\a\253\242", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\149\199O\138Vs\224&_\202\180\SYN\148\241G3\232\196)$~\216\157\181\176!", _willMsg = -// "_\241\DC4V97\239\206\170C\b\207\&9\170\141\GS3\216\234\DC4\141", _willProps = []}), _cleanSession = True, _keepAlive -// = 7, _connID = "G\\kY\SOH\242", _properties = []} +// ConnectRequest {_username = Just "\140\163RpjPE\225/:\ESC", _password = Just +// "\224\162k\234^k\194\DC3\157\n\DC4\228\216\234\160.o\NAKr\219\DC1\ETB", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS0, _willTopic = "\138\162?\130\159\141?\154+\DC4B\246\249\DEL1;-\244\132W;", _willMsg = +// "~j\245\255", _willProps = []}), _cleanSession = False, _keepAlive = 9554, _connID = "", _properties = []} TEST(Connect311QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0x66, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x0, 0x7, 0x0, 0x6, 0x47, - 0x5c, 0x6b, 0x59, 0x1, 0xf2, 0x0, 0x1a, 0x95, 0xc7, 0x4f, 0x8a, 0x56, 0x73, 0xe0, 0x26, - 0x5f, 0xca, 0xb4, 0x16, 0x94, 0xf1, 0x47, 0x33, 0xe8, 0xc4, 0x29, 0x24, 0x7e, 0xd8, 0x9d, - 0xb5, 0xb0, 0x21, 0x0, 0x15, 0x5f, 0xf1, 0x14, 0x56, 0x39, 0x37, 0xef, 0xce, 0xaa, 0x43, - 0x8, 0xcf, 0x39, 0xaa, 0x8d, 0x1d, 0x33, 0xd8, 0xea, 0x14, 0x8d, 0x0, 0x6, 0xf7, 0xf, - 0x3b, 0x7e, 0xf6, 0xe2, 0x0, 0x17, 0xb6, 0xc1, 0xcc, 0xb8, 0xf, 0xfb, 0xef, 0xdd, 0x47, - 0xbc, 0x2c, 0xcf, 0xb5, 0xde, 0xa9, 0x12, 0x61, 0xa6, 0x9c, 0xb4, 0x7, 0xfd, 0xf2}; + uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x25, 0x52, 0x0, 0x0, 0x0, 0x15, + 0x8a, 0xa2, 0x3f, 0x82, 0x9f, 0x8d, 0x3f, 0x9a, 0x2b, 0x14, 0x42, 0xf6, 0xf9, 0x7f, 0x31, 0x3b, + 0x2d, 0xf4, 0x84, 0x57, 0x3b, 0x0, 0x4, 0x7e, 0x6a, 0xf5, 0xff, 0x0, 0xb, 0x8c, 0xa3, 0x52, + 0x70, 0x6a, 0x50, 0x45, 0xe1, 0x2f, 0x3a, 0x1b, 0x0, 0x16, 0xe0, 0xa2, 0x6b, 0xea, 0x5e, 0x6b, + 0xc2, 0x13, 0x9d, 0xa, 0x14, 0xe4, 0xd8, 0xea, 0xa0, 0x2e, 0x6f, 0x15, 0x72, 0xdb, 0x11, 0x17}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6389,30 +6202,29 @@ TEST(Connect311QCTest, Encode23) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x95, 0xc7, 0x4f, 0x8a, 0x56, 0x73, 0xe0, 0x26, 0x5f, 0xca, 0xb4, 0x16, 0x94, - 0xf1, 0x47, 0x33, 0xe8, 0xc4, 0x29, 0x24, 0x7e, 0xd8, 0x9d, 0xb5, 0xb0, 0x21}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5f, 0xf1, 0x14, 0x56, 0x39, 0x37, 0xef, 0xce, 0xaa, 0x43, 0x8, - 0xcf, 0x39, 0xaa, 0x8d, 0x1d, 0x33, 0xd8, 0xea, 0x14, 0x8d}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x8a, 0xa2, 0x3f, 0x82, 0x9f, 0x8d, 0x3f, 0x9a, 0x2b, 0x14, 0x42, + 0xf6, 0xf9, 0x7f, 0x31, 0x3b, 0x2d, 0xf4, 0x84, 0x57, 0x3b}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7e, 0x6a, 0xf5, 0xff}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 7; - uint8_t client_id_bytes[] = {0x47, 0x5c, 0x6b, 0x59, 0x1, 0xf2}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 9554; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf7, 0xf, 0x3b, 0x7e, 0xf6, 0xe2}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x8c, 0xa3, 0x52, 0x70, 0x6a, 0x50, 0x45, 0xe1, 0x2f, 0x3a, 0x1b}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xb6, 0xc1, 0xcc, 0xb8, 0xf, 0xfb, 0xef, 0xdd, 0x47, 0xbc, 0x2c, 0xcf, - 0xb5, 0xde, 0xa9, 0x12, 0x61, 0xa6, 0x9c, 0xb4, 0x7, 0xfd, 0xf2}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe0, 0xa2, 0x6b, 0xea, 0x5e, 0x6b, 0xc2, 0x13, 0x9d, 0xa, 0x14, + 0xe4, 0xd8, 0xea, 0xa0, 0x2e, 0x6f, 0x15, 0x72, 0xdb, 0x11, 0x17}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6422,87 +6234,119 @@ TEST(Connect311QCTest, Encode23) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "{?~\139\226tEG\tA\FSI\236\230e<\SOH", _password = Just -// "\203)t\136\")\169\SID\246\237\158\241\231\162>!\140", _lastWill = Nothing, _cleanSession = True, _keepAlive = 8810, -// _connID = "n\253\208>\v\187pU\197NY\228\&5w!\237\179\179\SI\213", _properties = []} +// ConnectRequest {_username = Just "\184\n\192\249\GS\b\140\182\DC3\152 }=&7\DC4\181k", _password = Just +// "\150/\SO\220", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\r\243Owl", _willMsg = +// "\251\re\178 \ACK\242Y2h\FS\DEL\160X\254\171\133\v\217\160\DC2p\DC1\207\EM", _willProps = []}), _cleanSession = True, +// _keepAlive = 22347, _connID = "\148/\140]", _properties = []} TEST(Connect311QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x22, 0x6a, 0x0, 0x14, 0x6e, - 0xfd, 0xd0, 0x3e, 0xb, 0xbb, 0x70, 0x55, 0xc5, 0x4e, 0x59, 0xe4, 0x35, 0x77, 0x21, 0xed, - 0xb3, 0xb3, 0xf, 0xd5, 0x0, 0x11, 0x7b, 0x3f, 0x7e, 0x8b, 0xe2, 0x74, 0x45, 0x47, 0x9, - 0x41, 0x1c, 0x49, 0xec, 0xe6, 0x65, 0x3c, 0x1, 0x0, 0x12, 0xcb, 0x29, 0x74, 0x88, 0x22, - 0x29, 0xa9, 0xf, 0x44, 0xf6, 0xed, 0x9e, 0xf1, 0xe7, 0xa2, 0x3e, 0x21, 0x8c}; + uint8_t pkt[] = {0x10, 0x4c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x57, 0x4b, 0x0, 0x4, 0x94, 0x2f, + 0x8c, 0x5d, 0x0, 0x5, 0xd, 0xf3, 0x4f, 0x77, 0x6c, 0x0, 0x19, 0xfb, 0xd, 0x65, 0xb2, 0x20, + 0x6, 0xf2, 0x59, 0x32, 0x68, 0x1c, 0x7f, 0xa0, 0x58, 0xfe, 0xab, 0x85, 0xb, 0xd9, 0xa0, 0x12, + 0x70, 0x11, 0xcf, 0x19, 0x0, 0x12, 0xb8, 0xa, 0xc0, 0xf9, 0x1d, 0x8, 0x8c, 0xb6, 0x13, 0x98, + 0x20, 0x7d, 0x3d, 0x26, 0x37, 0x14, 0xb5, 0x6b, 0x0, 0x4, 0x96, 0x2f, 0xe, 0xdc}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd, 0xf3, 0x4f, 0x77, 0x6c}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfb, 0xd, 0x65, 0xb2, 0x20, 0x6, 0xf2, 0x59, 0x32, 0x68, 0x1c, 0x7f, 0xa0, + 0x58, 0xfe, 0xab, 0x85, 0xb, 0xd9, 0xa0, 0x12, 0x70, 0x11, 0xcf, 0x19}; + lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 8810; - uint8_t client_id_bytes[] = {0x6e, 0xfd, 0xd0, 0x3e, 0xb, 0xbb, 0x70, 0x55, 0xc5, 0x4e, - 0x59, 0xe4, 0x35, 0x77, 0x21, 0xed, 0xb3, 0xb3, 0xf, 0xd5}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.keep_alive = 22347; + uint8_t client_id_bytes[] = {0x94, 0x2f, 0x8c, 0x5d}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x7b, 0x3f, 0x7e, 0x8b, 0xe2, 0x74, 0x45, 0x47, 0x9, - 0x41, 0x1c, 0x49, 0xec, 0xe6, 0x65, 0x3c, 0x1}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb8, 0xa, 0xc0, 0xf9, 0x1d, 0x8, 0x8c, 0xb6, 0x13, + 0x98, 0x20, 0x7d, 0x3d, 0x26, 0x37, 0x14, 0xb5, 0x6b}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xcb, 0x29, 0x74, 0x88, 0x22, 0x29, 0xa9, 0xf, 0x44, - 0xf6, 0xed, 0x9e, 0xf1, 0xe7, 0xa2, 0x3e, 0x21, 0x8c}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x96, 0x2f, 0xe, 0xdc}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\132\241o\219m\247lL]\193i\175", _password = Just "\CANv\229k\211\205", _lastWill = -// Nothing, _cleanSession = True, _keepAlive = 7935, _connID = "\ETB\208H\169\248J\183R\169p\FS\190\DEL\182~\SYN", -// _properties = []} +// ConnectRequest {_username = Just "\183\178\ESC", _password = Just "-\203Id", _lastWill = Just (LastWill {_willRetain +// = False, _willQoS = QoS1, _willTopic = +// "oH%\176\195\240\217\234x\176Z\ETX\204\SO\DC3\DEL\138\181\252\US\254\147\218:\146\231\\\144", _willMsg = "n\EM\186", +// _willProps = []}), _cleanSession = True, _keepAlive = 18592, _connID = "\155j\169\&4\DC3T\219\&4P", _properties = []} TEST(Connect311QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0x32, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x1e, 0xff, 0x0, - 0x10, 0x17, 0xd0, 0x48, 0xa9, 0xf8, 0x4a, 0xb7, 0x52, 0xa9, 0x70, 0x1c, 0xbe, - 0x7f, 0xb6, 0x7e, 0x16, 0x0, 0xc, 0x84, 0xf1, 0x6f, 0xdb, 0x6d, 0xf7, 0x6c, - 0x4c, 0x5d, 0xc1, 0x69, 0xaf, 0x0, 0x6, 0x18, 0x76, 0xe5, 0x6b, 0xd3, 0xcd}; + uint8_t pkt[] = {0x10, 0x43, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x48, 0xa0, 0x0, 0x9, + 0x9b, 0x6a, 0xa9, 0x34, 0x13, 0x54, 0xdb, 0x34, 0x50, 0x0, 0x1c, 0x6f, 0x48, 0x25, + 0xb0, 0xc3, 0xf0, 0xd9, 0xea, 0x78, 0xb0, 0x5a, 0x3, 0xcc, 0xe, 0x13, 0x7f, 0x8a, + 0xb5, 0xfc, 0x1f, 0xfe, 0x93, 0xda, 0x3a, 0x92, 0xe7, 0x5c, 0x90, 0x0, 0x3, 0x6e, + 0x19, 0xba, 0x0, 0x3, 0xb7, 0xb2, 0x1b, 0x0, 0x4, 0x2d, 0xcb, 0x49, 0x64}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x6f, 0x48, 0x25, 0xb0, 0xc3, 0xf0, 0xd9, 0xea, 0x78, 0xb0, 0x5a, 0x3, 0xcc, 0xe, + 0x13, 0x7f, 0x8a, 0xb5, 0xfc, 0x1f, 0xfe, 0x93, 0xda, 0x3a, 0x92, 0xe7, 0x5c, 0x90}; + lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6e, 0x19, 0xba}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 7935; - uint8_t client_id_bytes[] = {0x17, 0xd0, 0x48, 0xa9, 0xf8, 0x4a, 0xb7, 0x52, - 0xa9, 0x70, 0x1c, 0xbe, 0x7f, 0xb6, 0x7e, 0x16}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.keep_alive = 18592; + uint8_t client_id_bytes[] = {0x9b, 0x6a, 0xa9, 0x34, 0x13, 0x54, 0xdb, 0x34, 0x50}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x84, 0xf1, 0x6f, 0xdb, 0x6d, 0xf7, 0x6c, 0x4c, 0x5d, 0xc1, 0x69, 0xaf}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb7, 0xb2, 0x1b}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x18, 0x76, 0xe5, 0x6b, 0xd3, 0xcd}; - lwmqtt_string_t password = {6, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x2d, 0xcb, 0x49, 0x64}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "d\140\&3,\181\151\SI[\ACK\153\237\181<<\225\185\SO", _lastWill -// = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "N\173\211", _willMsg = "c\251\173\SOHT\f\251", -// _willProps = []}), _cleanSession = True, _keepAlive = 10911, _connID = "\137\138\233WV \249\146:\152V\141\176'z", -// _properties = []} +// ConnectRequest {_username = Just "\164\207\151\149\193\237\154\&5;\151\f\187\235\141\182k?\198\208\205\150", +// _password = Just "\238\185\&5!R\163\189", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic +// = "\162r\149\182\167\158V@)qJ\240#\236\180\134\195xN", _willMsg = "y\213_\183\130", _willProps = []}), _cleanSession +// = False, _keepAlive = 10272, _connID = "\171\r5?\187", _properties = []} TEST(Connect311QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0x29, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x2a, 0x9f, 0x0, 0xf, 0x89, - 0x8a, 0xe9, 0x57, 0x56, 0x20, 0xf9, 0x92, 0x3a, 0x98, 0x56, 0x8d, 0xb0, 0x27, 0x7a, 0x0, - 0x3, 0x4e, 0xad, 0xd3, 0x0, 0x7, 0x63, 0xfb, 0xad, 0x1, 0x54, 0xc, 0xfb}; + uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x28, 0x20, 0x0, 0x5, 0xab, 0xd, + 0x35, 0x3f, 0xbb, 0x0, 0x13, 0xa2, 0x72, 0x95, 0xb6, 0xa7, 0x9e, 0x56, 0x40, 0x29, 0x71, 0x4a, + 0xf0, 0x23, 0xec, 0xb4, 0x86, 0xc3, 0x78, 0x4e, 0x0, 0x5, 0x79, 0xd5, 0x5f, 0xb7, 0x82, 0x0, + 0x15, 0xa4, 0xcf, 0x97, 0x95, 0xc1, 0xed, 0x9a, 0x35, 0x3b, 0x97, 0xc, 0xbb, 0xeb, 0x8d, 0xb6, + 0x6b, 0x3f, 0xc6, 0xd0, 0xcd, 0x96, 0x0, 0x7, 0xee, 0xb9, 0x35, 0x21, 0x52, 0xa3, 0xbd}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6513,26 +6357,29 @@ TEST(Connect311QCTest, Encode26) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4e, 0xad, 0xd3}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x63, 0xfb, 0xad, 0x1, 0x54, 0xc, 0xfb}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xa2, 0x72, 0x95, 0xb6, 0xa7, 0x9e, 0x56, 0x40, 0x29, 0x71, + 0x4a, 0xf0, 0x23, 0xec, 0xb4, 0x86, 0xc3, 0x78, 0x4e}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x79, 0xd5, 0x5f, 0xb7, 0x82}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS1; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 10911; - uint8_t client_id_bytes[] = {0x89, 0x8a, 0xe9, 0x57, 0x56, 0x20, 0xf9, 0x92, - 0x3a, 0x98, 0x56, 0x8d, 0xb0, 0x27, 0x7a}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 10272; + uint8_t client_id_bytes[] = {0xab, 0xd, 0x35, 0x3f, 0xbb}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x64, 0x8c, 0x33, 0x2c, 0xb5, 0x97, 0xf, 0x5b, 0x6, - 0x99, 0xed, 0xb5, 0x3c, 0x3c, 0xe1, 0xb9, 0xe}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xa4, 0xcf, 0x97, 0x95, 0xc1, 0xed, 0x9a, 0x35, 0x3b, 0x97, 0xc, + 0xbb, 0xeb, 0x8d, 0xb6, 0x6b, 0x3f, 0xc6, 0xd0, 0xcd, 0x96}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xee, 0xb9, 0x35, 0x21, 0x52, 0xa3, 0xbd}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6542,18 +6389,13 @@ TEST(Connect311QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\190\254\vG\140\DLEq\206\199\&1\235y\135a\b", _password = Just -// "(\ESC\DC14\172tH/\136\240\225", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = -// "'\SOH\141M", _willMsg = "\199I\t\155\SOHg\135,\200F\135\EM;\233J\152\NAK\ESCD\SUB\t\193M\DEL\220^\163\214", -// _willProps = []}), _cleanSession = True, _keepAlive = 14063, _connID = -// "\137\196\DC1\230\"\199\249,\241\a\f\239\159\223\170N\240\248\184\172", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS0, _willTopic = "\SIj\176\132r\238\172\184r\158pjf\GS\159\&7\185\DEL\211", _willMsg = "", _willProps = []}), +// _cleanSession = False, _keepAlive = 10342, _connID = "F/\a\165\170Bk\248\200\ENQ\199\172\&4\128", _properties = []} TEST(Connect311QCTest, Encode27) { - uint8_t pkt[] = {0x10, 0x62, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x36, 0xef, 0x0, 0x14, 0x89, 0xc4, 0x11, - 0xe6, 0x22, 0xc7, 0xf9, 0x2c, 0xf1, 0x7, 0xc, 0xef, 0x9f, 0xdf, 0xaa, 0x4e, 0xf0, 0xf8, 0xb8, 0xac, - 0x0, 0x4, 0x27, 0x1, 0x8d, 0x4d, 0x0, 0x1c, 0xc7, 0x49, 0x9, 0x9b, 0x1, 0x67, 0x87, 0x2c, 0xc8, - 0x46, 0x87, 0x19, 0x3b, 0xe9, 0x4a, 0x98, 0x15, 0x1b, 0x44, 0x1a, 0x9, 0xc1, 0x4d, 0x7f, 0xdc, 0x5e, - 0xa3, 0xd6, 0x0, 0xf, 0xbe, 0xfe, 0xb, 0x47, 0x8c, 0x10, 0x71, 0xce, 0xc7, 0x31, 0xeb, 0x79, 0x87, - 0x61, 0x8, 0x0, 0xb, 0x28, 0x1b, 0x11, 0x34, 0xac, 0x74, 0x48, 0x2f, 0x88, 0xf0, 0xe1}; + uint8_t pkt[] = {0x10, 0x31, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x4, 0x28, 0x66, 0x0, 0xe, 0x46, 0x2f, 0x7, + 0xa5, 0xaa, 0x42, 0x6b, 0xf8, 0xc8, 0x5, 0xc7, 0xac, 0x34, 0x80, 0x0, 0x13, 0xf, 0x6a, 0xb0, 0x84, + 0x72, 0xee, 0xac, 0xb8, 0x72, 0x9e, 0x70, 0x6a, 0x66, 0x1d, 0x9f, 0x37, 0xb9, 0x7f, 0xd3, 0x0, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6564,30 +6406,23 @@ TEST(Connect311QCTest, Encode27) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x27, 0x1, 0x8d, 0x4d}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc7, 0x49, 0x9, 0x9b, 0x1, 0x67, 0x87, 0x2c, 0xc8, 0x46, 0x87, 0x19, 0x3b, 0xe9, - 0x4a, 0x98, 0x15, 0x1b, 0x44, 0x1a, 0x9, 0xc1, 0x4d, 0x7f, 0xdc, 0x5e, 0xa3, 0xd6}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xf, 0x6a, 0xb0, 0x84, 0x72, 0xee, 0xac, 0xb8, 0x72, 0x9e, + 0x70, 0x6a, 0x66, 0x1d, 0x9f, 0x37, 0xb9, 0x7f, 0xd3}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14063; - uint8_t client_id_bytes[] = {0x89, 0xc4, 0x11, 0xe6, 0x22, 0xc7, 0xf9, 0x2c, 0xf1, 0x7, - 0xc, 0xef, 0x9f, 0xdf, 0xaa, 0x4e, 0xf0, 0xf8, 0xb8, 0xac}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 10342; + uint8_t client_id_bytes[] = {0x46, 0x2f, 0x7, 0xa5, 0xaa, 0x42, 0x6b, 0xf8, 0xc8, 0x5, 0xc7, 0xac, 0x34, 0x80}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xbe, 0xfe, 0xb, 0x47, 0x8c, 0x10, 0x71, 0xce, 0xc7, 0x31, 0xeb, 0x79, 0x87, 0x61, 0x8}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x28, 0x1b, 0x11, 0x34, 0xac, 0x74, 0x48, 0x2f, 0x88, 0xf0, 0xe1}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6596,18 +6431,18 @@ TEST(Connect311QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "%\DC3/-\bG2\192\137\196&\128\209\143\235\SI\201\&6\r\216vK\196dI\195\144G", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\132~x\156KS\246y\137\249\SYN\154%\145\149T\195\188", _willMsg = -// "X\195\&0\237\DC1l\222\ETX\219\&9\128\"\210/\254\243Q\204\169^H", _willProps = []}), _cleanSession = False, -// _keepAlive = 9629, _connID = "u\226c\130\167Y\128L\255\&1\SI\232\190", _properties = []} +// ConnectRequest {_username = Just "\177,\US\162\249\rU", _password = Just "\186$\184J\CAN:\210T\160t\185\242", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\248\192cB\223\ACK\132s!q\246\236pQ-R", _willMsg = "@\152\ETBp\180{\SI\148\180\&8\r\230\252vY\151]\223/\232&n", +// _willProps = []}), _cleanSession = True, _keepAlive = 1497, _connID = "\ENQfB\178\EOT\DLE\139\233\169H\233\GS[", +// _properties = []} TEST(Connect311QCTest, Encode28) { - uint8_t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18, 0x3a, 0xd2, 0x54, 0xa0, 0x74, 0xb9, 0xf2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6618,28 +6453,30 @@ TEST(Connect311QCTest, Encode28) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x84, 0x7e, 0x78, 0x9c, 0x4b, 0x53, 0xf6, 0x79, 0x89, - 0xf9, 0x16, 0x9a, 0x25, 0x91, 0x95, 0x54, 0xc3, 0xbc}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x58, 0xc3, 0x30, 0xed, 0x11, 0x6c, 0xde, 0x3, 0xdb, 0x39, 0x80, - 0x22, 0xd2, 0x2f, 0xfe, 0xf3, 0x51, 0xcc, 0xa9, 0x5e, 0x48}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xf8, 0xc0, 0x63, 0x42, 0xdf, 0x6, 0x84, 0x73, + 0x21, 0x71, 0xf6, 0xec, 0x70, 0x51, 0x2d, 0x52}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x40, 0x98, 0x17, 0x70, 0xb4, 0x7b, 0xf, 0x94, 0xb4, 0x38, 0xd, + 0xe6, 0xfc, 0x76, 0x59, 0x97, 0x5d, 0xdf, 0x2f, 0xe8, 0x26, 0x6e}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 9629; - uint8_t client_id_bytes[] = {0x75, 0xe2, 0x63, 0x82, 0xa7, 0x59, 0x80, 0x4c, 0xff, 0x31, 0xf, 0xe8, 0xbe}; + opts.clean_session = true; + opts.keep_alive = 1497; + uint8_t client_id_bytes[] = {0x5, 0x66, 0x42, 0xb2, 0x4, 0x10, 0x8b, 0xe9, 0xa9, 0x48, 0xe9, 0x1d, 0x5b}; lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x25, 0x13, 0x2f, 0x2d, 0x8, 0x47, 0x32, 0xc0, 0x89, 0xc4, 0x26, 0x80, 0xd1, 0x8f, - 0xeb, 0xf, 0xc9, 0x36, 0xd, 0xd8, 0x76, 0x4b, 0xc4, 0x64, 0x49, 0xc3, 0x90, 0x47}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb1, 0x2c, 0x1f, 0xa2, 0xf9, 0xd, 0x55}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0xba, 0x24, 0xb8, 0x4a, 0x18, 0x3a, 0xd2, 0x54, 0xa0, 0x74, 0xb9, 0xf2}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6648,16 +6485,15 @@ TEST(Connect311QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "A\215\192x\237\STX\181-", _password = Just "\148", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "\222\FS4[\199l\134\149\221T_=\130G\192\&4\179\205S>O", _willMsg -// = "\244\177\ETB\252l\159# _\EM\n\226\148\240e\135\229\SUB\SUB5", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "E?\ENQ\194E\208h\161\GSV2\189", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\143E\250\224\248%\EOT?\DC3_m\189\NAK\216\163\252\138B\142\RS", +// _willMsg = "|\253OH.E\US*\182\240-;\234\180\237\239\&2\136B\128\241\131", _willProps = []}), _cleanSession = True, +// _keepAlive = 6426, _connID = "J\158>Hv\SYNdF\SOH\160)\DC1*'#id\188iaD\192\b\213\152rW\251", _properties = []} TEST(Connect311QCTest, Encode30) { - uint8_t pkt[] = {0x10, 0x45, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x68, 0xd4, 0x0, 0x12, 0xcb, - 0x2c, 0x10, 0xff, 0x4, 0xf5, 0x92, 0xea, 0x3e, 0xe2, 0x94, 0xf0, 0x65, 0x87, 0xe5, 0x1a, - 0x1a, 0x35, 0x0, 0x1a, 0xbb, 0xfc, 0x1, 0x66, 0xe8, 0x6, 0xd5, 0xf5, 0xb0, 0xfc, 0xc3, - 0xeb, 0xf2, 0x39, 0xb6, 0xab, 0xa, 0x7, 0xde, 0x48, 0x41, 0xf, 0xba, 0x87, 0x9, 0x69, - 0x0, 0x9, 0x50, 0xf1, 0x26, 0x66, 0xec, 0x97, 0x43, 0xaf, 0xab}; + uint8_t pkt[] = {0x10, 0x56, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x19, 0x1a, 0x0, 0x1c, 0x4a, + 0x9e, 0x3e, 0x48, 0x76, 0x16, 0x64, 0x46, 0x1, 0xa0, 0x29, 0x11, 0x2a, 0x27, 0x23, 0x69, + 0x64, 0xbc, 0x69, 0x61, 0x44, 0xc0, 0x8, 0xd5, 0x98, 0x72, 0x57, 0xfb, 0x0, 0x14, 0x8f, + 0x45, 0xfa, 0xe0, 0xf8, 0x25, 0x4, 0x3f, 0x13, 0x5f, 0x6d, 0xbd, 0x15, 0xd8, 0xa3, 0xfc, + 0x8a, 0x42, 0x8e, 0x1e, 0x0, 0x16, 0x7c, 0xfd, 0x4f, 0x48, 0x2e, 0x45, 0x1f, 0x2a, 0xb6, + 0xf0, 0x2d, 0x3b, 0xea, 0xb4, 0xed, 0xef, 0x32, 0x88, 0x42, 0x80, 0xf1, 0x83}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8f, 0x45, 0xfa, 0xe0, 0xf8, 0x25, 0x4, 0x3f, 0x13, 0x5f, + 0x6d, 0xbd, 0x15, 0xd8, 0xa3, 0xfc, 0x8a, 0x42, 0x8e, 0x1e}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7c, 0xfd, 0x4f, 0x48, 0x2e, 0x45, 0x1f, 0x2a, 0xb6, 0xf0, 0x2d, + 0x3b, 0xea, 0xb4, 0xed, 0xef, 0x32, 0x88, 0x42, 0x80, 0xf1, 0x83}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 26836; - uint8_t client_id_bytes[] = {0xcb, 0x2c, 0x10, 0xff, 0x4, 0xf5, 0x92, 0xea, 0x3e, - 0xe2, 0x94, 0xf0, 0x65, 0x87, 0xe5, 0x1a, 0x1a, 0x35}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.keep_alive = 6426; + uint8_t client_id_bytes[] = {0x4a, 0x9e, 0x3e, 0x48, 0x76, 0x16, 0x64, 0x46, 0x1, 0xa0, 0x29, 0x11, 0x2a, 0x27, + 0x23, 0x69, 0x64, 0xbc, 0x69, 0x61, 0x44, 0xc0, 0x8, 0xd5, 0x98, 0x72, 0x57, 0xfb}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xbb, 0xfc, 0x1, 0x66, 0xe8, 0x6, 0xd5, 0xf5, 0xb0, 0xfc, 0xc3, 0xeb, 0xf2, - 0x39, 0xb6, 0xab, 0xa, 0x7, 0xde, 0x48, 0x41, 0xf, 0xba, 0x87, 0x9, 0x69}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x50, 0xf1, 0x26, 0x66, 0xec, 0x97, 0x43, 0xaf, 0xab}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x45, 0x3f, 0x5, 0xc2, 0x45, 0xd0, 0x68, 0xa1, 0x1d, 0x56, 0x32, 0xbd}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "Ke\173x'\220\170U\137[)Z\178\208[", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "M\150!\226\146b.\172]E2\203\181H\189\229`\158", _willMsg = -// "\254\224C\179\DC48p\a%0\153A\138\190\225Yw(dG\204\187\t5w\154\138F\208", _willProps = [PropServerKeepAlive 18831]}), -// _cleanSession = True, _keepAlive = 3972, _connID = "j\165k\247>\ENQ\145Xh\181N\246!\SUBX\201", _properties = -// [PropContentType "X\SO0j\160R\151\150\US\SIF\219\240L\205",PropMessageExpiryInterval -// 698,PropWildcardSubscriptionAvailable 200,PropAssignedClientIdentifier "\v^\213\173@\135:\208B\ENQQ\146DY\b"]} +// ConnectRequest {_username = Just "\247\bJ@ON", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS0, _willTopic = "\200\&8\143\219\210\&8\154\ETB\191\209\ENQ\247\151j\ETX\STX\DLEwW\DC4(\171\239", +// _willMsg = "\239\163,\150S\ETXA\235Q\144\193p~G\249\214\218Wh\175\200\235;\235np\154t", _willProps = [PropContentType +// "\236\STX\225\178i",PropUserProperty "\187\&3\128\f\USu8" "t\164_\166\&4 +// \254\230xga0p\251\232\185Xt\247\191\150\214u\FS\241\&0\208\&1B\191\255GmL",PropServerReference -// "\198\205\&73\171\GS\197\210\194\137\133\147S\150\223\188",PropAuthenticationMethod -// "9\220\237\141\190",PropTopicAliasMaximum 28999]}), _cleanSession = True, _keepAlive = 20710, _connID = -// "\153\186\STX-\152\157\214\157\245\"4\"\ETX", _properties = [PropUserProperty -// "\SUB\133\220E\183N\ETB\163\187\132K\128\169\234\\\fP6" -// "=[a\250\190Un\205I\154\&7H\150zo\NUL\166K\130\148\168",PropServerReference -// "\171\163`\204p\246\171",PropTopicAliasMaximum 11152,PropWillDelayInterval 11062,PropSharedSubscriptionAvailable -// 203,PropAuthenticationData "\DEL\212\DC1\UST\190\&2\160\152\&5\140\191\252\bz\173r\RS\155",PropWillDelayInterval -// 3785,PropTopicAliasMaximum 11255,PropServerReference -// "j\DC42\228ZG\246\181|\189\169\236\&3\227\152\f\236\207U/\183\"W",PropRequestResponseInformation -// 26,PropSharedSubscriptionAvailable 74,PropAssignedClientIdentifier -// "\132*\197\184\US\199~\178\237\234\b\227u\220J~L\197",PropTopicAlias 3113,PropReceiveMaximum -// 28559,PropSubscriptionIdentifier 12]} +// ConnectRequest {_username = Just "\DC4\245qv", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "\132\165\SUB\228Tg9\NULV.~\142\194\226:", _willMsg = +// "\176\179\172\a1r\164{\SOH\143\130V5\US-ElV\146\225\211\138\251\SOH\225\170",PropPayloadFormatIndicator -// 214,PropCorrelationData "\190\SUBb\CAN4D\197",PropAssignedClientIdentifier "\137TD.\ETX\181\131\144\&2m\"l\192"]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "\209\146\&2\164V", _willMsg = +// "\189\145\130\DC2U`\130\244\235\250\194@\222\162-\187\250\RS\SO\213$zF\EOT\t\197", _willProps = +// [PropRequestProblemInformation 83,PropResponseInformation +// "!\209\235\FS\170\&2\234\141m\238T\192ZgEH\SO\172\198\189\186\209\191\149\156r\246\&4/\f",PropRequestResponseInformation +// 84,PropMessageExpiryInterval 9800,PropUserProperty "" "f-",PropUserProperty "r\162\222\210$nPa,\206{\174\145\233jT" +// "O|",PropUserProperty "S\b_I)\\\198\145Mz\217\&1\142QZ\250'\214Cp\141\177\\i\249\232;" +// "\198",PropAssignedClientIdentifier "[\149p6I\208\188P\NUL\136\201\209gJ\159&\171\NUL\247",PropMaximumQoS +// 17,PropAssignedClientIdentifier +// "\250\rp\207s\223\220\SUBT\192<\176\b\232\r\GS\243\203F1\148#r\167\DC1",PropSubscriptionIdentifierAvailable +// 60,PropResponseInformation +// "\STX\254\198\248\141\197+\157!a5\136\225\129\bK\172\221\145\204\231\246\234\166bO",PropServerReference +// "\f<5I\186h\129\ETB\196",PropSharedSubscriptionAvailable 213,PropTopicAlias 16842,PropMessageExpiryInterval +// 1598,PropMaximumPacketSize 29381,PropMaximumPacketSize 23683,PropReceiveMaximum 727,PropSubscriptionIdentifier 23]}), +// _cleanSession = True, _keepAlive = 4029, _connID = "\ETB\180\164\136M><\142\&9\159Dn\bA\197\NUL2", _properties = +// [PropMaximumPacketSize 32513,PropAuthenticationMethod "\168i\223e0\STX",PropTopicAliasMaximum +// 4235,PropMessageExpiryInterval 16501,PropResponseTopic +// "\208\148\163\ACK\198\176M\245FqB\212\205iD\190W\165/\161:\138\206\&0\246",PropRequestProblemInformation +// 178,PropSubscriptionIdentifier 11,PropResponseInformation +// "\232p,\EOT\234/|\203\218\236t\SUB!\186tT\250\233\SUB\190\&0\\\228\154\a\189B",PropAuthenticationData +// "\211\189\207l\b(\211\171'x\189\201\132\137;\DC4SC*sP$\167yX>x",PropWillDelayInterval 7419,PropMaximumPacketSize +// 16457,PropRetainAvailable 183,PropAuthenticationData +// "_`C\233}\141\248\213\167C\142\254\vo\"2&\226$&a\\\235TW\203\173\195",PropAssignedClientIdentifier +// "\\|\213o\173\170\249\210c?Y\149\189[9\243\239w\SI\235Rd\202\154^\222\DELU\180\247",PropTopicAlias +// 26546,PropSessionExpiryInterval 24695,PropResponseInformation "y\DC3\212",PropReceiveMaximum +// 10210,PropAuthenticationMethod "",PropSessionExpiryInterval 2004,PropAuthenticationData "\254\206\ESCo\133\186 +// \US\145_W:\170\149\224\128og\249\161IE\145N\137",PropAssignedClientIdentifier +// "\v\224\193\194\204\215\249\ACKF",PropMessageExpiryInterval 23854,PropSharedSubscriptionAvailable 245]} TEST(Connect5QCTest, Encode3) { uint8_t pkt[] = { - 0x10, 0xde, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x82, 0x5a, 0x70, 0xbf, 0x1, 0x22, 0x54, 0x1, 0x1, - 0xe3, 0x25, 0xe1, 0x3, 0x0, 0x1d, 0xe9, 0xae, 0xc1, 0x72, 0x84, 0x7d, 0x35, 0x7, 0x6b, 0x21, 0x44, 0x27, 0xa4, - 0x8e, 0x57, 0x1c, 0xc3, 0x39, 0xf9, 0x9f, 0x34, 0x5d, 0x82, 0xc8, 0x24, 0x7f, 0x6b, 0x99, 0xfe, 0x13, 0x49, 0x33, - 0x2, 0x0, 0x0, 0x27, 0x79, 0x22, 0x47, 0x94, 0x23, 0x70, 0x56, 0x19, 0x99, 0xb, 0x1, 0x1, 0xec, 0x24, 0x0, - 0x9, 0x0, 0x12, 0xcd, 0x53, 0x32, 0xe8, 0x78, 0xdb, 0x4f, 0x80, 0x8d, 0x40, 0xe7, 0x17, 0x71, 0xbb, 0x3b, 0xd1, - 0xbf, 0xa3, 0x2, 0x0, 0x0, 0x7, 0x6e, 0x1a, 0x0, 0xc, 0xe0, 0xe7, 0xed, 0xae, 0xf6, 0xc2, 0x46, 0xe3, 0x93, - 0x8c, 0xaa, 0xbe, 0x24, 0xdb, 0x2, 0x0, 0x0, 0x36, 0x33, 0x19, 0x7c, 0x11, 0x0, 0x0, 0x2c, 0x72, 0x18, 0x0, - 0x0, 0x50, 0x87, 0x25, 0xb5, 0x8, 0x0, 0x5, 0x1f, 0x92, 0x41, 0x3c, 0x45, 0x1c, 0x0, 0x7, 0x85, 0x81, 0xb9, - 0x42, 0x6, 0x8c, 0x2e, 0x3, 0x0, 0x13, 0xcd, 0x5a, 0xf5, 0x9d, 0xfe, 0x5d, 0xf8, 0x90, 0xb1, 0x10, 0x16, 0x3e, - 0xe1, 0xd3, 0x8a, 0xfb, 0x1, 0xe1, 0xaa, 0x1, 0xd6, 0x9, 0x0, 0x7, 0xbe, 0x1a, 0x62, 0x18, 0x34, 0x44, 0xc5, - 0x12, 0x0, 0xd, 0x89, 0x54, 0x44, 0x2e, 0x3, 0xb5, 0x83, 0x90, 0x32, 0x6d, 0x22, 0x6c, 0xc0, 0x0, 0x8, 0x2a, - 0xc2, 0x97, 0xe0, 0x72, 0x54, 0x94, 0xd0, 0x0, 0x7, 0xf2, 0xd4, 0x75, 0x5d, 0x81, 0xcb, 0x9d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe9, 0xae, 0xc1, 0x72, 0x84, 0x7d, 0x35, 0x7, 0x6b, 0x21, 0x44, 0x27, 0xa4, 0x8e, 0x57, - 0x1c, 0xc3, 0x39, 0xf9, 0x9f, 0x34, 0x5d, 0x82, 0xc8, 0x24, 0x7f, 0x6b, 0x99, 0xfe}; - uint8_t bytesprops1[] = {0xcd, 0x53, 0x32, 0xe8, 0x78, 0xdb, 0x4f, 0x80, 0x8d, - 0x40, 0xe7, 0x17, 0x71, 0xbb, 0x3b, 0xd1, 0xbf, 0xa3}; - uint8_t bytesprops2[] = {0xe0, 0xe7, 0xed, 0xae, 0xf6, 0xc2, 0x46, 0xe3, 0x93, 0x8c, 0xaa, 0xbe}; - uint8_t bytesprops3[] = {0x1f, 0x92, 0x41, 0x3c, 0x45}; - uint8_t bytesprops4[] = {0x85, 0x81, 0xb9, 0x42, 0x6, 0x8c, 0x2e}; - uint8_t bytesprops5[] = {0xcd, 0x5a, 0xf5, 0x9d, 0xfe, 0x5d, 0xf8, 0x90, 0xb1, 0x10, - 0x16, 0x3e, 0xe1, 0xd3, 0x8a, 0xfb, 0x1, 0xe1, 0xaa}; - uint8_t bytesprops6[] = {0xbe, 0x1a, 0x62, 0x18, 0x34, 0x44, 0xc5}; - uint8_t bytesprops7[] = {0x89, 0x54, 0x44, 0x2e, 0x3, 0xb5, 0x83, 0x90, 0x32, 0x6d, 0x22, 0x6c, 0xc0}; + 0x10, 0xab, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe, 0xf, 0xbd, 0x86, 0x2, 0x27, 0x0, 0x0, 0x7f, + 0x1, 0x15, 0x0, 0x6, 0xa8, 0x69, 0xdf, 0x65, 0x30, 0x2, 0x22, 0x10, 0x8b, 0x2, 0x0, 0x0, 0x40, 0x75, 0x8, + 0x0, 0x19, 0xd0, 0x94, 0xa3, 0x6, 0xc6, 0xb0, 0x4d, 0xf5, 0x46, 0x71, 0x42, 0xd4, 0xcd, 0x69, 0x44, 0xbe, 0x57, + 0xa5, 0x2f, 0xa1, 0x3a, 0x8a, 0xce, 0x30, 0xf6, 0x17, 0xb2, 0xb, 0xb, 0x1a, 0x0, 0x1b, 0xe8, 0x70, 0x2c, 0x4, + 0xea, 0x2f, 0x7c, 0xcb, 0xda, 0xec, 0x74, 0x1a, 0x21, 0xba, 0x74, 0x54, 0xfa, 0xe9, 0x1a, 0xbe, 0x30, 0x5c, 0xe4, + 0x9a, 0x7, 0xbd, 0x42, 0x16, 0x0, 0x1b, 0xd3, 0xbd, 0xcf, 0x6c, 0x8, 0x28, 0xd3, 0xab, 0x27, 0x78, 0xbd, 0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x1c, 0x0, 0x9, 0xc, 0x3c, 0x35, 0x49, 0xba, + 0x68, 0x81, 0x17, 0xc4, 0x2a, 0xd5, 0x23, 0x41, 0xca, 0x2, 0x0, 0x0, 0x6, 0x3e, 0x27, 0x0, 0x0, 0x72, 0xc5, + 0x27, 0x0, 0x0, 0x5c, 0x83, 0x21, 0x2, 0xd7, 0xb, 0x17, 0x0, 0x5, 0xd1, 0x92, 0x32, 0xa4, 0x56, 0x0, 0x1a, + 0xbd, 0x91, 0x82, 0x12, 0x55, 0x60, 0x82, 0xf4, 0xeb, 0xfa, 0xc2, 0x40, 0xde, 0xa2, 0x2d, 0xbb, 0xfa, 0x1e, 0xe, + 0xd5, 0x24, 0x7a, 0x46, 0x4, 0x9, 0xc5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa8, 0x69, 0xdf, 0x65, 0x30, 0x2}; + uint8_t bytesprops1[] = {0xd0, 0x94, 0xa3, 0x6, 0xc6, 0xb0, 0x4d, 0xf5, 0x46, 0x71, 0x42, 0xd4, 0xcd, + 0x69, 0x44, 0xbe, 0x57, 0xa5, 0x2f, 0xa1, 0x3a, 0x8a, 0xce, 0x30, 0xf6}; + uint8_t bytesprops2[] = {0xe8, 0x70, 0x2c, 0x4, 0xea, 0x2f, 0x7c, 0xcb, 0xda, 0xec, 0x74, 0x1a, 0x21, 0xba, + 0x74, 0x54, 0xfa, 0xe9, 0x1a, 0xbe, 0x30, 0x5c, 0xe4, 0x9a, 0x7, 0xbd, 0x42}; + uint8_t bytesprops3[] = {0xd3, 0xbd, 0xcf, 0x6c, 0x8, 0x28, 0xd3, 0xab, 0x27, 0x78, 0xbd, 0xc9, 0x84, 0x89, + 0x3b, 0x14, 0x53, 0x43, 0x2a, 0x73, 0x50, 0x24, 0xa7, 0x79, 0x58, 0x3e, 0x78}; + uint8_t bytesprops4[] = {0x5f, 0x60, 0x43, 0xe9, 0x7d, 0x8d, 0xf8, 0xd5, 0xa7, 0x43, 0x8e, 0xfe, 0xb, 0x6f, + 0x22, 0x32, 0x26, 0xe2, 0x24, 0x26, 0x61, 0x5c, 0xeb, 0x54, 0x57, 0xcb, 0xad, 0xc3}; + uint8_t bytesprops5[] = {0x5c, 0x7c, 0xd5, 0x6f, 0xad, 0xaa, 0xf9, 0xd2, 0x63, 0x3f, 0x59, 0x95, 0xbd, 0x5b, 0x39, + 0xf3, 0xef, 0x77, 0xf, 0xeb, 0x52, 0x64, 0xca, 0x9a, 0x5e, 0xde, 0x7f, 0x55, 0xb4, 0xf7}; + uint8_t bytesprops6[] = {0x79, 0x13, 0xd4}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops8[] = {0xfe, 0xce, 0x1b, 0x6f, 0x85, 0xba, 0x20, 0x1f, 0x91, 0x5f, 0x57, 0x3a, 0xaa, + 0x95, 0xe0, 0x80, 0x6f, 0x67, 0xf9, 0xa1, 0x49, 0x45, 0x91, 0x4e, 0x89}; + uint8_t bytesprops9[] = {0xb, 0xe0, 0xc1, 0xc2, 0xcc, 0xd7, 0xf9, 0x6, 0x46}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21505}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18739}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10105}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18324}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28758}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1902}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13875}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11378}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20615}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32513}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4235}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16501}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7419}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16457}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26546}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24695}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10210}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2004}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23854}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 245}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x21, 0xd1, 0xeb, 0x1c, 0xaa, 0x32, 0xea, 0x8d, 0x6d, 0xee, 0x54, 0xc0, 0x5a, 0x67, 0x45, + 0x48, 0xe, 0xac, 0xc6, 0xbd, 0xba, 0xd1, 0xbf, 0x95, 0x9c, 0x72, 0xf6, 0x34, 0x2f, 0xc}; + uint8_t byteswillprops2[] = {0x66, 0x2d}; + uint8_t byteswillprops1[] = {0}; + uint8_t byteswillprops4[] = {0x4f, 0x7c}; + uint8_t byteswillprops3[] = {0x72, 0xa2, 0xde, 0xd2, 0x24, 0x6e, 0x50, 0x61, + 0x2c, 0xce, 0x7b, 0xae, 0x91, 0xe9, 0x6a, 0x54}; + uint8_t byteswillprops6[] = {0xc6}; + uint8_t byteswillprops5[] = {0x53, 0x8, 0x5f, 0x49, 0x29, 0x5c, 0xc6, 0x91, 0x4d, 0x7a, 0xd9, 0x31, 0x8e, 0x51, + 0x5a, 0xfa, 0x27, 0xd6, 0x43, 0x70, 0x8d, 0xb1, 0x5c, 0x69, 0xf9, 0xe8, 0x3b}; + uint8_t byteswillprops7[] = {0x5b, 0x95, 0x70, 0x36, 0x49, 0xd0, 0xbc, 0x50, 0x0, 0x88, + 0xc9, 0xd1, 0x67, 0x4a, 0x9f, 0x26, 0xab, 0x0, 0xf7}; + uint8_t byteswillprops8[] = {0xfa, 0xd, 0x70, 0xcf, 0x73, 0xdf, 0xdc, 0x1a, 0x54, 0xc0, 0x3c, 0xb0, 0x8, + 0xe8, 0xd, 0x1d, 0xf3, 0xcb, 0x46, 0x31, 0x94, 0x23, 0x72, 0xa7, 0x11}; + uint8_t byteswillprops9[] = {0x2, 0xfe, 0xc6, 0xf8, 0x8d, 0xc5, 0x2b, 0x9d, 0x21, 0x61, 0x35, 0x88, 0xe1, + 0x81, 0x8, 0x4b, 0xac, 0xdd, 0x91, 0xcc, 0xe7, 0xf6, 0xea, 0xa6, 0x62, 0x4f}; + uint8_t byteswillprops10[] = {0xc, 0x3c, 0x35, 0x49, 0xba, 0x68, 0x81, 0x17, 0xc4}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9800}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {0, (char*)&byteswillprops1}, .v = {2, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {16, (char*)&byteswillprops3}, .v = {2, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {27, (char*)&byteswillprops5}, .v = {1, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16842}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1598}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29381}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23683}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 727}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + }; + + lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd1, 0x92, 0x32, 0xa4, 0x56}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xbd, 0x91, 0x82, 0x12, 0x55, 0x60, 0x82, 0xf4, 0xeb, 0xfa, 0xc2, 0x40, 0xde, + 0xa2, 0x2d, 0xbb, 0xfa, 0x1e, 0xe, 0xd5, 0x24, 0x7a, 0x46, 0x4, 0x9, 0xc5}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 23152; - uint8_t client_id_bytes[] = {0x2a, 0xc2, 0x97, 0xe0, 0x72, 0x54, 0x94, 0xd0}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.keep_alive = 4029; + uint8_t client_id_bytes[] = {0x17, 0xb4, 0xa4, 0x88, 0x4d, 0x3e, 0x3c, 0x8e, 0x39, + 0x9f, 0x44, 0x6e, 0x8, 0x41, 0xc5, 0x0, 0x32}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf2, 0xd4, 0x75, 0x5d, 0x81, 0xcb, 0x9d}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; - opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\DLEv\182\131p6", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS0, _willTopic = -// "\CAN=S\217\STX\226v\251\&6\161\SYN\168\SO:\DC2P\198\184\217\161\221\199\148\168\142\ETB\245\178", _willMsg = -// "f\241\n]\DC4\198\146\187\\\239\149x\163\194\179?\132\207S", _willProps = [PropWildcardSubscriptionAvailable -// 0,PropServerReference "\160\208/1{)6^\CAN\220\166E>\166\135Zy(\217(2\229\188\152\140\&1\232d",PropTopicAlias -// 11543,PropUserProperty "\207\166S=eV-\136\154" -// "(w\159O\RS\128I#\140y\168\RS\217\v\SOH:\164\158\176\191",PropReasonString -// "\232\&5\177\241\186R2\130ys\DLEK\144k0\237}\163\236\169r|'\173\234\175X\209\US",PropMessageExpiryInterval -// 28516,PropServerReference -// "Ri}\167\197\208`KZ\233\146\"14\136\&9\169\171\187\f\192\164\145\SUB4",PropMaximumPacketSize 4874,PropReasonString -// "\134E:?\154\214\188\245\179i\144-NUy\213",PropAssignedClientIdentifier "\246\182@] -// \194P\245'\240\178\STX\132\162\184",PropReceiveMaximum 8768,PropServerReference -// "\222\175\169)\175\225\245&\237\231\NAK\131 \ETB\239y\254\159;\DC2",PropServerKeepAlive -// 27108,PropAuthenticationMethod "\DLE\152\NUL\199",PropResponseInformation -// "T\163S\147\149Wg\187_\160\196\228\t\239\172\"\231\NUL\208\150\138",PropRequestResponseInformation -// 157,PropSubscriptionIdentifier 12,PropServerReference "\143\233=",PropAssignedClientIdentifier -// "!\180\236\154F\169&\232J\136L\252\249]\ENQ\185pd\f\NAK\134\242 SN",PropCorrelationData -// "\156{\DC1>M\217\147\176?\247\196D\232\147\219N",PropSessionExpiryInterval 11271,PropSharedSubscriptionAvailable -// 207,PropResponseInformation "\aK_\SYNa\240\247\208\180\173{\ACK9\183\SOH\160\254EW'",PropMaximumPacketSize -// 18340,PropMessageExpiryInterval 10654,PropWillDelayInterval 13204,PropRetainAvailable 102]}), _cleanSession = True, -// _keepAlive = 29624, _connID = "\ETX\151\174C\139\235\225Y\221\247r\201\167\189j\NUL", _properties = -// [PropAuthenticationMethod "\176\DC1)\201\&4m)\DEL\222(\210\130\203",PropTopicAlias 23869,PropReceiveMaximum -// 14408,PropRetainAvailable 90,PropSessionExpiryInterval 22019,PropRequestProblemInformation -// 68,PropAuthenticationMethod "W\194\221\205\129\174h3\222",PropRequestResponseInformation 39]} +// ConnectRequest {_username = Just "F\237\221 :fM\163\208\237Y\ENQ\245\179\250$\234\187", _password = Nothing, +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 28626, _connID = "2\249o\r\221\161\151?\DC4\182_} \251\159", +// _properties = [PropTopicAliasMaximum 9492,PropSubscriptionIdentifier 16,PropAssignedClientIdentifier +// "t\207",PropResponseTopic +// "e\SI/\254K\NAK\205\DC4G\248C\140\&1\185\186t6]\139\171\145u\193w\131",PropAssignedClientIdentifier +// "H\157\158l-b\228\241\229,\229F\209\255(\168\bM\182#",PropTopicAliasMaximum 20871,PropSessionExpiryInterval +// 253,PropResponseInformation +// "_\227f\\X6\144\213\&4VPi\181\169Z\171a\141A\210\RSt\215\223Lg\238\215",PropRetainAvailable +// 165,PropAuthenticationData ";D\155W",PropWillDelayInterval 4393,PropMessageExpiryInterval +// 14413,PropAssignedClientIdentifier +// "!\132\167\&1\DC2C\203\157R\US\236\153\DC2\231\239\DLE\213l\171\241\131\252\t\156",PropPayloadFormatIndicator +// 204,PropUserProperty "X\134M\162\254\231^\138\STX_\177\DLE\\Kh\231~L\207\EM\ESC\237&6\254\140\190w|n" +// "\146]\233L\172\&1\175\162M\233\179\213L\239q=;\207\"\148",PropCorrelationData +// "k\DC1\130}J",PropRequestProblemInformation 46,PropSessionExpiryInterval 10169,PropAssignedClientIdentifier +// "\165\179\&3\172g\236G\178S\164e,\ESCiz",PropRequestResponseInformation 110,PropMaximumPacketSize +// 22080,PropReceiveMaximum 12311,PropSubscriptionIdentifierAvailable 92,PropTopicAlias 27810]} TEST(Connect5QCTest, Encode4) { uint8_t pkt[] = { - 0x10, 0xdc, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x66, 0x73, 0xb8, 0x2d, 0x15, 0x0, 0xd, 0xb0, 0x11, - 0x29, 0xc9, 0x34, 0x6d, 0x29, 0x7f, 0xde, 0x28, 0xd2, 0x82, 0xcb, 0x23, 0x5d, 0x3d, 0x21, 0x38, 0x48, 0x25, 0x5a, - 0x11, 0x0, 0x0, 0x56, 0x3, 0x17, 0x44, 0x15, 0x0, 0x9, 0x57, 0xc2, 0xdd, 0xcd, 0x81, 0xae, 0x68, 0x33, 0xde, - 0x19, 0x27, 0x0, 0x10, 0x3, 0x97, 0xae, 0x43, 0x8b, 0xeb, 0xe1, 0x59, 0xdd, 0xf7, 0x72, 0xc9, 0xa7, 0xbd, 0x6a, - 0x0, 0xd5, 0x2, 0x28, 0x0, 0x1c, 0x0, 0x1c, 0xa0, 0xd0, 0x2f, 0x31, 0x7b, 0x29, 0x36, 0x5e, 0x18, 0xdc, 0xa6, - 0x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, 0x84, 0xcf, 0x53, 0x0, 0x6, 0x10, 0x76, - 0xb6, 0x83, 0x70, 0x36}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb0, 0x11, 0x29, 0xc9, 0x34, 0x6d, 0x29, 0x7f, 0xde, 0x28, 0xd2, 0x82, 0xcb}; - uint8_t bytesprops1[] = {0x57, 0xc2, 0xdd, 0xcd, 0x81, 0xae, 0x68, 0x33, 0xde}; + 0x10, 0xac, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x80, 0x6f, 0xd2, 0xfb, 0x1, 0x22, 0x25, 0x14, 0xb, + 0x10, 0x12, 0x0, 0x2, 0x74, 0xcf, 0x8, 0x0, 0x19, 0x65, 0xf, 0x2f, 0xfe, 0x4b, 0x15, 0xcd, 0x14, 0x47, 0xf8, + 0x43, 0x8c, 0x31, 0xb9, 0xba, 0x74, 0x36, 0x5d, 0x8b, 0xab, 0x91, 0x75, 0xc1, 0x77, 0x83, 0x12, 0x0, 0x14, 0x48, + 0x9d, 0x9e, 0x6c, 0x2d, 0x62, 0xe4, 0xf1, 0xe5, 0x2c, 0xe5, 0x46, 0xd1, 0xff, 0x28, 0xa8, 0x8, 0x4d, 0xb6, 0x23, + 0x22, 0x51, 0x87, 0x11, 0x0, 0x0, 0x0, 0xfd, 0x1a, 0x0, 0x1c, 0x5f, 0xe3, 0x66, 0x5c, 0x58, 0x36, 0x90, 0xd5, + 0x34, 0x56, 0x50, 0x69, 0xb5, 0xa9, 0x5a, 0xab, 0x61, 0x8d, 0x41, 0xd2, 0x1e, 0x74, 0xd7, 0xdf, 0x4c, 0x67, 0xee, + 0xd7, 0x25, 0xa5, 0x16, 0x0, 0x4, 0x3b, 0x44, 0x9b, 0x57, 0x18, 0x0, 0x0, 0x11, 0x29, 0x2, 0x0, 0x0, 0x38, + 0x4d, 0x12, 0x0, 0x18, 0x21, 0x84, 0xa7, 0x31, 0x12, 0x43, 0xcb, 0x9d, 0x52, 0x1f, 0xec, 0x99, 0x12, 0xe7, 0xef, + 0x10, 0xd5, 0x6c, 0xab, 0xf1, 0x83, 0xfc, 0x9, 0x9c, 0x1, 0xcc, 0x26, 0x0, 0x1e, 0x58, 0x86, 0x4d, 0xa2, 0xfe, + 0xe7, 0x5e, 0x8a, 0x2, 0x5f, 0xb1, 0x10, 0x5c, 0x4b, 0x68, 0xe7, 0x7e, 0x4c, 0xcf, 0x19, 0x1b, 0xed, 0x26, 0x36, + 0xfe, 0x8c, 0xbe, 0x77, 0x7c, 0x6e, 0x0, 0x14, 0x92, 0x5d, 0xe9, 0x4c, 0xac, 0x31, 0xaf, 0xa2, 0x4d, 0xe9, 0xb3, + 0xd5, 0x4c, 0xef, 0x71, 0x3d, 0x3b, 0xcf, 0x22, 0x94, 0x9, 0x0, 0x5, 0x6b, 0x11, 0x82, 0x7d, 0x4a, 0x17, 0x2e, + 0x11, 0x0, 0x0, 0x27, 0xb9, 0x12, 0x0, 0xf, 0xa5, 0xb3, 0x33, 0xac, 0x67, 0xec, 0x47, 0xb2, 0x53, 0xa4, 0x65, + 0x2c, 0x1b, 0x69, 0x7a, 0x19, 0x6e, 0x27, 0x0, 0x0, 0x56, 0x40, 0x21, 0x30, 0x17, 0x29, 0x5c, 0x23, 0x6c, 0xa2, + 0x0, 0xf, 0x32, 0xf9, 0x6f, 0xd, 0xdd, 0xa1, 0x97, 0x3f, 0x14, 0xb6, 0x5f, 0x7d, 0x20, 0xfb, 0x9f, 0x0, 0x12, + 0x46, 0xed, 0xdd, 0x20, 0x3a, 0x66, 0x4d, 0xa3, 0xd0, 0xed, 0x59, 0x5, 0xf5, 0xb3, 0xfa, 0x24, 0xea, 0xbb}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x74, 0xcf}; + uint8_t bytesprops1[] = {0x65, 0xf, 0x2f, 0xfe, 0x4b, 0x15, 0xcd, 0x14, 0x47, 0xf8, 0x43, 0x8c, 0x31, + 0xb9, 0xba, 0x74, 0x36, 0x5d, 0x8b, 0xab, 0x91, 0x75, 0xc1, 0x77, 0x83}; + uint8_t bytesprops2[] = {0x48, 0x9d, 0x9e, 0x6c, 0x2d, 0x62, 0xe4, 0xf1, 0xe5, 0x2c, + 0xe5, 0x46, 0xd1, 0xff, 0x28, 0xa8, 0x8, 0x4d, 0xb6, 0x23}; + uint8_t bytesprops3[] = {0x5f, 0xe3, 0x66, 0x5c, 0x58, 0x36, 0x90, 0xd5, 0x34, 0x56, 0x50, 0x69, 0xb5, 0xa9, + 0x5a, 0xab, 0x61, 0x8d, 0x41, 0xd2, 0x1e, 0x74, 0xd7, 0xdf, 0x4c, 0x67, 0xee, 0xd7}; + uint8_t bytesprops4[] = {0x3b, 0x44, 0x9b, 0x57}; + uint8_t bytesprops5[] = {0x21, 0x84, 0xa7, 0x31, 0x12, 0x43, 0xcb, 0x9d, 0x52, 0x1f, 0xec, 0x99, + 0x12, 0xe7, 0xef, 0x10, 0xd5, 0x6c, 0xab, 0xf1, 0x83, 0xfc, 0x9, 0x9c}; + uint8_t bytesprops7[] = {0x92, 0x5d, 0xe9, 0x4c, 0xac, 0x31, 0xaf, 0xa2, 0x4d, 0xe9, + 0xb3, 0xd5, 0x4c, 0xef, 0x71, 0x3d, 0x3b, 0xcf, 0x22, 0x94}; + uint8_t bytesprops6[] = {0x58, 0x86, 0x4d, 0xa2, 0xfe, 0xe7, 0x5e, 0x8a, 0x2, 0x5f, 0xb1, 0x10, 0x5c, 0x4b, 0x68, + 0xe7, 0x7e, 0x4c, 0xcf, 0x19, 0x1b, 0xed, 0x26, 0x36, 0xfe, 0x8c, 0xbe, 0x77, 0x7c, 0x6e}; + uint8_t bytesprops8[] = {0x6b, 0x11, 0x82, 0x7d, 0x4a}; + uint8_t bytesprops9[] = {0xa5, 0xb3, 0x33, 0xac, 0x67, 0xec, 0x47, 0xb2, 0x53, 0xa4, 0x65, 0x2c, 0x1b, 0x69, 0x7a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23869}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14408}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22019}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, - }; - - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xa0, 0xd0, 0x2f, 0x31, 0x7b, 0x29, 0x36, 0x5e, 0x18, 0xdc, 0xa6, 0x45, 0x3e, 0xa6, - 0x87, 0x5a, 0x79, 0x28, 0xd9, 0x28, 0x32, 0xe5, 0xbc, 0x98, 0x8c, 0x31, 0xe8, 0x64}; - uint8_t byteswillprops2[] = {0x28, 0x77, 0x9f, 0x4f, 0x1e, 0x80, 0x49, 0x23, 0x8c, 0x79, - 0xa8, 0x1e, 0xd9, 0xb, 0x1, 0x3a, 0xa4, 0x9e, 0xb0, 0xbf}; - uint8_t byteswillprops1[] = {0xcf, 0xa6, 0x53, 0x3d, 0x65, 0x56, 0x2d, 0x88, 0x9a}; - uint8_t byteswillprops3[] = {0xe8, 0x35, 0xb1, 0xf1, 0xba, 0x52, 0x32, 0x82, 0x79, 0x73, 0x10, 0x4b, 0x90, 0x6b, 0x30, - 0xed, 0x7d, 0xa3, 0xec, 0xa9, 0x72, 0x7c, 0x27, 0xad, 0xea, 0xaf, 0x58, 0xd1, 0x1f}; - uint8_t byteswillprops4[] = {0x52, 0x69, 0x7d, 0xa7, 0xc5, 0xd0, 0x60, 0x4b, 0x5a, 0xe9, 0x92, 0x22, 0x31, - 0x34, 0x88, 0x39, 0xa9, 0xab, 0xbb, 0xc, 0xc0, 0xa4, 0x91, 0x1a, 0x34}; - uint8_t byteswillprops5[] = {0x86, 0x45, 0x3a, 0x3f, 0x9a, 0xd6, 0xbc, 0xf5, - 0xb3, 0x69, 0x90, 0x2d, 0x4e, 0x55, 0x79, 0xd5}; - uint8_t byteswillprops6[] = {0xf6, 0xb6, 0x40, 0x5d, 0x20, 0xc2, 0x50, 0xf5, 0x27, 0xf0, 0xb2, 0x2, 0x84, 0xa2, 0xb8}; - uint8_t byteswillprops7[] = {0xde, 0xaf, 0xa9, 0x29, 0xaf, 0xe1, 0xf5, 0x26, 0xed, 0xe7, - 0x15, 0x83, 0x20, 0x17, 0xef, 0x79, 0xfe, 0x9f, 0x3b, 0x12}; - uint8_t byteswillprops8[] = {0x10, 0x98, 0x0, 0xc7}; - uint8_t byteswillprops9[] = {0x54, 0xa3, 0x53, 0x93, 0x95, 0x57, 0x67, 0xbb, 0x5f, 0xa0, 0xc4, - 0xe4, 0x9, 0xef, 0xac, 0x22, 0xe7, 0x0, 0xd0, 0x96, 0x8a}; - uint8_t byteswillprops10[] = {0x8f, 0xe9, 0x3d}; - uint8_t byteswillprops11[] = {0x21, 0xb4, 0xec, 0x9a, 0x46, 0xa9, 0x26, 0xe8, 0x4a, 0x88, 0x4c, 0xfc, 0xf9, - 0x5d, 0x5, 0xb9, 0x70, 0x64, 0xc, 0x15, 0x86, 0xf2, 0x20, 0x53, 0x4e}; - uint8_t byteswillprops12[] = {0x9c, 0x7b, 0x11, 0x3e, 0x4d, 0xd9, 0x93, 0xb0, - 0x3f, 0xf7, 0xc4, 0x44, 0xe8, 0x93, 0xdb, 0x4e}; - uint8_t byteswillprops13[] = {0x7, 0x4b, 0x5f, 0x16, 0x61, 0xf0, 0xf7, 0xd0, 0xb4, 0xad, - 0x7b, 0x6, 0x39, 0xb7, 0x1, 0xa0, 0xfe, 0x45, 0x57, 0x27}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11543}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {9, (char*)&byteswillprops1}, .v = {20, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28516}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4874}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8768}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27108}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&byteswillprops12}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11271}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&byteswillprops13}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18340}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10654}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13204}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9492}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20871}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 253}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4393}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14413}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops6}, .v = {20, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10169}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22080}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12311}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27810}}, }; - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x18, 0x3d, 0x53, 0xd9, 0x2, 0xe2, 0x76, 0xfb, 0x36, 0xa1, 0x16, 0xa8, 0xe, 0x3a, - 0x12, 0x50, 0xc6, 0xb8, 0xd9, 0xa1, 0xdd, 0xc7, 0x94, 0xa8, 0x8e, 0x17, 0xf5, 0xb2}; - lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x66, 0xf1, 0xa, 0x5d, 0x14, 0xc6, 0x92, 0xbb, 0x5c, 0xef, - 0x95, 0x78, 0xa3, 0xc2, 0xb3, 0x3f, 0x84, 0xcf, 0x53}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 29624; - uint8_t client_id_bytes[] = {0x3, 0x97, 0xae, 0x43, 0x8b, 0xeb, 0xe1, 0x59, - 0xdd, 0xf7, 0x72, 0xc9, 0xa7, 0xbd, 0x6a, 0x0}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 28626; + uint8_t client_id_bytes[] = {0x32, 0xf9, 0x6f, 0xd, 0xdd, 0xa1, 0x97, 0x3f, 0x14, 0xb6, 0x5f, 0x7d, 0x20, 0xfb, 0x9f}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x10, 0x76, 0xb6, 0x83, 0x70, 0x36}; - lwmqtt_string_t password = {6, (char*)&password_bytes}; - opts.password = password; + uint8_t username_bytes[] = {0x46, 0xed, 0xdd, 0x20, 0x3a, 0x66, 0x4d, 0xa3, 0xd0, + 0xed, 0x59, 0x5, 0xf5, 0xb3, 0xfa, 0x24, 0xea, 0xbb}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; + opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "K\229g\209}\210\138\137T;\154Eh", _password = Nothing, _lastWill = Nothing, -// _cleanSession = True, _keepAlive = 31695, _connID = "cG\191s\155\131\202\186\155\&5C\DC2\207\217\173\144 -// \248\248\148", _properties = [PropTopicAliasMaximum 1156,PropRetainAvailable 243,PropCorrelationData -// "\194^}\DLE\199\252\216\&0\DC1z\r\t\216\187\FS\238\SO\236\240\163h\r\195\254\132\229t\244",PropWillDelayInterval -// 21486]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = +// 28697, _connID = "\203\185\&0\b\162/\DC4\184\135\214\244(e)\232\150t\248\130\139\217D\233k\138\237\\\202", +// _properties = [PropTopicAlias 7303,PropReasonString +// "\183\139\253+\155\228\DC2VU\222\232\r\247o|\FS\SYN\"NE",PropPayloadFormatIndicator +// 13,PropSharedSubscriptionAvailable 176,PropMaximumQoS 235,PropPayloadFormatIndicator 62,PropTopicAlias +// 2640,PropTopicAlias 32301,PropRequestResponseInformation 103,PropServerKeepAlive 17611,PropContentType +// "\EOT\SI\186\201W\239\167\202\204\210\153\233^\222+=\186\&6+",PropRequestProblemInformation 45]} TEST(Connect5QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0x59, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x82, 0x7b, 0xcf, 0x29, 0x22, 0x4, 0x84, - 0x25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, 0x5c, 0xca}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xc2, 0x5e, 0x7d, 0x10, 0xc7, 0xfc, 0xd8, 0x30, 0x11, 0x7a, 0xd, 0x9, 0xd8, 0xbb, - 0x1c, 0xee, 0xe, 0xec, 0xf0, 0xa3, 0x68, 0xd, 0xc3, 0xfe, 0x84, 0xe5, 0x74, 0xf4}; + uint8_t bytesprops0[] = {0xb7, 0x8b, 0xfd, 0x2b, 0x9b, 0xe4, 0x12, 0x56, 0x55, 0xde, + 0xe8, 0xd, 0xf7, 0x6f, 0x7c, 0x1c, 0x16, 0x22, 0x4e, 0x45}; + uint8_t bytesprops1[] = {0x4, 0xf, 0xba, 0xc9, 0x57, 0xef, 0xa7, 0xca, 0xcc, 0xd2, + 0x99, 0xe9, 0x5e, 0xde, 0x2b, 0x3d, 0xba, 0x36, 0x2b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1156}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21486}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7303}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2640}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32301}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17611}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 45}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 31695; - uint8_t client_id_bytes[] = {0x63, 0x47, 0xbf, 0x73, 0x9b, 0x83, 0xca, 0xba, 0x9b, 0x35, - 0x43, 0x12, 0xcf, 0xd9, 0xad, 0x90, 0x20, 0xf8, 0xf8, 0x94}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.keep_alive = 28697; + uint8_t client_id_bytes[] = {0xcb, 0xb9, 0x30, 0x8, 0xa2, 0x2f, 0x14, 0xb8, 0x87, 0xd6, 0xf4, 0x28, 0x65, 0x29, + 0xe8, 0x96, 0x74, 0xf8, 0x82, 0x8b, 0xd9, 0x44, 0xe9, 0x6b, 0x8a, 0xed, 0x5c, 0xca}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x4b, 0xe5, 0x67, 0xd1, 0x7d, 0xd2, 0x8a, 0x89, 0x54, 0x3b, 0x9a, 0x45, 0x68}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); @@ -7258,104 +7061,187 @@ TEST(Connect5QCTest, Encode5) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "\175'\US7>\EOT-K\160\NUL\SO\134T\148\232\194\132b\218\SIE\241L\156\204\169\145X3\250", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\CANf\159\155m", _willMsg = -// "\155)T\206\250\163y-\213[_\a\159\GS=\195L\155L\164\220\243\225)\208p", _willProps = [PropContentType -// "\157S\144\253Y|<\129I\STXt\204\255\142Y\166H\ETX\219qj<"]}), _cleanSession = True, _keepAlive = 11529, _connID = "", -// _properties = [PropPayloadFormatIndicator 16,PropSessionExpiryInterval 23466,PropUserProperty -// "\DC2\GS\USW\133\DC2\RSc\r\133l\175\152\146\DELY\219\190\209\216\157~\240\203r" -// "\137\152\v\218\152\134\FS0\DC3\204b\DC4\216\b:\151\188\165\248\&2\ESC\142\186\ayv\168",PropAssignedClientIdentifier -// "`r\229\GS\159\v\241\179e",PropTopicAlias 4328,PropWildcardSubscriptionAvailable 130,PropPayloadFormatIndicator -// 239,PropWillDelayInterval 18921,PropTopicAlias 12433,PropTopicAlias 2560,PropTopicAlias 3720,PropTopicAliasMaximum -// 3890,PropReasonString "5\205a\143!\211[\209hz\\\246\154\221nZ",PropTopicAliasMaximum -// 10484,PropRequestResponseInformation 247,PropSharedSubscriptionAvailable 91,PropReasonString -// "\141\226v",PropServerKeepAlive 676,PropUserProperty "\158\SUB@\177\137*\190\160j\203\r\160" -// "\189\221\157j1]\FSt\217\168Zo\202\228\173",PropWildcardSubscriptionAvailable 176,PropRetainAvailable 67]} +// ConnectRequest {_username = Just "\ETX\167/\DLE?I\DEL\214T$", _password = Just +// "\SUB\181v\f\SO\128\188\245\DEL\145\178\224\247\166\&8", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS1, _willTopic = "\212\201\CANR|p\199", _willMsg = +// "\171\188\151\239\EM#[\DC3\EM\SI1F0\134S8\195:\144\207\US\CANc\209?\213\190@\186", _willProps = +// [PropRequestProblemInformation 167,PropTopicAliasMaximum 5511,PropPayloadFormatIndicator 29,PropMessageExpiryInterval +// 30108,PropUserProperty "\240@7\DC2\185\SYN\211\&2X\226\132\140\254\DC3" +// "\129E\194x\153\137\200\251\131?D\220K",PropMessageExpiryInterval 4336,PropUserProperty +// "\199\186p\141\&0]\129?\193\r\NUL\217\182\216\248\a\215\t\145\199" +// "\RS\DC3\211\ETB\174h\244]\161\248c\190\250'\242m\GSc\144n?6\f\192P\ETX\208\208\139",PropSessionExpiryInterval +// 8037,PropWillDelayInterval 18302,PropPayloadFormatIndicator 202,PropReasonString +// "u4\147\195\128\219/\253:\212\190In\187\199o\RS\161\227\209LbH\145+",PropRequestResponseInformation +// 201,PropMaximumQoS 175,PropSubscriptionIdentifierAvailable 178,PropRequestProblemInformation +// 239,PropSessionExpiryInterval 8424,PropUserProperty "\219\246\169x\136\219\212\211\239" +// "\193\176\f\222f\132\190\182\160D"]}), _cleanSession = True, _keepAlive = 14165, _connID = +// "s@\"\140E\205\ESCb\193\200%\173\206\NAK)\152s", _properties = [PropAuthenticationData "\189,/\228j\223\SUB +// \153IHJ$\191\246f",PropAuthenticationData +// "\135\131CLX1\194Q\246n1\247\149\DC3\208Y\195\173:3:@+\GS\185",PropResponseTopic +// "\r\141\ESC\215PT\154\216\US*I",PropServerKeepAlive 16067,PropResponseTopic +// "\149\ETX\239\233\247\US\186\211\GS\SI\199\ESC\159\184\212\187\253&\SO\SO\DC1\FS\253\&3~",PropResponseTopic +// "rp_\173\162",PropReceiveMaximum 19811,PropAssignedClientIdentifier +// "\ESC\n\186\222\159\139",PropRequestProblemInformation 9,PropReasonString +// "\rBi\234\227\&7\249LO\236*\182>qR3\147h)\245j0\137\242A*H",PropSessionExpiryInterval 27006,PropAuthenticationMethod +// "L\219\128W\144}\158\221Y-\202\210\SOH1\230O\b\195",PropSubscriptionIdentifier 25,PropServerReference +// "v\DC3\156ni\154\193\DC3\228\180\156\198J*B\249\233\DEL\GS\145G\133\&4\143\235\195\134",PropRetainAvailable +// 166,PropRetainAvailable 198,PropWillDelayInterval 23170,PropSubscriptionIdentifier 23,PropMaximumQoS +// 23,PropAuthenticationData "\182@)",PropWillDelayInterval 7608,PropSubscriptionIdentifierAvailable 47,PropReasonString +// "\DC1\218\182",PropMaximumPacketSize 1376,PropAuthenticationMethod +// "G\215\199&\SUB0\DLE\160\217\157[\161\161\240\140\191\206", _password = Just -// "\175\183\193,\\>\244\ESCS\204\NULC\a\SOH\235\t\US\NAK\DC3", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS0, _willTopic = "8m\ETB\253\&5\"\149h\193\210!\DC2\192\173\163\v\157\214z\231?", _willMsg = -// "~\239s\199\207\DLE\137)\195w\DEL\200D\166\195y\230\ETX\179\187\224\188\198@\212\ESC", _willProps = -// [PropMessageExpiryInterval 4271,PropMessageExpiryInterval 6823,PropCorrelationData "(0\151\DC1\137 -// Jeg6\197\239E^\162\253i\211_\138i';d",PropRequestResponseInformation 145,PropAssignedClientIdentifier -// "6_\203\&0\142+4\178\193\178\b\221\233-\SUB|R\215\DC4\146c\183\ETB\148\210\209\191\DEL\f\236",PropReceiveMaximum -// 17759,PropTopicAliasMaximum 16206,PropMessageExpiryInterval 21818,PropPayloadFormatIndicator 130,PropCorrelationData -// "\211\161\189\133\232r\155:\133\238\239\201'\175*i\SUBl\SYN.r\172@\220\251\US",PropTopicAliasMaximum -// 29128,PropSubscriptionIdentifier 23,PropReasonString -// "\ESC?\213\147\182v\225\188\182\177\210\207,\ENQ|\247\185\229\197\255\165\253\135*Y\156\185\168\129\242",PropServerReference -// "w\207\&2\178\158G\153\226\SYNCVfh\198\176\252\EM",PropResponseInformation -// ">p~\254\186\236\237\231\SYN\161&\DLE\254S\163XW\143\175\&9\182\215\"",PropReasonString -// "9\132\250\181\230\208\254\&3\237\131\DELz{\217\183\156\n[",PropServerKeepAlive 14862,PropRequestResponseInformation -// 252,PropWillDelayInterval 26059,PropAssignedClientIdentifier "\157Z\vwb",PropMessageExpiryInterval -// 15429,PropAssignedClientIdentifier -// "\SO=\SO\165\159\255\DC1G\215\245A\223\163k=\181\164\242w\141t\251\166\&9",PropRequestProblemInformation -// 147,PropSessionExpiryInterval 29456,PropSessionExpiryInterval 11046]}), _cleanSession = True, _keepAlive = 1137, -// _connID = "H\161", _properties = [PropSubscriptionIdentifier 1,PropAssignedClientIdentifier -// "\224\225\217",PropSubscriptionIdentifier 8,PropSubscriptionIdentifierAvailable 172,PropRequestProblemInformation -// 231,PropMessageExpiryInterval 18221,PropReasonString "y\136\156\212K\150\176\201D",PropUserProperty -// "\145\250\EOT\NUL\171\165\ENQ\185r\138\142.\v\US\EOTNp\139\r\191O@\145\153]5r:e" "\152\NUL\161^q",PropUserProperty -// "XK$\161\247\t\DEL\191\ACK\137-\218\SUB\155rp\214\200\194\STX" -// "\153A{l\242%\185\202\164\220\205\210E\131\241\ACK+\\\235\165",PropSessionExpiryInterval 11196]} +// ConnectRequest {_username = Nothing, _password = Just "\223\&2\199@j\160\253\250\206\223!\137Hi\230\SUB`\181\222", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\217", _willMsg = "D~6I\EOT\181", +// _willProps = [PropPayloadFormatIndicator 156,PropRequestResponseInformation 77,PropServerKeepAlive +// 3956,PropTopicAlias 28656,PropRequestProblemInformation 102,PropRequestResponseInformation 170,PropTopicAlias +// 4936,PropMaximumQoS 205,PropRequestProblemInformation 59,PropSessionExpiryInterval 20589,PropMaximumQoS +// 111,PropReceiveMaximum 32392,PropSharedSubscriptionAvailable 15,PropMessageExpiryInterval +// 30902,PropAuthenticationData "\168\\\144\255+ Aj\222\198\226X\159\179\136",PropMessageExpiryInterval +// 8553,PropUserProperty "b\154\f\251{a\149" +// "\206a\161\169\253V\US\155y\177\194\214\149b\128\215\195\150\179\171",PropAuthenticationMethod +// "kg\233\ETX\139\ESC\169\190v\172\t\n|\224 ",PropMessageExpiryInterval 26952,PropMessageExpiryInterval +// 3730,PropWillDelayInterval 28842,PropMaximumPacketSize 10225,PropRequestProblemInformation +// 149,PropResponseInformation "R_\NAK\215\206Y\146N\178\179\nvF6L "]}), _cleanSession = False, _keepAlive = 27312, +// _connID = "\179\202\212\v\189N", _properties = [PropSubscriptionIdentifierAvailable 169,PropContentType +// "\193\145\202\244\141}A\CAN\252~9\189\&1",PropSubscriptionIdentifier 19]} TEST(Connect5QCTest, Encode7) { uint8_t pkt[] = { - 0x10, 0xf8, 0x3,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b, 0x77, 0x62, 0x2, 0x0, 0x0, - 0x3c, 0x45, 0x12, 0x0, 0x18, 0xe, 0x3d, 0xe, 0xa5, 0x9f, 0xff, 0x11, 0x47, 0xd7, 0xf5, 0x41, 0xdf, 0xa3, 0x6b, - 0x3d, 0xb5, 0xa4, 0xf2, 0x77, 0x8d, 0x74, 0xfb, 0xa6, 0x39, 0x17, 0x93, 0x11, 0x0, 0x0, 0x73, 0x10, 0x11, 0x0, - 0x0, 0x2b, 0x26, 0x0, 0x15, 0x38, 0x6d, 0x17, 0xfd, 0x35, 0x22, 0x95, 0x68, 0xc1, 0xd2, 0x21, 0x12, 0xc0, 0xad, - 0xa3, 0xb, 0x9d, 0xd6, 0x7a, 0xe7, 0x3f, 0x0, 0x1a, 0x7e, 0xef, 0x73, 0xc7, 0xcf, 0x10, 0x89, 0x29, 0xc3, 0x77, - 0x7f, 0xc8, 0x44, 0xa6, 0xc3, 0x79, 0xe6, 0x3, 0xb3, 0xbb, 0xe0, 0xbc, 0xc6, 0x40, 0xd4, 0x1b, 0x0, 0xc, 0x29, - 0xd4, 0xce, 0x9d, 0x3e, 0x5b, 0xa1, 0xa1, 0xf0, 0x8c, 0xbf, 0xce, 0x0, 0x13, 0xaf, 0xb7, 0xc1, 0x2c, 0x5c, 0x3e, - 0xf4, 0x1b, 0x53, 0xcc, 0x0, 0x43, 0x7, 0x1, 0xeb, 0x9, 0x1f, 0x15, 0x13}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe0, 0xe1, 0xd9}; - uint8_t bytesprops1[] = {0x79, 0x88, 0x9c, 0xd4, 0x4b, 0x96, 0xb0, 0xc9, 0x44}; - uint8_t bytesprops3[] = {0x98, 0x0, 0xa1, 0x5e, 0x71}; - uint8_t bytesprops2[] = {0x91, 0xfa, 0x4, 0x0, 0xab, 0xa5, 0x5, 0xb9, 0x72, 0x8a, 0x8e, 0x2e, 0xb, 0x1f, 0x4, - 0x4e, 0x70, 0x8b, 0xd, 0xbf, 0x4f, 0x40, 0x91, 0x99, 0x5d, 0x35, 0x72, 0x3a, 0x65}; - uint8_t bytesprops5[] = {0x99, 0x41, 0x7b, 0x6c, 0xf2, 0x25, 0xb9, 0xca, 0xa4, 0xdc, - 0xcd, 0xd2, 0x45, 0x83, 0xf1, 0x6, 0x2b, 0x5c, 0xeb, 0xa5}; - uint8_t bytesprops4[] = {0x58, 0x4b, 0x24, 0xa1, 0xf7, 0x9, 0x7f, 0xbf, 0x6, 0x89, - 0x2d, 0xda, 0x1a, 0x9b, 0x72, 0x70, 0xd6, 0xc8, 0xc2, 0x2}; + 0x10, 0xe1, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x54, 0x6a, 0xb0, 0x14, 0x29, 0xa9, 0x3, 0x0, 0xd, + 0xc1, 0x91, 0xca, 0xf4, 0x8d, 0x7d, 0x41, 0x18, 0xfc, 0x7e, 0x39, 0xbd, 0x31, 0xb, 0x13, 0x0, 0x6, 0xb3, 0xca, + 0xd4, 0xb, 0xbd, 0x4e, 0x98, 0x1, 0x1, 0x9c, 0x19, 0x4d, 0x13, 0xf, 0x74, 0x23, 0x6f, 0xf0, 0x17, 0x66, 0x19, + 0xaa, 0x23, 0x13, 0x48, 0x24, 0xcd, 0x17, 0x3b, 0x11, 0x0, 0x0, 0x50, 0x6d, 0x24, 0x6f, 0x21, 0x7e, 0x88, 0x2a, + 0xf, 0x2, 0x0, 0x0, 0x78, 0xb6, 0x16, 0x0, 0xf, 0xa8, 0x5c, 0x90, 0xff, 0x2b, 0x20, 0x41, 0x6a, 0xde, 0xc6, + 0xe2, 0x58, 0x9f, 0xb3, 0x88, 0x2, 0x0, 0x0, 0x21, 0x69, 0x26, 0x0, 0x7, 0x62, 0x9a, 0xc, 0xfb, 0x7b, 0x61, + 0x95, 0x0, 0x14, 0xce, 0x61, 0xa1, 0xa9, 0xfd, 0x56, 0x1f, 0x9b, 0x79, 0xb1, 0xc2, 0xd6, 0x95, 0x62, 0x80, 0xd7, + 0xc3, 0x96, 0xb3, 0xab, 0x15, 0x0, 0xf, 0x6b, 0x67, 0xe9, 0x3, 0x8b, 0x1b, 0xa9, 0xbe, 0x76, 0xac, 0x9, 0xa, + 0x7c, 0xe0, 0x20, 0x2, 0x0, 0x0, 0x69, 0x48, 0x2, 0x0, 0x0, 0xe, 0x92, 0x18, 0x0, 0x0, 0x70, 0xaa, 0x27, + 0x0, 0x0, 0x27, 0xf1, 0x17, 0x95, 0x1a, 0x0, 0x10, 0x52, 0x5f, 0x15, 0xd7, 0xce, 0x59, 0x92, 0x4e, 0xb2, 0xb3, + 0xa, 0x76, 0x46, 0x36, 0x4c, 0x20, 0x0, 0x1, 0xd9, 0x0, 0x6, 0x44, 0x7e, 0x36, 0x49, 0x4, 0xb5, 0x0, 0x13, + 0xdf, 0x32, 0xc7, 0x40, 0x6a, 0xa0, 0xfd, 0xfa, 0xce, 0xdf, 0x21, 0x89, 0x48, 0x69, 0xe6, 0x1a, 0x60, 0xb5, 0xde}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc1, 0x91, 0xca, 0xf4, 0x8d, 0x7d, 0x41, 0x18, 0xfc, 0x7e, 0x39, 0xbd, 0x31}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18221}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops2}, .v = {5, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops4}, .v = {20, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11196}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x28, 0x30, 0x97, 0x11, 0x89, 0x20, 0x4a, 0x65, 0x67, 0x36, 0xc5, 0xef, - 0x45, 0x5e, 0xa2, 0xfd, 0x69, 0xd3, 0x5f, 0x8a, 0x69, 0x27, 0x3b, 0x64}; - uint8_t byteswillprops1[] = {0x36, 0x5f, 0xcb, 0x30, 0x8e, 0x2b, 0x34, 0xb2, 0xc1, 0xb2, - 0x8, 0xdd, 0xe9, 0x2d, 0x1a, 0x7c, 0x52, 0xd7, 0x14, 0x92, - 0x63, 0xb7, 0x17, 0x94, 0xd2, 0xd1, 0xbf, 0x7f, 0xc, 0xec}; - uint8_t byteswillprops2[] = {0xd3, 0xa1, 0xbd, 0x85, 0xe8, 0x72, 0x9b, 0x3a, 0x85, 0xee, 0xef, 0xc9, 0x27, - 0xaf, 0x2a, 0x69, 0x1a, 0x6c, 0x16, 0x2e, 0x72, 0xac, 0x40, 0xdc, 0xfb, 0x1f}; - uint8_t byteswillprops3[] = {0x1b, 0x3f, 0xd5, 0x93, 0xb6, 0x76, 0xe1, 0xbc, 0xb6, 0xb1, - 0xd2, 0xcf, 0x2c, 0x5, 0x7c, 0xf7, 0xb9, 0xe5, 0xc5, 0xff, - 0xa5, 0xfd, 0x87, 0x2a, 0x59, 0x9c, 0xb9, 0xa8, 0x81, 0xf2}; - uint8_t byteswillprops4[] = {0x77, 0xcf, 0x32, 0xb2, 0x9e, 0x47, 0x99, 0xe2, 0x16, - 0x43, 0x56, 0x66, 0x68, 0xc6, 0xb0, 0xfc, 0x19}; - uint8_t byteswillprops5[] = {0x3e, 0x70, 0x7e, 0xfe, 0xba, 0xec, 0xed, 0xe7, 0x16, 0xa1, 0x26, 0x10, - 0xfe, 0x53, 0xa3, 0x58, 0x57, 0x8f, 0xaf, 0x39, 0xb6, 0xd7, 0x22}; - uint8_t byteswillprops6[] = {0x39, 0x84, 0xfa, 0xb5, 0xe6, 0xd0, 0xfe, 0x33, 0xed, - 0x83, 0x7f, 0x7a, 0x7b, 0xd9, 0xb7, 0x9c, 0xa, 0x5b}; - uint8_t byteswillprops7[] = {0x9d, 0x5a, 0xb, 0x77, 0x62}; - uint8_t byteswillprops8[] = {0xe, 0x3d, 0xe, 0xa5, 0x9f, 0xff, 0x11, 0x47, 0xd7, 0xf5, 0x41, 0xdf, - 0xa3, 0x6b, 0x3d, 0xb5, 0xa4, 0xf2, 0x77, 0x8d, 0x74, 0xfb, 0xa6, 0x39}; + uint8_t byteswillprops0[] = {0xa8, 0x5c, 0x90, 0xff, 0x2b, 0x20, 0x41, 0x6a, + 0xde, 0xc6, 0xe2, 0x58, 0x9f, 0xb3, 0x88}; + uint8_t byteswillprops2[] = {0xce, 0x61, 0xa1, 0xa9, 0xfd, 0x56, 0x1f, 0x9b, 0x79, 0xb1, + 0xc2, 0xd6, 0x95, 0x62, 0x80, 0xd7, 0xc3, 0x96, 0xb3, 0xab}; + uint8_t byteswillprops1[] = {0x62, 0x9a, 0xc, 0xfb, 0x7b, 0x61, 0x95}; + uint8_t byteswillprops3[] = {0x6b, 0x67, 0xe9, 0x3, 0x8b, 0x1b, 0xa9, 0xbe, 0x76, 0xac, 0x9, 0xa, 0x7c, 0xe0, 0x20}; + uint8_t byteswillprops4[] = {0x52, 0x5f, 0x15, 0xd7, 0xce, 0x59, 0x92, 0x4e, + 0xb2, 0xb3, 0xa, 0x76, 0x46, 0x36, 0x4c, 0x20}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4271}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6823}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17759}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16206}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21818}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29128}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14862}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26059}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15429}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29456}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11046}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3956}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28656}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4936}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20589}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32392}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30902}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8553}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {7, (char*)&byteswillprops1}, .v = {20, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26952}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3730}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28842}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10225}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops4}}}, }; - lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x38, 0x6d, 0x17, 0xfd, 0x35, 0x22, 0x95, 0x68, 0xc1, 0xd2, 0x21, - 0x12, 0xc0, 0xad, 0xa3, 0xb, 0x9d, 0xd6, 0x7a, 0xe7, 0x3f}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7e, 0xef, 0x73, 0xc7, 0xcf, 0x10, 0x89, 0x29, 0xc3, 0x77, 0x7f, 0xc8, 0x44, - 0xa6, 0xc3, 0x79, 0xe6, 0x3, 0xb3, 0xbb, 0xe0, 0xbc, 0xc6, 0x40, 0xd4, 0x1b}; - lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd9}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x44, 0x7e, 0x36, 0x49, 0x4, 0xb5}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1137; - uint8_t client_id_bytes[] = {0x48, 0xa1}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 27312; + uint8_t client_id_bytes[] = {0xb3, 0xca, 0xd4, 0xb, 0xbd, 0x4e}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x29, 0xd4, 0xce, 0x9d, 0x3e, 0x5b, 0xa1, 0xa1, 0xf0, 0x8c, 0xbf, 0xce}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xaf, 0xb7, 0xc1, 0x2c, 0x5c, 0x3e, 0xf4, 0x1b, 0x53, 0xcc, - 0x0, 0x43, 0x7, 0x1, 0xeb, 0x9, 0x1f, 0x15, 0x13}; + uint8_t password_bytes[] = {0xdf, 0x32, 0xc7, 0x40, 0x6a, 0xa0, 0xfd, 0xfa, 0xce, 0xdf, + 0x21, 0x89, 0x48, 0x69, 0xe6, 0x1a, 0x60, 0xb5, 0xde}; lwmqtt_string_t password = {19, (char*)&password_bytes}; opts.password = password; size_t len = 0; @@ -7525,174 +7355,142 @@ TEST(Connect5QCTest, Encode7) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\144", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS2, _willTopic = "\ACKb<[2\a\182/h\252g\145S\156\179?6\NAK\232/\SO\241\213P\bk", _willMsg = -// "\EM\140\168c\240\ESC]:\250l\160>CT\DC4\ETB\209\DC2", _willProps = [PropReasonString -// "\167H\170W\158\144\163\232\187\DC1",PropReceiveMaximum 24898,PropTopicAliasMaximum 14664,PropAuthenticationData -// "\156U2",PropPayloadFormatIndicator 193,PropRetainAvailable 135,PropAuthenticationMethod -// "}\215\208\160n9\164\213\191h\143\165Bp\145D\SOH\208\217\200W7\DEL5X\236",PropAuthenticationMethod -// "\128\CANSS\201\197",PropServerReference -// "\233M\ESC\142\137:\r\190\144\SUB\230\173\EOT\173\227\211l\USv\\\162\169\252\192\t\208",PropRequestProblemInformation -// 186,PropSessionExpiryInterval 25634,PropReceiveMaximum 28271,PropMaximumQoS 167,PropRequestProblemInformation -// 243,PropWildcardSubscriptionAvailable 11,PropReasonString "x0'D\ACK\SO\248l$\130I_\144",PropAuthenticationData -// "h\154B2\234\SOHOW\254",PropResponseTopic "8\185 ~\138\240\192<",PropRequestResponseInformation -// 34,PropAuthenticationMethod "tv\233J",PropServerReference -// "~\170&\236\138{\ENQSr_\174+",PropSharedSubscriptionAvailable 77,PropServerReference -// "\253\152\149r\201;M\188\r\215c\248\SYNS\195\234j\228\202\142\251\211\230",PropAssignedClientIdentifier -// "\244Q\159\RS",PropPayloadFormatIndicator 83]}), _cleanSession = False, _keepAlive = 1187, _connID = -// "\162\135\139O\243\166\t(\204\167\213e\215\220d\185\n\149\233\144\b\218\229\235,", _properties = -// [PropAuthenticationMethod "H\207\251Jy\208P\176.",PropMaximumPacketSize 23348,PropAuthenticationData -// "\221\DC2\SOH\184\ACKY\232@\183\&0\DLE\187\NUL=\174\223\175\228\223-\137-+\131\\\246\180t\192\n",PropTopicAliasMaximum -// 14884,PropServerReference -// "g\143\174S\166\139\SO>\131\160.\141O\199\168\SO\US=m\EOT\200\149\158\174\&9y\143\182",PropTopicAlias -// 13879,PropAuthenticationMethod "\229\227\252\174\233\&40\227\190\225q\CAN",PropTopicAliasMaximum -// 27692,PropServerReference "\f#\160",PropTopicAlias 17970,PropAuthenticationData "r\246\196,?g",PropReasonString -// "\214C\f",PropMessageExpiryInterval 5452,PropAssignedClientIdentifier "\224\231\214=\SYNSJ",PropWillDelayInterval -// 17062,PropSubscriptionIdentifierAvailable 81,PropTopicAlias 30262,PropUserProperty "\176\244\188\242" -// "&\168W\EOT=X\160\t\145OZ\DLE\174\246\185\128\NUL\219]\139\196s\RS\182",PropRequestProblemInformation -// 158,PropPayloadFormatIndicator 158,PropContentType "\235\187\129F\198",PropAuthenticationData -// "8\DC39A\191\202\&6Q\216\229C\136_\244\166\220\194\186w\DC4J\t",PropMaximumQoS 87,PropMaximumPacketSize -// 25405,PropMaximumQoS 210,PropAuthenticationMethod "\180i\239\ENQ",PropRequestResponseInformation -// 90,PropAuthenticationMethod "e\n[\187Nh\143l;\ESC\223>'\133\ACKw1Nc\218\171",PropReceiveMaximum 24426]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\EMS\165f>\192\196\FS\155\179\128]\225\223\DLE\151e@\159h\136\238\221\&9\205\DEL", _willMsg = +// "\DLE\ETB\v\131b\241\161<\217", _willProps = [PropRequestProblemInformation 76,PropMaximumPacketSize +// 30952,PropCorrelationData "\142a\227G\135\166\150\DEL",PropReceiveMaximum 21637,PropSubscriptionIdentifier +// 11,PropResponseInformation "",PropReceiveMaximum 31926,PropAssignedClientIdentifier +// "Q\192t5f8\150hL\DC4\NUL",PropWildcardSubscriptionAvailable 176,PropReasonString +// "\162\136\ETX\r6\209\168'\DC2jB\162\188\n\195\206\196\&7\139\187",PropAuthenticationMethod +// "\DC4\t@\FS1\149\214H\189;x\156X\188c\155q\135",PropTopicAliasMaximum 429,PropAuthenticationData "\158 +// v\176\180\142\&1t\235\EOTV",PropAuthenticationMethod +// "#\223F\164\187\157\229\204A\239\&3\SOH\237^1j\151}@\149\230=W\252\159]\fe",PropPayloadFormatIndicator +// 119,PropReceiveMaximum 32265,PropAuthenticationMethod +// "2\241\&8\ACK9\SOH\163q\220\165uY\160\220\164p\157M\207\221\227/o\204\156",PropSharedSubscriptionAvailable +// 14,PropUserProperty "!\199\171P\DLE\GS\201\SUBE\150\246\&4" +// "^\132\233\156\US@j`\139\142#\150\232/\142B\DC3q`h\131",PropAuthenticationMethod "\US\192~Y",PropServerReference +// ")\\%\169~\137\170\223\159\ESC\194\196\226&\171Z",PropWillDelayInterval 680,PropMaximumQoS +// 48,PropRequestProblemInformation 159,PropServerReference +// "\139\DC3<#\238\149\159>\GS\226+j[\205\153\178S-\232\247\132O\231\STX\ACK\160\255\132\181\241",PropSubscriptionIdentifier +// 19,PropResponseInformation "=&\220\143\255\245\a\231",PropMaximumPacketSize 23158,PropResponseInformation +// "\232\246jr\aGG\166f+G\131Q\196!\249\vV"]}), _cleanSession = True, _keepAlive = 20507, _connID = +// "-\202\240\v`\SOH\255oj\230\172\EM\212J", _properties = [PropRetainAvailable 201,PropSubscriptionIdentifierAvailable +// 131,PropMessageExpiryInterval 20159,PropWillDelayInterval 18712,PropCorrelationData +// "\202\205\170X\211\248W:\203\RS\221\134\163o\252L\156G\171_B\234\165D\n\240",PropWillDelayInterval +// 21003,PropPayloadFormatIndicator 66,PropAuthenticationData +// "$T\159\193\130H(\\\180\190u\DC4H$\173ncj\249d\195>\225n\247W4\165\130\154",PropMaximumPacketSize 28012]} T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 0x12, 0x19, 0x8c, 0xa8, 0x63, 0xf0, 0x1b, 0x5d, 0x3a, 0xfa, 0x6c, 0xa0, 0x3e, 0x43, 0x54, 0x14, - 0x17, 0xd1, 0x12, 0x0, 0x1, 0x90}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x48, 0xcf, 0xfb, 0x4a, 0x79, 0xd0, 0x50, 0xb0, 0x2e}; - uint8_t bytesprops1[] = {0xdd, 0x12, 0x1, 0xb8, 0x6, 0x59, 0xe8, 0x40, 0xb7, 0x30, 0x10, 0xbb, 0x0, 0x3d, 0xae, - 0xdf, 0xaf, 0xe4, 0xdf, 0x2d, 0x89, 0x2d, 0x2b, 0x83, 0x5c, 0xf6, 0xb4, 0x74, 0xc0, 0xa}; - uint8_t bytesprops2[] = {0x67, 0x8f, 0xae, 0x53, 0xa6, 0x8b, 0xe, 0x3e, 0x83, 0xa0, 0x2e, 0x8d, 0x4f, 0xc7, - 0xa8, 0xe, 0x1f, 0x3d, 0x6d, 0x4, 0xc8, 0x95, 0x9e, 0xae, 0x39, 0x79, 0x8f, 0xb6}; - uint8_t bytesprops3[] = {0xe5, 0xe3, 0xfc, 0xae, 0xe9, 0x34, 0x30, 0xe3, 0xbe, 0xe1, 0x71, 0x18}; - uint8_t bytesprops4[] = {0xc, 0x23, 0xa0}; - uint8_t bytesprops5[] = {0x72, 0xf6, 0xc4, 0x2c, 0x3f, 0x67}; - uint8_t bytesprops6[] = {0xd6, 0x43, 0xc}; - uint8_t bytesprops7[] = {0xe0, 0xe7, 0xd6, 0x3d, 0x16, 0x53, 0x4a}; - uint8_t bytesprops9[] = {0x26, 0xa8, 0x57, 0x4, 0x3d, 0x58, 0xa0, 0x9, 0x91, 0x4f, 0x5a, 0x10, - 0xae, 0xf6, 0xb9, 0x80, 0x0, 0xdb, 0x5d, 0x8b, 0xc4, 0x73, 0x1e, 0xb6}; - uint8_t bytesprops8[] = {0xb0, 0xf4, 0xbc, 0xf2}; - uint8_t bytesprops10[] = {0xeb, 0xbb, 0x81, 0x46, 0xc6}; - uint8_t bytesprops11[] = {0x38, 0x13, 0x39, 0x41, 0xbf, 0xca, 0x36, 0x51, 0xd8, 0xe5, 0x43, - 0x88, 0x5f, 0xf4, 0xa6, 0xdc, 0xc2, 0xba, 0x77, 0x14, 0x4a, 0x9}; - uint8_t bytesprops12[] = {0xb4, 0x69, 0xef, 0x5}; - uint8_t bytesprops13[] = {0x65, 0xa, 0x5b, 0xbb, 0x4e, 0x68, 0x8f, 0x6c, 0x3b, 0x1b, 0xdf, - 0x3e, 0x27, 0x85, 0x6, 0x77, 0x31, 0x4e, 0x63, 0xda, 0xab}; + 0x10, 0xd9, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0x50, 0x1b, 0x58, 0x25, 0xc9, 0x29, 0x83, 0x2, + 0x0, 0x0, 0x4e, 0xbf, 0x18, 0x0, 0x0, 0x49, 0x18, 0x9, 0x0, 0x1a, 0xca, 0xcd, 0xaa, 0x58, 0xd3, 0xf8, 0x57, + 0x3a, 0xcb, 0x1e, 0xdd, 0x86, 0xa3, 0x6f, 0xfc, 0x4c, 0x9c, 0x47, 0xab, 0x5f, 0x42, 0xea, 0xa5, 0x44, 0xa, 0xf0, + 0x18, 0x0, 0x0, 0x52, 0xb, 0x1, 0x42, 0x16, 0x0, 0x1e, 0x24, 0x54, 0x9f, 0xc1, 0x82, 0x48, 0x28, 0x5c, 0xb4, + 0xbe, 0x75, 0x14, 0x48, 0x24, 0xad, 0x6e, 0x63, 0x6a, 0xf9, 0x64, 0xc3, 0x3e, 0xe1, 0x6e, 0xf7, 0x57, 0x34, 0xa5, + 0x82, 0x9a, 0x27, 0x0, 0x0, 0x6d, 0x6c, 0x0, 0xe, 0x2d, 0xca, 0xf0, 0xb, 0x60, 0x1, 0xff, 0x6f, 0x6a, 0xe6, + 0xac, 0x19, 0xd4, 0x4a, 0xbd, 0x2, 0x17, 0x4c, 0x27, 0x0, 0x0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0x6f, 0xfc, 0x4c, 0x9c, 0x47, 0xab, 0x5f, 0x42, 0xea, 0xa5, 0x44, 0xa, 0xf0}; + uint8_t bytesprops1[] = {0x24, 0x54, 0x9f, 0xc1, 0x82, 0x48, 0x28, 0x5c, 0xb4, 0xbe, 0x75, 0x14, 0x48, 0x24, 0xad, + 0x6e, 0x63, 0x6a, 0xf9, 0x64, 0xc3, 0x3e, 0xe1, 0x6e, 0xf7, 0x57, 0x34, 0xa5, 0x82, 0x9a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23348}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20159}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18712}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21003}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 66}}, {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14884}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13879}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27692}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17970}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5452}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17062}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30262}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops8}, .v = {24, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25405}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24426}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28012}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xa7, 0x48, 0xaa, 0x57, 0x9e, 0x90, 0xa3, 0xe8, 0xbb, 0x11}; - uint8_t byteswillprops1[] = {0x9c, 0x55, 0x32}; - uint8_t byteswillprops2[] = {0x7d, 0xd7, 0xd0, 0xa0, 0x6e, 0x39, 0xa4, 0xd5, 0xbf, 0x68, 0x8f, 0xa5, 0x42, - 0x70, 0x91, 0x44, 0x1, 0xd0, 0xd9, 0xc8, 0x57, 0x37, 0x7f, 0x35, 0x58, 0xec}; - uint8_t byteswillprops3[] = {0x80, 0x18, 0x53, 0x53, 0xc9, 0xc5}; - uint8_t byteswillprops4[] = {0xe9, 0x4d, 0x1b, 0x8e, 0x89, 0x3a, 0xd, 0xbe, 0x90, 0x1a, 0xe6, 0xad, 0x4, - 0xad, 0xe3, 0xd3, 0x6c, 0x1f, 0x76, 0x5c, 0xa2, 0xa9, 0xfc, 0xc0, 0x9, 0xd0}; - uint8_t byteswillprops5[] = {0x78, 0x30, 0x27, 0x44, 0x6, 0xe, 0xf8, 0x6c, 0x24, 0x82, 0x49, 0x5f, 0x90}; - uint8_t byteswillprops6[] = {0x68, 0x9a, 0x42, 0x32, 0xea, 0x1, 0x4f, 0x57, 0xfe}; - uint8_t byteswillprops7[] = {0x38, 0xb9, 0x20, 0x7e, 0x8a, 0xf0, 0xc0, 0x3c}; - uint8_t byteswillprops8[] = {0x74, 0x76, 0xe9, 0x4a}; - uint8_t byteswillprops9[] = {0x7e, 0xaa, 0x26, 0xec, 0x8a, 0x7b, 0x5, 0x53, 0x72, 0x5f, 0xae, 0x2b}; - uint8_t byteswillprops10[] = {0xfd, 0x98, 0x95, 0x72, 0xc9, 0x3b, 0x4d, 0xbc, 0xd, 0xd7, 0x63, 0xf8, - 0x16, 0x53, 0xc3, 0xea, 0x6a, 0xe4, 0xca, 0x8e, 0xfb, 0xd3, 0xe6}; - uint8_t byteswillprops11[] = {0xf4, 0x51, 0x9f, 0x1e}; + uint8_t byteswillprops0[] = {0x8e, 0x61, 0xe3, 0x47, 0x87, 0xa6, 0x96, 0x7f}; + uint8_t byteswillprops1[] = {0}; + uint8_t byteswillprops2[] = {0x51, 0xc0, 0x74, 0x35, 0x66, 0x38, 0x96, 0x68, 0x4c, 0x14, 0x0}; + uint8_t byteswillprops3[] = {0xa2, 0x88, 0x3, 0xd, 0x36, 0xd1, 0xa8, 0x27, 0x12, 0x6a, + 0x42, 0xa2, 0xbc, 0xa, 0xc3, 0xce, 0xc4, 0x37, 0x8b, 0xbb}; + uint8_t byteswillprops4[] = {0x14, 0x9, 0x40, 0x1c, 0x31, 0x95, 0xd6, 0x48, 0xbd, + 0x3b, 0x78, 0x9c, 0x58, 0xbc, 0x63, 0x9b, 0x71, 0x87}; + uint8_t byteswillprops5[] = {0x9e, 0x20, 0x76, 0xb0, 0xb4, 0x8e, 0x31, 0x74, 0xeb, 0x4, 0x56}; + uint8_t byteswillprops6[] = {0x23, 0xdf, 0x46, 0xa4, 0xbb, 0x9d, 0xe5, 0xcc, 0x41, 0xef, 0x33, 0x1, 0xed, 0x5e, + 0x31, 0x6a, 0x97, 0x7d, 0x40, 0x95, 0xe6, 0x3d, 0x57, 0xfc, 0x9f, 0x5d, 0xc, 0x65}; + uint8_t byteswillprops7[] = {0x32, 0xf1, 0x38, 0x6, 0x39, 0x1, 0xa3, 0x71, 0xdc, 0xa5, 0x75, 0x59, 0xa0, + 0xdc, 0xa4, 0x70, 0x9d, 0x4d, 0xcf, 0xdd, 0xe3, 0x2f, 0x6f, 0xcc, 0x9c}; + uint8_t byteswillprops9[] = {0x5e, 0x84, 0xe9, 0x9c, 0x1f, 0x40, 0x6a, 0x60, 0x8b, 0x8e, 0x23, + 0x96, 0xe8, 0x2f, 0x8e, 0x42, 0x13, 0x71, 0x60, 0x68, 0x83}; + uint8_t byteswillprops8[] = {0x21, 0xc7, 0xab, 0x50, 0x10, 0x1d, 0xc9, 0x1a, 0x45, 0x96, 0xf6, 0x34}; + uint8_t byteswillprops10[] = {0x1f, 0xc0, 0x7e, 0x59}; + uint8_t byteswillprops11[] = {0x29, 0x5c, 0x25, 0xa9, 0x7e, 0x89, 0xaa, 0xdf, + 0x9f, 0x1b, 0xc2, 0xc4, 0xe2, 0x26, 0xab, 0x5a}; + uint8_t byteswillprops12[] = {0x8b, 0x13, 0x3c, 0x23, 0xee, 0x95, 0x9f, 0x3e, 0x1d, 0xe2, + 0x2b, 0x6a, 0x5b, 0xcd, 0x99, 0xb2, 0x53, 0x2d, 0xe8, 0xf7, + 0x84, 0x4f, 0xe7, 0x2, 0x6, 0xa0, 0xff, 0x84, 0xb5, 0xf1}; + uint8_t byteswillprops13[] = {0x3d, 0x26, 0xdc, 0x8f, 0xff, 0xf5, 0x7, 0xe7}; + uint8_t byteswillprops14[] = {0xe8, 0xf6, 0x6a, 0x72, 0x7, 0x47, 0x47, 0xa6, 0x66, + 0x2b, 0x47, 0x83, 0x51, 0xc4, 0x21, 0xf9, 0xb, 0x56}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24898}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14664}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25634}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28271}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30952}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21637}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31926}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 429}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32265}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {12, (char*)&byteswillprops8}, .v = {21, (char*)&byteswillprops9}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 680}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&byteswillprops12}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops13}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23158}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops14}}}, }; - lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6, 0x62, 0x3c, 0x5b, 0x32, 0x7, 0xb6, 0x2f, 0x68, 0xfc, 0x67, 0x91, 0x53, - 0x9c, 0xb3, 0x3f, 0x36, 0x15, 0xe8, 0x2f, 0xe, 0xf1, 0xd5, 0x50, 0x8, 0x6b}; + lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x19, 0x53, 0xa5, 0x66, 0x3e, 0xc0, 0xc4, 0x1c, 0x9b, 0xb3, 0x80, 0x5d, 0xe1, + 0xdf, 0x10, 0x97, 0x65, 0x40, 0x9f, 0x68, 0x88, 0xee, 0xdd, 0x39, 0xcd, 0x7f}; lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x19, 0x8c, 0xa8, 0x63, 0xf0, 0x1b, 0x5d, 0x3a, 0xfa, - 0x6c, 0xa0, 0x3e, 0x43, 0x54, 0x14, 0x17, 0xd1, 0x12}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + uint8_t will_payload_bytes[] = {0x10, 0x17, 0xb, 0x83, 0x62, 0xf1, 0xa1, 0x3c, 0xd9}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; @@ -7700,15 +7498,11 @@ TEST(Connect5QCTest, Encode8) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 1187; - uint8_t client_id_bytes[] = {0xa2, 0x87, 0x8b, 0x4f, 0xf3, 0xa6, 0x9, 0x28, 0xcc, 0xa7, 0xd5, 0x65, 0xd7, - 0xdc, 0x64, 0xb9, 0xa, 0x95, 0xe9, 0x90, 0x8, 0xda, 0xe5, 0xeb, 0x2c}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 20507; + uint8_t client_id_bytes[] = {0x2d, 0xca, 0xf0, 0xb, 0x60, 0x1, 0xff, 0x6f, 0x6a, 0xe6, 0xac, 0x19, 0xd4, 0x4a}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x90}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7717,102 +7511,194 @@ TEST(Connect5QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS0, _willTopic = "$`\SYN}79\139\SUB\138\ETX\146\rK\199\236*\DC2`D\178", _willMsg = -// "\146\226\241\226\SUB$6\236\236\SYN_\134\252\240\ACK\220_\158~\191\130\215\178", _willProps = []}), _cleanSession = -// False, _keepAlive = 6339, _connID = "", _properties = [PropAuthenticationData "\147\n",PropWillDelayInterval -// 11436,PropAssignedClientIdentifier "M\SO\165eHS-\SUB\180o\161> \152\230\205",PropSubscriptionIdentifier -// 18,PropSubscriptionIdentifierAvailable 233,PropMessageExpiryInterval 7344,PropRequestProblemInformation -// 222,PropServerReference ",\207\232\227\134\215\231\254x!\182",PropWildcardSubscriptionAvailable -// 195,PropAssignedClientIdentifier "\182%\233s\174\148\136IZ.",PropAuthenticationMethod -// "\235L7(\"\141\194\192\245F\164\USf\189\211\163\225}z\251\212\199t\DC2az\ETB",PropSubscriptionIdentifier -// 19,PropRetainAvailable 112,PropResponseTopic -// "\215\ETX5l9r\161\a\NUL\171\218\250\159$\250d\136Wn*|H\CAN\229\246\NUL8\186",PropTopicAliasMaximum -// 8032,PropReasonString "\\l\154\131\224\221yH\135CY\174\149\a\177;F\238\138\167\" \133/\147",PropAuthenticationData -// "\ETB\212\224\RSb\213-\212\230\188O\229",PropResponseInformation -// "\216\189\232g\v\190\208n\NULOXzK\SO\135\221y\156\143I\154'%\255",PropMessageExpiryInterval -// 23716,PropSubscriptionIdentifierAvailable 208,PropServerKeepAlive 14535]} +// ConnectRequest {_username = Just "\207\218?<\130\251\SI\189E\184\US\216$Z{?\252|\252", _password = Just +// "\184b#\224}]\DC4\210", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "J=\ESCG\249 +// t\STX\247m\RS\147\RS\157\225K\NUL\148G\203", _willMsg = +// "q\155\"+\180\161,\176\&9D\251\159!\164(|\235\247\178\213p\208\"\199~%X\226\251", _willProps = +// [PropWildcardSubscriptionAvailable 149,PropResponseInformation +// "\DEL\135\&4\218\224\228\235r@)\209\225\140\144UGV\217\142T\vq\216W\156\177\231",PropReasonString +// "\231\135\DLER\239n7\b\219P\250d>\141\152\STX\163",PropSubscriptionIdentifier 8,PropMaximumQoS +// 227,PropCorrelationData "\239:L}\DC4)\233\EOT",PropTopicAlias 31130,PropSharedSubscriptionAvailable +// 221,PropMessageExpiryInterval 22834,PropAuthenticationMethod "&o\138*\229\249-\v\191",PropMaximumPacketSize +// 32076,PropContentType "D\229[*i",PropAuthenticationData +// "4\218\191\172'-\\\131\RS\192\133c\254",PropSessionExpiryInterval 14123,PropSharedSubscriptionAvailable +// 84,PropAssignedClientIdentifier "",PropSubscriptionIdentifier 6,PropMessageExpiryInterval 30788,PropCorrelationData +// "\148\v@\246\151\144\&3\141\162",PropMaximumQoS 199,PropWillDelayInterval 7016,PropWillDelayInterval +// 16814,PropWillDelayInterval 24150,PropAssignedClientIdentifier +// "\vAD\RSI\254\179\142\128\205ix\191\NUL\130u\235\150/l\GSq",PropSharedSubscriptionAvailable +// 8,PropAssignedClientIdentifier "U\GS;\DC2\207",PropAuthenticationData "\DEL\209\FS",PropServerKeepAlive 24347]}), +// _cleanSession = False, _keepAlive = 8484, _connID = "\219\138\191|*\231\ACK\191WZCrWZ\r\ETXLA\247|6", _properties = +// [PropAuthenticationData "T6_m\148\177\CANP\ETB\191[\213\162\129\175\164!\DC1NM\b\248\ETX[9\181\181",PropMaximumQoS +// 18,PropUserProperty "\211\172K\174p3\STXf6\214\DC35\204\145" +// "(k'\160;k\158\199\238\186K\255\161\222\172\tNh\146*\147U\200N",PropMessageExpiryInterval +// 9906,PropAuthenticationMethod "d\184\180\131\255V\255\163\237;",PropTopicAliasMaximum 4996,PropCorrelationData +// "\253\177(\194\221u\n\145\145a\196;\193\231\173\200\143\194\225\155\194\145e\244T",PropAssignedClientIdentifier +// "t",PropReasonString "\224\EOT\220\199\223]\r\158\130\229\163\243\199\188\165\242qs",PropMaximumQoS +// 198,PropTopicAlias 9276,PropResponseInformation "\203\143\173\179\233\209\131d",PropServerReference +// "\230.\145\fd8=\253x\140\SOH\137\233\199\238\206\&9\164\216-@\144",PropMessageExpiryInterval +// 10006,PropSessionExpiryInterval 2484,PropReasonString +// "o\b}\156\167\185\196T\222b\STX8T\201\170\146Ql",PropMessageExpiryInterval 16834,PropReceiveMaximum +// 26987,PropSubscriptionIdentifierAvailable 169,PropWildcardSubscriptionAvailable 38,PropAuthenticationMethod +// "|\137",PropCorrelationData +// "\147b{\233\235\149\219\183\213\SYN\172\174\EM\176y\130\160\199w\254]W'\229sb\170\&1\201v",PropRequestResponseInformation +// 78]} TEST(Connect5QCTest, Encode9) { uint8_t pkt[] = { - 0x10, 0x97, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x4, 0x18, 0xc3, 0xd9, 0x1, 0x16, 0x0, 0x2, 0x93, - 0xa, 0x18, 0x0, 0x0, 0x2c, 0xac, 0x12, 0x0, 0x10, 0x4d, 0xe, 0xa5, 0x65, 0x48, 0x53, 0x2d, 0x1a, 0xb4, 0x6f, - 0xa1, 0x3e, 0x20, 0x98, 0xe6, 0xcd, 0xb, 0x12, 0x29, 0xe9, 0x2, 0x0, 0x0, 0x1c, 0xb0, 0x17, 0xde, 0x1c, 0x0, - 0xb, 0x2c, 0xcf, 0xe8, 0xe3, 0x86, 0xd7, 0xe7, 0xfe, 0x78, 0x21, 0xb6, 0x28, 0xc3, 0x12, 0x0, 0xa, 0xb6, 0x25, - 0xe9, 0x73, 0xae, 0x94, 0x88, 0x49, 0x5a, 0x2e, 0x15, 0x0, 0x1b, 0xeb, 0x4c, 0x37, 0x28, 0x22, 0x8d, 0xc2, 0xc0, - 0xf5, 0x46, 0xa4, 0x1f, 0x66, 0xbd, 0xd3, 0xa3, 0xe1, 0x7d, 0x7a, 0xfb, 0xd4, 0xc7, 0x74, 0x12, 0x61, 0x7a, 0x17, - 0xb, 0x13, 0x25, 0x70, 0x8, 0x0, 0x1c, 0xd7, 0x3, 0x35, 0x6c, 0x39, 0x72, 0xa1, 0x7, 0x0, 0xab, 0xda, 0xfa, - 0x9f, 0x24, 0xfa, 0x64, 0x88, 0x57, 0x6e, 0x2a, 0x7c, 0x48, 0x18, 0xe5, 0xf6, 0x0, 0x38, 0xba, 0x22, 0x1f, 0x60, - 0x1f, 0x0, 0x19, 0x5c, 0x6c, 0x9a, 0x83, 0xe0, 0xdd, 0x79, 0x48, 0x87, 0x43, 0x59, 0xae, 0x95, 0x7, 0xb1, 0x3b, - 0x46, 0xee, 0x8a, 0xa7, 0x22, 0x20, 0x85, 0x2f, 0x93, 0x16, 0x0, 0xc, 0x17, 0xd4, 0xe0, 0x1e, 0x62, 0xd5, 0x2d, - 0xd4, 0xe6, 0xbc, 0x4f, 0xe5, 0x1a, 0x0, 0x18, 0xd8, 0xbd, 0xe8, 0x67, 0xb, 0xbe, 0xd0, 0x6e, 0x0, 0x4f, 0x58, - 0x7a, 0x4b, 0xe, 0x87, 0xdd, 0x79, 0x9c, 0x8f, 0x49, 0x9a, 0x27, 0x25, 0xff, 0x2, 0x0, 0x0, 0x5c, 0xa4, 0x29, - 0xd0, 0x13, 0x38, 0xc7, 0x0, 0x0, 0x0, 0x0, 0x14, 0x24, 0x60, 0x16, 0x7d, 0x37, 0x39, 0x8b, 0x1a, 0x8a, 0x3, - 0x92, 0xd, 0x4b, 0xc7, 0xec, 0x2a, 0x12, 0x60, 0x44, 0xb2, 0x0, 0x17, 0x92, 0xe2, 0xf1, 0xe2, 0x1a, 0x24, 0x36, - 0xec, 0xec, 0x16, 0x5f, 0x86, 0xfc, 0xf0, 0x6, 0xdc, 0x5f, 0x9e, 0x7e, 0xbf, 0x82, 0xd7, 0xb2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x93, 0xa}; - uint8_t bytesprops1[] = {0x4d, 0xe, 0xa5, 0x65, 0x48, 0x53, 0x2d, 0x1a, - 0xb4, 0x6f, 0xa1, 0x3e, 0x20, 0x98, 0xe6, 0xcd}; - uint8_t bytesprops2[] = {0x2c, 0xcf, 0xe8, 0xe3, 0x86, 0xd7, 0xe7, 0xfe, 0x78, 0x21, 0xb6}; - uint8_t bytesprops3[] = {0xb6, 0x25, 0xe9, 0x73, 0xae, 0x94, 0x88, 0x49, 0x5a, 0x2e}; - uint8_t bytesprops4[] = {0xeb, 0x4c, 0x37, 0x28, 0x22, 0x8d, 0xc2, 0xc0, 0xf5, 0x46, 0xa4, 0x1f, 0x66, 0xbd, - 0xd3, 0xa3, 0xe1, 0x7d, 0x7a, 0xfb, 0xd4, 0xc7, 0x74, 0x12, 0x61, 0x7a, 0x17}; - uint8_t bytesprops5[] = {0xd7, 0x3, 0x35, 0x6c, 0x39, 0x72, 0xa1, 0x7, 0x0, 0xab, 0xda, 0xfa, 0x9f, 0x24, - 0xfa, 0x64, 0x88, 0x57, 0x6e, 0x2a, 0x7c, 0x48, 0x18, 0xe5, 0xf6, 0x0, 0x38, 0xba}; - uint8_t bytesprops6[] = {0x5c, 0x6c, 0x9a, 0x83, 0xe0, 0xdd, 0x79, 0x48, 0x87, 0x43, 0x59, 0xae, 0x95, - 0x7, 0xb1, 0x3b, 0x46, 0xee, 0x8a, 0xa7, 0x22, 0x20, 0x85, 0x2f, 0x93}; - uint8_t bytesprops7[] = {0x17, 0xd4, 0xe0, 0x1e, 0x62, 0xd5, 0x2d, 0xd4, 0xe6, 0xbc, 0x4f, 0xe5}; - uint8_t bytesprops8[] = {0xd8, 0xbd, 0xe8, 0x67, 0xb, 0xbe, 0xd0, 0x6e, 0x0, 0x4f, 0x58, 0x7a, - 0x4b, 0xe, 0x87, 0xdd, 0x79, 0x9c, 0x8f, 0x49, 0x9a, 0x27, 0x25, 0xff}; + 0x10, 0xda, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x21, 0x24, 0x91, 0x2, 0x16, 0x0, 0x1b, 0x54, + 0x36, 0x5f, 0x6d, 0x94, 0xb1, 0x18, 0x50, 0x17, 0xbf, 0x5b, 0xd5, 0xa2, 0x81, 0xaf, 0xa4, 0x21, 0x11, 0x4e, 0x4d, + 0x8, 0xf8, 0x3, 0x5b, 0x39, 0xb5, 0xb5, 0x24, 0x12, 0x26, 0x0, 0xe, 0xd3, 0xac, 0x4b, 0xae, 0x70, 0x33, 0x2, + 0x66, 0x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1, 0x18, 0x50, 0x17, 0xbf, 0x5b, 0xd5, 0xa2, 0x81, + 0xaf, 0xa4, 0x21, 0x11, 0x4e, 0x4d, 0x8, 0xf8, 0x3, 0x5b, 0x39, 0xb5, 0xb5}; + uint8_t bytesprops2[] = {0x28, 0x6b, 0x27, 0xa0, 0x3b, 0x6b, 0x9e, 0xc7, 0xee, 0xba, 0x4b, 0xff, + 0xa1, 0xde, 0xac, 0x9, 0x4e, 0x68, 0x92, 0x2a, 0x93, 0x55, 0xc8, 0x4e}; + uint8_t bytesprops1[] = {0xd3, 0xac, 0x4b, 0xae, 0x70, 0x33, 0x2, 0x66, 0x36, 0xd6, 0x13, 0x35, 0xcc, 0x91}; + uint8_t bytesprops3[] = {0x64, 0xb8, 0xb4, 0x83, 0xff, 0x56, 0xff, 0xa3, 0xed, 0x3b}; + uint8_t bytesprops4[] = {0xfd, 0xb1, 0x28, 0xc2, 0xdd, 0x75, 0xa, 0x91, 0x91, 0x61, 0xc4, 0x3b, 0xc1, + 0xe7, 0xad, 0xc8, 0x8f, 0xc2, 0xe1, 0x9b, 0xc2, 0x91, 0x65, 0xf4, 0x54}; + uint8_t bytesprops5[] = {0x74}; + uint8_t bytesprops6[] = {0xe0, 0x4, 0xdc, 0xc7, 0xdf, 0x5d, 0xd, 0x9e, 0x82, + 0xe5, 0xa3, 0xf3, 0xc7, 0xbc, 0xa5, 0xf2, 0x71, 0x73}; + uint8_t bytesprops7[] = {0xcb, 0x8f, 0xad, 0xb3, 0xe9, 0xd1, 0x83, 0x64}; + uint8_t bytesprops8[] = {0xe6, 0x2e, 0x91, 0xc, 0x64, 0x38, 0x3d, 0xfd, 0x78, 0x8c, 0x1, + 0x89, 0xe9, 0xc7, 0xee, 0xce, 0x39, 0xa4, 0xd8, 0x2d, 0x40, 0x90}; + uint8_t bytesprops9[] = {0x6f, 0x8, 0x7d, 0x9c, 0xa7, 0xb9, 0xc4, 0x54, 0xde, + 0x62, 0x2, 0x38, 0x54, 0xc9, 0xaa, 0x92, 0x51, 0x6c}; + uint8_t bytesprops10[] = {0x7c, 0x89}; + uint8_t bytesprops11[] = {0x93, 0x62, 0x7b, 0xe9, 0xeb, 0x95, 0xdb, 0xb7, 0xd5, 0x16, 0xac, 0xae, 0x19, 0xb0, 0x79, + 0x82, 0xa0, 0xc7, 0x77, 0xfe, 0x5d, 0x57, 0x27, 0xe5, 0x73, 0x62, 0xaa, 0x31, 0xc9, 0x76}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11436}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7344}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8032}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23716}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14535}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops1}, .v = {24, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9906}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4996}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9276}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10006}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2484}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16834}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26987}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 78}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x7f, 0x87, 0x34, 0xda, 0xe0, 0xe4, 0xeb, 0x72, 0x40, 0x29, 0xd1, 0xe1, 0x8c, 0x90, + 0x55, 0x47, 0x56, 0xd9, 0x8e, 0x54, 0xb, 0x71, 0xd8, 0x57, 0x9c, 0xb1, 0xe7}; + uint8_t byteswillprops1[] = {0xe7, 0x87, 0x10, 0x52, 0xef, 0x6e, 0x37, 0x8, 0xdb, + 0x50, 0xfa, 0x64, 0x3e, 0x8d, 0x98, 0x2, 0xa3}; + uint8_t byteswillprops2[] = {0xef, 0x3a, 0x4c, 0x7d, 0x14, 0x29, 0xe9, 0x4}; + uint8_t byteswillprops3[] = {0x26, 0x6f, 0x8a, 0x2a, 0xe5, 0xf9, 0x2d, 0xb, 0xbf}; + uint8_t byteswillprops4[] = {0x44, 0xe5, 0x5b, 0x2a, 0x69}; + uint8_t byteswillprops5[] = {0x34, 0xda, 0xbf, 0xac, 0x27, 0x2d, 0x5c, 0x83, 0x1e, 0xc0, 0x85, 0x63, 0xfe}; + uint8_t byteswillprops6[] = {0}; + uint8_t byteswillprops7[] = {0x94, 0xb, 0x40, 0xf6, 0x97, 0x90, 0x33, 0x8d, 0xa2}; + uint8_t byteswillprops8[] = {0xb, 0x41, 0x44, 0x1e, 0x49, 0xfe, 0xb3, 0x8e, 0x80, 0xcd, 0x69, + 0x78, 0xbf, 0x0, 0x82, 0x75, 0xeb, 0x96, 0x2f, 0x6c, 0x1d, 0x71}; + uint8_t byteswillprops9[] = {0x55, 0x1d, 0x3b, 0x12, 0xcf}; + uint8_t byteswillprops10[] = {0x7f, 0xd1, 0x1c}; - lwmqtt_property_t willpropslist[] = {}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31130}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22834}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32076}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14123}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30788}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7016}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16814}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24150}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24347}}, + }; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x24, 0x60, 0x16, 0x7d, 0x37, 0x39, 0x8b, 0x1a, 0x8a, 0x3, - 0x92, 0xd, 0x4b, 0xc7, 0xec, 0x2a, 0x12, 0x60, 0x44, 0xb2}; + lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4a, 0x3d, 0x1b, 0x47, 0xf9, 0x20, 0x74, 0x2, 0xf7, 0x6d, + 0x1e, 0x93, 0x1e, 0x9d, 0xe1, 0x4b, 0x0, 0x94, 0x47, 0xcb}; lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x92, 0xe2, 0xf1, 0xe2, 0x1a, 0x24, 0x36, 0xec, 0xec, 0x16, 0x5f, 0x86, - 0xfc, 0xf0, 0x6, 0xdc, 0x5f, 0x9e, 0x7e, 0xbf, 0x82, 0xd7, 0xb2}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + uint8_t will_payload_bytes[] = {0x71, 0x9b, 0x22, 0x2b, 0xb4, 0xa1, 0x2c, 0xb0, 0x39, 0x44, + 0xfb, 0x9f, 0x21, 0xa4, 0x28, 0x7c, 0xeb, 0xf7, 0xb2, 0xd5, + 0x70, 0xd0, 0x22, 0xc7, 0x7e, 0x25, 0x58, 0xe2, 0xfb}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 6339; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.keep_alive = 8484; + uint8_t client_id_bytes[] = {0xdb, 0x8a, 0xbf, 0x7c, 0x2a, 0xe7, 0x6, 0xbf, 0x57, 0x5a, 0x43, + 0x72, 0x57, 0x5a, 0xd, 0x3, 0x4c, 0x41, 0xf7, 0x7c, 0x36}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t username_bytes[] = {0xcf, 0xda, 0x3f, 0x3c, 0x82, 0xfb, 0xf, 0xbd, 0x45, 0xb8, + 0x1f, 0xd8, 0x24, 0x5a, 0x7b, 0x3f, 0xfc, 0x7c, 0xfc}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xb8, 0x62, 0x23, 0xe0, 0x7d, 0x5d, 0x14, 0xd2}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7821,267 +7707,290 @@ TEST(Connect5QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\195\225Z\248\165S\201G\ne9\161>\FS\201_\239D\203\r", _password = Just -// "\230WH\211", _lastWill = Nothing, _cleanSession = False, _keepAlive = 22088, _connID = "nx\237\250`\150", -// _properties = [PropRequestResponseInformation 102,PropPayloadFormatIndicator 219,PropWildcardSubscriptionAvailable -// 12,PropCorrelationData ";\169?\SOH\186p\248\140B\DC3@~r\148\227\162\153e\FSgP",PropRetainAvailable -// 64,PropRetainAvailable 132,PropUserProperty "F." "\174G\250\234\t\DC4\141\200",PropRetainAvailable -// 216,PropSharedSubscriptionAvailable 239,PropSubscriptionIdentifierAvailable 91,PropTopicAliasMaximum -// 16140,PropRequestProblemInformation 171,PropReasonString -// "\na\208\187h6d|%\250q*\171F\245\178\160\147\&9r\144s\237\ETB\170gO\253",PropMessageExpiryInterval -// 27214,PropCorrelationData "\206\195\196\195\n|\215\ETX\173\243\218\240v\197\234O\225\248",PropPayloadFormatIndicator -// 68,PropSessionExpiryInterval 3981,PropAssignedClientIdentifier -// "\215\147\\m\215\186\217S\tI\147n\NAK",PropAssignedClientIdentifier -// "\"@\193\135\139\179\157\252:\193\NULV(\SO\156",PropCorrelationData -// "\DC3\180\&73Y\209o\255\DC4\158\135fc\219nub.\204N\159\200\143\136",PropRequestResponseInformation 139,PropTopicAlias -// 7297,PropAuthenticationData "}U@\204\189\190\253\204\139#\v\164",PropServerReference "{S\167\DC1\\MI -// Z\STX\ACKK\198\180",PropSubscriptionIdentifier 10,PropWillDelayInterval 2992,PropReceiveMaximum -// 14476,PropPayloadFormatIndicator 15]} +// ConnectRequest {_username = Just "\204\DC2Bw\158G\232{\204\238N\218\&9\f\150", _password = Just +// "/ME\221/\224L\203\216\150\t=\195a\169\197P[\251\137\DC3\219\152\253\ENQL\153\239", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\160TX\134\176\USa\167\209[\146\&0", _willMsg = +// "\130\128b\DC1U\178\198J:\"\154\&9\174\144\&79\222\DEL\212\204'\ENQ\227\139\&7\132", _willProps = +// [PropWildcardSubscriptionAvailable 219,PropSharedSubscriptionAvailable 19,PropRequestResponseInformation +// 226,PropSessionExpiryInterval 30066,PropContentType +// "\212\184\141\\\143%W\190|\152\DC3\193E\n\t\237\159\184?\194\129|\131\231\171G\230\&0!\188",PropTopicAliasMaximum +// 2047,PropMessageExpiryInterval 25577,PropSubscriptionIdentifier 10,PropAuthenticationMethod +// "\193\235,\149\&7\212X",PropAuthenticationMethod "\206\254Wz\ETB\174)\179#\ETB\159W\174",PropCorrelationData +// "%\NAKH\EM&\166\208\192\EM\226\133\223\ENQ6\FS\138\156d}\145Gv",PropRetainAvailable 154,PropAuthenticationData +// "\162\151\SUBN\234\SUB\226\&3\SYN8\152\156*\249\137k6\175\250x\158\135!\208\STX+\194\a\246",PropRequestResponseInformation +// 245,PropAssignedClientIdentifier +// "\181h&v\183[\189\STX]P2\182\SYNO\179\f\245\226\166\189\236\247o\250]\193M\229",PropSharedSubscriptionAvailable +// 20,PropContentType "\247V\148\159\223`\a\244\217b\ETB:\217",PropReasonString +// "h\241\252P3\136\n\tg6\SI\136o\DC2I]\189bfy\DEL9L\131\199/\169{g\180"]}), _cleanSession = True, _keepAlive = 18071, +// _connID = "\150\237n\166\229\ETBi;m\233\SYN,\137\212\196\218", _properties = [PropSessionExpiryInterval +// 24708,PropSharedSubscriptionAvailable 250,PropSharedSubscriptionAvailable 94,PropWillDelayInterval +// 2639,PropServerReference +// "l\130\ACK\250\EM\186\NUL_\184\226\r\139\134\224\229\149\155\137\207x\132\175\224\&7q\SO\254\t\140",PropMaximumQoS +// 156,PropSessionExpiryInterval 14655,PropWillDelayInterval 11878,PropTopicAliasMaximum 16102,PropContentType +// "\193\STX9\155\155t6\235\154U\132!",PropWildcardSubscriptionAvailable 200,PropContentType +// "\200\v\b\224*\ETB\193\232\\\168G\129\233\238\129\246\171#x\204x",PropRetainAvailable 204,PropMaximumPacketSize +// 29406,PropRequestResponseInformation 23,PropReceiveMaximum 13674,PropContentType +// "\204z\250\GS\191\179\133\254V\f.\137\159LK\170h\163\SYN",PropSharedSubscriptionAvailable +// 188,PropAssignedClientIdentifier +// "\135=\NAKf\239\205\152\238$\149\SOHF8\137\141\194\255/7\209\EOT\251\STX%\201O\218",PropReasonString +// "\130\SOH\STX\162:H\145\174]\200\196\220A",PropRequestProblemInformation 47,PropReceiveMaximum +// 23351,PropSharedSubscriptionAvailable 124,PropMaximumQoS 69,PropCorrelationData "g",PropServerKeepAlive +// 20731,PropWillDelayInterval 14078,PropRequestResponseInformation 112]} TEST(Connect5QCTest, Encode10) { uint8_t pkt[] = { - 0x10, 0x9a, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x56, 0x48, 0xea, 0x1, 0x19, 0x66, 0x1, 0xdb, - 0x28, 0xc, 0x9, 0x0, 0x15, 0x3b, 0xa9, 0x3f, 0x1, 0xba, 0x70, 0xf8, 0x8c, 0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0x1c, 0x0, 0xe, 0x7b, 0x53, 0xa7, 0x11, 0x5c, - 0x4d, 0x49, 0x20, 0x5a, 0x2, 0x6, 0x4b, 0xc6, 0xb4, 0xb, 0xa, 0x18, 0x0, 0x0, 0xb, 0xb0, 0x21, 0x38, 0x8c, - 0x1, 0xf, 0x0, 0x6, 0x6e, 0x78, 0xed, 0xfa, 0x60, 0x96, 0x0, 0x14, 0xc3, 0xe1, 0x5a, 0xf8, 0xa5, 0x53, 0xc9, - 0x47, 0xa, 0x65, 0x39, 0xa1, 0x3e, 0x1c, 0xc9, 0x5f, 0xef, 0x44, 0xcb, 0xd, 0x0, 0x4, 0xe6, 0x57, 0x48, 0xd3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x3b, 0xa9, 0x3f, 0x1, 0xba, 0x70, 0xf8, 0x8c, 0x42, 0x13, 0x40, - 0x7e, 0x72, 0x94, 0xe3, 0xa2, 0x99, 0x65, 0x1c, 0x67, 0x50}; - uint8_t bytesprops2[] = {0xae, 0x47, 0xfa, 0xea, 0x9, 0x14, 0x8d, 0xc8}; - uint8_t bytesprops1[] = {0x46, 0x2e}; - uint8_t bytesprops3[] = {0xa, 0x61, 0xd0, 0xbb, 0x68, 0x36, 0x64, 0x7c, 0x25, 0xfa, 0x71, 0x2a, 0xab, 0x46, - 0xf5, 0xb2, 0xa0, 0x93, 0x39, 0x72, 0x90, 0x73, 0xed, 0x17, 0xaa, 0x67, 0x4f, 0xfd}; - uint8_t bytesprops4[] = {0xce, 0xc3, 0xc4, 0xc3, 0xa, 0x7c, 0xd7, 0x3, 0xad, - 0xf3, 0xda, 0xf0, 0x76, 0xc5, 0xea, 0x4f, 0xe1, 0xf8}; - uint8_t bytesprops5[] = {0xd7, 0x93, 0x5c, 0x6d, 0xd7, 0xba, 0xd9, 0x53, 0x9, 0x49, 0x93, 0x6e, 0x15}; - uint8_t bytesprops6[] = {0x22, 0x40, 0xc1, 0x87, 0x8b, 0xb3, 0x9d, 0xfc, 0x3a, 0xc1, 0x0, 0x56, 0x28, 0xe, 0x9c}; - uint8_t bytesprops7[] = {0x13, 0xb4, 0x37, 0x33, 0x59, 0xd1, 0x6f, 0xff, 0x14, 0x9e, 0x87, 0x66, - 0x63, 0xdb, 0x6e, 0x75, 0x62, 0x2e, 0xcc, 0x4e, 0x9f, 0xc8, 0x8f, 0x88}; - uint8_t bytesprops8[] = {0x7d, 0x55, 0x40, 0xcc, 0xbd, 0xbe, 0xfd, 0xcc, 0x8b, 0x23, 0xb, 0xa4}; - uint8_t bytesprops9[] = {0x7b, 0x53, 0xa7, 0x11, 0x5c, 0x4d, 0x49, 0x20, 0x5a, 0x2, 0x6, 0x4b, 0xc6, 0xb4}; + 0x10, 0xa7, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x46, 0x97, 0xcf, 0x1, 0x11, 0x0, 0x0, 0x60, + 0x84, 0x2a, 0xfa, 0x2a, 0x5e, 0x18, 0x0, 0x0, 0xa, 0x4f, 0x1c, 0x0, 0x1d, 0x6c, 0x82, 0x6, 0xfa, 0x19, 0xba, + 0x0, 0x5f, 0xb8, 0xe2, 0xd, 0x8b, 0x86, 0xe0, 0xe5, 0x95, 0x9b, 0x89, 0xcf, 0x78, 0x84, 0xaf, 0xe0, 0x37, 0x71, + 0xe, 0xfe, 0x9, 0x8c, 0x24, 0x9c, 0x11, 0x0, 0x0, 0x39, 0x3f, 0x18, 0x0, 0x0, 0x2e, 0x66, 0x22, 0x3e, 0xe6, + 0x3, 0x0, 0xc, 0xc1, 0x2, 0x39, 0x9b, 0x9b, 0x74, 0x36, 0xeb, 0x9a, 0x55, 0x84, 0x21, 0x28, 0xc8, 0x3, 0x0, + 0x15, 0xc8, 0xb, 0x8, 0xe0, 0x2a, 0x17, 0xc1, 0xe8, 0x5c, 0xa8, 0x47, 0x81, 0xe9, 0xee, 0x81, 0xf6, 0xab, 0x23, + 0x78, 0xcc, 0x78, 0x25, 0xcc, 0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0xae, + 0x90, 0x37, 0x39, 0xde, 0x7f, 0xd4, 0xcc, 0x27, 0x5, 0xe3, 0x8b, 0x37, 0x84, 0x0, 0xf, 0xcc, 0x12, 0x42, 0x77, + 0x9e, 0x47, 0xe8, 0x7b, 0xcc, 0xee, 0x4e, 0xda, 0x39, 0xc, 0x96, 0x0, 0x1c, 0x2f, 0x4d, 0x45, 0xdd, 0x2f, 0xe0, + 0x4c, 0xcb, 0xd8, 0x96, 0x9, 0x3d, 0xc3, 0x61, 0xa9, 0xc5, 0x50, 0x5b, 0xfb, 0x89, 0x13, 0xdb, 0x98, 0xfd, 0x5, + 0x4c, 0x99, 0xef}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x6c, 0x82, 0x6, 0xfa, 0x19, 0xba, 0x0, 0x5f, 0xb8, 0xe2, 0xd, 0x8b, 0x86, 0xe0, 0xe5, + 0x95, 0x9b, 0x89, 0xcf, 0x78, 0x84, 0xaf, 0xe0, 0x37, 0x71, 0xe, 0xfe, 0x9, 0x8c}; + uint8_t bytesprops1[] = {0xc1, 0x2, 0x39, 0x9b, 0x9b, 0x74, 0x36, 0xeb, 0x9a, 0x55, 0x84, 0x21}; + uint8_t bytesprops2[] = {0xc8, 0xb, 0x8, 0xe0, 0x2a, 0x17, 0xc1, 0xe8, 0x5c, 0xa8, 0x47, + 0x81, 0xe9, 0xee, 0x81, 0xf6, 0xab, 0x23, 0x78, 0xcc, 0x78}; + uint8_t bytesprops3[] = {0xcc, 0x7a, 0xfa, 0x1d, 0xbf, 0xb3, 0x85, 0xfe, 0x56, 0xc, + 0x2e, 0x89, 0x9f, 0x4c, 0x4b, 0xaa, 0x68, 0xa3, 0x16}; + uint8_t bytesprops4[] = {0x87, 0x3d, 0x15, 0x66, 0xef, 0xcd, 0x98, 0xee, 0x24, 0x95, 0x1, 0x46, 0x38, 0x89, + 0x8d, 0xc2, 0xff, 0x2f, 0x37, 0xd1, 0x4, 0xfb, 0x2, 0x25, 0xc9, 0x4f, 0xda}; + uint8_t bytesprops5[] = {0x82, 0x1, 0x2, 0xa2, 0x3a, 0x48, 0x91, 0xae, 0x5d, 0xc8, 0xc4, 0xdc, 0x41}; + uint8_t bytesprops6[] = {0x67}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16140}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27214}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3981}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7297}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2992}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14476}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24708}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2639}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14655}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11878}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16102}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29406}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13674}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23351}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20731}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14078}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 112}}, }; lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xd4, 0xb8, 0x8d, 0x5c, 0x8f, 0x25, 0x57, 0xbe, 0x7c, 0x98, + 0x13, 0xc1, 0x45, 0xa, 0x9, 0xed, 0x9f, 0xb8, 0x3f, 0xc2, + 0x81, 0x7c, 0x83, 0xe7, 0xab, 0x47, 0xe6, 0x30, 0x21, 0xbc}; + uint8_t byteswillprops1[] = {0xc1, 0xeb, 0x2c, 0x95, 0x37, 0xd4, 0x58}; + uint8_t byteswillprops2[] = {0xce, 0xfe, 0x57, 0x7a, 0x17, 0xae, 0x29, 0xb3, 0x23, 0x17, 0x9f, 0x57, 0xae}; + uint8_t byteswillprops3[] = {0x25, 0x15, 0x48, 0x19, 0x26, 0xa6, 0xd0, 0xc0, 0x19, 0xe2, 0x85, + 0xdf, 0x5, 0x36, 0x1c, 0x8a, 0x9c, 0x64, 0x7d, 0x91, 0x47, 0x76}; + uint8_t byteswillprops4[] = {0xa2, 0x97, 0x1a, 0x4e, 0xea, 0x1a, 0xe2, 0x33, 0x16, 0x38, 0x98, 0x9c, 0x2a, 0xf9, 0x89, + 0x6b, 0x36, 0xaf, 0xfa, 0x78, 0x9e, 0x87, 0x21, 0xd0, 0x2, 0x2b, 0xc2, 0x7, 0xf6}; + uint8_t byteswillprops5[] = {0xb5, 0x68, 0x26, 0x76, 0xb7, 0x5b, 0xbd, 0x2, 0x5d, 0x50, 0x32, 0xb6, 0x16, 0x4f, + 0xb3, 0xc, 0xf5, 0xe2, 0xa6, 0xbd, 0xec, 0xf7, 0x6f, 0xfa, 0x5d, 0xc1, 0x4d, 0xe5}; + uint8_t byteswillprops6[] = {0xf7, 0x56, 0x94, 0x9f, 0xdf, 0x60, 0x7, 0xf4, 0xd9, 0x62, 0x17, 0x3a, 0xd9}; + uint8_t byteswillprops7[] = {0x68, 0xf1, 0xfc, 0x50, 0x33, 0x88, 0xa, 0x9, 0x67, 0x36, + 0xf, 0x88, 0x6f, 0x12, 0x49, 0x5d, 0xbd, 0x62, 0x66, 0x79, + 0x7f, 0x39, 0x4c, 0x83, 0xc7, 0x2f, 0xa9, 0x7b, 0x67, 0xb4}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30066}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2047}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25577}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops7}}}, + }; + + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa0, 0x54, 0x58, 0x86, 0xb0, 0x1f, 0x61, 0xa7, 0xd1, 0x5b, 0x92, 0x30}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x82, 0x80, 0x62, 0x11, 0x55, 0xb2, 0xc6, 0x4a, 0x3a, 0x22, 0x9a, 0x39, 0xae, + 0x90, 0x37, 0x39, 0xde, 0x7f, 0xd4, 0xcc, 0x27, 0x5, 0xe3, 0x8b, 0x37, 0x84}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 22088; - uint8_t client_id_bytes[] = {0x6e, 0x78, 0xed, 0xfa, 0x60, 0x96}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 18071; + uint8_t client_id_bytes[] = {0x96, 0xed, 0x6e, 0xa6, 0xe5, 0x17, 0x69, 0x3b, + 0x6d, 0xe9, 0x16, 0x2c, 0x89, 0xd4, 0xc4, 0xda}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xc3, 0xe1, 0x5a, 0xf8, 0xa5, 0x53, 0xc9, 0x47, 0xa, 0x65, - 0x39, 0xa1, 0x3e, 0x1c, 0xc9, 0x5f, 0xef, 0x44, 0xcb, 0xd}; - lwmqtt_string_t username = {20, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xcc, 0x12, 0x42, 0x77, 0x9e, 0x47, 0xe8, 0x7b, 0xcc, 0xee, 0x4e, 0xda, 0x39, 0xc, 0x96}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xe6, 0x57, 0x48, 0xd3}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x2f, 0x4d, 0x45, 0xdd, 0x2f, 0xe0, 0x4c, 0xcb, 0xd8, 0x96, 0x9, 0x3d, 0xc3, 0x61, + 0xa9, 0xc5, 0x50, 0x5b, 0xfb, 0x89, 0x13, 0xdb, 0x98, 0xfd, 0x5, 0x4c, 0x99, 0xef}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "7{\215\177Q\252!\233\141P\206\242", _password = Just -// "\ETX\fegm\236K\157\249\140\DC3\144\186-9\156\238\222\167\138\202\SYN", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "j&\214\247\206Z\212\219\RS\US-,\155\190e!\\\142\GS\243X\241", _willMsg = -// "\SYN\183\156\207\209\215", _willProps = [PropReceiveMaximum 31818,PropWildcardSubscriptionAvailable -// 224,PropServerKeepAlive 8513,PropRetainAvailable 133,PropSubscriptionIdentifierAvailable 169,PropServerKeepAlive -// 16360,PropAssignedClientIdentifier -// "7\243\131\187\GSgs\132\148\245" -// "\NULA\ACK\207bc\214\161\190\248o\171M\149\142r\135\205\SI\131x\132"]}), _cleanSession = True, _keepAlive = 26306, -// _connID = "\SI&\208\136\142lJ|\nQ\231\&2,\161\FS\184", _properties = [PropCorrelationData -// "kC8\129\150/\197\176\179\200\140\159\183\203\154\NUL\135\DC4_w\157\158\v\247\213`U(\209\n",PropMessageExpiryInterval -// 3478,PropMaximumQoS 222,PropMessageExpiryInterval 23782,PropResponseTopic "\157",PropSubscriptionIdentifierAvailable -// 187,PropMessageExpiryInterval 25410,PropPayloadFormatIndicator 1,PropResponseInformation -// "\174\220\196\192t\230\196yu\199\201\244j\218\&5\184zZbT6\SUB[\245\221\a",PropResponseInformation -// "\227\184\FS\f0[\203f\192\DC3\179;\\K",PropCorrelationData "*\235`\150\210\ACK?",PropServerKeepAlive -// 705,PropTopicAlias 31472,PropReasonString -// "\234\212\DC1\232\222q\r\234k\130\242;\239V\DC2DA\152T\131\212\RS\213\180\208\220\RS",PropMessageExpiryInterval -// 24407,PropWillDelayInterval 28666,PropMessageExpiryInterval 24637,PropAuthenticationData -// "\226iup\252\137\163\218\135\203'",PropRetainAvailable 75,PropSubscriptionIdentifierAvailable -// 132,PropAuthenticationMethod "\vG\212aW\r2\230\DC4\176\145\237\DLE'",PropMaximumQoS 134,PropContentType -// "\225\182\179\141\168\&0\133\165\130\152P\175\229\213P",PropRetainAvailable 220]} +// ConnectRequest {_username = Just "\170\169T\181z[8\SOH\237A\171\211\161", _password = Just "\216/I\167", _lastWill = +// Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "i\\\223d\254\201\208#u\SUB\184\178\254^g", +// _willMsg = "\130\b\SOHn\241D<\208", _willProps = [PropAssignedClientIdentifier +// "\241\&2\DC4\187*\232\&5Jf\133y.\245T\255\&7+\140z0\DC2-\DLEe\190\243\213P\236",PropServerKeepAlive +// 17912,PropAuthenticationData "\159\233G\221",PropMessageExpiryInterval 10456,PropWillDelayInterval +// 6209,PropContentType "\198\147Xgv",PropServerKeepAlive 29007,PropAuthenticationData "\NAK\167v\SYN"]}), _cleanSession +// = False, _keepAlive = 20715, _connID = "\238Vc]\r\147\142\177>\228\133\&4\185\GS", _properties = +// [PropMessageExpiryInterval 1066,PropTopicAlias 16219,PropSubscriptionIdentifierAvailable +// 142,PropWildcardSubscriptionAvailable 211,PropRequestResponseInformation 233,PropRequestResponseInformation +// 2,PropRetainAvailable 154,PropTopicAlias 15714,PropPayloadFormatIndicator 42,PropWildcardSubscriptionAvailable +// 140,PropCorrelationData +// "m\198\ESC\222m7Ju\192J,\255\DLE\ACKW\247a\179%Q\214\227\212h\ETB\231",PropRequestResponseInformation +// 57,PropPayloadFormatIndicator 117,PropMaximumQoS 212,PropUserProperty +// "-\176\r\DEL\230}cU\\\163\243\STX`\v\250\&3\EM\f#j?\202<\141O\217\129\EM\186a" +// "qn\154f\136\r8\171\DC1\246",PropMessageExpiryInterval 1610,PropUserProperty +// "\SYN-\142J\224\SI,6\175\189\GS80\133M\t;&\211\203\170\147" "\179\189\192S\205\150\203<\129\ENQ\175"]} TEST(Connect5QCTest, Encode11) { uint8_t pkt[] = { - 0x10, 0xfa, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x66, 0xc2, 0xde, 0x1, 0x9, 0x0, 0x1e, 0x6b, - 0x43, 0x38, 0x81, 0x96, 0x2f, 0xc5, 0xb0, 0xb3, 0xc8, 0x8c, 0x9f, 0xb7, 0xcb, 0x9a, 0x0, 0x87, 0x14, 0x5f, 0x77, - 0x9d, 0x9e, 0xb, 0xf7, 0xd5, 0x60, 0x55, 0x28, 0xd1, 0xa, 0x2, 0x0, 0x0, 0xd, 0x96, 0x24, 0xde, 0x2, 0x0, - 0x0, 0x5c, 0xe6, 0x8, 0x0, 0x1, 0x9d, 0x29, 0xbb, 0x2, 0x0, 0x0, 0x63, 0x42, 0x1, 0x1, 0x1a, 0x0, 0x1a, - 0xae, 0xdc, 0xc4, 0xc0, 0x74, 0xe6, 0xc4, 0x79, 0x75, 0xc7, 0xc9, 0xf4, 0x6a, 0xda, 0x35, 0xb8, 0x7a, 0x5a, 0x62, - 0x54, 0x36, 0x1a, 0x5b, 0xf5, 0xdd, 0x7, 0x1a, 0x0, 0xe, 0xe3, 0xb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c, 0x21, 0xe9, 0x8d, 0x50, 0xce, 0xf2, 0x0, 0x16, 0x3, 0xc, 0x65, 0x67, 0x6d, 0xec, 0x4b, - 0x9d, 0xf9, 0x8c, 0x13, 0x90, 0xba, 0x2d, 0x39, 0x9c, 0xee, 0xde, 0xa7, 0x8a, 0xca, 0x16}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x6b, 0x43, 0x38, 0x81, 0x96, 0x2f, 0xc5, 0xb0, 0xb3, 0xc8, 0x8c, 0x9f, 0xb7, 0xcb, 0x9a, - 0x0, 0x87, 0x14, 0x5f, 0x77, 0x9d, 0x9e, 0xb, 0xf7, 0xd5, 0x60, 0x55, 0x28, 0xd1, 0xa}; - uint8_t bytesprops1[] = {0x9d}; - uint8_t bytesprops2[] = {0xae, 0xdc, 0xc4, 0xc0, 0x74, 0xe6, 0xc4, 0x79, 0x75, 0xc7, 0xc9, 0xf4, 0x6a, - 0xda, 0x35, 0xb8, 0x7a, 0x5a, 0x62, 0x54, 0x36, 0x1a, 0x5b, 0xf5, 0xdd, 0x7}; - uint8_t bytesprops3[] = {0xe3, 0xb8, 0x1c, 0xc, 0x30, 0x5b, 0xcb, 0x66, 0xc0, 0x13, 0xb3, 0x3b, 0x5c, 0x4b}; - uint8_t bytesprops4[] = {0x2a, 0xeb, 0x60, 0x96, 0xd2, 0x6, 0x3f}; - uint8_t bytesprops5[] = {0xea, 0xd4, 0x11, 0xe8, 0xde, 0x71, 0xd, 0xea, 0x6b, 0x82, 0xf2, 0x3b, 0xef, 0x56, - 0x12, 0x44, 0x41, 0x98, 0x54, 0x83, 0xd4, 0x1e, 0xd5, 0xb4, 0xd0, 0xdc, 0x1e}; - uint8_t bytesprops6[] = {0xe2, 0x69, 0x75, 0x70, 0xfc, 0x89, 0xa3, 0xda, 0x87, 0xcb, 0x27}; - uint8_t bytesprops7[] = {0xb, 0x47, 0xd4, 0x61, 0x57, 0xd, 0x32, 0xe6, 0x14, 0xb0, 0x91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ee, 0x56, 0x63, 0x5d, 0xd, 0x93, + 0x8e, 0xb1, 0x3e, 0xe4, 0x85, 0x34, 0xb9, 0x1d, 0x46, 0x12, 0x0, 0x1d, 0xf1, 0x32, 0x14, 0xbb, 0x2a, 0xe8, 0x35, + 0x4a, 0x66, 0x85, 0x79, 0x2e, 0xf5, 0x54, 0xff, 0x37, 0x2b, 0x8c, 0x7a, 0x30, 0x12, 0x2d, 0x10, 0x65, 0xbe, 0xf3, + 0xd5, 0x50, 0xec, 0x13, 0x45, 0xf8, 0x16, 0x0, 0x4, 0x9f, 0xe9, 0x47, 0xdd, 0x2, 0x0, 0x0, 0x28, 0xd8, 0x18, + 0x0, 0x0, 0x18, 0x41, 0x3, 0x0, 0x5, 0xc6, 0x93, 0x58, 0x67, 0x76, 0x13, 0x71, 0x4f, 0x16, 0x0, 0x4, 0x15, + 0xa7, 0x76, 0x16, 0x0, 0xf, 0x69, 0x5c, 0xdf, 0x64, 0xfe, 0xc9, 0xd0, 0x23, 0x75, 0x1a, 0xb8, 0xb2, 0xfe, 0x5e, + 0x67, 0x0, 0x8, 0x82, 0x8, 0x1, 0x6e, 0xf1, 0x44, 0x3c, 0xd0, 0x0, 0xd, 0xaa, 0xa9, 0x54, 0xb5, 0x7a, 0x5b, + 0x38, 0x1, 0xed, 0x41, 0xab, 0xd3, 0xa1, 0x0, 0x4, 0xd8, 0x2f, 0x49, 0xa7}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x6d, 0xc6, 0x1b, 0xde, 0x6d, 0x37, 0x4a, 0x75, 0xc0, 0x4a, 0x2c, 0xff, 0x10, + 0x6, 0x57, 0xf7, 0x61, 0xb3, 0x25, 0x51, 0xd6, 0xe3, 0xd4, 0x68, 0x17, 0xe7}; + uint8_t bytesprops2[] = {0x71, 0x6e, 0x9a, 0x66, 0x88, 0xd, 0x38, 0xab, 0x11, 0xf6}; + uint8_t bytesprops1[] = {0x2d, 0xb0, 0xd, 0x7f, 0xe6, 0x7d, 0x63, 0x55, 0x5c, 0xa3, 0xf3, 0x2, 0x60, 0xb, 0xfa, + 0x33, 0x19, 0xc, 0x23, 0x6a, 0x3f, 0xca, 0x3c, 0x8d, 0x4f, 0xd9, 0x81, 0x19, 0xba, 0x61}; + uint8_t bytesprops4[] = {0xb3, 0xbd, 0xc0, 0x53, 0xcd, 0x96, 0xcb, 0x3c, 0x81, 0x5, 0xaf}; + uint8_t bytesprops3[] = {0x16, 0x2d, 0x8e, 0x4a, 0xe0, 0xf, 0x2c, 0x36, 0xaf, 0xbd, 0x1d, + 0x38, 0x30, 0x85, 0x4d, 0x9, 0x3b, 0x26, 0xd3, 0xcb, 0xaa, 0x93}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3478}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23782}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25410}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 705}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31472}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24407}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28666}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24637}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1066}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16219}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15714}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops1}, .v = {10, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1610}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops3}, .v = {11, (char*)&bytesprops4}}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x37, 0xf3, 0x3c, 0x2f, 0x60, 0x2, 0x64, 0xd0, 0x36, 0x62, 0xbf, - 0x79, 0xec, 0x10, 0x8, 0xe4, 0xe7, 0x1, 0xf1, 0x8a, 0xc, 0x2e}; - uint8_t byteswillprops1[] = {0xce, 0xf3, 0x7f, 0xfe, 0x5c, 0x9b, 0x40, 0xfa, 0xd8, 0xeb, 0x6, 0x94, 0x2b, 0xd3}; - uint8_t byteswillprops2[] = {0xdf, 0xd7, 0xc4, 0xe8, 0x3b, 0x2c, 0xc3, 0xe9, 0x40, 0xd4, - 0xda, 0xe0, 0xeb, 0x3c, 0xf8, 0xc4, 0x71, 0x6d, 0xb7, 0xc2, - 0x30, 0x1c, 0x4, 0x17, 0x5d, 0x61, 0xab, 0xd7, 0xb9, 0x2f}; - uint8_t byteswillprops3[] = {0x70, 0x3f, 0x92, 0xa, 0xf, 0x24, 0x9c, 0x50, 0x0, 0xa0, 0xd9, 0x32, - 0x80, 0xbd, 0x2d, 0x49, 0x1, 0xa2, 0xbe, 0x90, 0x57, 0x97, 0xd6}; - uint8_t byteswillprops4[] = {0x3}; - uint8_t byteswillprops5[] = {0xc8, 0x71}; - uint8_t byteswillprops7[] = {0x0, 0x41, 0x6, 0xcf, 0x62, 0x63, 0xd6, 0xa1, 0xbe, 0xf8, 0x6f, - 0xab, 0x4d, 0x95, 0x8e, 0x72, 0x87, 0xcd, 0xf, 0x83, 0x78, 0x84}; - uint8_t byteswillprops6[] = {0xf6, 0x47, 0x77, 0x92, 0x3e, 0x83, 0xbb, 0x1d, 0x67, 0x73, 0x84, 0x94, 0xf5}; + uint8_t byteswillprops0[] = {0xf1, 0x32, 0x14, 0xbb, 0x2a, 0xe8, 0x35, 0x4a, 0x66, 0x85, 0x79, 0x2e, 0xf5, 0x54, 0xff, + 0x37, 0x2b, 0x8c, 0x7a, 0x30, 0x12, 0x2d, 0x10, 0x65, 0xbe, 0xf3, 0xd5, 0x50, 0xec}; + uint8_t byteswillprops1[] = {0x9f, 0xe9, 0x47, 0xdd}; + uint8_t byteswillprops2[] = {0xc6, 0x93, 0x58, 0x67, 0x76}; + uint8_t byteswillprops3[] = {0x15, 0xa7, 0x76, 0x16}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31818}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8513}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16360}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22714}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1969}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24092}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {13, (char*)&byteswillprops6}, .v = {22, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17912}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10456}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6209}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29007}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&byteswillprops3}}}, }; - lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6a, 0x26, 0xd6, 0xf7, 0xce, 0x5a, 0xd4, 0xdb, 0x1e, 0x1f, 0x2d, - 0x2c, 0x9b, 0xbe, 0x65, 0x21, 0x5c, 0x8e, 0x1d, 0xf3, 0x58, 0xf1}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x16, 0xb7, 0x9c, 0xcf, 0xd1, 0xd7}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x69, 0x5c, 0xdf, 0x64, 0xfe, 0xc9, 0xd0, 0x23, + 0x75, 0x1a, 0xb8, 0xb2, 0xfe, 0x5e, 0x67}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x82, 0x8, 0x1, 0x6e, 0xf1, 0x44, 0x3c, 0xd0}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 26306; - uint8_t client_id_bytes[] = {0xf, 0x26, 0xd0, 0x88, 0x8e, 0x6c, 0x4a, 0x7c, - 0xa, 0x51, 0xe7, 0x32, 0x2c, 0xa1, 0x1c, 0xb8}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 20715; + uint8_t client_id_bytes[] = {0xee, 0x56, 0x63, 0x5d, 0xd, 0x93, 0x8e, 0xb1, 0x3e, 0xe4, 0x85, 0x34, 0xb9, 0x1d}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x37, 0x7b, 0xd7, 0xb1, 0x51, 0xfc, 0x21, 0xe9, 0x8d, 0x50, 0xce, 0xf2}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xaa, 0xa9, 0x54, 0xb5, 0x7a, 0x5b, 0x38, 0x1, 0xed, 0x41, 0xab, 0xd3, 0xa1}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x3, 0xc, 0x65, 0x67, 0x6d, 0xec, 0x4b, 0x9d, 0xf9, 0x8c, 0x13, - 0x90, 0xba, 0x2d, 0x39, 0x9c, 0xee, 0xde, 0xa7, 0x8a, 0xca, 0x16}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xd8, 0x2f, 0x49, 0xa7}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8091,105 +8000,182 @@ TEST(Connect5QCTest, Encode11) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\169\190fw\241\246)\vwT\139\DC3xx\216\189\225\158\213x\238\179\140", _password = -// Just "q\230-\213\ENQ5-T\188\DEL\b\213\155+\SO`m\GS \242\165#\\", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS0, _willTopic = "\217 \214\EM\178\ACK\155", _willMsg = -// "\245)\238j2\DC2\161\134.\140\147HX\198`\252\237D\164\157*", _willProps = [PropAuthenticationMethod -// "\154\133en<\173\aS",PropCorrelationData "/L\159\131\US\180\n\145Yq",PropRequestProblemInformation -// 88,PropRetainAvailable 40,PropTopicAlias 5030,PropSharedSubscriptionAvailable 42,PropMaximumPacketSize -// 18739,PropSubscriptionIdentifierAvailable 50,PropMessageExpiryInterval 19443,PropPayloadFormatIndicator -// 181,PropCorrelationData "\186\CAN\164\193\133\210)$\182p\184\215\ESC",PropTopicAlias 8775,PropCorrelationData -// "W\ETB\137\143\130\NUL,\168\ETB\203\148",PropWildcardSubscriptionAvailable 107,PropWildcardSubscriptionAvailable -// 71,PropMaximumQoS 251]}), _cleanSession = False, _keepAlive = 19404, _connID = -// "#f\162\233\167\DEL?\182\198\174aF\143S\150\160\186\DC2JqI\244\199\152\&3", _properties = [PropSubscriptionIdentifier -// 30,PropWildcardSubscriptionAvailable 54,PropSubscriptionIdentifierAvailable 173,PropServerReference -// "\220>\CAN\188\191\155+C\205D\175\188\162\163\&3\171\DC3\EOT\196\138&",PropReasonString -// "\159\154\255\SO\211\201\179l\130\187i~!q",PropMaximumQoS 56,PropTopicAlias 11834,PropTopicAlias 30167]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\128", _willMsg = "G\244\250\238\173\220\204", _willProps = [PropServerKeepAlive +// 30225,PropRetainAvailable 120,PropUserProperty "r|M\rx\197\nG\t\147\215}\158\176\233\132C\164\ENQx`!Q" +// "\226}Z{\168|OL\GS\155)\229Q\166",PropAssignedClientIdentifier "\\\245\RSS\198\DLEY`\EM\210%\186 +// \239\193\186SR\216d#\SOx\239``",PropServerReference "\RS\172\142",PropSharedSubscriptionAvailable +// 237,PropResponseInformation "\155\241P\172-\174\142\RSx\139G3\180\250\&5\255!\NUL\173\n\144",PropRetainAvailable +// 199,PropSubscriptionIdentifier 19,PropAuthenticationData +// "_!i\159]\238\\\SI\128\194\198\230i\138",PropAuthenticationMethod +// "I\159l\214\226\158\245R\140\213\199\156cO\183\SO\249Qgk`\n\200\FSM\t",PropTopicAlias 15985,PropAuthenticationData +// "\228\150\233\227",PropTopicAlias 6436,PropRequestProblemInformation 224,PropAuthenticationMethod +// "((\182Wo\245t<\DC2\227\184\160\200\157\&6\148",PropSubscriptionIdentifierAvailable 75,PropRequestResponseInformation +// 45]}), _cleanSession = True, _keepAlive = 28847, _connID = "IP", _properties = [PropWildcardSubscriptionAvailable +// 111,PropReceiveMaximum 14339,PropResponseTopic "\148\162\143\176\245\194",PropContentType +// "\223\212FBW&\184s\206\183\&7",PropAuthenticationMethod +// "\146\204Op\161\&3]+\182\148e\211\172\159^\141`>\243\189\251w.\DC4\233\164$\167\236",PropSharedSubscriptionAvailable +// 181,PropContentType "\168a\130\"\205\208S\218 /F9\255r\185\ETX",PropMessageExpiryInterval 6731,PropWillDelayInterval +// 22863,PropRequestProblemInformation 161,PropAuthenticationMethod "\179\205g\128H\128a\137jb\SYNe\n",PropContentType +// "\170\DC3S\DC41S\191;\vYw\154\176!H\b\148\161~\ETXs\180%\DC2\183",PropAuthenticationData +// "\155\203",PropSessionExpiryInterval 5522,PropResponseInformation +// "\195\202\180\227\178p#\183\178_j\236\US\EM\DC1\165\160",PropSubscriptionIdentifier 2,PropUserProperty +// "\151\199@N\145h\195>\196\211\200X\212\178!\ESC\179" +// "\132\170\182\138\243\152\SUB\223\129\158\181\174\ETX",PropUserProperty "#[\GS/w\138\130\238\DLE\223;(2\152E\128" +// "!\v\133\SOt\139b\136\SO\211uc\147\ACK\DC3\144\169I\159\SOH9#\153\154^\156\168V`\130",PropTopicAliasMaximum +// 13969,PropSharedSubscriptionAvailable 151,PropResponseTopic +// "\184I4u\219D|N1\SUB/\DC1\238N,$\222\ENQ\229\235\140\&4\166",PropWildcardSubscriptionAvailable 27,PropUserProperty +// "\202\207\143\FSW\"\150Z \150/\234\&7\USI\172o\196\NAKr%\216\ESC\254\175\220\&8\135\FS" +// "\226\177\f\b\141x\188\154\205\224g)\173y\170EiU\186[\150=\RS\233&",PropContentType +// "\239J\250$L\169\196\170\196-`H\217\134\227t\fq\NUL\249\178CZY\255\130"]} TEST(Connect5QCTest, Encode12) { uint8_t pkt[] = { - 0x10, 0x86, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc4, 0x4b, 0xcc, 0x37, 0xb, 0x1e, 0x28, 0x36, 0x29, - 0xad, 0x1c, 0x0, 0x15, 0xdc, 0x3e, 0x18, 0xbc, 0xbf, 0x9b, 0x2b, 0x43, 0xcd, 0x44, 0xaf, 0xbc, 0xa2, 0xa3, 0x33, - 0xab, 0x13, 0x4, 0xc4, 0x8a, 0x26, 0x1f, 0x0, 0xe, 0x9f, 0x9a, 0xff, 0xe, 0xd3, 0xc9, 0xb3, 0x6c, 0x82, 0xbb, - 0x69, 0x7e, 0x21, 0x71, 0x24, 0x38, 0x23, 0x2e, 0x3a, 0x23, 0x75, 0xd7, 0x0, 0x19, 0x23, 0x66, 0xa2, 0xe9, 0xa7, - 0x7f, 0x3f, 0xb6, 0xc6, 0xae, 0x61, 0x46, 0x8f, 0x53, 0x96, 0xa0, 0xba, 0x12, 0x4a, 0x71, 0x49, 0xf4, 0xc7, 0x98, - 0x33, 0x56, 0x15, 0x0, 0x8, 0x9a, 0x85, 0x65, 0x6e, 0x3c, 0xad, 0x7, 0x53, 0x9, 0x0, 0xa, 0x2f, 0x4c, 0x9f, - 0x83, 0x1f, 0xb4, 0xa, 0x91, 0x59, 0x71, 0x17, 0x58, 0x25, 0x28, 0x23, 0x13, 0xa6, 0x2a, 0x2a, 0x27, 0x0, 0x0, - 0x49, 0x33, 0x29, 0x32, 0x2, 0x0, 0x0, 0x4b, 0xf3, 0x1, 0xb5, 0x9, 0x0, 0xd, 0xba, 0x18, 0xa4, 0xc1, 0x85, - 0xd2, 0x29, 0x24, 0xb6, 0x70, 0xb8, 0xd7, 0x1b, 0x23, 0x22, 0x47, 0x9, 0x0, 0xb, 0x57, 0x17, 0x89, 0x8f, 0x82, - 0x0, 0x2c, 0xa8, 0x17, 0xcb, 0x94, 0x28, 0x6b, 0x28, 0x47, 0x24, 0xfb, 0x0, 0x7, 0xd9, 0x20, 0xd6, 0x19, 0xb2, - 0x6, 0x9b, 0x0, 0x15, 0xf5, 0x29, 0xee, 0x6a, 0x32, 0x12, 0xa1, 0x86, 0x2e, 0x8c, 0x93, 0x48, 0x58, 0xc6, 0x60, - 0xfc, 0xed, 0x44, 0xa4, 0x9d, 0x2a, 0x0, 0x17, 0xa9, 0xbe, 0x66, 0x77, 0xf1, 0xf6, 0x29, 0xb, 0x77, 0x54, 0x8b, - 0x13, 0x78, 0x78, 0xd8, 0xbd, 0xe1, 0x9e, 0xd5, 0x78, 0xee, 0xb3, 0x8c, 0x0, 0x17, 0x71, 0xe6, 0x2d, 0xd5, 0x5, - 0x35, 0x2d, 0x54, 0xbc, 0x7f, 0x8, 0xd5, 0x9b, 0x2b, 0xe, 0x60, 0x6d, 0x1d, 0x20, 0xf2, 0xa5, 0x23, 0x5c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xdc, 0x3e, 0x18, 0xbc, 0xbf, 0x9b, 0x2b, 0x43, 0xcd, 0x44, 0xaf, - 0xbc, 0xa2, 0xa3, 0x33, 0xab, 0x13, 0x4, 0xc4, 0x8a, 0x26}; - uint8_t bytesprops1[] = {0x9f, 0x9a, 0xff, 0xe, 0xd3, 0xc9, 0xb3, 0x6c, 0x82, 0xbb, 0x69, 0x7e, 0x21, 0x71}; + 0x10, 0xda, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0x70, 0xaf, 0xf8, 0x2, 0x28, 0x6f, 0x21, 0x38, + 0x3, 0x8, 0x0, 0x6, 0x94, 0xa2, 0x8f, 0xb0, 0xf5, 0xc2, 0x3, 0x0, 0xb, 0xdf, 0xd4, 0x46, 0x42, 0x57, 0x26, + 0xb8, 0x73, 0xce, 0xb7, 0x37, 0x15, 0x0, 0x1d, 0x92, 0xcc, 0x4f, 0x70, 0xa1, 0x33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0x51, 0x0, 0xe, 0xe2, 0x7d, 0x5a, 0x7b, 0xa8, 0x7c, 0x4f, + 0x4c, 0x1d, 0x9b, 0x29, 0xe5, 0x51, 0xa6, 0x12, 0x0, 0x1a, 0x5c, 0xf5, 0x1e, 0x53, 0xc6, 0x10, 0x59, 0x60, 0x19, + 0xd2, 0x25, 0xba, 0x20, 0xef, 0xc1, 0xba, 0x53, 0x52, 0xd8, 0x64, 0x23, 0xe, 0x78, 0xef, 0x60, 0x60, 0x1c, 0x0, + 0x3, 0x1e, 0xac, 0x8e, 0x2a, 0xed, 0x1a, 0x0, 0x15, 0x9b, 0xf1, 0x50, 0xac, 0x2d, 0xae, 0x8e, 0x1e, 0x78, 0x8b, + 0x47, 0x33, 0xb4, 0xfa, 0x35, 0xff, 0x21, 0x0, 0xad, 0xa, 0x90, 0x25, 0xc7, 0xb, 0x13, 0x16, 0x0, 0xe, 0x5f, + 0x21, 0x69, 0x9f, 0x5d, 0xee, 0x5c, 0xf, 0x80, 0xc2, 0xc6, 0xe6, 0x69, 0x8a, 0x15, 0x0, 0x1a, 0x49, 0x9f, 0x6c, + 0xd6, 0xe2, 0x9e, 0xf5, 0x52, 0x8c, 0xd5, 0xc7, 0x9c, 0x63, 0x4f, 0xb7, 0xe, 0xf9, 0x51, 0x67, 0x6b, 0x60, 0xa, + 0xc8, 0x1c, 0x4d, 0x9, 0x23, 0x3e, 0x71, 0x16, 0x0, 0x4, 0xe4, 0x96, 0xe9, 0xe3, 0x23, 0x19, 0x24, 0x17, 0xe0, + 0x15, 0x0, 0x10, 0x28, 0x28, 0xb6, 0x57, 0x6f, 0xf5, 0x74, 0x3c, 0x12, 0xe3, 0xb8, 0xa0, 0xc8, 0x9d, 0x36, 0x94, + 0x29, 0x4b, 0x19, 0x2d, 0x0, 0x1, 0x80, 0x0, 0x7, 0x47, 0xf4, 0xfa, 0xee, 0xad, 0xdc, 0xcc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x94, 0xa2, 0x8f, 0xb0, 0xf5, 0xc2}; + uint8_t bytesprops1[] = {0xdf, 0xd4, 0x46, 0x42, 0x57, 0x26, 0xb8, 0x73, 0xce, 0xb7, 0x37}; + uint8_t bytesprops2[] = {0x92, 0xcc, 0x4f, 0x70, 0xa1, 0x33, 0x5d, 0x2b, 0xb6, 0x94, 0x65, 0xd3, 0xac, 0x9f, 0x5e, + 0x8d, 0x60, 0x3e, 0xf3, 0xbd, 0xfb, 0x77, 0x2e, 0x14, 0xe9, 0xa4, 0x24, 0xa7, 0xec}; + uint8_t bytesprops3[] = {0xa8, 0x61, 0x82, 0x22, 0xcd, 0xd0, 0x53, 0xda, + 0x20, 0x2f, 0x46, 0x39, 0xff, 0x72, 0xb9, 0x3}; + uint8_t bytesprops4[] = {0xb3, 0xcd, 0x67, 0x80, 0x48, 0x80, 0x61, 0x89, 0x6a, 0x62, 0x16, 0x65, 0xa}; + uint8_t bytesprops5[] = {0xaa, 0x13, 0x53, 0x14, 0x31, 0x53, 0xbf, 0x3b, 0xb, 0x59, 0x77, 0x9a, 0xb0, + 0x21, 0x48, 0x8, 0x94, 0xa1, 0x7e, 0x3, 0x73, 0xb4, 0x25, 0x12, 0xb7}; + uint8_t bytesprops6[] = {0x9b, 0xcb}; + uint8_t bytesprops7[] = {0xc3, 0xca, 0xb4, 0xe3, 0xb2, 0x70, 0x23, 0xb7, 0xb2, + 0x5f, 0x6a, 0xec, 0x1f, 0x19, 0x11, 0xa5, 0xa0}; + uint8_t bytesprops9[] = {0x84, 0xaa, 0xb6, 0x8a, 0xf3, 0x98, 0x1a, 0xdf, 0x81, 0x9e, 0xb5, 0xae, 0x3}; + uint8_t bytesprops8[] = {0x97, 0xc7, 0x40, 0x4e, 0x91, 0x68, 0xc3, 0x3e, 0xc4, + 0xd3, 0xc8, 0x58, 0xd4, 0xb2, 0x21, 0x1b, 0xb3}; + uint8_t bytesprops11[] = {0x21, 0xb, 0x85, 0xe, 0x74, 0x8b, 0x62, 0x88, 0xe, 0xd3, 0x75, 0x63, 0x93, 0x6, 0x13, + 0x90, 0xa9, 0x49, 0x9f, 0x1, 0x39, 0x23, 0x99, 0x9a, 0x5e, 0x9c, 0xa8, 0x56, 0x60, 0x82}; + uint8_t bytesprops10[] = {0x23, 0x5b, 0x1d, 0x2f, 0x77, 0x8a, 0x82, 0xee, + 0x10, 0xdf, 0x3b, 0x28, 0x32, 0x98, 0x45, 0x80}; + uint8_t bytesprops12[] = {0xb8, 0x49, 0x34, 0x75, 0xdb, 0x44, 0x7c, 0x4e, 0x31, 0x1a, 0x2f, 0x11, + 0xee, 0x4e, 0x2c, 0x24, 0xde, 0x5, 0xe5, 0xeb, 0x8c, 0x34, 0xa6}; + uint8_t bytesprops14[] = {0xe2, 0xb1, 0xc, 0x8, 0x8d, 0x78, 0xbc, 0x9a, 0xcd, 0xe0, 0x67, 0x29, 0xad, + 0x79, 0xaa, 0x45, 0x69, 0x55, 0xba, 0x5b, 0x96, 0x3d, 0x1e, 0xe9, 0x26}; + uint8_t bytesprops13[] = {0xca, 0xcf, 0x8f, 0x1c, 0x57, 0x22, 0x96, 0x5a, 0x20, 0x96, 0x2f, 0xea, 0x37, 0x1f, 0x49, + 0xac, 0x6f, 0xc4, 0x15, 0x72, 0x25, 0xd8, 0x1b, 0xfe, 0xaf, 0xdc, 0x38, 0x87, 0x1c}; + uint8_t bytesprops15[] = {0xef, 0x4a, 0xfa, 0x24, 0x4c, 0xa9, 0xc4, 0xaa, 0xc4, 0x2d, 0x60, 0x48, 0xd9, + 0x86, 0xe3, 0x74, 0xc, 0x71, 0x0, 0xf9, 0xb2, 0x43, 0x5a, 0x59, 0xff, 0x82}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11834}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30167}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14339}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6731}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22863}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5522}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops8}, .v = {13, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {16, (char*)&bytesprops10}, .v = {30, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13969}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {29, (char*)&bytesprops13}, .v = {25, (char*)&bytesprops14}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops15}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x9a, 0x85, 0x65, 0x6e, 0x3c, 0xad, 0x7, 0x53}; - uint8_t byteswillprops1[] = {0x2f, 0x4c, 0x9f, 0x83, 0x1f, 0xb4, 0xa, 0x91, 0x59, 0x71}; - uint8_t byteswillprops2[] = {0xba, 0x18, 0xa4, 0xc1, 0x85, 0xd2, 0x29, 0x24, 0xb6, 0x70, 0xb8, 0xd7, 0x1b}; - uint8_t byteswillprops3[] = {0x57, 0x17, 0x89, 0x8f, 0x82, 0x0, 0x2c, 0xa8, 0x17, 0xcb, 0x94}; + uint8_t byteswillprops1[] = {0xe2, 0x7d, 0x5a, 0x7b, 0xa8, 0x7c, 0x4f, 0x4c, 0x1d, 0x9b, 0x29, 0xe5, 0x51, 0xa6}; + uint8_t byteswillprops0[] = {0x72, 0x7c, 0x4d, 0xd, 0x78, 0xc5, 0xa, 0x47, 0x9, 0x93, 0xd7, 0x7d, + 0x9e, 0xb0, 0xe9, 0x84, 0x43, 0xa4, 0x5, 0x78, 0x60, 0x21, 0x51}; + uint8_t byteswillprops2[] = {0x5c, 0xf5, 0x1e, 0x53, 0xc6, 0x10, 0x59, 0x60, 0x19, 0xd2, 0x25, 0xba, 0x20, + 0xef, 0xc1, 0xba, 0x53, 0x52, 0xd8, 0x64, 0x23, 0xe, 0x78, 0xef, 0x60, 0x60}; + uint8_t byteswillprops3[] = {0x1e, 0xac, 0x8e}; + uint8_t byteswillprops4[] = {0x9b, 0xf1, 0x50, 0xac, 0x2d, 0xae, 0x8e, 0x1e, 0x78, 0x8b, 0x47, + 0x33, 0xb4, 0xfa, 0x35, 0xff, 0x21, 0x0, 0xad, 0xa, 0x90}; + uint8_t byteswillprops5[] = {0x5f, 0x21, 0x69, 0x9f, 0x5d, 0xee, 0x5c, 0xf, 0x80, 0xc2, 0xc6, 0xe6, 0x69, 0x8a}; + uint8_t byteswillprops6[] = {0x49, 0x9f, 0x6c, 0xd6, 0xe2, 0x9e, 0xf5, 0x52, 0x8c, 0xd5, 0xc7, 0x9c, 0x63, + 0x4f, 0xb7, 0xe, 0xf9, 0x51, 0x67, 0x6b, 0x60, 0xa, 0xc8, 0x1c, 0x4d, 0x9}; + uint8_t byteswillprops7[] = {0xe4, 0x96, 0xe9, 0xe3}; + uint8_t byteswillprops8[] = {0x28, 0x28, 0xb6, 0x57, 0x6f, 0xf5, 0x74, 0x3c, + 0x12, 0xe3, 0xb8, 0xa0, 0xc8, 0x9d, 0x36, 0x94}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5030}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18739}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19443}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8775}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30225}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {23, (char*)&byteswillprops0}, .v = {14, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15985}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6436}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 45}}, }; - lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd9, 0x20, 0xd6, 0x19, 0xb2, 0x6, 0x9b}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf5, 0x29, 0xee, 0x6a, 0x32, 0x12, 0xa1, 0x86, 0x2e, 0x8c, 0x93, - 0x48, 0x58, 0xc6, 0x60, 0xfc, 0xed, 0x44, 0xa4, 0x9d, 0x2a}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x80}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x47, 0xf4, 0xfa, 0xee, 0xad, 0xdc, 0xcc}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19404; - uint8_t client_id_bytes[] = {0x23, 0x66, 0xa2, 0xe9, 0xa7, 0x7f, 0x3f, 0xb6, 0xc6, 0xae, 0x61, 0x46, 0x8f, - 0x53, 0x96, 0xa0, 0xba, 0x12, 0x4a, 0x71, 0x49, 0xf4, 0xc7, 0x98, 0x33}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 28847; + uint8_t client_id_bytes[] = {0x49, 0x50}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa9, 0xbe, 0x66, 0x77, 0xf1, 0xf6, 0x29, 0xb, 0x77, 0x54, 0x8b, 0x13, - 0x78, 0x78, 0xd8, 0xbd, 0xe1, 0x9e, 0xd5, 0x78, 0xee, 0xb3, 0x8c}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x71, 0xe6, 0x2d, 0xd5, 0x5, 0x35, 0x2d, 0x54, 0xbc, 0x7f, 0x8, 0xd5, - 0x9b, 0x2b, 0xe, 0x60, 0x6d, 0x1d, 0x20, 0xf2, 0xa5, 0x23, 0x5c}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8198,94 +8184,126 @@ TEST(Connect5QCTest, Encode12) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\SIu}\231\235\&7\157S\163\235u\157\206\215Gn\180\152\STX\142\225\150\&0\244B0", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\173\184D\250<\252,\186c\146\178T!\ETXkKR\SO\139\253\&6", _willMsg = "h\144\228&\249\240u\248L", _willProps = -// [PropMessageExpiryInterval 22862,PropWillDelayInterval 19734,PropAuthenticationData -// "\EM\130\170\b\133\219\DC3+\245\ETX\146\158\241\129\&8\251\236\229\&4\229\STXo\143\204\SIe\232D\146",PropRequestProblemInformation -// 66,PropMessageExpiryInterval 15740,PropAuthenticationData "21",PropWildcardSubscriptionAvailable 134,PropContentType -// "\230\ENQ\SUB\FS\213\137r\a@\251EYX\218\ETX>q\DC4R/W>\250",PropMessageExpiryInterval 11158,PropAuthenticationData -// "g",PropResponseTopic "\144nN\DC2u\207\STX\199Dp\NUL\167{",PropMessageExpiryInterval 12811]}), _cleanSession = True, -// _keepAlive = 14654, _connID = "b!\199C\NAK8m\183\ETB\162\161\131\255\f\236\203\165\189\153\b\v\b\ACK", _properties = -// [PropCorrelationData "\DC2\207K\144\b\232\205v\229\\\176\218",PropWillDelayInterval 392,PropSessionExpiryInterval -// 27867,PropWillDelayInterval 21051,PropPayloadFormatIndicator 146,PropAuthenticationData ""]} +// ConnectRequest {_username = Just "hWE\168_M\187,\211\130\251B\217\\\139X\246p\GSUQ\252\&7\198\223\143}\191\164", +// _password = Just "\221\"\180", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "/\161\ETX\236\174\202\142\ACK\ENQ&\231\230Zg", _willMsg = "\164:(\192D\224", _willProps = [PropAuthenticationData +// "\218\NAKY\230\f\ETX \198\248\205\147\251\DLEu\240.\197(\243\227\146\144\218_",PropRequestResponseInformation +// 37,PropReasonString "Y\r\183N",PropSharedSubscriptionAvailable 205,PropSubscriptionIdentifier +// 18,PropAuthenticationData "+\248\172\244T[]\133\179",PropMaximumPacketSize 630,PropSubscriptionIdentifierAvailable +// 228,PropRequestProblemInformation 107,PropContentType "\214\202[\223O\227\225mQV\217\"\172\242",PropServerReference +// "\177\SOo\245\225\a\149R\134v<~\212c\ETB \216m-\"^\182\183B\f\238\136\150\245\170",PropPayloadFormatIndicator +// 31,PropSharedSubscriptionAvailable 120,PropWildcardSubscriptionAvailable 66,PropMessageExpiryInterval +// 25661,PropAssignedClientIdentifier +// "G\SO\206\177\226m\129\171\ACK1\155\236\224\213\236O\232\160\156\190\199J_\244",PropPayloadFormatIndicator +// 166,PropMaximumPacketSize 15157,PropWillDelayInterval 26991,PropAuthenticationMethod ";3"]}), _cleanSession = False, +// _keepAlive = 7983, _connID = "\255\v<\218q\253\223)BQ\136u\236\220\156&\164\".", _properties = [PropReasonString +// "\SI\161\162\224u\185\134\v)\236&\235\168\SIXVY\181\201K\STX",PropServerReference "\160",PropSessionExpiryInterval +// 26008,PropResponseTopic +// "u\DC2\DC1HP\158\175=hw\DEL4\248|\244\DC1+\236J\227sU\247\207\134\ETB",PropPayloadFormatIndicator +// 51,PropWildcardSubscriptionAvailable 153,PropSubscriptionIdentifierAvailable 79,PropSharedSubscriptionAvailable +// 34,PropRequestProblemInformation 127,PropRequestResponseInformation 40]} TEST(Connect5QCTest, Encode13) { - uint8_t pkt[] = {0x10, 0xf6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xa6, 0x39, 0x3e, 0x23, 0x9, 0x0, 0xc, - 0x12, 0xcf, 0x4b, 0x90, 0x8, 0xe8, 0xcd, 0x76, 0xe5, 0x5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f0, 0x75, 0xf8, 0x4c, - 0x0, 0x1a, 0xf, 0x75, 0x7d, 0xe7, 0xeb, 0x37, 0x9d, 0x53, 0xa3, 0xeb, 0x75, 0x9d, 0xce, 0xd7, 0x47, - 0x6e, 0xb4, 0x98, 0x2, 0x8e, 0xe1, 0x96, 0x30, 0xf4, 0x42, 0x30}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x12, 0xcf, 0x4b, 0x90, 0x8, 0xe8, 0xcd, 0x76, 0xe5, 0x5c, 0xb0, 0xda}; - uint8_t bytesprops1[] = {0}; + uint8_t pkt[] = { + 0x10, 0xce, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc4, 0x1f, 0x2f, 0x4a, 0x1f, 0x0, 0x15, 0xf, 0xa1, + 0xa2, 0xe0, 0x75, 0xb9, 0x86, 0xb, 0x29, 0xec, 0x26, 0xeb, 0xa8, 0xf, 0x58, 0x56, 0x59, 0xb5, 0xc9, 0x4b, 0x2, + 0x1c, 0x0, 0x1, 0xa0, 0x11, 0x0, 0x0, 0x65, 0x98, 0x8, 0x0, 0x1a, 0x75, 0x12, 0x11, 0x48, 0x50, 0x9e, 0xaf, + 0x3d, 0x68, 0x77, 0x7f, 0x34, 0xf8, 0x7c, 0xf4, 0x11, 0x2b, 0xec, 0x4a, 0xe3, 0x73, 0x55, 0xf7, 0xcf, 0x86, 0x17, + 0x1, 0x33, 0x28, 0x99, 0x29, 0x4f, 0x2a, 0x22, 0x17, 0x7f, 0x19, 0x28, 0x0, 0x13, 0xff, 0xb, 0x3c, 0xda, 0x71, + 0xfd, 0xdf, 0x29, 0x42, 0x51, 0x88, 0x75, 0xec, 0xdc, 0x9c, 0x26, 0xa4, 0x22, 0x2e, 0xa6, 0x1, 0x16, 0x0, 0x18, + 0xda, 0x15, 0x59, 0xe6, 0xc, 0x3, 0x20, 0xc6, 0xf8, 0xcd, 0x93, 0xfb, 0x10, 0x75, 0xf0, 0x2e,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 0x5c, 0x8b, 0x58, 0xf6, 0x70, 0x1d, 0x55, + 0x51, 0xfc, 0x37, 0xc6, 0xdf, 0x8f, 0x7d, 0xbf, 0xa4, 0x0, 0x3, 0xdd, 0x22, 0xb4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf, 0xa1, 0xa2, 0xe0, 0x75, 0xb9, 0x86, 0xb, 0x29, 0xec, 0x26, + 0xeb, 0xa8, 0xf, 0x58, 0x56, 0x59, 0xb5, 0xc9, 0x4b, 0x2}; + uint8_t bytesprops1[] = {0xa0}; + uint8_t bytesprops2[] = {0x75, 0x12, 0x11, 0x48, 0x50, 0x9e, 0xaf, 0x3d, 0x68, 0x77, 0x7f, 0x34, 0xf8, + 0x7c, 0xf4, 0x11, 0x2b, 0xec, 0x4a, 0xe3, 0x73, 0x55, 0xf7, 0xcf, 0x86, 0x17}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 392}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27867}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21051}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26008}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x19, 0x82, 0xaa, 0x8, 0x85, 0xdb, 0x13, 0x2b, 0xf5, 0x3, 0x92, 0x9e, 0xf1, 0x81, 0x38, - 0xfb, 0xec, 0xe5, 0x34, 0xe5, 0x2, 0x6f, 0x8f, 0xcc, 0xf, 0x65, 0xe8, 0x44, 0x92}; - uint8_t byteswillprops1[] = {0x32, 0x31}; - uint8_t byteswillprops2[] = {0xe6, 0x5, 0x1a, 0x1c, 0xd5, 0x89, 0x72, 0x7, 0x40, 0xfb, 0x45, 0x59, - 0x58, 0xda, 0x3, 0x3e, 0x71, 0x14, 0x52, 0x2f, 0x57, 0x3e, 0xfa}; - uint8_t byteswillprops3[] = {0x67}; - uint8_t byteswillprops4[] = {0x90, 0x6e, 0x4e, 0x12, 0x75, 0xcf, 0x2, 0xc7, 0x44, 0x70, 0x0, 0xa7, 0x7b}; + uint8_t byteswillprops0[] = {0xda, 0x15, 0x59, 0xe6, 0xc, 0x3, 0x20, 0xc6, 0xf8, 0xcd, 0x93, 0xfb, + 0x10, 0x75, 0xf0, 0x2e, 0xc5, 0x28, 0xf3, 0xe3, 0x92, 0x90, 0xda, 0x5f}; + uint8_t byteswillprops1[] = {0x59, 0xd, 0xb7, 0x4e}; + uint8_t byteswillprops2[] = {0x2b, 0xf8, 0xac, 0xf4, 0x54, 0x5b, 0x5d, 0x85, 0xb3}; + uint8_t byteswillprops3[] = {0xd6, 0xca, 0x5b, 0xdf, 0x4f, 0xe3, 0xe1, 0x6d, 0x51, 0x56, 0xd9, 0x22, 0xac, 0xf2}; + uint8_t byteswillprops4[] = {0xb1, 0xe, 0x6f, 0xf5, 0xe1, 0x7, 0x95, 0x52, 0x86, 0x76, + 0x3c, 0x7e, 0xd4, 0x63, 0x17, 0x20, 0xd8, 0x6d, 0x2d, 0x22, + 0x5e, 0xb6, 0xb7, 0x42, 0xc, 0xee, 0x88, 0x96, 0xf5, 0xaa}; + uint8_t byteswillprops5[] = {0x47, 0xe, 0xce, 0xb1, 0xe2, 0x6d, 0x81, 0xab, 0x6, 0x31, 0x9b, 0xec, + 0xe0, 0xd5, 0xec, 0x4f, 0xe8, 0xa0, 0x9c, 0xbe, 0xc7, 0x4a, 0x5f, 0xf4}; + uint8_t byteswillprops6[] = {0x3b, 0x33}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22862}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19734}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15740}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11158}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12811}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 630}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25661}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15157}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26991}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&byteswillprops6}}}, }; - lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xad, 0xb8, 0x44, 0xfa, 0x3c, 0xfc, 0x2c, 0xba, 0x63, 0x92, 0xb2, - 0x54, 0x21, 0x3, 0x6b, 0x4b, 0x52, 0xe, 0x8b, 0xfd, 0x36}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x68, 0x90, 0xe4, 0x26, 0xf9, 0xf0, 0x75, 0xf8, 0x4c}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2f, 0xa1, 0x3, 0xec, 0xae, 0xca, 0x8e, 0x6, 0x5, 0x26, 0xe7, 0xe6, 0x5a, 0x67}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa4, 0x3a, 0x28, 0xc0, 0x44, 0xe0}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14654; - uint8_t client_id_bytes[] = {0x62, 0x21, 0xc7, 0x43, 0x15, 0x38, 0x6d, 0xb7, 0x17, 0xa2, 0xa1, 0x83, - 0xff, 0xc, 0xec, 0xcb, 0xa5, 0xbd, 0x99, 0x8, 0xb, 0x8, 0x6}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 7983; + uint8_t client_id_bytes[] = {0xff, 0xb, 0x3c, 0xda, 0x71, 0xfd, 0xdf, 0x29, 0x42, 0x51, + 0x88, 0x75, 0xec, 0xdc, 0x9c, 0x26, 0xa4, 0x22, 0x2e}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf, 0x75, 0x7d, 0xe7, 0xeb, 0x37, 0x9d, 0x53, 0xa3, 0xeb, 0x75, 0x9d, 0xce, - 0xd7, 0x47, 0x6e, 0xb4, 0x98, 0x2, 0x8e, 0xe1, 0x96, 0x30, 0xf4, 0x42, 0x30}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x68, 0x57, 0x45, 0xa8, 0x5f, 0x4d, 0xbb, 0x2c, 0xd3, 0x82, 0xfb, 0x42, 0xd9, 0x5c, 0x8b, + 0x58, 0xf6, 0x70, 0x1d, 0x55, 0x51, 0xfc, 0x37, 0xc6, 0xdf, 0x8f, 0x7d, 0xbf, 0xa4}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0xdd, 0x22, 0xb4}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8294,249 +8312,233 @@ TEST(Connect5QCTest, Encode13) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "E\233Y!;0\183X\172\237\237\252\&9\t,\DC2\221d^", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\131\ETX\211$\DC4\162\130\183\SUB\187Y\238\196\ETB6", _willMsg = "\242\214\200\\7w\209dKcE\a\130\206\ACKsj\171\t", -// _willProps = [PropReceiveMaximum 18066,PropUserProperty "Y\207\NULV" -// "\ENQ\142]L0b\201\171\252\DC4\\\144|\163\203G\SUBx\214\232\243A\194\213\t]\ACK",PropResponseInformation -// "\207#\156\253i\DLE8\177\250t\234@^\v8J",PropSubscriptionIdentifier 25,PropRequestProblemInformation -// 203,PropSharedSubscriptionAvailable 144,PropRequestResponseInformation 72,PropMaximumQoS 4,PropUserProperty "" -// "\NAK\208\r.\240[\222\CAN\130\234\228\147",PropWildcardSubscriptionAvailable 148,PropWillDelayInterval -// 10395,PropResponseInformation "\SUBE\191V\USE^\222|\217\204'_\204",PropUserProperty -// ";+\t!\232|\186I\138\193u\v~\202\183\228\172s_\174" -// "\254y3\252\STX\152\v_K>\194\192\ENQ\DC1\147^?N(\146~Lo?\159\155",PropUserProperty "" -// "0\194\201X\235\140\248\&1Q\231\205-\180\150\RSDihoD\211\&9\134",PropCorrelationData -// "\236T",PropPayloadFormatIndicator 49,PropRequestResponseInformation 252,PropServerKeepAlive -// 18380,PropWildcardSubscriptionAvailable 130,PropSharedSubscriptionAvailable 94,PropUserProperty -// "=\192x\217w^\130RI!\DEL>Y>C\198\233D\220`\\,!\196\ESC" "v'\179\180\190\161,}I\226\201*\225",PropWillDelayInterval -// 12704,PropPayloadFormatIndicator 191,PropRetainAvailable 29,PropAssignedClientIdentifier -// "\252\"0\167U\250#|",PropPayloadFormatIndicator 132,PropRetainAvailable 176,PropPayloadFormatIndicator -// 247,PropUserProperty ",\156\241\149" "^,\133\158\130$&\SUB\192\236\ENQ0\231\158"]}), _cleanSession = True, _keepAlive -// = 9686, _connID = "\242\&1\174", _properties = [PropAuthenticationMethod -// "u\156Z\244$",PropSharedSubscriptionAvailable 158,PropMessageExpiryInterval 5802,PropUserProperty -// "\207\161\140T\DC4\144N6u$\166\140\214\183\&0;\199\149" -// "\231\222\233\157c\176p\179\128\220#-iA\211\219\SI",PropAuthenticationData -// "[\ACK\211\232\214\FS\140\EOT\DC2\EMp\232",PropMessageExpiryInterval 9094,PropReasonString -// "\139\DC2\"\172\rq\172,^;X\143\167i\226\231\220\ACK\\",PropRetainAvailable 107,PropRequestProblemInformation -// 232,PropMaximumPacketSize 21936,PropServerReference "\141\SO\199\ACK\217\200\235\180"]} +// ConnectRequest {_username = Nothing, _password = Just "I\SI\221-\132?i\130\DC4\231\186", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 15604, _connID = "\246\207\188\170T\240a\203\184x\230X\199\147{8_\SO;\188)", +// _properties = [PropServerReference "\218zK#\138uM",PropServerKeepAlive 3564,PropServerKeepAlive +// 6693,PropResponseTopic "\172\v.\245\225Ll\146\f\240,D\230",PropResponseTopic "",PropWillDelayInterval +// 17189,PropContentType "\147\190Jwf\167\254lJ5\180\168\233\159jG\177o\214o",PropAuthenticationData +// "\211PO\130'\ETB\222\207R\ENQ\f",PropSessionExpiryInterval 54,PropServerKeepAlive 12425,PropServerReference +// "\ACK\222S\204\DC1\141\SO\SI\rV\232\DLE\220&M?\208m\128\192",PropRetainAvailable 171,PropSubscriptionIdentifier +// 10,PropResponseInformation "U\DC2E\145\130\227\240",PropReasonString +// "C\t\DC4\NUL\196\250\218\173\SI\235\233\206)\239\&7\197\170()\157\237\176O\179;\253f\166\a",PropSubscriptionIdentifierAvailable +// 138,PropReasonString "\225\241\222Y\n\234\245\250\252S=\ESC}",PropSharedSubscriptionAvailable 14,PropServerKeepAlive +// 12324,PropMaximumQoS 12,PropMaximumPacketSize 10973,PropMaximumQoS 38,PropWillDelayInterval 7796,PropRetainAvailable +// 21,PropRetainAvailable 93,PropAuthenticationData +// "\199\245\198\230b\156\163I\SYN2\226\ENQ\154u\218\242\206\240\217\160X\254\198",PropSessionExpiryInterval +// 6316,PropServerKeepAlive 2977,PropSharedSubscriptionAvailable 210]} TEST(Connect5QCTest, Encode14) { uint8_t pkt[] = { - 0x10, 0xea, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x66, 0x25, 0xd6, 0x75, 0x15, 0x0, 0x5, 0x75, 0x9c, - 0x5a, 0xf4, 0x24, 0x2a, 0x9e, 0x2, 0x0, 0x0, 0x16, 0xaa, 0x26, 0x0, 0x12, 0xcf, 0xa1, 0x8c, 0x54, 0x14, 0x90, - 0x4e, 0x36, 0x75, 0x24, 0xa6, 0x8c, 0xd6, 0xb7, 0x30, 0x3b, 0xc7, 0x95, 0x0, 0x11, 0xe7, 0xde, 0xe9, 0x9d, 0x63, - 0xb0, 0x70, 0xb3, 0x80, 0xdc, 0x23, 0x2d, 0x69, 0x41, 0xd3, 0xdb, 0xf, 0x16, 0x0, 0xc, 0x5b, 0x6, 0xd3, 0xe8, - 0xd6, 0x1c, 0x8c, 0x4, 0x12, 0x19, 0x70, 0xe8, 0x2, 0x0, 0x0, 0x23, 0x86, 0x1f, 0x0, 0x13, 0x8b, 0x12, 0x22, - 0xac, 0xd, 0x71, 0xac, 0x2c, 0x5e, 0x3b, 0x58, 0x8f, 0xa7, 0x69, 0xe2, 0xe7, 0xdc, 0x6, 0x5c, 0x25, 0x6b, 0x17, - 0xe8, 0x27, 0x0, 0x0, 0x55, 0xb0, 0x1c, 0x0, 0x8, 0x8d, 0xe, 0xc7, 0x6, 0xd9, 0xc8, 0xeb, 0xb4, 0x0, 0x3, - 0xf2, 0x31, 0xae, 0xa8, 0x2, 0x21, 0x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, 0x9, 0x0, 0x2, 0xec, 0x54, 0x1, 0x31, 0x19, 0xfc, 0x13, 0x47, 0xcc, 0x28, 0x82, 0x2a, 0x5e, - 0x26, 0x0, 0x19, 0x3d, 0xc0, 0x78, 0xd9, 0x77, 0x5e, 0x82, 0x52, 0x49, 0x21, 0x7f, 0x3e, 0x59, 0x3e, 0x43, 0xc6, - 0xe9, 0x44, 0xdc, 0x60, 0x5c, 0x2c, 0x21, 0xc4, 0x1b, 0x0, 0xd, 0x76, 0x27, 0xb3, 0xb4, 0xbe, 0xa1, 0x2c, 0x7d, - 0x49, 0xe2, 0xc9, 0x2a, 0xe1, 0x18, 0x0, 0x0, 0x31, 0xa0, 0x1, 0xbf, 0x25, 0x1d, 0x12, 0x0, 0x8, 0xfc, 0x22, - 0x30, 0xa7, 0x55, 0xfa, 0x23, 0x7c, 0x1, 0x84, 0x25, 0xb0, 0x1, 0xf7, 0x26, 0x0, 0x4, 0x2c, 0x9c, 0xf1, 0x95, - 0x0, 0xe, 0x5e, 0x2c, 0x85, 0x9e, 0x82, 0x24, 0x26, 0x1a, 0xc0, 0xec, 0x5, 0x30, 0xe7, 0x9e, 0x0, 0xf, 0x83, - 0x3, 0xd3, 0x24, 0x14, 0xa2, 0x82, 0xb7, 0x1a, 0xbb, 0x59, 0xee, 0xc4, 0x17, 0x36, 0x0, 0x13, 0xf2, 0xd6, 0xc8, - 0x5c, 0x37, 0x77, 0xd1, 0x64, 0x4b, 0x63, 0x45, 0x7, 0x82, 0xce, 0x6, 0x73, 0x6a, 0xab, 0x9, 0x0, 0x13, 0x45, - 0xe9, 0x59, 0x21, 0x3b, 0x30, 0xb7, 0x58, 0xac, 0xed, 0xed, 0xfc, 0x39, 0x9, 0x2c, 0x12, 0xdd, 0x64, 0x5e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x75, 0x9c, 0x5a, 0xf4, 0x24}; - uint8_t bytesprops2[] = {0xe7, 0xde, 0xe9, 0x9d, 0x63, 0xb0, 0x70, 0xb3, 0x80, - 0xdc, 0x23, 0x2d, 0x69, 0x41, 0xd3, 0xdb, 0xf}; - uint8_t bytesprops1[] = {0xcf, 0xa1, 0x8c, 0x54, 0x14, 0x90, 0x4e, 0x36, 0x75, - 0x24, 0xa6, 0x8c, 0xd6, 0xb7, 0x30, 0x3b, 0xc7, 0x95}; - uint8_t bytesprops3[] = {0x5b, 0x6, 0xd3, 0xe8, 0xd6, 0x1c, 0x8c, 0x4, 0x12, 0x19, 0x70, 0xe8}; - uint8_t bytesprops4[] = {0x8b, 0x12, 0x22, 0xac, 0xd, 0x71, 0xac, 0x2c, 0x5e, 0x3b, - 0x58, 0x8f, 0xa7, 0x69, 0xe2, 0xe7, 0xdc, 0x6, 0x5c}; - uint8_t bytesprops5[] = {0x8d, 0xe, 0xc7, 0x6, 0xd9, 0xc8, 0xeb, 0xb4}; + 0x10, 0x97, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x40, 0x3c, 0xf4, 0xe7, 0x1, 0x1c, 0x0, 0x7, 0xda, + 0x7a, 0x4b, 0x23, 0x8a, 0x75, 0x4d, 0x13, 0xd, 0xec, 0x13, 0x1a, 0x25, 0x8, 0x0, 0xd, 0xac, 0xb, 0x2e, 0xf5, + 0xe1, 0x4c, 0x6c, 0x92, 0xc, 0xf0, 0x2c, 0x44, 0xe6, 0x8, 0x0, 0x0, 0x18, 0x0, 0x0, 0x43, 0x25, 0x3, 0x0, + 0x14, 0x93, 0xbe, 0x4a, 0x77, 0x66, 0xa7, 0xfe, 0x6c, 0x4a, 0x35, 0xb4, 0xa8, 0xe9, 0x9f, 0x6a, 0x47, 0xb1, 0x6f, + 0xd6, 0x6f, 0x16, 0x0, 0xb, 0xd3, 0x50, 0x4f, 0x82, 0x27, 0x17, 0xde, 0xcf, 0x52, 0x5, 0xc, 0x11, 0x0, 0x0, + 0x0, 0x36, 0x13, 0x30, 0x89, 0x1c, 0x0, 0x14, 0x6, 0xde, 0x53, 0xcc, 0x11, 0x8d, 0xe, 0xf, 0xd, 0x56, 0xe8, + 0x10, 0xdc, 0x26, 0x4d, 0x3f, 0xd0, 0x6d, 0x80, 0xc0, 0x25, 0xab, 0xb, 0xa, 0x1a, 0x0, 0x7, 0x55, 0x12, 0x45, + 0x91, 0x82, 0xe3, 0xf0, 0x1f, 0x0, 0x1d, 0x43, 0x9, 0x14, 0x0, 0xc4, 0xfa, 0xda, 0xad, 0xf, 0xeb, 0xe9, 0xce, + 0x29, 0xef, 0x37, 0xc5, 0xaa, 0x28, 0x29, 0x9d, 0xed, 0xb0, 0x4f, 0xb3, 0x3b, 0xfd, 0x66, 0xa6, 0x7, 0x29, 0x8a, + 0x1f, 0x0, 0xd, 0xe1, 0xf1, 0xde, 0x59, 0xa, 0xea, 0xf5, 0xfa, 0xfc, 0x53, 0x3d, 0x1b, 0x7d, 0x2a, 0xe, 0x13, + 0x30, 0x24, 0x24, 0xc, 0x27, 0x0, 0x0, 0x2a, 0xdd, 0x24, 0x26, 0x18, 0x0, 0x0, 0x1e, 0x74, 0x25, 0x15, 0x25, + 0x5d, 0x16, 0x0, 0x17, 0xc7, 0xf5, 0xc6, 0xe6, 0x62, 0x9c, 0xa3, 0x49, 0x16, 0x32, 0xe2, 0x5, 0x9a, 0x75, 0xda, + 0xf2, 0xce, 0xf0, 0xd9, 0xa0, 0x58, 0xfe, 0xc6, 0x11, 0x0, 0x0, 0x18, 0xac, 0x13, 0xb, 0xa1, 0x2a, 0xd2, 0x0, + 0x15, 0xf6, 0xcf, 0xbc, 0xaa, 0x54, 0xf0, 0x61, 0xcb, 0xb8, 0x78, 0xe6, 0x58, 0xc7, 0x93, 0x7b, 0x38, 0x5f, 0xe, + 0x3b, 0xbc, 0x29, 0x0, 0xb, 0x49, 0xf, 0xdd, 0x2d, 0x84, 0x3f, 0x69, 0x82, 0x14, 0xe7, 0xba}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xda, 0x7a, 0x4b, 0x23, 0x8a, 0x75, 0x4d}; + uint8_t bytesprops1[] = {0xac, 0xb, 0x2e, 0xf5, 0xe1, 0x4c, 0x6c, 0x92, 0xc, 0xf0, 0x2c, 0x44, 0xe6}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x93, 0xbe, 0x4a, 0x77, 0x66, 0xa7, 0xfe, 0x6c, 0x4a, 0x35, + 0xb4, 0xa8, 0xe9, 0x9f, 0x6a, 0x47, 0xb1, 0x6f, 0xd6, 0x6f}; + uint8_t bytesprops4[] = {0xd3, 0x50, 0x4f, 0x82, 0x27, 0x17, 0xde, 0xcf, 0x52, 0x5, 0xc}; + uint8_t bytesprops5[] = {0x6, 0xde, 0x53, 0xcc, 0x11, 0x8d, 0xe, 0xf, 0xd, 0x56, + 0xe8, 0x10, 0xdc, 0x26, 0x4d, 0x3f, 0xd0, 0x6d, 0x80, 0xc0}; + uint8_t bytesprops6[] = {0x55, 0x12, 0x45, 0x91, 0x82, 0xe3, 0xf0}; + uint8_t bytesprops7[] = {0x43, 0x9, 0x14, 0x0, 0xc4, 0xfa, 0xda, 0xad, 0xf, 0xeb, 0xe9, 0xce, 0x29, 0xef, 0x37, + 0xc5, 0xaa, 0x28, 0x29, 0x9d, 0xed, 0xb0, 0x4f, 0xb3, 0x3b, 0xfd, 0x66, 0xa6, 0x7}; + uint8_t bytesprops8[] = {0xe1, 0xf1, 0xde, 0x59, 0xa, 0xea, 0xf5, 0xfa, 0xfc, 0x53, 0x3d, 0x1b, 0x7d}; + uint8_t bytesprops9[] = {0xc7, 0xf5, 0xc6, 0xe6, 0x62, 0x9c, 0xa3, 0x49, 0x16, 0x32, 0xe2, 0x5, + 0x9a, 0x75, 0xda, 0xf2, 0xce, 0xf0, 0xd9, 0xa0, 0x58, 0xfe, 0xc6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5802}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {17, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9094}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21936}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3564}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6693}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17189}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 54}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12425}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12324}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10973}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7796}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6316}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2977}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x5, 0x8e, 0x5d, 0x4c, 0x30, 0x62, 0xc9, 0xab, 0xfc, 0x14, 0x5c, 0x90, 0x7c, 0xa3, - 0xcb, 0x47, 0x1a, 0x78, 0xd6, 0xe8, 0xf3, 0x41, 0xc2, 0xd5, 0x9, 0x5d, 0x6}; - uint8_t byteswillprops0[] = {0x59, 0xcf, 0x0, 0x56}; - uint8_t byteswillprops2[] = {0xcf, 0x23, 0x9c, 0xfd, 0x69, 0x10, 0x38, 0xb1, - 0xfa, 0x74, 0xea, 0x40, 0x5e, 0xb, 0x38, 0x4a}; - uint8_t byteswillprops4[] = {0x15, 0xd0, 0xd, 0x2e, 0xf0, 0x5b, 0xde, 0x18, 0x82, 0xea, 0xe4, 0x93}; - uint8_t byteswillprops3[] = {0}; - uint8_t byteswillprops5[] = {0x1a, 0x45, 0xbf, 0x56, 0x1f, 0x45, 0x5e, 0xde, 0x7c, 0xd9, 0xcc, 0x27, 0x5f, 0xcc}; - uint8_t byteswillprops7[] = {0xfe, 0x79, 0x33, 0xfc, 0x2, 0x98, 0xb, 0x5f, 0x4b, 0x3e, 0xc2, 0xc0, 0x5, - 0x11, 0x93, 0x5e, 0x3f, 0x4e, 0x28, 0x92, 0x7e, 0x4c, 0x6f, 0x3f, 0x9f, 0x9b}; - uint8_t byteswillprops6[] = {0x3b, 0x2b, 0x9, 0x21, 0xe8, 0x7c, 0xba, 0x49, 0x8a, 0xc1, - 0x75, 0xb, 0x7e, 0xca, 0xb7, 0xe4, 0xac, 0x73, 0x5f, 0xae}; - uint8_t byteswillprops9[] = {0x30, 0xc2, 0xc9, 0x58, 0xeb, 0x8c, 0xf8, 0x31, 0x51, 0xe7, 0xcd, 0x2d, - 0xb4, 0x96, 0x1e, 0x44, 0x69, 0x68, 0x6f, 0x44, 0xd3, 0x39, 0x86}; - uint8_t byteswillprops8[] = {0}; - uint8_t byteswillprops10[] = {0xec, 0x54}; - uint8_t byteswillprops12[] = {0x76, 0x27, 0xb3, 0xb4, 0xbe, 0xa1, 0x2c, 0x7d, 0x49, 0xe2, 0xc9, 0x2a, 0xe1}; - uint8_t byteswillprops11[] = {0x3d, 0xc0, 0x78, 0xd9, 0x77, 0x5e, 0x82, 0x52, 0x49, 0x21, 0x7f, 0x3e, 0x59, - 0x3e, 0x43, 0xc6, 0xe9, 0x44, 0xdc, 0x60, 0x5c, 0x2c, 0x21, 0xc4, 0x1b}; - uint8_t byteswillprops13[] = {0xfc, 0x22, 0x30, 0xa7, 0x55, 0xfa, 0x23, 0x7c}; - uint8_t byteswillprops15[] = {0x5e, 0x2c, 0x85, 0x9e, 0x82, 0x24, 0x26, 0x1a, 0xc0, 0xec, 0x5, 0x30, 0xe7, 0x9e}; - uint8_t byteswillprops14[] = {0x2c, 0x9c, 0xf1, 0x95}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18066}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {4, (char*)&byteswillprops0}, .v = {27, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {0, (char*)&byteswillprops3}, .v = {12, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10395}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {20, (char*)&byteswillprops6}, .v = {26, (char*)&byteswillprops7}}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {0, (char*)&byteswillprops8}, .v = {23, (char*)&byteswillprops9}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18380}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {25, (char*)&byteswillprops11}, .v = {13, (char*)&byteswillprops12}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12704}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&byteswillprops13}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {4, (char*)&byteswillprops14}, .v = {14, (char*)&byteswillprops15}}}}, - }; - - lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x83, 0x3, 0xd3, 0x24, 0x14, 0xa2, 0x82, 0xb7, - 0x1a, 0xbb, 0x59, 0xee, 0xc4, 0x17, 0x36}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf2, 0xd6, 0xc8, 0x5c, 0x37, 0x77, 0xd1, 0x64, 0x4b, 0x63, - 0x45, 0x7, 0x82, 0xce, 0x6, 0x73, 0x6a, 0xab, 0x9}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 9686; - uint8_t client_id_bytes[] = {0xf2, 0x31, 0xae}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 15604; + uint8_t client_id_bytes[] = {0xf6, 0xcf, 0xbc, 0xaa, 0x54, 0xf0, 0x61, 0xcb, 0xb8, 0x78, 0xe6, + 0x58, 0xc7, 0x93, 0x7b, 0x38, 0x5f, 0xe, 0x3b, 0xbc, 0x29}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x45, 0xe9, 0x59, 0x21, 0x3b, 0x30, 0xb7, 0x58, 0xac, 0xed, - 0xed, 0xfc, 0x39, 0x9, 0x2c, 0x12, 0xdd, 0x64, 0x5e}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x49, 0xf, 0xdd, 0x2d, 0x84, 0x3f, 0x69, 0x82, 0x14, 0xe7, 0xba}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\133\RS\ACKX^\249Y\190\f(u\241", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "-\244b\239\\\168\251\255\247\DC2\234\150\&8\242", _willMsg = -// "\GS\ACK\135\190\RS\238", _willProps = [PropRequestProblemInformation 243,PropSubscriptionIdentifier -// 24,PropTopicAliasMaximum 6842,PropMaximumQoS 95,PropMessageExpiryInterval 14927,PropSubscriptionIdentifierAvailable -// 207,PropPayloadFormatIndicator 188,PropTopicAlias 11781,PropContentType "U",PropMaximumPacketSize -// 5789,PropSessionExpiryInterval 9783,PropWillDelayInterval 17824,PropMessageExpiryInterval -// 26925,PropSubscriptionIdentifierAvailable 181,PropRequestProblemInformation 37,PropResponseTopic -// "\f\157\146Ws\NAK,\252\224\145\144\225<\139\187:\180",PropSharedSubscriptionAvailable 145,PropWillDelayInterval -// 2760,PropTopicAlias 11910,PropSharedSubscriptionAvailable 103,PropReceiveMaximum 13404,PropRequestProblemInformation -// 3,PropWildcardSubscriptionAvailable 148,PropRequestProblemInformation 158,PropWillDelayInterval 18830]}), -// _cleanSession = True, _keepAlive = 7105, _connID = "xW\GSn\170\158vUz\227\172\SI\145Z2\174\&2\235G\137\154\141F\204", -// _properties = [PropWildcardSubscriptionAvailable 213,PropTopicAliasMaximum 9089,PropTopicAlias 10175]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "Y4l\EOT[\245\243\233\211\199c\CANhx\DC4\190g\175\RS\147\191'\223\137<6", _willMsg = +// "\139|6\245\194\246\236j", _willProps = [PropSessionExpiryInterval 28956,PropTopicAliasMaximum 4577,PropContentType +// "\176\ETX\161\157\200\&4\v^\187\219W5\188[\227\135\128\176\207Cn\"d\236<5\149",PropRequestProblemInformation +// 102,PropResponseInformation "\"\255Z\199r\DLE\132\FS",PropReceiveMaximum 7492,PropAuthenticationMethod +// "o\242\129\170\251\156\\\177\220\238H",PropMaximumPacketSize 1156,PropUserProperty +// "\233^\206P\t\230\215\a_pj\181v\\\164\139\&6\188\203\145\238\233\141\198b\253\206?" +// "\224\161\SUBW\241\184U\252\227\154\SO3\248\140\&3\142\"\187\&4\246\208+2\222TO&u",PropRequestProblemInformation +// 225,PropMaximumQoS 219,PropCorrelationData +// "7mk\"\176\248\240\ACK\205V*\195To\167\187\233\241\162\226|\236",PropMaximumQoS 150,PropWillDelayInterval +// 16062,PropUserProperty "\208\245" "4\128D2K",PropWillDelayInterval 28121,PropWillDelayInterval 3146,PropReasonString +// "\128\DELd\150%Ab\ESC5Y\172*p\212",PropSubscriptionIdentifier 1,PropMessageExpiryInterval 2118]}), _cleanSession = +// True, _keepAlive = 1098, _connID = "\242\250\148C\fX\219\222", _properties = [PropCorrelationData +// "\138\205\206[H\228\194\DC2\177\142\144\248j",PropWillDelayInterval 30821,PropServerKeepAlive +// 14707,PropWildcardSubscriptionAvailable 164,PropPayloadFormatIndicator 50,PropTopicAlias 88,PropResponseTopic +// "\224v\RS\171*[&\184\240*\164\217.\203\170\160J)\241\131",PropRetainAvailable 90,PropResponseInformation +// "\160\238*\184\169^\254\148\137\229\&3,D\f\SOH",PropRetainAvailable 38,PropAuthenticationData +// "\134\211d\157\t\162\\\202\183\EOT\204\165\136X\228\t=\160w\152\186\SUB\209_-J\221\184\&3\240",PropMaximumPacketSize +// 26252,PropAuthenticationData +// "\197\CAN\EMD\205N\ACK\215\191\249\236\v\249\159\253\DC4\SUB\225cS+\161",PropMaximumPacketSize +// 17119,PropAuthenticationMethod "\173\247\CAN!\219\251\SO\202\185\152u\158M.`Y\161\228\147\142.\200\180\240]\229\160\ETX\171\215B\199\214\&4\ETB",PropAssignedClientIdentifier "Re -// \SO?R",PropSessionExpiryInterval 14304,PropMessageExpiryInterval 23156,PropReasonString "D\"V"]} +// ConnectRequest {_username = Just +// "\DC3\243\159\217u&\163Y\NAKhh\155\169\&4\142\166\213k\248t\130\212\216\DC3\173\140\DLE\DC4R:", _password = Just +// "&m\142x\192", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "\146\238\tq\148_\147\ENQ", _willMsg = "\251", _willProps = [PropReceiveMaximum 7576,PropReasonString +// "\nI~:\143\185i\147\&7\193t\231\156\244@\255\144\192\177P;*\253\161\131\156H\164",PropRetainAvailable +// 43,PropTopicAliasMaximum 27423,PropAuthenticationData +// "\212\EOT\CAN\188\251\142\180\b\NAK\219=\239\157\166J\SI\n\144",PropPayloadFormatIndicator +// 144,PropRequestProblemInformation 99,PropRequestProblemInformation 234]}), _cleanSession = True, _keepAlive = 25890, +// _connID = "\r\156\147\220\152hj\136^\SUB\177\ETX>i", _properties = [PropAuthenticationData +// "\240\143\228\249\190=\241\216!o%E\NUL\128\240",PropReceiveMaximum 23280,PropResponseInformation +// "\191\DELF\142U\209`",PropReasonString +// "S\254\128C\166:z\176#@\231#B\195\240\201r\216\DC3\184\210{\184n\EM\176\nO",PropMessageExpiryInterval +// 24863,PropTopicAlias 28084,PropPayloadFormatIndicator 198,PropCorrelationData +// "[3\254^;\131\231\132\182\151\195l\180X2\220&\231\137DQ\168",PropSharedSubscriptionAvailable 224]} TEST(Connect5QCTest, Encode16) { - uint8_t pkt[] = {0x10, 0x92, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x6c, 0x45, 0x66, 0x12, 0x0, 0x8, - 0xe5, 0x87, 0xb2, 0x1e, 0xc9, 0x37, 0x1f, 0xb4, 0x13, 0x10, 0x5e, 0x25, 0xe7, 0x18, 0x0, 0x0, 0x7b, - 0x8e, 0x27, 0x0, 0x0, 0x63, 0x5f, 0x1c, 0x0, 0x11, 0xea, 0x4c, 0xcd, 0x7f, 0x7e, 0x65, 0x64, 0xe1, - 0x5c, 0x86, 0x35, 0x35, 0x4d, 0x31, 0xbb, 0xee, 0x7f, 0x28, 0x52, 0x28, 0x14, 0x1c, 0x0, 0x18, 0xfc, - 0x3, 0x4, 0x70, 0x4d, 0x3e, 0xe4, 0x93, 0x8e, 0x2e, 0xc8, 0xb4, 0xf0, 0x5d, 0xe5, 0xa0, 0x3, 0xab, - 0xd7, 0x42, 0xc7, 0xd6, 0x34, 0x17, 0x12, 0x0, 0x6, 0x52, 0x65, 0x20, 0xe, 0x3f, 0x52, 0x11, 0x0, - 0x0, 0x37, 0xe0, 0x2, 0x0, 0x0, 0x5a, 0x74, 0x1f, 0x0, 0x3, 0x44, 0x22, 0x56, 0x0, 0x0, 0x0, - 0x7, 0xb2, 0xdd, 0xf8, 0x43, 0x8b, 0x38, 0x46, 0x0, 0x14, 0x5f, 0x18, 0xd0, 0x77, 0xef, 0xa, 0x1c, - 0x2a, 0xa8, 0x2a, 0x55, 0x1f, 0x11, 0x92, 0x3, 0x96, 0x12, 0xe, 0xf4, 0x45}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe5, 0x87, 0xb2, 0x1e, 0xc9, 0x37, 0x1f, 0xb4}; - uint8_t bytesprops1[] = {0xea, 0x4c, 0xcd, 0x7f, 0x7e, 0x65, 0x64, 0xe1, 0x5c, - 0x86, 0x35, 0x35, 0x4d, 0x31, 0xbb, 0xee, 0x7f}; - uint8_t bytesprops2[] = {0xfc, 0x3, 0x4, 0x70, 0x4d, 0x3e, 0xe4, 0x93, 0x8e, 0x2e, 0xc8, 0xb4, - 0xf0, 0x5d, 0xe5, 0xa0, 0x3, 0xab, 0xd7, 0x42, 0xc7, 0xd6, 0x34, 0x17}; - uint8_t bytesprops3[] = {0x52, 0x65, 0x20, 0xe, 0x3f, 0x52}; - uint8_t bytesprops4[] = {0x44, 0x22, 0x56}; + uint8_t pkt[] = {0x10, 0xf5, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x65, 0x22, 0x63, 0x16, 0x0, 0xf, + 0xf0, 0x8f, 0xe4, 0xf9, 0xbe, 0x3d, 0xf1, 0xd8, 0x21, 0x6f, 0x25, 0x45, 0x0, 0x80, 0xf0, 0x21, 0x5a, + 0xf0, 0x1a, 0x0, 0x7, 0xbf, 0x7f, 0x46, 0x8e, 0x55, 0xd1, 0x60, 0x1f, 0x0, 0x1c, 0x53, 0xfe, 0x80, + 0x43, 0xa6, 0x3a, 0x7a, 0xb0, 0x23, 0x40, 0xe7, 0x23, 0x42, 0xc3, 0xf0, 0xc9, 0x72, 0xd8, 0x13, 0xb8, + 0xd2, 0x7b, 0xb8, 0x6e, 0x19, 0xb0, 0xa, 0x4f, 0x2, 0x0, 0x0, 0x61, 0x1f, 0x23, 0x6d, 0xb4, 0x1, + 0xc6, 0x9, 0x0, 0x16, 0x5b, 0x33, 0xfe, 0x5e, 0x3b, 0x83, 0xe7, 0x84, 0xb6, 0x97, 0xc3, 0x6c, 0xb4, + 0x58, 0x32, 0xdc, 0x26, 0xe7, 0x89, 0x44, 0x51, 0xa8, 0x2a, 0xe0, 0x0, 0xe, 0xd, 0x9c, 0x93, 0xdc, + 0x98, 0x68, 0x6a, 0x88, 0x5e, 0x1a, 0xb1, 0x3, 0x3e, 0x69, 0x42, 0x21, 0x1d, 0x98, 0x1f, 0x0, 0x1c, + 0xa, 0x49, 0x7e, 0x3a, 0x8f, 0xb9, 0x69, 0x93, 0x37, 0xc1, 0x74, 0xe7, 0x9c, 0xf4, 0x40, 0xff, 0x90, + 0xc0, 0xb1, 0x50, 0x3b, 0x2a, 0xfd, 0xa1, 0x83, 0x9c, 0x48, 0xa4, 0x25, 0x2b, 0x22, 0x6b, 0x1f, 0x16, + 0x0, 0x12, 0xd4, 0x4, 0x18, 0xbc, 0xfb, 0x8e, 0xb4, 0x8, 0x15, 0xdb, 0x3d, 0xef, 0x9d, 0xa6, 0x4a, + 0xf, 0xa, 0x90, 0x1, 0x90, 0x17, 0x63, 0x17, 0xea, 0x0, 0x8, 0x92, 0xee, 0x9, 0x71, 0x94, 0x5f, + 0x93, 0x5, 0x0, 0x1, 0xfb, 0x0, 0x1e, 0x13, 0xf3, 0x9f, 0xd9, 0x75, 0x26, 0xa3, 0x59, 0x15, 0x68, + 0x68, 0x9b, 0xa9, 0x34, 0x8e, 0xa6, 0xd5, 0x6b, 0xf8, 0x74, 0x82, 0xd4, 0xd8, 0x13, 0xad, 0x8c, 0x10, + 0x14, 0x52, 0x3a, 0x0, 0x5, 0x26, 0x6d, 0x8e, 0x78, 0xc0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf0, 0x8f, 0xe4, 0xf9, 0xbe, 0x3d, 0xf1, 0xd8, 0x21, 0x6f, 0x25, 0x45, 0x0, 0x80, 0xf0}; + uint8_t bytesprops1[] = {0xbf, 0x7f, 0x46, 0x8e, 0x55, 0xd1, 0x60}; + uint8_t bytesprops2[] = {0x53, 0xfe, 0x80, 0x43, 0xa6, 0x3a, 0x7a, 0xb0, 0x23, 0x40, 0xe7, 0x23, 0x42, 0xc3, + 0xf0, 0xc9, 0x72, 0xd8, 0x13, 0xb8, 0xd2, 0x7b, 0xb8, 0x6e, 0x19, 0xb0, 0xa, 0x4f}; + uint8_t bytesprops3[] = {0x5b, 0x33, 0xfe, 0x5e, 0x3b, 0x83, 0xe7, 0x84, 0xb6, 0x97, 0xc3, + 0x6c, 0xb4, 0x58, 0x32, 0xdc, 0x26, 0xe7, 0x89, 0x44, 0x51, 0xa8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4190}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31630}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25439}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14304}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23156}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23280}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24863}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28084}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 224}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xa, 0x49, 0x7e, 0x3a, 0x8f, 0xb9, 0x69, 0x93, 0x37, 0xc1, 0x74, 0xe7, 0x9c, 0xf4, + 0x40, 0xff, 0x90, 0xc0, 0xb1, 0x50, 0x3b, 0x2a, 0xfd, 0xa1, 0x83, 0x9c, 0x48, 0xa4}; + uint8_t byteswillprops1[] = {0xd4, 0x4, 0x18, 0xbc, 0xfb, 0x8e, 0xb4, 0x8, 0x15, + 0xdb, 0x3d, 0xef, 0x9d, 0xa6, 0x4a, 0xf, 0xa, 0x90}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7576}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27423}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, + }; + + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x92, 0xee, 0x9, 0x71, 0x94, 0x5f, 0x93, 0x5}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfb}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 27717; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 25890; + uint8_t client_id_bytes[] = {0xd, 0x9c, 0x93, 0xdc, 0x98, 0x68, 0x6a, 0x88, 0x5e, 0x1a, 0xb1, 0x3, 0x3e, 0x69}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb2, 0xdd, 0xf8, 0x43, 0x8b, 0x38, 0x46}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x13, 0xf3, 0x9f, 0xd9, 0x75, 0x26, 0xa3, 0x59, 0x15, 0x68, 0x68, 0x9b, 0xa9, 0x34, 0x8e, + 0xa6, 0xd5, 0x6b, 0xf8, 0x74, 0x82, 0xd4, 0xd8, 0x13, 0xad, 0x8c, 0x10, 0x14, 0x52, 0x3a}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x5f, 0x18, 0xd0, 0x77, 0xef, 0xa, 0x1c, 0x2a, 0xa8, 0x2a, - 0x55, 0x1f, 0x11, 0x92, 0x3, 0x96, 0x12, 0xe, 0xf4, 0x45}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x26, 0x6d, 0x8e, 0x78, 0xc0}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "J\158\167\177\&3=j\176\214\201\193\&6w\169}", _password = Just -// "aA\246Ml\170b\195\217\197\232\210\143/A\222\200\147", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 16521, _connID = "\186\RS\SYN\164\190\223\&0\237:(\242m\129\163\SIz\146x~R\202Dc\184\223\169\230\163", _properties = -// [PropServerReference "\149lz\STX3{]\194\249\&1\172\212E",PropAuthenticationData -// "L\233\DC4J\185\158\173Gc\237\184\206\140y\177\129\247\183bt\237~\236\207Z\236",PropCorrelationData -// "\151\191\170`\224\218\213\230+\253\204S21l", _password = Just "\208`1MG\177\a\230\254", +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 24689, _connID = +// "\215'G$\ESCg\194\223\191:\ETX\166\139\193n\180\156\140\165\209\206\tj\241\ETB\237\210\212Jt", _properties = +// [PropAuthenticationMethod "\150\184\NUL\NUL\a@"]} TEST(Connect5QCTest, Encode17) { - uint8_t pkt[] = {0x10, 0xea, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x40, 0x89, 0x9b, 0x1, 0x1c, 0x0, - 0xd, 0x95, 0x6c, 0x7a, 0x2, 0x33, 0x7b, 0x5d, 0xc2, 0xf9, 0x31, 0xac, 0xd4, 0x45, 0x16, 0x0, 0x1a, - 0x4c, 0xe9, 0x14, 0x4a, 0xb9, 0x9e, 0xad, 0x47, 0x63, 0xed, 0xb8, 0xce, 0x8c, 0x79, 0xb1, 0x81, 0xf7, - 0xb7, 0x62, 0x74, 0xed, 0x7e, 0xec, 0xcf, 0x5a, 0xec, 0x9, 0x0, 0x1e, 0x97, 0xbf, 0xaa, 0x60, 0x3c, - 0x4a, 0x68, 0xc8, 0x3, 0xb1, 0x9, 0x7f, 0xf4, 0x9d, 0xd9, 0x13, 0x4, 0xcc, 0x86, 0x5a, 0xa9, 0x28, - 0x20, 0x5c, 0x2, 0xc8, 0x67, 0x6, 0xe9, 0x28, 0x2, 0x0, 0x0, 0x18, 0x7, 0x2, 0x0, 0x0, 0x79, - 0x4c, 0xb, 0x13, 0x13, 0x59, 0x7, 0x17, 0x6d, 0x8, 0x0, 0xd, 0xfe, 0x38, 0x8e, 0x57, 0x26, 0xfd, - 0xc8, 0xe7, 0xca, 0xbc, 0x46, 0x44, 0x42, 0x2, 0x0, 0x0, 0x15, 0x76, 0x9, 0x0, 0x18, 0x48, 0x20, - 0x6b, 0xef, 0xf7, 0x75, 0x80, 0x36, 0xc0, 0x2e, 0x3d, 0x76, 0x3a, 0x95, 0x75, 0x8b, 0x5f, 0xec, 0xef, - 0x9c, 0x1e, 0x39, 0xf9, 0x86, 0x2, 0x0, 0x0, 0x71, 0x67, 0x9, 0x0, 0x4, 0xc7, 0x35, 0xa5, 0x89, - 0x0, 0x1c, 0xba, 0x1e, 0x16, 0xa4, 0xbe, 0xdf, 0x30, 0xed, 0x3a, 0x28, 0xf2, 0x6d, 0x81, 0xa3, 0xf, - 0x7a, 0x92, 0x78, 0x7e, 0x52, 0xca, 0x44, 0x63, 0xb8, 0xdf, 0xa9, 0xe6, 0xa3, 0x0, 0xf, 0x4a, 0x9e, - 0xa7, 0xb1, 0x33, 0x3d, 0x6a, 0xb0, 0xd6, 0xc9, 0xc1, 0x36, 0x77, 0xa9, 0x7d, 0x0, 0x12, 0x61, 0x41, - 0xf6, 0x4d, 0x6c, 0xaa, 0x62, 0xc3, 0xd9, 0xc5, 0xe8, 0xd2, 0x8f, 0x2f, 0x41, 0xde, 0xc8, 0x93}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x95, 0x6c, 0x7a, 0x2, 0x33, 0x7b, 0x5d, 0xc2, 0xf9, 0x31, 0xac, 0xd4, 0x45}; - uint8_t bytesprops1[] = {0x4c, 0xe9, 0x14, 0x4a, 0xb9, 0x9e, 0xad, 0x47, 0x63, 0xed, 0xb8, 0xce, 0x8c, - 0x79, 0xb1, 0x81, 0xf7, 0xb7, 0x62, 0x74, 0xed, 0x7e, 0xec, 0xcf, 0x5a, 0xec}; - uint8_t bytesprops2[] = {0x97, 0xbf, 0xaa, 0x60, 0x3c, 0x4a, 0x68, 0xc8, 0x3, 0xb1, 0x9, 0x7f, 0xf4, 0x9d, 0xd9, - 0x13, 0x4, 0xcc, 0x86, 0x5a, 0xa9, 0x28, 0x20, 0x5c, 0x2, 0xc8, 0x67, 0x6, 0xe9, 0x28}; - uint8_t bytesprops3[] = {0xfe, 0x38, 0x8e, 0x57, 0x26, 0xfd, 0xc8, 0xe7, 0xca, 0xbc, 0x46, 0x44, 0x42}; - uint8_t bytesprops4[] = {0x48, 0x20, 0x6b, 0xef, 0xf7, 0x75, 0x80, 0x36, 0xc0, 0x2e, 0x3d, 0x76, - 0x3a, 0x95, 0x75, 0x8b, 0x5f, 0xec, 0xef, 0x9c, 0x1e, 0x39, 0xf9, 0x86}; - uint8_t bytesprops5[] = {0xc7, 0x35, 0xa5, 0x89}; + uint8_t pkt[] = {0x10, 0x50, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x60, 0x71, 0x9, 0x15, 0x0, 0x6, 0x96, + 0xb8, 0x0, 0x0, 0x7, 0x40, 0x0, 0x1e, 0xd7, 0x27, 0x47, 0x24, 0x1b, 0x67, 0xc2, 0xdf, 0xbf, 0x3a, + 0x3, 0xa6, 0x8b, 0xc1, 0x6e, 0xb4, 0x9c, 0x8c, 0xa5, 0xd1, 0xce, 0x9, 0x6a, 0xf1, 0x17, 0xed, 0xd2, + 0xd4, 0x4a, 0x74, 0x0, 0xf, 0xc1, 0x3c, 0x7e, 0x3e, 0xe0, 0xda, 0xd5, 0xe6, 0x2b, 0xfd, 0xcc, 0x53, + 0x32, 0x31, 0x6c, 0x0, 0x9, 0xd0, 0x60, 0x31, 0x4d, 0x47, 0xb1, 0x7, 0xe6, 0xfe}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x96, 0xb8, 0x0, 0x0, 0x7, 0x40}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6151}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31052}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22791}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5494}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29031}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 16521; - uint8_t client_id_bytes[] = {0xba, 0x1e, 0x16, 0xa4, 0xbe, 0xdf, 0x30, 0xed, 0x3a, 0x28, 0xf2, 0x6d, 0x81, 0xa3, - 0xf, 0x7a, 0x92, 0x78, 0x7e, 0x52, 0xca, 0x44, 0x63, 0xb8, 0xdf, 0xa9, 0xe6, 0xa3}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.keep_alive = 24689; + uint8_t client_id_bytes[] = {0xd7, 0x27, 0x47, 0x24, 0x1b, 0x67, 0xc2, 0xdf, 0xbf, 0x3a, + 0x3, 0xa6, 0x8b, 0xc1, 0x6e, 0xb4, 0x9c, 0x8c, 0xa5, 0xd1, + 0xce, 0x9, 0x6a, 0xf1, 0x17, 0xed, 0xd2, 0xd4, 0x4a, 0x74}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x4a, 0x9e, 0xa7, 0xb1, 0x33, 0x3d, 0x6a, 0xb0, 0xd6, 0xc9, 0xc1, 0x36, 0x77, 0xa9, 0x7d}; + uint8_t username_bytes[] = {0xc1, 0x3c, 0x7e, 0x3e, 0xe0, 0xda, 0xd5, 0xe6, 0x2b, 0xfd, 0xcc, 0x53, 0x32, 0x31, 0x6c}; lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x61, 0x41, 0xf6, 0x4d, 0x6c, 0xaa, 0x62, 0xc3, 0xd9, - 0xc5, 0xe8, 0xd2, 0x8f, 0x2f, 0x41, 0xde, 0xc8, 0x93}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xd0, 0x60, 0x31, 0x4d, 0x47, 0xb1, 0x7, 0xe6, 0xfe}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); @@ -8704,201 +8700,64 @@ TEST(Connect5QCTest, Encode17) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "J\SOHI-\a)\244e", _password = Just -// "o\249\n\239J\249D>\131\239\242>\206\FS\195\145\176\134\EM4", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS0, _willTopic = "\254", _willMsg = "\ETXm\199\156Oznd*\US\135*", _willProps = [PropMaximumQoS -// 208,PropSubscriptionIdentifierAvailable 66,PropContentType -// "\\=\188\DEL\a\ETB{\162\176\166\213\204C\204/",PropMessageExpiryInterval 17231,PropAuthenticationData -// "\191\SUBv\SYN\194X\240\233`\n",PropContentType "\232",PropAuthenticationMethod -// "j\202~%\186\ACKO\191\176\228S\US\204&\EOTI\218j\174\157\182\SI",PropServerReference -// "\US\DEL\EM\n\191\"\192\210z\NUL9\188\EOT\SO",PropTopicAliasMaximum 1458,PropRequestProblemInformation -// 2,PropReceiveMaximum 9909,PropWillDelayInterval 15809,PropMaximumQoS 199,PropReasonString -// "w\150S\a!0\188",PropCorrelationData "\180\226\b^\SYN\SYNO\242\132P]\152m\254G",PropSessionExpiryInterval -// 6495,PropServerReference "\217(Y\146C\165~zra",PropResponseTopic "\128",PropAssignedClientIdentifier -// "\DC4bJ\SUB\143\161\213\234\140y\248\219\227w+\230",PropWildcardSubscriptionAvailable 226,PropAuthenticationData -// "\163`\196Y\132\230\226\ENQ",PropReasonString -// "7\243\132x\205\248DI1\232\157\250ONuh\135%)J\242@\251Wu.\nP\160",PropResponseInformation -// "J\169",PropAuthenticationMethod "\249\173\EM.>\253\182/",PropTopicAlias 7781,PropRetainAvailable 43,PropUserProperty -// "w\231\170#\132>\GS\129F\186" "\229\177\182\139"]}), _cleanSession = True, _keepAlive = 17571, _connID = -// "}\227/\252\245n]F\190\242|\141\194\180\DLE\194\190\226W", _properties = [PropRequestResponseInformation -// 43,PropAssignedClientIdentifier -// "\238\145\253Gn\171\250\184\EOT\134\229\136\150\EOT\ENQb\155\236\CAN\b",PropWildcardSubscriptionAvailable -// 71,PropServerReference "\154\246\ENQ\207,_U\SI\180#d\210\243\193\223e\EOT\189J\141~",PropCorrelationData -// "n9\214\149h\205-D\172\228 ~\169\222\132w \141z",PropAssignedClientIdentifier -// "j\208\253Bb\237IT\147g\196\221\&5\229\129\205\152m\nZX",PropTopicAlias 31605,PropMessageExpiryInterval -// 32174,PropServerReference -// "\148\218\SUBe\215\194;L\138\224Z\182\ESC%-\154\243\135\DC4+\184\&0\ETX\189\254\224\195",PropWillDelayInterval -// 18475,PropWildcardSubscriptionAvailable 78,PropMaximumQoS 136,PropSessionExpiryInterval 372,PropTopicAlias -// 23001,PropContentType "I\188&\DC2YH\NULm\a\218#La\SYN3\225n\246\DC3\217&\SOc\143!\165x!\SOH",PropMaximumPacketSize -// 24916,PropSubscriptionIdentifier 10,PropRetainAvailable 242,PropUserProperty "" -// "\144f\168`\158Q\bo\234u\STX\131\223\175\FS`\140\223\199\246\142\134\168u\149\SI\SO\217",PropRequestProblemInformation -// 225,PropResponseInformation -// "\191\225\147\248H\136\196.iOA\173\CAN\133*\208\144\137\139'\233&",PropResponseInformation -// "\ACK{",PropSubscriptionIdentifierAvailable 203,PropRequestProblemInformation 90,PropServerKeepAlive -// 9708,PropServerReference "\230\199\140\GS,#\147\ESCYM\t\249"]} +// ConnectRequest {_username = Nothing, _password = Just +// "\163}\NULy\RS\158NX4\187\195\203rzn\170(\172\129\146(]jr\168Q\169 \195\200", _lastWill = Just (LastWill {_willRetain +// = True, _willQoS = QoS2, _willTopic = "", _willMsg = "\244~\217'Tx\238\164\179\193!,\167", _willProps = +// [PropMessageExpiryInterval 19201,PropResponseTopic "\185\213\211",PropSubscriptionIdentifierAvailable +// 223,PropMaximumQoS 244,PropMessageExpiryInterval 23312,PropSubscriptionIdentifierAvailable 97,PropRetainAvailable +// 147,PropResponseTopic "\205\132"]}), _cleanSession = False, _keepAlive = 26060, _connID = +// "ta\163\130\232\170\157\144\190\ETB\172\170g\"\136\233\NAK\NAK\231\ETX\160\SYN~\ENQG\220\208\150\241", _properties = +// []} TEST(Connect5QCTest, Encode18) { - uint8_t pkt[] = { - 0x10, 0xeb, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x44, 0xa3, 0x98, 0x2, 0x19, 0x2b, 0x12, 0x0, - 0x14, 0xee, 0x91, 0xfd, 0x47, 0x6e, 0xab, 0xfa, 0xb8, 0x4, 0x86, 0xe5, 0x88, 0x96, 0x4, 0x5, 0x62, 0x9b, 0xec, - 0x18, 0x8, 0x28, 0x47, 0x1c, 0x0, 0x15, 0x9a, 0xf6, 0x5, 0xcf, 0x2c, 0x5f, 0x55, 0xf, 0xb4, 0x23, 0x64, 0xd2, - 0xf3, 0xc1, 0xdf, 0x65, 0x4, 0xbd, 0x4a, 0x8d, 0x7e, 0x9, 0x0, 0x13, 0x6e, 0x39, 0xd6, 0x95, 0x68, 0x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0x6e, 0xab, 0xfa, 0xb8, 0x4, 0x86, - 0xe5, 0x88, 0x96, 0x4, 0x5, 0x62, 0x9b, 0xec, 0x18, 0x8}; - uint8_t bytesprops1[] = {0x9a, 0xf6, 0x5, 0xcf, 0x2c, 0x5f, 0x55, 0xf, 0xb4, 0x23, 0x64, - 0xd2, 0xf3, 0xc1, 0xdf, 0x65, 0x4, 0xbd, 0x4a, 0x8d, 0x7e}; - uint8_t bytesprops2[] = {0x6e, 0x39, 0xd6, 0x95, 0x68, 0xcd, 0x2d, 0x44, 0xac, 0xe4, - 0x20, 0x7e, 0xa9, 0xde, 0x84, 0x77, 0x20, 0x8d, 0x7a}; - uint8_t bytesprops3[] = {0x6a, 0xd0, 0xfd, 0x42, 0x62, 0xed, 0x49, 0x54, 0x93, 0x67, 0xc4, - 0xdd, 0x35, 0xe5, 0x81, 0xcd, 0x98, 0x6d, 0xa, 0x5a, 0x58}; - uint8_t bytesprops4[] = {0x94, 0xda, 0x1a, 0x65, 0xd7, 0xc2, 0x3b, 0x4c, 0x8a, 0xe0, 0x5a, 0xb6, 0x1b, 0x25, - 0x2d, 0x9a, 0xf3, 0x87, 0x14, 0x2b, 0xb8, 0x30, 0x3, 0xbd, 0xfe, 0xe0, 0xc3}; - uint8_t bytesprops5[] = {0x49, 0xbc, 0x26, 0x12, 0x59, 0x48, 0x0, 0x6d, 0x7, 0xda, 0x23, 0x4c, 0x61, 0x16, 0x33, - 0xe1, 0x6e, 0xf6, 0x13, 0xd9, 0x26, 0xe, 0x63, 0x8f, 0x21, 0xa5, 0x78, 0x21, 0x1}; - uint8_t bytesprops7[] = {0x90, 0x66, 0xa8, 0x60, 0x9e, 0x51, 0x8, 0x6f, 0xea, 0x75, 0x2, 0x83, 0xdf, 0xaf, - 0x1c, 0x60, 0x8c, 0xdf, 0xc7, 0xf6, 0x8e, 0x86, 0xa8, 0x75, 0x95, 0xf, 0xe, 0xd9}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops8[] = {0xbf, 0xe1, 0x93, 0xf8, 0x48, 0x88, 0xc4, 0x2e, 0x69, 0x4f, 0x41, - 0xad, 0x18, 0x85, 0x2a, 0xd0, 0x90, 0x89, 0x8b, 0x27, 0xe9, 0x26}; - uint8_t bytesprops9[] = {0x6, 0x7b}; - uint8_t bytesprops10[] = {0xe6, 0xc7, 0x8c, 0x1d, 0x2c, 0x23, 0x93, 0x1b, 0x59, 0x4d, 0x9, 0xf9}; + uint8_t pkt[] = {0x10, 0x79, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x74, 0x65, 0xcc, 0x0, 0x0, 0x1d, 0x74, + 0x61, 0xa3, 0x82, 0xe8, 0xaa, 0x9d, 0x90, 0xbe, 0x17, 0xac, 0xaa, 0x67, 0x22, 0x88, 0xe9, 0x15, + 0x15, 0xe7, 0x3, 0xa0, 0x16, 0x7e, 0x5, 0x47, 0xdc, 0xd0, 0x96, 0xf1, 0x1d, 0x2, 0x0, 0x0, + 0x4b, 0x1, 0x8, 0x0, 0x3, 0xb9, 0xd5, 0xd3, 0x29, 0xdf, 0x24, 0xf4, 0x2, 0x0, 0x0, 0x5b, + 0x10, 0x29, 0x61, 0x25, 0x93, 0x8, 0x0, 0x2, 0xcd, 0x84, 0x0, 0x0, 0x0, 0xd, 0xf4, 0x7e, + 0xd9, 0x27, 0x54, 0x78, 0xee, 0xa4, 0xb3, 0xc1, 0x21, 0x2c, 0xa7, 0x0, 0x1e, 0xa3, 0x7d, 0x0, + 0x79, 0x1e, 0x9e, 0x4e, 0x58, 0x34, 0xbb, 0xc3, 0xcb, 0x72, 0x7a, 0x6e, 0xaa, 0x28, 0xac, 0x81, + 0x92, 0x28, 0x5d, 0x6a, 0x72, 0xa8, 0x51, 0xa9, 0x20, 0xc3, 0xc8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31605}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32174}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18475}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 372}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23001}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24916}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops6}, .v = {28, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9708}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops10}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x5c, 0x3d, 0xbc, 0x7f, 0x7, 0x17, 0x7b, 0xa2, 0xb0, 0xa6, 0xd5, 0xcc, 0x43, 0xcc, 0x2f}; - uint8_t byteswillprops1[] = {0xbf, 0x1a, 0x76, 0x16, 0xc2, 0x58, 0xf0, 0xe9, 0x60, 0xa}; - uint8_t byteswillprops2[] = {0xe8}; - uint8_t byteswillprops3[] = {0x6a, 0xca, 0x7e, 0x25, 0xba, 0x6, 0x4f, 0xbf, 0xb0, 0xe4, 0x53, - 0x1f, 0xcc, 0x26, 0x4, 0x49, 0xda, 0x6a, 0xae, 0x9d, 0xb6, 0xf}; - uint8_t byteswillprops4[] = {0x1f, 0x7f, 0x19, 0xa, 0xbf, 0x22, 0xc0, 0xd2, 0x7a, 0x0, 0x39, 0xbc, 0x4, 0xe}; - uint8_t byteswillprops5[] = {0x77, 0x96, 0x53, 0x7, 0x21, 0x30, 0xbc}; - uint8_t byteswillprops6[] = {0xb4, 0xe2, 0x8, 0x5e, 0x16, 0x16, 0x4f, 0xf2, 0x84, 0x50, 0x5d, 0x98, 0x6d, 0xfe, 0x47}; - uint8_t byteswillprops7[] = {0xd9, 0x28, 0x59, 0x92, 0x43, 0xa5, 0x7e, 0x7a, 0x72, 0x61}; - uint8_t byteswillprops8[] = {0x80}; - uint8_t byteswillprops9[] = {0x14, 0x62, 0x4a, 0x1a, 0x8f, 0xa1, 0xd5, 0xea, - 0x8c, 0x79, 0xf8, 0xdb, 0xe3, 0x77, 0x2b, 0xe6}; - uint8_t byteswillprops10[] = {0xa3, 0x60, 0xc4, 0x59, 0x84, 0xe6, 0xe2, 0x5}; - uint8_t byteswillprops11[] = {0x37, 0xf3, 0x84, 0x78, 0xcd, 0xf8, 0x44, 0x49, 0x31, 0xe8, - 0x9d, 0xfa, 0x4f, 0x4e, 0x75, 0x68, 0x87, 0x25, 0x29, 0x4a, - 0xf2, 0x40, 0xfb, 0x57, 0x75, 0x2e, 0xa, 0x50, 0xa0}; - uint8_t byteswillprops12[] = {0x4a, 0xa9}; - uint8_t byteswillprops13[] = {0xf9, 0xad, 0x19, 0x2e, 0x3e, 0xfd, 0xb6, 0x2f}; - uint8_t byteswillprops15[] = {0xe5, 0xb1, 0xb6, 0x8b}; - uint8_t byteswillprops14[] = {0x77, 0xe7, 0xaa, 0x23, 0x84, 0x3e, 0x1d, 0x81, 0x46, 0xba}; + uint8_t byteswillprops0[] = {0xb9, 0xd5, 0xd3}; + uint8_t byteswillprops1[] = {0xcd, 0x84}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17231}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1458}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9909}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15809}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6495}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&byteswillprops12}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops13}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7781}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {10, (char*)&byteswillprops14}, .v = {4, (char*)&byteswillprops15}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19201}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23312}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&byteswillprops1}}}, }; - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xfe}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3, 0x6d, 0xc7, 0x9c, 0x4f, 0x7a, 0x6e, 0x64, 0x2a, 0x1f, 0x87, 0x2a}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf4, 0x7e, 0xd9, 0x27, 0x54, 0x78, 0xee, 0xa4, 0xb3, 0xc1, 0x21, 0x2c, 0xa7}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 17571; - uint8_t client_id_bytes[] = {0x7d, 0xe3, 0x2f, 0xfc, 0xf5, 0x6e, 0x5d, 0x46, 0xbe, 0xf2, - 0x7c, 0x8d, 0xc2, 0xb4, 0x10, 0xc2, 0xbe, 0xe2, 0x57}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 26060; + uint8_t client_id_bytes[] = {0x74, 0x61, 0xa3, 0x82, 0xe8, 0xaa, 0x9d, 0x90, 0xbe, 0x17, 0xac, 0xaa, 0x67, 0x22, 0x88, + 0xe9, 0x15, 0x15, 0xe7, 0x3, 0xa0, 0x16, 0x7e, 0x5, 0x47, 0xdc, 0xd0, 0x96, 0xf1}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x4a, 0x1, 0x49, 0x2d, 0x7, 0x29, 0xf4, 0x65}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6f, 0xf9, 0xa, 0xef, 0x4a, 0xf9, 0x44, 0x3e, 0x83, 0xef, - 0xf2, 0x3e, 0xce, 0x1c, 0xc3, 0x91, 0xb0, 0x86, 0x19, 0x34}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xa3, 0x7d, 0x0, 0x79, 0x1e, 0x9e, 0x4e, 0x58, 0x34, 0xbb, 0xc3, 0xcb, 0x72, 0x7a, 0x6e, + 0xaa, 0x28, 0xac, 0x81, 0x92, 0x28, 0x5d, 0x6a, 0x72, 0xa8, 0x51, 0xa9, 0x20, 0xc3, 0xc8}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8908,89 +8767,110 @@ TEST(Connect5QCTest, Encode18) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\185\234\165\192W\204egO", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = -// "\254\234\SUB6\251\190\216\209\209\149\ETX\168\240\240\209\216\198rh\ETX\182!\187\172\232D", _willMsg = -// "\178\150\146w\234\131bw", _willProps = [PropMessageExpiryInterval 4700]}), _cleanSession = True, _keepAlive = 26206, -// _connID = "\225\SOY\244\214&\"\224\224\202\NAK\196\174", _properties = [PropPayloadFormatIndicator 165,PropMaximumQoS -// 15,PropReceiveMaximum 16602,PropServerKeepAlive 13964,PropServerKeepAlive 31602,PropUserProperty -// "\225\174\228\134A\183\144Y" -// "0\196\152\230\136!5.j\219a\216\192\190\&1\238\234g\DC2\166\217\204A\USb;",PropTopicAliasMaximum -// 28403,PropReceiveMaximum 24001,PropRetainAvailable 144,PropMaximumQoS 45,PropReceiveMaximum -// 6896,PropSubscriptionIdentifierAvailable 166,PropRetainAvailable 121,PropReceiveMaximum 4838,PropMaximumQoS -// 231,PropSharedSubscriptionAvailable 227,PropResponseInformation -// "\218\205\245\149\170m\201)WO\134\204\210",PropCorrelationData -// "\200\227!\\~\157\144\DC1\SOH",PropMessageExpiryInterval 24616,PropRetainAvailable 122]} +// ConnectRequest {_username = Just +// "b\218e\239\183\CAN\191\&2\226\216\211h\139\177i\206P\217\216\241\162\247\&3Q0\255G", _password = Just +// "\134h4\201\252\b\204\DC1\165,\191\253\vJ\240X^\167\US\159\224(\229f\223c", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS0, _willTopic = "\165Ue\188\167\r\197\235M\161$\227j)\243\233e!X\DC2M\158}", _willMsg = +// ":])y\210Yhl\128}\247\163hG", _willProps = [PropReceiveMaximum 15050,PropSubscriptionIdentifierAvailable +// 199,PropUserProperty "s\ESCo\189\191\148\171\129\227_\197\143o2\156?\140\128#\DC4\EM2Y\240\SYN\190\&1\253\131\172" +// "\175\232\132\189\132jy\166",PropMaximumQoS 67,PropContentType +// "(_}\135\220e\141\198#Z\130\&1\175\130\248\246\187\FS\196\227\132",PropWillDelayInterval 8465,PropRetainAvailable +// 167,PropResponseTopic "\255\142\t\SI\SUB\219\&4\238\188\RSGt\195\184\189\191\236\DEL\200\161",PropReasonString +// "",PropServerReference +// "\235\131\247\&4\SOH\229&`\EM\184P\236\&4\205\228\218\GS\185\179\STX9\ETX\188\251\167",PropResponseTopic +// "d\218\"\196\224\162\&5/",PropSubscriptionIdentifier 26,PropRequestProblemInformation +// 114,PropWildcardSubscriptionAvailable 233,PropMessageExpiryInterval 5629,PropRequestResponseInformation 52]}), +// _cleanSession = False, _keepAlive = 4784, _connID = "o\EOT\144\EOTo`,\SIr\191\185\&6i\246\150\254", _properties = +// [PropSubscriptionIdentifier 16,PropSessionExpiryInterval 4281,PropMaximumPacketSize 6189,PropMaximumPacketSize 1916]} TEST(Connect5QCTest, Encode19) { - uint8_t pkt[] = {0x10, 0xc0, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x66, 0x5e, 0x6f, 0x1, 0xa5, 0x24, - 0xf, 0x21, 0x40, 0xda, 0x13, 0x36, 0x8c, 0x13, 0x7b, 0x72, 0x26, 0x0, 0x8, 0xe1, 0xae, 0xe4, 0x86, - 0x41, 0xb7, 0x90, 0x59, 0x0, 0x1a, 0x30, 0xc4, 0x98, 0xe6, 0x88, 0x21, 0x35, 0x2e, 0x6a, 0xdb, 0x61, - 0xd8, 0xc0, 0xbe, 0x31, 0xee, 0xea, 0x67, 0x12, 0xa6, 0xd9, 0xcc, 0x41, 0x1f, 0x62, 0x3b, 0x22, 0x6e, - 0xf3, 0x21, 0x5d, 0xc1, 0x25, 0x90, 0x24, 0x2d, 0x21, 0x1a, 0xf0, 0x29, 0xa6, 0x25, 0x79, 0x21, 0x12, - 0xe6, 0x24, 0xe7, 0x2a, 0xe3, 0x1a, 0x0, 0xd, 0xda, 0xcd, 0xf5, 0x95, 0xaa, 0x6d, 0xc9, 0x29, 0x57, - 0x4f, 0x86, 0xcc, 0xd2, 0x9, 0x0, 0x9, 0xc8, 0xe3, 0x21, 0x5c, 0x7e, 0x9d, 0x90, 0x11, 0x1, 0x2, - 0x0, 0x0, 0x60, 0x28, 0x25, 0x7a, 0x0, 0xd, 0xe1, 0xe, 0x59, 0xf4, 0xd6, 0x26, 0x22, 0xe0, 0xe0, - 0xca, 0x15, 0xc4, 0xae, 0x5, 0x2, 0x0, 0x0, 0x12, 0x5c, 0x0, 0x1a, 0xfe, 0xea, 0x1a, 0x36, 0xfb, - 0xbe, 0xd8, 0xd1, 0xd1, 0x95, 0x3, 0xa8, 0xf0, 0xf0, 0xd1, 0xd8, 0xc6, 0x72, 0x68, 0x3, 0xb6, 0x21, - 0xbb, 0xac, 0xe8, 0x44, 0x0, 0x8, 0xb2, 0x96, 0x92, 0x77, 0xea, 0x83, 0x62, 0x77, 0x0, 0x9, 0xb9, - 0xea, 0xa5, 0xc0, 0x57, 0xcc, 0x65, 0x67, 0x4f}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x30, 0xc4, 0x98, 0xe6, 0x88, 0x21, 0x35, 0x2e, 0x6a, 0xdb, 0x61, 0xd8, 0xc0, - 0xbe, 0x31, 0xee, 0xea, 0x67, 0x12, 0xa6, 0xd9, 0xcc, 0x41, 0x1f, 0x62, 0x3b}; - uint8_t bytesprops0[] = {0xe1, 0xae, 0xe4, 0x86, 0x41, 0xb7, 0x90, 0x59}; - uint8_t bytesprops2[] = {0xda, 0xcd, 0xf5, 0x95, 0xaa, 0x6d, 0xc9, 0x29, 0x57, 0x4f, 0x86, 0xcc, 0xd2}; - uint8_t bytesprops3[] = {0xc8, 0xe3, 0x21, 0x5c, 0x7e, 0x9d, 0x90, 0x11, 0x1}; + uint8_t pkt[] = { + 0x10, 0xb1, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x12, 0xb0, 0x11, 0xb, 0x10, 0x11, 0x0, 0x0, + 0x10, 0xb9, 0x27, 0x0, 0x0, 0x18, 0x2d, 0x27, 0x0, 0x0, 0x7, 0x7c, 0x0, 0x10, 0x6f, 0x4, 0x90, 0x4, 0x6f, + 0x60, 0x2c, 0xf, 0x72, 0xbf, 0xb9, 0x36, 0x69, 0xf6, 0x96, 0xfe, 0x9f, 0x1, 0x21, 0x3a, 0xca, 0x29, 0xc7, 0x26, + 0x0, 0x1e, 0x73, 0x1b, 0x6f, 0xbd, 0xbf, 0x94, 0xab, 0x81, 0xe3, 0x5f, 0xc5, 0x8f, 0x6f, 0x32, 0x9c, 0x3f, 0x8c, + 0x80, 0x23, 0x14, 0x19, 0x32, 0x59, 0xf0, 0x16, 0xbe, 0x31, 0xfd, 0x83, 0xac, 0x0, 0x8, 0xaf, 0xe8, 0x84, 0xbd, + 0x84, 0x6a, 0x79, 0xa6, 0x24, 0x43, 0x3, 0x0, 0x15, 0x28, 0x5f, 0x7d, 0x87, 0xdc, 0x65, 0x8d, 0xc6, 0x23, 0x5a, + 0x82, 0x31, 0xaf, 0x82, 0xf8, 0xf6, 0xbb, 0x1c, 0xc4, 0xe3, 0x84, 0x18, 0x0, 0x0, 0x21, 0x11, 0x25, 0xa7, 0x8, + 0x0, 0x14, 0xff, 0x8e, 0x9, 0xf, 0x1a, 0xdb, 0x34, 0xee, 0xbc, 0x1e, 0x47, 0x74, 0xc3, 0xb8, 0xbd, 0xbf, 0xec, + 0x7f, 0xc8, 0xa1, 0x1f, 0x0, 0x0, 0x1c, 0x0, 0x19, 0xeb, 0x83, 0xf7, 0x34, 0x1, 0xe5, 0x26, 0x60, 0x19, 0xb8, + 0x50, 0xec, 0x34, 0xcd, 0xe4, 0xda, 0x1d, 0xb9, 0xb3, 0x2, 0x39, 0x3, 0xbc, 0xfb, 0xa7, 0x8, 0x0, 0x8, 0x64, + 0xda, 0x22, 0xc4, 0xe0, 0xa2, 0x35, 0x2f, 0xb, 0x1a, 0x17, 0x72, 0x28, 0xe9, 0x2, 0x0, 0x0, 0x15, 0xfd, 0x19, + 0x34, 0x0, 0x17, 0xa5, 0x55, 0x65, 0xbc, 0xa7, 0xd, 0xc5, 0xeb, 0x4d, 0xa1, 0x24, 0xe3, 0x6a, 0x29, 0xf3, 0xe9, + 0x65, 0x21, 0x58, 0x12, 0x4d, 0x9e, 0x7d, 0x0, 0xe, 0x3a, 0x5d, 0x29, 0x79, 0xd2, 0x59, 0x68, 0x6c, 0x80, 0x7d, + 0xf7, 0xa3, 0x68, 0x47, 0x0, 0x1b, 0x62, 0xda, 0x65, 0xef, 0xb7, 0x18, 0xbf, 0x32, 0xe2, 0xd8, 0xd3, 0x68, 0x8b, + 0xb1, 0x69, 0xce, 0x50, 0xd9, 0xd8, 0xf1, 0xa2, 0xf7, 0x33, 0x51, 0x30, 0xff, 0x47, 0x0, 0x1a, 0x86, 0x68, 0x34, + 0xc9, 0xfc, 0x8, 0xcc, 0x11, 0xa5, 0x2c, 0xbf, 0xfd, 0xb, 0x4a, 0xf0, 0x58, 0x5e, 0xa7, 0x1f, 0x9f, 0xe0, 0x28, + 0xe5, 0x66, 0xdf, 0x63}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16602}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13964}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31602}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {26, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28403}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24001}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6896}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4838}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24616}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4281}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6189}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1916}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xaf, 0xe8, 0x84, 0xbd, 0x84, 0x6a, 0x79, 0xa6}; + uint8_t byteswillprops0[] = {0x73, 0x1b, 0x6f, 0xbd, 0xbf, 0x94, 0xab, 0x81, 0xe3, 0x5f, + 0xc5, 0x8f, 0x6f, 0x32, 0x9c, 0x3f, 0x8c, 0x80, 0x23, 0x14, + 0x19, 0x32, 0x59, 0xf0, 0x16, 0xbe, 0x31, 0xfd, 0x83, 0xac}; + uint8_t byteswillprops2[] = {0x28, 0x5f, 0x7d, 0x87, 0xdc, 0x65, 0x8d, 0xc6, 0x23, 0x5a, 0x82, + 0x31, 0xaf, 0x82, 0xf8, 0xf6, 0xbb, 0x1c, 0xc4, 0xe3, 0x84}; + uint8_t byteswillprops3[] = {0xff, 0x8e, 0x9, 0xf, 0x1a, 0xdb, 0x34, 0xee, 0xbc, 0x1e, + 0x47, 0x74, 0xc3, 0xb8, 0xbd, 0xbf, 0xec, 0x7f, 0xc8, 0xa1}; + uint8_t byteswillprops4[] = {0}; + uint8_t byteswillprops5[] = {0xeb, 0x83, 0xf7, 0x34, 0x1, 0xe5, 0x26, 0x60, 0x19, 0xb8, 0x50, 0xec, 0x34, + 0xcd, 0xe4, 0xda, 0x1d, 0xb9, 0xb3, 0x2, 0x39, 0x3, 0xbc, 0xfb, 0xa7}; + uint8_t byteswillprops6[] = {0x64, 0xda, 0x22, 0xc4, 0xe0, 0xa2, 0x35, 0x2f}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4700}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15050}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {30, (char*)&byteswillprops0}, .v = {8, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8465}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5629}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 52}}, }; - lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xfe, 0xea, 0x1a, 0x36, 0xfb, 0xbe, 0xd8, 0xd1, 0xd1, 0x95, 0x3, 0xa8, 0xf0, - 0xf0, 0xd1, 0xd8, 0xc6, 0x72, 0x68, 0x3, 0xb6, 0x21, 0xbb, 0xac, 0xe8, 0x44}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb2, 0x96, 0x92, 0x77, 0xea, 0x83, 0x62, 0x77}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa5, 0x55, 0x65, 0xbc, 0xa7, 0xd, 0xc5, 0xeb, 0x4d, 0xa1, 0x24, 0xe3, + 0x6a, 0x29, 0xf3, 0xe9, 0x65, 0x21, 0x58, 0x12, 0x4d, 0x9e, 0x7d}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3a, 0x5d, 0x29, 0x79, 0xd2, 0x59, 0x68, 0x6c, 0x80, 0x7d, 0xf7, 0xa3, 0x68, 0x47}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 26206; - uint8_t client_id_bytes[] = {0xe1, 0xe, 0x59, 0xf4, 0xd6, 0x26, 0x22, 0xe0, 0xe0, 0xca, 0x15, 0xc4, 0xae}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 4784; + uint8_t client_id_bytes[] = {0x6f, 0x4, 0x90, 0x4, 0x6f, 0x60, 0x2c, 0xf, + 0x72, 0xbf, 0xb9, 0x36, 0x69, 0xf6, 0x96, 0xfe}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xb9, 0xea, 0xa5, 0xc0, 0x57, 0xcc, 0x65, 0x67, 0x4f}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x62, 0xda, 0x65, 0xef, 0xb7, 0x18, 0xbf, 0x32, 0xe2, 0xd8, 0xd3, 0x68, 0x8b, 0xb1, + 0x69, 0xce, 0x50, 0xd9, 0xd8, 0xf1, 0xa2, 0xf7, 0x33, 0x51, 0x30, 0xff, 0x47}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x86, 0x68, 0x34, 0xc9, 0xfc, 0x8, 0xcc, 0x11, 0xa5, 0x2c, 0xbf, 0xfd, 0xb, + 0x4a, 0xf0, 0x58, 0x5e, 0xa7, 0x1f, 0x9f, 0xe0, 0x28, 0xe5, 0x66, 0xdf, 0x63}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9000,174 +8880,37 @@ TEST(Connect5QCTest, Encode19) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\204\&9\146\248Z\193\151\237F\231u\205\207?\138\180*}\164\191\"\DEL\198$\DC3", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\DC2L", _willMsg -// = "\187\173\179\182\226\182\159\197\SO<\158\197/\170\130\157\210\201\222", _willProps = -// [PropWildcardSubscriptionAvailable 155,PropReceiveMaximum 13368,PropTopicAlias 1094,PropPayloadFormatIndicator -// 168,PropServerReference ">N\140\223\STX\191\188",PropAuthenticationMethod -// "[?\151\222\162~-\216\151\207\220I\ENQ}\158\245\165Gz\180b\145\ETX\236G8",PropReceiveMaximum -// 18277,PropWildcardSubscriptionAvailable 8,PropContentType "\167\r\255F",PropServerKeepAlive 12961,PropServerReference -// "<^Z\144\US\193\139\172\RSI\136\207\251\199\a\SOHN\160\\6\131\138F3#",PropMaximumPacketSize -// 21589,PropRequestProblemInformation 203,PropContentType "<\159B\t\165\SI",PropResponseTopic -// "e\216\&8\CAN\ENQo\200\181:",PropWillDelayInterval 29867,PropRequestProblemInformation 101,PropSessionExpiryInterval -// 28255,PropTopicAlias 4921,PropReasonString -// "\168\r\255\184\180\\F=oR\250\150\&0\146E\210\246(\243O\a|\242\229\160\&3\249\179",PropCorrelationData -// "7\179B\155P\183M\203\129\DC3\182}]\205\218d\DC4WK\238\242\SYN(\155\134\NAK",PropMessageExpiryInterval -// 3794,PropReasonString "r\162\244\209\231\193\171\186\196\135\154\231\148\205\222",PropResponseTopic -// "An\155\199\233\172/\176\244\n\250\217\224\171\253\155\134\207Y\131\158\250\218",PropUserProperty -// "-\226qm\253\254\150\&1\141*.\158\195WHW\212\229" "u\183/`\160J",PropWillDelayInterval 29343,PropTopicAlias -// 28208,PropSessionExpiryInterval 21834,PropMaximumQoS 123]}), _cleanSession = False, _keepAlive = 15691, _connID = -// ",\205\DC2;&\213%\165D\167", _properties = [PropContentType -// "AN\t\205}\198'\191Fu\251\162\238\156\RSW\213o\241\&0n0G\210\134\211",PropServerReference -// "\ETB9~\206\US@\167\NAKl\139\DC1 \158;\152\162\180\181\207:\ETB{u\142\245\154\140w", _password = Just -// "\220\STXp\210}\178\179y\171", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "\187\ACK\FS\183\136\196\202@\150G&%;\224\149\140\ETB\223] \145\&61:y\199", _willMsg = "\218\200 -// \235O\SYN\vs\250\233G\156\217.\200\235x\198r\202fF\SUB\147\252\255\197", _willProps = [PropTopicAliasMaximum -// 23455,PropContentType "\137P\DEL\143\230",PropSessionExpiryInterval 23587,PropResponseTopic -// "\253::\n\226\&0A\247\244\238h?\DLE\SI$\224f\223\&3j",PropSubscriptionIdentifierAvailable -// 38,PropWildcardSubscriptionAvailable 173]}), _cleanSession = True, _keepAlive = 7593, _connID = "-e~\r", _properties -// = [PropAssignedClientIdentifier -// "6\206\179q\RS\212\246\&3\SOHS\244\200\172g\233\174\146\253S>",PropSubscriptionIdentifierAvailable -// 136,PropTopicAliasMaximum 12556,PropUserProperty "`t\aOK\207\193\250\244\175p0s\188\187\US\222\138\182\DLE\146YO'P&S" -// "\161\196ZR\186\EOTdx",PropRetainAvailable 66,PropMessageExpiryInterval 24590,PropAuthenticationData -// "\b\241\238\ETB&\234\134\SOHJ7f",PropSessionExpiryInterval 9944,PropPayloadFormatIndicator 154,PropMaximumPacketSize -// 3417,PropReasonString "\180\133\139i\197\205\201\193%\205\196m|\NAK\197\151-\a"]} +// ConnectRequest {_username = Just "\n\216?v+\184\ACKT", _password = Just "f\232\200\n", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "R\180\EM\225w\208\US\DC2X5\243[\225:a\225\DC17\225BK4", _willMsg +// = "\SUB\214\DC3\210\166<\201\147Vy\142\f\161\223BFAO,\EOT\178OU", _willProps = [PropContentType +// "\170\RS\221\196\153N\EM\178\227\n\153s@",PropTopicAlias 22120,PropRetainAvailable 227,PropRequestProblemInformation +// 243,PropReasonString "\158J\154\178\246a\131\SI\189\144\159\ETX\STX\225}~I\217w\ACK\196",PropMessageExpiryInterval +// 21232]}), _cleanSession = True, _keepAlive = 20729, _connID = ")\f6\175\243\RS\147wQ\178\140rR", _properties = +// [PropSessionExpiryInterval 28247,PropMaximumPacketSize 15308,PropReasonString +// "K\n\241M:\157\f\162\206\NAK*\NAK\188R",PropAssignedClientIdentifier "\165"]} TEST(Connect5QCTest, Encode21) { - uint8_t pkt[] = { - 0x10, 0x8f, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x1d, 0xa9, 0x7a, 0x12, 0x0, 0x14, 0x36, 0xce, - 0xb3, 0x71, 0x1e, 0xd4, 0xf6, 0x33, 0x1, 0x53, 0xf4, 0xc8, 0xac, 0x67, 0xe9, 0xae, 0x92, 0xfd, 0x53, 0x3e, 0x29, - 0x88, 0x22, 0x31, 0xc, 0x26, 0x0, 0x1b, 0x60, 0x74, 0x7, 0x4f, 0x4b, 0xcf, 0xc1, 0xfa, 0xf4, 0xaf, 0x70, 0x30, - 0x73, 0xbc, 0xbb, 0x1f, 0xde, 0x8a, 0xb6, 0x10, 0x92, 0x59, 0x4f, 0x27, 0x50, 0x26, 0x53, 0x0, 0x8, 0xa1, 0xc4, - 0x5a, 0x52, 0xba, 0x4, 0x64, 0x78, 0x25, 0x42, 0x2, 0x0, 0x0, 0x60, 0xe, 0x16, 0x0, 0xb, 0x8, 0xf1, 0xee, - 0x17, 0x26, 0xea, 0x86, 0x1, 0x4a, 0x37, 0x66, 0x11, 0x0, 0x0, 0x26, 0xd8, 0x1, 0x9a, 0x27, 0x0, 0x0, 0xd, - 0x59, 0x1f, 0x0, 0x12, 0xb4, 0x85, 0x8b, 0x69, 0xc5, 0xcd, 0xc9, 0xc1, 0x25, 0xcd, 0xc4, 0x6d, 0x7c, 0x15, 0xc5, - 0x97, 0x2d, 0x7, 0x0, 0x4, 0x2d, 0x65, 0x7e, 0xd, 0x2b, 0x22, 0x5b, 0x9f, 0x3, 0x0, 0x5, 0x89, 0x50, 0x7f, - 0x8f, 0xe6, 0x11, 0x0, 0x0, 0x5c, 0x23, 0x8, 0x0, 0x14, 0xfd, 0x3a, 0x3a, 0xa, 0xe2, 0x30, 0x41, 0xf7, 0xf4, - 0xee, 0x68, 0x3f, 0x10, 0xf, 0x24, 0xe0, 0x66, 0xdf, 0x33, 0x6a, 0x29, 0x26, 0x28, 0xad, 0x0, 0x1a, 0xbb, 0x6, - 0x1c, 0xb7, 0x88, 0xc4, 0xca, 0x40, 0x96, 0x47, 0x26, 0x25, 0x3b, 0xe0, 0x95, 0x8c, 0x17, 0xdf, 0x5d, 0x20, 0x91, - 0x36, 0x31, 0x3a, 0x79, 0xc7, 0x0, 0x1b, 0xda, 0xc8, 0x20, 0xeb, 0x4f, 0x16, 0xb, 0x73, 0xfa, 0xe9, 0x47, 0x9c, - 0xd9, 0x2e, 0xc8, 0xeb, 0x78, 0xc6, 0x72, 0xca, 0x66, 0x46, 0x1a, 0x93, 0xfc, 0xff, 0xc5, 0x0, 0x12, 0x54, 0x3e, - 0x9e, 0x3b, 0x98, 0xa2, 0xb4, 0xb5, 0xcf, 0x3a, 0x17, 0x7b, 0x75, 0x8e, 0xf5, 0x9a, 0x8c, 0x77, 0x0, 0x9, 0xdc, - 0x2, 0x70, 0xd2, 0x7d, 0xb2, 0xb3, 0x79, 0xab}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x36, 0xce, 0xb3, 0x71, 0x1e, 0xd4, 0xf6, 0x33, 0x1, 0x53, - 0xf4, 0xc8, 0xac, 0x67, 0xe9, 0xae, 0x92, 0xfd, 0x53, 0x3e}; - uint8_t bytesprops2[] = {0xa1, 0xc4, 0x5a, 0x52, 0xba, 0x4, 0x64, 0x78}; - uint8_t bytesprops1[] = {0x60, 0x74, 0x7, 0x4f, 0x4b, 0xcf, 0xc1, 0xfa, 0xf4, 0xaf, 0x70, 0x30, 0x73, 0xbc, - 0xbb, 0x1f, 0xde, 0x8a, 0xb6, 0x10, 0x92, 0x59, 0x4f, 0x27, 0x50, 0x26, 0x53}; - uint8_t bytesprops3[] = {0x8, 0xf1, 0xee, 0x17, 0x26, 0xea, 0x86, 0x1, 0x4a, 0x37, 0x66}; - uint8_t bytesprops4[] = {0xb4, 0x85, 0x8b, 0x69, 0xc5, 0xcd, 0xc9, 0xc1, 0x25, - 0xcd, 0xc4, 0x6d, 0x7c, 0x15, 0xc5, 0x97, 0x2d, 0x7}; + uint8_t pkt[] = {0x10, 0xaf, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x50, 0xf9, 0x1f, 0x11, 0x0, 0x0, + 0x6e, 0x57, 0x27, 0x0, 0x0, 0x3b, 0xcc, 0x1f, 0x0, 0xe, 0x4b, 0xa, 0xf1, 0x4d, 0x3a, 0x9d, 0xc, + 0xa2, 0xce, 0x15, 0x2a, 0x15, 0xbc, 0x52, 0x12, 0x0, 0x1, 0xa5, 0x0, 0xd, 0x29, 0xc, 0x36, 0xaf, + 0xf3, 0x1e, 0x93, 0x77, 0x51, 0xb2, 0x8c, 0x72, 0x52, 0x34, 0x3, 0x0, 0xd, 0xaa, 0x1e, 0xdd, 0xc4, + 0x99, 0x4e, 0x19, 0xb2, 0xe3, 0xa, 0x99, 0x73, 0x40, 0x23, 0x56, 0x68, 0x25, 0xe3, 0x17, 0xf3, 0x1f, + 0x0, 0x15, 0x9e, 0x4a, 0x9a, 0xb2, 0xf6, 0x61, 0x83, 0xf, 0xbd, 0x90, 0x9f, 0x3, 0x2, 0xe1, 0x7d, + 0x7e, 0x49, 0xd9, 0x77, 0x6, 0xc4, 0x2, 0x0, 0x0, 0x52, 0xf0, 0x0, 0x16, 0x52, 0xb4, 0x19, 0xe1, + 0x77, 0xd0, 0x1f, 0x12, 0x58, 0x35, 0xf3, 0x5b, 0xe1, 0x3a, 0x61, 0xe1, 0x11, 0x37, 0xe1, 0x42, 0x4b, + 0x34, 0x0, 0x17, 0x1a, 0xd6, 0x13, 0xd2, 0xa6, 0x3c, 0xc9, 0x93, 0x56, 0x79, 0x8e, 0xc, 0xa1, 0xdf, + 0x42, 0x46, 0x41, 0x4f, 0x2c, 0x4, 0xb2, 0x4f, 0x55, 0x0, 0x8, 0xa, 0xd8, 0x3f, 0x76, 0x2b, 0xb8, + 0x6, 0x54, 0x0, 0x4, 0x66, 0xe8, 0xc8, 0xa}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x4b, 0xa, 0xf1, 0x4d, 0x3a, 0x9d, 0xc, 0xa2, 0xce, 0x15, 0x2a, 0x15, 0xbc, 0x52}; + uint8_t bytesprops1[] = {0xa5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12556}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24590}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9944}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3417}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28247}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15308}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x89, 0x50, 0x7f, 0x8f, 0xe6}; - uint8_t byteswillprops1[] = {0xfd, 0x3a, 0x3a, 0xa, 0xe2, 0x30, 0x41, 0xf7, 0xf4, 0xee, - 0x68, 0x3f, 0x10, 0xf, 0x24, 0xe0, 0x66, 0xdf, 0x33, 0x6a}; + uint8_t byteswillprops0[] = {0xaa, 0x1e, 0xdd, 0xc4, 0x99, 0x4e, 0x19, 0xb2, 0xe3, 0xa, 0x99, 0x73, 0x40}; + uint8_t byteswillprops1[] = {0x9e, 0x4a, 0x9a, 0xb2, 0xf6, 0x61, 0x83, 0xf, 0xbd, 0x90, 0x9f, + 0x3, 0x2, 0xe1, 0x7d, 0x7e, 0x49, 0xd9, 0x77, 0x6, 0xc4}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23455}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23587}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22120}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21232}}, }; lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbb, 0x6, 0x1c, 0xb7, 0x88, 0xc4, 0xca, 0x40, 0x96, 0x47, 0x26, 0x25, 0x3b, - 0xe0, 0x95, 0x8c, 0x17, 0xdf, 0x5d, 0x20, 0x91, 0x36, 0x31, 0x3a, 0x79, 0xc7}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xda, 0xc8, 0x20, 0xeb, 0x4f, 0x16, 0xb, 0x73, 0xfa, 0xe9, 0x47, 0x9c, 0xd9, 0x2e, - 0xc8, 0xeb, 0x78, 0xc6, 0x72, 0xca, 0x66, 0x46, 0x1a, 0x93, 0xfc, 0xff, 0xc5}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x52, 0xb4, 0x19, 0xe1, 0x77, 0xd0, 0x1f, 0x12, 0x58, 0x35, 0xf3, + 0x5b, 0xe1, 0x3a, 0x61, 0xe1, 0x11, 0x37, 0xe1, 0x42, 0x4b, 0x34}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1a, 0xd6, 0x13, 0xd2, 0xa6, 0x3c, 0xc9, 0x93, 0x56, 0x79, 0x8e, 0xc, + 0xa1, 0xdf, 0x42, 0x46, 0x41, 0x4f, 0x2c, 0x4, 0xb2, 0x4f, 0x55}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 7593; - uint8_t client_id_bytes[] = {0x2d, 0x65, 0x7e, 0xd}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.keep_alive = 20729; + uint8_t client_id_bytes[] = {0x29, 0xc, 0x36, 0xaf, 0xf3, 0x1e, 0x93, 0x77, 0x51, 0xb2, 0x8c, 0x72, 0x52}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x54, 0x3e, 0x9e, 0x3b, 0x98, 0xa2, 0xb4, 0xb5, 0xcf, - 0x3a, 0x17, 0x7b, 0x75, 0x8e, 0xf5, 0x9a, 0x8c, 0x77}; - lwmqtt_string_t username = {18, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa, 0xd8, 0x3f, 0x76, 0x2b, 0xb8, 0x6, 0x54}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xdc, 0x2, 0x70, 0xd2, 0x7d, 0xb2, 0xb3, 0x79, 0xab}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x66, 0xe8, 0xc8, 0xa}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9295,60 +9017,87 @@ TEST(Connect5QCTest, Encode21) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "/O\134\NAKdJ", _password = Just -// "\196\156\220\155\135\182\vb\vM\183\205\156r\135f`\148\245\162\148\&5\243`G\196\184*\154", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 23419, _connID = "\138\r,\181sl\193\231\232\198\"\231/\251W\218!s", _properties = -// [PropCorrelationData "\GS5\254T\162HT\191\187\252\211\216\254\DLE\220G\231\139s@\205\vW",PropSessionExpiryInterval -// 5360,PropAuthenticationMethod "\n$\206\231\251\249\174\STX+d@",PropCorrelationData -// "\136\156lg\DC1\184\233\219\242Ni\145\SO(\231",PropMessageExpiryInterval 5401,PropUserProperty -// "\n\237J\219o\201\186\n\242\238L\193\161\164\SOH\ACK\151\198" -// "1?\178\249\157\250l\128\169\186{\140\133\201ug\227\202\147\232t,\235\DC1\"\188\SOH"]} +// ConnectRequest {_username = Just "\218", _password = Just +// "\157\199_\231w\v\CAN\198\175\204\172\255\223\220\130\250!\147\249\203$a\136\131\EMn\SOHO\252", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 1033, _connID = "\252\aa\128~\196\ESC\154\131\&6\174", _properties = +// [PropResponseInformation "8\246k\235\ESC\161*`-_^\138",PropTopicAliasMaximum 22551,PropAuthenticationMethod +// "L\"\188\172\f5\131\196\151\229q\US\tL\EOT-(\f$\220A<;\201\DLE\156\203",PropServerReference +// "\RSP\ESC{\147!\245\216\151x\b\248f\SYNV\129p=\155t\173",PropContentType +// "&\243-1\242\245(pJ\238WE\202\236",PropTopicAliasMaximum 24056,PropServerReference +// "Y\a=\173B?\244\178Z_\ACK\n\191\172\212\231\208\DC1^;^(Q\191\141\239'\ACKwI",PropUserProperty "\155\a\141\197\170" +// "\138\211\140V\193\192Z\223\GSx\238\253\SUB\216\186\217(\158\&0\"\184\215\220\EM\214\209\211\205",PropSessionExpiryInterval +// 11502,PropAuthenticationMethod +// "\171%8\152\229\a\160^\DC1\US\DC2]\158\151\DC16?3\160\238=J\228",PropAuthenticationData "(!\ETB\219J|",PropMaximumQoS +// 11,PropUserProperty "\226\134\181Z\228B\221\150\244\GS\233\227\&2\US\196\241\149\181q\184k\178\158\251\156o" +// "\194_\DC4>m.W\176M\204\f\212<\245w\151\r\150h\230eU\183\236"]} TEST(Connect5QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0xbc, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x5b, 0x7b, 0x76, 0x9, 0x0, - 0x17, 0x1d, 0x35, 0xfe, 0x54, 0xa2, 0x48, 0x54, 0xbf, 0xbb, 0xfc, 0xd3, 0xd8, 0xfe, 0x10, 0xdc, - 0x47, 0xe7, 0x8b, 0x73, 0x40, 0xcd, 0xb, 0x57, 0x11, 0x0, 0x0, 0x14, 0xf0, 0x15, 0x0, 0xb, - 0xa, 0x24, 0xce, 0xe7, 0xfb, 0xf9, 0xae, 0x2, 0x2b, 0x64, 0x40, 0x9, 0x0, 0xf, 0x88, 0x9c, - 0x6c, 0x67, 0x11, 0xb8, 0xe9, 0xdb, 0xf2, 0x4e, 0x69, 0x91, 0xe, 0x28, 0xe7, 0x2, 0x0, 0x0, - 0x15, 0x19, 0x26, 0x0, 0x12, 0xa, 0xed, 0x4a, 0xdb, 0x6f, 0xc9, 0xba, 0xa, 0xf2, 0xee, 0x4c, - 0xc1, 0xa1, 0xa4, 0x1, 0x6, 0x97, 0xc6, 0x0, 0x1b, 0x31, 0x3f, 0xb2, 0xf9, 0x9d, 0xfa, 0x6c, - 0x80, 0xa9, 0xba, 0x7b, 0x8c, 0x85, 0xc9, 0x75, 0x67, 0xe3, 0xca, 0x93, 0xe8, 0x74, 0x2c, 0xeb, - 0x11, 0x22, 0xbc, 0x1, 0x0, 0x12, 0x8a, 0xd, 0x2c, 0xb5, 0x73, 0x6c, 0xc1, 0xe7, 0xe8, 0xc6, - 0x22, 0xe7, 0x2f, 0xfb, 0x57, 0xda, 0x21, 0x73, 0x0, 0x6, 0x2f, 0x4f, 0x86, 0x15, 0x64, 0x4a, - 0x0, 0x1d, 0xc4, 0x9c, 0xdc, 0x9b, 0x87, 0xb6, 0xb, 0x62, 0xb, 0x4d, 0xb7, 0xcd, 0x9c, 0x72, - 0x87, 0x66, 0x60, 0x94, 0xf5, 0xa2, 0x94, 0x35, 0xf3, 0x60, 0x47, 0xc4, 0xb8, 0x2a, 0x9a}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1d, 0x35, 0xfe, 0x54, 0xa2, 0x48, 0x54, 0xbf, 0xbb, 0xfc, 0xd3, 0xd8, - 0xfe, 0x10, 0xdc, 0x47, 0xe7, 0x8b, 0x73, 0x40, 0xcd, 0xb, 0x57}; - uint8_t bytesprops1[] = {0xa, 0x24, 0xce, 0xe7, 0xfb, 0xf9, 0xae, 0x2, 0x2b, 0x64, 0x40}; - uint8_t bytesprops2[] = {0x88, 0x9c, 0x6c, 0x67, 0x11, 0xb8, 0xe9, 0xdb, 0xf2, 0x4e, 0x69, 0x91, 0xe, 0x28, 0xe7}; - uint8_t bytesprops4[] = {0x31, 0x3f, 0xb2, 0xf9, 0x9d, 0xfa, 0x6c, 0x80, 0xa9, 0xba, 0x7b, 0x8c, 0x85, 0xc9, - 0x75, 0x67, 0xe3, 0xca, 0x93, 0xe8, 0x74, 0x2c, 0xeb, 0x11, 0x22, 0xbc, 0x1}; - uint8_t bytesprops3[] = {0xa, 0xed, 0x4a, 0xdb, 0x6f, 0xc9, 0xba, 0xa, 0xf2, - 0xee, 0x4c, 0xc1, 0xa1, 0xa4, 0x1, 0x6, 0x97, 0xc6}; + uint8_t pkt[] = { + 0x10, 0xbf, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x4, 0x9, 0x84, 0x2, 0x1a, 0x0, 0xc, 0x38, + 0xf6, 0x6b, 0xeb, 0x1b, 0xa1, 0x2a, 0x60, 0x2d, 0x5f, 0x5e, 0x8a, 0x22, 0x58, 0x17, 0x15, 0x0, 0x1b, 0x4c, 0x22, + 0xbc, 0xac, 0xc, 0x35, 0x83, 0xc4, 0x97, 0xe5, 0x71, 0x1f, 0x9, 0x4c, 0x4, 0x2d, 0x28, 0xc, 0x24, 0xdc, 0x41, + 0x3c, 0x3b, 0xc9, 0x10, 0x9c, 0xcb, 0x1c, 0x0, 0x15, 0x1e, 0x50, 0x1b, 0x7b, 0x93, 0x21, 0xf5, 0xd8, 0x97, 0x78, + 0x8, 0xf8, 0x66, 0x16, 0x56, 0x81, 0x70, 0x3d, 0x9b, 0x74, 0xad, 0x3, 0x0, 0xe, 0x26, 0xf3, 0x2d, 0x31, 0xf2, + 0xf5, 0x28, 0x70, 0x4a, 0xee, 0x57, 0x45, 0xca, 0xec, 0x22, 0x5d, 0xf8, 0x1c, 0x0, 0x1e, 0x59, 0x7, 0x3d, 0xad, + 0x42, 0x3f, 0xf4, 0xb2, 0x5a, 0x5f, 0x6, 0xa, 0xbf, 0xac, 0x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 0xfa, 0x21, 0x93, 0xf9, 0xcb, 0x24, 0x61, 0x88, 0x83, 0x19, 0x6e, 0x1, 0x4f, 0xfc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x38, 0xf6, 0x6b, 0xeb, 0x1b, 0xa1, 0x2a, 0x60, 0x2d, 0x5f, 0x5e, 0x8a}; + uint8_t bytesprops1[] = {0x4c, 0x22, 0xbc, 0xac, 0xc, 0x35, 0x83, 0xc4, 0x97, 0xe5, 0x71, 0x1f, 0x9, 0x4c, + 0x4, 0x2d, 0x28, 0xc, 0x24, 0xdc, 0x41, 0x3c, 0x3b, 0xc9, 0x10, 0x9c, 0xcb}; + uint8_t bytesprops2[] = {0x1e, 0x50, 0x1b, 0x7b, 0x93, 0x21, 0xf5, 0xd8, 0x97, 0x78, 0x8, + 0xf8, 0x66, 0x16, 0x56, 0x81, 0x70, 0x3d, 0x9b, 0x74, 0xad}; + uint8_t bytesprops3[] = {0x26, 0xf3, 0x2d, 0x31, 0xf2, 0xf5, 0x28, 0x70, 0x4a, 0xee, 0x57, 0x45, 0xca, 0xec}; + uint8_t bytesprops4[] = {0x59, 0x7, 0x3d, 0xad, 0x42, 0x3f, 0xf4, 0xb2, 0x5a, 0x5f, 0x6, 0xa, 0xbf, 0xac, 0xd4, + 0xe7, 0xd0, 0x11, 0x5e, 0x3b, 0x5e, 0x28, 0x51, 0xbf, 0x8d, 0xef, 0x27, 0x6, 0x77, 0x49}; + uint8_t bytesprops6[] = {0x8a, 0xd3, 0x8c, 0x56, 0xc1, 0xc0, 0x5a, 0xdf, 0x1d, 0x78, 0xee, 0xfd, 0x1a, 0xd8, + 0xba, 0xd9, 0x28, 0x9e, 0x30, 0x22, 0xb8, 0xd7, 0xdc, 0x19, 0xd6, 0xd1, 0xd3, 0xcd}; + uint8_t bytesprops5[] = {0x9b, 0x7, 0x8d, 0xc5, 0xaa}; + uint8_t bytesprops7[] = {0xab, 0x25, 0x38, 0x98, 0xe5, 0x7, 0xa0, 0x5e, 0x11, 0x1f, 0x12, 0x5d, + 0x9e, 0x97, 0x11, 0x36, 0x3f, 0x33, 0xa0, 0xee, 0x3d, 0x4a, 0xe4}; + uint8_t bytesprops8[] = {0x28, 0x21, 0x17, 0xdb, 0x4a, 0x7c}; + uint8_t bytesprops10[] = {0xc2, 0x5f, 0x14, 0x3e, 0x6d, 0x2e, 0x57, 0xb0, 0x4d, 0xcc, 0xc, 0xd4, + 0x3c, 0xf5, 0x77, 0x97, 0xd, 0x96, 0x68, 0xe6, 0x65, 0x55, 0xb7, 0xec}; + uint8_t bytesprops9[] = {0xe2, 0x86, 0xb5, 0x5a, 0xe4, 0x42, 0xdd, 0x96, 0xf4, 0x1d, 0xe9, 0xe3, 0x32, + 0x1f, 0xc4, 0xf1, 0x95, 0xb5, 0x71, 0xb8, 0x6b, 0xb2, 0x9e, 0xfb, 0x9c, 0x6f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5360}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5401}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops3}, .v = {27, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22551}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24056}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops5}, .v = {28, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11502}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops9}, .v = {24, (char*)&bytesprops10}}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 23419; - uint8_t client_id_bytes[] = {0x8a, 0xd, 0x2c, 0xb5, 0x73, 0x6c, 0xc1, 0xe7, 0xe8, - 0xc6, 0x22, 0xe7, 0x2f, 0xfb, 0x57, 0xda, 0x21, 0x73}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.keep_alive = 1033; + uint8_t client_id_bytes[] = {0xfc, 0x7, 0x61, 0x80, 0x7e, 0xc4, 0x1b, 0x9a, 0x83, 0x36, 0xae}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2f, 0x4f, 0x86, 0x15, 0x64, 0x4a}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xda}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xc4, 0x9c, 0xdc, 0x9b, 0x87, 0xb6, 0xb, 0x62, 0xb, 0x4d, 0xb7, 0xcd, 0x9c, 0x72, 0x87, - 0x66, 0x60, 0x94, 0xf5, 0xa2, 0x94, 0x35, 0xf3, 0x60, 0x47, 0xc4, 0xb8, 0x2a, 0x9a}; + uint8_t password_bytes[] = {0x9d, 0xc7, 0x5f, 0xe7, 0x77, 0xb, 0x18, 0xc6, 0xaf, 0xcc, 0xac, 0xff, 0xdf, 0xdc, 0x82, + 0xfa, 0x21, 0x93, 0xf9, 0xcb, 0x24, 0x61, 0x88, 0x83, 0x19, 0x6e, 0x1, 0x4f, 0xfc}; lwmqtt_string_t password = {29, (char*)&password_bytes}; opts.password = password; size_t len = 0; @@ -9359,154 +9108,91 @@ TEST(Connect5QCTest, Encode22) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\247\SI;~\246\226", _password = Just -// "\182\193\204\184\SI\251\239\221G\188,\207\181\222\169\DC2a\166\156\180\a\253\242", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\149\199O\138Vs\224&_\202\180\SYN\148\241G3\232\196)$~\216\157\181\176!", _willMsg = -// "_\241\DC4V97\239\206\170C\b\207\&9\170\141\GS3\216\234\DC4\141", _willProps = [PropServerKeepAlive -// 4144,PropServerReference "\228\t\\|9p\177cY\201",PropPayloadFormatIndicator 17,PropMaximumPacketSize -// 20879,PropSharedSubscriptionAvailable 15,PropSubscriptionIdentifierAvailable 73,PropSharedSubscriptionAvailable -// 183,PropSharedSubscriptionAvailable 31,PropRetainAvailable 84,PropContentType "",PropMaximumQoS -// 100,PropTopicAliasMaximum 28424,PropAuthenticationData -// "b`\DC1\163\155\163\176\237ey~\165\t\160\ETX\236Uz\228g\167\184=",PropReceiveMaximum 9949,PropAuthenticationData -// "\139i",PropSessionExpiryInterval 12502,PropReceiveMaximum 21847,PropMessageExpiryInterval -// 22456,PropResponseInformation "]Ygv\176G\225\v",PropReasonString "\153\DC2\173\149\144U"]}), _cleanSession = True, -// _keepAlive = 7, _connID = "G\\kY\SOH\242", _properties = [PropReceiveMaximum -// 28332,PropSubscriptionIdentifierAvailable 65,PropRetainAvailable 40,PropSharedSubscriptionAvailable -// 92,PropReasonString "v\166Gl>\177$\240",PropWillDelayInterval 25126,PropResponseInformation -// "\232a\180\140\245\200/Xo\187\138Cu.\212j\143",PropCorrelationData "z[T",PropSharedSubscriptionAvailable -// 108,PropRequestResponseInformation 45,PropMessageExpiryInterval 23632,PropCorrelationData -// "\132(\ETXKN\156p\142)\250\246o",PropMaximumQoS 78,PropResponseTopic -// "\148\173\132\171\SOH\232\rf\243\162nX\136\ETB",PropRequestResponseInformation 237,PropReasonString -// "\184\254\197\130\223LN\SYN\217\212\177\210g",PropAuthenticationMethod -// "\148\159&P\CAN\ACK\132\177x\182H\ENQ",PropSubscriptionIdentifierAvailable 126,PropWildcardSubscriptionAvailable -// 118,PropUserProperty "\238\192T\SO\250\171r!\208\DC3+\214\207\230\217Sj\nU<\232" -// "\141\&8\243\227f\229m",PropTopicAlias 1412,PropRequestProblemInformation 88,PropResponseTopic -// ".\242\156\164\DC1e%7]\200\201\NAK\212\211\&0t\230\CAN",PropReceiveMaximum 11196]} +// ConnectRequest {_username = Just "\140\163RpjPE\225/:\ESC", _password = Just +// "\224\162k\234^k\194\DC3\157\n\DC4\228\216\234\160.o\NAKr\219\DC1\ETB", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS0, _willTopic = "\138\162?\130\159\141?\154+\DC4B\246\249\DEL1;-\244\132W;", _willMsg = +// "~j\245\255", _willProps = [PropAuthenticationData "",PropContentType +// "\DLE\229\157\202\219r\251\238\t\128",PropMessageExpiryInterval 31508,PropMaximumQoS 108,PropUserProperty +// "*\245\230\140\139s\239\161" "\255\203\204)D\210\164|\STX."]}), _cleanSession = False, _keepAlive = 9554, _connID = +// "", _properties = [PropReceiveMaximum 164,PropTopicAlias 21466,PropSessionExpiryInterval 7448,PropMaximumQoS +// 142,PropMaximumQoS 68,PropTopicAliasMaximum 7595,PropMessageExpiryInterval 9170,PropContentType +// "\216=",PropCorrelationData "OC\138\206\239\SI\159\SUB\173\221\253\220G\240\149\179",PropResponseTopic +// "\218\SI",PropRequestProblemInformation 196,PropResponseTopic "\DLE\239\205uk\216\200\225R"]} TEST(Connect5QCTest, Encode23) { - uint8_t pkt[] = { - 0x10, 0x96, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x0, 0x7, 0xc1, 0x1, 0x21, 0x6e, 0xac, 0x29, - 0x41, 0x25, 0x28, 0x2a, 0x5c, 0x1f, 0x0, 0x8, 0x76, 0xa6, 0x47, 0x6c, 0x3e, 0xb1, 0x24, 0xf0, 0x18, 0x0, 0x0, - 0x62, 0x26, 0x1a, 0x0, 0x11, 0xe8, 0x61, 0xb4, 0x8c, 0xf5, 0xc8, 0x2f, 0x58, 0x6f, 0xbb, 0x8a, 0x43, 0x75, 0x2e, - 0xd4, 0x6a, 0x8f, 0x9, 0x0, 0x3, 0x7a, 0x5b, 0x54, 0x2a, 0x6c, 0x19, 0x2d, 0x2, 0x0, 0x0, 0x5c, 0x50, 0x9, - 0x0, 0xc, 0x84, 0x28, 0x3, 0x4b, 0x4e, 0x9c, 0x70, 0x8e, 0x29, 0xfa, 0xf6, 0x6f, 0x24, 0x4e, 0x8, 0x0, 0xe, - 0x94, 0xad, 0x84, 0xab, 0x1, 0xe8, 0xd, 0x66, 0xf3, 0xa2, 0x6e, 0x58, 0x88, 0x17, 0x19, 0xed, 0x1f, 0x0, 0xd, - 0xb8, 0xfe, 0xc5, 0x82, 0xdf, 0x4c, 0x4e, 0x16, 0xd9, 0xd4, 0xb1, 0xd2, 0x67, 0x15, 0x0, 0xc, 0x94, 0x9f, 0x26, - 0x50, 0x18, 0x6, 0x84, 0xb1, 0x78, 0xb6, 0x48, 0x5, 0x29, 0x7e, 0x28, 0x76, 0x26, 0x0, 0x15, 0xee, 0xc0, 0x54, - 0xe, 0xfa, 0xab, 0x72, 0x21, 0xd0, 0x13, 0x2b, 0xd6, 0xcf, 0xe6, 0xd9, 0x53, 0x6a, 0xa, 0x55, 0x3c, 0xe8, 0x0, - 0x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0x37, - 0xef, 0xce, 0xaa, 0x43, 0x8, 0xcf, 0x39, 0xaa, 0x8d, 0x1d, 0x33, 0xd8, 0xea, 0x14, 0x8d, 0x0, 0x6, 0xf7, 0xf, - 0x3b, 0x7e, 0xf6, 0xe2, 0x0, 0x17, 0xb6, 0xc1, 0xcc, 0xb8, 0xf, 0xfb, 0xef, 0xdd, 0x47, 0xbc, 0x2c, 0xcf, 0xb5, - 0xde, 0xa9, 0x12, 0x61, 0xa6, 0x9c, 0xb4, 0x7, 0xfd, 0xf2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x76, 0xa6, 0x47, 0x6c, 0x3e, 0xb1, 0x24, 0xf0}; - uint8_t bytesprops1[] = {0xe8, 0x61, 0xb4, 0x8c, 0xf5, 0xc8, 0x2f, 0x58, 0x6f, - 0xbb, 0x8a, 0x43, 0x75, 0x2e, 0xd4, 0x6a, 0x8f}; - uint8_t bytesprops2[] = {0x7a, 0x5b, 0x54}; - uint8_t bytesprops3[] = {0x84, 0x28, 0x3, 0x4b, 0x4e, 0x9c, 0x70, 0x8e, 0x29, 0xfa, 0xf6, 0x6f}; - uint8_t bytesprops4[] = {0x94, 0xad, 0x84, 0xab, 0x1, 0xe8, 0xd, 0x66, 0xf3, 0xa2, 0x6e, 0x58, 0x88, 0x17}; - uint8_t bytesprops5[] = {0xb8, 0xfe, 0xc5, 0x82, 0xdf, 0x4c, 0x4e, 0x16, 0xd9, 0xd4, 0xb1, 0xd2, 0x67}; - uint8_t bytesprops6[] = {0x94, 0x9f, 0x26, 0x50, 0x18, 0x6, 0x84, 0xb1, 0x78, 0xb6, 0x48, 0x5}; - uint8_t bytesprops8[] = {0x8d, 0x38, 0xf3, 0xe3, 0x66, 0xe5, 0x6d}; - uint8_t bytesprops7[] = {0xee, 0xc0, 0x54, 0xe, 0xfa, 0xab, 0x72, 0x21, 0xd0, 0x13, 0x2b, - 0xd6, 0xcf, 0xe6, 0xd9, 0x53, 0x6a, 0x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c, 0xa3, 0x52, 0x70, 0x6a, 0x50, 0x45, 0xe1, 0x2f, 0x3a, + 0x1b, 0x0, 0x16, 0xe0, 0xa2, 0x6b, 0xea, 0x5e, 0x6b, 0xc2, 0x13, 0x9d, 0xa, 0x14, 0xe4, 0xd8, 0xea, + 0xa0, 0x2e, 0x6f, 0x15, 0x72, 0xdb, 0x11, 0x17}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xd8, 0x3d}; + uint8_t bytesprops1[] = {0x4f, 0x43, 0x8a, 0xce, 0xef, 0xf, 0x9f, 0x1a, + 0xad, 0xdd, 0xfd, 0xdc, 0x47, 0xf0, 0x95, 0xb3}; + uint8_t bytesprops2[] = {0xda, 0xf}; + uint8_t bytesprops3[] = {0x10, 0xef, 0xcd, 0x75, 0x6b, 0xd8, 0xc8, 0xe1, 0x52}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28332}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25126}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23632}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops7}, .v = {7, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1412}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11196}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 164}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21466}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7448}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7595}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9170}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe4, 0x9, 0x5c, 0x7c, 0x39, 0x70, 0xb1, 0x63, 0x59, 0xc9}; - uint8_t byteswillprops1[] = {0}; - uint8_t byteswillprops2[] = {0x62, 0x60, 0x11, 0xa3, 0x9b, 0xa3, 0xb0, 0xed, 0x65, 0x79, 0x7e, 0xa5, - 0x9, 0xa0, 0x3, 0xec, 0x55, 0x7a, 0xe4, 0x67, 0xa7, 0xb8, 0x3d}; - uint8_t byteswillprops3[] = {0x8b, 0x69}; - uint8_t byteswillprops4[] = {0x5d, 0x59, 0x67, 0x76, 0xb0, 0x47, 0xe1, 0xb}; - uint8_t byteswillprops5[] = {0x99, 0x12, 0xad, 0x95, 0x90, 0x55}; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops1[] = {0x10, 0xe5, 0x9d, 0xca, 0xdb, 0x72, 0xfb, 0xee, 0x9, 0x80}; + uint8_t byteswillprops3[] = {0xff, 0xcb, 0xcc, 0x29, 0x44, 0xd2, 0xa4, 0x7c, 0x2, 0x2e}; + uint8_t byteswillprops2[] = {0x2a, 0xf5, 0xe6, 0x8c, 0x8b, 0x73, 0xef, 0xa1}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4144}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20879}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28424}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9949}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12502}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21847}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22456}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31508}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {8, (char*)&byteswillprops2}, .v = {10, (char*)&byteswillprops3}}}}, }; - lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x95, 0xc7, 0x4f, 0x8a, 0x56, 0x73, 0xe0, 0x26, 0x5f, 0xca, 0xb4, 0x16, 0x94, - 0xf1, 0x47, 0x33, 0xe8, 0xc4, 0x29, 0x24, 0x7e, 0xd8, 0x9d, 0xb5, 0xb0, 0x21}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5f, 0xf1, 0x14, 0x56, 0x39, 0x37, 0xef, 0xce, 0xaa, 0x43, 0x8, - 0xcf, 0x39, 0xaa, 0x8d, 0x1d, 0x33, 0xd8, 0xea, 0x14, 0x8d}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8a, 0xa2, 0x3f, 0x82, 0x9f, 0x8d, 0x3f, 0x9a, 0x2b, 0x14, 0x42, + 0xf6, 0xf9, 0x7f, 0x31, 0x3b, 0x2d, 0xf4, 0x84, 0x57, 0x3b}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7e, 0x6a, 0xf5, 0xff}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 7; - uint8_t client_id_bytes[] = {0x47, 0x5c, 0x6b, 0x59, 0x1, 0xf2}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 9554; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf7, 0xf, 0x3b, 0x7e, 0xf6, 0xe2}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x8c, 0xa3, 0x52, 0x70, 0x6a, 0x50, 0x45, 0xe1, 0x2f, 0x3a, 0x1b}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xb6, 0xc1, 0xcc, 0xb8, 0xf, 0xfb, 0xef, 0xdd, 0x47, 0xbc, 0x2c, 0xcf, - 0xb5, 0xde, 0xa9, 0x12, 0x61, 0xa6, 0x9c, 0xb4, 0x7, 0xfd, 0xf2}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe0, 0xa2, 0x6b, 0xea, 0x5e, 0x6b, 0xc2, 0x13, 0x9d, 0xa, 0x14, + 0xe4, 0xd8, 0xea, 0xa0, 0x2e, 0x6f, 0x15, 0x72, 0xdb, 0x11, 0x17}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9516,249 +9202,461 @@ TEST(Connect5QCTest, Encode23) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "{?~\139\226tEG\tA\FSI\236\230e<\SOH", _password = Just -// "\203)t\136\")\169\SID\246\237\158\241\231\162>!\140", _lastWill = Nothing, _cleanSession = True, _keepAlive = 8810, -// _connID = "n\253\208>\v\187pU\197NY\228\&5w!\237\179\179\SI\213", _properties = [PropCorrelationData -// "B\236?\nv",PropRetainAvailable 20,PropRetainAvailable 236,PropCorrelationData "",PropCorrelationData -// "\194\208\144\170\133[{\239\209\177\248\176\210\142\SUB\202\181\170",PropMessageExpiryInterval -// 17662,PropAuthenticationData "\203\150S\135\&7S",PropSessionExpiryInterval 20993,PropRequestProblemInformation -// 178,PropServerKeepAlive 2714,PropReasonString "`\141\230\192 \243p\233,b\nP\DC4\199\n}"]} +// ConnectRequest {_username = Just "\184\n\192\249\GS\b\140\182\DC3\152 }=&7\DC4\181k", _password = Just +// "\150/\SO\220", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\r\243Owl", _willMsg = +// "\251\re\178 \ACK\242Y2h\FS\DEL\160X\254\171\133\v\217\160\DC2p\DC1\207\EM", _willProps = [PropWillDelayInterval +// 123,PropRetainAvailable 53,PropResponseTopic "\fR\199\&6Yt\188\165N<\137\165\193",PropWillDelayInterval +// 20706,PropMaximumQoS 251,PropResponseTopic "\205\163\&8\161\SI\150R\161\226e\162\SI",PropResponseTopic +// "\141\GS\235t0\221_\166\219\b<\236\175\180/\196",PropSessionExpiryInterval 4095,PropPayloadFormatIndicator +// 152,PropMessageExpiryInterval 1317,PropCorrelationData "&\176",PropWillDelayInterval 218]}), _cleanSession = True, +// _keepAlive = 22347, _connID = "\148/\140]", _properties = [PropMessageExpiryInterval +// 26942,PropWildcardSubscriptionAvailable 33,PropWillDelayInterval 28021,PropServerReference +// "\182k\169\204\223\196\170\197\215\199\193KZ\234hw\a\NUL\r\153\184\245\a\DC3H1\EOT",PropResponseInformation +// "D\143",PropSubscriptionIdentifier 5,PropRequestResponseInformation 152,PropAuthenticationMethod +// "\131\r\194\180",PropSubscriptionIdentifierAvailable 165,PropWillDelayInterval 18492,PropSharedSubscriptionAvailable +// 99,PropMessageExpiryInterval 7198]} TEST(Connect5QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x97, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x22, 0x6a, 0x4f, 0x9, 0x0, - 0x5, 0x42, 0xec, 0x3f, 0xa, 0x76, 0x25, 0x14, 0x25, 0xec, 0x9, 0x0, 0x0, 0x9, 0x0, 0x12, - 0xc2, 0xd0, 0x90, 0xaa, 0x85, 0x5b, 0x7b, 0xef, 0xd1, 0xb1, 0xf8, 0xb0, 0xd2, 0x8e, 0x1a, 0xca, - 0xb5, 0xaa, 0x2, 0x0, 0x0, 0x44, 0xfe, 0x16, 0x0, 0x6, 0xcb, 0x96, 0x53, 0x87, 0x37, 0x53, - 0x11, 0x0, 0x0, 0x52, 0x1, 0x17, 0xb2, 0x13, 0xa, 0x9a, 0x1f, 0x0, 0x10, 0x60, 0x8d, 0xe6, - 0xc0, 0x20, 0xf3, 0x70, 0xe9, 0x2c, 0x62, 0xa, 0x50, 0x14, 0xc7, 0xa, 0x7d, 0x0, 0x14, 0x6e, - 0xfd, 0xd0, 0x3e, 0xb, 0xbb, 0x70, 0x55, 0xc5, 0x4e, 0x59, 0xe4, 0x35, 0x77, 0x21, 0xed, 0xb3, - 0xb3, 0xf, 0xd5, 0x0, 0x11, 0x7b, 0x3f, 0x7e, 0x8b, 0xe2, 0x74, 0x45, 0x47, 0x9, 0x41, 0x1c, - 0x49, 0xec, 0xe6, 0x65, 0x3c, 0x1, 0x0, 0x12, 0xcb, 0x29, 0x74, 0x88, 0x22, 0x29, 0xa9, 0xf, - 0x44, 0xf6, 0xed, 0x9e, 0xf1, 0xe7, 0xa2, 0x3e, 0x21, 0x8c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x42, 0xec, 0x3f, 0xa, 0x76}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0xc2, 0xd0, 0x90, 0xaa, 0x85, 0x5b, 0x7b, 0xef, 0xd1, - 0xb1, 0xf8, 0xb0, 0xd2, 0x8e, 0x1a, 0xca, 0xb5, 0xaa}; - uint8_t bytesprops3[] = {0xcb, 0x96, 0x53, 0x87, 0x37, 0x53}; - uint8_t bytesprops4[] = {0x60, 0x8d, 0xe6, 0xc0, 0x20, 0xf3, 0x70, 0xe9, - 0x2c, 0x62, 0xa, 0x50, 0x14, 0xc7, 0xa, 0x7d}; + uint8_t pkt[] = { + 0x10, 0xec, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x57, 0x4b, 0x48, 0x2, 0x0, 0x0, 0x69, 0x3e, + 0x28, 0x21, 0x18, 0x0, 0x0, 0x6d, 0x75, 0x1c, 0x0, 0x1b, 0xb6, 0x6b, 0xa9, 0xcc, 0xdf, 0xc4, 0xaa, 0xc5, 0xd7, + 0xc7, 0xc1, 0x4b, 0x5a, 0xea, 0x68, 0x77, 0x7, 0x0, 0xd, 0x99, 0xb8, 0xf5, 0x7, 0x13, 0x48, 0x31, 0x4, 0x1a, + 0x0, 0x2, 0x44, 0x8f, 0xb, 0x5, 0x19, 0x98, 0x15, 0x0, 0x4, 0x83, 0xd, 0xc2, 0xb4, 0x29, 0xa5, 0x18, 0x0, + 0x0, 0x48, 0x3c, 0x2a, 0x63, 0x2, 0x0, 0x0, 0x1c, 0x1e, 0x0, 0x4, 0x94, 0x2f, 0x8c, 0x5d, 0x56, 0x18, 0x0, + 0x0, 0x0, 0x7b, 0x25, 0x35, 0x8, 0x0, 0xd, 0xc, 0x52, 0xc7, 0x36, 0x59, 0x74, 0xbc, 0xa5, 0x4e, 0x3c, 0x89, + 0xa5, 0xc1, 0x18, 0x0, 0x0, 0x50, 0xe2, 0x24, 0xfb, 0x8, 0x0, 0xc, 0xcd, 0xa3, 0x38, 0xa1, 0xf, 0x96, 0x52, + 0xa1, 0xe2, 0x65, 0xa2, 0xf, 0x8, 0x0, 0x10, 0x8d, 0x1d, 0xeb, 0x74, 0x30, 0xdd, 0x5f, 0xa6, 0xdb, 0x8, 0x3c, + 0xec, 0xaf, 0xb4, 0x2f, 0xc4, 0x11, 0x0, 0x0, 0xf, 0xff, 0x1, 0x98, 0x2, 0x0, 0x0, 0x5, 0x25, 0x9, 0x0, + 0x2, 0x26, 0xb0, 0x18, 0x0, 0x0, 0x0, 0xda, 0x0, 0x5, 0xd, 0xf3, 0x4f, 0x77, 0x6c, 0x0, 0x19, 0xfb, 0xd, + 0x65, 0xb2, 0x20, 0x6, 0xf2, 0x59, 0x32, 0x68, 0x1c, 0x7f, 0xa0, 0x58, 0xfe, 0xab, 0x85, 0xb, 0xd9, 0xa0, 0x12, + 0x70, 0x11, 0xcf, 0x19, 0x0, 0x12, 0xb8, 0xa, 0xc0, 0xf9, 0x1d, 0x8, 0x8c, 0xb6, 0x13, 0x98, 0x20, 0x7d, 0x3d, + 0x26, 0x37, 0x14, 0xb5, 0x6b, 0x0, 0x4, 0x96, 0x2f, 0xe, 0xdc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb6, 0x6b, 0xa9, 0xcc, 0xdf, 0xc4, 0xaa, 0xc5, 0xd7, 0xc7, 0xc1, 0x4b, 0x5a, 0xea, + 0x68, 0x77, 0x7, 0x0, 0xd, 0x99, 0xb8, 0xf5, 0x7, 0x13, 0x48, 0x31, 0x4}; + uint8_t bytesprops1[] = {0x44, 0x8f}; + uint8_t bytesprops2[] = {0x83, 0xd, 0xc2, 0xb4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17662}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20993}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2714}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26942}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28021}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18492}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7198}}, + }; + + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xc, 0x52, 0xc7, 0x36, 0x59, 0x74, 0xbc, 0xa5, 0x4e, 0x3c, 0x89, 0xa5, 0xc1}; + uint8_t byteswillprops1[] = {0xcd, 0xa3, 0x38, 0xa1, 0xf, 0x96, 0x52, 0xa1, 0xe2, 0x65, 0xa2, 0xf}; + uint8_t byteswillprops2[] = {0x8d, 0x1d, 0xeb, 0x74, 0x30, 0xdd, 0x5f, 0xa6, + 0xdb, 0x8, 0x3c, 0xec, 0xaf, 0xb4, 0x2f, 0xc4}; + uint8_t byteswillprops3[] = {0x26, 0xb0}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 123}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20706}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4095}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1317}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 218}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd, 0xf3, 0x4f, 0x77, 0x6c}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfb, 0xd, 0x65, 0xb2, 0x20, 0x6, 0xf2, 0x59, 0x32, 0x68, 0x1c, 0x7f, 0xa0, + 0x58, 0xfe, 0xab, 0x85, 0xb, 0xd9, 0xa0, 0x12, 0x70, 0x11, 0xcf, 0x19}; + lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 8810; - uint8_t client_id_bytes[] = {0x6e, 0xfd, 0xd0, 0x3e, 0xb, 0xbb, 0x70, 0x55, 0xc5, 0x4e, - 0x59, 0xe4, 0x35, 0x77, 0x21, 0xed, 0xb3, 0xb3, 0xf, 0xd5}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.keep_alive = 22347; + uint8_t client_id_bytes[] = {0x94, 0x2f, 0x8c, 0x5d}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x7b, 0x3f, 0x7e, 0x8b, 0xe2, 0x74, 0x45, 0x47, 0x9, - 0x41, 0x1c, 0x49, 0xec, 0xe6, 0x65, 0x3c, 0x1}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb8, 0xa, 0xc0, 0xf9, 0x1d, 0x8, 0x8c, 0xb6, 0x13, + 0x98, 0x20, 0x7d, 0x3d, 0x26, 0x37, 0x14, 0xb5, 0x6b}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xcb, 0x29, 0x74, 0x88, 0x22, 0x29, 0xa9, 0xf, 0x44, - 0xf6, 0xed, 0x9e, 0xf1, 0xe7, 0xa2, 0x3e, 0x21, 0x8c}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x96, 0x2f, 0xe, 0xdc}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\132\241o\219m\247lL]\193i\175", _password = Just "\CANv\229k\211\205", _lastWill = -// Nothing, _cleanSession = True, _keepAlive = 7935, _connID = "\ETB\208H\169\248J\183R\169p\FS\190\DEL\182~\SYN", -// _properties = [PropResponseTopic -// "i*\133\206UW\139\190%\GS\165k\201\235\SUB6\SI\144_\163\253\202\213\166\195\142b\129",PropTopicAlias -// 10431,PropSharedSubscriptionAvailable 196,PropRequestResponseInformation 254,PropRetainAvailable -// 177,PropRetainAvailable 212,PropSubscriptionIdentifierAvailable 115,PropMessageExpiryInterval -// 29471,PropSubscriptionIdentifierAvailable 136,PropMessageExpiryInterval 6213,PropSubscriptionIdentifierAvailable -// 83,PropRequestResponseInformation 215,PropUserProperty "\168+0\142;\DC3\NUL\213}\187\n^W\132[MN\234" -// "\165\138\213",PropContentType "-n\146f'\180h\159\250F\157d8$\177\210JU\SO\197",PropCorrelationData -// "",PropServerKeepAlive 30727,PropRequestProblemInformation 223,PropSubscriptionIdentifier 17,PropServerKeepAlive -// 5564,PropWildcardSubscriptionAvailable 12]} +// ConnectRequest {_username = Just "\183\178\ESC", _password = Just "-\203Id", _lastWill = Just (LastWill {_willRetain +// = False, _willQoS = QoS1, _willTopic = +// "oH%\176\195\240\217\234x\176Z\ETX\204\SO\DC3\DEL\138\181\252\US\254\147\218:\146\231\\\144", _willMsg = "n\EM\186", +// _willProps = [PropResponseInformation "f\180\145\218\SYNn\169\151N\138\144\b\145\231\229\185",PropTopicAliasMaximum +// 31420,PropSharedSubscriptionAvailable 113,PropUserProperty "|\148\NAK\DLE\152\232\187\204Q;\203\229y" +// "\197T:g",PropRetainAvailable 161,PropReasonString +// ":\142\205q9J\FSV\NUL\\\199C\166\131\194\183\147/\248#V7K~",PropWildcardSubscriptionAvailable +// 173,PropResponseInformation "\173\182\195\225\129\129",PropCorrelationData +// "\DC2\193\207Q\DLE\151\CAN\131\GS\129\195\144\238\"\ACK\193\196\169S\NAK\223\141\DELg",PropTopicAlias 12500,PropReceiveMaximum +// 14890,PropReceiveMaximum 3217,PropServerKeepAlive 8194,PropReasonString "\184",PropPayloadFormatIndicator +// 210,PropSubscriptionIdentifierAvailable 134,PropResponseInformation +// "\242\217\174[\237\165f6\169\EOT\213\199\197J\228\207",PropServerReference +// "7Q\128\143\234_G\221Q\198\229\\\EOT\166\254\136[\211_\b\199",PropWildcardSubscriptionAvailable 165]}), _cleanSession +// = False, _keepAlive = 10342, _connID = "F/\a\165\170Bk\248\200\ENQ\199\172\&4\128", _properties = [PropUserProperty +// "\RS\ESCZ\205\FS\218\177\250" +// "\198\DC4\DC3\162:\DC4\165B\243\195.\218\FS;\152h\156.\143O\237\176\203\230\&4\197\t}\210",PropReceiveMaximum +// 19041,PropCorrelationData +// "\242\ESC\154\251\US\238\\\191\234$\FS\173\164V\EOT\ETXn\219\151Y\DEL[\227\202\149\177\245\238",PropSubscriptionIdentifierAvailable +// 221,PropResponseTopic +// "\223&\184=>\NULF?\SO\129\141\216\218$\DC3~\250F%=E<\219e'\235\200",PropAssignedClientIdentifier +// "F\176\255\138\130\ENQ\FS1\\@n\218\251\STX",PropRequestProblemInformation 146,PropAuthenticationMethod +// "\210\190\248\ETB>x1'\246*BM\ESC\174W",PropReasonString +// "\217\229\166\165\243\GS\240\181|\143Y\GS\t\169*\US\US\136\135\156W\166\131\145*\130\168'",PropWildcardSubscriptionAvailable +// 143,PropSubscriptionIdentifierAvailable 39,PropMaximumQoS 235,PropWildcardSubscriptionAvailable +// 236,PropMaximumPacketSize 22864,PropUserProperty "\239\ENQ0f" "G\156}\145N\166 +// ]\197\223\a\226\163\200W\147}s\217\EM\145\170|\202\t",PropWildcardSubscriptionAvailable 16,PropTopicAlias 18534]} TEST(Connect5QCTest, Encode27) { uint8_t pkt[] = { - 0x10, 0x84, 0x2, 0x0,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a5, 0xf7, 0x89, 0x58, 0x2, 0xba, 0x3, 0x7c, 0x49, 0xe9, 0x31, 0x38, 0x2d, + 0x1c, 0x0, 0x16, 0xa4, 0x75, 0xfc, 0xb9, 0xd, 0x9e, 0xa2, 0x9, 0x8a, 0xcd, 0x3e, 0x22, 0x6, 0xc1, 0xc4, 0xa9, + 0x53, 0x15, 0xdf, 0x8d, 0x7f, 0x67, 0x23, 0x30, 0xd4, 0x21, 0x3a, 0x2a, 0x21, 0xc, 0x91, 0x13, 0x20, 0x2, 0x1f, + 0x0, 0x1, 0xb8, 0x1, 0xd2, 0x29, 0x86, 0x1a, 0x0, 0x10, 0xf2, 0xd9, 0xae, 0x5b, 0xed, 0xa5, 0x66, 0x36, 0xa9, + 0x4, 0xd5, 0xc7, 0xc5, 0x4a, 0xe4, 0xcf, 0x1c, 0x0, 0x15, 0x37, 0x51, 0x80, 0x8f, 0xea, 0x5f, 0x47, 0xdd, 0x51, + 0xc6, 0xe5, 0x5c, 0x4, 0xa6, 0xfe, 0x88, 0x5b, 0xd3, 0x5f, 0x8, 0xc7, 0x28, 0xa5, 0x0, 0x13, 0xf, 0x6a, 0xb0, + 0x84, 0x72, 0xee, 0xac, 0xb8, 0x72, 0x9e, 0x70, 0x6a, 0x66, 0x1d, 0x9f, 0x37, 0xb9, 0x7f, 0xd3, 0x0, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0xc6, 0x14, 0x13, 0xa2, 0x3a, 0x14, 0xa5, 0x42, 0xf3, 0xc3, 0x2e, 0xda, 0x1c, 0x3b, 0x98, + 0x68, 0x9c, 0x2e, 0x8f, 0x4f, 0xed, 0xb0, 0xcb, 0xe6, 0x34, 0xc5, 0x9, 0x7d, 0xd2}; + uint8_t bytesprops0[] = {0x1e, 0x1b, 0x5a, 0xcd, 0x1c, 0xda, 0xb1, 0xfa}; + uint8_t bytesprops2[] = {0xf2, 0x1b, 0x9a, 0xfb, 0x1f, 0xee, 0x5c, 0xbf, 0xea, 0x24, 0x1c, 0xad, 0xa4, 0x56, + 0x4, 0x3, 0x6e, 0xdb, 0x97, 0x59, 0x7f, 0x5b, 0xe3, 0xca, 0x95, 0xb1, 0xf5, 0xee}; + uint8_t bytesprops3[] = {0xdf, 0x26, 0xb8, 0x3d, 0x3e, 0x0, 0x46, 0x3f, 0xe, 0x81, 0x8d, 0xd8, 0xda, 0x24, + 0x13, 0x7e, 0xfa, 0x46, 0x25, 0x3d, 0x45, 0x3c, 0xdb, 0x65, 0x27, 0xeb, 0xc8}; + uint8_t bytesprops4[] = {0x46, 0xb0, 0xff, 0x8a, 0x82, 0x5, 0x1c, 0x31, 0x5c, 0x40, 0x6e, 0xda, 0xfb, 0x2}; + uint8_t bytesprops5[] = {0xd2, 0xbe, 0xf8, 0x17, 0x3e, 0x78, 0x31, 0x27, 0xf6, 0x2a, 0x42, 0x4d, 0x1b, 0xae, 0x57}; + uint8_t bytesprops6[] = {0xd9, 0xe5, 0xa6, 0xa5, 0xf3, 0x1d, 0xf0, 0xb5, 0x7c, 0x8f, 0x59, 0x1d, 0x9, 0xa9, + 0x2a, 0x1f, 0x1f, 0x88, 0x87, 0x9c, 0x57, 0xa6, 0x83, 0x91, 0x2a, 0x82, 0xa8, 0x27}; + uint8_t bytesprops8[] = {0x47, 0x9c, 0x7d, 0x91, 0x4e, 0xa6, 0x20, 0x5d, 0xc5, 0xdf, 0x7, 0xe2, 0xa3, + 0xc8, 0x57, 0x93, 0x7d, 0x73, 0xd9, 0x19, 0x91, 0xaa, 0x7c, 0xca, 0x9}; + uint8_t bytesprops7[] = {0xef, 0x5, 0x30, 0x66}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {29, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19041}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22864}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops7}, .v = {25, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18534}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc, 0xd1, 0x73, 0x60, 0xf9, 0xa3, 0xd, 0xd6, 0x8b, 0xcd, 0x14}; - uint8_t byteswillprops1[] = {0xee, 0xe6, 0xfb, 0x8e, 0xa0, 0x19, 0xa0, 0x1e, 0x51, 0x21, 0x39, 0x6e, 0x69, 0x2c, 0x4a, - 0x27, 0xaa, 0xf1, 0x25, 0x77, 0x42, 0x94, 0x3f, 0xfa, 0xd0, 0x73, 0xd2, 0xd7, 0xd1}; - uint8_t byteswillprops3[] = {0xe9, 0x41, 0x67, 0xe5, 0x52, 0x3c, 0xbe, 0xc0, 0x56, 0x3, 0xe9, 0x25, 0xa8, - 0x72, 0x67, 0xc2, 0xba, 0x2e, 0x60, 0x4f, 0x56, 0x92, 0xa1, 0x62, 0x95}; - uint8_t byteswillprops2[] = {0xd9, 0x62, 0x39, 0x7, 0x13, 0x31, 0xbf, 0x80, 0x1c, 0x4d, - 0x14, 0xdf, 0x83, 0x55, 0x7, 0x4e, 0x91, 0x44, 0x8f}; - uint8_t byteswillprops4[] = {0xbe, 0x1, 0x5d, 0xf1, 0x18, 0x94, 0x40, 0xf9, 0x96, 0x99, 0x40, 0xaf, 0xf5, 0x7a, - 0xd7, 0xb, 0x0, 0x2a, 0x58, 0x7, 0xd1, 0x47, 0x30, 0x9c, 0x16, 0x75, 0x27}; + uint8_t byteswillprops0[] = {0xce, 0xa8, 0xa7, 0x3b, 0xe8, 0x8c, 0xce, 0x2c, 0x91, 0x90, 0x7c, 0xc, 0xec}; + uint8_t byteswillprops1[] = {0x11, 0x4f, 0xa5, 0x4f, 0x8f, 0x22, 0xa5, 0xfe, 0xa5, 0xf7, 0x89, + 0x58, 0x2, 0xba, 0x3, 0x7c, 0x49, 0xe9, 0x31, 0x38, 0x2d}; + uint8_t byteswillprops2[] = {0xa4, 0x75, 0xfc, 0xb9, 0xd, 0x9e, 0xa2, 0x9, 0x8a, 0xcd, 0x3e, + 0x22, 0x6, 0xc1, 0xc4, 0xa9, 0x53, 0x15, 0xdf, 0x8d, 0x7f, 0x67}; + uint8_t byteswillprops3[] = {0xb8}; + uint8_t byteswillprops4[] = {0xf2, 0xd9, 0xae, 0x5b, 0xed, 0xa5, 0x66, 0x36, + 0xa9, 0x4, 0xd5, 0xc7, 0xc5, 0x4a, 0xe4, 0xcf}; + uint8_t byteswillprops5[] = {0x37, 0x51, 0x80, 0x8f, 0xea, 0x5f, 0x47, 0xdd, 0x51, 0xc6, 0xe5, + 0x5c, 0x4, 0xa6, 0xfe, 0x88, 0x5b, 0xd3, 0x5f, 0x8, 0xc7}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24417}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17524}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20187}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26133}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {19, (char*)&byteswillprops2}, .v = {25, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24125}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22673}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4017}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12500}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14890}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3217}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8194}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 165}}, }; - lwmqtt_properties_t willprops = {11, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x27, 0x1, 0x8d, 0x4d}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc7, 0x49, 0x9, 0x9b, 0x1, 0x67, 0x87, 0x2c, 0xc8, 0x46, 0x87, 0x19, 0x3b, 0xe9, - 0x4a, 0x98, 0x15, 0x1b, 0x44, 0x1a, 0x9, 0xc1, 0x4d, 0x7f, 0xdc, 0x5e, 0xa3, 0xd6}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf, 0x6a, 0xb0, 0x84, 0x72, 0xee, 0xac, 0xb8, 0x72, 0x9e, + 0x70, 0x6a, 0x66, 0x1d, 0x9f, 0x37, 0xb9, 0x7f, 0xd3}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14063; - uint8_t client_id_bytes[] = {0x89, 0xc4, 0x11, 0xe6, 0x22, 0xc7, 0xf9, 0x2c, 0xf1, 0x7, - 0xc, 0xef, 0x9f, 0xdf, 0xaa, 0x4e, 0xf0, 0xf8, 0xb8, 0xac}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 10342; + uint8_t client_id_bytes[] = {0x46, 0x2f, 0x7, 0xa5, 0xaa, 0x42, 0x6b, 0xf8, 0xc8, 0x5, 0xc7, 0xac, 0x34, 0x80}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xbe, 0xfe, 0xb, 0x47, 0x8c, 0x10, 0x71, 0xce, 0xc7, 0x31, 0xeb, 0x79, 0x87, 0x61, 0x8}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x28, 0x1b, 0x11, 0x34, 0xac, 0x74, 0x48, 0x2f, 0x88, 0xf0, 0xe1}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9865,73 +9805,155 @@ TEST(Connect5QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "%\DC3/-\bG2\192\137\196&\128\209\143\235\SI\201\&6\r\216vK\196dI\195\144G", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\132~x\156KS\246y\137\249\SYN\154%\145\149T\195\188", _willMsg = -// "X\195\&0\237\DC1l\222\ETX\219\&9\128\"\210/\254\243Q\204\169^H", _willProps = [PropServerKeepAlive -// 7936,PropResponseTopic "\202z\237\NULa\195\199"]}), _cleanSession = False, _keepAlive = 9629, _connID = -// "u\226c\130\167Y\128L\255\&1\SI\232\190", _properties = [PropResponseInformation -// "\217f\236\222\208\152\142\202\SOQ\236g\195\DLE\DC2",PropSubscriptionIdentifierAvailable 203,PropReceiveMaximum -// 2798,PropSharedSubscriptionAvailable 222,PropRequestResponseInformation 46,PropTopicAliasMaximum -// 2552,PropAuthenticationData "/\SO8\235}\188\229\156\147}\151^Or",PropTopicAliasMaximum 31519]} +// ConnectRequest {_username = Just "\177,\US\162\249\rU", _password = Just "\186$\184J\CAN:\210T\160t\185\242", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\248\192cB\223\ACK\132s!q\246\236pQ-R", _willMsg = "@\152\ETBp\180{\SI\148\180\&8\r\230\252vY\151]\223/\232&n", +// _willProps = [PropCorrelationData "\178\203fb\158\n\239\218\DC2\164\199\133\164\130\GS\SO\213",PropTopicAliasMaximum +// 32637,PropSharedSubscriptionAvailable 101,PropReasonString "Z|\141~x",PropAuthenticationData +// "{*v\171vl\186\&2\191U\SI\223\170\196\n\129\185\249\246\253Q\EOT\203j",PropRequestProblemInformation +// 201,PropAuthenticationMethod "\\z\201\239\DC3\185\218B\ETB\ETX\237\176\211m\161`",PropRequestProblemInformation +// 115,PropResponseInformation "hY\161m\164\US\221\ETBpI\203;a\223\230\155\NUL\232",PropRequestProblemInformation +// 25,PropPayloadFormatIndicator 245,PropMessageExpiryInterval 23460,PropSessionExpiryInterval 989,PropTopicAlias +// 10792,PropMaximumPacketSize 20351,PropSharedSubscriptionAvailable 225]}), _cleanSession = True, _keepAlive = 1497, +// _connID = "\ENQfB\178\EOT\DLE\139\233\169H\233\GS[", _properties = [PropResponseTopic +// "}\204\DC2B\159\NAK\157r\222[;\150\193UE\183\nIE\176\158\129\192,\158\&1\188\SUB\193",PropTopicAlias +// 19059,PropAuthenticationMethod "=Gp\247\239\214A\203\133\255\133ss@\249&|\133\178@\244\236/Z\190",PropUserProperty +// "\138\ACK\167\217\209F\179\232\164\GSw\209rgT\NAKQ\193\224\178\176M" +// ")\246\DLE;\207\192BLHX\239\160l\DELp\136\f^_F=\143",PropMaximumPacketSize 14420,PropSessionExpiryInterval +// 695,PropServerReference "{1\174\242-\131\182\SO\156\193'\EOTY\DEL;\131_",PropRequestProblemInformation +// 218,PropSubscriptionIdentifier 20,PropMessageExpiryInterval 757,PropCorrelationData +// "\170\RS\210\161H\195\SO\EM\224\247\251\211\143\153G\DLE(\150\202",PropSessionExpiryInterval +// 10859,PropPayloadFormatIndicator 138,PropRequestProblemInformation 9,PropUserProperty +// "\166\140\&0\t\245~\STX\156N\157,_I\RS;\141" +// "\128\&8\229\128\&4?h\145\a\128\&25\129",PropSubscriptionIdentifierAvailable 71,PropSubscriptionIdentifierAvailable +// 24,PropSubscriptionIdentifier 22,PropTopicAlias 25715,PropRequestProblemInformation 58,PropRequestProblemInformation +// 211,PropMessageExpiryInterval 15137,PropTopicAlias 18099]} TEST(Connect5QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0xa3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xa4, 0x25, 0x9d, 0x32, 0x1a, 0x0, 0xf, - 0xd9, 0x66, 0xec, 0xde, 0xd0, 0x98, 0x8e, 0xca, 0xe, 0x51, 0xec, 0x67, 0xc3, 0x10, 0x12, 0x29, 0xcb, - 0x21, 0xa, 0xee, 0x2a, 0xde, 0x19, 0x2e, 0x22, 0x9, 0xf8, 0x16, 0x0, 0xe, 0x2f, 0xe, 0x38, 0xeb, - 0x7d, 0xbc, 0xe5, 0x9c, 0x93, 0x7d, 0x97, 0x5e, 0x4f, 0x72, 0x22, 0x7b, 0x1f, 0x0, 0xd, 0x75, 0xe2, - 0x63, 0x82, 0xa7, 0x59, 0x80, 0x4c, 0xff, 0x31, 0xf, 0xe8, 0xbe, 0xd, 0x13, 0x1f, 0x0, 0x8, 0x0, - 0x7, 0xca, 0x7a, 0xed, 0x0, 0x61, 0xc3, 0xc7, 0x0, 0x12, 0x84, 0x7e, 0x78, 0x9c, 0x4b, 0x53, 0xf6, - 0x79, 0x89, 0xf9, 0x16, 0x9a, 0x25, 0x91, 0x95, 0x54, 0xc3, 0xbc, 0x0, 0x15, 0x58, 0xc3, 0x30, 0xed, - 0x11, 0x6c, 0xde, 0x3, 0xdb, 0x39, 0x80, 0x22, 0xd2, 0x2f, 0xfe, 0xf3, 0x51, 0xcc, 0xa9, 0x5e, 0x48, - 0x0, 0x1c, 0x25, 0x13, 0x2f, 0x2d, 0x8, 0x47, 0x32, 0xc0, 0x89, 0xc4, 0x26, 0x80, 0xd1, 0x8f, 0xeb, - 0xf, 0xc9, 0x36, 0xd, 0xd8, 0x76, 0x4b, 0xc4, 0x64, 0x49, 0xc3, 0x90, 0x47}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd9, 0x66, 0xec, 0xde, 0xd0, 0x98, 0x8e, 0xca, 0xe, 0x51, 0xec, 0x67, 0xc3, 0x10, 0x12}; - uint8_t bytesprops1[] = {0x2f, 0xe, 0x38, 0xeb, 0x7d, 0xbc, 0xe5, 0x9c, 0x93, 0x7d, 0x97, 0x5e, 0x4f, 0x72}; + uint8_t pkt[] = { + 0x10, 0xcb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x5, 0xd9, 0xed, 0x1, 0x8, 0x0, 0x1d, 0x7d, + 0xcc, 0x12, 0x42, 0x9f, 0x15, 0x9d, 0x72, 0xde, 0x5b, 0x3b, 0x96, 0xc1, 0x55, 0x45, 0xb7, 0xa, 0x49, 0x45, 0xb0, + 0x9e, 0x81, 0xc0, 0x2c, 0x9e, 0x31, 0xbc, 0x1a, 0xc1, 0x23, 0x4a, 0x73, 0x15, 0x0, 0x19, 0x3d, 0x47, 0x70, 0xf7, + 0xef, 0xd6, 0x41, 0xcb, 0x85, 0xff, 0x85, 0x73, 0x73, 0x40, 0xf9, 0x26, 0x7c, 0x85, 0xb2, 0x40, 0xf4, 0xec, 0x2f, + 0x5a, 0xbe, 0x26, 0x0, 0x16, 0x8a, 0x6, 0xa7, 0xd9, 0xd1, 0x46, 0xb3, 0xe8, 0xa4, 0x1d, 0x77, 0xd1, 0x72, 0x67, + 0x54, 0x15, 0x51, 0xc1, 0xe0, 0xb2, 0xb0, 0x4d, 0x0, 0x16, 0x29, 0xf6, 0x10, 0x3b, 0xcf, 0xc0, 0x42, 0x4c, 0x48, + 0x58, 0xef, 0xa0, 0x6c, 0x7f, 0x70, 0x88, 0xc, 0x5e, 0x5f, 0x46, 0x3d, 0x8f, 0x27, 0x0, 0x0, 0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4, 0xa, 0x81, 0xb9, 0xf9, + 0xf6, 0xfd, 0x51, 0x4, 0xcb, 0x6a, 0x17, 0xc9, 0x15, 0x0, 0x10, 0x5c, 0x7a, 0xc9, 0xef, 0x13, 0xb9, 0xda, 0x42, + 0x17, 0x3, 0xed, 0xb0, 0xd3, 0x6d, 0xa1, 0x60, 0x17, 0x73, 0x1a, 0x0, 0x12, 0x68, 0x59, 0xa1, 0x6d, 0xa4, 0x1f, + 0xdd, 0x17, 0x70, 0x49, 0xcb, 0x3b, 0x61, 0xdf, 0xe6, 0x9b, 0x0, 0xe8, 0x17, 0x19, 0x1, 0xf5, 0x2, 0x0, 0x0, + 0x5b, 0xa4, 0x11, 0x0, 0x0, 0x3, 0xdd, 0x23, 0x2a, 0x28, 0x27, 0x0, 0x0, 0x4f, 0x7f, 0x2a, 0xe1, 0x0, 0x10, + 0xf8, 0xc0, 0x63, 0x42, 0xdf, 0x6, 0x84, 0x73, 0x21, 0x71, 0xf6, 0xec, 0x70, 0x51, 0x2d, 0x52, 0x0, 0x16, 0x40, + 0x98, 0x17, 0x70, 0xb4, 0x7b, 0xf, 0x94, 0xb4, 0x38, 0xd, 0xe6, 0xfc, 0x76, 0x59, 0x97, 0x5d, 0xdf, 0x2f, 0xe8, + 0x26, 0x6e, 0x0, 0x7, 0xb1, 0x2c, 0x1f, 0xa2, 0xf9, 0xd, 0x55, 0x0, 0xc, 0xba, 0x24, 0xb8, 0x4a, 0x18, 0x3a, + 0xd2, 0x54, 0xa0, 0x74, 0xb9, 0xf2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7d, 0xcc, 0x12, 0x42, 0x9f, 0x15, 0x9d, 0x72, 0xde, 0x5b, 0x3b, 0x96, 0xc1, 0x55, 0x45, + 0xb7, 0xa, 0x49, 0x45, 0xb0, 0x9e, 0x81, 0xc0, 0x2c, 0x9e, 0x31, 0xbc, 0x1a, 0xc1}; + uint8_t bytesprops1[] = {0x3d, 0x47, 0x70, 0xf7, 0xef, 0xd6, 0x41, 0xcb, 0x85, 0xff, 0x85, 0x73, 0x73, + 0x40, 0xf9, 0x26, 0x7c, 0x85, 0xb2, 0x40, 0xf4, 0xec, 0x2f, 0x5a, 0xbe}; + uint8_t bytesprops3[] = {0x29, 0xf6, 0x10, 0x3b, 0xcf, 0xc0, 0x42, 0x4c, 0x48, 0x58, 0xef, + 0xa0, 0x6c, 0x7f, 0x70, 0x88, 0xc, 0x5e, 0x5f, 0x46, 0x3d, 0x8f}; + uint8_t bytesprops2[] = {0x8a, 0x6, 0xa7, 0xd9, 0xd1, 0x46, 0xb3, 0xe8, 0xa4, 0x1d, 0x77, + 0xd1, 0x72, 0x67, 0x54, 0x15, 0x51, 0xc1, 0xe0, 0xb2, 0xb0, 0x4d}; + uint8_t bytesprops4[] = {0x7b, 0x31, 0xae, 0xf2, 0x2d, 0x83, 0xb6, 0xe, 0x9c, + 0xc1, 0x27, 0x4, 0x59, 0x7f, 0x3b, 0x83, 0x5f}; + uint8_t bytesprops5[] = {0xaa, 0x1e, 0xd2, 0xa1, 0x48, 0xc3, 0xe, 0x19, 0xe0, 0xf7, + 0xfb, 0xd3, 0x8f, 0x99, 0x47, 0x10, 0x28, 0x96, 0xca}; + uint8_t bytesprops7[] = {0x80, 0x38, 0xe5, 0x80, 0x34, 0x3f, 0x68, 0x91, 0x7, 0x80, 0x32, 0x35, 0x81}; + uint8_t bytesprops6[] = {0xa6, 0x8c, 0x30, 0x9, 0xf5, 0x7e, 0x2, 0x9c, + 0x4e, 0x9d, 0x2c, 0x5f, 0x49, 0x1e, 0x3b, 0x8d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2798}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2552}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31519}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19059}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops2}, .v = {22, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14420}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 695}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 757}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10859}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops6}, .v = {13, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25715}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15137}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18099}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xca, 0x7a, 0xed, 0x0, 0x61, 0xc3, 0xc7}; + uint8_t byteswillprops0[] = {0xb2, 0xcb, 0x66, 0x62, 0x9e, 0xa, 0xef, 0xda, 0x12, + 0xa4, 0xc7, 0x85, 0xa4, 0x82, 0x1d, 0xe, 0xd5}; + uint8_t byteswillprops1[] = {0x5a, 0x7c, 0x8d, 0x7e, 0x78}; + uint8_t byteswillprops2[] = {0x7b, 0x2a, 0x76, 0xab, 0x76, 0x6c, 0xba, 0x32, 0xbf, 0x55, 0xf, 0xdf, + 0xaa, 0xc4, 0xa, 0x81, 0xb9, 0xf9, 0xf6, 0xfd, 0x51, 0x4, 0xcb, 0x6a}; + uint8_t byteswillprops3[] = {0x5c, 0x7a, 0xc9, 0xef, 0x13, 0xb9, 0xda, 0x42, + 0x17, 0x3, 0xed, 0xb0, 0xd3, 0x6d, 0xa1, 0x60}; + uint8_t byteswillprops4[] = {0x68, 0x59, 0xa1, 0x6d, 0xa4, 0x1f, 0xdd, 0x17, 0x70, + 0x49, 0xcb, 0x3b, 0x61, 0xdf, 0xe6, 0x9b, 0x0, 0xe8}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7936}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32637}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23460}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 989}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10792}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20351}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 225}}, }; - lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x84, 0x7e, 0x78, 0x9c, 0x4b, 0x53, 0xf6, 0x79, 0x89, - 0xf9, 0x16, 0x9a, 0x25, 0x91, 0x95, 0x54, 0xc3, 0xbc}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x58, 0xc3, 0x30, 0xed, 0x11, 0x6c, 0xde, 0x3, 0xdb, 0x39, 0x80, - 0x22, 0xd2, 0x2f, 0xfe, 0xf3, 0x51, 0xcc, 0xa9, 0x5e, 0x48}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf8, 0xc0, 0x63, 0x42, 0xdf, 0x6, 0x84, 0x73, + 0x21, 0x71, 0xf6, 0xec, 0x70, 0x51, 0x2d, 0x52}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x40, 0x98, 0x17, 0x70, 0xb4, 0x7b, 0xf, 0x94, 0xb4, 0x38, 0xd, + 0xe6, 0xfc, 0x76, 0x59, 0x97, 0x5d, 0xdf, 0x2f, 0xe8, 0x26, 0x6e}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 9629; - uint8_t client_id_bytes[] = {0x75, 0xe2, 0x63, 0x82, 0xa7, 0x59, 0x80, 0x4c, 0xff, 0x31, 0xf, 0xe8, 0xbe}; + opts.clean_session = true; + opts.keep_alive = 1497; + uint8_t client_id_bytes[] = {0x5, 0x66, 0x42, 0xb2, 0x4, 0x10, 0x8b, 0xe9, 0xa9, 0x48, 0xe9, 0x1d, 0x5b}; lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x25, 0x13, 0x2f, 0x2d, 0x8, 0x47, 0x32, 0xc0, 0x89, 0xc4, 0x26, 0x80, 0xd1, 0x8f, - 0xeb, 0xf, 0xc9, 0x36, 0xd, 0xd8, 0x76, 0x4b, 0xc4, 0x64, 0x49, 0xc3, 0x90, 0x47}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb1, 0x2c, 0x1f, 0xa2, 0xf9, 0xd, 0x55}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0xba, 0x24, 0xb8, 0x4a, 0x18, 0x3a, 0xd2, 0x54, 0xa0, 0x74, 0xb9, 0xf2}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9940,187 +9962,94 @@ TEST(Connect5QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "A\215\192x\237\STX\181-", _password = Just "\148", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "\222\FS4[\199l\134\149\221T_=\130G\192\&4\179\205S>O", _willMsg -// = "\244\177\ETB\252l\159# _\EM\n\239X\ETB\156m",PropSessionExpiryInterval -// 3800,PropAuthenticationData -// "\246\198\195\DEL\241\DEL\251FU\136\141\144\"\EMg>Cm\183\152\f\225s\242\152p\207#\161\177",PropSharedSubscriptionAvailable -// 89,PropServerReference "\130\b\168",PropCorrelationData "k\SOH\215t\247*(!\242\156",PropRetainAvailable -// 112,PropContentType "U\182\229\154\DC4\245\NAK\248Q\250Q}",PropPayloadFormatIndicator 148,PropUserProperty -// "\fB\253\254\159\131\142iMU\198\171\151\ENQne\221`Y\192\"\EM<\158#g" -// "\222\239,1\GS\148\253$\227\254\231+\176\145\241\DC4\206ED\155\163\226\254\199\170:\239\168\248\EM",PropReceiveMaximum -// 13798,PropAuthenticationData -// "\208gik_\195}\f\131\181\GSL\140\132;\168\&81\212\143\225\149\236",PropPayloadFormatIndicator -// 86,PropResponseInformation -// "\201\\\ETX\NUL\171\f\\/\186\159\153\SYN\157y\191_\FS\163\167\144\223?\164\&8\168&",PropRequestProblemInformation -// 86,PropRetainAvailable 121,PropCorrelationData "\f\133\190\191.\r\244&D/$s\226r\a_\246",PropMessageExpiryInterval -// 31196]}), _cleanSession = False, _keepAlive = 4049, _connID = "\209\185#Y\198\163T\169S\ETX", _properties = -// [PropResponseInformation "\133\131\216",PropReasonString "\186\SYN\250F\DC3\144",PropMaximumPacketSize -// 29022,PropMaximumQoS 88,PropAuthenticationMethod "\185f\RSc\195\DC1D\240",PropCorrelationData -// "\254-}\r\"r\GSjh(\223\GS\NAK\242X\t0s\245\184\141\135\128t\225\209JA]d",PropRequestProblemInformation -// 128,PropSubscriptionIdentifier 29,PropSubscriptionIdentifierAvailable 57,PropServerKeepAlive -// 2265,PropAuthenticationData -// "\235\208\NUL\151-zx\DC4\143\US\247\ETX\137\222\254\146M\190\165\183",PropResponseInformation -// "",PropWillDelayInterval 29590,PropTopicAlias 12605,PropSubscriptionIdentifier 0,PropAuthenticationMethod -// "i\234/",PropResponseTopic -// "\222U\134\254\212\202\205$\"\202\138\SOH,\227\220'2\233\162\135l\199D\237",PropAuthenticationData -// "grt\SOH&*\246-\229N\218\167>J\181",PropAuthenticationData -// "\155\161\242\128\197\157\ETX;\229m\238\198\&1",PropTopicAliasMaximum 15991,PropRetainAvailable 101,PropTopicAlias -// 15725,PropAuthenticationMethod "9)^\145;/iwN:\149\251\245y\DC2\ACK\205\191X\250\219\145"]} +// ConnectRequest {_username = Just "\137\131H\193\255h\165\215p\165", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "\194\&8\235\&3\136P\198a", _willMsg = +// "\ESC}E\DLE\133\162\200\238\202o\182\242", _willProps = [PropRetainAvailable 35,PropMessageExpiryInterval +// 27416,PropSubscriptionIdentifier 26,PropRequestProblemInformation 20,PropAssignedClientIdentifier +// "\"\183\DC1>f=\146\206\142\161\211\&2$\155\188\132j\SO\247\144\171 ~&\135?",PropMaximumQoS +// 127,PropRequestResponseInformation 19,PropTopicAliasMaximum 2785,PropMessageExpiryInterval +// 22684,PropPayloadFormatIndicator 23,PropContentType +// "\255\GS\172\&8\203\&9s6\242\NAK$\202\141\228\DLE\161#\231\214k\133z\146\154$\187\&6X'p",PropWillDelayInterval +// 29351,PropTopicAliasMaximum 12599,PropResponseInformation "TR\206rc\219dP\178\a\175\229",PropTopicAliasMaximum +// 21478,PropSubscriptionIdentifier 11,PropRequestProblemInformation 29,PropMaximumQoS 0,PropServerKeepAlive 21983]}), +// _cleanSession = False, _keepAlive = 17930, _connID = "\152@\239K\222UU\185", _properties = [PropWillDelayInterval +// 32405,PropSubscriptionIdentifier 7,PropSubscriptionIdentifier 29,PropSubscriptionIdentifier 16,PropServerReference +// "\130o\165\DC3b\192\165\&3\138",PropReceiveMaximum 10388,PropUserProperty +// "\241?\SI\142\ETB\246N\144\226h\b\140:\FS]Z\207." "Ve5q\156\DEL\131\172\146\NAK\164J,#\SUB%W\NUL",PropContentType +// "\131\DEL\136\139\&60\209\202\142\&1\195\225\186\180\234v\193\136A\ETX|\220\254\bw\NULd\208b\180"]} TEST(Connect5QCTest, Encode29) { uint8_t pkt[] = { - 0x10, 0x86, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0xf, 0xd1, 0xd3, 0x1, 0x1a, 0x0, 0x3, 0x85, - 0x83, 0xd8, 0x1f, 0x0, 0x6, 0xba, 0x16, 0xfa, 0x46, 0x13, 0x90, 0x27, 0x0, 0x0, 0x71, 0x5e, 0x24, 0x58, 0x15, - 0x0, 0x8, 0xb9, 0x66, 0x1e, 0x63, 0xc3, 0x11, 0x44, 0xf0, 0x9, 0x0, 0x1e, 0xfe, 0x2d, 0x7d, 0xd, 0x22, 0x72, - 0x1d, 0x6a, 0x68, 0x28, 0xdf, 0x1d, 0x15, 0xf2, 0x58, 0x9, 0x30, 0x73, 0xf5, 0xb8, 0x8d, 0x87, 0x80, 0x74, 0xe1, - 0xd1, 0x4a, 0x41, 0x5d, 0x64, 0x17, 0x80, 0xb, 0x1d, 0x29, 0x39, 0x13, 0x8, 0xd9, 0x16, 0x0, 0x14, 0xeb, 0xd0, - 0x0, 0x97, 0x2d, 0x7a, 0x78, 0x14, 0x8f, 0x1f, 0xf7, 0x3, 0x89, 0xde, 0xfe, 0x92, 0x4d, 0xbe, 0xa5, 0xb7, 0x1a, - 0x0, 0x0, 0x18, 0x0, 0x0, 0x73, 0x96, 0x23, 0x31, 0x3d, 0xb, 0x0, 0x15, 0x0, 0x3, 0x69, 0xea, 0x2f, 0x8, - 0x0, 0x18, 0xde, 0x55, 0x86, 0xfe, 0xd4, 0xca, 0xcd, 0x24, 0x22, 0xca, 0x8a, 0x1, 0x2c, 0xe3, 0xdc, 0x27, 0x32, - 0xe9, 0xa2, 0x87, 0x6c, 0xc7, 0x44, 0xed,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, 0x31, 0xd4, - 0x8f, 0xe1, 0x95, 0xec, 0x1, 0x56, 0x1a, 0x0, 0x1a, 0xc9, 0x5c, 0x3, 0x0, 0xab, 0xc, 0x5c, 0x2f, 0xba, 0x9f, - 0x99, 0x16, 0x9d, 0x79, 0xbf, 0x5f, 0x1c, 0xa3, 0xa7, 0x90, 0xdf, 0x3f, 0xa4, 0x38, 0xa8, 0x26, 0x17, 0x56, 0x25, - 0x79, 0x9, 0x0, 0x11, 0xc, 0x85, 0xbe, 0xbf, 0x2e, 0xd, 0xf4, 0x26, 0x44, 0x2f, 0x24, 0x73, 0xe2, 0x72, 0x7, - 0x5f, 0xf6, 0x2, 0x0, 0x0, 0x79, 0xdc, 0x0, 0x15, 0xde, 0x1c, 0x34, 0x5b, 0xc7, 0x6c, 0x86, 0x95, 0xdd, 0x54, - 0x5f, 0x3d, 0x82, 0x47, 0xc0, 0x34, 0xb3, 0xcd, 0x53, 0x3e, 0x4f, 0x0, 0xf, 0xf4, 0xb1, 0x17, 0xfc, 0x6c, 0x9f, - 0x23, 0x20, 0x5f, 0x19, 0xa, 0x3c, 0x43, 0x85, 0xa3, 0x0, 0x8, 0x41, 0xd7, 0xc0, 0x78, 0xed, 0x2, 0xb5, 0x2d, - 0x0, 0x1, 0x94}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x85, 0x83, 0xd8}; - uint8_t bytesprops1[] = {0xba, 0x16, 0xfa, 0x46, 0x13, 0x90}; - uint8_t bytesprops2[] = {0xb9, 0x66, 0x1e, 0x63, 0xc3, 0x11, 0x44, 0xf0}; - uint8_t bytesprops3[] = {0xfe, 0x2d, 0x7d, 0xd, 0x22, 0x72, 0x1d, 0x6a, 0x68, 0x28, 0xdf, 0x1d, 0x15, 0xf2, 0x58, - 0x9, 0x30, 0x73, 0xf5, 0xb8, 0x8d, 0x87, 0x80, 0x74, 0xe1, 0xd1, 0x4a, 0x41, 0x5d, 0x64}; - uint8_t bytesprops4[] = {0xeb, 0xd0, 0x0, 0x97, 0x2d, 0x7a, 0x78, 0x14, 0x8f, 0x1f, - 0xf7, 0x3, 0x89, 0xde, 0xfe, 0x92, 0x4d, 0xbe, 0xa5, 0xb7}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0x69, 0xea, 0x2f}; - uint8_t bytesprops7[] = {0xde, 0x55, 0x86, 0xfe, 0xd4, 0xca, 0xcd, 0x24, 0x22, 0xca, 0x8a, 0x1, - 0x2c, 0xe3, 0xdc, 0x27, 0x32, 0xe9, 0xa2, 0x87, 0x6c, 0xc7, 0x44, 0xed}; - uint8_t bytesprops8[] = {0x67, 0x72, 0x74, 0x1, 0x26, 0x2a, 0xf6, 0x2d, 0xe5, 0x4e, 0xda, 0xa7, 0x3e, 0x4a, 0xb5}; - uint8_t bytesprops9[] = {0x9b, 0xa1, 0xf2, 0x80, 0xc5, 0x9d, 0x3, 0x3b, 0xe5, 0x6d, 0xee, 0xc6, 0x31}; - uint8_t bytesprops10[] = {0x39, 0x29, 0x5e, 0x91, 0x3b, 0x2f, 0x69, 0x77, 0x4e, 0x3a, 0x95, - 0xfb, 0xf5, 0x79, 0x12, 0x6, 0xcd, 0xbf, 0x58, 0xfa, 0xdb, 0x91}; + 0x10, 0x98, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x94, 0x46, 0xa, 0x64, 0x18, 0x0, 0x0, 0x7e, 0x95, + 0xb, 0x7, 0xb, 0x1d, 0xb, 0x10, 0x1c, 0x0, 0x9, 0x82, 0x6f, 0xa5, 0x13, 0x62, 0xc0, 0xa5, 0x33, 0x8a, 0x21, + 0x28, 0x94, 0x26, 0x0, 0x12, 0xf1, 0x3f, 0xf, 0x8e, 0x17, 0xf6, 0x4e, 0x90, 0xe2, 0x68, 0x8, 0x8c, 0x3a, 0x1c, + 0x5d, 0x5a, 0xcf, 0x2e, 0x0, 0x12, 0x56, 0x65, 0x35, 0x71, 0x9c, 0x7f, 0x83, 0xac, 0x92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x45, 0x10, 0x85, 0xa2, 0xc8, + 0xee, 0xca, 0x6f, 0xb6, 0xf2, 0x0, 0xa, 0x89, 0x83, 0x48, 0xc1, 0xff, 0x68, 0xa5, 0xd7, 0x70, 0xa5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x82, 0x6f, 0xa5, 0x13, 0x62, 0xc0, 0xa5, 0x33, 0x8a}; + uint8_t bytesprops2[] = {0x56, 0x65, 0x35, 0x71, 0x9c, 0x7f, 0x83, 0xac, 0x92, + 0x15, 0xa4, 0x4a, 0x2c, 0x23, 0x1a, 0x25, 0x57, 0x0}; + uint8_t bytesprops1[] = {0xf1, 0x3f, 0xf, 0x8e, 0x17, 0xf6, 0x4e, 0x90, 0xe2, + 0x68, 0x8, 0x8c, 0x3a, 0x1c, 0x5d, 0x5a, 0xcf, 0x2e}; + uint8_t bytesprops3[] = {0x83, 0x7f, 0x88, 0x8b, 0x36, 0x30, 0xd1, 0xca, 0x8e, 0x31, 0xc3, 0xe1, 0xba, 0xb4, 0xea, + 0x76, 0xc1, 0x88, 0x41, 0x3, 0x7c, 0xdc, 0xfe, 0x8, 0x77, 0x0, 0x64, 0xd0, 0x62, 0xb4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29022}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32405}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2265}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29590}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12605}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15991}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15725}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10388}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xbd, 0x2e, 0xb7, 0x2f, 0xe4, 0xcc, 0x4f, 0x1f, 0xe0, 0x76, 0x61, 0x6a}; - uint8_t byteswillprops0[] = {0xb9, 0x7b, 0x94, 0x19, 0xa6, 0x7b, 0x67, 0x93, 0x4f, 0x18, 0x95, 0xa, 0xa0, 0x3a}; - uint8_t byteswillprops2[] = {0xa6, 0xa0, 0x3a, 0xdf, 0xdd, 0xfd, 0x18, 0x7d, 0x64}; - uint8_t byteswillprops3[] = {0xc3, 0xdc, 0x87, 0xae, 0x71, 0xd7, 0x84}; - uint8_t byteswillprops5[] = {0x9b, 0xf9, 0x27, 0xb, 0x3d, 0x49, 0xa5, 0x1f, 0xa8, 0x3a, 0x7f, 0xe5, 0x75, - 0x97, 0x92, 0xb6, 0xf8, 0xe0, 0x97, 0x3e, 0xef, 0x58, 0x17, 0x9c, 0x6d}; - uint8_t byteswillprops4[] = {0xb4, 0x86, 0x20, 0xfa, 0xdb, 0xaf, 0x9d, 0xc6, 0x6, 0x81, 0x28, 0xa2, 0xd1, - 0xf9, 0x9d, 0x34, 0xb7, 0x48, 0x86, 0x41, 0x2c, 0xd7, 0xf1, 0x10, 0xdf}; - uint8_t byteswillprops6[] = {0xf6, 0xc6, 0xc3, 0x7f, 0xf1, 0x7f, 0xfb, 0x46, 0x55, 0x88, - 0x8d, 0x90, 0x22, 0x19, 0x67, 0x3e, 0x43, 0x6d, 0xb7, 0x98, - 0xc, 0xe1, 0x73, 0xf2, 0x98, 0x70, 0xcf, 0x23, 0xa1, 0xb1}; - uint8_t byteswillprops7[] = {0x82, 0x8, 0xa8}; - uint8_t byteswillprops8[] = {0x6b, 0x1, 0xd7, 0x74, 0xf7, 0x2a, 0x28, 0x21, 0xf2, 0x9c}; - uint8_t byteswillprops9[] = {0x55, 0xb6, 0xe5, 0x9a, 0x14, 0xf5, 0x15, 0xf8, 0x51, 0xfa, 0x51, 0x7d}; - uint8_t byteswillprops11[] = {0xde, 0xef, 0x2c, 0x31, 0x1d, 0x94, 0xfd, 0x24, 0xe3, 0xfe, - 0xe7, 0x2b, 0xb0, 0x91, 0xf1, 0x14, 0xce, 0x45, 0x44, 0x9b, - 0xa3, 0xe2, 0xfe, 0xc7, 0xaa, 0x3a, 0xef, 0xa8, 0xf8, 0x19}; - uint8_t byteswillprops10[] = {0xc, 0x42, 0xfd, 0xfe, 0x9f, 0x83, 0x8e, 0x69, 0x4d, 0x55, 0xc6, 0xab, 0x97, - 0x5, 0x6e, 0x65, 0xdd, 0x60, 0x59, 0xc0, 0x22, 0x19, 0x3c, 0x9e, 0x23, 0x67}; - uint8_t byteswillprops12[] = {0xd0, 0x67, 0x69, 0x6b, 0x5f, 0xc3, 0x7d, 0xc, 0x83, 0xb5, 0x1d, 0x4c, - 0x8c, 0x84, 0x3b, 0xa8, 0x38, 0x31, 0xd4, 0x8f, 0xe1, 0x95, 0xec}; - uint8_t byteswillprops13[] = {0xc9, 0x5c, 0x3, 0x0, 0xab, 0xc, 0x5c, 0x2f, 0xba, 0x9f, 0x99, 0x16, 0x9d, - 0x79, 0xbf, 0x5f, 0x1c, 0xa3, 0xa7, 0x90, 0xdf, 0x3f, 0xa4, 0x38, 0xa8, 0x26}; - uint8_t byteswillprops14[] = {0xc, 0x85, 0xbe, 0xbf, 0x2e, 0xd, 0xf4, 0x26, 0x44, - 0x2f, 0x24, 0x73, 0xe2, 0x72, 0x7, 0x5f, 0xf6}; + uint8_t byteswillprops0[] = {0x22, 0xb7, 0x11, 0x3e, 0x66, 0x3d, 0x92, 0xce, 0x8e, 0xa1, 0xd3, 0x32, 0x24, + 0x9b, 0xbc, 0x84, 0x6a, 0xe, 0xf7, 0x90, 0xab, 0x20, 0x7e, 0x26, 0x87, 0x3f}; + uint8_t byteswillprops1[] = {0xff, 0x1d, 0xac, 0x38, 0xcb, 0x39, 0x73, 0x36, 0xf2, 0x15, + 0x24, 0xca, 0x8d, 0xe4, 0x10, 0xa1, 0x23, 0xe7, 0xd6, 0x6b, + 0x85, 0x7a, 0x92, 0x9a, 0x24, 0xbb, 0x36, 0x58, 0x27, 0x70}; + uint8_t byteswillprops2[] = {0x54, 0x52, 0xce, 0x72, 0x63, 0xdb, 0x64, 0x50, 0xb2, 0x7, 0xaf, 0xe5}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {14, (char*)&byteswillprops0}, .v = {12, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31819}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13095}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {25, (char*)&byteswillprops4}, .v = {25, (char*)&byteswillprops5}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3800}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {26, (char*)&byteswillprops10}, .v = {30, (char*)&byteswillprops11}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13798}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops12}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops13}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&byteswillprops14}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31196}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27416}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2785}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22684}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29351}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12599}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21478}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21983}}, }; - lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xde, 0x1c, 0x34, 0x5b, 0xc7, 0x6c, 0x86, 0x95, 0xdd, 0x54, 0x5f, - 0x3d, 0x82, 0x47, 0xc0, 0x34, 0xb3, 0xcd, 0x53, 0x3e, 0x4f}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf4, 0xb1, 0x17, 0xfc, 0x6c, 0x9f, 0x23, 0x20, - 0x5f, 0x19, 0xa, 0x3c, 0x43, 0x85, 0xa3}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc2, 0x38, 0xeb, 0x33, 0x88, 0x50, 0xc6, 0x61}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1b, 0x7d, 0x45, 0x10, 0x85, 0xa2, 0xc8, 0xee, 0xca, 0x6f, 0xb6, 0xf2}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; @@ -10129,16 +10058,13 @@ TEST(Connect5QCTest, Encode29) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 4049; - uint8_t client_id_bytes[] = {0xd1, 0xb9, 0x23, 0x59, 0xc6, 0xa3, 0x54, 0xa9, 0x53, 0x3}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; + opts.keep_alive = 17930; + uint8_t client_id_bytes[] = {0x98, 0x40, 0xef, 0x4b, 0xde, 0x55, 0x55, 0xb9}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x41, 0xd7, 0xc0, 0x78, 0xed, 0x2, 0xb5, 0x2d}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x89, 0x83, 0x48, 0xc1, 0xff, 0x68, 0xa5, 0xd7, 0x70, 0xa5}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x94}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10147,265 +10073,306 @@ TEST(Connect5QCTest, Encode29) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "\187\252\SOHf\232\ACK\213\245\176\252\195\235\242\&9\182\171\n\a\222HA\SI\186\135\ti", _password = Just -// "P\241&f\236\151C\175\171", _lastWill = Nothing, _cleanSession = True, _keepAlive = 26836, _connID = -// "\203,\DLE\255\EOT\245\146\234>\226\148\240e\135\229\SUB\SUB5", _properties = [PropPayloadFormatIndicator -// 97,PropResponseInformation "&\151E\158\144\186\180k\214'\202\&3\"x%vh=\SI\166\250W\219\202",PropTopicAliasMaximum -// 12587,PropAuthenticationMethod -// "1\180\243\SI\STX\f\188\249\225\155\152\&3)UlV3\155\232\211\SYN\243~3\CAN9",PropUserProperty -// "\199\187@\252\233r\a9\153\213t\251\&4\233\244" -// "\255s\163\178\&2\176\213\172\&9\157\253~,\RSE\CANj6P;B",PropSessionExpiryInterval 31793,PropAuthenticationData -// "\ETBBp\181k\135\193\"\DC2`",PropWildcardSubscriptionAvailable 59,PropSharedSubscriptionAvailable -// 138,PropRequestProblemInformation 105,PropRequestResponseInformation 131,PropSubscriptionIdentifier -// 33,PropWildcardSubscriptionAvailable 16,PropContentType "M\199\154",PropAuthenticationData -// "\ETX8C*\243\140\SI\227\184\129\182\181l",PropReceiveMaximum 5301,PropContentType -// "\157\SI\202\168\a\NAK\196tI\133\218W",PropRequestResponseInformation 173,PropRequestResponseInformation -// 206,PropTopicAlias 31868,PropRequestResponseInformation 241,PropMessageExpiryInterval 22153,PropUserProperty -// "\209\168\230" "B\180\184gppr\GS\182\RS\154p\157\NUL]rj9\SO\249)\SI:"]} +// ConnectRequest {_username = Nothing, _password = Just "E?\ENQ\194E\208h\161\GSV2\189", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\143E\250\224\248%\EOT?\DC3_m\189\NAK\216\163\252\138B\142\RS", +// _willMsg = "|\253OH.E\US*\182\240-;\234\180\237\239\&2\136B\128\241\131", _willProps = [PropRetainAvailable +// 250,PropReasonString "\255G1L\175\209|#Pe",PropRetainAvailable 221,PropReasonString "",PropRetainAvailable 25]}), +// _cleanSession = True, _keepAlive = 6426, _connID = "J\158>Hv\SYNdF\SOH\160)\DC1*'#id\188iaD\192\b\213\152rW\251", +// _properties = [PropMaximumPacketSize 23862,PropSubscriptionIdentifierAvailable 121,PropRequestProblemInformation +// 59,PropAuthenticationData "\145j",PropSubscriptionIdentifierAvailable 234,PropSharedSubscriptionAvailable +// 208,PropMessageExpiryInterval 32125,PropMessageExpiryInterval 22174,PropSessionExpiryInterval 9012,PropReceiveMaximum +// 11528,PropWillDelayInterval 20923,PropResponseTopic "\183\193l\142\ETX\184",PropWildcardSubscriptionAvailable +// 90,PropTopicAliasMaximum 14239,PropSubscriptionIdentifierAvailable 250,PropAuthenticationData +// "IP\153\&8+\148\&3;gc\165A\194`\151\252\232\209\189\SYN#\DC3\179\b\225\158\142\128",PropWildcardSubscriptionAvailable +// 76,PropReasonString "b\244\216\253o\141\240\"\183\238\134l\186f\219g\212c\214\160",PropWildcardSubscriptionAvailable +// 172,PropRequestResponseInformation 106,PropRetainAvailable 24,PropRetainAvailable 49,PropTopicAliasMaximum +// 23078,PropServerKeepAlive 5765,PropSessionExpiryInterval 27036,PropAssignedClientIdentifier +// "\254\232\248\199\165\GS\233z\206}\245@\177\162o@\206\135"]} TEST(Connect5QCTest, Encode30) { uint8_t pkt[] = { - 0x10, 0xa0, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x68, 0xd4, 0xd9, 0x1, 0x1, 0x61, 0x1a, 0x0, - 0x18, 0x26,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 0xb4, 0xb8, 0x67, 0x70, 0x70, 0x72, 0x1d, 0xb6, 0x1e, 0x9a, 0x70, 0x9d, 0x0, 0x5d, 0x72, 0x6a, 0x39, 0xe, - 0xf9, 0x29, 0xf, 0x3a, 0x0, 0x12, 0xcb, 0x2c, 0x10, 0xff, 0x4, 0xf5, 0x92, 0xea, 0x3e, 0xe2, 0x94, 0xf0, 0x65, - 0x87, 0xe5, 0x1a, 0x1a, 0x35, 0x0, 0x1a, 0xbb, 0xfc, 0x1, 0x66, 0xe8, 0x6, 0xd5, 0xf5, 0xb0, 0xfc, 0xc3, 0xeb, - 0xf2, 0x39, 0xb6, 0xab, 0xa, 0x7, 0xde, 0x48, 0x41, 0xf, 0xba, 0x87, 0x9, 0x69, 0x0, 0x9, 0x50, 0xf1, 0x26, - 0x66, 0xec, 0x97, 0x43, 0xaf, 0xab}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x26, 0x97, 0x45, 0x9e, 0x90, 0xba, 0xb4, 0x6b, 0xd6, 0x27, 0xca, 0x33, - 0x22, 0x78, 0x25, 0x76, 0x68, 0x3d, 0xf, 0xa6, 0xfa, 0x57, 0xdb, 0xca}; - uint8_t bytesprops1[] = {0x31, 0xb4, 0xf3, 0xf, 0x2, 0xc, 0xbc, 0xf9, 0xe1, 0x9b, 0x98, 0x33, 0x29, - 0x55, 0x6c, 0x56, 0x33, 0x9b, 0xe8, 0xd3, 0x16, 0xf3, 0x7e, 0x33, 0x18, 0x39}; - uint8_t bytesprops3[] = {0xff, 0x73, 0xa3, 0xb2, 0x32, 0xb0, 0xd5, 0xac, 0x39, 0x9d, 0xfd, - 0x7e, 0x2c, 0x1e, 0x45, 0x18, 0x6a, 0x36, 0x50, 0x3b, 0x42}; - uint8_t bytesprops2[] = {0xc7, 0xbb, 0x40, 0xfc, 0xe9, 0x72, 0x7, 0x39, 0x99, 0xd5, 0x74, 0xfb, 0x34, 0xe9, 0xf4}; - uint8_t bytesprops4[] = {0x17, 0x42, 0x70, 0xb5, 0x6b, 0x87, 0xc1, 0x22, 0x12, 0x60}; - uint8_t bytesprops5[] = {0x4d, 0xc7, 0x9a}; - uint8_t bytesprops6[] = {0x3, 0x38, 0x43, 0x2a, 0xf3, 0x8c, 0xf, 0xe3, 0xb8, 0x81, 0xb6, 0xb5, 0x6c}; - uint8_t bytesprops7[] = {0x9d, 0xf, 0xca, 0xa8, 0x7, 0x15, 0xc4, 0x74, 0x49, 0x85, 0xda, 0x57}; - uint8_t bytesprops9[] = {0x42, 0xb4, 0xb8, 0x67, 0x70, 0x70, 0x72, 0x1d, 0xb6, 0x1e, 0x9a, 0x70, - 0x9d, 0x0, 0x5d, 0x72, 0x6a, 0x39, 0xe, 0xf9, 0x29, 0xf, 0x3a}; - uint8_t bytesprops8[] = {0xd1, 0xa8, 0xe6}; + 0x10, 0x96, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x19, 0x1a, 0x99, 0x1, 0x27, 0x0, 0x0, 0x5d, + 0x36, 0x29, 0x79, 0x17, 0x3b, 0x16, 0x0, 0x2, 0x91, 0x6a, 0x29, 0xea, 0x2a, 0xd0, 0x2, 0x0, 0x0, 0x7d, 0x7d, + 0x2, 0x0, 0x0, 0x56, 0x9e, 0x11, 0x0, 0x0, 0x23, 0x34, 0x21, 0x2d, 0x8, 0x18, 0x0, 0x0, 0x51, 0xbb, 0x8, + 0x0, 0x6, 0xb7, 0xc1, 0x6c, 0x8e, 0x3, 0xb8, 0x28, 0x5a, 0x22, 0x37, 0x9f, 0x29, 0xfa, 0x16, 0x0, 0x1c, 0x49, + 0x50, 0x99, 0x38, 0x2b, 0x94, 0x33, 0x3b, 0x67, 0x63, 0xa5, 0x41, 0xc2, 0x60, 0x97, 0xfc, 0xe8, 0xd1, 0xbd, 0x16, + 0x23, 0x13, 0xb3, 0x8, 0xe1, 0x9e, 0x8e, 0x80, 0x28, 0x4c, 0x1f, 0x0, 0x14, 0x62, 0xf4, 0xd8, 0xfd, 0x6f, 0x8d, + 0xf0, 0x22, 0xb7, 0xee, 0x86, 0x6c, 0xba, 0x66, 0xdb, 0x67, 0xd4, 0x63, 0xd6, 0xa0, 0x28, 0xac, 0x19, 0x6a, 0x25, + 0x18, 0x25, 0x31, 0x22, 0x5a, 0x26, 0x13, 0x16, 0x85, 0x11, 0x0, 0x0, 0x69, 0x9c, 0x12, 0x0, 0x12, 0xfe, 0xe8, + 0xf8, 0xc7, 0xa5, 0x1d, 0xe9, 0x7a, 0xce, 0x7d, 0xf5, 0x40, 0xb1, 0xa2, 0x6f, 0x40, 0xce, 0x87, 0x0, 0x1c, 0x4a, + 0x9e, 0x3e, 0x48, 0x76, 0x16, 0x64, 0x46, 0x1, 0xa0, 0x29, 0x11, 0x2a, 0x27, 0x23, 0x69, 0x64, 0xbc, 0x69, 0x61, + 0x44, 0xc0, 0x8, 0xd5, 0x98, 0x72, 0x57, 0xfb, 0x16, 0x25, 0xfa, 0x1f, 0x0, 0xa, 0xff, 0x47, 0x31, 0x4c, 0xaf, + 0xd1, 0x7c, 0x23, 0x50, 0x65, 0x25, 0xdd, 0x1f, 0x0, 0x0, 0x25, 0x19, 0x0, 0x14, 0x8f, 0x45, 0xfa, 0xe0, 0xf8, + 0x25, 0x4, 0x3f, 0x13, 0x5f, 0x6d, 0xbd, 0x15, 0xd8, 0xa3, 0xfc, 0x8a, 0x42, 0x8e, 0x1e, 0x0, 0x16, 0x7c, 0xfd, + 0x4f, 0x48, 0x2e, 0x45, 0x1f, 0x2a, 0xb6, 0xf0, 0x2d, 0x3b, 0xea, 0xb4, 0xed, 0xef, 0x32, 0x88, 0x42, 0x80, 0xf1, + 0x83, 0x0, 0xc, 0x45, 0x3f, 0x5, 0xc2, 0x45, 0xd0, 0x68, 0xa1, 0x1d, 0x56, 0x32, 0xbd}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x91, 0x6a}; + uint8_t bytesprops1[] = {0xb7, 0xc1, 0x6c, 0x8e, 0x3, 0xb8}; + uint8_t bytesprops2[] = {0x49, 0x50, 0x99, 0x38, 0x2b, 0x94, 0x33, 0x3b, 0x67, 0x63, 0xa5, 0x41, 0xc2, 0x60, + 0x97, 0xfc, 0xe8, 0xd1, 0xbd, 0x16, 0x23, 0x13, 0xb3, 0x8, 0xe1, 0x9e, 0x8e, 0x80}; + uint8_t bytesprops3[] = {0x62, 0xf4, 0xd8, 0xfd, 0x6f, 0x8d, 0xf0, 0x22, 0xb7, 0xee, + 0x86, 0x6c, 0xba, 0x66, 0xdb, 0x67, 0xd4, 0x63, 0xd6, 0xa0}; + uint8_t bytesprops4[] = {0xfe, 0xe8, 0xf8, 0xc7, 0xa5, 0x1d, 0xe9, 0x7a, 0xce, + 0x7d, 0xf5, 0x40, 0xb1, 0xa2, 0x6f, 0x40, 0xce, 0x87}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12587}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops2}, .v = {21, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31793}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 33}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5301}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31868}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22153}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops8}, .v = {23, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23862}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32125}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22174}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9012}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11528}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20923}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14239}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23078}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5765}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27036}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xff, 0x47, 0x31, 0x4c, 0xaf, 0xd1, 0x7c, 0x23, 0x50, 0x65}; + uint8_t byteswillprops1[] = {0}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 25}}, + }; + + lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8f, 0x45, 0xfa, 0xe0, 0xf8, 0x25, 0x4, 0x3f, 0x13, 0x5f, + 0x6d, 0xbd, 0x15, 0xd8, 0xa3, 0xfc, 0x8a, 0x42, 0x8e, 0x1e}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7c, 0xfd, 0x4f, 0x48, 0x2e, 0x45, 0x1f, 0x2a, 0xb6, 0xf0, 0x2d, + 0x3b, 0xea, 0xb4, 0xed, 0xef, 0x32, 0x88, 0x42, 0x80, 0xf1, 0x83}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 26836; - uint8_t client_id_bytes[] = {0xcb, 0x2c, 0x10, 0xff, 0x4, 0xf5, 0x92, 0xea, 0x3e, - 0xe2, 0x94, 0xf0, 0x65, 0x87, 0xe5, 0x1a, 0x1a, 0x35}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.keep_alive = 6426; + uint8_t client_id_bytes[] = {0x4a, 0x9e, 0x3e, 0x48, 0x76, 0x16, 0x64, 0x46, 0x1, 0xa0, 0x29, 0x11, 0x2a, 0x27, + 0x23, 0x69, 0x64, 0xbc, 0x69, 0x61, 0x44, 0xc0, 0x8, 0xd5, 0x98, 0x72, 0x57, 0xfb}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xbb, 0xfc, 0x1, 0x66, 0xe8, 0x6, 0xd5, 0xf5, 0xb0, 0xfc, 0xc3, 0xeb, 0xf2, - 0x39, 0xb6, 0xab, 0xa, 0x7, 0xde, 0x48, 0x41, 0xf, 0xba, 0x87, 0x9, 0x69}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x50, 0xf1, 0x26, 0x66, 0xec, 0x97, 0x43, 0xaf, 0xab}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x45, 0x3f, 0x5, 0xc2, 0x45, 0xd0, 0x68, 0xa1, 0x1d, 0x56, 0x32, 0xbd}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7633 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2})] [] +// SubscribeRequest 22060 [("\223\227\254#\231\fk\254CT\157\246_G\GSI",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\212\DC4\172\SI\161\ETX[\171~`Y\188\185\181pS\206X",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x5, 0x1d, 0xd1, 0x0, 0x0, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7633, 1, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 29762 [("J\239",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0x7, 0x74, 0x42, 0x0, 0x2, 0x4a, 0xef, 0x2}; + uint8_t pkt[] = {0x82, 0x2a, 0x56, 0x2c, 0x0, 0x10, 0xdf, 0xe3, 0xfe, 0x23, 0xe7, 0xc, 0x6b, 0xfe, 0x43, + 0x54, 0x9d, 0xf6, 0x5f, 0x47, 0x1d, 0x49, 0x0, 0x0, 0x12, 0xd4, 0x14, 0xac, 0xf, 0xa1, + 0x3, 0x5b, 0xab, 0x7e, 0x60, 0x59, 0xbc, 0xb9, 0xb5, 0x70, 0x53, 0xce, 0x58, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x4a, 0xef}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xdf, 0xe3, 0xfe, 0x23, 0xe7, 0xc, 0x6b, 0xfe, + 0x43, 0x54, 0x9d, 0xf6, 0x5f, 0x47, 0x1d, 0x49}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s1_bytes[] = {0xd4, 0x14, 0xac, 0xf, 0xa1, 0x3, 0x5b, 0xab, 0x7e, + 0x60, 0x59, 0xbc, 0xb9, 0xb5, 0x70, 0x53, 0xce, 0x58}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29762, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22060, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30334 [("/\SUB\DC2:k\140\DC3\184\237\130\214-\204\144j\179\231\244\242tp@\RSZx\ENQX",SubOptions +// SubscribeRequest 21589 +// [("\204\251XL\209\150\136\SUB\146\187\US\196\153\150d\219\213\209\RS\174\175\144^\140\138\147\203\240\214\215",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("T\210\128\148\230\144\147\&2&+N\138\198\129\156\149",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\a[}\129\251}\153\232\133",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\156\198\198\142\194\236T\189\228\175e\155\ETX\145\225\\:\SUB\131\221",SubOptions {_retainHandling = +// QoS0}),("g\160\ESC\225\199\RS!%|\ACKG\217v\148w\135\203",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("I*\141\&7!n",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("D\174\175\216\224\ETB\193\170\214\231",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\207\193\224w'\248\246",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x6d, 0x76, 0x7e, 0x0, 0x1b, 0x2f, 0x1a, 0x12, 0x3a, 0x6b, 0x8c, 0x13, 0xb8, 0xed, 0x82, - 0xd6, 0x2d, 0xcc, 0x90, 0x6a, 0xb3, 0xe7, 0xf4, 0xf2, 0x74, 0x70, 0x40, 0x1e, 0x5a, 0x78, 0x5, - 0x58, 0x2, 0x0, 0x10, 0x54, 0xd2, 0x80, 0x94, 0xe6, 0x90, 0x93, 0x32, 0x26, 0x2b, 0x4e, 0x8a, - 0xc6, 0x81, 0x9c, 0x95, 0x0, 0x0, 0x9, 0x7, 0x5b, 0x7d, 0x81, 0xfb, 0x7d, 0x99, 0xe8, 0x85, - 0x1, 0x0, 0x14, 0x9c, 0xc6, 0xc6, 0x8e, 0xc2, 0xec, 0x54, 0xbd, 0xe4, 0xaf, 0x65, 0x9b, 0x3, - 0x91, 0xe1, 0x5c, 0x3a, 0x1a, 0x83, 0xdd, 0x1, 0x0, 0xa, 0x44, 0xae, 0xaf, 0xd8, 0xe0, 0x17, - 0xc1, 0xaa, 0xd6, 0xe7, 0x2, 0x0, 0x7, 0xcf, 0xc1, 0xe0, 0x77, 0x27, 0xf8, 0xf6, 0x0}; +// QoS0}),("\250wi\NAK0H\153\149m1#\244\243j\171jT\193\248\219\EOT\246X\217\161\192",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\241\239J(\216\192=\130\197-h|\170B\US\204]\166\204\149\152|\EOT\221X*U\138w\238",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\137;E\ETX\186\180\221\246\229\182\247\208",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("}\240",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("t\205_\220\162g\141/cH",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\135\137\149\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\165\DC36\SUBG\US}\220\EM\SI\137\251\204?\210\EOT#\bLN\129",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode2) { + uint8_t pkt[] = {0x82, 0xc1, 0x1, 0x54, 0x55, 0x0, 0x1e, 0xcc, 0xfb, 0x58, 0x4c, 0xd1, 0x96, 0x88, 0x1a, 0x92, 0xbb, + 0x1f, 0xc4, 0x99, 0x96, 0x64, 0xdb, 0xd5, 0xd1, 0x1e, 0xae, 0xaf, 0x90, 0x5e, 0x8c, 0x8a, 0x93, 0xcb, + 0xf0, 0xd6, 0xd7, 0x0, 0x0, 0x11, 0x67, 0xa0, 0x1b, 0xe1, 0xc7, 0x1e, 0x21, 0x25, 0x7c, 0x6, 0x47, + 0xd9, 0x76, 0x94, 0x77, 0x87, 0xcb, 0x1, 0x0, 0x6, 0x49, 0x2a, 0x8d, 0x37, 0x21, 0x6e, 0x0, 0x0, + 0x1a, 0xfa, 0x77, 0x69, 0x15, 0x30, 0x48, 0x99, 0x95, 0x6d, 0x31, 0x23, 0xf4, 0xf3, 0x6a, 0xab, 0x6a, + 0x54, 0xc1, 0xf8, 0xdb, 0x4, 0xf6, 0x58, 0xd9, 0xa1, 0xc0, 0x0, 0x0, 0x1e, 0xf1, 0xef, 0x4a, 0x28, + 0xd8, 0xc0, 0x3d, 0x82, 0xc5, 0x2d, 0x68, 0x7c, 0xaa, 0x42, 0x1f, 0xcc, 0x5d, 0xa6, 0xcc, 0x95, 0x98, + 0x7c, 0x4, 0xdd, 0x58, 0x2a, 0x55, 0x8a, 0x77, 0xee, 0x0, 0x0, 0x0, 0x1, 0x0, 0xc, 0x89, 0x3b, + 0x45, 0x3, 0xba, 0xb4, 0xdd, 0xf6, 0xe5, 0xb6, 0xf7, 0xd0, 0x0, 0x0, 0x2, 0x7d, 0xf0, 0x2, 0x0, + 0xa, 0x74, 0xcd, 0x5f, 0xdc, 0xa2, 0x67, 0x8d, 0x2f, 0x63, 0x48, 0x2, 0x0, 0x4, 0x87, 0x89, 0x95, + 0xd0, 0x2, 0x0, 0x15, 0xa5, 0x13, 0x36, 0x1a, 0x47, 0x1f, 0x7d, 0xdc, 0x19, 0xf, 0x89, 0xfb, 0xcc, + 0x3f, 0xd2, 0x4, 0x23, 0x8, 0x4c, 0x4e, 0x81, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x2f, 0x1a, 0x12, 0x3a, 0x6b, 0x8c, 0x13, 0xb8, 0xed, 0x82, 0xd6, 0x2d, 0xcc, 0x90, - 0x6a, 0xb3, 0xe7, 0xf4, 0xf2, 0x74, 0x70, 0x40, 0x1e, 0x5a, 0x78, 0x5, 0x58}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xcc, 0xfb, 0x58, 0x4c, 0xd1, 0x96, 0x88, 0x1a, 0x92, 0xbb, + 0x1f, 0xc4, 0x99, 0x96, 0x64, 0xdb, 0xd5, 0xd1, 0x1e, 0xae, + 0xaf, 0x90, 0x5e, 0x8c, 0x8a, 0x93, 0xcb, 0xf0, 0xd6, 0xd7}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x54, 0xd2, 0x80, 0x94, 0xe6, 0x90, 0x93, 0x32, - 0x26, 0x2b, 0x4e, 0x8a, 0xc6, 0x81, 0x9c, 0x95}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x67, 0xa0, 0x1b, 0xe1, 0xc7, 0x1e, 0x21, 0x25, 0x7c, + 0x6, 0x47, 0xd9, 0x76, 0x94, 0x77, 0x87, 0xcb}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7, 0x5b, 0x7d, 0x81, 0xfb, 0x7d, 0x99, 0xe8, 0x85}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x49, 0x2a, 0x8d, 0x37, 0x21, 0x6e}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9c, 0xc6, 0xc6, 0x8e, 0xc2, 0xec, 0x54, 0xbd, 0xe4, 0xaf, - 0x65, 0x9b, 0x3, 0x91, 0xe1, 0x5c, 0x3a, 0x1a, 0x83, 0xdd}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfa, 0x77, 0x69, 0x15, 0x30, 0x48, 0x99, 0x95, 0x6d, 0x31, 0x23, 0xf4, 0xf3, + 0x6a, 0xab, 0x6a, 0x54, 0xc1, 0xf8, 0xdb, 0x4, 0xf6, 0x58, 0xd9, 0xa1, 0xc0}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x44, 0xae, 0xaf, 0xd8, 0xe0, 0x17, 0xc1, 0xaa, 0xd6, 0xe7}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xf1, 0xef, 0x4a, 0x28, 0xd8, 0xc0, 0x3d, 0x82, 0xc5, 0x2d, + 0x68, 0x7c, 0xaa, 0x42, 0x1f, 0xcc, 0x5d, 0xa6, 0xcc, 0x95, + 0x98, 0x7c, 0x4, 0xdd, 0x58, 0x2a, 0x55, 0x8a, 0x77, 0xee}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xcf, 0xc1, 0xe0, 0x77, 0x27, 0xf8, 0xf6}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s6_bytes[] = {0x89, 0x3b, 0x45, 0x3, 0xba, 0xb4, 0xdd, 0xf6, 0xe5, 0xb6, 0xf7, 0xd0}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x7d, 0xf0}; + lwmqtt_string_t topic_filter_s7 = {2, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x74, 0xcd, 0x5f, 0xdc, 0xa2, 0x67, 0x8d, 0x2f, 0x63, 0x48}; + lwmqtt_string_t topic_filter_s8 = {10, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x87, 0x89, 0x95, 0xd0}; + lwmqtt_string_t topic_filter_s9 = {4, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xa5, 0x13, 0x36, 0x1a, 0x47, 0x1f, 0x7d, 0xdc, 0x19, 0xf, 0x89, + 0xfb, 0xcc, 0x3f, 0xd2, 0x4, 0x23, 0x8, 0x4c, 0x4e, 0x81}; + lwmqtt_string_t topic_filter_s10 = {21, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30334, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21589, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26291 [("\SI\235&\DLEy\150\n\207\212>H\132",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("@\181\178*D\211",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("5\138\164\236\175\v\154\215\DLE\DC1\250Z\168N\145\228\235C\186\rrf\247\243",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("o\235s\DC1p\179\196\&3\216n\ENQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0x43, 0x66, 0xb3, 0x0, 0xc, 0xf, 0xeb, 0x26, 0x10, 0x79, 0x96, 0xa, 0xcf, - 0xd4, 0x3e, 0x48, 0x84, 0x2, 0x0, 0x6, 0x40, 0xb5, 0xb2, 0x2a, 0x44, 0xd3, 0x2, - 0x0, 0x18, 0x35, 0x8a, 0xa4, 0xec, 0xaf, 0xb, 0x9a, 0xd7, 0x10, 0x11, 0xfa, 0x5a, - 0xa8, 0x4e, 0x91, 0xe4, 0xeb, 0x43, 0xba, 0xd, 0x72, 0x66, 0xf7, 0xf3, 0x2, 0x0, - 0xb, 0x6f, 0xeb, 0x73, 0x11, 0x70, 0xb3, 0xc4, 0x33, 0xd8, 0x6e, 0x5, 0x2}; +// SubscribeRequest 25658 [("\135\217dy\159J\NULIZ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("~|l\v\rK\139\EMPB\237\236M\165\138",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode3) { + uint8_t pkt[] = {0x82, 0x20, 0x64, 0x3a, 0x0, 0x9, 0x87, 0xd9, 0x64, 0x79, 0x9f, 0x4a, 0x0, 0x49, 0x5a, 0x2, 0x0, + 0xf, 0x7e, 0x7c, 0x6c, 0xb, 0xd, 0x4b, 0x8b, 0x19, 0x50, 0x42, 0xed, 0xec, 0x4d, 0xa5, 0x8a, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xf, 0xeb, 0x26, 0x10, 0x79, 0x96, 0xa, 0xcf, 0xd4, 0x3e, 0x48, 0x84}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x87, 0xd9, 0x64, 0x79, 0x9f, 0x4a, 0x0, 0x49, 0x5a}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x40, 0xb5, 0xb2, 0x2a, 0x44, 0xd3}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7e, 0x7c, 0x6c, 0xb, 0xd, 0x4b, 0x8b, 0x19, + 0x50, 0x42, 0xed, 0xec, 0x4d, 0xa5, 0x8a}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x35, 0x8a, 0xa4, 0xec, 0xaf, 0xb, 0x9a, 0xd7, 0x10, 0x11, 0xfa, 0x5a, - 0xa8, 0x4e, 0x91, 0xe4, 0xeb, 0x43, 0xba, 0xd, 0x72, 0x66, 0xf7, 0xf3}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6f, 0xeb, 0x73, 0x11, 0x70, 0xb3, 0xc4, 0x33, 0xd8, 0x6e, 0x5}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + lwmqtt_sub_options_t sub_opts[2]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -10414,104 +10381,171 @@ TEST(Subscribe311QCTest, Encode4) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26291, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25658, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29015 [("\163\tU\254\239\150/*\157\226\191\&1a\DC3\227{",SubOptions {_retainHandling = +// SubscribeRequest 3081 [("`\165\DC2QfJ\249\SI\229\168\140",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\175\219X\239\225\227x\227\ETB\252\181h",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\168#\148j\132a\191~\220R\159N\200\142j\222\155\217)\STX\rz\233",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\213\SUB\207\229\DC3\246\243\142",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x20, 0x71, 0x57, 0x0, 0x10, 0xa3, 0x9, 0x55, 0xfe, 0xef, 0x96, 0x2f, 0x2a, 0x9d, 0xe2, 0xbf, - 0x31, 0x61, 0x13, 0xe3, 0x7b, 0x1, 0x0, 0x8, 0xd5, 0x1a, 0xcf, 0xe5, 0x13, 0xf6, 0xf3, 0x8e, 0x2}; +// QoS2}),("?\223\227x\250\168\161\217j\189b\253dAOF\239\202\227",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\160\136\fl(\220\155",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\152\146\139\145\146",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\197\241H\131\203;\238\152\EOT\187CUa\222\142\128\EM\SUBq",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\ACK_\244\234\207,W\239J\240\181\240fXg\231",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("{\\\162.Ggs\SOH\145\237\&7T\146",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode4) { + uint8_t pkt[] = {0x82, 0x9a, 0x1, 0xc, 0x9, 0x0, 0xb, 0x60, 0xa5, 0x12, 0x51, 0x66, 0x4a, 0xf9, 0xf, 0xe5, + 0xa8, 0x8c, 0x2, 0x0, 0xc, 0xaf, 0xdb, 0x58, 0xef, 0xe1, 0xe3, 0x78, 0xe3, 0x17, 0xfc, 0xb5, + 0x68, 0x1, 0x0, 0x17, 0xa8, 0x23, 0x94, 0x6a, 0x84, 0x61, 0xbf, 0x7e, 0xdc, 0x52, 0x9f, 0x4e, + 0xc8, 0x8e, 0x6a, 0xde, 0x9b, 0xd9, 0x29, 0x2, 0xd, 0x7a, 0xe9, 0x2, 0x0, 0x13, 0x3f, 0xdf, + 0xe3, 0x78, 0xfa, 0xa8, 0xa1, 0xd9, 0x6a, 0xbd, 0x62, 0xfd, 0x64, 0x41, 0x4f, 0x46, 0xef, 0xca, + 0xe3, 0x2, 0x0, 0x7, 0xa0, 0x88, 0xc, 0x6c, 0x28, 0xdc, 0x9b, 0x2, 0x0, 0x5, 0x98, 0x92, + 0x8b, 0x91, 0x92, 0x2, 0x0, 0x13, 0xc5, 0xf1, 0x48, 0x83, 0xcb, 0x3b, 0xee, 0x98, 0x4, 0xbb, + 0x43, 0x55, 0x61, 0xde, 0x8e, 0x80, 0x19, 0x1a, 0x71, 0x0, 0x0, 0x10, 0x6, 0x5f, 0xf4, 0xea, + 0xcf, 0x2c, 0x57, 0xef, 0x4a, 0xf0, 0xb5, 0xf0, 0x66, 0x58, 0x67, 0xe7, 0x2, 0x0, 0xd, 0x7b, + 0x5c, 0xa2, 0x2e, 0x47, 0x67, 0x73, 0x1, 0x91, 0xed, 0x37, 0x54, 0x92, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xa3, 0x9, 0x55, 0xfe, 0xef, 0x96, 0x2f, 0x2a, - 0x9d, 0xe2, 0xbf, 0x31, 0x61, 0x13, 0xe3, 0x7b}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x60, 0xa5, 0x12, 0x51, 0x66, 0x4a, 0xf9, 0xf, 0xe5, 0xa8, 0x8c}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd5, 0x1a, 0xcf, 0xe5, 0x13, 0xf6, 0xf3, 0x8e}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xaf, 0xdb, 0x58, 0xef, 0xe1, 0xe3, 0x78, 0xe3, 0x17, 0xfc, 0xb5, 0x68}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s2_bytes[] = {0xa8, 0x23, 0x94, 0x6a, 0x84, 0x61, 0xbf, 0x7e, 0xdc, 0x52, 0x9f, 0x4e, + 0xc8, 0x8e, 0x6a, 0xde, 0x9b, 0xd9, 0x29, 0x2, 0xd, 0x7a, 0xe9}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x3f, 0xdf, 0xe3, 0x78, 0xfa, 0xa8, 0xa1, 0xd9, 0x6a, 0xbd, + 0x62, 0xfd, 0x64, 0x41, 0x4f, 0x46, 0xef, 0xca, 0xe3}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa0, 0x88, 0xc, 0x6c, 0x28, 0xdc, 0x9b}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x98, 0x92, 0x8b, 0x91, 0x92}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc5, 0xf1, 0x48, 0x83, 0xcb, 0x3b, 0xee, 0x98, 0x4, 0xbb, + 0x43, 0x55, 0x61, 0xde, 0x8e, 0x80, 0x19, 0x1a, 0x71}; + lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6, 0x5f, 0xf4, 0xea, 0xcf, 0x2c, 0x57, 0xef, + 0x4a, 0xf0, 0xb5, 0xf0, 0x66, 0x58, 0x67, 0xe7}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x7b, 0x5c, 0xa2, 0x2e, 0x47, 0x67, 0x73, 0x1, 0x91, 0xed, 0x37, 0x54, 0x92}; + lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29015, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3081, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 24249 [("\133\139\\\225\188\f;\\\232=\247\f\131i3BK7cp\150l\FSc",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\173$rH\250",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\169\145\164k\139\246",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\US\DEL\ffL]\EMM4V |1\RS\169\151\NAK\246",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\190\200Cvj\152\154\218\249x\STX\251}`\168\156\182>]`r\175",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\248\&3\182",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0x62, 0x5e, 0xb9, 0x0, 0x18, 0x85, 0x8b, 0x5c, 0xe1, 0xbc, 0xc, 0x3b, 0x5c, 0xe8, 0x3d, 0xf7, - 0xc, 0x83, 0x69, 0x33, 0x42, 0x4b, 0x37, 0x63, 0x70, 0x96, 0x6c, 0x1c, 0x63, 0x1, 0x0, 0x5, 0xad, - 0x24, 0x72, 0x48, 0xfa, 0x2, 0x0, 0x6, 0xa9, 0x91, 0xa4, 0x6b, 0x8b, 0xf6, 0x0, 0x0, 0x12, 0x1f, - 0x7f, 0xc, 0x66, 0x4c, 0x5d, 0x19, 0x4d, 0x34, 0x56, 0x20, 0x7c, 0x31, 0x1e, 0xa9, 0x97, 0x15, 0xf6, - 0x2, 0x0, 0x16, 0xbe, 0xc8, 0x43, 0x76, 0x6a, 0x98, 0x9a, 0xda, 0xf9, 0x78, 0x2, 0xfb, 0x7d, 0x60, - 0xa8, 0x9c, 0xb6, 0x3e, 0x5d, 0x60, 0x72, 0xaf, 0x1, 0x0, 0x3, 0xf8, 0x33, 0xb6, 0x0}; +// SubscribeRequest 26803 [("G0\203x\EOT9\163\234\244~\250\213\DEL\247z'\226",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("m,s\SO\194G\181\182\&9\128N\200\150;gq9\182u?e\\\252\219\SO\133\DC2\146\242W",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\129\156\160\NAK\194\&8\202\196Y +// \172\147\213\175\141*\168\ETB\195y\147",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("iM\SYN\223q\DEL@J\183\233\132\254[*",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("jX\ra\242\DC1\ETB@E\181\181\252R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\224\GSH\ESCU\212",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode5) { + uint8_t pkt[] = {0x82, 0x79, 0x68, 0xb3, 0x0, 0x11, 0x47, 0x30, 0xcb, 0x78, 0x4, 0x39, 0xa3, 0xea, 0xf4, 0x7e, + 0xfa, 0xd5, 0x7f, 0xf7, 0x7a, 0x27, 0xe2, 0x2, 0x0, 0x1e, 0x6d, 0x2c, 0x73, 0xe, 0xc2, 0x47, + 0xb5, 0xb6, 0x39, 0x80, 0x4e, 0xc8, 0x96, 0x3b, 0x67, 0x71, 0x39, 0xb6, 0x75, 0x3f, 0x65, 0x5c, + 0xfc, 0xdb, 0xe, 0x85, 0x12, 0x92, 0xf2, 0x57, 0x2, 0x0, 0x15, 0x81, 0x9c, 0xa0, 0x15, 0xc2, + 0x38, 0xca, 0xc4, 0x59, 0x20, 0xac, 0x93, 0xd5, 0xaf, 0x8d, 0x2a, 0xa8, 0x17, 0xc3, 0x79, 0x93, + 0x1, 0x0, 0xe, 0x69, 0x4d, 0x16, 0xdf, 0x71, 0x7f, 0x40, 0x4a, 0xb7, 0xe9, 0x84, 0xfe, 0x5b, + 0x2a, 0x1, 0x0, 0xd, 0x6a, 0x58, 0xd, 0x61, 0xf2, 0x11, 0x17, 0x40, 0x45, 0xb5, 0xb5, 0xfc, + 0x52, 0x1, 0x0, 0x6, 0xe0, 0x1d, 0x48, 0x1b, 0x55, 0xd4, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x85, 0x8b, 0x5c, 0xe1, 0xbc, 0xc, 0x3b, 0x5c, 0xe8, 0x3d, 0xf7, 0xc, - 0x83, 0x69, 0x33, 0x42, 0x4b, 0x37, 0x63, 0x70, 0x96, 0x6c, 0x1c, 0x63}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x47, 0x30, 0xcb, 0x78, 0x4, 0x39, 0xa3, 0xea, 0xf4, + 0x7e, 0xfa, 0xd5, 0x7f, 0xf7, 0x7a, 0x27, 0xe2}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xad, 0x24, 0x72, 0x48, 0xfa}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6d, 0x2c, 0x73, 0xe, 0xc2, 0x47, 0xb5, 0xb6, 0x39, 0x80, + 0x4e, 0xc8, 0x96, 0x3b, 0x67, 0x71, 0x39, 0xb6, 0x75, 0x3f, + 0x65, 0x5c, 0xfc, 0xdb, 0xe, 0x85, 0x12, 0x92, 0xf2, 0x57}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa9, 0x91, 0xa4, 0x6b, 0x8b, 0xf6}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x81, 0x9c, 0xa0, 0x15, 0xc2, 0x38, 0xca, 0xc4, 0x59, 0x20, 0xac, + 0x93, 0xd5, 0xaf, 0x8d, 0x2a, 0xa8, 0x17, 0xc3, 0x79, 0x93}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1f, 0x7f, 0xc, 0x66, 0x4c, 0x5d, 0x19, 0x4d, 0x34, - 0x56, 0x20, 0x7c, 0x31, 0x1e, 0xa9, 0x97, 0x15, 0xf6}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x69, 0x4d, 0x16, 0xdf, 0x71, 0x7f, 0x40, + 0x4a, 0xb7, 0xe9, 0x84, 0xfe, 0x5b, 0x2a}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xbe, 0xc8, 0x43, 0x76, 0x6a, 0x98, 0x9a, 0xda, 0xf9, 0x78, 0x2, - 0xfb, 0x7d, 0x60, 0xa8, 0x9c, 0xb6, 0x3e, 0x5d, 0x60, 0x72, 0xaf}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x6a, 0x58, 0xd, 0x61, 0xf2, 0x11, 0x17, 0x40, 0x45, 0xb5, 0xb5, 0xfc, 0x52}; + lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf8, 0x33, 0xb6}; - lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe0, 0x1d, 0x48, 0x1b, 0x55, 0xd4}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -10519,11 +10553,11 @@ TEST(Subscribe311QCTest, Encode6) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -10531,7 +10565,7 @@ TEST(Subscribe311QCTest, Encode6) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -10541,22 +10575,22 @@ TEST(Subscribe311QCTest, Encode6) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24249, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26803, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18033 [("\181\STX\205 B\134&\195T\EOT\226\245Is\192\233\ETBM\ENQ\150\240\161",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0x1b, 0x46, 0x71, 0x0, 0x16, 0xb5, 0x2, 0xcd, 0x20, 0x42, 0x86, 0x26, 0xc3, 0x54, - 0x4, 0xe2, 0xf5, 0x49, 0x73, 0xc0, 0xe9, 0x17, 0x4d, 0x5, 0x96, 0xf0, 0xa1, 0x0}; +// SubscribeRequest 11145 [("\164AU\201Ck\ACK\SYN_G\244\236M\230\204",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0x68, 0x67, 0xaf, 0x0, 0x3, 0xf9, 0xc9, 0x1a, 0x2, 0x0, 0x9, 0xdb, 0x9f, 0xe6, 0x7c, - 0xb5, 0x90, 0x2d, 0x1a, 0x90, 0x1, 0x0, 0x9, 0xdc, 0x98, 0x92, 0x82, 0xc5, 0xfb, 0x1, 0xe2, - 0x2b, 0x1, 0x0, 0x0, 0x1, 0x0, 0x8, 0x8f, 0xc8, 0xae, 0xde, 0xe2, 0x34, 0x8e, 0x2b, 0x1, - 0x0, 0x14, 0x91, 0xe4, 0x41, 0xf4, 0x9e, 0x8, 0xad, 0x66, 0x59, 0x26, 0xdc, 0x71, 0x14, 0xa1, - 0x5c, 0xae, 0xc7, 0x37, 0xac, 0x23, 0x2, 0x0, 0x5, 0x8a, 0x11, 0xa4, 0xc2, 0x17, 0x2, 0x0, - 0xa, 0x43, 0x8b, 0xb2, 0xd2, 0xd9, 0x55, 0x28, 0x53, 0x85, 0x7, 0x1, 0x0, 0xb, 0x4d, 0x55, - 0x3a, 0x48, 0x35, 0xca, 0xf6, 0xf7, 0x21, 0x0, 0xa9, 0x0}; +TEST(Subscribe311QCTest, Encode7) { + uint8_t pkt[] = {0x82, 0xd3, 0x1, 0x79, 0x44, 0x0, 0x1b, 0xbb, 0xc8, 0x9c, 0x21, 0x9e, 0xc, 0x34, 0x2, 0x0, 0xac, + 0x5, 0xf4, 0x7e, 0xd0, 0xac, 0x42, 0x13, 0x29, 0x91, 0x43, 0x31, 0xa6, 0x6d, 0xd0, 0xaf, 0xfe, 0x54, + 0x1, 0x0, 0x14, 0x11, 0x7c, 0x18, 0xdb, 0x13, 0x8f, 0xf2, 0x5, 0x14, 0x56, 0x18, 0x88, 0x88, 0x6f, + 0xe, 0x1b, 0x13, 0x2f, 0x9e, 0x3b, 0x2, 0x0, 0x17, 0x8c, 0x6e, 0x95, 0x67, 0x50, 0xa5, 0x85, 0x43, + 0xb7, 0x8c, 0x90, 0xc3, 0x49, 0xd, 0x1e, 0xd7, 0x20, 0xca, 0x45, 0x58, 0x4, 0xcb, 0x87, 0x0, 0x0, + 0x1, 0x19, 0x0, 0x0, 0xe, 0x70, 0x3c, 0x95, 0xb5, 0x16, 0xeb, 0x62, 0x3c, 0x4e, 0xf2, 0xcb, 0x70, + 0x53, 0xad, 0x0, 0x0, 0x1d, 0xfa, 0x5, 0xc2, 0xa5, 0x99, 0x3b, 0x97, 0xad, 0x8f, 0xdc, 0x7a, 0xaf, + 0x6e, 0xa8, 0x36, 0xbb, 0xe8, 0xf, 0x99, 0x84, 0x47, 0xbd, 0x1a, 0xab, 0x76, 0xf7, 0xb2, 0x57, 0xdb, + 0x1, 0x0, 0x1c, 0xb5, 0xd8, 0xd6, 0x65, 0xe1, 0x30, 0x23, 0x5d, 0xce, 0xf0, 0x37, 0xc7, 0x3, 0x85, + 0x84, 0x94, 0xd8, 0x37, 0x63, 0x3b, 0x49, 0x1f, 0xd4, 0x4, 0x1f, 0xda, 0x75, 0xb2, 0x2, 0x0, 0xf, + 0x7a, 0x89, 0x46, 0x4c, 0x6d, 0x30, 0x37, 0x3d, 0xe6, 0x46, 0xcd, 0xf2, 0xd, 0xa4, 0xdd, 0x1, 0x0, + 0x19, 0xbe, 0xb5, 0x60, 0x82, 0xea, 0xbb, 0xb0, 0x46, 0xc1, 0x95, 0xf2, 0xdf, 0x37, 0x82, 0xa7, 0x3e, + 0x6, 0x16, 0x5f, 0x47, 0xf4, 0xec, 0x4d, 0xe6, 0xcc, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xf9, 0xc9, 0x1a}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xbb, 0xc8, 0x9c, 0x21, 0x9e, 0xc, 0x34, 0x2, 0x0, 0xac, 0x5, 0xf4, 0x7e, 0xd0, + 0xac, 0x42, 0x13, 0x29, 0x91, 0x43, 0x31, 0xa6, 0x6d, 0xd0, 0xaf, 0xfe, 0x54}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xdb, 0x9f, 0xe6, 0x7c, 0xb5, 0x90, 0x2d, 0x1a, 0x90}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x11, 0x7c, 0x18, 0xdb, 0x13, 0x8f, 0xf2, 0x5, 0x14, 0x56, + 0x18, 0x88, 0x88, 0x6f, 0xe, 0x1b, 0x13, 0x2f, 0x9e, 0x3b}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdc, 0x98, 0x92, 0x82, 0xc5, 0xfb, 0x1, 0xe2, 0x2b}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8c, 0x6e, 0x95, 0x67, 0x50, 0xa5, 0x85, 0x43, 0xb7, 0x8c, 0x90, 0xc3, + 0x49, 0xd, 0x1e, 0xd7, 0x20, 0xca, 0x45, 0x58, 0x4, 0xcb, 0x87}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x19}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8f, 0xc8, 0xae, 0xde, 0xe2, 0x34, 0x8e, 0x2b}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x70, 0x3c, 0x95, 0xb5, 0x16, 0xeb, 0x62, + 0x3c, 0x4e, 0xf2, 0xcb, 0x70, 0x53, 0xad}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x91, 0xe4, 0x41, 0xf4, 0x9e, 0x8, 0xad, 0x66, 0x59, 0x26, - 0xdc, 0x71, 0x14, 0xa1, 0x5c, 0xae, 0xc7, 0x37, 0xac, 0x23}; - lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xfa, 0x5, 0xc2, 0xa5, 0x99, 0x3b, 0x97, 0xad, 0x8f, 0xdc, + 0x7a, 0xaf, 0x6e, 0xa8, 0x36, 0xbb, 0xe8, 0xf, 0x99, 0x84, + 0x47, 0xbd, 0x1a, 0xab, 0x76, 0xf7, 0xb2, 0x57, 0xdb}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8a, 0x11, 0xa4, 0xc2, 0x17}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb5, 0xd8, 0xd6, 0x65, 0xe1, 0x30, 0x23, 0x5d, 0xce, 0xf0, + 0x37, 0xc7, 0x3, 0x85, 0x84, 0x94, 0xd8, 0x37, 0x63, 0x3b, + 0x49, 0x1f, 0xd4, 0x4, 0x1f, 0xda, 0x75, 0xb2}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x43, 0x8b, 0xb2, 0xd2, 0xd9, 0x55, 0x28, 0x53, 0x85, 0x7}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x7a, 0x89, 0x46, 0x4c, 0x6d, 0x30, 0x37, 0x3d, + 0xe6, 0x46, 0xcd, 0xf2, 0xd, 0xa4, 0xdd}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x4d, 0x55, 0x3a, 0x48, 0x35, 0xca, 0xf6, 0xf7, 0x21, 0x0, 0xa9}; - lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xbe, 0xb5, 0x60, 0x82, 0xea, 0xbb, 0xb0, 0x46, 0xc1, 0x95, 0xf2, 0xdf, 0x37, + 0x82, 0xa7, 0x3e, 0x6, 0x16, 0x5f, 0x47, 0xf4, 0xec, 0x4d, 0xe6, 0xcc}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -10730,91 +10722,37 @@ TEST(Subscribe311QCTest, Encode9) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26543, 9, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14708 [("\NULK\203\169*aQ\217\USt\161",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("1\DLE\243[3\NUL\FS\CAN\220\179\247u\159Kf\236\149\FS\231\156*w\170",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0x2a, 0x39, 0x74, 0x0, 0xb, 0x0, 0x4b, 0xcb, 0xa9, 0x2a, 0x61, 0x51, 0xd9, 0x1f, - 0x74, 0xa1, 0x1, 0x0, 0x17, 0x31, 0x10, 0xf3, 0x5b, 0x33, 0x0, 0x1c, 0x18, 0xdc, 0xb3, - 0xf7, 0x75, 0x9f, 0x4b, 0x66, 0xec, 0x95, 0x1c, 0xe7, 0x9c, 0x2a, 0x77, 0xaa, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x0, 0x4b, 0xcb, 0xa9, 0x2a, 0x61, 0x51, 0xd9, 0x1f, 0x74, 0xa1}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x31, 0x10, 0xf3, 0x5b, 0x33, 0x0, 0x1c, 0x18, 0xdc, 0xb3, 0xf7, 0x75, - 0x9f, 0x4b, 0x66, 0xec, 0x95, 0x1c, 0xe7, 0x9c, 0x2a, 0x77, 0xaa}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14708, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31044, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 24735 [("I\184\193",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("C\231x)\"5\EOT\146\158\NAK\181,",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\251\n(!k\205\193u\208<\205g.\223Q\US\187[\232\\\206\DLE\148\202",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(")",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("_\204\209\225{\194\165\&4\222'\DLE\217\157Vu6G7\181\189\DC3)q",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("_6\149\215\&3\ENQ\133\244<\b!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0x5e, 0x60, 0x9f, 0x0, 0x3, 0x49, 0xb8, 0xc1, 0x2, 0x0, 0xc, 0x43, 0xe7, 0x78, 0x29, - 0x22, 0x35, 0x4, 0x92, 0x9e, 0x15, 0xb5, 0x2c, 0x2, 0x0, 0x18, 0xfb, 0xa, 0x28, 0x21, 0x6b, - 0xcd, 0xc1, 0x75, 0xd0, 0x3c, 0xcd, 0x67, 0x2e, 0xdf, 0x51, 0x1f, 0xbb, 0x5b, 0xe8, 0x5c, 0xce, - 0x10, 0x94, 0xca, 0x1, 0x0, 0x1, 0x29, 0x0, 0x0, 0x17, 0x5f, 0xcc, 0xd1, 0xe1, 0x7b, 0xc2, - 0xa5, 0x34, 0xde, 0x27, 0x10, 0xd9, 0x9d, 0x56, 0x75, 0x36, 0x47, 0x37, 0xb5, 0xbd, 0x13, 0x29, - 0x71, 0x2, 0x0, 0xb, 0x5f, 0x36, 0x95, 0xd7, 0x33, 0x5, 0x85, 0xf4, 0x3c, 0x8, 0x21, 0x1}; +// SubscribeRequest 8770 [("\246\142&\218\222\148\226\196\212s~U\253",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\189\174\GS0\252J +// \229\&3J\f\139\225\150\221\DC4p\226\223",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\169Q;\220&z\151\248\&5\149\161\202h\ENQ\162\148\158\137b\203\f",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode8) { + uint8_t pkt[] = {0x82, 0x40, 0x22, 0x42, 0x0, 0xd, 0xf6, 0x8e, 0x26, 0xda, 0xde, 0x94, 0xe2, 0xc4, 0xd4, 0x73, 0x7e, + 0x55, 0xfd, 0x0, 0x0, 0x13, 0xbd, 0xae, 0x1d, 0x30, 0xfc, 0x4a, 0x20, 0xe5, 0x33, 0x4a, 0xc, 0x8b, + 0xe1, 0x96, 0xdd, 0x14, 0x70, 0xe2, 0xdf, 0x2, 0x0, 0x15, 0xa9, 0x51, 0x3b, 0xdc, 0x26, 0x7a, 0x97, + 0xf8, 0x35, 0x95, 0xa1, 0xca, 0x68, 0x5, 0xa2, 0x94, 0x9e, 0x89, 0x62, 0xcb, 0xc, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x49, 0xb8, 0xc1}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xf6, 0x8e, 0x26, 0xda, 0xde, 0x94, 0xe2, 0xc4, 0xd4, 0x73, 0x7e, 0x55, 0xfd}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x43, 0xe7, 0x78, 0x29, 0x22, 0x35, 0x4, 0x92, 0x9e, 0x15, 0xb5, 0x2c}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbd, 0xae, 0x1d, 0x30, 0xfc, 0x4a, 0x20, 0xe5, 0x33, 0x4a, + 0xc, 0x8b, 0xe1, 0x96, 0xdd, 0x14, 0x70, 0xe2, 0xdf}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfb, 0xa, 0x28, 0x21, 0x6b, 0xcd, 0xc1, 0x75, 0xd0, 0x3c, 0xcd, 0x67, - 0x2e, 0xdf, 0x51, 0x1f, 0xbb, 0x5b, 0xe8, 0x5c, 0xce, 0x10, 0x94, 0xca}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa9, 0x51, 0x3b, 0xdc, 0x26, 0x7a, 0x97, 0xf8, 0x35, 0x95, 0xa1, + 0xca, 0x68, 0x5, 0xa2, 0x94, 0x9e, 0x89, 0x62, 0xcb, 0xc}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x29}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5f, 0xcc, 0xd1, 0xe1, 0x7b, 0xc2, 0xa5, 0x34, 0xde, 0x27, 0x10, 0xd9, - 0x9d, 0x56, 0x75, 0x36, 0x47, 0x37, 0xb5, 0xbd, 0x13, 0x29, 0x71}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5f, 0x36, 0x95, 0xd7, 0x33, 0x5, 0x85, 0xf4, 0x3c, 0x8, 0x21}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -10826,74 +10764,48 @@ TEST(Subscribe311QCTest, Encode11) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24735, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8770, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 31752 [("_\219L\240F\160\245'\201\213\145D\221\235\219\250\233\&8\211\&6\154\154\235",SubOptions +// SubscribeRequest 15580 +// [("\145\183m\232\217\188\204_\223\249\161\170\156\133T\234\233\159\235\&2H\175J\211\149j",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("]\151",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\205g~\180H*@/\252|\213\208\227\DC1\184-\238\128\169\237E",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\186\144",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("p\172",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("E\ETB\215\130\164\130",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\v\203N\139\228\165wx\175\155\n\231\195\176",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("\238\244E\141\168\203\228s?\190\232J\139\182N\157",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode12) { - uint8_t pkt[] = {0x82, 0x58, 0x7c, 0x8, 0x0, 0x17, 0x5f, 0xdb, 0x4c, 0xf0, 0x46, 0xa0, 0xf5, 0x27, 0xc9, - 0xd5, 0x91, 0x44, 0xdd, 0xeb, 0xdb, 0xfa, 0xe9, 0x38, 0xd3, 0x36, 0x9a, 0x9a, 0xeb, 0x1, - 0x0, 0x15, 0xcd, 0x67, 0x7e, 0xb4, 0x48, 0x2a, 0x40, 0x2f, 0xfc, 0x7c, 0xd5, 0xd0, 0xe3, - 0x11, 0xb8, 0x2d, 0xee, 0x80, 0xa9, 0xed, 0x45, 0x1, 0x0, 0x2, 0xba, 0x90, 0x0, 0x0, - 0x2, 0x70, 0xac, 0x1, 0x0, 0x6, 0x45, 0x17, 0xd7, 0x82, 0xa4, 0x82, 0x0, 0x0, 0xe, - 0xb, 0xcb, 0x4e, 0x8b, 0xe4, 0xa5, 0x77, 0x78, 0xaf, 0x9b, 0xa, 0xe7, 0xc3, 0xb0, 0x0}; +TEST(Subscribe311QCTest, Encode9) { + uint8_t pkt[] = {0x82, 0x37, 0x3c, 0xdc, 0x0, 0x1a, 0x91, 0xb7, 0x6d, 0xe8, 0xd9, 0xbc, 0xcc, 0x5f, 0xdf, + 0xf9, 0xa1, 0xaa, 0x9c, 0x85, 0x54, 0xea, 0xe9, 0x9f, 0xeb, 0x32, 0x48, 0xaf, 0x4a, 0xd3, + 0x95, 0x6a, 0x0, 0x0, 0x2, 0x5d, 0x97, 0x2, 0x0, 0x10, 0xee, 0xf4, 0x45, 0x8d, 0xa8, + 0xcb, 0xe4, 0x73, 0x3f, 0xbe, 0xe8, 0x4a, 0x8b, 0xb6, 0x4e, 0x9d, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x5f, 0xdb, 0x4c, 0xf0, 0x46, 0xa0, 0xf5, 0x27, 0xc9, 0xd5, 0x91, 0x44, - 0xdd, 0xeb, 0xdb, 0xfa, 0xe9, 0x38, 0xd3, 0x36, 0x9a, 0x9a, 0xeb}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x91, 0xb7, 0x6d, 0xe8, 0xd9, 0xbc, 0xcc, 0x5f, 0xdf, 0xf9, 0xa1, 0xaa, 0x9c, + 0x85, 0x54, 0xea, 0xe9, 0x9f, 0xeb, 0x32, 0x48, 0xaf, 0x4a, 0xd3, 0x95, 0x6a}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcd, 0x67, 0x7e, 0xb4, 0x48, 0x2a, 0x40, 0x2f, 0xfc, 0x7c, 0xd5, - 0xd0, 0xe3, 0x11, 0xb8, 0x2d, 0xee, 0x80, 0xa9, 0xed, 0x45}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5d, 0x97}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xba, 0x90}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xee, 0xf4, 0x45, 0x8d, 0xa8, 0xcb, 0xe4, 0x73, + 0x3f, 0xbe, 0xe8, 0x4a, 0x8b, 0xb6, 0x4e, 0x9d}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x70, 0xac}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x45, 0x17, 0xd7, 0x82, 0xa4, 0x82}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb, 0xcb, 0x4e, 0x8b, 0xe4, 0xa5, 0x77, 0x78, 0xaf, 0x9b, 0xa, 0xe7, 0xc3, 0xb0}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -10901,129 +10813,118 @@ TEST(Subscribe311QCTest, Encode12) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31752, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15580, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12709 [("\132\197\232\176\128>\167\NAKa",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\178\242Do\205\129\176\135\169\245\194\STXX|\196\207\227\196\169\\\DLE\175\138\200\v\186\135yL\172",SubOptions +// SubscribeRequest 10667 [("I\153\NUL\206\134\163T\222V`b\232I\232\254u\213}=\145\234\200$\183#\148\179",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("@f\171\247\189\153\191\162\&66\248\191:\167\234nw\220R\195\&3\SOH72\235\a\EOTx",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\241\135Z\182\210O\202\248\&6\NAK\215\DC2\217\EOT\171\128\173.\183\138qM]l\198_",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("{\ESCA\ETX\233J}\147\DC3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\242L\245\r\189\187\206",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("{4\GS\t\194H\206\FS\176",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\203\247\\`[\193",SubOptions +// QoS1}),("T\SYN\184.5\131\&8r'\221\184\170AuL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\194\SUB\SYN\139\NUL\NUL\233\RS\226\177\SUB\183\128",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\153\164\176\228\218\162\198\231\SI\135_\\P\249\176\169\200S",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("8\193\250\178\180`\161\204\240\245\129/\NAK\137\242\233f\NUL\179\171\US\157\197tX'",SubOptions +// QoS0}),("\135\196\232\200\SOHm\GS\194\235\n|\SOH\251\ETB\f7\137\FS\211",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\225\240\SOH \SUB",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\193\229\147&\176\150P\DC1}\195\SI\203!V\185\SO-YK\193\131K\195\149\211",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0xe4, 0x1, 0x31, 0xa5, 0x0, 0x9, 0x84, 0xc5, 0xe8, 0xb0, 0x80, 0x3e, 0xa7, 0x15, 0x61, 0x1, - 0x0, 0x1e, 0xb2, 0xf2, 0x44, 0x6f, 0xcd, 0x81, 0xb0, 0x87, 0xa9, 0xf5, 0xc2, 0x2, 0x58, 0x7c, 0xc4, - 0xcf, 0xe3, 0xc4, 0xa9, 0x5c, 0x10, 0xaf, 0x8a, 0xc8, 0xb, 0xba, 0x87, 0x79, 0x4c, 0xac, 0x0, 0x0, - 0x1c, 0x40, 0x66, 0xab, 0xf7, 0xbd, 0x99, 0xbf, 0xa2, 0x36, 0x36, 0xf8, 0xbf, 0x3a, 0xa7, 0xea, 0x6e, - 0x77, 0xdc, 0x52, 0xc3, 0x33, 0x1, 0x37, 0x32, 0xeb, 0x7, 0x4, 0x78, 0x1, 0x0, 0x1a, 0xf1, 0x87, - 0x5a, 0xb6, 0xd2, 0x4f, 0xca, 0xf8, 0x36, 0x15, 0xd7, 0x12, 0xd9, 0x4, 0xab, 0x80, 0xad, 0x2e, 0xb7, - 0x8a, 0x71, 0x4d, 0x5d, 0x6c, 0xc6, 0x5f, 0x1, 0x0, 0x9, 0x7b, 0x1b, 0x41, 0x3, 0xe9, 0x4a, 0x7d, - 0x93, 0x13, 0x2, 0x0, 0x7, 0xf2, 0x4c, 0xf5, 0xd, 0xbd, 0xbb, 0xce, 0x1, 0x0, 0x9, 0x7b, 0x34, - 0x1d, 0x9, 0xc2, 0x48, 0xce, 0x1c, 0xb0, 0x1, 0x0, 0x6, 0xcb, 0xf7, 0x5c, 0x60, 0x5b, 0xc1, 0x2, - 0x0, 0x12, 0x99, 0xa4, 0xb0, 0xe4, 0xda, 0xa2, 0xc6, 0xe7, 0xf, 0x87, 0x5f, 0x5c, 0x50, 0xf9, 0xb0, - 0xa9, 0xc8, 0x53, 0x2, 0x0, 0x1a, 0x38, 0xc1, 0xfa, 0xb2, 0xb4, 0x60, 0xa1, 0xcc, 0xf0, 0xf5, 0x81, - 0x2f, 0x15, 0x89, 0xf2, 0xe9, 0x66, 0x0, 0xb3, 0xab, 0x1f, 0x9d, 0xc5, 0x74, 0x58, 0x27, 0x2, 0x0, - 0x19, 0xc1, 0xe5, 0x93, 0x26, 0xb0, 0x96, 0x50, 0x11, 0x7d, 0xc3, 0xf, 0xcb, 0x21, 0x56, 0xb9, 0xe, - 0x2d, 0x59, 0x4b, 0xc1, 0x83, 0x4b, 0xc3, 0x95, 0xd3, 0x1}; +// QoS0}),(":1R\165-\228F\219>\136\EOT?\198\224\DC2\129Z\215\250V\188\192\150\220\CAN\185\202\208^",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("A\140\&8\DC4?\EMv\CAN\214\t\FS'\255\208n\209\218\188\140\229o@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("6\141\148A\161M\182\EM\129\DC4R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("W'\224\128}N\177m\137c.\r!",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\159\&6B~\216U\149-\240\230\194\218\157\166\NAK",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("1\161\160\GS\211\175d\178\213\SOHv\135\171%\155B/\222\FS9(\185g\173\174x_I\224)",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode10) { + uint8_t pkt[] = {0x82, 0xea, 0x1, 0x29, 0xab, 0x0, 0x1b, 0x49, 0x99, 0x0, 0xce, 0x86, 0xa3, 0x54, 0xde, 0x56, 0x60, + 0x62, 0xe8, 0x49, 0xe8, 0xfe, 0x75, 0xd5, 0x7d, 0x3d, 0x91, 0xea, 0xc8, 0x24, 0xb7, 0x23, 0x94, 0xb3, + 0x1, 0x0, 0xf, 0x54, 0x16, 0xb8, 0x2e, 0x35, 0x83, 0x38, 0x72, 0x27, 0xdd, 0xb8, 0xaa, 0x41, 0x75, + 0x4c, 0x1, 0x0, 0xd, 0xc2, 0x1a, 0x16, 0x8b, 0x0, 0x0, 0xe9, 0x1e, 0xe2, 0xb1, 0x1a, 0xb7, 0x80, + 0x0, 0x0, 0x13, 0x87, 0xc4, 0xe8, 0xc8, 0x1, 0x6d, 0x1d, 0xc2, 0xeb, 0xa, 0x7c, 0x1, 0xfb, 0x17, + 0xc, 0x37, 0x89, 0x1c, 0xd3, 0x2, 0x0, 0x5, 0xe1, 0xf0, 0x1, 0x20, 0x1a, 0x0, 0x0, 0x1d, 0x3a, + 0x31, 0x52, 0xa5, 0x2d, 0xe4, 0x46, 0xdb, 0x3e, 0x88, 0x4, 0x3f, 0xc6, 0xe0, 0x12, 0x81, 0x5a, 0xd7, + 0xfa, 0x56, 0xbc, 0xc0, 0x96, 0xdc, 0x18, 0xb9, 0xca, 0xd0, 0x5e, 0x2, 0x0, 0x16, 0x41, 0x8c, 0x38, + 0x14, 0x3f, 0x19, 0x76, 0x18, 0xd6, 0x9, 0x1c, 0x27, 0xff, 0xd0, 0x6e, 0xd1, 0xda, 0xbc, 0x8c, 0xe5, + 0x6f, 0x40, 0x1, 0x0, 0xb, 0x36, 0x8d, 0x94, 0x41, 0xa1, 0x4d, 0xb6, 0x19, 0x81, 0x14, 0x52, 0x2, + 0x0, 0xd, 0x57, 0x27, 0xe0, 0x80, 0x7d, 0x4e, 0xb1, 0x6d, 0x89, 0x63, 0x2e, 0xd, 0x21, 0x0, 0x0, + 0xf, 0x9f, 0x36, 0x42, 0x7e, 0xd8, 0x55, 0x95, 0x2d, 0xf0, 0xe6, 0xc2, 0xda, 0x9d, 0xa6, 0x15, 0x0, + 0x0, 0x1e, 0x31, 0xa1, 0xa0, 0x1d, 0xd3, 0xaf, 0x64, 0xb2, 0xd5, 0x1, 0x76, 0x87, 0xab, 0x25, 0x9b, + 0x42, 0x2f, 0xde, 0x1c, 0x39, 0x28, 0xb9, 0x67, 0xad, 0xae, 0x78, 0x5f, 0x49, 0xe0, 0x29, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x84, 0xc5, 0xe8, 0xb0, 0x80, 0x3e, 0xa7, 0x15, 0x61}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x49, 0x99, 0x0, 0xce, 0x86, 0xa3, 0x54, 0xde, 0x56, 0x60, 0x62, 0xe8, 0x49, 0xe8, + 0xfe, 0x75, 0xd5, 0x7d, 0x3d, 0x91, 0xea, 0xc8, 0x24, 0xb7, 0x23, 0x94, 0xb3}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb2, 0xf2, 0x44, 0x6f, 0xcd, 0x81, 0xb0, 0x87, 0xa9, 0xf5, - 0xc2, 0x2, 0x58, 0x7c, 0xc4, 0xcf, 0xe3, 0xc4, 0xa9, 0x5c, - 0x10, 0xaf, 0x8a, 0xc8, 0xb, 0xba, 0x87, 0x79, 0x4c, 0xac}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x54, 0x16, 0xb8, 0x2e, 0x35, 0x83, 0x38, 0x72, + 0x27, 0xdd, 0xb8, 0xaa, 0x41, 0x75, 0x4c}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x40, 0x66, 0xab, 0xf7, 0xbd, 0x99, 0xbf, 0xa2, 0x36, 0x36, - 0xf8, 0xbf, 0x3a, 0xa7, 0xea, 0x6e, 0x77, 0xdc, 0x52, 0xc3, - 0x33, 0x1, 0x37, 0x32, 0xeb, 0x7, 0x4, 0x78}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc2, 0x1a, 0x16, 0x8b, 0x0, 0x0, 0xe9, 0x1e, 0xe2, 0xb1, 0x1a, 0xb7, 0x80}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf1, 0x87, 0x5a, 0xb6, 0xd2, 0x4f, 0xca, 0xf8, 0x36, 0x15, 0xd7, 0x12, 0xd9, - 0x4, 0xab, 0x80, 0xad, 0x2e, 0xb7, 0x8a, 0x71, 0x4d, 0x5d, 0x6c, 0xc6, 0x5f}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x87, 0xc4, 0xe8, 0xc8, 0x1, 0x6d, 0x1d, 0xc2, 0xeb, 0xa, + 0x7c, 0x1, 0xfb, 0x17, 0xc, 0x37, 0x89, 0x1c, 0xd3}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7b, 0x1b, 0x41, 0x3, 0xe9, 0x4a, 0x7d, 0x93, 0x13}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xe1, 0xf0, 0x1, 0x20, 0x1a}; + lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf2, 0x4c, 0xf5, 0xd, 0xbd, 0xbb, 0xce}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x3a, 0x31, 0x52, 0xa5, 0x2d, 0xe4, 0x46, 0xdb, 0x3e, 0x88, + 0x4, 0x3f, 0xc6, 0xe0, 0x12, 0x81, 0x5a, 0xd7, 0xfa, 0x56, + 0xbc, 0xc0, 0x96, 0xdc, 0x18, 0xb9, 0xca, 0xd0, 0x5e}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x7b, 0x34, 0x1d, 0x9, 0xc2, 0x48, 0xce, 0x1c, 0xb0}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x41, 0x8c, 0x38, 0x14, 0x3f, 0x19, 0x76, 0x18, 0xd6, 0x9, 0x1c, + 0x27, 0xff, 0xd0, 0x6e, 0xd1, 0xda, 0xbc, 0x8c, 0xe5, 0x6f, 0x40}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xcb, 0xf7, 0x5c, 0x60, 0x5b, 0xc1}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x36, 0x8d, 0x94, 0x41, 0xa1, 0x4d, 0xb6, 0x19, 0x81, 0x14, 0x52}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x99, 0xa4, 0xb0, 0xe4, 0xda, 0xa2, 0xc6, 0xe7, 0xf, - 0x87, 0x5f, 0x5c, 0x50, 0xf9, 0xb0, 0xa9, 0xc8, 0x53}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x57, 0x27, 0xe0, 0x80, 0x7d, 0x4e, 0xb1, 0x6d, 0x89, 0x63, 0x2e, 0xd, 0x21}; + lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x38, 0xc1, 0xfa, 0xb2, 0xb4, 0x60, 0xa1, 0xcc, 0xf0, 0xf5, 0x81, 0x2f, 0x15, - 0x89, 0xf2, 0xe9, 0x66, 0x0, 0xb3, 0xab, 0x1f, 0x9d, 0xc5, 0x74, 0x58, 0x27}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0x9f, 0x36, 0x42, 0x7e, 0xd8, 0x55, 0x95, 0x2d, + 0xf0, 0xe6, 0xc2, 0xda, 0x9d, 0xa6, 0x15}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xc1, 0xe5, 0x93, 0x26, 0xb0, 0x96, 0x50, 0x11, 0x7d, 0xc3, 0xf, 0xcb, 0x21, - 0x56, 0xb9, 0xe, 0x2d, 0x59, 0x4b, 0xc1, 0x83, 0x4b, 0xc3, 0x95, 0xd3}; - lwmqtt_string_t topic_filter_s10 = {25, (char*)&topic_filter_s10_bytes}; + uint8_t topic_filter_s10_bytes[] = {0x31, 0xa1, 0xa0, 0x1d, 0xd3, 0xaf, 0x64, 0xb2, 0xd5, 0x1, + 0x76, 0x87, 0xab, 0x25, 0x9b, 0x42, 0x2f, 0xde, 0x1c, 0x39, + 0x28, 0xb9, 0x67, 0xad, 0xae, 0x78, 0x5f, 0x49, 0xe0, 0x29}; + lwmqtt_string_t topic_filter_s10 = {30, (char*)&topic_filter_s10_bytes}; topic_filters[10] = topic_filter_s10; lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -11035,15 +10936,15 @@ TEST(Subscribe311QCTest, Encode13) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].qos = LWMQTT_QOS0; sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].qos = LWMQTT_QOS2; sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[10].retain_as_published = false; sub_opts[10].no_local = false; @@ -11053,59 +10954,54 @@ TEST(Subscribe311QCTest, Encode13) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12709, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10667, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14473 [("\173\230\ESC\133\246\196\156\135\200q|\DC2\188\236\FS\153\183\SO\142b",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\CAN\192\&41\164\131Z8\251)\173>\128\193\211\222\167G\162\167\149}\129\174",SubOptions {_retainHandling = +// SubscribeRequest 13196 [("\171M\DLE+(\172\SIL\DEL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS2}),("\182H\165\138\247\bHO\207\164\ACKr\239\151\ENQ\137\190k\182\&4",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("g\226\&6wT\129\254\179\NUL\228\163\218\238\131\130\198\131\172\r\"\223\195\172\130",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("u\138\167\DEL\SI\167\172\136\244\217\249\185\239B\228y",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\193\254#\159\210\150\130\"\250",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\236\179\227\206P\141i\DC3\EM\237\243\232\"cG\151\199\190I",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0x84, 0x1, 0x38, 0x89, 0x0, 0x14, 0xad, 0xe6, 0x1b, 0x85, 0xf6, 0xc4, 0x9c, 0x87, 0xc8, 0x71, - 0x7c, 0x12, 0xbc, 0xec, 0x1c, 0x99, 0xb7, 0xe, 0x8e, 0x62, 0x0, 0x0, 0x18, 0x18, 0xc0, 0x34, 0x31, - 0xa4, 0x83, 0x5a, 0x38, 0xfb, 0x29, 0xad, 0x3e, 0x80, 0xc1, 0xd3, 0xde, 0xa7, 0x47, 0xa2, 0xa7, 0x95, - 0x7d, 0x81, 0xae, 0x2, 0x0, 0x18, 0x67, 0xe2, 0x36, 0x77, 0x54, 0x81, 0xfe, 0xb3, 0x0, 0xe4, 0xa3, - 0xda, 0xee, 0x83, 0x82, 0xc6, 0x83, 0xac, 0xd, 0x22, 0xdf, 0xc3, 0xac, 0x82, 0x1, 0x0, 0x10, 0x75, - 0x8a, 0xa7, 0x7f, 0xf, 0xa7, 0xac, 0x88, 0xf4, 0xd9, 0xf9, 0xb9, 0xef, 0x42, 0xe4, 0x79, 0x0, 0x0, - 0x9, 0xc1, 0xfe, 0x23, 0x9f, 0xd2, 0x96, 0x82, 0x22, 0xfa, 0x0, 0x0, 0x13, 0xec, 0xb3, 0xe3, 0xce, - 0x50, 0x8d, 0x69, 0x13, 0x19, 0xed, 0xf3, 0xe8, 0x22, 0x63, 0x47, 0x97, 0xc7, 0xbe, 0x49, 0x0}; +// QoS2}),("\231~\137\219\155\189\239N\199\208$X\206\145\176Q0\SIv\145\ETX",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\135\&4Dk@\b\247\150\217%:t\198f\195\&4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("\186,\216\227\251\233`o\219\177\179\DC4\ETB\226\180\143\194\CAN\202\140\&1Y\213\a\ACKq\165^",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode11) { + uint8_t pkt[] = {0x82, 0x6f, 0x33, 0x8c, 0x0, 0x9, 0xab, 0x4d, 0x10, 0x2b, 0x28, 0xac, 0xf, 0x4c, 0x7f, 0x2, 0x0, + 0x14, 0xb6, 0x48, 0xa5, 0x8a, 0xf7, 0x8, 0x48, 0x4f, 0xcf, 0xa4, 0x6, 0x72, 0xef, 0x97, 0x5, 0x89, + 0xbe, 0x6b, 0xb6, 0x34, 0x2, 0x0, 0x15, 0xe7, 0x7e, 0x89, 0xdb, 0x9b, 0xbd, 0xef, 0x4e, 0xc7, 0xd0, + 0x24, 0x58, 0xce, 0x91, 0xb0, 0x51, 0x30, 0xf, 0x76, 0x91, 0x3, 0x2, 0x0, 0x10, 0x87, 0x34, 0x44, + 0x6b, 0x40, 0x8, 0xf7, 0x96, 0xd9, 0x25, 0x3a, 0x74, 0xc6, 0x66, 0xc3, 0x34, 0x2, 0x0, 0x1c, 0xba, + 0x2c, 0xd8, 0xe3, 0xfb, 0xe9, 0x60, 0x6f, 0xdb, 0xb1, 0xb3, 0x14, 0x17, 0xe2, 0xb4, 0x8f, 0xc2, 0x18, + 0xca, 0x8c, 0x31, 0x59, 0xd5, 0x7, 0x6, 0x71, 0xa5, 0x5e, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xad, 0xe6, 0x1b, 0x85, 0xf6, 0xc4, 0x9c, 0x87, 0xc8, 0x71, - 0x7c, 0x12, 0xbc, 0xec, 0x1c, 0x99, 0xb7, 0xe, 0x8e, 0x62}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xab, 0x4d, 0x10, 0x2b, 0x28, 0xac, 0xf, 0x4c, 0x7f}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x18, 0xc0, 0x34, 0x31, 0xa4, 0x83, 0x5a, 0x38, 0xfb, 0x29, 0xad, 0x3e, - 0x80, 0xc1, 0xd3, 0xde, 0xa7, 0x47, 0xa2, 0xa7, 0x95, 0x7d, 0x81, 0xae}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb6, 0x48, 0xa5, 0x8a, 0xf7, 0x8, 0x48, 0x4f, 0xcf, 0xa4, + 0x6, 0x72, 0xef, 0x97, 0x5, 0x89, 0xbe, 0x6b, 0xb6, 0x34}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x67, 0xe2, 0x36, 0x77, 0x54, 0x81, 0xfe, 0xb3, 0x0, 0xe4, 0xa3, 0xda, - 0xee, 0x83, 0x82, 0xc6, 0x83, 0xac, 0xd, 0x22, 0xdf, 0xc3, 0xac, 0x82}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe7, 0x7e, 0x89, 0xdb, 0x9b, 0xbd, 0xef, 0x4e, 0xc7, 0xd0, 0x24, + 0x58, 0xce, 0x91, 0xb0, 0x51, 0x30, 0xf, 0x76, 0x91, 0x3}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x75, 0x8a, 0xa7, 0x7f, 0xf, 0xa7, 0xac, 0x88, - 0xf4, 0xd9, 0xf9, 0xb9, 0xef, 0x42, 0xe4, 0x79}; + uint8_t topic_filter_s3_bytes[] = {0x87, 0x34, 0x44, 0x6b, 0x40, 0x8, 0xf7, 0x96, + 0xd9, 0x25, 0x3a, 0x74, 0xc6, 0x66, 0xc3, 0x34}; lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc1, 0xfe, 0x23, 0x9f, 0xd2, 0x96, 0x82, 0x22, 0xfa}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xba, 0x2c, 0xd8, 0xe3, 0xfb, 0xe9, 0x60, 0x6f, 0xdb, 0xb1, + 0xb3, 0x14, 0x17, 0xe2, 0xb4, 0x8f, 0xc2, 0x18, 0xca, 0x8c, + 0x31, 0x59, 0xd5, 0x7, 0x6, 0x71, 0xa5, 0x5e}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xec, 0xb3, 0xe3, 0xce, 0x50, 0x8d, 0x69, 0x13, 0x19, 0xed, - 0xf3, 0xe8, 0x22, 0x63, 0x47, 0x97, 0xc7, 0xbe, 0x49}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11113,11 +11009,11 @@ TEST(Subscribe311QCTest, Encode14) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -11125,247 +11021,197 @@ TEST(Subscribe311QCTest, Encode14) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14473, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13196, 5, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 11145 [("\237\a\171\195\220\245\232@\229P\146~C\193\193\139\138\EOTF\139\ACK\135\ETX\253",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode12) { + uint8_t pkt[] = {0x82, 0x1d, 0x2b, 0x89, 0x0, 0x18, 0xed, 0x7, 0xab, 0xc3, 0xdc, 0xf5, 0xe8, 0x40, 0xe5, 0x50, + 0x92, 0x7e, 0x43, 0xc1, 0xc1, 0x8b, 0x8a, 0x4, 0x46, 0x8b, 0x6, 0x87, 0x3, 0xfd, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xed, 0x7, 0xab, 0xc3, 0xdc, 0xf5, 0xe8, 0x40, 0xe5, 0x50, 0x92, 0x7e, + 0x43, 0xc1, 0xc1, 0x8b, 0x8a, 0x4, 0x46, 0x8b, 0x6, 0x87, 0x3, 0xfd}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11145, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3580 [("\244E\204\&6O\ACKRSi\250\193:i*L\v{\159\212\243!\DLE\200o\175\172\236d\232\RS",SubOptions +// SubscribeRequest 22549 +// [("q&N\176\217\FS\143\140\217\b\164\171\163\233\237\200\214\223\156\197\201\182e\DC3q",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\251N<\255g\164",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("N\248\172\a7\159\250\EM\227{\179\201O\161ZR\140\251\188\207\144\212\STX\173\150w",SubOptions +// QoS1}),("\236\US\180\241\219\242\200\196\229J\244\135\&7]\225L\136\132\213\128\&8\252\234\US\157\230k\NAK}g",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\155W\251\fk<\195p\184\253\175A\162\210\ETB",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("v\DLE\188\STXG!\142W\193\182\236H\NUL\fO$`\253e+\SO\214",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\163+\244m -// 1\138n\233\129sR\182\CAN\137\199(BB}\202\196m\231\208XEz\148",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("j\148\131KK\155",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Y\f\153\US\197\228\\\211\233\&9\CAN>\237\190\193\v\239\GSb",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("/\r\190",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("yL\254\155\&0U{\DLE\199\211\253\189\183F\149\222\US\218\186\b\175\DC2\252'\156",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\US&\190d\ETX~\239/\NAK\128\228\240io\227\DC1\SUB6\DC1\175 \153",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode15) { - uint8_t pkt[] = {0x82, 0xe5, 0x1, 0xd, 0xfc, 0x0, 0x1e, 0xf4, 0x45, 0xcc, 0x36, 0x4f, 0x6, 0x52, 0x53, 0x69, 0xfa, - 0xc1, 0x3a, 0x69, 0x2a, 0x4c, 0xb, 0x7b, 0x9f, 0xd4, 0xf3, 0x21, 0x10, 0xc8, 0x6f, 0xaf, 0xac, 0xec, - 0x64, 0xe8, 0x1e, 0x2, 0x0, 0x1a, 0x4e, 0xf8, 0xac, 0x7, 0x37, 0x9f, 0xfa, 0x19, 0xe3, 0x7b, 0xb3, - 0xc9, 0x4f, 0xa1, 0x5a, 0x52, 0x8c, 0xfb, 0xbc, 0xcf, 0x90, 0xd4, 0x2, 0xad, 0x96, 0x77, 0x0, 0x0, - 0xf, 0x9b, 0x57, 0xfb, 0xc, 0x6b, 0x3c, 0xc3, 0x70, 0xb8, 0xfd, 0xaf, 0x41, 0xa2, 0xd2, 0x17, 0x0, - 0x0, 0x16, 0x76, 0x10, 0xbc, 0x2, 0x47, 0x21, 0x8e, 0x57, 0xc1, 0xb6, 0xec, 0x48, 0x0, 0xc, 0x4f, - 0x24, 0x60, 0xfd, 0x65, 0x2b, 0xe, 0xd6, 0x1, 0x0, 0x1d, 0xa3, 0x2b, 0xf4, 0x6d, 0x20, 0x31, 0x8a, - 0x6e, 0xe9, 0x81, 0x73, 0x52, 0xb6, 0x18, 0x89, 0xc7, 0x28, 0x42, 0x42, 0x7d, 0xca, 0xc4, 0x6d, 0xe7, - 0xd0, 0x58, 0x45, 0x7a, 0x94, 0x1, 0x0, 0x6, 0x6a, 0x94, 0x83, 0x4b, 0x4b, 0x9b, 0x2, 0x0, 0x13, - 0x59, 0xc, 0x99, 0x1f, 0xc5, 0xe4, 0x5c, 0xd3, 0xe9, 0x39, 0x18, 0x3e, 0xed, 0xbe, 0xc1, 0xb, 0xef, - 0x1d, 0x62, 0x1, 0x0, 0x3, 0x2f, 0xd, 0xbe, 0x0, 0x0, 0x19, 0x79, 0x4c, 0xfe, 0x9b, 0x30, 0x55, - 0x7b, 0x10, 0xc7, 0xd3, 0xfd, 0xbd, 0xb7, 0x46, 0x95, 0xde, 0x1f, 0xda, 0xba, 0x8, 0xaf, 0x12, 0xfc, - 0x27, 0x9c, 0x2, 0x0, 0x16, 0x1f, 0x26, 0xbe, 0x64, 0x3, 0x7e, 0xef, 0x2f, 0x15, 0x80, 0xe4, 0xf0, - 0x69, 0x6f, 0xe3, 0x11, 0x1a, 0x36, 0x11, 0xaf, 0x20, 0x99, 0x1}; +// QoS2}),("\157FH\237\157\&9\207X2\190\240\162\239\164",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode13) { + uint8_t pkt[] = {0x82, 0x59, 0x58, 0x15, 0x0, 0x19, 0x71, 0x26, 0x4e, 0xb0, 0xd9, 0x1c, 0x8f, 0x8c, 0xd9, 0x8, + 0xa4, 0xab, 0xa3, 0xe9, 0xed, 0xc8, 0xd6, 0xdf, 0x9c, 0xc5, 0xc9, 0xb6, 0x65, 0x13, 0x71, 0x0, + 0x0, 0x6, 0xfb, 0x4e, 0x3c, 0xff, 0x67, 0xa4, 0x1, 0x0, 0x1e, 0xec, 0x1f, 0xb4, 0xf1, 0xdb, + 0xf2, 0xc8, 0xc4, 0xe5, 0x4a, 0xf4, 0x87, 0x37, 0x5d, 0xe1, 0x4c, 0x88, 0x84, 0xd5, 0x80, 0x38, + 0xfc, 0xea, 0x1f, 0x9d, 0xe6, 0x6b, 0x15, 0x7d, 0x67, 0x2, 0x0, 0xe, 0x9d, 0x46, 0x48, 0xed, + 0x9d, 0x39, 0xcf, 0x58, 0x32, 0xbe, 0xf0, 0xa2, 0xef, 0xa4, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xf4, 0x45, 0xcc, 0x36, 0x4f, 0x6, 0x52, 0x53, 0x69, 0xfa, - 0xc1, 0x3a, 0x69, 0x2a, 0x4c, 0xb, 0x7b, 0x9f, 0xd4, 0xf3, - 0x21, 0x10, 0xc8, 0x6f, 0xaf, 0xac, 0xec, 0x64, 0xe8, 0x1e}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x71, 0x26, 0x4e, 0xb0, 0xd9, 0x1c, 0x8f, 0x8c, 0xd9, 0x8, 0xa4, 0xab, 0xa3, + 0xe9, 0xed, 0xc8, 0xd6, 0xdf, 0x9c, 0xc5, 0xc9, 0xb6, 0x65, 0x13, 0x71}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4e, 0xf8, 0xac, 0x7, 0x37, 0x9f, 0xfa, 0x19, 0xe3, 0x7b, 0xb3, 0xc9, 0x4f, - 0xa1, 0x5a, 0x52, 0x8c, 0xfb, 0xbc, 0xcf, 0x90, 0xd4, 0x2, 0xad, 0x96, 0x77}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xfb, 0x4e, 0x3c, 0xff, 0x67, 0xa4}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9b, 0x57, 0xfb, 0xc, 0x6b, 0x3c, 0xc3, 0x70, - 0xb8, 0xfd, 0xaf, 0x41, 0xa2, 0xd2, 0x17}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xec, 0x1f, 0xb4, 0xf1, 0xdb, 0xf2, 0xc8, 0xc4, 0xe5, 0x4a, + 0xf4, 0x87, 0x37, 0x5d, 0xe1, 0x4c, 0x88, 0x84, 0xd5, 0x80, + 0x38, 0xfc, 0xea, 0x1f, 0x9d, 0xe6, 0x6b, 0x15, 0x7d, 0x67}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x76, 0x10, 0xbc, 0x2, 0x47, 0x21, 0x8e, 0x57, 0xc1, 0xb6, 0xec, - 0x48, 0x0, 0xc, 0x4f, 0x24, 0x60, 0xfd, 0x65, 0x2b, 0xe, 0xd6}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9d, 0x46, 0x48, 0xed, 0x9d, 0x39, 0xcf, + 0x58, 0x32, 0xbe, 0xf0, 0xa2, 0xef, 0xa4}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa3, 0x2b, 0xf4, 0x6d, 0x20, 0x31, 0x8a, 0x6e, 0xe9, 0x81, - 0x73, 0x52, 0xb6, 0x18, 0x89, 0xc7, 0x28, 0x42, 0x42, 0x7d, - 0xca, 0xc4, 0x6d, 0xe7, 0xd0, 0x58, 0x45, 0x7a, 0x94}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6a, 0x94, 0x83, 0x4b, 0x4b, 0x9b}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x59, 0xc, 0x99, 0x1f, 0xc5, 0xe4, 0x5c, 0xd3, 0xe9, 0x39, - 0x18, 0x3e, 0xed, 0xbe, 0xc1, 0xb, 0xef, 0x1d, 0x62}; - lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x2f, 0xd, 0xbe}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x79, 0x4c, 0xfe, 0x9b, 0x30, 0x55, 0x7b, 0x10, 0xc7, 0xd3, 0xfd, 0xbd, 0xb7, - 0x46, 0x95, 0xde, 0x1f, 0xda, 0xba, 0x8, 0xaf, 0x12, 0xfc, 0x27, 0x9c}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x1f, 0x26, 0xbe, 0x64, 0x3, 0x7e, 0xef, 0x2f, 0x15, 0x80, 0xe4, - 0xf0, 0x69, 0x6f, 0xe3, 0x11, 0x1a, 0x36, 0x11, 0xaf, 0x20, 0x99}; - lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3580, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22549, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8671 [("\137/\167\132\169\250\&8Z\230",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("vQ\229\222\160\&5\214\180",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\227~\DC4\240\205\167\163\150\&9\US\197\SIO\186>\237\168\235[",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\197\199!H\185\STX\187\SI4oM\179\237 \167(vk\193\195\&4\208\205*^\161\153\178\RS",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\166\188\156I\185\220\&3S#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),(".\204\SYNt\DEL\ETXV\"6\RS\192\193\199\228\130\160",SubOptions {_retainHandling = +// SubscribeRequest 18393 [("{\US\242",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\201=\vz\142\EOT\237}\162$\ETXL\232c\RS",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("f\186\US\183;a^\179\132Wd\CAN\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),(",\166\140N",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\175\142\248\&0\231s\212\169^s\151\213\133[J\153L=\USc3",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("\247y\217\183\158j\243\153\130ub\232\193\210\DC4lt\EOTGRnv",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("J\227\239\US\219\166\EM\235K\b8G@\158\156l\216xH\131\&5{\174\253",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0xb8, 0x1, 0x21, 0xdf, 0x0, 0x9, 0x89, 0x2f, 0xa7, 0x84, 0xa9, 0xfa, 0x38, 0x5a, 0xe6, 0x1, - 0x0, 0x8, 0x76, 0x51, 0xe5, 0xde, 0xa0, 0x35, 0xd6, 0xb4, 0x1, 0x0, 0x13, 0xe3, 0x7e, 0x14, 0xf0, - 0xcd, 0xa7, 0xa3, 0x96, 0x39, 0x1f, 0xc5, 0xf, 0x4f, 0xba, 0x3e, 0xed, 0xa8, 0xeb, 0x5b, 0x0, 0x0, - 0x1d, 0xc5, 0xc7, 0x21, 0x48, 0xb9, 0x2, 0xbb, 0xf, 0x34, 0x6f, 0x4d, 0xb3, 0xed, 0x20, 0xa7, 0x28, - 0x76, 0x6b, 0xc1, 0xc3, 0x34, 0xd0, 0xcd, 0x2a, 0x5e, 0xa1, 0x99, 0xb2, 0x1e, 0x1, 0x0, 0x9, 0xa6, - 0xbc, 0x9c, 0x49, 0xb9, 0xdc, 0x33, 0x53, 0x23, 0x2, 0x0, 0x10, 0x2e, 0xcc, 0x16, 0x74, 0x7f, 0x3, - 0x56, 0x22, 0x36, 0x1e, 0xc0, 0xc1, 0xc7, 0xe4, 0x82, 0xa0, 0x1, 0x0, 0xd, 0x66, 0xba, 0x1f, 0xb7, - 0x3b, 0x61, 0x5e, 0xb3, 0x84, 0x57, 0x64, 0x18, 0xdb, 0x2, 0x0, 0x4, 0x2c, 0xa6, 0x8c, 0x4e, 0x2, - 0x0, 0x15, 0xaf, 0x8e, 0xf8, 0x30, 0xe7, 0x73, 0xd4, 0xa9, 0x5e, 0x73, 0x97, 0xd5, 0x85, 0x5b, 0x4a, - 0x99, 0x4c, 0x3d, 0x1f, 0x63, 0x33, 0x1, 0x0, 0x18, 0x4a, 0xe3, 0xef, 0x1f, 0xdb, 0xa6, 0x19, 0xeb, - 0x4b, 0x8, 0x38, 0x47, 0x40, 0x9e, 0x9c, 0x6c, 0xd8, 0x78, 0x48, 0x83, 0x35, 0x7b, 0xae, 0xfd, 0x2}; +// QoS1}),("8\140\&6\235T\162\129K\250\154E\163q\165\161\233\218\239\191\198%\208\222",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\167",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\138)\154\144@\221\174\188\n\143\197\159E6\191\149\251",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("Vi\140c:I\156\DEL\172\220A\GS9zg\167",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\193\198\250h\138\172\219di\163g\DC3\186`\129\162\202w\171\252",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode14) { + uint8_t pkt[] = {0x82, 0x92, 0x1, 0x47, 0xd9, 0x0, 0x3, 0x7b, 0x1f, 0xf2, 0x0, 0x0, 0xf, 0xc9, 0x3d, 0xb, 0x7a, + 0x8e, 0x4, 0xed, 0x7d, 0xa2, 0x24, 0x3, 0x4c, 0xe8, 0x63, 0x1e, 0x2, 0x0, 0x16, 0xf7, 0x79, 0xd9, + 0xb7, 0x9e, 0x6a, 0xf3, 0x99, 0x82, 0x75, 0x62, 0xe8, 0xc1, 0xd2, 0x14, 0x6c, 0x74, 0x4, 0x47, 0x52, + 0x6e, 0x76, 0x1, 0x0, 0x17, 0x38, 0x8c, 0x36, 0xeb, 0x54, 0xa2, 0x81, 0x4b, 0xfa, 0x9a, 0x45, 0xa3, + 0x71, 0xa5, 0xa1, 0xe9, 0xda, 0xef, 0xbf, 0xc6, 0x25, 0xd0, 0xde, 0x2, 0x0, 0x1, 0xa7, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x11, 0x8a, 0x29, 0x9a, 0x90, 0x40, 0xdd, 0xae, 0xbc, 0xa, 0x8f, 0xc5, 0x9f, 0x45, + 0x36, 0xbf, 0x95, 0xfb, 0x0, 0x0, 0x10, 0x56, 0x69, 0x8c, 0x63, 0x3a, 0x49, 0x9c, 0x7f, 0xac, 0xdc, + 0x41, 0x1d, 0x39, 0x7a, 0x67, 0xa7, 0x1, 0x0, 0x14, 0xc1, 0xc6, 0xfa, 0x68, 0x8a, 0xac, 0xdb, 0x64, + 0x69, 0xa3, 0x67, 0x13, 0xba, 0x60, 0x81, 0xa2, 0xca, 0x77, 0xab, 0xfc, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x89, 0x2f, 0xa7, 0x84, 0xa9, 0xfa, 0x38, 0x5a, 0xe6}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x7b, 0x1f, 0xf2}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x76, 0x51, 0xe5, 0xde, 0xa0, 0x35, 0xd6, 0xb4}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc9, 0x3d, 0xb, 0x7a, 0x8e, 0x4, 0xed, 0x7d, + 0xa2, 0x24, 0x3, 0x4c, 0xe8, 0x63, 0x1e}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe3, 0x7e, 0x14, 0xf0, 0xcd, 0xa7, 0xa3, 0x96, 0x39, 0x1f, - 0xc5, 0xf, 0x4f, 0xba, 0x3e, 0xed, 0xa8, 0xeb, 0x5b}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf7, 0x79, 0xd9, 0xb7, 0x9e, 0x6a, 0xf3, 0x99, 0x82, 0x75, 0x62, + 0xe8, 0xc1, 0xd2, 0x14, 0x6c, 0x74, 0x4, 0x47, 0x52, 0x6e, 0x76}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc5, 0xc7, 0x21, 0x48, 0xb9, 0x2, 0xbb, 0xf, 0x34, 0x6f, - 0x4d, 0xb3, 0xed, 0x20, 0xa7, 0x28, 0x76, 0x6b, 0xc1, 0xc3, - 0x34, 0xd0, 0xcd, 0x2a, 0x5e, 0xa1, 0x99, 0xb2, 0x1e}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x38, 0x8c, 0x36, 0xeb, 0x54, 0xa2, 0x81, 0x4b, 0xfa, 0x9a, 0x45, 0xa3, + 0x71, 0xa5, 0xa1, 0xe9, 0xda, 0xef, 0xbf, 0xc6, 0x25, 0xd0, 0xde}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa6, 0xbc, 0x9c, 0x49, 0xb9, 0xdc, 0x33, 0x53, 0x23}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa7}; + lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x2e, 0xcc, 0x16, 0x74, 0x7f, 0x3, 0x56, 0x22, - 0x36, 0x1e, 0xc0, 0xc1, 0xc7, 0xe4, 0x82, 0xa0}; - lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x66, 0xba, 0x1f, 0xb7, 0x3b, 0x61, 0x5e, 0xb3, 0x84, 0x57, 0x64, 0x18, 0xdb}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x8a, 0x29, 0x9a, 0x90, 0x40, 0xdd, 0xae, 0xbc, 0xa, + 0x8f, 0xc5, 0x9f, 0x45, 0x36, 0xbf, 0x95, 0xfb}; + lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x2c, 0xa6, 0x8c, 0x4e}; - lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x56, 0x69, 0x8c, 0x63, 0x3a, 0x49, 0x9c, 0x7f, + 0xac, 0xdc, 0x41, 0x1d, 0x39, 0x7a, 0x67, 0xa7}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xaf, 0x8e, 0xf8, 0x30, 0xe7, 0x73, 0xd4, 0xa9, 0x5e, 0x73, 0x97, - 0xd5, 0x85, 0x5b, 0x4a, 0x99, 0x4c, 0x3d, 0x1f, 0x63, 0x33}; - lwmqtt_string_t topic_filter_s8 = {21, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xc1, 0xc6, 0xfa, 0x68, 0x8a, 0xac, 0xdb, 0x64, 0x69, 0xa3, + 0x67, 0x13, 0xba, 0x60, 0x81, 0xa2, 0xca, 0x77, 0xab, 0xfc}; + lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x4a, 0xe3, 0xef, 0x1f, 0xdb, 0xa6, 0x19, 0xeb, 0x4b, 0x8, 0x38, 0x47, - 0x40, 0x9e, 0x9c, 0x6c, 0xd8, 0x78, 0x48, 0x83, 0x35, 0x7b, 0xae, 0xfd}; - lwmqtt_string_t topic_filter_s9 = {24, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; @@ -11373,98 +11219,119 @@ TEST(Subscribe311QCTest, Encode16) { sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8671, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18393, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12528 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\148\&2\192\239\ETBl1G.]3f\EOT\158\156\169i\146#uO\217",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\225L\215\SOHGKI\217p5\225\219\187\228,p\ENQ*\218I\194\153q",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("S\231ewx\206\160\202P",SubOptions {_retainHandling = +// SubscribeRequest 28507 [("\146\199\232\fj\226d",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("*\213\134P\169\&0S\207\229-\255G\158",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\171Kky\198c\184w\165e^\140n\236\SI\DEL\157d;\186d\234\NUL]\161",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\183",SubOptions {_retainHandling = +// QoS1}),("\226\203\183\nO\231\151\nD\225\208!\169N\166\228\220#\DC2WU\SI",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\251\t\179",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("~\144J\231\"6\CAN\145#\205z]\ETXUK\212\&7\145\EOT\176\252\SO",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("a&xM$\210\&9\179\194\SI\232\178-s\215;\DC3E\193\184\RS\SOH\177:S\170\ESC\167\158\220",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\243\135\&4\224\226\170\203",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode17) { - uint8_t pkt[] = {0x82, 0x92, 0x1, 0x30, 0xf0, 0x0, 0x0, 0x2, 0x0, 0x16, 0x94, 0x32, 0xc0, 0xef, 0x17, 0x6c, 0x31, - 0x47, 0x2e, 0x5d, 0x33, 0x66, 0x4, 0x9e, 0x9c, 0xa9, 0x69, 0x92, 0x23, 0x75, 0x4f, 0xd9, 0x0, 0x0, - 0x17, 0xe1, 0x4c, 0xd7, 0x1, 0x47, 0x4b, 0x49, 0xd9, 0x70, 0x35, 0xe1, 0xdb, 0xbb, 0xe4, 0x2c, 0x70, - 0x5, 0x2a, 0xda, 0x49, 0xc2, 0x99, 0x71, 0x1, 0x0, 0x9, 0x53, 0xe7, 0x65, 0x77, 0x78, 0xce, 0xa0, - 0xca, 0x50, 0x0, 0x0, 0x19, 0xab, 0x4b, 0x6b, 0x79, 0xc6, 0x63, 0xb8, 0x77, 0xa5, 0x65, 0x5e, 0x8c, - 0x6e, 0xec, 0xf, 0x7f, 0x9d, 0x64, 0x3b, 0xba, 0x64, 0xea, 0x0, 0x5d, 0xa1, 0x0, 0x0, 0x1, 0xb7, - 0x1, 0x0, 0xa, 0x3b, 0xf6, 0x86, 0xaa, 0xe0, 0xcf, 0x7a, 0x1e, 0x43, 0x71, 0x1, 0x0, 0x1e, 0x4a, - 0x1c, 0xce, 0x4e, 0x42, 0x9a, 0xfd, 0x8, 0x1f, 0xc5, 0xac, 0x2a, 0x3d, 0xe8, 0x43, 0x4f, 0xd4, 0xd2, - 0xb5, 0xca, 0x30, 0x2c, 0x26, 0x3e, 0x87, 0x34, 0xe0, 0xe2, 0xaa, 0xcb, 0x0}; +// QoS2}),("q\153\236Z\130\171\216\197\231W\253\192\139w\159\140\236\ENQ\215~\174\170t\NUL\154\179{\GS\253",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("0^\RS\201\&4\228\214UU\a.\252\227V\\\SOH\198\n.\162\217\196",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\167Y1\156C@\EOTw\191",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode15) { + uint8_t pkt[] = { + 0x82, 0xee, 0x1, 0x6f, 0x5b, 0x0, 0x7, 0x92, 0xc7, 0xe8, 0xc, 0x6a, 0xe2, 0x64,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a, 0xb3, 0x7b, 0x1d, 0xfd, 0x1, 0x0, 0x16, 0x30, 0x5e, 0x1e, + 0xc9, 0x34, 0xe4, 0xd6, 0x55, 0x55, 0x7, 0x2e, 0xfc, 0xe3, 0x56, 0x5c, 0x1, 0xc6, 0xa, 0x2e, 0xa2, 0xd9, 0xc4, + 0x0, 0x0, 0x9, 0xa7, 0x59, 0x31, 0x9c, 0x43, 0x40, 0x4, 0x77, 0xbf, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x92, 0xc7, 0xe8, 0xc, 0x6a, 0xe2, 0x64}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x94, 0x32, 0xc0, 0xef, 0x17, 0x6c, 0x31, 0x47, 0x2e, 0x5d, 0x33, - 0x66, 0x4, 0x9e, 0x9c, 0xa9, 0x69, 0x92, 0x23, 0x75, 0x4f, 0xd9}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2a, 0xd5, 0x86, 0x50, 0xa9, 0x30, 0x53, 0xcf, 0xe5, 0x2d, 0xff, 0x47, 0x9e}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe1, 0x4c, 0xd7, 0x1, 0x47, 0x4b, 0x49, 0xd9, 0x70, 0x35, 0xe1, 0xdb, - 0xbb, 0xe4, 0x2c, 0x70, 0x5, 0x2a, 0xda, 0x49, 0xc2, 0x99, 0x71}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe2, 0xcb, 0xb7, 0xa, 0x4f, 0xe7, 0x97, 0xa, 0x44, 0xe1, 0xd0, + 0x21, 0xa9, 0x4e, 0xa6, 0xe4, 0xdc, 0x23, 0x12, 0x57, 0x55, 0xf}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x53, 0xe7, 0x65, 0x77, 0x78, 0xce, 0xa0, 0xca, 0x50}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfb, 0x9, 0xb3}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xab, 0x4b, 0x6b, 0x79, 0xc6, 0x63, 0xb8, 0x77, 0xa5, 0x65, 0x5e, 0x8c, 0x6e, - 0xec, 0xf, 0x7f, 0x9d, 0x64, 0x3b, 0xba, 0x64, 0xea, 0x0, 0x5d, 0xa1}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x7e, 0x90, 0x4a, 0xe7, 0x22, 0x36, 0x18, 0x91, 0x23, 0xcd, 0x7a, + 0x5d, 0x3, 0x55, 0x4b, 0xd4, 0x37, 0x91, 0x4, 0xb0, 0xfc, 0xe}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb7}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x61, 0x26, 0x78, 0x4d, 0x24, 0xd2, 0x39, 0xb3, 0xc2, 0xf, + 0xe8, 0xb2, 0x2d, 0x73, 0xd7, 0x3b, 0x13, 0x45, 0xc1, 0xb8, + 0x1e, 0x1, 0xb1, 0x3a, 0x53, 0xaa, 0x1b, 0xa7, 0x9e, 0xdc}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3b, 0xf6, 0x86, 0xaa, 0xe0, 0xcf, 0x7a, 0x1e, 0x43, 0x71}; - lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xf3, 0x3c, 0x67, 0xd3, 0xc6, 0x22, 0x51, 0x7a, 0x75, 0xb8, + 0x52, 0x7, 0x5f, 0x63, 0x7, 0x91, 0x28, 0x7d, 0x25, 0x1a, + 0x6e, 0x31, 0x7f, 0x26, 0x20, 0x2e, 0xe4, 0xa5}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x4a, 0x1c, 0xce, 0x4e, 0x42, 0x9a, 0xfd, 0x8, 0x1f, 0xc5, - 0xac, 0x2a, 0x3d, 0xe8, 0x43, 0x4f, 0xd4, 0xd2, 0xb5, 0xca, - 0x30, 0x2c, 0x26, 0x3e, 0x87, 0x34, 0xe0, 0xe2, 0xaa, 0xcb}; - lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xf1, 0x84, 0xa1, 0x9c, 0xf4, 0x8d, 0x46, 0xda, 0xf9, + 0xc9, 0xcc, 0x90, 0xca, 0xc4, 0x39, 0x60, 0x1d, 0xa5}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; + uint8_t topic_filter_s8_bytes[] = {0x71, 0x99, 0xec, 0x5a, 0x82, 0xab, 0xd8, 0xc5, 0xe7, 0x57, + 0xfd, 0xc0, 0x8b, 0x77, 0x9f, 0x8c, 0xec, 0x5, 0xd7, 0x7e, + 0xae, 0xaa, 0x74, 0x0, 0x9a, 0xb3, 0x7b, 0x1d, 0xfd}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x30, 0x5e, 0x1e, 0xc9, 0x34, 0xe4, 0xd6, 0x55, 0x55, 0x7, 0x2e, + 0xfc, 0xe3, 0x56, 0x5c, 0x1, 0xc6, 0xa, 0x2e, 0xa2, 0xd9, 0xc4}; + lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xa7, 0x59, 0x31, 0x9c, 0x43, 0x40, 0x4, 0x77, 0xbf}; + lwmqtt_string_t topic_filter_s10 = {9, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -11472,124 +11339,185 @@ TEST(Subscribe311QCTest, Encode17) { sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12528, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28507, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9386 [("\209\EM\NUL~%q\250\200\SYNf]\226\199+9\165'\162\178V\208\DLE",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\n\ETB\130\245\135\213\245\138\&6E\221M\DC2]\175\198\214CL8\139",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("(pn\242\166\175uq\214\245\142\vZR\209",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode18) { - uint8_t pkt[] = {0x82, 0x45, 0x24, 0xaa, 0x0, 0x16, 0xd1, 0x19, 0x0, 0x7e, 0x25, 0x71, 0xfa, 0xc8, 0x16, - 0x66, 0x5d, 0xe2, 0xc7, 0x2b, 0x39, 0xa5, 0x27, 0xa2, 0xb2, 0x56, 0xd0, 0x10, 0x1, 0x0, - 0x15, 0xa, 0x17, 0x82, 0xf5, 0x87, 0xd5, 0xf5, 0x8a, 0x36, 0x45, 0xdd, 0x4d, 0x12, 0x5d, - 0xaf, 0xc6, 0xd6, 0x43, 0x4c, 0x38, 0x8b, 0x0, 0x0, 0xf, 0x28, 0x70, 0x6e, 0xf2, 0xa6, - 0xaf, 0x75, 0x71, 0xd6, 0xf5, 0x8e, 0xb, 0x5a, 0x52, 0xd1, 0x2}; +// SubscribeRequest 23094 [("\128\&6\225\129\221\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("\163\250\137\240\239Q\202\n\217\167\232\STX\199\245m\147/\184\154\ESC\\-F\223\n\141\220\&1'\196",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\254\143\243T\251\204J",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS0}),("\250\165\218\255^o\227\134\STXZ\172\209\130\n7F\146\SO\237~H",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\173\FS\206\233\172\r\198\\\142\185*\217L1\233v`",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode16) { + uint8_t pkt[] = {0x82, 0x62, 0x5a, 0x36, 0x0, 0x6, 0x80, 0x36, 0xe1, 0x81, 0xdd, 0xaa, 0x0, 0x0, 0x1e, 0xa3, 0xfa, + 0x89, 0xf0, 0xef, 0x51, 0xca, 0xa, 0xd9, 0xa7, 0xe8, 0x2, 0xc7, 0xf5, 0x6d, 0x93, 0x2f, 0xb8, 0x9a, + 0x1b, 0x5c, 0x2d, 0x46, 0xdf, 0xa, 0x8d, 0xdc, 0x31, 0x27, 0xc4, 0x2, 0x0, 0x7, 0xfe, 0x8f, 0xf3, + 0x54, 0xfb, 0xcc, 0x4a, 0x0, 0x0, 0x15, 0xfa, 0xa5, 0xda, 0xff, 0x5e, 0x6f, 0xe3, 0x86, 0x2, 0x5a, + 0xac, 0xd1, 0x82, 0xa, 0x37, 0x46, 0x92, 0xe, 0xed, 0x7e, 0x48, 0x0, 0x0, 0x11, 0xad, 0x1c, 0xce, + 0xe9, 0xac, 0xd, 0xc6, 0x5c, 0x8e, 0xb9, 0x2a, 0xd9, 0x4c, 0x31, 0xe9, 0x76, 0x60, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xd1, 0x19, 0x0, 0x7e, 0x25, 0x71, 0xfa, 0xc8, 0x16, 0x66, 0x5d, - 0xe2, 0xc7, 0x2b, 0x39, 0xa5, 0x27, 0xa2, 0xb2, 0x56, 0xd0, 0x10}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x80, 0x36, 0xe1, 0x81, 0xdd, 0xaa}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa, 0x17, 0x82, 0xf5, 0x87, 0xd5, 0xf5, 0x8a, 0x36, 0x45, 0xdd, - 0x4d, 0x12, 0x5d, 0xaf, 0xc6, 0xd6, 0x43, 0x4c, 0x38, 0x8b}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa3, 0xfa, 0x89, 0xf0, 0xef, 0x51, 0xca, 0xa, 0xd9, 0xa7, + 0xe8, 0x2, 0xc7, 0xf5, 0x6d, 0x93, 0x2f, 0xb8, 0x9a, 0x1b, + 0x5c, 0x2d, 0x46, 0xdf, 0xa, 0x8d, 0xdc, 0x31, 0x27, 0xc4}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x28, 0x70, 0x6e, 0xf2, 0xa6, 0xaf, 0x75, 0x71, - 0xd6, 0xf5, 0x8e, 0xb, 0x5a, 0x52, 0xd1}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xfe, 0x8f, 0xf3, 0x54, 0xfb, 0xcc, 0x4a}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s3_bytes[] = {0xfa, 0xa5, 0xda, 0xff, 0x5e, 0x6f, 0xe3, 0x86, 0x2, 0x5a, 0xac, + 0xd1, 0x82, 0xa, 0x37, 0x46, 0x92, 0xe, 0xed, 0x7e, 0x48}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xad, 0x1c, 0xce, 0xe9, 0xac, 0xd, 0xc6, 0x5c, 0x8e, + 0xb9, 0x2a, 0xd9, 0x4c, 0x31, 0xe9, 0x76, 0x60}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9386, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23094, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 17533 [("(\v5\187IR\198\&8\215Mh\DC1\234\194",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("_E",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\166GM",SubOptions {_retainHandling = +// SubscribeRequest 7726 [("\143]\132\&9x\254\"\152\138W\190\240~\234\155>\147W\SOv%\NAK\US\230l",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\155\"\219\&9`\138\145\182\&3\178\147\226G\a[h\191`\212`\185\143",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("a]\205\220o\197]\139qT\177$?P\151\158\141=\231\157\249k\231H\159\163.",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode18) { + uint8_t pkt[] = {0x82, 0xe6, 0x1, 0x4, 0xab, 0x0, 0x9, 0x3, 0xbf, 0x9c, 0x1f, 0x33, 0x89, 0x35, 0xbe, 0x61, 0x0, + 0x0, 0xe, 0xa5, 0x15, 0xc4, 0x50, 0x20, 0xec, 0xac, 0xc5, 0x4d, 0x8c, 0xb1, 0x72, 0x1a, 0x9f, 0x0, + 0x0, 0x5, 0x1e, 0xcf, 0xc0, 0xd8, 0xa8, 0x0, 0x0, 0x1a, 0x33, 0xdd, 0x69, 0x11, 0xa2, 0xe2, 0xd6, + 0x45, 0x6e, 0x57, 0xfa, 0x9c, 0xe6, 0xb6, 0x3b, 0x56, 0xc3, 0xe6, 0x64, 0x0, 0xae, 0x3c, 0xad, 0x4a, + 0x8b, 0xa0, 0x1, 0x0, 0x14, 0xfa, 0x75, 0x97, 0x9f, 0x50, 0x27, 0x8b, 0x19, 0x9d, 0x55, 0xfa, 0x2b, + 0x15, 0x48, 0x92, 0x2b, 0x56, 0xca, 0x52, 0x7a, 0x1, 0x0, 0x19, 0xc7, 0x55, 0x53, 0x78, 0xae, 0x69, + 0x61, 0x1d, 0x7a, 0x6, 0x12, 0x5c, 0x29, 0xc0, 0x1, 0x43, 0x8e, 0x60, 0x2f, 0x7c, 0xce, 0x4a, 0x60, + 0x44, 0x4f, 0x1, 0x0, 0x1d, 0xea, 0xc2, 0x81, 0x7e, 0x7a, 0x39, 0x5f, 0x45, 0xc, 0x76, 0x6b, 0xe8, + 0xa8, 0x69, 0x31, 0x7d, 0x29, 0x2f, 0x88, 0x52, 0x54, 0x8d, 0xaa, 0xb8, 0x3a, 0xd2, 0x40, 0xe3, 0x49, + 0x1, 0x0, 0x15, 0x44, 0xa9, 0xd7, 0x2f, 0x30, 0x52, 0x7f, 0xc9, 0x3e, 0xea, 0x9b, 0x3e, 0x93, 0x57, + 0xe, 0x76, 0x25, 0x15, 0x1f, 0xe6, 0x6c, 0x1, 0x0, 0x16, 0x9b, 0x22, 0xdb, 0x39, 0x60, 0x8a, 0x91, + 0xb6, 0x33, 0xb2, 0x93, 0xe2, 0x47, 0x7, 0x5b, 0x68, 0xbf, 0x60, 0xd4, 0x60, 0xb9, 0x8f, 0x0, 0x0, + 0x1b, 0x61, 0x5d, 0xcd, 0xdc, 0x6f, 0xc5, 0x5d, 0x8b, 0x71, 0x54, 0xb1, 0x24, 0x3f, 0x50, 0x97, 0x9e, + 0x8d, 0x3d, 0xe7, 0x9d, 0xf9, 0x6b, 0xe7, 0x48, 0x9f, 0xa3, 0x2e, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xfd, 0xc3, 0x0, 0xa9, 0x1a, 0xcd, 0x2f, 0x16, 0x63, 0xa8, 0xe9, 0x7c, 0x61, - 0xac, 0xa1, 0xbb, 0xec, 0x95, 0x9f, 0x20, 0xde, 0xd7, 0x24, 0xc3, 0x3c}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x3, 0xbf, 0x9c, 0x1f, 0x33, 0x89, 0x35, 0xbe, 0x61}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x45, 0xc9, 0x52, 0x5e, 0x26, 0x1a, 0x2c, 0x94, 0x76, 0x70, 0x40, 0xe0}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa5, 0x15, 0xc4, 0x50, 0x20, 0xec, 0xac, + 0xc5, 0x4d, 0x8c, 0xb1, 0x72, 0x1a, 0x9f}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd7, 0x88, 0x2e, 0x5e, 0x40, 0x7c, 0x73, 0x36, 0x87, 0x3f, 0x55, 0xe7, - 0xe6, 0x51, 0x7b, 0xee, 0x64, 0xa1, 0x83, 0x0, 0xb1, 0x4d, 0x5c, 0x11}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1e, 0xcf, 0xc0, 0xd8, 0xa8}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x88, 0x85, 0x63, 0x82, 0x6, 0x3}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x33, 0xdd, 0x69, 0x11, 0xa2, 0xe2, 0xd6, 0x45, 0x6e, 0x57, 0xfa, 0x9c, 0xe6, + 0xb6, 0x3b, 0x56, 0xc3, 0xe6, 0x64, 0x0, 0xae, 0x3c, 0xad, 0x4a, 0x8b, 0xa0}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x29, 0xab, 0x92, 0xbb, 0xf1, 0x99, 0xef}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xfa, 0x75, 0x97, 0x9f, 0x50, 0x27, 0x8b, 0x19, 0x9d, 0x55, + 0xfa, 0x2b, 0x15, 0x48, 0x92, 0x2b, 0x56, 0xca, 0x52, 0x7a}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8d, 0xf8, 0x12, 0xa1, 0x3f, 0x2c, 0x6a, 0x43, 0xcb, 0x47, 0xc6, - 0x87, 0xcb, 0x86, 0x3d, 0x9d, 0xc0, 0xdd, 0xf9, 0x7e, 0xf6}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xc7, 0x55, 0x53, 0x78, 0xae, 0x69, 0x61, 0x1d, 0x7a, 0x6, 0x12, 0x5c, 0x29, + 0xc0, 0x1, 0x43, 0x8e, 0x60, 0x2f, 0x7c, 0xce, 0x4a, 0x60, 0x44, 0x4f}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbd, 0x4d, 0x21, 0x7c, 0xb2, 0x7e, 0xa6, 0x8d, 0x72, 0x6e, 0xf7, 0x77, 0xea}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xea, 0xc2, 0x81, 0x7e, 0x7a, 0x39, 0x5f, 0x45, 0xc, 0x76, + 0x6b, 0xe8, 0xa8, 0x69, 0x31, 0x7d, 0x29, 0x2f, 0x88, 0x52, + 0x54, 0x8d, 0xaa, 0xb8, 0x3a, 0xd2, 0x40, 0xe3, 0x49}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s7_bytes[] = {0x44, 0xa9, 0xd7, 0x2f, 0x30, 0x52, 0x7f, 0xc9, 0x3e, 0xea, 0x9b, + 0x3e, 0x93, 0x57, 0xe, 0x76, 0x25, 0x15, 0x1f, 0xe6, 0x6c}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x9b, 0x22, 0xdb, 0x39, 0x60, 0x8a, 0x91, 0xb6, 0x33, 0xb2, 0x93, + 0xe2, 0x47, 0x7, 0x5b, 0x68, 0xbf, 0x60, 0xd4, 0x60, 0xb9, 0x8f}; + lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x61, 0x5d, 0xcd, 0xdc, 0x6f, 0xc5, 0x5d, 0x8b, 0x71, 0x54, 0xb1, 0x24, 0x3f, 0x50, + 0x97, 0x9e, 0x8d, 0x3d, 0xe7, 0x9d, 0xf9, 0x6b, 0xe7, 0x48, 0x9f, 0xa3, 0x2e}; + lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -11738,108 +11678,80 @@ TEST(Subscribe311QCTest, Encode21) { sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14558, 7, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 14679 [("\207`\174\172K_\ENQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),(";\232\&5\184JOL\164\ETX\139\154`\228+\DC23`\228",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode22) { - uint8_t pkt[] = {0x82, 0x21, 0x39, 0x57, 0x0, 0x7, 0xcf, 0x60, 0xae, 0xac, 0x4b, 0x5f, - 0x5, 0x2, 0x0, 0x12, 0x3b, 0xe8, 0x35, 0xb8, 0x4a, 0x4f, 0x4c, 0xa4, - 0x3, 0x8b, 0x9a, 0x60, 0xe4, 0x2b, 0x12, 0x33, 0x60, 0xe4, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xcf, 0x60, 0xae, 0xac, 0x4b, 0x5f, 0x5}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3b, 0xe8, 0x35, 0xb8, 0x4a, 0x4f, 0x4c, 0xa4, 0x3, - 0x8b, 0x9a, 0x60, 0xe4, 0x2b, 0x12, 0x33, 0x60, 0xe4}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14679, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1195, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12650 [("\128\169\159\162P\211\&9;",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\208m\216",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\236_\171\216\143\"\186H\168\235\192<\204\ACK\DEL[h\235\178@\147",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\216\RS\142\&4\175O\SOHGI9M\r\US\159\148,2\RS\196\SUB\136\EM\176\GS\129",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(",V\156\135\DC1\226\RS\199Z\rf\r\191.\220.\204\243\227\NAK\198\232\&6$@",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\172\192\171\236\193\&0\139\ENQvR\250\SOH6\160\NAK\191\&9u",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\194\ETXM3U\240\EM\243\176\SO/\205H\143\242wn\138\199\137\156\211\175",SubOptions {_retainHandling = +// SubscribeRequest 4397 +// [("\SUB\ETX\210\235\182\"\235m\202\r6\154h\136\163\131\130\186$\186\129+[\232\241\213\194x\211\187",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\192#0\201ZxW\ENQ\210 ^}0\SOH\CAN\213\248",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS2}),("j\249\215G\224\163\155\205/\178\206fT\139\&0~\215\CAN\233!\DC4",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\EOT\211",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\136\FS\200\185\171\231^l\SO\167\145f\226\219\143`\t^\137F\163",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode23) { - uint8_t pkt[] = {0x82, 0x92, 0x1, 0x31, 0x6a, 0x0, 0x8, 0x80, 0xa9, 0x9f, 0xa2, 0x50, 0xd3, 0x39, 0x3b, 0x1, 0x0, - 0x3, 0xd0, 0x6d, 0xd8, 0x2, 0x0, 0x15, 0xec, 0x5f, 0xab, 0xd8, 0x8f, 0x22, 0xba, 0x48, 0xa8, 0xeb, - 0xc0, 0x3c, 0xcc, 0x6, 0x7f, 0x5b, 0x68, 0xeb, 0xb2, 0x40, 0x93, 0x0, 0x0, 0x19, 0xd8, 0x1e, 0x8e, - 0x34, 0xaf, 0x4f, 0x1, 0x47, 0x49, 0x39, 0x4d, 0xd, 0x1f, 0x9f, 0x94, 0x2c, 0x32, 0x1e, 0xc4, 0x1a, - 0x88, 0x19, 0xb0, 0x1d, 0x81, 0x0, 0x0, 0x19, 0x2c, 0x56, 0x9c, 0x87, 0x11, 0xe2, 0x1e, 0xc7, 0x5a, - 0xd, 0x66, 0xd, 0xbf, 0x2e, 0xdc, 0x2e, 0xcc, 0xf3, 0xe3, 0x15, 0xc6, 0xe8, 0x36, 0x24, 0x40, 0x2, - 0x0, 0x12, 0xac, 0xc0, 0xab, 0xec, 0xc1, 0x30, 0x8b, 0x5, 0x76, 0x52, 0xfa, 0x1, 0x36, 0xa0, 0x15, - 0xbf, 0x39, 0x75, 0x2, 0x0, 0x17, 0xc2, 0x3, 0x4d, 0x33, 0x55, 0xf0, 0x19, 0xf3, 0xb0, 0xe, 0x2f, - 0xcd, 0x48, 0x8f, 0xf2, 0x77, 0x6e, 0x8a, 0xc7, 0x89, 0x9c, 0xd3, 0xaf, 0x2}; +TEST(Subscribe311QCTest, Encode19) { + uint8_t pkt[] = {0x82, 0x72, 0x11, 0x2d, 0x0, 0x1e, 0x1a, 0x3, 0xd2, 0xeb, 0xb6, 0x22, 0xeb, 0x6d, 0xca, 0xd, 0x36, + 0x9a, 0x68, 0x88, 0xa3, 0x83, 0x82, 0xba, 0x24, 0xba, 0x81, 0x2b, 0x5b, 0xe8, 0xf1, 0xd5, 0xc2, 0x78, + 0xd3, 0xbb, 0x2, 0x0, 0x11, 0xc0, 0x23, 0x30, 0xc9, 0x5a, 0x78, 0x57, 0x5, 0xd2, 0x20, 0x5e, 0x7d, + 0x30, 0x1, 0x18, 0xd5, 0xf8, 0x2, 0x0, 0x15, 0x6a, 0xf9, 0xd7, 0x47, 0xe0, 0xa3, 0x9b, 0xcd, 0x2f, + 0xb2, 0xce, 0x66, 0x54, 0x8b, 0x30, 0x7e, 0xd7, 0x18, 0xe9, 0x21, 0x14, 0x1, 0x0, 0x0, 0x0, 0x0, + 0x2, 0x4, 0xd3, 0x1, 0x0, 0x15, 0x88, 0x1c, 0xc8, 0xb9, 0xab, 0xe7, 0x5e, 0x6c, 0xe, 0xa7, 0x91, + 0x66, 0xe2, 0xdb, 0x8f, 0x60, 0x9, 0x5e, 0x89, 0x46, 0xa3, 0x0, 0x0, 0x0, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x80, 0xa9, 0x9f, 0xa2, 0x50, 0xd3, 0x39, 0x3b}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x1a, 0x3, 0xd2, 0xeb, 0xb6, 0x22, 0xeb, 0x6d, 0xca, 0xd, + 0x36, 0x9a, 0x68, 0x88, 0xa3, 0x83, 0x82, 0xba, 0x24, 0xba, + 0x81, 0x2b, 0x5b, 0xe8, 0xf1, 0xd5, 0xc2, 0x78, 0xd3, 0xbb}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd0, 0x6d, 0xd8}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc0, 0x23, 0x30, 0xc9, 0x5a, 0x78, 0x57, 0x5, 0xd2, + 0x20, 0x5e, 0x7d, 0x30, 0x1, 0x18, 0xd5, 0xf8}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xec, 0x5f, 0xab, 0xd8, 0x8f, 0x22, 0xba, 0x48, 0xa8, 0xeb, 0xc0, - 0x3c, 0xcc, 0x6, 0x7f, 0x5b, 0x68, 0xeb, 0xb2, 0x40, 0x93}; + uint8_t topic_filter_s2_bytes[] = {0x6a, 0xf9, 0xd7, 0x47, 0xe0, 0xa3, 0x9b, 0xcd, 0x2f, 0xb2, 0xce, + 0x66, 0x54, 0x8b, 0x30, 0x7e, 0xd7, 0x18, 0xe9, 0x21, 0x14}; lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd8, 0x1e, 0x8e, 0x34, 0xaf, 0x4f, 0x1, 0x47, 0x49, 0x39, 0x4d, 0xd, 0x1f, - 0x9f, 0x94, 0x2c, 0x32, 0x1e, 0xc4, 0x1a, 0x88, 0x19, 0xb0, 0x1d, 0x81}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2c, 0x56, 0x9c, 0x87, 0x11, 0xe2, 0x1e, 0xc7, 0x5a, 0xd, 0x66, 0xd, 0xbf, - 0x2e, 0xdc, 0x2e, 0xcc, 0xf3, 0xe3, 0x15, 0xc6, 0xe8, 0x36, 0x24, 0x40}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x4, 0xd3}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xac, 0xc0, 0xab, 0xec, 0xc1, 0x30, 0x8b, 0x5, 0x76, - 0x52, 0xfa, 0x1, 0x36, 0xa0, 0x15, 0xbf, 0x39, 0x75}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x88, 0x1c, 0xc8, 0xb9, 0xab, 0xe7, 0x5e, 0x6c, 0xe, 0xa7, 0x91, + 0x66, 0xe2, 0xdb, 0x8f, 0x60, 0x9, 0x5e, 0x89, 0x46, 0xa3}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc2, 0x3, 0x4d, 0x33, 0x55, 0xf0, 0x19, 0xf3, 0xb0, 0xe, 0x2f, 0xcd, - 0x48, 0x8f, 0xf2, 0x77, 0x6e, 0x8a, 0xc7, 0x89, 0x9c, 0xd3, 0xaf}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11847,7 +11759,7 @@ TEST(Subscribe311QCTest, Encode23) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -11855,11 +11767,11 @@ TEST(Subscribe311QCTest, Encode23) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -11873,111 +11785,157 @@ TEST(Subscribe311QCTest, Encode23) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12650, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4397, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3665 [("\RS2\128\242",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x9, 0xe, 0x51, 0x0, 0x4, 0x1e, 0x32, 0x80, 0xf2, 0x0}; +// SubscribeRequest 27847 +// [("\243<\205\142\254\168U\222\165,\134\130\135\225_\143\205\US\162\203D\ETBR\SO\n\242\194",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("s\199\173\183n\252\245\235\237\ETX\SOH\189\190M9\160/+",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\148",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("4x\187\128\139\&3\a\DC3\233\136\CAN{\200\172B\213\155\SYNS\175\221\183\195\GS",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode20) { + uint8_t pkt[] = {0x82, 0x54, 0x6c, 0xc7, 0x0, 0x1b, 0xf3, 0x3c, 0xcd, 0x8e, 0xfe, 0xa8, 0x55, 0xde, 0xa5, + 0x2c, 0x86, 0x82, 0x87, 0xe1, 0x5f, 0x8f, 0xcd, 0x1f, 0xa2, 0xcb, 0x44, 0x17, 0x52, 0xe, + 0xa, 0xf2, 0xc2, 0x2, 0x0, 0x12, 0x73, 0xc7, 0xad, 0xb7, 0x6e, 0xfc, 0xf5, 0xeb, 0xed, + 0x3, 0x1, 0xbd, 0xbe, 0x4d, 0x39, 0xa0, 0x2f, 0x2b, 0x0, 0x0, 0x1, 0x94, 0x2, 0x0, + 0x18, 0x34, 0x78, 0xbb, 0x80, 0x8b, 0x33, 0x7, 0x13, 0xe9, 0x88, 0x18, 0x7b, 0xc8, 0xac, + 0x42, 0xd5, 0x9b, 0x16, 0x53, 0xaf, 0xdd, 0xb7, 0xc3, 0x1d, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x1e, 0x32, 0x80, 0xf2}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xf3, 0x3c, 0xcd, 0x8e, 0xfe, 0xa8, 0x55, 0xde, 0xa5, 0x2c, 0x86, 0x82, 0x87, 0xe1, + 0x5f, 0x8f, 0xcd, 0x1f, 0xa2, 0xcb, 0x44, 0x17, 0x52, 0xe, 0xa, 0xf2, 0xc2}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s1_bytes[] = {0x73, 0xc7, 0xad, 0xb7, 0x6e, 0xfc, 0xf5, 0xeb, 0xed, + 0x3, 0x1, 0xbd, 0xbe, 0x4d, 0x39, 0xa0, 0x2f, 0x2b}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x94}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x34, 0x78, 0xbb, 0x80, 0x8b, 0x33, 0x7, 0x13, 0xe9, 0x88, 0x18, 0x7b, + 0xc8, 0xac, 0x42, 0xd5, 0x9b, 0x16, 0x53, 0xaf, 0xdd, 0xb7, 0xc3, 0x1d}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3665, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27847, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23603 [("\197\163\195D\141\173\234\249,\160]\180\nZ\t\FS\244Iu\131s[\184\\",SubOptions +// SubscribeRequest 29011 [("L\255\232\&7",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\ENQ +// \STX\209\189\DEL\160\167\&6~\254\SYN\144\246\217(\GS\207(c\142\241",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\237\194\247\230\ETX\134\225\f\SI\143\242\181\&1+\226EO\223\186\144se\216HY>\170\209",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\182\253\219\136*\159\139\DC1\249\240$r\252\233",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\219\DC4\184\&5M\153\135\234\188\ENQ\184",SubOptions +// QoS0}),("\155O\191\161v\218\167\168_\147\DC1",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\FS\236xY=!\172\241\217\230\209\222\179\DC2\SI",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\218\185}\160^\f\252\130\170}\"u\132m\185\FS\250\157-\169o\DC4",SubOptions {_retainHandling = +// QoS1}),("d}\134\162\229\233`\212\248\207\DC4\254\137\186\232KP\165\222\144",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\128\158`\237A\207\227\151P\STX\248\177\n\202\STX\130N\183\169\198^",SubOptions {_retainHandling = +// QoS2}),("\241\197)E\130G\STX\248\&7w\179\173\243\vTB\FS\212o\195jN\201\151Z\NUL",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\207\255b\143\CAN\FS\140\203!\SYN<\138\131V\187.Y\252\186\253\DC1\150",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\191h",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("PsYa\175\245B\255\RS\136\128\GS\201\201wA\\\198\&3tES\184+\244\&5\SYN5",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\224\CAN\160\211\DLE",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x5c, 0x33, 0x0, 0x18, 0xc5, 0xa3, 0xc3, 0x44, 0x8d, 0xad, 0xea, 0xf9, 0x2c, 0xa0, - 0x5d, 0xb4, 0xa, 0x5a, 0x9, 0x1c, 0xf4, 0x49, 0x75, 0x83, 0x73, 0x5b, 0xb8, 0x5c, 0x0, 0x0, 0xe, - 0xb6, 0xfd, 0xdb, 0x88, 0x2a, 0x9f, 0x8b, 0x11, 0xf9, 0xf0, 0x24, 0x72, 0xfc, 0xe9, 0x1, 0x0, 0xb, - 0xdb, 0x14, 0xb8, 0x35, 0x4d, 0x99, 0x87, 0xea, 0xbc, 0x5, 0xb8, 0x1, 0x0, 0x16, 0xda, 0xb9, 0x7d, - 0xa0, 0x5e, 0xc, 0xfc, 0x82, 0xaa, 0x7d, 0x22, 0x75, 0x84, 0x6d, 0xb9, 0x1c, 0xfa, 0x9d, 0x2d, 0xa9, - 0x6f, 0x14, 0x0, 0x0, 0x15, 0x80, 0x9e, 0x60, 0xed, 0x41, 0xcf, 0xe3, 0x97, 0x50, 0x2, 0xf8, 0xb1, - 0xa, 0xca, 0x2, 0x82, 0x4e, 0xb7, 0xa9, 0xc6, 0x5e, 0x1, 0x0, 0x16, 0xcf, 0xff, 0x62, 0x8f, 0x18, - 0x1c, 0x8c, 0xcb, 0x21, 0x16, 0x3c, 0x8a, 0x83, 0x56, 0xbb, 0x2e, 0x59, 0xfc, 0xba, 0xfd, 0x11, 0x96, - 0x0, 0x0, 0x2, 0xbf, 0x68, 0x0, 0x0, 0x1c, 0x50, 0x73, 0x59, 0x61, 0xaf, 0xf5, 0x42, 0xff, 0x1e, - 0x88, 0x80, 0x1d, 0xc9, 0xc9, 0x77, 0x41, 0x5c, 0xc6, 0x33, 0x74, 0x45, 0x53, 0xb8, 0x2b, 0xf4, 0x35, - 0x16, 0x35, 0x2, 0x0, 0x5, 0xe0, 0x18, 0xa0, 0xd3, 0x10, 0x2, 0x0, 0x0, 0x2}; +// QoS0}),("\194\235)\201J\157\SOH3\t|\DC4\164\v\175\206\SOHY\236 \166(\212\130",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\181H\154\233\193\216W\142\190\172\173\206\ACKC`",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("s\231w\220\208\DC4\157\191\CAN\EOTo\187\170.c\DLE-\219",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode21) { + uint8_t pkt[] = {0x82, 0xd9, 0x1, 0x71, 0x53, 0x0, 0x4, 0x4c, 0xff, 0xe8, 0x37, 0x0, 0x0, 0x0, 0x0, 0x0, 0x16, + 0x5, 0x20, 0x2, 0xd1, 0xbd, 0x7f, 0xa0, 0xa7, 0x36, 0x7e, 0xfe, 0x16, 0x90, 0xf6, 0xd9, 0x28, 0x1d, + 0xcf, 0x28, 0x63, 0x8e, 0xf1, 0x1, 0x0, 0x1c, 0xed, 0xc2, 0xf7, 0xe6, 0x3, 0x86, 0xe1, 0xc, 0xf, + 0x8f, 0xf2, 0xb5, 0x31, 0x2b, 0xe2, 0x45, 0x4f, 0xdf, 0xba, 0x90, 0x73, 0x65, 0xd8, 0x48, 0x59, 0x3e, + 0xaa, 0xd1, 0x0, 0x0, 0xb, 0x9b, 0x4f, 0xbf, 0xa1, 0x76, 0xda, 0xa7, 0xa8, 0x5f, 0x93, 0x11, 0x0, + 0x0, 0xf, 0x1c, 0xec, 0x78, 0x59, 0x3d, 0x21, 0xac, 0xf1, 0xd9, 0xe6, 0xd1, 0xde, 0xb3, 0x12, 0xf, + 0x1, 0x0, 0x14, 0x64, 0x7d, 0x86, 0xa2, 0xe5, 0xe9, 0x60, 0xd4, 0xf8, 0xcf, 0x14, 0xfe, 0x89, 0xba, + 0xe8, 0x4b, 0x50, 0xa5, 0xde, 0x90, 0x2, 0x0, 0x1a, 0xf1, 0xc5, 0x29, 0x45, 0x82, 0x47, 0x2, 0xf8, + 0x37, 0x77, 0xb3, 0xad, 0xf3, 0xb, 0x54, 0x42, 0x1c, 0xd4, 0x6f, 0xc3, 0x6a, 0x4e, 0xc9, 0x97, 0x5a, + 0x0, 0x0, 0x0, 0x17, 0xc2, 0xeb, 0x29, 0xc9, 0x4a, 0x9d, 0x1, 0x33, 0x9, 0x7c, 0x14, 0xa4, 0xb, + 0xaf, 0xce, 0x1, 0x59, 0xec, 0x20, 0xa6, 0x28, 0xd4, 0x82, 0x1, 0x0, 0xf, 0xb5, 0x48, 0x9a, 0xe9, + 0xc1, 0xd8, 0x57, 0x8e, 0xbe, 0xac, 0xad, 0xce, 0x6, 0x43, 0x60, 0x0, 0x0, 0x12, 0x73, 0xe7, 0x77, + 0xdc, 0xd0, 0x14, 0x9d, 0xbf, 0x18, 0x4, 0x6f, 0xbb, 0xaa, 0x2e, 0x63, 0x10, 0x2d, 0xdb, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xc5, 0xa3, 0xc3, 0x44, 0x8d, 0xad, 0xea, 0xf9, 0x2c, 0xa0, 0x5d, 0xb4, - 0xa, 0x5a, 0x9, 0x1c, 0xf4, 0x49, 0x75, 0x83, 0x73, 0x5b, 0xb8, 0x5c}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x4c, 0xff, 0xe8, 0x37}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb6, 0xfd, 0xdb, 0x88, 0x2a, 0x9f, 0x8b, - 0x11, 0xf9, 0xf0, 0x24, 0x72, 0xfc, 0xe9}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdb, 0x14, 0xb8, 0x35, 0x4d, 0x99, 0x87, 0xea, 0xbc, 0x5, 0xb8}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5, 0x20, 0x2, 0xd1, 0xbd, 0x7f, 0xa0, 0xa7, 0x36, 0x7e, 0xfe, + 0x16, 0x90, 0xf6, 0xd9, 0x28, 0x1d, 0xcf, 0x28, 0x63, 0x8e, 0xf1}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xda, 0xb9, 0x7d, 0xa0, 0x5e, 0xc, 0xfc, 0x82, 0xaa, 0x7d, 0x22, - 0x75, 0x84, 0x6d, 0xb9, 0x1c, 0xfa, 0x9d, 0x2d, 0xa9, 0x6f, 0x14}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xed, 0xc2, 0xf7, 0xe6, 0x3, 0x86, 0xe1, 0xc, 0xf, 0x8f, + 0xf2, 0xb5, 0x31, 0x2b, 0xe2, 0x45, 0x4f, 0xdf, 0xba, 0x90, + 0x73, 0x65, 0xd8, 0x48, 0x59, 0x3e, 0xaa, 0xd1}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x80, 0x9e, 0x60, 0xed, 0x41, 0xcf, 0xe3, 0x97, 0x50, 0x2, 0xf8, - 0xb1, 0xa, 0xca, 0x2, 0x82, 0x4e, 0xb7, 0xa9, 0xc6, 0x5e}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x9b, 0x4f, 0xbf, 0xa1, 0x76, 0xda, 0xa7, 0xa8, 0x5f, 0x93, 0x11}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xcf, 0xff, 0x62, 0x8f, 0x18, 0x1c, 0x8c, 0xcb, 0x21, 0x16, 0x3c, - 0x8a, 0x83, 0x56, 0xbb, 0x2e, 0x59, 0xfc, 0xba, 0xfd, 0x11, 0x96}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x1c, 0xec, 0x78, 0x59, 0x3d, 0x21, 0xac, 0xf1, + 0xd9, 0xe6, 0xd1, 0xde, 0xb3, 0x12, 0xf}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbf, 0x68}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x64, 0x7d, 0x86, 0xa2, 0xe5, 0xe9, 0x60, 0xd4, 0xf8, 0xcf, + 0x14, 0xfe, 0x89, 0xba, 0xe8, 0x4b, 0x50, 0xa5, 0xde, 0x90}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x50, 0x73, 0x59, 0x61, 0xaf, 0xf5, 0x42, 0xff, 0x1e, 0x88, - 0x80, 0x1d, 0xc9, 0xc9, 0x77, 0x41, 0x5c, 0xc6, 0x33, 0x74, - 0x45, 0x53, 0xb8, 0x2b, 0xf4, 0x35, 0x16, 0x35}; - lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xf1, 0xc5, 0x29, 0x45, 0x82, 0x47, 0x2, 0xf8, 0x37, 0x77, 0xb3, 0xad, 0xf3, + 0xb, 0x54, 0x42, 0x1c, 0xd4, 0x6f, 0xc3, 0x6a, 0x4e, 0xc9, 0x97, 0x5a, 0x0}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe0, 0x18, 0xa0, 0xd3, 0x10}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xc2, 0xeb, 0x29, 0xc9, 0x4a, 0x9d, 0x1, 0x33, 0x9, 0x7c, 0x14, 0xa4, + 0xb, 0xaf, 0xce, 0x1, 0x59, 0xec, 0x20, 0xa6, 0x28, 0xd4, 0x82}; + lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0}; - lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0xb5, 0x48, 0x9a, 0xe9, 0xc1, 0xd8, 0x57, 0x8e, + 0xbe, 0xac, 0xad, 0xce, 0x6, 0x43, 0x60}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; + uint8_t topic_filter_s10_bytes[] = {0x73, 0xe7, 0x77, 0xdc, 0xd0, 0x14, 0x9d, 0xbf, 0x18, + 0x4, 0x6f, 0xbb, 0xaa, 0x2e, 0x63, 0x10, 0x2d, 0xdb}; + lwmqtt_string_t topic_filter_s10 = {18, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -11989,99 +11947,78 @@ TEST(Subscribe311QCTest, Encode25) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].qos = LWMQTT_QOS0; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].qos = LWMQTT_QOS1; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].qos = LWMQTT_QOS0; sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23603, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29011, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26458 [("\183`M\228xY\249D",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\237\157\196\228p\189\168\211",SubOptions {_retainHandling = +// SubscribeRequest 29705 [("\amn\138\157\180\217\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0}),("!!Va\217\152",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\249\n}\251\170",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\255\152\155\238\160\241#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\221\172",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\212\176\130\245\147\226D\DC1\170\164\SOH\210`>\241\244\135\149\243\210\198#\166\227\243\195\ACK",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("S/\168!^A\129\141\161\212\235\177",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\160\228\STX\163#\156\211",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\131(\196qI\152p\148\234\235i\148\219\186\139A\137\SI\188\207\164\132%.\135G_\229\211\254",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x7f, 0x67, 0x5a, 0x0, 0x8, 0xb7, 0x60, 0x4d, 0xe4, 0x78, 0x59, 0xf9, 0x44, 0x1, 0x0, 0x8, - 0xed, 0x9d, 0xc4, 0xe4, 0x70, 0xbd, 0xa8, 0xd3, 0x1, 0x0, 0x7, 0xff, 0x98, 0x9b, 0xee, 0xa0, 0xf1, - 0x23, 0x1, 0x0, 0x2, 0xdd, 0xac, 0x1, 0x0, 0x1b, 0xd4, 0xb0, 0x82, 0xf5, 0x93, 0xe2, 0x44, 0x11, - 0xaa, 0xa4, 0x1, 0xd2, 0x60, 0x3e, 0xf1, 0xf4, 0x87, 0x95, 0xf3, 0xd2, 0xc6, 0x23, 0xa6, 0xe3, 0xf3, - 0xc3, 0x6, 0x0, 0x0, 0xc, 0x53, 0x2f, 0xa8, 0x21, 0x5e, 0x41, 0x81, 0x8d, 0xa1, 0xd4, 0xeb, 0xb1, - 0x1, 0x0, 0x7, 0xa0, 0xe4, 0x2, 0xa3, 0x23, 0x9c, 0xd3, 0x0, 0x0, 0x1e, 0x83, 0x28, 0xc4, 0x71, - 0x49, 0x98, 0x70, 0x94, 0xea, 0xeb, 0x69, 0x94, 0xdb, 0xba, 0x8b, 0x41, 0x89, 0xf, 0xbc, 0xcf, 0xa4, - 0x84, 0x25, 0x2e, 0x87, 0x47, 0x5f, 0xe5, 0xd3, 0xfe, 0x1}; +// QoS1}),("\158\v\b\RS\149\235Vv\NAK\240\135d\189r\203\185b\176\ETB\195,EE\185y",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode22) { + uint8_t pkt[] = {0x82, 0x3a, 0x74, 0x9, 0x0, 0x8, 0x7, 0x6d, 0x6e, 0x8a, 0x9d, 0xb4, 0xd9, 0xdb, 0x0, + 0x0, 0x6, 0x21, 0x21, 0x56, 0x61, 0xd9, 0x98, 0x2, 0x0, 0x5, 0xf9, 0xa, 0x7d, 0xfb, + 0xaa, 0x1, 0x0, 0x19, 0x9e, 0xb, 0x8, 0x1e, 0x95, 0xeb, 0x56, 0x76, 0x15, 0xf0, 0x87, + 0x64, 0xbd, 0x72, 0xcb, 0xb9, 0x62, 0xb0, 0x17, 0xc3, 0x2c, 0x45, 0x45, 0xb9, 0x79, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xb7, 0x60, 0x4d, 0xe4, 0x78, 0x59, 0xf9, 0x44}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x7, 0x6d, 0x6e, 0x8a, 0x9d, 0xb4, 0xd9, 0xdb}; lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xed, 0x9d, 0xc4, 0xe4, 0x70, 0xbd, 0xa8, 0xd3}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x21, 0x21, 0x56, 0x61, 0xd9, 0x98}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xff, 0x98, 0x9b, 0xee, 0xa0, 0xf1, 0x23}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf9, 0xa, 0x7d, 0xfb, 0xaa}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xdd, 0xac}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9e, 0xb, 0x8, 0x1e, 0x95, 0xeb, 0x56, 0x76, 0x15, 0xf0, 0x87, 0x64, 0xbd, + 0x72, 0xcb, 0xb9, 0x62, 0xb0, 0x17, 0xc3, 0x2c, 0x45, 0x45, 0xb9, 0x79}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd4, 0xb0, 0x82, 0xf5, 0x93, 0xe2, 0x44, 0x11, 0xaa, 0xa4, 0x1, 0xd2, 0x60, 0x3e, - 0xf1, 0xf4, 0x87, 0x95, 0xf3, 0xd2, 0xc6, 0x23, 0xa6, 0xe3, 0xf3, 0xc3, 0x6}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x53, 0x2f, 0xa8, 0x21, 0x5e, 0x41, 0x81, 0x8d, 0xa1, 0xd4, 0xeb, 0xb1}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa0, 0xe4, 0x2, 0xa3, 0x23, 0x9c, 0xd3}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x83, 0x28, 0xc4, 0x71, 0x49, 0x98, 0x70, 0x94, 0xea, 0xeb, - 0x69, 0x94, 0xdb, 0xba, 0x8b, 0x41, 0x89, 0xf, 0xbc, 0xcf, - 0xa4, 0x84, 0x25, 0x2e, 0x87, 0x47, 0x5f, 0xe5, 0xd3, 0xfe}; - lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -12089,79 +12026,82 @@ TEST(Subscribe311QCTest, Encode26) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26458, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29705, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4488 [("y\134]",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2}),("M\251\156z\tw\201\201\201\b\244\145\253\166",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\207h\177E\207\162\163\233\143",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\CAN\241\ENQ/\"M\212\227\&2\237\164<\230\204\237\206eX\208\194\&7.",SubOptions +// SubscribeRequest 30426 [("\SYNez\ACK\162N\176`#\DLEr6\206\183\167\183\224\241\&4OY\ENQ\162'\169\187\136A",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\152",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\234\233uo\245\154\131\&5#\223~@\NAKY\140\175\191\179\141\129\166)\188k",SubOptions {_retainHandling = +// QoS0}),("mD\188mxN\232n\174\197\149e\174/\"\187\196\138\131\232",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\193]\DC2\n\228\224l6\162\149f\"J.\240\202",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(":q\223\215|h\a\208G\164\\~\231q_R\131\211\242\198\EM\CAN\220(\158\DLE\133",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\233:\215\250\&2\131\227\DLE^\175J",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0x67, 0x11, 0x88, 0x0, 0x3, 0x79, 0x86, 0x5d, 0x2, 0x0, 0xe, 0x4d, 0xfb, 0x9c, - 0x7a, 0x9, 0x77, 0xc9, 0xc9, 0xc9, 0x8, 0xf4, 0x91, 0xfd, 0xa6, 0x0, 0x0, 0x9, 0xcf, - 0x68, 0xb1, 0x45, 0xcf, 0xa2, 0xa3, 0xe9, 0x8f, 0x0, 0x0, 0x16, 0x18, 0xf1, 0x5, 0x2f, - 0x22, 0x4d, 0xd4, 0xe3, 0x32, 0xed, 0xa4, 0x3c, 0xe6, 0xcc, 0xed, 0xce, 0x65, 0x58, 0xd0, - 0xc2, 0x37, 0x2e, 0x1, 0x0, 0x18, 0xea, 0xe9, 0x75, 0x6f, 0xf5, 0x9a, 0x83, 0x35, 0x23, - 0xdf, 0x7e, 0x40, 0x15, 0x59, 0x8c, 0xaf, 0xbf, 0xb3, 0x8d, 0x81, 0xa6, 0x29, 0xbc, 0x6b, - 0x0, 0x0, 0xb, 0xe9, 0x3a, 0xd7, 0xfa, 0x32, 0x83, 0xe3, 0x10, 0x5e, 0xaf, 0x4a, 0x1}; +// QoS1}),("\225\243\168\&79\184\251\210N\f>-\149\138K\n\155\217\220\DC33T\250\255UB=\188\RS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("_\174@\222\188\207\224\212\179\190C\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\165\SYN\186\167:\ETX\214\DC2\145O\237\221\197",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0xac, 0x1, 0x76, 0xda, 0x0, 0x1c, 0x16, 0x65, 0x7a, 0x6, 0xa2, 0x4e, 0xb0, 0x60, 0x23, + 0x10, 0x72, 0x36, 0xce, 0xb7, 0xa7, 0xb7, 0xe0, 0xf1, 0x34, 0x4f, 0x59, 0x5, 0xa2, 0x27, 0xa9, + 0xbb, 0x88, 0x41, 0x2, 0x0, 0x1, 0x98, 0x0, 0x0, 0x14, 0x6d, 0x44, 0xbc, 0x6d, 0x78, 0x4e, + 0xe8, 0x6e, 0xae, 0xc5, 0x95, 0x65, 0xae, 0x2f, 0x22, 0xbb, 0xc4, 0x8a, 0x83, 0xe8, 0x2, 0x0, + 0x10, 0xc1, 0x5d, 0x12, 0xa, 0xe4, 0xe0, 0x6c, 0x36, 0xa2, 0x95, 0x66, 0x22, 0x4a, 0x2e, 0xf0, + 0xca, 0x0, 0x0, 0x1b, 0x3a, 0x71, 0xdf, 0xd7, 0x7c, 0x68, 0x7, 0xd0, 0x47, 0xa4, 0x5c, 0x7e, + 0xe7, 0x71, 0x5f, 0x52, 0x83, 0xd3, 0xf2, 0xc6, 0x19, 0x18, 0xdc, 0x28, 0x9e, 0x10, 0x85, 0x1, + 0x0, 0x1d, 0xe1, 0xf3, 0xa8, 0x37, 0x39, 0xb8, 0xfb, 0xd2, 0x4e, 0xc, 0x3e, 0x2d, 0x95, 0x8a, + 0x4b, 0xa, 0x9b, 0xd9, 0xdc, 0x13, 0x33, 0x54, 0xfa, 0xff, 0x55, 0x42, 0x3d, 0xbc, 0x1e, 0x0, + 0x0, 0xc, 0x5f, 0xae, 0x40, 0xde, 0xbc, 0xcf, 0xe0, 0xd4, 0xb3, 0xbe, 0x43, 0xce, 0x1, 0x0, + 0xd, 0xa5, 0x16, 0xba, 0xa7, 0x3a, 0x3, 0xd6, 0x12, 0x91, 0x4f, 0xed, 0xdd, 0xc5, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x79, 0x86, 0x5d}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x16, 0x65, 0x7a, 0x6, 0xa2, 0x4e, 0xb0, 0x60, 0x23, 0x10, + 0x72, 0x36, 0xce, 0xb7, 0xa7, 0xb7, 0xe0, 0xf1, 0x34, 0x4f, + 0x59, 0x5, 0xa2, 0x27, 0xa9, 0xbb, 0x88, 0x41}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4d, 0xfb, 0x9c, 0x7a, 0x9, 0x77, 0xc9, 0xc9, 0xc9, 0x8, 0xf4, 0x91, 0xfd, 0xa6}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x98}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xcf, 0x68, 0xb1, 0x45, 0xcf, 0xa2, 0xa3, 0xe9, 0x8f}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6d, 0x44, 0xbc, 0x6d, 0x78, 0x4e, 0xe8, 0x6e, 0xae, 0xc5, + 0x95, 0x65, 0xae, 0x2f, 0x22, 0xbb, 0xc4, 0x8a, 0x83, 0xe8}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x18, 0xf1, 0x5, 0x2f, 0x22, 0x4d, 0xd4, 0xe3, 0x32, 0xed, 0xa4, - 0x3c, 0xe6, 0xcc, 0xed, 0xce, 0x65, 0x58, 0xd0, 0xc2, 0x37, 0x2e}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc1, 0x5d, 0x12, 0xa, 0xe4, 0xe0, 0x6c, 0x36, + 0xa2, 0x95, 0x66, 0x22, 0x4a, 0x2e, 0xf0, 0xca}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xea, 0xe9, 0x75, 0x6f, 0xf5, 0x9a, 0x83, 0x35, 0x23, 0xdf, 0x7e, 0x40, - 0x15, 0x59, 0x8c, 0xaf, 0xbf, 0xb3, 0x8d, 0x81, 0xa6, 0x29, 0xbc, 0x6b}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x3a, 0x71, 0xdf, 0xd7, 0x7c, 0x68, 0x7, 0xd0, 0x47, 0xa4, 0x5c, 0x7e, 0xe7, 0x71, + 0x5f, 0x52, 0x83, 0xd3, 0xf2, 0xc6, 0x19, 0x18, 0xdc, 0x28, 0x9e, 0x10, 0x85}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe9, 0x3a, 0xd7, 0xfa, 0x32, 0x83, 0xe3, 0x10, 0x5e, 0xaf, 0x4a}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe1, 0xf3, 0xa8, 0x37, 0x39, 0xb8, 0xfb, 0xd2, 0x4e, 0xc, + 0x3e, 0x2d, 0x95, 0x8a, 0x4b, 0xa, 0x9b, 0xd9, 0xdc, 0x13, + 0x33, 0x54, 0xfa, 0xff, 0x55, 0x42, 0x3d, 0xbc, 0x1e}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0x5f, 0xae, 0x40, 0xde, 0xbc, 0xcf, 0xe0, 0xd4, 0xb3, 0xbe, 0x43, 0xce}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xa5, 0x16, 0xba, 0xa7, 0x3a, 0x3, 0xd6, 0x12, 0x91, 0x4f, 0xed, 0xdd, 0xc5}; + lwmqtt_string_t topic_filter_s7 = {13, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -12170,88 +12110,76 @@ TEST(Subscribe311QCTest, Encode27) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4488, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30426, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28692 -// [("a^z\164{\209P\192\235d\163\187\135\198\205\238\DC4\185h\146\199\197\&9\223\220\253",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("]\163\DC3\140]\129\245\224\164\163S",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("\171\&1\208\132\SI\194\193m\ACK\203\239\SIx\ENQ\218\160O|1\235Y:\184\174",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\176\STX\244\239\208df\183(B\197x;\189\224\232 Y\218\155f\135\149v\249d\245\FS\208L",SubOptions +// SubscribeRequest 21987 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("Cz\235\f\236\158'=\190",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("l\166=\210\242k\194\162\DLE}w\148\202W\216\US\178\f",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\n#\223\137\184\136\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS1}),("`\RS8\b\137\129\FS#\SO\234\SYN\192\217\144A'\216\235\227\226\ai\205\207}c",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("V\224\171\163j",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0x98, 0x1, 0x70, 0x14, 0x0, 0x1a, 0x61, 0x5e, 0x7a, 0xa4, 0x7b, 0xd1, 0x50, 0xc0, 0xeb, - 0x64, 0xa3, 0xbb, 0x87, 0xc6, 0xcd, 0xee, 0x14, 0xb9, 0x68, 0x92, 0xc7, 0xc5, 0x39, 0xdf, 0xdc, - 0xfd, 0x2, 0x0, 0xb, 0x5d, 0xa3, 0x13, 0x8c, 0x5d, 0x81, 0xf5, 0xe0, 0xa4, 0xa3, 0x53, 0x2, - 0x0, 0x18, 0xab, 0x31, 0xd0, 0x84, 0xf, 0xc2, 0xc1, 0x6d, 0x6, 0xcb, 0xef, 0xf, 0x78, 0x5, - 0xda, 0xa0, 0x4f, 0x7c, 0x31, 0xeb, 0x59, 0x3a, 0xb8, 0xae, 0x2, 0x0, 0x1e, 0xb0, 0x2, 0xf4, - 0xef, 0xd0, 0x64, 0x66, 0xb7, 0x28, 0x42, 0xc5, 0x78, 0x3b, 0xbd, 0xe0, 0xe8, 0x20, 0x59, 0xda, - 0x9b, 0x66, 0x87, 0x95, 0x76, 0xf9, 0x64, 0xf5, 0x1c, 0xd0, 0x4c, 0x2, 0x0, 0x7, 0xa, 0x23, - 0xdf, 0x89, 0xb8, 0x88, 0xe1, 0x1, 0x0, 0x1a, 0x60, 0x1e, 0x38, 0x8, 0x89, 0x81, 0x1c, 0x23, - 0xe, 0xea, 0x16, 0xc0, 0xd9, 0x90, 0x41, 0x27, 0xd8, 0xeb, 0xe3, 0xe2, 0x7, 0x69, 0xcd, 0xcf, - 0x7d, 0x63, 0x0, 0x0, 0x5, 0x56, 0xe0, 0xab, 0xa3, 0x6a, 0x0}; +// QoS1}),("x\t\SO\224\131\ENQ\\\237\221\168\246&x\STX\246T\228\249\194\129\SUB",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\223\SI\255\235\250\134\ETX\178u\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode24) { + uint8_t pkt[] = {0x82, 0x4b, 0x55, 0xe3, 0x0, 0x0, 0x2, 0x0, 0x9, 0x43, 0x7a, 0xeb, 0xc, 0xec, 0x9e, 0x27, + 0x3d, 0xbe, 0x2, 0x0, 0x12, 0x6c, 0xa6, 0x3d, 0xd2, 0xf2, 0x6b, 0xc2, 0xa2, 0x10, 0x7d, 0x77, + 0x94, 0xca, 0x57, 0xd8, 0x1f, 0xb2, 0xc, 0x1, 0x0, 0x15, 0x78, 0x9, 0xe, 0xe0, 0x83, 0x5, + 0x5c, 0xed, 0xdd, 0xa8, 0xf6, 0x26, 0x78, 0x2, 0xf6, 0x54, 0xe4, 0xf9, 0xc2, 0x81, 0x1a, 0x0, + 0x0, 0xa, 0xdf, 0xf, 0xff, 0xeb, 0xfa, 0x86, 0x3, 0xb2, 0x75, 0xd2, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x61, 0x5e, 0x7a, 0xa4, 0x7b, 0xd1, 0x50, 0xc0, 0xeb, 0x64, 0xa3, 0xbb, 0x87, - 0xc6, 0xcd, 0xee, 0x14, 0xb9, 0x68, 0x92, 0xc7, 0xc5, 0x39, 0xdf, 0xdc, 0xfd}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5d, 0xa3, 0x13, 0x8c, 0x5d, 0x81, 0xf5, 0xe0, 0xa4, 0xa3, 0x53}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x43, 0x7a, 0xeb, 0xc, 0xec, 0x9e, 0x27, 0x3d, 0xbe}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xab, 0x31, 0xd0, 0x84, 0xf, 0xc2, 0xc1, 0x6d, 0x6, 0xcb, 0xef, 0xf, - 0x78, 0x5, 0xda, 0xa0, 0x4f, 0x7c, 0x31, 0xeb, 0x59, 0x3a, 0xb8, 0xae}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6c, 0xa6, 0x3d, 0xd2, 0xf2, 0x6b, 0xc2, 0xa2, 0x10, + 0x7d, 0x77, 0x94, 0xca, 0x57, 0xd8, 0x1f, 0xb2, 0xc}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb0, 0x2, 0xf4, 0xef, 0xd0, 0x64, 0x66, 0xb7, 0x28, 0x42, - 0xc5, 0x78, 0x3b, 0xbd, 0xe0, 0xe8, 0x20, 0x59, 0xda, 0x9b, - 0x66, 0x87, 0x95, 0x76, 0xf9, 0x64, 0xf5, 0x1c, 0xd0, 0x4c}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x78, 0x9, 0xe, 0xe0, 0x83, 0x5, 0x5c, 0xed, 0xdd, 0xa8, 0xf6, + 0x26, 0x78, 0x2, 0xf6, 0x54, 0xe4, 0xf9, 0xc2, 0x81, 0x1a}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa, 0x23, 0xdf, 0x89, 0xb8, 0x88, 0xe1}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xdf, 0xf, 0xff, 0xeb, 0xfa, 0x86, 0x3, 0xb2, 0x75, 0xd2}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x60, 0x1e, 0x38, 0x8, 0x89, 0x81, 0x1c, 0x23, 0xe, 0xea, 0x16, 0xc0, 0xd9, - 0x90, 0x41, 0x27, 0xd8, 0xeb, 0xe3, 0xe2, 0x7, 0x69, 0xcd, 0xcf, 0x7d, 0x63}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x56, 0xe0, 0xab, 0xa3, 0x6a}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; + lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -12260,108 +12188,201 @@ TEST(Subscribe311QCTest, Encode28) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28692, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21987, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11607 [("\200P\177\221",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("A\173\ETX\f\226l\DELM\233\194ndO4\248\238\130\173\224\214",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\246\222N\189z",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("\216\NAKQ\172\ACK\138\167\168\&5&",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SYN\130\197\169\254\\\180\144\164g\158k",SubOptions +// SubscribeRequest 23704 [("t \154\149\224\EM\158fEc\239\249\&6\231\DC4\159",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\253\\\220\193&\209[",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("e",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("R[&",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\NUL\214a\170\SOH\192\ETX\136M\252\SOH\238q\183\ETX\172\138\213$]\154J\166\142\232R",SubOptions +// QoS1}),("^\169\135\136\143\241q\SI\254\254",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode25) { + uint8_t pkt[] = {0x82, 0x36, 0x5c, 0x98, 0x0, 0x10, 0x74, 0x20, 0x9a, 0x95, 0xe0, 0x19, 0x9e, 0x66, + 0x45, 0x63, 0xef, 0xf9, 0x36, 0xe7, 0x14, 0x9f, 0x1, 0x0, 0x7, 0xfd, 0x5c, 0xdc, + 0xc1, 0x26, 0xd1, 0x5b, 0x2, 0x0, 0x1, 0x65, 0x1, 0x0, 0x3, 0x52, 0x5b, 0x26, + 0x1, 0x0, 0xa, 0x5e, 0xa9, 0x87, 0x88, 0x8f, 0xf1, 0x71, 0xf, 0xfe, 0xfe, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x74, 0x20, 0x9a, 0x95, 0xe0, 0x19, 0x9e, 0x66, + 0x45, 0x63, 0xef, 0xf9, 0x36, 0xe7, 0x14, 0x9f}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xfd, 0x5c, 0xdc, 0xc1, 0x26, 0xd1, 0x5b}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x65}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x52, 0x5b, 0x26}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x5e, 0xa9, 0x87, 0x88, 0x8f, 0xf1, 0x71, 0xf, 0xfe, 0xfe}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23704, 5, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 25818 [("\235\&1\a\173\150\175\208\&8",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode26) { + uint8_t pkt[] = {0x82, 0xd, 0x64, 0xda, 0x0, 0x8, 0xeb, 0x31, 0x7, 0xad, 0x96, 0xaf, 0xd0, 0x38, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xeb, 0x31, 0x7, 0xad, 0x96, 0xaf, 0xd0, 0x38}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25818, 1, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 19332 [("-\196\154\190n\186/h\n\161\203p\157Ap",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("~\210\229q\182\141\167%]a\fh\248\233\253\167>\NAKu\US\STX\133:",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\144;#\ENQ\236h-\ETX\243\164R3\237\241\129\171\225",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\254\167a\227\GS\169X\240\139\CAN\242\212K\164g]T\203\246\141",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\252=6J\200\227L",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Mu-|\132\218\214j\253",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = -// QoS0}),("\240\161\131\US\213\DC1\239\222\n\133\218\180j\176p\215\204s\138t\154N\163!\227y(\233l\166",SubOptions +// QoS2}),("U\199y\ETX\222\t\"\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2}),("\202\SUB\220\214,g\158Ugne6\221\DLE\222}n\252\&1w/\NUL\171\244vou",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\237\136f\131sp\148i\158+cYt\ESC;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0xa0, 0x1, 0x2d, 0x57, 0x0, 0x4, 0xc8, 0x50, 0xb1, 0xdd, 0x2, 0x0, 0x14, 0x41, 0xad, 0x3, - 0xc, 0xe2, 0x6c, 0x7f, 0x4d, 0xe9, 0xc2, 0x6e, 0x64, 0x4f, 0x34, 0xf8, 0xee, 0x82, 0xad, 0xe0, 0xd6, - 0x0, 0x0, 0x5, 0xf6, 0xde, 0x4e, 0xbd, 0x7a, 0x2, 0x0, 0xa, 0xd8, 0x15, 0x51, 0xac, 0x6, 0x8a, - 0xa7, 0xa8, 0x35, 0x26, 0x1, 0x0, 0xc, 0x16, 0x82, 0xc5, 0xa9, 0xfe, 0x5c, 0xb4, 0x90, 0xa4, 0x67, - 0x9e, 0x6b, 0x0, 0x0, 0x1a, 0x0, 0xd6, 0x61, 0xaa, 0x1, 0xc0, 0x3, 0x88, 0x4d, 0xfc, 0x1, 0xee, - 0x71, 0xb7, 0x3, 0xac, 0x8a, 0xd5, 0x24, 0x5d, 0x9a, 0x4a, 0xa6, 0x8e, 0xe8, 0x52, 0x2, 0x0, 0x9, - 0x4d, 0x75, 0x2d, 0x7c, 0x84, 0xda, 0xd6, 0x6a, 0xfd, 0x0, 0x0, 0x1e, 0xf0, 0xa1, 0x83, 0x1f, 0xd5, - 0x11, 0xef, 0xde, 0xa, 0x85, 0xda, 0xb4, 0x6a, 0xb0, 0x70, 0xd7, 0xcc, 0x73, 0x8a, 0x74, 0x9a, 0x4e, - 0xa3, 0x21, 0xe3, 0x79, 0x28, 0xe9, 0x6c, 0xa6, 0x0, 0x0, 0xf, 0xed, 0x88, 0x66, 0x83, 0x73, 0x70, - 0x94, 0x69, 0x9e, 0x2b, 0x63, 0x59, 0x74, 0x1b, 0x3b, 0x1}; +// QoS1}),("-\SO\230DQ\130\178\\\129\&2i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\205\132\136\DC2y",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ACK)\174\200\186",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\140\197o\USH\162P\197x$\209\218\SI\172\GS\176\147\204\148\CAN\226\CAN",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode27) { + uint8_t pkt[] = {0x82, 0xc3, 0x1, 0x4b, 0x84, 0x0, 0xf, 0x2d, 0xc4, 0x9a, 0xbe, 0x6e, 0xba, 0x2f, 0x68, 0xa, 0xa1, + 0xcb, 0x70, 0x9d, 0x41, 0x70, 0x0, 0x0, 0x17, 0x7e, 0xd2, 0xe5, 0x71, 0xb6, 0x8d, 0xa7, 0x25, 0x5d, + 0x61, 0xc, 0x68, 0xf8, 0xe9, 0xfd, 0xa7, 0x3e, 0x15, 0x75, 0x1f, 0x2, 0x85, 0x3a, 0x2, 0x0, 0x11, + 0x90, 0x3b, 0x23, 0x5, 0xec, 0x68, 0x2d, 0x3, 0xf3, 0xa4, 0x52, 0x33, 0xed, 0xf1, 0x81, 0xab, 0xe1, + 0x0, 0x0, 0x14, 0xfe, 0xa7, 0x61, 0xe3, 0x1d, 0xa9, 0x58, 0xf0, 0x8b, 0x18, 0xf2, 0xd4, 0x4b, 0xa4, + 0x67, 0x5d, 0x54, 0xcb, 0xf6, 0x8d, 0x1, 0x0, 0x7, 0xfc, 0x3d, 0x36, 0x4a, 0xc8, 0xe3, 0x4c, 0x2, + 0x0, 0x8, 0x55, 0xc7, 0x79, 0x3, 0xde, 0x9, 0x22, 0xe8, 0x2, 0x0, 0x1b, 0xca, 0x1a, 0xdc, 0xd6, + 0x2c, 0x67, 0x9e, 0x55, 0x67, 0x6e, 0x65, 0x36, 0xdd, 0x10, 0xde, 0x7d, 0x6e, 0xfc, 0x31, 0x77, 0x2f, + 0x0, 0xab, 0xf4, 0x76, 0x6f, 0x75, 0x1, 0x0, 0xb, 0x2d, 0xe, 0xe6, 0x44, 0x51, 0x82, 0xb2, 0x5c, + 0x81, 0x32, 0x69, 0x0, 0x0, 0x5, 0xcd, 0x84, 0x88, 0x12, 0x79, 0x0, 0x0, 0x5, 0x6, 0x29, 0xae, + 0xc8, 0xba, 0x1, 0x0, 0x16, 0x8c, 0xc5, 0x6f, 0x1f, 0x48, 0xa2, 0x50, 0xc5, 0x78, 0x24, 0xd1, 0xda, + 0xf, 0xac, 0x1d, 0xb0, 0x93, 0xcc, 0x94, 0x18, 0xe2, 0x18, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xc8, 0x50, 0xb1, 0xdd}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x2d, 0xc4, 0x9a, 0xbe, 0x6e, 0xba, 0x2f, 0x68, + 0xa, 0xa1, 0xcb, 0x70, 0x9d, 0x41, 0x70}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x41, 0xad, 0x3, 0xc, 0xe2, 0x6c, 0x7f, 0x4d, 0xe9, 0xc2, - 0x6e, 0x64, 0x4f, 0x34, 0xf8, 0xee, 0x82, 0xad, 0xe0, 0xd6}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7e, 0xd2, 0xe5, 0x71, 0xb6, 0x8d, 0xa7, 0x25, 0x5d, 0x61, 0xc, 0x68, + 0xf8, 0xe9, 0xfd, 0xa7, 0x3e, 0x15, 0x75, 0x1f, 0x2, 0x85, 0x3a}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf6, 0xde, 0x4e, 0xbd, 0x7a}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x90, 0x3b, 0x23, 0x5, 0xec, 0x68, 0x2d, 0x3, 0xf3, + 0xa4, 0x52, 0x33, 0xed, 0xf1, 0x81, 0xab, 0xe1}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd8, 0x15, 0x51, 0xac, 0x6, 0x8a, 0xa7, 0xa8, 0x35, 0x26}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfe, 0xa7, 0x61, 0xe3, 0x1d, 0xa9, 0x58, 0xf0, 0x8b, 0x18, + 0xf2, 0xd4, 0x4b, 0xa4, 0x67, 0x5d, 0x54, 0xcb, 0xf6, 0x8d}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x16, 0x82, 0xc5, 0xa9, 0xfe, 0x5c, 0xb4, 0x90, 0xa4, 0x67, 0x9e, 0x6b}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xfc, 0x3d, 0x36, 0x4a, 0xc8, 0xe3, 0x4c}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x0, 0xd6, 0x61, 0xaa, 0x1, 0xc0, 0x3, 0x88, 0x4d, 0xfc, 0x1, 0xee, 0x71, - 0xb7, 0x3, 0xac, 0x8a, 0xd5, 0x24, 0x5d, 0x9a, 0x4a, 0xa6, 0x8e, 0xe8, 0x52}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x55, 0xc7, 0x79, 0x3, 0xde, 0x9, 0x22, 0xe8}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4d, 0x75, 0x2d, 0x7c, 0x84, 0xda, 0xd6, 0x6a, 0xfd}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xca, 0x1a, 0xdc, 0xd6, 0x2c, 0x67, 0x9e, 0x55, 0x67, 0x6e, 0x65, 0x36, 0xdd, 0x10, + 0xde, 0x7d, 0x6e, 0xfc, 0x31, 0x77, 0x2f, 0x0, 0xab, 0xf4, 0x76, 0x6f, 0x75}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf0, 0xa1, 0x83, 0x1f, 0xd5, 0x11, 0xef, 0xde, 0xa, 0x85, - 0xda, 0xb4, 0x6a, 0xb0, 0x70, 0xd7, 0xcc, 0x73, 0x8a, 0x74, - 0x9a, 0x4e, 0xa3, 0x21, 0xe3, 0x79, 0x28, 0xe9, 0x6c, 0xa6}; - lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x2d, 0xe, 0xe6, 0x44, 0x51, 0x82, 0xb2, 0x5c, 0x81, 0x32, 0x69}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xed, 0x88, 0x66, 0x83, 0x73, 0x70, 0x94, 0x69, - 0x9e, 0x2b, 0x63, 0x59, 0x74, 0x1b, 0x3b}; - lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xcd, 0x84, 0x88, 0x12, 0x79}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s9_bytes[] = {0x6, 0x29, 0xae, 0xc8, 0xba}; + lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x8c, 0xc5, 0x6f, 0x1f, 0x48, 0xa2, 0x50, 0xc5, 0x78, 0x24, 0xd1, + 0xda, 0xf, 0xac, 0x1d, 0xb0, 0x93, 0xcc, 0x94, 0x18, 0xe2, 0x18}; + lwmqtt_string_t topic_filter_s10 = {22, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -12369,7 +12390,7 @@ TEST(Subscribe311QCTest, Encode29) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -12377,7 +12398,7 @@ TEST(Subscribe311QCTest, Encode29) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; @@ -12385,3433 +12406,5294 @@ TEST(Subscribe311QCTest, Encode29) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11607, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19332, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22426 [("\FS\227\218",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// SubscribeRequest 20518 [("\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\208\138rec7\DLE\135k\b\245\159\135\&8\198\&0x\EM\188\ESC",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("OC{\222\a\203\253\158#\181\203J&\a\179\STX6\141\175\135\212QE\DC4<\207",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("qa\DC3x\197\165\234`\236\156",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("j\241\241/\244.\251\220v\185(f\144\147\f\170\246\219",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("f\189\233W\169\244b\222\169",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, // _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x8, 0x57, 0x9a, 0x0, 0x3, 0x1c, 0xe3, 0xda, 0x1}; +TEST(Subscribe311QCTest, Encode28) { + uint8_t pkt[] = {0x82, 0x6b, 0x50, 0x26, 0x0, 0x1, 0xb8, 0x1, 0x0, 0x14, 0xd0, 0x8a, 0x72, 0x65, 0x63, 0x37, + 0x10, 0x87, 0x6b, 0x8, 0xf5, 0x9f, 0x87, 0x38, 0xc6, 0x30, 0x78, 0x19, 0xbc, 0x1b, 0x0, 0x0, + 0x0, 0x1, 0x0, 0x1a, 0x4f, 0x43, 0x7b, 0xde, 0x7, 0xcb, 0xfd, 0x9e, 0x23, 0xb5, 0xcb, 0x4a, + 0x26, 0x7, 0xb3, 0x2, 0x36, 0x8d, 0xaf, 0x87, 0xd4, 0x51, 0x45, 0x14, 0x3c, 0xcf, 0x0, 0x0, + 0xa, 0x71, 0x61, 0x13, 0x78, 0xc5, 0xa5, 0xea, 0x60, 0xec, 0x9c, 0x2, 0x0, 0x12, 0x6a, 0xf1, + 0xf1, 0x2f, 0xf4, 0x2e, 0xfb, 0xdc, 0x76, 0xb9, 0x28, 0x66, 0x90, 0x93, 0xc, 0xaa, 0xf6, 0xdb, + 0x0, 0x0, 0x9, 0x66, 0xbd, 0xe9, 0x57, 0xa9, 0xf4, 0x62, 0xde, 0xa9, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x1c, 0xe3, 0xda}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xb8}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; + uint8_t topic_filter_s1_bytes[] = {0xd0, 0x8a, 0x72, 0x65, 0x63, 0x37, 0x10, 0x87, 0x6b, 0x8, + 0xf5, 0x9f, 0x87, 0x38, 0xc6, 0x30, 0x78, 0x19, 0xbc, 0x1b}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x4f, 0x43, 0x7b, 0xde, 0x7, 0xcb, 0xfd, 0x9e, 0x23, 0xb5, 0xcb, 0x4a, 0x26, + 0x7, 0xb3, 0x2, 0x36, 0x8d, 0xaf, 0x87, 0xd4, 0x51, 0x45, 0x14, 0x3c, 0xcf}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x71, 0x61, 0x13, 0x78, 0xc5, 0xa5, 0xea, 0x60, 0xec, 0x9c}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6a, 0xf1, 0xf1, 0x2f, 0xf4, 0x2e, 0xfb, 0xdc, 0x76, + 0xb9, 0x28, 0x66, 0x90, 0x93, 0xc, 0xaa, 0xf6, 0xdb}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x66, 0xbd, 0xe9, 0x57, 0xa9, 0xf4, 0x62, 0xde, 0xa9}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22426, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20518, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7633 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2})] [PropReasonString -// "\155\148e\NUL\226\147\"\165\SOb\167\&5\a\163\145\131\145\a{7\255\&4\252\182",PropWillDelayInterval -// 24271,PropTopicAlias 3636] -TEST(Subscribe5QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x29, 0x1d, 0xd1, 0x23, 0x1f, 0x0, 0x18, 0x9b, 0x94, 0x65, 0x0, 0xe2, 0x93, 0x22, - 0xa5, 0xe, 0x62, 0xa7, 0x35, 0x7, 0xa3, 0x91, 0x83, 0x91, 0x7, 0x7b, 0x37, 0xff, 0x34, - 0xfc, 0xb6, 0x18, 0x0, 0x0, 0x5e, 0xcf, 0x23, 0xe, 0x34, 0x0, 0x0, 0x2}; +// SubscribeRequest 4648 [("\172K\233\189\190\a>\228I\131=\247\DEL\255",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("d\206\145J",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\192\f%\166\NAK\218D3Q\180\233O'N\DC39i5\236\&2r",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\195\233]\b\254s\198E",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\161\EOTL\192\&7\180m\152*\178,\241`\199\167 ",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\159\FS\203g6+\169\183\247\253\137\168\SO\174\243\r\EOT\tH\EOTkQ\a)G#:7\204\DC3",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\RSB)}\225\170\218\238\205\247",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode29) { + uint8_t pkt[] = {0x82, 0x7e, 0x12, 0x28, 0x0, 0xe, 0xac, 0x4b, 0xe9, 0xbd, 0xbe, 0x7, 0x3e, 0xe4, 0x49, 0x83, + 0x3d, 0xf7, 0x7f, 0xff, 0x0, 0x0, 0x4, 0x64, 0xce, 0x91, 0x4a, 0x1, 0x0, 0x15, 0xc0, 0xc, + 0x25, 0xa6, 0x15, 0xda, 0x44, 0x33, 0x51, 0xb4, 0xe9, 0x4f, 0x27, 0x4e, 0x13, 0x39, 0x69, 0x35, + 0xec, 0x32, 0x72, 0x2, 0x0, 0x8, 0xc3, 0xe9, 0x5d, 0x8, 0xfe, 0x73, 0xc6, 0x45, 0x2, 0x0, + 0x10, 0xa1, 0x4, 0x4c, 0xc0, 0x37, 0xb4, 0x6d, 0x98, 0x2a, 0xb2, 0x2c, 0xf1, 0x60, 0xc7, 0xa7, + 0x20, 0x0, 0x0, 0x1e, 0x9f, 0x1c, 0xcb, 0x67, 0x36, 0x2b, 0xa9, 0xb7, 0xf7, 0xfd, 0x89, 0xa8, + 0xe, 0xae, 0xf3, 0xd, 0x4, 0x9, 0x48, 0x4, 0x6b, 0x51, 0x7, 0x29, 0x47, 0x23, 0x3a, 0x37, + 0xcc, 0x13, 0x0, 0x0, 0xa, 0x1e, 0x42, 0x29, 0x7d, 0xe1, 0xaa, 0xda, 0xee, 0xcd, 0xf7, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xac, 0x4b, 0xe9, 0xbd, 0xbe, 0x7, 0x3e, 0xe4, 0x49, 0x83, 0x3d, 0xf7, 0x7f, 0xff}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s1_bytes[] = {0x64, 0xce, 0x91, 0x4a}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc0, 0xc, 0x25, 0xa6, 0x15, 0xda, 0x44, 0x33, 0x51, 0xb4, 0xe9, + 0x4f, 0x27, 0x4e, 0x13, 0x39, 0x69, 0x35, 0xec, 0x32, 0x72}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc3, 0xe9, 0x5d, 0x8, 0xfe, 0x73, 0xc6, 0x45}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa1, 0x4, 0x4c, 0xc0, 0x37, 0xb4, 0x6d, 0x98, + 0x2a, 0xb2, 0x2c, 0xf1, 0x60, 0xc7, 0xa7, 0x20}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x9f, 0x1c, 0xcb, 0x67, 0x36, 0x2b, 0xa9, 0xb7, 0xf7, 0xfd, + 0x89, 0xa8, 0xe, 0xae, 0xf3, 0xd, 0x4, 0x9, 0x48, 0x4, + 0x6b, 0x51, 0x7, 0x29, 0x47, 0x23, 0x3a, 0x37, 0xcc, 0x13}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x1e, 0x42, 0x29, 0x7d, 0xe1, 0xaa, 0xda, 0xee, 0xcd, 0xf7}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - uint8_t bytesprops0[] = {0x9b, 0x94, 0x65, 0x0, 0xe2, 0x93, 0x22, 0xa5, 0xe, 0x62, 0xa7, 0x35, - 0x7, 0xa3, 0x91, 0x83, 0x91, 0x7, 0x7b, 0x37, 0xff, 0x34, 0xfc, 0xb6}; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24271}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3636}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7633, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4648, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29762 [("J\239",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable 164,PropPayloadFormatIndicator -// 175,PropMessageExpiryInterval 7362,PropMaximumPacketSize 25435,PropMessageExpiryInterval 15479,PropServerReference -// "\FS\169\DC1\163\242\224",PropAssignedClientIdentifier "\SUB\154 k#\250t\128\242HQ\209$\173\SI",PropTopicAlias -// 7747,PropMessageExpiryInterval 3634,PropAuthenticationMethod -// "2vE\128\215\138rD\242\243\211\202\STX]\"!\238\159%\174\243",PropWildcardSubscriptionAvailable -// 141,PropTopicAliasMaximum 21116,PropSessionExpiryInterval 14836] -TEST(Subscribe5QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0x60, 0x74, 0x42, 0x58, 0x2a, 0xa4, 0x1, 0xaf, 0x2, 0x0, 0x0, 0x1c, 0xc2, 0x27, 0x0, 0x0, - 0x63, 0x5b, 0x2, 0x0, 0x0, 0x3c, 0x77, 0x1c, 0x0, 0x6, 0x1c, 0xa9, 0x11, 0xa3, 0xf2, 0xe0, 0x12, - 0x0, 0xf, 0x1a, 0x9a, 0x20, 0x6b, 0x23, 0xfa, 0x74, 0x80, 0xf2, 0x48, 0x51, 0xd1, 0x24, 0xad, 0xf, - 0x23, 0x1e, 0x43, 0x2, 0x0, 0x0, 0xe, 0x32, 0x15, 0x0, 0x15, 0x32, 0x76, 0x45, 0x80, 0xd7, 0x8a, - 0x72, 0x44, 0xf2, 0xf3, 0xd3, 0xca, 0x2, 0x5d, 0x22, 0x21, 0xee, 0x9f, 0x25, 0xae, 0xf3, 0x28, 0x8d, - 0x22, 0x52, 0x7c, 0x11, 0x0, 0x0, 0x39, 0xf4, 0x0, 0x2, 0x4a, 0xef, 0x22}; +// SubscribeRequest 13920 [(";q\215\241\130b\220s",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode30) { + uint8_t pkt[] = {0x82, 0xd, 0x36, 0x60, 0x0, 0x8, 0x3b, 0x71, 0xd7, 0xf1, 0x82, 0x62, 0xdc, 0x73, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x4a, 0xef}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x3b, 0x71, 0xd7, 0xf1, 0x82, 0x62, 0xdc, 0x73}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - uint8_t bytesprops0[] = {0x1c, 0xa9, 0x11, 0xa3, 0xf2, 0xe0}; - uint8_t bytesprops1[] = {0x1a, 0x9a, 0x20, 0x6b, 0x23, 0xfa, 0x74, 0x80, 0xf2, 0x48, 0x51, 0xd1, 0x24, 0xad, 0xf}; - uint8_t bytesprops2[] = {0x32, 0x76, 0x45, 0x80, 0xd7, 0x8a, 0x72, 0x44, 0xf2, 0xf3, 0xd3, - 0xca, 0x2, 0x5d, 0x22, 0x21, 0xee, 0x9f, 0x25, 0xae, 0xf3}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7362}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25435}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15479}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7747}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3634}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21116}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14836}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29762, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13920, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30334 [("/\SUB\DC2:k\140\DC3\184\237\130\214-\204\144j\179\231\244\242tp@\RSZx\ENQX",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("T\210\128\148\230\144\147\&2&+N\138\198\129\156\149",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\a[}\129\251}\153\232\133",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\156\198\198\142\194\236T\189\228\175e\155\ETX\145\225\\:\SUB\131\221",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("D\174\175\216\224\ETB\193\170\214\231",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished -// = False, _noLocal = True, _subQoS = QoS2}),("\207\193\224w'\248\246",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropSessionExpiryInterval -// 18702,PropReceiveMaximum 21620,PropSharedSubscriptionAvailable 214] -TEST(Subscribe5QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x78, 0x76, 0x7e, 0xa, 0x11, 0x0, 0x0, 0x49, 0xe, 0x21, 0x54, 0x74, 0x2a, 0xd6, 0x0, - 0x1b, 0x2f, 0x1a, 0x12, 0x3a, 0x6b, 0x8c, 0x13, 0xb8, 0xed, 0x82, 0xd6, 0x2d, 0xcc, 0x90, 0x6a, - 0xb3, 0xe7, 0xf4, 0xf2, 0x74, 0x70, 0x40, 0x1e, 0x5a, 0x78, 0x5, 0x58, 0x16, 0x0, 0x10, 0x54, - 0xd2, 0x80, 0x94, 0xe6, 0x90, 0x93, 0x32, 0x26, 0x2b, 0x4e, 0x8a, 0xc6, 0x81, 0x9c, 0x95, 0x10, - 0x0, 0x9, 0x7, 0x5b, 0x7d, 0x81, 0xfb, 0x7d, 0x99, 0xe8, 0x85, 0x2d, 0x0, 0x14, 0x9c, 0xc6, - 0xc6, 0x8e, 0xc2, 0xec, 0x54, 0xbd, 0xe4, 0xaf, 0x65, 0x9b, 0x3, 0x91, 0xe1, 0x5c, 0x3a, 0x1a, - 0x83, 0xdd, 0x5, 0x0, 0xa, 0x44, 0xae, 0xaf, 0xd8, 0xe0, 0x17, 0xc1, 0xaa, 0xd6, 0xe7, 0x16, - 0x0, 0x7, 0xcf, 0xc1, 0xe0, 0x77, 0x27, 0xf8, 0xf6, 0x2c}; +// SubscribeRequest 22060 [("\223\227\254#\231\fk\254CT\157\246_G\GSI",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\212\DC4\172\SI\161\ETX[\171~`Y\188\185\181pS\206X",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropServerReference +// "r\181\rI\ETB\181\203[\215^([\160+\174\197\230\SI\139%\177\137r\232_s\253\DC3\n",PropServerReference +// "\ETB\242\ESC\151\128r\176<\167\209N\RS\232\NAK\196\SOM\138\209\191\134\191\190\221\221\183\167Z",PropTopicAliasMaximum +// 17608,PropResponseInformation +// "\SI\r\193H\132",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("@\181\178*D\211",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("5\138\164\236\175\v\154\215\DLE\DC1\250Z\168N\145\228\235C\186\rrf\247\243",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("o\235s\DC1p\179\196\&3\216n\ENQ",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS2})] [PropAuthenticationData -// "3\STX\146(\244\153@\186\251\SUBcG1\191\223Z\SUBh\221C\203>",PropServerKeepAlive 986,PropTopicAlias -// 9329,PropWillDelayInterval 3455,PropAssignedClientIdentifier -// "\211Rp\255\FS\FS\238\&6",PropWildcardSubscriptionAvailable 228,PropRequestResponseInformation -// 250,PropServerReference "",PropMessageExpiryInterval 13564,PropReceiveMaximum 10366,PropSubscriptionIdentifier -// 27,PropServerKeepAlive 6764,PropWillDelayInterval 29672,PropSessionExpiryInterval 3082,PropTopicAlias -// 11165,PropWillDelayInterval 28623,PropSessionExpiryInterval 10852,PropResponseInformation -// "I",PropRequestProblemInformation 98,PropMaximumQoS 75,PropMaximumQoS 88,PropMessageExpiryInterval -// 1740,PropReceiveMaximum 21047,PropSubscriptionIdentifier 28] -TEST(Subscribe5QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0xb2, 0x1, 0x66, 0xb3, 0x6e, 0x16, 0x0, 0x16, 0x33, 0x2, 0x92, 0x28, 0xf4, 0x99, 0x40, 0xba, - 0xfb, 0x1a, 0x63, 0x47, 0x31, 0xbf, 0xdf, 0x5a, 0x1a, 0x68, 0xdd, 0x43, 0xcb, 0x3e, 0x13, 0x3, 0xda, - 0x23, 0x24, 0x71, 0x18, 0x0, 0x0, 0xd, 0x7f, 0x12, 0x0, 0x8, 0xd3, 0x52, 0x70, 0xff, 0x1c, 0x1c, - 0xee, 0x36, 0x28, 0xe4, 0x19, 0xfa, 0x1c, 0x0, 0x0, 0x2, 0x0, 0x0, 0x34, 0xfc, 0x21, 0x28, 0x7e, - 0xb, 0x1b, 0x13, 0x1a, 0x6c, 0x18, 0x0, 0x0, 0x73, 0xe8, 0x11, 0x0, 0x0, 0xc, 0xa, 0x23, 0x2b, - 0x9d, 0x18, 0x0, 0x0, 0x6f, 0xcf, 0x11, 0x0, 0x0, 0x2a, 0x64, 0x1a, 0x0, 0x1, 0x49, 0x17, 0x62, - 0x24, 0x4b, 0x24, 0x58, 0x2, 0x0, 0x0, 0x6, 0xcc, 0x21, 0x52, 0x37, 0xb, 0x1c, 0x0, 0xc, 0xf, - 0xeb, 0x26, 0x10, 0x79, 0x96, 0xa, 0xcf, 0xd4, 0x3e, 0x48, 0x84, 0xa, 0x0, 0x6, 0x40, 0xb5, 0xb2, - 0x2a, 0x44, 0xd3, 0x16, 0x0, 0x18, 0x35, 0x8a, 0xa4, 0xec, 0xaf, 0xb, 0x9a, 0xd7, 0x10, 0x11, 0xfa, - 0x5a, 0xa8, 0x4e, 0x91, 0xe4, 0xeb, 0x43, 0xba, 0xd, 0x72, 0x66, 0xf7, 0xf3, 0xa, 0x0, 0xb, 0x6f, - 0xeb, 0x73, 0x11, 0x70, 0xb3, 0xc4, 0x33, 0xd8, 0x6e, 0x5, 0x16}; +// SubscribeRequest 21589 +// [("\204\251XL\209\150\136\SUB\146\187\US\196\153\150d\219\213\209\RS\174\175\144^\140\138\147\203\240\214\215",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("g\160\ESC\225\199\RS!%|\ACKG\217v\148w\135\203",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("I*\141\&7!n",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\250wi\NAK0H\153\149m1#\244\243j\171jT\193\248\219\EOT\246X\217\161\192",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\241\239J(\216\192=\130\197-h|\170B\US\204]\166\204\149\152|\EOT\221X*U\138w\238",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\137;E\ETX\186\180\221\246\229\182\247\208",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("}\240",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("t\205_\220\162g\141/cH",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS2}),("\135\137\149\208",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\165\DC36\SUBG\US}\220\EM\SI\137\251\204?\210\EOT#\bLN\129",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropResponseInformation +// "1\129\243\187f*|\232",PropServerKeepAlive 9919] +TEST(Subscribe5QCTest, Encode2) { + uint8_t pkt[] = {0x82, 0xd0, 0x1, 0x54, 0x55, 0xe, 0x1a, 0x0, 0x8, 0x31, 0x81, 0xf3, 0xbb, 0x66, 0x2a, 0x7c, 0xe8, + 0x13, 0x26, 0xbf, 0x0, 0x1e, 0xcc, 0xfb, 0x58, 0x4c, 0xd1, 0x96, 0x88, 0x1a, 0x92, 0xbb, 0x1f, 0xc4, + 0x99, 0x96, 0x64, 0xdb, 0xd5, 0xd1, 0x1e, 0xae, 0xaf, 0x90, 0x5e, 0x8c, 0x8a, 0x93, 0xcb, 0xf0, 0xd6, + 0xd7, 0x14, 0x0, 0x11, 0x67, 0xa0, 0x1b, 0xe1, 0xc7, 0x1e, 0x21, 0x25, 0x7c, 0x6, 0x47, 0xd9, 0x76, + 0x94, 0x77, 0x87, 0xcb, 0x29, 0x0, 0x6, 0x49, 0x2a, 0x8d, 0x37, 0x21, 0x6e, 0x0, 0x0, 0x1a, 0xfa, + 0x77, 0x69, 0x15, 0x30, 0x48, 0x99, 0x95, 0x6d, 0x31, 0x23, 0xf4, 0xf3, 0x6a, 0xab, 0x6a, 0x54, 0xc1, + 0xf8, 0xdb, 0x4, 0xf6, 0x58, 0xd9, 0xa1, 0xc0, 0x1c, 0x0, 0x1e, 0xf1, 0xef, 0x4a, 0x28, 0xd8, 0xc0, + 0x3d, 0x82, 0xc5, 0x2d, 0x68, 0x7c, 0xaa, 0x42, 0x1f, 0xcc, 0x5d, 0xa6, 0xcc, 0x95, 0x98, 0x7c, 0x4, + 0xdd, 0x58, 0x2a, 0x55, 0x8a, 0x77, 0xee, 0x18, 0x0, 0x0, 0x5, 0x0, 0xc, 0x89, 0x3b, 0x45, 0x3, + 0xba, 0xb4, 0xdd, 0xf6, 0xe5, 0xb6, 0xf7, 0xd0, 0x28, 0x0, 0x2, 0x7d, 0xf0, 0x12, 0x0, 0xa, 0x74, + 0xcd, 0x5f, 0xdc, 0xa2, 0x67, 0x8d, 0x2f, 0x63, 0x48, 0x1a, 0x0, 0x4, 0x87, 0x89, 0x95, 0xd0, 0x12, + 0x0, 0x15, 0xa5, 0x13, 0x36, 0x1a, 0x47, 0x1f, 0x7d, 0xdc, 0x19, 0xf, 0x89, 0xfb, 0xcc, 0x3f, 0xd2, + 0x4, 0x23, 0x8, 0x4c, 0x4e, 0x81, 0x18}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xf, 0xeb, 0x26, 0x10, 0x79, 0x96, 0xa, 0xcf, 0xd4, 0x3e, 0x48, 0x84}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xcc, 0xfb, 0x58, 0x4c, 0xd1, 0x96, 0x88, 0x1a, 0x92, 0xbb, + 0x1f, 0xc4, 0x99, 0x96, 0x64, 0xdb, 0xd5, 0xd1, 0x1e, 0xae, + 0xaf, 0x90, 0x5e, 0x8c, 0x8a, 0x93, 0xcb, 0xf0, 0xd6, 0xd7}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x40, 0xb5, 0xb2, 0x2a, 0x44, 0xd3}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x67, 0xa0, 0x1b, 0xe1, 0xc7, 0x1e, 0x21, 0x25, 0x7c, + 0x6, 0x47, 0xd9, 0x76, 0x94, 0x77, 0x87, 0xcb}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x35, 0x8a, 0xa4, 0xec, 0xaf, 0xb, 0x9a, 0xd7, 0x10, 0x11, 0xfa, 0x5a, - 0xa8, 0x4e, 0x91, 0xe4, 0xeb, 0x43, 0xba, 0xd, 0x72, 0x66, 0xf7, 0xf3}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x49, 0x2a, 0x8d, 0x37, 0x21, 0x6e}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6f, 0xeb, 0x73, 0x11, 0x70, 0xb3, 0xc4, 0x33, 0xd8, 0x6e, 0x5}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfa, 0x77, 0x69, 0x15, 0x30, 0x48, 0x99, 0x95, 0x6d, 0x31, 0x23, 0xf4, 0xf3, + 0x6a, 0xab, 0x6a, 0x54, 0xc1, 0xf8, 0xdb, 0x4, 0xf6, 0x58, 0xd9, 0xa1, 0xc0}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; + uint8_t topic_filter_s4_bytes[] = {0xf1, 0xef, 0x4a, 0x28, 0xd8, 0xc0, 0x3d, 0x82, 0xc5, 0x2d, + 0x68, 0x7c, 0xaa, 0x42, 0x1f, 0xcc, 0x5d, 0xa6, 0xcc, 0x95, + 0x98, 0x7c, 0x4, 0xdd, 0x58, 0x2a, 0x55, 0x8a, 0x77, 0xee}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x89, 0x3b, 0x45, 0x3, 0xba, 0xb4, 0xdd, 0xf6, 0xe5, 0xb6, 0xf7, 0xd0}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x7d, 0xf0}; + lwmqtt_string_t topic_filter_s7 = {2, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x74, 0xcd, 0x5f, 0xdc, 0xa2, 0x67, 0x8d, 0x2f, 0x63, 0x48}; + lwmqtt_string_t topic_filter_s8 = {10, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x87, 0x89, 0x95, 0xd0}; + lwmqtt_string_t topic_filter_s9 = {4, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xa5, 0x13, 0x36, 0x1a, 0x47, 0x1f, 0x7d, 0xdc, 0x19, 0xf, 0x89, + 0xfb, 0xcc, 0x3f, 0xd2, 0x4, 0x23, 0x8, 0x4c, 0x4e, 0x81}; + lwmqtt_string_t topic_filter_s10 = {21, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; - uint8_t bytesprops0[] = {0x33, 0x2, 0x92, 0x28, 0xf4, 0x99, 0x40, 0xba, 0xfb, 0x1a, 0x63, - 0x47, 0x31, 0xbf, 0xdf, 0x5a, 0x1a, 0x68, 0xdd, 0x43, 0xcb, 0x3e}; - uint8_t bytesprops1[] = {0xd3, 0x52, 0x70, 0xff, 0x1c, 0x1c, 0xee, 0x36}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x49}; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = false; + uint8_t bytesprops0[] = {0x31, 0x81, 0xf3, 0xbb, 0x66, 0x2a, 0x7c, 0xe8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 986}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9329}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3455}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13564}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10366}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6764}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29672}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3082}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11165}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28623}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10852}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1740}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21047}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9919}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26291, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21589, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29015 [("\163\tU\254\239\150/*\157\226\191\&1a\DC3\227{",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\213\SUB\207\229\DC3\246\243\142",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [PropRequestResponseInformation 223,PropServerReference -// "\239\139\206\179\GS\133jT&p\150\232\206\CAN\217",PropSharedSubscriptionAvailable 72,PropServerKeepAlive -// 10269,PropServerReference "CP",PropPayloadFormatIndicator 144,PropWillDelayInterval 20331,PropAuthenticationData -// "\222\SI\128\ETXF\194\249O\180'\198\192\&9\233\163\217\189\239\GS\223\DC2\b\130Ou]=\142\\Q",PropSessionExpiryInterval -// 14899,PropRetainAvailable 53,PropRetainAvailable 23,PropSharedSubscriptionAvailable 74,PropPayloadFormatIndicator -// 90,PropMessageExpiryInterval 26931,PropRequestProblemInformation 202,PropSubscriptionIdentifierAvailable -// 70,PropMaximumQoS 160,PropServerReference -// "\196\207\143&\235@\178\248\154\190\163\201\153M\148\168",PropWillDelayInterval 24816,PropMaximumPacketSize -// 26054,PropCorrelationData "\243?H\SYN\181w\130R/\146\NULcpF\182\219.\181\232\200\220\a\255G8",PropServerKeepAlive -// 12011,PropRetainAvailable 29,PropSubscriptionIdentifier 6,PropMaximumQoS 2,PropRequestProblemInformation 42] -TEST(Subscribe5QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0xc4, 0x1, 0x71, 0x57, 0xa2, 0x1, 0x19, 0xdf, 0x1c, 0x0, 0xf, 0xef, 0x8b, 0xce, 0xb3, 0x1d, - 0x85, 0x6a, 0x54, 0x26, 0x70, 0x96, 0xe8, 0xce, 0x18, 0xd9, 0x2a, 0x48, 0x13, 0x28, 0x1d, 0x1c, 0x0, - 0x2, 0x43, 0x50, 0x1, 0x90, 0x18, 0x0, 0x0, 0x4f, 0x6b, 0x16, 0x0, 0x1e, 0xde, 0xf, 0x80, 0x3, - 0x46, 0xc2, 0xf9, 0x4f, 0xb4, 0x27, 0xc6, 0xc0, 0x39, 0xe9, 0xa3, 0xd9, 0xbd, 0xef, 0x1d, 0xdf, 0x12, - 0x8, 0x82, 0x4f, 0x75, 0x5d, 0x3d, 0x8e, 0x5c, 0x51, 0x11, 0x0, 0x0, 0x3a, 0x33, 0x25, 0x35, 0x25, - 0x17, 0x2a, 0x4a, 0x1, 0x5a, 0x2, 0x0, 0x0, 0x69, 0x33, 0x17, 0xca, 0x29, 0x46, 0x24, 0xa0, 0x1c, - 0x0, 0x10, 0xc4, 0xcf, 0x8f, 0x26, 0xeb, 0x40, 0xb2, 0xf8, 0x9a, 0xbe, 0xa3, 0xc9, 0x99, 0x4d, 0x94, - 0xa8, 0x18, 0x0, 0x0, 0x60, 0xf0, 0x27, 0x0, 0x0, 0x65, 0xc6, 0x9, 0x0, 0x19, 0xf3, 0x3f, 0x48, - 0x16, 0xb5, 0x77, 0x82, 0x52, 0x2f, 0x92, 0x0, 0x63, 0x70, 0x46, 0xb6, 0xdb, 0x2e, 0xb5, 0xe8, 0xc8, - 0xdc, 0x7, 0xff, 0x47, 0x38, 0x13, 0x2e, 0xeb, 0x25, 0x1d, 0xb, 0x6, 0x24, 0x2, 0x17, 0x2a, 0x0, - 0x10, 0xa3, 0x9, 0x55, 0xfe, 0xef, 0x96, 0x2f, 0x2a, 0x9d, 0xe2, 0xbf, 0x31, 0x61, 0x13, 0xe3, 0x7b, - 0x1, 0x0, 0x8, 0xd5, 0x1a, 0xcf, 0xe5, 0x13, 0xf6, 0xf3, 0x8e, 0x22}; +// SubscribeRequest 25658 [("\135\217dy\159J\NULIZ",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("~|l\v\rK\139\EMPB\237\236M\165\138",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] +// [PropRequestProblemInformation 79,PropRetainAvailable 116,PropContentType "[",PropMaximumPacketSize +// 24345,PropRequestResponseInformation 139,PropReceiveMaximum 19854,PropRetainAvailable 90,PropResponseInformation +// "\GS\135Ko\150\201\&0",PropMessageExpiryInterval 28084,PropMaximumPacketSize 6563,PropAuthenticationData +// "9Xk",PropSubscriptionIdentifier 22,PropRequestProblemInformation 247,PropTopicAlias 5595,PropContentType +// "\181\208i'2\161\162\192Wx\206\255\132Z\174e\224a~\149",PropWillDelayInterval 19259,PropContentType +// "\215\221%\216\191\DC2XX\253\232\156m\247\232\144\CAN\178\215[p\243&]\166",PropUserProperty "\228\150" +// "q!\193\SO\239$\165\b\168T\219!\154o\214\227skV\232",PropRetainAvailable 201,PropRetainAvailable +// 53,PropSubscriptionIdentifier 18,PropSubscriptionIdentifier 29,PropWildcardSubscriptionAvailable +// 25,PropTopicAliasMaximum 31978,PropAuthenticationMethod +// "Bf\146\ESCfn\170(\243(\EM\158t\ETX\158\160\GS\132\SICC\248",PropAuthenticationData +// "\134:\b\195\240\181\209\156<:H\174\172\232\190\243\128\189\150\208IOJ\200\155\154\DLE\219\GS)",PropSessionExpiryInterval +// 15712,PropContentType "\249\193&1r\a\197,\159\154 \205mq\223\161r\202\130.>C\129\&8\131",PropReceiveMaximum 29108] +TEST(Subscribe5QCTest, Encode3) { + uint8_t pkt[] = { + 0x82, 0x94, 0x2, 0x64, 0x3a, 0xf2, 0x1, 0x17, 0x4f, 0x25, 0x74, 0x3, 0x0, 0x1, 0x5b, 0x27, 0x0, 0x0, 0x5f, + 0x19, 0x19, 0x8b, 0x21, 0x4d, 0x8e, 0x25, 0x5a, 0x1a, 0x0, 0x7, 0x1d, 0x87, 0x4b, 0x6f, 0x96, 0xc9, 0x30, 0x2, + 0x0, 0x0, 0x6d, 0xb4, 0x27, 0x0, 0x0, 0x19, 0xa3, 0x16, 0x0, 0x3, 0x39, 0x58, 0x6b, 0xb, 0x16, 0x17, 0xf7, + 0x23, 0x15, 0xdb, 0x3, 0x0, 0x14, 0xb5, 0xd0, 0x69, 0x27, 0x32, 0xa1, 0xa2, 0xc0, 0x57, 0x78, 0xce, 0xff, 0x84, + 0x5a, 0xae, 0x65, 0xe0, 0x61, 0x7e, 0x95, 0x18, 0x0, 0x0, 0x4b, 0x3b, 0x3, 0x0, 0x18, 0xd7, 0xdd, 0x25, 0xd8, + 0xbf, 0x12, 0x58, 0x58, 0xfd, 0xe8, 0x9c, 0x6d, 0xf7, 0xe8, 0x90, 0x18, 0xb2, 0xd7, 0x5b, 0x70, 0xf3, 0x26, 0x5d, + 0xa6, 0x26, 0x0, 0x2, 0xe4, 0x96, 0x0, 0x14, 0x71, 0x21, 0xc1, 0xe, 0xef, 0x24, 0xa5, 0x8, 0xa8, 0x54, 0xdb, + 0x21, 0x9a, 0x6f, 0xd6, 0xe3, 0x73, 0x6b, 0x56, 0xe8, 0x25, 0xc9, 0x25, 0x35, 0xb, 0x12, 0xb, 0x1d, 0x28, 0x19, + 0x22, 0x7c, 0xea, 0x15, 0x0, 0x16, 0x42, 0x66, 0x92, 0x1b, 0x66, 0x6e, 0xaa, 0x28, 0xf3, 0x28, 0x19, 0x9e, 0x74, + 0x3, 0x9e, 0xa0, 0x1d, 0x84, 0xf, 0x43, 0x43, 0xf8, 0x16, 0x0, 0x1e, 0x86, 0x3a, 0x8, 0xc3, 0xf0, 0xb5, 0xd1, + 0x9c, 0x3c, 0x3a, 0x48, 0xae, 0xac, 0xe8, 0xbe, 0xf3, 0x80, 0xbd, 0x96, 0xd0, 0x49, 0x4f, 0x4a, 0xc8, 0x9b, 0x9a, + 0x10, 0xdb, 0x1d, 0x29, 0x11, 0x0, 0x0, 0x3d, 0x60, 0x3, 0x0, 0x19, 0xf9, 0xc1, 0x26, 0x31, 0x72, 0x7, 0xc5, + 0x2c, 0x9f, 0x9a, 0x20, 0xcd, 0x6d, 0x71, 0xdf, 0xa1, 0x72, 0xca, 0x82, 0x2e, 0x3e, 0x43, 0x81, 0x38, 0x83, 0x21, + 0x71, 0xb4, 0x0, 0x9, 0x87, 0xd9, 0x64, 0x79, 0x9f, 0x4a, 0x0, 0x49, 0x5a, 0x22, 0x0, 0xf, 0x7e, 0x7c, 0x6c, + 0xb, 0xd, 0x4b, 0x8b, 0x19, 0x50, 0x42, 0xed, 0xec, 0x4d, 0xa5, 0x8a, 0x26}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xa3, 0x9, 0x55, 0xfe, 0xef, 0x96, 0x2f, 0x2a, - 0x9d, 0xe2, 0xbf, 0x31, 0x61, 0x13, 0xe3, 0x7b}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x87, 0xd9, 0x64, 0x79, 0x9f, 0x4a, 0x0, 0x49, 0x5a}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd5, 0x1a, 0xcf, 0xe5, 0x13, 0xf6, 0xf3, 0x8e}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7e, 0x7c, 0x6c, 0xb, 0xd, 0x4b, 0x8b, 0x19, + 0x50, 0x42, 0xed, 0xec, 0x4d, 0xa5, 0x8a}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - uint8_t bytesprops0[] = {0xef, 0x8b, 0xce, 0xb3, 0x1d, 0x85, 0x6a, 0x54, 0x26, 0x70, 0x96, 0xe8, 0xce, 0x18, 0xd9}; - uint8_t bytesprops1[] = {0x43, 0x50}; - uint8_t bytesprops2[] = {0xde, 0xf, 0x80, 0x3, 0x46, 0xc2, 0xf9, 0x4f, 0xb4, 0x27, 0xc6, 0xc0, 0x39, 0xe9, 0xa3, - 0xd9, 0xbd, 0xef, 0x1d, 0xdf, 0x12, 0x8, 0x82, 0x4f, 0x75, 0x5d, 0x3d, 0x8e, 0x5c, 0x51}; - uint8_t bytesprops3[] = {0xc4, 0xcf, 0x8f, 0x26, 0xeb, 0x40, 0xb2, 0xf8, - 0x9a, 0xbe, 0xa3, 0xc9, 0x99, 0x4d, 0x94, 0xa8}; - uint8_t bytesprops4[] = {0xf3, 0x3f, 0x48, 0x16, 0xb5, 0x77, 0x82, 0x52, 0x2f, 0x92, 0x0, 0x63, 0x70, - 0x46, 0xb6, 0xdb, 0x2e, 0xb5, 0xe8, 0xc8, 0xdc, 0x7, 0xff, 0x47, 0x38}; + sub_opts[1].no_local = true; + uint8_t bytesprops0[] = {0x5b}; + uint8_t bytesprops1[] = {0x1d, 0x87, 0x4b, 0x6f, 0x96, 0xc9, 0x30}; + uint8_t bytesprops2[] = {0x39, 0x58, 0x6b}; + uint8_t bytesprops3[] = {0xb5, 0xd0, 0x69, 0x27, 0x32, 0xa1, 0xa2, 0xc0, 0x57, 0x78, + 0xce, 0xff, 0x84, 0x5a, 0xae, 0x65, 0xe0, 0x61, 0x7e, 0x95}; + uint8_t bytesprops4[] = {0xd7, 0xdd, 0x25, 0xd8, 0xbf, 0x12, 0x58, 0x58, 0xfd, 0xe8, 0x9c, 0x6d, + 0xf7, 0xe8, 0x90, 0x18, 0xb2, 0xd7, 0x5b, 0x70, 0xf3, 0x26, 0x5d, 0xa6}; + uint8_t bytesprops6[] = {0x71, 0x21, 0xc1, 0xe, 0xef, 0x24, 0xa5, 0x8, 0xa8, 0x54, + 0xdb, 0x21, 0x9a, 0x6f, 0xd6, 0xe3, 0x73, 0x6b, 0x56, 0xe8}; + uint8_t bytesprops5[] = {0xe4, 0x96}; + uint8_t bytesprops7[] = {0x42, 0x66, 0x92, 0x1b, 0x66, 0x6e, 0xaa, 0x28, 0xf3, 0x28, 0x19, + 0x9e, 0x74, 0x3, 0x9e, 0xa0, 0x1d, 0x84, 0xf, 0x43, 0x43, 0xf8}; + uint8_t bytesprops8[] = {0x86, 0x3a, 0x8, 0xc3, 0xf0, 0xb5, 0xd1, 0x9c, 0x3c, 0x3a, 0x48, 0xae, 0xac, 0xe8, 0xbe, + 0xf3, 0x80, 0xbd, 0x96, 0xd0, 0x49, 0x4f, 0x4a, 0xc8, 0x9b, 0x9a, 0x10, 0xdb, 0x1d, 0x29}; + uint8_t bytesprops9[] = {0xf9, 0xc1, 0x26, 0x31, 0x72, 0x7, 0xc5, 0x2c, 0x9f, 0x9a, 0x20, 0xcd, 0x6d, + 0x71, 0xdf, 0xa1, 0x72, 0xca, 0x82, 0x2e, 0x3e, 0x43, 0x81, 0x38, 0x83}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10269}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20331}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14899}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24345}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19854}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28084}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6563}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5595}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19259}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops5}, .v = {20, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 201}}, {.prop = (lwmqtt_prop_t)37, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26931}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24816}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26054}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12011}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31978}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15712}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29108}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29015, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25658, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 24249 [("\133\139\\\225\188\f;\\\232=\247\f\131i3BK7cp\150l\FSc",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\173$rH\250",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\169\145\164k\139\246",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\US\DEL\ffL]\EMM4V |1\RS\169\151\NAK\246",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\190\200Cvj\152\154\218\249x\STX\251}`\168\156\182>]`r\175",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\248\&3\182",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] -// [PropSessionExpiryInterval 15919,PropMessageExpiryInterval 13210,PropSharedSubscriptionAvailable -// 2,PropResponseInformation -// "\173p\184\166Z\174\249\226\182\211Z\\\231\136^\240y\243\186\SUB\DLE\247,\167{\172V\203",PropPayloadFormatIndicator -// 57,PropTopicAliasMaximum 16229,PropMaximumQoS 46,PropSubscriptionIdentifier 32,PropUserProperty -// "\ru\135\v@\145\160\215\177\&4EQ\150\138\&3;\225\222\217" "\SI\195\SO\DLE\228",PropCorrelationData -// "\EM\229\DC3\222B\172m\DC2\230\238",PropMessageExpiryInterval 7126,PropSubscriptionIdentifier 10,PropRetainAvailable -// 192,PropResponseTopic "\168\184\&9l\238\DC1\ACK\185&\179*{\DC1-\187\DLE11N$n\138\151\GS`^y\152A"] -TEST(Subscribe5QCTest, Encode6) { +// SubscribeRequest 3081 [("`\165\DC2QfJ\249\SI\229\168\140",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\175\219X\239\225\227x\227\ETB\252\181h",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\168#\148j\132a\191~\220R\159N\200\142j\222\155\217)\STX\rz\233",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("?\223\227x\250\168\161\217j\189b\253dAOF\239\202\227",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\160\136\fl(\220\155",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\152\146\139\145\146",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\197\241H\131\203;\238\152\EOT\187CUa\222\142\128\EM\SUBq",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\ACK_\244\234\207,W\239J\240\181\240fXg\231",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("{\\\162.Ggs\SOH\145\237\&7T\146",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] +// [PropTopicAlias 30114,PropRequestResponseInformation 126,PropContentType "\t\191_\216\RS\US7.\SUB +// ,\208\153\132\222\204\197\197\176\233\219",PropAuthenticationMethod +// "\191d\158f\222Q\196\254\194`:\233\f\133\191a\141\r\249\175\164\225so\229\188",PropResponseTopic +// "m9`\249\133\213\149\190A\170G",PropAuthenticationData +// "\222\164I\140\207gn\206\183\DC2\NUL30\252\128\185\RS\191\214_\160\180\&7\164QuF3\FS",PropServerReference +// "\190\173j",PropAuthenticationData "\228\179\EM\159\173%w\143\239)\233\240\&2\196",PropMessageExpiryInterval +// 29813,PropMaximumQoS 102,PropServerReference "\187L",PropServerKeepAlive 30422,PropAuthenticationMethod +// "\234x\f!\209\DC2\198\166\169",PropMessageExpiryInterval 32593,PropReasonString +// "^\141\&5\229\133B\254]{\230o",PropWildcardSubscriptionAvailable 112,PropSubscriptionIdentifierAvailable +// 135,PropResponseTopic "",PropMessageExpiryInterval 20318,PropRetainAvailable 209,PropMaximumPacketSize +// 2052,PropTopicAliasMaximum 10929,PropAssignedClientIdentifier +// "\134\US85\205?\225\167\234\acZN\179\136\NAK\221\150-",PropAuthenticationMethod "\201|\174u_\EM"] +TEST(Subscribe5QCTest, Encode4) { uint8_t pkt[] = { - 0x82, 0xeb, 0x1, 0x5e, 0xb9, 0x87, 0x1, 0x11, 0x0, 0x0, 0x3e, 0x2f, 0x2, 0x0, 0x0, 0x33, 0x9a, 0x2a, 0x2, - 0x1a, 0x0, 0x1c, 0xad, 0x70, 0xb8, 0xa6, 0x5a, 0xae, 0xf9, 0xe2, 0xb6, 0xd3, 0x5a, 0x5c, 0xe7, 0x88, 0x5e, 0xf0, - 0x79, 0xf3, 0xba, 0x1a, 0x10, 0xf7, 0x2c, 0xa7, 0x7b, 0xac, 0x56, 0xcb, 0x1, 0x39, 0x22, 0x3f, 0x65, 0x24, 0x2e, - 0xb, 0x20, 0x26, 0x0, 0x13, 0xd, 0x75, 0x87, 0xb, 0x40, 0x91, 0xa0, 0xd7, 0x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topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x85, 0x8b, 0x5c, 0xe1, 0xbc, 0xc, 0x3b, 0x5c, 0xe8, 0x3d, 0xf7, 0xc, - 0x83, 0x69, 0x33, 0x42, 0x4b, 0x37, 0x63, 0x70, 0x96, 0x6c, 0x1c, 0x63}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x60, 0xa5, 0x12, 0x51, 0x66, 0x4a, 0xf9, 0xf, 0xe5, 0xa8, 0x8c}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xad, 0x24, 0x72, 0x48, 0xfa}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xaf, 0xdb, 0x58, 0xef, 0xe1, 0xe3, 0x78, 0xe3, 0x17, 0xfc, 0xb5, 0x68}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa9, 0x91, 0xa4, 0x6b, 0x8b, 0xf6}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa8, 0x23, 0x94, 0x6a, 0x84, 0x61, 0xbf, 0x7e, 0xdc, 0x52, 0x9f, 0x4e, + 0xc8, 0x8e, 0x6a, 0xde, 0x9b, 0xd9, 0x29, 0x2, 0xd, 0x7a, 0xe9}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1f, 0x7f, 0xc, 0x66, 0x4c, 0x5d, 0x19, 0x4d, 0x34, - 0x56, 0x20, 0x7c, 0x31, 0x1e, 0xa9, 0x97, 0x15, 0xf6}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3f, 0xdf, 0xe3, 0x78, 0xfa, 0xa8, 0xa1, 0xd9, 0x6a, 0xbd, + 0x62, 0xfd, 0x64, 0x41, 0x4f, 0x46, 0xef, 0xca, 0xe3}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xbe, 0xc8, 0x43, 0x76, 0x6a, 0x98, 0x9a, 0xda, 0xf9, 0x78, 0x2, - 0xfb, 0x7d, 0x60, 0xa8, 0x9c, 0xb6, 0x3e, 0x5d, 0x60, 0x72, 0xaf}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa0, 0x88, 0xc, 0x6c, 0x28, 0xdc, 0x9b}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf8, 0x33, 0xb6}; - lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x98, 0x92, 0x8b, 0x91, 0x92}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s6_bytes[] = {0xc5, 0xf1, 0x48, 0x83, 0xcb, 0x3b, 0xee, 0x98, 0x4, 0xbb, + 0x43, 0x55, 0x61, 0xde, 0x8e, 0x80, 0x19, 0x1a, 0x71}; + lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6, 0x5f, 0xf4, 0xea, 0xcf, 0x2c, 0x57, 0xef, + 0x4a, 0xf0, 0xb5, 0xf0, 0x66, 0x58, 0x67, 0xe7}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x7b, 0x5c, 0xa2, 0x2e, 0x47, 0x67, 0x73, 0x1, 0x91, 0xed, 0x37, 0x54, 0x92}; + lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; + sub_opts[5].retain_as_published = false; sub_opts[5].no_local = true; - uint8_t bytesprops0[] = {0xad, 0x70, 0xb8, 0xa6, 0x5a, 0xae, 0xf9, 0xe2, 0xb6, 0xd3, 0x5a, 0x5c, 0xe7, 0x88, - 0x5e, 0xf0, 0x79, 0xf3, 0xba, 0x1a, 0x10, 0xf7, 0x2c, 0xa7, 0x7b, 0xac, 0x56, 0xcb}; - uint8_t bytesprops2[] = {0xf, 0xc3, 0xe, 0x10, 0xe4}; - uint8_t bytesprops1[] = {0xd, 0x75, 0x87, 0xb, 0x40, 0x91, 0xa0, 0xd7, 0xb1, 0x34, - 0x45, 0x51, 0x96, 0x8a, 0x33, 0x3b, 0xe1, 0xde, 0xd9}; - uint8_t bytesprops3[] = {0x19, 0xe5, 0x13, 0xde, 0x42, 0xac, 0x6d, 0x12, 0xe6, 0xee}; - uint8_t bytesprops4[] = {0xa8, 0xb8, 0x39, 0x6c, 0xee, 0x11, 0x6, 0xb9, 0x26, 0xb3, 0x2a, 0x7b, 0x11, 0x2d, 0xbb, - 0x10, 0x31, 0x31, 0x4e, 0x24, 0x6e, 0x8a, 0x97, 0x1d, 0x60, 0x5e, 0x79, 0x98, 0x41}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15919}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13210}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16229}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 32}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops1}, .v = {5, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7126}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops4}}}, - }; - - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24249, 6, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 18033 [("\181\STX\205 B\134&\195T\EOT\226\245Is\192\233\ETBM\ENQ\150\240\161",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropMaximumQoS -// 84,PropRequestProblemInformation 130,PropRetainAvailable 128,PropAuthenticationMethod -// "\196\133\ETB\SO\225\&9d\226\251\210-\210$",PropSubscriptionIdentifierAvailable 223,PropWillDelayInterval -// 11937,PropServerKeepAlive 5382,PropSubscriptionIdentifier 8,PropWildcardSubscriptionAvailable -// 247,PropMessageExpiryInterval 19198,PropAuthenticationData -// "\200\157p\189e\ENQ\197DJa]\244-?",PropMessageExpiryInterval 9872,PropAuthenticationMethod -// "s\215\231\243m\159\&9~\190\139 \ACK",PropPayloadFormatIndicator 197,PropReceiveMaximum 26191,PropServerKeepAlive -// 20944,PropSubscriptionIdentifier 14,PropMaximumPacketSize 22810,PropWildcardSubscriptionAvailable 26,PropContentType -// "\177I",PropResponseTopic -// "\DLE\b\147\161\SOH\213\183\228qi\129\FS\160\149\CAN\224\v\177\r\NUL4t",PropWillDelayInterval -// 10334,PropPayloadFormatIndicator 136,PropSubscriptionIdentifierAvailable 203,PropUserProperty -// "\247h%\SOH\244\150{\163\&5Ji;7ey\161;s%!\231\193D\215\232\129\214\181" -// "&\148\155\CAN\242ap\SOl\137\STX\191B\204\135\199U\EOT\148\RS\174",PropSubscriptionIdentifierAvailable 192] -TEST(Subscribe5QCTest, Encode7) { - uint8_t pkt[] = { - 0x82, 0xdb, 0x1, 0x46, 0x71, 0xbe, 0x1, 0x24, 0x54, 0x17, 0x82, 0x25, 0x80, 0x15, 0x0, 0xd, 0xc4, 0x85, 0x17, - 0xe, 0xe1, 0x39, 0x64, 0xe2, 0xfb, 0xd2, 0x2d, 0xd2, 0x24, 0x29, 0xdf, 0x18, 0x0, 0x0, 0x2e, 0xa1, 0x13, 0x15, - 0x6, 0xb, 0x8, 0x28, 0xf7, 0x2, 0x0, 0x0, 0x4a, 0xfe, 0x16, 0x0, 0xe, 0xc8, 0x9d, 0x70, 0xbd, 0x65, 0x5, - 0xc5, 0x44, 0x4a, 0x61, 0x5d, 0xf4, 0x2d, 0x3f, 0x2, 0x0, 0x0, 0x26, 0x90, 0x15, 0x0, 0xc, 0x73, 0xd7, 0xe7, - 0xf3, 0x6d, 0x9f, 0x39, 0x7e, 0xbe, 0x8b, 0x20, 0x6, 0x1, 0xc5, 0x21, 0x66, 0x4f, 0x13, 0x51, 0xd0, 0xb, 0xe, - 0x27, 0x0, 0x0, 0x59, 0x1a, 0x28, 0x1a, 0x3, 0x0, 0x2, 0xb1, 0x49, 0x8, 0x0, 0x16, 0x10, 0x8, 0x93, 0xa1, - 0x1, 0xd5, 0xb7, 0xe4, 0x71, 0x69, 0x81, 0x1c, 0xa0, 0x95, 0x18, 0xe0, 0xb, 0xb1, 0xd, 0x0, 0x34, 0x74, 0x18, - 0x0, 0x0, 0x28, 0x5e, 0x1, 0x88, 0x29, 0xcb, 0x26, 0x0, 0x1c, 0xf7, 0x68, 0x25, 0x1, 0xf4, 0x96, 0x7b, 0xa3, - 0x35, 0x4a, 0x69, 0x3b, 0x37, 0x65, 0x79, 0xa1, 0x3b, 0x73, 0x25, 0x21, 0xe7, 0xc1, 0x44, 0xd7, 0xe8, 0x81, 0xd6, - 0xb5, 0x0, 0x15, 0x26, 0x94, 0x9b, 0x18, 0xf2, 0x61, 0x70, 0xe, 0x6c, 0x89, 0x2, 0xbf, 0x42, 0xcc, 0x87, 0xc7, - 0x55, 0x4, 0x94, 0x1e, 0xae, 0x29, 0xc0, 0x0, 0x16, 0xb5, 0x2, 0xcd, 0x20, 0x42, 0x86, 0x26, 0xc3, 0x54, 0x4, - 0xe2, 0xf5, 0x49, 0x73, 0xc0, 0xe9, 0x17, 0x4d, 0x5, 0x96, 0xf0, 0xa1, 0x4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xb5, 0x2, 0xcd, 0x20, 0x42, 0x86, 0x26, 0xc3, 0x54, 0x4, 0xe2, - 0xf5, 0x49, 0x73, 0xc0, 0xe9, 0x17, 0x4d, 0x5, 0x96, 0xf0, 0xa1}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - uint8_t bytesprops0[] = {0xc4, 0x85, 0x17, 0xe, 0xe1, 0x39, 0x64, 0xe2, 0xfb, 0xd2, 0x2d, 0xd2, 0x24}; - uint8_t bytesprops1[] = {0xc8, 0x9d, 0x70, 0xbd, 0x65, 0x5, 0xc5, 0x44, 0x4a, 0x61, 0x5d, 0xf4, 0x2d, 0x3f}; - uint8_t bytesprops2[] = {0x73, 0xd7, 0xe7, 0xf3, 0x6d, 0x9f, 0x39, 0x7e, 0xbe, 0x8b, 0x20, 0x6}; - uint8_t bytesprops3[] = {0xb1, 0x49}; - uint8_t bytesprops4[] = {0x10, 0x8, 0x93, 0xa1, 0x1, 0xd5, 0xb7, 0xe4, 0x71, 0x69, 0x81, - 0x1c, 0xa0, 0x95, 0x18, 0xe0, 0xb, 0xb1, 0xd, 0x0, 0x34, 0x74}; - uint8_t bytesprops6[] = {0x26, 0x94, 0x9b, 0x18, 0xf2, 0x61, 0x70, 0xe, 0x6c, 0x89, 0x2, - 0xbf, 0x42, 0xcc, 0x87, 0xc7, 0x55, 0x4, 0x94, 0x1e, 0xae}; - uint8_t bytesprops5[] = {0xf7, 0x68, 0x25, 0x1, 0xf4, 0x96, 0x7b, 0xa3, 0x35, 0x4a, 0x69, 0x3b, 0x37, 0x65, - 0x79, 0xa1, 0x3b, 0x73, 0x25, 0x21, 0xe7, 0xc1, 0x44, 0xd7, 0xe8, 0x81, 0xd6, 0xb5}; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + uint8_t bytesprops0[] = {0x9, 0xbf, 0x5f, 0xd8, 0x1e, 0x1f, 0x37, 0x2e, 0x1a, 0x20, 0x2c, + 0xd0, 0x99, 0x84, 0xde, 0xcc, 0xc5, 0xc5, 0xb0, 0xe9, 0xdb}; + uint8_t bytesprops1[] = {0xbf, 0x64, 0x9e, 0x66, 0xde, 0x51, 0xc4, 0xfe, 0xc2, 0x60, 0x3a, 0xe9, 0xc, + 0x85, 0xbf, 0x61, 0x8d, 0xd, 0xf9, 0xaf, 0xa4, 0xe1, 0x73, 0x6f, 0xe5, 0xbc}; + uint8_t bytesprops2[] = {0x6d, 0x39, 0x60, 0xf9, 0x85, 0xd5, 0x95, 0xbe, 0x41, 0xaa, 0x47}; + uint8_t bytesprops3[] = {0xde, 0xa4, 0x49, 0x8c, 0xcf, 0x67, 0x6e, 0xce, 0xb7, 0x12, 0x0, 0x33, 0x30, 0xfc, 0x80, + 0xb9, 0x1e, 0xbf, 0xd6, 0x5f, 0xa0, 0xb4, 0x37, 0xa4, 0x51, 0x75, 0x46, 0x33, 0x1c}; + uint8_t bytesprops4[] = {0xbe, 0xad, 0x6a}; + uint8_t bytesprops5[] = {0xe4, 0xb3, 0x19, 0x9f, 0xad, 0x25, 0x77, 0x8f, 0xef, 0x29, 0xe9, 0xf0, 0x32, 0xc4}; + uint8_t bytesprops6[] = {0xbb, 0x4c}; + uint8_t bytesprops7[] = {0xea, 0x78, 0xc, 0x21, 0xd1, 0x12, 0xc6, 0xa6, 0xa9}; + uint8_t bytesprops8[] = {0x5e, 0x8d, 0x35, 0xe5, 0x85, 0x42, 0xfe, 0x5d, 0x7b, 0xe6, 0x6f}; + uint8_t bytesprops9[] = {0}; + uint8_t bytesprops10[] = {0x86, 0x1f, 0x38, 0x35, 0xcd, 0x3f, 0xe1, 0xa7, 0xea, 0x7, + 0x63, 0x5a, 0x4e, 0xb3, 0x88, 0x15, 0xdd, 0x96, 0x2d}; + uint8_t bytesprops11[] = {0xc9, 0x7c, 0xae, 0x75, 0x5f, 0x19}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11937}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5382}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19198}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9872}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26191}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20944}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 14}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22810}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10334}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops5}, .v = {21, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30114}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29813}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30422}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32593}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20318}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2052}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10929}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18033, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3081, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22392 -// [("G\SO_\r\DLE\244.\250W\133;\154\229\255\200(\128({\RS\DEL\205\&3\233\NAK\158\197\191l",SubOptions {_retainHandling -// = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\233\157F\ACK\128m\130\216\142\NUL\197\184\&8\243\248\SIvz\CAN\229w\US\EM\159\141",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\146\&0m\DC3J\242\217\STXV\251\177G\241m?\246\228",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\t\190\224d\180\148N\147{\128\156",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] -// [PropRetainAvailable 105,PropSubscriptionIdentifier 12,PropAssignedClientIdentifier -// "\149\161{\161n\129\147\142\198",PropAuthenticationMethod -// "\ETXU]n%\ETX\DC2\238'\140R\211])>\ACK\146{e\162\147+A\142\153",PropWillDelayInterval 1145,PropReasonString -// "\206\149\GS\232\&4\247\&9\251\FS\210\190\DC2\255\145\156\f\251\233K",PropAssignedClientIdentifier -// "\f\196\248\244\ACK",PropMessageExpiryInterval 30990,PropSubscriptionIdentifierAvailable 170,PropUserProperty -// "\183\&5\171\213)\200\214\b2OqE\236l\173\154\198X\236\191^\201\182\153\142\238\SYNe\145" -// "Nv\132\199S\234s\f\162ts\186\198f\242\a\183\SO\SO 1\n\182",PropResponseTopic -// "&\245\218\227R\v\246Jw}\182\143O\208O\186%\170\197\236\238",PropResponseInformation -// "\ETB6\187\EOT\188\159c\209Pm)e\185\160\198\214Q\n\ETB\EOTb\am\227\FS,\224\&5",PropServerReference -// "\f\190\148X\243\178mC\136",PropServerKeepAlive 3868,PropContentType "\227\141\154\US\235 -// \224~\153",PropMessageExpiryInterval 14518,PropAssignedClientIdentifier -// "\151x\165\132Z\217\tU0x,\ETX\163\154",PropAuthenticationData -// "\157\146[\237y\154\156\b\221f\178\181\136w\232&\193\r"] -TEST(Subscribe5QCTest, Encode8) { - uint8_t pkt[] = { - 0x82, 0xee, 0x2, 0x57, 0x78, 0x8c, 0x2, 0x25, 0x69, 0xb, 0xc, 0x12, 0x0, 0x9, 0x95, 0xa1, 0x7b, 0xa1, 0x6e, - 0x81, 0x93, 0x8e, 0xc6, 0x15, 0x0, 0x19, 0x3, 0x55, 0x5d, 0x6e, 0x25, 0x3, 0x12, 0xee, 0x27, 0x8c, 0x52, 0xd3, - 0x5d, 0x29, 0x3e, 0x6, 0x92, 0x7b, 0x65, 0xa2, 0x93, 0x2b, 0x41, 0x8e, 0x99, 0x18, 0x0, 0x0, 0x4, 0x79, 0x1f, - 0x0, 0x13, 0xce, 0x95, 0x1d, 0xe8, 0x34, 0xf7, 0x39, 0xfb, 0x1c, 0xd2, 0xbe, 0x12, 0xff, 0x91, 0x9c, 0xc, 0xfb, - 0xe9, 0x4b, 0x12, 0x0, 0x5, 0xc, 0xc4, 0xf8, 0xf4, 0x6, 0x2, 0x0, 0x0, 0x79, 0xe, 0x29, 0xaa, 0x26, 0x0, - 0x1d, 0xb7, 0x35, 0xab, 0xd5, 0x29, 0xc8, 0xd6, 0x8, 0x32, 0x4f, 0x71, 0x45, 0xec, 0x6c, 0xad, 0x9a, 0xc6, 0x58, - 0xec, 0xbf, 0x5e, 0xc9, 0xb6, 0x99, 0x8e, 0xee, 0x16, 0x65, 0x91, 0x0, 0x17, 0x4e, 0x76, 0x84, 0xc7, 0x53, 0xea, - 0x73, 0xc, 0xa2, 0x74, 0x73, 0xba, 0xc6, 0x66, 0xf2, 0x7, 0xb7, 0xe, 0xe, 0x20, 0x31, 0xa, 0xb6, 0x8, 0x0, - 0x15, 0x26, 0xf5, 0xda, 0xe3, 0x52, 0xb, 0xf6, 0x4a, 0x77, 0x7d, 0xb6, 0x8f, 0x4f, 0xd0, 0x4f, 0xba, 0x25, 0xaa, - 0xc5, 0xec, 0xee, 0x1a, 0x0, 0x1c, 0x17, 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, 0x4e, 0x93, 0x7b, 0x80, 0x9c, 0xd}; +// SubscribeRequest 26803 [("G0\203x\EOT9\163\234\244~\250\213\DEL\247z'\226",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("m,s\SO\194G\181\182\&9\128N\200\150;gq9\182u?e\\\252\219\SO\133\DC2\146\242W",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\129\156\160\NAK\194\&8\202\196Y +// \172\147\213\175\141*\168\ETB\195y\147",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("iM\SYN\223q\DEL@J\183\233\132\254[*",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("jX\ra\242\DC1\ETB@E\181\181\252R",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\224\GSH\ESCU\212",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropReceiveMaximum 7683,PropMessageExpiryInterval +// 31743,PropAuthenticationMethod "\STXL\254\223\133\190H\217\228\f",PropServerReference +// "^\244\132\253?e\ENQ\\",PropSessionExpiryInterval 16241,PropResponseTopic +// "\246\137\225H\161r\219\203\242\149\ETB?\173e2\219\130\192\&7"] +TEST(Subscribe5QCTest, Encode5) { + uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x68, 0xb3, 0x3b, 0x21, 0x1e, 0x3, 0x2, 0x0, 0x0, 0x7b, 0xff, 0x15, 0x0, 0xa, + 0x2, 0x4c, 0xfe, 0xdf, 0x85, 0xbe, 0x48, 0xd9, 0xe4, 0xc, 0x1c, 0x0, 0x8, 0x5e, 0xf4, 0x84, 0xfd, + 0x3f, 0x65, 0x5, 0x5c, 0x11, 0x0, 0x0, 0x3f, 0x71, 0x8, 0x0, 0x13, 0xf6, 0x89, 0xe1, 0x48, 0xa1, + 0x72, 0xdb, 0xcb, 0xf2, 0x95, 0x17, 0x3f, 0xad, 0x65, 0x32, 0xdb, 0x82, 0xc0, 0x37, 0x0, 0x11, 0x47, + 0x30, 0xcb, 0x78, 0x4, 0x39, 0xa3, 0xea, 0xf4, 0x7e, 0xfa, 0xd5, 0x7f, 0xf7, 0x7a, 0x27, 0xe2, 0x12, + 0x0, 0x1e, 0x6d, 0x2c, 0x73, 0xe, 0xc2, 0x47, 0xb5, 0xb6, 0x39, 0x80, 0x4e, 0xc8, 0x96, 0x3b, 0x67, + 0x71, 0x39, 0xb6, 0x75, 0x3f, 0x65, 0x5c, 0xfc, 0xdb, 0xe, 0x85, 0x12, 0x92, 0xf2, 0x57, 0x12, 0x0, + 0x15, 0x81, 0x9c, 0xa0, 0x15, 0xc2, 0x38, 0xca, 0xc4, 0x59, 0x20, 0xac, 0x93, 0xd5, 0xaf, 0x8d, 0x2a, + 0xa8, 0x17, 0xc3, 0x79, 0x93, 0x11, 0x0, 0xe, 0x69, 0x4d, 0x16, 0xdf, 0x71, 0x7f, 0x40, 0x4a, 0xb7, + 0xe9, 0x84, 0xfe, 0x5b, 0x2a, 0x1, 0x0, 0xd, 0x6a, 0x58, 0xd, 0x61, 0xf2, 0x11, 0x17, 0x40, 0x45, + 0xb5, 0xb5, 0xfc, 0x52, 0x21, 0x0, 0x6, 0xe0, 0x1d, 0x48, 0x1b, 0x55, 0xd4, 0x26}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x47, 0xe, 0x5f, 0xd, 0x10, 0xf4, 0x2e, 0xfa, 0x57, 0x85, - 0x3b, 0x9a, 0xe5, 0xff, 0xc8, 0x28, 0x80, 0x28, 0x7b, 0x1e, - 0x7f, 0xcd, 0x33, 0xe9, 0x15, 0x9e, 0xc5, 0xbf, 0x6c}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x47, 0x30, 0xcb, 0x78, 0x4, 0x39, 0xa3, 0xea, 0xf4, + 0x7e, 0xfa, 0xd5, 0x7f, 0xf7, 0x7a, 0x27, 0xe2}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe9, 0x9d, 0x46, 0x6, 0x80, 0x6d, 0x82, 0xd8, 0x8e, 0x0, 0xc5, 0xb8, 0x38, - 0xf3, 0xf8, 0xf, 0x76, 0x7a, 0x18, 0xe5, 0x77, 0x1f, 0x19, 0x9f, 0x8d}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6d, 0x2c, 0x73, 0xe, 0xc2, 0x47, 0xb5, 0xb6, 0x39, 0x80, + 0x4e, 0xc8, 0x96, 0x3b, 0x67, 0x71, 0x39, 0xb6, 0x75, 0x3f, + 0x65, 0x5c, 0xfc, 0xdb, 0xe, 0x85, 0x12, 0x92, 0xf2, 0x57}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x92, 0x30, 0x6d, 0x13, 0x4a, 0xf2, 0xd9, 0x2, 0x56, - 0xfb, 0xb1, 0x47, 0xf1, 0x6d, 0x3f, 0xf6, 0xe4}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x81, 0x9c, 0xa0, 0x15, 0xc2, 0x38, 0xca, 0xc4, 0x59, 0x20, 0xac, + 0x93, 0xd5, 0xaf, 0x8d, 0x2a, 0xa8, 0x17, 0xc3, 0x79, 0x93}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9, 0xbe, 0xe0, 0x64, 0xb4, 0x94, 0x4e, 0x93, 0x7b, 0x80, 0x9c}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x69, 0x4d, 0x16, 0xdf, 0x71, 0x7f, 0x40, + 0x4a, 0xb7, 0xe9, 0x84, 0xfe, 0x5b, 0x2a}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + uint8_t topic_filter_s4_bytes[] = {0x6a, 0x58, 0xd, 0x61, 0xf2, 0x11, 0x17, 0x40, 0x45, 0xb5, 0xb5, 0xfc, 0x52}; + lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe0, 0x1d, 0x48, 0x1b, 0x55, 0xd4}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - uint8_t bytesprops0[] = {0x95, 0xa1, 0x7b, 0xa1, 0x6e, 0x81, 0x93, 0x8e, 0xc6}; - uint8_t bytesprops1[] = {0x3, 0x55, 0x5d, 0x6e, 0x25, 0x3, 0x12, 0xee, 0x27, 0x8c, 0x52, 0xd3, 0x5d, - 0x29, 0x3e, 0x6, 0x92, 0x7b, 0x65, 0xa2, 0x93, 0x2b, 0x41, 0x8e, 0x99}; - uint8_t bytesprops2[] = {0xce, 0x95, 0x1d, 0xe8, 0x34, 0xf7, 0x39, 0xfb, 0x1c, 0xd2, - 0xbe, 0x12, 0xff, 0x91, 0x9c, 0xc, 0xfb, 0xe9, 0x4b}; - uint8_t bytesprops3[] = {0xc, 0xc4, 0xf8, 0xf4, 0x6}; - uint8_t bytesprops5[] = {0x4e, 0x76, 0x84, 0xc7, 0x53, 0xea, 0x73, 0xc, 0xa2, 0x74, 0x73, 0xba, - 0xc6, 0x66, 0xf2, 0x7, 0xb7, 0xe, 0xe, 0x20, 0x31, 0xa, 0xb6}; - uint8_t bytesprops4[] = {0xb7, 0x35, 0xab, 0xd5, 0x29, 0xc8, 0xd6, 0x8, 0x32, 0x4f, 0x71, 0x45, 0xec, 0x6c, 0xad, - 0x9a, 0xc6, 0x58, 0xec, 0xbf, 0x5e, 0xc9, 0xb6, 0x99, 0x8e, 0xee, 0x16, 0x65, 0x91}; - uint8_t bytesprops6[] = {0x26, 0xf5, 0xda, 0xe3, 0x52, 0xb, 0xf6, 0x4a, 0x77, 0x7d, 0xb6, - 0x8f, 0x4f, 0xd0, 0x4f, 0xba, 0x25, 0xaa, 0xc5, 0xec, 0xee}; - uint8_t bytesprops7[] = {0x17, 0x36, 0xbb, 0x4, 0xbc, 0x9f, 0x63, 0xd1, 0x50, 0x6d, 0x29, 0x65, 0xb9, 0xa0, - 0xc6, 0xd6, 0x51, 0xa, 0x17, 0x4, 0x62, 0x7, 0x6d, 0xe3, 0x1c, 0x2c, 0xe0, 0x35}; - uint8_t bytesprops8[] = {0xc, 0xbe, 0x94, 0x58, 0xf3, 0xb2, 0x6d, 0x43, 0x88}; - uint8_t bytesprops9[] = {0xe3, 0x8d, 0x9a, 0x1f, 0xeb, 0x20, 0xe0, 0x7e, 0x99}; - uint8_t bytesprops10[] = {0x97, 0x78, 0xa5, 0x84, 0x5a, 0xd9, 0x9, 0x55, 0x30, 0x78, 0x2c, 0x3, 0xa3, 0x9a}; - uint8_t bytesprops11[] = {0x9d, 0x92, 0x5b, 0xed, 0x79, 0x9a, 0x9c, 0x8, 0xdd, - 0x66, 0xb2, 0xb5, 0x88, 0x77, 0xe8, 0x26, 0xc1, 0xd}; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + uint8_t bytesprops0[] = {0x2, 0x4c, 0xfe, 0xdf, 0x85, 0xbe, 0x48, 0xd9, 0xe4, 0xc}; + uint8_t bytesprops1[] = {0x5e, 0xf4, 0x84, 0xfd, 0x3f, 0x65, 0x5, 0x5c}; + uint8_t bytesprops2[] = {0xf6, 0x89, 0xe1, 0x48, 0xa1, 0x72, 0xdb, 0xcb, 0xf2, 0x95, + 0x17, 0x3f, 0xad, 0x65, 0x32, 0xdb, 0x82, 0xc0, 0x37}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1145}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30990}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {23, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3868}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14518}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7683}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31743}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16241}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22392, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26803, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26543 [("\249\201\SUB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS2}),("\219\159\230|\181\144-\SUB\144",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\220\152\146\130\197\251\SOH\226+",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\143\200\174\222\226\&4\142+",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS1}),("\145\228A\244\158\b\173fY&\220q\DC4\161\\\174\199\&7\172#",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\138\DC1\164\194\ETB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS2}),("C\139\178\210\217U(S\133\a",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("MU:H5\202\246\247!\NUL\169",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe5QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0x69, 0x67, 0xaf, 0x0, 0x0, 0x3, 0xf9, 0xc9, 0x1a, 0xe, 0x0, 0x9, 0xdb, 0x9f, 0xe6, - 0x7c, 0xb5, 0x90, 0x2d, 0x1a, 0x90, 0x9, 0x0, 0x9, 0xdc, 0x98, 0x92, 0x82, 0xc5, 0xfb, 0x1, - 0xe2, 0x2b, 0x19, 0x0, 0x0, 0x11, 0x0, 0x8, 0x8f, 0xc8, 0xae, 0xde, 0xe2, 0x34, 0x8e, 0x2b, - 0x9, 0x0, 0x14, 0x91, 0xe4, 0x41, 0xf4, 0x9e, 0x8, 0xad, 0x66, 0x59, 0x26, 0xdc, 0x71, 0x14, - 0xa1, 0x5c, 0xae, 0xc7, 0x37, 0xac, 0x23, 0x16, 0x0, 0x5, 0x8a, 0x11, 0xa4, 0xc2, 0x17, 0x6, - 0x0, 0xa, 0x43, 0x8b, 0xb2, 0xd2, 0xd9, 0x55, 0x28, 0x53, 0x85, 0x7, 0x9, 0x0, 0xb, 0x4d, - 0x55, 0x3a, 0x48, 0x35, 0xca, 0xf6, 0xf7, 0x21, 0x0, 0xa9, 0x8}; +// SubscribeRequest 11145 [("\164AU\201Ck\ACK\SYN_G\244\236M\230\204",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] +// [PropRetainAvailable 101,PropContentType "&\\\165",PropMaximumPacketSize 20497,PropMessageExpiryInterval +// 18487,PropServerReference "c\228\200\129\177n\NUL\168A\195\249\232\239\171\148\154",PropRetainAvailable +// 246,PropMessageExpiryInterval 3316,PropResponseTopic "\"\186",PropPayloadFormatIndicator 25,PropTopicAliasMaximum +// 6042,PropResponseInformation "\149eE\137\222\&0\202\143\DC1C\234\157|[\249\178?",PropMessageExpiryInterval +// 22525,PropResponseInformation "\197\250[\230\a\242\180R\186\163\170\240\247t\187\238\DEL +// t\"\164\156+\130\164",PropRequestResponseInformation 170] +TEST(Subscribe5QCTest, Enc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e, 0xd7, 0x20, 0xca, 0x45, 0x58, 0x4, 0xcb, 0x87, 0x14, 0x0, 0x1, 0x19, 0x1c, + 0x0, 0xe, 0x70, 0x3c, 0x95, 0xb5, 0x16, 0xeb, 0x62, 0x3c, 0x4e, 0xf2, 0xcb, 0x70, 0x53, 0xad, 0x1c, 0x0, + 0x1d, 0xfa, 0x5, 0xc2, 0xa5, 0x99, 0x3b, 0x97, 0xad, 0x8f, 0xdc, 0x7a, 0xaf, 0x6e, 0xa8, 0x36, 0xbb, 0xe8, + 0xf, 0x99, 0x84, 0x47, 0xbd, 0x1a, 0xab, 0x76, 0xf7, 0xb2, 0x57, 0xdb, 0x19, 0x0, 0x1c, 0xb5, 0xd8, 0xd6, + 0x65, 0xe1, 0x30, 0x23, 0x5d, 0xce, 0xf0, 0x37, 0xc7, 0x3, 0x85, 0x84, 0x94, 0xd8, 0x37, 0x63, 0x3b, 0x49, + 0x1f, 0xd4, 0x4, 0x1f, 0xda, 0x75, 0xb2, 0x6, 0x0, 0xf, 0x7a, 0x89, 0x46, 0x4c, 0x6d, 0x30, 0x37, 0x3d, + 0xe6, 0x46, 0xcd, 0xf2, 0xd, 0xa4, 0xdd, 0x21, 0x0, 0x19, 0xbe, 0xb5, 0x60, 0x82, 0xea, 0xbb, 0xb0, 0x46, + 0xc1, 0x95, 0xf2, 0xdf, 0x37, 0x82, 0xa7, 0x3e, 0x6, 0x16, 0x5f, 0x47, 0xf4, 0xec, 0x4d, 0xe6, 0xcc, 0x18}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xf9, 0xc9, 0x1a}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xbb, 0xc8, 0x9c, 0x21, 0x9e, 0xc, 0x34, 0x2, 0x0, 0xac, 0x5, 0xf4, 0x7e, 0xd0, + 0xac, 0x42, 0x13, 0x29, 0x91, 0x43, 0x31, 0xa6, 0x6d, 0xd0, 0xaf, 0xfe, 0x54}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xdb, 0x9f, 0xe6, 0x7c, 0xb5, 0x90, 0x2d, 0x1a, 0x90}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x11, 0x7c, 0x18, 0xdb, 0x13, 0x8f, 0xf2, 0x5, 0x14, 0x56, + 0x18, 0x88, 0x88, 0x6f, 0xe, 0x1b, 0x13, 0x2f, 0x9e, 0x3b}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdc, 0x98, 0x92, 0x82, 0xc5, 0xfb, 0x1, 0xe2, 0x2b}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8c, 0x6e, 0x95, 0x67, 0x50, 0xa5, 0x85, 0x43, 0xb7, 0x8c, 0x90, 0xc3, + 0x49, 0xd, 0x1e, 0xd7, 0x20, 0xca, 0x45, 0x58, 0x4, 0xcb, 0x87}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x19}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8f, 0xc8, 0xae, 0xde, 0xe2, 0x34, 0x8e, 0x2b}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x70, 0x3c, 0x95, 0xb5, 0x16, 0xeb, 0x62, + 0x3c, 0x4e, 0xf2, 0xcb, 0x70, 0x53, 0xad}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x91, 0xe4, 0x41, 0xf4, 0x9e, 0x8, 0xad, 0x66, 0x59, 0x26, - 0xdc, 0x71, 0x14, 0xa1, 0x5c, 0xae, 0xc7, 0x37, 0xac, 0x23}; - lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xfa, 0x5, 0xc2, 0xa5, 0x99, 0x3b, 0x97, 0xad, 0x8f, 0xdc, + 0x7a, 0xaf, 0x6e, 0xa8, 0x36, 0xbb, 0xe8, 0xf, 0x99, 0x84, + 0x47, 0xbd, 0x1a, 0xab, 0x76, 0xf7, 0xb2, 0x57, 0xdb}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8a, 0x11, 0xa4, 0xc2, 0x17}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb5, 0xd8, 0xd6, 0x65, 0xe1, 0x30, 0x23, 0x5d, 0xce, 0xf0, + 0x37, 0xc7, 0x3, 0x85, 0x84, 0x94, 0xd8, 0x37, 0x63, 0x3b, + 0x49, 0x1f, 0xd4, 0x4, 0x1f, 0xda, 0x75, 0xb2}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x43, 0x8b, 0xb2, 0xd2, 0xd9, 0x55, 0x28, 0x53, 0x85, 0x7}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x7a, 0x89, 0x46, 0x4c, 0x6d, 0x30, 0x37, 0x3d, + 0xe6, 0x46, 0xcd, 0xf2, 0xd, 0xa4, 0xdd}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x4d, 0x55, 0x3a, 0x48, 0x35, 0xca, 0xf6, 0xf7, 0x21, 0x0, 0xa9}; - lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xbe, 0xb5, 0x60, 0x82, 0xea, 0xbb, 0xb0, 0x46, 0xc1, 0x95, 0xf2, 0xdf, 0x37, + 0x82, 0xa7, 0x3e, 0x6, 0x16, 0x5f, 0x47, 0xf4, 0xec, 0x4d, 0xe6, 0xcc}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = true; sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[8].retain_as_published = true; sub_opts[8].no_local = false; + uint8_t bytesprops0[] = {0x26, 0x5c, 0xa5}; + uint8_t bytesprops1[] = {0x63, 0xe4, 0xc8, 0x81, 0xb1, 0x6e, 0x0, 0xa8, + 0x41, 0xc3, 0xf9, 0xe8, 0xef, 0xab, 0x94, 0x9a}; + uint8_t bytesprops2[] = {0x22, 0xba}; + uint8_t bytesprops3[] = {0x95, 0x65, 0x45, 0x89, 0xde, 0x30, 0xca, 0x8f, 0x11, + 0x43, 0xea, 0x9d, 0x7c, 0x5b, 0xf9, 0xb2, 0x3f}; + uint8_t bytesprops4[] = {0xc5, 0xfa, 0x5b, 0xe6, 0x7, 0xf2, 0xb4, 0x52, 0xba, 0xa3, 0xaa, 0xf0, 0xf7, + 0x74, 0xbb, 0xee, 0x7f, 0x20, 0x74, 0x22, 0xa4, 0x9c, 0x2b, 0x82, 0xa4}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20497}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18487}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3316}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6042}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22525}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 170}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26543, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31044, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14708 [("\NULK\203\169*aQ\217\USt\161",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("1\DLE\243[3\NUL\FS\CAN\220\179\247u\159Kf\236\149\FS\231\156*w\170",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable -// 49,PropUserProperty "\b\DC4\193\219<\164\227l" "u\184N\223\&9\166\246\139P\139J\233\210\ny"] -TEST(Subscribe5QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0x49, 0x39, 0x74, 0x1e, 0x2a, 0x31, 0x26, 0x0, 0x8, 0x8, 0x14, 0xc1, 0xdb, 0x3c, - 0xa4, 0xe3, 0x6c, 0x0, 0xf, 0x75, 0xb8, 0x4e, 0xdf, 0x39, 0xa6, 0xf6, 0x8b, 0x50, 0x8b, - 0x4a, 0xe9, 0xd2, 0xa, 0x79, 0x0, 0xb, 0x0, 0x4b, 0xcb, 0xa9, 0x2a, 0x61, 0x51, 0xd9, - 0x1f, 0x74, 0xa1, 0x15, 0x0, 0x17, 0x31, 0x10, 0xf3, 0x5b, 0x33, 0x0, 0x1c, 0x18, 0xdc, - 0xb3, 0xf7, 0x75, 0x9f, 0x4b, 0x66, 0xec, 0x95, 0x1c, 0xe7, 0x9c, 0x2a, 0x77, 0xaa, 0xa}; +// SubscribeRequest 8770 [("\246\142&\218\222\148\226\196\212s~U\253",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\189\174\GS0\252J +// \229\&3J\f\139\225\150\221\DC4p\226\223",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\169Q;\220&z\151\248\&5\149\161\202h\ENQ\162\148\158\137b\203\f",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] +// [PropSessionExpiryInterval 9936,PropSessionExpiryInterval 30050,PropServerReference +// "\SUB|\201K\186(\FS\r\206\252\DC2\237\146Qw",PropWillDelayInterval 32549,PropReasonString +// "i\DC32\234\247\183",PropResponseTopic +// "[\238\247)\US\163\191\&3\202\245\198>\191t\aN'\229\148\176\ESC\202\SOH",PropUserProperty +// "f\222\236MO\EM71\132\198mB\241\177\178\ETB" +// "G\GS\252#v\237\198d\187\187r\187\162\152\&7\SOH+\225\ETX",PropRetainAvailable 171,PropRetainAvailable +// 209,PropTopicAlias 15467,PropTopicAliasMaximum 17442,PropResponseTopic +// "\219\132-\135\129#.\214\206\184i\238\DC3\130\220\US\168\248T\RSD\SYN\SUBB\185\SUB\135\129",PropAuthenticationData "W +// \218C\190\149\240",PropPayloadFormatIndicator 81,PropCorrelationData +// "\247\232^\221CdI./B",PropRequestProblemInformation 89,PropResponseInformation +// "\EM\138\225i\197\247\188u\196\NAK\"y\234\254o\GS\158\155\248\227\151\250n\142\255\195\SYN\135\181",PropMaximumQoS +// 163,PropPayloadFormatIndicator 45,PropServerReference +// "\SYN@\DLE\207\222\SOH\184\213\&33?&\t\159",PropSessionExpiryInterval 6115,PropServerReference +// "#N\SOH\ESC\SO\ETBbN\155\r[\173",PropWillDelayInterval 15590,PropSubscriptionIdentifierAvailable +// 72,PropReceiveMaximum 1371,PropUserProperty "7\DC1\204\177,\170IK\144\133\218`\156\223X\134\150\DELs\247:" +// "\192uN\191G\a\246\150\253\&9\192\SO\DC3\196\162\196\205]{\213g\148B#\177\224>\239t",PropMessageExpiryInterval +// 3198,PropReceiveMaximum 19723] +TEST(Subscribe5QCTest, Encode8) { + uint8_t pkt[] = { + 0x82, 0x84, 0x3, 0x22, 0x42, 0xc2, 0x2, 0x11, 0x0, 0x0, 0x26, 0xd0, 0x11, 0x0, 0x0, 0x75, 0x62, 0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uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x0, 0x4b, 0xcb, 0xa9, 0x2a, 0x61, 0x51, 0xd9, 0x1f, 0x74, 0xa1}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xf6, 0x8e, 0x26, 0xda, 0xde, 0x94, 0xe2, 0xc4, 0xd4, 0x73, 0x7e, 0x55, 0xfd}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x31, 0x10, 0xf3, 0x5b, 0x33, 0x0, 0x1c, 0x18, 0xdc, 0xb3, 0xf7, 0x75, - 0x9f, 0x4b, 0x66, 0xec, 0x95, 0x1c, 0xe7, 0x9c, 0x2a, 0x77, 0xaa}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbd, 0xae, 0x1d, 0x30, 0xfc, 0x4a, 0x20, 0xe5, 0x33, 0x4a, + 0xc, 0x8b, 0xe1, 0x96, 0xdd, 0x14, 0x70, 0xe2, 0xdf}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s2_bytes[] = {0xa9, 0x51, 0x3b, 0xdc, 0x26, 0x7a, 0x97, 0xf8, 0x35, 0x95, 0xa1, + 0xca, 0x68, 0x5, 0xa2, 0x94, 0x9e, 0x89, 0x62, 0xcb, 0xc}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; + sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - uint8_t bytesprops1[] = {0x75, 0xb8, 0x4e, 0xdf, 0x39, 0xa6, 0xf6, 0x8b, 0x50, 0x8b, 0x4a, 0xe9, 0xd2, 0xa, 0x79}; - uint8_t bytesprops0[] = {0x8, 0x14, 0xc1, 0xdb, 0x3c, 0xa4, 0xe3, 0x6c}; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + uint8_t bytesprops0[] = {0x1a, 0x7c, 0xc9, 0x4b, 0xba, 0x28, 0x1c, 0xd, 0xce, 0xfc, 0x12, 0xed, 0x92, 0x51, 0x77}; + uint8_t bytesprops1[] = {0x69, 0x13, 0x32, 0xea, 0xf7, 0xb7}; + uint8_t bytesprops2[] = {0x5b, 0xee, 0xf7, 0x29, 0x1f, 0xa3, 0xbf, 0x33, 0xca, 0xf5, 0xc6, 0x3e, + 0xbf, 0x74, 0x7, 0x4e, 0x27, 0xe5, 0x94, 0xb0, 0x1b, 0xca, 0x1}; + uint8_t bytesprops4[] = {0x47, 0x1d, 0xfc, 0x23, 0x76, 0xed, 0xc6, 0x64, 0xbb, 0xbb, + 0x72, 0xbb, 0xa2, 0x98, 0x37, 0x1, 0x2b, 0xe1, 0x3}; + uint8_t bytesprops3[] = {0x66, 0xde, 0xec, 0x4d, 0x4f, 0x19, 0x37, 0x31, + 0x84, 0xc6, 0x6d, 0x42, 0xf1, 0xb1, 0xb2, 0x17}; + uint8_t bytesprops5[] = {0xdb, 0x84, 0x2d, 0x87, 0x81, 0x23, 0x2e, 0xd6, 0xce, 0xb8, 0x69, 0xee, 0x13, 0x82, + 0xdc, 0x1f, 0xa8, 0xf8, 0x54, 0x1e, 0x44, 0x16, 0x1a, 0x42, 0xb9, 0x1a, 0x87, 0x81}; + uint8_t bytesprops6[] = {0x57, 0x20, 0xda, 0x43, 0xbe, 0x95, 0xf0}; + uint8_t bytesprops7[] = {0xf7, 0xe8, 0x5e, 0xdd, 0x43, 0x64, 0x49, 0x2e, 0x2f, 0x42}; + uint8_t bytesprops8[] = {0x19, 0x8a, 0xe1, 0x69, 0xc5, 0xf7, 0xbc, 0x75, 0xc4, 0x15, 0x22, 0x79, 0xea, 0xfe, 0x6f, + 0x1d, 0x9e, 0x9b, 0xf8, 0xe3, 0x97, 0xfa, 0x6e, 0x8e, 0xff, 0xc3, 0x16, 0x87, 0xb5}; + uint8_t bytesprops9[] = {0x16, 0x40, 0x10, 0xcf, 0xde, 0x1, 0xb8, 0xd5, 0x33, 0x33, 0x3f, 0x26, 0x9, 0x9f}; + uint8_t bytesprops10[] = {0x23, 0x4e, 0x1, 0x1b, 0xe, 0x17, 0x62, 0x4e, 0x9b, 0xd, 0x5b, 0xad}; + uint8_t bytesprops12[] = {0xc0, 0x75, 0x4e, 0xbf, 0x47, 0x7, 0xf6, 0x96, 0xfd, 0x39, 0xc0, 0xe, 0x13, 0xc4, 0xa2, + 0xc4, 0xcd, 0x5d, 0x7b, 0xd5, 0x67, 0x94, 0x42, 0x23, 0xb1, 0xe0, 0x3e, 0xef, 0x74}; + uint8_t bytesprops11[] = {0x37, 0x11, 0xcc, 0xb1, 0x2c, 0xaa, 0x49, 0x4b, 0x90, 0x85, 0xda, + 0x60, 0x9c, 0xdf, 0x58, 0x86, 0x96, 0x7f, 0x73, 0xf7, 0x3a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {15, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9936}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30050}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32549}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {19, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15467}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17442}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6115}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15590}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1371}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {21, (char*)&bytesprops11}, .v = {29, (char*)&bytesprops12}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3198}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19723}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14708, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8770, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 24735 [("I\184\193",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS2}),("C\231x)\"5\EOT\146\158\NAK\181,",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\251\n(!k\205\193u\208<\205g.\223Q\US\187[\232\\\206\DLE\148\202",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),(")",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("_\204\209\225{\194\165\&4\222'\DLE\217\157Vu6G7\181\189\DC3)q",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("_6\149\215\&3\ENQ\133\244<\b!",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS1})] [PropResponseTopic -// "`eE\153\SUBC\179\SYN\203\221\CAN\209\t\ACK",PropSharedSubscriptionAvailable 132,PropTopicAliasMaximum -// 3544,PropUserProperty "\189\234X\244\ETB\192\216" "",PropSubscriptionIdentifier 4,PropSessionExpiryInterval -// 7130,PropSessionExpiryInterval 22723,PropAuthenticationData ":\GSnz\203iH\213\136\159",PropRetainAvailable -// 210,PropTopicAlias 27169,PropSubscriptionIdentifier 10,PropResponseTopic -// "\148\US\206\ETB\251\154o\244\168\150p\199r\196\185-\178\253\&3\a\196P\r \253\220\a\SOH\192"] -TEST(Subscribe5QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0xc1, 0x1, 0x60, 0x9f, 0x62, 0x8, 0x0, 0xe, 0x60, 0x65, 0x45, 0x99, 0x1a, 0x43, 0xb3, 0x16, - 0xcb, 0xdd, 0x18, 0xd1, 0x9, 0x6, 0x2a, 0x84, 0x22, 0xd, 0xd8, 0x26, 0x0, 0x7, 0xbd, 0xea, 0x58, - 0xf4, 0x17, 0xc0, 0xd8, 0x0, 0x0, 0xb, 0x4, 0x11, 0x0, 0x0, 0x1b, 0xda, 0x11, 0x0, 0x0, 0x58, - 0xc3, 0x16, 0x0, 0xa, 0x3a, 0x1d, 0x6e, 0x7a, 0xcb, 0x69, 0x48, 0xd5, 0x88, 0x9f, 0x25, 0xd2, 0x23, - 0x6a, 0x21, 0xb, 0xa, 0x8, 0x0, 0x1d, 0x94, 0x1f, 0xce, 0x17, 0xfb, 0x9a, 0x6f, 0xf4, 0xa8, 0x96, - 0x70, 0xc7, 0x72, 0xc4, 0xb9, 0x2d, 0xb2, 0xfd, 0x33, 0x7, 0xc4, 0x50, 0xd, 0x20, 0xfd, 0xdc, 0x7, - 0x1, 0xc0, 0x0, 0x3, 0x49, 0xb8, 0xc1, 0x6, 0x0, 0xc, 0x43, 0xe7, 0x78, 0x29, 0x22, 0x35, 0x4, - 0x92, 0x9e, 0x15, 0xb5, 0x2c, 0x26, 0x0, 0x18, 0xfb, 0xa, 0x28, 0x21, 0x6b, 0xcd, 0xc1, 0x75, 0xd0, - 0x3c, 0xcd, 0x67, 0x2e, 0xdf, 0x51, 0x1f, 0xbb, 0x5b, 0xe8, 0x5c, 0xce, 0x10, 0x94, 0xca, 0x19, 0x0, - 0x1, 0x29, 0xc, 0x0, 0x17, 0x5f, 0xcc, 0xd1, 0xe1, 0x7b, 0xc2, 0xa5, 0x34, 0xde, 0x27, 0x10, 0xd9, - 0x9d, 0x56, 0x75, 0x36, 0x47, 0x37, 0xb5, 0xbd, 0x13, 0x29, 0x71, 0x2e, 0x0, 0xb, 0x5f, 0x36, 0x95, - 0xd7, 0x33, 0x5, 0x85, 0xf4, 0x3c, 0x8, 0x21, 0x25}; +// SubscribeRequest 15580 +// [("\145\183m\232\217\188\204_\223\249\161\170\156\133T\234\233\159\235\&2H\175J\211\149j",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("]\151",SubOptions {_retainHandling +// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\238\244E\141\168\203\228s?\190\232J\139\182N\157",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAssignedClientIdentifier +// "O,\169e`v\182\133\201{\177\141L\192\157\142\128\243\145\133\163\140",PropRequestResponseInformation +// 235,PropSubscriptionIdentifier 23,PropAssignedClientIdentifier +// "\135\142\141\222\141\SYN\\2\139i0r<(\237\169F\249\220\233",PropReceiveMaximum 29989,PropMessageExpiryInterval +// 28800,PropAuthenticationData "\243\152",PropMessageExpiryInterval 17966,PropSharedSubscriptionAvailable +// 153,PropResponseTopic +// "\v\FS\131\164Ml\229z\207\FS\EM,\227\250L\164H\b0\170\162\b6\139\167\169\171",PropServerReference +// "\133\224\SOq\173\244\SI\v\ACKw\SOH{\226\164z",PropSubscriptionIdentifier 10,PropUserProperty +// "\253\156\217\b\208@\146" "\aY\EM\234",PropRequestProblemInformation 148,PropContentType +// "\237]{\ENQ3w\196\186",PropRequestResponseInformation 28,PropMaximumPacketSize 1417,PropWillDelayInterval +// 10215,PropMaximumPacketSize 8387,PropAssignedClientIdentifier "\162\&5",PropRequestResponseInformation +// 158,PropMessageExpiryInterval 8655,PropMaximumQoS 49,PropServerKeepAlive 9880,PropRequestResponseInformation +// 70,PropSubscriptionIdentifier 15,PropAuthenticationData +// ",o\155\&0\139\252IS\234N,=\179\&1p\v\193\155\&2\230",PropWillDelayInterval 1640,PropTopicAlias +// 21613,PropMessageExpiryInterval 10411] +TEST(Subscribe5QCTest, Encode9) { + uint8_t pkt[] = { + 0x82, 0x9a, 0x2, 0x3c, 0xdc, 0xe1, 0x1, 0x12, 0x0, 0x16, 0x4f, 0x2c, 0xa9, 0x65, 0x60, 0x76, 0xb6, 0x85, 0xc9, + 0x7b, 0xb1, 0x8d, 0x4c, 0xc0, 0x9d, 0x8e, 0x80, 0xf3, 0x91, 0x85, 0xa3, 0x8c, 0x19, 0xeb, 0xb, 0x17, 0x12, 0x0, + 0x14, 0x87, 0x8e, 0x8d, 0xde, 0x8d, 0x16, 0x5c, 0x32, 0x8b, 0x69, 0x30, 0x72, 0x3c, 0x28, 0xed, 0xa9, 0x46, 0xf9, + 0xdc, 0xe9, 0x21, 0x75, 0x25, 0x2, 0x0, 0x0, 0x70, 0x80, 0x16, 0x0, 0x2, 0xf3, 0x98, 0x2, 0x0, 0x0, 0x46, + 0x2e, 0x2a, 0x99, 0x8, 0x0, 0x1b, 0xb, 0x1c, 0x83, 0xa4, 0x4d, 0x6c, 0xe5, 0x7a, 0xcf, 0x1c, 0x19, 0x2c, 0xe3, + 0xfa, 0x4c, 0xa4, 0x48, 0x8, 0x30, 0xaa, 0xa2, 0x8, 0x36, 0x8b, 0xa7, 0xa9, 0xab, 0x1c, 0x0, 0xf, 0x85, 0xe0, + 0xe, 0x71, 0xad, 0xf4, 0xf, 0xb, 0x6, 0x77, 0x1, 0x7b, 0xe2, 0xa4, 0x7a, 0xb, 0xa, 0x26, 0x0, 0x7, 0xfd, + 0x9c, 0xd9, 0x8, 0xd0, 0x40, 0x92, 0x0, 0x4, 0x7, 0x59, 0x19, 0xea, 0x17, 0x94, 0x3, 0x0, 0x8, 0xed, 0x5d, + 0x7b, 0x5, 0x33, 0x77, 0xc4, 0xba, 0x19, 0x1c, 0x27, 0x0, 0x0, 0x5, 0x89, 0x18, 0x0, 0x0, 0x27, 0xe7, 0x27, + 0x0, 0x0, 0x20, 0xc3, 0x12, 0x0, 0x2, 0xa2, 0x35, 0x19, 0x9e, 0x2, 0x0, 0x0, 0x21, 0xcf, 0x24, 0x31, 0x13, + 0x26, 0x98, 0x19, 0x46, 0xb, 0xf, 0x16, 0x0, 0x14, 0x2c, 0x6f, 0x9b, 0x30, 0x8b, 0xfc, 0x49, 0x53, 0xea, 0x4e, + 0x2c, 0x3d, 0xb3, 0x31, 0x70, 0xb, 0xc1, 0x9b, 0x32, 0xe6, 0x18, 0x0, 0x0, 0x6, 0x68, 0x23, 0x54, 0x6d, 0x2, + 0x0, 0x0, 0x28, 0xab, 0x0, 0x1a, 0x91, 0xb7, 0x6d, 0xe8, 0xd9, 0xbc, 0xcc, 0x5f, 0xdf, 0xf9, 0xa1, 0xaa, 0x9c, + 0x85, 0x54, 0xea, 0xe9, 0x9f, 0xeb, 0x32, 0x48, 0xaf, 0x4a, 0xd3, 0x95, 0x6a, 0x8, 0x0, 0x2, 0x5d, 0x97, 0x1e, + 0x0, 0x10, 0xee, 0xf4, 0x45, 0x8d, 0xa8, 0xcb, 0xe4, 0x73, 0x3f, 0xbe, 0xe8, 0x4a, 0x8b, 0xb6, 0x4e, 0x9d, 0x20}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x49, 0xb8, 0xc1}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x91, 0xb7, 0x6d, 0xe8, 0xd9, 0xbc, 0xcc, 0x5f, 0xdf, 0xf9, 0xa1, 0xaa, 0x9c, + 0x85, 0x54, 0xea, 0xe9, 0x9f, 0xeb, 0x32, 0x48, 0xaf, 0x4a, 0xd3, 0x95, 0x6a}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x43, 0xe7, 0x78, 0x29, 0x22, 0x35, 0x4, 0x92, 0x9e, 0x15, 0xb5, 0x2c}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5d, 0x97}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfb, 0xa, 0x28, 0x21, 0x6b, 0xcd, 0xc1, 0x75, 0xd0, 0x3c, 0xcd, 0x67, - 0x2e, 0xdf, 0x51, 0x1f, 0xbb, 0x5b, 0xe8, 0x5c, 0xce, 0x10, 0x94, 0xca}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xee, 0xf4, 0x45, 0x8d, 0xa8, 0xcb, 0xe4, 0x73, + 0x3f, 0xbe, 0xe8, 0x4a, 0x8b, 0xb6, 0x4e, 0x9d}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x29}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5f, 0xcc, 0xd1, 0xe1, 0x7b, 0xc2, 0xa5, 0x34, 0xde, 0x27, 0x10, 0xd9, - 0x9d, 0x56, 0x75, 0x36, 0x47, 0x37, 0xb5, 0xbd, 0x13, 0x29, 0x71}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5f, 0x36, 0x95, 0xd7, 0x33, 0x5, 0x85, 0xf4, 0x3c, 0x8, 0x21}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - uint8_t bytesprops0[] = {0x60, 0x65, 0x45, 0x99, 0x1a, 0x43, 0xb3, 0x16, 0xcb, 0xdd, 0x18, 0xd1, 0x9, 0x6}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops1[] = {0xbd, 0xea, 0x58, 0xf4, 0x17, 0xc0, 0xd8}; - uint8_t bytesprops3[] = {0x3a, 0x1d, 0x6e, 0x7a, 0xcb, 0x69, 0x48, 0xd5, 0x88, 0x9f}; - uint8_t bytesprops4[] = {0x94, 0x1f, 0xce, 0x17, 0xfb, 0x9a, 0x6f, 0xf4, 0xa8, 0x96, 0x70, 0xc7, 0x72, 0xc4, 0xb9, - 0x2d, 0xb2, 0xfd, 0x33, 0x7, 0xc4, 0x50, 0xd, 0x20, 0xfd, 0xdc, 0x7, 0x1, 0xc0}; + uint8_t bytesprops0[] = {0x4f, 0x2c, 0xa9, 0x65, 0x60, 0x76, 0xb6, 0x85, 0xc9, 0x7b, 0xb1, + 0x8d, 0x4c, 0xc0, 0x9d, 0x8e, 0x80, 0xf3, 0x91, 0x85, 0xa3, 0x8c}; + uint8_t bytesprops1[] = {0x87, 0x8e, 0x8d, 0xde, 0x8d, 0x16, 0x5c, 0x32, 0x8b, 0x69, + 0x30, 0x72, 0x3c, 0x28, 0xed, 0xa9, 0x46, 0xf9, 0xdc, 0xe9}; + uint8_t bytesprops2[] = {0xf3, 0x98}; + uint8_t bytesprops3[] = {0xb, 0x1c, 0x83, 0xa4, 0x4d, 0x6c, 0xe5, 0x7a, 0xcf, 0x1c, 0x19, 0x2c, 0xe3, 0xfa, + 0x4c, 0xa4, 0x48, 0x8, 0x30, 0xaa, 0xa2, 0x8, 0x36, 0x8b, 0xa7, 0xa9, 0xab}; + uint8_t bytesprops4[] = {0x85, 0xe0, 0xe, 0x71, 0xad, 0xf4, 0xf, 0xb, 0x6, 0x77, 0x1, 0x7b, 0xe2, 0xa4, 0x7a}; + uint8_t bytesprops6[] = {0x7, 0x59, 0x19, 0xea}; + uint8_t bytesprops5[] = {0xfd, 0x9c, 0xd9, 0x8, 0xd0, 0x40, 0x92}; + uint8_t bytesprops7[] = {0xed, 0x5d, 0x7b, 0x5, 0x33, 0x77, 0xc4, 0xba}; + uint8_t bytesprops8[] = {0xa2, 0x35}; + uint8_t bytesprops9[] = {0x2c, 0x6f, 0x9b, 0x30, 0x8b, 0xfc, 0x49, 0x53, 0xea, 0x4e, + 0x2c, 0x3d, 0xb3, 0x31, 0x70, 0xb, 0xc1, 0x9b, 0x32, 0xe6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3544}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops1}, .v = {0, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7130}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22723}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27169}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29989}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28800}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17966}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops4}}}, {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops5}, .v = {4, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1417}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10215}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8387}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8655}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9880}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1640}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21613}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10411}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24735, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15580, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 31752 [("_\219L\240F\160\245'\201\213\145D\221\235\219\250\233\&8\211\&6\154\154\235",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\205g~\180H*@/\252|\213\208\227\DC1\184-\238\128\169\237E",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\186\144",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("p\172",SubOptions {_retainHandling = +// SubscribeRequest 10667 [("I\153\NUL\206\134\163T\222V`b\232I\232\254u\213}=\145\234\200$\183#\148\179",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("T\SYN\184.5\131\&8r'\221\184\170AuL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS1}),("\194\SUB\SYN\139\NUL\NUL\233\RS\226\177\SUB\183\128",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\135\196\232\200\SOHm\GS\194\235\n|\SOH\251\ETB\f7\137\FS\211",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\225\240\SOH \SUB",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),(":1R\165-\228F\219>\136\EOT?\198\224\DC2\129Z\215\250V\188\192\150\220\CAN\185\202\208^",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("A\140\&8\DC4?\EMv\CAN\214\t\FS'\255\208n\209\218\188\140\229o@",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("6\141\148A\161M\182\EM\129\DC4R",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// True, _noLocal = False, _subQoS = QoS2}),("W'\224\128}N\177m\137c.\r!",SubOptions {_retainHandling = // SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("E\ETB\215\130\164\130",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal -// = False, _subQoS = QoS0}),("\v\203N\139\228\165wx\175\155\n\231\195\176",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropSubscriptionIdentifier -// 2,PropTopicAliasMaximum 19084,PropSharedSubscriptionAvailable 18,PropAssignedClientIdentifier -// "\183\tTVl\186\181\247\178\171\165\229r}\218\&2F\219\173a",PropWillDelayInterval 16542,PropResponseTopic -// "<\242n,\241U\149\STX\148`\177\157n\252%\164'\187\187\165q\a\SYNz\178d",PropUserProperty -// "!\231\NAKl\161jI\130\&5\151z\237\142\STX\239\137\165N\235\202\216\DC4\150\224\164o\167Y\SYN\v" -// "\176\NAK\174&\SOH\149\188\225\DELr`1\DC4?\144<\194\244\133\168,CrG",PropCorrelationData -// "\171\171\133Z?ge!p4S\FSV\231\169\183\170\190b\201\ETX!\128\\",PropAuthenticationMethod -// "e^}v\204\245\205\vic\130@:\185 W\230\225)\ESCY!RP",PropResponseTopic "0N\168\235\166\216>\165\ACKg",PropTopicAlias -// 14415,PropServerKeepAlive 16075,PropSessionExpiryInterval 7034,PropAssignedClientIdentifier "",PropCorrelationData -// ".\184l$\168\168\209\&5Na\ETX",PropRetainAvailable 204,PropAuthenticationData "",PropContentType -// "\130\NUL\215\NAK\197\154\172\188F\200z\RS\131,1\200mng",PropTopicAliasMaximum 20411,PropRetainAvailable -// 78,PropSharedSubscriptionAvailable 227,PropWildcardSubscriptionAvailable 58,PropMessageExpiryInterval 9835] -TEST(Subscribe5QCTest, Encode12) { +// QoS0}),("\159\&6B~\216U\149-\240\230\194\218\157\166\NAK",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("1\161\160\GS\211\175d\178\213\SOHv\135\171%\155B/\222\FS9(\185g\173\174x_I\224)",SubOptions {_retainHandling +// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropTopicAlias +// 14265,PropAuthenticationData +// "\234\176J\177M{\135\SUB\163~\SUB\158\235\158\179\DEL\173\DC2\191\143\234\aU\214/\134X\t",PropSharedSubscriptionAvailable +// 90,PropMaximumQoS 85,PropRequestProblemInformation 140,PropContentType +// "lJ\161\ETX\FS\175\&1\184\227\140",PropReasonString +// "o\f\162\GS\235H\DEL\195\n\179\133\185\DC3\130\ENQ\158\219z]",PropWillDelayInterval 10700,PropReceiveMaximum 9910] +TEST(Subscribe5QCTest, Encode10) { uint8_t pkt[] = { - 0x82, 0xdd, 0x2, 0x7c, 0x8, 0x83, 0x2, 0xb, 0x2, 0x22, 0x4a, 0x8c, 0x2a, 0x12, 0x12, 0x0, 0x14, 0xb7, 0x9, - 0x54, 0x56, 0x6c, 0xba, 0xb5, 0xf7, 0xb2, 0xab, 0xa5, 0xe5, 0x72, 0x7d, 0xda, 0x32, 0x46, 0xdb, 0xad, 0x61, 0x18, - 0x0, 0x0, 0x40, 0x9e, 0x8, 0x0, 0x1a, 0x3c, 0xf2, 0x6e, 0x2c, 0xf1, 0x55, 0x95, 0x2, 0x94, 0x60, 0xb1, 0x9d, - 0x6e, 0xfc, 0x25, 0xa4, 0x27, 0xbb, 0xbb, 0xa5, 0x71, 0x7, 0x16, 0x7a, 0xb2, 0x64, 0x26, 0x0, 0x1e, 0x21, 0xe7, - 0x15, 0x6c, 0xa1, 0x6a, 0x49, 0x82, 0x35, 0x97, 0x7a, 0xed, 0x8e, 0x2, 0xef, 0x89, 0xa5, 0x4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xaf, 0x64, 0xb2, 0xd5, 0x1, 0x76, 0x87, 0xab, 0x25, + 0x9b, 0x42, 0x2f, 0xde, 0x1c, 0x39, 0x28, 0xb9, 0x67, 0xad, 0xae, 0x78, 0x5f, 0x49, 0xe0, 0x29, 0x1a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x5f, 0xdb, 0x4c, 0xf0, 0x46, 0xa0, 0xf5, 0x27, 0xc9, 0xd5, 0x91, 0x44, - 0xdd, 0xeb, 0xdb, 0xfa, 0xe9, 0x38, 0xd3, 0x36, 0x9a, 0x9a, 0xeb}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x49, 0x99, 0x0, 0xce, 0x86, 0xa3, 0x54, 0xde, 0x56, 0x60, 0x62, 0xe8, 0x49, 0xe8, + 0xfe, 0x75, 0xd5, 0x7d, 0x3d, 0x91, 0xea, 0xc8, 0x24, 0xb7, 0x23, 0x94, 0xb3}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcd, 0x67, 0x7e, 0xb4, 0x48, 0x2a, 0x40, 0x2f, 0xfc, 0x7c, 0xd5, - 0xd0, 0xe3, 0x11, 0xb8, 0x2d, 0xee, 0x80, 0xa9, 0xed, 0x45}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x54, 0x16, 0xb8, 0x2e, 0x35, 0x83, 0x38, 0x72, + 0x27, 0xdd, 0xb8, 0xaa, 0x41, 0x75, 0x4c}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xba, 0x90}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc2, 0x1a, 0x16, 0x8b, 0x0, 0x0, 0xe9, 0x1e, 0xe2, 0xb1, 0x1a, 0xb7, 0x80}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x70, 0xac}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x87, 0xc4, 0xe8, 0xc8, 0x1, 0x6d, 0x1d, 0xc2, 0xeb, 0xa, + 0x7c, 0x1, 0xfb, 0x17, 0xc, 0x37, 0x89, 0x1c, 0xd3}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x45, 0x17, 0xd7, 0x82, 0xa4, 0x82}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xe1, 0xf0, 0x1, 0x20, 0x1a}; + lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb, 0xcb, 0x4e, 0x8b, 0xe4, 0xa5, 0x77, 0x78, 0xaf, 0x9b, 0xa, 0xe7, 0xc3, 0xb0}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x3a, 0x31, 0x52, 0xa5, 0x2d, 0xe4, 0x46, 0xdb, 0x3e, 0x88, + 0x4, 0x3f, 0xc6, 0xe0, 0x12, 0x81, 0x5a, 0xd7, 0xfa, 0x56, + 0xbc, 0xc0, 0x96, 0xdc, 0x18, 0xb9, 0xca, 0xd0, 0x5e}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0x41, 0x8c, 0x38, 0x14, 0x3f, 0x19, 0x76, 0x18, 0xd6, 0x9, 0x1c, + 0x27, 0xff, 0xd0, 0x6e, 0xd1, 0xda, 0xbc, 0x8c, 0xe5, 0x6f, 0x40}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x36, 0x8d, 0x94, 0x41, 0xa1, 0x4d, 0xb6, 0x19, 0x81, 0x14, 0x52}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x57, 0x27, 0xe0, 0x80, 0x7d, 0x4e, 0xb1, 0x6d, 0x89, 0x63, 0x2e, 0xd, 0x21}; + lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x9f, 0x36, 0x42, 0x7e, 0xd8, 0x55, 0x95, 0x2d, + 0xf0, 0xe6, 0xc2, 0xda, 0x9d, 0xa6, 0x15}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x31, 0xa1, 0xa0, 0x1d, 0xd3, 0xaf, 0x64, 0xb2, 0xd5, 0x1, + 0x76, 0x87, 0xab, 0x25, 0x9b, 0x42, 0x2f, 0xde, 0x1c, 0x39, + 0x28, 0xb9, 0x67, 0xad, 0xae, 0x78, 0x5f, 0x49, 0xe0, 0x29}; + lwmqtt_string_t topic_filter_s10 = {30, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - uint8_t bytesprops0[] = {0xb7, 0x9, 0x54, 0x56, 0x6c, 0xba, 0xb5, 0xf7, 0xb2, 0xab, - 0xa5, 0xe5, 0x72, 0x7d, 0xda, 0x32, 0x46, 0xdb, 0xad, 0x61}; - uint8_t bytesprops1[] = {0x3c, 0xf2, 0x6e, 0x2c, 0xf1, 0x55, 0x95, 0x2, 0x94, 0x60, 0xb1, 0x9d, 0x6e, - 0xfc, 0x25, 0xa4, 0x27, 0xbb, 0xbb, 0xa5, 0x71, 0x7, 0x16, 0x7a, 0xb2, 0x64}; - uint8_t bytesprops3[] = {0xb0, 0x15, 0xae, 0x26, 0x1, 0x95, 0xbc, 0xe1, 0x7f, 0x72, 0x60, 0x31, - 0x14, 0x3f, 0x90, 0x3c, 0xc2, 0xf4, 0x85, 0xa8, 0x2c, 0x43, 0x72, 0x47}; - uint8_t bytesprops2[] = {0x21, 0xe7, 0x15, 0x6c, 0xa1, 0x6a, 0x49, 0x82, 0x35, 0x97, 0x7a, 0xed, 0x8e, 0x2, 0xef, - 0x89, 0xa5, 0x4e, 0xeb, 0xca, 0xd8, 0x14, 0x96, 0xe0, 0xa4, 0x6f, 0xa7, 0x59, 0x16, 0xb}; - uint8_t bytesprops4[] = {0xab, 0xab, 0x85, 0x5a, 0x3f, 0x67, 0x65, 0x21, 0x70, 0x34, 0x53, 0x1c, - 0x56, 0xe7, 0xa9, 0xb7, 0xaa, 0xbe, 0x62, 0xc9, 0x3, 0x21, 0x80, 0x5c}; - uint8_t bytesprops5[] = {0x65, 0x5e, 0x7d, 0x76, 0xcc, 0xf5, 0xcd, 0xb, 0x69, 0x63, 0x82, 0x40, - 0x3a, 0xb9, 0x20, 0x57, 0xe6, 0xe1, 0x29, 0x1b, 0x59, 0x21, 0x52, 0x50}; - uint8_t bytesprops6[] = {0x30, 0x4e, 0xa8, 0xeb, 0xa6, 0xd8, 0x3e, 0xa5, 0x6, 0x67}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops8[] = {0x2e, 0xb8, 0x6c, 0x24, 0xa8, 0xa8, 0xd1, 0x35, 0x4e, 0x61, 0x3}; - uint8_t bytesprops9[] = {0}; - uint8_t bytesprops10[] = {0x82, 0x0, 0xd7, 0x15, 0xc5, 0x9a, 0xac, 0xbc, 0x46, 0xc8, - 0x7a, 0x1e, 0x83, 0x2c, 0x31, 0xc8, 0x6d, 0x6e, 0x67}; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = true; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = false; + uint8_t bytesprops0[] = {0xea, 0xb0, 0x4a, 0xb1, 0x4d, 0x7b, 0x87, 0x1a, 0xa3, 0x7e, 0x1a, 0x9e, 0xeb, 0x9e, + 0xb3, 0x7f, 0xad, 0x12, 0xbf, 0x8f, 0xea, 0x7, 0x55, 0xd6, 0x2f, 0x86, 0x58, 0x9}; + uint8_t bytesprops1[] = {0x6c, 0x4a, 0xa1, 0x3, 0x1c, 0xaf, 0x31, 0xb8, 0xe3, 0x8c}; + uint8_t bytesprops2[] = {0x6f, 0xc, 0xa2, 0x1d, 0xeb, 0x48, 0x7f, 0xc3, 0xa, 0xb3, + 0x85, 0xb9, 0x13, 0x82, 0x5, 0x9e, 0xdb, 0x7a, 0x5d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19084}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16542}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops2}, .v = {24, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14415}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16075}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7034}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20411}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9835}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14265}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10700}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9910}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31752, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10667, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12709 [("\132\197\232\176\128>\167\NAKa",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\178\242Do\205\129\176\135\169\245\194\STXX|\196\207\227\196\169\\\DLE\175\138\200\v\186\135yL\172",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("@f\171\247\189\153\191\162\&66\248\191:\167\234nw\220R\195\&3\SOH72\235\a\EOTx",SubOptions {_retainHandling -// = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\241\135Z\182\210O\202\248\&6\NAK\215\DC2\217\EOT\171\128\173.\183\138qM]l\198_",SubOptions {_retainHandling -// = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("{\ESCA\ETX\233J}\147\DC3",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\242L\245\r\189\187\206",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("{4\GS\t\194H\206\FS\176",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\203\247\\`[\193",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\153\164\176\228\218\162\198\231\SI\135_\\P\249\176\169\200S",SubOptions {_retainHandling = +// SubscribeRequest 13196 [("\171M\DLE+(\172\SIL\DEL",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\182H\165\138\247\bHO\207\164\ACKr\239\151\ENQ\137\190k\182\&4",SubOptions {_retainHandling = // SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("8\193\250\178\180`\161\204\240\245\129/\NAK\137\242\233f\NUL\179\171\US\157\197tX'",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\193\229\147&\176\150P\DC1}\195\SI\203!V\185\SO-YK\193\131K\195\149\211",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropWillDelayInterval -// 2229,PropSubscriptionIdentifier 19,PropRequestResponseInformation 88,PropSessionExpiryInterval -// 25640,PropWillDelayInterval 29275,PropResponseInformation -// "\DC4\240\232\247\149\179\237\218xHW\DLEp\157\171\&3\NAKs\129P~\174",PropRequestProblemInformation -// 118,PropRequestResponseInformation 219,PropCorrelationData "*\250\201h\v",PropAssignedClientIdentifier -// "",PropServerReference "@\245\220\131\163\182Q~\134\RS\220\&2\138+Le!H\155\152\187\195",PropWillDelayInterval -// 27690,PropMessageExpiryInterval 15595,PropUserProperty "" -// "\199_\140\137\236\USt\188c\249n\137kF#\r\153e\157RqA}\165\235\232",PropServerReference "K\n\SYN",PropServerReference -// "\239\162\DC1\229i\233\150\187=\n\204\226\153\243\199\234\167N+jY\136\214\175\155\182",PropSubscriptionIdentifierAvailable -// 171,PropTopicAliasMaximum 22343,PropUserProperty "\SYN\134g,,\177" -// "*<\184i\157@\NUL\249\137\171e]\196\235\151./>!*\FS'\170\252\252\213#",PropUserProperty -// "&\134\v\150^\SOo{\209\211l\229\239^:" -// "9\140\NUL\248A\DEL\199F\246\130\DC2\138Qt\233\DELY\187\DELON\229\199\&6E\149\172",PropWillDelayInterval -// 26714,PropSessionExpiryInterval 31256,PropTopicAliasMaximum 6163,PropAssignedClientIdentifier -// "\178\FS\211\248\191\&8\154\186\134Fv\163\199X\235\196/\236\164\SYN\152\192\232'\251PJ)W",PropMessageExpiryInterval -// 16327,PropReasonString "DH\248\248x\174\176\191 \155\128\t\237\140\191\239",PropWildcardSubscriptionAvailable -// 228,PropTopicAliasMaximum 3438,PropContentType "\173$\173\240\178\187\171\nJ\172~8\\",PropPayloadFormatIndicator 150] -TEST(Subscribe5QCTest, Encode13) { - uint8_t pkt[] = { - 0x82, 0xbc, 0x4, 0x31, 0xa5, 0xd6, 0x2, 0x18, 0x0, 0x0, 0x8, 0xb5, 0xb, 0x13, 0x19, 0x58, 0x11, 0x0, 0x0, - 0x64, 0x28, 0x18, 0x0, 0x0, 0x72, 0x5b, 0x1a, 0x0, 0x16, 0x14, 0xf0, 0xe8, 0xf7, 0x95, 0xb3, 0xed, 0xda, 0x78, - 0x48, 0x57, 0x10, 0x70, 0x9d, 0xab, 0x33, 0x15, 0x73, 0x81, 0x50, 0x7e, 0xae, 0x17, 0x76, 0x19, 0xdb, 0x9, 0x0, - 0x5, 0x2a, 0xfa, 0xc9, 0x68, 0xb, 0x12, 0x0, 0x0, 0x1c, 0x0, 0x16, 0x40, 0xf5, 0xdc, 0x83, 0xa3, 0xb6, 0x51, - 0x7e, 0x86, 0x1e, 0xdc, 0x32, 0x8a, 0x2b, 0x4c, 0x65, 0x21, 0x48, 0x9b, 0x98, 0xbb, 0xc3, 0x18, 0x0, 0x0, 0x6c, - 0x2a, 0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x0, 0x7, 0xf2, 0x4c, 0xf5, 0xd, 0xbd, 0xbb, 0xce, - 0xd, 0x0, 0x9, 0x7b, 0x34, 0x1d, 0x9, 0xc2, 0x48, 0xce, 0x1c, 0xb0, 0x11, 0x0, 0x6, 0xcb, 0xf7, 0x5c, 0x60, - 0x5b, 0xc1, 0x2e, 0x0, 0x12, 0x99, 0xa4, 0xb0, 0xe4, 0xda, 0xa2, 0xc6, 0xe7, 0xf, 0x87, 0x5f, 0x5c, 0x50, 0xf9, - 0xb0, 0xa9, 0xc8, 0x53, 0x1a, 0x0, 0x1a, 0x38, 0xc1, 0xfa, 0xb2, 0xb4, 0x60, 0xa1, 0xcc, 0xf0, 0xf5, 0x81, 0x2f, - 0x15, 0x89, 0xf2, 0xe9, 0x66, 0x0, 0xb3, 0xab, 0x1f, 0x9d, 0xc5, 0x74, 0x58, 0x27, 0x12, 0x0, 0x19, 0xc1, 0xe5, - 0x93, 0x26, 0xb0, 0x96, 0x50, 0x11, 0x7d, 0xc3, 0xf, 0xcb, 0x21, 0x56, 0xb9, 0xe, 0x2d, 0x59, 0x4b, 0xc1, 0x83, - 0x4b, 0xc3, 0x95, 0xd3, 0x15}; +// QoS2}),("\231~\137\219\155\189\239N\199\208$X\206\145\176Q0\SIv\145\ETX",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\135\&4Dk@\b\247\150\217%:t\198f\195\&4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// True, _noLocal = False, _subQoS = +// QoS2}),("\186,\216\227\251\233`o\219\177\179\DC4\ETB\226\180\143\194\CAN\202\140\&1Y\213\a\ACKq\165^",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] +// [PropReceiveMaximum 2979,PropReceiveMaximum 20597,PropTopicAliasMaximum 24577,PropSharedSubscriptionAvailable +// 21,PropAssignedClientIdentifier "\232\145\174\232\140r\209\DC4H\STX\219\132\229\208",PropUserProperty "\167\&0" +// "\222\SOH[P\215\215]}'\238\223"] +TEST(Subscribe5QCTest, Encode11) { + uint8_t pkt[] = {0x82, 0x9e, 0x1, 0x33, 0x8c, 0x2e, 0x21, 0xb, 0xa3, 0x21, 0x50, 0x75, 0x22, 0x60, 0x1, 0x2a, 0x15, + 0x12, 0x0, 0xe, 0xe8, 0x91, 0xae, 0xe8, 0x8c, 0x72, 0xd1, 0x14, 0x48, 0x2, 0xdb, 0x84, 0xe5, 0xd0, + 0x26, 0x0, 0x2, 0xa7, 0x30, 0x0, 0xb, 0xde, 0x1, 0x5b, 0x50, 0xd7, 0xd7, 0x5d, 0x7d, 0x27, 0xee, + 0xdf, 0x0, 0x9, 0xab, 0x4d, 0x10, 0x2b, 0x28, 0xac, 0xf, 0x4c, 0x7f, 0x2a, 0x0, 0x14, 0xb6, 0x48, + 0xa5, 0x8a, 0xf7, 0x8, 0x48, 0x4f, 0xcf, 0xa4, 0x6, 0x72, 0xef, 0x97, 0x5, 0x89, 0xbe, 0x6b, 0xb6, + 0x34, 0x1a, 0x0, 0x15, 0xe7, 0x7e, 0x89, 0xdb, 0x9b, 0xbd, 0xef, 0x4e, 0xc7, 0xd0, 0x24, 0x58, 0xce, + 0x91, 0xb0, 0x51, 0x30, 0xf, 0x76, 0x91, 0x3, 0x2, 0x0, 0x10, 0x87, 0x34, 0x44, 0x6b, 0x40, 0x8, + 0xf7, 0x96, 0xd9, 0x25, 0x3a, 0x74, 0xc6, 0x66, 0xc3, 0x34, 0xa, 0x0, 0x1c, 0xba, 0x2c, 0xd8, 0xe3, + 0xfb, 0xe9, 0x60, 0x6f, 0xdb, 0xb1, 0xb3, 0x14, 0x17, 0xe2, 0xb4, 0x8f, 0xc2, 0x18, 0xca, 0x8c, 0x31, + 0x59, 0xd5, 0x7, 0x6, 0x71, 0xa5, 0x5e, 0x28}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x84, 0xc5, 0xe8, 0xb0, 0x80, 0x3e, 0xa7, 0x15, 0x61}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xab, 0x4d, 0x10, 0x2b, 0x28, 0xac, 0xf, 0x4c, 0x7f}; lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb2, 0xf2, 0x44, 0x6f, 0xcd, 0x81, 0xb0, 0x87, 0xa9, 0xf5, - 0xc2, 0x2, 0x58, 0x7c, 0xc4, 0xcf, 0xe3, 0xc4, 0xa9, 0x5c, - 0x10, 0xaf, 0x8a, 0xc8, 0xb, 0xba, 0x87, 0x79, 0x4c, 0xac}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb6, 0x48, 0xa5, 0x8a, 0xf7, 0x8, 0x48, 0x4f, 0xcf, 0xa4, + 0x6, 0x72, 0xef, 0x97, 0x5, 0x89, 0xbe, 0x6b, 0xb6, 0x34}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x40, 0x66, 0xab, 0xf7, 0xbd, 0x99, 0xbf, 0xa2, 0x36, 0x36, - 0xf8, 0xbf, 0x3a, 0xa7, 0xea, 0x6e, 0x77, 0xdc, 0x52, 0xc3, - 0x33, 0x1, 0x37, 0x32, 0xeb, 0x7, 0x4, 0x78}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe7, 0x7e, 0x89, 0xdb, 0x9b, 0xbd, 0xef, 0x4e, 0xc7, 0xd0, 0x24, + 0x58, 0xce, 0x91, 0xb0, 0x51, 0x30, 0xf, 0x76, 0x91, 0x3}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf1, 0x87, 0x5a, 0xb6, 0xd2, 0x4f, 0xca, 0xf8, 0x36, 0x15, 0xd7, 0x12, 0xd9, - 0x4, 0xab, 0x80, 0xad, 0x2e, 0xb7, 0x8a, 0x71, 0x4d, 0x5d, 0x6c, 0xc6, 0x5f}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x87, 0x34, 0x44, 0x6b, 0x40, 0x8, 0xf7, 0x96, + 0xd9, 0x25, 0x3a, 0x74, 0xc6, 0x66, 0xc3, 0x34}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7b, 0x1b, 0x41, 0x3, 0xe9, 0x4a, 0x7d, 0x93, 0x13}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xba, 0x2c, 0xd8, 0xe3, 0xfb, 0xe9, 0x60, 0x6f, 0xdb, 0xb1, + 0xb3, 0x14, 0x17, 0xe2, 0xb4, 0x8f, 0xc2, 0x18, 0xca, 0x8c, + 0x31, 0x59, 0xd5, 0x7, 0x6, 0x71, 0xa5, 0x5e}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf2, 0x4c, 0xf5, 0xd, 0xbd, 0xbb, 0xce}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x7b, 0x34, 0x1d, 0x9, 0xc2, 0x48, 0xce, 0x1c, 0xb0}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xcb, 0xf7, 0x5c, 0x60, 0x5b, 0xc1}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x99, 0xa4, 0xb0, 0xe4, 0xda, 0xa2, 0xc6, 0xe7, 0xf, - 0x87, 0x5f, 0x5c, 0x50, 0xf9, 0xb0, 0xa9, 0xc8, 0x53}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x38, 0xc1, 0xfa, 0xb2, 0xb4, 0x60, 0xa1, 0xcc, 0xf0, 0xf5, 0x81, 0x2f, 0x15, - 0x89, 0xf2, 0xe9, 0x66, 0x0, 0xb3, 0xab, 0x1f, 0x9d, 0xc5, 0x74, 0x58, 0x27}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xc1, 0xe5, 0x93, 0x26, 0xb0, 0x96, 0x50, 0x11, 0x7d, 0xc3, 0xf, 0xcb, 0x21, - 0x56, 0xb9, 0xe, 0x2d, 0x59, 0x4b, 0xc1, 0x83, 0x4b, 0xc3, 0x95, 0xd3}; - lwmqtt_string_t topic_filter_s10 = {25, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS1; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = true; - uint8_t bytesprops0[] = {0x14, 0xf0, 0xe8, 0xf7, 0x95, 0xb3, 0xed, 0xda, 0x78, 0x48, 0x57, - 0x10, 0x70, 0x9d, 0xab, 0x33, 0x15, 0x73, 0x81, 0x50, 0x7e, 0xae}; - uint8_t bytesprops1[] = {0x2a, 0xfa, 0xc9, 0x68, 0xb}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x40, 0xf5, 0xdc, 0x83, 0xa3, 0xb6, 0x51, 0x7e, 0x86, 0x1e, 0xdc, - 0x32, 0x8a, 0x2b, 0x4c, 0x65, 0x21, 0x48, 0x9b, 0x98, 0xbb, 0xc3}; - uint8_t bytesprops5[] = {0xc7, 0x5f, 0x8c, 0x89, 0xec, 0x1f, 0x74, 0xbc, 0x63, 0xf9, 0x6e, 0x89, 0x6b, - 0x46, 0x23, 0xd, 0x99, 0x65, 0x9d, 0x52, 0x71, 0x41, 0x7d, 0xa5, 0xeb, 0xe8}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops6[] = {0x4b, 0xa, 0x16}; - uint8_t bytesprops7[] = {0xef, 0xa2, 0x11, 0xe5, 0x69, 0xe9, 0x96, 0xbb, 0x3d, 0xa, 0xcc, 0xe2, 0x99, - 0xf3, 0xc7, 0xea, 0xa7, 0x4e, 0x2b, 0x6a, 0x59, 0x88, 0xd6, 0xaf, 0x9b, 0xb6}; - uint8_t bytesprops9[] = {0x2a, 0x3c, 0xb8, 0x69, 0x9d, 0x40, 0x0, 0xf9, 0x89, 0xab, 0x65, 0x5d, 0xc4, 0xeb, - 0x97, 0x2e, 0x2f, 0x3e, 0x21, 0x2a, 0x1c, 0x27, 0xaa, 0xfc, 0xfc, 0xd5, 0x23}; - uint8_t bytesprops8[] = {0x16, 0x86, 0x67, 0x2c, 0x2c, 0xb1}; - uint8_t bytesprops11[] = {0x39, 0x8c, 0x0, 0xf8, 0x41, 0x7f, 0xc7, 0x46, 0xf6, 0x82, 0x12, 0x8a, 0x51, 0x74, - 0xe9, 0x7f, 0x59, 0xbb, 0x7f, 0x4f, 0x4e, 0xe5, 0xc7, 0x36, 0x45, 0x95, 0xac}; - uint8_t bytesprops10[] = {0x26, 0x86, 0xb, 0x96, 0x5e, 0xe, 0x6f, 0x7b, 0xd1, 0xd3, 0x6c, 0xe5, 0xef, 0x5e, 0x3a}; - uint8_t bytesprops12[] = {0xb2, 0x1c, 0xd3, 0xf8, 0xbf, 0x38, 0x9a, 0xba, 0x86, 0x46, 0x76, 0xa3, 0xc7, 0x58, 0xeb, - 0xc4, 0x2f, 0xec, 0xa4, 0x16, 0x98, 0xc0, 0xe8, 0x27, 0xfb, 0x50, 0x4a, 0x29, 0x57}; - uint8_t bytesprops13[] = {0x44, 0x48, 0xf8, 0xf8, 0x78, 0xae, 0xb0, 0xbf, - 0x20, 0x9b, 0x80, 0x9, 0xed, 0x8c, 0xbf, 0xef}; - uint8_t bytesprops14[] = {0xad, 0x24, 0xad, 0xf0, 0xb2, 0xbb, 0xab, 0xa, 0x4a, 0xac, 0x7e, 0x38, 0x5c}; + uint8_t bytesprops0[] = {0xe8, 0x91, 0xae, 0xe8, 0x8c, 0x72, 0xd1, 0x14, 0x48, 0x2, 0xdb, 0x84, 0xe5, 0xd0}; + uint8_t bytesprops2[] = {0xde, 0x1, 0x5b, 0x50, 0xd7, 0xd7, 0x5d, 0x7d, 0x27, 0xee, 0xdf}; + uint8_t bytesprops1[] = {0xa7, 0x30}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2229}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25640}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29275}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27690}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15595}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops4}, .v = {26, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22343}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops8}, .v = {27, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {15, (char*)&bytesprops10}, .v = {27, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26714}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31256}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6163}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16327}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3438}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2979}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20597}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24577}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12709, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13196, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14473 [("\173\230\ESC\133\246\196\156\135\200q|\DC2\188\236\FS\153\183\SO\142b",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\CAN\192\&41\164\131Z8\251)\173>\128\193\211\222\167G\162\167\149}\129\174",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("g\226\&6wT\129\254\179\NUL\228\163\218\238\131\130\198\131\172\r\"\223\195\172\130",SubOptions +// SubscribeRequest 11145 [("\237\a\171\195\220\245\232@\229P\146~C\193\193\139\138\EOTF\139\ACK\135\ETX\253",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] +// [PropMessageExpiryInterval 3734,PropMaximumPacketSize 5015] +TEST(Subscribe5QCTest, Encode12) { + uint8_t pkt[] = {0x82, 0x28, 0x2b, 0x89, 0xa, 0x2, 0x0, 0x0, 0xe, 0x96, 0x27, 0x0, 0x0, 0x13, + 0x97, 0x0, 0x18, 0xed, 0x7, 0xab, 0xc3, 0xdc, 0xf5, 0xe8, 0x40, 0xe5, 0x50, 0x92, + 0x7e, 0x43, 0xc1, 0xc1, 0x8b, 0x8a, 0x4, 0x46, 0x8b, 0x6, 0x87, 0x3, 0xfd, 0x26}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xed, 0x7, 0xab, 0xc3, 0xdc, 0xf5, 0xe8, 0x40, 0xe5, 0x50, 0x92, 0x7e, + 0x43, 0xc1, 0xc1, 0x8b, 0x8a, 0x4, 0x46, 0x8b, 0x6, 0x87, 0x3, 0xfd}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3734}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5015}}, + }; + + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11145, 1, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 22549 +// [("q&N\176\217\FS\143\140\217\b\164\171\163\233\237\200\214\223\156\197\201\182e\DC3q",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\251N<\255g\164",SubOptions // {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("u\138\167\DEL\SI\167\172\136\244\217\249\185\239B\228y",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\193\254#\159\210\150\130\"\250",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\236\179\227\206P\141i\DC3\EM\237\243\232\"cG\151\199\190I",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropTopicAliasMaximum -// 7848,PropSessionExpiryInterval 28305,PropRetainAvailable 225,PropMessageExpiryInterval -// 4567,PropAssignedClientIdentifier "G\192\174\165~\DEL",PropMaximumQoS 183,PropUserProperty -// "\185\193\SYN\221\SO\a\200\192\139\162\DLE\160\&0\203\246\212Qi" -// "?\213\174\bf\SIV!ZS\175zUv\EOT\151\&3&",PropSessionExpiryInterval 20670,PropReasonString -// "y\USs\152\220fZ\248\SUB\128\213",PropSharedSubscriptionAvailable 149,PropCorrelationData -// "\249\154\ETB]\205\222(\249^\178\147+}E\244%\DLE\187y\250\&6\173\ENQa\228",PropAssignedClientIdentifier -// "\217\199\GS\158\EOTt\213Un@H\EOT\191",PropAuthenticationMethod -// "\186\&9\SI\210!\245\STX\153T\243X\250;\199\177Z\204\208\238\227ub\SUB6\STXyg\207G",PropRequestResponseInformation -// 63,PropMaximumPacketSize 31623,PropAuthenticationData -// "\228M\248\139\SO\177l\213A=\140\215\202\189\&8\a\149\241\DC1^0\185p\134\130\140B9",PropAssignedClientIdentifier -// "\255\&4\168\224_#\149\SO\EOT\245",PropServerReference -// "\201*n_\186\138hW\237\196<\177nD\174\153\203B\230^\236\151\DC4\SUB\n]\235\240\146\216",PropRequestResponseInformation -// 82,PropCorrelationData "\ESC\155E:\153\195\130\ETB^0\249}\SUB\185=n",PropRequestResponseInformation -// 153,PropReasonString "\240\&3\t5",PropTopicAlias 29714,PropWillDelayInterval 22439,PropTopicAlias -// 29750,PropRequestResponseInformation 201,PropSubscriptionIdentifierAvailable 27] -TEST(Subscribe5QCTest, Encode14) { +// QoS1}),("\236\US\180\241\219\242\200\196\229J\244\135\&7]\225L\136\132\213\128\&8\252\234\US\157\230k\NAK}g",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\157FH\237\157\&9\207X2\190\240\162\239\164",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable +// 37,PropSharedSubscriptionAvailable 153,PropSessionExpiryInterval 29426,PropMessageExpiryInterval +// 23723,PropMessageExpiryInterval 8643,PropSessionExpiryInterval 10393,PropPayloadFormatIndicator 48,PropResponseTopic +// "t\227\219\204E\144=*n\DEL",PropReasonString +// "\219\209\ETB\SOH\GS\161\150\221\175\DC3\213\199\131\DEL\235\190_vaZ\218\128\155\209\&9\137",PropResponseInformation +// "\155\136\CAN ^\222\SUBH\187\128\n\150\238_\192",PropRequestResponseInformation 164,PropServerKeepAlive +// 1216,PropSubscriptionIdentifier 23,PropServerKeepAlive 24368,PropSessionExpiryInterval 2690,PropSessionExpiryInterval +// 28694,PropMessageExpiryInterval 21697,PropRetainAvailable 56,PropMessageExpiryInterval 31144,PropAuthenticationMethod +// "",PropReceiveMaximum 10744,PropTopicAlias 16979,PropReasonString +// "\253\vH\234\142\163o\193\150\192\158\157\241\221\200",PropTopicAlias 11000] +TEST(Subscribe5QCTest, Encode13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0x23, 0x42, + 0x53, 0x1f, 0x0, 0xf, 0xfd, 0xb, 0x48, 0xea, 0x8e, 0xa3, 0x6f, 0xc1, 0x96, 0xc0, 0x9e, 0x9d, 0xf1, 0xdd, 0xc8, + 0x23, 0x2a, 0xf8, 0x0, 0x19, 0x71, 0x26, 0x4e, 0xb0, 0xd9, 0x1c, 0x8f, 0x8c, 0xd9, 0x8, 0xa4, 0xab, 0xa3, 0xe9, + 0xed, 0xc8, 0xd6, 0xdf, 0x9c, 0xc5, 0xc9, 0xb6, 0x65, 0x13, 0x71, 0x2c, 0x0, 0x6, 0xfb, 0x4e, 0x3c, 0xff, 0x67, + 0xa4, 0x29, 0x0, 0x1e, 0xec, 0x1f, 0xb4, 0xf1, 0xdb, 0xf2, 0xc8, 0xc4, 0xe5, 0x4a, 0xf4, 0x87, 0x37, 0x5d, 0xe1, + 0x4c, 0x88, 0x84, 0xd5, 0x80, 0x38, 0xfc, 0xea, 0x1f, 0x9d, 0xe6, 0x6b, 0x15, 0x7d, 0x67, 0x1a, 0x0, 0xe, 0x9d, + 0x46, 0x48, 0xed, 0x9d, 0x39, 0xcf, 0x58, 0x32, 0xbe, 0xf0, 0xa2, 0xef, 0xa4, 0x2a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xad, 0xe6, 0x1b, 0x85, 0xf6, 0xc4, 0x9c, 0x87, 0xc8, 0x71, - 0x7c, 0x12, 0xbc, 0xec, 0x1c, 0x99, 0xb7, 0xe, 0x8e, 0x62}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x71, 0x26, 0x4e, 0xb0, 0xd9, 0x1c, 0x8f, 0x8c, 0xd9, 0x8, 0xa4, 0xab, 0xa3, + 0xe9, 0xed, 0xc8, 0xd6, 0xdf, 0x9c, 0xc5, 0xc9, 0xb6, 0x65, 0x13, 0x71}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x18, 0xc0, 0x34, 0x31, 0xa4, 0x83, 0x5a, 0x38, 0xfb, 0x29, 0xad, 0x3e, - 0x80, 0xc1, 0xd3, 0xde, 0xa7, 0x47, 0xa2, 0xa7, 0x95, 0x7d, 0x81, 0xae}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xfb, 0x4e, 0x3c, 0xff, 0x67, 0xa4}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x67, 0xe2, 0x36, 0x77, 0x54, 0x81, 0xfe, 0xb3, 0x0, 0xe4, 0xa3, 0xda, - 0xee, 0x83, 0x82, 0xc6, 0x83, 0xac, 0xd, 0x22, 0xdf, 0xc3, 0xac, 0x82}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xec, 0x1f, 0xb4, 0xf1, 0xdb, 0xf2, 0xc8, 0xc4, 0xe5, 0x4a, + 0xf4, 0x87, 0x37, 0x5d, 0xe1, 0x4c, 0x88, 0x84, 0xd5, 0x80, + 0x38, 0xfc, 0xea, 0x1f, 0x9d, 0xe6, 0x6b, 0x15, 0x7d, 0x67}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x75, 0x8a, 0xa7, 0x7f, 0xf, 0xa7, 0xac, 0x88, - 0xf4, 0xd9, 0xf9, 0xb9, 0xef, 0x42, 0xe4, 0x79}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9d, 0x46, 0x48, 0xed, 0x9d, 0x39, 0xcf, + 0x58, 0x32, 0xbe, 0xf0, 0xa2, 0xef, 0xa4}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc1, 0xfe, 0x23, 0x9f, 0xd2, 0x96, 0x82, 0x22, 0xfa}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xec, 0xb3, 0xe3, 0xce, 0x50, 0x8d, 0x69, 0x13, 0x19, 0xed, - 0xf3, 0xe8, 0x22, 0x63, 0x47, 0x97, 0xc7, 0xbe, 0x49}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + lwmqtt_sub_options_t sub_opts[4]; sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - uint8_t bytesprops0[] = {0x47, 0xc0, 0xae, 0xa5, 0x7e, 0x7f}; - uint8_t bytesprops2[] = {0x3f, 0xd5, 0xae, 0x8, 0x66, 0xf, 0x56, 0x21, 0x5a, - 0x53, 0xaf, 0x7a, 0x55, 0x76, 0x4, 0x97, 0x33, 0x26}; - uint8_t bytesprops1[] = {0xb9, 0xc1, 0x16, 0xdd, 0xe, 0x7, 0xc8, 0xc0, 0x8b, - 0xa2, 0x10, 0xa0, 0x30, 0xcb, 0xf6, 0xd4, 0x51, 0x69}; - uint8_t bytesprops3[] = {0x79, 0x1f, 0x73, 0x98, 0xdc, 0x66, 0x5a, 0xf8, 0x1a, 0x80, 0xd5}; - uint8_t bytesprops4[] = {0xf9, 0x9a, 0x17, 0x5d, 0xcd, 0xde, 0x28, 0xf9, 0x5e, 0xb2, 0x93, 0x2b, 0x7d, - 0x45, 0xf4, 0x25, 0x10, 0xbb, 0x79, 0xfa, 0x36, 0xad, 0x5, 0x61, 0xe4}; - uint8_t bytesprops5[] = {0xd9, 0xc7, 0x1d, 0x9e, 0x4, 0x74, 0xd5, 0x55, 0x6e, 0x40, 0x48, 0x4, 0xbf}; - uint8_t bytesprops6[] = {0xba, 0x39, 0xf, 0xd2, 0x21, 0xf5, 0x2, 0x99, 0x54, 0xf3, 0x58, 0xfa, 0x3b, 0xc7, 0xb1, - 0x5a, 0xcc, 0xd0, 0xee, 0xe3, 0x75, 0x62, 0x1a, 0x36, 0x2, 0x79, 0x67, 0xcf, 0x47}; - uint8_t bytesprops7[] = {0xe4, 0x4d, 0xf8, 0x8b, 0xe, 0xb1, 0x6c, 0xd5, 0x41, 0x3d, 0x8c, 0xd7, 0xca, 0xbd, - 0x38, 0x7, 0x95, 0xf1, 0x11, 0x5e, 0x30, 0xb9, 0x70, 0x86, 0x82, 0x8c, 0x42, 0x39}; - uint8_t bytesprops8[] = {0xff, 0x34, 0xa8, 0xe0, 0x5f, 0x23, 0x95, 0xe, 0x4, 0xf5}; - uint8_t bytesprops9[] = {0xc9, 0x2a, 0x6e, 0x5f, 0xba, 0x8a, 0x68, 0x57, 0xed, 0xc4, 0x3c, 0xb1, 0x6e, 0x44, 0xae, - 0x99, 0xcb, 0x42, 0xe6, 0x5e, 0xec, 0x97, 0x14, 0x1a, 0xa, 0x5d, 0xeb, 0xf0, 0x92, 0xd8}; - uint8_t bytesprops10[] = {0x1b, 0x9b, 0x45, 0x3a, 0x99, 0xc3, 0x82, 0x17, - 0x5e, 0x30, 0xf9, 0x7d, 0x1a, 0xb9, 0x3d, 0x6e}; - uint8_t bytesprops11[] = {0xf0, 0x33, 0x9, 0x35}; + uint8_t bytesprops0[] = {0x74, 0xe3, 0xdb, 0xcc, 0x45, 0x90, 0x3d, 0x2a, 0x6e, 0x7f}; + uint8_t bytesprops1[] = {0xdb, 0xd1, 0x17, 0x1, 0x1d, 0xa1, 0x96, 0xdd, 0xaf, 0x13, 0xd5, 0xc7, 0x83, + 0x7f, 0xeb, 0xbe, 0x5f, 0x76, 0x61, 0x5a, 0xda, 0x80, 0x9b, 0xd1, 0x39, 0x89}; + uint8_t bytesprops2[] = {0x9b, 0x88, 0x18, 0x20, 0x5e, 0xde, 0x1a, 0x48, 0xbb, 0x80, 0xa, 0x96, 0xee, 0x5f, 0xc0}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0xfd, 0xb, 0x48, 0xea, 0x8e, 0xa3, 0x6f, 0xc1, 0x96, 0xc0, 0x9e, 0x9d, 0xf1, 0xdd, 0xc8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7848}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28305}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4567}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20670}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31623}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29714}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22439}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29750}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29426}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23723}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8643}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10393}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1216}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24368}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2690}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28694}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21697}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31144}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10744}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16979}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11000}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14473, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22549, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3580 [("\244E\204\&6O\ACKRSi\250\193:i*L\v{\159\212\243!\DLE\200o\175\172\236d\232\RS",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("N\248\172\a7\159\250\EM\227{\179\201O\161ZR\140\251\188\207\144\212\STX\173\150w",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\155W\251\fk<\195p\184\253\175A\162\210\ETB",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("v\DLE\188\STXG!\142W\193\182\236H\NUL\fO$`\253e+\SO\214",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\163+\244m -// 1\138n\233\129sR\182\CAN\137\199(BB}\202\196m\231\208XEz\148",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("j\148\131KK\155",SubOptions {_retainHandling = +// SubscribeRequest 18393 [("{\US\242",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS0}),("\201=\vz\142\EOT\237}\162$\ETXL\232c\RS",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Y\f\153\US\197\228\\\211\233\&9\CAN>\237\190\193\v\239\GSb",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("/\r\190",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("yL\254\155\&0U{\DLE\199\211\253\189\183F\149\222\US\218\186\b\175\DC2\252'\156",SubOptions {_retainHandling -// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\US&\190d\ETX~\239/\NAK\128\228\240io\227\DC1\SUB6\DC1\175 \153",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropTopicAliasMaximum -// 25272,PropTopicAliasMaximum 14579,PropRequestResponseInformation 189,PropTopicAlias 14505,PropReasonString -// "\163^'\163\136\DC3n\145k\214\ACK\250`\155",PropServerReference -// "\DC4\154\NUL\159v\144-\213\246\128\192nF\b{\CAN}P>\162Yw",PropResponseInformation -// "\NULn~})5",PropRequestProblemInformation 59,PropPayloadFormatIndicator 184,PropResponseTopic -// "\EOT\180V\182x;\252\163\&0\131\n8\EM\232",PropRequestProblemInformation 113,PropCorrelationData -// "2",PropWildcardSubscriptionAvailable 43,PropMaximumQoS 237,PropRequestResponseInformation -// 20,PropWildcardSubscriptionAvailable 253,PropAuthenticationData "h!Q,\206\184\215\128G\ETX",PropTopicAliasMaximum -// 7133,PropWillDelayInterval 32528,PropWildcardSubscriptionAvailable 162,PropRequestResponseInformation -// 48,PropServerKeepAlive 28613,PropMessageExpiryInterval 6419,PropContentType -// "\157Z\149\DC3\213\174\231\241\&1[\225\151\DEL+]\fT[\FS\243\198\206'sI\252>\148\ETB\194",PropResponseInformation -// ")v\160\t\228\210(VA\142\ESC\r\253Uw(so\248\244U\201K",PropServerKeepAlive 13558,PropSubscriptionIdentifierAvailable -// 122,PropRequestProblemInformation 192] -TEST(Subscribe5QCTest, Encode15) { - uint8_t pkt[] = { - 0x82, 0xab, 0x3, 0xd, 0xfc, 0xc4, 0x1, 0x22, 0x62, 0xb8, 0x22, 0x38, 0xf3, 0x19, 0xbd, 0x23, 0x38, 0xa9, 0x1f, - 0x0, 0xe, 0xa3, 0x5e, 0x27, 0xa3, 0x88, 0x13, 0x6e, 0x91, 0x6b, 0xd6, 0x6, 0xfa, 0x60, 0x9b, 0x1c, 0x0, 0x16, - 0x14, 0x9a, 0x0, 0x9f, 0x76, 0x90, 0x2d, 0xd5, 0xf6, 0x80, 0xc0, 0x6e, 0x46, 0x8, 0x7b, 0x18, 0x7d, 0x50, 0x3e, - 0xa2, 0x59, 0x77, 0x1a, 0x0, 0x6, 0x0, 0x6e, 0x7e, 0x7d, 0x29, 0x35, 0x17, 0x3b, 0x1, 0xb8, 0x8, 0x0, 0xe, - 0x4, 0xb4, 0x56, 0xb6, 0x78, 0x3b, 0xfc, 0xa3, 0x30, 0x83, 0xa, 0x38, 0x19, 0xe8, 0x17, 0x71, 0x9, 0x0, 0x1, - 0x32, 0x28, 0x2b, 0x24, 0xed, 0x19, 0x14, 0x28, 0xfd, 0x16, 0x0, 0xa, 0x68, 0x21, 0x51, 0x2c, 0xce, 0xb8, 0xd7, - 0x80, 0x47, 0x3, 0x22, 0x1b, 0xdd, 0x18, 0x0, 0x0, 0x7f, 0x10, 0x28, 0xa2, 0x19, 0x30, 0x13, 0x6f, 0xc5, 0x2, - 0x0, 0x0, 0x19, 0x13, 0x3, 0x0, 0x1e, 0x9d, 0x5a, 0x95, 0x13, 0xd5, 0xae, 0xe7, 0xf1, 0x31, 0x5b, 0xe1, 0x97, - 0x7f, 0x2b, 0x5d, 0xc, 0x54, 0x5b, 0x1c, 0xf3, 0xc6, 0xce, 0x27, 0x73, 0x49, 0xfc, 0x3e, 0x94, 0x17, 0xc2, 0x1a, - 0x0, 0x17, 0x29, 0x76, 0xa0, 0x9, 0xe4, 0xd2, 0x28, 0x56, 0x41,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 0xb, 0xef, 0x1d, 0x62, 0x9, 0x0, 0x3, 0x2f, 0xd, 0xbe, 0x8, 0x0, 0x19, 0x79, - 0x4c, 0xfe, 0x9b, 0x30, 0x55, 0x7b, 0x10, 0xc7, 0xd3, 0xfd, 0xbd, 0xb7, 0x46, 0x95, 0xde, 0x1f, 0xda, 0xba, 0x8, - 0xaf, 0x12, 0xfc, 0x27, 0x9c, 0x1a, 0x0, 0x16, 0x1f, 0x26, 0xbe, 0x64, 0x3, 0x7e, 0xef, 0x2f, 0x15, 0x80, 0xe4, - 0xf0, 0x69, 0x6f, 0xe3, 0x11, 0x1a, 0x36, 0x11, 0xaf, 0x20, 0x99, 0x1}; +// QoS2}),("\247y\217\183\158j\243\153\130ub\232\193\210\DC4lt\EOTGRnv",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("8\140\&6\235T\162\129K\250\154E\163q\165\161\233\218\239\191\198%\208\222",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\167",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling +// = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\138)\154\144@\221\174\188\n\143\197\159E6\191\149\251",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("Vi\140c:I\156\DEL\172\220A\GS9zg\167",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\193\198\250h\138\172\219di\163g\DC3\186`\129\162\202w\171\252",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty +// "\DLE\254\218\246s\229\a\NAK\225k\164" +// "?\246\177\148'$\135\STX\161EI}\US\128\b\224\171e\213E\139YvT\216\204\&2",PropSubscriptionIdentifier +// 21,PropSubscriptionIdentifierAvailable 204,PropSharedSubscriptionAvailable 55,PropRequestProblemInformation +// 165,PropRequestProblemInformation 55,PropServerKeepAlive 19127,PropAuthenticationData +// "S\DELtZ%y\190^5\186\US\FS_",PropCorrelationData +// "D(\DC1\160\136\166\b\SYN{[\231t\133\181\128\183\160s\DEL\EOT\STX\200\167\206"] +TEST(Subscribe5QCTest, Encode14) { + uint8_t pkt[] = {0x82, 0xf6, 0x1, 0x47, 0xd9, 0x63, 0x26, 0x0, 0xb, 0x10, 0xfe, 0xda, 0xf6, 0x73, 0xe5, 0x7, 0x15, + 0xe1, 0x6b, 0xa4, 0x0, 0x1b, 0x3f, 0xf6, 0xb1, 0x94, 0x27, 0x24, 0x87, 0x2, 0xa1, 0x45, 0x49, 0x7d, + 0x1f, 0x80, 0x8, 0xe0, 0xab, 0x65, 0xd5, 0x45, 0x8b, 0x59, 0x76, 0x54, 0xd8, 0xcc, 0x32, 0xb, 0x15, + 0x29, 0xcc, 0x2a, 0x37, 0x17, 0xa5, 0x17, 0x37, 0x13, 0x4a, 0xb7, 0x16, 0x0, 0xd, 0x53, 0x7f, 0x74, + 0x5a, 0x25, 0x79, 0xbe, 0x5e, 0x35, 0xba, 0x1f, 0x1c, 0x5f, 0x9, 0x0, 0x18, 0x44, 0x28, 0x11, 0xa0, + 0x88, 0xa6, 0x8, 0x16, 0x7b, 0x5b, 0xe7, 0x74, 0x85, 0xb5, 0x80, 0xb7, 0xa0, 0x73, 0x7f, 0x4, 0x2, + 0xc8, 0xa7, 0xce, 0x0, 0x3, 0x7b, 0x1f, 0xf2, 0x28, 0x0, 0xf, 0xc9, 0x3d, 0xb, 0x7a, 0x8e, 0x4, + 0xed, 0x7d, 0xa2, 0x24, 0x3, 0x4c, 0xe8, 0x63, 0x1e, 0x2, 0x0, 0x16, 0xf7, 0x79, 0xd9, 0xb7, 0x9e, + 0x6a, 0xf3, 0x99, 0x82, 0x75, 0x62, 0xe8, 0xc1, 0xd2, 0x14, 0x6c, 0x74, 0x4, 0x47, 0x52, 0x6e, 0x76, + 0x29, 0x0, 0x17, 0x38, 0x8c, 0x36, 0xeb, 0x54, 0xa2, 0x81, 0x4b, 0xfa, 0x9a, 0x45, 0xa3, 0x71, 0xa5, + 0xa1, 0xe9, 0xda, 0xef, 0xbf, 0xc6, 0x25, 0xd0, 0xde, 0xe, 0x0, 0x1, 0xa7, 0x20, 0x0, 0x0, 0x28, + 0x0, 0x11, 0x8a, 0x29, 0x9a, 0x90, 0x40, 0xdd, 0xae, 0xbc, 0xa, 0x8f, 0xc5, 0x9f, 0x45, 0x36, 0xbf, + 0x95, 0xfb, 0x18, 0x0, 0x10, 0x56, 0x69, 0x8c, 0x63, 0x3a, 0x49, 0x9c, 0x7f, 0xac, 0xdc, 0x41, 0x1d, + 0x39, 0x7a, 0x67, 0xa7, 0x1, 0x0, 0x14, 0xc1, 0xc6, 0xfa, 0x68, 0x8a, 0xac, 0xdb, 0x64, 0x69, 0xa3, + 0x67, 0x13, 0xba, 0x60, 0x81, 0xa2, 0xca, 0x77, 0xab, 0xfc, 0x11}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xf4, 0x45, 0xcc, 0x36, 0x4f, 0x6, 0x52, 0x53, 0x69, 0xfa, - 0xc1, 0x3a, 0x69, 0x2a, 0x4c, 0xb, 0x7b, 0x9f, 0xd4, 0xf3, - 0x21, 0x10, 0xc8, 0x6f, 0xaf, 0xac, 0xec, 0x64, 0xe8, 0x1e}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x7b, 0x1f, 0xf2}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4e, 0xf8, 0xac, 0x7, 0x37, 0x9f, 0xfa, 0x19, 0xe3, 0x7b, 0xb3, 0xc9, 0x4f, - 0xa1, 0x5a, 0x52, 0x8c, 0xfb, 0xbc, 0xcf, 0x90, 0xd4, 0x2, 0xad, 0x96, 0x77}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc9, 0x3d, 0xb, 0x7a, 0x8e, 0x4, 0xed, 0x7d, + 0xa2, 0x24, 0x3, 0x4c, 0xe8, 0x63, 0x1e}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9b, 0x57, 0xfb, 0xc, 0x6b, 0x3c, 0xc3, 0x70, - 0xb8, 0xfd, 0xaf, 0x41, 0xa2, 0xd2, 0x17}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf7, 0x79, 0xd9, 0xb7, 0x9e, 0x6a, 0xf3, 0x99, 0x82, 0x75, 0x62, + 0xe8, 0xc1, 0xd2, 0x14, 0x6c, 0x74, 0x4, 0x47, 0x52, 0x6e, 0x76}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x76, 0x10, 0xbc, 0x2, 0x47, 0x21, 0x8e, 0x57, 0xc1, 0xb6, 0xec, - 0x48, 0x0, 0xc, 0x4f, 0x24, 0x60, 0xfd, 0x65, 0x2b, 0xe, 0xd6}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x38, 0x8c, 0x36, 0xeb, 0x54, 0xa2, 0x81, 0x4b, 0xfa, 0x9a, 0x45, 0xa3, + 0x71, 0xa5, 0xa1, 0xe9, 0xda, 0xef, 0xbf, 0xc6, 0x25, 0xd0, 0xde}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa3, 0x2b, 0xf4, 0x6d, 0x20, 0x31, 0x8a, 0x6e, 0xe9, 0x81, - 0x73, 0x52, 0xb6, 0x18, 0x89, 0xc7, 0x28, 0x42, 0x42, 0x7d, - 0xca, 0xc4, 0x6d, 0xe7, 0xd0, 0x58, 0x45, 0x7a, 0x94}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa7}; + lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6a, 0x94, 0x83, 0x4b, 0x4b, 0x9b}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x59, 0xc, 0x99, 0x1f, 0xc5, 0xe4, 0x5c, 0xd3, 0xe9, 0x39, - 0x18, 0x3e, 0xed, 0xbe, 0xc1, 0xb, 0xef, 0x1d, 0x62}; - lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x8a, 0x29, 0x9a, 0x90, 0x40, 0xdd, 0xae, 0xbc, 0xa, + 0x8f, 0xc5, 0x9f, 0x45, 0x36, 0xbf, 0x95, 0xfb}; + lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x2f, 0xd, 0xbe}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x56, 0x69, 0x8c, 0x63, 0x3a, 0x49, 0x9c, 0x7f, + 0xac, 0xdc, 0x41, 0x1d, 0x39, 0x7a, 0x67, 0xa7}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x79, 0x4c, 0xfe, 0x9b, 0x30, 0x55, 0x7b, 0x10, 0xc7, 0xd3, 0xfd, 0xbd, 0xb7, - 0x46, 0x95, 0xde, 0x1f, 0xda, 0xba, 0x8, 0xaf, 0x12, 0xfc, 0x27, 0x9c}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xc1, 0xc6, 0xfa, 0x68, 0x8a, 0xac, 0xdb, 0x64, 0x69, 0xa3, + 0x67, 0x13, 0xba, 0x60, 0x81, 0xa2, 0xca, 0x77, 0xab, 0xfc}; + lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x1f, 0x26, 0xbe, 0x64, 0x3, 0x7e, 0xef, 0x2f, 0x15, 0x80, 0xe4, - 0xf0, 0x69, 0x6f, 0xe3, 0x11, 0x1a, 0x36, 0x11, 0xaf, 0x20, 0x99}; - lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[6].retain_as_published = true; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; + sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].qos = LWMQTT_QOS1; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = true; + sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - uint8_t bytesprops0[] = {0xa3, 0x5e, 0x27, 0xa3, 0x88, 0x13, 0x6e, 0x91, 0x6b, 0xd6, 0x6, 0xfa, 0x60, 0x9b}; - uint8_t bytesprops1[] = {0x14, 0x9a, 0x0, 0x9f, 0x76, 0x90, 0x2d, 0xd5, 0xf6, 0x80, 0xc0, - 0x6e, 0x46, 0x8, 0x7b, 0x18, 0x7d, 0x50, 0x3e, 0xa2, 0x59, 0x77}; - uint8_t bytesprops2[] = {0x0, 0x6e, 0x7e, 0x7d, 0x29, 0x35}; - uint8_t bytesprops3[] = {0x4, 0xb4, 0x56, 0xb6, 0x78, 0x3b, 0xfc, 0xa3, 0x30, 0x83, 0xa, 0x38, 0x19, 0xe8}; - uint8_t bytesprops4[] = {0x32}; - uint8_t bytesprops5[] = {0x68, 0x21, 0x51, 0x2c, 0xce, 0xb8, 0xd7, 0x80, 0x47, 0x3}; - uint8_t bytesprops6[] = {0x9d, 0x5a, 0x95, 0x13, 0xd5, 0xae, 0xe7, 0xf1, 0x31, 0x5b, 0xe1, 0x97, 0x7f, 0x2b, 0x5d, - 0xc, 0x54, 0x5b, 0x1c, 0xf3, 0xc6, 0xce, 0x27, 0x73, 0x49, 0xfc, 0x3e, 0x94, 0x17, 0xc2}; - uint8_t bytesprops7[] = {0x29, 0x76, 0xa0, 0x9, 0xe4, 0xd2, 0x28, 0x56, 0x41, 0x8e, 0x1b, 0xd, - 0xfd, 0x55, 0x77, 0x28, 0x73, 0x6f, 0xf8, 0xf4, 0x55, 0xc9, 0x4b}; + uint8_t bytesprops1[] = {0x3f, 0xf6, 0xb1, 0x94, 0x27, 0x24, 0x87, 0x2, 0xa1, 0x45, 0x49, 0x7d, 0x1f, 0x80, + 0x8, 0xe0, 0xab, 0x65, 0xd5, 0x45, 0x8b, 0x59, 0x76, 0x54, 0xd8, 0xcc, 0x32}; + uint8_t bytesprops0[] = {0x10, 0xfe, 0xda, 0xf6, 0x73, 0xe5, 0x7, 0x15, 0xe1, 0x6b, 0xa4}; + uint8_t bytesprops2[] = {0x53, 0x7f, 0x74, 0x5a, 0x25, 0x79, 0xbe, 0x5e, 0x35, 0xba, 0x1f, 0x1c, 0x5f}; + uint8_t bytesprops3[] = {0x44, 0x28, 0x11, 0xa0, 0x88, 0xa6, 0x8, 0x16, 0x7b, 0x5b, 0xe7, 0x74, + 0x85, 0xb5, 0x80, 0xb7, 0xa0, 0x73, 0x7f, 0x4, 0x2, 0xc8, 0xa7, 0xce}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25272}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14579}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14505}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7133}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32528}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28613}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6419}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13558}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {27, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19127}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3580, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18393, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8671 [("\137/\167\132\169\250\&8Z\230",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("vQ\229\222\160\&5\214\180",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\227~\DC4\240\205\167\163\150\&9\US\197\SIO\186>\237\168\235[",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\197\199!H\185\STX\187\SI4oM\179\237 \167(vk\193\195\&4\208\205*^\161\153\178\RS",SubOptions +// SubscribeRequest 28507 [("\146\199\232\fj\226d",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("*\213\134P\169\&0S\207\229-\255G\158",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\226\203\183\nO\231\151\nD\225\208!\169N\166\228\220#\DC2WU\SI",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\251\t\179",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("~\144J\231\"6\CAN\145#\205z]\ETXUK\212\&7\145\EOT\176\252\SO",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("a&xM$\210\&9\179\194\SI\232\178-s\215;\DC3E\193\184\RS\SOH\177:S\170\ESC\167\158\220",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\243\187\FS\201\180\223\156\vw",PropReceiveMaximum -// 3626,PropAuthenticationMethod "\158\253\DELH\181y\163\SI\161\136\137",PropUserProperty -// "O\181\137\208\192\&4\145Z\f'`\207'\213\&9++\187\SOx" "U=",PropWillDelayInterval -// 9887,PropWildcardSubscriptionAvailable 228,PropMaximumPacketSize 19549,PropAuthenticationMethod -// "\218\RS\SYN\DC3\b\CAN\220_\237\209\US\230\191\231t\129\159s$\US\\M\142&2",PropSubscriptionIdentifierAvailable 52] -TEST(Subscribe5QCTest, Encode16) { +// QoS1}),("0^\RS\201\&4\228\214UU\a.\252\227V\\\SOH\198\n.\162\217\196",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\167Y1\156C@\EOTw\191",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] +// [PropTopicAliasMaximum 10480,PropWildcardSubscriptionAvailable 100,PropRequestProblemInformation +// 123,PropTopicAliasMaximum 13965,PropSessionExpiryInterval 14160,PropMaximumQoS 235] +TEST(Subscribe5QCTest, Encode15) { uint8_t pkt[] = { - 0x82, 0xb6, 0x3, 0x21, 0xdf, 0xfc, 0x1, 0x1, 0x32, 0x26, 0x0, 0x12, 0xa6, 0xe0, 0xcc, 0x15, 0x24, 0x71, 0xb6, - 0xab, 0x16, 0x7a, 0x5e, 0xce, 0x30, 0x78, 0x1, 0x37, 0xaa, 0x44, 0x0, 0x9, 0x64, 0xa3, 0x69, 0x2e, 0xf6, 0xf2, - 0x91, 0xa3, 0xd4, 0x27, 0x0, 0x0, 0x67, 0x7a, 0x1f, 0x0, 0x1d, 0x1b, 0xec, 0x3a, 0xa6, 0x4e, 0x11, 0x8, 0xe7, - 0xe7, 0x80, 0xed, 0xae, 0xfd, 0x2b, 0xa5, 0x75, 0xc, 0x8a, 0xb8, 0x27, 0x13, 0xa1, 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x39, 0x60, 0x1d, 0xa5, 0x1e, + 0x0, 0x1d, 0x71, 0x99, 0xec, 0x5a, 0x82, 0xab, 0xd8, 0xc5, 0xe7, 0x57, 0xfd, 0xc0, 0x8b, 0x77, 0x9f, 0x8c, 0xec, + 0x5, 0xd7, 0x7e, 0xae, 0xaa, 0x74, 0x0, 0x9a, 0xb3, 0x7b, 0x1d, 0xfd, 0x21, 0x0, 0x16, 0x30, 0x5e, 0x1e, 0xc9, + 0x34, 0xe4, 0xd6, 0x55, 0x55, 0x7, 0x2e, 0xfc, 0xe3, 0x56, 0x5c, 0x1, 0xc6, 0xa, 0x2e, 0xa2, 0xd9, 0xc4, 0x18, + 0x0, 0x9, 0xa7, 0x59, 0x31, 0x9c, 0x43, 0x40, 0x4, 0x77, 0xbf, 0x2a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x89, 0x2f, 0xa7, 0x84, 0xa9, 0xfa, 0x38, 0x5a, 0xe6}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x92, 0xc7, 0xe8, 0xc, 0x6a, 0xe2, 0x64}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x76, 0x51, 0xe5, 0xde, 0xa0, 0x35, 0xd6, 0xb4}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2a, 0xd5, 0x86, 0x50, 0xa9, 0x30, 0x53, 0xcf, 0xe5, 0x2d, 0xff, 0x47, 0x9e}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe3, 0x7e, 0x14, 0xf0, 0xcd, 0xa7, 0xa3, 0x96, 0x39, 0x1f, - 0xc5, 0xf, 0x4f, 0xba, 0x3e, 0xed, 0xa8, 0xeb, 0x5b}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe2, 0xcb, 0xb7, 0xa, 0x4f, 0xe7, 0x97, 0xa, 0x44, 0xe1, 0xd0, + 0x21, 0xa9, 0x4e, 0xa6, 0xe4, 0xdc, 0x23, 0x12, 0x57, 0x55, 0xf}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc5, 0xc7, 0x21, 0x48, 0xb9, 0x2, 0xbb, 0xf, 0x34, 0x6f, - 0x4d, 0xb3, 0xed, 0x20, 0xa7, 0x28, 0x76, 0x6b, 0xc1, 0xc3, - 0x34, 0xd0, 0xcd, 0x2a, 0x5e, 0xa1, 0x99, 0xb2, 0x1e}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfb, 0x9, 0xb3}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa6, 0xbc, 0x9c, 0x49, 0xb9, 0xdc, 0x33, 0x53, 0x23}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x7e, 0x90, 0x4a, 0xe7, 0x22, 0x36, 0x18, 0x91, 0x23, 0xcd, 0x7a, + 0x5d, 0x3, 0x55, 0x4b, 0xd4, 0x37, 0x91, 0x4, 0xb0, 0xfc, 0xe}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x2e, 0xcc, 0x16, 0x74, 0x7f, 0x3, 0x56, 0x22, - 0x36, 0x1e, 0xc0, 0xc1, 0xc7, 0xe4, 0x82, 0xa0}; - lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x61, 0x26, 0x78, 0x4d, 0x24, 0xd2, 0x39, 0xb3, 0xc2, 0xf, + 0xe8, 0xb2, 0x2d, 0x73, 0xd7, 0x3b, 0x13, 0x45, 0xc1, 0xb8, + 0x1e, 0x1, 0xb1, 0x3a, 0x53, 0xaa, 0x1b, 0xa7, 0x9e, 0xdc}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x66, 0xba, 0x1f, 0xb7, 0x3b, 0x61, 0x5e, 0xb3, 0x84, 0x57, 0x64, 0x18, 0xdb}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xf3, 0x3c, 0x67, 0xd3, 0xc6, 0x22, 0x51, 0x7a, 0x75, 0xb8, + 0x52, 0x7, 0x5f, 0x63, 0x7, 0x91, 0x28, 0x7d, 0x25, 0x1a, + 0x6e, 0x31, 0x7f, 0x26, 0x20, 0x2e, 0xe4, 0xa5}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x2c, 0xa6, 0x8c, 0x4e}; - lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xf1, 0x84, 0xa1, 0x9c, 0xf4, 0x8d, 0x46, 0xda, 0xf9, + 0xc9, 0xcc, 0x90, 0xca, 0xc4, 0x39, 0x60, 0x1d, 0xa5}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xaf, 0x8e, 0xf8, 0x30, 0xe7, 0x73, 0xd4, 0xa9, 0x5e, 0x73, 0x97, - 0xd5, 0x85, 0x5b, 0x4a, 0x99, 0x4c, 0x3d, 0x1f, 0x63, 0x33}; - lwmqtt_string_t topic_filter_s8 = {21, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x71, 0x99, 0xec, 0x5a, 0x82, 0xab, 0xd8, 0xc5, 0xe7, 0x57, + 0xfd, 0xc0, 0x8b, 0x77, 0x9f, 0x8c, 0xec, 0x5, 0xd7, 0x7e, + 0xae, 0xaa, 0x74, 0x0, 0x9a, 0xb3, 0x7b, 0x1d, 0xfd}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x4a, 0xe3, 0xef, 0x1f, 0xdb, 0xa6, 0x19, 0xeb, 0x4b, 0x8, 0x38, 0x47, - 0x40, 0x9e, 0x9c, 0x6c, 0xd8, 0x78, 0x48, 0x83, 0x35, 0x7b, 0xae, 0xfd}; - lwmqtt_string_t topic_filter_s9 = {24, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0x30, 0x5e, 0x1e, 0xc9, 0x34, 0xe4, 0xd6, 0x55, 0x55, 0x7, 0x2e, + 0xfc, 0xe3, 0x56, 0x5c, 0x1, 0xc6, 0xa, 0x2e, 0xa2, 0xd9, 0xc4}; + lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s10_bytes[] = {0xa7, 0x59, 0x31, 0x9c, 0x43, 0x40, 0x4, 0x77, 0xbf}; + lwmqtt_string_t topic_filter_s10 = {9, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; + sub_opts[6].no_local = true; sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[7].retain_as_published = true; sub_opts[7].no_local = true; sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[9].retain_as_published = true; sub_opts[9].no_local = false; - uint8_t bytesprops1[] = {0x64, 0xa3, 0x69, 0x2e, 0xf6, 0xf2, 0x91, 0xa3, 0xd4}; - uint8_t bytesprops0[] = {0xa6, 0xe0, 0xcc, 0x15, 0x24, 0x71, 0xb6, 0xab, 0x16, - 0x7a, 0x5e, 0xce, 0x30, 0x78, 0x1, 0x37, 0xaa, 0x44}; - uint8_t bytesprops2[] = {0x1b, 0xec, 0x3a, 0xa6, 0x4e, 0x11, 0x8, 0xe7, 0xe7, 0x80, 0xed, 0xae, 0xfd, 0x2b, 0xa5, - 0x75, 0xc, 0x8a, 0xb8, 0x27, 0x13, 0xa1, 0xbc, 0xde, 0x50, 0xac, 0x48, 0x71, 0xde}; - uint8_t bytesprops3[] = {0xb4, 0x83, 0x4e, 0x3f, 0x5, 0x49, 0xde, 0xca, 0x78}; - uint8_t bytesprops4[] = {0xe5, 0x24, 0x7a, 0x5e, 0x5d, 0x87, 0x16, 0x3f, 0x5d, 0xbc, 0x43, 0x52, 0xa3, 0xc6, 0x58, - 0x39, 0xef, 0xdb, 0x1d, 0x6f, 0xaf, 0xe, 0x3a, 0x2c, 0xc0, 0xa9, 0xf1, 0xe, 0xe4, 0xb7}; - uint8_t bytesprops5[] = {0x8d, 0x1a, 0x40, 0x12, 0x39, 0x7a, 0xbb}; - uint8_t bytesprops6[] = {0xef, 0xb0, 0x74, 0xba, 0xb3, 0x64, 0xb5, 0xd5, 0xc3, 0x78, 0x2b, 0x6e, 0x23, 0xf9, 0x37, - 0x16, 0x54, 0xcb, 0xe, 0x2b, 0x62, 0x3e, 0xbb, 0x1c, 0xc9, 0xb4, 0xdf, 0x9c, 0xb, 0x77}; - uint8_t bytesprops7[] = {0x9e, 0xfd, 0x7f, 0x48, 0xb5, 0x79, 0xa3, 0xf, 0xa1, 0x88, 0x89}; - uint8_t bytesprops9[] = {0x55, 0x3d}; - uint8_t bytesprops8[] = {0x4f, 0xb5, 0x89, 0xd0, 0xc0, 0x34, 0x91, 0x5a, 0xc, 0x27, - 0x60, 0xcf, 0x27, 0xd5, 0x39, 0x2b, 0x2b, 0xbb, 0xe, 0x78}; - uint8_t bytesprops10[] = {0xda, 0x1e, 0x16, 0x13, 0x8, 0x18, 0xdc, 0x5f, 0xed, 0xd1, 0x1f, 0xe6, 0xbf, - 0xe7, 0x74, 0x81, 0x9f, 0x73, 0x24, 0x1f, 0x5c, 0x4d, 0x8e, 0x26, 0x32}; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops0}, .v = {9, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26490}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31181}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3626}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops8}, .v = {2, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9887}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19549}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10480}}, {.prop = (lwmqtt_prop_t)40, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 123}}, {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13965}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14160}}, {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8671, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28507, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12528 [("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\148\&2\192\239\ETBl1G.]3f\EOT\158\156\169i\146#uO\217",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\225L\215\SOHGKI\217p5\225\219\187\228,p\ENQ*\218I\194\153q",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("S\231ewx\206\160\202P",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\171Kky\198c\184w\165e^\140n\236\SI\DEL\157d;\186d\234\NUL]\161",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\183",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),(";\246\134\170\224\207z\RSCq",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = -// QoS1}),("J\FS\206NB\154\253\b\US\197\172*=\232CO\212\210\181\202\&0,&>\135\&4\224\226\170\203",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] -// [PropUserProperty "\NAK\DC1\136*\192>}\148\128\143\182\248\143\167\164\161R\143\135\SO\175zc#\DLE\167\182`{V" -// "z\RS\ESC\186\247\DC48\177",PropPayloadFormatIndicator 150,PropAuthenticationData -// "\216\234\232|\237\f\154C\179/.\217\238\166\NUL\240\174}{\139\167\223\DLE4",PropReasonString -// "]\131\200\238\255\&2\207s\EM>I\183\218\ETB\DEL\186\251\196\251Ux\248\180\132k\ETBb\227\231\214",PropContentType -// "\NAKo|\144\202XH\163\243\SOH\fM\254\184v\222\180c\163\NUL\252\247\198_S\233",PropWillDelayInterval -// 16406,PropRetainAvailable 34,PropCorrelationData "\164\164\142\237V\166\188w",PropMaximumQoS 215,PropUserProperty -// "\225\214\210\224\STX\246<\162\SYN<\209\&5!j\194\176\128\SOH\DEL<=\178" -// "P\250\214\251RO\172y\128\245G",PropResponseTopic "Tn",PropSubscriptionIdentifierAvailable 104,PropTopicAlias -// 14762,PropSubscriptionIdentifierAvailable 31,PropResponseTopic -// "[,\v\255{|py$\184NX\148\DC1|\235\225\251h\159\GSw1\211\221\EOT",PropWillDelayInterval -// 17498,PropSubscriptionIdentifierAvailable 184,PropCorrelationData -// "=\223\226S\134r\134\SIe\185\192(\130",PropServerReference -// "-\164\233J\197\192\200\216\US3%\131\156\235\b\USQ\162\SYN\215,=\GS\DC4\212",PropSessionExpiryInterval -// 9456,PropReceiveMaximum 17438,PropMessageExpiryInterval 14322,PropTopicAliasMaximum 14800,PropReasonString -// "\216B\148X\191\STX\196\231\221q\EMO\145.\216\175\150\147\176\229^\nK\228\166cJ\203|",PropServerReference "\199\225"] -TEST(Subscribe5QCTest, Encode17) { - uint8_t pkt[] = { - 0x82, 0xe5, 0x3, 0x30, 0xf0, 0xd1, 0x2, 0x26, 0x0, 0x1e, 0x15, 0x11, 0x88, 0x2a, 0xc0, 0x3e, 0x7d, 0x94, 0x80, - 0x8f, 0xb6, 0xf8, 0x8f, 0xa7, 0xa4, 0xa1, 0x52, 0x8f, 0x87, 0xe, 0xaf, 0x7a, 0x63, 0x23, 0x10, 0xa7, 0xb6, 0x60, - 0x7b, 0x56, 0x0, 0x8, 0x7a, 0x1e, 0x1b, 0xba, 0xf7, 0x14, 0x38, 0xb1, 0x1, 0x96, 0x16, 0x0, 0x18, 0xd8, 0xea, - 0xe8, 0x7c, 0xed, 0xc, 0x9a, 0x43, 0xb3, 0x2f, 0x2e, 0xd9, 0xee, 0xa6, 0x0, 0xf0, 0xae, 0x7d, 0x7b, 0x8b, 0xa7, - 0xdf, 0x10, 0x34, 0x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x7a, 0x1e, 0x43, 0x71, 0x5, 0x0, - 0x1e, 0x4a, 0x1c, 0xce, 0x4e, 0x42, 0x9a, 0xfd, 0x8, 0x1f, 0xc5, 0xac, 0x2a, 0x3d, 0xe8, 0x43, 0x4f, 0xd4, 0xd2, - 0xb5, 0xca, 0x30, 0x2c, 0x26, 0x3e, 0x87, 0x34, 0xe0, 0xe2, 0xaa, 0xcb, 0x18}; +// SubscribeRequest 23094 [("\128\&6\225\129\221\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("\163\250\137\240\239Q\202\n\217\167\232\STX\199\245m\147/\184\154\ESC\\-F\223\n\141\220\&1'\196",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\254\143\243T\251\204J",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS0}),("\250\165\218\255^o\227\134\STXZ\172\209\130\n7F\146\SO\237~H",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\173\FS\206\233\172\r\198\\\142\185*\217L1\233v`",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropTopicAlias 3117,PropMaximumPacketSize 28793] +TEST(Subscribe5QCTest, Encode16) { + uint8_t pkt[] = {0x82, 0x6b, 0x5a, 0x36, 0x8, 0x23, 0xc, 0x2d, 0x27, 0x0, 0x0, 0x70, 0x79, 0x0, 0x6, 0x80, + 0x36, 0xe1, 0x81, 0xdd, 0xaa, 0x0, 0x0, 0x1e, 0xa3, 0xfa, 0x89, 0xf0, 0xef, 0x51, 0xca, 0xa, + 0xd9, 0xa7, 0xe8, 0x2, 0xc7, 0xf5, 0x6d, 0x93, 0x2f, 0xb8, 0x9a, 0x1b, 0x5c, 0x2d, 0x46, 0xdf, + 0xa, 0x8d, 0xdc, 0x31, 0x27, 0xc4, 0x2, 0x0, 0x7, 0xfe, 0x8f, 0xf3, 0x54, 0xfb, 0xcc, 0x4a, + 0x1c, 0x0, 0x15, 0xfa, 0xa5, 0xda, 0xff, 0x5e, 0x6f, 0xe3, 0x86, 0x2, 0x5a, 0xac, 0xd1, 0x82, + 0xa, 0x37, 0x46, 0x92, 0xe, 0xed, 0x7e, 0x48, 0x10, 0x0, 0x11, 0xad, 0x1c, 0xce, 0xe9, 0xac, + 0xd, 0xc6, 0x5c, 0x8e, 0xb9, 0x2a, 0xd9, 0x4c, 0x31, 0xe9, 0x76, 0x60, 0x2e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x80, 0x36, 0xe1, 0x81, 0xdd, 0xaa}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x94, 0x32, 0xc0, 0xef, 0x17, 0x6c, 0x31, 0x47, 0x2e, 0x5d, 0x33, - 0x66, 0x4, 0x9e, 0x9c, 0xa9, 0x69, 0x92, 0x23, 0x75, 0x4f, 0xd9}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa3, 0xfa, 0x89, 0xf0, 0xef, 0x51, 0xca, 0xa, 0xd9, 0xa7, + 0xe8, 0x2, 0xc7, 0xf5, 0x6d, 0x93, 0x2f, 0xb8, 0x9a, 0x1b, + 0x5c, 0x2d, 0x46, 0xdf, 0xa, 0x8d, 0xdc, 0x31, 0x27, 0xc4}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe1, 0x4c, 0xd7, 0x1, 0x47, 0x4b, 0x49, 0xd9, 0x70, 0x35, 0xe1, 0xdb, - 0xbb, 0xe4, 0x2c, 0x70, 0x5, 0x2a, 0xda, 0x49, 0xc2, 0x99, 0x71}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xfe, 0x8f, 0xf3, 0x54, 0xfb, 0xcc, 0x4a}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x53, 0xe7, 0x65, 0x77, 0x78, 0xce, 0xa0, 0xca, 0x50}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfa, 0xa5, 0xda, 0xff, 0x5e, 0x6f, 0xe3, 0x86, 0x2, 0x5a, 0xac, + 0xd1, 0x82, 0xa, 0x37, 0x46, 0x92, 0xe, 0xed, 0x7e, 0x48}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xab, 0x4b, 0x6b, 0x79, 0xc6, 0x63, 0xb8, 0x77, 0xa5, 0x65, 0x5e, 0x8c, 0x6e, - 0xec, 0xf, 0x7f, 0x9d, 0x64, 0x3b, 0xba, 0x64, 0xea, 0x0, 0x5d, 0xa1}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xad, 0x1c, 0xce, 0xe9, 0xac, 0xd, 0xc6, 0x5c, 0x8e, + 0xb9, 0x2a, 0xd9, 0x4c, 0x31, 0xe9, 0x76, 0x60}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb7}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3b, 0xf6, 0x86, 0xaa, 0xe0, 0xcf, 0x7a, 0x1e, 0x43, 0x71}; - lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x4a, 0x1c, 0xce, 0x4e, 0x42, 0x9a, 0xfd, 0x8, 0x1f, 0xc5, - 0xac, 0x2a, 0x3d, 0xe8, 0x43, 0x4f, 0xd4, 0xd2, 0xb5, 0xca, - 0x30, 0x2c, 0x26, 0x3e, 0x87, 0x34, 0xe0, 0xe2, 0xaa, 0xcb}; - lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - uint8_t bytesprops1[] = {0x7a, 0x1e, 0x1b, 0xba, 0xf7, 0x14, 0x38, 0xb1}; - uint8_t bytesprops0[] = {0x15, 0x11, 0x88, 0x2a, 0xc0, 0x3e, 0x7d, 0x94, 0x80, 0x8f, 0xb6, 0xf8, 0x8f, 0xa7, 0xa4, - 0xa1, 0x52, 0x8f, 0x87, 0xe, 0xaf, 0x7a, 0x63, 0x23, 0x10, 0xa7, 0xb6, 0x60, 0x7b, 0x56}; - uint8_t bytesprops2[] = {0xd8, 0xea, 0xe8, 0x7c, 0xed, 0xc, 0x9a, 0x43, 0xb3, 0x2f, 0x2e, 0xd9, - 0xee, 0xa6, 0x0, 0xf0, 0xae, 0x7d, 0x7b, 0x8b, 0xa7, 0xdf, 0x10, 0x34}; - uint8_t bytesprops3[] = {0x5d, 0x83, 0xc8, 0xee, 0xff, 0x32, 0xcf, 0x73, 0x19, 0x3e, 0x49, 0xb7, 0xda, 0x17, 0x7f, - 0xba, 0xfb, 0xc4, 0xfb, 0x55, 0x78, 0xf8, 0xb4, 0x84, 0x6b, 0x17, 0x62, 0xe3, 0xe7, 0xd6}; - uint8_t bytesprops4[] = {0x15, 0x6f, 0x7c, 0x90, 0xca, 0x58, 0x48, 0xa3, 0xf3, 0x1, 0xc, 0x4d, 0xfe, - 0xb8, 0x76, 0xde, 0xb4, 0x63, 0xa3, 0x0, 0xfc, 0xf7, 0xc6, 0x5f, 0x53, 0xe9}; - uint8_t bytesprops5[] = {0xa4, 0xa4, 0x8e, 0xed, 0x56, 0xa6, 0xbc, 0x77}; - uint8_t bytesprops7[] = {0x50, 0xfa, 0xd6, 0xfb, 0x52, 0x4f, 0xac, 0x79, 0x80, 0xf5, 0x47}; - uint8_t bytesprops6[] = {0xe1, 0xd6, 0xd2, 0xe0, 0x2, 0xf6, 0x3c, 0xa2, 0x16, 0x3c, 0xd1, - 0x35, 0x21, 0x6a, 0xc2, 0xb0, 0x80, 0x1, 0x7f, 0x3c, 0x3d, 0xb2}; - uint8_t bytesprops8[] = {0x54, 0x6e}; - uint8_t bytesprops9[] = {0x5b, 0x2c, 0xb, 0xff, 0x7b, 0x7c, 0x70, 0x79, 0x24, 0xb8, 0x4e, 0x58, 0x94, - 0x11, 0x7c, 0xeb, 0xe1, 0xfb, 0x68, 0x9f, 0x1d, 0x77, 0x31, 0xd3, 0xdd, 0x4}; - uint8_t bytesprops10[] = {0x3d, 0xdf, 0xe2, 0x53, 0x86, 0x72, 0x86, 0xf, 0x65, 0xb9, 0xc0, 0x28, 0x82}; - uint8_t bytesprops11[] = {0x2d, 0xa4, 0xe9, 0x4a, 0xc5, 0xc0, 0xc8, 0xd8, 0x1f, 0x33, 0x25, 0x83, 0x9c, - 0xeb, 0x8, 0x1f, 0x51, 0xa2, 0x16, 0xd7, 0x2c, 0x3d, 0x1d, 0x14, 0xd4}; - uint8_t bytesprops12[] = {0xd8, 0x42, 0x94, 0x58, 0xbf, 0x2, 0xc4, 0xe7, 0xdd, 0x71, 0x19, 0x4f, 0x91, 0x2e, 0xd8, - 0xaf, 0x96, 0x93, 0xb0, 0xe5, 0x5e, 0xa, 0x4b, 0xe4, 0xa6, 0x63, 0x4a, 0xcb, 0x7c}; - uint8_t bytesprops13[] = {0xc7, 0xe1}; + sub_opts[4].no_local = true; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16406}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops6}, .v = {11, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14762}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17498}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9456}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17438}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14322}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14800}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3117}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28793}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12528, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23094, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9386 [("\209\EM\NUL~%q\250\200\SYNf]\226\199+9\165'\162\178V\208\DLE",SubOptions {_retainHandling = +// SubscribeRequest 7726 [("\143]\132\&9x\254\"\152\138W\190\240~u#\177Q[\204\&6\241v\167J\b",PropCorrelationData -// "\254\218+C@/\128\231}\222\129\132G\228\DC3\199]w\137\NAK\158$@B\206",PropMessageExpiryInterval -// 5811,PropServerReference -// "\221\254\174Z\158\172\228_\241e#\EOTa\168\245j\219\159\FS\n\175n\NUL\184\241",PropCorrelationData -// "*\163A\181|\130\233l\145H\201\ETB\166\178x\161\"\aTU",PropAuthenticationMethod "",PropWillDelayInterval -// 25248,PropSubscriptionIdentifierAvailable 210,PropWildcardSubscriptionAvailable 146,PropAuthenticationMethod -// "\244V\207\207\n'1\ACK\169\DC2=\173\140\231\197G\DC2M5+\DC3"] -TEST(Subscribe5QCTest, Encode18) { - uint8_t pkt[] = { - 0x82, 0xe0, 0x1, 0x24, 0xaa, 0x99, 0x1, 0x8, 0x0, 0x1e, 0x85, 0x3d, 0x19, 0xe5, 0x1a, 0xa2, 0xfc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0xd6, 0x43, 0x4c, 0x38, 0x8b, 0x14, - 0x0, 0xf, 0x28, 0x70, 0x6e, 0xf2, 0xa6, 0xaf, 0x75, 0x71, 0xd6, 0xf5, 0x8e, 0xb, 0x5a, 0x52, 0xd1, 0x1a}; +// QoS0}),("\164\238\144r\220E\CANQ\216\130\171\SYN)D\160\179U",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropServerKeepAlive 10066,PropMaximumQoS +// 119,PropSessionExpiryInterval 12417,PropAuthenticationMethod +// "\186\244\151\226\na\139\155\239\133t\NAKg\RS$\238\SO",PropWildcardSubscriptionAvailable 179,PropTopicAliasMaximum +// 21147] +TEST(Subscribe5QCTest, Encode17) { + uint8_t pkt[] = {0x82, 0x9e, 0x2, 0x1e, 0x2e, 0x23, 0x13, 0x27, 0x52, 0x24, 0x77, 0x11, 0x0, 0x0, 0x30, 0x81, 0x15, + 0x0, 0x11, 0xba, 0xf4, 0x97, 0xe2, 0xa, 0x61, 0x8b, 0x9b, 0xef, 0x85, 0x74, 0x15, 0x67, 0x1e, 0x24, + 0xee, 0xe, 0x28, 0xb3, 0x22, 0x52, 0x9b, 0x0, 0x1d, 0x8f, 0x5d, 0x84, 0x39, 0x78, 0xfe, 0x22, 0x98, + 0x8a, 0x57, 0xbe, 0xf0, 0x7e, 0x3c, 0x55, 0xb2, 0xb6, 0x69, 0x4a, 0x71, 0xe4, 0x87, 0x4e, 0x0, 0x9c, + 0x6d, 0xb9, 0xe8, 0xfe, 0x6, 0x0, 0x19, 0xc3, 0xcd, 0xec, 0x1f, 0x78, 0x25, 0xbd, 0xb5, 0xd7, 0x62, + 0xb2, 0xa0, 0xa4, 0x75, 0xf1, 0x2a, 0xe2, 0x8d, 0x56, 0x3d, 0x39, 0x74, 0xe4, 0x28, 0xe4, 0x15, 0x0, + 0x17, 0x6e, 0xe, 0x47, 0xa4, 0xa6, 0x21, 0x18, 0xf1, 0x18, 0x4c, 0xa6, 0xaa, 0x41, 0x54, 0xdc, 0xba, + 0x88, 0xc2, 0xa3, 0xdf, 0xd1, 0xe9, 0x3b, 0x2e, 0x0, 0x19, 0x8e, 0x10, 0x47, 0x18, 0x44, 0x58, 0x38, + 0x1d, 0x70, 0xdf, 0x89, 0xf8, 0x57, 0x62, 0x35, 0x1e, 0x9d, 0xd6, 0x8e, 0x16, 0xb1, 0x4b, 0x5, 0x72, + 0x0, 0x9, 0x0, 0x17, 0xd4, 0x72, 0x5, 0xdf, 0x56, 0x6a, 0x65, 0x3b, 0x72, 0xc1, 0x89, 0x41, 0x53, + 0x36, 0xef, 0x31, 0xa7, 0x7e, 0xc0, 0x32, 0xae, 0x71, 0xf3, 0x4, 0x0, 0xa, 0x2b, 0x10, 0x2e, 0x88, + 0x4, 0x8b, 0xaf, 0xb7, 0xbf, 0xb5, 0x0, 0x0, 0x4, 0xaa, 0x46, 0x6e, 0x9e, 0x2e, 0x0, 0xa, 0xe9, + 0x2f, 0xb0, 0x8, 0x72, 0x24, 0x63, 0x9e, 0xb, 0xe8, 0x22, 0x0, 0x16, 0x68, 0x2d, 0xc4, 0xb1, 0xbd, + 0xfa, 0x4a, 0x18, 0x45, 0xec, 0x9a, 0xda, 0x83, 0x8e, 0xb7, 0x6, 0xf7, 0x9a, 0xa9, 0x23, 0xcf, 0x63, + 0x18, 0x0, 0x1b, 0x54, 0xe7, 0xa, 0xd, 0x2c, 0x30, 0x33, 0x21, 0x87, 0x12, 0xe1, 0x6c, 0x55, 0x3f, + 0xf, 0x84, 0xd0, 0xfe, 0xa4, 0x9f, 0xb1, 0xc3, 0x9, 0x84, 0xdc, 0x6a, 0x3f, 0x14, 0x0, 0x11, 0xa4, + 0xee, 0x90, 0x72, 0xdc, 0x45, 0x18, 0x51, 0xd8, 0x82, 0xab, 0x16, 0x29, 0x44, 0xa0, 0xb3, 0x55, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xd1, 0x19, 0x0, 0x7e, 0x25, 0x71, 0xfa, 0xc8, 0x16, 0x66, 0x5d, - 0xe2, 0xc7, 0x2b, 0x39, 0xa5, 0x27, 0xa2, 0xb2, 0x56, 0xd0, 0x10}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x8f, 0x5d, 0x84, 0x39, 0x78, 0xfe, 0x22, 0x98, 0x8a, 0x57, + 0xbe, 0xf0, 0x7e, 0x3c, 0x55, 0xb2, 0xb6, 0x69, 0x4a, 0x71, + 0xe4, 0x87, 0x4e, 0x0, 0x9c, 0x6d, 0xb9, 0xe8, 0xfe}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa, 0x17, 0x82, 0xf5, 0x87, 0xd5, 0xf5, 0x8a, 0x36, 0x45, 0xdd, - 0x4d, 0x12, 0x5d, 0xaf, 0xc6, 0xd6, 0x43, 0x4c, 0x38, 0x8b}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc3, 0xcd, 0xec, 0x1f, 0x78, 0x25, 0xbd, 0xb5, 0xd7, 0x62, 0xb2, 0xa0, 0xa4, + 0x75, 0xf1, 0x2a, 0xe2, 0x8d, 0x56, 0x3d, 0x39, 0x74, 0xe4, 0x28, 0xe4}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x28, 0x70, 0x6e, 0xf2, 0xa6, 0xaf, 0x75, 0x71, - 0xd6, 0xf5, 0x8e, 0xb, 0x5a, 0x52, 0xd1}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6e, 0xe, 0x47, 0xa4, 0xa6, 0x21, 0x18, 0xf1, 0x18, 0x4c, 0xa6, 0xaa, + 0x41, 0x54, 0xdc, 0xba, 0x88, 0xc2, 0xa3, 0xdf, 0xd1, 0xe9, 0x3b}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + uint8_t topic_filter_s3_bytes[] = {0x8e, 0x10, 0x47, 0x18, 0x44, 0x58, 0x38, 0x1d, 0x70, 0xdf, 0x89, 0xf8, 0x57, + 0x62, 0x35, 0x1e, 0x9d, 0xd6, 0x8e, 0x16, 0xb1, 0x4b, 0x5, 0x72, 0x0}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd4, 0x72, 0x5, 0xdf, 0x56, 0x6a, 0x65, 0x3b, 0x72, 0xc1, 0x89, 0x41, + 0x53, 0x36, 0xef, 0x31, 0xa7, 0x7e, 0xc0, 0x32, 0xae, 0x71, 0xf3}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x2b, 0x10, 0x2e, 0x88, 0x4, 0x8b, 0xaf, 0xb7, 0xbf, 0xb5}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xaa, 0x46, 0x6e, 0x9e}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe9, 0x2f, 0xb0, 0x8, 0x72, 0x24, 0x63, 0x9e, 0xb, 0xe8}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x68, 0x2d, 0xc4, 0xb1, 0xbd, 0xfa, 0x4a, 0x18, 0x45, 0xec, 0x9a, + 0xda, 0x83, 0x8e, 0xb7, 0x6, 0xf7, 0x9a, 0xa9, 0x23, 0xcf, 0x63}; + lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x54, 0xe7, 0xa, 0xd, 0x2c, 0x30, 0x33, 0x21, 0x87, 0x12, 0xe1, 0x6c, 0x55, 0x3f, + 0xf, 0x84, 0xd0, 0xfe, 0xa4, 0x9f, 0xb1, 0xc3, 0x9, 0x84, 0xdc, 0x6a, 0x3f}; + lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xa4, 0xee, 0x90, 0x72, 0xdc, 0x45, 0x18, 0x51, 0xd8, + 0x82, 0xab, 0x16, 0x29, 0x44, 0xa0, 0xb3, 0x55}; + lwmqtt_string_t topic_filter_s10 = {17, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - uint8_t bytesprops0[] = {0x85, 0x3d, 0x19, 0xe5, 0x1a, 0xa2, 0xfc, 0x4b, 0xac, 0x76, 0xf0, 0x7, 0xc2, 0x50, 0x86, - 0x58, 0xff, 0x3e, 0x75, 0x23, 0xb1, 0x51, 0x5b, 0xcc, 0x36, 0xf1, 0x76, 0xa7, 0x4a, 0x8}; - uint8_t bytesprops1[] = {0xfe, 0xda, 0x2b, 0x43, 0x40, 0x2f, 0x80, 0xe7, 0x7d, 0xde, 0x81, 0x84, 0x47, - 0xe4, 0x13, 0xc7, 0x5d, 0x77, 0x89, 0x15, 0x9e, 0x24, 0x40, 0x42, 0xce}; - uint8_t bytesprops2[] = {0xdd, 0xfe, 0xae, 0x5a, 0x9e, 0xac, 0xe4, 0x5f, 0xf1, 0x65, 0x23, 0x4, 0x61, - 0xa8, 0xf5, 0x6a, 0xdb, 0x9f, 0x1c, 0xa, 0xaf, 0x6e, 0x0, 0xb8, 0xf1}; - uint8_t bytesprops3[] = {0x2a, 0xa3, 0x41, 0xb5, 0x7c, 0x82, 0xe9, 0x6c, 0x91, 0x48, - 0xc9, 0x17, 0xa6, 0xb2, 0x78, 0xa1, 0x22, 0x7, 0x54, 0x55}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0xf4, 0x56, 0xcf, 0xcf, 0xa, 0x27, 0x31, 0x6, 0xa9, 0x12, 0x3d, - 0xad, 0x8c, 0xe7, 0xc5, 0x47, 0x12, 0x4d, 0x35, 0x2b, 0x13}; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = true; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; + uint8_t bytesprops0[] = {0xba, 0xf4, 0x97, 0xe2, 0xa, 0x61, 0x8b, 0x9b, 0xef, + 0x85, 0x74, 0x15, 0x67, 0x1e, 0x24, 0xee, 0xe}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5811}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25248}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10066}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12417}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21147}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9386, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7726, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 17533 [("(\v5\187IR\198\&8\215Mh\DC1\234\194",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("_E",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\166GM",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\216\209{\247V0\206\253\155\DC4\CAN",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = True, _noLocal = True, _subQoS = QoS2}),(",\170\200\239\ETX\218}\155\195\194\177faHsp\134\SI",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\140\140\rH\207f*P<\249\191k\ETB\229\141\224Y\138\SI\SYN\251;\DC12M",SubOptions {_retainHandling = +// SubscribeRequest 1195 [("\ETX\191\156\US3\137\&5\190a",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\165\NAK\196P +// \236\172\197M\140\177r\SUB\159",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal +// = True, _subQoS = QoS0}),("\RS\207\192\216\168",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// True, _noLocal = False, _subQoS = +// QoS0}),("3\221i\DC1\162\226\214EnW\250\156\230\182;V\195\230d\NUL\174<\173J\139\160",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\250u\151\159P'\139\EM\157U\250+\NAKH\146+V\202Rz",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\199USx\174ia\GSz\ACK\DC2\\)\192\SOHC\142`/|\206J`DO",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\234\194\129~z9_E\fvk\232\168i1})/\136RT\141\170\184:\210@\227I",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("D\169\215/0R\DEL\201>\234\155>\147W\SOv%\NAK\US\230l",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\155\"\219\&9`\138\145\182\&3\178\147\226G\a[h\191`\212`\185\143",SubOptions {_retainHandling = // SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("j\234\196n\SUB\146\132\168?\155F\190)\137\235.\233\224\135\138\DC1\a#\GS",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("83\213v",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropResponseInformation "\r\163U7\225\141/\215\229\216\162",PropAuthenticationData -// "\204V\133\RS{k\233\236\248!:\CAN\DEL\GS\189",PropRetainAvailable 207,PropPayloadFormatIndicator -// 122,PropWillDelayInterval 24641,PropAssignedClientIdentifier -// "\ESC\180\219\212\&2#]8\129\US?",PropSessionExpiryInterval 29296,PropContentType -// "\190\CAN\221U\133P",PropSharedSubscriptionAvailable 51,PropRequestProblemInformation 42,PropWillDelayInterval -// 6999,PropMaximumPacketSize 24918,PropUserProperty -// "SE\183+\172\213\142>\SIL0\153q\166\229\172\224K\171\144\145>\233a\132%\181\r" -// "\216\141\145\210\176{\195",PropRequestResponseInformation 108,PropUserProperty "|\SYN\EMo\214\192\154M\235" -// "\196p\SI\230\158\207\157\196\252\211\175\143p",PropSubscriptionIdentifier 9,PropMaximumPacketSize -// 28386,PropReceiveMaximum 8213,PropSharedSubscriptionAvailable 114,PropSharedSubscriptionAvailable -// 174,PropTopicAliasMaximum 14924] -TEST(Subscribe5QCTest, Encode19) { +// QoS0}),("a]\205\220o\197]\139qT\177$?P\151\158\141=\231\157\249k\231H\159\163.",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropCorrelationData +// "\173\161\DC1\166\244Z\167\&1\139Po\237\170\193\138=\244\187",PropWillDelayInterval 12750,PropSubscriptionIdentifier +// 6,PropReasonString "*\162\180\&3\182\222\210\250Y\189\&5m\253\172",PropRequestResponseInformation 6,PropResponseTopic +// "\DEL\204\228\143\203K\254B4\181\NULA\DELRe\245\223\183\237%x0*\240*c",PropWillDelayInterval 1053,PropServerReference +// "h\ETXm`\226\164\&3\178qd{\154\183y",PropRequestProblemInformation 21,PropMaximumPacketSize +// 31500,PropRequestResponseInformation 119,PropMaximumPacketSize 10228,PropServerKeepAlive 10977,PropResponseTopic +// "/\167\&6\228JC\209\207\DC4\214_|R\207!\133\SOHB",PropWillDelayInterval 10162,PropSessionExpiryInterval +// 24718,PropAuthenticationData "\227\214\EOT\SO\235n\144\232",PropSharedSubscriptionAvailable +// 176,PropPayloadFormatIndicator 55] +TEST(Subscribe5QCTest, Encode18) { uint8_t pkt[] = { - 0x82, 0xaa, 0x2, 0x44, 0x7d, 0xa9, 0x1, 0x1a, 0x0, 0xb, 0xd, 0xa3, 0x55, 0x37, 0xe1, 0x8d, 0x2f, 0xd7, 0xe5, - 0xd8, 0xa2, 0x16, 0x0, 0xf, 0xcc, 0x56, 0x85, 0x1e, 0x7b, 0x6b, 0xe9, 0xec, 0xf8, 0x21, 0x3a, 0x18, 0x7f, 0x1d, - 0xbd, 0x25, 0xcf, 0x1, 0x7a, 0x18, 0x0, 0x0, 0x60, 0x41, 0x12, 0x0, 0xb, 0x1b, 0xb4, 0xdb, 0xd4, 0x32, 0x23, - 0x5d, 0x38, 0x81, 0x1f, 0x3f, 0x11, 0x0, 0x0, 0x72, 0x70, 0x3, 0x0, 0x6, 0xbe, 0x18, 0xdd, 0x55, 0x85, 0x50, - 0x2a, 0x33, 0x17, 0x2a, 0x18, 0x0, 0x0, 0x1b, 0x57, 0x27, 0x0, 0x0, 0x61, 0x56, 0x26, 0x0, 0x1c, 0x53, 0x45, - 0xb7, 0x2b, 0xac, 0xd5, 0x8e, 0x3e, 0xf, 0x4c, 0x30, 0x99, 0x71, 0xa6, 0xe5, 0xac, 0xe0, 0x4b, 0xab, 0x90, 0x91, - 0x3e, 0xe9, 0x61, 0x84, 0x25, 0xb5, 0xd, 0x0, 0x7, 0xd8, 0x8d, 0x91, 0xd2, 0xb0, 0x7b, 0xc3, 0x19, 0x6c, 0x26, - 0x0, 0x9, 0x7c, 0x16, 0x19, 0x6f, 0xd6, 0xc0, 0x9a, 0x4d, 0xeb, 0x0, 0xd, 0xc4, 0x70, 0xf, 0xe6, 0x9e, 0xcf, - 0x9d, 0xc4, 0xfc, 0xd3, 0xaf, 0x8f, 0x70, 0xb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 0x8b, 0xa0, 0x9, 0x0, 0x14, 0xfa, 0x75, 0x97, 0x9f, 0x50, 0x27, 0x8b, 0x19, 0x9d, 0x55, 0xfa, + 0x2b, 0x15, 0x48, 0x92, 0x2b, 0x56, 0xca, 0x52, 0x7a, 0x25, 0x0, 0x19, 0xc7, 0x55, 0x53, 0x78, 0xae, 0x69, 0x61, + 0x1d, 0x7a, 0x6, 0x12, 0x5c, 0x29, 0xc0, 0x1, 0x43, 0x8e, 0x60, 0x2f, 0x7c, 0xce, 0x4a, 0x60, 0x44, 0x4f, 0x25, + 0x0, 0x1d, 0xea, 0xc2, 0x81, 0x7e, 0x7a, 0x39, 0x5f, 0x45, 0xc, 0x76, 0x6b, 0xe8, 0xa8, 0x69, 0x31, 0x7d, 0x29, + 0x2f, 0x88, 0x52, 0x54, 0x8d, 0xaa, 0xb8, 0x3a, 0xd2, 0x40, 0xe3, 0x49, 0x5, 0x0, 0x15, 0x44, 0xa9, 0xd7, 0x2f, + 0x30, 0x52, 0x7f, 0xc9, 0x3e, 0xea, 0x9b, 0x3e, 0x93, 0x57, 0xe, 0x76, 0x25, 0x15, 0x1f, 0xe6, 0x6c, 0x5, 0x0, + 0x16, 0x9b, 0x22, 0xdb, 0x39, 0x60, 0x8a, 0x91, 0xb6, 0x33, 0xb2, 0x93, 0xe2, 0x47, 0x7, 0x5b, 0x68, 0xbf, 0x60, + 0xd4, 0x60, 0xb9, 0x8f, 0x1c, 0x0, 0x1b, 0x61, 0x5d, 0xcd, 0xdc, 0x6f, 0xc5, 0x5d, 0x8b, 0x71, 0x54, 0xb1, 0x24, + 0x3f, 0x50, 0x97, 0x9e, 0x8d, 0x3d, 0xe7, 0x9d, 0xf9, 0x6b, 0xe7, 0x48, 0x9f, 0xa3, 0x2e, 0x25}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x28, 0xb, 0x35, 0xbb, 0x49, 0x52, 0xc6, 0x38, 0xd7, 0x4d, 0x68, 0x11, 0xea, 0xc2}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x3, 0xbf, 0x9c, 0x1f, 0x33, 0x89, 0x35, 0xbe, 0x61}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5f, 0x45}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa5, 0x15, 0xc4, 0x50, 0x20, 0xec, 0xac, + 0xc5, 0x4d, 0x8c, 0xb1, 0x72, 0x1a, 0x9f}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa6, 0x47, 0x4d}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1e, 0xcf, 0xc0, 0xd8, 0xa8}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd8, 0xd1, 0x7b, 0xf7, 0x56, 0x30, 0xce, 0xfd, 0x9b, 0x14, 0x18}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x33, 0xdd, 0x69, 0x11, 0xa2, 0xe2, 0xd6, 0x45, 0x6e, 0x57, 0xfa, 0x9c, 0xe6, + 0xb6, 0x3b, 0x56, 0xc3, 0xe6, 0x64, 0x0, 0xae, 0x3c, 0xad, 0x4a, 0x8b, 0xa0}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2c, 0xaa, 0xc8, 0xef, 0x3, 0xda, 0x7d, 0x9b, 0xc3, - 0xc2, 0xb1, 0x66, 0x61, 0x48, 0x73, 0x70, 0x86, 0xf}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xfa, 0x75, 0x97, 0x9f, 0x50, 0x27, 0x8b, 0x19, 0x9d, 0x55, + 0xfa, 0x2b, 0x15, 0x48, 0x92, 0x2b, 0x56, 0xca, 0x52, 0x7a}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8c, 0x8c, 0xd, 0x48, 0xcf, 0x66, 0x2a, 0x50, 0x3c, 0xf9, 0xbf, 0x6b, 0x17, - 0xe5, 0x8d, 0xe0, 0x59, 0x8a, 0xf, 0x16, 0xfb, 0x3b, 0x11, 0x32, 0x4d}; + uint8_t topic_filter_s5_bytes[] = {0xc7, 0x55, 0x53, 0x78, 0xae, 0x69, 0x61, 0x1d, 0x7a, 0x6, 0x12, 0x5c, 0x29, + 0xc0, 0x1, 0x43, 0x8e, 0x60, 0x2f, 0x7c, 0xce, 0x4a, 0x60, 0x44, 0x4f}; lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6a, 0xea, 0xc4, 0x6e, 0x1a, 0x92, 0x84, 0xa8, 0x3f, 0x9b, 0x46, 0xbe, - 0x29, 0x89, 0xeb, 0x2e, 0xe9, 0xe0, 0x87, 0x8a, 0x11, 0x7, 0x23, 0x1d}; - lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xea, 0xc2, 0x81, 0x7e, 0x7a, 0x39, 0x5f, 0x45, 0xc, 0x76, + 0x6b, 0xe8, 0xa8, 0x69, 0x31, 0x7d, 0x29, 0x2f, 0x88, 0x52, + 0x54, 0x8d, 0xaa, 0xb8, 0x3a, 0xd2, 0x40, 0xe3, 0x49}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x38, 0x33, 0xd5, 0x76}; - lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x44, 0xa9, 0xd7, 0x2f, 0x30, 0x52, 0x7f, 0xc9, 0x3e, 0xea, 0x9b, + 0x3e, 0x93, 0x57, 0xe, 0x76, 0x25, 0x15, 0x1f, 0xe6, 0x6c}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s8_bytes[] = {0x9b, 0x22, 0xdb, 0x39, 0x60, 0x8a, 0x91, 0xb6, 0x33, 0xb2, 0x93, + 0xe2, 0x47, 0x7, 0x5b, 0x68, 0xbf, 0x60, 0xd4, 0x60, 0xb9, 0x8f}; + lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x61, 0x5d, 0xcd, 0xdc, 0x6f, 0xc5, 0x5d, 0x8b, 0x71, 0x54, 0xb1, 0x24, 0x3f, 0x50, + 0x97, 0x9e, 0x8d, 0x3d, 0xe7, 0x9d, 0xf9, 0x6b, 0xe7, 0x48, 0x9f, 0xa3, 0x2e}; + lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = true; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; sub_opts[5].no_local = true; sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - uint8_t bytesprops0[] = {0xd, 0xa3, 0x55, 0x37, 0xe1, 0x8d, 0x2f, 0xd7, 0xe5, 0xd8, 0xa2}; - uint8_t bytesprops1[] = {0xcc, 0x56, 0x85, 0x1e, 0x7b, 0x6b, 0xe9, 0xec, 0xf8, 0x21, 0x3a, 0x18, 0x7f, 0x1d, 0xbd}; - uint8_t bytesprops2[] = {0x1b, 0xb4, 0xdb, 0xd4, 0x32, 0x23, 0x5d, 0x38, 0x81, 0x1f, 0x3f}; - uint8_t bytesprops3[] = {0xbe, 0x18, 0xdd, 0x55, 0x85, 0x50}; - uint8_t bytesprops5[] = {0xd8, 0x8d, 0x91, 0xd2, 0xb0, 0x7b, 0xc3}; - uint8_t bytesprops4[] = {0x53, 0x45, 0xb7, 0x2b, 0xac, 0xd5, 0x8e, 0x3e, 0xf, 0x4c, 0x30, 0x99, 0x71, 0xa6, - 0xe5, 0xac, 0xe0, 0x4b, 0xab, 0x90, 0x91, 0x3e, 0xe9, 0x61, 0x84, 0x25, 0xb5, 0xd}; - uint8_t bytesprops7[] = {0xc4, 0x70, 0xf, 0xe6, 0x9e, 0xcf, 0x9d, 0xc4, 0xfc, 0xd3, 0xaf, 0x8f, 0x70}; - uint8_t bytesprops6[] = {0x7c, 0x16, 0x19, 0x6f, 0xd6, 0xc0, 0x9a, 0x4d, 0xeb}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24641}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29296}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6999}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24918}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops4}, .v = {7, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops6}, .v = {13, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28386}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8213}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14924}}, - }; - - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17533, 8, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 1875 [("\131\239*\255VM\230[\170\a\ACK|\132\249\176v\212",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropResponseInformation -// "Z\196",PropWildcardSubscriptionAvailable 183,PropServerKeepAlive 24665,PropWillDelayInterval 7907,PropMaximumQoS -// 22,PropPayloadFormatIndicator 100,PropRequestProblemInformation 248,PropWillDelayInterval 3496,PropMaximumPacketSize -// 21061,PropTopicAliasMaximum 21354,PropResponseTopic "\247\227\&7",PropSubscriptionIdentifier 15,PropWillDelayInterval -// 24629,PropUserProperty "\234\140\175<\234#\180\&0\FS\249!\169\243\165\210\240\ACK\200" -// "N\GS\CAN\160\219\167D\169\223\160\164\"\222\153\192~\235\131\&6p\248\a\246\162",PropAuthenticationMethod -// "\193\252\143U}\151+=\249i5\DC2;\149g\183\a]",PropSubscriptionIdentifier 0,PropWildcardSubscriptionAvailable -// 237,PropWillDelayInterval 6547,PropServerReference -// "sa\133\247\251\132\245\185\148\232\145F?\181",PropRequestResponseInformation 207,PropTopicAliasMaximum -// 12816,PropRetainAvailable 145,PropTopicAliasMaximum 27568,PropMaximumPacketSize 25047,PropMessageExpiryInterval -// 18783,PropSubscriptionIdentifier 6,PropMaximumPacketSize 32075,PropUserProperty "\a\185\225\135Q&\200" -// "\247\191\178F",PropMessageExpiryInterval 13005,PropMaximumQoS 23] -TEST(Subscribe5QCTest, Encode20) { - uint8_t pkt[] = {0x82, 0xd7, 0x1, 0x7, 0x53, 0xbf, 0x1, 0x1a, 0x0, 0x2, 0x5a, 0xc4, 0x28, 0xb7, 0x13, 0x60, 0x59, - 0x18, 0x0, 0x0, 0x1e, 0xe3, 0x24, 0x16, 0x1, 0x64, 0x17, 0xf8, 0x18, 0x0, 0x0, 0xd, 0xa8, 0x27, - 0x0, 0x0, 0x52, 0x45, 0x22, 0x53, 0x6a, 0x8, 0x0, 0x3, 0xf7, 0xe3, 0x37, 0xb, 0xf, 0x18, 0x0, - 0x0, 0x60, 0x35, 0x26, 0x0, 0x12, 0xea, 0x8c, 0xaf, 0x3c, 0xea, 0x23, 0xb4, 0x30, 0x1c, 0xf9, 0x21, - 0xa9, 0xf3, 0xa5, 0xd2, 0xf0, 0x6, 0xc8, 0x0, 0x18, 0x4e, 0x1d, 0x18, 0xa0, 0xdb, 0xa7, 0x44, 0xa9, - 0xdf, 0xa0, 0xa4, 0x22, 0xde, 0x99, 0xc0, 0x7e, 0xeb, 0x83, 0x36, 0x70, 0xf8, 0x7, 0xf6, 0xa2, 0x15, - 0x0, 0x12, 0xc1, 0xfc, 0x8f, 0x55, 0x7d, 0x97, 0x2b, 0x3d, 0xf9, 0x69, 0x35, 0x12, 0x3b, 0x95, 0x67, - 0xb7, 0x7, 0x5d, 0xb, 0x0, 0x28, 0xed, 0x18, 0x0, 0x0, 0x19, 0x93, 0x1c, 0x0, 0xe, 0x73, 0x61, - 0x85, 0xf7, 0xfb, 0x84, 0xf5, 0xb9, 0x94, 0xe8, 0x91, 0x46, 0x3f, 0xb5, 0x19, 0xcf, 0x22, 0x32, 0x10, - 0x25, 0x91, 0x22, 0x6b, 0xb0, 0x27, 0x0, 0x0, 0x61, 0xd7, 0x2, 0x0, 0x0, 0x49, 0x5f, 0xb, 0x6, - 0x27, 0x0, 0x0, 0x7d, 0x4b, 0x26, 0x0, 0x7, 0x7, 0xb9, 0xe1, 0x87, 0x51, 0x26, 0xc8, 0x0, 0x4, - 0xf7, 0xbf, 0xb2, 0x46, 0x2, 0x0, 0x0, 0x32, 0xcd, 0x24, 0x17, 0x0, 0x11, 0x83, 0xef, 0x2a, 0xff, - 0x56, 0x4d, 0xe6, 0x5b, 0xaa, 0x7, 0x6, 0x7c, 0x84, 0xf9, 0xb0, 0x76, 0xd4, 0x6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x83, 0xef, 0x2a, 0xff, 0x56, 0x4d, 0xe6, 0x5b, 0xaa, - 0x7, 0x6, 0x7c, 0x84, 0xf9, 0xb0, 0x76, 0xd4}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - uint8_t bytesprops0[] = {0x5a, 0xc4}; - uint8_t bytesprops1[] = {0xf7, 0xe3, 0x37}; - uint8_t bytesprops3[] = {0x4e, 0x1d, 0x18, 0xa0, 0xdb, 0xa7, 0x44, 0xa9, 0xdf, 0xa0, 0xa4, 0x22, - 0xde, 0x99, 0xc0, 0x7e, 0xeb, 0x83, 0x36, 0x70, 0xf8, 0x7, 0xf6, 0xa2}; - uint8_t bytesprops2[] = {0xea, 0x8c, 0xaf, 0x3c, 0xea, 0x23, 0xb4, 0x30, 0x1c, - 0xf9, 0x21, 0xa9, 0xf3, 0xa5, 0xd2, 0xf0, 0x6, 0xc8}; - uint8_t bytesprops4[] = {0xc1, 0xfc, 0x8f, 0x55, 0x7d, 0x97, 0x2b, 0x3d, 0xf9, - 0x69, 0x35, 0x12, 0x3b, 0x95, 0x67, 0xb7, 0x7, 0x5d}; - uint8_t bytesprops5[] = {0x73, 0x61, 0x85, 0xf7, 0xfb, 0x84, 0xf5, 0xb9, 0x94, 0xe8, 0x91, 0x46, 0x3f, 0xb5}; - uint8_t bytesprops7[] = {0xf7, 0xbf, 0xb2, 0x46}; - uint8_t bytesprops6[] = {0x7, 0xb9, 0xe1, 0x87, 0x51, 0x26, 0xc8}; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = true; + uint8_t bytesprops0[] = {0xad, 0xa1, 0x11, 0xa6, 0xf4, 0x5a, 0xa7, 0x31, 0x8b, + 0x50, 0x6f, 0xed, 0xaa, 0xc1, 0x8a, 0x3d, 0xf4, 0xbb}; + uint8_t bytesprops1[] = {0x2a, 0xa2, 0xb4, 0x33, 0xb6, 0xde, 0xd2, 0xfa, 0x59, 0xbd, 0x35, 0x6d, 0xfd, 0xac}; + uint8_t bytesprops2[] = {0x7f, 0xcc, 0xe4, 0x8f, 0xcb, 0x4b, 0xfe, 0x42, 0x34, 0xb5, 0x0, 0x41, 0x7f, + 0x52, 0x65, 0xf5, 0xdf, 0xb7, 0xed, 0x25, 0x78, 0x30, 0x2a, 0xf0, 0x2a, 0x63}; + uint8_t bytesprops3[] = {0x68, 0x3, 0x6d, 0x60, 0xe2, 0xa4, 0x33, 0xb2, 0x71, 0x64, 0x7b, 0x9a, 0xb7, 0x79}; + uint8_t bytesprops4[] = {0x2f, 0xa7, 0x36, 0xe4, 0x4a, 0x43, 0xd1, 0xcf, 0x14, + 0xd6, 0x5f, 0x7c, 0x52, 0xcf, 0x21, 0x85, 0x1, 0x42}; + uint8_t bytesprops5[] = {0xe3, 0xd6, 0x4, 0xe, 0xeb, 0x6e, 0x90, 0xe8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24665}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7907}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3496}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21061}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21354}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24629}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops2}, .v = {24, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6547}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12816}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27568}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25047}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18783}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12750}}, {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32075}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops6}, .v = {4, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13005}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1053}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31500}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10228}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10977}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10162}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24718}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 55}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1875, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1195, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14558 [("\253\195\NUL\169\SUB\205/\SYNc\168\233|a\172\161\187\236\149\159 \222\215$\195<",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("E\201R^&\SUB,\148vp@\224",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\215\136.^@|s6\135?U\231\230Q{\238d\161\131\NUL\177M\\\DC1",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\136\133c\130\ACK\ETX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS0}),(")\171\146\187\241\153\239",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\141\248\DC2\161?,jC\203G\198\135\203\134=\157\192\221\249~\246",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\189M!|\178~\166\141rn\247w\234",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// True, _noLocal = True, _subQoS = QoS1})] [PropServerReference "\142a\DC42\194\234\191\169",PropSubscriptionIdentifier -// 21,PropSessionExpiryInterval 5774,PropAssignedClientIdentifier "\SI[\204\129<\184S\EOTS*",PropServerReference -// "\219\196\196\212\134\r\150\238L",PropServerReference -// "\131E\208\SI%\246y\DLE*\137\208\168\153\&5\189\182\226xO\238H\231\148",PropWillDelayInterval -// 22265,PropSharedSubscriptionAvailable 169,PropServerKeepAlive 768,PropSubscriptionIdentifier -// 25,PropSessionExpiryInterval 2168,PropWillDelayInterval 19691,PropRequestResponseInformation -// 117,PropSubscriptionIdentifierAvailable 178,PropResponseInformation -// "g\155\DC17\251\131S\142^\211\143L\STXG4\ETX\SYN\146a\207\160",PropContentType "\246",PropWillDelayInterval -// 6475,PropSubscriptionIdentifier 17,PropContentType "\255\240\185\STXEt\192R",PropSubscriptionIdentifierAvailable -// 189,PropCorrelationData "\146(U*\249\225Y\215\215y\232\213\ACK3\217\234\202\146?\151t"] -TEST(Subscribe5QCTest, Encode21) { +// SubscribeRequest 4397 +// [("\SUB\ETX\210\235\182\"\235m\202\r6\154h\136\163\131\130\186$\186\129+[\232\241\213\194x\211\187",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\192#0\201ZxW\ENQ\210 ^}0\SOH\CAN\213\248",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = True, _noLocal = False, _subQoS = +// QoS2}),("j\249\215G\224\163\155\205/\178\206fT\139\&0~\215\CAN\233!\DC4",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling +// = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\EOT\211",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\136\FS\200\185\171\231^l\SO\167\145f\226\219\143`\t^\137F\163",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropResponseInformation +// "\STX'\188\v\191\no\240\SYN\213G\165",PropSubscriptionIdentifier 25,PropResponseInformation +// "\234\130g\223,ah\b=\202\DC2\DC3\133\132\163\221.\a\DEL\172\SUB\205t\254v\201&\251",PropSessionExpiryInterval +// 20154,PropMaximumPacketSize 1765,PropWillDelayInterval 10094,PropMessageExpiryInterval 1449,PropContentType +// "\nj\190'\196\206]\148\191C\190\169n_",PropAuthenticationData +// "\133\180V\130\SO\173\138\133\151\DC2\128A\199\a\r|C\201\148\238=&R\210",PropMessageExpiryInterval +// 24951,PropRetainAvailable 95,PropRequestResponseInformation 41] +TEST(Subscribe5QCTest, Encode19) { uint8_t pkt[] = { - 0x82, 0xac, 0x2, 0x38, 0xde, 0xa7, 0x1, 0x1c, 0x0, 0x8, 0x8e, 0x61, 0x14, 0x32, 0xc2, 0xea, 0xbf, 0xa9, 0xb, - 0x15, 0x11, 0x0, 0x0, 0x16, 0x8e, 0x12, 0x0, 0xa, 0xf, 0x5b, 0xcc, 0x81, 0x3c, 0xb8, 0x53, 0x4, 0x53, 0x2a, - 0x1c, 0x0, 0x9, 0xdb, 0xc4, 0xc4, 0xd4, 0x86, 0xd, 0x96, 0xee, 0x4c, 0x1c, 0x0, 0x17, 0x83, 0x45, 0xd0, 0xf, - 0x25, 0xf6, 0x79, 0x10, 0x2a, 0x89, 0xd0, 0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0xca, 0xd, 0x36, 0x9a, 0x68, 0x88, 0xa3, 0x83, 0x82, 0xba, 0x24, 0xba, 0x81, 0x2b, 0x5b, + 0xe8, 0xf1, 0xd5, 0xc2, 0x78, 0xd3, 0xbb, 0x16, 0x0, 0x11, 0xc0, 0x23, 0x30, 0xc9, 0x5a, 0x78, 0x57, 0x5, 0xd2, + 0x20, 0x5e, 0x7d, 0x30, 0x1, 0x18, 0xd5, 0xf8, 0xa, 0x0, 0x15, 0x6a, 0xf9, 0xd7, 0x47, 0xe0, 0xa3, 0x9b, 0xcd, + 0x2f, 0xb2, 0xce, 0x66, 0x54, 0x8b, 0x30, 0x7e, 0xd7, 0x18, 0xe9, 0x21, 0x14, 0x21, 0x0, 0x0, 0x24, 0x0, 0x2, + 0x4, 0xd3, 0x5, 0x0, 0x15, 0x88, 0x1c, 0xc8, 0xb9, 0xab, 0xe7, 0x5e, 0x6c, 0xe, 0xa7, 0x91, 0x66, 0xe2, 0xdb, + 0x8f, 0x60, 0x9, 0x5e, 0x89, 0x46, 0xa3, 0x4, 0x0, 0x0, 0x6}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xfd, 0xc3, 0x0, 0xa9, 0x1a, 0xcd, 0x2f, 0x16, 0x63, 0xa8, 0xe9, 0x7c, 0x61, - 0xac, 0xa1, 0xbb, 0xec, 0x95, 0x9f, 0x20, 0xde, 0xd7, 0x24, 0xc3, 0x3c}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x1a, 0x3, 0xd2, 0xeb, 0xb6, 0x22, 0xeb, 0x6d, 0xca, 0xd, + 0x36, 0x9a, 0x68, 0x88, 0xa3, 0x83, 0x82, 0xba, 0x24, 0xba, + 0x81, 0x2b, 0x5b, 0xe8, 0xf1, 0xd5, 0xc2, 0x78, 0xd3, 0xbb}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x45, 0xc9, 0x52, 0x5e, 0x26, 0x1a, 0x2c, 0x94, 0x76, 0x70, 0x40, 0xe0}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc0, 0x23, 0x30, 0xc9, 0x5a, 0x78, 0x57, 0x5, 0xd2, + 0x20, 0x5e, 0x7d, 0x30, 0x1, 0x18, 0xd5, 0xf8}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd7, 0x88, 0x2e, 0x5e, 0x40, 0x7c, 0x73, 0x36, 0x87, 0x3f, 0x55, 0xe7, - 0xe6, 0x51, 0x7b, 0xee, 0x64, 0xa1, 0x83, 0x0, 0xb1, 0x4d, 0x5c, 0x11}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6a, 0xf9, 0xd7, 0x47, 0xe0, 0xa3, 0x9b, 0xcd, 0x2f, 0xb2, 0xce, + 0x66, 0x54, 0x8b, 0x30, 0x7e, 0xd7, 0x18, 0xe9, 0x21, 0x14}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x88, 0x85, 0x63, 0x82, 0x6, 0x3}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x29, 0xab, 0x92, 0xbb, 0xf1, 0x99, 0xef}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x4, 0xd3}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8d, 0xf8, 0x12, 0xa1, 0x3f, 0x2c, 0x6a, 0x43, 0xcb, 0x47, 0xc6, - 0x87, 0xcb, 0x86, 0x3d, 0x9d, 0xc0, 0xdd, 0xf9, 0x7e, 0xf6}; + uint8_t topic_filter_s5_bytes[] = {0x88, 0x1c, 0xc8, 0xb9, 0xab, 0xe7, 0x5e, 0x6c, 0xe, 0xa7, 0x91, + 0x66, 0xe2, 0xdb, 0x8f, 0x60, 0x9, 0x5e, 0x89, 0x46, 0xa3}; lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbd, 0x4d, 0x21, 0x7c, 0xb2, 0x7e, 0xa6, 0x8d, 0x72, 0x6e, 0xf7, 0x77, 0xea}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; sub_opts[6].no_local = true; - uint8_t bytesprops0[] = {0x8e, 0x61, 0x14, 0x32, 0xc2, 0xea, 0xbf, 0xa9}; - uint8_t bytesprops1[] = {0xf, 0x5b, 0xcc, 0x81, 0x3c, 0xb8, 0x53, 0x4, 0x53, 0x2a}; - uint8_t bytesprops2[] = {0xdb, 0xc4, 0xc4, 0xd4, 0x86, 0xd, 0x96, 0xee, 0x4c}; - uint8_t bytesprops3[] = {0x83, 0x45, 0xd0, 0xf, 0x25, 0xf6, 0x79, 0x10, 0x2a, 0x89, 0xd0, 0xa8, - 0x99, 0x35, 0xbd, 0xb6, 0xe2, 0x78, 0x4f, 0xee, 0x48, 0xe7, 0x94}; - uint8_t bytesprops4[] = {0x67, 0x9b, 0x11, 0x37, 0xfb, 0x83, 0x53, 0x8e, 0x5e, 0xd3, 0x8f, - 0x4c, 0x2, 0x47, 0x34, 0x3, 0x16, 0x92, 0x61, 0xcf, 0xa0}; - uint8_t bytesprops5[] = {0xf6}; - uint8_t bytesprops6[] = {0xff, 0xf0, 0xb9, 0x2, 0x45, 0x74, 0xc0, 0x52}; - uint8_t bytesprops7[] = {0x92, 0x28, 0x55, 0x2a, 0xf9, 0xe1, 0x59, 0xd7, 0xd7, 0x79, 0xe8, - 0xd5, 0x6, 0x33, 0xd9, 0xea, 0xca, 0x92, 0x3f, 0x97, 0x74}; + uint8_t bytesprops0[] = {0x2, 0x27, 0xbc, 0xb, 0xbf, 0xa, 0x6f, 0xf0, 0x16, 0xd5, 0x47, 0xa5}; + uint8_t bytesprops1[] = {0xea, 0x82, 0x67, 0xdf, 0x2c, 0x61, 0x68, 0x8, 0x3d, 0xca, 0x12, 0x13, 0x85, 0x84, + 0xa3, 0xdd, 0x2e, 0x7, 0x7f, 0xac, 0x1a, 0xcd, 0x74, 0xfe, 0x76, 0xc9, 0x26, 0xfb}; + uint8_t bytesprops2[] = {0xa, 0x6a, 0xbe, 0x27, 0xc4, 0xce, 0x5d, 0x94, 0xbf, 0x43, 0xbe, 0xa9, 0x6e, 0x5f}; + uint8_t bytesprops3[] = {0x85, 0xb4, 0x56, 0x82, 0xe, 0xad, 0x8a, 0x85, 0x97, 0x12, 0x80, 0x41, + 0xc7, 0x7, 0xd, 0x7c, 0x43, 0xc9, 0x94, 0xee, 0x3d, 0x26, 0x52, 0xd2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5774}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22265}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 768}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops0}}}, {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2168}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19691}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6475}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20154}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1765}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10094}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1449}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24951}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 41}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14558, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4397, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14679 [("\207`\174\172K_\ENQ",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = True, _noLocal = True, _subQoS = QoS2}),(";\232\&5\184JOL\164\ETX\139\154`\228+\DC23`\228",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropUserProperty -// "\185\227\SO.\161\152\a4\DEL\215\158\230U" -// "\213a\t\153\169\&3\128\173\135\197\254x\135!\229on9z\246L\224\&2U\151",PropAuthenticationData -// "1\131\187;\SOH\241\172",PropMessageExpiryInterval 23772,PropWillDelayInterval 2648,PropSessionExpiryInterval -// 32304,PropAssignedClientIdentifier "",PropAssignedClientIdentifier "\206\152&",PropUserProperty "\231x" -// "\169\253\236\RS\208\&7!\196\137\230~d}\STX\140\203o\228\188Z\231\146@",PropCorrelationData -// "\228\204e\240y\176\160\143]",PropMessageExpiryInterval 30439] -TEST(Subscribe5QCTest, Encode22) { - uint8_t pkt[] = {0x82, 0x9e, 0x1, 0x39, 0x57, 0x7c, 0x26, 0x0, 0xd, 0xb9, 0xe3, 0xe, 0x2e, 0xa1, 0x98, 0x7, 0x34, - 0x7f, 0xd7, 0x9e, 0xe6, 0x55, 0x0, 0x19, 0xd5, 0x61, 0x9, 0x99, 0xa9, 0x33, 0x80, 0xad, 0x87, 0xc5, - 0xfe, 0x78, 0x87, 0x21, 0xe5, 0x6f, 0x6e, 0x39, 0x7a, 0xf6, 0x4c, 0xe0, 0x32, 0x55, 0x97, 0x16, 0x0, - 0x7, 0x31, 0x83, 0xbb, 0x3b, 0x1, 0xf1, 0xac, 0x2, 0x0, 0x0, 0x5c, 0xdc, 0x18, 0x0, 0x0, 0xa, - 0x58, 0x11, 0x0, 0x0, 0x7e, 0x30, 0x12, 0x0, 0x0, 0x12, 0x0, 0x3, 0xce, 0x98, 0x26, 0x26, 0x0, - 0x2, 0xe7, 0x78, 0x0, 0x17, 0xa9, 0xfd, 0xec, 0x1e, 0xd0, 0x37, 0x21, 0xc4, 0x89, 0xe6, 0x7e, 0x64, - 0x7d, 0x2, 0x8c, 0xcb, 0x6f, 0xe4, 0xbc, 0x5a, 0xe7, 0x92, 0x40, 0x9, 0x0, 0x9, 0xe4, 0xcc, 0x65, - 0xf0, 0x79, 0xb0, 0xa0, 0x8f, 0x5d, 0x2, 0x0, 0x0, 0x76, 0xe7, 0x0, 0x7, 0xcf, 0x60, 0xae, 0xac, - 0x4b, 0x5f, 0x5, 0x2e, 0x0, 0x12, 0x3b, 0xe8, 0x35, 0xb8, 0x4a, 0x4f, 0x4c, 0xa4, 0x3, 0x8b, 0x9a, - 0x60, 0xe4, 0x2b, 0x12, 0x33, 0x60, 0xe4, 0xa}; +// SubscribeRequest 27847 +// [("\243<\205\142\254\168U\222\165,\134\130\135\225_\143\205\US\162\203D\ETBR\SO\n\242\194",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("s\199\173\183n\252\245\235\237\ETX\SOH\189\190M9\160/+",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\148",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("4x\187\128\139\&3\a\DC3\233\136\CAN{\200\172B\213\155\SYNS\175\221\183\195\GS",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropServerReference +// "h\158\218u\224\"\219 \181#&\SYN\166y(\243y\154+\225\131\187/_\157Qi(\145\166",PropSharedSubscriptionAvailable +// 111,PropTopicAlias 8625,PropAssignedClientIdentifier +// "G\CAN\200\230\&4qhbYu8\249\204\131\DC1s\215\242\232\DC2\149\"\248",PropCorrelationData +// "D\158y\EM%\232}\138\194S\DC17\138\242\STX\222\DC2\ENQ\192\192\128a\179\244E\r\183\178\SO*",PropCorrelationData +// "\198\222+\196\129)_\198G\129\\\SOj\SOd\ENQ",PropRequestProblemInformation 177,PropAssignedClientIdentifier +// "\247d\239\179\141\t\RS\174\STX;",PropServerKeepAlive 966,PropMessageExpiryInterval 17493,PropServerReference +// "\161\129\179\&1\177\200\232\177/\ETX\251\187&\210>\CAN",PropWildcardSubscriptionAvailable 96,PropCorrelationData +// "\131,\227\DC4k\n\205\185\184)Z\205\215a%\144{j\201\205`\228\177R",PropWillDelayInterval +// 31922,PropAuthenticationMethod "\178Q[",PropWildcardSubscriptionAvailable 255,PropReasonString "",PropResponseTopic +// "\202\151\153F",PropRetainAvailable 126,PropResponseTopic +// "\239\DC40\139\154\&9\157hZ^m\NAK\195\156\214\229\138\152",PropAssignedClientIdentifier "\233",PropRetainAvailable +// 181,PropRequestProblemInformation 208,PropMaximumPacketSize 6700,PropUserProperty "itp\171\GS=\214m\136{Z\129\210t" +// "\235\233\RSc)6\241\237\147^\139\137\n\ACK\173_;x>\206\167\138\207\233\ETB\231\EM\255o",PropSubscriptionIdentifier +// 9,PropMaximumPacketSize 19656,PropReceiveMaximum 2700,PropSessionExpiryInterval 20638] +TEST(Subscribe5QCTest, Encode20) { + u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0x2e, 0x0, 0x18, 0x34, 0x78, 0xbb, 0x80, 0x8b, 0x33, 0x7, + 0x13, 0xe9, 0x88, 0x18, 0x7b, 0xc8, 0xac, 0x42, 0xd5, 0x9b, 0x16, 0x53, 0xaf, 0xdd, 0xb7, 0xc3, 0x1d, 0xc}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xcf, 0x60, 0xae, 0xac, 0x4b, 0x5f, 0x5}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xf3, 0x3c, 0xcd, 0x8e, 0xfe, 0xa8, 0x55, 0xde, 0xa5, 0x2c, 0x86, 0x82, 0x87, 0xe1, + 0x5f, 0x8f, 0xcd, 0x1f, 0xa2, 0xcb, 0x44, 0x17, 0x52, 0xe, 0xa, 0xf2, 0xc2}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3b, 0xe8, 0x35, 0xb8, 0x4a, 0x4f, 0x4c, 0xa4, 0x3, - 0x8b, 0x9a, 0x60, 0xe4, 0x2b, 0x12, 0x33, 0x60, 0xe4}; + uint8_t topic_filter_s1_bytes[] = {0x73, 0xc7, 0xad, 0xb7, 0x6e, 0xfc, 0xf5, 0xeb, 0xed, + 0x3, 0x1, 0xbd, 0xbe, 0x4d, 0x39, 0xa0, 0x2f, 0x2b}; lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; + uint8_t topic_filter_s2_bytes[] = {0x94}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x34, 0x78, 0xbb, 0x80, 0x8b, 0x33, 0x7, 0x13, 0xe9, 0x88, 0x18, 0x7b, + 0xc8, 0xac, 0x42, 0xd5, 0x9b, 0x16, 0x53, 0xaf, 0xdd, 0xb7, 0xc3, 0x1d}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - uint8_t bytesprops1[] = {0xd5, 0x61, 0x9, 0x99, 0xa9, 0x33, 0x80, 0xad, 0x87, 0xc5, 0xfe, 0x78, 0x87, - 0x21, 0xe5, 0x6f, 0x6e, 0x39, 0x7a, 0xf6, 0x4c, 0xe0, 0x32, 0x55, 0x97}; - uint8_t bytesprops0[] = {0xb9, 0xe3, 0xe, 0x2e, 0xa1, 0x98, 0x7, 0x34, 0x7f, 0xd7, 0x9e, 0xe6, 0x55}; - uint8_t bytesprops2[] = {0x31, 0x83, 0xbb, 0x3b, 0x1, 0xf1, 0xac}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0xce, 0x98, 0x26}; - uint8_t bytesprops6[] = {0xa9, 0xfd, 0xec, 0x1e, 0xd0, 0x37, 0x21, 0xc4, 0x89, 0xe6, 0x7e, 0x64, - 0x7d, 0x2, 0x8c, 0xcb, 0x6f, 0xe4, 0xbc, 0x5a, 0xe7, 0x92, 0x40}; - uint8_t bytesprops5[] = {0xe7, 0x78}; - uint8_t bytesprops7[] = {0xe4, 0xcc, 0x65, 0xf0, 0x79, 0xb0, 0xa0, 0x8f, 0x5d}; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + uint8_t bytesprops0[] = {0x68, 0x9e, 0xda, 0x75, 0xe0, 0x22, 0xdb, 0x20, 0xb5, 0x23, 0x26, 0x16, 0xa6, 0x79, 0x28, + 0xf3, 0x79, 0x9a, 0x2b, 0xe1, 0x83, 0xbb, 0x2f, 0x5f, 0x9d, 0x51, 0x69, 0x28, 0x91, 0xa6}; + uint8_t bytesprops1[] = {0x47, 0x18, 0xc8, 0xe6, 0x34, 0x71, 0x68, 0x62, 0x59, 0x75, 0x38, 0xf9, + 0xcc, 0x83, 0x11, 0x73, 0xd7, 0xf2, 0xe8, 0x12, 0x95, 0x22, 0xf8}; + uint8_t bytesprops2[] = {0x44, 0x9e, 0x79, 0x19, 0x25, 0xe8, 0x7d, 0x8a, 0xc2, 0x53, 0x11, 0x37, 0x8a, 0xf2, 0x2, + 0xde, 0x12, 0x5, 0xc0, 0xc0, 0x80, 0x61, 0xb3, 0xf4, 0x45, 0xd, 0xb7, 0xb2, 0xe, 0x2a}; + uint8_t bytesprops3[] = {0xc6, 0xde, 0x2b, 0xc4, 0x81, 0x29, 0x5f, 0xc6, 0x47, 0x81, 0x5c, 0xe, 0x6a, 0xe, 0x64, 0x5}; + uint8_t bytesprops4[] = {0xf7, 0x64, 0xef, 0xb3, 0x8d, 0x9, 0x1e, 0xae, 0x2, 0x3b}; + uint8_t bytesprops5[] = {0xa1, 0x81, 0xb3, 0x31, 0xb1, 0xc8, 0xe8, 0xb1, + 0x2f, 0x3, 0xfb, 0xbb, 0x26, 0xd2, 0x3e, 0x18}; + uint8_t bytesprops6[] = {0x83, 0x2c, 0xe3, 0x14, 0x6b, 0xa, 0xcd, 0xb9, 0xb8, 0x29, 0x5a, 0xcd, + 0xd7, 0x61, 0x25, 0x90, 0x7b, 0x6a, 0xc9, 0xcd, 0x60, 0xe4, 0xb1, 0x52}; + uint8_t bytesprops7[] = {0xb2, 0x51, 0x5b}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0xca, 0x97, 0x99, 0x46}; + uint8_t bytesprops10[] = {0xef, 0x14, 0x30, 0x8b, 0x9a, 0x39, 0x9d, 0x68, 0x5a, + 0x5e, 0x6d, 0x15, 0xc3, 0x9c, 0xd6, 0xe5, 0x8a, 0x98}; + uint8_t bytesprops11[] = {0xe9}; + uint8_t bytesprops13[] = {0xeb, 0xe9, 0x1e, 0x63, 0x29, 0x36, 0xf1, 0xed, 0x93, 0x5e, 0x8b, 0x89, 0xa, 0x6, 0xad, + 0x5f, 0x3b, 0x78, 0x3e, 0xce, 0xa7, 0x8a, 0xcf, 0xe9, 0x17, 0xe7, 0x19, 0xff, 0x6f}; + uint8_t bytesprops12[] = {0x69, 0x74, 0x70, 0xab, 0x1d, 0x3d, 0xd6, 0x6d, 0x88, 0x7b, 0x5a, 0x81, 0xd2, 0x74}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23772}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2648}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32304}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops5}, .v = {23, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30439}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8625}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 966}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17493}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31922}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6700}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {14, (char*)&bytesprops12}, .v = {29, (char*)&bytesprops13}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19656}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2700}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20638}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14679, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27847, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12650 [("\128\169\159\162P\211\&9;",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\208m\216",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\236_\171\216\143\"\186H\168\235\192<\204\ACK\DEL[h\235\178@\147",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\216\RS\142\&4\175O\SOHGI9M\r\US\159\148,2\RS\196\SUB\136\EM\176\GS\129",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(",V\156\135\DC1\226\RS\199Z\rf\r\191.\220.\204\243\227\NAK\198\232\&6$@",SubOptions {_retainHandling = +// SubscribeRequest 29011 [("L\255\232\&7",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// True, _noLocal = True, _subQoS = QoS0}),("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// True, _noLocal = False, _subQoS = QoS0}),("\ENQ +// \STX\209\189\DEL\160\167\&6~\254\SYN\144\246\217(\GS\207(c\142\241",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\237\194\247\230\ETX\134\225\f\SI\143\242\181\&1+\226EO\223\186\144se\216HY>\170\209",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\155O\191\161v\218\167\168_\147\DC1",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = True, _subQoS = QoS0}),("\FS\236xY=!\172\241\217\230\209\222\179\DC2\SI",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("d}\134\162\229\233`\212\248\207\DC4\254\137\186\232KP\165\222\144",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\241\197)E\130G\STX\248\&7w\179\173\243\vTB\FS\212o\195jN\201\151Z\NUL",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\194\235)\201J\157\SOH3\t|\DC4\164\v\175\206\SOHY\236 \166(\212\130",SubOptions {_retainHandling = // DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\172\192\171\236\193\&0\139\ENQvR\250\SOH6\160\NAK\191\&9u",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\194\ETXM3U\240\EM\243\176\SO/\205H\143\242wn\138\199\137\156\211\175",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropSessionExpiryInterval -// 1524,PropReceiveMaximum 18350,PropRetainAvailable 238,PropRetainAvailable 182,PropTopicAliasMaximum -// 26470,PropTopicAlias 3473,PropTopicAlias 25376,PropReasonString -// "\139\197G\238\254\211\135\143#\208\159l\178\DC3;\138\220\143",PropContentType -// "3\164f\169Hz\250\131\DC3\129E\SYN\nD\206[\244\192\210",PropSharedSubscriptionAvailable -// 33,PropSharedSubscriptionAvailable 219,PropReceiveMaximum 21214,PropRequestProblemInformation -// 29,PropWillDelayInterval 21731,PropMessageExpiryInterval 7458,PropResponseInformation -// "\ENQ\f\CAN\STXj\237\148\199",PropWildcardSubscriptionAvailable 244,PropContentType -// "=\209\191N\169\248_\245J9\235\197d\244\190\136\185\164\&2\205e\200\251",PropMessageExpiryInterval -// 20023,PropMessageExpiryInterval 19469,PropTopicAlias 12641,PropMaximumQoS 15,PropSubscriptionIdentifierAvailable -// 193,PropMessageExpiryInterval 3100,PropResponseInformation "Nk\142=&1\154/#\251\231\153I",PropWillDelayInterval 6949] -TEST(Subscribe5QCTest, Encode23) { - uint8_t pkt[] = { - 0x82, 0xb9, 0x2, 0x31, 0x6a, 0xa5, 0x1, 0x11, 0x0, 0x0, 0x5, 0xf4, 0x21, 0x47, 0xae, 0x25, 0xee, 0x25, 0xb6, - 0x22, 0x67, 0x66, 0x23, 0xd, 0x91, 0x23, 0x63, 0x20, 0x1f, 0x0, 0x12, 0x8b, 0xc5, 0x47, 0xee, 0xfe, 0xd3, 0x87, - 0x8f, 0x23, 0xd0, 0x9f, 0x6c, 0xb2, 0x13, 0x3b, 0x8a, 0xdc, 0x8f, 0x3, 0x0, 0x13, 0x33, 0xa4, 0x66, 0xa9, 0x48, - 0x7a, 0xfa, 0x83, 0x13, 0x81, 0x45, 0x16, 0xa, 0x44, 0xce, 0x5b, 0xf4, 0xc0, 0xd2, 0x2a, 0x21, 0x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0xcc, 0xf3, 0xe3, 0x15, 0xc6, 0xe8, 0x36, - 0x24, 0x40, 0x2e, 0x0, 0x12, 0xac, 0xc0, 0xab, 0xec, 0xc1, 0x30, 0x8b, 0x5, 0x76, 0x52, 0xfa, 0x1, 0x36, 0xa0, - 0x15, 0xbf, 0x39, 0x75, 0x1a, 0x0, 0x17, 0xc2, 0x3, 0x4d, 0x33, 0x55, 0xf0, 0x19, 0xf3, 0xb0, 0xe, 0x2f, 0xcd, - 0x48, 0x8f, 0xf2, 0x77, 0x6e, 0x8a, 0xc7, 0x89, 0x9c, 0xd3, 0xaf, 0x1a}; +// QoS1}),("\181H\154\233\193\216W\142\190\172\173\206\ACKC`",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("s\231w\220\208\DC4\157\191\CAN\EOTo\187\170.c\DLE-\219",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe5QCTest, Encode21) { + uint8_t pkt[] = {0x82, 0xda, 0x1, 0x71, 0x53, 0x0, 0x0, 0x4, 0x4c, 0xff, 0xe8, 0x37, 0x2c, 0x0, 0x0, 0x28, 0x0, + 0x16, 0x5, 0x20, 0x2, 0xd1, 0xbd, 0x7f, 0xa0, 0xa7, 0x36, 0x7e, 0xfe, 0x16, 0x90, 0xf6, 0xd9, 0x28, + 0x1d, 0xcf, 0x28, 0x63, 0x8e, 0xf1, 0x1d, 0x0, 0x1c, 0xed, 0xc2, 0xf7, 0xe6, 0x3, 0x86, 0xe1, 0xc, + 0xf, 0x8f, 0xf2, 0xb5, 0x31, 0x2b, 0xe2, 0x45, 0x4f, 0xdf, 0xba, 0x90, 0x73, 0x65, 0xd8, 0x48, 0x59, + 0x3e, 0xaa, 0xd1, 0x18, 0x0, 0xb, 0x9b, 0x4f, 0xbf, 0xa1, 0x76, 0xda, 0xa7, 0xa8, 0x5f, 0x93, 0x11, + 0x2c, 0x0, 0xf, 0x1c, 0xec, 0x78, 0x59, 0x3d, 0x21, 0xac, 0xf1, 0xd9, 0xe6, 0xd1, 0xde, 0xb3, 0x12, + 0xf, 0x1d, 0x0, 0x14, 0x64, 0x7d, 0x86, 0xa2, 0xe5, 0xe9, 0x60, 0xd4, 0xf8, 0xcf, 0x14, 0xfe, 0x89, + 0xba, 0xe8, 0x4b, 0x50, 0xa5, 0xde, 0x90, 0xe, 0x0, 0x1a, 0xf1, 0xc5, 0x29, 0x45, 0x82, 0x47, 0x2, + 0xf8, 0x37, 0x77, 0xb3, 0xad, 0xf3, 0xb, 0x54, 0x42, 0x1c, 0xd4, 0x6f, 0xc3, 0x6a, 0x4e, 0xc9, 0x97, + 0x5a, 0x0, 0x1c, 0x0, 0x17, 0xc2, 0xeb, 0x29, 0xc9, 0x4a, 0x9d, 0x1, 0x33, 0x9, 0x7c, 0x14, 0xa4, + 0xb, 0xaf, 0xce, 0x1, 0x59, 0xec, 0x20, 0xa6, 0x28, 0xd4, 0x82, 0x2d, 0x0, 0xf, 0xb5, 0x48, 0x9a, + 0xe9, 0xc1, 0xd8, 0x57, 0x8e, 0xbe, 0xac, 0xad, 0xce, 0x6, 0x43, 0x60, 0x1c, 0x0, 0x12, 0x73, 0xe7, + 0x77, 0xdc, 0xd0, 0x14, 0x9d, 0xbf, 0x18, 0x4, 0x6f, 0xbb, 0xaa, 0x2e, 0x63, 0x10, 0x2d, 0xdb, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x80, 0xa9, 0x9f, 0xa2, 0x50, 0xd3, 0x39, 0x3b}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x4c, 0xff, 0xe8, 0x37}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd0, 0x6d, 0xd8}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xec, 0x5f, 0xab, 0xd8, 0x8f, 0x22, 0xba, 0x48, 0xa8, 0xeb, 0xc0, - 0x3c, 0xcc, 0x6, 0x7f, 0x5b, 0x68, 0xeb, 0xb2, 0x40, 0x93}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5, 0x20, 0x2, 0xd1, 0xbd, 0x7f, 0xa0, 0xa7, 0x36, 0x7e, 0xfe, + 0x16, 0x90, 0xf6, 0xd9, 0x28, 0x1d, 0xcf, 0x28, 0x63, 0x8e, 0xf1}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd8, 0x1e, 0x8e, 0x34, 0xaf, 0x4f, 0x1, 0x47, 0x49, 0x39, 0x4d, 0xd, 0x1f, - 0x9f, 0x94, 0x2c, 0x32, 0x1e, 0xc4, 0x1a, 0x88, 0x19, 0xb0, 0x1d, 0x81}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xed, 0xc2, 0xf7, 0xe6, 0x3, 0x86, 0xe1, 0xc, 0xf, 0x8f, + 0xf2, 0xb5, 0x31, 0x2b, 0xe2, 0x45, 0x4f, 0xdf, 0xba, 0x90, + 0x73, 0x65, 0xd8, 0x48, 0x59, 0x3e, 0xaa, 0xd1}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2c, 0x56, 0x9c, 0x87, 0x11, 0xe2, 0x1e, 0xc7, 0x5a, 0xd, 0x66, 0xd, 0xbf, - 0x2e, 0xdc, 0x2e, 0xcc, 0xf3, 0xe3, 0x15, 0xc6, 0xe8, 0x36, 0x24, 0x40}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x9b, 0x4f, 0xbf, 0xa1, 0x76, 0xda, 0xa7, 0xa8, 0x5f, 0x93, 0x11}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xac, 0xc0, 0xab, 0xec, 0xc1, 0x30, 0x8b, 0x5, 0x76, - 0x52, 0xfa, 0x1, 0x36, 0xa0, 0x15, 0xbf, 0x39, 0x75}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x1c, 0xec, 0x78, 0x59, 0x3d, 0x21, 0xac, 0xf1, + 0xd9, 0xe6, 0xd1, 0xde, 0xb3, 0x12, 0xf}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc2, 0x3, 0x4d, 0x33, 0x55, 0xf0, 0x19, 0xf3, 0xb0, 0xe, 0x2f, 0xcd, - 0x48, 0x8f, 0xf2, 0x77, 0x6e, 0x8a, 0xc7, 0x89, 0x9c, 0xd3, 0xaf}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x64, 0x7d, 0x86, 0xa2, 0xe5, 0xe9, 0x60, 0xd4, 0xf8, 0xcf, + 0x14, 0xfe, 0x89, 0xba, 0xe8, 0x4b, 0x50, 0xa5, 0xde, 0x90}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s7_bytes[] = {0xf1, 0xc5, 0x29, 0x45, 0x82, 0x47, 0x2, 0xf8, 0x37, 0x77, 0xb3, 0xad, 0xf3, + 0xb, 0x54, 0x42, 0x1c, 0xd4, 0x6f, 0xc3, 0x6a, 0x4e, 0xc9, 0x97, 0x5a, 0x0}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xc2, 0xeb, 0x29, 0xc9, 0x4a, 0x9d, 0x1, 0x33, 0x9, 0x7c, 0x14, 0xa4, + 0xb, 0xaf, 0xce, 0x1, 0x59, 0xec, 0x20, 0xa6, 0x28, 0xd4, 0x82}; + lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xb5, 0x48, 0x9a, 0xe9, 0xc1, 0xd8, 0x57, 0x8e, + 0xbe, 0xac, 0xad, 0xce, 0x6, 0x43, 0x60}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x73, 0xe7, 0x77, 0xdc, 0xd0, 0x14, 0x9d, 0xbf, 0x18, + 0x4, 0x6f, 0xbb, 0xaa, 0x2e, 0x63, 0x10, 0x2d, 0xdb}; + lwmqtt_string_t topic_filter_s10 = {18, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; + sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; + sub_opts[5].no_local = true; sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - uint8_t bytesprops0[] = {0x8b, 0xc5, 0x47, 0xee, 0xfe, 0xd3, 0x87, 0x8f, 0x23, - 0xd0, 0x9f, 0x6c, 0xb2, 0x13, 0x3b, 0x8a, 0xdc, 0x8f}; - uint8_t bytesprops1[] = {0x33, 0xa4, 0x66, 0xa9, 0x48, 0x7a, 0xfa, 0x83, 0x13, 0x81, - 0x45, 0x16, 0xa, 0x44, 0xce, 0x5b, 0xf4, 0xc0, 0xd2}; - uint8_t bytesprops2[] = {0x5, 0xc, 0x18, 0x2, 0x6a, 0xed, 0x94, 0xc7}; - uint8_t bytesprops3[] = {0x3d, 0xd1, 0xbf, 0x4e, 0xa9, 0xf8, 0x5f, 0xf5, 0x4a, 0x39, 0xeb, 0xc5, - 0x64, 0xf4, 0xbe, 0x88, 0xb9, 0xa4, 0x32, 0xcd, 0x65, 0xc8, 0xfb}; - uint8_t bytesprops4[] = {0x4e, 0x6b, 0x8e, 0x3d, 0x26, 0x31, 0x9a, 0x2f, 0x23, 0xfb, 0xe7, 0x99, 0x49}; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = true; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1524}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18350}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26470}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3473}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25376}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21214}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21731}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7458}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20023}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19469}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12641}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3100}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6949}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12650, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29011, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3665 [("\RS2\128\242",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0})] [PropAuthenticationData -// "P\197\SUB\SOH\205\194X\150\224[\222\f\SO(\161\145D\CAN\233\ACKy\204\243@\149\164",PropSubscriptionIdentifier 10] -TEST(Subscribe5QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x29, 0xe, 0x51, 0x1f, 0x16, 0x0, 0x1a, 0x50, 0xc5, 0x1a, 0x1, 0xcd, 0xc2, 0x58, - 0x96, 0xe0, 0x5b, 0xde, 0xc, 0xe, 0x28, 0xa1, 0x91, 0x44, 0x18, 0xe9, 0x6, 0x79, 0xcc, - 0xf3, 0x40, 0x95, 0xa4, 0xb, 0xa, 0x0, 0x4, 0x1e, 0x32, 0x80, 0xf2, 0x10}; +// SubscribeRequest 29705 [("\amn\138\157\180\217\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0}),("!!Va\217\152",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\249\n}\251\170",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\158\v\b\RS\149\235Vv\NAK\240\135d\189r\203\185b\176\ETB\195,EE\185y",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSessionExpiryInterval +// 28284,PropResponseTopic "L"] +TEST(Subscribe5QCTest, Encode22) { + uint8_t pkt[] = {0x82, 0x44, 0x74, 0x9, 0x9, 0x11, 0x0, 0x0, 0x6e, 0x7c, 0x8, 0x0, 0x1, 0x4c, + 0x0, 0x8, 0x7, 0x6d, 0x6e, 0x8a, 0x9d, 0xb4, 0xd9, 0xdb, 0x0, 0x0, 0x6, 0x21, + 0x21, 0x56, 0x61, 0xd9, 0x98, 0xa, 0x0, 0x5, 0xf9, 0xa, 0x7d, 0xfb, 0xaa, 0x1, + 0x0, 0x19, 0x9e, 0xb, 0x8, 0x1e, 0x95, 0xeb, 0x56, 0x76, 0x15, 0xf0, 0x87, 0x64, + 0xbd, 0x72, 0xcb, 0xb9, 0x62, 0xb0, 0x17, 0xc3, 0x2c, 0x45, 0x45, 0xb9, 0x79, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x1e, 0x32, 0x80, 0xf2}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x7, 0x6d, 0x6e, 0x8a, 0x9d, 0xb4, 0xd9, 0xdb}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; + uint8_t topic_filter_s1_bytes[] = {0x21, 0x21, 0x56, 0x61, 0xd9, 0x98}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf9, 0xa, 0x7d, 0xfb, 0xaa}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x9e, 0xb, 0x8, 0x1e, 0x95, 0xeb, 0x56, 0x76, 0x15, 0xf0, 0x87, 0x64, 0xbd, + 0x72, 0xcb, 0xb9, 0x62, 0xb0, 0x17, 0xc3, 0x2c, 0x45, 0x45, 0xb9, 0x79}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - uint8_t bytesprops0[] = {0x50, 0xc5, 0x1a, 0x1, 0xcd, 0xc2, 0x58, 0x96, 0xe0, 0x5b, 0xde, 0xc, 0xe, - 0x28, 0xa1, 0x91, 0x44, 0x18, 0xe9, 0x6, 0x79, 0xcc, 0xf3, 0x40, 0x95, 0xa4}; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + uint8_t bytesprops0[] = {0x4c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28284}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops0}}}, }; lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3665, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29705, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23603 [("\197\163\195D\141\173\234\249,\160]\180\nZ\t\FS\244Iu\131s[\184\\",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\182\253\219\136*\159\139\DC1\249\240$r\252\233",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\219\DC4\184\&5M\153\135\234\188\ENQ\184",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\218\185}\160^\f\252\130\170}\"u\132m\185\FS\250\157-\169o\DC4",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\128\158`\237A\207\227\151P\STX\248\177\n\202\STX\130N\183\169\198^",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\207\255b\143\CAN\FS\140\203!\SYN<\138\131V\187.Y\252\186\253\DC1\150",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\191h",SubOptions +// SubscribeRequest 30426 [("\SYNez\ACK\162N\176`#\DLEr6\206\183\167\183\224\241\&4OY\ENQ\162'\169\187\136A",SubOptions // {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("PsYa\175\245B\255\RS\136\128\GS\201\201wA\\\198\&3tES\184+\244\&5\SYN5",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\224\CAN\160\211\DLE",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropMaximumQoS -// 61,PropTopicAlias 25005,PropSubscriptionIdentifierAvailable 85,PropPayloadFormatIndicator -// 45,PropMessageExpiryInterval 32022,PropWillDelayInterval 2228,PropServerKeepAlive 1756,PropResponseTopic -// "dV",PropRequestResponseInformation 183,PropWillDelayInterval 19475,PropMessageExpiryInterval -// 12359,PropServerKeepAlive 707] -TEST(Subscribe5QCTest, Encode25) { +// QoS2}),("\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("mD\188mxN\232n\174\197\149e\174/\"\187\196\138\131\232",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\193]\DC2\n\228\224l6\162\149f\"J.\240\202",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),(":q\223\215|h\a\208G\164\\~\231q_R\131\211\242\198\EM\CAN\220(\158\DLE\133",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\225\243\168\&79\184\251\210N\f>-\149\138K\n\155\217\220\DC33T\250\255UB=\188\RS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("_\174@\222\188\207\224\212\179\190C\206",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\165\SYN\186\167:\ETX\214\DC2\145O\237\221\197",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic +// ">\197d\SOH\141\182\233\152\161e3\\'F\NUL\242\238\201\137>\226`d\247\216\f",PropUserProperty +// "\DLEC\133\DEL)fF;hO\202+\136\v\160\197i\238\DC1\215" +// "\212n\170#\146\197]\216\179\237\237K,B\227\"\190\DEL\ETXeIS\196",PropWillDelayInterval +// 20679,PropAuthenticationMethod "\\\254\&1\196^^\175b\136\ESC4d@n\241\STXs>'W\\=:w",PropMaximumPacketSize +// 3791,PropServerKeepAlive 29126,PropResponseTopic "\137\SI",PropMessageExpiryInterval 2636,PropServerKeepAlive +// 7512,PropRequestProblemInformation 204,PropSessionExpiryInterval 10542,PropTopicAlias 2720,PropMaximumPacketSize +// 30315,PropResponseInformation +// "\221\CAN\229\NAK\164\195\155\SOH\244\193\"\t\140\133\140\206\216\158\211\242\DLE\210",PropSubscriptionIdentifierAvailable +// 131,PropTopicAliasMaximum 31102,PropAuthenticationMethod "x\159d\133\SOH\161\198fD",PropAuthenticationMethod "Z\197"] +TEST(Subscribe5QCTest, Encode23) { uint8_t pkt[] = { - 0x82, 0xe0, 0x1, 0x5c, 0x33, 0x2a, 0x24, 0x3d, 0x23, 0x61, 0xad, 0x29, 0x55, 0x1, 0x2d, 0x2, 0x0, 0x0, 0x7d, - 0x16, 0x18, 0x0, 0x0, 0x8, 0xb4, 0x13, 0x6, 0xdc, 0x8, 0x0, 0x2, 0x64, 0x56, 0x19, 0xb7, 0x18, 0x0, 0x0, - 0x4c, 0x13, 0x2, 0x0, 0x0, 0x30, 0x47, 0x13, 0x2, 0xc3, 0x0, 0x18, 0xc5, 0xa3, 0xc3, 0x44, 0x8d, 0xad, 0xea, - 0xf9, 0x2c, 0xa0, 0x5d, 0xb4, 0xa, 0x5a, 0x9, 0x1c, 0xf4, 0x49, 0x75, 0x83, 0x73, 0x5b, 0xb8, 0x5c, 0x28, 0x0, - 0xe, 0xb6, 0xfd, 0xdb, 0x88, 0x2a, 0x9f, 0x8b, 0x11, 0xf9, 0xf0, 0x24, 0x72, 0xfc, 0xe9, 0xd, 0x0, 0xb, 0xdb, - 0x14, 0xb8, 0x35, 0x4d, 0x99, 0x87, 0xea, 0xbc, 0x5, 0xb8, 0x19, 0x0, 0x16, 0xda, 0xb9, 0x7d, 0xa0, 0x5e, 0xc, - 0xfc, 0x82, 0xaa, 0x7d, 0x22, 0x75, 0x84, 0x6d, 0xb9, 0x1c, 0xfa, 0x9d, 0x2d, 0xa9, 0x6f, 0x14, 0x2c, 0x0, 0x15, - 0x80, 0x9e, 0x60, 0xed, 0x41, 0xcf, 0xe3, 0x97, 0x50, 0x2, 0xf8, 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 0x71, 0x5f, 0x52, 0x83, 0xd3, 0xf2, 0xc6, 0x19, 0x18, 0xdc, 0x28, 0x9e, 0x10, + 0x85, 0x29, 0x0, 0x1d, 0xe1, 0xf3, 0xa8, 0x37, 0x39, 0xb8, 0xfb, 0xd2, 0x4e, 0xc, 0x3e, 0x2d, 0x95, 0x8a, 0x4b, + 0xa, 0x9b, 0xd9, 0xdc, 0x13, 0x33, 0x54, 0xfa, 0xff, 0x55, 0x42, 0x3d, 0xbc, 0x1e, 0xc, 0x0, 0xc, 0x5f, 0xae, + 0x40, 0xde, 0xbc, 0xcf, 0xe0, 0xd4, 0xb3, 0xbe, 0x43, 0xce, 0x19, 0x0, 0xd, 0xa5, 0x16, 0xba, 0xa7, 0x3a, 0x3, + 0xd6, 0x12, 0x91, 0x4f, 0xed, 0xdd, 0xc5, 0x9}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xc5, 0xa3, 0xc3, 0x44, 0x8d, 0xad, 0xea, 0xf9, 0x2c, 0xa0, 0x5d, 0xb4, - 0xa, 0x5a, 0x9, 0x1c, 0xf4, 0x49, 0x75, 0x83, 0x73, 0x5b, 0xb8, 0x5c}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x16, 0x65, 0x7a, 0x6, 0xa2, 0x4e, 0xb0, 0x60, 0x23, 0x10, + 0x72, 0x36, 0xce, 0xb7, 0xa7, 0xb7, 0xe0, 0xf1, 0x34, 0x4f, + 0x59, 0x5, 0xa2, 0x27, 0xa9, 0xbb, 0x88, 0x41}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb6, 0xfd, 0xdb, 0x88, 0x2a, 0x9f, 0x8b, - 0x11, 0xf9, 0xf0, 0x24, 0x72, 0xfc, 0xe9}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x98}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdb, 0x14, 0xb8, 0x35, 0x4d, 0x99, 0x87, 0xea, 0xbc, 0x5, 0xb8}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6d, 0x44, 0xbc, 0x6d, 0x78, 0x4e, 0xe8, 0x6e, 0xae, 0xc5, + 0x95, 0x65, 0xae, 0x2f, 0x22, 0xbb, 0xc4, 0x8a, 0x83, 0xe8}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xda, 0xb9, 0x7d, 0xa0, 0x5e, 0xc, 0xfc, 0x82, 0xaa, 0x7d, 0x22, - 0x75, 0x84, 0x6d, 0xb9, 0x1c, 0xfa, 0x9d, 0x2d, 0xa9, 0x6f, 0x14}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc1, 0x5d, 0x12, 0xa, 0xe4, 0xe0, 0x6c, 0x36, + 0xa2, 0x95, 0x66, 0x22, 0x4a, 0x2e, 0xf0, 0xca}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x80, 0x9e, 0x60, 0xed, 0x41, 0xcf, 0xe3, 0x97, 0x50, 0x2, 0xf8, - 0xb1, 0xa, 0xca, 0x2, 0x82, 0x4e, 0xb7, 0xa9, 0xc6, 0x5e}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x3a, 0x71, 0xdf, 0xd7, 0x7c, 0x68, 0x7, 0xd0, 0x47, 0xa4, 0x5c, 0x7e, 0xe7, 0x71, + 0x5f, 0x52, 0x83, 0xd3, 0xf2, 0xc6, 0x19, 0x18, 0xdc, 0x28, 0x9e, 0x10, 0x85}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xcf, 0xff, 0x62, 0x8f, 0x18, 0x1c, 0x8c, 0xcb, 0x21, 0x16, 0x3c, - 0x8a, 0x83, 0x56, 0xbb, 0x2e, 0x59, 0xfc, 0xba, 0xfd, 0x11, 0x96}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe1, 0xf3, 0xa8, 0x37, 0x39, 0xb8, 0xfb, 0xd2, 0x4e, 0xc, + 0x3e, 0x2d, 0x95, 0x8a, 0x4b, 0xa, 0x9b, 0xd9, 0xdc, 0x13, + 0x33, 0x54, 0xfa, 0xff, 0x55, 0x42, 0x3d, 0xbc, 0x1e}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbf, 0x68}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x5f, 0xae, 0x40, 0xde, 0xbc, 0xcf, 0xe0, 0xd4, 0xb3, 0xbe, 0x43, 0xce}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x50, 0x73, 0x59, 0x61, 0xaf, 0xf5, 0x42, 0xff, 0x1e, 0x88, - 0x80, 0x1d, 0xc9, 0xc9, 0x77, 0x41, 0x5c, 0xc6, 0x33, 0x74, - 0x45, 0x53, 0xb8, 0x2b, 0xf4, 0x35, 0x16, 0x35}; - lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xa5, 0x16, 0xba, 0xa7, 0x3a, 0x3, 0xd6, 0x12, 0x91, 0x4f, 0xed, 0xdd, 0xc5}; + lwmqtt_string_t topic_filter_s7 = {13, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe0, 0x18, 0xa0, 0xd3, 0x10}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0}; - lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; + sub_opts[3].no_local = false; sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[6].retain_as_published = true; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = true; - uint8_t bytesprops0[] = {0x64, 0x56}; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + uint8_t bytesprops0[] = {0x3e, 0xc5, 0x64, 0x1, 0x8d, 0xb6, 0xe9, 0x98, 0xa1, 0x65, 0x33, 0x5c, 0x27, + 0x46, 0x0, 0xf2, 0xee, 0xc9, 0x89, 0x3e, 0xe2, 0x60, 0x64, 0xf7, 0xd8, 0xc}; + uint8_t bytesprops2[] = {0xd4, 0x6e, 0xaa, 0x23, 0x92, 0xc5, 0x5d, 0xd8, 0xb3, 0xed, 0xed, 0x4b, + 0x2c, 0x42, 0xe3, 0x22, 0xbe, 0x7f, 0x3, 0x65, 0x49, 0x53, 0xc4}; + uint8_t bytesprops1[] = {0x10, 0x43, 0x85, 0x7f, 0x29, 0x66, 0x46, 0x3b, 0x68, 0x4f, + 0xca, 0x2b, 0x88, 0xb, 0xa0, 0xc5, 0x69, 0xee, 0x11, 0xd7}; + uint8_t bytesprops3[] = {0x5c, 0xfe, 0x31, 0xc4, 0x5e, 0x5e, 0xaf, 0x62, 0x88, 0x1b, 0x34, 0x64, + 0x40, 0x6e, 0xf1, 0x2, 0x73, 0x3e, 0x27, 0x57, 0x5c, 0x3d, 0x3a, 0x77}; + uint8_t bytesprops4[] = {0x89, 0xf}; + uint8_t bytesprops5[] = {0xdd, 0x18, 0xe5, 0x15, 0xa4, 0xc3, 0x9b, 0x1, 0xf4, 0xc1, 0x22, + 0x9, 0x8c, 0x85, 0x8c, 0xce, 0xd8, 0x9e, 0xd3, 0xf2, 0x10, 0xd2}; + uint8_t bytesprops6[] = {0x78, 0x9f, 0x64, 0x85, 0x1, 0xa1, 0xc6, 0x66, 0x44}; + uint8_t bytesprops7[] = {0x5a, 0xc5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25005}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32022}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2228}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1756}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19475}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12359}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 707}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops1}, .v = {23, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20679}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3791}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29126}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2636}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7512}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10542}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2720}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30315}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31102}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23603, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30426, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26458 [("\183`M\228xY\249D",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS1}),("\237\157\196\228p\189\168\211",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\255\152\155\238\160\241#",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS1}),("\221\172",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// True, _noLocal = True, _subQoS = -// QoS1}),("\212\176\130\245\147\226D\DC1\170\164\SOH\210`>\241\244\135\149\243\210\198#\166\227\243\195\ACK",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("S/\168!^A\129\141\161\212\235\177",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// True, _noLocal = True, _subQoS = QoS1}),("\160\228\STX\163#\156\211",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\131(\196qI\152p\148\234\235i\148\219\186\139A\137\SI\188\207\164\132%.\135G_\229\211\254",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropTopicAlias -// 19703] -TEST(Subscribe5QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x83, 0x1, 0x67, 0x5a, 0x3, 0x23, 0x4c, 0xf7, 0x0, 0x8, 0xb7, 0x60, 0x4d, 0xe4, 0x78, 0x59, - 0xf9, 0x44, 0x15, 0x0, 0x8, 0xed, 0x9d, 0xc4, 0xe4, 0x70, 0xbd, 0xa8, 0xd3, 0x21, 0x0, 0x7, 0xff, - 0x98, 0x9b, 0xee, 0xa0, 0xf1, 0x23, 0x29, 0x0, 0x2, 0xdd, 0xac, 0x1d, 0x0, 0x1b, 0xd4, 0xb0, 0x82, - 0xf5, 0x93, 0xe2, 0x44, 0x11, 0xaa, 0xa4, 0x1, 0xd2, 0x60, 0x3e, 0xf1, 0xf4, 0x87, 0x95, 0xf3, 0xd2, - 0xc6, 0x23, 0xa6, 0xe3, 0xf3, 0xc3, 0x6, 0x8, 0x0, 0xc, 0x53, 0x2f, 0xa8, 0x21, 0x5e, 0x41, 0x81, - 0x8d, 0xa1, 0xd4, 0xeb, 0xb1, 0x1d, 0x0, 0x7, 0xa0, 0xe4, 0x2, 0xa3, 0x23, 0x9c, 0xd3, 0x10, 0x0, - 0x1e, 0x83, 0x28, 0xc4, 0x71, 0x49, 0x98, 0x70, 0x94, 0xea, 0xeb, 0x69, 0x94, 0xdb, 0xba, 0x8b, 0x41, - 0x89, 0xf, 0xbc, 0xcf, 0xa4, 0x84, 0x25, 0x2e, 0x87, 0x47, 0x5f, 0xe5, 0xd3, 0xfe, 0xd}; +// SubscribeRequest 21987 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS2}),("Cz\235\f\236\158'=\190",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("l\166=\210\242k\194\162\DLE}w\148\202W\216\US\178\f",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("x\t\SO\224\131\ENQ\\\237\221\168\246&x\STX\246T\228\249\194\129\SUB",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\223\SI\255\235\250\134\ETX\178u\210",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = True, _subQoS = QoS2})] [PropMessageExpiryInterval 3349,PropContentType +// "C\236\n\232\162K",PropUserProperty "\145\162j\195>\181" +// "\141\239\221w\227\244)\a\DLE2h\170js\203\165\&1\214*",PropResponseInformation " +// J>!\132\t\146\FS\144x\187\154d\166\130\&6\143$JH\216\185\227",PropPayloadFormatIndicator 134] +TEST(Subscribe5QCTest, Encode24) { + uint8_t pkt[] = {0x82, 0x94, 0x1, 0x55, 0xe3, 0x48, 0x2, 0x0, 0x0, 0xd, 0x15, 0x3, 0x0, 0x6, 0x43, 0xec, 0xa, + 0xe8, 0xa2, 0x4b, 0x26, 0x0, 0x6, 0x91, 0xa2, 0x6a, 0xc3, 0x3e, 0xb5, 0x0, 0x13, 0x8d, 0xef, 0xdd, + 0x77, 0xe3, 0xf4, 0x29, 0x7, 0x10, 0x32, 0x68, 0xaa, 0x6a, 0x73, 0xcb, 0xa5, 0x31, 0xd6, 0x2a, 0x1a, + 0x0, 0x17, 0x20, 0x4a, 0x3e, 0x21, 0x84, 0x9, 0x92, 0x1c, 0x90, 0x78, 0xbb, 0x9a, 0x64, 0xa6, 0x82, + 0x36, 0x8f, 0x24, 0x4a, 0x48, 0xd8, 0xb9, 0xe3, 0x1, 0x86, 0x0, 0x0, 0xa, 0x0, 0x9, 0x43, 0x7a, + 0xeb, 0xc, 0xec, 0x9e, 0x27, 0x3d, 0xbe, 0x2, 0x0, 0x12, 0x6c, 0xa6, 0x3d, 0xd2, 0xf2, 0x6b, 0xc2, + 0xa2, 0x10, 0x7d, 0x77, 0x94, 0xca, 0x57, 0xd8, 0x1f, 0xb2, 0xc, 0x2d, 0x0, 0x15, 0x78, 0x9, 0xe, + 0xe0, 0x83, 0x5, 0x5c, 0xed, 0xdd, 0xa8, 0xf6, 0x26, 0x78, 0x2, 0xf6, 0x54, 0xe4, 0xf9, 0xc2, 0x81, + 0x1a, 0x24, 0x0, 0xa, 0xdf, 0xf, 0xff, 0xeb, 0xfa, 0x86, 0x3, 0xb2, 0x75, 0xd2, 0x2e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xb7, 0x60, 0x4d, 0xe4, 0x78, 0x59, 0xf9, 0x44}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xed, 0x9d, 0xc4, 0xe4, 0x70, 0xbd, 0xa8, 0xd3}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x43, 0x7a, 0xeb, 0xc, 0xec, 0x9e, 0x27, 0x3d, 0xbe}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xff, 0x98, 0x9b, 0xee, 0xa0, 0xf1, 0x23}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6c, 0xa6, 0x3d, 0xd2, 0xf2, 0x6b, 0xc2, 0xa2, 0x10, + 0x7d, 0x77, 0x94, 0xca, 0x57, 0xd8, 0x1f, 0xb2, 0xc}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xdd, 0xac}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x78, 0x9, 0xe, 0xe0, 0x83, 0x5, 0x5c, 0xed, 0xdd, 0xa8, 0xf6, + 0x26, 0x78, 0x2, 0xf6, 0x54, 0xe4, 0xf9, 0xc2, 0x81, 0x1a}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd4, 0xb0, 0x82, 0xf5, 0x93, 0xe2, 0x44, 0x11, 0xaa, 0xa4, 0x1, 0xd2, 0x60, 0x3e, - 0xf1, 0xf4, 0x87, 0x95, 0xf3, 0xd2, 0xc6, 0x23, 0xa6, 0xe3, 0xf3, 0xc3, 0x6}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xdf, 0xf, 0xff, 0xeb, 0xfa, 0x86, 0x3, 0xb2, 0x75, 0xd2}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x53, 0x2f, 0xa8, 0x21, 0x5e, 0x41, 0x81, 0x8d, 0xa1, 0xd4, 0xeb, 0xb1}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa0, 0xe4, 0x2, 0xa3, 0x23, 0x9c, 0xd3}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x83, 0x28, 0xc4, 0x71, 0x49, 0x98, 0x70, 0x94, 0xea, 0xeb, - 0x69, 0x94, 0xdb, 0xba, 0x8b, 0x41, 0x89, 0xf, 0xbc, 0xcf, - 0xa4, 0x84, 0x25, 0x2e, 0x87, 0x47, 0x5f, 0xe5, 0xd3, 0xfe}; - lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; + sub_opts[4].no_local = true; + uint8_t bytesprops0[] = {0x43, 0xec, 0xa, 0xe8, 0xa2, 0x4b}; + uint8_t bytesprops2[] = {0x8d, 0xef, 0xdd, 0x77, 0xe3, 0xf4, 0x29, 0x7, 0x10, 0x32, + 0x68, 0xaa, 0x6a, 0x73, 0xcb, 0xa5, 0x31, 0xd6, 0x2a}; + uint8_t bytesprops1[] = {0x91, 0xa2, 0x6a, 0xc3, 0x3e, 0xb5}; + uint8_t bytesprops3[] = {0x20, 0x4a, 0x3e, 0x21, 0x84, 0x9, 0x92, 0x1c, 0x90, 0x78, 0xbb, 0x9a, + 0x64, 0xa6, 0x82, 0x36, 0x8f, 0x24, 0x4a, 0x48, 0xd8, 0xb9, 0xe3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19703}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3349}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {19, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 134}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26458, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21987, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4488 [("y\134]",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = -// True, _subQoS = QoS2}),("M\251\156z\tw\201\201\201\b\244\145\253\166",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\207h\177E\207\162\163\233\143",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\CAN\241\ENQ/\"M\212\227\&2\237\164<\230\204\237\206eX\208\194\&7.",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\234\233uo\245\154\131\&5#\223~@\NAKY\140\175\191\179\141\129\166)\188k",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\233:\215\250\&2\131\227\DLE^\175J",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// True, _noLocal = False, _subQoS = QoS1})] [PropUserProperty "X\209\219\188\147\227\"\178Px\134" -// "_\162Wd#\149\162B%w",PropUserProperty "\157@\128\203\184\135K\181\ENQ\218\192" -// "\159\221\165\223\247\US\209;c\STX,\250\\8\178f\ENQ}\247\145\211\243e\137\189\DC2\128Tp",PropServerKeepAlive -// 4430,PropRetainAvailable 20,PropServerKeepAlive 12100,PropAssignedClientIdentifier -// "\a\146\174gc\227\SYNX\144\191\&4@\220UV\227QtI\146\CAN\130\152<:\ENQ",PropMessageExpiryInterval -// 27248,PropResponseInformation "\234\243\SI\212",PropSubscriptionIdentifier 4] -TEST(Subscribe5QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0xe2, 0x1, 0x11, 0x88, 0x7a, 0x26, 0x0, 0xb, 0x58, 0xd1, 0xdb, 0xbc, 0x93, 0xe3, 0x22, 0xb2, - 0x50, 0x78, 0x86, 0x0, 0xa, 0x5f, 0xa2, 0x57, 0x64, 0x23, 0x95, 0xa2, 0x42, 0x25, 0x77, 0x26, 0x0, - 0xb, 0x9d, 0x40, 0x80, 0xcb, 0xb8, 0x87, 0x4b, 0xb5, 0x5, 0xda, 0xc0, 0x0, 0x1d, 0x9f, 0xdd, 0xa5, - 0xdf, 0xf7, 0x1f, 0xd1, 0x3b, 0x63, 0x2, 0x2c, 0xfa, 0x5c, 0x38, 0xb2, 0x66, 0x5, 0x7d, 0xf7, 0x91, - 0xd3, 0xf3, 0x65, 0x89, 0xbd, 0x12, 0x80, 0x54, 0x70, 0x13, 0x11, 0x4e, 0x25, 0x14, 0x13, 0x2f, 0x44, - 0x12, 0x0, 0x1a, 0x7, 0x92, 0xae, 0x67, 0x63, 0xe3, 0x16, 0x58, 0x90, 0xbf, 0x34, 0x40, 0xdc, 0x55, - 0x56, 0xe3, 0x51, 0x74, 0x49, 0x92, 0x18, 0x82, 0x98, 0x3c, 0x3a, 0x5, 0x2, 0x0, 0x0, 0x6a, 0x70, - 0x1a, 0x0, 0x4, 0xea, 0xf3, 0xf, 0xd4, 0xb, 0x4, 0x0, 0x3, 0x79, 0x86, 0x5d, 0xe, 0x0, 0xe, - 0x4d, 0xfb, 0x9c, 0x7a, 0x9, 0x77, 0xc9, 0xc9, 0xc9, 0x8, 0xf4, 0x91, 0xfd, 0xa6, 0x4, 0x0, 0x9, - 0xcf, 0x68, 0xb1, 0x45, 0xcf, 0xa2, 0xa3, 0xe9, 0x8f, 0x24, 0x0, 0x16, 0x18, 0xf1, 0x5, 0x2f, 0x22, - 0x4d, 0xd4, 0xe3, 0x32, 0xed, 0xa4, 0x3c, 0xe6, 0xcc, 0xed, 0xce, 0x65, 0x58, 0xd0, 0xc2, 0x37, 0x2e, - 0x1d, 0x0, 0x18, 0xea, 0xe9, 0x75, 0x6f, 0xf5, 0x9a, 0x83, 0x35, 0x23, 0xdf, 0x7e, 0x40, 0x15, 0x59, - 0x8c, 0xaf, 0xbf, 0xb3, 0x8d, 0x81, 0xa6, 0x29, 0xbc, 0x6b, 0x18, 0x0, 0xb, 0xe9, 0x3a, 0xd7, 0xfa, - 0x32, 0x83, 0xe3, 0x10, 0x5e, 0xaf, 0x4a, 0x19}; +// SubscribeRequest 23704 [("t \154\149\224\EM\158fEc\239\249\&6\231\DC4\159",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\253\\\220\193&\209[",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("e",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("R[&",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("^\169\135\136\143\241q\SI\254\254",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropAuthenticationData " +// \168|\206\130&N\174en2aK\138",PropAssignedClientIdentifier +// "\215`\195\147\209\b\197V\184&5\161\137\215PD",PropSubscriptionIdentifierAvailable 121,PropResponseTopic +// "B\ae\234\GS\148\192\128\159X",PropRequestResponseInformation 196,PropWildcardSubscriptionAvailable +// 36,PropSharedSubscriptionAvailable 186,PropSubscriptionIdentifier 29,PropWillDelayInterval +// 23802,PropSubscriptionIdentifier 0,PropRequestResponseInformation 106,PropTopicAlias 30327,PropServerKeepAlive +// 7428,PropAuthenticationData "\ESC\177|@\239\GS\228\SYNTB\ENQ*\RS\248\214l\244\172\145\237/",PropResponseTopic +// "\159qn\179H5\158k\146",PropTopicAlias 10678,PropWillDelayInterval 31517,PropMessageExpiryInterval 1842] +TEST(Subscribe5QCTest, Encode25) { + uint8_t pkt[] = {0x82, 0xb2, 0x1, 0x5c, 0x98, 0x7b, 0x16, 0x0, 0xe, 0x20, 0xa8, 0x7c, 0xce, 0x82, 0x26, 0x4e, 0xae, + 0x65, 0x6e, 0x32, 0x61, 0x4b, 0x8a, 0x12, 0x0, 0x10, 0xd7, 0x60, 0xc3, 0x93, 0xd1, 0x8, 0xc5, 0x56, + 0xb8, 0x26, 0x35, 0xa1, 0x89, 0xd7, 0x50, 0x44, 0x29, 0x79, 0x8, 0x0, 0xa, 0x42, 0x7, 0x65, 0xea, + 0x1d, 0x94, 0xc0, 0x80, 0x9f, 0x58, 0x19, 0xc4, 0x28, 0x24, 0x2a, 0xba, 0xb, 0x1d, 0x18, 0x0, 0x0, + 0x5c, 0xfa, 0xb, 0x0, 0x19, 0x6a, 0x23, 0x76, 0x77, 0x13, 0x1d, 0x4, 0x16, 0x0, 0x15, 0x1b, 0xb1, + 0x7c, 0x40, 0xef, 0x1d, 0xe4, 0x16, 0x54, 0x42, 0x5, 0x2a, 0x1e, 0xf8, 0xd6, 0x6c, 0xf4, 0xac, 0x91, + 0xed, 0x2f, 0x8, 0x0, 0x9, 0x9f, 0x71, 0x6e, 0xb3, 0x48, 0x35, 0x9e, 0x6b, 0x92, 0x23, 0x29, 0xb6, + 0x18, 0x0, 0x0, 0x7b, 0x1d, 0x2, 0x0, 0x0, 0x7, 0x32, 0x0, 0x10, 0x74, 0x20, 0x9a, 0x95, 0xe0, + 0x19, 0x9e, 0x66, 0x45, 0x63, 0xef, 0xf9, 0x36, 0xe7, 0x14, 0x9f, 0x1d, 0x0, 0x7, 0xfd, 0x5c, 0xdc, + 0xc1, 0x26, 0xd1, 0x5b, 0x2a, 0x0, 0x1, 0x65, 0x2d, 0x0, 0x3, 0x52, 0x5b, 0x26, 0x21, 0x0, 0xa, + 0x5e, 0xa9, 0x87, 0x88, 0x8f, 0xf1, 0x71, 0xf, 0xfe, 0xfe, 0x2e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x79, 0x86, 0x5d}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x74, 0x20, 0x9a, 0x95, 0xe0, 0x19, 0x9e, 0x66, + 0x45, 0x63, 0xef, 0xf9, 0x36, 0xe7, 0x14, 0x9f}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4d, 0xfb, 0x9c, 0x7a, 0x9, 0x77, 0xc9, 0xc9, 0xc9, 0x8, 0xf4, 0x91, 0xfd, 0xa6}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xfd, 0x5c, 0xdc, 0xc1, 0x26, 0xd1, 0x5b}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xcf, 0x68, 0xb1, 0x45, 0xcf, 0xa2, 0xa3, 0xe9, 0x8f}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x65}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x18, 0xf1, 0x5, 0x2f, 0x22, 0x4d, 0xd4, 0xe3, 0x32, 0xed, 0xa4, - 0x3c, 0xe6, 0xcc, 0xed, 0xce, 0x65, 0x58, 0xd0, 0xc2, 0x37, 0x2e}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x52, 0x5b, 0x26}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xea, 0xe9, 0x75, 0x6f, 0xf5, 0x9a, 0x83, 0x35, 0x23, 0xdf, 0x7e, 0x40, - 0x15, 0x59, 0x8c, 0xaf, 0xbf, 0xb3, 0x8d, 0x81, 0xa6, 0x29, 0xbc, 0x6b}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x5e, 0xa9, 0x87, 0x88, 0x8f, 0xf1, 0x71, 0xf, 0xfe, 0xfe}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe9, 0x3a, 0xd7, 0xfa, 0x32, 0x83, 0xe3, 0x10, 0x5e, 0xaf, 0x4a}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - uint8_t bytesprops1[] = {0x5f, 0xa2, 0x57, 0x64, 0x23, 0x95, 0xa2, 0x42, 0x25, 0x77}; - uint8_t bytesprops0[] = {0x58, 0xd1, 0xdb, 0xbc, 0x93, 0xe3, 0x22, 0xb2, 0x50, 0x78, 0x86}; - uint8_t bytesprops3[] = {0x9f, 0xdd, 0xa5, 0xdf, 0xf7, 0x1f, 0xd1, 0x3b, 0x63, 0x2, 0x2c, 0xfa, 0x5c, 0x38, 0xb2, - 0x66, 0x5, 0x7d, 0xf7, 0x91, 0xd3, 0xf3, 0x65, 0x89, 0xbd, 0x12, 0x80, 0x54, 0x70}; - uint8_t bytesprops2[] = {0x9d, 0x40, 0x80, 0xcb, 0xb8, 0x87, 0x4b, 0xb5, 0x5, 0xda, 0xc0}; - uint8_t bytesprops4[] = {0x7, 0x92, 0xae, 0x67, 0x63, 0xe3, 0x16, 0x58, 0x90, 0xbf, 0x34, 0x40, 0xdc, - 0x55, 0x56, 0xe3, 0x51, 0x74, 0x49, 0x92, 0x18, 0x82, 0x98, 0x3c, 0x3a, 0x5}; - uint8_t bytesprops5[] = {0xea, 0xf3, 0xf, 0xd4}; + sub_opts[4].no_local = true; + uint8_t bytesprops0[] = {0x20, 0xa8, 0x7c, 0xce, 0x82, 0x26, 0x4e, 0xae, 0x65, 0x6e, 0x32, 0x61, 0x4b, 0x8a}; + uint8_t bytesprops1[] = {0xd7, 0x60, 0xc3, 0x93, 0xd1, 0x8, 0xc5, 0x56, + 0xb8, 0x26, 0x35, 0xa1, 0x89, 0xd7, 0x50, 0x44}; + uint8_t bytesprops2[] = {0x42, 0x7, 0x65, 0xea, 0x1d, 0x94, 0xc0, 0x80, 0x9f, 0x58}; + uint8_t bytesprops3[] = {0x1b, 0xb1, 0x7c, 0x40, 0xef, 0x1d, 0xe4, 0x16, 0x54, 0x42, 0x5, + 0x2a, 0x1e, 0xf8, 0xd6, 0x6c, 0xf4, 0xac, 0x91, 0xed, 0x2f}; + uint8_t bytesprops4[] = {0x9f, 0x71, 0x6e, 0xb3, 0x48, 0x35, 0x9e, 0x6b, 0x92}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops2}, .v = {29, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4430}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12100}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27248}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23802}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30327}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7428}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10678}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31517}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1842}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4488, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23704, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28692 -// [("a^z\164{\209P\192\235d\163\187\135\198\205\238\DC4\185h\146\199\197\&9\223\220\253",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("]\163\DC3\140]\129\245\224\164\163S",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = True, _noLocal = True, _subQoS = -// QoS2}),("\171\&1\208\132\SI\194\193m\ACK\203\239\SIx\ENQ\218\160O|1\235Y:\184\174",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\176\STX\244\239\208df\183(B\197x;\189\224\232 Y\218\155f\135\149v\249d\245\FS\208L",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\n#\223\137\184\136\225",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = False, _subQoS = -// QoS1}),("`\RS8\b\137\129\FS#\SO\234\SYN\192\217\144A'\216\235\227\226\ai\205\207}c",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("V\224\171\163j",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe5QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0x99, 0x1, 0x70, 0x14, 0x0, 0x0, 0x1a, 0x61, 0x5e, 0x7a, 0xa4, 0x7b, 0xd1, 0x50, 0xc0, - 0xeb, 0x64, 0xa3, 0xbb, 0x87, 0xc6, 0xcd, 0xee, 0x14, 0xb9, 0x68, 0x92, 0xc7, 0xc5, 0x39, 0xdf, - 0xdc, 0xfd, 0x16, 0x0, 0xb, 0x5d, 0xa3, 0x13, 0x8c, 0x5d, 0x81, 0xf5, 0xe0, 0xa4, 0xa3, 0x53, - 0x2e, 0x0, 0x18, 0xab, 0x31, 0xd0, 0x84, 0xf, 0xc2, 0xc1, 0x6d, 0x6, 0xcb, 0xef, 0xf, 0x78, - 0x5, 0xda, 0xa0, 0x4f, 0x7c, 0x31, 0xeb, 0x59, 0x3a, 0xb8, 0xae, 0x22, 0x0, 0x1e, 0xb0, 0x2, - 0xf4, 0xef, 0xd0, 0x64, 0x66, 0xb7, 0x28, 0x42, 0xc5, 0x78, 0x3b, 0xbd, 0xe0, 0xe8, 0x20, 0x59, - 0xda, 0x9b, 0x66, 0x87, 0x95, 0x76, 0xf9, 0x64, 0xf5, 0x1c, 0xd0, 0x4c, 0x22, 0x0, 0x7, 0xa, - 0x23, 0xdf, 0x89, 0xb8, 0x88, 0xe1, 0x29, 0x0, 0x1a, 0x60, 0x1e, 0x38, 0x8, 0x89, 0x81, 0x1c, - 0x23, 0xe, 0xea, 0x16, 0xc0, 0xd9, 0x90, 0x41, 0x27, 0xd8, 0xeb, 0xe3, 0xe2, 0x7, 0x69, 0xcd, - 0xcf, 0x7d, 0x63, 0x24, 0x0, 0x5, 0x56, 0xe0, 0xab, 0xa3, 0x6a, 0x10}; +// SubscribeRequest 25818 [("\235\&1\a\173\150\175\208\&8",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropSubscriptionIdentifierAvailable +// 144,PropPayloadFormatIndicator 206,PropMaximumPacketSize 27231,PropRequestResponseInformation 156,PropResponseTopic +// "_\211\188\198\192<\aE\211\217\248\139\251y\245\233\166\230P\232d\216\141:\208\131\EOT\130",PropSubscriptionIdentifierAvailable +// 1,PropAuthenticationData +// "\211~\162\CAN\ETBX\231\DEL\SOH\205\177\254\234N\ETB)\216\167\252\DELi\136\222",PropReceiveMaximum +// 2956,PropPayloadFormatIndicator 15,PropUserProperty "a +// (\135\161^\156\ACK\DC2\133/\136T\243\152\236\252\DEL\165MV\227r\128" +// "\235R>\DLE\166&\218\130\157\211\167\NAK{\227\NUL\174\169\191q"] +TEST(Subscribe5QCTest, Encode26) { + uint8_t pkt[] = {0x82, 0x89, 0x1, 0x64, 0xda, 0x7b, 0x29, 0x90, 0x1, 0xce, 0x27, 0x0, 0x0, 0x6a, 0x5f, 0x19, + 0x9c, 0x8, 0x0, 0x1c, 0x5f, 0xd3, 0xbc, 0xc6, 0xc0, 0x3c, 0x7, 0x45, 0xd3, 0xd9, 0xf8, 0x8b, + 0xfb, 0x79, 0xf5, 0xe9, 0xa6, 0xe6, 0x50, 0xe8, 0x64, 0xd8, 0x8d, 0x3a, 0xd0, 0x83, 0x4, 0x82, + 0x29, 0x1, 0x16, 0x0, 0x17, 0xd3, 0x7e, 0xa2, 0x18, 0x17, 0x58, 0xe7, 0x7f, 0x1, 0xcd, 0xb1, + 0xfe, 0xea, 0x4e, 0x17, 0x29, 0xd8, 0xa7, 0xfc, 0x7f, 0x69, 0x88, 0xde, 0x21, 0xb, 0x8c, 0x1, + 0xf, 0x26, 0x0, 0x18, 0x61, 0x20, 0x28, 0x87, 0xa1, 0x5e, 0x9c, 0x6, 0x12, 0x85, 0x2f, 0x88, + 0x54, 0xf3, 0x98, 0xec, 0xfc, 0x7f, 0xa5, 0x4d, 0x56, 0xe3, 0x72, 0x80, 0x0, 0x13, 0xeb, 0x52, + 0x3e, 0x10, 0xa6, 0x26, 0xda, 0x82, 0x9d, 0xd3, 0xa7, 0x15, 0x7b, 0xe3, 0x0, 0xae, 0xa9, 0xbf, + 0x71, 0x0, 0x8, 0xeb, 0x31, 0x7, 0xad, 0x96, 0xaf, 0xd0, 0x38, 0x29}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x61, 0x5e, 0x7a, 0xa4, 0x7b, 0xd1, 0x50, 0xc0, 0xeb, 0x64, 0xa3, 0xbb, 0x87, - 0xc6, 0xcd, 0xee, 0x14, 0xb9, 0x68, 0x92, 0xc7, 0xc5, 0x39, 0xdf, 0xdc, 0xfd}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xeb, 0x31, 0x7, 0xad, 0x96, 0xaf, 0xd0, 0x38}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5d, 0xa3, 0x13, 0x8c, 0x5d, 0x81, 0xf5, 0xe0, 0xa4, 0xa3, 0x53}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xab, 0x31, 0xd0, 0x84, 0xf, 0xc2, 0xc1, 0x6d, 0x6, 0xcb, 0xef, 0xf, - 0x78, 0x5, 0xda, 0xa0, 0x4f, 0x7c, 0x31, 0xeb, 0x59, 0x3a, 0xb8, 0xae}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb0, 0x2, 0xf4, 0xef, 0xd0, 0x64, 0x66, 0xb7, 0x28, 0x42, - 0xc5, 0x78, 0x3b, 0xbd, 0xe0, 0xe8, 0x20, 0x59, 0xda, 0x9b, - 0x66, 0x87, 0x95, 0x76, 0xf9, 0x64, 0xf5, 0x1c, 0xd0, 0x4c}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa, 0x23, 0xdf, 0x89, 0xb8, 0x88, 0xe1}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x60, 0x1e, 0x38, 0x8, 0x89, 0x81, 0x1c, 0x23, 0xe, 0xea, 0x16, 0xc0, 0xd9, - 0x90, 0x41, 0x27, 0xd8, 0xeb, 0xe3, 0xe2, 0x7, 0x69, 0xcd, 0xcf, 0x7d, 0x63}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x56, 0xe0, 0xab, 0xa3, 0x6a}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0x5f, 0xd3, 0xbc, 0xc6, 0xc0, 0x3c, 0x7, 0x45, 0xd3, 0xd9, 0xf8, 0x8b, 0xfb, 0x79, + 0xf5, 0xe9, 0xa6, 0xe6, 0x50, 0xe8, 0x64, 0xd8, 0x8d, 0x3a, 0xd0, 0x83, 0x4, 0x82}; + uint8_t bytesprops1[] = {0xd3, 0x7e, 0xa2, 0x18, 0x17, 0x58, 0xe7, 0x7f, 0x1, 0xcd, 0xb1, 0xfe, + 0xea, 0x4e, 0x17, 0x29, 0xd8, 0xa7, 0xfc, 0x7f, 0x69, 0x88, 0xde}; + uint8_t bytesprops3[] = {0xeb, 0x52, 0x3e, 0x10, 0xa6, 0x26, 0xda, 0x82, 0x9d, 0xd3, + 0xa7, 0x15, 0x7b, 0xe3, 0x0, 0xae, 0xa9, 0xbf, 0x71}; + uint8_t bytesprops2[] = {0x61, 0x20, 0x28, 0x87, 0xa1, 0x5e, 0x9c, 0x6, 0x12, 0x85, 0x2f, 0x88, + 0x54, 0xf3, 0x98, 0xec, 0xfc, 0x7f, 0xa5, 0x4d, 0x56, 0xe3, 0x72, 0x80}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27231}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2956}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops2}, .v = {19, (char*)&bytesprops3}}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28692, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25818, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11607 [("\200P\177\221",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("A\173\ETX\f\226l\DELM\233\194ndO4\248\238\130\173\224\214",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\246\222N\189z",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, -// _subQoS = QoS2}),("\216\NAKQ\172\ACK\138\167\168\&5&",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\SYN\130\197\169\254\\\180\144\164g\158k",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\NUL\214a\170\SOH\192\ETX\136M\252\SOH\238q\183\ETX\172\138\213$]\154J\166\142\232R",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Mu-|\132\218\214j\253",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = -// QoS0}),("\240\161\131\US\213\DC1\239\222\n\133\218\180j\176p\215\204s\138t\154N\163!\227y(\233l\166",SubOptions +// SubscribeRequest 19332 [("-\196\154\190n\186/h\n\161\203p\157Ap",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("~\210\229q\182\141\167%]a\fh\248\233\253\167>\NAKu\US\STX\133:",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\144;#\ENQ\236h-\ETX\243\164R3\237\241\129\171\225",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\254\167a\227\GS\169X\240\139\CAN\242\212K\164g]T\203\246\141",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\252=6J\200\227L",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("U\199y\ETX\222\t\"\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = +// True, _subQoS = QoS2}),("\202\SUB\220\214,g\158Ugne6\221\DLE\222}n\252\&1w/\NUL\171\244vou",SubOptions // {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\237\136f\131sp\148i\158+cYt\ESC;",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// True, _noLocal = True, _subQoS = QoS1})] [PropServerReference "0\150\153\ETBu\184\244",PropAssignedClientIdentifier -// "\187\&9c\"\178\219\255",PropSubscriptionIdentifierAvailable 204,PropAuthenticationMethod -// "0\158\176\141Ot\197\133\129\145){t\158\164\133\192\233\135\251bC",PropServerKeepAlive -// 16637,PropWildcardSubscriptionAvailable 86,PropUserProperty -// "\227\EM\189\244\157\SIuP\206?R\205b\208\187\144W9\179\239S\190\214\DC3\FS=3\249" -// "(\n\t\145\179<\162\157-\n\173\254\225j\148 \176\157",PropTopicAliasMaximum 11024,PropWildcardSubscriptionAvailable -// 220,PropResponseInformation "'\255\218N\162",PropAuthenticationData "\188\220\225\157\193",PropReasonString -// "\236\223KC\DC1\142\140\217\v\229{\182eY\204]",PropReceiveMaximum 11339,PropMessageExpiryInterval -// 12885,PropResponseInformation "\242\227#\150\130\226\178\215>",PropSubscriptionIdentifier 8] -TEST(Subscribe5QCTest, Encode29) { +// QoS1}),("-\SO\230DQ\130\178\\\129\&2i",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS0}),("\205\132\136\DC2y",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ACK)\174\200\186",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\140\197o\USH\162P\197x$\209\218\SI\172\GS\176\147\204\148\CAN\226\CAN",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropServerReference +// "`\SYN\DC1\153a\bn{xL\165p\242}?",PropAuthenticationData "\158\156\v\243) '4}}\SUB-\a",PropSessionExpiryInterval +// 15033,PropContentType "",PropSharedSubscriptionAvailable 192,PropAuthenticationData +// "\200\178\228\203i\203\185\US\135\170\v\227r\239\151\&6\EOT\141d\196&\241\145\234\179",PropUserProperty +// "\151\SUB\174\204\214\158" "T\138\253u\229\193!\158+\145J",PropReasonString +// "\252%8\154V\233\204\191\241\DC3l\244\DC4\246\252|`",PropSharedSubscriptionAvailable 67,PropReasonString +// "\STX",PropAssignedClientIdentifier +// "m2\197\179\208\191\193\230\181\DC3\168\137?.\ENQ\US\145RM\158(",PropMessageExpiryInterval +// 29660,PropMaximumPacketSize 2329,PropSubscriptionIdentifier 21,PropAuthenticationMethod +// "\RS)C&E\143m\241\169\US\205e<+\240@\220\254\172\169\241\SIc9\141",PropResponseTopic +// "\SYN*\216!\139\&1\224\&5K=\147K1\145\149:\133rB\156{\GS\188-",PropMessageExpiryInterval +// 1646,PropSubscriptionIdentifierAvailable 78,PropWillDelayInterval 23060,PropSubscriptionIdentifierAvailable 83] +TEST(Subscribe5QCTest, Encode27) { uint8_t pkt[] = { - 0x82, 0xc7, 0x2, 0x2d, 0x57, 0xa5, 0x1, 0x1c, 0x0, 0x7, 0x30, 0x96, 0x99, 0x17, 0x75, 0xb8, 0xf4, 0x12, 0x0, - 0x7, 0xbb, 0x39, 0x63, 0x22, 0xb2, 0xdb, 0xff, 0x29, 0xcc, 0x15, 0x0, 0x16, 0x30, 0x9e, 0xb0, 0x8d, 0x4f, 0x74, - 0xc5, 0x85, 0x81, 0x91, 0x29, 0x7b, 0x74, 0x9e, 0xa4, 0x85, 0xc0, 0xe9, 0x87, 0xfb, 0x62, 0x43, 0x13, 0x40, 0xfd, - 0x28, 0x56, 0x26, 0x0, 0x1c, 0xe3, 0x19, 0xbd, 0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xf1, 0x81, 0xab, 0xe1, 0x14, 0x0, 0x14, 0xfe, 0xa7, 0x61, 0xe3, 0x1d, 0xa9, + 0x58, 0xf0, 0x8b, 0x18, 0xf2, 0xd4, 0x4b, 0xa4, 0x67, 0x5d, 0x54, 0xcb, 0xf6, 0x8d, 0x1d, 0x0, 0x7, 0xfc, 0x3d, + 0x36, 0x4a, 0xc8, 0xe3, 0x4c, 0xe, 0x0, 0x8, 0x55, 0xc7, 0x79, 0x3, 0xde, 0x9, 0x22, 0xe8, 0xe, 0x0, 0x1b, + 0xca, 0x1a, 0xdc, 0xd6, 0x2c, 0x67, 0x9e, 0x55, 0x67, 0x6e, 0x65, 0x36, 0xdd, 0x10, 0xde, 0x7d, 0x6e, 0xfc, 0x31, + 0x77, 0x2f, 0x0, 0xab, 0xf4, 0x76, 0x6f, 0x75, 0x1d, 0x0, 0xb, 0x2d, 0xe, 0xe6, 0x44, 0x51, 0x82, 0xb2, 0x5c, + 0x81, 0x32, 0x69, 0x2c, 0x0, 0x5, 0xcd, 0x84, 0x88, 0x12, 0x79, 0x20, 0x0, 0x5, 0x6, 0x29, 0xae, 0xc8, 0xba, + 0x11, 0x0, 0x16, 0x8c, 0xc5, 0x6f, 0x1f, 0x48, 0xa2, 0x50, 0xc5, 0x78, 0x24, 0xd1, 0xda, 0xf, 0xac, 0x1d, 0xb0, + 0x93, 0xcc, 0x94, 0x18, 0xe2, 0x18, 0xe}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xc8, 0x50, 0xb1, 0xdd}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x2d, 0xc4, 0x9a, 0xbe, 0x6e, 0xba, 0x2f, 0x68, + 0xa, 0xa1, 0xcb, 0x70, 0x9d, 0x41, 0x70}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x41, 0xad, 0x3, 0xc, 0xe2, 0x6c, 0x7f, 0x4d, 0xe9, 0xc2, - 0x6e, 0x64, 0x4f, 0x34, 0xf8, 0xee, 0x82, 0xad, 0xe0, 0xd6}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7e, 0xd2, 0xe5, 0x71, 0xb6, 0x8d, 0xa7, 0x25, 0x5d, 0x61, 0xc, 0x68, + 0xf8, 0xe9, 0xfd, 0xa7, 0x3e, 0x15, 0x75, 0x1f, 0x2, 0x85, 0x3a}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf6, 0xde, 0x4e, 0xbd, 0x7a}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x90, 0x3b, 0x23, 0x5, 0xec, 0x68, 0x2d, 0x3, 0xf3, + 0xa4, 0x52, 0x33, 0xed, 0xf1, 0x81, 0xab, 0xe1}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd8, 0x15, 0x51, 0xac, 0x6, 0x8a, 0xa7, 0xa8, 0x35, 0x26}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfe, 0xa7, 0x61, 0xe3, 0x1d, 0xa9, 0x58, 0xf0, 0x8b, 0x18, + 0xf2, 0xd4, 0x4b, 0xa4, 0x67, 0x5d, 0x54, 0xcb, 0xf6, 0x8d}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x16, 0x82, 0xc5, 0xa9, 0xfe, 0x5c, 0xb4, 0x90, 0xa4, 0x67, 0x9e, 0x6b}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xfc, 0x3d, 0x36, 0x4a, 0xc8, 0xe3, 0x4c}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x0, 0xd6, 0x61, 0xaa, 0x1, 0xc0, 0x3, 0x88, 0x4d, 0xfc, 0x1, 0xee, 0x71, - 0xb7, 0x3, 0xac, 0x8a, 0xd5, 0x24, 0x5d, 0x9a, 0x4a, 0xa6, 0x8e, 0xe8, 0x52}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x55, 0xc7, 0x79, 0x3, 0xde, 0x9, 0x22, 0xe8}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4d, 0x75, 0x2d, 0x7c, 0x84, 0xda, 0xd6, 0x6a, 0xfd}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xca, 0x1a, 0xdc, 0xd6, 0x2c, 0x67, 0x9e, 0x55, 0x67, 0x6e, 0x65, 0x36, 0xdd, 0x10, + 0xde, 0x7d, 0x6e, 0xfc, 0x31, 0x77, 0x2f, 0x0, 0xab, 0xf4, 0x76, 0x6f, 0x75}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf0, 0xa1, 0x83, 0x1f, 0xd5, 0x11, 0xef, 0xde, 0xa, 0x85, - 0xda, 0xb4, 0x6a, 0xb0, 0x70, 0xd7, 0xcc, 0x73, 0x8a, 0x74, - 0x9a, 0x4e, 0xa3, 0x21, 0xe3, 0x79, 0x28, 0xe9, 0x6c, 0xa6}; - lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x2d, 0xe, 0xe6, 0x44, 0x51, 0x82, 0xb2, 0x5c, 0x81, 0x32, 0x69}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xed, 0x88, 0x66, 0x83, 0x73, 0x70, 0x94, 0x69, - 0x9e, 0x2b, 0x63, 0x59, 0x74, 0x1b, 0x3b}; - lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xcd, 0x84, 0x88, 0x12, 0x79}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s9_bytes[] = {0x6, 0x29, 0xae, 0xc8, 0xba}; + lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x8c, 0xc5, 0x6f, 0x1f, 0x48, 0xa2, 0x50, 0xc5, 0x78, 0x24, 0xd1, + 0xda, 0xf, 0xac, 0x1d, 0xb0, 0x93, 0xcc, 0x94, 0x18, 0xe2, 0x18}; + lwmqtt_string_t topic_filter_s10 = {22, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = true; + uint8_t bytesprops0[] = {0x60, 0x16, 0x11, 0x99, 0x61, 0x8, 0x6e, 0x7b, 0x78, 0x4c, 0xa5, 0x70, 0xf2, 0x7d, 0x3f}; + uint8_t bytesprops1[] = {0x9e, 0x9c, 0xb, 0xf3, 0x29, 0x20, 0x27, 0x34, 0x7d, 0x7d, 0x1a, 0x2d, 0x7}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0xc8, 0xb2, 0xe4, 0xcb, 0x69, 0xcb, 0xb9, 0x1f, 0x87, 0xaa, 0xb, 0xe3, 0x72, + 0xef, 0x97, 0x36, 0x4, 0x8d, 0x64, 0xc4, 0x26, 0xf1, 0x91, 0xea, 0xb3}; + uint8_t bytesprops5[] = {0x54, 0x8a, 0xfd, 0x75, 0xe5, 0xc1, 0x21, 0x9e, 0x2b, 0x91, 0x4a}; + uint8_t bytesprops4[] = {0x97, 0x1a, 0xae, 0xcc, 0xd6, 0x9e}; + uint8_t bytesprops6[] = {0xfc, 0x25, 0x38, 0x9a, 0x56, 0xe9, 0xcc, 0xbf, 0xf1, + 0x13, 0x6c, 0xf4, 0x14, 0xf6, 0xfc, 0x7c, 0x60}; + uint8_t bytesprops7[] = {0x2}; + uint8_t bytesprops8[] = {0x6d, 0x32, 0xc5, 0xb3, 0xd0, 0xbf, 0xc1, 0xe6, 0xb5, 0x13, 0xa8, + 0x89, 0x3f, 0x2e, 0x5, 0x1f, 0x91, 0x52, 0x4d, 0x9e, 0x28}; + uint8_t bytesprops9[] = {0x1e, 0x29, 0x43, 0x26, 0x45, 0x8f, 0x6d, 0xf1, 0xa9, 0x1f, 0xcd, 0x65, 0x3c, + 0x2b, 0xf0, 0x40, 0xdc, 0xfe, 0xac, 0xa9, 0xf1, 0xf, 0x63, 0x39, 0x8d}; + uint8_t bytesprops10[] = {0x16, 0x2a, 0xd8, 0x21, 0x8b, 0x31, 0xe0, 0x35, 0x4b, 0x3d, 0x93, 0x4b, + 0x31, 0x91, 0x95, 0x3a, 0x85, 0x72, 0x42, 0x9c, 0x7b, 0x1d, 0xbc, 0x2d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15033}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops4}, .v = {11, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29660}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2329}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1646}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23060}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 83}}, + }; + + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19332, 11, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 20518 [("\184",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\208\138rec7\DLE\135k\b\245\159\135\&8\198\&0x\EM\188\ESC",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("OC{\222\a\203\253\158#\181\203J&\a\179\STX6\141\175\135\212QE\DC4<\207",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("qa\DC3x\197\165\234`\236\156",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS2}),("j\241\241/\244.\251\220v\185(f\144\147\f\170\246\219",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("f\189\233W\169\244b\222\169",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [PropAuthenticationMethod +// "\227\218\145n\182T\238|~i\ESCZ^_",PropRequestProblemInformation 24,PropSubscriptionIdentifierAvailable +// 55,PropReasonString "!\214\143:~",PropAuthenticationData "\202\140\159J\245\154 '4\159\238\DC1\141",PropTopicAlias +// 10438,PropTopicAlias 6509,PropTopicAlias 30518,PropPayloadFormatIndicator 101,PropRequestResponseInformation +// 103,PropSharedSubscriptionAvailable 143,PropSessionExpiryInterval 5218,PropWillDelayInterval +// 31083,PropServerReference "\147\235[N\214*\128\&0",PropSessionExpiryInterval 19195,PropResponseTopic +// "\197",PropPayloadFormatIndicator 100,PropServerReference +// "\209K\246A\176\192<\CAN\219\ETB\132\190\219\152H\176R\CAN\205\253\170\\`!l\195\a\DC2\DLEL",PropReasonString +// "\160\&2\210#\DC3\DC3\160\230\251\211\243\202\217\226\142\151_S\EOT}?\SO\166\222\EM6\159\175\EOT",PropMaximumPacketSize +// 21571,PropUserProperty "\STX\154\CAN\169jr\241\202P" +// "k\ESC\182\EM[\251\251\184\&7ah9\214\211\156J#\251\136\145\227I\185",PropMessageExpiryInterval +// 5854,PropSubscriptionIdentifier 28] +TEST(Subscribe5QCTest, Encode28) { + uint8_t pkt[] = { + 0x82, 0xbb, 0x2, 0x50, 0x26, 0xce, 0x1, 0x15, 0x0, 0xe, 0xe3, 0xda, 0x91, 0x6e, 0xb6, 0x54, 0xee, 0x7c, 0x7e, + 0x69, 0x1b, 0x5a, 0x5e, 0x5f, 0x17, 0x18, 0x29, 0x37, 0x1f, 0x0, 0x5, 0x21, 0xd6, 0x8f, 0x3a, 0x7e, 0x16, 0x0, + 0xd, 0xca, 0x8c, 0x9f, 0x4a, 0xf5, 0x9a, 0x20, 0x27, 0x34, 0x9f, 0xee, 0x11, 0x8d, 0x23, 0x28, 0xc6, 0x23, 0x19, + 0x6d, 0x23, 0x77, 0x36, 0x1, 0x65, 0x19, 0x67, 0x2a, 0x8f, 0x11, 0x0, 0x0, 0x14, 0x62, 0x18, 0x0, 0x0, 0x79, + 0x6b, 0x1c, 0x0, 0x8, 0x93, 0xeb, 0x5b, 0x4e, 0xd6, 0x2a, 0x80, 0x30, 0x11, 0x0, 0x0, 0x4a, 0xfb, 0x8, 0x0, + 0x1, 0xc5, 0x1, 0x64, 0x1c, 0x0, 0x1e, 0xd1, 0x4b, 0xf6, 0x41, 0xb0, 0xc0, 0x3c, 0x18, 0xdb, 0x17, 0x84, 0xbe, + 0xdb, 0x98, 0x48, 0xb0, 0x52, 0x18, 0xcd, 0xfd, 0xaa, 0x5c, 0x60, 0x21, 0x6c, 0xc3, 0x7, 0x12, 0x10, 0x4c, 0x1f, + 0x0, 0x1d, 0xa0, 0x32, 0xd2, 0x23, 0x13, 0x13, 0xa0, 0xe6, 0xfb, 0xd3, 0xf3, 0xca, 0xd9, 0xe2, 0x8e, 0x97, 0x5f, + 0x53, 0x4, 0x7d, 0x3f, 0xe, 0xa6, 0xde, 0x19, 0x36, 0x9f, 0xaf, 0x4, 0x27, 0x0, 0x0, 0x54, 0x43, 0x26, 0x0, + 0x9, 0x2, 0x9a, 0x18, 0xa9, 0x6a, 0x72, 0xf1, 0xca, 0x50, 0x0, 0x17, 0x6b, 0x1b, 0xb6, 0x19, 0x5b, 0xfb, 0xfb, + 0xb8, 0x37, 0x61, 0x68, 0x39, 0xd6, 0xd3, 0x9c, 0x4a, 0x23, 0xfb, 0x88, 0x91, 0xe3, 0x49, 0xb9, 0x2, 0x0, 0x0, + 0x16, 0xde, 0xb, 0x1c, 0x0, 0x1, 0xb8, 0x11, 0x0, 0x14, 0xd0, 0x8a, 0x72, 0x65, 0x63, 0x37, 0x10, 0x87, 0x6b, + 0x8, 0xf5, 0x9f, 0x87, 0x38, 0xc6, 0x30, 0x78, 0x19, 0xbc, 0x1b, 0x24, 0x0, 0x0, 0xd, 0x0, 0x1a, 0x4f, 0x43, + 0x7b, 0xde, 0x7, 0xcb, 0xfd, 0x9e, 0x23, 0xb5, 0xcb, 0x4a, 0x26, 0x7, 0xb3, 0x2, 0x36, 0x8d, 0xaf, 0x87, 0xd4, + 0x51, 0x45, 0x14, 0x3c, 0xcf, 0xc, 0x0, 0xa, 0x71, 0x61, 0x13, 0x78, 0xc5, 0xa5, 0xea, 0x60, 0xec, 0x9c, 0xe, + 0x0, 0x12, 0x6a, 0xf1, 0xf1, 0x2f, 0xf4, 0x2e, 0xfb, 0xdc, 0x76, 0xb9, 0x28, 0x66, 0x90, 0x93, 0xc, 0xaa, 0xf6, + 0xdb, 0xc, 0x0, 0x9, 0x66, 0xbd, 0xe9, 0x57, 0xa9, 0xf4, 0x62, 0xde, 0xa9, 0x21}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xb8}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd0, 0x8a, 0x72, 0x65, 0x63, 0x37, 0x10, 0x87, 0x6b, 0x8, + 0xf5, 0x9f, 0x87, 0x38, 0xc6, 0x30, 0x78, 0x19, 0xbc, 0x1b}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x4f, 0x43, 0x7b, 0xde, 0x7, 0xcb, 0xfd, 0x9e, 0x23, 0xb5, 0xcb, 0x4a, 0x26, + 0x7, 0xb3, 0x2, 0x36, 0x8d, 0xaf, 0x87, 0xd4, 0x51, 0x45, 0x14, 0x3c, 0xcf}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x71, 0x61, 0x13, 0x78, 0xc5, 0xa5, 0xea, 0x60, 0xec, 0x9c}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6a, 0xf1, 0xf1, 0x2f, 0xf4, 0x2e, 0xfb, 0xdc, 0x76, + 0xb9, 0x28, 0x66, 0x90, 0x93, 0xc, 0xaa, 0xf6, 0xdb}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x66, 0xbd, 0xe9, 0x57, 0xa9, 0xf4, 0x62, 0xde, 0xa9}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + uint8_t bytesprops0[] = {0xe3, 0xda, 0x91, 0x6e, 0xb6, 0x54, 0xee, 0x7c, 0x7e, 0x69, 0x1b, 0x5a, 0x5e, 0x5f}; + uint8_t bytesprops1[] = {0x21, 0xd6, 0x8f, 0x3a, 0x7e}; + uint8_t bytesprops2[] = {0xca, 0x8c, 0x9f, 0x4a, 0xf5, 0x9a, 0x20, 0x27, 0x34, 0x9f, 0xee, 0x11, 0x8d}; + uint8_t bytesprops3[] = {0x93, 0xeb, 0x5b, 0x4e, 0xd6, 0x2a, 0x80, 0x30}; + uint8_t bytesprops4[] = {0xc5}; + uint8_t bytesprops5[] = {0xd1, 0x4b, 0xf6, 0x41, 0xb0, 0xc0, 0x3c, 0x18, 0xdb, 0x17, 0x84, 0xbe, 0xdb, 0x98, 0x48, + 0xb0, 0x52, 0x18, 0xcd, 0xfd, 0xaa, 0x5c, 0x60, 0x21, 0x6c, 0xc3, 0x7, 0x12, 0x10, 0x4c}; + uint8_t bytesprops6[] = {0xa0, 0x32, 0xd2, 0x23, 0x13, 0x13, 0xa0, 0xe6, 0xfb, 0xd3, 0xf3, 0xca, 0xd9, 0xe2, 0x8e, + 0x97, 0x5f, 0x53, 0x4, 0x7d, 0x3f, 0xe, 0xa6, 0xde, 0x19, 0x36, 0x9f, 0xaf, 0x4}; + uint8_t bytesprops8[] = {0x6b, 0x1b, 0xb6, 0x19, 0x5b, 0xfb, 0xfb, 0xb8, 0x37, 0x61, 0x68, 0x39, + 0xd6, 0xd3, 0x9c, 0x4a, 0x23, 0xfb, 0x88, 0x91, 0xe3, 0x49, 0xb9}; + uint8_t bytesprops7[] = {0x2, 0x9a, 0x18, 0xa9, 0x6a, 0x72, 0xf1, 0xca, 0x50}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10438}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6509}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30518}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5218}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31083}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19195}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21571}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops7}, .v = {23, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5854}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20518, 7, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 4648 [("\172K\233\189\190\a>\228I\131=\247\DEL\255",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("d\206\145J",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\192\f%\166\NAK\218D3Q\180\233O'N\DC39i5\236\&2r",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\195\233]\b\254s\198E",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\161\EOTL\192\&7\180m\152*\178,\241`\199\167 ",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\159\FS\203g6+\169\183\247\253\137\168\SO\174\243\r\EOT\tH\EOTkQ\a)G#:7\204\DC3",SubOptions {_retainHandling +// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\RSB)}\225\170\218\238\205\247",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [PropUserProperty "\242\203\"\220\218\214" +// "\NUL?\DC4\232\&9\208]\208\NULW\154\185\177\STX\254",PropReceiveMaximum +// 4372,PropSubscriptionIdentifier 15,PropPayloadFormatIndicator 95,PropReasonString +// "D\170\DC2d\148:\f\220\164\254\174",PropSubscriptionIdentifierAvailable 122,PropMaximumQoS 207,PropServerKeepAlive +// 3358,PropMaximumQoS 74,PropWillDelayInterval 18357] +TEST(Subscribe5QCTest, Encode29) { + uint8_t pkt[] = {0x82, 0xc5, 0x1, 0x12, 0x28, 0x46, 0x26, 0x0, 0x6, 0xf2, 0xcb, 0x22, 0xdc, 0xda, 0xd6, 0x0, 0x18, + 0x0, 0x3f, 0x14, 0x3c, 0x64, 0x94, 0x33, 0xaa, 0x81, 0x2f, 0xc7, 0x3e, 0xe8, 0x39, 0xd0, 0x5d, 0xd0, + 0x0, 0x57, 0x9a, 0xb9, 0xb1, 0x2, 0xfe, 0x21, 0x11, 0x14, 0xb, 0xf, 0x1, 0x5f, 0x1f, 0x0, 0xb, + 0x44, 0xaa, 0x12, 0x64, 0x94, 0x3a, 0xc, 0xdc, 0xa4, 0xfe, 0xae, 0x29, 0x7a, 0x24, 0xcf, 0x13, 0xd, + 0x1e, 0x24, 0x4a, 0x18, 0x0, 0x0, 0x47, 0xb5, 0x0, 0xe, 0xac, 0x4b, 0xe9, 0xbd, 0xbe, 0x7, 0x3e, + 0xe4, 0x49, 0x83, 0x3d, 0xf7, 0x7f, 0xff, 0x14, 0x0, 0x4, 0x64, 0xce, 0x91, 0x4a, 0x1, 0x0, 0x15, + 0xc0, 0xc, 0x25, 0xa6, 0x15, 0xda, 0x44, 0x33, 0x51, 0xb4, 0xe9, 0x4f, 0x27, 0x4e, 0x13, 0x39, 0x69, + 0x35, 0xec, 0x32, 0x72, 0x2, 0x0, 0x8, 0xc3, 0xe9, 0x5d, 0x8, 0xfe, 0x73, 0xc6, 0x45, 0x2e, 0x0, + 0x10, 0xa1, 0x4, 0x4c, 0xc0, 0x37, 0xb4, 0x6d, 0x98, 0x2a, 0xb2, 0x2c, 0xf1, 0x60, 0xc7, 0xa7, 0x20, + 0x8, 0x0, 0x1e, 0x9f, 0x1c, 0xcb, 0x67, 0x36, 0x2b, 0xa9, 0xb7, 0xf7, 0xfd, 0x89, 0xa8, 0xe, 0xae, + 0xf3, 0xd, 0x4, 0x9, 0x48, 0x4, 0x6b, 0x51, 0x7, 0x29, 0x47, 0x23, 0x3a, 0x37, 0xcc, 0x13, 0x18, + 0x0, 0xa, 0x1e, 0x42, 0x29, 0x7d, 0xe1, 0xaa, 0xda, 0xee, 0xcd, 0xf7, 0x12}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xac, 0x4b, 0xe9, 0xbd, 0xbe, 0x7, 0x3e, 0xe4, 0x49, 0x83, 0x3d, 0xf7, 0x7f, 0xff}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x64, 0xce, 0x91, 0x4a}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc0, 0xc, 0x25, 0xa6, 0x15, 0xda, 0x44, 0x33, 0x51, 0xb4, 0xe9, + 0x4f, 0x27, 0x4e, 0x13, 0x39, 0x69, 0x35, 0xec, 0x32, 0x72}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc3, 0xe9, 0x5d, 0x8, 0xfe, 0x73, 0xc6, 0x45}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa1, 0x4, 0x4c, 0xc0, 0x37, 0xb4, 0x6d, 0x98, + 0x2a, 0xb2, 0x2c, 0xf1, 0x60, 0xc7, 0xa7, 0x20}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x9f, 0x1c, 0xcb, 0x67, 0x36, 0x2b, 0xa9, 0xb7, 0xf7, 0xfd, + 0x89, 0xa8, 0xe, 0xae, 0xf3, 0xd, 0x4, 0x9, 0x48, 0x4, + 0x6b, 0x51, 0x7, 0x29, 0x47, 0x23, 0x3a, 0x37, 0xcc, 0x13}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x1e, 0x42, 0x29, 0x7d, 0xe1, 0xaa, 0xda, 0xee, 0xcd, 0xf7}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = true; - uint8_t bytesprops0[] = {0x30, 0x96, 0x99, 0x17, 0x75, 0xb8, 0xf4}; - uint8_t bytesprops1[] = {0xbb, 0x39, 0x63, 0x22, 0xb2, 0xdb, 0xff}; - uint8_t bytesprops2[] = {0x30, 0x9e, 0xb0, 0x8d, 0x4f, 0x74, 0xc5, 0x85, 0x81, 0x91, 0x29, - 0x7b, 0x74, 0x9e, 0xa4, 0x85, 0xc0, 0xe9, 0x87, 0xfb, 0x62, 0x43}; - uint8_t bytesprops4[] = {0x28, 0xa, 0x9, 0x91, 0xb3, 0x3c, 0xa2, 0x9d, 0x2d, - 0xa, 0xad, 0xfe, 0xe1, 0x6a, 0x94, 0x20, 0xb0, 0x9d}; - uint8_t bytesprops3[] = {0xe3, 0x19, 0xbd, 0xf4, 0x9d, 0xf, 0x75, 0x50, 0xce, 0x3f, 0x52, 0xcd, 0x62, 0xd0, - 0xbb, 0x90, 0x57, 0x39, 0xb3, 0xef, 0x53, 0xbe, 0xd6, 0x13, 0x1c, 0x3d, 0x33, 0xf9}; - uint8_t bytesprops5[] = {0x27, 0xff, 0xda, 0x4e, 0xa2}; - uint8_t bytesprops6[] = {0xbc, 0xdc, 0xe1, 0x9d, 0xc1}; - uint8_t bytesprops7[] = {0xec, 0xdf, 0x4b, 0x43, 0x11, 0x8e, 0x8c, 0xd9, - 0xb, 0xe5, 0x7b, 0xb6, 0x65, 0x59, 0xcc, 0x5d}; - uint8_t bytesprops8[] = {0xf2, 0xe3, 0x23, 0x96, 0x82, 0xe2, 0xb2, 0xd7, 0x3e}; + sub_opts[6].no_local = false; + uint8_t bytesprops1[] = {0x0, 0x3f, 0x14, 0x3c, 0x64, 0x94, 0x33, 0xaa, 0x81, 0x2f, 0xc7, 0x3e, + 0xe8, 0x39, 0xd0, 0x5d, 0xd0, 0x0, 0x57, 0x9a, 0xb9, 0xb1, 0x2, 0xfe}; + uint8_t bytesprops0[] = {0xf2, 0xcb, 0x22, 0xdc, 0xda, 0xd6}; + uint8_t bytesprops2[] = {0x44, 0xaa, 0x12, 0x64, 0x94, 0x3a, 0xc, 0xdc, 0xa4, 0xfe, 0xae}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16637}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops3}, .v = {18, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11024}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11339}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12885}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4372}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3358}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18357}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11607, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4648, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22426 [("\FS\227\218",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1})] [PropMaximumPacketSize 19858,PropAuthenticationMethod -// "\217<\SIme\220j\224Wj{\233\SIuW@&\133\254\155;\199\177\173",PropTopicAlias 574,PropSubscriptionIdentifierAvailable -// 218,PropReasonString "\253",PropReasonString "*\240\251\250S\202`\218",PropContentType -// "\SID`\\\150(\v\RSL\198\"r\141Do\247\CANP\193\230\189\ETX\161u",PropServerReference "\191",PropWillDelayInterval -// 12739,PropMaximumPacketSize 16985] +// SubscribeRequest 13920 [(";q\215\241\130b\220s",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval +// 7604,PropResponseInformation "\194\181\171\148\138l\NUL\194\229\254m\134@\245\194\170\234",PropUserProperty +// "M\f\245\229\241Y\130\152\DEL8/fJ\193\139\DLE\243\146\134UC`\151,\229\237\132K\235" +// "\254f'G\236UH\222",PropMaximumQoS 22,PropRequestProblemInformation 80,PropAuthenticationMethod +// "\169\&7\177v.=\237Z\184Q\186\RS\222",PropMessageExpiryInterval 31770,PropSubscriptionIdentifier +// 15,PropAuthenticationData "\151m[ZUo]\141\131\195e\181\SOH\168\ETB5C\248",PropTopicAlias +// 32243,PropSubscriptionIdentifierAvailable 45,PropReceiveMaximum 9546,PropMaximumPacketSize +// 28536,PropSubscriptionIdentifier 25,PropRetainAvailable 82,PropContentType +// "\198\148\179\174G\212\153HId\187\208\181f\SOH\182\255X\140/\189\214\244<\145-",PropUserProperty +// "\v\221I\226\230\174|\SOH|\161\176_\210\US\ETBwW\244\255z\EMI56" +// "7\176\134\192`\226i1\223\146b\221\140\&8#\DC3c\129",PropSessionExpiryInterval 23112,PropWillDelayInterval +// 3222,PropServerReference "",PropSubscriptionIdentifierAvailable 39,PropTopicAliasMaximum 26662] TEST(Subscribe5QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x66, 0x57, 0x9a, 0x5d, 0x27, 0x0, 0x0, 0x4d, 0x92, 0x15, 0x0, 0x18, 0xd9, 0x3c, - 0xf, 0x6d, 0x65, 0xdc, 0x6a, 0xe0, 0x57, 0x6a, 0x7b, 0xe9, 0xf, 0x75, 0x57, 0x40, 0x26, - 0x85, 0xfe, 0x9b, 0x3b, 0xc7, 0xb1, 0xad, 0x23, 0x2, 0x3e, 0x29, 0xda, 0x1f, 0x0, 0x1, - 0xfd, 0x1f, 0x0, 0x8, 0x2a, 0xf0, 0xfb, 0xfa, 0x53, 0xca, 0x60, 0xda, 0x3, 0x0, 0x18, - 0xf, 0x44, 0x60, 0x5c, 0x96, 0x28, 0xb, 0x1e, 0x4c, 0xc6, 0x22, 0x72, 0x8d, 0x44, 0x6f, - 0xf7, 0x18, 0x50, 0xc1, 0xe6, 0xbd, 0x3, 0xa1, 0x75, 0x1c, 0x0, 0x1, 0xbf, 0x18, 0x0, - 0x0, 0x31, 0xc3, 0x27, 0x0, 0x0, 0x42, 0x59, 0x0, 0x3, 0x1c, 0xe3, 0xda, 0x1}; + uint8_t pkt[] = { + 0x82, 0xf1, 0x1, 0x36, 0x60, 0xe2, 0x1, 0x2, 0x0, 0x0, 0x1d, 0xb4, 0x1a, 0x0, 0x11, 0xc2, 0xb5, 0xab, 0x94, + 0x8a, 0x6c, 0x0, 0xc2, 0xe5, 0xfe, 0x6d, 0x86, 0x40, 0xf5, 0xc2, 0xaa, 0xea, 0x26, 0x0, 0x1d, 0x4d, 0xc, 0xf5, + 0xe5, 0xf1, 0x59, 0x82, 0x98, 0x7f, 0x38, 0x2f, 0x66, 0x4a, 0xc1, 0x8b, 0x10, 0xf3, 0x92, 0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73, 0x29}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x1c, 0xe3, 0xda}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x3b, 0x71, 0xd7, 0xf1, 0x82, 0x62, 0xdc, 0x73}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; lwmqtt_sub_options_t sub_opts[1]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - uint8_t bytesprops0[] = {0xd9, 0x3c, 0xf, 0x6d, 0x65, 0xdc, 0x6a, 0xe0, 0x57, 0x6a, 0x7b, 0xe9, - 0xf, 0x75, 0x57, 0x40, 0x26, 0x85, 0xfe, 0x9b, 0x3b, 0xc7, 0xb1, 0xad}; - uint8_t bytesprops1[] = {0xfd}; - uint8_t bytesprops2[] = {0x2a, 0xf0, 0xfb, 0xfa, 0x53, 0xca, 0x60, 0xda}; - uint8_t bytesprops3[] = {0xf, 0x44, 0x60, 0x5c, 0x96, 0x28, 0xb, 0x1e, 0x4c, 0xc6, 0x22, 0x72, - 0x8d, 0x44, 0x6f, 0xf7, 0x18, 0x50, 0xc1, 0xe6, 0xbd, 0x3, 0xa1, 0x75}; - uint8_t bytesprops4[] = {0xbf}; + uint8_t bytesprops0[] = {0xc2, 0xb5, 0xab, 0x94, 0x8a, 0x6c, 0x0, 0xc2, 0xe5, + 0xfe, 0x6d, 0x86, 0x40, 0xf5, 0xc2, 0xaa, 0xea}; + uint8_t bytesprops2[] = {0xfe, 0x66, 0x27, 0x47, 0xec, 0x55, 0x48, 0xde}; + uint8_t bytesprops1[] = {0x4d, 0xc, 0xf5, 0xe5, 0xf1, 0x59, 0x82, 0x98, 0x7f, 0x38, 0x2f, 0x66, 0x4a, 0xc1, 0x8b, + 0x10, 0xf3, 0x92, 0x86, 0x55, 0x43, 0x60, 0x97, 0x2c, 0xe5, 0xed, 0x84, 0x4b, 0xeb}; + uint8_t bytesprops3[] = {0xa9, 0x37, 0xb1, 0x76, 0x2e, 0x3d, 0xed, 0x5a, 0xb8, 0x51, 0xba, 0x1e, 0xde}; + uint8_t bytesprops4[] = {0x97, 0x6d, 0x5b, 0x5a, 0x55, 0x6f, 0x5d, 0x8d, 0x83, + 0xc3, 0x65, 0xb5, 0x1, 0xa8, 0x17, 0x35, 0x43, 0xf8}; + uint8_t bytesprops5[] = {0xc6, 0x94, 0xb3, 0xae, 0x47, 0xd4, 0x99, 0x48, 0x49, 0x64, 0xbb, 0xd0, 0xb5, + 0x66, 0x1, 0xb6, 0xff, 0x58, 0x8c, 0x2f, 0xbd, 0xd6, 0xf4, 0x3c, 0x91, 0x2d}; + uint8_t bytesprops7[] = {0x37, 0xb0, 0x86, 0xc0, 0x60, 0xe2, 0x69, 0x31, 0xdf, + 0x92, 0x62, 0xdd, 0x8c, 0x38, 0x23, 0x13, 0x63, 0x81}; + uint8_t bytesprops6[] = {0xb, 0xdd, 0x49, 0xe2, 0xe6, 0xae, 0x7c, 0x1, 0x7c, 0xa1, 0xb0, 0x5f, + 0xd2, 0x1f, 0x17, 0x77, 0x57, 0xf4, 0xff, 0x7a, 0x19, 0x49, 0x35, 0x36}; + uint8_t bytesprops8[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19858}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 574}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12739}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16985}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7604}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31770}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32243}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9546}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28536}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops6}, .v = {18, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23112}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3222}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26662}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22426, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13920, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } + +// SubscribeResponse 4646 [Right QoS1,Left SubErrUnspecifiedError,Right QoS2,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Right +// QoS0,Left SubErrUnspecifiedError] [] +TEST(SubACK311QCTest, Decode1) { + uint8_t pkt[] = {0x90, 0xb, 0x12, 0x26, 0x1, 0x80, 0x2, 0xa1, 0x1, 0x1, 0xa2, 0x0, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4646); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], 0x80); +} + +// SubscribeResponse 3536 [Right QoS1,Left SubErrUnspecifiedError,Left SubErrSubscriptionIdentifiersNotSupported] [] +TEST(SubACK311QCTest, Decode2) { + uint8_t pkt[] = {0x90, 0x5, 0xd, 0xd0, 0x1, 0x80, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 3536); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); +} + +// SubscribeResponse 13945 [Left SubErrPacketIdentifierInUse,Right QoS1] [] +TEST(SubACK311QCTest, Decode3) { + uint8_t pkt[] = {0x90, 0x4, 0x36, 0x79, 0x91, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 13945); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); +} + +// SubscribeResponse 27071 [Right QoS0,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left +// SubErrUnspecifiedError,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrSubscriptionIdentifiersNotSupported] [] +TEST(SubACK311QCTest, Decode4) { + uint8_t pkt[] = {0x90, 0xa, 0x69, 0xbf, 0x0, 0x1, 0xa2, 0x0, 0x80, 0x2, 0xa2, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 27071); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); +} + +// SubscribeResponse 29147 [Right QoS2,Right QoS2,Left SubErrImplementationSpecificError,Left +// SubErrUnspecifiedError,Right QoS2,Right QoS2] [] +TEST(SubACK311QCTest, Decode5) { + uint8_t pkt[] = {0x90, 0x8, 0x71, 0xdb, 0x2, 0x2, 0x83, 0x80, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 29147); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); +} + +// SubscribeResponse 9531 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Left +// SubErrTopicFilterInvalid,Right QoS1,Left SubErrNotAuthorized,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS2] [] +TEST(SubACK311QCTest, Decode6) { + uint8_t pkt[] = {0x90, 0xc, 0x25, 0x3b, 0x1, 0xa1, 0x2, 0x8f, 0x1, 0x87, 0x0, 0x9e, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 9531); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); +} + +// SubscribeResponse 30374 [Left SubErrQuotaExceeded,Left SubErrSubscriptionIdentifiersNotSupported] [] +TEST(SubACK311QCTest, Decode7) { + uint8_t pkt[] = {0x90, 0x4, 0x76, 0xa6, 0x97, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 30374); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); +} + +// SubscribeResponse 8812 [Right QoS0,Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left +// SubErrTopicFilterInvalid,Right QoS0,Right QoS2,Right QoS0,Right QoS2] [] +TEST(SubACK311QCTest, Decode8) { + uint8_t pkt[] = {0x90, 0xb, 0x22, 0x6c, 0x0, 0x2, 0x91, 0x1, 0x8f, 0x0, 0x2, 0x0, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8812); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); +} + +// SubscribeResponse 31341 [Left SubErrImplementationSpecificError,Right QoS2,Left SubErrQuotaExceeded,Right QoS1,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS1] [] +TEST(SubACK311QCTest, Decode9) { + uint8_t pkt[] = {0x90, 0xa, 0x7a, 0x6d, 0x83, 0x2, 0x97, 0x1, 0x9e, 0x91, 0x0, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 31341); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); +} + +// SubscribeResponse 16134 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Left +// SubErrNotAuthorized,Right QoS1,Right QoS0,Left SubErrUnspecifiedError,Right QoS1] [] +TEST(SubACK311QCTest, Decode10) { + uint8_t pkt[] = {0x90, 0xa, 0x3f, 0x6, 0x1, 0xa1, 0x1, 0x87, 0x1, 0x0, 0x80, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 16134); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); +} + +// SubscribeResponse 27712 [Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Right QoS0] [] +TEST(SubACK311QCTest, Decode11) { + uint8_t pkt[] = {0x90, 0x5, 0x6c, 0x40, 0x83, 0x80, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 27712); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); +} + +// SubscribeResponse 23389 [Right QoS2,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right +// QoS2,Left SubErrTopicFilterInvalid] [] +TEST(SubACK311QCTest, Decode12) { + uint8_t pkt[] = {0x90, 0x8, 0x5b, 0x5d, 0x2, 0x1, 0xa2, 0x0, 0x2, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 23389); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x80); +} + +// SubscribeResponse 3364 [Right QoS0,Left SubErrUnspecifiedError] [] +TEST(SubACK311QCTest, Decode13) { + uint8_t pkt[] = {0x90, 0x4, 0xd, 0x24, 0x0, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 3364); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); +} + +// SubscribeResponse 8138 [Right QoS0,Right QoS1,Right QoS2] [] +TEST(SubACK311QCTest, Decode14) { + uint8_t pkt[] = {0x90, 0x5, 0x1f, 0xca, 0x0, 0x1, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8138); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); +} + +// SubscribeResponse 7647 [Left SubErrTopicFilterInvalid,Left SubErrNotAuthorized,Left SubErrTopicFilterInvalid,Left +// SubErrUnspecifiedError,Left SubErrQuotaExceeded,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrQuotaExceeded,Left SubErrNotAuthorized,Left SubErrQuotaExceeded] [] +TEST(SubACK311QCTest, Decode15) { + uint8_t pkt[] = {0x90, 0xb, 0x1d, 0xdf, 0x8f, 0x87, 0x8f, 0x80, 0x97, 0xa1, 0x97, 0x87, 0x97}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7647); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); +} + +// SubscribeResponse 4989 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [] +TEST(SubACK311QCTest, Decode16) { + uint8_t pkt[] = {0x90, 0x4, 0x13, 0x7d, 0x1, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4989); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); +} + +// SubscribeResponse 12633 [Right QoS2,Right QoS0,Right QoS0,Right QoS1] [] +TEST(SubACK311QCTest, Decode17) { + uint8_t pkt[] = {0x90, 0x6, 0x31, 0x59, 0x2, 0x0, 0x0, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 12633); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); +} + +// SubscribeResponse 1188 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported] [] +TEST(SubACK311QCTest, Decode18) { + uint8_t pkt[] = {0x90, 0x4, 0x4, 0xa4, 0x0, 0xa2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 1188); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); +} + +// SubscribeResponse 17587 [Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS0,Left +// SubErrNotAuthorized,Right QoS0] [] +TEST(SubACK311QCTest, Decode19) { + uint8_t pkt[] = {0x90, 0xc, 0x44, 0xb3, 0x0, 0x2, 0xa2, 0x8f, 0xa2, 0x2, 0x1, 0x0, 0x87, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 17587); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); +} + +// SubscribeResponse 7329 [Right QoS2,Left SubErrPacketIdentifierInUse] [] +TEST(SubACK311QCTest, Decode20) { + uint8_t pkt[] = {0x90, 0x4, 0x1c, 0xa1, 0x2, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7329); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); +} + +// SubscribeResponse 19479 [Right QoS1] [] +TEST(SubACK311QCTest, Decode21) { + uint8_t pkt[] = {0x90, 0x3, 0x4c, 0x17, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 19479); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); +} + +// SubscribeResponse 4187 [Right QoS2,Right QoS1,Left SubErrQuotaExceeded,Right QoS1,Right QoS0,Right QoS2,Left +// SubErrImplementationSpecificError] [] +TEST(SubACK311QCTest, Decode22) { + uint8_t pkt[] = {0x90, 0x9, 0x10, 0x5b, 0x2, 0x1, 0x97, 0x1, 0x0, 0x2, 0x83}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4187); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); +} + +// SubscribeResponse 1954 [Left SubErrNotAuthorized,Right QoS2,Left SubErrUnspecifiedError,Left +// SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrImplementationSpecificError,Right +// QoS2,Right QoS2] [] +TEST(SubACK311QCTest, Decode23) { + uint8_t pkt[] = {0x90, 0xa, 0x7, 0xa2, 0x87, 0x2, 0x80, 0x8f, 0xa2, 0x83, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 1954); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); +} + +// SubscribeResponse 9962 [Left SubErrPacketIdentifierInUse,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrNotAuthorized,Right QoS1,Left SubErrQuotaExceeded,Right QoS1] [] +TEST(SubACK311QCTest, Decode24) { + uint8_t pkt[] = {0x90, 0x8, 0x26, 0xea, 0x91, 0xa2, 0x87, 0x1, 0x97, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 9962); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); +} + +// SubscribeResponse 16427 [Left SubErrQuotaExceeded,Right QoS0,Right QoS2,Right QoS2,Right QoS1] [] +TEST(SubACK311QCTest, Decode25) { + uint8_t pkt[] = {0x90, 0x7, 0x40, 0x2b, 0x97, 0x0, 0x2, 0x2, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 16427); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); +} + +// SubscribeResponse 14848 [Left SubErrImplementationSpecificError,Left SubErrSubscriptionIdentifiersNotSupported] [] +TEST(SubACK311QCTest, Decode26) { + uint8_t pkt[] = {0x90, 0x4, 0x3a, 0x0, 0x83, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 14848); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); +} + +// SubscribeResponse 15477 [Left SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Right QoS2,Right QoS2,Right +// QoS1,Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Right QoS1,Left +// SubErrWildcardSubscriptionsNotSupported] [] +TEST(SubACK311QCTest, Decode27) { + uint8_t pkt[] = {0x90, 0xc, 0x3c, 0x75, 0x91, 0x87, 0x2, 0x2, 0x1, 0x9e, 0x80, 0x0, 0x1, 0xa2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 15477); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[9], 0x80); +} + +// SubscribeResponse 13181 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right +// QoS2,Left SubErrImplementationSpecificError,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrPacketIdentifierInUse,Right QoS1,Left SubErrUnspecifiedError] [] +TEST(SubACK311QCTest, Decode28) { + uint8_t pkt[] = {0x90, 0xb, 0x33, 0x7d, 0x87, 0x80, 0x87, 0x2, 0x83, 0xa1, 0x91, 0x1, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 13181); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], 0x80); +} + +// SubscribeResponse 32677 [Right QoS1,Left SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS2] [] +TEST(SubACK311QCTest, Decode29) { + uint8_t pkt[] = {0x90, 0x7, 0x7f, 0xa5, 0x1, 0x80, 0x2, 0x0, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 32677); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); +} + +// SubscribeResponse 14851 [Right QoS0,Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError,Left SubErrNotAuthorized,Left +// SubErrSharedSubscriptionsNotSupported] [] +TEST(SubACK311QCTest, Decode30) { + uint8_t pkt[] = {0x90, 0xa, 0x3a, 0x3, 0x0, 0x87, 0x80, 0x9e, 0x1, 0x83, 0x87, 0x9e}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 14851); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); +} + +// SubscribeResponse 4646 [Right QoS1,Left SubErrUnspecifiedError,Right QoS2,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Right +// QoS0,Left SubErrUnspecifiedError] [PropSubscriptionIdentifier 22,PropRequestResponseInformation +// 17,PropSubscriptionIdentifierAvailable 50,PropWildcardSubscriptionAvailable 51,PropRetainAvailable +// 233,PropReceiveMaximum 23309,PropResponseInformation +// "\251\r{G\166E\137\154\133JK\160\247\208\231t\177$]\193\240*\184\133\162\247R\165%\137",PropRequestResponseInformation +// 8,PropServerReference +// "\145\248\135d)\213B\n\135EJ\198\NAK\203\&6\153\214\173\141\138\236\NULy\DC1\215<\227sd",PropSubscriptionIdentifierAvailable +// 81,PropUserProperty "TK\156\b\130,\232\ENQ'\SYN\SUB6G\206\163\133\&4\EM\EM\213J " +// "\150\178Zd\187\233\237U\229\RS\DEL}/P\187\221\226\203~",PropUserProperty +// "v!l\151;4\STX=\222\238\SUB\f\136\178\175\134+5" "\154f\CANv\175+)",PropSessionExpiryInterval +// 29233,PropWildcardSubscriptionAvailable 6,PropMessageExpiryInterval 12194,PropResponseInformation +// "\215\254\&9\189\150\DC1\164HQ\216\v\185\167S)n%\200\188N~\SUBQ",PropSubscriptionIdentifier +// 27,PropWildcardSubscriptionAvailable 13,PropMessageExpiryInterval 7423,PropWillDelayInterval 28935,PropResponseTopic +// "",PropTopicAliasMaximum 2012,PropPayloadFormatIndicator 112,PropReceiveMaximum 15776,PropCorrelationData +// "B\202\134W\f=k\RS.\249\ACK\211\252~yv\234G\129_\218\129i",PropAuthenticationMethod +// "\136\224\SOH\US1E\244\f",PropRequestResponseInformation 168,PropMessageExpiryInterval +// 1846,PropMessageExpiryInterval 19979,PropAuthenticationData "J\177 +// D\182_w\USH\180\207\ETB\235\180\DC3)3\213x1c\186h\206\200m\227\221X",PropRequestProblemInformation 53,PropMaximumQoS +// 146,PropReceiveMaximum 25571,PropServerKeepAlive 3299,PropPayloadFormatIndicator 255,PropReasonString +// "q\245\154\&2",PropTopicAlias 15510] +TEST(SubACK5QCTest, Decode4) { + uint8_t pkt[] = {0x90, 0x8c, 0x1, 0x69, 0xbf, 0x80, 0x1, 0x12, 0x0, 0x9, 0x55, 0x85, 0xad, 0xd1, 0x3f, 0x7d, + 0x63, 0x90, 0xad, 0x26, 0x0, 0x6, 0x37, 0x6d, 0xb9, 0x49, 0x53, 0xc8, 0x0, 0x15, 0xff, 0xcc, + 0x42, 0x28, 0x2d, 0x8d, 0x33, 0x15, 0x3b, 0xd7, 0x81, 0x71, 0xb8, 0x93, 0xcc, 0x2c, 0xc4, 0xe5, + 0x30, 0xe7, 0x20, 0x1f, 0x0, 0xf, 0x65, 0x3, 0x9a, 0xa9, 0x7e, 0xc9, 0xe7, 0x91, 0x95, 0x13, + 0xcb, 0x7a, 0x2a, 0xab, 0x3e, 0x19, 0xa8, 0x2, 0x0, 0x0, 0x7, 0x36, 0x2, 0x0, 0x0, 0x4e, + 0xb, 0x16, 0x0, 0x1d, 0x4a, 0xb1, 0x20, 0x44, 0xb6, 0x5f, 0x77, 0x1f, 0x48, 0xb4, 0xcf, 0x17, + 0xeb, 0xb4, 0x13, 0x29, 0x33, 0xd5, 0x78, 0x31, 0x63, 0xba, 0x68, 0xce, 0xc8, 0x6d, 0xe3, 0xdd, + 0x58, 0x17, 0x35, 0x24, 0x92, 0x21, 0x63, 0xe3, 0x13, 0xc, 0xe3, 0x1, 0xff, 0x1f, 0x0, 0x4, + 0x71, 0xf5, 0x9a, 0x32, 0x23, 0x3c, 0x96, 0x0, 0x1, 0xa2, 0x0, 0x80, 0x2, 0xa2, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 27071); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0xA2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0xA2); + EXPECT_EQ(granted_qos_levels[7], 0xA1); +} + +// SubscribeResponse 29147 [Right QoS2,Right QoS2,Left SubErrImplementationSpecificError,Left +// SubErrUnspecifiedError,Right QoS2,Right QoS2] [PropSubscriptionIdentifier 29,PropWillDelayInterval +// 5901,PropReasonString "\NUL/\153\168\GS|$\190\232\210\158\132\ACK\179q",PropWildcardSubscriptionAvailable +// 76,PropRetainAvailable 119,PropSubscriptionIdentifier 16,PropUserProperty +// "CY]\r\239\238Q\222i\a\251\SO\202\147\216?\f\SUB\213p\232a\227]" +// "#\ETX\USL[\DEL*\167qJ\219\226r\DC2\198*\189!\255\169\&6\244",PropCorrelationData +// "\208}\132x\197hO\STX\SOH|l\208G\EM\178\FS",PropMessageExpiryInterval 14507,PropMaximumPacketSize +// 19945,PropSubscriptionIdentifierAvailable 170,PropRetainAvailable 214,PropRequestResponseInformation +// 42,PropResponseInformation "\r\ENQrX\226\143[\DEL"] +TEST(SubACK5QCTest, Decode5) { + uint8_t pkt[] = {0x90, 0x8a, 0x1, 0x71, 0xdb, 0x80, 0x1, 0xb, 0x1d, 0x18, 0x0, 0x0, 0x17, 0xd, 0x1f, 0x0, + 0xf, 0x0, 0x2f, 0x99, 0xa8, 0x1d, 0x7c, 0x24, 0xbe, 0xe8, 0xd2, 0x9e, 0x84, 0x6, 0xb3, 0x71, + 0x28, 0x4c, 0x25, 0x77, 0xb, 0x10, 0x26, 0x0, 0x18, 0x43, 0x59, 0x5d, 0xd, 0xef, 0xee, 0x51, + 0xde, 0x69, 0x7, 0xfb, 0xe, 0xca, 0x93, 0xd8, 0x3f, 0xc, 0x1a, 0xd5, 0x70, 0xe8, 0x61, 0xe3, + 0x5d, 0x0, 0x16, 0x23, 0x3, 0x1f, 0x4c, 0x5b, 0x7f, 0x2a, 0xa7, 0x71, 0x4a, 0xdb, 0xe2, 0x72, + 0x12, 0xc6, 0x2a, 0xbd, 0x21, 0xff, 0xa9, 0x36, 0xf4, 0x9, 0x0, 0x10, 0xd0, 0x7d, 0x84, 0x78, + 0xc5, 0x68, 0x4f, 0x2, 0x1, 0x7c, 0x6c, 0xd0, 0x47, 0x19, 0xb2, 0x1c, 0x2, 0x0, 0x0, 0x38, + 0xab, 0x27, 0x0, 0x0, 0x4d, 0xe9, 0x29, 0xaa, 0x25, 0xd6, 0x19, 0x2a, 0x1a, 0x0, 0x8, 0xd, + 0x5, 0x72, 0x58, 0xe2, 0x8f, 0x5b, 0x7f, 0x2, 0x2, 0x83, 0x80, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 29147); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x83); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); +} + +// SubscribeResponse 9531 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Left +// SubErrTopicFilterInvalid,Right QoS1,Left SubErrNotAuthorized,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS2] [PropSessionExpiryInterval 6243,PropTopicAliasMaximum +// 1854,PropPayloadFormatIndicator 70,PropContentType +// "\US\193\232\200!\f\171\222\146\"\200\184J\195{\189\RS\233\208\131%",PropWildcardSubscriptionAvailable +// 154,PropReasonString "\255\219\130u\251\218gb\224\138\&4%?L\200Tw:\217\&2\223",PropWillDelayInterval +// 16298,PropMessageExpiryInterval 18664,PropUserProperty +// "\173\176\RS\EM\245\182o\167\250m\215\164A\184\b\NUL\142\130\214Z" "b\\\147\131\155\231\EOT\239E",PropReceiveMaximum +// 22869,PropMaximumQoS 216,PropWildcardSubscriptionAvailable 93,PropResponseInformation +// "'\180\RSY8\150\DEL\SOH\186\CAN\155d\246\147\174c\149t",PropSubscriptionIdentifier 21,PropReceiveMaximum +// 6947,PropWillDelayInterval 6293,PropTopicAliasMaximum 13827,PropUserProperty "" +// "\133\219n\US\SYN\235\DC2\193\&9\v^\221\170l\RS\211",PropSharedSubscriptionAvailable +// 144,PropWildcardSubscriptionAvailable 8,PropUserProperty "1\DC3\200\161\220\139\t\EOTl;\143\200\240\172" +// "\SYN\255\214aA\244\141\251e#\168\\\178\168R\174"] +TEST(SubACK5QCTest, Decode6) { + uint8_t pkt[] = { + 0x90, 0xdb, 0x1, 0x25, 0x3b, 0xcd, 0x1, 0x11, 0x0, 0x0, 0x18, 0x63, 0x22, 0x7, 0x3e, 0x1, 0x46, 0x3, 0x0, + 0x15, 0x1f, 0xc1, 0xe8, 0xc8, 0x21, 0xc, 0xab, 0xde, 0x92, 0x22, 0xc8, 0xb8, 0x4a, 0xc3, 0x7b, 0xbd, 0x1e, 0xe9, + 0xd0, 0x83, 0x25, 0x28, 0x9a, 0x1f, 0x0, 0x15, 0xff, 0xdb, 0x82, 0x75, 0xfb, 0xda, 0x67, 0x62, 0xe0, 0x8a, 0x34, + 0x25, 0x3f, 0x4c, 0xc8, 0x54, 0x77, 0x3a, 0xd9, 0x32, 0xdf, 0x18, 0x0, 0x0, 0x3f, 0xaa, 0x2, 0x0, 0x0, 0x48, + 0xe8, 0x26, 0x0, 0x14, 0xad, 0xb0, 0x1e, 0x19, 0xf5, 0xb6, 0x6f, 0xa7, 0xfa, 0x6d, 0xd7, 0xa4, 0x41, 0xb8, 0x8, + 0x0, 0x8e, 0x82, 0xd6, 0x5a, 0x0, 0x9, 0x62, 0x5c, 0x93, 0x83, 0x9b, 0xe7, 0x4, 0xef, 0x45, 0x21, 0x59, 0x55, + 0x24, 0xd8, 0x28, 0x5d, 0x1a, 0x0, 0x12, 0x27, 0xb4, 0x1e, 0x59, 0x38, 0x96, 0x7f, 0x1, 0xba, 0x18, 0x9b, 0x64, + 0xf6, 0x93, 0xae, 0x63, 0x95, 0x74, 0xb, 0x15, 0x21, 0x1b, 0x23, 0x18, 0x0, 0x0, 0x18, 0x95, 0x22, 0x36, 0x3, + 0x26, 0x0, 0x0, 0x0, 0x10, 0x85, 0xdb, 0x6e, 0x1f, 0x16, 0xeb, 0x12, 0xc1, 0x39, 0xb, 0x5e, 0xdd, 0xaa, 0x6c, + 0x1e, 0xd3, 0x2a, 0x90, 0x28, 0x8, 0x26, 0x0, 0xe, 0x31, 0x13, 0xc8, 0xa1, 0xdc, 0x8b, 0x9, 0x4, 0x6c, 0x3b, + 0x8f, 0xc8, 0xf0, 0xac, 0x0, 0x10, 0x16, 0xff, 0xd6, 0x61, 0x41, 0xf4, 0x8d, 0xfb, 0x65, 0x23, 0xa8, 0x5c, 0xb2, + 0xa8, 0x52, 0xae, 0x1, 0xa1, 0x2, 0x8f, 0x1, 0x87, 0x0, 0x9e, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 9531); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0xA1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x8F); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x87); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x9E); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); +} + +// SubscribeResponse 30374 [Left SubErrQuotaExceeded,Left SubErrSubscriptionIdentifiersNotSupported] +// [PropMaximumPacketSize 8115,PropTopicAliasMaximum 8706,PropCorrelationData "\142\200\t\132\150 +// \227\a\180\227\185)\187W\163u",PropPayloadFormatIndicator 54,PropRequestProblemInformation 50] +TEST(SubACK5QCTest, Decode7) { + uint8_t pkt[] = {0x90, 0x24, 0x76, 0xa6, 0x1f, 0x27, 0x0, 0x0, 0x1f, 0xb3, 0x22, 0x22, 0x2, + 0x9, 0x0, 0x10, 0x8e, 0xc8, 0x9, 0x84, 0x96, 0x20, 0xe3, 0x7, 0xb4, 0xe3, + 0xb9, 0x29, 0xbb, 0x57, 0xa3, 0x75, 0x1, 0x36, 0x17, 0x32, 0x97, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 30374); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], 0x97); + EXPECT_EQ(granted_qos_levels[1], 0xA1); +} + +// SubscribeResponse 8812 [Right QoS0,Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left +// SubErrTopicFilterInvalid,Right QoS0,Right QoS2,Right QoS0,Right QoS2] [PropCorrelationData +// "\DC4\166GV",PropSubscriptionIdentifier 2,PropServerReference "\201\&5G\142\154l]\238\192",PropMaximumQoS +// 49,PropWillDelayInterval 926,PropReceiveMaximum 24762,PropServerKeepAlive 23026,PropSubscriptionIdentifierAvailable +// 15,PropResponseTopic "\v 9\178\134\ACK\191\198$^\198A\SId\154",PropAuthenticationMethod "4C",PropWillDelayInterval +// 13004] +TEST(SubACK5QCTest, Decode8) { + uint8_t pkt[] = {0x90, 0x4c, 0x22, 0x6c, 0x40, 0x9, 0x0, 0x4, 0x14, 0xa6, 0x47, 0x56, 0xb, 0x2, 0x1c, 0x0, + 0x9, 0xc9, 0x35, 0x47, 0x8e, 0x9a, 0x6c, 0x5d, 0xee, 0xc0, 0x24, 0x31, 0x18, 0x0, 0x0, 0x3, + 0x9e, 0x21, 0x60, 0xba, 0x13, 0x59, 0xf2, 0x29, 0xf, 0x8, 0x0, 0xf, 0xb, 0x20, 0x39, 0xb2, + 0x86, 0x6, 0xbf, 0xc6, 0x24, 0x5e, 0xc6, 0x41, 0xf, 0x64, 0x9a, 0x15, 0x0, 0x2, 0x34, 0x43, + 0x18, 0x0, 0x0, 0x32, 0xcc, 0x0, 0x2, 0x91, 0x1, 0x8f, 0x0, 0x2, 0x0, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8812); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x91); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x8F); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); +} + +// SubscribeResponse 31341 [Left SubErrImplementationSpecificError,Right QoS2,Left SubErrQuotaExceeded,Right QoS1,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS1] +// [PropRequestProblemInformation 94,PropContentType "\224\243",PropAuthenticationData "h\ACK",PropRetainAvailable +// 17,PropResponseInformation "\154\255\DEL\RS\164\v\185M5",PropPayloadFormatIndicator 184,PropAuthenticationData +// "\DEL\133\156\&1\170",PropResponseInformation +// "\133\DLE\209\141\243\EMH\166\185\STXA\177\128\STXT",PropWillDelayInterval 27214,PropSessionExpiryInterval +// 14089,PropAssignedClientIdentifier "l\213\178\159"] +TEST(SubACK5QCTest, Decode9) { + uint8_t pkt[] = {0x90, 0x52, 0x7a, 0x6d, 0x47, 0x17, 0x5e, 0x3, 0x0, 0x2, 0xe0, 0xf3, 0x16, 0x0, 0x2, 0x68, 0x6, + 0x25, 0x11, 0x1a, 0x0, 0x9, 0x9a, 0xff, 0x7f, 0x1e, 0xa4, 0xb, 0xb9, 0x4d, 0x35, 0x1, 0xb8, 0x16, + 0x0, 0x5, 0x7f, 0x85, 0x9c, 0x31, 0xaa, 0x1a, 0x0, 0xf, 0x85, 0x10, 0xd1, 0x8d, 0xf3, 0x19, 0x48, + 0xa6, 0xb9, 0x2, 0x41, 0xb1, 0x80, 0x2, 0x54, 0x18, 0x0, 0x0, 0x6a, 0x4e, 0x11, 0x0, 0x0, 0x37, + 0x9, 0x12, 0x0, 0x4, 0x6c, 0xd5, 0xb2, 0x9f, 0x83, 0x2, 0x97, 0x1, 0x9e, 0x91, 0x0, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 31341); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0x83); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x97); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x9E); + EXPECT_EQ(granted_qos_levels[5], 0x91); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); +} + +// SubscribeResponse 16134 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Left +// SubErrNotAuthorized,Right QoS1,Right QoS0,Left SubErrUnspecifiedError,Right QoS1] [PropResponseTopic +// "571\167\180\147\252\128\246X\152Z\242\v9\186",PropAuthenticationMethod "g\139\DC4",PropTopicAliasMaximum +// 5202,PropWildcardSubscriptionAvailable 185,PropTopicAlias 10282,PropSubscriptionIdentifier 9,PropServerKeepAlive +// 22027,PropResponseTopic "GG\SUB\139\226\a\160\t\167g\148\172\ETB\183\185\188n\241",PropCorrelationData +// "\220\249\232\235:'",PropResponseInformation +// "u>\210\204\214\137\161.\161\192F\197",PropSubscriptionIdentifierAvailable 153,PropAssignedClientIdentifier +// "O\203\171\198\175j\201\241\DLE\CAN\179tv2\147\148",PropMaximumPacketSize 21008,PropUserProperty +// "\t\US\171A\CANs\163\177T}fE\173iVvi\200Y" ":\152G\CANZ\252",PropReceiveMaximum +// 26151,PropSubscriptionIdentifierAvailable 4] +TEST(SubACK5QCTest, Decode10) { + uint8_t pkt[] = {0x90, 0x9c, 0x1, 0x3f, 0x6, 0x90, 0x1, 0x8, 0x0, 0x10, 0x35, 0x37, 0x31, 0xa7, 0xb4, 0x93, + 0xfc, 0x80, 0xf6, 0x58, 0x98, 0x5a, 0xf2, 0xb, 0x39, 0xba, 0x15, 0x0, 0x3, 0x67, 0x8b, 0x14, + 0x22, 0x14, 0x52, 0x28, 0xb9, 0x23, 0x28, 0x2a, 0xb, 0x9, 0x13, 0x56, 0xb, 0x8, 0x0, 0x12, + 0x47, 0x47, 0x1a, 0x8b, 0xe2, 0x7, 0xa0, 0x9, 0xa7, 0x67, 0x94, 0xac, 0x17, 0xb7, 0xb9, 0xbc, + 0x6e, 0xf1, 0x9, 0x0, 0x6, 0xdc, 0xf9, 0xe8, 0xeb, 0x3a, 0x27, 0x1a, 0x0, 0xc, 0x75, 0x3e, + 0xd2, 0xcc, 0xd6, 0x89, 0xa1, 0x2e, 0xa1, 0xc0, 0x46, 0xc5, 0x29, 0x99, 0x12, 0x0, 0x10, 0x4f, + 0xcb, 0xab, 0xc6, 0xaf, 0x6a, 0xc9, 0xf1, 0x10, 0x18, 0xb3, 0x74, 0x76, 0x32, 0x93, 0x94, 0x27, + 0x0, 0x0, 0x52, 0x10, 0x26, 0x0, 0x13, 0x9, 0x1f, 0xab, 0x41, 0x18, 0x73, 0xa3, 0xb1, 0x54, + 0x7d, 0x66, 0x45, 0xad, 0x69, 0x56, 0x76, 0x69, 0xc8, 0x59, 0x0, 0x6, 0x3a, 0x98, 0x47, 0x18, + 0x5a, 0xfc, 0x21, 0x66, 0x27, 0x29, 0x4, 0x1, 0xa1, 0x1, 0x87, 0x1, 0x0, 0x80, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 16134); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0xA1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x87); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); +} + +// SubscribeResponse 27712 [Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Right QoS0] +// [PropTopicAliasMaximum 15336,PropResponseInformation "%\219\212w7\218M\157\143\237r\aAO\213,",PropServerKeepAlive +// 29870,PropReceiveMaximum 339] +TEST(SubACK5QCTest, Decode11) { + uint8_t pkt[] = {0x90, 0x22, 0x6c, 0x40, 0x1c, 0x22, 0x3b, 0xe8, 0x1a, 0x0, 0x10, 0x25, + 0xdb, 0xd4, 0x77, 0x37, 0xda, 0x4d, 0x9d, 0x8f, 0xed, 0x72, 0x7, 0x41, + 0x4f, 0xd5, 0x2c, 0x13, 0x74, 0xae, 0x21, 0x1, 0x53, 0x83, 0x80, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 27712); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0x83); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); +} + +// SubscribeResponse 23389 [Right QoS2,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right +// QoS2,Left SubErrTopicFilterInvalid] [PropReasonString +// ">c'\236\255R\147\155\184\217\234z\234\222\128",PropRequestResponseInformation 230,PropMessageExpiryInterval +// 1522,PropSharedSubscriptionAvailable 116,PropResponseInformation "\241\150V$",PropCorrelationData +// "\218",PropSubscriptionIdentifier 14,PropReasonString +// "a\v\135P\205e\RS\182\241\204\135\211\138\"\164oE\DC3\150\220\131\148\176\216\a\132B\212C\165",PropSessionExpiryInterval +// 3925,PropSessionExpiryInterval 8684,PropMaximumPacketSize 29880,PropSubscriptionIdentifierAvailable +// 151,PropServerKeepAlive 11995] +TEST(SubACK5QCTest, Decode12) { + uint8_t pkt[] = {0x90, 0x66, 0x5b, 0x5d, 0x5d, 0x1f, 0x0, 0xf, 0x3e, 0x63, 0x27, 0xec, 0xff, 0x52, 0x93, + 0x9b, 0xb8, 0xd9, 0xea, 0x7a, 0xea, 0xde, 0x80, 0x19, 0xe6, 0x2, 0x0, 0x0, 0x5, 0xf2, + 0x2a, 0x74, 0x1a, 0x0, 0x4, 0xf1, 0x96, 0x56, 0x24, 0x9, 0x0, 0x1, 0xda, 0xb, 0xe, + 0x1f, 0x0, 0x1e, 0x61, 0xb, 0x87, 0x50, 0xcd, 0x65, 0x1e, 0xb6, 0xf1, 0xcc, 0x87, 0xd3, + 0x8a, 0x22, 0xa4, 0x6f, 0x45, 0x13, 0x96, 0xdc, 0x83, 0x94, 0xb0, 0xd8, 0x7, 0x84, 0x42, + 0xd4, 0x43, 0xa5, 0x11, 0x0, 0x0, 0xf, 0x55, 0x11, 0x0, 0x0, 0x21, 0xec, 0x27, 0x0, + 0x0, 0x74, 0xb8, 0x29, 0x97, 0x13, 0x2e, 0xdb, 0x2, 0x1, 0xa2, 0x0, 0x2, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 23389); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0xA2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x8F); +} + +// SubscribeResponse 3364 [Right QoS0,Left SubErrUnspecifiedError] [PropRequestResponseInformation +// 171,PropWildcardSubscriptionAvailable 54,PropRetainAvailable 169,PropAuthenticationData +// "\231S\SYN\130\168a~\202\192@y\150\251\201\FS&\SO[\224\170\193\142\173\177\235R",PropTopicAlias +// 13874,PropSharedSubscriptionAvailable 133,PropTopicAlias 1693,PropMessageExpiryInterval +// 17193,PropWildcardSubscriptionAvailable 83,PropTopicAlias 933,PropResponseTopic +// "E\243\170\t\180\191|X\150.N\185\182\254l\244\153",PropMaximumPacketSize 24169,PropServerReference +// "$\249*\140\197\133)+",PropPayloadFormatIndicator 194,PropSubscriptionIdentifierAvailable 124,PropWillDelayInterval +// 9096,PropResponseTopic +// "\132\143\135\168\f\251M\EOT\174\SORcp\RS\243\172\RS\209\199z\195\217\250\224Y\210\251",PropAuthenticationMethod +// "\208\181\202D\EM\FS\176\206g\183\191\166\249Rk\254\228\GSC\129\&6\149",PropReasonString +// "?\DC1\176\135\171\196\219X#p\207L-\143\140\131\207\153d|\211\206",PropTopicAliasMaximum +// 29896,PropSubscriptionIdentifier 26,PropServerReference +// "\SUB\161\250\&6\DC1^\SOH7)\DELI\222\138\201\ACK\240\189\199\&2",PropWildcardSubscriptionAvailable 147,PropTopicAlias +// 8676,PropMessageExpiryInterval 29724,PropSessionExpiryInterval 18665,PropUserProperty +// "\n\US\166jm\162\229\197U\233\131\229^$\b\155\200\214\187\196\156=6\241\139)\185T\ACK" +// "\181\SYN\201\250\166\207\172,\177\150\151\243\158\158oZ\222\DC3\247\147^\246x\184\197\130"] +TEST(SubACK5QCTest, Decode13) { + uint8_t pkt[] = { + 0x90, 0x9e, 0x2, 0xd, 0x24, 0x98, 0x2, 0x19, 0xab, 0x28, 0x36, 0x25, 0xa9, 0x16, 0x0, 0x1a, 0xe7, 0x53, 0x16, + 0x82, 0xa8, 0x61, 0x7e, 0xca, 0xc0, 0x40, 0x79, 0x96, 0xfb, 0xc9, 0x1c, 0x26, 0xe, 0x5b, 0xe0, 0xaa, 0xc1, 0x8e, + 0xad, 0xb1, 0xeb, 0x52, 0x23, 0x36, 0x32, 0x2a, 0x85, 0x23, 0x6, 0x9d, 0x2, 0x0, 0x0, 0x43, 0x29, 0x28, 0x53, + 0x23, 0x3, 0xa5, 0x8, 0x0, 0x11, 0x45, 0xf3, 0xaa, 0x9, 0xb4, 0xbf, 0x7c, 0x58, 0x96, 0x2e, 0x4e, 0xb9, 0xb6, + 0xfe, 0x6c, 0xf4, 0x99, 0x27, 0x0, 0x0, 0x5e, 0x69, 0x1c, 0x0, 0x8, 0x24, 0xf9, 0x2a, 0x8c, 0xc5, 0x85, 0x29, + 0x2b, 0x1, 0xc2, 0x29, 0x7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78, 0xb8, + 0xc5, 0x82, 0x0, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 3364); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); +} + +// SubscribeResponse 8138 [Right QoS0,Right QoS1,Right QoS2] [PropRequestResponseInformation 205,PropUserProperty +// "N'\157\207$\151\235" "\197s\159\159\v\210\190\177DM\230N\138|i?`4\DEL \224\250\192a'\246X",PropReasonString +// "\199\170\197\SYN",PropSubscriptionIdentifier 13,PropRequestResponseInformation 161,PropUserProperty +// "\FSGFUWV\232\184\180{\ACK\253\181]y\138\167\ETB\157\&1\184N\163" +// "\247\176\&3\255\213\226\a\152\190\DEL\248sz\172s\DC1\SYNy",PropAuthenticationMethod +// "pL\167\EOT\203\133\&1\197D\181;\186_",PropMessageExpiryInterval 31515,PropAuthenticationMethod +// "\216k\143\208GU\CAN\ETX[\SI}\215\131S\FSg\226\GSC",PropWildcardSubscriptionAvailable 7,PropResponseInformation +// ":\233\164H\214\162\178B\STX\180A\160'\SOH\"\181Y\189&\DC4",PropAuthenticationData +// "~\EOT\223\158\150\216{\196\CANqE\252\EM\156\212\238B\166\SOH-\166\149z?\175/\140O\197",PropReasonString +// "o\217\221H\134t\157\b\170\156Ep\169\253\147\176@\222ov#O\128J\DC1C\134",PropTopicAlias 512,PropMessageExpiryInterval +// 29859,PropRequestResponseInformation 21,PropReceiveMaximum 4053,PropUserProperty +// "\219\208\200\148\DC29\217\DC24o\224" "\DC2wP\190",PropSubscriptionIdentifierAvailable 226,PropReceiveMaximum +// 16548,PropAssignedClientIdentifier "7Yw3\141\231\183",PropTopicAlias 8751] +TEST(SubACK5QCTest, Decode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x7b, 0xc4, 0x18, 0x71, 0x45, + 0xfc, 0x19, 0x9c, 0xd4, 0xee, 0x42, 0xa6, 0x1, 0x2d, 0xa6, 0x95, 0x7a, 0x3f, 0xaf, 0x2f, 0x8c, 0x4f, + 0xc5, 0x1f, 0x0, 0x1b, 0x6f, 0xd9, 0xdd, 0x48, 0x86, 0x74, 0x9d, 0x8, 0xaa, 0x9c, 0x45, 0x70, 0xa9, + 0xfd, 0x93, 0xb0, 0x40, 0xde, 0x6f, 0x76, 0x23, 0x4f, 0x80, 0x4a, 0x11, 0x43, 0x86, 0x23, 0x2, 0x0, + 0x2, 0x0, 0x0, 0x74, 0xa3, 0x19, 0x15, 0x21, 0xf, 0xd5, 0x26, 0x0, 0xb, 0xdb, 0xd0, 0xc8, 0x94, + 0x12, 0x39, 0xd9, 0x12, 0x34, 0x6f, 0xe0, 0x0, 0x4, 0x12, 0x77, 0x50, 0xbe, 0x29, 0xe2, 0x21, 0x40, + 0xa4, 0x12, 0x0, 0x7, 0x37, 0x59, 0x77, 0x33, 0x8d, 0xe7, 0xb7, 0x23, 0x22, 0x2f, 0x0, 0x1, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8138); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); +} + +// SubscribeResponse 7647 [Left SubErrTopicFilterInvalid,Left SubErrNotAuthorized,Left SubErrTopicFilterInvalid,Left +// SubErrUnspecifiedError,Left SubErrQuotaExceeded,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrQuotaExceeded,Left SubErrNotAuthorized,Left SubErrQuotaExceeded] [PropWillDelayInterval 18079,PropMaximumQoS +// 251,PropWillDelayInterval 8818,PropRetainAvailable 64,PropMessageExpiryInterval 24146,PropAuthenticationData +// "\150\233Rm+\170H0\249\189\141\178\199\234:\184\158\234-\vu\218\201Cza",PropTopicAlias +// 11739,PropSessionExpiryInterval 25398,PropWildcardSubscriptionAvailable 141,PropMaximumPacketSize +// 6767,PropReasonString "?Q\n",PropSubscriptionIdentifierAvailable 218,PropPayloadFormatIndicator +// 10,PropSharedSubscriptionAvailable 239,PropAuthenticationMethod "\250I",PropMessageExpiryInterval +// 32723,PropSessionExpiryInterval 2619,PropMaximumPacketSize 15529,PropTopicAliasMaximum 27150,PropTopicAliasMaximum +// 17762,PropSubscriptionIdentifierAvailable 49] +TEST(SubACK5QCTest, Decode15) { + uint8_t pkt[] = {0x90, 0x73, 0x1d, 0xdf, 0x67, 0x18, 0x0, 0x0, 0x46, 0x9f, 0x24, 0xfb, 0x18, 0x0, 0x0, 0x22, 0x72, + 0x25, 0x40, 0x2, 0x0, 0x0, 0x5e, 0x52, 0x16, 0x0, 0x1a, 0x96, 0xe9, 0x52, 0x6d, 0x2b, 0xaa, 0x48, + 0x30, 0xf9, 0xbd, 0x8d, 0xb2, 0xc7, 0xea, 0x3a, 0xb8, 0x9e, 0xea, 0x2d, 0xb, 0x75, 0xda, 0xc9, 0x43, + 0x7a, 0x61, 0x23, 0x2d, 0xdb, 0x11, 0x0, 0x0, 0x63, 0x36, 0x28, 0x8d, 0x27, 0x0, 0x0, 0x1a, 0x6f, + 0x1f, 0x0, 0x3, 0x3f, 0x51, 0xa, 0x29, 0xda, 0x1, 0xa, 0x2a, 0xef, 0x15, 0x0, 0x2, 0xfa, 0x49, + 0x2, 0x0, 0x0, 0x7f, 0xd3, 0x11, 0x0, 0x0, 0xa, 0x3b, 0x27, 0x0, 0x0, 0x3c, 0xa9, 0x22, 0x6a, + 0xe, 0x22, 0x45, 0x62, 0x29, 0x31, 0x8f, 0x87, 0x8f, 0x80, 0x97, 0xa1, 0x97, 0x87, 0x97}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7647); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x8F); + EXPECT_EQ(granted_qos_levels[1], 0x87); + EXPECT_EQ(granted_qos_levels[2], 0x8F); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x97); + EXPECT_EQ(granted_qos_levels[5], 0xA1); + EXPECT_EQ(granted_qos_levels[6], 0x97); + EXPECT_EQ(granted_qos_levels[7], 0x87); + EXPECT_EQ(granted_qos_levels[8], 0x97); +} + +// SubscribeResponse 4989 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [PropWillDelayInterval 22475] +TEST(SubACK5QCTest, Decode16) { + uint8_t pkt[] = {0x90, 0xa, 0x13, 0x7d, 0x5, 0x18, 0x0, 0x0, 0x57, 0xcb, 0x1, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4989); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0xA1); +} + +// SubscribeResponse 12633 [Right QoS2,Right QoS0,Right QoS0,Right QoS1] [PropPayloadFormatIndicator 144,PropMaximumQoS +// 159,PropPayloadFormatIndicator 65] +TEST(SubACK5QCTest, Decode17) { + uint8_t pkt[] = {0x90, 0xd, 0x31, 0x59, 0x6, 0x1, 0x90, 0x24, 0x9f, 0x1, 0x41, 0x2, 0x0, 0x0, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 12633); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); +} + +// SubscribeResponse 1188 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported] [PropMaximumPacketSize +// 18249,PropWildcardSubscriptionAvailable 131,PropTopicAlias 26908,PropResponseTopic +// "\239\255!7\234\DC3\220kv\129\247k\209\226\ACK\222\148\160\227e\SUBo\225",PropSessionExpiryInterval +// 32084,PropAuthenticationMethod +// "\246`C\209\218\227\196Z0\153\143\v\254\212j\223\t\182\202\251\208\NULX",PropRequestResponseInformation +// 196,PropSubscriptionIdentifier 21,PropWildcardSubscriptionAvailable 32,PropReceiveMaximum +// 3585,PropRequestProblemInformation 163,PropCorrelationData +// "\245\159K\133\158G\207\132L\223\168w\172\162Gu{3\196",PropContentType +// "\182\DC3Rh\218\CAN\196\164W\220\EM",PropServerKeepAlive 28344,PropSessionExpiryInterval 9213,PropTopicAliasMaximum +// 29557,PropMaximumPacketSize 1064,PropMaximumPacketSize 6638] +TEST(SubACK5QCTest, Decode18) { + uint8_t pkt[] = {0x90, 0x8d, 0x1, 0x4, 0xa4, 0x87, 0x1, 0x27, 0x0, 0x0, 0x47, 0x49, 0x28, 0x83, 0x23, 0x69, + 0x1c, 0x8, 0x0, 0x17, 0xef, 0xff, 0x21, 0x37, 0xea, 0x13, 0xdc, 0x6b, 0x76, 0x81, 0xf7, 0x6b, + 0xd1, 0xe2, 0x6, 0xde, 0x94, 0xa0, 0xe3, 0x65, 0x1a, 0x6f, 0xe1, 0x11, 0x0, 0x0, 0x7d, 0x54, + 0x15, 0x0, 0x17, 0xf6, 0x60, 0x43, 0xd1, 0xda, 0xe3, 0xc4, 0x5a, 0x30, 0x99, 0x8f, 0xb, 0xfe, + 0xd4, 0x6a, 0xdf, 0x9, 0xb6, 0xca, 0xfb, 0xd0, 0x0, 0x58, 0x19, 0xc4, 0xb, 0x15, 0x28, 0x20, + 0x21, 0xe, 0x1, 0x17, 0xa3, 0x9, 0x0, 0x13, 0xf5, 0x9f, 0x4b, 0x85, 0x9e, 0x47, 0xcf, 0x84, + 0x4c, 0xdf, 0xa8, 0x77, 0xac, 0xa2, 0x47, 0x75, 0x7b, 0x33, 0xc4, 0x3, 0x0, 0xb, 0xb6, 0x13, + 0x52, 0x68, 0xda, 0x18, 0xc4, 0xa4, 0x57, 0xdc, 0x19, 0x13, 0x6e, 0xb8, 0x11, 0x0, 0x0, 0x23, + 0xfd, 0x22, 0x73, 0x75, 0x27, 0x0, 0x0, 0x4, 0x28, 0x27, 0x0, 0x0, 0x19, 0xee, 0x0, 0xa2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 1188); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0xA2); +} + +// SubscribeResponse 17587 [Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS0,Left +// SubErrNotAuthorized,Right QoS0] [PropResponseTopic +// "j\205\183\182\235\tQ\168\206F]R\149-{\243]\243@\147\242\ETX{K\247@",PropRequestResponseInformation +// 119,PropAssignedClientIdentifier "n=E\128*\174\154\DLE\DLE\143n\251s)c\203\219\211\193Lo\241q#=\195",PropReasonString +// "$\128\164\202wr3M+\133T\207|Y\142\194$UV\148",PropRequestProblemInformation 41,PropMessageExpiryInterval +// 5040,PropAuthenticationMethod +// "m\US\198\223qI\152\160>.\182\vP\150A\165\249\"&\171\ESCf\180LAC",PropSubscriptionIdentifierAvailable +// 139,PropResponseInformation "\176\t_\135\137\246|[\191\187\182i\US\150\EOT",PropMessageExpiryInterval +// 1423,PropRetainAvailable 245,PropWillDelayInterval 29895,PropUserProperty "\a\ETBQ\SO\134\139\NAKdX\206\145Z" +// "\178\165x\140\GS\203\ETX\DC1\161Z\128\162\237a\f\255N\174\196\NAK-\136\176\218",PropSubscriptionIdentifierAvailable +// 120,PropReasonString "C",PropSubscriptionIdentifierAvailable 10,PropResponseTopic +// "\f\201\DLE\238",PropSharedSubscriptionAvailable 70,PropResponseInformation +// "\151\249\232r\150\188\191F\208\237\177\142s\a\232L\169\203\206\193.w",PropResponseTopic +// "!u\a\209",PropAuthenticationData "\EM\138\137\158\NULG\181\205\US\132\221\145H\153\244\"",PropServerKeepAlive +// 12070,PropReasonString "\192\209\193\154*+\228\215d",PropAssignedClientIdentifier +// "+\214\233H\199$\"\198|_\182\135\137[4\131\209\139\161\214\n\193\DC1\130\199\DC3l",PropPayloadFormatIndicator +// 29,PropRequestProblemInformation 87,PropServerKeepAlive 22897,PropContentType "\181\&0 \243F"] +TEST(SubACK5QCTest, Decode19) { + uint8_t pkt[] = { + 0x90, 0xce, 0x2, 0x44, 0xb3, 0xc0, 0x2, 0x8, 0x0, 0x1a, 0x6a, 0xcd, 0xb7, 0xb6, 0xeb, 0x9, 0x51, 0xa8, 0xce, + 0x46, 0x5d, 0x52, 0x95, 0x2d, 0x7b, 0xf3, 0x5d, 0xf3, 0x40, 0x93, 0xf2, 0x3, 0x7b, 0x4b, 0xf7, 0x40, 0x19, 0x77, + 0x12, 0x0, 0x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 0xed, 0xb1, 0x8e, 0x73, 0x7, 0xe8, 0x4c, 0xa9, 0xcb, 0xce, 0xc1, 0x2e, 0x77, 0x8, 0x0, 0x4, 0x21, 0x75, 0x7, + 0xd1, 0x16, 0x0, 0x10, 0x19, 0x8a, 0x89, 0x9e, 0x0, 0x47, 0xb5, 0xcd, 0x1f, 0x84, 0xdd, 0x91, 0x48, 0x99, 0xf4, + 0x22, 0x13, 0x2f, 0x26, 0x1f, 0x0, 0x9, 0xc0, 0xd1, 0xc1, 0x9a, 0x2a, 0x2b, 0xe4, 0xd7, 0x64, 0x12, 0x0, 0x1b, + 0x2b, 0xd6, 0xe9, 0x48, 0xc7, 0x24, 0x22, 0xc6, 0x7c, 0x5f, 0xb6, 0x87, 0x89, 0x5b, 0x34, 0x83, 0xd1, 0x8b, 0xa1, + 0xd6, 0xa, 0xc1, 0x11, 0x82, 0xc7, 0x13, 0x6c, 0x1, 0x1d, 0x17, 0x57, 0x13, 0x59, 0x71, 0x3, 0x0, 0x5, 0xb5, + 0x30, 0x20, 0xf3, 0x46, 0x0, 0x2, 0xa2, 0x8f, 0xa2, 0x2, 0x1, 0x0, 0x87, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 17587); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0xA2); + EXPECT_EQ(granted_qos_levels[3], 0x8F); + EXPECT_EQ(granted_qos_levels[4], 0xA2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], 0x87); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); +} + +// SubscribeResponse 7329 [Right QoS2,Left SubErrPacketIdentifierInUse] [PropRequestProblemInformation +// 249,PropTopicAlias 26290,PropSharedSubscriptionAvailable 248,PropUserProperty +// "T\178\&3\176L\222h;\184s\134\180\157\b\226\SI\ETB\207M\186}Y?\141\162\208\DLE" +// "`{>|\\\202\249$\195\&5\EM\188B\191\131\227\241\215\173\&3\191p\147\175",PropReasonString +// "\DC1(\184P\199\184\196\ESC\153\209/",PropWillDelayInterval 7562,PropCorrelationData +// "_\FS/\185G\205\169^\217\246\NULi\FS\227\SOH\229gh\246\225",PropSharedSubscriptionAvailable 220,PropMaximumQoS +// 176,PropMessageExpiryInterval 18923,PropWillDelayInterval 18806,PropUserProperty +// "PN\139\221\197GeM\164\201\169q\144\186\184wZ\223\200\199\181\203?\246\v\192" "\215\174",PropAuthenticationMethod +// "\146\195\DC4\149\150\239\203\248!P\206N\"8\234?\163o!\STX\165\204t\196,d",PropResponseInformation +// "\185;\166_T\154-P\166\DEL",PropTopicAliasMaximum 25060,PropAuthenticationData "\\\184",PropPayloadFormatIndicator +// 248,PropSubscriptionIdentifierAvailable 126,PropMaximumQoS 10,PropTopicAliasMaximum 2628,PropResponseTopic +// "\220\n\156\SOj}oL",PropRequestProblemInformation 244,PropRequestProblemInformation 191,PropServerKeepAlive +// 5460,PropMessageExpiryInterval 16666] +TEST(SubACK5QCTest, Decode20) { + uint8_t pkt[] = { + 0x90, 0xf0, 0x1, 0x1c, 0xa1, 0xea, 0x1, 0x17, 0xf9, 0x23, 0x66, 0xb2, 0x2a, 0xf8, 0x26, 0x0, 0x1b, 0x54, 0xb2, + 0x33, 0xb0, 0x4c, 0xde, 0x68, 0x3b, 0xb8, 0x73, 0x86, 0xb4, 0x9d, 0x8, 0xe2, 0xf, 0x17, 0xcf, 0x4d, 0xba, 0x7d, + 0x59, 0x3f, 0x8d, 0x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0x7d, 0x6f, + 0x4c, 0x17, 0xf4, 0x17, 0xbf, 0x13, 0x15, 0x54, 0x2, 0x0, 0x0, 0x41, 0x1a, 0x2, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7329); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x91); +} + +// SubscribeResponse 19479 [Right QoS1] [PropMessageExpiryInterval 22457,PropRequestResponseInformation +// 8,PropWildcardSubscriptionAvailable 23,PropMessageExpiryInterval 24259,PropSharedSubscriptionAvailable +// 44,PropWildcardSubscriptionAvailable 9,PropSubscriptionIdentifier 21] +TEST(SubACK5QCTest, Decode21) { + uint8_t pkt[] = {0x90, 0x18, 0x4c, 0x17, 0x14, 0x2, 0x0, 0x0, 0x57, 0xb9, 0x19, 0x8, 0x28, + 0x17, 0x2, 0x0, 0x0, 0x5e, 0xc3, 0x2a, 0x2c, 0x28, 0x9, 0xb, 0x15, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 19479); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); +} + +// SubscribeResponse 4187 [Right QoS2,Right QoS1,Left SubErrQuotaExceeded,Right QoS1,Right QoS0,Right QoS2,Left +// SubErrImplementationSpecificError] [PropCorrelationData +// "\199\232\188I\216\178+\205\243\189\248w[\140\233E\165\&5:\167\173\&5J\153^\SOHA\199",PropReasonString +// "\224ZZ.8\152k\ETXE\137\187!+\NAK\147@",PropAuthenticationMethod +// "\221\130\RS'\143\237\134\198\SO\174\201m\150\220\168\134l\NAKL2y\253-\215\246",PropCorrelationData +// ".\142\FS\185\160$(\173\&5x\204-7\189\234uY\228\132\156F\210\251\145\129\136\144\249",PropSharedSubscriptionAvailable +// 209,PropMessageExpiryInterval 2510,PropSharedSubscriptionAvailable 231,PropAuthenticationMethod "\171\DLE +// WY\166>\ENQK\176n\246\177\252k\165\DC3h#-E\254\226",PropSubscriptionIdentifierAvailable 199,PropUserProperty +// "\157\248\154o\185" "*\ETBo\154",PropAssignedClientIdentifier "\210U\199\232\192Zy\RSX",PropResponseInformation +// "\182\&9\140\192VC\186 \168\RS\220",PropPayloadFormatIndicator 125,PropMessageExpiryInterval 26196,PropTopicAlias +// 2336,PropRetainAvailable 220,PropWildcardSubscriptionAvailable 12,PropServerReference +// "\EOT\a\250P\218\131\STX\EM\EOT\175\141\250\235]\ETX*)\249F\205\149\DEL@\229=T\205Z\183\219",PropSessionExpiryInterval +// 32172,PropSubscriptionIdentifier 14,PropAssignedClientIdentifier "\STX$C\145\STX\ETX",PropServerKeepAlive +// 21027,PropMessageExpiryInterval 24132,PropReceiveMaximum 30095,PropServerReference +// "s\173\191\208\&6\\\STX\206\DC1\131\241\165\DLE\t\230\r",PropTopicAlias 14796,PropRetainAvailable 120] +TEST(SubACK5QCTest, Decode22) { + uint8_t pkt[] = { + 0x90, 0xa7, 0x2, 0x10, 0x5b, 0x9c, 0x2, 0x9, 0x0, 0x1c, 0xc7, 0xe8, 0xbc, 0x49, 0xd8, 0xb2, 0x2b, 0xcd, 0xf3, + 0xbd, 0xf8, 0x77, 0x5b, 0x8c, 0xe9, 0x45, 0xa5, 0x35, 0x3a, 0xa7, 0xad, 0x35, 0x4a, 0x99, 0x5e, 0x1, 0x41, 0xc7, + 0x1f, 0x0, 0x10, 0xe0, 0x5a, 0x5a, 0x2e, 0x38, 0x98, 0x6b, 0x3, 0x45, 0x89, 0xbb, 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, 0xb7, 0xdb, 0x11, 0x0, 0x0, 0x7d, 0xac, 0xb, 0xe, + 0x12, 0x0, 0x6, 0x2, 0x24, 0x43, 0x91, 0x2, 0x3, 0x13, 0x52, 0x23, 0x2, 0x0, 0x0, 0x5e, 0x44, 0x21, 0x75, + 0x8f, 0x1c, 0x0, 0x10, 0x73, 0xad, 0xbf, 0xd0, 0x36, 0x5c, 0x2, 0xce, 0x11, 0x83, 0xf1, 0xa5, 0x10, 0x9, 0xe6, + 0xd, 0x23, 0x39, 0xcc, 0x25, 0x78, 0x2, 0x1, 0x97, 0x1, 0x0, 0x2, 0x83}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4187); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x97); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x83); +} + +// SubscribeResponse 1954 [Left SubErrNotAuthorized,Right QoS2,Left SubErrUnspecifiedError,Left +// SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrImplementationSpecificError,Right +// QoS2,Right QoS2] [PropWildcardSubscriptionAvailable 1,PropWildcardSubscriptionAvailable 77,PropServerKeepAlive +// 4976,PropSharedSubscriptionAvailable 54,PropReceiveMaximum 9243,PropRequestProblemInformation 35,PropServerKeepAlive +// 529] +TEST(SubACK5QCTest, Decode23) { + uint8_t pkt[] = {0x90, 0x1c, 0x7, 0xa2, 0x11, 0x28, 0x1, 0x28, 0x4d, 0x13, 0x13, 0x70, 0x2a, 0x36, 0x21, + 0x24, 0x1b, 0x17, 0x23, 0x13, 0x2, 0x11, 0x87, 0x2, 0x80, 0x8f, 0xa2, 0x83, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 1954); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0x87); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x8F); + EXPECT_EQ(granted_qos_levels[4], 0xA2); + EXPECT_EQ(granted_qos_levels[5], 0x83); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); +} + +// SubscribeResponse 9962 [Left SubErrPacketIdentifierInUse,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrNotAuthorized,Right QoS1,Left SubErrQuotaExceeded,Right QoS1] [PropMaximumQoS 33,PropPayloadFormatIndicator +// 170,PropMessageExpiryInterval 9660,PropServerKeepAlive 20380,PropPayloadFormatIndicator 9,PropWillDelayInterval +// 18773,PropRequestProblemInformation 73,PropResponseInformation +// "\191\166J\b\ETB\249\139\SOHx^\232\218\136q\166hn\SUB\SYN6\136\231\179l\147\SUB\242T\ESC",PropSessionExpiryInterval +// 24270] +TEST(SubACK5QCTest, Decode24) { + uint8_t pkt[] = {0x90, 0x43, 0x26, 0xea, 0x3a, 0x24, 0x21, 0x1, 0xaa, 0x2, 0x0, 0x0, 0x25, 0xbc, + 0x13, 0x4f, 0x9c, 0x1, 0x9, 0x18, 0x0, 0x0, 0x49, 0x55, 0x17, 0x49, 0x1a, 0x0, + 0x1d, 0xbf, 0xa6, 0x4a, 0x8, 0x17, 0xf9, 0x8b, 0x1, 0x78, 0x5e, 0xe8, 0xda, 0x88, + 0x71, 0xa6, 0x68, 0x6e, 0x1a, 0x16, 0x36, 0x88, 0xe7, 0xb3, 0x6c, 0x93, 0x1a, 0xf2, + 0x54, 0x1b, 0x11, 0x0, 0x0, 0x5e, 0xce, 0x91, 0xa2, 0x87, 0x1, 0x97, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 9962); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(granted_qos_levels[2], 0x87); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x97); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); +} + +// SubscribeResponse 16427 [Left SubErrQuotaExceeded,Right QoS0,Right QoS2,Right QoS2,Right QoS1] +// [PropRequestResponseInformation 104,PropServerReference "\171",PropSubscriptionIdentifier 24,PropAuthenticationData +// "1",PropAssignedClientIdentifier +// "\209\246\222`\DC2\132.\217E:l\133\145\221g\248\215\&1\208\172M\239\252\&3",PropSubscriptionIdentifier +// 7,PropMessageExpiryInterval 31633,PropMaximumPacketSize 12879,PropSessionExpiryInterval 4551,PropCorrelationData +// "\250Q@",PropWillDelayInterval 11026,PropReasonString "K\146\247[e\253c\221\184y]fG\128\218L\200\129",PropTopicAlias +// 9372,PropServerReference +// "\160\245\250y\147\180\182\RS\217M\134\a\245wQ\178Z\143E\208\248\212\181\139ye\130PC",PropMaximumQoS +// 220,PropAuthenticationMethod +// "\170\250#\131>\147QF\142\234\CAN\DC4\173j\ETXe\236\ACK\186\211\215;D\US]",PropUserProperty +// "\178\153Rs\169\169\141\DC1\130\&0\170xek\183\143\208C\NAK\v" +// "\243\DLE'j\140$\206e\226F\174\247\241Zs\148\144\221\166R\153$\209\133\248",PropTopicAlias +// 7597,PropAuthenticationData "\221\160\DC2\CAN\237W=S\167\EM^6ATm",PropAuthenticationData "'\193r;\208\DC1"] +TEST(SubACK5QCTest, Decode25) { + uint8_t pkt[] = { + 0x90, 0xf2, 0x1, 0x40, 0x2b, 0xe9, 0x1, 0x19, 0x68, 0x1c, 0x0, 0x1, 0xab, 0xb, 0x18, 0x16, 0x0, 0x1, 0x31, + 0x12, 0x0, 0x18, 0xd1, 0xf6, 0xde, 0x60, 0x12, 0x84, 0x2e, 0xd9, 0x45, 0x3a, 0x6c, 0x85, 0x91, 0xdd, 0x67, 0xf8, + 0xd7, 0x31, 0xd0, 0xac, 0x4d, 0xef, 0xfc, 0x33, 0xb, 0x7, 0x2, 0x0, 0x0, 0x7b, 0x91, 0x27, 0x0, 0x0, 0x32, + 0x4f, 0x11, 0x0, 0x0, 0x11, 0xc7, 0x9, 0x0, 0x3, 0xfa, 0x51, 0x40, 0x18, 0x0, 0x0, 0x2b, 0x12, 0x1f, 0x0, + 0x12, 0x4b, 0x92, 0xf7, 0x5b, 0x65, 0xfd, 0x63, 0xdd, 0xb8, 0x79, 0x5d, 0x66, 0x47, 0x80, 0xda, 0x4c, 0xc8, 0x81, + 0x23, 0x24, 0x9c, 0x1c, 0x0, 0x1d, 0xa0, 0xf5, 0xfa, 0x79, 0x93, 0xb4, 0xb6, 0x1e, 0xd9, 0x4d, 0x86, 0x7, 0xf5, + 0x77, 0x51, 0xb2, 0x5a, 0x8f, 0x45, 0xd0, 0xf8, 0xd4, 0xb5, 0x8b, 0x79, 0x65, 0x82, 0x50, 0x43, 0x24, 0xdc, 0x15, + 0x0, 0x19, 0xaa, 0xfa, 0x23, 0x83, 0x3e, 0x93, 0x51, 0x46, 0x8e, 0xea, 0x18, 0x14, 0xad, 0x6a, 0x3, 0x65, 0xec, + 0x6, 0xba, 0xd3, 0xd7, 0x3b, 0x44, 0x1f, 0x5d, 0x26, 0x0, 0x14, 0xb2, 0x99, 0x52, 0x73, 0xa9, 0xa9, 0x8d, 0x11, + 0x82, 0x30, 0xaa, 0x78, 0x65, 0x6b, 0xb7, 0x8f, 0xd0, 0x43, 0x15, 0xb, 0x0, 0x19, 0xf3, 0x10, 0x27, 0x6a, 0x8c, + 0x24, 0xce, 0x65, 0xe2, 0x46, 0xae, 0xf7, 0xf1, 0x5a, 0x73, 0x94, 0x90, 0xdd, 0xa6, 0x52, 0x99, 0x24, 0xd1, 0x85, + 0xf8, 0x23, 0x1d, 0xad, 0x16, 0x0, 0xf, 0xdd, 0xa0, 0x12, 0x18, 0xed, 0x57, 0x3d, 0x53, 0xa7, 0x19, 0x5e, 0x36, + 0x41, 0x54, 0x6d, 0x16, 0x0, 0x6, 0x27, 0xc1, 0x72, 0x3b, 0xd0, 0x11, 0x97, 0x0, 0x2, 0x2, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 16427); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x97); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); +} + +// SubscribeResponse 14848 [Left SubErrImplementationSpecificError,Left SubErrSubscriptionIdentifiersNotSupported] +// [PropAuthenticationMethod "\247\225\239\136\176\&4",PropReceiveMaximum 9177,PropTopicAlias +// 31213,PropMessageExpiryInterval 28807,PropAuthenticationData +// "yG\175\195\166\213\225rZ\180\166y\242\185;\174B\213\200\204<%\245`\188\t("] +TEST(SubACK5QCTest, Decode26) { + uint8_t pkt[] = {0x90, 0x37, 0x3a, 0x0, 0x32, 0x15, 0x0, 0x6, 0xf7, 0xe1, 0xef, 0x88, 0xb0, 0x34, 0x21, + 0x23, 0xd9, 0x23, 0x79, 0xed, 0x2, 0x0, 0x0, 0x70, 0x87, 0x16, 0x0, 0x1b, 0x79, 0x47, + 0xaf, 0xc3, 0xa6, 0xd5, 0xe1, 0x72, 0x5a, 0xb4, 0xa6, 0x79, 0xf2, 0xb9, 0x3b, 0xae, 0x42, + 0xd5, 0xc8, 0xcc, 0x3c, 0x25, 0xf5, 0x60, 0xbc, 0x9, 0x28, 0x83, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 14848); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], 0x83); + EXPECT_EQ(granted_qos_levels[1], 0xA1); +} + +// SubscribeResponse 15477 [Left SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Right QoS2,Right QoS2,Right +// QoS1,Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Right QoS1,Left +// SubErrWildcardSubscriptionsNotSupported] [PropCorrelationData "\rs\233\246",PropReceiveMaximum +// 20152,PropPayloadFormatIndicator 57,PropMessageExpiryInterval 1359,PropMessageExpiryInterval +// 416,PropAssignedClientIdentifier "9(<\DLEb\v\177",PropCorrelationData +// "\251V\195\DC3(\180\133\199\140l,\194\253>\209d,<\244\180\208\156b",PropMaximumPacketSize 16384,PropServerKeepAlive +// 4743,PropUserProperty "\201\ENQT\158=c+Sz\166;H" +// "\255\r\159D\255\217_\211Q\211\DC4)\241\&4\228\233\233\182\247\ETB\146",PropRetainAvailable 89,PropMaximumPacketSize +// 12246,PropAuthenticationData +// "\154M\163\186A\197\ETBA\168e\204\219M\227\205\&8@\169\t\148\143u\233\136\170",PropMessageExpiryInterval +// 9201,PropWillDelayInterval 21887,PropResponseInformation ".?`8",PropAssignedClientIdentifier +// "\203\nsi\226`\151\184,J\STXM\233\FS\254\GS",PropRetainAvailable 242,PropRequestResponseInformation +// 207,PropSessionExpiryInterval 22939,PropAuthenticationMethod "A!\163>\SO",PropMaximumPacketSize +// 4575,PropRetainAvailable 139,PropAssignedClientIdentifier +// "&\213\DC3\196\185\196\&1x\247\198\134\241\137a\211%\133;\147\222\&9_;uuoV\223'\148",PropRequestResponseInformation +// 61,PropRequestResponseInformation 212,PropRequestProblemInformation 58,PropUserProperty +// "\220:\237\190Kv\206\137\183\ETB\168R\189W\194\171q;\141U,\148\216kT\GS\203*" +// "\185\225L\GSq-\237\203H\224",PropUserProperty "\SITp>Q\163\157oR\USI\195\v\247i\RSYW\206d\255\251\224W\162" +// "\231hkmJp\\<0"] +TEST(SubACK5QCTest, Decode27) { + uint8_t pkt[] = { + 0x90, 0xce, 0x2, 0x3c, 0x75, 0xc0, 0x2, 0x9, 0x0, 0x4, 0xd, 0x73, 0xe9, 0xf6, 0x21, 0x4e, 0xb8, 0x1, 0x39, + 0x2, 0x0, 0x0, 0x5, 0x4f, 0x2, 0x0, 0x0, 0x1, 0xa0, 0x12, 0x0, 0x7, 0x39, 0x28, 0x3c, 0x10, 0x62, 0xb, + 0xb1, 0x9, 0x0, 0x17, 0xfb, 0x56, 0xc3, 0x13, 0x28, 0xb4, 0x85, 0xc7, 0x8c, 0x6c, 0x2c, 0xc2, 0xfd, 0x3e, 0xd1, + 0x64, 0x2c, 0x3c, 0xf4, 0xb4, 0xd0, 0x9c, 0x62, 0x27, 0x0, 0x0, 0x40, 0x0, 0x13, 0x12, 0x87, 0x26, 0x0, 0xc, + 0xc9, 0x5, 0x54, 0x9e, 0x3d, 0x63, 0x2b, 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, 0xd8, 0x6b, 0x54, 0x1d, 0xcb, 0x2a, 0x0, 0xa, 0xb9, 0xe1, 0x4c, 0x1d, 0x71, 0x2d, 0xed, + 0xcb, 0x48, 0xe0, 0x26, 0x0, 0x19, 0xf, 0x54, 0x70, 0x3e, 0x51, 0xa3, 0x9d, 0x6f, 0x52, 0x1f, 0x49, 0xc3, 0xb, + 0xf7, 0x69, 0x1e, 0x59, 0x57, 0xce, 0x64, 0xff, 0xfb, 0xe0, 0x57, 0xa2, 0x0, 0x9, 0xe7, 0x68, 0x6b, 0x6d, 0x4a, + 0x70, 0x5c, 0x3c, 0x30, 0x91, 0x87, 0x2, 0x2, 0x1, 0x9e, 0x80, 0x0, 0x1, 0xa2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 15477); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(granted_qos_levels[1], 0x87); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x9E); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[9], 0xA2); +} + +// SubscribeResponse 13181 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right +// QoS2,Left SubErrImplementationSpecificError,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrPacketIdentifierInUse,Right QoS1,Left SubErrUnspecifiedError] [] +TEST(SubACK5QCTest, Decode28) { + uint8_t pkt[] = {0x90, 0xc, 0x33, 0x7d, 0x0, 0x87, 0x80, 0x87, 0x2, 0x83, 0xa1, 0x91, 0x1, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 13181); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x87); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x87); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x83); + EXPECT_EQ(granted_qos_levels[5], 0xA1); + EXPECT_EQ(granted_qos_levels[6], 0x91); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], 0x80); +} + +// SubscribeResponse 32677 [Right QoS1,Left SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS2] +// [PropWillDelayInterval 12589,PropAuthenticationMethod "\129\137\142\235H +// \251|,K2\230\192+/^\176X\133\198\GSX\ENQ9",PropReasonString "eH\142\&3\189\203\235W\146",PropContentType +// "D\160|\f\237{G>\166\218\187\145\187\250\153\175\210\247\SI\v\ESC\167",PropServerReference "",PropWillDelayInterval +// 9311,PropUserProperty "\168=R\203\211\187%\205\&6!*zW\STX\191\157\147\&9=\183y" +// "A\138\133\178f\225U\213\&4w\241T^\175\226l\138\248\222Be^\US{m\184\242\"\n",PropSubscriptionIdentifierAvailable +// 212,PropRequestResponseInformation 189,PropMaximumPacketSize 13803,PropAuthenticationData +// "`!8e",PropMessageExpiryInterval 3947,PropSubscriptionIdentifier 26,PropMessageExpiryInterval 17424,PropMaximumQoS +// 58,PropSubscriptionIdentifierAvailable 188,PropCorrelationData +// "*\162\212\170\201\152\213\129",PropRequestResponseInformation 251,PropCorrelationData +// "\172i\SYNA\196\181\EM(|\246\129\ETB \DC2.\176\210\251\128\\\177n\SI\251\EM",PropWildcardSubscriptionAvailable 206] +TEST(SubACK5QCTest, Decode29) { + uint8_t pkt[] = {0x90, 0xd8, 0x1, 0x7f, 0xa5, 0xcf, 0x1, 0x18, 0x0, 0x0, 0x31, 0x2d, 0x15, 0x0, 0x18, 0x81, 0x89, + 0x8e, 0xeb, 0x48, 0x20, 0xfb, 0x7c, 0x2c, 0x4b, 0x32, 0xe6, 0xc0, 0x2b, 0x2f, 0x5e, 0xb0, 0x58, 0x85, + 0xc6, 0x1d, 0x58, 0x5, 0x39, 0x1f, 0x0, 0x9, 0x65, 0x48, 0x8e, 0x33, 0xbd, 0xcb, 0xeb, 0x57, 0x92, + 0x3, 0x0, 0x16, 0x44, 0xa0, 0x7c, 0xc, 0xed, 0x7b, 0x47, 0x3e, 0xa6, 0xda, 0xbb, 0x91, 0xbb, 0xfa, + 0x99, 0xaf, 0xd2, 0xf7, 0xf, 0xb, 0x1b, 0xa7, 0x1c, 0x0, 0x0, 0x18, 0x0, 0x0, 0x24, 0x5f, 0x26, + 0x0, 0x15, 0xa8, 0x3d, 0x52, 0xcb, 0xd3, 0xbb, 0x25, 0xcd, 0x36, 0x21, 0x2a, 0x7a, 0x57, 0x2, 0xbf, + 0x9d, 0x93, 0x39, 0x3d, 0xb7, 0x79, 0x0, 0x1d, 0x41, 0x8a, 0x85, 0xb2, 0x66, 0xe1, 0x55, 0xd5, 0x34, + 0x77, 0xf1, 0x54, 0x5e, 0xaf, 0xe2, 0x6c, 0x8a, 0xf8, 0xde, 0x42, 0x65, 0x5e, 0x1f, 0x7b, 0x6d, 0xb8, + 0xf2, 0x22, 0xa, 0x29, 0xd4, 0x19, 0xbd, 0x27, 0x0, 0x0, 0x35, 0xeb, 0x16, 0x0, 0x4, 0x60, 0x21, + 0x38, 0x65, 0x2, 0x0, 0x0, 0xf, 0x6b, 0xb, 0x1a, 0x2, 0x0, 0x0, 0x44, 0x10, 0x24, 0x3a, 0x29, + 0xbc, 0x9, 0x0, 0x8, 0x2a, 0xa2, 0xd4, 0xaa, 0xc9, 0x98, 0xd5, 0x81, 0x19, 0xfb, 0x9, 0x0, 0x19, + 0xac, 0x69, 0x16, 0x41, 0xc4, 0xb5, 0x19, 0x28, 0x7c, 0xf6, 0x81, 0x17, 0x20, 0x12, 0x2e, 0xb0, 0xd2, + 0xfb, 0x80, 0x5c, 0xb1, 0x6e, 0xf, 0xfb, 0x19, 0x28, 0xce, 0x1, 0x80, 0x2, 0x0, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 32677); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); +} + +// SubscribeResponse 14851 [Right QoS0,Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError,Left SubErrNotAuthorized,Left +// SubErrSharedSubscriptionsNotSupported] [PropAuthenticationData ""] +TEST(SubACK5QCTest, Decode30) { + uint8_t pkt[] = {0x90, 0xe, 0x3a, 0x3, 0x3, 0x16, 0x0, 0x0, 0x0, 0x87, 0x80, 0x9e, 0x1, 0x83, 0x87, 0x9e}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 14851); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x87); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x9E); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x83); + EXPECT_EQ(granted_qos_levels[6], 0x87); + EXPECT_EQ(granted_qos_levels[7], 0x9E); +} From 1b21fab4b62d0974355c031ca52fb2a9bd206713 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Fri, 20 Sep 2019 09:17:11 -0700 Subject: [PATCH 18/26] Introduce lwmqtt_serialized_properties_t for props output. --- examples/async.c | 3 +- examples/sync.c | 3 +- gentests/app/Main.hs | 3 +- include/lwmqtt.h | 8 +- src/client.c | 5 +- src/packet.c | 14 +- src/packet.h | 3 +- tests/client.cpp | 6 +- tests/generated.cpp | 24811 +++++++++++++++++++++-------------------- tests/packet.cpp | 9 +- 10 files changed, 12482 insertions(+), 12383 deletions(-) diff --git a/examples/async.c b/examples/async.c index d4dee25..fc87502 100644 --- a/examples/async.c +++ b/examples/async.c @@ -15,7 +15,8 @@ lwmqtt_client_t client; pthread_mutex_t mutex; -static void message_arrived(lwmqtt_client_t *_client, void *ref, lwmqtt_string_t topic, lwmqtt_message_t msg) { +static void message_arrived(lwmqtt_client_t *_client, void *ref, lwmqtt_string_t topic, lwmqtt_message_t msg, + lwmqtt_serialized_properties_t props) { printf("message_arrived: %.*s => %.*s (%d)\n", (int)topic.len, topic.data, (int)msg.payload_len, (char *)msg.payload, (int)msg.payload_len); } diff --git a/examples/sync.c b/examples/sync.c index 34008bd..f2d9d35 100644 --- a/examples/sync.c +++ b/examples/sync.c @@ -13,7 +13,8 @@ lwmqtt_unix_timer_t timer1, timer2, timer3; lwmqtt_client_t client; -static void message_arrived(lwmqtt_client_t *_client, void *ref, lwmqtt_string_t topic, lwmqtt_message_t msg) { +static void message_arrived(lwmqtt_client_t *_client, void *ref, lwmqtt_string_t topic, lwmqtt_message_t msg, + lwmqtt_serialized_properties_t props) { printf("message_arrived: %.*s => %.*s (%d)\n", (int)topic.len, topic.data, (int)msg.payload_len, (char *)msg.payload, (int)msg.payload_len); } diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 54e3ce2..f9f2431 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -181,7 +181,8 @@ genPublishTest prot i p@PublishRequest{..} = "uint16_t packet_id;\n", "lwmqtt_string_t topic;\n", "lwmqtt_message_t msg;\n", - "lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), ", protlvl prot, ", &dup, &packet_id, &topic, &msg);\n", + "lwmqtt_serialized_properties_t props;\n", + "lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), ", protlvl prot, ", &dup, &packet_id, &topic, &msg, &props);\n", "\n", "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", encodeString "exp_topic" _pubTopic, diff --git a/include/lwmqtt.h b/include/lwmqtt.h index 90c2401..e6b0d99 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -141,6 +141,11 @@ typedef struct { #define lwmqtt_empty_props \ { 0, NULL } +typedef struct { + size_t size; + uint8_t *start; +} lwmqtt_serialized_properties_t; + /** * The message object used to publish and receive messages. */ @@ -215,7 +220,8 @@ typedef int32_t (*lwmqtt_timer_get_t)(void *ref); * recommended to call any further lwmqtt methods in the callback as this might result in weird call stacks. The * callback should place the received messages in a queue and dispatch them after the caller has returned. */ -typedef void (*lwmqtt_callback_t)(lwmqtt_client_t *client, void *ref, lwmqtt_string_t str, lwmqtt_message_t msg); +typedef void (*lwmqtt_callback_t)(lwmqtt_client_t *client, void *ref, lwmqtt_string_t str, lwmqtt_message_t msg, + lwmqtt_serialized_properties_t props); /** * The client object. diff --git a/src/client.c b/src/client.c index 00b3d95..ddb5c59 100644 --- a/src/client.c +++ b/src/client.c @@ -266,15 +266,16 @@ static lwmqtt_err_t lwmqtt_cycle(lwmqtt_client_t *client, size_t *read, lwmqtt_p uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; err = lwmqtt_decode_publish(client->read_buf, client->read_buf_size, client->protocol, &dup, &packet_id, &topic, - &msg); + &msg, &props); if (err != LWMQTT_SUCCESS) { return err; } // call callback if set if (client->callback != NULL) { - client->callback(client, client->callback_ref, topic, msg); + client->callback(client, client->callback_ref, topic, msg, props); } // break early on qos zero diff --git a/src/packet.c b/src/packet.c index b89bb69..5883fbd 100644 --- a/src/packet.c +++ b/src/packet.c @@ -555,7 +555,7 @@ lwmqtt_err_t lwmqtt_encode_ack(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt } static lwmqtt_err_t decode_props(uint8_t **buf, const uint8_t *buf_len, lwmqtt_protocol_t protocol, - lwmqtt_properties_t *props) { + lwmqtt_serialized_properties_t *props) { if (protocol == LWMQTT_MQTT311) { return LWMQTT_SUCCESS; } @@ -564,13 +564,16 @@ static lwmqtt_err_t decode_props(uint8_t **buf, const uint8_t *buf_len, lwmqtt_p if (err != LWMQTT_SUCCESS) { return err; } - // TODO: Actually grab them instead of just skipping over + props->size = (size_t)prop_len; + props->start = *buf; + *buf += prop_len; return LWMQTT_SUCCESS; } lwmqtt_err_t lwmqtt_decode_publish(uint8_t *buf, size_t buf_len, lwmqtt_protocol_t protocol, bool *dup, - uint16_t *packet_id, lwmqtt_string_t *topic, lwmqtt_message_t *msg) { + uint16_t *packet_id, lwmqtt_string_t *topic, lwmqtt_message_t *msg, + lwmqtt_serialized_properties_t *props) { // prepare pointer uint8_t *buf_ptr = buf; uint8_t *buf_end = buf + buf_len; @@ -645,8 +648,7 @@ lwmqtt_err_t lwmqtt_decode_publish(uint8_t *buf, size_t buf_len, lwmqtt_protocol *packet_id = 0; } - lwmqtt_properties_t props; - err = decode_props(&buf_ptr, buf_end, protocol, &props); + err = decode_props(&buf_ptr, buf_end, protocol, props); if (err != LWMQTT_SUCCESS) { return err; } @@ -856,7 +858,7 @@ lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet return err; } - lwmqtt_properties_t props; + lwmqtt_serialized_properties_t props; err = decode_props(&buf_ptr, buf_end, protocol, &props); if (err != LWMQTT_SUCCESS) { return err; diff --git a/src/packet.h b/src/packet.h index a501c58..9cb8f85 100644 --- a/src/packet.h +++ b/src/packet.h @@ -124,7 +124,8 @@ lwmqtt_err_t lwmqtt_encode_ack(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt * @return An error value. */ lwmqtt_err_t lwmqtt_decode_publish(uint8_t *buf, size_t buf_len, lwmqtt_protocol_t protocol, bool *dup, - uint16_t *packet_id, lwmqtt_string_t *topic, lwmqtt_message_t *msg); + uint16_t *packet_id, lwmqtt_string_t *topic, lwmqtt_message_t *msg, + lwmqtt_serialized_properties_t *props); /** * Encodes a publish packet into the supplied buffer. diff --git a/tests/client.cpp b/tests/client.cpp index 7bac121..11f3edc 100644 --- a/tests/client.cpp +++ b/tests/client.cpp @@ -19,7 +19,8 @@ const char *custom_ref = "cool"; static lwmqtt_properties_t empty_props = lwmqtt_empty_props; -static void message_arrived(lwmqtt_client_t *c, void *ref, lwmqtt_string_t t, lwmqtt_message_t m) { +static void message_arrived(lwmqtt_client_t *c, void *ref, lwmqtt_string_t t, lwmqtt_message_t m, + lwmqtt_serialized_properties_t props) { ASSERT_EQ(ref, custom_ref); int res = lwmqtt_strcmp(t, "lwmqtt"); @@ -32,7 +33,8 @@ static void message_arrived(lwmqtt_client_t *c, void *ref, lwmqtt_string_t t, lw counter++; } -static void big_message_arrived(lwmqtt_client_t *c, void *ref, lwmqtt_string_t t, lwmqtt_message_t m) { +static void big_message_arrived(lwmqtt_client_t *c, void *ref, lwmqtt_string_t t, lwmqtt_message_t m, + lwmqtt_serialized_properties_t props) { ASSERT_EQ(ref, custom_ref); int res = lwmqtt_strcmp(t, "lwmqtt"); diff --git a/tests/generated.cpp b/tests/generated.cpp index 2d618d9..b29083e 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,22 +21,19 @@ extern "C" { } \ } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\162[\135Y\179\166\248\129\206{\238\216oc:{M\ESC \SI\180[fv\192\SO", _pubPktID = 0, _pubBody = -// "\129\ETB\238\SYN)\SI\254", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\240\228VZ\144!o", _pubPktID = +// 2440, _pubBody = "H\151\243\172\184\224\192", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x31, 0x23, 0x0, 0x1a, 0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, - 0x7b, 0xee, 0xd8, 0x6f, 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, - 0x66, 0x76, 0xc0, 0xe, 0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; - uint8_t topic_bytes[] = {0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, 0xee, 0xd8, 0x6f, - 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, 0xc0, 0xe}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x13, 0x0, 0x8, 0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, + 0x6f, 0x9, 0x88, 0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; + uint8_t topic_bytes[] = {0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 7; @@ -44,1519 +41,1554 @@ TEST(Publish311QCTest, Encode1) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2440, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\162[\135Y\179\166\248\129\206{\238\216oc:{M\ESC \SI\180[fv\192\SO", _pubPktID = 0, _pubBody = -// "\129\ETB\238\SYN)\SI\254", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\240\228VZ\144!o", _pubPktID = +// 2440, _pubBody = "H\151\243\172\184\224\192", _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x31, 0x23, 0x0, 0x1a, 0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, - 0x7b, 0xee, 0xd8, 0x6f, 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, - 0x66, 0x76, 0xc0, 0xe, 0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; + uint8_t pkt[] = {0x3a, 0x13, 0x0, 0x8, 0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, + 0x6f, 0x9, 0x88, 0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, 0xee, 0xd8, 0x6f, - 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, 0xc0, 0xe}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; + uint8_t exp_topic_bytes[] = {0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 2440); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); EXPECT_EQ(msg.payload_len, 7); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\"\225\135\&6h>|U\199", _pubPktID = -// 10161, _pubBody = "\240\177C\238jP+", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "}o\146\180\a\160\t\DC4T\196Oz)\145Z(2\146\157\n", _pubPktID = 8900, _pubBody = "GA\176\&8", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x3b, 0x14, 0x0, 0x9, 0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, - 0x55, 0xc7, 0x27, 0xb1, 0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; - uint8_t topic_bytes[] = {0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, 0x55, 0xc7}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x1c, 0x0, 0x14, 0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, 0x4f, + 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa, 0x22, 0xc4, 0x47, 0x41, 0xb0, 0x38}; + uint8_t topic_bytes[] = {0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, + 0x4f, 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; + uint8_t msg_bytes[] = {0x47, 0x41, 0xb0, 0x38}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 4; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10161, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 8900, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\"\225\135\&6h>|U\199", _pubPktID = -// 10161, _pubBody = "\240\177C\238jP+", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "}o\146\180\a\160\t\DC4T\196Oz)\145Z(2\146\157\n", _pubPktID = 8900, _pubBody = "GA\176\&8", _pubProps = []} TEST(Publish311QCTest, Decode2) { - uint8_t pkt[] = {0x3b, 0x14, 0x0, 0x9, 0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, - 0x55, 0xc7, 0x27, 0xb1, 0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; + uint8_t pkt[] = {0x3d, 0x1c, 0x0, 0x14, 0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, 0x4f, + 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa, 0x22, 0xc4, 0x47, 0x41, 0xb0, 0x38}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, 0x55, 0xc7}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, + 0x4f, 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x47, 0x41, 0xb0, 0x38}; + lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 10161); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(packet_id, 8900); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 4); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\\\247{A0\nX.\STX\243\151\STX\230}\221\144D<\209\NAKM\153\192\209=d\148\179\231", _pubPktID = 26319, _pubBody = -// "\166\229\136\206\180b\149", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\151\STXH3\208\EM\137z\b\129j\156\252", _pubPktID = 0, _pubBody = "\202\152NR\SI_", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x3c, 0x28, 0x0, 0x1d, 0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, - 0x97, 0x2, 0xe6, 0x7d, 0xdd, 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, - 0x3d, 0x64, 0x94, 0xb3, 0xe7, 0x66, 0xcf, 0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; - uint8_t topic_bytes[] = {0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, 0x7d, 0xdd, - 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x15, 0x0, 0xd, 0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, + 0x8, 0x81, 0x6a, 0x9c, 0xfc, 0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; + uint8_t topic_bytes[] = {0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; + uint8_t msg_bytes[] = {0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 6; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 26319, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\\\247{A0\nX.\STX\243\151\STX\230}\221\144D<\209\NAKM\153\192\209=d\148\179\231", _pubPktID = 26319, _pubBody = -// "\166\229\136\206\180b\149", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\151\STXH3\208\EM\137z\b\129j\156\252", _pubPktID = 0, _pubBody = "\202\152NR\SI_", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x3c, 0x28, 0x0, 0x1d, 0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, - 0x97, 0x2, 0xe6, 0x7d, 0xdd, 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, - 0x3d, 0x64, 0x94, 0xb3, 0xe7, 0x66, 0xcf, 0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; + uint8_t pkt[] = {0x38, 0x15, 0x0, 0xd, 0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, + 0x8, 0x81, 0x6a, 0x9c, 0xfc, 0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, 0x7d, 0xdd, - 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 26319); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ETXTx", _pubPktID = 0, _pubBody = -// "Ei\SI", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "<\v\SYN\154J\242", _pubPktID = +// 10596, _pubBody = "\187\150\168\193Z\202\188\STX?", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x39, 0x8, 0x0, 0x3, 0x3, 0x54, 0x78, 0x45, 0x69, 0xf}; - uint8_t topic_bytes[] = {0x3, 0x54, 0x78}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x13, 0x0, 0x6, 0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2, 0x29, + 0x64, 0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; + uint8_t topic_bytes[] = {0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x45, 0x69, 0xf}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 9; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10596, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ETXTx", _pubPktID = 0, _pubBody = -// "Ei\SI", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "<\v\SYN\154J\242", _pubPktID = +// 10596, _pubBody = "\187\150\168\193Z\202\188\STX?", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x39, 0x8, 0x0, 0x3, 0x3, 0x54, 0x78, 0x45, 0x69, 0xf}; + uint8_t pkt[] = {0x3c, 0x13, 0x0, 0x6, 0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2, 0x29, + 0x64, 0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3, 0x54, 0x78}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x45, 0x69, 0xf}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 10596); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 7815, _pubBody = -// "\168\142\FS", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\165,\215\220S\205E\205\200\222\229\249\ESC\148", _pubPktID = 15507, _pubBody = "pR:\130:", _pubProps = []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x34, 0x7, 0x0, 0x0, 0x1e, 0x87, 0xa8, 0x8e, 0x1c}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x17, 0x0, 0xe, 0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, + 0xde, 0xe5, 0xf9, 0x1b, 0x94, 0x3c, 0x93, 0x70, 0x52, 0x3a, 0x82, 0x3a}; + uint8_t topic_bytes[] = {0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, 0xf9, 0x1b, 0x94}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xa8, 0x8e, 0x1c}; + uint8_t msg_bytes[] = {0x70, 0x52, 0x3a, 0x82, 0x3a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 5; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7815, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 15507, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 7815, _pubBody = -// "\168\142\FS", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\165,\215\220S\205E\205\200\222\229\249\ESC\148", _pubPktID = 15507, _pubBody = "pR:\130:", _pubProps = []} TEST(Publish311QCTest, Decode5) { - uint8_t pkt[] = {0x34, 0x7, 0x0, 0x0, 0x1e, 0x87, 0xa8, 0x8e, 0x1c}; + uint8_t pkt[] = {0x3c, 0x17, 0x0, 0xe, 0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, + 0xde, 0xe5, 0xf9, 0x1b, 0x94, 0x3c, 0x93, 0x70, 0x52, 0x3a, 0x82, 0x3a}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa8, 0x8e, 0x1c}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, 0xf9, 0x1b, 0x94}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x70, 0x52, 0x3a, 0x82, 0x3a}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 7815); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(packet_id, 15507); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\174\208\231e\229\225\201\ENQS\217\DEL\146\214\ENQ\145", _pubPktID = 25416, _pubBody = -// "\151\234\215\234\133\219\164\174\221\&1\EOTCs\212\"\141`\135\243\236q}6", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\v\255\253\245\160v\SO\231\130e\134B1\174\n", _pubPktID = 29653, _pubBody = +// "\169\178\185\220\v\ACKV\254\137C8\154\ETB\\\213\142=", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x33, 0x2a, 0x0, 0xf, 0xae, 0xd0, 0xe7, 0x65, 0xe5, 0xe1, 0xc9, 0x5, 0x53, 0xd9, 0x7f, - 0x92, 0xd6, 0x5, 0x91, 0x63, 0x48, 0x97, 0xea, 0xd7, 0xea, 0x85, 0xdb, 0xa4, 0xae, 0xdd, - 0x31, 0x4, 0x43, 0x73, 0xd4, 0x22, 0x8d, 0x60, 0x87, 0xf3, 0xec, 0x71, 0x7d, 0x36}; - uint8_t topic_bytes[] = {0xae, 0xd0, 0xe7, 0x65, 0xe5, 0xe1, 0xc9, 0x5, 0x53, 0xd9, 0x7f, 0x92, 0xd6, 0x5, 0x91}; + uint8_t pkt[] = {0x35, 0x24, 0x0, 0xf, 0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, + 0x65, 0x86, 0x42, 0x31, 0xae, 0xa, 0x73, 0xd5, 0xa9, 0xb2, 0xb9, 0xdc, 0xb, + 0x6, 0x56, 0xfe, 0x89, 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; + uint8_t topic_bytes[] = {0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, 0x65, 0x86, 0x42, 0x31, 0xae, 0xa}; lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x97, 0xea, 0xd7, 0xea, 0x85, 0xdb, 0xa4, 0xae, 0xdd, 0x31, 0x4, 0x43, - 0x73, 0xd4, 0x22, 0x8d, 0x60, 0x87, 0xf3, 0xec, 0x71, 0x7d, 0x36}; + uint8_t msg_bytes[] = {0xa9, 0xb2, 0xb9, 0xdc, 0xb, 0x6, 0x56, 0xfe, 0x89, + 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25416, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29653, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\174\208\231e\229\225\201\ENQS\217\DEL\146\214\ENQ\145", _pubPktID = 25416, _pubBody = -// "\151\234\215\234\133\219\164\174\221\&1\EOTCs\212\"\141`\135\243\236q}6", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\v\255\253\245\160v\SO\231\130e\134B1\174\n", _pubPktID = 29653, _pubBody = +// "\169\178\185\220\v\ACKV\254\137C8\154\ETB\\\213\142=", _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x33, 0x2a, 0x0, 0xf, 0xae, 0xd0, 0xe7, 0x65, 0xe5, 0xe1, 0xc9, 0x5, 0x53, 0xd9, 0x7f, - 0x92, 0xd6, 0x5, 0x91, 0x63, 0x48, 0x97, 0xea, 0xd7, 0xea, 0x85, 0xdb, 0xa4, 0xae, 0xdd, - 0x31, 0x4, 0x43, 0x73, 0xd4, 0x22, 0x8d, 0x60, 0x87, 0xf3, 0xec, 0x71, 0x7d, 0x36}; + uint8_t pkt[] = {0x35, 0x24, 0x0, 0xf, 0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, + 0x65, 0x86, 0x42, 0x31, 0xae, 0xa, 0x73, 0xd5, 0xa9, 0xb2, 0xb9, 0xdc, 0xb, + 0x6, 0x56, 0xfe, 0x89, 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xae, 0xd0, 0xe7, 0x65, 0xe5, 0xe1, 0xc9, 0x5, 0x53, 0xd9, 0x7f, 0x92, 0xd6, 0x5, 0x91}; + uint8_t exp_topic_bytes[] = {0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, 0x65, 0x86, 0x42, 0x31, 0xae, 0xa}; lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x97, 0xea, 0xd7, 0xea, 0x85, 0xdb, 0xa4, 0xae, 0xdd, 0x31, 0x4, 0x43, - 0x73, 0xd4, 0x22, 0x8d, 0x60, 0x87, 0xf3, 0xec, 0x71, 0x7d, 0x36}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; + uint8_t exp_body_bytes[] = {0xa9, 0xb2, 0xb9, 0xdc, 0xb, 0x6, 0x56, 0xfe, 0x89, + 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 25416); + EXPECT_EQ(packet_id, 29653); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 23); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "=\178\242\158\145\238\151\166;*4)", -// _pubPktID = 0, _pubBody = "s\252\179R\CANz\233E\191\b\150\SYN\142G\217\188\190\148z\234#\250\177\240\254m\219\SOH", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\207)#\195\178f\ESC\134K\157xAj\210\148\138\207\185", _pubPktID = 17568, _pubBody = "\171Y", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x30, 0x2a, 0x0, 0xc, 0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, - 0x29, 0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, - 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; - uint8_t topic_bytes[] = {0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, 0x29}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x18, 0x0, 0x12, 0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, + 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9, 0x44, 0xa0, 0xab, 0x59}; + uint8_t topic_bytes[] = {0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, + 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, - 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xab, 0x59}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 2; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17568, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "=\178\242\158\145\238\151\166;*4)", -// _pubPktID = 0, _pubBody = "s\252\179R\CANz\233E\191\b\150\SYN\142G\217\188\190\148z\234#\250\177\240\254m\219\SOH", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\207)#\195\178f\ESC\134K\157xAj\210\148\138\207\185", _pubPktID = 17568, _pubBody = "\171Y", _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x30, 0x2a, 0x0, 0xc, 0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, - 0x29, 0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, - 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; + uint8_t pkt[] = {0x33, 0x18, 0x0, 0x12, 0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, + 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9, 0x44, 0xa0, 0xab, 0x59}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, 0x29}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, - 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, + 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xab, 0x59}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 17568); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\148\\\SUBg||N\DC41_\225\t\200Db_\163g\147\140\150]\254\216", _pubPktID = 0, _pubBody = "\130", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(9fA\NAK\140\194;\215\236\145\SO\240#\ESC", _pubPktID = 5686, _pubBody = +// "\197\149\245\GS\f\206T\209\&7\232c\143\164A\177\DC3\r<.\ACK", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x30, 0x1b, 0x0, 0x18, 0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, - 0x9, 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8, 0x82}; - uint8_t topic_bytes[] = {0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, - 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x27, 0x0, 0xf, 0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, + 0x91, 0xe, 0xf0, 0x23, 0x1b, 0x16, 0x36, 0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, + 0xd1, 0x37, 0xe8, 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; + uint8_t topic_bytes[] = {0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, 0x1b}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x82}; + uint8_t msg_bytes[] = {0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, 0xd1, 0x37, 0xe8, + 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 20; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 5686, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\148\\\SUBg||N\DC41_\225\t\200Db_\163g\147\140\150]\254\216", _pubPktID = 0, _pubBody = "\130", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(9fA\NAK\140\194;\215\236\145\SO\240#\ESC", _pubPktID = 5686, _pubBody = +// "\197\149\245\GS\f\206T\209\&7\232c\143\164A\177\DC3\r<.\ACK", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x30, 0x1b, 0x0, 0x18, 0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, - 0x9, 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8, 0x82}; + uint8_t pkt[] = {0x32, 0x27, 0x0, 0xf, 0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, + 0x91, 0xe, 0xf0, 0x23, 0x1b, 0x16, 0x36, 0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, + 0xd1, 0x37, 0xe8, 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, - 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8}; - lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x82}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, 0x1b}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, 0xd1, 0x37, 0xe8, + 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(packet_id, 5686); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\167a*\t\248\248\176\&7", _pubPktID -// = 3229, _pubBody = "q\NUL\185\ACK\181\209\244d\DC1\207\251\203\230\128\DC1A(\215\169\248\224\136EM\156.\EOT\f", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\234\227\201xQ\221\GS\f\US\208(\t\212", _pubPktID = 0, _pubBody = +// "\140\174]d\t\144\158\DC2\237\196\202\147\133\154\231\176|1", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x3c, 0x28, 0x0, 0x8, 0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37, 0xc, 0x9d, - 0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, - 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; - uint8_t topic_bytes[] = {0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x21, 0x0, 0xd, 0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, + 0x1f, 0xd0, 0x28, 0x9, 0xd4, 0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, + 0x12, 0xed, 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; + uint8_t topic_bytes[] = {0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, 0x1f, 0xd0, 0x28, 0x9, 0xd4}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, - 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; + uint8_t msg_bytes[] = {0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, + 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 18; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 3229, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\167a*\t\248\248\176\&7", _pubPktID -// = 3229, _pubBody = "q\NUL\185\ACK\181\209\244d\DC1\207\251\203\230\128\DC1A(\215\169\248\224\136EM\156.\EOT\f", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\234\227\201xQ\221\GS\f\US\208(\t\212", _pubPktID = 0, _pubBody = +// "\140\174]d\t\144\158\DC2\237\196\202\147\133\154\231\176|1", _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x3c, 0x28, 0x0, 0x8, 0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37, 0xc, 0x9d, - 0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, - 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; + uint8_t pkt[] = {0x38, 0x21, 0x0, 0xd, 0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, + 0x1f, 0xd0, 0x28, 0x9, 0xd4, 0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, + 0x12, 0xed, 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, - 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, 0x1f, 0xd0, 0x28, 0x9, 0xd4}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, + 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 3229); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[Q\172\216\185:|\162\194", _pubPktID -// = 10305, _pubBody = "\238\134", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\SYNr\142QB1\171\213)1\210q\199\"\203\225\251\233[&p\202\238", _pubPktID = 17787, _pubBody = +// "\172\FS\186\216A\244\EOT^<\NAK\136\187\235\ESC\245\209\128", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x3b, 0xf, 0x0, 0x9, 0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2, 0x28, 0x41, 0xee, 0x86}; - uint8_t topic_bytes[] = {0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x2c, 0x0, 0x17, 0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, + 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee, 0x45, 0x7b, 0xac, 0x1c, 0xba, + 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; + uint8_t topic_bytes[] = {0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, + 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xee, 0x86}; + msg.retained = false; + uint8_t msg_bytes[] = {0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, + 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10305, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17787, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[Q\172\216\185:|\162\194", _pubPktID -// = 10305, _pubBody = "\238\134", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\SYNr\142QB1\171\213)1\210q\199\"\203\225\251\233[&p\202\238", _pubPktID = 17787, _pubBody = +// "\172\FS\186\216A\244\EOT^<\NAK\136\187\235\ESC\245\209\128", _pubProps = []} TEST(Publish311QCTest, Decode10) { - uint8_t pkt[] = {0x3b, 0xf, 0x0, 0x9, 0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2, 0x28, 0x41, 0xee, 0x86}; + uint8_t pkt[] = {0x32, 0x2c, 0x0, 0x17, 0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, + 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee, 0x45, 0x7b, 0xac, 0x1c, 0xba, + 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xee, 0x86}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, + 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, + 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 10305); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 17787); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ESC\169\150\136?o\142\230\b", -// _pubPktID = 0, _pubBody = "\203\ENQ\254)\215\158R\255\SOH\SOHM8\245\234\222t\225\187\175", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "e", _pubPktID = 29287, _pubBody = +// "o\220=\DLE\237\181\219\FS\ESC%~\198\SYN/{P", _pubProps = []} TEST(Publish311QCTest, Encode11) { - uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x9, 0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8, 0xcb, 0x5, 0xfe, - 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; - uint8_t topic_bytes[] = {0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x15, 0x0, 0x1, 0x65, 0x72, 0x67, 0x6f, 0xdc, 0x3d, 0x10, 0xed, + 0xb5, 0xdb, 0x1c, 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; + uint8_t topic_bytes[] = {0x65}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xcb, 0x5, 0xfe, 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, - 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; + uint8_t msg_bytes[] = {0x6f, 0xdc, 0x3d, 0x10, 0xed, 0xb5, 0xdb, 0x1c, + 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 16; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29287, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ESC\169\150\136?o\142\230\b", -// _pubPktID = 0, _pubBody = "\203\ENQ\254)\215\158R\255\SOH\SOHM8\245\234\222t\225\187\175", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "e", _pubPktID = 29287, _pubBody = +// "o\220=\DLE\237\181\219\FS\ESC%~\198\SYN/{P", _pubProps = []} TEST(Publish311QCTest, Decode11) { - uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x9, 0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8, 0xcb, 0x5, 0xfe, - 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; + uint8_t pkt[] = {0x33, 0x15, 0x0, 0x1, 0x65, 0x72, 0x67, 0x6f, 0xdc, 0x3d, 0x10, 0xed, + 0xb5, 0xdb, 0x1c, 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcb, 0x5, 0xfe, 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, - 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x65}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x6f, 0xdc, 0x3d, 0x10, 0xed, 0xb5, 0xdb, 0x1c, + 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_EQ(packet_id, 29287); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\186\b\221\f\178D\188&~\248P\ENQ\134\167\n\241\196v\203\245_\206\177\208\SI\FS", _pubPktID = 16783, _pubBody = "", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\139\194\ETB\145\245\&3\175\131\230\149\231\192\SO", _pubPktID = 2558, _pubBody = +// "3u\151\168\SYN\191\144\230d\rn\148=", _pubProps = []} TEST(Publish311QCTest, Encode12) { - uint8_t pkt[] = {0x3a, 0x1e, 0x0, 0x1a, 0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, - 0x86, 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c, 0x41, 0x8f}; - uint8_t topic_bytes[] = {0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, 0x86, - 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x1e, 0x0, 0xd, 0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, + 0xe, 0x9, 0xfe, 0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; + uint8_t topic_bytes[] = {0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0}; + uint8_t msg_bytes[] = {0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 13; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16783, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 2558, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\186\b\221\f\178D\188&~\248P\ENQ\134\167\n\241\196v\203\245_\206\177\208\SI\FS", _pubPktID = 16783, _pubBody = "", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\139\194\ETB\145\245\&3\175\131\230\149\231\192\SO", _pubPktID = 2558, _pubBody = +// "3u\151\168\SYN\191\144\230d\rn\148=", _pubProps = []} TEST(Publish311QCTest, Decode12) { - uint8_t pkt[] = {0x3a, 0x1e, 0x0, 0x1a, 0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, - 0x86, 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c, 0x41, 0x8f}; + uint8_t pkt[] = {0x32, 0x1e, 0x0, 0xd, 0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, + 0xe, 0x9, 0xfe, 0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, 0x86, - 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 16783); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + EXPECT_EQ(packet_id, 2558); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// ";V\193\141}\175x\217i^\231g\247\v\203\183_\151\EM\\", _pubPktID = 0, _pubBody = -// "\162\166\173\187\NAK){\138\210Q^p+\SI\145Q\165\GS\166\249CG", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "$\212", _pubPktID = 1716, _pubBody +// = "\190\141B\DELW\166\237\195J\183\212y\176h", _pubProps = []} TEST(Publish311QCTest, Encode13) { - uint8_t pkt[] = {0x31, 0x2c, 0x0, 0x14, 0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, 0xe7, 0x67, - 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c, 0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, - 0xd2, 0x51, 0x5e, 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; - uint8_t topic_bytes[] = {0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, - 0xe7, 0x67, 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x14, 0x0, 0x2, 0x24, 0xd4, 0x6, 0xb4, 0xbe, 0x8d, 0x42, + 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; + uint8_t topic_bytes[] = {0x24, 0xd4}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, 0xd2, 0x51, 0x5e, - 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 14; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1716, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// ";V\193\141}\175x\217i^\231g\247\v\203\183_\151\EM\\", _pubPktID = 0, _pubBody = -// "\162\166\173\187\NAK){\138\210Q^p+\SI\145Q\165\GS\166\249CG", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "$\212", _pubPktID = 1716, _pubBody +// = "\190\141B\DELW\166\237\195J\183\212y\176h", _pubProps = []} TEST(Publish311QCTest, Decode13) { - uint8_t pkt[] = {0x31, 0x2c, 0x0, 0x14, 0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, 0xe7, 0x67, - 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c, 0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, - 0xd2, 0x51, 0x5e, 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; + uint8_t pkt[] = {0x34, 0x14, 0x0, 0x2, 0x24, 0xd4, 0x6, 0xb4, 0xbe, 0x8d, 0x42, + 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, - 0xe7, 0x67, 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, 0xd2, 0x51, 0x5e, - 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x24, 0xd4}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 1716); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\141\253\251\DC4\210]", _pubPktID = -// 0, _pubBody = "a#\200\US\234\221\168\235\213|\205w", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\180\150\252c\201h%\ACKX[", +// _pubPktID = 23232, _pubBody = "\245\158IP\ETX\CAN\DLE|\148\175\r", _pubProps = []} TEST(Publish311QCTest, Encode14) { - uint8_t pkt[] = {0x31, 0x14, 0x0, 0x6, 0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d, 0x61, - 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; - uint8_t topic_bytes[] = {0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x19, 0x0, 0xa, 0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b, + 0x5a, 0xc0, 0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; + uint8_t topic_bytes[] = {0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x61, 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 11; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 23232, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\141\253\251\DC4\210]", _pubPktID = -// 0, _pubBody = "a#\200\US\234\221\168\235\213|\205w", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\180\150\252c\201h%\ACKX[", +// _pubPktID = 23232, _pubBody = "\245\158IP\ETX\CAN\DLE|\148\175\r", _pubProps = []} TEST(Publish311QCTest, Decode14) { - uint8_t pkt[] = {0x31, 0x14, 0x0, 0x6, 0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d, 0x61, - 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; + uint8_t pkt[] = {0x3c, 0x19, 0x0, 0xa, 0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b, + 0x5a, 0xc0, 0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x61, 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + uint8_t exp_topic_bytes[] = {0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 23232); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\n", _pubPktID = 15576, _pubBody = -// "\SYN\168.K\212\233\154\159\233j\172\130\DC2\187\203\187\155\ETX", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\200a\188\164\254\SO\133s@", +// _pubPktID = 0, _pubBody = "i(topic.data), 1); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + uint8_t exp_topic_bytes[] = {0xc8, 0x61, 0xbc, 0xa4, 0xfe, 0xe, 0x85, 0x73, 0x40}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x69, 0x3c, 0x55, 0x4a, 0xd9, 0x4a, 0x28, 0x76, 0xa3, 0x5c, 0xd0, + 0x5a, 0xd1, 0x30, 0xec, 0x7e, 0x31, 0x64, 0xd3, 0x58, 0x12}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\195\214\220\150\206L\a\225", -// _pubPktID = 0, _pubBody = "\203\137\DC3y\ETBf\GS\255}~\231\217kJ\ESCI\193\148\254p\247\ACKB\245", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ">\248\138\204\&7]\233\FS\228\b|\187\148\202aA\US\153\STX\GS\135\211p", _pubPktID = 4359, _pubBody = +// "\242\145\166\143\135]\136Z\130\202\216\&2*\239?C\217\144\162", _pubProps = []} TEST(Publish311QCTest, Encode16) { - uint8_t pkt[] = {0x30, 0x22, 0x0, 0x8, 0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1, - 0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, - 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; - uint8_t topic_bytes[] = {0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x17, 0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, + 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70, 0x11, 0x7, 0xf2, 0x91, 0xa6, + 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; + uint8_t topic_bytes[] = {0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, + 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, - 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; + uint8_t msg_bytes[] = {0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, + 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 4359, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\195\214\220\150\206L\a\225", -// _pubPktID = 0, _pubBody = "\203\137\DC3y\ETBf\GS\255}~\231\217kJ\ESCI\193\148\254p\247\ACKB\245", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ">\248\138\204\&7]\233\FS\228\b|\187\148\202aA\US\153\STX\GS\135\211p", _pubPktID = 4359, _pubBody = +// "\242\145\166\143\135]\136Z\130\202\216\&2*\239?C\217\144\162", _pubProps = []} TEST(Publish311QCTest, Decode16) { - uint8_t pkt[] = {0x30, 0x22, 0x0, 0x8, 0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1, - 0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, - 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; + uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x17, 0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, + 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70, 0x11, 0x7, 0xf2, 0x91, 0xa6, + 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, - 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, + 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, + 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + EXPECT_EQ(packet_id, 4359); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\NUL=U\137\224\247\192", _pubPktID = -// 0, _pubBody = "\142\160\202\237f\186\202Fc1p\\\ACK\231J\193%\250kl", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\245*\174k\165!xK\226\163\190\195\171\228\STXdu\RS", _pubPktID = 10342, _pubBody = +// "\178\172\US)\254\SYN\146\229\NULP\NAK\n\186\220\f\"\SYN\230\190", _pubProps = []} TEST(Publish311QCTest, Encode17) { - uint8_t pkt[] = {0x39, 0x1d, 0x0, 0x7, 0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0, 0x8e, 0xa0, 0xca, 0xed, 0x66, - 0xba, 0xca, 0x46, 0x63, 0x31, 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, 0x25, 0xfa, 0x6b, 0x6c}; - uint8_t topic_bytes[] = {0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x29, 0x0, 0x12, 0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, 0xa3, 0xbe, + 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e, 0x28, 0x66, 0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, + 0x92, 0xe5, 0x0, 0x50, 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; + uint8_t topic_bytes[] = {0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, + 0xa3, 0xbe, 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x8e, 0xa0, 0xca, 0xed, 0x66, 0xba, 0xca, 0x46, 0x63, 0x31, - 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, 0x25, 0xfa, 0x6b, 0x6c}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, + 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10342, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\NUL=U\137\224\247\192", _pubPktID = -// 0, _pubBody = "\142\160\202\237f\186\202Fc1p\\\ACK\231J\193%\250kl", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\245*\174k\165!xK\226\163\190\195\171\228\STXdu\RS", _pubPktID = 10342, _pubBody = +// "\178\172\US)\254\SYN\146\229\NULP\NAK\n\186\220\f\"\SYN\230\190", _pubProps = []} TEST(Publish311QCTest, Decode17) { - uint8_t pkt[] = {0x39, 0x1d, 0x0, 0x7, 0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0, 0x8e, 0xa0, 0xca, 0xed, 0x66, - 0xba, 0xca, 0x46, 0x63, 0x31, 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, 0x25, 0xfa, 0x6b, 0x6c}; + uint8_t pkt[] = {0x32, 0x29, 0x0, 0x12, 0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, 0xa3, 0xbe, + 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e, 0x28, 0x66, 0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, + 0x92, 0xe5, 0x0, 0x50, 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8e, 0xa0, 0xca, 0xed, 0x66, 0xba, 0xca, 0x46, 0x63, 0x31, - 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, 0x25, 0xfa, 0x6b, 0x6c}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + uint8_t exp_topic_bytes[] = {0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, + 0xa3, 0xbe, 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, + 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 10342); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\192\226\177\DC3\178\200n\184h\162\210\RS\153\149\253\&1\132\250\156\\\190\ETB\149 \192\247C\203", _pubPktID = 0, -// _pubBody = "\243(topic.data), 28); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(packet_id, 18773); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "Q\144\172\176:\255\255\236\209\134\204", _pubPktID = 29463, _pubBody = -// "\135s\STX\155A\v\217\&8\EOT^,\220\194\183\195\251\223H9g\164", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\194", _pubPktID = 0, _pubBody = +// "\251\145\"\229\t+\230\175\144\209p\ETX^\217KR\195", _pubProps = []} TEST(Publish311QCTest, Encode19) { - uint8_t pkt[] = {0x3b, 0x24, 0x0, 0xb, 0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, - 0x86, 0xcc, 0x73, 0x17, 0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, - 0x5e, 0x2c, 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; - uint8_t topic_bytes[] = {0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x15, 0x0, 0x2, 0xdd, 0xc2, 0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, + 0xe6, 0xaf, 0x90, 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; + uint8_t topic_bytes[] = {0xdd, 0xc2}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, 0x5e, 0x2c, - 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; + uint8_t msg_bytes[] = {0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, + 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29463, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "Q\144\172\176:\255\255\236\209\134\204", _pubPktID = 29463, _pubBody = -// "\135s\STX\155A\v\217\&8\EOT^,\220\194\183\195\251\223H9g\164", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\194", _pubPktID = 0, _pubBody = +// "\251\145\"\229\t+\230\175\144\209p\ETX^\217KR\195", _pubProps = []} TEST(Publish311QCTest, Decode19) { - uint8_t pkt[] = {0x3b, 0x24, 0x0, 0xb, 0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, - 0x86, 0xcc, 0x73, 0x17, 0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, - 0x5e, 0x2c, 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; + uint8_t pkt[] = {0x31, 0x15, 0x0, 0x2, 0xdd, 0xc2, 0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, + 0xe6, 0xaf, 0x90, 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, 0x5e, 0x2c, - 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0xdd, 0xc2}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, + 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29463); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\220\&2\138\ETX\145\167\209n\146\EOT\ACK\187\213\216b\156\231@\149\194\129", _pubPktID = 25900, _pubBody = "+;\SYN", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\253\&0\CANabo\DC3\254\241\240\244{\194\r)2\133Gj\233%", _pubPktID = 23762, _pubBody = "\224", _pubProps = []} TEST(Publish311QCTest, Encode20) { - uint8_t pkt[] = {0x34, 0x1c, 0x0, 0x15, 0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, - 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81, 0x65, 0x2c, 0x2b, 0x3b, 0x16}; - uint8_t topic_bytes[] = {0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, - 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81}; + uint8_t pkt[] = {0x35, 0x1a, 0x0, 0x15, 0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, + 0xf4, 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25, 0x5c, 0xd2, 0xe0}; + uint8_t topic_bytes[] = {0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, 0xf4, + 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25}; lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x2b, 0x3b, 0x16}; + msg.retained = true; + uint8_t msg_bytes[] = {0xe0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 1; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25900, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 23762, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\220\&2\138\ETX\145\167\209n\146\EOT\ACK\187\213\216b\156\231@\149\194\129", _pubPktID = 25900, _pubBody = "+;\SYN", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\253\&0\CANabo\DC3\254\241\240\244{\194\r)2\133Gj\233%", _pubPktID = 23762, _pubBody = "\224", _pubProps = []} TEST(Publish311QCTest, Decode20) { - uint8_t pkt[] = {0x34, 0x1c, 0x0, 0x15, 0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, - 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81, 0x65, 0x2c, 0x2b, 0x3b, 0x16}; + uint8_t pkt[] = {0x35, 0x1a, 0x0, 0x15, 0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, + 0xf4, 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25, 0x5c, 0xd2, 0xe0}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, - 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81}; + uint8_t exp_topic_bytes[] = {0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, 0xf4, + 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25}; lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2b, 0x3b, 0x16}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + uint8_t exp_body_bytes[] = {0xe0}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 25900); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 23762); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\224", _pubPktID = 936, _pubBody = -// "6\245", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC1\DC4:", _pubPktID = 0, _pubBody = +// "V\144J\230\153\132\164\SO", _pubProps = []} TEST(Publish311QCTest, Encode21) { - uint8_t pkt[] = {0x3a, 0x7, 0x0, 0x1, 0xe0, 0x3, 0xa8, 0x36, 0xf5}; - uint8_t topic_bytes[] = {0xe0}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0xd, 0x0, 0x3, 0x11, 0x14, 0x3a, 0x56, 0x90, 0x4a, 0xe6, 0x99, 0x84, 0xa4, 0xe}; + uint8_t topic_bytes[] = {0x11, 0x14, 0x3a}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x36, 0xf5}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x56, 0x90, 0x4a, 0xe6, 0x99, 0x84, 0xa4, 0xe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 8; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 936, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\224", _pubPktID = 936, _pubBody = -// "6\245", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC1\DC4:", _pubPktID = 0, _pubBody = +// "V\144J\230\153\132\164\SO", _pubProps = []} TEST(Publish311QCTest, Decode21) { - uint8_t pkt[] = {0x3a, 0x7, 0x0, 0x1, 0xe0, 0x3, 0xa8, 0x36, 0xf5}; + uint8_t pkt[] = {0x39, 0xd, 0x0, 0x3, 0x11, 0x14, 0x3a, 0x56, 0x90, 0x4a, 0xe6, 0x99, 0x84, 0xa4, 0xe}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe0}; - lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x36, 0xf5}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x11, 0x14, 0x3a}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x56, 0x90, 0x4a, 0xe6, 0x99, 0x84, 0xa4, 0xe}; + lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 936); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 8); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "E\177\160\226\133O\252!\"\251\129\164{\STX\178\165g\229E\168\162\209>N\STXWn\191\235", _pubPktID = 0, _pubBody = -// "t\139\164\144a\157:\239\157\145M\SI\t\162\DC1\194D\143\134", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "6\USp^\205\245IA +// \ETB+\158\220\216ea[,\180\190\&1\DLE\183\198\217", _pubPktID = 25164, _pubBody = +// "\155\145\198\173f\139:a\195\141sE}\221\223\243\145\224*\180\vSEy{\166\178\148`", _pubProps = []} TEST(Publish311QCTest, Encode22) { - uint8_t pkt[] = {0x30, 0x32, 0x0, 0x1d, 0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, - 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, - 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb, 0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, - 0x3a, 0xef, 0x9d, 0x91, 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; - uint8_t topic_bytes[] = {0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, - 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x3a, 0x0, 0x19, 0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, + 0x9e, 0xdc, 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9, 0x62, + 0x4c, 0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, + 0xdf, 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; + uint8_t topic_bytes[] = {0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, 0x9e, 0xdc, + 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, 0x3a, 0xef, 0x9d, 0x91, - 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, 0xdf, + 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 29; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25164, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "E\177\160\226\133O\252!\"\251\129\164{\STX\178\165g\229E\168\162\209>N\STXWn\191\235", _pubPktID = 0, _pubBody = -// "t\139\164\144a\157:\239\157\145M\SI\t\162\DC1\194D\143\134", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "6\USp^\205\245IA +// \ETB+\158\220\216ea[,\180\190\&1\DLE\183\198\217", _pubPktID = 25164, _pubBody = +// "\155\145\198\173f\139:a\195\141sE}\221\223\243\145\224*\180\vSEy{\166\178\148`", _pubProps = []} TEST(Publish311QCTest, Decode22) { - uint8_t pkt[] = {0x30, 0x32, 0x0, 0x1d, 0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, - 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, - 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb, 0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, - 0x3a, 0xef, 0x9d, 0x91, 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; + uint8_t pkt[] = {0x33, 0x3a, 0x0, 0x19, 0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, + 0x9e, 0xdc, 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9, 0x62, + 0x4c, 0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, + 0xdf, 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, - 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, 0x3a, 0xef, 0x9d, 0x91, - 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, 0x9e, 0xdc, + 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, 0xdf, + 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 25164); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\208\167\232\STX\DLE\GSQr\146|", -// _pubPktID = 8189, _pubBody = "c`\ESC\156x\229(\255\178\168\214\240a\217\197\224\170\174\&48pk\NAK\200\ETX\130\235", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\178\&7A\251\143\146\159\171\130\211\146\190g", _pubPktID = 0, _pubBody = "", _pubProps = []} TEST(Publish311QCTest, Encode23) { - uint8_t pkt[] = {0x3a, 0x29, 0x0, 0xa, 0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c, 0x1f, - 0xfd, 0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, - 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; - uint8_t topic_bytes[] = {0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0xf, 0x0, 0xd, 0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; + uint8_t topic_bytes[] = {0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, - 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 0; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 8189, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\208\167\232\STX\DLE\GSQr\146|", -// _pubPktID = 8189, _pubBody = "c`\ESC\156x\229(\255\178\168\214\240a\217\197\224\170\174\&48pk\NAK\200\ETX\130\235", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\178\&7A\251\143\146\159\171\130\211\146\190g", _pubPktID = 0, _pubBody = "", _pubProps = []} TEST(Publish311QCTest, Decode23) { - uint8_t pkt[] = {0x3a, 0x29, 0x0, 0xa, 0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c, 0x1f, - 0xfd, 0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, - 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; + uint8_t pkt[] = {0x39, 0xf, 0x0, 0xd, 0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, - 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 8189); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 27); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "b\245\197\244\&04\214\&6*\178", -// _pubPktID = 0, _pubBody = "\184", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\198\161\148\238\191@\246\217\217\241\DC1\227\239", _pubPktID = 10944, _pubBody = "R3\160", _pubProps = []} TEST(Publish311QCTest, Encode24) { - uint8_t pkt[] = {0x38, 0xd, 0x0, 0xa, 0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2, 0xb8}; - uint8_t topic_bytes[] = {0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x14, 0x0, 0xd, 0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, + 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef, 0x2a, 0xc0, 0x52, 0x33, 0xa0}; + uint8_t topic_bytes[] = {0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xb8}; + uint8_t msg_bytes[] = {0x52, 0x33, 0xa0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 3; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10944, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "b\245\197\244\&04\214\&6*\178", -// _pubPktID = 0, _pubBody = "\184", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\198\161\148\238\191@\246\217\217\241\DC1\227\239", _pubPktID = 10944, _pubBody = "R3\160", _pubProps = []} TEST(Publish311QCTest, Decode24) { - uint8_t pkt[] = {0x38, 0xd, 0x0, 0xa, 0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2, 0xb8}; + uint8_t pkt[] = {0x3c, 0x14, 0x0, 0xd, 0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, + 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef, 0x2a, 0xc0, 0x52, 0x33, 0xa0}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb8}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x52, 0x33, 0xa0}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(packet_id, 10944); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\200\170v\196", _pubPktID = 30063, -// _pubBody = "\RS(g\190(g%\FS\249\135\DC1S\250\ACK(N\CANHC\157\RSK\175\DEL\225\159", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "V\195\159\242\185\ENQ\214\147\DLE\144\144,r\245\SO\237n\143\204\SUB\229\230", _pubPktID = 0, _pubBody = +// "\171\131\154", _pubProps = []} TEST(Publish311QCTest, Encode25) { - uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x4, 0xc8, 0xaa, 0x76, 0xc4, 0x75, 0x6f, 0x1e, 0x28, - 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, 0x6, - 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; - uint8_t topic_bytes[] = {0xc8, 0xaa, 0x76, 0xc4}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x1b, 0x0, 0x16, 0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, + 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6, 0xab, 0x83, 0x9a}; + uint8_t topic_bytes[] = {0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, + 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, - 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xab, 0x83, 0x9a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 3; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30063, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\200\170v\196", _pubPktID = 30063, -// _pubBody = "\RS(g\190(g%\FS\249\135\DC1S\250\ACK(N\CANHC\157\RSK\175\DEL\225\159", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "V\195\159\242\185\ENQ\214\147\DLE\144\144,r\245\SO\237n\143\204\SUB\229\230", _pubPktID = 0, _pubBody = +// "\171\131\154", _pubProps = []} TEST(Publish311QCTest, Decode25) { - uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x4, 0xc8, 0xaa, 0x76, 0xc4, 0x75, 0x6f, 0x1e, 0x28, - 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, 0x6, - 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; + uint8_t pkt[] = {0x39, 0x1b, 0x0, 0x16, 0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, + 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6, 0xab, 0x83, 0x9a}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc8, 0xaa, 0x76, 0xc4}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, - 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, + 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xab, 0x83, 0x9a}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 30063); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\229<<\234;", _pubPktID = 0, -// _pubBody = "+ eK\208\CAN\232\179\167\129\227'Hqi\SO\163\r\168\188\157\247", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ",\129\b\199\224\197\191\196~\130\211\129B\164\238\NAK\138I\201f\163", _pubPktID = 2253, _pubBody = +// "|\153\171Y,OB.\132d\186cm;\DC4+\153\209y\t\128", _pubProps = []} TEST(Publish311QCTest, Encode26) { - uint8_t pkt[] = {0x31, 0x1d, 0x0, 0x5, 0xe5, 0x3c, 0x3c, 0xea, 0x3b, 0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, - 0xb3, 0xa7, 0x81, 0xe3, 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; - uint8_t topic_bytes[] = {0xe5, 0x3c, 0x3c, 0xea, 0x3b}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x15, 0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, 0x81, + 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3, 0x8, 0xcd, 0x7c, 0x99, 0xab, 0x59, 0x2c, + 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; + uint8_t topic_bytes[] = {0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, + 0x81, 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, - 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, + 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 2253, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\229<<\234;", _pubPktID = 0, -// _pubBody = "+ eK\208\CAN\232\179\167\129\227'Hqi\SO\163\r\168\188\157\247", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ",\129\b\199\224\197\191\196~\130\211\129B\164\238\NAK\138I\201f\163", _pubPktID = 2253, _pubBody = +// "|\153\171Y,OB.\132d\186cm;\DC4+\153\209y\t\128", _pubProps = []} TEST(Publish311QCTest, Decode26) { - uint8_t pkt[] = {0x31, 0x1d, 0x0, 0x5, 0xe5, 0x3c, 0x3c, 0xea, 0x3b, 0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, - 0xb3, 0xa7, 0x81, 0xe3, 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; + uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x15, 0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, 0x81, + 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3, 0x8, 0xcd, 0x7c, 0x99, 0xab, 0x59, 0x2c, + 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe5, 0x3c, 0x3c, 0xea, 0x3b}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, - 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, + 0x81, 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, + 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 2253); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\ETX[\136\204X%(topic.data), 22); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + uint8_t exp_topic_bytes[] = {0xff, 0x8a, 0xa0, 0xe, 0x7d, 0x91, 0xe7, 0x3d, 0x9a, 0xf1, 0x69, + 0x52, 0xdb, 0x1c, 0x97, 0xf0, 0x7d, 0x42, 0x8d, 0x28, 0xd6}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf9, 0x90, 0x37, 0x20, 0x2c, 0x12, 0xd8, 0x92, 0x72, + 0x9b, 0xa1, 0xe0, 0x6c, 0xee, 0xa5, 0x1c, 0xf5}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 10836); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201eh\234\223\242\222", _pubPktID = -// 0, _pubBody = " .@o\137\224\135\201\224\168\\&%,\220\&6\DC2\SI\209\132J\DC2]\FS\210\132\134\189\b~", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\203\137\174H\204\220\160\&8\f+bXR\239\199\DC1\186\254\249\218\179y\210~\185\250\166\248", _pubPktID = 0, _pubBody = +// "\136\142{\DC4\\\154]/:\184\246N\DC28\204\&2C\f@\172\199\237\162)]W\186\180", _pubProps = []} TEST(Publish311QCTest, Encode28) { - uint8_t pkt[] = {0x38, 0x27, 0x0, 0x7, 0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde, 0x20, 0x2e, 0x40, - 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, 0x36, 0x12, - 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; - uint8_t topic_bytes[] = {0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x3a, 0x0, 0x1c, 0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, + 0x58, 0x52, 0xef, 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, + 0xa6, 0xf8, 0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, + 0x38, 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; + uint8_t topic_bytes[] = {0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, 0xef, + 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, - 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; + uint8_t msg_bytes[] = {0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, + 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 28; lwmqtt_property_t propslist[] = {}; @@ -1568,3311 +1600,3278 @@ TEST(Publish311QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201eh\234\223\242\222", _pubPktID = -// 0, _pubBody = " .@o\137\224\135\201\224\168\\&%,\220\&6\DC2\SI\209\132J\DC2]\FS\210\132\134\189\b~", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\203\137\174H\204\220\160\&8\f+bXR\239\199\DC1\186\254\249\218\179y\210~\185\250\166\248", _pubPktID = 0, _pubBody = +// "\136\142{\DC4\\\154]/:\184\246N\DC28\204\&2C\f@\172\199\237\162)]W\186\180", _pubProps = []} TEST(Publish311QCTest, Decode28) { - uint8_t pkt[] = {0x38, 0x27, 0x0, 0x7, 0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde, 0x20, 0x2e, 0x40, - 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, 0x36, 0x12, - 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; + uint8_t pkt[] = {0x38, 0x3a, 0x0, 0x1c, 0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, + 0x58, 0x52, 0xef, 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, + 0xa6, 0xf8, 0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, + 0x38, 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, - 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, 0xef, + 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, + 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "{\200\227JE\EM6\185bARg\185\190\226e\205R\n\v\167\CAN\DC3~\152nd8\155'", _pubPktID = 24808, _pubBody = -// "\FS\196\NUL\238\180K\252nl\r\235$v\169K\163\182\254\134\186", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "dU\158\136\251\148W][8D\138i\232?$", +// _pubPktID = 0, _pubBody = "'\136\162\SO\255\RS\205q\229\ACK\148\ETX\129rJ\DC2Y3\165a11\180\247", _pubProps = []} TEST(Publish311QCTest, Encode29) { - uint8_t pkt[] = {0x34, 0x36, 0x0, 0x1e, 0x7b, 0xc8, 0xe3, 0x4a, 0x45, 0x19, 0x36, 0xb9, 0x62, 0x41, - 0x52, 0x67, 0xb9, 0xbe, 0xe2, 0x65, 0xcd, 0x52, 0xa, 0xb, 0xa7, 0x18, 0x13, 0x7e, - 0x98, 0x6e, 0x64, 0x38, 0x9b, 0x27, 0x60, 0xe8, 0x1c, 0xc4, 0x0, 0xee, 0xb4, 0x4b, - 0xfc, 0x6e, 0x6c, 0xd, 0xeb, 0x24, 0x76, 0xa9, 0x4b, 0xa3, 0xb6, 0xfe, 0x86, 0xba}; - uint8_t topic_bytes[] = {0x7b, 0xc8, 0xe3, 0x4a, 0x45, 0x19, 0x36, 0xb9, 0x62, 0x41, 0x52, 0x67, 0xb9, 0xbe, 0xe2, - 0x65, 0xcd, 0x52, 0xa, 0xb, 0xa7, 0x18, 0x13, 0x7e, 0x98, 0x6e, 0x64, 0x38, 0x9b, 0x27}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x2a, 0x0, 0x10, 0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, 0x5b, 0x38, 0x44, + 0x8a, 0x69, 0xe8, 0x3f, 0x24, 0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, + 0x94, 0x3, 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; + uint8_t topic_bytes[] = {0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, + 0x5b, 0x38, 0x44, 0x8a, 0x69, 0xe8, 0x3f, 0x24}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x1c, 0xc4, 0x0, 0xee, 0xb4, 0x4b, 0xfc, 0x6e, 0x6c, 0xd, - 0xeb, 0x24, 0x76, 0xa9, 0x4b, 0xa3, 0xb6, 0xfe, 0x86, 0xba}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, 0x94, 0x3, + 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 24; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24808, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "{\200\227JE\EM6\185bARg\185\190\226e\205R\n\v\167\CAN\DC3~\152nd8\155'", _pubPktID = 24808, _pubBody = -// "\FS\196\NUL\238\180K\252nl\r\235$v\169K\163\182\254\134\186", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "dU\158\136\251\148W][8D\138i\232?$", +// _pubPktID = 0, _pubBody = "'\136\162\SO\255\RS\205q\229\ACK\148\ETX\129rJ\DC2Y3\165a11\180\247", _pubProps = []} TEST(Publish311QCTest, Decode29) { - uint8_t pkt[] = {0x34, 0x36, 0x0, 0x1e, 0x7b, 0xc8, 0xe3, 0x4a, 0x45, 0x19, 0x36, 0xb9, 0x62, 0x41, - 0x52, 0x67, 0xb9, 0xbe, 0xe2, 0x65, 0xcd, 0x52, 0xa, 0xb, 0xa7, 0x18, 0x13, 0x7e, - 0x98, 0x6e, 0x64, 0x38, 0x9b, 0x27, 0x60, 0xe8, 0x1c, 0xc4, 0x0, 0xee, 0xb4, 0x4b, - 0xfc, 0x6e, 0x6c, 0xd, 0xeb, 0x24, 0x76, 0xa9, 0x4b, 0xa3, 0xb6, 0xfe, 0x86, 0xba}; + uint8_t pkt[] = {0x39, 0x2a, 0x0, 0x10, 0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, 0x5b, 0x38, 0x44, + 0x8a, 0x69, 0xe8, 0x3f, 0x24, 0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, + 0x94, 0x3, 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7b, 0xc8, 0xe3, 0x4a, 0x45, 0x19, 0x36, 0xb9, 0x62, 0x41, - 0x52, 0x67, 0xb9, 0xbe, 0xe2, 0x65, 0xcd, 0x52, 0xa, 0xb, - 0xa7, 0x18, 0x13, 0x7e, 0x98, 0x6e, 0x64, 0x38, 0x9b, 0x27}; - lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1c, 0xc4, 0x0, 0xee, 0xb4, 0x4b, 0xfc, 0x6e, 0x6c, 0xd, - 0xeb, 0x24, 0x76, 0xa9, 0x4b, 0xa3, 0xb6, 0xfe, 0x86, 0xba}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 24808); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + uint8_t exp_topic_bytes[] = {0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, + 0x5b, 0x38, 0x44, 0x8a, 0x69, 0xe8, 0x3f, 0x24}; + lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, 0x94, 0x3, + 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\218\139Q\DC1\195\175\199\249J\b\183\226\228\185\ESC\245\128\130\166\n]\133:\228\231$K*v", _pubPktID = 0, _pubBody = -// "\SOH\135h\234D\134\149\210zy\n\143\141\&7Q", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\173\207\249\USrJ\214L\ENQAT\140JUG\ESC\FS\165\202\218\206\DEL\142\250'\167s\139", _pubPktID = 24516, _pubBody = "", +// _pubProps = []} TEST(Publish311QCTest, Encode30) { - uint8_t pkt[] = {0x39, 0x2e, 0x0, 0x1d, 0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, - 0xe4, 0xb9, 0x1b, 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, - 0x76, 0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; - uint8_t topic_bytes[] = {0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, 0xe4, 0xb9, 0x1b, - 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, 0x76}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x20, 0x0, 0x1c, 0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, + 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, + 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b, 0x5f, 0xc4}; + uint8_t topic_bytes[] = {0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, + 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 0; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 24516, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\218\139Q\DC1\195\175\199\249J\b\183\226\228\185\ESC\245\128\130\166\n]\133:\228\231$K*v", _pubPktID = 0, _pubBody = -// "\SOH\135h\234D\134\149\210zy\n\143\141\&7Q", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\173\207\249\USrJ\214L\ENQAT\140JUG\ESC\FS\165\202\218\206\DEL\142\250'\167s\139", _pubPktID = 24516, _pubBody = "", +// _pubProps = []} TEST(Publish311QCTest, Decode30) { - uint8_t pkt[] = {0x39, 0x2e, 0x0, 0x1d, 0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, - 0xe4, 0xb9, 0x1b, 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, - 0x76, 0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; + uint8_t pkt[] = {0x3d, 0x20, 0x0, 0x1c, 0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, + 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, + 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b, 0x5f, 0xc4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, 0xe4, 0xb9, 0x1b, - 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, 0x76}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, + 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 24516); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\162[\135Y\179\166\248\129\206{\238\216oc:{M\ESC \SI\180[fv\192\SO", _pubPktID = 0, _pubBody = -// "\129\ETB\238\SYN)\SI\254", _pubProps = [PropAuthenticationData -// "\187\151\183'\US\238\213\205\t8u\181\SYNw",PropReasonString "\216\248-8Y\248\175",PropMessageExpiryInterval 8175]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\240\228VZ\144!o", _pubPktID = +// 2440, _pubBody = "H\151\243\172\184\224\192", _pubProps = [PropPayloadFormatIndicator +// 31,PropRequestProblemInformation 225,PropServerReference +// "\ETB\ESC\156\241}\170\249\160\205\175",PropMessageExpiryInterval 13969,PropSubscriptionIdentifier +// 5,PropRequestResponseInformation 97,PropWillDelayInterval 13658,PropContentType +// "_\133{qb.!\b\"\160\SYNd",PropUserProperty "\251\&6\235#" "x\138\155\155\211 +// \166\135\156\239\255v\SOHz\a,'\154ve\219\DC384\b\239\149\161\DC2",PropSubscriptionIdentifierAvailable +// 165,PropSubscriptionIdentifierAvailable 68,PropMaximumPacketSize 21324,PropRequestProblemInformation +// 81,PropWillDelayInterval 21670,PropResponseInformation +// "\144QB\229f\151.d\232\a\164\bn\240\157O\177\227\211\199\DC1\SYN\165\186\&7\135BM\163\247",PropSharedSubscriptionAvailable +// 243,PropServerKeepAlive 21923,PropSharedSubscriptionAvailable 48,PropSubscriptionIdentifier 0,PropTopicAliasMaximum +// 3371,PropAssignedClientIdentifier +// "\157\152\235\v\182\205h\SI\164\&8\193\207\215W\152\183\&7\152\EM8\131[.adoaa\208\185",PropServerKeepAlive 22147]} TEST(Publish5QCTest, Encode1) { - uint8_t pkt[] = {0x31, 0x44, 0x0, 0x1a, 0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, - 0xee, 0xd8, 0x6f, 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, - 0xc0, 0xe, 0x20, 0x16, 0x0, 0xe, 0xbb, 0x97, 0xb7, 0x27, 0x1f, 0xee, 0xd5, 0xcd, - 0x9, 0x38, 0x75, 0xb5, 0x16, 0x77, 0x1f, 0x0, 0x7, 0xd8, 0xf8, 0x2d, 0x38, 0x59, - 0xf8, 0xaf, 0x2, 0x0, 0x0, 0x1f, 0xef, 0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; - uint8_t topic_bytes[] = {0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, 0xee, 0xd8, 0x6f, - 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, 0xc0, 0xe}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; +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, 0x5b, 0x2e, 0x61, 0x64, + 0x6f, 0x61, 0x61, 0xd0, 0xb9, 0x13, 0x56, 0x83, 0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; + uint8_t topic_bytes[] = {0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 7; - uint8_t bytesprops0[] = {0xbb, 0x97, 0xb7, 0x27, 0x1f, 0xee, 0xd5, 0xcd, 0x9, 0x38, 0x75, 0xb5, 0x16, 0x77}; - uint8_t bytesprops1[] = {0xd8, 0xf8, 0x2d, 0x38, 0x59, 0xf8, 0xaf}; + uint8_t bytesprops0[] = {0x17, 0x1b, 0x9c, 0xf1, 0x7d, 0xaa, 0xf9, 0xa0, 0xcd, 0xaf}; + uint8_t bytesprops1[] = {0x5f, 0x85, 0x7b, 0x71, 0x62, 0x2e, 0x21, 0x8, 0x22, 0xa0, 0x16, 0x64}; + uint8_t bytesprops3[] = {0x78, 0x8a, 0x9b, 0x9b, 0xd3, 0x20, 0xa6, 0x87, 0x9c, 0xef, 0xff, 0x76, 0x1, 0x7a, 0x7, + 0x2c, 0x27, 0x9a, 0x76, 0x65, 0xdb, 0x13, 0x38, 0x34, 0x8, 0xef, 0x95, 0xa1, 0x12}; + uint8_t bytesprops2[] = {0xfb, 0x36, 0xeb, 0x23}; + uint8_t bytesprops4[] = {0x90, 0x51, 0x42, 0xe5, 0x66, 0x97, 0x2e, 0x64, 0xe8, 0x7, 0xa4, 0x8, 0x6e, 0xf0, 0x9d, + 0x4f, 0xb1, 0xe3, 0xd3, 0xc7, 0x11, 0x16, 0xa5, 0xba, 0x37, 0x87, 0x42, 0x4d, 0xa3, 0xf7}; + uint8_t bytesprops5[] = {0x9d, 0x98, 0xeb, 0xb, 0xb6, 0xcd, 0x68, 0xf, 0xa4, 0x38, 0xc1, 0xcf, 0xd7, 0x57, 0x98, + 0xb7, 0x37, 0x98, 0x19, 0x38, 0x83, 0x5b, 0x2e, 0x61, 0x64, 0x6f, 0x61, 0x61, 0xd0, 0xb9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8175}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13969}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13658}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops2}, .v = {29, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21324}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21670}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21923}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3371}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22147}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2440, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\162[\135Y\179\166\248\129\206{\238\216oc:{M\ESC \SI\180[fv\192\SO", _pubPktID = 0, _pubBody = -// "\129\ETB\238\SYN)\SI\254", _pubProps = [PropAuthenticationData -// "\187\151\183'\US\238\213\205\t8u\181\SYNw",PropReasonString "\216\248-8Y\248\175",PropMessageExpiryInterval 8175]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\240\228VZ\144!o", _pubPktID = +// 2440, _pubBody = "H\151\243\172\184\224\192", _pubProps = [PropPayloadFormatIndicator +// 31,PropRequestProblemInformation 225,PropServerReference +// "\ETB\ESC\156\241}\170\249\160\205\175",PropMessageExpiryInterval 13969,PropSubscriptionIdentifier +// 5,PropRequestResponseInformation 97,PropWillDelayInterval 13658,PropContentType +// "_\133{qb.!\b\"\160\SYNd",PropUserProperty "\251\&6\235#" "x\138\155\155\211 +// \166\135\156\239\255v\SOHz\a,'\154ve\219\DC384\b\239\149\161\DC2",PropSubscriptionIdentifierAvailable +// 165,PropSubscriptionIdentifierAvailable 68,PropMaximumPacketSize 21324,PropRequestProblemInformation +// 81,PropWillDelayInterval 21670,PropResponseInformation +// "\144QB\229f\151.d\232\a\164\bn\240\157O\177\227\211\199\DC1\SYN\165\186\&7\135BM\163\247",PropSharedSubscriptionAvailable +// 243,PropServerKeepAlive 21923,PropSharedSubscriptionAvailable 48,PropSubscriptionIdentifier 0,PropTopicAliasMaximum +// 3371,PropAssignedClientIdentifier +// "\157\152\235\v\182\205h\SI\164\&8\193\207\215W\152\183\&7\152\EM8\131[.adoaa\208\185",PropServerKeepAlive 22147]} TEST(Publish5QCTest, Decode1) { - uint8_t pkt[] = {0x31, 0x44, 0x0, 0x1a, 0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, - 0xee, 0xd8, 0x6f, 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, - 0xc0, 0xe, 0x20, 0x16, 0x0, 0xe, 0xbb, 0x97, 0xb7, 0x27, 0x1f, 0xee, 0xd5, 0xcd, - 0x9, 0x38, 0x75, 0xb5, 0x16, 0x77, 0x1f, 0x0, 0x7, 0xd8, 0xf8, 0x2d, 0x38, 0x59, - 0xf8, 0xaf, 0x2, 0x0, 0x0, 0x1f, 0xef, 0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; + uint8_t pkt[] = { + 0x3a, 0xca, 0x1, 0x0, 0x8, 0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f, 0x9, 0x88, 0xb5, 0x1, 0x1, 0x1f, + 0x17, 0xe1, 0x1c, 0x0, 0xa, 0x17, 0x1b, 0x9c, 0xf1, 0x7d, 0xaa, 0xf9, 0xa0, 0xcd, 0xaf, 0x2, 0x0, 0x0, 0x36, + 0x91, 0xb, 0x5, 0x19, 0x61, 0x18, 0x0, 0x0, 0x35, 0x5a, 0x3, 0x0, 0xc, 0x5f, 0x85, 0x7b, 0x71, 0x62, 0x2e, + 0x21, 0x8, 0x22, 0xa0, 0x16, 0x64, 0x26, 0x0, 0x4, 0xfb, 0x36, 0xeb, 0x23, 0x0, 0x1d, 0x78, 0x8a, 0x9b, 0x9b, + 0xd3, 0x20, 0xa6, 0x87, 0x9c, 0xef, 0xff, 0x76, 0x1, 0x7a, 0x7, 0x2c, 0x27, 0x9a, 0x76, 0x65, 0xdb, 0x13, 0x38, + 0x34, 0x8, 0xef, 0x95, 0xa1, 0x12, 0x29, 0xa5, 0x29, 0x44, 0x27, 0x0, 0x0, 0x53, 0x4c, 0x17, 0x51, 0x18, 0x0, + 0x0, 0x54, 0xa6, 0x1a, 0x0, 0x1e, 0x90, 0x51, 0x42, 0xe5, 0x66, 0x97, 0x2e, 0x64, 0xe8, 0x7, 0xa4, 0x8, 0x6e, + 0xf0, 0x9d, 0x4f, 0xb1, 0xe3, 0xd3, 0xc7, 0x11, 0x16, 0xa5, 0xba, 0x37, 0x87, 0x42, 0x4d, 0xa3, 0xf7, 0x2a, 0xf3, + 0x13, 0x55, 0xa3, 0x2a, 0x30, 0xb, 0x0, 0x22, 0xd, 0x2b, 0x12, 0x0, 0x1e, 0x9d, 0x98, 0xeb, 0xb, 0xb6, 0xcd, + 0x68, 0xf, 0xa4, 0x38, 0xc1, 0xcf, 0xd7, 0x57, 0x98, 0xb7, 0x37, 0x98, 0x19, 0x38, 0x83, 0x5b, 0x2e, 0x61, 0x64, + 0x6f, 0x61, 0x61, 0xd0, 0xb9, 0x13, 0x56, 0x83, 0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa2, 0x5b, 0x87, 0x59, 0xb3, 0xa6, 0xf8, 0x81, 0xce, 0x7b, 0xee, 0xd8, 0x6f, - 0x63, 0x3a, 0x7b, 0x4d, 0x1b, 0x20, 0xf, 0xb4, 0x5b, 0x66, 0x76, 0xc0, 0xe}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x81, 0x17, 0xee, 0x16, 0x29, 0xf, 0xfe}; + uint8_t exp_topic_bytes[] = {0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 2440); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); EXPECT_EQ(msg.payload_len, 7); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\"\225\135\&6h>|U\199", _pubPktID = -// 10161, _pubBody = "\240\177C\238jP+", _pubProps = [PropResponseInformation -// "\164L\197\211\149]\171\198\206\DEL\197",PropMaximumQoS 193,PropSubscriptionIdentifier 3,PropTopicAliasMaximum -// 19390,PropWillDelayInterval 23674,PropUserProperty "\168\245W" -// "\233\191\155/\NAK\138,\217\ETXK\203\f",PropAuthenticationMethod -// "\253\176O^\233P\174\DEL\205\160\STX\"N\228X9\141\&9\158\169]5\SYN",PropRequestResponseInformation -// 94,PropAssignedClientIdentifier "\233\243\203\207,",PropSubscriptionIdentifierAvailable 130,PropAuthenticationData -// "\161\213\202\DLE\202]\US\212-\166\238\145",PropPayloadFormatIndicator 9,PropRequestProblemInformation -// 208,PropTopicAlias 6428,PropServerReference "\173L\148\243dc\RS\141fFs\180%U3\135\250",PropReceiveMaximum -// 986,PropTopicAliasMaximum 26453,PropWillDelayInterval 7668,PropMaximumQoS 42,PropMessageExpiryInterval -// 18158,PropRetainAvailable 76,PropMessageExpiryInterval 5254,PropReceiveMaximum 28353,PropResponseInformation -// "\175dT\170H\161\242c\203\213\133\153\144\188\171~N\198+\252\156\171\NUL\227\224\135\221\180",PropCorrelationData -// "\DC3\227\186%;_\238\160",PropAuthenticationMethod "\247?\214",PropRequestProblemInformation -// 76,PropSubscriptionIdentifier 20]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "}o\146\180\a\160\t\DC4T\196Oz)\145Z(2\146\157\n", _pubPktID = 8900, _pubBody = "GA\176\&8", _pubProps = +// [PropSessionExpiryInterval 1395,PropWillDelayInterval 2583,PropTopicAlias 12261,PropMessageExpiryInterval +// 2628,PropWildcardSubscriptionAvailable 174,PropRetainAvailable 239,PropMessageExpiryInterval +// 30086,PropMessageExpiryInterval 4735,PropRequestProblemInformation 181,PropSharedSubscriptionAvailable +// 244,PropUserProperty "\143\228Ymo\ENQ\210\NUL\251\150g\249W\205\239\175\236g" +// "\243\ENQz/\158\220\236\128\172\162\148(\226\245\223~\234\247\150\169\252\SI \CANhR\211"]} TEST(Publish5QCTest, Encode2) { - uint8_t pkt[] = {0x3b, 0xe4, 0x1, 0x0,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x7e, 0x4e, 0xc6, 0x2b, 0xfc, 0x9c, 0xab, 0x0, 0xe3, 0xe0, 0x87, 0xdd, 0xb4, 0x9, - 0x0, 0x8, 0x13, 0xe3, 0xba, 0x25, 0x3b, 0x5f, 0xee, 0xa0, 0x15, 0x0, 0x3, 0xf7, 0x3f, 0xd6, 0x17, - 0x4c, 0xb, 0x14, 0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; - uint8_t topic_bytes[] = {0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, 0x55, 0xc7}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x73, 0x0, 0x14, 0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, 0x4f, 0x7a, 0x29, + 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa, 0x22, 0xc4, 0x56, 0x11, 0x0, 0x0, 0x5, 0x73, 0x18, 0x0, + 0x0, 0xa, 0x17, 0x23, 0x2f, 0xe5, 0x2, 0x0, 0x0, 0xa, 0x44, 0x28, 0xae, 0x25, 0xef, 0x2, 0x0, + 0x0, 0x75, 0x86, 0x2, 0x0, 0x0, 0x12, 0x7f, 0x17, 0xb5, 0x2a, 0xf4, 0x26, 0x0, 0x12, 0x8f, 0xe4, + 0x59, 0x6d, 0x6f, 0x5, 0xd2, 0x0, 0xfb, 0x96, 0x67, 0xf9, 0x57, 0xcd, 0xef, 0xaf, 0xec, 0x67, 0x0, + 0x1b, 0xf3, 0x5, 0x7a, 0x2f, 0x9e, 0xdc, 0xec, 0x80, 0xac, 0xa2, 0x94, 0x28, 0xe2, 0xf5, 0xdf, 0x7e, + 0xea, 0xf7, 0x96, 0xa9, 0xfc, 0xf, 0x20, 0x18, 0x68, 0x52, 0xd3, 0x47, 0x41, 0xb0, 0x38}; + uint8_t topic_bytes[] = {0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, + 0x4f, 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; + uint8_t msg_bytes[] = {0x47, 0x41, 0xb0, 0x38}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 4; - uint8_t bytesprops0[] = {0xa4, 0x4c, 0xc5, 0xd3, 0x95, 0x5d, 0xab, 0xc6, 0xce, 0x7f, 0xc5}; - uint8_t bytesprops2[] = {0xe9, 0xbf, 0x9b, 0x2f, 0x15, 0x8a, 0x2c, 0xd9, 0x3, 0x4b, 0xcb, 0xc}; - uint8_t bytesprops1[] = {0xa8, 0xf5, 0x57}; - uint8_t bytesprops3[] = {0xfd, 0xb0, 0x4f, 0x5e, 0xe9, 0x50, 0xae, 0x7f, 0xcd, 0xa0, 0x2, 0x22, - 0x4e, 0xe4, 0x58, 0x39, 0x8d, 0x39, 0x9e, 0xa9, 0x5d, 0x35, 0x16}; - uint8_t bytesprops4[] = {0xe9, 0xf3, 0xcb, 0xcf, 0x2c}; - uint8_t bytesprops5[] = {0xa1, 0xd5, 0xca, 0x10, 0xca, 0x5d, 0x1f, 0xd4, 0x2d, 0xa6, 0xee, 0x91}; - uint8_t bytesprops6[] = {0xad, 0x4c, 0x94, 0xf3, 0x64, 0x63, 0x1e, 0x8d, 0x66, - 0x46, 0x73, 0xb4, 0x25, 0x55, 0x33, 0x87, 0xfa}; - uint8_t bytesprops7[] = {0xaf, 0x64, 0x54, 0xaa, 0x48, 0xa1, 0xf2, 0x63, 0xcb, 0xd5, 0x85, 0x99, 0x90, 0xbc, - 0xab, 0x7e, 0x4e, 0xc6, 0x2b, 0xfc, 0x9c, 0xab, 0x0, 0xe3, 0xe0, 0x87, 0xdd, 0xb4}; - uint8_t bytesprops8[] = {0x13, 0xe3, 0xba, 0x25, 0x3b, 0x5f, 0xee, 0xa0}; - uint8_t bytesprops9[] = {0xf7, 0x3f, 0xd6}; + uint8_t bytesprops1[] = {0xf3, 0x5, 0x7a, 0x2f, 0x9e, 0xdc, 0xec, 0x80, 0xac, 0xa2, 0x94, 0x28, 0xe2, 0xf5, + 0xdf, 0x7e, 0xea, 0xf7, 0x96, 0xa9, 0xfc, 0xf, 0x20, 0x18, 0x68, 0x52, 0xd3}; + uint8_t bytesprops0[] = {0x8f, 0xe4, 0x59, 0x6d, 0x6f, 0x5, 0xd2, 0x0, 0xfb, + 0x96, 0x67, 0xf9, 0x57, 0xcd, 0xef, 0xaf, 0xec, 0x67}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19390}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23674}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops1}, .v = {12, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6428}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 986}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26453}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7668}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18158}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5254}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28353}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1395}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2583}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12261}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2628}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30086}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4735}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops0}, .v = {27, (char*)&bytesprops1}}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10161, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 8900, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\"\225\135\&6h>|U\199", _pubPktID = -// 10161, _pubBody = "\240\177C\238jP+", _pubProps = [PropResponseInformation -// "\164L\197\211\149]\171\198\206\DEL\197",PropMaximumQoS 193,PropSubscriptionIdentifier 3,PropTopicAliasMaximum -// 19390,PropWillDelayInterval 23674,PropUserProperty "\168\245W" -// "\233\191\155/\NAK\138,\217\ETXK\203\f",PropAuthenticationMethod -// "\253\176O^\233P\174\DEL\205\160\STX\"N\228X9\141\&9\158\169]5\SYN",PropRequestResponseInformation -// 94,PropAssignedClientIdentifier "\233\243\203\207,",PropSubscriptionIdentifierAvailable 130,PropAuthenticationData -// "\161\213\202\DLE\202]\US\212-\166\238\145",PropPayloadFormatIndicator 9,PropRequestProblemInformation -// 208,PropTopicAlias 6428,PropServerReference "\173L\148\243dc\RS\141fFs\180%U3\135\250",PropReceiveMaximum -// 986,PropTopicAliasMaximum 26453,PropWillDelayInterval 7668,PropMaximumQoS 42,PropMessageExpiryInterval -// 18158,PropRetainAvailable 76,PropMessageExpiryInterval 5254,PropReceiveMaximum 28353,PropResponseInformation -// "\175dT\170H\161\242c\203\213\133\153\144\188\171~N\198+\252\156\171\NUL\227\224\135\221\180",PropCorrelationData -// "\DC3\227\186%;_\238\160",PropAuthenticationMethod "\247?\214",PropRequestProblemInformation -// 76,PropSubscriptionIdentifier 20]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "}o\146\180\a\160\t\DC4T\196Oz)\145Z(2\146\157\n", _pubPktID = 8900, _pubBody = "GA\176\&8", _pubProps = +// [PropSessionExpiryInterval 1395,PropWillDelayInterval 2583,PropTopicAlias 12261,PropMessageExpiryInterval +// 2628,PropWildcardSubscriptionAvailable 174,PropRetainAvailable 239,PropMessageExpiryInterval +// 30086,PropMessageExpiryInterval 4735,PropRequestProblemInformation 181,PropSharedSubscriptionAvailable +// 244,PropUserProperty "\143\228Ymo\ENQ\210\NUL\251\150g\249W\205\239\175\236g" +// "\243\ENQz/\158\220\236\128\172\162\148(\226\245\223~\234\247\150\169\252\SI \CANhR\211"]} TEST(Publish5QCTest, Decode2) { - uint8_t pkt[] = {0x3b, 0xe4, 0x1, 0x0, 0x9, 0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, 0x55, 0xc7, 0x27, 0xb1, 0xce, - 0x1, 0x1a, 0x0, 0xb, 0xa4, 0x4c, 0xc5, 0xd3, 0x95, 0x5d, 0xab, 0xc6, 0xce, 0x7f, 0xc5, 0x24, 0xc1, - 0xb, 0x3, 0x22, 0x4b, 0xbe, 0x18, 0x0, 0x0, 0x5c, 0x7a, 0x26, 0x0, 0x3, 0xa8, 0xf5, 0x57, 0x0, - 0xc, 0xe9, 0xbf, 0x9b, 0x2f, 0x15, 0x8a, 0x2c, 0xd9, 0x3, 0x4b, 0xcb, 0xc, 0x15, 0x0, 0x17, 0xfd, - 0xb0, 0x4f, 0x5e, 0xe9, 0x50, 0xae, 0x7f, 0xcd, 0xa0, 0x2, 0x22, 0x4e, 0xe4, 0x58, 0x39, 0x8d, 0x39, - 0x9e, 0xa9, 0x5d, 0x35, 0x16, 0x19, 0x5e, 0x12, 0x0, 0x5, 0xe9, 0xf3, 0xcb, 0xcf, 0x2c, 0x29, 0x82, - 0x16, 0x0, 0xc, 0xa1, 0xd5, 0xca, 0x10, 0xca, 0x5d, 0x1f, 0xd4, 0x2d, 0xa6, 0xee, 0x91, 0x1, 0x9, - 0x17, 0xd0, 0x23, 0x19, 0x1c, 0x1c, 0x0, 0x11, 0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, 0x67, 0x0, + 0x1b, 0xf3, 0x5, 0x7a, 0x2f, 0x9e, 0xdc, 0xec, 0x80, 0xac, 0xa2, 0x94, 0x28, 0xe2, 0xf5, 0xdf, 0x7e, + 0xea, 0xf7, 0x96, 0xa9, 0xfc, 0xf, 0x20, 0x18, 0x68, 0x52, 0xd3, 0x47, 0x41, 0xb0, 0x38}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x22, 0xe1, 0x87, 0x36, 0x68, 0x3e, 0x7c, 0x55, 0xc7}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf0, 0xb1, 0x43, 0xee, 0x6a, 0x50, 0x2b}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, + 0x4f, 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x47, 0x41, 0xb0, 0x38}; + lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 10161); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(packet_id, 8900); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 4); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\\\247{A0\nX.\STX\243\151\STX\230}\221\144D<\209\NAKM\153\192\209=d\148\179\231", _pubPktID = 26319, _pubBody = -// "\166\229\136\206\180b\149", _pubProps = [PropWillDelayInterval 6188,PropPayloadFormatIndicator 235]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\151\STXH3\208\EM\137z\b\129j\156\252", _pubPktID = 0, _pubBody = "\202\152NR\SI_", _pubProps = +// [PropMessageExpiryInterval 10144,PropSharedSubscriptionAvailable 254,PropReasonString +// "\SOH?\193\190X\175\185\"+\242\&7\147V\172C\214\183\SOH\DC4\255\b\227\148o\135(",PropSubscriptionIdentifier +// 3,PropAssignedClientIdentifier "\162\193\236{\188\238\SYNjk)\156\205\CAN\SUB\215",PropRetainAvailable +// 85,PropServerReference "\253\161&*'\DC1\167\188T6\DC3\249",PropSubscriptionIdentifierAvailable 139,PropTopicAlias +// 22556,PropAuthenticationData "\196\190\222.S\RS\129y9\209\CAN\168\&5"]} TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = {0x3c, 0x30, 0x0, 0x1d, 0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, - 0x7d, 0xdd, 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7, 0x66, - 0xcf, 0x7, 0x18, 0x0, 0x0, 0x18, 0x2c, 0x1, 0xeb, 0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; - uint8_t topic_bytes[] = {0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, 0x7d, 0xdd, - 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x74, 0x0, 0xd, 0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc, + 0x5e, 0x2, 0x0, 0x0, 0x27, 0xa0, 0x2a, 0xfe, 0x1f, 0x0, 0x1a, 0x1, 0x3f, 0xc1, 0xbe, 0x58, 0xaf, + 0xb9, 0x22, 0x2b, 0xf2, 0x37, 0x93, 0x56, 0xac, 0x43, 0xd6, 0xb7, 0x1, 0x14, 0xff, 0x8, 0xe3, 0x94, + 0x6f, 0x87, 0x28, 0xb, 0x3, 0x12, 0x0, 0xf, 0xa2, 0xc1, 0xec, 0x7b, 0xbc, 0xee, 0x16, 0x6a, 0x6b, + 0x29, 0x9c, 0xcd, 0x18, 0x1a, 0xd7, 0x25, 0x55, 0x1c, 0x0, 0xc, 0xfd, 0xa1, 0x26, 0x2a, 0x27, 0x11, + 0xa7, 0xbc, 0x54, 0x36, 0x13, 0xf9, 0x29, 0x8b, 0x23, 0x58, 0x1c, 0x16, 0x0, 0xd, 0xc4, 0xbe, 0xde, + 0x2e, 0x53, 0x1e, 0x81, 0x79, 0x39, 0xd1, 0x18, 0xa8, 0x35, 0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; + uint8_t topic_bytes[] = {0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; + uint8_t msg_bytes[] = {0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 6; + + uint8_t bytesprops0[] = {0x1, 0x3f, 0xc1, 0xbe, 0x58, 0xaf, 0xb9, 0x22, 0x2b, 0xf2, 0x37, 0x93, 0x56, + 0xac, 0x43, 0xd6, 0xb7, 0x1, 0x14, 0xff, 0x8, 0xe3, 0x94, 0x6f, 0x87, 0x28}; + uint8_t bytesprops1[] = {0xa2, 0xc1, 0xec, 0x7b, 0xbc, 0xee, 0x16, 0x6a, 0x6b, 0x29, 0x9c, 0xcd, 0x18, 0x1a, 0xd7}; + uint8_t bytesprops2[] = {0xfd, 0xa1, 0x26, 0x2a, 0x27, 0x11, 0xa7, 0xbc, 0x54, 0x36, 0x13, 0xf9}; + uint8_t bytesprops3[] = {0xc4, 0xbe, 0xde, 0x2e, 0x53, 0x1e, 0x81, 0x79, 0x39, 0xd1, 0x18, 0xa8, 0x35}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6188}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10144}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22556}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 26319, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\\\247{A0\nX.\STX\243\151\STX\230}\221\144D<\209\NAKM\153\192\209=d\148\179\231", _pubPktID = 26319, _pubBody = -// "\166\229\136\206\180b\149", _pubProps = [PropWillDelayInterval 6188,PropPayloadFormatIndicator 235]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\151\STXH3\208\EM\137z\b\129j\156\252", _pubPktID = 0, _pubBody = "\202\152NR\SI_", _pubProps = +// [PropMessageExpiryInterval 10144,PropSharedSubscriptionAvailable 254,PropReasonString +// "\SOH?\193\190X\175\185\"+\242\&7\147V\172C\214\183\SOH\DC4\255\b\227\148o\135(",PropSubscriptionIdentifier +// 3,PropAssignedClientIdentifier "\162\193\236{\188\238\SYNjk)\156\205\CAN\SUB\215",PropRetainAvailable +// 85,PropServerReference "\253\161&*'\DC1\167\188T6\DC3\249",PropSubscriptionIdentifierAvailable 139,PropTopicAlias +// 22556,PropAuthenticationData "\196\190\222.S\RS\129y9\209\CAN\168\&5"]} TEST(Publish5QCTest, Decode3) { - uint8_t pkt[] = {0x3c, 0x30, 0x0, 0x1d, 0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, - 0x7d, 0xdd, 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7, 0x66, - 0xcf, 0x7, 0x18, 0x0, 0x0, 0x18, 0x2c, 0x1, 0xeb, 0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; + uint8_t pkt[] = {0x38, 0x74, 0x0, 0xd, 0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc, + 0x5e, 0x2, 0x0, 0x0, 0x27, 0xa0, 0x2a, 0xfe, 0x1f, 0x0, 0x1a, 0x1, 0x3f, 0xc1, 0xbe, 0x58, 0xaf, + 0xb9, 0x22, 0x2b, 0xf2, 0x37, 0x93, 0x56, 0xac, 0x43, 0xd6, 0xb7, 0x1, 0x14, 0xff, 0x8, 0xe3, 0x94, + 0x6f, 0x87, 0x28, 0xb, 0x3, 0x12, 0x0, 0xf, 0xa2, 0xc1, 0xec, 0x7b, 0xbc, 0xee, 0x16, 0x6a, 0x6b, + 0x29, 0x9c, 0xcd, 0x18, 0x1a, 0xd7, 0x25, 0x55, 0x1c, 0x0, 0xc, 0xfd, 0xa1, 0x26, 0x2a, 0x27, 0x11, + 0xa7, 0xbc, 0x54, 0x36, 0x13, 0xf9, 0x29, 0x8b, 0x23, 0x58, 0x1c, 0x16, 0x0, 0xd, 0xc4, 0xbe, 0xde, + 0x2e, 0x53, 0x1e, 0x81, 0x79, 0x39, 0xd1, 0x18, 0xa8, 0x35, 0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5c, 0xf7, 0x7b, 0x41, 0x30, 0xa, 0x58, 0x2e, 0x2, 0xf3, 0x97, 0x2, 0xe6, 0x7d, 0xdd, - 0x90, 0x44, 0x3c, 0xd1, 0x15, 0x4d, 0x99, 0xc0, 0xd1, 0x3d, 0x64, 0x94, 0xb3, 0xe7}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa6, 0xe5, 0x88, 0xce, 0xb4, 0x62, 0x95}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 26319); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ETXTx", _pubPktID = 0, _pubBody = -// "Ei\SI", _pubProps = [PropAssignedClientIdentifier -// "\247P\DC3-\230\239\243.\bn\"k\DC4\253\149",PropMessageExpiryInterval 25436,PropMessageExpiryInterval -// 27046,PropServerKeepAlive 53,PropServerReference -// "t\f\"t\SYN\215\SI\136j\245\255\SI\ENQj\166U\206\169\151\177\254\197sv\206\&2V\DC3\221\DC2",PropMaximumQoS -// 25,PropResponseTopic "\153\231\234\251P\160\250\135\163\DLE\166C\234JZ\184\226A",PropAuthenticationMethod -// "\218\175u@J\220\235\149(^\192\SOH\148\r;\153\222\134Z\237Xr\r\136 ",PropUserProperty -// "\239\&6\163'\244\&2\255\GSpmxEb\146\142\156\215\235t" -// "\175\&2\225\245\240\&2\DC1^\135\156\197\164\202",PropMessageExpiryInterval 31197,PropResponseInformation -// "#Jq\213\243K\217\176\&5\165\146\CAN^\204\216\ESC\218e[",PropMaximumPacketSize 11704,PropSharedSubscriptionAvailable -// 116,PropContentType -// "\DC4\t\166B1\168\252\NUL<;\vp\aI\194\175`\t+\170\tG\212\136\191\&8\203%\207Q",PropRequestResponseInformation -// 182,PropTopicAlias 22990,PropMaximumPacketSize 5336,PropTopicAlias 26427,PropContentType -// "\176\252\ETX\245\224\182T\227kK\198%\204V\a0\194\174\&5y\240\205\131\196"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "<\v\SYN\154J\242", _pubPktID = +// 10596, _pubBody = "\187\150\168\193Z\202\188\STX?", _pubProps = [PropAssignedClientIdentifier +// "\223\a\220\EOTC\"",PropRequestResponseInformation 239,PropAuthenticationData +// "X.\130%\GS\217\159\&3\177\227e\236",PropRequestProblemInformation 141,PropRequestResponseInformation +// 39,PropTopicAliasMaximum 17854,PropRequestResponseInformation 80,PropTopicAliasMaximum +// 26066,PropRequestResponseInformation 37,PropSharedSubscriptionAvailable 197,PropAssignedClientIdentifier +// "a\EM\STX\v",PropRequestResponseInformation 119,PropResponseTopic +// "H\222\167\142\164+h\153\180\242>\ESC$\175\ay\164",PropUserProperty "\153\151\136dT" +// "\244\237\151\169\184\229\236\bL\152J\239\141q\224El"]} TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = {0x39, 0x8d, 0x2, 0x0, 0x3, 0x3, 0x54, 0x78, 0x83, 0x2, 0x12, 0x0, 0xf, 0xf7, 0x50, 0x13, 0x2d, - 0xe6, 0xef, 0xf3, 0x2e, 0x8, 0x6e, 0x22, 0x6b, 0x14, 0xfd, 0x95, 0x2, 0x0, 0x0, 0x63, 0x5c, 0x2, - 0x0, 0x0, 0x69, 0xa6, 0x13, 0x0, 0x35, 0x1c, 0x0, 0x1e, 0x74, 0xc, 0x22, 0x74, 0x16, 0xd7, 0xf, - 0x88, 0x6a, 0xf5, 0xff, 0xf, 0x5, 0x6a, 0xa6, 0x55, 0xce, 0xa9, 0x97, 0xb1, 0xfe, 0xc5, 0x73, 0x76, - 0xce, 0x32, 0x56, 0x13, 0xdd, 0x12, 0x24, 0x19, 0x8, 0x0, 0x12, 0x99, 0xe7, 0xea, 0xfb, 0x50, 0xa0, - 0xfa, 0x87, 0xa3, 0x10, 0xa6, 0x43, 0xea, 0x4a, 0x5a, 0xb8, 0xe2, 0x41, 0x15, 0x0, 0x19, 0xda, 0xaf, - 0x75, 0x40, 0x4a, 0xdc, 0xeb, 0x95, 0x28, 0x5e, 0xc0, 0x1, 0x94, 0xd, 0x3b, 0x99, 0xde, 0x86, 0x5a, - 0xed, 0x58, 0x72, 0xd, 0x88, 0x20, 0x26, 0x0, 0x13, 0xef, 0x36, 0xa3, 0x27, 0xf4, 0x32, 0xff, 0x1d, - 0x70, 0x6d, 0x78, 0x45, 0x62, 0x92, 0x8e, 0x9c, 0xd7, 0xeb, 0x74, 0x0, 0xd, 0xaf, 0x32, 0xe1, 0xf5, - 0xf0, 0x32, 0x11, 0x5e, 0x87, 0x9c, 0xc5, 0xa4, 0xca, 0x2, 0x0, 0x0, 0x79, 0xdd, 0x1a, 0x0, 0x13, - 0x23, 0x4a, 0x71, 0xd5, 0xf3, 0x4b, 0xd9, 0xb0, 0x35, 0xa5, 0x92, 0x18, 0x5e, 0xcc, 0xd8, 0x1b, 0xda, - 0x65, 0x5b, 0x27, 0x0, 0x0, 0x2d, 0xb8, 0x2a, 0x74, 0x3, 0x0, 0x1e, 0x14, 0x9, 0xa6, 0x42, 0x31, - 0xa8, 0xfc, 0x0, 0x3c, 0x3b, 0xb, 0x70, 0x7, 0x49, 0xc2, 0xaf, 0x60, 0x9, 0x2b, 0xaa, 0x9, 0x47, - 0xd4, 0x88, 0xbf, 0x38, 0xcb, 0x25, 0xcf, 0x51, 0x19, 0xb6, 0x23, 0x59, 0xce, 0x27, 0x0, 0x0, 0x14, - 0xd8, 0x23, 0x67, 0x3b, 0x3, 0x0, 0x18, 0xb0, 0xfc, 0x3, 0xf5, 0xe0, 0xb6, 0x54, 0xe3, 0x6b, 0x4b, - 0xc6, 0x25, 0xcc, 0x56, 0x7, 0x30, 0xc2, 0xae, 0x35, 0x79, 0xf0, 0xcd, 0x83, 0xc4, 0x45, 0x69, 0xf}; - uint8_t topic_bytes[] = {0x3, 0x54, 0x78}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x76, 0x0, 0x6, 0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2, 0x29, 0x64, 0x62, 0x12, 0x0, + 0x6, 0xdf, 0x7, 0xdc, 0x4, 0x43, 0x22, 0x19, 0xef, 0x16, 0x0, 0xc, 0x58, 0x2e, 0x82, + 0x25, 0x1d, 0xd9, 0x9f, 0x33, 0xb1, 0xe3, 0x65, 0xec, 0x17, 0x8d, 0x19, 0x27, 0x22, 0x45, + 0xbe, 0x19, 0x50, 0x22, 0x65, 0xd2, 0x19, 0x25, 0x2a, 0xc5, 0x12, 0x0, 0x4, 0x61, 0x19, + 0x2, 0xb, 0x19, 0x77, 0x8, 0x0, 0x11, 0x48, 0xde, 0xa7, 0x8e, 0xa4, 0x2b, 0x68, 0x99, + 0xb4, 0xf2, 0x3e, 0x1b, 0x24, 0xaf, 0x7, 0x79, 0xa4, 0x26, 0x0, 0x5, 0x99, 0x97, 0x88, + 0x64, 0x54, 0x0, 0x11, 0xf4, 0xed, 0x97, 0xa9, 0xb8, 0xe5, 0xec, 0x8, 0x4c, 0x98, 0x4a, + 0xef, 0x8d, 0x71, 0xe0, 0x45, 0x6c, 0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; + uint8_t topic_bytes[] = {0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x45, 0x69, 0xf}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 9; - uint8_t bytesprops0[] = {0xf7, 0x50, 0x13, 0x2d, 0xe6, 0xef, 0xf3, 0x2e, 0x8, 0x6e, 0x22, 0x6b, 0x14, 0xfd, 0x95}; - uint8_t bytesprops1[] = {0x74, 0xc, 0x22, 0x74, 0x16, 0xd7, 0xf, 0x88, 0x6a, 0xf5, 0xff, 0xf, 0x5, 0x6a, 0xa6, - 0x55, 0xce, 0xa9, 0x97, 0xb1, 0xfe, 0xc5, 0x73, 0x76, 0xce, 0x32, 0x56, 0x13, 0xdd, 0x12}; - uint8_t bytesprops2[] = {0x99, 0xe7, 0xea, 0xfb, 0x50, 0xa0, 0xfa, 0x87, 0xa3, - 0x10, 0xa6, 0x43, 0xea, 0x4a, 0x5a, 0xb8, 0xe2, 0x41}; - uint8_t bytesprops3[] = {0xda, 0xaf, 0x75, 0x40, 0x4a, 0xdc, 0xeb, 0x95, 0x28, 0x5e, 0xc0, 0x1, 0x94, - 0xd, 0x3b, 0x99, 0xde, 0x86, 0x5a, 0xed, 0x58, 0x72, 0xd, 0x88, 0x20}; - uint8_t bytesprops5[] = {0xaf, 0x32, 0xe1, 0xf5, 0xf0, 0x32, 0x11, 0x5e, 0x87, 0x9c, 0xc5, 0xa4, 0xca}; - uint8_t bytesprops4[] = {0xef, 0x36, 0xa3, 0x27, 0xf4, 0x32, 0xff, 0x1d, 0x70, 0x6d, - 0x78, 0x45, 0x62, 0x92, 0x8e, 0x9c, 0xd7, 0xeb, 0x74}; - uint8_t bytesprops6[] = {0x23, 0x4a, 0x71, 0xd5, 0xf3, 0x4b, 0xd9, 0xb0, 0x35, 0xa5, - 0x92, 0x18, 0x5e, 0xcc, 0xd8, 0x1b, 0xda, 0x65, 0x5b}; - uint8_t bytesprops7[] = {0x14, 0x9, 0xa6, 0x42, 0x31, 0xa8, 0xfc, 0x0, 0x3c, 0x3b, 0xb, 0x70, 0x7, 0x49, 0xc2, - 0xaf, 0x60, 0x9, 0x2b, 0xaa, 0x9, 0x47, 0xd4, 0x88, 0xbf, 0x38, 0xcb, 0x25, 0xcf, 0x51}; - uint8_t bytesprops8[] = {0xb0, 0xfc, 0x3, 0xf5, 0xe0, 0xb6, 0x54, 0xe3, 0x6b, 0x4b, 0xc6, 0x25, - 0xcc, 0x56, 0x7, 0x30, 0xc2, 0xae, 0x35, 0x79, 0xf0, 0xcd, 0x83, 0xc4}; + uint8_t bytesprops0[] = {0xdf, 0x7, 0xdc, 0x4, 0x43, 0x22}; + uint8_t bytesprops1[] = {0x58, 0x2e, 0x82, 0x25, 0x1d, 0xd9, 0x9f, 0x33, 0xb1, 0xe3, 0x65, 0xec}; + uint8_t bytesprops2[] = {0x61, 0x19, 0x2, 0xb}; + uint8_t bytesprops3[] = {0x48, 0xde, 0xa7, 0x8e, 0xa4, 0x2b, 0x68, 0x99, 0xb4, + 0xf2, 0x3e, 0x1b, 0x24, 0xaf, 0x7, 0x79, 0xa4}; + uint8_t bytesprops5[] = {0xf4, 0xed, 0x97, 0xa9, 0xb8, 0xe5, 0xec, 0x8, 0x4c, + 0x98, 0x4a, 0xef, 0x8d, 0x71, 0xe0, 0x45, 0x6c}; + uint8_t bytesprops4[] = {0x99, 0x97, 0x88, 0x64, 0x54}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25436}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27046}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 53}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops4}, .v = {13, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31197}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11704}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22990}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5336}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26427}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17854}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26066}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops4}, .v = {17, (char*)&bytesprops5}}}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10596, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ETXTx", _pubPktID = 0, _pubBody = -// "Ei\SI", _pubProps = [PropAssignedClientIdentifier -// "\247P\DC3-\230\239\243.\bn\"k\DC4\253\149",PropMessageExpiryInterval 25436,PropMessageExpiryInterval -// 27046,PropServerKeepAlive 53,PropServerReference -// "t\f\"t\SYN\215\SI\136j\245\255\SI\ENQj\166U\206\169\151\177\254\197sv\206\&2V\DC3\221\DC2",PropMaximumQoS -// 25,PropResponseTopic "\153\231\234\251P\160\250\135\163\DLE\166C\234JZ\184\226A",PropAuthenticationMethod -// "\218\175u@J\220\235\149(^\192\SOH\148\r;\153\222\134Z\237Xr\r\136 ",PropUserProperty -// "\239\&6\163'\244\&2\255\GSpmxEb\146\142\156\215\235t" -// "\175\&2\225\245\240\&2\DC1^\135\156\197\164\202",PropMessageExpiryInterval 31197,PropResponseInformation -// "#Jq\213\243K\217\176\&5\165\146\CAN^\204\216\ESC\218e[",PropMaximumPacketSize 11704,PropSharedSubscriptionAvailable -// 116,PropContentType -// "\DC4\t\166B1\168\252\NUL<;\vp\aI\194\175`\t+\170\tG\212\136\191\&8\203%\207Q",PropRequestResponseInformation -// 182,PropTopicAlias 22990,PropMaximumPacketSize 5336,PropTopicAlias 26427,PropContentType -// "\176\252\ETX\245\224\182T\227kK\198%\204V\a0\194\174\&5y\240\205\131\196"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "<\v\SYN\154J\242", _pubPktID = +// 10596, _pubBody = "\187\150\168\193Z\202\188\STX?", _pubProps = [PropAssignedClientIdentifier +// "\223\a\220\EOTC\"",PropRequestResponseInformation 239,PropAuthenticationData +// "X.\130%\GS\217\159\&3\177\227e\236",PropRequestProblemInformation 141,PropRequestResponseInformation +// 39,PropTopicAliasMaximum 17854,PropRequestResponseInformation 80,PropTopicAliasMaximum +// 26066,PropRequestResponseInformation 37,PropSharedSubscriptionAvailable 197,PropAssignedClientIdentifier +// "a\EM\STX\v",PropRequestResponseInformation 119,PropResponseTopic +// "H\222\167\142\164+h\153\180\242>\ESC$\175\ay\164",PropUserProperty "\153\151\136dT" +// "\244\237\151\169\184\229\236\bL\152J\239\141q\224El"]} TEST(Publish5QCTest, Decode4) { - uint8_t pkt[] = {0x39, 0x8d, 0x2, 0x0, 0x3, 0x3, 0x54, 0x78, 0x83, 0x2, 0x12, 0x0, 0xf, 0xf7, 0x50, 0x13, 0x2d,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, 0x3f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3, 0x54, 0x78}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x45, 0x69, 0xf}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 10596); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 7815, _pubBody = -// "\168\142\FS", _pubProps = [PropResponseInformation "\208/+\158\144\255\SYN\SO\243Inw",PropTopicAliasMaximum -// 18437,PropTopicAliasMaximum 1104,PropSessionExpiryInterval 27902,PropServerReference -// "\134\174\231\235\232\CAN\178\130\CAN\216f\166 \145\172\141",PropTopicAliasMaximum 8918,PropMessageExpiryInterval -// 27657,PropAuthenticationMethod "\196'\\-",PropContentType -// "\150\\\188\244\131\167\193\136\DC4\CANB\v",PropSessionExpiryInterval 7240,PropAuthenticationMethod -// "\155\v:@\NAK\193\248M*",PropRetainAvailable 253,PropContentType -// "\NUL\252knZ\139JD\239\242%.\144\DC2\185\132R\f\244?",PropAssignedClientIdentifier -// "\209G\149\221\188\138*\FS\ACKu\181\161z\208\169\197\RS\250`r\213\168\237\&4H\174\245",PropReasonString -// "\238q\162m\237\204\214\246[\SI\DC3\151\142k\140\&8 a\SI\GS",PropSharedSubscriptionAvailable 1,PropTopicAliasMaximum -// 3287,PropMessageExpiryInterval 7895,PropRequestResponseInformation 238,PropRequestResponseInformation -// 247,PropRequestProblemInformation 76,PropCorrelationData -// "\194\211\165\148fO\208\198\167Xk\134w\255U`\169\EOT\133I\179u\241\ETXx\254",PropWillDelayInterval -// 20602,PropMessageExpiryInterval 24630,PropContentType -// "2\248\130\228\STX\203\237\146\161\153\250z\160H",PropMaximumPacketSize 18994,PropReasonString -// "\140-\216\252\240u\246\234\213\233y\253\167\196\223:\151"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\165,\215\220S\205E\205\200\222\229\249\ESC\148", _pubPktID = 15507, _pubBody = "pR:\130:", _pubProps = +// [PropRequestProblemInformation 19,PropMessageExpiryInterval 20770,PropAuthenticationData +// "\174\254\r\157h\203\190\209",PropCorrelationData +// "l\128}bI\137\160\185\v\169\253\161l;\215\232\241\134I\204)\158\241\166\207\190\216"]} TEST(Publish5QCTest, Encode5) { - uint8_t pkt[] = { - 0x34, 0x94, 0x2, 0x0, 0x0, 0x1e, 0x87, 0x8b, 0x2,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9, 0x0, 0x1a, 0xc2, 0xd3, 0xa5, 0x94, 0x66, 0x4f, 0xd0, 0xc6, 0xa7, 0x58, 0x6b, - 0x86, 0x77, 0xff, 0x55, 0x60, 0xa9, 0x4, 0x85, 0x49, 0xb3, 0x75, 0xf1, 0x3, 0x78, 0xfe, 0x18, 0x0, 0x0, 0x50, - 0x7a, 0x2, 0x0, 0x0, 0x60, 0x36, 0x3, 0x0, 0xe, 0x32, 0xf8, 0x82, 0xe4, 0x2, 0xcb, 0xed, 0x92, 0xa1, 0x99, - 0xfa, 0x7a, 0xa0, 0x48, 0x27, 0x0, 0x0, 0x4a, 0x32, 0x1f, 0x0, 0x11, 0x8c, 0x2d, 0xd8, 0xfc, 0xf0, 0x75, 0xf6, - 0xea, 0xd5, 0xe9, 0x79, 0xfd, 0xa7, 0xc4, 0xdf, 0x3a, 0x97, 0xa8, 0x8e, 0x1c}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x48, 0x0, 0xe, 0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, + 0xf9, 0x1b, 0x94, 0x3c, 0x93, 0x30, 0x17, 0x13, 0x2, 0x0, 0x0, 0x51, 0x22, 0x16, 0x0, + 0x8, 0xae, 0xfe, 0xd, 0x9d, 0x68, 0xcb, 0xbe, 0xd1, 0x9, 0x0, 0x1b, 0x6c, 0x80, 0x7d, + 0x62, 0x49, 0x89, 0xa0, 0xb9, 0xb, 0xa9, 0xfd, 0xa1, 0x6c, 0x3b, 0xd7, 0xe8, 0xf1, 0x86, + 0x49, 0xcc, 0x29, 0x9e, 0xf1, 0xa6, 0xcf, 0xbe, 0xd8, 0x70, 0x52, 0x3a, 0x82, 0x3a}; + uint8_t topic_bytes[] = {0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, 0xf9, 0x1b, 0x94}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xa8, 0x8e, 0x1c}; + uint8_t msg_bytes[] = {0x70, 0x52, 0x3a, 0x82, 0x3a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 5; - uint8_t bytesprops0[] = {0xd0, 0x2f, 0x2b, 0x9e, 0x90, 0xff, 0x16, 0xe, 0xf3, 0x49, 0x6e, 0x77}; - uint8_t bytesprops1[] = {0x86, 0xae, 0xe7, 0xeb, 0xe8, 0x18, 0xb2, 0x82, - 0x18, 0xd8, 0x66, 0xa6, 0x20, 0x91, 0xac, 0x8d}; - uint8_t bytesprops2[] = {0xc4, 0x27, 0x5c, 0x2d}; - uint8_t bytesprops3[] = {0x96, 0x5c, 0xbc, 0xf4, 0x83, 0xa7, 0xc1, 0x88, 0x14, 0x18, 0x42, 0xb}; - uint8_t bytesprops4[] = {0x9b, 0xb, 0x3a, 0x40, 0x15, 0xc1, 0xf8, 0x4d, 0x2a}; - uint8_t bytesprops5[] = {0x0, 0xfc, 0x6b, 0x6e, 0x5a, 0x8b, 0x4a, 0x44, 0xef, 0xf2, - 0x25, 0x2e, 0x90, 0x12, 0xb9, 0x84, 0x52, 0xc, 0xf4, 0x3f}; - uint8_t bytesprops6[] = {0xd1, 0x47, 0x95, 0xdd, 0xbc, 0x8a, 0x2a, 0x1c, 0x6, 0x75, 0xb5, 0xa1, 0x7a, 0xd0, - 0xa9, 0xc5, 0x1e, 0xfa, 0x60, 0x72, 0xd5, 0xa8, 0xed, 0x34, 0x48, 0xae, 0xf5}; - uint8_t bytesprops7[] = {0xee, 0x71, 0xa2, 0x6d, 0xed, 0xcc, 0xd6, 0xf6, 0x5b, 0xf, - 0x13, 0x97, 0x8e, 0x6b, 0x8c, 0x38, 0x20, 0x61, 0xf, 0x1d}; - uint8_t bytesprops8[] = {0xc2, 0xd3, 0xa5, 0x94, 0x66, 0x4f, 0xd0, 0xc6, 0xa7, 0x58, 0x6b, 0x86, 0x77, - 0xff, 0x55, 0x60, 0xa9, 0x4, 0x85, 0x49, 0xb3, 0x75, 0xf1, 0x3, 0x78, 0xfe}; - uint8_t bytesprops9[] = {0x32, 0xf8, 0x82, 0xe4, 0x2, 0xcb, 0xed, 0x92, 0xa1, 0x99, 0xfa, 0x7a, 0xa0, 0x48}; - uint8_t bytesprops10[] = {0x8c, 0x2d, 0xd8, 0xfc, 0xf0, 0x75, 0xf6, 0xea, 0xd5, - 0xe9, 0x79, 0xfd, 0xa7, 0xc4, 0xdf, 0x3a, 0x97}; + uint8_t bytesprops0[] = {0xae, 0xfe, 0xd, 0x9d, 0x68, 0xcb, 0xbe, 0xd1}; + uint8_t bytesprops1[] = {0x6c, 0x80, 0x7d, 0x62, 0x49, 0x89, 0xa0, 0xb9, 0xb, 0xa9, 0xfd, 0xa1, 0x6c, 0x3b, + 0xd7, 0xe8, 0xf1, 0x86, 0x49, 0xcc, 0x29, 0x9e, 0xf1, 0xa6, 0xcf, 0xbe, 0xd8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18437}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1104}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27902}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8918}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27657}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7240}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3287}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7895}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20602}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24630}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18994}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20770}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7815, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15507, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 7815, _pubBody = -// "\168\142\FS", _pubProps = [PropResponseInformation "\208/+\158\144\255\SYN\SO\243Inw",PropTopicAliasMaximum -// 18437,PropTopicAliasMaximum 1104,PropSessionExpiryInterval 27902,PropServerReference -// "\134\174\231\235\232\CAN\178\130\CAN\216f\166 \145\172\141",PropTopicAliasMaximum 8918,PropMessageExpiryInterval -// 27657,PropAuthenticationMethod "\196'\\-",PropContentType -// "\150\\\188\244\131\167\193\136\DC4\CANB\v",PropSessionExpiryInterval 7240,PropAuthenticationMethod -// "\155\v:@\NAK\193\248M*",PropRetainAvailable 253,PropContentType -// "\NUL\252knZ\139JD\239\242%.\144\DC2\185\132R\f\244?",PropAssignedClientIdentifier -// "\209G\149\221\188\138*\FS\ACKu\181\161z\208\169\197\RS\250`r\213\168\237\&4H\174\245",PropReasonString -// "\238q\162m\237\204\214\246[\SI\DC3\151\142k\140\&8 a\SI\GS",PropSharedSubscriptionAvailable 1,PropTopicAliasMaximum -// 3287,PropMessageExpiryInterval 7895,PropRequestResponseInformation 238,PropRequestResponseInformation -// 247,PropRequestProblemInformation 76,PropCorrelationData -// "\194\211\165\148fO\208\198\167Xk\134w\255U`\169\EOT\133I\179u\241\ETXx\254",PropWillDelayInterval -// 20602,PropMessageExpiryInterval 24630,PropContentType -// "2\248\130\228\STX\203\237\146\161\153\250z\160H",PropMaximumPacketSize 18994,PropReasonString -// "\140-\216\252\240u\246\234\213\233y\253\167\196\223:\151"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\165,\215\220S\205E\205\200\222\229\249\ESC\148", _pubPktID = 15507, _pubBody = "pR:\130:", _pubProps = +// [PropRequestProblemInformation 19,PropMessageExpiryInterval 20770,PropAuthenticationData +// "\174\254\r\157h\203\190\209",PropCorrelationData +// "l\128}bI\137\160\185\v\169\253\161l;\215\232\241\134I\204)\158\241\166\207\190\216"]} TEST(Publish5QCTest, Decode5) { - uint8_t pkt[] = { - 0x34, 0x94, 0x2, 0x0, 0x0, 0x1e, 0x87, 0x8b, 0x2, 0x1a, 0x0, 0xc, 0xd0, 0x2f, 0x2b, 0x9e, 0x90, 0xff, 0x16, - 0xe, 0xf3, 0x49, 0x6e, 0x77, 0x22, 0x48, 0x5, 0x22, 0x4, 0x50, 0x11, 0x0, 0x0, 0x6c, 0xfe, 0x1c, 0x0, 0x10, - 0x86, 0xae, 0xe7, 0xeb, 0xe8, 0x18, 0xb2, 0x82, 0x18, 0xd8, 0x66, 0xa6, 0x20, 0x91, 0xac, 0x8d, 0x22, 0x22, 0xd6, - 0x2, 0x0, 0x0, 0x6c, 0x9, 0x15, 0x0, 0x4, 0xc4, 0x27, 0x5c, 0x2d, 0x3, 0x0, 0xc, 0x96, 0x5c, 0xbc, 0xf4, - 0x83, 0xa7, 0xc1, 0x88, 0x14, 0x18, 0x42, 0xb, 0x11, 0x0, 0x0, 0x1c, 0x48, 0x15, 0x0, 0x9, 0x9b, 0xb, 0x3a, - 0x40, 0x15, 0xc1, 0xf8, 0x4d, 0x2a, 0x25, 0xfd, 0x3, 0x0, 0x14, 0x0, 0xfc, 0x6b, 0x6e, 0x5a, 0x8b, 0x4a, 0x44, - 0xef, 0xf2, 0x25, 0x2e, 0x90, 0x12, 0xb9, 0x84, 0x52, 0xc, 0xf4, 0x3f, 0x12, 0x0, 0x1b, 0xd1, 0x47, 0x95, 0xdd, - 0xbc, 0x8a, 0x2a, 0x1c, 0x6, 0x75, 0xb5, 0xa1, 0x7a, 0xd0, 0xa9, 0xc5, 0x1e, 0xfa, 0x60, 0x72, 0xd5, 0xa8, 0xed, - 0x34, 0x48, 0xae, 0xf5, 0x1f, 0x0, 0x14, 0xee, 0x71, 0xa2, 0x6d, 0xed, 0xcc, 0xd6, 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, 0x52, 0x3a, 0x82, 0x3a}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa8, 0x8e, 0x1c}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, 0xf9, 0x1b, 0x94}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x70, 0x52, 0x3a, 0x82, 0x3a}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 7815); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(packet_id, 15507); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\174\208\231e\229\225\201\ENQS\217\DEL\146\214\ENQ\145", _pubPktID = 25416, _pubBody = -// "\151\234\215\234\133\219\164\174\221\&1\EOTCs\212\"\141`\135\243\236q}6", _pubProps = [PropSubscriptionIdentifier -// 25,PropTopicAlias 29625,PropSubscriptionIdentifier 0,PropSharedSubscriptionAvailable 209,PropServerReference -// "\vG\165\&1\148\EM.\205\130\USV\158\132\251\187",PropMaximumQoS 91,PropRequestResponseInformation 123,PropTopicAlias -// 17527,PropServerReference -// "T\226\150\184\232\235\133\234\223\158\137\DLE\142\\\225\134\223\209\252\FSn\204]\177\249",PropMessageExpiryInterval -// 987,PropMaximumQoS 227,PropMaximumQoS 97,PropRetainAvailable 25,PropResponseInformation -// "\221\233[\240\SYN\187\242~\196\STX\136\165\198\&5(topic.data), 15); - EXPECT_EQ(msg.payload_len, 23); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "=\178\242\158\145\238\151\166;*4)", -// _pubPktID = 0, _pubBody = "s\252\179R\CANz\233E\191\b\150\SYN\142G\217\188\190\148z\234#\250\177\240\254m\219\SOH", -// _pubProps = [PropRequestProblemInformation 201,PropServerKeepAlive 21147,PropTopicAlias -// 25249,PropMessageExpiryInterval 11702,PropReceiveMaximum 5760,PropMessageExpiryInterval 638,PropAuthenticationData -// "\147\157\151\rj:\\\132\228^\228",PropAuthenticationMethod -// "\136\193\v0%\ESC\167\153_\US\238G\SOH\239\214\227\&4\132\221\181\177\162?\\",PropWildcardSubscriptionAvailable -// 210,PropCorrelationData "\FS\v\214",PropAuthenticationData "\214>?=\242{L\234h\ENQx \165v|\148\"v\173x\215\230 -// \249VF\142h}X",PropResponseTopic "\211\169\238n",PropSubscriptionIdentifier 24,PropServerKeepAlive -// 32603,PropMessageExpiryInterval 25708,PropRequestResponseInformation 57,PropResponseInformation -// "n\204\214\143\194\223\149(to\129",PropAuthenticationData -// "+\141q\161\DC1\228\160C\191[vZ:\212\137\150\190[\SUBv\204\&6d\f?y\am",PropMessageExpiryInterval 15130]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\207)#\195\178f\ESC\134K\157xAj\210\148\138\207\185", _pubPktID = 17568, _pubBody = "\171Y", _pubProps = +// [PropContentType "\134v\226Zj2\ACK.=\141{\196[\239hp\169*\142 |\USd\171\171}=\239",PropSubscriptionIdentifier +// 3,PropAuthenticationMethod +// "\252\190ys\195\US\192Z\175\170\191\192'\232C\202j\DELn\211\134\US\251*",PropMessageExpiryInterval +// 16252,PropSubscriptionIdentifier 5,PropTopicAlias 6022,PropReceiveMaximum 5386,PropTopicAliasMaximum +// 19404,PropPayloadFormatIndicator 143,PropWillDelayInterval 21874,PropContentType +// "\nrf\140\224\128\207\223\US\161\NULF",PropMaximumPacketSize 31744,PropMessageExpiryInterval +// 24715,PropMessageExpiryInterval 16233,PropReceiveMaximum 11567,PropRetainAvailable +// 143,PropWildcardSubscriptionAvailable 146]} TEST(Publish5QCTest, Encode7) { - uint8_t pkt[] = {0x30, 0xd8, 0x1, 0x0, 0xc, 0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, 0x29, - 0xac, 0x1, 0x17, 0xc9, 0x13, 0x52, 0x9b, 0x23, 0x62, 0xa1, 0x2, 0x0, 0x0, 0x2d, 0xb6, 0x21, 0x16, - 0x80, 0x2, 0x0, 0x0, 0x2, 0x7e, 0x16, 0x0, 0xb, 0x93, 0x9d, 0x97, 0xd, 0x6a, 0x3a, 0x5c, 0x84, - 0xe4, 0x5e, 0xe4, 0x15, 0x0, 0x18, 0x88, 0xc1, 0xb, 0x30, 0x25, 0x1b, 0xa7, 0x99, 0x5f, 0x1f, 0xee, - 0x47, 0x1, 0xef, 0xd6, 0xe3, 0x34, 0x84, 0xdd, 0xb5, 0xb1, 0xa2, 0x3f, 0x5c, 0x28, 0xd2, 0x9, 0x0, - 0x3, 0x1c, 0xb, 0xd6, 0x16, 0x0, 0x1e, 0xd6, 0x3e, 0x3f, 0x3d, 0xf2, 0x7b, 0x4c, 0xea, 0x68, 0x5, - 0x78, 0x20, 0xa5, 0x76, 0x7c, 0x94, 0x22, 0x76, 0xad, 0x78, 0xd7, 0xe6, 0x20, 0xf9, 0x56, 0x46, 0x8e, - 0x68, 0x7d, 0x58, 0x8, 0x0, 0x4, 0xd3, 0xa9, 0xee, 0x6e, 0xb, 0x18, 0x13, 0x7f, 0x5b, 0x2, 0x0, - 0x0, 0x64, 0x6c, 0x19, 0x39, 0x1a, 0x0, 0xb, 0x6e, 0xcc, 0xd6, 0x8f, 0xc2, 0xdf, 0x95, 0x28, 0x74, - 0x6f, 0x81, 0x16, 0x0, 0x1c, 0x2b, 0x8d, 0x71, 0xa1, 0x11, 0xe4, 0xa0, 0x43, 0xbf, 0x5b, 0x76, 0x5a, - 0x3a, 0xd4, 0x89, 0x96, 0xbe, 0x5b, 0x1a, 0x76, 0xcc, 0x36, 0x64, 0xc, 0x3f, 0x79, 0x7, 0x6d, 0x2, - 0x0, 0x0, 0x3b, 0x1a, 0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, - 0x47, 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; - uint8_t topic_bytes[] = {0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, 0x29}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x91, 0x1, 0x0, 0x12, 0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, 0x9d, 0x78, 0x41, + 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9, 0x44, 0xa0, 0x78, 0x3, 0x0, 0x1c, 0x86, 0x76, 0xe2, 0x5a, 0x6a, + 0x32, 0x6, 0x2e, 0x3d, 0x8d, 0x7b, 0xc4, 0x5b, 0xef, 0x68, 0x70, 0xa9, 0x2a, 0x8e, 0x20, 0x7c, 0x1f, + 0x64, 0xab, 0xab, 0x7d, 0x3d, 0xef, 0xb, 0x3, 0x15, 0x0, 0x18, 0xfc, 0xbe, 0x79, 0x73, 0xc3, 0x1f, + 0xc0, 0x5a, 0xaf, 0xaa, 0xbf, 0xc0, 0x27, 0xe8, 0x43, 0xca, 0x6a, 0x7f, 0x6e, 0xd3, 0x86, 0x1f, 0xfb, + 0x2a, 0x2, 0x0, 0x0, 0x3f, 0x7c, 0xb, 0x5, 0x23, 0x17, 0x86, 0x21, 0x15, 0xa, 0x22, 0x4b, 0xcc, + 0x1, 0x8f, 0x18, 0x0, 0x0, 0x55, 0x72, 0x3, 0x0, 0xc, 0xa, 0x72, 0x66, 0x8c, 0xe0, 0x80, 0xcf, + 0xdf, 0x1f, 0xa1, 0x0, 0x46, 0x27, 0x0, 0x0, 0x7c, 0x0, 0x2, 0x0, 0x0, 0x60, 0x8b, 0x2, 0x0, + 0x0, 0x3f, 0x69, 0x21, 0x2d, 0x2f, 0x25, 0x8f, 0x28, 0x92, 0xab, 0x59}; + uint8_t topic_bytes[] = {0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, + 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, - 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xab, 0x59}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 2; - uint8_t bytesprops0[] = {0x93, 0x9d, 0x97, 0xd, 0x6a, 0x3a, 0x5c, 0x84, 0xe4, 0x5e, 0xe4}; - uint8_t bytesprops1[] = {0x88, 0xc1, 0xb, 0x30, 0x25, 0x1b, 0xa7, 0x99, 0x5f, 0x1f, 0xee, 0x47, - 0x1, 0xef, 0xd6, 0xe3, 0x34, 0x84, 0xdd, 0xb5, 0xb1, 0xa2, 0x3f, 0x5c}; - uint8_t bytesprops2[] = {0x1c, 0xb, 0xd6}; - uint8_t bytesprops3[] = {0xd6, 0x3e, 0x3f, 0x3d, 0xf2, 0x7b, 0x4c, 0xea, 0x68, 0x5, 0x78, 0x20, 0xa5, 0x76, 0x7c, - 0x94, 0x22, 0x76, 0xad, 0x78, 0xd7, 0xe6, 0x20, 0xf9, 0x56, 0x46, 0x8e, 0x68, 0x7d, 0x58}; - uint8_t bytesprops4[] = {0xd3, 0xa9, 0xee, 0x6e}; - uint8_t bytesprops5[] = {0x6e, 0xcc, 0xd6, 0x8f, 0xc2, 0xdf, 0x95, 0x28, 0x74, 0x6f, 0x81}; - uint8_t bytesprops6[] = {0x2b, 0x8d, 0x71, 0xa1, 0x11, 0xe4, 0xa0, 0x43, 0xbf, 0x5b, 0x76, 0x5a, 0x3a, 0xd4, - 0x89, 0x96, 0xbe, 0x5b, 0x1a, 0x76, 0xcc, 0x36, 0x64, 0xc, 0x3f, 0x79, 0x7, 0x6d}; + uint8_t bytesprops0[] = {0x86, 0x76, 0xe2, 0x5a, 0x6a, 0x32, 0x6, 0x2e, 0x3d, 0x8d, 0x7b, 0xc4, 0x5b, 0xef, + 0x68, 0x70, 0xa9, 0x2a, 0x8e, 0x20, 0x7c, 0x1f, 0x64, 0xab, 0xab, 0x7d, 0x3d, 0xef}; + uint8_t bytesprops1[] = {0xfc, 0xbe, 0x79, 0x73, 0xc3, 0x1f, 0xc0, 0x5a, 0xaf, 0xaa, 0xbf, 0xc0, + 0x27, 0xe8, 0x43, 0xca, 0x6a, 0x7f, 0x6e, 0xd3, 0x86, 0x1f, 0xfb, 0x2a}; + uint8_t bytesprops2[] = {0xa, 0x72, 0x66, 0x8c, 0xe0, 0x80, 0xcf, 0xdf, 0x1f, 0xa1, 0x0, 0x46}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21147}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25249}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11702}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5760}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 638}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32603}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25708}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15130}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16252}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6022}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5386}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19404}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21874}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31744}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24715}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16233}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11567}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 146}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17568, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "=\178\242\158\145\238\151\166;*4)", -// _pubPktID = 0, _pubBody = "s\252\179R\CANz\233E\191\b\150\SYN\142G\217\188\190\148z\234#\250\177\240\254m\219\SOH", -// _pubProps = [PropRequestProblemInformation 201,PropServerKeepAlive 21147,PropTopicAlias -// 25249,PropMessageExpiryInterval 11702,PropReceiveMaximum 5760,PropMessageExpiryInterval 638,PropAuthenticationData -// "\147\157\151\rj:\\\132\228^\228",PropAuthenticationMethod -// "\136\193\v0%\ESC\167\153_\US\238G\SOH\239\214\227\&4\132\221\181\177\162?\\",PropWildcardSubscriptionAvailable -// 210,PropCorrelationData "\FS\v\214",PropAuthenticationData "\214>?=\242{L\234h\ENQx \165v|\148\"v\173x\215\230 -// \249VF\142h}X",PropResponseTopic "\211\169\238n",PropSubscriptionIdentifier 24,PropServerKeepAlive -// 32603,PropMessageExpiryInterval 25708,PropRequestResponseInformation 57,PropResponseInformation -// "n\204\214\143\194\223\149(to\129",PropAuthenticationData -// "+\141q\161\DC1\228\160C\191[vZ:\212\137\150\190[\SUBv\204\&6d\f?y\am",PropMessageExpiryInterval 15130]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\207)#\195\178f\ESC\134K\157xAj\210\148\138\207\185", _pubPktID = 17568, _pubBody = "\171Y", _pubProps = +// [PropContentType "\134v\226Zj2\ACK.=\141{\196[\239hp\169*\142 |\USd\171\171}=\239",PropSubscriptionIdentifier +// 3,PropAuthenticationMethod +// "\252\190ys\195\US\192Z\175\170\191\192'\232C\202j\DELn\211\134\US\251*",PropMessageExpiryInterval +// 16252,PropSubscriptionIdentifier 5,PropTopicAlias 6022,PropReceiveMaximum 5386,PropTopicAliasMaximum +// 19404,PropPayloadFormatIndicator 143,PropWillDelayInterval 21874,PropContentType +// "\nrf\140\224\128\207\223\US\161\NULF",PropMaximumPacketSize 31744,PropMessageExpiryInterval +// 24715,PropMessageExpiryInterval 16233,PropReceiveMaximum 11567,PropRetainAvailable +// 143,PropWildcardSubscriptionAvailable 146]} TEST(Publish5QCTest, Decode7) { - uint8_t pkt[] = {0x30, 0xd8, 0x1, 0x0, 0xc, 0x3d, 0xb2, 0xf2, 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0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, - 0x47, 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; + uint8_t pkt[] = {0x33, 0x91, 0x1, 0x0, 0x12, 0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, 0x9d, 0x78, 0x41, + 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9, 0x44, 0xa0, 0x78, 0x3, 0x0, 0x1c, 0x86, 0x76, 0xe2, 0x5a, 0x6a, + 0x32, 0x6, 0x2e, 0x3d, 0x8d, 0x7b, 0xc4, 0x5b, 0xef, 0x68, 0x70, 0xa9, 0x2a, 0x8e, 0x20, 0x7c, 0x1f, + 0x64, 0xab, 0xab, 0x7d, 0x3d, 0xef, 0xb, 0x3, 0x15, 0x0, 0x18, 0xfc, 0xbe, 0x79, 0x73, 0xc3, 0x1f, + 0xc0, 0x5a, 0xaf, 0xaa, 0xbf, 0xc0, 0x27, 0xe8, 0x43, 0xca, 0x6a, 0x7f, 0x6e, 0xd3, 0x86, 0x1f, 0xfb, + 0x2a, 0x2, 0x0, 0x0, 0x3f, 0x7c, 0xb, 0x5, 0x23, 0x17, 0x86, 0x21, 0x15, 0xa, 0x22, 0x4b, 0xcc, + 0x1, 0x8f, 0x18, 0x0, 0x0, 0x55, 0x72, 0x3, 0x0, 0xc, 0xa, 0x72, 0x66, 0x8c, 0xe0, 0x80, 0xcf, + 0xdf, 0x1f, 0xa1, 0x0, 0x46, 0x27, 0x0, 0x0, 0x7c, 0x0, 0x2, 0x0, 0x0, 0x60, 0x8b, 0x2, 0x0, + 0x0, 0x3f, 0x69, 0x21, 0x2d, 0x2f, 0x25, 0x8f, 0x28, 0x92, 0xab, 0x59}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3d, 0xb2, 0xf2, 0x9e, 0x91, 0xee, 0x97, 0xa6, 0x3b, 0x2a, 0x34, 0x29}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x73, 0xfc, 0xb3, 0x52, 0x18, 0x7a, 0xe9, 0x45, 0xbf, 0x8, 0x96, 0x16, 0x8e, 0x47, - 0xd9, 0xbc, 0xbe, 0x94, 0x7a, 0xea, 0x23, 0xfa, 0xb1, 0xf0, 0xfe, 0x6d, 0xdb, 0x1}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, + 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xab, 0x59}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 17568); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\148\\\SUBg||N\DC41_\225\t\200Db_\163g\147\140\150]\254\216", _pubPktID = 0, _pubBody = "\130", _pubProps = -// [PropRequestProblemInformation 232]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(9fA\NAK\140\194;\215\236\145\SO\240#\ESC", _pubPktID = 5686, _pubBody = +// "\197\149\245\GS\f\206T\209\&7\232c\143\164A\177\DC3\r<.\ACK", _pubProps = [PropSessionExpiryInterval +// 21595,PropSharedSubscriptionAvailable 6,PropServerReference +// "\154\134\&1\208y,\EOT\249\185\232\141\SYN^\132\158\254",PropReasonString +// "\218+\v\ETX~\212\acFLU\138\235",PropSubscriptionIdentifierAvailable 103,PropResponseInformation +// "B\247\fNU\170\&6U\141\DLEm\154\237y +// \201;\a\223i\163\169\176\FS\v\232\128\227\128\245",PropRequestResponseInformation 199,PropRequestResponseInformation +// 107,PropReceiveMaximum 19809,PropSubscriptionIdentifier 1,PropTopicAliasMaximum 552,PropReasonString +// "\212\137\tdr!\CAN\242=\136n\133\133\187\194\t\v\FSZ\203\130ll\188ue~\a\190",PropServerKeepAlive +// 9635,PropSharedSubscriptionAvailable 177,PropResponseInformation "",PropServerReference +// "\170\142\ETXA\234\237^\EOT\231V^\146\177W",PropResponseInformation "\SI",PropAuthenticationMethod +// "\140[\SYN\167\198\134y\167\156@4\193\&5",PropCorrelationData +// "\172\188\161\192=\EM\138\EMk\ETXy+\187\133\252?V\226\195T\231U\188\158n",PropSubscriptionIdentifier +// 0,PropSubscriptionIdentifierAvailable 143,PropTopicAlias 27154,PropResponseInformation +// "]?\146.\133d0\ETB~T\173\208\&6-\GS\139\204\222\152\139\SI",PropTopicAlias 11738,PropPayloadFormatIndicator +// 141,PropMessageExpiryInterval 387,PropMaximumQoS 113,PropServerReference +// "\196\229i\152\\u\\\184",PropResponseInformation "z~\184\148\230H^\186A\229\\\SUB\DEL\168\216\150"]} TEST(Publish5QCTest, Encode8) { - uint8_t pkt[] = {0x30, 0x1e, 0x0, 0x18, 0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, - 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8, 0x2, 0x17, 0xe8, 0x82}; - uint8_t topic_bytes[] = {0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, - 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x32, 0xb4, 0x2, 0x0, 0xf, 0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, + 0x1b, 0x16, 0x36, 0x8b, 0x2, 0x11, 0x0, 0x0, 0x54, 0x5b, 0x2a, 0x6, 0x1c, 0x0, 0x10, 0x9a, 0x86, 0x31, 0xd0, + 0x79, 0x2c, 0x4, 0xf9, 0xb9, 0xe8, 0x8d, 0x16, 0x5e, 0x84, 0x9e, 0xfe, 0x1f, 0x0, 0xd, 0xda, 0x2b, 0xb, 0x3, + 0x7e, 0xd4, 0x7, 0x63, 0x46, 0x4c, 0x55, 0x8a, 0xeb, 0x29, 0x67, 0x1a, 0x0, 0x1e, 0x42, 0xf7, 0xc, 0x4e, 0x55, + 0xaa, 0x36, 0x55, 0x8d, 0x10, 0x6d, 0x9a, 0xed, 0x79, 0x20, 0xc9, 0x3b, 0x7, 0xdf, 0x69, 0xa3, 0xa9, 0xb0, 0x1c, + 0xb, 0xe8, 0x80, 0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5, + 0x5c, 0x1a, 0x7f, 0xa8, 0xd8, 0x96, 0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, 0xd1, 0x37, 0xe8, 0x63, 0x8f, 0xa4, + 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; + uint8_t topic_bytes[] = {0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, 0x1b}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x82}; + uint8_t msg_bytes[] = {0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, 0xd1, 0x37, 0xe8, + 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 20; + + uint8_t bytesprops0[] = {0x9a, 0x86, 0x31, 0xd0, 0x79, 0x2c, 0x4, 0xf9, + 0xb9, 0xe8, 0x8d, 0x16, 0x5e, 0x84, 0x9e, 0xfe}; + uint8_t bytesprops1[] = {0xda, 0x2b, 0xb, 0x3, 0x7e, 0xd4, 0x7, 0x63, 0x46, 0x4c, 0x55, 0x8a, 0xeb}; + uint8_t bytesprops2[] = {0x42, 0xf7, 0xc, 0x4e, 0x55, 0xaa, 0x36, 0x55, 0x8d, 0x10, 0x6d, 0x9a, 0xed, 0x79, 0x20, + 0xc9, 0x3b, 0x7, 0xdf, 0x69, 0xa3, 0xa9, 0xb0, 0x1c, 0xb, 0xe8, 0x80, 0xe3, 0x80, 0xf5}; + uint8_t bytesprops3[] = {0xd4, 0x89, 0x9, 0x64, 0x72, 0x21, 0x18, 0xf2, 0x3d, 0x88, 0x6e, 0x85, 0x85, 0xbb, 0xc2, + 0x9, 0xb, 0x1c, 0x5a, 0xcb, 0x82, 0x6c, 0x6c, 0xbc, 0x75, 0x65, 0x7e, 0x7, 0xbe}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0xaa, 0x8e, 0x3, 0x41, 0xea, 0xed, 0x5e, 0x4, 0xe7, 0x56, 0x5e, 0x92, 0xb1, 0x57}; + uint8_t bytesprops6[] = {0xf}; + uint8_t bytesprops7[] = {0x8c, 0x5b, 0x16, 0xa7, 0xc6, 0x86, 0x79, 0xa7, 0x9c, 0x40, 0x34, 0xc1, 0x35}; + uint8_t bytesprops8[] = {0xac, 0xbc, 0xa1, 0xc0, 0x3d, 0x19, 0x8a, 0x19, 0x6b, 0x3, 0x79, 0x2b, 0xbb, + 0x85, 0xfc, 0x3f, 0x56, 0xe2, 0xc3, 0x54, 0xe7, 0x55, 0xbc, 0x9e, 0x6e}; + uint8_t bytesprops9[] = {0x5d, 0x3f, 0x92, 0x2e, 0x85, 0x64, 0x30, 0x17, 0x7e, 0x54, 0xad, + 0xd0, 0x36, 0x2d, 0x1d, 0x8b, 0xcc, 0xde, 0x98, 0x8b, 0xf}; + uint8_t bytesprops10[] = {0xc4, 0xe5, 0x69, 0x98, 0x5c, 0x75, 0x5c, 0xb8}; + uint8_t bytesprops11[] = {0x7a, 0x7e, 0xb8, 0x94, 0xe6, 0x48, 0x5e, 0xba, + 0x41, 0xe5, 0x5c, 0x1a, 0x7f, 0xa8, 0xd8, 0x96}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21595}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19809}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 552}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9635}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27154}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11738}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 387}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 5686, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\148\\\SUBg||N\DC41_\225\t\200Db_\163g\147\140\150]\254\216", _pubPktID = 0, _pubBody = "\130", _pubProps = -// [PropRequestProblemInformation 232]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(9fA\NAK\140\194;\215\236\145\SO\240#\ESC", _pubPktID = 5686, _pubBody = +// "\197\149\245\GS\f\206T\209\&7\232c\143\164A\177\DC3\r<.\ACK", _pubProps = [PropSessionExpiryInterval +// 21595,PropSharedSubscriptionAvailable 6,PropServerReference +// "\154\134\&1\208y,\EOT\249\185\232\141\SYN^\132\158\254",PropReasonString +// "\218+\v\ETX~\212\acFLU\138\235",PropSubscriptionIdentifierAvailable 103,PropResponseInformation +// "B\247\fNU\170\&6U\141\DLEm\154\237y +// \201;\a\223i\163\169\176\FS\v\232\128\227\128\245",PropRequestResponseInformation 199,PropRequestResponseInformation +// 107,PropReceiveMaximum 19809,PropSubscriptionIdentifier 1,PropTopicAliasMaximum 552,PropReasonString +// "\212\137\tdr!\CAN\242=\136n\133\133\187\194\t\v\FSZ\203\130ll\188ue~\a\190",PropServerKeepAlive +// 9635,PropSharedSubscriptionAvailable 177,PropResponseInformation "",PropServerReference +// "\170\142\ETXA\234\237^\EOT\231V^\146\177W",PropResponseInformation "\SI",PropAuthenticationMethod +// "\140[\SYN\167\198\134y\167\156@4\193\&5",PropCorrelationData +// "\172\188\161\192=\EM\138\EMk\ETXy+\187\133\252?V\226\195T\231U\188\158n",PropSubscriptionIdentifier +// 0,PropSubscriptionIdentifierAvailable 143,PropTopicAlias 27154,PropResponseInformation +// "]?\146.\133d0\ETB~T\173\208\&6-\GS\139\204\222\152\139\SI",PropTopicAlias 11738,PropPayloadFormatIndicator +// 141,PropMessageExpiryInterval 387,PropMaximumQoS 113,PropServerReference +// "\196\229i\152\\u\\\184",PropResponseInformation "z~\184\148\230H^\186A\229\\\SUB\DEL\168\216\150"]} TEST(Publish5QCTest, Decode8) { - uint8_t pkt[] = {0x30, 0x1e, 0x0, 0x18, 0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, - 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8, 0x2, 0x17, 0xe8, 0x82}; + uint8_t pkt[] = { + 0x32, 0xb4, 0x2, 0x0, 0xf, 0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, + 0x1b, 0x16, 0x36, 0x8b, 0x2, 0x11, 0x0, 0x0, 0x54, 0x5b, 0x2a, 0x6, 0x1c, 0x0, 0x10, 0x9a, 0x86, 0x31, 0xd0, + 0x79, 0x2c, 0x4, 0xf9, 0xb9, 0xe8, 0x8d, 0x16, 0x5e, 0x84, 0x9e, 0xfe, 0x1f, 0x0, 0xd, 0xda, 0x2b, 0xb, 0x3, + 0x7e, 0xd4, 0x7, 0x63, 0x46, 0x4c, 0x55, 0x8a, 0xeb, 0x29, 0x67, 0x1a, 0x0, 0x1e, 0x42, 0xf7, 0xc, 0x4e, 0x55, + 0xaa, 0x36, 0x55, 0x8d, 0x10, 0x6d, 0x9a, 0xed, 0x79, 0x20, 0xc9, 0x3b, 0x7, 0xdf, 0x69, 0xa3, 0xa9, 0xb0, 0x1c, + 0xb, 0xe8, 0x80, 0xe3, 0x80, 0xf5, 0x19, 0xc7, 0x19, 0x6b, 0x21, 0x4d, 0x61, 0xb, 0x1, 0x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 0xce, 0x54, 0xd1, 0x37, 0xe8, 0x63, 0x8f, 0xa4, + 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x94, 0x5c, 0x1a, 0x67, 0x7c, 0x7c, 0x4e, 0x14, 0x31, 0x5f, 0xe1, 0x9, - 0xc8, 0x44, 0x62, 0x5f, 0xa3, 0x67, 0x93, 0x8c, 0x96, 0x5d, 0xfe, 0xd8}; - lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x82}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, 0x1b}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, 0xd1, 0x37, 0xe8, + 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(packet_id, 5686); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\167a*\t\248\248\176\&7", _pubPktID -// = 3229, _pubBody = "q\NUL\185\ACK\181\209\244d\DC1\207\251\203\230\128\DC1A(\215\169\248\224\136EM\156.\EOT\f", -// _pubProps = [PropUserProperty "\171\178\180\177L\237\232\133" -// "\160\195\DLE\252\209\152\141p\DC2e\DC1\219\169",PropPayloadFormatIndicator 186,PropServerKeepAlive -// 22704,PropContentType "=\160\248h\156\&2\SOH\176S\176\145\NUL",PropUserProperty -// ":\ENQs\245\&6\252%}\133P!\201\213\155\179\215" -// "\162i\190\175\233]`\SOM,hBP\137\225\141\SUB\179)\180\229\183\154\233>\201\SYN\178",PropAssignedClientIdentifier -// "\153AI\128\142\&7\DC1\SIF]\189a\177\DC2\144{S\239)\240h\219\189\196\200\&4\238l",PropServerReference -// "\166\149\f_[\161\240\254\249\222\225\&2\EOT3\228+\140\144\218,\148\224\157h\181\248\207\213",PropTopicAlias -// 32605,PropTopicAliasMaximum 9453,PropResponseTopic -// "$\197\180\139\138\130\157\168PBR4\211\STXy\229\147\&9\253%\227\189\177\192",PropSubscriptionIdentifierAvailable -// 137,PropMessageExpiryInterval 31937,PropResponseInformation "\b",PropAssignedClientIdentifier -// "\196JG}\164\236Z\\\175\158o\160\169",PropWildcardSubscriptionAvailable 98,PropRequestResponseInformation -// 49,PropRequestProblemInformation 110]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\234\227\201xQ\221\GS\f\US\208(\t\212", _pubPktID = 0, _pubBody = +// "\140\174]d\t\144\158\DC2\237\196\202\147\133\154\231\176|1", _pubProps = [PropMessageExpiryInterval +// 14546,PropMessageExpiryInterval 14300,PropReasonString "\183j\173Z\222K",PropTopicAlias 24083,PropResponseInformation +// "\SO\161\227\DLE\141\173\DC4\149)\247\154\US\225L\231Y\195",PropTopicAlias 22040,PropRetainAvailable +// 145,PropUserProperty "8\169\225\228\231lk&\152\211" "\246)J\EOT\192F\210\254\223\253\210\141{R",PropCorrelationData " +// y\228\130\229i\164(p\134\186Uf\ENQ\144\191\171e",PropWillDelayInterval 26330,PropRequestResponseInformation +// 227,PropContentType ".0\SOH\SUB\249\250E\165\181\168\196\146Z\197\210H^N\218\&8\255\167",PropResponseTopic +// "\nG\189\167h[\246\161\194\227x\138\136L\156",PropSessionExpiryInterval 25383,PropAssignedClientIdentifier +// "@\168\149\DC1\ACK\v\220\169\221\168\241\209#*Yf\161\173\153\198\173\189\198\179",PropServerKeepAlive +// 7700,PropTopicAliasMaximum 24476,PropTopicAliasMaximum 11573,PropResponseInformation +// ":\ETX\US\246g\DLE\130\NUL#\171\138\210\ENQ\177\a\224m\130",PropUserProperty "\216A\239s\t\172\&7\156?" +// "\167\160\165\CAN\ENQ\212\&5(\138\245\DC2V'\184\203\RS\244\164\162\221\GSM\128k",PropResponseTopic +// "\150&\189F\170",PropServerKeepAlive 31478,PropAuthenticationData +// "\244:HY\215;\144\133\187\168\178&}%",PropAssignedClientIdentifier +// "\"\242N\178\b6\216NL\143\154",PropRequestResponseInformation 88]} TEST(Publish5QCTest, Encode9) { - uint8_t pkt[] = {0x3c, 0x89, 0x2, 0x0, 0x8, 0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37, 0xc, 0x9d, 0xdf, 0x1, - 0x26, 0x0, 0x8, 0xab, 0xb2, 0xb4, 0xb1, 0x4c, 0xed, 0xe8, 0x85, 0x0, 0xd, 0xa0, 0xc3, 0x10, 0xfc, - 0xd1, 0x98, 0x8d, 0x70, 0x12, 0x65, 0x11, 0xdb,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xec, 0x5a, 0x5c, 0xaf, 0x9e, 0x6f, 0xa0, 0xa9, 0x28, 0x62, 0x19, 0x31, - 0x17, 0x6e, 0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, 0x11, - 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; - uint8_t topic_bytes[] = {0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x38, 0xc6, 0x2, 0x0, 0xd, 0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, 0x1f, 0xd0, 0x28, 0x9, 0xd4, 0xa3, + 0x2, 0x2, 0x0, 0x0, 0x38, 0xd2, 0x2, 0x0, 0x0, 0x37, 0xdc, 0x1f, 0x0, 0x6, 0xb7, 0x6a, 0xad, 0x5a, 0xde, + 0x4b, 0x23, 0x5e, 0x13, 0x1a, 0x0, 0x11, 0xe, 0xa1, 0xe3, 0x10, 0x8d, 0xad, 0x14, 0x95, 0x29, 0xf7, 0x9a, 0x1f, + 0xe1, 0x4c, 0xe7, 0x59, 0xc3, 0x23, 0x56, 0x18, 0x25, 0x91, 0x26, 0x0, 0xa, 0x38, 0xa9, 0xe1, 0xe4, 0xe7, 0x6c, + 0x6b, 0x26, 0x98, 0xd3, 0x0, 0xe, 0xf6, 0x29, 0x4a, 0x4, 0xc0, 0x46, 0xd2, 0xfe, 0xdf, 0xfd, 0xd2, 0x8d, 0x7b, + 0x52, 0x9, 0x0, 0x12, 0x20, 0x79, 0xe4, 0x82, 0xe5, 0x69, 0xa4, 0x28, 0x70, 0x86, 0xba, 0x55, 0x66, 0x5, 0x90, + 0xbf, 0xab, 0x65, 0x18, 0x0, 0x0, 0x66, 0xda, 0x19, 0xe3, 0x3, 0x0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, 0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, 0xc4, 0xca, 0x93, + 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; + uint8_t topic_bytes[] = {0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, 0x1f, 0xd0, 0x28, 0x9, 0xd4}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, - 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; + uint8_t msg_bytes[] = {0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, + 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 18; - uint8_t bytesprops1[] = {0xa0, 0xc3, 0x10, 0xfc, 0xd1, 0x98, 0x8d, 0x70, 0x12, 0x65, 0x11, 0xdb, 0xa9}; - uint8_t bytesprops0[] = {0xab, 0xb2, 0xb4, 0xb1, 0x4c, 0xed, 0xe8, 0x85}; - uint8_t bytesprops2[] = {0x3d, 0xa0, 0xf8, 0x68, 0x9c, 0x32, 0x1, 0xb0, 0x53, 0xb0, 0x91, 0x0}; - uint8_t bytesprops4[] = {0xa2, 0x69, 0xbe, 0xaf, 0xe9, 0x5d, 0x60, 0xe, 0x4d, 0x2c, 0x68, 0x42, 0x50, 0x89, - 0xe1, 0x8d, 0x1a, 0xb3, 0x29, 0xb4, 0xe5, 0xb7, 0x9a, 0xe9, 0x3e, 0xc9, 0x16, 0xb2}; - uint8_t bytesprops3[] = {0x3a, 0x5, 0x73, 0xf5, 0x36, 0xfc, 0x25, 0x7d, - 0x85, 0x50, 0x21, 0xc9, 0xd5, 0x9b, 0xb3, 0xd7}; - uint8_t bytesprops5[] = {0x99, 0x41, 0x49, 0x80, 0x8e, 0x37, 0x11, 0xf, 0x46, 0x5d, 0xbd, 0x61, 0xb1, 0x12, - 0x90, 0x7b, 0x53, 0xef, 0x29, 0xf0, 0x68, 0xdb, 0xbd, 0xc4, 0xc8, 0x34, 0xee, 0x6c}; - uint8_t bytesprops6[] = {0xa6, 0x95, 0xc, 0x5f, 0x5b, 0xa1, 0xf0, 0xfe, 0xf9, 0xde, 0xe1, 0x32, 0x4, 0x33, - 0xe4, 0x2b, 0x8c, 0x90, 0xda, 0x2c, 0x94, 0xe0, 0x9d, 0x68, 0xb5, 0xf8, 0xcf, 0xd5}; - uint8_t bytesprops7[] = {0x24, 0xc5, 0xb4, 0x8b, 0x8a, 0x82, 0x9d, 0xa8, 0x50, 0x42, 0x52, 0x34, - 0xd3, 0x2, 0x79, 0xe5, 0x93, 0x39, 0xfd, 0x25, 0xe3, 0xbd, 0xb1, 0xc0}; - uint8_t bytesprops8[] = {0x8}; - uint8_t bytesprops9[] = {0xc4, 0x4a, 0x47, 0x7d, 0xa4, 0xec, 0x5a, 0x5c, 0xaf, 0x9e, 0x6f, 0xa0, 0xa9}; + uint8_t bytesprops0[] = {0xb7, 0x6a, 0xad, 0x5a, 0xde, 0x4b}; + uint8_t bytesprops1[] = {0xe, 0xa1, 0xe3, 0x10, 0x8d, 0xad, 0x14, 0x95, 0x29, + 0xf7, 0x9a, 0x1f, 0xe1, 0x4c, 0xe7, 0x59, 0xc3}; + uint8_t bytesprops3[] = {0xf6, 0x29, 0x4a, 0x4, 0xc0, 0x46, 0xd2, 0xfe, 0xdf, 0xfd, 0xd2, 0x8d, 0x7b, 0x52}; + uint8_t bytesprops2[] = {0x38, 0xa9, 0xe1, 0xe4, 0xe7, 0x6c, 0x6b, 0x26, 0x98, 0xd3}; + uint8_t bytesprops4[] = {0x20, 0x79, 0xe4, 0x82, 0xe5, 0x69, 0xa4, 0x28, 0x70, + 0x86, 0xba, 0x55, 0x66, 0x5, 0x90, 0xbf, 0xab, 0x65}; + uint8_t bytesprops5[] = {0x2e, 0x30, 0x1, 0x1a, 0xf9, 0xfa, 0x45, 0xa5, 0xb5, 0xa8, 0xc4, + 0x92, 0x5a, 0xc5, 0xd2, 0x48, 0x5e, 0x4e, 0xda, 0x38, 0xff, 0xa7}; + uint8_t bytesprops6[] = {0xa, 0x47, 0xbd, 0xa7, 0x68, 0x5b, 0xf6, 0xa1, 0xc2, 0xe3, 0x78, 0x8a, 0x88, 0x4c, 0x9c}; + uint8_t bytesprops7[] = {0x40, 0xa8, 0x95, 0x11, 0x6, 0xb, 0xdc, 0xa9, 0xdd, 0xa8, 0xf1, 0xd1, + 0x23, 0x2a, 0x59, 0x66, 0xa1, 0xad, 0x99, 0xc6, 0xad, 0xbd, 0xc6, 0xb3}; + uint8_t bytesprops8[] = {0x3a, 0x3, 0x1f, 0xf6, 0x67, 0x10, 0x82, 0x0, 0x23, + 0xab, 0x8a, 0xd2, 0x5, 0xb1, 0x7, 0xe0, 0x6d, 0x82}; + uint8_t bytesprops10[] = {0xa7, 0xa0, 0xa5, 0x18, 0x5, 0xd4, 0x35, 0x28, 0x8a, 0xf5, 0x12, 0x56, + 0x27, 0xb8, 0xcb, 0x1e, 0xf4, 0xa4, 0xa2, 0xdd, 0x1d, 0x4d, 0x80, 0x6b}; + uint8_t bytesprops9[] = {0xd8, 0x41, 0xef, 0x73, 0x9, 0xac, 0x37, 0x9c, 0x3f}; + uint8_t bytesprops11[] = {0x96, 0x26, 0xbd, 0x46, 0xaa}; + uint8_t bytesprops12[] = {0xf4, 0x3a, 0x48, 0x59, 0xd7, 0x3b, 0x90, 0x85, 0xbb, 0xa8, 0xb2, 0x26, 0x7d, 0x25}; + uint8_t bytesprops13[] = {0x22, 0xf2, 0x4e, 0xb2, 0x8, 0x36, 0xd8, 0x4e, 0x4c, 0x8f, 0x9a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22704}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32605}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9453}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31937}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14546}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14300}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24083}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22040}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {14, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26330}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25383}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7700}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24476}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11573}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops9}, .v = {24, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31478}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 88}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 3229, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\167a*\t\248\248\176\&7", _pubPktID -// = 3229, _pubBody = "q\NUL\185\ACK\181\209\244d\DC1\207\251\203\230\128\DC1A(\215\169\248\224\136EM\156.\EOT\f", -// _pubProps = [PropUserProperty "\171\178\180\177L\237\232\133" -// "\160\195\DLE\252\209\152\141p\DC2e\DC1\219\169",PropPayloadFormatIndicator 186,PropServerKeepAlive -// 22704,PropContentType "=\160\248h\156\&2\SOH\176S\176\145\NUL",PropUserProperty -// ":\ENQs\245\&6\252%}\133P!\201\213\155\179\215" -// "\162i\190\175\233]`\SOM,hBP\137\225\141\SUB\179)\180\229\183\154\233>\201\SYN\178",PropAssignedClientIdentifier -// "\153AI\128\142\&7\DC1\SIF]\189a\177\DC2\144{S\239)\240h\219\189\196\200\&4\238l",PropServerReference -// "\166\149\f_[\161\240\254\249\222\225\&2\EOT3\228+\140\144\218,\148\224\157h\181\248\207\213",PropTopicAlias -// 32605,PropTopicAliasMaximum 9453,PropResponseTopic -// "$\197\180\139\138\130\157\168PBR4\211\STXy\229\147\&9\253%\227\189\177\192",PropSubscriptionIdentifierAvailable -// 137,PropMessageExpiryInterval 31937,PropResponseInformation "\b",PropAssignedClientIdentifier -// "\196JG}\164\236Z\\\175\158o\160\169",PropWildcardSubscriptionAvailable 98,PropRequestResponseInformation -// 49,PropRequestProblemInformation 110]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\234\227\201xQ\221\GS\f\US\208(\t\212", _pubPktID = 0, _pubBody = +// "\140\174]d\t\144\158\DC2\237\196\202\147\133\154\231\176|1", _pubProps = [PropMessageExpiryInterval +// 14546,PropMessageExpiryInterval 14300,PropReasonString "\183j\173Z\222K",PropTopicAlias 24083,PropResponseInformation +// "\SO\161\227\DLE\141\173\DC4\149)\247\154\US\225L\231Y\195",PropTopicAlias 22040,PropRetainAvailable +// 145,PropUserProperty "8\169\225\228\231lk&\152\211" "\246)J\EOT\192F\210\254\223\253\210\141{R",PropCorrelationData " +// y\228\130\229i\164(p\134\186Uf\ENQ\144\191\171e",PropWillDelayInterval 26330,PropRequestResponseInformation +// 227,PropContentType ".0\SOH\SUB\249\250E\165\181\168\196\146Z\197\210H^N\218\&8\255\167",PropResponseTopic +// "\nG\189\167h[\246\161\194\227x\138\136L\156",PropSessionExpiryInterval 25383,PropAssignedClientIdentifier +// "@\168\149\DC1\ACK\v\220\169\221\168\241\209#*Yf\161\173\153\198\173\189\198\179",PropServerKeepAlive +// 7700,PropTopicAliasMaximum 24476,PropTopicAliasMaximum 11573,PropResponseInformation +// ":\ETX\US\246g\DLE\130\NUL#\171\138\210\ENQ\177\a\224m\130",PropUserProperty "\216A\239s\t\172\&7\156?" +// "\167\160\165\CAN\ENQ\212\&5(\138\245\DC2V'\184\203\RS\244\164\162\221\GSM\128k",PropResponseTopic +// "\150&\189F\170",PropServerKeepAlive 31478,PropAuthenticationData +// "\244:HY\215;\144\133\187\168\178&}%",PropAssignedClientIdentifier +// "\"\242N\178\b6\216NL\143\154",PropRequestResponseInformation 88]} TEST(Publish5QCTest, Decode9) { - uint8_t pkt[] = {0x3c, 0x89, 0x2, 0x0, 0x8, 0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37, 0xc, 0x9d, 0xdf, 0x1, - 0x26, 0x0, 0x8, 0xab, 0xb2, 0xb4, 0xb1, 0x4c, 0xed, 0xe8, 0x85, 0x0, 0xd, 0xa0, 0xc3, 0x10, 0xfc, - 0xd1, 0x98, 0x8d, 0x70, 0x12, 0x65, 0x11, 0xdb, 0xa9, 0x1, 0xba, 0x13, 0x58, 0xb0, 0x3, 0x0, 0xc, - 0x3d, 0xa0, 0xf8, 0x68, 0x9c, 0x32, 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 0x5b, 0xf6, 0xa1, 0xc2, 0xe3, 0x78, 0x8a, 0x88, 0x4c, 0x9c, 0x11, 0x0, 0x0, 0x63, + 0x27, 0x12, 0x0, 0x18, 0x40, 0xa8, 0x95, 0x11, 0x6, 0xb, 0xdc, 0xa9, 0xdd, 0xa8, 0xf1, 0xd1, 0x23, 0x2a, 0x59, + 0x66, 0xa1, 0xad, 0x99, 0xc6, 0xad, 0xbd, 0xc6, 0xb3, 0x13, 0x1e, 0x14, 0x22, 0x5f, 0x9c, 0x22, 0x2d, 0x35, 0x1a, + 0x0, 0x12, 0x3a, 0x3, 0x1f, 0xf6, 0x67, 0x10, 0x82, 0x0, 0x23, 0xab, 0x8a, 0xd2, 0x5, 0xb1, 0x7, 0xe0, 0x6d, + 0x82, 0x26, 0x0, 0x9, 0xd8, 0x41, 0xef, 0x73, 0x9, 0xac, 0x37, 0x9c, 0x3f, 0x0, 0x18, 0xa7, 0xa0, 0xa5, 0x18, + 0x5, 0xd4, 0x35, 0x28, 0x8a, 0xf5, 0x12, 0x56, 0x27, 0xb8, 0xcb, 0x1e, 0xf4, 0xa4, 0xa2, 0xdd, 0x1d, 0x4d, 0x80, + 0x6b, 0x8, 0x0, 0x5, 0x96, 0x26, 0xbd, 0x46, 0xaa, 0x13, 0x7a, 0xf6, 0x16, 0x0, 0xe, 0xf4, 0x3a, 0x48, 0x59, + 0xd7, 0x3b, 0x90, 0x85, 0xbb, 0xa8, 0xb2, 0x26, 0x7d, 0x25, 0x12, 0x0, 0xb, 0x22, 0xf2, 0x4e, 0xb2, 0x8, 0x36, + 0xd8, 0x4e, 0x4c, 0x8f, 0x9a, 0x19, 0x58, 0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, 0xc4, 0xca, 0x93, + 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa7, 0x61, 0x2a, 0x9, 0xf8, 0xf8, 0xb0, 0x37}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x71, 0x0, 0xb9, 0x6, 0xb5, 0xd1, 0xf4, 0x64, 0x11, 0xcf, 0xfb, 0xcb, 0xe6, 0x80, - 0x11, 0x41, 0x28, 0xd7, 0xa9, 0xf8, 0xe0, 0x88, 0x45, 0x4d, 0x9c, 0x2e, 0x4, 0xc}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, 0x1f, 0xd0, 0x28, 0x9, 0xd4}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, + 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 3229); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[Q\172\216\185:|\162\194", _pubPktID -// = 10305, _pubBody = "\238\134", _pubProps = [PropReceiveMaximum 10817,PropReceiveMaximum -// 24022,PropMessageExpiryInterval 23639,PropUserProperty "H\173\DC3" "\225\CAN|w\147\168K\247(} -// \132\196\t^L",PropMessageExpiryInterval 16643,PropWildcardSubscriptionAvailable 163,PropWillDelayInterval -// 22770,PropUserProperty "m1A\161\&5e\159-\215\178" -// "<\206L{\DEL\177M^m\142S\SYN\200\&2\158\DC2:\242",PropWillDelayInterval 28106,PropWildcardSubscriptionAvailable -// 221,PropTopicAliasMaximum 13801,PropSubscriptionIdentifier 11,PropWillDelayInterval 19944,PropMaximumQoS -// 186,PropWillDelayInterval 5955,PropSessionExpiryInterval 6777,PropSessionExpiryInterval 22897,PropTopicAlias -// 6180,PropRetainAvailable 93,PropResponseTopic -// "\177\232\138\239\152\219;\164\229C\151'\224\&7\251\199\204R/\SO\nu\142\158\SI\DC1%\231",PropSessionExpiryInterval -// 22932,PropUserProperty "\191p" "\195\DC2\240Y\184\ENQ\150\163\180\173\217\198\ACKa\149N\252\\/\v\170\218 -// ,\206\166",PropSharedSubscriptionAvailable 241,PropContentType "",PropReceiveMaximum 8513,PropRetainAvailable 77]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\SYNr\142QB1\171\213)1\210q\199\"\203\225\251\233[&p\202\238", _pubPktID = 17787, _pubBody = +// "\172\FS\186\216A\244\EOT^<\NAK\136\187\235\ESC\245\209\128", _pubProps = [PropResponseTopic +// "\130\&8\141\184\169\181_\254\142]",PropRetainAvailable 44,PropReasonString +// "q1\241U\133\181\218\238h\GS\156\202\198\194\201\&8\165oH\150t~\201\171\CAN",PropPayloadFormatIndicator +// 21,PropMessageExpiryInterval 32507,PropRetainAvailable 215,PropReceiveMaximum 5188,PropRequestProblemInformation +// 160,PropResponseTopic "\150u1+\204\230m\145\172\230\243\246\EOTuB\US",PropWildcardSubscriptionAvailable +// 2,PropServerReference "\145\\\206+\172\143;\192",PropContentType "\ETB\225\142{\aEn\ACK",PropMessageExpiryInterval +// 19133,PropRequestResponseInformation 0,PropRequestProblemInformation 49,PropAssignedClientIdentifier +// "b\206\190\f\EM\SO\232\FS[\173\189_\201m\220",PropRequestResponseInformation 131]} TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = {0x3b, 0xd7, 0x1, 0x0, 0x9, 0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2, 0x28, 0x41, 0xc6, - 0x1, 0x21, 0x2a, 0x41, 0x21, 0x5d, 0xd6, 0x2, 0x0, 0x0, 0x5c, 0x57, 0x26, 0x0, 0x3, 0x48, 0xad, - 0x13, 0x0, 0x10, 0xe1, 0x18, 0x7c, 0x77, 0x93, 0xa8, 0x4b, 0xf7, 0x28, 0x7d, 0x20, 0x84, 0xc4, 0x9, - 0x5e, 0x4c, 0x2, 0x0, 0x0, 0x41, 0x3, 0x28, 0xa3, 0x18, 0x0, 0x0, 0x58, 0xf2, 0x26, 0x0, 0xa, - 0x6d, 0x31, 0x41, 0xa1, 0x35, 0x65, 0x9f, 0x2d, 0xd7, 0xb2, 0x0, 0x12, 0x3c, 0xce, 0x4c, 0x7b, 0x7f, - 0xb1, 0x4d, 0x5e, 0x6d, 0x8e, 0x53, 0x16, 0xc8, 0x32, 0x9e, 0x12, 0x3a, 0xf2, 0x18, 0x0, 0x0, 0x6d, - 0xca, 0x28, 0xdd, 0x22, 0x35, 0xe9, 0xb, 0xb, 0x18, 0x0, 0x0, 0x4d, 0xe8, 0x24, 0xba, 0x18, 0x0, - 0x0, 0x17, 0x43, 0x11, 0x0, 0x0, 0x1a, 0x79, 0x11, 0x0, 0x0, 0x59, 0x71, 0x23, 0x18, 0x24, 0x25, - 0x5d, 0x8, 0x0, 0x1c, 0xb1, 0xe8, 0x8a, 0xef, 0x98, 0xdb, 0x3b, 0xa4, 0xe5, 0x43, 0x97, 0x27, 0xe0, - 0x37, 0xfb, 0xc7, 0xcc, 0x52, 0x2f, 0xe, 0xa, 0x75, 0x8e, 0x9e, 0xf, 0x11, 0x25, 0xe7, 0x11, 0x0, - 0x0, 0x59, 0x94, 0x26, 0x0, 0x2, 0xbf, 0x70, 0x0, 0x1a, 0xc3, 0x12, 0xf0, 0x59, 0xb8, 0x5, 0x96, - 0xa3, 0xb4, 0xad, 0xd9, 0xc6, 0x6, 0x61, 0x95, 0x4e, 0xfc, 0x5c, 0x2f, 0xb, 0xaa, 0xda, 0x20, 0x2c, - 0xce, 0xa6, 0x2a, 0xf1, 0x3, 0x0, 0x0, 0x21, 0x21, 0x41, 0x25, 0x4d, 0xee, 0x86}; - uint8_t topic_bytes[] = {0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0xaf, 0x1, 0x0, 0x17, 0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, + 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee, 0x45, 0x7b, 0x81, 0x1, 0x8, 0x0, + 0xa, 0x82, 0x38, 0x8d, 0xb8, 0xa9, 0xb5, 0x5f, 0xfe, 0x8e, 0x5d, 0x25, 0x2c, 0x1f, 0x0, 0x19, 0x71, + 0x31, 0xf1, 0x55, 0x85, 0xb5, 0xda, 0xee, 0x68, 0x1d, 0x9c, 0xca, 0xc6, 0xc2, 0xc9, 0x38, 0xa5, 0x6f, + 0x48, 0x96, 0x74, 0x7e, 0xc9, 0xab, 0x18, 0x1, 0x15, 0x2, 0x0, 0x0, 0x7e, 0xfb, 0x25, 0xd7, 0x21, + 0x14, 0x44, 0x17, 0xa0, 0x8, 0x0, 0x10, 0x96, 0x75, 0x31, 0x2b, 0xcc, 0xe6, 0x6d, 0x91, 0xac, 0xe6, + 0xf3, 0xf6, 0x4, 0x75, 0x42, 0x1f, 0x28, 0x2, 0x1c, 0x0, 0x8, 0x91, 0x5c, 0xce, 0x2b, 0xac, 0x8f, + 0x3b, 0xc0, 0x3, 0x0, 0x8, 0x17, 0xe1, 0x8e, 0x7b, 0x7, 0x45, 0x6e, 0x6, 0x2, 0x0, 0x0, 0x4a, + 0xbd, 0x19, 0x0, 0x17, 0x31, 0x12, 0x0, 0xf, 0x62, 0xce, 0xbe, 0xc, 0x19, 0xe, 0xe8, 0x1c, 0x5b, + 0xad, 0xbd, 0x5f, 0xc9, 0x6d, 0xdc, 0x19, 0x83, 0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, + 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; + uint8_t topic_bytes[] = {0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, + 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xee, 0x86}; + msg.retained = false; + uint8_t msg_bytes[] = {0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, + 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 17; - uint8_t bytesprops1[] = {0xe1, 0x18, 0x7c, 0x77, 0x93, 0xa8, 0x4b, 0xf7, - 0x28, 0x7d, 0x20, 0x84, 0xc4, 0x9, 0x5e, 0x4c}; - uint8_t bytesprops0[] = {0x48, 0xad, 0x13}; - uint8_t bytesprops3[] = {0x3c, 0xce, 0x4c, 0x7b, 0x7f, 0xb1, 0x4d, 0x5e, 0x6d, - 0x8e, 0x53, 0x16, 0xc8, 0x32, 0x9e, 0x12, 0x3a, 0xf2}; - uint8_t bytesprops2[] = {0x6d, 0x31, 0x41, 0xa1, 0x35, 0x65, 0x9f, 0x2d, 0xd7, 0xb2}; - uint8_t bytesprops4[] = {0xb1, 0xe8, 0x8a, 0xef, 0x98, 0xdb, 0x3b, 0xa4, 0xe5, 0x43, 0x97, 0x27, 0xe0, 0x37, - 0xfb, 0xc7, 0xcc, 0x52, 0x2f, 0xe, 0xa, 0x75, 0x8e, 0x9e, 0xf, 0x11, 0x25, 0xe7}; - uint8_t bytesprops6[] = {0xc3, 0x12, 0xf0, 0x59, 0xb8, 0x5, 0x96, 0xa3, 0xb4, 0xad, 0xd9, 0xc6, 0x6, - 0x61, 0x95, 0x4e, 0xfc, 0x5c, 0x2f, 0xb, 0xaa, 0xda, 0x20, 0x2c, 0xce, 0xa6}; - uint8_t bytesprops5[] = {0xbf, 0x70}; - uint8_t bytesprops7[] = {0}; + uint8_t bytesprops0[] = {0x82, 0x38, 0x8d, 0xb8, 0xa9, 0xb5, 0x5f, 0xfe, 0x8e, 0x5d}; + uint8_t bytesprops1[] = {0x71, 0x31, 0xf1, 0x55, 0x85, 0xb5, 0xda, 0xee, 0x68, 0x1d, 0x9c, 0xca, 0xc6, + 0xc2, 0xc9, 0x38, 0xa5, 0x6f, 0x48, 0x96, 0x74, 0x7e, 0xc9, 0xab, 0x18}; + uint8_t bytesprops2[] = {0x96, 0x75, 0x31, 0x2b, 0xcc, 0xe6, 0x6d, 0x91, + 0xac, 0xe6, 0xf3, 0xf6, 0x4, 0x75, 0x42, 0x1f}; + uint8_t bytesprops3[] = {0x91, 0x5c, 0xce, 0x2b, 0xac, 0x8f, 0x3b, 0xc0}; + uint8_t bytesprops4[] = {0x17, 0xe1, 0x8e, 0x7b, 0x7, 0x45, 0x6e, 0x6}; + uint8_t bytesprops5[] = {0x62, 0xce, 0xbe, 0xc, 0x19, 0xe, 0xe8, 0x1c, 0x5b, 0xad, 0xbd, 0x5f, 0xc9, 0x6d, 0xdc}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10817}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24022}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23639}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16643}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22770}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {18, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28106}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13801}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19944}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5955}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6777}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22897}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6180}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22932}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops5}, .v = {26, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8513}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32507}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5188}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19133}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 131}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10305, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17787, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[Q\172\216\185:|\162\194", _pubPktID -// = 10305, _pubBody = "\238\134", _pubProps = [PropReceiveMaximum 10817,PropReceiveMaximum -// 24022,PropMessageExpiryInterval 23639,PropUserProperty "H\173\DC3" "\225\CAN|w\147\168K\247(} -// \132\196\t^L",PropMessageExpiryInterval 16643,PropWildcardSubscriptionAvailable 163,PropWillDelayInterval -// 22770,PropUserProperty "m1A\161\&5e\159-\215\178" -// "<\206L{\DEL\177M^m\142S\SYN\200\&2\158\DC2:\242",PropWillDelayInterval 28106,PropWildcardSubscriptionAvailable -// 221,PropTopicAliasMaximum 13801,PropSubscriptionIdentifier 11,PropWillDelayInterval 19944,PropMaximumQoS -// 186,PropWillDelayInterval 5955,PropSessionExpiryInterval 6777,PropSessionExpiryInterval 22897,PropTopicAlias -// 6180,PropRetainAvailable 93,PropResponseTopic -// "\177\232\138\239\152\219;\164\229C\151'\224\&7\251\199\204R/\SO\nu\142\158\SI\DC1%\231",PropSessionExpiryInterval -// 22932,PropUserProperty "\191p" "\195\DC2\240Y\184\ENQ\150\163\180\173\217\198\ACKa\149N\252\\/\v\170\218 -// ,\206\166",PropSharedSubscriptionAvailable 241,PropContentType "",PropReceiveMaximum 8513,PropRetainAvailable 77]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\SYNr\142QB1\171\213)1\210q\199\"\203\225\251\233[&p\202\238", _pubPktID = 17787, _pubBody = +// "\172\FS\186\216A\244\EOT^<\NAK\136\187\235\ESC\245\209\128", _pubProps = [PropResponseTopic +// "\130\&8\141\184\169\181_\254\142]",PropRetainAvailable 44,PropReasonString +// "q1\241U\133\181\218\238h\GS\156\202\198\194\201\&8\165oH\150t~\201\171\CAN",PropPayloadFormatIndicator +// 21,PropMessageExpiryInterval 32507,PropRetainAvailable 215,PropReceiveMaximum 5188,PropRequestProblemInformation +// 160,PropResponseTopic "\150u1+\204\230m\145\172\230\243\246\EOTuB\US",PropWildcardSubscriptionAvailable +// 2,PropServerReference "\145\\\206+\172\143;\192",PropContentType "\ETB\225\142{\aEn\ACK",PropMessageExpiryInterval +// 19133,PropRequestResponseInformation 0,PropRequestProblemInformation 49,PropAssignedClientIdentifier +// "b\206\190\f\EM\SO\232\FS[\173\189_\201m\220",PropRequestResponseInformation 131]} TEST(Publish5QCTest, Decode10) { - uint8_t pkt[] = {0x3b, 0xd7, 0x1, 0x0, 0x9, 0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2, 0x28, 0x41, 0xc6, - 0x1, 0x21, 0x2a, 0x41, 0x21, 0x5d, 0xd6, 0x2, 0x0, 0x0, 0x5c, 0x57, 0x26, 0x0, 0x3, 0x48, 0xad, - 0x13, 0x0, 0x10, 0xe1, 0x18, 0x7c, 0x77, 0x93, 0xa8, 0x4b, 0xf7, 0x28, 0x7d, 0x20, 0x84, 0xc4, 0x9, - 0x5e, 0x4c, 0x2, 0x0, 0x0, 0x41, 0x3, 0x28, 0xa3, 0x18, 0x0, 0x0, 0x58, 0xf2, 0x26, 0x0, 0xa, - 0x6d, 0x31, 0x41, 0xa1, 0x35, 0x65, 0x9f, 0x2d, 0xd7, 0xb2, 0x0, 0x12, 0x3c, 0xce, 0x4c, 0x7b, 0x7f, - 0xb1, 0x4d, 0x5e, 0x6d, 0x8e, 0x53, 0x16, 0xc8, 0x32, 0x9e, 0x12, 0x3a, 0xf2, 0x18, 0x0, 0x0, 0x6d, - 0xca, 0x28, 0xdd, 0x22, 0x35, 0xe9, 0xb, 0xb, 0x18, 0x0, 0x0, 0x4d, 0xe8, 0x24, 0xba, 0x18, 0x0, - 0x0, 0x17, 0x43, 0x11, 0x0, 0x0, 0x1a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75, 0x31, 0x2b, 0xcc, 0xe6, 0x6d, 0x91, 0xac, 0xe6, + 0xf3, 0xf6, 0x4, 0x75, 0x42, 0x1f, 0x28, 0x2, 0x1c, 0x0, 0x8, 0x91, 0x5c, 0xce, 0x2b, 0xac, 0x8f, + 0x3b, 0xc0, 0x3, 0x0, 0x8, 0x17, 0xe1, 0x8e, 0x7b, 0x7, 0x45, 0x6e, 0x6, 0x2, 0x0, 0x0, 0x4a, + 0xbd, 0x19, 0x0, 0x17, 0x31, 0x12, 0x0, 0xf, 0x62, 0xce, 0xbe, 0xc, 0x19, 0xe, 0xe8, 0x1c, 0x5b, + 0xad, 0xbd, 0x5f, 0xc9, 0x6d, 0xdc, 0x19, 0x83, 0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, + 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5b, 0x51, 0xac, 0xd8, 0xb9, 0x3a, 0x7c, 0xa2, 0xc2}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xee, 0x86}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, + 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, + 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 10305); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 17787); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ESC\169\150\136?o\142\230\b", -// _pubPktID = 0, _pubBody = "\203\ENQ\254)\215\158R\255\SOH\SOHM8\245\234\222t\225\187\175", _pubProps = -// [PropSessionExpiryInterval 22238,PropAssignedClientIdentifier -// "\223\149\250\ETB\ETB\143\248\212\164\252\226\221\172\237\180\&1\255\219\198\140\182\224\253\210\b",PropSharedSubscriptionAvailable -// 194,PropContentType "8!",PropPayloadFormatIndicator 206,PropContentType -// "M\176\177\DC2\aN\210\NAK\207c\144\219\EMH[",PropResponseInformation "S",PropReceiveMaximum -// 24749,PropTopicAliasMaximum 10148,PropRetainAvailable 247,PropMaximumQoS 100,PropReceiveMaximum -// 2658,PropPayloadFormatIndicator 72,PropReceiveMaximum 18557,PropWillDelayInterval 16949,PropAssignedClientIdentifier -// "bz\192\140\235\209<\DLE\174\237P\184h",PropSessionExpiryInterval 3362,PropServerReference -// "T\178\147.\154\&4u\178\217\222\DLE\131\132\142a\DC4\224\158\215\224}\SYN\208\175p\203\240\240p'",PropSharedSubscriptionAvailable -// 250,PropTopicAliasMaximum 27083,PropMaximumQoS 140,PropTopicAliasMaximum 17705]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "e", _pubPktID = 29287, _pubBody = +// "o\220=\DLE\237\181\219\FS\ESC%~\198\SYN/{P", _pubProps = [PropContentType "",PropWildcardSubscriptionAvailable +// 8,PropTopicAlias 2941,PropServerReference ">\164*\219\172\189C~\219\a\236X\ESCS\140K\SYN2.",PropAuthenticationData +// "\143\202bO\250Z \196A\"L\218\ESC\235{B"]} TEST(Publish5QCTest, Encode11) { - uint8_t pkt[] = {0x31, 0xb7, 0x1, 0x0, 0x9, 0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8, 0x97, 0x1, 0x11, - 0x0, 0x0, 0x56, 0xde, 0x12, 0x0, 0x19, 0xdf, 0x95, 0xfa, 0x17, 0x17, 0x8f, 0xf8, 0xd4, 0xa4, 0xfc, - 0xe2, 0xdd, 0xac, 0xed, 0xb4, 0x31, 0xff, 0xdb, 0xc6, 0x8c, 0xb6, 0xe0, 0xfd, 0xd2, 0x8, 0x2a, 0xc2, - 0x3, 0x0, 0x2, 0x38, 0x21, 0x1, 0xce, 0x3, 0x0, 0xf, 0x4d, 0xb0, 0xb1, 0x12, 0x7, 0x4e, 0xd2, - 0x15, 0xcf, 0x63, 0x90, 0xdb, 0x19, 0x48, 0x5b, 0x1a, 0x0, 0x1, 0x53, 0x21, 0x60, 0xad, 0x22, 0x27, - 0xa4, 0x25, 0xf7, 0x24, 0x64, 0x21, 0xa, 0x62, 0x1, 0x48, 0x21, 0x48, 0x7d, 0x18, 0x0, 0x0, 0x42, - 0x35, 0x12, 0x0, 0xd, 0x62, 0x7a, 0xc0, 0x8c, 0xeb, 0xd1, 0x3c, 0x10, 0xae, 0xed, 0x50, 0xb8, 0x68, - 0x11, 0x0, 0x0, 0xd, 0x22, 0x1c, 0x0, 0x1e, 0x54, 0xb2, 0x93, 0x2e, 0x9a, 0x34, 0x75, 0xb2, 0xd9, - 0xde, 0x10, 0x83, 0x84, 0x8e, 0x61, 0x14, 0xe0, 0x9e, 0xd7, 0xe0, 0x7d, 0x16, 0xd0, 0xaf, 0x70, 0xcb, - 0xf0, 0xf0, 0x70, 0x27, 0x2a, 0xfa, 0x22, 0x69, 0xcb, 0x24, 0x8c, 0x22, 0x45, 0x29, 0xcb, 0x5, 0xfe, - 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; - uint8_t topic_bytes[] = {0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x47, 0x0, 0x1, 0x65, 0x72, 0x67, 0x31, 0x3, 0x0, 0x0, 0x28, 0x8, 0x23, 0xb, + 0x7d, 0x1c, 0x0, 0x13, 0x3e, 0xa4, 0x2a, 0xdb, 0xac, 0xbd, 0x43, 0x7e, 0xdb, 0x7, 0xec, + 0x58, 0x1b, 0x53, 0x8c, 0x4b, 0x16, 0x32, 0x2e, 0x16, 0x0, 0x10, 0x8f, 0xca, 0x62, 0x4f, + 0xfa, 0x5a, 0x20, 0xc4, 0x41, 0x22, 0x4c, 0xda, 0x1b, 0xeb, 0x7b, 0x42, 0x6f, 0xdc, 0x3d, + 0x10, 0xed, 0xb5, 0xdb, 0x1c, 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; + uint8_t topic_bytes[] = {0x65}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xcb, 0x5, 0xfe, 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, - 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; + uint8_t msg_bytes[] = {0x6f, 0xdc, 0x3d, 0x10, 0xed, 0xb5, 0xdb, 0x1c, + 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 16; - uint8_t bytesprops0[] = {0xdf, 0x95, 0xfa, 0x17, 0x17, 0x8f, 0xf8, 0xd4, 0xa4, 0xfc, 0xe2, 0xdd, 0xac, - 0xed, 0xb4, 0x31, 0xff, 0xdb, 0xc6, 0x8c, 0xb6, 0xe0, 0xfd, 0xd2, 0x8}; - uint8_t bytesprops1[] = {0x38, 0x21}; - uint8_t bytesprops2[] = {0x4d, 0xb0, 0xb1, 0x12, 0x7, 0x4e, 0xd2, 0x15, 0xcf, 0x63, 0x90, 0xdb, 0x19, 0x48, 0x5b}; - uint8_t bytesprops3[] = {0x53}; - uint8_t bytesprops4[] = {0x62, 0x7a, 0xc0, 0x8c, 0xeb, 0xd1, 0x3c, 0x10, 0xae, 0xed, 0x50, 0xb8, 0x68}; - uint8_t bytesprops5[] = {0x54, 0xb2, 0x93, 0x2e, 0x9a, 0x34, 0x75, 0xb2, 0xd9, 0xde, 0x10, 0x83, 0x84, 0x8e, 0x61, - 0x14, 0xe0, 0x9e, 0xd7, 0xe0, 0x7d, 0x16, 0xd0, 0xaf, 0x70, 0xcb, 0xf0, 0xf0, 0x70, 0x27}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x3e, 0xa4, 0x2a, 0xdb, 0xac, 0xbd, 0x43, 0x7e, 0xdb, 0x7, + 0xec, 0x58, 0x1b, 0x53, 0x8c, 0x4b, 0x16, 0x32, 0x2e}; + uint8_t bytesprops2[] = {0x8f, 0xca, 0x62, 0x4f, 0xfa, 0x5a, 0x20, 0xc4, + 0x41, 0x22, 0x4c, 0xda, 0x1b, 0xeb, 0x7b, 0x42}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22238}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24749}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10148}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2658}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18557}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16949}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3362}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27083}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17705}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2941}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29287, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\ESC\169\150\136?o\142\230\b", -// _pubPktID = 0, _pubBody = "\203\ENQ\254)\215\158R\255\SOH\SOHM8\245\234\222t\225\187\175", _pubProps = -// [PropSessionExpiryInterval 22238,PropAssignedClientIdentifier -// "\223\149\250\ETB\ETB\143\248\212\164\252\226\221\172\237\180\&1\255\219\198\140\182\224\253\210\b",PropSharedSubscriptionAvailable -// 194,PropContentType "8!",PropPayloadFormatIndicator 206,PropContentType -// "M\176\177\DC2\aN\210\NAK\207c\144\219\EMH[",PropResponseInformation "S",PropReceiveMaximum -// 24749,PropTopicAliasMaximum 10148,PropRetainAvailable 247,PropMaximumQoS 100,PropReceiveMaximum -// 2658,PropPayloadFormatIndicator 72,PropReceiveMaximum 18557,PropWillDelayInterval 16949,PropAssignedClientIdentifier -// "bz\192\140\235\209<\DLE\174\237P\184h",PropSessionExpiryInterval 3362,PropServerReference -// "T\178\147.\154\&4u\178\217\222\DLE\131\132\142a\DC4\224\158\215\224}\SYN\208\175p\203\240\240p'",PropSharedSubscriptionAvailable -// 250,PropTopicAliasMaximum 27083,PropMaximumQoS 140,PropTopicAliasMaximum 17705]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "e", _pubPktID = 29287, _pubBody = +// "o\220=\DLE\237\181\219\FS\ESC%~\198\SYN/{P", _pubProps = [PropContentType "",PropWildcardSubscriptionAvailable +// 8,PropTopicAlias 2941,PropServerReference ">\164*\219\172\189C~\219\a\236X\ESCS\140K\SYN2.",PropAuthenticationData +// "\143\202bO\250Z \196A\"L\218\ESC\235{B"]} TEST(Publish5QCTest, Decode11) { - uint8_t pkt[] = {0x31, 0xb7, 0x1, 0x0, 0x9, 0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8, 0x97, 0x1, 0x11, - 0x0, 0x0, 0x56, 0xde, 0x12, 0x0, 0x19, 0xdf, 0x95, 0xfa, 0x17, 0x17, 0x8f, 0xf8, 0xd4, 0xa4, 0xfc, - 0xe2, 0xdd, 0xac, 0xed, 0xb4, 0x31, 0xff, 0xdb, 0xc6, 0x8c, 0xb6, 0xe0, 0xfd, 0xd2, 0x8, 0x2a, 0xc2, - 0x3, 0x0, 0x2, 0x38, 0x21, 0x1, 0xce, 0x3, 0x0, 0xf, 0x4d, 0xb0, 0xb1, 0x12, 0x7, 0x4e, 0xd2, - 0x15, 0xcf, 0x63, 0x90, 0xdb, 0x19, 0x48, 0x5b, 0x1a, 0x0, 0x1, 0x53, 0x21, 0x60, 0xad, 0x22, 0x27, - 0xa4, 0x25, 0xf7, 0x24, 0x64, 0x21, 0xa, 0x62, 0x1, 0x48, 0x21, 0x48, 0x7d, 0x18, 0x0, 0x0, 0x42, - 0x35, 0x12, 0x0, 0xd, 0x62, 0x7a, 0xc0, 0x8c, 0xeb, 0xd1, 0x3c, 0x10, 0xae, 0xed, 0x50, 0xb8, 0x68, - 0x11, 0x0, 0x0, 0xd, 0x22, 0x1c, 0x0, 0x1e, 0x54, 0xb2, 0x93, 0x2e, 0x9a, 0x34, 0x75, 0xb2, 0xd9, - 0xde, 0x10, 0x83, 0x84, 0x8e, 0x61, 0x14, 0xe0, 0x9e, 0xd7, 0xe0, 0x7d, 0x16, 0xd0, 0xaf, 0x70, 0xcb, - 0xf0, 0xf0, 0x70, 0x27, 0x2a, 0xfa, 0x22, 0x69, 0xcb, 0x24, 0x8c, 0x22, 0x45, 0x29, 0xcb, 0x5, 0xfe, - 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; + uint8_t pkt[] = {0x33, 0x47, 0x0, 0x1, 0x65, 0x72, 0x67, 0x31, 0x3, 0x0, 0x0, 0x28, 0x8, 0x23, 0xb, + 0x7d, 0x1c, 0x0, 0x13, 0x3e, 0xa4, 0x2a, 0xdb, 0xac, 0xbd, 0x43, 0x7e, 0xdb, 0x7, 0xec, + 0x58, 0x1b, 0x53, 0x8c, 0x4b, 0x16, 0x32, 0x2e, 0x16, 0x0, 0x10, 0x8f, 0xca, 0x62, 0x4f, + 0xfa, 0x5a, 0x20, 0xc4, 0x41, 0x22, 0x4c, 0xda, 0x1b, 0xeb, 0x7b, 0x42, 0x6f, 0xdc, 0x3d, + 0x10, 0xed, 0xb5, 0xdb, 0x1c, 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x1b, 0xa9, 0x96, 0x88, 0x3f, 0x6f, 0x8e, 0xe6, 0x8}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcb, 0x5, 0xfe, 0x29, 0xd7, 0x9e, 0x52, 0xff, 0x1, 0x1, - 0x4d, 0x38, 0xf5, 0xea, 0xde, 0x74, 0xe1, 0xbb, 0xaf}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x65}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x6f, 0xdc, 0x3d, 0x10, 0xed, 0xb5, 0xdb, 0x1c, + 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_EQ(packet_id, 29287); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\186\b\221\f\178D\188&~\248P\ENQ\134\167\n\241\196v\203\245_\206\177\208\SI\FS", _pubPktID = 16783, _pubBody = "", -// _pubProps = [PropServerKeepAlive 27404,PropReceiveMaximum 26000,PropRequestResponseInformation -// 194,PropMessageExpiryInterval 12227,PropMessageExpiryInterval 3446,PropTopicAlias 16275,PropServerReference -// "R\239\GS\FS\185\167(",PropTopicAliasMaximum 32156,PropResponseInformation -// "\DC3\217\133#\ACKa\130>i\191o\US\240\162\EM\EMN\241\&02c\244-\143/\225",PropWillDelayInterval -// 3283,PropRetainAvailable 193,PropServerReference "\b\147\130\231\SI\200&\v.2T\164T\176\186\GS",PropMaximumQoS 109]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\139\194\ETB\145\245\&3\175\131\230\149\231\192\SO", _pubPktID = 2558, _pubBody = +// "3u\151\168\SYN\191\144\230d\rn\148=", _pubProps = [PropReasonString "\254*Y +// \EMKY\147\155\&5\163\211\134\247\160\168%\145",PropRequestResponseInformation 218,PropUserProperty +// "(\197\144\176\252N-g\148\135\185\162g\CAN\136S" "\174\DEL/\130\159\244\217\201\SOHok",PropTopicAlias +// 11573,PropRetainAvailable 179,PropMaximumPacketSize 27929,PropRetainAvailable 251,PropRequestProblemInformation +// 190,PropRetainAvailable 60,PropUserProperty +// "\fH\165\224|\nG\159\223@\195j\220SD\US\128\247\207\164\149\DLE\156\151\185%\168x*\246" +// "\196-\193*\253D\207\136`\221\130\153\184\&9;\198\159g\136\139@\241|\206\158\ETXc",PropCorrelationData +// "V}pM\165\179\228\no\206\US?7\197>8I",PropRequestResponseInformation 251,PropResponseInformation +// "7\233F\220",PropTopicAliasMaximum 26753,PropAuthenticationData +// "\185\215\f@#\SYN\185\ENQx-c\230)\136\SI\134",PropSubscriptionIdentifierAvailable 173,PropPayloadFormatIndicator +// 61,PropSessionExpiryInterval 23833,PropResponseTopic "\ETX?\248'G\FS\ESC\SI\182\185\210n"]} TEST(Publish5QCTest, Encode12) { - uint8_t pkt[] = {0x3a, 0x7a, 0x0, 0x1a, 0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, - 0x86, 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c, 0x41, 0x8f, - 0x5b, 0x13, 0x6b, 0xc, 0x21, 0x65, 0x90, 0x19, 0xc2, 0x2, 0x0, 0x0, 0x2f, 0xc3, 0x2, 0x0, - 0x0, 0xd, 0x76, 0x23, 0x3f, 0x93, 0x1c, 0x0, 0x7, 0x52, 0xef, 0x1d, 0x1c, 0xb9, 0xa7, 0x28, - 0x22, 0x7d, 0x9c, 0x1a, 0x0, 0x1a, 0x13, 0xd9, 0x85, 0x23, 0x6, 0x61, 0x82, 0x3e, 0x69, 0xbf, - 0x6f, 0x1f, 0xf0, 0xa2, 0x19, 0x19, 0x4e, 0xf1, 0x30, 0x32, 0x63, 0xf4, 0x2d, 0x8f, 0x2f, 0xe1, - 0x18, 0x0, 0x0, 0xc, 0xd3, 0x25, 0xc1, 0x1c, 0x0, 0x10, 0x8, 0x93, 0x82, 0xe7, 0xf, 0xc8, - 0x26, 0xb, 0x2e, 0x32, 0x54, 0xa4, 0x54, 0xb0, 0xba, 0x1d, 0x24, 0x6d}; - uint8_t topic_bytes[] = {0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, 0x86, - 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x32, 0xf0, 0x1, 0x0, 0xd, 0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe, 0x9, + 0xfe, 0xd0, 0x1, 0x1f, 0x0, 0x12, 0xfe, 0x2a, 0x59, 0x20, 0x19, 0x4b, 0x59, 0x93, 0x9b, 0x35, 0xa3, 0xd3, 0x86, + 0xf7, 0xa0, 0xa8, 0x25, 0x91, 0x19, 0xda, 0x26, 0x0, 0x10, 0x28, 0xc5, 0x90, 0xb0, 0xfc, 0x4e, 0x2d, 0x67, 0x94, + 0x87, 0xb9, 0xa2, 0x67, 0x18, 0x88, 0x53, 0x0, 0xb, 0xae, 0x7f, 0x2f, 0x82, 0x9f, 0xf4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0, 0xe}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0}; + uint8_t msg_bytes[] = {0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; - - uint8_t bytesprops0[] = {0x52, 0xef, 0x1d, 0x1c, 0xb9, 0xa7, 0x28}; - uint8_t bytesprops1[] = {0x13, 0xd9, 0x85, 0x23, 0x6, 0x61, 0x82, 0x3e, 0x69, 0xbf, 0x6f, 0x1f, 0xf0, - 0xa2, 0x19, 0x19, 0x4e, 0xf1, 0x30, 0x32, 0x63, 0xf4, 0x2d, 0x8f, 0x2f, 0xe1}; - uint8_t bytesprops2[] = {0x8, 0x93, 0x82, 0xe7, 0xf, 0xc8, 0x26, 0xb, 0x2e, 0x32, 0x54, 0xa4, 0x54, 0xb0, 0xba, 0x1d}; + msg.payload_len = 13; + + uint8_t bytesprops0[] = {0xfe, 0x2a, 0x59, 0x20, 0x19, 0x4b, 0x59, 0x93, 0x9b, + 0x35, 0xa3, 0xd3, 0x86, 0xf7, 0xa0, 0xa8, 0x25, 0x91}; + uint8_t bytesprops2[] = {0xae, 0x7f, 0x2f, 0x82, 0x9f, 0xf4, 0xd9, 0xc9, 0x1, 0x6f, 0x6b}; + uint8_t bytesprops1[] = {0x28, 0xc5, 0x90, 0xb0, 0xfc, 0x4e, 0x2d, 0x67, + 0x94, 0x87, 0xb9, 0xa2, 0x67, 0x18, 0x88, 0x53}; + uint8_t bytesprops4[] = {0xc4, 0x2d, 0xc1, 0x2a, 0xfd, 0x44, 0xcf, 0x88, 0x60, 0xdd, 0x82, 0x99, 0xb8, 0x39, + 0x3b, 0xc6, 0x9f, 0x67, 0x88, 0x8b, 0x40, 0xf1, 0x7c, 0xce, 0x9e, 0x3, 0x63}; + uint8_t bytesprops3[] = {0xc, 0x48, 0xa5, 0xe0, 0x7c, 0xa, 0x47, 0x9f, 0xdf, 0x40, 0xc3, 0x6a, 0xdc, 0x53, 0x44, + 0x1f, 0x80, 0xf7, 0xcf, 0xa4, 0x95, 0x10, 0x9c, 0x97, 0xb9, 0x25, 0xa8, 0x78, 0x2a, 0xf6}; + uint8_t bytesprops5[] = {0x56, 0x7d, 0x70, 0x4d, 0xa5, 0xb3, 0xe4, 0xa, 0x6f, + 0xce, 0x1f, 0x3f, 0x37, 0xc5, 0x3e, 0x38, 0x49}; + uint8_t bytesprops6[] = {0x37, 0xe9, 0x46, 0xdc}; + uint8_t bytesprops7[] = {0xb9, 0xd7, 0xc, 0x40, 0x23, 0x16, 0xb9, 0x5, 0x78, 0x2d, 0x63, 0xe6, 0x29, 0x88, 0xf, 0x86}; + uint8_t bytesprops8[] = {0x3, 0x3f, 0xf8, 0x27, 0x47, 0x1c, 0x1b, 0xf, 0xb6, 0xb9, 0xd2, 0x6e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27404}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26000}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12227}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3446}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16275}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32156}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3283}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11573}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27929}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops3}, .v = {27, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26753}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23833}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16783, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 2558, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\186\b\221\f\178D\188&~\248P\ENQ\134\167\n\241\196v\203\245_\206\177\208\SI\FS", _pubPktID = 16783, _pubBody = "", -// _pubProps = [PropServerKeepAlive 27404,PropReceiveMaximum 26000,PropRequestResponseInformation -// 194,PropMessageExpiryInterval 12227,PropMessageExpiryInterval 3446,PropTopicAlias 16275,PropServerReference -// "R\239\GS\FS\185\167(",PropTopicAliasMaximum 32156,PropResponseInformation -// "\DC3\217\133#\ACKa\130>i\191o\US\240\162\EM\EMN\241\&02c\244-\143/\225",PropWillDelayInterval -// 3283,PropRetainAvailable 193,PropServerReference "\b\147\130\231\SI\200&\v.2T\164T\176\186\GS",PropMaximumQoS 109]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\139\194\ETB\145\245\&3\175\131\230\149\231\192\SO", _pubPktID = 2558, _pubBody = +// "3u\151\168\SYN\191\144\230d\rn\148=", _pubProps = [PropReasonString "\254*Y +// \EMKY\147\155\&5\163\211\134\247\160\168%\145",PropRequestResponseInformation 218,PropUserProperty +// "(\197\144\176\252N-g\148\135\185\162g\CAN\136S" "\174\DEL/\130\159\244\217\201\SOHok",PropTopicAlias +// 11573,PropRetainAvailable 179,PropMaximumPacketSize 27929,PropRetainAvailable 251,PropRequestProblemInformation +// 190,PropRetainAvailable 60,PropUserProperty +// "\fH\165\224|\nG\159\223@\195j\220SD\US\128\247\207\164\149\DLE\156\151\185%\168x*\246" +// "\196-\193*\253D\207\136`\221\130\153\184\&9;\198\159g\136\139@\241|\206\158\ETXc",PropCorrelationData +// "V}pM\165\179\228\no\206\US?7\197>8I",PropRequestResponseInformation 251,PropResponseInformation +// "7\233F\220",PropTopicAliasMaximum 26753,PropAuthenticationData +// "\185\215\f@#\SYN\185\ENQx-c\230)\136\SI\134",PropSubscriptionIdentifierAvailable 173,PropPayloadFormatIndicator +// 61,PropSessionExpiryInterval 23833,PropResponseTopic "\ETX?\248'G\FS\ESC\SI\182\185\210n"]} TEST(Publish5QCTest, Decode12) { - uint8_t pkt[] = {0x3a, 0x7a, 0x0, 0x1a, 0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, - 0x86, 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c, 0x41, 0x8f, - 0x5b, 0x13, 0x6b, 0xc, 0x21, 0x65, 0x90, 0x19, 0xc2, 0x2, 0x0, 0x0, 0x2f, 0xc3, 0x2, 0x0, - 0x0, 0xd, 0x76, 0x23, 0x3f, 0x93, 0x1c, 0x0, 0x7, 0x52, 0xef, 0x1d, 0x1c, 0xb9, 0xa7, 0x28, - 0x22, 0x7d, 0x9c, 0x1a, 0x0, 0x1a, 0x13, 0xd9, 0x85, 0x23, 0x6, 0x61, 0x82, 0x3e, 0x69, 0xbf, - 0x6f, 0x1f, 0xf0, 0xa2, 0x19, 0x19, 0x4e, 0xf1, 0x30, 0x32, 0x63, 0xf4, 0x2d, 0x8f, 0x2f, 0xe1, - 0x18, 0x0, 0x0, 0xc, 0xd3, 0x25, 0xc1, 0x1c, 0x0, 0x10, 0x8, 0x93, 0x82, 0xe7, 0xf, 0xc8, - 0x26, 0xb, 0x2e, 0x32, 0x54, 0xa4, 0x54, 0xb0, 0xba, 0x1d, 0x24, 0x6d}; + uint8_t pkt[] = { + 0x32, 0xf0, 0x1, 0x0, 0xd, 0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe, 0x9, + 0xfe, 0xd0, 0x1, 0x1f, 0x0, 0x12, 0xfe, 0x2a, 0x59, 0x20, 0x19, 0x4b, 0x59, 0x93, 0x9b, 0x35, 0xa3,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x47, 0x1c, 0x1b, 0xf, 0xb6, 0xb9, + 0xd2, 0x6e, 0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xba, 0x8, 0xdd, 0xc, 0xb2, 0x44, 0xbc, 0x26, 0x7e, 0xf8, 0x50, 0x5, 0x86, - 0xa7, 0xa, 0xf1, 0xc4, 0x76, 0xcb, 0xf5, 0x5f, 0xce, 0xb1, 0xd0, 0xf, 0x1c}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 16783); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + EXPECT_EQ(packet_id, 2558); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// ";V\193\141}\175x\217i^\231g\247\v\203\183_\151\EM\\", _pubPktID = 0, _pubBody = -// "\162\166\173\187\NAK){\138\210Q^p+\SI\145Q\165\GS\166\249CG", _pubProps = [PropResponseTopic -// "\DC1",PropAssignedClientIdentifier "\241\167*\EM\224*\174z\a\192\192\236_\177G\STX+\224\213/\SI",PropServerReference -// ">\191\&29\210.y\158\162\248b\185\171\255\SUBs\SI\167\243\142\&0@\210\DC1\214\132\SYNl`",PropMessageExpiryInterval -// 19534,PropTopicAliasMaximum 1048,PropCorrelationData -// "\190\248P&\175Y\199\166yC\188\237\252\&7Q2\215d",PropPayloadFormatIndicator 150,PropRequestProblemInformation -// 178,PropWildcardSubscriptionAvailable 154,PropWildcardSubscriptionAvailable 38,PropTopicAlias -// 4361,PropWillDelayInterval 18009,PropMaximumQoS 185,PropAuthenticationMethod -// ",\172\253\251\160\243",PropSessionExpiryInterval 23756]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "$\212", _pubPktID = 1716, _pubBody +// = "\190\141B\DELW\166\237\195J\183\212y\176h", _pubProps = [PropAssignedClientIdentifier +// "\149\128\198\171\US\253\GS\SUB?\180&B59Z'\166,\183/q\138\189\180\237>\206\170",PropReasonString +// "\\\139\DC2vGA-]R1\226\167%u&\250\bSO\207",PropPayloadFormatIndicator 220,PropAuthenticationMethod +// "d\207\238\as\253?>\142\255\204I\241\ETB",PropResponseInformation +// "p\f\222\&3\210\NAKi\139UX\190\192\SUB\245\&4\r;h",PropRequestResponseInformation 157,PropMaximumQoS +// 72,PropWillDelayInterval 24790,PropMessageExpiryInterval 3742,PropReceiveMaximum 23049,PropAuthenticationMethod +// "\189p%\221_\DLE\217u\177\183@\ACK\245\135\DC4\239\202\173\179\182\208V\163\168",PropRequestResponseInformation +// 85,PropSubscriptionIdentifier 0,PropRetainAvailable 38,PropTopicAliasMaximum 8926,PropSharedSubscriptionAvailable +// 17,PropContentType "\USb\156\FS\168\164.\NAK\140\DC2G\DC1N\185\&0\234Z",PropContentType +// "\237\135\132\186m\168\205\"!\215\208\163",PropRequestProblemInformation 174]} TEST(Publish5QCTest, Encode13) { - uint8_t pkt[] = {0x31, 0xa6, 0x1, 0x0, 0x14, 0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, 0xe7, 0x67, - 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c, 0x79, 0x8, 0x0, 0x1, 0x11, 0x12, 0x0, 0x15, 0xf1, - 0xa7, 0x2a, 0x19, 0xe0, 0x2a, 0xae, 0x7a, 0x7, 0xc0, 0xc0, 0xec, 0x5f, 0xb1, 0x47, 0x2, 0x2b, 0xe0, - 0xd5, 0x2f, 0xf, 0x1c, 0x0, 0x1d, 0x3e, 0xbf, 0x32, 0x39, 0xd2, 0x2e, 0x79, 0x9e, 0xa2, 0xf8, 0x62, - 0xb9, 0xab, 0xff, 0x1a, 0x73, 0xf, 0xa7, 0xf3, 0x8e, 0x30, 0x40, 0xd2, 0x11, 0xd6, 0x84, 0x16, 0x6c, - 0x60, 0x2, 0x0, 0x0, 0x4c, 0x4e, 0x22, 0x4, 0x18, 0x9, 0x0, 0x12, 0xbe, 0xf8, 0x50, 0x26, 0xaf, - 0x59, 0xc7, 0xa6, 0x79, 0x43, 0xbc, 0xed, 0xfc, 0x37, 0x51, 0x32, 0xd7, 0x64, 0x1, 0x96, 0x17, 0xb2, - 0x28, 0x9a, 0x28, 0x26, 0x23, 0x11, 0x9, 0x18, 0x0, 0x0, 0x46, 0x59, 0x24, 0xb9, 0x15, 0x0, 0x6, - 0x2c, 0xac, 0xfd, 0xfb, 0xa0, 0xf3, 0x11, 0x0, 0x0, 0x5c, 0xcc, 0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, - 0x7b, 0x8a, 0xd2, 0x51, 0x5e, 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; - uint8_t topic_bytes[] = {0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, - 0xe7, 0x67, 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0xd0, 0x1, 0x0, 0x2, 0x24, 0xd4, 0x6, 0xb4, 0xba, 0x1, 0x12, 0x0, 0x1c, 0x95, 0x80, 0xc6, + 0xab, 0x1f, 0xfd, 0x1d, 0x1a, 0x3f, 0xb4, 0x26, 0x42, 0x35, 0x39, 0x5a, 0x27, 0xa6, 0x2c, 0xb7, 0x2f, + 0x71, 0x8a, 0xbd, 0xb4, 0xed, 0x3e, 0xce, 0xaa, 0x1f, 0x0, 0x14, 0x5c, 0x8b, 0x12, 0x76, 0x47, 0x41, + 0x2d, 0x5d, 0x52, 0x31, 0xe2, 0xa7, 0x25, 0x75, 0x26, 0xfa, 0x8, 0x53, 0x4f, 0xcf, 0x1, 0xdc, 0x15, + 0x0, 0xe, 0x64, 0xcf, 0xee, 0x7, 0x73, 0xfd, 0x3f, 0x3e, 0x8e, 0xff, 0xcc, 0x49, 0xf1, 0x17, 0x1a, + 0x0, 0x12, 0x70, 0xc, 0xde, 0x33, 0xd2, 0x15, 0x69, 0x8b, 0x55, 0x58, 0xbe, 0xc0, 0x1a, 0xf5, 0x34, + 0xd, 0x3b, 0x68, 0x19, 0x9d, 0x24, 0x48, 0x18, 0x0, 0x0, 0x60, 0xd6, 0x2, 0x0, 0x0, 0xe, 0x9e, + 0x21, 0x5a, 0x9, 0x15, 0x0, 0x18, 0xbd, 0x70, 0x25, 0xdd, 0x5f, 0x10, 0xd9, 0x75, 0xb1, 0xb7, 0x40, + 0x6, 0xf5, 0x87, 0x14, 0xef, 0xca, 0xad, 0xb3, 0xb6, 0xd0, 0x56, 0xa3, 0xa8, 0x19, 0x55, 0xb, 0x0, + 0x25, 0x26, 0x22, 0x22, 0xde, 0x2a, 0x11, 0x3, 0x0, 0x11, 0x1f, 0x62, 0x9c, 0x1c, 0xa8, 0xa4, 0x2e, + 0x15, 0x8c, 0x12, 0x47, 0x11, 0x4e, 0xb9, 0x30, 0xea, 0x5a, 0x3, 0x0, 0xc, 0xed, 0x87, 0x84, 0xba, + 0x6d, 0xa8, 0xcd, 0x22, 0x21, 0xd7, 0xd0, 0xa3, 0x17, 0xae, 0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, + 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; + uint8_t topic_bytes[] = {0x24, 0xd4}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, 0xd2, 0x51, 0x5e, - 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 14; - uint8_t bytesprops0[] = {0x11}; - uint8_t bytesprops1[] = {0xf1, 0xa7, 0x2a, 0x19, 0xe0, 0x2a, 0xae, 0x7a, 0x7, 0xc0, 0xc0, - 0xec, 0x5f, 0xb1, 0x47, 0x2, 0x2b, 0xe0, 0xd5, 0x2f, 0xf}; - uint8_t bytesprops2[] = {0x3e, 0xbf, 0x32, 0x39, 0xd2, 0x2e, 0x79, 0x9e, 0xa2, 0xf8, 0x62, 0xb9, 0xab, 0xff, 0x1a, - 0x73, 0xf, 0xa7, 0xf3, 0x8e, 0x30, 0x40, 0xd2, 0x11, 0xd6, 0x84, 0x16, 0x6c, 0x60}; - uint8_t bytesprops3[] = {0xbe, 0xf8, 0x50, 0x26, 0xaf, 0x59, 0xc7, 0xa6, 0x79, - 0x43, 0xbc, 0xed, 0xfc, 0x37, 0x51, 0x32, 0xd7, 0x64}; - uint8_t bytesprops4[] = {0x2c, 0xac, 0xfd, 0xfb, 0xa0, 0xf3}; + uint8_t bytesprops0[] = {0x95, 0x80, 0xc6, 0xab, 0x1f, 0xfd, 0x1d, 0x1a, 0x3f, 0xb4, 0x26, 0x42, 0x35, 0x39, + 0x5a, 0x27, 0xa6, 0x2c, 0xb7, 0x2f, 0x71, 0x8a, 0xbd, 0xb4, 0xed, 0x3e, 0xce, 0xaa}; + uint8_t bytesprops1[] = {0x5c, 0x8b, 0x12, 0x76, 0x47, 0x41, 0x2d, 0x5d, 0x52, 0x31, + 0xe2, 0xa7, 0x25, 0x75, 0x26, 0xfa, 0x8, 0x53, 0x4f, 0xcf}; + uint8_t bytesprops2[] = {0x64, 0xcf, 0xee, 0x7, 0x73, 0xfd, 0x3f, 0x3e, 0x8e, 0xff, 0xcc, 0x49, 0xf1, 0x17}; + uint8_t bytesprops3[] = {0x70, 0xc, 0xde, 0x33, 0xd2, 0x15, 0x69, 0x8b, 0x55, + 0x58, 0xbe, 0xc0, 0x1a, 0xf5, 0x34, 0xd, 0x3b, 0x68}; + uint8_t bytesprops4[] = {0xbd, 0x70, 0x25, 0xdd, 0x5f, 0x10, 0xd9, 0x75, 0xb1, 0xb7, 0x40, 0x6, + 0xf5, 0x87, 0x14, 0xef, 0xca, 0xad, 0xb3, 0xb6, 0xd0, 0x56, 0xa3, 0xa8}; + uint8_t bytesprops5[] = {0x1f, 0x62, 0x9c, 0x1c, 0xa8, 0xa4, 0x2e, 0x15, 0x8c, + 0x12, 0x47, 0x11, 0x4e, 0xb9, 0x30, 0xea, 0x5a}; + uint8_t bytesprops6[] = {0xed, 0x87, 0x84, 0xba, 0x6d, 0xa8, 0xcd, 0x22, 0x21, 0xd7, 0xd0, 0xa3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19534}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1048}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4361}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18009}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23756}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24790}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3742}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23049}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8926}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 174}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1716, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// ";V\193\141}\175x\217i^\231g\247\v\203\183_\151\EM\\", _pubPktID = 0, _pubBody = -// "\162\166\173\187\NAK){\138\210Q^p+\SI\145Q\165\GS\166\249CG", _pubProps = [PropResponseTopic -// "\DC1",PropAssignedClientIdentifier "\241\167*\EM\224*\174z\a\192\192\236_\177G\STX+\224\213/\SI",PropServerReference -// ">\191\&29\210.y\158\162\248b\185\171\255\SUBs\SI\167\243\142\&0@\210\DC1\214\132\SYNl`",PropMessageExpiryInterval -// 19534,PropTopicAliasMaximum 1048,PropCorrelationData -// "\190\248P&\175Y\199\166yC\188\237\252\&7Q2\215d",PropPayloadFormatIndicator 150,PropRequestProblemInformation -// 178,PropWildcardSubscriptionAvailable 154,PropWildcardSubscriptionAvailable 38,PropTopicAlias -// 4361,PropWillDelayInterval 18009,PropMaximumQoS 185,PropAuthenticationMethod -// ",\172\253\251\160\243",PropSessionExpiryInterval 23756]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "$\212", _pubPktID = 1716, _pubBody +// = "\190\141B\DELW\166\237\195J\183\212y\176h", _pubProps = [PropAssignedClientIdentifier +// "\149\128\198\171\US\253\GS\SUB?\180&B59Z'\166,\183/q\138\189\180\237>\206\170",PropReasonString +// "\\\139\DC2vGA-]R1\226\167%u&\250\bSO\207",PropPayloadFormatIndicator 220,PropAuthenticationMethod +// "d\207\238\as\253?>\142\255\204I\241\ETB",PropResponseInformation +// "p\f\222\&3\210\NAKi\139UX\190\192\SUB\245\&4\r;h",PropRequestResponseInformation 157,PropMaximumQoS +// 72,PropWillDelayInterval 24790,PropMessageExpiryInterval 3742,PropReceiveMaximum 23049,PropAuthenticationMethod +// "\189p%\221_\DLE\217u\177\183@\ACK\245\135\DC4\239\202\173\179\182\208V\163\168",PropRequestResponseInformation +// 85,PropSubscriptionIdentifier 0,PropRetainAvailable 38,PropTopicAliasMaximum 8926,PropSharedSubscriptionAvailable +// 17,PropContentType "\USb\156\FS\168\164.\NAK\140\DC2G\DC1N\185\&0\234Z",PropContentType +// "\237\135\132\186m\168\205\"!\215\208\163",PropRequestProblemInformation 174]} TEST(Publish5QCTest, Decode13) { - uint8_t pkt[] = {0x31, 0xa6, 0x1, 0x0, 0x14, 0x3b, 0x56, 0xc1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0xb0, 0x68}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3b, 0x56, 0xc1, 0x8d, 0x7d, 0xaf, 0x78, 0xd9, 0x69, 0x5e, - 0xe7, 0x67, 0xf7, 0xb, 0xcb, 0xb7, 0x5f, 0x97, 0x19, 0x5c}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa2, 0xa6, 0xad, 0xbb, 0x15, 0x29, 0x7b, 0x8a, 0xd2, 0x51, 0x5e, - 0x70, 0x2b, 0xf, 0x91, 0x51, 0xa5, 0x1d, 0xa6, 0xf9, 0x43, 0x47}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x24, 0xd4}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 1716); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\141\253\251\DC4\210]", _pubPktID = -// 0, _pubBody = "a#\200\US\234\221\168\235\213|\205w", _pubProps = [PropResponseTopic -// "\EM\166\243\154!\131e6!cq%;\221x\190J\250\206\170\189\a\172G\220c\195\US?\186",PropMessageExpiryInterval -// 9099,PropTopicAliasMaximum 17515,PropUserProperty "\184\130kV\184c\196:'\ESC\DC4\131\206@\133" -// "\197\140st\149{3W\157\FS\NUL\153\128\133+y\150)Gcz^l\140a\161<",PropTopicAliasMaximum 6907,PropServerKeepAlive -// 14769,PropPayloadFormatIndicator 38,PropAuthenticationMethod -// "\240\ETX\248\&6gl\v\216\200\212D\RSe\170\198\&8[(\GSx",PropMaximumPacketSize 29348,PropAuthenticationData -// "\178\153\146_\192=\f\143\178?4Ck/M",PropRequestProblemInformation 49,PropCorrelationData -// "\ETXd\nV\130\181L\167\137\251\174I\199\&2V\130\215\225\r\209k\141\162U\181"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\180\150\252c\201h%\ACKX[", +// _pubPktID = 23232, _pubBody = "\245\158IP\ETX\CAN\DLE|\148\175\r", _pubProps = [PropResponseInformation +// "\ETB\240\GSR\130D",PropAuthenticationMethod +// "k\224\193vn3L\249<\161\207\US\215\203\&5\228\SYN\134\167\222",PropTopicAlias 16911,PropResponseTopic +// ".s\246\161\ESC",PropWillDelayInterval 18379,PropMessageExpiryInterval 29762,PropReasonString +// "\178\224\&8\ESC\174",PropSubscriptionIdentifierAvailable 214,PropPayloadFormatIndicator +// 240,PropRequestProblemInformation 247,PropSharedSubscriptionAvailable 9,PropResponseInformation +// "\148F?\220\204\149",PropContentType "\138\251\159E`\NUL"]} TEST(Publish5QCTest, Encode14) { - uint8_t pkt[] = { - 0x31, 0xe4, 0x2, 0x0, 0x6, 0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d, 0xce, 0x2, 0x8, 0x0, 0x1e, 0x19, 0xa6, 0xf3, - 0x9a, 0x21, 0x83, 0x65, 0x36, 0x21, 0x63, 0x71, 0x25, 0x3b, 0xdd, 0x78, 0xbe, 0x4a, 0xfa, 0xce, 0xaa, 0xbd, 0x7, - 0xac, 0x47, 0xdc, 0x63, 0xc3, 0x1f, 0x3f, 0xba, 0x2, 0x0, 0x0, 0x23, 0x8b, 0x22, 0x44, 0x6b, 0x26, 0x0, 0xf, - 0xb8, 0x82, 0x6b, 0x56, 0xb8, 0x63, 0xc4, 0x3a, 0x27, 0x1b, 0x14, 0x83, 0xce, 0x40, 0x85, 0x0, 0x1b, 0xc5, 0x8c, - 0x73, 0x74, 0x95, 0x7b, 0x33, 0x57, 0x9d, 0x1c, 0x0, 0x99, 0x80, 0x85, 0x2b, 0x79, 0x96, 0x29, 0x47, 0x63, 0x7a, - 0x5e, 0x6c, 0x8c, 0x61, 0xa1, 0x3c, 0x22, 0x1a, 0xfb, 0x13, 0x39, 0xb1, 0x1, 0x26, 0x15, 0x0, 0x14, 0xf0, 0x3, - 0xf8, 0x36, 0x67, 0x6c, 0xb, 0xd8, 0xc8, 0xd4, 0x44, 0x1e, 0x65, 0xaa, 0xc6, 0x38, 0x5b, 0x28, 0x1d, 0x78, 0x27, - 0x0, 0x0, 0x72, 0xa4, 0x16, 0x0, 0xf, 0xb2, 0x99, 0x92, 0x5f, 0xc0, 0x3d, 0xc, 0x8f, 0xb2, 0x3f, 0x34, 0x43, - 0x6b, 0x2f, 0x4d, 0x17, 0x31, 0x9, 0x0, 0x17, 0x3, 0x64, 0xa, 0x56, 0x82, 0xb5, 0x4c, 0xa7, 0x89, 0xfb, 0xae, - 0x49, 0xc7, 0x32, 0x56, 0x82, 0xd7, 0xe1, 0x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xfd, 0xfb, 0x14, 0xd2, 0x5d}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x71, 0x0, 0xa, 0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b, 0x5a, 0xc0, 0x57, + 0x1a, 0x0, 0x6, 0x17, 0xf0, 0x1d, 0x52, 0x82, 0x44, 0x15, 0x0, 0x14, 0x6b, 0xe0, 0xc1, 0x76, 0x6e, + 0x33, 0x4c, 0xf9, 0x3c, 0xa1, 0xcf, 0x1f, 0xd7, 0xcb, 0x35, 0xe4, 0x16, 0x86, 0xa7, 0xde, 0x23, 0x42, + 0xf, 0x8, 0x0, 0x5, 0x2e, 0x73, 0xf6, 0xa1, 0x1b, 0x18, 0x0, 0x0, 0x47, 0xcb, 0x2, 0x0, 0x0, + 0x74, 0x42, 0x1f, 0x0, 0x5, 0xb2, 0xe0, 0x38, 0x1b, 0xae, 0x29, 0xd6, 0x1, 0xf0, 0x17, 0xf7, 0x2a, + 0x9, 0x1a, 0x0, 0x6, 0x94, 0x46, 0x3f, 0xdc, 0xcc, 0x95, 0x3, 0x0, 0x6, 0x8a, 0xfb, 0x9f, 0x45, + 0x60, 0x0, 0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; + uint8_t topic_bytes[] = {0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x61, 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; - - uint8_t bytesprops0[] = {0x19, 0xa6, 0xf3, 0x9a, 0x21, 0x83, 0x65, 0x36, 0x21, 0x63, 0x71, 0x25, 0x3b, 0xdd, 0x78, - 0xbe, 0x4a, 0xfa, 0xce, 0xaa, 0xbd, 0x7, 0xac, 0x47, 0xdc, 0x63, 0xc3, 0x1f, 0x3f, 0xba}; - uint8_t bytesprops2[] = {0xc5, 0x8c, 0x73, 0x74, 0x95, 0x7b, 0x33, 0x57, 0x9d, 0x1c, 0x0, 0x99, 0x80, 0x85, - 0x2b, 0x79, 0x96, 0x29, 0x47, 0x63, 0x7a, 0x5e, 0x6c, 0x8c, 0x61, 0xa1, 0x3c}; - uint8_t bytesprops1[] = {0xb8, 0x82, 0x6b, 0x56, 0xb8, 0x63, 0xc4, 0x3a, 0x27, 0x1b, 0x14, 0x83, 0xce, 0x40, 0x85}; - uint8_t bytesprops3[] = {0xf0, 0x3, 0xf8, 0x36, 0x67, 0x6c, 0xb, 0xd8, 0xc8, 0xd4, - 0x44, 0x1e, 0x65, 0xaa, 0xc6, 0x38, 0x5b, 0x28, 0x1d, 0x78}; - uint8_t bytesprops4[] = {0xb2, 0x99, 0x92, 0x5f, 0xc0, 0x3d, 0xc, 0x8f, 0xb2, 0x3f, 0x34, 0x43, 0x6b, 0x2f, 0x4d}; - uint8_t bytesprops5[] = {0x3, 0x64, 0xa, 0x56, 0x82, 0xb5, 0x4c, 0xa7, 0x89, 0xfb, 0xae, 0x49, - 0xc7, 0x32, 0x56, 0x82, 0xd7, 0xe1, 0xd, 0xd1, 0x3c, 0x64, 0x30}; - uint8_t bytesprops6[] = {0xb3, 0xa0, 0xa7, 0xa1, 0x29, 0x18, 0xab, 0xb5, 0x23, 0xd5, 0xd8, 0x98, 0x9d, 0x7c, 0x62, - 0x8c, 0xd8, 0xc8, 0x91, 0x39, 0x47, 0x96, 0x64, 0x9b, 0x7c, 0x39, 0x1b, 0xff, 0x4f}; - uint8_t bytesprops7[] = {0xf8, 0xc9, 0x4d, 0xeb, 0x5c, 0xe2, 0x34, 0xc2, 0x53, 0xcd, 0x9f, 0x68, 0x8b, 0x8, 0x81, - 0xc, 0x95, 0x75, 0xa1, 0x54, 0x15, 0x47, 0xba, 0x6b, 0xf, 0xf7, 0xb5, 0xd7, 0x98, 0xf4}; - uint8_t bytesprops9[] = {0x9, 0x50, 0x61, 0x3b, 0x10, 0x5c, 0x14, 0xa8, 0xb9, 0x23, 0x54, 0x4a, 0x96, 0x8c, - 0x4, 0x88, 0x5d, 0xc8, 0xf3, 0x74, 0x2e, 0x3c, 0x16, 0xd2, 0x42, 0x3b, 0x20}; - uint8_t bytesprops8[] = {0x62, 0x8, 0x49, 0x13, 0x99, 0x65, 0xcd, 0xcb, 0xc0, - 0xd2, 0x5, 0x21, 0x22, 0x92, 0x9c, 0xb5, 0x7c}; - uint8_t bytesprops10[] = {0x88, 0x31, 0xaa, 0x91, 0x24, 0xfc, 0x16, 0x98, 0xc3, 0xac, 0x49, 0xb2, 0x79, - 0x42, 0xd, 0x69, 0xdb, 0xc5, 0xb2, 0xb6, 0xb8, 0xb5, 0xc6, 0xe2, 0xd0}; - uint8_t bytesprops11[] = {0x5f, 0xf, 0x3e, 0x6b, 0x8d, 0xa2, 0x55, 0xb5}; + msg.payload_len = 11; + + uint8_t bytesprops0[] = {0x17, 0xf0, 0x1d, 0x52, 0x82, 0x44}; + uint8_t bytesprops1[] = {0x6b, 0xe0, 0xc1, 0x76, 0x6e, 0x33, 0x4c, 0xf9, 0x3c, 0xa1, + 0xcf, 0x1f, 0xd7, 0xcb, 0x35, 0xe4, 0x16, 0x86, 0xa7, 0xde}; + uint8_t bytesprops2[] = {0x2e, 0x73, 0xf6, 0xa1, 0x1b}; + uint8_t bytesprops3[] = {0xb2, 0xe0, 0x38, 0x1b, 0xae}; + uint8_t bytesprops4[] = {0x94, 0x46, 0x3f, 0xdc, 0xcc, 0x95}; + uint8_t bytesprops5[] = {0x8a, 0xfb, 0x9f, 0x45, 0x60, 0x0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9099}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17515}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops1}, .v = {27, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6907}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14769}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29348}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7990}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops8}, .v = {27, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16911}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18379}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29762}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 23232, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\141\253\251\DC4\210]", _pubPktID = -// 0, _pubBody = "a#\200\US\234\221\168\235\213|\205w", _pubProps = [PropResponseTopic -// "\EM\166\243\154!\131e6!cq%;\221x\190J\250\206\170\189\a\172G\220c\195\US?\186",PropMessageExpiryInterval -// 9099,PropTopicAliasMaximum 17515,PropUserProperty "\184\130kV\184c\196:'\ESC\DC4\131\206@\133" -// "\197\140st\149{3W\157\FS\NUL\153\128\133+y\150)Gcz^l\140a\161<",PropTopicAliasMaximum 6907,PropServerKeepAlive -// 14769,PropPayloadFormatIndicator 38,PropAuthenticationMethod -// "\240\ETX\248\&6gl\v\216\200\212D\RSe\170\198\&8[(\GSx",PropMaximumPacketSize 29348,PropAuthenticationData -// "\178\153\146_\192=\f\143\178?4Ck/M",PropRequestProblemInformation 49,PropCorrelationData -// "\ETXd\nV\130\181L\167\137\251\174I\199\&2V\130\215\225\r\209k\141\162U\181"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\180\150\252c\201h%\ACKX[", +// _pubPktID = 23232, _pubBody = "\245\158IP\ETX\CAN\DLE|\148\175\r", _pubProps = [PropResponseInformation +// "\ETB\240\GSR\130D",PropAuthenticationMethod +// "k\224\193vn3L\249<\161\207\US\215\203\&5\228\SYN\134\167\222",PropTopicAlias 16911,PropResponseTopic +// ".s\246\161\ESC",PropWillDelayInterval 18379,PropMessageExpiryInterval 29762,PropReasonString +// "\178\224\&8\ESC\174",PropSubscriptionIdentifierAvailable 214,PropPayloadFormatIndicator +// 240,PropRequestProblemInformation 247,PropSharedSubscriptionAvailable 9,PropResponseInformation +// "\148F?\220\204\149",PropContentType "\138\251\159E`\NUL"]} TEST(Publish5QCTest, Decode14) { - uint8_t pkt[] = { - 0x31, 0xe4, 0x2, 0x0, 0x6, 0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d, 0xce, 0x2, 0x8, 0x0, 0x1e, 0x19, 0xa6, 0xf3, - 0x9a, 0x21, 0x83, 0x65, 0x36, 0x21, 0x63, 0x71, 0x25, 0x3b, 0xdd, 0x78, 0xbe, 0x4a, 0xfa, 0xce, 0xaa, 0xbd, 0x7, - 0xac, 0x47, 0xdc, 0x63, 0xc3, 0x1f, 0x3f, 0xba, 0x2, 0x0, 0x0, 0x23, 0x8b, 0x22, 0x44, 0x6b, 0x26, 0x0, 0xf, - 0xb8, 0x82, 0x6b, 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, 0x0, 0x5, 0xb2, 0xe0, 0x38, 0x1b, 0xae, 0x29, 0xd6, 0x1, 0xf0, 0x17, 0xf7, 0x2a, + 0x9, 0x1a, 0x0, 0x6, 0x94, 0x46, 0x3f, 0xdc, 0xcc, 0x95, 0x3, 0x0, 0x6, 0x8a, 0xfb, 0x9f, 0x45, + 0x60, 0x0, 0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8d, 0xfd, 0xfb, 0x14, 0xd2, 0x5d}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x61, 0x23, 0xc8, 0x1f, 0xea, 0xdd, 0xa8, 0xeb, 0xd5, 0x7c, 0xcd, 0x77}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + uint8_t exp_topic_bytes[] = {0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 23232); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\n", _pubPktID = 15576, _pubBody = -// "\SYN\168.K\212\233\154\159\233j\172\130\DC2\187\203\187\155\ETX", _pubProps = [PropMaximumQoS -// 93,PropPayloadFormatIndicator 146,PropReceiveMaximum 21533,PropWillDelayInterval 20406,PropMaximumPacketSize -// 22453,PropMessageExpiryInterval 7551,PropRequestResponseInformation 41,PropMaximumQoS 142,PropResponseInformation -// "\198I\SI\ACK\152p\128",PropUserProperty -// "\157\178l\206\ETBB\132\174\235P\204\151\NAK\239\\^\177v/:\\\243Q\148\153\178{\205" -// "\DEL\158\131",PropRequestResponseInformation 90,PropMaximumQoS 159,PropTopicAlias 22855,PropMessageExpiryInterval -// 24420,PropWillDelayInterval 10065,PropSessionExpiryInterval 18232,PropAssignedClientIdentifier -// "\147\185\FS\bn\205\194\143\SYN",PropSessionExpiryInterval 13363,PropMessageExpiryInterval -// 26041,PropSubscriptionIdentifierAvailable 166,PropResponseInformation "F\157",PropWillDelayInterval -// 26757,PropServerReference "\209\247\248\150\ACKW}"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\200a\188\164\254\SO\133s@", +// _pubPktID = 0, _pubBody = "i\EM\SOH\179\179;\199eG\211b\163Ye\"\211",PropReceiveMaximum 10464,PropResponseInformation +// "n\204",PropServerKeepAlive 19107,PropMessageExpiryInterval 27838,PropWildcardSubscriptionAvailable +// 102,PropMessageExpiryInterval 15603,PropSubscriptionIdentifierAvailable 131,PropCorrelationData +// "l\140",PropSessionExpiryInterval 5845,PropRequestProblemInformation 83,PropRequestProblemInformation +// 46,PropMessageExpiryInterval 25078,PropUserProperty "\150)g\181\184]V]\157\&7S&\132\206\n4\204r\215h{\188vO&\b\159" +// "\207\141\142\222;MI\152\225\220\v\164\149j\254\245>\170\129\128X\161W\"\174",PropMessageExpiryInterval +// 3649,PropAuthenticationData +// "\ACK\t\220\229\130\146\EOT.o\203BV\173U\247\222\218\228\222\149\&7",PropRequestProblemInformation +// 2,PropRetainAvailable 126,PropSessionExpiryInterval 32225,PropPayloadFormatIndicator 175,PropReceiveMaximum +// 24587,PropResponseTopic ";\160\163\250\174&#R\164\182\152\143\145@mF)\204\182S4\190\199O\254$\236",PropMaximumQoS +// 219,PropPayloadFormatIndicator 233,PropTopicAlias 32208,PropContentType ":\176Q",PropResponseTopic +// "7\NUL\174V\168\226\193svo\225`\ESC\147\250a:1.W\rK\249"]} TEST(Publish5QCTest, Encode15) { - uint8_t pkt[] = {0x3c, 0xa3, 0x1, 0x0, 0x1, 0xa, 0x3c, 0xd8, 0x8a, 0x1, 0x24, 0x5d, 0x1, 0x92, 0x21, 0x54, 0x1d, - 0x18, 0x0, 0x0, 0x4f, 0xb6, 0x27, 0x0, 0x0, 0x57, 0xb5, 0x2, 0x0, 0x0, 0x1d, 0x7f, 0x19, 0x29, - 0x24, 0x8e, 0x1a, 0x0, 0x7, 0xc6, 0x49, 0xf, 0x6, 0x98, 0x70, 0x80, 0x26, 0x0, 0x1c, 0x9d, 0xb2, - 0x6c, 0xce, 0x17, 0x42, 0x84, 0xae, 0xeb, 0x50, 0xcc, 0x97, 0x15, 0xef, 0x5c, 0x5e, 0xb1, 0x76, 0x2f, - 0x3a, 0x5c, 0xf3, 0x51, 0x94, 0x99, 0xb2, 0x7b, 0xcd, 0x0, 0x3, 0x7f, 0x9e, 0x83, 0x19, 0x5a, 0x24, - 0x9f, 0x23, 0x59, 0x47, 0x2, 0x0, 0x0, 0x5f, 0x64, 0x18, 0x0, 0x0, 0x27, 0x51, 0x11, 0x0, 0x0, - 0x47, 0x38, 0x12, 0x0, 0x9, 0x93, 0xb9, 0x1c, 0x8, 0x6e, 0xcd, 0xc2, 0x8f, 0x16, 0x11, 0x0, 0x0, - 0x34, 0x33, 0x2, 0x0, 0x0, 0x65, 0xb9, 0x29, 0xa6, 0x1a, 0x0, 0x2, 0x46, 0x9d, 0x18, 0x0, 0x0, - 0x68, 0x85, 0x1c, 0x0, 0x7, 0xd1, 0xf7, 0xf8, 0x96, 0x6, 0x57, 0x7d, 0x16, 0xa8, 0x2e, 0x4b, 0xd4, - 0xe9, 0x9a, 0x9f, 0xe9, 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; - uint8_t topic_bytes[] = {0xa}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x8a, 0x2, 0x0, 0x9, 0xc8, 0x61, 0xbc, 0xa4, 0xfe, 0xe, 0x85, 0x73, 0x40, 0xe8, 0x1, 0x3, + 0x0, 0x10, 0x3e, 0x19, 0x1, 0xb3, 0xb3, 0x3b, 0xc7, 0x65, 0x47, 0xd3, 0x62, 0xa3, 0x59, 0x65, 0x22, + 0xd3, 0x21, 0x28, 0xe0, 0x1a, 0x0, 0x2, 0x6e, 0xcc, 0x13, 0x4a, 0xa3, 0x2, 0x0, 0x0, 0x6c, 0xbe, + 0x28, 0x66, 0x2, 0x0, 0x0, 0x3c, 0xf3, 0x29, 0x83, 0x9, 0x0, 0x2, 0x6c, 0x8c, 0x11, 0x0, 0x0, + 0x16, 0xd5, 0x17, 0x53, 0x17, 0x2e, 0x2, 0x0, 0x0, 0x61, 0xf6, 0x26, 0x0, 0x1b, 0x96, 0x29, 0x67, + 0xb5, 0xb8, 0x5d, 0x56, 0x5d, 0x9d, 0x37, 0x53, 0x26, 0x84, 0xce, 0xa, 0x34, 0xcc, 0x72, 0xd7, 0x68, + 0x7b, 0xbc, 0x76, 0x4f, 0x26, 0x8, 0x9f, 0x0, 0x19, 0xcf, 0x8d, 0x8e, 0xde, 0x3b, 0x4d, 0x49, 0x98, + 0xe1, 0xdc, 0xb, 0xa4, 0x95, 0x6a, 0xfe, 0xf5, 0x3e, 0xaa, 0x81, 0x80, 0x58, 0xa1, 0x57, 0x22, 0xae, + 0x2, 0x0, 0x0, 0xe, 0x41, 0x16, 0x0, 0x15, 0x6, 0x9, 0xdc, 0xe5, 0x82, 0x92, 0x4, 0x2e, 0x6f, + 0xcb, 0x42, 0x56, 0xad, 0x55, 0xf7, 0xde, 0xda, 0xe4, 0xde, 0x95, 0x37, 0x17, 0x2, 0x25, 0x7e, 0x11, + 0x0, 0x0, 0x7d, 0xe1, 0x1, 0xaf, 0x21, 0x60, 0xb, 0x8, 0x0, 0x1b, 0x3b, 0xa0, 0xa3, 0xfa, 0xae, + 0x26, 0x23, 0x52, 0xa4, 0xb6, 0x98, 0x8f, 0x91, 0x40, 0x6d, 0x46, 0x29, 0xcc, 0xb6, 0x53, 0x34, 0xbe, + 0xc7, 0x4f, 0xfe, 0x24, 0xec, 0x24, 0xdb, 0x1, 0xe9, 0x23, 0x7d, 0xd0, 0x3, 0x0, 0x3, 0x3a, 0xb0, + 0x51, 0x8, 0x0, 0x17, 0x37, 0x0, 0xae, 0x56, 0xa8, 0xe2, 0xc1, 0x73, 0x76, 0x6f, 0xe1, 0x60, 0x1b, + 0x93, 0xfa, 0x61, 0x3a, 0x31, 0x2e, 0x57, 0xd, 0x4b, 0xf9, 0x69, 0x3c, 0x55, 0x4a, 0xd9, 0x4a, 0x28, + 0x76, 0xa3, 0x5c, 0xd0, 0x5a, 0xd1, 0x30, 0xec, 0x7e, 0x31, 0x64, 0xd3, 0x58, 0x12}; + uint8_t topic_bytes[] = {0xc8, 0x61, 0xbc, 0xa4, 0xfe, 0xe, 0x85, 0x73, 0x40}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x16, 0xa8, 0x2e, 0x4b, 0xd4, 0xe9, 0x9a, 0x9f, 0xe9, - 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x69, 0x3c, 0x55, 0x4a, 0xd9, 0x4a, 0x28, 0x76, 0xa3, 0x5c, 0xd0, + 0x5a, 0xd1, 0x30, 0xec, 0x7e, 0x31, 0x64, 0xd3, 0x58, 0x12}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 21; - uint8_t bytesprops0[] = {0xc6, 0x49, 0xf, 0x6, 0x98, 0x70, 0x80}; - uint8_t bytesprops2[] = {0x7f, 0x9e, 0x83}; - uint8_t bytesprops1[] = {0x9d, 0xb2, 0x6c, 0xce, 0x17, 0x42, 0x84, 0xae, 0xeb, 0x50, 0xcc, 0x97, 0x15, 0xef, - 0x5c, 0x5e, 0xb1, 0x76, 0x2f, 0x3a, 0x5c, 0xf3, 0x51, 0x94, 0x99, 0xb2, 0x7b, 0xcd}; - uint8_t bytesprops3[] = {0x93, 0xb9, 0x1c, 0x8, 0x6e, 0xcd, 0xc2, 0x8f, 0x16}; - uint8_t bytesprops4[] = {0x46, 0x9d}; - uint8_t bytesprops5[] = {0xd1, 0xf7, 0xf8, 0x96, 0x6, 0x57, 0x7d}; + uint8_t bytesprops0[] = {0x3e, 0x19, 0x1, 0xb3, 0xb3, 0x3b, 0xc7, 0x65, + 0x47, 0xd3, 0x62, 0xa3, 0x59, 0x65, 0x22, 0xd3}; + uint8_t bytesprops1[] = {0x6e, 0xcc}; + uint8_t bytesprops2[] = {0x6c, 0x8c}; + uint8_t bytesprops4[] = {0xcf, 0x8d, 0x8e, 0xde, 0x3b, 0x4d, 0x49, 0x98, 0xe1, 0xdc, 0xb, 0xa4, 0x95, + 0x6a, 0xfe, 0xf5, 0x3e, 0xaa, 0x81, 0x80, 0x58, 0xa1, 0x57, 0x22, 0xae}; + uint8_t bytesprops3[] = {0x96, 0x29, 0x67, 0xb5, 0xb8, 0x5d, 0x56, 0x5d, 0x9d, 0x37, 0x53, 0x26, 0x84, 0xce, + 0xa, 0x34, 0xcc, 0x72, 0xd7, 0x68, 0x7b, 0xbc, 0x76, 0x4f, 0x26, 0x8, 0x9f}; + uint8_t bytesprops5[] = {0x6, 0x9, 0xdc, 0xe5, 0x82, 0x92, 0x4, 0x2e, 0x6f, 0xcb, 0x42, + 0x56, 0xad, 0x55, 0xf7, 0xde, 0xda, 0xe4, 0xde, 0x95, 0x37}; + uint8_t bytesprops6[] = {0x3b, 0xa0, 0xa3, 0xfa, 0xae, 0x26, 0x23, 0x52, 0xa4, 0xb6, 0x98, 0x8f, 0x91, 0x40, + 0x6d, 0x46, 0x29, 0xcc, 0xb6, 0x53, 0x34, 0xbe, 0xc7, 0x4f, 0xfe, 0x24, 0xec}; + uint8_t bytesprops7[] = {0x3a, 0xb0, 0x51}; + uint8_t bytesprops8[] = {0x37, 0x0, 0xae, 0x56, 0xa8, 0xe2, 0xc1, 0x73, 0x76, 0x6f, 0xe1, 0x60, + 0x1b, 0x93, 0xfa, 0x61, 0x3a, 0x31, 0x2e, 0x57, 0xd, 0x4b, 0xf9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21533}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20406}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22453}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7551}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops1}, .v = {3, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22855}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24420}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10065}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18232}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13363}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26041}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26757}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10464}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19107}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27838}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15603}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5845}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25078}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops3}, .v = {25, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3649}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32225}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24587}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32208}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15576, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\n", _pubPktID = 15576, _pubBody = -// "\SYN\168.K\212\233\154\159\233j\172\130\DC2\187\203\187\155\ETX", _pubProps = [PropMaximumQoS -// 93,PropPayloadFormatIndicator 146,PropReceiveMaximum 21533,PropWillDelayInterval 20406,PropMaximumPacketSize -// 22453,PropMessageExpiryInterval 7551,PropRequestResponseInformation 41,PropMaximumQoS 142,PropResponseInformation -// "\198I\SI\ACK\152p\128",PropUserProperty -// "\157\178l\206\ETBB\132\174\235P\204\151\NAK\239\\^\177v/:\\\243Q\148\153\178{\205" -// "\DEL\158\131",PropRequestResponseInformation 90,PropMaximumQoS 159,PropTopicAlias 22855,PropMessageExpiryInterval -// 24420,PropWillDelayInterval 10065,PropSessionExpiryInterval 18232,PropAssignedClientIdentifier -// "\147\185\FS\bn\205\194\143\SYN",PropSessionExpiryInterval 13363,PropMessageExpiryInterval -// 26041,PropSubscriptionIdentifierAvailable 166,PropResponseInformation "F\157",PropWillDelayInterval -// 26757,PropServerReference "\209\247\248\150\ACKW}"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\200a\188\164\254\SO\133s@", +// _pubPktID = 0, _pubBody = "i\EM\SOH\179\179;\199eG\211b\163Ye\"\211",PropReceiveMaximum 10464,PropResponseInformation +// "n\204",PropServerKeepAlive 19107,PropMessageExpiryInterval 27838,PropWildcardSubscriptionAvailable +// 102,PropMessageExpiryInterval 15603,PropSubscriptionIdentifierAvailable 131,PropCorrelationData +// "l\140",PropSessionExpiryInterval 5845,PropRequestProblemInformation 83,PropRequestProblemInformation +// 46,PropMessageExpiryInterval 25078,PropUserProperty "\150)g\181\184]V]\157\&7S&\132\206\n4\204r\215h{\188vO&\b\159" +// "\207\141\142\222;MI\152\225\220\v\164\149j\254\245>\170\129\128X\161W\"\174",PropMessageExpiryInterval +// 3649,PropAuthenticationData +// "\ACK\t\220\229\130\146\EOT.o\203BV\173U\247\222\218\228\222\149\&7",PropRequestProblemInformation +// 2,PropRetainAvailable 126,PropSessionExpiryInterval 32225,PropPayloadFormatIndicator 175,PropReceiveMaximum +// 24587,PropResponseTopic ";\160\163\250\174&#R\164\182\152\143\145@mF)\204\182S4\190\199O\254$\236",PropMaximumQoS +// 219,PropPayloadFormatIndicator 233,PropTopicAlias 32208,PropContentType ":\176Q",PropResponseTopic +// "7\NUL\174V\168\226\193svo\225`\ESC\147\250a:1.W\rK\249"]} TEST(Publish5QCTest, Decode15) { - uint8_t pkt[] = {0x3c, 0xa3, 0x1, 0x0, 0x1, 0xa, 0x3c, 0xd8, 0x8a, 0x1, 0x24, 0x5d, 0x1, 0x92, 0x21, 0x54, 0x1d, - 0x18, 0x0, 0x0, 0x4f, 0xb6, 0x27, 0x0, 0x0, 0x57, 0xb5, 0x2, 0x0, 0x0, 0x1d, 0x7f, 0x19, 0x29, - 0x24, 0x8e, 0x1a, 0x0, 0x7, 0xc6, 0x49, 0xf, 0x6, 0x98, 0x70, 0x80, 0x26, 0x0, 0x1c, 0x9d, 0xb2, - 0x6c, 0xce, 0x17, 0x42, 0x84, 0xae, 0xeb, 0x50, 0xcc, 0x97, 0x15, 0xef, 0x5c, 0x5e, 0xb1, 0x76, 0x2f, - 0x3a, 0x5c, 0xf3, 0x51, 0x94, 0x99, 0xb2, 0x7b, 0xcd, 0x0, 0x3, 0x7f, 0x9e, 0x83, 0x19, 0x5a, 0x24, - 0x9f, 0x23, 0x59, 0x47, 0x2, 0x0, 0x0, 0x5f, 0x64, 0x18, 0x0, 0x0, 0x27, 0x51, 0x11, 0x0, 0x0, - 0x47, 0x38, 0x12, 0x0, 0x9, 0x93, 0xb9, 0x1c, 0x8, 0x6e, 0xcd, 0xc2, 0x8f, 0x16, 0x11, 0x0, 0x0, - 0x34, 0x33, 0x2, 0x0, 0x0, 0x65, 0xb9, 0x29, 0xa6, 0x1a, 0x0, 0x2, 0x46, 0x9d, 0x18, 0x0, 0x0, - 0x68, 0x85, 0x1c, 0x0, 0x7, 0xd1, 0xf7, 0xf8, 0x96, 0x6, 0x57, 0x7d, 0x16, 0xa8, 0x2e, 0x4b, 0xd4, - 0xe9,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1, 0x1, 0xaf, 0x21, 0x60, 0xb, 0x8, 0x0, 0x1b, 0x3b, 0xa0, 0xa3, 0xfa, 0xae, + 0x26, 0x23, 0x52, 0xa4, 0xb6, 0x98, 0x8f, 0x91, 0x40, 0x6d, 0x46, 0x29, 0xcc, 0xb6, 0x53, 0x34, 0xbe, + 0xc7, 0x4f, 0xfe, 0x24, 0xec, 0x24, 0xdb, 0x1, 0xe9, 0x23, 0x7d, 0xd0, 0x3, 0x0, 0x3, 0x3a, 0xb0, + 0x51, 0x8, 0x0, 0x17, 0x37, 0x0, 0xae, 0x56, 0xa8, 0xe2, 0xc1, 0x73, 0x76, 0x6f, 0xe1, 0x60, 0x1b, + 0x93, 0xfa, 0x61, 0x3a, 0x31, 0x2e, 0x57, 0xd, 0x4b, 0xf9, 0x69, 0x3c, 0x55, 0x4a, 0xd9, 0x4a, 0x28, + 0x76, 0xa3, 0x5c, 0xd0, 0x5a, 0xd1, 0x30, 0xec, 0x7e, 0x31, 0x64, 0xd3, 0x58, 0x12}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa}; - lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x16, 0xa8, 0x2e, 0x4b, 0xd4, 0xe9, 0x9a, 0x9f, 0xe9, - 0x6a, 0xac, 0x82, 0x12, 0xbb, 0xcb, 0xbb, 0x9b, 0x3}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 15576); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + uint8_t exp_topic_bytes[] = {0xc8, 0x61, 0xbc, 0xa4, 0xfe, 0xe, 0x85, 0x73, 0x40}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x69, 0x3c, 0x55, 0x4a, 0xd9, 0x4a, 0x28, 0x76, 0xa3, 0x5c, 0xd0, + 0x5a, 0xd1, 0x30, 0xec, 0x7e, 0x31, 0x64, 0xd3, 0x58, 0x12}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\195\214\220\150\206L\a\225", -// _pubPktID = 0, _pubBody = "\203\137\DC3y\ETBf\GS\255}~\231\217kJ\ESCI\193\148\254p\247\ACKB\245", _pubProps = -// [PropMaximumQoS 244,PropCorrelationData -// "\181\249\159\175\155\170\r\191X\253\226\180\181\235\168\\\165\195f\NAK",PropSubscriptionIdentifierAvailable -// 149,PropWildcardSubscriptionAvailable 9,PropTopicAliasMaximum 27472,PropMessageExpiryInterval 269,PropReasonString -// "\230o\STX{l\138p",PropMessageExpiryInterval 32244,PropWillDelayInterval 26373,PropTopicAliasMaximum -// 26296,PropWillDelayInterval 17842,PropMessageExpiryInterval 14239,PropRetainAvailable 179,PropUserProperty -// "\222\211\187\&9\254\208\239" -// "\n\t\224E\NAK\195\SUB\209@\235\214\182\ETBn%_$o\159\v\206\254",PropSubscriptionIdentifierAvailable -// 94,PropServerKeepAlive 3204,PropTopicAlias 992]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ">\248\138\204\&7]\233\FS\228\b|\187\148\202aA\US\153\STX\GS\135\211p", _pubPktID = 4359, _pubBody = +// "\242\145\166\143\135]\136Z\130\202\216\&2*\239?C\217\144\162", _pubProps = [PropSharedSubscriptionAvailable +// 179,PropAuthenticationData "4C\158\223\174\165\223\218k\FSy\238\249\197\134\t>",PropRequestProblemInformation +// 118,PropResponseTopic ":\162\STX \239",PropMessageExpiryInterval 16702,PropMaximumQoS 226,PropServerReference +// "\216\176\ACKP\234\&8z\131\&0\221\248kFLX\225\193\STX\223\201L;\217\242\253\t\168\245TP",PropMaximumPacketSize +// 7247,PropSessionExpiryInterval 6004]} TEST(Publish5QCTest, Encode16) { - uint8_t pkt[] = {0x30, 0x95, 0x1, 0x0, 0x8, 0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1, 0x72, 0x24, 0xf4, 0x9, - 0x0, 0x14, 0xb5, 0xf9, 0x9f, 0xaf, 0x9b, 0xaa, 0xd, 0xbf, 0x58, 0xfd, 0xe2, 0xb4, 0xb5, 0xeb, 0xa8, - 0x5c, 0xa5, 0xc3, 0x66, 0x15, 0x29, 0x95, 0x28, 0x9, 0x22, 0x6b, 0x50, 0x2, 0x0, 0x0, 0x1, 0xd, - 0x1f, 0x0, 0x7, 0xe6, 0x6f, 0x2, 0x7b, 0x6c, 0x8a, 0x70, 0x2, 0x0, 0x0, 0x7d, 0xf4, 0x18, 0x0, - 0x0, 0x67, 0x5, 0x22, 0x66, 0xb8, 0x18, 0x0, 0x0, 0x45, 0xb2, 0x2, 0x0, 0x0, 0x37, 0x9f, 0x25, - 0xb3, 0x26, 0x0, 0x7, 0xde, 0xd3, 0xbb, 0x39, 0xfe, 0xd0, 0xef, 0x0, 0x16, 0xa, 0x9, 0xe0, 0x45, - 0x15, 0xc3, 0x1a, 0xd1, 0x40, 0xeb, 0xd6, 0xb6, 0x17, 0x6e, 0x25, 0x5f, 0x24, 0x6f, 0x9f, 0xb, 0xce, - 0xfe, 0x29, 0x5e, 0x13, 0xc, 0x84, 0x23, 0x3, 0xe0, 0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, - 0x7d, 0x7e, 0xe7, 0xd9, 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; - uint8_t topic_bytes[] = {0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x81, 0x1, 0x0, 0x17, 0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, + 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70, 0x11, 0x7, 0x52, 0x2a, 0xb3, 0x16, + 0x0, 0x11, 0x34, 0x43, 0x9e, 0xdf, 0xae, 0xa5, 0xdf, 0xda, 0x6b, 0x1c, 0x79, 0xee, 0xf9, 0xc5, 0x86, + 0x9, 0x3e, 0x17, 0x76, 0x8, 0x0, 0x5, 0x3a, 0xa2, 0x2, 0x20, 0xef, 0x2, 0x0, 0x0, 0x41, 0x3e, + 0x24, 0xe2, 0x1c, 0x0, 0x1e, 0xd8, 0xb0, 0x6, 0x50, 0xea, 0x38, 0x7a, 0x83, 0x30, 0xdd, 0xf8, 0x6b, + 0x46, 0x4c, 0x58, 0xe1, 0xc1, 0x2, 0xdf, 0xc9, 0x4c, 0x3b, 0xd9, 0xf2, 0xfd, 0x9, 0xa8, 0xf5, 0x54, + 0x50, 0x27, 0x0, 0x0, 0x1c, 0x4f, 0x11, 0x0, 0x0, 0x17, 0x74, 0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, + 0x88, 0x5a, 0x82, 0xca, 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; + uint8_t topic_bytes[] = {0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, + 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, - 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; + uint8_t msg_bytes[] = {0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, + 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 19; - uint8_t bytesprops0[] = {0xb5, 0xf9, 0x9f, 0xaf, 0x9b, 0xaa, 0xd, 0xbf, 0x58, 0xfd, - 0xe2, 0xb4, 0xb5, 0xeb, 0xa8, 0x5c, 0xa5, 0xc3, 0x66, 0x15}; - uint8_t bytesprops1[] = {0xe6, 0x6f, 0x2, 0x7b, 0x6c, 0x8a, 0x70}; - uint8_t bytesprops3[] = {0xa, 0x9, 0xe0, 0x45, 0x15, 0xc3, 0x1a, 0xd1, 0x40, 0xeb, 0xd6, - 0xb6, 0x17, 0x6e, 0x25, 0x5f, 0x24, 0x6f, 0x9f, 0xb, 0xce, 0xfe}; - uint8_t bytesprops2[] = {0xde, 0xd3, 0xbb, 0x39, 0xfe, 0xd0, 0xef}; + uint8_t bytesprops0[] = {0x34, 0x43, 0x9e, 0xdf, 0xae, 0xa5, 0xdf, 0xda, 0x6b, + 0x1c, 0x79, 0xee, 0xf9, 0xc5, 0x86, 0x9, 0x3e}; + uint8_t bytesprops1[] = {0x3a, 0xa2, 0x2, 0x20, 0xef}; + uint8_t bytesprops2[] = {0xd8, 0xb0, 0x6, 0x50, 0xea, 0x38, 0x7a, 0x83, 0x30, 0xdd, 0xf8, 0x6b, 0x46, 0x4c, 0x58, + 0xe1, 0xc1, 0x2, 0xdf, 0xc9, 0x4c, 0x3b, 0xd9, 0xf2, 0xfd, 0x9, 0xa8, 0xf5, 0x54, 0x50}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27472}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 269}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32244}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26373}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26296}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17842}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14239}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops2}, .v = {22, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3204}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 992}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16702}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7247}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6004}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 4359, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\195\214\220\150\206L\a\225", -// _pubPktID = 0, _pubBody = "\203\137\DC3y\ETBf\GS\255}~\231\217kJ\ESCI\193\148\254p\247\ACKB\245", _pubProps = -// [PropMaximumQoS 244,PropCorrelationData -// "\181\249\159\175\155\170\r\191X\253\226\180\181\235\168\\\165\195f\NAK",PropSubscriptionIdentifierAvailable -// 149,PropWildcardSubscriptionAvailable 9,PropTopicAliasMaximum 27472,PropMessageExpiryInterval 269,PropReasonString -// "\230o\STX{l\138p",PropMessageExpiryInterval 32244,PropWillDelayInterval 26373,PropTopicAliasMaximum -// 26296,PropWillDelayInterval 17842,PropMessageExpiryInterval 14239,PropRetainAvailable 179,PropUserProperty -// "\222\211\187\&9\254\208\239" -// "\n\t\224E\NAK\195\SUB\209@\235\214\182\ETBn%_$o\159\v\206\254",PropSubscriptionIdentifierAvailable -// 94,PropServerKeepAlive 3204,PropTopicAlias 992]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ">\248\138\204\&7]\233\FS\228\b|\187\148\202aA\US\153\STX\GS\135\211p", _pubPktID = 4359, _pubBody = +// "\242\145\166\143\135]\136Z\130\202\216\&2*\239?C\217\144\162", _pubProps = [PropSharedSubscriptionAvailable +// 179,PropAuthenticationData "4C\158\223\174\165\223\218k\FSy\238\249\197\134\t>",PropRequestProblemInformation +// 118,PropResponseTopic ":\162\STX \239",PropMessageExpiryInterval 16702,PropMaximumQoS 226,PropServerReference +// "\216\176\ACKP\234\&8z\131\&0\221\248kFLX\225\193\STX\223\201L;\217\242\253\t\168\245TP",PropMaximumPacketSize +// 7247,PropSessionExpiryInterval 6004]} TEST(Publish5QCTest, Decode16) { - uint8_t pkt[] = {0x30, 0x95, 0x1, 0x0, 0x8, 0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1, 0x72, 0x24, 0xf4, 0x9, - 0x0, 0x14, 0xb5, 0xf9, 0x9f, 0xaf, 0x9b, 0xaa, 0xd, 0xbf, 0x58, 0xfd, 0xe2, 0xb4, 0xb5, 0xeb, 0xa8, - 0x5c, 0xa5, 0xc3, 0x66, 0x15, 0x29, 0x95, 0x28, 0x9, 0x22, 0x6b, 0x50, 0x2, 0x0, 0x0, 0x1, 0xd, - 0x1f, 0x0, 0x7, 0xe6, 0x6f, 0x2, 0x7b, 0x6c, 0x8a, 0x70, 0x2, 0x0, 0x0, 0x7d, 0xf4, 0x18, 0x0, - 0x0, 0x67, 0x5, 0x22, 0x66, 0xb8, 0x18, 0x0, 0x0, 0x45, 0xb2, 0x2, 0x0, 0x0, 0x37, 0x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 0xa6, 0x8f, 0x87, 0x5d, + 0x88, 0x5a, 0x82, 0xca, 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc3, 0xd6, 0xdc, 0x96, 0xce, 0x4c, 0x7, 0xe1}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcb, 0x89, 0x13, 0x79, 0x17, 0x66, 0x1d, 0xff, 0x7d, 0x7e, 0xe7, 0xd9, - 0x6b, 0x4a, 0x1b, 0x49, 0xc1, 0x94, 0xfe, 0x70, 0xf7, 0x6, 0x42, 0xf5}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, + 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, + 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + EXPECT_EQ(packet_id, 4359); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\NUL=U\137\224\247\192", _pubPktID = -// 0, _pubBody = "\142\160\202\237f\186\202Fc1p\\\ACK\231J\193%\250kl", _pubProps = [PropResponseTopic -// "O\141*\235\&3\DC4\168\162\EOT;\RS\229",PropAuthenticationMethod -// "\131\STX\192\RSs)\157\145\222\238\178\137\162\244&\161\157\221mfd\201G\253\147S",PropPayloadFormatIndicator -// 181,PropRetainAvailable 216,PropContentType -// "\241\roz\NAK\216\238\192\155\249\200\211\129\f$*\175\147",PropReasonString -// "b\ta\190\187\148\DEL\170L\215e\197\240\151\DLE\223\SO\232\153\&9\155'r\207\168\210i",PropWildcardSubscriptionAvailable -// 225,PropMaximumPacketSize 26717,PropMaximumQoS 92,PropMaximumQoS 102,PropUserProperty -// "\196\FS\172\\\213+m\242\DLEo=\189=\213\218\243<\188\253\152F\209\133\252\139\170\159\207V" -// "\202\129\NULU\177\233\203\246hv\ETX\240\&9E\229B6\252\&4\155\136\r\231\229",PropMessageExpiryInterval -// 20811,PropAuthenticationMethod -// "\CAN8\213\197#\136\254\192\152I\237_n{9X/t\152\a+\165\&8\181\&2\226\151",PropMessageExpiryInterval -// 24371,PropSubscriptionIdentifier 27,PropUserProperty "\136" -// "yb\RS\DEL)\198o\EOTs\180\DC1e\213\214!\182Ql\251\137\154\165\137\216\144\218\247\130+\227",PropUserProperty -// "\177\132U^\v\249\252\145]\v\250b\184\US5zN\STX\195m" -// "\173\n\156\165\GS\255\195u\181\142\178\134\252kX\220*\RSm",PropSubscriptionIdentifier 16,PropResponseInformation -// "\149l&~\225\129\140f.\206\195p\152\156\202LS\ACKi\"!\175\255",PropTopicAlias +// 31038,PropAuthenticationMethod "v;\218\149\251?tvDk",PropAssignedClientIdentifier +// "\129\EMo\251\138\210\178\248z`\EM\238Z\231\DC1\"!\bI\f\219\176\245\140\149\137\182\202",PropMessageExpiryInterval +// 14407]} TEST(Publish5QCTest, Encode17) { - uint8_t pkt[] = { - 0x39, 0xea, 0x2, 0x0, 0x7, 0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0, 0xcb, 0x2, 0x8, 0x0, 0xc, 0x4f, 0x8d, - 0x2a, 0xeb, 0x33, 0x14, 0xa8, 0xa2, 0x4, 0x3b, 0x1e, 0xe5, 0x15, 0x0, 0x1a, 0x83, 0x2, 0xc0, 0x1e, 0x73, 0x29, - 0x9d, 0x91, 0xde, 0xee, 0xb2, 0x89, 0xa2, 0xf4, 0x26, 0xa1, 0x9d, 0xdd, 0x6d, 0x66, 0x64, 0xc9, 0x47, 0xfd, 0x93, - 0x53, 0x1, 0xb5, 0x25, 0xd8, 0x3, 0x0, 0x12, 0xf1, 0xd, 0x6f, 0x7a, 0x15, 0xd8, 0xee, 0xc0, 0x9b, 0xf9, 0xc8, - 0xd3, 0x81, 0xc, 0x24, 0x2a, 0xaf, 0x93, 0x1f, 0x0, 0x1b, 0x62, 0x9, 0x61, 0xbe, 0xbb, 0x94, 0x7f, 0xaa, 0x4c, - 0xd7, 0x65, 0xc5, 0xf0, 0x97, 0x10, 0xdf, 0xe, 0xe8, 0x99, 0x39, 0x9b, 0x27, 0x72, 0xcf, 0xa8, 0xd2, 0x69, 0x28, - 0xe1, 0x27, 0x0, 0x0, 0x68, 0x5d, 0x24, 0x5c, 0x24, 0x66, 0x26, 0x0, 0x1d, 0xc4, 0x1c, 0xac, 0x5c, 0xd5,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x66, 0x2e, 0xce, 0xc3, 0x70, 0x98, 0x9c, - 0xca, 0x3c, 0x54, 0x82, 0x2b, 0xa2, 0x29, 0x6b, 0x67, 0x6e, 0x44, 0x22, 0x2, 0x0, 0x0, 0x3c, 0x39, 0x11, 0x0, - 0x0, 0x48, 0xe9, 0x8e, 0xa0, 0xca, 0xed, 0x66, 0xba, 0xca, 0x46, 0x63, 0x31, 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, - 0x25, 0xfa, 0x6b, 0x6c}; - uint8_t topic_bytes[] = {0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x96, 0x1, 0x0, 0x12, 0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, 0xa3, 0xbe, + 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e, 0x28, 0x66, 0x6c, 0x19, 0x45, 0x22, 0x69, 0x4f, 0x13, + 0xf, 0x19, 0x22, 0x4d, 0x31, 0x29, 0x73, 0x16, 0x0, 0x9, 0x0, 0xd6, 0x1d, 0x63, 0x75, 0x3f, + 0x70, 0xf8, 0xca, 0x21, 0x3e, 0x25, 0x26, 0x0, 0x1, 0xbf, 0x0, 0x16, 0xeb, 0xf2, 0x1e, 0xa7, + 0xbb, 0x4a, 0x6b, 0xed, 0x37, 0x25, 0x9d, 0xc0, 0xd5, 0x3e, 0x4c, 0x53, 0x6, 0x69, 0x22, 0x21, + 0xaf, 0xff, 0x23, 0x79, 0x3e, 0x15, 0x0, 0xa, 0x76, 0x3b, 0xda, 0x95, 0xfb, 0x3f, 0x74, 0x76, + 0x44, 0x6b, 0x12, 0x0, 0x1c, 0x81, 0x19, 0x6f, 0xfb, 0x8a, 0xd2, 0xb2, 0xf8, 0x7a, 0x60, 0x19, + 0xee, 0x5a, 0xe7, 0x11, 0x22, 0x21, 0x8, 0x49, 0xc, 0xdb, 0xb0, 0xf5, 0x8c, 0x95, 0x89, 0xb6, + 0xca, 0x2, 0x0, 0x0, 0x38, 0x47, 0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, + 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; + uint8_t topic_bytes[] = {0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, + 0xa3, 0xbe, 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x8e, 0xa0, 0xca, 0xed, 0x66, 0xba, 0xca, 0x46, 0x63, 0x31, - 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, 0x25, 0xfa, 0x6b, 0x6c}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, + 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 19; - uint8_t bytesprops0[] = {0x4f, 0x8d, 0x2a, 0xeb, 0x33, 0x14, 0xa8, 0xa2, 0x4, 0x3b, 0x1e, 0xe5}; - uint8_t bytesprops1[] = {0x83, 0x2, 0xc0, 0x1e, 0x73, 0x29, 0x9d, 0x91, 0xde, 0xee, 0xb2, 0x89, 0xa2, - 0xf4, 0x26, 0xa1, 0x9d, 0xdd, 0x6d, 0x66, 0x64, 0xc9, 0x47, 0xfd, 0x93, 0x53}; - uint8_t bytesprops2[] = {0xf1, 0xd, 0x6f, 0x7a, 0x15, 0xd8, 0xee, 0xc0, 0x9b, - 0xf9, 0xc8, 0xd3, 0x81, 0xc, 0x24, 0x2a, 0xaf, 0x93}; - uint8_t bytesprops3[] = {0x62, 0x9, 0x61, 0xbe, 0xbb, 0x94, 0x7f, 0xaa, 0x4c, 0xd7, 0x65, 0xc5, 0xf0, 0x97, - 0x10, 0xdf, 0xe, 0xe8, 0x99, 0x39, 0x9b, 0x27, 0x72, 0xcf, 0xa8, 0xd2, 0x69}; - uint8_t bytesprops5[] = {0xca, 0x81, 0x0, 0x55, 0xb1, 0xe9, 0xcb, 0xf6, 0x68, 0x76, 0x3, 0xf0, - 0x39, 0x45, 0xe5, 0x42, 0x36, 0xfc, 0x34, 0x9b, 0x88, 0xd, 0xe7, 0xe5}; - uint8_t bytesprops4[] = {0xc4, 0x1c, 0xac, 0x5c, 0xd5, 0x2b, 0x6d, 0xf2, 0x10, 0x6f, 0x3d, 0xbd, 0x3d, 0xd5, 0xda, - 0xf3, 0x3c, 0xbc, 0xfd, 0x98, 0x46, 0xd1, 0x85, 0xfc, 0x8b, 0xaa, 0x9f, 0xcf, 0x56}; - uint8_t bytesprops6[] = {0x18, 0x38, 0xd5, 0xc5, 0x23, 0x88, 0xfe, 0xc0, 0x98, 0x49, 0xed, 0x5f, 0x6e, 0x7b, - 0x39, 0x58, 0x2f, 0x74, 0x98, 0x7, 0x2b, 0xa5, 0x38, 0xb5, 0x32, 0xe2, 0x97}; - uint8_t bytesprops8[] = {0x79, 0x62, 0x1e, 0x7f, 0x29, 0xc6, 0x6f, 0x4, 0x73, 0xb4, 0x11, 0x65, 0xd5, 0xd6, 0x21, - 0xb6, 0x51, 0x6c, 0xfb, 0x89, 0x9a, 0xa5, 0x89, 0xd8, 0x90, 0xda, 0xf7, 0x82, 0x2b, 0xe3}; - uint8_t bytesprops7[] = {0x88}; - uint8_t bytesprops10[] = {0xad, 0xa, 0x9c, 0xa5, 0x1d, 0xff, 0xc3, 0x75, 0xb5, 0x8e, - 0xb2, 0x86, 0xfc, 0x6b, 0x58, 0xdc, 0x2a, 0x1e, 0x6d}; - uint8_t bytesprops9[] = {0xb1, 0x84, 0x55, 0x5e, 0xb, 0xf9, 0xfc, 0x91, 0x5d, 0xb, - 0xfa, 0x62, 0xb8, 0x1f, 0x35, 0x7a, 0x4e, 0x2, 0xc3, 0x6d}; - uint8_t bytesprops11[] = {0x95, 0x6c, 0x26, 0x7e, 0xe1, 0x81, 0x8c, 0x66, 0x2e, 0xce, 0xc3, 0x70, 0x98, - 0x9c, 0xca, 0x3c, 0x54, 0x82, 0x2b, 0xa2, 0x29, 0x6b, 0x67, 0x6e, 0x44, 0x22}; + uint8_t bytesprops0[] = {0x0, 0xd6, 0x1d, 0x63, 0x75, 0x3f, 0x70, 0xf8, 0xca}; + uint8_t bytesprops2[] = {0xeb, 0xf2, 0x1e, 0xa7, 0xbb, 0x4a, 0x6b, 0xed, 0x37, 0x25, 0x9d, + 0xc0, 0xd5, 0x3e, 0x4c, 0x53, 0x6, 0x69, 0x22, 0x21, 0xaf, 0xff}; + uint8_t bytesprops1[] = {0xbf}; + uint8_t bytesprops3[] = {0x76, 0x3b, 0xda, 0x95, 0xfb, 0x3f, 0x74, 0x76, 0x44, 0x6b}; + uint8_t bytesprops4[] = {0x81, 0x19, 0x6f, 0xfb, 0x8a, 0xd2, 0xb2, 0xf8, 0x7a, 0x60, 0x19, 0xee, 0x5a, 0xe7, + 0x11, 0x22, 0x21, 0x8, 0x49, 0xc, 0xdb, 0xb0, 0xf5, 0x8c, 0x95, 0x89, 0xb6, 0xca}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26717}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {24, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20811}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24371}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops7}, .v = {30, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops9}, .v = {19, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15417}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18665}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26959}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3865}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19761}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15909}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops1}, .v = {22, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31038}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14407}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10342, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\NUL=U\137\224\247\192", _pubPktID = -// 0, _pubBody = "\142\160\202\237f\186\202Fc1p\\\ACK\231J\193%\250kl", _pubProps = [PropResponseTopic -// "O\141*\235\&3\DC4\168\162\EOT;\RS\229",PropAuthenticationMethod -// "\131\STX\192\RSs)\157\145\222\238\178\137\162\244&\161\157\221mfd\201G\253\147S",PropPayloadFormatIndicator -// 181,PropRetainAvailable 216,PropContentType -// "\241\roz\NAK\216\238\192\155\249\200\211\129\f$*\175\147",PropReasonString -// "b\ta\190\187\148\DEL\170L\215e\197\240\151\DLE\223\SO\232\153\&9\155'r\207\168\210i",PropWildcardSubscriptionAvailable -// 225,PropMaximumPacketSize 26717,PropMaximumQoS 92,PropMaximumQoS 102,PropUserProperty -// "\196\FS\172\\\213+m\242\DLEo=\189=\213\218\243<\188\253\152F\209\133\252\139\170\159\207V" -// "\202\129\NULU\177\233\203\246hv\ETX\240\&9E\229B6\252\&4\155\136\r\231\229",PropMessageExpiryInterval -// 20811,PropAuthenticationMethod -// "\CAN8\213\197#\136\254\192\152I\237_n{9X/t\152\a+\165\&8\181\&2\226\151",PropMessageExpiryInterval -// 24371,PropSubscriptionIdentifier 27,PropUserProperty "\136" -// "yb\RS\DEL)\198o\EOTs\180\DC1e\213\214!\182Ql\251\137\154\165\137\216\144\218\247\130+\227",PropUserProperty -// "\177\132U^\v\249\252\145]\v\250b\184\US5zN\STX\195m" -// "\173\n\156\165\GS\255\195u\181\142\178\134\252kX\220*\RSm",PropSubscriptionIdentifier 16,PropResponseInformation -// "\149l&~\225\129\140f.\206\195p\152\156\202LS\ACKi\"!\175\255",PropTopicAlias +// 31038,PropAuthenticationMethod "v;\218\149\251?tvDk",PropAssignedClientIdentifier +// "\129\EMo\251\138\210\178\248z`\EM\238Z\231\DC1\"!\bI\f\219\176\245\140\149\137\182\202",PropMessageExpiryInterval +// 14407]} TEST(Publish5QCTest, Decode17) { - uint8_t pkt[] = { - 0x39, 0xea, 0x2, 0x0, 0x7, 0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0, 0xcb, 0x2, 0x8, 0x0, 0xc, 0x4f, 0x8d, - 0x2a, 0xeb, 0x33, 0x14, 0xa8, 0xa2, 0x4, 0x3b, 0x1e, 0xe5, 0x15, 0x0, 0x1a, 0x83, 0x2, 0xc0, 0x1e, 0x73, 0x29, - 0x9d, 0x91, 0xde, 0xee, 0xb2, 0x89, 0xa2, 0xf4, 0x26, 0xa1, 0x9d, 0xdd, 0x6d, 0x66, 0x64, 0xc9, 0x47, 0xfd, 0x93, - 0x53, 0x1, 0xb5, 0x25, 0xd8, 0x3, 0x0, 0x12, 0xf1, 0xd, 0x6f, 0x7a, 0x15, 0xd8, 0xee, 0xc0, 0x9b, 0xf9, 0xc8, - 0xd3, 0x81, 0xc, 0x24, 0x2a, 0xaf, 0x93, 0x1f, 0x0, 0x1b, 0x62, 0x9, 0x61, 0xbe, 0xbb, 0x94, 0x7f, 0xaa, 0x4c, - 0xd7, 0x65, 0xc5, 0xf0, 0x97, 0x10, 0xdf, 0xe, 0xe8, 0x99, 0x39, 0x9b, 0x27, 0x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, 0x5a, 0xe7, 0x11, 0x22, 0x21, 0x8, 0x49, 0xc, 0xdb, 0xb0, 0xf5, 0x8c, 0x95, 0x89, 0xb6, + 0xca, 0x2, 0x0, 0x0, 0x38, 0x47, 0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, + 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x0, 0x3d, 0x55, 0x89, 0xe0, 0xf7, 0xc0}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8e, 0xa0, 0xca, 0xed, 0x66, 0xba, 0xca, 0x46, 0x63, 0x31, - 0x70, 0x5c, 0x6, 0xe7, 0x4a, 0xc1, 0x25, 0xfa, 0x6b, 0x6c}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + uint8_t exp_topic_bytes[] = {0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, + 0xa3, 0xbe, 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, + 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 10342); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\192\226\177\DC3\178\200n\184h\162\210\RS\153\149\253\&1\132\250\156\\\190\ETB\149 \192\247C\203", _pubPktID = 0, -// _pubBody = "\243(topic.data), 28); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(packet_id, 18773); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "Q\144\172\176:\255\255\236\209\134\204", _pubPktID = 29463, _pubBody = -// "\135s\STX\155A\v\217\&8\EOT^,\220\194\183\195\251\223H9g\164", _pubProps = [PropSubscriptionIdentifierAvailable -// 1,PropSharedSubscriptionAvailable 127,PropAssignedClientIdentifier -// "\SI\NULB[\DC3\137\155\255\ENQ\SUBqa\DC3\234%\158\184\200\129\155",PropSubscriptionIdentifierAvailable -// 246,PropTopicAliasMaximum 4016,PropTopicAliasMaximum 9506]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\194", _pubPktID = 0, _pubBody = +// "\251\145\"\229\t+\230\175\144\209p\ETX^\217KR\195", _pubProps = [PropResponseTopic +// "\195\GS\250\"\175\133\fN\SO#=\199fBU4",PropResponseInformation "\236\207?\DC1\194+\239\&4",PropTopicAlias +// 23167,PropSubscriptionIdentifierAvailable 113,PropUserProperty "\200\181\130\173K]\179\DEL>\SYN\EOTM\FS\186V" +// "p@N\FS\250\ETB,\214\185:\\\171",PropResponseInformation +// "\228\&3B\157\225\189\212\STXz~\229x\255\129^\237\156m\vj\181\213\STX\128\144\SUBB\205",PropRequestProblemInformation +// 131,PropReasonString ",\167\249h\215*\174\138\216\129\161\233\SUB",PropSharedSubscriptionAvailable +// 145,PropCorrelationData +// "I\b\179zw\197\246j\209\171\255\SUBm\138\174\f\129\145y\239\155",PropRequestProblemInformation 70,PropReasonString +// "l",PropMessageExpiryInterval 25951,PropResponseInformation +// "\142\149\130_W\180g\148\"\SYN>\221\194i\DC2w\148\162/\210\169}\251t\SOH#\NUL\195v3",PropSharedSubscriptionAvailable +// 144,PropWildcardSubscriptionAvailable 11,PropReceiveMaximum 16763]} TEST(Publish5QCTest, Encode19) { - uint8_t pkt[] = {0x3b, 0x48, 0x0, 0xb, 0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc, - 0x73, 0x17, 0x23, 0x29, 0x1, 0x2a, 0x7f, 0x12, 0x0, 0x14, 0xf, 0x0, 0x42, 0x5b, 0x13, - 0x89, 0x9b, 0xff, 0x5, 0x1a, 0x71, 0x61, 0x13, 0xea, 0x25, 0x9e, 0xb8, 0xc8, 0x81, 0x9b, - 0x29, 0xf6, 0x22, 0xf, 0xb0, 0x22, 0x25, 0x22, 0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, - 0x38, 0x4, 0x5e, 0x2c, 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; - uint8_t topic_bytes[] = {0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0xd8, 0x1, 0x0, 0x2, 0xdd, 0xc2, 0xc1, 0x1, 0x8, 0x0, 0x10, 0xc3, 0x1d, 0xfa, 0x22, 0xaf, + 0x85, 0xc, 0x4e, 0xe, 0x23, 0x3d, 0xc7, 0x66, 0x42, 0x55, 0x34, 0x1a, 0x0, 0x8, 0xec, 0xcf, 0x3f, + 0x11, 0xc2, 0x2b, 0xef, 0x34, 0x23, 0x5a, 0x7f, 0x29, 0x71, 0x26, 0x0, 0xf, 0xc8, 0xb5, 0x82, 0xad, + 0x4b, 0x5d, 0xb3, 0x7f, 0x3e, 0x16, 0x4, 0x4d, 0x1c, 0xba, 0x56, 0x0, 0xc, 0x70, 0x40, 0x4e, 0x1c, + 0xfa, 0x17, 0x2c, 0xd6, 0xb9, 0x3a, 0x5c, 0xab, 0x1a, 0x0, 0x1c, 0xe4, 0x33, 0x42, 0x9d, 0xe1, 0xbd, + 0xd4, 0x2, 0x7a, 0x7e, 0xe5, 0x78, 0xff, 0x81, 0x5e, 0xed, 0x9c, 0x6d, 0xb, 0x6a, 0xb5, 0xd5, 0x2, + 0x80, 0x90, 0x1a, 0x42, 0xcd, 0x17, 0x83, 0x1f, 0x0, 0xd, 0x2c, 0xa7, 0xf9, 0x68, 0xd7, 0x2a, 0xae, + 0x8a, 0xd8, 0x81, 0xa1, 0xe9, 0x1a, 0x2a, 0x91, 0x9, 0x0, 0x15, 0x49, 0x8, 0xb3, 0x7a, 0x77, 0xc5, + 0xf6, 0x6a, 0xd1, 0xab, 0xff, 0x1a, 0x6d, 0x8a, 0xae, 0xc, 0x81, 0x91, 0x79, 0xef, 0x9b, 0x17, 0x46, + 0x1f, 0x0, 0x1, 0x6c, 0x2, 0x0, 0x0, 0x65, 0x5f, 0x1a, 0x0, 0x1e, 0x8e, 0x95, 0x82, 0x5f, 0x57, + 0xb4, 0x67, 0x94, 0x22, 0x16, 0x3e, 0xdd, 0xc2, 0x69, 0x12, 0x77, 0x94, 0xa2, 0x2f, 0xd2, 0xa9, 0x7d, + 0xfb, 0x74, 0x1, 0x23, 0x0, 0xc3, 0x76, 0x33, 0x2a, 0x90, 0x28, 0xb, 0x21, 0x41, 0x7b, 0xfb, 0x91, + 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; + uint8_t topic_bytes[] = {0xdd, 0xc2}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, 0x5e, 0x2c, - 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; + uint8_t msg_bytes[] = {0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, + 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - - uint8_t bytesprops0[] = {0xf, 0x0, 0x42, 0x5b, 0x13, 0x89, 0x9b, 0xff, 0x5, 0x1a, - 0x71, 0x61, 0x13, 0xea, 0x25, 0x9e, 0xb8, 0xc8, 0x81, 0x9b}; + msg.payload_len = 17; + + uint8_t bytesprops0[] = {0xc3, 0x1d, 0xfa, 0x22, 0xaf, 0x85, 0xc, 0x4e, + 0xe, 0x23, 0x3d, 0xc7, 0x66, 0x42, 0x55, 0x34}; + uint8_t bytesprops1[] = {0xec, 0xcf, 0x3f, 0x11, 0xc2, 0x2b, 0xef, 0x34}; + uint8_t bytesprops3[] = {0x70, 0x40, 0x4e, 0x1c, 0xfa, 0x17, 0x2c, 0xd6, 0xb9, 0x3a, 0x5c, 0xab}; + uint8_t bytesprops2[] = {0xc8, 0xb5, 0x82, 0xad, 0x4b, 0x5d, 0xb3, 0x7f, 0x3e, 0x16, 0x4, 0x4d, 0x1c, 0xba, 0x56}; + uint8_t bytesprops4[] = {0xe4, 0x33, 0x42, 0x9d, 0xe1, 0xbd, 0xd4, 0x2, 0x7a, 0x7e, 0xe5, 0x78, 0xff, 0x81, + 0x5e, 0xed, 0x9c, 0x6d, 0xb, 0x6a, 0xb5, 0xd5, 0x2, 0x80, 0x90, 0x1a, 0x42, 0xcd}; + uint8_t bytesprops5[] = {0x2c, 0xa7, 0xf9, 0x68, 0xd7, 0x2a, 0xae, 0x8a, 0xd8, 0x81, 0xa1, 0xe9, 0x1a}; + uint8_t bytesprops6[] = {0x49, 0x8, 0xb3, 0x7a, 0x77, 0xc5, 0xf6, 0x6a, 0xd1, 0xab, 0xff, + 0x1a, 0x6d, 0x8a, 0xae, 0xc, 0x81, 0x91, 0x79, 0xef, 0x9b}; + uint8_t bytesprops7[] = {0x6c}; + uint8_t bytesprops8[] = {0x8e, 0x95, 0x82, 0x5f, 0x57, 0xb4, 0x67, 0x94, 0x22, 0x16, 0x3e, 0xdd, 0xc2, 0x69, 0x12, + 0x77, 0x94, 0xa2, 0x2f, 0xd2, 0xa9, 0x7d, 0xfb, 0x74, 0x1, 0x23, 0x0, 0xc3, 0x76, 0x33}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4016}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9506}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23167}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops2}, .v = {12, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25951}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16763}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29463, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "Q\144\172\176:\255\255\236\209\134\204", _pubPktID = 29463, _pubBody = -// "\135s\STX\155A\v\217\&8\EOT^,\220\194\183\195\251\223H9g\164", _pubProps = [PropSubscriptionIdentifierAvailable -// 1,PropSharedSubscriptionAvailable 127,PropAssignedClientIdentifier -// "\SI\NULB[\DC3\137\155\255\ENQ\SUBqa\DC3\234%\158\184\200\129\155",PropSubscriptionIdentifierAvailable -// 246,PropTopicAliasMaximum 4016,PropTopicAliasMaximum 9506]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\194", _pubPktID = 0, _pubBody = +// "\251\145\"\229\t+\230\175\144\209p\ETX^\217KR\195", _pubProps = [PropResponseTopic +// "\195\GS\250\"\175\133\fN\SO#=\199fBU4",PropResponseInformation "\236\207?\DC1\194+\239\&4",PropTopicAlias +// 23167,PropSubscriptionIdentifierAvailable 113,PropUserProperty "\200\181\130\173K]\179\DEL>\SYN\EOTM\FS\186V" +// "p@N\FS\250\ETB,\214\185:\\\171",PropResponseInformation +// "\228\&3B\157\225\189\212\STXz~\229x\255\129^\237\156m\vj\181\213\STX\128\144\SUBB\205",PropRequestProblemInformation +// 131,PropReasonString ",\167\249h\215*\174\138\216\129\161\233\SUB",PropSharedSubscriptionAvailable +// 145,PropCorrelationData +// "I\b\179zw\197\246j\209\171\255\SUBm\138\174\f\129\145y\239\155",PropRequestProblemInformation 70,PropReasonString +// "l",PropMessageExpiryInterval 25951,PropResponseInformation +// "\142\149\130_W\180g\148\"\SYN>\221\194i\DC2w\148\162/\210\169}\251t\SOH#\NUL\195v3",PropSharedSubscriptionAvailable +// 144,PropWildcardSubscriptionAvailable 11,PropReceiveMaximum 16763]} TEST(Publish5QCTest, Decode19) { - uint8_t pkt[] = {0x3b, 0x48, 0x0, 0xb, 0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc, - 0x73,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 0x2a, 0x91, 0x9, 0x0, 0x15, 0x49, 0x8, 0xb3, 0x7a, 0x77, 0xc5, + 0xf6, 0x6a, 0xd1, 0xab, 0xff, 0x1a, 0x6d, 0x8a, 0xae, 0xc, 0x81, 0x91, 0x79, 0xef, 0x9b, 0x17, 0x46, + 0x1f, 0x0, 0x1, 0x6c, 0x2, 0x0, 0x0, 0x65, 0x5f, 0x1a, 0x0, 0x1e, 0x8e, 0x95, 0x82, 0x5f, 0x57, + 0xb4, 0x67, 0x94, 0x22, 0x16, 0x3e, 0xdd, 0xc2, 0x69, 0x12, 0x77, 0x94, 0xa2, 0x2f, 0xd2, 0xa9, 0x7d, + 0xfb, 0x74, 0x1, 0x23, 0x0, 0xc3, 0x76, 0x33, 0x2a, 0x90, 0x28, 0xb, 0x21, 0x41, 0x7b, 0xfb, 0x91, + 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x51, 0x90, 0xac, 0xb0, 0x3a, 0xff, 0xff, 0xec, 0xd1, 0x86, 0xcc}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x87, 0x73, 0x2, 0x9b, 0x41, 0xb, 0xd9, 0x38, 0x4, 0x5e, 0x2c, - 0xdc, 0xc2, 0xb7, 0xc3, 0xfb, 0xdf, 0x48, 0x39, 0x67, 0xa4}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0xdd, 0xc2}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, + 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29463); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\220\&2\138\ETX\145\167\209n\146\EOT\ACK\187\213\216b\156\231@\149\194\129", _pubPktID = 25900, _pubBody = "+;\SYN", -// _pubProps = [PropAuthenticationMethod "\195\EOT\243\165\152",PropSubscriptionIdentifierAvailable -// 98,PropAuthenticationMethod "\215\SI\221\162#\222\249#\131",PropReasonString -// "u\140\147\SYN\247ur\254\171\128\227R\ENQ\231\"\rG\225\198\217\205G/\173",PropResponseInformation -// "\206P\163",PropReasonString "(UAe\DEL\234\160\&4R\GS#q\218L\DC4\135H\129",PropSubscriptionIdentifierAvailable -// 81,PropResponseInformation "\232\189",PropAssignedClientIdentifier "\228.B\224Ey$g\202f",PropAuthenticationData -// "\149\ACK\139'\236\239m\191",PropMaximumQoS 220,PropAssignedClientIdentifier -// "b@\DEL\EM\144[-\181\162\157\199=\204",PropAuthenticationMethod -// "\169\&6\a\197\ACKV{C~\ACK\166\216u",PropServerReference -// "\148w%aR,\ENQh=1K\DC2\252\251\132\166LA",PropAssignedClientIdentifier "/\212]\208",PropReceiveMaximum 28597]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\253\&0\CANabo\DC3\254\241\240\244{\194\r)2\133Gj\233%", _pubPktID = 23762, _pubBody = "\224", _pubProps = +// [PropWildcardSubscriptionAvailable 107,PropResponseTopic "\164&\169\232l\231$P)O.Fu\224\US\214\145H\253 +// \195\131oL\160A%",PropTopicAlias 20811,PropRequestResponseInformation 179,PropRequestProblemInformation +// 128,PropSubscriptionIdentifier 11,PropTopicAliasMaximum 12610,PropSessionExpiryInterval 20293,PropAuthenticationData +// "\"\131p@f\ETBb>\214\189\222\DC3M",PropSessionExpiryInterval 6338,PropSharedSubscriptionAvailable +// 90,PropRequestResponseInformation 113,PropPayloadFormatIndicator 89,PropAssignedClientIdentifier +// "\188j^\248",PropMessageExpiryInterval 24560,PropPayloadFormatIndicator 139,PropUserProperty +// "}\136\171\228\224\190\177\STX7\253V\193\160\222\t\194\DC2%\193\188e1y\129\r\240" +// "6Yo\160R",PropSubscriptionIdentifier 30,PropReasonString +// "Y,\151\173!\131\143\211\208\248\220\140\149",PropPayloadFormatIndicator 218,PropUserProperty "\DC4\249\196\128\255" +// "mf\141\&9i|\RS\211\&1\136I\129\253\STX\134e:\192\185\EM\ETX\240\205p\133\255\153\&94",PropSubscriptionIdentifierAvailable +// 34,PropResponseTopic +// "4C\v\251\180\171x\185\189;X\163\148\NUL\170\STX\172\205K)\173=J\143\t\141\189",PropReceiveMaximum 2967]} TEST(Publish5QCTest, Encode20) { - uint8_t pkt[] = { - 0x34, 0xca, 0x1, 0x0, 0x15, 0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, 0xb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, 0x59, 0x2c, 0x97, 0xad, 0x21, 0x83, 0x8f, 0xd3, 0xd0, + 0xf8, 0xdc, 0x8c, 0x95, 0x1, 0xda, 0x26, 0x0, 0x5, 0x14, 0xf9, 0xc4, 0x80, 0xff, 0x0, 0x1d, 0x6d, + 0x66, 0x8d, 0x39, 0x69, 0x7c, 0x1e, 0xd3, 0x31, 0x88, 0x49, 0x81, 0xfd, 0x2, 0x86, 0x65, 0x3a, 0xc0, + 0xb9, 0x19, 0x3, 0xf0, 0xcd, 0x70, 0x85, 0xff, 0x99, 0x39, 0x34, 0x29, 0x22, 0x8, 0x0, 0x1b, 0x34, + 0x43, 0xb, 0xfb, 0xb4, 0xab, 0x78, 0xb9, 0xbd, 0x3b, 0x58, 0xa3, 0x94, 0x0, 0xaa, 0x2, 0xac, 0xcd, + 0x4b, 0x29, 0xad, 0x3d, 0x4a, 0x8f, 0x9, 0x8d, 0xbd, 0x21, 0xb, 0x97, 0xe0}; + uint8_t topic_bytes[] = {0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, 0xf4, + 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25}; lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x2b, 0x3b, 0x16}; + msg.retained = true; + uint8_t msg_bytes[] = {0xe0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 1; - uint8_t bytesprops0[] = {0xc3, 0x4, 0xf3, 0xa5, 0x98}; - uint8_t bytesprops1[] = {0xd7, 0xf, 0xdd, 0xa2, 0x23, 0xde, 0xf9, 0x23, 0x83}; - uint8_t bytesprops2[] = {0x75, 0x8c, 0x93, 0x16, 0xf7, 0x75, 0x72, 0xfe, 0xab, 0x80, 0xe3, 0x52, - 0x5, 0xe7, 0x22, 0xd, 0x47, 0xe1, 0xc6, 0xd9, 0xcd, 0x47, 0x2f, 0xad}; - uint8_t bytesprops3[] = {0xce, 0x50, 0xa3}; - uint8_t bytesprops4[] = {0x28, 0x55, 0x41, 0x65, 0x7f, 0xea, 0xa0, 0x34, 0x52, - 0x1d, 0x23, 0x71, 0xda, 0x4c, 0x14, 0x87, 0x48, 0x81}; - uint8_t bytesprops5[] = {0xe8, 0xbd}; - uint8_t bytesprops6[] = {0xe4, 0x2e, 0x42, 0xe0, 0x45, 0x79, 0x24, 0x67, 0xca, 0x66}; - uint8_t bytesprops7[] = {0x95, 0x6, 0x8b, 0x27, 0xec, 0xef, 0x6d, 0xbf}; - uint8_t bytesprops8[] = {0x62, 0x40, 0x7f, 0x19, 0x90, 0x5b, 0x2d, 0xb5, 0xa2, 0x9d, 0xc7, 0x3d, 0xcc}; - uint8_t bytesprops9[] = {0xa9, 0x36, 0x7, 0xc5, 0x6, 0x56, 0x7b, 0x43, 0x7e, 0x6, 0xa6, 0xd8, 0x75}; - uint8_t bytesprops10[] = {0x94, 0x77, 0x25, 0x61, 0x52, 0x2c, 0x5, 0x68, 0x3d, - 0x31, 0x4b, 0x12, 0xfc, 0xfb, 0x84, 0xa6, 0x4c, 0x41}; - uint8_t bytesprops11[] = {0x2f, 0xd4, 0x5d, 0xd0}; + uint8_t bytesprops0[] = {0xa4, 0x26, 0xa9, 0xe8, 0x6c, 0xe7, 0x24, 0x50, 0x29, 0x4f, 0x2e, 0x46, 0x75, 0xe0, + 0x1f, 0xd6, 0x91, 0x48, 0xfd, 0x20, 0xc3, 0x83, 0x6f, 0x4c, 0xa0, 0x41, 0x25}; + uint8_t bytesprops1[] = {0x22, 0x83, 0x70, 0x40, 0x66, 0x17, 0x62, 0x3e, 0xd6, 0xbd, 0xde, 0x13, 0x4d}; + uint8_t bytesprops2[] = {0xbc, 0x6a, 0x5e, 0xf8}; + uint8_t bytesprops4[] = {0x36, 0x59, 0x6f, 0xa0, 0x52}; + uint8_t bytesprops3[] = {0x7d, 0x88, 0xab, 0xe4, 0xe0, 0xbe, 0xb1, 0x2, 0x37, 0xfd, 0x56, 0xc1, 0xa0, + 0xde, 0x9, 0xc2, 0x12, 0x25, 0xc1, 0xbc, 0x65, 0x31, 0x79, 0x81, 0xd, 0xf0}; + uint8_t bytesprops5[] = {0x59, 0x2c, 0x97, 0xad, 0x21, 0x83, 0x8f, 0xd3, 0xd0, 0xf8, 0xdc, 0x8c, 0x95}; + uint8_t bytesprops7[] = {0x6d, 0x66, 0x8d, 0x39, 0x69, 0x7c, 0x1e, 0xd3, 0x31, 0x88, 0x49, 0x81, 0xfd, 0x2, 0x86, + 0x65, 0x3a, 0xc0, 0xb9, 0x19, 0x3, 0xf0, 0xcd, 0x70, 0x85, 0xff, 0x99, 0x39, 0x34}; + uint8_t bytesprops6[] = {0x14, 0xf9, 0xc4, 0x80, 0xff}; + uint8_t bytesprops8[] = {0x34, 0x43, 0xb, 0xfb, 0xb4, 0xab, 0x78, 0xb9, 0xbd, 0x3b, 0x58, 0xa3, 0x94, 0x0, + 0xaa, 0x2, 0xac, 0xcd, 0x4b, 0x29, 0xad, 0x3d, 0x4a, 0x8f, 0x9, 0x8d, 0xbd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28597}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20811}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12610}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20293}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6338}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24560}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops6}, .v = {29, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2967}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 25900, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 23762, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\220\&2\138\ETX\145\167\209n\146\EOT\ACK\187\213\216b\156\231@\149\194\129", _pubPktID = 25900, _pubBody = "+;\SYN", -// _pubProps = [PropAuthenticationMethod "\195\EOT\243\165\152",PropSubscriptionIdentifierAvailable -// 98,PropAuthenticationMethod "\215\SI\221\162#\222\249#\131",PropReasonString -// "u\140\147\SYN\247ur\254\171\128\227R\ENQ\231\"\rG\225\198\217\205G/\173",PropResponseInformation -// "\206P\163",PropReasonString "(UAe\DEL\234\160\&4R\GS#q\218L\DC4\135H\129",PropSubscriptionIdentifierAvailable -// 81,PropResponseInformation "\232\189",PropAssignedClientIdentifier "\228.B\224Ey$g\202f",PropAuthenticationData -// "\149\ACK\139'\236\239m\191",PropMaximumQoS 220,PropAssignedClientIdentifier -// "b@\DEL\EM\144[-\181\162\157\199=\204",PropAuthenticationMethod -// "\169\&6\a\197\ACKV{C~\ACK\166\216u",PropServerReference -// "\148w%aR,\ENQh=1K\DC2\252\251\132\166LA",PropAssignedClientIdentifier "/\212]\208",PropReceiveMaximum 28597]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\253\&0\CANabo\DC3\254\241\240\244{\194\r)2\133Gj\233%", _pubPktID = 23762, _pubBody = "\224", _pubProps = +// [PropWildcardSubscriptionAvailable 107,PropResponseTopic "\164&\169\232l\231$P)O.Fu\224\US\214\145H\253 +// \195\131oL\160A%",PropTopicAlias 20811,PropRequestResponseInformation 179,PropRequestProblemInformation +// 128,PropSubscriptionIdentifier 11,PropTopicAliasMaximum 12610,PropSessionExpiryInterval 20293,PropAuthenticationData +// "\"\131p@f\ETBb>\214\189\222\DC3M",PropSessionExpiryInterval 6338,PropSharedSubscriptionAvailable +// 90,PropRequestResponseInformation 113,PropPayloadFormatIndicator 89,PropAssignedClientIdentifier +// "\188j^\248",PropMessageExpiryInterval 24560,PropPayloadFormatIndicator 139,PropUserProperty +// "}\136\171\228\224\190\177\STX7\253V\193\160\222\t\194\DC2%\193\188e1y\129\r\240" +// "6Yo\160R",PropSubscriptionIdentifier 30,PropReasonString +// "Y,\151\173!\131\143\211\208\248\220\140\149",PropPayloadFormatIndicator 218,PropUserProperty "\DC4\249\196\128\255" +// "mf\141\&9i|\RS\211\&1\136I\129\253\STX\134e:\192\185\EM\ETX\240\205p\133\255\153\&94",PropSubscriptionIdentifierAvailable +// 34,PropResponseTopic +// "4C\v\251\180\171x\185\189;X\163\148\NUL\170\STX\172\205K)\173=J\143\t\141\189",PropReceiveMaximum 2967]} TEST(Publish5QCTest, Decode20) { - uint8_t pkt[] = { - 0x34, 0xca, 0x1, 0x0, 0x15, 0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, 0xbb, 0xd5, 0xd8, - 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81, 0x65, 0x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0x49, 0x81, 0xfd, 0x2, 0x86, 0x65, 0x3a, 0xc0, + 0xb9, 0x19, 0x3, 0xf0, 0xcd, 0x70, 0x85, 0xff, 0x99, 0x39, 0x34, 0x29, 0x22, 0x8, 0x0, 0x1b, 0x34, + 0x43, 0xb, 0xfb, 0xb4, 0xab, 0x78, 0xb9, 0xbd, 0x3b, 0x58, 0xa3, 0x94, 0x0, 0xaa, 0x2, 0xac, 0xcd, + 0x4b, 0x29, 0xad, 0x3d, 0x4a, 0x8f, 0x9, 0x8d, 0xbd, 0x21, 0xb, 0x97, 0xe0}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xdc, 0x32, 0x8a, 0x3, 0x91, 0xa7, 0xd1, 0x6e, 0x92, 0x4, 0x6, - 0xbb, 0xd5, 0xd8, 0x62, 0x9c, 0xe7, 0x40, 0x95, 0xc2, 0x81}; + uint8_t exp_topic_bytes[] = {0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, 0xf4, + 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25}; lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2b, 0x3b, 0x16}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + uint8_t exp_body_bytes[] = {0xe0}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 25900); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 23762); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\224", _pubPktID = 936, _pubBody = -// "6\245", _pubProps = [PropReasonString "\166\240\229cSm\228\224\238\155\244\a(\172",PropResponseInformation -// "\\\186\146\160mi\GS\217\ETXf\DEL\228\160\183\156\204\&7\a\152\232\179\253\182\246",PropAuthenticationData -// "\243*\210\USHX\142\129\193\167o\235}c\199\141",PropCorrelationData "\166\203\246\255\206@\180\228\188\EM7\211v -// ",PropSharedSubscriptionAvailable 173,PropSharedSubscriptionAvailable 56,PropWillDelayInterval -// 2519,PropAssignedClientIdentifier "",PropMaximumQoS 178,PropResponseInformation -// "\160n\142\131\154}\138\192\ETB}",PropUserProperty -// "8?\242\247\156CD\"\192\&4\222\175U\207&\186\231j\190Rx\202\220\151\192?\215\162" -// "\229'\225\142s\204\144\195\235*O\SOH8\a;8\183",PropWildcardSubscriptionAvailable 173,PropRetainAvailable -// 124,PropResponseInformation -// "\DLE)\214\150;\SO\249-.\150%\159\ETX@\SYN\131\ACK\229\248\ESC\208\&4s\182\ETB[A\r\187\235",PropUserProperty -// "\216\188\208\242\r\SUB\234\133\254\RS\254V\178T" -// "\174\142V^C\145\&0\DELy\176w\141\174\138i\251~\\Ui\132'",PropMaximumQoS 247]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC1\DC4:", _pubPktID = 0, _pubBody = +// "V\144J\230\153\132\164\SO", _pubProps = [PropMaximumQoS 226,PropMaximumPacketSize 24860,PropAssignedClientIdentifier +// "\159(topic.data), 1); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 8); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "E\177\160\226\133O\252!\"\251\129\164{\STX\178\165g\229E\168\162\209>N\STXWn\191\235", _pubPktID = 0, _pubBody = -// "t\139\164\144a\157:\239\157\145M\SI\t\162\DC1\194D\143\134", _pubProps = [PropContentType -// "\aB\249\179\ESC\SOH\193\252\164f\136\224",PropRequestResponseInformation 214,PropReceiveMaximum -// 4070,PropSubscriptionIdentifierAvailable 193,PropRequestProblemInformation 237,PropSharedSubscriptionAvailable -// 176,PropPayloadFormatIndicator 69,PropSessionExpiryInterval 30221,PropSubscriptionIdentifierAvailable -// 79,PropMessageExpiryInterval 25509,PropAuthenticationData -// "\131\231\181\168G\US>\238V\138\\F>B|\133\233\175",PropTopicAliasMaximum 2402,PropRetainAvailable 204]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "6\USp^\205\245IA +// \ETB+\158\220\216ea[,\180\190\&1\DLE\183\198\217", _pubPktID = 25164, _pubBody = +// "\155\145\198\173f\139:a\195\141sE}\221\223\243\145\224*\180\vSEy{\166\178\148`", _pubProps = [PropCorrelationData +// "\230\194/G;\134Y\155\163Z\NUL"]} TEST(Publish5QCTest, Encode22) { - uint8_t pkt[] = {0x30, 0x75, 0x0, 0x1d, 0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, - 0xa4, 0x7b, 0x2, 0xb2, 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, - 0x6e, 0xbf, 0xeb, 0x42, 0x3, 0x0, 0xc, 0x7, 0x42, 0xf9, 0xb3, 0x1b, 0x1, 0xc1, 0xfc, - 0xa4, 0x66, 0x88, 0xe0, 0x19, 0xd6, 0x21, 0xf, 0xe6, 0x29, 0xc1, 0x17, 0xed, 0x2a, 0xb0, - 0x1, 0x45, 0x11, 0x0, 0x0, 0x76, 0xd, 0x29, 0x4f, 0x2, 0x0, 0x0, 0x63, 0xa5, 0x16, - 0x0, 0x12, 0x83, 0xe7, 0xb5, 0xa8, 0x47, 0x1f, 0x3e, 0xee, 0x56, 0x8a, 0x5c, 0x46, 0x3e, - 0x42, 0x7c, 0x85, 0xe9, 0xaf, 0x22, 0x9, 0x62, 0x25, 0xcc, 0x74, 0x8b, 0xa4, 0x90, 0x61, - 0x9d, 0x3a, 0xef, 0x9d, 0x91, 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; - uint8_t topic_bytes[] = {0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, - 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x49, 0x0, 0x19, 0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, + 0x9e, 0xdc, 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9, 0x62, + 0x4c, 0xe, 0x9, 0x0, 0xb, 0xe6, 0xc2, 0x2f, 0x47, 0x3b, 0x86, 0x59, 0x9b, 0xa3, 0x5a, + 0x0, 0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, + 0xdf, 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; + uint8_t topic_bytes[] = {0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, 0x9e, 0xdc, + 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, 0x3a, 0xef, 0x9d, 0x91, - 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, 0xdf, + 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; - uint8_t bytesprops0[] = {0x7, 0x42, 0xf9, 0xb3, 0x1b, 0x1, 0xc1, 0xfc, 0xa4, 0x66, 0x88, 0xe0}; - uint8_t bytesprops1[] = {0x83, 0xe7, 0xb5, 0xa8, 0x47, 0x1f, 0x3e, 0xee, 0x56, - 0x8a, 0x5c, 0x46, 0x3e, 0x42, 0x7c, 0x85, 0xe9, 0xaf}; + uint8_t bytesprops0[] = {0xe6, 0xc2, 0x2f, 0x47, 0x3b, 0x86, 0x59, 0x9b, 0xa3, 0x5a, 0x0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4070}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30221}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25509}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2402}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 25164, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "E\177\160\226\133O\252!\"\251\129\164{\STX\178\165g\229E\168\162\209>N\STXWn\191\235", _pubPktID = 0, _pubBody = -// "t\139\164\144a\157:\239\157\145M\SI\t\162\DC1\194D\143\134", _pubProps = [PropContentType -// "\aB\249\179\ESC\SOH\193\252\164f\136\224",PropRequestResponseInformation 214,PropReceiveMaximum -// 4070,PropSubscriptionIdentifierAvailable 193,PropRequestProblemInformation 237,PropSharedSubscriptionAvailable -// 176,PropPayloadFormatIndicator 69,PropSessionExpiryInterval 30221,PropSubscriptionIdentifierAvailable -// 79,PropMessageExpiryInterval 25509,PropAuthenticationData -// "\131\231\181\168G\US>\238V\138\\F>B|\133\233\175",PropTopicAliasMaximum 2402,PropRetainAvailable 204]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "6\USp^\205\245IA +// \ETB+\158\220\216ea[,\180\190\&1\DLE\183\198\217", _pubPktID = 25164, _pubBody = +// "\155\145\198\173f\139:a\195\141sE}\221\223\243\145\224*\180\vSEy{\166\178\148`", _pubProps = [PropCorrelationData +// "\230\194/G;\134Y\155\163Z\NUL"]} TEST(Publish5QCTest, Decode22) { - uint8_t pkt[] = {0x30, 0x75, 0x0, 0x1d, 0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, - 0xa4, 0x7b, 0x2, 0xb2, 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, - 0x6e, 0xbf, 0xeb, 0x42, 0x3, 0x0, 0xc, 0x7, 0x42, 0xf9, 0xb3, 0x1b, 0x1, 0xc1, 0xfc, - 0xa4, 0x66, 0x88, 0xe0, 0x19, 0xd6, 0x21, 0xf, 0xe6, 0x29, 0xc1, 0x17, 0xed, 0x2a, 0xb0, - 0x1, 0x45, 0x11, 0x0, 0x0, 0x76, 0xd, 0x29, 0x4f, 0x2, 0x0, 0x0, 0x63, 0xa5, 0x16, - 0x0, 0x12, 0x83, 0xe7, 0xb5, 0xa8, 0x47, 0x1f, 0x3e, 0xee, 0x56, 0x8a, 0x5c, 0x46, 0x3e, - 0x42, 0x7c, 0x85, 0xe9, 0xaf, 0x22, 0x9, 0x62, 0x25, 0xcc, 0x74, 0x8b, 0xa4, 0x90, 0x61, - 0x9d, 0x3a, 0xef, 0x9d, 0x91, 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; + uint8_t pkt[] = {0x33, 0x49, 0x0, 0x19, 0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, + 0x9e, 0xdc, 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9, 0x62, + 0x4c, 0xe, 0x9, 0x0, 0xb, 0xe6, 0xc2, 0x2f, 0x47, 0x3b, 0x86, 0x59, 0x9b, 0xa3, 0x5a, + 0x0, 0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, + 0xdf, 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x45, 0xb1, 0xa0, 0xe2, 0x85, 0x4f, 0xfc, 0x21, 0x22, 0xfb, 0x81, 0xa4, 0x7b, 0x2, 0xb2, - 0xa5, 0x67, 0xe5, 0x45, 0xa8, 0xa2, 0xd1, 0x3e, 0x4e, 0x2, 0x57, 0x6e, 0xbf, 0xeb}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x74, 0x8b, 0xa4, 0x90, 0x61, 0x9d, 0x3a, 0xef, 0x9d, 0x91, - 0x4d, 0xf, 0x9, 0xa2, 0x11, 0xc2, 0x44, 0x8f, 0x86}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, 0x9e, 0xdc, + 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, 0xdf, + 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 25164); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\208\167\232\STX\DLE\GSQr\146|", -// _pubPktID = 8189, _pubBody = "c`\ESC\156x\229(\255\178\168\214\240a\217\197\224\170\174\&48pk\NAK\200\ETX\130\235", -// _pubProps = [PropPayloadFormatIndicator 219,PropServerKeepAlive 25155,PropCorrelationData -// "\v\224\240\182",PropRetainAvailable 10,PropAssignedClientIdentifier -// "\173\DEL\168\159v\DLEi\203\212\235@\221\181c\129\178\201\251\135\NUL\190\188bc>\195c",PropTopicAlias -// 18173,PropSessionExpiryInterval 627,PropResponseInformation "[j\202B\212|\237\252\207",PropRequestResponseInformation -// 209]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\178\&7A\251\143\146\159\171\130\211\146\190g", _pubPktID = 0, _pubBody = "", _pubProps = [PropMessageExpiryInterval +// 18622,PropAssignedClientIdentifier "e\164\154\171\184\215\140w\181Dr"]} TEST(Publish5QCTest, Encode23) { - uint8_t pkt[] = {0x3a, 0x6c, 0x0, 0xa, 0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c, 0x1f, 0xfd, - 0x42, 0x1, 0xdb, 0x13, 0x62, 0x43, 0x9, 0x0, 0x4, 0xb, 0xe0, 0xf0, 0xb6, 0x25, 0xa, 0x12, - 0x0, 0x1b, 0xad, 0x7f, 0xa8, 0x9f, 0x76, 0x10, 0x69, 0xcb, 0xd4, 0xeb, 0x40, 0xdd, 0xb5, 0x63, - 0x81, 0xb2, 0xc9, 0xfb, 0x87, 0x0, 0xbe, 0xbc, 0x62, 0x63, 0x3e, 0xc3, 0x63, 0x23, 0x46, 0xfd, - 0x11, 0x0, 0x0, 0x2, 0x73, 0x1a, 0x0, 0x9, 0x5b, 0x6a, 0xca, 0x42, 0xd4, 0x7c, 0xed, 0xfc, - 0xcf, 0x19, 0xd1, 0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, - 0xd9, 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; - uint8_t topic_bytes[] = {0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x23, 0x0, 0xd, 0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, + 0xd3, 0x92, 0xbe, 0x67, 0x13, 0x2, 0x0, 0x0, 0x48, 0xbe, 0x12, 0x0, 0xb, + 0x65, 0xa4, 0x9a, 0xab, 0xb8, 0xd7, 0x8c, 0x77, 0xb5, 0x44, 0x72}; + uint8_t topic_bytes[] = {0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, - 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 27; + msg.payload_len = 0; - uint8_t bytesprops0[] = {0xb, 0xe0, 0xf0, 0xb6}; - uint8_t bytesprops1[] = {0xad, 0x7f, 0xa8, 0x9f, 0x76, 0x10, 0x69, 0xcb, 0xd4, 0xeb, 0x40, 0xdd, 0xb5, 0x63, - 0x81, 0xb2, 0xc9, 0xfb, 0x87, 0x0, 0xbe, 0xbc, 0x62, 0x63, 0x3e, 0xc3, 0x63}; - uint8_t bytesprops2[] = {0x5b, 0x6a, 0xca, 0x42, 0xd4, 0x7c, 0xed, 0xfc, 0xcf}; + uint8_t bytesprops0[] = {0x65, 0xa4, 0x9a, 0xab, 0xb8, 0xd7, 0x8c, 0x77, 0xb5, 0x44, 0x72}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25155}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18173}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 627}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18622}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 8189, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\208\167\232\STX\DLE\GSQr\146|", -// _pubPktID = 8189, _pubBody = "c`\ESC\156x\229(\255\178\168\214\240a\217\197\224\170\174\&48pk\NAK\200\ETX\130\235", -// _pubProps = [PropPayloadFormatIndicator 219,PropServerKeepAlive 25155,PropCorrelationData -// "\v\224\240\182",PropRetainAvailable 10,PropAssignedClientIdentifier -// "\173\DEL\168\159v\DLEi\203\212\235@\221\181c\129\178\201\251\135\NUL\190\188bc>\195c",PropTopicAlias -// 18173,PropSessionExpiryInterval 627,PropResponseInformation "[j\202B\212|\237\252\207",PropRequestResponseInformation -// 209]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\178\&7A\251\143\146\159\171\130\211\146\190g", _pubPktID = 0, _pubBody = "", _pubProps = [PropMessageExpiryInterval +// 18622,PropAssignedClientIdentifier "e\164\154\171\184\215\140w\181Dr"]} TEST(Publish5QCTest, Decode23) { - uint8_t pkt[] = {0x3a, 0x6c, 0x0, 0xa, 0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c, 0x1f, 0xfd, - 0x42, 0x1, 0xdb, 0x13, 0x62, 0x43, 0x9, 0x0, 0x4, 0xb, 0xe0, 0xf0, 0xb6, 0x25, 0xa, 0x12, - 0x0, 0x1b, 0xad, 0x7f, 0xa8, 0x9f, 0x76, 0x10, 0x69, 0xcb, 0xd4, 0xeb, 0x40, 0xdd, 0xb5, 0x63, - 0x81, 0xb2, 0xc9, 0xfb, 0x87, 0x0, 0xbe, 0xbc, 0x62, 0x63, 0x3e, 0xc3, 0x63, 0x23, 0x46, 0xfd, - 0x11, 0x0, 0x0, 0x2, 0x73, 0x1a, 0x0, 0x9, 0x5b, 0x6a, 0xca, 0x42, 0xd4, 0x7c, 0xed, 0xfc, - 0xcf, 0x19, 0xd1, 0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, - 0xd9, 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; + uint8_t pkt[] = {0x39, 0x23, 0x0, 0xd, 0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, + 0xd3, 0x92, 0xbe, 0x67, 0x13, 0x2, 0x0, 0x0, 0x48, 0xbe, 0x12, 0x0, 0xb, + 0x65, 0xa4, 0x9a, 0xab, 0xb8, 0xd7, 0x8c, 0x77, 0xb5, 0x44, 0x72}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xd0, 0xa7, 0xe8, 0x2, 0x10, 0x1d, 0x51, 0x72, 0x92, 0x7c}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x63, 0x60, 0x1b, 0x9c, 0x78, 0xe5, 0x28, 0xff, 0xb2, 0xa8, 0xd6, 0xf0, 0x61, 0xd9, - 0xc5, 0xe0, 0xaa, 0xae, 0x34, 0x38, 0x70, 0x6b, 0x15, 0xc8, 0x3, 0x82, 0xeb}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 8189); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 27); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "b\245\197\244\&04\214\&6*\178", -// _pubPktID = 0, _pubBody = "\184", _pubProps = [PropSubscriptionIdentifier 30,PropReasonString -// "7c\157K\v\162l\155?\162\133\203o\236\152!4\149\249\160\US\139\DEL^\130^\130",PropMessageExpiryInterval -// 346,PropTopicAliasMaximum 7985]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\198\161\148\238\191@\246\217\217\241\DC1\227\239", _pubPktID = 10944, _pubBody = "R3\160", _pubProps = +// [PropWildcardSubscriptionAvailable 84,PropTopicAliasMaximum 14373,PropResponseTopic +// "\163\NUL\243\131\211\147\148\158&.\r",PropServerKeepAlive 25898,PropMaximumPacketSize 7145,PropReceiveMaximum +// 29689,PropRequestProblemInformation 197,PropSubscriptionIdentifier 28,PropResponseTopic +// "\t\198\FS\130\144!\130F5\191\"u\211\161\147",PropTopicAlias 9274,PropRetainAvailable 33,PropReasonString +// "\189\DC2>FV=C\STX\ACKu\142\133\215\249\224\195\225*",PropSubscriptionIdentifierAvailable 131,PropServerReference +// "\244FB\203>p>",PropReceiveMaximum 8728,PropSubscriptionIdentifierAvailable 125,PropCorrelationData +// "\141\180\130g\166\221>\167\STX\140]\153\136k\135\135\STX\243\215\223"]} TEST(Publish5QCTest, Encode24) { - uint8_t pkt[] = {0x38, 0x36, 0x0, 0xa, 0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2, - 0x28, 0xb, 0x1e, 0x1f, 0x0, 0x1b, 0x37, 0x63, 0x9d, 0x4b, 0xb, 0xa2, 0x6c, 0x9b, - 0x3f, 0xa2, 0x85, 0xcb, 0x6f, 0xec, 0x98, 0x21, 0x34, 0x95, 0xf9, 0xa0, 0x1f, 0x8b, - 0x7f, 0x5e, 0x82, 0x5e, 0x82, 0x2, 0x0, 0x0, 0x1, 0x5a, 0x22, 0x1f, 0x31, 0xb8}; - uint8_t topic_bytes[] = {0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x8b, 0x1, 0x0, 0xd, 0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, + 0xe3, 0xef, 0x2a, 0xc0, 0x76, 0x28, 0x54, 0x22, 0x38, 0x25, 0x8, 0x0, 0xb, 0xa3, 0x0, 0xf3, + 0x83, 0xd3, 0x93, 0x94, 0x9e, 0x26, 0x2e, 0xd, 0x13, 0x65, 0x2a, 0x27, 0x0, 0x0, 0x1b, 0xe9, + 0x21, 0x73, 0xf9, 0x17, 0xc5, 0xb, 0x1c, 0x8, 0x0, 0xf, 0x9, 0xc6, 0x1c, 0x82, 0x90, 0x21, + 0x82, 0x46, 0x35, 0xbf, 0x22, 0x75, 0xd3, 0xa1, 0x93, 0x23, 0x24, 0x3a, 0x25, 0x21, 0x1f, 0x0, + 0x12, 0xbd, 0x12, 0x3e, 0x46, 0x56, 0x3d, 0x43, 0x2, 0x6, 0x75, 0x8e, 0x85, 0xd7, 0xf9, 0xe0, + 0xc3, 0xe1, 0x2a, 0x29, 0x83, 0x1c, 0x0, 0x7, 0xf4, 0x46, 0x42, 0xcb, 0x3e, 0x70, 0x3e, 0x21, + 0x22, 0x18, 0x29, 0x7d, 0x9, 0x0, 0x14, 0x8d, 0xb4, 0x82, 0x67, 0xa6, 0xdd, 0x3e, 0xa7, 0x2, + 0x8c, 0x5d, 0x99, 0x88, 0x6b, 0x87, 0x87, 0x2, 0xf3, 0xd7, 0xdf, 0x52, 0x33, 0xa0}; + uint8_t topic_bytes[] = {0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xb8}; + uint8_t msg_bytes[] = {0x52, 0x33, 0xa0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 3; - uint8_t bytesprops0[] = {0x37, 0x63, 0x9d, 0x4b, 0xb, 0xa2, 0x6c, 0x9b, 0x3f, 0xa2, 0x85, 0xcb, 0x6f, 0xec, - 0x98, 0x21, 0x34, 0x95, 0xf9, 0xa0, 0x1f, 0x8b, 0x7f, 0x5e, 0x82, 0x5e, 0x82}; + uint8_t bytesprops0[] = {0xa3, 0x0, 0xf3, 0x83, 0xd3, 0x93, 0x94, 0x9e, 0x26, 0x2e, 0xd}; + uint8_t bytesprops1[] = {0x9, 0xc6, 0x1c, 0x82, 0x90, 0x21, 0x82, 0x46, 0x35, 0xbf, 0x22, 0x75, 0xd3, 0xa1, 0x93}; + uint8_t bytesprops2[] = {0xbd, 0x12, 0x3e, 0x46, 0x56, 0x3d, 0x43, 0x2, 0x6, + 0x75, 0x8e, 0x85, 0xd7, 0xf9, 0xe0, 0xc3, 0xe1, 0x2a}; + uint8_t bytesprops3[] = {0xf4, 0x46, 0x42, 0xcb, 0x3e, 0x70, 0x3e}; + uint8_t bytesprops4[] = {0x8d, 0xb4, 0x82, 0x67, 0xa6, 0xdd, 0x3e, 0xa7, 0x2, 0x8c, + 0x5d, 0x99, 0x88, 0x6b, 0x87, 0x87, 0x2, 0xf3, 0xd7, 0xdf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 346}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7985}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14373}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25898}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7145}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29689}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9274}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8728}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10944, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "b\245\197\244\&04\214\&6*\178", -// _pubPktID = 0, _pubBody = "\184", _pubProps = [PropSubscriptionIdentifier 30,PropReasonString -// "7c\157K\v\162l\155?\162\133\203o\236\152!4\149\249\160\US\139\DEL^\130^\130",PropMessageExpiryInterval -// 346,PropTopicAliasMaximum 7985]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\198\161\148\238\191@\246\217\217\241\DC1\227\239", _pubPktID = 10944, _pubBody = "R3\160", _pubProps = +// [PropWildcardSubscriptionAvailable 84,PropTopicAliasMaximum 14373,PropResponseTopic +// "\163\NUL\243\131\211\147\148\158&.\r",PropServerKeepAlive 25898,PropMaximumPacketSize 7145,PropReceiveMaximum +// 29689,PropRequestProblemInformation 197,PropSubscriptionIdentifier 28,PropResponseTopic +// "\t\198\FS\130\144!\130F5\191\"u\211\161\147",PropTopicAlias 9274,PropRetainAvailable 33,PropReasonString +// "\189\DC2>FV=C\STX\ACKu\142\133\215\249\224\195\225*",PropSubscriptionIdentifierAvailable 131,PropServerReference +// "\244FB\203>p>",PropReceiveMaximum 8728,PropSubscriptionIdentifierAvailable 125,PropCorrelationData +// "\141\180\130g\166\221>\167\STX\140]\153\136k\135\135\STX\243\215\223"]} TEST(Publish5QCTest, Decode24) { - uint8_t pkt[] = {0x38, 0x36, 0x0, 0xa, 0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2, - 0x28, 0xb, 0x1e, 0x1f, 0x0, 0x1b, 0x37, 0x63, 0x9d, 0x4b, 0xb, 0xa2, 0x6c, 0x9b, - 0x3f, 0xa2, 0x85, 0xcb, 0x6f, 0xec, 0x98, 0x21, 0x34, 0x95, 0xf9, 0xa0, 0x1f, 0x8b, - 0x7f, 0x5e, 0x82, 0x5e, 0x82, 0x2, 0x0, 0x0, 0x1, 0x5a, 0x22, 0x1f, 0x31, 0xb8}; + uint8_t pkt[] = {0x3c, 0x8b, 0x1, 0x0, 0xd, 0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, + 0xe3, 0xef, 0x2a, 0xc0, 0x76, 0x28, 0x54, 0x22, 0x38, 0x25, 0x8, 0x0, 0xb, 0xa3, 0x0, 0xf3, + 0x83, 0xd3, 0x93, 0x94, 0x9e, 0x26, 0x2e, 0xd, 0x13, 0x65, 0x2a, 0x27, 0x0, 0x0, 0x1b, 0xe9, + 0x21, 0x73, 0xf9, 0x17, 0xc5, 0xb, 0x1c, 0x8, 0x0, 0xf, 0x9, 0xc6, 0x1c, 0x82, 0x90, 0x21, + 0x82, 0x46, 0x35, 0xbf, 0x22, 0x75, 0xd3, 0xa1, 0x93, 0x23, 0x24, 0x3a, 0x25, 0x21, 0x1f, 0x0, + 0x12, 0xbd, 0x12, 0x3e, 0x46, 0x56, 0x3d, 0x43, 0x2, 0x6, 0x75, 0x8e, 0x85, 0xd7, 0xf9, 0xe0, + 0xc3, 0xe1, 0x2a, 0x29, 0x83, 0x1c, 0x0, 0x7, 0xf4, 0x46, 0x42, 0xcb, 0x3e, 0x70, 0x3e, 0x21, + 0x22, 0x18, 0x29, 0x7d, 0x9, 0x0, 0x14, 0x8d, 0xb4, 0x82, 0x67, 0xa6, 0xdd, 0x3e, 0xa7, 0x2, + 0x8c, 0x5d, 0x99, 0x88, 0x6b, 0x87, 0x87, 0x2, 0xf3, 0xd7, 0xdf, 0x52, 0x33, 0xa0}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x62, 0xf5, 0xc5, 0xf4, 0x30, 0x34, 0xd6, 0x36, 0x2a, 0xb2}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb8}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x52, 0x33, 0xa0}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(packet_id, 10944); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\200\170v\196", _pubPktID = 30063, -// _pubBody = "\RS(g\190(g%\FS\249\135\DC1S\250\ACK(N\CANHC\157\RSK\175\DEL\225\159", _pubProps = [PropRetainAvailable -// 155,PropRequestResponseInformation 86,PropResponseInformation "e\216\214f\152\213C\173",PropReasonString -// "(\131\DEL\DC12\229E\233\146$6\164\165\SO\148",PropResponseTopic -// "\248y\172\190\154^\221\DC3/\166\SO\193N3\164@HN\203\185\247\168\USR\RS\248R\241i\217",PropSharedSubscriptionAvailable -// 148,PropWildcardSubscriptionAvailable 183,PropWillDelayInterval 14294]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "V\195\159\242\185\ENQ\214\147\DLE\144\144,r\245\SO\237n\143\204\SUB\229\230", _pubPktID = 0, _pubBody = +// "\171\131\154", _pubProps = [PropContentType "\165jh\204\246\SOH\131KlPMz\142\143K=",PropCorrelationData +// "\231\223\SYN\157\255\226^\178\255\227",PropSubscriptionIdentifierAvailable 29,PropTopicAlias +// 24599,PropSessionExpiryInterval 17667,PropRetainAvailable 228,PropAuthenticationMethod +// "\142\EOT\159\223l2\177v\233\185\241\136;\186p",PropMaximumQoS 61,PropMaximumQoS 206,PropSharedSubscriptionAvailable +// 90,PropRequestProblemInformation 242,PropAuthenticationData "\186\159e\225\238\237",PropTopicAliasMaximum +// 17236,PropAuthenticationData "\168b\211",PropAuthenticationMethod +// "\180#G\231\a\ETXX}\233\232\FS\192\SUB@\250O\NAKn\176\227\DC4\156^V\215\134\169\190\194",PropMaximumQoS +// 192,PropSharedSubscriptionAvailable 39,PropServerKeepAlive 30465,PropUserProperty +// "\203\179l\247-\146\ESC)6\179\225\CAN\202,3\207\131\214\160\241$5" "9$\SOH\237M",PropTopicAliasMaximum +// 5969,PropSubscriptionIdentifierAvailable 27]} TEST(Publish5QCTest, Encode25) { - uint8_t pkt[] = {0x3c, 0x6e, 0x0, 0x4, 0xc8, 0xaa, 0x76, 0xc4, 0x75, 0x6f, 0x4b, 0x25, 0x9b, 0x19, 0x56, 0x1a, - 0x0, 0x8, 0x65, 0xd8, 0xd6, 0x66, 0x98, 0xd5, 0x43, 0xad, 0x1f, 0x0, 0xf, 0x28, 0x83, 0x7f, - 0x11, 0x32, 0xe5, 0x45, 0xe9, 0x92, 0x24, 0x36, 0xa4, 0xa5, 0xe, 0x94, 0x8, 0x0, 0x1e, 0xf8, - 0x79, 0xac, 0xbe, 0x9a, 0x5e, 0xdd, 0x13, 0x2f, 0xa6, 0xe, 0xc1, 0x4e, 0x33, 0xa4, 0x40, 0x48, - 0x4e, 0xcb, 0xb9, 0xf7, 0xa8, 0x1f, 0x52, 0x1e, 0xf8, 0x52, 0xf1, 0x69, 0xd9, 0x2a, 0x94, 0x28, - 0xb7, 0x18, 0x0, 0x0, 0x37, 0xd6, 0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, - 0x11, 0x53, 0xfa, 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; - uint8_t topic_bytes[] = {0xc8, 0xaa, 0x76, 0xc4}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0xc1, 0x1, 0x0, 0x16, 0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, 0x2c, + 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6, 0xa4, 0x1, 0x3, 0x0, 0x10, 0xa5, 0x6a, + 0x68, 0xcc, 0xf6, 0x1, 0x83, 0x4b, 0x6c, 0x50, 0x4d, 0x7a, 0x8e, 0x8f, 0x4b, 0x3d, 0x9, 0x0, 0xa, + 0xe7, 0xdf, 0x16, 0x9d, 0xff, 0xe2, 0x5e, 0xb2, 0xff, 0xe3, 0x29, 0x1d, 0x23, 0x60, 0x17, 0x11, 0x0, + 0x0, 0x45, 0x3, 0x25, 0xe4, 0x15, 0x0, 0xf, 0x8e, 0x4, 0x9f, 0xdf, 0x6c, 0x32, 0xb1, 0x76, 0xe9, + 0xb9, 0xf1, 0x88, 0x3b, 0xba, 0x70, 0x24, 0x3d, 0x24, 0xce, 0x2a, 0x5a, 0x17, 0xf2, 0x16, 0x0, 0x6, + 0xba, 0x9f, 0x65, 0xe1, 0xee, 0xed, 0x22, 0x43, 0x54, 0x16, 0x0, 0x3, 0xa8, 0x62, 0xd3, 0x15, 0x0, + 0x1d, 0xb4, 0x23, 0x47, 0xe7, 0x7, 0x3, 0x58, 0x7d, 0xe9, 0xe8, 0x1c, 0xc0, 0x1a, 0x40, 0xfa, 0x4f, + 0x15, 0x6e, 0xb0, 0xe3, 0x14, 0x9c, 0x5e, 0x56, 0xd7, 0x86, 0xa9, 0xbe, 0xc2, 0x24, 0xc0, 0x2a, 0x27, + 0x13, 0x77, 0x1, 0x26, 0x0, 0x16, 0xcb, 0xb3, 0x6c, 0xf7, 0x2d, 0x92, 0x1b, 0x29, 0x36, 0xb3, 0xe1, + 0x18, 0xca, 0x2c, 0x33, 0xcf, 0x83, 0xd6, 0xa0, 0xf1, 0x24, 0x35, 0x0, 0x5, 0x39, 0x24, 0x1, 0xed, + 0x4d, 0x22, 0x17, 0x51, 0x29, 0x1b, 0xab, 0x83, 0x9a}; + uint8_t topic_bytes[] = {0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, + 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, - 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xab, 0x83, 0x9a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 3; - uint8_t bytesprops0[] = {0x65, 0xd8, 0xd6, 0x66, 0x98, 0xd5, 0x43, 0xad}; - uint8_t bytesprops1[] = {0x28, 0x83, 0x7f, 0x11, 0x32, 0xe5, 0x45, 0xe9, 0x92, 0x24, 0x36, 0xa4, 0xa5, 0xe, 0x94}; - uint8_t bytesprops2[] = {0xf8, 0x79, 0xac, 0xbe, 0x9a, 0x5e, 0xdd, 0x13, 0x2f, 0xa6, 0xe, 0xc1, 0x4e, 0x33, 0xa4, - 0x40, 0x48, 0x4e, 0xcb, 0xb9, 0xf7, 0xa8, 0x1f, 0x52, 0x1e, 0xf8, 0x52, 0xf1, 0x69, 0xd9}; + uint8_t bytesprops0[] = {0xa5, 0x6a, 0x68, 0xcc, 0xf6, 0x1, 0x83, 0x4b, + 0x6c, 0x50, 0x4d, 0x7a, 0x8e, 0x8f, 0x4b, 0x3d}; + uint8_t bytesprops1[] = {0xe7, 0xdf, 0x16, 0x9d, 0xff, 0xe2, 0x5e, 0xb2, 0xff, 0xe3}; + uint8_t bytesprops2[] = {0x8e, 0x4, 0x9f, 0xdf, 0x6c, 0x32, 0xb1, 0x76, 0xe9, 0xb9, 0xf1, 0x88, 0x3b, 0xba, 0x70}; + uint8_t bytesprops3[] = {0xba, 0x9f, 0x65, 0xe1, 0xee, 0xed}; + uint8_t bytesprops4[] = {0xa8, 0x62, 0xd3}; + uint8_t bytesprops5[] = {0xb4, 0x23, 0x47, 0xe7, 0x7, 0x3, 0x58, 0x7d, 0xe9, 0xe8, 0x1c, 0xc0, 0x1a, 0x40, 0xfa, + 0x4f, 0x15, 0x6e, 0xb0, 0xe3, 0x14, 0x9c, 0x5e, 0x56, 0xd7, 0x86, 0xa9, 0xbe, 0xc2}; + uint8_t bytesprops7[] = {0x39, 0x24, 0x1, 0xed, 0x4d}; + uint8_t bytesprops6[] = {0xcb, 0xb3, 0x6c, 0xf7, 0x2d, 0x92, 0x1b, 0x29, 0x36, 0xb3, 0xe1, + 0x18, 0xca, 0x2c, 0x33, 0xcf, 0x83, 0xd6, 0xa0, 0xf1, 0x24, 0x35}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14294}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24599}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17667}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17236}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30465}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops6}, .v = {5, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5969}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 27}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 30063, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\200\170v\196", _pubPktID = 30063, -// _pubBody = "\RS(g\190(g%\FS\249\135\DC1S\250\ACK(N\CANHC\157\RSK\175\DEL\225\159", _pubProps = [PropRetainAvailable -// 155,PropRequestResponseInformation 86,PropResponseInformation "e\216\214f\152\213C\173",PropReasonString -// "(\131\DEL\DC12\229E\233\146$6\164\165\SO\148",PropResponseTopic -// "\248y\172\190\154^\221\DC3/\166\SO\193N3\164@HN\203\185\247\168\USR\RS\248R\241i\217",PropSharedSubscriptionAvailable -// 148,PropWildcardSubscriptionAvailable 183,PropWillDelayInterval 14294]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "V\195\159\242\185\ENQ\214\147\DLE\144\144,r\245\SO\237n\143\204\SUB\229\230", _pubPktID = 0, _pubBody = +// "\171\131\154", _pubProps = [PropContentType "\165jh\204\246\SOH\131KlPMz\142\143K=",PropCorrelationData +// "\231\223\SYN\157\255\226^\178\255\227",PropSubscriptionIdentifierAvailable 29,PropTopicAlias +// 24599,PropSessionExpiryInterval 17667,PropRetainAvailable 228,PropAuthenticationMethod +// "\142\EOT\159\223l2\177v\233\185\241\136;\186p",PropMaximumQoS 61,PropMaximumQoS 206,PropSharedSubscriptionAvailable +// 90,PropRequestProblemInformation 242,PropAuthenticationData "\186\159e\225\238\237",PropTopicAliasMaximum +// 17236,PropAuthenticationData "\168b\211",PropAuthenticationMethod +// "\180#G\231\a\ETXX}\233\232\FS\192\SUB@\250O\NAKn\176\227\DC4\156^V\215\134\169\190\194",PropMaximumQoS +// 192,PropSharedSubscriptionAvailable 39,PropServerKeepAlive 30465,PropUserProperty +// "\203\179l\247-\146\ESC)6\179\225\CAN\202,3\207\131\214\160\241$5" "9$\SOH\237M",PropTopicAliasMaximum +// 5969,PropSubscriptionIdentifierAvailable 27]} TEST(Publish5QCTest, Decode25) { - uint8_t pkt[] = {0x3c, 0x6e, 0x0, 0x4, 0xc8, 0xaa, 0x76, 0xc4, 0x75, 0x6f, 0x4b, 0x25, 0x9b, 0x19, 0x56, 0x1a, - 0x0, 0x8, 0x65, 0xd8, 0xd6, 0x66, 0x98, 0xd5, 0x43, 0xad, 0x1f, 0x0, 0xf, 0x28, 0x83, 0x7f, - 0x11, 0x32, 0xe5, 0x45, 0xe9, 0x92, 0x24, 0x36, 0xa4, 0xa5, 0xe, 0x94, 0x8, 0x0, 0x1e, 0xf8, - 0x79, 0xac, 0xbe, 0x9a, 0x5e, 0xdd, 0x13, 0x2f, 0xa6, 0xe, 0xc1, 0x4e, 0x33, 0xa4, 0x40, 0x48, - 0x4e, 0xcb, 0xb9, 0xf7, 0xa8, 0x1f, 0x52, 0x1e, 0xf8, 0x52, 0xf1, 0x69, 0xd9, 0x2a, 0x94, 0x28, - 0xb7, 0x18, 0x0, 0x0, 0x37, 0xd6, 0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, - 0x11, 0x53, 0xfa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0xe1, + 0x18, 0xca, 0x2c, 0x33, 0xcf, 0x83, 0xd6, 0xa0, 0xf1, 0x24, 0x35, 0x0, 0x5, 0x39, 0x24, 0x1, 0xed, + 0x4d, 0x22, 0x17, 0x51, 0x29, 0x1b, 0xab, 0x83, 0x9a}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc8, 0xaa, 0x76, 0xc4}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1e, 0x28, 0x67, 0xbe, 0x28, 0x67, 0x25, 0x1c, 0xf9, 0x87, 0x11, 0x53, 0xfa, - 0x6, 0x28, 0x4e, 0x18, 0x48, 0x43, 0x9d, 0x1e, 0x4b, 0xaf, 0x7f, 0xe1, 0x9f}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, + 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xab, 0x83, 0x9a}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 30063); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\229<<\234;", _pubPktID = 0, -// _pubBody = "+ eK\208\CAN\232\179\167\129\227'Hqi\SO\163\r\168\188\157\247", _pubProps = [PropReasonString -// "\218&",PropMaximumQoS 139,PropUserProperty "u9\246l\ETB\227?V@~" -// "\246\248KBQ\ACK",PropSubscriptionIdentifierAvailable 161,PropRetainAvailable 146,PropAssignedClientIdentifier -// "\189\233\146\140Ir\207px9\172g\193\216Z\243\244\133\137\RSybT\172E\133L",PropRequestProblemInformation -// 56,PropSharedSubscriptionAvailable 91,PropAssignedClientIdentifier "\DC2\146",PropResponseInformation -// "A\250\217\RS\228v\ACK30rj\157\222\181\181#LE\221!\234\DC28\151\129\211\156\210\183",PropReasonString -// "\SO",PropReceiveMaximum 9804,PropSessionExpiryInterval 21555,PropSessionExpiryInterval 19432,PropUserProperty -// "\202pV\252{\200\197\154\140\US\154\157\184\183\218\213\171" -// "\189\DC2\143\236\177\153\SOH6\227\246f\SUB\191\143`",PropTopicAliasMaximum 19556,PropTopicAlias 6627,PropMaximumQoS -// 46,PropAuthenticationData "\241\\\130\DC1\172\ETX\RS\128y\ENQ\211\138V\255\RS\199u\222w\241\219\178",PropMaximumQoS -// 40,PropAuthenticationMethod "Q\171"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ",\129\b\199\224\197\191\196~\130\211\129B\164\238\NAK\138I\201f\163", _pubPktID = 2253, _pubBody = +// "|\153\171Y,OB.\132d\186cm;\DC4+\153\209y\t\128", _pubProps = [PropReasonString "\195U\132s:\212",PropReceiveMaximum +// 9748,PropMessageExpiryInterval 29630,PropResponseTopic "\153\&4\166~2\191\165\186\EOTM0\139 +// p3\166\186",PropResponseInformation +// "\243\210\EM\240\"\n\DC1\192\181p,\226)\241\DC1b\230d\194\137\150\221\228\SI]t\246",PropRetainAvailable +// 18,PropTopicAliasMaximum 16390,PropAuthenticationData "\222\143\211\240",PropReceiveMaximum 2405]} TEST(Publish5QCTest, Encode26) { - uint8_t pkt[] = {0x31, 0xe4, 0x1, 0x0, 0x5, 0xe5, 0x3c, 0x3c, 0xea, 0x3b, 0xc5, 0x1, 0x1f, 0x0, 0x2, 0xda, 0x26, - 0x24, 0x8b, 0x26, 0x0, 0xa, 0x75, 0x39, 0xf6, 0x6c, 0x17, 0xe3, 0x3f, 0x56, 0x40, 0x7e, 0x0, 0x6, - 0xf6, 0xf8, 0x4b, 0x42, 0x51, 0x6, 0x29, 0xa1, 0x25, 0x92, 0x12, 0x0, 0x1b, 0xbd, 0xe9, 0x92, 0x8c, - 0x49, 0x72, 0xcf, 0x70, 0x78, 0x39, 0xac, 0x67, 0xc1, 0xd8, 0x5a, 0xf3, 0xf4, 0x85, 0x89, 0x1e, 0x79, - 0x62, 0x54, 0xac, 0x45, 0x85, 0x4c, 0x17, 0x38, 0x2a, 0x5b, 0x12, 0x0, 0x2, 0x12, 0x92, 0x1a, 0x0, - 0x1d, 0x41, 0xfa, 0xd9, 0x1e, 0xe4, 0x76, 0x6, 0x33, 0x30, 0x72, 0x6a, 0x9d, 0xde, 0xb5, 0xb5, 0x23, - 0x4c, 0x45, 0xdd, 0x21, 0xea, 0x12, 0x38, 0x97, 0x81, 0xd3, 0x9c, 0xd2, 0xb7, 0x1f, 0x0, 0x1, 0xe, - 0x21, 0x26, 0x4c, 0x11, 0x0, 0x0, 0x54, 0x33, 0x11, 0x0, 0x0, 0x4b, 0xe8, 0x26, 0x0, 0x11, 0xca, - 0x70, 0x56, 0xfc, 0x7b, 0xc8, 0xc5, 0x9a, 0x8c, 0x1f, 0x9a, 0x9d, 0xb8, 0xb7, 0xda, 0xd5, 0xab, 0x0, - 0xf, 0xbd, 0x12, 0x8f, 0xec, 0xb1, 0x99, 0x1, 0x36, 0xe3, 0xf6, 0x66, 0x1a, 0xbf, 0x8f, 0x60, 0x22, - 0x4c, 0x64, 0x23, 0x19, 0xe3, 0x24, 0x2e, 0x16, 0x0, 0x16, 0xf1, 0x5c, 0x82, 0x11, 0xac, 0x3, 0x1e, - 0x80, 0x79, 0x5, 0xd3, 0x8a, 0x56, 0xff, 0x1e, 0xc7, 0x75, 0xde, 0x77, 0xf1, 0xdb, 0xb2, 0x24, 0x28, - 0x15, 0x0, 0x2, 0x51, 0xab, 0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, 0x27, - 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; - uint8_t topic_bytes[] = {0xe5, 0x3c, 0x3c, 0xea, 0x3b}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x81, 0x1, 0x0, 0x15, 0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, 0x81, + 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3, 0x8, 0xcd, 0x52, 0x1f, 0x0, 0x6, 0xc3, 0x55, + 0x84, 0x73, 0x3a, 0xd4, 0x21, 0x26, 0x14, 0x2, 0x0, 0x0, 0x73, 0xbe, 0x8, 0x0, 0x11, 0x99, 0x34, + 0xa6, 0x7e, 0x32, 0xbf, 0xa5, 0xba, 0x4, 0x4d, 0x30, 0x8b, 0x20, 0x70, 0x33, 0xa6, 0xba, 0x1a, 0x0, + 0x1b, 0xf3, 0xd2, 0x19, 0xf0, 0x22, 0xa, 0x11, 0xc0, 0xb5, 0x70, 0x2c, 0xe2, 0x29, 0xf1, 0x11, 0x62, + 0xe6, 0x64, 0xc2, 0x89, 0x96, 0xdd, 0xe4, 0xf, 0x5d, 0x74, 0xf6, 0x25, 0x12, 0x22, 0x40, 0x6, 0x16, + 0x0, 0x4, 0xde, 0x8f, 0xd3, 0xf0, 0x21, 0x9, 0x65, 0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, + 0x84, 0x64, 0xba, 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; + uint8_t topic_bytes[] = {0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, + 0x81, 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, - 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, + 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; - - uint8_t bytesprops0[] = {0xda, 0x26}; - uint8_t bytesprops2[] = {0xf6, 0xf8, 0x4b, 0x42, 0x51, 0x6}; - uint8_t bytesprops1[] = {0x75, 0x39, 0xf6, 0x6c, 0x17, 0xe3, 0x3f, 0x56, 0x40, 0x7e}; - uint8_t bytesprops3[] = {0xbd, 0xe9, 0x92, 0x8c, 0x49, 0x72, 0xcf, 0x70, 0x78, 0x39, 0xac, 0x67, 0xc1, 0xd8, - 0x5a, 0xf3, 0xf4, 0x85, 0x89, 0x1e, 0x79, 0x62, 0x54, 0xac, 0x45, 0x85, 0x4c}; - uint8_t bytesprops4[] = {0x12, 0x92}; - uint8_t bytesprops5[] = {0x41, 0xfa, 0xd9, 0x1e, 0xe4, 0x76, 0x6, 0x33, 0x30, 0x72, 0x6a, 0x9d, 0xde, 0xb5, 0xb5, - 0x23, 0x4c, 0x45, 0xdd, 0x21, 0xea, 0x12, 0x38, 0x97, 0x81, 0xd3, 0x9c, 0xd2, 0xb7}; - uint8_t bytesprops6[] = {0xe}; - uint8_t bytesprops8[] = {0xbd, 0x12, 0x8f, 0xec, 0xb1, 0x99, 0x1, 0x36, 0xe3, 0xf6, 0x66, 0x1a, 0xbf, 0x8f, 0x60}; - uint8_t bytesprops7[] = {0xca, 0x70, 0x56, 0xfc, 0x7b, 0xc8, 0xc5, 0x9a, 0x8c, - 0x1f, 0x9a, 0x9d, 0xb8, 0xb7, 0xda, 0xd5, 0xab}; - uint8_t bytesprops9[] = {0xf1, 0x5c, 0x82, 0x11, 0xac, 0x3, 0x1e, 0x80, 0x79, 0x5, 0xd3, - 0x8a, 0x56, 0xff, 0x1e, 0xc7, 0x75, 0xde, 0x77, 0xf1, 0xdb, 0xb2}; - uint8_t bytesprops10[] = {0x51, 0xab}; + msg.payload_len = 21; + + uint8_t bytesprops0[] = {0xc3, 0x55, 0x84, 0x73, 0x3a, 0xd4}; + uint8_t bytesprops1[] = {0x99, 0x34, 0xa6, 0x7e, 0x32, 0xbf, 0xa5, 0xba, 0x4, + 0x4d, 0x30, 0x8b, 0x20, 0x70, 0x33, 0xa6, 0xba}; + uint8_t bytesprops2[] = {0xf3, 0xd2, 0x19, 0xf0, 0x22, 0xa, 0x11, 0xc0, 0xb5, 0x70, 0x2c, 0xe2, 0x29, 0xf1, + 0x11, 0x62, 0xe6, 0x64, 0xc2, 0x89, 0x96, 0xdd, 0xe4, 0xf, 0x5d, 0x74, 0xf6}; + uint8_t bytesprops3[] = {0xde, 0x8f, 0xd3, 0xf0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9804}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21555}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19432}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops7}, .v = {15, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19556}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6627}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9748}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29630}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16390}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2405}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 2253, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\229<<\234;", _pubPktID = 0, -// _pubBody = "+ eK\208\CAN\232\179\167\129\227'Hqi\SO\163\r\168\188\157\247", _pubProps = [PropReasonString -// "\218&",PropMaximumQoS 139,PropUserProperty "u9\246l\ETB\227?V@~" -// "\246\248KBQ\ACK",PropSubscriptionIdentifierAvailable 161,PropRetainAvailable 146,PropAssignedClientIdentifier -// "\189\233\146\140Ir\207px9\172g\193\216Z\243\244\133\137\RSybT\172E\133L",PropRequestProblemInformation -// 56,PropSharedSubscriptionAvailable 91,PropAssignedClientIdentifier "\DC2\146",PropResponseInformation -// "A\250\217\RS\228v\ACK30rj\157\222\181\181#LE\221!\234\DC28\151\129\211\156\210\183",PropReasonString -// "\SO",PropReceiveMaximum 9804,PropSessionExpiryInterval 21555,PropSessionExpiryInterval 19432,PropUserProperty -// "\202pV\252{\200\197\154\140\US\154\157\184\183\218\213\171" -// "\189\DC2\143\236\177\153\SOH6\227\246f\SUB\191\143`",PropTopicAliasMaximum 19556,PropTopicAlias 6627,PropMaximumQoS -// 46,PropAuthenticationData "\241\\\130\DC1\172\ETX\RS\128y\ENQ\211\138V\255\RS\199u\222w\241\219\178",PropMaximumQoS -// 40,PropAuthenticationMethod "Q\171"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ",\129\b\199\224\197\191\196~\130\211\129B\164\238\NAK\138I\201f\163", _pubPktID = 2253, _pubBody = +// "|\153\171Y,OB.\132d\186cm;\DC4+\153\209y\t\128", _pubProps = [PropReasonString "\195U\132s:\212",PropReceiveMaximum +// 9748,PropMessageExpiryInterval 29630,PropResponseTopic "\153\&4\166~2\191\165\186\EOTM0\139 +// p3\166\186",PropResponseInformation +// "\243\210\EM\240\"\n\DC1\192\181p,\226)\241\DC1b\230d\194\137\150\221\228\SI]t\246",PropRetainAvailable +// 18,PropTopicAliasMaximum 16390,PropAuthenticationData "\222\143\211\240",PropReceiveMaximum 2405]} TEST(Publish5QCTest, Decode26) { - uint8_t pkt[] = {0x31, 0xe4, 0x1, 0x0, 0x5, 0xe5, 0x3c, 0x3c, 0xea, 0x3b, 0xc5, 0x1, 0x1f, 0x0, 0x2, 0xda, 0x26, - 0x24, 0x8b, 0x26, 0x0, 0xa, 0x75, 0x39, 0xf6, 0x6c, 0x17, 0xe3, 0x3f, 0x56, 0x40, 0x7e, 0x0, 0x6, - 0xf6, 0xf8, 0x4b, 0x42, 0x51, 0x6, 0x29, 0xa1, 0x25, 0x92, 0x12, 0x0, 0x1b, 0xbd, 0xe9, 0x92, 0x8c, - 0x49, 0x72, 0xcf, 0x70, 0x78, 0x39, 0xac, 0x67, 0xc1, 0xd8, 0x5a, 0xf3, 0xf4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x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3, 0x8, 0xcd, 0x52, 0x1f, 0x0, 0x6, 0xc3, 0x55, + 0x84, 0x73, 0x3a, 0xd4, 0x21, 0x26, 0x14, 0x2, 0x0, 0x0, 0x73, 0xbe, 0x8, 0x0, 0x11, 0x99, 0x34, + 0xa6, 0x7e, 0x32, 0xbf, 0xa5, 0xba, 0x4, 0x4d, 0x30, 0x8b, 0x20, 0x70, 0x33, 0xa6, 0xba, 0x1a, 0x0, + 0x1b, 0xf3, 0xd2, 0x19, 0xf0, 0x22, 0xa, 0x11, 0xc0, 0xb5, 0x70, 0x2c, 0xe2, 0x29, 0xf1, 0x11, 0x62, + 0xe6, 0x64, 0xc2, 0x89, 0x96, 0xdd, 0xe4, 0xf, 0x5d, 0x74, 0xf6, 0x25, 0x12, 0x22, 0x40, 0x6, 0x16, + 0x0, 0x4, 0xde, 0x8f, 0xd3, 0xf0, 0x21, 0x9, 0x65, 0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, + 0x84, 0x64, 0xba, 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe5, 0x3c, 0x3c, 0xea, 0x3b}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2b, 0x20, 0x65, 0x4b, 0xd0, 0x18, 0xe8, 0xb3, 0xa7, 0x81, 0xe3, - 0x27, 0x48, 0x71, 0x69, 0xe, 0xa3, 0xd, 0xa8, 0xbc, 0x9d, 0xf7}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, + 0x81, 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, + 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 2253); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\ETX[\136\204X%(topic.data), 22); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + uint8_t exp_topic_bytes[] = {0xff, 0x8a, 0xa0, 0xe, 0x7d, 0x91, 0xe7, 0x3d, 0x9a, 0xf1, 0x69, + 0x52, 0xdb, 0x1c, 0x97, 0xf0, 0x7d, 0x42, 0x8d, 0x28, 0xd6}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf9, 0x90, 0x37, 0x20, 0x2c, 0x12, 0xd8, 0x92, 0x72, + 0x9b, 0xa1, 0xe0, 0x6c, 0xee, 0xa5, 0x1c, 0xf5}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 10836); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201eh\234\223\242\222", _pubPktID = -// 0, _pubBody = " .@o\137\224\135\201\224\168\\&%,\220\&6\DC2\SI\209\132J\DC2]\FS\210\132\134\189\b~", _pubProps = -// [PropAssignedClientIdentifier "\t",PropAssignedClientIdentifier "\173\246$\137\207\204\GSg\192{\"5\ACKp\140\FSf"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\203\137\174H\204\220\160\&8\f+bXR\239\199\DC1\186\254\249\218\179y\210~\185\250\166\248", _pubPktID = 0, _pubBody = +// "\136\142{\DC4\\\154]/:\184\246N\DC28\204\&2C\f@\172\199\237\162)]W\186\180", _pubProps = [PropSubscriptionIdentifier +// 28,PropReasonString "m\SYN\215N\147a\164B~\157\176\&0",PropSharedSubscriptionAvailable +// 155,PropSubscriptionIdentifierAvailable 52,PropAuthenticationData "r\222\DC3\173eK\183\198`",PropContentType +// "9\231\244\219k\246o",PropTopicAlias 25947,PropReasonString +// "\197\240\246\183\239\187\195\DC2\195\132xh^/\189\DC1\165\221\158"]} TEST(Publish5QCTest, Encode28) { - uint8_t pkt[] = {0x38, 0x40, 0x0, 0x7, 0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde, 0x18, 0x12, 0x0, 0x1, 0x9, 0x12, - 0x0, 0x11, 0xad, 0xf6, 0x24, 0x89, 0xcf, 0xcc, 0x1d, 0x67, 0xc0, 0x7b, 0x22, 0x35, 0x6, 0x70, 0x8c, - 0x1c, 0x66, 0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, - 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; - uint8_t topic_bytes[] = {0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x7f, 0x0, 0x1c, 0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, + 0xef, 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8, 0x44, 0xb, + 0x1c, 0x1f, 0x0, 0xc, 0x6d, 0x16, 0xd7, 0x4e, 0x93, 0x61, 0xa4, 0x42, 0x7e, 0x9d, 0xb0, 0x30, 0x2a, + 0x9b, 0x29, 0x34, 0x16, 0x0, 0x9, 0x72, 0xde, 0x13, 0xad, 0x65, 0x4b, 0xb7, 0xc6, 0x60, 0x3, 0x0, + 0x7, 0x39, 0xe7, 0xf4, 0xdb, 0x6b, 0xf6, 0x6f, 0x23, 0x65, 0x5b, 0x1f, 0x0, 0x13, 0xc5, 0xf0, 0xf6, + 0xb7, 0xef, 0xbb, 0xc3, 0x12, 0xc3, 0x84, 0x78, 0x68, 0x5e, 0x2f, 0xbd, 0x11, 0xa5, 0xdd, 0x9e, 0x88, + 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, 0xcc, 0x32, 0x43, 0xc, + 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; + uint8_t topic_bytes[] = {0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, 0xef, + 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, - 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; + uint8_t msg_bytes[] = {0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, + 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 28; - uint8_t bytesprops0[] = {0x9}; - uint8_t bytesprops1[] = {0xad, 0xf6, 0x24, 0x89, 0xcf, 0xcc, 0x1d, 0x67, 0xc0, - 0x7b, 0x22, 0x35, 0x6, 0x70, 0x8c, 0x1c, 0x66}; + uint8_t bytesprops0[] = {0x6d, 0x16, 0xd7, 0x4e, 0x93, 0x61, 0xa4, 0x42, 0x7e, 0x9d, 0xb0, 0x30}; + uint8_t bytesprops1[] = {0x72, 0xde, 0x13, 0xad, 0x65, 0x4b, 0xb7, 0xc6, 0x60}; + uint8_t bytesprops2[] = {0x39, 0xe7, 0xf4, 0xdb, 0x6b, 0xf6, 0x6f}; + uint8_t bytesprops3[] = {0xc5, 0xf0, 0xf6, 0xb7, 0xef, 0xbb, 0xc3, 0x12, 0xc3, 0x84, + 0x78, 0x68, 0x5e, 0x2f, 0xbd, 0x11, 0xa5, 0xdd, 0x9e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25947}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); @@ -4880,351 +4879,252 @@ TEST(Publish5QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\201eh\234\223\242\222", _pubPktID = -// 0, _pubBody = " .@o\137\224\135\201\224\168\\&%,\220\&6\DC2\SI\209\132J\DC2]\FS\210\132\134\189\b~", _pubProps = -// [PropAssignedClientIdentifier "\t",PropAssignedClientIdentifier "\173\246$\137\207\204\GSg\192{\"5\ACKp\140\FSf"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\203\137\174H\204\220\160\&8\f+bXR\239\199\DC1\186\254\249\218\179y\210~\185\250\166\248", _pubPktID = 0, _pubBody = +// "\136\142{\DC4\\\154]/:\184\246N\DC28\204\&2C\f@\172\199\237\162)]W\186\180", _pubProps = [PropSubscriptionIdentifier +// 28,PropReasonString "m\SYN\215N\147a\164B~\157\176\&0",PropSharedSubscriptionAvailable +// 155,PropSubscriptionIdentifierAvailable 52,PropAuthenticationData "r\222\DC3\173eK\183\198`",PropContentType +// "9\231\244\219k\246o",PropTopicAlias 25947,PropReasonString +// "\197\240\246\183\239\187\195\DC2\195\132xh^/\189\DC1\165\221\158"]} TEST(Publish5QCTest, Decode28) { - uint8_t pkt[] = {0x38, 0x40, 0x0, 0x7, 0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde, 0x18, 0x12, 0x0, 0x1, 0x9, 0x12, - 0x0, 0x11, 0xad, 0xf6, 0x24, 0x89, 0xcf, 0xcc, 0x1d, 0x67, 0xc0, 0x7b, 0x22, 0x35, 0x6, 0x70, 0x8c, - 0x1c, 0x66, 0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, - 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; + uint8_t pkt[] = {0x38, 0x7f, 0x0, 0x1c, 0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, + 0xef, 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8, 0x44, 0xb, + 0x1c, 0x1f, 0x0, 0xc, 0x6d, 0x16, 0xd7, 0x4e, 0x93, 0x61, 0xa4, 0x42, 0x7e, 0x9d, 0xb0, 0x30, 0x2a, + 0x9b, 0x29, 0x34, 0x16, 0x0, 0x9, 0x72, 0xde, 0x13, 0xad, 0x65, 0x4b, 0xb7, 0xc6, 0x60, 0x3, 0x0, + 0x7, 0x39, 0xe7, 0xf4, 0xdb, 0x6b, 0xf6, 0x6f, 0x23, 0x65, 0x5b, 0x1f, 0x0, 0x13, 0xc5, 0xf0, 0xf6, + 0xb7, 0xef, 0xbb, 0xc3, 0x12, 0xc3, 0x84, 0x78, 0x68, 0x5e, 0x2f, 0xbd, 0x11, 0xa5, 0xdd, 0x9e, 0x88, + 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, 0xcc, 0x32, 0x43, 0xc, + 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc9, 0x65, 0x68, 0xea, 0xdf, 0xf2, 0xde}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x20, 0x2e, 0x40, 0x6f, 0x89, 0xe0, 0x87, 0xc9, 0xe0, 0xa8, 0x5c, 0x26, 0x25, 0x2c, 0xdc, - 0x36, 0x12, 0xf, 0xd1, 0x84, 0x4a, 0x12, 0x5d, 0x1c, 0xd2, 0x84, 0x86, 0xbd, 0x8, 0x7e}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, 0xef, + 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, + 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "{\200\227JE\EM6\185bARg\185\190\226e\205R\n\v\167\CAN\DC3~\152nd8\155'", _pubPktID = 24808, _pubBody = -// "\FS\196\NUL\238\180K\252nl\r\235$v\169K\163\182\254\134\186", _pubProps = [PropTopicAliasMaximum -// 26688,PropRetainAvailable 162,PropServerReference "\253u\144\199x\215\&0\142\v\161\177\US",PropMessageExpiryInterval -// 14586,PropCorrelationData -// "A\158C\241A\224\156\198'oa\227\&2(topic.data), 30); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + uint8_t exp_topic_bytes[] = {0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, + 0x5b, 0x38, 0x44, 0x8a, 0x69, 0xe8, 0x3f, 0x24}; + lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, 0x94, 0x3, + 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\218\139Q\DC1\195\175\199\249J\b\183\226\228\185\ESC\245\128\130\166\n]\133:\228\231$K*v", _pubPktID = 0, _pubBody = -// "\SOH\135h\234D\134\149\210zy\n\143\141\&7Q", _pubProps = [PropSharedSubscriptionAvailable -// 210,PropRequestResponseInformation 98,PropCorrelationData "\234\138CL\DC24qZ\195\134Qu\ETB -// \178\t\242\247\SYNGi\147z\DC1j",PropMaximumPacketSize 9483,PropWildcardSubscriptionAvailable -// 51,PropWildcardSubscriptionAvailable 35,PropUserProperty "\NUL\rw\164\th\199|\158$\164\222}\175\219" -// "",PropPayloadFormatIndicator 231,PropMaximumQoS 8,PropRequestProblemInformation 148,PropMaximumPacketSize -// 21886,PropReceiveMaximum 28042,PropRetainAvailable 68,PropRequestProblemInformation 3,PropMaximumQoS -// 58,PropRequestResponseInformation 255,PropRequestResponseInformation 253,PropWildcardSubscriptionAvailable -// 15,PropRetainAvailable 71,PropSessionExpiryInterval 22458,PropMessageExpiryInterval 15175,PropReceiveMaximum -// 13058,PropResponseInformation "\150Z(\215\v0"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\173\207\249\USrJ\214L\ENQAT\140JUG\ESC\FS\165\202\218\206\DEL\142\250'\167s\139", _pubPktID = 24516, _pubBody = "", +// _pubProps = [PropSubscriptionIdentifier 20,PropCorrelationData +// ";UtP!\fs\v\200\159\NAK\"\FS\184\201",PropRequestProblemInformation 5,PropMaximumQoS 209,PropResponseTopic +// "\224\&1/V?\246\&7c\137\&3G|\144\227\176\&8\250FzsMB",PropUserProperty "\SYN7\221\STXW\189" +// "Hi\178\129\\\162\&4U\CAN\167'\172\223l?\250",PropRequestProblemInformation 166,PropMessageExpiryInterval +// 30177,PropRetainAvailable 132]} TEST(Publish5QCTest, Encode30) { - uint8_t pkt[] = {0x39, 0x9e, 0x1, 0x0, 0x1d, 0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, - 0xe4, 0xb9, 0x1b, 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, 0x76, - 0x6f, 0x2a, 0xd2, 0x19, 0x62, 0x9, 0x0, 0x19, 0xea, 0x8a, 0x43, 0x4c, 0x12, 0x34, 0x71, 0x5a, 0xc3, - 0x86, 0x51, 0x75, 0x17, 0x20, 0xb2, 0x9, 0xf2, 0xf7, 0x16, 0x47, 0x69, 0x93, 0x7a, 0x11, 0x6a, 0x27, - 0x0, 0x0, 0x25, 0xb, 0x28, 0x33, 0x28, 0x23, 0x26, 0x0, 0xf, 0x0, 0xd, 0x77, 0xa4, 0x9, 0x68, - 0xc7, 0x7c, 0x9e, 0x24, 0xa4, 0xde, 0x7d, 0xaf, 0xdb, 0x0, 0x0, 0x1, 0xe7, 0x24, 0x8, 0x17, 0x94, - 0x27, 0x0, 0x0, 0x55, 0x7e, 0x21, 0x6d, 0x8a, 0x25, 0x44, 0x17, 0x3, 0x24, 0x3a, 0x19, 0xff, 0x19, - 0xfd, 0x28, 0xf, 0x25, 0x47, 0x11, 0x0, 0x0, 0x57, 0xba, 0x2, 0x0, 0x0, 0x3b, 0x47, 0x21, 0x33, - 0x2, 0x1a, 0x0, 0x6, 0x96, 0x5a, 0x28, 0xd7, 0xb, 0x30, 0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, - 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; - uint8_t topic_bytes[] = {0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, 0xe4, 0xb9, 0x1b, - 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, 0x76}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x76, 0x0, 0x1c, 0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, + 0x8c, 0x4a, 0x55, 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, + 0x73, 0x8b, 0x5f, 0xc4, 0x55, 0xb, 0x14, 0x9, 0x0, 0xf, 0x3b, 0x55, 0x74, 0x50, 0x21, + 0xc, 0x73, 0xb, 0xc8, 0x9f, 0x15, 0x22, 0x1c, 0xb8, 0xc9, 0x17, 0x5, 0x24, 0xd1, 0x8, + 0x0, 0x16, 0xe0, 0x31, 0x2f, 0x56, 0x3f, 0xf6, 0x37, 0x63, 0x89, 0x33, 0x47, 0x7c, 0x90, + 0xe3, 0xb0, 0x38, 0xfa, 0x46, 0x7a, 0x73, 0x4d, 0x42, 0x26, 0x0, 0x6, 0x16, 0x37, 0xdd, + 0x2, 0x57, 0xbd, 0x0, 0x10, 0x48, 0x69, 0xb2, 0x81, 0x5c, 0xa2, 0x34, 0x55, 0x18, 0xa7, + 0x27, 0xac, 0xdf, 0x6c, 0x3f, 0xfa, 0x17, 0xa6, 0x2, 0x0, 0x0, 0x75, 0xe1, 0x25, 0x84}; + uint8_t topic_bytes[] = {0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, + 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 0; - uint8_t bytesprops0[] = {0xea, 0x8a, 0x43, 0x4c, 0x12, 0x34, 0x71, 0x5a, 0xc3, 0x86, 0x51, 0x75, 0x17, - 0x20, 0xb2, 0x9, 0xf2, 0xf7, 0x16, 0x47, 0x69, 0x93, 0x7a, 0x11, 0x6a}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops1[] = {0x0, 0xd, 0x77, 0xa4, 0x9, 0x68, 0xc7, 0x7c, 0x9e, 0x24, 0xa4, 0xde, 0x7d, 0xaf, 0xdb}; - uint8_t bytesprops3[] = {0x96, 0x5a, 0x28, 0xd7, 0xb, 0x30}; + uint8_t bytesprops0[] = {0x3b, 0x55, 0x74, 0x50, 0x21, 0xc, 0x73, 0xb, 0xc8, 0x9f, 0x15, 0x22, 0x1c, 0xb8, 0xc9}; + uint8_t bytesprops1[] = {0xe0, 0x31, 0x2f, 0x56, 0x3f, 0xf6, 0x37, 0x63, 0x89, 0x33, 0x47, + 0x7c, 0x90, 0xe3, 0xb0, 0x38, 0xfa, 0x46, 0x7a, 0x73, 0x4d, 0x42}; + uint8_t bytesprops3[] = {0x48, 0x69, 0xb2, 0x81, 0x5c, 0xa2, 0x34, 0x55, + 0x18, 0xa7, 0x27, 0xac, 0xdf, 0x6c, 0x3f, 0xfa}; + uint8_t bytesprops2[] = {0x16, 0x37, 0xdd, 0x2, 0x57, 0xbd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9483}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops1}, .v = {0, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21886}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28042}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22458}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15175}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13058}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops2}, .v = {16, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30177}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 24516, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\218\139Q\DC1\195\175\199\249J\b\183\226\228\185\ESC\245\128\130\166\n]\133:\228\231$K*v", _pubPktID = 0, _pubBody = -// "\SOH\135h\234D\134\149\210zy\n\143\141\&7Q", _pubProps = [PropSharedSubscriptionAvailable -// 210,PropRequestResponseInformation 98,PropCorrelationData "\234\138CL\DC24qZ\195\134Qu\ETB -// \178\t\242\247\SYNGi\147z\DC1j",PropMaximumPacketSize 9483,PropWildcardSubscriptionAvailable -// 51,PropWildcardSubscriptionAvailable 35,PropUserProperty "\NUL\rw\164\th\199|\158$\164\222}\175\219" -// "",PropPayloadFormatIndicator 231,PropMaximumQoS 8,PropRequestProblemInformation 148,PropMaximumPacketSize -// 21886,PropReceiveMaximum 28042,PropRetainAvailable 68,PropRequestProblemInformation 3,PropMaximumQoS -// 58,PropRequestResponseInformation 255,PropRequestResponseInformation 253,PropWildcardSubscriptionAvailable -// 15,PropRetainAvailable 71,PropSessionExpiryInterval 22458,PropMessageExpiryInterval 15175,PropReceiveMaximum -// 13058,PropResponseInformation "\150Z(\215\v0"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\173\207\249\USrJ\214L\ENQAT\140JUG\ESC\FS\165\202\218\206\DEL\142\250'\167s\139", _pubPktID = 24516, _pubBody = "", +// _pubProps = [PropSubscriptionIdentifier 20,PropCorrelationData +// ";UtP!\fs\v\200\159\NAK\"\FS\184\201",PropRequestProblemInformation 5,PropMaximumQoS 209,PropResponseTopic +// "\224\&1/V?\246\&7c\137\&3G|\144\227\176\&8\250FzsMB",PropUserProperty "\SYN7\221\STXW\189" +// "Hi\178\129\\\162\&4U\CAN\167'\172\223l?\250",PropRequestProblemInformation 166,PropMessageExpiryInterval +// 30177,PropRetainAvailable 132]} TEST(Publish5QCTest, Decode30) { - uint8_t pkt[] = {0x39, 0x9e, 0x1, 0x0, 0x1d, 0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0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 0x74, 0x50, 0x21, + 0xc, 0x73, 0xb, 0xc8, 0x9f, 0x15, 0x22, 0x1c, 0xb8, 0xc9, 0x17, 0x5, 0x24, 0xd1, 0x8, + 0x0, 0x16, 0xe0, 0x31, 0x2f, 0x56, 0x3f, 0xf6, 0x37, 0x63, 0x89, 0x33, 0x47, 0x7c, 0x90, + 0xe3, 0xb0, 0x38, 0xfa, 0x46, 0x7a, 0x73, 0x4d, 0x42, 0x26, 0x0, 0x6, 0x16, 0x37, 0xdd, + 0x2, 0x57, 0xbd, 0x0, 0x10, 0x48, 0x69, 0xb2, 0x81, 0x5c, 0xa2, 0x34, 0x55, 0x18, 0xa7, + 0x27, 0xac, 0xdf, 0x6c, 0x3f, 0xfa, 0x17, 0xa6, 0x2, 0x0, 0x0, 0x75, 0xe1, 0x25, 0x84}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xda, 0x8b, 0x51, 0x11, 0xc3, 0xaf, 0xc7, 0xf9, 0x4a, 0x8, 0xb7, 0xe2, 0xe4, 0xb9, 0x1b, - 0xf5, 0x80, 0x82, 0xa6, 0xa, 0x5d, 0x85, 0x3a, 0xe4, 0xe7, 0x24, 0x4b, 0x2a, 0x76}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1, 0x87, 0x68, 0xea, 0x44, 0x86, 0x95, 0xd2, 0x7a, 0x79, 0xa, 0x8f, 0x8d, 0x37, 0x51}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, + 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 24516); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); lwmqtt_string_t x = exp_topic; x = exp_body; } -// ConnectRequest {_username = Just "\247\bJ@ON", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS0, _willTopic = "\200\&8\143\219\210\&8\154\ETB\191\209\ENQ\247\151j\ETX\STX\DLEwW\DC4(\171\239", -// _willMsg = "\239\163,\150S\ETXA\235Q\144\193p~G\249\214\218Wh\175\200\235;\235np\154t", _willProps = []}), -// _cleanSession = True, _keepAlive = 24957, _connID = "\SUB\DC4P\DC4\ENQ\160\SO\226\141\r\251", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\DLEVW\161\173W!+\154\235\a\169\136(K\152\224\190I4y", +// _lastWill = Nothing, _cleanSession = True, _keepAlive = 3940, _connID = "\147b\SOH\234HL\237", _properties = []} TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x56, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa6, 0x61, 0x7d, 0x0, 0xb, 0x1a, - 0x14, 0x50, 0x14, 0x5, 0xa0, 0xe, 0xe2, 0x8d, 0xd, 0xfb, 0x0, 0x17, 0xc8, 0x38, 0x8f, - 0xdb, 0xd2, 0x38, 0x9a, 0x17, 0xbf, 0xd1, 0x5, 0xf7, 0x97, 0x6a, 0x3, 0x2, 0x10, 0x77, - 0x57, 0x14, 0x28, 0xab, 0xef, 0x0, 0x1c, 0xef, 0xa3, 0x2c, 0x96, 0x53, 0x3, 0x41, 0xeb, - 0x51, 0x90, 0xc1, 0x70, 0x7e, 0x47, 0xf9, 0xd6, 0xda, 0x57, 0x68, 0xaf, 0xc8, 0xeb, 0x3b, - 0xeb, 0x6e, 0x70, 0x9a, 0x74, 0x0, 0x6, 0xf7, 0x8, 0x4a, 0x40, 0x4f, 0x4e}; + uint8_t pkt[] = {0x10, 0x13, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0xf, + 0x64, 0x0, 0x7, 0x93, 0x62, 0x1, 0xea, 0x48, 0x4c, 0xed}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc8, 0x38, 0x8f, 0xdb, 0xd2, 0x38, 0x9a, 0x17, 0xbf, 0xd1, 0x5, 0xf7, - 0x97, 0x6a, 0x3, 0x2, 0x10, 0x77, 0x57, 0x14, 0x28, 0xab, 0xef}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xef, 0xa3, 0x2c, 0x96, 0x53, 0x3, 0x41, 0xeb, 0x51, 0x90, 0xc1, 0x70, 0x7e, 0x47, - 0xf9, 0xd6, 0xda, 0x57, 0x68, 0xaf, 0xc8, 0xeb, 0x3b, 0xeb, 0x6e, 0x70, 0x9a, 0x74}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 24957; - uint8_t client_id_bytes[] = {0x1a, 0x14, 0x50, 0x14, 0x5, 0xa0, 0xe, 0xe2, 0x8d, 0xd, 0xfb}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.keep_alive = 3940; + uint8_t client_id_bytes[] = {0x93, 0x62, 0x1, 0xea, 0x48, 0x4c, 0xed}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf7, 0x8, 0x4a, 0x40, 0x4f, 0x4e}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; + uint8_t password_bytes[] = {0x10, 0x56, 0x57, 0xa1, 0xad, 0x57, 0x21, 0x2b, 0x9a, 0xeb, 0x7, + 0xa9, 0x88, 0x28, 0x4b, 0x98, 0xe0, 0xbe, 0x49, 0x34, 0x79}; + lwmqtt_string_t password = {21, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\DC4\245qv", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "\132\165\SUB\228Tg9\NULV.~\142\194\226:", _willMsg = -// "\176\179\172\a1r\164{\SOH\143\130V5\US-ElV\146\228\133\&4\185\GS", _properties = []} +// ConnectRequest {_username = Just "\167 \167\208\233f\167\246'\240T\252\&3!", _password = Just +// "\204ptBG\160\v\SUB\223!\EM\SI\STX\b\DEL+1Z", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, +// _willTopic = "\186To9\139\230@\227W\SUB\173\175\253\165\SI\195\133i\DC4\ESC\229\DC2=z\251\186\231", _willMsg = +// "rXO\rA\ESC\fQ\DC2\152\SO\ETB{\248\203\197%\175\203\235\227", _willProps = []}), _cleanSession = False, _keepAlive = +// 21475, _connID = "\130", _properties = []} TEST(Connect311QCTest, Encode11) { - uint8_t pkt[] = {0x10, 0x4a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x50, 0xeb, 0x0, 0xe, 0xee, 0x56, - 0x63, 0x5d, 0xd, 0x93, 0x8e, 0xb1, 0x3e, 0xe4, 0x85, 0x34, 0xb9, 0x1d, 0x0, 0xf, 0x69, 0x5c, - 0xdf, 0x64, 0xfe, 0xc9, 0xd0, 0x23, 0x75, 0x1a, 0xb8, 0xb2, 0xfe, 0x5e, 0x67, 0x0, 0x8, 0x82, - 0x8, 0x1, 0x6e, 0xf1, 0x44, 0x3c, 0xd0, 0x0, 0xd, 0xaa, 0xa9, 0x54, 0xb5, 0x7a, 0x5b, 0x38, - 0x1, 0xed, 0x41, 0xab, 0xd3, 0xa1, 0x0, 0x4, 0xd8, 0x2f, 0x49, 0xa7}; + uint8_t pkt[] = {0x10, 0x65, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x53, 0xe3, 0x0, 0x1, 0x82, + 0x0, 0x1b, 0xba, 0x54, 0x6f, 0x39, 0x8b, 0xe6, 0x40, 0xe3, 0x57, 0x1a, 0xad, 0xaf, 0xfd, + 0xa5, 0xf, 0xc3, 0x85, 0x69, 0x14, 0x1b, 0xe5, 0x12, 0x3d, 0x7a, 0xfb, 0xba, 0xe7, 0x0, + 0x15, 0x72, 0x58, 0x4f, 0xd, 0x41, 0x1b, 0xc, 0x51, 0x12, 0x98, 0xe, 0x17, 0x7b, 0xf8, + 0xcb, 0xc5, 0x25, 0xaf, 0xcb, 0xeb, 0xe3, 0x0, 0xe, 0xa7, 0x20, 0xa7, 0xd0, 0xe9, 0x66, + 0xa7, 0xf6, 0x27, 0xf0, 0x54, 0xfc, 0x33, 0x21, 0x0, 0x12, 0xcc, 0x70, 0x74, 0x42, 0x47, + 0xa0, 0xb, 0x1a, 0xdf, 0x21, 0x19, 0xf, 0x2, 0x8, 0x7f, 0x2b, 0x31, 0x5a}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5648,28 +5565,30 @@ TEST(Connect311QCTest, Encode11) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x69, 0x5c, 0xdf, 0x64, 0xfe, 0xc9, 0xd0, 0x23, - 0x75, 0x1a, 0xb8, 0xb2, 0xfe, 0x5e, 0x67}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x82, 0x8, 0x1, 0x6e, 0xf1, 0x44, 0x3c, 0xd0}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xba, 0x54, 0x6f, 0x39, 0x8b, 0xe6, 0x40, 0xe3, 0x57, 0x1a, 0xad, 0xaf, 0xfd, 0xa5, + 0xf, 0xc3, 0x85, 0x69, 0x14, 0x1b, 0xe5, 0x12, 0x3d, 0x7a, 0xfb, 0xba, 0xe7}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x72, 0x58, 0x4f, 0xd, 0x41, 0x1b, 0xc, 0x51, 0x12, 0x98, 0xe, + 0x17, 0x7b, 0xf8, 0xcb, 0xc5, 0x25, 0xaf, 0xcb, 0xeb, 0xe3}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 20715; - uint8_t client_id_bytes[] = {0xee, 0x56, 0x63, 0x5d, 0xd, 0x93, 0x8e, 0xb1, 0x3e, 0xe4, 0x85, 0x34, 0xb9, 0x1d}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.keep_alive = 21475; + uint8_t client_id_bytes[] = {0x82}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xaa, 0xa9, 0x54, 0xb5, 0x7a, 0x5b, 0x38, 0x1, 0xed, 0x41, 0xab, 0xd3, 0xa1}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa7, 0x20, 0xa7, 0xd0, 0xe9, 0x66, 0xa7, 0xf6, 0x27, 0xf0, 0x54, 0xfc, 0x33, 0x21}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xd8, 0x2f, 0x49, 0xa7}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xcc, 0x70, 0x74, 0x42, 0x47, 0xa0, 0xb, 0x1a, 0xdf, + 0x21, 0x19, 0xf, 0x2, 0x8, 0x7f, 0x2b, 0x31, 0x5a}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5679,12 +5598,15 @@ TEST(Connect311QCTest, Encode11) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "\128", _willMsg = "G\244\250\238\173\220\204", _willProps = []}), _cleanSession = True, -// _keepAlive = 28847, _connID = "IP", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "4\244\&1\217\142\&8\NAK5", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "e;\194\&7\237P\201 w\216\149l\171W\RS\241>\135`\SYN\ENQ\197\t", +// _willMsg = "2\174", _willProps = []}), _cleanSession = True, _keepAlive = 29263, _connID = +// "\173Q\DC4\163\185\129\144\238\155\169Q\252K\131\227\&9\CAN\v\239", _properties = []} TEST(Connect311QCTest, Encode12) { - uint8_t pkt[] = {0x10, 0x1a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x70, 0xaf, 0x0, 0x2, - 0x49, 0x50, 0x0, 0x1, 0x80, 0x0, 0x7, 0x47, 0xf4, 0xfa, 0xee, 0xad, 0xdc, 0xcc}; + uint8_t pkt[] = {0x10, 0x3c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x72, 0x4f, 0x0, 0x13, 0xad, 0x51, + 0x14, 0xa3, 0xb9, 0x81, 0x90, 0xee, 0x9b, 0xa9, 0x51, 0xfc, 0x4b, 0x83, 0xe3, 0x39, 0x18, 0xb, + 0xef, 0x0, 0x17, 0x65, 0x3b, 0xc2, 0x37, 0xed, 0x50, 0xc9, 0x20, 0x77, 0xd8, 0x95, 0x6c, 0xab, + 0x57, 0x1e, 0xf1, 0x3e, 0x87, 0x60, 0x16, 0x5, 0xc5, 0x9, 0x0, 0x2, 0x32, 0xae}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5695,22 +5617,27 @@ TEST(Connect311QCTest, Encode12) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x80}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x47, 0xf4, 0xfa, 0xee, 0xad, 0xdc, 0xcc}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x65, 0x3b, 0xc2, 0x37, 0xed, 0x50, 0xc9, 0x20, 0x77, 0xd8, 0x95, 0x6c, + 0xab, 0x57, 0x1e, 0xf1, 0x3e, 0x87, 0x60, 0x16, 0x5, 0xc5, 0x9}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x32, 0xae}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 28847; - uint8_t client_id_bytes[] = {0x49, 0x50}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.keep_alive = 29263; + uint8_t client_id_bytes[] = {0xad, 0x51, 0x14, 0xa3, 0xb9, 0x81, 0x90, 0xee, 0x9b, 0xa9, + 0x51, 0xfc, 0x4b, 0x83, 0xe3, 0x39, 0x18, 0xb, 0xef}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t password_bytes[] = {0x34, 0xf4, 0x31, 0xd9, 0x8e, 0x38, 0x15, 0x35}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5719,99 +5646,102 @@ TEST(Connect311QCTest, Encode12) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "hWE\168_M\187,\211\130\251B\217\\\139X\246p\GSUQ\252\&7\198\223\143}\191\164", -// _password = Just "\221\"\180", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "/\161\ETX\236\174\202\142\ACK\ENQ&\231\230Zg", _willMsg = "\164:(\192D\224", _willProps = []}), _cleanSession = -// False, _keepAlive = 7983, _connID = "\255\v<\218q\253\223)BQ\136u\236\220\156&\164\".", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\199\154\ACK\130\147\145\141\149\SOH", _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 26934, _connID = "\185\183=\217", _properties = []} TEST(Connect311QCTest, Encode13) { - uint8_t pkt[] = {0x10, 0x5b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x1f, 0x2f, 0x0, 0x13, 0xff, 0xb, - 0x3c, 0xda, 0x71, 0xfd, 0xdf, 0x29, 0x42, 0x51, 0x88, 0x75, 0xec, 0xdc, 0x9c, 0x26, 0xa4, 0x22, - 0x2e, 0x0, 0xe, 0x2f, 0xa1, 0x3, 0xec, 0xae, 0xca, 0x8e, 0x6, 0x5, 0x26, 0xe7, 0xe6, 0x5a, - 0x67, 0x0, 0x6, 0xa4, 0x3a, 0x28, 0xc0, 0x44, 0xe0, 0x0, 0x1d, 0x68, 0x57, 0x45, 0xa8, 0x5f, - 0x4d, 0xbb, 0x2c, 0xd3, 0x82, 0xfb, 0x42, 0xd9, 0x5c, 0x8b, 0x58, 0xf6, 0x70, 0x1d, 0x55, 0x51, - 0xfc, 0x37, 0xc6, 0xdf, 0x8f, 0x7d, 0xbf, 0xa4, 0x0, 0x3, 0xdd, 0x22, 0xb4}; + uint8_t pkt[] = {0x10, 0x10, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, + 0x2, 0x69, 0x36, 0x0, 0x4, 0xb9, 0xb7, 0x3d, 0xd9}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2f, 0xa1, 0x3, 0xec, 0xae, 0xca, 0x8e, 0x6, 0x5, 0x26, 0xe7, 0xe6, 0x5a, 0x67}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa4, 0x3a, 0x28, 0xc0, 0x44, 0xe0}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 7983; - uint8_t client_id_bytes[] = {0xff, 0xb, 0x3c, 0xda, 0x71, 0xfd, 0xdf, 0x29, 0x42, 0x51, - 0x88, 0x75, 0xec, 0xdc, 0x9c, 0x26, 0xa4, 0x22, 0x2e}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 26934; + uint8_t client_id_bytes[] = {0xb9, 0xb7, 0x3d, 0xd9}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x68, 0x57, 0x45, 0xa8, 0x5f, 0x4d, 0xbb, 0x2c, 0xd3, 0x82, 0xfb, 0x42, 0xd9, 0x5c, 0x8b, - 0x58, 0xf6, 0x70, 0x1d, 0x55, 0x51, 0xfc, 0x37, 0xc6, 0xdf, 0x8f, 0x7d, 0xbf, 0xa4}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xdd, 0x22, 0xb4}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xc7, 0x9a, 0x6, 0x82, 0x93, 0x91, 0x8d, 0x95, 0x1}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "I\SI\221-\132?i\130\DC4\231\186", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 15604, _connID = "\246\207\188\170T\240a\203\184x\230X\199\147{8_\SO;\188)", -// _properties = []} +// ConnectRequest {_username = Just +// "-\247+\DC1\233}bt\ENQ\200\241\ENQ\SI\v\163F\173\246\236h\217\149Ur\237\DC3\244\208\217\EOT", _password = Just +// "\181\199$\147\180\ETX6\202", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\227\174\130\185\246$4`\SI^`\215\195\238\204OL\188\134\144\164\DLE^-\187\STX\DC4\224\178", _willMsg = +// "\210\221\DC4\SYN\212^\167\212v\131\142\DELq\191\136\237\&6\203\227.\181\SYN\138", _willProps = []}), _cleanSession = +// False, _keepAlive = 20204, _connID = "\140\212\218\244p", _properties = []} TEST(Connect311QCTest, Encode14) { - uint8_t pkt[] = {0x10, 0x21, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x3c, 0xf4, - 0x0, 0x15, 0xf6, 0xcf, 0xbc, 0xaa, 0x54, 0xf0, 0x61, 0xcb, 0xb8, 0x78, - 0xe6, 0x58, 0xc7, 0x93, 0x7b, 0x38, 0x5f, 0xe, 0x3b, 0xbc, 0x29}; + uint8_t pkt[] = {0x10, 0x73, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x4e, 0xec, 0x0, 0x5, 0x8c, 0xd4, 0xda, + 0xf4, 0x70, 0x0, 0x1d, 0xe3, 0xae, 0x82, 0xb9, 0xf6, 0x24, 0x34, 0x60, 0xf, 0x5e, 0x60, 0xd7, 0xc3, + 0xee, 0xcc, 0x4f, 0x4c, 0xbc, 0x86, 0x90, 0xa4, 0x10, 0x5e, 0x2d, 0xbb, 0x2, 0x14, 0xe0, 0xb2, 0x0, + 0x17, 0xd2, 0xdd, 0x14, 0x16, 0xd4, 0x5e, 0xa7, 0xd4, 0x76, 0x83, 0x8e, 0x7f, 0x71, 0xbf, 0x88, 0xed, + 0x36, 0xcb, 0xe3, 0x2e, 0xb5, 0x16, 0x8a, 0x0, 0x1e, 0x2d, 0xf7, 0x2b, 0x11, 0xe9, 0x7d, 0x62, 0x74, + 0x5, 0xc8, 0xf1, 0x5, 0xf, 0xb, 0xa3, 0x46, 0xad, 0xf6, 0xec, 0x68, 0xd9, 0x95, 0x55, 0x72, 0xed, + 0x13, 0xf4, 0xd0, 0xd9, 0x4, 0x0, 0x8, 0xb5, 0xc7, 0x24, 0x93, 0xb4, 0x3, 0x36, 0xca}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe3, 0xae, 0x82, 0xb9, 0xf6, 0x24, 0x34, 0x60, 0xf, 0x5e, + 0x60, 0xd7, 0xc3, 0xee, 0xcc, 0x4f, 0x4c, 0xbc, 0x86, 0x90, + 0xa4, 0x10, 0x5e, 0x2d, 0xbb, 0x2, 0x14, 0xe0, 0xb2}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd2, 0xdd, 0x14, 0x16, 0xd4, 0x5e, 0xa7, 0xd4, 0x76, 0x83, 0x8e, 0x7f, + 0x71, 0xbf, 0x88, 0xed, 0x36, 0xcb, 0xe3, 0x2e, 0xb5, 0x16, 0x8a}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 15604; - uint8_t client_id_bytes[] = {0xf6, 0xcf, 0xbc, 0xaa, 0x54, 0xf0, 0x61, 0xcb, 0xb8, 0x78, 0xe6, - 0x58, 0xc7, 0x93, 0x7b, 0x38, 0x5f, 0xe, 0x3b, 0xbc, 0x29}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.keep_alive = 20204; + uint8_t client_id_bytes[] = {0x8c, 0xd4, 0xda, 0xf4, 0x70}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x49, 0xf, 0xdd, 0x2d, 0x84, 0x3f, 0x69, 0x82, 0x14, 0xe7, 0xba}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x2d, 0xf7, 0x2b, 0x11, 0xe9, 0x7d, 0x62, 0x74, 0x5, 0xc8, 0xf1, 0x5, 0xf, 0xb, 0xa3, + 0x46, 0xad, 0xf6, 0xec, 0x68, 0xd9, 0x95, 0x55, 0x72, 0xed, 0x13, 0xf4, 0xd0, 0xd9, 0x4}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xb5, 0xc7, 0x24, 0x93, 0xb4, 0x3, 0x36, 0xca}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "Y4l\EOT[\245\243\233\211\199c\CANhx\DC4\190g\175\RS\147\191'\223\137<6", _willMsg = -// "\139|6\245\194\246\236j", _willProps = []}), _cleanSession = True, _keepAlive = 1098, _connID = -// "\242\250\148C\fX\219\222", _properties = []} +// ConnectRequest {_username = Just "r=\231\144i:\207\214h\149\199\202J", _password = Just "2\202\ACK*\135", _lastWill = +// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "rx&4\204G@rz\177>", _willMsg = "\237\222\176\197", +// _willProps = []}), _cleanSession = False, _keepAlive = 11274, _connID = +// "\223\t\143\166\173\230\156\142\250\&1\248\EOT\185\ACK\235\144\155+\249\150\182\136\232\133\206", _properties = []} TEST(Connect311QCTest, Encode15) { - uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x4, 0x4a, 0x0, 0x8, 0xf2, - 0xfa, 0x94, 0x43, 0xc, 0x58, 0xdb, 0xde, 0x0, 0x1a, 0x59, 0x34, 0x6c, 0x4, 0x5b, 0xf5, - 0xf3, 0xe9, 0xd3, 0xc7, 0x63, 0x18, 0x68, 0x78, 0x14, 0xbe, 0x67, 0xaf, 0x1e, 0x93, 0xbf, - 0x27, 0xdf, 0x89, 0x3c, 0x36, 0x0, 0x8, 0x8b, 0x7c, 0x36, 0xf5, 0xc2, 0xf6, 0xec, 0x6a}; + uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x2c, 0xa, 0x0, 0x19, 0xdf, 0x9, + 0x8f, 0xa6, 0xad, 0xe6, 0x9c, 0x8e, 0xfa, 0x31, 0xf8, 0x4, 0xb9, 0x6, 0xeb, 0x90, 0x9b, 0x2b, + 0xf9, 0x96, 0xb6, 0x88, 0xe8, 0x85, 0xce, 0x0, 0xb, 0x72, 0x78, 0x26, 0x34, 0xcc, 0x47, 0x40, + 0x72, 0x7a, 0xb1, 0x3e, 0x0, 0x4, 0xed, 0xde, 0xb0, 0xc5, 0x0, 0xd, 0x72, 0x3d, 0xe7, 0x90, + 0x69, 0x3a, 0xcf, 0xd6, 0x68, 0x95, 0xc7, 0xca, 0x4a, 0x0, 0x5, 0x32, 0xca, 0x6, 0x2a, 0x87}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5822,23 +5752,29 @@ TEST(Connect311QCTest, Encode15) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x59, 0x34, 0x6c, 0x4, 0x5b, 0xf5, 0xf3, 0xe9, 0xd3, 0xc7, 0x63, 0x18, 0x68, - 0x78, 0x14, 0xbe, 0x67, 0xaf, 0x1e, 0x93, 0xbf, 0x27, 0xdf, 0x89, 0x3c, 0x36}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x8b, 0x7c, 0x36, 0xf5, 0xc2, 0xf6, 0xec, 0x6a}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x72, 0x78, 0x26, 0x34, 0xcc, 0x47, 0x40, 0x72, 0x7a, 0xb1, 0x3e}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xed, 0xde, 0xb0, 0xc5}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 1098; - uint8_t client_id_bytes[] = {0xf2, 0xfa, 0x94, 0x43, 0xc, 0x58, 0xdb, 0xde}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 11274; + uint8_t client_id_bytes[] = {0xdf, 0x9, 0x8f, 0xa6, 0xad, 0xe6, 0x9c, 0x8e, 0xfa, 0x31, 0xf8, 0x4, 0xb9, + 0x6, 0xeb, 0x90, 0x9b, 0x2b, 0xf9, 0x96, 0xb6, 0x88, 0xe8, 0x85, 0xce}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t username_bytes[] = {0x72, 0x3d, 0xe7, 0x90, 0x69, 0x3a, 0xcf, 0xd6, 0x68, 0x95, 0xc7, 0xca, 0x4a}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x32, 0xca, 0x6, 0x2a, 0x87}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5847,17 +5783,17 @@ TEST(Connect311QCTest, Encode15) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "\DC3\243\159\217u&\163Y\NAKhh\155\169\&4\142\166\213k\248t\130\212\216\DC3\173\140\DLE\DC4R:", _password = Just -// "&m\142x\192", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "\146\238\tq\148_\147\ENQ", _willMsg = "\251", _willProps = []}), _cleanSession = True, _keepAlive = 25890, _connID = -// "\r\156\147\220\152hj\136^\SUB\177\ETX>i", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "#Q\186\\\192N\NUL\ETB\159\205\a\194`T\211\EM\157\133\ACKf;Z\189\220\129\164", _willMsg = +// "\EOT\228!\252NLON\246\199\210g\235\225\255\130\139\v ", _willProps = []}), _cleanSession = True, _keepAlive = 13058, +// _connID = ".d\DC4\204\250e\224\180\140\158\RS3)G\143\172\SOST\ETBEX", _properties = []} TEST(Connect311QCTest, Encode16) { - uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe6, 0x65, 0x22, 0x0, 0xe, 0xd, 0x9c, - 0x93, 0xdc, 0x98, 0x68, 0x6a, 0x88, 0x5e, 0x1a, 0xb1, 0x3, 0x3e, 0x69, 0x0, 0x8, 0x92, 0xee, - 0x9, 0x71, 0x94, 0x5f, 0x93, 0x5, 0x0, 0x1, 0xfb, 0x0, 0x1e, 0x13, 0xf3, 0x9f, 0xd9, 0x75, - 0x26, 0xa3, 0x59, 0x15, 0x68, 0x68, 0x9b, 0xa9, 0x34, 0x8e, 0xa6, 0xd5, 0x6b, 0xf8, 0x74, 0x82, - 0xd4, 0xd8, 0x13, 0xad, 0x8c, 0x10, 0x14, 0x52, 0x3a, 0x0, 0x5, 0x26, 0x6d, 0x8e, 0x78, 0xc0}; + uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x33, 0x2, 0x0, 0x16, 0x2e, + 0x64, 0x14, 0xcc, 0xfa, 0x65, 0xe0, 0xb4, 0x8c, 0x9e, 0x1e, 0x33, 0x29, 0x47, 0x8f, 0xac, + 0xe, 0x53, 0x54, 0x17, 0x45, 0x58, 0x0, 0x1a, 0x23, 0x51, 0xba, 0x5c, 0xc0, 0x4e, 0x0, + 0x17, 0x9f, 0xcd, 0x7, 0xc2, 0x60, 0x54, 0xd3, 0x19, 0x9d, 0x85, 0x6, 0x66, 0x3b, 0x5a, + 0xbd, 0xdc, 0x81, 0xa4, 0x0, 0x13, 0x4, 0xe4, 0x21, 0xfc, 0x4e, 0x4c, 0x4f, 0x4e, 0xf6, + 0xc7, 0xd2, 0x67, 0xeb, 0xe1, 0xff, 0x82, 0x8b, 0xb, 0x20}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5868,29 +5804,25 @@ TEST(Connect311QCTest, Encode16) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x92, 0xee, 0x9, 0x71, 0x94, 0x5f, 0x93, 0x5}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfb}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x23, 0x51, 0xba, 0x5c, 0xc0, 0x4e, 0x0, 0x17, 0x9f, 0xcd, 0x7, 0xc2, 0x60, + 0x54, 0xd3, 0x19, 0x9d, 0x85, 0x6, 0x66, 0x3b, 0x5a, 0xbd, 0xdc, 0x81, 0xa4}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4, 0xe4, 0x21, 0xfc, 0x4e, 0x4c, 0x4f, 0x4e, 0xf6, 0xc7, + 0xd2, 0x67, 0xeb, 0xe1, 0xff, 0x82, 0x8b, 0xb, 0x20}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 25890; - uint8_t client_id_bytes[] = {0xd, 0x9c, 0x93, 0xdc, 0x98, 0x68, 0x6a, 0x88, 0x5e, 0x1a, 0xb1, 0x3, 0x3e, 0x69}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.keep_alive = 13058; + uint8_t client_id_bytes[] = {0x2e, 0x64, 0x14, 0xcc, 0xfa, 0x65, 0xe0, 0xb4, 0x8c, 0x9e, 0x1e, + 0x33, 0x29, 0x47, 0x8f, 0xac, 0xe, 0x53, 0x54, 0x17, 0x45, 0x58}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x13, 0xf3, 0x9f, 0xd9, 0x75, 0x26, 0xa3, 0x59, 0x15, 0x68, 0x68, 0x9b, 0xa9, 0x34, 0x8e, - 0xa6, 0xd5, 0x6b, 0xf8, 0x74, 0x82, 0xd4, 0xd8, 0x13, 0xad, 0x8c, 0x10, 0x14, 0x52, 0x3a}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x26, 0x6d, 0x8e, 0x78, 0xc0}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5899,15 +5831,12 @@ TEST(Connect311QCTest, Encode16) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\193<~>\224\218\213\230+\253\204S21l", _password = Just "\208`1MG\177\a\230\254", -// _lastWill = Nothing, _cleanSession = False, _keepAlive = 24689, _connID = -// "\215'G$\ESCg\194\223\191:\ETX\166\139\193n\180\156\140\165\209\206\tj\241\ETB\237\210\212Jt", _properties = []} +// ConnectRequest {_username = Just "-\157\STX\167\DC4\171\157t", _password = Just "/j-", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 2165, _connID = ";l\192\DC1N\156z\170\170\165[\f", _properties = []} TEST(Connect311QCTest, Encode17) { - uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x60, 0x71, 0x0, 0x1e, 0xd7, - 0x27, 0x47, 0x24, 0x1b, 0x67, 0xc2, 0xdf, 0xbf, 0x3a, 0x3, 0xa6, 0x8b, 0xc1, 0x6e, 0xb4, - 0x9c, 0x8c, 0xa5, 0xd1, 0xce, 0x9, 0x6a, 0xf1, 0x17, 0xed, 0xd2, 0xd4, 0x4a, 0x74, 0x0, - 0xf, 0xc1, 0x3c, 0x7e, 0x3e, 0xe0, 0xda, 0xd5, 0xe6, 0x2b, 0xfd, 0xcc, 0x53, 0x32, 0x31, - 0x6c, 0x0, 0x9, 0xd0, 0x60, 0x31, 0x4d, 0x47, 0xb1, 0x7, 0xe6, 0xfe}; + uint8_t pkt[] = {0x10, 0x27, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x8, 0x75, 0x0, 0xc, + 0x3b, 0x6c, 0xc0, 0x11, 0x4e, 0x9c, 0x7a, 0xaa, 0xaa, 0xa5, 0x5b, 0xc, 0x0, 0x8, + 0x2d, 0x9d, 0x2, 0xa7, 0x14, 0xab, 0x9d, 0x74, 0x0, 0x3, 0x2f, 0x6a, 0x2d}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5916,17 +5845,15 @@ TEST(Connect311QCTest, Encode17) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 24689; - uint8_t client_id_bytes[] = {0xd7, 0x27, 0x47, 0x24, 0x1b, 0x67, 0xc2, 0xdf, 0xbf, 0x3a, - 0x3, 0xa6, 0x8b, 0xc1, 0x6e, 0xb4, 0x9c, 0x8c, 0xa5, 0xd1, - 0xce, 0x9, 0x6a, 0xf1, 0x17, 0xed, 0xd2, 0xd4, 0x4a, 0x74}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.keep_alive = 2165; + uint8_t client_id_bytes[] = {0x3b, 0x6c, 0xc0, 0x11, 0x4e, 0x9c, 0x7a, 0xaa, 0xaa, 0xa5, 0x5b, 0xc}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xc1, 0x3c, 0x7e, 0x3e, 0xe0, 0xda, 0xd5, 0xe6, 0x2b, 0xfd, 0xcc, 0x53, 0x32, 0x31, 0x6c}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x2d, 0x9d, 0x2, 0xa7, 0x14, 0xab, 0x9d, 0x74}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xd0, 0x60, 0x31, 0x4d, 0x47, 0xb1, 0x7, 0xe6, 0xfe}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x2f, 0x6a, 0x2d}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); @@ -5936,17 +5863,15 @@ TEST(Connect311QCTest, Encode17) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "\163}\NULy\RS\158NX4\187\195\203rzn\170(\172\129\146(]jr\168Q\169 \195\200", _lastWill = Just (LastWill {_willRetain -// = True, _willQoS = QoS2, _willTopic = "", _willMsg = "\244~\217'Tx\238\164\179\193!,\167", _willProps = []}), -// _cleanSession = False, _keepAlive = 26060, _connID = -// "ta\163\130\232\170\157\144\190\ETB\172\170g\"\136\233\NAK\NAK\231\ETX\160\SYN~\ENQG\220\208\150\241", _properties = -// []} +// ConnectRequest {_username = Nothing, _password = Just "^a,Y\US\230/\202\240\t\229\218\191\SUBdl", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\170", _willMsg = +// "@d\157b\SYN\150\&0\164\ENQ\236O\149e\129\218\210wSKU\DC4y\SOH\188\163m\EOT", _willProps = []}), _cleanSession = +// True, _keepAlive = 10569, _connID = "\185Xg$ZH\152\132 !", _properties = []} TEST(Connect311QCTest, Encode18) { - uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x65, 0xcc, 0x0, 0x1d, 0x74, - 0x61, 0xa3, 0x82, 0xe8, 0xaa, 0x9d, 0x90, 0xbe, 0x17, 0xac, 0xaa, 0x67, 0x22, 0x88, 0xe9, - 0x15, 0x15, 0xe7, 0x3, 0xa0, 0x16, 0x7e, 0x5, 0x47, 0xdc, 0xd0, 0x96, 0xf1, 0x0, 0x0, - 0x0, 0xd, 0xf4, 0x7e, 0xd9, 0x27, 0x54, 0x78, 0xee, 0xa4, 0xb3, 0xc1, 0x21, 0x2c, 0xa7}; + uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x29, 0x49, 0x0, 0xa, + 0xb9, 0x58, 0x67, 0x24, 0x5a, 0x48, 0x98, 0x84, 0x20, 0x21, 0x0, 0x1, 0xaa, 0x0, + 0x1b, 0x40, 0x64, 0x9d, 0x62, 0x16, 0x96, 0x30, 0xa4, 0x5, 0xec, 0x4f, 0x95, 0x65, + 0x81, 0xda, 0xd2, 0x77, 0x53, 0x4b, 0x55, 0x14, 0x79, 0x1, 0xbc, 0xa3, 0x6d, 0x4}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5957,26 +5882,26 @@ TEST(Connect311QCTest, Encode18) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf4, 0x7e, 0xd9, 0x27, 0x54, 0x78, 0xee, 0xa4, 0xb3, 0xc1, 0x21, 0x2c, 0xa7}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xaa}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x40, 0x64, 0x9d, 0x62, 0x16, 0x96, 0x30, 0xa4, 0x5, 0xec, 0x4f, 0x95, 0x65, 0x81, + 0xda, 0xd2, 0x77, 0x53, 0x4b, 0x55, 0x14, 0x79, 0x1, 0xbc, 0xa3, 0x6d, 0x4}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 26060; - uint8_t client_id_bytes[] = {0x74, 0x61, 0xa3, 0x82, 0xe8, 0xaa, 0x9d, 0x90, 0xbe, 0x17, 0xac, 0xaa, 0x67, 0x22, 0x88, - 0xe9, 0x15, 0x15, 0xe7, 0x3, 0xa0, 0x16, 0x7e, 0x5, 0x47, 0xdc, 0xd0, 0x96, 0xf1}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 10569; + uint8_t client_id_bytes[] = {0xb9, 0x58, 0x67, 0x24, 0x5a, 0x48, 0x98, 0x84, 0x20, 0x21}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xa3, 0x7d, 0x0, 0x79, 0x1e, 0x9e, 0x4e, 0x58, 0x34, 0xbb, 0xc3, 0xcb, 0x72, 0x7a, 0x6e, - 0xaa, 0x28, 0xac, 0x81, 0x92, 0x28, 0x5d, 0x6a, 0x72, 0xa8, 0x51, 0xa9, 0x20, 0xc3, 0xc8}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x5e, 0x61, 0x2c, 0x59, 0x1f, 0xe6, 0x2f, 0xca, + 0xf0, 0x9, 0xe5, 0xda, 0xbf, 0x1a, 0x64, 0x6c}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5986,73 +5911,50 @@ TEST(Connect311QCTest, Encode18) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "b\218e\239\183\CAN\191\&2\226\216\211h\139\177i\206P\217\216\241\162\247\&3Q0\255G", _password = Just -// "\134h4\201\252\b\204\DC1\165,\191\253\vJ\240X^\167\US\159\224(\229f\223c", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS0, _willTopic = "\165Ue\188\167\r\197\235M\161$\227j)\243\233e!X\DC2M\158}", _willMsg = -// ":])y\210Yhl\128}\247\163hG", _willProps = []}), _cleanSession = False, _keepAlive = 4784, _connID = -// "o\EOT\144\EOTo`,\SIr\191\185\&6i\246\150\254", _properties = []} +// ConnectRequest {_username = Just "\251\140\165-\247FkO\242Y\DC2\f\236\DC2\223pL\DC1+\246\255", _password = Nothing, +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 692, _connID = +// "h\254\SUB\167\243\223\&6e\ACK\209\169\208{K\152\224:\222\217Se]1", _properties = []} TEST(Connect311QCTest, Encode19) { - uint8_t pkt[] = {0x10, 0x7e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x12, 0xb0, 0x0, 0x10, 0x6f, 0x4, - 0x90, 0x4, 0x6f, 0x60, 0x2c, 0xf, 0x72, 0xbf, 0xb9, 0x36, 0x69, 0xf6, 0x96, 0xfe, 0x0, 0x17, - 0xa5, 0x55, 0x65, 0xbc, 0xa7, 0xd, 0xc5, 0xeb, 0x4d, 0xa1, 0x24, 0xe3, 0x6a, 0x29, 0xf3, 0xe9, - 0x65, 0x21, 0x58, 0x12, 0x4d, 0x9e, 0x7d, 0x0, 0xe, 0x3a, 0x5d, 0x29, 0x79, 0xd2, 0x59, 0x68, - 0x6c, 0x80, 0x7d, 0xf7, 0xa3, 0x68, 0x47, 0x0, 0x1b, 0x62, 0xda, 0x65, 0xef, 0xb7, 0x18, 0xbf, - 0x32, 0xe2, 0xd8, 0xd3, 0x68, 0x8b, 0xb1, 0x69, 0xce, 0x50, 0xd9, 0xd8, 0xf1, 0xa2, 0xf7, 0x33, - 0x51, 0x30, 0xff, 0x47, 0x0, 0x1a, 0x86, 0x68, 0x34, 0xc9, 0xfc, 0x8, 0xcc, 0x11, 0xa5, 0x2c, - 0xbf, 0xfd, 0xb, 0x4a, 0xf0, 0x58, 0x5e, 0xa7, 0x1f, 0x9f, 0xe0, 0x28, 0xe5, 0x66, 0xdf, 0x63}; + uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x2, 0xb4, 0x0, 0x17, 0x68, + 0xfe, 0x1a, 0xa7, 0xf3, 0xdf, 0x36, 0x65, 0x6, 0xd1, 0xa9, 0xd0, 0x7b, 0x4b, 0x98, 0xe0, + 0x3a, 0xde, 0xd9, 0x53, 0x65, 0x5d, 0x31, 0x0, 0x15, 0xfb, 0x8c, 0xa5, 0x2d, 0xf7, 0x46, + 0x6b, 0x4f, 0xf2, 0x59, 0x12, 0xc, 0xec, 0x12, 0xdf, 0x70, 0x4c, 0x11, 0x2b, 0xf6, 0xff}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa5, 0x55, 0x65, 0xbc, 0xa7, 0xd, 0xc5, 0xeb, 0x4d, 0xa1, 0x24, 0xe3, - 0x6a, 0x29, 0xf3, 0xe9, 0x65, 0x21, 0x58, 0x12, 0x4d, 0x9e, 0x7d}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3a, 0x5d, 0x29, 0x79, 0xd2, 0x59, 0x68, 0x6c, 0x80, 0x7d, 0xf7, 0xa3, 0x68, 0x47}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 4784; - uint8_t client_id_bytes[] = {0x6f, 0x4, 0x90, 0x4, 0x6f, 0x60, 0x2c, 0xf, - 0x72, 0xbf, 0xb9, 0x36, 0x69, 0xf6, 0x96, 0xfe}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.keep_alive = 692; + uint8_t client_id_bytes[] = {0x68, 0xfe, 0x1a, 0xa7, 0xf3, 0xdf, 0x36, 0x65, 0x6, 0xd1, 0xa9, 0xd0, + 0x7b, 0x4b, 0x98, 0xe0, 0x3a, 0xde, 0xd9, 0x53, 0x65, 0x5d, 0x31}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x62, 0xda, 0x65, 0xef, 0xb7, 0x18, 0xbf, 0x32, 0xe2, 0xd8, 0xd3, 0x68, 0x8b, 0xb1, - 0x69, 0xce, 0x50, 0xd9, 0xd8, 0xf1, 0xa2, 0xf7, 0x33, 0x51, 0x30, 0xff, 0x47}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xfb, 0x8c, 0xa5, 0x2d, 0xf7, 0x46, 0x6b, 0x4f, 0xf2, 0x59, 0x12, + 0xc, 0xec, 0x12, 0xdf, 0x70, 0x4c, 0x11, 0x2b, 0xf6, 0xff}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x86, 0x68, 0x34, 0xc9, 0xfc, 0x8, 0xcc, 0x11, 0xa5, 0x2c, 0xbf, 0xfd, 0xb, - 0x4a, 0xf0, 0x58, 0x5e, 0xa7, 0x1f, 0x9f, 0xe0, 0x28, 0xe5, 0x66, 0xdf, 0x63}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "%0V8\236", _password = Just "Q\245\GS\148#\160\195\156\184jCX\DC3\EM4k", _lastWill -// = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "w%h\153A\237", _willMsg = "\GS\201n\b\226\NUL", -// _willProps = []}), _cleanSession = True, _keepAlive = 17312, _connID = "\201\234;\NAKS", _properties = []} +// ConnectRequest {_username = Just "NZ\205t\136\"\192\172", _password = Just ";", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = +// "I\178\221P\DC2\179\161\234\145\EOT-\160eY\DEL'\191\250\&5|\172\EOT\240", _willMsg = +// "D]Y\226\&7\ESC\249\US8w\142\212z\211\143@\168d\NUL\149\STX\220e2", _willProps = []}), _cleanSession = False, +// _keepAlive = 2830, _connID = "\244\148g", _properties = []} TEST(Connect311QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x43, 0xa0, 0x0, 0x5, 0xc9, - 0xea, 0x3b, 0x15, 0x53, 0x0, 0x6, 0x77, 0x25, 0x68, 0x99, 0x41, 0xed, 0x0, 0x6, 0x1d, - 0xc9, 0x6e, 0x8, 0xe2, 0x0, 0x0, 0x5, 0x25, 0x30, 0x56, 0x38, 0xec, 0x0, 0x10, 0x51, - 0xf5, 0x1d, 0x94, 0x23, 0xa0, 0xc3, 0x9c, 0xb8, 0x6a, 0x43, 0x58, 0x13, 0x19, 0x34, 0x6b}; + uint8_t pkt[] = {0x10, 0x4f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0xb, 0xe, 0x0, 0x3, 0xf4, 0x94, 0x67, + 0x0, 0x17, 0x49, 0xb2, 0xdd, 0x50, 0x12, 0xb3, 0xa1, 0xea, 0x91, 0x4, 0x2d, 0xa0, 0x65, 0x59, 0x7f, + 0x27, 0xbf, 0xfa, 0x35, 0x7c, 0xac, 0x4, 0xf0, 0x0, 0x18, 0x44, 0x5d, 0x59, 0xe2, 0x37, 0x1b, 0xf9, + 0x1f, 0x38, 0x77, 0x8e, 0xd4, 0x7a, 0xd3, 0x8f, 0x40, 0xa8, 0x64, 0x0, 0x95, 0x2, 0xdc, 0x65, 0x32, + 0x0, 0x8, 0x4e, 0x5a, 0xcd, 0x74, 0x88, 0x22, 0xc0, 0xac, 0x0, 0x1, 0x3b}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6063,10 +5965,12 @@ TEST(Connect311QCTest, Encode20) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x77, 0x25, 0x68, 0x99, 0x41, 0xed}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1d, 0xc9, 0x6e, 0x8, 0xe2, 0x0}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x49, 0xb2, 0xdd, 0x50, 0x12, 0xb3, 0xa1, 0xea, 0x91, 0x4, 0x2d, 0xa0, + 0x65, 0x59, 0x7f, 0x27, 0xbf, 0xfa, 0x35, 0x7c, 0xac, 0x4, 0xf0}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x44, 0x5d, 0x59, 0xe2, 0x37, 0x1b, 0xf9, 0x1f, 0x38, 0x77, 0x8e, 0xd4, + 0x7a, 0xd3, 0x8f, 0x40, 0xa8, 0x64, 0x0, 0x95, 0x2, 0xdc, 0x65, 0x32}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; @@ -6074,17 +5978,16 @@ TEST(Connect311QCTest, Encode20) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 17312; - uint8_t client_id_bytes[] = {0xc9, 0xea, 0x3b, 0x15, 0x53}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 2830; + uint8_t client_id_bytes[] = {0xf4, 0x94, 0x67}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x25, 0x30, 0x56, 0x38, 0xec}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x4e, 0x5a, 0xcd, 0x74, 0x88, 0x22, 0xc0, 0xac}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x51, 0xf5, 0x1d, 0x94, 0x23, 0xa0, 0xc3, 0x9c, - 0xb8, 0x6a, 0x43, 0x58, 0x13, 0x19, 0x34, 0x6b}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x3b}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6094,17 +5997,20 @@ TEST(Connect311QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\n\216?v+\184\ACKT", _password = Just "f\232\200\n", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "R\180\EM\225w\208\US\DC2X5\243[\225:a\225\DC17\225BK4", _willMsg -// = "\SUB\214\DC3\210\166<\201\147Vy\142\f\161\223BFAO,\EOT\178OU", _willProps = []}), _cleanSession = True, _keepAlive -// = 20729, _connID = ")\f6\175\243\RS\147wQ\178\140rR", _properties = []} +// ConnectRequest {_username = Just "\218\&6%\STX(5i0\189a\150\ENQ\229YH,0&^\167\f\254\209k", _password = Just +// "\202)\161\202\205\170z\SI\230\241\175\142\208\213\245\142]dM\EM\231\155\244", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\139\152\193\DC2\171\179\224m\168J\129\237\153t\SOH\ENQ\244G\203\EOT\US}\221\162", _willMsg = +// "\DLE\135\NAK^\193va\DC4\252\141-\RS", _willProps = []}), _cleanSession = True, _keepAlive = 11916, _connID = +// "z\209/\DEL\213B\229\RS\240B\238", _properties = []} TEST(Connect311QCTest, Encode21) { - uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x50, 0xf9, 0x0, 0xd, 0x29, 0xc, - 0x36, 0xaf, 0xf3, 0x1e, 0x93, 0x77, 0x51, 0xb2, 0x8c, 0x72, 0x52, 0x0, 0x16, 0x52, 0xb4, 0x19, - 0xe1, 0x77, 0xd0, 0x1f, 0x12, 0x58, 0x35, 0xf3, 0x5b, 0xe1, 0x3a, 0x61, 0xe1, 0x11, 0x37, 0xe1, - 0x42, 0x4b, 0x34, 0x0, 0x17, 0x1a, 0xd6, 0x13, 0xd2, 0xa6, 0x3c, 0xc9, 0x93, 0x56, 0x79, 0x8e, - 0xc, 0xa1, 0xdf, 0x42, 0x46, 0x41, 0x4f, 0x2c, 0x4, 0xb2, 0x4f, 0x55, 0x0, 0x8, 0xa, 0xd8, - 0x3f, 0x76, 0x2b, 0xb8, 0x6, 0x54, 0x0, 0x4, 0x66, 0xe8, 0xc8, 0xa}; + uint8_t pkt[] = {0x10, 0x72, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x2e, 0x8c, 0x0, 0xb, 0x7a, 0xd1, 0x2f, + 0x7f, 0xd5, 0x42, 0xe5, 0x1e, 0xf0, 0x42, 0xee, 0x0, 0x18, 0x8b, 0x98, 0xc1, 0x12, 0xab, 0xb3, 0xe0, + 0x6d, 0xa8, 0x4a, 0x81, 0xed, 0x99, 0x74, 0x1, 0x5, 0xf4, 0x47, 0xcb, 0x4, 0x1f, 0x7d, 0xdd, 0xa2, + 0x0, 0xc, 0x10, 0x87, 0x15, 0x5e, 0xc1, 0x76, 0x61, 0x14, 0xfc, 0x8d, 0x2d, 0x1e, 0x0, 0x18, 0xda, + 0x36, 0x25, 0x2, 0x28, 0x35, 0x69, 0x30, 0xbd, 0x61, 0x96, 0x5, 0xe5, 0x59, 0x48, 0x2c, 0x30, 0x26, + 0x5e, 0xa7, 0xc, 0xfe, 0xd1, 0x6b, 0x0, 0x17, 0xca, 0x29, 0xa1, 0xca, 0xcd, 0xaa, 0x7a, 0xf, 0xe6, + 0xf1, 0xaf, 0x8e, 0xd0, 0xd5, 0xf5, 0x8e, 0x5d, 0x64, 0x4d, 0x19, 0xe7, 0x9b, 0xf4}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6115,29 +6021,30 @@ TEST(Connect311QCTest, Encode21) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x52, 0xb4, 0x19, 0xe1, 0x77, 0xd0, 0x1f, 0x12, 0x58, 0x35, 0xf3, - 0x5b, 0xe1, 0x3a, 0x61, 0xe1, 0x11, 0x37, 0xe1, 0x42, 0x4b, 0x34}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1a, 0xd6, 0x13, 0xd2, 0xa6, 0x3c, 0xc9, 0x93, 0x56, 0x79, 0x8e, 0xc, - 0xa1, 0xdf, 0x42, 0x46, 0x41, 0x4f, 0x2c, 0x4, 0xb2, 0x4f, 0x55}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x8b, 0x98, 0xc1, 0x12, 0xab, 0xb3, 0xe0, 0x6d, 0xa8, 0x4a, 0x81, 0xed, + 0x99, 0x74, 0x1, 0x5, 0xf4, 0x47, 0xcb, 0x4, 0x1f, 0x7d, 0xdd, 0xa2}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x10, 0x87, 0x15, 0x5e, 0xc1, 0x76, 0x61, 0x14, 0xfc, 0x8d, 0x2d, 0x1e}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 20729; - uint8_t client_id_bytes[] = {0x29, 0xc, 0x36, 0xaf, 0xf3, 0x1e, 0x93, 0x77, 0x51, 0xb2, 0x8c, 0x72, 0x52}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.keep_alive = 11916; + uint8_t client_id_bytes[] = {0x7a, 0xd1, 0x2f, 0x7f, 0xd5, 0x42, 0xe5, 0x1e, 0xf0, 0x42, 0xee}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa, 0xd8, 0x3f, 0x76, 0x2b, 0xb8, 0x6, 0x54}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xda, 0x36, 0x25, 0x2, 0x28, 0x35, 0x69, 0x30, 0xbd, 0x61, 0x96, 0x5, + 0xe5, 0x59, 0x48, 0x2c, 0x30, 0x26, 0x5e, 0xa7, 0xc, 0xfe, 0xd1, 0x6b}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x66, 0xe8, 0xc8, 0xa}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xca, 0x29, 0xa1, 0xca, 0xcd, 0xaa, 0x7a, 0xf, 0xe6, 0xf1, 0xaf, 0x8e, + 0xd0, 0xd5, 0xf5, 0x8e, 0x5d, 0x64, 0x4d, 0x19, 0xe7, 0x9b, 0xf4}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6147,51 +6054,63 @@ TEST(Connect311QCTest, Encode21) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\218", _password = Just -// "\157\199_\231w\v\CAN\198\175\204\172\255\223\220\130\250!\147\249\203$a\136\131\EMn\SOHO\252", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 1033, _connID = "\252\aa\128~\196\ESC\154\131\&6\174", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just +// "\143y\166C\221w?;4\243\179\248z\136\a\221\DC3\228\DC1\156,\131\183sM\171&y", _lastWill = Just (LastWill {_willRetain +// = False, _willQoS = QoS2, _willTopic = "\226", _willMsg = "\240\178+p\166\192", _willProps = []}), _cleanSession = +// False, _keepAlive = 29711, _connID = "x2\200o\132\250", _properties = []} TEST(Connect311QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x4, 0x9, 0x0, 0xb, 0xfc, - 0x7, 0x61, 0x80, 0x7e, 0xc4, 0x1b, 0x9a, 0x83, 0x36, 0xae, 0x0, 0x1, 0xda, 0x0, 0x1d, - 0x9d, 0xc7, 0x5f, 0xe7, 0x77, 0xb, 0x18, 0xc6, 0xaf, 0xcc, 0xac, 0xff, 0xdf, 0xdc, 0x82, - 0xfa, 0x21, 0x93, 0xf9, 0xcb, 0x24, 0x61, 0x88, 0x83, 0x19, 0x6e, 0x1, 0x4f, 0xfc}; + uint8_t pkt[] = {0x10, 0x1d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x14, 0x74, 0xf, 0x0, 0x6, 0x78, 0x32, + 0xc8, 0x6f, 0x84, 0xfa, 0x0, 0x1, 0xe2, 0x0, 0x6, 0xf0, 0xb2, 0x2b, 0x70, 0xa6, 0xc0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe2}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf0, 0xb2, 0x2b, 0x70, 0xa6, 0xc0}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 1033; - uint8_t client_id_bytes[] = {0xfc, 0x7, 0x61, 0x80, 0x7e, 0xc4, 0x1b, 0x9a, 0x83, 0x36, 0xae}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.keep_alive = 29711; + uint8_t client_id_bytes[] = {0x78, 0x32, 0xc8, 0x6f, 0x84, 0xfa}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xda}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x9d, 0xc7, 0x5f, 0xe7, 0x77, 0xb, 0x18, 0xc6, 0xaf, 0xcc, 0xac, 0xff, 0xdf, 0xdc, 0x82, - 0xfa, 0x21, 0x93, 0xf9, 0xcb, 0x24, 0x61, 0x88, 0x83, 0x19, 0x6e, 0x1, 0x4f, 0xfc}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x8f, 0x79, 0xa6, 0x43, 0xdd, 0x77, 0x3f, 0x3b, 0x34, 0xf3, 0xb3, 0xf8, 0x7a, 0x88, + 0x7, 0xdd, 0x13, 0xe4, 0x11, 0x9c, 0x2c, 0x83, 0xb7, 0x73, 0x4d, 0xab, 0x26, 0x79}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\140\163RpjPE\225/:\ESC", _password = Just -// "\224\162k\234^k\194\DC3\157\n\DC4\228\216\234\160.o\NAKr\219\DC1\ETB", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS0, _willTopic = "\138\162?\130\159\141?\154+\DC4B\246\249\DEL1;-\244\132W;", _willMsg = -// "~j\245\255", _willProps = []}), _cleanSession = False, _keepAlive = 9554, _connID = "", _properties = []} +// ConnectRequest {_username = Just "\157\244\252!\no\225e", _password = Just +// "\203+\193\206\143\177\CAN\NUL\b\229\143p\249\aoT\130\140\199\197\139\130", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS1, _willTopic = "\188$&\229\204\146\186\244p\ACK\165dC\198G", _willMsg = +// ",n\136+E\195\136_K\222\148\132s\141{\231", _willProps = []}), _cleanSession = True, _keepAlive = 25534, _connID = +// "t\177\139,\191\139t\244\NAK\f\140!G\131k\141", _properties = []} TEST(Connect311QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x25, 0x52, 0x0, 0x0, 0x0, 0x15, - 0x8a, 0xa2, 0x3f, 0x82, 0x9f, 0x8d, 0x3f, 0x9a, 0x2b, 0x14, 0x42, 0xf6, 0xf9, 0x7f, 0x31, 0x3b, - 0x2d, 0xf4, 0x84, 0x57, 0x3b, 0x0, 0x4, 0x7e, 0x6a, 0xf5, 0xff, 0x0, 0xb, 0x8c, 0xa3, 0x52, - 0x70, 0x6a, 0x50, 0x45, 0xe1, 0x2f, 0x3a, 0x1b, 0x0, 0x16, 0xe0, 0xa2, 0x6b, 0xea, 0x5e, 0x6b, - 0xc2, 0x13, 0x9d, 0xa, 0x14, 0xe4, 0xd8, 0xea, 0xa0, 0x2e, 0x6f, 0x15, 0x72, 0xdb, 0x11, 0x17}; + uint8_t pkt[] = {0x10, 0x61, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x63, 0xbe, 0x0, 0x10, 0x74, 0xb1, 0x8b, + 0x2c, 0xbf, 0x8b, 0x74, 0xf4, 0x15, 0xc, 0x8c, 0x21, 0x47, 0x83, 0x6b, 0x8d, 0x0, 0xf, 0xbc, 0x24, + 0x26, 0xe5, 0xcc, 0x92, 0xba, 0xf4, 0x70, 0x6, 0xa5, 0x64, 0x43, 0xc6, 0x47, 0x0, 0x10, 0x2c, 0x6e, + 0x88, 0x2b, 0x45, 0xc3, 0x88, 0x5f, 0x4b, 0xde, 0x94, 0x84, 0x73, 0x8d, 0x7b, 0xe7, 0x0, 0x8, 0x9d, + 0xf4, 0xfc, 0x21, 0xa, 0x6f, 0xe1, 0x65, 0x0, 0x16, 0xcb, 0x2b, 0xc1, 0xce, 0x8f, 0xb1, 0x18, 0x0, + 0x8, 0xe5, 0x8f, 0x70, 0xf9, 0x7, 0x6f, 0x54, 0x82, 0x8c, 0xc7, 0xc5, 0x8b, 0x82}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6202,28 +6121,30 @@ TEST(Connect311QCTest, Encode23) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8a, 0xa2, 0x3f, 0x82, 0x9f, 0x8d, 0x3f, 0x9a, 0x2b, 0x14, 0x42, - 0xf6, 0xf9, 0x7f, 0x31, 0x3b, 0x2d, 0xf4, 0x84, 0x57, 0x3b}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7e, 0x6a, 0xf5, 0xff}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xbc, 0x24, 0x26, 0xe5, 0xcc, 0x92, 0xba, 0xf4, + 0x70, 0x6, 0xa5, 0x64, 0x43, 0xc6, 0x47}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2c, 0x6e, 0x88, 0x2b, 0x45, 0xc3, 0x88, 0x5f, + 0x4b, 0xde, 0x94, 0x84, 0x73, 0x8d, 0x7b, 0xe7}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 9554; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 25534; + uint8_t client_id_bytes[] = {0x74, 0xb1, 0x8b, 0x2c, 0xbf, 0x8b, 0x74, 0xf4, + 0x15, 0xc, 0x8c, 0x21, 0x47, 0x83, 0x6b, 0x8d}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x8c, 0xa3, 0x52, 0x70, 0x6a, 0x50, 0x45, 0xe1, 0x2f, 0x3a, 0x1b}; - lwmqtt_string_t username = {11, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x9d, 0xf4, 0xfc, 0x21, 0xa, 0x6f, 0xe1, 0x65}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xe0, 0xa2, 0x6b, 0xea, 0x5e, 0x6b, 0xc2, 0x13, 0x9d, 0xa, 0x14, - 0xe4, 0xd8, 0xea, 0xa0, 0x2e, 0x6f, 0x15, 0x72, 0xdb, 0x11, 0x17}; + uint8_t password_bytes[] = {0xcb, 0x2b, 0xc1, 0xce, 0x8f, 0xb1, 0x18, 0x0, 0x8, 0xe5, 0x8f, + 0x70, 0xf9, 0x7, 0x6f, 0x54, 0x82, 0x8c, 0xc7, 0xc5, 0x8b, 0x82}; lwmqtt_string_t password = {22, (char*)&password_bytes}; opts.password = password; size_t len = 0; @@ -6234,68 +6155,52 @@ TEST(Connect311QCTest, Encode23) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\184\n\192\249\GS\b\140\182\DC3\152 }=&7\DC4\181k", _password = Just -// "\150/\SO\220", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\r\243Owl", _willMsg = -// "\251\re\178 \ACK\242Y2h\FS\DEL\160X\254\171\133\v\217\160\DC2p\DC1\207\EM", _willProps = []}), _cleanSession = True, -// _keepAlive = 22347, _connID = "\148/\140]", _properties = []} +// ConnectRequest {_username = Just "\DC2K\SOH\205\130\243\197\138\251g", _password = Just +// "\203\162\176\223n\163\159\204\NAK\t+\212", _lastWill = Nothing, _cleanSession = True, _keepAlive = 31053, _connID = +// "X\134\206\232\134\243\221\DC1\252", _properties = []} TEST(Connect311QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x4c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x57, 0x4b, 0x0, 0x4, 0x94, 0x2f, - 0x8c, 0x5d, 0x0, 0x5, 0xd, 0xf3, 0x4f, 0x77, 0x6c, 0x0, 0x19, 0xfb, 0xd, 0x65, 0xb2, 0x20, - 0x6, 0xf2, 0x59, 0x32, 0x68, 0x1c, 0x7f, 0xa0, 0x58, 0xfe, 0xab, 0x85, 0xb, 0xd9, 0xa0, 0x12, - 0x70, 0x11, 0xcf, 0x19, 0x0, 0x12, 0xb8, 0xa, 0xc0, 0xf9, 0x1d, 0x8, 0x8c, 0xb6, 0x13, 0x98, - 0x20, 0x7d, 0x3d, 0x26, 0x37, 0x14, 0xb5, 0x6b, 0x0, 0x4, 0x96, 0x2f, 0xe, 0xdc}; + uint8_t pkt[] = {0x10, 0x2f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x79, 0x4d, 0x0, 0x9, 0x58, 0x86, 0xce, + 0xe8, 0x86, 0xf3, 0xdd, 0x11, 0xfc, 0x0, 0xa, 0x12, 0x4b, 0x1, 0xcd, 0x82, 0xf3, 0xc5, 0x8a, 0xfb, + 0x67, 0x0, 0xc, 0xcb, 0xa2, 0xb0, 0xdf, 0x6e, 0xa3, 0x9f, 0xcc, 0x15, 0x9, 0x2b, 0xd4}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd, 0xf3, 0x4f, 0x77, 0x6c}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfb, 0xd, 0x65, 0xb2, 0x20, 0x6, 0xf2, 0x59, 0x32, 0x68, 0x1c, 0x7f, 0xa0, - 0x58, 0xfe, 0xab, 0x85, 0xb, 0xd9, 0xa0, 0x12, 0x70, 0x11, 0xcf, 0x19}; - lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 22347; - uint8_t client_id_bytes[] = {0x94, 0x2f, 0x8c, 0x5d}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.keep_alive = 31053; + uint8_t client_id_bytes[] = {0x58, 0x86, 0xce, 0xe8, 0x86, 0xf3, 0xdd, 0x11, 0xfc}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb8, 0xa, 0xc0, 0xf9, 0x1d, 0x8, 0x8c, 0xb6, 0x13, - 0x98, 0x20, 0x7d, 0x3d, 0x26, 0x37, 0x14, 0xb5, 0x6b}; - lwmqtt_string_t username = {18, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x12, 0x4b, 0x1, 0xcd, 0x82, 0xf3, 0xc5, 0x8a, 0xfb, 0x67}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x96, 0x2f, 0xe, 0xdc}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xcb, 0xa2, 0xb0, 0xdf, 0x6e, 0xa3, 0x9f, 0xcc, 0x15, 0x9, 0x2b, 0xd4}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\183\178\ESC", _password = Just "-\203Id", _lastWill = Just (LastWill {_willRetain -// = False, _willQoS = QoS1, _willTopic = -// "oH%\176\195\240\217\234x\176Z\ETX\204\SO\DC3\DEL\138\181\252\US\254\147\218:\146\231\\\144", _willMsg = "n\EM\186", -// _willProps = []}), _cleanSession = True, _keepAlive = 18592, _connID = "\155j\169\&4\DC3T\219\&4P", _properties = []} +// ConnectRequest {_username = Just "\SI\249\217\245+\148\214W4\194\166\EM\248\229\173\221\207!\207", _password = Just +// "\162\230\187s\155\185\166\184\194\DLE6", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic +// = "\NAK6\214\US\166`\243!\147\STX\254$x\152\221|]V\DC2\132\180{E#\STX|.\209\244", _willMsg = +// "\200\238p[\209Nf\186\211\186\213\164\&0\t\223\176", _willProps = []}), _cleanSession = True, _keepAlive = 12605, +// _connID = "\132\135\132`\t\238\191\184 \SOH\162", _properties = []} TEST(Connect311QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0x43, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x48, 0xa0, 0x0, 0x9, - 0x9b, 0x6a, 0xa9, 0x34, 0x13, 0x54, 0xdb, 0x34, 0x50, 0x0, 0x1c, 0x6f, 0x48, 0x25, - 0xb0, 0xc3, 0xf0, 0xd9, 0xea, 0x78, 0xb0, 0x5a, 0x3, 0xcc, 0xe, 0x13, 0x7f, 0x8a, - 0xb5, 0xfc, 0x1f, 0xfe, 0x93, 0xda, 0x3a, 0x92, 0xe7, 0x5c, 0x90, 0x0, 0x3, 0x6e, - 0x19, 0xba, 0x0, 0x3, 0xb7, 0xb2, 0x1b, 0x0, 0x4, 0x2d, 0xcb, 0x49, 0x64}; + uint8_t pkt[] = {0x10, 0x6a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x31, 0x3d, 0x0, 0xb, 0x84, 0x87, + 0x84, 0x60, 0x9, 0xee, 0xbf, 0xb8, 0x20, 0x1, 0xa2, 0x0, 0x1d, 0x15, 0x36, 0xd6, 0x1f, 0xa6, + 0x60, 0xf3, 0x21, 0x93, 0x2, 0xfe, 0x24, 0x78, 0x98, 0xdd, 0x7c, 0x5d, 0x56, 0x12, 0x84, 0xb4, + 0x7b, 0x45, 0x23, 0x2, 0x7c, 0x2e, 0xd1, 0xf4, 0x0, 0x10, 0xc8, 0xee, 0x70, 0x5b, 0xd1, 0x4e, + 0x66, 0xba, 0xd3, 0xba, 0xd5, 0xa4, 0x30, 0x9, 0xdf, 0xb0, 0x0, 0x13, 0xf, 0xf9, 0xd9, 0xf5, + 0x2b, 0x94, 0xd6, 0x57, 0x34, 0xc2, 0xa6, 0x19, 0xf8, 0xe5, 0xad, 0xdd, 0xcf, 0x21, 0xcf, 0x0, + 0xb, 0xa2, 0xe6, 0xbb, 0x73, 0x9b, 0xb9, 0xa6, 0xb8, 0xc2, 0x10, 0x36}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6306,28 +6211,30 @@ TEST(Connect311QCTest, Encode25) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6f, 0x48, 0x25, 0xb0, 0xc3, 0xf0, 0xd9, 0xea, 0x78, 0xb0, 0x5a, 0x3, 0xcc, 0xe, - 0x13, 0x7f, 0x8a, 0xb5, 0xfc, 0x1f, 0xfe, 0x93, 0xda, 0x3a, 0x92, 0xe7, 0x5c, 0x90}; - lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6e, 0x19, 0xba}; - lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x15, 0x36, 0xd6, 0x1f, 0xa6, 0x60, 0xf3, 0x21, 0x93, 0x2, 0xfe, 0x24, 0x78, 0x98, 0xdd, + 0x7c, 0x5d, 0x56, 0x12, 0x84, 0xb4, 0x7b, 0x45, 0x23, 0x2, 0x7c, 0x2e, 0xd1, 0xf4}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc8, 0xee, 0x70, 0x5b, 0xd1, 0x4e, 0x66, 0xba, + 0xd3, 0xba, 0xd5, 0xa4, 0x30, 0x9, 0xdf, 0xb0}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 18592; - uint8_t client_id_bytes[] = {0x9b, 0x6a, 0xa9, 0x34, 0x13, 0x54, 0xdb, 0x34, 0x50}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.keep_alive = 12605; + uint8_t client_id_bytes[] = {0x84, 0x87, 0x84, 0x60, 0x9, 0xee, 0xbf, 0xb8, 0x20, 0x1, 0xa2}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb7, 0xb2, 0x1b}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf, 0xf9, 0xd9, 0xf5, 0x2b, 0x94, 0xd6, 0x57, 0x34, 0xc2, + 0xa6, 0x19, 0xf8, 0xe5, 0xad, 0xdd, 0xcf, 0x21, 0xcf}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x2d, 0xcb, 0x49, 0x64}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xa2, 0xe6, 0xbb, 0x73, 0x9b, 0xb9, 0xa6, 0xb8, 0xc2, 0x10, 0x36}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6337,16 +6244,15 @@ TEST(Connect311QCTest, Encode25) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\164\207\151\149\193\237\154\&5;\151\f\187\235\141\182k?\198\208\205\150", -// _password = Just "\238\185\&5!R\163\189", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic -// = "\162r\149\182\167\158V@)qJ\240#\236\180\134\195xN", _willMsg = "y\213_\183\130", _willProps = []}), _cleanSession -// = False, _keepAlive = 10272, _connID = "\171\r5?\187", _properties = []} +// ConnectRequest {_username = Just "\222\FS\NUL", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "\236?v#\231\182\221\157[=\139|\191\209\208\147\164?\221=)\ETB?\217\223e", _willMsg = +// "n\212", _willProps = []}), _cleanSession = False, _keepAlive = 12313, _connID = "%W\235 +// )\183\218\188oO\152j\237\b!", _properties = []} TEST(Connect311QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0x4d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x28, 0x20, 0x0, 0x5, 0xab, 0xd, - 0x35, 0x3f, 0xbb, 0x0, 0x13, 0xa2, 0x72, 0x95, 0xb6, 0xa7, 0x9e, 0x56, 0x40, 0x29, 0x71, 0x4a, - 0xf0, 0x23, 0xec, 0xb4, 0x86, 0xc3, 0x78, 0x4e, 0x0, 0x5, 0x79, 0xd5, 0x5f, 0xb7, 0x82, 0x0, - 0x15, 0xa4, 0xcf, 0x97, 0x95, 0xc1, 0xed, 0x9a, 0x35, 0x3b, 0x97, 0xc, 0xbb, 0xeb, 0x8d, 0xb6, - 0x6b, 0x3f, 0xc6, 0xd0, 0xcd, 0x96, 0x0, 0x7, 0xee, 0xb9, 0x35, 0x21, 0x52, 0xa3, 0xbd}; + uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb4, 0x30, 0x19, 0x0, 0xf, 0x25, 0x57, 0xeb, + 0x20, 0x29, 0xb7, 0xda, 0xbc, 0x6f, 0x4f, 0x98, 0x6a, 0xed, 0x8, 0x21, 0x0, 0x1a, 0xec, 0x3f, 0x76, + 0x23, 0xe7, 0xb6, 0xdd, 0x9d, 0x5b, 0x3d, 0x8b, 0x7c, 0xbf, 0xd1, 0xd0, 0x93, 0xa4, 0x3f, 0xdd, 0x3d, + 0x29, 0x17, 0x3f, 0xd9, 0xdf, 0x65, 0x0, 0x2, 0x6e, 0xd4, 0x0, 0x3, 0xde, 0x1c, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6357,30 +6263,26 @@ TEST(Connect311QCTest, Encode26) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa2, 0x72, 0x95, 0xb6, 0xa7, 0x9e, 0x56, 0x40, 0x29, 0x71, - 0x4a, 0xf0, 0x23, 0xec, 0xb4, 0x86, 0xc3, 0x78, 0x4e}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x79, 0xd5, 0x5f, 0xb7, 0x82}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xec, 0x3f, 0x76, 0x23, 0xe7, 0xb6, 0xdd, 0x9d, 0x5b, 0x3d, 0x8b, 0x7c, 0xbf, + 0xd1, 0xd0, 0x93, 0xa4, 0x3f, 0xdd, 0x3d, 0x29, 0x17, 0x3f, 0xd9, 0xdf, 0x65}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6e, 0xd4}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 10272; - uint8_t client_id_bytes[] = {0xab, 0xd, 0x35, 0x3f, 0xbb}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.keep_alive = 12313; + uint8_t client_id_bytes[] = {0x25, 0x57, 0xeb, 0x20, 0x29, 0xb7, 0xda, 0xbc, 0x6f, 0x4f, 0x98, 0x6a, 0xed, 0x8, 0x21}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa4, 0xcf, 0x97, 0x95, 0xc1, 0xed, 0x9a, 0x35, 0x3b, 0x97, 0xc, - 0xbb, 0xeb, 0x8d, 0xb6, 0x6b, 0x3f, 0xc6, 0xd0, 0xcd, 0x96}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xde, 0x1c, 0x0}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xee, 0xb9, 0x35, 0x21, 0x52, 0xa3, 0xbd}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6389,13 +6291,18 @@ TEST(Connect311QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS0, _willTopic = "\SIj\176\132r\238\172\184r\158pjf\GS\159\&7\185\DEL\211", _willMsg = "", _willProps = []}), -// _cleanSession = False, _keepAlive = 10342, _connID = "F/\a\165\170Bk\248\200\ENQ\199\172\&4\128", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\ENQ\177\248\150\234\US\132\246q", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\183\FS\DC1\132\182jmFH\GS\201\141\226\&3\n", _willMsg = +// "\134\204\FS{\151\206b\190e\177\149\v\146\182\240\197\189NN\183\242\207\\BM\fs\198H", _willProps = []}), +// _cleanSession = True, _keepAlive = 13514, _connID = "\161 \149\244\226\242\217\139I +// p\234\"\249\DLE\216>p\SOV\CAN\207\131", _properties = []} TEST(Connect311QCTest, Encode27) { - uint8_t pkt[] = {0x10, 0x31, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x4, 0x28, 0x66, 0x0, 0xe, 0x46, 0x2f, 0x7, - 0xa5, 0xaa, 0x42, 0x6b, 0xf8, 0xc8, 0x5, 0xc7, 0xac, 0x34, 0x80, 0x0, 0x13, 0xf, 0x6a, 0xb0, 0x84, - 0x72, 0xee, 0xac, 0xb8, 0x72, 0x9e, 0x70, 0x6a, 0x66, 0x1d, 0x9f, 0x37, 0xb9, 0x7f, 0xd3, 0x0, 0x0}; + uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x34, 0xca, 0x0, 0x17, 0xa1, + 0x20, 0x95, 0xf4, 0xe2, 0xf2, 0xd9, 0x8b, 0x49, 0x20, 0x70, 0xea, 0x22, 0xf9, 0x10, 0xd8, + 0x3e, 0x70, 0xe, 0x56, 0x18, 0xcf, 0x83, 0x0, 0xf, 0xb7, 0x1c, 0x11, 0x84, 0xb6, 0x6a, + 0x6d, 0x46, 0x48, 0x1d, 0xc9, 0x8d, 0xe2, 0x33, 0xa, 0x0, 0x1d, 0x86, 0xcc, 0x1c, 0x7b, + 0x97, 0xce, 0x62, 0xbe, 0x65, 0xb1, 0x95, 0xb, 0x92, 0xb6, 0xf0, 0xc5, 0xbd, 0x4e, 0x4e, + 0xb7, 0xf2, 0xcf, 0x5c, 0x42, 0x4d, 0xc, 0x73, 0xc6, 0x48}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6406,23 +6313,29 @@ TEST(Connect311QCTest, Encode27) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf, 0x6a, 0xb0, 0x84, 0x72, 0xee, 0xac, 0xb8, 0x72, 0x9e, - 0x70, 0x6a, 0x66, 0x1d, 0x9f, 0x37, 0xb9, 0x7f, 0xd3}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xb7, 0x1c, 0x11, 0x84, 0xb6, 0x6a, 0x6d, 0x46, + 0x48, 0x1d, 0xc9, 0x8d, 0xe2, 0x33, 0xa}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x86, 0xcc, 0x1c, 0x7b, 0x97, 0xce, 0x62, 0xbe, 0x65, 0xb1, + 0x95, 0xb, 0x92, 0xb6, 0xf0, 0xc5, 0xbd, 0x4e, 0x4e, 0xb7, + 0xf2, 0xcf, 0x5c, 0x42, 0x4d, 0xc, 0x73, 0xc6, 0x48}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS2; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 10342; - uint8_t client_id_bytes[] = {0x46, 0x2f, 0x7, 0xa5, 0xaa, 0x42, 0x6b, 0xf8, 0xc8, 0x5, 0xc7, 0xac, 0x34, 0x80}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 13514; + uint8_t client_id_bytes[] = {0xa1, 0x20, 0x95, 0xf4, 0xe2, 0xf2, 0xd9, 0x8b, 0x49, 0x20, 0x70, 0xea, + 0x22, 0xf9, 0x10, 0xd8, 0x3e, 0x70, 0xe, 0x56, 0x18, 0xcf, 0x83}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t password_bytes[] = {0x5, 0xb1, 0xf8, 0x96, 0xea, 0x1f, 0x84, 0xf6, 0x71}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6431,18 +6344,18 @@ TEST(Connect311QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\177,\US\162\249\rU", _password = Just "\186$\184J\CAN:\210T\160t\185\242", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\248\192cB\223\ACK\132s!q\246\236pQ-R", _willMsg = "@\152\ETBp\180{\SI\148\180\&8\r\230\252vY\151]\223/\232&n", -// _willProps = []}), _cleanSession = True, _keepAlive = 1497, _connID = "\ENQfB\178\EOT\DLE\139\233\169H\233\GS[", -// _properties = []} +// ConnectRequest {_username = Just "\218r\168\139R\217\209\a@\135\239\135\152\130\140\156\230\152>\156\160", _password +// = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\220\218\137\179z\158\vc\CAN\128\SUBU\DC3\175n\201P\218B", _willMsg = +// "\218\174\233=\151\&7\204\204\181\t\146\180O\189\173.`\244\151\180I@0\252", _willProps = []}), _cleanSession = True, +// _keepAlive = 5227, _connID = "_\201\&2\202<\161\171\209\244\241\165", _properties = []} TEST(Connect311QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x5, 0xd9, 0x0, 0xd, 0x5, 0x66, - 0x42, 0xb2, 0x4, 0x10, 0x8b, 0xe9, 0xa9, 0x48, 0xe9, 0x1d, 0x5b, 0x0, 0x10, 0xf8, 0xc0, 0x63, - 0x42, 0xdf, 0x6, 0x84, 0x73, 0x21, 0x71, 0xf6, 0xec, 0x70, 0x51, 0x2d, 0x52, 0x0, 0x16, 0x40, - 0x98, 0x17, 0x70, 0xb4, 0x7b, 0xf, 0x94, 0xb4, 0x38, 0xd, 0xe6, 0xfc, 0x76, 0x59, 0x97, 0x5d, - 0xdf, 0x2f, 0xe8, 0x26, 0x6e, 0x0, 0x7, 0xb1, 0x2c, 0x1f, 0xa2, 0xf9, 0xd, 0x55, 0x0, 0xc, - 0xba, 0x24, 0xb8, 0x4a, 0x18, 0x3a, 0xd2, 0x54, 0xa0, 0x74, 0xb9, 0xf2}; + uint8_t pkt[] = {0x10, 0x5d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xae, 0x14, 0x6b, 0x0, 0xb, 0x5f, 0xc9, + 0x32, 0xca, 0x3c, 0xa1, 0xab, 0xd1, 0xf4, 0xf1, 0xa5, 0x0, 0x13, 0xdc, 0xda, 0x89, 0xb3, 0x7a, + 0x9e, 0xb, 0x63, 0x18, 0x80, 0x1a, 0x55, 0x13, 0xaf, 0x6e, 0xc9, 0x50, 0xda, 0x42, 0x0, 0x18, + 0xda, 0xae, 0xe9, 0x3d, 0x97, 0x37, 0xcc, 0xcc, 0xb5, 0x9, 0x92, 0xb4, 0x4f, 0xbd, 0xad, 0x2e, + 0x60, 0xf4, 0x97, 0xb4, 0x49, 0x40, 0x30, 0xfc, 0x0, 0x15, 0xda, 0x72, 0xa8, 0x8b, 0x52, 0xd9, + 0xd1, 0x7, 0x40, 0x87, 0xef, 0x87, 0x98, 0x82, 0x8c, 0x9c, 0xe6, 0x98, 0x3e, 0x9c, 0xa0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6453,30 +6366,28 @@ TEST(Connect311QCTest, Encode28) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf8, 0xc0, 0x63, 0x42, 0xdf, 0x6, 0x84, 0x73, - 0x21, 0x71, 0xf6, 0xec, 0x70, 0x51, 0x2d, 0x52}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x40, 0x98, 0x17, 0x70, 0xb4, 0x7b, 0xf, 0x94, 0xb4, 0x38, 0xd, - 0xe6, 0xfc, 0x76, 0x59, 0x97, 0x5d, 0xdf, 0x2f, 0xe8, 0x26, 0x6e}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xdc, 0xda, 0x89, 0xb3, 0x7a, 0x9e, 0xb, 0x63, 0x18, 0x80, + 0x1a, 0x55, 0x13, 0xaf, 0x6e, 0xc9, 0x50, 0xda, 0x42}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xda, 0xae, 0xe9, 0x3d, 0x97, 0x37, 0xcc, 0xcc, 0xb5, 0x9, 0x92, 0xb4, + 0x4f, 0xbd, 0xad, 0x2e, 0x60, 0xf4, 0x97, 0xb4, 0x49, 0x40, 0x30, 0xfc}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS1; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 1497; - uint8_t client_id_bytes[] = {0x5, 0x66, 0x42, 0xb2, 0x4, 0x10, 0x8b, 0xe9, 0xa9, 0x48, 0xe9, 0x1d, 0x5b}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.keep_alive = 5227; + uint8_t client_id_bytes[] = {0x5f, 0xc9, 0x32, 0xca, 0x3c, 0xa1, 0xab, 0xd1, 0xf4, 0xf1, 0xa5}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb1, 0x2c, 0x1f, 0xa2, 0xf9, 0xd, 0x55}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xda, 0x72, 0xa8, 0x8b, 0x52, 0xd9, 0xd1, 0x7, 0x40, 0x87, 0xef, + 0x87, 0x98, 0x82, 0x8c, 0x9c, 0xe6, 0x98, 0x3e, 0x9c, 0xa0}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xba, 0x24, 0xb8, 0x4a, 0x18, 0x3a, 0xd2, 0x54, 0xa0, 0x74, 0xb9, 0xf2}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6485,15 +6396,19 @@ TEST(Connect311QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\137\131H\193\255h\165\215p\165", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "\194\&8\235\&3\136P\198a", _willMsg = -// "\ESC}E\DLE\133\162\200\238\202o\182\242", _willProps = []}), _cleanSession = False, _keepAlive = 17930, _connID = -// "\152@\239K\222UU\185", _properties = []} +// ConnectRequest {_username = Just "\SO\"\229\f\229\n\211x\145\nR\255A\196y\255\218\ACK\138:\183m@\SI\153[\SOH\150F\206\225",PropResponseTopic +// "\EMv\205\SOH",PropRequestProblemInformation 111,PropPayloadFormatIndicator 254,PropReasonString +// "\223~\166\171\189\179py\195\203\171",PropContentType +// "r\203S:(\n\SYNy\SUB/\n\178>8o\183\218\254\237Ie\192\RS];\222",PropSharedSubscriptionAvailable +// 28,PropTopicAliasMaximum 23838,PropMessageExpiryInterval 23226,PropTopicAlias 25172,PropUserProperty +// ";\254\128\220\DEL\130hZ\134" "R'\STXM",PropAssignedClientIdentifier +// "\139\235\158\153\SYN\209D\183T\SO\235\192D\166;*\151\&3\170\221b\177\218",PropSharedSubscriptionAvailable +// 198,PropTopicAlias 2061,PropPayloadFormatIndicator 216,PropTopicAliasMaximum 20856,PropSubscriptionIdentifier +// 25,PropAuthenticationMethod ", \169\160\&6\157\155\228",PropSubscriptionIdentifier 32]}), _cleanSession = False, +// _keepAlive = 13091, _connID = "k!a\t\182\181\230\207<\SUB\251\243b\250\216\131H", _properties = [PropCorrelationData +// "\211\164\134\176\182\163\EOTk\ESC\207:\178H\227\129Y\176\244\216\229t\128",PropServerReference +// "\SIT\255\132\203G}\DLEz\ETBzv\197p\153\ACK\144",PropContentType +// "\249\193\171n\204\ETB\164\200\185>\152\254\NAK\221E\163\209",PropSubscriptionIdentifierAvailable +// 135,PropPayloadFormatIndicator 87,PropWildcardSubscriptionAvailable 155,PropRequestProblemInformation +// 52,PropAuthenticationData "\227\216"]} TEST(Connect5QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x7d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb6, 0x13, 0x63, 0x0, 0x0, 0x18, 0x92, - 0x1a, 0x2e, 0x37, 0xe8, 0xf4, 0x52, 0x3, 0xaf, 0x55, 0xc0, 0x95, 0x7f, 0xb9, 0x4d, 0x6d, 0x1b, - 0xa5, 0xef, 0x6c, 0xbd, 0x95, 0xb5, 0x52, 0x25, 0x1c, 0x0, 0x16, 0x81, 0xa8, 0x7d, 0x50, 0xb, - 0x9d, 0x66, 0x5e, 0x6c, 0x6b, 0xa7, 0xe, 0x43, 0xc9, 0xaa, 0x2, 0x4d, 0x12, 0xe9, 0xad, 0x2f, - 0x91, 0x2, 0x0, 0x0, 0x4c, 0x91, 0xb, 0xd, 0x11, 0x0, 0x0, 0x3f, 0xcf, 0x0, 0xf, 0x84, - 0xa5, 0x1a, 0xe4, 0x54, 0x67, 0x39, 0x0, 0x56, 0x2e, 0x7e, 0x8e, 0xc2, 0xe2, 0x3a, 0x0, 0x19, - 0xb0, 0xb3, 0xac, 0x7, 0x31, 0x72, 0xa4, 0x7b, 0x1, 0x8f, 0x82, 0x56, 0x35, 0x1f, 0x2d, 0x45, - 0x6c, 0x56, 0x92, 0x3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x1b, 0xcf, 0x3a, + 0xb2, 0x48, 0xe3, 0x81, 0x59, 0xb0, 0xf4, 0xd8, 0xe5, 0x74, 0x80}; + uint8_t bytesprops1[] = {0xf, 0x54, 0xff, 0x84, 0xcb, 0x47, 0x7d, 0x10, 0x7a, + 0x17, 0x7a, 0x76, 0xc5, 0x70, 0x99, 0x6, 0x90}; + uint8_t bytesprops2[] = {0xf9, 0xc1, 0xab, 0x6e, 0xcc, 0x17, 0xa4, 0xc8, 0xb9, + 0x3e, 0x98, 0xfe, 0x15, 0xdd, 0x45, 0xa3, 0xd1}; + uint8_t bytesprops3[] = {0xe3, 0xd8}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x81, 0xa8, 0x7d, 0x50, 0xb, 0x9d, 0x66, 0x5e, 0x6c, 0x6b, 0xa7, - 0xe, 0x43, 0xc9, 0xaa, 0x2, 0x4d, 0x12, 0xe9, 0xad, 0x2f, 0x91}; + uint8_t byteswillprops0[] = {0xb5, 0x49, 0xe7, 0x20, 0xb0, 0xca, 0xf, 0xda, 0xa0, 0xb1}; + uint8_t byteswillprops1[] = {0xab, 0xed, 0x38, 0x39, 0xdf, 0x2e}; + uint8_t byteswillprops2[] = {0xbd, 0xfc, 0x5b, 0xb7, 0xe2, 0x31, 0x3e, 0xda, 0x6, 0x8a, 0x3a, + 0xb7, 0x6d, 0x40, 0xf, 0x99, 0x5b, 0x1, 0x96, 0x46, 0xce, 0xe1}; + uint8_t byteswillprops3[] = {0x19, 0x76, 0xcd, 0x1}; + uint8_t byteswillprops4[] = {0xdf, 0x7e, 0xa6, 0xab, 0xbd, 0xb3, 0x70, 0x79, 0xc3, 0xcb, 0xab}; + uint8_t byteswillprops5[] = {0x72, 0xcb, 0x53, 0x3a, 0x28, 0xa, 0x16, 0x79, 0x1a, 0x2f, 0xa, 0xb2, 0x3e, + 0x38, 0x6f, 0xb7, 0xda, 0xfe, 0xed, 0x49, 0x65, 0xc0, 0x1e, 0x5d, 0x3b, 0xde}; + uint8_t byteswillprops7[] = {0x52, 0x27, 0x2, 0x4d}; + uint8_t byteswillprops6[] = {0x3b, 0xfe, 0x80, 0xdc, 0x7f, 0x82, 0x68, 0x5a, 0x86}; + uint8_t byteswillprops8[] = {0x8b, 0xeb, 0x9e, 0x99, 0x16, 0xd1, 0x44, 0xb7, 0x54, 0xe, 0xeb, 0xc0, + 0x44, 0xa6, 0x3b, 0x2a, 0x97, 0x33, 0xaa, 0xdd, 0x62, 0xb1, 0xda}; + uint8_t byteswillprops9[] = {0x2c, 0x20, 0xa9, 0xa0, 0x36, 0x9d, 0x9b, 0xe4}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19601}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16335}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23838}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23226}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25172}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {9, (char*)&byteswillprops6}, .v = {4, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2061}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20856}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 32}}, }; - lwmqtt_properties_t willprops = {4, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x84, 0xa5, 0x1a, 0xe4, 0x54, 0x67, 0x39, 0x0, - 0x56, 0x2e, 0x7e, 0x8e, 0xc2, 0xe2, 0x3a}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb0, 0xb3, 0xac, 0x7, 0x31, 0x72, 0xa4, 0x7b, 0x1, 0x8f, 0x82, 0x56, 0x35, - 0x1f, 0x2d, 0x45, 0x6c, 0x56, 0x92, 0x3c, 0x52, 0x54, 0xaa, 0xe1, 0x65}; - lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x68, 0xa5, 0x7b, 0xd3, 0x42, 0xd6, 0xa9, 0x57, 0xed}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS1; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 4963; - uint8_t client_id_bytes[] = {0x92, 0x1a, 0x2e, 0x37, 0xe8, 0xf4, 0x52, 0x3, 0xaf, 0x55, 0xc0, 0x95, - 0x7f, 0xb9, 0x4d, 0x6d, 0x1b, 0xa5, 0xef, 0x6c, 0xbd, 0x95, 0xb5, 0x52}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 13091; + uint8_t client_id_bytes[] = {0x6b, 0x21, 0x61, 0x9, 0xb6, 0xb5, 0xe6, 0xcf, 0x3c, + 0x1a, 0xfb, 0xf3, 0x62, 0xfa, 0xd8, 0x83, 0x48}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x14, 0xf5, 0x71, 0x76}; + uint8_t username_bytes[] = {0xe8, 0x66, 0x3b, 0x2f}; lwmqtt_string_t username = {4, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x54, 0x27, 0xf8, 0x90, 0xb3, 0x9b, 0x56, 0xd1, 0x15, 0x24, + 0x6c, 0x86, 0xa9, 0xa5, 0xf4, 0x5f, 0x6, 0x7, 0x61, 0x1f}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -6731,176 +6683,122 @@ TEST(Connect5QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "\209\146\&2\164V", _willMsg = -// "\189\145\130\DC2U`\130\244\235\250\194@\222\162-\187\250\RS\SO\213$zF\EOT\t\197", _willProps = -// [PropRequestProblemInformation 83,PropResponseInformation -// "!\209\235\FS\170\&2\234\141m\238T\192ZgEH\SO\172\198\189\186\209\191\149\156r\246\&4/\f",PropRequestResponseInformation -// 84,PropMessageExpiryInterval 9800,PropUserProperty "" "f-",PropUserProperty "r\162\222\210$nPa,\206{\174\145\233jT" -// "O|",PropUserProperty "S\b_I)\\\198\145Mz\217\&1\142QZ\250'\214Cp\141\177\\i\249\232;" -// "\198",PropAssignedClientIdentifier "[\149p6I\208\188P\NUL\136\201\209gJ\159&\171\NUL\247",PropMaximumQoS -// 17,PropAssignedClientIdentifier -// "\250\rp\207s\223\220\SUBT\192<\176\b\232\r\GS\243\203F1\148#r\167\DC1",PropSubscriptionIdentifierAvailable -// 60,PropResponseInformation -// "\STX\254\198\248\141\197+\157!a5\136\225\129\bK\172\221\145\204\231\246\234\166bO",PropServerReference -// "\f<5I\186h\129\ETB\196",PropSharedSubscriptionAvailable 213,PropTopicAlias 16842,PropMessageExpiryInterval -// 1598,PropMaximumPacketSize 29381,PropMaximumPacketSize 23683,PropReceiveMaximum 727,PropSubscriptionIdentifier 23]}), -// _cleanSession = True, _keepAlive = 4029, _connID = "\ETB\180\164\136M><\142\&9\159Dn\bA\197\NUL2", _properties = -// [PropMaximumPacketSize 32513,PropAuthenticationMethod "\168i\223e0\STX",PropTopicAliasMaximum -// 4235,PropMessageExpiryInterval 16501,PropResponseTopic -// "\208\148\163\ACK\198\176M\245FqB\212\205iD\190W\165/\161:\138\206\&0\246",PropRequestProblemInformation -// 178,PropSubscriptionIdentifier 11,PropResponseInformation -// "\232p,\EOT\234/|\203\218\236t\SUB!\186tT\250\233\SUB\190\&0\\\228\154\a\189B",PropAuthenticationData -// "\211\189\207l\b(\211\171'x\189\201\132\137;\DC4SC*sP$\167yX>x",PropWillDelayInterval 7419,PropMaximumPacketSize -// 16457,PropRetainAvailable 183,PropAuthenticationData -// "_`C\233}\141\248\213\167C\142\254\vo\"2&\226$&a\\\235TW\203\173\195",PropAssignedClientIdentifier -// "\\|\213o\173\170\249\210c?Y\149\189[9\243\239w\SI\235Rd\202\154^\222\DELU\180\247",PropTopicAlias -// 26546,PropSessionExpiryInterval 24695,PropResponseInformation "y\DC3\212",PropReceiveMaximum -// 10210,PropAuthenticationMethod "",PropSessionExpiryInterval 2004,PropAuthenticationData "\254\206\ESCo\133\186 -// \US\145_W:\170\149\224\128og\249\161IE\145N\137",PropAssignedClientIdentifier -// "\v\224\193\194\204\215\249\ACKF",PropMessageExpiryInterval 23854,PropSharedSubscriptionAvailable 245]} +// ConnectRequest {_username = Just "\211\228\SUB\176\198\221", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "xpj95\230\&1\225?", _willMsg = "\248", _willProps = +// [PropCorrelationData "\197\&4\239I\150\236U\STX\234/",PropReceiveMaximum 17282,PropSubscriptionIdentifier +// 28,PropReasonString "\GSR\RS\SUB\152\158\135;\n\227",PropContentType "f\183\210n\156p\155\a\241<\248\255 +// \219\178`,a\226l\USC*\225w\DELVy\247",PropMaximumQoS 75,PropAuthenticationData +// "\183\254\148\233!:5`\197",PropServerKeepAlive 17308,PropMaximumQoS 249,PropMessageExpiryInterval +// 30756,PropRetainAvailable 189,PropRequestProblemInformation 94,PropMaximumPacketSize 5418,PropWillDelayInterval +// 13911,PropCorrelationData "\ETB\147\170~\240:\FS\DC1Z\173Uq}h\254\EM\195\252\DC11\232\128\249",PropReceiveMaximum +// 14720,PropRequestResponseInformation 131,PropMaximumPacketSize 31902]}), _cleanSession = True, _keepAlive = 2433, +// _connID = "\185\137\241\223?ec+\\U\r\DC1\GS\181\187\231\&9\243\232\195" "\207`\151\133O",PropReasonString +// "\209\174\214",PropMessageExpiryInterval 1097,PropMessageExpiryInterval 11875,PropRequestResponseInformation 8]} TEST(Connect5QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0x6e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2, 0x70, 0x19, 0x45, 0x23, 0x1c, 0x87, - 0x1f, 0x0, 0x14, 0xb7, 0x8b, 0xfd, 0x2b, 0x9b, 0xe4, 0x12, 0x56, 0x55, 0xde, 0xe8, 0xd, 0xf7, - 0x6f, 0x7c, 0x1c, 0x16, 0x22, 0x4e, 0x45, 0x1, 0xd, 0x2a, 0xb0, 0x24, 0xeb, 0x1, 0x3e, 0x23, - 0xa, 0x50, 0x23, 0x7e, 0x2d, 0x19, 0x67, 0x13, 0x44, 0xcb, 0x3, 0x0, 0x13, 0x4, 0xf, 0xba, - 0xc9, 0x57, 0xef, 0xa7, 0xca, 0xcc, 0xd2, 0x99, 0xe9, 0x5e, 0xde, 0x2b, 0x3d, 0xba, 0x36, 0x2b, - 0x17, 0x2d, 0x0, 0x1c, 0xcb, 0xb9, 0x30, 0x8, 0xa2, 0x2f, 0x14, 0xb8, 0x87, 0xd6, 0xf4, 0x28, - 0x65, 0x29, 0xe8, 0x96, 0x74, 0xf8, 0x82, 0x8b, 0xd9, 0x44, 0xe9, 0x6b, 0x8a, 0xed, 0x5c, 0xca}; + uint8_t pkt[] = { + 0x10, 0x8e, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54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1, 0x6, 0x13, 0x63, 0x8e, 0x23, 0x1, 0x7b, 0x0, 0x7, 0x87, 0x54, 0x87, 0x75, + 0x84, 0x82, 0x4b, 0x0, 0x1c, 0x3d, 0x8f, 0xb4, 0x46, 0x73, 0xae, 0x4f, 0x39, 0x4b, 0xc8, 0xf0, 0xfa, 0x2f, 0x8d, + 0xc6, 0x5, 0x25, 0x16, 0xc9, 0xe7, 0x6c, 0x67, 0x34, 0x6e, 0xcc, 0x1e, 0xf8, 0xd6, 0x0, 0x1d, 0xed, 0x4b, 0x77, + 0x74, 0x1b, 0x33, 0xdc, 0x14, 0x66, 0x93, 0x3d, 0x7d, 0x83, 0x44, 0xc4, 0xea, 0x80, 0xbb, 0xe9, 0x6a, 0x7b, 0x9, + 0x8a, 0x3a, 0x28, 0x49, 0x0, 0xb7, 0xdc}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb7, 0x8b, 0xfd, 0x2b, 0x9b, 0xe4, 0x12, 0x56, 0x55, 0xde, - 0xe8, 0xd, 0xf7, 0x6f, 0x7c, 0x1c, 0x16, 0x22, 0x4e, 0x45}; - uint8_t bytesprops1[] = {0x4, 0xf, 0xba, 0xc9, 0x57, 0xef, 0xa7, 0xca, 0xcc, 0xd2, - 0x99, 0xe9, 0x5e, 0xde, 0x2b, 0x3d, 0xba, 0x36, 0x2b}; + uint8_t bytesprops0[] = {0x15, 0xe8, 0x9d, 0xaf, 0x82, 0x81, 0x47, 0x43, 0x1d, 0xfb, 0x59, + 0xc2, 0x19, 0x44, 0x20, 0x8e, 0x79, 0xb3, 0xfa, 0x25, 0x60}; + uint8_t bytesprops1[] = {0x56}; + uint8_t bytesprops2[] = {0x19, 0x7e, 0xcb, 0xd4, 0x5a, 0x83, 0x82, 0xd4}; + uint8_t bytesprops3[] = {0xaf, 0xa1, 0x7d, 0xfe, 0x16, 0xa1, 0xf6, 0x47, 0xfd, 0xdf, 0x76, 0x39, 0xf, + 0x4a, 0xfb, 0x31, 0xc, 0xad, 0xd, 0x36, 0x8d, 0x7a, 0xcc, 0x89, 0x92}; + uint8_t bytesprops4[] = {0xc9, 0xe2, 0x32, 0xe4, 0xd7, 0x11, 0xfd, 0x15, 0x54, 0x92, 0x57, 0x19, 0x87, 0x82, 0x28}; + uint8_t bytesprops6[] = {0xcf, 0x60, 0x97, 0x85, 0x4f}; + uint8_t bytesprops5[] = {0x17, 0x73, 0xf1, 0x87, 0xa4, 0x9d, 0x86, 0x73, 0x11, + 0xd2, 0x3e, 0xb5, 0xbb, 0xe7, 0x39, 0xf3, 0xe8, 0xc3}; + uint8_t bytesprops7[] = {0xd1, 0xae, 0xd6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7303}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2640}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32301}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17611}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22578}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21175}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5064}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22275}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22844}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18627}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops5}, .v = {5, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1097}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11875}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25486}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 379}}, + }; + + lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x87, 0x54, 0x87, 0x75, 0x84, 0x82, 0x4b}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3d, 0x8f, 0xb4, 0x46, 0x73, 0xae, 0x4f, 0x39, 0x4b, 0xc8, 0xf0, 0xfa, 0x2f, 0x8d, + 0xc6, 0x5, 0x25, 0x16, 0xc9, 0xe7, 0x6c, 0x67, 0x34, 0x6e, 0xcc, 0x1e, 0xf8, 0xd6}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 28697; - uint8_t client_id_bytes[] = {0xcb, 0xb9, 0x30, 0x8, 0xa2, 0x2f, 0x14, 0xb8, 0x87, 0xd6, 0xf4, 0x28, 0x65, 0x29, - 0xe8, 0x96, 0x74, 0xf8, 0x82, 0x8b, 0xd9, 0x44, 0xe9, 0x6b, 0x8a, 0xed, 0x5c, 0xca}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 29757; + uint8_t client_id_bytes[] = {0xf0, 0x68, 0xf6, 0xa0, 0xbf, 0x81, 0x9d, 0x9b, 0xdb, 0xd3, 0xd7, 0xf6, 0xa2, 0xf1}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t password_bytes[] = {0xed, 0x4b, 0x77, 0x74, 0x1b, 0x33, 0xdc, 0x14, 0x66, 0x93, 0x3d, 0x7d, 0x83, 0x44, 0xc4, + 0xea, 0x80, 0xbb, 0xe9, 0x6a, 0x7b, 0x9, 0x8a, 0x3a, 0x28, 0x49, 0x0, 0xb7, 0xdc}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\ETX\167/\DLE?I\DEL\214T$", _password = Just -// "\SUB\181v\f\SO\128\188\245\DEL\145\178\224\247\166\&8", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS1, _willTopic = "\212\201\CANR|p\199", _willMsg = -// "\171\188\151\239\EM#[\DC3\EM\SI1F0\134S8\195:\144\207\US\CANc\209?\213\190@\186", _willProps = -// [PropRequestProblemInformation 167,PropTopicAliasMaximum 5511,PropPayloadFormatIndicator 29,PropMessageExpiryInterval -// 30108,PropUserProperty "\240@7\DC2\185\SYN\211\&2X\226\132\140\254\DC3" -// "\129E\194x\153\137\200\251\131?D\220K",PropMessageExpiryInterval 4336,PropUserProperty -// "\199\186p\141\&0]\129?\193\r\NUL\217\182\216\248\a\215\t\145\199" -// "\RS\DC3\211\ETB\174h\244]\161\248c\190\250'\242m\GSc\144n?6\f\192P\ETX\208\208\139",PropSessionExpiryInterval -// 8037,PropWillDelayInterval 18302,PropPayloadFormatIndicator 202,PropReasonString -// "u4\147\195\128\219/\253:\212\190In\187\199o\RS\161\227\209LbH\145+",PropRequestResponseInformation -// 201,PropMaximumQoS 175,PropSubscriptionIdentifierAvailable 178,PropRequestProblemInformation -// 239,PropSessionExpiryInterval 8424,PropUserProperty "\219\246\169x\136\219\212\211\239" -// "\193\176\f\222f\132\190\182\160D"]}), _cleanSession = True, _keepAlive = 14165, _connID = -// "s@\"\140E\205\ESCb\193\200%\173\206\NAK)\152s", _properties = [PropAuthenticationData "\189,/\228j\223\SUB -// \153IHJ$\191\246f",PropAuthenticationData -// "\135\131CLX1\194Q\246n1\247\149\DC3\208Y\195\173:3:@+\GS\185",PropResponseTopic -// "\r\141\ESC\215PT\154\216\US*I",PropServerKeepAlive 16067,PropResponseTopic -// "\149\ETX\239\233\247\US\186\211\GS\SI\199\ESC\159\184\212\187\253&\SO\SO\DC1\FS\253\&3~",PropResponseTopic -// "rp_\173\162",PropReceiveMaximum 19811,PropAssignedClientIdentifier -// "\ESC\n\186\222\159\139",PropRequestProblemInformation 9,PropReasonString -// "\rBi\234\227\&7\249LO\236*\182>qR3\147h)\245j0\137\242A*H",PropSessionExpiryInterval 27006,PropAuthenticationMethod -// "L\219\128W\144}\158\221Y-\202\210\SOH1\230O\b\195",PropSubscriptionIdentifier 25,PropServerReference -// "v\DC3\156ni\154\193\DC3\228\180\156\198J*B\249\233\DEL\GS\145G\133\&4\143\235\195\134",PropRetainAvailable -// 166,PropRetainAvailable 198,PropWillDelayInterval 23170,PropSubscriptionIdentifier 23,PropMaximumQoS -// 23,PropAuthenticationData "\182@)",PropWillDelayInterval 7608,PropSubscriptionIdentifierAvailable 47,PropReasonString -// "\DC1\218\182",PropMaximumPacketSize 1376,PropAuthenticationMethod -// "G\215\199&\SUB0\DLE\160\217\157\238\ETB\248F\174*\164\231\GS\"\142\251\243\nM\151\128\196i2",PropAuthenticationMethod +// "{g\224\175\b\232\163\225_\136\149\167\194\NUL\202F\148d\252\EM\145\NAK\221\137",PropPayloadFormatIndicator +// 250,PropMessageExpiryInterval 14991,PropAuthenticationData +// "\b\248+\189\226\NAK\155,\144\192K\157h\214\ENQb*3&\194u\142\183U\SUB^/8\173",PropAssignedClientIdentifier +// "\173\147\"!d\166\242!\216\205\DC3\144\242\254\147#",PropSessionExpiryInterval 3173,PropResponseInformation +// "\250+\238\254\185\208E\156=u\192nQ\132A~\235h\251iV\165>*D",PropResponseTopic +// "\162\180\193\154\170\195\239\255\ACK\134S\147(lc\242I\132\216\SYN\173O\nbi)",PropAuthenticationMethod +// "",PropWillDelayInterval 11821,PropSubscriptionIdentifierAvailable 210,PropSubscriptionIdentifier +// 27,PropMaximumPacketSize 20831,PropWildcardSubscriptionAvailable 199,PropAssignedClientIdentifier +// "\230\139{\ESC\234\207v\138\GS\220>\191ml",PropContentType +// ",-b$\DLE-\CAN\218\ETB\132\132=Pl\247\186GL\180\184\216\247",PropMessageExpiryInterval +// 12214,PropRequestResponseInformation 241,PropCorrelationData +// "\135\148\128\210j\208Mf\232\166\231?\172\CAN\174\&7\248\181\&9>dj\201\138\231\163=I",PropResponseInformation +// "\190\STX7\147\139Jv<\254\219H,\187\SI+",PropRequestProblemInformation 99,PropResponseInformation +// "\ESCJ\134\206\US"]}), _cleanSession = False, _keepAlive = 24021, _connID = +// "\226\DC1b\162U#[l\222e\215\133\236\USO\246T\196\148]\bq\191\235\137az", _properties = [PropAuthenticationData +// "\DC18\250\166<\252r\SI\DC16#\239\159}\DEL\244 \fB",PropWildcardSubscriptionAvailable 6,PropTopicAlias +// 12941,PropRetainAvailable 48,PropMaximumQoS 208,PropWildcardSubscriptionAvailable 97,PropTopicAliasMaximum +// 25976,PropTopicAlias 23357,PropWildcardSubscriptionAvailable 56,PropMessageExpiryInterval +// 1922,PropSessionExpiryInterval 2342,PropAssignedClientIdentifier +// "\178\130\211\140\SI\219\185\212\243H\145`.\207\143\DLET\t-(\128",PropMessageExpiryInterval 26447,PropContentType +// "|\199B",PropRequestResponseInformation 91,PropSharedSubscriptionAvailable 115,PropAssignedClientIdentifier +// "\192\237\US>`\170\238\250cc\130\&33!\166\234\165>\173",PropMaximumQoS 37,PropContentType +// "\185\EMg\150\155\227\RS\163\183S",PropTopicAliasMaximum 16720,PropReasonString +// "a`\v\191\SUBpv\254\231\232E\149\233\t\167\ETX\ESC\163[\138U",PropTopicAlias 26061]} TEST(Connect5QCTest, Encode6) { uint8_t pkt[] = { - 0x10, 0xd3, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x37, 0x55, 0xb9, 0x2, 0x16, 0x0, 0x10, 0xbd, - 0x2c, 0x2f, 0xe4, 0x6a, 0xdf, 0x1a, 0x20, 0x99, 0x49, 0x48, 0x4a, 0x24, 0xbf, 0xf6, 0x66, 0x16, 0x0, 0x19, 0x87, - 0x83, 0x43, 0x4c, 0x58, 0x31, 0xc2, 0x51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 0xb1, 0x55, 0x0, 0x12, 0x59, + 0xe3, 0xd3, 0xde, 0x48, 0xe5, 0xb5, 0x7a, 0xe1, 0x58, 0x43, 0x95, 0x44, 0x26, 0x40, 0xd0, 0x4c, 0x44, 0x0, 0xf, + 0x81, 0x52, 0xbc, 0x3c, 0x61, 0x8e, 0xf0, 0x34, 0xf4, 0x66, 0x0, 0x40, 0x33, 0x2f, 0x1e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xbd, 0x2c, 0x2f, 0xe4, 0x6a, 0xdf, 0x1a, 0x20, - 0x99, 0x49, 0x48, 0x4a, 0x24, 0xbf, 0xf6, 0x66}; - uint8_t bytesprops1[] = {0x87, 0x83, 0x43, 0x4c, 0x58, 0x31, 0xc2, 0x51, 0xf6, 0x6e, 0x31, 0xf7, 0x95, - 0x13, 0xd0, 0x59, 0xc3, 0xad, 0x3a, 0x33, 0x3a, 0x40, 0x2b, 0x1d, 0xb9}; - uint8_t bytesprops2[] = {0xd, 0x8d, 0x1b, 0xd7, 0x50, 0x54, 0x9a, 0xd8, 0x1f, 0x2a, 0x49}; - uint8_t bytesprops3[] = {0x95, 0x3, 0xef, 0xe9, 0xf7, 0x1f, 0xba, 0xd3, 0x1d, 0xf, 0xc7, 0x1b, 0x9f, - 0xb8, 0xd4, 0xbb, 0xfd, 0x26, 0xe, 0xe, 0x11, 0x1c, 0xfd, 0x33, 0x7e}; - uint8_t bytesprops4[] = {0x72, 0x70, 0x5f, 0xad, 0xa2}; - uint8_t bytesprops5[] = {0x1b, 0xa, 0xba, 0xde, 0x9f, 0x8b}; - uint8_t bytesprops6[] = {0xd, 0x42, 0x69, 0xea, 0xe3, 0x37, 0xf9, 0x4c, 0x4f, 0xec, 0x2a, 0xb6, 0x3e, 0x71, - 0x52, 0x33, 0x93, 0x68, 0x29, 0xf5, 0x6a, 0x30, 0x89, 0xf2, 0x41, 0x2a, 0x48}; - uint8_t bytesprops7[] = {0x4c, 0xdb, 0x80, 0x57, 0x90, 0x7d, 0x9e, 0xdd, 0x59, - 0x2d, 0xca, 0xd2, 0x1, 0x31, 0xe6, 0x4f, 0x8, 0xc3}; - uint8_t bytesprops8[] = {0x76, 0x13, 0x9c, 0x6e, 0x69, 0x9a, 0xc1, 0x13, 0xe4, 0xb4, 0x9c, 0xc6, 0x4a, 0x2a, - 0x42, 0xf9, 0xe9, 0x7f, 0x1d, 0x91, 0x47, 0x85, 0x34, 0x8f, 0xeb, 0xc3, 0x86}; - uint8_t bytesprops9[] = {0xb6, 0x40, 0x29}; - uint8_t bytesprops10[] = {0x11, 0xda, 0xb6}; - uint8_t bytesprops11[] = {0x47, 0xd7, 0xc7, 0x26, 0x1a, 0x30, 0x10, 0xa0, 0xd9, 0x9d, 0x3c, 0x75, 0xeb, 0x12, 0x7a, - 0xae, 0xa6, 0x93, 0x79, 0x87, 0xbf, 0xf1, 0xc0, 0xff, 0x72, 0x45, 0xc1, 0xc4, 0x5e, 0x34}; - uint8_t bytesprops12[] = {0x59, 0xe0, 0xb7, 0x3a, 0xce, 0x52, 0x76, 0xd7, 0xb7, 0xee, 0xa1, 0x63, 0xfe, 0xa9, - 0x16, 0x66, 0x7b, 0x6e, 0x57, 0x33, 0x36, 0x97, 0xe, 0x1a, 0x32, 0x6a, 0x7a, 0x4f}; + uint8_t bytesprops0[] = {0x11, 0x38, 0xfa, 0xa6, 0x3c, 0xfc, 0x72, 0xf, 0x11, 0x36, + 0x23, 0xef, 0x9f, 0x7d, 0x7f, 0xf4, 0x20, 0xc, 0x42}; + uint8_t bytesprops1[] = {0xb2, 0x82, 0xd3, 0x8c, 0xf, 0xdb, 0xb9, 0xd4, 0xf3, 0x48, 0x91, + 0x60, 0x2e, 0xcf, 0x8f, 0x10, 0x54, 0x9, 0x2d, 0x28, 0x80}; + uint8_t bytesprops2[] = {0x7c, 0xc7, 0x42}; + uint8_t bytesprops3[] = {0xc0, 0xed, 0x1f, 0x3e, 0x60, 0xaa, 0xee, 0xfa, 0x63, 0x63, + 0x82, 0x33, 0x33, 0x21, 0xa6, 0xea, 0xa5, 0x3e, 0xad}; + uint8_t bytesprops4[] = {0xb9, 0x19, 0x67, 0x96, 0x9b, 0xe3, 0x1e, 0xa3, 0xb7, 0x53}; + uint8_t bytesprops5[] = {0x61, 0x60, 0xb, 0xbf, 0x1a, 0x70, 0x76, 0xfe, 0xe7, 0xe8, 0x45, + 0x95, 0xe9, 0x9, 0xa7, 0x3, 0x1b, 0xa3, 0x5b, 0x8a, 0x55}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16067}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19811}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27006}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23170}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7608}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1376}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14329}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20018}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12941}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25976}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23357}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1922}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2342}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26447}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16720}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26061}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x81, 0x45, 0xc2, 0x78, 0x99, 0x89, 0xc8, 0xfb, 0x83, 0x3f, 0x44, 0xdc, 0x4b}; - uint8_t byteswillprops0[] = {0xf0, 0x40, 0x37, 0x12, 0xb9, 0x16, 0xd3, 0x32, 0x58, 0xe2, 0x84, 0x8c, 0xfe, 0x13}; - uint8_t byteswillprops3[] = {0x1e, 0x13, 0xd3, 0x17, 0xae, 0x68, 0xf4, 0x5d, 0xa1, 0xf8, 0x63, 0xbe, 0xfa, 0x27, 0xf2, - 0x6d, 0x1d, 0x63, 0x90, 0x6e, 0x3f, 0x36, 0xc, 0xc0, 0x50, 0x3, 0xd0, 0xd0, 0x8b}; - uint8_t byteswillprops2[] = {0xc7, 0xba, 0x70, 0x8d, 0x30, 0x5d, 0x81, 0x3f, 0xc1, 0xd, - 0x0, 0xd9, 0xb6, 0xd8, 0xf8, 0x7, 0xd7, 0x9, 0x91, 0xc7}; - uint8_t byteswillprops4[] = {0x75, 0x34, 0x93, 0xc3, 0x80, 0xdb, 0x2f, 0xfd, 0x3a, 0xd4, 0xbe, 0x49, 0x6e, - 0xbb, 0xc7, 0x6f, 0x1e, 0xa1, 0xe3, 0xd1, 0x4c, 0x62, 0x48, 0x91, 0x2b}; - uint8_t byteswillprops6[] = {0xc1, 0xb0, 0xc, 0xde, 0x66, 0x84, 0xbe, 0xb6, 0xa0, 0x44}; - uint8_t byteswillprops5[] = {0xdb, 0xf6, 0xa9, 0x78, 0x88, 0xdb, 0xd4, 0xd3, 0xef}; + uint8_t byteswillprops0[] = {0x4d, 0xcf, 0x76, 0xed, 0x48, 0x37, 0x44, 0x5c, 0xe1, 0x47, 0x5a, 0xdb, 0x8c, + 0xf, 0x6f, 0x4a, 0xd8, 0x8d, 0xc5, 0xc4, 0xc, 0xfe, 0xee, 0xd8, 0x6f, 0xa}; + uint8_t byteswillprops1[] = {0xb2, 0x9c, 0x52, 0x5c, 0x9b, 0xdb, 0x3e, 0xee, 0x17, 0xf8, 0x46, 0xae, 0x2a, 0xa4, + 0xe7, 0x1d, 0x22, 0x8e, 0xfb, 0xf3, 0xa, 0x4d, 0x97, 0x80, 0xc4, 0x69, 0x32}; + uint8_t byteswillprops2[] = {0x7b, 0x67, 0xe0, 0xaf, 0x8, 0xe8, 0xa3, 0xe1, 0x5f, 0x88, 0x95, 0xa7, + 0xc2, 0x0, 0xca, 0x46, 0x94, 0x64, 0xfc, 0x19, 0x91, 0x15, 0xdd, 0x89}; + uint8_t byteswillprops3[] = {0x8, 0xf8, 0x2b, 0xbd, 0xe2, 0x15, 0x9b, 0x2c, 0x90, 0xc0, 0x4b, 0x9d, 0x68, 0xd6, 0x5, + 0x62, 0x2a, 0x33, 0x26, 0xc2, 0x75, 0x8e, 0xb7, 0x55, 0x1a, 0x5e, 0x2f, 0x38, 0xad}; + uint8_t byteswillprops4[] = {0xad, 0x93, 0x22, 0x21, 0x64, 0xa6, 0xf2, 0x21, + 0xd8, 0xcd, 0x13, 0x90, 0xf2, 0xfe, 0x93, 0x23}; + uint8_t byteswillprops5[] = {0xfa, 0x2b, 0xee, 0xfe, 0xb9, 0xd0, 0x45, 0x9c, 0x3d, 0x75, 0xc0, 0x6e, 0x51, + 0x84, 0x41, 0x7e, 0xeb, 0x68, 0xfb, 0x69, 0x56, 0xa5, 0x3e, 0x2a, 0x44}; + uint8_t byteswillprops6[] = {0xa2, 0xb4, 0xc1, 0x9a, 0xaa, 0xc3, 0xef, 0xff, 0x6, 0x86, 0x53, 0x93, 0x28, + 0x6c, 0x63, 0xf2, 0x49, 0x84, 0xd8, 0x16, 0xad, 0x4f, 0xa, 0x62, 0x69, 0x29}; + uint8_t byteswillprops7[] = {0}; + uint8_t byteswillprops8[] = {0xe6, 0x8b, 0x7b, 0x1b, 0xea, 0xcf, 0x76, 0x8a, 0x1d, 0xdc, 0x3e, 0xbf, 0x6d, 0x6c}; + uint8_t byteswillprops9[] = {0x2c, 0x2d, 0x62, 0x24, 0x10, 0x2d, 0x18, 0xda, 0x17, 0x84, 0x84, + 0x3d, 0x50, 0x6c, 0xf7, 0xba, 0x47, 0x4c, 0xb4, 0xb8, 0xd8, 0xf7}; + uint8_t byteswillprops10[] = {0x87, 0x94, 0x80, 0xd2, 0x6a, 0xd0, 0x4d, 0x66, 0xe8, 0xa6, 0xe7, 0x3f, 0xac, 0x18, + 0xae, 0x37, 0xf8, 0xb5, 0x39, 0x3e, 0x64, 0x6a, 0xc9, 0x8a, 0xe7, 0xa3, 0x3d, 0x49}; + uint8_t byteswillprops11[] = {0xbe, 0x2, 0x37, 0x93, 0x8b, 0x4a, 0x76, 0x3c, 0xfe, 0xdb, 0x48, 0x2c, 0xbb, 0xf, 0x2b}; + uint8_t byteswillprops12[] = {0x1b, 0x4a, 0x86, 0xce, 0x1f}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5511}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30108}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {14, (char*)&byteswillprops0}, .v = {13, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4336}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {20, (char*)&byteswillprops2}, .v = {29, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8037}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18302}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8424}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {9, (char*)&byteswillprops5}, .v = {10, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7921}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1864}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28800}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18639}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14991}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3173}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11821}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20831}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12214}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&byteswillprops12}}}, }; - lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd4, 0xc9, 0x18, 0x52, 0x7c, 0x70, 0xc7}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xab, 0xbc, 0x97, 0xef, 0x19, 0x23, 0x5b, 0x13, 0x19, 0xf, - 0x31, 0x46, 0x30, 0x86, 0x53, 0x38, 0xc3, 0x3a, 0x90, 0xcf, - 0x1f, 0x18, 0x63, 0xd1, 0x3f, 0xd5, 0xbe, 0x40, 0xba}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x80, 0xf1, 0xa8, 0xa, 0xf2, 0xbb, 0xf0, 0xb1, 0x55}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x59, 0xe3, 0xd3, 0xde, 0x48, 0xe5, 0xb5, 0x7a, 0xe1, + 0x58, 0x43, 0x95, 0x44, 0x26, 0x40, 0xd0, 0x4c, 0x44}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14165; - uint8_t client_id_bytes[] = {0x73, 0x40, 0x22, 0x8c, 0x45, 0xcd, 0x1b, 0x62, 0xc1, - 0xc8, 0x25, 0xad, 0xce, 0x15, 0x29, 0x98, 0x73}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 24021; + uint8_t client_id_bytes[] = {0xe2, 0x11, 0x62, 0xa2, 0x55, 0x23, 0x5b, 0x6c, 0xde, 0x65, 0xd7, 0x85, 0xec, 0x1f, + 0x4f, 0xf6, 0x54, 0xc4, 0x94, 0x5d, 0x8, 0x71, 0xbf, 0xeb, 0x89, 0x61, 0x7a}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x3, 0xa7, 0x2f, 0x10, 0x3f, 0x49, 0x7f, 0xd6, 0x54, 0x24}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x81, 0x52, 0xbc, 0x3c, 0x61, 0x8e, 0xf0, 0x34, 0xf4, 0x66, 0x0, 0x40, 0x33, 0x2f, 0x1e}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x1a, 0xb5, 0x76, 0xc, 0xe, 0x80, 0xbc, 0xf5, 0x7f, 0x91, 0xb2, 0xe0, 0xf7, 0xa6, 0x38}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7250,259 +7174,191 @@ TEST(Connect5QCTest, Encode6) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\223\&2\199@j\160\253\250\206\223!\137Hi\230\SUB`\181\222", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\217", _willMsg = "D~6I\EOT\181", -// _willProps = [PropPayloadFormatIndicator 156,PropRequestResponseInformation 77,PropServerKeepAlive -// 3956,PropTopicAlias 28656,PropRequestProblemInformation 102,PropRequestResponseInformation 170,PropTopicAlias -// 4936,PropMaximumQoS 205,PropRequestProblemInformation 59,PropSessionExpiryInterval 20589,PropMaximumQoS -// 111,PropReceiveMaximum 32392,PropSharedSubscriptionAvailable 15,PropMessageExpiryInterval -// 30902,PropAuthenticationData "\168\\\144\255+ Aj\222\198\226X\159\179\136",PropMessageExpiryInterval -// 8553,PropUserProperty "b\154\f\251{a\149" -// "\206a\161\169\253V\US\155y\177\194\214\149b\128\215\195\150\179\171",PropAuthenticationMethod -// "kg\233\ETX\139\ESC\169\190v\172\t\n|\224 ",PropMessageExpiryInterval 26952,PropMessageExpiryInterval -// 3730,PropWillDelayInterval 28842,PropMaximumPacketSize 10225,PropRequestProblemInformation -// 149,PropResponseInformation "R_\NAK\215\206Y\146N\178\179\nvF6L "]}), _cleanSession = False, _keepAlive = 27312, -// _connID = "\179\202\212\v\189N", _properties = [PropSubscriptionIdentifierAvailable 169,PropContentType -// "\193\145\202\244\141}A\CAN\252~9\189\&1",PropSubscriptionIdentifier 19]} +// ConnectRequest {_username = Nothing, _password = Just "i\250\FS\227S", _lastWill = Nothing, _cleanSession = False, +// _keepAlive = 30539, _connID = "\226\ENQ\244\222I6\213j\202\&9\230\198\255\173\133\239\DC3\228\134\186]", _properties +// = [PropTopicAlias 30070,PropResponseTopic +// "\207\203\&4l6a\225}_\218\200_88\186w#W\181\203\ETX\188K\216\248\207vx,",PropContentType +// "\150\&2\210\244\168uq\219",PropReceiveMaximum 6983,PropReasonString +// "\184Y\216\158\237X\146\152\221\143\231\237\SO?\198r\130(\148\241",PropReceiveMaximum 9483,PropResponseTopic +// "\n\ACK\188\160\231\188i\185T\170E6\166\&3\242\ESC\150}",PropCorrelationData "[^Y\181\SUB\129",PropWillDelayInterval +// 12175,PropResponseTopic ";4\CAN\166oQ\GS\226+j[\205\153\178S-\232\247\132O\231\STX\ACK\160\255\132\181\241",PropSubscriptionIdentifier -// 19,PropResponseInformation "=&\220\143\255\245\a\231",PropMaximumPacketSize 23158,PropResponseInformation -// "\232\246jr\aGG\166f+G\131Q\196!\249\vV"]}), _cleanSession = True, _keepAlive = 20507, _connID = -// "-\202\240\v`\SOH\255oj\230\172\EM\212J", _properties = [PropRetainAvailable 201,PropSubscriptionIdentifierAvailable -// 131,PropMessageExpiryInterval 20159,PropWillDelayInterval 18712,PropCorrelationData -// "\202\205\170X\211\248W:\203\RS\221\134\163o\252L\156G\171_B\234\165D\n\240",PropWillDelayInterval -// 21003,PropPayloadFormatIndicator 66,PropAuthenticationData -// "$T\159\193\130H(\\\180\190u\DC4H$\173ncj\249d\195>\225n\247W4\165\130\154",PropMaximumPacketSize 28012]} +// ConnectRequest {_username = Just "\225\203mIB\148\147s", _password = Nothing, _lastWill = Just (LastWill {_willRetain +// = False, _willQoS = QoS0, _willTopic = "`\SO\132\139\ESC\222W\198\STXb$", _willMsg = +// "j\225L%\SYN:R\144\143\244\201FZce\154\SO[\DC1\183\205\197\134J,\184", _willProps = [PropTopicAliasMaximum +// 16098,PropTopicAlias 13294,PropSubscriptionIdentifier 13,PropWillDelayInterval 3829,PropResponseInformation +// "",PropRequestResponseInformation 158,PropReasonString +// "\211\154\249\151\225\140v\SOH\143\234\204\NULcX`\185M\130\182",PropSubscriptionIdentifier 0,PropMaximumPacketSize +// 30261,PropServerReference "\151\170",PropTopicAlias 2905,PropRequestResponseInformation 163,PropRetainAvailable +// 244,PropWillDelayInterval 24559,PropServerKeepAlive 1251,PropReasonString +// "\238So\171\214\GS0\188\147\DEL\205[\211\&6\231\255\161\128\&3y:\USfN\240'\210\130E",PropCorrelationData +// "{\180\&9X\145\174\SI\r\197\172",PropMessageExpiryInterval 31230,PropUserProperty "q\175P\244\a\184\161\SYN" +// "\128b\212\147\139p",PropRequestResponseInformation 119]}), _cleanSession = False, _keepAlive = 14155, _connID = +// "\190I\DC1\187\DEL", _properties = [PropSubscriptionIdentifier 6,PropReceiveMaximum +// 27185,PropSharedSubscriptionAvailable 85,PropAssignedClientIdentifier +// "M~\220\251o\DC2\160L\144\134",PropRequestResponseInformation 39]} TEST(Connect5QCTest, Encode8) { - uint8_t pkt[] = { - 0x10, 0xd9, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0x50, 0x1b, 0x58, 0x25, 0xc9, 0x29, 0x83, 0x2, - 0x0, 0x0, 0x4e, 0xbf, 0x18, 0x0, 0x0, 0x49, 0x18, 0x9, 0x0, 0x1a, 0xca, 0xcd, 0xaa, 0x58, 0xd3, 0xf8, 0x57, - 0x3a, 0xcb, 0x1e, 0xdd, 0x86, 0xa3, 0x6f, 0xfc, 0x4c, 0x9c, 0x47, 0xab, 0x5f, 0x42, 0xea, 0xa5, 0x44, 0xa, 0xf0, - 0x18, 0x0, 0x0, 0x52, 0xb, 0x1, 0x42, 0x16, 0x0, 0x1e, 0x24, 0x54, 0x9f, 0xc1, 0x82, 0x48, 0x28, 0x5c, 0xb4, - 0xbe, 0x75, 0x14, 0x48, 0x24, 0xad, 0x6e, 0x63, 0x6a, 0xf9, 0x64, 0xc3, 0x3e, 0xe1, 0x6e, 0xf7, 0x57, 0x34, 0xa5, - 0x82, 0x9a, 0x27, 0x0, 0x0, 0x6d, 0x6c, 0x0, 0xe, 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0x8b, 0x1b, 0xde, 0x57, 0xc6, 0x2, 0x62, 0x24, 0x0, 0x1a, 0x6a, 0xe1, 0x4c, 0x25, 0x16, 0x3a, + 0x52, 0x90, 0x8f, 0xf4, 0xc9, 0x46, 0x5a, 0x63, 0x65, 0x9a, 0xe, 0x5b, 0x11, 0xb7, 0xcd, 0xc5, 0x86, + 0x4a, 0x2c, 0xb8, 0x0, 0x8, 0xe1, 0xcb, 0x6d, 0x49, 0x42, 0x94, 0x93, 0x73}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xca, 0xcd, 0xaa, 0x58, 0xd3, 0xf8, 0x57, 0x3a, 0xcb, 0x1e, 0xdd, 0x86, 0xa3, - 0x6f, 0xfc, 0x4c, 0x9c, 0x47, 0xab, 0x5f, 0x42, 0xea, 0xa5, 0x44, 0xa, 0xf0}; - uint8_t bytesprops1[] = {0x24, 0x54, 0x9f, 0xc1, 0x82, 0x48, 0x28, 0x5c, 0xb4, 0xbe, 0x75, 0x14, 0x48, 0x24, 0xad, - 0x6e, 0x63, 0x6a, 0xf9, 0x64, 0xc3, 0x3e, 0xe1, 0x6e, 0xf7, 0x57, 0x34, 0xa5, 0x82, 0x9a}; + uint8_t bytesprops0[] = {0x4d, 0x7e, 0xdc, 0xfb, 0x6f, 0x12, 0xa0, 0x4c, 0x90, 0x86}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20159}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18712}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21003}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28012}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27185}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x8e, 0x61, 0xe3, 0x47, 0x87, 0xa6, 0x96, 0x7f}; - uint8_t byteswillprops1[] = {0}; - uint8_t byteswillprops2[] = {0x51, 0xc0, 0x74, 0x35, 0x66, 0x38, 0x96, 0x68, 0x4c, 0x14, 0x0}; - uint8_t byteswillprops3[] = {0xa2, 0x88, 0x3, 0xd, 0x36, 0xd1, 0xa8, 0x27, 0x12, 0x6a, - 0x42, 0xa2, 0xbc, 0xa, 0xc3, 0xce, 0xc4, 0x37, 0x8b, 0xbb}; - uint8_t byteswillprops4[] = {0x14, 0x9, 0x40, 0x1c, 0x31, 0x95, 0xd6, 0x48, 0xbd, - 0x3b, 0x78, 0x9c, 0x58, 0xbc, 0x63, 0x9b, 0x71, 0x87}; - uint8_t byteswillprops5[] = {0x9e, 0x20, 0x76, 0xb0, 0xb4, 0x8e, 0x31, 0x74, 0xeb, 0x4, 0x56}; - uint8_t byteswillprops6[] = {0x23, 0xdf, 0x46, 0xa4, 0xbb, 0x9d, 0xe5, 0xcc, 0x41, 0xef, 0x33, 0x1, 0xed, 0x5e, - 0x31, 0x6a, 0x97, 0x7d, 0x40, 0x95, 0xe6, 0x3d, 0x57, 0xfc, 0x9f, 0x5d, 0xc, 0x65}; - uint8_t byteswillprops7[] = {0x32, 0xf1, 0x38, 0x6, 0x39, 0x1, 0xa3, 0x71, 0xdc, 0xa5, 0x75, 0x59, 0xa0, - 0xdc, 0xa4, 0x70, 0x9d, 0x4d, 0xcf, 0xdd, 0xe3, 0x2f, 0x6f, 0xcc, 0x9c}; - uint8_t byteswillprops9[] = {0x5e, 0x84, 0xe9, 0x9c, 0x1f, 0x40, 0x6a, 0x60, 0x8b, 0x8e, 0x23, - 0x96, 0xe8, 0x2f, 0x8e, 0x42, 0x13, 0x71, 0x60, 0x68, 0x83}; - uint8_t byteswillprops8[] = {0x21, 0xc7, 0xab, 0x50, 0x10, 0x1d, 0xc9, 0x1a, 0x45, 0x96, 0xf6, 0x34}; - uint8_t byteswillprops10[] = {0x1f, 0xc0, 0x7e, 0x59}; - uint8_t byteswillprops11[] = {0x29, 0x5c, 0x25, 0xa9, 0x7e, 0x89, 0xaa, 0xdf, - 0x9f, 0x1b, 0xc2, 0xc4, 0xe2, 0x26, 0xab, 0x5a}; - uint8_t byteswillprops12[] = {0x8b, 0x13, 0x3c, 0x23, 0xee, 0x95, 0x9f, 0x3e, 0x1d, 0xe2, - 0x2b, 0x6a, 0x5b, 0xcd, 0x99, 0xb2, 0x53, 0x2d, 0xe8, 0xf7, - 0x84, 0x4f, 0xe7, 0x2, 0x6, 0xa0, 0xff, 0x84, 0xb5, 0xf1}; - uint8_t byteswillprops13[] = {0x3d, 0x26, 0xdc, 0x8f, 0xff, 0xf5, 0x7, 0xe7}; - uint8_t byteswillprops14[] = {0xe8, 0xf6, 0x6a, 0x72, 0x7, 0x47, 0x47, 0xa6, 0x66, - 0x2b, 0x47, 0x83, 0x51, 0xc4, 0x21, 0xf9, 0xb, 0x56}; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops1[] = {0xd3, 0x9a, 0xf9, 0x97, 0xe1, 0x8c, 0x76, 0x1, 0x8f, 0xea, + 0xcc, 0x0, 0x63, 0x58, 0x60, 0xb9, 0x4d, 0x82, 0xb6}; + uint8_t byteswillprops2[] = {0x97, 0xaa}; + uint8_t byteswillprops3[] = {0xee, 0x53, 0x6f, 0xab, 0xd6, 0x1d, 0x30, 0xbc, 0x93, 0x7f, 0xcd, 0x5b, 0xd3, 0x36, 0xe7, + 0xff, 0xa1, 0x80, 0x33, 0x79, 0x3a, 0x1f, 0x66, 0x4e, 0xf0, 0x27, 0xd2, 0x82, 0x45}; + uint8_t byteswillprops4[] = {0x7b, 0xb4, 0x39, 0x58, 0x91, 0xae, 0xf, 0xd, 0xc5, 0xac}; + uint8_t byteswillprops6[] = {0x80, 0x62, 0xd4, 0x93, 0x8b, 0x70}; + uint8_t byteswillprops5[] = {0x71, 0xaf, 0x50, 0xf4, 0x7, 0xb8, 0xa1, 0x16}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30952}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21637}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31926}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 429}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32265}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16098}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13294}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3829}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30261}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2905}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24559}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1251}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31230}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {12, (char*)&byteswillprops8}, .v = {21, (char*)&byteswillprops9}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 680}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&byteswillprops12}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops13}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23158}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops14}}}, + .value = {.pair = {.k = {8, (char*)&byteswillprops5}, .v = {6, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 119}}, }; - lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x19, 0x53, 0xa5, 0x66, 0x3e, 0xc0, 0xc4, 0x1c, 0x9b, 0xb3, 0x80, 0x5d, 0xe1, - 0xdf, 0x10, 0x97, 0x65, 0x40, 0x9f, 0x68, 0x88, 0xee, 0xdd, 0x39, 0xcd, 0x7f}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x10, 0x17, 0xb, 0x83, 0x62, 0xf1, 0xa1, 0x3c, 0xd9}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x60, 0xe, 0x84, 0x8b, 0x1b, 0xde, 0x57, 0xc6, 0x2, 0x62, 0x24}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6a, 0xe1, 0x4c, 0x25, 0x16, 0x3a, 0x52, 0x90, 0x8f, 0xf4, 0xc9, 0x46, 0x5a, + 0x63, 0x65, 0x9a, 0xe, 0x5b, 0x11, 0xb7, 0xcd, 0xc5, 0x86, 0x4a, 0x2c, 0xb8}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 20507; - uint8_t client_id_bytes[] = {0x2d, 0xca, 0xf0, 0xb, 0x60, 0x1, 0xff, 0x6f, 0x6a, 0xe6, 0xac, 0x19, 0xd4, 0x4a}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 14155; + uint8_t client_id_bytes[] = {0xbe, 0x49, 0x11, 0xbb, 0x7f}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t username_bytes[] = {0xe1, 0xcb, 0x6d, 0x49, 0x42, 0x94, 0x93, 0x73}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7511,174 +7367,116 @@ TEST(Connect5QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\207\218?<\130\251\SI\189E\184\US\216$Z{?\252|\252", _password = Just -// "\184b#\224}]\DC4\210", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "J=\ESCG\249 -// t\STX\247m\RS\147\RS\157\225K\NUL\148G\203", _willMsg = -// "q\155\"+\180\161,\176\&9D\251\159!\164(|\235\247\178\213p\208\"\199~%X\226\251", _willProps = -// [PropWildcardSubscriptionAvailable 149,PropResponseInformation -// "\DEL\135\&4\218\224\228\235r@)\209\225\140\144UGV\217\142T\vq\216W\156\177\231",PropReasonString -// "\231\135\DLER\239n7\b\219P\250d>\141\152\STX\163",PropSubscriptionIdentifier 8,PropMaximumQoS -// 227,PropCorrelationData "\239:L}\DC4)\233\EOT",PropTopicAlias 31130,PropSharedSubscriptionAvailable -// 221,PropMessageExpiryInterval 22834,PropAuthenticationMethod "&o\138*\229\249-\v\191",PropMaximumPacketSize -// 32076,PropContentType "D\229[*i",PropAuthenticationData -// "4\218\191\172'-\\\131\RS\192\133c\254",PropSessionExpiryInterval 14123,PropSharedSubscriptionAvailable -// 84,PropAssignedClientIdentifier "",PropSubscriptionIdentifier 6,PropMessageExpiryInterval 30788,PropCorrelationData -// "\148\v@\246\151\144\&3\141\162",PropMaximumQoS 199,PropWillDelayInterval 7016,PropWillDelayInterval -// 16814,PropWillDelayInterval 24150,PropAssignedClientIdentifier -// "\vAD\RSI\254\179\142\128\205ix\191\NUL\130u\235\150/l\GSq",PropSharedSubscriptionAvailable -// 8,PropAssignedClientIdentifier "U\GS;\DC2\207",PropAuthenticationData "\DEL\209\FS",PropServerKeepAlive 24347]}), -// _cleanSession = False, _keepAlive = 8484, _connID = "\219\138\191|*\231\ACK\191WZCrWZ\r\ETXLA\247|6", _properties = -// [PropAuthenticationData "T6_m\148\177\CANP\ETB\191[\213\162\129\175\164!\DC1NM\b\248\ETX[9\181\181",PropMaximumQoS -// 18,PropUserProperty "\211\172K\174p3\STXf6\214\DC35\204\145" -// "(k'\160;k\158\199\238\186K\255\161\222\172\tNh\146*\147U\200N",PropMessageExpiryInterval -// 9906,PropAuthenticationMethod "d\184\180\131\255V\255\163\237;",PropTopicAliasMaximum 4996,PropCorrelationData -// "\253\177(\194\221u\n\145\145a\196;\193\231\173\200\143\194\225\155\194\145e\244T",PropAssignedClientIdentifier -// "t",PropReasonString "\224\EOT\220\199\223]\r\158\130\229\163\243\199\188\165\242qs",PropMaximumQoS -// 198,PropTopicAlias 9276,PropResponseInformation "\203\143\173\179\233\209\131d",PropServerReference -// "\230.\145\fd8=\253x\140\SOH\137\233\199\238\206\&9\164\216-@\144",PropMessageExpiryInterval -// 10006,PropSessionExpiryInterval 2484,PropReasonString -// "o\b}\156\167\185\196T\222b\STX8T\201\170\146Ql",PropMessageExpiryInterval 16834,PropReceiveMaximum -// 26987,PropSubscriptionIdentifierAvailable 169,PropWildcardSubscriptionAvailable 38,PropAuthenticationMethod -// "|\137",PropCorrelationData -// "\147b{\233\235\149\219\183\213\SYN\172\174\EM\176y\130\160\199w\254]W'\229sb\170\&1\201v",PropRequestResponseInformation -// 78]} +// ConnectRequest {_username = Just "\bA\DC1\DEL\213g\EMC\130^", _password = Just +// "\188\164\213\\P1\226\188\191\201\185\135\150z\216\157\DC4", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS1, _willTopic = "\171C0\171", _willMsg = +// "6\164j\195\226\206\EOT\186\FS?\207\245\154\164\223jR\224#2sJ\165N\145#H\196\159\146", _willProps = [PropMaximumQoS +// 144,PropAuthenticationMethod "\193<\182\202~\233P\204\174F\229MGp\DEL_@\138u\219\207\159d",PropResponseTopic +// "\164\151+\185\ENQ@\SYN\DLE\t\226\231\199k\155\ETX\204.\222%",PropSharedSubscriptionAvailable 34,PropReasonString +// "\166\135\167A\169\204\SYN\147\141\240\254\200ku\n~^B\212R\231\EM7\158",PropWillDelayInterval 10273,PropContentType +// "\190m\183\186\147b\198\236y\ENQ\239S\182\231\DC4\247\a\220\205\b\v}\192\n\151;\157\199\171\159",PropTopicAlias +// 16211,PropCorrelationData "\148\155t\SUB\205Evl\165\220\250"]}), _cleanSession = True, _keepAlive = 29647, _connID = +// "\176\248\150\&5VEy\GS\DC1kSt(`\136\SUB\233\233\156\174\213", _properties = [PropAuthenticationData +// "\241\\\187\251\178#S\140\135\&6\174\FS\230\&5r9\CAN!",PropContentType +// "\193\131QV\228\229K\STXr\205\215q\207}\229\r\236",PropMaximumPacketSize 11364,PropSessionExpiryInterval +// 7409,PropSharedSubscriptionAvailable 158,PropAuthenticationMethod "\225?m?\158\200aC",PropResponseTopic +// "",PropSharedSubscriptionAvailable 85,PropRetainAvailable 97,PropWildcardSubscriptionAvailable 211,PropResponseTopic +// "H!\241\128\ETX\\(\185\160\211\135\196\214\&4_\164",PropPayloadFormatIndicator 39,PropSessionExpiryInterval +// 3336,PropContentType " +// }\FS\US\t\172\167;l:\a\237\164\195\188\214\212#\212\177\157s\246x\231",PropSubscriptionIdentifierAvailable +// 74,PropAuthenticationMethod "f\172#\244\162\173F#\ETBc",PropMessageExpiryInterval 17913,PropContentType +// "\DC4\210:\237\RST_\158"]} TEST(Connect5QCTest, Encode9) { uint8_t pkt[] = { - 0x10, 0xda, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x21, 0x24, 0x91, 0x2, 0x16, 0x0, 0x1b, 0x54, - 0x36, 0x5f, 0x6d, 0x94, 0xb1, 0x18, 0x50, 0x17, 0xbf, 0x5b, 0xd5, 0xa2, 0x81, 0xaf, 0xa4, 0x21, 0x11, 0x4e, 0x4d, - 0x8, 0xf8, 0x3, 0x5b, 0x39, 0xb5, 0xb5, 0x24, 0x12, 0x26, 0x0, 0xe, 0xd3, 0xac, 0x4b, 0xae, 0x70, 0x33, 0x2, - 0x66, 0x36, 0xd6, 0x13, 0x35, 0xcc, 0x91, 0x0, 0x18, 0x28, 0x6b, 0x27, 0xa0, 0x3b, 0x6b, 0x9e, 0xc7, 0xee, 0xba, - 0x4b, 0xff, 0xa1, 0xde, 0xac, 0x9, 0x4e, 0x68, 0x92, 0x2a, 0x93, 0x55, 0xc8, 0x4e, 0x2, 0x0, 0x0, 0x26, 0xb2, - 0x15, 0x0, 0xa, 0x64, 0xb8, 0xb4, 0x83, 0xff, 0x56, 0xff, 0xa3, 0xed, 0x3b, 0x22, 0x13, 0x84, 0x9, 0x0, 0x19, - 0xfd, 0xb1, 0x28, 0xc2, 0xdd, 0x75, 0xa, 0x91, 0x91, 0x61, 0xc4, 0x3b, 0xc1, 0xe7, 0xad, 0xc8, 0x8f, 0xc2, 0xe1, - 0x9b, 0xc2, 0x91, 0x65, 0xf4, 0x54, 0x12, 0x0, 0x1, 0x74, 0x1f, 0x0, 0x12, 0xe0, 0x4, 0xdc, 0xc7, 0xdf, 0x5d, - 0xd, 0x9e, 0x82, 0xe5, 0xa3, 0xf3, 0xc7, 0xbc, 0xa5, 0xf2, 0x71, 0x73, 0x24,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0xc0, 0xa, 0x97, 0x3b, 0x9d, 0xc7, 0xab, 0x9f, 0x23, 0x3f, 0x53, 0x9, 0x0, 0xb, 0x94, 0x9b, + 0x74, 0x1a, 0xcd, 0x45, 0x76, 0x6c, 0xa5, 0xdc, 0xfa, 0x0, 0x4, 0xab, 0x43, 0x30, 0xab, 0x0, 0x1e, 0x36, 0xa4, + 0x6a, 0xc3, 0xe2, 0xce, 0x4, 0xba, 0x1c, 0x3f, 0xcf, 0xf5, 0x9a, 0xa4, 0xdf, 0x6a, 0x52, 0xe0, 0x23, 0x32, 0x73, + 0x4a, 0xa5, 0x4e, 0x91, 0x23, 0x48, 0xc4, 0x9f, 0x92, 0x0, 0xa, 0x8, 0x41, 0x11, 0x7f, 0xd5, 0x67, 0x19, 0x43, + 0x82, 0x5e, 0x0, 0x11, 0xbc, 0xa4, 0xd5, 0x5c, 0x50, 0x31, 0xe2, 0xbc, 0xbf, 0xc9, 0xb9, 0x87, 0x96, 0x7a, 0xd8, + 0x9d, 0x14}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x54, 0x36, 0x5f, 0x6d, 0x94, 0xb1, 0x18, 0x50, 0x17, 0xbf, 0x5b, 0xd5, 0xa2, 0x81, - 0xaf, 0xa4, 0x21, 0x11, 0x4e, 0x4d, 0x8, 0xf8, 0x3, 0x5b, 0x39, 0xb5, 0xb5}; - uint8_t bytesprops2[] = {0x28, 0x6b, 0x27, 0xa0, 0x3b, 0x6b, 0x9e, 0xc7, 0xee, 0xba, 0x4b, 0xff, - 0xa1, 0xde, 0xac, 0x9, 0x4e, 0x68, 0x92, 0x2a, 0x93, 0x55, 0xc8, 0x4e}; - uint8_t bytesprops1[] = {0xd3, 0xac, 0x4b, 0xae, 0x70, 0x33, 0x2, 0x66, 0x36, 0xd6, 0x13, 0x35, 0xcc, 0x91}; - uint8_t bytesprops3[] = {0x64, 0xb8, 0xb4, 0x83, 0xff, 0x56, 0xff, 0xa3, 0xed, 0x3b}; - uint8_t bytesprops4[] = {0xfd, 0xb1, 0x28, 0xc2, 0xdd, 0x75, 0xa, 0x91, 0x91, 0x61, 0xc4, 0x3b, 0xc1, - 0xe7, 0xad, 0xc8, 0x8f, 0xc2, 0xe1, 0x9b, 0xc2, 0x91, 0x65, 0xf4, 0x54}; - uint8_t bytesprops5[] = {0x74}; - uint8_t bytesprops6[] = {0xe0, 0x4, 0xdc, 0xc7, 0xdf, 0x5d, 0xd, 0x9e, 0x82, - 0xe5, 0xa3, 0xf3, 0xc7, 0xbc, 0xa5, 0xf2, 0x71, 0x73}; - uint8_t bytesprops7[] = {0xcb, 0x8f, 0xad, 0xb3, 0xe9, 0xd1, 0x83, 0x64}; - uint8_t bytesprops8[] = {0xe6, 0x2e, 0x91, 0xc, 0x64, 0x38, 0x3d, 0xfd, 0x78, 0x8c, 0x1, - 0x89, 0xe9, 0xc7, 0xee, 0xce, 0x39, 0xa4, 0xd8, 0x2d, 0x40, 0x90}; - uint8_t bytesprops9[] = {0x6f, 0x8, 0x7d, 0x9c, 0xa7, 0xb9, 0xc4, 0x54, 0xde, - 0x62, 0x2, 0x38, 0x54, 0xc9, 0xaa, 0x92, 0x51, 0x6c}; - uint8_t bytesprops10[] = {0x7c, 0x89}; - uint8_t bytesprops11[] = {0x93, 0x62, 0x7b, 0xe9, 0xeb, 0x95, 0xdb, 0xb7, 0xd5, 0x16, 0xac, 0xae, 0x19, 0xb0, 0x79, - 0x82, 0xa0, 0xc7, 0x77, 0xfe, 0x5d, 0x57, 0x27, 0xe5, 0x73, 0x62, 0xaa, 0x31, 0xc9, 0x76}; + uint8_t bytesprops0[] = {0xf1, 0x5c, 0xbb, 0xfb, 0xb2, 0x23, 0x53, 0x8c, 0x87, + 0x36, 0xae, 0x1c, 0xe6, 0x35, 0x72, 0x39, 0x18, 0x21}; + uint8_t bytesprops1[] = {0xc1, 0x83, 0x51, 0x56, 0xe4, 0xe5, 0x4b, 0x2, 0x72, + 0xcd, 0xd7, 0x71, 0xcf, 0x7d, 0xe5, 0xd, 0xec}; + uint8_t bytesprops2[] = {0xe1, 0x3f, 0x6d, 0x3f, 0x9e, 0xc8, 0x61, 0x43}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x48, 0x21, 0xf1, 0x80, 0x3, 0x5c, 0x28, 0xb9, + 0xa0, 0xd3, 0x87, 0xc4, 0xd6, 0x34, 0x5f, 0xa4}; + uint8_t bytesprops5[] = {0x20, 0x7d, 0x1c, 0x1f, 0x9, 0xac, 0xa7, 0x3b, 0x6c, 0x3a, 0x7, 0xed, 0xa4, + 0xc3, 0xbc, 0xd6, 0xd4, 0x23, 0xd4, 0xb1, 0x9d, 0x73, 0xf6, 0x78, 0xe7}; + uint8_t bytesprops6[] = {0x66, 0xac, 0x23, 0xf4, 0xa2, 0xad, 0x46, 0x23, 0x17, 0x63}; + uint8_t bytesprops7[] = {0x14, 0xd2, 0x3a, 0xed, 0x1e, 0x54, 0x5f, 0x9e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops1}, .v = {24, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9906}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4996}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9276}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10006}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2484}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16834}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26987}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11364}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7409}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3336}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17913}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x7f, 0x87, 0x34, 0xda, 0xe0, 0xe4, 0xeb, 0x72, 0x40, 0x29, 0xd1, 0xe1, 0x8c, 0x90, - 0x55, 0x47, 0x56, 0xd9, 0x8e, 0x54, 0xb, 0x71, 0xd8, 0x57, 0x9c, 0xb1, 0xe7}; - uint8_t byteswillprops1[] = {0xe7, 0x87, 0x10, 0x52, 0xef, 0x6e, 0x37, 0x8, 0xdb, - 0x50, 0xfa, 0x64, 0x3e, 0x8d, 0x98, 0x2, 0xa3}; - uint8_t byteswillprops2[] = {0xef, 0x3a, 0x4c, 0x7d, 0x14, 0x29, 0xe9, 0x4}; - uint8_t byteswillprops3[] = {0x26, 0x6f, 0x8a, 0x2a, 0xe5, 0xf9, 0x2d, 0xb, 0xbf}; - uint8_t byteswillprops4[] = {0x44, 0xe5, 0x5b, 0x2a, 0x69}; - uint8_t byteswillprops5[] = {0x34, 0xda, 0xbf, 0xac, 0x27, 0x2d, 0x5c, 0x83, 0x1e, 0xc0, 0x85, 0x63, 0xfe}; - uint8_t byteswillprops6[] = {0}; - uint8_t byteswillprops7[] = {0x94, 0xb, 0x40, 0xf6, 0x97, 0x90, 0x33, 0x8d, 0xa2}; - uint8_t byteswillprops8[] = {0xb, 0x41, 0x44, 0x1e, 0x49, 0xfe, 0xb3, 0x8e, 0x80, 0xcd, 0x69, - 0x78, 0xbf, 0x0, 0x82, 0x75, 0xeb, 0x96, 0x2f, 0x6c, 0x1d, 0x71}; - uint8_t byteswillprops9[] = {0x55, 0x1d, 0x3b, 0x12, 0xcf}; - uint8_t byteswillprops10[] = {0x7f, 0xd1, 0x1c}; + uint8_t byteswillprops0[] = {0xc1, 0x3c, 0xb6, 0xca, 0x7e, 0xe9, 0x50, 0xcc, 0xae, 0x46, 0xe5, 0x4d, + 0x47, 0x70, 0x7f, 0x5f, 0x40, 0x8a, 0x75, 0xdb, 0xcf, 0x9f, 0x64}; + uint8_t byteswillprops1[] = {0xa4, 0x97, 0x2b, 0xb9, 0x5, 0x40, 0x16, 0x10, 0x9, 0xe2, + 0xe7, 0xc7, 0x6b, 0x9b, 0x3, 0xcc, 0x2e, 0xde, 0x25}; + uint8_t byteswillprops2[] = {0xa6, 0x87, 0xa7, 0x41, 0xa9, 0xcc, 0x16, 0x93, 0x8d, 0xf0, 0xfe, 0xc8, + 0x6b, 0x75, 0xa, 0x7e, 0x5e, 0x42, 0xd4, 0x52, 0xe7, 0x19, 0x37, 0x9e}; + uint8_t byteswillprops3[] = {0xbe, 0x6d, 0xb7, 0xba, 0x93, 0x62, 0xc6, 0xec, 0x79, 0x5, + 0xef, 0x53, 0xb6, 0xe7, 0x14, 0xf7, 0x7, 0xdc, 0xcd, 0x8, + 0xb, 0x7d, 0xc0, 0xa, 0x97, 0x3b, 0x9d, 0xc7, 0xab, 0x9f}; + uint8_t byteswillprops4[] = {0x94, 0x9b, 0x74, 0x1a, 0xcd, 0x45, 0x76, 0x6c, 0xa5, 0xdc, 0xfa}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31130}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22834}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32076}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14123}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30788}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7016}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16814}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24150}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24347}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10273}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16211}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops4}}}, }; - lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4a, 0x3d, 0x1b, 0x47, 0xf9, 0x20, 0x74, 0x2, 0xf7, 0x6d, - 0x1e, 0x93, 0x1e, 0x9d, 0xe1, 0x4b, 0x0, 0x94, 0x47, 0xcb}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x71, 0x9b, 0x22, 0x2b, 0xb4, 0xa1, 0x2c, 0xb0, 0x39, 0x44, - 0xfb, 0x9f, 0x21, 0xa4, 0x28, 0x7c, 0xeb, 0xf7, 0xb2, 0xd5, - 0x70, 0xd0, 0x22, 0xc7, 0x7e, 0x25, 0x58, 0xe2, 0xfb}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xab, 0x43, 0x30, 0xab}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x36, 0xa4, 0x6a, 0xc3, 0xe2, 0xce, 0x4, 0xba, 0x1c, 0x3f, + 0xcf, 0xf5, 0x9a, 0xa4, 0xdf, 0x6a, 0x52, 0xe0, 0x23, 0x32, + 0x73, 0x4a, 0xa5, 0x4e, 0x91, 0x23, 0x48, 0xc4, 0x9f, 0x92}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -7686,18 +7484,18 @@ TEST(Connect5QCTest, Encode9) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 8484; - uint8_t client_id_bytes[] = {0xdb, 0x8a, 0xbf, 0x7c, 0x2a, 0xe7, 0x6, 0xbf, 0x57, 0x5a, 0x43, - 0x72, 0x57, 0x5a, 0xd, 0x3, 0x4c, 0x41, 0xf7, 0x7c, 0x36}; + opts.clean_session = true; + opts.keep_alive = 29647; + uint8_t client_id_bytes[] = {0xb0, 0xf8, 0x96, 0x35, 0x56, 0x45, 0x79, 0x1d, 0x11, 0x6b, 0x53, + 0x74, 0x28, 0x60, 0x88, 0x1a, 0xe9, 0xe9, 0x9c, 0xae, 0xd5}; lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xcf, 0xda, 0x3f, 0x3c, 0x82, 0xfb, 0xf, 0xbd, 0x45, 0xb8, - 0x1f, 0xd8, 0x24, 0x5a, 0x7b, 0x3f, 0xfc, 0x7c, 0xfc}; - lwmqtt_string_t username = {19, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x8, 0x41, 0x11, 0x7f, 0xd5, 0x67, 0x19, 0x43, 0x82, 0x5e}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xb8, 0x62, 0x23, 0xe0, 0x7d, 0x5d, 0x14, 0xd2}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xbc, 0xa4, 0xd5, 0x5c, 0x50, 0x31, 0xe2, 0xbc, 0xbf, + 0xc9, 0xb9, 0x87, 0x96, 0x7a, 0xd8, 0x9d, 0x14}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7707,156 +7505,103 @@ TEST(Connect5QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\204\DC2Bw\158G\232{\204\238N\218\&9\f\150", _password = Just -// "/ME\221/\224L\203\216\150\t=\195a\169\197P[\251\137\DC3\219\152\253\ENQL\153\239", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\160TX\134\176\USa\167\209[\146\&0", _willMsg = -// "\130\128b\DC1U\178\198J:\"\154\&9\174\144\&79\222\DEL\212\204'\ENQ\227\139\&7\132", _willProps = -// [PropWildcardSubscriptionAvailable 219,PropSharedSubscriptionAvailable 19,PropRequestResponseInformation -// 226,PropSessionExpiryInterval 30066,PropContentType -// "\212\184\141\\\143%W\190|\152\DC3\193E\n\t\237\159\184?\194\129|\131\231\171G\230\&0!\188",PropTopicAliasMaximum -// 2047,PropMessageExpiryInterval 25577,PropSubscriptionIdentifier 10,PropAuthenticationMethod -// "\193\235,\149\&7\212X",PropAuthenticationMethod "\206\254Wz\ETB\174)\179#\ETB\159W\174",PropCorrelationData -// "%\NAKH\EM&\166\208\192\EM\226\133\223\ENQ6\FS\138\156d}\145Gv",PropRetainAvailable 154,PropAuthenticationData -// "\162\151\SUBN\234\SUB\226\&3\SYN8\152\156*\249\137k6\175\250x\158\135!\208\STX+\194\a\246",PropRequestResponseInformation -// 245,PropAssignedClientIdentifier -// "\181h&v\183[\189\STX]P2\182\SYNO\179\f\245\226\166\189\236\247o\250]\193M\229",PropSharedSubscriptionAvailable -// 20,PropContentType "\247V\148\159\223`\a\244\217b\ETB:\217",PropReasonString -// "h\241\252P3\136\n\tg6\SI\136o\DC2I]\189bfy\DEL9L\131\199/\169{g\180"]}), _cleanSession = True, _keepAlive = 18071, -// _connID = "\150\237n\166\229\ETBi;m\233\SYN,\137\212\196\218", _properties = [PropSessionExpiryInterval -// 24708,PropSharedSubscriptionAvailable 250,PropSharedSubscriptionAvailable 94,PropWillDelayInterval -// 2639,PropServerReference -// "l\130\ACK\250\EM\186\NUL_\184\226\r\139\134\224\229\149\155\137\207x\132\175\224\&7q\SO\254\t\140",PropMaximumQoS -// 156,PropSessionExpiryInterval 14655,PropWillDelayInterval 11878,PropTopicAliasMaximum 16102,PropContentType -// "\193\STX9\155\155t6\235\154U\132!",PropWildcardSubscriptionAvailable 200,PropContentType -// "\200\v\b\224*\ETB\193\232\\\168G\129\233\238\129\246\171#x\204x",PropRetainAvailable 204,PropMaximumPacketSize -// 29406,PropRequestResponseInformation 23,PropReceiveMaximum 13674,PropContentType -// "\204z\250\GS\191\179\133\254V\f.\137\159LK\170h\163\SYN",PropSharedSubscriptionAvailable -// 188,PropAssignedClientIdentifier -// "\135=\NAKf\239\205\152\238$\149\SOHF8\137\141\194\255/7\209\EOT\251\STX%\201O\218",PropReasonString -// "\130\SOH\STX\162:H\145\174]\200\196\220A",PropRequestProblemInformation 47,PropReceiveMaximum -// 23351,PropSharedSubscriptionAvailable 124,PropMaximumQoS 69,PropCorrelationData "g",PropServerKeepAlive -// 20731,PropWillDelayInterval 14078,PropRequestResponseInformation 112]} +// ConnectRequest {_username = Just "\240\ETX\187\240'\219\214:\CANw", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\137\169\150c", _willMsg = "\189", _willProps = +// [PropResponseTopic "k5\207N\181\192WU,\SIe4\172\254\210\EM\ae\176\DLE-",PropAssignedClientIdentifier +// "\nJ\166j\194\158\239?Y\148\224\159\141\173\241\ESC\191If\142\DC1\201\230\199\&0\253\243\&02",PropAuthenticationMethod +// "w\DC2\255\210\133\191\202\215\248T\185\164\135\ENQ_\185aJ",PropAuthenticationData +// "\v)O\232P$\206Kf\ETX;\182\&3C\198\188\243f\183",PropMessageExpiryInterval 28426,PropSharedSubscriptionAvailable +// 168,PropCorrelationData "?\138\202\t\190\143x\n\f@\196",PropResponseTopic +// "\247e\243Z\193\202\&4F\SUB\b0\172\&7\252\167\243r\DEL\190!aQ\143?U",PropResponseInformation +// "\188\219\163[f\EM\137I)\RS\DLE",PropTopicAlias 12835]}), _cleanSession = False, _keepAlive = 19444, _connID = +// "\151\173\128\254\189>\225\168\184@\169\179", _properties = [PropMessageExpiryInterval 2574,PropContentType +// "\ETX\180^0\174\203\175h2\t\204\145\238\183\SI\144JP\142",PropSubscriptionIdentifier +// 30,PropSharedSubscriptionAvailable 232,PropContentType +// "-\233XZ\212\234\161R\165!MD\158\231\\\199\&0\232\138",PropAssignedClientIdentifier "s",PropMaximumQoS +// 151,PropAssignedClientIdentifier "q\162j\243\168Rj\EM +// _\246\203\221;\149\192\232y\RS\DLE\214\246\129\143\EM|a",PropWildcardSubscriptionAvailable 108,PropWillDelayInterval +// 1033,PropMessageExpiryInterval 24445,PropTopicAlias 23778,PropSessionExpiryInterval 16092,PropMaximumPacketSize +// 1282,PropServerKeepAlive 12039]} TEST(Connect5QCTest, Encode10) { uint8_t pkt[] = { - 0x10, 0xa7, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x46, 0x97, 0xcf, 0x1, 0x11, 0x0, 0x0, 0x60, - 0x84, 0x2a, 0xfa, 0x2a, 0x5e, 0x18, 0x0, 0x0, 0xa, 0x4f, 0x1c, 0x0, 0x1d, 0x6c, 0x82, 0x6, 0xfa, 0x19, 0xba, - 0x0, 0x5f, 0xb8, 0xe2, 0xd, 0x8b, 0x86, 0xe0, 0xe5, 0x95, 0x9b, 0x89, 0xcf, 0x78, 0x84, 0xaf, 0xe0, 0x37, 0x71, - 0xe, 0xfe, 0x9, 0x8c, 0x24, 0x9c, 0x11, 0x0, 0x0, 0x39, 0x3f, 0x18, 0x0, 0x0, 0x2e, 0x66, 0x22, 0x3e, 0xe6, - 0x3, 0x0, 0xc, 0xc1, 0x2, 0x39, 0x9b, 0x9b, 0x74, 0x36, 0xeb, 0x9a, 0x55, 0x84, 0x21, 0x28, 0xc8, 0x3, 0x0, - 0x15, 0xc8, 0xb, 0x8, 0xe0, 0x2a, 0x17, 0xc1, 0xe8, 0x5c, 0xa8, 0x47, 0x81, 0xe9, 0xee, 0x81, 0xf6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19, + 0x89, 0x49, 0x29, 0x1e, 0x10, 0x23, 0x32, 0x23, 0x0, 0x4, 0x89, 0xa9, 0x96, 0x63, 0x0, 0x1, 0xbd, 0x0, 0xa, + 0xf0, 0x3, 0xbb, 0xf0, 0x27, 0xdb, 0xd6, 0x3a, 0x18, 0x77}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x6c, 0x82, 0x6, 0xfa, 0x19, 0xba, 0x0, 0x5f, 0xb8, 0xe2, 0xd, 0x8b, 0x86, 0xe0, 0xe5, - 0x95, 0x9b, 0x89, 0xcf, 0x78, 0x84, 0xaf, 0xe0, 0x37, 0x71, 0xe, 0xfe, 0x9, 0x8c}; - uint8_t bytesprops1[] = {0xc1, 0x2, 0x39, 0x9b, 0x9b, 0x74, 0x36, 0xeb, 0x9a, 0x55, 0x84, 0x21}; - uint8_t bytesprops2[] = {0xc8, 0xb, 0x8, 0xe0, 0x2a, 0x17, 0xc1, 0xe8, 0x5c, 0xa8, 0x47, - 0x81, 0xe9, 0xee, 0x81, 0xf6, 0xab, 0x23, 0x78, 0xcc, 0x78}; - uint8_t bytesprops3[] = {0xcc, 0x7a, 0xfa, 0x1d, 0xbf, 0xb3, 0x85, 0xfe, 0x56, 0xc, - 0x2e, 0x89, 0x9f, 0x4c, 0x4b, 0xaa, 0x68, 0xa3, 0x16}; - uint8_t bytesprops4[] = {0x87, 0x3d, 0x15, 0x66, 0xef, 0xcd, 0x98, 0xee, 0x24, 0x95, 0x1, 0x46, 0x38, 0x89, - 0x8d, 0xc2, 0xff, 0x2f, 0x37, 0xd1, 0x4, 0xfb, 0x2, 0x25, 0xc9, 0x4f, 0xda}; - uint8_t bytesprops5[] = {0x82, 0x1, 0x2, 0xa2, 0x3a, 0x48, 0x91, 0xae, 0x5d, 0xc8, 0xc4, 0xdc, 0x41}; - uint8_t bytesprops6[] = {0x67}; + uint8_t bytesprops0[] = {0x3, 0xb4, 0x5e, 0x30, 0xae, 0xcb, 0xaf, 0x68, 0x32, 0x9, + 0xcc, 0x91, 0xee, 0xb7, 0xf, 0x90, 0x4a, 0x50, 0x8e}; + uint8_t bytesprops1[] = {0x2d, 0xe9, 0x58, 0x5a, 0xd4, 0xea, 0xa1, 0x52, 0xa5, 0x21, + 0x4d, 0x44, 0x9e, 0xe7, 0x5c, 0xc7, 0x30, 0xe8, 0x8a}; + uint8_t bytesprops2[] = {0x73}; + uint8_t bytesprops3[] = {0x71, 0xa2, 0x6a, 0xf3, 0xa8, 0x52, 0x6a, 0x19, 0x20, 0x5f, 0xf6, 0xcb, 0xdd, 0x3b, + 0x95, 0xc0, 0xe8, 0x79, 0x1e, 0x10, 0xd6, 0xf6, 0x81, 0x8f, 0x19, 0x7c, 0x61}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24708}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2639}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14655}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11878}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16102}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29406}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13674}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23351}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20731}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14078}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2574}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1033}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24445}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23778}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16092}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1282}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12039}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd4, 0xb8, 0x8d, 0x5c, 0x8f, 0x25, 0x57, 0xbe, 0x7c, 0x98, - 0x13, 0xc1, 0x45, 0xa, 0x9, 0xed, 0x9f, 0xb8, 0x3f, 0xc2, - 0x81, 0x7c, 0x83, 0xe7, 0xab, 0x47, 0xe6, 0x30, 0x21, 0xbc}; - uint8_t byteswillprops1[] = {0xc1, 0xeb, 0x2c, 0x95, 0x37, 0xd4, 0x58}; - uint8_t byteswillprops2[] = {0xce, 0xfe, 0x57, 0x7a, 0x17, 0xae, 0x29, 0xb3, 0x23, 0x17, 0x9f, 0x57, 0xae}; - uint8_t byteswillprops3[] = {0x25, 0x15, 0x48, 0x19, 0x26, 0xa6, 0xd0, 0xc0, 0x19, 0xe2, 0x85, - 0xdf, 0x5, 0x36, 0x1c, 0x8a, 0x9c, 0x64, 0x7d, 0x91, 0x47, 0x76}; - uint8_t byteswillprops4[] = {0xa2, 0x97, 0x1a, 0x4e, 0xea, 0x1a, 0xe2, 0x33, 0x16, 0x38, 0x98, 0x9c, 0x2a, 0xf9, 0x89, - 0x6b, 0x36, 0xaf, 0xfa, 0x78, 0x9e, 0x87, 0x21, 0xd0, 0x2, 0x2b, 0xc2, 0x7, 0xf6}; - uint8_t byteswillprops5[] = {0xb5, 0x68, 0x26, 0x76, 0xb7, 0x5b, 0xbd, 0x2, 0x5d, 0x50, 0x32, 0xb6, 0x16, 0x4f, - 0xb3, 0xc, 0xf5, 0xe2, 0xa6, 0xbd, 0xec, 0xf7, 0x6f, 0xfa, 0x5d, 0xc1, 0x4d, 0xe5}; - uint8_t byteswillprops6[] = {0xf7, 0x56, 0x94, 0x9f, 0xdf, 0x60, 0x7, 0xf4, 0xd9, 0x62, 0x17, 0x3a, 0xd9}; - uint8_t byteswillprops7[] = {0x68, 0xf1, 0xfc, 0x50, 0x33, 0x88, 0xa, 0x9, 0x67, 0x36, - 0xf, 0x88, 0x6f, 0x12, 0x49, 0x5d, 0xbd, 0x62, 0x66, 0x79, - 0x7f, 0x39, 0x4c, 0x83, 0xc7, 0x2f, 0xa9, 0x7b, 0x67, 0xb4}; + uint8_t byteswillprops0[] = {0x6b, 0x35, 0xcf, 0x4e, 0xb5, 0xc0, 0x57, 0x55, 0x2c, 0xf, 0x65, + 0x34, 0xac, 0xfe, 0xd2, 0x19, 0x7, 0x65, 0xb0, 0x10, 0x2d}; + uint8_t byteswillprops1[] = {0xa, 0x4a, 0xa6, 0x6a, 0xc2, 0x9e, 0xef, 0x3f, 0x59, 0x94, 0xe0, 0x9f, 0x8d, 0xad, 0xf1, + 0x1b, 0xbf, 0x49, 0x66, 0x8e, 0x11, 0xc9, 0xe6, 0xc7, 0x30, 0xfd, 0xf3, 0x30, 0x32}; + uint8_t byteswillprops2[] = {0x77, 0x12, 0xff, 0xd2, 0x85, 0xbf, 0xca, 0xd7, 0xf8, + 0x54, 0xb9, 0xa4, 0x87, 0x5, 0x5f, 0xb9, 0x61, 0x4a}; + uint8_t byteswillprops3[] = {0xb, 0x29, 0x4f, 0xe8, 0x50, 0x24, 0xce, 0x4b, 0x66, 0x3, + 0x3b, 0xb6, 0x33, 0x43, 0xc6, 0xbc, 0xf3, 0x66, 0xb7}; + uint8_t byteswillprops4[] = {0x3f, 0x8a, 0xca, 0x9, 0xbe, 0x8f, 0x78, 0xa, 0xc, 0x40, 0xc4}; + uint8_t byteswillprops5[] = {0xf7, 0x65, 0xf3, 0x5a, 0xc1, 0xca, 0x34, 0x46, 0x1a, 0x8, 0x30, 0xac, 0x37, + 0xfc, 0xa7, 0xf3, 0x72, 0x7f, 0xbe, 0x21, 0x61, 0x51, 0x8f, 0x3f, 0x55}; + uint8_t byteswillprops6[] = {0xbc, 0xdb, 0xa3, 0x5b, 0x66, 0x19, 0x89, 0x49, 0x29, 0x1e, 0x10}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30066}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2047}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25577}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28426}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12835}}, }; - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa0, 0x54, 0x58, 0x86, 0xb0, 0x1f, 0x61, 0xa7, 0xd1, 0x5b, 0x92, 0x30}; - lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x82, 0x80, 0x62, 0x11, 0x55, 0xb2, 0xc6, 0x4a, 0x3a, 0x22, 0x9a, 0x39, 0xae, - 0x90, 0x37, 0x39, 0xde, 0x7f, 0xd4, 0xcc, 0x27, 0x5, 0xe3, 0x8b, 0x37, 0x84}; - lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x89, 0xa9, 0x96, 0x63}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xbd}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -7864,19 +7609,14 @@ TEST(Connect5QCTest, Encode10) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 18071; - uint8_t client_id_bytes[] = {0x96, 0xed, 0x6e, 0xa6, 0xe5, 0x17, 0x69, 0x3b, - 0x6d, 0xe9, 0x16, 0x2c, 0x89, 0xd4, 0xc4, 0xda}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 19444; + uint8_t client_id_bytes[] = {0x97, 0xad, 0x80, 0xfe, 0xbd, 0x3e, 0xe1, 0xa8, 0xb8, 0x40, 0xa9, 0xb3}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xcc, 0x12, 0x42, 0x77, 0x9e, 0x47, 0xe8, 0x7b, 0xcc, 0xee, 0x4e, 0xda, 0x39, 0xc, 0x96}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf0, 0x3, 0xbb, 0xf0, 0x27, 0xdb, 0xd6, 0x3a, 0x18, 0x77}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x2f, 0x4d, 0x45, 0xdd, 0x2f, 0xe0, 0x4c, 0xcb, 0xd8, 0x96, 0x9, 0x3d, 0xc3, 0x61, - 0xa9, 0xc5, 0x50, 0x5b, 0xfb, 0x89, 0x13, 0xdb, 0x98, 0xfd, 0x5, 0x4c, 0x99, 0xef}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7885,112 +7625,156 @@ TEST(Connect5QCTest, Encode10) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\170\169T\181z[8\SOH\237A\171\211\161", _password = Just "\216/I\167", _lastWill = -// Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "i\\\223d\254\201\208#u\SUB\184\178\254^g", -// _willMsg = "\130\b\SOHn\241D<\208", _willProps = [PropAssignedClientIdentifier -// "\241\&2\DC4\187*\232\&5Jf\133y.\245T\255\&7+\140z0\DC2-\DLEe\190\243\213P\236",PropServerKeepAlive -// 17912,PropAuthenticationData "\159\233G\221",PropMessageExpiryInterval 10456,PropWillDelayInterval -// 6209,PropContentType "\198\147Xgv",PropServerKeepAlive 29007,PropAuthenticationData "\NAK\167v\SYN"]}), _cleanSession -// = False, _keepAlive = 20715, _connID = "\238Vc]\r\147\142\177>\228\133\&4\185\GS", _properties = -// [PropMessageExpiryInterval 1066,PropTopicAlias 16219,PropSubscriptionIdentifierAvailable -// 142,PropWildcardSubscriptionAvailable 211,PropRequestResponseInformation 233,PropRequestResponseInformation -// 2,PropRetainAvailable 154,PropTopicAlias 15714,PropPayloadFormatIndicator 42,PropWildcardSubscriptionAvailable -// 140,PropCorrelationData -// "m\198\ESC\222m7Ju\192J,\255\DLE\ACKW\247a\179%Q\214\227\212h\ETB\231",PropRequestResponseInformation -// 57,PropPayloadFormatIndicator 117,PropMaximumQoS 212,PropUserProperty -// "-\176\r\DEL\230}cU\\\163\243\STX`\v\250\&3\EM\f#j?\202<\141O\217\129\EM\186a" -// "qn\154f\136\r8\171\DC1\246",PropMessageExpiryInterval 1610,PropUserProperty -// "\SYN-\142J\224\SI,6\175\189\GS80\133M\t;&\211\203\170\147" "\179\189\192S\205\150\203<\129\ENQ\175"]} +// ConnectRequest {_username = Just "\167 \167\208\233f\167\246'\240T\252\&3!", _password = Just +// "\204ptBG\160\v\SUB\223!\EM\SI\STX\b\DEL+1Z", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, +// _willTopic = "\186To9\139\230@\227W\SUB\173\175\253\165\SI\195\133i\DC4\ESC\229\DC2=z\251\186\231", _willMsg = +// "rXO\rA\ESC\fQ\DC2\152\SO\ETB{\248\203\197%\175\203\235\227", _willProps = [PropWillDelayInterval +// 4229,PropCorrelationData ":",PropMessageExpiryInterval 31827,PropMessageExpiryInterval 29078,PropServerKeepAlive +// 16436,PropSubscriptionIdentifier 11,PropSubscriptionIdentifier 16,PropAuthenticationData +// "\DC2\v|\254{\179\DC2k\151o)\RS\DC3\SO\129\201\v\131X\246\141\225>\149\&2-9\249\250\162",PropSessionExpiryInterval +// 14463,PropCorrelationData +// "WH\EOTJ\167\aX\t\179\&7;\180\154\&6\153\171FO\DC2\236\173\139S\232",PropResponseInformation +// "\DC3\143;\129\163\239:\240R\248\188\179\129\t\139\&9m'\134#\250\150\166",PropAssignedClientIdentifier +// "F\152u\153_\155",PropMaximumPacketSize 7776,PropSharedSubscriptionAvailable 253,PropReasonString +// "\232\253\177s\247m\178\237\231\222\221",PropResponseInformation +// "\210\175\215\nM\134\211\218Jp\226R\EOT\US\232j\b\212\239\NAKA\253J\DLE\t\187\253\229\236",PropReceiveMaximum +// 9466,PropSubscriptionIdentifierAvailable 89,PropSubscriptionIdentifier 15,PropAuthenticationMethod "\140Dp\rR\250 +// \146\SO\158\149",PropAuthenticationData +// "p\163]\225!_\181WU!\231\238?\193r\169\138\165\155U\DC28\146\161\250\194\166",PropSessionExpiryInterval +// 5750,PropMessageExpiryInterval 28985,PropRetainAvailable 244]}), _cleanSession = False, _keepAlive = 21475, _connID = +// "\130", _properties = [PropReceiveMaximum 4893,PropAuthenticationMethod "",PropAuthenticationMethod +// "]\174\253\GS\146\NAK\236\245\227h\216\DC2g\241\174\212\253;",PropReceiveMaximum 1689,PropWillDelayInterval +// 27418,PropRequestProblemInformation 197,PropSubscriptionIdentifier 21,PropRequestProblemInformation 68,PropTopicAlias +// 16330,PropPayloadFormatIndicator 38,PropTopicAlias 22185,PropServerReference +// "p\255L\244A\193P\SYNh\143\200\168",PropSubscriptionIdentifierAvailable 184,PropMaximumPacketSize +// 25634,PropCorrelationData "\184U\173\203\ESCMtAA\229\184\223\203\222\190\137\195\&3\235",PropSessionExpiryInterval +// 338,PropSubscriptionIdentifierAvailable 21,PropAuthenticationMethod "\135$\145\153\SUB1\223\NUL\DC3\f\245"]} TEST(Connect5QCTest, Encode11) { uint8_t pkt[] = { - 0x10, 0xa7, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x50, 0xeb, 0x94, 0x1, 0x2, 0x0, 0x0, 0x4, - 0x2a, 0x23, 0x3f, 0x5b, 0x29, 0x8e, 0x28, 0xd3, 0x19, 0xe9, 0x19, 0x2, 0x25, 0x9a, 0x23, 0x3d, 0x62, 0x1, 0x2a, - 0x28, 0x8c, 0x9, 0x0, 0x1a, 0x6d, 0xc6, 0x1b, 0xde, 0x6d, 0x37, 0x4a, 0x75, 0xc0, 0x4a, 0x2c, 0xff, 0x10, 0x6, - 0x57, 0xf7, 0x61, 0xb3, 0x25, 0x51, 0xd6, 0xe3, 0xd4, 0x68, 0x17, 0xe7, 0x19, 0x39, 0x1, 0x75, 0x24, 0xd4, 0x26, - 0x0, 0x1e, 0x2d, 0xb0, 0xd, 0x7f, 0xe6, 0x7d, 0x63, 0x55, 0x5c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0xa5, 0x9b, 0x55, 0x12, 0x38, 0x92, 0xa1, 0xfa, + 0xc2, 0xa6, 0x11, 0x0, 0x0, 0x16, 0x76, 0x2, 0x0, 0x0, 0x71, 0x39, 0x25, 0xf4, 0x0, 0x1b, 0xba, 0x54, 0x6f, + 0x39, 0x8b, 0xe6, 0x40, 0xe3, 0x57, 0x1a, 0xad, 0xaf, 0xfd, 0xa5, 0xf, 0xc3, 0x85, 0x69, 0x14, 0x1b, 0xe5, 0x12, + 0x3d, 0x7a, 0xfb, 0xba, 0xe7, 0x0, 0x15, 0x72, 0x58, 0x4f, 0xd, 0x41, 0x1b, 0xc, 0x51, 0x12, 0x98, 0xe, 0x17, + 0x7b, 0xf8, 0xcb, 0xc5, 0x25, 0xaf, 0xcb, 0xeb, 0xe3, 0x0, 0xe, 0xa7, 0x20, 0xa7, 0xd0, 0xe9, 0x66, 0xa7, 0xf6, + 0x27, 0xf0, 0x54, 0xfc, 0x33, 0x21, 0x0, 0x12, 0xcc, 0x70, 0x74, 0x42, 0x47, 0xa0, 0xb, 0x1a, 0xdf, 0x21, 0x19, + 0xf, 0x2, 0x8, 0x7f, 0x2b, 0x31, 0x5a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x6d, 0xc6, 0x1b, 0xde, 0x6d, 0x37, 0x4a, 0x75, 0xc0, 0x4a, 0x2c, 0xff, 0x10, - 0x6, 0x57, 0xf7, 0x61, 0xb3, 0x25, 0x51, 0xd6, 0xe3, 0xd4, 0x68, 0x17, 0xe7}; - uint8_t bytesprops2[] = {0x71, 0x6e, 0x9a, 0x66, 0x88, 0xd, 0x38, 0xab, 0x11, 0xf6}; - uint8_t bytesprops1[] = {0x2d, 0xb0, 0xd, 0x7f, 0xe6, 0x7d, 0x63, 0x55, 0x5c, 0xa3, 0xf3, 0x2, 0x60, 0xb, 0xfa, - 0x33, 0x19, 0xc, 0x23, 0x6a, 0x3f, 0xca, 0x3c, 0x8d, 0x4f, 0xd9, 0x81, 0x19, 0xba, 0x61}; - uint8_t bytesprops4[] = {0xb3, 0xbd, 0xc0, 0x53, 0xcd, 0x96, 0xcb, 0x3c, 0x81, 0x5, 0xaf}; - uint8_t bytesprops3[] = {0x16, 0x2d, 0x8e, 0x4a, 0xe0, 0xf, 0x2c, 0x36, 0xaf, 0xbd, 0x1d, - 0x38, 0x30, 0x85, 0x4d, 0x9, 0x3b, 0x26, 0xd3, 0xcb, 0xaa, 0x93}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x5d, 0xae, 0xfd, 0x1d, 0x92, 0x15, 0xec, 0xf5, 0xe3, + 0x68, 0xd8, 0x12, 0x67, 0xf1, 0xae, 0xd4, 0xfd, 0x3b}; + uint8_t bytesprops2[] = {0x70, 0xff, 0x4c, 0xf4, 0x41, 0xc1, 0x50, 0x16, 0x68, 0x8f, 0xc8, 0xa8}; + uint8_t bytesprops3[] = {0xb8, 0x55, 0xad, 0xcb, 0x1b, 0x4d, 0x74, 0x41, 0x41, 0xe5, + 0xb8, 0xdf, 0xcb, 0xde, 0xbe, 0x89, 0xc3, 0x33, 0xeb}; + uint8_t bytesprops4[] = {0x87, 0x24, 0x91, 0x99, 0x1a, 0x31, 0xdf, 0x0, 0x13, 0xc, 0xf5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1066}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16219}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15714}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops1}, .v = {10, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1610}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops3}, .v = {11, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4893}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1689}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27418}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16330}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22185}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25634}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 338}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xf1, 0x32, 0x14, 0xbb, 0x2a, 0xe8, 0x35, 0x4a, 0x66, 0x85, 0x79, 0x2e, 0xf5, 0x54, 0xff, - 0x37, 0x2b, 0x8c, 0x7a, 0x30, 0x12, 0x2d, 0x10, 0x65, 0xbe, 0xf3, 0xd5, 0x50, 0xec}; - uint8_t byteswillprops1[] = {0x9f, 0xe9, 0x47, 0xdd}; - uint8_t byteswillprops2[] = {0xc6, 0x93, 0x58, 0x67, 0x76}; - uint8_t byteswillprops3[] = {0x15, 0xa7, 0x76, 0x16}; + uint8_t byteswillprops0[] = {0x3a}; + uint8_t byteswillprops1[] = {0x12, 0xb, 0x7c, 0xfe, 0x7b, 0xb3, 0x12, 0x6b, 0x97, 0x6f, 0x29, 0x1e, 0x13, 0xe, 0x81, + 0xc9, 0xb, 0x83, 0x58, 0xf6, 0x8d, 0xe1, 0x3e, 0x95, 0x32, 0x2d, 0x39, 0xf9, 0xfa, 0xa2}; + uint8_t byteswillprops2[] = {0x57, 0x48, 0x4, 0x4a, 0xa7, 0x7, 0x58, 0x9, 0xb3, 0x37, 0x3b, 0xb4, + 0x9a, 0x36, 0x99, 0xab, 0x46, 0x4f, 0x12, 0xec, 0xad, 0x8b, 0x53, 0xe8}; + uint8_t byteswillprops3[] = {0x13, 0x8f, 0x3b, 0x81, 0xa3, 0xef, 0x3a, 0xf0, 0x52, 0xf8, 0xbc, 0xb3, + 0x81, 0x9, 0x8b, 0x39, 0x6d, 0x27, 0x86, 0x23, 0xfa, 0x96, 0xa6}; + uint8_t byteswillprops4[] = {0x46, 0x98, 0x75, 0x99, 0x5f, 0x9b}; + uint8_t byteswillprops5[] = {0xe8, 0xfd, 0xb1, 0x73, 0xf7, 0x6d, 0xb2, 0xed, 0xe7, 0xde, 0xdd}; + uint8_t byteswillprops6[] = {0xd2, 0xaf, 0xd7, 0xa, 0x4d, 0x86, 0xd3, 0xda, 0x4a, 0x70, 0xe2, 0x52, 0x4, 0x1f, 0xe8, + 0x6a, 0x8, 0xd4, 0xef, 0x15, 0x41, 0xfd, 0x4a, 0x10, 0x9, 0xbb, 0xfd, 0xe5, 0xec}; + uint8_t byteswillprops7[] = {0x8c, 0x44, 0x70, 0xd, 0x52, 0xfa, 0x20, 0x92, 0xe, 0x9e, 0x95}; + uint8_t byteswillprops8[] = {0x70, 0xa3, 0x5d, 0xe1, 0x21, 0x5f, 0xb5, 0x57, 0x55, 0x21, 0xe7, 0xee, 0x3f, 0xc1, + 0x72, 0xa9, 0x8a, 0xa5, 0x9b, 0x55, 0x12, 0x38, 0x92, 0xa1, 0xfa, 0xc2, 0xa6}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17912}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10456}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6209}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29007}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4229}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31827}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29078}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16436}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14463}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7776}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9466}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5750}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28985}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 244}}, }; - lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x69, 0x5c, 0xdf, 0x64, 0xfe, 0xc9, 0xd0, 0x23, - 0x75, 0x1a, 0xb8, 0xb2, 0xfe, 0x5e, 0x67}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x82, 0x8, 0x1, 0x6e, 0xf1, 0x44, 0x3c, 0xd0}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xba, 0x54, 0x6f, 0x39, 0x8b, 0xe6, 0x40, 0xe3, 0x57, 0x1a, 0xad, 0xaf, 0xfd, 0xa5, + 0xf, 0xc3, 0x85, 0x69, 0x14, 0x1b, 0xe5, 0x12, 0x3d, 0x7a, 0xfb, 0xba, 0xe7}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x72, 0x58, 0x4f, 0xd, 0x41, 0x1b, 0xc, 0x51, 0x12, 0x98, 0xe, + 0x17, 0x7b, 0xf8, 0xcb, 0xc5, 0x25, 0xaf, 0xcb, 0xeb, 0xe3}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 20715; - uint8_t client_id_bytes[] = {0xee, 0x56, 0x63, 0x5d, 0xd, 0x93, 0x8e, 0xb1, 0x3e, 0xe4, 0x85, 0x34, 0xb9, 0x1d}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.keep_alive = 21475; + uint8_t client_id_bytes[] = {0x82}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xaa, 0xa9, 0x54, 0xb5, 0x7a, 0x5b, 0x38, 0x1, 0xed, 0x41, 0xab, 0xd3, 0xa1}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa7, 0x20, 0xa7, 0xd0, 0xe9, 0x66, 0xa7, 0xf6, 0x27, 0xf0, 0x54, 0xfc, 0x33, 0x21}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xd8, 0x2f, 0x49, 0xa7}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xcc, 0x70, 0x74, 0x42, 0x47, 0xa0, 0xb, 0x1a, 0xdf, + 0x21, 0x19, 0xf, 0x2, 0x8, 0x7f, 0x2b, 0x31, 0x5a}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8000,182 +7784,137 @@ TEST(Connect5QCTest, Encode11) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "\128", _willMsg = "G\244\250\238\173\220\204", _willProps = [PropServerKeepAlive -// 30225,PropRetainAvailable 120,PropUserProperty "r|M\rx\197\nG\t\147\215}\158\176\233\132C\164\ENQx`!Q" -// "\226}Z{\168|OL\GS\155)\229Q\166",PropAssignedClientIdentifier "\\\245\RSS\198\DLEY`\EM\210%\186 -// \239\193\186SR\216d#\SOx\239``",PropServerReference "\RS\172\142",PropSharedSubscriptionAvailable -// 237,PropResponseInformation "\155\241P\172-\174\142\RSx\139G3\180\250\&5\255!\NUL\173\n\144",PropRetainAvailable -// 199,PropSubscriptionIdentifier 19,PropAuthenticationData -// "_!i\159]\238\\\SI\128\194\198\230i\138",PropAuthenticationMethod -// "I\159l\214\226\158\245R\140\213\199\156cO\183\SO\249Qgk`\n\200\FSM\t",PropTopicAlias 15985,PropAuthenticationData -// "\228\150\233\227",PropTopicAlias 6436,PropRequestProblemInformation 224,PropAuthenticationMethod -// "((\182Wo\245t<\DC2\227\184\160\200\157\&6\148",PropSubscriptionIdentifierAvailable 75,PropRequestResponseInformation -// 45]}), _cleanSession = True, _keepAlive = 28847, _connID = "IP", _properties = [PropWildcardSubscriptionAvailable -// 111,PropReceiveMaximum 14339,PropResponseTopic "\148\162\143\176\245\194",PropContentType -// "\223\212FBW&\184s\206\183\&7",PropAuthenticationMethod -// "\146\204Op\161\&3]+\182\148e\211\172\159^\141`>\243\189\251w.\DC4\233\164$\167\236",PropSharedSubscriptionAvailable -// 181,PropContentType "\168a\130\"\205\208S\218 /F9\255r\185\ETX",PropMessageExpiryInterval 6731,PropWillDelayInterval -// 22863,PropRequestProblemInformation 161,PropAuthenticationMethod "\179\205g\128H\128a\137jb\SYNe\n",PropContentType -// "\170\DC3S\DC41S\191;\vYw\154\176!H\b\148\161~\ETXs\180%\DC2\183",PropAuthenticationData -// "\155\203",PropSessionExpiryInterval 5522,PropResponseInformation -// "\195\202\180\227\178p#\183\178_j\236\US\EM\DC1\165\160",PropSubscriptionIdentifier 2,PropUserProperty -// "\151\199@N\145h\195>\196\211\200X\212\178!\ESC\179" -// "\132\170\182\138\243\152\SUB\223\129\158\181\174\ETX",PropUserProperty "#[\GS/w\138\130\238\DLE\223;(2\152E\128" -// "!\v\133\SOt\139b\136\SO\211uc\147\ACK\DC3\144\169I\159\SOH9#\153\154^\156\168V`\130",PropTopicAliasMaximum -// 13969,PropSharedSubscriptionAvailable 151,PropResponseTopic -// "\184I4u\219D|N1\SUB/\DC1\238N,$\222\ENQ\229\235\140\&4\166",PropWildcardSubscriptionAvailable 27,PropUserProperty -// "\202\207\143\FSW\"\150Z \150/\234\&7\USI\172o\196\NAKr%\216\ESC\254\175\220\&8\135\FS" -// "\226\177\f\b\141x\188\154\205\224g)\173y\170EiU\186[\150=\RS\233&",PropContentType -// "\239J\250$L\169\196\170\196-`H\217\134\227t\fq\NUL\249\178CZY\255\130"]} +// ConnectRequest {_username = Nothing, _password = Just "4\244\&1\217\142\&8\NAK5", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "e;\194\&7\237P\201 w\216\149l\171W\RS\241>\135`\SYN\ENQ\197\t", +// _willMsg = "2\174", _willProps = [PropResponseTopic +// "\142\216\206=\187\ETB?OH\195r\237\129\133f\190\219\150\200\142\rK\138",PropSubscriptionIdentifier +// 6,PropAssignedClientIdentifier "\161\USlM\STXUg",PropWillDelayInterval 6334,PropWildcardSubscriptionAvailable +// 70,PropWildcardSubscriptionAvailable 240,PropServerReference +// "\194wP\163\231\SO+\217\&92\136w&\214\STX*\NUL\ENQ3\GS\DC1",PropResponseInformation +// "\200V%\185",PropSubscriptionIdentifierAvailable 99,PropContentType +// "\n\175\138Sa\198o;r-",PropWildcardSubscriptionAvailable 150,PropReasonString "\220S\139Qd",PropTopicAlias +// 14266,PropAssignedClientIdentifier "D|%\142M?\148eEE\155\182",PropMessageExpiryInterval +// 2407,PropRequestProblemInformation 31,PropTopicAlias 15204,PropMessageExpiryInterval 7923,PropUserProperty +// "8h\199\190hz\234\230\235N\148\197a\246\225P\251\ETXd^iG\188\184\136\131" +// "\146\222\ENQ\v\SO\211i]2\FS\SYN\220\244\200\231\179\FS\\\150\196\188\149\155",PropMaximumQoS +// 134,PropPayloadFormatIndicator 8,PropReasonString "M(\249"]}), _cleanSession = True, _keepAlive = 29263, _connID = +// "\173Q\DC4\163\185\129\144\238\155\169Q\252K\131\227\&9\CAN\v\239", _properties = [PropTopicAlias +// 25630,PropSubscriptionIdentifier 6,PropSharedSubscriptionAvailable 158,PropResponseTopic +// "{G\NAK&0YDEtI",PropServerKeepAlive 11245,PropResponseInformation +// "\190d\136\&1\171D+.C\177\ACK\SI\167\145\135",PropSessionExpiryInterval 15509,PropRetainAvailable +// 18,PropServerKeepAlive 5583,PropContentType "+?\144\188^\165\&73\RSe\249\246\RSOa\177\128o",PropMaximumQoS +// 152,PropCorrelationData "@'\253[z\129K\139N\241\t\148\198TD\247\&0\193\DC1v\FSoud",PropPayloadFormatIndicator 23]} TEST(Connect5QCTest, Encode12) { uint8_t pkt[] = { - 0x10, 0xda, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0x70, 0xaf, 0xf8, 0x2, 0x28, 0x6f, 0x21, 0x38, - 0x3, 0x8, 0x0, 0x6, 0x94, 0xa2, 0x8f, 0xb0, 0xf5, 0xc2, 0x3, 0x0, 0xb, 0xdf, 0xd4, 0x46, 0x42, 0x57, 0x26, - 0xb8, 0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77, 0x8a, - 0x82, 0xee, 0x10, 0xdf, 0x3b, 0x28, 0x32, 0x98, 0x45, 0x80, 0x0, 0x1e, 0x21, 0xb, 0x85, 0xe, 0x74, 0x8b, 0x62, - 0x88, 0xe, 0xd3, 0x75, 0x63, 0x93, 0x6, 0x13, 0x90, 0xa9, 0x49, 0x9f, 0x1, 0x39, 0x23, 0x99, 0x9a, 0x5e, 0x9c, - 0xa8, 0x56, 0x60, 0x82, 0x22, 0x36, 0x91, 0x2a, 0x97, 0x8, 0x0, 0x17, 0xb8, 0x49, 0x34, 0x75, 0xdb, 0x44, 0x7c, - 0x4e, 0x31, 0x1a, 0x2f, 0x11, 0xee, 0x4e, 0x2c, 0x24, 0xde, 0x5, 0xe5, 0xeb, 0x8c, 0x34, 0xa6, 0x28, 0x1b, 0x26, - 0x0, 0x1d, 0xca, 0xcf, 0x8f, 0x1c, 0x57, 0x22, 0x96, 0x5a, 0x20, 0x96, 0x2f, 0xea, 0x37, 0x1f, 0x49, 0xac, 0x6f, - 0xc4, 0x15, 0x72, 0x25, 0xd8, 0x1b, 0xfe, 0xaf, 0xdc, 0x38, 0x87, 0x1c, 0x0, 0x19, 0xe2, 0xb1, 0xc, 0x8, 0x8d, - 0x78, 0xbc, 0x9a, 0xcd, 0xe0, 0x67, 0x29, 0xad, 0x79, 0xaa, 0x45, 0x69, 0x55, 0xba, 0x5b, 0x96, 0x3d, 0x1e, 0xe9, - 0x26, 0x3, 0x0, 0x1a, 0xef, 0x4a, 0xfa, 0x24, 0x4c, 0xa9, 0xc4, 0xaa, 0xc4, 0x2d, 0x60, 0x48, 0xd9, 0x86, 0xe3, - 0x74, 0xc, 0x71, 0x0, 0xf9, 0xb2, 0x43, 0x5a, 0x59, 0xff, 0x82, 0x0, 0x2, 0x49, 0x50, 0xc4, 0x1, 0x13, 0x76, - 0x11, 0x25, 0x78, 0x26, 0x0, 0x17, 0x72, 0x7c, 0x4d, 0xd, 0x78, 0xc5, 0xa, 0x47, 0x9, 0x93, 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31, 0xd9, 0x8e, 0x38, 0x15, 0x35}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x94, 0xa2, 0x8f, 0xb0, 0xf5, 0xc2}; - uint8_t bytesprops1[] = {0xdf, 0xd4, 0x46, 0x42, 0x57, 0x26, 0xb8, 0x73, 0xce, 0xb7, 0x37}; - uint8_t bytesprops2[] = {0x92, 0xcc, 0x4f, 0x70, 0xa1, 0x33, 0x5d, 0x2b, 0xb6, 0x94, 0x65, 0xd3, 0xac, 0x9f, 0x5e, - 0x8d, 0x60, 0x3e, 0xf3, 0xbd, 0xfb, 0x77, 0x2e, 0x14, 0xe9, 0xa4, 0x24, 0xa7, 0xec}; - uint8_t bytesprops3[] = {0xa8, 0x61, 0x82, 0x22, 0xcd, 0xd0, 0x53, 0xda, - 0x20, 0x2f, 0x46, 0x39, 0xff, 0x72, 0xb9, 0x3}; - uint8_t bytesprops4[] = {0xb3, 0xcd, 0x67, 0x80, 0x48, 0x80, 0x61, 0x89, 0x6a, 0x62, 0x16, 0x65, 0xa}; - uint8_t bytesprops5[] = {0xaa, 0x13, 0x53, 0x14, 0x31, 0x53, 0xbf, 0x3b, 0xb, 0x59, 0x77, 0x9a, 0xb0, - 0x21, 0x48, 0x8, 0x94, 0xa1, 0x7e, 0x3, 0x73, 0xb4, 0x25, 0x12, 0xb7}; - uint8_t bytesprops6[] = {0x9b, 0xcb}; - uint8_t bytesprops7[] = {0xc3, 0xca, 0xb4, 0xe3, 0xb2, 0x70, 0x23, 0xb7, 0xb2, - 0x5f, 0x6a, 0xec, 0x1f, 0x19, 0x11, 0xa5, 0xa0}; - uint8_t bytesprops9[] = {0x84, 0xaa, 0xb6, 0x8a, 0xf3, 0x98, 0x1a, 0xdf, 0x81, 0x9e, 0xb5, 0xae, 0x3}; - uint8_t bytesprops8[] = {0x97, 0xc7, 0x40, 0x4e, 0x91, 0x68, 0xc3, 0x3e, 0xc4, - 0xd3, 0xc8, 0x58, 0xd4, 0xb2, 0x21, 0x1b, 0xb3}; - uint8_t bytesprops11[] = {0x21, 0xb, 0x85, 0xe, 0x74, 0x8b, 0x62, 0x88, 0xe, 0xd3, 0x75, 0x63, 0x93, 0x6, 0x13, - 0x90, 0xa9, 0x49, 0x9f, 0x1, 0x39, 0x23, 0x99, 0x9a, 0x5e, 0x9c, 0xa8, 0x56, 0x60, 0x82}; - uint8_t bytesprops10[] = {0x23, 0x5b, 0x1d, 0x2f, 0x77, 0x8a, 0x82, 0xee, - 0x10, 0xdf, 0x3b, 0x28, 0x32, 0x98, 0x45, 0x80}; - uint8_t bytesprops12[] = {0xb8, 0x49, 0x34, 0x75, 0xdb, 0x44, 0x7c, 0x4e, 0x31, 0x1a, 0x2f, 0x11, - 0xee, 0x4e, 0x2c, 0x24, 0xde, 0x5, 0xe5, 0xeb, 0x8c, 0x34, 0xa6}; - uint8_t bytesprops14[] = {0xe2, 0xb1, 0xc, 0x8, 0x8d, 0x78, 0xbc, 0x9a, 0xcd, 0xe0, 0x67, 0x29, 0xad, - 0x79, 0xaa, 0x45, 0x69, 0x55, 0xba, 0x5b, 0x96, 0x3d, 0x1e, 0xe9, 0x26}; - uint8_t bytesprops13[] = {0xca, 0xcf, 0x8f, 0x1c, 0x57, 0x22, 0x96, 0x5a, 0x20, 0x96, 0x2f, 0xea, 0x37, 0x1f, 0x49, - 0xac, 0x6f, 0xc4, 0x15, 0x72, 0x25, 0xd8, 0x1b, 0xfe, 0xaf, 0xdc, 0x38, 0x87, 0x1c}; - uint8_t bytesprops15[] = {0xef, 0x4a, 0xfa, 0x24, 0x4c, 0xa9, 0xc4, 0xaa, 0xc4, 0x2d, 0x60, 0x48, 0xd9, - 0x86, 0xe3, 0x74, 0xc, 0x71, 0x0, 0xf9, 0xb2, 0x43, 0x5a, 0x59, 0xff, 0x82}; + uint8_t bytesprops0[] = {0x7b, 0x47, 0x15, 0x26, 0x30, 0x59, 0x44, 0x45, 0x74, 0x49}; + uint8_t bytesprops1[] = {0xbe, 0x64, 0x88, 0x31, 0xab, 0x44, 0x2b, 0x2e, 0x43, 0xb1, 0x6, 0xf, 0xa7, 0x91, 0x87}; + uint8_t bytesprops2[] = {0x2b, 0x3f, 0x90, 0xbc, 0x5e, 0xa5, 0x37, 0x33, 0x1e, + 0x65, 0xf9, 0xf6, 0x1e, 0x4f, 0x61, 0xb1, 0x80, 0x6f}; + uint8_t bytesprops3[] = {0x40, 0x27, 0xfd, 0x5b, 0x7a, 0x81, 0x4b, 0x8b, 0x4e, 0xf1, 0x9, 0x94, + 0xc6, 0x54, 0x44, 0xf7, 0x30, 0xc1, 0x11, 0x76, 0x1c, 0x6f, 0x75, 0x64}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14339}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6731}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22863}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5522}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 2}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops8}, .v = {13, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {16, (char*)&bytesprops10}, .v = {30, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13969}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {29, (char*)&bytesprops13}, .v = {25, (char*)&bytesprops14}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25630}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11245}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15509}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5583}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xe2, 0x7d, 0x5a, 0x7b, 0xa8, 0x7c, 0x4f, 0x4c, 0x1d, 0x9b, 0x29, 0xe5, 0x51, 0xa6}; - uint8_t byteswillprops0[] = {0x72, 0x7c, 0x4d, 0xd, 0x78, 0xc5, 0xa, 0x47, 0x9, 0x93, 0xd7, 0x7d, - 0x9e, 0xb0, 0xe9, 0x84, 0x43, 0xa4, 0x5, 0x78, 0x60, 0x21, 0x51}; - uint8_t byteswillprops2[] = {0x5c, 0xf5, 0x1e, 0x53, 0xc6, 0x10, 0x59, 0x60, 0x19, 0xd2, 0x25, 0xba, 0x20, - 0xef, 0xc1, 0xba, 0x53, 0x52, 0xd8, 0x64, 0x23, 0xe, 0x78, 0xef, 0x60, 0x60}; - uint8_t byteswillprops3[] = {0x1e, 0xac, 0x8e}; - uint8_t byteswillprops4[] = {0x9b, 0xf1, 0x50, 0xac, 0x2d, 0xae, 0x8e, 0x1e, 0x78, 0x8b, 0x47, - 0x33, 0xb4, 0xfa, 0x35, 0xff, 0x21, 0x0, 0xad, 0xa, 0x90}; - uint8_t byteswillprops5[] = {0x5f, 0x21, 0x69, 0x9f, 0x5d, 0xee, 0x5c, 0xf, 0x80, 0xc2, 0xc6, 0xe6, 0x69, 0x8a}; - uint8_t byteswillprops6[] = {0x49, 0x9f, 0x6c, 0xd6, 0xe2, 0x9e, 0xf5, 0x52, 0x8c, 0xd5, 0xc7, 0x9c, 0x63, - 0x4f, 0xb7, 0xe, 0xf9, 0x51, 0x67, 0x6b, 0x60, 0xa, 0xc8, 0x1c, 0x4d, 0x9}; - uint8_t byteswillprops7[] = {0xe4, 0x96, 0xe9, 0xe3}; - uint8_t byteswillprops8[] = {0x28, 0x28, 0xb6, 0x57, 0x6f, 0xf5, 0x74, 0x3c, - 0x12, 0xe3, 0xb8, 0xa0, 0xc8, 0x9d, 0x36, 0x94}; + uint8_t byteswillprops0[] = {0x8e, 0xd8, 0xce, 0x3d, 0xbb, 0x17, 0x3f, 0x4f, 0x48, 0xc3, 0x72, 0xed, + 0x81, 0x85, 0x66, 0xbe, 0xdb, 0x96, 0xc8, 0x8e, 0xd, 0x4b, 0x8a}; + uint8_t byteswillprops1[] = {0xa1, 0x1f, 0x6c, 0x4d, 0x2, 0x55, 0x67}; + uint8_t byteswillprops2[] = {0xc2, 0x77, 0x50, 0xa3, 0xe7, 0xe, 0x2b, 0xd9, 0x39, 0x32, 0x88, + 0x77, 0x26, 0xd6, 0x2, 0x2a, 0x0, 0x5, 0x33, 0x1d, 0x11}; + uint8_t byteswillprops3[] = {0xc8, 0x56, 0x25, 0xb9}; + uint8_t byteswillprops4[] = {0xa, 0xaf, 0x8a, 0x53, 0x61, 0xc6, 0x6f, 0x3b, 0x72, 0x2d}; + uint8_t byteswillprops5[] = {0xdc, 0x53, 0x8b, 0x51, 0x64}; + uint8_t byteswillprops6[] = {0x44, 0x7c, 0x25, 0x8e, 0x4d, 0x3f, 0x94, 0x65, 0x45, 0x45, 0x9b, 0xb6}; + uint8_t byteswillprops8[] = {0x92, 0xde, 0x5, 0xb, 0xe, 0xd3, 0x69, 0x5d, 0x32, 0x1c, 0x16, 0xdc, + 0xf4, 0xc8, 0xe7, 0xb3, 0x1c, 0x5c, 0x96, 0xc4, 0xbc, 0x95, 0x9b}; + uint8_t byteswillprops7[] = {0x38, 0x68, 0xc7, 0xbe, 0x68, 0x7a, 0xea, 0xe6, 0xeb, 0x4e, 0x94, 0xc5, 0x61, + 0xf6, 0xe1, 0x50, 0xfb, 0x3, 0x64, 0x5e, 0x69, 0x47, 0xbc, 0xb8, 0x88, 0x83}; + uint8_t byteswillprops9[] = {0x4d, 0x28, 0xf9}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30225}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6334}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14266}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2407}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15204}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7923}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {23, (char*)&byteswillprops0}, .v = {14, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15985}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6436}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 45}}, + .value = {.pair = {.k = {26, (char*)&byteswillprops7}, .v = {23, (char*)&byteswillprops8}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops9}}}, }; - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x80}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x47, 0xf4, 0xfa, 0xee, 0xad, 0xdc, 0xcc}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x65, 0x3b, 0xc2, 0x37, 0xed, 0x50, 0xc9, 0x20, 0x77, 0xd8, 0x95, 0x6c, + 0xab, 0x57, 0x1e, 0xf1, 0x3e, 0x87, 0x60, 0x16, 0x5, 0xc5, 0x9}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x32, 0xae}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 28847; - uint8_t client_id_bytes[] = {0x49, 0x50}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.keep_alive = 29263; + uint8_t client_id_bytes[] = {0xad, 0x51, 0x14, 0xa3, 0xb9, 0x81, 0x90, 0xee, 0x9b, 0xa9, + 0x51, 0xfc, 0x4b, 0x83, 0xe3, 0x39, 0x18, 0xb, 0xef}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t password_bytes[] = {0x34, 0xf4, 0x31, 0xd9, 0x8e, 0x38, 0x15, 0x35}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8184,373 +7923,404 @@ TEST(Connect5QCTest, Encode12) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "hWE\168_M\187,\211\130\251B\217\\\139X\246p\GSUQ\252\&7\198\223\143}\191\164", -// _password = Just "\221\"\180", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = -// "/\161\ETX\236\174\202\142\ACK\ENQ&\231\230Zg", _willMsg = "\164:(\192D\224", _willProps = [PropAuthenticationData -// "\218\NAKY\230\f\ETX \198\248\205\147\251\DLEu\240.\197(\243\227\146\144\218_",PropRequestResponseInformation -// 37,PropReasonString "Y\r\183N",PropSharedSubscriptionAvailable 205,PropSubscriptionIdentifier -// 18,PropAuthenticationData "+\248\172\244T[]\133\179",PropMaximumPacketSize 630,PropSubscriptionIdentifierAvailable -// 228,PropRequestProblemInformation 107,PropContentType "\214\202[\223O\227\225mQV\217\"\172\242",PropServerReference -// "\177\SOo\245\225\a\149R\134v<~\212c\ETB \216m-\"^\182\183B\f\238\136\150\245\170",PropPayloadFormatIndicator -// 31,PropSharedSubscriptionAvailable 120,PropWildcardSubscriptionAvailable 66,PropMessageExpiryInterval -// 25661,PropAssignedClientIdentifier -// "G\SO\206\177\226m\129\171\ACK1\155\236\224\213\236O\232\160\156\190\199J_\244",PropPayloadFormatIndicator -// 166,PropMaximumPacketSize 15157,PropWillDelayInterval 26991,PropAuthenticationMethod ";3"]}), _cleanSession = False, -// _keepAlive = 7983, _connID = "\255\v<\218q\253\223)BQ\136u\236\220\156&\164\".", _properties = [PropReasonString -// "\SI\161\162\224u\185\134\v)\236&\235\168\SIXVY\181\201K\STX",PropServerReference "\160",PropSessionExpiryInterval -// 26008,PropResponseTopic -// "u\DC2\DC1HP\158\175=hw\DEL4\248|\244\DC1+\236J\227sU\247\207\134\ETB",PropPayloadFormatIndicator -// 51,PropWildcardSubscriptionAvailable 153,PropSubscriptionIdentifierAvailable 79,PropSharedSubscriptionAvailable -// 34,PropRequestProblemInformation 127,PropRequestResponseInformation 40]} +// ConnectRequest {_username = Nothing, _password = Just "\199\154\ACK\130\147\145\141\149\SOH", _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 26934, _connID = "\185\183=\217", _properties = [PropCorrelationData +// "\239\210u(+\143u\173",PropRetainAvailable 45,PropSessionExpiryInterval 25383,PropMessageExpiryInterval +// 21093,PropCorrelationData "",PropMaximumQoS 7,PropReceiveMaximum 14060,PropSharedSubscriptionAvailable +// 253,PropReasonString "@\200)\189\162a6\159\v{l\235s\ETB",PropRetainAvailable 171,PropReceiveMaximum +// 21217,PropServerKeepAlive 27975,PropSharedSubscriptionAvailable 209,PropSessionExpiryInterval +// 13956,PropMessageExpiryInterval 30032,PropAuthenticationData +// "+\221gp\SOH7\175\233J0\244@\242v\176H\237i\133:\139t\134N\226\160",PropSessionExpiryInterval +// 11445,PropReceiveMaximum 30403,PropAssignedClientIdentifier +// "\221\&0\135\ETB\216\RSV\222\201t)\SOHi\v\218\212\128\225\133",PropRequestResponseInformation +// 138,PropRequestProblemInformation 79,PropResponseInformation +// "F7]\188[\250&\195\146Qa\189\203_\181\237\SOH\GS\241\130q\194\236\209\STX\250\242",PropMessageExpiryInterval +// 10611,PropTopicAlias 15572,PropAuthenticationMethod "X\187\141\177\&8\220\244\210\&8\214\200\144",PropRetainAvailable +// 159,PropSubscriptionIdentifierAvailable 212]} TEST(Connect5QCTest, Encode13) { uint8_t pkt[] = { - 0x10, 0xce, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc4, 0x1f, 0x2f, 0x4a, 0x1f, 0x0, 0x15, 0xf, 0xa1, - 0xa2, 0xe0, 0x75, 0xb9, 0x86, 0xb, 0x29, 0xec, 0x26, 0xeb, 0xa8, 0xf, 0x58, 0x56, 0x59, 0xb5, 0xc9, 0x4b, 0x2, - 0x1c, 0x0, 0x1, 0xa0, 0x11, 0x0, 0x0, 0x65, 0x98, 0x8, 0x0, 0x1a, 0x75, 0x12, 0x11, 0x48, 0x50, 0x9e, 0xaf, - 0x3d, 0x68, 0x77, 0x7f, 0x34, 0xf8, 0x7c, 0xf4, 0x11, 0x2b, 0xec, 0x4a, 0xe3, 0x73, 0x55, 0xf7, 0xcf, 0x86, 0x17, - 0x1, 0x33, 0x28, 0x99, 0x29, 0x4f, 0x2a, 0x22, 0x17, 0x7f, 0x19, 0x28, 0x0, 0x13, 0xff, 0xb, 0x3c, 0xda, 0x71, - 0xfd, 0xdf, 0x29, 0x42, 0x51, 0x88, 0x75, 0xec, 0xdc, 0x9c, 0x26, 0xa4, 0x22, 0x2e, 0xa6, 0x1, 0x16, 0x0, 0x18, - 0xda, 0x15, 0x59, 0xe6, 0xc, 0x3, 0x20, 0xc6, 0xf8, 0xcd, 0x93, 0xfb, 0x10, 0x75, 0xf0, 0x2e, 0xc5, 0x28, 0xf3, - 0xe3, 0x92, 0x90, 0xda, 0x5f, 0x19, 0x25, 0x1f, 0x0, 0x4, 0x59, 0xd, 0xb7, 0x4e, 0x2a, 0xcd, 0xb, 0x12, 0x16, - 0x0, 0x9, 0x2b, 0xf8, 0xac, 0xf4, 0x54, 0x5b, 0x5d, 0x85, 0xb3, 0x27, 0x0, 0x0, 0x2, 0x76, 0x29, 0xe4, 0x17, - 0x6b, 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0x3d, 0xd9, 0x0, 0x9, 0xc7, 0x9a, 0x6, 0x82, 0x93, 0x91, 0x8d, 0x95, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf, 0xa1, 0xa2, 0xe0, 0x75, 0xb9, 0x86, 0xb, 0x29, 0xec, 0x26, - 0xeb, 0xa8, 0xf, 0x58, 0x56, 0x59, 0xb5, 0xc9, 0x4b, 0x2}; - uint8_t bytesprops1[] = {0xa0}; - uint8_t bytesprops2[] = {0x75, 0x12, 0x11, 0x48, 0x50, 0x9e, 0xaf, 0x3d, 0x68, 0x77, 0x7f, 0x34, 0xf8, - 0x7c, 0xf4, 0x11, 0x2b, 0xec, 0x4a, 0xe3, 0x73, 0x55, 0xf7, 0xcf, 0x86, 0x17}; + uint8_t bytesprops0[] = {0xef, 0xd2, 0x75, 0x28, 0x2b, 0x8f, 0x75, 0xad}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x40, 0xc8, 0x29, 0xbd, 0xa2, 0x61, 0x36, 0x9f, 0xb, 0x7b, 0x6c, 0xeb, 0x73, 0x17}; + uint8_t bytesprops3[] = {0x2b, 0xdd, 0x67, 0x70, 0x1, 0x37, 0xaf, 0xe9, 0x4a, 0x30, 0xf4, 0x40, 0xf2, + 0x76, 0xb0, 0x48, 0xed, 0x69, 0x85, 0x3a, 0x8b, 0x74, 0x86, 0x4e, 0xe2, 0xa0}; + uint8_t bytesprops4[] = {0xdd, 0x30, 0x87, 0x17, 0xd8, 0x1e, 0x56, 0xde, 0xc9, 0x74, + 0x29, 0x1, 0x69, 0xb, 0xda, 0xd4, 0x80, 0xe1, 0x85}; + uint8_t bytesprops5[] = {0x46, 0x37, 0x5d, 0xbc, 0x5b, 0xfa, 0x26, 0xc3, 0x92, 0x51, 0x61, 0xbd, 0xcb, 0x5f, + 0xb5, 0xed, 0x1, 0x1d, 0xf1, 0x82, 0x71, 0xc2, 0xec, 0xd1, 0x2, 0xfa, 0xf2}; + uint8_t bytesprops6[] = {0x58, 0xbb, 0x8d, 0xb1, 0x38, 0xdc, 0xf4, 0xd2, 0x38, 0xd6, 0xc8, 0x90}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26008}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xda, 0x15, 0x59, 0xe6, 0xc, 0x3, 0x20, 0xc6, 0xf8, 0xcd, 0x93, 0xfb, - 0x10, 0x75, 0xf0, 0x2e, 0xc5, 0x28, 0xf3, 0xe3, 0x92, 0x90, 0xda, 0x5f}; - uint8_t byteswillprops1[] = {0x59, 0xd, 0xb7, 0x4e}; - uint8_t byteswillprops2[] = {0x2b, 0xf8, 0xac, 0xf4, 0x54, 0x5b, 0x5d, 0x85, 0xb3}; - uint8_t byteswillprops3[] = {0xd6, 0xca, 0x5b, 0xdf, 0x4f, 0xe3, 0xe1, 0x6d, 0x51, 0x56, 0xd9, 0x22, 0xac, 0xf2}; - uint8_t byteswillprops4[] = {0xb1, 0xe, 0x6f, 0xf5, 0xe1, 0x7, 0x95, 0x52, 0x86, 0x76, - 0x3c, 0x7e, 0xd4, 0x63, 0x17, 0x20, 0xd8, 0x6d, 0x2d, 0x22, - 0x5e, 0xb6, 0xb7, 0x42, 0xc, 0xee, 0x88, 0x96, 0xf5, 0xaa}; - uint8_t byteswillprops5[] = {0x47, 0xe, 0xce, 0xb1, 0xe2, 0x6d, 0x81, 0xab, 0x6, 0x31, 0x9b, 0xec, - 0xe0, 0xd5, 0xec, 0x4f, 0xe8, 0xa0, 0x9c, 0xbe, 0xc7, 0x4a, 0x5f, 0xf4}; - uint8_t byteswillprops6[] = {0x3b, 0x33}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 630}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25661}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15157}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26991}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25383}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21093}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14060}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21217}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27975}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13956}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30032}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11445}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30403}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10611}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15572}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 212}}, }; - lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2f, 0xa1, 0x3, 0xec, 0xae, 0xca, 0x8e, 0x6, 0x5, 0x26, 0xe7, 0xe6, 0x5a, 0x67}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa4, 0x3a, 0x28, 0xc0, 0x44, 0xe0}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 7983; - uint8_t client_id_bytes[] = {0xff, 0xb, 0x3c, 0xda, 0x71, 0xfd, 0xdf, 0x29, 0x42, 0x51, - 0x88, 0x75, 0xec, 0xdc, 0x9c, 0x26, 0xa4, 0x22, 0x2e}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 26934; + uint8_t client_id_bytes[] = {0xb9, 0xb7, 0x3d, 0xd9}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x68, 0x57, 0x45, 0xa8, 0x5f, 0x4d, 0xbb, 0x2c, 0xd3, 0x82, 0xfb, 0x42, 0xd9, 0x5c, 0x8b, - 0x58, 0xf6, 0x70, 0x1d, 0x55, 0x51, 0xfc, 0x37, 0xc6, 0xdf, 0x8f, 0x7d, 0xbf, 0xa4}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xdd, 0x22, 0xb4}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xc7, 0x9a, 0x6, 0x82, 0x93, 0x91, 0x8d, 0x95, 0x1}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "I\SI\221-\132?i\130\DC4\231\186", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 15604, _connID = "\246\207\188\170T\240a\203\184x\230X\199\147{8_\SO;\188)", -// _properties = [PropServerReference "\218zK#\138uM",PropServerKeepAlive 3564,PropServerKeepAlive -// 6693,PropResponseTopic "\172\v.\245\225Ll\146\f\240,D\230",PropResponseTopic "",PropWillDelayInterval -// 17189,PropContentType "\147\190Jwf\167\254lJ5\180\168\233\159jG\177o\214o",PropAuthenticationData -// "\211PO\130'\ETB\222\207R\ENQ\f",PropSessionExpiryInterval 54,PropServerKeepAlive 12425,PropServerReference -// "\ACK\222S\204\DC1\141\SO\SI\rV\232\DLE\220&M?\208m\128\192",PropRetainAvailable 171,PropSubscriptionIdentifier -// 10,PropResponseInformation "U\DC2E\145\130\227\240",PropReasonString -// "C\t\DC4\NUL\196\250\218\173\SI\235\233\206)\239\&7\197\170()\157\237\176O\179;\253f\166\a",PropSubscriptionIdentifierAvailable -// 138,PropReasonString "\225\241\222Y\n\234\245\250\252S=\ESC}",PropSharedSubscriptionAvailable 14,PropServerKeepAlive -// 12324,PropMaximumQoS 12,PropMaximumPacketSize 10973,PropMaximumQoS 38,PropWillDelayInterval 7796,PropRetainAvailable -// 21,PropRetainAvailable 93,PropAuthenticationData -// "\199\245\198\230b\156\163I\SYN2\226\ENQ\154u\218\242\206\240\217\160X\254\198",PropSessionExpiryInterval -// 6316,PropServerKeepAlive 2977,PropSharedSubscriptionAvailable 210]} +// ConnectRequest {_username = Just +// "-\247+\DC1\233}bt\ENQ\200\241\ENQ\SI\v\163F\173\246\236h\217\149Ur\237\DC3\244\208\217\EOT", _password = Just +// "\181\199$\147\180\ETX6\202", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\227\174\130\185\246$4`\SI^`\215\195\238\204OL\188\134\144\164\DLE^-\187\STX\DC4\224\178", _willMsg = +// "\210\221\DC4\SYN\212^\167\212v\131\142\DELq\191\136\237\&6\203\227.\181\SYN\138", _willProps = +// [PropWildcardSubscriptionAvailable 185,PropCorrelationData "\253l\182o\221\205\214\SYNp\231\191",PropRetainAvailable +// 187,PropMessageExpiryInterval 30413,PropMaximumQoS 59,PropResponseInformation +// "\216\249>\184\207%.\243\214\DC4\200`",PropReasonString +// "\190\CAN\v\247\172\195q\177C\171\&5{\248\&3[\223\135\134'",PropAuthenticationMethod +// "\248\229=L\165=\DC4\241\181<\174\188q.",PropAuthenticationData +// "\145\184I3\218\156\139\153\b\133,\182\np\DC3\132\ENQ\243\ETX\240\167\DC1\194B\ETXyl",PropResponseTopic +// "\200\SO\240\223\234\&0",PropRequestProblemInformation 177,PropResponseTopic +// "!\152`\198\148\140\DC1Q\CAN\v\242\192\182 \198",PropReasonString "C\253/\215",PropResponseTopic +// "\182-\146Y\196\b\202\214\DC2\145\148\ESC=\180\255Q+",PropSubscriptionIdentifier 11,PropServerReference +// "\203\233\242\153\166\246X\235\&5'\144!>\240\207\DLE9\217xr\158\255\241.j{",PropAuthenticationData +// "k\228\t_\252\165RF\179{Z\EOT\207\201\197SY'\234\135k\166\152;\DEL\172\242",PropTopicAlias 27251,PropContentType +// "\EOT\r\174\154f\165\"\195\158\201\SOH",PropSharedSubscriptionAvailable 57,PropUserProperty +// "b\144\251\240\US\245\NAK(\SIo%l\178\174V\191\226zD" "\159",PropResponseTopic +// "\rFi\SO`Aij5\231q\185\US6",PropSubscriptionIdentifier 18,PropMessageExpiryInterval +// 28407,PropRequestResponseInformation 129,PropReasonString "4p\203\141\133\153s4HZ",PropCorrelationData +// "x\193\204\&6\206\247",PropAssignedClientIdentifier "\246\&4\US+\aN\161\239a",PropAuthenticationMethod +// "\129\150\201}<\207"]}), _cleanSession = False, _keepAlive = 20204, _connID = "\140\212\218\244p", _properties = +// [PropAuthenticationMethod "\146P\t\153Y\136",PropSubscriptionIdentifier 17,PropReceiveMaximum +// 2002,PropCorrelationData "\231\223i~=e\160\196\175\232\198\138}\222\DC2j",PropAuthenticationMethod +// "\253\250AU5B\ETB\255[\210",PropUserProperty "\190\ETX\148*+\189" "D/e\215G?\202w\197\NAK\157\221\204\v\247\245 +// &z\146\141\245\SYN\CAN\181",PropPayloadFormatIndicator 213,PropTopicAlias 7603]} TEST(Connect5QCTest, Encode14) { uint8_t pkt[] = { - 0x10, 0x97, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x40, 0x3c, 0xf4, 0xe7, 0x1, 0x1c, 0x0, 0x7, 0xda, - 0x7a, 0x4b, 0x23, 0x8a, 0x75, 0x4d, 0x13, 0xd, 0xec, 0x13, 0x1a, 0x25, 0x8, 0x0, 0xd, 0xac, 0xb, 0x2e, 0xf5, - 0xe1, 0x4c, 0x6c, 0x92, 0xc, 0xf0, 0x2c, 0x44, 0xe6, 0x8, 0x0, 0x0, 0x18, 0x0, 0x0, 0x43, 0x25, 0x3, 0x0, - 0x14, 0x93, 0xbe, 0x4a, 0x77, 0x66, 0xa7, 0xfe, 0x6c, 0x4a, 0x35, 0xb4, 0xa8, 0xe9, 0x9f, 0x6a, 0x47, 0xb1, 0x6f, - 0xd6, 0x6f, 0x16, 0x0, 0xb, 0xd3, 0x50, 0x4f, 0x82, 0x27, 0x17, 0xde, 0xcf, 0x52, 0x5, 0xc, 0x11, 0x0, 0x0, - 0x0, 0x36, 0x13, 0x30, 0x89, 0x1c, 0x0, 0x14, 0x6, 0xde, 0x53, 0xcc, 0x11, 0x8d, 0xe, 0xf, 0xd, 0x56, 0xe8, - 0x10, 0xd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, 0x71, 0xb9, 0x1f, 0x36, 0xb, 0x12, + 0x2, 0x0, 0x0, 0x6e, 0xf7, 0x19, 0x81, 0x1f, 0x0, 0xa, 0x34, 0x70, 0xcb, 0x8d, 0x85, 0x99, 0x73, 0x34, 0x48, + 0x5a, 0x9, 0x0, 0x6, 0x78, 0xc1, 0xcc, 0x36, 0xce, 0xf7, 0x12, 0x0, 0x9, 0xf6, 0x34, 0x1f, 0x2b, 0x7, 0x4e, + 0xa1, 0xef, 0x61, 0x15, 0x0, 0x6, 0x81, 0x96, 0xc9, 0x7d, 0x3c, 0xcf, 0x0, 0x1d, 0xe3, 0xae, 0x82, 0xb9, 0xf6, + 0x24, 0x34, 0x60, 0xf, 0x5e, 0x60, 0xd7, 0xc3, 0xee, 0xcc, 0x4f, 0x4c, 0xbc, 0x86, 0x90, 0xa4, 0x10, 0x5e, 0x2d, + 0xbb, 0x2, 0x14, 0xe0, 0xb2, 0x0, 0x17, 0xd2, 0xdd, 0x14, 0x16, 0xd4, 0x5e, 0xa7, 0xd4, 0x76, 0x83, 0x8e, 0x7f, + 0x71, 0xbf, 0x88, 0xed, 0x36, 0xcb, 0xe3, 0x2e, 0xb5, 0x16, 0x8a, 0x0, 0x1e, 0x2d, 0xf7, 0x2b, 0x11, 0xe9, 0x7d, + 0x62, 0x74, 0x5, 0xc8, 0xf1, 0x5, 0xf, 0xb, 0xa3, 0x46, 0xad, 0xf6, 0xec, 0x68, 0xd9, 0x95, 0x55, 0x72, 0xed, + 0x13, 0xf4, 0xd0, 0xd9, 0x4, 0x0, 0x8, 0xb5, 0xc7, 0x24, 0x93, 0xb4, 0x3, 0x36, 0xca}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xda, 0x7a, 0x4b, 0x23, 0x8a, 0x75, 0x4d}; - uint8_t bytesprops1[] = {0xac, 0xb, 0x2e, 0xf5, 0xe1, 0x4c, 0x6c, 0x92, 0xc, 0xf0, 0x2c, 0x44, 0xe6}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x93, 0xbe, 0x4a, 0x77, 0x66, 0xa7, 0xfe, 0x6c, 0x4a, 0x35, - 0xb4, 0xa8, 0xe9, 0x9f, 0x6a, 0x47, 0xb1, 0x6f, 0xd6, 0x6f}; - uint8_t bytesprops4[] = {0xd3, 0x50, 0x4f, 0x82, 0x27, 0x17, 0xde, 0xcf, 0x52, 0x5, 0xc}; - uint8_t bytesprops5[] = {0x6, 0xde, 0x53, 0xcc, 0x11, 0x8d, 0xe, 0xf, 0xd, 0x56, - 0xe8, 0x10, 0xdc, 0x26, 0x4d, 0x3f, 0xd0, 0x6d, 0x80, 0xc0}; - uint8_t bytesprops6[] = {0x55, 0x12, 0x45, 0x91, 0x82, 0xe3, 0xf0}; - uint8_t bytesprops7[] = {0x43, 0x9, 0x14, 0x0, 0xc4, 0xfa, 0xda, 0xad, 0xf, 0xeb, 0xe9, 0xce, 0x29, 0xef, 0x37, - 0xc5, 0xaa, 0x28, 0x29, 0x9d, 0xed, 0xb0, 0x4f, 0xb3, 0x3b, 0xfd, 0x66, 0xa6, 0x7}; - uint8_t bytesprops8[] = {0xe1, 0xf1, 0xde, 0x59, 0xa, 0xea, 0xf5, 0xfa, 0xfc, 0x53, 0x3d, 0x1b, 0x7d}; - uint8_t bytesprops9[] = {0xc7, 0xf5, 0xc6, 0xe6, 0x62, 0x9c, 0xa3, 0x49, 0x16, 0x32, 0xe2, 0x5, - 0x9a, 0x75, 0xda, 0xf2, 0xce, 0xf0, 0xd9, 0xa0, 0x58, 0xfe, 0xc6}; + uint8_t bytesprops0[] = {0x92, 0x50, 0x9, 0x99, 0x59, 0x88}; + uint8_t bytesprops1[] = {0xe7, 0xdf, 0x69, 0x7e, 0x3d, 0x65, 0xa0, 0xc4, + 0xaf, 0xe8, 0xc6, 0x8a, 0x7d, 0xde, 0x12, 0x6a}; + uint8_t bytesprops2[] = {0xfd, 0xfa, 0x41, 0x55, 0x35, 0x42, 0x17, 0xff, 0x5b, 0xd2}; + uint8_t bytesprops4[] = {0x44, 0x2f, 0x65, 0xd7, 0x47, 0x3f, 0xca, 0x77, 0xc5, 0x15, 0x9d, 0xdd, 0xcc, + 0xb, 0xf7, 0xf5, 0x20, 0x26, 0x7a, 0x92, 0x8d, 0xf5, 0x16, 0x18, 0xb5}; + uint8_t bytesprops3[] = {0xbe, 0x3, 0x94, 0x2a, 0x2b, 0xbd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3564}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6693}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17189}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 54}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12425}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12324}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10973}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7796}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6316}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2977}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2002}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops3}, .v = {25, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7603}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xfd, 0x6c, 0xb6, 0x6f, 0xdd, 0xcd, 0xd6, 0x16, 0x70, 0xe7, 0xbf}; + uint8_t byteswillprops1[] = {0xd8, 0xf9, 0x3e, 0xb8, 0xcf, 0x25, 0x2e, 0xf3, 0xd6, 0x14, 0xc8, 0x60}; + uint8_t byteswillprops2[] = {0xbe, 0x18, 0xb, 0xf7, 0xac, 0xc3, 0x71, 0xb1, 0x43, 0xab, + 0x35, 0x7b, 0xf8, 0x33, 0x5b, 0xdf, 0x87, 0x86, 0x27}; + uint8_t byteswillprops3[] = {0xf8, 0xe5, 0x3d, 0x4c, 0xa5, 0x3d, 0x14, 0xf1, 0xb5, 0x3c, 0xae, 0xbc, 0x71, 0x2e}; + uint8_t byteswillprops4[] = {0x91, 0xb8, 0x49, 0x33, 0xda, 0x9c, 0x8b, 0x99, 0x8, 0x85, 0x2c, 0xb6, 0xa, 0x70, + 0x13, 0x84, 0x5, 0xf3, 0x3, 0xf0, 0xa7, 0x11, 0xc2, 0x42, 0x3, 0x79, 0x6c}; + uint8_t byteswillprops5[] = {0xc8, 0xe, 0xf0, 0xdf, 0xea, 0x30}; + uint8_t byteswillprops6[] = {0x21, 0x98, 0x60, 0xc6, 0x94, 0x8c, 0x11, 0x51, 0x18, 0xb, 0xf2, 0xc0, 0xb6, 0x20, 0xc6}; + uint8_t byteswillprops7[] = {0x43, 0xfd, 0x2f, 0xd7}; + uint8_t byteswillprops8[] = {0xb6, 0x2d, 0x92, 0x59, 0xc4, 0x8, 0xca, 0xd6, 0x12, + 0x91, 0x94, 0x1b, 0x3d, 0xb4, 0xff, 0x51, 0x2b}; + uint8_t byteswillprops9[] = {0xcb, 0xe9, 0xf2, 0x99, 0xa6, 0xf6, 0x58, 0xeb, 0x35, 0x27, 0x90, 0x21, 0x3e, + 0xf0, 0xcf, 0x10, 0x39, 0xd9, 0x78, 0x72, 0x9e, 0xff, 0xf1, 0x2e, 0x6a, 0x7b}; + uint8_t byteswillprops10[] = {0x6b, 0xe4, 0x9, 0x5f, 0xfc, 0xa5, 0x52, 0x46, 0xb3, 0x7b, 0x5a, 0x4, 0xcf, 0xc9, + 0xc5, 0x53, 0x59, 0x27, 0xea, 0x87, 0x6b, 0xa6, 0x98, 0x3b, 0x7f, 0xac, 0xf2}; + uint8_t byteswillprops11[] = {0x4, 0xd, 0xae, 0x9a, 0x66, 0xa5, 0x22, 0xc3, 0x9e, 0xc9, 0x1}; + uint8_t byteswillprops13[] = {0x9f}; + uint8_t byteswillprops12[] = {0x62, 0x90, 0xfb, 0xf0, 0x1f, 0xf5, 0x15, 0x28, 0xf, 0x6f, + 0x25, 0x6c, 0xb2, 0xae, 0x56, 0xbf, 0xe2, 0x7a, 0x44}; + uint8_t byteswillprops14[] = {0xd, 0x46, 0x69, 0xe, 0x60, 0x41, 0x69, 0x6a, 0x35, 0xe7, 0x71, 0xb9, 0x1f, 0x36}; + uint8_t byteswillprops15[] = {0x34, 0x70, 0xcb, 0x8d, 0x85, 0x99, 0x73, 0x34, 0x48, 0x5a}; + uint8_t byteswillprops16[] = {0x78, 0xc1, 0xcc, 0x36, 0xce, 0xf7}; + uint8_t byteswillprops17[] = {0xf6, 0x34, 0x1f, 0x2b, 0x7, 0x4e, 0xa1, 0xef, 0x61}; + uint8_t byteswillprops18[] = {0x81, 0x96, 0xc9, 0x7d, 0x3c, 0xcf}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30413}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27251}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {19, (char*)&byteswillprops12}, .v = {1, (char*)&byteswillprops13}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&byteswillprops14}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28407}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops15}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops16}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops17}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops18}}}, + }; + + lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe3, 0xae, 0x82, 0xb9, 0xf6, 0x24, 0x34, 0x60, 0xf, 0x5e, + 0x60, 0xd7, 0xc3, 0xee, 0xcc, 0x4f, 0x4c, 0xbc, 0x86, 0x90, + 0xa4, 0x10, 0x5e, 0x2d, 0xbb, 0x2, 0x14, 0xe0, 0xb2}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd2, 0xdd, 0x14, 0x16, 0xd4, 0x5e, 0xa7, 0xd4, 0x76, 0x83, 0x8e, 0x7f, + 0x71, 0xbf, 0x88, 0xed, 0x36, 0xcb, 0xe3, 0x2e, 0xb5, 0x16, 0x8a}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 15604; - uint8_t client_id_bytes[] = {0xf6, 0xcf, 0xbc, 0xaa, 0x54, 0xf0, 0x61, 0xcb, 0xb8, 0x78, 0xe6, - 0x58, 0xc7, 0x93, 0x7b, 0x38, 0x5f, 0xe, 0x3b, 0xbc, 0x29}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.keep_alive = 20204; + uint8_t client_id_bytes[] = {0x8c, 0xd4, 0xda, 0xf4, 0x70}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x49, 0xf, 0xdd, 0x2d, 0x84, 0x3f, 0x69, 0x82, 0x14, 0xe7, 0xba}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x2d, 0xf7, 0x2b, 0x11, 0xe9, 0x7d, 0x62, 0x74, 0x5, 0xc8, 0xf1, 0x5, 0xf, 0xb, 0xa3, + 0x46, 0xad, 0xf6, 0xec, 0x68, 0xd9, 0x95, 0x55, 0x72, 0xed, 0x13, 0xf4, 0xd0, 0xd9, 0x4}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xb5, 0xc7, 0x24, 0x93, 0xb4, 0x3, 0x36, 0xca}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "Y4l\EOT[\245\243\233\211\199c\CANhx\DC4\190g\175\RS\147\191'\223\137<6", _willMsg = -// "\139|6\245\194\246\236j", _willProps = [PropSessionExpiryInterval 28956,PropTopicAliasMaximum 4577,PropContentType -// "\176\ETX\161\157\200\&4\v^\187\219W5\188[\227\135\128\176\207Cn\"d\236<5\149",PropRequestProblemInformation -// 102,PropResponseInformation "\"\255Z\199r\DLE\132\FS",PropReceiveMaximum 7492,PropAuthenticationMethod -// "o\242\129\170\251\156\\\177\220\238H",PropMaximumPacketSize 1156,PropUserProperty -// "\233^\206P\t\230\215\a_pj\181v\\\164\139\&6\188\203\145\238\233\141\198b\253\206?" -// "\224\161\SUBW\241\184U\252\227\154\SO3\248\140\&3\142\"\187\&4\246\208+2\222TO&u",PropRequestProblemInformation -// 225,PropMaximumQoS 219,PropCorrelationData -// "7mk\"\176\248\240\ACK\205V*\195To\167\187\233\241\162\226|\236",PropMaximumQoS 150,PropWillDelayInterval -// 16062,PropUserProperty "\208\245" "4\128D2K",PropWillDelayInterval 28121,PropWillDelayInterval 3146,PropReasonString -// "\128\DELd\150%Ab\ESC5Y\172*p\212",PropSubscriptionIdentifier 1,PropMessageExpiryInterval 2118]}), _cleanSession = -// True, _keepAlive = 1098, _connID = "\242\250\148C\fX\219\222", _properties = [PropCorrelationData -// "\138\205\206[H\228\194\DC2\177\142\144\248j",PropWillDelayInterval 30821,PropServerKeepAlive -// 14707,PropWildcardSubscriptionAvailable 164,PropPayloadFormatIndicator 50,PropTopicAlias 88,PropResponseTopic -// "\224v\RS\171*[&\184\240*\164\217.\203\170\160J)\241\131",PropRetainAvailable 90,PropResponseInformation -// "\160\238*\184\169^\254\148\137\229\&3,D\f\SOH",PropRetainAvailable 38,PropAuthenticationData -// "\134\211d\157\t\162\\\202\183\EOT\204\165\136X\228\t=\160w\152\186\SUB\209_-J\221\184\&3\240",PropMaximumPacketSize -// 26252,PropAuthenticationData -// "\197\CAN\EMD\205N\ACK\215\191\249\236\v\249\159\253\DC4\SUB\225cS+\161",PropMaximumPacketSize -// 17119,PropAuthenticationMethod "\173\247\CAN!\219\251\SO\202\185\152u\158M.`Y\161{\237\202\232\220@v\181\146-",PropReceiveMaximum 30893,PropServerReference +// "D",PropWildcardSubscriptionAvailable 103,PropServerKeepAlive 9030,PropRetainAvailable 158,PropMaximumPacketSize +// 17128,PropServerKeepAlive 13020,PropServerKeepAlive 17468]} TEST(Connect5QCTest, Encode16) { - uint8_t pkt[] = {0x10, 0xf5, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x65, 0x22, 0x63, 0x16, 0x0, 0xf, - 0xf0, 0x8f, 0xe4, 0xf9, 0xbe, 0x3d, 0xf1, 0xd8, 0x21, 0x6f, 0x25, 0x45, 0x0, 0x80, 0xf0, 0x21, 0x5a, - 0xf0, 0x1a, 0x0, 0x7, 0xbf, 0x7f, 0x46, 0x8e, 0x55, 0xd1, 0x60, 0x1f, 0x0, 0x1c, 0x53, 0xfe, 0x80, - 0x43, 0xa6, 0x3a, 0x7a, 0xb0, 0x23, 0x40, 0xe7, 0x23, 0x42, 0xc3, 0xf0, 0xc9, 0x72, 0xd8, 0x13, 0xb8, - 0xd2, 0x7b, 0xb8, 0x6e, 0x19, 0xb0, 0xa, 0x4f, 0x2, 0x0, 0x0, 0x61, 0x1f, 0x23, 0x6d, 0xb4, 0x1, - 0xc6, 0x9, 0x0, 0x16, 0x5b, 0x33, 0xfe, 0x5e, 0x3b, 0x83, 0xe7, 0x84, 0xb6, 0x97, 0xc3, 0x6c, 0xb4, - 0x58, 0x32, 0xdc, 0x26, 0xe7, 0x89, 0x44, 0x51, 0xa8, 0x2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x4c, 0x4f, 0x4e, 0xf6, 0xc7, 0xd2, 0x67, 0xeb, 0xe1, 0xff, 0x82, 0x8b, 0xb, 0x20}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf0, 0x8f, 0xe4, 0xf9, 0xbe, 0x3d, 0xf1, 0xd8, 0x21, 0x6f, 0x25, 0x45, 0x0, 0x80, 0xf0}; - uint8_t bytesprops1[] = {0xbf, 0x7f, 0x46, 0x8e, 0x55, 0xd1, 0x60}; - uint8_t bytesprops2[] = {0x53, 0xfe, 0x80, 0x43, 0xa6, 0x3a, 0x7a, 0xb0, 0x23, 0x40, 0xe7, 0x23, 0x42, 0xc3, - 0xf0, 0xc9, 0x72, 0xd8, 0x13, 0xb8, 0xd2, 0x7b, 0xb8, 0x6e, 0x19, 0xb0, 0xa, 0x4f}; - uint8_t bytesprops3[] = {0x5b, 0x33, 0xfe, 0x5e, 0x3b, 0x83, 0xe7, 0x84, 0xb6, 0x97, 0xc3, - 0x6c, 0xb4, 0x58, 0x32, 0xdc, 0x26, 0xe7, 0x89, 0x44, 0x51, 0xa8}; + uint8_t bytesprops0[] = {0x66, 0x64, 0x29, 0x1, 0xfe, 0xfd, 0x11, 0x10, 0x21, 0x11, 0xa8, 0x77, + 0x36, 0xe6, 0x6d, 0xaf, 0xb3, 0x48, 0x93, 0xeb, 0x63, 0x9f, 0xde, 0x2}; + uint8_t bytesprops2[] = {0x90, 0xc, 0xec, 0xdb, 0x28, 0x31, 0x40, 0x1, 0xe3, 0x34, 0x3c, 0xef, 0xc3}; + uint8_t bytesprops1[] = {0x25, 0x15, 0xa1, 0x5d, 0x50, 0xc4, 0x88, 0xfb, 0x84, 0x42, 0x2b, 0xf3, + 0x4b, 0xe6, 0x73, 0x14, 0xc3, 0x1, 0x79, 0x23, 0x28, 0x1d, 0x60}; + uint8_t bytesprops3[] = {0xe8, 0xfa}; + uint8_t bytesprops4[] = {0xa7, 0xa0, 0x2d, 0x5c, 0x82, 0xbc, 0x2d, 0xf4, 0x7e, 0xa, 0x26, 0x2a, 0xcc, 0x5a, + 0xf7, 0x9b, 0x87, 0x37, 0x92, 0x98, 0xbf, 0x2d, 0xd9, 0x5, 0x6a, 0x3a, 0x85}; + uint8_t bytesprops5[] = {0x75, 0x8a, 0x5, 0xcc, 0xad, 0x1b, 0x46, 0xb7, 0x60, + 0x71, 0x69, 0xdc, 0x5e, 0xc0, 0xb9, 0x41, 0x96}; + uint8_t bytesprops6[] = {0x5f, 0x32, 0x66, 0xba, 0x49, 0xa, 0x24, 0x39, 0x50, 0x4d, 0x3a}; + uint8_t bytesprops7[] = {0xe1, 0x57, 0x3e, 0x7b, 0xed, 0xca, 0xe8, 0xdc, 0x40, 0x76, 0xb5, 0x92, 0x2d}; + uint8_t bytesprops8[] = {0x44}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23280}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24863}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28084}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6137}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5995}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops1}, .v = {13, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2713}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14510}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1590}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14239}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26634}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30893}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9030}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17128}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13020}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17468}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xa, 0x49, 0x7e, 0x3a, 0x8f, 0xb9, 0x69, 0x93, 0x37, 0xc1, 0x74, 0xe7, 0x9c, 0xf4, - 0x40, 0xff, 0x90, 0xc0, 0xb1, 0x50, 0x3b, 0x2a, 0xfd, 0xa1, 0x83, 0x9c, 0x48, 0xa4}; - uint8_t byteswillprops1[] = {0xd4, 0x4, 0x18, 0xbc, 0xfb, 0x8e, 0xb4, 0x8, 0x15, - 0xdb, 0x3d, 0xef, 0x9d, 0xa6, 0x4a, 0xf, 0xa, 0x90}; + uint8_t byteswillprops0[] = {0x5b, 0x58, 0xba, 0x5, 0xf4}; + uint8_t byteswillprops1[] = {0x89, 0x10, 0x48, 0x5a, 0x49, 0x70, 0x27, 0xde, 0xd4, 0xc3, 0xf6, 0x2b, 0x7b, + 0x67, 0x5f, 0x9b, 0xc7, 0xf4, 0xa2, 0x1d, 0xe8, 0x6, 0x1c, 0xe3, 0xf1, 0x5e}; + uint8_t byteswillprops2[] = {0xf3, 0x85, 0x53, 0x3b, 0x2d, 0xbe, 0x4, 0xee, 0x8a, 0x1c, 0x6c, 0xda, + 0x12, 0xf9, 0x11, 0x2a, 0xc, 0x71, 0x4a, 0x80, 0xe2, 0x52, 0xb5}; + uint8_t byteswillprops3[] = {0xfc, 0x6c, 0xec, 0xad, 0xa1, 0x82, 0x93, 0xaf, 0x5a, 0x4f, 0x60, 0xba, 0xeb, + 0x3f, 0x34, 0x9a, 0x5b, 0x64, 0x20, 0x6c, 0x2d, 0xbd, 0x4, 0x64, 0x8b, 0x54}; + uint8_t byteswillprops4[] = {0x8, 0xa4, 0x3, 0xab, 0x85, 0xdd, 0xbf, 0x7f, 0xf5, 0x9f, 0x89, 0xba, 0x81, + 0x7b, 0xe6, 0xd7, 0x5f, 0x88, 0x4d, 0x8f, 0xcb, 0xac, 0x44, 0x89, 0x81, 0x19}; + uint8_t byteswillprops6[] = {0xce, 0x3d, 0xff, 0x26, 0xdc, 0x82, 0x83, 0x8, 0x5, 0xdd, 0x66, 0x92, 0xa2, 0x6d, + 0xc4, 0x79, 0x3c, 0x72, 0x5d, 0xb7, 0x2f, 0xb3, 0x72, 0xa, 0xb0, 0xa6, 0x64, 0xe4}; + uint8_t byteswillprops5[] = {0x24, 0xb0, 0x77, 0x82, 0xaa, 0x58, 0x99, 0x4e, + 0x64, 0x51, 0xd2, 0x2b, 0x86, 0xd7, 0x3, 0xe3}; + uint8_t byteswillprops8[] = {0xc0, 0x92, 0xde, 0x1c, 0x9, 0x39, 0xaa, 0x65, 0xf0, 0x24, + 0x40, 0x97, 0x78, 0x4a, 0x1c, 0x6b, 0x64, 0xa7, 0x85}; + uint8_t byteswillprops7[] = {0xda, 0x24, 0x35, 0xa8, 0xc6, 0x11, 0x1d, 0x7, 0xd1, 0x5b, 0xae, 0x5a, 0x34, 0x8, 0x7f}; + uint8_t byteswillprops9[] = {0x53, 0x50, 0xb5, 0xb7, 0x84, 0xa7, 0x6a, 0xaf, 0x92, 0x64, 0xe7, 0xd2, 0x3, 0xa0, 0xa4}; + uint8_t byteswillprops10[] = {0x55, 0xcc, 0x91, 0x68, 0x11, 0x37, 0x2c, 0xb5, 0x30, 0x64}; + uint8_t byteswillprops11[] = {0x14, 0x76, 0xf5, 0x5e, 0x1f, 0xea, 0xa2, 0xea, 0x68, + 0x32, 0xfd, 0xdb, 0x9b, 0x5f, 0x63, 0xdb, 0x86}; + uint8_t byteswillprops12[] = {0x61, 0x3c, 0x70, 0x88, 0x26, 0x8d, 0xce, 0x30, 0x13, 0xb9, 0x64, 0x20, + 0xfd, 0xef, 0x9a, 0xc9, 0x11, 0xe7, 0xd0, 0xb1, 0xf8, 0xff, 0x6f, 0xdd}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7576}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27423}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15164}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14987}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3660}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {16, (char*)&byteswillprops5}, .v = {28, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {15, (char*)&byteswillprops7}, .v = {19, (char*)&byteswillprops8}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20680}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6221}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops12}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 74}}, }; - lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x92, 0xee, 0x9, 0x71, 0x94, 0x5f, 0x93, 0x5}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfb}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x23, 0x51, 0xba, 0x5c, 0xc0, 0x4e, 0x0, 0x17, 0x9f, 0xcd, 0x7, 0xc2, 0x60, + 0x54, 0xd3, 0x19, 0x9d, 0x85, 0x6, 0x66, 0x3b, 0x5a, 0xbd, 0xdc, 0x81, 0xa4}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4, 0xe4, 0x21, 0xfc, 0x4e, 0x4c, 0x4f, 0x4e, 0xf6, 0xc7, + 0xd2, 0x67, 0xeb, 0xe1, 0xff, 0x82, 0x8b, 0xb, 0x20}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 25890; - uint8_t client_id_bytes[] = {0xd, 0x9c, 0x93, 0xdc, 0x98, 0x68, 0x6a, 0x88, 0x5e, 0x1a, 0xb1, 0x3, 0x3e, 0x69}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.keep_alive = 13058; + uint8_t client_id_bytes[] = {0x2e, 0x64, 0x14, 0xcc, 0xfa, 0x65, 0xe0, 0xb4, 0x8c, 0x9e, 0x1e, + 0x33, 0x29, 0x47, 0x8f, 0xac, 0xe, 0x53, 0x54, 0x17, 0x45, 0x58}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x13, 0xf3, 0x9f, 0xd9, 0x75, 0x26, 0xa3, 0x59, 0x15, 0x68, 0x68, 0x9b, 0xa9, 0x34, 0x8e, - 0xa6, 0xd5, 0x6b, 0xf8, 0x74, 0x82, 0xd4, 0xd8, 0x13, 0xad, 0x8c, 0x10, 0x14, 0x52, 0x3a}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x26, 0x6d, 0x8e, 0x78, 0xc0}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8659,38 +8517,64 @@ TEST(Connect5QCTest, Encode16) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\193<~>\224\218\213\230+\253\204S21l", _password = Just "\208`1MG\177\a\230\254", -// _lastWill = Nothing, _cleanSession = False, _keepAlive = 24689, _connID = -// "\215'G$\ESCg\194\223\191:\ETX\166\139\193n\180\156\140\165\209\206\tj\241\ETB\237\210\212Jt", _properties = -// [PropAuthenticationMethod "\150\184\NUL\NUL\a@"]} +// ConnectRequest {_username = Just "-\157\STX\167\DC4\171\157t", _password = Just "/j-", _lastWill = Nothing, +// _cleanSession = False, _keepAlive = 2165, _connID = ";l\192\DC1N\156z\170\170\165[\f", _properties = +// [PropSubscriptionIdentifierAvailable 80,PropPayloadFormatIndicator 153,PropPayloadFormatIndicator +// 45,PropTopicAliasMaximum 28038,PropRequestResponseInformation 248,PropSubscriptionIdentifierAvailable +// 35,PropSessionExpiryInterval 14184,PropSubscriptionIdentifier 17,PropSessionExpiryInterval +// 25123,PropRequestResponseInformation 80,PropRequestResponseInformation 214,PropSubscriptionIdentifier +// 11,PropReceiveMaximum 24025,PropUserProperty "Q\249\163\249-\197\197r\ENQ\239\USe\214\145" +// "\EMI\206G.\r\183v",PropTopicAliasMaximum 10284,PropServerKeepAlive 30193,PropWillDelayInterval +// 19307,PropUserProperty "v\174\133[\172\&6\ENQ\151\200\242\138\167\213'" "\249"]} TEST(Connect5QCTest, Encode17) { - uint8_t pkt[] = {0x10, 0x50, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x60, 0x71, 0x9, 0x15, 0x0, 0x6, 0x96, - 0xb8, 0x0, 0x0, 0x7, 0x40, 0x0, 0x1e, 0xd7, 0x27, 0x47, 0x24, 0x1b, 0x67, 0xc2, 0xdf, 0xbf, 0x3a, - 0x3, 0xa6, 0x8b, 0xc1, 0x6e, 0xb4, 0x9c, 0x8c, 0xa5, 0xd1, 0xce, 0x9, 0x6a, 0xf1, 0x17, 0xed, 0xd2, - 0xd4, 0x4a, 0x74, 0x0, 0xf, 0xc1, 0x3c, 0x7e, 0x3e, 0xe0, 0xda, 0xd5, 0xe6, 0x2b, 0xfd, 0xcc, 0x53, - 0x32, 0x31, 0x6c, 0x0, 0x9, 0xd0, 0x60, 0x31, 0x4d, 0x47, 0xb1, 0x7, 0xe6, 0xfe}; + uint8_t pkt[] = {0x10, 0x84, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x8, 0x75, 0x5c, 0x29, 0x50, 0x1, + 0x99, 0x1, 0x2d, 0x22, 0x6d, 0x86, 0x19, 0xf8, 0x29, 0x23, 0x11, 0x0, 0x0, 0x37, 0x68, 0xb, 0x11, + 0x11, 0x0, 0x0, 0x62, 0x23, 0x19, 0x50, 0x19, 0xd6, 0xb, 0xb, 0x21, 0x5d, 0xd9, 0x26, 0x0, 0xe, + 0x51, 0xf9, 0xa3, 0xf9, 0x2d, 0xc5, 0xc5, 0x72, 0x5, 0xef, 0x1f, 0x65, 0xd6, 0x91, 0x0, 0x8, 0x19, + 0x49, 0xce, 0x47, 0x2e, 0xd, 0xb7, 0x76, 0x22, 0x28, 0x2c, 0x13, 0x75, 0xf1, 0x18, 0x0, 0x0, 0x4b, + 0x6b, 0x26, 0x0, 0xe, 0x76, 0xae, 0x85, 0x5b, 0xac, 0x36, 0x5, 0x97, 0xc8, 0xf2, 0x8a, 0xa7, 0xd5, + 0x27, 0x0, 0x1, 0xf9, 0x0, 0xc, 0x3b, 0x6c, 0xc0, 0x11, 0x4e, 0x9c, 0x7a, 0xaa, 0xaa, 0xa5, 0x5b, + 0xc, 0x0, 0x8, 0x2d, 0x9d, 0x2, 0xa7, 0x14, 0xab, 0x9d, 0x74, 0x0, 0x3, 0x2f, 0x6a, 0x2d}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x96, 0xb8, 0x0, 0x0, 0x7, 0x40}; + uint8_t bytesprops1[] = {0x19, 0x49, 0xce, 0x47, 0x2e, 0xd, 0xb7, 0x76}; + uint8_t bytesprops0[] = {0x51, 0xf9, 0xa3, 0xf9, 0x2d, 0xc5, 0xc5, 0x72, 0x5, 0xef, 0x1f, 0x65, 0xd6, 0x91}; + uint8_t bytesprops3[] = {0xf9}; + uint8_t bytesprops2[] = {0x76, 0xae, 0x85, 0x5b, 0xac, 0x36, 0x5, 0x97, 0xc8, 0xf2, 0x8a, 0xa7, 0xd5, 0x27}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28038}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14184}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25123}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24025}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10284}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30193}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19307}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops2}, .v = {1, (char*)&bytesprops3}}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 24689; - uint8_t client_id_bytes[] = {0xd7, 0x27, 0x47, 0x24, 0x1b, 0x67, 0xc2, 0xdf, 0xbf, 0x3a, - 0x3, 0xa6, 0x8b, 0xc1, 0x6e, 0xb4, 0x9c, 0x8c, 0xa5, 0xd1, - 0xce, 0x9, 0x6a, 0xf1, 0x17, 0xed, 0xd2, 0xd4, 0x4a, 0x74}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; + opts.keep_alive = 2165; + uint8_t client_id_bytes[] = {0x3b, 0x6c, 0xc0, 0x11, 0x4e, 0x9c, 0x7a, 0xaa, 0xaa, 0xa5, 0x5b, 0xc}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xc1, 0x3c, 0x7e, 0x3e, 0xe0, 0xda, 0xd5, 0xe6, 0x2b, 0xfd, 0xcc, 0x53, 0x32, 0x31, 0x6c}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x2d, 0x9d, 0x2, 0xa7, 0x14, 0xab, 0x9d, 0x74}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xd0, 0x60, 0x31, 0x4d, 0x47, 0xb1, 0x7, 0xe6, 0xfe}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x2f, 0x6a, 0x2d}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); @@ -8700,64 +8584,124 @@ TEST(Connect5QCTest, Encode17) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "\163}\NULy\RS\158NX4\187\195\203rzn\170(\172\129\146(]jr\168Q\169 \195\200", _lastWill = Just (LastWill {_willRetain -// = True, _willQoS = QoS2, _willTopic = "", _willMsg = "\244~\217'Tx\238\164\179\193!,\167", _willProps = -// [PropMessageExpiryInterval 19201,PropResponseTopic "\185\213\211",PropSubscriptionIdentifierAvailable -// 223,PropMaximumQoS 244,PropMessageExpiryInterval 23312,PropSubscriptionIdentifierAvailable 97,PropRetainAvailable -// 147,PropResponseTopic "\205\132"]}), _cleanSession = False, _keepAlive = 26060, _connID = -// "ta\163\130\232\170\157\144\190\ETB\172\170g\"\136\233\NAK\NAK\231\ETX\160\SYN~\ENQG\220\208\150\241", _properties = -// []} +// ConnectRequest {_username = Nothing, _password = Just "^a,Y\US\230/\202\240\t\229\218\191\SUBdl", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\170", _willMsg = +// "@d\157b\SYN\150\&0\164\ENQ\236O\149e\129\218\210wSKU\DC4y\SOH\188\163m\EOT", _willProps = [PropReasonString +// "v\n\168/t\169",PropSubscriptionIdentifier 4,PropMessageExpiryInterval 21322,PropTopicAliasMaximum +// 9552,PropTopicAliasMaximum 24731,PropReceiveMaximum 29502,PropCorrelationData +// "n\196z\172-\214\141\173\168$Mx\DC4\184\&8",PropContentType +// "R\201aH\166*B\186\163/\145\235\174\US>S\DC4-\191\137\209\&7^\212y\DC1To\CAN",PropMessageExpiryInterval +// 3252,PropAuthenticationData "\EM\248",PropServerReference "",PropWillDelayInterval 21121,PropContentType +// "\193\193\234_\223G@\232^\136\218\233Y1'\DC4\204t\250",PropUserProperty "\168" +// "v\238\176\NAK\f\ETB7\ESCUU\222y?\163\159\175\189\159\v\186!-;fm.W\176M\204\f\212<\245w\151\r\150h\230eU\183\236"]} +// ConnectRequest {_username = Nothing, _password = Just +// "\143y\166C\221w?;4\243\179\248z\136\a\221\DC3\228\DC1\156,\131\183sM\171&y", _lastWill = Just (LastWill {_willRetain +// = False, _willQoS = QoS2, _willTopic = "\226", _willMsg = "\240\178+p\166\192", _willProps = +// [PropAuthenticationMethod "\SUB\161\133Q7\DEL\226G\183\168\163\195\134\201\239iO",PropTopicAliasMaximum +// 27269,PropSubscriptionIdentifier 12,PropReasonString "\157",PropAssignedClientIdentifier +// "\242nkL\v\SI=G\170\238\222\&3\tf\233\221C(\151j",PropMessageExpiryInterval 31488,PropMaximumQoS +// 47,PropSessionExpiryInterval 15063,PropSubscriptionIdentifier 27,PropRequestResponseInformation +// 156,PropRequestResponseInformation 43,PropAssignedClientIdentifier "\147\241\222E\179\&25",PropReceiveMaximum +// 72,PropReceiveMaximum 30761,PropTopicAliasMaximum 24233,PropCorrelationData +// "\146\216y\197\134\196\173\211{\aUgEE\214\EM\147\182\229",PropSharedSubscriptionAvailable 207,PropServerReference +// "?\171\170\169\249\215\229W\157\&9\SOH\237\186|",PropSubscriptionIdentifierAvailable +// 42,PropSubscriptionIdentifierAvailable 28,PropMessageExpiryInterval 11243,PropRetainAvailable 136,PropUserProperty +// "\192\178\209\202\233\216\225",PropMaximumQoS +// 209,PropSessionExpiryInterval 6705,PropResponseTopic +// "\190-F\201\158\164H\167\236=\188",PropSubscriptionIdentifierAvailable 19,PropTopicAlias +// 4285,PropSharedSubscriptionAvailable 74,PropAssignedClientIdentifier "\172\DC2%\190\136",PropReasonString +// "UP\235\245\192YI\\\201$e\225\130\ENQn<2\141",PropTopicAlias 15039,PropMaximumQoS 17,PropTopicAlias +// 22926,PropCorrelationData "\CAN\239\FS\DC4\177\164o\246&\207",PropMessageExpiryInterval 20290]} TEST(Connect5QCTest, Encode25) { uint8_t pkt[] = { - 0x10, 0xfd, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x48, 0xa0, 0xc9, 0x1, 0x26, 0x0, 0x8, 0xa0, - 0xfd, 0x89, 0xb5, 0xe0, 0xda, 0x5d, 0x9f, 0x0, 0xe, 0x1c, 0x6c, 0x6f, 0x2d, 0xb, 0xb9, 0x2, 0x13, 0x59, 0x60, - 0xd1, 0x5b, 0x4e, 0xa6, 0x2, 0x0, 0x0, 0xc, 0x5d, 0x22, 0x75, 0xbd, 0xb, 0x4, 0x13, 0x62, 0x12, 0x23, 0x50, - 0x4b, 0x3, 0x0, 0x4, 0x24, 0x57, 0x56, 0xd1, 0x2, 0x0, 0x0, 0x19, 0x88, 0x28, 0x5f, 0x8, 0x0, 0x1e, 0x86, - 0x96, 0x23, 0x14, 0x91, 0xb5, 0x2a, 0xd9, 0xcb, 0xbd, 0x30, 0xe6, 0x40, 0x2a, 0xb6, 0xb, 0xa1, 0x8b, 0x44, 0x5f, - 0x0, 0x15, 0x56, 0x1, 0xfb, 0xda, 0x91, 0x1f, 0x5e, 0x56, 0x1f, 0x0, 0x10, 0x4e, 0xd3, 0xaf, 0x29, 0x2c, 0x4b, - 0x30, 0x8a, 0x66, 0xb0, 0xd8, 0x59, 0x6a, 0x2c, 0xa6, 0x23, 0x9, 0x0, 0x5, 0x9, 0x9c, 0x80, 0x7b, 0xc7, 0x1, - 0xd0, 0x25, 0x16, 0xb, 0x1c, 0x19, 0x2f, 0x1a, 0x0, 0xb, 0x26, 0x95, 0xc7, 0xa4, 0x45, 0x26, 0x31, 0x93, 0xf8, - 0xd, 0x2c, 0x1a, 0x0, 0x1a, 0x3d, 0xee, 0x66, 0x7c, 0x72, 0x93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, 0x73, 0x9b, 0xb9, + 0xa6, 0xb8, 0xc2, 0x10, 0x36}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x1c, 0x6c, 0x6f, 0x2d, 0xb, 0xb9, 0x2, 0x13, 0x59, 0x60, 0xd1, 0x5b, 0x4e, 0xa6}; - uint8_t bytesprops0[] = {0xa0, 0xfd, 0x89, 0xb5, 0xe0, 0xda, 0x5d, 0x9f}; - uint8_t bytesprops2[] = {0x24, 0x57, 0x56, 0xd1}; - uint8_t bytesprops3[] = {0x86, 0x96, 0x23, 0x14, 0x91, 0xb5, 0x2a, 0xd9, 0xcb, 0xbd, 0x30, 0xe6, 0x40, 0x2a, 0xb6, - 0xb, 0xa1, 0x8b, 0x44, 0x5f, 0x0, 0x15, 0x56, 0x1, 0xfb, 0xda, 0x91, 0x1f, 0x5e, 0x56}; - uint8_t bytesprops4[] = {0x4e, 0xd3, 0xaf, 0x29, 0x2c, 0x4b, 0x30, 0x8a, - 0x66, 0xb0, 0xd8, 0x59, 0x6a, 0x2c, 0xa6, 0x23}; - uint8_t bytesprops5[] = {0x9, 0x9c, 0x80, 0x7b, 0xc7}; - uint8_t bytesprops6[] = {0x26, 0x95, 0xc7, 0xa4, 0x45, 0x26, 0x31, 0x93, 0xf8, 0xd, 0x2c}; - uint8_t bytesprops7[] = {0x3d, 0xee, 0x66, 0x7c, 0x72, 0x93, 0x3, 0xd7, 0xb8, 0xc1, 0x54, 0x60, 0x1b, - 0xab, 0x40, 0x8c, 0x7d, 0x73, 0xda, 0xba, 0x19, 0x55, 0x71, 0xb2, 0x52, 0xa3}; - uint8_t bytesprops9[] = {0x11, 0x25, 0xdd, 0x95}; - uint8_t bytesprops8[] = {0x5f, 0xde, 0x99, 0x65, 0x9b, 0xb8, 0x66, 0x91, 0xaf, 0x8f, - 0xe, 0x33, 0xc6, 0xe1, 0xa6, 0xa8, 0x63, 0x27, 0x4b}; + uint8_t bytesprops0[] = {0x3b, 0x59, 0x86, 0xd5, 0xdc, 0x1c, 0x91, 0x9d, 0xf7, 0xc2, 0x7, 0x94, 0xd4, 0xe4, 0x92, + 0x1d, 0x16, 0x70, 0x4b, 0x68, 0x81, 0xe, 0x52, 0xe6, 0x71, 0xf8, 0xb2, 0x3e, 0xe1}; + uint8_t bytesprops1[] = {0xbe, 0x2d, 0x46, 0xc9, 0x9e, 0xa4, 0x48, 0xa7, 0xec, 0x3d, 0xbc}; + uint8_t bytesprops2[] = {0xac, 0x12, 0x25, 0xbe, 0x88}; + uint8_t bytesprops3[] = {0x55, 0x50, 0xeb, 0xf5, 0xc0, 0x59, 0x49, 0x5c, 0xc9, + 0x24, 0x65, 0xe1, 0x82, 0x5, 0x6e, 0x3c, 0x32, 0x8d}; + uint8_t bytesprops4[] = {0x18, 0xef, 0x1c, 0x14, 0xb1, 0xa4, 0x6f, 0xf6, 0x26, 0xcf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {14, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3165}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30141}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25106}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20555}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6536}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32409}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops8}, .v = {4, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20650}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6705}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4285}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15039}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22926}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20290}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x66, 0xb4, 0x91, 0xda, 0x16, 0x6e, 0xa9, 0x97, - 0x4e, 0x8a, 0x90, 0x8, 0x91, 0xe7, 0xe5, 0xb9}; - uint8_t byteswillprops2[] = {0xc5, 0x54, 0x3a, 0x67}; - uint8_t byteswillprops1[] = {0x7c, 0x94, 0x15, 0x10, 0x98, 0xe8, 0xbb, 0xcc, 0x51, 0x3b, 0xcb, 0xe5, 0x79}; - uint8_t byteswillprops3[] = {0x3a, 0x8e, 0xcd, 0x71, 0x39, 0x4a, 0x1c, 0x56, 0x0, 0x5c, 0xc7, 0x43, - 0xa6, 0x83, 0xc2, 0xb7, 0x93, 0x2f, 0xf8, 0x23, 0x56, 0x37, 0x4b, 0x7e}; - uint8_t byteswillprops4[] = {0xad, 0xb6, 0xc3, 0xe1, 0x81, 0x81}; - uint8_t byteswillprops5[] = {0x12, 0xc1, 0xcf, 0x51, 0x10, 0x97, 0x18, 0x83, - 0x1d, 0x81, 0xc3, 0x90, 0xee, 0x3c, 0x50, 0x95}; + uint8_t byteswillprops0[] = {0x83, 0x13, 0x38, 0x6a, 0xfc, 0x2c, 0x62, 0x93, 0x35, 0xc6, 0x90}; + uint8_t byteswillprops1[] = {0xf3, 0x94, 0x24, 0x80, 0x2d, 0xd2, 0xc4, 0x5, 0xbb, 0xab, 0x5a, 0x50, 0xb2, + 0x5d, 0xf6, 0xf, 0xb6, 0xf3, 0x85, 0x53, 0x54, 0x96, 0xb0, 0x9f, 0x5f, 0x46}; + uint8_t byteswillprops2[] = {0x51, 0x6a, 0xe7, 0x8d, 0x36, 0x88, 0xcf, 0x92, 0x83, + 0x4e, 0x7f, 0xab, 0x25, 0x2b, 0xc5, 0x91, 0x27, 0x5b}; + uint8_t byteswillprops3[] = {0x7a, 0x66}; + uint8_t byteswillprops4[] = {0xc7, 0x6b, 0x80, 0x79}; + uint8_t byteswillprops5[] = {0x65, 0x92, 0xaf, 0xad, 0x79, 0xbd, 0xeb, 0x18, 0x30}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31420}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {13, (char*)&byteswillprops1}, .v = {4, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14703}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16723}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27480}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11494}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31551}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops5}}}, }; - lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6f, 0x48, 0x25, 0xb0, 0xc3, 0xf0, 0xd9, 0xea, 0x78, 0xb0, 0x5a, 0x3, 0xcc, 0xe, - 0x13, 0x7f, 0x8a, 0xb5, 0xfc, 0x1f, 0xfe, 0x93, 0xda, 0x3a, 0x92, 0xe7, 0x5c, 0x90}; - lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6e, 0x19, 0xba}; - lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x15, 0x36, 0xd6, 0x1f, 0xa6, 0x60, 0xf3, 0x21, 0x93, 0x2, 0xfe, 0x24, 0x78, 0x98, 0xdd, + 0x7c, 0x5d, 0x56, 0x12, 0x84, 0xb4, 0x7b, 0x45, 0x23, 0x2, 0x7c, 0x2e, 0xd1, 0xf4}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc8, 0xee, 0x70, 0x5b, 0xd1, 0x4e, 0x66, 0xba, + 0xd3, 0xba, 0xd5, 0xa4, 0x30, 0x9, 0xdf, 0xb0}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 18592; - uint8_t client_id_bytes[] = {0x9b, 0x6a, 0xa9, 0x34, 0x13, 0x54, 0xdb, 0x34, 0x50}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.keep_alive = 12605; + uint8_t client_id_bytes[] = {0x84, 0x87, 0x84, 0x60, 0x9, 0xee, 0xbf, 0xb8, 0x20, 0x1, 0xa2}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb7, 0xb2, 0x1b}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf, 0xf9, 0xd9, 0xf5, 0x2b, 0x94, 0xd6, 0x57, 0x34, 0xc2, + 0xa6, 0x19, 0xf8, 0xe5, 0xad, 0xdd, 0xcf, 0x21, 0xcf}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x2d, 0xcb, 0x49, 0x64}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xa2, 0xe6, 0xbb, 0x73, 0x9b, 0xb9, 0xa6, 0xb8, 0xc2, 0x10, 0x36}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9446,218 +9532,113 @@ TEST(Connect5QCTest, Encode25) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\164\207\151\149\193\237\154\&5;\151\f\187\235\141\182k?\198\208\205\150", -// _password = Just "\238\185\&5!R\163\189", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic -// = "\162r\149\182\167\158V@)qJ\240#\236\180\134\195xN", _willMsg = "y\213_\183\130", _willProps = -// [PropAuthenticationData "R\\\236\144#\137\252\195$",PropReasonString -// "Av\206\NUL\183_\206(gv\160xy\173o\231/`\134\158\203\STX\178\156s2",PropResponseTopic -// "e\DLE\244\142!t",PropAuthenticationData "\DEL\130\233",PropServerKeepAlive 14614,PropRetainAvailable -// 134,PropAuthenticationMethod -// "\RS\214\US6_!\166H\236\214\155\138C\202\135\166\225\177\244",PropSharedSubscriptionAvailable -// 79,PropMessageExpiryInterval 8665,PropAssignedClientIdentifier -// ".\186\248\224\STXs\158_\DLEk\ETB\a\141\240",PropServerReference -// "\205(4#-\199\249\135\SIbNPyM\208\161\204\229\192\v\148\DC1\159\142",PropMaximumPacketSize -// 30032,PropSubscriptionIdentifier 4,PropReasonString -// "\209:\SOH\185+\184\207\243\249\235r\210]?\235`k\254gJ\151;\202\&8_\212",PropAuthenticationData -// "\195\&1\168\FS\150\198\248\EOT\213\214\139\227T\166\&0x\DEL",PropSubscriptionIdentifier 21,PropResponseTopic -// "\f;\251r\133\b\ESC\200\219\223\ESC!\141\133\&3\EMs",PropSharedSubscriptionAvailable 79,PropPayloadFormatIndicator -// 243,PropAuthenticationData "(\188A\235r\208`\201\EM](\175t\163\238\217\160X~YK",PropReasonString -// "\131`\137\DELo#\156\223\242\DC1l\140;\218\196f$]6\"S=4\182\176\255\255\151C\ESC",PropServerReference -// "E\166\CAN",PropServerReference -// "\204p\185\183\183m\155\188\238\FS\146\179Mw)\rv\216\&38\213\EM\ACK\128}u",PropCorrelationData -// "\149\232H",PropResponseInformation "\196\ETX|\DC4Kt\142\\\183\217\198\207V\193\"*\r",PropSubscriptionIdentifier -// 25,PropResponseTopic "-\160P\189\&3\rF\142\221\DC2$\181",PropAssignedClientIdentifier "u\235"]}), _cleanSession = -// False, _keepAlive = 10272, _connID = "\171\r5?\187", _properties = [PropMaximumPacketSize 10997,PropResponseTopic -// "VZ\NULK\134\DC2\134\139T\190UA\128\&2\180\196it\181",PropTopicAlias 22484,PropServerReference "0\252\STX -// \131ic\SI\SOe\230]\132'\232\163\225\ACK\233",PropResponseTopic -// "\229?{0\245\191\175\150\NUL\226\r\223\255\171\158\178@p\168\199",PropSessionExpiryInterval 12502,PropTopicAlias -// 14906,PropMessageExpiryInterval 20156,PropAuthenticationData -// "\188\210pR\191\163(zT\168\143\243.4\152\SUB\139\253^",PropResponseInformation -// "\194\225l\143SK\251tv\181G\148\165\131",PropUserProperty -// "\DC2\178\214\143\252\244%#w0\DC2\210\SUB\177\229\bE\173\133" "\237\218",PropRequestProblemInformation -// 140,PropReceiveMaximum 19767,PropReasonString "@w\DC3\143@\STX\178^\ACK\194\158\&3\166\181",PropMessageExpiryInterval -// 3897,PropResponseTopic "\149\r\248",PropAssignedClientIdentifier "\133\DC3|l\231-\186\NAK\ESC",PropMaximumPacketSize -// 5499,PropContentType "\148\199\196\233ai\155c\USL\210\193 -// \152}X!\151\187E\DLE\183\151",PropSubscriptionIdentifierAvailable 65,PropWillDelayInterval 15667,PropRetainAvailable -// 157,PropServerKeepAlive 32012,PropMessageExpiryInterval 23157,PropMaximumPacketSize -// 13539,PropSubscriptionIdentifierAvailable 1,PropRequestProblemInformation 232,PropSubscriptionIdentifier 18]} +// ConnectRequest {_username = Just "\222\FS\NUL", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "\236?v#\231\182\221\157[=\139|\191\209\208\147\164?\221=)\ETB?\217\223e", _willMsg = +// "n\212", _willProps = [PropRequestResponseInformation 94,PropPayloadFormatIndicator 132,PropContentType +// "p\128\239\STX\229\200",PropCorrelationData +// "\168\239}\235\219\230\139\&9\232L\237\181\208P\226\SYN\"\213zF",PropSharedSubscriptionAvailable 131,PropMaximumQoS +// 210,PropSessionExpiryInterval 31642]}), _cleanSession = False, _keepAlive = 12313, _connID = "%W\235 +// )\183\218\188oO\152j\237\b!", _properties = [PropCorrelationData "",PropUserProperty +// "\219\242\DEL\229\232\&8\DC4\147\200\214@O0\216<\234\&4\159\204\231\139:^\204" +// "![s\250\196\NUL@\239?2\133\DC2\246\238\195V",PropTopicAliasMaximum 15720,PropMaximumPacketSize +// 32521,PropAuthenticationMethod "V",PropContentType +// "\228wB\STX\194\206%\CAN\253;\136\215\&4-\139\205\178\DC3_\234\146\226\199\ENQ",PropAuthenticationMethod +// "\t\169\192\150\246\214H\SYN\DC1`",PropUserProperty +// "\164\135\171\CAN\208\134:\172\201\184\ENQ\150s\183\181\241\202<\203\148q\249\t\148\137\176Ka\255\n" +// "\207\193\157\215D\164\FS{@\214\n",PropSharedSubscriptionAvailable 210,PropPayloadFormatIndicator +// 250,PropAuthenticationMethod "\140\250\165x\183l/)",PropServerKeepAlive 15023,PropServerKeepAlive +// 6531,PropUserProperty "\218 I\NULQ\196" "\EM\168\134\161z5\RSV\243\NAKZ\172e\219c\167"]} TEST(Connect5QCTest, Encode26) { uint8_t pkt[] = { - 0x10, 0xb6, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x28, 0x20, 0x81, 0x2, 0x27, 0x0, 0x0, 0x2a, - 0xf5, 0x8, 0x0, 0x13, 0x56, 0x5a, 0x0, 0x4b, 0x86, 0x12, 0x86, 0x8b, 0x54, 0xbe, 0x55, 0x41, 0x80, 0x32, 0xb4, - 0xc4, 0x69, 0x74, 0xb5, 0x23, 0x57, 0xd4, 0x1c, 0x0, 0x13, 0x30, 0xfc, 0x2, 0x20, 0x83, 0x69, 0x63, 0xf, 0xe, - 0x65, 0xe6, 0x5d, 0x84, 0x27, 0xe8, 0xa3, 0xe1, 0x6, 0xe9, 0x8, 0x0, 0x14, 0xe5, 0x3f, 0x7b, 0x30, 0xf5, 0xbf, - 0xaf, 0x96, 0x0, 0xe2, 0xd, 0xdf, 0xff, 0xab, 0x9e, 0xb2, 0x40, 0x70, 0xa8, 0xc7, 0x11, 0x0, 0x0, 0x30, 0xd6, - 0x23, 0x3a, 0x3a, 0x2, 0x0, 0x0, 0x4e, 0xbc, 0x16, 0x0, 0x13, 0xbc, 0xd2, 0x70, 0x52, 0xbf, 0xa3, 0x28, 0x7a, - 0x54, 0xa8, 0x8f, 0xf3, 0x2e, 0x34, 0x98, 0x1a, 0x8b, 0xfd, 0x5e, 0x1a, 0x0, 0xe, 0xc2, 0xe1, 0x6c, 0x8f, 0x53, - 0x4b, 0xfb, 0x74, 0x76, 0xb5, 0x47, 0x94, 0xa5, 0x83, 0x26, 0x0, 0x13, 0x12, 0xb2, 0xd6, 0x8f, 0xfc, 0xf4, 0x25, - 0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0x5a, 0xac, 0x65, 0xdb, 0x63, 0xa7, + 0x0, 0xf, 0x25, 0x57, 0xeb, 0x20, 0x29, 0xb7, 0xda, 0xbc, 0x6f, 0x4f, 0x98, 0x6a, 0xed, 0x8, 0x21, 0x2d, 0x19, + 0x5e, 0x1, 0x84, 0x3, 0x0, 0x6, 0x70, 0x80, 0xef, 0x2, 0xe5, 0xc8, 0x9, 0x0, 0x14, 0xa8, 0xef, 0x7d, 0xeb, + 0xdb, 0xe6, 0x8b, 0x39, 0xe8, 0x4c, 0xed, 0xb5, 0xd0, 0x50, 0xe2, 0x16, 0x22, 0xd5, 0x7a, 0x46, 0x2a, 0x83, 0x24, + 0xd2, 0x11, 0x0, 0x0, 0x7b, 0x9a, 0x0, 0x1a, 0xec, 0x3f, 0x76, 0x23, 0xe7, 0xb6, 0xdd, 0x9d, 0x5b, 0x3d, 0x8b, + 0x7c, 0xbf, 0xd1, 0xd0, 0x93, 0xa4, 0x3f, 0xdd, 0x3d, 0x29, 0x17, 0x3f, 0xd9, 0xdf, 0x65, 0x0, 0x2, 0x6e, 0xd4, + 0x0, 0x3, 0xde, 0x1c, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x56, 0x5a, 0x0, 0x4b, 0x86, 0x12, 0x86, 0x8b, 0x54, 0xbe, - 0x55, 0x41, 0x80, 0x32, 0xb4, 0xc4, 0x69, 0x74, 0xb5}; - uint8_t bytesprops1[] = {0x30, 0xfc, 0x2, 0x20, 0x83, 0x69, 0x63, 0xf, 0xe, 0x65, - 0xe6, 0x5d, 0x84, 0x27, 0xe8, 0xa3, 0xe1, 0x6, 0xe9}; - uint8_t bytesprops2[] = {0xe5, 0x3f, 0x7b, 0x30, 0xf5, 0xbf, 0xaf, 0x96, 0x0, 0xe2, - 0xd, 0xdf, 0xff, 0xab, 0x9e, 0xb2, 0x40, 0x70, 0xa8, 0xc7}; - uint8_t bytesprops3[] = {0xbc, 0xd2, 0x70, 0x52, 0xbf, 0xa3, 0x28, 0x7a, 0x54, 0xa8, - 0x8f, 0xf3, 0x2e, 0x34, 0x98, 0x1a, 0x8b, 0xfd, 0x5e}; - uint8_t bytesprops4[] = {0xc2, 0xe1, 0x6c, 0x8f, 0x53, 0x4b, 0xfb, 0x74, 0x76, 0xb5, 0x47, 0x94, 0xa5, 0x83}; - uint8_t bytesprops6[] = {0xed, 0xda}; - uint8_t bytesprops5[] = {0x12, 0xb2, 0xd6, 0x8f, 0xfc, 0xf4, 0x25, 0x23, 0x77, 0x30, - 0x12, 0xd2, 0x1a, 0xb1, 0xe5, 0x8, 0x45, 0xad, 0x85}; - uint8_t bytesprops7[] = {0x40, 0x77, 0x13, 0x8f, 0x40, 0x2, 0xb2, 0x5e, 0x6, 0xc2, 0x9e, 0x33, 0xa6, 0xb5}; - uint8_t bytesprops8[] = {0x95, 0xd, 0xf8}; - uint8_t bytesprops9[] = {0x85, 0x13, 0x7c, 0x6c, 0xe7, 0x2d, 0xba, 0x15, 0x1b}; - uint8_t bytesprops10[] = {0x94, 0xc7, 0xc4, 0xe9, 0x61, 0x69, 0x9b, 0x63, 0x1f, 0x4c, 0xd2, 0xc1, - 0x20, 0x98, 0x7d, 0x58, 0x21, 0x97, 0xbb, 0x45, 0x10, 0xb7, 0x97}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops2[] = {0x21, 0x5b, 0x73, 0xfa, 0xc4, 0x0, 0x40, 0xef, + 0x3f, 0x32, 0x85, 0x12, 0xf6, 0xee, 0xc3, 0x56}; + uint8_t bytesprops1[] = {0xdb, 0xf2, 0x7f, 0xe5, 0xe8, 0x38, 0x14, 0x93, 0xc8, 0xd6, 0x40, 0x4f, + 0x30, 0xd8, 0x3c, 0xea, 0x34, 0x9f, 0xcc, 0xe7, 0x8b, 0x3a, 0x5e, 0xcc}; + uint8_t bytesprops3[] = {0x56}; + uint8_t bytesprops4[] = {0xe4, 0x77, 0x42, 0x2, 0xc2, 0xce, 0x25, 0x18, 0xfd, 0x3b, 0x88, 0xd7, + 0x34, 0x2d, 0x8b, 0xcd, 0xb2, 0x13, 0x5f, 0xea, 0x92, 0xe2, 0xc7, 0x5}; + uint8_t bytesprops5[] = {0x9, 0xa9, 0xc0, 0x96, 0xf6, 0xd6, 0x48, 0x16, 0x11, 0x60}; + uint8_t bytesprops7[] = {0xcf, 0xc1, 0x9d, 0xd7, 0x44, 0xa4, 0x1c, 0x7b, 0x40, 0xd6, 0xa}; + uint8_t bytesprops6[] = {0xa4, 0x87, 0xab, 0x18, 0xd0, 0x86, 0x3a, 0xac, 0xc9, 0xb8, 0x5, 0x96, 0x73, 0xb7, 0xb5, + 0xf1, 0xca, 0x3c, 0xcb, 0x94, 0x71, 0xf9, 0x9, 0x94, 0x89, 0xb0, 0x4b, 0x61, 0xff, 0xa}; + uint8_t bytesprops8[] = {0x8c, 0xfa, 0xa5, 0x78, 0xb7, 0x6c, 0x2f, 0x29}; + uint8_t bytesprops10[] = {0x19, 0xa8, 0x86, 0xa1, 0x7a, 0x35, 0x1e, 0x56, + 0xf3, 0x15, 0x5a, 0xac, 0x65, 0xdb, 0x63, 0xa7}; + uint8_t bytesprops9[] = {0xda, 0x20, 0x49, 0x0, 0x51, 0xc4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10997}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22484}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12502}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14906}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20156}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops5}, .v = {2, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19767}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3897}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5499}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15667}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32012}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23157}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13539}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops1}, .v = {16, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15720}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32521}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops6}, .v = {11, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15023}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6531}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops9}, .v = {16, (char*)&bytesprops10}}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x52, 0x5c, 0xec, 0x90, 0x23, 0x89, 0xfc, 0xc3, 0x24}; - uint8_t byteswillprops1[] = {0x41, 0x76, 0xce, 0x0, 0xb7, 0x5f, 0xce, 0x28, 0x67, 0x76, 0xa0, 0x78, 0x79, - 0xad, 0x6f, 0xe7, 0x2f, 0x60, 0x86, 0x9e, 0xcb, 0x2, 0xb2, 0x9c, 0x73, 0x32}; - uint8_t byteswillprops2[] = {0x65, 0x10, 0xf4, 0x8e, 0x21, 0x74}; - uint8_t byteswillprops3[] = {0x7f, 0x82, 0xe9}; - uint8_t byteswillprops4[] = {0x1e, 0xd6, 0x1f, 0x36, 0x5f, 0x21, 0xa6, 0x48, 0xec, 0xd6, - 0x9b, 0x8a, 0x43, 0xca, 0x87, 0xa6, 0xe1, 0xb1, 0xf4}; - uint8_t byteswillprops5[] = {0x2e, 0xba, 0xf8, 0xe0, 0x2, 0x73, 0x9e, 0x5f, 0x10, 0x6b, 0x17, 0x7, 0x8d, 0xf0}; - uint8_t byteswillprops6[] = {0xcd, 0x28, 0x34, 0x23, 0x2d, 0xc7, 0xf9, 0x87, 0xf, 0x62, 0x4e, 0x50, - 0x79, 0x4d, 0xd0, 0xa1, 0xcc, 0xe5, 0xc0, 0xb, 0x94, 0x11, 0x9f, 0x8e}; - uint8_t byteswillprops7[] = {0xd1, 0x3a, 0x1, 0xb9, 0x2b, 0xb8, 0xcf, 0xf3, 0xf9, 0xeb, 0x72, 0xd2, 0x5d, - 0x3f, 0xeb, 0x60, 0x6b, 0xfe, 0x67, 0x4a, 0x97, 0x3b, 0xca, 0x38, 0x5f, 0xd4}; - uint8_t byteswillprops8[] = {0xc3, 0x31, 0xa8, 0x1c, 0x96, 0xc6, 0xf8, 0x4, 0xd5, - 0xd6, 0x8b, 0xe3, 0x54, 0xa6, 0x30, 0x78, 0x7f}; - uint8_t byteswillprops9[] = {0xc, 0x3b, 0xfb, 0x72, 0x85, 0x8, 0x1b, 0xc8, 0xdb, - 0xdf, 0x1b, 0x21, 0x8d, 0x85, 0x33, 0x19, 0x73}; - uint8_t byteswillprops10[] = {0x28, 0xbc, 0x41, 0xeb, 0x72, 0xd0, 0x60, 0xc9, 0x19, 0x5d, 0x28, - 0xaf, 0x74, 0xa3, 0xee, 0xd9, 0xa0, 0x58, 0x7e, 0x59, 0x4b}; - uint8_t byteswillprops11[] = {0x83, 0x60, 0x89, 0x7f, 0x6f, 0x23, 0x9c, 0xdf, 0xf2, 0x11, - 0x6c, 0x8c, 0x3b, 0xda, 0xc4, 0x66, 0x24, 0x5d, 0x36, 0x22, - 0x53, 0x3d, 0x34, 0xb6, 0xb0, 0xff, 0xff, 0x97, 0x43, 0x1b}; - uint8_t byteswillprops12[] = {0x45, 0xa6, 0x18}; - uint8_t byteswillprops13[] = {0xcc, 0x70, 0xb9, 0xb7, 0xb7, 0x6d, 0x9b, 0xbc, 0xee, 0x1c, 0x92, 0xb3, 0x4d, - 0x77, 0x29, 0xd, 0x76, 0xd8, 0x33, 0x38, 0xd5, 0x19, 0x6, 0x80, 0x7d, 0x75}; - uint8_t byteswillprops14[] = {0x95, 0xe8, 0x48}; - uint8_t byteswillprops15[] = {0xc4, 0x3, 0x7c, 0x14, 0x4b, 0x74, 0x8e, 0x5c, 0xb7, - 0xd9, 0xc6, 0xcf, 0x56, 0xc1, 0x22, 0x2a, 0xd}; - uint8_t byteswillprops16[] = {0x2d, 0xa0, 0x50, 0xbd, 0x33, 0xd, 0x46, 0x8e, 0xdd, 0x12, 0x24, 0xb5}; - uint8_t byteswillprops17[] = {0x75, 0xeb}; + uint8_t byteswillprops0[] = {0x70, 0x80, 0xef, 0x2, 0xe5, 0xc8}; + uint8_t byteswillprops1[] = {0xa8, 0xef, 0x7d, 0xeb, 0xdb, 0xe6, 0x8b, 0x39, 0xe8, 0x4c, + 0xed, 0xb5, 0xd0, 0x50, 0xe2, 0x16, 0x22, 0xd5, 0x7a, 0x46}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14614}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8665}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30032}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 4}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops12}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops13}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&byteswillprops14}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&byteswillprops15}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&byteswillprops16}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops17}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31642}}, }; - lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa2, 0x72, 0x95, 0xb6, 0xa7, 0x9e, 0x56, 0x40, 0x29, 0x71, - 0x4a, 0xf0, 0x23, 0xec, 0xb4, 0x86, 0xc3, 0x78, 0x4e}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x79, 0xd5, 0x5f, 0xb7, 0x82}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xec, 0x3f, 0x76, 0x23, 0xe7, 0xb6, 0xdd, 0x9d, 0x5b, 0x3d, 0x8b, 0x7c, 0xbf, + 0xd1, 0xd0, 0x93, 0xa4, 0x3f, 0xdd, 0x3d, 0x29, 0x17, 0x3f, 0xd9, 0xdf, 0x65}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6e, 0xd4}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 10272; - uint8_t client_id_bytes[] = {0xab, 0xd, 0x35, 0x3f, 0xbb}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.keep_alive = 12313; + uint8_t client_id_bytes[] = {0x25, 0x57, 0xeb, 0x20, 0x29, 0xb7, 0xda, 0xbc, 0x6f, 0x4f, 0x98, 0x6a, 0xed, 0x8, 0x21}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa4, 0xcf, 0x97, 0x95, 0xc1, 0xed, 0x9a, 0x35, 0x3b, 0x97, 0xc, - 0xbb, 0xeb, 0x8d, 0xb6, 0x6b, 0x3f, 0xc6, 0xd0, 0xcd, 0x96}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xde, 0x1c, 0x0}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xee, 0xb9, 0x35, 0x21, 0x52, 0xa3, 0xbd}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9666,137 +9647,99 @@ TEST(Connect5QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS0, _willTopic = "\SIj\176\132r\238\172\184r\158pjf\GS\159\&7\185\DEL\211", _willMsg = "", _willProps = -// [PropReceiveMaximum 4017,PropAuthenticationMethod -// "\206\168\167;\232\140\206,\145\144|\f\236",PropAssignedClientIdentifier -// "\DC1O\165O\143\"\165\254\165\247\137X\STX\186\ETX|I\233\&18-",PropServerReference -// "\164u\252\185\r\158\162\t\138\205>\"\ACK\193\196\169S\NAK\223\141\DELg",PropTopicAlias 12500,PropReceiveMaximum -// 14890,PropReceiveMaximum 3217,PropServerKeepAlive 8194,PropReasonString "\184",PropPayloadFormatIndicator -// 210,PropSubscriptionIdentifierAvailable 134,PropResponseInformation -// "\242\217\174[\237\165f6\169\EOT\213\199\197J\228\207",PropServerReference -// "7Q\128\143\234_G\221Q\198\229\\\EOT\166\254\136[\211_\b\199",PropWildcardSubscriptionAvailable 165]}), _cleanSession -// = False, _keepAlive = 10342, _connID = "F/\a\165\170Bk\248\200\ENQ\199\172\&4\128", _properties = [PropUserProperty -// "\RS\ESCZ\205\FS\218\177\250" -// "\198\DC4\DC3\162:\DC4\165B\243\195.\218\FS;\152h\156.\143O\237\176\203\230\&4\197\t}\210",PropReceiveMaximum -// 19041,PropCorrelationData -// "\242\ESC\154\251\US\238\\\191\234$\FS\173\164V\EOT\ETXn\219\151Y\DEL[\227\202\149\177\245\238",PropSubscriptionIdentifierAvailable -// 221,PropResponseTopic -// "\223&\184=>\NULF?\SO\129\141\216\218$\DC3~\250F%=E<\219e'\235\200",PropAssignedClientIdentifier -// "F\176\255\138\130\ENQ\FS1\\@n\218\251\STX",PropRequestProblemInformation 146,PropAuthenticationMethod -// "\210\190\248\ETB>x1'\246*BM\ESC\174W",PropReasonString -// "\217\229\166\165\243\GS\240\181|\143Y\GS\t\169*\US\US\136\135\156W\166\131\145*\130\168'",PropWildcardSubscriptionAvailable -// 143,PropSubscriptionIdentifierAvailable 39,PropMaximumQoS 235,PropWildcardSubscriptionAvailable -// 236,PropMaximumPacketSize 22864,PropUserProperty "\239\ENQ0f" "G\156}\145N\166 -// ]\197\223\a\226\163\200W\147}s\217\EM\145\170|\202\t",PropWildcardSubscriptionAvailable 16,PropTopicAlias 18534]} +// ConnectRequest {_username = Nothing, _password = Just "\ENQ\177\248\150\234\US\132\246q", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "\183\FS\DC1\132\182jmFH\GS\201\141\226\&3\n", _willMsg = +// "\134\204\FS{\151\206b\190e\177\149\v\146\182\240\197\189NN\183\242\207\\BM\fs\198H", _willProps = +// [PropServerKeepAlive 253,PropWillDelayInterval 12369,PropAuthenticationMethod "6"]}), _cleanSession = True, +// _keepAlive = 13514, _connID = "\161 \149\244\226\242\217\139I p\234\"\249\DLE\216>p\SOV\CAN\207\131", _properties = +// [PropAuthenticationData +// "~\223\208\175\211\192iA\151\215\172P\184\236\142OE\201Y\204iO\225\209\219VY\203",PropUserProperty +// "E\208\251\CAN\177J\CAN\\\222lb&\194>\230\158" +// "\226\147\172\156B\153\226x\SOH\158\ETXU\GS\193\188Gt+\n\237-.u\133\149",PropTopicAliasMaximum +// 10312,PropRequestResponseInformation 21,PropServerKeepAlive 7697,PropServerReference +// "X\219",PropAssignedClientIdentifier +// "VJ\ENQ\167\243}\244\\\204k\158}CO\RSg\206$\143\220\180E\184\176\234\174\131\199\180",PropServerReference +// "\200\&8\251e\205\186v\SYNf\128\227\SYN8\141",PropTopicAliasMaximum 16471,PropTopicAlias 28347,PropServerKeepAlive +// 11503,PropAuthenticationData "\153U\163\173\234J\243\188\&2c\150\233"]} TEST(Connect5QCTest, Encode27) { uint8_t pkt[] = { - 0x10, 0x9e, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x4, 0x28, 0x66, 0xe4, 0x1, 0x26, 0x0, 0x8, 0x1e, - 0x1b, 0x5a, 0xcd, 0x1c, 0xda, 0xb1, 0xfa, 0x0, 0x1d, 0xc6, 0x14, 0x13, 0xa2, 0x3a, 0x14, 0xa5, 0x42, 0xf3, 0xc3, - 0x2e, 0xda, 0x1c, 0x3b, 0x98, 0x68, 0x9c, 0x2e, 0x8f, 0x4f, 0xed, 0xb0, 0xcb, 0xe6, 0x34, 0xc5, 0x9, 0x7d, 0xd2, - 0x21, 0x4a, 0x61, 0x9, 0x0, 0x1c, 0xf2, 0x1b, 0x9a, 0xfb, 0x1f, 0xee, 0x5c, 0xbf, 0xea, 0x24, 0x1c, 0xad, 0xa4, - 0x56, 0x4, 0x3, 0x6e, 0xdb, 0x97, 0x59, 0x7f, 0x5b, 0xe3, 0xca, 0x95, 0xb1, 0xf5, 0xee, 0x29, 0xdd, 0x8, 0x0, - 0x1b, 0xdf, 0x26, 0xb8, 0x3d, 0x3e, 0x0, 0x46, 0x3f, 0xe, 0x81, 0x8d, 0xd8, 0xda, 0x24, 0x13, 0x7e, 0xfa, 0x46, - 0x25, 0x3d, 0x45, 0x3c, 0xdb, 0x65, 0x27, 0xeb, 0xc8, 0x12, 0x0, 0xe, 0x46, 0xb0, 0xff, 0x8a, 0x82, 0x5, 0x1c, - 0x31, 0x5c, 0x40, 0x6e, 0xda, 0xfb, 0x2, 0x17, 0x92, 0x15, 0x0, 0xf, 0xd2, 0xbe, 0xf8, 0x17, 0x3e, 0x78, 0x31, - 0x27, 0xf6, 0x2a, 0x42, 0x4d, 0x1b, 0xae, 0x57, 0x1f, 0x0, 0x1c, 0xd9, 0xe5, 0xa6, 0xa5, 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, 0x1e, 0x67, 0xce, 0x24, 0x8f, 0xdc, 0xb4, 0x45, 0xb8, 0xb0, 0xea, + 0xae, 0x83, 0xc7, 0xb4, 0x1c, 0x0, 0xe, 0xc8, 0x38, 0xfb, 0x65, 0xcd, 0xba, 0x76, 0x16, 0x66, 0x80, 0xe3, 0x16, + 0x38, 0x8d, 0x22, 0x40, 0x57, 0x23, 0x6e, 0xbb, 0x13, 0x2c, 0xef, 0x16, 0x0, 0xc, 0x99, 0x55, 0xa3, 0xad, 0xea, + 0x4a, 0xf3, 0xbc, 0x32, 0x63, 0x96, 0xe9, 0x0, 0x17, 0xa1, 0x20, 0x95, 0xf4, 0xe2, 0xf2, 0xd9, 0x8b, 0x49, 0x20, + 0x70, 0xea, 0x22, 0xf9, 0x10, 0xd8, 0x3e, 0x70, 0xe, 0x56, 0x18, 0xcf, 0x83, 0xc, 0x13, 0x0, 0xfd, 0x18, 0x0, + 0x0, 0x30, 0x51, 0x15, 0x0, 0x1, 0x36, 0x0, 0xf, 0xb7, 0x1c, 0x11, 0x84, 0xb6, 0x6a, 0x6d, 0x46, 0x48, 0x1d, + 0xc9, 0x8d, 0xe2, 0x33, 0xa, 0x0, 0x1d, 0x86, 0xcc, 0x1c, 0x7b, 0x97, 0xce, 0x62, 0xbe, 0x65, 0xb1, 0x95, 0xb, + 0x92, 0xb6, 0xf0, 0xc5, 0xbd, 0x4e, 0x4e, 0xb7, 0xf2, 0xcf, 0x5c, 0x42, 0x4d, 0xc, 0x73, 0xc6, 0x48, 0x0, 0x9, + 0x5, 0xb1, 0xf8, 0x96, 0xea, 0x1f, 0x84, 0xf6, 0x71}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0xc6, 0x14, 0x13, 0xa2, 0x3a, 0x14, 0xa5, 0x42, 0xf3, 0xc3, 0x2e, 0xda, 0x1c, 0x3b, 0x98, - 0x68, 0x9c, 0x2e, 0x8f, 0x4f, 0xed, 0xb0, 0xcb, 0xe6, 0x34, 0xc5, 0x9, 0x7d, 0xd2}; - uint8_t bytesprops0[] = {0x1e, 0x1b, 0x5a, 0xcd, 0x1c, 0xda, 0xb1, 0xfa}; - uint8_t bytesprops2[] = {0xf2, 0x1b, 0x9a, 0xfb, 0x1f, 0xee, 0x5c, 0xbf, 0xea, 0x24, 0x1c, 0xad, 0xa4, 0x56, - 0x4, 0x3, 0x6e, 0xdb, 0x97, 0x59, 0x7f, 0x5b, 0xe3, 0xca, 0x95, 0xb1, 0xf5, 0xee}; - uint8_t bytesprops3[] = {0xdf, 0x26, 0xb8, 0x3d, 0x3e, 0x0, 0x46, 0x3f, 0xe, 0x81, 0x8d, 0xd8, 0xda, 0x24, - 0x13, 0x7e, 0xfa, 0x46, 0x25, 0x3d, 0x45, 0x3c, 0xdb, 0x65, 0x27, 0xeb, 0xc8}; - uint8_t bytesprops4[] = {0x46, 0xb0, 0xff, 0x8a, 0x82, 0x5, 0x1c, 0x31, 0x5c, 0x40, 0x6e, 0xda, 0xfb, 0x2}; - uint8_t bytesprops5[] = {0xd2, 0xbe, 0xf8, 0x17, 0x3e, 0x78, 0x31, 0x27, 0xf6, 0x2a, 0x42, 0x4d, 0x1b, 0xae, 0x57}; - uint8_t bytesprops6[] = {0xd9, 0xe5, 0xa6, 0xa5, 0xf3, 0x1d, 0xf0, 0xb5, 0x7c, 0x8f, 0x59, 0x1d, 0x9, 0xa9, - 0x2a, 0x1f, 0x1f, 0x88, 0x87, 0x9c, 0x57, 0xa6, 0x83, 0x91, 0x2a, 0x82, 0xa8, 0x27}; - uint8_t bytesprops8[] = {0x47, 0x9c, 0x7d, 0x91, 0x4e, 0xa6, 0x20, 0x5d, 0xc5, 0xdf, 0x7, 0xe2, 0xa3, - 0xc8, 0x57, 0x93, 0x7d, 0x73, 0xd9, 0x19, 0x91, 0xaa, 0x7c, 0xca, 0x9}; - uint8_t bytesprops7[] = {0xef, 0x5, 0x30, 0x66}; + uint8_t bytesprops0[] = {0x7e, 0xdf, 0xd0, 0xaf, 0xd3, 0xc0, 0x69, 0x41, 0x97, 0xd7, 0xac, 0x50, 0xb8, 0xec, + 0x8e, 0x4f, 0x45, 0xc9, 0x59, 0xcc, 0x69, 0x4f, 0xe1, 0xd1, 0xdb, 0x56, 0x59, 0xcb}; + uint8_t bytesprops2[] = {0xe2, 0x93, 0xac, 0x9c, 0x42, 0x99, 0xe2, 0x78, 0x1, 0x9e, 0x3, 0x55, 0x1d, + 0xc1, 0xbc, 0x47, 0x74, 0x2b, 0xa, 0xed, 0x2d, 0x2e, 0x75, 0x85, 0x95}; + uint8_t bytesprops1[] = {0x45, 0xd0, 0xfb, 0x18, 0xb1, 0x4a, 0x18, 0x5c, + 0xde, 0x6c, 0x62, 0x26, 0xc2, 0x3e, 0xe6, 0x9e}; + uint8_t bytesprops3[] = {0x58, 0xdb}; + uint8_t bytesprops4[] = {0x56, 0x4a, 0x5, 0xa7, 0xf3, 0x7d, 0xf4, 0x5c, 0xcc, 0x6b, 0x9e, 0x7d, 0x43, 0x4f, 0x1e, + 0x67, 0xce, 0x24, 0x8f, 0xdc, 0xb4, 0x45, 0xb8, 0xb0, 0xea, 0xae, 0x83, 0xc7, 0xb4}; + uint8_t bytesprops5[] = {0xc8, 0x38, 0xfb, 0x65, 0xcd, 0xba, 0x76, 0x16, 0x66, 0x80, 0xe3, 0x16, 0x38, 0x8d}; + uint8_t bytesprops6[] = {0x99, 0x55, 0xa3, 0xad, 0xea, 0x4a, 0xf3, 0xbc, 0x32, 0x63, 0x96, 0xe9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {29, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19041}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22864}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops7}, .v = {25, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18534}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {25, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10312}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7697}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16471}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28347}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11503}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xce, 0xa8, 0xa7, 0x3b, 0xe8, 0x8c, 0xce, 0x2c, 0x91, 0x90, 0x7c, 0xc, 0xec}; - uint8_t byteswillprops1[] = {0x11, 0x4f, 0xa5, 0x4f, 0x8f, 0x22, 0xa5, 0xfe, 0xa5, 0xf7, 0x89, - 0x58, 0x2, 0xba, 0x3, 0x7c, 0x49, 0xe9, 0x31, 0x38, 0x2d}; - uint8_t byteswillprops2[] = {0xa4, 0x75, 0xfc, 0xb9, 0xd, 0x9e, 0xa2, 0x9, 0x8a, 0xcd, 0x3e, - 0x22, 0x6, 0xc1, 0xc4, 0xa9, 0x53, 0x15, 0xdf, 0x8d, 0x7f, 0x67}; - uint8_t byteswillprops3[] = {0xb8}; - uint8_t byteswillprops4[] = {0xf2, 0xd9, 0xae, 0x5b, 0xed, 0xa5, 0x66, 0x36, - 0xa9, 0x4, 0xd5, 0xc7, 0xc5, 0x4a, 0xe4, 0xcf}; - uint8_t byteswillprops5[] = {0x37, 0x51, 0x80, 0x8f, 0xea, 0x5f, 0x47, 0xdd, 0x51, 0xc6, 0xe5, - 0x5c, 0x4, 0xa6, 0xfe, 0x88, 0x5b, 0xd3, 0x5f, 0x8, 0xc7}; + uint8_t byteswillprops0[] = {0x36}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4017}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12500}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14890}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3217}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8194}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 253}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12369}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops0}}}, }; - lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf, 0x6a, 0xb0, 0x84, 0x72, 0xee, 0xac, 0xb8, 0x72, 0x9e, - 0x70, 0x6a, 0x66, 0x1d, 0x9f, 0x37, 0xb9, 0x7f, 0xd3}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb7, 0x1c, 0x11, 0x84, 0xb6, 0x6a, 0x6d, 0x46, + 0x48, 0x1d, 0xc9, 0x8d, 0xe2, 0x33, 0xa}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x86, 0xcc, 0x1c, 0x7b, 0x97, 0xce, 0x62, 0xbe, 0x65, 0xb1, + 0x95, 0xb, 0x92, 0xb6, 0xf0, 0xc5, 0xbd, 0x4e, 0x4e, 0xb7, + 0xf2, 0xcf, 0x5c, 0x42, 0x4d, 0xc, 0x73, 0xc6, 0x48}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS2; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 10342; - uint8_t client_id_bytes[] = {0x46, 0x2f, 0x7, 0xa5, 0xaa, 0x42, 0x6b, 0xf8, 0xc8, 0x5, 0xc7, 0xac, 0x34, 0x80}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 13514; + uint8_t client_id_bytes[] = {0xa1, 0x20, 0x95, 0xf4, 0xe2, 0xf2, 0xd9, 0x8b, 0x49, 0x20, 0x70, 0xea, + 0x22, 0xf9, 0x10, 0xd8, 0x3e, 0x70, 0xe, 0x56, 0x18, 0xcf, 0x83}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t password_bytes[] = {0x5, 0xb1, 0xf8, 0x96, 0xea, 0x1f, 0x84, 0xf6, 0x71}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9805,155 +9748,178 @@ TEST(Connect5QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\177,\US\162\249\rU", _password = Just "\186$\184J\CAN:\210T\160t\185\242", -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\248\192cB\223\ACK\132s!q\246\236pQ-R", _willMsg = "@\152\ETBp\180{\SI\148\180\&8\r\230\252vY\151]\223/\232&n", -// _willProps = [PropCorrelationData "\178\203fb\158\n\239\218\DC2\164\199\133\164\130\GS\SO\213",PropTopicAliasMaximum -// 32637,PropSharedSubscriptionAvailable 101,PropReasonString "Z|\141~x",PropAuthenticationData -// "{*v\171vl\186\&2\191U\SI\223\170\196\n\129\185\249\246\253Q\EOT\203j",PropRequestProblemInformation -// 201,PropAuthenticationMethod "\\z\201\239\DC3\185\218B\ETB\ETX\237\176\211m\161`",PropRequestProblemInformation -// 115,PropResponseInformation "hY\161m\164\US\221\ETBpI\203;a\223\230\155\NUL\232",PropRequestProblemInformation -// 25,PropPayloadFormatIndicator 245,PropMessageExpiryInterval 23460,PropSessionExpiryInterval 989,PropTopicAlias -// 10792,PropMaximumPacketSize 20351,PropSharedSubscriptionAvailable 225]}), _cleanSession = True, _keepAlive = 1497, -// _connID = "\ENQfB\178\EOT\DLE\139\233\169H\233\GS[", _properties = [PropResponseTopic -// "}\204\DC2B\159\NAK\157r\222[;\150\193UE\183\nIE\176\158\129\192,\158\&1\188\SUB\193",PropTopicAlias -// 19059,PropAuthenticationMethod "=Gp\247\239\214A\203\133\255\133ss@\249&|\133\178@\244\236/Z\190",PropUserProperty -// "\138\ACK\167\217\209F\179\232\164\GSw\209rgT\NAKQ\193\224\178\176M" -// ")\246\DLE;\207\192BLHX\239\160l\DELp\136\f^_F=\143",PropMaximumPacketSize 14420,PropSessionExpiryInterval -// 695,PropServerReference "{1\174\242-\131\182\SO\156\193'\EOTY\DEL;\131_",PropRequestProblemInformation -// 218,PropSubscriptionIdentifier 20,PropMessageExpiryInterval 757,PropCorrelationData -// "\170\RS\210\161H\195\SO\EM\224\247\251\211\143\153G\DLE(\150\202",PropSessionExpiryInterval -// 10859,PropPayloadFormatIndicator 138,PropRequestProblemInformation 9,PropUserProperty -// "\166\140\&0\t\245~\STX\156N\157,_I\RS;\141" -// "\128\&8\229\128\&4?h\145\a\128\&25\129",PropSubscriptionIdentifierAvailable 71,PropSubscriptionIdentifierAvailable -// 24,PropSubscriptionIdentifier 22,PropTopicAlias 25715,PropRequestProblemInformation 58,PropRequestProblemInformation -// 211,PropMessageExpiryInterval 15137,PropTopicAlias 18099]} +// ConnectRequest {_username = Just "\218r\168\139R\217\209\a@\135\239\135\152\130\140\156\230\152>\156\160", _password +// = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\220\218\137\179z\158\vc\CAN\128\SUBU\DC3\175n\201P\218B", _willMsg = +// "\218\174\233=\151\&7\204\204\181\t\146\180O\189\173.`\244\151\180I@0\252", _willProps = [PropServerReference +// "\185+\ACKp,\DC348\155\178'\197\r\252[\191\ENQ",PropMessageExpiryInterval 16461,PropWillDelayInterval +// 14555,PropSharedSubscriptionAvailable 229,PropServerReference "",PropRequestResponseInformation +// 34,PropSubscriptionIdentifier 24,PropMessageExpiryInterval 1953,PropTopicAlias 5336,PropSubscriptionIdentifier +// 24,PropServerKeepAlive 13981,PropAuthenticationMethod +// "-K\136\175O\234\SOH\137\NAK\188\205\GSZ\214\132\148\198\227Xw\a1,\ETX\EOT#V$",PropSubscriptionIdentifierAvailable +// 56,PropReceiveMaximum 13755,PropAssignedClientIdentifier "bf7",PropReceiveMaximum +// 20468,PropRequestResponseInformation 110,PropContentType "\153\153",PropReasonString +// "#\SYNo\149\211",PropUserProperty "\RS8\192;E\232J\nye8\238:\153\183\178\137\NAK\238\147\207\CAN\192" +// "(\235\218\154b",PropRequestResponseInformation 211,PropRetainAvailable 23,PropPayloadFormatIndicator +// 148,PropCorrelationData "\161\132\186I\178'9\205lh}\144\187\249\NUL\177M\STX +// \RS\n\154\159SNY\188C\194#",PropAuthenticationData +// "\214\253\205\207\250\155\157\148\190\226/S\156\220\235q\233\SUBA\v\180$\FS\221\ESC\165",PropMaximumQoS +// 187,PropSessionExpiryInterval 14562,PropSubscriptionIdentifierAvailable 242,PropReceiveMaximum 292,PropResponseTopic +// "\129\155\197zP\186\229\156\180\132\&3\FS)\156\179\213q=,\n"]}), _cleanSession = True, _keepAlive = 5227, _connID = +// "_\201\&2\202<\161\171\209\244\241\165", _properties = [PropTopicAliasMaximum 16149,PropTopicAliasMaximum +// 24850,PropResponseInformation "\131\163\236\190\&3'\193\233\141\150M>\205",PropReceiveMaximum +// 31161,PropSessionExpiryInterval 25873,PropSessionExpiryInterval 27557,PropWillDelayInterval +// 14599,PropAuthenticationMethod "\170\130\148\203\162I\210\177z\150X",PropWildcardSubscriptionAvailable +// 242,PropCorrelationData "P^\237\248",PropTopicAlias 11716,PropWillDelayInterval 10255,PropAuthenticationMethod +// "\202\255\154\170\175\187\151\&2\145MT\131\NAK\SOH\227\EOTQ\NAK\160\237?L\245",PropCorrelationData +// "\152\218\"\206\241\224U\129>",PropSessionExpiryInterval 23109,PropWildcardSubscriptionAvailable +// 229,PropPayloadFormatIndicator 181,PropServerKeepAlive 21011,PropReceiveMaximum 7128,PropServerReference +// "\179v\181\158T\217i",PropMaximumPacketSize 17720,PropMessageExpiryInterval 5161,PropSharedSubscriptionAvailable +// 116,PropAssignedClientIdentifier "\DC2J\130\&2@\201s\172u)R\175"]} TEST(Connect5QCTest, Encode28) { uint8_t pkt[] = { - 0x10, 0xcb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x5, 0xd9, 0xed, 0x1, 0x8, 0x0, 0x1d, 0x7d, - 0xcc, 0x12, 0x42, 0x9f, 0x15, 0x9d, 0x72, 0xde, 0x5b, 0x3b, 0x96, 0xc1, 0x55, 0x45, 0xb7, 0xa, 0x49, 0x45, 0xb0, - 0x9e, 0x81, 0xc0, 0x2c, 0x9e, 0x31, 0xbc, 0x1a, 0xc1, 0x23, 0x4a, 0x73, 0x15, 0x0, 0x19, 0x3d, 0x47, 0x70, 0xf7, - 0xef, 0xd6, 0x41, 0xcb, 0x85, 0xff, 0x85, 0x73, 0x73, 0x40, 0xf9, 0x26, 0x7c, 0x85, 0xb2, 0x40, 0xf4, 0xec, 0x2f, - 0x5a, 0xbe, 0x26, 0x0, 0x16, 0x8a, 0x6, 0xa7, 0xd9, 0xd1, 0x46, 0xb3, 0xe8, 0xa4, 0x1d, 0x77, 0xd1, 0x72, 0x67, - 0x54, 0x15, 0x51, 0xc1, 0xe0, 0xb2, 0xb0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0xeb, 0x71, 0xe9, 0x1a, 0x41, 0xb, 0xb4, + 0x24, 0x1c, 0xdd, 0x1b, 0xa5, 0x24, 0xbb, 0x11, 0x0, 0x0, 0x38, 0xe2, 0x29, 0xf2, 0x21, 0x1, 0x24, 0x8, 0x0, + 0x14, 0x81, 0x9b, 0xc5, 0x7a, 0x50, 0xba, 0xe5, 0x9c, 0xb4, 0x84, 0x33, 0x1c, 0x29, 0x9c, 0xb3, 0xd5, 0x71, 0x3d, + 0x2c, 0xa, 0x0, 0x13, 0xdc, 0xda, 0x89, 0xb3, 0x7a, 0x9e, 0xb, 0x63, 0x18, 0x80, 0x1a, 0x55, 0x13, 0xaf, 0x6e, + 0xc9, 0x50, 0xda, 0x42, 0x0, 0x18, 0xda, 0xae, 0xe9, 0x3d, 0x97, 0x37, 0xcc, 0xcc, 0xb5, 0x9, 0x92, 0xb4, 0x4f, + 0xbd, 0xad, 0x2e, 0x60, 0xf4, 0x97, 0xb4, 0x49, 0x40, 0x30, 0xfc, 0x0, 0x15, 0xda, 0x72, 0xa8, 0x8b, 0x52, 0xd9, + 0xd1, 0x7, 0x40, 0x87, 0xef, 0x87, 0x98, 0x82, 0x8c, 0x9c, 0xe6, 0x98, 0x3e, 0x9c, 0xa0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7d, 0xcc, 0x12, 0x42, 0x9f, 0x15, 0x9d, 0x72, 0xde, 0x5b, 0x3b, 0x96, 0xc1, 0x55, 0x45, - 0xb7, 0xa, 0x49, 0x45, 0xb0, 0x9e, 0x81, 0xc0, 0x2c, 0x9e, 0x31, 0xbc, 0x1a, 0xc1}; - uint8_t bytesprops1[] = {0x3d, 0x47, 0x70, 0xf7, 0xef, 0xd6, 0x41, 0xcb, 0x85, 0xff, 0x85, 0x73, 0x73, - 0x40, 0xf9, 0x26, 0x7c, 0x85, 0xb2, 0x40, 0xf4, 0xec, 0x2f, 0x5a, 0xbe}; - uint8_t bytesprops3[] = {0x29, 0xf6, 0x10, 0x3b, 0xcf, 0xc0, 0x42, 0x4c, 0x48, 0x58, 0xef, - 0xa0, 0x6c, 0x7f, 0x70, 0x88, 0xc, 0x5e, 0x5f, 0x46, 0x3d, 0x8f}; - uint8_t bytesprops2[] = {0x8a, 0x6, 0xa7, 0xd9, 0xd1, 0x46, 0xb3, 0xe8, 0xa4, 0x1d, 0x77, - 0xd1, 0x72, 0x67, 0x54, 0x15, 0x51, 0xc1, 0xe0, 0xb2, 0xb0, 0x4d}; - uint8_t bytesprops4[] = {0x7b, 0x31, 0xae, 0xf2, 0x2d, 0x83, 0xb6, 0xe, 0x9c, - 0xc1, 0x27, 0x4, 0x59, 0x7f, 0x3b, 0x83, 0x5f}; - uint8_t bytesprops5[] = {0xaa, 0x1e, 0xd2, 0xa1, 0x48, 0xc3, 0xe, 0x19, 0xe0, 0xf7, - 0xfb, 0xd3, 0x8f, 0x99, 0x47, 0x10, 0x28, 0x96, 0xca}; - uint8_t bytesprops7[] = {0x80, 0x38, 0xe5, 0x80, 0x34, 0x3f, 0x68, 0x91, 0x7, 0x80, 0x32, 0x35, 0x81}; - uint8_t bytesprops6[] = {0xa6, 0x8c, 0x30, 0x9, 0xf5, 0x7e, 0x2, 0x9c, - 0x4e, 0x9d, 0x2c, 0x5f, 0x49, 0x1e, 0x3b, 0x8d}; + uint8_t bytesprops0[] = {0x83, 0xa3, 0xec, 0xbe, 0x33, 0x27, 0xc1, 0xe9, 0x8d, 0x96, 0x4d, 0x3e, 0xcd}; + uint8_t bytesprops1[] = {0xaa, 0x82, 0x94, 0xcb, 0xa2, 0x49, 0xd2, 0xb1, 0x7a, 0x96, 0x58}; + uint8_t bytesprops2[] = {0x50, 0x5e, 0xed, 0xf8}; + uint8_t bytesprops3[] = {0xca, 0xff, 0x9a, 0xaa, 0xaf, 0xbb, 0x97, 0x32, 0x91, 0x4d, 0x54, 0x83, + 0x15, 0x1, 0xe3, 0x4, 0x51, 0x15, 0xa0, 0xed, 0x3f, 0x4c, 0xf5}; + uint8_t bytesprops4[] = {0x98, 0xda, 0x22, 0xce, 0xf1, 0xe0, 0x55, 0x81, 0x3e}; + uint8_t bytesprops5[] = {0xb3, 0x76, 0xb5, 0x9e, 0x54, 0xd9, 0x69}; + uint8_t bytesprops6[] = {0x12, 0x4a, 0x82, 0x32, 0x40, 0xc9, 0x73, 0xac, 0x75, 0x29, 0x52, 0xaf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19059}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops2}, .v = {22, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14420}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 695}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 757}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10859}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops6}, .v = {13, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25715}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15137}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18099}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16149}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24850}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31161}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25873}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27557}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14599}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11716}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10255}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23109}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21011}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7128}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17720}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5161}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xb2, 0xcb, 0x66, 0x62, 0x9e, 0xa, 0xef, 0xda, 0x12, - 0xa4, 0xc7, 0x85, 0xa4, 0x82, 0x1d, 0xe, 0xd5}; - uint8_t byteswillprops1[] = {0x5a, 0x7c, 0x8d, 0x7e, 0x78}; - uint8_t byteswillprops2[] = {0x7b, 0x2a, 0x76, 0xab, 0x76, 0x6c, 0xba, 0x32, 0xbf, 0x55, 0xf, 0xdf, - 0xaa, 0xc4, 0xa, 0x81, 0xb9, 0xf9, 0xf6, 0xfd, 0x51, 0x4, 0xcb, 0x6a}; - uint8_t byteswillprops3[] = {0x5c, 0x7a, 0xc9, 0xef, 0x13, 0xb9, 0xda, 0x42, - 0x17, 0x3, 0xed, 0xb0, 0xd3, 0x6d, 0xa1, 0x60}; - uint8_t byteswillprops4[] = {0x68, 0x59, 0xa1, 0x6d, 0xa4, 0x1f, 0xdd, 0x17, 0x70, - 0x49, 0xcb, 0x3b, 0x61, 0xdf, 0xe6, 0x9b, 0x0, 0xe8}; + uint8_t byteswillprops0[] = {0xb9, 0x2b, 0x6, 0x70, 0x2c, 0x13, 0x34, 0x38, 0x9b, + 0xb2, 0x27, 0xc5, 0xd, 0xfc, 0x5b, 0xbf, 0x5}; + uint8_t byteswillprops1[] = {0}; + uint8_t byteswillprops2[] = {0x2d, 0x4b, 0x88, 0xaf, 0x4f, 0xea, 0x1, 0x89, 0x15, 0xbc, 0xcd, 0x1d, 0x5a, 0xd6, + 0x84, 0x94, 0xc6, 0xe3, 0x58, 0x77, 0x7, 0x31, 0x2c, 0x3, 0x4, 0x23, 0x56, 0x24}; + uint8_t byteswillprops3[] = {0x62, 0x66, 0x37}; + uint8_t byteswillprops4[] = {0x99, 0x99}; + uint8_t byteswillprops5[] = {0x23, 0x16, 0x6f, 0x95, 0xd3}; + uint8_t byteswillprops7[] = {0x28, 0xeb, 0xda, 0x9a, 0x62}; + uint8_t byteswillprops6[] = {0x1e, 0x38, 0xc0, 0x3b, 0x45, 0xe8, 0x4a, 0xa, 0x79, 0x65, 0x38, 0xee, + 0x3a, 0x99, 0xb7, 0xb2, 0x89, 0x15, 0xee, 0x93, 0xcf, 0x18, 0xc0}; + uint8_t byteswillprops8[] = {0xa1, 0x84, 0xba, 0x49, 0xb2, 0x27, 0x39, 0xcd, 0x6c, 0x68, + 0x7d, 0x90, 0xbb, 0xf9, 0x0, 0xb1, 0x4d, 0x2, 0x20, 0x1e, + 0xa, 0x9a, 0x9f, 0x53, 0x4e, 0x59, 0xbc, 0x43, 0xc2, 0x23}; + uint8_t byteswillprops9[] = {0xd6, 0xfd, 0xcd, 0xcf, 0xfa, 0x9b, 0x9d, 0x94, 0xbe, 0xe2, 0x2f, 0x53, 0x9c, + 0xdc, 0xeb, 0x71, 0xe9, 0x1a, 0x41, 0xb, 0xb4, 0x24, 0x1c, 0xdd, 0x1b, 0xa5}; + uint8_t byteswillprops10[] = {0x81, 0x9b, 0xc5, 0x7a, 0x50, 0xba, 0xe5, 0x9c, 0xb4, 0x84, + 0x33, 0x1c, 0x29, 0x9c, 0xb3, 0xd5, 0x71, 0x3d, 0x2c, 0xa}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32637}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23460}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 989}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10792}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20351}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16461}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14555}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1953}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5336}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13981}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13755}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20468}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {23, (char*)&byteswillprops6}, .v = {5, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14562}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 292}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops10}}}, }; - lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf8, 0xc0, 0x63, 0x42, 0xdf, 0x6, 0x84, 0x73, - 0x21, 0x71, 0xf6, 0xec, 0x70, 0x51, 0x2d, 0x52}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x40, 0x98, 0x17, 0x70, 0xb4, 0x7b, 0xf, 0x94, 0xb4, 0x38, 0xd, - 0xe6, 0xfc, 0x76, 0x59, 0x97, 0x5d, 0xdf, 0x2f, 0xe8, 0x26, 0x6e}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xdc, 0xda, 0x89, 0xb3, 0x7a, 0x9e, 0xb, 0x63, 0x18, 0x80, + 0x1a, 0x55, 0x13, 0xaf, 0x6e, 0xc9, 0x50, 0xda, 0x42}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xda, 0xae, 0xe9, 0x3d, 0x97, 0x37, 0xcc, 0xcc, 0xb5, 0x9, 0x92, 0xb4, + 0x4f, 0xbd, 0xad, 0x2e, 0x60, 0xf4, 0x97, 0xb4, 0x49, 0x40, 0x30, 0xfc}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS1; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 1497; - uint8_t client_id_bytes[] = {0x5, 0x66, 0x42, 0xb2, 0x4, 0x10, 0x8b, 0xe9, 0xa9, 0x48, 0xe9, 0x1d, 0x5b}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.keep_alive = 5227; + uint8_t client_id_bytes[] = {0x5f, 0xc9, 0x32, 0xca, 0x3c, 0xa1, 0xab, 0xd1, 0xf4, 0xf1, 0xa5}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb1, 0x2c, 0x1f, 0xa2, 0xf9, 0xd, 0x55}; - lwmqtt_string_t username = {7, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xda, 0x72, 0xa8, 0x8b, 0x52, 0xd9, 0xd1, 0x7, 0x40, 0x87, 0xef, + 0x87, 0x98, 0x82, 0x8c, 0x9c, 0xe6, 0x98, 0x3e, 0x9c, 0xa0}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xba, 0x24, 0xb8, 0x4a, 0x18, 0x3a, 0xd2, 0x54, 0xa0, 0x74, 0xb9, 0xf2}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9962,109 +9928,147 @@ TEST(Connect5QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\137\131H\193\255h\165\215p\165", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "\194\&8\235\&3\136P\198a", _willMsg = -// "\ESC}E\DLE\133\162\200\238\202o\182\242", _willProps = [PropRetainAvailable 35,PropMessageExpiryInterval -// 27416,PropSubscriptionIdentifier 26,PropRequestProblemInformation 20,PropAssignedClientIdentifier -// "\"\183\DC1>f=\146\206\142\161\211\&2$\155\188\132j\SO\247\144\171 ~&\135?",PropMaximumQoS -// 127,PropRequestResponseInformation 19,PropTopicAliasMaximum 2785,PropMessageExpiryInterval -// 22684,PropPayloadFormatIndicator 23,PropContentType -// "\255\GS\172\&8\203\&9s6\242\NAK$\202\141\228\DLE\161#\231\214k\133z\146\154$\187\&6X'p",PropWillDelayInterval -// 29351,PropTopicAliasMaximum 12599,PropResponseInformation "TR\206rc\219dP\178\a\175\229",PropTopicAliasMaximum -// 21478,PropSubscriptionIdentifier 11,PropRequestProblemInformation 29,PropMaximumQoS 0,PropServerKeepAlive 21983]}), -// _cleanSession = False, _keepAlive = 17930, _connID = "\152@\239K\222UU\185", _properties = [PropWillDelayInterval -// 32405,PropSubscriptionIdentifier 7,PropSubscriptionIdentifier 29,PropSubscriptionIdentifier 16,PropServerReference -// "\130o\165\DC3b\192\165\&3\138",PropReceiveMaximum 10388,PropUserProperty -// "\241?\SI\142\ETB\246N\144\226h\b\140:\FS]Z\207." "Ve5q\156\DEL\131\172\146\NAK\164J,#\SUB%W\NUL",PropContentType -// "\131\DEL\136\139\&60\209\202\142\&1\195\225\186\180\234v\193\136A\ETX|\220\254\bw\NULd\208b\180"]} +// ConnectRequest {_username = Just "\SO\"\229\f\229\n\211x\145\nR\255A\196y\255",PropAuthenticationMethod +// "\134\243\201\207\246x\240\RS\194P\GS\FSl\217\188\154\143\180\242$\139\197\173\210\233\b\179\134\138",PropResponseInformation +// "N#\153\&4OL\131\149y\145\216\&7"]} TEST(Connect5QCTest, Encode29) { uint8_t pkt[] = { - 0x10, 0x98, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x94, 0x46, 0xa, 0x64, 0x18, 0x0, 0x0, 0x7e, 0x95, - 0xb, 0x7, 0xb, 0x1d, 0xb, 0x10, 0x1c, 0x0, 0x9, 0x82, 0x6f, 0xa5, 0x13, 0x62, 0xc0, 0xa5, 0x33, 0x8a, 0x21, - 0x28, 0x94, 0x26, 0x0, 0x12, 0xf1, 0x3f, 0xf, 0x8e, 0x17, 0xf6, 0x4e, 0x90, 0xe2, 0x68, 0x8, 0x8c, 0x3a, 0x1c, - 0x5d, 0x5a, 0xcf, 0x2e, 0x0, 0x12, 0x56, 0x65, 0x35, 0x71, 0x9c, 0x7f, 0x83, 0xac, 0x92, 0x15, 0xa4, 0x4a, 0x2c, - 0x23, 0x1a, 0x25, 0x57, 0x0, 0x3, 0x0, 0x1e, 0x83, 0x7f, 0x88, 0x8b, 0x36, 0x30, 0xd1, 0xca, 0x8e, 0x31, 0xc3, - 0xe1, 0xba, 0xb4, 0xea, 0x76, 0xc1, 0x88, 0x41, 0x3, 0x7c, 0xdc, 0xfe, 0x8, 0x77, 0x0, 0x64, 0xd0, 0x62, 0xb4, - 0x0, 0x8, 0x98, 0x40, 0xef, 0x4b, 0xde, 0x55, 0x55, 0xb9, 0x7a, 0x25, 0x23, 0x2, 0x0, 0x0, 0x6b, 0x18, 0xb, - 0x1a, 0x17, 0x14, 0x12, 0x0, 0x1a, 0x22, 0xb7, 0x11, 0x3e, 0x66, 0x3d, 0x92, 0xce, 0x8e, 0xa1, 0xd3, 0x32, 0x24, - 0x9b, 0xbc, 0x84, 0x6a, 0xe, 0xf7, 0x90, 0xab, 0x20, 0x7e, 0x26, 0x87, 0x3f, 0x24, 0x7f, 0x19, 0x13, 0x22, 0xa, - 0xe1, 0x2, 0x0, 0x0, 0x58, 0x9c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, 0xdb, 0x5d, 0x11, 0x0, 0x0, 0x37, 0xda, 0x27, 0x0, 0x0, 0x6d, 0x80, 0x26, 0x0, 0x14, 0x82, + 0xe4, 0x70, 0xf3, 0x42, 0xb0, 0x47, 0x53, 0xc2, 0x4d, 0xed, 0xa1, 0x76, 0x1e, 0x4e, 0xc1, 0x96, 0xe6, 0xfb, 0x2f, + 0x0, 0x2, 0xdc, 0xd5, 0x19, 0xca, 0x18, 0x0, 0x0, 0x45, 0x5d, 0x17, 0x85, 0x28, 0xd7, 0x2, 0x0, 0x0, 0x42, + 0xd1, 0x27, 0x0, 0x0, 0x35, 0x10, 0x25, 0x5f, 0x22, 0x58, 0x89, 0x3, 0x0, 0x19, 0xad, 0x34, 0x8f, 0x6c, 0x2f, + 0xe6, 0xe3, 0x3c, 0x32, 0xf9, 0xfb, 0x7e, 0x2a, 0x4e, 0x2e, 0xa3, 0x6a, 0xfa, 0x24, 0x6f, 0x3c, 0x4b, 0x24, 0x3a, + 0x8c, 0xb, 0x1c, 0x0, 0xf, 0x47, 0x4e, 0x8a, 0x55, 0x28, 0x1d, 0xe6, 0xf, 0x2b, 0x58, 0x21, 0x54, 0x75, 0xd5, + 0xbe, 0x0, 0x6, 0x2d, 0xfe, 0xb1, 0x51, 0x8a, 0x57, 0x0, 0x15, 0xe, 0x22, 0xe5, 0xc, 0xe5, 0xa, 0xd3, 0x78, + 0x91, 0xa, 0x52, 0xff, 0x41, 0xc4, 0x79, 0xff, 0x3c, 0x54, 0x5b, 0x95, 0x3, 0x0, 0x16, 0xa1, 0x27, 0xf1, 0xab, + 0x32, 0x22, 0x71, 0xaa, 0xa5, 0x8b, 0xe9, 0xf8, 0x9c, 0x74, 0xf4, 0x9e, 0xe7, 0xe9, 0x86, 0x71, 0x4e, 0x43}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x82, 0x6f, 0xa5, 0x13, 0x62, 0xc0, 0xa5, 0x33, 0x8a}; - uint8_t bytesprops2[] = {0x56, 0x65, 0x35, 0x71, 0x9c, 0x7f, 0x83, 0xac, 0x92, - 0x15, 0xa4, 0x4a, 0x2c, 0x23, 0x1a, 0x25, 0x57, 0x0}; - uint8_t bytesprops1[] = {0xf1, 0x3f, 0xf, 0x8e, 0x17, 0xf6, 0x4e, 0x90, 0xe2, - 0x68, 0x8, 0x8c, 0x3a, 0x1c, 0x5d, 0x5a, 0xcf, 0x2e}; - uint8_t bytesprops3[] = {0x83, 0x7f, 0x88, 0x8b, 0x36, 0x30, 0xd1, 0xca, 0x8e, 0x31, 0xc3, 0xe1, 0xba, 0xb4, 0xea, - 0x76, 0xc1, 0x88, 0x41, 0x3, 0x7c, 0xdc, 0xfe, 0x8, 0x77, 0x0, 0x64, 0xd0, 0x62, 0xb4}; + uint8_t bytesprops0[] = {0xb7, 0x2c, 0xe3, 0x2f, 0x47, 0x1, 0xb8, 0x63, 0x2b}; + uint8_t bytesprops1[] = {0x31, 0x6e, 0x3c, 0x84, 0x11, 0x69, 0x87, 0x6a}; + uint8_t bytesprops2[] = {0x75, 0x55}; + uint8_t bytesprops3[] = {0xd0, 0xa8, 0xff, 0x3c, 0xe2, 0x7a, 0x66, 0xf7}; + uint8_t bytesprops4[] = {0x5f, 0x61, 0x89, 0x80, 0xce, 0x21, 0x7e, 0xd7, 0x4c, 0x46, 0x38, + 0xe5, 0xd7, 0x82, 0x6a, 0x6b, 0xa5, 0x93, 0x2a, 0x5a, 0xfd, 0xb5}; + uint8_t bytesprops5[] = {0x24, 0xd3, 0xa7, 0xfd, 0xe6, 0x25, 0x2b, 0x63, 0x50, 0xd0, 0x84, + 0x91, 0xed, 0x6b, 0xb5, 0x71, 0xe8, 0xb0, 0x40, 0xde, 0xa5, 0x71}; + uint8_t bytesprops6[] = {0x3a, 0xcc, 0x8b, 0xc6, 0x8d, 0x52, 0x6e, 0x6d, 0x6e, 0x5d, 0x53, 0xaf, + 0x8d, 0x8e, 0xcc, 0x12, 0x29, 0x85, 0xc8, 0x54, 0xee, 0x15, 0xb4, 0x2d}; + uint8_t bytesprops7[] = {0xe7, 0x4f, 0x3a, 0x3, 0x8c}; + uint8_t bytesprops8[] = {0xfa, 0x48, 0x1, 0xa5, 0x39, 0x13}; + uint8_t bytesprops9[] = {0xef, 0x31, 0xe7, 0x7, 0xa5, 0xb7, 0xa, 0xc4, 0x5a, + 0xf7, 0x84, 0x3c, 0x69, 0x66, 0x8e, 0x95, 0xd}; + uint8_t bytesprops10[] = {0xb9, 0x6e, 0x83, 0x36, 0xd9, 0x20, 0x0, 0x3e}; + uint8_t bytesprops11[] = {0x86, 0xf3, 0xc9, 0xcf, 0xf6, 0x78, 0xf0, 0x1e, 0xc2, 0x50, 0x1d, 0x1c, 0x6c, 0xd9, 0xbc, + 0x9a, 0x8f, 0xb4, 0xf2, 0x24, 0x8b, 0xc5, 0xad, 0xd2, 0xe9, 0x8, 0xb3, 0x86, 0x8a}; + uint8_t bytesprops12[] = {0x4e, 0x23, 0x99, 0x34, 0x4f, 0x4c, 0x83, 0x95, 0x79, 0x91, 0xd8, 0x37}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32405}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10388}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13835}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21997}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19719}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops12}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x22, 0xb7, 0x11, 0x3e, 0x66, 0x3d, 0x92, 0xce, 0x8e, 0xa1, 0xd3, 0x32, 0x24, - 0x9b, 0xbc, 0x84, 0x6a, 0xe, 0xf7, 0x90, 0xab, 0x20, 0x7e, 0x26, 0x87, 0x3f}; - uint8_t byteswillprops1[] = {0xff, 0x1d, 0xac, 0x38, 0xcb, 0x39, 0x73, 0x36, 0xf2, 0x15, - 0x24, 0xca, 0x8d, 0xe4, 0x10, 0xa1, 0x23, 0xe7, 0xd6, 0x6b, - 0x85, 0x7a, 0x92, 0x9a, 0x24, 0xbb, 0x36, 0x58, 0x27, 0x70}; - uint8_t byteswillprops2[] = {0x54, 0x52, 0xce, 0x72, 0x63, 0xdb, 0x64, 0x50, 0xb2, 0x7, 0xaf, 0xe5}; + uint8_t byteswillprops1[] = {0xdc, 0xd5}; + uint8_t byteswillprops0[] = {0x82, 0xe4, 0x70, 0xf3, 0x42, 0xb0, 0x47, 0x53, 0xc2, 0x4d, + 0xed, 0xa1, 0x76, 0x1e, 0x4e, 0xc1, 0x96, 0xe6, 0xfb, 0x2f}; + uint8_t byteswillprops2[] = {0xad, 0x34, 0x8f, 0x6c, 0x2f, 0xe6, 0xe3, 0x3c, 0x32, 0xf9, 0xfb, 0x7e, 0x2a, + 0x4e, 0x2e, 0xa3, 0x6a, 0xfa, 0x24, 0x6f, 0x3c, 0x4b, 0x24, 0x3a, 0x8c}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27416}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 26}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2785}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22684}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29351}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12599}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21478}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21983}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14298}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28032}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {20, (char*)&byteswillprops0}, .v = {2, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17757}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17105}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13584}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22665}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, }; - lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc2, 0x38, 0xeb, 0x33, 0x88, 0x50, 0xc6, 0x61}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1b, 0x7d, 0x45, 0x10, 0x85, 0xa2, 0xc8, 0xee, 0xca, 0x6f, 0xb6, 0xf2}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x47, 0x4e, 0x8a, 0x55, 0x28, 0x1d, 0xe6, 0xf, + 0x2b, 0x58, 0x21, 0x54, 0x75, 0xd5, 0xbe}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2d, 0xfe, 0xb1, 0x51, 0x8a, 0x57}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS1; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 17930; - uint8_t client_id_bytes[] = {0x98, 0x40, 0xef, 0x4b, 0xde, 0x55, 0x55, 0xb9}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 2566; + uint8_t client_id_bytes[] = {0x45, 0x16, 0x7d, 0xe1, 0x3a, 0x75, 0x52, 0x47, 0xd5, 0x25, 0xcd, + 0x77, 0xbf, 0x7a, 0x46, 0x64, 0x97, 0x72, 0x9d, 0x6, 0xdb}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x89, 0x83, 0x48, 0xc1, 0xff, 0x68, 0xa5, 0xd7, 0x70, 0xa5}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xe, 0x22, 0xe5, 0xc, 0xe5, 0xa, 0xd3, 0x78, 0x91, 0xa, 0x52, + 0xff, 0x41, 0xc4, 0x79, 0xff, 0x3c, 0x54, 0x5b, 0x95, 0x3}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0xa1, 0x27, 0xf1, 0xab, 0x32, 0x22, 0x71, 0xaa, 0xa5, 0x8b, 0xe9, + 0xf8, 0x9c, 0x74, 0xf4, 0x9e, 0xe7, 0xe9, 0x86, 0x71, 0x4e, 0x43}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10073,112 +10077,89 @@ TEST(Connect5QCTest, Encode29) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "E?\ENQ\194E\208h\161\GSV2\189", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\143E\250\224\248%\EOT?\DC3_m\189\NAK\216\163\252\138B\142\RS", -// _willMsg = "|\253OH.E\US*\182\240-;\234\180\237\239\&2\136B\128\241\131", _willProps = [PropRetainAvailable -// 250,PropReasonString "\255G1L\175\209|#Pe",PropRetainAvailable 221,PropReasonString "",PropRetainAvailable 25]}), -// _cleanSession = True, _keepAlive = 6426, _connID = "J\158>Hv\SYNdF\SOH\160)\DC1*'#id\188iaD\192\b\213\152rW\251", -// _properties = [PropMaximumPacketSize 23862,PropSubscriptionIdentifierAvailable 121,PropRequestProblemInformation -// 59,PropAuthenticationData "\145j",PropSubscriptionIdentifierAvailable 234,PropSharedSubscriptionAvailable -// 208,PropMessageExpiryInterval 32125,PropMessageExpiryInterval 22174,PropSessionExpiryInterval 9012,PropReceiveMaximum -// 11528,PropWillDelayInterval 20923,PropResponseTopic "\183\193l\142\ETX\184",PropWildcardSubscriptionAvailable -// 90,PropTopicAliasMaximum 14239,PropSubscriptionIdentifierAvailable 250,PropAuthenticationData -// "IP\153\&8+\148\&3;gc\165A\194`\151\252\232\209\189\SYN#\DC3\179\b\225\158\142\128",PropWildcardSubscriptionAvailable -// 76,PropReasonString "b\244\216\253o\141\240\"\183\238\134l\186f\219g\212c\214\160",PropWildcardSubscriptionAvailable -// 172,PropRequestResponseInformation 106,PropRetainAvailable 24,PropRetainAvailable 49,PropTopicAliasMaximum -// 23078,PropServerKeepAlive 5765,PropSessionExpiryInterval 27036,PropAssignedClientIdentifier -// "\254\232\248\199\165\GS\233z\206}\245@\177\162o@\206\135"]} +// ConnectRequest {_username = Just "\152\221\234q\203G\217\fNt\228\210\150\136\182i)\202\138\152\231\173\145\214", +// _password = Just "'\180\139\198S@\216", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic +// = "8c-\209\158\&6\143C\DC4\218\154\186y\201\RS\157N\158z\179p!i\176B\133]\193\202\DC1", _willMsg = +// "\161kV;\231\200\136\195\SI", _willProps = [PropTopicAliasMaximum 7867,PropContentType +// "\131\192\204\245\195\230\148\171g\163\197Jbk[S",PropServerReference +// "n\165\CAN`\132\210\194\f\"G\f\239",PropWillDelayInterval 20782,PropUserProperty +// "\FS`\208\217}+g\aC2=\210l\r\ENQ\218\241\EOT\129b\SOH\198\143\&6" +// "\248\227\174{\166\130\133a\DC4\203",PropRetainAvailable 100]}), _cleanSession = True, _keepAlive = 23001, _connID = +// "O\245i\ESC", _properties = [PropServerReference "\180\SOH)",PropReceiveMaximum 29954,PropMessageExpiryInterval +// 22203,PropRequestProblemInformation 106,PropSessionExpiryInterval 18514,PropWillDelayInterval +// 23155,PropRequestResponseInformation 130,PropWildcardSubscriptionAvailable 7]} TEST(Connect5QCTest, Encode30) { - uint8_t pkt[] = { - 0x10, 0x96, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x19, 0x1a, 0x99, 0x1, 0x27, 0x0, 0x0, 0x5d, - 0x36, 0x29, 0x79, 0x17, 0x3b, 0x16, 0x0, 0x2, 0x91, 0x6a, 0x29, 0xea, 0x2a, 0xd0, 0x2, 0x0, 0x0, 0x7d, 0x7d, - 0x2, 0x0, 0x0, 0x56, 0x9e, 0x11, 0x0, 0x0, 0x23, 0x34, 0x21, 0x2d, 0x8, 0x18, 0x0, 0x0, 0x51, 0xbb, 0x8, - 0x0, 0x6, 0xb7, 0xc1, 0x6c, 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0x9e, 0x7a, 0xb3, 0x70, 0x21, 0x69, 0xb0, 0x42, 0x85, 0x5d, 0xc1, 0xca, 0x11, 0x0, 0x9, 0xa1, 0x6b, + 0x56, 0x3b, 0xe7, 0xc8, 0x88, 0xc3, 0xf, 0x0, 0x18, 0x98, 0xdd, 0xea, 0x71, 0xcb, 0x47, 0xd9, 0xc, + 0x4e, 0x74, 0xe4, 0xd2, 0x96, 0x88, 0xb6, 0x69, 0x29, 0xca, 0x8a, 0x98, 0xe7, 0xad, 0x91, 0xd6, 0x0, + 0x7, 0x27, 0xb4, 0x8b, 0xc6, 0x53, 0x40, 0xd8}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x91, 0x6a}; - uint8_t bytesprops1[] = {0xb7, 0xc1, 0x6c, 0x8e, 0x3, 0xb8}; - uint8_t bytesprops2[] = {0x49, 0x50, 0x99, 0x38, 0x2b, 0x94, 0x33, 0x3b, 0x67, 0x63, 0xa5, 0x41, 0xc2, 0x60, - 0x97, 0xfc, 0xe8, 0xd1, 0xbd, 0x16, 0x23, 0x13, 0xb3, 0x8, 0xe1, 0x9e, 0x8e, 0x80}; - uint8_t bytesprops3[] = {0x62, 0xf4, 0xd8, 0xfd, 0x6f, 0x8d, 0xf0, 0x22, 0xb7, 0xee, - 0x86, 0x6c, 0xba, 0x66, 0xdb, 0x67, 0xd4, 0x63, 0xd6, 0xa0}; - uint8_t bytesprops4[] = {0xfe, 0xe8, 0xf8, 0xc7, 0xa5, 0x1d, 0xe9, 0x7a, 0xce, - 0x7d, 0xf5, 0x40, 0xb1, 0xa2, 0x6f, 0x40, 0xce, 0x87}; + uint8_t bytesprops0[] = {0xb4, 0x1, 0x29}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23862}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32125}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22174}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9012}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11528}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20923}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14239}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23078}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5765}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27036}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29954}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22203}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18514}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23155}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xff, 0x47, 0x31, 0x4c, 0xaf, 0xd1, 0x7c, 0x23, 0x50, 0x65}; - uint8_t byteswillprops1[] = {0}; + uint8_t byteswillprops0[] = {0x83, 0xc0, 0xcc, 0xf5, 0xc3, 0xe6, 0x94, 0xab, + 0x67, 0xa3, 0xc5, 0x4a, 0x62, 0x6b, 0x5b, 0x53}; + uint8_t byteswillprops1[] = {0x6e, 0xa5, 0x18, 0x60, 0x84, 0xd2, 0xc2, 0xc, 0x22, 0x47, 0xc, 0xef}; + uint8_t byteswillprops3[] = {0xf8, 0xe3, 0xae, 0x7b, 0xa6, 0x82, 0x85, 0x61, 0x14, 0xcb}; + uint8_t byteswillprops2[] = {0x1c, 0x60, 0xd0, 0xd9, 0x7d, 0x2b, 0x67, 0x7, 0x43, 0x32, 0x3d, 0xd2, + 0x6c, 0xd, 0x5, 0xda, 0xf1, 0x4, 0x81, 0x62, 0x1, 0xc6, 0x8f, 0x36}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7867}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20782}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {24, (char*)&byteswillprops2}, .v = {10, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 100}}, }; - lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8f, 0x45, 0xfa, 0xe0, 0xf8, 0x25, 0x4, 0x3f, 0x13, 0x5f, - 0x6d, 0xbd, 0x15, 0xd8, 0xa3, 0xfc, 0x8a, 0x42, 0x8e, 0x1e}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7c, 0xfd, 0x4f, 0x48, 0x2e, 0x45, 0x1f, 0x2a, 0xb6, 0xf0, 0x2d, - 0x3b, 0xea, 0xb4, 0xed, 0xef, 0x32, 0x88, 0x42, 0x80, 0xf1, 0x83}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x38, 0x63, 0x2d, 0xd1, 0x9e, 0x36, 0x8f, 0x43, 0x14, 0xda, + 0x9a, 0xba, 0x79, 0xc9, 0x1e, 0x9d, 0x4e, 0x9e, 0x7a, 0xb3, + 0x70, 0x21, 0x69, 0xb0, 0x42, 0x85, 0x5d, 0xc1, 0xca, 0x11}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa1, 0x6b, 0x56, 0x3b, 0xe7, 0xc8, 0x88, 0xc3, 0xf}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 6426; - uint8_t client_id_bytes[] = {0x4a, 0x9e, 0x3e, 0x48, 0x76, 0x16, 0x64, 0x46, 0x1, 0xa0, 0x29, 0x11, 0x2a, 0x27, - 0x23, 0x69, 0x64, 0xbc, 0x69, 0x61, 0x44, 0xc0, 0x8, 0xd5, 0x98, 0x72, 0x57, 0xfb}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; + opts.keep_alive = 23001; + uint8_t client_id_bytes[] = {0x4f, 0xf5, 0x69, 0x1b}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x45, 0x3f, 0x5, 0xc2, 0x45, 0xd0, 0x68, 0xa1, 0x1d, 0x56, 0x32, 0xbd}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x98, 0xdd, 0xea, 0x71, 0xcb, 0x47, 0xd9, 0xc, 0x4e, 0x74, 0xe4, 0xd2, + 0x96, 0x88, 0xb6, 0x69, 0x29, 0xca, 0x8a, 0x98, 0xe7, 0xad, 0x91, 0xd6}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x27, 0xb4, 0x8b, 0xc6, 0x53, 0x40, 0xd8}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10188,120 +10169,98 @@ TEST(Connect5QCTest, Encode30) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22060 [("\223\227\254#\231\fk\254CT\157\246_G\GSI",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\212\DC4\172\SI\161\ETX[\171~`Y\188\185\181pS\206X",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 5047 [("H\129E$_\201\142?\214\245~\170",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\EOT\171",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("|\130\163TL\202",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\147^\181B\US12\255U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\185\DC1\142\241\ENQ\"\ETX",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\139\130\222\tW\SI",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x2a, 0x56, 0x2c, 0x0, 0x10, 0xdf, 0xe3, 0xfe, 0x23, 0xe7, 0xc, 0x6b, 0xfe, 0x43, - 0x54, 0x9d, 0xf6, 0x5f, 0x47, 0x1d, 0x49, 0x0, 0x0, 0x12, 0xd4, 0x14, 0xac, 0xf, 0xa1, - 0x3, 0x5b, 0xab, 0x7e, 0x60, 0x59, 0xbc, 0xb9, 0xb5, 0x70, 0x53, 0xce, 0x58, 0x2}; + uint8_t pkt[] = {0x82, 0x3e, 0x13, 0xb7, 0x0, 0xc, 0x48, 0x81, 0x45, 0x24, 0x5f, 0xc9, 0x8e, 0x3f, 0xd6, 0xf5, + 0x7e, 0xaa, 0x2, 0x0, 0x2, 0x4, 0xab, 0x0, 0x0, 0x6, 0x7c, 0x82, 0xa3, 0x54, 0x4c, 0xca, + 0x1, 0x0, 0x9, 0x93, 0x5e, 0xb5, 0x42, 0x1f, 0x31, 0x32, 0xff, 0x55, 0x2, 0x0, 0x7, 0xb9, + 0x11, 0x8e, 0xf1, 0x5, 0x22, 0x3, 0x0, 0x0, 0x6, 0x8b, 0x82, 0xde, 0x9, 0x57, 0xf, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xdf, 0xe3, 0xfe, 0x23, 0xe7, 0xc, 0x6b, 0xfe, - 0x43, 0x54, 0x9d, 0xf6, 0x5f, 0x47, 0x1d, 0x49}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x48, 0x81, 0x45, 0x24, 0x5f, 0xc9, 0x8e, 0x3f, 0xd6, 0xf5, 0x7e, 0xaa}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd4, 0x14, 0xac, 0xf, 0xa1, 0x3, 0x5b, 0xab, 0x7e, - 0x60, 0x59, 0xbc, 0xb9, 0xb5, 0x70, 0x53, 0xce, 0x58}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4, 0xab}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s2_bytes[] = {0x7c, 0x82, 0xa3, 0x54, 0x4c, 0xca}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x93, 0x5e, 0xb5, 0x42, 0x1f, 0x31, 0x32, 0xff, 0x55}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xb9, 0x11, 0x8e, 0xf1, 0x5, 0x22, 0x3}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8b, 0x82, 0xde, 0x9, 0x57, 0xf}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22060, 2, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 21589 -// [("\204\251XL\209\150\136\SUB\146\187\US\196\153\150d\219\213\209\RS\174\175\144^\140\138\147\203\240\214\215",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("g\160\ESC\225\199\RS!%|\ACKG\217v\148w\135\203",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("I*\141\&7!n",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\250wi\NAK0H\153\149m1#\244\243j\171jT\193\248\219\EOT\246X\217\161\192",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\241\239J(\216\192=\130\197-h|\170B\US\204]\166\204\149\152|\EOT\221X*U\138w\238",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\137;E\ETX\186\180\221\246\229\182\247\208",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("}\240",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("t\205_\220\162g\141/cH",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\135\137\149\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\165\DC36\SUBG\US}\220\EM\SI\137\251\204?\210\EOT#\bLN\129",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5047, 6, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 3206 [("\DC12^",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS1}),("\184\136",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("$\217\231uJ\220\&4\205\163\&2\171'\203P\ESC\252\228\SOH\202",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0xc1, 0x1, 0x54, 0x55, 0x0, 0x1e, 0xcc, 0xfb, 0x58, 0x4c, 0xd1, 0x96, 0x88, 0x1a, 0x92, 0xbb, - 0x1f, 0xc4, 0x99, 0x96, 0x64, 0xdb, 0xd5, 0xd1, 0x1e, 0xae, 0xaf, 0x90, 0x5e, 0x8c, 0x8a, 0x93, 0xcb, - 0xf0, 0xd6, 0xd7, 0x0, 0x0, 0x11, 0x67, 0xa0, 0x1b, 0xe1, 0xc7, 0x1e, 0x21, 0x25, 0x7c, 0x6, 0x47, - 0xd9, 0x76, 0x94, 0x77, 0x87, 0xcb, 0x1, 0x0, 0x6, 0x49, 0x2a, 0x8d, 0x37, 0x21, 0x6e, 0x0, 0x0, - 0x1a, 0xfa, 0x77, 0x69, 0x15, 0x30, 0x48, 0x99, 0x95, 0x6d, 0x31, 0x23, 0xf4, 0xf3, 0x6a, 0xab, 0x6a, - 0x54, 0xc1, 0xf8, 0xdb, 0x4, 0xf6, 0x58, 0xd9, 0xa1, 0xc0, 0x0, 0x0, 0x1e, 0xf1, 0xef, 0x4a, 0x28, - 0xd8, 0xc0, 0x3d, 0x82, 0xc5, 0x2d, 0x68, 0x7c, 0xaa, 0x42, 0x1f, 0xcc, 0x5d, 0xa6, 0xcc, 0x95, 0x98, - 0x7c, 0x4, 0xdd, 0x58, 0x2a, 0x55, 0x8a, 0x77, 0xee, 0x0, 0x0, 0x0, 0x1, 0x0, 0xc, 0x89, 0x3b, - 0x45, 0x3, 0xba, 0xb4, 0xdd, 0xf6, 0xe5, 0xb6, 0xf7, 0xd0, 0x0, 0x0, 0x2, 0x7d, 0xf0, 0x2, 0x0, - 0xa, 0x74, 0xcd, 0x5f, 0xdc, 0xa2, 0x67, 0x8d, 0x2f, 0x63, 0x48, 0x2, 0x0, 0x4, 0x87, 0x89, 0x95, - 0xd0, 0x2, 0x0, 0x15, 0xa5, 0x13, 0x36, 0x1a, 0x47, 0x1f, 0x7d, 0xdc, 0x19, 0xf, 0x89, 0xfb, 0xcc, - 0x3f, 0xd2, 0x4, 0x23, 0x8, 0x4c, 0x4e, 0x81, 0x0}; + uint8_t pkt[] = {0x82, 0x23, 0xc, 0x86, 0x0, 0x3, 0x11, 0x32, 0x5e, 0x1, 0x0, 0x2, 0xb8, + 0x88, 0x1, 0x0, 0x13, 0x24, 0xd9, 0xe7, 0x75, 0x4a, 0xdc, 0x34, 0xcd, 0xa3, + 0x32, 0xab, 0x27, 0xcb, 0x50, 0x1b, 0xfc, 0xe4, 0x1, 0xca, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xcc, 0xfb, 0x58, 0x4c, 0xd1, 0x96, 0x88, 0x1a, 0x92, 0xbb, - 0x1f, 0xc4, 0x99, 0x96, 0x64, 0xdb, 0xd5, 0xd1, 0x1e, 0xae, - 0xaf, 0x90, 0x5e, 0x8c, 0x8a, 0x93, 0xcb, 0xf0, 0xd6, 0xd7}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x11, 0x32, 0x5e}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x67, 0xa0, 0x1b, 0xe1, 0xc7, 0x1e, 0x21, 0x25, 0x7c, - 0x6, 0x47, 0xd9, 0x76, 0x94, 0x77, 0x87, 0xcb}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb8, 0x88}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x49, 0x2a, 0x8d, 0x37, 0x21, 0x6e}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x24, 0xd9, 0xe7, 0x75, 0x4a, 0xdc, 0x34, 0xcd, 0xa3, 0x32, + 0xab, 0x27, 0xcb, 0x50, 0x1b, 0xfc, 0xe4, 0x1, 0xca}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfa, 0x77, 0x69, 0x15, 0x30, 0x48, 0x99, 0x95, 0x6d, 0x31, 0x23, 0xf4, 0xf3, - 0x6a, 0xab, 0x6a, 0x54, 0xc1, 0xf8, 0xdb, 0x4, 0xf6, 0x58, 0xd9, 0xa1, 0xc0}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xf1, 0xef, 0x4a, 0x28, 0xd8, 0xc0, 0x3d, 0x82, 0xc5, 0x2d, - 0x68, 0x7c, 0xaa, 0x42, 0x1f, 0xcc, 0x5d, 0xa6, 0xcc, 0x95, - 0x98, 0x7c, 0x4, 0xdd, 0x58, 0x2a, 0x55, 0x8a, 0x77, 0xee}; - lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x89, 0x3b, 0x45, 0x3, 0xba, 0xb4, 0xdd, 0xf6, 0xe5, 0xb6, 0xf7, 0xd0}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7d, 0xf0}; - lwmqtt_string_t topic_filter_s7 = {2, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x74, 0xcd, 0x5f, 0xdc, 0xa2, 0x67, 0x8d, 0x2f, 0x63, 0x48}; - lwmqtt_string_t topic_filter_s8 = {10, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x87, 0x89, 0x95, 0xd0}; - lwmqtt_string_t topic_filter_s9 = {4, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xa5, 0x13, 0x36, 0x1a, 0x47, 0x1f, 0x7d, 0xdc, 0x19, 0xf, 0x89, - 0xfb, 0xcc, 0x3f, 0xd2, 0x4, 0x23, 0x8, 0x4c, 0x4e, 0x81}; - lwmqtt_string_t topic_filter_s10 = {21, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -10309,150 +10268,131 @@ TEST(Subscribe311QCTest, Encode2) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21589, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3206, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25658 [("\135\217dy\159J\NULIZ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("~|l\v\rK\139\EMPB\237\236M\165\138",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 13602 [("\183z",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2}),("1\166\179}\189\167\248\176&\209\EMo\162",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("`\230^\177X\132'\DLE}\211",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("4\242",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS +// = QoS2})] [] TEST(Subscribe311QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x20, 0x64, 0x3a, 0x0, 0x9, 0x87, 0xd9, 0x64, 0x79, 0x9f, 0x4a, 0x0, 0x49, 0x5a, 0x2, 0x0, - 0xf, 0x7e, 0x7c, 0x6c, 0xb, 0xd, 0x4b, 0x8b, 0x19, 0x50, 0x42, 0xed, 0xec, 0x4d, 0xa5, 0x8a, 0x2}; + uint8_t pkt[] = {0x82, 0x29, 0x35, 0x22, 0x0, 0x2, 0xb7, 0x7a, 0x2, 0x0, 0xd, 0x31, 0xa6, 0xb3, 0x7d, + 0xbd, 0xa7, 0xf8, 0xb0, 0x26, 0xd1, 0x19, 0x6f, 0xa2, 0x1, 0x0, 0xa, 0x60, 0xe6, 0x5e, + 0xb1, 0x58, 0x84, 0x27, 0x10, 0x7d, 0xd3, 0x2, 0x0, 0x2, 0x34, 0xf2, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x87, 0xd9, 0x64, 0x79, 0x9f, 0x4a, 0x0, 0x49, 0x5a}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xb7, 0x7a}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7e, 0x7c, 0x6c, 0xb, 0xd, 0x4b, 0x8b, 0x19, - 0x50, 0x42, 0xed, 0xec, 0x4d, 0xa5, 0x8a}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x31, 0xa6, 0xb3, 0x7d, 0xbd, 0xa7, 0xf8, 0xb0, 0x26, 0xd1, 0x19, 0x6f, 0xa2}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; + uint8_t topic_filter_s2_bytes[] = {0x60, 0xe6, 0x5e, 0xb1, 0x58, 0x84, 0x27, 0x10, 0x7d, 0xd3}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x34, 0xf2}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25658, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13602, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3081 [("`\165\DC2QfJ\249\SI\229\168\140",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\175\219X\239\225\227x\227\ETB\252\181h",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\168#\148j\132a\191~\220R\159N\200\142j\222\155\217)\STX\rz\233",SubOptions {_retainHandling = +// SubscribeRequest 14384 [("\FS\128\241\248\208\137C~(\163%\158w",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("5X8\205\211\235pK\ETBW@\NUL:\138\244U\176\143\vel\244x_\255\153",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("?\223\227x\250\168\161\217j\189b\253dAOF\239\202\227",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\160\136\fl(\220\155",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\152\146\139\145\146",SubOptions +// QoS1}),("r^\143\162\178\168\192\172\141.\SI\245\a\221\ETBN\254w\DC4\141\EMJ\141)3\194\246",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\t",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\197\241H\131\203;\238\152\EOT\187CUa\222\142\128\EM\SUBq",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\ACK_\244\234\207,W\239J\240\181\240fXg\231",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("{\\\162.Ggs\SOH\145\237\&7T\146",SubOptions +// QoS2}),("\144\194A\232\SOH\155\ESCL\\\214\&8\169\DC2\239\173\&0\DC4P:&",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("i\129\v\240\205@PA/",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("A!\225\138=",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\169\193\&8B\138\143\CAN~=\150\240\216U\168\DLECx\DEL(\245\135\&1G|1\144F",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0x9a, 0x1, 0xc, 0x9, 0x0, 0xb, 0x60, 0xa5, 0x12, 0x51, 0x66, 0x4a, 0xf9, 0xf, 0xe5, - 0xa8, 0x8c, 0x2, 0x0, 0xc, 0xaf, 0xdb, 0x58, 0xef, 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72, 0x5e, 0x8f, 0xa2, 0xb2, 0xa8, 0xc0, 0xac, 0x8d, 0x2e, 0xf, 0xf5, + 0x7, 0xdd, 0x17, 0x4e, 0xfe, 0x77, 0x14, 0x8d, 0x19, 0x4a, 0x8d, 0x29, 0x33, 0xc2, 0xf6, 0x2, + 0x0, 0x1, 0x9, 0x2, 0x0, 0x14, 0x90, 0xc2, 0x41, 0xe8, 0x1, 0x9b, 0x1b, 0x4c, 0x5c, 0xd6, + 0x38, 0xa9, 0x12, 0xef, 0xad, 0x30, 0x14, 0x50, 0x3a, 0x26, 0x1, 0x0, 0x9, 0x69, 0x81, 0xb, + 0xf0, 0xcd, 0x40, 0x50, 0x41, 0x2f, 0x1, 0x0, 0x5, 0x41, 0x21, 0xe1, 0x8a, 0x3d, 0x1, 0x0, + 0x1b, 0xa9, 0xc1, 0x38, 0x42, 0x8a, 0x8f, 0x18, 0x7e, 0x3d, 0x96, 0xf0, 0xd8, 0x55, 0xa8, 0x10, + 0x43, 0x78, 0x7f, 0x28, 0xf5, 0x87, 0x31, 0x47, 0x7c, 0x31, 0x90, 0x46, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x60, 0xa5, 0x12, 0x51, 0x66, 0x4a, 0xf9, 0xf, 0xe5, 0xa8, 0x8c}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x1c, 0x80, 0xf1, 0xf8, 0xd0, 0x89, 0x43, 0x7e, 0x28, 0xa3, 0x25, 0x9e, 0x77}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xaf, 0xdb, 0x58, 0xef, 0xe1, 0xe3, 0x78, 0xe3, 0x17, 0xfc, 0xb5, 0x68}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x35, 0x58, 0x38, 0xcd, 0xd3, 0xeb, 0x70, 0x4b, 0x17, 0x57, 0x40, 0x0, 0x3a, + 0x8a, 0xf4, 0x55, 0xb0, 0x8f, 0xb, 0x65, 0x6c, 0xf4, 0x78, 0x5f, 0xff, 0x99}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa8, 0x23, 0x94, 0x6a, 0x84, 0x61, 0xbf, 0x7e, 0xdc, 0x52, 0x9f, 0x4e, - 0xc8, 0x8e, 0x6a, 0xde, 0x9b, 0xd9, 0x29, 0x2, 0xd, 0x7a, 0xe9}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x72, 0x5e, 0x8f, 0xa2, 0xb2, 0xa8, 0xc0, 0xac, 0x8d, 0x2e, 0xf, 0xf5, 0x7, 0xdd, + 0x17, 0x4e, 0xfe, 0x77, 0x14, 0x8d, 0x19, 0x4a, 0x8d, 0x29, 0x33, 0xc2, 0xf6}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3f, 0xdf, 0xe3, 0x78, 0xfa, 0xa8, 0xa1, 0xd9, 0x6a, 0xbd, - 0x62, 0xfd, 0x64, 0x41, 0x4f, 0x46, 0xef, 0xca, 0xe3}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa0, 0x88, 0xc, 0x6c, 0x28, 0xdc, 0x9b}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x90, 0xc2, 0x41, 0xe8, 0x1, 0x9b, 0x1b, 0x4c, 0x5c, 0xd6, + 0x38, 0xa9, 0x12, 0xef, 0xad, 0x30, 0x14, 0x50, 0x3a, 0x26}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x98, 0x92, 0x8b, 0x91, 0x92}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x69, 0x81, 0xb, 0xf0, 0xcd, 0x40, 0x50, 0x41, 0x2f}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc5, 0xf1, 0x48, 0x83, 0xcb, 0x3b, 0xee, 0x98, 0x4, 0xbb, - 0x43, 0x55, 0x61, 0xde, 0x8e, 0x80, 0x19, 0x1a, 0x71}; - lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x41, 0x21, 0xe1, 0x8a, 0x3d}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6, 0x5f, 0xf4, 0xea, 0xcf, 0x2c, 0x57, 0xef, - 0x4a, 0xf0, 0xb5, 0xf0, 0x66, 0x58, 0x67, 0xe7}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xa9, 0xc1, 0x38, 0x42, 0x8a, 0x8f, 0x18, 0x7e, 0x3d, 0x96, 0xf0, 0xd8, 0x55, 0xa8, + 0x10, 0x43, 0x78, 0x7f, 0x28, 0xf5, 0x87, 0x31, 0x47, 0x7c, 0x31, 0x90, 0x46}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x7b, 0x5c, 0xa2, 0x2e, 0x47, 0x67, 0x73, 0x1, 0x91, 0xed, 0x37, 0x54, 0x92}; - lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -10468,15 +10408,15 @@ TEST(Subscribe311QCTest, Encode4) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; @@ -10484,80 +10424,81 @@ TEST(Subscribe311QCTest, Encode4) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3081, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14384, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26803 [("G0\203x\EOT9\163\234\244~\250\213\DEL\247z'\226",SubOptions {_retainHandling = +// SubscribeRequest 10952 [("\189\131\143u\249\178\237\221\225\135\200_E",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\138:\130%\226\132\219i%\244x~=X\220\GS\224\244\133\144\194O\240\154",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("m,s\SO\194G\181\182\&9\128N\200\150;gq9\182u?e\\\252\219\SO\133\DC2\146\242W",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\129\156\160\NAK\194\&8\202\196Y -// \172\147\213\175\141*\168\ETB\195y\147",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("iM\SYN\223q\DEL@J\183\233\132\254[*",SubOptions {_retainHandling = +// QoS1}),("\184*~\237,+2\155\&2P\221\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\172\&6\205I;\188o",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("-\ETB\193\208",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("jX\ra\242\DC1\ETB@E\181\181\252R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\224\GSH\ESCU\212",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS1}),("\ENQ\r\210U\140\DC2\148\199\188\163\197]",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1}),("yr \203n\154\&6\197\134\218xJ\DC4\144",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("8Y\218Q\175\&2",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x79, 0x68, 0xb3, 0x0, 0x11, 0x47, 0x30, 0xcb, 0x78, 0x4, 0x39, 0xa3, 0xea, 0xf4, 0x7e, - 0xfa, 0xd5, 0x7f, 0xf7, 0x7a, 0x27, 0xe2, 0x2, 0x0, 0x1e, 0x6d, 0x2c, 0x73, 0xe, 0xc2, 0x47, - 0xb5, 0xb6, 0x39, 0x80, 0x4e, 0xc8, 0x96, 0x3b, 0x67, 0x71, 0x39, 0xb6, 0x75, 0x3f, 0x65, 0x5c, - 0xfc, 0xdb, 0xe, 0x85, 0x12, 0x92, 0xf2, 0x57, 0x2, 0x0, 0x15, 0x81, 0x9c, 0xa0, 0x15, 0xc2, - 0x38, 0xca, 0xc4, 0x59, 0x20, 0xac, 0x93, 0xd5, 0xaf, 0x8d, 0x2a, 0xa8, 0x17, 0xc3, 0x79, 0x93, - 0x1, 0x0, 0xe, 0x69, 0x4d, 0x16, 0xdf, 0x71, 0x7f, 0x40, 0x4a, 0xb7, 0xe9, 0x84, 0xfe, 0x5b, - 0x2a, 0x1, 0x0, 0xd, 0x6a, 0x58, 0xd, 0x61, 0xf2, 0x11, 0x17, 0x40, 0x45, 0xb5, 0xb5, 0xfc, - 0x52, 0x1, 0x0, 0x6, 0xe0, 0x1d, 0x48, 0x1b, 0x55, 0xd4, 0x2}; + uint8_t pkt[] = {0x82, 0x76, 0x2a, 0xc8, 0x0, 0xd, 0xbd, 0x83, 0x8f, 0x75, 0xf9, 0xb2, 0xed, 0xdd, 0xe1, + 0x87, 0xc8, 0x5f, 0x45, 0x2, 0x0, 0x18, 0x8a, 0x3a, 0x82, 0x25, 0xe2, 0x84, 0xdb, 0x69, + 0x25, 0xf4, 0x78, 0x7e, 0x3d, 0x58, 0xdc, 0x1d, 0xe0, 0xf4, 0x85, 0x90, 0xc2, 0x4f, 0xf0, + 0x9a, 0x1, 0x0, 0xc, 0xb8, 0x2a, 0x7e, 0xed, 0x2c, 0x2b, 0x32, 0x9b, 0x32, 0x50, 0xdd, + 0xc5, 0x0, 0x0, 0x7, 0xac, 0x36, 0xcd, 0x49, 0x3b, 0xbc, 0x6f, 0x2, 0x0, 0x4, 0x2d, + 0x17, 0xc1, 0xd0, 0x1, 0x0, 0xc, 0x5, 0xd, 0xd2, 0x55, 0x8c, 0x12, 0x94, 0xc7, 0xbc, + 0xa3, 0xc5, 0x5d, 0x1, 0x0, 0xe, 0x79, 0x72, 0x20, 0xcb, 0x6e, 0x9a, 0x36, 0xc5, 0x86, + 0xda, 0x78, 0x4a, 0x14, 0x90, 0x1, 0x0, 0x6, 0x38, 0x59, 0xda, 0x51, 0xaf, 0x32, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x47, 0x30, 0xcb, 0x78, 0x4, 0x39, 0xa3, 0xea, 0xf4, - 0x7e, 0xfa, 0xd5, 0x7f, 0xf7, 0x7a, 0x27, 0xe2}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xbd, 0x83, 0x8f, 0x75, 0xf9, 0xb2, 0xed, 0xdd, 0xe1, 0x87, 0xc8, 0x5f, 0x45}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6d, 0x2c, 0x73, 0xe, 0xc2, 0x47, 0xb5, 0xb6, 0x39, 0x80, - 0x4e, 0xc8, 0x96, 0x3b, 0x67, 0x71, 0x39, 0xb6, 0x75, 0x3f, - 0x65, 0x5c, 0xfc, 0xdb, 0xe, 0x85, 0x12, 0x92, 0xf2, 0x57}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x8a, 0x3a, 0x82, 0x25, 0xe2, 0x84, 0xdb, 0x69, 0x25, 0xf4, 0x78, 0x7e, + 0x3d, 0x58, 0xdc, 0x1d, 0xe0, 0xf4, 0x85, 0x90, 0xc2, 0x4f, 0xf0, 0x9a}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x81, 0x9c, 0xa0, 0x15, 0xc2, 0x38, 0xca, 0xc4, 0x59, 0x20, 0xac, - 0x93, 0xd5, 0xaf, 0x8d, 0x2a, 0xa8, 0x17, 0xc3, 0x79, 0x93}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb8, 0x2a, 0x7e, 0xed, 0x2c, 0x2b, 0x32, 0x9b, 0x32, 0x50, 0xdd, 0xc5}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x69, 0x4d, 0x16, 0xdf, 0x71, 0x7f, 0x40, - 0x4a, 0xb7, 0xe9, 0x84, 0xfe, 0x5b, 0x2a}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xac, 0x36, 0xcd, 0x49, 0x3b, 0xbc, 0x6f}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x6a, 0x58, 0xd, 0x61, 0xf2, 0x11, 0x17, 0x40, 0x45, 0xb5, 0xb5, 0xfc, 0x52}; - lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2d, 0x17, 0xc1, 0xd0}; + lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe0, 0x1d, 0x48, 0x1b, 0x55, 0xd4}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x5, 0xd, 0xd2, 0x55, 0x8c, 0x12, 0x94, 0xc7, 0xbc, 0xa3, 0xc5, 0x5d}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0x79, 0x72, 0x20, 0xcb, 0x6e, 0x9a, 0x36, + 0xc5, 0x86, 0xda, 0x78, 0x4a, 0x14, 0x90}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x38, 0x59, 0xda, 0x51, 0xaf, 0x32}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -10565,126 +10506,181 @@ TEST(Subscribe311QCTest, Encode5) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26803, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10952, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11145 [("\164AU\201CkkO\229g",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\181\216\214e\225\&0#]\206\240\&7\199\ETX\133\132\148\216\&7c;I\US\212\EOT\US\218u\178",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("z\137FLm07=\230F\205\242\r\164\221",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\190\181`\130\234\187\176F\193\149\242\223\&7\130\167>\ACK\SYN_G\244\236M\230\204",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS0}),(",\255\175\ENQ\139\179%\241\252\148^\228T\243\DLE",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DEL\152",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\ACK\168&\158\RS\EM(\144%\ACKy\f\185=\229\161\139\170\SOH",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\RSMD\EM\154\220\162\b\165\174\174Z\246\DLE$\b\193",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0xd3, 0x1, 0x79, 0x44, 0x0, 0x1b, 0xbb, 0xc8, 0x9c, 0x21, 0x9e, 0xc, 0x34, 0x2, 0x0, 0xac, - 0x5, 0xf4, 0x7e, 0xd0, 0xac, 0x42, 0x13, 0x29, 0x91, 0x43, 0x31, 0xa6, 0x6d, 0xd0, 0xaf, 0xfe, 0x54, -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 0x85, 0x0, 0x18, 0x2e, 0x4a, 0xab, 0x7f, 0xa0, 0xc2, 0xe1, 0xe1, 0xaf, + 0xd7, 0x2c, 0x42, 0x8c, 0x58, 0x11, 0xa, 0x60, 0x52, 0xb8, 0x6a, 0xa4, 0x5a, 0x42, 0x5, 0x2, + 0x0, 0xe, 0xf8, 0x61, 0xe1, 0xc9, 0x70, 0x11, 0xb5, 0x46, 0x76, 0xd2, 0xda, 0xe, 0xe0, 0x1a, + 0x1, 0x0, 0x3, 0x46, 0xef, 0xa0, 0x0, 0x0, 0x9, 0xb7, 0x2e, 0xf6, 0x79, 0xa4, 0xa2, 0xd0, + 0x79, 0x2, 0x0, 0x0, 0x16, 0xca, 0x82, 0xc0, 0x89, 0xe7, 0x2, 0xa4, 0x19, 0xc3, 0x7a, 0xa8, + 0x23, 0x54, 0x65, 0x6a, 0x81, 0x4f, 0x3e, 0x6b, 0x4f, 0xe5, 0x67, 0x0, 0x0, 0xf, 0x2c, 0xff, + 0xaf, 0x5, 0x8b, 0xb3, 0x25, 0xf1, 0xfc, 0x94, 0x5e, 0xe4, 0x54, 0xf3, 0x10, 0x2, 0x0, 0x2, + 0x7f, 0x98, 0x1, 0x0, 0x0, 0x0, 0x0, 0x13, 0x6, 0xa8, 0x26, 0x9e, 0x1e, 0x19, 0x28, 0x90, + 0x25, 0x6, 0x79, 0xc, 0xb9, 0x3d, 0xe5, 0xa1, 0x8b, 0xaa, 0x1, 0x0, 0x0, 0x11, 0x1e, 0x4d, + 0x44, 0x19, 0x9a, 0xdc, 0xa2, 0x8, 0xa5, 0xae, 0xae, 0x5a, 0xf6, 0x10, 0x24, 0x8, 0xc1, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xbb, 0xc8, 0x9c, 0x21, 0x9e, 0xc, 0x34, 0x2, 0x0, 0xac, 0x5, 0xf4, 0x7e, 0xd0, - 0xac, 0x42, 0x13, 0x29, 0x91, 0x43, 0x31, 0xa6, 0x6d, 0xd0, 0xaf, 0xfe, 0x54}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x2e, 0x4a, 0xab, 0x7f, 0xa0, 0xc2, 0xe1, 0xe1, 0xaf, 0xd7, 0x2c, 0x42, + 0x8c, 0x58, 0x11, 0xa, 0x60, 0x52, 0xb8, 0x6a, 0xa4, 0x5a, 0x42, 0x5}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x11, 0x7c, 0x18, 0xdb, 0x13, 0x8f, 0xf2, 0x5, 0x14, 0x56, - 0x18, 0x88, 0x88, 0x6f, 0xe, 0x1b, 0x13, 0x2f, 0x9e, 0x3b}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf8, 0x61, 0xe1, 0xc9, 0x70, 0x11, 0xb5, 0x46, 0x76, 0xd2, 0xda, 0xe, 0xe0, 0x1a}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8c, 0x6e, 0x95, 0x67, 0x50, 0xa5, 0x85, 0x43, 0xb7, 0x8c, 0x90, 0xc3, - 0x49, 0xd, 0x1e, 0xd7, 0x20, 0xca, 0x45, 0x58, 0x4, 0xcb, 0x87}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x46, 0xef, 0xa0}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x19}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xb7, 0x2e, 0xf6, 0x79, 0xa4, 0xa2, 0xd0, 0x79, 0x2}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x70, 0x3c, 0x95, 0xb5, 0x16, 0xeb, 0x62, - 0x3c, 0x4e, 0xf2, 0xcb, 0x70, 0x53, 0xad}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xca, 0x82, 0xc0, 0x89, 0xe7, 0x2, 0xa4, 0x19, 0xc3, 0x7a, 0xa8, + 0x23, 0x54, 0x65, 0x6a, 0x81, 0x4f, 0x3e, 0x6b, 0x4f, 0xe5, 0x67}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfa, 0x5, 0xc2, 0xa5, 0x99, 0x3b, 0x97, 0xad, 0x8f, 0xdc, - 0x7a, 0xaf, 0x6e, 0xa8, 0x36, 0xbb, 0xe8, 0xf, 0x99, 0x84, - 0x47, 0xbd, 0x1a, 0xab, 0x76, 0xf7, 0xb2, 0x57, 0xdb}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x2c, 0xff, 0xaf, 0x5, 0x8b, 0xb3, 0x25, 0xf1, + 0xfc, 0x94, 0x5e, 0xe4, 0x54, 0xf3, 0x10}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb5, 0xd8, 0xd6, 0x65, 0xe1, 0x30, 0x23, 0x5d, 0xce, 0xf0, - 0x37, 0xc7, 0x3, 0x85, 0x84, 0x94, 0xd8, 0x37, 0x63, 0x3b, - 0x49, 0x1f, 0xd4, 0x4, 0x1f, 0xda, 0x75, 0xb2}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x7f, 0x98}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7a, 0x89, 0x46, 0x4c, 0x6d, 0x30, 0x37, 0x3d, - 0xe6, 0x46, 0xcd, 0xf2, 0xd, 0xa4, 0xdd}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xbe, 0xb5, 0x60, 0x82, 0xea, 0xbb, 0xb0, 0x46, 0xc1, 0x95, 0xf2, 0xdf, 0x37, - 0x82, 0xa7, 0x3e, 0x6, 0x16, 0x5f, 0x47, 0xf4, 0xec, 0x4d, 0xe6, 0xcc}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x6, 0xa8, 0x26, 0x9e, 0x1e, 0x19, 0x28, 0x90, 0x25, 0x6, + 0x79, 0xc, 0xb9, 0x3d, 0xe5, 0xa1, 0x8b, 0xaa, 0x1}; + lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s9_bytes[] = {0x1e, 0x4d, 0x44, 0x19, 0x9a, 0xdc, 0xa2, 0x8, 0xa5, + 0xae, 0xae, 0x5a, 0xf6, 0x10, 0x24, 0x8, 0xc1}; + lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -10700,15 +10696,15 @@ TEST(Subscribe311QCTest, Encode7) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].qos = LWMQTT_QOS0; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; @@ -10716,43 +10712,43 @@ TEST(Subscribe311QCTest, Encode7) { sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31044, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3461, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8770 [("\246\142&\218\222\148\226\196\212s~U\253",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\189\174\GS0\252J -// \229\&3J\f\139\225\150\221\DC4p\226\223",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\169Q;\220&z\151\248\&5\149\161\202h\ENQ\162\148\158\137b\203\f",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 24628 [("J$\202\SOH\164s\193\241\FS\196\170\186\133\233\147!bV\164\233m\185\177wW",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Pu\230B\171\159)-\n\236\132r\193f\179`H\140\168\r&\ESC\241\173\219\190",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x40, 0x22, 0x42, 0x0, 0xd, 0xf6, 0x8e, 0x26, 0xda, 0xde, 0x94, 0xe2, 0xc4, 0xd4, 0x73, 0x7e, - 0x55, 0xfd, 0x0, 0x0, 0x13, 0xbd, 0xae, 0x1d, 0x30, 0xfc, 0x4a, 0x20, 0xe5, 0x33, 0x4a, 0xc, 0x8b, - 0xe1, 0x96, 0xdd, 0x14, 0x70, 0xe2, 0xdf, 0x2, 0x0, 0x15, 0xa9, 0x51, 0x3b, 0xdc, 0x26, 0x7a, 0x97, - 0xf8, 0x35, 0x95, 0xa1, 0xca, 0x68, 0x5, 0xa2, 0x94, 0x9e, 0x89, 0x62, 0xcb, 0xc, 0x1}; + uint8_t pkt[] = {0x82, 0x3b, 0x60, 0x34, 0x0, 0x19, 0x4a, 0x24, 0xca, 0x1, 0xa4, 0x73, 0xc1, 0xf1, 0x1c, 0xc4, + 0xaa, 0xba, 0x85, 0xe9, 0x93, 0x21, 0x62, 0x56, 0xa4, 0xe9, 0x6d, 0xb9, 0xb1, 0x77, 0x57, 0x2, + 0x0, 0x1a, 0x50, 0x75, 0xe6, 0x42, 0xab, 0x9f, 0x29, 0x2d, 0xa, 0xec, 0x84, 0x72, 0xc1, 0x66, + 0xb3, 0x60, 0x48, 0x8c, 0xa8, 0xd, 0x26, 0x1b, 0xf1, 0xad, 0xdb, 0xbe, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xf6, 0x8e, 0x26, 0xda, 0xde, 0x94, 0xe2, 0xc4, 0xd4, 0x73, 0x7e, 0x55, 0xfd}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x4a, 0x24, 0xca, 0x1, 0xa4, 0x73, 0xc1, 0xf1, 0x1c, 0xc4, 0xaa, 0xba, 0x85, + 0xe9, 0x93, 0x21, 0x62, 0x56, 0xa4, 0xe9, 0x6d, 0xb9, 0xb1, 0x77, 0x57}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbd, 0xae, 0x1d, 0x30, 0xfc, 0x4a, 0x20, 0xe5, 0x33, 0x4a, - 0xc, 0x8b, 0xe1, 0x96, 0xdd, 0x14, 0x70, 0xe2, 0xdf}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x50, 0x75, 0xe6, 0x42, 0xab, 0x9f, 0x29, 0x2d, 0xa, 0xec, 0x84, 0x72, 0xc1, + 0x66, 0xb3, 0x60, 0x48, 0x8c, 0xa8, 0xd, 0x26, 0x1b, 0xf1, 0xad, 0xdb, 0xbe}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa9, 0x51, 0x3b, 0xdc, 0x26, 0x7a, 0x97, 0xf8, 0x35, 0x95, 0xa1, - 0xca, 0x68, 0x5, 0xa2, 0x94, 0x9e, 0x89, 0x62, 0xcb, 0xc}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -10760,47 +10756,92 @@ TEST(Subscribe311QCTest, Encode8) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8770, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24628, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15580 -// [("\145\183m\232\217\188\204_\223\249\161\170\156\133T\234\233\159\235\&2H\175J\211\149j",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("]\151",SubOptions +// SubscribeRequest 27288 [("\217\135\214\SIKL\f\214\225\208\141\236\194:4\212\162{\DLE\CAN",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\203\193<\223\198\148=\252\DC3=x\192\203\215\231\&2\211",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("-.N5P\STXC\CAN",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\147\DLE\210K\RS,n\142:0O\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\STXs\187\214l$s\164\&9O\a\137M\132\197\"\151\179\229,\193\188^\173",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\238\244E\141\168\203\228s?\190\232J\139\182N\157",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0x37, 0x3c, 0xdc, 0x0, 0x1a, 0x91, 0xb7, 0x6d, 0xe8, 0xd9, 0xbc, 0xcc, 0x5f, 0xdf, - 0xf9, 0xa1, 0xaa, 0x9c, 0x85, 0x54, 0xea, 0xe9, 0x9f, 0xeb, 0x32, 0x48, 0xaf, 0x4a, 0xd3, - 0x95, 0x6a, 0x0, 0x0, 0x2, 0x5d, 0x97, 0x2, 0x0, 0x10, 0xee, 0xf4, 0x45, 0x8d, 0xa8, - 0xcb, 0xe4, 0x73, 0x3f, 0xbe, 0xe8, 0x4a, 0x8b, 0xb6, 0x4e, 0x9d, 0x0}; +// QoS0}),("\252\138+\n\175\ETX\235\\s\224\216\249m\228WJ\fy\195\226\195#\182\139\215",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\143\237,\176$\130\243/\DLE\DEL\156\226\192\193I%D7a\SUB",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\160}\178\229\154'\175?\176I\167Y\243r+\148\192\&4\186X:\192\247r\246\132",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\DC4\128\162\SO\152]\188\DC1\184\174M\136\DC4\203\235\164\203\ACK\136\208\255N\133\250\173",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("?'h\n\240j\b\244;\129\DEL\203\169\ENQ\149\140\131\168h\137$",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode9) { + uint8_t pkt[] = {0x82, 0xe6, 0x1, 0x6a, 0x98, 0x0, 0x14, 0xd9, 0x87, 0xd6, 0xf, 0x4b, 0x4c, 0xc, 0xd6, 0xe1, 0xd0, + 0x8d, 0xec, 0xc2, 0x3a, 0x34, 0xd4, 0xa2, 0x7b, 0x10, 0x18, 0x0, 0x0, 0x11, 0xcb, 0xc1, 0x3c, 0xdf, + 0xc6, 0x94, 0x3d, 0xfc, 0x13, 0x3d, 0x78, 0xc0, 0xcb, 0xd7, 0xe7, 0x32, 0xd3, 0x2, 0x0, 0x8, 0x2d, + 0x2e, 0x4e, 0x35, 0x50, 0x2, 0x43, 0x18, 0x2, 0x0, 0xc, 0x93, 0x10, 0xd2, 0x4b, 0x1e, 0x2c, 0x6e, + 0x8e, 0x3a, 0x30, 0x4f, 0xd9, 0x2, 0x0, 0x18, 0x2, 0x73, 0xbb, 0xd6, 0x6c, 0x24, 0x73, 0xa4, 0x39, + 0x4f, 0x7, 0x89, 0x4d, 0x84, 0xc5, 0x22, 0x97, 0xb3, 0xe5, 0x2c, 0xc1, 0xbc, 0x5e, 0xad, 0x0, 0x0, + 0x19, 0xfc, 0x8a, 0x2b, 0xa, 0xaf, 0x3, 0xeb, 0x5c, 0x73, 0xe0, 0xd8, 0xf9, 0x6d, 0xe4, 0x57, 0x4a, + 0xc, 0x79, 0xc3, 0xe2, 0xc3, 0x23, 0xb6, 0x8b, 0xd7, 0x1, 0x0, 0x14, 0x8f, 0xed, 0x2c, 0xb0, 0x24, + 0x82, 0xf3, 0x2f, 0x10, 0x7f, 0x9c, 0xe2, 0xc0, 0xc1, 0x49, 0x25, 0x44, 0x37, 0x61, 0x1a, 0x2, 0x0, + 0x1a, 0xa0, 0x7d, 0xb2, 0xe5, 0x9a, 0x27, 0xaf, 0x3f, 0xb0, 0x49, 0xa7, 0x59, 0xf3, 0x72, 0x2b, 0x94, + 0xc0, 0x34, 0xba, 0x58, 0x3a, 0xc0, 0xf7, 0x72, 0xf6, 0x84, 0x0, 0x0, 0x19, 0x14, 0x80, 0xa2, 0xe, + 0x98, 0x5d, 0xbc, 0x11, 0xb8, 0xae, 0x4d, 0x88, 0x14, 0xcb, 0xeb, 0xa4, 0xcb, 0x6, 0x88, 0xd0, 0xff, + 0x4e, 0x85, 0xfa, 0xad, 0x1, 0x0, 0x15, 0x3f, 0x27, 0x68, 0xa, 0xf0, 0x6a, 0x8, 0xf4, 0x3b, 0x81, + 0x7f, 0xcb, 0xa9, 0x5, 0x95, 0x8c, 0x83, 0xa8, 0x68, 0x89, 0x24, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x91, 0xb7, 0x6d, 0xe8, 0xd9, 0xbc, 0xcc, 0x5f, 0xdf, 0xf9, 0xa1, 0xaa, 0x9c, - 0x85, 0x54, 0xea, 0xe9, 0x9f, 0xeb, 0x32, 0x48, 0xaf, 0x4a, 0xd3, 0x95, 0x6a}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd9, 0x87, 0xd6, 0xf, 0x4b, 0x4c, 0xc, 0xd6, 0xe1, 0xd0, + 0x8d, 0xec, 0xc2, 0x3a, 0x34, 0xd4, 0xa2, 0x7b, 0x10, 0x18}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5d, 0x97}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xcb, 0xc1, 0x3c, 0xdf, 0xc6, 0x94, 0x3d, 0xfc, 0x13, + 0x3d, 0x78, 0xc0, 0xcb, 0xd7, 0xe7, 0x32, 0xd3}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xee, 0xf4, 0x45, 0x8d, 0xa8, 0xcb, 0xe4, 0x73, - 0x3f, 0xbe, 0xe8, 0x4a, 0x8b, 0xb6, 0x4e, 0x9d}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2d, 0x2e, 0x4e, 0x35, 0x50, 0x2, 0x43, 0x18}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; + uint8_t topic_filter_s3_bytes[] = {0x93, 0x10, 0xd2, 0x4b, 0x1e, 0x2c, 0x6e, 0x8e, 0x3a, 0x30, 0x4f, 0xd9}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x2, 0x73, 0xbb, 0xd6, 0x6c, 0x24, 0x73, 0xa4, 0x39, 0x4f, 0x7, 0x89, + 0x4d, 0x84, 0xc5, 0x22, 0x97, 0xb3, 0xe5, 0x2c, 0xc1, 0xbc, 0x5e, 0xad}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xfc, 0x8a, 0x2b, 0xa, 0xaf, 0x3, 0xeb, 0x5c, 0x73, 0xe0, 0xd8, 0xf9, 0x6d, + 0xe4, 0x57, 0x4a, 0xc, 0x79, 0xc3, 0xe2, 0xc3, 0x23, 0xb6, 0x8b, 0xd7}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8f, 0xed, 0x2c, 0xb0, 0x24, 0x82, 0xf3, 0x2f, 0x10, 0x7f, + 0x9c, 0xe2, 0xc0, 0xc1, 0x49, 0x25, 0x44, 0x37, 0x61, 0x1a}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xa0, 0x7d, 0xb2, 0xe5, 0x9a, 0x27, 0xaf, 0x3f, 0xb0, 0x49, 0xa7, 0x59, 0xf3, + 0x72, 0x2b, 0x94, 0xc0, 0x34, 0xba, 0x58, 0x3a, 0xc0, 0xf7, 0x72, 0xf6, 0x84}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x14, 0x80, 0xa2, 0xe, 0x98, 0x5d, 0xbc, 0x11, 0xb8, 0xae, 0x4d, 0x88, 0x14, + 0xcb, 0xeb, 0xa4, 0xcb, 0x6, 0x88, 0xd0, 0xff, 0x4e, 0x85, 0xfa, 0xad}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x3f, 0x27, 0x68, 0xa, 0xf0, 0x6a, 0x8, 0xf4, 0x3b, 0x81, 0x7f, + 0xcb, 0xa9, 0x5, 0x95, 0x8c, 0x83, 0xa8, 0x68, 0x89, 0x24}; + lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -10809,106 +10850,136 @@ TEST(Subscribe311QCTest, Encode9) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15580, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27288, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 10667 [("I\153\NUL\206\134\163T\222V`b\232I\232\254u\213}=\145\234\200$\183#\148\179",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("T\SYN\184.5\131\&8r'\221\184\170AuL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\194\SUB\SYN\139\NUL\NUL\233\RS\226\177\SUB\183\128",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\135\196\232\200\SOHm\GS\194\235\n|\SOH\251\ETB\f7\137\FS\211",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\225\240\SOH \SUB",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(":1R\165-\228F\219>\136\EOT?\198\224\DC2\129Z\215\250V\188\192\150\220\CAN\185\202\208^",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("A\140\&8\DC4?\EMv\CAN\214\t\FS'\255\208n\209\218\188\140\229o@",SubOptions {_retainHandling = +// SubscribeRequest 14432 [("\132\142U\243\225d\SO^\184\204\176\ng\214\232",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("6\141\148A\161M\182\EM\129\DC4R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("W'\224\128}N\177m\137c.\r!",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\159\&6B~\216U\149-\240\230\194\218\157\166\NAK",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("1\161\160\GS\211\175d\178\213\SOHv\135\171%\155B/\222\FS9(\185g\173\174x_I\224)",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS1}),("\ap\172QO\204\154J[\145n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\RS\167x\142;=\175\194m}:\128\206\146\&5 PF\224\155",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\168c\156\132\130\233l",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS1}),("\138\204\153\191\242P(t/<\251\206\247P*\239f",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\SOH5\252\ETX\182\137\247D\155\b\175\SO\193\137\fS\148\225\133^a\a\207T\160",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\182\129\173\SUB\239\244",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("\ACK\163\NAK\DC1\195\169\246\220\EMt-\224\251\210\190k\170\170\251\193\&0\DC1\208\233\&1\NUL1",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\n\SUB\192\143\n1\SYNu\131\135tm\186\224\200\235IQ4h>0",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("J\166;]\v@\SYNME\249\NAK +// \166\187\168h\EM,\194\193\148mF6\154d}\192",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\176\&9\ne\247S\212\228T\157k\157\139P\CAN\DC1\ESC\220\227$\252\ACK\217\192\128\128H\155\174",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0xea, 0x1, 0x29, 0xab, 0x0, 0x1b, 0x49, 0x99, 0x0, 0xce, 0x86, 0xa3, 0x54, 0xde, 0x56, 0x60, - 0x62, 0xe8, 0x49, 0xe8, 0xfe, 0x75, 0xd5, 0x7d, 0x3d, 0x91, 0xea, 0xc8, 0x24, 0xb7, 0x23, 0x94, 0xb3, - 0x1, 0x0, 0xf, 0x54, 0x16, 0xb8, 0x2e, 0x35, 0x83, 0x38, 0x72, 0x27, 0xdd, 0xb8, 0xaa, 0x41, 0x75, - 0x4c, 0x1, 0x0, 0xd, 0xc2, 0x1a, 0x16, 0x8b, 0x0, 0x0, 0xe9, 0x1e, 0xe2, 0xb1, 0x1a, 0xb7, 0x80, - 0x0, 0x0, 0x13, 0x87, 0xc4, 0xe8, 0xc8, 0x1, 0x6d, 0x1d, 0xc2, 0xeb, 0xa, 0x7c, 0x1, 0xfb, 0x17, - 0xc, 0x37, 0x89, 0x1c, 0xd3, 0x2, 0x0, 0x5, 0xe1, 0xf0, 0x1, 0x20, 0x1a, 0x0, 0x0, 0x1d, 0x3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xe3, 0x24, 0xfc, 0x6, 0xd9, 0xc0, 0x80, 0x80, 0x48, 0x9b, 0xae, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x49, 0x99, 0x0, 0xce, 0x86, 0xa3, 0x54, 0xde, 0x56, 0x60, 0x62, 0xe8, 0x49, 0xe8, - 0xfe, 0x75, 0xd5, 0x7d, 0x3d, 0x91, 0xea, 0xc8, 0x24, 0xb7, 0x23, 0x94, 0xb3}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x84, 0x8e, 0x55, 0xf3, 0xe1, 0x64, 0xe, 0x5e, + 0xb8, 0xcc, 0xb0, 0xa, 0x67, 0xd6, 0xe8}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x54, 0x16, 0xb8, 0x2e, 0x35, 0x83, 0x38, 0x72, - 0x27, 0xdd, 0xb8, 0xaa, 0x41, 0x75, 0x4c}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7, 0x70, 0xac, 0x51, 0x4f, 0xcc, 0x9a, 0x4a, 0x5b, 0x91, 0x6e}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc2, 0x1a, 0x16, 0x8b, 0x0, 0x0, 0xe9, 0x1e, 0xe2, 0xb1, 0x1a, 0xb7, 0x80}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1e, 0xa7, 0x78, 0x8e, 0x3b, 0x3d, 0xaf, 0xc2, 0x6d, 0x7d, + 0x3a, 0x80, 0xce, 0x92, 0x35, 0x20, 0x50, 0x46, 0xe0, 0x9b}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x87, 0xc4, 0xe8, 0xc8, 0x1, 0x6d, 0x1d, 0xc2, 0xeb, 0xa, - 0x7c, 0x1, 0xfb, 0x17, 0xc, 0x37, 0x89, 0x1c, 0xd3}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa8, 0x63, 0x9c, 0x84, 0x82, 0xe9, 0x6c}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe1, 0xf0, 0x1, 0x20, 0x1a}; - lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x8a, 0xcc, 0x99, 0xbf, 0xf2, 0x50, 0x28, 0x74, 0x2f, + 0x3c, 0xfb, 0xce, 0xf7, 0x50, 0x2a, 0xef, 0x66}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x3a, 0x31, 0x52, 0xa5, 0x2d, 0xe4, 0x46, 0xdb, 0x3e, 0x88, - 0x4, 0x3f, 0xc6, 0xe0, 0x12, 0x81, 0x5a, 0xd7, 0xfa, 0x56, - 0xbc, 0xc0, 0x96, 0xdc, 0x18, 0xb9, 0xca, 0xd0, 0x5e}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x1, 0x35, 0xfc, 0x3, 0xb6, 0x89, 0xf7, 0x44, 0x9b, 0x8, 0xaf, 0xe, 0xc1, + 0x89, 0xc, 0x53, 0x94, 0xe1, 0x85, 0x5e, 0x61, 0x7, 0xcf, 0x54, 0xa0}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x41, 0x8c, 0x38, 0x14, 0x3f, 0x19, 0x76, 0x18, 0xd6, 0x9, 0x1c, - 0x27, 0xff, 0xd0, 0x6e, 0xd1, 0xda, 0xbc, 0x8c, 0xe5, 0x6f, 0x40}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb6, 0x81, 0xad, 0x1a, 0xef, 0xf4}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x36, 0x8d, 0x94, 0x41, 0xa1, 0x4d, 0xb6, 0x19, 0x81, 0x14, 0x52}; - lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x6, 0xa3, 0x15, 0x11, 0xc3, 0xa9, 0xf6, 0xdc, 0x19, 0x74, 0x2d, 0xe0, 0xfb, 0xd2, + 0xbe, 0x6b, 0xaa, 0xaa, 0xfb, 0xc1, 0x30, 0x11, 0xd0, 0xe9, 0x31, 0x0, 0x31}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x57, 0x27, 0xe0, 0x80, 0x7d, 0x4e, 0xb1, 0x6d, 0x89, 0x63, 0x2e, 0xd, 0x21}; - lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xa, 0x1a, 0xc0, 0x8f, 0xa, 0x31, 0x16, 0x75, 0x83, 0x87, 0x74, + 0x6d, 0xba, 0xe0, 0xc8, 0xeb, 0x49, 0x51, 0x34, 0x68, 0x3e, 0x30}; + lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x9f, 0x36, 0x42, 0x7e, 0xd8, 0x55, 0x95, 0x2d, - 0xf0, 0xe6, 0xc2, 0xda, 0x9d, 0xa6, 0x15}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0x4a, 0xa6, 0x3b, 0x5d, 0xb, 0x40, 0x16, 0x4d, 0x45, 0xf9, + 0x15, 0x20, 0xa6, 0xbb, 0xa8, 0x68, 0x19, 0x2c, 0xc2, 0xc1, + 0x94, 0x6d, 0x46, 0x36, 0x9a, 0x64, 0x7d, 0xc0}; + lwmqtt_string_t topic_filter_s9 = {28, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x31, 0xa1, 0xa0, 0x1d, 0xd3, 0xaf, 0x64, 0xb2, 0xd5, 0x1, - 0x76, 0x87, 0xab, 0x25, 0x9b, 0x42, 0x2f, 0xde, 0x1c, 0x39, - 0x28, 0xb9, 0x67, 0xad, 0xae, 0x78, 0x5f, 0x49, 0xe0, 0x29}; - lwmqtt_string_t topic_filter_s10 = {30, (char*)&topic_filter_s10_bytes}; + uint8_t topic_filter_s10_bytes[] = {0xb0, 0x39, 0xa, 0x65, 0xf7, 0x53, 0xd4, 0xe4, 0x54, 0x9d, + 0x6b, 0x9d, 0x8b, 0x50, 0x18, 0x11, 0x1b, 0xdc, 0xe3, 0x24, + 0xfc, 0x6, 0xd9, 0xc0, 0x80, 0x80, 0x48, 0x9b, 0xae}; + lwmqtt_string_t topic_filter_s10 = {29, (char*)&topic_filter_s10_bytes}; topic_filters[10] = topic_filter_s10; lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -10916,19 +10987,19 @@ TEST(Subscribe311QCTest, Encode10) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; @@ -10936,11 +11007,11 @@ TEST(Subscribe311QCTest, Encode10) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].qos = LWMQTT_QOS2; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].qos = LWMQTT_QOS1; sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; @@ -10954,66 +11025,70 @@ TEST(Subscribe311QCTest, Encode10) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10667, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14432, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 13196 [("\171M\DLE+(\172\SIL\DEL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS2}),("\182H\165\138\247\bHO\207\164\ACKr\239\151\ENQ\137\190k\182\&4",SubOptions {_retainHandling = +// SubscribeRequest 29362 [("_\243\230\136\DEL\192\SOH\129",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(")^\224-\RSS\187\132\DLE\157\228F\236\193P/= +// \US\203\163d<\r>\228\239\253\SO\223",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("d!#X=\180_\191R\DEL\180\224\148\190i\152\228b",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\231~\137\219\155\189\239N\199\208$X\206\145\176Q0\SIv\145\ETX",SubOptions {_retainHandling = +// QoS1}),("\209\139\ACKUg\\\156\248\"\241\232*\SUB\148\"~\131c\rpq\ENQ\DC3\212\179y\RSX",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\135\&4Dk@\b\247\150\217%:t\198f\195\&4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("\186,\216\227\251\233`o\219\177\179\DC4\ETB\226\180\143\194\CAN\202\140\&1Y\213\a\ACKq\165^",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS0}),("_\231\198F\215\f\226\236\156vQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\225_l!\242_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0x6f, 0x33, 0x8c, 0x0, 0x9, 0xab, 0x4d, 0x10, 0x2b, 0x28, 0xac, 0xf, 0x4c, 0x7f, 0x2, 0x0, - 0x14, 0xb6, 0x48, 0xa5, 0x8a, 0xf7, 0x8, 0x48, 0x4f, 0xcf, 0xa4, 0x6, 0x72, 0xef, 0x97, 0x5, 0x89, - 0xbe, 0x6b, 0xb6, 0x34, 0x2, 0x0, 0x15, 0xe7, 0x7e, 0x89, 0xdb, 0x9b, 0xbd, 0xef, 0x4e, 0xc7, 0xd0, - 0x24, 0x58, 0xce, 0x91, 0xb0, 0x51, 0x30, 0xf, 0x76, 0x91, 0x3, 0x2, 0x0, 0x10, 0x87, 0x34, 0x44, - 0x6b, 0x40, 0x8, 0xf7, 0x96, 0xd9, 0x25, 0x3a, 0x74, 0xc6, 0x66, 0xc3, 0x34, 0x2, 0x0, 0x1c, 0xba, - 0x2c, 0xd8, 0xe3, 0xfb, 0xe9, 0x60, 0x6f, 0xdb, 0xb1, 0xb3, 0x14, 0x17, 0xe2, 0xb4, 0x8f, 0xc2, 0x18, - 0xca, 0x8c, 0x31, 0x59, 0xd5, 0x7, 0x6, 0x71, 0xa5, 0x5e, 0x0}; + uint8_t pkt[] = {0x82, 0x79, 0x72, 0xb2, 0x0, 0x8, 0x5f, 0xf3, 0xe6, 0x88, 0x7f, 0xc0, 0x1, 0x81, 0x0, 0x0, + 0x1e, 0x29, 0x5e, 0xe0, 0x2d, 0x1e, 0x53, 0xbb, 0x84, 0x10, 0x9d, 0xe4, 0x46, 0xec, 0xc1, 0x50, + 0x2f, 0x3d, 0x20, 0x1f, 0xcb, 0xa3, 0x64, 0x3c, 0xd, 0x3e, 0xe4, 0xef, 0xfd, 0xe, 0xdf, 0x0, + 0x0, 0x12, 0x64, 0x21, 0x23, 0x58, 0x3d, 0xb4, 0x5f, 0xbf, 0x52, 0x7f, 0xb4, 0xe0, 0x94, 0xbe, + 0x69, 0x98, 0xe4, 0x62, 0x1, 0x0, 0x1c, 0xd1, 0x8b, 0x6, 0x55, 0x67, 0x5c, 0x9c, 0xf8, 0x22, + 0xf1, 0xe8, 0x2a, 0x1a, 0x94, 0x22, 0x7e, 0x83, 0x63, 0xd, 0x70, 0x71, 0x5, 0x13, 0xd4, 0xb3, + 0x79, 0x1e, 0x58, 0x0, 0x0, 0xb, 0x5f, 0xe7, 0xc6, 0x46, 0xd7, 0xc, 0xe2, 0xec, 0x9c, 0x76, + 0x51, 0x0, 0x0, 0x6, 0xe1, 0x5f, 0x6c, 0x21, 0xf2, 0x5f, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xab, 0x4d, 0x10, 0x2b, 0x28, 0xac, 0xf, 0x4c, 0x7f}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x5f, 0xf3, 0xe6, 0x88, 0x7f, 0xc0, 0x1, 0x81}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb6, 0x48, 0xa5, 0x8a, 0xf7, 0x8, 0x48, 0x4f, 0xcf, 0xa4, - 0x6, 0x72, 0xef, 0x97, 0x5, 0x89, 0xbe, 0x6b, 0xb6, 0x34}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x29, 0x5e, 0xe0, 0x2d, 0x1e, 0x53, 0xbb, 0x84, 0x10, 0x9d, + 0xe4, 0x46, 0xec, 0xc1, 0x50, 0x2f, 0x3d, 0x20, 0x1f, 0xcb, + 0xa3, 0x64, 0x3c, 0xd, 0x3e, 0xe4, 0xef, 0xfd, 0xe, 0xdf}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe7, 0x7e, 0x89, 0xdb, 0x9b, 0xbd, 0xef, 0x4e, 0xc7, 0xd0, 0x24, - 0x58, 0xce, 0x91, 0xb0, 0x51, 0x30, 0xf, 0x76, 0x91, 0x3}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x64, 0x21, 0x23, 0x58, 0x3d, 0xb4, 0x5f, 0xbf, 0x52, + 0x7f, 0xb4, 0xe0, 0x94, 0xbe, 0x69, 0x98, 0xe4, 0x62}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x87, 0x34, 0x44, 0x6b, 0x40, 0x8, 0xf7, 0x96, - 0xd9, 0x25, 0x3a, 0x74, 0xc6, 0x66, 0xc3, 0x34}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd1, 0x8b, 0x6, 0x55, 0x67, 0x5c, 0x9c, 0xf8, 0x22, 0xf1, + 0xe8, 0x2a, 0x1a, 0x94, 0x22, 0x7e, 0x83, 0x63, 0xd, 0x70, + 0x71, 0x5, 0x13, 0xd4, 0xb3, 0x79, 0x1e, 0x58}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xba, 0x2c, 0xd8, 0xe3, 0xfb, 0xe9, 0x60, 0x6f, 0xdb, 0xb1, - 0xb3, 0x14, 0x17, 0xe2, 0xb4, 0x8f, 0xc2, 0x18, 0xca, 0x8c, - 0x31, 0x59, 0xd5, 0x7, 0x6, 0x71, 0xa5, 0x5e}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x5f, 0xe7, 0xc6, 0x46, 0xd7, 0xc, 0xe2, 0xec, 0x9c, 0x76, 0x51}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s5_bytes[] = {0xe1, 0x5f, 0x6c, 0x21, 0xf2, 0x5f}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -11021,28 +11096,35 @@ TEST(Subscribe311QCTest, Encode11) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13196, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29362, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11145 [("\237\a\171\195\220\245\232@\229P\146~C\193\193\139\138\EOTF\139\ACK\135\ETX\253",SubOptions +// SubscribeRequest 18382 +// [("\231\EM\193\193q\251\CAN\154\SYN\230\146\204c_\141w\148\DC3\215\RS!\ETXw\186x$n\182\231",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode12) { - uint8_t pkt[] = {0x82, 0x1d, 0x2b, 0x89, 0x0, 0x18, 0xed, 0x7, 0xab, 0xc3, 0xdc, 0xf5, 0xe8, 0x40, 0xe5, 0x50, - 0x92, 0x7e, 0x43, 0xc1, 0xc1, 0x8b, 0x8a, 0x4, 0x46, 0x8b, 0x6, 0x87, 0x3, 0xfd, 0x2}; + uint8_t pkt[] = {0x82, 0x22, 0x47, 0xce, 0x0, 0x1d, 0xe7, 0x19, 0xc1, 0xc1, 0x71, 0xfb, + 0x18, 0x9a, 0x16, 0xe6, 0x92, 0xcc, 0x63, 0x5f, 0x8d, 0x77, 0x94, 0x13, + 0xd7, 0x1e, 0x21, 0x3, 0x77, 0xba, 0x78, 0x24, 0x6e, 0xb6, 0xe7, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x7, 0xab, 0xc3, 0xdc, 0xf5, 0xe8, 0x40, 0xe5, 0x50, 0x92, 0x7e, - 0x43, 0xc1, 0xc1, 0x8b, 0x8a, 0x4, 0x46, 0x8b, 0x6, 0x87, 0x3, 0xfd}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xe7, 0x19, 0xc1, 0xc1, 0x71, 0xfb, 0x18, 0x9a, 0x16, 0xe6, + 0x92, 0xcc, 0x63, 0x5f, 0x8d, 0x77, 0x94, 0x13, 0xd7, 0x1e, + 0x21, 0x3, 0x77, 0xba, 0x78, 0x24, 0x6e, 0xb6, 0xe7}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; lwmqtt_sub_options_t sub_opts[1]; sub_opts[0].qos = LWMQTT_QOS2; @@ -11055,47 +11137,119 @@ TEST(Subscribe311QCTest, Encode12) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11145, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18382, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22549 -// [("q&N\176\217\FS\143\140\217\b\164\171\163\233\237\200\214\223\156\197\201\182e\DC3q",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\251N<\255g\164",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\236\US\180\241\219\242\200\196\229J\244\135\&7]\225L\136\132\213\128\&8\252\234\US\157\230k\NAK}g",SubOptions +// SubscribeRequest 3280 [("\252\153?\GSp",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("_\132\USe\201\201\207X\SI%\DC4\188n<\231p\ACK{\157\165\215\142\182\165\234\137\&6u",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\157FH\237\157\&9\207X2\190\240\162\239\164",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("\\3\146\160\169\t\156\ENQ\193$\238\197jL\b\216\252\216",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\ETX\240",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\a;J7U.\178\156\&8d\196\SO$\145\224\131Y\200\&2+;l",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("E\177t%H\185\EOTxHjzc\212\174}XI\SYNBe*\SOH\249Q6R\NUL-",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0x59, 0x58, 0x15, 0x0, 0x19, 0x71, 0x26, 0x4e, 0xb0, 0xd9, 0x1c, 0x8f, 0x8c, 0xd9, 0x8, - 0xa4, 0xab, 0xa3, 0xe9, 0xed, 0xc8, 0xd6, 0xdf, 0x9c, 0xc5, 0xc9, 0xb6, 0x65, 0x13, 0x71, 0x0, - 0x0, 0x6, 0xfb, 0x4e, 0x3c, 0xff, 0x67, 0xa4, 0x1, 0x0, 0x1e, 0xec, 0x1f, 0xb4, 0xf1, 0xdb, - 0xf2, 0xc8, 0xc4, 0xe5, 0x4a, 0xf4, 0x87, 0x37, 0x5d, 0xe1, 0x4c, 0x88, 0x84, 0xd5, 0x80, 0x38, - 0xfc, 0xea, 0x1f, 0x9d, 0xe6, 0x6b, 0x15, 0x7d, 0x67, 0x2, 0x0, 0xe, 0x9d, 0x46, 0x48, 0xed, - 0x9d, 0x39, 0xcf, 0x58, 0x32, 0xbe, 0xf0, 0xa2, 0xef, 0xa4, 0x2}; + uint8_t pkt[] = {0x82, 0x7b, 0xc, 0xd0, 0x0, 0x5, 0xfc, 0x99, 0x3f, 0x1d, 0x70, 0x0, 0x0, 0x1c, 0x5f, 0x84, + 0x1f, 0x65, 0xc9, 0xc9, 0xcf, 0x58, 0xf, 0x25, 0x14, 0xbc, 0x6e, 0x3c, 0xe7, 0x70, 0x6, 0x7b, + 0x9d, 0xa5, 0xd7, 0x8e, 0xb6, 0xa5, 0xea, 0x89, 0x36, 0x75, 0x2, 0x0, 0x12, 0x5c, 0x33, 0x92, + 0xa0, 0xa9, 0x9, 0x9c, 0x5, 0xc1, 0x24, 0xee, 0xc5, 0x6a, 0x4c, 0x8, 0xd8, 0xfc, 0xd8, 0x1, + 0x0, 0x2, 0x3, 0xf0, 0x1, 0x0, 0x16, 0x7, 0x3b, 0x4a, 0x37, 0x55, 0x2e, 0xb2, 0x9c, 0x38, + 0x64, 0xc4, 0xe, 0x24, 0x91, 0xe0, 0x83, 0x59, 0xc8, 0x32, 0x2b, 0x3b, 0x6c, 0x2, 0x0, 0x1c, + 0x45, 0xb1, 0x74, 0x25, 0x48, 0xb9, 0x4, 0x78, 0x48, 0x6a, 0x7a, 0x63, 0xd4, 0xae, 0x7d, 0x58, + 0x49, 0x16, 0x42, 0x65, 0x2a, 0x1, 0xf9, 0x51, 0x36, 0x52, 0x0, 0x2d, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xfc, 0x99, 0x3f, 0x1d, 0x70}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x5f, 0x84, 0x1f, 0x65, 0xc9, 0xc9, 0xcf, 0x58, 0xf, 0x25, + 0x14, 0xbc, 0x6e, 0x3c, 0xe7, 0x70, 0x6, 0x7b, 0x9d, 0xa5, + 0xd7, 0x8e, 0xb6, 0xa5, 0xea, 0x89, 0x36, 0x75}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5c, 0x33, 0x92, 0xa0, 0xa9, 0x9, 0x9c, 0x5, 0xc1, + 0x24, 0xee, 0xc5, 0x6a, 0x4c, 0x8, 0xd8, 0xfc, 0xd8}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x3, 0xf0}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x7, 0x3b, 0x4a, 0x37, 0x55, 0x2e, 0xb2, 0x9c, 0x38, 0x64, 0xc4, + 0xe, 0x24, 0x91, 0xe0, 0x83, 0x59, 0xc8, 0x32, 0x2b, 0x3b, 0x6c}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x45, 0xb1, 0x74, 0x25, 0x48, 0xb9, 0x4, 0x78, 0x48, 0x6a, + 0x7a, 0x63, 0xd4, 0xae, 0x7d, 0x58, 0x49, 0x16, 0x42, 0x65, + 0x2a, 0x1, 0xf9, 0x51, 0x36, 0x52, 0x0, 0x2d}; + lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3280, 6, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 4639 [("\165\EM\DC2g\NUL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\ESCH\249\163F",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\203\206z\136",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\156`s_",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode14) { + uint8_t pkt[] = {0x82, 0x20, 0x12, 0x1f, 0x0, 0x5, 0xa5, 0x19, 0x12, 0x67, 0x0, 0x2, 0x0, 0x5, 0x1b, 0x48, 0xf9, + 0xa3, 0x46, 0x1, 0x0, 0x4, 0xcb, 0xce, 0x7a, 0x88, 0x1, 0x0, 0x4, 0x9c, 0x60, 0x73, 0x5f, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x71, 0x26, 0x4e, 0xb0, 0xd9, 0x1c, 0x8f, 0x8c, 0xd9, 0x8, 0xa4, 0xab, 0xa3, - 0xe9, 0xed, 0xc8, 0xd6, 0xdf, 0x9c, 0xc5, 0xc9, 0xb6, 0x65, 0x13, 0x71}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xa5, 0x19, 0x12, 0x67, 0x0}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfb, 0x4e, 0x3c, 0xff, 0x67, 0xa4}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1b, 0x48, 0xf9, 0xa3, 0x46}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xec, 0x1f, 0xb4, 0xf1, 0xdb, 0xf2, 0xc8, 0xc4, 0xe5, 0x4a, - 0xf4, 0x87, 0x37, 0x5d, 0xe1, 0x4c, 0x88, 0x84, 0xd5, 0x80, - 0x38, 0xfc, 0xea, 0x1f, 0x9d, 0xe6, 0x6b, 0x15, 0x7d, 0x67}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xcb, 0xce, 0x7a, 0x88}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9d, 0x46, 0x48, 0xed, 0x9d, 0x39, 0xcf, - 0x58, 0x32, 0xbe, 0xf0, 0xa2, 0xef, 0xa4}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9c, 0x60, 0x73, 0x5f}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11103,11 +11257,11 @@ TEST(Subscribe311QCTest, Encode13) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -11117,81 +11271,75 @@ TEST(Subscribe311QCTest, Encode13) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22549, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4639, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18393 [("{\US\242",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\201=\vz\142\EOT\237}\162$\ETXL\232c\RS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\247y\217\183\158j\243\153\130ub\232\193\210\DC4lt\EOTGRnv",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 23421 [("\251(\b\221xT^\230i\US\136\EOT",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("8\140\&6\235T\162\129K\250\154E\163q\165\161\233\218\239\191\198%\208\222",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\167",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\138)\154\144@\221\174\188\n\143\197\159E6\191\149\251",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("Vi\140c:I\156\DEL\172\220A\GS9zg\167",SubOptions +// QoS0}),("\239\134\214\190s\242G\b\155\159\231F\196",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("R\224\a\fdO\239\252\137\148rl,\DELe\145\206_\153\201\&4\149\173\208\\\n[\213\227",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\193\198\250h\138\172\219di\163g\DC3\186`\129\162\202w\171\252",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0x92, 0x1, 0x47, 0xd9, 0x0, 0x3, 0x7b, 0x1f, 0xf2, 0x0, 0x0, 0xf, 0xc9, 0x3d, 0xb, 0x7a, - 0x8e, 0x4, 0xed, 0x7d, 0xa2, 0x24, 0x3, 0x4c, 0xe8, 0x63, 0x1e, 0x2, 0x0, 0x16, 0xf7, 0x79, 0xd9, - 0xb7, 0x9e, 0x6a, 0xf3, 0x99, 0x82, 0x75, 0x62, 0xe8, 0xc1, 0xd2, 0x14, 0x6c, 0x74, 0x4, 0x47, 0x52, - 0x6e, 0x76, 0x1, 0x0, 0x17, 0x38, 0x8c, 0x36, 0xeb, 0x54, 0xa2, 0x81, 0x4b, 0xfa, 0x9a, 0x45, 0xa3, - 0x71, 0xa5, 0xa1, 0xe9, 0xda, 0xef, 0xbf, 0xc6, 0x25, 0xd0, 0xde, 0x2, 0x0, 0x1, 0xa7, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x11, 0x8a, 0x29, 0x9a, 0x90, 0x40, 0xdd, 0xae, 0xbc, 0xa, 0x8f, 0xc5, 0x9f, 0x45, - 0x36, 0xbf, 0x95, 0xfb, 0x0, 0x0, 0x10, 0x56, 0x69, 0x8c, 0x63, 0x3a, 0x49, 0x9c, 0x7f, 0xac, 0xdc, - 0x41, 0x1d, 0x39, 0x7a, 0x67, 0xa7, 0x1, 0x0, 0x14, 0xc1, 0xc6, 0xfa, 0x68, 0x8a, 0xac, 0xdb, 0x64, - 0x69, 0xa3, 0x67, 0x13, 0xba, 0x60, 0x81, 0xa2, 0xca, 0x77, 0xab, 0xfc, 0x1}; +// QoS2}),("\221A\172\SYN\229\189\v\177\194\tM6\158\244\184\129\CANc;T\142\&1@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\159\222\ESC0\198\131\133\220\213\242\238\229\202\SUB\151\&4R\223cL\171r:\136\128\t\nV1@\206",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("a&xM$\210\&9\179\194\SI\232\178-s\215;\DC3E\193\184\RS\SOH\177:S\170\ESC\167\158\220",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\243\230\164\181\242q51",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\241\132\161\156\244\141F\218\249\201\204\144\202\196\&9`\GS\165",SubOptions {_retainHandling = +// QoS1}),("\176O\235\183\144\ETX\224\ACK\173\237*\DLE\129\NUL\CAN\151",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\210\189\SI\243c",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("q\153\236Z\130\171\216\197\231W\253\192\139w\159\140\236\ENQ\215~\174\170t\NUL\154\179{\GS\253",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("0^\RS\201\&4\228\214UU\a.\252\227V\\\SOH\198\n.\162\217\196",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\167Y1\156C@\EOTw\191",SubOptions {_retainHandling = +// QoS0}),("\164\176\159\168\229\233v\159\v\223\227\158\207\190\216\187\203Z",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode15) { - uint8_t pkt[] = { - 0x82, 0xee, 0x1, 0x6f, 0x5b, 0x0, 0x7, 0x92, 0xc7, 0xe8, 0xc, 0x6a, 0xe2, 0x64, 0x2, 0x0, 0xd, 0x2a, 0xd5, - 0x86, 0x50, 0xa9, 0x30, 0x53, 0xcf, 0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c9, 0x34, 0xe4, 0xd6, 0x55, 0x55, 0x7, 0x2e, 0xfc, 0xe3, 0x56, 0x5c, 0x1, 0xc6, 0xa, 0x2e, 0xa2, 0xd9, 0xc4, - 0x0, 0x0, 0x9, 0xa7, 0x59, 0x31, 0x9c, 0x43, 0x40, 0x4, 0x77, 0xbf, 0x2}; +TEST(Subscribe311QCTest, Encode16) { + uint8_t pkt[] = {0x82, 0xd0, 0x1, 0x72, 0xe5, 0x0, 0x1c, 0xd, 0xb1, 0xff, 0x38, 0xcd, 0x54, 0xdc, 0xdd, 0xc8, 0x49, + 0x87, 0xb3, 0x0, 0x8, 0x26, 0xd2, 0x3c, 0xa0, 0x76, 0x8b, 0xae, 0x95, 0x70, 0xe2, 0x31, 0x2, 0xe3, + 0xaa, 0x0, 0x0, 0x6, 0x15, 0x52, 0x4c, 0x69, 0xe, 0x21, 0x2, 0x0, 0xe, 0x5e, 0x24, 0xc3, 0xdd, + 0x71, 0x59, 0x74, 0x4b, 0x31, 0xa5, 0x6c, 0x59, 0xe6, 0xff, 0x2, 0x0, 0x19, 0x1d, 0xa4, 0xba, 0x96, + 0xbf, 0xd, 0x9, 0x6f, 0xbd, 0xbe, 0x96, 0xb7, 0x29, 0x29, 0x61, 0x19, 0xeb, 0x12, 0x42, 0x5c, 0xd7, + 0x47, 0xed, 0x3a, 0xa1, 0x0, 0x0, 0x16, 0x67, 0xb9, 0xe4, 0x5b, 0x11, 0x25, 0x36, 0x1c, 0x24, 0xfb, + 0xef, 0xd2, 0x85, 0x95, 0xb8, 0x36, 0x31, 0x4, 0x53, 0x83, 0xbe, 0x93, 0x1, 0x0, 0x16, 0x34, 0x54, + 0x42, 0xeb, 0x4b, 0xd7, 0x4e, 0x22, 0xc6, 0x3e, 0x4c, 0xab, 0x72, 0x3a, 0x88, 0x80, 0x9, 0xa, 0x56, + 0x31, 0x40, 0xce, 0x0, 0x0, 0x14, 0x98, 0xb2, 0x18, 0xaf, 0x51, 0xe5, 0x68, 0x11, 0x39, 0x49, 0xc9, + 0xbe, 0x3e, 0xe6, 0xa4, 0xb5, 0xf2, 0x71, 0x35, 0x31, 0x1, 0x0, 0x10, 0xb0, 0x4f, 0xeb, 0xb7, 0x90, + 0x3, 0xe0, 0x6, 0xad, 0xed, 0x2a, 0x10, 0x81, 0x0, 0x18, 0x97, 0x1, 0x0, 0x5, 0xd2, 0xbd, 0xf, + 0xf3, 0x63, 0x0, 0x0, 0x12, 0xa4, 0xb0, 0x9f, 0xa8, 0xe5, 0xe9, 0x76, 0x9f, 0xb, 0xdf, 0xe3, 0x9e, + 0xcf, 0xbe, 0xd8, 0xbb, 0xcb, 0x5a, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x92, 0xc7, 0xe8, 0xc, 0x6a, 0xe2, 0x64}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd, 0xb1, 0xff, 0x38, 0xcd, 0x54, 0xdc, 0xdd, 0xc8, 0x49, + 0x87, 0xb3, 0x0, 0x8, 0x26, 0xd2, 0x3c, 0xa0, 0x76, 0x8b, + 0xae, 0x95, 0x70, 0xe2, 0x31, 0x2, 0xe3, 0xaa}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2a, 0xd5, 0x86, 0x50, 0xa9, 0x30, 0x53, 0xcf, 0xe5, 0x2d, 0xff, 0x47, 0x9e}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x15, 0x52, 0x4c, 0x69, 0xe, 0x21}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe2, 0xcb, 0xb7, 0xa, 0x4f, 0xe7, 0x97, 0xa, 0x44, 0xe1, 0xd0, - 0x21, 0xa9, 0x4e, 0xa6, 0xe4, 0xdc, 0x23, 0x12, 0x57, 0x55, 0xf}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5e, 0x24, 0xc3, 0xdd, 0x71, 0x59, 0x74, + 0x4b, 0x31, 0xa5, 0x6c, 0x59, 0xe6, 0xff}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfb, 0x9, 0xb3}; - lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1d, 0xa4, 0xba, 0x96, 0xbf, 0xd, 0x9, 0x6f, 0xbd, 0xbe, 0x96, 0xb7, 0x29, + 0x29, 0x61, 0x19, 0xeb, 0x12, 0x42, 0x5c, 0xd7, 0x47, 0xed, 0x3a, 0xa1}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7e, 0x90, 0x4a, 0xe7, 0x22, 0x36, 0x18, 0x91, 0x23, 0xcd, 0x7a, - 0x5d, 0x3, 0x55, 0x4b, 0xd4, 0x37, 0x91, 0x4, 0xb0, 0xfc, 0xe}; + uint8_t topic_filter_s4_bytes[] = {0x67, 0xb9, 0xe4, 0x5b, 0x11, 0x25, 0x36, 0x1c, 0x24, 0xfb, 0xef, + 0xd2, 0x85, 0x95, 0xb8, 0x36, 0x31, 0x4, 0x53, 0x83, 0xbe, 0x93}; lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x61, 0x26, 0x78, 0x4d, 0x24, 0xd2, 0x39, 0xb3, 0xc2, 0xf, - 0xe8, 0xb2, 0x2d, 0x73, 0xd7, 0x3b, 0x13, 0x45, 0xc1, 0xb8, - 0x1e, 0x1, 0xb1, 0x3a, 0x53, 0xaa, 0x1b, 0xa7, 0x9e, 0xdc}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x34, 0x54, 0x42, 0xeb, 0x4b, 0xd7, 0x4e, 0x22, 0xc6, 0x3e, 0x4c, + 0xab, 0x72, 0x3a, 0x88, 0x80, 0x9, 0xa, 0x56, 0x31, 0x40, 0xce}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf3, 0x3c, 0x67, 0xd3, 0xc6, 0x22, 0x51, 0x7a, 0x75, 0xb8, - 0x52, 0x7, 0x5f, 0x63, 0x7, 0x91, 0x28, 0x7d, 0x25, 0x1a, - 0x6e, 0x31, 0x7f, 0x26, 0x20, 0x2e, 0xe4, 0xa5}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x98, 0xb2, 0x18, 0xaf, 0x51, 0xe5, 0x68, 0x11, 0x39, 0x49, + 0xc9, 0xbe, 0x3e, 0xe6, 0xa4, 0xb5, 0xf2, 0x71, 0x35, 0x31}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf1, 0x84, 0xa1, 0x9c, 0xf4, 0x8d, 0x46, 0xda, 0xf9, - 0xc9, 0xcc, 0x90, 0xca, 0xc4, 0x39, 0x60, 0x1d, 0xa5}; - lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xb0, 0x4f, 0xeb, 0xb7, 0x90, 0x3, 0xe0, 0x6, + 0xad, 0xed, 0x2a, 0x10, 0x81, 0x0, 0x18, 0x97}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x71, 0x99, 0xec, 0x5a, 0x82, 0xab, 0xd8, 0xc5, 0xe7, 0x57, - 0xfd, 0xc0, 0x8b, 0x77, 0x9f, 0x8c, 0xec, 0x5, 0xd7, 0x7e, - 0xae, 0xaa, 0x74, 0x0, 0x9a, 0xb3, 0x7b, 0x1d, 0xfd}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xd2, 0xbd, 0xf, 0xf3, 0x63}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x30, 0x5e, 0x1e, 0xc9, 0x34, 0xe4, 0xd6, 0x55, 0x55, 0x7, 0x2e, - 0xfc, 0xe3, 0x56, 0x5c, 0x1, 0xc6, 0xa, 0x2e, 0xa2, 0xd9, 0xc4}; - lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0xa4, 0xb0, 0x9f, 0xa8, 0xe5, 0xe9, 0x76, 0x9f, 0xb, + 0xdf, 0xe3, 0x9e, 0xcf, 0xbe, 0xd8, 0xbb, 0xcb, 0x5a}; + lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xa7, 0x59, 0x31, 0x9c, 0x43, 0x40, 0x4, 0x77, 0xbf}; - lwmqtt_string_t topic_filter_s10 = {9, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -11339,73 +11474,70 @@ TEST(Subscribe311QCTest, Encode15) { sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].qos = LWMQTT_QOS2; sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28507, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29413, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23094 [("\128\&6\225\129\221\170",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS0}),("\163\250\137\240\239Q\202\n\217\167\232\STX\199\245m\147/\184\154\ESC\\-F\223\n\141\220\&1'\196",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\254\143\243T\251\204J",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS0}),("\250\165\218\255^o\227\134\STXZ\172\209\130\n7F\146\SO\237~H",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\173\FS\206\233\172\r\198\\\142\185*\217L1\233v`",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0x62, 0x5a, 0x36, 0x0, 0x6, 0x80, 0x36, 0xe1, 0x81, 0xdd, 0xaa, 0x0, 0x0, 0x1e, 0xa3, 0xfa, - 0x89, 0xf0, 0xef, 0x51, 0xca, 0xa, 0xd9, 0xa7, 0xe8, 0x2, 0xc7, 0xf5, 0x6d, 0x93, 0x2f, 0xb8, 0x9a, - 0x1b, 0x5c, 0x2d, 0x46, 0xdf, 0xa, 0x8d, 0xdc, 0x31, 0x27, 0xc4, 0x2, 0x0, 0x7, 0xfe, 0x8f, 0xf3, - 0x54, 0xfb, 0xcc, 0x4a, 0x0, 0x0, 0x15, 0xfa, 0xa5, 0xda, 0xff, 0x5e, 0x6f, 0xe3, 0x86, 0x2, 0x5a, - 0xac, 0xd1, 0x82, 0xa, 0x37, 0x46, 0x92, 0xe, 0xed, 0x7e, 0x48, 0x0, 0x0, 0x11, 0xad, 0x1c, 0xce, - 0xe9, 0xac, 0xd, 0xc6, 0x5c, 0x8e, 0xb9, 0x2a, 0xd9, 0x4c, 0x31, 0xe9, 0x76, 0x60, 0x2}; +// SubscribeRequest 6204 [("O\CAN\197/\176M5\196\CAN\225\129Lt\140(",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\182\157\155]\RS\202Z\206F\192\t\240bW\211\158\163b\219\147F3>",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\173U\245\ACK\156A\ENQ\208\187\208\DELX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\188\246\170$\240\EM",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\"~R\129\189*P\134\186\ETB\222\230\&4\168^\237\146\ACK\240\190q\205\153U\SOH^|H",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode17) { + uint8_t pkt[] = {0x82, 0x65, 0x18, 0x3c, 0x0, 0xf, 0x4f, 0x18, 0xc5, 0x2f, 0xb0, 0x4d, 0x35, 0xc4, 0x18, + 0xe1, 0x81, 0x4c, 0x74, 0x8c, 0x28, 0x2, 0x0, 0x17, 0xb6, 0x9d, 0x9b, 0x5d, 0x1e, 0xca, + 0x5a, 0xce, 0x46, 0xc0, 0x9, 0xf0, 0x62, 0x57, 0xd3, 0x9e, 0xa3, 0x62, 0xdb, 0x93, 0x46, + 0x33, 0x3e, 0x2, 0x0, 0xc, 0xad, 0x55, 0xf5, 0x6, 0x9c, 0x41, 0x5, 0xd0, 0xbb, 0xd0, + 0x7f, 0x58, 0x1, 0x0, 0x6, 0xbc, 0xf6, 0xaa, 0x24, 0xf0, 0x19, 0x0, 0x0, 0x1c, 0x22, + 0x7e, 0x52, 0x81, 0xbd, 0x2a, 0x50, 0x86, 0xba, 0x17, 0xde, 0xe6, 0x34, 0xa8, 0x5e, 0xed, + 0x92, 0x6, 0xf0, 0xbe, 0x71, 0xcd, 0x99, 0x55, 0x1, 0x5e, 0x7c, 0x48, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x80, 0x36, 0xe1, 0x81, 0xdd, 0xaa}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x4f, 0x18, 0xc5, 0x2f, 0xb0, 0x4d, 0x35, 0xc4, + 0x18, 0xe1, 0x81, 0x4c, 0x74, 0x8c, 0x28}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa3, 0xfa, 0x89, 0xf0, 0xef, 0x51, 0xca, 0xa, 0xd9, 0xa7, - 0xe8, 0x2, 0xc7, 0xf5, 0x6d, 0x93, 0x2f, 0xb8, 0x9a, 0x1b, - 0x5c, 0x2d, 0x46, 0xdf, 0xa, 0x8d, 0xdc, 0x31, 0x27, 0xc4}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb6, 0x9d, 0x9b, 0x5d, 0x1e, 0xca, 0x5a, 0xce, 0x46, 0xc0, 0x9, 0xf0, + 0x62, 0x57, 0xd3, 0x9e, 0xa3, 0x62, 0xdb, 0x93, 0x46, 0x33, 0x3e}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfe, 0x8f, 0xf3, 0x54, 0xfb, 0xcc, 0x4a}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xad, 0x55, 0xf5, 0x6, 0x9c, 0x41, 0x5, 0xd0, 0xbb, 0xd0, 0x7f, 0x58}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfa, 0xa5, 0xda, 0xff, 0x5e, 0x6f, 0xe3, 0x86, 0x2, 0x5a, 0xac, - 0xd1, 0x82, 0xa, 0x37, 0x46, 0x92, 0xe, 0xed, 0x7e, 0x48}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xbc, 0xf6, 0xaa, 0x24, 0xf0, 0x19}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xad, 0x1c, 0xce, 0xe9, 0xac, 0xd, 0xc6, 0x5c, 0x8e, - 0xb9, 0x2a, 0xd9, 0x4c, 0x31, 0xe9, 0x76, 0x60}; - lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x22, 0x7e, 0x52, 0x81, 0xbd, 0x2a, 0x50, 0x86, 0xba, 0x17, + 0xde, 0xe6, 0x34, 0xa8, 0x5e, 0xed, 0x92, 0x6, 0xf0, 0xbe, + 0x71, 0xcd, 0x99, 0x55, 0x1, 0x5e, 0x7c, 0x48}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11413,7 +11545,7 @@ TEST(Subscribe311QCTest, Encode16) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -11421,7 +11553,7 @@ TEST(Subscribe311QCTest, Encode16) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -11431,94 +11563,186 @@ TEST(Subscribe311QCTest, Encode16) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23094, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6204, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7726 [("\143]\132\&9x\254\"\152\138W\190\240~\234\155>\147W\SOv%\NAK\US\230l",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\155\"\219\&9`\138\145\182\&3\178\147\226G\a[h\191`\212`\185\143",SubOptions {_retainHandling = +// QoS1}),("\198\151\141\&8-\DEL\251\FS\a\CANfH\231*i\179\172\r\239_\141S(~Y\236",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("a]\205\220o\197]\139qT\177$?P\151\158\141=\231\157\249k\231H\159\163.",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode18) { - uint8_t pkt[] = {0x82, 0xe6, 0x1, 0x4, 0xab, 0x0, 0x9, 0x3, 0xbf, 0x9c, 0x1f, 0x33, 0x89, 0x35, 0xbe, 0x61, 0x0, - 0x0, 0xe, 0xa5, 0x15, 0xc4, 0x50, 0x20, 0xec, 0xac, 0xc5, 0x4d, 0x8c, 0xb1, 0x72, 0x1a, 0x9f, 0x0, - 0x0, 0x5, 0x1e, 0xcf, 0xc0, 0xd8, 0xa8, 0x0, 0x0, 0x1a, 0x33, 0xdd, 0x69, 0x11, 0xa2, 0xe2, 0xd6, - 0x45, 0x6e, 0x57, 0xfa, 0x9c, 0xe6, 0xb6, 0x3b, 0x56, 0xc3, 0xe6, 0x64, 0x0, 0xae, 0x3c, 0xad, 0x4a, - 0x8b, 0xa0, 0x1, 0x0, 0x14, 0xfa, 0x75, 0x97, 0x9f, 0x50, 0x27, 0x8b, 0x19, 0x9d, 0x55, 0xfa, 0x2b, - 0x15, 0x48, 0x92, 0x2b, 0x56, 0xca, 0x52, 0x7a, 0x1, 0x0, 0x19, 0xc7, 0x55, 0x53, 0x78, 0xae, 0x69, - 0x61, 0x1d, 0x7a, 0x6, 0x12, 0x5c, 0x29, 0xc0, 0x1, 0x43, 0x8e, 0x60, 0x2f, 0x7c, 0xce, 0x4a, 0x60, - 0x44, 0x4f, 0x1, 0x0, 0x1d, 0xea, 0xc2, 0x81, 0x7e, 0x7a, 0x39, 0x5f, 0x45, 0xc, 0x76, 0x6b, 0xe8, - 0xa8, 0x69, 0x31, 0x7d, 0x29, 0x2f, 0x88, 0x52, 0x54, 0x8d, 0xaa, 0xb8, 0x3a, 0xd2, 0x40, 0xe3, 0x49, - 0x1, 0x0, 0x15, 0x44, 0xa9, 0xd7, 0x2f, 0x30, 0x52, 0x7f, 0xc9, 0x3e, 0xea, 0x9b, 0x3e, 0x93, 0x57, - 0xe, 0x76, 0x25, 0x15, 0x1f, 0xe6, 0x6c, 0x1, 0x0, 0x16, 0x9b, 0x22, 0xdb, 0x39, 0x60, 0x8a, 0x91, - 0xb6, 0x33, 0xb2, 0x93, 0xe2, 0x47, 0x7, 0x5b, 0x68, 0xbf, 0x60, 0xd4, 0x60, 0xb9, 0x8f, 0x0, 0x0, - 0x1b, 0x61, 0x5d, 0xcd, 0xdc, 0x6f, 0xc5, 0x5d, 0x8b, 0x71, 0x54, 0xb1, 0x24, 0x3f, 0x50, 0x97, 0x9e, - 0x8d, 0x3d, 0xe7, 0x9d, 0xf9, 0x6b, 0xe7, 0x48, 0x9f, 0xa3, 0x2e, 0x1}; +// QoS0}),("9oU\227^\\\129P74A\252\165^<\US\206\&6\148\182\&1\154\238\235\248\210\164\ENQ\ACK\184",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode21) { + uint8_t pkt[] = {0x82, 0x80, 0x1, 0x31, 0xee, 0x0, 0xd, 0xee, 0xc7, 0xa3, 0x4, 0x24, 0xe4, 0xad, 0xae, 0x19, 0x80, + 0x76, 0x41, 0xd8, 0x2, 0x0, 0x13, 0xac, 0x2c, 0xcb, 0xf8, 0x5a, 0x81, 0x1d, 0x1e, 0x6a, 0x2e, 0xd0, + 0x7, 0x71, 0x4d, 0xb2, 0xa7, 0x6e, 0x37, 0xeb, 0x0, 0x0, 0x17, 0xe5, 0x2e, 0xd2, 0x98, 0x17, 0xea, + 0xe5, 0x56, 0x1c, 0xb1, 0xd6, 0x17, 0x45, 0x8f, 0x44, 0x17, 0xde, 0x9a, 0x9d, 0x26, 0xcc, 0xf7, 0xef, + 0x1, 0x0, 0x1a, 0xc6, 0x97, 0x8d, 0x38, 0x2d, 0x7f, 0xfb, 0x1c, 0x7, 0x18, 0x66, 0x48, 0xe7, 0x2a, + 0x69, 0xb3, 0xac, 0xd, 0xef, 0x5f, 0x8d, 0x53, 0x28, 0x7e, 0x59, 0xec, 0x0, 0x0, 0x1e, 0x39, 0x6f, + 0x55, 0xe3, 0x5e, 0x5c, 0x81, 0x50, 0x37, 0x34, 0x41, 0xfc, 0xa5, 0x5e, 0x3c, 0x1f, 0xce, 0x36, 0x94, + 0xb6, 0x31, 0x9a, 0xee, 0xeb, 0xf8, 0xd2, 0xa4, 0x5, 0x6, 0xb8, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x3, 0xbf, 0x9c, 0x1f, 0x33, 0x89, 0x35, 0xbe, 0x61}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xee, 0xc7, 0xa3, 0x4, 0x24, 0xe4, 0xad, 0xae, 0x19, 0x80, 0x76, 0x41, 0xd8}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa5, 0x15, 0xc4, 0x50, 0x20, 0xec, 0xac, - 0xc5, 0x4d, 0x8c, 0xb1, 0x72, 0x1a, 0x9f}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xac, 0x2c, 0xcb, 0xf8, 0x5a, 0x81, 0x1d, 0x1e, 0x6a, 0x2e, + 0xd0, 0x7, 0x71, 0x4d, 0xb2, 0xa7, 0x6e, 0x37, 0xeb}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1e, 0xcf, 0xc0, 0xd8, 0xa8}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe5, 0x2e, 0xd2, 0x98, 0x17, 0xea, 0xe5, 0x56, 0x1c, 0xb1, 0xd6, 0x17, + 0x45, 0x8f, 0x44, 0x17, 0xde, 0x9a, 0x9d, 0x26, 0xcc, 0xf7, 0xef}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x33, 0xdd, 0x69, 0x11, 0xa2, 0xe2, 0xd6, 0x45, 0x6e, 0x57, 0xfa, 0x9c, 0xe6, - 0xb6, 0x3b, 0x56, 0xc3, 0xe6, 0x64, 0x0, 0xae, 0x3c, 0xad, 0x4a, 0x8b, 0xa0}; + uint8_t topic_filter_s3_bytes[] = {0xc6, 0x97, 0x8d, 0x38, 0x2d, 0x7f, 0xfb, 0x1c, 0x7, 0x18, 0x66, 0x48, 0xe7, + 0x2a, 0x69, 0xb3, 0xac, 0xd, 0xef, 0x5f, 0x8d, 0x53, 0x28, 0x7e, 0x59, 0xec}; lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xfa, 0x75, 0x97, 0x9f, 0x50, 0x27, 0x8b, 0x19, 0x9d, 0x55, - 0xfa, 0x2b, 0x15, 0x48, 0x92, 0x2b, 0x56, 0xca, 0x52, 0x7a}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x39, 0x6f, 0x55, 0xe3, 0x5e, 0x5c, 0x81, 0x50, 0x37, 0x34, + 0x41, 0xfc, 0xa5, 0x5e, 0x3c, 0x1f, 0xce, 0x36, 0x94, 0xb6, + 0x31, 0x9a, 0xee, 0xeb, 0xf8, 0xd2, 0xa4, 0x5, 0x6, 0xb8}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc7, 0x55, 0x53, 0x78, 0xae, 0x69, 0x61, 0x1d, 0x7a, 0x6, 0x12, 0x5c, 0x29, - 0xc0, 0x1, 0x43, 0x8e, 0x60, 0x2f, 0x7c, 0xce, 0x4a, 0x60, 0x44, 0x4f}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xea, 0xc2, 0x81, 0x7e, 0x7a, 0x39, 0x5f, 0x45, 0xc, 0x76, - 0x6b, 0xe8, 0xa8, 0x69, 0x31, 0x7d, 0x29, 0x2f, 0x88, 0x52, - 0x54, 0x8d, 0xaa, 0xb8, 0x3a, 0xd2, 0x40, 0xe3, 0x49}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x44, 0xa9, 0xd7, 0x2f, 0x30, 0x52, 0x7f, 0xc9, 0x3e, 0xea, 0x9b, - 0x3e, 0x93, 0x57, 0xe, 0x76, 0x25, 0x15, 0x1f, 0xe6, 0x6c}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x9b, 0x22, 0xdb, 0x39, 0x60, 0x8a, 0x91, 0xb6, 0x33, 0xb2, 0x93, - 0xe2, 0x47, 0x7, 0x5b, 0x68, 0xbf, 0x60, 0xd4, 0x60, 0xb9, 0x8f}; - lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x61, 0x5d, 0xcd, 0xdc, 0x6f, 0xc5, 0x5d, 0x8b, 0x71, 0x54, 0xb1, 0x24, 0x3f, 0x50, - 0x97, 0x9e, 0x8d, 0x3d, 0xe7, 0x9d, 0xf9, 0x6b, 0xe7, 0x48, 0x9f, 0xa3, 0x2e}; - lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11658,112 +11848,121 @@ TEST(Subscribe311QCTest, Encode18) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1195, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12782, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4397 -// [("\SUB\ETX\210\235\182\"\235m\202\r6\154h\136\163\131\130\186$\186\129+[\232\241\213\194x\211\187",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\192#0\201ZxW\ENQ\210 ^}0\SOH\CAN\213\248",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS2}),("j\249\215G\224\163\155\205/\178\206fT\139\&0~\215\CAN\233!\DC4",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\EOT\211",SubOptions +// SubscribeRequest 7994 [("w\248Bj\ETB\DC2\226U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\190\217[",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("4/\225\175\&4\185\&5j\228\195\217\184\142\145(7%\165fb]\156\STX",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\131\156\225\148\176O5\ETX\213\218\214\174\214S\242\198Y\152\&2V%\188\222\GS8",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("1\US\176)\SYN3\SO\n\n4r\188\165vj\216\187]%\243\&244\SYN\186\166\r",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\170:\197\207\254\DLE\218c\r\134\184\235\NULq?\174\146B\227\240\211",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\151\237H\215M\151\DC4\144\228\180c\210\v\195\251",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\162\255\252\DC17\138\&3.\159W\239\237{Z/T\SO\132\246\251\170\243\186\162\177\&7",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\136\FS\200\185\171\231^l\SO\167\145f\226\219\143`\t^\137F\163",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode19) { - uint8_t pkt[] = {0x82, 0x72, 0x11, 0x2d, 0x0, 0x1e, 0x1a, 0x3, 0xd2, 0xeb, 0xb6, 0x22, 0xeb, 0x6d, 0xca, 0xd, 0x36, - 0x9a, 0x68, 0x88, 0xa3, 0x83, 0x82, 0xba, 0x24, 0xba, 0x81, 0x2b, 0x5b, 0xe8, 0xf1, 0xd5, 0xc2, 0x78, - 0xd3, 0xbb, 0x2, 0x0, 0x11, 0xc0, 0x23, 0x30, 0xc9, 0x5a, 0x78, 0x57, 0x5, 0xd2, 0x20, 0x5e, 0x7d, - 0x30, 0x1, 0x18, 0xd5, 0xf8, 0x2, 0x0, 0x15, 0x6a, 0xf9, 0xd7, 0x47, 0xe0, 0xa3, 0x9b, 0xcd, 0x2f, - 0xb2, 0xce, 0x66, 0x54, 0x8b, 0x30, 0x7e, 0xd7, 0x18, 0xe9, 0x21, 0x14, 0x1, 0x0, 0x0, 0x0, 0x0, - 0x2, 0x4, 0xd3, 0x1, 0x0, 0x15, 0x88, 0x1c, 0xc8, 0xb9, 0xab, 0xe7, 0x5e, 0x6c, 0xe, 0xa7, 0x91, - 0x66, 0xe2, 0xdb, 0x8f, 0x60, 0x9, 0x5e, 0x89, 0x46, 0xa3, 0x0, 0x0, 0x0, 0x2}; +// QoS2}),("\225)u\SUB\181#\ETB\132 \212\238G9{|-{h:@r0\186r\DC4\214\225\&4",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("l$",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),(">\217\185\166\NAK\216\248(\172\194\189",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode22) { + uint8_t pkt[] = { + 0x82, 0xe0, 0x1, 0x1f, 0x3a, 0x0, 0x8, 0x77, 0xf8, 0x42, 0x6a, 0x17, 0x12, 0xe2, 0x55, 0x0, 0x0, 0x3, 0xbe, + 0xd9, 0x5b, 0x1, 0x0, 0x17, 0x34, 0x2f, 0xe1, 0xaf, 0x34, 0xb9, 0x35, 0x6a, 0xe4, 0xc3, 0xd9, 0xb8, 0x8e, 0x91, + 0x28, 0x37, 0x25, 0xa5, 0x66, 0x62, 0x5d, 0x9c, 0x2, 0x2, 0x0, 0x19, 0x83, 0x9c, 0xe1, 0x94, 0xb0, 0x4f, 0x35, + 0x3, 0xd5, 0xda, 0xd6, 0xae, 0xd6, 0x53, 0xf2, 0xc6, 0x59, 0x98, 0x32, 0x56, 0x25, 0xbc, 0xde, 0x1d, 0x38, 0x2, + 0x0, 0x1b, 0x31, 0x1f, 0xb0, 0x29, 0x16, 0x33, 0xe, 0xa, 0xa, 0x34, 0x72, 0xbc, 0xa5, 0x76, 0x6a, 0xd8, 0xbb, + 0x5d, 0x25, 0xf3, 0x32, 0x34, 0x34, 0x16, 0xba, 0xa6, 0xd, 0x1, 0x0, 0x15, 0xaa, 0x3a, 0xc5, 0xcf, 0xfe, 0x10, + 0xda, 0x63, 0xd, 0x86, 0xb8, 0xeb, 0x0, 0x71, 0x3f, 0xae, 0x92, 0x42, 0xe3, 0xf0, 0xd3, 0x2, 0x0, 0xf, 0x97, + 0xed, 0x48, 0xd7, 0x4d, 0x97, 0x14, 0x90, 0xe4, 0xb4, 0x63, 0xd2, 0xb, 0xc3, 0xfb, 0x0, 0x0, 0x1a, 0xa2, 0xff, + 0xfc, 0x11, 0x37, 0x8a, 0x33, 0x2e, 0x9f, 0x57, 0xef, 0xed, 0x7b, 0x5a, 0x2f, 0x54, 0xe, 0x84, 0xf6, 0xfb, 0xaa, + 0xf3, 0xba, 0xa2, 0xb1, 0x37, 0x2, 0x0, 0x1c, 0xe1, 0x29, 0x75, 0x1a, 0xb5, 0x23, 0x17, 0x84, 0x20, 0xd4, 0xee, + 0x47, 0x39, 0x7b, 0x7c, 0x2d, 0x7b, 0x68, 0x3a, 0x40, 0x72, 0x30, 0xba, 0x72, 0x14, 0xd6, 0xe1, 0x34, 0x1, 0x0, + 0x2, 0x6c, 0x24, 0x1, 0x0, 0xb, 0x3e, 0xd9, 0xb9, 0xa6, 0x15, 0xd8, 0xf8, 0x28, 0xac, 0xc2, 0xbd, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x1a, 0x3, 0xd2, 0xeb, 0xb6, 0x22, 0xeb, 0x6d, 0xca, 0xd, - 0x36, 0x9a, 0x68, 0x88, 0xa3, 0x83, 0x82, 0xba, 0x24, 0xba, - 0x81, 0x2b, 0x5b, 0xe8, 0xf1, 0xd5, 0xc2, 0x78, 0xd3, 0xbb}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x77, 0xf8, 0x42, 0x6a, 0x17, 0x12, 0xe2, 0x55}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc0, 0x23, 0x30, 0xc9, 0x5a, 0x78, 0x57, 0x5, 0xd2, - 0x20, 0x5e, 0x7d, 0x30, 0x1, 0x18, 0xd5, 0xf8}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbe, 0xd9, 0x5b}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6a, 0xf9, 0xd7, 0x47, 0xe0, 0xa3, 0x9b, 0xcd, 0x2f, 0xb2, 0xce, - 0x66, 0x54, 0x8b, 0x30, 0x7e, 0xd7, 0x18, 0xe9, 0x21, 0x14}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x34, 0x2f, 0xe1, 0xaf, 0x34, 0xb9, 0x35, 0x6a, 0xe4, 0xc3, 0xd9, 0xb8, + 0x8e, 0x91, 0x28, 0x37, 0x25, 0xa5, 0x66, 0x62, 0x5d, 0x9c, 0x2}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x83, 0x9c, 0xe1, 0x94, 0xb0, 0x4f, 0x35, 0x3, 0xd5, 0xda, 0xd6, 0xae, 0xd6, + 0x53, 0xf2, 0xc6, 0x59, 0x98, 0x32, 0x56, 0x25, 0xbc, 0xde, 0x1d, 0x38}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4, 0xd3}; - lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x1f, 0xb0, 0x29, 0x16, 0x33, 0xe, 0xa, 0xa, 0x34, 0x72, 0xbc, 0xa5, 0x76, + 0x6a, 0xd8, 0xbb, 0x5d, 0x25, 0xf3, 0x32, 0x34, 0x34, 0x16, 0xba, 0xa6, 0xd}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x88, 0x1c, 0xc8, 0xb9, 0xab, 0xe7, 0x5e, 0x6c, 0xe, 0xa7, 0x91, - 0x66, 0xe2, 0xdb, 0x8f, 0x60, 0x9, 0x5e, 0x89, 0x46, 0xa3}; + uint8_t topic_filter_s5_bytes[] = {0xaa, 0x3a, 0xc5, 0xcf, 0xfe, 0x10, 0xda, 0x63, 0xd, 0x86, 0xb8, + 0xeb, 0x0, 0x71, 0x3f, 0xae, 0x92, 0x42, 0xe3, 0xf0, 0xd3}; lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x97, 0xed, 0x48, 0xd7, 0x4d, 0x97, 0x14, 0x90, + 0xe4, 0xb4, 0x63, 0xd2, 0xb, 0xc3, 0xfb}; + lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s7_bytes[] = {0xa2, 0xff, 0xfc, 0x11, 0x37, 0x8a, 0x33, 0x2e, 0x9f, 0x57, 0xef, 0xed, 0x7b, + 0x5a, 0x2f, 0x54, 0xe, 0x84, 0xf6, 0xfb, 0xaa, 0xf3, 0xba, 0xa2, 0xb1, 0x37}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe1, 0x29, 0x75, 0x1a, 0xb5, 0x23, 0x17, 0x84, 0x20, 0xd4, + 0xee, 0x47, 0x39, 0x7b, 0x7c, 0x2d, 0x7b, 0x68, 0x3a, 0x40, + 0x72, 0x30, 0xba, 0x72, 0x14, 0xd6, 0xe1, 0x34}; + lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x6c, 0x24}; + lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x3e, 0xd9, 0xb9, 0xa6, 0x15, 0xd8, 0xf8, 0x28, 0xac, 0xc2, 0xbd}; + lwmqtt_string_t topic_filter_s10 = {11, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -11771,60 +11970,94 @@ TEST(Subscribe311QCTest, Encode19) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4397, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7994, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27847 -// [("\243<\205\142\254\168U\222\165,\134\130\135\225_\143\205\US\162\203D\ETBR\SO\n\242\194",SubOptions +// SubscribeRequest 23842 [("\140\185\224\250R\251\"\210\238\130\148\253\176\167\230\DELx%",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("k\157(%\238\144\NAK\133\246\206\163w\161\180x5X\SI\SYN(\130\224u\222\247\155\175\200",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("s\199\173\183n\252\245\235\237\ETX\SOH\189\190M9\160/+",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\148",SubOptions {_retainHandling = SendOnSubscribe, +// QoS0}),("\188k9#!@s.\150+\ETBF\197\DC3i\159Z\197,\214\167\253\245\aE",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("4x\187\128\139\&3\a\DC3\233\136\CAN{\200\172B\213\155\SYNS\175\221\183\195\GS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode20) { - uint8_t pkt[] = {0x82, 0x54, 0x6c, 0xc7, 0x0, 0x1b, 0xf3, 0x3c, 0xcd, 0x8e, 0xfe, 0xa8, 0x55, 0xde, 0xa5, - 0x2c, 0x86, 0x82, 0x87, 0xe1, 0x5f, 0x8f, 0xcd, 0x1f, 0xa2, 0xcb, 0x44, 0x17, 0x52, 0xe, - 0xa, 0xf2, 0xc2, 0x2, 0x0, 0x12, 0x73, 0xc7, 0xad, 0xb7, 0x6e, 0xfc, 0xf5, 0xeb, 0xed, - 0x3, 0x1, 0xbd, 0xbe, 0x4d, 0x39, 0xa0, 0x2f, 0x2b, 0x0, 0x0, 0x1, 0x94, 0x2, 0x0, - 0x18, 0x34, 0x78, 0xbb, 0x80, 0x8b, 0x33, 0x7, 0x13, 0xe9, 0x88, 0x18, 0x7b, 0xc8, 0xac, - 0x42, 0xd5, 0x9b, 0x16, 0x53, 0xaf, 0xdd, 0xb7, 0xc3, 0x1d, 0x0}; +// QoS0}),("+\194\188\205\157\178\221\t\245\213\254W\129\251A\aV\219\210\b\229<\149\204&\201\196\182U",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\222\146\234\140\195c\209LL$\222\179\153\DEL\208\218\132\209\214%\139\228\230",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\CAN\151aE\174\174\225\221%N\238d\SI\187",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x5d, 0x22, 0x0, 0x12, 0x8c, 0xb9, 0xe0, 0xfa, 0x52, 0xfb, 0x22, 0xd2, 0xee, + 0x82, 0x94, 0xfd, 0xb0, 0xa7, 0xe6, 0x7f, 0x78, 0x25, 0x1, 0x0, 0x1c, 0x6b, 0x9d, 0x28, 0x25, + 0xee, 0x90, 0x15, 0x85, 0xf6, 0xce, 0xa3, 0x77, 0xa1, 0xb4, 0x78, 0x35, 0x58, 0xf, 0x16, 0x28, + 0x82, 0xe0, 0x75, 0xde, 0xf7, 0x9b, 0xaf, 0xc8, 0x0, 0x0, 0x19, 0xbc, 0x6b, 0x39, 0x23, 0x21, + 0x40, 0x73, 0x2e, 0x96, 0x2b, 0x17, 0x46, 0xc5, 0x13, 0x69, 0x9f, 0x5a, 0xc5, 0x2c, 0xd6, 0xa7, + 0xfd, 0xf5, 0x7, 0x45, 0x0, 0x0, 0x1d, 0x2b, 0xc2, 0xbc, 0xcd, 0x9d, 0xb2, 0xdd, 0x9, 0xf5, + 0xd5, 0xfe, 0x57, 0x81, 0xfb, 0x41, 0x7, 0x56, 0xdb, 0xd2, 0x8, 0xe5, 0x3c, 0x95, 0xcc, 0x26, + 0xc9, 0xc4, 0xb6, 0x55, 0x2, 0x0, 0x17, 0xde, 0x92, 0xea, 0x8c, 0xc3, 0x63, 0xd1, 0x4c, 0x4c, + 0x24, 0xde, 0xb3, 0x99, 0x7f, 0xd0, 0xda, 0x84, 0xd1, 0xd6, 0x25, 0x8b, 0xe4, 0xe6, 0x1, 0x0, + 0xe, 0x18, 0x97, 0x61, 0x45, 0xae, 0xae, 0xe1, 0xdd, 0x25, 0x4e, 0xee, 0x64, 0xf, 0xbb, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xf3, 0x3c, 0xcd, 0x8e, 0xfe, 0xa8, 0x55, 0xde, 0xa5, 0x2c, 0x86, 0x82, 0x87, 0xe1, - 0x5f, 0x8f, 0xcd, 0x1f, 0xa2, 0xcb, 0x44, 0x17, 0x52, 0xe, 0xa, 0xf2, 0xc2}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x8c, 0xb9, 0xe0, 0xfa, 0x52, 0xfb, 0x22, 0xd2, 0xee, + 0x82, 0x94, 0xfd, 0xb0, 0xa7, 0xe6, 0x7f, 0x78, 0x25}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x73, 0xc7, 0xad, 0xb7, 0x6e, 0xfc, 0xf5, 0xeb, 0xed, - 0x3, 0x1, 0xbd, 0xbe, 0x4d, 0x39, 0xa0, 0x2f, 0x2b}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6b, 0x9d, 0x28, 0x25, 0xee, 0x90, 0x15, 0x85, 0xf6, 0xce, + 0xa3, 0x77, 0xa1, 0xb4, 0x78, 0x35, 0x58, 0xf, 0x16, 0x28, + 0x82, 0xe0, 0x75, 0xde, 0xf7, 0x9b, 0xaf, 0xc8}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x94}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xbc, 0x6b, 0x39, 0x23, 0x21, 0x40, 0x73, 0x2e, 0x96, 0x2b, 0x17, 0x46, 0xc5, + 0x13, 0x69, 0x9f, 0x5a, 0xc5, 0x2c, 0xd6, 0xa7, 0xfd, 0xf5, 0x7, 0x45}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x34, 0x78, 0xbb, 0x80, 0x8b, 0x33, 0x7, 0x13, 0xe9, 0x88, 0x18, 0x7b, - 0xc8, 0xac, 0x42, 0xd5, 0x9b, 0x16, 0x53, 0xaf, 0xdd, 0xb7, 0xc3, 0x1d}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x2b, 0xc2, 0xbc, 0xcd, 0x9d, 0xb2, 0xdd, 0x9, 0xf5, 0xd5, + 0xfe, 0x57, 0x81, 0xfb, 0x41, 0x7, 0x56, 0xdb, 0xd2, 0x8, + 0xe5, 0x3c, 0x95, 0xcc, 0x26, 0xc9, 0xc4, 0xb6, 0x55}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s4_bytes[] = {0xde, 0x92, 0xea, 0x8c, 0xc3, 0x63, 0xd1, 0x4c, 0x4c, 0x24, 0xde, 0xb3, + 0x99, 0x7f, 0xd0, 0xda, 0x84, 0xd1, 0xd6, 0x25, 0x8b, 0xe4, 0xe6}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x18, 0x97, 0x61, 0x45, 0xae, 0xae, 0xe1, 0xdd, 0x25, 0x4e, 0xee, 0x64, 0xf, 0xbb}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11832,110 +12065,128 @@ TEST(Subscribe311QCTest, Encode20) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27847, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23842, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29011 [("L\255\232\&7",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\ENQ -// \STX\209\189\DEL\160\167\&6~\254\SYN\144\246\217(\GS\207(c\142\241",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\237\194\247\230\ETX\134\225\f\SI\143\242\181\&1+\226EO\223\186\144se\216HY>\170\209",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\155O\191\161v\218\167\168_\147\DC1",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\FS\236xY=!\172\241\217\230\209\222\179\DC2\SI",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("d}\134\162\229\233`\212\248\207\DC4\254\137\186\232KP\165\222\144",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\241\197)E\130G\STX\248\&7w\179\173\243\vTB\FS\212o\195jN\201\151Z\NUL",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\194\235)\201J\157\SOH3\t|\DC4\164\v\175\206\SOHY\236 \166(\212\130",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\181H\154\233\193\216W\142\190\172\173\206\ACKC`",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 26921 [("K3\SI\145\&6N\152\205\207\211\175\226(",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\232\&0\ESC1 |\197\148\&8\225\CAN*\229",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode24) { + uint8_t pkt[] = {0x82, 0x22, 0x69, 0x29, 0x0, 0xd, 0x4b, 0x33, 0xf, 0x91, 0x36, 0x4e, + 0x98, 0xcd, 0xcf, 0xd3, 0xaf, 0xe2, 0x28, 0x0, 0x0, 0xd, 0xe8, 0x30, + 0x1b, 0x31, 0x20, 0x7c, 0xc5, 0x94, 0x38, 0xe1, 0x18, 0x2a, 0xe5, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x4b, 0x33, 0xf, 0x91, 0x36, 0x4e, 0x98, 0xcd, 0xcf, 0xd3, 0xaf, 0xe2, 0x28}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xe8, 0x30, 0x1b, 0x31, 0x20, 0x7c, 0xc5, 0x94, 0x38, 0xe1, 0x18, 0x2a, 0xe5}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26921, 2, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 21060 [("|\157\247\167%X\146\239\FSa@\163\225",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(".\147\177\f\201\211\245\229\237\RS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\EOT\149z\193\&2\140\137\131\155#}#h\153\&4",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("s\231w\220\208\DC4\157\191\CAN\EOTo\187\170.c\DLE-\219",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode21) { - uint8_t pkt[] = {0x82, 0xd9, 0x1, 0x71, 0x53, 0x0, 0x4, 0x4c, 0xff, 0xe8, 0x37, 0x0, 0x0, 0x0, 0x0, 0x0, 0x16, - 0x5, 0x20, 0x2, 0xd1, 0xbd, 0x7f, 0xa0, 0xa7, 0x36, 0x7e, 0xfe, 0x16, 0x90, 0xf6, 0xd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0x2d, 0xdb, 0x0}; +// QoS1}),("oo\189n\216\174\b[\219d\225\166\b\146^/\138\130\132[\235",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\176\&5\141\&1\143<\138xIV~\187\\\234\250Sa\US\240\219w8vTXw",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\164\153\198\218k\176b\231\SO",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Y\156\203\236\EOT\225\149\165[\246\158\US(\248",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\140\170^\229\250K\220\216\241\233\146\"",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode25) { + uint8_t pkt[] = {0x82, 0x92, 0x1, 0x52, 0x44, 0x0, 0xd, 0x7c, 0x9d, 0xf7, 0xa7, 0x25, 0x58, 0x92, 0xef, 0x1c, 0x61, + 0x40, 0xa3, 0xe1, 0x1, 0x0, 0xa, 0x2e, 0x93, 0xb1, 0xc, 0xc9, 0xd3, 0xf5, 0xe5, 0xed, 0x1e, 0x1, + 0x0, 0xf, 0x4, 0x95, 0x7a, 0xc1, 0x32, 0x8c, 0x89, 0x83, 0x9b, 0x23, 0x7d, 0x23, 0x68, 0x99, 0x34, + 0x1, 0x0, 0x15, 0x6f, 0x6f, 0xbd, 0x6e, 0xd8, 0xae, 0x8, 0x5b, 0xdb, 0x64, 0xe1, 0xa6, 0x8, 0x92, + 0x5e, 0x2f, 0x8a, 0x82, 0x84, 0x5b, 0xeb, 0x2, 0x0, 0x1a, 0xb0, 0x35, 0x8d, 0x31, 0x8f, 0x3c, 0x8a, + 0x78, 0x49, 0x56, 0x7e, 0xbb, 0x5c, 0xea, 0xfa, 0x53, 0x61, 0x1f, 0xf0, 0xdb, 0x77, 0x38, 0x76, 0x54, + 0x58, 0x77, 0x1, 0x0, 0x9, 0xa4, 0x99, 0xc6, 0xda, 0x6b, 0xb0, 0x62, 0xe7, 0xe, 0x2, 0x0, 0xe, + 0x59, 0x9c, 0xcb, 0xec, 0x4, 0xe1, 0x95, 0xa5, 0x5b, 0xf6, 0x9e, 0x1f, 0x28, 0xf8, 0x2, 0x0, 0xc, + 0x8c, 0xaa, 0x5e, 0xe5, 0xfa, 0x4b, 0xdc, 0xd8, 0xf1, 0xe9, 0x92, 0x22, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x4c, 0xff, 0xe8, 0x37}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x7c, 0x9d, 0xf7, 0xa7, 0x25, 0x58, 0x92, 0xef, 0x1c, 0x61, 0x40, 0xa3, 0xe1}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2e, 0x93, 0xb1, 0xc, 0xc9, 0xd3, 0xf5, 0xe5, 0xed, 0x1e}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5, 0x20, 0x2, 0xd1, 0xbd, 0x7f, 0xa0, 0xa7, 0x36, 0x7e, 0xfe, - 0x16, 0x90, 0xf6, 0xd9, 0x28, 0x1d, 0xcf, 0x28, 0x63, 0x8e, 0xf1}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4, 0x95, 0x7a, 0xc1, 0x32, 0x8c, 0x89, 0x83, + 0x9b, 0x23, 0x7d, 0x23, 0x68, 0x99, 0x34}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xed, 0xc2, 0xf7, 0xe6, 0x3, 0x86, 0xe1, 0xc, 0xf, 0x8f, - 0xf2, 0xb5, 0x31, 0x2b, 0xe2, 0x45, 0x4f, 0xdf, 0xba, 0x90, - 0x73, 0x65, 0xd8, 0x48, 0x59, 0x3e, 0xaa, 0xd1}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6f, 0x6f, 0xbd, 0x6e, 0xd8, 0xae, 0x8, 0x5b, 0xdb, 0x64, 0xe1, + 0xa6, 0x8, 0x92, 0x5e, 0x2f, 0x8a, 0x82, 0x84, 0x5b, 0xeb}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9b, 0x4f, 0xbf, 0xa1, 0x76, 0xda, 0xa7, 0xa8, 0x5f, 0x93, 0x11}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xb0, 0x35, 0x8d, 0x31, 0x8f, 0x3c, 0x8a, 0x78, 0x49, 0x56, 0x7e, 0xbb, 0x5c, + 0xea, 0xfa, 0x53, 0x61, 0x1f, 0xf0, 0xdb, 0x77, 0x38, 0x76, 0x54, 0x58, 0x77}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1c, 0xec, 0x78, 0x59, 0x3d, 0x21, 0xac, 0xf1, - 0xd9, 0xe6, 0xd1, 0xde, 0xb3, 0x12, 0xf}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xa4, 0x99, 0xc6, 0xda, 0x6b, 0xb0, 0x62, 0xe7, 0xe}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x64, 0x7d, 0x86, 0xa2, 0xe5, 0xe9, 0x60, 0xd4, 0xf8, 0xcf, - 0x14, 0xfe, 0x89, 0xba, 0xe8, 0x4b, 0x50, 0xa5, 0xde, 0x90}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x59, 0x9c, 0xcb, 0xec, 0x4, 0xe1, 0x95, 0xa5, 0x5b, 0xf6, 0x9e, 0x1f, 0x28, 0xf8}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf1, 0xc5, 0x29, 0x45, 0x82, 0x47, 0x2, 0xf8, 0x37, 0x77, 0xb3, 0xad, 0xf3, - 0xb, 0x54, 0x42, 0x1c, 0xd4, 0x6f, 0xc3, 0x6a, 0x4e, 0xc9, 0x97, 0x5a, 0x0}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x8c, 0xaa, 0x5e, 0xe5, 0xfa, 0x4b, 0xdc, 0xd8, 0xf1, 0xe9, 0x92, 0x22}; + lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc2, 0xeb, 0x29, 0xc9, 0x4a, 0x9d, 0x1, 0x33, 0x9, 0x7c, 0x14, 0xa4, - 0xb, 0xaf, 0xce, 0x1, 0x59, 0xec, 0x20, 0xa6, 0x28, 0xd4, 0x82}; - lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xb5, 0x48, 0x9a, 0xe9, 0xc1, 0xd8, 0x57, 0x8e, - 0xbe, 0xac, 0xad, 0xce, 0x6, 0x43, 0x60}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x73, 0xe7, 0x77, 0xdc, 0xd0, 0x14, 0x9d, 0xbf, 0x18, - 0x4, 0x6f, 0xbb, 0xaa, 0x2e, 0x63, 0x10, 0x2d, 0xdb}; - lwmqtt_string_t topic_filter_s10 = {18, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -11943,15 +12194,15 @@ TEST(Subscribe311QCTest, Encode21) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -11963,228 +12214,136 @@ TEST(Subscribe311QCTest, Encode21) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29011, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21060, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29705 [("\amn\138\157\180\217\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS0}),("!!Va\217\152",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\249\n}\251\170",SubOptions {_retainHandling = +// SubscribeRequest 18677 [("=\161\253\230\ACK|8",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("$wX\204\158I\216\&9c\142@\195\248\186>\SUBi\SYN\165H\212\242\&3;",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\158\v\b\RS\149\235Vv\NAK\240\135d\189r\203\185b\176\ETB\195,EE\185y",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode22) { - uint8_t pkt[] = {0x82, 0x3a, 0x74, 0x9, 0x0, 0x8, 0x7, 0x6d, 0x6e, 0x8a, 0x9d, 0xb4, 0xd9, 0xdb, 0x0, - 0x0, 0x6, 0x21, 0x21, 0x56, 0x61, 0xd9, 0x98, 0x2, 0x0, 0x5, 0xf9, 0xa, 0x7d, 0xfb, - 0xaa, 0x1, 0x0, 0x19, 0x9e, 0xb, 0x8, 0x1e, 0x95, 0xeb, 0x56, 0x76, 0x15, 0xf0, 0x87, - 0x64, 0xbd, 0x72, 0xcb, 0xb9, 0x62, 0xb0, 0x17, 0xc3, 0x2c, 0x45, 0x45, 0xb9, 0x79, 0x2}; +// QoS1}),("\153\231\243Nc7\160^\177\204:\236\247\fCy\174\181\172\131A",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode26) { + uint8_t pkt[] = {0x82, 0x3f, 0x48, 0xf5, 0x0, 0x7, 0x3d, 0xa1, 0xfd, 0xe6, 0x6, 0x7c, 0x38, 0x0, 0x0, 0x18, 0x24, + 0x77, 0x58, 0xcc, 0x9e, 0x49, 0xd8, 0x39, 0x63, 0x8e, 0x40, 0xc3, 0xf8, 0xba, 0x3e, 0x1a, 0x69, 0x16, + 0xa5, 0x48, 0xd4, 0xf2, 0x33, 0x3b, 0x1, 0x0, 0x15, 0x99, 0xe7, 0xf3, 0x4e, 0x63, 0x37, 0xa0, 0x5e, + 0xb1, 0xcc, 0x3a, 0xec, 0xf7, 0xc, 0x43, 0x79, 0xae, 0xb5, 0xac, 0x83, 0x41, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x7, 0x6d, 0x6e, 0x8a, 0x9d, 0xb4, 0xd9, 0xdb}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x3d, 0xa1, 0xfd, 0xe6, 0x6, 0x7c, 0x38}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x21, 0x21, 0x56, 0x61, 0xd9, 0x98}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x24, 0x77, 0x58, 0xcc, 0x9e, 0x49, 0xd8, 0x39, 0x63, 0x8e, 0x40, 0xc3, + 0xf8, 0xba, 0x3e, 0x1a, 0x69, 0x16, 0xa5, 0x48, 0xd4, 0xf2, 0x33, 0x3b}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf9, 0xa, 0x7d, 0xfb, 0xaa}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x99, 0xe7, 0xf3, 0x4e, 0x63, 0x37, 0xa0, 0x5e, 0xb1, 0xcc, 0x3a, + 0xec, 0xf7, 0xc, 0x43, 0x79, 0xae, 0xb5, 0xac, 0x83, 0x41}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9e, 0xb, 0x8, 0x1e, 0x95, 0xeb, 0x56, 0x76, 0x15, 0xf0, 0x87, 0x64, 0xbd, - 0x72, 0xcb, 0xb9, 0x62, 0xb0, 0x17, 0xc3, 0x2c, 0x45, 0x45, 0xb9, 0x79}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + lwmqtt_sub_options_t sub_opts[3]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29705, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18677, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30426 [("\SYNez\ACK\162N\176`#\DLEr6\206\183\167\183\224\241\&4OY\ENQ\162'\169\187\136A",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\152",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("mD\188mxN\232n\174\197\149e\174/\"\187\196\138\131\232",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\193]\DC2\n\228\224l6\162\149f\"J.\240\202",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(":q\223\215|h\a\208G\164\\~\231q_R\131\211\242\198\EM\CAN\220(\158\DLE\133",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\225\243\168\&79\184\251\210N\f>-\149\138K\n\155\217\220\DC33T\250\255UB=\188\RS",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("_\174@\222\188\207\224\212\179\190C\206",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\165\SYN\186\167:\ETX\214\DC2\145O\237\221\197",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode23) { - uint8_t pkt[] = {0x82, 0xac, 0x1, 0x76, 0xda, 0x0, 0x1c, 0x16, 0x65, 0x7a, 0x6, 0xa2, 0x4e, 0xb0, 0x60, 0x23, - 0x10, 0x72, 0x36, 0xce, 0xb7, 0xa7, 0xb7, 0xe0, 0xf1, 0x34, 0x4f, 0x59, 0x5, 0xa2, 0x27, 0xa9, - 0xbb, 0x88, 0x41, 0x2, 0x0, 0x1, 0x98, 0x0, 0x0, 0x14, 0x6d, 0x44, 0xbc, 0x6d, 0x78, 0x4e, - 0xe8, 0x6e, 0xae, 0xc5, 0x95, 0x65, 0xae, 0x2f, 0x22, 0xbb, 0xc4, 0x8a, 0x83, 0xe8, 0x2, 0x0, - 0x10, 0xc1, 0x5d, 0x12, 0xa, 0xe4, 0xe0, 0x6c, 0x36, 0xa2, 0x95, 0x66, 0x22, 0x4a, 0x2e, 0xf0, - 0xca, 0x0, 0x0, 0x1b, 0x3a, 0x71, 0xdf, 0xd7, 0x7c, 0x68, 0x7, 0xd0, 0x47, 0xa4, 0x5c, 0x7e, - 0xe7, 0x71, 0x5f, 0x52, 0x83, 0xd3, 0xf2, 0xc6, 0x19, 0x18, 0xdc, 0x28, 0x9e, 0x10, 0x85, 0x1, - 0x0, 0x1d, 0xe1, 0xf3, 0xa8, 0x37, 0x39, 0xb8, 0xfb, 0xd2, 0x4e, 0xc, 0x3e, 0x2d, 0x95, 0x8a, - 0x4b, 0xa, 0x9b, 0xd9, 0xdc, 0x13, 0x33, 0x54, 0xfa, 0xff, 0x55, 0x42, 0x3d, 0xbc, 0x1e, 0x0, - 0x0, 0xc, 0x5f, 0xae, 0x40, 0xde, 0xbc, 0xcf, 0xe0, 0xd4, 0xb3, 0xbe, 0x43, 0xce, 0x1, 0x0, - 0xd, 0xa5, 0x16, 0xba, 0xa7, 0x3a, 0x3, 0xd6, 0x12, 0x91, 0x4f, 0xed, 0xdd, 0xc5, 0x1}; +// SubscribeRequest 15426 [(">,\208\132\222\237\163V\189v\141\DC4<\218\135\r(U",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode27) { + uint8_t pkt[] = {0x82, 0x17, 0x3c, 0x42, 0x0, 0x12, 0x3e, 0x2c, 0xd0, 0x84, 0xde, 0xed, 0xa3, + 0x56, 0xbd, 0x76, 0x8d, 0x14, 0x3c, 0xda, 0x87, 0xd, 0x28, 0x55, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x16, 0x65, 0x7a, 0x6, 0xa2, 0x4e, 0xb0, 0x60, 0x23, 0x10, - 0x72, 0x36, 0xce, 0xb7, 0xa7, 0xb7, 0xe0, 0xf1, 0x34, 0x4f, - 0x59, 0x5, 0xa2, 0x27, 0xa9, 0xbb, 0x88, 0x41}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x3e, 0x2c, 0xd0, 0x84, 0xde, 0xed, 0xa3, 0x56, 0xbd, + 0x76, 0x8d, 0x14, 0x3c, 0xda, 0x87, 0xd, 0x28, 0x55}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x98}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6d, 0x44, 0xbc, 0x6d, 0x78, 0x4e, 0xe8, 0x6e, 0xae, 0xc5, - 0x95, 0x65, 0xae, 0x2f, 0x22, 0xbb, 0xc4, 0x8a, 0x83, 0xe8}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc1, 0x5d, 0x12, 0xa, 0xe4, 0xe0, 0x6c, 0x36, - 0xa2, 0x95, 0x66, 0x22, 0x4a, 0x2e, 0xf0, 0xca}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x3a, 0x71, 0xdf, 0xd7, 0x7c, 0x68, 0x7, 0xd0, 0x47, 0xa4, 0x5c, 0x7e, 0xe7, 0x71, - 0x5f, 0x52, 0x83, 0xd3, 0xf2, 0xc6, 0x19, 0x18, 0xdc, 0x28, 0x9e, 0x10, 0x85}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe1, 0xf3, 0xa8, 0x37, 0x39, 0xb8, 0xfb, 0xd2, 0x4e, 0xc, - 0x3e, 0x2d, 0x95, 0x8a, 0x4b, 0xa, 0x9b, 0xd9, 0xdc, 0x13, - 0x33, 0x54, 0xfa, 0xff, 0x55, 0x42, 0x3d, 0xbc, 0x1e}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5f, 0xae, 0x40, 0xde, 0xbc, 0xcf, 0xe0, 0xd4, 0xb3, 0xbe, 0x43, 0xce}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa5, 0x16, 0xba, 0xa7, 0x3a, 0x3, 0xd6, 0x12, 0x91, 0x4f, 0xed, 0xdd, 0xc5}; - lwmqtt_string_t topic_filter_s7 = {13, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; + lwmqtt_sub_options_t sub_opts[1]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30426, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15426, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21987 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("Cz\235\f\236\158'=\190",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("l\166=\210\242k\194\162\DLE}w\148\202W\216\US\178\f",SubOptions +// SubscribeRequest 11166 [("\253",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\160\191\253\EOT\221\233mn\DLE0\180\USn",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("F\137\196\196\246j\196\202xY\172\CANg",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("x\t\SO\224\131\ENQ\\\237\221\168\246&x\STX\246T\228\249\194\129\SUB",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\223\SI\255\235\250\134\ETX\178u\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x4b, 0x55, 0xe3, 0x0, 0x0, 0x2, 0x0, 0x9, 0x43, 0x7a, 0xeb, 0xc, 0xec, 0x9e, 0x27, - 0x3d, 0xbe, 0x2, 0x0, 0x12, 0x6c, 0xa6, 0x3d, 0xd2, 0xf2, 0x6b, 0xc2, 0xa2, 0x10, 0x7d, 0x77, - 0x94, 0xca, 0x57, 0xd8, 0x1f, 0xb2, 0xc, 0x1, 0x0, 0x15, 0x78, 0x9, 0xe, 0xe0, 0x83, 0x5, - 0x5c, 0xed, 0xdd, 0xa8, 0xf6, 0x26, 0x78, 0x2, 0xf6, 0x54, 0xe4, 0xf9, 0xc2, 0x81, 0x1a, 0x0, - 0x0, 0xa, 0xdf, 0xf, 0xff, 0xeb, 0xfa, 0x86, 0x3, 0xb2, 0x75, 0xd2, 0x2}; +// QoS1}),("\209\FS\DC3#w\220<\201Ou\SI\131]\154\159",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS2}),("`\161lN\DLE\160\DC1s:",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("6",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode28) { + uint8_t pkt[] = {0x82, 0x48, 0x2b, 0x9e, 0x0, 0x1, 0xfd, 0x1, 0x0, 0xd, 0xa0, 0xbf, 0xfd, 0x4, 0xdd, + 0xe9, 0x6d, 0x6e, 0x10, 0x30, 0xb4, 0x1f, 0x6e, 0x1, 0x0, 0xd, 0x46, 0x89, 0xc4, 0xc4, + 0xf6, 0x6a, 0xc4, 0xca, 0x78, 0x59, 0xac, 0x18, 0x67, 0x1, 0x0, 0xf, 0xd1, 0x1c, 0x13, + 0x23, 0x77, 0xdc, 0x3c, 0xc9, 0x4f, 0x75, 0xf, 0x83, 0x5d, 0x9a, 0x9f, 0x2, 0x0, 0x9, + 0x60, 0xa1, 0x6c, 0x4e, 0x10, 0xa0, 0x11, 0x73, 0x3a, 0x0, 0x0, 0x1, 0x36, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xfd}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x43, 0x7a, 0xeb, 0xc, 0xec, 0x9e, 0x27, 0x3d, 0xbe}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa0, 0xbf, 0xfd, 0x4, 0xdd, 0xe9, 0x6d, 0x6e, 0x10, 0x30, 0xb4, 0x1f, 0x6e}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6c, 0xa6, 0x3d, 0xd2, 0xf2, 0x6b, 0xc2, 0xa2, 0x10, - 0x7d, 0x77, 0x94, 0xca, 0x57, 0xd8, 0x1f, 0xb2, 0xc}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x46, 0x89, 0xc4, 0xc4, 0xf6, 0x6a, 0xc4, 0xca, 0x78, 0x59, 0xac, 0x18, 0x67}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x78, 0x9, 0xe, 0xe0, 0x83, 0x5, 0x5c, 0xed, 0xdd, 0xa8, 0xf6, - 0x26, 0x78, 0x2, 0xf6, 0x54, 0xe4, 0xf9, 0xc2, 0x81, 0x1a}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd1, 0x1c, 0x13, 0x23, 0x77, 0xdc, 0x3c, 0xc9, + 0x4f, 0x75, 0xf, 0x83, 0x5d, 0x9a, 0x9f}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xdf, 0xf, 0xff, 0xeb, 0xfa, 0x86, 0x3, 0xb2, 0x75, 0xd2}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x60, 0xa1, 0x6c, 0x4e, 0x10, 0xa0, 0x11, 0x73, 0x3a}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s5_bytes[] = {0x36}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -12192,58 +12351,58 @@ TEST(Subscribe311QCTest, Encode24) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21987, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11166, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23704 [("t \154\149\224\EM\158fEc\239\249\&6\231\DC4\159",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\253\\\220\193&\209[",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("e",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("R[&",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("^\169\135\136\143\241q\SI\254\254",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0x36, 0x5c, 0x98, 0x0, 0x10, 0x74, 0x20, 0x9a, 0x95, 0xe0, 0x19, 0x9e, 0x66, - 0x45, 0x63, 0xef, 0xf9, 0x36, 0xe7, 0x14, 0x9f, 0x1, 0x0, 0x7, 0xfd, 0x5c, 0xdc, - 0xc1, 0x26, 0xd1, 0x5b, 0x2, 0x0, 0x1, 0x65, 0x1, 0x0, 0x3, 0x52, 0x5b, 0x26, - 0x1, 0x0, 0xa, 0x5e, 0xa9, 0x87, 0x88, 0x8f, 0xf1, 0x71, 0xf, 0xfe, 0xfe, 0x2}; +// SubscribeRequest 9472 [("\243\DC2\199A\218\167\CAN\SYN\220w\165\160\NAK",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\247\192Pw\199\196)T\SI\142wV\188!\138\241[\171",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("]\205\240x6\SI\137\238\166K\152\156\181ri\NUL\224\130^\f\190\132\156\170\149\199U\142n",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode29) { + uint8_t pkt[] = {0x82, 0x47, 0x25, 0x0, 0x0, 0xd, 0xf3, 0x12, 0xc7, 0x41, 0xda, 0xa7, 0x18, 0x16, 0xdc, + 0x77, 0xa5, 0xa0, 0x15, 0x2, 0x0, 0x12, 0xf7, 0xc0, 0x50, 0x77, 0xc7, 0xc4, 0x29, 0x54, + 0xf, 0x8e, 0x77, 0x56, 0xbc, 0x21, 0x8a, 0xf1, 0x5b, 0xab, 0x2, 0x0, 0x1d, 0x5d, 0xcd, + 0xf0, 0x78, 0x36, 0xf, 0x89, 0xee, 0xa6, 0x4b, 0x98, 0x9c, 0xb5, 0x72, 0x69, 0x0, 0xe0, + 0x82, 0x5e, 0xc, 0xbe, 0x84, 0x9c, 0xaa, 0x95, 0xc7, 0x55, 0x8e, 0x6e, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x74, 0x20, 0x9a, 0x95, 0xe0, 0x19, 0x9e, 0x66, - 0x45, 0x63, 0xef, 0xf9, 0x36, 0xe7, 0x14, 0x9f}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xf3, 0x12, 0xc7, 0x41, 0xda, 0xa7, 0x18, 0x16, 0xdc, 0x77, 0xa5, 0xa0, 0x15}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfd, 0x5c, 0xdc, 0xc1, 0x26, 0xd1, 0x5b}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf7, 0xc0, 0x50, 0x77, 0xc7, 0xc4, 0x29, 0x54, 0xf, + 0x8e, 0x77, 0x56, 0xbc, 0x21, 0x8a, 0xf1, 0x5b, 0xab}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x65}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5d, 0xcd, 0xf0, 0x78, 0x36, 0xf, 0x89, 0xee, 0xa6, 0x4b, + 0x98, 0x9c, 0xb5, 0x72, 0x69, 0x0, 0xe0, 0x82, 0x5e, 0xc, + 0xbe, 0x84, 0x9c, 0xaa, 0x95, 0xc7, 0x55, 0x8e, 0x6e}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x52, 0x5b, 0x26}; - lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5e, 0xa9, 0x87, 0x88, 0x8f, 0xf1, 0x71, 0xf, 0xfe, 0xfe}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -12251,134 +12410,94 @@ TEST(Subscribe311QCTest, Encode25) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23704, 5, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 25818 [("\235\&1\a\173\150\175\208\&8",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0xd, 0x64, 0xda, 0x0, 0x8, 0xeb, 0x31, 0x7, 0xad, 0x96, 0xaf, 0xd0, 0x38, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xeb, 0x31, 0x7, 0xad, 0x96, 0xaf, 0xd0, 0x38}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25818, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9472, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19332 [("-\196\154\190n\186/h\n\161\203p\157Ap",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 18189 [("\142\SUB\241ET\151\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("t\160\t\216\&0\193Dg",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("~\210\229q\182\141\167%]a\fh\248\233\253\167>\NAKu\US\STX\133:",SubOptions {_retainHandling = +// QoS1}),("\218\225\n\t_\\\243\201\136\236\156E\172\217C\208\EOTn\147\225\145",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\144;#\ENQ\236h-\ETX\243\164R3\237\241\129\171\225",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\254\167a\227\GS\169X\240\139\CAN\242\212K\164g]T\203\246\141",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\252=6J\200\227L",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("U\199y\ETX\222\t\"\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2}),("\202\SUB\220\214,g\158Ugne6\221\DLE\222}n\252\&1w/\NUL\171\244vou",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("-\SO\230DQ\130\178\\\129\&2i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\205\132\136\DC2y",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ACK)\174\200\186",SubOptions {_retainHandling = +// QoS0}),("\167NE\EOT\132/\SIWTa\223|'\178]?\227\170O",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\208\238\156.\186\253",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\140\197o\USH\162P\197x$\209\218\SI\172\GS\176\147\204\148\CAN\226\CAN",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode27)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0x24, 0xd1, 0xda, - 0xf, 0xac, 0x1d, 0xb0, 0x93, 0xcc, 0x94, 0x18, 0xe2, 0x18, 0x2}; +// QoS1}),("\227\238\151ou]\230\234\ETB\aQ\170\218",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\249\a\164!\177YC\194\&0\183f\212\212Y\NAK\EOT\178\179",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("[",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\CANk+w\218\153\151\DEL\179U\STXl\DC2\SUBE\251\241\208",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\132B\f\206\169",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode30) { + uint8_t pkt[] = {0x82, 0x97, 0x1, 0x47, 0xd, 0x0, 0x7, 0x8e, 0x1a, 0xf1, 0x45, 0x54, 0x97, 0xe8, 0x2, 0x0, + 0x8, 0x74, 0xa0, 0x9, 0xd8, 0x30, 0xc1, 0x44, 0x67, 0x1, 0x0, 0x15, 0xda, 0xe1, 0xa, 0x9, + 0x5f, 0x5c, 0xf3, 0xc9, 0x88, 0xec, 0x9c, 0x45, 0xac, 0xd9, 0x43, 0xd0, 0x4, 0x6e, 0x93, 0xe1, + 0x91, 0x0, 0x0, 0x13, 0xa7, 0x4e, 0x45, 0x4, 0x84, 0x2f, 0xf, 0x57, 0x54, 0x61, 0xdf, 0x7c, + 0x27, 0xb2, 0x5d, 0x3f, 0xe3, 0xaa, 0x4f, 0x2, 0x0, 0x6, 0xd0, 0xee, 0x9c, 0x2e, 0xba, 0xfd, + 0x1, 0x0, 0xd, 0xe3, 0xee, 0x97, 0x6f, 0x75, 0x5d, 0xe6, 0xea, 0x17, 0x7, 0x51, 0xaa, 0xda, + 0x2, 0x0, 0x0, 0x1, 0x0, 0x12, 0xf9, 0x7, 0xa4, 0x21, 0xb1, 0x59, 0x43, 0xc2, 0x30, 0xb7, + 0x66, 0xd4, 0xd4, 0x59, 0x15, 0x4, 0xb2, 0xb3, 0x0, 0x0, 0x1, 0x5b, 0x0, 0x0, 0x12, 0x18, + 0x6b, 0x2b, 0x77, 0xda, 0x99, 0x97, 0x7f, 0xb3, 0x55, 0x2, 0x6c, 0x12, 0x1a, 0x45, 0xfb, 0xf1, + 0xd0, 0x0, 0x0, 0x5, 0x84, 0x42, 0xc, 0xce, 0xa9, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x2d, 0xc4, 0x9a, 0xbe, 0x6e, 0xba, 0x2f, 0x68, - 0xa, 0xa1, 0xcb, 0x70, 0x9d, 0x41, 0x70}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x8e, 0x1a, 0xf1, 0x45, 0x54, 0x97, 0xe8}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7e, 0xd2, 0xe5, 0x71, 0xb6, 0x8d, 0xa7, 0x25, 0x5d, 0x61, 0xc, 0x68, - 0xf8, 0xe9, 0xfd, 0xa7, 0x3e, 0x15, 0x75, 0x1f, 0x2, 0x85, 0x3a}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x74, 0xa0, 0x9, 0xd8, 0x30, 0xc1, 0x44, 0x67}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x90, 0x3b, 0x23, 0x5, 0xec, 0x68, 0x2d, 0x3, 0xf3, - 0xa4, 0x52, 0x33, 0xed, 0xf1, 0x81, 0xab, 0xe1}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xda, 0xe1, 0xa, 0x9, 0x5f, 0x5c, 0xf3, 0xc9, 0x88, 0xec, 0x9c, + 0x45, 0xac, 0xd9, 0x43, 0xd0, 0x4, 0x6e, 0x93, 0xe1, 0x91}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfe, 0xa7, 0x61, 0xe3, 0x1d, 0xa9, 0x58, 0xf0, 0x8b, 0x18, - 0xf2, 0xd4, 0x4b, 0xa4, 0x67, 0x5d, 0x54, 0xcb, 0xf6, 0x8d}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa7, 0x4e, 0x45, 0x4, 0x84, 0x2f, 0xf, 0x57, 0x54, 0x61, + 0xdf, 0x7c, 0x27, 0xb2, 0x5d, 0x3f, 0xe3, 0xaa, 0x4f}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xfc, 0x3d, 0x36, 0x4a, 0xc8, 0xe3, 0x4c}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd0, 0xee, 0x9c, 0x2e, 0xba, 0xfd}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x55, 0xc7, 0x79, 0x3, 0xde, 0x9, 0x22, 0xe8}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe3, 0xee, 0x97, 0x6f, 0x75, 0x5d, 0xe6, 0xea, 0x17, 0x7, 0x51, 0xaa, 0xda}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xca, 0x1a, 0xdc, 0xd6, 0x2c, 0x67, 0x9e, 0x55, 0x67, 0x6e, 0x65, 0x36, 0xdd, 0x10, - 0xde, 0x7d, 0x6e, 0xfc, 0x31, 0x77, 0x2f, 0x0, 0xab, 0xf4, 0x76, 0x6f, 0x75}; - lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x2d, 0xe, 0xe6, 0x44, 0x51, 0x82, 0xb2, 0x5c, 0x81, 0x32, 0x69}; - lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xf9, 0x7, 0xa4, 0x21, 0xb1, 0x59, 0x43, 0xc2, 0x30, + 0xb7, 0x66, 0xd4, 0xd4, 0x59, 0x15, 0x4, 0xb2, 0xb3}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xcd, 0x84, 0x88, 0x12, 0x79}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x5b}; + lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x6, 0x29, 0xae, 0xc8, 0xba}; - lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0x18, 0x6b, 0x2b, 0x77, 0xda, 0x99, 0x97, 0x7f, 0xb3, + 0x55, 0x2, 0x6c, 0x12, 0x1a, 0x45, 0xfb, 0xf1, 0xd0}; + lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x8c, 0xc5, 0x6f, 0x1f, 0x48, 0xa2, 0x50, 0xc5, 0x78, 0x24, 0xd1, - 0xda, 0xf, 0xac, 0x1d, 0xb0, 0x93, 0xcc, 0x94, 0x18, 0xe2, 0x18}; - lwmqtt_string_t topic_filter_s10 = {22, (char*)&topic_filter_s10_bytes}; + uint8_t topic_filter_s10_bytes[] = {0x84, 0x42, 0xc, 0xce, 0xa9}; + lwmqtt_string_t topic_filter_s10 = {5, (char*)&topic_filter_s10_bytes}; topic_filters[10] = topic_filter_s10; lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -12386,11 +12505,11 @@ TEST(Subscribe311QCTest, Encode27) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -12410,11 +12529,11 @@ TEST(Subscribe311QCTest, Encode27) { sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].qos = LWMQTT_QOS0; sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].qos = LWMQTT_QOS0; sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[10].retain_as_published = false; sub_opts[10].no_local = false; @@ -12424,5276 +12543,5238 @@ TEST(Subscribe311QCTest, Encode27) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19332, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18189, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20518 [("\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("\208\138rec7\DLE\135k\b\245\159\135\&8\198\&0x\EM\188\ESC",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("OC{\222\a\203\253\158#\181\203J&\a\179\STX6\141\175\135\212QE\DC4<\207",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("qa\DC3x\197\165\234`\236\156",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("j\241\241/\244.\251\220v\185(f\144\147\f\170\246\219",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("f\189\233W\169\244b\222\169",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0x6b, 0x50, 0x26, 0x0, 0x1, 0xb8, 0x1, 0x0, 0x14, 0xd0, 0x8a, 0x72, 0x65, 0x63, 0x37, - 0x10, 0x87, 0x6b, 0x8, 0xf5, 0x9f, 0x87, 0x38, 0xc6, 0x30, 0x78, 0x19, 0xbc, 0x1b, 0x0, 0x0, - 0x0, 0x1, 0x0, 0x1a, 0x4f, 0x43, 0x7b, 0xde, 0x7, 0xcb, 0xfd, 0x9e, 0x23, 0xb5, 0xcb, 0x4a, - 0x26, 0x7, 0xb3, 0x2, 0x36, 0x8d, 0xaf, 0x87, 0xd4, 0x51, 0x45, 0x14, 0x3c, 0xcf, 0x0, 0x0, - 0xa, 0x71, 0x61, 0x13, 0x78, 0xc5, 0xa5, 0xea, 0x60, 0xec, 0x9c, 0x2, 0x0, 0x12, 0x6a, 0xf1, - 0xf1, 0x2f, 0xf4, 0x2e, 0xfb, 0xdc, 0x76, 0xb9, 0x28, 0x66, 0x90, 0x93, 0xc, 0xaa, 0xf6, 0xdb, - 0x0, 0x0, 0x9, 0x66, 0xbd, 0xe9, 0x57, 0xa9, 0xf4, 0x62, 0xde, 0xa9, 0x1}; +// SubscribeRequest 5047 [("H\129E$_\201\142?\214\245~\170",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\EOT\171",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("|\130\163TL\202",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\147^\181B\US12\255U",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal +// = False, _subQoS = QoS2}),("\185\DC1\142\241\ENQ\"\ETX",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\139\130\222\tW\SI",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropRetainAvailable +// 155,PropTopicAlias 4606,PropContentType +// "rE!\226\208\253(f%\144\226\238\210\235p\a\DC3;&\224[q\250T\181}\192",PropMessageExpiryInterval +// 16020,PropRetainAvailable 0] +TEST(Subscribe5QCTest, Encode1) { + uint8_t pkt[] = {0x82, 0x69, 0x13, 0xb7, 0x2a, 0x25, 0x9b, 0x23, 0x11, 0xfe, 0x3, 0x0, 0x1b, 0x72, 0x45, 0x21, + 0xe2, 0xd0, 0xfd, 0x28, 0x66, 0x25, 0x90, 0xe2, 0xee, 0xd2, 0xeb, 0x70, 0x7, 0x13, 0x3b, 0x26, + 0xe0, 0x5b, 0x71, 0xfa, 0x54, 0xb5, 0x7d, 0xc0, 0x2, 0x0, 0x0, 0x3e, 0x94, 0x25, 0x0, 0x0, + 0xc, 0x48, 0x81, 0x45, 0x24, 0x5f, 0xc9, 0x8e, 0x3f, 0xd6, 0xf5, 0x7e, 0xaa, 0xa, 0x0, 0x2, + 0x4, 0xab, 0x2c, 0x0, 0x6, 0x7c, 0x82, 0xa3, 0x54, 0x4c, 0xca, 0x2d, 0x0, 0x9, 0x93, 0x5e, + 0xb5, 0x42, 0x1f, 0x31, 0x32, 0xff, 0x55, 0x1a, 0x0, 0x7, 0xb9, 0x11, 0x8e, 0xf1, 0x5, 0x22, + 0x3, 0x0, 0x0, 0x6, 0x8b, 0x82, 0xde, 0x9, 0x57, 0xf, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xb8}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x48, 0x81, 0x45, 0x24, 0x5f, 0xc9, 0x8e, 0x3f, 0xd6, 0xf5, 0x7e, 0xaa}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd0, 0x8a, 0x72, 0x65, 0x63, 0x37, 0x10, 0x87, 0x6b, 0x8, - 0xf5, 0x9f, 0x87, 0x38, 0xc6, 0x30, 0x78, 0x19, 0xbc, 0x1b}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4, 0xab}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7c, 0x82, 0xa3, 0x54, 0x4c, 0xca}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x4f, 0x43, 0x7b, 0xde, 0x7, 0xcb, 0xfd, 0x9e, 0x23, 0xb5, 0xcb, 0x4a, 0x26, - 0x7, 0xb3, 0x2, 0x36, 0x8d, 0xaf, 0x87, 0xd4, 0x51, 0x45, 0x14, 0x3c, 0xcf}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x93, 0x5e, 0xb5, 0x42, 0x1f, 0x31, 0x32, 0xff, 0x55}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x71, 0x61, 0x13, 0x78, 0xc5, 0xa5, 0xea, 0x60, 0xec, 0x9c}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xb9, 0x11, 0x8e, 0xf1, 0x5, 0x22, 0x3}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6a, 0xf1, 0xf1, 0x2f, 0xf4, 0x2e, 0xfb, 0xdc, 0x76, - 0xb9, 0x28, 0x66, 0x90, 0x93, 0xc, 0xaa, 0xf6, 0xdb}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x8b, 0x82, 0xde, 0x9, 0x57, 0xf}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x66, 0xbd, 0xe9, 0x57, 0xa9, 0xf4, 0x62, 0xde, 0xa9}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; + uint8_t bytesprops0[] = {0x72, 0x45, 0x21, 0xe2, 0xd0, 0xfd, 0x28, 0x66, 0x25, 0x90, 0xe2, 0xee, 0xd2, 0xeb, + 0x70, 0x7, 0x13, 0x3b, 0x26, 0xe0, 0x5b, 0x71, 0xfa, 0x54, 0xb5, 0x7d, 0xc0}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4606}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16020}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 0}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20518, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5047, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4648 [("\172K\233\189\190\a>\228I\131=\247\DEL\255",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("d\206\145J",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\192\f%\166\NAK\218D3Q\180\233O'N\DC39i5\236\&2r",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\195\233]\b\254s\198E",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\161\EOTL\192\&7\180m\152*\178,\241`\199\167 ",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\159\FS\203g6+\169\183\247\253\137\168\SO\174\243\r\EOT\tH\EOTkQ\a)G#:7\204\DC3",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\RSB)}\225\170\218\238\205\247",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0x7e, 0x12, 0x28, 0x0, 0xe, 0xac, 0x4b, 0xe9, 0xbd, 0xbe, 0x7, 0x3e, 0xe4, 0x49, 0x83, - 0x3d, 0xf7, 0x7f, 0xff, 0x0, 0x0, 0x4, 0x64, 0xce, 0x91, 0x4a, 0x1, 0x0, 0x15, 0xc0, 0xc, - 0x25, 0xa6, 0x15, 0xda, 0x44, 0x33, 0x51, 0xb4, 0xe9, 0x4f, 0x27, 0x4e, 0x13, 0x39, 0x69, 0x35, - 0xec, 0x32, 0x72, 0x2, 0x0, 0x8, 0xc3, 0xe9, 0x5d, 0x8, 0xfe, 0x73, 0xc6, 0x45, 0x2, 0x0, - 0x10, 0xa1, 0x4, 0x4c, 0xc0, 0x37, 0xb4, 0x6d, 0x98, 0x2a, 0xb2, 0x2c, 0xf1, 0x60, 0xc7, 0xa7, - 0x20, 0x0, 0x0, 0x1e, 0x9f, 0x1c, 0xcb, 0x67, 0x36, 0x2b, 0xa9, 0xb7, 0xf7, 0xfd, 0x89, 0xa8, - 0xe, 0xae, 0xf3, 0xd, 0x4, 0x9, 0x48, 0x4, 0x6b, 0x51, 0x7, 0x29, 0x47, 0x23, 0x3a, 0x37, - 0xcc, 0x13, 0x0, 0x0, 0xa, 0x1e, 0x42, 0x29, 0x7d, 0xe1, 0xaa, 0xda, 0xee, 0xcd, 0xf7, 0x2}; +// SubscribeRequest 3206 [("\DC12^",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS1}),("\184\136",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS1}),("$\217\231uJ\220\&4\205\163\&2\171'\203P\ESC\252\228\SOH\202",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] +// [PropReceiveMaximum 31812,PropSubscriptionIdentifierAvailable 200,PropMessageExpiryInterval 26308,PropServerKeepAlive +// 30441,PropTopicAliasMaximum 19633,PropWillDelayInterval 20710,PropCorrelationData +// "5\129\DLE\230\230\208\247\178\233\US",PropServerReference +// "\140\235\247\&2\198j\188\149\&8\243*\185\ETX\b\DEL\144\183Je\138\SI\227\193\218\239C\252"] +TEST(Subscribe5QCTest, Encode2) { + uint8_t pkt[] = {0x82, 0x64, 0xc, 0x86, 0x40, 0x21, 0x7c, 0x44, 0x29, 0xc8, 0x2, 0x0, 0x0, 0x66, 0xc4, + 0x13, 0x76, 0xe9, 0x22, 0x4c, 0xb1, 0x18, 0x0, 0x0, 0x50, 0xe6, 0x9, 0x0, 0xa, 0x35, + 0x81, 0x10, 0xe6, 0xe6, 0xd0, 0xf7, 0xb2, 0xe9, 0x1f, 0x1c, 0x0, 0x1b, 0x8c, 0xeb, 0xf7, + 0x32, 0xc6, 0x6a, 0xbc, 0x95, 0x38, 0xf3, 0x2a, 0xb9, 0x3, 0x8, 0x7f, 0x90, 0xb7, 0x4a, + 0x65, 0x8a, 0xf, 0xe3, 0xc1, 0xda, 0xef, 0x43, 0xfc, 0x0, 0x3, 0x11, 0x32, 0x5e, 0x15, + 0x0, 0x2, 0xb8, 0x88, 0x15, 0x0, 0x13, 0x24, 0xd9, 0xe7, 0x75, 0x4a, 0xdc, 0x34, 0xcd, + 0xa3, 0x32, 0xab, 0x27, 0xcb, 0x50, 0x1b, 0xfc, 0xe4, 0x1, 0xca, 0x1e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xac, 0x4b, 0xe9, 0xbd, 0xbe, 0x7, 0x3e, 0xe4, 0x49, 0x83, 0x3d, 0xf7, 0x7f, 0xff}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x11, 0x32, 0x5e}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x64, 0xce, 0x91, 0x4a}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb8, 0x88}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc0, 0xc, 0x25, 0xa6, 0x15, 0xda, 0x44, 0x33, 0x51, 0xb4, 0xe9, - 0x4f, 0x27, 0x4e, 0x13, 0x39, 0x69, 0x35, 0xec, 0x32, 0x72}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x24, 0xd9, 0xe7, 0x75, 0x4a, 0xdc, 0x34, 0xcd, 0xa3, 0x32, + 0xab, 0x27, 0xcb, 0x50, 0x1b, 0xfc, 0xe4, 0x1, 0xca}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc3, 0xe9, 0x5d, 0x8, 0xfe, 0x73, 0xc6, 0x45}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa1, 0x4, 0x4c, 0xc0, 0x37, 0xb4, 0x6d, 0x98, - 0x2a, 0xb2, 0x2c, 0xf1, 0x60, 0xc7, 0xa7, 0x20}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x9f, 0x1c, 0xcb, 0x67, 0x36, 0x2b, 0xa9, 0xb7, 0xf7, 0xfd, - 0x89, 0xa8, 0xe, 0xae, 0xf3, 0xd, 0x4, 0x9, 0x48, 0x4, - 0x6b, 0x51, 0x7, 0x29, 0x47, 0x23, 0x3a, 0x37, 0xcc, 0x13}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x1e, 0x42, 0x29, 0x7d, 0xe1, 0xaa, 0xda, 0xee, 0xcd, 0xf7}; - lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; + sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; + sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4648, 7, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 13920 [(";q\215\241\130b\220s",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0xd, 0x36, 0x60, 0x0, 0x8, 0x3b, 0x71, 0xd7, 0xf1, 0x82, 0x62, 0xdc, 0x73, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x3b, 0x71, 0xd7, 0xf1, 0x82, 0x62, 0xdc, 0x73}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + uint8_t bytesprops0[] = {0x35, 0x81, 0x10, 0xe6, 0xe6, 0xd0, 0xf7, 0xb2, 0xe9, 0x1f}; + uint8_t bytesprops1[] = {0x8c, 0xeb, 0xf7, 0x32, 0xc6, 0x6a, 0xbc, 0x95, 0x38, 0xf3, 0x2a, 0xb9, 0x3, 0x8, + 0x7f, 0x90, 0xb7, 0x4a, 0x65, 0x8a, 0xf, 0xe3, 0xc1, 0xda, 0xef, 0x43, 0xfc}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31812}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26308}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30441}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19633}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20710}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops1}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13920, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3206, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22060 [("\223\227\254#\231\fk\254CT\157\246_G\GSI",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\212\DC4\172\SI\161\ETX[\171~`Y\188\185\181pS\206X",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropServerReference -// "r\181\rI\ETB\181\203[\215^([\160+\174\197\230\SI\139%\177\137r\232_s\253\DC3\n",PropServerReference -// "\ETB\242\ESC\151\128r\176<\167\209N\RS\232\NAK\196\SOM\138\209\191\134\191\190\221\221\183\167Z",PropTopicAliasMaximum -// 17608,PropResponseInformation -// "\SI\r\193@\179\ESCy\155\147\164\DC3\169",PropUserProperty +// "#\152\SUB\245|\GSb\153`\v\145Ob\242\183\254\195" +// "\192\225d\NAK\239\r\239\211h*\134\228^\148\158\214-\217\140\231\SYN\199\203m\185\162",PropPayloadFormatIndicator +// 251,PropMessageExpiryInterval 17985,PropWildcardSubscriptionAvailable 47,PropRetainAvailable 9,PropCorrelationData +// "\DC1\DEL#)\r\231\FS\245Ta$\RS\171\182\246\219\r\211\NAK\SYN",PropRequestResponseInformation +// 138,PropMessageExpiryInterval 4082,PropServerReference " +// \204\255\&7\193\208u\SUB\142\&7\167\165vD\217xu\195\240\192\180\231\ACK\186",PropRetainAvailable +// 102,PropRequestResponseInformation 215,PropRequestResponseInformation 117] +TEST(Subscribe5QCTest, Encode4) { + uint8_t pkt[] = { + 0x82, 0xa7, 0x2, 0x38, 0x30, 0x8b, 0x1, 0xb, 0x1b, 0x24, 0x9f, 0x1a, 0x0, 0xa, 0x3e, 0x40, 0xb3, 0x1b, 0x79, + 0x9b, 0x93, 0xa4, 0x13, 0xa9, 0x26, 0x0, 0x11, 0x23, 0x98, 0x1a, 0xf5, 0x7c, 0x1d, 0x62, 0x99, 0x60, 0xb, 0x91, + 0x4f, 0x62, 0xf2, 0xb7, 0xfe, 0xc3, 0x0, 0x1a, 0xc0, 0xe1, 0x64, 0x15, 0xef, 0xd, 0xef, 0xd3, 0x68, 0x2a, 0x86, + 0xe4, 0x5e, 0x94, 0x9e, 0xd6, 0x2d, 0xd9, 0x8c, 0xe7, 0x16, 0xc7, 0xcb, 0x6d, 0xb9, 0xa2, 0x1, 0xfb, 0x2, 0x0, + 0x0, 0x46, 0x41, 0x28, 0x2f, 0x25, 0x9, 0x9, 0x0, 0x14, 0x11, 0x7f, 0x23, 0x29, 0xd, 0xe7, 0x1c, 0xf5, 0x54, + 0x61, 0x24, 0x1e, 0xab, 0xb6, 0xf6, 0xdb, 0xd, 0xd3, 0x15, 0x16, 0x19, 0x8a, 0x2, 0x0, 0x0, 0xf, 0xf2, 0x1c, + 0x0, 0x18, 0x20, 0xcc, 0xff, 0x37, 0xc1, 0xd0, 0x75, 0x1a, 0x8e, 0x37, 0xa7, 0xa5, 0x76, 0x44, 0xd9, 0x78, 0x75, + 0xc3, 0xf0, 0xc0, 0xb4, 0xe7, 0x6, 0xba, 0x25, 0x66, 0x19, 0xd7, 0x19, 0x75, 0x0, 0xd, 0x1c, 0x80, 0xf1, 0xf8, + 0xd0, 0x89, 0x43, 0x7e, 0x28, 0xa3, 0x25, 0x9e, 0x77, 0x19, 0x0, 0x1a, 0x35, 0x58, 0x38, 0xcd, 0xd3, 0xeb, 0x70, + 0x4b, 0x17, 0x57, 0x40, 0x0, 0x3a, 0x8a, 0xf4, 0x55, 0xb0, 0x8f, 0xb, 0x65, 0x6c, 0xf4, 0x78, 0x5f, 0xff, 0x99, + 0x19, 0x0, 0x1b, 0x72, 0x5e, 0x8f, 0xa2, 0xb2, 0xa8, 0xc0, 0xac, 0x8d, 0x2e, 0xf, 0xf5, 0x7, 0xdd, 0x17, 0x4e, + 0xfe, 0x77, 0x14, 0x8d, 0x19, 0x4a, 0x8d, 0x29, 0x33, 0xc2, 0xf6, 0xe, 0x0, 0x1, 0x9, 0x2a, 0x0, 0x14, 0x90, + 0xc2, 0x41, 0xe8, 0x1, 0x9b, 0x1b, 0x4c, 0x5c, 0xd6, 0x38, 0xa9, 0x12, 0xef, 0xad, 0x30, 0x14, 0x50, 0x3a, 0x26, + 0x21, 0x0, 0x9, 0x69, 0x81, 0xb, 0xf0, 0xcd, 0x40, 0x50, 0x41, 0x2f, 0x19, 0x0, 0x5, 0x41, 0x21, 0xe1, 0x8a, + 0x3d, 0x25, 0x0, 0x1b, 0xa9, 0xc1, 0x38, 0x42, 0x8a, 0x8f, 0x18, 0x7e, 0x3d, 0x96, 0xf0, 0xd8, 0x55, 0xa8, 0x10, + 0x43, 0x78, 0x7f, 0x28, 0xf5, 0x87, 0x31, 0x47, 0x7c, 0x31, 0x90, 0x46, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xcc, 0xfb, 0x58, 0x4c, 0xd1, 0x96, 0x88, 0x1a, 0x92, 0xbb, - 0x1f, 0xc4, 0x99, 0x96, 0x64, 0xdb, 0xd5, 0xd1, 0x1e, 0xae, - 0xaf, 0x90, 0x5e, 0x8c, 0x8a, 0x93, 0xcb, 0xf0, 0xd6, 0xd7}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x1c, 0x80, 0xf1, 0xf8, 0xd0, 0x89, 0x43, 0x7e, 0x28, 0xa3, 0x25, 0x9e, 0x77}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x67, 0xa0, 0x1b, 0xe1, 0xc7, 0x1e, 0x21, 0x25, 0x7c, - 0x6, 0x47, 0xd9, 0x76, 0x94, 0x77, 0x87, 0xcb}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x35, 0x58, 0x38, 0xcd, 0xd3, 0xeb, 0x70, 0x4b, 0x17, 0x57, 0x40, 0x0, 0x3a, + 0x8a, 0xf4, 0x55, 0xb0, 0x8f, 0xb, 0x65, 0x6c, 0xf4, 0x78, 0x5f, 0xff, 0x99}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x49, 0x2a, 0x8d, 0x37, 0x21, 0x6e}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x72, 0x5e, 0x8f, 0xa2, 0xb2, 0xa8, 0xc0, 0xac, 0x8d, 0x2e, 0xf, 0xf5, 0x7, 0xdd, + 0x17, 0x4e, 0xfe, 0x77, 0x14, 0x8d, 0x19, 0x4a, 0x8d, 0x29, 0x33, 0xc2, 0xf6}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfa, 0x77, 0x69, 0x15, 0x30, 0x48, 0x99, 0x95, 0x6d, 0x31, 0x23, 0xf4, 0xf3, - 0x6a, 0xab, 0x6a, 0x54, 0xc1, 0xf8, 0xdb, 0x4, 0xf6, 0x58, 0xd9, 0xa1, 0xc0}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xf1, 0xef, 0x4a, 0x28, 0xd8, 0xc0, 0x3d, 0x82, 0xc5, 0x2d, - 0x68, 0x7c, 0xaa, 0x42, 0x1f, 0xcc, 0x5d, 0xa6, 0xcc, 0x95, - 0x98, 0x7c, 0x4, 0xdd, 0x58, 0x2a, 0x55, 0x8a, 0x77, 0xee}; - lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x90, 0xc2, 0x41, 0xe8, 0x1, 0x9b, 0x1b, 0x4c, 0x5c, 0xd6, + 0x38, 0xa9, 0x12, 0xef, 0xad, 0x30, 0x14, 0x50, 0x3a, 0x26}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x69, 0x81, 0xb, 0xf0, 0xcd, 0x40, 0x50, 0x41, 0x2f}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x89, 0x3b, 0x45, 0x3, 0xba, 0xb4, 0xdd, 0xf6, 0xe5, 0xb6, 0xf7, 0xd0}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x41, 0x21, 0xe1, 0x8a, 0x3d}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7d, 0xf0}; - lwmqtt_string_t topic_filter_s7 = {2, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xa9, 0xc1, 0x38, 0x42, 0x8a, 0x8f, 0x18, 0x7e, 0x3d, 0x96, 0xf0, 0xd8, 0x55, 0xa8, + 0x10, 0x43, 0x78, 0x7f, 0x28, 0xf5, 0x87, 0x31, 0x47, 0x7c, 0x31, 0x90, 0x46}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x74, 0xcd, 0x5f, 0xdc, 0xa2, 0x67, 0x8d, 0x2f, 0x63, 0x48}; - lwmqtt_string_t topic_filter_s8 = {10, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x87, 0x89, 0x95, 0xd0}; - lwmqtt_string_t topic_filter_s9 = {4, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xa5, 0x13, 0x36, 0x1a, 0x47, 0x1f, 0x7d, 0xdc, 0x19, 0xf, 0x89, - 0xfb, 0xcc, 0x3f, 0xd2, 0x4, 0x23, 0x8, 0x4c, 0x4e, 0x81}; - lwmqtt_string_t topic_filter_s10 = {21, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = true; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[10].retain_as_published = true; - sub_opts[10].no_local = false; - uint8_t bytesprops0[] = {0x31, 0x81, 0xf3, 0xbb, 0x66, 0x2a, 0x7c, 0xe8}; + uint8_t bytesprops0[] = {0x3e, 0x40, 0xb3, 0x1b, 0x79, 0x9b, 0x93, 0xa4, 0x13, 0xa9}; + uint8_t bytesprops2[] = {0xc0, 0xe1, 0x64, 0x15, 0xef, 0xd, 0xef, 0xd3, 0x68, 0x2a, 0x86, 0xe4, 0x5e, + 0x94, 0x9e, 0xd6, 0x2d, 0xd9, 0x8c, 0xe7, 0x16, 0xc7, 0xcb, 0x6d, 0xb9, 0xa2}; + uint8_t bytesprops1[] = {0x23, 0x98, 0x1a, 0xf5, 0x7c, 0x1d, 0x62, 0x99, 0x60, + 0xb, 0x91, 0x4f, 0x62, 0xf2, 0xb7, 0xfe, 0xc3}; + uint8_t bytesprops3[] = {0x11, 0x7f, 0x23, 0x29, 0xd, 0xe7, 0x1c, 0xf5, 0x54, 0x61, + 0x24, 0x1e, 0xab, 0xb6, 0xf6, 0xdb, 0xd, 0xd3, 0x15, 0x16}; + uint8_t bytesprops4[] = {0x20, 0xcc, 0xff, 0x37, 0xc1, 0xd0, 0x75, 0x1a, 0x8e, 0x37, 0xa7, 0xa5, + 0x76, 0x44, 0xd9, 0x78, 0x75, 0xc3, 0xf0, 0xc0, 0xb4, 0xe7, 0x6, 0xba}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9919}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {26, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17985}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4082}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21589, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14384, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25658 [("\135\217dy\159J\NULIZ",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("~|l\v\rK\139\EMPB\237\236M\165\138",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] -// [PropRequestProblemInformation 79,PropRetainAvailable 116,PropContentType "[",PropMaximumPacketSize -// 24345,PropRequestResponseInformation 139,PropReceiveMaximum 19854,PropRetainAvailable 90,PropResponseInformation -// "\GS\135Ko\150\201\&0",PropMessageExpiryInterval 28084,PropMaximumPacketSize 6563,PropAuthenticationData -// "9Xk",PropSubscriptionIdentifier 22,PropRequestProblemInformation 247,PropTopicAlias 5595,PropContentType -// "\181\208i'2\161\162\192Wx\206\255\132Z\174e\224a~\149",PropWillDelayInterval 19259,PropContentType -// "\215\221%\216\191\DC2XX\253\232\156m\247\232\144\CAN\178\215[p\243&]\166",PropUserProperty "\228\150" -// "q!\193\SO\239$\165\b\168T\219!\154o\214\227skV\232",PropRetainAvailable 201,PropRetainAvailable -// 53,PropSubscriptionIdentifier 18,PropSubscriptionIdentifier 29,PropWildcardSubscriptionAvailable -// 25,PropTopicAliasMaximum 31978,PropAuthenticationMethod -// "Bf\146\ESCfn\170(\243(\EM\158t\ETX\158\160\GS\132\SICC\248",PropAuthenticationData -// "\134:\b\195\240\181\209\156<:H\174\172\232\190\243\128\189\150\208IOJ\200\155\154\DLE\219\GS)",PropSessionExpiryInterval -// 15712,PropContentType "\249\193&1r\a\197,\159\154 \205mq\223\161r\202\130.>C\129\&8\131",PropReceiveMaximum 29108] -TEST(Subscribe5QCTest, Encode3) { - uint8_t pkt[] =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 0xb5, 0xd1, - 0x9c, 0x3c, 0x3a, 0x48, 0xae, 0xac, 0xe8, 0xbe, 0xf3, 0x80, 0xbd, 0x96, 0xd0, 0x49, 0x4f, 0x4a, 0xc8, 0x9b, 0x9a, - 0x10, 0xdb, 0x1d, 0x29, 0x11, 0x0, 0x0, 0x3d, 0x60, 0x3, 0x0, 0x19, 0xf9, 0xc1, 0x26, 0x31, 0x72, 0x7, 0xc5, - 0x2c, 0x9f, 0x9a, 0x20, 0xcd, 0x6d, 0x71, 0xdf, 0xa1, 0x72, 0xca, 0x82, 0x2e, 0x3e, 0x43, 0x81, 0x38, 0x83, 0x21, - 0x71, 0xb4, 0x0, 0x9, 0x87, 0xd9, 0x64, 0x79, 0x9f, 0x4a, 0x0, 0x49, 0x5a, 0x22, 0x0, 0xf, 0x7e, 0x7c, 0x6c, - 0xb, 0xd, 0x4b, 0x8b, 0x19, 0x50, 0x42, 0xed, 0xec, 0x4d, 0xa5, 0x8a, 0x26}; +// SubscribeRequest 10952 [("\189\131\143u\249\178\237\221\225\135\200_E",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\138:\130%\226\132\219i%\244x~=X\220\GS\224\244\133\144\194O\240\154",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\184*~\237,+2\155\&2P\221\197",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS0}),("\172\&6\205I;\188o",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("-\ETB\193\208",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\ENQ\r\210U\140\DC2\148\199\188\163\197]",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("yr \203n\154\&6\197\134\218xJ\DC4\144",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("8Y\218Q\175\&2",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS2})] [PropReasonString "\ENQT\246",PropMaximumQoS 247,PropAuthenticationMethod +// "K\r0\153\217\FS",PropRequestResponseInformation 112,PropReceiveMaximum 11958,PropPayloadFormatIndicator +// 68,PropMaximumQoS 59] +TEST(Subscribe5QCTest, Encode5) { + uint8_t pkt[] = {0x82, 0x91, 0x1, 0x2a, 0xc8, 0x1a, 0x1f, 0x0, 0x3, 0x5, 0x54, 0xf6, 0x24, 0xf7, 0x15, 0x0, 0x6, + 0x4b, 0xd, 0x30, 0x99, 0xd9, 0x1c, 0x19, 0x70, 0x21, 0x2e, 0xb6, 0x1, 0x44, 0x24, 0x3b, 0x0, 0xd, + 0xbd, 0x83, 0x8f, 0x75, 0xf9, 0xb2, 0xed, 0xdd, 0xe1, 0x87, 0xc8, 0x5f, 0x45, 0x2, 0x0, 0x18, 0x8a, + 0x3a, 0x82, 0x25, 0xe2, 0x84, 0xdb, 0x69, 0x25, 0xf4, 0x78, 0x7e, 0x3d, 0x58, 0xdc, 0x1d, 0xe0, 0xf4, + 0x85, 0x90, 0xc2, 0x4f, 0xf0, 0x9a, 0x1d, 0x0, 0xc, 0xb8, 0x2a, 0x7e, 0xed, 0x2c, 0x2b, 0x32, 0x9b, + 0x32, 0x50, 0xdd, 0xc5, 0x1c, 0x0, 0x7, 0xac, 0x36, 0xcd, 0x49, 0x3b, 0xbc, 0x6f, 0x2e, 0x0, 0x4, + 0x2d, 0x17, 0xc1, 0xd0, 0x1, 0x0, 0xc, 0x5, 0xd, 0xd2, 0x55, 0x8c, 0x12, 0x94, 0xc7, 0xbc, 0xa3, + 0xc5, 0x5d, 0x2d, 0x0, 0xe, 0x79, 0x72, 0x20, 0xcb, 0x6e, 0x9a, 0x36, 0xc5, 0x86, 0xda, 0x78, 0x4a, + 0x14, 0x90, 0x1, 0x0, 0x6, 0x38, 0x59, 0xda, 0x51, 0xaf, 0x32, 0x2a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x87, 0xd9, 0x64, 0x79, 0x9f, 0x4a, 0x0, 0x49, 0x5a}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xbd, 0x83, 0x8f, 0x75, 0xf9, 0xb2, 0xed, 0xdd, 0xe1, 0x87, 0xc8, 0x5f, 0x45}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7e, 0x7c, 0x6c, 0xb, 0xd, 0x4b, 0x8b, 0x19, - 0x50, 0x42, 0xed, 0xec, 0x4d, 0xa5, 0x8a}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x8a, 0x3a, 0x82, 0x25, 0xe2, 0x84, 0xdb, 0x69, 0x25, 0xf4, 0x78, 0x7e, + 0x3d, 0x58, 0xdc, 0x1d, 0xe0, 0xf4, 0x85, 0x90, 0xc2, 0x4f, 0xf0, 0x9a}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - uint8_t bytesprops0[] = {0x5b}; - uint8_t bytesprops1[] = {0x1d, 0x87, 0x4b, 0x6f, 0x96, 0xc9, 0x30}; - uint8_t bytesprops2[] = {0x39, 0x58, 0x6b}; - uint8_t bytesprops3[] = {0xb5, 0xd0, 0x69, 0x27, 0x32, 0xa1, 0xa2, 0xc0, 0x57, 0x78, - 0xce, 0xff, 0x84, 0x5a, 0xae, 0x65, 0xe0, 0x61, 0x7e, 0x95}; - uint8_t bytesprops4[] = {0xd7, 0xdd, 0x25, 0xd8, 0xbf, 0x12, 0x58, 0x58, 0xfd, 0xe8, 0x9c, 0x6d, - 0xf7, 0xe8, 0x90, 0x18, 0xb2, 0xd7, 0x5b, 0x70, 0xf3, 0x26, 0x5d, 0xa6}; - uint8_t bytesprops6[] = {0x71, 0x21, 0xc1, 0xe, 0xef, 0x24, 0xa5, 0x8, 0xa8, 0x54, - 0xdb, 0x21, 0x9a, 0x6f, 0xd6, 0xe3, 0x73, 0x6b, 0x56, 0xe8}; - uint8_t bytesprops5[] = {0xe4, 0x96}; - uint8_t bytesprops7[] = {0x42, 0x66, 0x92, 0x1b, 0x66, 0x6e, 0xaa, 0x28, 0xf3, 0x28, 0x19, - 0x9e, 0x74, 0x3, 0x9e, 0xa0, 0x1d, 0x84, 0xf, 0x43, 0x43, 0xf8}; - uint8_t bytesprops8[] = {0x86, 0x3a, 0x8, 0xc3, 0xf0, 0xb5, 0xd1, 0x9c, 0x3c, 0x3a, 0x48, 0xae, 0xac, 0xe8, 0xbe, - 0xf3, 0x80, 0xbd, 0x96, 0xd0, 0x49, 0x4f, 0x4a, 0xc8, 0x9b, 0x9a, 0x10, 0xdb, 0x1d, 0x29}; - uint8_t bytesprops9[] = {0xf9, 0xc1, 0x26, 0x31, 0x72, 0x7, 0xc5, 0x2c, 0x9f, 0x9a, 0x20, 0xcd, 0x6d, - 0x71, 0xdf, 0xa1, 0x72, 0xca, 0x82, 0x2e, 0x3e, 0x43, 0x81, 0x38, 0x83}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24345}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19854}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28084}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6563}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 22}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5595}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19259}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops5}, .v = {20, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31978}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15712}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29108}}, - }; - - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25658, 2, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 3081 [("`\165\DC2QfJ\249\SI\229\168\140",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\175\219X\239\225\227x\227\ETB\252\181h",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\168#\148j\132a\191~\220R\159N\200\142j\222\155\217)\STX\rz\233",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("?\223\227x\250\168\161\217j\189b\253dAOF\239\202\227",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\160\136\fl(\220\155",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\152\146\139\145\146",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\197\241H\131\203;\238\152\EOT\187CUa\222\142\128\EM\SUBq",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\ACK_\244\234\207,W\239J\240\181\240fXg\231",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("{\\\162.Ggs\SOH\145\237\&7T\146",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] -// [PropTopicAlias 30114,PropRequestResponseInformation 126,PropContentType "\t\191_\216\RS\US7.\SUB -// ,\208\153\132\222\204\197\197\176\233\219",PropAuthenticationMethod -// "\191d\158f\222Q\196\254\194`:\233\f\133\191a\141\r\249\175\164\225so\229\188",PropResponseTopic -// "m9`\249\133\213\149\190A\170G",PropAuthenticationData -// "\222\164I\140\207gn\206\183\DC2\NUL30\252\128\185\RS\191\214_\160\180\&7\164QuF3\FS",PropServerReference -// "\190\173j",PropAuthenticationData "\228\179\EM\159\173%w\143\239)\233\240\&2\196",PropMessageExpiryInterval -// 29813,PropMaximumQoS 102,PropServerReference "\187L",PropServerKeepAlive 30422,PropAuthenticationMethod -// "\234x\f!\209\DC2\198\166\169",PropMessageExpiryInterval 32593,PropReasonString -// "^\141\&5\229\133B\254]{\230o",PropWildcardSubscriptionAvailable 112,PropSubscriptionIdentifierAvailable -// 135,PropResponseTopic "",PropMessageExpiryInterval 20318,PropRetainAvailable 209,PropMaximumPacketSize -// 2052,PropTopicAliasMaximum 10929,PropAssignedClientIdentifier -// "\134\US85\205?\225\167\234\acZN\179\136\NAK\221\150-",PropAuthenticationMethod "\201|\174u_\EM"] -TEST(Subscribe5QCTest, Encode4) { - uint8_t pkt[] = { - 0x82, 0xfe, 0x2, 0xc, 0x9, 0xe2, 0x1, 0x23, 0x75, 0xa2, 0x19, 0x7e, 0x3, 0x0, 0x15, 0x9, 0xbf, 0x5f, 0xd8, - 0x1e, 0x1f, 0x37, 0x2e, 0x1a, 0x20, 0x2c, 0xd0, 0x99, 0x84, 0xde, 0xcc, 0xc5, 0xc5, 0xb0, 0xe9, 0xdb, 0x15, 0x0, - 0x1a, 0xbf, 0x64, 0x9e, 0x66, 0xde, 0x51, 0xc4, 0xfe, 0xc2, 0x60, 0x3a, 0xe9, 0xc, 0x85, 0xbf, 0x61, 0x8d, 0xd, - 0xf9, 0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c, 0x22, - 0x0, 0xc, 0xaf, 0xdb, 0x58, 0xef, 0xe1, 0xe3, 0x78, 0xe3, 0x17, 0xfc, 0xb5, 0x68, 0x1, 0x0, 0x17, 0xa8, 0x23, - 0x94, 0x6a, 0x84, 0x61, 0xbf, 0x7e, 0xdc, 0x52, 0x9f, 0x4e, 0xc8, 0x8e, 0x6a, 0xde, 0x9b, 0xd9, 0x29, 0x2, 0xd, - 0x7a, 0xe9, 0x2a, 0x0, 0x13, 0x3f, 0xdf, 0xe3, 0x78, 0xfa, 0xa8, 0xa1, 0xd9, 0x6a, 0xbd, 0x62, 0xfd, 0x64, 0x41, - 0x4f, 0x46, 0xef, 0xca, 0xe3, 0x16, 0x0, 0x7, 0xa0, 0x88, 0xc, 0x6c, 0x28, 0xdc, 0x9b, 0x6, 0x0, 0x5, 0x98, - 0x92, 0x8b, 0x91, 0x92, 0x26, 0x0, 0x13, 0xc5, 0xf1, 0x48, 0x83, 0xcb, 0x3b, 0xee, 0x98, 0x4, 0xbb, 0x43, 0x55, - 0x61, 0xde, 0x8e, 0x80, 0x19, 0x1a, 0x71, 0x4, 0x0, 0x10, 0x6, 0x5f, 0xf4, 0xea, 0xcf, 0x2c, 0x57, 0xef, 0x4a, - 0xf0, 0xb5, 0xf0, 0x66, 0x58, 0x67, 0xe7, 0x2e, 0x0, 0xd, 0x7b, 0x5c, 0xa2, 0x2e, 0x47, 0x67, 0x73, 0x1, 0x91, - 0xed, 0x37, 0x54, 0x92, 0x2e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x60, 0xa5, 0x12, 0x51, 0x66, 0x4a, 0xf9, 0xf, 0xe5, 0xa8, 0x8c}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xaf, 0xdb, 0x58, 0xef, 0xe1, 0xe3, 0x78, 0xe3, 0x17, 0xfc, 0xb5, 0x68}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa8, 0x23, 0x94, 0x6a, 0x84, 0x61, 0xbf, 0x7e, 0xdc, 0x52, 0x9f, 0x4e, - 0xc8, 0x8e, 0x6a, 0xde, 0x9b, 0xd9, 0x29, 0x2, 0xd, 0x7a, 0xe9}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb8, 0x2a, 0x7e, 0xed, 0x2c, 0x2b, 0x32, 0x9b, 0x32, 0x50, 0xdd, 0xc5}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3f, 0xdf, 0xe3, 0x78, 0xfa, 0xa8, 0xa1, 0xd9, 0x6a, 0xbd, - 0x62, 0xfd, 0x64, 0x41, 0x4f, 0x46, 0xef, 0xca, 0xe3}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xac, 0x36, 0xcd, 0x49, 0x3b, 0xbc, 0x6f}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa0, 0x88, 0xc, 0x6c, 0x28, 0xdc, 0x9b}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2d, 0x17, 0xc1, 0xd0}; + lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x98, 0x92, 0x8b, 0x91, 0x92}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x5, 0xd, 0xd2, 0x55, 0x8c, 0x12, 0x94, 0xc7, 0xbc, 0xa3, 0xc5, 0x5d}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc5, 0xf1, 0x48, 0x83, 0xcb, 0x3b, 0xee, 0x98, 0x4, 0xbb, - 0x43, 0x55, 0x61, 0xde, 0x8e, 0x80, 0x19, 0x1a, 0x71}; - lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x79, 0x72, 0x20, 0xcb, 0x6e, 0x9a, 0x36, + 0xc5, 0x86, 0xda, 0x78, 0x4a, 0x14, 0x90}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6, 0x5f, 0xf4, 0xea, 0xcf, 0x2c, 0x57, 0xef, - 0x4a, 0xf0, 0xb5, 0xf0, 0x66, 0x58, 0x67, 0xe7}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x38, 0x59, 0xda, 0x51, 0xaf, 0x32}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x7b, 0x5c, 0xa2, 0x2e, 0x47, 0x67, 0x73, 0x1, 0x91, 0xed, 0x37, 0x54, 0x92}; - lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; + lwmqtt_sub_options_t sub_opts[8]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; + sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; + sub_opts[6].no_local = false; sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = true; - uint8_t bytesprops0[] = {0x9, 0xbf, 0x5f, 0xd8, 0x1e, 0x1f, 0x37, 0x2e, 0x1a, 0x20, 0x2c, - 0xd0, 0x99, 0x84, 0xde, 0xcc, 0xc5, 0xc5, 0xb0, 0xe9, 0xdb}; - uint8_t bytesprops1[] = {0xbf, 0x64, 0x9e, 0x66, 0xde, 0x51, 0xc4, 0xfe, 0xc2, 0x60, 0x3a, 0xe9, 0xc, - 0x85, 0xbf, 0x61, 0x8d, 0xd, 0xf9, 0xaf, 0xa4, 0xe1, 0x73, 0x6f, 0xe5, 0xbc}; - uint8_t bytesprops2[] = {0x6d, 0x39, 0x60, 0xf9, 0x85, 0xd5, 0x95, 0xbe, 0x41, 0xaa, 0x47}; - uint8_t bytesprops3[] = {0xde, 0xa4, 0x49, 0x8c, 0xcf, 0x67, 0x6e, 0xce, 0xb7, 0x12, 0x0, 0x33, 0x30, 0xfc, 0x80, - 0xb9, 0x1e, 0xbf, 0xd6, 0x5f, 0xa0, 0xb4, 0x37, 0xa4, 0x51, 0x75, 0x46, 0x33, 0x1c}; - uint8_t bytesprops4[] = {0xbe, 0xad, 0x6a}; - uint8_t bytesprops5[] = {0xe4, 0xb3, 0x19, 0x9f, 0xad, 0x25, 0x77, 0x8f, 0xef, 0x29, 0xe9, 0xf0, 0x32, 0xc4}; - uint8_t bytesprops6[] = {0xbb, 0x4c}; - uint8_t bytesprops7[] = {0xea, 0x78, 0xc, 0x21, 0xd1, 0x12, 0xc6, 0xa6, 0xa9}; - uint8_t bytesprops8[] = {0x5e, 0x8d, 0x35, 0xe5, 0x85, 0x42, 0xfe, 0x5d, 0x7b, 0xe6, 0x6f}; - uint8_t bytesprops9[] = {0}; - uint8_t bytesprops10[] = {0x86, 0x1f, 0x38, 0x35, 0xcd, 0x3f, 0xe1, 0xa7, 0xea, 0x7, - 0x63, 0x5a, 0x4e, 0xb3, 0x88, 0x15, 0xdd, 0x96, 0x2d}; - uint8_t bytesprops11[] = {0xc9, 0x7c, 0xae, 0x75, 0x5f, 0x19}; + sub_opts[7].no_local = false; + uint8_t bytesprops0[] = {0x5, 0x54, 0xf6}; + uint8_t bytesprops1[] = {0x4b, 0xd, 0x30, 0x99, 0xd9, 0x1c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30114}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29813}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30422}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32593}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20318}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2052}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10929}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11958}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 59}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3081, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10952, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26803 [("G0\203x\EOT9\163\234\244~\250\213\DEL\247z'\226",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("m,s\SO\194G\181\182\&9\128N\200\150;gq9\182u?e\\\252\219\SO\133\DC2\146\242W",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\129\156\160\NAK\194\&8\202\196Y -// \172\147\213\175\141*\168\ETB\195y\147",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("iM\SYN\223q\DEL@J\183\233\132\254[*",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("jX\ra\242\DC1\ETB@E\181\181\252R",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\224\GSH\ESCU\212",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropReceiveMaximum 7683,PropMessageExpiryInterval -// 31743,PropAuthenticationMethod "\STXL\254\223\133\190H\217\228\f",PropServerReference -// "^\244\132\253?e\ENQ\\",PropSessionExpiryInterval 16241,PropResponseTopic -// "\246\137\225H\161r\219\203\242\149\ETB?\173e2\219\130\192\&7"] -TEST(Subscribe5QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x68, 0xb3, 0x3b, 0x21, 0x1e, 0x3, 0x2, 0x0, 0x0, 0x7b, 0xff, 0x15, 0x0, 0xa, - 0x2, 0x4c, 0xfe, 0xdf, 0x85, 0xbe, 0x48, 0xd9, 0xe4, 0xc, 0x1c, 0x0, 0x8, 0x5e, 0xf4, 0x84, 0xfd, - 0x3f, 0x65, 0x5, 0x5c, 0x11, 0x0, 0x0, 0x3f, 0x71, 0x8, 0x0, 0x13, 0xf6, 0x89, 0xe1, 0x48, 0xa1, - 0x72, 0xdb, 0xcb, 0xf2, 0x95, 0x17, 0x3f, 0xad, 0x65, 0x32, 0xdb, 0x82, 0xc0, 0x37, 0x0, 0x11, 0x47, - 0x30, 0xcb, 0x78, 0x4, 0x39, 0xa3, 0xea, 0xf4, 0x7e, 0xfa, 0xd5, 0x7f, 0xf7, 0x7a, 0x27, 0xe2, 0x12, - 0x0, 0x1e, 0x6d, 0x2c, 0x73, 0xe, 0xc2, 0x47, 0xb5, 0xb6, 0x39, 0x80, 0x4e, 0xc8, 0x96, 0x3b, 0x67, - 0x71, 0x39, 0xb6, 0x75, 0x3f, 0x65, 0x5c, 0xfc, 0xdb, 0xe, 0x85, 0x12, 0x92, 0xf2, 0x57, 0x12, 0x0, - 0x15, 0x81, 0x9c, 0xa0, 0x15, 0xc2, 0x38, 0xca, 0xc4, 0x59, 0x20, 0xac, 0x93, 0xd5, 0xaf, 0x8d, 0x2a, - 0xa8, 0x17, 0xc3, 0x79, 0x93, 0x11, 0x0, 0xe, 0x69, 0x4d, 0x16, 0xdf, 0x71, 0x7f, 0x40, 0x4a, 0xb7, - 0xe9, 0x84, 0xfe, 0x5b, 0x2a, 0x1, 0x0, 0xd, 0x6a, 0x58, 0xd, 0x61, 0xf2, 0x11, 0x17, 0x40, 0x45, - 0xb5, 0xb5, 0xfc, 0x52, 0x21, 0x0, 0x6, 0xe0, 0x1d, 0x48, 0x1b, 0x55, 0xd4, 0x26}; +// SubscribeRequest 20143 +// [("N\178\188\208\255\162\DEL;\181\212\177\147\234\168\234)\194x\206K)\DC1\247\191\&4f\155",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\f\163\ACK\SYN_G\244\236M\230\204",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] -// [PropRetainAvailable 101,PropContentType "&\\\165",PropMaximumPacketSize 20497,PropMessageExpiryInterval -// 18487,PropServerReference "c\228\200\129\177n\NUL\168A\195\249\232\239\171\148\154",PropRetainAvailable -// 246,PropMessageExpiryInterval 3316,PropResponseTopic "\"\186",PropPayloadFormatIndicator 25,PropTopicAliasMaximum -// 6042,PropResponseInformation "\149eE\137\222\&0\202\143\DC1C\234\157|[\249\178?",PropMessageExpiryInterval -// 22525,PropResponseInformation "\197\250[\230\a\242\180R\186\163\170\240\247t\187\238\DEL -// t\"\164\156+\130\164",PropRequestResponseInformation 170] +// QoS2}),("\248a\225\201p\DC1\181Fv\210\218\SO\224\SUB",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("F\239\160",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\183.\246y\164\162\208y\STX",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS0}),("\202\130\192\137\231\STX\164\EM\195z\168#Tej\129O>kO\229g",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),(",\255\175\ENQ\139\179%\241\252\148^\228T\243\DLE",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\DEL\152",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\ACK\168&\158\RS\EM(\144%\ACKy\f\185=\229\161\139\170\SOH",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\RSMD\EM\154\220\162\b\165\174\174Z\246\DLE$\b\193",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropAuthenticationMethod +// "x\212\152\154t\129",PropWillDelayInterval 23768,PropMaximumPacketSize 4377,PropUserProperty "\218Wa\190I" +// "&",PropMessageExpiryInterval 12138,PropAuthenticationMethod +// "\144\205[\206\179\b\151\131\138\DC1\163\128\173\253(S\187_\173\235\174\209\240\229h^l\156",PropReasonString +// "\v\151Ft\139v\136\167\SO[q",PropMaximumQoS 123,PropServerKeepAlive 14339,PropContentType +// "\137\147\215\215\NAK\168`jX3\"\243",PropRequestResponseInformation 133,PropWillDelayInterval +// 26823,PropResponseInformation "\USn\226Y8\247\180\&4\241\&0N\vU",PropReasonString "\145",PropRetainAvailable +// 117,PropTopicAlias 7329,PropMaximumPacketSize 25747,PropMaximumQoS 237,PropWildcardSubscriptionAvailable +// 187,PropSessionExpiryInterval 28904,PropServerKeepAlive 25814,PropRequestResponseInformation 14] TEST(Subscribe5QCTest, Encode7) { uint8_t pkt[] = { - 0x82, 0xc1, 0x2, 0x79, 0x44, 0x6d, 0x25, 0x65, 0x3, 0x0, 0x3, 0x26, 0x5c, 0xa5, 0x27, 0x0, 0x0, 0x50, - 0x11, 0x2, 0x0, 0x0, 0x48, 0x37, 0x1c, 0x0, 0x10, 0x63, 0xe4, 0xc8, 0x81, 0xb1, 0x6e, 0x0, 0xa8, 0x41, - 0xc3, 0xf9, 0xe8, 0xef, 0xab, 0x94, 0x9a, 0x25, 0xf6, 0x2, 0x0, 0x0, 0xc, 0xf4, 0x8, 0x0, 0x2, 0x22, - 0xba, 0x1, 0x19, 0x22, 0x17, 0x9a, 0x1a, 0x0, 0x11, 0x95, 0x65, 0x45, 0x89, 0xde, 0x30, 0xca, 0x8f, 0x11, - 0x43, 0xea, 0x9d, 0x7c, 0x5b, 0xf9, 0xb2, 0x3f, 0x2, 0x0, 0x0, 0x57, 0xfd, 0x1a, 0x0, 0x19, 0xc5, 0xfa, - 0x5b, 0xe6, 0x7, 0xf2, 0xb4, 0x52, 0xba, 0xa3, 0xaa, 0xf0, 0xf7, 0x74, 0xbb, 0xee, 0x7f, 0x20, 0x74, 0x22, - 0xa4, 0x9c, 0x2b, 0x82, 0xa4, 0x19, 0xaa, 0x0, 0x1b, 0xbb, 0xc8, 0x9c, 0x21, 0x9e, 0xc, 0x34, 0x2, 0x0, - 0xac, 0x5, 0xf4, 0x7e, 0xd0, 0xac, 0x42, 0x13, 0x29, 0x91, 0x43, 0x31, 0xa6, 0x6d, 0xd0, 0xaf, 0xfe, 0x54, - 0x21, 0x0, 0x14, 0x11, 0x7c, 0x18, 0xdb, 0x13, 0x8f, 0xf2, 0x5, 0x14, 0x56, 0x18,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 0x9, 0xb7, 0x2e, 0xf6, 0x79, 0xa4, 0xa2, 0xd0, 0x79, 0x2, 0x2c, 0x0, 0x16, 0xca, 0x82, 0xc0, 0x89, 0xe7, 0x2, + 0xa4, 0x19, 0xc3, 0x7a, 0xa8, 0x23, 0x54, 0x65, 0x6a, 0x81, 0x4f, 0x3e, 0x6b, 0x4f, 0xe5, 0x67, 0x28, 0x0, 0xf, + 0x2c, 0xff, 0xaf, 0x5, 0x8b, 0xb3, 0x25, 0xf1, 0xfc, 0x94, 0x5e, 0xe4, 0x54, 0xf3, 0x10, 0xe, 0x0, 0x2, 0x7f, + 0x98, 0x29, 0x0, 0x0, 0x18, 0x0, 0x13, 0x6, 0xa8, 0x26, 0x9e, 0x1e, 0x19, 0x28, 0x90, 0x25, 0x6, 0x79, 0xc, + 0xb9, 0x3d, 0xe5, 0xa1, 0x8b, 0xaa, 0x1, 0x4, 0x0, 0x11, 0x1e, 0x4d, 0x44, 0x19, 0x9a, 0xdc, 0xa2, 0x8, 0xa5, + 0xae, 0xae, 0x5a, 0xf6, 0x10, 0x24, 0x8, 0xc1, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xbb, 0xc8, 0x9c, 0x21, 0x9e, 0xc, 0x34, 0x2, 0x0, 0xac, 0x5, 0xf4, 0x7e, 0xd0, - 0xac, 0x42, 0x13, 0x29, 0x91, 0x43, 0x31, 0xa6, 0x6d, 0xd0, 0xaf, 0xfe, 0x54}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x2e, 0x4a, 0xab, 0x7f, 0xa0, 0xc2, 0xe1, 0xe1, 0xaf, 0xd7, 0x2c, 0x42, + 0x8c, 0x58, 0x11, 0xa, 0x60, 0x52, 0xb8, 0x6a, 0xa4, 0x5a, 0x42, 0x5}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x11, 0x7c, 0x18, 0xdb, 0x13, 0x8f, 0xf2, 0x5, 0x14, 0x56, - 0x18, 0x88, 0x88, 0x6f, 0xe, 0x1b, 0x13, 0x2f, 0x9e, 0x3b}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf8, 0x61, 0xe1, 0xc9, 0x70, 0x11, 0xb5, 0x46, 0x76, 0xd2, 0xda, 0xe, 0xe0, 0x1a}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8c, 0x6e, 0x95, 0x67, 0x50, 0xa5, 0x85, 0x43, 0xb7, 0x8c, 0x90, 0xc3, - 0x49, 0xd, 0x1e, 0xd7, 0x20, 0xca, 0x45, 0x58, 0x4, 0xcb, 0x87}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x46, 0xef, 0xa0}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x19}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xb7, 0x2e, 0xf6, 0x79, 0xa4, 0xa2, 0xd0, 0x79, 0x2}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x70, 0x3c, 0x95, 0xb5, 0x16, 0xeb, 0x62, - 0x3c, 0x4e, 0xf2, 0xcb, 0x70, 0x53, 0xad}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xca, 0x82, 0xc0, 0x89, 0xe7, 0x2, 0xa4, 0x19, 0xc3, 0x7a, 0xa8, + 0x23, 0x54, 0x65, 0x6a, 0x81, 0x4f, 0x3e, 0x6b, 0x4f, 0xe5, 0x67}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfa, 0x5, 0xc2, 0xa5, 0x99, 0x3b, 0x97, 0xad, 0x8f, 0xdc, - 0x7a, 0xaf, 0x6e, 0xa8, 0x36, 0xbb, 0xe8, 0xf, 0x99, 0x84, - 0x47, 0xbd, 0x1a, 0xab, 0x76, 0xf7, 0xb2, 0x57, 0xdb}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x2c, 0xff, 0xaf, 0x5, 0x8b, 0xb3, 0x25, 0xf1, + 0xfc, 0x94, 0x5e, 0xe4, 0x54, 0xf3, 0x10}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb5, 0xd8, 0xd6, 0x65, 0xe1, 0x30, 0x23, 0x5d, 0xce, 0xf0, - 0x37, 0xc7, 0x3, 0x85, 0x84, 0x94, 0xd8, 0x37, 0x63, 0x3b, - 0x49, 0x1f, 0xd4, 0x4, 0x1f, 0xda, 0x75, 0xb2}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x7f, 0x98}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7a, 0x89, 0x46, 0x4c, 0x6d, 0x30, 0x37, 0x3d, - 0xe6, 0x46, 0xcd, 0xf2, 0xd, 0xa4, 0xdd}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xbe, 0xb5, 0x60, 0x82, 0xea, 0xbb, 0xb0, 0x46, 0xc1, 0x95, 0xf2, 0xdf, 0x37, - 0x82, 0xa7, 0x3e, 0x6, 0x16, 0x5f, 0x47, 0xf4, 0xec, 0x4d, 0xe6, 0xcc}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x6, 0xa8, 0x26, 0x9e, 0x1e, 0x19, 0x28, 0x90, 0x25, 0x6, + 0x79, 0xc, 0xb9, 0x3d, 0xe5, 0xa1, 0x8b, 0xaa, 0x1}; + lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s9_bytes[] = {0x1e, 0x4d, 0x44, 0x19, 0x9a, 0xdc, 0xa2, 0x8, 0xa5, + 0xae, 0xae, 0x5a, 0xf6, 0x10, 0x24, 0x8, 0xc1}; + lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; sub_opts[7].no_local = false; sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = false; - uint8_t bytesprops0[] = {0x26, 0x5c, 0xa5}; - uint8_t bytesprops1[] = {0x63, 0xe4, 0xc8, 0x81, 0xb1, 0x6e, 0x0, 0xa8, - 0x41, 0xc3, 0xf9, 0xe8, 0xef, 0xab, 0x94, 0x9a}; - uint8_t bytesprops2[] = {0x22, 0xba}; - uint8_t bytesprops3[] = {0x95, 0x65, 0x45, 0x89, 0xde, 0x30, 0xca, 0x8f, 0x11, - 0x43, 0xea, 0x9d, 0x7c, 0x5b, 0xf9, 0xb2, 0x3f}; - uint8_t bytesprops4[] = {0xc5, 0xfa, 0x5b, 0xe6, 0x7, 0xf2, 0xb4, 0x52, 0xba, 0xa3, 0xaa, 0xf0, 0xf7, - 0x74, 0xbb, 0xee, 0x7f, 0x20, 0x74, 0x22, 0xa4, 0x9c, 0x2b, 0x82, 0xa4}; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + uint8_t bytesprops0[] = {0x78, 0xd4, 0x98, 0x9a, 0x74, 0x81}; + uint8_t bytesprops2[] = {0x26}; + uint8_t bytesprops1[] = {0xda, 0x57, 0x61, 0xbe, 0x49}; + uint8_t bytesprops3[] = {0x90, 0xcd, 0x5b, 0xce, 0xb3, 0x8, 0x97, 0x83, 0x8a, 0x11, 0xa3, 0x80, 0xad, 0xfd, + 0x28, 0x53, 0xbb, 0x5f, 0xad, 0xeb, 0xae, 0xd1, 0xf0, 0xe5, 0x68, 0x5e, 0x6c, 0x9c}; + uint8_t bytesprops4[] = {0xb, 0x97, 0x46, 0x74, 0x8b, 0x76, 0x88, 0xa7, 0xe, 0x5b, 0x71}; + uint8_t bytesprops5[] = {0x89, 0x93, 0xd7, 0xd7, 0x15, 0xa8, 0x60, 0x6a, 0x58, 0x33, 0x22, 0xf3}; + uint8_t bytesprops6[] = {0x1f, 0x6e, 0xe2, 0x59, 0x38, 0xf7, 0xb4, 0x34, 0xf1, 0x30, 0x4e, 0xb, 0x55}; + uint8_t bytesprops7[] = {0x91}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20497}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18487}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3316}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6042}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22525}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23768}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4377}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops1}, .v = {1, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12138}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14339}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26823}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7329}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25747}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28904}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25814}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 14}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31044, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3461, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8770 [("\246\142&\218\222\148\226\196\212s~U\253",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\189\174\GS0\252J -// \229\&3J\f\139\225\150\221\DC4p\226\223",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\169Q;\220&z\151\248\&5\149\161\202h\ENQ\162\148\158\137b\203\f",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] -// [PropSessionExpiryInterval 9936,PropSessionExpiryInterval 30050,PropServerReference -// "\SUB|\201K\186(\FS\r\206\252\DC2\237\146Qw",PropWillDelayInterval 32549,PropReasonString -// "i\DC32\234\247\183",PropResponseTopic -// "[\238\247)\US\163\191\&3\202\245\198>\191t\aN'\229\148\176\ESC\202\SOH",PropUserProperty -// "f\222\236MO\EM71\132\198mB\241\177\178\ETB" -// "G\GS\252#v\237\198d\187\187r\187\162\152\&7\SOH+\225\ETX",PropRetainAvailable 171,PropRetainAvailable -// 209,PropTopicAlias 15467,PropTopicAliasMaximum 17442,PropResponseTopic -// "\219\132-\135\129#.\214\206\184i\238\DC3\130\220\US\168\248T\RSD\SYN\SUBB\185\SUB\135\129",PropAuthenticationData "W -// \218C\190\149\240",PropPayloadFormatIndicator 81,PropCorrelationData -// "\247\232^\221CdI./B",PropRequestProblemInformation 89,PropResponseInformation -// "\EM\138\225i\197\247\188u\196\NAK\"y\234\254o\GS\158\155\248\227\151\250n\142\255\195\SYN\135\181",PropMaximumQoS -// 163,PropPayloadFormatIndicator 45,PropServerReference -// "\SYN@\DLE\207\222\SOH\184\213\&33?&\t\159",PropSessionExpiryInterval 6115,PropServerReference -// "#N\SOH\ESC\SO\ETBbN\155\r[\173",PropWillDelayInterval 15590,PropSubscriptionIdentifierAvailable -// 72,PropReceiveMaximum 1371,PropUserProperty "7\DC1\204\177,\170IK\144\133\218`\156\223X\134\150\DELs\247:" -// "\192uN\191G\a\246\150\253\&9\192\SO\DC3\196\162\196\205]{\213g\148B#\177\224>\239t",PropMessageExpiryInterval -// 3198,PropReceiveMaximum 19723] +// SubscribeRequest 24628 [("J$\202\SOH\164s\193\241\FS\196\170\186\133\233\147!bV\164\233m\185\177wW",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("Pu\230B\171\159)-\n\236\132r\193f\179`H\140\168\r&\ESC\241\173\219\190",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropCorrelationData +// "\153(\158EC\160\189\DLE\169\253\218\US\b\135\228\NUL\232S\225}\178\193\170\&6W)l\211g",PropReasonString +// "6`",PropResponseTopic "\165\EOT\NUL\163\169\235tpr\186\137#=\DEL\SYN",PropMaximumQoS 87] TEST(Subscribe5QCTest, Encode8) { - uint8_t pkt[] = { - 0x82, 0x84, 0x3, 0x22, 0x42, 0xc2, 0x2, 0x11, 0x0, 0x0, 0x26, 0xd0, 0x11, 0x0, 0x0, 0x75, 0x62, 0x1c, 0x0, - 0xf, 0x1a, 0x7c, 0xc9, 0x4b, 0xba, 0x28, 0x1c, 0xd, 0xce, 0xfc, 0x12, 0xed, 0x92, 0x51, 0x77, 0x18, 0x0, 0x0, - 0x7f, 0x25, 0x1f, 0x0, 0x6, 0x69, 0x13, 0x32, 0xea, 0xf7, 0xb7, 0x8, 0x0, 0x17, 0x5b, 0xee, 0xf7, 0x29, 0x1f, - 0xa3, 0xbf, 0x33, 0xca, 0xf5, 0xc6, 0x3e, 0xbf, 0x74, 0x7, 0x4e, 0x27, 0xe5, 0x94, 0xb0, 0x1b, 0xca, 0x1, 0x26, - 0x0, 0x10, 0x66, 0xde, 0xec, 0x4d, 0x4f, 0x19, 0x37, 0x31, 0x84, 0xc6, 0x6d, 0x42, 0xf1, 0xb1, 0xb2, 0x17, 0x0, - 0x13, 0x47, 0x1d, 0xfc, 0x23, 0x76, 0xed, 0xc6, 0x64, 0xbb, 0xbb, 0x72, 0xbb, 0xa2, 0x98, 0x37, 0x1, 0x2b, 0xe1, - 0x3, 0x25, 0xab, 0x25, 0xd1, 0x23, 0x3c, 0x6b, 0x22, 0x44, 0x22, 0x8, 0x0, 0x1c, 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x48, 0x8c, 0xa8, 0xd, 0x26, 0x1b, 0xf1, 0xad, 0xdb, 0xbe, 0x16}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xf6, 0x8e, 0x26, 0xda, 0xde, 0x94, 0xe2, 0xc4, 0xd4, 0x73, 0x7e, 0x55, 0xfd}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x4a, 0x24, 0xca, 0x1, 0xa4, 0x73, 0xc1, 0xf1, 0x1c, 0xc4, 0xaa, 0xba, 0x85, + 0xe9, 0x93, 0x21, 0x62, 0x56, 0xa4, 0xe9, 0x6d, 0xb9, 0xb1, 0x77, 0x57}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbd, 0xae, 0x1d, 0x30, 0xfc, 0x4a, 0x20, 0xe5, 0x33, 0x4a, - 0xc, 0x8b, 0xe1, 0x96, 0xdd, 0x14, 0x70, 0xe2, 0xdf}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x50, 0x75, 0xe6, 0x42, 0xab, 0x9f, 0x29, 0x2d, 0xa, 0xec, 0x84, 0x72, 0xc1, + 0x66, 0xb3, 0x60, 0x48, 0x8c, 0xa8, 0xd, 0x26, 0x1b, 0xf1, 0xad, 0xdb, 0xbe}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa9, 0x51, 0x3b, 0xdc, 0x26, 0x7a, 0x97, 0xf8, 0x35, 0x95, 0xa1, - 0xca, 0x68, 0x5, 0xa2, 0x94, 0x9e, 0x89, 0x62, 0xcb, 0xc}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - uint8_t bytesprops0[] = {0x1a, 0x7c, 0xc9, 0x4b, 0xba, 0x28, 0x1c, 0xd, 0xce, 0xfc, 0x12, 0xed, 0x92, 0x51, 0x77}; - uint8_t bytesprops1[] = {0x69, 0x13, 0x32, 0xea, 0xf7, 0xb7}; - uint8_t bytesprops2[] = {0x5b, 0xee, 0xf7, 0x29, 0x1f, 0xa3, 0xbf, 0x33, 0xca, 0xf5, 0xc6, 0x3e, - 0xbf, 0x74, 0x7, 0x4e, 0x27, 0xe5, 0x94, 0xb0, 0x1b, 0xca, 0x1}; - uint8_t bytesprops4[] = {0x47, 0x1d, 0xfc, 0x23, 0x76, 0xed, 0xc6, 0x64, 0xbb, 0xbb, - 0x72, 0xbb, 0xa2, 0x98, 0x37, 0x1, 0x2b, 0xe1, 0x3}; - uint8_t bytesprops3[] = {0x66, 0xde, 0xec, 0x4d, 0x4f, 0x19, 0x37, 0x31, - 0x84, 0xc6, 0x6d, 0x42, 0xf1, 0xb1, 0xb2, 0x17}; - uint8_t bytesprops5[] = {0xdb, 0x84, 0x2d, 0x87, 0x81, 0x23, 0x2e, 0xd6, 0xce, 0xb8, 0x69, 0xee, 0x13, 0x82, - 0xdc, 0x1f, 0xa8, 0xf8, 0x54, 0x1e, 0x44, 0x16, 0x1a, 0x42, 0xb9, 0x1a, 0x87, 0x81}; - uint8_t bytesprops6[] = {0x57, 0x20, 0xda, 0x43, 0xbe, 0x95, 0xf0}; - uint8_t bytesprops7[] = {0xf7, 0xe8, 0x5e, 0xdd, 0x43, 0x64, 0x49, 0x2e, 0x2f, 0x42}; - uint8_t bytesprops8[] = {0x19, 0x8a, 0xe1, 0x69, 0xc5, 0xf7, 0xbc, 0x75, 0xc4, 0x15, 0x22, 0x79, 0xea, 0xfe, 0x6f, - 0x1d, 0x9e, 0x9b, 0xf8, 0xe3, 0x97, 0xfa, 0x6e, 0x8e, 0xff, 0xc3, 0x16, 0x87, 0xb5}; - uint8_t bytesprops9[] = {0x16, 0x40, 0x10, 0xcf, 0xde, 0x1, 0xb8, 0xd5, 0x33, 0x33, 0x3f, 0x26, 0x9, 0x9f}; - uint8_t bytesprops10[] = {0x23, 0x4e, 0x1, 0x1b, 0xe, 0x17, 0x62, 0x4e, 0x9b, 0xd, 0x5b, 0xad}; - uint8_t bytesprops12[] = {0xc0, 0x75, 0x4e, 0xbf, 0x47, 0x7, 0xf6, 0x96, 0xfd, 0x39, 0xc0, 0xe, 0x13, 0xc4, 0xa2, - 0xc4, 0xcd, 0x5d, 0x7b, 0xd5, 0x67, 0x94, 0x42, 0x23, 0xb1, 0xe0, 0x3e, 0xef, 0x74}; - uint8_t bytesprops11[] = {0x37, 0x11, 0xcc, 0xb1, 0x2c, 0xaa, 0x49, 0x4b, 0x90, 0x85, 0xda, - 0x60, 0x9c, 0xdf, 0x58, 0x86, 0x96, 0x7f, 0x73, 0xf7, 0x3a}; + sub_opts[1].no_local = true; + uint8_t bytesprops0[] = {0x99, 0x28, 0x9e, 0x45, 0x43, 0xa0, 0xbd, 0x10, 0xa9, 0xfd, 0xda, 0x1f, 0x8, 0x87, 0xe4, + 0x0, 0xe8, 0x53, 0xe1, 0x7d, 0xb2, 0xc1, 0xaa, 0x36, 0x57, 0x29, 0x6c, 0xd3, 0x67}; + uint8_t bytesprops1[] = {0x36, 0x60}; + uint8_t bytesprops2[] = {0xa5, 0x4, 0x0, 0xa3, 0xa9, 0xeb, 0x74, 0x70, 0x72, 0xba, 0x89, 0x23, 0x3d, 0x7f, 0x16}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9936}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30050}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32549}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {19, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15467}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17442}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6115}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15590}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1371}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {21, (char*)&bytesprops11}, .v = {29, (char*)&bytesprops12}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3198}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19723}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8770, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24628, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15580 -// [("\145\183m\232\217\188\204_\223\249\161\170\156\133T\234\233\159\235\&2H\175J\211\149j",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("]\151",SubOptions {_retainHandling -// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\238\244E\141\168\203\228s?\190\232J\139\182N\157",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAssignedClientIdentifier -// "O,\169e`v\182\133\201{\177\141L\192\157\142\128\243\145\133\163\140",PropRequestResponseInformation -// 235,PropSubscriptionIdentifier 23,PropAssignedClientIdentifier -// "\135\142\141\222\141\SYN\\2\139i0r<(\237\169F\249\220\233",PropReceiveMaximum 29989,PropMessageExpiryInterval -// 28800,PropAuthenticationData "\243\152",PropMessageExpiryInterval 17966,PropSharedSubscriptionAvailable -// 153,PropResponseTopic -// "\v\FS\131\164Ml\229z\207\FS\EM,\227\250L\164H\b0\170\162\b6\139\167\169\171",PropServerReference -// "\133\224\SOq\173\244\SI\v\ACKw\SOH{\226\164z",PropSubscriptionIdentifier 10,PropUserProperty -// "\253\156\217\b\208@\146" "\aY\EM\234",PropRequestProblemInformation 148,PropContentType -// "\237]{\ENQ3w\196\186",PropRequestResponseInformation 28,PropMaximumPacketSize 1417,PropWillDelayInterval -// 10215,PropMaximumPacketSize 8387,PropAssignedClientIdentifier "\162\&5",PropRequestResponseInformation -// 158,PropMessageExpiryInterval 8655,PropMaximumQoS 49,PropServerKeepAlive 9880,PropRequestResponseInformation -// 70,PropSubscriptionIdentifier 15,PropAuthenticationData -// ",o\155\&0\139\252IS\234N,=\179\&1p\v\193\155\&2\230",PropWillDelayInterval 1640,PropTopicAlias -// 21613,PropMessageExpiryInterval 10411] +// SubscribeRequest 27288 [("\217\135\214\SIKL\f\214\225\208\141\236\194:4\212\162{\DLE\CAN",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\203\193<\223\198\148=\252\DC3=x\192\203\215\231\&2\211",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("-.N5P\STXC\CAN",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\147\DLE\210K\RS,n\142:0O\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\STXs\187\214l$s\164\&9O\a\137M\132\197\"\151\179\229,\193\188^\173",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\252\138+\n\175\ETX\235\\s\224\216\249m\228WJ\fy\195\226\195#\182\139\215",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\143\237,\176$\130\243/\DLE\DEL\156\226\192\193I%D7a\SUB",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\160}\178\229\154'\175?\176I\167Y\243r+\148\192\&4\186X:\192\247r\246\132",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\DC4\128\162\SO\152]\188\DC1\184\174M\136\DC4\203\235\164\203\ACK\136\208\255N\133\250\173",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("?'h\n\240j\b\244;\129\DEL\203\169\ENQ\149\140\131\168h\137$",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropSessionExpiryInterval +// 1940,PropMaximumPacketSize 30321,PropSessionExpiryInterval 32334,PropUserProperty "'\240\247\249\192j\130\233\&6\133" +// "C\180\&0\139M\153{\235X@",PropSubscriptionIdentifierAvailable 218,PropTopicAliasMaximum 13456,PropContentType +// "\150\SUBd\169|R\n\147\137\\\154\130 H\152\183\133Y\201",PropServerKeepAlive 13969,PropSubscriptionIdentifier +// 16,PropWildcardSubscriptionAvailable 194,PropCorrelationData ""] TEST(Subscribe5QCTest, Encode9) { u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d, 0x88, 0x14, 0xcb, 0xeb, 0xa4, 0xcb, 0x6, 0x88, 0xd0, 0xff, 0x4e, 0x85, 0xfa, + 0xad, 0x1d, 0x0, 0x15, 0x3f, 0x27, 0x68, 0xa, 0xf0, 0x6a, 0x8, 0xf4, 0x3b, 0x81, 0x7f, 0xcb, 0xa9, 0x5, 0x95, + 0x8c, 0x83, 0xa8, 0x68, 0x89, 0x24, 0x24}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x91, 0xb7, 0x6d, 0xe8, 0xd9, 0xbc, 0xcc, 0x5f, 0xdf, 0xf9, 0xa1, 0xaa, 0x9c, - 0x85, 0x54, 0xea, 0xe9, 0x9f, 0xeb, 0x32, 0x48, 0xaf, 0x4a, 0xd3, 0x95, 0x6a}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd9, 0x87, 0xd6, 0xf, 0x4b, 0x4c, 0xc, 0xd6, 0xe1, 0xd0, + 0x8d, 0xec, 0xc2, 0x3a, 0x34, 0xd4, 0xa2, 0x7b, 0x10, 0x18}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5d, 0x97}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xcb, 0xc1, 0x3c, 0xdf, 0xc6, 0x94, 0x3d, 0xfc, 0x13, + 0x3d, 0x78, 0xc0, 0xcb, 0xd7, 0xe7, 0x32, 0xd3}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xee, 0xf4, 0x45, 0x8d, 0xa8, 0xcb, 0xe4, 0x73, - 0x3f, 0xbe, 0xe8, 0x4a, 0x8b, 0xb6, 0x4e, 0x9d}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2d, 0x2e, 0x4e, 0x35, 0x50, 0x2, 0x43, 0x18}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; + uint8_t topic_filter_s3_bytes[] = {0x93, 0x10, 0xd2, 0x4b, 0x1e, 0x2c, 0x6e, 0x8e, 0x3a, 0x30, 0x4f, 0xd9}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x2, 0x73, 0xbb, 0xd6, 0x6c, 0x24, 0x73, 0xa4, 0x39, 0x4f, 0x7, 0x89, + 0x4d, 0x84, 0xc5, 0x22, 0x97, 0xb3, 0xe5, 0x2c, 0xc1, 0xbc, 0x5e, 0xad}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xfc, 0x8a, 0x2b, 0xa, 0xaf, 0x3, 0xeb, 0x5c, 0x73, 0xe0, 0xd8, 0xf9, 0x6d, + 0xe4, 0x57, 0x4a, 0xc, 0x79, 0xc3, 0xe2, 0xc3, 0x23, 0xb6, 0x8b, 0xd7}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8f, 0xed, 0x2c, 0xb0, 0x24, 0x82, 0xf3, 0x2f, 0x10, 0x7f, + 0x9c, 0xe2, 0xc0, 0xc1, 0x49, 0x25, 0x44, 0x37, 0x61, 0x1a}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xa0, 0x7d, 0xb2, 0xe5, 0x9a, 0x27, 0xaf, 0x3f, 0xb0, 0x49, 0xa7, 0x59, 0xf3, + 0x72, 0x2b, 0x94, 0xc0, 0x34, 0xba, 0x58, 0x3a, 0xc0, 0xf7, 0x72, 0xf6, 0x84}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x14, 0x80, 0xa2, 0xe, 0x98, 0x5d, 0xbc, 0x11, 0xb8, 0xae, 0x4d, 0x88, 0x14, + 0xcb, 0xeb, 0xa4, 0xcb, 0x6, 0x88, 0xd0, 0xff, 0x4e, 0x85, 0xfa, 0xad}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x3f, 0x27, 0x68, 0xa, 0xf0, 0x6a, 0x8, 0xf4, 0x3b, 0x81, 0x7f, + 0xcb, 0xa9, 0x5, 0x95, 0x8c, 0x83, 0xa8, 0x68, 0x89, 0x24}; + lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - uint8_t bytesprops0[] = {0x4f, 0x2c, 0xa9, 0x65, 0x60, 0x76, 0xb6, 0x85, 0xc9, 0x7b, 0xb1, - 0x8d, 0x4c, 0xc0, 0x9d, 0x8e, 0x80, 0xf3, 0x91, 0x85, 0xa3, 0x8c}; - uint8_t bytesprops1[] = {0x87, 0x8e, 0x8d, 0xde, 0x8d, 0x16, 0x5c, 0x32, 0x8b, 0x69, - 0x30, 0x72, 0x3c, 0x28, 0xed, 0xa9, 0x46, 0xf9, 0xdc, 0xe9}; - uint8_t bytesprops2[] = {0xf3, 0x98}; - uint8_t bytesprops3[] = {0xb, 0x1c, 0x83, 0xa4, 0x4d, 0x6c, 0xe5, 0x7a, 0xcf, 0x1c, 0x19, 0x2c, 0xe3, 0xfa, - 0x4c, 0xa4, 0x48, 0x8, 0x30, 0xaa, 0xa2, 0x8, 0x36, 0x8b, 0xa7, 0xa9, 0xab}; - uint8_t bytesprops4[] = {0x85, 0xe0, 0xe, 0x71, 0xad, 0xf4, 0xf, 0xb, 0x6, 0x77, 0x1, 0x7b, 0xe2, 0xa4, 0x7a}; - uint8_t bytesprops6[] = {0x7, 0x59, 0x19, 0xea}; - uint8_t bytesprops5[] = {0xfd, 0x9c, 0xd9, 0x8, 0xd0, 0x40, 0x92}; - uint8_t bytesprops7[] = {0xed, 0x5d, 0x7b, 0x5, 0x33, 0x77, 0xc4, 0xba}; - uint8_t bytesprops8[] = {0xa2, 0x35}; - uint8_t bytesprops9[] = {0x2c, 0x6f, 0x9b, 0x30, 0x8b, 0xfc, 0x49, 0x53, 0xea, 0x4e, - 0x2c, 0x3d, 0xb3, 0x31, 0x70, 0xb, 0xc1, 0x9b, 0x32, 0xe6}; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = true; + uint8_t bytesprops1[] = {0x43, 0xb4, 0x30, 0x8b, 0x4d, 0x99, 0x7b, 0xeb, 0x58, 0x40}; + uint8_t bytesprops0[] = {0x27, 0xf0, 0xf7, 0xf9, 0xc0, 0x6a, 0x82, 0xe9, 0x36, 0x85}; + uint8_t bytesprops2[] = {0x96, 0x1a, 0x64, 0xa9, 0x7c, 0x52, 0xa, 0x93, 0x89, 0x5c, + 0x9a, 0x82, 0x20, 0x48, 0x98, 0xb7, 0x85, 0x59, 0xc9}; + uint8_t bytesprops3[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29989}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28800}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17966}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 10}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops5}, .v = {4, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1417}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10215}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8387}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8655}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9880}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1640}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21613}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10411}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1940}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30321}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32334}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13456}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13969}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15580, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27288, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 10667 [("I\153\NUL\206\134\163T\222V`b\232I\232\254u\213}=\145\234\200$\183#\148\179",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("T\SYN\184.5\131\&8r'\221\184\170AuL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS1}),("\194\SUB\SYN\139\NUL\NUL\233\RS\226\177\SUB\183\128",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\135\196\232\200\SOHm\GS\194\235\n|\SOH\251\ETB\f7\137\FS\211",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\225\240\SOH \SUB",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),(":1R\165-\228F\219>\136\EOT?\198\224\DC2\129Z\215\250V\188\192\150\220\CAN\185\202\208^",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("A\140\&8\DC4?\EMv\CAN\214\t\FS'\255\208n\209\218\188\140\229o@",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("6\141\148A\161M\182\EM\129\DC4R",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// True, _noLocal = False, _subQoS = QoS2}),("W'\224\128}N\177m\137c.\r!",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\159\&6B~\216U\149-\240\230\194\218\157\166\NAK",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// SubscribeRequest 14432 [("\132\142U\243\225d\SO^\184\204\176\ng\214\232",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\ap\172QO\204\154J[\145n",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\RS\167x\142;=\175\194m}:\128\206\146\&5 PF\224\155",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\168c\156\132\130\233l",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\138\204\153\191\242P(t/<\251\206\247P*\239f",SubOptions {_retainHandling = DoNotSendOnSubscribe, // _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("1\161\160\GS\211\175d\178\213\SOHv\135\171%\155B/\222\FS9(\185g\173\174x_I\224)",SubOptions {_retainHandling -// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropTopicAlias -// 14265,PropAuthenticationData -// "\234\176J\177M{\135\SUB\163~\SUB\158\235\158\179\DEL\173\DC2\191\143\234\aU\214/\134X\t",PropSharedSubscriptionAvailable -// 90,PropMaximumQoS 85,PropRequestProblemInformation 140,PropContentType -// "lJ\161\ETX\FS\175\&1\184\227\140",PropReasonString -// "o\f\162\GS\235H\DEL\195\n\179\133\185\DC3\130\ENQ\158\219z]",PropWillDelayInterval 10700,PropReceiveMaximum 9910] +// QoS2}),("\SOH5\252\ETX\182\137\247D\155\b\175\SO\193\137\fS\148\225\133^a\a\207T\160",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\182\129\173\SUB\239\244",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\ACK\163\NAK\DC1\195\169\246\220\EMt-\224\251\210\190k\170\170\251\193\&0\DC1\208\233\&1\NUL1",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\n\SUB\192\143\n1\SYNu\131\135tm\186\224\200\235IQ4h>0",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("J\166;]\v@\SYNME\249\NAK +// \166\187\168h\EM,\194\193\148mF6\154d}\192",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// True, _noLocal = False, _subQoS = +// QoS1}),("\176\&9\ne\247S\212\228T\157k\157\139P\CAN\DC1\ESC\220\227$\252\ACK\217\192\128\128H\155\174",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropUserProperty +// "\142\218\SUBH\163\ACK\169\148\204M" "\DC2\184j;\156\173\ETB\nU\188\EOT>\207\159\rD\r",PropPayloadFormatIndicator +// 237,PropWildcardSubscriptionAvailable 4,PropSubscriptionIdentifierAvailable 162,PropServerReference +// "\170\DELT6\SOH\168\158\ESCR\253\162\161\132t\192\188+\165\218\t\225\DC4\163B\172",PropSubscriptionIdentifierAvailable +// 175,PropRequestResponseInformation 80,PropResponseInformation "8d",PropRequestProblemInformation +// 63,PropRetainAvailable 48,PropServerKeepAlive 22450,PropReceiveMaximum 14219,PropResponseTopic +// "m\217k\nt7\148(\186~\133\140\245\237J\ENQ",PropUserProperty "" "3\146\248\203m\190`\138\151 +// r\200OT\133\145\ACK\ESC",PropResponseInformation "\RS\FSCx\152aH +// o\153\162\135\&3\246\\\236Q\167\132#\165\139O\161P",PropRequestProblemInformation 165,PropAuthenticationMethod +// "\194a\161\204\182 F\207\229\182E&C",PropMaximumQoS 35,PropAssignedClientIdentifier +// "\151\199\136{B\237\184\233\157~6\157Y\255\163v\161\t:",PropRequestProblemInformation +// 7,PropSharedSubscriptionAvailable 113] TEST(Subscribe5QCTest, Encode10) { uint8_t pkt[] = { - 0x82, 0xbe, 0x2, 0x29, 0xab, 0x53, 0x23, 0x37, 0xb9, 0x16, 0x0, 0x1c, 0xea, 0xb0, 0x4a, 0xb1, 0x4d, 0x7b, 0x87, - 0x1a, 0xa3, 0x7e, 0x1a, 0x9e, 0xeb, 0x9e, 0xb3, 0x7f, 0xad, 0x12, 0xbf, 0x8f, 0xea, 0x7, 0x55, 0xd6, 0x2f, 0x86, - 0x58, 0x9, 0x2a, 0x5a, 0x24, 0x55, 0x17, 0x8c, 0x3, 0x0, 0xa, 0x6c, 0x4a, 0xa1, 0x3, 0x1c, 0xaf, 0x31, 0xb8, - 0xe3, 0x8c, 0x1f, 0x0, 0x13, 0x6f, 0xc, 0xa2, 0x1d, 0xeb, 0x48, 0x7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0xe, 0xc1, 0x89, 0xc, 0x53, 0x94, 0xe1, 0x85, 0x5e, 0x61, 0x7, 0xcf, 0x54, 0xa0, 0x4, 0x0, 0x6, + 0xb6, 0x81, 0xad, 0x1a, 0xef, 0xf4, 0x8, 0x0, 0x1b, 0x6, 0xa3, 0x15, 0x11, 0xc3, 0xa9, 0xf6, 0xdc, 0x19, 0x74, + 0x2d, 0xe0, 0xfb, 0xd2, 0xbe, 0x6b, 0xaa, 0xaa, 0xfb, 0xc1, 0x30, 0x11, 0xd0, 0xe9, 0x31, 0x0, 0x31, 0xa, 0x0, + 0x16, 0xa, 0x1a, 0xc0, 0x8f, 0xa, 0x31, 0x16, 0x75, 0x83, 0x87, 0x74, 0x6d, 0xba, 0xe0, 0xc8, 0xeb, 0x49, 0x51, + 0x34, 0x68, 0x3e, 0x30, 0x16, 0x0, 0x1c, 0x4a, 0xa6, 0x3b, 0x5d, 0xb, 0x40, 0x16, 0x4d, 0x45, 0xf9, 0x15, 0x20, + 0xa6, 0xbb, 0xa8, 0x68, 0x19, 0x2c, 0xc2, 0xc1, 0x94, 0x6d, 0x46, 0x36, 0x9a, 0x64, 0x7d, 0xc0, 0x19, 0x0, 0x1d, + 0xb0, 0x39, 0xa, 0x65, 0xf7, 0x53, 0xd4, 0xe4, 0x54, 0x9d, 0x6b, 0x9d, 0x8b, 0x50, 0x18, 0x11, 0x1b, 0xdc, 0xe3, + 0x24, 0xfc, 0x6, 0xd9, 0xc0, 0x80, 0x80, 0x48, 0x9b, 0xae, 0x6}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x49, 0x99, 0x0, 0xce, 0x86, 0xa3, 0x54, 0xde, 0x56, 0x60, 0x62, 0xe8, 0x49, 0xe8, - 0xfe, 0x75, 0xd5, 0x7d, 0x3d, 0x91, 0xea, 0xc8, 0x24, 0xb7, 0x23, 0x94, 0xb3}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x84, 0x8e, 0x55, 0xf3, 0xe1, 0x64, 0xe, 0x5e, + 0xb8, 0xcc, 0xb0, 0xa, 0x67, 0xd6, 0xe8}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x54, 0x16, 0xb8, 0x2e, 0x35, 0x83, 0x38, 0x72, - 0x27, 0xdd, 0xb8, 0xaa, 0x41, 0x75, 0x4c}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7, 0x70, 0xac, 0x51, 0x4f, 0xcc, 0x9a, 0x4a, 0x5b, 0x91, 0x6e}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc2, 0x1a, 0x16, 0x8b, 0x0, 0x0, 0xe9, 0x1e, 0xe2, 0xb1, 0x1a, 0xb7, 0x80}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1e, 0xa7, 0x78, 0x8e, 0x3b, 0x3d, 0xaf, 0xc2, 0x6d, 0x7d, + 0x3a, 0x80, 0xce, 0x92, 0x35, 0x20, 0x50, 0x46, 0xe0, 0x9b}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x87, 0xc4, 0xe8, 0xc8, 0x1, 0x6d, 0x1d, 0xc2, 0xeb, 0xa, - 0x7c, 0x1, 0xfb, 0x17, 0xc, 0x37, 0x89, 0x1c, 0xd3}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa8, 0x63, 0x9c, 0x84, 0x82, 0xe9, 0x6c}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe1, 0xf0, 0x1, 0x20, 0x1a}; - lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x8a, 0xcc, 0x99, 0xbf, 0xf2, 0x50, 0x28, 0x74, 0x2f, + 0x3c, 0xfb, 0xce, 0xf7, 0x50, 0x2a, 0xef, 0x66}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x3a, 0x31, 0x52, 0xa5, 0x2d, 0xe4, 0x46, 0xdb, 0x3e, 0x88, - 0x4, 0x3f, 0xc6, 0xe0, 0x12, 0x81, 0x5a, 0xd7, 0xfa, 0x56, - 0xbc, 0xc0, 0x96, 0xdc, 0x18, 0xb9, 0xca, 0xd0, 0x5e}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x1, 0x35, 0xfc, 0x3, 0xb6, 0x89, 0xf7, 0x44, 0x9b, 0x8, 0xaf, 0xe, 0xc1, + 0x89, 0xc, 0x53, 0x94, 0xe1, 0x85, 0x5e, 0x61, 0x7, 0xcf, 0x54, 0xa0}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x41, 0x8c, 0x38, 0x14, 0x3f, 0x19, 0x76, 0x18, 0xd6, 0x9, 0x1c, - 0x27, 0xff, 0xd0, 0x6e, 0xd1, 0xda, 0xbc, 0x8c, 0xe5, 0x6f, 0x40}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb6, 0x81, 0xad, 0x1a, 0xef, 0xf4}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x36, 0x8d, 0x94, 0x41, 0xa1, 0x4d, 0xb6, 0x19, 0x81, 0x14, 0x52}; - lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x6, 0xa3, 0x15, 0x11, 0xc3, 0xa9, 0xf6, 0xdc, 0x19, 0x74, 0x2d, 0xe0, 0xfb, 0xd2, + 0xbe, 0x6b, 0xaa, 0xaa, 0xfb, 0xc1, 0x30, 0x11, 0xd0, 0xe9, 0x31, 0x0, 0x31}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x57, 0x27, 0xe0, 0x80, 0x7d, 0x4e, 0xb1, 0x6d, 0x89, 0x63, 0x2e, 0xd, 0x21}; - lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xa, 0x1a, 0xc0, 0x8f, 0xa, 0x31, 0x16, 0x75, 0x83, 0x87, 0x74, + 0x6d, 0xba, 0xe0, 0xc8, 0xeb, 0x49, 0x51, 0x34, 0x68, 0x3e, 0x30}; + lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x9f, 0x36, 0x42, 0x7e, 0xd8, 0x55, 0x95, 0x2d, - 0xf0, 0xe6, 0xc2, 0xda, 0x9d, 0xa6, 0x15}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0x4a, 0xa6, 0x3b, 0x5d, 0xb, 0x40, 0x16, 0x4d, 0x45, 0xf9, + 0x15, 0x20, 0xa6, 0xbb, 0xa8, 0x68, 0x19, 0x2c, 0xc2, 0xc1, + 0x94, 0x6d, 0x46, 0x36, 0x9a, 0x64, 0x7d, 0xc0}; + lwmqtt_string_t topic_filter_s9 = {28, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x31, 0xa1, 0xa0, 0x1d, 0xd3, 0xaf, 0x64, 0xb2, 0xd5, 0x1, - 0x76, 0x87, 0xab, 0x25, 0x9b, 0x42, 0x2f, 0xde, 0x1c, 0x39, - 0x28, 0xb9, 0x67, 0xad, 0xae, 0x78, 0x5f, 0x49, 0xe0, 0x29}; - lwmqtt_string_t topic_filter_s10 = {30, (char*)&topic_filter_s10_bytes}; + uint8_t topic_filter_s10_bytes[] = {0xb0, 0x39, 0xa, 0x65, 0xf7, 0x53, 0xd4, 0xe4, 0x54, 0x9d, + 0x6b, 0x9d, 0x8b, 0x50, 0x18, 0x11, 0x1b, 0xdc, 0xe3, 0x24, + 0xfc, 0x6, 0xd9, 0xc0, 0x80, 0x80, 0x48, 0x9b, 0xae}; + lwmqtt_string_t topic_filter_s10 = {29, (char*)&topic_filter_s10_bytes}; topic_filters[10] = topic_filter_s10; lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; + sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; + sub_opts[6].no_local = false; sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = true; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].qos = LWMQTT_QOS2; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = true; + sub_opts[9].no_local = false; sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[10].retain_as_published = true; - sub_opts[10].no_local = false; - uint8_t bytesprops0[] = {0xea, 0xb0, 0x4a, 0xb1, 0x4d, 0x7b, 0x87, 0x1a, 0xa3, 0x7e, 0x1a, 0x9e, 0xeb, 0x9e, - 0xb3, 0x7f, 0xad, 0x12, 0xbf, 0x8f, 0xea, 0x7, 0x55, 0xd6, 0x2f, 0x86, 0x58, 0x9}; - uint8_t bytesprops1[] = {0x6c, 0x4a, 0xa1, 0x3, 0x1c, 0xaf, 0x31, 0xb8, 0xe3, 0x8c}; - uint8_t bytesprops2[] = {0x6f, 0xc, 0xa2, 0x1d, 0xeb, 0x48, 0x7f, 0xc3, 0xa, 0xb3, - 0x85, 0xb9, 0x13, 0x82, 0x5, 0x9e, 0xdb, 0x7a, 0x5d}; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = true; + uint8_t bytesprops1[] = {0x12, 0xb8, 0x6a, 0x3b, 0x9c, 0xad, 0x17, 0xa, 0x55, + 0xbc, 0x4, 0x3e, 0xcf, 0x9f, 0xd, 0x44, 0xd}; + uint8_t bytesprops0[] = {0x8e, 0xda, 0x1a, 0x48, 0xa3, 0x6, 0xa9, 0x94, 0xcc, 0x4d}; + uint8_t bytesprops2[] = {0xaa, 0x7f, 0x54, 0x36, 0x1, 0xa8, 0x9e, 0x1b, 0x52, 0xfd, 0xa2, 0xa1, 0x84, + 0x74, 0xc0, 0xbc, 0x2b, 0xa5, 0xda, 0x9, 0xe1, 0x14, 0xa3, 0x42, 0xac}; + uint8_t bytesprops3[] = {0x38, 0x64}; + uint8_t bytesprops4[] = {0x6d, 0xd9, 0x6b, 0xa, 0x74, 0x37, 0x94, 0x28, + 0xba, 0x7e, 0x85, 0x8c, 0xf5, 0xed, 0x4a, 0x5}; + uint8_t bytesprops6[] = {0x33, 0x92, 0xf8, 0xcb, 0x6d, 0xbe, 0x60, 0x8a, 0x97, + 0x20, 0x72, 0xc8, 0x4f, 0x54, 0x85, 0x91, 0x6, 0x1b}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops7[] = {0x1e, 0x1c, 0x43, 0x78, 0x98, 0x61, 0x48, 0x20, 0x6f, 0x99, 0xa2, 0x87, 0x33, + 0xf6, 0x5c, 0xec, 0x51, 0xa7, 0x84, 0x23, 0xa5, 0x8b, 0x4f, 0xa1, 0x50}; + uint8_t bytesprops8[] = {0xc2, 0x61, 0xa1, 0xcc, 0xb6, 0x20, 0x46, 0xcf, 0xe5, 0xb6, 0x45, 0x26, 0x43}; + uint8_t bytesprops9[] = {0x97, 0xc7, 0x88, 0x7b, 0x42, 0xed, 0xb8, 0xe9, 0x9d, 0x7e, + 0x36, 0x9d, 0x59, 0xff, 0xa3, 0x76, 0xa1, 0x9, 0x3a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14265}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10700}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9910}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {17, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22450}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14219}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops5}, .v = {18, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 113}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10667, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14432, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 13196 [("\171M\DLE+(\172\SIL\DEL",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\182H\165\138\247\bHO\207\164\ACKr\239\151\ENQ\137\190k\182\&4",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\231~\137\219\155\189\239N\199\208$X\206\145\176Q0\SIv\145\ETX",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\135\&4Dk@\b\247\150\217%:t\198f\195\&4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// True, _noLocal = False, _subQoS = -// QoS2}),("\186,\216\227\251\233`o\219\177\179\DC4\ETB\226\180\143\194\CAN\202\140\&1Y\213\a\ACKq\165^",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] -// [PropReceiveMaximum 2979,PropReceiveMaximum 20597,PropTopicAliasMaximum 24577,PropSharedSubscriptionAvailable -// 21,PropAssignedClientIdentifier "\232\145\174\232\140r\209\DC4H\STX\219\132\229\208",PropUserProperty "\167\&0" -// "\222\SOH[P\215\215]}'\238\223"] +// SubscribeRequest 29362 [("_\243\230\136\DEL\192\SOH\129",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),(")^\224-\RSS\187\132\DLE\157\228F\236\193P/= +// \US\203\163d<\r>\228\239\253\SO\223",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS0}),("d!#X=\180_\191R\DEL\180\224\148\190i\152\228b",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\209\139\ACKUg\\\156\248\"\241\232*\SUB\148\"~\131c\rpq\ENQ\DC3\212\179y\RSX",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("_\231\198F\215\f\226\236\156vQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS0}),("\225_l!\242_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// True, _noLocal = False, _subQoS = QoS0})] [PropSessionExpiryInterval 17671,PropPayloadFormatIndicator +// 109,PropReceiveMaximum 31944,PropMaximumQoS 115,PropAuthenticationMethod +// "AG\157\204\\\192q\186\177W\175=",PropSubscriptionIdentifierAvailable 57,PropSessionExpiryInterval +// 1970,PropTopicAliasMaximum 24957,PropCorrelationData +// "\217\180\148\160\CANiA\220z\140\188g*Oy\170\&2\230;\"\166\178\NUL\217\219<",PropAuthenticationMethod +// "7\SI",PropServerReference "\231\247\170\t\EM"] TEST(Subscribe5QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0x9e, 0x1, 0x33, 0x8c, 0x2e, 0x21, 0xb, 0xa3, 0x21, 0x50, 0x75, 0x22, 0x60, 0x1, 0x2a, 0x15, - 0x12, 0x0, 0xe, 0xe8, 0x91, 0xae, 0xe8, 0x8c, 0x72, 0xd1, 0x14, 0x48, 0x2, 0xdb, 0x84, 0xe5, 0xd0, - 0x26, 0x0, 0x2, 0xa7, 0x30, 0x0, 0xb, 0xde, 0x1, 0x5b, 0x50, 0xd7, 0xd7, 0x5d, 0x7d, 0x27, 0xee, - 0xdf, 0x0, 0x9, 0xab, 0x4d, 0x10, 0x2b, 0x28, 0xac, 0xf, 0x4c, 0x7f, 0x2a, 0x0, 0x14, 0xb6, 0x48, - 0xa5, 0x8a, 0xf7, 0x8, 0x48, 0x4f, 0xcf, 0xa4, 0x6, 0x72, 0xef, 0x97, 0x5, 0x89, 0xbe, 0x6b, 0xb6, - 0x34, 0x1a, 0x0, 0x15, 0xe7, 0x7e, 0x89, 0xdb, 0x9b, 0xbd,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cb, 0xa3, + 0x64, 0x3c, 0xd, 0x3e, 0xe4, 0xef, 0xfd, 0xe, 0xdf, 0x2c, 0x0, 0x12, 0x64, 0x21, 0x23, 0x58, 0x3d, + 0xb4, 0x5f, 0xbf, 0x52, 0x7f, 0xb4, 0xe0, 0x94, 0xbe, 0x69, 0x98, 0xe4, 0x62, 0x9, 0x0, 0x1c, 0xd1, + 0x8b, 0x6, 0x55, 0x67, 0x5c, 0x9c, 0xf8, 0x22, 0xf1, 0xe8, 0x2a, 0x1a, 0x94, 0x22, 0x7e, 0x83, 0x63, + 0xd, 0x70, 0x71, 0x5, 0x13, 0xd4, 0xb3, 0x79, 0x1e, 0x58, 0x1c, 0x0, 0xb, 0x5f, 0xe7, 0xc6, 0x46, + 0xd7, 0xc, 0xe2, 0xec, 0x9c, 0x76, 0x51, 0x4, 0x0, 0x6, 0xe1, 0x5f, 0x6c, 0x21, 0xf2, 0x5f, 0x8}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xab, 0x4d, 0x10, 0x2b, 0x28, 0xac, 0xf, 0x4c, 0x7f}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x5f, 0xf3, 0xe6, 0x88, 0x7f, 0xc0, 0x1, 0x81}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb6, 0x48, 0xa5, 0x8a, 0xf7, 0x8, 0x48, 0x4f, 0xcf, 0xa4, - 0x6, 0x72, 0xef, 0x97, 0x5, 0x89, 0xbe, 0x6b, 0xb6, 0x34}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x29, 0x5e, 0xe0, 0x2d, 0x1e, 0x53, 0xbb, 0x84, 0x10, 0x9d, + 0xe4, 0x46, 0xec, 0xc1, 0x50, 0x2f, 0x3d, 0x20, 0x1f, 0xcb, + 0xa3, 0x64, 0x3c, 0xd, 0x3e, 0xe4, 0xef, 0xfd, 0xe, 0xdf}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe7, 0x7e, 0x89, 0xdb, 0x9b, 0xbd, 0xef, 0x4e, 0xc7, 0xd0, 0x24, - 0x58, 0xce, 0x91, 0xb0, 0x51, 0x30, 0xf, 0x76, 0x91, 0x3}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x64, 0x21, 0x23, 0x58, 0x3d, 0xb4, 0x5f, 0xbf, 0x52, + 0x7f, 0xb4, 0xe0, 0x94, 0xbe, 0x69, 0x98, 0xe4, 0x62}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x87, 0x34, 0x44, 0x6b, 0x40, 0x8, 0xf7, 0x96, - 0xd9, 0x25, 0x3a, 0x74, 0xc6, 0x66, 0xc3, 0x34}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd1, 0x8b, 0x6, 0x55, 0x67, 0x5c, 0x9c, 0xf8, 0x22, 0xf1, + 0xe8, 0x2a, 0x1a, 0x94, 0x22, 0x7e, 0x83, 0x63, 0xd, 0x70, + 0x71, 0x5, 0x13, 0xd4, 0xb3, 0x79, 0x1e, 0x58}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xba, 0x2c, 0xd8, 0xe3, 0xfb, 0xe9, 0x60, 0x6f, 0xdb, 0xb1, - 0xb3, 0x14, 0x17, 0xe2, 0xb4, 0x8f, 0xc2, 0x18, 0xca, 0x8c, - 0x31, 0x59, 0xd5, 0x7, 0x6, 0x71, 0xa5, 0x5e}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x5f, 0xe7, 0xc6, 0x46, 0xd7, 0xc, 0xe2, 0xec, 0x9c, 0x76, 0x51}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s5_bytes[] = {0xe1, 0x5f, 0x6c, 0x21, 0xf2, 0x5f}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; + sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - uint8_t bytesprops0[] = {0xe8, 0x91, 0xae, 0xe8, 0x8c, 0x72, 0xd1, 0x14, 0x48, 0x2, 0xdb, 0x84, 0xe5, 0xd0}; - uint8_t bytesprops2[] = {0xde, 0x1, 0x5b, 0x50, 0xd7, 0xd7, 0x5d, 0x7d, 0x27, 0xee, 0xdf}; - uint8_t bytesprops1[] = {0xa7, 0x30}; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + uint8_t bytesprops0[] = {0x41, 0x47, 0x9d, 0xcc, 0x5c, 0xc0, 0x71, 0xba, 0xb1, 0x57, 0xaf, 0x3d}; + uint8_t bytesprops1[] = {0xd9, 0xb4, 0x94, 0xa0, 0x18, 0x69, 0x41, 0xdc, 0x7a, 0x8c, 0xbc, 0x67, 0x2a, + 0x4f, 0x79, 0xaa, 0x32, 0xe6, 0x3b, 0x22, 0xa6, 0xb2, 0x0, 0xd9, 0xdb, 0x3c}; + uint8_t bytesprops2[] = {0x37, 0xf}; + uint8_t bytesprops3[] = {0xe7, 0xf7, 0xaa, 0x9, 0x19}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2979}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20597}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24577}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17671}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31944}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1970}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24957}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13196, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29362, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11145 [("\237\a\171\195\220\245\232@\229P\146~C\193\193\139\138\EOTF\139\ACK\135\ETX\253",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] -// [PropMessageExpiryInterval 3734,PropMaximumPacketSize 5015] +// SubscribeRequest 18382 +// [("\231\EM\193\193q\251\CAN\154\SYN\230\146\204c_\141w\148\DC3\215\RS!\ETXw\186x$n\182\231",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] +// [PropReasonString "\CANB\238hj\224\196'\158a\212\187\182@\252R\213t\232\172\160t",PropUserProperty +// "\134\SI)\190\160|\ETB\191L\190\230+\223\&7\165" "M\233\USZ\246\&7",PropWildcardSubscriptionAvailable +// 232,PropUserProperty "\GS\137\251W\186\DC2o" "\175!9x!",PropPayloadFormatIndicator 19,PropAuthenticationMethod +// "\155\207l_\130\157\153\NAK?\212(I\CAN\202\134NwZ\DC4\251",PropCorrelationData +// "<\133j\146\US%\245\222&u",PropSharedSubscriptionAvailable 232,PropCorrelationData +// "\192\182W\226\171\177^\223\192rK{\149\227\220",PropSubscriptionIdentifier 1,PropServerReference +// "",PropSubscriptionIdentifier 3,PropSubscriptionIdentifier 8,PropAssignedClientIdentifier +// "L-\191e\216",PropWillDelayInterval 25674,PropMessageExpiryInterval 17484,PropSessionExpiryInterval +// 4335,PropResponseTopic "~\ACK\DC3\218\190\SUB\195C\248t(!q\230/\238h\205\218\254\214",PropMessageExpiryInterval +// 2322,PropTopicAlias 2796,PropRequestProblemInformation 232,PropMaximumQoS 9,PropRequestResponseInformation +// 65,PropTopicAlias 26821,PropAssignedClientIdentifier +// "R\240a\227\151\225QM\213G\197\199*9\226\DEL\197\170\202\213J@\142&(\204",PropTopicAlias +// 9265,PropWildcardSubscriptionAvailable 53] TEST(Subscribe5QCTest, Encode12) { - uint8_t pkt[] = {0x82, 0x28, 0x2b, 0x89, 0xa, 0x2, 0x0, 0x0, 0xe, 0x96, 0x27, 0x0, 0x0, 0x13, - 0x97, 0x0, 0x18, 0xed, 0x7, 0xab, 0xc3, 0xdc, 0xf5, 0xe8, 0x40, 0xe5, 0x50, 0x92, - 0x7e, 0x43, 0xc1, 0xc1, 0x8b, 0x8a, 0x4, 0x46, 0x8b, 0x6, 0x87, 0x3, 0xfd, 0x26}; + uint8_t pkt[] = { + 0x82, 0x8f, 0x2, 0x47, 0xce, 0xeb, 0x1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x9, 0x12, 0x23, 0xa, 0xec, 0x17, 0xe8, 0x24, 0x9, 0x19, 0x41, 0x23, 0x68, 0xc5, 0x12, + 0x0, 0x1a, 0x52, 0xf0, 0x61, 0xe3, 0x97, 0xe1, 0x51, 0x4d, 0xd5, 0x47, 0xc5, 0xc7, 0x2a, 0x39, 0xe2, 0x7f, 0xc5, + 0xaa, 0xca, 0xd5, 0x4a, 0x40, 0x8e, 0x26, 0x28, 0xcc, 0x23, 0x24, 0x31, 0x28, 0x35, 0x0, 0x1d, 0xe7, 0x19, 0xc1, + 0xc1, 0x71, 0xfb, 0x18, 0x9a, 0x16, 0xe6, 0x92, 0xcc, 0x63, 0x5f, 0x8d, 0x77, 0x94, 0x13, 0xd7, 0x1e, 0x21, 0x3, + 0x77, 0xba, 0x78, 0x24, 0x6e, 0xb6, 0xe7, 0x1e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x7, 0xab, 0xc3, 0xdc, 0xf5, 0xe8, 0x40, 0xe5, 0x50, 0x92, 0x7e, - 0x43, 0xc1, 0xc1, 0x8b, 0x8a, 0x4, 0x46, 0x8b, 0x6, 0x87, 0x3, 0xfd}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xe7, 0x19, 0xc1, 0xc1, 0x71, 0xfb, 0x18, 0x9a, 0x16, 0xe6, + 0x92, 0xcc, 0x63, 0x5f, 0x8d, 0x77, 0x94, 0x13, 0xd7, 0x1e, + 0x21, 0x3, 0x77, 0xba, 0x78, 0x24, 0x6e, 0xb6, 0xe7}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; lwmqtt_sub_options_t sub_opts[1]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; + uint8_t bytesprops0[] = {0x18, 0x42, 0xee, 0x68, 0x6a, 0xe0, 0xc4, 0x27, 0x9e, 0x61, 0xd4, + 0xbb, 0xb6, 0x40, 0xfc, 0x52, 0xd5, 0x74, 0xe8, 0xac, 0xa0, 0x74}; + uint8_t bytesprops2[] = {0x4d, 0xe9, 0x1f, 0x5a, 0xf6, 0x37}; + uint8_t bytesprops1[] = {0x86, 0xf, 0x29, 0xbe, 0xa0, 0x7c, 0x17, 0xbf, 0x4c, 0xbe, 0xe6, 0x2b, 0xdf, 0x37, 0xa5}; + uint8_t bytesprops4[] = {0xaf, 0x21, 0x39, 0x78, 0x21}; + uint8_t bytesprops3[] = {0x1d, 0x89, 0xfb, 0x57, 0xba, 0x12, 0x6f}; + uint8_t bytesprops5[] = {0x9b, 0xcf, 0x6c, 0x5f, 0x82, 0x9d, 0x99, 0x15, 0x3f, 0xd4, + 0x28, 0x49, 0x18, 0xca, 0x86, 0x4e, 0x77, 0x5a, 0x14, 0xfb}; + uint8_t bytesprops6[] = {0x3c, 0x85, 0x6a, 0x92, 0x1f, 0x25, 0xf5, 0xde, 0x26, 0x75}; + uint8_t bytesprops7[] = {0xc0, 0xb6, 0x57, 0xe2, 0xab, 0xb1, 0x5e, 0xdf, 0xc0, 0x72, 0x4b, 0x7b, 0x95, 0xe3, 0xdc}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0x4c, 0x2d, 0xbf, 0x65, 0xd8}; + uint8_t bytesprops10[] = {0x7e, 0x6, 0x13, 0xda, 0xbe, 0x1a, 0xc3, 0x43, 0xf8, 0x74, 0x28, + 0x21, 0x71, 0xe6, 0x2f, 0xee, 0x68, 0xcd, 0xda, 0xfe, 0xd6}; + uint8_t bytesprops11[] = {0x52, 0xf0, 0x61, 0xe3, 0x97, 0xe1, 0x51, 0x4d, 0xd5, 0x47, 0xc5, 0xc7, 0x2a, + 0x39, 0xe2, 0x7f, 0xc5, 0xaa, 0xca, 0xd5, 0x4a, 0x40, 0x8e, 0x26, 0x28, 0xcc}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3734}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5015}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25674}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17484}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4335}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2322}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2796}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26821}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9265}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 53}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11145, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18382, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22549 -// [("q&N\176\217\FS\143\140\217\b\164\171\163\233\237\200\214\223\156\197\201\182e\DC3q",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\251N<\255g\164",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\236\US\180\241\219\242\200\196\229J\244\135\&7]\225L\136\132\213\128\&8\252\234\US\157\230k\NAK}g",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\157FH\237\157\&9\207X2\190\240\162\239\164",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropSharedSubscriptionAvailable -// 37,PropSharedSubscriptionAvailable 153,PropSessionExpiryInterval 29426,PropMessageExpiryInterval -// 23723,PropMessageExpiryInterval 8643,PropSessionExpiryInterval 10393,PropPayloadFormatIndicator 48,PropResponseTopic -// "t\227\219\204E\144=*n\DEL",PropReasonString -// "\219\209\ETB\SOH\GS\161\150\221\175\DC3\213\199\131\DEL\235\190_vaZ\218\128\155\209\&9\137",PropResponseInformation -// "\155\136\CAN ^\222\SUBH\187\128\n\150\238_\192",PropRequestResponseInformation 164,PropServerKeepAlive -// 1216,PropSubscriptionIdentifier 23,PropServerKeepAlive 24368,PropSessionExpiryInterval 2690,PropSessionExpiryInterval -// 28694,PropMessageExpiryInterval 21697,PropRetainAvailable 56,PropMessageExpiryInterval 31144,PropAuthenticationMethod -// "",PropReceiveMaximum 10744,PropTopicAlias 16979,PropReasonString -// "\253\vH\234\142\163o\193\150\192\158\157\241\221\200",PropTopicAlias 11000] +// SubscribeRequest 3280 [("\252\153?\GSp",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("_\132\USe\201\201\207X\SI%\DC4\188n<\231p\ACK{\157\165\215\142\182\165\234\137\&6u",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\\3\146\160\169\t\156\ENQ\193$\238\197jL\b\216\252\216",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\ETX\240",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\a;J7U.\178\156\&8d\196\SO$\145\224\131Y\200\&2+;l",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("E\177t%H\185\EOTxHjzc\212\174}XI\SYNBe*\SOH\249Q6R\NUL-",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropRetainAvailable 175,PropAuthenticationData +// "\USv~\243c,\215\v\DC1\f6\144Fq\DC4\139\155\221\176s\STX)v\240",PropWildcardSubscriptionAvailable +// 10,PropRequestProblemInformation 16,PropCorrelationData "?}\242\DLE\167c\144\DEL\EOT\156j\153\147\136\225 +// l\SOH\217\193\172\ETBH\v\DLE\192\ACK\246",PropMaximumPacketSize 3641,PropReasonString +// "\186\162n\130\150\147\146D\211E\181\230C\128\128?\248\209G\153\246\208\197\n\213PJ\SUB\156\201",PropWildcardSubscriptionAvailable +// 100,PropSubscriptionIdentifier 7,PropUserProperty "\NUL\246\DLEZWL-\NAK,4\169[C\128[\163k\200" +// "\188V\202\176h\CAN\165\200\GS$TP|\171kc\199\191-\ACK\233\231.5\235[\197i\158\138",PropRetainAvailable +// 77,PropRequestProblemInformation 176] TEST(Subscribe5QCTest, Encode13) { uint8_t pkt[] = { - 0x82, 0xef, 0x1, 0x58, 0x15, 0x94, 0x1, 0x2a, 0x25, 0x2a, 0x99, 0x11, 0x0, 0x0, 0x72, 0xf2, 0x2, 0x0, 0x0, - 0x5c, 0xab, 0x2, 0x0, 0x0, 0x21, 0xc3, 0x11, 0x0, 0x0, 0x28, 0x99, 0x1, 0x30, 0x8, 0x0, 0xa, 0x74, 0xe3, - 0xdb, 0xcc, 0x45, 0x90, 0x3d, 0x2a, 0x6e, 0x7f, 0x1f, 0x0, 0x1a, 0xdb, 0xd1, 0x17, 0x1, 0x1d, 0xa1, 0x96, 0xdd, - 0xaf, 0x13, 0xd5, 0xc7, 0x83, 0x7f, 0xeb, 0xbe, 0x5f, 0x76, 0x61, 0x5a, 0xda, 0x80, 0x9b, 0xd1, 0x39, 0x89, 0x1a, - 0x0, 0xf, 0x9b, 0x88, 0x18, 0x20, 0x5e, 0xde, 0x1a, 0x48, 0xbb, 0x80, 0xa, 0x96, 0xee, 0x5f, 0xc0, 0x19, 0xa4, - 0x13, 0x4, 0xc0, 0xb, 0x17, 0x13, 0x5f, 0x30, 0x11, 0x0, 0x0, 0xa, 0x82, 0x11, 0x0, 0x0, 0x70, 0x16, 0x2,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0x55, 0x2e, 0xb2, 0x9c, 0x38, 0x64, + 0xc4, 0xe, 0x24, 0x91, 0xe0, 0x83, 0x59, 0xc8, 0x32, 0x2b, 0x3b, 0x6c, 0x2a, 0x0, 0x1c, 0x45, 0xb1, 0x74, 0x25, + 0x48, 0xb9, 0x4, 0x78, 0x48, 0x6a, 0x7a, 0x63, 0xd4, 0xae, 0x7d, 0x58, 0x49, 0x16, 0x42, 0x65, 0x2a, 0x1, 0xf9, + 0x51, 0x36, 0x52, 0x0, 0x2d, 0x1e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x71, 0x26, 0x4e, 0xb0, 0xd9, 0x1c, 0x8f, 0x8c, 0xd9, 0x8, 0xa4, 0xab, 0xa3, - 0xe9, 0xed, 0xc8, 0xd6, 0xdf, 0x9c, 0xc5, 0xc9, 0xb6, 0x65, 0x13, 0x71}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xfc, 0x99, 0x3f, 0x1d, 0x70}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfb, 0x4e, 0x3c, 0xff, 0x67, 0xa4}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5f, 0x84, 0x1f, 0x65, 0xc9, 0xc9, 0xcf, 0x58, 0xf, 0x25, + 0x14, 0xbc, 0x6e, 0x3c, 0xe7, 0x70, 0x6, 0x7b, 0x9d, 0xa5, + 0xd7, 0x8e, 0xb6, 0xa5, 0xea, 0x89, 0x36, 0x75}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xec, 0x1f, 0xb4, 0xf1, 0xdb, 0xf2, 0xc8, 0xc4, 0xe5, 0x4a, - 0xf4, 0x87, 0x37, 0x5d, 0xe1, 0x4c, 0x88, 0x84, 0xd5, 0x80, - 0x38, 0xfc, 0xea, 0x1f, 0x9d, 0xe6, 0x6b, 0x15, 0x7d, 0x67}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5c, 0x33, 0x92, 0xa0, 0xa9, 0x9, 0x9c, 0x5, 0xc1, + 0x24, 0xee, 0xc5, 0x6a, 0x4c, 0x8, 0xd8, 0xfc, 0xd8}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9d, 0x46, 0x48, 0xed, 0x9d, 0x39, 0xcf, - 0x58, 0x32, 0xbe, 0xf0, 0xa2, 0xef, 0xa4}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3, 0xf0}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + uint8_t topic_filter_s4_bytes[] = {0x7, 0x3b, 0x4a, 0x37, 0x55, 0x2e, 0xb2, 0x9c, 0x38, 0x64, 0xc4, + 0xe, 0x24, 0x91, 0xe0, 0x83, 0x59, 0xc8, 0x32, 0x2b, 0x3b, 0x6c}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x45, 0xb1, 0x74, 0x25, 0x48, 0xb9, 0x4, 0x78, 0x48, 0x6a, + 0x7a, 0x63, 0xd4, 0xae, 0x7d, 0x58, 0x49, 0x16, 0x42, 0x65, + 0x2a, 0x1, 0xf9, 0x51, 0x36, 0x52, 0x0, 0x2d}; + lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; - uint8_t bytesprops0[] = {0x74, 0xe3, 0xdb, 0xcc, 0x45, 0x90, 0x3d, 0x2a, 0x6e, 0x7f}; - uint8_t bytesprops1[] = {0xdb, 0xd1, 0x17, 0x1, 0x1d, 0xa1, 0x96, 0xdd, 0xaf, 0x13, 0xd5, 0xc7, 0x83, - 0x7f, 0xeb, 0xbe, 0x5f, 0x76, 0x61, 0x5a, 0xda, 0x80, 0x9b, 0xd1, 0x39, 0x89}; - uint8_t bytesprops2[] = {0x9b, 0x88, 0x18, 0x20, 0x5e, 0xde, 0x1a, 0x48, 0xbb, 0x80, 0xa, 0x96, 0xee, 0x5f, 0xc0}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0xfd, 0xb, 0x48, 0xea, 0x8e, 0xa3, 0x6f, 0xc1, 0x96, 0xc0, 0x9e, 0x9d, 0xf1, 0xdd, 0xc8}; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + uint8_t bytesprops0[] = {0x1f, 0x76, 0x7e, 0xf3, 0x63, 0x2c, 0xd7, 0xb, 0x11, 0xc, 0x36, 0x90, + 0x46, 0x71, 0x14, 0x8b, 0x9b, 0xdd, 0xb0, 0x73, 0x2, 0x29, 0x76, 0xf0}; + uint8_t bytesprops1[] = {0x3f, 0x7d, 0xf2, 0x10, 0xa7, 0x63, 0x90, 0x7f, 0x4, 0x9c, 0x6a, 0x99, 0x93, 0x88, + 0xe1, 0x20, 0x6c, 0x1, 0xd9, 0xc1, 0xac, 0x17, 0x48, 0xb, 0x10, 0xc0, 0x6, 0xf6}; + uint8_t bytesprops2[] = {0xba, 0xa2, 0x6e, 0x82, 0x96, 0x93, 0x92, 0x44, 0xd3, 0x45, 0xb5, 0xe6, 0x43, 0x80, 0x80, + 0x3f, 0xf8, 0xd1, 0x47, 0x99, 0xf6, 0xd0, 0xc5, 0xa, 0xd5, 0x50, 0x4a, 0x1a, 0x9c, 0xc9}; + uint8_t bytesprops4[] = {0xbc, 0x56, 0xca, 0xb0, 0x68, 0x18, 0xa5, 0xc8, 0x1d, 0x24, 0x54, 0x50, 0x7c, 0xab, 0x6b, + 0x63, 0xc7, 0xbf, 0x2d, 0x6, 0xe9, 0xe7, 0x2e, 0x35, 0xeb, 0x5b, 0xc5, 0x69, 0x9e, 0x8a}; + uint8_t bytesprops3[] = {0x0, 0xf6, 0x10, 0x5a, 0x57, 0x4c, 0x2d, 0x15, 0x2c, + 0x34, 0xa9, 0x5b, 0x43, 0x80, 0x5b, 0xa3, 0x6b, 0xc8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29426}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23723}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8643}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10393}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1216}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 23}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24368}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2690}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28694}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21697}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31144}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10744}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16979}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11000}}, - }; + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3641}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops3}, .v = {30, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 176}}, + }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22549, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3280, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18393 [("{\US\242",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS0}),("\201=\vz\142\EOT\237}\162$\ETXL\232c\RS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\247y\217\183\158j\243\153\130ub\232\193\210\DC4lt\EOTGRnv",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("8\140\&6\235T\162\129K\250\154E\163q\165\161\233\218\239\191\198%\208\222",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\167",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling -// = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\138)\154\144@\221\174\188\n\143\197\159E6\191\149\251",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("Vi\140c:I\156\DEL\172\220A\GS9zg\167",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\193\198\250h\138\172\219di\163g\DC3\186`\129\162\202w\171\252",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty -// "\DLE\254\218\246s\229\a\NAK\225k\164" -// "?\246\177\148'$\135\STX\161EI}\US\128\b\224\171e\213E\139YvT\216\204\&2",PropSubscriptionIdentifier -// 21,PropSubscriptionIdentifierAvailable 204,PropSharedSubscriptionAvailable 55,PropRequestProblemInformation -// 165,PropRequestProblemInformation 55,PropServerKeepAlive 19127,PropAuthenticationData -// "S\DELtZ%y\190^5\186\US\FS_",PropCorrelationData -// "D(\DC1\160\136\166\b\SYN{[\231t\133\181\128\183\160s\DEL\EOT\STX\200\167\206"] +// SubscribeRequest 4639 [("\165\EM\DC2g\NUL",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\ESCH\249\163F",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\203\206z\136",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\156`s_",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty +// "+G\189" "\DC1\FS\216\210;\145\164)\NUL\226^\147\141\DC3\254f",PropRequestResponseInformation +// 121,PropWildcardSubscriptionAvailable 148,PropRetainAvailable 5,PropRequestProblemInformation +// 249,PropAuthenticationMethod "\213q@H\255\190o}\213K\132\141",PropTopicAlias 2644,PropUserProperty " " +// "\r\157]J\153\172\135",PropAuthenticationMethod "\148\199\SOH|\192G\223U\251\232",PropMessageExpiryInterval 24483] TEST(Subscribe5QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0xf6, 0x1, 0x47, 0xd9, 0x63, 0x26, 0x0, 0xb, 0x10, 0xfe, 0xda, 0xf6, 0x73, 0xe5, 0x7, 0x15, - 0xe1, 0x6b, 0xa4, 0x0, 0x1b, 0x3f, 0xf6, 0xb1, 0x94, 0x27, 0x24, 0x87, 0x2, 0xa1, 0x45, 0x49, 0x7d, - 0x1f, 0x80, 0x8, 0xe0, 0xab, 0x65, 0xd5, 0x45, 0x8b, 0x59, 0x76, 0x54, 0xd8, 0xcc, 0x32, 0xb, 0x15, - 0x29, 0xcc, 0x2a, 0x37, 0x17, 0xa5, 0x17, 0x37, 0x13, 0x4a, 0xb7, 0x16, 0x0, 0xd, 0x53, 0x7f, 0x74, - 0x5a, 0x25, 0x79, 0xbe, 0x5e, 0x35, 0xba, 0x1f, 0x1c, 0x5f, 0x9, 0x0, 0x18, 0x44, 0x28, 0x11, 0xa0, - 0x88, 0xa6, 0x8, 0x16, 0x7b, 0x5b, 0xe7, 0x74, 0x85, 0xb5, 0x80, 0xb7, 0xa0, 0x73, 0x7f, 0x4, 0x2, - 0xc8, 0xa7, 0xce, 0x0, 0x3, 0x7b, 0x1f, 0xf2, 0x28, 0x0, 0xf, 0xc9, 0x3d, 0xb, 0x7a, 0x8e, 0x4, - 0xed, 0x7d, 0xa2, 0x24, 0x3, 0x4c, 0xe8, 0x63, 0x1e, 0x2, 0x0, 0x16, 0xf7, 0x79, 0xd9, 0xb7, 0x9e, - 0x6a, 0xf3, 0x99, 0x82, 0x75, 0x62, 0xe8, 0xc1, 0xd2, 0x14, 0x6c, 0x74, 0x4, 0x47, 0x52, 0x6e, 0x76, - 0x29, 0x0, 0x17, 0x38, 0x8c, 0x36, 0xeb, 0x54, 0xa2, 0x81, 0x4b, 0xfa, 0x9a, 0x45, 0xa3, 0x71, 0xa5, - 0xa1, 0xe9, 0xda, 0xef, 0xbf, 0xc6, 0x25, 0xd0, 0xde, 0xe, 0x0, 0x1, 0xa7, 0x20, 0x0, 0x0, 0x28, - 0x0, 0x11, 0x8a, 0x29, 0x9a, 0x90, 0x40, 0xdd, 0xae, 0xbc, 0xa, 0x8f, 0xc5, 0x9f, 0x45, 0x36, 0xbf, - 0x95, 0xfb, 0x18, 0x0, 0x10, 0x56, 0x69, 0x8c, 0x63, 0x3a, 0x49, 0x9c, 0x7f, 0xac, 0xdc, 0x41, 0x1d, - 0x39, 0x7a, 0x67, 0xa7, 0x1, 0x0, 0x14, 0xc1, 0xc6, 0xfa, 0x68, 0x8a, 0xac, 0xdb, 0x64, 0x69, 0xa3, - 0x67, 0x13, 0xba, 0x60, 0x81, 0xa2, 0xca, 0x77, 0xab, 0xfc, 0x11}; + uint8_t pkt[] = {0x82, 0x72, 0x12, 0x1f, 0x51, 0x26, 0x0, 0x3, 0x2b, 0x47, 0xbd, 0x0, 0x10, 0x11, 0x1c, 0xd8, 0xd2, + 0x3b, 0x91, 0xa4, 0x29, 0x0, 0xe2, 0x5e, 0x93, 0x8d, 0x13, 0xfe, 0x66, 0x19, 0x79, 0x28, 0x94, 0x25, + 0x5, 0x17, 0xf9, 0x15, 0x0, 0xc, 0xd5, 0x71, 0x40, 0x48, 0xff, 0xbe, 0x6f, 0x7d, 0xd5, 0x4b, 0x84, + 0x8d, 0x23, 0xa, 0x54, 0x26, 0x0, 0x1, 0x20, 0x0, 0x7, 0xd, 0x9d, 0x5d, 0x4a, 0x99, 0xac, 0x87, + 0x15, 0x0, 0xa, 0x94, 0xc7, 0x1, 0x7c, 0xc0, 0x47, 0xdf, 0x55, 0xfb, 0xe8, 0x2, 0x0, 0x0, 0x5f, + 0xa3, 0x0, 0x5, 0xa5, 0x19, 0x12, 0x67, 0x0, 0x22, 0x0, 0x5, 0x1b, 0x48, 0xf9, 0xa3, 0x46, 0x11, + 0x0, 0x4, 0xcb, 0xce, 0x7a, 0x88, 0x2d, 0x0, 0x4, 0x9c, 0x60, 0x73, 0x5f, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x7b, 0x1f, 0xf2}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xa5, 0x19, 0x12, 0x67, 0x0}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc9, 0x3d, 0xb, 0x7a, 0x8e, 0x4, 0xed, 0x7d, - 0xa2, 0x24, 0x3, 0x4c, 0xe8, 0x63, 0x1e}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1b, 0x48, 0xf9, 0xa3, 0x46}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf7, 0x79, 0xd9, 0xb7, 0x9e, 0x6a, 0xf3, 0x99, 0x82, 0x75, 0x62, - 0xe8, 0xc1, 0xd2, 0x14, 0x6c, 0x74, 0x4, 0x47, 0x52, 0x6e, 0x76}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xcb, 0xce, 0x7a, 0x88}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x38, 0x8c, 0x36, 0xeb, 0x54, 0xa2, 0x81, 0x4b, 0xfa, 0x9a, 0x45, 0xa3, - 0x71, 0xa5, 0xa1, 0xe9, 0xda, 0xef, 0xbf, 0xc6, 0x25, 0xd0, 0xde}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9c, 0x60, 0x73, 0x5f}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa7}; - lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8a, 0x29, 0x9a, 0x90, 0x40, 0xdd, 0xae, 0xbc, 0xa, - 0x8f, 0xc5, 0x9f, 0x45, 0x36, 0xbf, 0x95, 0xfb}; - lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x56, 0x69, 0x8c, 0x63, 0x3a, 0x49, 0x9c, 0x7f, - 0xac, 0xdc, 0x41, 0x1d, 0x39, 0x7a, 0x67, 0xa7}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc1, 0xc6, 0xfa, 0x68, 0x8a, 0xac, 0xdb, 0x64, 0x69, 0xa3, - 0x67, 0x13, 0xba, 0x60, 0x81, 0xa2, 0xca, 0x77, 0xab, 0xfc}; - lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - uint8_t bytesprops1[] = {0x3f, 0xf6, 0xb1, 0x94, 0x27, 0x24, 0x87, 0x2, 0xa1, 0x45, 0x49, 0x7d, 0x1f, 0x80, - 0x8, 0xe0, 0xab, 0x65, 0xd5, 0x45, 0x8b, 0x59, 0x76, 0x54, 0xd8, 0xcc, 0x32}; - uint8_t bytesprops0[] = {0x10, 0xfe, 0xda, 0xf6, 0x73, 0xe5, 0x7, 0x15, 0xe1, 0x6b, 0xa4}; - uint8_t bytesprops2[] = {0x53, 0x7f, 0x74, 0x5a, 0x25, 0x79, 0xbe, 0x5e, 0x35, 0xba, 0x1f, 0x1c, 0x5f}; - uint8_t bytesprops3[] = {0x44, 0x28, 0x11, 0xa0, 0x88, 0xa6, 0x8, 0x16, 0x7b, 0x5b, 0xe7, 0x74, - 0x85, 0xb5, 0x80, 0xb7, 0xa0, 0x73, 0x7f, 0x4, 0x2, 0xc8, 0xa7, 0xce}; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + uint8_t bytesprops1[] = {0x11, 0x1c, 0xd8, 0xd2, 0x3b, 0x91, 0xa4, 0x29, + 0x0, 0xe2, 0x5e, 0x93, 0x8d, 0x13, 0xfe, 0x66}; + uint8_t bytesprops0[] = {0x2b, 0x47, 0xbd}; + uint8_t bytesprops2[] = {0xd5, 0x71, 0x40, 0x48, 0xff, 0xbe, 0x6f, 0x7d, 0xd5, 0x4b, 0x84, 0x8d}; + uint8_t bytesprops4[] = {0xd, 0x9d, 0x5d, 0x4a, 0x99, 0xac, 0x87}; + uint8_t bytesprops3[] = {0x20}; + uint8_t bytesprops5[] = {0x94, 0xc7, 0x1, 0x7c, 0xc0, 0x47, 0xdf, 0x55, 0xfb, 0xe8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {27, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19127}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2644}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops3}, .v = {7, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24483}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18393, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4639, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28507 [("\146\199\232\fj\226d",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("*\213\134P\169\&0S\207\229-\255G\158",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\226\203\183\nO\231\151\nD\225\208!\169N\166\228\220#\DC2WU\SI",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\251\t\179",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("~\144J\231\"6\CAN\145#\205z]\ETXUK\212\&7\145\EOT\176\252\SO",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("a&xM$\210\&9\179\194\SI\232\178-s\215;\DC3E\193\184\RS\SOH\177:S\170\ESC\167\158\220",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\243L\171r:\136\128\t\nV1@\206",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\152\178\CAN\175Q\229h\DC19I\201\190>\230\164\181\242q51",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\176O\235\183\144\ETX\224\ACK\173\237*\DLE\129\NUL\CAN\151",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\210\189\SI\243c",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\164\176\159\168\229\233v\159\v\223\227\158\207\190\216\187\203Z",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropTopicAlias +// 27259,PropServerKeepAlive 14117,PropContentType +// "\DLEh\182\216\DC2\t]\138Of\192M\ENQ\166\149)\188\139\US\213",PropRetainAvailable 33,PropResponseTopic +// "\243\v\247\US.+\207\227\161\209\150/D\237\225t",PropMaximumPacketSize 8492,PropPayloadFormatIndicator +// 3,PropResponseTopic +// "\STX\186\165\221l\193\221\SO2\159_\208\n\174\&1Q\240\229\243\201/\226X\162i\244\198",PropSharedSubscriptionAvailable +// 50,PropTopicAlias 22557,PropSubscriptionIdentifier 13,PropTopicAliasMaximum 8009,PropResponseTopic +// "\139\ACK|f\ACK\217\213u+\f\239\201\225K\199\213\ESC\189\EMv\214",PropSubscriptionIdentifierAvailable +// 104,PropResponseInformation "i\224\tR|\183\"\v\218\218x\245\199\SOH\203\234\231",PropRequestProblemInformation +// 71,PropRetainAvailable 129,PropSubscriptionIdentifierAvailable 84,PropAssignedClientIdentifier +// "!*\175\DC47\209",PropMessageExpiryInterval 466,PropMaximumPacketSize 2156,PropMaximumQoS +// 167,PropMessageExpiryInterval 23974,PropUserProperty "\168P\f\234\167SFw\231\245 \SYNPSo\NUL2j|" +// "~I",PropServerReference "\139\170w2P\143\241\193\DC3",PropReasonString +// "F\239j\220\140\132\DEL\191'\164\SYN\170[X\218\218\210\208ux\197?\186",PropWillDelayInterval 19569] TEST(Subscribe5QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0x6b, 0x5a, 0x36, 0x8, 0x23, 0xc, 0x2d, 0x27, 0x0, 0x0, 0x70, 0x79, 0x0, 0x6, 0x80, - 0x36, 0xe1, 0x81, 0xdd, 0xaa, 0x0, 0x0, 0x1e, 0xa3, 0xfa, 0x89, 0xf0, 0xef, 0x51, 0xca, 0xa, - 0xd9, 0xa7, 0xe8, 0x2, 0xc7, 0xf5, 0x6d, 0x93, 0x2f, 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a5, 0x6c, + 0x59, 0xe6, 0xff, 0x6, 0x0, 0x19, 0x1d, 0xa4, 0xba, 0x96, 0xbf, 0xd, 0x9, 0x6f, 0xbd, 0xbe, 0x96, 0xb7, 0x29, + 0x29, 0x61, 0x19, 0xeb, 0x12, 0x42, 0x5c, 0xd7, 0x47, 0xed, 0x3a, 0xa1, 0x24, 0x0, 0x16, 0x67, 0xb9, 0xe4, 0x5b, + 0x11, 0x25, 0x36, 0x1c, 0x24, 0xfb, 0xef, 0xd2, 0x85, 0x95, 0xb8, 0x36, 0x31, 0x4, 0x53, 0x83, 0xbe, 0x93, 0x25, + 0x0, 0x16, 0x34, 0x54, 0x42, 0xeb, 0x4b, 0xd7, 0x4e, 0x22, 0xc6, 0x3e, 0x4c, 0xab, 0x72, 0x3a, 0x88, 0x80, 0x9, + 0xa, 0x56, 0x31, 0x40, 0xce, 0x18, 0x0, 0x14, 0x98, 0xb2, 0x18, 0xaf, 0x51, 0xe5, 0x68, 0x11, 0x39, 0x49, 0xc9, + 0xbe, 0x3e, 0xe6, 0xa4, 0xb5, 0xf2, 0x71, 0x35, 0x31, 0x21, 0x0, 0x10, 0xb0, 0x4f, 0xeb, 0xb7, 0x90, 0x3, 0xe0, + 0x6, 0xad, 0xed, 0x2a, 0x10, 0x81, 0x0, 0x18, 0x97, 0x25, 0x0, 0x5, 0xd2, 0xbd, 0xf, 0xf3, 0x63, 0x1c, 0x0, + 0x12, 0xa4, 0xb0, 0x9f, 0xa8, 0xe5, 0xe9, 0x76, 0x9f, 0xb, 0xdf, 0xe3, 0x9e, 0xcf, 0xbe, 0xd8, 0xbb, 0xcb, 0x5a, + 0xa}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x80, 0x36, 0xe1, 0x81, 0xdd, 0xaa}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd, 0xb1, 0xff, 0x38, 0xcd, 0x54, 0xdc, 0xdd, 0xc8, 0x49, + 0x87, 0xb3, 0x0, 0x8, 0x26, 0xd2, 0x3c, 0xa0, 0x76, 0x8b, + 0xae, 0x95, 0x70, 0xe2, 0x31, 0x2, 0xe3, 0xaa}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa3, 0xfa, 0x89, 0xf0, 0xef, 0x51, 0xca, 0xa, 0xd9, 0xa7, - 0xe8, 0x2, 0xc7, 0xf5, 0x6d, 0x93, 0x2f, 0xb8, 0x9a, 0x1b, - 0x5c, 0x2d, 0x46, 0xdf, 0xa, 0x8d, 0xdc, 0x31, 0x27, 0xc4}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x15, 0x52, 0x4c, 0x69, 0xe, 0x21}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfe, 0x8f, 0xf3, 0x54, 0xfb, 0xcc, 0x4a}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5e, 0x24, 0xc3, 0xdd, 0x71, 0x59, 0x74, + 0x4b, 0x31, 0xa5, 0x6c, 0x59, 0xe6, 0xff}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfa, 0xa5, 0xda, 0xff, 0x5e, 0x6f, 0xe3, 0x86, 0x2, 0x5a, 0xac, - 0xd1, 0x82, 0xa, 0x37, 0x46, 0x92, 0xe, 0xed, 0x7e, 0x48}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1d, 0xa4, 0xba, 0x96, 0xbf, 0xd, 0x9, 0x6f, 0xbd, 0xbe, 0x96, 0xb7, 0x29, + 0x29, 0x61, 0x19, 0xeb, 0x12, 0x42, 0x5c, 0xd7, 0x47, 0xed, 0x3a, 0xa1}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xad, 0x1c, 0xce, 0xe9, 0xac, 0xd, 0xc6, 0x5c, 0x8e, - 0xb9, 0x2a, 0xd9, 0x4c, 0x31, 0xe9, 0x76, 0x60}; - lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x67, 0xb9, 0xe4, 0x5b, 0x11, 0x25, 0x36, 0x1c, 0x24, 0xfb, 0xef, + 0xd2, 0x85, 0x95, 0xb8, 0x36, 0x31, 0x4, 0x53, 0x83, 0xbe, 0x93}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; + uint8_t topic_filter_s5_bytes[] = {0x34, 0x54, 0x42, 0xeb, 0x4b, 0xd7, 0x4e, 0x22, 0xc6, 0x3e, 0x4c, + 0xab, 0x72, 0x3a, 0x88, 0x80, 0x9, 0xa, 0x56, 0x31, 0x40, 0xce}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x98, 0xb2, 0x18, 0xaf, 0x51, 0xe5, 0x68, 0x11, 0x39, 0x49, + 0xc9, 0xbe, 0x3e, 0xe6, 0xa4, 0xb5, 0xf2, 0x71, 0x35, 0x31}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xb0, 0x4f, 0xeb, 0xb7, 0x90, 0x3, 0xe0, 0x6, + 0xad, 0xed, 0x2a, 0x10, 0x81, 0x0, 0x18, 0x97}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd2, 0xbd, 0xf, 0xf3, 0x63}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa4, 0xb0, 0x9f, 0xa8, 0xe5, 0xe9, 0x76, 0x9f, 0xb, + 0xdf, 0xe3, 0x9e, 0xcf, 0xbe, 0xd8, 0xbb, 0xcb, 0x5a}; + lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; + sub_opts[4].retain_as_published = false; sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = false; + uint8_t bytesprops0[] = {0x10, 0x68, 0xb6, 0xd8, 0x12, 0x9, 0x5d, 0x8a, 0x4f, 0x66, + 0xc0, 0x4d, 0x5, 0xa6, 0x95, 0x29, 0xbc, 0x8b, 0x1f, 0xd5}; + uint8_t bytesprops1[] = {0xf3, 0xb, 0xf7, 0x1f, 0x2e, 0x2b, 0xcf, 0xe3, + 0xa1, 0xd1, 0x96, 0x2f, 0x44, 0xed, 0xe1, 0x74}; + uint8_t bytesprops2[] = {0x2, 0xba, 0xa5, 0xdd, 0x6c, 0xc1, 0xdd, 0xe, 0x32, 0x9f, 0x5f, 0xd0, 0xa, 0xae, + 0x31, 0x51, 0xf0, 0xe5, 0xf3, 0xc9, 0x2f, 0xe2, 0x58, 0xa2, 0x69, 0xf4, 0xc6}; + uint8_t bytesprops3[] = {0x8b, 0x6, 0x7c, 0x66, 0x6, 0xd9, 0xd5, 0x75, 0x2b, 0xc, 0xef, + 0xc9, 0xe1, 0x4b, 0xc7, 0xd5, 0x1b, 0xbd, 0x19, 0x76, 0xd6}; + uint8_t bytesprops4[] = {0x69, 0xe0, 0x9, 0x52, 0x7c, 0xb7, 0x22, 0xb, 0xda, + 0xda, 0x78, 0xf5, 0xc7, 0x1, 0xcb, 0xea, 0xe7}; + uint8_t bytesprops5[] = {0x21, 0x2a, 0xaf, 0x14, 0x37, 0xd1}; + uint8_t bytesprops7[] = {0x7e, 0x49}; + uint8_t bytesprops6[] = {0xa8, 0x50, 0xc, 0xea, 0xa7, 0x53, 0x46, 0x77, 0xe7, 0xf5, + 0x20, 0x16, 0x50, 0x53, 0x6f, 0x0, 0x32, 0x6a, 0x7c}; + uint8_t bytesprops8[] = {0x8b, 0xaa, 0x77, 0x32, 0x50, 0x8f, 0xf1, 0xc1, 0x13}; + uint8_t bytesprops9[] = {0x46, 0xef, 0x6a, 0xdc, 0x8c, 0x84, 0x7f, 0xbf, 0x27, 0xa4, 0x16, 0xaa, + 0x5b, 0x58, 0xda, 0xda, 0xd2, 0xd0, 0x75, 0x78, 0xc5, 0x3f, 0xba}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3117}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28793}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27259}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14117}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8492}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22557}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8009}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 466}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2156}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23974}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops6}, .v = {2, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19569}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23094, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29413, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7726 [("\143]\132\&9x\254\"\152\138W\190\240~",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\212r\ENQ\223Vje;r\193\137AS6\239\&1\167~\192\&2\174q\243",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("+\DLE.\136\EOT\139\175\183\191\181",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\170Fn\158",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, -// _subQoS = QoS2}),("\233/\176\br$c\158\v\232",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("h-\196\177\189\250J\CANE\236\154\218\131\142\183\ACK\247\154\169#\207c",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("T\231\n\r,03!\135\DC2\225lU?\SI\132\208\254\164\159\177\195\t\132\220j?",SubOptions {_retainHandling = +// QoS2}),("\173U\245\ACK\156A\ENQ\208\187\208\DELX",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\188\246\170$\240\EM",SubOptions {_retainHandling = // SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\164\238\144r\220E\CANQ\216\130\171\SYN)D\160\179U",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropServerKeepAlive 10066,PropMaximumQoS -// 119,PropSessionExpiryInterval 12417,PropAuthenticationMethod -// "\186\244\151\226\na\139\155\239\133t\NAKg\RS$\238\SO",PropWildcardSubscriptionAvailable 179,PropTopicAliasMaximum -// 21147] +// QoS0}),("\"~R\129\189*P\134\186\ETB\222\230\&4\168^\237\146\ACK\240\190q\205\153U\SOH^|H",SubOptions {_retainHandling +// = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropReceiveMaximum +// 9386,PropPayloadFormatIndicator 171,PropRequestResponseInformation 192,PropReceiveMaximum +// 26762,PropSharedSubscriptionAvailable 198,PropAuthenticationData +// "\149\153e\137\n\EM\204\228Ns\205\DC3\NUL\162\155\NAK:\223\&5\CAN\248C\201\206\194n",PropMaximumPacketSize +// 8554,PropAssignedClientIdentifier "\160\138K\208\201\152\209\224\173T\217!\172",PropMessageExpiryInterval +// 19029,PropCorrelationData "y\195\175\ETX",PropServerReference +// "\138cfZ.\147a#\SYN.K%\163\186S\132YK\EM&\131\ETBd\245",PropMaximumPacketSize 20156,PropReasonString +// "\252\147",PropRetainAvailable 63,PropRequestResponseInformation 77,PropWildcardSubscriptionAvailable +// 242,PropSharedSubscriptionAvailable 230,PropMaximumQoS 54,PropResponseTopic "\225\ETBX\215\DC1\NUL\a"] TEST(Subscribe5QCTest, Encode17) { - uint8_t pkt[] = {0x82, 0x9e, 0x2, 0x1e, 0x2e, 0x23, 0x13, 0x27, 0x52, 0x24, 0x77, 0x11, 0x0, 0x0, 0x30, 0x81, 0x15, - 0x0, 0x11, 0xba, 0xf4, 0x97, 0xe2, 0xa, 0x61, 0x8b, 0x9b, 0xef, 0x85, 0x74, 0x15, 0x67, 0x1e, 0x24, - 0xee, 0xe, 0x28, 0xb3, 0x22, 0x52, 0x9b, 0x0, 0x1d, 0x8f, 0x5d, 0x84, 0x39, 0x78, 0xfe, 0x22, 0x98, - 0x8a, 0x57, 0xbe, 0xf0, 0x7e, 0x3c, 0x55, 0xb2, 0xb6, 0x69, 0x4a, 0x71, 0xe4, 0x87, 0x4e, 0x0, 0x9c, - 0x6d, 0xb9, 0xe8, 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0x8c, 0x28, 0x22, 0x0, 0x17, 0xb6, 0x9d, 0x9b, 0x5d, 0x1e, 0xca, 0x5a, 0xce, 0x46, 0xc0, 0x9, 0xf0, + 0x62, 0x57, 0xd3, 0x9e, 0xa3, 0x62, 0xdb, 0x93, 0x46, 0x33, 0x3e, 0xa, 0x0, 0xc, 0xad, 0x55, 0xf5, + 0x6, 0x9c, 0x41, 0x5, 0xd0, 0xbb, 0xd0, 0x7f, 0x58, 0x29, 0x0, 0x6, 0xbc, 0xf6, 0xaa, 0x24, 0xf0, + 0x19, 0x14, 0x0, 0x1c, 0x22, 0x7e, 0x52, 0x81, 0xbd, 0x2a, 0x50, 0x86, 0xba, 0x17, 0xde, 0xe6, 0x34, + 0xa8, 0x5e, 0xed, 0x92, 0x6, 0xf0, 0xbe, 0x71, 0xcd, 0x99, 0x55, 0x1, 0x5e, 0x7c, 0x48, 0x10}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x8f, 0x5d, 0x84, 0x39, 0x78, 0xfe, 0x22, 0x98, 0x8a, 0x57, - 0xbe, 0xf0, 0x7e, 0x3c, 0x55, 0xb2, 0xb6, 0x69, 0x4a, 0x71, - 0xe4, 0x87, 0x4e, 0x0, 0x9c, 0x6d, 0xb9, 0xe8, 0xfe}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x4f, 0x18, 0xc5, 0x2f, 0xb0, 0x4d, 0x35, 0xc4, + 0x18, 0xe1, 0x81, 0x4c, 0x74, 0x8c, 0x28}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc3, 0xcd, 0xec, 0x1f, 0x78, 0x25, 0xbd, 0xb5, 0xd7, 0x62, 0xb2, 0xa0, 0xa4, - 0x75, 0xf1, 0x2a, 0xe2, 0x8d, 0x56, 0x3d, 0x39, 0x74, 0xe4, 0x28, 0xe4}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb6, 0x9d, 0x9b, 0x5d, 0x1e, 0xca, 0x5a, 0xce, 0x46, 0xc0, 0x9, 0xf0, + 0x62, 0x57, 0xd3, 0x9e, 0xa3, 0x62, 0xdb, 0x93, 0x46, 0x33, 0x3e}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6e, 0xe, 0x47, 0xa4, 0xa6, 0x21, 0x18, 0xf1, 0x18, 0x4c, 0xa6, 0xaa, - 0x41, 0x54, 0xdc, 0xba, 0x88, 0xc2, 0xa3, 0xdf, 0xd1, 0xe9, 0x3b}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xad, 0x55, 0xf5, 0x6, 0x9c, 0x41, 0x5, 0xd0, 0xbb, 0xd0, 0x7f, 0x58}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8e, 0x10, 0x47, 0x18, 0x44, 0x58, 0x38, 0x1d, 0x70, 0xdf, 0x89, 0xf8, 0x57, - 0x62, 0x35, 0x1e, 0x9d, 0xd6, 0x8e, 0x16, 0xb1, 0x4b, 0x5, 0x72, 0x0}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xbc, 0xf6, 0xaa, 0x24, 0xf0, 0x19}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd4, 0x72, 0x5, 0xdf, 0x56, 0x6a, 0x65, 0x3b, 0x72, 0xc1, 0x89, 0x41, - 0x53, 0x36, 0xef, 0x31, 0xa7, 0x7e, 0xc0, 0x32, 0xae, 0x71, 0xf3}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x22, 0x7e, 0x52, 0x81, 0xbd, 0x2a, 0x50, 0x86, 0xba, 0x17, + 0xde, 0xe6, 0x34, 0xa8, 0x5e, 0xed, 0x92, 0x6, 0xf0, 0xbe, + 0x71, 0xcd, 0x99, 0x55, 0x1, 0x5e, 0x7c, 0x48}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x2b, 0x10, 0x2e, 0x88, 0x4, 0x8b, 0xaf, 0xb7, 0xbf, 0xb5}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xaa, 0x46, 0x6e, 0x9e}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe9, 0x2f, 0xb0, 0x8, 0x72, 0x24, 0x63, 0x9e, 0xb, 0xe8}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x68, 0x2d, 0xc4, 0xb1, 0xbd, 0xfa, 0x4a, 0x18, 0x45, 0xec, 0x9a, - 0xda, 0x83, 0x8e, 0xb7, 0x6, 0xf7, 0x9a, 0xa9, 0x23, 0xcf, 0x63}; - lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x54, 0xe7, 0xa, 0xd, 0x2c, 0x30, 0x33, 0x21, 0x87, 0x12, 0xe1, 0x6c, 0x55, 0x3f, - 0xf, 0x84, 0xd0, 0xfe, 0xa4, 0x9f, 0xb1, 0xc3, 0x9, 0x84, 0xdc, 0x6a, 0x3f}; - lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xa4, 0xee, 0x90, 0x72, 0xdc, 0x45, 0x18, 0x51, 0xd8, - 0x82, 0xab, 0x16, 0x29, 0x44, 0xa0, 0xb3, 0x55}; - lwmqtt_string_t topic_filter_s10 = {17, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; + lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = true; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; - uint8_t bytesprops0[] = {0xba, 0xf4, 0x97, 0xe2, 0xa, 0x61, 0x8b, 0x9b, 0xef, - 0x85, 0x74, 0x15, 0x67, 0x1e, 0x24, 0xee, 0xe}; + sub_opts[4].no_local = false; + uint8_t bytesprops0[] = {0x95, 0x99, 0x65, 0x89, 0xa, 0x19, 0xcc, 0xe4, 0x4e, 0x73, 0xcd, 0x13, 0x0, + 0xa2, 0x9b, 0x15, 0x3a, 0xdf, 0x35, 0x18, 0xf8, 0x43, 0xc9, 0xce, 0xc2, 0x6e}; + uint8_t bytesprops1[] = {0xa0, 0x8a, 0x4b, 0xd0, 0xc9, 0x98, 0xd1, 0xe0, 0xad, 0x54, 0xd9, 0x21, 0xac}; + uint8_t bytesprops2[] = {0x79, 0xc3, 0xaf, 0x3}; + uint8_t bytesprops3[] = {0x8a, 0x63, 0x66, 0x5a, 0x2e, 0x93, 0x61, 0x23, 0x16, 0x2e, 0x4b, 0x25, + 0xa3, 0xba, 0x53, 0x84, 0x59, 0x4b, 0x19, 0x26, 0x83, 0x17, 0x64, 0xf5}; + uint8_t bytesprops4[] = {0xfc, 0x93}; + uint8_t bytesprops5[] = {0xe1, 0x17, 0x58, 0xd7, 0x11, 0x0, 0x7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10066}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12417}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21147}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9386}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26762}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8554}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19029}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20156}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7726, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6204, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 1195 [("\ETX\191\156\US3\137\&5\190a",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\165\NAK\196P -// \236\172\197M\140\177r\SUB\159",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal -// = True, _subQoS = QoS0}),("\RS\207\192\216\168",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// True, _noLocal = False, _subQoS = -// QoS0}),("3\221i\DC1\162\226\214EnW\250\156\230\182;V\195\230d\NUL\174<\173J\139\160",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\250u\151\159P'\139\EM\157U\250+\NAKH\146+V\202Rz",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\199USx\174ia\GSz\ACK\DC2\\)\192\SOHC\142`/|\206J`DO",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\234\194\129~z9_E\fvk\232\168i1})/\136RT\141\170\184:\210@\227I",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("D\169\215/0R\DEL\201>\234\155>\147W\SOv%\NAK\US\230l",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\155\"\219\&9`\138\145\182\&3\178\147\226G\a[h\191`\212`\185\143",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("a]\205\220o\197]\139qT\177$?P\151\158\141=\231\157\249k\231H\159\163.",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropCorrelationData -// "\173\161\DC1\166\244Z\167\&1\139Po\237\170\193\138=\244\187",PropWillDelayInterval 12750,PropSubscriptionIdentifier -// 6,PropReasonString "*\162\180\&3\182\222\210\250Y\189\&5m\253\172",PropRequestResponseInformation 6,PropResponseTopic -// "\DEL\204\228\143\203K\254B4\181\NULA\DELRe\245\223\183\237%x0*\240*c",PropWillDelayInterval 1053,PropServerReference -// "h\ETXm`\226\164\&3\178qd{\154\183y",PropRequestProblemInformation 21,PropMaximumPacketSize -// 31500,PropRequestResponseInformation 119,PropMaximumPacketSize 10228,PropServerKeepAlive 10977,PropResponseTopic -// "/\167\&6\228JC\209\207\DC4\214_|R\207!\133\SOHB",PropWillDelayInterval 10162,PropSessionExpiryInterval -// 24718,PropAuthenticationData "\227\214\EOT\SO\235n\144\232",PropSharedSubscriptionAvailable -// 176,PropPayloadFormatIndicator 55] +// SubscribeRequest 8030 [("\234\190\DEL\176\250cyY\218\176\196\212\214",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\153\174",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\185D\196\STX\DC3\194\198\144\b\211h\192\175\SI\250aJ\177\167",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("6\ETB\STXr\219j\151-\227",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] +// [PropCorrelationData "\DC4\209\216\241/\ETX\t\222\191\213\146S@\199\GSS\ETB\244;\f\195\187\SYN",PropResponseTopic +// "\191\SOH\233\131\240\221\129\148\196\157\218{n\201+q\181\217t\137Y\FSv\GS\129",PropSessionExpiryInterval +// 6725,PropTopicAliasMaximum 6943,PropMessageExpiryInterval 32523,PropResponseTopic +// "K\238\134\187\253\128!*\re\167\135J%\245\251\136\t^\242G\SI\155\ETBxb-P\217",PropRequestResponseInformation +// 102,PropWillDelayInterval 31845,PropAuthenticationMethod +// "\231\US\NULZ\151\DLE\218\226\v\252\191\157\167[\232\155^\243\DEL\146\222(}",PropReceiveMaximum +// 23804,PropReasonString "&\155\SO\192\243\NAK\253\241\\\175\190\180.x\234`UF\"",PropResponseInformation +// "\250\156\\\137f\135\USNg\230YE\US\220\NUL|\224r\201\238\175r",PropSubscriptionIdentifierAvailable +// 238,PropServerKeepAlive 13004,PropAssignedClientIdentifier +// "\244\186\246_&\194\224v\CAN",PropWildcardSubscriptionAvailable 96,PropCorrelationData -// "\131,\227\DC4k\n\205\185\184)Z\205\215a%\144{j\201\205`\228\177R",PropWillDelayInterval -// 31922,PropAuthenticationMethod "\178Q[",PropWildcardSubscriptionAvailable 255,PropReasonString "",PropResponseTopic -// "\202\151\153F",PropRetainAvailable 126,PropResponseTopic -// "\239\DC40\139\154\&9\157hZ^m\NAK\195\156\214\229\138\152",PropAssignedClientIdentifier "\233",PropRetainAvailable -// 181,PropRequestProblemInformation 208,PropMaximumPacketSize 6700,PropUserProperty "itp\171\GS=\214m\136{Z\129\210t" -// "\235\233\RSc)6\241\237\147^\139\137\n\ACK\173_;x>\206\167\138\207\233\ETB\231\EM\255o",PropSubscriptionIdentifier -// 9,PropMaximumPacketSize 19656,PropReceiveMaximum 2700,PropSessionExpiryInterval 20638] +// SubscribeRequest 20073 [("\150\229\151f\221S\227F9\174\140\214\205\194\&6",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("b'\220g\205\179\146\202\229\249\GS\151R#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = True, _subQoS = QoS1}),("\NAK",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\212m\205\&6\249'\241wU\144\246\172\DEL4b!*\199\&4K\220\225",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("h\235\206",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\252\156\160\253\208\193C\SI[\235\239\236\248\207J&b\135\248\157",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\SYN\167%\167C+\SOH\205\197\t3\244\136\RS\ETB\237:\n\EOTco\DC3~\160\135",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\131\204\157\FS\182\179\254}\198^zy\160P\255\NAK\192]\172\DLE(\173\129oIr\144u\212",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\230\212\130m\136\168\227\&6\206;\ACK\STX\242",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\249\t3\197x@\253D\DC4\"\229\193\219\163\145}\167\&9\182\145I",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("yW<\191",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] +// [PropAuthenticationData "\146\US\n\162'\207\224\248\&6j\183.(t\241J\DC1\t",PropMaximumPacketSize +// 10820,PropRequestResponseInformation 112,PropReceiveMaximum 16246,PropAssignedClientIdentifier +// "\241\130\203\133\CAN\217n\GS\aM\255\198\STX\b\214\241y\DC2\172\184|\159\202"] TEST(Subscribe5QCTest, Encode20) { uint8_t pkt[] = { - 0x82, 0x8b, 0x3, 0x6c, 0xc7, 0xb5, 0x2, 0x1c, 0x0, 0x1e, 0x68, 0x9e, 0xda, 0x75, 0xe0, 0x22, 0xdb, 0x20, 0xb5, - 0x23, 0x26, 0x16, 0xa6, 0x79, 0x28, 0xf3, 0x79, 0x9a, 0x2b, 0xe1, 0x83, 0xbb, 0x2f, 0x5f, 0x9d, 0x51, 0x69, 0x28, - 0x91, 0xa6, 0x2a, 0x6f, 0x23, 0x21, 0xb1, 0x12, 0x0, 0x17, 0x47, 0x18, 0xc8, 0xe6, 0x34, 0x71, 0x68, 0x62, 0x59, - 0x75, 0x38, 0xf9, 0xcc, 0x83, 0x11, 0x73, 0xd7, 0xf2, 0xe8, 0x12, 0x95, 0x22, 0xf8, 0x9, 0x0, 0x1e, 0x44, 0x9e, - 0x79, 0x19, 0x25, 0xe8, 0x7d, 0x8a, 0xc2, 0x53, 0x11, 0x37, 0x8a, 0xf2, 0x2, 0xde, 0x12, 0x5, 0xc0, 0xc0, 0x80, - 0x61, 0xb3, 0xf4, 0x45, 0xd, 0xb7, 0xb2, 0xe, 0x2a, 0x9, 0x0, 0x10, 0xc6, 0xde, 0x2b, 0xc4, 0x81, 0x29, 0x5f, - 0xc6, 0x47, 0x81, 0x5c, 0xe, 0x6a, 0xe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x52, 0x23, 0x5, 0x0, 0x1, 0x15, 0x1a, 0x0, 0x16, 0xd4, 0x6d, 0xcd, 0x36, 0xf9, 0x27, 0xf1, 0x77, 0x55, 0x90, + 0xf6, 0xac, 0x7f, 0x34, 0x62, 0x21, 0x2a, 0xc7, 0x34, 0x4b, 0xdc, 0xe1, 0xe, 0x0, 0x3, 0x68, 0xeb, 0xce, 0xc, + 0x0, 0x14, 0xfc, 0x9c, 0xa0, 0xfd, 0xd0, 0xc1, 0x43, 0xf, 0x5b, 0xeb, 0xef, 0xec, 0xf8, 0xcf, 0x4a, 0x26, 0x62, + 0x87, 0xf8, 0x9d, 0x9, 0x0, 0x19, 0x16, 0xa7, 0x25, 0xa7, 0x43, 0x2b, 0x1, 0xcd, 0xc5, 0x9, 0x33, 0xf4, 0x88, + 0x1e, 0x17, 0xed, 0x3a, 0xa, 0x4, 0x63, 0x6f, 0x13, 0x7e, 0xa0, 0x87, 0x16, 0x0, 0x1d, 0x83, 0xcc, 0x9d, 0x1c, + 0xb6, 0xb3, 0xfe, 0x7d, 0xc6, 0x5e, 0x7a, 0x79, 0xa0, 0x50, 0xff, 0x15, 0xc0, 0x5d, 0xac, 0x10, 0x28, 0xad, 0x81, + 0x6f, 0x49, 0x72, 0x90, 0x75, 0xd4, 0x8, 0x0, 0xd, 0xe6, 0xd4, 0x82, 0x6d, 0x88, 0xa8, 0xe3, 0x36, 0xce, 0x3b, + 0x6, 0x2, 0xf2, 0x25, 0x0, 0x15, 0xf9, 0x9, 0x33, 0xc5, 0x78, 0x40, 0xfd, 0x44, 0x14, 0x22, 0xe5, 0xc1, 0xdb, + 0xa3, 0x91, 0x7d, 0xa7, 0x39, 0xb6, 0x91, 0x49, 0x12, 0x0, 0x4, 0x79, 0x57, 0x3c, 0xbf, 0x2c}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xf3, 0x3c, 0xcd, 0x8e, 0xfe, 0xa8, 0x55, 0xde, 0xa5, 0x2c, 0x86, 0x82, 0x87, 0xe1, - 0x5f, 0x8f, 0xcd, 0x1f, 0xa2, 0xcb, 0x44, 0x17, 0x52, 0xe, 0xa, 0xf2, 0xc2}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x96, 0xe5, 0x97, 0x66, 0xdd, 0x53, 0xe3, 0x46, + 0x39, 0xae, 0x8c, 0xd6, 0xcd, 0xc2, 0x36}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x73, 0xc7, 0xad, 0xb7, 0x6e, 0xfc, 0xf5, 0xeb, 0xed, - 0x3, 0x1, 0xbd, 0xbe, 0x4d, 0x39, 0xa0, 0x2f, 0x2b}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x62, 0x27, 0xdc, 0x67, 0xcd, 0xb3, 0x92, + 0xca, 0xe5, 0xf9, 0x1d, 0x97, 0x52, 0x23}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x94}; + uint8_t topic_filter_s2_bytes[] = {0x15}; lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x34, 0x78, 0xbb, 0x80, 0x8b, 0x33, 0x7, 0x13, 0xe9, 0x88, 0x18, 0x7b, - 0xc8, 0xac, 0x42, 0xd5, 0x9b, 0x16, 0x53, 0xaf, 0xdd, 0xb7, 0xc3, 0x1d}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd4, 0x6d, 0xcd, 0x36, 0xf9, 0x27, 0xf1, 0x77, 0x55, 0x90, 0xf6, + 0xac, 0x7f, 0x34, 0x62, 0x21, 0x2a, 0xc7, 0x34, 0x4b, 0xdc, 0xe1}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s4_bytes[] = {0x68, 0xeb, 0xce}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xfc, 0x9c, 0xa0, 0xfd, 0xd0, 0xc1, 0x43, 0xf, 0x5b, 0xeb, + 0xef, 0xec, 0xf8, 0xcf, 0x4a, 0x26, 0x62, 0x87, 0xf8, 0x9d}; + lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x16, 0xa7, 0x25, 0xa7, 0x43, 0x2b, 0x1, 0xcd, 0xc5, 0x9, 0x33, 0xf4, 0x88, + 0x1e, 0x17, 0xed, 0x3a, 0xa, 0x4, 0x63, 0x6f, 0x13, 0x7e, 0xa0, 0x87}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x83, 0xcc, 0x9d, 0x1c, 0xb6, 0xb3, 0xfe, 0x7d, 0xc6, 0x5e, + 0x7a, 0x79, 0xa0, 0x50, 0xff, 0x15, 0xc0, 0x5d, 0xac, 0x10, + 0x28, 0xad, 0x81, 0x6f, 0x49, 0x72, 0x90, 0x75, 0xd4}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe6, 0xd4, 0x82, 0x6d, 0x88, 0xa8, 0xe3, 0x36, 0xce, 0x3b, 0x6, 0x2, 0xf2}; + lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xf9, 0x9, 0x33, 0xc5, 0x78, 0x40, 0xfd, 0x44, 0x14, 0x22, 0xe5, + 0xc1, 0xdb, 0xa3, 0x91, 0x7d, 0xa7, 0x39, 0xb6, 0x91, 0x49}; + lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x79, 0x57, 0x3c, 0xbf}; + lwmqtt_string_t topic_filter_s10 = {4, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; - uint8_t bytesprops0[] = {0x68, 0x9e, 0xda, 0x75, 0xe0, 0x22, 0xdb, 0x20, 0xb5, 0x23, 0x26, 0x16, 0xa6, 0x79, 0x28, - 0xf3, 0x79, 0x9a, 0x2b, 0xe1, 0x83, 0xbb, 0x2f, 0x5f, 0x9d, 0x51, 0x69, 0x28, 0x91, 0xa6}; - uint8_t bytesprops1[] = {0x47, 0x18, 0xc8, 0xe6, 0x34, 0x71, 0x68, 0x62, 0x59, 0x75, 0x38, 0xf9, - 0xcc, 0x83, 0x11, 0x73, 0xd7, 0xf2, 0xe8, 0x12, 0x95, 0x22, 0xf8}; - uint8_t bytesprops2[] = {0x44, 0x9e, 0x79, 0x19, 0x25, 0xe8, 0x7d, 0x8a, 0xc2, 0x53, 0x11, 0x37, 0x8a, 0xf2, 0x2, - 0xde, 0x12, 0x5, 0xc0, 0xc0, 0x80, 0x61, 0xb3, 0xf4, 0x45, 0xd, 0xb7, 0xb2, 0xe, 0x2a}; - uint8_t bytesprops3[] = {0xc6, 0xde, 0x2b, 0xc4, 0x81, 0x29, 0x5f, 0xc6, 0x47, 0x81, 0x5c, 0xe, 0x6a, 0xe, 0x64, 0x5}; - uint8_t bytesprops4[] = {0xf7, 0x64, 0xef, 0xb3, 0x8d, 0x9, 0x1e, 0xae, 0x2, 0x3b}; - uint8_t bytesprops5[] = {0xa1, 0x81, 0xb3, 0x31, 0xb1, 0xc8, 0xe8, 0xb1, - 0x2f, 0x3, 0xfb, 0xbb, 0x26, 0xd2, 0x3e, 0x18}; - uint8_t bytesprops6[] = {0x83, 0x2c, 0xe3, 0x14, 0x6b, 0xa, 0xcd, 0xb9, 0xb8, 0x29, 0x5a, 0xcd, - 0xd7, 0x61, 0x25, 0x90, 0x7b, 0x6a, 0xc9, 0xcd, 0x60, 0xe4, 0xb1, 0x52}; - uint8_t bytesprops7[] = {0xb2, 0x51, 0x5b}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops9[] = {0xca, 0x97, 0x99, 0x46}; - uint8_t bytesprops10[] = {0xef, 0x14, 0x30, 0x8b, 0x9a, 0x39, 0x9d, 0x68, 0x5a, - 0x5e, 0x6d, 0x15, 0xc3, 0x9c, 0xd6, 0xe5, 0x8a, 0x98}; - uint8_t bytesprops11[] = {0xe9}; - uint8_t bytesprops13[] = {0xeb, 0xe9, 0x1e, 0x63, 0x29, 0x36, 0xf1, 0xed, 0x93, 0x5e, 0x8b, 0x89, 0xa, 0x6, 0xad, - 0x5f, 0x3b, 0x78, 0x3e, 0xce, 0xa7, 0x8a, 0xcf, 0xe9, 0x17, 0xe7, 0x19, 0xff, 0x6f}; - uint8_t bytesprops12[] = {0x69, 0x74, 0x70, 0xab, 0x1d, 0x3d, 0xd6, 0x6d, 0x88, 0x7b, 0x5a, 0x81, 0xd2, 0x74}; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = true; + uint8_t bytesprops0[] = {0x92, 0x1f, 0xa, 0xa2, 0x27, 0xcf, 0xe0, 0xf8, 0x36, + 0x6a, 0xb7, 0x2e, 0x28, 0x74, 0xf1, 0x4a, 0x11, 0x9}; + uint8_t bytesprops1[] = {0xf1, 0x82, 0xcb, 0x85, 0x18, 0xd9, 0x6e, 0x1d, 0x7, 0x4d, 0xff, 0xc6, + 0x2, 0x8, 0xd6, 0xf1, 0x79, 0x12, 0xac, 0xb8, 0x7c, 0x9f, 0xca}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8625}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10820}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16246}}, {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 966}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17493}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31922}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6700}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {14, (char*)&bytesprops12}, .v = {29, (char*)&bytesprops13}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 9}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19656}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2700}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20638}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27847, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20073, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29011 [("L\255\232\&7",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// True, _noLocal = True, _subQoS = QoS0}),("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// True, _noLocal = False, _subQoS = QoS0}),("\ENQ -// \STX\209\189\DEL\160\167\&6~\254\SYN\144\246\217(\GS\207(c\142\241",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\237\194\247\230\ETX\134\225\f\SI\143\242\181\&1+\226EO\223\186\144se\216HY>\170\209",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\155O\191\161v\218\167\168_\147\DC1",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = True, _noLocal = True, _subQoS = QoS0}),("\FS\236xY=!\172\241\217\230\209\222\179\DC2\SI",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("d}\134\162\229\233`\212\248\207\DC4\254\137\186\232KP\165\222\144",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\241\197)E\130G\STX\248\&7w\179\173\243\vTB\FS\212o\195jN\201\151Z\NUL",SubOptions {_retainHandling = +// SubscribeRequest 12782 [("\238\199\163\EOT$\228\173\174\EM\128vA\216",SubOptions {_retainHandling = // SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\194\235)\201J\157\SOH3\t|\DC4\164\v\175\206\SOHY\236 \166(\212\130",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\181H\154\233\193\216W\142\190\172\173\206\ACKC`",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("s\231w\220\208\DC4\157\191\CAN\EOTo\187\170.c\DLE-\219",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS2}),("\172,\203\248Z\129\GS\RSj.\208\aqM\178\167n7\235",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\229.\210\152\ETB\234\229V\FS\177\214\ETBE\143D\ETB\222\154\157&\204\247\239",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\198\151\141\&8-\DEL\251\FS\a\CANfH\231*i\179\172\r\239_\141S(~Y\236",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("9oU\227^\\\129P74A\252\165^<\US\206\&6\148\182\&1\154\238\235\248\210\164\ENQ\ACK\184",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] +// [PropSharedSubscriptionAvailable 204,PropResponseInformation "E\170)=Q\201\t",PropAuthenticationData +// "\171\225\ETX;\176Zzi\246\195\237f\SI\199\232M\US\DC4\179*\160\177V\183\239n"] TEST(Subscribe5QCTest, Encode21) { - uint8_t pkt[] = {0x82, 0xda, 0x1, 0x71, 0x53, 0x0, 0x0, 0x4, 0x4c, 0xff, 0xe8, 0x37, 0x2c, 0x0, 0x0, 0x28, 0x0, - 0x16, 0x5, 0x20, 0x2, 0xd1, 0xbd, 0x7f, 0xa0, 0xa7, 0x36, 0x7e, 0xfe, 0x16, 0x90, 0xf6, 0xd9, 0x28, - 0x1d, 0xcf, 0x28, 0x63, 0x8e, 0xf1, 0x1d, 0x0, 0x1c, 0xed, 0xc2, 0xf7, 0xe6, 0x3, 0x86, 0xe1, 0xc, - 0xf, 0x8f, 0xf2, 0xb5, 0x31, 0x2b, 0xe2, 0x45, 0x4f, 0xdf, 0xba, 0x90, 0x73, 0x65, 0xd8, 0x48, 0x59, - 0x3e, 0xaa, 0xd1, 0x18, 0x0, 0xb, 0x9b, 0x4f, 0xbf, 0xa1, 0x76, 0xda, 0xa7, 0xa8, 0x5f, 0x93, 0x11, - 0x2c, 0x0, 0xf, 0x1c, 0xec, 0x78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 0x4, 0x24, 0xe4, 0xad, 0xae, 0x19, 0x80, 0x76, 0x41, 0xd8, 0x1e, 0x0, + 0x13, 0xac, 0x2c, 0xcb, 0xf8, 0x5a, 0x81, 0x1d, 0x1e, 0x6a, 0x2e, 0xd0, 0x7, 0x71, 0x4d, 0xb2, + 0xa7, 0x6e, 0x37, 0xeb, 0x4, 0x0, 0x17, 0xe5, 0x2e, 0xd2, 0x98, 0x17, 0xea, 0xe5, 0x56, 0x1c, + 0xb1, 0xd6, 0x17, 0x45, 0x8f, 0x44, 0x17, 0xde, 0x9a, 0x9d, 0x26, 0xcc, 0xf7, 0xef, 0x1d, 0x0, + 0x1a, 0xc6, 0x97, 0x8d, 0x38, 0x2d, 0x7f, 0xfb, 0x1c, 0x7, 0x18, 0x66, 0x48, 0xe7, 0x2a, 0x69, + 0xb3, 0xac, 0xd, 0xef, 0x5f, 0x8d, 0x53, 0x28, 0x7e, 0x59, 0xec, 0x0, 0x0, 0x1e, 0x39, 0x6f, + 0x55, 0xe3, 0x5e, 0x5c, 0x81, 0x50, 0x37, 0x34, 0x41, 0xfc, 0xa5, 0x5e, 0x3c, 0x1f, 0xce, 0x36, + 0x94, 0xb6, 0x31, 0x9a, 0xee, 0xeb, 0xf8, 0xd2, 0xa4, 0x5, 0x6, 0xb8, 0x24}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x4c, 0xff, 0xe8, 0x37}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xee, 0xc7, 0xa3, 0x4, 0x24, 0xe4, 0xad, 0xae, 0x19, 0x80, 0x76, 0x41, 0xd8}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xac, 0x2c, 0xcb, 0xf8, 0x5a, 0x81, 0x1d, 0x1e, 0x6a, 0x2e, + 0xd0, 0x7, 0x71, 0x4d, 0xb2, 0xa7, 0x6e, 0x37, 0xeb}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5, 0x20, 0x2, 0xd1, 0xbd, 0x7f, 0xa0, 0xa7, 0x36, 0x7e, 0xfe, - 0x16, 0x90, 0xf6, 0xd9, 0x28, 0x1d, 0xcf, 0x28, 0x63, 0x8e, 0xf1}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe5, 0x2e, 0xd2, 0x98, 0x17, 0xea, 0xe5, 0x56, 0x1c, 0xb1, 0xd6, 0x17, + 0x45, 0x8f, 0x44, 0x17, 0xde, 0x9a, 0x9d, 0x26, 0xcc, 0xf7, 0xef}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xed, 0xc2, 0xf7, 0xe6, 0x3, 0x86, 0xe1, 0xc, 0xf, 0x8f, - 0xf2, 0xb5, 0x31, 0x2b, 0xe2, 0x45, 0x4f, 0xdf, 0xba, 0x90, - 0x73, 0x65, 0xd8, 0x48, 0x59, 0x3e, 0xaa, 0xd1}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc6, 0x97, 0x8d, 0x38, 0x2d, 0x7f, 0xfb, 0x1c, 0x7, 0x18, 0x66, 0x48, 0xe7, + 0x2a, 0x69, 0xb3, 0xac, 0xd, 0xef, 0x5f, 0x8d, 0x53, 0x28, 0x7e, 0x59, 0xec}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9b, 0x4f, 0xbf, 0xa1, 0x76, 0xda, 0xa7, 0xa8, 0x5f, 0x93, 0x11}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x39, 0x6f, 0x55, 0xe3, 0x5e, 0x5c, 0x81, 0x50, 0x37, 0x34, + 0x41, 0xfc, 0xa5, 0x5e, 0x3c, 0x1f, 0xce, 0x36, 0x94, 0xb6, + 0x31, 0x9a, 0xee, 0xeb, 0xf8, 0xd2, 0xa4, 0x5, 0x6, 0xb8}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1c, 0xec, 0x78, 0x59, 0x3d, 0x21, 0xac, 0xf1, - 0xd9, 0xe6, 0xd1, 0xde, 0xb3, 0x12, 0xf}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x64, 0x7d, 0x86, 0xa2, 0xe5, 0xe9, 0x60, 0xd4, 0xf8, 0xcf, - 0x14, 0xfe, 0x89, 0xba, 0xe8, 0x4b, 0x50, 0xa5, 0xde, 0x90}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf1, 0xc5, 0x29, 0x45, 0x82, 0x47, 0x2, 0xf8, 0x37, 0x77, 0xb3, 0xad, 0xf3, - 0xb, 0x54, 0x42, 0x1c, 0xd4, 0x6f, 0xc3, 0x6a, 0x4e, 0xc9, 0x97, 0x5a, 0x0}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc2, 0xeb, 0x29, 0xc9, 0x4a, 0x9d, 0x1, 0x33, 0x9, 0x7c, 0x14, 0xa4, - 0xb, 0xaf, 0xce, 0x1, 0x59, 0xec, 0x20, 0xa6, 0x28, 0xd4, 0x82}; - lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xb5, 0x48, 0x9a, 0xe9, 0xc1, 0xd8, 0x57, 0x8e, - 0xbe, 0xac, 0xad, 0xce, 0x6, 0x43, 0x60}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x73, 0xe7, 0x77, 0xdc, 0xd0, 0x14, 0x9d, 0xbf, 0x18, - 0x4, 0x6f, 0xbb, 0xaa, 0x2e, 0x63, 0x10, 0x2d, 0xdb}; - lwmqtt_string_t topic_filter_s10 = {18, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; + sub_opts[4].retain_as_published = false; sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = true; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; + uint8_t bytesprops0[] = {0x45, 0xaa, 0x29, 0x3d, 0x51, 0xc9, 0x9}; + uint8_t bytesprops1[] = {0xab, 0xe1, 0x3, 0x3b, 0xb0, 0x5a, 0x7a, 0x69, 0xf6, 0xc3, 0xed, 0x66, 0xf, + 0xc7, 0xe8, 0x4d, 0x1f, 0x14, 0xb3, 0x2a, 0xa0, 0xb1, 0x56, 0xb7, 0xef, 0x6e}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops1}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29011, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12782, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29705 [("\amn\138\157\180\217\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS0}),("!!Va\217\152",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\249\n}\251\170",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\158\v\b\RS\149\235Vv\NAK\240\135d\189r\203\185b\176\ETB\195,EE\185y",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropSessionExpiryInterval -// 28284,PropResponseTopic "L"] +// SubscribeRequest 7994 [("w\248Bj\ETB\DC2\226U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS0}),("\190\217[",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("4/\225\175\&4\185\&5j\228\195\217\184\142\145(7%\165fb]\156\STX",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\131\156\225\148\176O5\ETX\213\218\214\174\214S\242\198Y\152\&2V%\188\222\GS8",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("1\US\176)\SYN3\SO\n\n4r\188\165vj\216\187]%\243\&244\SYN\186\166\r",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\170:\197\207\254\DLE\218c\r\134\184\235\NULq?\174\146B\227\240\211",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\151\237H\215M\151\DC4\144\228\180c\210\v\195\251",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\162\255\252\DC17\138\&3.\159W\239\237{Z/T\SO\132\246\251\170\243\186\162\177\&7",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\225)u\SUB\181#\ETB\132 \212\238G9{|-{h:@r0\186r\DC4\214\225\&4",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("l$",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),(">\217\185\166\NAK\216\248(\172\194\189",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS1})] [PropAuthenticationData "\170\159z\238\186^\223\210",PropServerKeepAlive +// 8290,PropTopicAliasMaximum 4943,PropSharedSubscriptionAvailable 22,PropTopicAliasMaximum 9948,PropAuthenticationData +// "\176p\192\156\US\n\217\139Z\202X\234\140y,\195\147",PropReasonString +// "\250\136A\138\143b\181]e/V\134l=\185\248\np\129\172(\RS\186\SI",PropResponseTopic +// "/\184\181>>\231\SO\219'\147\130\177\238r\233 Gx\198Fd\215\209\SYN.\DC2\SO\177\129+",PropReasonString +// "\170",PropContentType +// "\147Mq\ENQB!\247\143\237b\ACK#\163\176\179\ESC`\198\133\205zK\SOH]\204\172Z\203\165",PropMaximumPacketSize +// 31659,PropMaximumPacketSize 4540,PropResponseInformation +// "\233{\135\f\247y&\204\237\254\&7\ACK\CAND\135\r0\183L\DELGc\194YW",PropMessageExpiryInterval +// 24650,PropPayloadFormatIndicator 205,PropContentType +// "F\166\236\159f\US\230t0%\242\231\165\222P\SO\163\&0\fGGw\143_G7\158\187",PropServerReference +// "\199\162\220\164v\209\209\DC3\216\226\&4\215\CAN\GS\215-\150\170\169\176\193_\131\148\242\205h\b\198",PropResponseInformation +// "\NAK\210\128z\200\208>\190\217\132\227C\182\239v\172\173.3\SUBy\143\171\229\181\144A",PropReasonString +// ">\242N9\182",PropUserProperty "\158\141\252\150" +// "\172\ETB\165B\189\196\222\173\240\200\159K\NUL",PropAuthenticationMethod +// "\186\213\132\224\ETB\237\141\aa\ETB`\135\194\219\243\184?\v\235b\ESC\137\180B\199",PropAuthenticationMethod +// "\247-\159\142G4\250\223\&1\178\173\223\144)",PropAuthenticationMethod +// "\209\SOl\251\222\192\DC4\SOU\DC2\US\199i\211\193\248\138\GS\231\202\223\128\214\184^\135\240S",PropContentType +// "\159#\142\233\"\154\DC4\214ikm\150\RS",PropMessageExpiryInterval 7285] TEST(Subscribe5QCTest, Encode22) { - uint8_t pkt[] = {0x82, 0x44, 0x74, 0x9, 0x9, 0x11, 0x0, 0x0, 0x6e, 0x7c, 0x8, 0x0, 0x1, 0x4c, - 0x0, 0x8, 0x7, 0x6d, 0x6e, 0x8a, 0x9d, 0xb4, 0xd9, 0xdb, 0x0, 0x0, 0x6, 0x21, - 0x21, 0x56, 0x61, 0xd9, 0x98, 0xa, 0x0, 0x5, 0xf9, 0xa, 0x7d, 0xfb, 0xaa, 0x1, - 0x0, 0x19, 0x9e, 0x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0x42, 0xe3, + 0xf0, 0xd3, 0xe, 0x0, 0xf, 0x97, 0xed, 0x48, 0xd7, 0x4d, 0x97, 0x14, 0x90, 0xe4, 0xb4, 0x63, 0xd2, 0xb, 0xc3, + 0xfb, 0x18, 0x0, 0x1a, 0xa2, 0xff, 0xfc, 0x11, 0x37, 0x8a, 0x33, 0x2e, 0x9f, 0x57, 0xef, 0xed, 0x7b, 0x5a, 0x2f, + 0x54, 0xe, 0x84, 0xf6, 0xfb, 0xaa, 0xf3, 0xba, 0xa2, 0xb1, 0x37, 0xa, 0x0, 0x1c, 0xe1, 0x29, 0x75, 0x1a, 0xb5, + 0x23, 0x17, 0x84, 0x20, 0xd4, 0xee, 0x47, 0x39, 0x7b, 0x7c, 0x2d, 0x7b, 0x68, 0x3a, 0x40, 0x72, 0x30, 0xba, 0x72, + 0x14, 0xd6, 0xe1, 0x34, 0x2d, 0x0, 0x2, 0x6c, 0x24, 0x1, 0x0, 0xb, 0x3e, 0xd9, 0xb9, 0xa6, 0x15, 0xd8, 0xf8, + 0x28, 0xac, 0xc2, 0xbd, 0x5}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x7, 0x6d, 0x6e, 0x8a, 0x9d, 0xb4, 0xd9, 0xdb}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x77, 0xf8, 0x42, 0x6a, 0x17, 0x12, 0xe2, 0x55}; lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x21, 0x21, 0x56, 0x61, 0xd9, 0x98}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbe, 0xd9, 0x5b}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf9, 0xa, 0x7d, 0xfb, 0xaa}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x34, 0x2f, 0xe1, 0xaf, 0x34, 0xb9, 0x35, 0x6a, 0xe4, 0xc3, 0xd9, 0xb8, + 0x8e, 0x91, 0x28, 0x37, 0x25, 0xa5, 0x66, 0x62, 0x5d, 0x9c, 0x2}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9e, 0xb, 0x8, 0x1e, 0x95, 0xeb, 0x56, 0x76, 0x15, 0xf0, 0x87, 0x64, 0xbd, - 0x72, 0xcb, 0xb9, 0x62, 0xb0, 0x17, 0xc3, 0x2c, 0x45, 0x45, 0xb9, 0x79}; + uint8_t topic_filter_s3_bytes[] = {0x83, 0x9c, 0xe1, 0x94, 0xb0, 0x4f, 0x35, 0x3, 0xd5, 0xda, 0xd6, 0xae, 0xd6, + 0x53, 0xf2, 0xc6, 0x59, 0x98, 0x32, 0x56, 0x25, 0xbc, 0xde, 0x1d, 0x38}; lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x1f, 0xb0, 0x29, 0x16, 0x33, 0xe, 0xa, 0xa, 0x34, 0x72, 0xbc, 0xa5, 0x76, + 0x6a, 0xd8, 0xbb, 0x5d, 0x25, 0xf3, 0x32, 0x34, 0x34, 0x16, 0xba, 0xa6, 0xd}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xaa, 0x3a, 0xc5, 0xcf, 0xfe, 0x10, 0xda, 0x63, 0xd, 0x86, 0xb8, + 0xeb, 0x0, 0x71, 0x3f, 0xae, 0x92, 0x42, 0xe3, 0xf0, 0xd3}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x97, 0xed, 0x48, 0xd7, 0x4d, 0x97, 0x14, 0x90, + 0xe4, 0xb4, 0x63, 0xd2, 0xb, 0xc3, 0xfb}; + lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xa2, 0xff, 0xfc, 0x11, 0x37, 0x8a, 0x33, 0x2e, 0x9f, 0x57, 0xef, 0xed, 0x7b, + 0x5a, 0x2f, 0x54, 0xe, 0x84, 0xf6, 0xfb, 0xaa, 0xf3, 0xba, 0xa2, 0xb1, 0x37}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe1, 0x29, 0x75, 0x1a, 0xb5, 0x23, 0x17, 0x84, 0x20, 0xd4, + 0xee, 0x47, 0x39, 0x7b, 0x7c, 0x2d, 0x7b, 0x68, 0x3a, 0x40, + 0x72, 0x30, 0xba, 0x72, 0x14, 0xd6, 0xe1, 0x34}; + lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x6c, 0x24}; + lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x3e, 0xd9, 0xb9, 0xa6, 0x15, 0xd8, 0xf8, 0x28, 0xac, 0xc2, 0xbd}; + lwmqtt_string_t topic_filter_s10 = {11, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - uint8_t bytesprops0[] = {0x4c}; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = true; + uint8_t bytesprops0[] = {0xaa, 0x9f, 0x7a, 0xee, 0xba, 0x5e, 0xdf, 0xd2}; + uint8_t bytesprops1[] = {0xb0, 0x70, 0xc0, 0x9c, 0x1f, 0xa, 0xd9, 0x8b, 0x5a, + 0xca, 0x58, 0xea, 0x8c, 0x79, 0x2c, 0xc3, 0x93}; + uint8_t bytesprops2[] = {0xfa, 0x88, 0x41, 0x8a, 0x8f, 0x62, 0xb5, 0x5d, 0x65, 0x2f, 0x56, 0x86, + 0x6c, 0x3d, 0xb9, 0xf8, 0xa, 0x70, 0x81, 0xac, 0x28, 0x1e, 0xba, 0xf}; + uint8_t bytesprops3[] = {0x2f, 0xb8, 0xb5, 0x3e, 0x3e, 0xe7, 0xe, 0xdb, 0x27, 0x93, 0x82, 0xb1, 0xee, 0x72, 0xe9, + 0x20, 0x47, 0x78, 0xc6, 0x46, 0x64, 0xd7, 0xd1, 0x16, 0x2e, 0x12, 0xe, 0xb1, 0x81, 0x2b}; + uint8_t bytesprops4[] = {0xaa}; + uint8_t bytesprops5[] = {0x93, 0x4d, 0x71, 0x5, 0x42, 0x21, 0xf7, 0x8f, 0xed, 0x62, 0x6, 0x23, 0xa3, 0xb0, 0xb3, + 0x1b, 0x60, 0xc6, 0x85, 0xcd, 0x7a, 0x4b, 0x1, 0x5d, 0xcc, 0xac, 0x5a, 0xcb, 0xa5}; + uint8_t bytesprops6[] = {0xe9, 0x7b, 0x87, 0xc, 0xf7, 0x79, 0x26, 0xcc, 0xed, 0xfe, 0x37, 0x6, 0x18, + 0x44, 0x87, 0xd, 0x30, 0xb7, 0x4c, 0x7f, 0x47, 0x63, 0xc2, 0x59, 0x57}; + uint8_t bytesprops7[] = {0x46, 0xa6, 0xec, 0x9f, 0x66, 0x1f, 0xe6, 0x74, 0x30, 0x25, 0xf2, 0xe7, 0xa5, 0xde, + 0x50, 0xe, 0xa3, 0x30, 0xc, 0x47, 0x47, 0x77, 0x8f, 0x5f, 0x47, 0x37, 0x9e, 0xbb}; + uint8_t bytesprops8[] = {0xc7, 0xa2, 0xdc, 0xa4, 0x76, 0xd1, 0xd1, 0x13, 0xd8, 0xe2, 0x34, 0xd7, 0x18, 0x1d, 0xd7, + 0x2d, 0x96, 0xaa, 0xa9, 0xb0, 0xc1, 0x5f, 0x83, 0x94, 0xf2, 0xcd, 0x68, 0x8, 0xc6}; + uint8_t bytesprops9[] = {0x15, 0xd2, 0x80, 0x7a, 0xc8, 0xd0, 0x3e, 0xbe, 0xd9, 0x84, 0xe3, 0x43, 0xb6, 0xef, + 0x76, 0xac, 0xad, 0x2e, 0x33, 0x1a, 0x79, 0x8f, 0xab, 0xe5, 0xb5, 0x90, 0x41}; + uint8_t bytesprops10[] = {0x3e, 0xf2, 0x4e, 0x39, 0xb6}; + uint8_t bytesprops12[] = {0xac, 0x17, 0xa5, 0x42, 0xbd, 0xc4, 0xde, 0xad, 0xf0, 0xc8, 0x9f, 0x4b, 0x0}; + uint8_t bytesprops11[] = {0x9e, 0x8d, 0xfc, 0x96}; + uint8_t bytesprops13[] = {0xba, 0xd5, 0x84, 0xe0, 0x17, 0xed, 0x8d, 0x7, 0x61, 0x17, 0x60, 0x87, 0xc2, + 0xdb, 0xf3, 0xb8, 0x3f, 0xb, 0xeb, 0x62, 0x1b, 0x89, 0xb4, 0x42, 0xc7}; + uint8_t bytesprops14[] = {0xf7, 0x2d, 0x9f, 0x8e, 0x47, 0x34, 0xfa, 0xdf, 0x31, 0xb2, 0xad, 0xdf, 0x90, 0x29}; + uint8_t bytesprops15[] = {0xd1, 0xe, 0x6c, 0xfb, 0xde, 0xc0, 0x14, 0xe, 0x55, 0x12, 0x1f, 0xc7, 0x69, 0xd3, + 0xc1, 0xf8, 0x8a, 0x1d, 0xe7, 0xca, 0xdf, 0x80, 0xd6, 0xb8, 0x5e, 0x87, 0xf0, 0x53}; + uint8_t bytesprops16[] = {0x9f, 0x23, 0x8e, 0xe9, 0x22, 0x9a, 0x14, 0xd6, 0x69, 0x6b, 0x6d, 0x96, 0x1e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28284}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8290}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4943}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9948}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31659}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4540}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24650}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops11}, .v = {13, (char*)&bytesprops12}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops16}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7285}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29705, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7994, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30426 [("\SYNez\ACK\162N\176`#\DLEr6\206\183\167\183\224\241\&4OY\ENQ\162'\169\187\136A",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("mD\188mxN\232n\174\197\149e\174/\"\187\196\138\131\232",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\193]\DC2\n\228\224l6\162\149f\"J.\240\202",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),(":q\223\215|h\a\208G\164\\~\231q_R\131\211\242\198\EM\CAN\220(\158\DLE\133",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\225\243\168\&79\184\251\210N\f>-\149\138K\n\155\217\220\DC33T\250\255UB=\188\RS",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("_\174@\222\188\207\224\212\179\190C\206",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\165\SYN\186\167:\ETX\214\DC2\145O\237\221\197",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic -// ">\197d\SOH\141\182\233\152\161e3\\'F\NUL\242\238\201\137>\226`d\247\216\f",PropUserProperty -// "\DLEC\133\DEL)fF;hO\202+\136\v\160\197i\238\DC1\215" -// "\212n\170#\146\197]\216\179\237\237K,B\227\"\190\DEL\ETXeIS\196",PropWillDelayInterval -// 20679,PropAuthenticationMethod "\\\254\&1\196^^\175b\136\ESC4d@n\241\STXs>'W\\=:w",PropMaximumPacketSize -// 3791,PropServerKeepAlive 29126,PropResponseTopic "\137\SI",PropMessageExpiryInterval 2636,PropServerKeepAlive -// 7512,PropRequestProblemInformation 204,PropSessionExpiryInterval 10542,PropTopicAlias 2720,PropMaximumPacketSize -// 30315,PropResponseInformation -// "\221\CAN\229\NAK\164\195\155\SOH\244\193\"\t\140\133\140\206\216\158\211\242\DLE\210",PropSubscriptionIdentifierAvailable -// 131,PropTopicAliasMaximum 31102,PropAuthenticationMethod "x\159d\133\SOH\161\198fD",PropAuthenticationMethod "Z\197"] +// SubscribeRequest 23842 [("\140\185\224\250R\251\"\210\238\130\148\253\176\167\230\DELx%",SubOptions {_retainHandling +// = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("k\157(%\238\144\NAK\133\246\206\163w\161\180x5X\SI\SYN(\130\224u\222\247\155\175\200",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\188k9#!@s.\150+\ETBF\197\DC3i\159Z\197,\214\167\253\245\aE",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("+\194\188\205\157\178\221\t\245\213\254W\129\251A\aV\219\210\b\229<\149\204&\201\196\182U",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\222\146\234\140\195c\209LL$\222\179\153\DEL\208\218\132\209\214%\139\228\230",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\CAN\151aE\174\174\225\221%N\238d\SI\187",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropWillDelayInterval 6427,PropServerReference +// "r\241:\181\231\231xy\251w\214\145[",PropMessageExpiryInterval 8166,PropSessionExpiryInterval +// 1244,PropRequestProblemInformation 241,PropSharedSubscriptionAvailable 206,PropRequestProblemInformation +// 179,PropTopicAliasMaximum 3266,PropContentType "\220;\ACK\SOH\229\228&S9{b\143\171J\133$cX",PropReceiveMaximum +// 27044,PropPayloadFormatIndicator 233,PropCorrelationData +// "\158\t\SO\149G,o\EM\133\196\182\224\&7\230\171}*\DEL\\\238\195",PropUserProperty "D\246\216\237^\159\ENQ\150t Nb" +// "",PropUserProperty "\201\132@h\202\139\192\221\DC2\241m\175s;\182\FS\128\227\159\225\208\247\ETB\196\237\255\182g" +// "\214\250\131%\195\195IG\138X\250\217",PropWillDelayInterval 20526,PropSubscriptionIdentifier +// 8,PropSessionExpiryInterval 21501,PropSubscriptionIdentifier 31,PropMaximumPacketSize 30816,PropMessageExpiryInterval +// 12097,PropMaximumQoS 191,PropWillDelayInterval 14550,PropMessageExpiryInterval 10328,PropMessageExpiryInterval +// 19723,PropMaximumQoS 67,PropWillDelayInterval 31618,PropResponseTopic +// "\218\254\b\221\224\253\168\183\161\181\b\128\181" -// "\141\239\221w\227\244)\a\DLE2h\170js\203\165\&1\214*",PropResponseInformation " -// J>!\132\t\146\FS\144x\187\154d\166\130\&6\143$JH\216\185\227",PropPayloadFormatIndicator 134] +// SubscribeRequest 26921 [("K3\SI\145\&6N\152\205\207\211\175\226(",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\232\&0\ESC1 |\197\148\&8\225\CAN*\229",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] +// [PropReceiveMaximum 15170,PropMaximumQoS 125,PropServerKeepAlive 6331,PropAssignedClientIdentifier +// ">\211\130\153t\NAKk7\214D\ACKq\GS\150\243\233nW\160=\249(",PropReceiveMaximum 19285,PropSessionExpiryInterval +// 22725,PropSessionExpiryInterval 28884,PropSubscriptionIdentifierAvailable 49,PropSubscriptionIdentifierAvailable +// 194,PropRequestProblemInformation 1,PropTopicAliasMaximum 7896,PropSessionExpiryInterval 7833] TEST(Subscribe5QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x94, 0x1, 0x55, 0xe3, 0x48, 0x2, 0x0, 0x0, 0xd, 0x15, 0x3, 0x0, 0x6, 0x43, 0xec, 0xa, - 0xe8, 0xa2, 0x4b, 0x26, 0x0, 0x6, 0x91, 0xa2, 0x6a, 0xc3, 0x3e, 0xb5, 0x0, 0x13, 0x8d, 0xef, 0xdd, - 0x77, 0xe3, 0xf4, 0x29, 0x7, 0x10, 0x32, 0x68, 0xaa, 0x6a, 0x73, 0xcb, 0xa5, 0x31, 0xd6, 0x2a, 0x1a, - 0x0, 0x17, 0x20, 0x4a, 0x3e, 0x21, 0x84, 0x9, 0x92, 0x1c, 0x90, 0x78, 0xbb, 0x9a, 0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eof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x4b, 0x33, 0xf, 0x91, 0x36, 0x4e, 0x98, 0xcd, 0xcf, 0xd3, 0xaf, 0xe2, 0x28}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x43, 0x7a, 0xeb, 0xc, 0xec, 0x9e, 0x27, 0x3d, 0xbe}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe8, 0x30, 0x1b, 0x31, 0x20, 0x7c, 0xc5, 0x94, 0x38, 0xe1, 0x18, 0x2a, 0xe5}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6c, 0xa6, 0x3d, 0xd2, 0xf2, 0x6b, 0xc2, 0xa2, 0x10, - 0x7d, 0x77, 0x94, 0xca, 0x57, 0xd8, 0x1f, 0xb2, 0xc}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x78, 0x9, 0xe, 0xe0, 0x83, 0x5, 0x5c, 0xed, 0xdd, 0xa8, 0xf6, - 0x26, 0x78, 0x2, 0xf6, 0x54, 0xe4, 0xf9, 0xc2, 0x81, 0x1a}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xdf, 0xf, 0xff, 0xeb, 0xfa, 0x86, 0x3, 0xb2, 0x75, 0xd2}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - uint8_t bytesprops0[] = {0x43, 0xec, 0xa, 0xe8, 0xa2, 0x4b}; - uint8_t bytesprops2[] = {0x8d, 0xef, 0xdd, 0x77, 0xe3, 0xf4, 0x29, 0x7, 0x10, 0x32, - 0x68, 0xaa, 0x6a, 0x73, 0xcb, 0xa5, 0x31, 0xd6, 0x2a}; - uint8_t bytesprops1[] = {0x91, 0xa2, 0x6a, 0xc3, 0x3e, 0xb5}; - uint8_t bytesprops3[] = {0x20, 0x4a, 0x3e, 0x21, 0x84, 0x9, 0x92, 0x1c, 0x90, 0x78, 0xbb, 0x9a, - 0x64, 0xa6, 0x82, 0x36, 0x8f, 0x24, 0x4a, 0x48, 0xd8, 0xb9, 0xe3}; + uint8_t bytesprops0[] = {0x3e, 0xd3, 0x82, 0x99, 0x74, 0x15, 0x6b, 0x37, 0xd6, 0x44, 0x6, + 0x71, 0x1d, 0x96, 0xf3, 0xe9, 0x6e, 0x57, 0xa0, 0x3d, 0xf9, 0x28}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3349}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {19, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15170}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6331}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19285}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22725}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28884}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7896}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7833}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21987, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26921, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23704 [("t \154\149\224\EM\158fEc\239\249\&6\231\DC4\159",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\253\\\220\193&\209[",SubOptions +// SubscribeRequest 21060 [("|\157\247\167%X\146\239\FSa@\163\225",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),(".\147\177\f\201\211\245\229\237\RS",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\EOT\149z\193\&2\140\137\131\155#}#h\153\&4",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("oo\189n\216\174\b[\219d\225\166\b\146^/\138\130\132[\235",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\176\&5\141\&1\143<\138xIV~\187\\\234\250Sa\US\240\219w8vTXw",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\164\153\198\218k\176b\231\SO",SubOptions // {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("e",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("R[&",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("^\169\135\136\143\241q\SI\254\254",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropAuthenticationData " -// \168|\206\130&N\174en2aK\138",PropAssignedClientIdentifier -// "\215`\195\147\209\b\197V\184&5\161\137\215PD",PropSubscriptionIdentifierAvailable 121,PropResponseTopic -// "B\ae\234\GS\148\192\128\159X",PropRequestResponseInformation 196,PropWildcardSubscriptionAvailable -// 36,PropSharedSubscriptionAvailable 186,PropSubscriptionIdentifier 29,PropWillDelayInterval -// 23802,PropSubscriptionIdentifier 0,PropRequestResponseInformation 106,PropTopicAlias 30327,PropServerKeepAlive -// 7428,PropAuthenticationData "\ESC\177|@\239\GS\228\SYNTB\ENQ*\RS\248\214l\244\172\145\237/",PropResponseTopic -// "\159qn\179H5\158k\146",PropTopicAlias 10678,PropWillDelayInterval 31517,PropMessageExpiryInterval 1842] +// QoS2}),("Y\156\203\236\EOT\225\149\165[\246\158\US(\248",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\140\170^\229\250K\220\216\241\233\146\"",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe5QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0xb2, 0x1, 0x5c, 0x98, 0x7b, 0x16, 0x0, 0xe, 0x20, 0xa8, 0x7c, 0xce, 0x82, 0x26, 0x4e, 0xae, - 0x65, 0x6e, 0x32, 0x61, 0x4b, 0x8a, 0x12, 0x0, 0x10, 0xd7, 0x60, 0xc3, 0x93, 0xd1, 0x8, 0xc5, 0x56, - 0xb8, 0x26, 0x35, 0xa1, 0x89, 0xd7, 0x50, 0x44, 0x29, 0x79, 0x8, 0x0, 0xa, 0x42, 0x7, 0x65, 0xea, - 0x1d, 0x94, 0xc0, 0x80, 0x9f, 0x58, 0x19, 0xc4, 0x28, 0x24, 0x2a, 0xba, 0xb, 0x1d, 0x18, 0x0, 0x0, - 0x5c, 0xfa, 0xb, 0x0, 0x19, 0x6a, 0x23, 0x76, 0x77, 0x13, 0x1d, 0x4, 0x16, 0x0, 0x15, 0x1b, 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 0x49, 0x56, 0x7e, 0xbb, 0x5c, 0xea, 0xfa, 0x53, 0x61, 0x1f, 0xf0, 0xdb, 0x77, 0x38, 0x76, + 0x54, 0x58, 0x77, 0xd, 0x0, 0x9, 0xa4, 0x99, 0xc6, 0xda, 0x6b, 0xb0, 0x62, 0xe7, 0xe, 0x2a, 0x0, + 0xe, 0x59, 0x9c, 0xcb, 0xec, 0x4, 0xe1, 0x95, 0xa5, 0x5b, 0xf6, 0x9e, 0x1f, 0x28, 0xf8, 0x22, 0x0, + 0xc, 0x8c, 0xaa, 0x5e, 0xe5, 0xfa, 0x4b, 0xdc, 0xd8, 0xf1, 0xe9, 0x92, 0x22, 0x20}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x74, 0x20, 0x9a, 0x95, 0xe0, 0x19, 0x9e, 0x66, - 0x45, 0x63, 0xef, 0xf9, 0x36, 0xe7, 0x14, 0x9f}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x7c, 0x9d, 0xf7, 0xa7, 0x25, 0x58, 0x92, 0xef, 0x1c, 0x61, 0x40, 0xa3, 0xe1}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfd, 0x5c, 0xdc, 0xc1, 0x26, 0xd1, 0x5b}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2e, 0x93, 0xb1, 0xc, 0xc9, 0xd3, 0xf5, 0xe5, 0xed, 0x1e}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x65}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4, 0x95, 0x7a, 0xc1, 0x32, 0x8c, 0x89, 0x83, + 0x9b, 0x23, 0x7d, 0x23, 0x68, 0x99, 0x34}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x52, 0x5b, 0x26}; - lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6f, 0x6f, 0xbd, 0x6e, 0xd8, 0xae, 0x8, 0x5b, 0xdb, 0x64, 0xe1, + 0xa6, 0x8, 0x92, 0x5e, 0x2f, 0x8a, 0x82, 0x84, 0x5b, 0xeb}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5e, 0xa9, 0x87, 0x88, 0x8f, 0xf1, 0x71, 0xf, 0xfe, 0xfe}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xb0, 0x35, 0x8d, 0x31, 0x8f, 0x3c, 0x8a, 0x78, 0x49, 0x56, 0x7e, 0xbb, 0x5c, + 0xea, 0xfa, 0x53, 0x61, 0x1f, 0xf0, 0xdb, 0x77, 0x38, 0x76, 0x54, 0x58, 0x77}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; + uint8_t topic_filter_s5_bytes[] = {0xa4, 0x99, 0xc6, 0xda, 0x6b, 0xb0, 0x62, 0xe7, 0xe}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x59, 0x9c, 0xcb, 0xec, 0x4, 0xe1, 0x95, 0xa5, 0x5b, 0xf6, 0x9e, 0x1f, 0x28, 0xf8}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x8c, 0xaa, 0x5e, 0xe5, 0xfa, 0x4b, 0xdc, 0xd8, 0xf1, 0xe9, 0x92, 0x22}; + lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = true; - uint8_t bytesprops0[] = {0x20, 0xa8, 0x7c, 0xce, 0x82, 0x26, 0x4e, 0xae, 0x65, 0x6e, 0x32, 0x61, 0x4b, 0x8a}; - uint8_t bytesprops1[] = {0xd7, 0x60, 0xc3, 0x93, 0xd1, 0x8, 0xc5, 0x56, - 0xb8, 0x26, 0x35, 0xa1, 0x89, 0xd7, 0x50, 0x44}; - uint8_t bytesprops2[] = {0x42, 0x7, 0x65, 0xea, 0x1d, 0x94, 0xc0, 0x80, 0x9f, 0x58}; - uint8_t bytesprops3[] = {0x1b, 0xb1, 0x7c, 0x40, 0xef, 0x1d, 0xe4, 0x16, 0x54, 0x42, 0x5, - 0x2a, 0x1e, 0xf8, 0xd6, 0x6c, 0xf4, 0xac, 0x91, 0xed, 0x2f}; - uint8_t bytesprops4[] = {0x9f, 0x71, 0x6e, 0xb3, 0x48, 0x35, 0x9e, 0x6b, 0x92}; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 29}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23802}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30327}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7428}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10678}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31517}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1842}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23704, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21060, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25818 [("\235\&1\a\173\150\175\208\&8",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropSubscriptionIdentifierAvailable -// 144,PropPayloadFormatIndicator 206,PropMaximumPacketSize 27231,PropRequestResponseInformation 156,PropResponseTopic -// "_\211\188\198\192<\aE\211\217\248\139\251y\245\233\166\230P\232d\216\141:\208\131\EOT\130",PropSubscriptionIdentifierAvailable -// 1,PropAuthenticationData -// "\211~\162\CAN\ETBX\231\DEL\SOH\205\177\254\234N\ETB)\216\167\252\DELi\136\222",PropReceiveMaximum -// 2956,PropPayloadFormatIndicator 15,PropUserProperty "a -// (\135\161^\156\ACK\DC2\133/\136T\243\152\236\252\DEL\165MV\227r\128" -// "\235R>\DLE\166&\218\130\157\211\167\NAK{\227\NUL\174\169\191q"] +// SubscribeRequest 18677 [("=\161\253\230\ACK|8",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = True, _subQoS = +// QoS0}),("$wX\204\158I\216\&9c\142@\195\248\186>\SUBi\SYN\165H\212\242\&3;",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\153\231\243Nc7\160^\177\204:\236\247\fCy\174\181\172\131A",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropTopicAlias +// 19406,PropTopicAlias 1380,PropCorrelationData "\200\148\&2[\251\r\ETB\234",PropSubscriptionIdentifierAvailable +// 14,PropResponseTopic "\193/\209\206\US\155-",PropServerKeepAlive 3091,PropCorrelationData +// "N\230\178\252OC\DEL\174\253p\250;\223M\222F\SO",PropMaximumQoS 220,PropSubscriptionIdentifier +// 32,PropSubscriptionIdentifierAvailable 34,PropMessageExpiryInterval 12666,PropCorrelationData +// "\CAN",PropRequestResponseInformation 197,PropSessionExpiryInterval 5342,PropWillDelayInterval +// 9931,PropMessageExpiryInterval 4431,PropTopicAliasMaximum 24873,PropRequestProblemInformation 210,PropServerKeepAlive +// 20259,PropTopicAlias 32129,PropRequestProblemInformation 253,PropReasonString "\134",PropMessageExpiryInterval +// 22401,PropSharedSubscriptionAvailable 51,PropTopicAlias 8670,PropSharedSubscriptionAvailable 252,PropServerReference +// ".ae\252\215",PropAuthenticationMethod +// "\235C\205\250\RS\181:O\CAN\156\248\204,b\NUL\148\196g\183\151\161",PropReceiveMaximum 25059] TEST(Subscribe5QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x89, 0x1, 0x64, 0xda, 0x7b, 0x29, 0x90, 0x1, 0xce, 0x27, 0x0, 0x0, 0x6a, 0x5f, 0x19, - 0x9c, 0x8, 0x0, 0x1c, 0x5f, 0xd3, 0xbc, 0xc6, 0xc0, 0x3c, 0x7, 0x45, 0xd3, 0xd9, 0xf8, 0x8b, - 0xfb, 0x79, 0xf5, 0xe9, 0xa6, 0xe6, 0x50, 0xe8, 0x64, 0xd8, 0x8d, 0x3a, 0xd0, 0x83, 0x4, 0x82, - 0x29, 0x1, 0x16, 0x0, 0x17, 0xd3, 0x7e, 0xa2, 0x18, 0x17, 0x58, 0xe7, 0x7f, 0x1, 0xcd, 0xb1, - 0xfe, 0xea, 0x4e, 0x17, 0x29, 0xd8, 0xa7, 0xfc, 0x7f, 0x69, 0x88, 0xde, 0x21, 0xb, 0x8c, 0x1, - 0xf, 0x26, 0x0, 0x18, 0x61, 0x20, 0x28, 0x87, 0xa1, 0x5e, 0x9c, 0x6, 0x12, 0x85, 0x2f, 0x88, - 0x54, 0xf3, 0x98, 0xec, 0xfc, 0x7f, 0xa5, 0x4d, 0x56, 0xe3, 0x72, 0x80, 0x0, 0x13, 0xeb, 0x52, - 0x3e, 0x10, 0xa6, 0x26, 0xda, 0x82, 0x9d, 0xd3, 0xa7, 0x15, 0x7b, 0xe3, 0x0, 0xae, 0xa9, 0xbf, - 0x71, 0x0, 0x8, 0xeb, 0x31, 0x7, 0xad, 0x96, 0xaf, 0xd0, 0x38, 0x29}; + uint8_t pkt[] = {0x82, 0xd5, 0x1, 0x48, 0xf5, 0x94, 0x1, 0x23, 0x4b, 0xce, 0x23, 0x5, 0x64, 0x9, 0x0, 0x8, 0xc8, + 0x94, 0x32, 0x5b, 0xfb, 0xd, 0x17, 0xea, 0x29, 0xe, 0x8, 0x0, 0x7, 0xc1, 0x2f, 0xd1, 0xce, 0x1f, + 0x9b, 0x2d, 0x13, 0xc, 0x13, 0x9, 0x0, 0x11, 0x4e, 0xe6, 0xb2, 0xfc, 0x4f, 0x43, 0x7f, 0xae, 0xfd, + 0x70, 0xfa, 0x3b, 0xdf, 0x4d, 0xde, 0x46, 0xe, 0x24, 0xdc, 0xb, 0x20, 0x29, 0x22, 0x2, 0x0, 0x0, + 0x31, 0x7a, 0x9, 0x0, 0x1, 0x18, 0x19, 0xc5, 0x11, 0x0, 0x0, 0x14, 0xde, 0x18, 0x0, 0x0, 0x26, + 0xcb, 0x2, 0x0, 0x0, 0x11, 0x4f, 0x22, 0x61, 0x29, 0x17, 0xd2, 0x13, 0x4f, 0x23, 0x23, 0x7d, 0x81, + 0x17, 0xfd, 0x1f, 0x0, 0x1, 0x86, 0x2, 0x0, 0x0, 0x57, 0x81, 0x2a, 0x33, 0x23, 0x21, 0xde, 0x2a, + 0xfc, 0x1c, 0x0, 0x5, 0x2e, 0x61, 0x65, 0xfc, 0xd7, 0x15, 0x0, 0x15, 0xeb, 0x43, 0xcd, 0xfa, 0x1e, + 0xb5, 0x3a, 0x4f, 0x18, 0x9c, 0xf8, 0xcc, 0x2c, 0x62, 0x0, 0x94, 0xc4, 0x67, 0xb7, 0x97, 0xa1, 0x21, + 0x61, 0xe3, 0x0, 0x7, 0x3d, 0xa1, 0xfd, 0xe6, 0x6, 0x7c, 0x38, 0x2c, 0x0, 0x18, 0x24, 0x77, 0x58, + 0xcc, 0x9e, 0x49, 0xd8, 0x39, 0x63, 0x8e, 0x40, 0xc3, 0xf8, 0xba, 0x3e, 0x1a, 0x69, 0x16, 0xa5, 0x48, + 0xd4, 0xf2, 0x33, 0x3b, 0x15, 0x0, 0x15, 0x99, 0xe7, 0xf3, 0x4e, 0x63, 0x37, 0xa0, 0x5e, 0xb1, 0xcc, + 0x3a, 0xec, 0xf7, 0xc, 0x43, 0x79, 0xae, 0xb5, 0xac, 0x83, 0x41, 0x2e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xeb, 0x31, 0x7, 0xad, 0x96, 0xaf, 0xd0, 0x38}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x3d, 0xa1, 0xfd, 0xe6, 0x6, 0x7c, 0x38}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s1_bytes[] = {0x24, 0x77, 0x58, 0xcc, 0x9e, 0x49, 0xd8, 0x39, 0x63, 0x8e, 0x40, 0xc3, + 0xf8, 0xba, 0x3e, 0x1a, 0x69, 0x16, 0xa5, 0x48, 0xd4, 0xf2, 0x33, 0x3b}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x99, 0xe7, 0xf3, 0x4e, 0x63, 0x37, 0xa0, 0x5e, 0xb1, 0xcc, 0x3a, + 0xec, 0xf7, 0xc, 0x43, 0x79, 0xae, 0xb5, 0xac, 0x83, 0x41}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - uint8_t bytesprops0[] = {0x5f, 0xd3, 0xbc, 0xc6, 0xc0, 0x3c, 0x7, 0x45, 0xd3, 0xd9, 0xf8, 0x8b, 0xfb, 0x79, - 0xf5, 0xe9, 0xa6, 0xe6, 0x50, 0xe8, 0x64, 0xd8, 0x8d, 0x3a, 0xd0, 0x83, 0x4, 0x82}; - uint8_t bytesprops1[] = {0xd3, 0x7e, 0xa2, 0x18, 0x17, 0x58, 0xe7, 0x7f, 0x1, 0xcd, 0xb1, 0xfe, - 0xea, 0x4e, 0x17, 0x29, 0xd8, 0xa7, 0xfc, 0x7f, 0x69, 0x88, 0xde}; - uint8_t bytesprops3[] = {0xeb, 0x52, 0x3e, 0x10, 0xa6, 0x26, 0xda, 0x82, 0x9d, 0xd3, - 0xa7, 0x15, 0x7b, 0xe3, 0x0, 0xae, 0xa9, 0xbf, 0x71}; - uint8_t bytesprops2[] = {0x61, 0x20, 0x28, 0x87, 0xa1, 0x5e, 0x9c, 0x6, 0x12, 0x85, 0x2f, 0x88, - 0x54, 0xf3, 0x98, 0xec, 0xfc, 0x7f, 0xa5, 0x4d, 0x56, 0xe3, 0x72, 0x80}; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + uint8_t bytesprops0[] = {0xc8, 0x94, 0x32, 0x5b, 0xfb, 0xd, 0x17, 0xea}; + uint8_t bytesprops1[] = {0xc1, 0x2f, 0xd1, 0xce, 0x1f, 0x9b, 0x2d}; + uint8_t bytesprops2[] = {0x4e, 0xe6, 0xb2, 0xfc, 0x4f, 0x43, 0x7f, 0xae, 0xfd, + 0x70, 0xfa, 0x3b, 0xdf, 0x4d, 0xde, 0x46, 0xe}; + uint8_t bytesprops3[] = {0x18}; + uint8_t bytesprops4[] = {0x86}; + uint8_t bytesprops5[] = {0x2e, 0x61, 0x65, 0xfc, 0xd7}; + uint8_t bytesprops6[] = {0xeb, 0x43, 0xcd, 0xfa, 0x1e, 0xb5, 0x3a, 0x4f, 0x18, 0x9c, 0xf8, + 0xcc, 0x2c, 0x62, 0x0, 0x94, 0xc4, 0x67, 0xb7, 0x97, 0xa1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27231}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2956}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops2}, .v = {19, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19406}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1380}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3091}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 32}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12666}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5342}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9931}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4431}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24873}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20259}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32129}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22401}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8670}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25059}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25818, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18677, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19332 [("-\196\154\190n\186/h\n\161\203p\157Ap",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("~\210\229q\182\141\167%]a\fh\248\233\253\167>\NAKu\US\STX\133:",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\144;#\ENQ\236h-\ETX\243\164R3\237\241\129\171\225",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\254\167a\227\GS\169X\240\139\CAN\242\212K\164g]T\203\246\141",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\252=6J\200\227L",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("U\199y\ETX\222\t\"\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = -// True, _subQoS = QoS2}),("\202\SUB\220\214,g\158Ugne6\221\DLE\222}n\252\&1w/\NUL\171\244vou",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("-\SO\230DQ\130\178\\\129\&2i",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS0}),("\205\132\136\DC2y",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ACK)\174\200\186",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\140\197o\USH\162P\197x$\209\218\SI\172\GS\176\147\204\148\CAN\226\CAN",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropServerReference -// "`\SYN\DC1\153a\bn{xL\165p\242}?",PropAuthenticationData "\158\156\v\243) '4}}\SUB-\a",PropSessionExpiryInterval -// 15033,PropContentType "",PropSharedSubscriptionAvailable 192,PropAuthenticationData -// "\200\178\228\203i\203\185\US\135\170\v\227r\239\151\&6\EOT\141d\196&\241\145\234\179",PropUserProperty -// "\151\SUB\174\204\214\158" "T\138\253u\229\193!\158+\145J",PropReasonString -// "\252%8\154V\233\204\191\241\DC3l\244\DC4\246\252|`",PropSharedSubscriptionAvailable 67,PropReasonString -// "\STX",PropAssignedClientIdentifier -// "m2\197\179\208\191\193\230\181\DC3\168\137?.\ENQ\US\145RM\158(",PropMessageExpiryInterval -// 29660,PropMaximumPacketSize 2329,PropSubscriptionIdentifier 21,PropAuthenticationMethod -// "\RS)C&E\143m\241\169\US\205e<+\240@\220\254\172\169\241\SIc9\141",PropResponseTopic -// "\SYN*\216!\139\&1\224\&5K=\147K1\145\149:\133rB\156{\GS\188-",PropMessageExpiryInterval -// 1646,PropSubscriptionIdentifierAvailable 78,PropWillDelayInterval 23060,PropSubscriptionIdentifierAvailable 83] +// SubscribeRequest 15426 [(">,\208\132\222\237\163V\189v\141\DC4<\218\135\r(U",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropSubscriptionIdentifierAvailable 250,PropResponseInformation "\237t",PropMessageExpiryInterval +// 6544,PropMaximumQoS 212,PropRequestProblemInformation 23,PropRequestResponseInformation 220,PropResponseInformation +// "\236\250\185\236O\167\245\211\195\249\ETBfEj\164\152\174H<\"",PropServerKeepAlive 25666,PropWillDelayInterval +// 7275,PropRetainAvailable 129,PropResponseTopic +// "\ETX+\a\NUL\SUB\247\145\223\201\152k]3M\"\152\233om\139\SO\STX\174yQQj\163\227\167\SI",PropWildcardSubscriptionAvailable 63,PropAuthenticationMethod +// "\EM\163\200\208\DC1\149\182Q/\f)\161\206\252\221\142\&0C\219P%\158\245\202\154g",PropSharedSubscriptionAvailable +// 52,PropSessionExpiryInterval 15259] TEST(Subscribe5QCTest, Encode27) { - uint8_t pkt[] = { - 0x82, 0xa6, 0x3, 0x4b, 0x84, 0xe1, 0x1, 0x1c, 0x0, 0xf, 0x60, 0x16, 0x11, 0x99, 0x61, 0x8, 0x6e, 0x7b, 0x78, - 0x4c, 0xa5, 0x70, 0xf2, 0x7d, 0x3f, 0x16, 0x0, 0xd, 0x9e, 0x9c, 0xb, 0xf3, 0x29, 0x20, 0x27, 0x34, 0x7d, 0x7d, - 0x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0xa7, 0xf, 0x28, 0x3f, 0x15, 0x0, 0x1a, 0x19, 0xa3, 0xc8, 0xd0, 0x11, 0x95, 0xb6, 0x51, 0x2f, 0xc, + 0x29, 0xa1, 0xce, 0xfc, 0xdd, 0x8e, 0x30, 0x43, 0xdb, 0x50, 0x25, 0x9e, 0xf5, 0xca, 0x9a, 0x67, 0x2a, + 0x34, 0x11, 0x0, 0x0, 0x3b, 0x9b, 0x0, 0x12, 0x3e, 0x2c, 0xd0, 0x84, 0xde, 0xed, 0xa3, 0x56, 0xbd, + 0x76, 0x8d, 0x14, 0x3c, 0xda, 0x87, 0xd, 0x28, 0x55, 0x22}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x2d, 0xc4, 0x9a, 0xbe, 0x6e, 0xba, 0x2f, 0x68, - 0xa, 0xa1, 0xcb, 0x70, 0x9d, 0x41, 0x70}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x3e, 0x2c, 0xd0, 0x84, 0xde, 0xed, 0xa3, 0x56, 0xbd, + 0x76, 0x8d, 0x14, 0x3c, 0xda, 0x87, 0xd, 0x28, 0x55}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7e, 0xd2, 0xe5, 0x71, 0xb6, 0x8d, 0xa7, 0x25, 0x5d, 0x61, 0xc, 0x68, - 0xf8, 0xe9, 0xfd, 0xa7, 0x3e, 0x15, 0x75, 0x1f, 0x2, 0x85, 0x3a}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x90, 0x3b, 0x23, 0x5, 0xec, 0x68, 0x2d, 0x3, 0xf3, - 0xa4, 0x52, 0x33, 0xed, 0xf1, 0x81, 0xab, 0xe1}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfe, 0xa7, 0x61, 0xe3, 0x1d, 0xa9, 0x58, 0xf0, 0x8b, 0x18, - 0xf2, 0xd4, 0x4b, 0xa4, 0x67, 0x5d, 0x54, 0xcb, 0xf6, 0x8d}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xfc, 0x3d, 0x36, 0x4a, 0xc8, 0xe3, 0x4c}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x55, 0xc7, 0x79, 0x3, 0xde, 0x9, 0x22, 0xe8}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xca, 0x1a, 0xdc, 0xd6, 0x2c, 0x67, 0x9e, 0x55, 0x67, 0x6e, 0x65, 0x36, 0xdd, 0x10, - 0xde, 0x7d, 0x6e, 0xfc, 0x31, 0x77, 0x2f, 0x0, 0xab, 0xf4, 0x76, 0x6f, 0x75}; - lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x2d, 0xe, 0xe6, 0x44, 0x51, 0x82, 0xb2, 0x5c, 0x81, 0x32, 0x69}; - lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xcd, 0x84, 0x88, 0x12, 0x79}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x6, 0x29, 0xae, 0xc8, 0xba}; - lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x8c, 0xc5, 0x6f, 0x1f, 0x48, 0xa2, 0x50, 0xc5, 0x78, 0x24, 0xd1, - 0xda, 0xf, 0xac, 0x1d, 0xb0, 0x93, 0xcc, 0x94, 0x18, 0xe2, 0x18}; - lwmqtt_string_t topic_filter_s10 = {22, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = true; - sub_opts[10].no_local = true; - uint8_t bytesprops0[] = {0x60, 0x16, 0x11, 0x99, 0x61, 0x8, 0x6e, 0x7b, 0x78, 0x4c, 0xa5, 0x70, 0xf2, 0x7d, 0x3f}; - uint8_t bytesprops1[] = {0x9e, 0x9c, 0xb, 0xf3, 0x29, 0x20, 0x27, 0x34, 0x7d, 0x7d, 0x1a, 0x2d, 0x7}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0xc8, 0xb2, 0xe4, 0xcb, 0x69, 0xcb, 0xb9, 0x1f, 0x87, 0xaa, 0xb, 0xe3, 0x72, - 0xef, 0x97, 0x36, 0x4, 0x8d, 0x64, 0xc4, 0x26, 0xf1, 0x91, 0xea, 0xb3}; - uint8_t bytesprops5[] = {0x54, 0x8a, 0xfd, 0x75, 0xe5, 0xc1, 0x21, 0x9e, 0x2b, 0x91, 0x4a}; - uint8_t bytesprops4[] = {0x97, 0x1a, 0xae, 0xcc, 0xd6, 0x9e}; - uint8_t bytesprops6[] = {0xfc, 0x25, 0x38, 0x9a, 0x56, 0xe9, 0xcc, 0xbf, 0xf1, - 0x13, 0x6c, 0xf4, 0x14, 0xf6, 0xfc, 0x7c, 0x60}; - uint8_t bytesprops7[] = {0x2}; - uint8_t bytesprops8[] = {0x6d, 0x32, 0xc5, 0xb3, 0xd0, 0xbf, 0xc1, 0xe6, 0xb5, 0x13, 0xa8, - 0x89, 0x3f, 0x2e, 0x5, 0x1f, 0x91, 0x52, 0x4d, 0x9e, 0x28}; - uint8_t bytesprops9[] = {0x1e, 0x29, 0x43, 0x26, 0x45, 0x8f, 0x6d, 0xf1, 0xa9, 0x1f, 0xcd, 0x65, 0x3c, - 0x2b, 0xf0, 0x40, 0xdc, 0xfe, 0xac, 0xa9, 0xf1, 0xf, 0x63, 0x39, 0x8d}; - uint8_t bytesprops10[] = {0x16, 0x2a, 0xd8, 0x21, 0x8b, 0x31, 0xe0, 0x35, 0x4b, 0x3d, 0x93, 0x4b, - 0x31, 0x91, 0x95, 0x3a, 0x85, 0x72, 0x42, 0x9c, 0x7b, 0x1d, 0xbc, 0x2d}; + sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0xed, 0x74}; + uint8_t bytesprops1[] = {0xec, 0xfa, 0xb9, 0xec, 0x4f, 0xa7, 0xf5, 0xd3, 0xc3, 0xf9, + 0x17, 0x66, 0x45, 0x6a, 0xa4, 0x98, 0xae, 0x48, 0x3c, 0x22}; + uint8_t bytesprops2[] = {0x3, 0x2b, 0x7, 0x0, 0x1a, 0xf7, 0x91, 0xdf, 0xc9, 0x98, 0x6b, 0x5d, 0x33, 0x4d, + 0x22, 0x98, 0xe9, 0x6f, 0x6d, 0x8b, 0x3c, 0x6a, 0x8e, 0x2f, 0x27, 0xac, 0xda}; + uint8_t bytesprops3[] = {0x9c, 0x95, 0x4, 0xfc, 0x20, 0x93, 0xe8, 0x99, 0x8, 0x1a, 0xd6, 0x82, 0x53, 0x88, 0x9f, + 0x62, 0x5d, 0x3a, 0xf8, 0x2c, 0x37, 0x86, 0xef, 0xa3, 0x1a, 0x17, 0x54, 0x7, 0x7c, 0xe2}; + uint8_t bytesprops4[] = {0xa9, 0x1e, 0x66, 0xc6, 0x6a, 0x7f, 0x78, 0x2f, + 0x5f, 0x20, 0x5f, 0x87, 0x2c, 0xeb, 0x57, 0x27}; + uint8_t bytesprops5[] = {0xd7, 0xe, 0x91, 0x34, 0x23, 0x3e, 0xe, 0x2, 0xae, + 0x79, 0x51, 0x51, 0x6a, 0xa3, 0xe3, 0xa7, 0xf}; + uint8_t bytesprops6[] = {0x19, 0xa3, 0xc8, 0xd0, 0x11, 0x95, 0xb6, 0x51, 0x2f, 0xc, 0x29, 0xa1, 0xce, + 0xfc, 0xdd, 0x8e, 0x30, 0x43, 0xdb, 0x50, 0x25, 0x9e, 0xf5, 0xca, 0x9a, 0x67}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15033}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops4}, .v = {11, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29660}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2329}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1646}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23060}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6544}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25666}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7275}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29319}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24182}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15259}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19332, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15426, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20518 [("\184",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\208\138rec7\DLE\135k\b\245\159\135\&8\198\&0x\EM\188\ESC",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("OC{\222\a\203\253\158#\181\203J&\a\179\STX6\141\175\135\212QE\DC4<\207",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("qa\DC3x\197\165\234`\236\156",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS2}),("j\241\241/\244.\251\220v\185(f\144\147\f\170\246\219",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("f\189\233W\169\244b\222\169",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1})] [PropAuthenticationMethod -// "\227\218\145n\182T\238|~i\ESCZ^_",PropRequestProblemInformation 24,PropSubscriptionIdentifierAvailable -// 55,PropReasonString "!\214\143:~",PropAuthenticationData "\202\140\159J\245\154 '4\159\238\DC1\141",PropTopicAlias -// 10438,PropTopicAlias 6509,PropTopicAlias 30518,PropPayloadFormatIndicator 101,PropRequestResponseInformation -// 103,PropSharedSubscriptionAvailable 143,PropSessionExpiryInterval 5218,PropWillDelayInterval -// 31083,PropServerReference "\147\235[N\214*\128\&0",PropSessionExpiryInterval 19195,PropResponseTopic -// "\197",PropPayloadFormatIndicator 100,PropServerReference -// "\209K\246A\176\192<\CAN\219\ETB\132\190\219\152H\176R\CAN\205\253\170\\`!l\195\a\DC2\DLEL",PropReasonString -// "\160\&2\210#\DC3\DC3\160\230\251\211\243\202\217\226\142\151_S\EOT}?\SO\166\222\EM6\159\175\EOT",PropMaximumPacketSize -// 21571,PropUserProperty "\STX\154\CAN\169jr\241\202P" -// "k\ESC\182\EM[\251\251\184\&7ah9\214\211\156J#\251\136\145\227I\185",PropMessageExpiryInterval -// 5854,PropSubscriptionIdentifier 28] +// SubscribeRequest 11166 [("\253",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS1}),("\160\191\253\EOT\221\233mn\DLE0\180\USn",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("F\137\196\196\246j\196\202xY\172\CANg",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1}),("\209\FS\DC3#w\220<\201Ou\SI\131]\154\159",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("`\161lN\DLE\160\DC1s:",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("6",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] +// [PropMaximumPacketSize 4921,PropRequestProblemInformation 188,PropResponseInformation +// "L\161Fb\169\174\&5f\231,\161\\\ry\209g\"\143\195\165",PropAuthenticationMethod +// "\142\RS\EM\SYN\197\NUL\156\209\ESC\132\154!\129H\205)M\161\202|Y\169\231",PropResponseTopic +// "\169\GS",PropUserProperty "\184\DC2\243\227\251\129\a\165\150\201?\231\195\240\189g\219\203>\196" "",PropContentType +// "\EOT`",PropMessageExpiryInterval 13915,PropAuthenticationData +// "8\150\213m\SOH\144\203~to\151t\158\240(\236\&5\DLE\138\193A%H\240\169\217\242",PropMessageExpiryInterval +// 25559,PropRequestResponseInformation 9,PropReasonString +// "T\"\167\249\163R:\ETX\239\US\213az\243\&9\203\160\178\154^p\202d\180",PropMessageExpiryInterval +// 13397,PropRequestResponseInformation 230,PropSessionExpiryInterval 7107,PropWillDelayInterval +// 23581,PropPayloadFormatIndicator 126,PropUserProperty "" "\217^\154\&7\166>\ESC\181",PropRequestProblemInformation +// 8,PropMessageExpiryInterval 16882,PropContentType +// "y\193n\168C\148\202z\245\162\CANU\210`\242\a\SYNT\188\174\223\144\EM",PropSubscriptionIdentifierAvailable +// 150,PropResponseInformation "\159;\198\253\160\217g\246@@\223\162\151N \151",PropReasonString +// "\234\150D\213\160\186b\nE\"\218\228\204\253\159\219\SYN\223\DC2*[",PropRetainAvailable 99,PropServerKeepAlive +// 14604,PropSubscriptionIdentifier 12,PropContentType "y\234\236\&7;\191`5(pw",PropSubscriptionIdentifierAvailable 74] TEST(Subscribe5QCTest, Encode28) { uint8_t pkt[] = { - 0x82, 0xbb, 0x2, 0x50, 0x26, 0xce, 0x1, 0x15, 0x0, 0xe, 0xe3, 0xda, 0x91, 0x6e, 0xb6, 0x54, 0xee, 0x7c, 0x7e, - 0x69, 0x1b, 0x5a, 0x5e, 0x5f, 0x17, 0x18, 0x29, 0x37, 0x1f, 0x0, 0x5, 0x21, 0xd6, 0x8f, 0x3a, 0x7e, 0x16, 0x0, - 0xd, 0xca, 0x8c, 0x9f, 0x4a, 0xf5, 0x9a, 0x20, 0x27, 0x34, 0x9f, 0xee, 0x11, 0x8d, 0x23, 0x28, 0xc6, 0x23, 0x19, - 0x6d, 0x23, 0x77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fd, 0x2d, + 0x0, 0xd, 0xa0, 0xbf, 0xfd, 0x4, 0xdd, 0xe9, 0x6d, 0x6e, 0x10, 0x30, 0xb4, 0x1f, 0x6e, 0x5, 0x0, 0xd, 0x46, + 0x89, 0xc4, 0xc4, 0xf6, 0x6a, 0xc4, 0xca, 0x78, 0x59, 0xac, 0x18, 0x67, 0x11, 0x0, 0xf, 0xd1, 0x1c, 0x13, 0x23, + 0x77, 0xdc, 0x3c, 0xc9, 0x4f, 0x75, 0xf, 0x83, 0x5d, 0x9a, 0x9f, 0xa, 0x0, 0x9, 0x60, 0xa1, 0x6c, 0x4e, 0x10, + 0xa0, 0x11, 0x73, 0x3a, 0x8, 0x0, 0x1, 0x36, 0x11}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xb8}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xfd}; lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd0, 0x8a, 0x72, 0x65, 0x63, 0x37, 0x10, 0x87, 0x6b, 0x8, - 0xf5, 0x9f, 0x87, 0x38, 0xc6, 0x30, 0x78, 0x19, 0xbc, 0x1b}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa0, 0xbf, 0xfd, 0x4, 0xdd, 0xe9, 0x6d, 0x6e, 0x10, 0x30, 0xb4, 0x1f, 0x6e}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x46, 0x89, 0xc4, 0xc4, 0xf6, 0x6a, 0xc4, 0xca, 0x78, 0x59, 0xac, 0x18, 0x67}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x4f, 0x43, 0x7b, 0xde, 0x7, 0xcb, 0xfd, 0x9e, 0x23, 0xb5, 0xcb, 0x4a, 0x26, - 0x7, 0xb3, 0x2, 0x36, 0x8d, 0xaf, 0x87, 0xd4, 0x51, 0x45, 0x14, 0x3c, 0xcf}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd1, 0x1c, 0x13, 0x23, 0x77, 0xdc, 0x3c, 0xc9, + 0x4f, 0x75, 0xf, 0x83, 0x5d, 0x9a, 0x9f}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x71, 0x61, 0x13, 0x78, 0xc5, 0xa5, 0xea, 0x60, 0xec, 0x9c}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x60, 0xa1, 0x6c, 0x4e, 0x10, 0xa0, 0x11, 0x73, 0x3a}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6a, 0xf1, 0xf1, 0x2f, 0xf4, 0x2e, 0xfb, 0xdc, 0x76, - 0xb9, 0x28, 0x66, 0x90, 0x93, 0xc, 0xaa, 0xf6, 0xdb}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x36}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x66, 0xbd, 0xe9, 0x57, 0xa9, 0xf4, 0x62, 0xde, 0xa9}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; + lwmqtt_sub_options_t sub_opts[6]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - uint8_t bytesprops0[] = {0xe3, 0xda, 0x91, 0x6e, 0xb6, 0x54, 0xee, 0x7c, 0x7e, 0x69, 0x1b, 0x5a, 0x5e, 0x5f}; - uint8_t bytesprops1[] = {0x21, 0xd6, 0x8f, 0x3a, 0x7e}; - uint8_t bytesprops2[] = {0xca, 0x8c, 0x9f, 0x4a, 0xf5, 0x9a, 0x20, 0x27, 0x34, 0x9f, 0xee, 0x11, 0x8d}; - uint8_t bytesprops3[] = {0x93, 0xeb, 0x5b, 0x4e, 0xd6, 0x2a, 0x80, 0x30}; - uint8_t bytesprops4[] = {0xc5}; - uint8_t bytesprops5[] = {0xd1, 0x4b, 0xf6, 0x41, 0xb0, 0xc0, 0x3c, 0x18, 0xdb, 0x17, 0x84, 0xbe, 0xdb, 0x98, 0x48, - 0xb0, 0x52, 0x18, 0xcd, 0xfd, 0xaa, 0x5c, 0x60, 0x21, 0x6c, 0xc3, 0x7, 0x12, 0x10, 0x4c}; - uint8_t bytesprops6[] = {0xa0, 0x32, 0xd2, 0x23, 0x13, 0x13, 0xa0, 0xe6, 0xfb, 0xd3, 0xf3, 0xca, 0xd9, 0xe2, 0x8e, - 0x97, 0x5f, 0x53, 0x4, 0x7d, 0x3f, 0xe, 0xa6, 0xde, 0x19, 0x36, 0x9f, 0xaf, 0x4}; - uint8_t bytesprops8[] = {0x6b, 0x1b, 0xb6, 0x19, 0x5b, 0xfb, 0xfb, 0xb8, 0x37, 0x61, 0x68, 0x39, - 0xd6, 0xd3, 0x9c, 0x4a, 0x23, 0xfb, 0x88, 0x91, 0xe3, 0x49, 0xb9}; - uint8_t bytesprops7[] = {0x2, 0x9a, 0x18, 0xa9, 0x6a, 0x72, 0xf1, 0xca, 0x50}; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + uint8_t bytesprops0[] = {0x4c, 0xa1, 0x46, 0x62, 0xa9, 0xae, 0x35, 0x66, 0xe7, 0x2c, + 0xa1, 0x5c, 0xd, 0x79, 0xd1, 0x67, 0x22, 0x8f, 0xc3, 0xa5}; + uint8_t bytesprops1[] = {0x8e, 0x1e, 0x19, 0x16, 0xc5, 0x0, 0x9c, 0xd1, 0x1b, 0x84, 0x9a, 0x21, + 0x81, 0x48, 0xcd, 0x29, 0x4d, 0xa1, 0xca, 0x7c, 0x59, 0xa9, 0xe7}; + uint8_t bytesprops2[] = {0xa9, 0x1d}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops3[] = {0xb8, 0x12, 0xf3, 0xe3, 0xfb, 0x81, 0x7, 0xa5, 0x96, 0xc9, + 0x3f, 0xe7, 0xc3, 0xf0, 0xbd, 0x67, 0xdb, 0xcb, 0x3e, 0xc4}; + uint8_t bytesprops5[] = {0x4, 0x60}; + uint8_t bytesprops6[] = {0x38, 0x96, 0xd5, 0x6d, 0x1, 0x90, 0xcb, 0x7e, 0x74, 0x6f, 0x97, 0x74, 0x9e, 0xf0, + 0x28, 0xec, 0x35, 0x10, 0x8a, 0xc1, 0x41, 0x25, 0x48, 0xf0, 0xa9, 0xd9, 0xf2}; + uint8_t bytesprops7[] = {0x54, 0x22, 0xa7, 0xf9, 0xa3, 0x52, 0x3a, 0x3, 0xef, 0x1f, 0xd5, 0x61, + 0x7a, 0xf3, 0x39, 0xcb, 0xa0, 0xb2, 0x9a, 0x5e, 0x70, 0xca, 0x64, 0xb4}; + uint8_t bytesprops9[] = {0xd9, 0x5e, 0x9a, 0x37, 0xa6, 0x3e, 0x1b, 0xb5}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops10[] = {0x79, 0xc1, 0x6e, 0xa8, 0x43, 0x94, 0xca, 0x7a, 0xf5, 0xa2, 0x18, 0x55, + 0xd2, 0x60, 0xf2, 0x7, 0x16, 0x54, 0xbc, 0xae, 0xdf, 0x90, 0x19}; + uint8_t bytesprops11[] = {0x9f, 0x3b, 0xc6, 0xfd, 0xa0, 0xd9, 0x67, 0xf6, + 0x40, 0x40, 0xdf, 0xa2, 0x97, 0x4e, 0x20, 0x97}; + uint8_t bytesprops12[] = {0xea, 0x96, 0x44, 0xd5, 0xa0, 0xba, 0x62, 0xa, 0x45, 0x22, 0xda, + 0xe4, 0xcc, 0xfd, 0x9f, 0xdb, 0x16, 0xdf, 0x12, 0x2a, 0x5b}; + uint8_t bytesprops13[] = {0x79, 0xea, 0xec, 0x37, 0x3b, 0xbf, 0x60, 0x35, 0x28, 0x70, 0x77}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10438}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6509}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30518}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5218}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31083}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19195}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21571}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops7}, .v = {23, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5854}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4921}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops3}, .v = {0, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13915}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25559}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13397}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7107}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23581}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops8}, .v = {8, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16882}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14604}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 74}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20518, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11166, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4648 [("\172K\233\189\190\a>\228I\131=\247\DEL\255",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("d\206\145J",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\192\f%\166\NAK\218D3Q\180\233O'N\DC39i5\236\&2r",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\195\233]\b\254s\198E",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\161\EOTL\192\&7\180m\152*\178,\241`\199\167 ",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\159\FS\203g6+\169\183\247\253\137\168\SO\174\243\r\EOT\tH\EOTkQ\a)G#:7\204\DC3",SubOptions {_retainHandling -// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\RSB)}\225\170\218\238\205\247",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [PropUserProperty "\242\203\"\220\218\214" -// "\NUL?\DC4\232\&9\208]\208\NULW\154\185\177\STX\254",PropReceiveMaximum -// 4372,PropSubscriptionIdentifier 15,PropPayloadFormatIndicator 95,PropReasonString -// "D\170\DC2d\148:\f\220\164\254\174",PropSubscriptionIdentifierAvailable 122,PropMaximumQoS 207,PropServerKeepAlive -// 3358,PropMaximumQoS 74,PropWillDelayInterval 18357] +// SubscribeRequest 9472 [("\243\DC2\199A\218\167\CAN\SYN\220w\165\160\NAK",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\247\192Pw\199\196)T\SI\142wV\188!\138\241[\171",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("]\205\240x6\SI\137\238\166K\152\156\181ri\NUL\224\130^\f\190\132\156\170\149\199U\142n",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropSharedSubscriptionAvailable 99,PropReceiveMaximum 18943,PropRetainAvailable 72,PropRetainAvailable +// 59,PropSharedSubscriptionAvailable 37,PropPayloadFormatIndicator 14] TEST(Subscribe5QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0xc5, 0x1, 0x12, 0x28, 0x46, 0x26, 0x0, 0x6, 0xf2, 0xcb, 0x22, 0xdc, 0xda, 0xd6, 0x0, 0x18, - 0x0, 0x3f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x0, 0xd, 0x2a, 0x63, 0x21, 0x49, 0xff, 0x25, 0x48, 0x25, 0x3b, 0x2a, + 0x25, 0x1, 0xe, 0x0, 0xd, 0xf3, 0x12, 0xc7, 0x41, 0xda, 0xa7, 0x18, 0x16, 0xdc, 0x77, + 0xa5, 0xa0, 0x15, 0x2, 0x0, 0x12, 0xf7, 0xc0, 0x50, 0x77, 0xc7, 0xc4, 0x29, 0x54, 0xf, + 0x8e, 0x77, 0x56, 0xbc, 0x21, 0x8a, 0xf1, 0x5b, 0xab, 0xe, 0x0, 0x1d, 0x5d, 0xcd, 0xf0, + 0x78, 0x36, 0xf, 0x89, 0xee, 0xa6, 0x4b, 0x98, 0x9c, 0xb5, 0x72, 0x69, 0x0, 0xe0, 0x82, + 0x5e, 0xc, 0xbe, 0x84, 0x9c, 0xaa, 0x95, 0xc7, 0x55, 0x8e, 0x6e, 0x20}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xac, 0x4b, 0xe9, 0xbd, 0xbe, 0x7, 0x3e, 0xe4, 0x49, 0x83, 0x3d, 0xf7, 0x7f, 0xff}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xf3, 0x12, 0xc7, 0x41, 0xda, 0xa7, 0x18, 0x16, 0xdc, 0x77, 0xa5, 0xa0, 0x15}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x64, 0xce, 0x91, 0x4a}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf7, 0xc0, 0x50, 0x77, 0xc7, 0xc4, 0x29, 0x54, 0xf, + 0x8e, 0x77, 0x56, 0xbc, 0x21, 0x8a, 0xf1, 0x5b, 0xab}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc0, 0xc, 0x25, 0xa6, 0x15, 0xda, 0x44, 0x33, 0x51, 0xb4, 0xe9, - 0x4f, 0x27, 0x4e, 0x13, 0x39, 0x69, 0x35, 0xec, 0x32, 0x72}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5d, 0xcd, 0xf0, 0x78, 0x36, 0xf, 0x89, 0xee, 0xa6, 0x4b, + 0x98, 0x9c, 0xb5, 0x72, 0x69, 0x0, 0xe0, 0x82, 0x5e, 0xc, + 0xbe, 0x84, 0x9c, 0xaa, 0x95, 0xc7, 0x55, 0x8e, 0x6e}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc3, 0xe9, 0x5d, 0x8, 0xfe, 0x73, 0xc6, 0x45}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa1, 0x4, 0x4c, 0xc0, 0x37, 0xb4, 0x6d, 0x98, - 0x2a, 0xb2, 0x2c, 0xf1, 0x60, 0xc7, 0xa7, 0x20}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x9f, 0x1c, 0xcb, 0x67, 0x36, 0x2b, 0xa9, 0xb7, 0xf7, 0xfd, - 0x89, 0xa8, 0xe, 0xae, 0xf3, 0xd, 0x4, 0x9, 0x48, 0x4, - 0x6b, 0x51, 0x7, 0x29, 0x47, 0x23, 0x3a, 0x37, 0xcc, 0x13}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x1e, 0x42, 0x29, 0x7d, 0xe1, 0xaa, 0xda, 0xee, 0xcd, 0xf7}; - lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - uint8_t bytesprops1[] = {0x0, 0x3f, 0x14, 0x3c, 0x64, 0x94, 0x33, 0xaa, 0x81, 0x2f, 0xc7, 0x3e, - 0xe8, 0x39, 0xd0, 0x5d, 0xd0, 0x0, 0x57, 0x9a, 0xb9, 0xb1, 0x2, 0xfe}; - uint8_t bytesprops0[] = {0xf2, 0xcb, 0x22, 0xdc, 0xda, 0xd6}; - uint8_t bytesprops2[] = {0x44, 0xaa, 0x12, 0x64, 0x94, 0x3a, 0xc, 0xdc, 0xa4, 0xfe, 0xae}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4372}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3358}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18357}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18943}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 72}}, {.prop = (lwmqtt_prop_t)37, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 37}}, {.prop = (lwmqtt_prop_t)1, .value = {.byte = 14}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4648, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9472, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 13920 [(";q\215\241\130b\220s",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval -// 7604,PropResponseInformation "\194\181\171\148\138l\NUL\194\229\254m\134@\245\194\170\234",PropUserProperty -// "M\f\245\229\241Y\130\152\DEL8/fJ\193\139\DLE\243\146\134UC`\151,\229\237\132K\235" -// "\254f'G\236UH\222",PropMaximumQoS 22,PropRequestProblemInformation 80,PropAuthenticationMethod -// "\169\&7\177v.=\237Z\184Q\186\RS\222",PropMessageExpiryInterval 31770,PropSubscriptionIdentifier -// 15,PropAuthenticationData "\151m[ZUo]\141\131\195e\181\SOH\168\ETB5C\248",PropTopicAlias -// 32243,PropSubscriptionIdentifierAvailable 45,PropReceiveMaximum 9546,PropMaximumPacketSize -// 28536,PropSubscriptionIdentifier 25,PropRetainAvailable 82,PropContentType -// "\198\148\179\174G\212\153HId\187\208\181f\SOH\182\255X\140/\189\214\244<\145-",PropUserProperty -// "\v\221I\226\230\174|\SOH|\161\176_\210\US\ETBwW\244\255z\EMI56" -// "7\176\134\192`\226i1\223\146b\221\140\&8#\DC3c\129",PropSessionExpiryInterval 23112,PropWillDelayInterval -// 3222,PropServerReference "",PropSubscriptionIdentifierAvailable 39,PropTopicAliasMaximum 26662] +// SubscribeRequest 18189 [("\142\SUB\241ET\151\232",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("t\160\t\216\&0\193Dg",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\218\225\n\t_\\\243\201\136\236\156E\172\217C\208\EOTn\147\225\145",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\167NE\EOT\132/\SIWTa\223|'\178]?\227\170O",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\208\238\156.\186\253",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\227\238\151ou]\230\234\ETB\aQ\170\218",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = True, _noLocal = True, _subQoS = QoS2}),("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = True, _subQoS = QoS1}),("\249\a\164!\177YC\194\&0\183f\212\212Y\NAK\EOT\178\179",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("[",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\CANk+w\218\153\151\DEL\179U\STXl\DC2\SUBE\251\241\208",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\132B\f\206\169",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropPayloadFormatIndicator +// 202,PropMaximumPacketSize 29573,PropWillDelayInterval 21956,PropServerKeepAlive 15460,PropSubscriptionIdentifier +// 21,PropMessageExpiryInterval 4729,PropSubscriptionIdentifierAvailable 188,PropMessageExpiryInterval +// 19861,PropReceiveMaximum 28358,PropPayloadFormatIndicator 237,PropCorrelationData "\203",PropResponseInformation +// "\182@\161\SUB\vT\157f4|\253 \197\230\SYN\NUL\205\165\199\134E\129n0",PropRequestProblemInformation +// 104,PropReasonString +// "\146\191\144\196\DC1\151\178\173\173!\192\213\f\252\&5\142\EOTL\243\152\231\181\250\161\SOna\135\159",PropResponseTopic +// "\228\212\161\SI\254\252\172\209o\"8\151",PropContentType +// "\199i\162\&9\226\ETB\252\231\254`\230\213\194\211b\212\207,\165\&5p\162C0j>\ETX\SYN",PropSharedSubscriptionAvailable +// 68,PropMaximumPacketSize 10716,PropMessageExpiryInterval 10250,PropSubscriptionIdentifier 7,PropMaximumPacketSize +// 2136,PropResponseTopic "\194\171?\150TB"] TEST(Subscribe5QCTest, Encode30) { uint8_t pkt[] = { - 0x82, 0xf1, 0x1, 0x36, 0x60, 0xe2, 0x1, 0x2, 0x0, 0x0, 0x1d, 0xb4, 0x1a, 0x0, 0x11, 0xc2, 0xb5, 0xab, 0x94, - 0x8a, 0x6c, 0x0, 0xc2, 0xe5, 0xfe, 0x6d, 0x86, 0x40, 0xf5, 0xc2, 0xaa, 0xea, 0x26, 0x0, 0x1d, 0x4d, 0xc, 0xf5, - 0xe5, 0xf1, 0x59, 0x82, 0x98, 0x7f, 0x38, 0x2f, 0x66, 0x4a, 0xc1, 0x8b, 0x10, 0xf3, 0x92, 0x86, 0x55, 0x43, 0x60, - 0x97, 0x2c, 0xe5, 0xed, 0x84, 0x4b, 0xeb, 0x0, 0x8, 0xfe, 0x66, 0x27, 0x47, 0xec, 0x55, 0x48, 0xde, 0x24, 0x16, - 0x17, 0x50, 0x15, 0x0, 0xd, 0xa9, 0x37, 0xb1, 0x76, 0x2e, 0x3d, 0xed, 0x5a, 0xb8, 0x51, 0xba, 0x1e, 0xde, 0x2, - 0x0, 0x0, 0x7c, 0x1a, 0xb, 0xf, 0x16, 0x0, 0x12, 0x97, 0x6d, 0x5b, 0x5a, 0x55, 0x6f, 0x5d, 0x8d, 0x83, 0xc3, - 0x65, 0xb5, 0x1, 0xa8, 0x17, 0x35, 0x43, 0xf8, 0x23, 0x7d, 0xf3, 0x29, 0x2d, 0x21, 0x25, 0x4a, 0x27, 0x0, 0x0, - 0x6f, 0x78, 0x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x51, 0xaa, 0xda, 0x1e, 0x0, 0x0, 0x2d, 0x0, 0x12, 0xf9, 0x7, 0xa4, 0x21, 0xb1, 0x59, 0x43, 0xc2, + 0x30, 0xb7, 0x66, 0xd4, 0xd4, 0x59, 0x15, 0x4, 0xb2, 0xb3, 0x1c, 0x0, 0x1, 0x5b, 0x18, 0x0, 0x12, 0x18, 0x6b, + 0x2b, 0x77, 0xda, 0x99, 0x97, 0x7f, 0xb3, 0x55, 0x2, 0x6c, 0x12, 0x1a, 0x45, 0xfb, 0xf1, 0xd0, 0x20, 0x0, 0x5, + 0x84, 0x42, 0xc, 0xce, 0xa9, 0x18}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x3b, 0x71, 0xd7, 0xf1, 0x82, 0x62, 0xdc, 0x73}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x8e, 0x1a, 0xf1, 0x45, 0x54, 0x97, 0xe8}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s1_bytes[] = {0x74, 0xa0, 0x9, 0xd8, 0x30, 0xc1, 0x44, 0x67}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xda, 0xe1, 0xa, 0x9, 0x5f, 0x5c, 0xf3, 0xc9, 0x88, 0xec, 0x9c, + 0x45, 0xac, 0xd9, 0x43, 0xd0, 0x4, 0x6e, 0x93, 0xe1, 0x91}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa7, 0x4e, 0x45, 0x4, 0x84, 0x2f, 0xf, 0x57, 0x54, 0x61, + 0xdf, 0x7c, 0x27, 0xb2, 0x5d, 0x3f, 0xe3, 0xaa, 0x4f}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd0, 0xee, 0x9c, 0x2e, 0xba, 0xfd}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xe3, 0xee, 0x97, 0x6f, 0x75, 0x5d, 0xe6, 0xea, 0x17, 0x7, 0x51, 0xaa, 0xda}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf9, 0x7, 0xa4, 0x21, 0xb1, 0x59, 0x43, 0xc2, 0x30, + 0xb7, 0x66, 0xd4, 0xd4, 0x59, 0x15, 0x4, 0xb2, 0xb3}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x5b}; + lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x18, 0x6b, 0x2b, 0x77, 0xda, 0x99, 0x97, 0x7f, 0xb3, + 0x55, 0x2, 0x6c, 0x12, 0x1a, 0x45, 0xfb, 0xf1, 0xd0}; + lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x84, 0x42, 0xc, 0xce, 0xa9}; + lwmqtt_string_t topic_filter_s10 = {5, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - uint8_t bytesprops0[] = {0xc2, 0xb5, 0xab, 0x94, 0x8a, 0x6c, 0x0, 0xc2, 0xe5, - 0xfe, 0x6d, 0x86, 0x40, 0xf5, 0xc2, 0xaa, 0xea}; - uint8_t bytesprops2[] = {0xfe, 0x66, 0x27, 0x47, 0xec, 0x55, 0x48, 0xde}; - uint8_t bytesprops1[] = {0x4d, 0xc, 0xf5, 0xe5, 0xf1, 0x59, 0x82, 0x98, 0x7f, 0x38, 0x2f, 0x66, 0x4a, 0xc1, 0x8b, - 0x10, 0xf3, 0x92, 0x86, 0x55, 0x43, 0x60, 0x97, 0x2c, 0xe5, 0xed, 0x84, 0x4b, 0xeb}; - uint8_t bytesprops3[] = {0xa9, 0x37, 0xb1, 0x76, 0x2e, 0x3d, 0xed, 0x5a, 0xb8, 0x51, 0xba, 0x1e, 0xde}; - uint8_t bytesprops4[] = {0x97, 0x6d, 0x5b, 0x5a, 0x55, 0x6f, 0x5d, 0x8d, 0x83, - 0xc3, 0x65, 0xb5, 0x1, 0xa8, 0x17, 0x35, 0x43, 0xf8}; - uint8_t bytesprops5[] = {0xc6, 0x94, 0xb3, 0xae, 0x47, 0xd4, 0x99, 0x48, 0x49, 0x64, 0xbb, 0xd0, 0xb5, - 0x66, 0x1, 0xb6, 0xff, 0x58, 0x8c, 0x2f, 0xbd, 0xd6, 0xf4, 0x3c, 0x91, 0x2d}; - uint8_t bytesprops7[] = {0x37, 0xb0, 0x86, 0xc0, 0x60, 0xe2, 0x69, 0x31, 0xdf, - 0x92, 0x62, 0xdd, 0x8c, 0x38, 0x23, 0x13, 0x63, 0x81}; - uint8_t bytesprops6[] = {0xb, 0xdd, 0x49, 0xe2, 0xe6, 0xae, 0x7c, 0x1, 0x7c, 0xa1, 0xb0, 0x5f, - 0xd2, 0x1f, 0x17, 0x77, 0x57, 0xf4, 0xff, 0x7a, 0x19, 0x49, 0x35, 0x36}; - uint8_t bytesprops8[] = {0}; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = false; + uint8_t bytesprops0[] = {0xcb}; + uint8_t bytesprops1[] = {0xb6, 0x40, 0xa1, 0x1a, 0xb, 0x54, 0x9d, 0x66, 0x34, 0x7c, 0xfd, 0x20, + 0xc5, 0xe6, 0x16, 0x0, 0xcd, 0xa5, 0xc7, 0x86, 0x45, 0x81, 0x6e, 0x30}; + uint8_t bytesprops2[] = {0x92, 0xbf, 0x90, 0xc4, 0x11, 0x97, 0xb2, 0xad, 0xad, 0x21, 0xc0, 0xd5, 0xc, 0xfc, 0x35, + 0x8e, 0x4, 0x4c, 0xf3, 0x98, 0xe7, 0xb5, 0xfa, 0xa1, 0xe, 0x6e, 0x61, 0x87, 0x9f}; + uint8_t bytesprops3[] = {0xe4, 0xd4, 0xa1, 0xf, 0xfe, 0xfc, 0xac, 0xd1, 0x6f, 0x22, 0x38, 0x97}; + uint8_t bytesprops4[] = {0xc7, 0x69, 0xa2, 0x39, 0xe2, 0x17, 0xfc, 0xe7, 0xfe, 0x60, 0xe6, 0xd5, 0xc2, 0xd3, + 0x62, 0xd4, 0xcf, 0x2c, 0xa5, 0x35, 0x70, 0xa2, 0x43, 0x30, 0x6a, 0x3e, 0x3, 0x16}; + uint8_t bytesprops5[] = {0xc2, 0xab, 0x3f, 0x96, 0x54, 0x42}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7604}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31770}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32243}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9546}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28536}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops6}, .v = {18, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23112}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3222}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26662}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29573}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21956}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15460}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4729}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19861}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28358}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10716}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10250}}, + {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2136}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops5}}}, }; lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13920, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18189, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeResponse 4646 [Right QoS1,Left SubErrUnspecifiedError,Right QoS2,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Right -// QoS0,Left SubErrUnspecifiedError] [] +// SubscribeResponse 30748 [Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Right QoS0,Right QoS1,Right +// QoS1,Left SubErrNotAuthorized,Left SubErrNotAuthorized,Left SubErrNotAuthorized] [] TEST(SubACK311QCTest, Decode1) { - uint8_t pkt[] = {0x90, 0xb, 0x12, 0x26, 0x1, 0x80, 0x2, 0xa1, 0x1, 0x1, 0xa2, 0x0, 0x80}; + uint8_t pkt[] = {0x90, 0xb, 0x78, 0x1c, 0x1, 0x1, 0x83, 0x0, 0x1, 0x1, 0x87, 0x87, 0x87}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[9]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4646); + EXPECT_EQ(packet_id, 30748); EXPECT_EQ(count, 9); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x80); EXPECT_EQ(granted_qos_levels[8], 0x80); } -// SubscribeResponse 3536 [Right QoS1,Left SubErrUnspecifiedError,Left SubErrSubscriptionIdentifiersNotSupported] [] +// SubscribeResponse 11486 [Right QoS1,Right QoS1,Right QoS1,Left SubErrNotAuthorized] [] TEST(SubACK311QCTest, Decode2) { - uint8_t pkt[] = {0x90, 0x5, 0xd, 0xd0, 0x1, 0x80, 0xa1}; + uint8_t pkt[] = {0x90, 0x6, 0x2c, 0xde, 0x1, 0x1, 0x1, 0x87}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3536); - EXPECT_EQ(count, 3); + EXPECT_EQ(packet_id, 11486); + EXPECT_EQ(count, 4); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); } -// SubscribeResponse 13945 [Left SubErrPacketIdentifierInUse,Right QoS1] [] +// SubscribeResponse 31056 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS0,Right +// QoS0,Right QoS1] [] TEST(SubACK311QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0x4, 0x36, 0x79, 0x91, 0x1}; + uint8_t pkt[] = {0x90, 0x9, 0x79, 0x50, 0x87, 0x80, 0x2, 0x0, 0x0, 0x0, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13945); - EXPECT_EQ(count, 2); + EXPECT_EQ(packet_id, 31056); + EXPECT_EQ(count, 7); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); } -// SubscribeResponse 27071 [Right QoS0,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left -// SubErrUnspecifiedError,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrSubscriptionIdentifiersNotSupported] [] +// SubscribeResponse 7634 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS1] [] TEST(SubACK311QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0xa, 0x69, 0xbf, 0x0, 0x1, 0xa2, 0x0, 0x80, 0x2, 0xa2, 0xa1}; + uint8_t pkt[] = {0x90, 0x5, 0x1d, 0xd2, 0xa1, 0x2, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27071); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(packet_id, 7634); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); } -// SubscribeResponse 29147 [Right QoS2,Right QoS2,Left SubErrImplementationSpecificError,Left -// SubErrUnspecifiedError,Right QoS2,Right QoS2] [] +// SubscribeResponse 17449 [Left SubErrUnspecifiedError,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Left +// SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right +// QoS2,Right QoS1] [] TEST(SubACK311QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0x8, 0x71, 0xdb, 0x2, 0x2, 0x83, 0x80, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0xb, 0x44, 0x29, 0x80, 0x97, 0x80, 0x80, 0x91, 0x0, 0xa2, 0x2, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29147); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 17449); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); } -// SubscribeResponse 9531 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Left -// SubErrTopicFilterInvalid,Right QoS1,Left SubErrNotAuthorized,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS2] [] +// SubscribeResponse 27369 [Left SubErrImplementationSpecificError,Right QoS1,Right QoS0,Left +// SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS0,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Left +// SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported] [] TEST(SubACK311QCTest, Decode6) { - uint8_t pkt[] = {0x90, 0xc, 0x25, 0x3b, 0x1, 0xa1, 0x2, 0x8f, 0x1, 0x87, 0x0, 0x9e, 0x2, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9531); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); -} - -// SubscribeResponse 30374 [Left SubErrQuotaExceeded,Left SubErrSubscriptionIdentifiersNotSupported] [] -TEST(SubACK311QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0x4, 0x76, 0xa6, 0x97, 0xa1}; + uint8_t pkt[] = {0x90, 0xd, 0x6a, 0xe9, 0x83, 0x1, 0x0, 0x80, 0x2, 0x0, 0x0, 0x80, 0x87, 0x8f, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 30374); - EXPECT_EQ(count, 2); + EXPECT_EQ(packet_id, 27369); + EXPECT_EQ(count, 11); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); -} - -// SubscribeResponse 8812 [Right QoS0,Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left -// SubErrTopicFilterInvalid,Right QoS0,Right QoS2,Right QoS0,Right QoS2] [] -TEST(SubACK311QCTest, Decode8) { - uint8_t pkt[] = {0x90, 0xb, 0x22, 0x6c, 0x0, 0x2, 0x91, 0x1, 0x8f, 0x0, 0x2, 0x0, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8812); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 31341 [Left SubErrImplementationSpecificError,Right QoS2,Left SubErrQuotaExceeded,Right QoS1,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS1] [] -TEST(SubACK311QCTest, Decode9) { - uint8_t pkt[] = {0x90, 0xa, 0x7a, 0x6d, 0x83, 0x2, 0x97, 0x1, 0x9e, 0x91, 0x0, 0x1}; +// SubscribeResponse 9981 [Right QoS2,Right QoS1,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Right +// QoS2,Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Left SubErrUnspecifiedError] [] +TEST(SubACK311QCTest, Decode7) { + uint8_t pkt[] = {0x90, 0xa, 0x26, 0xfd, 0x2, 0x1, 0x80, 0x91, 0x2, 0x83, 0x80, 0x80}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[8]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 31341); + EXPECT_EQ(packet_id, 9981); EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); } -// SubscribeResponse 16134 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Left -// SubErrNotAuthorized,Right QoS1,Right QoS0,Left SubErrUnspecifiedError,Right QoS1] [] -TEST(SubACK311QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0xa, 0x3f, 0x6, 0x1, 0xa1, 0x1, 0x87, 0x1, 0x0, 0x80, 0x1}; +// SubscribeResponse 25704 [Right QoS1,Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError] [] +TEST(SubACK311QCTest, Decode8) { + uint8_t pkt[] = {0x90, 0x5, 0x64, 0x68, 0x1, 0x83, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 25704); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); +} + +// SubscribeResponse 27290 [Right QoS0,Right QoS1,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrPacketIdentifierInUse,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS2] [] +TEST(SubACK311QCTest, Decode9) { + uint8_t pkt[] = {0x90, 0xa, 0x6a, 0x9a, 0x0, 0x1, 0x1, 0x9e, 0x91, 0x1, 0x91, 0x2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[8]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 16134); + EXPECT_EQ(packet_id, 27290); EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); } -// SubscribeResponse 27712 [Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Right QoS0] [] -TEST(SubACK311QCTest, Decode11) { - uint8_t pkt[] = {0x90, 0x5, 0x6c, 0x40, 0x83, 0x80, 0x0}; +// SubscribeResponse 26187 [Left SubErrImplementationSpecificError,Right QoS1,Left SubErrImplementationSpecificError] [] +TEST(SubACK311QCTest, Decode10) { + uint8_t pkt[] = {0x90, 0x5, 0x66, 0x4b, 0x83, 0x1, 0x83}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[3]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27712); + EXPECT_EQ(packet_id, 26187); EXPECT_EQ(count, 3); EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); +} + +// SubscribeResponse 26384 [Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Right QoS1,Left +// SubErrNotAuthorized,Right QoS0,Right QoS1,Left SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS2] [] +TEST(SubACK311QCTest, Decode11) { + uint8_t pkt[] = {0x90, 0xd, 0x67, 0x10, 0x80, 0x80, 0x1, 0x87, 0x0, 0x1, 0x83, 0x97, 0xa1, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 26384); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); } -// SubscribeResponse 23389 [Right QoS2,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right -// QoS2,Left SubErrTopicFilterInvalid] [] +// SubscribeResponse 24874 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrImplementationSpecificError,Right QoS1,Right QoS2] [] TEST(SubACK311QCTest, Decode12) { - uint8_t pkt[] = {0x90, 0x8, 0x5b, 0x5d, 0x2, 0x1, 0xa2, 0x0, 0x2, 0x8f}; + uint8_t pkt[] = {0x90, 0x7, 0x61, 0x2a, 0x2, 0x9e, 0x83, 0x1, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 23389); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 24874); + EXPECT_EQ(count, 5); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x80); } -// SubscribeResponse 3364 [Right QoS0,Left SubErrUnspecifiedError] [] +// SubscribeResponse 25167 [Left SubErrQuotaExceeded] [] TEST(SubACK311QCTest, Decode13) { - uint8_t pkt[] = {0x90, 0x4, 0xd, 0x24, 0x0, 0x80}; + uint8_t pkt[] = {0x90, 0x3, 0x62, 0x4f, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3364); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(packet_id, 25167); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], 0x80); } -// SubscribeResponse 8138 [Right QoS0,Right QoS1,Right QoS2] [] +// SubscribeResponse 7252 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left SubErrUnspecifiedError,Right +// QoS2,Right QoS1,Right QoS2,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0] [] TEST(SubACK311QCTest, Decode14) { - uint8_t pkt[] = {0x90, 0x5, 0x1f, 0xca, 0x0, 0x1, 0x2}; + uint8_t pkt[] = {0x90, 0xb, 0x1c, 0x54, 0xa2, 0x0, 0x80, 0x2, 0x1, 0x2, 0x0, 0xa1, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8138); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 7252); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); } -// SubscribeResponse 7647 [Left SubErrTopicFilterInvalid,Left SubErrNotAuthorized,Left SubErrTopicFilterInvalid,Left -// SubErrUnspecifiedError,Left SubErrQuotaExceeded,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrQuotaExceeded,Left SubErrNotAuthorized,Left SubErrQuotaExceeded] [] +// SubscribeResponse 22592 [Left SubErrUnspecifiedError,Right QoS2,Right QoS0,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrPacketIdentifierInUse] [] TEST(SubACK311QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0xb, 0x1d, 0xdf, 0x8f, 0x87, 0x8f, 0x80, 0x97, 0xa1, 0x97, 0x87, 0x97}; + uint8_t pkt[] = {0x90, 0x7, 0x58, 0x40, 0x80, 0x2, 0x0, 0xa1, 0x91}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7647); - EXPECT_EQ(count, 9); + EXPECT_EQ(packet_id, 22592); + EXPECT_EQ(count, 5); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[3], 0x80); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); } -// SubscribeResponse 4989 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [] +// SubscribeResponse 1930 [Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right QoS2,Left SubErrQuotaExceeded,Right QoS1,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Left SubErrTopicFilterInvalid,Left +// SubErrTopicFilterInvalid,Left SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0x4, 0x13, 0x7d, 0x1, 0xa1}; + uint8_t pkt[] = {0x90, 0xd, 0x7, 0x8a, 0xa2, 0xa2, 0x0, 0x2, 0x97, 0x1, 0xa1, 0x8f, 0x8f, 0x8f, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4989); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 1930); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 12633 [Right QoS2,Right QoS0,Right QoS0,Right QoS1] [] +// SubscribeResponse 32288 [Right QoS1,Right QoS0,Right QoS1,Right QoS2,Left SubErrImplementationSpecificError,Right +// QoS1,Left SubErrQuotaExceeded,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0x6, 0x31, 0x59, 0x2, 0x0, 0x0, 0x1}; + uint8_t pkt[] = {0x90, 0xd, 0x7e, 0x20, 0x1, 0x0, 0x1, 0x2, 0x83, 0x1, 0x97, 0x1, 0x91, 0x2, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12633); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 32288); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 1188 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported] [] +// SubscribeResponse 8665 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left +// SubErrQuotaExceeded,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS2,Right QoS2] [] TEST(SubACK311QCTest, Decode18) { - uint8_t pkt[] = {0x90, 0x4, 0x4, 0xa4, 0x0, 0xa2}; + uint8_t pkt[] = {0x90, 0x9, 0x21, 0xd9, 0x9e, 0x80, 0x97, 0x2, 0x8f, 0x2, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1188); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 8665); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); } -// SubscribeResponse 17587 [Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS0,Left -// SubErrNotAuthorized,Right QoS0] [] +// SubscribeResponse 32158 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left +// SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode19) { - uint8_t pkt[] = {0x90, 0xc, 0x44, 0xb3, 0x0, 0x2, 0xa2, 0x8f, 0xa2, 0x2, 0x1, 0x0, 0x87, 0x0}; + uint8_t pkt[] = {0x90, 0x5, 0x7d, 0x9e, 0xa2, 0x0, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17587); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 32158); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); } -// SubscribeResponse 7329 [Right QoS2,Left SubErrPacketIdentifierInUse] [] +// SubscribeResponse 9271 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS2,Right QoS0,Left +// SubErrQuotaExceeded,Right QoS0,Right QoS2] [] TEST(SubACK311QCTest, Decode20) { - uint8_t pkt[] = {0x90, 0x4, 0x1c, 0xa1, 0x2, 0x91}; + uint8_t pkt[] = {0x90, 0x9, 0x24, 0x37, 0xa1, 0x1, 0x2, 0x0, 0x97, 0x0, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7329); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(packet_id, 9271); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); } -// SubscribeResponse 19479 [Right QoS1] [] +// SubscribeResponse 4115 [Left SubErrUnspecifiedError,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrNotAuthorized,Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0x3, 0x4c, 0x17, 0x1}; + uint8_t pkt[] = {0x90, 0x7, 0x10, 0x13, 0x80, 0x9e, 0x87, 0x9e, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19479); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 4115); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); } -// SubscribeResponse 4187 [Right QoS2,Right QoS1,Left SubErrQuotaExceeded,Right QoS1,Right QoS0,Right QoS2,Left -// SubErrImplementationSpecificError] [] +// SubscribeResponse 24961 [Right QoS2,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Left SubErrTopicFilterInvalid,Left +// SubErrQuotaExceeded,Right QoS0,Left SubErrQuotaExceeded,Right QoS2,Right QoS0] [] TEST(SubACK311QCTest, Decode22) { - uint8_t pkt[] = {0x90, 0x9, 0x10, 0x5b, 0x2, 0x1, 0x97, 0x1, 0x0, 0x2, 0x83}; + uint8_t pkt[] = {0x90, 0xc, 0x61, 0x81, 0x2, 0x0, 0x97, 0x0, 0x8f, 0x97, 0x0, 0x97, 0x2, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4187); - EXPECT_EQ(count, 7); + EXPECT_EQ(packet_id, 24961); + EXPECT_EQ(count, 10); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); } -// SubscribeResponse 1954 [Left SubErrNotAuthorized,Right QoS2,Left SubErrUnspecifiedError,Left -// SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrImplementationSpecificError,Right -// QoS2,Right QoS2] [] +// SubscribeResponse 18340 [Right QoS2,Left SubErrTopicFilterInvalid,Right QoS1,Left SubErrImplementationSpecificError] +// [] TEST(SubACK311QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0xa, 0x7, 0xa2, 0x87, 0x2, 0x80, 0x8f, 0xa2, 0x83, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0x6, 0x47, 0xa4, 0x2, 0x8f, 0x1, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1954); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(packet_id, 18340); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); } -// SubscribeResponse 9962 [Left SubErrPacketIdentifierInUse,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrNotAuthorized,Right QoS1,Left SubErrQuotaExceeded,Right QoS1] [] +// SubscribeResponse 8517 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS0] [] TEST(SubACK311QCTest, Decode24) { - uint8_t pkt[] = {0x90, 0x8, 0x26, 0xea, 0x91, 0xa2, 0x87, 0x1, 0x97, 0x1}; + uint8_t pkt[] = {0x90, 0x8, 0x21, 0x45, 0x9e, 0x0, 0xa1, 0xa2, 0x2, 0x0}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[6]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9962); + EXPECT_EQ(packet_id, 8517); EXPECT_EQ(count, 6); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); +} + +// SubscribeResponse 31168 [Right QoS2,Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrNotAuthorized,Right QoS0,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left +// SubErrPacketIdentifierInUse,Left SubErrNotAuthorized] [] +TEST(SubACK311QCTest, Decode25) { + uint8_t pkt[] = {0x90, 0xb, 0x79, 0xc0, 0x2, 0x8f, 0xa1, 0x87, 0x0, 0x9e, 0x1, 0x91, 0x87}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 31168); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); +} + +// SubscribeResponse 6558 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left +// SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Right +// QoS1,Left SubErrTopicFilterInvalid] [] +TEST(SubACK311QCTest, Decode26) { + uint8_t pkt[] = {0x90, 0x9, 0x19, 0x9e, 0x9e, 0x0, 0x83, 0x83, 0x83, 0x1, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 6558); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); EXPECT_EQ(granted_qos_levels[4], 0x80); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); } -// SubscribeResponse 16427 [Left SubErrQuotaExceeded,Right QoS0,Right QoS2,Right QoS2,Right QoS1] [] -TEST(SubACK311QCTest, Decode25) { - uint8_t pkt[] = {0x90, 0x7, 0x40, 0x2b, 0x97, 0x0, 0x2, 0x2, 0x1}; +// SubscribeResponse 25528 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left +// SubErrUnspecifiedError,Left SubErrImplementationSpecificError,Right QoS2] [] +TEST(SubACK311QCTest, Decode27) { + uint8_t pkt[] = {0x90, 0x7, 0x63, 0xb8, 0x9e, 0x80, 0x80, 0x83, 0x2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[5]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 16427); + EXPECT_EQ(packet_id, 25528); EXPECT_EQ(count, 5); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); -} - -// SubscribeResponse 14848 [Left SubErrImplementationSpecificError,Left SubErrSubscriptionIdentifiersNotSupported] [] -TEST(SubACK311QCTest, Decode26) { - uint8_t pkt[] = {0x90, 0x4, 0x3a, 0x0, 0x83, 0xa1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14848); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); } -// SubscribeResponse 15477 [Left SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Right QoS2,Right QoS2,Right -// QoS1,Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Right QoS1,Left -// SubErrWildcardSubscriptionsNotSupported] [] -TEST(SubACK311QCTest, Decode27) { - uint8_t pkt[] = {0x90, 0xc, 0x3c, 0x75, 0x91, 0x87, 0x2, 0x2, 0x1, 0x9e, 0x80, 0x0, 0x1, 0xa2}; +// SubscribeResponse 29497 [Right QoS2,Right QoS2,Right QoS2,Right QoS1,Right QoS2,Left SubErrPacketIdentifierInUse] [] +TEST(SubACK311QCTest, Decode28) { + uint8_t pkt[] = {0x90, 0x8, 0x73, 0x39, 0x2, 0x2, 0x2, 0x1, 0x2, 0x91}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15477); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(packet_id, 29497); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[9], 0x80); } -// SubscribeResponse 13181 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right -// QoS2,Left SubErrImplementationSpecificError,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrPacketIdentifierInUse,Right QoS1,Left SubErrUnspecifiedError] [] -TEST(SubACK311QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0xb, 0x33, 0x7d, 0x87, 0x80, 0x87, 0x2, 0x83, 0xa1, 0x91, 0x1, 0x80}; +// SubscribeResponse 9048 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS1,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS1,Right QoS2,Right QoS2,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded] [] +TEST(SubACK311QCTest, Decode29) { + uint8_t pkt[] = {0x90, 0xd, 0x23, 0x58, 0x87, 0x80, 0x87, 0x1, 0x9e, 0x1, 0x1, 0x2, 0x2, 0xa2, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13181); - EXPECT_EQ(count, 9); + EXPECT_EQ(packet_id, 9048); + EXPECT_EQ(count, 11); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0x80); -} - -// SubscribeResponse 32677 [Right QoS1,Left SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS2] [] -TEST(SubACK311QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0x7, 0x7f, 0xa5, 0x1, 0x80, 0x2, 0x0, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32677); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 14851 [Right QoS0,Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError,Left SubErrNotAuthorized,Left -// SubErrSharedSubscriptionsNotSupported] [] +// SubscribeResponse 18118 [Right QoS1] [] TEST(SubACK311QCTest, Decode30) { - uint8_t pkt[] = {0x90, 0xa, 0x3a, 0x3, 0x0, 0x87, 0x80, 0x9e, 0x1, 0x83, 0x87, 0x9e}; + uint8_t pkt[] = {0x90, 0x3, 0x46, 0xc6, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14851); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(packet_id, 18118); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); } -// SubscribeResponse 4646 [Right QoS1,Left SubErrUnspecifiedError,Right QoS2,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Right -// QoS0,Left SubErrUnspecifiedError] [PropSubscriptionIdentifier 22,PropRequestResponseInformation -// 17,PropSubscriptionIdentifierAvailable 50,PropWildcardSubscriptionAvailable 51,PropRetainAvailable -// 233,PropReceiveMaximum 23309,PropResponseInformation -// "\251\r{G\166E\137\154\133JK\160\247\208\231t\177$]\193\240*\184\133\162\247R\165%\137",PropRequestResponseInformation -// 8,PropServerReference -// "\145\248\135d)\213B\n\135EJ\198\NAK\203\&6\153\214\173\141\138\236\NULy\DC1\215<\227sd",PropSubscriptionIdentifierAvailable -// 81,PropUserProperty "TK\156\b\130,\232\ENQ'\SYN\SUB6G\206\163\133\&4\EM\EM\213J " -// "\150\178Zd\187\233\237U\229\RS\DEL}/P\187\221\226\203~",PropUserProperty -// "v!l\151;4\STX=\222\238\SUB\f\136\178\175\134+5" "\154f\CANv\175+)",PropSessionExpiryInterval -// 29233,PropWildcardSubscriptionAvailable 6,PropMessageExpiryInterval 12194,PropResponseInformation -// "\215\254\&9\189\150\DC1\164HQ\216\v\185\167S)n%\200\188N~\SUBQ",PropSubscriptionIdentifier -// 27,PropWildcardSubscriptionAvailable 13,PropMessageExpiryInterval 7423,PropWillDelayInterval 28935,PropResponseTopic -// "",PropTopicAliasMaximum 2012,PropPayloadFormatIndicator 112,PropReceiveMaximum 15776,PropCorrelationData -// "B\202\134W\f=k\RS.\249\ACK\211\252~yv\234G\129_\218\129i",PropAuthenticationMethod -// "\136\224\SOH\US1E\244\f\178\NAK\r\NUL\134\207/\207\DEL\188\167\222\134\DEL",PropRetainAvailable +// 185,PropServerReference "x\233\186s\131\SI",PropRequestResponseInformation 88,PropRequestProblemInformation +// 231,PropSubscriptionIdentifier 26,PropMessageExpiryInterval 27266,PropResponseTopic +// "O$\158\ETX#\195x\SO\129\FS\249\189\178\STX\169\212;\202\154#",PropRequestResponseInformation 168,PropMessageExpiryInterval -// 1846,PropMessageExpiryInterval 19979,PropAuthenticationData "J\177 -// D\182_w\USH\180\207\ETB\235\180\DC3)3\213x1c\186h\206\200m\227\221X",PropRequestProblemInformation 53,PropMaximumQoS -// 146,PropReceiveMaximum 25571,PropServerKeepAlive 3299,PropPayloadFormatIndicator 255,PropReasonString -// "q\245\154\&2",PropTopicAlias 15510] +// SubscribeResponse 7634 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS1] +// [PropWildcardSubscriptionAvailable 117,PropSessionExpiryInterval 19428,PropMaximumPacketSize 8971,PropMaximumQoS +// 43,PropRetainAvailable 125,PropMaximumPacketSize 11341,PropSharedSubscriptionAvailable 195,PropAuthenticationData +// "y\191)\242\\\STX\254\a\SI\GS'\159ak\230\140\164\162\130+\189\ESC",PropAssignedClientIdentifier +// "\254j\SUBjht\226\NUL\159-\145\203\151\RS\230\189Zo\174\254\141q\237\244",PropWildcardSubscriptionAvailable +// 152,PropMaximumQoS 35,PropTopicAliasMaximum 13672,PropSharedSubscriptionAvailable 216,PropAssignedClientIdentifier +// "\172\233",PropCorrelationData "\158\&1\t\137=]",PropSharedSubscriptionAvailable 150,PropMessageExpiryInterval +// 30357,PropReasonString "\188\"\207X\246\130\US\188R\253=\nQ\US\STX\132\169r",PropMaximumQoS 201,PropServerKeepAlive +// 8699,PropReasonString "\203\ENQ\145OC-2?\162\212",PropAuthenticationMethod +// "\221\156\SUB\142\236\138\128\nu\162\n\180\136j\229\228\&3",PropReceiveMaximum 9931] TEST(SubACK5QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0x8c, 0x1, 0x69, 0xbf, 0x80, 0x1, 0x12, 0x0, 0x9, 0x55, 0x85, 0xad, 0xd1, 0x3f, 0x7d, - 0x63, 0x90, 0xad, 0x26,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6a, 0x68, 0x74, 0xe2, 0x0, 0x9f, 0x2d, + 0x91, 0xcb, 0x97, 0x1e, 0xe6, 0xbd, 0x5a, 0x6f, 0xae, 0xfe, 0x8d, 0x71, 0xed, 0xf4, 0x28, 0x98, 0x24, + 0x23, 0x22, 0x35, 0x68, 0x2a, 0xd8, 0x12, 0x0, 0x2, 0xac, 0xe9, 0x9, 0x0, 0x6, 0x9e, 0x31, 0x9, + 0x89, 0x3d, 0x5d, 0x2a, 0x96, 0x2, 0x0, 0x0, 0x76, 0x95, 0x1f, 0x0, 0x12, 0xbc, 0x22, 0xcf, 0x58, + 0xf6, 0x82, 0x1f, 0xbc, 0x52, 0xfd, 0x3d, 0xa, 0x51, 0x1f, 0x2, 0x84, 0xa9, 0x72, 0x24, 0xc9, 0x13, + 0x21, 0xfb, 0x1f, 0x0, 0xa, 0xcb, 0x5, 0x91, 0x4f, 0x43, 0x2d, 0x32, 0x3f, 0xa2, 0xd4, 0x15, 0x0, + 0x11, 0xdd, 0x9c, 0x1a, 0x8e, 0xec, 0x8a, 0x80, 0xa, 0x75, 0xa2, 0xa, 0xb4, 0x88, 0x6a, 0xe5, 0xe4, + 0x33, 0x21, 0x26, 0xcb, 0xa1, 0x2, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27071); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0xA2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0xA2); - EXPECT_EQ(granted_qos_levels[7], 0xA1); + EXPECT_EQ(packet_id, 7634); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); } -// SubscribeResponse 29147 [Right QoS2,Right QoS2,Left SubErrImplementationSpecificError,Left -// SubErrUnspecifiedError,Right QoS2,Right QoS2] [PropSubscriptionIdentifier 29,PropWillDelayInterval -// 5901,PropReasonString "\NUL/\153\168\GS|$\190\232\210\158\132\ACK\179q",PropWildcardSubscriptionAvailable -// 76,PropRetainAvailable 119,PropSubscriptionIdentifier 16,PropUserProperty -// "CY]\r\239\238Q\222i\a\251\SO\202\147\216?\f\SUB\213p\232a\227]" -// "#\ETX\USL[\DEL*\167qJ\219\226r\DC2\198*\189!\255\169\&6\244",PropCorrelationData -// "\208}\132x\197hO\STX\SOH|l\208G\EM\178\FS",PropMessageExpiryInterval 14507,PropMaximumPacketSize -// 19945,PropSubscriptionIdentifierAvailable 170,PropRetainAvailable 214,PropRequestResponseInformation -// 42,PropResponseInformation "\r\ENQrX\226\143[\DEL"] +// SubscribeResponse 17449 [Left SubErrUnspecifiedError,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Left +// SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right +// QoS2,Right QoS1] [PropResponseInformation +// "\NAK\231\DC4$VU\152\205\ACK\138\245\171\157;\tw\183W",PropWillDelayInterval 2297,PropWillDelayInterval +// 6369,PropReceiveMaximum 14983,PropRetainAvailable 1,PropAuthenticationMethod +// "\r\156\&7*g\131\229\238\FSTN\211\135\182\225\153\146\147\194",PropTopicAliasMaximum 2942,PropTopicAlias +// 20633,PropRequestResponseInformation 3,PropReasonString "\212%",PropSubscriptionIdentifier +// 9,PropMessageExpiryInterval 25957,PropMaximumPacketSize 17017,PropResponseTopic +// ";\180\250D\ACK\235g_t\NAK6\174\137i\186E\182p\DLE\229;G\STX\181\237Y\191",PropPayloadFormatIndicator +// 92,PropRetainAvailable 102,PropRetainAvailable 170,PropRequestProblemInformation 152,PropUserProperty +// "\150\163\243\n\r\ETB\210\233\&3\176f\157\208\254m\175D\217\178[\226\169*\199\177\&6\145>\185" +// "\147\178\206\245\236D\222O\176\191\132y\196",PropRequestProblemInformation 141,PropRequestProblemInformation +// 72,PropTopicAlias 18280] TEST(SubACK5QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0x8a, 0x1, 0x71, 0xdb, 0x80, 0x1, 0xb, 0x1d, 0x18, 0x0, 0x0, 0x17, 0xd, 0x1f, 0x0, - 0xf, 0x0, 0x2f, 0x99, 0xa8, 0x1d, 0x7c, 0x24, 0xbe, 0xe8, 0xd2, 0x9e, 0x84, 0x6, 0xb3, 0x71, - 0x28, 0x4c, 0x25, 0x77, 0xb, 0x10, 0x26, 0x0, 0x18, 0x43, 0x59, 0x5d, 0xd, 0xef, 0xee, 0x51, - 0xde, 0x69, 0x7, 0xfb, 0xe, 0xca, 0x93, 0xd8, 0x3f, 0xc, 0x1a, 0xd5, 0x70, 0xe8, 0x61, 0xe3, - 0x5d, 0x0, 0x16, 0x23, 0x3, 0x1f, 0x4c, 0x5b, 0x7f, 0x2a, 0xa7, 0x71, 0x4a, 0xdb, 0xe2, 0x72, - 0x12, 0xc6, 0x2a, 0xbd, 0x21, 0xff, 0xa9, 0x36, 0xf4, 0x9, 0x0, 0x10, 0xd0, 0x7d, 0x84, 0x78, - 0xc5, 0x68, 0x4f, 0x2, 0x1, 0x7c, 0x6c, 0xd0, 0x47, 0x19, 0xb2, 0x1c, 0x2, 0x0, 0x0, 0x38, - 0xab, 0x27, 0x0, 0x0, 0x4d, 0xe9, 0x29, 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ce, 0xf5, 0xec, 0x44, 0xde, 0x4f, 0xb0, 0xbf, 0x84, 0x79, 0xc4, 0x17, + 0x8d, 0x17, 0x48, 0x23, 0x47, 0x68, 0x80, 0x97, 0x80, 0x80, 0x91, 0x0, 0xa2, 0x2, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29147); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x83); + EXPECT_EQ(packet_id, 17449); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x97); + EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x91); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0xA2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); } -// SubscribeResponse 9531 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Left -// SubErrTopicFilterInvalid,Right QoS1,Left SubErrNotAuthorized,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS2] [PropSessionExpiryInterval 6243,PropTopicAliasMaximum -// 1854,PropPayloadFormatIndicator 70,PropContentType -// "\US\193\232\200!\f\171\222\146\"\200\184J\195{\189\RS\233\208\131%",PropWildcardSubscriptionAvailable -// 154,PropReasonString "\255\219\130u\251\218gb\224\138\&4%?L\200Tw:\217\&2\223",PropWillDelayInterval -// 16298,PropMessageExpiryInterval 18664,PropUserProperty -// "\173\176\RS\EM\245\182o\167\250m\215\164A\184\b\NUL\142\130\214Z" "b\\\147\131\155\231\EOT\239E",PropReceiveMaximum -// 22869,PropMaximumQoS 216,PropWildcardSubscriptionAvailable 93,PropResponseInformation -// "'\180\RSY8\150\DEL\SOH\186\CAN\155d\246\147\174c\149t",PropSubscriptionIdentifier 21,PropReceiveMaximum -// 6947,PropWillDelayInterval 6293,PropTopicAliasMaximum 13827,PropUserProperty "" -// "\133\219n\US\SYN\235\DC2\193\&9\v^\221\170l\RS\211",PropSharedSubscriptionAvailable -// 144,PropWildcardSubscriptionAvailable 8,PropUserProperty "1\DC3\200\161\220\139\t\EOTl;\143\200\240\172" -// "\SYN\255\214aA\244\141\251e#\168\\\178\168R\174"] +// SubscribeResponse 27369 [Left SubErrImplementationSpecificError,Right QoS1,Right QoS0,Left +// SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS0,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Left +// SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported] [PropContentType +// "\234\146\&0.\151\163\229p=\r\164R\252\DC1\158\239\163Xg\180\ESC\255",PropReasonString +// "bz\245\DC4\195\233\144\224}\159g\138c\131\238L\138Ts\208\t\214]\EM\175\238:\144\255\252",PropPayloadFormatIndicator +// 208,PropAssignedClientIdentifier "\EMTh\229.\194\ETX+\148\197\DC3f\225\206u",PropCorrelationData +// "\183d\136\140cm.\195\205}\147\206\187",PropRequestResponseInformation 174,PropTopicAlias +// 18785,PropWildcardSubscriptionAvailable 140,PropTopicAliasMaximum 7985,PropRetainAvailable 248,PropUserProperty +// "\207\195\177\241,\US\134\254\205\130#\161\214\132\DC3" +// "K\EM\154U\SI\171b\220$\SUBS\180\244\150\254:\147p\221\207^",PropSharedSubscriptionAvailable +// 205,PropPayloadFormatIndicator 226,PropRequestProblemInformation 220,PropResponseTopic +// "o\148\EOT\232?\v7\ESCl\ETX\200\&2\158\255\DEL\175\130\173\204\DC2\EOTj\134\172",PropAuthenticationData +// "\146]\ESC\DLE\RSR/\"x\153\232M\NAKF\187\RS\139\179\249{\207\&2\143\180\252a\198vY\151"] TEST(SubACK5QCTest, Decode6) { - uint8_t pkt[] = { - 0x90, 0xdb, 0x1, 0x25, 0x3b, 0xcd, 0x1, 0x11, 0x0, 0x0, 0x18, 0x63, 0x22, 0x7, 0x3e, 0x1, 0x46, 0x3, 0x0, - 0x15, 0x1f, 0xc1, 0xe8, 0xc8, 0x21, 0xc, 0xab, 0xde, 0x92, 0x22, 0xc8, 0xb8, 0x4a, 0xc3, 0x7b, 0xbd, 0x1e, 0xe9, - 0xd0, 0x83, 0x25, 0x28, 0x9a, 0x1f, 0x0, 0x15, 0xff, 0xdb, 0x82, 0x75, 0xfb, 0xda, 0x67, 0x62, 0xe0, 0x8a, 0x34, - 0x25, 0x3f, 0x4c, 0xc8, 0x54, 0x77, 0x3a, 0xd9, 0x32, 0xdf, 0x18, 0x0, 0x0, 0x3f, 0xaa, 0x2, 0x0, 0x0, 0x48, - 0xe8, 0x26, 0x0, 0x14, 0xad, 0xb0, 0x1e, 0x19, 0xf5, 0xb6, 0x6f, 0xa7, 0xfa, 0x6d, 0xd7, 0xa4, 0x41, 0xb8, 0x8, - 0x0, 0x8e, 0x82, 0xd6, 0x5a, 0x0, 0x9, 0x62, 0x5c, 0x93, 0x83, 0x9b, 0xe7, 0x4, 0xef, 0x45, 0x21, 0x59, 0x55, - 0x24, 0xd8, 0x28, 0x5d, 0x1a, 0x0, 0x12, 0x27, 0xb4, 0x1e, 0x59, 0x38, 0x96, 0x7f, 0x1, 0xba, 0x18, 0x9b, 0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0xc3, 0xcd, 0x7d, 0x93, 0xce, 0xbb, 0x19, + 0xae, 0x23, 0x49, 0x61, 0x28, 0x8c, 0x22, 0x1f, 0x31, 0x25, 0xf8, 0x26, 0x0, 0xf, 0xcf, 0xc3, 0xb1, + 0xf1, 0x2c, 0x1f, 0x86, 0xfe, 0xcd, 0x82, 0x23, 0xa1, 0xd6, 0x84, 0x13, 0x0, 0x15, 0x4b, 0x19, 0x9a, + 0x55, 0xf, 0xab, 0x62, 0xdc, 0x24, 0x1a, 0x53, 0xb4, 0xf4, 0x96, 0xfe, 0x3a, 0x93, 0x70, 0xdd, 0xcf, + 0x5e, 0x2a, 0xcd, 0x1, 0xe2, 0x17, 0xdc, 0x8, 0x0, 0x18, 0x6f, 0x94, 0x4, 0xe8, 0x3f, 0xb, 0x37, + 0x1b, 0x6c, 0x3, 0xc8, 0x32, 0x9e, 0xff, 0x7f, 0xaf, 0x82, 0xad, 0xcc, 0x12, 0x4, 0x6a, 0x86, 0xac, + 0x16, 0x0, 0x1e, 0x92, 0x5d, 0x1b, 0x10, 0x1e, 0x52, 0x2f, 0x22, 0x78, 0x99, 0xe8, 0x4d, 0x15, 0x46, + 0xbb, 0x1e, 0x8b, 0xb3, 0xf9, 0x7b, 0xcf, 0x32, 0x8f, 0xb4, 0xfc, 0x61, 0xc6, 0x76, 0x59, 0x97, 0x83, + 0x1, 0x0, 0x80, 0x2, 0x0, 0x0, 0x80, 0x87, 0x8f, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9531); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0xA1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x8F); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x87); + EXPECT_EQ(packet_id, 27369); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x83); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x9E); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); -} - -// SubscribeResponse 30374 [Left SubErrQuotaExceeded,Left SubErrSubscriptionIdentifiersNotSupported] -// [PropMaximumPacketSize 8115,PropTopicAliasMaximum 8706,PropCorrelationData "\142\200\t\132\150 -// \227\a\180\227\185)\187W\163u",PropPayloadFormatIndicator 54,PropRequestProblemInformation 50] + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x87); + EXPECT_EQ(granted_qos_levels[9], 0x8F); + EXPECT_EQ(granted_qos_levels[10], 0xA1); +} + +// SubscribeResponse 9981 [Right QoS2,Right QoS1,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Right +// QoS2,Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Left SubErrUnspecifiedError] +// [PropAuthenticationData "\152",PropMaximumQoS 127,PropTopicAlias 18865,PropCorrelationData +// "\EOT\ENQ\131\197Jh~\181Hr\177\SI\235:\132\247Av(",PropServerReference +// "t\EOT\203\168\221g\222\135\232>\fC\132_6\DLE\131\&5G\223K\161&\250\219\225Uq4N",PropWillDelayInterval +// 11881,PropRequestProblemInformation 159,PropMessageExpiryInterval 13721,PropCorrelationData +// "\242qt\128\153\anZ[\US\171",PropSubscriptionIdentifierAvailable 110,PropReasonString " \194\DLE\185\142\213t +// s%\159\n\214X\CAN\200p\DELVX)",PropCorrelationData +// "\215j}\SI\208!\142'?\STX\130\185\&3%L\218\ETB\212",PropSharedSubscriptionAvailable 42,PropAuthenticationData +// "H\149\252m\195\141\196\246\129/]\208P\162",PropRequestResponseInformation 32,PropSubscriptionIdentifierAvailable +// 41,PropWildcardSubscriptionAvailable 71,PropSharedSubscriptionAvailable 72] TEST(SubACK5QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0x24, 0x76, 0xa6, 0x1f, 0x27, 0x0, 0x0, 0x1f, 0xb3, 0x22, 0x22, 0x2, - 0x9, 0x0, 0x10, 0x8e, 0xc8, 0x9, 0x84, 0x96, 0x20, 0xe3, 0x7, 0xb4, 0xe3, - 0xb9, 0x29, 0xbb, 0x57, 0xa3, 0x75, 0x1, 0x36, 0x17, 0x32, 0x97, 0xa1}; + uint8_t pkt[] = {0x90, 0xb0, 0x1, 0x26, 0xfd, 0xa4, 0x1, 0x16, 0x0, 0x1, 0x98, 0x24, 0x7f, 0x23, 0x49, 0xb1, 0x9, + 0x0, 0x13, 0x4, 0x5, 0x83, 0xc5, 0x4a, 0x68, 0x7e, 0xb5, 0x48, 0x72, 0xb1, 0xf, 0xeb, 0x3a, 0x84, + 0xf7, 0x41, 0x76, 0x28, 0x1c, 0x0, 0x1e, 0x74, 0x4, 0xcb, 0xa8, 0xdd, 0x67, 0xde, 0x87, 0xe8, 0x3e, + 0xc, 0x43, 0x84, 0x5f, 0x36, 0x10, 0x83, 0x35, 0x47, 0xdf, 0x4b, 0xa1, 0x26, 0xfa, 0xdb, 0xe1, 0x55, + 0x71, 0x34, 0x4e, 0x18, 0x0, 0x0, 0x2e, 0x69, 0x17, 0x9f, 0x2, 0x0, 0x0, 0x35, 0x99, 0x9, 0x0, + 0xb, 0xf2, 0x71, 0x74, 0x80, 0x99, 0x7, 0x6e, 0x5a, 0x5b, 0x1f, 0xab, 0x29, 0x6e, 0x1f, 0x0, 0x15, + 0x20, 0xc2, 0x10, 0xb9, 0x8e, 0xd5, 0x74, 0x20, 0x73, 0x25, 0x9f, 0xa, 0xd6, 0x58, 0x18, 0xc8, 0x70, + 0x7f, 0x56, 0x58, 0x29, 0x9, 0x0, 0x12, 0xd7, 0x6a, 0x7d, 0xf, 0xd0, 0x21, 0x8e, 0x27, 0x3f, 0x2, + 0x82, 0xb9, 0x33, 0x25, 0x4c, 0xda, 0x17, 0xd4, 0x2a, 0x2a, 0x16, 0x0, 0xe, 0x48, 0x95, 0xfc, 0x6d, + 0xc3, 0x8d, 0xc4, 0xf6, 0x81, 0x2f, 0x5d, 0xd0, 0x50, 0xa2, 0x19, 0x20, 0x29, 0x29, 0x28, 0x47, 0x2a, + 0x48, 0x2, 0x1, 0x80, 0x91, 0x2, 0x83, 0x80, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 30374); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], 0x97); - EXPECT_EQ(granted_qos_levels[1], 0xA1); + EXPECT_EQ(packet_id, 9981); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x91); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x83); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); } -// SubscribeResponse 8812 [Right QoS0,Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left -// SubErrTopicFilterInvalid,Right QoS0,Right QoS2,Right QoS0,Right QoS2] [PropCorrelationData -// "\DC4\166GV",PropSubscriptionIdentifier 2,PropServerReference "\201\&5G\142\154l]\238\192",PropMaximumQoS -// 49,PropWillDelayInterval 926,PropReceiveMaximum 24762,PropServerKeepAlive 23026,PropSubscriptionIdentifierAvailable -// 15,PropResponseTopic "\v 9\178\134\ACK\191\198$^\198A\SId\154",PropAuthenticationMethod "4C",PropWillDelayInterval -// 13004] +// SubscribeResponse 25704 [Right QoS1,Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError] +// [PropWildcardSubscriptionAvailable 84,PropSessionExpiryInterval 13092,PropTopicAliasMaximum 19356] TEST(SubACK5QCTest, Decode8) { - uint8_t pkt[] = {0x90, 0x4c, 0x22, 0x6c, 0x40, 0x9, 0x0, 0x4, 0x14, 0xa6, 0x47, 0x56, 0xb, 0x2, 0x1c, 0x0, - 0x9, 0xc9, 0x35, 0x47, 0x8e, 0x9a, 0x6c, 0x5d, 0xee, 0xc0, 0x24, 0x31, 0x18, 0x0, 0x0, 0x3, - 0x9e, 0x21, 0x60, 0xba, 0x13, 0x59, 0xf2, 0x29, 0xf, 0x8, 0x0, 0xf, 0xb, 0x20, 0x39, 0xb2, - 0x86, 0x6, 0xbf, 0xc6, 0x24, 0x5e, 0xc6, 0x41, 0xf, 0x64, 0x9a, 0x15, 0x0, 0x2, 0x34, 0x43, - 0x18, 0x0, 0x0, 0x32, 0xcc, 0x0, 0x2, 0x91, 0x1, 0x8f, 0x0, 0x2, 0x0, 0x2}; + uint8_t pkt[] = {0x90, 0x10, 0x64, 0x68, 0xa, 0x28, 0x54, 0x11, 0x0, + 0x0, 0x33, 0x24, 0x22, 0x4b, 0x9c, 0x1, 0x83, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8812); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x91); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], 0x8F); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 25704); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], 0x80); } -// SubscribeResponse 31341 [Left SubErrImplementationSpecificError,Right QoS2,Left SubErrQuotaExceeded,Right QoS1,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS1] -// [PropRequestProblemInformation 94,PropContentType "\224\243",PropAuthenticationData "h\ACK",PropRetainAvailable -// 17,PropResponseInformation "\154\255\DEL\RS\164\v\185M5",PropPayloadFormatIndicator 184,PropAuthenticationData -// "\DEL\133\156\&1\170",PropResponseInformation -// "\133\DLE\209\141\243\EMH\166\185\STXA\177\128\STXT",PropWillDelayInterval 27214,PropSessionExpiryInterval -// 14089,PropAssignedClientIdentifier "l\213\178\159"] +// SubscribeResponse 27290 [Right QoS0,Right QoS1,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrPacketIdentifierInUse,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS2] [PropSubscriptionIdentifier +// 24,PropReceiveMaximum 9995,PropAuthenticationMethod +// "\251\v\182\FS\250Q\241\212C\"K|N\249J+\200\137",PropRetainAvailable 189,PropServerReference +// "dN\213+\180\254m!\STX\182\r\204\182\&7\144\185\r\183\221\233\&3\159ki\209",PropWillDelayInterval +// 24527,PropSubscriptionIdentifier 19,PropContentType "\190/8\167\NUL",PropPayloadFormatIndicator 131,PropResponseTopic +// "",PropSessionExpiryInterval 13681,PropSessionExpiryInterval 3955,PropReceiveMaximum 13878,PropSubscriptionIdentifier +// 5,PropSessionExpiryInterval 4247,PropTopicAlias 6837,PropMessageExpiryInterval 32164] TEST(SubACK5QCTest, Decode9) { - uint8_t pkt[] = {0x90, 0x52, 0x7a, 0x6d, 0x47, 0x17, 0x5e, 0x3, 0x0, 0x2, 0xe0, 0xf3, 0x16, 0x0, 0x2, 0x68, 0x6, - 0x25, 0x11, 0x1a, 0x0, 0x9, 0x9a, 0xff, 0x7f, 0x1e, 0xa4, 0xb, 0xb9, 0x4d, 0x35, 0x1, 0xb8, 0x16, - 0x0, 0x5, 0x7f, 0x85, 0x9c, 0x31, 0xaa, 0x1a, 0x0, 0xf, 0x85, 0x10, 0xd1, 0x8d, 0xf3, 0x19, 0x48, - 0xa6, 0xb9, 0x2, 0x41, 0xb1, 0x80, 0x2, 0x54, 0x18, 0x0, 0x0, 0x6a, 0x4e, 0x11, 0x0, 0x0, 0x37, - 0x9, 0x12, 0x0, 0x4, 0x6c, 0xd5, 0xb2, 0x9f, 0x83, 0x2, 0x97, 0x1, 0x9e, 0x91, 0x0, 0x1}; + uint8_t pkt[] = {0x90, 0x73, 0x6a, 0x9a, 0x68, 0xb, 0x18, 0x21, 0x27, 0xb, 0x15, 0x0, 0x12, 0xfb, 0xb, 0xb6, 0x1c, + 0xfa, 0x51, 0xf1, 0xd4, 0x43, 0x22, 0x4b, 0x7c, 0x4e, 0xf9, 0x4a, 0x2b, 0xc8, 0x89, 0x25, 0xbd, 0x1c, + 0x0, 0x19, 0x64, 0x4e, 0xd5, 0x2b, 0xb4, 0xfe, 0x6d, 0x21, 0x2, 0xb6, 0xd, 0xcc, 0xb6, 0x37, 0x90, + 0xb9, 0xd, 0xb7, 0xdd, 0xe9, 0x33, 0x9f, 0x6b, 0x69, 0xd1, 0x18, 0x0, 0x0, 0x5f, 0xcf, 0xb, 0x13, + 0x3, 0x0, 0x5, 0xbe, 0x2f, 0x38, 0xa7, 0x0, 0x1, 0x83, 0x8, 0x0, 0x0, 0x11, 0x0, 0x0, 0x35, + 0x71, 0x11, 0x0, 0x0, 0xf, 0x73, 0x21, 0x36, 0x36, 0xb, 0x5, 0x11, 0x0, 0x0, 0x10, 0x97, 0x23, + 0x1a, 0xb5, 0x2, 0x0, 0x0, 0x7d, 0xa4, 0x0, 0x1, 0x1, 0x9e, 0x91, 0x1, 0x91, 0x2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[8]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 31341); + EXPECT_EQ(packet_id, 27290); EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], 0x83); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x97); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], 0x9E); - EXPECT_EQ(granted_qos_levels[5], 0x91); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x9E); + EXPECT_EQ(granted_qos_levels[4], 0x91); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x91); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); } -// SubscribeResponse 16134 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Left -// SubErrNotAuthorized,Right QoS1,Right QoS0,Left SubErrUnspecifiedError,Right QoS1] [PropResponseTopic -// "571\167\180\147\252\128\246X\152Z\242\v9\186",PropAuthenticationMethod "g\139\DC4",PropTopicAliasMaximum -// 5202,PropWildcardSubscriptionAvailable 185,PropTopicAlias 10282,PropSubscriptionIdentifier 9,PropServerKeepAlive -// 22027,PropResponseTopic "GG\SUB\139\226\a\160\t\167g\148\172\ETB\183\185\188n\241",PropCorrelationData -// "\220\249\232\235:'",PropResponseInformation -// "u>\210\204\214\137\161.\161\192F\197",PropSubscriptionIdentifierAvailable 153,PropAssignedClientIdentifier -// "O\203\171\198\175j\201\241\DLE\CAN\179tv2\147\148",PropMaximumPacketSize 21008,PropUserProperty -// "\t\US\171A\CANs\163\177T}fE\173iVvi\200Y" ":\152G\CANZ\252",PropReceiveMaximum -// 26151,PropSubscriptionIdentifierAvailable 4] +// SubscribeResponse 26187 [Left SubErrImplementationSpecificError,Right QoS1,Left SubErrImplementationSpecificError] +// [PropMessageExpiryInterval 119,PropContentType "",PropServerReference "\140",PropAssignedClientIdentifier +// "b\173J\131\NAK\225\ETB0\128\DC3\161t`\SI\200\188\EOT\221\235\190\233Jp\226\133\205\ENQ`",PropRequestResponseInformation +// 20,PropAssignedClientIdentifier "\STXR\152?\189V\215\&0a\228\220?\239\NAK",PropAuthenticationMethod +// "S\FS\196\ACKElA\169>\147\165",PropRetainAvailable 147,PropMaximumQoS 250,PropSubscriptionIdentifier +// 19,PropSharedSubscriptionAvailable 48,PropMaximumPacketSize 14740,PropRetainAvailable 230,PropCorrelationData +// "\131|\198\219",PropUserProperty "\160\&9pU\209\220?l" ",;8c=A\\\147j\207\147F=\237\198\165\&5",PropMaximumPacketSize +// 14635,PropMaximumPacketSize 12754,PropPayloadFormatIndicator 40,PropSubscriptionIdentifier 13,PropResponseInformation +// "\f\147\&7\235\DC2\233\168#qoo\171\US\210\154\218e\204\190\&8",PropAuthenticationData +// "pQ\f\230Sr\142\&2\ETB/^[\225j\153\NAK\218-T\199\207$\224uH",PropReceiveMaximum 30595,PropRequestResponseInformation +// 43,PropContentType "36\210",PropAuthenticationData +// "\ETX\144y\161]\254w\163\EM\166\RS\213\133\253\CAN\158\157+4\220\198",PropMessageExpiryInterval 5797] TEST(SubACK5QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0x9c, 0x1, 0x3f, 0x6, 0x90, 0x1, 0x8, 0x0, 0x10, 0x35, 0x37, 0x31, 0xa7, 0xb4, 0x93, - 0xfc, 0x80, 0xf6, 0x58, 0x98, 0x5a, 0xf2, 0xb, 0x39, 0xba, 0x15, 0x0, 0x3, 0x67, 0x8b, 0x14, - 0x22, 0x14, 0x52, 0x28, 0xb9, 0x23, 0x28, 0x2a, 0xb, 0x9, 0x13, 0x56, 0xb, 0x8, 0x0, 0x12, - 0x47, 0x47, 0x1a, 0x8b, 0xe2, 0x7, 0xa0, 0x9, 0xa7, 0x67, 0x94, 0xac, 0x17, 0xb7, 0xb9, 0xbc, - 0x6e, 0xf1, 0x9, 0x0, 0x6, 0xdc, 0xf9, 0xe8, 0xeb, 0x3a, 0x27, 0x1a, 0x0, 0xc, 0x75, 0x3e, - 0xd2, 0xcc, 0xd6, 0x89, 0xa1, 0x2e, 0xa1, 0xc0, 0x46, 0xc5, 0x29, 0x99, 0x12, 0x0, 0x10, 0x4f, - 0xcb, 0xab, 0xc6, 0xaf, 0x6a, 0xc9, 0xf1, 0x10, 0x18, 0xb3, 0x74, 0x76, 0x32, 0x93, 0x94, 0x27, - 0x0, 0x0, 0x52, 0x10, 0x26, 0x0, 0x13, 0x9, 0x1f, 0xab, 0x41, 0x18, 0x73, 0xa3, 0xb1, 0x54, - 0x7d, 0x66, 0x45, 0xad, 0x69, 0x56, 0x76, 0x69, 0xc8, 0x59, 0x0, 0x6, 0x3a, 0x98, 0x47, 0x18, - 0x5a, 0xfc, 0x21, 0x66, 0x27, 0x29, 0x4, 0x1, 0xa1, 0x1, 0x87, 0x1, 0x0, 0x80, 0x1}; + uint8_t pkt[] = { + 0x90, 0xf0, 0x1, 0x66, 0x4b, 0xe9, 0x1, 0x2, 0x0, 0x0, 0x0, 0x77, 0x3, 0x0, 0x0, 0x1c, 0x0, 0x1, 0x8c, + 0x12, 0x0, 0x1c, 0x62, 0xad, 0x4a, 0x83, 0x15, 0xe1, 0x17, 0x30, 0x80, 0x13, 0xa1, 0x74, 0x60, 0xf, 0xc8, 0xbc, + 0x4, 0xdd, 0xeb, 0xbe, 0xe9, 0x4a, 0x70, 0xe2, 0x85, 0xcd, 0x5, 0x60, 0x19, 0x14, 0x12, 0x0, 0xe, 0x2, 0x52, + 0x98, 0x3f, 0xbd, 0x56, 0xd7, 0x30, 0x61, 0xe4, 0xdc, 0x3f, 0xef, 0x15, 0x15, 0x0, 0xb, 0x53, 0x1c, 0xc4, 0x6, + 0x45, 0x6c, 0x41, 0xa9, 0x3e, 0x93, 0xa5, 0x25, 0x93, 0x24, 0xfa, 0xb, 0x13, 0x2a, 0x30, 0x27, 0x0, 0x0, 0x39, + 0x94, 0x25, 0xe6, 0x9, 0x0, 0x4, 0x83, 0x7c, 0xc6, 0xdb, 0x26, 0x0, 0x8, 0xa0, 0x39, 0x70, 0x55, 0xd1, 0xdc, + 0x3f, 0x6c, 0x0, 0x11, 0x2c, 0x3b, 0x38, 0x63, 0x3d, 0x41, 0x5c, 0x93, 0x6a, 0xcf, 0x93, 0x46, 0x3d, 0xed, 0xc6, + 0xa5, 0x35, 0x27, 0x0, 0x0, 0x39, 0x2b, 0x27, 0x0, 0x0, 0x31, 0xd2, 0x1, 0x28, 0xb, 0xd, 0x1a, 0x0, 0x14, + 0xc, 0x93, 0x37, 0xeb, 0x12, 0xe9, 0xa8, 0x23, 0x71, 0x6f, 0x6f, 0xab, 0x1f, 0xd2, 0x9a, 0xda, 0x65, 0xcc, 0xbe, + 0x38, 0x16, 0x0, 0x19, 0x70, 0x51, 0xc, 0xe6, 0x53, 0x72, 0x8e, 0x32, 0x17, 0x2f, 0x5e, 0x5b, 0xe1, 0x6a, 0x99, + 0x15, 0xda, 0x2d, 0x54, 0xc7, 0xcf, 0x24, 0xe0, 0x75, 0x48, 0x21, 0x77, 0x83, 0x19, 0x2b, 0x3, 0x0, 0x3, 0x33, + 0x36, 0xd2, 0x16, 0x0, 0x15, 0x3, 0x90, 0x79, 0xa1, 0x5d, 0xfe, 0x77, 0xa3, 0x19, 0xa6, 0x1e, 0xd5, 0x85, 0xfd, + 0x18, 0x9e, 0x9d, 0x2b, 0x34, 0xdc, 0xc6, 0x2, 0x0, 0x0, 0x16, 0xa5, 0x83, 0x1, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 16134); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0xA1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x87); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 26187); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0x83); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x83); } -// SubscribeResponse 27712 [Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Right QoS0] -// [PropTopicAliasMaximum 15336,PropResponseInformation "%\219\212w7\218M\157\143\237r\aAO\213,",PropServerKeepAlive -// 29870,PropReceiveMaximum 339] +// SubscribeResponse 26384 [Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Right QoS1,Left +// SubErrNotAuthorized,Right QoS0,Right QoS1,Left SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS2] [PropUserProperty "{\195\147\227k\139" +// "\174\SO\180\195\164&!}",PropMessageExpiryInterval 9881,PropMaximumQoS 232,PropResponseTopic +// "\174g\179\226\156l\223\176\DLE]+#\130 \128\135\196",PropMaximumPacketSize 12346,PropContentType "\193\216\252\189 +// \206*\228\201\ETX\222Z\172\215\SOH\188\224SC6\252e\152w",PropAssignedClientIdentifier "\US\210\ETB\198\137\215\&1U"] TEST(SubACK5QCTest, Decode11) { - uint8_t pkt[] = {0x90, 0x22, 0x6c, 0x40, 0x1c, 0x22, 0x3b, 0xe8, 0x1a, 0x0, 0x10, 0x25, - 0xdb, 0xd4, 0x77, 0x37, 0xda, 0x4d, 0x9d, 0x8f, 0xed, 0x72, 0x7, 0x41, - 0x4f, 0xd5, 0x2c, 0x13, 0x74, 0xae, 0x21, 0x1, 0x53, 0x83, 0x80, 0x0}; + uint8_t pkt[] = {0x90, 0x67, 0x67, 0x10, 0x59, 0x26, 0x0, 0x6, 0x7b, 0xc3, 0x93, 0xe3, 0x6b, 0x8b, 0x0, + 0x8, 0xae, 0xe, 0xb4, 0xc3, 0xa4, 0x26, 0x21, 0x7d, 0x2, 0x0, 0x0, 0x26, 0x99, 0x24, + 0xe8, 0x8, 0x0, 0x11, 0xae, 0x67, 0xb3, 0xe2, 0x9c, 0x6c, 0xdf, 0xb0, 0x10, 0x5d, 0x2b, + 0x23, 0x82, 0x20, 0x80, 0x87, 0xc4, 0x27, 0x0, 0x0, 0x30, 0x3a, 0x3, 0x0, 0x18, 0xc1, + 0xd8, 0xfc, 0xbd, 0x20, 0xce, 0x2a, 0xe4, 0xc9, 0x3, 0xde, 0x5a, 0xac, 0xd7, 0x1, 0xbc, + 0xe0, 0x53, 0x43, 0x36, 0xfc, 0x65, 0x98, 0x77, 0x12, 0x0, 0x8, 0x1f, 0xd2, 0x17, 0xc6, + 0x89, 0xd7, 0x31, 0x55, 0x80, 0x80, 0x1, 0x87, 0x0, 0x1, 0x83, 0x97, 0xa1, 0x2, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27712); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0x83); + EXPECT_EQ(packet_id, 26384); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x87); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x83); + EXPECT_EQ(granted_qos_levels[7], 0x97); + EXPECT_EQ(granted_qos_levels[8], 0xA1); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); } -// SubscribeResponse 23389 [Right QoS2,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right -// QoS2,Left SubErrTopicFilterInvalid] [PropReasonString -// ">c'\236\255R\147\155\184\217\234z\234\222\128",PropRequestResponseInformation 230,PropMessageExpiryInterval -// 1522,PropSharedSubscriptionAvailable 116,PropResponseInformation "\241\150V$",PropCorrelationData -// "\218",PropSubscriptionIdentifier 14,PropReasonString -// "a\v\135P\205e\RS\182\241\204\135\211\138\"\164oE\DC3\150\220\131\148\176\216\a\132B\212C\165",PropSessionExpiryInterval -// 3925,PropSessionExpiryInterval 8684,PropMaximumPacketSize 29880,PropSubscriptionIdentifierAvailable -// 151,PropServerKeepAlive 11995] +// SubscribeResponse 24874 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrImplementationSpecificError,Right QoS1,Right QoS2] [PropReasonString "'\230\146\SIyi",PropResponseTopic +// "\146\136+\205\205X\201\147\231oR\151\247\&1lr\ETX\r\128\fy\DELW%gt\245\144i",PropContentType +// "\240G\SOq\255\189`\SYN\NAK%\CAN\RS1\173\187\SI\232]~\208\149\ACK",PropWillDelayInterval 17058,PropMaximumPacketSize +// 12076,PropMaximumQoS 214,PropRequestProblemInformation 88,PropServerReference +// "\204\212~\218iJ\143\151\242",PropAuthenticationMethod "\238\232\NUL\167",PropContentType +// "\255Y\DC3n\144\t\DC4\183=<\149\157\192\158cx\221\224\DC4D\211s\131Mr"] TEST(SubACK5QCTest, Decode12) { - uint8_t pkt[] = {0x90, 0x66, 0x5b, 0x5d, 0x5d, 0x1f, 0x0, 0xf, 0x3e, 0x63, 0x27, 0xec, 0xff, 0x52, 0x93, - 0x9b, 0xb8, 0xd9, 0xea, 0x7a, 0xea, 0xde, 0x80, 0x19, 0xe6, 0x2, 0x0, 0x0, 0x5, 0xf2, - 0x2a, 0x74, 0x1a, 0x0, 0x4, 0xf1, 0x96, 0x56, 0x24, 0x9, 0x0, 0x1, 0xda, 0xb, 0xe, - 0x1f, 0x0, 0x1e, 0x61, 0xb, 0x87, 0x50, 0xcd, 0x65, 0x1e, 0xb6, 0xf1, 0xcc, 0x87, 0xd3, - 0x8a, 0x22, 0xa4, 0x6f, 0x45, 0x13, 0x96, 0xdc, 0x83, 0x94, 0xb0, 0xd8, 0x7, 0x84, 0x42, - 0xd4, 0x43, 0xa5, 0x11, 0x0, 0x0, 0xf, 0x55, 0x11, 0x0, 0x0, 0x21, 0xec, 0x27, 0x0, - 0x0, 0x74, 0xb8, 0x29, 0x97, 0x13, 0x2e, 0xdb, 0x2, 0x1, 0xa2, 0x0, 0x2, 0x8f}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 23389); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0xA2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x8F); -} - -// SubscribeResponse 3364 [Right QoS0,Left SubErrUnspecifiedError] [PropRequestResponseInformation -// 171,PropWildcardSubscriptionAvailable 54,PropRetainAvailable 169,PropAuthenticationData -// "\231S\SYN\130\168a~\202\192@y\150\251\201\FS&\SO[\224\170\193\142\173\177\235R",PropTopicAlias -// 13874,PropSharedSubscriptionAvailable 133,PropTopicAlias 1693,PropMessageExpiryInterval -// 17193,PropWildcardSubscriptionAvailable 83,PropTopicAlias 933,PropResponseTopic -// "E\243\170\t\180\191|X\150.N\185\182\254l\244\153",PropMaximumPacketSize 24169,PropServerReference -// "$\249*\140\197\133)+",PropPayloadFormatIndicator 194,PropSubscriptionIdentifierAvailable 124,PropWillDelayInterval -// 9096,PropResponseTopic -// "\132\143\135\168\f\251M\EOT\174\SORcp\RS\243\172\RS\209\199z\195\217\250\224Y\210\251",PropAuthenticationMethod -// "\208\181\202D\EM\FS\176\206g\183\191\166\249Rk\254\228\GSC\129\&6\149",PropReasonString -// "?\DC1\176\135\171\196\219X#p\207L-\143\140\131\207\153d|\211\206",PropTopicAliasMaximum -// 29896,PropSubscriptionIdentifier 26,PropServerReference -// "\SUB\161\250\&6\DC1^\SOH7)\DELI\222\138\201\ACK\240\189\199\&2",PropWildcardSubscriptionAvailable 147,PropTopicAlias -// 8676,PropMessageExpiryInterval 29724,PropSessionExpiryInterval 18665,PropUserProperty -// "\n\US\166jm\162\229\197U\233\131\229^$\b\155\200\214\187\196\156=6\241\139)\185T\ACK" -// "\181\SYN\201\250\166\207\172,\177\150\151\243\158\158oZ\222\DC3\247\147^\246x\184\197\130"] -TEST(SubACK5QCTest, Decode13) { - uint8_t pkt[] = { - 0x90, 0x9e, 0x2, 0xd, 0x24, 0x98, 0x2, 0x19, 0xab, 0x28, 0x36, 0x25, 0xa9, 0x16, 0x0, 0x1a, 0xe7, 0x53, 0x16, - 0x82, 0xa8, 0x61, 0x7e, 0xca, 0xc0, 0x40, 0x79, 0x96, 0xfb, 0xc9, 0x1c, 0x26, 0xe, 0x5b, 0xe0, 0xaa, 0xc1, 0x8e, - 0xad, 0xb1, 0xeb, 0x52, 0x23, 0x36, 0x32, 0x2a, 0x85, 0x23, 0x6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x73, 0x83, 0x4d, 0x72, 0x2, 0x9e, 0x83, 0x1, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3364); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(packet_id, 24874); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x9E); + EXPECT_EQ(granted_qos_levels[2], 0x83); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); } -// SubscribeResponse 8138 [Right QoS0,Right QoS1,Right QoS2] [PropRequestResponseInformation 205,PropUserProperty -// "N'\157\207$\151\235" "\197s\159\159\v\210\190\177DM\230N\138|i?`4\DEL \224\250\192a'\246X",PropReasonString -// "\199\170\197\SYN",PropSubscriptionIdentifier 13,PropRequestResponseInformation 161,PropUserProperty -// "\FSGFUWV\232\184\180{\ACK\253\181]y\138\167\ETB\157\&1\184N\163" -// "\247\176\&3\255\213\226\a\152\190\DEL\248sz\172s\DC1\SYNy",PropAuthenticationMethod -// "pL\167\EOT\203\133\&1\197D\181;\186_",PropMessageExpiryInterval 31515,PropAuthenticationMethod -// "\216k\143\208GU\CAN\ETX[\SI}\215\131S\FSg\226\GSC",PropWildcardSubscriptionAvailable 7,PropResponseInformation -// ":\233\164H\214\162\178B\STX\180A\160'\SOH\"\181Y\189&\DC4",PropAuthenticationData -// "~\EOT\223\158\150\216{\196\CANqE\252\EM\156\212\238B\166\SOH-\166\149z?\175/\140O\197",PropReasonString -// "o\217\221H\134t\157\b\170\156Ep\169\253\147\176@\222ov#O\128J\DC1C\134",PropTopicAlias 512,PropMessageExpiryInterval -// 29859,PropRequestResponseInformation 21,PropReceiveMaximum 4053,PropUserProperty -// "\219\208\200\148\DC29\217\DC24o\224" "\DC2wP\190",PropSubscriptionIdentifierAvailable 226,PropReceiveMaximum -// 16548,PropAssignedClientIdentifier "7Yw3\141\231\183",PropTopicAlias 8751] -TEST(SubACK5QCTest, Decode14) { - uint8_t pkt[] = {0x90, 0x9e, 0x2, 0x1f, 0xca, 0x97, 0x2, 0x19, 0xcd, 0x26, 0x0, 0x7, 0x4e, 0x27, 0x9d, 0xcf, 0x24, - 0x97, 0xeb, 0x0, 0x1b, 0xc5, 0x73, 0x9f, 0x9f, 0xb, 0xd2, 0xbe, 0xb1, 0x44, 0x4d, 0xe6, 0x4e, 0x8a, - 0x7c, 0x69, 0x3f, 0x60, 0x34, 0x7f, 0x20, 0xe0, 0xfa, 0xc0, 0x61, 0x27, 0xf6, 0x58, 0x1f, 0x0, 0x4, - 0xc7, 0xaa, 0xc5, 0x16, 0xb, 0xd, 0x19, 0xa1, 0x26, 0x0, 0x17, 0x1c, 0x47, 0x46, 0x55, 0x57, 0x56, - 0xe8, 0xb8, 0xb4, 0x7b, 0x6, 0xfd, 0xb5, 0x5d, 0x79, 0x8a, 0xa7, 0x17, 0x9d, 0x31, 0xb8, 0x4e, 0xa3, - 0x0, 0x12, 0xf7, 0xb0, 0x33, 0xff, 0xd5, 0xe2, 0x7, 0x98, 0xbe, 0x7f, 0xf8, 0x73, 0x7a, 0xac, 0x73, - 0x11, 0x16, 0x79, 0x15, 0x0, 0xd, 0x70, 0x4c, 0xa7, 0x4, 0xcb, 0x85, 0x31, 0xc5, 0x44, 0xb5, 0x3b, - 0xba, 0x5f, 0x2, 0x0, 0x0, 0x7b, 0x1b, 0x15, 0x0, 0x13, 0xd8, 0x6b, 0x8f, 0xd0, 0x47, 0x55, 0x18, - 0x3, 0x5b, 0xf, 0x7d, 0xd7, 0x83, 0x53, 0x1c, 0x67, 0xe2, 0x1d, 0x43, 0x28, 0x7, 0x1a, 0x0, 0x14, - 0x3a, 0xe9, 0xa4, 0x48, 0xd6, 0xa2, 0xb2, 0x42, 0x2, 0xb4, 0x41, 0xa0, 0x27, 0x1, 0x22, 0xb5, 0x59, - 0xbd, 0x26, 0x14, 0x16, 0x0, 0x1d, 0x7e, 0x4, 0xdf, 0x9e, 0x96, 0xd8, 0x7b, 0xc4, 0x18, 0x71, 0x45, - 0xfc, 0x19, 0x9c, 0xd4, 0xee, 0x42, 0xa6, 0x1, 0x2d, 0xa6, 0x95, 0x7a, 0x3f, 0xaf, 0x2f, 0x8c, 0x4f, - 0xc5, 0x1f, 0x0, 0x1b, 0x6f, 0xd9, 0xdd, 0x48, 0x86, 0x74, 0x9d, 0x8, 0xaa, 0x9c, 0x45, 0x70, 0xa9, - 0xfd, 0x93, 0xb0, 0x40, 0xde, 0x6f, 0x76, 0x23, 0x4f, 0x80, 0x4a, 0x11, 0x43, 0x86, 0x23, 0x2, 0x0, - 0x2, 0x0, 0x0, 0x74, 0xa3, 0x19, 0x15, 0x21, 0xf, 0xd5, 0x26, 0x0, 0xb, 0xdb, 0xd0, 0xc8, 0x94, - 0x12, 0x39, 0xd9, 0x12, 0x34, 0x6f, 0xe0, 0x0, 0x4, 0x12, 0x77, 0x50, 0xbe, 0x29, 0xe2, 0x21, 0x40, - 0xa4, 0x12, 0x0, 0x7, 0x37, 0x59, 0x77, 0x33, 0x8d, 0xe7, 0xb7, 0x23, 0x22, 0x2f, 0x0, 0x1, 0x2}; +// SubscribeResponse 25167 [Left SubErrQuotaExceeded] [PropTopicAliasMaximum 17510,PropContentType +// "\GS",PropServerKeepAlive 2458,PropRetainAvailable 194,PropSharedSubscriptionAvailable 100,PropAuthenticationData +// "\195\231\239\DC4x\255\224\156\154\194f\216D\136<\201\STX",PropRequestResponseInformation 52,PropWillDelayInterval +// 29739,PropContentType +// "l\152\190\DC1$\SYN\250]S\144\255\&1\220\252\EM\170\ACK\203K\153\209\162",PropSubscriptionIdentifierAvailable 85] +TEST(SubACK5QCTest, Decode13) { + uint8_t pkt[] = {0x90, 0x48, 0x62, 0x4f, 0x44, 0x22, 0x44, 0x66, 0x3, 0x0, 0x1, 0x1d, 0x13, 0x9, 0x9a, + 0x25, 0xc2, 0x2a, 0x64, 0x16, 0x0, 0x11, 0xc3, 0xe7, 0xef, 0x14, 0x78, 0xff, 0xe0, 0x9c, + 0x9a, 0xc2, 0x66, 0xd8, 0x44, 0x88, 0x3c, 0xc9, 0x2, 0x19, 0x34, 0x18, 0x0, 0x0, 0x74, + 0x2b, 0x3, 0x0, 0x16, 0x6c, 0x98, 0xbe, 0x11, 0x24, 0x16, 0xfa, 0x5d, 0x53, 0x90, 0xff, + 0x31, 0xdc, 0xfc, 0x19, 0xaa, 0x6, 0xcb, 0x4b, 0x99, 0xd1, 0xa2, 0x29, 0x55, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8138); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 25167); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], 0x97); } -// SubscribeResponse 7647 [Left SubErrTopicFilterInvalid,Left SubErrNotAuthorized,Left SubErrTopicFilterInvalid,Left -// SubErrUnspecifiedError,Left SubErrQuotaExceeded,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrQuotaExceeded,Left SubErrNotAuthorized,Left SubErrQuotaExceeded] [PropWillDelayInterval 18079,PropMaximumQoS -// 251,PropWillDelayInterval 8818,PropRetainAvailable 64,PropMessageExpiryInterval 24146,PropAuthenticationData -// "\150\233Rm+\170H0\249\189\141\178\199\234:\184\158\234-\vu\218\201Cza",PropTopicAlias -// 11739,PropSessionExpiryInterval 25398,PropWildcardSubscriptionAvailable 141,PropMaximumPacketSize -// 6767,PropReasonString "?Q\n",PropSubscriptionIdentifierAvailable 218,PropPayloadFormatIndicator -// 10,PropSharedSubscriptionAvailable 239,PropAuthenticationMethod "\250I",PropMessageExpiryInterval -// 32723,PropSessionExpiryInterval 2619,PropMaximumPacketSize 15529,PropTopicAliasMaximum 27150,PropTopicAliasMaximum -// 17762,PropSubscriptionIdentifierAvailable 49] -TEST(SubACK5QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0x73, 0x1d, 0xdf, 0x67, 0x18, 0x0, 0x0, 0x46, 0x9f, 0x24, 0xfb, 0x18, 0x0, 0x0, 0x22, 0x72, - 0x25, 0x40, 0x2, 0x0, 0x0, 0x5e, 0x52, 0x16, 0x0, 0x1a, 0x96, 0xe9, 0x52, 0x6d, 0x2b, 0xaa, 0x48, - 0x30, 0xf9, 0xbd, 0x8d, 0xb2, 0xc7, 0xea, 0x3a, 0xb8, 0x9e, 0xea, 0x2d, 0xb, 0x75, 0xda, 0xc9, 0x43, - 0x7a, 0x61, 0x23, 0x2d, 0xdb, 0x11, 0x0, 0x0, 0x63, 0x36, 0x28, 0x8d, 0x27, 0x0, 0x0, 0x1a, 0x6f, - 0x1f, 0x0, 0x3, 0x3f, 0x51, 0xa, 0x29, 0xda, 0x1, 0xa, 0x2a, 0xef, 0x15, 0x0, 0x2, 0xfa, 0x49, - 0x2, 0x0, 0x0, 0x7f, 0xd3, 0x11, 0x0, 0x0, 0xa, 0x3b, 0x27, 0x0, 0x0, 0x3c, 0xa9, 0x22, 0x6a, - 0xe, 0x22, 0x45, 0x62, 0x29, 0x31, 0x8f, 0x87, 0x8f, 0x80, 0x97, 0xa1, 0x97, 0x87, 0x97}; +// SubscribeResponse 7252 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left SubErrUnspecifiedError,Right +// QoS2,Right QoS1,Right QoS2,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0] [PropCorrelationData +// "\RS\SOH\152",PropRequestResponseInformation 7,PropWildcardSubscriptionAvailable 140,PropMaximumQoS +// 147,PropResponseInformation "\240\142\150R\252\236",PropRetainAvailable 125,PropPayloadFormatIndicator +// 9,PropContentType "\153\183\255\fB\212\134\216\ESC%\SUB",PropRequestResponseInformation +// 50,PropSubscriptionIdentifierAvailable 11,PropWillDelayInterval 15604,PropRetainAvailable 244,PropContentType +// "\"\201k1\246/`P\182\193\255\RSMQ\253\140\150+$\152\229\215E\179\225\182'`\156",PropWildcardSubscriptionAvailable +// 107,PropAssignedClientIdentifier "\255MI~\200\141\&4E\200s",PropRequestResponseInformation +// 225,PropSubscriptionIdentifier 4] +TEST(SubACK5QCTest, Decode14) { + uint8_t pkt[] = {0x90, 0x71, 0x1c, 0x54, 0x65, 0x9, 0x0, 0x3, 0x1e, 0x1, 0x98, 0x19, 0x7, 0x28, 0x8c, 0x24, 0x93, + 0x1a, 0x0, 0x6, 0xf0, 0x8e, 0x96, 0x52, 0xfc, 0xec, 0x25, 0x7d, 0x1, 0x9, 0x3, 0x0, 0xb, 0x99, + 0xb7, 0xff, 0xc, 0x42, 0xd4, 0x86, 0xd8, 0x1b, 0x25, 0x1a, 0x19, 0x32, 0x29, 0xb, 0x18, 0x0, 0x0, + 0x3c, 0xf4, 0x25, 0xf4, 0x3, 0x0, 0x1d, 0x22, 0xc9, 0x6b, 0x31, 0xf6, 0x2f, 0x60, 0x50, 0xb6, 0xc1, + 0xff, 0x1e, 0x4d, 0x51, 0xfd, 0x8c, 0x96, 0x2b, 0x24, 0x98, 0xe5, 0xd7, 0x45, 0xb3, 0xe1, 0xb6, 0x27, + 0x60, 0x9c, 0x28, 0x6b, 0x12, 0x0, 0xa, 0xff, 0x4d, 0x49, 0x7e, 0xc8, 0x8d, 0x34, 0x45, 0xc8, 0x73, + 0x19, 0xe1, 0xb, 0x4, 0xa2, 0x0, 0x80, 0x2, 0x1, 0x2, 0x0, 0xa1, 0x0}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[9]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7647); + EXPECT_EQ(packet_id, 7252); EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x8F); - EXPECT_EQ(granted_qos_levels[1], 0x87); - EXPECT_EQ(granted_qos_levels[2], 0x8F); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x97); - EXPECT_EQ(granted_qos_levels[5], 0xA1); - EXPECT_EQ(granted_qos_levels[6], 0x97); - EXPECT_EQ(granted_qos_levels[7], 0x87); - EXPECT_EQ(granted_qos_levels[8], 0x97); + EXPECT_EQ(granted_qos_levels[0], 0xA2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0xA1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); +} + +// SubscribeResponse 22592 [Left SubErrUnspecifiedError,Right QoS2,Right QoS0,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrPacketIdentifierInUse] [PropAssignedClientIdentifier +// "\171\205",PropWildcardSubscriptionAvailable 207,PropSharedSubscriptionAvailable 40,PropReceiveMaximum +// 8158,PropTopicAliasMaximum 20860,PropRequestProblemInformation 162,PropPayloadFormatIndicator +// 188,PropSessionExpiryInterval 7412,PropMaximumPacketSize 2196,PropTopicAliasMaximum 10660,PropServerReference +// "\t\203Q\139\155\157S\255\179\241=\\\v!\184\r\224\t\192\247\152\&5Nz\SYN",PropSubscriptionIdentifierAvailable +// 223,PropMessageExpiryInterval 27404,PropWillDelayInterval 21950,PropResponseInformation +// "]t\209\230\DC2\ENQ\248\SO\182\NAK\137i\147\149N`g'h\179\161\232\130|\177\225",PropMaximumQoS 165,PropUserProperty +// "\157U!\"" "\164\DLE>+S\153t\210\&6(\132z\172\175JJE\US\ETX\ETB\184_\157",PropCorrelationData +// "\222\DC4\SI\195\210\246\SYNkqz[\160\255p\152\DC3Jd,,q\148\DC2\DC32\\",PropResponseTopic +// "\188==l\255\182JXe\150\&9\192l",PropResponseInformation +// "\133\DC36E_\255\178.7\f\130\250\181\250\&1l\210\231\129;K?\170\NUL\r\vWW",PropAuthenticationData +// "^\192",PropRequestProblemInformation 202,PropSessionExpiryInterval 9944,PropUserProperty +// "\239\STX\135\176x+\241\158\&7" "\225"] +TEST(SubACK5QCTest, Decode15) { + uint8_t pkt[] = {0x90, 0xf7, 0x1, 0x58, 0x40, 0xee, 0x1, 0x12, 0x0, 0x2, 0xab, 0xcd, 0x28, 0xcf, 0x2a, 0x28, 0x21, + 0x1f, 0xde, 0x22, 0x51, 0x7c, 0x17, 0xa2, 0x1, 0xbc, 0x11, 0x0, 0x0, 0x1c, 0xf4, 0x27, 0x0, 0x0, + 0x8, 0x94, 0x22, 0x29, 0xa4, 0x1c, 0x0, 0x19, 0x9, 0xcb, 0x51, 0x8b, 0x9b, 0x9d, 0x53, 0xff, 0xb3, + 0xf1, 0x3d, 0x5c, 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 0x37, 0x0, 0x1, 0xe1, 0x80, 0x2, 0x0, 0xa1, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 22592); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0xA1); + EXPECT_EQ(granted_qos_levels[4], 0x91); } -// SubscribeResponse 4989 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [PropWillDelayInterval 22475] +// SubscribeResponse 1930 [Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right QoS2,Left SubErrQuotaExceeded,Right QoS1,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Left SubErrTopicFilterInvalid,Left +// SubErrTopicFilterInvalid,Left SubErrUnspecifiedError] [PropPayloadFormatIndicator 152,PropMessageExpiryInterval +// 4959,PropUserProperty "7\201b]v\237" +// "\SOH\159\194\223\SUBL\240\232\234\b\227\193\176y\216\&4\222\235\&7\141\163U",PropCorrelationData +// "\176\167l\148\185\207\204\165R\SI\145Q\DC3I\242\210F\216\160X;",PropSharedSubscriptionAvailable +// 200,PropAuthenticationMethod "\238\154D\219\219\&6\231\222\231\RS\212\180\SOH\155\ACK"] TEST(SubACK5QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0xa, 0x13, 0x7d, 0x5, 0x18, 0x0, 0x0, 0x57, 0xcb, 0x1, 0xa1}; + uint8_t pkt[] = {0x90, 0x62, 0x7, 0x8a, 0x54, 0x1, 0x98, 0x2, 0x0, 0x0, 0x13, 0x5f, 0x26, 0x0, 0x6, 0x37, 0xc9, + 0x62, 0x5d, 0x76, 0xed, 0x0, 0x16, 0x1, 0x9f, 0xc2, 0xdf, 0x1a, 0x4c, 0xf0, 0xe8, 0xea, 0x8, 0xe3, + 0xc1, 0xb0, 0x79, 0xd8, 0x34, 0xde, 0xeb, 0x37, 0x8d, 0xa3, 0x55, 0x9, 0x0, 0x15, 0xb0, 0xa7, 0x6c, + 0x94, 0xb9, 0xcf, 0xcc, 0xa5, 0x52, 0xf, 0x91, 0x51, 0x13, 0x49, 0xf2, 0xd2, 0x46, 0xd8, 0xa0, 0x58, + 0x3b, 0x2a, 0xc8, 0x15, 0x0, 0xf, 0xee, 0x9a, 0x44, 0xdb, 0xdb, 0x36, 0xe7, 0xde, 0xe7, 0x1e, 0xd4, + 0xb4, 0x1, 0x9b, 0x6, 0xa2, 0xa2, 0x0, 0x2, 0x97, 0x1, 0xa1, 0x8f, 0x8f, 0x8f, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4989); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0xA1); -} - -// SubscribeResponse 12633 [Right QoS2,Right QoS0,Right QoS0,Right QoS1] [PropPayloadFormatIndicator 144,PropMaximumQoS -// 159,PropPayloadFormatIndicator 65] + EXPECT_EQ(packet_id, 1930); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0xA2); + EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x97); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0xA1); + EXPECT_EQ(granted_qos_levels[7], 0x8F); + EXPECT_EQ(granted_qos_levels[8], 0x8F); + EXPECT_EQ(granted_qos_levels[9], 0x8F); + EXPECT_EQ(granted_qos_levels[10], 0x80); +} + +// SubscribeResponse 32288 [Right QoS1,Right QoS0,Right QoS1,Right QoS2,Left SubErrImplementationSpecificError,Right +// QoS1,Left SubErrQuotaExceeded,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrUnspecifiedError] +// [PropServerKeepAlive 23284,PropAssignedClientIdentifier +// "\190\249\154$@\SO\248G\209e\238:`O\254\242\151<\223",PropUserProperty +// "\ESCS\146a\EOT\245+\162\142\DEL\173\168\f\208C\200;\212\211,\253\238\154!\187\219\182o\130" +// "\235\157\162\209\247>c\EM\186O\NUL\150\220\EOTN\185",PropTopicAliasMaximum 30054,PropMaximumPacketSize +// 1391,PropSessionExpiryInterval 20428,PropSessionExpiryInterval 30001] TEST(SubACK5QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0xd, 0x31, 0x59, 0x6, 0x1, 0x90, 0x24, 0x9f, 0x1, 0x41, 0x2, 0x0, 0x0, 0x1}; + uint8_t pkt[] = {0x90, 0x6b, 0x7e, 0x20, 0x5d, 0x13, 0x5a, 0xf4, 0x12, 0x0, 0x13, 0xbe, 0xf9, 0x9a, 0x24, 0x40, + 0xe, 0xf8, 0x47, 0xd1, 0x65, 0xee, 0x3a, 0x60, 0x4f, 0xfe, 0xf2, 0x97, 0x3c, 0xdf, 0x26, 0x0, + 0x1d, 0x1b, 0x53, 0x92, 0x61, 0x4, 0xf5, 0x2b, 0xa2, 0x8e, 0x7f, 0xad, 0xa8, 0xc, 0xd0, 0x43, + 0xc8, 0x3b, 0xd4, 0xd3, 0x2c, 0xfd, 0xee, 0x9a, 0x21, 0xbb, 0xdb, 0xb6, 0x6f, 0x82, 0x0, 0x10, + 0xeb, 0x9d, 0xa2, 0xd1, 0xf7, 0x3e, 0x63, 0x19, 0xba, 0x4f, 0x0, 0x96, 0xdc, 0x4, 0x4e, 0xb9, + 0x22, 0x75, 0x66, 0x27, 0x0, 0x0, 0x5, 0x6f, 0x11, 0x0, 0x0, 0x4f, 0xcc, 0x11, 0x0, 0x0, + 0x75, 0x31, 0x1, 0x0, 0x1, 0x2, 0x83, 0x1, 0x97, 0x1, 0x91, 0x2, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12633); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 32288); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); -} - -// SubscribeResponse 1188 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported] [PropMaximumPacketSize -// 18249,PropWildcardSubscriptionAvailable 131,PropTopicAlias 26908,PropResponseTopic -// "\239\255!7\234\DC3\220kv\129\247k\209\226\ACK\222\148\160\227e\SUBo\225",PropSessionExpiryInterval -// 32084,PropAuthenticationMethod -// "\246`C\209\218\227\196Z0\153\143\v\254\212j\223\t\182\202\251\208\NULX",PropRequestResponseInformation -// 196,PropSubscriptionIdentifier 21,PropWildcardSubscriptionAvailable 32,PropReceiveMaximum -// 3585,PropRequestProblemInformation 163,PropCorrelationData -// "\245\159K\133\158G\207\132L\223\168w\172\162Gu{3\196",PropContentType -// "\182\DC3Rh\218\CAN\196\164W\220\EM",PropServerKeepAlive 28344,PropSessionExpiryInterval 9213,PropTopicAliasMaximum -// 29557,PropMaximumPacketSize 1064,PropMaximumPacketSize 6638] + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x83); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x97); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], 0x91); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[10], 0x80); +} + +// SubscribeResponse 8665 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left +// SubErrQuotaExceeded,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS2,Right QoS2] [PropSharedSubscriptionAvailable +// 207,PropAssignedClientIdentifier +// "\249@q\US:\253\n\219\187\170X\168\DLE\154O@\DC4\186\255",PropRequestProblemInformation +// 174,PropRequestResponseInformation 157,PropRetainAvailable 88,PropWillDelayInterval +// 21067,PropSharedSubscriptionAvailable 113,PropResponseTopic "\207",PropWildcardSubscriptionAvailable +// 132,PropResponseInformation "\204$\250*\ACKiR",PropServerReference +// "\221\197\211\233G\GS\191_9i-\168\133f^)C\b",PropUserProperty "\199\143" +// "#N\192\243.R\244\DELT\191|\235,",PropMessageExpiryInterval 24446,PropTopicAliasMaximum +// 3665,PropSharedSubscriptionAvailable 102,PropReasonString +// "JG\149N\147\STXc|\191\210Z\156\246\249\128\252r",PropAssignedClientIdentifier +// "\236q\131\203\r\EM\ENQ!s)\201\245\176Q\185\133\243\145\143",PropWillDelayInterval 12649,PropServerReference ""] TEST(SubACK5QCTest, Decode18) { - uint8_t pkt[] = {0x90, 0x8d, 0x1, 0x4, 0xa4, 0x87, 0x1, 0x27, 0x0, 0x0, 0x47, 0x49, 0x28, 0x83, 0x23, 0x69, - 0x1c, 0x8, 0x0, 0x17, 0xef, 0xff, 0x21, 0x37, 0xea, 0x13, 0xdc, 0x6b, 0x76, 0x81, 0xf7, 0x6b, - 0xd1, 0xe2, 0x6, 0xde, 0x94, 0xa0, 0xe3, 0x65, 0x1a, 0x6f, 0xe1, 0x11, 0x0, 0x0, 0x7d, 0x54, - 0x15, 0x0, 0x17, 0xf6, 0x60, 0x43, 0xd1, 0xda, 0xe3, 0xc4, 0x5a, 0x30, 0x99, 0x8f, 0xb, 0xfe, - 0xd4, 0x6a, 0xdf, 0x9, 0xb6, 0xca, 0xfb, 0xd0, 0x0, 0x58, 0x19, 0xc4, 0xb, 0x15, 0x28, 0x20, - 0x21, 0xe, 0x1, 0x17, 0xa3, 0x9, 0x0, 0x13, 0xf5, 0x9f, 0x4b, 0x85, 0x9e, 0x47, 0xcf, 0x84, - 0x4c, 0xdf, 0xa8, 0x77, 0xac, 0xa2, 0x47, 0x75, 0x7b, 0x33, 0xc4, 0x3, 0x0, 0xb, 0xb6, 0x13, - 0x52, 0x68, 0xda, 0x18, 0xc4, 0xa4, 0x57, 0xdc, 0x19, 0x13, 0x6e, 0xb8, 0x11, 0x0, 0x0, 0x23, - 0xfd, 0x22, 0x73, 0x75, 0x27, 0x0, 0x0, 0x4, 0x28, 0x27, 0x0, 0x0, 0x19, 0xee, 0x0, 0xa2}; + uint8_t pkt[] = {0x90, 0xa5, 0x1, 0x21, 0xd9, 0x9a, 0x1, 0x2a, 0xcf, 0x12, 0x0, 0x13, 0xf9, 0x40, 0x71, 0x1f, 0x3a, + 0xfd, 0xa, 0xdb, 0xbb, 0xaa, 0x58, 0xa8, 0x10, 0x9a, 0x4f, 0x40, 0x14, 0xba, 0xff, 0x17, 0xae, 0x19, + 0x9d, 0x25, 0x58, 0x18, 0x0, 0x0, 0x52, 0x4b, 0x2a, 0x71, 0x8, 0x0, 0x1, 0xcf, 0x28, 0x84, 0x1a, + 0x0, 0x7, 0xcc, 0x24, 0xfa, 0x2a, 0x6, 0x69, 0x52, 0x1c, 0x0, 0x12, 0xdd, 0xc5, 0xd3, 0xe9, 0x47, + 0x1d, 0xbf, 0x5f, 0x39, 0x69, 0x2d, 0xa8, 0x85, 0x66, 0x5e, 0x29, 0x43, 0x8, 0x26, 0x0, 0x2, 0xc7, + 0x8f, 0x0, 0xd, 0x23, 0x4e, 0xc0, 0xf3, 0x2e, 0x52, 0xf4, 0x7f, 0x54, 0xbf, 0x7c, 0xeb, 0x2c, 0x2, + 0x0, 0x0, 0x5f, 0x7e, 0x22, 0xe, 0x51, 0x2a, 0x66, 0x1f, 0x0, 0x11, 0x4a, 0x47, 0x95, 0x4e, 0x93, + 0x2, 0x63, 0x7c, 0xbf, 0xd2, 0x5a, 0x9c, 0xf6, 0xf9, 0x80, 0xfc, 0x72, 0x12, 0x0, 0x13, 0xec, 0x71, + 0x83, 0xcb, 0xd, 0x19, 0x5, 0x21, 0x73, 0x29, 0xc9, 0xf5, 0xb0, 0x51, 0xb9, 0x85, 0xf3, 0x91, 0x8f, + 0x18, 0x0, 0x0, 0x31, 0x69, 0x1c, 0x0, 0x0, 0x9e, 0x80, 0x97, 0x2, 0x8f, 0x2, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1188); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(packet_id, 8665); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x97); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x8F); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); } -// SubscribeResponse 17587 [Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS0,Left -// SubErrNotAuthorized,Right QoS0] [PropResponseTopic -// "j\205\183\182\235\tQ\168\206F]R\149-{\243]\243@\147\242\ETX{K\247@",PropRequestResponseInformation -// 119,PropAssignedClientIdentifier "n=E\128*\174\154\DLE\DLE\143n\251s)c\203\219\211\193Lo\241q#=\195",PropReasonString -// "$\128\164\202wr3M+\133T\207|Y\142\194$UV\148",PropRequestProblemInformation 41,PropMessageExpiryInterval -// 5040,PropAuthenticationMethod -// "m\US\198\223qI\152\160>.\182\vP\150A\165\249\"&\171\ESCf\180LAC",PropSubscriptionIdentifierAvailable -// 139,PropResponseInformation "\176\t_\135\137\246|[\191\187\182i\US\150\EOT",PropMessageExpiryInterval -// 1423,PropRetainAvailable 245,PropWillDelayInterval 29895,PropUserProperty "\a\ETBQ\SO\134\139\NAKdX\206\145Z" -// "\178\165x\140\GS\203\ETX\DC1\161Z\128\162\237a\f\255N\174\196\NAK-\136\176\218",PropSubscriptionIdentifierAvailable -// 120,PropReasonString "C",PropSubscriptionIdentifierAvailable 10,PropResponseTopic -// "\f\201\DLE\238",PropSharedSubscriptionAvailable 70,PropResponseInformation -// "\151\249\232r\150\188\191F\208\237\177\142s\a\232L\169\203\206\193.w",PropResponseTopic -// "!u\a\209",PropAuthenticationData "\EM\138\137\158\NULG\181\205\US\132\221\145H\153\244\"",PropServerKeepAlive -// 12070,PropReasonString "\192\209\193\154*+\228\215d",PropAssignedClientIdentifier -// "+\214\233H\199$\"\198|_\182\135\137[4\131\209\139\161\214\n\193\DC1\130\199\DC3l",PropPayloadFormatIndicator -// 29,PropRequestProblemInformation 87,PropServerKeepAlive 22897,PropContentType "\181\&0 \243F"] +// SubscribeResponse 32158 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left +// SubErrWildcardSubscriptionsNotSupported] [PropAssignedClientIdentifier +// "\181\252\207\137\ETBo\129\ESC1\139\131\n3P\230D",PropSubscriptionIdentifierAvailable 255,PropMessageExpiryInterval +// 10411,PropSubscriptionIdentifierAvailable 213,PropCorrelationData +// "\NAK\222\151\139\218l\216\150\245\132g\194cT\186\242d\STX\159:i\132\FS/J\SUBm",PropUserProperty +// "\158\230Q\241b2x0\186\132NB4X\129D\129\128PQ\139\STX\230\203\&8`" "\156",PropRetainAvailable 197,PropRetainAvailable +// 24,PropMessageExpiryInterval 18114,PropContentType "|\239\150\EM\NAK[\220\129o\151\128",PropTopicAliasMaximum +// 18832,PropAuthenticationData +// "\219\SYN\CAN\227\249S\DEL\CAN/\129\ETB\240X\213Sub\176%!\SYN\135*\EM\NAK$",PropSubscriptionIdentifierAvailable +// 236,PropContentType "'\227\STXp`\174\DEL",PropContentType "\EOT\222\FS0\177\218",PropAuthenticationMethod +// "\168\251\181s\167j\SUB\SI} \ENQv\187Oi\US\233\ENQ\213\157x\232\208j/a\132\237M\a",PropAuthenticationMethod +// "a(\145",PropTopicAliasMaximum 7553,PropCorrelationData "",PropWillDelayInterval 5167,PropReasonString +// "",PropReceiveMaximum 15579,PropAssignedClientIdentifier "\ACK.\173",PropServerReference +// "\136\202\179@\163\228\215\&5:I\201\180\221\186\161Tw\130\154\174A\212",PropAssignedClientIdentifier +// "\211s18",PropTopicAliasMaximum 5758,PropServerKeepAlive 16122] TEST(SubACK5QCTest, Decode19) { uint8_t pkt[] = { - 0x90, 0xce, 0x2, 0x44, 0xb3, 0xc0, 0x2, 0x8, 0x0, 0x1a, 0x6a, 0xcd, 0xb7, 0xb6, 0xeb, 0x9, 0x51, 0xa8, 0xce, - 0x46, 0x5d, 0x52, 0x95, 0x2d, 0x7b, 0xf3, 0x5d, 0xf3, 0x40, 0x93, 0xf2, 0x3, 0x7b, 0x4b, 0xf7, 0x40, 0x19, 0x77, - 0x12, 0x0, 0x1a, 0x6e, 0x3d, 0x45, 0x80, 0x2a, 0xae, 0x9a, 0x10, 0x10, 0x8f, 0x6e, 0xfb, 0x73, 0x29, 0x63, 0xcb, - 0xdb, 0xd3, 0xc1, 0x4c, 0x6f, 0xf1, 0x71, 0x23, 0x3d, 0xc3, 0x1f, 0x0, 0x14, 0x24, 0x80, 0xa4, 0xca, 0x77, 0x72, - 0x33, 0x4d, 0x2b, 0x85, 0x54, 0xcf, 0x7c, 0x59, 0x8e, 0xc2, 0x24, 0x55, 0x56, 0x94, 0x17, 0x29, 0x2, 0x0, 0x0, - 0x13, 0xb0, 0x15, 0x0, 0x1a, 0x6d, 0x1f, 0xc6, 0xdf, 0x71, 0x49, 0x98, 0xa0, 0x3e, 0x2e, 0xb6, 0xb, 0x50, 0x96, - 0x41, 0xa5, 0xf9, 0x22, 0x26, 0xab, 0x1b, 0x66, 0xb4, 0x4c, 0x41, 0x43, 0x29, 0x8b, 0x1a, 0x0, 0xf, 0xb0, 0x9, - 0x5f, 0x87, 0x89, 0xf6, 0x7c, 0x5b, 0xbf, 0xbb, 0xb6, 0x69, 0x1f, 0x96, 0x4, 0x2, 0x0, 0x0, 0x5, 0x8f, 0x25, - 0xf5, 0x18, 0x0, 0x0, 0x74, 0xc7, 0x26, 0x0, 0xc, 0x7, 0x17, 0x51, 0xe, 0x86, 0x8b, 0x15, 0x64, 0x58, 0xce, - 0x91, 0x5a, 0x0, 0x18, 0xb2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44, 0x29, 0xff, 0x2, 0x0, 0x0, 0x28, 0xab, 0x29, 0xd5, 0x9, 0x0, 0x1b, + 0x15, 0xde, 0x97, 0x8b, 0xda, 0x6c, 0xd8, 0x96, 0xf5, 0x84, 0x67, 0xc2, 0x63, 0x54, 0xba, 0xf2, 0x64, 0x2, 0x9f, + 0x3a, 0x69, 0x84, 0x1c, 0x2f, 0x4a, 0x1a, 0x6d, 0x26, 0x0, 0x1a, 0x9e, 0xe6, 0x51, 0xf1, 0x62, 0x32, 0x78, 0x30, + 0xba, 0x84, 0x4e, 0x42, 0x34, 0x58, 0x81, 0x44, 0x81, 0x80, 0x50, 0x51, 0x8b, 0x2, 0xe6, 0xcb, 0x38, 0x60, 0x0, + 0x1, 0x9c, 0x25, 0xc5, 0x25, 0x18, 0x2, 0x0, 0x0, 0x46, 0xc2, 0x3, 0x0, 0xb, 0x7c, 0xef, 0x96, 0x19, 0x15, + 0x5b, 0xdc, 0x81, 0x6f, 0x97, 0x80, 0x22, 0x49, 0x90, 0x16, 0x0, 0x1a, 0xdb, 0x16, 0x18, 0xe3, 0xf9, 0x53, 0x7f, + 0x18, 0x2f, 0x81, 0x17, 0xf0, 0x58, 0xd5, 0x53, 0x75, 0x62, 0xb0, 0x25, 0x21, 0x16, 0x87, 0x2a, 0x19, 0x15, 0x24, + 0x29, 0xec, 0x3, 0x0, 0x7, 0x27, 0xe3, 0x2, 0x70, 0x60, 0xae, 0x7f, 0x3, 0x0, 0x6, 0x4, 0xde, 0x1c, 0x30, + 0xb1, 0xda, 0x15, 0x0, 0x1e, 0xa8, 0xfb, 0xb5, 0x73, 0xa7, 0x6a, 0x1a, 0xf, 0x7d, 0x20, 0x5, 0x76, 0xbb, 0x4f, + 0x69, 0x1f, 0xe9, 0x5, 0xd5, 0x9d, 0x78, 0xe8, 0xd0, 0x6a, 0x2f, 0x61, 0x84, 0xed, 0x4d, 0x7, 0x15, 0x0, 0x3, + 0x61, 0x28, 0x91, 0x22, 0x1d, 0x81, 0x9, 0x0, 0x0, 0x18, 0x0, 0x0, 0x14, 0x2f, 0x1f, 0x0, 0x0, 0x21, 0x3c, + 0xdb, 0x12, 0x0, 0x3, 0x6, 0x2e, 0xad, 0x1c, 0x0, 0x16, 0x88, 0xca, 0xb3, 0x40, 0xa3, 0xe4, 0xd7, 0x35, 0x3a, + 0x49, 0xc9, 0xb4, 0xdd, 0xba, 0xa1, 0x54, 0x77, 0x82, 0x9a, 0xae, 0x41, 0xd4, 0x12, 0x0, 0x4, 0xd3, 0x73, 0x31, + 0x38, 0x22, 0x16, 0x7e, 0x13, 0x3e, 0xfa, 0xa2, 0x0, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17587); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 32158); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0xA2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], 0xA2); - EXPECT_EQ(granted_qos_levels[3], 0x8F); - EXPECT_EQ(granted_qos_levels[4], 0xA2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], 0x87); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); } -// SubscribeResponse 7329 [Right QoS2,Left SubErrPacketIdentifierInUse] [PropRequestProblemInformation -// 249,PropTopicAlias 26290,PropSharedSubscriptionAvailable 248,PropUserProperty -// "T\178\&3\176L\222h;\184s\134\180\157\b\226\SI\ETB\207M\186}Y?\141\162\208\DLE" -// "`{>|\\\202\249$\195\&5\EM\188B\191\131\227\241\215\173\&3\191p\147\175",PropReasonString -// "\DC1(\184P\199\184\196\ESC\153\209/",PropWillDelayInterval 7562,PropCorrelationData -// "_\FS/\185G\205\169^\217\246\NULi\FS\227\SOH\229gh\246\225",PropSharedSubscriptionAvailable 220,PropMaximumQoS -// 176,PropMessageExpiryInterval 18923,PropWillDelayInterval 18806,PropUserProperty -// "PN\139\221\197GeM\164\201\169q\144\186\184wZ\223\200\199\181\203?\246\v\192" "\215\174",PropAuthenticationMethod -// "\146\195\DC4\149\150\239\203\248!P\206N\"8\234?\163o!\STX\165\204t\196,d",PropResponseInformation -// "\185;\166_T\154-P\166\DEL",PropTopicAliasMaximum 25060,PropAuthenticationData "\\\184",PropPayloadFormatIndicator -// 248,PropSubscriptionIdentifierAvailable 126,PropMaximumQoS 10,PropTopicAliasMaximum 2628,PropResponseTopic -// "\220\n\156\SOj}oL",PropRequestProblemInformation 244,PropRequestProblemInformation 191,PropServerKeepAlive -// 5460,PropMessageExpiryInterval 16666] +// SubscribeResponse 9271 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS2,Right QoS0,Left +// SubErrQuotaExceeded,Right QoS0,Right QoS2] [PropReasonString +// "1\202]\141\169\238\189\178TQ\252\STX\172\201\151\132\237\250\158\229x",PropServerReference "\136\148 +// m\248\DC1W/O",PropRequestResponseInformation 28,PropSubscriptionIdentifier 25,PropWillDelayInterval +// 22265,PropWildcardSubscriptionAvailable 195,PropTopicAlias 18986,PropMaximumPacketSize +// 19940,PropSubscriptionIdentifier 11,PropMessageExpiryInterval 22097] TEST(SubACK5QCTest, Decode20) { - uint8_t pkt[] = { - 0x90, 0xf0, 0x1, 0x1c,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0x1a, 0x0, - 0xa, 0xb9, 0x3b, 0xa6, 0x5f, 0x54, 0x9a, 0x2d, 0x50, 0xa6, 0x7f, 0x22, 0x61, 0xe4, 0x16, 0x0, 0x2, 0x5c, 0xb8, - 0x1, 0xf8, 0x29, 0x7e, 0x24, 0xa, 0x22, 0xa, 0x44, 0x8, 0x0, 0x8, 0xdc, 0xa, 0x9c, 0xe, 0x6a, 0x7d, 0x6f, - 0x4c, 0x17, 0xf4, 0x17, 0xbf, 0x13, 0x15, 0x54, 0x2, 0x0, 0x0, 0x41, 0x1a, 0x2, 0x91}; + uint8_t pkt[] = {0x90, 0x48, 0x24, 0x37, 0x3e, 0x1f, 0x0, 0x15, 0x31, 0xca, 0x5d, 0x8d, 0xa9, 0xee, 0xbd, + 0xb2, 0x54, 0x51, 0xfc, 0x2, 0xac, 0xc9, 0x97, 0x84, 0xed, 0xfa, 0x9e, 0xe5, 0x78, 0x1c, + 0x0, 0x9, 0x88, 0x94, 0x20, 0x6d, 0xf8, 0x11, 0x57, 0x2f, 0x4f, 0x19, 0x1c, 0xb, 0x19, + 0x18, 0x0, 0x0, 0x56, 0xf9, 0x28, 0xc3, 0x23, 0x4a, 0x2a, 0x27, 0x0, 0x0, 0x4d, 0xe4, + 0xb, 0xb, 0x2, 0x0, 0x0, 0x56, 0x51, 0xa1, 0x1, 0x2, 0x0, 0x97, 0x0, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7329); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x91); + EXPECT_EQ(packet_id, 9271); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x97); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); } -// SubscribeResponse 19479 [Right QoS1] [PropMessageExpiryInterval 22457,PropRequestResponseInformation -// 8,PropWildcardSubscriptionAvailable 23,PropMessageExpiryInterval 24259,PropSharedSubscriptionAvailable -// 44,PropWildcardSubscriptionAvailable 9,PropSubscriptionIdentifier 21] +// SubscribeResponse 4115 [Left SubErrUnspecifiedError,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrNotAuthorized,Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError] [PropTopicAlias +// 1711,PropReasonString "PZ\t<\222{\r\162",PropResponseTopic "a\129*\198\DEL\n",PropMessageExpiryInterval +// 23699,PropSharedSubscriptionAvailable 220] TEST(SubACK5QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0x18, 0x4c, 0x17, 0x14, 0x2, 0x0, 0x0, 0x57, 0xb9, 0x19, 0x8, 0x28, - 0x17, 0x2, 0x0, 0x0, 0x5e, 0xc3, 0x2a, 0x2c, 0x28, 0x9, 0xb, 0x15, 0x1}; + uint8_t pkt[] = {0x90, 0x26, 0x10, 0x13, 0x1e, 0x23, 0x6, 0xaf, 0x1f, 0x0, 0x8, 0x50, 0x5a, 0x9, + 0x3c, 0xde, 0x7b, 0xd, 0xa2, 0x8, 0x0, 0x6, 0x61, 0x81, 0x2a, 0xc6, 0x7f, 0xa, + 0x2, 0x0, 0x0, 0x5c, 0x93, 0x2a, 0xdc, 0x80, 0x9e, 0x87, 0x9e, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19479); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 4115); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x9E); + EXPECT_EQ(granted_qos_levels[2], 0x87); + EXPECT_EQ(granted_qos_levels[3], 0x9E); + EXPECT_EQ(granted_qos_levels[4], 0x80); } -// SubscribeResponse 4187 [Right QoS2,Right QoS1,Left SubErrQuotaExceeded,Right QoS1,Right QoS0,Right QoS2,Left -// SubErrImplementationSpecificError] [PropCorrelationData -// "\199\232\188I\216\178+\205\243\189\248w[\140\233E\165\&5:\167\173\&5J\153^\SOHA\199",PropReasonString -// "\224ZZ.8\152k\ETXE\137\187!+\NAK\147@",PropAuthenticationMethod -// "\221\130\RS'\143\237\134\198\SO\174\201m\150\220\168\134l\NAKL2y\253-\215\246",PropCorrelationData -// ".\142\FS\185\160$(\173\&5x\204-7\189\234uY\228\132\156F\210\251\145\129\136\144\249",PropSharedSubscriptionAvailable -// 209,PropMessageExpiryInterval 2510,PropSharedSubscriptionAvailable 231,PropAuthenticationMethod "\171\DLE -// WY\166>\ENQK\176n\246\177\252k\165\DC3h#-E\254\226",PropSubscriptionIdentifierAvailable 199,PropUserProperty -// "\157\248\154o\185" "*\ETBo\154",PropAssignedClientIdentifier "\210U\199\232\192Zy\RSX",PropResponseInformation -// "\182\&9\140\192VC\186 \168\RS\220",PropPayloadFormatIndicator 125,PropMessageExpiryInterval 26196,PropTopicAlias -// 2336,PropRetainAvailable 220,PropWildcardSubscriptionAvailable 12,PropServerReference -// "\EOT\a\250P\218\131\STX\EM\EOT\175\141\250\235]\ETX*)\249F\205\149\DEL@\229=T\205Z\183\219",PropSessionExpiryInterval -// 32172,PropSubscriptionIdentifier 14,PropAssignedClientIdentifier "\STX$C\145\STX\ETX",PropServerKeepAlive -// 21027,PropMessageExpiryInterval 24132,PropReceiveMaximum 30095,PropServerReference -// "s\173\191\208\&6\\\STX\206\DC1\131\241\165\DLE\t\230\r",PropTopicAlias 14796,PropRetainAvailable 120] +// SubscribeResponse 24961 [Right QoS2,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Left SubErrTopicFilterInvalid,Left +// SubErrQuotaExceeded,Right QoS0,Left SubErrQuotaExceeded,Right QoS2,Right QoS0] [PropServerReference +// "\nClt\172\176z6d\NUL\137\203\212\162QA\155\142\180p<\254\SI_qm",PropSubscriptionIdentifier +// 8,PropAssignedClientIdentifier "P\ETXqo\254\157\150\203Eu\226\141X\233\DEL\218Y\197`\NUL\b\152\134\SOHz\r"] TEST(SubACK5QCTest, Decode22) { - uint8_t pkt[] = { - 0x90, 0xa7, 0x2, 0x10, 0x5b, 0x9c, 0x2, 0x9, 0x0, 0x1c, 0xc7, 0xe8, 0xbc, 0x49, 0xd8, 0xb2, 0x2b, 0xcd, 0xf3, - 0xbd, 0xf8, 0x77, 0x5b, 0x8c, 0xe9, 0x45, 0xa5, 0x35, 0x3a, 0xa7, 0xad, 0x35, 0x4a, 0x99, 0x5e, 0x1, 0x41, 0xc7, - 0x1f, 0x0, 0x10, 0xe0, 0x5a, 0x5a, 0x2e, 0x38, 0x98, 0x6b, 0x3, 0x45, 0x89, 0xbb, 0x21, 0x2b, 0x15, 0x93, 0x40, - 0x15, 0x0, 0x19, 0xdd, 0x82, 0x1e, 0x27, 0x8f, 0xed, 0x86, 0xc6, 0xe, 0xae, 0xc9, 0x6d, 0x96, 0xdc, 0xa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x0, 0x5e, 0x44, 0x21, 0x75, - 0x8f, 0x1c, 0x0, 0x10, 0x73, 0xad, 0xbf, 0xd0, 0x36, 0x5c, 0x2, 0xce, 0x11, 0x83, 0xf1, 0xa5, 0x10, 0x9, 0xe6, - 0xd, 0x23, 0x39, 0xcc, 0x25, 0x78, 0x2, 0x1, 0x97, 0x1, 0x0, 0x2, 0x83}; + uint8_t pkt[] = {0x90, 0x49, 0x61, 0x81, 0x3c, 0x1c, 0x0, 0x1a, 0xa, 0x43, 0x6c, 0x74, 0xac, 0xb0, 0x7a, + 0x36, 0x64, 0x0, 0x89, 0xcb, 0xd4, 0xa2, 0x51, 0x41, 0x9b, 0x8e, 0xb4, 0x70, 0x3c, 0xfe, + 0xf, 0x5f, 0x71, 0x6d, 0xb, 0x8, 0x12, 0x0, 0x1a, 0x50, 0x3, 0x71, 0x6f, 0xfe, 0x9d, + 0x96, 0xcb, 0x45, 0x75, 0xe2, 0x8d, 0x58, 0xe9, 0x7f, 0xda, 0x59, 0xc5, 0x60, 0x0, 0x8, + 0x98, 0x86, 0x1, 0x7a, 0xd, 0x2, 0x0, 0x97, 0x0, 0x8f, 0x97, 0x0, 0x97, 0x2, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4187); - EXPECT_EQ(count, 7); + EXPECT_EQ(packet_id, 24961); + EXPECT_EQ(count, 10); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], 0x97); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0x83); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x8F); + EXPECT_EQ(granted_qos_levels[5], 0x97); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x97); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); } -// SubscribeResponse 1954 [Left SubErrNotAuthorized,Right QoS2,Left SubErrUnspecifiedError,Left -// SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrImplementationSpecificError,Right -// QoS2,Right QoS2] [PropWildcardSubscriptionAvailable 1,PropWildcardSubscriptionAvailable 77,PropServerKeepAlive -// 4976,PropSharedSubscriptionAvailable 54,PropReceiveMaximum 9243,PropRequestProblemInformation 35,PropServerKeepAlive -// 529] +// SubscribeResponse 18340 [Right QoS2,Left SubErrTopicFilterInvalid,Right QoS1,Left SubErrImplementationSpecificError] +// [PropAuthenticationData +// "\206}\GS?\245\240\GS\212\ENQ\200\252+\231D\DC1\224\&6\248\DC3\145\181\202\169\207\250-",PropSessionExpiryInterval +// 2333,PropResponseTopic "Fj8\221\177O=o_\158\t\175\230\NUL",PropMaximumPacketSize 5429,PropAuthenticationMethod +// "\139\221\DC1\253z\146\EMZf\SI\213\&7*4\174\254\RS \SYN7\226\163\179\SOH\206B\NUL",PropRequestProblemInformation +// 54,PropAuthenticationData "n\242Y\240Q\CAN\205\&5+*\197\231$\169\179\US{M\171\187",PropTopicAliasMaximum +// 31685,PropSharedSubscriptionAvailable 54,PropMessageExpiryInterval 30661] TEST(SubACK5QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0x1c, 0x7, 0xa2, 0x11, 0x28, 0x1, 0x28, 0x4d, 0x13, 0x13, 0x70, 0x2a, 0x36, 0x21, - 0x24, 0x1b, 0x17, 0x23, 0x13, 0x2, 0x11, 0x87, 0x2, 0x80, 0x8f, 0xa2, 0x83, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0x80, 0x1, 0x47, 0xa4, 0x79, 0x16, 0x0, 0x1a, 0xce, 0x7d, 0x1d, 0x3f, 0xf5, 0xf0, 0x1d, 0xd4, + 0x5, 0xc8, 0xfc, 0x2b, 0xe7, 0x44, 0x11, 0xe0, 0x36, 0xf8, 0x13, 0x91, 0xb5, 0xca, 0xa9, 0xcf, 0xfa, + 0x2d, 0x11, 0x0, 0x0, 0x9, 0x1d, 0x8, 0x0, 0xe, 0x46, 0x6a, 0x38, 0xdd, 0xb1, 0x4f, 0x3d, 0x6f, + 0x5f, 0x9e, 0x9, 0xaf, 0xe6, 0x0, 0x27, 0x0, 0x0, 0x15, 0x35, 0x15, 0x0, 0x1b, 0x8b, 0xdd, 0x11, + 0xfd, 0x7a, 0x92, 0x19, 0x5a, 0x66, 0xf, 0xd5, 0x37, 0x2a, 0x34, 0xae, 0xfe, 0x1e, 0x20, 0x16, 0x37, + 0xe2, 0xa3, 0xb3, 0x1, 0xce, 0x42, 0x0, 0x17, 0x36, 0x16, 0x0, 0x14, 0x6e, 0xf2, 0x59, 0xf0, 0x51, + 0x18, 0xcd, 0x35, 0x2b, 0x2a, 0xc5, 0xe7, 0x24, 0xa9, 0xb3, 0x1f, 0x7b, 0x4d, 0xab, 0xbb, 0x22, 0x7b, + 0xc5, 0x2a, 0x36, 0x2, 0x0, 0x0, 0x77, 0xc5, 0x2, 0x8f, 0x1, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1954); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], 0x87); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x8F); - EXPECT_EQ(granted_qos_levels[4], 0xA2); - EXPECT_EQ(granted_qos_levels[5], 0x83); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); -} - -// SubscribeResponse 9962 [Left SubErrPacketIdentifierInUse,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrNotAuthorized,Right QoS1,Left SubErrQuotaExceeded,Right QoS1] [PropMaximumQoS 33,PropPayloadFormatIndicator -// 170,PropMessageExpiryInterval 9660,PropServerKeepAlive 20380,PropPayloadFormatIndicator 9,PropWillDelayInterval -// 18773,PropRequestProblemInformation 73,PropResponseInformation -// "\191\166J\b\ETB\249\139\SOHx^\232\218\136q\166hn\SUB\SYN6\136\231\179l\147\SUB\242T\ESC",PropSessionExpiryInterval -// 24270] + EXPECT_EQ(packet_id, 18340); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x8F); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x83); +} + +// SubscribeResponse 8517 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS0] +// [PropServerReference "\164\213\242\159g\236h\176\&9x\EOTT%V\153\229\"w\234\184\182\236",PropSessionExpiryInterval +// 16327,PropServerReference "\200^\129",PropTopicAliasMaximum 11537,PropSubscriptionIdentifierAvailable +// 214,PropReasonString "A\216Y\246\141\163\189)\136\&2\237t\128\176%\SIB&",PropReceiveMaximum +// 16877,PropWillDelayInterval 22070,PropUserProperty +// "\227\f\224k\f\212\251\ENQ\221\172\az\210v]P\RS\DLE|\204\185\253e\130r\214\197\175=7" +// "5\ACK\214\194\&1\211'\238bA\USs\177\STX",PropAssignedClientIdentifier +// "\ETB\225[X#\SO\182,\234\214\203N\SOH\242\202\ETB\178\161\143\148\165\&0*\v\162L\174\242\fM",PropSharedSubscriptionAvailable +// 209,PropMessageExpiryInterval 26844,PropReceiveMaximum 13624,PropResponseTopic "\144",PropAuthenticationData +// ",\DC2\164\176\SI\ETB\"w\237_1\192\174",PropMaximumQoS 183,PropRequestResponseInformation 146,PropAuthenticationData +// "\186U\227f\140\f\136s\160\191\239\DC2M)D\DC1\196\\{5\176\151\189\SOH\241\DEL\128",PropRetainAvailable +// 246,PropMessageExpiryInterval 15562,PropContentType +// "\213P\201G\210\239\216\223\223\238\&7\203\215P\145a\229\157\DC2\156\DC1",PropPayloadFormatIndicator +// 118,PropAssignedClientIdentifier "",PropRequestProblemInformation 202,PropWillDelayInterval 30258] TEST(SubACK5QCTest, Decode24) { - uint8_t pkt[] = {0x90, 0x43, 0x26, 0xea, 0x3a, 0x24, 0x21, 0x1, 0xaa, 0x2, 0x0, 0x0, 0x25, 0xbc, - 0x13, 0x4f, 0x9c, 0x1, 0x9, 0x18, 0x0, 0x0, 0x49, 0x55, 0x17, 0x49, 0x1a, 0x0, - 0x1d, 0xbf, 0xa6, 0x4a, 0x8, 0x17, 0xf9, 0x8b, 0x1, 0x78, 0x5e, 0xe8, 0xda, 0x88, - 0x71, 0xa6, 0x68, 0x6e, 0x1a, 0x16, 0x36, 0x88, 0xe7, 0xb3, 0x6c, 0x93, 0x1a, 0xf2, - 0x54, 0x1b, 0x11, 0x0, 0x0, 0x5e, 0xce, 0x91, 0x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0x17, 0x22, 0x77, 0xed, 0x5f, 0x31, + 0xc0, 0xae, 0x24, 0xb7, 0x19, 0x92, 0x16, 0x0, 0x1b, 0xba, 0x55, 0xe3, 0x66, 0x8c, 0xc, 0x88, 0x73, + 0xa0, 0xbf, 0xef, 0x12, 0x4d, 0x29, 0x44, 0x11, 0xc4, 0x5c, 0x7b, 0x35, 0xb0, 0x97, 0xbd, 0x1, 0xf1, + 0x7f, 0x80, 0x25, 0xf6, 0x2, 0x0, 0x0, 0x3c, 0xca, 0x3, 0x0, 0x15, 0xd5, 0x50, 0xc9, 0x47, 0xd2, + 0xef, 0xd8, 0xdf, 0xdf, 0xee, 0x37, 0xcb, 0xd7, 0x50, 0x91, 0x61, 0xe5, 0x9d, 0x12, 0x9c, 0x11, 0x1, + 0x76, 0x12, 0x0, 0x0, 0x17, 0xca, 0x18, 0x0, 0x0, 0x76, 0x32, 0x9e, 0x0, 0xa1, 0xa2, 0x2, 0x0}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[6]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9962); + EXPECT_EQ(packet_id, 8517); EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], 0x91); - EXPECT_EQ(granted_qos_levels[1], 0xA2); - EXPECT_EQ(granted_qos_levels[2], 0x87); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], 0x97); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0xA1); + EXPECT_EQ(granted_qos_levels[3], 0xA2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); } -// SubscribeResponse 16427 [Left SubErrQuotaExceeded,Right QoS0,Right QoS2,Right QoS2,Right QoS1] -// [PropRequestResponseInformation 104,PropServerReference "\171",PropSubscriptionIdentifier 24,PropAuthenticationData -// "1",PropAssignedClientIdentifier -// "\209\246\222`\DC2\132.\217E:l\133\145\221g\248\215\&1\208\172M\239\252\&3",PropSubscriptionIdentifier -// 7,PropMessageExpiryInterval 31633,PropMaximumPacketSize 12879,PropSessionExpiryInterval 4551,PropCorrelationData -// "\250Q@",PropWillDelayInterval 11026,PropReasonString "K\146\247[e\253c\221\184y]fG\128\218L\200\129",PropTopicAlias -// 9372,PropServerReference -// "\160\245\250y\147\180\182\RS\217M\134\a\245wQ\178Z\143E\208\248\212\181\139ye\130PC",PropMaximumQoS -// 220,PropAuthenticationMethod -// "\170\250#\131>\147QF\142\234\CAN\DC4\173j\ETXe\236\ACK\186\211\215;D\US]",PropUserProperty -// "\178\153Rs\169\169\141\DC1\130\&0\170xek\183\143\208C\NAK\v" -// "\243\DLE'j\140$\206e\226F\174\247\241Zs\148\144\221\166R\153$\209\133\248",PropTopicAlias -// 7597,PropAuthenticationData "\221\160\DC2\CAN\237W=S\167\EM^6ATm",PropAuthenticationData "'\193r;\208\DC1"] +// SubscribeResponse 31168 [Right QoS2,Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrNotAuthorized,Right QoS0,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left +// SubErrPacketIdentifierInUse,Left SubErrNotAuthorized] [PropSubscriptionIdentifierAvailable 144,PropUserProperty +// "\169r\208\173G\SOH\223\RS\220\129\249\198p2M\251w\151;Y\218\235\145\253Y\165n\242" +// "\ACK\196\134=\SI\145\227\EOTe\183\195\218\147\237",PropMessageExpiryInterval 21387,PropAssignedClientIdentifier +// "\146\201\243t\165\179\220\ENQ\138B\217d\132\rj\CAN\144"] TEST(SubACK5QCTest, Decode25) { - uint8_t pkt[] = {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x6a, 0x8c, - 0x24, 0xce, 0x65, 0xe2, 0x46, 0xae, 0xf7, 0xf1, 0x5a, 0x73, 0x94, 0x90, 0xdd, 0xa6, 0x52, 0x99, 0x24, 0xd1, 0x85, - 0xf8, 0x23, 0x1d, 0xad, 0x16, 0x0, 0xf, 0xdd, 0xa0, 0x12, 0x18, 0xed, 0x57, 0x3d, 0x53, 0xa7, 0x19, 0x5e, 0x36, - 0x41, 0x54, 0x6d, 0x16, 0x0, 0x6, 0x27, 0xc1, 0x72, 0x3b, 0xd0, 0x11, 0x97, 0x0, 0x2, 0x2, 0x1}; + uint8_t pkt[] = {0x90, 0x56, 0x79, 0xc0, 0x4a, 0x29, 0x90, 0x26, 0x0, 0x1c, 0xa9, 0x72, 0xd0, 0xad, 0x47, + 0x1, 0xdf, 0x1e, 0xdc, 0x81, 0xf9, 0xc6, 0x70, 0x32, 0x4d, 0xfb, 0x77, 0x97, 0x3b, 0x59, + 0xda, 0xeb, 0x91, 0xfd, 0x59, 0xa5, 0x6e, 0xf2, 0x0, 0xe, 0x6, 0xc4, 0x86, 0x3d, 0xf, + 0x91, 0xe3, 0x4, 0x65, 0xb7, 0xc3, 0xda, 0x93, 0xed, 0x2, 0x0, 0x0, 0x53, 0x8b, 0x12, + 0x0, 0x11, 0x92, 0xc9, 0xf3, 0x74, 0xa5, 0xb3, 0xdc, 0x5, 0x8a, 0x42, 0xd9, 0x64, 0x84, + 0xd, 0x6a, 0x18, 0x90, 0x2, 0x8f, 0xa1, 0x87, 0x0, 0x9e, 0x1, 0x91, 0x87}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 16427); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x97); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 31168); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x8F); + EXPECT_EQ(granted_qos_levels[2], 0xA1); + EXPECT_EQ(granted_qos_levels[3], 0x87); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x9E); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], 0x91); + EXPECT_EQ(granted_qos_levels[8], 0x87); } -// SubscribeResponse 14848 [Left SubErrImplementationSpecificError,Left SubErrSubscriptionIdentifiersNotSupported] -// [PropAuthenticationMethod "\247\225\239\136\176\&4",PropReceiveMaximum 9177,PropTopicAlias -// 31213,PropMessageExpiryInterval 28807,PropAuthenticationData -// "yG\175\195\166\213\225rZ\180\166y\242\185;\174B\213\200\204<%\245`\188\t("] +// SubscribeResponse 6558 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left +// SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Right +// QoS1,Left SubErrTopicFilterInvalid] [PropServerReference "",PropSubscriptionIdentifierAvailable +// 103,PropReceiveMaximum 28000,PropMessageExpiryInterval 22245,PropServerReference +// "\DC4\229\&0\DC2\147\DC3\237\213\155\SUB\193\US\\\221\178H\243\STX\238\128S\207o\141",PropMessageExpiryInterval +// 12590,PropSessionExpiryInterval 2530,PropCorrelationData +// "7\211h\190\&6\237\163\131\128j\233\226\a\173`\254`e\151\rm*\222=\248\159",PropPayloadFormatIndicator +// 19,PropReasonString "\150\f\186P!~V\SOH\179\210\DC2L/\247\STX\190 1\SUB5l\173",PropMessageExpiryInterval +// 3585,PropSessionExpiryInterval 9887,PropRetainAvailable 104,PropSubscriptionIdentifierAvailable +// 50,PropSubscriptionIdentifierAvailable 222,PropAssignedClientIdentifier +// "F\227\DLE\165\228\199dI\210\SUB\DC3\215E\139",PropAuthenticationData "|\207N\146A",PropTopicAlias +// 32016,PropTopicAliasMaximum 26219] TEST(SubACK5QCTest, Decode26) { - uint8_t pkt[] = {0x90, 0x37, 0x3a, 0x0, 0x32, 0x15, 0x0, 0x6, 0xf7, 0xe1, 0xef, 0x88, 0xb0, 0x34, 0x21, - 0x23, 0xd9, 0x23, 0x79, 0xed, 0x2, 0x0, 0x0, 0x70, 0x87, 0x16, 0x0, 0x1b, 0x79, 0x47, - 0xaf, 0xc3, 0xa6, 0xd5, 0xe1, 0x72, 0x5a, 0xb4, 0xa6, 0x79, 0xf2, 0xb9, 0x3b, 0xae, 0x42, - 0xd5, 0xc8, 0xcc, 0x3c, 0x25, 0xf5, 0x60, 0xbc, 0x9, 0x28, 0x83, 0xa1}; + uint8_t pkt[] = {0x90, 0xa4, 0x1, 0x19, 0x9e, 0x99, 0x1, 0x1c, 0x0, 0x0, 0x29, 0x67, 0x21, 0x6d, 0x60, 0x2, 0x0, + 0x0, 0x56, 0xe5, 0x1c, 0x0, 0x18, 0x14, 0xe5, 0x30, 0x12, 0x93, 0x13, 0xed, 0xd5, 0x9b, 0x1a, 0xc1, + 0x1f, 0x5c, 0xdd, 0xb2, 0x48, 0xf3, 0x2, 0xee, 0x80, 0x53, 0xcf, 0x6f, 0x8d, 0x2, 0x0, 0x0, 0x31, + 0x2e, 0x11, 0x0, 0x0, 0x9, 0xe2, 0x9, 0x0, 0x1a, 0x37, 0xd3, 0x68, 0xbe, 0x36, 0xed, 0xa3, 0x83, + 0x80, 0x6a, 0xe9, 0xe2, 0x7, 0xad, 0x60, 0xfe, 0x60, 0x65, 0x97, 0xd, 0x6d, 0x2a, 0xde, 0x3d, 0xf8, + 0x9f, 0x1, 0x13, 0x1f, 0x0, 0x16, 0x96, 0xc, 0xba, 0x50, 0x21, 0x7e, 0x56, 0x1, 0xb3, 0xd2, 0x12, + 0x4c, 0x2f, 0xf7, 0x2, 0xbe, 0x20, 0x31, 0x1a, 0x35, 0x6c, 0xad, 0x2, 0x0, 0x0, 0xe, 0x1, 0x11, + 0x0, 0x0, 0x26, 0x9f, 0x25, 0x68, 0x29, 0x32, 0x29, 0xde, 0x12, 0x0, 0xe, 0x46, 0xe3, 0x10, 0xa5, + 0xe4, 0xc7, 0x64, 0x49, 0xd2, 0x1a, 0x13, 0xd7, 0x45, 0x8b, 0x16, 0x0, 0x5, 0x7c, 0xcf, 0x4e, 0x92, + 0x41, 0x23, 0x7d, 0x10, 0x22, 0x66, 0x6b, 0x9e, 0x0, 0x83, 0x83, 0x83, 0x1, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14848); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], 0x83); - EXPECT_EQ(granted_qos_levels[1], 0xA1); -} - -// SubscribeResponse 15477 [Left SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Right QoS2,Right QoS2,Right -// QoS1,Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Right QoS1,Left -// SubErrWildcardSubscriptionsNotSupported] [PropCorrelationData "\rs\233\246",PropReceiveMaximum -// 20152,PropPayloadFormatIndicator 57,PropMessageExpiryInterval 1359,PropMessageExpiryInterval -// 416,PropAssignedClientIdentifier "9(<\DLEb\v\177",PropCorrelationData -// "\251V\195\DC3(\180\133\199\140l,\194\253>\209d,<\244\180\208\156b",PropMaximumPacketSize 16384,PropServerKeepAlive -// 4743,PropUserProperty "\201\ENQT\158=c+Sz\166;H" -// "\255\r\159D\255\217_\211Q\211\DC4)\241\&4\228\233\233\182\247\ETB\146",PropRetainAvailable 89,PropMaximumPacketSize -// 12246,PropAuthenticationData -// "\154M\163\186A\197\ETBA\168e\204\219M\227\205\&8@\169\t\148\143u\233\136\170",PropMessageExpiryInterval -// 9201,PropWillDelayInterval 21887,PropResponseInformation ".?`8",PropAssignedClientIdentifier -// "\203\nsi\226`\151\184,J\STXM\233\FS\254\GS",PropRetainAvailable 242,PropRequestResponseInformation -// 207,PropSessionExpiryInterval 22939,PropAuthenticationMethod "A!\163>\SO",PropMaximumPacketSize -// 4575,PropRetainAvailable 139,PropAssignedClientIdentifier -// "&\213\DC3\196\185\196\&1x\247\198\134\241\137a\211%\133;\147\222\&9_;uuoV\223'\148",PropRequestResponseInformation -// 61,PropRequestResponseInformation 212,PropRequestProblemInformation 58,PropUserProperty -// "\220:\237\190Kv\206\137\183\ETB\168R\189W\194\171q;\141U,\148\216kT\GS\203*" -// "\185\225L\GSq-\237\203H\224",PropUserProperty "\SITp>Q\163\157oR\USI\195\v\247i\RSYW\206d\255\251\224W\162" -// "\231hkmJp\\<0"] + EXPECT_EQ(packet_id, 6558); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x83); + EXPECT_EQ(granted_qos_levels[3], 0x83); + EXPECT_EQ(granted_qos_levels[4], 0x83); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x8F); +} + +// SubscribeResponse 25528 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left +// SubErrUnspecifiedError,Left SubErrImplementationSpecificError,Right QoS2] [PropMessageExpiryInterval +// 30797,PropRetainAvailable 33,PropServerKeepAlive 21346,PropUserProperty "G\145\253\\M\131\224" +// "U",PropSubscriptionIdentifierAvailable 177] TEST(SubACK5QCTest, Decode27) { - uint8_t pkt[] = { - 0x90, 0xce, 0x2, 0x3c, 0x75, 0xc0, 0x2, 0x9, 0x0, 0x4, 0xd, 0x73, 0xe9, 0xf6, 0x21, 0x4e, 0xb8, 0x1, 0x39, - 0x2, 0x0, 0x0, 0x5, 0x4f, 0x2, 0x0, 0x0, 0x1, 0xa0, 0x12, 0x0, 0x7, 0x39, 0x28, 0x3c, 0x10, 0x62, 0xb, - 0xb1, 0x9, 0x0, 0x17, 0xfb, 0x56, 0xc3, 0x13, 0x28, 0xb4, 0x85, 0xc7, 0x8c, 0x6c, 0x2c, 0xc2, 0xfd, 0x3e, 0xd1, - 0x64, 0x2c, 0x3c, 0xf4, 0xb4, 0xd0, 0x9c, 0x62, 0x27, 0x0, 0x0, 0x40, 0x0, 0x13, 0x12, 0x87, 0x26, 0x0, 0xc, - 0xc9, 0x5, 0x54, 0x9e, 0x3d, 0x63, 0x2b, 0x53, 0x7a, 0xa6, 0x3b, 0x48, 0x0, 0x15, 0xff, 0xd, 0x9f, 0x44, 0xff, - 0xd9, 0x5f, 0xd3, 0x51, 0xd3, 0x14, 0x29, 0xf1, 0x34, 0xe4, 0xe9, 0xe9, 0xb6, 0xf7, 0x17, 0x92, 0x25, 0x59, 0x27, - 0x0, 0x0, 0x2f, 0xd6, 0x16, 0x0, 0x19, 0x9a, 0x4d, 0xa3, 0xba, 0x41, 0xc5, 0x17, 0x41, 0xa8, 0x65, 0xcc, 0xdb, - 0x4d, 0xe3, 0xcd, 0x38, 0x40, 0xa9, 0x9, 0x94, 0x8f, 0x75, 0xe9, 0x88, 0xaa, 0x2, 0x0, 0x0, 0x23, 0xf1, 0x18, - 0x0, 0x0, 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x21, 0x63, 0xb8, 0x19, 0x2, 0x0, 0x0, 0x78, 0x4d, 0x25, 0x21, + 0x13, 0x53, 0x62, 0x26, 0x0, 0x7, 0x47, 0x91, 0xfd, 0x5c, 0x4d, 0x83, + 0xe0, 0x0, 0x1, 0x55, 0x29, 0xb1, 0x9e, 0x80, 0x80, 0x83, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15477); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x91); - EXPECT_EQ(granted_qos_levels[1], 0x87); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x9E); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[9], 0xA2); + EXPECT_EQ(packet_id, 25528); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x83); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); } -// SubscribeResponse 13181 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right -// QoS2,Left SubErrImplementationSpecificError,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrPacketIdentifierInUse,Right QoS1,Left SubErrUnspecifiedError] [] +// SubscribeResponse 29497 [Right QoS2,Right QoS2,Right QoS2,Right QoS1,Right QoS2,Left SubErrPacketIdentifierInUse] +// [PropResponseTopic "\142\214",PropWildcardSubscriptionAvailable 159,PropServerKeepAlive 3120,PropResponseInformation +// "\196\181[.\250\238^\FS\197\218\DC38\202}h\136\fI\200&\209\192K\ENQ\253",PropRetainAvailable 200,PropRetainAvailable +// 136,PropTopicAliasMaximum 29048,PropRequestProblemInformation 129,PropUserProperty +// "2\230\CAN\157y\DC1w\130\179\189`\186Mz\SUBlK\237s\167. 4\168\ESC\205" +// "\207\129\251\149+\EOT\191\136",PropMaximumPacketSize 10414,PropReceiveMaximum 26546,PropRequestResponseInformation +// 24,PropResponseTopic "h\210\DEL\207m\156\151\219\136\231\157",PropAssignedClientIdentifier +// "t^$\170\239\&7\220S\133t\ACK",PropRequestResponseInformation 37,PropTopicAlias 26638,PropAuthenticationData +// "\244L?\243\SIr\RS~\136\a\196\207*\242\245\168U\161\222\167\131:M",PropAuthenticationMethod +// "UU\ESC\148\195\220\138\NAKS\207\140-\ENQ\228\137<\243\216\GS\164,\ENQ4\188\141\133",PropServerReference +// "\225\212\199\164\210\214\174\255\169",PropWillDelayInterval 4639,PropRequestProblemInformation 4,PropReasonString +// "?M\NAK>\DLE%\181j\SUB\US#\157\ETX\182\RSym\147\155\217\176\152\145)} \CANI",PropRequestProblemInformation 48] TEST(SubACK5QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0xc, 0x33, 0x7d, 0x0, 0x87, 0x80, 0x87, 0x2, 0x83, 0xa1, 0x91, 0x1, 0x80}; + uint8_t pkt[] = {0x90, 0xf6, 0x1, 0x73, 0x39, 0xec, 0x1, 0x8, 0x0, 0x2, 0x8e, 0xd6, 0x28, 0x9f, 0x13, 0xc, 0x30, + 0x1a, 0x0, 0x19, 0xc4, 0xb5, 0x5b, 0x2e, 0xfa,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, 0x0, 0x1c, 0x3f, 0x4d, 0x15, 0x3e, 0x10, 0x25, 0xb5, 0x6a, + 0x1a, 0x1f, 0x23, 0x9d, 0x3, 0xb6, 0x1e, 0x79, 0x6d, 0x93, 0x9b, 0xd9, 0xb0, 0x98, 0x91, 0x29, 0x7d, + 0x20, 0x18, 0x49, 0x17, 0x30, 0x2, 0x2, 0x2, 0x1, 0x2, 0x91}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13181); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x87); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x87); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x83); - EXPECT_EQ(granted_qos_levels[5], 0xA1); - EXPECT_EQ(granted_qos_levels[6], 0x91); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(packet_id, 29497); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x91); } -// SubscribeResponse 32677 [Right QoS1,Left SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS2] -// [PropWillDelayInterval 12589,PropAuthenticationMethod "\129\137\142\235H -// \251|,K2\230\192+/^\176X\133\198\GSX\ENQ9",PropReasonString "eH\142\&3\189\203\235W\146",PropContentType -// "D\160|\f\237{G>\166\218\187\145\187\250\153\175\210\247\SI\v\ESC\167",PropServerReference "",PropWillDelayInterval -// 9311,PropUserProperty "\168=R\203\211\187%\205\&6!*zW\STX\191\157\147\&9=\183y" -// "A\138\133\178f\225U\213\&4w\241T^\175\226l\138\248\222Be^\US{m\184\242\"\n",PropSubscriptionIdentifierAvailable -// 212,PropRequestResponseInformation 189,PropMaximumPacketSize 13803,PropAuthenticationData -// "`!8e",PropMessageExpiryInterval 3947,PropSubscriptionIdentifier 26,PropMessageExpiryInterval 17424,PropMaximumQoS -// 58,PropSubscriptionIdentifierAvailable 188,PropCorrelationData -// "*\162\212\170\201\152\213\129",PropRequestResponseInformation 251,PropCorrelationData -// "\172i\SYNA\196\181\EM(|\246\129\ETB \DC2.\176\210\251\128\\\177n\SI\251\EM",PropWildcardSubscriptionAvailable 206] +// SubscribeResponse 9048 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS1,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS1,Right QoS2,Right QoS2,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded] [PropServerKeepAlive 29652,PropServerReference +// "N\209\227[l\245\198\167\182\145\188\246\138\176\RS\a<\134\208\201\&79Z\204",PropReasonString +// "\NUL\NUL\212\248\213\239\233\206%1\207\168\183s^\US\150\DC3\160\RS\155\STX/T\129\SO:\222\158\252",PropMessageExpiryInterval +// 11470,PropWillDelayInterval 10358,PropMaximumPacketSize 11999,PropSessionExpiryInterval 29249,PropCorrelationData +// "\216\NUL\209\252;v \168bc\tV6C4j\r`\255\252@\EOT\147$\151\214",PropAssignedClientIdentifier +// "\167\146n/\CAN\130T[\203B\141",PropSubscriptionIdentifierAvailable 217,PropSubscriptionIdentifier +// 28,PropServerReference "\SYN\221RL\DC1`\DLE\156",PropContentType +// "\219r\154{\159F\194\159\236\US\154\146p\141\250",PropSharedSubscriptionAvailable +// 153,PropSubscriptionIdentifierAvailable 48,PropPayloadFormatIndicator 21,PropResponseTopic +// "\136\148W\180A\251X\189\216\174\242\tr\221\248\230\199\208\196\241",PropContentType +// "D\\\242\156:qp\159z\194`\175#\STX\189\SO\130\137/\191\234"] TEST(SubACK5QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0xd8, 0x1, 0x7f, 0xa5, 0xcf, 0x1, 0x18, 0x0, 0x0, 0x31, 0x2d, 0x15, 0x0, 0x18, 0x81, 0x89, - 0x8e, 0xeb, 0x48, 0x20, 0xfb, 0x7c, 0x2c, 0x4b, 0x32, 0xe6, 0xc0, 0x2b, 0x2f, 0x5e, 0xb0, 0x58, 0x85, - 0xc6, 0x1d, 0x58, 0x5, 0x39, 0x1f, 0x0, 0x9, 0x65, 0x48, 0x8e, 0x33, 0xbd, 0xcb, 0xeb, 0x57, 0x92, - 0x3, 0x0, 0x16, 0x44, 0xa0, 0x7c, 0xc, 0xed, 0x7b, 0x47, 0x3e, 0xa6, 0xda, 0xbb, 0x91, 0xbb, 0xfa, - 0x99, 0xaf, 0xd2, 0xf7, 0xf, 0xb, 0x1b, 0xa7, 0x1c, 0x0, 0x0, 0x18, 0x0, 0x0, 0x24, 0x5f, 0x26, - 0x0, 0x15, 0xa8, 0x3d, 0x52, 0xcb, 0xd3, 0xbb, 0x25, 0xcd, 0x36, 0x21, 0x2a, 0x7a, 0x57, 0x2, 0xbf, - 0x9d, 0x93, 0x39, 0x3d, 0xb7, 0x79, 0x0, 0x1d, 0x41, 0x8a, 0x85, 0xb2, 0x66, 0xe1, 0x55, 0xd5, 0x34, - 0x77, 0xf1, 0x54, 0x5e, 0xaf, 0xe2, 0x6c, 0x8a, 0xf8, 0xde, 0x42, 0x65, 0x5e, 0x1f, 0x7b, 0x6d, 0xb8, - 0xf2, 0x22, 0xa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, 0x36, 0x43, 0x34, 0x6a, 0xd, 0x60, 0xff, 0xfc, 0x40, 0x4, 0x93, 0x24, 0x97, 0xd6, + 0x12, 0x0, 0xb, 0xa7, 0x92, 0x6e, 0x2f, 0x18, 0x82, 0x54, 0x5b, 0xcb, 0x42, 0x8d, 0x29, 0xd9, 0xb, + 0x1c, 0x1c, 0x0, 0x8, 0x16, 0xdd, 0x52, 0x4c, 0x11, 0x60, 0x10, 0x9c, 0x3, 0x0, 0xf, 0xdb, 0x72, + 0x9a, 0x7b, 0x9f, 0x46, 0xc2, 0x9f, 0xec, 0x1f, 0x9a, 0x92, 0x70, 0x8d, 0xfa, 0x2a, 0x99, 0x29, 0x30, + 0x1, 0x15, 0x8, 0x0, 0x14, 0x88, 0x94, 0x57, 0xb4, 0x41, 0xfb, 0x58, 0xbd, 0xd8, 0xae, 0xf2, 0x9, + 0x72, 0xdd, 0xf8, 0xe6, 0xc7, 0xd0, 0xc4, 0xf1, 0x3, 0x0, 0x15, 0x44, 0x5c, 0xf2, 0x9c, 0x3a, 0x71, + 0x70, 0x9f, 0x7a, 0xc2, 0x60, 0xaf, 0x23, 0x2, 0xbd, 0xe, 0x82, 0x89, 0x2f, 0xbf, 0xea, 0x87, 0x80, + 0x87, 0x1, 0x9e, 0x1, 0x1, 0x2, 0x2, 0xa2, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32677); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 9048); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x87); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); -} - -// SubscribeResponse 14851 [Right QoS0,Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError,Left SubErrNotAuthorized,Left -// SubErrSharedSubscriptionsNotSupported] [PropAuthenticationData ""] + EXPECT_EQ(granted_qos_levels[2], 0x87); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x9E); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], 0xA2); + EXPECT_EQ(granted_qos_levels[10], 0x97); +} + +// SubscribeResponse 18118 [Right QoS1] [PropTopicAlias 32552,PropCorrelationData +// "\219\205T\187\223\203V\US\254$:\211\206\181\253\162\EOT",PropUserProperty +// "\a\128D[\207\ETBuDt\141CZ\160\240\222\195\233\n\153\133U\ETB\168" +// "v\243\229\bv{\251\193'\186\143\ETX\DC2\254\147\244Q\128\FS\r\DEL$\ts*\233\191g\249",PropRequestProblemInformation +// 47,PropSessionExpiryInterval 29723,PropServerKeepAlive 6447,PropRequestProblemInformation +// 42,PropMessageExpiryInterval 16508,PropServerReference "\128b~\229\132",PropAuthenticationMethod +// "\215\SUB",PropSubscriptionIdentifierAvailable 109,PropAssignedClientIdentifier +// "\223}\146:J)\225\226\GS#\EOTn\227E7\184\248'u\ACK\223@\140\227U",PropMaximumQoS 22,PropServerReference +// "\248\225G\SO\209kK \188",PropWillDelayInterval 1146,PropResponseInformation +// "\202\215k(\209\237GUT\b\134P\249\180k\248.{\SO\173^",PropUserProperty +// "\rf.E\SI\151oopgY\232\&5\134{f$\211\n4\150\t\149\238\181\175/Z\EMx" "\ENQ2\154;",PropPayloadFormatIndicator +// 77,PropResponseTopic " \162h\149\NULP\226\226e\219\RS\236, \252Wgvb\FSM\224\237\187\ETXZ",PropMaximumQoS +// 117,PropResponseTopic "OV\RS\213p$\SUB\135"] TEST(SubACK5QCTest, Decode30) { - uint8_t pkt[] = {0x90, 0xe, 0x3a, 0x3, 0x3, 0x16, 0x0, 0x0, 0x0, 0x87, 0x80, 0x9e, 0x1, 0x83, 0x87, 0x9e}; + uint8_t pkt[] = { + 0x90, 0x8f, 0x2, 0x46, 0xc6, 0x8a, 0x2, 0x23, 0x7f, 0x28, 0x9, 0x0, 0x11, 0xdb, 0xcd, 0x54, 0xbb, 0xdf, 0xcb, + 0x56, 0x1f, 0xfe, 0x24, 0x3a, 0xd3, 0xce, 0xb5, 0xfd, 0xa2, 0x4, 0x26, 0x0, 0x17, 0x7, 0x80, 0x44, 0x5b, 0xcf, + 0x17, 0x75, 0x44, 0x74, 0x8d, 0x43, 0x5a, 0xa0, 0xf0, 0xde, 0xc3, 0xe9, 0xa, 0x99, 0x85, 0x55, 0x17, 0xa8, 0x0, + 0x1d, 0x76, 0xf3, 0xe5, 0x8, 0x76, 0x7b, 0xfb, 0xc1, 0x27, 0xba, 0x8f, 0x3, 0x12, 0xfe, 0x93, 0xf4, 0x51, 0x80, + 0x1c, 0xd, 0x7f, 0x24, 0x9, 0x73, 0x2a, 0xe9, 0xbf, 0x67, 0xf9, 0x17, 0x2f, 0x11, 0x0, 0x0, 0x74, 0x1b, 0x13, + 0x19, 0x2f, 0x17, 0x2a, 0x2, 0x0, 0x0, 0x40, 0x7c, 0x1c, 0x0, 0x5, 0x80, 0x62, 0x7e, 0xe5, 0x84, 0x15, 0x0, + 0x2, 0xd7, 0x1a, 0x29, 0x6d, 0x12, 0x0, 0x19, 0xdf, 0x7d, 0x92, 0x3a, 0x4a, 0x29, 0xe1, 0xe2, 0x1d, 0x23, 0x4, + 0x6e, 0xe3, 0x45, 0x37, 0xb8, 0xf8, 0x27, 0x75, 0x6, 0xdf, 0x40, 0x8c, 0xe3, 0x55, 0x24, 0x16, 0x1c, 0x0, 0x9, + 0xf8, 0xe1, 0x47, 0xe, 0xd1, 0x6b, 0x4b, 0x20, 0xbc, 0x18, 0x0, 0x0, 0x4, 0x7a, 0x1a, 0x0, 0x15, 0xca, 0xd7, + 0x6b, 0x28, 0xd1, 0xed, 0x47, 0x55, 0x54, 0x8, 0x86, 0x50, 0xf9, 0xb4, 0x6b, 0xf8, 0x2e, 0x7b, 0xe, 0xad, 0x5e, + 0x26, 0x0, 0x1e, 0xd, 0x66, 0x2e, 0x45, 0xf, 0x97, 0x6f, 0x6f, 0x70, 0x67, 0x59, 0xe8, 0x35, 0x86, 0x7b, 0x66, + 0x24, 0xd3, 0xa, 0x34, 0x96, 0x9, 0x95, 0xee, 0xb5, 0xaf, 0x2f, 0x5a, 0x19, 0x78, 0x0, 0x4, 0x5, 0x32, 0x9a, + 0x3b, 0x1, 0x4d, 0x8, 0x0, 0x1a, 0x20, 0xa2, 0x68, 0x95, 0x0, 0x50, 0xe2, 0xe2, 0x65, 0xdb, 0x1e, 0xec, 0x2c, + 0x20, 0xfc, 0x57, 0x67, 0x76, 0x62, 0x1c, 0x4d, 0xe0, 0xed, 0xbb, 0x3, 0x5a, 0x24, 0x75, 0x8, 0x0, 0x8, 0x4f, + 0x56, 0x1e, 0xd5, 0x70, 0x24, 0x1a, 0x87, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14851); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x87); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x9E); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x83); - EXPECT_EQ(granted_qos_levels[6], 0x87); - EXPECT_EQ(granted_qos_levels[7], 0x9E); + EXPECT_EQ(packet_id, 18118); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); } diff --git a/tests/packet.cpp b/tests/packet.cpp index 7d849c4..18c0dea 100644 --- a/tests/packet.cpp +++ b/tests/packet.cpp @@ -422,7 +422,8 @@ TEST(PublishTest, Decode1) { uint16_t packet_id; lwmqtt_string_t topic; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 25, LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 25, LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(dup, true); @@ -465,7 +466,8 @@ TEST(PublishTest, Decode2) { uint16_t packet_id; lwmqtt_string_t topic = lwmqtt_default_string; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 23, LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 23, LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(dup, false); @@ -487,7 +489,8 @@ TEST(PublishTest, DecodeError1) { uint16_t packet_id; lwmqtt_string_t topic = lwmqtt_default_string; lwmqtt_message_t msg; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 2, LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg); + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, 2, LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_BUFFER_TOO_SHORT); } From 3368cfad8a1c747d6aa9ad3f21ec526411b3e610 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Fri, 20 Sep 2019 10:22:47 -0700 Subject: [PATCH 19/26] Properties visitor to read all the properties. --- examples/sync.c | 58 + gentests/app/Main.hs | 2 +- include/lwmqtt.h | 5 +- src/client.c | 92 + src/helpers.c | 12 + src/helpers.h | 2 + src/packet.c | 4 +- tests/generated.cpp | 24869 +++++++++++++++++++++-------------------- 8 files changed, 12933 insertions(+), 12111 deletions(-) diff --git a/examples/sync.c b/examples/sync.c index f2d9d35..cff1ede 100644 --- a/examples/sync.c +++ b/examples/sync.c @@ -13,10 +13,68 @@ lwmqtt_unix_timer_t timer1, timer2, timer3; lwmqtt_client_t client; +static void prop_printer(void *ref, lwmqtt_property_t prop) { + switch (prop.prop) { + // one byte + case LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR: + case LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION: + case LWMQTT_PROP_MAXIMUM_QOS: + case LWMQTT_PROP_RETAIN_AVAILABLE: + case LWMQTT_PROP_REQUEST_RESPONSE_INFORMATION: + case LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE: + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE: + case LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE: + printf(" Property %x (byte): 0x%x\n", prop.prop, prop.value.byte); + break; + + // two byte int + case LWMQTT_PROP_SERVER_KEEP_ALIVE: + case LWMQTT_PROP_RECEIVE_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS: + printf(" Property %x (int): %d\n", prop.prop, prop.value.int16); + break; + + // 4 byte int + case LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL: + case LWMQTT_PROP_SESSION_EXPIRY_INTERVAL: + case LWMQTT_PROP_WILL_DELAY_INTERVAL: + case LWMQTT_PROP_MAXIMUM_PACKET_SIZE: + printf(" Property %x (int32): %d\n", prop.prop, prop.value.int32); + break; + + // Variable byte int + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: + printf(" Property %x (varint): %d\n", prop.prop, prop.value.int32); + break; + + // UTF-8 string + case LWMQTT_PROP_CONTENT_TYPE: + case LWMQTT_PROP_RESPONSE_TOPIC: + case LWMQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER: + case LWMQTT_PROP_AUTHENTICATION_METHOD: + case LWMQTT_PROP_RESPONSE_INFORMATION: + case LWMQTT_PROP_SERVER_REFERENCE: + case LWMQTT_PROP_REASON_STRING: + + // Arbitrary blobs as the same encoding. + case LWMQTT_PROP_CORRELATION_DATA: + case LWMQTT_PROP_AUTHENTICATION_DATA: + printf(" Property %x (string): %.*s\n", prop.prop, prop.value.str.len, prop.value.str.data); + break; + + case LWMQTT_PROP_USER_PROPERTY: + printf(" User property: k=%.*s, v=%.*s\n", prop.value.pair.k.len, prop.value.pair.k.data, prop.value.pair.v.len, + prop.value.pair.v.data); + } +} + static void message_arrived(lwmqtt_client_t *_client, void *ref, lwmqtt_string_t topic, lwmqtt_message_t msg, lwmqtt_serialized_properties_t props) { printf("message_arrived: %.*s => %.*s (%d)\n", (int)topic.len, topic.data, (int)msg.payload_len, (char *)msg.payload, (int)msg.payload_len); + + lwmqtt_property_visitor(NULL, props, prop_printer); } int main() { diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index f9f2431..1a7feff 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -71,7 +71,7 @@ captureProps = map e peW32 i x = IProp i "int32" (fromEnum x) peUTF8 i x = SProp i "str" (0,x) peBin i x = SProp i "str" (0,x) - peVarInt i = IProp i "varint" + peVarInt i = IProp i "int32" pePair i k v = UProp i (0,k) (0,v) e (PropPayloadFormatIndicator x) = peW8 0x01 x diff --git a/include/lwmqtt.h b/include/lwmqtt.h index e6b0d99..0c98516 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -124,7 +124,6 @@ typedef struct { uint8_t byte; uint32_t int32; uint16_t int16; - int varint; lwmqtt_string_t str; struct { lwmqtt_string_t k; @@ -481,4 +480,8 @@ lwmqtt_err_t lwmqtt_yield(lwmqtt_client_t *client, size_t available, uint32_t ti */ lwmqtt_err_t lwmqtt_keep_alive(lwmqtt_client_t *client, uint32_t timeout); +typedef void (*lwmqtt_prop_callback_t)(void *ref, lwmqtt_property_t prop); + +lwmqtt_err_t lwmqtt_property_visitor(void *ref, lwmqtt_serialized_properties_t props, lwmqtt_prop_callback_t cb); + #endif // LWMQTT_H diff --git a/src/client.c b/src/client.c index ddb5c59..dba2c6c 100644 --- a/src/client.c +++ b/src/client.c @@ -684,3 +684,95 @@ lwmqtt_err_t lwmqtt_keep_alive(lwmqtt_client_t *client, uint32_t timeout) { return LWMQTT_SUCCESS; } + +lwmqtt_err_t lwmqtt_property_visitor(void *ref, lwmqtt_serialized_properties_t props, lwmqtt_prop_callback_t cb) { + uint8_t *p = props.start; + uint8_t *end = p + props.size; + lwmqtt_err_t err; + + while (p < end) { + lwmqtt_property_t prop; + err = lwmqtt_read_byte(&p, end, (uint8_t *)&prop.prop); + if (err != LWMQTT_SUCCESS) { + return err; + } + + switch (prop.prop) { + // one byte + case LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR: + case LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION: + case LWMQTT_PROP_MAXIMUM_QOS: + case LWMQTT_PROP_RETAIN_AVAILABLE: + case LWMQTT_PROP_REQUEST_RESPONSE_INFORMATION: + case LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE: + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE: + case LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE: + err = lwmqtt_read_byte(&p, end, &prop.value.byte); + if (err != LWMQTT_SUCCESS) { + return err; + } + break; + + // two byte int + case LWMQTT_PROP_SERVER_KEEP_ALIVE: + case LWMQTT_PROP_RECEIVE_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS: + err = lwmqtt_read_num(&p, end, &prop.value.int16); + if (err != LWMQTT_SUCCESS) { + return err; + } + break; + + // 4 byte int + case LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL: + case LWMQTT_PROP_SESSION_EXPIRY_INTERVAL: + case LWMQTT_PROP_WILL_DELAY_INTERVAL: + case LWMQTT_PROP_MAXIMUM_PACKET_SIZE: + err = lwmqtt_read_num32(&p, end, &prop.value.int32); + if (err != LWMQTT_SUCCESS) { + return err; + } + break; + + // Variable byte int + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: + err = lwmqtt_read_varnum(&p, end, &prop.value.int32); + if (err != LWMQTT_SUCCESS) { + return err; + } + break; + + // UTF-8 string + case LWMQTT_PROP_CONTENT_TYPE: + case LWMQTT_PROP_RESPONSE_TOPIC: + case LWMQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER: + case LWMQTT_PROP_AUTHENTICATION_METHOD: + case LWMQTT_PROP_RESPONSE_INFORMATION: + case LWMQTT_PROP_SERVER_REFERENCE: + case LWMQTT_PROP_REASON_STRING: + + // Arbitrary blobs as the same encoding. + case LWMQTT_PROP_CORRELATION_DATA: + case LWMQTT_PROP_AUTHENTICATION_DATA: + err = lwmqtt_read_string(&p, end, &prop.value.str); + if (err != LWMQTT_SUCCESS) { + return err; + } + break; + + case LWMQTT_PROP_USER_PROPERTY: + err = lwmqtt_read_string(&p, end, &prop.value.pair.k); + if (err != LWMQTT_SUCCESS) { + return err; + } + err = lwmqtt_read_string(&p, end, &prop.value.pair.v); + if (err != LWMQTT_SUCCESS) { + return err; + } + } + cb(ref, prop); + } + + return LWMQTT_SUCCESS; +} diff --git a/src/helpers.c b/src/helpers.c index eae4f00..e9b36fb 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -101,6 +101,18 @@ lwmqtt_err_t lwmqtt_write_num32(uint8_t **buf, const uint8_t *buf_end, uint32_t return LWMQTT_SUCCESS; } +lwmqtt_err_t lwmqtt_read_num32(uint8_t **buf, const uint8_t *buf_end, uint32_t *num) { + if ((size_t)(buf_end - (*buf)) < 4) { + return LWMQTT_BUFFER_TOO_SHORT; + } + + // read four byte integer + *num = ((uint32_t)(*buf)[0] << 24) | ((uint32_t)(*buf)[1] << 16) | ((uint32_t)(*buf)[2] << 8) | (uint32_t)(*buf)[3]; + + *buf += 4; + return LWMQTT_SUCCESS; +} + lwmqtt_err_t lwmqtt_read_string(uint8_t **buf, const uint8_t *buf_end, lwmqtt_string_t *str) { // read length uint16_t len; diff --git a/src/helpers.h b/src/helpers.h index 6d8a4b8..f23c511 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -67,6 +67,8 @@ lwmqtt_err_t lwmqtt_write_num(uint8_t **buf, const uint8_t *buf_end, uint16_t nu lwmqtt_err_t lwmqtt_write_num32(uint8_t **buf, const uint8_t *buf_end, uint32_t num); +lwmqtt_err_t lwmqtt_read_num32(uint8_t **buf, const uint8_t *buf_end, uint32_t *num); + /** * Reads a string from the specified buffer into the passed object. The pointer is incremented by the bytes read. * diff --git a/src/packet.c b/src/packet.c index 5883fbd..781eaaf 100644 --- a/src/packet.c +++ b/src/packet.c @@ -85,7 +85,7 @@ static size_t proplen(lwmqtt_property_t prop) { // Variable byte int case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: - lwmqtt_varnum_length(prop.value.varint, &ll); + lwmqtt_varnum_length(prop.value.int32, &ll); return 1 + ll; // UTF-8 string @@ -142,7 +142,7 @@ static lwmqtt_err_t write_prop(uint8_t **buf, const uint8_t *buf_end, lwmqtt_pro // Variable byte int case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: - return lwmqtt_write_varnum(buf, buf_end, prop.value.varint); + return lwmqtt_write_varnum(buf, buf_end, prop.value.int32); // UTF-8 string case LWMQTT_PROP_CONTENT_TYPE: diff --git a/tests/generated.cpp b/tests/generated.cpp index b29083e..9beaa97 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,37 +21,40 @@ extern "C" { } \ } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\240\228VZ\144!o", _pubPktID = -// 2440, _pubBody = "H\151\243\172\184\224\192", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "#\234\SI\231\179\228\175!\174\132/\ETXg\US\r\STX\178\203\151\187\DC3C", _pubPktID = 3425, _pubBody = ":\171^C\n", +// _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x3a, 0x13, 0x0, 0x8, 0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, - 0x6f, 0x9, 0x88, 0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; - uint8_t topic_bytes[] = {0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x1f, 0x0, 0x16, 0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, 0x3, 0x67, + 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43, 0xd, 0x61, 0x3a, 0xab, 0x5e, 0x43, 0xa}; + uint8_t topic_bytes[] = {0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, + 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; + uint8_t msg_bytes[] = {0x3a, 0xab, 0x5e, 0x43, 0xa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 5; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2440, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3425, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\240\228VZ\144!o", _pubPktID = -// 2440, _pubBody = "H\151\243\172\184\224\192", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "#\234\SI\231\179\228\175!\174\132/\ETXg\US\r\STX\178\203\151\187\DC3C", _pubPktID = 3425, _pubBody = ":\171^C\n", +// _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x3a, 0x13, 0x0, 0x8, 0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, - 0x6f, 0x9, 0x88, 0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; + uint8_t pkt[] = {0x32, 0x1f, 0x0, 0x16, 0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, 0x3, 0x67, + 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43, 0xd, 0x61, 0x3a, 0xab, 0x5e, 0x43, 0xa}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -60,53 +63,58 @@ TEST(Publish311QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, + 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x3a, 0xab, 0x5e, 0x43, 0xa}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2440); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(packet_id, 3425); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "}o\146\180\a\160\t\DC4T\196Oz)\145Z(2\146\157\n", _pubPktID = 8900, _pubBody = "GA\176\&8", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\158\245\154\154\236\CAN_4\221\253\192\177\172<\236c\171]F_", _pubPktID = 29370, _pubBody = +// "z\217-\243HF\176HG\200\166\159", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x3d, 0x1c, 0x0, 0x14, 0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, 0x4f, - 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa, 0x22, 0xc4, 0x47, 0x41, 0xb0, 0x38}; - uint8_t topic_bytes[] = {0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, - 0x4f, 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa}; + uint8_t pkt[] = {0x3c, 0x24, 0x0, 0x14, 0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, + 0xfd, 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f, 0x72, 0xba, + 0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; + uint8_t topic_bytes[] = {0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, 0xfd, + 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f}; lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x47, 0x41, 0xb0, 0x38}; + msg.retained = false; + uint8_t msg_bytes[] = {0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 12; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 8900, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29370, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "}o\146\180\a\160\t\DC4T\196Oz)\145Z(2\146\157\n", _pubPktID = 8900, _pubBody = "GA\176\&8", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\158\245\154\154\236\CAN_4\221\253\192\177\172<\236c\171]F_", _pubPktID = 29370, _pubBody = +// "z\217-\243HF\176HG\200\166\159", _pubProps = []} TEST(Publish311QCTest, Decode2) { - uint8_t pkt[] = {0x3d, 0x1c, 0x0, 0x14, 0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, 0x4f, - 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa, 0x22, 0xc4, 0x47, 0x41, 0xb0, 0x38}; + uint8_t pkt[] = {0x3c, 0x24, 0x0, 0x14, 0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, + 0xfd, 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f, 0x72, 0xba, + 0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -115,37 +123,41 @@ TEST(Publish311QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, - 0x4f, 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa}; + uint8_t exp_topic_bytes[] = {0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, 0xfd, + 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f}; lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x47, 0x41, 0xb0, 0x38}; - lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + uint8_t exp_body_bytes[] = {0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 8900); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 29370); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 4); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\151\STXH3\208\EM\137z\b\129j\156\252", _pubPktID = 0, _pubBody = "\202\152NR\SI_", _pubProps = []} +// "uh{\218\a\247\172\148\ESC\ETB\187\138\184\255\vX\180\DC1\131\&0\219\216\SI\147\203\ETX)\218", _pubPktID = 0, +// _pubBody = "\207\DC1\209\235\144\141K\255\225\177/B\DC1\DC3\175\144", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x38, 0x15, 0x0, 0xd, 0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, - 0x8, 0x81, 0x6a, 0x9c, 0xfc, 0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; - uint8_t topic_bytes[] = {0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x2e, 0x0, 0x1c, 0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, + 0xb8, 0xff, 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda, + 0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; + uint8_t topic_bytes[] = {0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, 0xb8, 0xff, + 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; + uint8_t msg_bytes[] = {0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, + 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 16; lwmqtt_property_t propslist[] = {}; @@ -158,10 +170,12 @@ TEST(Publish311QCTest, Encode3) { } // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\151\STXH3\208\EM\137z\b\129j\156\252", _pubPktID = 0, _pubBody = "\202\152NR\SI_", _pubProps = []} +// "uh{\218\a\247\172\148\ESC\ETB\187\138\184\255\vX\180\DC1\131\&0\219\216\SI\147\203\ETX)\218", _pubPktID = 0, +// _pubBody = "\207\DC1\209\235\144\141K\255\225\177/B\DC1\DC3\175\144", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x38, 0x15, 0x0, 0xd, 0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, - 0x8, 0x81, 0x6a, 0x9c, 0xfc, 0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; + uint8_t pkt[] = {0x38, 0x2e, 0x0, 0x1c, 0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, + 0xb8, 0xff, 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda, + 0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -170,52 +184,59 @@ TEST(Publish311QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; - lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, 0xb8, 0xff, + 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, + 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 6); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "<\v\SYN\154J\242", _pubPktID = -// 10596, _pubBody = "\187\150\168\193Z\202\188\STX?", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\193)\128\208yd\SOi\134\237\DC2Ir\136\217", _pubPktID = 8430, _pubBody = +// "\138\214\&5p\ESCn,\183\152u\192\244\165\&1\147\140\172", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x3c, 0x13, 0x0, 0x6, 0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2, 0x29, - 0x64, 0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; - uint8_t topic_bytes[] = {0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x24, 0x0, 0xf, 0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, + 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9, 0x20, 0xee, 0x8a, 0xd6, 0x35, 0x70, 0x1b, + 0x6e, 0x2c, 0xb7, 0x98, 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; + uint8_t topic_bytes[] = {0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; + msg.retained = true; + uint8_t msg_bytes[] = {0x8a, 0xd6, 0x35, 0x70, 0x1b, 0x6e, 0x2c, 0xb7, 0x98, + 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10596, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 8430, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "<\v\SYN\154J\242", _pubPktID = -// 10596, _pubBody = "\187\150\168\193Z\202\188\STX?", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\193)\128\208yd\SOi\134\237\DC2Ir\136\217", _pubPktID = 8430, _pubBody = +// "\138\214\&5p\ESCn,\183\152u\192\244\165\&1\147\140\172", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x3c, 0x13, 0x0, 0x6, 0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2, 0x29, - 0x64, 0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; + uint8_t pkt[] = {0x3d, 0x24, 0x0, 0xf, 0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, + 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9, 0x20, 0xee, 0x8a, 0xd6, 0x35, 0x70, 0x1b, + 0x6e, 0x2c, 0xb7, 0x98, 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -224,52 +245,59 @@ TEST(Publish311QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8a, 0xd6, 0x35, 0x70, 0x1b, 0x6e, 0x2c, 0xb7, 0x98, + 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10596); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 8430); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\165,\215\220S\205E\205\200\222\229\249\ESC\148", _pubPktID = 15507, _pubBody = "pR:\130:", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\DC2\184\144\&5\136\156E\174\237\230\175\SUB\153 \NAKk\EM\f", _pubPktID = 0, _pubBody = +// "i\232{\DC3k\GS\158\DLE|\218\236v\244>\145\172,\bR\165\255\174", _pubProps = []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x3c, 0x17, 0x0, 0xe, 0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, - 0xde, 0xe5, 0xf9, 0x1b, 0x94, 0x3c, 0x93, 0x70, 0x52, 0x3a, 0x82, 0x3a}; - uint8_t topic_bytes[] = {0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, 0xf9, 0x1b, 0x94}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x2a, 0x0, 0x12, 0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, 0xe6, 0xaf, + 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc, 0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, + 0x7c, 0xda, 0xec, 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; + uint8_t topic_bytes[] = {0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, + 0xe6, 0xaf, 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x70, 0x52, 0x3a, 0x82, 0x3a}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, 0xda, 0xec, + 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 15507, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\165,\215\220S\205E\205\200\222\229\249\ESC\148", _pubPktID = 15507, _pubBody = "pR:\130:", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\DC2\184\144\&5\136\156E\174\237\230\175\SUB\153 \NAKk\EM\f", _pubPktID = 0, _pubBody = +// "i\232{\DC3k\GS\158\DLE|\218\236v\244>\145\172,\bR\165\255\174", _pubProps = []} TEST(Publish311QCTest, Decode5) { - uint8_t pkt[] = {0x3c, 0x17, 0x0, 0xe, 0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, - 0xde, 0xe5, 0xf9, 0x1b, 0x94, 0x3c, 0x93, 0x70, 0x52, 0x3a, 0x82, 0x3a}; + uint8_t pkt[] = {0x31, 0x2a, 0x0, 0x12, 0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, 0xe6, 0xaf, + 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc, 0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, + 0x7c, 0xda, 0xec, 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -278,57 +306,54 @@ TEST(Publish311QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, 0xf9, 0x1b, 0x94}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x70, 0x52, 0x3a, 0x82, 0x3a}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 15507); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + uint8_t exp_topic_bytes[] = {0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, + 0xe6, 0xaf, 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, 0xda, 0xec, + 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\v\255\253\245\160v\SO\231\130e\134B1\174\n", _pubPktID = 29653, _pubBody = -// "\169\178\185\220\v\ACKV\254\137C8\154\ETB\\\213\142=", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\251M\156e\192", _pubPktID = 0, +// _pubBody = "O\254\197\133\153\151~\137\172", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x35, 0x24, 0x0, 0xf, 0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, - 0x65, 0x86, 0x42, 0x31, 0xae, 0xa, 0x73, 0xd5, 0xa9, 0xb2, 0xb9, 0xdc, 0xb, - 0x6, 0x56, 0xfe, 0x89, 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; - uint8_t topic_bytes[] = {0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, 0x65, 0x86, 0x42, 0x31, 0xae, 0xa}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x10, 0x0, 0x5, 0xfb, 0x4d, 0x9c, 0x65, 0xc0, + 0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; + uint8_t topic_bytes[] = {0xfb, 0x4d, 0x9c, 0x65, 0xc0}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xa9, 0xb2, 0xb9, 0xdc, 0xb, 0x6, 0x56, 0xfe, 0x89, - 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; + uint8_t msg_bytes[] = {0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 9; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29653, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\v\255\253\245\160v\SO\231\130e\134B1\174\n", _pubPktID = 29653, _pubBody = -// "\169\178\185\220\v\ACKV\254\137C8\154\ETB\\\213\142=", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\251M\156e\192", _pubPktID = 0, +// _pubBody = "O\254\197\133\153\151~\137\172", _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x35, 0x24, 0x0, 0xf, 0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, - 0x65, 0x86, 0x42, 0x31, 0xae, 0xa, 0x73, 0xd5, 0xa9, 0xb2, 0xb9, 0xdc, 0xb, - 0x6, 0x56, 0xfe, 0x89, 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; + uint8_t pkt[] = {0x31, 0x10, 0x0, 0x5, 0xfb, 0x4d, 0x9c, 0x65, 0xc0, + 0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -337,54 +362,55 @@ TEST(Publish311QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, 0x65, 0x86, 0x42, 0x31, 0xae, 0xa}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa9, 0xb2, 0xb9, 0xdc, 0xb, 0x6, 0x56, 0xfe, 0x89, - 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xfb, 0x4d, 0x9c, 0x65, 0xc0}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29653); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\207)#\195\178f\ESC\134K\157xAj\210\148\138\207\185", _pubPktID = 17568, _pubBody = "\171Y", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\224@\143", _pubPktID = 6480, +// _pubBody = "p\191(\150l\241Y\SO\208g\192\EMT+\DLE\246\189f\179C\EOTFwX1\DC3I*A\n", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x33, 0x18, 0x0, 0x12, 0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, - 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9, 0x44, 0xa0, 0xab, 0x59}; - uint8_t topic_bytes[] = {0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, - 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x25, 0x0, 0x3, 0xe0, 0x40, 0x8f, 0x19, 0x50, 0x70, 0xbf, 0x28, 0x96, + 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, 0xf6, 0xbd, + 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; + uint8_t topic_bytes[] = {0xe0, 0x40, 0x8f}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xab, 0x59}; + uint8_t msg_bytes[] = {0x70, 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, + 0xf6, 0xbd, 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 30; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17568, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6480, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\207)#\195\178f\ESC\134K\157xAj\210\148\138\207\185", _pubPktID = 17568, _pubBody = "\171Y", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\224@\143", _pubPktID = 6480, +// _pubBody = "p\191(\150l\241Y\SO\208g\192\EMT+\DLE\246\189f\179C\EOTFwX1\DC3I*A\n", _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x33, 0x18, 0x0, 0x12, 0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, - 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9, 0x44, 0xa0, 0xab, 0x59}; + uint8_t pkt[] = {0x3b, 0x25, 0x0, 0x3, 0xe0, 0x40, 0x8f, 0x19, 0x50, 0x70, 0xbf, 0x28, 0x96, + 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, 0xf6, 0xbd, + 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -393,58 +419,58 @@ TEST(Publish311QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, - 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xab, 0x59}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xe0, 0x40, 0x8f}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x70, 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, + 0xf6, 0xbd, 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 17568); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(packet_id, 6480); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "(9fA\NAK\140\194;\215\236\145\SO\240#\ESC", _pubPktID = 5686, _pubBody = -// "\197\149\245\GS\f\206T\209\&7\232c\143\164A\177\DC3\r<.\ACK", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\141\RSw\147`\NAK\ENQ\149f_Y\196\&3b\209U\150s\240\238\a\156\v\151~%\224P\244", _pubPktID = 0, _pubBody = +// "\220\213O", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x32, 0x27, 0x0, 0xf, 0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, - 0x91, 0xe, 0xf0, 0x23, 0x1b, 0x16, 0x36, 0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, - 0xd1, 0x37, 0xe8, 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; - uint8_t topic_bytes[] = {0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, 0x1b}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x22, 0x0, 0x1d, 0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, + 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, 0x55, 0x96, 0x73, 0xf0, 0xee, + 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4, 0xdc, 0xd5, 0x4f}; + uint8_t topic_bytes[] = {0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, + 0x55, 0x96, 0x73, 0xf0, 0xee, 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, 0xd1, 0x37, 0xe8, - 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; + uint8_t msg_bytes[] = {0xdc, 0xd5, 0x4f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 3; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 5686, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "(9fA\NAK\140\194;\215\236\145\SO\240#\ESC", _pubPktID = 5686, _pubBody = -// "\197\149\245\GS\f\206T\209\&7\232c\143\164A\177\DC3\r<.\ACK", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\141\RSw\147`\NAK\ENQ\149f_Y\196\&3b\209U\150s\240\238\a\156\v\151~%\224P\244", _pubPktID = 0, _pubBody = +// "\220\213O", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x32, 0x27, 0x0, 0xf, 0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, - 0x91, 0xe, 0xf0, 0x23, 0x1b, 0x16, 0x36, 0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, - 0xd1, 0x37, 0xe8, 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; + uint8_t pkt[] = {0x38, 0x22, 0x0, 0x1d, 0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, + 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, 0x55, 0x96, 0x73, 0xf0, 0xee, + 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4, 0xdc, 0xd5, 0x4f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -453,58 +479,58 @@ TEST(Publish311QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, 0x1b}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, 0xd1, 0x37, 0xe8, - 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, + 0x55, 0x96, 0x73, 0xf0, 0xee, 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xdc, 0xd5, 0x4f}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 5686); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\234\227\201xQ\221\GS\f\US\208(\t\212", _pubPktID = 0, _pubBody = -// "\140\174]d\t\144\158\DC2\237\196\202\147\133\154\231\176|1", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\130\180J\210\214\ENQ\185\DC3T.\233,_\253N\188M\218\t\203\210\&9z\193w\227", _pubPktID = 5801, _pubBody = +// "e/2Y\147]W%\233\NUL\170j25\192", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x38, 0x21, 0x0, 0xd, 0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, - 0x1f, 0xd0, 0x28, 0x9, 0xd4, 0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, - 0x12, 0xed, 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; - uint8_t topic_bytes[] = {0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, 0x1f, 0xd0, 0x28, 0x9, 0xd4}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x2d, 0x0, 0x1a, 0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, + 0x5f, 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3, 0x16, 0xa9, + 0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; + uint8_t topic_bytes[] = {0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, 0x5f, + 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, - 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; + uint8_t msg_bytes[] = {0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5801, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\234\227\201xQ\221\GS\f\US\208(\t\212", _pubPktID = 0, _pubBody = -// "\140\174]d\t\144\158\DC2\237\196\202\147\133\154\231\176|1", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\130\180J\210\214\ENQ\185\DC3T.\233,_\253N\188M\218\t\203\210\&9z\193w\227", _pubPktID = 5801, _pubBody = +// "e/2Y\147]W%\233\NUL\170j25\192", _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x38, 0x21, 0x0, 0xd, 0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, - 0x1f, 0xd0, 0x28, 0x9, 0xd4, 0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, - 0x12, 0xed, 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; + uint8_t pkt[] = {0x3a, 0x2d, 0x0, 0x1a, 0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, + 0x5f, 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3, 0x16, 0xa9, + 0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -513,59 +539,54 @@ TEST(Publish311QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, 0x1f, 0xd0, 0x28, 0x9, 0xd4}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, - 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, 0x5f, + 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + EXPECT_EQ(packet_id, 5801); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\SYNr\142QB1\171\213)1\210q\199\"\203\225\251\233[&p\202\238", _pubPktID = 17787, _pubBody = -// "\172\FS\186\216A\244\EOT^<\NAK\136\187\235\ESC\245\209\128", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "$hC\136_\134&\134\182\244\211M\211a\221[", _pubPktID = 25662, _pubBody = "", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x32, 0x2c, 0x0, 0x17, 0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, - 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee, 0x45, 0x7b, 0xac, 0x1c, 0xba, - 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; - uint8_t topic_bytes[] = {0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, - 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x14, 0x0, 0x10, 0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, + 0x86, 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b, 0x64, 0x3e}; + uint8_t topic_bytes[] = {0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, + 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, - 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 0; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17787, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25662, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\SYNr\142QB1\171\213)1\210q\199\"\203\225\251\233[&p\202\238", _pubPktID = 17787, _pubBody = -// "\172\FS\186\216A\244\EOT^<\NAK\136\187\235\ESC\245\209\128", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "$hC\136_\134&\134\182\244\211M\211a\221[", _pubPktID = 25662, _pubBody = "", _pubProps = []} TEST(Publish311QCTest, Decode10) { - uint8_t pkt[] = {0x32, 0x2c, 0x0, 0x17, 0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, - 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee, 0x45, 0x7b, 0xac, 0x1c, 0xba, - 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; + uint8_t pkt[] = {0x3c, 0x14, 0x0, 0x10, 0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, + 0x86, 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b, 0x64, 0x3e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -574,55 +595,58 @@ TEST(Publish311QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, - 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, - 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, + 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b}; + lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 17787); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(packet_id, 25662); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "e", _pubPktID = 29287, _pubBody = -// "o\220=\DLE\237\181\219\FS\ESC%~\198\SYN/{P", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\181\165\155@\151\196\153>\212\208\158e;\229\178\rW&", _pubPktID = 28678, _pubBody = +// "\197b\187\ACKO^\130\182\SI\241\185\141\n\187P", _pubProps = []} TEST(Publish311QCTest, Encode11) { - uint8_t pkt[] = {0x33, 0x15, 0x0, 0x1, 0x65, 0x72, 0x67, 0x6f, 0xdc, 0x3d, 0x10, 0xed, - 0xb5, 0xdb, 0x1c, 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; - uint8_t topic_bytes[] = {0x65}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x25, 0x0, 0x12, 0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, + 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26, 0x70, 0x6, 0xc5, 0x62, + 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; + uint8_t topic_bytes[] = {0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, + 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x6f, 0xdc, 0x3d, 0x10, 0xed, 0xb5, 0xdb, 0x1c, - 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; + msg.retained = false; + uint8_t msg_bytes[] = {0xc5, 0x62, 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29287, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 28678, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "e", _pubPktID = 29287, _pubBody = -// "o\220=\DLE\237\181\219\FS\ESC%~\198\SYN/{P", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\181\165\155@\151\196\153>\212\208\158e;\229\178\rW&", _pubPktID = 28678, _pubBody = +// "\197b\187\ACKO^\130\182\SI\241\185\141\n\187P", _pubProps = []} TEST(Publish311QCTest, Decode11) { - uint8_t pkt[] = {0x33, 0x15, 0x0, 0x1, 0x65, 0x72, 0x67, 0x6f, 0xdc, 0x3d, 0x10, 0xed, - 0xb5, 0xdb, 0x1c, 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; + uint8_t pkt[] = {0x32, 0x25, 0x0, 0x12, 0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, + 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26, 0x70, 0x6, 0xc5, 0x62, + 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -631,55 +655,54 @@ TEST(Publish311QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x65}; - lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x6f, 0xdc, 0x3d, 0x10, 0xed, 0xb5, 0xdb, 0x1c, - 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, + 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc5, 0x62, 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29287); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 28678); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\139\194\ETB\145\245\&3\175\131\230\149\231\192\SO", _pubPktID = 2558, _pubBody = -// "3u\151\168\SYN\191\144\230d\rn\148=", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\196x\255\172\&4\CAN?V{\217\182\160\&3\169g\176\192\r\NAK\186s", _pubPktID = 0, _pubBody = "s", _pubProps = []} TEST(Publish311QCTest, Encode12) { - uint8_t pkt[] = {0x32, 0x1e, 0x0, 0xd, 0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, - 0xe, 0x9, 0xfe, 0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; - uint8_t topic_bytes[] = {0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x18, 0x0, 0x15, 0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, + 0xd9, 0xb6, 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73, 0x73}; + uint8_t topic_bytes[] = {0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, + 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x73}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 1; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 2558, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\139\194\ETB\145\245\&3\175\131\230\149\231\192\SO", _pubPktID = 2558, _pubBody = -// "3u\151\168\SYN\191\144\230d\rn\148=", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\196x\255\172\&4\CAN?V{\217\182\160\&3\169g\176\192\r\NAK\186s", _pubPktID = 0, _pubBody = "s", _pubProps = []} TEST(Publish311QCTest, Decode12) { - uint8_t pkt[] = {0x32, 0x1e, 0x0, 0xd, 0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, - 0xe, 0x9, 0xfe, 0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; + uint8_t pkt[] = {0x39, 0x18, 0x0, 0x15, 0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, + 0xd9, 0xb6, 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73, 0x73}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -688,52 +711,56 @@ TEST(Publish311QCTest, Decode12) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2558); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 13); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + uint8_t exp_topic_bytes[] = {0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, + 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x73}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "$\212", _pubPktID = 1716, _pubBody -// = "\190\141B\DELW\166\237\195J\183\212y\176h", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\136@e", _pubPktID = 1120, _pubBody +// = "U\146=\184\GS9[\230\210\180\157\ENQ\204\240\DC36\FSl0\136\172^\RSr4t7\193\178", _pubProps = []} TEST(Publish311QCTest, Encode13) { - uint8_t pkt[] = {0x34, 0x14, 0x0, 0x2, 0x24, 0xd4, 0x6, 0xb4, 0xbe, 0x8d, 0x42, - 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; - uint8_t topic_bytes[] = {0x24, 0xd4}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x24, 0x0, 0x3, 0x88, 0x40, 0x65, 0x4, 0x60, 0x55, 0x92, 0x3d, 0xb8, + 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, 0x36, 0x1c, + 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; + uint8_t topic_bytes[] = {0x88, 0x40, 0x65}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; + msg.retained = true; + uint8_t msg_bytes[] = {0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, + 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 29; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1716, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1120, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "$\212", _pubPktID = 1716, _pubBody -// = "\190\141B\DELW\166\237\195J\183\212y\176h", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\136@e", _pubPktID = 1120, _pubBody +// = "U\146=\184\GS9[\230\210\180\157\ENQ\204\240\DC36\FSl0\136\172^\RSr4t7\193\178", _pubProps = []} TEST(Publish311QCTest, Decode13) { - uint8_t pkt[] = {0x34, 0x14, 0x0, 0x2, 0x24, 0xd4, 0x6, 0xb4, 0xbe, 0x8d, 0x42, - 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; + uint8_t pkt[] = {0x35, 0x24, 0x0, 0x3, 0x88, 0x40, 0x65, 0x4, 0x60, 0x55, 0x92, 0x3d, 0xb8, + 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, 0x36, 0x1c, + 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -742,52 +769,56 @@ TEST(Publish311QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x24, 0xd4}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x88, 0x40, 0x65}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, + 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 1716); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 1120); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\180\150\252c\201h%\ACKX[", -// _pubPktID = 23232, _pubBody = "\245\158IP\ETX\CAN\DLE|\148\175\r", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\156\129\b\202\ETB\"y\195\204\150S\DLE\231\CANg\207\&0\n\246~U\196\194\&5", _pubPktID = 17194, _pubBody = +// "\158\237", _pubProps = []} TEST(Publish311QCTest, Encode14) { - uint8_t pkt[] = {0x3c, 0x19, 0x0, 0xa, 0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b, - 0x5a, 0xc0, 0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; - uint8_t topic_bytes[] = {0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x1e, 0x0, 0x18, 0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, + 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35, 0x43, 0x2a, 0x9e, 0xed}; + uint8_t topic_bytes[] = {0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, + 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x9e, 0xed}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 2; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 23232, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17194, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\180\150\252c\201h%\ACKX[", -// _pubPktID = 23232, _pubBody = "\245\158IP\ETX\CAN\DLE|\148\175\r", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\156\129\b\202\ETB\"y\195\204\150S\DLE\231\CANg\207\&0\n\246~U\196\194\&5", _pubPktID = 17194, _pubBody = +// "\158\237", _pubProps = []} TEST(Publish311QCTest, Decode14) { - uint8_t pkt[] = {0x3c, 0x19, 0x0, 0xa, 0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b, - 0x5a, 0xc0, 0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; + uint8_t pkt[] = {0x33, 0x1e, 0x0, 0x18, 0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, + 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35, 0x43, 0x2a, 0x9e, 0xed}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -796,55 +827,56 @@ TEST(Publish311QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 23232); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + uint8_t exp_topic_bytes[] = {0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, + 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9e, 0xed}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 17194); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\200a\188\164\254\SO\133s@", -// _pubPktID = 0, _pubBody = "i(topic.data), 9); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 18606); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ">\248\138\204\&7]\233\FS\228\b|\187\148\202aA\US\153\STX\GS\135\211p", _pubPktID = 4359, _pubBody = -// "\242\145\166\143\135]\136Z\130\202\216\&2*\239?C\217\144\162", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\168E\247k\237\175\&5\SO\SYNU\224\160", _pubPktID = 28189, _pubBody = "", _pubProps = []} TEST(Publish311QCTest, Encode16) { - uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x17, 0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, - 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70, 0x11, 0x7, 0xf2, 0x91, 0xa6, - 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; - uint8_t topic_bytes[] = {0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, - 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x10, 0x0, 0xc, 0xa8, 0x45, 0xf7, 0x6b, 0xed, + 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0, 0x6e, 0x1d}; + uint8_t topic_bytes[] = {0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, - 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; + msg.retained = true; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 0; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 4359, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 28189, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ">\248\138\204\&7]\233\FS\228\b|\187\148\202aA\US\153\STX\GS\135\211p", _pubPktID = 4359, _pubBody = -// "\242\145\166\143\135]\136Z\130\202\216\&2*\239?C\217\144\162", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\168E\247k\237\175\&5\SO\SYNU\224\160", _pubPktID = 28189, _pubBody = "", _pubProps = []} TEST(Publish311QCTest, Decode16) { - uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x17, 0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, - 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70, 0x11, 0x7, 0xf2, 0x91, 0xa6, - 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; + uint8_t pkt[] = {0x35, 0x10, 0x0, 0xc, 0xa8, 0x45, 0xf7, 0x6b, 0xed, + 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0, 0x6e, 0x1d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -914,60 +940,54 @@ TEST(Publish311QCTest, Decode16) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, - 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, - 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 4359); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); - lwmqtt_string_t x = exp_topic; - x = exp_body; + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 28189); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + lwmqtt_string_t x = exp_topic; + x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\245*\174k\165!xK\226\163\190\195\171\228\STXdu\RS", _pubPktID = 10342, _pubBody = -// "\178\172\US)\254\SYN\146\229\NULP\NAK\n\186\220\f\"\SYN\230\190", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\191\CAN?\r\149\&0\185\198\tZ\213\STX5\192\195", _pubPktID = 0, _pubBody = "\190\206\169pC<\142\135\&8\243", +// _pubProps = []} TEST(Publish311QCTest, Encode17) { - uint8_t pkt[] = {0x32, 0x29, 0x0, 0x12, 0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, 0xa3, 0xbe, - 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e, 0x28, 0x66, 0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, - 0x92, 0xe5, 0x0, 0x50, 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; - uint8_t topic_bytes[] = {0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, - 0xa3, 0xbe, 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x1b, 0x0, 0xf, 0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, + 0x2, 0x35, 0xc0, 0xc3, 0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; + uint8_t topic_bytes[] = {0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, 0x2, 0x35, 0xc0, 0xc3}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, - 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 10; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10342, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\245*\174k\165!xK\226\163\190\195\171\228\STXdu\RS", _pubPktID = 10342, _pubBody = -// "\178\172\US)\254\SYN\146\229\NULP\NAK\n\186\220\f\"\SYN\230\190", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\191\CAN?\r\149\&0\185\198\tZ\213\STX5\192\195", _pubPktID = 0, _pubBody = "\190\206\169pC<\142\135\&8\243", +// _pubProps = []} TEST(Publish311QCTest, Decode17) { - uint8_t pkt[] = {0x32, 0x29, 0x0, 0x12, 0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, 0xa3, 0xbe, - 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e, 0x28, 0x66, 0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, - 0x92, 0xe5, 0x0, 0x50, 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; + uint8_t pkt[] = {0x39, 0x1b, 0x0, 0xf, 0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, + 0x2, 0x35, 0xc0, 0xc3, 0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -976,59 +996,58 @@ TEST(Publish311QCTest, Decode17) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, - 0xa3, 0xbe, 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, - 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10342); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + uint8_t exp_topic_bytes[] = {0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, 0x2, 0x35, 0xc0, 0xc3}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "W\DC4\201\190\193\SUB\164\DC3i\182]\GS", _pubPktID = 18773, _pubBody = -// "*F\223\201\140z\253\&8Q\176\t\175!\148(4\SOH\248\EM\192\217B\193\220\225", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\209\227N0}\DEL\200\186\135Q\178Ab\227[N~\173\197\252P", _pubPktID = 17259, _pubBody = +// "\211\&9\214\163\194\138\\\205\223\162\148\156\131\232\SYN\215\213\DC4\174", _pubProps = []} TEST(Publish311QCTest, Encode18) { - uint8_t pkt[] = {0x3a, 0x29, 0x0, 0xc, 0x57, 0x14, 0xc9, 0xbe, 0xc1, 0x1a, 0xa4, 0x13, 0x69, 0xb6, 0x5d, - 0x1d, 0x49, 0x55, 0x2a, 0x46, 0xdf, 0xc9, 0x8c, 0x7a, 0xfd, 0x38, 0x51, 0xb0, 0x9, 0xaf, - 0x21, 0x94, 0x28, 0x34, 0x1, 0xf8, 0x19, 0xc0, 0xd9, 0x42, 0xc1, 0xdc, 0xe1}; - uint8_t topic_bytes[] = {0x57, 0x14, 0xc9, 0xbe, 0xc1, 0x1a, 0xa4, 0x13, 0x69, 0xb6, 0x5d, 0x1d}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x2c, 0x0, 0x15, 0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, 0x41, + 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50, 0x43, 0x6b, 0xd3, 0x39, 0xd6, 0xa3, 0xc2, + 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; + uint8_t topic_bytes[] = {0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, + 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x2a, 0x46, 0xdf, 0xc9, 0x8c, 0x7a, 0xfd, 0x38, 0x51, 0xb0, 0x9, 0xaf, 0x21, - 0x94, 0x28, 0x34, 0x1, 0xf8, 0x19, 0xc0, 0xd9, 0x42, 0xc1, 0xdc, 0xe1}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, + 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 18773, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 17259, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "W\DC4\201\190\193\SUB\164\DC3i\182]\GS", _pubPktID = 18773, _pubBody = -// "*F\223\201\140z\253\&8Q\176\t\175!\148(4\SOH\248\EM\192\217B\193\220\225", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\209\227N0}\DEL\200\186\135Q\178Ab\227[N~\173\197\252P", _pubPktID = 17259, _pubBody = +// "\211\&9\214\163\194\138\\\205\223\162\148\156\131\232\SYN\215\213\DC4\174", _pubProps = []} TEST(Publish311QCTest, Decode18) { - uint8_t pkt[] = {0x3a, 0x29, 0x0, 0xc, 0x57, 0x14, 0xc9, 0xbe, 0xc1, 0x1a, 0xa4, 0x13, 0x69, 0xb6, 0x5d, - 0x1d, 0x49, 0x55, 0x2a, 0x46, 0xdf, 0xc9, 0x8c, 0x7a, 0xfd, 0x38, 0x51, 0xb0, 0x9, 0xaf, - 0x21, 0x94, 0x28, 0x34, 0x1, 0xf8, 0x19, 0xc0, 0xd9, 0x42, 0xc1, 0xdc, 0xe1}; + uint8_t pkt[] = {0x3d, 0x2c, 0x0, 0x15, 0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, 0x41, + 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50, 0x43, 0x6b, 0xd3, 0x39, 0xd6, 0xa3, 0xc2, + 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1037,54 +1056,59 @@ TEST(Publish311QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x57, 0x14, 0xc9, 0xbe, 0xc1, 0x1a, 0xa4, 0x13, 0x69, 0xb6, 0x5d, 0x1d}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2a, 0x46, 0xdf, 0xc9, 0x8c, 0x7a, 0xfd, 0x38, 0x51, 0xb0, 0x9, 0xaf, 0x21, - 0x94, 0x28, 0x34, 0x1, 0xf8, 0x19, 0xc0, 0xd9, 0x42, 0xc1, 0xdc, 0xe1}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, + 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, + 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 18773); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 17259); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\194", _pubPktID = 0, _pubBody = -// "\251\145\"\229\t+\230\175\144\209p\ETX^\217KR\195", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\157\255\149\212\150\224\139\154J\197\&0C\166\189\203/\179f$J\197-\r\240\SUB\188;\r\173", _pubPktID = 22738, +// _pubBody = "\210\DC1\143z\164\179\bD\DELn", _pubProps = []} TEST(Publish311QCTest, Encode19) { - uint8_t pkt[] = {0x31, 0x15, 0x0, 0x2, 0xdd, 0xc2, 0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, - 0xe6, 0xaf, 0x90, 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; - uint8_t topic_bytes[] = {0xdd, 0xc2}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x2b, 0x0, 0x1d, 0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, + 0x43, 0xa6, 0xbd, 0xcb, 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, + 0x3b, 0xd, 0xad, 0x58, 0xd2, 0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; + uint8_t topic_bytes[] = {0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, 0x43, 0xa6, 0xbd, 0xcb, + 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, 0x3b, 0xd, 0xad}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, - 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 10; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 22738, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\194", _pubPktID = 0, _pubBody = -// "\251\145\"\229\t+\230\175\144\209p\ETX^\217KR\195", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\157\255\149\212\150\224\139\154J\197\&0C\166\189\203/\179f$J\197-\r\240\SUB\188;\r\173", _pubPktID = 22738, +// _pubBody = "\210\DC1\143z\164\179\bD\DELn", _pubProps = []} TEST(Publish311QCTest, Decode19) { - uint8_t pkt[] = {0x31, 0x15, 0x0, 0x2, 0xdd, 0xc2, 0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, - 0xe6, 0xaf, 0x90, 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; + uint8_t pkt[] = {0x3c, 0x2b, 0x0, 0x1d, 0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, + 0x43, 0xa6, 0xbd, 0xcb, 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, + 0x3b, 0xd, 0xad, 0x58, 0xd2, 0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1093,54 +1117,54 @@ TEST(Publish311QCTest, Decode19) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xdd, 0xc2}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, - 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + uint8_t exp_topic_bytes[] = {0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, 0x43, 0xa6, 0xbd, 0xcb, + 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, 0x3b, 0xd, 0xad}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 22738); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\253\&0\CANabo\DC3\254\241\240\244{\194\r)2\133Gj\233%", _pubPktID = 23762, _pubBody = "\224", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 6071, _pubBody = +// "#\140\138\233\171\140\SOH9\165\168kP\138\237?\192\174", _pubProps = []} TEST(Publish311QCTest, Encode20) { - uint8_t pkt[] = {0x35, 0x1a, 0x0, 0x15, 0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, - 0xf4, 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25, 0x5c, 0xd2, 0xe0}; - uint8_t topic_bytes[] = {0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, 0xf4, - 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x15, 0x0, 0x0, 0x17, 0xb7, 0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, + 0x1, 0x39, 0xa5, 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xe0}; + uint8_t msg_bytes[] = {0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, + 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 23762, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6071, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\253\&0\CANabo\DC3\254\241\240\244{\194\r)2\133Gj\233%", _pubPktID = 23762, _pubBody = "\224", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 6071, _pubBody = +// "#\140\138\233\171\140\SOH9\165\168kP\138\237?\192\174", _pubProps = []} TEST(Publish311QCTest, Decode20) { - uint8_t pkt[] = {0x35, 0x1a, 0x0, 0x15, 0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, - 0xf4, 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25, 0x5c, 0xd2, 0xe0}; + uint8_t pkt[] = {0x3b, 0x15, 0x0, 0x0, 0x17, 0xb7, 0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, + 0x1, 0x39, 0xa5, 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1149,51 +1173,56 @@ TEST(Publish311QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, 0xf4, - 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xe0}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, + 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 23762); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(packet_id, 6071); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC1\DC4:", _pubPktID = 0, _pubBody = -// "V\144J\230\153\132\164\SO", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "(topic.data), 3); - EXPECT_EQ(msg.payload_len, 8); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "6\USp^\205\245IA -// \ETB+\158\220\216ea[,\180\190\&1\DLE\183\198\217", _pubPktID = 25164, _pubBody = -// "\155\145\198\173f\139:a\195\141sE}\221\223\243\145\224*\180\vSEy{\166\178\148`", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 29931, _pubBody = +// "\254t\DLE\GS|r\CAN\243)\RS\151\DC4/_\229b\\", _pubProps = []} TEST(Publish311QCTest, Encode22) { - uint8_t pkt[] = {0x33, 0x3a, 0x0, 0x19, 0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, - 0x9e, 0xdc, 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9, 0x62, - 0x4c, 0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, - 0xdf, 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; - uint8_t topic_bytes[] = {0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, 0x9e, 0xdc, - 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x15, 0x0, 0x0, 0x74, 0xeb, 0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, + 0x18, 0xf3, 0x29, 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, 0xdf, - 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, + 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25164, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29931, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "6\USp^\205\245IA -// \ETB+\158\220\216ea[,\180\190\&1\DLE\183\198\217", _pubPktID = 25164, _pubBody = -// "\155\145\198\173f\139:a\195\141sE}\221\223\243\145\224*\180\vSEy{\166\178\148`", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 29931, _pubBody = +// "\254t\DLE\GS|r\CAN\243)\RS\151\DC4/_\229b\\", _pubProps = []} TEST(Publish311QCTest, Decode22) { - uint8_t pkt[] = {0x33, 0x3a, 0x0, 0x19, 0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, - 0x9e, 0xdc, 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9, 0x62, - 0x4c, 0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, - 0xdf, 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; + uint8_t pkt[] = {0x3c, 0x15, 0x0, 0x0, 0x74, 0xeb, 0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, + 0x18, 0xf3, 0x29, 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1264,52 +1287,59 @@ TEST(Publish311QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, 0x9e, 0xdc, - 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, 0xdf, - 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 25164); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, + 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 29931); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\178\&7A\251\143\146\159\171\130\211\146\190g", _pubPktID = 0, _pubBody = "", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\128\158-GrC\129\166\140\231\NULj!M4\SUB", _pubPktID = 0, _pubBody = +// "\228\ESC\231\DC3\136\217\177W_\ESCp\130\DC2\212,\158\236\215\204\207m\205", _pubProps = []} TEST(Publish311QCTest, Encode23) { - uint8_t pkt[] = {0x39, 0xf, 0x0, 0xd, 0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; - uint8_t topic_bytes[] = {0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x28, 0x0, 0x10, 0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, 0x8c, 0xe7, + 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a, 0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, + 0x5f, 0x1b, 0x70, 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; + uint8_t topic_bytes[] = {0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, + 0x8c, 0xe7, 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0}; + uint8_t msg_bytes[] = {0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, 0x1b, 0x70, + 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\178\&7A\251\143\146\159\171\130\211\146\190g", _pubPktID = 0, _pubBody = "", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\128\158-GrC\129\166\140\231\NULj!M4\SUB", _pubPktID = 0, _pubBody = +// "\228\ESC\231\DC3\136\217\177W_\ESCp\130\DC2\212,\158\236\215\204\207m\205", _pubProps = []} TEST(Publish311QCTest, Decode23) { - uint8_t pkt[] = {0x39, 0xf, 0x0, 0xd, 0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; + uint8_t pkt[] = {0x31, 0x28, 0x0, 0x10, 0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, 0x8c, 0xe7, + 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a, 0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, + 0x5f, 0x1b, 0x70, 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1318,52 +1348,62 @@ TEST(Publish311QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, + 0x8c, 0xe7, 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a}; + lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, 0x1b, 0x70, + 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\198\161\148\238\191@\246\217\217\241\DC1\227\239", _pubPktID = 10944, _pubBody = "R3\160", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "s\233\140\183\209=t\220\206\194\143\249\ETX\234\&5\b\144\f\246\250\US\193\193\178\226\201\156", _pubPktID = 8248, +// _pubBody = "v\196\240]\193r\165~\158\205\155'\206\&8\215s\248\196\250\&1\247", _pubProps = []} TEST(Publish311QCTest, Encode24) { - uint8_t pkt[] = {0x3c, 0x14, 0x0, 0xd, 0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, - 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef, 0x2a, 0xc0, 0x52, 0x33, 0xa0}; - uint8_t topic_bytes[] = {0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x34, 0x0, 0x1b, 0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, + 0x8f, 0xf9, 0x3, 0xea, 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, + 0xe2, 0xc9, 0x9c, 0x20, 0x38, 0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, + 0xcd, 0x9b, 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; + uint8_t topic_bytes[] = {0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, 0x3, 0xea, + 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x52, 0x33, 0xa0}; + uint8_t msg_bytes[] = {0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, + 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10944, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8248, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\198\161\148\238\191@\246\217\217\241\DC1\227\239", _pubPktID = 10944, _pubBody = "R3\160", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "s\233\140\183\209=t\220\206\194\143\249\ETX\234\&5\b\144\f\246\250\US\193\193\178\226\201\156", _pubPktID = 8248, +// _pubBody = "v\196\240]\193r\165~\158\205\155'\206\&8\215s\248\196\250\&1\247", _pubProps = []} TEST(Publish311QCTest, Decode24) { - uint8_t pkt[] = {0x3c, 0x14, 0x0, 0xd, 0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, - 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef, 0x2a, 0xc0, 0x52, 0x33, 0xa0}; + uint8_t pkt[] = {0x34, 0x34, 0x0, 0x1b, 0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, + 0x8f, 0xf9, 0x3, 0xea, 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, + 0xe2, 0xc9, 0x9c, 0x20, 0x38, 0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, + 0xcd, 0x9b, 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1372,38 +1412,43 @@ TEST(Publish311QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x52, 0x33, 0xa0}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, 0x3, 0xea, + 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, + 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10944); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(packet_id, 8248); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "V\195\159\242\185\ENQ\214\147\DLE\144\144,r\245\SO\237n\143\204\SUB\229\230", _pubPktID = 0, _pubBody = -// "\171\131\154", _pubProps = []} +// "\146;?\158\252\\a5\133\233\144\&9O\159\231\133\240}\DC1\200\&9\154a%\176Y", _pubPktID = 0, _pubBody = +// "\173\221\&2\157\129qMv\218\&6\216\165J\tp\242\205\&2\194t\243\161\STX?", _pubProps = []} TEST(Publish311QCTest, Encode25) { - uint8_t pkt[] = {0x39, 0x1b, 0x0, 0x16, 0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, - 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6, 0xab, 0x83, 0x9a}; - uint8_t topic_bytes[] = {0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, - 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x34, 0x0, 0x1a, 0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, + 0x90, 0x39, 0x4f, 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, + 0xb0, 0x59, 0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, + 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; + uint8_t topic_bytes[] = {0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, 0x90, 0x39, 0x4f, + 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, 0xb0, 0x59}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xab, 0x83, 0x9a}; + uint8_t msg_bytes[] = {0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, + 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 24; lwmqtt_property_t propslist[] = {}; @@ -1416,11 +1461,13 @@ TEST(Publish311QCTest, Encode25) { } // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "V\195\159\242\185\ENQ\214\147\DLE\144\144,r\245\SO\237n\143\204\SUB\229\230", _pubPktID = 0, _pubBody = -// "\171\131\154", _pubProps = []} +// "\146;?\158\252\\a5\133\233\144\&9O\159\231\133\240}\DC1\200\&9\154a%\176Y", _pubPktID = 0, _pubBody = +// "\173\221\&2\157\129qMv\218\&6\216\165J\tp\242\205\&2\194t\243\161\STX?", _pubProps = []} TEST(Publish311QCTest, Decode25) { - uint8_t pkt[] = {0x39, 0x1b, 0x0, 0x16, 0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, - 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6, 0xab, 0x83, 0x9a}; + uint8_t pkt[] = {0x39, 0x34, 0x0, 0x1a, 0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, + 0x90, 0x39, 0x4f, 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, + 0xb0, 0x59, 0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, + 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1429,59 +1476,59 @@ TEST(Publish311QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, - 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xab, 0x83, 0x9a}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, 0x90, 0x39, 0x4f, + 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, 0xb0, 0x59}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, + 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ",\129\b\199\224\197\191\196~\130\211\129B\164\238\NAK\138I\201f\163", _pubPktID = 2253, _pubBody = -// "|\153\171Y,OB.\132d\186cm;\DC4+\153\209y\t\128", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "?X\254\SIJ/\199\240\153I\171-\227\213\191\205\b\202\247\252\a\196\136\150\215K\\R", _pubPktID = 0, _pubBody = +// "\167\192W\238\177\207\SO\148\212\134\&6\145\223N\168", _pubProps = []} TEST(Publish311QCTest, Encode26) { - uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x15, 0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, 0x81, - 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3, 0x8, 0xcd, 0x7c, 0x99, 0xab, 0x59, 0x2c, - 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; - uint8_t topic_bytes[] = {0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, - 0x81, 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x2d, 0x0, 0x1c, 0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, + 0xe3, 0xd5, 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52, + 0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; + uint8_t topic_bytes[] = {0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, 0xe3, 0xd5, + 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, - 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 2253, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ",\129\b\199\224\197\191\196~\130\211\129B\164\238\NAK\138I\201f\163", _pubPktID = 2253, _pubBody = -// "|\153\171Y,OB.\132d\186cm;\DC4+\153\209y\t\128", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "?X\254\SIJ/\199\240\153I\171-\227\213\191\205\b\202\247\252\a\196\136\150\215K\\R", _pubPktID = 0, _pubBody = +// "\167\192W\238\177\207\SO\148\212\134\&6\145\223N\168", _pubProps = []} TEST(Publish311QCTest, Decode26) { - uint8_t pkt[] = {0x34, 0x2e, 0x0, 0x15, 0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, 0x81, - 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3, 0x8, 0xcd, 0x7c, 0x99, 0xab, 0x59, 0x2c, - 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; + uint8_t pkt[] = {0x31, 0x2d, 0x0, 0x1c, 0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, + 0xe3, 0xd5, 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52, + 0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1490,60 +1537,54 @@ TEST(Publish311QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, - 0x81, 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, - 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, 0xe3, 0xd5, + 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2253); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\255\138\160\SO}\145\231=\154\241iR\219\FS\151\240}B\141(\214", _pubPktID = 10836, _pubBody = "\249\144\&7 -// ,\DC2\216\146r\155\161\224l\238\165\FS\245", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\144\167\130\179A", _pubPktID = 0, +// _pubBody = "\148\134\185\213\184\233\187\157\198\233\181\148_\215\n$@\169\251\210\184\f", _pubProps = []} TEST(Publish311QCTest, Encode27) { - uint8_t pkt[] = {0x3a, 0x2a, 0x0, 0x15, 0xff, 0x8a, 0xa0, 0xe, 0x7d, 0x91, 0xe7, 0x3d, 0x9a, 0xf1, 0x69, - 0x52, 0xdb, 0x1c, 0x97, 0xf0, 0x7d, 0x42, 0x8d, 0x28, 0xd6, 0x2a, 0x54, 0xf9, 0x90, 0x37, - 0x20, 0x2c, 0x12, 0xd8, 0x92, 0x72, 0x9b, 0xa1, 0xe0, 0x6c, 0xee, 0xa5, 0x1c, 0xf5}; - uint8_t topic_bytes[] = {0xff, 0x8a, 0xa0, 0xe, 0x7d, 0x91, 0xe7, 0x3d, 0x9a, 0xf1, 0x69, - 0x52, 0xdb, 0x1c, 0x97, 0xf0, 0x7d, 0x42, 0x8d, 0x28, 0xd6}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x5, 0x90, 0xa7, 0x82, 0xb3, 0x41, 0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, + 0x9d, 0xc6, 0xe9, 0xb5, 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; + uint8_t topic_bytes[] = {0x90, 0xa7, 0x82, 0xb3, 0x41}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xf9, 0x90, 0x37, 0x20, 0x2c, 0x12, 0xd8, 0x92, 0x72, - 0x9b, 0xa1, 0xe0, 0x6c, 0xee, 0xa5, 0x1c, 0xf5}; + uint8_t msg_bytes[] = {0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, + 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10836, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\255\138\160\SO}\145\231=\154\241iR\219\FS\151\240}B\141(\214", _pubPktID = 10836, _pubBody = "\249\144\&7 -// ,\DC2\216\146r\155\161\224l\238\165\FS\245", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\144\167\130\179A", _pubPktID = 0, +// _pubBody = "\148\134\185\213\184\233\187\157\198\233\181\148_\215\n$@\169\251\210\184\f", _pubProps = []} TEST(Publish311QCTest, Decode27) { - uint8_t pkt[] = {0x3a, 0x2a, 0x0, 0x15, 0xff, 0x8a, 0xa0, 0xe, 0x7d, 0x91, 0xe7, 0x3d, 0x9a, 0xf1, 0x69, - 0x52, 0xdb, 0x1c, 0x97, 0xf0, 0x7d, 0x42, 0x8d, 0x28, 0xd6, 0x2a, 0x54, 0xf9, 0x90, 0x37, - 0x20, 0x2c, 0x12, 0xd8, 0x92, 0x72, 0x9b, 0xa1, 0xe0, 0x6c, 0xee, 0xa5, 0x1c, 0xf5}; + uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x5, 0x90, 0xa7, 0x82, 0xb3, 0x41, 0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, + 0x9d, 0xc6, 0xe9, 0xb5, 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1552,43 +1593,36 @@ TEST(Publish311QCTest, Decode27) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xff, 0x8a, 0xa0, 0xe, 0x7d, 0x91, 0xe7, 0x3d, 0x9a, 0xf1, 0x69, - 0x52, 0xdb, 0x1c, 0x97, 0xf0, 0x7d, 0x42, 0x8d, 0x28, 0xd6}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf9, 0x90, 0x37, 0x20, 0x2c, 0x12, 0xd8, 0x92, 0x72, - 0x9b, 0xa1, 0xe0, 0x6c, 0xee, 0xa5, 0x1c, 0xf5}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x90, 0xa7, 0x82, 0xb3, 0x41}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, + 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10836); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\203\137\174H\204\220\160\&8\f+bXR\239\199\DC1\186\254\249\218\179y\210~\185\250\166\248", _pubPktID = 0, _pubBody = -// "\136\142{\DC4\\\154]/:\184\246N\DC28\204\&2C\f@\172\199\237\162)]W\186\180", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\187\249\143~(e\135", _pubProps = []} TEST(Publish311QCTest, Encode28) { - uint8_t pkt[] = {0x38, 0x3a, 0x0, 0x1c, 0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, - 0x58, 0x52, 0xef, 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, - 0xa6, 0xf8, 0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, - 0x38, 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; - uint8_t topic_bytes[] = {0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, 0xef, - 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x9, 0x0, 0x0, 0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, - 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; + msg.retained = true; + uint8_t msg_bytes[] = {0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 7; lwmqtt_property_t propslist[] = {}; @@ -1600,14 +1634,10 @@ TEST(Publish311QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\203\137\174H\204\220\160\&8\f+bXR\239\199\DC1\186\254\249\218\179y\210~\185\250\166\248", _pubPktID = 0, _pubBody = -// "\136\142{\DC4\\\154]/:\184\246N\DC28\204\&2C\f@\172\199\237\162)]W\186\180", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\187\249\143~(e\135", _pubProps = []} TEST(Publish311QCTest, Decode28) { - uint8_t pkt[] = {0x38, 0x3a, 0x0, 0x1c, 0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, - 0x58, 0x52, 0xef, 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, - 0xa6, 0xf8, 0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, - 0x38, 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; + uint8_t pkt[] = {0x39, 0x9, 0x0, 0x0, 0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1616,58 +1646,60 @@ TEST(Publish311QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, 0xef, - 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, - 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "dU\158\136\251\148W][8D\138i\232?$", -// _pubPktID = 0, _pubBody = "'\136\162\SO\255\RS\205q\229\ACK\148\ETX\129rJ\DC2Y3\165a11\180\247", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "h\137\169\166b`\193\RS\133\235I\188\167\&9\DC1\161uN\176\SOf\ACK-O\194\vo", _pubPktID = 7918, _pubBody = +// "G\142\SYN\154\171\162\185\ENQg\129\240\186 \199\202{\CAN\233\v^\170", _pubProps = []} TEST(Publish311QCTest, Encode29) { - uint8_t pkt[] = {0x39, 0x2a, 0x0, 0x10, 0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, 0x5b, 0x38, 0x44, - 0x8a, 0x69, 0xe8, 0x3f, 0x24, 0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, - 0x94, 0x3, 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; - uint8_t topic_bytes[] = {0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, - 0x5b, 0x38, 0x44, 0x8a, 0x69, 0xe8, 0x3f, 0x24}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x34, 0x0, 0x1b, 0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, + 0x49, 0xbc, 0xa7, 0x39, 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, + 0xc2, 0xb, 0x6f, 0x1e, 0xee, 0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, + 0x81, 0xf0, 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; + uint8_t topic_bytes[] = {0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, + 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0xc2, 0xb, 0x6f}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, 0x94, 0x3, - 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, + 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7918, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "dU\158\136\251\148W][8D\138i\232?$", -// _pubPktID = 0, _pubBody = "'\136\162\SO\255\RS\205q\229\ACK\148\ETX\129rJ\DC2Y3\165a11\180\247", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "h\137\169\166b`\193\RS\133\235I\188\167\&9\DC1\161uN\176\SOf\ACK-O\194\vo", _pubPktID = 7918, _pubBody = +// "G\142\SYN\154\171\162\185\ENQg\129\240\186 \199\202{\CAN\233\v^\170", _pubProps = []} TEST(Publish311QCTest, Decode29) { - uint8_t pkt[] = {0x39, 0x2a, 0x0, 0x10, 0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, 0x5b, 0x38, 0x44, - 0x8a, 0x69, 0xe8, 0x3f, 0x24, 0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, - 0x94, 0x3, 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; + uint8_t pkt[] = {0x3a, 0x34, 0x0, 0x1b, 0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, + 0x49, 0xbc, 0xa7, 0x39, 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, + 0xc2, 0xb, 0x6f, 0x1e, 0xee, 0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, + 0x81, 0xf0, 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1676,59 +1708,54 @@ TEST(Publish311QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, - 0x5b, 0x38, 0x44, 0x8a, 0x69, 0xe8, 0x3f, 0x24}; - lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, 0x94, 0x3, - 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, + 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0xc2, 0xb, 0x6f}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, + 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7918); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\173\207\249\USrJ\214L\ENQAT\140JUG\ESC\FS\165\202\218\206\DEL\142\250'\167s\139", _pubPktID = 24516, _pubBody = "", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "k\r\250c\140\225\149\144@\133", +// _pubPktID = 0, _pubBody = "',/I\RSD\195\229\202", _pubProps = []} TEST(Publish311QCTest, Encode30) { - uint8_t pkt[] = {0x3d, 0x20, 0x0, 0x1c, 0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, - 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, - 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b, 0x5f, 0xc4}; - uint8_t topic_bytes[] = {0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, - 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x15, 0x0, 0xa, 0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, + 0x40, 0x85, 0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; + uint8_t topic_bytes[] = {0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, 0x40, 0x85}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 9; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 24516, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\173\207\249\USrJ\214L\ENQAT\140JUG\ESC\FS\165\202\218\206\DEL\142\250'\167s\139", _pubPktID = 24516, _pubBody = "", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "k\r\250c\140\225\149\144@\133", +// _pubPktID = 0, _pubBody = "',/I\RSD\195\229\202", _pubProps = []} TEST(Publish311QCTest, Decode30) { - uint8_t pkt[] = {0x3d, 0x20, 0x0, 0x1c, 0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, - 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, - 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b, 0x5f, 0xc4}; + uint8_t pkt[] = {0x30, 0x15, 0x0, 0xa, 0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, + 0x40, 0x85, 0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1737,128 +1764,72 @@ TEST(Publish311QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, - 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 24516); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + uint8_t exp_topic_bytes[] = {0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, 0x40, 0x85}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\240\228VZ\144!o", _pubPktID = -// 2440, _pubBody = "H\151\243\172\184\224\192", _pubProps = [PropPayloadFormatIndicator -// 31,PropRequestProblemInformation 225,PropServerReference -// "\ETB\ESC\156\241}\170\249\160\205\175",PropMessageExpiryInterval 13969,PropSubscriptionIdentifier -// 5,PropRequestResponseInformation 97,PropWillDelayInterval 13658,PropContentType -// "_\133{qb.!\b\"\160\SYNd",PropUserProperty "\251\&6\235#" "x\138\155\155\211 -// \166\135\156\239\255v\SOHz\a,'\154ve\219\DC384\b\239\149\161\DC2",PropSubscriptionIdentifierAvailable -// 165,PropSubscriptionIdentifierAvailable 68,PropMaximumPacketSize 21324,PropRequestProblemInformation -// 81,PropWillDelayInterval 21670,PropResponseInformation -// "\144QB\229f\151.d\232\a\164\bn\240\157O\177\227\211\199\DC1\SYN\165\186\&7\135BM\163\247",PropSharedSubscriptionAvailable -// 243,PropServerKeepAlive 21923,PropSharedSubscriptionAvailable 48,PropSubscriptionIdentifier 0,PropTopicAliasMaximum -// 3371,PropAssignedClientIdentifier -// "\157\152\235\v\182\205h\SI\164\&8\193\207\215W\152\183\&7\152\EM8\131[.adoaa\208\185",PropServerKeepAlive 22147]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "#\234\SI\231\179\228\175!\174\132/\ETXg\US\r\STX\178\203\151\187\DC3C", _pubPktID = 3425, _pubBody = ":\171^C\n", +// _pubProps = [PropResponseTopic "^\255\219\212\234E\196\NAK\v\231\230\148(\SO\196'",PropResponseInformation +// "r{\180za]\185U\204\128\131@\226\&4b<",PropTopicAliasMaximum 25499]} TEST(Publish5QCTest, Encode1) { - uint8_t pkt[] = { - 0x3a, 0xca, 0x1, 0x0, 0x8, 0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f, 0x9, 0x88, 0xb5, 0x1, 0x1, 0x1f, - 0x17, 0xe1, 0x1c, 0x0, 0xa, 0x17, 0x1b, 0x9c, 0xf1, 0x7d, 0xaa, 0xf9, 0xa0, 0xcd, 0xaf, 0x2, 0x0, 0x0, 0x36, - 0x91, 0xb, 0x5, 0x19, 0x61, 0x18, 0x0, 0x0, 0x35, 0x5a, 0x3, 0x0, 0xc, 0x5f, 0x85, 0x7b, 0x71, 0x62, 0x2e, - 0x21, 0x8, 0x22, 0xa0, 0x16, 0x64, 0x26, 0x0, 0x4, 0xfb, 0x36, 0xeb, 0x23, 0x0, 0x1d, 0x78, 0x8a, 0x9b, 0x9b, - 0xd3, 0x20, 0xa6, 0x87, 0x9c, 0xef, 0xff, 0x76, 0x1, 0x7a, 0x7, 0x2c, 0x27, 0x9a, 0x76, 0x65, 0xdb, 0x13, 0x38, - 0x34, 0x8, 0xef, 0x95, 0xa1, 0x12, 0x29, 0xa5, 0x29, 0x44, 0x27, 0x0, 0x0, 0x53, 0x4c, 0x17, 0x51, 0x18, 0x0, - 0x0, 0x54, 0xa6, 0x1a, 0x0, 0x1e, 0x90, 0x51, 0x42, 0xe5, 0x66, 0x97, 0x2e, 0x64, 0xe8, 0x7, 0xa4, 0x8, 0x6e, - 0xf0, 0x9d, 0x4f, 0xb1, 0xe3, 0xd3, 0xc7, 0x11, 0x16, 0xa5, 0xba, 0x37, 0x87, 0x42, 0x4d, 0xa3, 0xf7, 0x2a, 0xf3, - 0x13, 0x55, 0xa3, 0x2a, 0x30, 0xb, 0x0, 0x22, 0xd, 0x2b, 0x12, 0x0, 0x1e, 0x9d, 0x98, 0xeb, 0xb, 0xb6, 0xcd, - 0x68, 0xf, 0xa4, 0x38, 0xc1, 0xcf, 0xd7, 0x57, 0x98, 0xb7, 0x37, 0x98, 0x19, 0x38, 0x83, 0x5b, 0x2e, 0x61, 0x64, - 0x6f, 0x61, 0x61, 0xd0, 0xb9, 0x13, 0x56, 0x83, 0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; - uint8_t topic_bytes[] = {0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x49, 0x0, 0x16, 0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, + 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43, 0xd, 0x61, 0x29, 0x8, + 0x0, 0x10, 0x5e, 0xff, 0xdb, 0xd4, 0xea, 0x45, 0xc4, 0x15, 0xb, 0xe7, 0xe6, 0x94, 0x28, + 0xe, 0xc4, 0x27, 0x1a, 0x0, 0x10, 0x72, 0x7b, 0xb4, 0x7a, 0x61, 0x5d, 0xb9, 0x55, 0xcc, + 0x80, 0x83, 0x40, 0xe2, 0x34, 0x62, 0x3c, 0x22, 0x63, 0x9b, 0x3a, 0xab, 0x5e, 0x43, 0xa}; + uint8_t topic_bytes[] = {0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, + 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; + uint8_t msg_bytes[] = {0x3a, 0xab, 0x5e, 0x43, 0xa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 5; - uint8_t bytesprops0[] = {0x17, 0x1b, 0x9c, 0xf1, 0x7d, 0xaa, 0xf9, 0xa0, 0xcd, 0xaf}; - uint8_t bytesprops1[] = {0x5f, 0x85, 0x7b, 0x71, 0x62, 0x2e, 0x21, 0x8, 0x22, 0xa0, 0x16, 0x64}; - uint8_t bytesprops3[] = {0x78, 0x8a, 0x9b, 0x9b, 0xd3, 0x20, 0xa6, 0x87, 0x9c, 0xef, 0xff, 0x76, 0x1, 0x7a, 0x7, - 0x2c, 0x27, 0x9a, 0x76, 0x65, 0xdb, 0x13, 0x38, 0x34, 0x8, 0xef, 0x95, 0xa1, 0x12}; - uint8_t bytesprops2[] = {0xfb, 0x36, 0xeb, 0x23}; - uint8_t bytesprops4[] = {0x90, 0x51, 0x42, 0xe5, 0x66, 0x97, 0x2e, 0x64, 0xe8, 0x7, 0xa4, 0x8, 0x6e, 0xf0, 0x9d, - 0x4f, 0xb1, 0xe3, 0xd3, 0xc7, 0x11, 0x16, 0xa5, 0xba, 0x37, 0x87, 0x42, 0x4d, 0xa3, 0xf7}; - uint8_t bytesprops5[] = {0x9d, 0x98, 0xeb, 0xb, 0xb6, 0xcd, 0x68, 0xf, 0xa4, 0x38, 0xc1, 0xcf, 0xd7, 0x57, 0x98, - 0xb7, 0x37, 0x98, 0x19, 0x38, 0x83, 0x5b, 0x2e, 0x61, 0x64, 0x6f, 0x61, 0x61, 0xd0, 0xb9}; + uint8_t bytesprops0[] = {0x5e, 0xff, 0xdb, 0xd4, 0xea, 0x45, 0xc4, 0x15, + 0xb, 0xe7, 0xe6, 0x94, 0x28, 0xe, 0xc4, 0x27}; + uint8_t bytesprops1[] = {0x72, 0x7b, 0xb4, 0x7a, 0x61, 0x5d, 0xb9, 0x55, + 0xcc, 0x80, 0x83, 0x40, 0xe2, 0x34, 0x62, 0x3c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13969}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13658}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops2}, .v = {29, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21324}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21670}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21923}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3371}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22147}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25499}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2440, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 3425, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\NAK\240\228VZ\144!o", _pubPktID = -// 2440, _pubBody = "H\151\243\172\184\224\192", _pubProps = [PropPayloadFormatIndicator -// 31,PropRequestProblemInformation 225,PropServerReference -// "\ETB\ESC\156\241}\170\249\160\205\175",PropMessageExpiryInterval 13969,PropSubscriptionIdentifier -// 5,PropRequestResponseInformation 97,PropWillDelayInterval 13658,PropContentType -// "_\133{qb.!\b\"\160\SYNd",PropUserProperty "\251\&6\235#" "x\138\155\155\211 -// \166\135\156\239\255v\SOHz\a,'\154ve\219\DC384\b\239\149\161\DC2",PropSubscriptionIdentifierAvailable -// 165,PropSubscriptionIdentifierAvailable 68,PropMaximumPacketSize 21324,PropRequestProblemInformation -// 81,PropWillDelayInterval 21670,PropResponseInformation -// "\144QB\229f\151.d\232\a\164\bn\240\157O\177\227\211\199\DC1\SYN\165\186\&7\135BM\163\247",PropSharedSubscriptionAvailable -// 243,PropServerKeepAlive 21923,PropSharedSubscriptionAvailable 48,PropSubscriptionIdentifier 0,PropTopicAliasMaximum -// 3371,PropAssignedClientIdentifier -// "\157\152\235\v\182\205h\SI\164\&8\193\207\215W\152\183\&7\152\EM8\131[.adoaa\208\185",PropServerKeepAlive 22147]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "#\234\SI\231\179\228\175!\174\132/\ETXg\US\r\STX\178\203\151\187\DC3C", _pubPktID = 3425, _pubBody = ":\171^C\n", +// _pubProps = [PropResponseTopic "^\255\219\212\234E\196\NAK\v\231\230\148(\SO\196'",PropResponseInformation +// "r{\180za]\185U\204\128\131@\226\&4b<",PropTopicAliasMaximum 25499]} TEST(Publish5QCTest, Decode1) { - uint8_t pkt[] = { - 0x3a, 0xca, 0x1, 0x0, 0x8, 0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f, 0x9, 0x88, 0xb5, 0x1, 0x1, 0x1f, - 0x17, 0xe1, 0x1c, 0x0, 0xa, 0x17, 0x1b, 0x9c, 0xf1, 0x7d, 0xaa, 0xf9, 0xa0, 0xcd, 0xaf, 0x2, 0x0, 0x0, 0x36, - 0x91, 0xb, 0x5, 0x19, 0x61, 0x18, 0x0, 0x0, 0x35, 0x5a, 0x3, 0x0, 0xc, 0x5f, 0x85, 0x7b, 0x71, 0x62, 0x2e, - 0x21, 0x8, 0x22, 0xa0, 0x16, 0x64, 0x26, 0x0, 0x4, 0xfb, 0x36, 0xeb, 0x23, 0x0, 0x1d, 0x78, 0x8a, 0x9b, 0x9b, - 0xd3, 0x20, 0xa6, 0x87, 0x9c, 0xef, 0xff, 0x76, 0x1, 0x7a, 0x7, 0x2c, 0x27, 0x9a, 0x76, 0x65, 0xdb, 0x13, 0x38, - 0x34, 0x8, 0xef, 0x95, 0xa1, 0x12, 0x29, 0xa5, 0x29, 0x44, 0x27, 0x0, 0x0, 0x53, 0x4c, 0x17, 0x51, 0x18, 0x0, - 0x0, 0x54, 0xa6, 0x1a, 0x0, 0x1e, 0x90, 0x51, 0x42, 0xe5, 0x66, 0x97, 0x2e, 0x64, 0xe8, 0x7, 0xa4, 0x8, 0x6e, - 0xf0, 0x9d, 0x4f, 0xb1, 0xe3, 0xd3, 0xc7, 0x11, 0x16, 0xa5, 0xba, 0x37, 0x87, 0x42, 0x4d, 0xa3, 0xf7, 0x2a, 0xf3, - 0x13, 0x55, 0xa3, 0x2a, 0x30, 0xb, 0x0, 0x22, 0xd, 0x2b, 0x12, 0x0, 0x1e, 0x9d, 0x98, 0xeb, 0xb, 0xb6, 0xcd, - 0x68, 0xf, 0xa4, 0x38, 0xc1, 0xcf, 0xd7, 0x57, 0x98, 0xb7, 0x37, 0x98, 0x19, 0x38, 0x83, 0x5b, 0x2e, 0x61, 0x64, - 0x6f, 0x61, 0x61, 0xd0, 0xb9, 0x13, 0x56, 0x83, 0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; + uint8_t pkt[] = {0x32, 0x49, 0x0, 0x16, 0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, + 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43, 0xd, 0x61, 0x29, 0x8, + 0x0, 0x10, 0x5e, 0xff, 0xdb, 0xd4, 0xea, 0x45, 0xc4, 0x15, 0xb, 0xe7, 0xe6, 0x94, 0x28, + 0xe, 0xc4, 0x27, 0x1a, 0x0, 0x10, 0x72, 0x7b, 0xb4, 0x7a, 0x61, 0x5d, 0xb9, 0x55, 0xcc, + 0x80, 0x83, 0x40, 0xe2, 0x34, 0x62, 0x3c, 0x22, 0x63, 0x9b, 0x3a, 0xab, 0x5e, 0x43, 0xa}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1867,90 +1838,106 @@ TEST(Publish5QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x15, 0xf0, 0xe4, 0x56, 0x5a, 0x90, 0x21, 0x6f}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x48, 0x97, 0xf3, 0xac, 0xb8, 0xe0, 0xc0}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, + 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x3a, 0xab, 0x5e, 0x43, 0xa}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2440); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(packet_id, 3425); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "}o\146\180\a\160\t\DC4T\196Oz)\145Z(2\146\157\n", _pubPktID = 8900, _pubBody = "GA\176\&8", _pubProps = -// [PropSessionExpiryInterval 1395,PropWillDelayInterval 2583,PropTopicAlias 12261,PropMessageExpiryInterval -// 2628,PropWildcardSubscriptionAvailable 174,PropRetainAvailable 239,PropMessageExpiryInterval -// 30086,PropMessageExpiryInterval 4735,PropRequestProblemInformation 181,PropSharedSubscriptionAvailable -// 244,PropUserProperty "\143\228Ymo\ENQ\210\NUL\251\150g\249W\205\239\175\236g" -// "\243\ENQz/\158\220\236\128\172\162\148(\226\245\223~\234\247\150\169\252\SI \CANhR\211"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\158\245\154\154\236\CAN_4\221\253\192\177\172<\236c\171]F_", _pubPktID = 29370, _pubBody = +// "z\217-\243HF\176HG\200\166\159", _pubProps = [PropMessageExpiryInterval 25413,PropSessionExpiryInterval +// 10036,PropUserProperty "\160\240\177G:gT_+\234\197\143\176\230]\\\159\205v" +// "T\255\ACK\SO\247\163\US\248\163\142H\ACK\148\210\162\189S\137\251\152\223Gb\248",PropSessionExpiryInterval +// 19732,PropTopicAlias 30295,PropUserProperty "\173,q\227\&4\EOT\209\173\193WT\208l\SIH\152\&3" +// "J\184@",PropRequestProblemInformation 107,PropAssignedClientIdentifier "\162 +// \157\181\172\ETB\245\220\225:\200\235O\241T",PropPayloadFormatIndicator 248,PropMessageExpiryInterval +// 24928,PropRequestResponseInformation 194,PropServerKeepAlive 208]} TEST(Publish5QCTest, Encode2) { - uint8_t pkt[] = {0x3d, 0x73, 0x0, 0x14, 0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, 0x4f, 0x7a, 0x29, - 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa, 0x22, 0xc4, 0x56, 0x11, 0x0, 0x0, 0x5, 0x73, 0x18, 0x0, - 0x0, 0xa, 0x17, 0x23, 0x2f, 0xe5, 0x2, 0x0, 0x0, 0xa, 0x44, 0x28, 0xae, 0x25, 0xef, 0x2, 0x0, - 0x0, 0x75, 0x86, 0x2, 0x0, 0x0, 0x12, 0x7f, 0x17, 0xb5, 0x2a, 0xf4, 0x26, 0x0, 0x12, 0x8f, 0xe4, - 0x59, 0x6d, 0x6f, 0x5, 0xd2, 0x0, 0xfb, 0x96, 0x67, 0xf9, 0x57, 0xcd, 0xef, 0xaf, 0xec, 0x67, 0x0, - 0x1b, 0xf3, 0x5, 0x7a, 0x2f, 0x9e, 0xdc, 0xec, 0x80, 0xac, 0xa2, 0x94, 0x28, 0xe2, 0xf5, 0xdf, 0x7e, - 0xea, 0xf7, 0x96, 0xa9, 0xfc, 0xf, 0x20, 0x18, 0x68, 0x52, 0xd3, 0x47, 0x41, 0xb0, 0x38}; - uint8_t topic_bytes[] = {0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 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, 0x18, 0x5f, 0x34, 0xdd, 0xfd, + 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f}; lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x47, 0x41, 0xb0, 0x38}; + msg.retained = false; + uint8_t msg_bytes[] = {0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 12; - uint8_t bytesprops1[] = {0xf3, 0x5, 0x7a, 0x2f, 0x9e, 0xdc, 0xec, 0x80, 0xac, 0xa2, 0x94, 0x28, 0xe2, 0xf5, - 0xdf, 0x7e, 0xea, 0xf7, 0x96, 0xa9, 0xfc, 0xf, 0x20, 0x18, 0x68, 0x52, 0xd3}; - uint8_t bytesprops0[] = {0x8f, 0xe4, 0x59, 0x6d, 0x6f, 0x5, 0xd2, 0x0, 0xfb, - 0x96, 0x67, 0xf9, 0x57, 0xcd, 0xef, 0xaf, 0xec, 0x67}; + uint8_t bytesprops1[] = {0x54, 0xff, 0x6, 0xe, 0xf7, 0xa3, 0x1f, 0xf8, 0xa3, 0x8e, 0x48, 0x6, + 0x94, 0xd2, 0xa2, 0xbd, 0x53, 0x89, 0xfb, 0x98, 0xdf, 0x47, 0x62, 0xf8}; + uint8_t bytesprops0[] = {0xa0, 0xf0, 0xb1, 0x47, 0x3a, 0x67, 0x54, 0x5f, 0x2b, 0xea, + 0xc5, 0x8f, 0xb0, 0xe6, 0x5d, 0x5c, 0x9f, 0xcd, 0x76}; + uint8_t bytesprops3[] = {0x4a, 0xb8, 0x40}; + uint8_t bytesprops2[] = {0xad, 0x2c, 0x71, 0xe3, 0x34, 0x4, 0xd1, 0xad, 0xc1, + 0x57, 0x54, 0xd0, 0x6c, 0xf, 0x48, 0x98, 0x33}; + uint8_t bytesprops4[] = {0xa2, 0x20, 0x9d, 0xb5, 0xac, 0x17, 0xf5, 0xdc, 0xe1, 0x3a, 0xc8, 0xeb, 0x4f, 0xf1, 0x54}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1395}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2583}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12261}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2628}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30086}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4735}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops0}, .v = {27, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25413}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10036}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19732}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30295}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops2}, .v = {3, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24928}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 208}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 8900, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29370, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "}o\146\180\a\160\t\DC4T\196Oz)\145Z(2\146\157\n", _pubPktID = 8900, _pubBody = "GA\176\&8", _pubProps = -// [PropSessionExpiryInterval 1395,PropWillDelayInterval 2583,PropTopicAlias 12261,PropMessageExpiryInterval -// 2628,PropWildcardSubscriptionAvailable 174,PropRetainAvailable 239,PropMessageExpiryInterval -// 30086,PropMessageExpiryInterval 4735,PropRequestProblemInformation 181,PropSharedSubscriptionAvailable -// 244,PropUserProperty "\143\228Ymo\ENQ\210\NUL\251\150g\249W\205\239\175\236g" -// "\243\ENQz/\158\220\236\128\172\162\148(\226\245\223~\234\247\150\169\252\SI \CANhR\211"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\158\245\154\154\236\CAN_4\221\253\192\177\172<\236c\171]F_", _pubPktID = 29370, _pubBody = +// "z\217-\243HF\176HG\200\166\159", _pubProps = [PropMessageExpiryInterval 25413,PropSessionExpiryInterval +// 10036,PropUserProperty "\160\240\177G:gT_+\234\197\143\176\230]\\\159\205v" +// "T\255\ACK\SO\247\163\US\248\163\142H\ACK\148\210\162\189S\137\251\152\223Gb\248",PropSessionExpiryInterval +// 19732,PropTopicAlias 30295,PropUserProperty "\173,q\227\&4\EOT\209\173\193WT\208l\SIH\152\&3" +// "J\184@",PropRequestProblemInformation 107,PropAssignedClientIdentifier "\162 +// \157\181\172\ETB\245\220\225:\200\235O\241T",PropPayloadFormatIndicator 248,PropMessageExpiryInterval +// 24928,PropRequestResponseInformation 194,PropServerKeepAlive 208]} TEST(Publish5QCTest, Decode2) { - uint8_t pkt[] = {0x3d, 0x73, 0x0, 0x14, 0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, 0x4f, 0x7a, 0x29, - 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa, 0x22, 0xc4, 0x56, 0x11, 0x0, 0x0, 0x5, 0x73, 0x18, 0x0, - 0x0, 0xa, 0x17, 0x23, 0x2f, 0xe5, 0x2, 0x0, 0x0, 0xa, 0x44, 0x28, 0xae, 0x25, 0xef, 0x2, 0x0, - 0x0, 0x75, 0x86, 0x2, 0x0, 0x0, 0x12, 0x7f, 0x17, 0xb5, 0x2a, 0xf4, 0x26, 0x0, 0x12, 0x8f, 0xe4, - 0x59, 0x6d, 0x6f, 0x5, 0xd2, 0x0, 0xfb, 0x96, 0x67, 0xf9, 0x57, 0xcd, 0xef, 0xaf, 0xec, 0x67, 0x0, - 0x1b, 0xf3, 0x5, 0x7a, 0x2f, 0x9e, 0xdc, 0xec, 0x80, 0xac, 0xa2, 0x94, 0x28, 0xe2, 0xf5, 0xdf, 0x7e, - 0xea, 0xf7, 0x96, 0xa9, 0xfc, 0xf, 0x20, 0x18, 0x68, 0x52, 0xd3, 0x47, 0x41, 0xb0, 0x38}; + uint8_t pkt[] = {0x3c, 0xa0, 0x1, 0x0, 0x14, 0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, 0xfd, 0xc0, 0xb1, + 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f, 0x72, 0xba, 0x7b, 0x2, 0x0, 0x0, 0x63, 0x45, 0x11, + 0x0, 0x0, 0x27, 0x34, 0x26, 0x0, 0x13, 0xa0, 0xf0, 0xb1, 0x47, 0x3a, 0x67, 0x54, 0x5f, 0x2b, 0xea, + 0xc5, 0x8f, 0xb0, 0xe6, 0x5d, 0x5c, 0x9f, 0xcd, 0x76, 0x0, 0x18, 0x54, 0xff, 0x6, 0xe, 0xf7, 0xa3, + 0x1f, 0xf8, 0xa3, 0x8e, 0x48, 0x6, 0x94, 0xd2, 0xa2, 0xbd, 0x53, 0x89, 0xfb, 0x98, 0xdf, 0x47, 0x62, + 0xf8, 0x11, 0x0, 0x0, 0x4d, 0x14, 0x23, 0x76, 0x57, 0x26, 0x0, 0x11, 0xad, 0x2c, 0x71, 0xe3, 0x34, + 0x4, 0xd1, 0xad, 0xc1, 0x57, 0x54, 0xd0, 0x6c, 0xf, 0x48, 0x98, 0x33, 0x0, 0x3, 0x4a, 0xb8, 0x40, + 0x17, 0x6b, 0x12, 0x0, 0xf, 0xa2, 0x20, 0x9d, 0xb5, 0xac, 0x17, 0xf5, 0xdc, 0xe1, 0x3a, 0xc8, 0xeb, + 0x4f, 0xf1, 0x54, 0x1, 0xf8, 0x2, 0x0, 0x0, 0x61, 0x60, 0x19, 0xc2, 0x13, 0x0, 0xd0, 0x7a, 0xd9, + 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1959,68 +1946,108 @@ TEST(Publish5QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7d, 0x6f, 0x92, 0xb4, 0x7, 0xa0, 0x9, 0x14, 0x54, 0xc4, - 0x4f, 0x7a, 0x29, 0x91, 0x5a, 0x28, 0x32, 0x92, 0x9d, 0xa}; + uint8_t exp_topic_bytes[] = {0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, 0xfd, + 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f}; lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x47, 0x41, 0xb0, 0x38}; - lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + uint8_t exp_body_bytes[] = {0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 8900); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 29370); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 4); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\151\STXH3\208\EM\137z\b\129j\156\252", _pubPktID = 0, _pubBody = "\202\152NR\SI_", _pubProps = -// [PropMessageExpiryInterval 10144,PropSharedSubscriptionAvailable 254,PropReasonString -// "\SOH?\193\190X\175\185\"+\242\&7\147V\172C\214\183\SOH\DC4\255\b\227\148o\135(",PropSubscriptionIdentifier -// 3,PropAssignedClientIdentifier "\162\193\236{\188\238\SYNjk)\156\205\CAN\SUB\215",PropRetainAvailable -// 85,PropServerReference "\253\161&*'\DC1\167\188T6\DC3\249",PropSubscriptionIdentifierAvailable 139,PropTopicAlias -// 22556,PropAuthenticationData "\196\190\222.S\RS\129y9\209\CAN\168\&5"]} +// "uh{\218\a\247\172\148\ESC\ETB\187\138\184\255\vX\180\DC1\131\&0\219\216\SI\147\203\ETX)\218", _pubPktID = 0, +// _pubBody = "\207\DC1\209\235\144\141K\255\225\177/B\DC1\DC3\175\144", _pubProps = [PropReasonString +// "\213>\211\224^0\247\164\133Z\154(\198F?\240\167\&59\t\ETBj",PropResponseInformation +// "\211\147f\217\197\253\163U\135\&2",PropSharedSubscriptionAvailable 175,PropCorrelationData +// "r\242\151\207\149\ACKg\241\&3\159\138\171X\SYNA;\nM\223+",PropMessageExpiryInterval 22620,PropServerReference +// "@",PropCorrelationData +// "\153\193\147\164\207}\FSQo\227\224XA\n\206\231\170:\211O\189Z\180",PropRequestResponseInformation +// 223,PropUserProperty "\ENQ\246\&6@\143\RSgP\247\134\SIDH\243\f\DC2[\194\191\240gB\ACK\194\239y\173\230!\166" +// "\134\DELM\195\204\157\SUBy\SO)\241Lp3\GS\199m\129",PropSharedSubscriptionAvailable 20,PropReceiveMaximum +// 15739,PropTopicAliasMaximum 30129,PropMessageExpiryInterval 29406,PropCorrelationData +// "n\DC4\NAK\SOH",PropRetainAvailable 248,PropServerKeepAlive 22227,PropSessionExpiryInterval 18366,PropResponseTopic +// "jY\228\148\244\212\218h\157/'M\215\152\n\188\200\208z1",PropTopicAlias 22179,PropPayloadFormatIndicator +// 236,PropTopicAlias 16075,PropServerKeepAlive 12101]} TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = {0x38, 0x74, 0x0, 0xd, 0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc, - 0x5e, 0x2, 0x0, 0x0, 0x27, 0xa0, 0x2a, 0xfe, 0x1f, 0x0, 0x1a, 0x1, 0x3f, 0xc1, 0xbe, 0x58, 0xaf, - 0xb9, 0x22, 0x2b, 0xf2, 0x37, 0x93, 0x56, 0xac, 0x43, 0xd6, 0xb7, 0x1, 0x14, 0xff, 0x8, 0xe3, 0x94, - 0x6f, 0x87, 0x28, 0xb, 0x3, 0x12, 0x0, 0xf, 0xa2, 0xc1, 0xec, 0x7b, 0xbc, 0xee, 0x16, 0x6a, 0x6b, - 0x29, 0x9c, 0xcd, 0x18, 0x1a, 0xd7, 0x25, 0x55, 0x1c, 0x0, 0xc, 0xfd, 0xa1, 0x26, 0x2a, 0x27, 0x11, - 0xa7, 0xbc, 0x54, 0x36, 0x13, 0xf9, 0x29, 0x8b, 0x23, 0x58, 0x1c, 0x16, 0x0, 0xd, 0xc4, 0xbe, 0xde, - 0x2e, 0x53, 0x1e, 0x81, 0x79, 0x39, 0xd1, 0x18, 0xa8, 0x35, 0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; - uint8_t topic_bytes[] = {0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x89, 0x2, 0x0, 0x1c, 0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, + 0xb8, 0xff, 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda, 0xd9, + 0x1, 0x1f, 0x0, 0x16, 0xd5, 0x3e, 0xd3, 0xe0, 0x5e, 0x30, 0xf7, 0xa4, 0x85, 0x5a, 0x9a, 0x28, 0xc6, + 0x46, 0x3f, 0xf0, 0xa7, 0x35, 0x39, 0x9, 0x17, 0x6a, 0x1a, 0x0, 0xa, 0xd3, 0x93, 0x66, 0xd9, 0xc5, + 0xfd, 0xa3, 0x55, 0x87, 0x32, 0x2a, 0xaf, 0x9, 0x0, 0x14, 0x72, 0xf2, 0x97, 0xcf, 0x95, 0x6, 0x67, + 0xf1, 0x33, 0x9f, 0x8a, 0xab, 0x58, 0x16, 0x41, 0x3b, 0xa, 0x4d, 0xdf, 0x2b, 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xff, + 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; + uint8_t msg_bytes[] = {0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, + 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 16; - uint8_t bytesprops0[] = {0x1, 0x3f, 0xc1, 0xbe, 0x58, 0xaf, 0xb9, 0x22, 0x2b, 0xf2, 0x37, 0x93, 0x56, - 0xac, 0x43, 0xd6, 0xb7, 0x1, 0x14, 0xff, 0x8, 0xe3, 0x94, 0x6f, 0x87, 0x28}; - uint8_t bytesprops1[] = {0xa2, 0xc1, 0xec, 0x7b, 0xbc, 0xee, 0x16, 0x6a, 0x6b, 0x29, 0x9c, 0xcd, 0x18, 0x1a, 0xd7}; - uint8_t bytesprops2[] = {0xfd, 0xa1, 0x26, 0x2a, 0x27, 0x11, 0xa7, 0xbc, 0x54, 0x36, 0x13, 0xf9}; - uint8_t bytesprops3[] = {0xc4, 0xbe, 0xde, 0x2e, 0x53, 0x1e, 0x81, 0x79, 0x39, 0xd1, 0x18, 0xa8, 0x35}; + uint8_t bytesprops0[] = {0xd5, 0x3e, 0xd3, 0xe0, 0x5e, 0x30, 0xf7, 0xa4, 0x85, 0x5a, 0x9a, + 0x28, 0xc6, 0x46, 0x3f, 0xf0, 0xa7, 0x35, 0x39, 0x9, 0x17, 0x6a}; + uint8_t bytesprops1[] = {0xd3, 0x93, 0x66, 0xd9, 0xc5, 0xfd, 0xa3, 0x55, 0x87, 0x32}; + uint8_t bytesprops2[] = {0x72, 0xf2, 0x97, 0xcf, 0x95, 0x6, 0x67, 0xf1, 0x33, 0x9f, + 0x8a, 0xab, 0x58, 0x16, 0x41, 0x3b, 0xa, 0x4d, 0xdf, 0x2b}; + uint8_t bytesprops3[] = {0x40}; + uint8_t bytesprops4[] = {0x99, 0xc1, 0x93, 0xa4, 0xcf, 0x7d, 0x1c, 0x51, 0x6f, 0xe3, 0xe0, 0x58, + 0x41, 0xa, 0xce, 0xe7, 0xaa, 0x3a, 0xd3, 0x4f, 0xbd, 0x5a, 0xb4}; + uint8_t bytesprops6[] = {0x86, 0x7f, 0x4d, 0xc3, 0xcc, 0x9d, 0x1a, 0x79, 0xe, + 0x29, 0xf1, 0x4c, 0x70, 0x33, 0x1d, 0xc7, 0x6d, 0x81}; + uint8_t bytesprops5[] = {0x5, 0xf6, 0x36, 0x40, 0x8f, 0x1e, 0x67, 0x50, 0xf7, 0x86, 0xf, 0x44, 0x48, 0xf3, 0xc, + 0x12, 0x5b, 0xc2, 0xbf, 0xf0, 0x67, 0x42, 0x6, 0xc2, 0xef, 0x79, 0xad, 0xe6, 0x21, 0xa6}; + uint8_t bytesprops7[] = {0x6e, 0x14, 0x15, 0x1}; + uint8_t bytesprops8[] = {0x6a, 0x59, 0xe4, 0x94, 0xf4, 0xd4, 0xda, 0x68, 0x9d, 0x2f, + 0x27, 0x4d, 0xd7, 0x98, 0xa, 0xbc, 0xc8, 0xd0, 0x7a, 0x31}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10144}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22556}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22620}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops5}, .v = {18, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15739}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30129}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29406}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22227}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18366}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22179}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16075}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12101}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); @@ -2029,20 +2056,36 @@ TEST(Publish5QCTest, Encode3) { } // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\151\STXH3\208\EM\137z\b\129j\156\252", _pubPktID = 0, _pubBody = "\202\152NR\SI_", _pubProps = -// [PropMessageExpiryInterval 10144,PropSharedSubscriptionAvailable 254,PropReasonString -// "\SOH?\193\190X\175\185\"+\242\&7\147V\172C\214\183\SOH\DC4\255\b\227\148o\135(",PropSubscriptionIdentifier -// 3,PropAssignedClientIdentifier "\162\193\236{\188\238\SYNjk)\156\205\CAN\SUB\215",PropRetainAvailable -// 85,PropServerReference "\253\161&*'\DC1\167\188T6\DC3\249",PropSubscriptionIdentifierAvailable 139,PropTopicAlias -// 22556,PropAuthenticationData "\196\190\222.S\RS\129y9\209\CAN\168\&5"]} +// "uh{\218\a\247\172\148\ESC\ETB\187\138\184\255\vX\180\DC1\131\&0\219\216\SI\147\203\ETX)\218", _pubPktID = 0, +// _pubBody = "\207\DC1\209\235\144\141K\255\225\177/B\DC1\DC3\175\144", _pubProps = [PropReasonString +// "\213>\211\224^0\247\164\133Z\154(\198F?\240\167\&59\t\ETBj",PropResponseInformation +// "\211\147f\217\197\253\163U\135\&2",PropSharedSubscriptionAvailable 175,PropCorrelationData +// "r\242\151\207\149\ACKg\241\&3\159\138\171X\SYNA;\nM\223+",PropMessageExpiryInterval 22620,PropServerReference +// "@",PropCorrelationData +// "\153\193\147\164\207}\FSQo\227\224XA\n\206\231\170:\211O\189Z\180",PropRequestResponseInformation +// 223,PropUserProperty "\ENQ\246\&6@\143\RSgP\247\134\SIDH\243\f\DC2[\194\191\240gB\ACK\194\239y\173\230!\166" +// "\134\DELM\195\204\157\SUBy\SO)\241Lp3\GS\199m\129",PropSharedSubscriptionAvailable 20,PropReceiveMaximum +// 15739,PropTopicAliasMaximum 30129,PropMessageExpiryInterval 29406,PropCorrelationData +// "n\DC4\NAK\SOH",PropRetainAvailable 248,PropServerKeepAlive 22227,PropSessionExpiryInterval 18366,PropResponseTopic +// "jY\228\148\244\212\218h\157/'M\215\152\n\188\200\208z1",PropTopicAlias 22179,PropPayloadFormatIndicator +// 236,PropTopicAlias 16075,PropServerKeepAlive 12101]} TEST(Publish5QCTest, Decode3) { - uint8_t pkt[] = {0x38, 0x74, 0x0, 0xd, 0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc, - 0x5e, 0x2, 0x0, 0x0, 0x27, 0xa0, 0x2a, 0xfe, 0x1f, 0x0, 0x1a, 0x1, 0x3f, 0xc1, 0xbe, 0x58, 0xaf, - 0xb9, 0x22, 0x2b, 0xf2, 0x37, 0x93, 0x56, 0xac, 0x43, 0xd6, 0xb7, 0x1, 0x14, 0xff, 0x8, 0xe3, 0x94, - 0x6f, 0x87, 0x28, 0xb, 0x3, 0x12, 0x0, 0xf, 0xa2, 0xc1, 0xec, 0x7b, 0xbc, 0xee, 0x16, 0x6a, 0x6b, - 0x29, 0x9c, 0xcd, 0x18, 0x1a, 0xd7, 0x25, 0x55, 0x1c, 0x0, 0xc, 0xfd, 0xa1, 0x26, 0x2a, 0x27, 0x11, - 0xa7, 0xbc, 0x54, 0x36, 0x13, 0xf9, 0x29, 0x8b, 0x23, 0x58, 0x1c, 0x16, 0x0, 0xd, 0xc4, 0xbe, 0xde, - 0x2e, 0x53, 0x1e, 0x81, 0x79, 0x39, 0xd1, 0x18, 0xa8, 0x35, 0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; + uint8_t pkt[] = {0x38, 0x89, 0x2, 0x0, 0x1c, 0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94,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 0x0, 0x72, 0xde, 0x9, 0x0, 0x4, + 0x6e, 0x14, 0x15, 0x1, 0x25, 0xf8, 0x13, 0x56, 0xd3, 0x11, 0x0, 0x0, 0x47, 0xbe, 0x8, 0x0, 0x14, + 0x6a, 0x59, 0xe4, 0x94, 0xf4, 0xd4, 0xda, 0x68, 0x9d, 0x2f, 0x27, 0x4d, 0xd7, 0x98, 0xa, 0xbc, 0xc8, + 0xd0, 0x7a, 0x31, 0x23, 0x56, 0xa3, 0x1, 0xec, 0x23, 0x3e, 0xcb, 0x13, 0x2f, 0x45, 0xcf, 0x11, 0xd1, + 0xeb, 0x90, 0x8d, 0x4b, 0xff, 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2051,102 +2094,98 @@ TEST(Publish5QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x97, 0x2, 0x48, 0x33, 0xd0, 0x19, 0x89, 0x7a, 0x8, 0x81, 0x6a, 0x9c, 0xfc}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xca, 0x98, 0x4e, 0x52, 0xf, 0x5f}; - lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, 0xb8, 0xff, + 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, + 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 6); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "<\v\SYN\154J\242", _pubPktID = -// 10596, _pubBody = "\187\150\168\193Z\202\188\STX?", _pubProps = [PropAssignedClientIdentifier -// "\223\a\220\EOTC\"",PropRequestResponseInformation 239,PropAuthenticationData -// "X.\130%\GS\217\159\&3\177\227e\236",PropRequestProblemInformation 141,PropRequestResponseInformation -// 39,PropTopicAliasMaximum 17854,PropRequestResponseInformation 80,PropTopicAliasMaximum -// 26066,PropRequestResponseInformation 37,PropSharedSubscriptionAvailable 197,PropAssignedClientIdentifier -// "a\EM\STX\v",PropRequestResponseInformation 119,PropResponseTopic -// "H\222\167\142\164+h\153\180\242>\ESC$\175\ay\164",PropUserProperty "\153\151\136dT" -// "\244\237\151\169\184\229\236\bL\152J\239\141q\224El"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\193)\128\208yd\SOi\134\237\DC2Ir\136\217", _pubPktID = 8430, _pubBody = +// "\138\214\&5p\ESCn,\183\152u\192\244\165\&1\147\140\172", _pubProps = [PropReceiveMaximum +// 19627,PropSubscriptionIdentifier 11,PropPayloadFormatIndicator 254,PropAuthenticationMethod +// "\ETBO\172\EOT\165\CAN\201Y\189xl\153v\a\214\202\176\199",PropContentType "\245*.\194\146",PropMaximumPacketSize +// 15159,PropSubscriptionIdentifierAvailable 168,PropSharedSubscriptionAvailable 41,PropReasonString +// "_}\201lLo>9\n\217}\177",PropReasonString +// "\220[\167\&4h\244\217\222\142H\ETX\175F#\153\161y(O\EMZ\244*s!\174\247",PropPayloadFormatIndicator 155]} TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = {0x3c, 0x76, 0x0, 0x6, 0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2, 0x29, 0x64, 0x62, 0x12, 0x0, - 0x6, 0xdf, 0x7, 0xdc, 0x4, 0x43, 0x22, 0x19, 0xef, 0x16, 0x0, 0xc, 0x58, 0x2e, 0x82, - 0x25, 0x1d, 0xd9, 0x9f, 0x33, 0xb1, 0xe3, 0x65, 0xec, 0x17, 0x8d, 0x19, 0x27, 0x22, 0x45, - 0xbe, 0x19, 0x50, 0x22, 0x65, 0xd2, 0x19, 0x25, 0x2a, 0xc5, 0x12, 0x0, 0x4, 0x61, 0x19, - 0x2, 0xb, 0x19, 0x77, 0x8, 0x0, 0x11, 0x48, 0xde, 0xa7, 0x8e, 0xa4, 0x2b, 0x68, 0x99, - 0xb4, 0xf2, 0x3e, 0x1b, 0x24, 0xaf, 0x7, 0x79, 0xa4, 0x26, 0x0, 0x5, 0x99, 0x97, 0x88, - 0x64, 0x54, 0x0, 0x11, 0xf4, 0xed, 0x97, 0xa9, 0xb8, 0xe5, 0xec, 0x8, 0x4c, 0x98, 0x4a, - 0xef, 0x8d, 0x71, 0xe0, 0x45, 0x6c, 0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; - uint8_t topic_bytes[] = {0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x81, 0x1, 0x0, 0xf, 0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, + 0x72, 0x88, 0xd9, 0x20, 0xee, 0x5c, 0x21, 0x4c, 0xab, 0xb, 0xb, 0x1, 0xfe, 0x15, 0x0, 0x12, 0x17, + 0x4f, 0xac, 0x4, 0xa5, 0x18, 0xc9, 0x59, 0xbd, 0x78, 0x6c, 0x99, 0x76, 0x7, 0xd6, 0xca, 0xb0, 0xc7, + 0x3, 0x0, 0x5, 0xf5, 0x2a, 0x2e, 0xc2, 0x92, 0x27, 0x0, 0x0, 0x3b, 0x37, 0x29, 0xa8, 0x2a, 0x29, + 0x1f, 0x0, 0xc, 0x5f, 0x7d, 0xc9, 0x6c, 0x4c, 0x6f, 0x3e, 0x39, 0xa, 0xd9, 0x7d, 0xb1, 0x1f, 0x0, + 0x1b, 0xdc, 0x5b, 0xa7, 0x34, 0x68, 0xf4, 0xd9, 0xde, 0x8e, 0x48, 0x3, 0xaf, 0x46, 0x23, 0x99, 0xa1, + 0x79, 0x28, 0x4f, 0x19, 0x5a, 0xf4, 0x2a, 0x73, 0x21, 0xae, 0xf7, 0x1, 0x9b, 0x8a, 0xd6, 0x35, 0x70, + 0x1b, 0x6e, 0x2c, 0xb7, 0x98, 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; + uint8_t topic_bytes[] = {0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; + msg.retained = true; + uint8_t msg_bytes[] = {0x8a, 0xd6, 0x35, 0x70, 0x1b, 0x6e, 0x2c, 0xb7, 0x98, + 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 17; - uint8_t bytesprops0[] = {0xdf, 0x7, 0xdc, 0x4, 0x43, 0x22}; - uint8_t bytesprops1[] = {0x58, 0x2e, 0x82, 0x25, 0x1d, 0xd9, 0x9f, 0x33, 0xb1, 0xe3, 0x65, 0xec}; - uint8_t bytesprops2[] = {0x61, 0x19, 0x2, 0xb}; - uint8_t bytesprops3[] = {0x48, 0xde, 0xa7, 0x8e, 0xa4, 0x2b, 0x68, 0x99, 0xb4, - 0xf2, 0x3e, 0x1b, 0x24, 0xaf, 0x7, 0x79, 0xa4}; - uint8_t bytesprops5[] = {0xf4, 0xed, 0x97, 0xa9, 0xb8, 0xe5, 0xec, 0x8, 0x4c, - 0x98, 0x4a, 0xef, 0x8d, 0x71, 0xe0, 0x45, 0x6c}; - uint8_t bytesprops4[] = {0x99, 0x97, 0x88, 0x64, 0x54}; + uint8_t bytesprops0[] = {0x17, 0x4f, 0xac, 0x4, 0xa5, 0x18, 0xc9, 0x59, 0xbd, + 0x78, 0x6c, 0x99, 0x76, 0x7, 0xd6, 0xca, 0xb0, 0xc7}; + uint8_t bytesprops1[] = {0xf5, 0x2a, 0x2e, 0xc2, 0x92}; + uint8_t bytesprops2[] = {0x5f, 0x7d, 0xc9, 0x6c, 0x4c, 0x6f, 0x3e, 0x39, 0xa, 0xd9, 0x7d, 0xb1}; + uint8_t bytesprops3[] = {0xdc, 0x5b, 0xa7, 0x34, 0x68, 0xf4, 0xd9, 0xde, 0x8e, 0x48, 0x3, 0xaf, 0x46, 0x23, + 0x99, 0xa1, 0x79, 0x28, 0x4f, 0x19, 0x5a, 0xf4, 0x2a, 0x73, 0x21, 0xae, 0xf7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17854}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26066}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops4}, .v = {17, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19627}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15159}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10596, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 8430, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "<\v\SYN\154J\242", _pubPktID = -// 10596, _pubBody = "\187\150\168\193Z\202\188\STX?", _pubProps = [PropAssignedClientIdentifier -// "\223\a\220\EOTC\"",PropRequestResponseInformation 239,PropAuthenticationData -// "X.\130%\GS\217\159\&3\177\227e\236",PropRequestProblemInformation 141,PropRequestResponseInformation -// 39,PropTopicAliasMaximum 17854,PropRequestResponseInformation 80,PropTopicAliasMaximum -// 26066,PropRequestResponseInformation 37,PropSharedSubscriptionAvailable 197,PropAssignedClientIdentifier -// "a\EM\STX\v",PropRequestResponseInformation 119,PropResponseTopic -// "H\222\167\142\164+h\153\180\242>\ESC$\175\ay\164",PropUserProperty "\153\151\136dT" -// "\244\237\151\169\184\229\236\bL\152J\239\141q\224El"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\193)\128\208yd\SOi\134\237\DC2Ir\136\217", _pubPktID = 8430, _pubBody = +// "\138\214\&5p\ESCn,\183\152u\192\244\165\&1\147\140\172", _pubProps = [PropReceiveMaximum +// 19627,PropSubscriptionIdentifier 11,PropPayloadFormatIndicator 254,PropAuthenticationMethod +// "\ETBO\172\EOT\165\CAN\201Y\189xl\153v\a\214\202\176\199",PropContentType "\245*.\194\146",PropMaximumPacketSize +// 15159,PropSubscriptionIdentifierAvailable 168,PropSharedSubscriptionAvailable 41,PropReasonString +// "_}\201lLo>9\n\217}\177",PropReasonString +// "\220[\167\&4h\244\217\222\142H\ETX\175F#\153\161y(O\EMZ\244*s!\174\247",PropPayloadFormatIndicator 155]} TEST(Publish5QCTest, Decode4) { - uint8_t pkt[] = {0x3c, 0x76, 0x0, 0x6, 0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2, 0x29, 0x64, 0x62, 0x12, 0x0, - 0x6, 0xdf, 0x7, 0xdc, 0x4, 0x43, 0x22, 0x19, 0xef, 0x16, 0x0, 0xc, 0x58, 0x2e, 0x82, - 0x25, 0x1d, 0xd9, 0x9f, 0x33, 0xb1, 0xe3, 0x65, 0xec, 0x17, 0x8d, 0x19, 0x27, 0x22, 0x45, - 0xbe, 0x19, 0x50, 0x22, 0x65, 0xd2, 0x19, 0x25, 0x2a, 0xc5, 0x12, 0x0, 0x4, 0x61, 0x19, - 0x2, 0xb, 0x19, 0x77, 0x8, 0x0, 0x11, 0x48, 0xde, 0xa7, 0x8e, 0xa4, 0x2b, 0x68, 0x99, - 0xb4, 0xf2, 0x3e, 0x1b, 0x24, 0xaf, 0x7, 0x79, 0xa4, 0x26, 0x0, 0x5, 0x99, 0x97, 0x88, - 0x64, 0x54, 0x0, 0x11, 0xf4, 0xed, 0x97, 0xa9, 0xb8, 0xe5, 0xec, 0x8, 0x4c, 0x98, 0x4a, - 0xef, 0x8d, 0x71, 0xe0, 0x45, 0x6c, 0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; + uint8_t pkt[] = {0x3d, 0x81, 0x1, 0x0, 0xf, 0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, + 0x72, 0x88, 0xd9, 0x20, 0xee, 0x5c, 0x21, 0x4c, 0xab, 0xb, 0xb, 0x1, 0xfe, 0x15, 0x0, 0x12, 0x17, + 0x4f, 0xac, 0x4, 0xa5, 0x18, 0xc9, 0x59, 0xbd, 0x78, 0x6c, 0x99, 0x76, 0x7, 0xd6, 0xca, 0xb0, 0xc7, + 0x3, 0x0, 0x5, 0xf5, 0x2a, 0x2e, 0xc2, 0x92, 0x27, 0x0, 0x0, 0x3b, 0x37, 0x29, 0xa8, 0x2a, 0x29, + 0x1f, 0x0, 0xc, 0x5f, 0x7d, 0xc9, 0x6c, 0x4c, 0x6f, 0x3e, 0x39, 0xa, 0xd9, 0x7d, 0xb1, 0x1f, 0x0, + 0x1b, 0xdc, 0x5b, 0xa7, 0x34, 0x68, 0xf4, 0xd9, 0xde, 0x8e, 0x48, 0x3, 0xaf, 0x46, 0x23, 0x99, 0xa1, + 0x79, 0x28, 0x4f, 0x19, 0x5a, 0xf4, 0x2a, 0x73, 0x21, 0xae, 0xf7, 0x1, 0x9b, 0x8a, 0xd6, 0x35, 0x70, + 0x1b, 0x6e, 0x2c, 0xb7, 0x98, 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2155,73 +2194,70 @@ TEST(Publish5QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3c, 0xb, 0x16, 0x9a, 0x4a, 0xf2}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbb, 0x96, 0xa8, 0xc1, 0x5a, 0xca, 0xbc, 0x2, 0x3f}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8a, 0xd6, 0x35, 0x70, 0x1b, 0x6e, 0x2c, 0xb7, 0x98, + 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10596); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 8430); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\165,\215\220S\205E\205\200\222\229\249\ESC\148", _pubPktID = 15507, _pubBody = "pR:\130:", _pubProps = -// [PropRequestProblemInformation 19,PropMessageExpiryInterval 20770,PropAuthenticationData -// "\174\254\r\157h\203\190\209",PropCorrelationData -// "l\128}bI\137\160\185\v\169\253\161l;\215\232\241\134I\204)\158\241\166\207\190\216"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\DC2\184\144\&5\136\156E\174\237\230\175\SUB\153 \NAKk\EM\f", _pubPktID = 0, _pubBody = +// "i\232{\DC3k\GS\158\DLE|\218\236v\244>\145\172,\bR\165\255\174", _pubProps = [PropCorrelationData +// "\227\244",PropServerKeepAlive 1521,PropResponseTopic "\130%)hs"]} TEST(Publish5QCTest, Encode5) { - uint8_t pkt[] = {0x3c, 0x48, 0x0, 0xe, 0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, - 0xf9, 0x1b, 0x94, 0x3c, 0x93, 0x30, 0x17, 0x13, 0x2, 0x0, 0x0, 0x51, 0x22, 0x16, 0x0, - 0x8, 0xae, 0xfe, 0xd, 0x9d, 0x68, 0xcb, 0xbe, 0xd1, 0x9, 0x0, 0x1b, 0x6c, 0x80, 0x7d, - 0x62, 0x49, 0x89, 0xa0, 0xb9, 0xb, 0xa9, 0xfd, 0xa1, 0x6c, 0x3b, 0xd7, 0xe8, 0xf1, 0x86, - 0x49, 0xcc, 0x29, 0x9e, 0xf1, 0xa6, 0xcf, 0xbe, 0xd8, 0x70, 0x52, 0x3a, 0x82, 0x3a}; - uint8_t topic_bytes[] = {0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, 0xf9, 0x1b, 0x94}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x3b, 0x0, 0x12, 0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, 0xe6, 0xaf, 0x1a, + 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc, 0x10, 0x9, 0x0, 0x2, 0xe3, 0xf4, 0x13, 0x5, 0xf1, 0x8, + 0x0, 0x5, 0x82, 0x25, 0x29, 0x68, 0x73, 0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, + 0xda, 0xec, 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; + uint8_t topic_bytes[] = {0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, + 0xe6, 0xaf, 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x70, 0x52, 0x3a, 0x82, 0x3a}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, 0xda, 0xec, + 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + msg.payload_len = 22; - uint8_t bytesprops0[] = {0xae, 0xfe, 0xd, 0x9d, 0x68, 0xcb, 0xbe, 0xd1}; - uint8_t bytesprops1[] = {0x6c, 0x80, 0x7d, 0x62, 0x49, 0x89, 0xa0, 0xb9, 0xb, 0xa9, 0xfd, 0xa1, 0x6c, 0x3b, - 0xd7, 0xe8, 0xf1, 0x86, 0x49, 0xcc, 0x29, 0x9e, 0xf1, 0xa6, 0xcf, 0xbe, 0xd8}; + uint8_t bytesprops0[] = {0xe3, 0xf4}; + uint8_t bytesprops1[] = {0x82, 0x25, 0x29, 0x68, 0x73}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20770}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1521}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 15507, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\165,\215\220S\205E\205\200\222\229\249\ESC\148", _pubPktID = 15507, _pubBody = "pR:\130:", _pubProps = -// [PropRequestProblemInformation 19,PropMessageExpiryInterval 20770,PropAuthenticationData -// "\174\254\r\157h\203\190\209",PropCorrelationData -// "l\128}bI\137\160\185\v\169\253\161l;\215\232\241\134I\204)\158\241\166\207\190\216"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\DC2\184\144\&5\136\156E\174\237\230\175\SUB\153 \NAKk\EM\f", _pubPktID = 0, _pubBody = +// "i\232{\DC3k\GS\158\DLE|\218\236v\244>\145\172,\bR\165\255\174", _pubProps = [PropCorrelationData +// "\227\244",PropServerKeepAlive 1521,PropResponseTopic "\130%)hs"]} TEST(Publish5QCTest, Decode5) { - uint8_t pkt[] = {0x3c, 0x48, 0x0, 0xe, 0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, - 0xf9, 0x1b, 0x94, 0x3c, 0x93, 0x30, 0x17, 0x13, 0x2, 0x0, 0x0, 0x51, 0x22, 0x16, 0x0, - 0x8, 0xae, 0xfe, 0xd, 0x9d, 0x68, 0xcb, 0xbe, 0xd1, 0x9, 0x0, 0x1b, 0x6c, 0x80, 0x7d, - 0x62, 0x49, 0x89, 0xa0, 0xb9, 0xb, 0xa9, 0xfd, 0xa1, 0x6c, 0x3b, 0xd7, 0xe8, 0xf1, 0x86, - 0x49, 0xcc, 0x29, 0x9e, 0xf1, 0xa6, 0xcf, 0xbe, 0xd8, 0x70, 0x52, 0x3a, 0x82, 0x3a}; + uint8_t pkt[] = {0x31, 0x3b, 0x0, 0x12, 0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, 0xe6, 0xaf, 0x1a, + 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc, 0x10, 0x9, 0x0, 0x2, 0xe3, 0xf4, 0x13, 0x5, 0xf1, 0x8, + 0x0, 0x5, 0x82, 0x25, 0x29, 0x68, 0x73, 0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, + 0xda, 0xec, 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2230,108 +2266,112 @@ TEST(Publish5QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa5, 0x2c, 0xd7, 0xdc, 0x53, 0xcd, 0x45, 0xcd, 0xc8, 0xde, 0xe5, 0xf9, 0x1b, 0x94}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x70, 0x52, 0x3a, 0x82, 0x3a}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 15507); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + uint8_t exp_topic_bytes[] = {0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, + 0xe6, 0xaf, 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, 0xda, 0xec, + 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\v\255\253\245\160v\SO\231\130e\134B1\174\n", _pubPktID = 29653, _pubBody = -// "\169\178\185\220\v\ACKV\254\137C8\154\ETB\\\213\142=", _pubProps = [PropSubscriptionIdentifierAvailable -// 163,PropContentType -// "\238\RS\137\144\182\SIS\133\135g\181,T\222\185\&2\191\215\185\150\144e\236\184\152\141\DEL",PropUserProperty -// "A\182\202y\177m\190\207\186\208\183H\174\187\220\240\182\SI" "\236\243QZ\197\132\DLE\246d",PropTopicAliasMaximum -// 15667,PropTopicAlias 24501,PropAuthenticationMethod "\173\CANuc\184^\152Tq\ESC",PropRequestProblemInformation -// 26,PropMaximumPacketSize 17078,PropReasonString -// "\134p\188D\191\207\131\211:\225<}B\182f\251;OI^\181\249\202\133\255K*\NAK\248\GS",PropReasonString -// "\DLEn5\171T\251\232\156"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\251M\156e\192", _pubPktID = 0, +// _pubBody = "O\254\197\133\153\151~\137\172", _pubProps = [PropCorrelationData "\164\SYNM",PropResponseInformation +// "\198\172\187",PropMessageExpiryInterval 15651,PropRetainAvailable 113,PropSharedSubscriptionAvailable +// 216,PropPayloadFormatIndicator 60,PropSessionExpiryInterval 32556,PropRetainAvailable 157,PropResponseTopic +// "bs\182\201\208\166\184\235s",PropSharedSubscriptionAvailable 161,PropCorrelationData +// "\251\167\&6W,g\154\DC2{\163\173\n\177\145\221\151\162\251\159;!o\232\SI\205]{\239\148\216",PropSubscriptionIdentifierAvailable +// 131,PropTopicAliasMaximum 30761,PropMaximumQoS 12,PropContentType +// "\214\132_\244\175\236=^\131\r1d!\223\173w\221",PropWillDelayInterval 27380,PropRequestProblemInformation +// 122,PropTopicAlias 19545,PropReasonString "\166\EOT\231\US\185",PropSubscriptionIdentifierAvailable 97]} TEST(Publish5QCTest, Encode6) { - uint8_t pkt[] = {0x35, 0xac, 0x1, 0x0, 0xf, 0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, 0x65, 0x86, - 0x42, 0x31, 0xae, 0xa, 0x73, 0xd5, 0x86, 0x1, 0x29, 0xa3, 0x3, 0x0, 0x1b, 0xee, 0x1e, 0x89, - 0x90, 0xb6, 0xf, 0x53, 0x85, 0x87, 0x67, 0xb5, 0x2c, 0x54, 0xde, 0xb9, 0x32, 0xbf, 0xd7, 0xb9, - 0x96, 0x90, 0x65, 0xec, 0xb8, 0x98, 0x8d, 0x7f, 0x26, 0x0, 0x12, 0x41, 0xb6, 0xca, 0x79, 0xb1, - 0x6d, 0xbe, 0xcf, 0xba, 0xd0, 0xb7, 0x48, 0xae, 0xbb, 0xdc, 0xf0, 0xb6, 0xf, 0x0, 0x9, 0xec, - 0xf3, 0x51, 0x5a, 0xc5, 0x84, 0x10, 0xf6, 0x64, 0x22, 0x3d, 0x33, 0x23, 0x5f, 0xb5, 0x15, 0x0, - 0xa, 0xad, 0x18, 0x75, 0x63, 0xb8, 0x5e, 0x98, 0x54, 0x71, 0x1b, 0x17, 0x1a, 0x27, 0x0, 0x0, - 0x42, 0xb6, 0x1f, 0x0, 0x1e, 0x86, 0x70, 0xbc, 0x44, 0xbf, 0xcf, 0x83, 0xd3, 0x3a, 0xe1, 0x3c, - 0x7d, 0x42, 0xb6, 0x66, 0xfb, 0x3b, 0x4f, 0x49, 0x5e, 0xb5, 0xf9, 0xca, 0x85, 0xff, 0x4b, 0x2a, - 0x15, 0xf8, 0x1d, 0x1f, 0x0, 0x8, 0x10, 0x6e, 0x35, 0xab, 0x54, 0xfb, 0xe8, 0x9c, 0xa9, 0xb2, - 0xb9, 0xdc, 0xb, 0x6, 0x56, 0xfe, 0x89, 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; - uint8_t topic_bytes[] = {0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, 0x65, 0x86, 0x42, 0x31, 0xae, 0xa}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x8d, 0x1, 0x0, 0x5, 0xfb, 0x4d, 0x9c, 0x65, 0xc0, 0x7c, 0x9, 0x0, 0x3, 0xa4, 0x16, + 0x4d, 0x1a, 0x0, 0x3, 0xc6, 0xac, 0xbb, 0x2, 0x0, 0x0, 0x3d, 0x23, 0x25, 0x71, 0x2a, 0xd8, + 0x1, 0x3c, 0x11, 0x0, 0x0, 0x7f, 0x2c, 0x25, 0x9d, 0x8, 0x0, 0x9, 0x62, 0x73, 0xb6, 0xc9, + 0xd0, 0xa6, 0xb8, 0xeb, 0x73, 0x2a, 0xa1, 0x9, 0x0, 0x1e, 0xfb, 0xa7, 0x36, 0x57, 0x2c, 0x67, + 0x9a, 0x12, 0x7b, 0xa3, 0xad, 0xa, 0xb1, 0x91, 0xdd, 0x97, 0xa2, 0xfb, 0x9f, 0x3b, 0x21, 0x6f, + 0xe8, 0xf, 0xcd, 0x5d, 0x7b, 0xef, 0x94, 0xd8, 0x29, 0x83, 0x22, 0x78, 0x29, 0x24, 0xc, 0x3, + 0x0, 0x11, 0xd6, 0x84, 0x5f, 0xf4, 0xaf, 0xec, 0x3d, 0x5e, 0x83, 0xd, 0x31, 0x64, 0x21, 0xdf, + 0xad, 0x77, 0xdd, 0x18, 0x0, 0x0, 0x6a, 0xf4, 0x17, 0x7a, 0x23, 0x4c, 0x59, 0x1f, 0x0, 0x5, + 0xa6, 0x4, 0xe7, 0x1f, 0xb9, 0x29, 0x61, 0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; + uint8_t topic_bytes[] = {0xfb, 0x4d, 0x9c, 0x65, 0xc0}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xa9, 0xb2, 0xb9, 0xdc, 0xb, 0x6, 0x56, 0xfe, 0x89, - 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; + uint8_t msg_bytes[] = {0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 9; - uint8_t bytesprops0[] = {0xee, 0x1e, 0x89, 0x90, 0xb6, 0xf, 0x53, 0x85, 0x87, 0x67, 0xb5, 0x2c, 0x54, 0xde, - 0xb9, 0x32, 0xbf, 0xd7, 0xb9, 0x96, 0x90, 0x65, 0xec, 0xb8, 0x98, 0x8d, 0x7f}; - uint8_t bytesprops2[] = {0xec, 0xf3, 0x51, 0x5a, 0xc5, 0x84, 0x10, 0xf6, 0x64}; - uint8_t bytesprops1[] = {0x41, 0xb6, 0xca, 0x79, 0xb1, 0x6d, 0xbe, 0xcf, 0xba, - 0xd0, 0xb7, 0x48, 0xae, 0xbb, 0xdc, 0xf0, 0xb6, 0xf}; - uint8_t bytesprops3[] = {0xad, 0x18, 0x75, 0x63, 0xb8, 0x5e, 0x98, 0x54, 0x71, 0x1b}; - uint8_t bytesprops4[] = {0x86, 0x70, 0xbc, 0x44, 0xbf, 0xcf, 0x83, 0xd3, 0x3a, 0xe1, 0x3c, 0x7d, 0x42, 0xb6, 0x66, - 0xfb, 0x3b, 0x4f, 0x49, 0x5e, 0xb5, 0xf9, 0xca, 0x85, 0xff, 0x4b, 0x2a, 0x15, 0xf8, 0x1d}; - uint8_t bytesprops5[] = {0x10, 0x6e, 0x35, 0xab, 0x54, 0xfb, 0xe8, 0x9c}; + uint8_t bytesprops0[] = {0xa4, 0x16, 0x4d}; + uint8_t bytesprops1[] = {0xc6, 0xac, 0xbb}; + uint8_t bytesprops2[] = {0x62, 0x73, 0xb6, 0xc9, 0xd0, 0xa6, 0xb8, 0xeb, 0x73}; + uint8_t bytesprops3[] = {0xfb, 0xa7, 0x36, 0x57, 0x2c, 0x67, 0x9a, 0x12, 0x7b, 0xa3, 0xad, 0xa, 0xb1, 0x91, 0xdd, + 0x97, 0xa2, 0xfb, 0x9f, 0x3b, 0x21, 0x6f, 0xe8, 0xf, 0xcd, 0x5d, 0x7b, 0xef, 0x94, 0xd8}; + uint8_t bytesprops4[] = {0xd6, 0x84, 0x5f, 0xf4, 0xaf, 0xec, 0x3d, 0x5e, 0x83, + 0xd, 0x31, 0x64, 0x21, 0xdf, 0xad, 0x77, 0xdd}; + uint8_t bytesprops5[] = {0xa6, 0x4, 0xe7, 0x1f, 0xb9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {9, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15667}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24501}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17078}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15651}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32556}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30761}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27380}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19545}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 97}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29653, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\v\255\253\245\160v\SO\231\130e\134B1\174\n", _pubPktID = 29653, _pubBody = -// "\169\178\185\220\v\ACKV\254\137C8\154\ETB\\\213\142=", _pubProps = [PropSubscriptionIdentifierAvailable -// 163,PropContentType -// "\238\RS\137\144\182\SIS\133\135g\181,T\222\185\&2\191\215\185\150\144e\236\184\152\141\DEL",PropUserProperty -// "A\182\202y\177m\190\207\186\208\183H\174\187\220\240\182\SI" "\236\243QZ\197\132\DLE\246d",PropTopicAliasMaximum -// 15667,PropTopicAlias 24501,PropAuthenticationMethod "\173\CANuc\184^\152Tq\ESC",PropRequestProblemInformation -// 26,PropMaximumPacketSize 17078,PropReasonString -// "\134p\188D\191\207\131\211:\225<}B\182f\251;OI^\181\249\202\133\255K*\NAK\248\GS",PropReasonString -// "\DLEn5\171T\251\232\156"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\251M\156e\192", _pubPktID = 0, +// _pubBody = "O\254\197\133\153\151~\137\172", _pubProps = [PropCorrelationData "\164\SYNM",PropResponseInformation +// "\198\172\187",PropMessageExpiryInterval 15651,PropRetainAvailable 113,PropSharedSubscriptionAvailable +// 216,PropPayloadFormatIndicator 60,PropSessionExpiryInterval 32556,PropRetainAvailable 157,PropResponseTopic +// "bs\182\201\208\166\184\235s",PropSharedSubscriptionAvailable 161,PropCorrelationData +// "\251\167\&6W,g\154\DC2{\163\173\n\177\145\221\151\162\251\159;!o\232\SI\205]{\239\148\216",PropSubscriptionIdentifierAvailable +// 131,PropTopicAliasMaximum 30761,PropMaximumQoS 12,PropContentType +// "\214\132_\244\175\236=^\131\r1d!\223\173w\221",PropWillDelayInterval 27380,PropRequestProblemInformation +// 122,PropTopicAlias 19545,PropReasonString "\166\EOT\231\US\185",PropSubscriptionIdentifierAvailable 97]} TEST(Publish5QCTest, Decode6) { - uint8_t pkt[] = {0x35, 0xac, 0x1, 0x0, 0xf, 0xb, 0xff, 0x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+ 0x4d, 0x1a, 0x0, 0x3, 0xc6, 0xac, 0xbb, 0x2, 0x0, 0x0, 0x3d, 0x23, 0x25, 0x71, 0x2a, 0xd8, + 0x1, 0x3c, 0x11, 0x0, 0x0, 0x7f, 0x2c, 0x25, 0x9d, 0x8, 0x0, 0x9, 0x62, 0x73, 0xb6, 0xc9, + 0xd0, 0xa6, 0xb8, 0xeb, 0x73, 0x2a, 0xa1, 0x9, 0x0, 0x1e, 0xfb, 0xa7, 0x36, 0x57, 0x2c, 0x67, + 0x9a, 0x12, 0x7b, 0xa3, 0xad, 0xa, 0xb1, 0x91, 0xdd, 0x97, 0xa2, 0xfb, 0x9f, 0x3b, 0x21, 0x6f, + 0xe8, 0xf, 0xcd, 0x5d, 0x7b, 0xef, 0x94, 0xd8, 0x29, 0x83, 0x22, 0x78, 0x29, 0x24, 0xc, 0x3, + 0x0, 0x11, 0xd6, 0x84, 0x5f, 0xf4, 0xaf, 0xec, 0x3d, 0x5e, 0x83, 0xd, 0x31, 0x64, 0x21, 0xdf, + 0xad, 0x77, 0xdd, 0x18, 0x0, 0x0, 0x6a, 0xf4, 0x17, 0x7a, 0x23, 0x4c, 0x59, 0x1f, 0x0, 0x5, + 0xa6, 0x4, 0xe7, 0x1f, 0xb9, 0x29, 0x61, 0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2340,108 +2380,115 @@ TEST(Publish5QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb, 0xff, 0xfd, 0xf5, 0xa0, 0x76, 0xe, 0xe7, 0x82, 0x65, 0x86, 0x42, 0x31, 0xae, 0xa}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa9, 0xb2, 0xb9, 0xdc, 0xb, 0x6, 0x56, 0xfe, 0x89, - 0x43, 0x38, 0x9a, 0x17, 0x5c, 0xd5, 0x8e, 0x3d}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xfb, 0x4d, 0x9c, 0x65, 0xc0}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29653); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\207)#\195\178f\ESC\134K\157xAj\210\148\138\207\185", _pubPktID = 17568, _pubBody = "\171Y", _pubProps = -// [PropContentType "\134v\226Zj2\ACK.=\141{\196[\239hp\169*\142 |\USd\171\171}=\239",PropSubscriptionIdentifier -// 3,PropAuthenticationMethod -// "\252\190ys\195\US\192Z\175\170\191\192'\232C\202j\DELn\211\134\US\251*",PropMessageExpiryInterval -// 16252,PropSubscriptionIdentifier 5,PropTopicAlias 6022,PropReceiveMaximum 5386,PropTopicAliasMaximum -// 19404,PropPayloadFormatIndicator 143,PropWillDelayInterval 21874,PropContentType -// "\nrf\140\224\128\207\223\US\161\NULF",PropMaximumPacketSize 31744,PropMessageExpiryInterval -// 24715,PropMessageExpiryInterval 16233,PropReceiveMaximum 11567,PropRetainAvailable -// 143,PropWildcardSubscriptionAvailable 146]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\224@\143", _pubPktID = 6480, +// _pubBody = "p\191(\150l\241Y\SO\208g\192\EMT+\DLE\246\189f\179C\EOTFwX1\DC3I*A\n", _pubProps = +// [PropSubscriptionIdentifierAvailable 229,PropSubscriptionIdentifierAvailable 203,PropAssignedClientIdentifier +// "F\195\210\155",PropServerReference "\213\201\ESC\EOT\129|\187\139x",PropReceiveMaximum 23639,PropUserProperty +// "\SO\222O\NAK\188\216\b1\STX\138\158\205m\236D\fy\GS*\223\162\v\231\188\154B\ESC(i" "\178u\ETB\251\241\206\204:j\178 +// ",PropAuthenticationMethod "\167\SUB\235\224\179nC",PropCorrelationData "AH\143]M\202X\141\STX>",PropTopicAlias +// 7879,PropAssignedClientIdentifier "?8\196vb\209i\185\175\&5N\174{\250d\151w%",PropSubscriptionIdentifierAvailable +// 108,PropSharedSubscriptionAvailable 218,PropTopicAlias 27267,PropMaximumPacketSize 20290,PropResponseTopic +// "\EOT\135/c\153\173\178\192\184\207\DC4\ENQ\247\174\CANr\184\197\185\203\\\190\182H"]} TEST(Publish5QCTest, Encode7) { - uint8_t pkt[] = {0x33, 0x91, 0x1, 0x0, 0x12, 0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, 0x9d, 0x78, 0x41, - 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9, 0x44, 0xa0, 0x78, 0x3, 0x0, 0x1c, 0x86, 0x76, 0xe2, 0x5a, 0x6a, - 0x32, 0x6, 0x2e, 0x3d, 0x8d, 0x7b, 0xc4, 0x5b, 0xef, 0x68, 0x70, 0xa9, 0x2a, 0x8e, 0x20, 0x7c, 0x1f, - 0x64, 0xab, 0xab, 0x7d, 0x3d, 0xef, 0xb, 0x3, 0x15, 0x0, 0x18, 0xfc, 0xbe, 0x79, 0x73, 0xc3, 0x1f, - 0xc0, 0x5a, 0xaf, 0xaa, 0xbf, 0xc0, 0x27, 0xe8, 0x43, 0xca, 0x6a, 0x7f, 0x6e, 0xd3, 0x86, 0x1f, 0xfb, - 0x2a, 0x2, 0x0, 0x0, 0x3f, 0x7c, 0xb, 0x5, 0x23, 0x17, 0x86, 0x21, 0x15, 0xa, 0x22, 0x4b, 0xcc, - 0x1, 0x8f, 0x18, 0x0, 0x0, 0x55, 0x72, 0x3, 0x0, 0xc, 0xa, 0x72, 0x66, 0x8c, 0xe0, 0x80, 0xcf, - 0xdf, 0x1f, 0xa1, 0x0, 0x46, 0x27, 0x0, 0x0, 0x7c, 0x0, 0x2, 0x0, 0x0, 0x60, 0x8b, 0x2, 0x0, - 0x0, 0x3f, 0x69, 0x21, 0x2d, 0x2f, 0x25, 0x8f, 0x28, 0x92, 0xab, 0x59}; - uint8_t topic_bytes[] = {0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, - 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0xc4, 0x1, 0x0, 0x3, 0xe0, 0x40, 0x8f, 0x19, 0x50, 0x9d, 0x1, 0x29, 0xe5, 0x29, 0xcb, 0x12, + 0x0, 0x4, 0x46, 0xc3, 0xd2, 0x9b, 0x1c, 0x0, 0x9, 0xd5, 0xc9, 0x1b, 0x4, 0x81, 0x7c, 0xbb, 0x8b, + 0x78, 0x21, 0x5c, 0x57, 0x26, 0x0, 0x1d, 0xe, 0xde, 0x4f, 0x15, 0xbc, 0xd8, 0x8, 0x31, 0x2, 0x8a, + 0x9e, 0xcd, 0x6d, 0xec, 0x44, 0xc, 0x79, 0x1d, 0x2a, 0xdf, 0xa2, 0xb, 0xe7, 0xbc, 0x9a, 0x42, 0x1b, + 0x28, 0x69, 0x0, 0xb, 0xb2, 0x75, 0x17, 0xfb, 0xf1, 0xce, 0xcc, 0x3a, 0x6a, 0xb2, 0x20, 0x15, 0x0, + 0x7, 0xa7, 0x1a, 0xeb, 0xe0, 0xb3, 0x6e, 0x43, 0x9, 0x0, 0xa, 0x41, 0x48, 0x8f, 0x5d, 0x4d, 0xca, + 0x58, 0x8d, 0x2, 0x3e, 0x23, 0x1e, 0xc7, 0x12, 0x0, 0x12, 0x3f, 0x38, 0xc4, 0x76, 0x62, 0xd1, 0x69, + 0xb9, 0xaf, 0x35, 0x4e, 0xae, 0x7b, 0xfa, 0x64, 0x97, 0x77, 0x25, 0x29, 0x6c, 0x2a, 0xda, 0x23, 0x6a, + 0x83, 0x27, 0x0, 0x0, 0x4f, 0x42, 0x8, 0x0, 0x18, 0x4, 0x87, 0x2f, 0x63, 0x99, 0xad, 0xb2, 0xc0, + 0xb8, 0xcf, 0x14, 0x5, 0xf7, 0xae, 0x18, 0x72, 0xb8, 0xc5, 0xb9, 0xcb, 0x5c, 0xbe, 0xb6, 0x48, 0x70, + 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, 0xf6, 0xbd, 0x66, + 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; + uint8_t topic_bytes[] = {0xe0, 0x40, 0x8f}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xab, 0x59}; + uint8_t msg_bytes[] = {0x70, 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, + 0xf6, 0xbd, 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; - - uint8_t bytesprops0[] = {0x86, 0x76, 0xe2, 0x5a, 0x6a, 0x32, 0x6, 0x2e, 0x3d, 0x8d, 0x7b, 0xc4, 0x5b, 0xef, - 0x68, 0x70, 0xa9, 0x2a, 0x8e, 0x20, 0x7c, 0x1f, 0x64, 0xab, 0xab, 0x7d, 0x3d, 0xef}; - uint8_t bytesprops1[] = {0xfc, 0xbe, 0x79, 0x73, 0xc3, 0x1f, 0xc0, 0x5a, 0xaf, 0xaa, 0xbf, 0xc0, - 0x27, 0xe8, 0x43, 0xca, 0x6a, 0x7f, 0x6e, 0xd3, 0x86, 0x1f, 0xfb, 0x2a}; - uint8_t bytesprops2[] = {0xa, 0x72, 0x66, 0x8c, 0xe0, 0x80, 0xcf, 0xdf, 0x1f, 0xa1, 0x0, 0x46}; + msg.payload_len = 30; + + uint8_t bytesprops0[] = {0x46, 0xc3, 0xd2, 0x9b}; + uint8_t bytesprops1[] = {0xd5, 0xc9, 0x1b, 0x4, 0x81, 0x7c, 0xbb, 0x8b, 0x78}; + uint8_t bytesprops3[] = {0xb2, 0x75, 0x17, 0xfb, 0xf1, 0xce, 0xcc, 0x3a, 0x6a, 0xb2, 0x20}; + uint8_t bytesprops2[] = {0xe, 0xde, 0x4f, 0x15, 0xbc, 0xd8, 0x8, 0x31, 0x2, 0x8a, 0x9e, 0xcd, 0x6d, 0xec, 0x44, + 0xc, 0x79, 0x1d, 0x2a, 0xdf, 0xa2, 0xb, 0xe7, 0xbc, 0x9a, 0x42, 0x1b, 0x28, 0x69}; + uint8_t bytesprops4[] = {0xa7, 0x1a, 0xeb, 0xe0, 0xb3, 0x6e, 0x43}; + uint8_t bytesprops5[] = {0x41, 0x48, 0x8f, 0x5d, 0x4d, 0xca, 0x58, 0x8d, 0x2, 0x3e}; + uint8_t bytesprops6[] = {0x3f, 0x38, 0xc4, 0x76, 0x62, 0xd1, 0x69, 0xb9, 0xaf, + 0x35, 0x4e, 0xae, 0x7b, 0xfa, 0x64, 0x97, 0x77, 0x25}; + uint8_t bytesprops7[] = {0x4, 0x87, 0x2f, 0x63, 0x99, 0xad, 0xb2, 0xc0, 0xb8, 0xcf, 0x14, 0x5, + 0xf7, 0xae, 0x18, 0x72, 0xb8, 0xc5, 0xb9, 0xcb, 0x5c, 0xbe, 0xb6, 0x48}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16252}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 5}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6022}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5386}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19404}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21874}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31744}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24715}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16233}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11567}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23639}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7879}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27267}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20290}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17568, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6480, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\207)#\195\178f\ESC\134K\157xAj\210\148\138\207\185", _pubPktID = 17568, _pubBody = "\171Y", _pubProps = -// [PropContentType "\134v\226Zj2\ACK.=\141{\196[\239hp\169*\142 |\USd\171\171}=\239",PropSubscriptionIdentifier -// 3,PropAuthenticationMethod -// "\252\190ys\195\US\192Z\175\170\191\192'\232C\202j\DELn\211\134\US\251*",PropMessageExpiryInterval -// 16252,PropSubscriptionIdentifier 5,PropTopicAlias 6022,PropReceiveMaximum 5386,PropTopicAliasMaximum -// 19404,PropPayloadFormatIndicator 143,PropWillDelayInterval 21874,PropContentType -// "\nrf\140\224\128\207\223\US\161\NULF",PropMaximumPacketSize 31744,PropMessageExpiryInterval -// 24715,PropMessageExpiryInterval 16233,PropReceiveMaximum 11567,PropRetainAvailable -// 143,PropWildcardSubscriptionAvailable 146]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\224@\143", _pubPktID = 6480, +// _pubBody = "p\191(\150l\241Y\SO\208g\192\EMT+\DLE\246\189f\179C\EOTFwX1\DC3I*A\n", _pubProps = +// [PropSubscriptionIdentifierAvailable 229,PropSubscriptionIdentifierAvailable 203,PropAssignedClientIdentifier +// "F\195\210\155",PropServerReference "\213\201\ESC\EOT\129|\187\139x",PropReceiveMaximum 23639,PropUserProperty +// "\SO\222O\NAK\188\216\b1\STX\138\158\205m\236D\fy\GS*\223\162\v\231\188\154B\ESC(i" "\178u\ETB\251\241\206\204:j\178 +// ",PropAuthenticationMethod "\167\SUB\235\224\179nC",PropCorrelationData "AH\143]M\202X\141\STX>",PropTopicAlias +// 7879,PropAssignedClientIdentifier "?8\196vb\209i\185\175\&5N\174{\250d\151w%",PropSubscriptionIdentifierAvailable +// 108,PropSharedSubscriptionAvailable 218,PropTopicAlias 27267,PropMaximumPacketSize 20290,PropResponseTopic +// "\EOT\135/c\153\173\178\192\184\207\DC4\ENQ\247\174\CANr\184\197\185\203\\\190\182H"]} TEST(Publish5QCTest, Decode7) { - uint8_t pkt[] = {0x33, 0x91, 0x1, 0x0, 0x12, 0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, 0x9d, 0x78, 0x41, - 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9, 0x44, 0xa0, 0x78, 0x3, 0x0, 0x1c, 0x86, 0x76, 0xe2, 0x5a, 0x6a, - 0x32, 0x6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b, 0xb2, 0x75, 0x17, 0xfb, 0xf1, 0xce, 0xcc, 0x3a, 0x6a, 0xb2, 0x20, 0x15, 0x0, + 0x7, 0xa7, 0x1a, 0xeb, 0xe0, 0xb3, 0x6e, 0x43, 0x9, 0x0, 0xa, 0x41, 0x48, 0x8f, 0x5d, 0x4d, 0xca, + 0x58, 0x8d, 0x2, 0x3e, 0x23, 0x1e, 0xc7, 0x12, 0x0, 0x12, 0x3f, 0x38, 0xc4, 0x76, 0x62, 0xd1, 0x69, + 0xb9, 0xaf, 0x35, 0x4e, 0xae, 0x7b, 0xfa, 0x64, 0x97, 0x77, 0x25, 0x29, 0x6c, 0x2a, 0xda, 0x23, 0x6a, + 0x83, 0x27, 0x0, 0x0, 0x4f, 0x42, 0x8, 0x0, 0x18, 0x4, 0x87, 0x2f, 0x63, 0x99, 0xad, 0xb2, 0xc0, + 0xb8, 0xcf, 0x14, 0x5, 0xf7, 0xae, 0x18, 0x72, 0xb8, 0xc5, 0xb9, 0xcb, 0x5c, 0xbe, 0xb6, 0x48, 0x70, + 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, 0xf6, 0xbd, 0x66, + 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2450,167 +2497,125 @@ TEST(Publish5QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xcf, 0x29, 0x23, 0xc3, 0xb2, 0x66, 0x1b, 0x86, 0x4b, - 0x9d, 0x78, 0x41, 0x6a, 0xd2, 0x94, 0x8a, 0xcf, 0xb9}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xab, 0x59}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xe0, 0x40, 0x8f}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x70, 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, + 0xf6, 0xbd, 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 17568); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(packet_id, 6480); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "(9fA\NAK\140\194;\215\236\145\SO\240#\ESC", _pubPktID = 5686, _pubBody = -// "\197\149\245\GS\f\206T\209\&7\232c\143\164A\177\DC3\r<.\ACK", _pubProps = [PropSessionExpiryInterval -// 21595,PropSharedSubscriptionAvailable 6,PropServerReference -// "\154\134\&1\208y,\EOT\249\185\232\141\SYN^\132\158\254",PropReasonString -// "\218+\v\ETX~\212\acFLU\138\235",PropSubscriptionIdentifierAvailable 103,PropResponseInformation -// "B\247\fNU\170\&6U\141\DLEm\154\237y -// \201;\a\223i\163\169\176\FS\v\232\128\227\128\245",PropRequestResponseInformation 199,PropRequestResponseInformation -// 107,PropReceiveMaximum 19809,PropSubscriptionIdentifier 1,PropTopicAliasMaximum 552,PropReasonString -// "\212\137\tdr!\CAN\242=\136n\133\133\187\194\t\v\FSZ\203\130ll\188ue~\a\190",PropServerKeepAlive -// 9635,PropSharedSubscriptionAvailable 177,PropResponseInformation "",PropServerReference -// "\170\142\ETXA\234\237^\EOT\231V^\146\177W",PropResponseInformation "\SI",PropAuthenticationMethod -// "\140[\SYN\167\198\134y\167\156@4\193\&5",PropCorrelationData -// "\172\188\161\192=\EM\138\EMk\ETXy+\187\133\252?V\226\195T\231U\188\158n",PropSubscriptionIdentifier -// 0,PropSubscriptionIdentifierAvailable 143,PropTopicAlias 27154,PropResponseInformation -// "]?\146.\133d0\ETB~T\173\208\&6-\GS\139\204\222\152\139\SI",PropTopicAlias 11738,PropPayloadFormatIndicator -// 141,PropMessageExpiryInterval 387,PropMaximumQoS 113,PropServerReference -// "\196\229i\152\\u\\\184",PropResponseInformation "z~\184\148\230H^\186A\229\\\SUB\DEL\168\216\150"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\141\RSw\147`\NAK\ENQ\149f_Y\196\&3b\209U\150s\240\238\a\156\v\151~%\224P\244", _pubPktID = 0, _pubBody = +// "\220\213O", _pubProps = [PropReceiveMaximum 18322,PropRetainAvailable 119,PropReasonString +// "\175\180[\213\230/\203\DC3\173b\160^\DC2\201Y\185\129w\fXw",PropPayloadFormatIndicator 175,PropMaximumQoS +// 179,PropMaximumQoS 174,PropAssignedClientIdentifier "(\217\225\156\ACK",PropResponseTopic +// "\217L\191\252oU\FSl\212\FS\222\213\242\224I\ETB\SO",PropMaximumPacketSize 19484,PropReceiveMaximum +// 32000,PropAssignedClientIdentifier "*u\157f\233aI\237",PropTopicAlias 6311,PropMessageExpiryInterval +// 1640,PropReceiveMaximum 7468,PropMessageExpiryInterval 16489,PropSessionExpiryInterval 3774,PropServerKeepAlive +// 13402,PropTopicAliasMaximum 2331,PropWildcardSubscriptionAvailable 197,PropAuthenticationMethod +// "\206H\160T\197P\CAN\v",PropCorrelationData "\247x\201\224\234b\195\145/\203\192",PropSubscriptionIdentifier +// 19,PropMessageExpiryInterval 16517,PropMaximumPacketSize 20293,PropRequestProblemInformation 92]} TEST(Publish5QCTest, Encode8) { uint8_t pkt[] = { - 0x32, 0xb4, 0x2, 0x0, 0xf, 0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, - 0x1b, 0x16, 0x36, 0x8b, 0x2, 0x11, 0x0, 0x0, 0x54, 0x5b, 0x2a, 0x6, 0x1c, 0x0, 0x10, 0x9a, 0x86, 0x31, 0xd0, - 0x79, 0x2c, 0x4, 0xf9, 0xb9, 0xe8, 0x8d, 0x16, 0x5e, 0x84, 0x9e, 0xfe, 0x1f, 0x0, 0xd, 0xda, 0x2b, 0xb, 0x3, - 0x7e, 0xd4, 0x7, 0x63, 0x46, 0x4c, 0x55, 0x8a, 0xeb, 0x29, 0x67, 0x1a, 0x0, 0x1e, 0x42, 0xf7, 0xc, 0x4e, 0x55, - 0xaa, 0x36, 0x55, 0x8d, 0x10, 0x6d, 0x9a, 0xed, 0x79, 0x20, 0xc9, 0x3b, 0x7, 0xdf, 0x69, 0xa3, 0xa9, 0xb0, 0x1c, - 0xb, 0xe8, 0x80, 0xe3, 0x80, 0xf5, 0x19, 0xc7, 0x19, 0x6b, 0x21, 0x4d, 0x61, 0xb, 0x1, 0x22, 0x2, 0x28, 0x1f, - 0x0, 0x1d, 0xd4, 0x89, 0x9, 0x64, 0x72, 0x21, 0x18, 0xf2, 0x3d, 0x88, 0x6e, 0x85, 0x85, 0xbb, 0xc2, 0x9, 0xb, - 0x1c, 0x5a, 0xcb, 0x82, 0x6c, 0x6c, 0xbc, 0x75, 0x65, 0x7e, 0x7, 0xbe, 0x13, 0x25, 0xa3, 0x2a, 0xb1, 0x1a, 0x0, - 0x0, 0x1c, 0x0, 0xe, 0xaa, 0x8e, 0x3, 0x41, 0xea, 0xed, 0x5e, 0x4, 0xe7, 0x56, 0x5e, 0x92, 0xb1, 0x57, 0x1a, - 0x0, 0x1, 0xf, 0x15, 0x0, 0xd, 0x8c, 0x5b, 0x16, 0xa7, 0xc6, 0x86, 0x79, 0xa7, 0x9c, 0x40, 0x34, 0xc1, 0x35, - 0x9, 0x0, 0x19, 0xac, 0xbc, 0xa1, 0xc0, 0x3d, 0x19, 0x8a, 0x19, 0x6b, 0x3, 0x79, 0x2b, 0xbb, 0x85, 0xfc, 0x3f, - 0x56, 0xe2, 0xc3, 0x54, 0xe7, 0x55, 0xbc, 0x9e, 0x6e, 0xb, 0x0, 0x29, 0x8f, 0x23, 0x6a, 0x12, 0x1a, 0x0, 0x15, - 0x5d, 0x3f, 0x92, 0x2e, 0x85, 0x64, 0x30, 0x17, 0x7e, 0x54, 0xad, 0xd0, 0x36, 0x2d, 0x1d, 0x8b, 0xcc, 0xde, 0x98, - 0x8b, 0xf, 0x23, 0x2d, 0xda, 0x1, 0x8d, 0x2, 0x0, 0x0, 0x1, 0x83, 0x24, 0x71, 0x1c, 0x0, 0x8, 0xc4, 0xe5, - 0x69, 0x98, 0x5c, 0x75, 0x5c, 0xb8, 0x1a, 0x0, 0x10, 0x7a, 0x7e, 0xb8, 0x94, 0xe6, 0x48, 0x5e, 0xba, 0x41, 0xe5, - 0x5c, 0x1a, 0x7f, 0xa8, 0xd8, 0x96, 0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, 0xd1, 0x37, 0xe8, 0x63, 0x8f, 0xa4, - 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; - uint8_t topic_bytes[] = {0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, 0x1b}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + 0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_t topic_bytes[] = {0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, + 0x55, 0x96, 0x73, 0xf0, 0xee, 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, 0xd1, 0x37, 0xe8, - 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; + uint8_t msg_bytes[] = {0xdc, 0xd5, 0x4f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; - - uint8_t bytesprops0[] = {0x9a, 0x86, 0x31, 0xd0, 0x79, 0x2c, 0x4, 0xf9, - 0xb9, 0xe8, 0x8d, 0x16, 0x5e, 0x84, 0x9e, 0xfe}; - uint8_t bytesprops1[] = {0xda, 0x2b, 0xb, 0x3, 0x7e, 0xd4, 0x7, 0x63, 0x46, 0x4c, 0x55, 0x8a, 0xeb}; - uint8_t bytesprops2[] = {0x42, 0xf7, 0xc, 0x4e, 0x55, 0xaa, 0x36, 0x55, 0x8d, 0x10, 0x6d, 0x9a, 0xed, 0x79, 0x20, - 0xc9, 0x3b, 0x7, 0xdf, 0x69, 0xa3, 0xa9, 0xb0, 0x1c, 0xb, 0xe8, 0x80, 0xe3, 0x80, 0xf5}; - uint8_t bytesprops3[] = {0xd4, 0x89, 0x9, 0x64, 0x72, 0x21, 0x18, 0xf2, 0x3d, 0x88, 0x6e, 0x85, 0x85, 0xbb, 0xc2, - 0x9, 0xb, 0x1c, 0x5a, 0xcb, 0x82, 0x6c, 0x6c, 0xbc, 0x75, 0x65, 0x7e, 0x7, 0xbe}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0xaa, 0x8e, 0x3, 0x41, 0xea, 0xed, 0x5e, 0x4, 0xe7, 0x56, 0x5e, 0x92, 0xb1, 0x57}; - uint8_t bytesprops6[] = {0xf}; - uint8_t bytesprops7[] = {0x8c, 0x5b, 0x16, 0xa7, 0xc6, 0x86, 0x79, 0xa7, 0x9c, 0x40, 0x34, 0xc1, 0x35}; - uint8_t bytesprops8[] = {0xac, 0xbc, 0xa1, 0xc0, 0x3d, 0x19, 0x8a, 0x19, 0x6b, 0x3, 0x79, 0x2b, 0xbb, - 0x85, 0xfc, 0x3f, 0x56, 0xe2, 0xc3, 0x54, 0xe7, 0x55, 0xbc, 0x9e, 0x6e}; - uint8_t bytesprops9[] = {0x5d, 0x3f, 0x92, 0x2e, 0x85, 0x64, 0x30, 0x17, 0x7e, 0x54, 0xad, - 0xd0, 0x36, 0x2d, 0x1d, 0x8b, 0xcc, 0xde, 0x98, 0x8b, 0xf}; - uint8_t bytesprops10[] = {0xc4, 0xe5, 0x69, 0x98, 0x5c, 0x75, 0x5c, 0xb8}; - uint8_t bytesprops11[] = {0x7a, 0x7e, 0xb8, 0x94, 0xe6, 0x48, 0x5e, 0xba, - 0x41, 0xe5, 0x5c, 0x1a, 0x7f, 0xa8, 0xd8, 0x96}; + msg.payload_len = 3; + + uint8_t bytesprops0[] = {0xaf, 0xb4, 0x5b, 0xd5, 0xe6, 0x2f, 0xcb, 0x13, 0xad, 0x62, 0xa0, + 0x5e, 0x12, 0xc9, 0x59, 0xb9, 0x81, 0x77, 0xc, 0x58, 0x77}; + uint8_t bytesprops1[] = {0x28, 0xd9, 0xe1, 0x9c, 0x6}; + uint8_t bytesprops2[] = {0xd9, 0x4c, 0xbf, 0xfc, 0x6f, 0x55, 0x1c, 0x6c, 0xd4, + 0x1c, 0xde, 0xd5, 0xf2, 0xe0, 0x49, 0x17, 0xe}; + uint8_t bytesprops3[] = {0x2a, 0x75, 0x9d, 0x66, 0xe9, 0x61, 0x49, 0xed}; + uint8_t bytesprops4[] = {0xce, 0x48, 0xa0, 0x54, 0xc5, 0x50, 0x18, 0xb}; + uint8_t bytesprops5[] = {0xf7, 0x78, 0xc9, 0xe0, 0xea, 0x62, 0xc3, 0x91, 0x2f, 0xcb, 0xc0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21595}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19809}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 552}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9635}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27154}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11738}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 387}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18322}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19484}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32000}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6311}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1640}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7468}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16489}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3774}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13402}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2331}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16517}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20293}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 92}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 5686, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "(9fA\NAK\140\194;\215\236\145\SO\240#\ESC", _pubPktID = 5686, _pubBody = -// "\197\149\245\GS\f\206T\209\&7\232c\143\164A\177\DC3\r<.\ACK", _pubProps = [PropSessionExpiryInterval -// 21595,PropSharedSubscriptionAvailable 6,PropServerReference -// "\154\134\&1\208y,\EOT\249\185\232\141\SYN^\132\158\254",PropReasonString -// "\218+\v\ETX~\212\acFLU\138\235",PropSubscriptionIdentifierAvailable 103,PropResponseInformation -// "B\247\fNU\170\&6U\141\DLEm\154\237y -// \201;\a\223i\163\169\176\FS\v\232\128\227\128\245",PropRequestResponseInformation 199,PropRequestResponseInformation -// 107,PropReceiveMaximum 19809,PropSubscriptionIdentifier 1,PropTopicAliasMaximum 552,PropReasonString -// "\212\137\tdr!\CAN\242=\136n\133\133\187\194\t\v\FSZ\203\130ll\188ue~\a\190",PropServerKeepAlive -// 9635,PropSharedSubscriptionAvailable 177,PropResponseInformation "",PropServerReference -// "\170\142\ETXA\234\237^\EOT\231V^\146\177W",PropResponseInformation "\SI",PropAuthenticationMethod -// "\140[\SYN\167\198\134y\167\156@4\193\&5",PropCorrelationData -// "\172\188\161\192=\EM\138\EMk\ETXy+\187\133\252?V\226\195T\231U\188\158n",PropSubscriptionIdentifier -// 0,PropSubscriptionIdentifierAvailable 143,PropTopicAlias 27154,PropResponseInformation -// "]?\146.\133d0\ETB~T\173\208\&6-\GS\139\204\222\152\139\SI",PropTopicAlias 11738,PropPayloadFormatIndicator -// 141,PropMessageExpiryInterval 387,PropMaximumQoS 113,PropServerReference -// "\196\229i\152\\u\\\184",PropResponseInformation "z~\184\148\230H^\186A\229\\\SUB\DEL\168\216\150"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\141\RSw\147`\NAK\ENQ\149f_Y\196\&3b\209U\150s\240\238\a\156\v\151~%\224P\244", _pubPktID = 0, _pubBody = +// "\220\213O", _pubProps = [PropReceiveMaximum 18322,PropRetainAvailable 119,PropReasonString +// "\175\180[\213\230/\203\DC3\173b\160^\DC2\201Y\185\129w\fXw",PropPayloadFormatIndicator 175,PropMaximumQoS +// 179,PropMaximumQoS 174,PropAssignedClientIdentifier "(\217\225\156\ACK",PropResponseTopic +// "\217L\191\252oU\FSl\212\FS\222\213\242\224I\ETB\SO",PropMaximumPacketSize 19484,PropReceiveMaximum +// 32000,PropAssignedClientIdentifier "*u\157f\233aI\237",PropTopicAlias 6311,PropMessageExpiryInterval +// 1640,PropReceiveMaximum 7468,PropMessageExpiryInterval 16489,PropSessionExpiryInterval 3774,PropServerKeepAlive +// 13402,PropTopicAliasMaximum 2331,PropWildcardSubscriptionAvailable 197,PropAuthenticationMethod +// "\206H\160T\197P\CAN\v",PropCorrelationData "\247x\201\224\234b\195\145/\203\192",PropSubscriptionIdentifier +// 19,PropMessageExpiryInterval 16517,PropMaximumPacketSize 20293,PropRequestProblemInformation 92]} TEST(Publish5QCTest, Decode8) { u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 0xb9, 0x81, 0x77, 0xc, 0x58, 0x77, 0x1, 0xaf, 0x24, 0xb3, 0x24, 0xae, 0x12, 0x0, 0x5, 0x28, 0xd9, + 0xe1, 0x9c, 0x6, 0x8, 0x0, 0x11, 0xd9, 0x4c, 0xbf, 0xfc, 0x6f, 0x55, 0x1c, 0x6c, 0xd4, 0x1c, 0xde, 0xd5, 0xf2, + 0xe0, 0x49, 0x17, 0xe, 0x27, 0x0, 0x0, 0x4c, 0x1c, 0x21, 0x7d, 0x0, 0x12, 0x0, 0x8, 0x2a, 0x75, 0x9d, 0x66, + 0xe9, 0x61, 0x49, 0xed, 0x23, 0x18, 0xa7, 0x2, 0x0, 0x0, 0x6, 0x68, 0x21, 0x1d, 0x2c, 0x2, 0x0, 0x0, 0x40, + 0x69, 0x11, 0x0, 0x0, 0xe, 0xbe, 0x13, 0x34, 0x5a, 0x22, 0x9, 0x1b, 0x28, 0xc5, 0x15, 0x0, 0x8, 0xce, 0x48, + 0xa0, 0x54, 0xc5, 0x50, 0x18, 0xb, 0x9, 0x0, 0xb, 0xf7, 0x78, 0xc9, 0xe0, 0xea, 0x62, 0xc3, 0x91, 0x2f, 0xcb, + 0xc0, 0xb, 0x13, 0x2, 0x0, 0x0, 0x40, 0x85, 0x27, 0x0, 0x0, 0x4f, 0x45, 0x17, 0x5c, 0xdc, 0xd5, 0x4f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2619,163 +2624,92 @@ TEST(Publish5QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x28, 0x39, 0x66, 0x41, 0x15, 0x8c, 0xc2, 0x3b, 0xd7, 0xec, 0x91, 0xe, 0xf0, 0x23, 0x1b}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc5, 0x95, 0xf5, 0x1d, 0xc, 0xce, 0x54, 0xd1, 0x37, 0xe8, - 0x63, 0x8f, 0xa4, 0x41, 0xb1, 0x13, 0xd, 0x3c, 0x2e, 0x6}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, + 0x55, 0x96, 0x73, 0xf0, 0xee, 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xdc, 0xd5, 0x4f}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 5686); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\234\227\201xQ\221\GS\f\US\208(\t\212", _pubPktID = 0, _pubBody = -// "\140\174]d\t\144\158\DC2\237\196\202\147\133\154\231\176|1", _pubProps = [PropMessageExpiryInterval -// 14546,PropMessageExpiryInterval 14300,PropReasonString "\183j\173Z\222K",PropTopicAlias 24083,PropResponseInformation -// "\SO\161\227\DLE\141\173\DC4\149)\247\154\US\225L\231Y\195",PropTopicAlias 22040,PropRetainAvailable -// 145,PropUserProperty "8\169\225\228\231lk&\152\211" "\246)J\EOT\192F\210\254\223\253\210\141{R",PropCorrelationData " -// y\228\130\229i\164(p\134\186Uf\ENQ\144\191\171e",PropWillDelayInterval 26330,PropRequestResponseInformation -// 227,PropContentType ".0\SOH\SUB\249\250E\165\181\168\196\146Z\197\210H^N\218\&8\255\167",PropResponseTopic -// "\nG\189\167h[\246\161\194\227x\138\136L\156",PropSessionExpiryInterval 25383,PropAssignedClientIdentifier -// "@\168\149\DC1\ACK\v\220\169\221\168\241\209#*Yf\161\173\153\198\173\189\198\179",PropServerKeepAlive -// 7700,PropTopicAliasMaximum 24476,PropTopicAliasMaximum 11573,PropResponseInformation -// ":\ETX\US\246g\DLE\130\NUL#\171\138\210\ENQ\177\a\224m\130",PropUserProperty "\216A\239s\t\172\&7\156?" -// "\167\160\165\CAN\ENQ\212\&5(\138\245\DC2V'\184\203\RS\244\164\162\221\GSM\128k",PropResponseTopic -// "\150&\189F\170",PropServerKeepAlive 31478,PropAuthenticationData -// "\244:HY\215;\144\133\187\168\178&}%",PropAssignedClientIdentifier -// "\"\242N\178\b6\216NL\143\154",PropRequestResponseInformation 88]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\130\180J\210\214\ENQ\185\DC3T.\233,_\253N\188M\218\t\203\210\&9z\193w\227", _pubPktID = 5801, _pubBody = +// "e/2Y\147]W%\233\NUL\170j25\192", _pubProps = [PropUserProperty "+\173\131\ETX\156\246\222i\129\FS" +// "]\154C\131\170|\248P",PropContentType "\128\CAN\181Y",PropSubscriptionIdentifierAvailable +// 184,PropSharedSubscriptionAvailable 154,PropResponseInformation "!\174\152@#\171\248l\r\161\231\b4",PropTopicAlias +// 24162,PropResponseTopic +// "h\253\215\&3\165\155\178D\181\SO\SYNP\225\RS\175\226/\154\203\229\&9\205\132\225\203",PropMaximumQoS 62]} TEST(Publish5QCT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0xdd, 0xa8, 0xf1, 0xd1, 0x23, 0x2a, 0x59, - 0x66, 0xa1, 0xad, 0x99, 0xc6, 0xad, 0xbd, 0xc6, 0xb3, 0x13, 0x1e, 0x14, 0x22, 0x5f, 0x9c, 0x22, 0x2d, 0x35, 0x1a, - 0x0, 0x12, 0x3a, 0x3, 0x1f, 0xf6, 0x67, 0x10, 0x82, 0x0, 0x23, 0xab, 0x8a, 0xd2, 0x5, 0xb1, 0x7, 0xe0, 0x6d, - 0x82, 0x26, 0x0, 0x9, 0xd8, 0x41, 0xef, 0x73, 0x9, 0xac, 0x37, 0x9c, 0x3f, 0x0, 0x18, 0xa7, 0xa0, 0xa5, 0x18, - 0x5, 0xd4, 0x35, 0x28, 0x8a, 0xf5, 0x12, 0x56, 0x27, 0xb8, 0xcb, 0x1e, 0xf4, 0xa4, 0xa2, 0xdd, 0x1d, 0x4d, 0x80, - 0x6b, 0x8, 0x0, 0x5, 0x96, 0x26, 0xbd, 0x46, 0xaa, 0x13, 0x7a, 0xf6, 0x16, 0x0, 0xe, 0xf4, 0x3a, 0x48, 0x59, - 0xd7, 0x3b, 0x90, 0x85, 0xbb, 0xa8, 0xb2, 0x26, 0x7d, 0x25, 0x12, 0x0, 0xb, 0x22, 0xf2, 0x4e, 0xb2, 0x8, 0x36, - 0xd8, 0x4e, 0x4c, 0x8f, 0x9a, 0x19, 0x58, 0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, 0xc4, 0xca, 0x93, - 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; - uint8_t topic_bytes[] = {0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, 0x1f, 0xd0, 0x28, 0x9, 0xd4}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x81, 0x1, 0x0, 0x1a, 0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, + 0x5f, 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3, 0x16, 0xa9, 0x53, + 0x26, 0x0, 0xa, 0x2b, 0xad, 0x83, 0x3, 0x9c, 0xf6, 0xde, 0x69, 0x81, 0x1c, 0x0, 0x8, 0x5d, 0x9a, + 0x43, 0x83, 0xaa, 0x7c, 0xf8, 0x50, 0x3, 0x0, 0x4, 0x80, 0x18, 0xb5, 0x59, 0x29, 0xb8, 0x2a, 0x9a, + 0x1a, 0x0, 0xd, 0x21, 0xae, 0x98, 0x40, 0x23, 0xab, 0xf8, 0x6c, 0xd, 0xa1, 0xe7, 0x8, 0x34, 0x23, + 0x5e, 0x62, 0x8, 0x0, 0x19, 0x68, 0xfd, 0xd7, 0x33, 0xa5, 0x9b, 0xb2, 0x44, 0xb5, 0xe, 0x16, 0x50, + 0xe1, 0x1e, 0xaf, 0xe2, 0x2f, 0x9a, 0xcb, 0xe5, 0x39, 0xcd, 0x84, 0xe1, 0xcb, 0x24, 0x3e, 0x65, 0x2f, + 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; + uint8_t topic_bytes[] = {0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, 0x5f, + 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, - 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; + uint8_t msg_bytes[] = {0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; - - uint8_t bytesprops0[] = {0xb7, 0x6a, 0xad, 0x5a, 0xde, 0x4b}; - uint8_t bytesprops1[] = {0xe, 0xa1, 0xe3, 0x10, 0x8d, 0xad, 0x14, 0x95, 0x29, - 0xf7, 0x9a, 0x1f, 0xe1, 0x4c, 0xe7, 0x59, 0xc3}; - uint8_t bytesprops3[] = {0xf6, 0x29, 0x4a, 0x4, 0xc0, 0x46, 0xd2, 0xfe, 0xdf, 0xfd, 0xd2, 0x8d, 0x7b, 0x52}; - uint8_t bytesprops2[] = {0x38, 0xa9, 0xe1, 0xe4, 0xe7, 0x6c, 0x6b, 0x26, 0x98, 0xd3}; - uint8_t bytesprops4[] = {0x20, 0x79, 0xe4, 0x82, 0xe5, 0x69, 0xa4, 0x28, 0x70, - 0x86, 0xba, 0x55, 0x66, 0x5, 0x90, 0xbf, 0xab, 0x65}; - uint8_t bytesprops5[] = {0x2e, 0x30, 0x1, 0x1a, 0xf9, 0xfa, 0x45, 0xa5, 0xb5, 0xa8, 0xc4, - 0x92, 0x5a, 0xc5, 0xd2, 0x48, 0x5e, 0x4e, 0xda, 0x38, 0xff, 0xa7}; - uint8_t bytesprops6[] = {0xa, 0x47, 0xbd, 0xa7, 0x68, 0x5b, 0xf6, 0xa1, 0xc2, 0xe3, 0x78, 0x8a, 0x88, 0x4c, 0x9c}; - uint8_t bytesprops7[] = {0x40, 0xa8, 0x95, 0x11, 0x6, 0xb, 0xdc, 0xa9, 0xdd, 0xa8, 0xf1, 0xd1, - 0x23, 0x2a, 0x59, 0x66, 0xa1, 0xad, 0x99, 0xc6, 0xad, 0xbd, 0xc6, 0xb3}; - uint8_t bytesprops8[] = {0x3a, 0x3, 0x1f, 0xf6, 0x67, 0x10, 0x82, 0x0, 0x23, - 0xab, 0x8a, 0xd2, 0x5, 0xb1, 0x7, 0xe0, 0x6d, 0x82}; - uint8_t bytesprops10[] = {0xa7, 0xa0, 0xa5, 0x18, 0x5, 0xd4, 0x35, 0x28, 0x8a, 0xf5, 0x12, 0x56, - 0x27, 0xb8, 0xcb, 0x1e, 0xf4, 0xa4, 0xa2, 0xdd, 0x1d, 0x4d, 0x80, 0x6b}; - uint8_t bytesprops9[] = {0xd8, 0x41, 0xef, 0x73, 0x9, 0xac, 0x37, 0x9c, 0x3f}; - uint8_t bytesprops11[] = {0x96, 0x26, 0xbd, 0x46, 0xaa}; - uint8_t bytesprops12[] = {0xf4, 0x3a, 0x48, 0x59, 0xd7, 0x3b, 0x90, 0x85, 0xbb, 0xa8, 0xb2, 0x26, 0x7d, 0x25}; - uint8_t bytesprops13[] = {0x22, 0xf2, 0x4e, 0xb2, 0x8, 0x36, 0xd8, 0x4e, 0x4c, 0x8f, 0x9a}; + msg.payload_len = 15; + + uint8_t bytesprops1[] = {0x5d, 0x9a, 0x43, 0x83, 0xaa, 0x7c, 0xf8, 0x50}; + uint8_t bytesprops0[] = {0x2b, 0xad, 0x83, 0x3, 0x9c, 0xf6, 0xde, 0x69, 0x81, 0x1c}; + uint8_t bytesprops2[] = {0x80, 0x18, 0xb5, 0x59}; + uint8_t bytesprops3[] = {0x21, 0xae, 0x98, 0x40, 0x23, 0xab, 0xf8, 0x6c, 0xd, 0xa1, 0xe7, 0x8, 0x34}; + uint8_t bytesprops4[] = {0x68, 0xfd, 0xd7, 0x33, 0xa5, 0x9b, 0xb2, 0x44, 0xb5, 0xe, 0x16, 0x50, 0xe1, + 0x1e, 0xaf, 0xe2, 0x2f, 0x9a, 0xcb, 0xe5, 0x39, 0xcd, 0x84, 0xe1, 0xcb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14546}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14300}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24083}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22040}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {14, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26330}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25383}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7700}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24476}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11573}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops9}, .v = {24, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31478}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24162}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 62}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5801, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\234\227\201xQ\221\GS\f\US\208(\t\212", _pubPktID = 0, _pubBody = -// "\140\174]d\t\144\158\DC2\237\196\202\147\133\154\231\176|1", _pubProps = [PropMessageExpiryInterval -// 14546,PropMessageExpiryInterval 14300,PropReasonString "\183j\173Z\222K",PropTopicAlias 24083,PropResponseInformation -// "\SO\161\227\DLE\141\173\DC4\149)\247\154\US\225L\231Y\195",PropTopicAlias 22040,PropRetainAvailable -// 145,PropUserProperty "8\169\225\228\231lk&\152\211" "\246)J\EOT\192F\210\254\223\253\210\141{R",PropCorrelationData " -// y\228\130\229i\164(p\134\186Uf\ENQ\144\191\171e",PropWillDelayInterval 26330,PropRequestResponseInformation -// 227,PropContentType ".0\SOH\SUB\249\250E\165\181\168\196\146Z\197\210H^N\218\&8\255\167",PropResponseTopic -// "\nG\189\167h[\246\161\194\227x\138\136L\156",PropSessionExpiryInterval 25383,PropAssignedClientIdentifier -// "@\168\149\DC1\ACK\v\220\169\221\168\241\209#*Yf\161\173\153\198\173\189\198\179",PropServerKeepAlive -// 7700,PropTopicAliasMaximum 24476,PropTopicAliasMaximum 11573,PropResponseInformation -// ":\ETX\US\246g\DLE\130\NUL#\171\138\210\ENQ\177\a\224m\130",PropUserProperty "\216A\239s\t\172\&7\156?" -// "\167\160\165\CAN\ENQ\212\&5(\138\245\DC2V'\184\203\RS\244\164\162\221\GSM\128k",PropResponseTopic -// "\150&\189F\170",PropServerKeepAlive 31478,PropAuthenticationData -// "\244:HY\215;\144\133\187\168\178&}%",PropAssignedClientIdentifier -// "\"\242N\178\b6\216NL\143\154",PropRequestResponseInformation 88]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\130\180J\210\214\ENQ\185\DC3T.\233,_\253N\188M\218\t\203\210\&9z\193w\227", _pubPktID = 5801, _pubBody = +// "e/2Y\147]W%\233\NUL\170j25\192", _pubProps = [PropUserProperty "+\173\131\ETX\156\246\222i\129\FS" +// "]\154C\131\170|\248P",PropContentType "\128\CAN\181Y",PropSubscriptionIdentifierAvailable +// 184,PropSharedSubscriptionAvailable 154,PropResponseInformation "!\174\152@#\171\248l\r\161\231\b4",PropTopicAlias +// 24162,PropResponseTopic +// "h\253\215\&3\165\155\178D\181\SO\SYNP\225\RS\175\226/\154\203\229\&9\205\132\225\203",PropMaximumQoS 62]} TEST(Publish5QCTest, Decode9) { - uint8_t pkt[] = { - 0x38, 0xc6, 0x2, 0x0, 0xd, 0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, 0x1f, 0xd0, 0x28, 0x9, 0xd4, 0xa3, - 0x2, 0x2, 0x0, 0x0, 0x38, 0xd2, 0x2, 0x0, 0x0, 0x37, 0xdc, 0x1f, 0x0, 0x6, 0xb7,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0x40, 0x23, 0xab, 0xf8, 0x6c, 0xd, 0xa1, 0xe7, 0x8, 0x34, 0x23, + 0x5e, 0x62, 0x8, 0x0, 0x19, 0x68, 0xfd, 0xd7, 0x33, 0xa5, 0x9b, 0xb2, 0x44, 0xb5, 0xe, 0x16, 0x50, + 0xe1, 0x1e, 0xaf, 0xe2, 0x2f, 0x9a, 0xcb, 0xe5, 0x39, 0xcd, 0x84, 0xe1, 0xcb, 0x24, 0x3e, 0x65, 0x2f, + 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2784,116 +2718,90 @@ TEST(Publish5QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xea, 0xe3, 0xc9, 0x78, 0x51, 0xdd, 0x1d, 0xc, 0x1f, 0xd0, 0x28, 0x9, 0xd4}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8c, 0xae, 0x5d, 0x64, 0x9, 0x90, 0x9e, 0x12, 0xed, - 0xc4, 0xca, 0x93, 0x85, 0x9a, 0xe7, 0xb0, 0x7c, 0x31}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, 0x5f, + 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + EXPECT_EQ(packet_id, 5801); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\SYNr\142QB1\171\213)1\210q\199\"\203\225\251\233[&p\202\238", _pubPktID = 17787, _pubBody = -// "\172\FS\186\216A\244\EOT^<\NAK\136\187\235\ESC\245\209\128", _pubProps = [PropResponseTopic -// "\130\&8\141\184\169\181_\254\142]",PropRetainAvailable 44,PropReasonString -// "q1\241U\133\181\218\238h\GS\156\202\198\194\201\&8\165oH\150t~\201\171\CAN",PropPayloadFormatIndicator -// 21,PropMessageExpiryInterval 32507,PropRetainAvailable 215,PropReceiveMaximum 5188,PropRequestProblemInformation -// 160,PropResponseTopic "\150u1+\204\230m\145\172\230\243\246\EOTuB\US",PropWildcardSubscriptionAvailable -// 2,PropServerReference "\145\\\206+\172\143;\192",PropContentType "\ETB\225\142{\aEn\ACK",PropMessageExpiryInterval -// 19133,PropRequestResponseInformation 0,PropRequestProblemInformation 49,PropAssignedClientIdentifier -// "b\206\190\f\EM\SO\232\FS[\173\189_\201m\220",PropRequestResponseInformation 131]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "$hC\136_\134&\134\182\244\211M\211a\221[", _pubPktID = 25662, _pubBody = "", _pubProps = [PropAuthenticationData +// "\255b\ENQ\STX\nb\133\169\184\SI\143\EM^\SYN\165\207I\209\221\170\174\217",PropSharedSubscriptionAvailable +// 63,PropSessionExpiryInterval 27183,PropWillDelayInterval 524,PropSharedSubscriptionAvailable +// 96,PropRequestProblemInformation 230,PropTopicAliasMaximum 5870,PropReasonString +// "\156T\166",PropMessageExpiryInterval 5899,PropMessageExpiryInterval 9209,PropWillDelayInterval +// 6888,PropReceiveMaximum 2826,PropRequestResponseInformation 52]} TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = {0x32, 0xaf, 0x1, 0x0, 0x17, 0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, - 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee, 0x45, 0x7b, 0x81, 0x1, 0x8, 0x0, - 0xa, 0x82, 0x38, 0x8d, 0xb8, 0xa9, 0xb5, 0x5f, 0xfe, 0x8e, 0x5d, 0x25, 0x2c, 0x1f, 0x0, 0x19, 0x71, - 0x31, 0xf1, 0x55, 0x85, 0xb5, 0xda, 0xee, 0x68, 0x1d, 0x9c, 0xca, 0xc6, 0xc2, 0xc9, 0x38, 0xa5, 0x6f, - 0x48, 0x96, 0x74, 0x7e, 0xc9, 0xab, 0x18, 0x1, 0x15, 0x2, 0x0, 0x0, 0x7e, 0xfb, 0x25, 0xd7, 0x21, - 0x14, 0x44, 0x17, 0xa0, 0x8, 0x0, 0x10, 0x96, 0x75, 0x31, 0x2b, 0xcc, 0xe6, 0x6d, 0x91, 0xac, 0xe6, - 0xf3, 0xf6, 0x4, 0x75, 0x42, 0x1f, 0x28, 0x2, 0x1c, 0x0, 0x8, 0x91, 0x5c, 0xce, 0x2b, 0xac, 0x8f, - 0x3b, 0xc0, 0x3, 0x0, 0x8, 0x17, 0xe1, 0x8e, 0x7b, 0x7, 0x45, 0x6e, 0x6, 0x2, 0x0, 0x0, 0x4a, - 0xbd, 0x19, 0x0, 0x17, 0x31, 0x12, 0x0, 0xf, 0x62, 0xce, 0xbe, 0xc, 0x19, 0xe, 0xe8, 0x1c, 0x5b, - 0xad, 0xbd, 0x5f, 0xc9, 0x6d, 0xdc, 0x19, 0x83, 0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, - 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; - uint8_t topic_bytes[] = {0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, - 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x5b, 0x0, 0x10, 0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, 0xb6, 0xf4, 0xd3, 0x4d, + 0xd3, 0x61, 0xdd, 0x5b, 0x64, 0x3e, 0x46, 0x16, 0x0, 0x16, 0xff, 0x62, 0x5, 0x2, 0xa, 0x62, + 0x85, 0xa9, 0xb8, 0xf, 0x8f, 0x19, 0x5e, 0x16, 0xa5, 0xcf, 0x49, 0xd1, 0xdd, 0xaa, 0xae, 0xd9, + 0x2a, 0x3f, 0x11, 0x0, 0x0, 0x6a, 0x2f, 0x18, 0x0, 0x0, 0x2, 0xc, 0x2a, 0x60, 0x17, 0xe6, + 0x22, 0x16, 0xee, 0x1f, 0x0, 0x3, 0x9c, 0x54, 0xa6, 0x2, 0x0, 0x0, 0x17, 0xb, 0x2, 0x0, + 0x0, 0x23, 0xf9, 0x18, 0x0, 0x0, 0x1a, 0xe8, 0x21, 0xb, 0xa, 0x19, 0x34}; + uint8_t topic_bytes[] = {0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, + 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, - 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 0; - uint8_t bytesprops0[] = {0x82, 0x38, 0x8d, 0xb8, 0xa9, 0xb5, 0x5f, 0xfe, 0x8e, 0x5d}; - uint8_t bytesprops1[] = {0x71, 0x31, 0xf1, 0x55, 0x85, 0xb5, 0xda, 0xee, 0x68, 0x1d, 0x9c, 0xca, 0xc6, - 0xc2, 0xc9, 0x38, 0xa5, 0x6f, 0x48, 0x96, 0x74, 0x7e, 0xc9, 0xab, 0x18}; - uint8_t bytesprops2[] = {0x96, 0x75, 0x31, 0x2b, 0xcc, 0xe6, 0x6d, 0x91, - 0xac, 0xe6, 0xf3, 0xf6, 0x4, 0x75, 0x42, 0x1f}; - uint8_t bytesprops3[] = {0x91, 0x5c, 0xce, 0x2b, 0xac, 0x8f, 0x3b, 0xc0}; - uint8_t bytesprops4[] = {0x17, 0xe1, 0x8e, 0x7b, 0x7, 0x45, 0x6e, 0x6}; - uint8_t bytesprops5[] = {0x62, 0xce, 0xbe, 0xc, 0x19, 0xe, 0xe8, 0x1c, 0x5b, 0xad, 0xbd, 0x5f, 0xc9, 0x6d, 0xdc}; + uint8_t bytesprops0[] = {0xff, 0x62, 0x5, 0x2, 0xa, 0x62, 0x85, 0xa9, 0xb8, 0xf, 0x8f, + 0x19, 0x5e, 0x16, 0xa5, 0xcf, 0x49, 0xd1, 0xdd, 0xaa, 0xae, 0xd9}; + uint8_t bytesprops1[] = {0x9c, 0x54, 0xa6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32507}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5188}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19133}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27183}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 524}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5870}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5899}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9209}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6888}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2826}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 52}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17787, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25662, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\SYNr\142QB1\171\213)1\210q\199\"\203\225\251\233[&p\202\238", _pubPktID = 17787, _pubBody = -// "\172\FS\186\216A\244\EOT^<\NAK\136\187\235\ESC\245\209\128", _pubProps = [PropResponseTopic -// "\130\&8\141\184\169\181_\254\142]",PropRetainAvailable 44,PropReasonString -// "q1\241U\133\181\218\238h\GS\156\202\198\194\201\&8\165oH\150t~\201\171\CAN",PropPayloadFormatIndicator -// 21,PropMessageExpiryInterval 32507,PropRetainAvailable 215,PropReceiveMaximum 5188,PropRequestProblemInformation -// 160,PropResponseTopic "\150u1+\204\230m\145\172\230\243\246\EOTuB\US",PropWildcardSubscriptionAvailable -// 2,PropServerReference "\145\\\206+\172\143;\192",PropContentType "\ETB\225\142{\aEn\ACK",PropMessageExpiryInterval -// 19133,PropRequestResponseInformation 0,PropRequestProblemInformation 49,PropAssignedClientIdentifier -// "b\206\190\f\EM\SO\232\FS[\173\189_\201m\220",PropRequestResponseInformation 131]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "$hC\136_\134&\134\182\244\211M\211a\221[", _pubPktID = 25662, _pubBody = "", _pubProps = [PropAuthenticationData +// "\255b\ENQ\STX\nb\133\169\184\SI\143\EM^\SYN\165\207I\209\221\170\174\217",PropSharedSubscriptionAvailable +// 63,PropSessionExpiryInterval 27183,PropWillDelayInterval 524,PropSharedSubscriptionAvailable +// 96,PropRequestProblemInformation 230,PropTopicAliasMaximum 5870,PropReasonString +// "\156T\166",PropMessageExpiryInterval 5899,PropMessageExpiryInterval 9209,PropWillDelayInterval +// 6888,PropReceiveMaximum 2826,PropRequestResponseInformation 52]} TEST(Publish5QCTest, Decode10) { - uint8_t pkt[] = {0x32, 0xaf, 0x1, 0x0, 0x17, 0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, - 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee, 0x45, 0x7b, 0x81, 0x1, 0x8, 0x0, - 0xa, 0x82, 0x38, 0x8d, 0xb8, 0xa9, 0xb5, 0x5f, 0xfe, 0x8e, 0x5d, 0x25, 0x2c, 0x1f, 0x0, 0x19, 0x71, - 0x31, 0xf1, 0x55, 0x85, 0xb5, 0xda, 0xee, 0x68, 0x1d, 0x9c, 0xca, 0xc6, 0xc2, 0xc9, 0x38, 0xa5, 0x6f, - 0x48, 0x96, 0x74, 0x7e, 0xc9, 0xab, 0x18, 0x1, 0x15, 0x2, 0x0, 0x0, 0x7e, 0xfb, 0x25, 0xd7, 0x21, - 0x14, 0x44, 0x17, 0xa0, 0x8, 0x0, 0x10, 0x96, 0x75, 0x31, 0x2b, 0xcc, 0xe6, 0x6d, 0x91, 0xac, 0xe6, - 0xf3, 0xf6, 0x4, 0x75, 0x42, 0x1f, 0x28, 0x2, 0x1c, 0x0, 0x8, 0x91, 0x5c, 0xce, 0x2b, 0xac, 0x8f, - 0x3b, 0xc0, 0x3, 0x0, 0x8, 0x17, 0xe1, 0x8e, 0x7b, 0x7, 0x45, 0x6e, 0x6, 0x2, 0x0, 0x0, 0x4a, - 0xbd, 0x19, 0x0, 0x17, 0x31, 0x12, 0x0, 0xf, 0x62, 0xce, 0xbe, 0xc, 0x19, 0xe, 0xe8, 0x1c, 0x5b, - 0xad, 0xbd, 0x5f, 0xc9, 0x6d, 0xdc, 0x19, 0x83, 0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, - 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; + uint8_t pkt[] = {0x3c, 0x5b, 0x0, 0x10, 0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, 0xb6, 0xf4, 0xd3, 0x4d, + 0xd3, 0x61, 0xdd, 0x5b, 0x64, 0x3e, 0x46, 0x16, 0x0, 0x16, 0xff, 0x62, 0x5, 0x2, 0xa, 0x62, + 0x85, 0xa9, 0xb8, 0xf, 0x8f, 0x19, 0x5e, 0x16, 0xa5, 0xcf, 0x49, 0xd1, 0xdd, 0xaa, 0xae, 0xd9, + 0x2a, 0x3f, 0x11, 0x0, 0x0, 0x6a, 0x2f, 0x18, 0x0, 0x0, 0x2, 0xc, 0x2a, 0x60, 0x17, 0xe6, + 0x22, 0x16, 0xee, 0x1f, 0x0, 0x3, 0x9c, 0x54, 0xa6, 0x2, 0x0, 0x0, 0x17, 0xb, 0x2, 0x0, + 0x0, 0x23, 0xf9, 0x18, 0x0, 0x0, 0x1a, 0xe8, 0x21, 0xb, 0xa, 0x19, 0x34}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2902,77 +2810,145 @@ TEST(Publish5QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x16, 0x72, 0x8e, 0x51, 0x42, 0x31, 0xab, 0xd5, 0x29, 0x31, 0xd2, 0x71, - 0xc7, 0x22, 0xcb, 0xe1, 0xfb, 0xe9, 0x5b, 0x26, 0x70, 0xca, 0xee}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xac, 0x1c, 0xba, 0xd8, 0x41, 0xf4, 0x4, 0x5e, 0x3c, - 0x15, 0x88, 0xbb, 0xeb, 0x1b, 0xf5, 0xd1, 0x80}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, + 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b}; + lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 17787); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(packet_id, 25662); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "e", _pubPktID = 29287, _pubBody = -// "o\220=\DLE\237\181\219\FS\ESC%~\198\SYN/{P", _pubProps = [PropContentType "",PropWildcardSubscriptionAvailable -// 8,PropTopicAlias 2941,PropServerReference ">\164*\219\172\189C~\219\a\236X\ESCS\140K\SYN2.",PropAuthenticationData -// "\143\202bO\250Z \196A\"L\218\ESC\235{B"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\181\165\155@\151\196\153>\212\208\158e;\229\178\rW&", _pubPktID = 28678, _pubBody = +// "\197b\187\ACKO^\130\182\SI\241\185\141\n\187P", _pubProps = [PropReceiveMaximum 12673,PropMaximumPacketSize +// 3493,PropMaximumQoS 123,PropMessageExpiryInterval 17483,PropServerReference +// "\DEL\ESCn6\193\n(\153L6MThmB\NAK{\212\186\244\223\"\135\f\130",PropResponseTopic +// ".\ESCC\CANS\210\173i\158i\248|'!",PropMessageExpiryInterval 2389,PropSubscriptionIdentifier 33,PropServerKeepAlive +// 31451,PropServerReference "\177\ETB\255p\144u\190}\SIx\ETX&c]\198\b\214(\220b\134\172`",PropMaximumQoS +// 23,PropResponseInformation "\194\194\GS",PropMessageExpiryInterval 32044,PropAuthenticationData +// "\184f\226",PropResponseTopic "\142\185\246\137\"\204",PropMaximumPacketSize 32478,PropReasonString +// "d\212\208\206?",PropResponseInformation "\SOH\ACK\234z\206G+s\241\\+x\158\214\199\"",PropCorrelationData +// "\150\247\181\210K\208`\229\174\&1!\167,`",PropUserProperty "\223WA" "\232\148",PropTopicAliasMaximum +// 10581,PropAuthenticationMethod "b\164",PropCorrelationData "\154\223!_\216\254S\209\218\"\210",PropCorrelationData +// "?J\163\161\173q\187\225Z\159"]} TEST(Publish5QCTest, Encode11) { - uint8_t pkt[] = {0x33, 0x47, 0x0, 0x1, 0x65, 0x72, 0x67, 0x31, 0x3, 0x0, 0x0, 0x28, 0x8, 0x23, 0xb, - 0x7d, 0x1c, 0x0, 0x13, 0x3e, 0xa4, 0x2a, 0xdb, 0xac, 0xbd, 0x43, 0x7e, 0xdb, 0x7, 0xec, - 0x58, 0x1b, 0x53, 0x8c, 0x4b, 0x16, 0x32, 0x2e, 0x16, 0x0, 0x10, 0x8f, 0xca, 0x62, 0x4f, - 0xfa, 0x5a, 0x20, 0xc4, 0x41, 0x22, 0x4c, 0xda, 0x1b, 0xeb, 0x7b, 0x42, 0x6f, 0xdc, 0x3d, - 0x10, 0xed, 0xb5, 0xdb, 0x1c, 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; - uint8_t topic_bytes[] = {0x65}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x32, 0x81, 0x2, 0x0, 0x12, 0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, 0xd0, 0x9e, 0x65, 0x3b, 0xe5, + 0xb2, 0xd, 0x57, 0x26, 0x70, 0x6, 0xda, 0x1, 0x21, 0x31, 0x81, 0x27, 0x0, 0x0, 0xd, 0xa5, 0x24, 0x7b, 0x2, + 0x0, 0x0, 0x44, 0x4b, 0x1c, 0x0, 0x19, 0x7f, 0x1b, 0x6e, 0x36, 0xc1, 0xa, 0x28, 0x99, 0x4c, 0x36, 0x4d, 0x54, + 0x68, 0x6d, 0x42, 0x15, 0x7b, 0xd4, 0xba, 0xf4, 0xdf, 0x22, 0x87, 0xc, 0x82, 0x8, 0x0, 0xe, 0x2e, 0x1b, 0x43, + 0x18, 0x53, 0xd2, 0xad, 0x69, 0x9e, 0x69, 0xf8, 0x7c, 0x27, 0x21, 0x2, 0x0, 0x0, 0x9, 0x55, 0xb, 0x21, 0x13, + 0x7a, 0xdb, 0x1c, 0x0, 0x17, 0xb1, 0x17, 0xff, 0x70, 0x90, 0x75, 0xbe, 0x7d, 0xf, 0x78, 0x3, 0x26, 0x63, 0x5d, + 0xc6, 0x8, 0xd6, 0x28, 0xdc, 0x62, 0x86, 0xac, 0x60, 0x24, 0x17, 0x1a, 0x0, 0x3, 0xc2, 0xc2, 0x1d, 0x2, 0x0, + 0x0, 0x7d, 0x2c, 0x16, 0x0, 0x3, 0xb8, 0x66, 0xe2, 0x8, 0x0, 0x6, 0x8e, 0xb9, 0xf6, 0x89, 0x22, 0xcc, 0x27, + 0x0, 0x0, 0x7e, 0xde, 0x1f, 0x0, 0x5, 0x64, 0xd4, 0xd0, 0xce, 0x3f, 0x1a, 0x0, 0x10, 0x1, 0x6, 0xea, 0x7a, + 0xce, 0x47, 0x2b, 0x73, 0xf1, 0x5c, 0x2b, 0x78, 0x9e, 0xd6, 0xc7, 0x22, 0x9, 0x0, 0xe, 0x96, 0xf7, 0xb5, 0xd2, + 0x4b, 0xd0, 0x60, 0xe5, 0xae, 0x31, 0x21, 0xa7, 0x2c, 0x60, 0x26, 0x0, 0x3, 0xdf, 0x57, 0x41, 0x0, 0x2, 0xe8, + 0x94, 0x22, 0x29, 0x55, 0x15, 0x0, 0x2, 0x62, 0xa4, 0x9, 0x0, 0xb, 0x9a, 0xdf, 0x21, 0x5f, 0xd8, 0xfe, 0x53, + 0xd1, 0xda, 0x22, 0xd2, 0x9, 0x0, 0xa, 0x3f, 0x4a, 0xa3, 0xa1, 0xad, 0x71, 0xbb, 0xe1, 0x5a, 0x9f, 0xc5, 0x62, + 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; + uint8_t topic_bytes[] = {0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, + 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x6f, 0xdc, 0x3d, 0x10, 0xed, 0xb5, 0xdb, 0x1c, - 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; + msg.retained = false; + uint8_t msg_bytes[] = {0xc5, 0x62, 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; - - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x3e, 0xa4, 0x2a, 0xdb, 0xac, 0xbd, 0x43, 0x7e, 0xdb, 0x7, - 0xec, 0x58, 0x1b, 0x53, 0x8c, 0x4b, 0x16, 0x32, 0x2e}; - uint8_t bytesprops2[] = {0x8f, 0xca, 0x62, 0x4f, 0xfa, 0x5a, 0x20, 0xc4, - 0x41, 0x22, 0x4c, 0xda, 0x1b, 0xeb, 0x7b, 0x42}; + msg.payload_len = 15; + + uint8_t bytesprops0[] = {0x7f, 0x1b, 0x6e, 0x36, 0xc1, 0xa, 0x28, 0x99, 0x4c, 0x36, 0x4d, 0x54, 0x68, + 0x6d, 0x42, 0x15, 0x7b, 0xd4, 0xba, 0xf4, 0xdf, 0x22, 0x87, 0xc, 0x82}; + uint8_t bytesprops1[] = {0x2e, 0x1b, 0x43, 0x18, 0x53, 0xd2, 0xad, 0x69, 0x9e, 0x69, 0xf8, 0x7c, 0x27, 0x21}; + uint8_t bytesprops2[] = {0xb1, 0x17, 0xff, 0x70, 0x90, 0x75, 0xbe, 0x7d, 0xf, 0x78, 0x3, 0x26, + 0x63, 0x5d, 0xc6, 0x8, 0xd6, 0x28, 0xdc, 0x62, 0x86, 0xac, 0x60}; + uint8_t bytesprops3[] = {0xc2, 0xc2, 0x1d}; + uint8_t bytesprops4[] = {0xb8, 0x66, 0xe2}; + uint8_t bytesprops5[] = {0x8e, 0xb9, 0xf6, 0x89, 0x22, 0xcc}; + uint8_t bytesprops6[] = {0x64, 0xd4, 0xd0, 0xce, 0x3f}; + uint8_t bytesprops7[] = {0x1, 0x6, 0xea, 0x7a, 0xce, 0x47, 0x2b, 0x73, + 0xf1, 0x5c, 0x2b, 0x78, 0x9e, 0xd6, 0xc7, 0x22}; + uint8_t bytesprops8[] = {0x96, 0xf7, 0xb5, 0xd2, 0x4b, 0xd0, 0x60, 0xe5, 0xae, 0x31, 0x21, 0xa7, 0x2c, 0x60}; + uint8_t bytesprops10[] = {0xe8, 0x94}; + uint8_t bytesprops9[] = {0xdf, 0x57, 0x41}; + uint8_t bytesprops11[] = {0x62, 0xa4}; + uint8_t bytesprops12[] = {0x9a, 0xdf, 0x21, 0x5f, 0xd8, 0xfe, 0x53, 0xd1, 0xda, 0x22, 0xd2}; + uint8_t bytesprops13[] = {0x3f, 0x4a, 0xa3, 0xa1, 0xad, 0x71, 0xbb, 0xe1, 0x5a, 0x9f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2941}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12673}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3493}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17483}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2389}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 33}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31451}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32044}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32478}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops9}, .v = {2, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10581}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops13}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29287, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 28678, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "e", _pubPktID = 29287, _pubBody = -// "o\220=\DLE\237\181\219\FS\ESC%~\198\SYN/{P", _pubProps = [PropContentType "",PropWildcardSubscriptionAvailable -// 8,PropTopicAlias 2941,PropServerReference ">\164*\219\172\189C~\219\a\236X\ESCS\140K\SYN2.",PropAuthenticationData -// "\143\202bO\250Z \196A\"L\218\ESC\235{B"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\181\165\155@\151\196\153>\212\208\158e;\229\178\rW&", _pubPktID = 28678, _pubBody = +// "\197b\187\ACKO^\130\182\SI\241\185\141\n\187P", _pubProps = [PropReceiveMaximum 12673,PropMaximumPacketSize +// 3493,PropMaximumQoS 123,PropMessageExpiryInterval 17483,PropServerReference +// "\DEL\ESCn6\193\n(\153L6MThmB\NAK{\212\186\244\223\"\135\f\130",PropResponseTopic +// ".\ESCC\CANS\210\173i\158i\248|'!",PropMessageExpiryInterval 2389,PropSubscriptionIdentifier 33,PropServerKeepAlive +// 31451,PropServerReference "\177\ETB\255p\144u\190}\SIx\ETX&c]\198\b\214(\220b\134\172`",PropMaximumQoS +// 23,PropResponseInformation "\194\194\GS",PropMessageExpiryInterval 32044,PropAuthenticationData +// "\184f\226",PropResponseTopic "\142\185\246\137\"\204",PropMaximumPacketSize 32478,PropReasonString +// "d\212\208\206?",PropResponseInformation "\SOH\ACK\234z\206G+s\241\\+x\158\214\199\"",PropCorrelationData +// "\150\247\181\210K\208`\229\174\&1!\167,`",PropUserProperty "\223WA" "\232\148",PropTopicAliasMaximum +// 10581,PropAuthenticationMethod "b\164",PropCorrelationData "\154\223!_\216\254S\209\218\"\210",PropCorrelationData +// "?J\163\161\173q\187\225Z\159"]} TEST(Publish5QCTest, Decode11) { - uint8_t pkt[] = {0x33, 0x47, 0x0, 0x1, 0x65, 0x72, 0x67, 0x31, 0x3, 0x0, 0x0, 0x28, 0x8, 0x23, 0xb, - 0x7d, 0x1c, 0x0, 0x13, 0x3e, 0xa4, 0x2a, 0xdb, 0xac, 0xbd, 0x43, 0x7e, 0xdb, 0x7, 0xec, - 0x58, 0x1b, 0x53, 0x8c, 0x4b, 0x16, 0x32, 0x2e, 0x16, 0x0, 0x10, 0x8f, 0xca, 0x62, 0x4f, - 0xfa, 0x5a, 0x20, 0xc4, 0x41, 0x22, 0x4c, 0xda, 0x1b, 0xeb, 0x7b, 0x42, 0x6f, 0xd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xce, 0x47, 0x2b, 0x73, 0xf1, 0x5c, 0x2b, 0x78, 0x9e, 0xd6, 0xc7, 0x22, 0x9, 0x0, 0xe, 0x96, 0xf7, 0xb5, 0xd2, + 0x4b, 0xd0, 0x60, 0xe5, 0xae, 0x31, 0x21, 0xa7, 0x2c, 0x60, 0x26, 0x0, 0x3, 0xdf, 0x57, 0x41, 0x0, 0x2, 0xe8, + 0x94, 0x22, 0x29, 0x55, 0x15, 0x0, 0x2, 0x62, 0xa4, 0x9, 0x0, 0xb, 0x9a, 0xdf, 0x21, 0x5f, 0xd8, 0xfe, 0x53, + 0xd1, 0xda, 0x22, 0xd2, 0x9, 0x0, 0xa, 0x3f, 0x4a, 0xa3, 0xa1, 0xad, 0x71, 0xbb, 0xe1, 0x5a, 0x9f, 0xc5, 0x62, + 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2981,134 +2957,106 @@ TEST(Publish5QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x65}; - lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x6f, 0xdc, 0x3d, 0x10, 0xed, 0xb5, 0xdb, 0x1c, - 0x1b, 0x25, 0x7e, 0xc6, 0x16, 0x2f, 0x7b, 0x50}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, + 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc5, 0x62, 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29287); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 28678); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\139\194\ETB\145\245\&3\175\131\230\149\231\192\SO", _pubPktID = 2558, _pubBody = -// "3u\151\168\SYN\191\144\230d\rn\148=", _pubProps = [PropReasonString "\254*Y -// \EMKY\147\155\&5\163\211\134\247\160\168%\145",PropRequestResponseInformation 218,PropUserProperty -// "(\197\144\176\252N-g\148\135\185\162g\CAN\136S" "\174\DEL/\130\159\244\217\201\SOHok",PropTopicAlias -// 11573,PropRetainAvailable 179,PropMaximumPacketSize 27929,PropRetainAvailable 251,PropRequestProblemInformation -// 190,PropRetainAvailable 60,PropUserProperty -// "\fH\165\224|\nG\159\223@\195j\220SD\US\128\247\207\164\149\DLE\156\151\185%\168x*\246" -// "\196-\193*\253D\207\136`\221\130\153\184\&9;\198\159g\136\139@\241|\206\158\ETXc",PropCorrelationData -// "V}pM\165\179\228\no\206\US?7\197>8I",PropRequestResponseInformation 251,PropResponseInformation -// "7\233F\220",PropTopicAliasMaximum 26753,PropAuthenticationData -// "\185\215\f@#\SYN\185\ENQx-c\230)\136\SI\134",PropSubscriptionIdentifierAvailable 173,PropPayloadFormatIndicator -// 61,PropSessionExpiryInterval 23833,PropResponseTopic "\ETX?\248'G\FS\ESC\SI\182\185\210n"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\196x\255\172\&4\CAN?V{\217\182\160\&3\169g\176\192\r\NAK\186s", _pubPktID = 0, _pubBody = "s", _pubProps = +// [PropMessageExpiryInterval 10907,PropAuthenticationMethod +// "\237\198\DC2\v\139Z98\248\172\ESC\176\STX\234\"\180]e\166\159\167Z",PropContentType +// ")\140\227\169\231!v",PropTopicAlias 19767,PropSubscriptionIdentifierAvailable 57,PropServerReference +// "\223\221\190\SUB\156\214\246\t_\190G\216\166\246FM_&\DC2Tf\SYNR\155M\DC3\222Wr",PropMessageExpiryInterval +// 27077,PropSessionExpiryInterval 6103,PropResponseInformation +// "\253\216\170*k\ACK\145\GS\232\187\ESC\136\&2\236\DEL",PropResponseTopic "[",PropResponseTopic +// "\140\176\137\SUBv!lk(\US\178\129\&2\188\149H[\209\219\DC1)"]} TEST(Publish5QCTest, Encode12) { - uint8_t pkt[] = { - 0x32, 0xf0, 0x1, 0x0, 0xd, 0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe, 0x9, - 0xfe, 0xd0, 0x1, 0x1f, 0x0, 0x12, 0xfe, 0x2a, 0x59, 0x20, 0x19, 0x4b, 0x59, 0x93, 0x9b, 0x35, 0xa3, 0xd3, 0x86, - 0xf7, 0xa0, 0xa8, 0x25, 0x91, 0x19, 0xda, 0x26, 0x0, 0x10, 0x28, 0xc5, 0x90, 0xb0, 0xfc, 0x4e, 0x2d, 0x67, 0x94, - 0x87, 0xb9, 0xa2, 0x67, 0x18, 0x88, 0x53, 0x0, 0xb, 0xae, 0x7f, 0x2f, 0x82, 0x9f, 0xf4, 0xd9, 0xc9, 0x1, 0x6f, - 0x6b, 0x23, 0x2d, 0x35, 0x25, 0xb3, 0x27, 0x0, 0x0, 0x6d, 0x19, 0x25, 0xfb, 0x17, 0xbe, 0x25, 0x3c, 0x26, 0x0, - 0x1e, 0xc, 0x48, 0xa5, 0xe0, 0x7c, 0xa, 0x47, 0x9f, 0xdf, 0x40, 0xc3, 0x6a, 0xdc, 0x53, 0x44, 0x1f, 0x80, 0xf7, - 0xcf, 0xa4, 0x95, 0x10, 0x9c, 0x97, 0xb9, 0x25, 0xa8, 0x78, 0x2a, 0xf6, 0x0, 0x1b, 0xc4, 0x2d, 0xc1, 0x2a, 0xfd, - 0x44, 0xcf, 0x88, 0x60, 0xdd, 0x82, 0x99, 0xb8, 0x39, 0x3b, 0xc6, 0x9f, 0x67, 0x88, 0x8b, 0x40, 0xf1, 0x7c, 0xce, - 0x9e, 0x3, 0x63, 0x9, 0x0, 0x11, 0x56, 0x7d, 0x70, 0x4d, 0xa5, 0xb3, 0xe4, 0xa, 0x6f, 0xce, 0x1f, 0x3f, 0x37, - 0xc5, 0x3e, 0x38, 0x49, 0x19, 0xfb, 0x1a, 0x0, 0x4, 0x37, 0xe9, 0x46, 0xdc, 0x22, 0x68, 0x81, 0x16, 0x0, 0x10, - 0xb9, 0xd7, 0xc, 0x40, 0x23, 0x16, 0xb9, 0x5, 0x78, 0x2d, 0x63, 0xe6, 0x29, 0x88, 0xf, 0x86, 0x29, 0xad, 0x1, - 0x3d, 0x11, 0x0, 0x0, 0x5d, 0x19, 0x8, 0x0, 0xc, 0x3, 0x3f, 0xf8, 0x27, 0x47, 0x1c, 0x1b, 0xf, 0xb6, 0xb9, - 0xd2, 0x6e, 0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; - uint8_t topic_bytes[] = {0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x9f, 0x1, 0x0, 0x15, 0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, 0xa0, + 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73, 0x85, 0x1, 0x2, 0x0, 0x0, 0x2a, 0x9b, 0x15, + 0x0, 0x16, 0xed, 0xc6, 0x12, 0xb, 0x8b, 0x5a, 0x39, 0x38, 0xf8, 0xac, 0x1b, 0xb0, 0x2, 0xea, 0x22, + 0xb4, 0x5d, 0x65, 0xa6, 0x9f, 0xa7, 0x5a, 0x3, 0x0, 0x7, 0x29, 0x8c, 0xe3, 0xa9, 0xe7, 0x21, 0x76, + 0x23, 0x4d, 0x37, 0x29, 0x39, 0x1c, 0x0, 0x1d, 0xdf, 0xdd, 0xbe, 0x1a, 0x9c, 0xd6, 0xf6, 0x9, 0x5f, + 0xbe, 0x47, 0xd8, 0xa6, 0xf6, 0x46, 0x4d, 0x5f, 0x26, 0x12, 0x54, 0x66, 0x16, 0x52, 0x9b, 0x4d, 0x13, + 0xde, 0x57, 0x72, 0x2, 0x0, 0x0, 0x69, 0xc5, 0x11, 0x0, 0x0, 0x17, 0xd7, 0x1a, 0x0, 0xf, 0xfd, + 0xd8, 0xaa, 0x2a, 0x6b, 0x6, 0x91, 0x1d, 0xe8, 0xbb, 0x1b, 0x88, 0x32, 0xec, 0x7f, 0x8, 0x0, 0x1, + 0x5b, 0x8, 0x0, 0x15, 0x8c, 0xb0, 0x89, 0x1a, 0x76, 0x21, 0x6c, 0x6b, 0x28, 0x1f, 0xb2, 0x81, 0x32, + 0xbc, 0x95, 0x48, 0x5b, 0xd1, 0xdb, 0x11, 0x29, 0x73}; + uint8_t topic_bytes[] = {0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, + 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x73}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; - - uint8_t bytesprops0[] = {0xfe, 0x2a, 0x59, 0x20, 0x19, 0x4b, 0x59, 0x93, 0x9b, - 0x35, 0xa3, 0xd3, 0x86, 0xf7, 0xa0, 0xa8, 0x25, 0x91}; - uint8_t bytesprops2[] = {0xae, 0x7f, 0x2f, 0x82, 0x9f, 0xf4, 0xd9, 0xc9, 0x1, 0x6f, 0x6b}; - uint8_t bytesprops1[] = {0x28, 0xc5, 0x90, 0xb0, 0xfc, 0x4e, 0x2d, 0x67, - 0x94, 0x87, 0xb9, 0xa2, 0x67, 0x18, 0x88, 0x53}; - uint8_t bytesprops4[] = {0xc4, 0x2d, 0xc1, 0x2a, 0xfd, 0x44, 0xcf, 0x88, 0x60, 0xdd, 0x82, 0x99, 0xb8, 0x39, - 0x3b, 0xc6, 0x9f, 0x67, 0x88, 0x8b, 0x40, 0xf1, 0x7c, 0xce, 0x9e, 0x3, 0x63}; - uint8_t bytesprops3[] = {0xc, 0x48, 0xa5, 0xe0, 0x7c, 0xa, 0x47, 0x9f, 0xdf, 0x40, 0xc3, 0x6a, 0xdc, 0x53, 0x44, - 0x1f, 0x80, 0xf7, 0xcf, 0xa4, 0x95, 0x10, 0x9c, 0x97, 0xb9, 0x25, 0xa8, 0x78, 0x2a, 0xf6}; - uint8_t bytesprops5[] = {0x56, 0x7d, 0x70, 0x4d, 0xa5, 0xb3, 0xe4, 0xa, 0x6f, - 0xce, 0x1f, 0x3f, 0x37, 0xc5, 0x3e, 0x38, 0x49}; - uint8_t bytesprops6[] = {0x37, 0xe9, 0x46, 0xdc}; - uint8_t bytesprops7[] = {0xb9, 0xd7, 0xc, 0x40, 0x23, 0x16, 0xb9, 0x5, 0x78, 0x2d, 0x63, 0xe6, 0x29, 0x88, 0xf, 0x86}; - uint8_t bytesprops8[] = {0x3, 0x3f, 0xf8, 0x27, 0x47, 0x1c, 0x1b, 0xf, 0xb6, 0xb9, 0xd2, 0x6e}; + msg.payload_len = 1; + + uint8_t bytesprops0[] = {0xed, 0xc6, 0x12, 0xb, 0x8b, 0x5a, 0x39, 0x38, 0xf8, 0xac, 0x1b, + 0xb0, 0x2, 0xea, 0x22, 0xb4, 0x5d, 0x65, 0xa6, 0x9f, 0xa7, 0x5a}; + uint8_t bytesprops1[] = {0x29, 0x8c, 0xe3, 0xa9, 0xe7, 0x21, 0x76}; + uint8_t bytesprops2[] = {0xdf, 0xdd, 0xbe, 0x1a, 0x9c, 0xd6, 0xf6, 0x9, 0x5f, 0xbe, 0x47, 0xd8, 0xa6, 0xf6, 0x46, + 0x4d, 0x5f, 0x26, 0x12, 0x54, 0x66, 0x16, 0x52, 0x9b, 0x4d, 0x13, 0xde, 0x57, 0x72}; + uint8_t bytesprops3[] = {0xfd, 0xd8, 0xaa, 0x2a, 0x6b, 0x6, 0x91, 0x1d, 0xe8, 0xbb, 0x1b, 0x88, 0x32, 0xec, 0x7f}; + uint8_t bytesprops4[] = {0x5b}; + uint8_t bytesprops5[] = {0x8c, 0xb0, 0x89, 0x1a, 0x76, 0x21, 0x6c, 0x6b, 0x28, 0x1f, 0xb2, + 0x81, 0x32, 0xbc, 0x95, 0x48, 0x5b, 0xd1, 0xdb, 0x11, 0x29}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11573}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27929}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops3}, .v = {27, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26753}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23833}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10907}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19767}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27077}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6103}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 2558, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\139\194\ETB\145\245\&3\175\131\230\149\231\192\SO", _pubPktID = 2558, _pubBody = -// "3u\151\168\SYN\191\144\230d\rn\148=", _pubProps = [PropReasonString "\254*Y -// \EMKY\147\155\&5\163\211\134\247\160\168%\145",PropRequestResponseInformation 218,PropUserProperty -// "(\197\144\176\252N-g\148\135\185\162g\CAN\136S" "\174\DEL/\130\159\244\217\201\SOHok",PropTopicAlias -// 11573,PropRetainAvailable 179,PropMaximumPacketSize 27929,PropRetainAvailable 251,PropRequestProblemInformation -// 190,PropRetainAvailable 60,PropUserProperty -// "\fH\165\224|\nG\159\223@\195j\220SD\US\128\247\207\164\149\DLE\156\151\185%\168x*\246" -// "\196-\193*\253D\207\136`\221\130\153\184\&9;\198\159g\136\139@\241|\206\158\ETXc",PropCorrelationData -// "V}pM\165\179\228\no\206\US?7\197>8I",PropRequestResponseInformation 251,PropResponseInformation -// "7\233F\220",PropTopicAliasMaximum 26753,PropAuthenticationData -// "\185\215\f@#\SYN\185\ENQx-c\230)\136\SI\134",PropSubscriptionIdentifierAvailable 173,PropPayloadFormatIndicator -// 61,PropSessionExpiryInterval 23833,PropResponseTopic "\ETX?\248'G\FS\ESC\SI\182\185\210n"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\196x\255\172\&4\CAN?V{\217\182\160\&3\169g\176\192\r\NAK\186s", _pubPktID = 0, _pubBody = "s", _pubProps = +// [PropMessageExpiryInterval 10907,PropAuthenticationMethod +// "\237\198\DC2\v\139Z98\248\172\ESC\176\STX\234\"\180]e\166\159\167Z",PropContentType +// ")\140\227\169\231!v",PropTopicAlias 19767,PropSubscriptionIdentifierAvailable 57,PropServerReference +// "\223\221\190\SUB\156\214\246\t_\190G\216\166\246FM_&\DC2Tf\SYNR\155M\DC3\222Wr",PropMessageExpiryInterval +// 27077,PropSessionExpiryInterval 6103,PropResponseInformation +// "\253\216\170*k\ACK\145\GS\232\187\ESC\136\&2\236\DEL",PropResponseTopic "[",PropResponseTopic +// "\140\176\137\SUBv!lk(\US\178\129\&2\188\149H[\209\219\DC1)"]} TEST(Publish5QCTest, Decode12) { - uint8_t pkt[] = { - 0x32, 0xf0, 0x1, 0x0, 0xd, 0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe, 0x9, - 0xfe, 0xd0, 0x1, 0x1f, 0x0, 0x12, 0xfe, 0x2a, 0x59, 0x20, 0x19, 0x4b, 0x59, 0x93, 0x9b, 0x35, 0xa3, 0xd3, 0x86, - 0xf7, 0xa0, 0xa8, 0x25, 0x91, 0x19, 0xda, 0x26, 0x0, 0x10, 0x28, 0xc5, 0x90, 0xb0, 0xfc, 0x4e, 0x2d, 0x67, 0x94, - 0x87, 0xb9, 0xa2, 0x67, 0x18, 0x88, 0x53, 0x0, 0xb, 0xae, 0x7f, 0x2f, 0x82, 0x9f, 0xf4, 0xd9, 0xc9, 0x1, 0x6f, - 0x6b, 0x23, 0x2d, 0x35, 0x25, 0xb3, 0x27, 0x0, 0x0, 0x6d, 0x19, 0x25, 0xfb, 0x17, 0xbe, 0x25, 0x3c, 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x0, 0x16, 0xed, 0xc6, 0x12, 0xb, 0x8b, 0x5a, 0x39, 0x38, 0xf8, 0xac, 0x1b, 0xb0, 0x2, 0xea, 0x22, + 0xb4, 0x5d, 0x65, 0xa6, 0x9f, 0xa7, 0x5a, 0x3, 0x0, 0x7, 0x29, 0x8c, 0xe3, 0xa9, 0xe7, 0x21, 0x76, + 0x23, 0x4d, 0x37, 0x29, 0x39, 0x1c, 0x0, 0x1d, 0xdf, 0xdd, 0xbe, 0x1a, 0x9c, 0xd6, 0xf6, 0x9, 0x5f, + 0xbe, 0x47, 0xd8, 0xa6, 0xf6, 0x46, 0x4d, 0x5f, 0x26, 0x12, 0x54, 0x66, 0x16, 0x52, 0x9b, 0x4d, 0x13, + 0xde, 0x57, 0x72, 0x2, 0x0, 0x0, 0x69, 0xc5, 0x11, 0x0, 0x0, 0x17, 0xd7, 0x1a, 0x0, 0xf, 0xfd, + 0xd8, 0xaa, 0x2a, 0x6b, 0x6, 0x91, 0x1d, 0xe8, 0xbb, 0x1b, 0x88, 0x32, 0xec, 0x7f, 0x8, 0x0, 0x1, + 0x5b, 0x8, 0x0, 0x15, 0x8c, 0xb0, 0x89, 0x1a, 0x76, 0x21, 0x6c, 0x6b, 0x28, 0x1f, 0xb2, 0x81, 0x32, + 0xbc, 0x95, 0x48, 0x5b, 0xd1, 0xdb, 0x11, 0x29, 0x73}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3117,125 +3065,103 @@ TEST(Publish5QCTest, Decode12) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8b, 0xc2, 0x17, 0x91, 0xf5, 0x33, 0xaf, 0x83, 0xe6, 0x95, 0xe7, 0xc0, 0xe}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x33, 0x75, 0x97, 0xa8, 0x16, 0xbf, 0x90, 0xe6, 0x64, 0xd, 0x6e, 0x94, 0x3d}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2558); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 13); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + uint8_t exp_topic_bytes[] = {0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, + 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x73}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "$\212", _pubPktID = 1716, _pubBody -// = "\190\141B\DELW\166\237\195J\183\212y\176h", _pubProps = [PropAssignedClientIdentifier -// "\149\128\198\171\US\253\GS\SUB?\180&B59Z'\166,\183/q\138\189\180\237>\206\170",PropReasonString -// "\\\139\DC2vGA-]R1\226\167%u&\250\bSO\207",PropPayloadFormatIndicator 220,PropAuthenticationMethod -// "d\207\238\as\253?>\142\255\204I\241\ETB",PropResponseInformation -// "p\f\222\&3\210\NAKi\139UX\190\192\SUB\245\&4\r;h",PropRequestResponseInformation 157,PropMaximumQoS -// 72,PropWillDelayInterval 24790,PropMessageExpiryInterval 3742,PropReceiveMaximum 23049,PropAuthenticationMethod -// "\189p%\221_\DLE\217u\177\183@\ACK\245\135\DC4\239\202\173\179\182\208V\163\168",PropRequestResponseInformation -// 85,PropSubscriptionIdentifier 0,PropRetainAvailable 38,PropTopicAliasMaximum 8926,PropSharedSubscriptionAvailable -// 17,PropContentType "\USb\156\FS\168\164.\NAK\140\DC2G\DC1N\185\&0\234Z",PropContentType -// "\237\135\132\186m\168\205\"!\215\208\163",PropRequestProblemInformation 174]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\136@e", _pubPktID = 1120, _pubBody +// = "U\146=\184\GS9[\230\210\180\157\ENQ\204\240\DC36\FSl0\136\172^\RSr4t7\193\178", _pubProps = [PropContentType +// "'\184m\204oOr",PropReceiveMaximum 29088,PropRequestProblemInformation 86,PropWildcardSubscriptionAvailable +// 125,PropCorrelationData "oW\220W\SUB%F\225\DC3\233\161\&6K\216`\216\FS\252\ENQ\253\216",PropCorrelationData +// ",?\185\148\172",PropReceiveMaximum 32523,PropResponseInformation +// "\233\152M\171Xg\DEL\141",PropPayloadFormatIndicator 86,PropResponseInformation +// "\183\156\197V\223w\US\228\190r@\FS$\189G\167.0^w\213\t\GSoX%",PropRetainAvailable 77,PropPayloadFormatIndicator +// 118,PropSubscriptionIdentifierAvailable 247,PropSubscriptionIdentifier 16]} TEST(Publish5QCTest, Encode13) { - uint8_t pkt[] = {0x34, 0xd0, 0x1, 0x0, 0x2, 0x24, 0xd4, 0x6, 0xb4, 0xba, 0x1, 0x12, 0x0, 0x1c, 0x95, 0x80, 0xc6, - 0xab, 0x1f, 0xfd, 0x1d, 0x1a, 0x3f, 0xb4, 0x26, 0x42, 0x35, 0x39, 0x5a, 0x27, 0xa6, 0x2c, 0xb7, 0x2f, - 0x71, 0x8a, 0xbd, 0xb4, 0xed, 0x3e, 0xce, 0xaa, 0x1f, 0x0, 0x14, 0x5c, 0x8b, 0x12, 0x76, 0x47, 0x41, - 0x2d, 0x5d, 0x52, 0x31, 0xe2, 0xa7, 0x25, 0x75, 0x26, 0xfa, 0x8, 0x53, 0x4f, 0xcf, 0x1, 0xdc, 0x15, - 0x0, 0xe, 0x64, 0xcf, 0xee, 0x7, 0x73, 0xfd, 0x3f, 0x3e, 0x8e, 0xff, 0xcc, 0x49, 0xf1, 0x17, 0x1a, - 0x0, 0x12, 0x70, 0xc, 0xde, 0x33, 0xd2, 0x15, 0x69, 0x8b, 0x55, 0x58, 0xbe, 0xc0, 0x1a, 0xf5, 0x34, - 0xd, 0x3b, 0x68, 0x19, 0x9d, 0x24, 0x48, 0x18, 0x0, 0x0, 0x60, 0xd6, 0x2, 0x0, 0x0, 0xe, 0x9e, - 0x21, 0x5a, 0x9, 0x15, 0x0, 0x18, 0xbd, 0x70, 0x25, 0xdd, 0x5f, 0x10, 0xd9, 0x75, 0xb1, 0xb7, 0x40, - 0x6, 0xf5, 0x87, 0x14, 0xef, 0xca, 0xad, 0xb3, 0xb6, 0xd0, 0x56, 0xa3, 0xa8, 0x19, 0x55, 0xb, 0x0, - 0x25, 0x26, 0x22, 0x22, 0xde, 0x2a, 0x11, 0x3, 0x0, 0x11, 0x1f, 0x62, 0x9c, 0x1c, 0xa8, 0xa4, 0x2e, - 0x15, 0x8c, 0x12, 0x47, 0x11, 0x4e, 0xb9, 0x30, 0xea, 0x5a, 0x3, 0x0, 0xc, 0xed, 0x87, 0x84, 0xba, - 0x6d, 0xa8, 0xcd, 0x22, 0x21, 0xd7, 0xd0, 0xa3, 0x17, 0xae, 0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, - 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; - uint8_t topic_bytes[] = {0x24, 0xd4}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x8b, 0x1, 0x0, 0x3, 0x88, 0x40, 0x65, 0x4, 0x60, 0x66, 0x3, 0x0, 0x7, 0x27, 0xb8, + 0x6d, 0xcc, 0x6f, 0x4f, 0x72, 0x21, 0x71, 0xa0, 0x17, 0x56, 0x28, 0x7d, 0x9, 0x0, 0x15, 0x6f, + 0x57, 0xdc, 0x57, 0x1a, 0x25, 0x46, 0xe1, 0x13, 0xe9, 0xa1, 0x36, 0x4b, 0xd8, 0x60, 0xd8, 0x1c, + 0xfc, 0x5, 0xfd, 0xd8, 0x9, 0x0, 0x5, 0x2c, 0x3f, 0xb9, 0x94, 0xac, 0x21, 0x7f, 0xb, 0x1a, + 0x0, 0x8, 0xe9, 0x98, 0x4d, 0xab, 0x58, 0x67, 0x7f, 0x8d, 0x1, 0x56, 0x1a, 0x0, 0x1a, 0xb7, + 0x9c, 0xc5, 0x56, 0xdf, 0x77, 0x1f, 0xe4, 0xbe, 0x72, 0x40, 0x1c, 0x24, 0xbd, 0x47, 0xa7, 0x2e, + 0x30, 0x5e, 0x77, 0xd5, 0x9, 0x1d, 0x6f, 0x58, 0x25, 0x25, 0x4d, 0x1, 0x76, 0x29, 0xf7, 0xb, + 0x10, 0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, + 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; + uint8_t topic_bytes[] = {0x88, 0x40, 0x65}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; + msg.retained = true; + uint8_t msg_bytes[] = {0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, + 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; - - uint8_t bytesprops0[] = {0x95, 0x80, 0xc6, 0xab, 0x1f, 0xfd, 0x1d, 0x1a, 0x3f, 0xb4, 0x26, 0x42, 0x35, 0x39, - 0x5a, 0x27, 0xa6, 0x2c, 0xb7, 0x2f, 0x71, 0x8a, 0xbd, 0xb4, 0xed, 0x3e, 0xce, 0xaa}; - uint8_t bytesprops1[] = {0x5c, 0x8b, 0x12, 0x76, 0x47, 0x41, 0x2d, 0x5d, 0x52, 0x31, - 0xe2, 0xa7, 0x25, 0x75, 0x26, 0xfa, 0x8, 0x53, 0x4f, 0xcf}; - uint8_t bytesprops2[] = {0x64, 0xcf, 0xee, 0x7, 0x73, 0xfd, 0x3f, 0x3e, 0x8e, 0xff, 0xcc, 0x49, 0xf1, 0x17}; - uint8_t bytesprops3[] = {0x70, 0xc, 0xde, 0x33, 0xd2, 0x15, 0x69, 0x8b, 0x55, - 0x58, 0xbe, 0xc0, 0x1a, 0xf5, 0x34, 0xd, 0x3b, 0x68}; - uint8_t bytesprops4[] = {0xbd, 0x70, 0x25, 0xdd, 0x5f, 0x10, 0xd9, 0x75, 0xb1, 0xb7, 0x40, 0x6, - 0xf5, 0x87, 0x14, 0xef, 0xca, 0xad, 0xb3, 0xb6, 0xd0, 0x56, 0xa3, 0xa8}; - uint8_t bytesprops5[] = {0x1f, 0x62, 0x9c, 0x1c, 0xa8, 0xa4, 0x2e, 0x15, 0x8c, - 0x12, 0x47, 0x11, 0x4e, 0xb9, 0x30, 0xea, 0x5a}; - uint8_t bytesprops6[] = {0xed, 0x87, 0x84, 0xba, 0x6d, 0xa8, 0xcd, 0x22, 0x21, 0xd7, 0xd0, 0xa3}; + msg.payload_len = 29; + + uint8_t bytesprops0[] = {0x27, 0xb8, 0x6d, 0xcc, 0x6f, 0x4f, 0x72}; + uint8_t bytesprops1[] = {0x6f, 0x57, 0xdc, 0x57, 0x1a, 0x25, 0x46, 0xe1, 0x13, 0xe9, 0xa1, + 0x36, 0x4b, 0xd8, 0x60, 0xd8, 0x1c, 0xfc, 0x5, 0xfd, 0xd8}; + uint8_t bytesprops2[] = {0x2c, 0x3f, 0xb9, 0x94, 0xac}; + uint8_t bytesprops3[] = {0xe9, 0x98, 0x4d, 0xab, 0x58, 0x67, 0x7f, 0x8d}; + uint8_t bytesprops4[] = {0xb7, 0x9c, 0xc5, 0x56, 0xdf, 0x77, 0x1f, 0xe4, 0xbe, 0x72, 0x40, 0x1c, 0x24, + 0xbd, 0x47, 0xa7, 0x2e, 0x30, 0x5e, 0x77, 0xd5, 0x9, 0x1d, 0x6f, 0x58, 0x25}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24790}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3742}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23049}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8926}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29088}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32523}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1716, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1120, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "$\212", _pubPktID = 1716, _pubBody -// = "\190\141B\DELW\166\237\195J\183\212y\176h", _pubProps = [PropAssignedClientIdentifier -// "\149\128\198\171\US\253\GS\SUB?\180&B59Z'\166,\183/q\138\189\180\237>\206\170",PropReasonString -// "\\\139\DC2vGA-]R1\226\167%u&\250\bSO\207",PropPayloadFormatIndicator 220,PropAuthenticationMethod -// "d\207\238\as\253?>\142\255\204I\241\ETB",PropResponseInformation -// "p\f\222\&3\210\NAKi\139UX\190\192\SUB\245\&4\r;h",PropRequestResponseInformation 157,PropMaximumQoS -// 72,PropWillDelayInterval 24790,PropMessageExpiryInterval 3742,PropReceiveMaximum 23049,PropAuthenticationMethod -// "\189p%\221_\DLE\217u\177\183@\ACK\245\135\DC4\239\202\173\179\182\208V\163\168",PropRequestResponseInformation -// 85,PropSubscriptionIdentifier 0,PropRetainAvailable 38,PropTopicAliasMaximum 8926,PropSharedSubscriptionAvailable -// 17,PropContentType "\USb\156\FS\168\164.\NAK\140\DC2G\DC1N\185\&0\234Z",PropContentType -// "\237\135\132\186m\168\205\"!\215\208\163",PropRequestProblemInformation 174]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\136@e", _pubPktID = 1120, _pubBody +// = "U\146=\184\GS9[\230\210\180\157\ENQ\204\240\DC36\FSl0\136\172^\RSr4t7\193\178", _pubProps = [PropContentType +// "'\184m\204oOr",PropReceiveMaximum 29088,PropRequestProblemInformation 86,PropWildcardSubscriptionAvailable +// 125,PropCorrelationData "oW\220W\SUB%F\225\DC3\233\161\&6K\216`\216\FS\252\ENQ\253\216",PropCorrelationData +// ",?\185\148\172",PropReceiveMaximum 32523,PropResponseInformation +// "\233\152M\171Xg\DEL\141",PropPayloadFormatIndicator 86,PropResponseInformation +// "\183\156\197V\223w\US\228\190r@\FS$\189G\167.0^w\213\t\GSoX%",PropRetainAvailable 77,PropPayloadFormatIndicator +// 118,PropSubscriptionIdentifierAvailable 247,PropSubscriptionIdentifier 16]} TEST(Publish5QCTest, Decode13) { - uint8_t pkt[] = {0x34, 0xd0, 0x1, 0x0, 0x2, 0x24, 0xd4, 0x6, 0xb4, 0xba, 0x1, 0x12, 0x0, 0x1c, 0x95, 0x80, 0xc6, - 0xab, 0x1f, 0xfd, 0x1d, 0x1a, 0x3f, 0xb4, 0x26, 0x42, 0x35, 0x39, 0x5a, 0x27, 0xa6, 0x2c, 0xb7, 0x2f, - 0x71, 0x8a, 0xbd, 0xb4, 0xed, 0x3e, 0xce, 0xaa, 0x1f, 0x0, 0x14, 0x5c, 0x8b, 0x12, 0x76, 0x47, 0x41, - 0x2d, 0x5d, 0x52, 0x31, 0xe2, 0xa7, 0x25, 0x75, 0x26, 0xfa, 0x8, 0x53, 0x4f, 0xcf, 0x1, 0xdc, 0x15, - 0x0, 0xe, 0x64, 0xcf, 0xee, 0x7, 0x73, 0xfd, 0x3f, 0x3e, 0x8e, 0xff, 0xcc, 0x49, 0xf1, 0x17, 0x1a, - 0x0, 0x12, 0x70, 0xc, 0xde, 0x33, 0xd2, 0x15, 0x69, 0x8b, 0x55, 0x58, 0xbe, 0xc0, 0x1a, 0xf5, 0x34, - 0xd, 0x3b, 0x68, 0x19, 0x9d, 0x24, 0x48, 0x18, 0x0, 0x0, 0x60, 0xd6, 0x2, 0x0, 0x0, 0xe, 0x9e, - 0x21, 0x5a, 0x9, 0x15, 0x0, 0x18, 0xbd, 0x70, 0x25, 0xdd, 0x5f, 0x10, 0xd9, 0x75, 0xb1, 0xb7, 0x40, - 0x6, 0xf5, 0x87, 0x14, 0xef, 0xca, 0xad, 0xb3, 0xb6, 0xd0, 0x56, 0xa3, 0xa8, 0x19, 0x55, 0xb, 0x0, - 0x25, 0x26, 0x22, 0x22, 0xde, 0x2a, 0x11, 0x3, 0x0, 0x11, 0x1f, 0x62, 0x9c, 0x1c, 0xa8, 0xa4, 0x2e, - 0x15, 0x8c, 0x12, 0x47, 0x11, 0x4e, 0xb9, 0x30, 0xea, 0x5a, 0x3, 0x0, 0xc, 0xed, 0x87, 0x84, 0xba, - 0x6d, 0xa8, 0xcd, 0x22, 0x21, 0xd7, 0xd0, 0xa3, 0x17, 0xae, 0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, - 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; + uint8_t pkt[] = {0x35, 0x8b, 0x1, 0x0, 0x3, 0x88, 0x40, 0x65, 0x4, 0x60, 0x66, 0x3, 0x0, 0x7, 0x27, 0xb8, + 0x6d, 0xcc, 0x6f, 0x4f, 0x72, 0x21, 0x71, 0xa0, 0x17, 0x56, 0x28, 0x7d, 0x9, 0x0, 0x15, 0x6f, + 0x57, 0xdc, 0x57, 0x1a, 0x25, 0x46, 0xe1, 0x13, 0xe9, 0xa1, 0x36, 0x4b, 0xd8, 0x60, 0xd8, 0x1c, + 0xfc, 0x5, 0xfd, 0xd8, 0x9, 0x0, 0x5, 0x2c, 0x3f, 0xb9, 0x94, 0xac, 0x21, 0x7f, 0xb, 0x1a, + 0x0, 0x8, 0xe9, 0x98, 0x4d, 0xab, 0x58, 0x67, 0x7f, 0x8d, 0x1, 0x56, 0x1a, 0x0, 0x1a, 0xb7, + 0x9c, 0xc5, 0x56, 0xdf, 0x77, 0x1f, 0xe4, 0xbe, 0x72, 0x40, 0x1c, 0x24, 0xbd, 0x47, 0xa7, 0x2e, + 0x30, 0x5e, 0x77, 0xd5, 0x9, 0x1d, 0x6f, 0x58, 0x25, 0x25, 0x4d, 0x1, 0x76, 0x29, 0xf7, 0xb, + 0x10, 0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, + 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3244,96 +3170,142 @@ TEST(Publish5QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x24, 0xd4}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbe, 0x8d, 0x42, 0x7f, 0x57, 0xa6, 0xed, 0xc3, 0x4a, 0xb7, 0xd4, 0x79, 0xb0, 0x68}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x88, 0x40, 0x65}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, + 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 1716); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 1120); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\180\150\252c\201h%\ACKX[", -// _pubPktID = 23232, _pubBody = "\245\158IP\ETX\CAN\DLE|\148\175\r", _pubProps = [PropResponseInformation -// "\ETB\240\GSR\130D",PropAuthenticationMethod -// "k\224\193vn3L\249<\161\207\US\215\203\&5\228\SYN\134\167\222",PropTopicAlias 16911,PropResponseTopic -// ".s\246\161\ESC",PropWillDelayInterval 18379,PropMessageExpiryInterval 29762,PropReasonString -// "\178\224\&8\ESC\174",PropSubscriptionIdentifierAvailable 214,PropPayloadFormatIndicator -// 240,PropRequestProblemInformation 247,PropSharedSubscriptionAvailable 9,PropResponseInformation -// "\148F?\220\204\149",PropContentType "\138\251\159E`\NUL"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\156\129\b\202\ETB\"y\195\204\150S\DLE\231\CANg\207\&0\n\246~U\196\194\&5", _pubPktID = 17194, _pubBody = +// "\158\237", _pubProps = [PropPayloadFormatIndicator 191,PropRequestProblemInformation +// 232,PropSubscriptionIdentifierAvailable 54,PropTopicAliasMaximum 1708,PropWildcardSubscriptionAvailable +// 116,PropAuthenticationData "o'\133\177\235t@\149A+\233\140\SOH",PropMessageExpiryInterval 5729,PropTopicAliasMaximum +// 16831,PropAuthenticationData +// "\200\SO\250\&6\144\192yG\211\STX\139\253\175\DC2\157\139\SUB\RS6\178\249\n'\186\206O\STX\b",PropRetainAvailable +// 38,PropTopicAlias 27395,PropMaximumQoS 187,PropPayloadFormatIndicator 196,PropMessageExpiryInterval +// 6396,PropServerKeepAlive 21502,PropRequestProblemInformation 199,PropWildcardSubscriptionAvailable +// 159,PropReceiveMaximum 21944,PropWillDelayInterval 24951,PropMaximumQoS 95,PropMessageExpiryInterval +// 9751,PropMaximumPacketSize 10710,PropRetainAvailable 207,PropSubscriptionIdentifierAvailable +// 106,PropSharedSubscriptionAvailable 187,PropServerReference "\139\211\238\132",PropCorrelationData +// "\SYN;\218\247|\212\231\156\bV\199z#5\223;\170H\189\220\174\224\GS8\250\206z\240",PropRetainAvailable +// 191,PropAuthenticationData +// "Z\SI\b&\163\ACKr0\208\150\188\EMV\FS\138\185r\227\229j",PropSubscriptionIdentifierAvailable 136]} TEST(Publish5QCTest, Encode14) { - uint8_t pkt[] = {0x3c, 0x71, 0x0, 0xa, 0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b, 0x5a, 0xc0, 0x57, - 0x1a, 0x0, 0x6, 0x17, 0xf0, 0x1d, 0x52, 0x82, 0x44, 0x15, 0x0, 0x14, 0x6b, 0xe0, 0xc1, 0x76, 0x6e, - 0x33, 0x4c, 0xf9, 0x3c, 0xa1, 0xcf, 0x1f, 0xd7, 0xcb, 0x35, 0xe4, 0x16, 0x86, 0xa7, 0xde, 0x23, 0x42, - 0xf, 0x8, 0x0, 0x5, 0x2e, 0x73, 0xf6, 0xa1, 0x1b, 0x18, 0x0, 0x0, 0x47, 0xcb, 0x2, 0x0, 0x0, - 0x74, 0x42, 0x1f, 0x0, 0x5, 0xb2, 0xe0, 0x38, 0x1b, 0xae, 0x29, 0xd6, 0x1, 0xf0, 0x17, 0xf7, 0x2a, - 0x9, 0x1a, 0x0, 0x6, 0x94, 0x46, 0x3f, 0xdc, 0xcc, 0x95, 0x3, 0x0, 0x6, 0x8a, 0xfb, 0x9f, 0x45, - 0x60, 0x0, 0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; - uint8_t topic_bytes[] = {0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0xd2, 0x1, 0x0, 0x18, 0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, + 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35, 0x43, 0x2a, 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, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, + 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x9e, 0xed}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 2; - uint8_t bytesprops0[] = {0x17, 0xf0, 0x1d, 0x52, 0x82, 0x44}; - uint8_t bytesprops1[] = {0x6b, 0xe0, 0xc1, 0x76, 0x6e, 0x33, 0x4c, 0xf9, 0x3c, 0xa1, - 0xcf, 0x1f, 0xd7, 0xcb, 0x35, 0xe4, 0x16, 0x86, 0xa7, 0xde}; - uint8_t bytesprops2[] = {0x2e, 0x73, 0xf6, 0xa1, 0x1b}; - uint8_t bytesprops3[] = {0xb2, 0xe0, 0x38, 0x1b, 0xae}; - uint8_t bytesprops4[] = {0x94, 0x46, 0x3f, 0xdc, 0xcc, 0x95}; - uint8_t bytesprops5[] = {0x8a, 0xfb, 0x9f, 0x45, 0x60, 0x0}; + uint8_t bytesprops0[] = {0x6f, 0x27, 0x85, 0xb1, 0xeb, 0x74, 0x40, 0x95, 0x41, 0x2b, 0xe9, 0x8c, 0x1}; + uint8_t bytesprops1[] = {0xc8, 0xe, 0xfa, 0x36, 0x90, 0xc0, 0x79, 0x47, 0xd3, 0x2, 0x8b, 0xfd, 0xaf, 0x12, + 0x9d, 0x8b, 0x1a, 0x1e, 0x36, 0xb2, 0xf9, 0xa, 0x27, 0xba, 0xce, 0x4f, 0x2, 0x8}; + uint8_t bytesprops2[] = {0x8b, 0xd3, 0xee, 0x84}; + uint8_t bytesprops3[] = {0x16, 0x3b, 0xda, 0xf7, 0x7c, 0xd4, 0xe7, 0x9c, 0x8, 0x56, 0xc7, 0x7a, 0x23, 0x35, + 0xdf, 0x3b, 0xaa, 0x48, 0xbd, 0xdc, 0xae, 0xe0, 0x1d, 0x38, 0xfa, 0xce, 0x7a, 0xf0}; + uint8_t bytesprops4[] = {0x5a, 0xf, 0x8, 0x26, 0xa3, 0x6, 0x72, 0x30, 0xd0, 0x96, + 0xbc, 0x19, 0x56, 0x1c, 0x8a, 0xb9, 0x72, 0xe3, 0xe5, 0x6a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16911}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18379}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29762}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1708}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5729}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16831}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27395}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6396}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21502}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21944}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24951}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9751}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10710}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 23232, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17194, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\180\150\252c\201h%\ACKX[", -// _pubPktID = 23232, _pubBody = "\245\158IP\ETX\CAN\DLE|\148\175\r", _pubProps = [PropResponseInformation -// "\ETB\240\GSR\130D",PropAuthenticationMethod -// "k\224\193vn3L\249<\161\207\US\215\203\&5\228\SYN\134\167\222",PropTopicAlias 16911,PropResponseTopic -// ".s\246\161\ESC",PropWillDelayInterval 18379,PropMessageExpiryInterval 29762,PropReasonString -// "\178\224\&8\ESC\174",PropSubscriptionIdentifierAvailable 214,PropPayloadFormatIndicator -// 240,PropRequestProblemInformation 247,PropSharedSubscriptionAvailable 9,PropResponseInformation -// "\148F?\220\204\149",PropContentType "\138\251\159E`\NUL"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\156\129\b\202\ETB\"y\195\204\150S\DLE\231\CANg\207\&0\n\246~U\196\194\&5", _pubPktID = 17194, _pubBody = +// "\158\237", _pubProps = [PropPayloadFormatIndicator 191,PropRequestProblemInformation +// 232,PropSubscriptionIdentifierAvailable 54,PropTopicAliasMaximum 1708,PropWildcardSubscriptionAvailable +// 116,PropAuthenticationData "o'\133\177\235t@\149A+\233\140\SOH",PropMessageExpiryInterval 5729,PropTopicAliasMaximum +// 16831,PropAuthenticationData +// "\200\SO\250\&6\144\192yG\211\STX\139\253\175\DC2\157\139\SUB\RS6\178\249\n'\186\206O\STX\b",PropRetainAvailable +// 38,PropTopicAlias 27395,PropMaximumQoS 187,PropPayloadFormatIndicator 196,PropMessageExpiryInterval +// 6396,PropServerKeepAlive 21502,PropRequestProblemInformation 199,PropWildcardSubscriptionAvailable +// 159,PropReceiveMaximum 21944,PropWillDelayInterval 24951,PropMaximumQoS 95,PropMessageExpiryInterval +// 9751,PropMaximumPacketSize 10710,PropRetainAvailable 207,PropSubscriptionIdentifierAvailable +// 106,PropSharedSubscriptionAvailable 187,PropServerReference "\139\211\238\132",PropCorrelationData +// "\SYN;\218\247|\212\231\156\bV\199z#5\223;\170H\189\220\174\224\GS8\250\206z\240",PropRetainAvailable +// 191,PropAuthenticationData +// "Z\SI\b&\163\ACKr0\208\150\188\EMV\FS\138\185r\227\229j",PropSubscriptionIdentifierAvailable 136]} TEST(Publish5QCTest, Decode14) { - uint8_t pkt[] = {0x3c, 0x71, 0x0, 0xa, 0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b, 0x5a, 0xc0, 0x57, - 0x1a, 0x0, 0x6, 0x17, 0xf0, 0x1d, 0x52, 0x82, 0x44, 0x15, 0x0, 0x14, 0x6b, 0xe0, 0xc1, 0x76, 0x6e, - 0x33, 0x4c, 0xf9, 0x3c, 0xa1, 0xcf, 0x1f, 0xd7, 0xcb, 0x35, 0xe4, 0x16, 0x86, 0xa7, 0xde, 0x23, 0x42, - 0xf, 0x8, 0x0, 0x5, 0x2e, 0x73, 0xf6, 0xa1, 0x1b, 0x18, 0x0, 0x0, 0x47, 0xcb, 0x2, 0x0, 0x0, - 0x74, 0x42, 0x1f, 0x0, 0x5, 0xb2, 0xe0, 0x38, 0x1b, 0xae, 0x29, 0xd6, 0x1, 0xf0, 0x17, 0xf7, 0x2a, - 0x9, 0x1a, 0x0, 0x6, 0x94, 0x46, 0x3f, 0xdc, 0xcc, 0x95, 0x3, 0x0, 0x6, 0x8a, 0xfb, 0x9f, 0x45, - 0x60, 0x0, 0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; + uint8_t pkt[] = {0x33, 0xd2, 0x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f, 0x8, 0x26, 0xa3, 0x6, 0x72, 0x30, 0xd0, 0x96, 0xbc, 0x19, 0x56, 0x1c, 0x8a, + 0xb9, 0x72, 0xe3, 0xe5, 0x6a, 0x29, 0x88, 0x9e, 0xed}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3342,149 +3314,136 @@ TEST(Publish5QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb4, 0x96, 0xfc, 0x63, 0xc9, 0x68, 0x25, 0x6, 0x58, 0x5b}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf5, 0x9e, 0x49, 0x50, 0x3, 0x18, 0x10, 0x7c, 0x94, 0xaf, 0xd}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 23232); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + uint8_t exp_topic_bytes[] = {0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, + 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9e, 0xed}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 17194); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\200a\188\164\254\SO\133s@", -// _pubPktID = 0, _pubBody = "i\EM\SOH\179\179;\199eG\211b\163Ye\"\211",PropReceiveMaximum 10464,PropResponseInformation -// "n\204",PropServerKeepAlive 19107,PropMessageExpiryInterval 27838,PropWildcardSubscriptionAvailable -// 102,PropMessageExpiryInterval 15603,PropSubscriptionIdentifierAvailable 131,PropCorrelationData -// "l\140",PropSessionExpiryInterval 5845,PropRequestProblemInformation 83,PropRequestProblemInformation -// 46,PropMessageExpiryInterval 25078,PropUserProperty "\150)g\181\184]V]\157\&7S&\132\206\n4\204r\215h{\188vO&\b\159" -// "\207\141\142\222;MI\152\225\220\v\164\149j\254\245>\170\129\128X\161W\"\174",PropMessageExpiryInterval -// 3649,PropAuthenticationData -// "\ACK\t\220\229\130\146\EOT.o\203BV\173U\247\222\218\228\222\149\&7",PropRequestProblemInformation -// 2,PropRetainAvailable 126,PropSessionExpiryInterval 32225,PropPayloadFormatIndicator 175,PropReceiveMaximum -// 24587,PropResponseTopic ";\160\163\250\174&#R\164\182\152\143\145@mF)\204\182S4\190\199O\254$\236",PropMaximumQoS -// 219,PropPayloadFormatIndicator 233,PropTopicAlias 32208,PropContentType ":\176Q",PropResponseTopic -// "7\NUL\174V\168\226\193svo\225`\ESC\147\250a:1.W\rK\249"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// ")\223\215<\151R\ENQ\DC3I\131&\207\&4\179\156\CAN\SO", _pubPktID = 18606, _pubBody = "\208Zo\214\246#v", _pubProps = +// [PropSubscriptionIdentifier 9,PropAuthenticationData +// "\242\231\FSo\223\180\b\241)\214pM\NAK\nH\138+h;&t8\STX\216\178q\251\137+",PropWildcardSubscriptionAvailable +// 246,PropSubscriptionIdentifier 4,PropTopicAliasMaximum 11929,PropSessionExpiryInterval 12227,PropTopicAliasMaximum +// 21923,PropWildcardSubscriptionAvailable 49,PropAssignedClientIdentifier "_\136\166 +// \GS\EM\ETX\220\ACK]\ENQ\196\&63\ACK\SI\197k\228a4,",PropMessageExpiryInterval 31165,PropAuthenticationMethod +// "\SYN\f\173\244Y\247z\160i9i\128C\178\201\143oM\ENQ\138\176@\192",PropCorrelationData +// "\197\"\194\214\241a\209\199U\138D\200\CAN\"7W\EOT$_#",PropResponseTopic "\237\202^\244",PropAssignedClientIdentifier +// "\239\147~\US3\222UK\186y\SOHG\226\163\DLE\152\242",PropReceiveMaximum 9627,PropReceiveMaximum +// 7912,PropAssignedClientIdentifier +// "\237\191\228d\245fu\215\255\222\171\170\229\DC2\184q>#\239\ab\252\188\211\r\247\147\ENQ",PropMaximumQoS +// 55,PropWillDelayInterval 17769,PropTopicAliasMaximum 28809,PropPayloadFormatIndicator 162]} TEST(Publish5QCTest, Encode15) { - uint8_t pkt[] = {0x31, 0x8a, 0x2, 0x0, 0x9, 0xc8, 0x61, 0xbc, 0xa4, 0xfe, 0xe, 0x85, 0x73, 0x40, 0xe8, 0x1, 0x3, - 0x0, 0x10, 0x3e, 0x19, 0x1, 0xb3, 0xb3, 0x3b, 0xc7, 0x65, 0x47, 0xd3, 0x62, 0xa3, 0x59, 0x65, 0x22, - 0xd3, 0x21, 0x28, 0xe0, 0x1a, 0x0, 0x2, 0x6e, 0xcc, 0x13, 0x4a, 0xa3, 0x2, 0x0, 0x0, 0x6c, 0xbe, - 0x28, 0x66, 0x2, 0x0, 0x0, 0x3c, 0xf3, 0x29, 0x83, 0x9, 0x0, 0x2, 0x6c, 0x8c, 0x11, 0x0, 0x0, - 0x16, 0xd5, 0x17, 0x53, 0x17, 0x2e, 0x2, 0x0, 0x0, 0x61, 0xf6, 0x26, 0x0, 0x1b, 0x96, 0x29, 0x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es[] = {0xc8, 0x61, 0xbc, 0xa4, 0xfe, 0xe, 0x85, 0x73, 0x40}; - lwmqtt_string_t topic = {9, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x35, 0xec, 0x1, 0x0, 0x11, 0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, 0x83, 0x26, 0xcf, 0x34, 0xb3, + 0x9c, 0x18, 0xe, 0x48, 0xae, 0xce, 0x1, 0xb, 0x9, 0x16, 0x0, 0x1d, 0xf2, 0xe7, 0x1c, 0x6f, 0xdf, 0xb4, 0x8, + 0xf1, 0x29, 0xd6, 0x70, 0x4d, 0x15, 0xa, 0x48, 0x8a, 0x2b, 0x68, 0x3b, 0x26, 0x74, 0x38, 0x2, 0xd8, 0xb2, 0x71, + 0xfb, 0x89, 0x2b, 0x28, 0xf6, 0xb, 0x4, 0x22, 0x2e, 0x99, 0x11, 0x0, 0x0, 0x2f, 0xc3, 0x22, 0x55, 0xa3, 0x28, + 0x31, 0x12, 0x0, 0x16, 0x5f, 0x88, 0xa6, 0x20, 0x1d, 0x19, 0x3, 0xdc, 0x6, 0x5d, 0x5, 0xc4, 0x36, 0x33, 0x6, + 0xf, 0xc5, 0x6b, 0xe4, 0x61, 0x34, 0x2c, 0x2, 0x0, 0x0, 0x79, 0xbd, 0x15, 0x0, 0x17, 0x16, 0xc, 0xad, 0xf4, + 0x59, 0xf7, 0x7a, 0xa0, 0x69, 0x39, 0x69, 0x80, 0x43, 0xb2, 0xc9, 0x8f, 0x6f, 0x4d, 0x5, 0x8a, 0xb0, 0x40, 0xc0, + 0x9, 0x0, 0x14, 0xc5, 0x22, 0xc2, 0xd6, 0xf1, 0x61, 0xd1, 0xc7, 0x55, 0x8a, 0x44, 0xc8, 0x18, 0x22, 0x37, 0x57, + 0x4, 0x24, 0x5f, 0x23, 0x8, 0x0, 0x4, 0xed, 0xca, 0x5e, 0xf4, 0x12, 0x0, 0x11, 0xef, 0x93, 0x7e, 0x1f, 0x33, + 0xde, 0x55, 0x4b, 0xba, 0x79, 0x1, 0x47, 0xe2, 0xa3, 0x10, 0x98, 0xf2, 0x21, 0x25, 0x9b, 0x21, 0x1e, 0xe8, 0x12, + 0x0, 0x1c, 0xed, 0xbf, 0xe4, 0x64, 0xf5, 0x66, 0x75, 0xd7, 0xff, 0xde, 0xab, 0xaa, 0xe5, 0x12, 0xb8, 0x71, 0x3e, + 0x23, 0xef, 0x7, 0x62, 0xfc, 0xbc, 0xd3, 0xd, 0xf7, 0x93, 0x5, 0x24, 0x37, 0x18, 0x0, 0x0, 0x45, 0x69, 0x22, + 0x70, 0x89, 0x1, 0xa2, 0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; + uint8_t topic_bytes[] = {0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, + 0x83, 0x26, 0xcf, 0x34, 0xb3, 0x9c, 0x18, 0xe}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x69, 0x3c, 0x55, 0x4a, 0xd9, 0x4a, 0x28, 0x76, 0xa3, 0x5c, 0xd0, - 0x5a, 0xd1, 0x30, 0xec, 0x7e, 0x31, 0x64, 0xd3, 0x58, 0x12}; + uint8_t msg_bytes[] = {0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 7; - uint8_t bytesprops0[] = {0x3e, 0x19, 0x1, 0xb3, 0xb3, 0x3b, 0xc7, 0x65, - 0x47, 0xd3, 0x62, 0xa3, 0x59, 0x65, 0x22, 0xd3}; - uint8_t bytesprops1[] = {0x6e, 0xcc}; - uint8_t bytesprops2[] = {0x6c, 0x8c}; - uint8_t bytesprops4[] = {0xcf, 0x8d, 0x8e, 0xde, 0x3b, 0x4d, 0x49, 0x98, 0xe1, 0xdc, 0xb, 0xa4, 0x95, - 0x6a, 0xfe, 0xf5, 0x3e, 0xaa, 0x81, 0x80, 0x58, 0xa1, 0x57, 0x22, 0xae}; - uint8_t bytesprops3[] = {0x96, 0x29, 0x67, 0xb5, 0xb8, 0x5d, 0x56, 0x5d, 0x9d, 0x37, 0x53, 0x26, 0x84, 0xce, - 0xa, 0x34, 0xcc, 0x72, 0xd7, 0x68, 0x7b, 0xbc, 0x76, 0x4f, 0x26, 0x8, 0x9f}; - uint8_t bytesprops5[] = {0x6, 0x9, 0xdc, 0xe5, 0x82, 0x92, 0x4, 0x2e, 0x6f, 0xcb, 0x42, - 0x56, 0xad, 0x55, 0xf7, 0xde, 0xda, 0xe4, 0xde, 0x95, 0x37}; - uint8_t bytesprops6[] = {0x3b, 0xa0, 0xa3, 0xfa, 0xae, 0x26, 0x23, 0x52, 0xa4, 0xb6, 0x98, 0x8f, 0x91, 0x40, - 0x6d, 0x46, 0x29, 0xcc, 0xb6, 0x53, 0x34, 0xbe, 0xc7, 0x4f, 0xfe, 0x24, 0xec}; - uint8_t bytesprops7[] = {0x3a, 0xb0, 0x51}; - uint8_t bytesprops8[] = {0x37, 0x0, 0xae, 0x56, 0xa8, 0xe2, 0xc1, 0x73, 0x76, 0x6f, 0xe1, 0x60, - 0x1b, 0x93, 0xfa, 0x61, 0x3a, 0x31, 0x2e, 0x57, 0xd, 0x4b, 0xf9}; + uint8_t bytesprops0[] = {0xf2, 0xe7, 0x1c, 0x6f, 0xdf, 0xb4, 0x8, 0xf1, 0x29, 0xd6, 0x70, 0x4d, 0x15, 0xa, 0x48, + 0x8a, 0x2b, 0x68, 0x3b, 0x26, 0x74, 0x38, 0x2, 0xd8, 0xb2, 0x71, 0xfb, 0x89, 0x2b}; + uint8_t bytesprops1[] = {0x5f, 0x88, 0xa6, 0x20, 0x1d, 0x19, 0x3, 0xdc, 0x6, 0x5d, 0x5, + 0xc4, 0x36, 0x33, 0x6, 0xf, 0xc5, 0x6b, 0xe4, 0x61, 0x34, 0x2c}; + uint8_t bytesprops2[] = {0x16, 0xc, 0xad, 0xf4, 0x59, 0xf7, 0x7a, 0xa0, 0x69, 0x39, 0x69, 0x80, + 0x43, 0xb2, 0xc9, 0x8f, 0x6f, 0x4d, 0x5, 0x8a, 0xb0, 0x40, 0xc0}; + uint8_t bytesprops3[] = {0xc5, 0x22, 0xc2, 0xd6, 0xf1, 0x61, 0xd1, 0xc7, 0x55, 0x8a, + 0x44, 0xc8, 0x18, 0x22, 0x37, 0x57, 0x4, 0x24, 0x5f, 0x23}; + uint8_t bytesprops4[] = {0xed, 0xca, 0x5e, 0xf4}; + uint8_t bytesprops5[] = {0xef, 0x93, 0x7e, 0x1f, 0x33, 0xde, 0x55, 0x4b, 0xba, + 0x79, 0x1, 0x47, 0xe2, 0xa3, 0x10, 0x98, 0xf2}; + uint8_t bytesprops6[] = {0xed, 0xbf, 0xe4, 0x64, 0xf5, 0x66, 0x75, 0xd7, 0xff, 0xde, 0xab, 0xaa, 0xe5, 0x12, + 0xb8, 0x71, 0x3e, 0x23, 0xef, 0x7, 0x62, 0xfc, 0xbc, 0xd3, 0xd, 0xf7, 0x93, 0x5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10464}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19107}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27838}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15603}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5845}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25078}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops3}, .v = {25, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3649}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32225}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24587}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32208}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11929}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12227}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21923}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31165}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9627}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7912}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17769}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28809}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 162}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 18606, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\200a\188\164\254\SO\133s@", -// _pubPktID = 0, _pubBody = "i\EM\SOH\179\179;\199eG\211b\163Ye\"\211",PropReceiveMaximum 10464,PropResponseInformation -// "n\204",PropServerKeepAlive 19107,PropMessageExpiryInterval 27838,PropWildcardSubscriptionAvailable -// 102,PropMessageExpiryInterval 15603,PropSubscriptionIdentifierAvailable 131,PropCorrelationData -// "l\140",PropSessionExpiryInterval 5845,PropRequestProblemInformation 83,PropRequestProblemInformation -// 46,PropMessageExpiryInterval 25078,PropUserProperty "\150)g\181\184]V]\157\&7S&\132\206\n4\204r\215h{\188vO&\b\159" -// "\207\141\142\222;MI\152\225\220\v\164\149j\254\245>\170\129\128X\161W\"\174",PropMessageExpiryInterval -// 3649,PropAuthenticationData -// "\ACK\t\220\229\130\146\EOT.o\203BV\173U\247\222\218\228\222\149\&7",PropRequestProblemInformation -// 2,PropRetainAvailable 126,PropSessionExpiryInterval 32225,PropPayloadFormatIndicator 175,PropReceiveMaximum -// 24587,PropResponseTopic ";\160\163\250\174&#R\164\182\152\143\145@mF)\204\182S4\190\199O\254$\236",PropMaximumQoS -// 219,PropPayloadFormatIndicator 233,PropTopicAlias 32208,PropContentType ":\176Q",PropResponseTopic -// "7\NUL\174V\168\226\193svo\225`\ESC\147\250a:1.W\rK\249"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// ")\223\215<\151R\ENQ\DC3I\131&\207\&4\179\156\CAN\SO", _pubPktID = 18606, _pubBody = "\208Zo\214\246#v", _pubProps = +// [PropSubscriptionIdentifier 9,PropAuthenticationData +// "\242\231\FSo\223\180\b\241)\214pM\NAK\nH\138+h;&t8\STX\216\178q\251\137+",PropWildcardSubscriptionAvailable +// 246,PropSubscriptionIdentifier 4,PropTopicAliasMaximum 11929,PropSessionExpiryInterval 12227,PropTopicAliasMaximum +// 21923,PropWildcardSubscriptionAvailable 49,PropAssignedClientIdentifier "_\136\166 +// \GS\EM\ETX\220\ACK]\ENQ\196\&63\ACK\SI\197k\228a4,",PropMessageExpiryInterval 31165,PropAuthenticationMethod +// "\SYN\f\173\244Y\247z\160i9i\128C\178\201\143oM\ENQ\138\176@\192",PropCorrelationData +// "\197\"\194\214\241a\209\199U\138D\200\CAN\"7W\EOT$_#",PropResponseTopic "\237\202^\244",PropAssignedClientIdentifier +// "\239\147~\US3\222UK\186y\SOHG\226\163\DLE\152\242",PropReceiveMaximum 9627,PropReceiveMaximum +// 7912,PropAssignedClientIdentifier +// "\237\191\228d\245fu\215\255\222\171\170\229\DC2\184q>#\239\ab\252\188\211\r\247\147\ENQ",PropMaximumQoS +// 55,PropWillDelayInterval 17769,PropTopicAliasMaximum 28809,PropPayloadFormatIndicator 162]} TEST(Publish5QCTest, Decode15) { - uint8_t pkt[] = {0x31, 0x8a, 0x2, 0x0, 0x9, 0xc8, 0x61, 0xbc, 0xa4, 0xfe, 0xe, 0x85, 0x73, 0x40, 0xe8, 0x1, 0x3, - 0x0, 0x10, 0x3e, 0x19, 0x1, 0xb3, 0xb3, 0x3b, 0xc7, 0x65, 0x47, 0xd3, 0x62, 0xa3, 0x59, 0x65, 0x22, - 0xd3, 0x21, 0x28, 0xe0, 0x1a, 0x0, 0x2, 0x6e, 0xcc, 0x13, 0x4a, 0xa3, 0x2, 0x0, 0x0, 0x6c, 0xbe, - 0x28, 0x66, 0x2, 0x0, 0x0, 0x3c, 0xf3, 0x29, 0x83, 0x9, 0x0, 0x2, 0x6c, 0x8c, 0x11, 0x0, 0x0, - 0x16, 0xd5, 0x17, 0x53, 0x17, 0x2e, 0x2, 0x0, 0x0, 0x61, 0xf6, 0x26, 0x0, 0x1b, 0x96, 0x29, 0x67, - 0xb5, 0xb8, 0x5d, 0x56, 0x5d, 0x9d, 0x37, 0x53, 0x26, 0x84, 0xce, 0xa, 0x34, 0xcc, 0x72, 0xd7, 0x68, - 0x7b, 0xbc, 0x76, 0x4f, 0x26, 0x8, 0x9f, 0x0, 0x19, 0xcf, 0x8d, 0x8e, 0xde, 0x3b, 0x4d, 0x49, 0x98, - 0xe1, 0xdc, 0xb, 0xa4, 0x95, 0x6a, 0xfe, 0xf5, 0x3e, 0xaa, 0x81, 0x80, 0x58, 0xa1, 0x57, 0x22, 0xae, - 0x2, 0x0, 0x0, 0xe, 0x41, 0x16, 0x0, 0x15, 0x6, 0x9, 0xdc, 0xe5, 0x82, 0x92, 0x4, 0x2e, 0x6f, - 0xcb, 0x42, 0x56, 0xad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22, 0x55, 0xa3, 0x28, + 0x31, 0x12, 0x0, 0x16, 0x5f, 0x88, 0xa6, 0x20, 0x1d, 0x19, 0x3, 0xdc, 0x6, 0x5d, 0x5, 0xc4, 0x36, 0x33, 0x6, + 0xf, 0xc5, 0x6b, 0xe4, 0x61, 0x34, 0x2c, 0x2, 0x0, 0x0, 0x79, 0xbd, 0x15, 0x0, 0x17, 0x16, 0xc, 0xad, 0xf4, + 0x59, 0xf7, 0x7a, 0xa0, 0x69, 0x39, 0x69, 0x80, 0x43, 0xb2, 0xc9, 0x8f, 0x6f, 0x4d, 0x5, 0x8a, 0xb0, 0x40, 0xc0, + 0x9, 0x0, 0x14, 0xc5, 0x22, 0xc2, 0xd6, 0xf1, 0x61, 0xd1, 0xc7, 0x55, 0x8a, 0x44, 0xc8, 0x18, 0x22, 0x37, 0x57, + 0x4, 0x24, 0x5f, 0x23, 0x8, 0x0, 0x4, 0xed, 0xca, 0x5e, 0xf4, 0x12, 0x0, 0x11, 0xef, 0x93, 0x7e, 0x1f, 0x33, + 0xde, 0x55, 0x4b, 0xba, 0x79, 0x1, 0x47, 0xe2, 0xa3, 0x10, 0x98, 0xf2, 0x21, 0x25, 0x9b, 0x21, 0x1e, 0xe8, 0x12, + 0x0, 0x1c, 0xed, 0xbf, 0xe4, 0x64, 0xf5, 0x66, 0x75, 0xd7, 0xff, 0xde, 0xab, 0xaa, 0xe5, 0x12, 0xb8, 0x71, 0x3e, + 0x23, 0xef, 0x7, 0x62, 0xfc, 0xbc, 0xd3, 0xd, 0xf7, 0x93, 0x5, 0x24, 0x37, 0x18, 0x0, 0x0, 0x45, 0x69, 0x22, + 0x70, 0x89, 0x1, 0xa2, 0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3493,93 +3452,62 @@ TEST(Publish5QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc8, 0x61, 0xbc, 0xa4, 0xfe, 0xe, 0x85, 0x73, 0x40}; - lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x69, 0x3c, 0x55, 0x4a, 0xd9, 0x4a, 0x28, 0x76, 0xa3, 0x5c, 0xd0, - 0x5a, 0xd1, 0x30, 0xec, 0x7e, 0x31, 0x64, 0xd3, 0x58, 0x12}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, + 0x83, 0x26, 0xcf, 0x34, 0xb3, 0x9c, 0x18, 0xe}; + lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 18606); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ">\248\138\204\&7]\233\FS\228\b|\187\148\202aA\US\153\STX\GS\135\211p", _pubPktID = 4359, _pubBody = -// "\242\145\166\143\135]\136Z\130\202\216\&2*\239?C\217\144\162", _pubProps = [PropSharedSubscriptionAvailable -// 179,PropAuthenticationData "4C\158\223\174\165\223\218k\FSy\238\249\197\134\t>",PropRequestProblemInformation -// 118,PropResponseTopic ":\162\STX \239",PropMessageExpiryInterval 16702,PropMaximumQoS 226,PropServerReference -// "\216\176\ACKP\234\&8z\131\&0\221\248kFLX\225\193\STX\223\201L;\217\242\253\t\168\245TP",PropMaximumPacketSize -// 7247,PropSessionExpiryInterval 6004]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\168E\247k\237\175\&5\SO\SYNU\224\160", _pubPktID = 28189, _pubBody = "", _pubProps = [PropResponseInformation +// "Y\236\&2K\172\176\155\149\164\203\&1Q\173",PropWildcardSubscriptionAvailable 109]} TEST(Publish5QCTest, Encode16) { - uint8_t pkt[] = {0x34, 0x81, 0x1, 0x0, 0x17, 0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, - 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70, 0x11, 0x7, 0x52, 0x2a, 0xb3, 0x16, - 0x0, 0x11, 0x34, 0x43, 0x9e, 0xdf, 0xae, 0xa5, 0xdf, 0xda, 0x6b, 0x1c, 0x79, 0xee, 0xf9, 0xc5, 0x86, - 0x9, 0x3e, 0x17, 0x76, 0x8, 0x0, 0x5, 0x3a, 0xa2, 0x2, 0x20, 0xef, 0x2, 0x0, 0x0, 0x41, 0x3e, - 0x24, 0xe2, 0x1c, 0x0, 0x1e, 0xd8, 0xb0, 0x6, 0x50, 0xea, 0x38, 0x7a, 0x83, 0x30, 0xdd, 0xf8, 0x6b, - 0x46, 0x4c, 0x58, 0xe1, 0xc1, 0x2, 0xdf, 0xc9, 0x4c, 0x3b, 0xd9, 0xf2, 0xfd, 0x9, 0xa8, 0xf5, 0x54, - 0x50, 0x27, 0x0, 0x0, 0x1c, 0x4f, 0x11, 0x0, 0x0, 0x17, 0x74, 0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, - 0x88, 0x5a, 0x82, 0xca, 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; - uint8_t topic_bytes[] = {0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, - 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x23, 0x0, 0xc, 0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, + 0x55, 0xe0, 0xa0, 0x6e, 0x1d, 0x12, 0x1a, 0x0, 0xd, 0x59, 0xec, 0x32, 0x4b, + 0xac, 0xb0, 0x9b, 0x95, 0xa4, 0xcb, 0x31, 0x51, 0xad, 0x28, 0x6d}; + uint8_t topic_bytes[] = {0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, - 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; + msg.retained = true; + uint8_t msg_bytes[] = {0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 0; - uint8_t bytesprops0[] = {0x34, 0x43, 0x9e, 0xdf, 0xae, 0xa5, 0xdf, 0xda, 0x6b, - 0x1c, 0x79, 0xee, 0xf9, 0xc5, 0x86, 0x9, 0x3e}; - uint8_t bytesprops1[] = {0x3a, 0xa2, 0x2, 0x20, 0xef}; - uint8_t bytesprops2[] = {0xd8, 0xb0, 0x6, 0x50, 0xea, 0x38, 0x7a, 0x83, 0x30, 0xdd, 0xf8, 0x6b, 0x46, 0x4c, 0x58, - 0xe1, 0xc1, 0x2, 0xdf, 0xc9, 0x4c, 0x3b, 0xd9, 0xf2, 0xfd, 0x9, 0xa8, 0xf5, 0x54, 0x50}; + uint8_t bytesprops0[] = {0x59, 0xec, 0x32, 0x4b, 0xac, 0xb0, 0x9b, 0x95, 0xa4, 0xcb, 0x31, 0x51, 0xad}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16702}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7247}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6004}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 109}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 4359, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 28189, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ">\248\138\204\&7]\233\FS\228\b|\187\148\202aA\US\153\STX\GS\135\211p", _pubPktID = 4359, _pubBody = -// "\242\145\166\143\135]\136Z\130\202\216\&2*\239?C\217\144\162", _pubProps = [PropSharedSubscriptionAvailable -// 179,PropAuthenticationData "4C\158\223\174\165\223\218k\FSy\238\249\197\134\t>",PropRequestProblemInformation -// 118,PropResponseTopic ":\162\STX \239",PropMessageExpiryInterval 16702,PropMaximumQoS 226,PropServerReference -// "\216\176\ACKP\234\&8z\131\&0\221\248kFLX\225\193\STX\223\201L;\217\242\253\t\168\245TP",PropMaximumPacketSize -// 7247,PropSessionExpiryInterval 6004]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\168E\247k\237\175\&5\SO\SYNU\224\160", _pubPktID = 28189, _pubBody = "", _pubProps = [PropResponseInformation +// "Y\236\&2K\172\176\155\149\164\203\&1Q\173",PropWildcardSubscriptionAvailable 109]} TEST(Publish5QCTest, Decode16) { - uint8_t pkt[] = {0x34, 0x81, 0x1, 0x0, 0x17, 0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, - 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70, 0x11, 0x7, 0x52, 0x2a, 0xb3, 0x16, - 0x0, 0x11, 0x34, 0x43, 0x9e, 0xdf, 0xae, 0xa5, 0xdf, 0xda, 0x6b, 0x1c, 0x79, 0xee, 0xf9, 0xc5, 0x86, - 0x9, 0x3e, 0x17, 0x76, 0x8, 0x0, 0x5, 0x3a, 0xa2, 0x2, 0x20, 0xef, 0x2, 0x0, 0x0, 0x41, 0x3e, - 0x24, 0xe2, 0x1c, 0x0, 0x1e, 0xd8, 0xb0, 0x6, 0x50, 0xea, 0x38, 0x7a, 0x83, 0x30, 0xdd, 0xf8, 0x6b, - 0x46, 0x4c, 0x58, 0xe1, 0xc1, 0x2, 0xdf, 0xc9, 0x4c, 0x3b, 0xd9, 0xf2, 0xfd, 0x9, 0xa8, 0xf5, 0x54, - 0x50, 0x27, 0x0, 0x0, 0x1c, 0x4f, 0x11, 0x0, 0x0, 0x17, 0x74, 0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, - 0x88, 0x5a, 0x82, 0xca, 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; + uint8_t pkt[] = {0x35, 0x23, 0x0, 0xc, 0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, + 0x55, 0xe0, 0xa0, 0x6e, 0x1d, 0x12, 0x1a, 0x0, 0xd, 0x59, 0xec, 0x32, 0x4b, + 0xac, 0xb0, 0x9b, 0x95, 0xa4, 0xcb, 0x31, 0x51, 0xad, 0x28, 0x6d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3588,107 +3516,84 @@ TEST(Publish5QCTest, Decode16) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3e, 0xf8, 0x8a, 0xcc, 0x37, 0x5d, 0xe9, 0x1c, 0xe4, 0x8, 0x7c, 0xbb, - 0x94, 0xca, 0x61, 0x41, 0x1f, 0x99, 0x2, 0x1d, 0x87, 0xd3, 0x70}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf2, 0x91, 0xa6, 0x8f, 0x87, 0x5d, 0x88, 0x5a, 0x82, 0xca, - 0xd8, 0x32, 0x2a, 0xef, 0x3f, 0x43, 0xd9, 0x90, 0xa2}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 4359); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 28189); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\245*\174k\165!xK\226\163\190\195\171\228\STXdu\RS", _pubPktID = 10342, _pubBody = -// "\178\172\US)\254\SYN\146\229\NULP\NAK\n\186\220\f\"\SYN\230\190", _pubProps = [PropRequestResponseInformation -// 69,PropTopicAliasMaximum 26959,PropServerKeepAlive 3865,PropTopicAliasMaximum -// 19761,PropSubscriptionIdentifierAvailable 115,PropAuthenticationData "\NUL\214\GScu?p\248\202",PropReceiveMaximum -// 15909,PropUserProperty "\191" "\235\242\RS\167\187Jk\237\&7%\157\192\213>LS\ACKi\"!\175\255",PropTopicAlias -// 31038,PropAuthenticationMethod "v;\218\149\251?tvDk",PropAssignedClientIdentifier -// "\129\EMo\251\138\210\178\248z`\EM\238Z\231\DC1\"!\bI\f\219\176\245\140\149\137\182\202",PropMessageExpiryInterval -// 14407]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\191\CAN?\r\149\&0\185\198\tZ\213\STX5\192\195", _pubPktID = 0, _pubBody = "\190\206\169pC<\142\135\&8\243", +// _pubProps = [PropRequestResponseInformation 30,PropReceiveMaximum 13794,PropSubscriptionIdentifierAvailable +// 193,PropResponseInformation "\204\198\191\192ND\FS\218\DC4",PropSubscriptionIdentifierAvailable 226,PropMaximumQoS +// 112,PropMaximumQoS 106,PropWillDelayInterval 19852,PropTopicAlias 29604,PropMessageExpiryInterval +// 2602,PropContentType ";O\147\155!<~\199\ETX\215\SOHcc\DC4i\247I\231"]} TEST(Publish5QCTest, Encode17) { - uint8_t pkt[] = {0x32, 0x96, 0x1, 0x0, 0x12, 0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, 0xa3, 0xbe, - 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e, 0x28, 0x66, 0x6c, 0x19, 0x45, 0x22, 0x69, 0x4f, 0x13, - 0xf, 0x19, 0x22, 0x4d, 0x31, 0x29, 0x73, 0x16, 0x0, 0x9, 0x0, 0xd6, 0x1d, 0x63, 0x75, 0x3f, - 0x70, 0xf8, 0xca, 0x21, 0x3e, 0x25, 0x26, 0x0, 0x1, 0xbf, 0x0, 0x16, 0xeb, 0xf2, 0x1e, 0xa7, - 0xbb, 0x4a, 0x6b, 0xed, 0x37, 0x25, 0x9d, 0xc0, 0xd5, 0x3e, 0x4c, 0x53, 0x6, 0x69, 0x22, 0x21, - 0xaf, 0xff, 0x23, 0x79, 0x3e, 0x15, 0x0, 0xa, 0x76, 0x3b, 0xda, 0x95, 0xfb, 0x3f, 0x74, 0x76, - 0x44, 0x6b, 0x12, 0x0, 0x1c, 0x81, 0x19, 0x6f, 0xfb, 0x8a, 0xd2, 0xb2, 0xf8, 0x7a, 0x60, 0x19, - 0xee, 0x5a, 0xe7, 0x11, 0x22, 0x21, 0x8, 0x49, 0xc, 0xdb, 0xb0, 0xf5, 0x8c, 0x95, 0x89, 0xb6, - 0xca, 0x2, 0x0, 0x0, 0x38, 0x47, 0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, - 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; - uint8_t topic_bytes[] = {0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, - 0xa3, 0xbe, 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x57, 0x0, 0xf, 0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, + 0x2, 0x35, 0xc0, 0xc3, 0x3b, 0x19, 0x1e, 0x21, 0x35, 0xe2, 0x29, 0xc1, 0x1a, 0x0, 0x9, + 0xcc, 0xc6, 0xbf, 0xc0, 0x4e, 0x44, 0x1c, 0xda, 0x14, 0x29, 0xe2, 0x24, 0x70, 0x24, 0x6a, + 0x18, 0x0, 0x0, 0x4d, 0x8c, 0x23, 0x73, 0xa4, 0x2, 0x0, 0x0, 0xa, 0x2a, 0x3, 0x0, + 0x12, 0x3b, 0x4f, 0x93, 0x9b, 0x21, 0x3c, 0x7e, 0xc7, 0x3, 0xd7, 0x1, 0x63, 0x63, 0x14, + 0x69, 0xf7, 0x49, 0xe7, 0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; + uint8_t topic_bytes[] = {0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, 0x2, 0x35, 0xc0, 0xc3}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, - 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 10; - uint8_t bytesprops0[] = {0x0, 0xd6, 0x1d, 0x63, 0x75, 0x3f, 0x70, 0xf8, 0xca}; - uint8_t bytesprops2[] = {0xeb, 0xf2, 0x1e, 0xa7, 0xbb, 0x4a, 0x6b, 0xed, 0x37, 0x25, 0x9d, - 0xc0, 0xd5, 0x3e, 0x4c, 0x53, 0x6, 0x69, 0x22, 0x21, 0xaf, 0xff}; - uint8_t bytesprops1[] = {0xbf}; - uint8_t bytesprops3[] = {0x76, 0x3b, 0xda, 0x95, 0xfb, 0x3f, 0x74, 0x76, 0x44, 0x6b}; - uint8_t bytesprops4[] = {0x81, 0x19, 0x6f, 0xfb, 0x8a, 0xd2, 0xb2, 0xf8, 0x7a, 0x60, 0x19, 0xee, 0x5a, 0xe7, - 0x11, 0x22, 0x21, 0x8, 0x49, 0xc, 0xdb, 0xb0, 0xf5, 0x8c, 0x95, 0x89, 0xb6, 0xca}; + uint8_t bytesprops0[] = {0xcc, 0xc6, 0xbf, 0xc0, 0x4e, 0x44, 0x1c, 0xda, 0x14}; + uint8_t bytesprops1[] = {0x3b, 0x4f, 0x93, 0x9b, 0x21, 0x3c, 0x7e, 0xc7, 0x3, + 0xd7, 0x1, 0x63, 0x63, 0x14, 0x69, 0xf7, 0x49, 0xe7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26959}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3865}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19761}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15909}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops1}, .v = {22, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31038}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14407}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13794}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19852}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29604}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2602}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10342, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\245*\174k\165!xK\226\163\190\195\171\228\STXdu\RS", _pubPktID = 10342, _pubBody = -// "\178\172\US)\254\SYN\146\229\NULP\NAK\n\186\220\f\"\SYN\230\190", _pubProps = [PropRequestResponseInformation -// 69,PropTopicAliasMaximum 26959,PropServerKeepAlive 3865,PropTopicAliasMaximum -// 19761,PropSubscriptionIdentifierAvailable 115,PropAuthenticationData "\NUL\214\GScu?p\248\202",PropReceiveMaximum -// 15909,PropUserProperty "\191" "\235\242\RS\167\187Jk\237\&7%\157\192\213>LS\ACKi\"!\175\255",PropTopicAlias -// 31038,PropAuthenticationMethod "v;\218\149\251?tvDk",PropAssignedClientIdentifier -// "\129\EMo\251\138\210\178\248z`\EM\238Z\231\DC1\"!\bI\f\219\176\245\140\149\137\182\202",PropMessageExpiryInterval -// 14407]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\191\CAN?\r\149\&0\185\198\tZ\213\STX5\192\195", _pubPktID = 0, _pubBody = "\190\206\169pC<\142\135\&8\243", +// _pubProps = [PropRequestResponseInformation 30,PropReceiveMaximum 13794,PropSubscriptionIdentifierAvailable +// 193,PropResponseInformation "\204\198\191\192ND\FS\218\DC4",PropSubscriptionIdentifierAvailable 226,PropMaximumQoS +// 112,PropMaximumQoS 106,PropWillDelayInterval 19852,PropTopicAlias 29604,PropMessageExpiryInterval +// 2602,PropContentType ";O\147\155!<~\199\ETX\215\SOHcc\DC4i\247I\231"]} TEST(Publish5QCTest, Decode17) { - uint8_t pkt[] = {0x32, 0x96, 0x1, 0x0, 0x12, 0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, 0xa3, 0xbe, - 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e, 0x28, 0x66, 0x6c, 0x19, 0x45, 0x22, 0x69, 0x4f, 0x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93, 0x9b, 0x21, 0x3c, 0x7e, 0xc7, 0x3, 0xd7, 0x1, 0x63, 0x63, 0x14, + 0x69, 0xf7, 0x49, 0xe7, 0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3697,124 +3602,121 @@ TEST(Publish5QCTest, Decode17) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf5, 0x2a, 0xae, 0x6b, 0xa5, 0x21, 0x78, 0x4b, 0xe2, - 0xa3, 0xbe, 0xc3, 0xab, 0xe4, 0x2, 0x64, 0x75, 0x1e}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb2, 0xac, 0x1f, 0x29, 0xfe, 0x16, 0x92, 0xe5, 0x0, 0x50, - 0x15, 0xa, 0xba, 0xdc, 0xc, 0x22, 0x16, 0xe6, 0xbe}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10342); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + uint8_t exp_topic_bytes[] = {0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, 0x2, 0x35, 0xc0, 0xc3}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "W\DC4\201\190\193\SUB\164\DC3i\182]\GS", _pubPktID = 18773, _pubBody = -// "*F\223\201\140z\253\&8Q\176\t\175!\148(4\SOH\248\EM\192\217B\193\220\225", _pubProps = [PropReceiveMaximum -// 5186,PropReasonString "i\"P3\156",PropServerKeepAlive 29277,PropWillDelayInterval 7450,PropUserProperty -// "zzg\ACK)j\NAK\206\SUB,\GS\182\217\137\181\197\219\172,p\229,\133\168\DLE\132\223\SIn" -// "\248\138\STX\154Y\NAK\164\202o7\161\254\b-\128\225\&4\166=V<\164\fL*pK\180\&6\254",PropTopicAliasMaximum -// 6168,PropAssignedClientIdentifier "\a",PropServerKeepAlive 30055,PropAuthenticationData -// "\183*q\146N\229=0\210b\\\160\156",PropSessionExpiryInterval 29274,PropRetainAvailable 211,PropMessageExpiryInterval -// 26698,PropServerReference "i\242\222\201\157\r\235.\150\\\168L",PropMessageExpiryInterval -// 532,PropSubscriptionIdentifier 18,PropUserProperty "k\241\&4\215\234\&1\157" "%\180 -// \145\144!\200\190<7jc\SI[Ph\b\ETX"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\209\227N0}\DEL\200\186\135Q\178Ab\227[N~\173\197\252P", _pubPktID = 17259, _pubBody = +// "\211\&9\214\163\194\138\\\205\223\162\148\156\131\232\SYN\215\213\DC4\174", _pubProps = [PropReceiveMaximum +// 22801,PropAuthenticationData "\207\205\ESC\151",PropMaximumPacketSize 18459,PropTopicAlias 3707,PropRetainAvailable +// 96,PropServerReference "\230\129#r\158\231m+\FS\163,z\200\254\152",PropTopicAliasMaximum +// 23376,PropSubscriptionIdentifier 1,PropRetainAvailable 81,PropMessageExpiryInterval 31204,PropReasonString +// "\137\ENQ\150\185\218",PropPayloadFormatIndicator 122,PropMaximumPacketSize 6063,PropMessageExpiryInterval +// 14185,PropSharedSubscriptionAvailable 118,PropPayloadFormatIndicator 113,PropSubscriptionIdentifier +// 20,PropSubscriptionIdentifierAvailable 192,PropMessageExpiryInterval 21107,PropWildcardSubscriptionAvailable +// 3,PropServerKeepAlive 14528,PropCorrelationData "x",PropAuthenticationMethod "1z&[",PropMaximumQoS +// 46,PropSharedSubscriptionAvailable 61,PropMaximumQoS 55]} TEST(Publish5QCTest, Encode18) { - uint8_t pkt[] = {0x3a, 0xd8, 0x1, 0x0, 0xc, 0x57, 0x14, 0xc9, 0xbe, 0xc1, 0x1a, 0xa4, 0x13, 0x69, 0xb6, 0x5d, 0x1d, - 0x49, 0x55, 0xad, 0x1, 0x21, 0x14, 0x42, 0x1f, 0x0, 0x5, 0x69, 0x22, 0x50, 0x33, 0x9c, 0x13, 0x72, - 0x5d, 0x18, 0x0, 0x0, 0x1d, 0x1a, 0x26, 0x0, 0x1d, 0x7a, 0x7a, 0x67, 0x6, 0x29, 0x6a, 0x15, 0xce, - 0x1a, 0x2c, 0x1d, 0xb6, 0xd9, 0x89, 0xb5, 0xc5, 0xdb, 0xac, 0x2c, 0x70, 0xe5, 0x2c, 0x85, 0xa8, 0x10, - 0x84, 0xdf, 0xf, 0x6e, 0x0, 0x1e, 0xf8, 0x8a, 0x2, 0x9a, 0x59, 0x15, 0xa4, 0xca, 0x6f, 0x37, 0xa1, - 0xfe, 0x8, 0x2d, 0x80, 0xe1, 0x34, 0xa6, 0x3d, 0x56, 0x3c, 0xa4, 0xc, 0x4c, 0x2a, 0x70, 0x4b, 0xb4, - 0x36, 0xfe, 0x22, 0x18, 0x18, 0x12, 0x0, 0x1, 0x7, 0x13, 0x75, 0x67, 0x16, 0x0, 0xd, 0xb7, 0x2a, - 0x71, 0x92, 0x4e, 0xe5, 0x3d, 0x30, 0xd2, 0x62, 0x5c, 0xa0, 0x9c, 0x11, 0x0, 0x0, 0x72, 0x5a, 0x25, - 0xd3, 0x2, 0x0, 0x0, 0x68, 0x4a, 0x1c, 0x0, 0xc, 0x69, 0xf2, 0xde, 0xc9, 0x9d, 0xd, 0xeb, 0x2e, - 0x96, 0x5c, 0xa8, 0x4c, 0x2, 0x0, 0x0, 0x2, 0x14, 0xb, 0x12, 0x26, 0x0, 0x7, 0x6b, 0xf1, 0x34, - 0xd7, 0xea, 0x31, 0x9d, 0x0, 0x12, 0x25, 0xb4, 0x20, 0x91, 0x90, 0x21, 0xc8, 0xbe, 0x3c, 0x37, 0x6a, - 0x63, 0xf, 0x5b, 0x50, 0x68, 0x8, 0x3, 0x2a, 0x46, 0xdf, 0xc9, 0x8c, 0x7a, 0xfd, 0x38, 0x51, 0xb0, - 0x9, 0xaf, 0x21, 0x94, 0x28, 0x34, 0x1, 0xf8, 0x19, 0xc0, 0xd9, 0x42, 0xc1, 0xdc, 0xe1}; - uint8_t topic_bytes[] = {0x57, 0x14, 0xc9, 0xbe, 0xc1, 0x1a, 0xa4, 0x13, 0x69, 0xb6, 0x5d, 0x1d}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x96, 0x1, 0x0, 0x15, 0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, + 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50, 0x43, 0x6b, 0x69, 0x21, 0x59, 0x11, + 0x16, 0x0, 0x4, 0xcf, 0xcd, 0x1b, 0x97, 0x27, 0x0, 0x0, 0x48, 0x1b, 0x23, 0xe, 0x7b, 0x25, + 0x60, 0x1c, 0x0, 0xf, 0xe6, 0x81, 0x23, 0x72, 0x9e, 0xe7, 0x6d, 0x2b, 0x1c, 0xa3, 0x2c, 0x7a, + 0xc8, 0xfe, 0x98, 0x22, 0x5b, 0x50, 0xb, 0x1, 0x25, 0x51, 0x2, 0x0, 0x0, 0x79, 0xe4, 0x1f, + 0x0, 0x5, 0x89, 0x5, 0x96, 0xb9, 0xda, 0x1, 0x7a, 0x27, 0x0, 0x0, 0x17, 0xaf, 0x2, 0x0, + 0x0, 0x37, 0x69, 0x2a, 0x76, 0x1, 0x71, 0xb, 0x14, 0x29, 0xc0, 0x2, 0x0, 0x0, 0x52, 0x73, + 0x28, 0x3, 0x13, 0x38, 0xc0, 0x9, 0x0, 0x1, 0x78, 0x15, 0x0, 0x4, 0x31, 0x7a, 0x26, 0x5b, + 0x24, 0x2e, 0x2a, 0x3d, 0x24, 0x37, 0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, + 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; + uint8_t topic_bytes[] = {0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, + 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x2a, 0x46, 0xdf, 0xc9, 0x8c, 0x7a, 0xfd, 0x38, 0x51, 0xb0, 0x9, 0xaf, 0x21, - 0x94, 0x28, 0x34, 0x1, 0xf8, 0x19, 0xc0, 0xd9, 0x42, 0xc1, 0xdc, 0xe1}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, + 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 25; + msg.payload_len = 19; - uint8_t bytesprops0[] = {0x69, 0x22, 0x50, 0x33, 0x9c}; - uint8_t bytesprops2[] = {0xf8, 0x8a, 0x2, 0x9a, 0x59, 0x15, 0xa4, 0xca, 0x6f, 0x37, 0xa1, 0xfe, 0x8, 0x2d, 0x80, - 0xe1, 0x34, 0xa6, 0x3d, 0x56, 0x3c, 0xa4, 0xc, 0x4c, 0x2a, 0x70, 0x4b, 0xb4, 0x36, 0xfe}; - uint8_t bytesprops1[] = {0x7a, 0x7a, 0x67, 0x6, 0x29, 0x6a, 0x15, 0xce, 0x1a, 0x2c, 0x1d, 0xb6, 0xd9, 0x89, 0xb5, - 0xc5, 0xdb, 0xac, 0x2c, 0x70, 0xe5, 0x2c, 0x85, 0xa8, 0x10, 0x84, 0xdf, 0xf, 0x6e}; - uint8_t bytesprops3[] = {0x7}; - uint8_t bytesprops4[] = {0xb7, 0x2a, 0x71, 0x92, 0x4e, 0xe5, 0x3d, 0x30, 0xd2, 0x62, 0x5c, 0xa0, 0x9c}; - uint8_t bytesprops5[] = {0x69, 0xf2, 0xde, 0xc9, 0x9d, 0xd, 0xeb, 0x2e, 0x96, 0x5c, 0xa8, 0x4c}; - uint8_t bytesprops7[] = {0x25, 0xb4, 0x20, 0x91, 0x90, 0x21, 0xc8, 0xbe, 0x3c, - 0x37, 0x6a, 0x63, 0xf, 0x5b, 0x50, 0x68, 0x8, 0x3}; - uint8_t bytesprops6[] = {0x6b, 0xf1, 0x34, 0xd7, 0xea, 0x31, 0x9d}; + uint8_t bytesprops0[] = {0xcf, 0xcd, 0x1b, 0x97}; + uint8_t bytesprops1[] = {0xe6, 0x81, 0x23, 0x72, 0x9e, 0xe7, 0x6d, 0x2b, 0x1c, 0xa3, 0x2c, 0x7a, 0xc8, 0xfe, 0x98}; + uint8_t bytesprops2[] = {0x89, 0x5, 0x96, 0xb9, 0xda}; + uint8_t bytesprops3[] = {0x78}; + uint8_t bytesprops4[] = {0x31, 0x7a, 0x26, 0x5b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5186}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29277}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7450}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6168}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30055}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29274}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26698}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 532}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops6}, .v = {18, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22801}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18459}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3707}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23376}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31204}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6063}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14185}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21107}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14528}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 55}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 18773, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 17259, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "W\DC4\201\190\193\SUB\164\DC3i\182]\GS", _pubPktID = 18773, _pubBody = -// "*F\223\201\140z\253\&8Q\176\t\175!\148(4\SOH\248\EM\192\217B\193\220\225", _pubProps = [PropReceiveMaximum -// 5186,PropReasonString "i\"P3\156",PropServerKeepAlive 29277,PropWillDelayInterval 7450,PropUserProperty -// "zzg\ACK)j\NAK\206\SUB,\GS\182\217\137\181\197\219\172,p\229,\133\168\DLE\132\223\SIn" -// "\248\138\STX\154Y\NAK\164\202o7\161\254\b-\128\225\&4\166=V<\164\fL*pK\180\&6\254",PropTopicAliasMaximum -// 6168,PropAssignedClientIdentifier "\a",PropServerKeepAlive 30055,PropAuthenticationData -// "\183*q\146N\229=0\210b\\\160\156",PropSessionExpiryInterval 29274,PropRetainAvailable 211,PropMessageExpiryInterval -// 26698,PropServerReference "i\242\222\201\157\r\235.\150\\\168L",PropMessageExpiryInterval -// 532,PropSubscriptionIdentifier 18,PropUserProperty "k\241\&4\215\234\&1\157" "%\180 -// \145\144!\200\190<7jc\SI[Ph\b\ETX"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\209\227N0}\DEL\200\186\135Q\178Ab\227[N~\173\197\252P", _pubPktID = 17259, _pubBody = +// "\211\&9\214\163\194\138\\\205\223\162\148\156\131\232\SYN\215\213\DC4\174", _pubProps = [PropReceiveMaximum +// 22801,PropAuthenticationData "\207\205\ESC\151",PropMaximumPacketSize 18459,PropTopicAlias 3707,PropRetainAvailable +// 96,PropServerReference "\230\129#r\158\231m+\FS\163,z\200\254\152",PropTopicAliasMaximum +// 23376,PropSubscriptionIdentifier 1,PropRetainAvailable 81,PropMessageExpiryInterval 31204,PropReasonString +// "\137\ENQ\150\185\218",PropPayloadFormatIndicator 122,PropMaximumPacketSize 6063,PropMessageExpiryInterval +// 14185,PropSharedSubscriptionAvailable 118,PropPayloadFormatIndicator 113,PropSubscriptionIdentifier +// 20,PropSubscriptionIdentifierAvailable 192,PropMessageExpiryInterval 21107,PropWildcardSubscriptionAvailable +// 3,PropServerKeepAlive 14528,PropCorrelationData "x",PropAuthenticationMethod "1z&[",PropMaximumQoS +// 46,PropSharedSubscriptionAvailable 61,PropMaximumQoS 55]} TEST(Publish5QCTest, Decode18) { - uint8_t pkt[] = {0x3a, 0xd8, 0x1, 0x0, 0xc, 0x57, 0x14, 0xc9, 0xbe, 0xc1, 0x1a, 0xa4, 0x13, 0x69, 0xb6, 0x5d, 0x1d, - 0x49, 0x55, 0xad, 0x1, 0x21, 0x14, 0x42, 0x1f, 0x0, 0x5, 0x69, 0x22, 0x50, 0x33, 0x9c, 0x13, 0x72, - 0x5d, 0x18, 0x0, 0x0, 0x1d, 0x1a, 0x26, 0x0, 0x1d, 0x7a, 0x7a, 0x67, 0x6, 0x29, 0x6a, 0x15, 0xce, - 0x1a, 0x2c, 0x1d, 0xb6, 0xd9, 0x89, 0xb5, 0xc5, 0xdb, 0xac, 0x2c, 0x70, 0xe5, 0x2c, 0x85, 0xa8, 0x10, - 0x84, 0xdf, 0xf, 0x6e, 0x0, 0x1e, 0xf8, 0x8a, 0x2, 0x9a, 0x59, 0x15, 0xa4, 0xca, 0x6f, 0x37, 0xa1, - 0xfe, 0x8, 0x2d, 0x80, 0xe1, 0x34, 0xa6, 0x3d, 0x56, 0x3c, 0xa4, 0xc, 0x4c, 0x2a, 0x70, 0x4b, 0xb4, - 0x36, 0xfe, 0x22, 0x18, 0x18, 0x12, 0x0, 0x1, 0x7, 0x13, 0x75, 0x67, 0x16, 0x0, 0xd, 0xb7, 0x2a, - 0x71, 0x92, 0x4e, 0xe5, 0x3d, 0x30, 0xd2, 0x62, 0x5c, 0xa0, 0x9c, 0x11, 0x0, 0x0, 0x72, 0x5a, 0x25, - 0xd3, 0x2, 0x0, 0x0, 0x68, 0x4a, 0x1c, 0x0, 0xc, 0x69, 0xf2, 0xde, 0xc9, 0x9d, 0xd, 0xeb, 0x2e, - 0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 0x15, 0x0, 0x4, 0x31, 0x7a, 0x26, 0x5b, + 0x24, 0x2e, 0x2a, 0x3d, 0x24, 0x37, 0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, + 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3823,128 +3725,110 @@ TEST(Publish5QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x57, 0x14, 0xc9, 0xbe, 0xc1, 0x1a, 0xa4, 0x13, 0x69, 0xb6, 0x5d, 0x1d}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2a, 0x46, 0xdf, 0xc9, 0x8c, 0x7a, 0xfd, 0x38, 0x51, 0xb0, 0x9, 0xaf, 0x21, - 0x94, 0x28, 0x34, 0x1, 0xf8, 0x19, 0xc0, 0xd9, 0x42, 0xc1, 0xdc, 0xe1}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, + 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, + 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 18773); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 17259); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\194", _pubPktID = 0, _pubBody = -// "\251\145\"\229\t+\230\175\144\209p\ETX^\217KR\195", _pubProps = [PropResponseTopic -// "\195\GS\250\"\175\133\fN\SO#=\199fBU4",PropResponseInformation "\236\207?\DC1\194+\239\&4",PropTopicAlias -// 23167,PropSubscriptionIdentifierAvailable 113,PropUserProperty "\200\181\130\173K]\179\DEL>\SYN\EOTM\FS\186V" -// "p@N\FS\250\ETB,\214\185:\\\171",PropResponseInformation -// "\228\&3B\157\225\189\212\STXz~\229x\255\129^\237\156m\vj\181\213\STX\128\144\SUBB\205",PropRequestProblemInformation -// 131,PropReasonString ",\167\249h\215*\174\138\216\129\161\233\SUB",PropSharedSubscriptionAvailable -// 145,PropCorrelationData -// "I\b\179zw\197\246j\209\171\255\SUBm\138\174\f\129\145y\239\155",PropRequestProblemInformation 70,PropReasonString -// "l",PropMessageExpiryInterval 25951,PropResponseInformation -// "\142\149\130_W\180g\148\"\SYN>\221\194i\DC2w\148\162/\210\169}\251t\SOH#\NUL\195v3",PropSharedSubscriptionAvailable -// 144,PropWildcardSubscriptionAvailable 11,PropReceiveMaximum 16763]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\157\255\149\212\150\224\139\154J\197\&0C\166\189\203/\179f$J\197-\r\240\SUB\188;\r\173", _pubPktID = 22738, +// _pubBody = "\210\DC1\143z\164\179\bD\DELn", _pubProps = [PropMessageExpiryInterval 27990,PropMaximumPacketSize +// 22586,PropAssignedClientIdentifier "o@Z\207\212\141\233\136\149Yk\178b=\134OgP\ENQ\171_",PropAuthenticationData +// "@6\200\241\163\154\211\181L",PropAuthenticationData "8r\237\205\195\141\167\190\173L",PropAuthenticationData +// "*\149\SYNC\208\FS\145T7oDG\206\213\&1\153\231\&2s\192i\ENQ\FS\170\158|\SYN\ENQ",PropReceiveMaximum +// 24325,PropCorrelationData +// "\128\r\194\188\187\vVbUN_\181\&8\142:\195\236_XF\165\168\CAN\f\150DV\192\147",PropResponseInformation +// "k\DC1\198M\EM\132\196\219\197\ETB+\254\ESC\138\209\182p-\158\251"]} TEST(Publish5QCTest, Encode19) { - uint8_t pkt[] = {0x31, 0xd8, 0x1, 0x0, 0x2, 0xdd, 0xc2, 0xc1, 0x1, 0x8, 0x0, 0x10, 0xc3, 0x1d, 0xfa, 0x22, 0xaf, - 0x85, 0xc, 0x4e, 0xe, 0x23, 0x3d, 0xc7, 0x66, 0x42, 0x55, 0x34, 0x1a, 0x0, 0x8, 0xec, 0xcf, 0x3f, - 0x11, 0xc2, 0x2b, 0xef, 0x34, 0x23, 0x5a, 0x7f, 0x29, 0x71, 0x26, 0x0, 0xf, 0xc8, 0xb5, 0x82, 0xad, - 0x4b, 0x5d, 0xb3, 0x7f, 0x3e, 0x16, 0x4, 0x4d, 0x1c, 0xba, 0x56, 0x0, 0xc, 0x70, 0x40, 0x4e, 0x1c, - 0xfa, 0x17, 0x2c, 0xd6, 0xb9, 0x3a, 0x5c, 0xab, 0x1a, 0x0, 0x1c, 0xe4, 0x33, 0x42, 0x9d, 0xe1, 0xbd, - 0xd4, 0x2, 0x7a, 0x7e, 0xe5, 0x78, 0xff, 0x81, 0x5e, 0xed, 0x9c, 0x6d, 0xb, 0x6a, 0xb5, 0xd5, 0x2, - 0x80, 0x90, 0x1a, 0x42, 0xcd, 0x17, 0x83, 0x1f, 0x0, 0xd, 0x2c, 0xa7, 0xf9, 0x68, 0xd7, 0x2a, 0xae, - 0x8a, 0xd8, 0x81, 0xa1, 0xe9, 0x1a, 0x2a, 0x91, 0x9, 0x0, 0x15, 0x49, 0x8, 0xb3, 0x7a, 0x77, 0xc5, - 0xf6, 0x6a, 0xd1, 0xab, 0xff, 0x1a, 0x6d, 0x8a, 0xae, 0xc, 0x81, 0x91, 0x79, 0xef, 0x9b, 0x17, 0x46, - 0x1f, 0x0, 0x1, 0x6c, 0x2, 0x0, 0x0, 0x65, 0x5f, 0x1a, 0x0, 0x1e, 0x8e, 0x95, 0x82, 0x5f, 0x57, - 0xb4, 0x67, 0x94, 0x22, 0x16, 0x3e, 0xdd, 0xc2, 0x69, 0x12, 0x77, 0x94, 0xa2, 0x2f, 0xd2, 0xa9, 0x7d, - 0xfb, 0x74, 0x1, 0x23, 0x0, 0xc3, 0x76, 0x33, 0x2a, 0x90, 0x28, 0xb, 0x21, 0x41, 0x7b, 0xfb, 0x91, - 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; - uint8_t topic_bytes[] = {0xdd, 0xc2}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0xc1, 0x1, 0x0, 0x1d, 0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, 0x43, + 0xa6, 0xbd, 0xcb, 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, 0x3b, 0xd, 0xad, + 0x58, 0xd2, 0x94, 0x1, 0x2, 0x0, 0x0, 0x6d, 0x56, 0x27, 0x0, 0x0, 0x58, 0x3a, 0x12, 0x0, 0x15, + 0x6f, 0x40, 0x5a, 0xcf, 0xd4, 0x8d, 0xe9, 0x88, 0x95, 0x59, 0x6b, 0xb2, 0x62, 0x3d, 0x86, 0x4f, 0x67, + 0x50, 0x5, 0xab, 0x5f, 0x16, 0x0, 0x9, 0x40, 0x36, 0xc8, 0xf1, 0xa3, 0x9a, 0xd3, 0xb5, 0x4c, 0x16, + 0x0, 0xa, 0x38, 0x72, 0xed, 0xcd, 0xc3, 0x8d, 0xa7, 0xbe, 0xad, 0x4c, 0x16, 0x0, 0x1c, 0x2a, 0x95, + 0x16, 0x43, 0xd0, 0x1c, 0x91, 0x54, 0x37, 0x6f, 0x44, 0x47, 0xce, 0xd5, 0x31, 0x99, 0xe7, 0x32, 0x73, + 0xc0, 0x69, 0x5, 0x1c, 0xaa, 0x9e, 0x7c, 0x16, 0x5, 0x21, 0x5f, 0x5, 0x9, 0x0, 0x1d, 0x80, 0xd, + 0xc2, 0xbc, 0xbb, 0xb, 0x56, 0x62, 0x55, 0x4e, 0x5f, 0xb5, 0x38, 0x8e, 0x3a, 0xc3, 0xec, 0x5f, 0x58, + 0x46, 0xa5, 0xa8, 0x18, 0xc, 0x96, 0x44, 0x56, 0xc0, 0x93, 0x1a, 0x0, 0x14, 0x6b, 0x11, 0xc6, 0x4d, + 0x19, 0x84, 0xc4, 0xdb, 0xc5, 0x17, 0x2b, 0xfe, 0x1b, 0x8a, 0xd1, 0xb6, 0x70, 0x2d, 0x9e, 0xfb, 0xd2, + 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; + uint8_t topic_bytes[] = {0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, 0x43, 0xa6, 0xbd, 0xcb, + 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, 0x3b, 0xd, 0xad}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, - 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; - - uint8_t bytesprops0[] = {0xc3, 0x1d, 0xfa, 0x22, 0xaf, 0x85, 0xc, 0x4e, - 0xe, 0x23, 0x3d, 0xc7, 0x66, 0x42, 0x55, 0x34}; - uint8_t bytesprops1[] = {0xec, 0xcf, 0x3f, 0x11, 0xc2, 0x2b, 0xef, 0x34}; - uint8_t bytesprops3[] = {0x70, 0x40, 0x4e, 0x1c, 0xfa, 0x17, 0x2c, 0xd6, 0xb9, 0x3a, 0x5c, 0xab}; - uint8_t bytesprops2[] = {0xc8, 0xb5, 0x82, 0xad, 0x4b, 0x5d, 0xb3, 0x7f, 0x3e, 0x16, 0x4, 0x4d, 0x1c, 0xba, 0x56}; - uint8_t bytesprops4[] = {0xe4, 0x33, 0x42, 0x9d, 0xe1, 0xbd, 0xd4, 0x2, 0x7a, 0x7e, 0xe5, 0x78, 0xff, 0x81, - 0x5e, 0xed, 0x9c, 0x6d, 0xb, 0x6a, 0xb5, 0xd5, 0x2, 0x80, 0x90, 0x1a, 0x42, 0xcd}; - uint8_t bytesprops5[] = {0x2c, 0xa7, 0xf9, 0x68, 0xd7, 0x2a, 0xae, 0x8a, 0xd8, 0x81, 0xa1, 0xe9, 0x1a}; - uint8_t bytesprops6[] = {0x49, 0x8, 0xb3, 0x7a, 0x77, 0xc5, 0xf6, 0x6a, 0xd1, 0xab, 0xff, - 0x1a, 0x6d, 0x8a, 0xae, 0xc, 0x81, 0x91, 0x79, 0xef, 0x9b}; - uint8_t bytesprops7[] = {0x6c}; - uint8_t bytesprops8[] = {0x8e, 0x95, 0x82, 0x5f, 0x57, 0xb4, 0x67, 0x94, 0x22, 0x16, 0x3e, 0xdd, 0xc2, 0x69, 0x12, - 0x77, 0x94, 0xa2, 0x2f, 0xd2, 0xa9, 0x7d, 0xfb, 0x74, 0x1, 0x23, 0x0, 0xc3, 0x76, 0x33}; + msg.payload_len = 10; + + uint8_t bytesprops0[] = {0x6f, 0x40, 0x5a, 0xcf, 0xd4, 0x8d, 0xe9, 0x88, 0x95, 0x59, 0x6b, + 0xb2, 0x62, 0x3d, 0x86, 0x4f, 0x67, 0x50, 0x5, 0xab, 0x5f}; + uint8_t bytesprops1[] = {0x40, 0x36, 0xc8, 0xf1, 0xa3, 0x9a, 0xd3, 0xb5, 0x4c}; + uint8_t bytesprops2[] = {0x38, 0x72, 0xed, 0xcd, 0xc3, 0x8d, 0xa7, 0xbe, 0xad, 0x4c}; + uint8_t bytesprops3[] = {0x2a, 0x95, 0x16, 0x43, 0xd0, 0x1c, 0x91, 0x54, 0x37, 0x6f, 0x44, 0x47, 0xce, 0xd5, + 0x31, 0x99, 0xe7, 0x32, 0x73, 0xc0, 0x69, 0x5, 0x1c, 0xaa, 0x9e, 0x7c, 0x16, 0x5}; + uint8_t bytesprops4[] = {0x80, 0xd, 0xc2, 0xbc, 0xbb, 0xb, 0x56, 0x62, 0x55, 0x4e, 0x5f, 0xb5, 0x38, 0x8e, 0x3a, + 0xc3, 0xec, 0x5f, 0x58, 0x46, 0xa5, 0xa8, 0x18, 0xc, 0x96, 0x44, 0x56, 0xc0, 0x93}; + uint8_t bytesprops5[] = {0x6b, 0x11, 0xc6, 0x4d, 0x19, 0x84, 0xc4, 0xdb, 0xc5, 0x17, + 0x2b, 0xfe, 0x1b, 0x8a, 0xd1, 0xb6, 0x70, 0x2d, 0x9e, 0xfb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23167}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops2}, .v = {12, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25951}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16763}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27990}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22586}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24325}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 22738, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\221\194", _pubPktID = 0, _pubBody = -// "\251\145\"\229\t+\230\175\144\209p\ETX^\217KR\195", _pubProps = [PropResponseTopic -// "\195\GS\250\"\175\133\fN\SO#=\199fBU4",PropResponseInformation "\236\207?\DC1\194+\239\&4",PropTopicAlias -// 23167,PropSubscriptionIdentifierAvailable 113,PropUserProperty "\200\181\130\173K]\179\DEL>\SYN\EOTM\FS\186V" -// "p@N\FS\250\ETB,\214\185:\\\171",PropResponseInformation -// "\228\&3B\157\225\189\212\STXz~\229x\255\129^\237\156m\vj\181\213\STX\128\144\SUBB\205",PropRequestProblemInformation -// 131,PropReasonString ",\167\249h\215*\174\138\216\129\161\233\SUB",PropSharedSubscriptionAvailable -// 145,PropCorrelationData -// "I\b\179zw\197\246j\209\171\255\SUBm\138\174\f\129\145y\239\155",PropRequestProblemInformation 70,PropReasonString -// "l",PropMessageExpiryInterval 25951,PropResponseInformation -// "\142\149\130_W\180g\148\"\SYN>\221\194i\DC2w\148\162/\210\169}\251t\SOH#\NUL\195v3",PropSharedSubscriptionAvailable -// 144,PropWildcardSubscriptionAvailable 11,PropReceiveMaximum 16763]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\157\255\149\212\150\224\139\154J\197\&0C\166\189\203/\179f$J\197-\r\240\SUB\188;\r\173", _pubPktID = 22738, +// _pubBody = "\210\DC1\143z\164\179\bD\DELn", _pubProps = [PropMessageExpiryInterval 27990,PropMaximumPacketSize +// 22586,PropAssignedClientIdentifier "o@Z\207\212\141\233\136\149Yk\178b=\134OgP\ENQ\171_",PropAuthenticationData +// "@6\200\241\163\154\211\181L",PropAuthenticationData "8r\237\205\195\141\167\190\173L",PropAuthenticationData +// "*\149\SYNC\208\FS\145T7oDG\206\213\&1\153\231\&2s\192i\ENQ\FS\170\158|\SYN\ENQ",PropReceiveMaximum +// 24325,PropCorrelationData +// "\128\r\194\188\187\vVbUN_\181\&8\142:\195\236_XF\165\168\CAN\f\150DV\192\147",PropResponseInformation +// "k\DC1\198M\EM\132\196\219\197\ETB+\254\ESC\138\209\182p-\158\251"]} TEST(Publish5QCTest, Decode19) { - uint8_t pkt[] = {0x31, 0xd8, 0x1, 0x0, 0x2, 0xdd, 0xc2, 0xc1, 0x1, 0x8, 0x0, 0x10, 0xc3, 0x1d, 0xfa, 0x22, 0xaf, - 0x85, 0xc, 0x4e, 0xe, 0x23, 0x3d, 0xc7, 0x66, 0x42, 0x55, 0x34, 0x1a, 0x0, 0x8, 0xec, 0xcf, 0x3f, - 0x11, 0xc2, 0x2b, 0xef, 0x34, 0x23, 0x5a, 0x7f, 0x29, 0x71, 0x26, 0x0, 0xf, 0xc8, 0xb5, 0x82, 0xad, - 0x4b, 0x5d, 0xb3, 0x7f, 0x3e, 0x16, 0x4, 0x4d, 0x1c, 0xba, 0x56, 0x0, 0xc, 0x70, 0x40, 0x4e, 0x1c, - 0xfa, 0x17, 0x2c, 0xd6, 0xb9, 0x3a, 0x5c, 0xab, 0x1a, 0x0, 0x1c, 0xe4, 0x33, 0x42, 0x9d, 0xe1, 0xbd, - 0xd4, 0x2, 0x7a, 0x7e, 0xe5, 0x78, 0xff, 0x81, 0x5e, 0xed, 0x9c, 0x6d, 0xb, 0x6a, 0xb5, 0xd5, 0x2, - 0x80, 0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 0x67, + 0x50, 0x5, 0xab, 0x5f, 0x16, 0x0, 0x9, 0x40, 0x36, 0xc8, 0xf1, 0xa3, 0x9a, 0xd3, 0xb5, 0x4c, 0x16, + 0x0, 0xa, 0x38, 0x72, 0xed, 0xcd, 0xc3, 0x8d, 0xa7, 0xbe, 0xad, 0x4c, 0x16, 0x0, 0x1c, 0x2a, 0x95, + 0x16, 0x43, 0xd0, 0x1c, 0x91, 0x54, 0x37, 0x6f, 0x44, 0x47, 0xce, 0xd5, 0x31, 0x99, 0xe7, 0x32, 0x73, + 0xc0, 0x69, 0x5, 0x1c, 0xaa, 0x9e, 0x7c, 0x16, 0x5, 0x21, 0x5f, 0x5, 0x9, 0x0, 0x1d, 0x80, 0xd, + 0xc2, 0xbc, 0xbb, 0xb, 0x56, 0x62, 0x55, 0x4e, 0x5f, 0xb5, 0x38, 0x8e, 0x3a, 0xc3, 0xec, 0x5f, 0x58, + 0x46, 0xa5, 0xa8, 0x18, 0xc, 0x96, 0x44, 0x56, 0xc0, 0x93, 0x1a, 0x0, 0x14, 0x6b, 0x11, 0xc6, 0x4d, + 0x19, 0x84, 0xc4, 0xdb, 0xc5, 0x17, 0x2b, 0xfe, 0x1b, 0x8a, 0xd1, 0xb6, 0x70, 0x2d, 0x9e, 0xfb, 0xd2, + 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3953,143 +3837,166 @@ TEST(Publish5QCTest, Decode19) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xdd, 0xc2}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfb, 0x91, 0x22, 0xe5, 0x9, 0x2b, 0xe6, 0xaf, 0x90, - 0xd1, 0x70, 0x3, 0x5e, 0xd9, 0x4b, 0x52, 0xc3}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + uint8_t exp_topic_bytes[] = {0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, 0x43, 0xa6, 0xbd, 0xcb, + 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, 0x3b, 0xd, 0xad}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 22738); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\253\&0\CANabo\DC3\254\241\240\244{\194\r)2\133Gj\233%", _pubPktID = 23762, _pubBody = "\224", _pubProps = -// [PropWildcardSubscriptionAvailable 107,PropResponseTopic "\164&\169\232l\231$P)O.Fu\224\US\214\145H\253 -// \195\131oL\160A%",PropTopicAlias 20811,PropRequestResponseInformation 179,PropRequestProblemInformation -// 128,PropSubscriptionIdentifier 11,PropTopicAliasMaximum 12610,PropSessionExpiryInterval 20293,PropAuthenticationData -// "\"\131p@f\ETBb>\214\189\222\DC3M",PropSessionExpiryInterval 6338,PropSharedSubscriptionAvailable -// 90,PropRequestResponseInformation 113,PropPayloadFormatIndicator 89,PropAssignedClientIdentifier -// "\188j^\248",PropMessageExpiryInterval 24560,PropPayloadFormatIndicator 139,PropUserProperty -// "}\136\171\228\224\190\177\STX7\253V\193\160\222\t\194\DC2%\193\188e1y\129\r\240" -// "6Yo\160R",PropSubscriptionIdentifier 30,PropReasonString -// "Y,\151\173!\131\143\211\208\248\220\140\149",PropPayloadFormatIndicator 218,PropUserProperty "\DC4\249\196\128\255" -// "mf\141\&9i|\RS\211\&1\136I\129\253\STX\134e:\192\185\EM\ETX\240\205p\133\255\153\&94",PropSubscriptionIdentifierAvailable -// 34,PropResponseTopic -// "4C\v\251\180\171x\185\189;X\163\148\NUL\170\STX\172\205K)\173=J\143\t\141\189",PropReceiveMaximum 2967]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 6071, _pubBody = +// "#\140\138\233\171\140\SOH9\165\168kP\138\237?\192\174", _pubProps = [PropSubscriptionIdentifier +// 19,PropCorrelationData +// "\163\146\223\STX\v\158\142\216vy\t\195\168r\DLEQ\201Z\185Lhw@\134\168G\193\190",PropAuthenticationMethod +// "\142{x",PropSharedSubscriptionAvailable 136,PropServerReference +// "\218\183r\155\128\141\192<\182\250\221B\189\ENQ@\195,\RS<\170\161\SI\168",PropUserProperty +// "y@J]\NULg\184\NUL\196Nz\151\STX\153[7\150\EM" +// "\172\CANzCe\244:\165\200P\180\146#\182\202`xq\129L\207\157a=\251[\191V\156",PropRetainAvailable +// 105,PropAssignedClientIdentifier "\167\STX\DELeb\254~\SI",PropSubscriptionIdentifierAvailable 150,PropResponseTopic +// "@\145\EOT$!(\200\DC3%\169",PropReasonString +// "\194\197\175\206\177\131\206?\176\209\128\STXW7\250/\250",PropWildcardSubscriptionAvailable +// 192,PropSubscriptionIdentifier 24,PropSharedSubscriptionAvailable 229,PropTopicAlias 19504,PropTopicAlias +// 5785,PropMessageExpiryInterval 5671,PropTopicAliasMaximum 8296,PropWildcardSubscriptionAvailable +// 156,PropAuthenticationMethod "\136.\180O\203\vUn\185\181\221oS\249lO\208\194>\249\135",PropServerReference +// "\169\&4:\213",PropSharedSubscriptionAvailable 158,PropAssignedClientIdentifier +// "T;\244I\214\197%\170\138\204\211\163R\ACKR]H[$\235Ik\ESC-r",PropTopicAliasMaximum +// 6908,PropSharedSubscriptionAvailable 103,PropAuthenticationMethod +// "\221x\RS\147qG\128\171\239\250\243&\159\226\198\DC1QA\vl\250o\194\195d\145\193"]} TEST(Publish5QCTest, Encode20) { - uint8_t pkt[] = {0x35, 0xf8, 0x1, 0x0, 0x15, 0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, 0xf4, 0x7b, - 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25, 0x5c, 0xd2, 0xdc, 0x1, 0x28, 0x6b, 0x8, 0x0, - 0x1b, 0xa4, 0x26, 0xa9, 0xe8, 0x6c, 0xe7, 0x24, 0x50, 0x29, 0x4f, 0x2e, 0x46, 0x75, 0xe0, 0x1f, 0xd6, - 0x91, 0x48, 0xfd, 0x20, 0xc3, 0x83, 0x6f, 0x4c, 0xa0, 0x41, 0x25, 0x23, 0x51, 0x4b, 0x19, 0xb3, 0x17, - 0x80, 0xb, 0xb, 0x22, 0x31, 0x42, 0x11, 0x0, 0x0, 0x4f, 0x45, 0x16, 0x0, 0xd, 0x22, 0x83, 0x70, - 0x40, 0x66, 0x17, 0x62, 0x3e, 0xd6, 0xbd, 0xde, 0x13, 0x4d, 0x11, 0x0, 0x0, 0x18, 0xc2, 0x2a, 0x5a, - 0x19, 0x71, 0x1, 0x59, 0x12, 0x0, 0x4, 0xbc, 0x6a, 0x5e, 0xf8, 0x2, 0x0, 0x0, 0x5f, 0xf0, 0x1, - 0x8b, 0x26, 0x0, 0x1a, 0x7d, 0x88, 0xab, 0xe4, 0xe0, 0xbe, 0xb1, 0x2, 0x37, 0xfd, 0x56, 0xc1, 0xa0, - 0xde, 0x9, 0xc2, 0x12, 0x25, 0xc1, 0xbc, 0x65, 0x31, 0x79, 0x81, 0xd, 0xf0, 0x0, 0x5, 0x36, 0x59, - 0x6f, 0xa0, 0x52, 0xb, 0x1e, 0x1f, 0x0, 0xd, 0x59, 0x2c, 0x97, 0xad, 0x21, 0x83, 0x8f, 0xd3, 0xd0, - 0xf8, 0xdc, 0x8c, 0x95, 0x1, 0xda, 0x26, 0x0, 0x5, 0x14, 0xf9, 0xc4, 0x80, 0xff, 0x0, 0x1d, 0x6d, - 0x66, 0x8d, 0x39, 0x69, 0x7c, 0x1e, 0xd3, 0x31, 0x88, 0x49, 0x81, 0xfd, 0x2, 0x86, 0x65, 0x3a, 0xc0, - 0xb9, 0x19, 0x3, 0xf0, 0xcd, 0x70, 0x85, 0xff, 0x99, 0x39, 0x34, 0x29, 0x22, 0x8, 0x0, 0x1b, 0x34, - 0x43, 0xb, 0xfb, 0xb4, 0xab, 0x78, 0xb9, 0xbd, 0x3b, 0x58, 0xa3, 0x94, 0x0, 0xaa, 0x2, 0xac, 0xcd, - 0x4b, 0x29, 0xad, 0x3d, 0x4a, 0x8f, 0x9, 0x8d, 0xbd, 0x21, 0xb, 0x97, 0xe0}; - uint8_t topic_bytes[] = {0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, 0xf4, - 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x3b, 0xb4, 0x2, 0x0, 0x0, 0x17, 0xb7, 0x9d, 0x2, 0xb, 0x13, 0x9, 0x0, 0x1c, 0xa3, 0x92, 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0xb4, 0x4f, 0xcb, 0xb, 0x55, 0x6e, + 0xb9, 0xb5, 0xdd, 0x6f, 0x53, 0xf9, 0x6c, 0x4f, 0xd0, 0xc2, 0x3e, 0xf9, 0x87, 0x1c, 0x0, 0x4, 0xa9, 0x34, 0x3a, + 0xd5, 0x2a, 0x9e, 0x12, 0x0, 0x19, 0x54, 0x3b, 0xf4, 0x49, 0xd6, 0xc5, 0x25, 0xaa, 0x8a, 0xcc, 0xd3, 0xa3, 0x52, + 0x6, 0x52, 0x5d, 0x48, 0x5b, 0x24, 0xeb, 0x49, 0x6b, 0x1b, 0x2d, 0x72, 0x22, 0x1a, 0xfc, 0x2a, 0x67, 0x15, 0x0, + 0x1b, 0xdd, 0x78, 0x1e, 0x93, 0x71, 0x47, 0x80, 0xab, 0xef, 0xfa, 0xf3, 0x26, 0x9f, 0xe2, 0xc6, 0x11, 0x51, 0x41, + 0xb, 0x6c, 0xfa, 0x6f, 0xc2, 0xc3, 0x64, 0x91, 0xc1, 0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, 0xa8, + 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xe0}; + uint8_t msg_bytes[] = {0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, + 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 17; - uint8_t bytesprops0[] = {0xa4, 0x26, 0xa9, 0xe8, 0x6c, 0xe7, 0x24, 0x50, 0x29, 0x4f, 0x2e, 0x46, 0x75, 0xe0, - 0x1f, 0xd6, 0x91, 0x48, 0xfd, 0x20, 0xc3, 0x83, 0x6f, 0x4c, 0xa0, 0x41, 0x25}; - uint8_t bytesprops1[] = {0x22, 0x83, 0x70, 0x40, 0x66, 0x17, 0x62, 0x3e, 0xd6, 0xbd, 0xde, 0x13, 0x4d}; - uint8_t bytesprops2[] = {0xbc, 0x6a, 0x5e, 0xf8}; - uint8_t bytesprops4[] = {0x36, 0x59, 0x6f, 0xa0, 0x52}; - uint8_t bytesprops3[] = {0x7d, 0x88, 0xab, 0xe4, 0xe0, 0xbe, 0xb1, 0x2, 0x37, 0xfd, 0x56, 0xc1, 0xa0, - 0xde, 0x9, 0xc2, 0x12, 0x25, 0xc1, 0xbc, 0x65, 0x31, 0x79, 0x81, 0xd, 0xf0}; - uint8_t bytesprops5[] = {0x59, 0x2c, 0x97, 0xad, 0x21, 0x83, 0x8f, 0xd3, 0xd0, 0xf8, 0xdc, 0x8c, 0x95}; - uint8_t bytesprops7[] = {0x6d, 0x66, 0x8d, 0x39, 0x69, 0x7c, 0x1e, 0xd3, 0x31, 0x88, 0x49, 0x81, 0xfd, 0x2, 0x86, - 0x65, 0x3a, 0xc0, 0xb9, 0x19, 0x3, 0xf0, 0xcd, 0x70, 0x85, 0xff, 0x99, 0x39, 0x34}; - uint8_t bytesprops6[] = {0x14, 0xf9, 0xc4, 0x80, 0xff}; - uint8_t bytesprops8[] = {0x34, 0x43, 0xb, 0xfb, 0xb4, 0xab, 0x78, 0xb9, 0xbd, 0x3b, 0x58, 0xa3, 0x94, 0x0, - 0xaa, 0x2, 0xac, 0xcd, 0x4b, 0x29, 0xad, 0x3d, 0x4a, 0x8f, 0x9, 0x8d, 0xbd}; + uint8_t bytesprops0[] = {0xa3, 0x92, 0xdf, 0x2, 0xb, 0x9e, 0x8e, 0xd8, 0x76, 0x79, 0x9, 0xc3, 0xa8, 0x72, + 0x10, 0x51, 0xc9, 0x5a, 0xb9, 0x4c, 0x68, 0x77, 0x40, 0x86, 0xa8, 0x47, 0xc1, 0xbe}; + uint8_t bytesprops1[] = {0x8e, 0x7b, 0x78}; + uint8_t bytesprops2[] = {0xda, 0xb7, 0x72, 0x9b, 0x80, 0x8d, 0xc0, 0x3c, 0xb6, 0xfa, 0xdd, 0x42, + 0xbd, 0x5, 0x40, 0xc3, 0x2c, 0x1e, 0x3c, 0xaa, 0xa1, 0xf, 0xa8}; + uint8_t bytesprops4[] = {0xac, 0x18, 0x7a, 0x43, 0x65, 0xf4, 0x3a, 0xa5, 0xc8, 0x50, 0xb4, 0x92, 0x23, 0xb6, 0xca, + 0x60, 0x78, 0x71, 0x81, 0x4c, 0xcf, 0x9d, 0x61, 0x3d, 0xfb, 0x5b, 0xbf, 0x56, 0x9c}; + uint8_t bytesprops3[] = {0x79, 0x40, 0x4a, 0x5d, 0x0, 0x67, 0xb8, 0x0, 0xc4, + 0x4e, 0x7a, 0x97, 0x2, 0x99, 0x5b, 0x37, 0x96, 0x19}; + uint8_t bytesprops5[] = {0xa7, 0x2, 0x7f, 0x65, 0x62, 0xfe, 0x7e, 0xf}; + uint8_t bytesprops6[] = {0x40, 0x91, 0x4, 0x24, 0x21, 0x28, 0xc8, 0x13, 0x25, 0xa9}; + uint8_t bytesprops7[] = {0xc2, 0xc5, 0xaf, 0xce, 0xb1, 0x83, 0xce, 0x3f, 0xb0, + 0xd1, 0x80, 0x2, 0x57, 0x37, 0xfa, 0x2f, 0xfa}; + uint8_t bytesprops8[] = {0x88, 0x2e, 0xb4, 0x4f, 0xcb, 0xb, 0x55, 0x6e, 0xb9, 0xb5, 0xdd, + 0x6f, 0x53, 0xf9, 0x6c, 0x4f, 0xd0, 0xc2, 0x3e, 0xf9, 0x87}; + uint8_t bytesprops9[] = {0xa9, 0x34, 0x3a, 0xd5}; + uint8_t bytesprops10[] = {0x54, 0x3b, 0xf4, 0x49, 0xd6, 0xc5, 0x25, 0xaa, 0x8a, 0xcc, 0xd3, 0xa3, 0x52, + 0x6, 0x52, 0x5d, 0x48, 0x5b, 0x24, 0xeb, 0x49, 0x6b, 0x1b, 0x2d, 0x72}; + uint8_t bytesprops11[] = {0xdd, 0x78, 0x1e, 0x93, 0x71, 0x47, 0x80, 0xab, 0xef, 0xfa, 0xf3, 0x26, 0x9f, 0xe2, + 0xc6, 0x11, 0x51, 0x41, 0xb, 0x6c, 0xfa, 0x6f, 0xc2, 0xc3, 0x64, 0x91, 0xc1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20811}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12610}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20293}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6338}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24560}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops6}, .v = {29, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2967}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops3}, .v = {29, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19504}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5785}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5671}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8296}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6908}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 23762, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6071, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\253\&0\CANabo\DC3\254\241\240\244{\194\r)2\133Gj\233%", _pubPktID = 23762, _pubBody = "\224", _pubProps = -// [PropWildcardSubscriptionAvailable 107,PropResponseTopic "\164&\169\232l\231$P)O.Fu\224\US\214\145H\253 -// \195\131oL\160A%",PropTopicAlias 20811,PropRequestResponseInformation 179,PropRequestProblemInformation -// 128,PropSubscriptionIdentifier 11,PropTopicAliasMaximum 12610,PropSessionExpiryInterval 20293,PropAuthenticationData -// "\"\131p@f\ETBb>\214\189\222\DC3M",PropSessionExpiryInterval 6338,PropSharedSubscriptionAvailable -// 90,PropRequestResponseInformation 113,PropPayloadFormatIndicator 89,PropAssignedClientIdentifier -// "\188j^\248",PropMessageExpiryInterval 24560,PropPayloadFormatIndicator 139,PropUserProperty -// "}\136\171\228\224\190\177\STX7\253V\193\160\222\t\194\DC2%\193\188e1y\129\r\240" -// "6Yo\160R",PropSubscriptionIdentifier 30,PropReasonString -// "Y,\151\173!\131\143\211\208\248\220\140\149",PropPayloadFormatIndicator 218,PropUserProperty "\DC4\249\196\128\255" -// "mf\141\&9i|\RS\211\&1\136I\129\253\STX\134e:\192\185\EM\ETX\240\205p\133\255\153\&94",PropSubscriptionIdentifierAvailable -// 34,PropResponseTopic -// "4C\v\251\180\171x\185\189;X\163\148\NUL\170\STX\172\205K)\173=J\143\t\141\189",PropReceiveMaximum 2967]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 6071, _pubBody = +// "#\140\138\233\171\140\SOH9\165\168kP\138\237?\192\174", _pubProps = [PropSubscriptionIdentifier +// 19,PropCorrelationData +// "\163\146\223\STX\v\158\142\216vy\t\195\168r\DLEQ\201Z\185Lhw@\134\168G\193\190",PropAuthenticationMethod +// "\142{x",PropSharedSubscriptionAvailable 136,PropServerReference +// "\218\183r\155\128\141\192<\182\250\221B\189\ENQ@\195,\RS<\170\161\SI\168",PropUserProperty +// "y@J]\NULg\184\NUL\196Nz\151\STX\153[7\150\EM" +// "\172\CANzCe\244:\165\200P\180\146#\182\202`xq\129L\207\157a=\251[\191V\156",PropRetainAvailable +// 105,PropAssignedClientIdentifier "\167\STX\DELeb\254~\SI",PropSubscriptionIdentifierAvailable 150,PropResponseTopic +// "@\145\EOT$!(\200\DC3%\169",PropReasonString +// "\194\197\175\206\177\131\206?\176\209\128\STXW7\250/\250",PropWildcardSubscriptionAvailable +// 192,PropSubscriptionIdentifier 24,PropSharedSubscriptionAvailable 229,PropTopicAlias 19504,PropTopicAlias +// 5785,PropMessageExpiryInterval 5671,PropTopicAliasMaximum 8296,PropWildcardSubscriptionAvailable +// 156,PropAuthenticationMethod "\136.\180O\203\vUn\185\181\221oS\249lO\208\194>\249\135",PropServerReference +// "\169\&4:\213",PropSharedSubscriptionAvailable 158,PropAssignedClientIdentifier +// "T;\244I\214\197%\170\138\204\211\163R\ACKR]H[$\235Ik\ESC-r",PropTopicAliasMaximum +// 6908,PropSharedSubscriptionAvailable 103,PropAuthenticationMethod +// "\221x\RS\147qG\128\171\239\250\243&\159\226\198\DC1QA\vl\250o\194\195d\145\193"]} TEST(Publish5QCTest, Decode20) { - uint8_t pkt[] = {0x35, 0xf8, 0x1, 0x0, 0x15, 0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, 0xf4, 0x7b, - 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25, 0x5c, 0xd2, 0xdc, 0x1, 0x28, 0x6b, 0x8, 0x0, - 0x1b, 0xa4, 0x26, 0xa9, 0xe8, 0x6c, 0xe7, 0x24, 0x50, 0x29, 0x4f, 0x2e, 0x46, 0x75, 0xe0, 0x1f, 0xd6, - 0x91, 0x48, 0xfd, 0x20, 0xc3, 0x83, 0x6f, 0x4c, 0xa0, 0x41, 0x25, 0x23, 0x51, 0x4b, 0x19, 0xb3, 0x17, - 0x80, 0xb, 0xb, 0x22, 0x31, 0x42, 0x11, 0x0, 0x0, 0x4f, 0x45, 0x16, 0x0, 0xd, 0x22, 0x83, 0x70, - 0x40, 0x66, 0x17, 0x62, 0x3e, 0xd6, 0xbd, 0xde, 0x13, 0x4d, 0x11, 0x0, 0x0, 0x18, 0xc2, 0x2a, 0x5a, - 0x19, 0x71, 0x1, 0x59, 0x12, 0x0, 0x4, 0xbc, 0x6a, 0x5e, 0xf8, 0x2, 0x0, 0x0, 0x5f, 0xf0, 0x1, - 0x8b, 0x26, 0x0, 0x1a, 0x7d, 0x88, 0xab, 0xe4, 0xe0, 0xbe, 0xb1, 0x2, 0x37, 0xfd, 0x56, 0xc1, 0xa0, - 0xde, 0x9, 0xc2, 0x12, 0x25, 0xc1, 0xbc, 0x65, 0x31, 0x79, 0x81, 0xd, 0xf0, 0x0, 0x5, 0x36, 0x59, - 0x6f, 0xa0, 0x52, 0xb, 0x1e, 0x1f, 0x0, 0xd, 0x59, 0x2c, 0x97, 0xad, 0x21, 0x83, 0x8f, 0xd3, 0xd0, - 0xf8, 0xdc, 0x8c,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x64, 0x91, 0xc1, 0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, 0xa8, + 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4098,103 +4005,118 @@ TEST(Publish5QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xfd, 0x30, 0x18, 0x61, 0x62, 0x6f, 0x13, 0xfe, 0xf1, 0xf0, 0xf4, - 0x7b, 0xc2, 0xd, 0x29, 0x32, 0x85, 0x47, 0x6a, 0xe9, 0x25}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xe0}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, + 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 23762); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_EQ(packet_id, 6071); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC1\DC4:", _pubPktID = 0, _pubBody = -// "V\144J\230\153\132\164\SO", _pubProps = [PropMaximumQoS 226,PropMaximumPacketSize 24860,PropAssignedClientIdentifier -// "\159(topic.data), 3); - EXPECT_EQ(msg.payload_len, 8); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "6\USp^\205\245IA -// \ETB+\158\220\216ea[,\180\190\&1\DLE\183\198\217", _pubPktID = 25164, _pubBody = -// "\155\145\198\173f\139:a\195\141sE}\221\223\243\145\224*\180\vSEy{\166\178\148`", _pubProps = [PropCorrelationData -// "\230\194/G;\134Y\155\163Z\NUL"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 29931, _pubBody = +// "\254t\DLE\GS|r\CAN\243)\RS\151\DC4/_\229b\\", _pubProps = [PropRequestProblemInformation +// 181,PropRequestResponseInformation 73,PropReceiveMaximum 30707,PropMessageExpiryInterval +// 19377,PropSessionExpiryInterval 22687,PropServerKeepAlive 23724,PropSharedSubscriptionAvailable +// 139,PropAuthenticationData "\217O<",PropWillDelayInterval 11547,PropContentType "<\fe\147(m]7",PropMaximumQoS +// 198,PropRequestResponseInformation 184,PropRequestResponseInformation 172,PropAssignedClientIdentifier +// "\247\250\229\235_\DLE\190\NAK\165\240\164\222aT\165~](\247",PropAssignedClientIdentifier +// "\185U\164\245\ACKeK\227N\157\166",PropMaximumQoS 191,PropRequestProblemInformation 2,PropContentType +// "\149\149\DC2\244\197\150\252M@\215\180\220_Z\140\&4\236\143CV\188\SYN\166",PropWildcardSubscriptionAvailable +// 154,PropUserProperty "\183\215\247~R0\158\GS\154\&8" +// "\202\181\GS\218\169!sB\248\r\SOF\197\178\246\188ai\252\175\SOJ\248",PropRequestProblemInformation +// 50,PropSubscriptionIdentifier 0,PropMaximumPacketSize 14544,PropAuthenticationData +// "y\135\&3`0\210\216h",PropUserProperty "\246o\197\SUB\228\224\224" +// "n\144)\182\215\251:\SO\189;\144\194\r\190b*\201u\DC4\183\225\160\GS\128",PropWillDelayInterval 15728]} TEST(Publish5QCTest, Encode22) { - uint8_t pkt[] = {0x33, 0x49, 0x0, 0x19, 0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, - 0x9e, 0xdc, 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9, 0x62, - 0x4c, 0xe, 0x9, 0x0, 0xb, 0xe6, 0xc2, 0x2f, 0x47, 0x3b, 0x86, 0x59, 0x9b, 0xa3, 0x5a, - 0x0, 0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, - 0xdf, 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; - uint8_t topic_bytes[] = {0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, 0x9e, 0xdc, - 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x3c, 0xf0, 0x1, 0x0, 0x0, 0x74, 0xeb, 0xd9, 0x1, 0x17, 0xb5, 0x19, 0x49, 0x21, 0x77, 0xf3, 0x2, 0x0, 0x0, + 0x4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bd, 0x3b, 0x90, 0xc2, + 0xd, 0xbe, 0x62, 0x2a, 0xc9, 0x75, 0x14, 0xb7, 0xe1, 0xa0, 0x1d, 0x80, 0x18, 0x0, 0x0, 0x3d, 0x70, 0xfe, 0x74, + 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, 0xdf, - 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, + 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 17; - uint8_t bytesprops0[] = {0xe6, 0xc2, 0x2f, 0x47, 0x3b, 0x86, 0x59, 0x9b, 0xa3, 0x5a, 0x0}; + uint8_t bytesprops0[] = {0xd9, 0x4f, 0x3c}; + uint8_t bytesprops1[] = {0x3c, 0xc, 0x65, 0x93, 0x28, 0x6d, 0x5d, 0x37}; + uint8_t bytesprops2[] = {0xf7, 0xfa, 0xe5, 0xeb, 0x5f, 0x10, 0xbe, 0x15, 0xa5, 0xf0, + 0xa4, 0xde, 0x61, 0x54, 0xa5, 0x7e, 0x5d, 0x28, 0xf7}; + uint8_t bytesprops3[] = {0xb9, 0x55, 0xa4, 0xf5, 0x6, 0x65, 0x4b, 0xe3, 0x4e, 0x9d, 0xa6}; + uint8_t bytesprops4[] = {0x95, 0x95, 0x12, 0xf4, 0xc5, 0x96, 0xfc, 0x4d, 0x40, 0xd7, 0xb4, 0xdc, + 0x5f, 0x5a, 0x8c, 0x34, 0xec, 0x8f, 0x43, 0x56, 0xbc, 0x16, 0xa6}; + uint8_t bytesprops6[] = {0xca, 0xb5, 0x1d, 0xda, 0xa9, 0x21, 0x73, 0x42, 0xf8, 0xd, 0xe, 0x46, + 0xc5, 0xb2, 0xf6, 0xbc, 0x61, 0x69, 0xfc, 0xaf, 0xe, 0x4a, 0xf8}; + uint8_t bytesprops5[] = {0xb7, 0xd7, 0xf7, 0x7e, 0x52, 0x30, 0x9e, 0x1d, 0x9a, 0x38}; + uint8_t bytesprops7[] = {0x79, 0x87, 0x33, 0x60, 0x30, 0xd2, 0xd8, 0x68}; + uint8_t bytesprops9[] = {0x6e, 0x90, 0x29, 0xb6, 0xd7, 0xfb, 0x3a, 0xe, 0xbd, 0x3b, 0x90, 0xc2, + 0xd, 0xbe, 0x62, 0x2a, 0xc9, 0x75, 0x14, 0xb7, 0xe1, 0xa0, 0x1d, 0x80}; + uint8_t bytesprops8[] = {0xf6, 0x6f, 0xc5, 0x1a, 0xe4, 0xe0, 0xe0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30707}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19377}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22687}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23724}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11547}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops5}, .v = {23, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14544}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops8}, .v = {24, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15728}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 25164, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29931, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "6\USp^\205\245IA -// \ETB+\158\220\216ea[,\180\190\&1\DLE\183\198\217", _pubPktID = 25164, _pubBody = -// "\155\145\198\173f\139:a\195\141sE}\221\223\243\145\224*\180\vSEy{\166\178\148`", _pubProps = [PropCorrelationData -// "\230\194/G;\134Y\155\163Z\NUL"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 29931, _pubBody = +// "\254t\DLE\GS|r\CAN\243)\RS\151\DC4/_\229b\\", _pubProps = [PropRequestProblemInformation +// 181,PropRequestResponseInformation 73,PropReceiveMaximum 30707,PropMessageExpiryInterval +// 19377,PropSessionExpiryInterval 22687,PropServerKeepAlive 23724,PropSharedSubscriptionAvailable +// 139,PropAuthenticationData "\217O<",PropWillDelayInterval 11547,PropContentType "<\fe\147(m]7",PropMaximumQoS +// 198,PropRequestResponseInformation 184,PropRequestResponseInformation 172,PropAssignedClientIdentifier +// "\247\250\229\235_\DLE\190\NAK\165\240\164\222aT\165~](\247",PropAssignedClientIdentifier +// "\185U\164\245\ACKeK\227N\157\166",PropMaximumQoS 191,PropRequestProblemInformation 2,PropContentType +// "\149\149\DC2\244\197\150\252M@\215\180\220_Z\140\&4\236\143CV\188\SYN\166",PropWildcardSubscriptionAvailable +// 154,PropUserProperty "\183\215\247~R0\158\GS\154\&8" +// "\202\181\GS\218\169!sB\248\r\SOF\197\178\246\188ai\252\175\SOJ\248",PropRequestProblemInformation +// 50,PropSubscriptionIdentifier 0,PropMaximumPacketSize 14544,PropAuthenticationData +// "y\135\&3`0\210\216h",PropUserProperty "\246o\197\SUB\228\224\224" +// "n\144)\182\215\251:\SO\189;\144\194\r\190b*\201u\DC4\183\225\160\GS\128",PropWillDelayInterval 15728]} TEST(Publish5QCTest, Decode22) { - uint8_t pkt[] = {0x33, 0x49, 0x0, 0x19, 0x36, 0x1f, 0x70, 0x5e, 0xc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a, 0x8c, 0x34, 0xec, 0x8f, 0x43, 0x56, 0xbc, 0x16, 0xa6, 0x28, 0x9a, 0x26, 0x0, 0xa, 0xb7, 0xd7, 0xf7, + 0x7e, 0x52, 0x30, 0x9e, 0x1d, 0x9a, 0x38, 0x0, 0x17, 0xca, 0xb5, 0x1d, 0xda, 0xa9, 0x21, 0x73, 0x42, 0xf8, 0xd, + 0xe, 0x46, 0xc5, 0xb2, 0xf6, 0xbc, 0x61, 0x69, 0xfc, 0xaf, 0xe, 0x4a, 0xf8, 0x17, 0x32, 0xb, 0x0, 0x27, 0x0, + 0x0, 0x38, 0xd0, 0x16, 0x0, 0x8, 0x79, 0x87, 0x33, 0x60, 0x30, 0xd2, 0xd8, 0x68, 0x26, 0x0, 0x7, 0xf6, 0x6f, + 0xc5, 0x1a, 0xe4, 0xe0, 0xe0, 0x0, 0x18, 0x6e, 0x90, 0x29, 0xb6, 0xd7, 0xfb, 0x3a, 0xe, 0xbd, 0x3b, 0x90, 0xc2, + 0xd, 0xbe, 0x62, 0x2a, 0xc9, 0x75, 0x14, 0xb7, 0xe1, 0xa0, 0x1d, 0x80, 0x18, 0x0, 0x0, 0x3d, 0x70, 0xfe, 0x74, + 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4273,63 +4271,130 @@ TEST(Publish5QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x36, 0x1f, 0x70, 0x5e, 0xcd, 0xf5, 0x49, 0x41, 0x20, 0x17, 0x2b, 0x9e, 0xdc, - 0xd8, 0x65, 0x61, 0x5b, 0x2c, 0xb4, 0xbe, 0x31, 0x10, 0xb7, 0xc6, 0xd9}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9b, 0x91, 0xc6, 0xad, 0x66, 0x8b, 0x3a, 0x61, 0xc3, 0x8d, 0x73, 0x45, 0x7d, 0xdd, 0xdf, - 0xf3, 0x91, 0xe0, 0x2a, 0xb4, 0xb, 0x53, 0x45, 0x79, 0x7b, 0xa6, 0xb2, 0x94, 0x60}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 25164); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, + 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 29931); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\178\&7A\251\143\146\159\171\130\211\146\190g", _pubPktID = 0, _pubBody = "", _pubProps = [PropMessageExpiryInterval -// 18622,PropAssignedClientIdentifier "e\164\154\171\184\215\140w\181Dr"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\128\158-GrC\129\166\140\231\NULj!M4\SUB", _pubPktID = 0, _pubBody = +// "\228\ESC\231\DC3\136\217\177W_\ESCp\130\DC2\212,\158\236\215\204\207m\205", _pubProps = +// [PropRequestProblemInformation 64,PropAuthenticationData +// "\133\236\132T\RS\149\164\140f\220\200\200",PropServerReference "\138s\200\181\144r\224\190C+;",PropContentType +// "\t\153\142ji\206\236\156$*\136\DC4\n\202(\172xCXc\204",PropMaximumQoS 114,PropRetainAvailable +// 94,PropSessionExpiryInterval 24598,PropAssignedClientIdentifier +// "`\202\237]t\131\179M\226\218\250\160)\227\167\&0\154\n\DC2]\DLE\US\150?\234B\239\139\242",PropWillDelayInterval +// 28070,PropSessionExpiryInterval 12851,PropMaximumQoS 89,PropRequestResponseInformation 13,PropTopicAlias +// 13547,PropSessionExpiryInterval 10014,PropSessionExpiryInterval 19691,PropAuthenticationMethod +// "\198<\129\214\246",PropSessionExpiryInterval 12398,PropMessageExpiryInterval 29590,PropRequestProblemInformation +// 102,PropServerKeepAlive 12804,PropSubscriptionIdentifierAvailable 177,PropServerReference "\175",PropServerKeepAlive +// 16845]} TEST(Publish5QCTest, Encode23) { - uint8_t pkt[] = {0x39, 0x23, 0x0, 0xd, 0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, - 0xd3, 0x92, 0xbe, 0x67, 0x13, 0x2, 0x0, 0x0, 0x48, 0xbe, 0x12, 0x0, 0xb, - 0x65, 0xa4, 0x9a, 0xab, 0xb8, 0xd7, 0x8c, 0x77, 0xb5, 0x44, 0x72}; - uint8_t topic_bytes[] = {0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0xc5, 0x1, 0x0, 0x10, 0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 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cd}; + uint8_t topic_bytes[] = {0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, + 0x8c, 0xe7, 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0}; + uint8_t msg_bytes[] = {0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, 0x1b, 0x70, + 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 22; - uint8_t bytesprops0[] = {0x65, 0xa4, 0x9a, 0xab, 0xb8, 0xd7, 0x8c, 0x77, 0xb5, 0x44, 0x72}; + uint8_t bytesprops0[] = {0x85, 0xec, 0x84, 0x54, 0x1e, 0x95, 0xa4, 0x8c, 0x66, 0xdc, 0xc8, 0xc8}; + uint8_t bytesprops1[] = {0x8a, 0x73, 0xc8, 0xb5, 0x90, 0x72, 0xe0, 0xbe, 0x43, 0x2b, 0x3b}; + uint8_t bytesprops2[] = {0x9, 0x99, 0x8e, 0x6a, 0x69, 0xce, 0xec, 0x9c, 0x24, 0x2a, 0x88, + 0x14, 0xa, 0xca, 0x28, 0xac, 0x78, 0x43, 0x58, 0x63, 0xcc}; + uint8_t bytesprops3[] = {0x60, 0xca, 0xed, 0x5d, 0x74, 0x83, 0xb3, 0x4d, 0xe2, 0xda, 0xfa, 0xa0, 0x29, 0xe3, 0xa7, + 0x30, 0x9a, 0xa, 0x12, 0x5d, 0x10, 0x1f, 0x96, 0x3f, 0xea, 0x42, 0xef, 0x8b, 0xf2}; + uint8_t bytesprops4[] = {0xc6, 0x3c, 0x81, 0xd6, 0xf6}; + uint8_t bytesprops5[] = {0xaf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18622}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24598}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28070}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12851}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13547}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10014}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19691}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12398}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29590}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12804}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16845}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\178\&7A\251\143\146\159\171\130\211\146\190g", _pubPktID = 0, _pubBody = "", _pubProps = [PropMessageExpiryInterval -// 18622,PropAssignedClientIdentifier "e\164\154\171\184\215\140w\181Dr"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\128\158-GrC\129\166\140\231\NULj!M4\SUB", _pubPktID = 0, _pubBody = +// "\228\ESC\231\DC3\136\217\177W_\ESCp\130\DC2\212,\158\236\215\204\207m\205", _pubProps = +// [PropRequestProblemInformation 64,PropAuthenticationData +// "\133\236\132T\RS\149\164\140f\220\200\200",PropServerReference "\138s\200\181\144r\224\190C+;",PropContentType +// "\t\153\142ji\206\236\156$*\136\DC4\n\202(\172xCXc\204",PropMaximumQoS 114,PropRetainAvailable +// 94,PropSessionExpiryInterval 24598,PropAssignedClientIdentifier +// "`\202\237]t\131\179M\226\218\250\160)\227\167\&0\154\n\DC2]\DLE\US\150?\234B\239\139\242",PropWillDelayInterval +// 28070,PropSessionExpiryInterval 12851,PropMaximumQoS 89,PropRequestResponseInformation 13,PropTopicAlias +// 13547,PropSessionExpiryInterval 10014,PropSessionExpiryInterval 19691,PropAuthenticationMethod +// "\198<\129\214\246",PropSessionExpiryInterval 12398,PropMessageExpiryInterval 29590,PropRequestProblemInformation +// 102,PropServerKeepAlive 12804,PropSubscriptionIdentifierAvailable 177,PropServerReference "\175",PropServerKeepAlive +// 16845]} TEST(Publish5QCTest, Decode23) { - uint8_t pkt[] = {0x39, 0x23, 0x0, 0xd, 0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, - 0xd3, 0x92, 0xbe, 0x67, 0x13, 0x2, 0x0, 0x0, 0x48, 0xbe, 0x12, 0x0, 0xb, - 0x65, 0xa4, 0x9a, 0xab, 0xb8, 0xd7, 0x8c, 0x77, 0xb5, 0x44, 0x72}; + uint8_t pkt[] = {0x31, 0xc5, 0x1, 0x0, 0x10, 0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, 0x8c, 0xe7, 0x0, 0x6a, + 0x21, 0x4d, 0x34, 0x1a, 0x9b, 0x1, 0x17, 0x40, 0x16, 0x0, 0xc, 0x85, 0xec, 0x84, 0x54, 0x1e, 0x95, + 0xa4, 0x8c, 0x66, 0xdc, 0xc8, 0xc8, 0x1c, 0x0, 0xb, 0x8a, 0x73, 0xc8, 0xb5, 0x90, 0x72, 0xe0, 0xbe, + 0x43, 0x2b, 0x3b, 0x3, 0x0, 0x15, 0x9, 0x99, 0x8e, 0x6a, 0x69, 0xce, 0xec, 0x9c, 0x24, 0x2a, 0x88, + 0x14, 0xa, 0xca, 0x28, 0xac, 0x78, 0x43, 0x58, 0x63, 0xcc, 0x24, 0x72, 0x25, 0x5e, 0x11, 0x0, 0x0, + 0x60, 0x16, 0x12, 0x0, 0x1d, 0x60, 0xca, 0xed, 0x5d, 0x74, 0x83, 0xb3, 0x4d, 0xe2, 0xda, 0xfa, 0xa0, + 0x29, 0xe3, 0xa7, 0x30, 0x9a, 0xa, 0x12, 0x5d, 0x10, 0x1f, 0x96, 0x3f, 0xea, 0x42, 0xef, 0x8b, 0xf2, + 0x18, 0x0, 0x0, 0x6d, 0xa6, 0x11, 0x0, 0x0, 0x32, 0x33, 0x24, 0x59, 0x19, 0xd, 0x23, 0x34, 0xeb, + 0x11, 0x0, 0x0, 0x27, 0x1e, 0x11, 0x0, 0x0, 0x4c, 0xeb, 0x15, 0x0, 0x5, 0xc6, 0x3c, 0x81, 0xd6, + 0xf6, 0x11, 0x0, 0x0, 0x30, 0x6e, 0x2, 0x0, 0x0, 0x73, 0x96, 0x17, 0x66, 0x13, 0x32, 0x4, 0x29, + 0xb1, 0x1c, 0x0, 0x1, 0xaf, 0x13, 0x41, 0xcd, 0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, + 0x1b, 0x70, 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4338,106 +4403,123 @@ TEST(Publish5QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb2, 0x37, 0x41, 0xfb, 0x8f, 0x92, 0x9f, 0xab, 0x82, 0xd3, 0x92, 0xbe, 0x67}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, + 0x8c, 0xe7, 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a}; + lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, 0x1b, 0x70, + 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\198\161\148\238\191@\246\217\217\241\DC1\227\239", _pubPktID = 10944, _pubBody = "R3\160", _pubProps = -// [PropWildcardSubscriptionAvailable 84,PropTopicAliasMaximum 14373,PropResponseTopic -// "\163\NUL\243\131\211\147\148\158&.\r",PropServerKeepAlive 25898,PropMaximumPacketSize 7145,PropReceiveMaximum -// 29689,PropRequestProblemInformation 197,PropSubscriptionIdentifier 28,PropResponseTopic -// "\t\198\FS\130\144!\130F5\191\"u\211\161\147",PropTopicAlias 9274,PropRetainAvailable 33,PropReasonString -// "\189\DC2>FV=C\STX\ACKu\142\133\215\249\224\195\225*",PropSubscriptionIdentifierAvailable 131,PropServerReference -// "\244FB\203>p>",PropReceiveMaximum 8728,PropSubscriptionIdentifierAvailable 125,PropCorrelationData -// "\141\180\130g\166\221>\167\STX\140]\153\136k\135\135\STX\243\215\223"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "s\233\140\183\209=t\220\206\194\143\249\ETX\234\&5\b\144\f\246\250\US\193\193\178\226\201\156", _pubPktID = 8248, +// _pubBody = "v\196\240]\193r\165~\158\205\155'\206\&8\215s\248\196\250\&1\247", _pubProps = +// [PropWildcardSubscriptionAvailable 105,PropUserProperty "w\143\189\202" +// ")|\ENQ`\155\193\250\159\177\170\174K\SI\147\200g\246\177",PropResponseInformation +// "\163\145C\159Hw6\169\\\132G`_;d\v\206\135xsk",PropSessionExpiryInterval 9513,PropMessageExpiryInterval +// 2757,PropAuthenticationData +// "\128q1v\189\\=\215\166Ym\186\205\223\204m\237\255\146\215\198ef\218d\187\170\207\198",PropTopicAlias +// 16031,PropServerKeepAlive 8395,PropSessionExpiryInterval 13943,PropReceiveMaximum +// 28503,PropRequestResponseInformation 118,PropResponseTopic "$\187",PropServerReference +// "r\178\201\CAN\197\227U\132\210\178\b\223",PropSharedSubscriptionAvailable 190,PropRequestProblemInformation +// 186,PropMaximumQoS 207]} TEST(Publish5QCTest, Encode24) { - uint8_t pkt[] = {0x3c, 0x8b, 0x1, 0x0, 0xd, 0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, - 0xe3, 0xef, 0x2a, 0xc0, 0x76, 0x28, 0x54, 0x22, 0x38, 0x25, 0x8, 0x0, 0xb, 0xa3, 0x0, 0xf3, - 0x83, 0xd3, 0x93, 0x94, 0x9e, 0x26, 0x2e, 0xd, 0x13, 0x65, 0x2a, 0x27, 0x0, 0x0, 0x1b, 0xe9, - 0x21, 0x73, 0xf9, 0x17, 0xc5, 0xb, 0x1c, 0x8, 0x0, 0xf, 0x9, 0xc6, 0x1c, 0x82, 0x90, 0x21, - 0x82, 0x46, 0x35, 0xbf, 0x22, 0x75, 0xd3, 0xa1, 0x93, 0x23, 0x24, 0x3a, 0x25, 0x21, 0x1f, 0x0, - 0x12, 0xbd, 0x12, 0x3e, 0x46, 0x56, 0x3d, 0x43, 0x2, 0x6, 0x75, 0x8e, 0x85, 0xd7, 0xf9, 0xe0, - 0xc3, 0xe1, 0x2a, 0x29, 0x83, 0x1c, 0x0, 0x7, 0xf4, 0x46, 0x42, 0xcb, 0x3e, 0x70, 0x3e, 0x21, - 0x22, 0x18, 0x29, 0x7d, 0x9, 0x0, 0x14, 0x8d, 0xb4, 0x82, 0x67, 0xa6, 0xdd, 0x3e, 0xa7, 0x2, - 0x8c, 0x5d, 0x99, 0x88, 0x6b, 0x87, 0x87, 0x2, 0xf3, 0xd7, 0xdf, 0x52, 0x33, 0xa0}; - uint8_t topic_bytes[] = {0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0xbf, 0x1, 0x0, 0x1b, 0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, + 0x3, 0xea, 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c, 0x20, 0x38, + 0x89, 0x1, 0x28, 0x69, 0x26, 0x0, 0x4, 0x77, 0x8f, 0xbd, 0xca, 0x0, 0x12, 0x29, 0x7c, 0x5, 0x60, + 0x9b, 0xc1, 0xfa, 0x9f, 0xb1, 0xaa, 0xae, 0x4b, 0xf, 0x93, 0xc8, 0x67, 0xf6, 0xb1, 0x1a, 0x0, 0x15, + 0xa3, 0x91, 0x43, 0x9f, 0x48, 0x77, 0x36, 0xa9, 0x5c, 0x84, 0x47, 0x60, 0x5f, 0x3b, 0x64, 0xb, 0xce, + 0x87, 0x78, 0x73, 0x6b, 0x11, 0x0, 0x0, 0x25, 0x29, 0x2, 0x0, 0x0, 0xa, 0xc5, 0x16, 0x0, 0x1d, + 0x80, 0x71, 0x31, 0x76, 0xbd, 0x5c, 0x3d, 0xd7, 0xa6, 0x59, 0x6d, 0xba, 0xcd, 0xdf, 0xcc, 0x6d, 0xed, + 0xff, 0x92, 0xd7, 0xc6, 0x65, 0x66, 0xda, 0x64, 0xbb, 0xaa, 0xcf, 0xc6, 0x23, 0x3e, 0x9f, 0x13, 0x20, + 0xcb, 0x11, 0x0, 0x0, 0x36, 0x77, 0x21, 0x6f, 0x57, 0x19, 0x76, 0x8, 0x0, 0x2, 0x24, 0xbb, 0x1c, + 0x0, 0xc, 0x72, 0xb2, 0xc9, 0x18, 0xc5, 0xe3, 0x55, 0x84, 0xd2, 0xb2, 0x8, 0xdf, 0x2a, 0xbe, 0x17, + 0xba, 0x24, 0xcf, 0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, 0x27, 0xce, 0x38, + 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; + uint8_t topic_bytes[] = {0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, 0x3, 0xea, + 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x52, 0x33, 0xa0}; + uint8_t msg_bytes[] = {0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, + 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 21; - uint8_t bytesprops0[] = {0xa3, 0x0, 0xf3, 0x83, 0xd3, 0x93, 0x94, 0x9e, 0x26, 0x2e, 0xd}; - uint8_t bytesprops1[] = {0x9, 0xc6, 0x1c, 0x82, 0x90, 0x21, 0x82, 0x46, 0x35, 0xbf, 0x22, 0x75, 0xd3, 0xa1, 0x93}; - uint8_t bytesprops2[] = {0xbd, 0x12, 0x3e, 0x46, 0x56, 0x3d, 0x43, 0x2, 0x6, - 0x75, 0x8e, 0x85, 0xd7, 0xf9, 0xe0, 0xc3, 0xe1, 0x2a}; - uint8_t bytesprops3[] = {0xf4, 0x46, 0x42, 0xcb, 0x3e, 0x70, 0x3e}; - uint8_t bytesprops4[] = {0x8d, 0xb4, 0x82, 0x67, 0xa6, 0xdd, 0x3e, 0xa7, 0x2, 0x8c, - 0x5d, 0x99, 0x88, 0x6b, 0x87, 0x87, 0x2, 0xf3, 0xd7, 0xdf}; + uint8_t bytesprops1[] = {0x29, 0x7c, 0x5, 0x60, 0x9b, 0xc1, 0xfa, 0x9f, 0xb1, + 0xaa, 0xae, 0x4b, 0xf, 0x93, 0xc8, 0x67, 0xf6, 0xb1}; + uint8_t bytesprops0[] = {0x77, 0x8f, 0xbd, 0xca}; + uint8_t bytesprops2[] = {0xa3, 0x91, 0x43, 0x9f, 0x48, 0x77, 0x36, 0xa9, 0x5c, 0x84, 0x47, + 0x60, 0x5f, 0x3b, 0x64, 0xb, 0xce, 0x87, 0x78, 0x73, 0x6b}; + uint8_t bytesprops3[] = {0x80, 0x71, 0x31, 0x76, 0xbd, 0x5c, 0x3d, 0xd7, 0xa6, 0x59, 0x6d, 0xba, 0xcd, 0xdf, 0xcc, + 0x6d, 0xed, 0xff, 0x92, 0xd7, 0xc6, 0x65, 0x66, 0xda, 0x64, 0xbb, 0xaa, 0xcf, 0xc6}; + uint8_t bytesprops4[] = {0x24, 0xbb}; + uint8_t bytesprops5[] = {0x72, 0xb2, 0xc9, 0x18, 0xc5, 0xe3, 0x55, 0x84, 0xd2, 0xb2, 0x8, 0xdf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14373}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25898}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7145}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29689}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9274}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8728}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops0}, .v = {18, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9513}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2757}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16031}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8395}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13943}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28503}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10944, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 8248, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\198\161\148\238\191@\246\217\217\241\DC1\227\239", _pubPktID = 10944, _pubBody = "R3\160", _pubProps = -// [PropWildcardSubscriptionAvailable 84,PropTopicAliasMaximum 14373,PropResponseTopic -// "\163\NUL\243\131\211\147\148\158&.\r",PropServerKeepAlive 25898,PropMaximumPacketSize 7145,PropReceiveMaximum -// 29689,PropRequestProblemInformation 197,PropSubscriptionIdentifier 28,PropResponseTopic -// "\t\198\FS\130\144!\130F5\191\"u\211\161\147",PropTopicAlias 9274,PropRetainAvailable 33,PropReasonString -// "\189\DC2>FV=C\STX\ACKu\142\133\215\249\224\195\225*",PropSubscriptionIdentifierAvailable 131,PropServerReference -// "\244FB\203>p>",PropReceiveMaximum 8728,PropSubscriptionIdentifierAvailable 125,PropCorrelationData -// "\141\180\130g\166\221>\167\STX\140]\153\136k\135\135\STX\243\215\223"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "s\233\140\183\209=t\220\206\194\143\249\ETX\234\&5\b\144\f\246\250\US\193\193\178\226\201\156", _pubPktID = 8248, +// _pubBody = "v\196\240]\193r\165~\158\205\155'\206\&8\215s\248\196\250\&1\247", _pubProps = +// [PropWildcardSubscriptionAvailable 105,PropUserProperty "w\143\189\202" +// ")|\ENQ`\155\193\250\159\177\170\174K\SI\147\200g\246\177",PropResponseInformation +// "\163\145C\159Hw6\169\\\132G`_;d\v\206\135xsk",PropSessionExpiryInterval 9513,PropMessageExpiryInterval +// 2757,PropAuthenticationData +// "\128q1v\189\\=\215\166Ym\186\205\223\204m\237\255\146\215\198ef\218d\187\170\207\198",PropTopicAlias +// 16031,PropServerKeepAlive 8395,PropSessionExpiryInterval 13943,PropReceiveMaximum +// 28503,PropRequestResponseInformation 118,PropResponseTopic "$\187",PropServerReference +// "r\178\201\CAN\197\227U\132\210\178\b\223",PropSharedSubscriptionAvailable 190,PropRequestProblemInformation +// 186,PropMaximumQoS 207]} TEST(Publish5QCTest, Decode24) { - uint8_t pkt[] = {0x3c, 0x8b, 0x1, 0x0, 0xd, 0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, - 0xe3, 0xef, 0x2a, 0xc0, 0x76, 0x28, 0x54, 0x22, 0x38, 0x25, 0x8, 0x0, 0xb, 0xa3, 0x0, 0xf3, - 0x83, 0xd3, 0x93, 0x94, 0x9e, 0x26, 0x2e, 0xd, 0x13, 0x65, 0x2a, 0x27, 0x0, 0x0, 0x1b, 0xe9, - 0x21, 0x73, 0xf9, 0x17, 0xc5, 0xb, 0x1c, 0x8, 0x0, 0xf, 0x9, 0xc6, 0x1c, 0x82, 0x90, 0x21, - 0x82, 0x46, 0x35, 0xbf, 0x22, 0x75, 0xd3, 0xa1, 0x93, 0x23, 0x24, 0x3a, 0x25, 0x21, 0x1f, 0x0, - 0x12, 0xbd, 0x12, 0x3e, 0x46, 0x56, 0x3d, 0x43, 0x2, 0x6, 0x75, 0x8e, 0x85, 0xd7, 0xf9, 0xe0, - 0xc3, 0xe1, 0x2a, 0x29, 0x83, 0x1c, 0x0, 0x7, 0xf4, 0x46, 0x42, 0xcb, 0x3e, 0x70, 0x3e, 0x21, - 0x22, 0x18, 0x29, 0x7d, 0x9, 0x0, 0x14, 0x8d, 0xb4, 0x82, 0x67, 0xa6, 0xdd, 0x3e, 0xa7, 0x2, - 0x8c, 0x5d, 0x99, 0x88,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0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, 0x27, 0xce, 0x38, + 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4446,95 +4528,76 @@ TEST(Publish5QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc6, 0xa1, 0x94, 0xee, 0xbf, 0x40, 0xf6, 0xd9, 0xd9, 0xf1, 0x11, 0xe3, 0xef}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x52, 0x33, 0xa0}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, 0x3, 0xea, + 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, + 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10944); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(packet_id, 8248); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "V\195\159\242\185\ENQ\214\147\DLE\144\144,r\245\SO\237n\143\204\SUB\229\230", _pubPktID = 0, _pubBody = -// "\171\131\154", _pubProps = [PropContentType "\165jh\204\246\SOH\131KlPMz\142\143K=",PropCorrelationData -// "\231\223\SYN\157\255\226^\178\255\227",PropSubscriptionIdentifierAvailable 29,PropTopicAlias -// 24599,PropSessionExpiryInterval 17667,PropRetainAvailable 228,PropAuthenticationMethod -// "\142\EOT\159\223l2\177v\233\185\241\136;\186p",PropMaximumQoS 61,PropMaximumQoS 206,PropSharedSubscriptionAvailable -// 90,PropRequestProblemInformation 242,PropAuthenticationData "\186\159e\225\238\237",PropTopicAliasMaximum -// 17236,PropAuthenticationData "\168b\211",PropAuthenticationMethod -// "\180#G\231\a\ETXX}\233\232\FS\192\SUB@\250O\NAKn\176\227\DC4\156^V\215\134\169\190\194",PropMaximumQoS -// 192,PropSharedSubscriptionAvailable 39,PropServerKeepAlive 30465,PropUserProperty -// "\203\179l\247-\146\ESC)6\179\225\CAN\202,3\207\131\214\160\241$5" "9$\SOH\237M",PropTopicAliasMaximum -// 5969,PropSubscriptionIdentifierAvailable 27]} +// "\146;?\158\252\\a5\133\233\144\&9O\159\231\133\240}\DC1\200\&9\154a%\176Y", _pubPktID = 0, _pubBody = +// "\173\221\&2\157\129qMv\218\&6\216\165J\tp\242\205\&2\194t\243\161\STX?", _pubProps = +// [PropWildcardSubscriptionAvailable 100,PropSharedSubscriptionAvailable 223,PropTopicAlias 20373,PropMaximumPacketSize +// 5572,PropSessionExpiryInterval 738,PropReceiveMaximum 29296,PropWildcardSubscriptionAvailable +// 214,PropSharedSubscriptionAvailable 228,PropSubscriptionIdentifier 0,PropAuthenticationData +// "\236\161\148?\223\SI\130#I",PropSubscriptionIdentifier 17,PropMaximumQoS 12,PropServerKeepAlive 1836,PropContentType +// "Y\170\163\218\n\143\197\168\143\229\156Ja\129\214\"$v\216",PropWillDelayInterval 30892]} TEST(Publish5QCTest, Encode25) { - uint8_t pkt[] = {0x39, 0xc1, 0x1, 0x0, 0x16, 0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, 0x2c, - 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6, 0xa4, 0x1, 0x3, 0x0, 0x10, 0xa5, 0x6a, - 0x68, 0xcc, 0xf6, 0x1, 0x83, 0x4b, 0x6c, 0x50, 0x4d, 0x7a, 0x8e, 0x8f, 0x4b, 0x3d, 0x9, 0x0, 0xa, - 0xe7, 0xdf, 0x16, 0x9d, 0xff, 0xe2, 0x5e, 0xb2, 0xff, 0xe3, 0x29, 0x1d, 0x23, 0x60, 0x17, 0x11, 0x0, - 0x0, 0x45, 0x3, 0x25, 0xe4, 0x15, 0x0, 0xf, 0x8e, 0x4, 0x9f, 0xdf, 0x6c, 0x32, 0xb1, 0x76, 0xe9, - 0xb9, 0xf1, 0x88, 0x3b, 0xba, 0x70, 0x24, 0x3d, 0x24, 0xce, 0x2a, 0x5a, 0x17, 0xf2, 0x16, 0x0, 0x6, - 0xba, 0x9f, 0x65, 0xe1, 0xee, 0xed, 0x22, 0x43, 0x54, 0x16, 0x0, 0x3, 0xa8, 0x62, 0xd3, 0x15, 0x0, - 0x1d, 0xb4, 0x23, 0x47, 0xe7, 0x7, 0x3, 0x58, 0x7d, 0xe9, 0xe8, 0x1c, 0xc0, 0x1a, 0x40, 0xfa, 0x4f, - 0x15, 0x6e, 0xb0, 0xe3, 0x14, 0x9c, 0x5e, 0x56, 0xd7, 0x86, 0xa9, 0xbe, 0xc2, 0x24, 0xc0, 0x2a, 0x27, - 0x13, 0x77, 0x1, 0x26, 0x0, 0x16, 0xcb, 0xb3, 0x6c, 0xf7, 0x2d, 0x92, 0x1b, 0x29, 0x36, 0xb3, 0xe1, - 0x18, 0xca, 0x2c, 0x33, 0xcf, 0x83, 0xd6, 0xa0, 0xf1, 0x24, 0x35, 0x0, 0x5, 0x39, 0x24, 0x1, 0xed, - 0x4d, 0x22, 0x17, 0x51, 0x29, 0x1b, 0xab, 0x83, 0x9a}; - uint8_t topic_bytes[] = {0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, - 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x7d, 0x0, 0x1a, 0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, 0x90, 0x39, + 0x4f, 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, 0xb0, 0x59, 0x48, 0x28, + 0x64, 0x2a, 0xdf, 0x23, 0x4f, 0x95, 0x27, 0x0, 0x0, 0x15, 0xc4, 0x11, 0x0, 0x0, 0x2, 0xe2, + 0x21, 0x72, 0x70, 0x28, 0xd6, 0x2a, 0xe4, 0xb, 0x0, 0x16, 0x0, 0x9, 0xec, 0xa1, 0x94, 0x3f, + 0xdf, 0xf, 0x82, 0x23, 0x49, 0xb, 0x11, 0x24, 0xc, 0x13, 0x7, 0x2c, 0x3, 0x0, 0x13, 0x59, + 0xaa, 0xa3, 0xda, 0xa, 0x8f, 0xc5, 0xa8, 0x8f, 0xe5, 0x9c, 0x4a, 0x61, 0x81, 0xd6, 0x22, 0x24, + 0x76, 0xd8, 0x18, 0x0, 0x0, 0x78, 0xac, 0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, + 0x36, 0xd8, 0xa5, 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; + uint8_t topic_bytes[] = {0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, 0x90, 0x39, 0x4f, + 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, 0xb0, 0x59}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xab, 0x83, 0x9a}; + uint8_t msg_bytes[] = {0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, + 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 24; - uint8_t bytesprops0[] = {0xa5, 0x6a, 0x68, 0xcc, 0xf6, 0x1, 0x83, 0x4b, - 0x6c, 0x50, 0x4d, 0x7a, 0x8e, 0x8f, 0x4b, 0x3d}; - uint8_t bytesprops1[] = {0xe7, 0xdf, 0x16, 0x9d, 0xff, 0xe2, 0x5e, 0xb2, 0xff, 0xe3}; - uint8_t bytesprops2[] = {0x8e, 0x4, 0x9f, 0xdf, 0x6c, 0x32, 0xb1, 0x76, 0xe9, 0xb9, 0xf1, 0x88, 0x3b, 0xba, 0x70}; - uint8_t bytesprops3[] = {0xba, 0x9f, 0x65, 0xe1, 0xee, 0xed}; - uint8_t bytesprops4[] = {0xa8, 0x62, 0xd3}; - uint8_t bytesprops5[] = {0xb4, 0x23, 0x47, 0xe7, 0x7, 0x3, 0x58, 0x7d, 0xe9, 0xe8, 0x1c, 0xc0, 0x1a, 0x40, 0xfa, - 0x4f, 0x15, 0x6e, 0xb0, 0xe3, 0x14, 0x9c, 0x5e, 0x56, 0xd7, 0x86, 0xa9, 0xbe, 0xc2}; - uint8_t bytesprops7[] = {0x39, 0x24, 0x1, 0xed, 0x4d}; - uint8_t bytesprops6[] = {0xcb, 0xb3, 0x6c, 0xf7, 0x2d, 0x92, 0x1b, 0x29, 0x36, 0xb3, 0xe1, - 0x18, 0xca, 0x2c, 0x33, 0xcf, 0x83, 0xd6, 0xa0, 0xf1, 0x24, 0x35}; + uint8_t bytesprops0[] = {0xec, 0xa1, 0x94, 0x3f, 0xdf, 0xf, 0x82, 0x23, 0x49}; + uint8_t bytesprops1[] = {0x59, 0xaa, 0xa3, 0xda, 0xa, 0x8f, 0xc5, 0xa8, 0x8f, 0xe5, + 0x9c, 0x4a, 0x61, 0x81, 0xd6, 0x22, 0x24, 0x76, 0xd8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24599}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17667}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17236}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30465}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops6}, .v = {5, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5969}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20373}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5572}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 738}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29296}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1836}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30892}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); @@ -4543,30 +4606,22 @@ TEST(Publish5QCTest, Encode25) { } // PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "V\195\159\242\185\ENQ\214\147\DLE\144\144,r\245\SO\237n\143\204\SUB\229\230", _pubPktID = 0, _pubBody = -// "\171\131\154", _pubProps = [PropContentType "\165jh\204\246\SOH\131KlPMz\142\143K=",PropCorrelationData -// "\231\223\SYN\157\255\226^\178\255\227",PropSubscriptionIdentifierAvailable 29,PropTopicAlias -// 24599,PropSessionExpiryInterval 17667,PropRetainAvailable 228,PropAuthenticationMethod -// "\142\EOT\159\223l2\177v\233\185\241\136;\186p",PropMaximumQoS 61,PropMaximumQoS 206,PropSharedSubscriptionAvailable -// 90,PropRequestProblemInformation 242,PropAuthenticationData "\186\159e\225\238\237",PropTopicAliasMaximum -// 17236,PropAuthenticationData "\168b\211",PropAuthenticationMethod -// "\180#G\231\a\ETXX}\233\232\FS\192\SUB@\250O\NAKn\176\227\DC4\156^V\215\134\169\190\194",PropMaximumQoS -// 192,PropSharedSubscriptionAvailable 39,PropServerKeepAlive 30465,PropUserProperty -// "\203\179l\247-\146\ESC)6\179\225\CAN\202,3\207\131\214\160\241$5" "9$\SOH\237M",PropTopicAliasMaximum -// 5969,PropSubscriptionIdentifierAvailable 27]} +// "\146;?\158\252\\a5\133\233\144\&9O\159\231\133\240}\DC1\200\&9\154a%\176Y", _pubPktID = 0, _pubBody = +// "\173\221\&2\157\129qMv\218\&6\216\165J\tp\242\205\&2\194t\243\161\STX?", _pubProps = +// [PropWildcardSubscriptionAvailable 100,PropSharedSubscriptionAvailable 223,PropTopicAlias 20373,PropMaximumPacketSize +// 5572,PropSessionExpiryInterval 738,PropReceiveMaximum 29296,PropWildcardSubscriptionAvailable +// 214,PropSharedSubscriptionAvailable 228,PropSubscriptionIdentifier 0,PropAuthenticationData +// "\236\161\148?\223\SI\130#I",PropSubscriptionIdentifier 17,PropMaximumQoS 12,PropServerKeepAlive 1836,PropContentType +// "Y\170\163\218\n\143\197\168\143\229\156Ja\129\214\"$v\216",PropWillDelayInterval 30892]} TEST(Publish5QCTest, Decode25) { - uint8_t pkt[] = {0x39, 0xc1, 0x1, 0x0, 0x16, 0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, 0x2c, - 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6, 0xa4, 0x1, 0x3, 0x0, 0x10, 0xa5, 0x6a, - 0x68, 0xcc, 0xf6, 0x1, 0x83, 0x4b, 0x6c, 0x50, 0x4d, 0x7a, 0x8e, 0x8f, 0x4b, 0x3d, 0x9, 0x0, 0xa, - 0xe7, 0xdf, 0x16, 0x9d, 0xff, 0xe2, 0x5e, 0xb2, 0xff, 0xe3, 0x29, 0x1d, 0x23, 0x60, 0x17, 0x11, 0x0, - 0x0, 0x45, 0x3, 0x25, 0xe4, 0x15, 0x0, 0xf, 0x8e, 0x4, 0x9f, 0xdf, 0x6c, 0x32, 0xb1, 0x76, 0xe9, - 0xb9, 0xf1, 0x88, 0x3b, 0xba, 0x70, 0x24, 0x3d, 0x24, 0xce, 0x2a, 0x5a, 0x17, 0xf2, 0x16, 0x0, 0x6, - 0xba, 0x9f, 0x65, 0xe1, 0xee, 0xed, 0x22, 0x43, 0x54, 0x16, 0x0, 0x3, 0xa8, 0x62, 0xd3, 0x15, 0x0, - 0x1d, 0xb4, 0x23, 0x47, 0xe7, 0x7, 0x3, 0x58, 0x7d, 0xe9, 0xe8, 0x1c, 0xc0, 0x1a, 0x40, 0xfa, 0x4f, - 0x15, 0x6e, 0xb0, 0xe3, 0x14, 0x9c, 0x5e, 0x56, 0xd7, 0x86, 0xa9, 0xbe, 0xc2, 0x24, 0xc0, 0x2a, 0x27, - 0x13, 0x77, 0x1, 0x26, 0x0, 0x16, 0xcb, 0xb3, 0x6c, 0xf7, 0x2d, 0x92, 0x1b, 0x29, 0x36, 0xb3, 0xe1, - 0x18, 0xca, 0x2c, 0x33, 0xcf, 0x83, 0xd6, 0xa0, 0xf1, 0x24, 0x35, 0x0, 0x5, 0x39, 0x24, 0x1, 0xed, - 0x4d, 0x22, 0x17, 0x51, 0x29, 0x1b, 0xab, 0x83, 0x9a}; + uint8_t pkt[] = {0x39, 0x7d, 0x0, 0x1a, 0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, 0x90, 0x39, + 0x4f, 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, 0xb0, 0x59, 0x48, 0x28, + 0x64, 0x2a, 0xdf, 0x23, 0x4f, 0x95, 0x27, 0x0, 0x0, 0x15, 0xc4, 0x11, 0x0, 0x0, 0x2, 0xe2, + 0x21, 0x72, 0x70, 0x28, 0xd6, 0x2a, 0xe4, 0xb, 0x0, 0x16, 0x0, 0x9, 0xec, 0xa1, 0x94, 0x3f, + 0xdf, 0xf, 0x82, 0x23, 0x49, 0xb, 0x11, 0x24, 0xc, 0x13, 0x7, 0x2c, 0x3, 0x0, 0x13, 0x59, + 0xaa, 0xa3, 0xda, 0xa, 0x8f, 0xc5, 0xa8, 0x8f, 0xe5, 0x9c, 0x4a, 0x61, 0x81, 0xd6, 0x22, 0x24, + 0x76, 0xd8, 0x18, 0x0, 0x0, 0x78, 0xac, 0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, + 0x36, 0xd8, 0xa5, 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4575,94 +4630,122 @@ TEST(Publish5QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x56, 0xc3, 0x9f, 0xf2, 0xb9, 0x5, 0xd6, 0x93, 0x10, 0x90, 0x90, - 0x2c, 0x72, 0xf5, 0xe, 0xed, 0x6e, 0x8f, 0xcc, 0x1a, 0xe5, 0xe6}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xab, 0x83, 0x9a}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, 0x90, 0x39, 0x4f, + 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, 0xb0, 0x59}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, + 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ",\129\b\199\224\197\191\196~\130\211\129B\164\238\NAK\138I\201f\163", _pubPktID = 2253, _pubBody = -// "|\153\171Y,OB.\132d\186cm;\DC4+\153\209y\t\128", _pubProps = [PropReasonString "\195U\132s:\212",PropReceiveMaximum -// 9748,PropMessageExpiryInterval 29630,PropResponseTopic "\153\&4\166~2\191\165\186\EOTM0\139 -// p3\166\186",PropResponseInformation -// "\243\210\EM\240\"\n\DC1\192\181p,\226)\241\DC1b\230d\194\137\150\221\228\SI]t\246",PropRetainAvailable -// 18,PropTopicAliasMaximum 16390,PropAuthenticationData "\222\143\211\240",PropReceiveMaximum 2405]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "?X\254\SIJ/\199\240\153I\171-\227\213\191\205\b\202\247\252\a\196\136\150\215K\\R", _pubPktID = 0, _pubBody = +// "\167\192W\238\177\207\SO\148\212\134\&6\145\223N\168", _pubProps = [PropMaximumPacketSize +// 23071,PropSessionExpiryInterval 11860,PropRequestResponseInformation 15,PropCorrelationData +// "\SYN",PropTopicAliasMaximum 12529,PropAssignedClientIdentifier "C",PropWillDelayInterval +// 30896,PropSubscriptionIdentifier 30,PropReceiveMaximum 4366,PropCorrelationData "\221",PropMaximumQoS +// 167,PropRequestProblemInformation 224,PropContentType +// "\148\196\176\241\190\170\&7W\182\250\168\GS\226\169\206\233\SIkrvq",PropAssignedClientIdentifier +// "\178\162|J\232\216\158\186\133\ENQ\234w",PropServerKeepAlive 7326,PropResponseInformation +// "\176\251\199\&7F&\234\137\129\248\n\209&\194\161d\221{\158\156\164",PropCorrelationData +// "\244\255\209\153\183\DC1N\168",PropMaximumQoS 49,PropRetainAvailable 71,PropTopicAliasMaximum 7503]} TEST(Publish5QCTest, Encode26) { - uint8_t pkt[] = {0x34, 0x81, 0x1, 0x0, 0x15, 0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, 0x81, - 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3, 0x8, 0xcd, 0x52, 0x1f, 0x0, 0x6, 0xc3, 0x55, - 0x84, 0x73, 0x3a, 0xd4, 0x21, 0x26, 0x14, 0x2, 0x0, 0x0, 0x73, 0xbe, 0x8, 0x0, 0x11, 0x99, 0x34, - 0xa6, 0x7e, 0x32, 0xbf, 0xa5, 0xba, 0x4, 0x4d, 0x30, 0x8b, 0x20, 0x70, 0x33, 0xa6, 0xba, 0x1a, 0x0, - 0x1b, 0xf3, 0xd2, 0x19, 0xf0, 0x22, 0xa, 0x11, 0xc0, 0xb5, 0x70, 0x2c, 0xe2, 0x29, 0xf1, 0x11, 0x62, - 0xe6, 0x64, 0xc2, 0x89, 0x96, 0xdd, 0xe4, 0xf, 0x5d, 0x74, 0xf6, 0x25, 0x12, 0x22, 0x40, 0x6, 0x16, - 0x0, 0x4, 0xde, 0x8f, 0xd3, 0xf0, 0x21, 0x9, 0x65, 0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, - 0x84, 0x64, 0xba, 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; - uint8_t topic_bytes[] = {0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, - 0x81, 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0xab, 0x1, 0x0, 0x1c, 0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, + 0x2d, 0xe3, 0xd5, 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, + 0x52, 0x7d, 0x27, 0x0, 0x0, 0x5a, 0x1f, 0x11, 0x0, 0x0, 0x2e, 0x54, 0x19, 0xf, 0x9, 0x0, + 0x1, 0x16, 0x22, 0x30, 0xf1, 0x12, 0x0, 0x1, 0x43, 0x18, 0x0, 0x0, 0x78, 0xb0, 0xb, 0x1e, + 0x21, 0x11, 0xe, 0x9, 0x0, 0x1, 0xdd, 0x24, 0xa7, 0x17, 0xe0, 0x3, 0x0, 0x15, 0x94, 0xc4, + 0xb0, 0xf1, 0xbe, 0xaa, 0x37, 0x57, 0xb6, 0xfa, 0xa8, 0x1d, 0xe2, 0xa9, 0xce, 0xe9, 0xf, 0x6b, + 0x72, 0x76, 0x71, 0x12, 0x0, 0xc, 0xb2, 0xa2, 0x7c, 0x4a, 0xe8, 0xd8, 0x9e, 0xba, 0x85, 0x5, + 0xea, 0x77, 0x13, 0x1c, 0x9e, 0x1a, 0x0, 0x15, 0xb0, 0xfb, 0xc7, 0x37, 0x46, 0x26, 0xea, 0x89, + 0x81, 0xf8, 0xa, 0xd1, 0x26, 0xc2, 0xa1, 0x64, 0xdd, 0x7b, 0x9e, 0x9c, 0xa4, 0x9, 0x0, 0x8, + 0xf4, 0xff, 0xd1, 0x99, 0xb7, 0x11, 0x4e, 0xa8, 0x24, 0x31, 0x25, 0x47, 0x22, 0x1d, 0x4f, 0xa7, + 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; + uint8_t topic_bytes[] = {0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, 0xe3, 0xd5, + 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, - 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - - uint8_t bytesprops0[] = {0xc3, 0x55, 0x84, 0x73, 0x3a, 0xd4}; - uint8_t bytesprops1[] = {0x99, 0x34, 0xa6, 0x7e, 0x32, 0xbf, 0xa5, 0xba, 0x4, - 0x4d, 0x30, 0x8b, 0x20, 0x70, 0x33, 0xa6, 0xba}; - uint8_t bytesprops2[] = {0xf3, 0xd2, 0x19, 0xf0, 0x22, 0xa, 0x11, 0xc0, 0xb5, 0x70, 0x2c, 0xe2, 0x29, 0xf1, - 0x11, 0x62, 0xe6, 0x64, 0xc2, 0x89, 0x96, 0xdd, 0xe4, 0xf, 0x5d, 0x74, 0xf6}; - uint8_t bytesprops3[] = {0xde, 0x8f, 0xd3, 0xf0}; + msg.payload_len = 15; + + uint8_t bytesprops0[] = {0x16}; + uint8_t bytesprops1[] = {0x43}; + uint8_t bytesprops2[] = {0xdd}; + uint8_t bytesprops3[] = {0x94, 0xc4, 0xb0, 0xf1, 0xbe, 0xaa, 0x37, 0x57, 0xb6, 0xfa, 0xa8, + 0x1d, 0xe2, 0xa9, 0xce, 0xe9, 0xf, 0x6b, 0x72, 0x76, 0x71}; + uint8_t bytesprops4[] = {0xb2, 0xa2, 0x7c, 0x4a, 0xe8, 0xd8, 0x9e, 0xba, 0x85, 0x5, 0xea, 0x77}; + uint8_t bytesprops5[] = {0xb0, 0xfb, 0xc7, 0x37, 0x46, 0x26, 0xea, 0x89, 0x81, 0xf8, 0xa, + 0xd1, 0x26, 0xc2, 0xa1, 0x64, 0xdd, 0x7b, 0x9e, 0x9c, 0xa4}; + uint8_t bytesprops6[] = {0xf4, 0xff, 0xd1, 0x99, 0xb7, 0x11, 0x4e, 0xa8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9748}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29630}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16390}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2405}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23071}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11860}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12529}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30896}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4366}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7326}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7503}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 2253, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ",\129\b\199\224\197\191\196~\130\211\129B\164\238\NAK\138I\201f\163", _pubPktID = 2253, _pubBody = -// "|\153\171Y,OB.\132d\186cm;\DC4+\153\209y\t\128", _pubProps = [PropReasonString "\195U\132s:\212",PropReceiveMaximum -// 9748,PropMessageExpiryInterval 29630,PropResponseTopic "\153\&4\166~2\191\165\186\EOTM0\139 -// p3\166\186",PropResponseInformation -// "\243\210\EM\240\"\n\DC1\192\181p,\226)\241\DC1b\230d\194\137\150\221\228\SI]t\246",PropRetainAvailable -// 18,PropTopicAliasMaximum 16390,PropAuthenticationData "\222\143\211\240",PropReceiveMaximum 2405]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "?X\254\SIJ/\199\240\153I\171-\227\213\191\205\b\202\247\252\a\196\136\150\215K\\R", _pubPktID = 0, _pubBody = +// "\167\192W\238\177\207\SO\148\212\134\&6\145\223N\168", _pubProps = [PropMaximumPacketSize +// 23071,PropSessionExpiryInterval 11860,PropRequestResponseInformation 15,PropCorrelationData +// "\SYN",PropTopicAliasMaximum 12529,PropAssignedClientIdentifier "C",PropWillDelayInterval +// 30896,PropSubscriptionIdentifier 30,PropReceiveMaximum 4366,PropCorrelationData "\221",PropMaximumQoS +// 167,PropRequestProblemInformation 224,PropContentType +// "\148\196\176\241\190\170\&7W\182\250\168\GS\226\169\206\233\SIkrvq",PropAssignedClientIdentifier +// "\178\162|J\232\216\158\186\133\ENQ\234w",PropServerKeepAlive 7326,PropResponseInformation +// "\176\251\199\&7F&\234\137\129\248\n\209&\194\161d\221{\158\156\164",PropCorrelationData +// "\244\255\209\153\183\DC1N\168",PropMaximumQoS 49,PropRetainAvailable 71,PropTopicAliasMaximum 7503]} TEST(Publish5QCTest, Decode26) { - uint8_t pkt[] = {0x34, 0x81, 0x1, 0x0, 0x15, 0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, 0x81, - 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3, 0x8, 0xcd, 0x52, 0x1f, 0x0, 0x6, 0xc3, 0x55, - 0x84, 0x73, 0x3a, 0xd4, 0x21, 0x26, 0x14, 0x2, 0x0, 0x0, 0x73, 0xbe, 0x8, 0x0, 0x11, 0x99, 0x34, - 0xa6, 0x7e, 0x32, 0xbf, 0xa5, 0xba, 0x4, 0x4d, 0x30, 0x8b, 0x20, 0x70, 0x33, 0xa6, 0xba, 0x1a, 0x0, - 0x1b, 0xf3, 0xd2, 0x19, 0xf0, 0x22, 0xa, 0x11, 0xc0, 0xb5, 0x70, 0x2c, 0xe2, 0x29, 0xf1, 0x11, 0x62, - 0xe6, 0x64, 0xc2, 0x89, 0x96, 0xdd, 0xe4, 0xf, 0x5d, 0x74, 0xf6, 0x25, 0x12, 0x22, 0x40, 0x6, 0x16, - 0x0, 0x4, 0xde, 0x8f, 0xd3, 0xf0, 0x21, 0x9, 0x65, 0x7c, 0x99, 0xab, 0x59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94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4671,135 +4754,158 @@ TEST(Publish5QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x2c, 0x81, 0x8, 0xc7, 0xe0, 0xc5, 0xbf, 0xc4, 0x7e, 0x82, 0xd3, - 0x81, 0x42, 0xa4, 0xee, 0x15, 0x8a, 0x49, 0xc9, 0x66, 0xa3}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7c, 0x99, 0xab, 0x59, 0x2c, 0x4f, 0x42, 0x2e, 0x84, 0x64, 0xba, - 0x63, 0x6d, 0x3b, 0x14, 0x2b, 0x99, 0xd1, 0x79, 0x9, 0x80}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, 0xe3, 0xd5, + 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2253); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\255\138\160\SO}\145\231=\154\241iR\219\FS\151\240}B\141(\214", _pubPktID = 10836, _pubBody = "\249\144\&7 -// ,\DC2\216\146r\155\161\224l\238\165\FS\245", _pubProps = [PropRequestProblemInformation 141,PropMessageExpiryInterval -// 6268,PropSessionExpiryInterval 15867,PropReceiveMaximum 1447,PropTopicAliasMaximum 31003,PropCorrelationData -// "\228",PropMessageExpiryInterval 27091,PropWillDelayInterval 20427,PropSessionExpiryInterval 32582,PropResponseTopic -// "!e]\"\248\225\246\246\r\227V\146\252\237\180\215\185\201\SI\227\&8H\SYN\153\181x\134\174?",PropPayloadFormatIndicator -// 161,PropAssignedClientIdentifier "[\150\250d\191\163\220",PropCorrelationData "L\187E:J$o\234",PropMaximumQoS -// 180,PropCorrelationData "AS\141",PropRequestResponseInformation 131,PropUserProperty "\198\150" -// "\224c\250\195Upn\132\171\207S\205\165\209zN:h\137o\NAK\222\ACK",PropRetainAvailable 185,PropAssignedClientIdentifier -// "\r\GS\166\156<\DC4L\171",PropMessageExpiryInterval 17333,PropRetainAvailable 239,PropRequestResponseInformation -// 239,PropCorrelationData "\237{^\220\142\169$\190\172^\ETXZ\137\183\DC2\SUB\248\DC1\177*\154\\\243\167w\ACK"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\144\167\130\179A", _pubPktID = 0, +// _pubBody = "\148\134\185\213\184\233\187\157\198\233\181\148_\215\n$@\169\251\210\184\f", _pubProps = +// [PropAuthenticationMethod +// "|\143q\195\251M\191\232h\177P\223+GO\216\205\SOHt\NUL\195\166\215\149\248\DC1\172\175",PropWildcardSubscriptionAvailable +// 110,PropServerKeepAlive 4553,PropUserProperty "\171nt\205N@\181\158\130" +// "\132&\133\171(\158\191\141\134\NUL9~]\166\v\US\175Ke5{z\155\DEL\220Q#\144\210L",PropRequestProblemInformation +// 209,PropMessageExpiryInterval 18135,PropRetainAvailable 50,PropSharedSubscriptionAvailable +// 25,PropRequestResponseInformation 116,PropAssignedClientIdentifier "\222~\174\197]x}\tt",PropAssignedClientIdentifier +// "\254m\222~\246c\236\EMxgc\n\133\DC3\161\215\138\189\196\160\239v\195\214",PropServerReference +// "v\228\245!.}\DC4\234\167y\248\193\145\163\128\133\234\222\154\155'\216\ETX\182\149\196\FS\198$",PropContentType +// "\194\157\134\206L\155\159T\181\225\202\251\165\135\218V/M\SO\\\182\&7\tb\186y",PropServerKeepAlive +// 28713,PropAssignedClientIdentifier +// "\184\NUL\195X\133\147\177JY\136\198\SUB$\231<\SUB\154\166\214\180\193/\FS",PropResponseInformation +// "\157+6\169",PropRequestResponseInformation 231,PropWillDelayInterval 27240,PropMaximumPacketSize +// 2824,PropRequestResponseInformation 113,PropPayloadFormatIndicator 71,PropServerReference +// "!4\CAN\241\142\181j",PropWillDelayInterval 28393,PropResponseInformation "(\174\188e",PropMaximumPacketSize 15079]} TEST(Publish5QCTest, Encode27) { - uint8_t pkt[] = {0x3a, 0xe3, 0x1, 0x0, 0x15, 0xff, 0x8a, 0xa0, 0xe, 0x7d, 0x91, 0xe7, 0x3d, 0x9a, 0xf1, 0x69, 0x52, - 0xdb, 0x1c, 0x97, 0xf0, 0x7d, 0x42, 0x8d, 0x28, 0xd6, 0x2a, 0x54, 0xb7, 0x1, 0x17, 0x8d, 0x2, 0x0, - 0x0, 0x18, 0x7c, 0x11, 0x0, 0x0, 0x3d, 0xfb, 0x21, 0x5, 0xa7, 0x22, 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es[] = {0xff, 0x8a, 0xa0, 0xe, 0x7d, 0x91, 0xe7, 0x3d, 0x9a, 0xf1, 0x69, - 0x52, 0xdb, 0x1c, 0x97, 0xf0, 0x7d, 0x42, 0x8d, 0x28, 0xd6}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0xaf, 0x2, 0x0, 0x5, 0x90, 0xa7, 0x82, 0xb3, 0x41, 0x90, 0x2, 0x15, 0x0, 0x1c, 0x7c, 0x8f, + 0x71, 0xc3, 0xfb, 0x4d, 0xbf, 0xe8, 0x68, 0xb1, 0x50, 0xdf, 0x2b, 0x47, 0x4f, 0xd8, 0xcd, 0x1, 0x74, + 0x0, 0xc3, 0xa6, 0xd7, 0x95, 0xf8, 0x11, 0xac, 0xaf, 0x28, 0x6e, 0x13, 0x11, 0xc9, 0x26, 0x0, 0x9, + 0xab, 0x6e, 0x74, 0xcd, 0x4e, 0x40, 0xb5, 0x9e, 0x82, 0x0, 0x1e, 0x84, 0x26, 0x85, 0xab, 0x28, 0x9e, + 0xbf, 0x8d, 0x86, 0x0, 0x39, 0x7e, 0x5d, 0xa6, 0xb, 0x1f, 0xaf, 0x4b, 0x65, 0x35, 0x7b, 0x7a, 0x9b, + 0x7f, 0xdc, 0x51, 0x23, 0x90, 0xd2, 0x4c, 0x17, 0xd1, 0x2, 0x0, 0x0, 0x46, 0xd7, 0x25, 0x32, 0x2a, + 0x19, 0x19, 0x74, 0x12, 0x0, 0x9, 0xde, 0x7e, 0xae, 0xc5, 0x5d, 0x78, 0x7d, 0x9, 0x74, 0x12, 0x0, + 0x18, 0xfe, 0x6d, 0xde, 0x7e, 0xf6, 0x63, 0xec, 0x19, 0x78, 0x67, 0x63, 0xa, 0x85, 0x13, 0xa1, 0xd7, + 0x8a, 0xbd, 0xc4, 0xa0, 0xef, 0x76, 0xc3, 0xd6, 0x1c, 0x0, 0x1d, 0x76, 0xe4, 0xf5, 0x21, 0x2e, 0x7d, + 0x14, 0xea, 0xa7, 0x79, 0xf8, 0xc1, 0x91, 0xa3, 0x80, 0x85, 0xea, 0xde, 0x9a, 0x9b, 0x27, 0xd8, 0x3, + 0xb6, 0x95, 0xc4, 0x1c, 0xc6, 0x24, 0x3, 0x0, 0x1a, 0xc2, 0x9d, 0x86, 0xce, 0x4c, 0x9b, 0x9f, 0x54, + 0xb5, 0xe1, 0xca, 0xfb, 0xa5, 0x87, 0xda, 0x56, 0x2f, 0x4d, 0xe, 0x5c, 0xb6, 0x37, 0x9, 0x62, 0xba, + 0x79, 0x13, 0x70, 0x29, 0x12, 0x0, 0x17, 0xb8, 0x0, 0xc3, 0x58, 0x85, 0x93, 0xb1, 0x4a, 0x59, 0x88, + 0xc6, 0x1a, 0x24, 0xe7, 0x3c, 0x1a, 0x9a, 0xa6, 0xd6, 0xb4, 0xc1, 0x2f, 0x1c, 0x1a, 0x0, 0x4, 0x9d, + 0x2b, 0x36, 0xa9, 0x19, 0xe7, 0x18, 0x0, 0x0, 0x6a, 0x68, 0x27, 0x0, 0x0, 0xb, 0x8, 0x19, 0x71, + 0x1, 0x47, 0x1c, 0x0, 0x7, 0x21, 0x34, 0x18, 0xf1, 0x8e, 0xb5, 0x6a, 0x18, 0x0, 0x0, 0x6e, 0xe9, + 0x1a, 0x0, 0x4, 0x28, 0xae, 0xbc, 0x65, 0x27, 0x0, 0x0, 0x3a, 0xe7, 0x94, 0x86, 0xb9, 0xd5, 0xb8, + 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; + uint8_t topic_bytes[] = {0x90, 0xa7, 0x82, 0xb3, 0x41}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0xf9, 0x90, 0x37, 0x20, 0x2c, 0x12, 0xd8, 0x92, 0x72, - 0x9b, 0xa1, 0xe0, 0x6c, 0xee, 0xa5, 0x1c, 0xf5}; + uint8_t msg_bytes[] = {0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, + 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; - - uint8_t bytesprops0[] = {0xe4}; - uint8_t bytesprops1[] = {0x21, 0x65, 0x5d, 0x22, 0xf8, 0xe1, 0xf6, 0xf6, 0xd, 0xe3, 0x56, 0x92, 0xfc, 0xed, 0xb4, - 0xd7, 0xb9, 0xc9, 0xf, 0xe3, 0x38, 0x48, 0x16, 0x99, 0xb5, 0x78, 0x86, 0xae, 0x3f}; - uint8_t bytesprops2[] = {0x5b, 0x96, 0xfa, 0x64, 0xbf, 0xa3, 0xdc}; - uint8_t bytesprops3[] = {0x4c, 0xbb, 0x45, 0x3a, 0x4a, 0x24, 0x6f, 0xea}; - uint8_t bytesprops4[] = {0x41, 0x53, 0x8d}; - uint8_t bytesprops6[] = {0xe0, 0x63, 0xfa, 0xc3, 0x55, 0x70, 0x6e, 0x84, 0xab, 0xcf, 0x53, 0xcd, - 0xa5, 0xd1, 0x7a, 0x4e, 0x3a, 0x68, 0x89, 0x6f, 0x15, 0xde, 0x6}; - uint8_t bytesprops5[] = {0xc6, 0x96}; - uint8_t bytesprops7[] = {0xd, 0x1d, 0xa6, 0x9c, 0x3c, 0x14, 0x4c, 0xab}; - uint8_t bytesprops8[] = {0xed, 0x7b, 0x5e, 0xdc, 0x8e, 0xa9, 0x24, 0xbe, 0xac, 0x5e, 0x3, 0x5a, 0x89, - 0xb7, 0x12, 0x1a, 0xf8, 0x11, 0xb1, 0x2a, 0x9a, 0x5c, 0xf3, 0xa7, 0x77, 0x6}; + msg.payload_len = 22; + + uint8_t bytesprops0[] = {0x7c, 0x8f, 0x71, 0xc3, 0xfb, 0x4d, 0xbf, 0xe8, 0x68, 0xb1, 0x50, 0xdf, 0x2b, 0x47, + 0x4f, 0xd8, 0xcd, 0x1, 0x74, 0x0, 0xc3, 0xa6, 0xd7, 0x95, 0xf8, 0x11, 0xac, 0xaf}; + uint8_t bytesprops2[] = {0x84, 0x26, 0x85, 0xab, 0x28, 0x9e, 0xbf, 0x8d, 0x86, 0x0, 0x39, 0x7e, 0x5d, 0xa6, 0xb, + 0x1f, 0xaf, 0x4b, 0x65, 0x35, 0x7b, 0x7a, 0x9b, 0x7f, 0xdc, 0x51, 0x23, 0x90, 0xd2, 0x4c}; + uint8_t bytesprops1[] = {0xab, 0x6e, 0x74, 0xcd, 0x4e, 0x40, 0xb5, 0x9e, 0x82}; + uint8_t bytesprops3[] = {0xde, 0x7e, 0xae, 0xc5, 0x5d, 0x78, 0x7d, 0x9, 0x74}; + uint8_t bytesprops4[] = {0xfe, 0x6d, 0xde, 0x7e, 0xf6, 0x63, 0xec, 0x19, 0x78, 0x67, 0x63, 0xa, + 0x85, 0x13, 0xa1, 0xd7, 0x8a, 0xbd, 0xc4, 0xa0, 0xef, 0x76, 0xc3, 0xd6}; + uint8_t bytesprops5[] = {0x76, 0xe4, 0xf5, 0x21, 0x2e, 0x7d, 0x14, 0xea, 0xa7, 0x79, 0xf8, 0xc1, 0x91, 0xa3, 0x80, + 0x85, 0xea, 0xde, 0x9a, 0x9b, 0x27, 0xd8, 0x3, 0xb6, 0x95, 0xc4, 0x1c, 0xc6, 0x24}; + uint8_t bytesprops6[] = {0xc2, 0x9d, 0x86, 0xce, 0x4c, 0x9b, 0x9f, 0x54, 0xb5, 0xe1, 0xca, 0xfb, 0xa5, + 0x87, 0xda, 0x56, 0x2f, 0x4d, 0xe, 0x5c, 0xb6, 0x37, 0x9, 0x62, 0xba, 0x79}; + uint8_t bytesprops7[] = {0xb8, 0x0, 0xc3, 0x58, 0x85, 0x93, 0xb1, 0x4a, 0x59, 0x88, 0xc6, 0x1a, + 0x24, 0xe7, 0x3c, 0x1a, 0x9a, 0xa6, 0xd6, 0xb4, 0xc1, 0x2f, 0x1c}; + uint8_t bytesprops8[] = {0x9d, 0x2b, 0x36, 0xa9}; + uint8_t bytesprops9[] = {0x21, 0x34, 0x18, 0xf1, 0x8e, 0xb5, 0x6a}; + uint8_t bytesprops10[] = {0x28, 0xae, 0xbc, 0x65}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6268}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15867}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1447}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31003}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27091}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20427}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32582}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops5}, .v = {23, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17333}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4553}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18135}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28713}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27240}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2824}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28393}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15079}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10836, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\255\138\160\SO}\145\231=\154\241iR\219\FS\151\240}B\141(\214", _pubPktID = 10836, _pubBody = "\249\144\&7 -// ,\DC2\216\146r\155\161\224l\238\165\FS\245", _pubProps = [PropRequestProblemInformation 141,PropMessageExpiryInterval -// 6268,PropSessionExpiryInterval 15867,PropReceiveMaximum 1447,PropTopicAliasMaximum 31003,PropCorrelationData -// "\228",PropMessageExpiryInterval 27091,PropWillDelayInterval 20427,PropSessionExpiryInterval 32582,PropResponseTopic -// "!e]\"\248\225\246\246\r\227V\146\252\237\180\215\185\201\SI\227\&8H\SYN\153\181x\134\174?",PropPayloadFormatIndicator -// 161,PropAssignedClientIdentifier "[\150\250d\191\163\220",PropCorrelationData "L\187E:J$o\234",PropMaximumQoS -// 180,PropCorrelationData "AS\141",PropRequestResponseInformation 131,PropUserProperty "\198\150" -// "\224c\250\195Upn\132\171\207S\205\165\209zN:h\137o\NAK\222\ACK",PropRetainAvailable 185,PropAssignedClientIdentifier -// "\r\GS\166\156<\DC4L\171",PropMessageExpiryInterval 17333,PropRetainAvailable 239,PropRequestResponseInformation -// 239,PropCorrelationData "\237{^\220\142\169$\190\172^\ETXZ\137\183\DC2\SUB\248\DC1\177*\154\\\243\167w\ACK"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\144\167\130\179A", _pubPktID = 0, +// _pubBody = "\148\134\185\213\184\233\187\157\198\233\181\148_\215\n$@\169\251\210\184\f", _pubProps = +// [PropAuthenticationMethod +// "|\143q\195\251M\191\232h\177P\223+GO\216\205\SOHt\NUL\195\166\215\149\248\DC1\172\175",PropWildcardSubscriptionAvailable +// 110,PropServerKeepAlive 4553,PropUserProperty "\171nt\205N@\181\158\130" +// "\132&\133\171(\158\191\141\134\NUL9~]\166\v\US\175Ke5{z\155\DEL\220Q#\144\210L",PropRequestProblemInformation +// 209,PropMessageExpiryInterval 18135,PropRetainAvailable 50,PropSharedSubscriptionAvailable +// 25,PropRequestResponseInformation 116,PropAssignedClientIdentifier "\222~\174\197]x}\tt",PropAssignedClientIdentifier +// "\254m\222~\246c\236\EMxgc\n\133\DC3\161\215\138\189\196\160\239v\195\214",PropServerReference +// "v\228\245!.}\DC4\234\167y\248\193\145\163\128\133\234\222\154\155'\216\ETX\182\149\196\FS\198$",PropContentType +// "\194\157\134\206L\155\159T\181\225\202\251\165\135\218V/M\SO\\\182\&7\tb\186y",PropServerKeepAlive +// 28713,PropAssignedClientIdentifier +// "\184\NUL\195X\133\147\177JY\136\198\SUB$\231<\SUB\154\166\214\180\193/\FS",PropResponseInformation +// "\157+6\169",PropRequestResponseInformation 231,PropWillDelayInterval 27240,PropMaximumPacketSize +// 2824,PropRequestResponseInformation 113,PropPayloadFormatIndicator 71,PropServerReference +// "!4\CAN\241\142\181j",PropWillDelayInterval 28393,PropResponseInformation "(\174\188e",PropMaximumPacketSize 15079]} TEST(Publish5QCTest, Decode27) { - uint8_t pkt[] = {0x3a, 0xe3, 0x1, 0x0, 0x15, 0xff, 0x8a, 0xa0, 0xe, 0x7d, 0x91, 0xe7, 0x3d, 0x9a, 0xf1, 0x69, 0x52, - 0xdb, 0x1c,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c1, 0x91, 0xa3, 0x80, 0x85, 0xea, 0xde, 0x9a, 0x9b, 0x27, 0xd8, 0x3, + 0xb6, 0x95, 0xc4, 0x1c, 0xc6, 0x24, 0x3, 0x0, 0x1a, 0xc2, 0x9d, 0x86, 0xce, 0x4c, 0x9b, 0x9f, 0x54, + 0xb5, 0xe1, 0xca, 0xfb, 0xa5, 0x87, 0xda, 0x56, 0x2f, 0x4d, 0xe, 0x5c, 0xb6, 0x37, 0x9, 0x62, 0xba, + 0x79, 0x13, 0x70, 0x29, 0x12, 0x0, 0x17, 0xb8, 0x0, 0xc3, 0x58, 0x85, 0x93, 0xb1, 0x4a, 0x59, 0x88, + 0xc6, 0x1a, 0x24, 0xe7, 0x3c, 0x1a, 0x9a, 0xa6, 0xd6, 0xb4, 0xc1, 0x2f, 0x1c, 0x1a, 0x0, 0x4, 0x9d, + 0x2b, 0x36, 0xa9, 0x19, 0xe7, 0x18, 0x0, 0x0, 0x6a, 0x68, 0x27, 0x0, 0x0, 0xb, 0x8, 0x19, 0x71, + 0x1, 0x47, 0x1c, 0x0, 0x7, 0x21, 0x34, 0x18, 0xf1, 0x8e, 0xb5, 0x6a, 0x18, 0x0, 0x0, 0x6e, 0xe9, + 0x1a, 0x0, 0x4, 0x28, 0xae, 0xbc, 0x65, 0x27, 0x0, 0x0, 0x3a, 0xe7, 0x94, 0x86, 0xb9, 0xd5, 0xb8, + 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4808,70 +4914,105 @@ TEST(Publish5QCTest, Decode27) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xff, 0x8a, 0xa0, 0xe, 0x7d, 0x91, 0xe7, 0x3d, 0x9a, 0xf1, 0x69, - 0x52, 0xdb, 0x1c, 0x97, 0xf0, 0x7d, 0x42, 0x8d, 0x28, 0xd6}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf9, 0x90, 0x37, 0x20, 0x2c, 0x12, 0xd8, 0x92, 0x72, - 0x9b, 0xa1, 0xe0, 0x6c, 0xee, 0xa5, 0x1c, 0xf5}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x90, 0xa7, 0x82, 0xb3, 0x41}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, + 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10836); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\203\137\174H\204\220\160\&8\f+bXR\239\199\DC1\186\254\249\218\179y\210~\185\250\166\248", _pubPktID = 0, _pubBody = -// "\136\142{\DC4\\\154]/:\184\246N\DC28\204\&2C\f@\172\199\237\162)]W\186\180", _pubProps = [PropSubscriptionIdentifier -// 28,PropReasonString "m\SYN\215N\147a\164B~\157\176\&0",PropSharedSubscriptionAvailable -// 155,PropSubscriptionIdentifierAvailable 52,PropAuthenticationData "r\222\DC3\173eK\183\198`",PropContentType -// "9\231\244\219k\246o",PropTopicAlias 25947,PropReasonString -// "\197\240\246\183\239\187\195\DC2\195\132xh^/\189\DC1\165\221\158"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\187\249\143~(e\135", _pubProps = [PropSubscriptionIdentifier 20,PropUserProperty +// "\147\196\GS\178\rB9Y\145\CAN\135\233\179\rW\206" "\153\161\SUB\158\183;\192\CAN\US",PropAuthenticationData +// "",PropPayloadFormatIndicator 50,PropCorrelationData +// "P\SUB\136\&8\132\234f\SUB\196\232\&0\134\192\160\ETXB@\205\&4b\232\129\218~",PropReceiveMaximum 18515,PropMaximumQoS +// 108,PropTopicAliasMaximum 19988,PropRetainAvailable 87,PropMessageExpiryInterval 13619,PropSessionExpiryInterval +// 14566,PropAuthenticationMethod +// "\SO\222\190\199\&2\241*\185[\130\253%\255B1\131FP\163S\179\SUB\182\180\138\CAN\169",PropResponseTopic +// "\251\240\vp>\CAN,97\189!o\f\148\231",PropSubscriptionIdentifier 18,PropMessageExpiryInterval 21618,PropContentType +// "\172\211&\ESC\156\DEL\218\242\254\150Z\133\165\165\NAK,\182\STX\151H",PropServerReference +// "\220\DC2_\200\153`\227\190\NUL\188\216\143\DC1\214\135\CAN",PropReasonString +// "\130\DC3\149\&9\215\245\254",PropMaximumPacketSize 4301,PropAuthenticationData "\FS?",PropMaximumPacketSize +// 16401,PropRetainAvailable 43,PropServerReference "\"Uz\195\199B\176\226\187\CAN4\186\189\163"]} TEST(Publish5QCTest, Encode28) { - uint8_t pkt[] = {0x38, 0x7f, 0x0, 0x1c, 0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, - 0xef, 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8, 0x44, 0xb, - 0x1c, 0x1f, 0x0, 0xc, 0x6d, 0x16, 0xd7, 0x4e, 0x93, 0x61, 0xa4, 0x42, 0x7e, 0x9d, 0xb0, 0x30, 0x2a, - 0x9b, 0x29, 0x34, 0x16, 0x0, 0x9, 0x72, 0xde, 0x13, 0xad, 0x65, 0x4b, 0xb7, 0xc6, 0x60, 0x3, 0x0, - 0x7, 0x39, 0xe7, 0xf4, 0xdb, 0x6b, 0xf6, 0x6f, 0x23, 0x65, 0x5b, 0x1f, 0x0, 0x13, 0xc5, 0xf0, 0xf6, - 0xb7, 0xef, 0xbb, 0xc3, 0x12, 0xc3, 0x84, 0x78, 0x68, 0x5e, 0x2f, 0xbd, 0x11, 0xa5, 0xdd, 0x9e, 0x88, - 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, 0xcc, 0x32, 0x43, 0xc, - 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; - uint8_t topic_bytes[] = {0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, 0xef, - 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x39, 0xec, 0x1, 0x0, 0x0, 0xe1, 0x1, 0xb, 0x14, 0x26, 0x0, 0x10, 0x93, 0xc4, 0x1d, 0xb2, 0xd, 0x42, 0x39, + 0x59, 0x91, 0x18, 0x87, 0xe9, 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 0x25, 0x2b, 0x1c, 0x0, 0xe, 0x22, 0x55, 0x7a, 0xc3, 0xc7, 0x42, 0xb0, 0xe2, 0xbb, 0x18, + 0x34, 0xba, 0xbd, 0xa3, 0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, - 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; + msg.retained = true; + uint8_t msg_bytes[] = {0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 7; - uint8_t bytesprops0[] = {0x6d, 0x16, 0xd7, 0x4e, 0x93, 0x61, 0xa4, 0x42, 0x7e, 0x9d, 0xb0, 0x30}; - uint8_t bytesprops1[] = {0x72, 0xde, 0x13, 0xad, 0x65, 0x4b, 0xb7, 0xc6, 0x60}; - uint8_t bytesprops2[] = {0x39, 0xe7, 0xf4, 0xdb, 0x6b, 0xf6, 0x6f}; - uint8_t bytesprops3[] = {0xc5, 0xf0, 0xf6, 0xb7, 0xef, 0xbb, 0xc3, 0x12, 0xc3, 0x84, - 0x78, 0x68, 0x5e, 0x2f, 0xbd, 0x11, 0xa5, 0xdd, 0x9e}; + uint8_t bytesprops1[] = {0x99, 0xa1, 0x1a, 0x9e, 0xb7, 0x3b, 0xc0, 0x18, 0x1f}; + uint8_t bytesprops0[] = {0x93, 0xc4, 0x1d, 0xb2, 0xd, 0x42, 0x39, 0x59, + 0x91, 0x18, 0x87, 0xe9, 0xb3, 0xd, 0x57, 0xce}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x50, 0x1a, 0x88, 0x38, 0x84, 0xea, 0x66, 0x1a, 0xc4, 0xe8, 0x30, 0x86, + 0xc0, 0xa0, 0x3, 0x42, 0x40, 0xcd, 0x34, 0x62, 0xe8, 0x81, 0xda, 0x7e}; + uint8_t bytesprops4[] = {0xe, 0xde, 0xbe, 0xc7, 0x32, 0xf1, 0x2a, 0xb9, 0x5b, 0x82, 0xfd, 0x25, 0xff, 0x42, + 0x31, 0x83, 0x46, 0x50, 0xa3, 0x53, 0xb3, 0x1a, 0xb6, 0xb4, 0x8a, 0x18, 0xa9}; + uint8_t bytesprops5[] = {0xfb, 0xf0, 0xb, 0x70, 0x3e, 0x18, 0x2c, 0x39, 0x37, 0xbd, 0x21, 0x6f, 0xc, 0x94, 0xe7}; + uint8_t bytesprops6[] = {0xac, 0xd3, 0x26, 0x1b, 0x9c, 0x7f, 0xda, 0xf2, 0xfe, 0x96, + 0x5a, 0x85, 0xa5, 0xa5, 0x15, 0x2c, 0xb6, 0x2, 0x97, 0x48}; + uint8_t bytesprops7[] = {0xdc, 0x12, 0x5f, 0xc8, 0x99, 0x60, 0xe3, 0xbe, + 0x0, 0xbc, 0xd8, 0x8f, 0x11, 0xd6, 0x87, 0x18}; + uint8_t bytesprops8[] = {0x82, 0x13, 0x95, 0x39, 0xd7, 0xf5, 0xfe}; + uint8_t bytesprops9[] = {0x1c, 0x3f}; + uint8_t bytesprops10[] = {0x22, 0x55, 0x7a, 0xc3, 0xc7, 0x42, 0xb0, 0xe2, 0xbb, 0x18, 0x34, 0xba, 0xbd, 0xa3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25947}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops0}, .v = {9, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18515}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19988}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13619}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14566}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21618}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4301}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16401}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); @@ -4879,22 +5020,34 @@ TEST(Publish5QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\203\137\174H\204\220\160\&8\f+bXR\239\199\DC1\186\254\249\218\179y\210~\185\250\166\248", _pubPktID = 0, _pubBody = -// "\136\142{\DC4\\\154]/:\184\246N\DC28\204\&2C\f@\172\199\237\162)]W\186\180", _pubProps = [PropSubscriptionIdentifier -// 28,PropReasonString "m\SYN\215N\147a\164B~\157\176\&0",PropSharedSubscriptionAvailable -// 155,PropSubscriptionIdentifierAvailable 52,PropAuthenticationData "r\222\DC3\173eK\183\198`",PropContentType -// "9\231\244\219k\246o",PropTopicAlias 25947,PropReasonString -// "\197\240\246\183\239\187\195\DC2\195\132xh^/\189\DC1\165\221\158"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\187\249\143~(e\135", _pubProps = [PropSubscriptionIdentifier 20,PropUserProperty +// "\147\196\GS\178\rB9Y\145\CAN\135\233\179\rW\206" "\153\161\SUB\158\183;\192\CAN\US",PropAuthenticationData +// "",PropPayloadFormatIndicator 50,PropCorrelationData +// "P\SUB\136\&8\132\234f\SUB\196\232\&0\134\192\160\ETXB@\205\&4b\232\129\218~",PropReceiveMaximum 18515,PropMaximumQoS +// 108,PropTopicAliasMaximum 19988,PropRetainAvailable 87,PropMessageExpiryInterval 13619,PropSessionExpiryInterval +// 14566,PropAuthenticationMethod +// "\SO\222\190\199\&2\241*\185[\130\253%\255B1\131FP\163S\179\SUB\182\180\138\CAN\169",PropResponseTopic +// "\251\240\vp>\CAN,97\189!o\f\148\231",PropSubscriptionIdentifier 18,PropMessageExpiryInterval 21618,PropContentType +// "\172\211&\ESC\156\DEL\218\242\254\150Z\133\165\165\NAK,\182\STX\151H",PropServerReference +// "\220\DC2_\200\153`\227\190\NUL\188\216\143\DC1\214\135\CAN",PropReasonString +// "\130\DC3\149\&9\215\245\254",PropMaximumPacketSize 4301,PropAuthenticationData "\FS?",PropMaximumPacketSize +// 16401,PropRetainAvailable 43,PropServerReference "\"Uz\195\199B\176\226\187\CAN4\186\189\163"]} TEST(Publish5QCTest, Decode28) { - uint8_t pkt[] = {0x38, 0x7f, 0x0, 0x1c, 0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, - 0xef, 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8, 0x44, 0xb, - 0x1c, 0x1f, 0x0, 0xc, 0x6d, 0x16, 0xd7, 0x4e, 0x93, 0x61, 0xa4, 0x42, 0x7e, 0x9d, 0xb0, 0x30, 0x2a, - 0x9b, 0x29, 0x34, 0x16, 0x0, 0x9, 0x72, 0xde, 0x13, 0xad, 0x65, 0x4b, 0xb7, 0xc6, 0x60, 0x3, 0x0, - 0x7, 0x39, 0xe7, 0xf4, 0xdb, 0x6b, 0xf6, 0x6f, 0x23, 0x65, 0x5b, 0x1f, 0x0, 0x13, 0xc5, 0xf0, 0xf6, - 0xb7, 0xef, 0xbb, 0xc3, 0x12, 0xc3, 0x84, 0x78, 0x68, 0x5e, 0x2f, 0xbd, 0x11, 0xa5, 0xdd, 0x9e, 0x88, - 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, 0xcc, 0x32, 0x43, 0xc, - 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; + uint8_t pkt[] = { + 0x39, 0xec, 0x1, 0x0, 0x0, 0xe1, 0x1, 0xb, 0x14, 0x26, 0x0, 0x10, 0x93, 0xc4, 0x1d, 0xb2, 0xd, 0x42, 0x39, + 0x59, 0x91, 0x18, 0x87, 0xe9, 0xb3, 0xd, 0x57, 0xce, 0x0, 0x9, 0x99, 0xa1, 0x1a, 0x9e, 0xb7, 0x3b, 0xc0, 0x18, + 0x1f, 0x16, 0x0, 0x0, 0x1, 0x32, 0x9, 0x0, 0x18, 0x50, 0x1a, 0x88, 0x38, 0x84, 0xea, 0x66, 0x1a, 0xc4, 0xe8, + 0x30, 0x86, 0xc0, 0xa0, 0x3, 0x42, 0x40, 0xcd, 0x34, 0x62, 0xe8, 0x81, 0xda, 0x7e, 0x21, 0x48, 0x53, 0x24, 0x6c, + 0x22, 0x4e, 0x14, 0x25, 0x57, 0x2, 0x0, 0x0, 0x35, 0x33, 0x11, 0x0, 0x0, 0x38, 0xe6, 0x15, 0x0, 0x1b, 0xe, + 0xde, 0xbe, 0xc7, 0x32, 0xf1, 0x2a, 0xb9, 0x5b, 0x82, 0xfd, 0x25, 0xff, 0x42, 0x31, 0x83, 0x46, 0x50, 0xa3, 0x53, + 0xb3, 0x1a, 0xb6, 0xb4, 0x8a, 0x18, 0xa9, 0x8, 0x0, 0xf, 0xfb, 0xf0, 0xb, 0x70, 0x3e, 0x18, 0x2c, 0x39, 0x37, + 0xbd, 0x21, 0x6f, 0xc, 0x94, 0xe7, 0xb, 0x12, 0x2, 0x0, 0x0, 0x54, 0x72, 0x3, 0x0, 0x14, 0xac, 0xd3, 0x26, + 0x1b, 0x9c, 0x7f, 0xda, 0xf2, 0xfe, 0x96, 0x5a, 0x85, 0xa5, 0xa5, 0x15, 0x2c, 0xb6, 0x2, 0x97, 0x48, 0x1c, 0x0, + 0x10, 0xdc, 0x12, 0x5f, 0xc8, 0x99, 0x60, 0xe3, 0xbe, 0x0, 0xbc, 0xd8, 0x8f, 0x11, 0xd6, 0x87, 0x18, 0x1f, 0x0, + 0x7, 0x82, 0x13, 0x95, 0x39, 0xd7, 0xf5, 0xfe, 0x27, 0x0, 0x0, 0x10, 0xcd, 0x16, 0x0, 0x2, 0x1c, 0x3f, 0x27, + 0x0, 0x0, 0x40, 0x11, 0x25, 0x2b, 0x1c, 0x0, 0xe, 0x22, 0x55, 0x7a, 0xc3, 0xc7, 0x42, 0xb0, 0xe2, 0xbb, 0x18, + 0x34, 0xba, 0xbd, 0xa3, 0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4903,69 +5056,137 @@ TEST(Publish5QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xcb, 0x89, 0xae, 0x48, 0xcc, 0xdc, 0xa0, 0x38, 0xc, 0x2b, 0x62, 0x58, 0x52, 0xef, - 0xc7, 0x11, 0xba, 0xfe, 0xf9, 0xda, 0xb3, 0x79, 0xd2, 0x7e, 0xb9, 0xfa, 0xa6, 0xf8}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x88, 0x8e, 0x7b, 0x14, 0x5c, 0x9a, 0x5d, 0x2f, 0x3a, 0xb8, 0xf6, 0x4e, 0x12, 0x38, - 0xcc, 0x32, 0x43, 0xc, 0x40, 0xac, 0xc7, 0xed, 0xa2, 0x29, 0x5d, 0x57, 0xba, 0xb4}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "dU\158\136\251\148W][8D\138i\232?$", -// _pubPktID = 0, _pubBody = "'\136\162\SO\255\RS\205q\229\ACK\148\ETX\129rJ\DC2Y3\165a11\180\247", _pubProps = -// [PropMaximumQoS 247,PropReasonString "\151\235j!\157\NAK",PropSessionExpiryInterval 15510,PropServerKeepAlive 23576]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "h\137\169\166b`\193\RS\133\235I\188\167\&9\DC1\161uN\176\SOf\ACK-O\194\vo", _pubPktID = 7918, _pubBody = +// "G\142\SYN\154\171\162\185\ENQg\129\240\186 \199\202{\CAN\233\v^\170", _pubProps = [PropSubscriptionIdentifier +// 18,PropMessageExpiryInterval 2493,PropSessionExpiryInterval 20854,PropResponseTopic +// "\t\132-\200\130\192\134\236\159\SOH~\253\143\138\GS\185!)j\144\239{\n\134\188",PropSharedSubscriptionAvailable +// 152,PropCorrelationData "\EM%8\187\233Y\200\164\219.GZ#\153\183\&6\143\239\243\147\224",PropAssignedClientIdentifier +// "k",PropSubscriptionIdentifierAvailable 36,PropWildcardSubscriptionAvailable 46,PropTopicAliasMaximum +// 7511,PropAuthenticationData "\184\174\234\255\250\US6\STX\131\180\DC1\237&\152*:\247",PropResponseTopic +// "\183\SUB\180\189\164\RS/q\223\236\207b\162\251D\SYN",PropResponseInformation "",PropRequestProblemInformation +// 120,PropAuthenticationMethod "^\206'R\156",PropUserProperty "\222u\CAN\221!\202\131\129S/v\146U" +// "=UHL\166\246C\150\167\157\CAN\155\141M+T\203\238\170|",PropUserProperty "" +// "D/z\167\SO\145\170\157?sY\207I\132(4d\206!&?o;\130",PropSubscriptionIdentifier 26]} TEST(Publish5QCTest, Encode29) { - uint8_t pkt[] = {0x39, 0x3e, 0x0, 0x10, 0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, 0x5b, 0x38, 0x44, 0x8a, - 0x69, 0xe8, 0x3f, 0x24, 0x13, 0x24, 0xf7, 0x1f, 0x0, 0x6, 0x97, 0xeb, 0x6a, 0x21, 0x9d, 0x15, - 0x11, 0x0, 0x0, 0x3c, 0x96, 0x13, 0x5c, 0x18, 0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, - 0xe5, 0x6, 0x94, 0x3, 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; - uint8_t topic_bytes[] = {0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, - 0x5b, 0x38, 0x44, 0x8a, 0x69, 0xe8, 0x3f, 0x24}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x3a, 0xfc, 0x1, 0x0, 0x1b, 0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, + 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0xc2, 0xb, 0x6f, 0x1e, 0xee, 0xc6, 0x1, 0xb,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xce, 0x21, 0x26, + 0x3f, 0x6f, 0x3b, 0x82, 0xb, 0x1a, 0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, 0xba, 0x20, + 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; + uint8_t topic_bytes[] = {0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, + 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0xc2, 0xb, 0x6f}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, 0x94, 0x3, - 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, + 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 21; - uint8_t bytesprops0[] = {0x97, 0xeb, 0x6a, 0x21, 0x9d, 0x15}; + uint8_t bytesprops0[] = {0x9, 0x84, 0x2d, 0xc8, 0x82, 0xc0, 0x86, 0xec, 0x9f, 0x1, 0x7e, 0xfd, 0x8f, + 0x8a, 0x1d, 0xb9, 0x21, 0x29, 0x6a, 0x90, 0xef, 0x7b, 0xa, 0x86, 0xbc}; + uint8_t bytesprops1[] = {0x19, 0x25, 0x38, 0xbb, 0xe9, 0x59, 0xc8, 0xa4, 0xdb, 0x2e, 0x47, + 0x5a, 0x23, 0x99, 0xb7, 0x36, 0x8f, 0xef, 0xf3, 0x93, 0xe0}; + uint8_t bytesprops2[] = {0x6b}; + uint8_t bytesprops3[] = {0xb8, 0xae, 0xea, 0xff, 0xfa, 0x1f, 0x36, 0x2, 0x83, + 0xb4, 0x11, 0xed, 0x26, 0x98, 0x2a, 0x3a, 0xf7}; + uint8_t bytesprops4[] = {0xb7, 0x1a, 0xb4, 0xbd, 0xa4, 0x1e, 0x2f, 0x71, + 0xdf, 0xec, 0xcf, 0x62, 0xa2, 0xfb, 0x44, 0x16}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0x5e, 0xce, 0x27, 0x52, 0x9c}; + uint8_t bytesprops8[] = {0x3d, 0x55, 0x48, 0x4c, 0xa6, 0xf6, 0x43, 0x96, 0xa7, 0x9d, + 0x18, 0x9b, 0x8d, 0x4d, 0x2b, 0x54, 0xcb, 0xee, 0xaa, 0x7c}; + uint8_t bytesprops7[] = {0xde, 0x75, 0x18, 0xdd, 0x21, 0xca, 0x83, 0x81, 0x53, 0x2f, 0x76, 0x92, 0x55}; + uint8_t bytesprops10[] = {0x44, 0x2f, 0x7a, 0xa7, 0xe, 0x91, 0xaa, 0x9d, 0x3f, 0x73, 0x59, 0xcf, + 0x49, 0x84, 0x28, 0x34, 0x64, 0xce, 0x21, 0x26, 0x3f, 0x6f, 0x3b, 0x82}; + uint8_t bytesprops9[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15510}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23576}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2493}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20854}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7511}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops7}, .v = {20, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops9}, .v = {24, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7918, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "dU\158\136\251\148W][8D\138i\232?$", -// _pubPktID = 0, _pubBody = "'\136\162\SO\255\RS\205q\229\ACK\148\ETX\129rJ\DC2Y3\165a11\180\247", _pubProps = -// [PropMaximumQoS 247,PropReasonString "\151\235j!\157\NAK",PropSessionExpiryInterval 15510,PropServerKeepAlive 23576]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "h\137\169\166b`\193\RS\133\235I\188\167\&9\DC1\161uN\176\SOf\ACK-O\194\vo", _pubPktID = 7918, _pubBody = +// "G\142\SYN\154\171\162\185\ENQg\129\240\186 \199\202{\CAN\233\v^\170", _pubProps = [PropSubscriptionIdentifier +// 18,PropMessageExpiryInterval 2493,PropSessionExpiryInterval 20854,PropResponseTopic +// "\t\132-\200\130\192\134\236\159\SOH~\253\143\138\GS\185!)j\144\239{\n\134\188",PropSharedSubscriptionAvailable +// 152,PropCorrelationData "\EM%8\187\233Y\200\164\219.GZ#\153\183\&6\143\239\243\147\224",PropAssignedClientIdentifier +// "k",PropSubscriptionIdentifierAvailable 36,PropWildcardSubscriptionAvailable 46,PropTopicAliasMaximum +// 7511,PropAuthenticationData "\184\174\234\255\250\US6\STX\131\180\DC1\237&\152*:\247",PropResponseTopic +// "\183\SUB\180\189\164\RS/q\223\236\207b\162\251D\SYN",PropResponseInformation "",PropRequestProblemInformation +// 120,PropAuthenticationMethod "^\206'R\156",PropUserProperty "\222u\CAN\221!\202\131\129S/v\146U" +// "=UHL\166\246C\150\167\157\CAN\155\141M+T\203\238\170|",PropUserProperty "" +// "D/z\167\SO\145\170\157?sY\207I\132(4d\206!&?o;\130",PropSubscriptionIdentifier 26]} TEST(Publish5QCTest, Decode29) { - uint8_t pkt[] = {0x39, 0x3e, 0x0, 0x10, 0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, 0x5b, 0x38, 0x44, 0x8a, - 0x69, 0xe8, 0x3f, 0x24, 0x13, 0x24, 0xf7, 0x1f, 0x0, 0x6, 0x97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x62, 0xa2, 0xfb, 0x44, 0x16, + 0x1a, 0x0, 0x0, 0x17, 0x78, 0x15, 0x0, 0x5, 0x5e, 0xce, 0x27, 0x52, 0x9c, 0x26, 0x0, 0xd, 0xde, 0x75, 0x18, + 0xdd, 0x21, 0xca, 0x83, 0x81, 0x53, 0x2f, 0x76, 0x92, 0x55, 0x0, 0x14, 0x3d, 0x55, 0x48, 0x4c, 0xa6, 0xf6, 0x43, + 0x96, 0xa7, 0x9d, 0x18, 0x9b, 0x8d, 0x4d, 0x2b, 0x54, 0xcb, 0xee, 0xaa, 0x7c, 0x26, 0x0, 0x0, 0x0, 0x18, 0x44, + 0x2f, 0x7a, 0xa7, 0xe, 0x91, 0xaa, 0x9d, 0x3f, 0x73, 0x59, 0xcf, 0x49, 0x84, 0x28, 0x34, 0x64, 0xce, 0x21, 0x26, + 0x3f, 0x6f, 0x3b, 0x82, 0xb, 0x1a, 0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, 0xba, 0x20, + 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4974,94 +5195,63 @@ TEST(Publish5QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x64, 0x55, 0x9e, 0x88, 0xfb, 0x94, 0x57, 0x5d, - 0x5b, 0x38, 0x44, 0x8a, 0x69, 0xe8, 0x3f, 0x24}; - lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x27, 0x88, 0xa2, 0xe, 0xff, 0x1e, 0xcd, 0x71, 0xe5, 0x6, 0x94, 0x3, - 0x81, 0x72, 0x4a, 0x12, 0x59, 0x33, 0xa5, 0x61, 0x31, 0x31, 0xb4, 0xf7}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, + 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0xc2, 0xb, 0x6f}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, + 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7918); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\173\207\249\USrJ\214L\ENQAT\140JUG\ESC\FS\165\202\218\206\DEL\142\250'\167s\139", _pubPktID = 24516, _pubBody = "", -// _pubProps = [PropSubscriptionIdentifier 20,PropCorrelationData -// ";UtP!\fs\v\200\159\NAK\"\FS\184\201",PropRequestProblemInformation 5,PropMaximumQoS 209,PropResponseTopic -// "\224\&1/V?\246\&7c\137\&3G|\144\227\176\&8\250FzsMB",PropUserProperty "\SYN7\221\STXW\189" -// "Hi\178\129\\\162\&4U\CAN\167'\172\223l?\250",PropRequestProblemInformation 166,PropMessageExpiryInterval -// 30177,PropRetainAvailable 132]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "k\r\250c\140\225\149\144@\133", +// _pubPktID = 0, _pubBody = "',/I\RSD\195\229\202", _pubProps = [PropResponseInformation +// "gd\181",PropMessageExpiryInterval 12250]} TEST(Publish5QCTest, Encode30) { - uint8_t pkt[] = {0x3d, 0x76, 0x0, 0x1c, 0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, - 0x8c, 0x4a, 0x55, 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, - 0x73, 0x8b, 0x5f, 0xc4, 0x55, 0xb, 0x14, 0x9, 0x0, 0xf, 0x3b, 0x55, 0x74, 0x50, 0x21, - 0xc, 0x73, 0xb, 0xc8, 0x9f, 0x15, 0x22, 0x1c, 0xb8, 0xc9, 0x17, 0x5, 0x24, 0xd1, 0x8, - 0x0, 0x16, 0xe0, 0x31, 0x2f, 0x56, 0x3f, 0xf6, 0x37, 0x63, 0x89, 0x33, 0x47, 0x7c, 0x90, - 0xe3, 0xb0, 0x38, 0xfa, 0x46, 0x7a, 0x73, 0x4d, 0x42, 0x26, 0x0, 0x6, 0x16, 0x37, 0xdd, - 0x2, 0x57, 0xbd, 0x0, 0x10, 0x48, 0x69, 0xb2, 0x81, 0x5c, 0xa2, 0x34, 0x55, 0x18, 0xa7, - 0x27, 0xac, 0xdf, 0x6c, 0x3f, 0xfa, 0x17, 0xa6, 0x2, 0x0, 0x0, 0x75, 0xe1, 0x25, 0x84}; - uint8_t topic_bytes[] = {0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, - 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x21, 0x0, 0xa, 0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, + 0x40, 0x85, 0xb, 0x1a, 0x0, 0x3, 0x67, 0x64, 0xb5, 0x2, 0x0, 0x0, + 0x2f, 0xda, 0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; + uint8_t topic_bytes[] = {0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, 0x40, 0x85}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 9; - uint8_t bytesprops0[] = {0x3b, 0x55, 0x74, 0x50, 0x21, 0xc, 0x73, 0xb, 0xc8, 0x9f, 0x15, 0x22, 0x1c, 0xb8, 0xc9}; - uint8_t bytesprops1[] = {0xe0, 0x31, 0x2f, 0x56, 0x3f, 0xf6, 0x37, 0x63, 0x89, 0x33, 0x47, - 0x7c, 0x90, 0xe3, 0xb0, 0x38, 0xfa, 0x46, 0x7a, 0x73, 0x4d, 0x42}; - uint8_t bytesprops3[] = {0x48, 0x69, 0xb2, 0x81, 0x5c, 0xa2, 0x34, 0x55, - 0x18, 0xa7, 0x27, 0xac, 0xdf, 0x6c, 0x3f, 0xfa}; - uint8_t bytesprops2[] = {0x16, 0x37, 0xdd, 0x2, 0x57, 0xbd}; + uint8_t bytesprops0[] = {0x67, 0x64, 0xb5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 20}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops2}, .v = {16, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30177}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12250}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 24516, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\173\207\249\USrJ\214L\ENQAT\140JUG\ESC\FS\165\202\218\206\DEL\142\250'\167s\139", _pubPktID = 24516, _pubBody = "", -// _pubProps = [PropSubscriptionIdentifier 20,PropCorrelationData -// ";UtP!\fs\v\200\159\NAK\"\FS\184\201",PropRequestProblemInformation 5,PropMaximumQoS 209,PropResponseTopic -// "\224\&1/V?\246\&7c\137\&3G|\144\227\176\&8\250FzsMB",PropUserProperty "\SYN7\221\STXW\189" -// "Hi\178\129\\\162\&4U\CAN\167'\172\223l?\250",PropRequestProblemInformation 166,PropMessageExpiryInterval -// 30177,PropRetainAvailable 132]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "k\r\250c\140\225\149\144@\133", +// _pubPktID = 0, _pubBody = "',/I\RSD\195\229\202", _pubProps = [PropResponseInformation +// "gd\181",PropMessageExpiryInterval 12250]} TEST(Publish5QCTest, Decode30) { - uint8_t pkt[] = {0x3d, 0x76, 0x0, 0x1c, 0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, - 0x8c, 0x4a, 0x55, 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, - 0x73, 0x8b, 0x5f, 0xc4, 0x55, 0xb, 0x14, 0x9, 0x0, 0xf, 0x3b, 0x55, 0x74, 0x50, 0x21, - 0xc, 0x73, 0xb, 0xc8, 0x9f, 0x15, 0x22, 0x1c, 0xb8, 0xc9, 0x17, 0x5, 0x24, 0xd1, 0x8, - 0x0, 0x16, 0xe0, 0x31, 0x2f, 0x56, 0x3f, 0xf6, 0x37, 0x63, 0x89, 0x33, 0x47, 0x7c, 0x90, - 0xe3, 0xb0, 0x38, 0xfa, 0x46, 0x7a, 0x73, 0x4d, 0x42, 0x26, 0x0, 0x6, 0x16, 0x37, 0xdd, - 0x2, 0x57, 0xbd, 0x0, 0x10, 0x48, 0x69, 0xb2, 0x81, 0x5c, 0xa2, 0x34, 0x55, 0x18, 0xa7, - 0x27, 0xac, 0xdf, 0x6c, 0x3f, 0xfa, 0x17, 0xa6, 0x2, 0x0, 0x0, 0x75, 0xe1, 0x25, 0x84}; + uint8_t pkt[] = {0x30, 0x21, 0x0, 0xa, 0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, + 0x40, 0x85, 0xb, 0x1a, 0x0, 0x3, 0x67, 0x64, 0xb5, 0x2, 0x0, 0x0, + 0x2f, 0xda, 0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -5070,61 +5260,74 @@ TEST(Publish5QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xad, 0xcf, 0xf9, 0x1f, 0x72, 0x4a, 0xd6, 0x4c, 0x5, 0x41, 0x54, 0x8c, 0x4a, 0x55, - 0x47, 0x1b, 0x1c, 0xa5, 0xca, 0xda, 0xce, 0x7f, 0x8e, 0xfa, 0x27, 0xa7, 0x73, 0x8b}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 24516); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + uint8_t exp_topic_bytes[] = {0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, 0x40, 0x85}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// ConnectRequest {_username = Nothing, _password = Just "\DLEVW\161\173W!+\154\235\a\169\136(K\152\224\190I4y", -// _lastWill = Nothing, _cleanSession = True, _keepAlive = 3940, _connID = "\147b\SOH\234HL\237", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "\STX'd2\162\&8\201\179\247\166Y\212\\E\134\229", _willMsg = +// "\STX\227Q\213\190e/R\238\220$q\218Y~\146:~\ESCo\213\150\243\EM\156+r", _willProps = []}), _cleanSession = True, +// _keepAlive = 14707, _connID = "\r\239\133\224\t\138Z\SOHVQ\194n\b\"", _properties = []} TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x13, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0xf, - 0x64, 0x0, 0x7, 0x93, 0x62, 0x1, 0xea, 0x48, 0x4c, 0xed}; + uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x39, 0x73, 0x0, 0xe, 0xd, + 0xef, 0x85, 0xe0, 0x9, 0x8a, 0x5a, 0x1, 0x56, 0x51, 0xc2, 0x6e, 0x8, 0x22, 0x0, 0x10, + 0x2, 0x27, 0x64, 0x32, 0xa2, 0x38, 0xc9, 0xb3, 0xf7, 0xa6, 0x59, 0xd4, 0x5c, 0x45, 0x86, + 0xe5, 0x0, 0x1b, 0x2, 0xe3, 0x51, 0xd5, 0xbe, 0x65, 0x2f, 0x52, 0xee, 0xdc, 0x24, 0x71, + 0xda, 0x59, 0x7e, 0x92, 0x3a, 0x7e, 0x1b, 0x6f, 0xd5, 0x96, 0xf3, 0x19, 0x9c, 0x2b, 0x72}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2, 0x27, 0x64, 0x32, 0xa2, 0x38, 0xc9, 0xb3, + 0xf7, 0xa6, 0x59, 0xd4, 0x5c, 0x45, 0x86, 0xe5}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2, 0xe3, 0x51, 0xd5, 0xbe, 0x65, 0x2f, 0x52, 0xee, 0xdc, 0x24, 0x71, 0xda, 0x59, + 0x7e, 0x92, 0x3a, 0x7e, 0x1b, 0x6f, 0xd5, 0x96, 0xf3, 0x19, 0x9c, 0x2b, 0x72}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 3940; - uint8_t client_id_bytes[] = {0x93, 0x62, 0x1, 0xea, 0x48, 0x4c, 0xed}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.keep_alive = 14707; + uint8_t client_id_bytes[] = {0xd, 0xef, 0x85, 0xe0, 0x9, 0x8a, 0x5a, 0x1, 0x56, 0x51, 0xc2, 0x6e, 0x8, 0x22}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x10, 0x56, 0x57, 0xa1, 0xad, 0x57, 0x21, 0x2b, 0x9a, 0xeb, 0x7, - 0xa9, 0x88, 0x28, 0x4b, 0x98, 0xe0, 0xbe, 0x49, 0x34, 0x79}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\232f;/", _password = Just -// "T'\248\144\179\155V\209\NAK$l\134\169\165\244_\ACK\aa\US", _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS1, _willTopic = "h\165{\211B\214\169W\237", _willMsg = "", _willProps = []}), _cleanSession = False, _keepAlive -// = 13091, _connID = "k!a\t\182\181\230\207<\SUB\251\243b\250\216\131H", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\175\223\237\151\165\143\181\186", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\224\241\206\223", _willMsg = "<\185B\DC1", _willProps = []}), +// _cleanSession = True, _keepAlive = 12709, _connID = "qR&\218b\224.r|a\206\139\226\174(\216\EM\193", _properties = []} TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x33, 0x23, 0x0, 0x11, 0x6b, - 0x21, 0x61, 0x9, 0xb6, 0xb5, 0xe6, 0xcf, 0x3c, 0x1a, 0xfb, 0xf3, 0x62, 0xfa, 0xd8, 0x83, - 0x48, 0x0, 0x9, 0x68, 0xa5, 0x7b, 0xd3, 0x42, 0xd6, 0xa9, 0x57, 0xed, 0x0, 0x0, 0x0, - 0x4, 0xe8, 0x66, 0x3b, 0x2f, 0x0, 0x14, 0x54, 0x27, 0xf8, 0x90, 0xb3, 0x9b, 0x56, 0xd1, - 0x15, 0x24, 0x6c, 0x86, 0xa9, 0xa5, 0xf4, 0x5f, 0x6, 0x7, 0x61, 0x1f}; + uint8_t pkt[] = {0x10, 0x2a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x31, 0xa5, 0x0, 0x12, 0x71, + 0x52, 0x26, 0xda, 0x62, 0xe0, 0x2e, 0x72, 0x7c, 0x61, 0xce, 0x8b, 0xe2, 0xae, 0x28, 0xd8, + 0x19, 0xc1, 0x0, 0x4, 0xe0, 0xf1, 0xce, 0xdf, 0x0, 0x4, 0x3c, 0xb9, 0x42, 0x11}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5135,29 +5338,25 @@ TEST(Connect311QCTest, Encode2) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x68, 0xa5, 0x7b, 0xd3, 0x42, 0xd6, 0xa9, 0x57, 0xed}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xe0, 0xf1, 0xce, 0xdf}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3c, 0xb9, 0x42, 0x11}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 13091; - uint8_t client_id_bytes[] = {0x6b, 0x21, 0x61, 0x9, 0xb6, 0xb5, 0xe6, 0xcf, 0x3c, - 0x1a, 0xfb, 0xf3, 0x62, 0xfa, 0xd8, 0x83, 0x48}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 12709; + uint8_t client_id_bytes[] = {0x71, 0x52, 0x26, 0xda, 0x62, 0xe0, 0x2e, 0x72, 0x7c, + 0x61, 0xce, 0x8b, 0xe2, 0xae, 0x28, 0xd8, 0x19, 0xc1}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xe8, 0x66, 0x3b, 0x2f}; - lwmqtt_string_t username = {4, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x54, 0x27, 0xf8, 0x90, 0xb3, 0x9b, 0x56, 0xd1, 0x15, 0x24, - 0x6c, 0x86, 0xa9, 0xa5, 0xf4, 0x5f, 0x6, 0x7, 0x61, 0x1f}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xaf, 0xdf, 0xed, 0x97, 0xa5, 0x8f, 0xb5, 0xba}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5167,111 +5366,88 @@ TEST(Connect311QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\211\228\SUB\176\198\221", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS0, _willTopic = "xpj95\230\&1\225?", _willMsg = "\248", _willProps = []}), -// _cleanSession = True, _keepAlive = 2433, _connID = -// "\185\137\241\223?ec+\\U\r\DC1\GS\193\167\185\189\222`\151Q", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "\219\242^+:\f\EOT\173\175\&1\CAN\171\&8", _willMsg = +// "\172\220\161\161W~?%", _willProps = []}), _cleanSession = False, _keepAlive = 9252, _connID = +// "\175\167p\FS\238\ni\164\&3*\183\243\186\129\SO\153{\225\138\236\216\213${|P^\248\148\128", _properties = []} TEST(Connect311QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0x21, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x0, 0x77, 0x4b, - 0x0, 0x15, 0xe2, 0x5, 0xf4, 0xde, 0x49, 0x36, 0xd5, 0x6a, 0xca, 0x39, - 0xe6, 0xc6, 0xff, 0xad, 0x85, 0xef, 0x13, 0xe4, 0x86, 0xba, 0x5d}; + uint8_t pkt[] = {0x10, 0x70, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x24, 0x24, 0x0, 0x1e, 0xaf, 0xa7, 0x70, + 0x1c, 0xee, 0xa, 0x69, 0xa4, 0x33, 0x2a, 0xb7, 0xf3, 0xba, 0x81, 0xe, 0x99, 0x7b, 0xe1, 0x8a, 0xec, + 0xd8, 0xd5, 0x24, 0x7b, 0x7c, 0x50, 0x5e, 0xf8, 0x94, 0x80, 0x0, 0xd, 0xdb, 0xf2, 0x5e, 0x2b, 0x3a, + 0xc, 0x4, 0xad, 0xaf, 0x31, 0x18, 0xab, 0x38, 0x0, 0x8, 0xac, 0xdc, 0xa1, 0xa1, 0x57, 0x7e, 0x3f, + 0x25, 0x0, 0xf, 0x19, 0x9f, 0x19, 0x0, 0x14, 0x5c, 0x2c, 0x8c, 0x6d, 0x6d, 0x47, 0x6c, 0xa2, 0xbb, + 0xde, 0x0, 0x1a, 0x18, 0xf9, 0x92, 0x66, 0x48, 0x16, 0xa1, 0x1f, 0x9a, 0xad, 0xf3, 0xb1, 0xf0, 0xd4, + 0x6b, 0xcb, 0xdb, 0x3e, 0xc1, 0xa7, 0xb9, 0xbd, 0xde, 0x60, 0x97, 0x51}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xdb, 0xf2, 0x5e, 0x2b, 0x3a, 0xc, 0x4, 0xad, 0xaf, 0x31, 0x18, 0xab, 0x38}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xac, 0xdc, 0xa1, 0xa1, 0x57, 0x7e, 0x3f, 0x25}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 30539; - uint8_t client_id_bytes[] = {0xe2, 0x5, 0xf4, 0xde, 0x49, 0x36, 0xd5, 0x6a, 0xca, 0x39, 0xe6, - 0xc6, 0xff, 0xad, 0x85, 0xef, 0x13, 0xe4, 0x86, 0xba, 0x5d}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.keep_alive = 9252; + uint8_t client_id_bytes[] = {0xaf, 0xa7, 0x70, 0x1c, 0xee, 0xa, 0x69, 0xa4, 0x33, 0x2a, + 0xb7, 0xf3, 0xba, 0x81, 0xe, 0x99, 0x7b, 0xe1, 0x8a, 0xec, + 0xd8, 0xd5, 0x24, 0x7b, 0x7c, 0x50, 0x5e, 0xf8, 0x94, 0x80}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x69, 0xfa, 0x1c, 0xe3, 0x53}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x19, 0x9f, 0x19, 0x0, 0x14, 0x5c, 0x2c, 0x8c, 0x6d, 0x6d, 0x47, 0x6c, 0xa2, 0xbb, 0xde}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x18, 0xf9, 0x92, 0x66, 0x48, 0x16, 0xa1, 0x1f, 0x9a, 0xad, 0xf3, 0xb1, 0xf0, + 0xd4, 0x6b, 0xcb, 0xdb, 0x3e, 0xc1, 0xa7, 0xb9, 0xbd, 0xde, 0x60, 0x97, 0x51}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\225\203mIB\148\147s", _password = Nothing, _lastWill = Just (LastWill {_willRetain -// = False, _willQoS = QoS0, _willTopic = "`\SO\132\139\ESC\222W\198\STXb$", _willMsg = -// "j\225L%\SYN:R\144\143\244\201FZce\154\SO[\DC1\183\205\197\134J,\184", _willProps = []}), _cleanSession = False, -// _keepAlive = 14155, _connID = "\190I\DC1\187\DEL", _properties = []} +// ConnectRequest {_username = Just "\132Jc\237#\175s\149\208\140\v\175\198\197@bE\255\177&4\223%%\194\229\ETB", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "_B\130\238\164\ACK\246/\243\243\182\&9h\219Dp\161E\201n(\130u", _willMsg = +// "L\ETX\226\236\158\CAN3\190\221\140\156\129Mj\211\ACKv+\USU\197e\219\EM\135\221\145", _willProps = []}), +// _cleanSession = False, _keepAlive = 23111, _connID = +// "\128'\168\a\165\214u\"VvPa\154y\236\ETB\165ng\208\175\233\198\234\235\a", _properties = []} TEST(Connect311QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x84, 0x37, 0x4b, 0x0, 0x5, - 0xbe, 0x49, 0x11, 0xbb, 0x7f, 0x0, 0xb, 0x60, 0xe, 0x84, 0x8b, 0x1b, 0xde, 0x57, - 0xc6, 0x2, 0x62, 0x24, 0x0, 0x1a, 0x6a, 0xe1, 0x4c, 0x25, 0x16, 0x3a, 0x52, 0x90, - 0x8f, 0xf4, 0xc9, 0x46, 0x5a, 0x63, 0x65, 0x9a, 0xe, 0x5b, 0x11, 0xb7, 0xcd, 0xc5, - 0x86, 0x4a, 0x2c, 0xb8, 0x0, 0x8, 0xe1, 0xcb, 0x6d, 0x49, 0x42, 0x94, 0x93, 0x73}; + uint8_t pkt[] = {0x10, 0x79, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb4, 0x5a, 0x47, 0x0, 0x1a, 0x80, 0x27, + 0xa8, 0x7, 0xa5, 0xd6, 0x75, 0x22, 0x56, 0x76, 0x50, 0x61, 0x9a, 0x79, 0xec, 0x17, 0xa5, 0x6e, + 0x67, 0xd0, 0xaf, 0xe9, 0xc6, 0xea, 0xeb, 0x7, 0x0, 0x17, 0x5f, 0x42, 0x82, 0xee, 0xa4, 0x6, + 0xf6, 0x2f, 0xf3, 0xf3, 0xb6, 0x39, 0x68, 0xdb, 0x44, 0x70, 0xa1, 0x45, 0xc9, 0x6e, 0x28, 0x82, + 0x75, 0x0, 0x1b, 0x4c, 0x3, 0xe2, 0xec, 0x9e, 0x18, 0x33, 0xbe, 0xdd, 0x8c, 0x9c, 0x81, 0x4d, + 0x6a, 0xd3, 0x6, 0x76, 0x2b, 0x1f, 0x55, 0xc5, 0x65, 0xdb, 0x19, 0x87, 0xdd, 0x91, 0x0, 0x1b, + 0x84, 0x4a, 0x63, 0xed, 0x23, 0xaf, 0x73, 0x95, 0xd0, 0x8c, 0xb, 0xaf, 0xc6, 0xc5, 0x40, 0x62, + 0x45, 0xff, 0xb1, 0x26, 0x34, 0xdf, 0x25, 0x25, 0xc2, 0xe5, 0x17}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5412,25 +5623,28 @@ TEST(Connect311QCTest, Encode8) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x60, 0xe, 0x84, 0x8b, 0x1b, 0xde, 0x57, 0xc6, 0x2, 0x62, 0x24}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6a, 0xe1, 0x4c, 0x25, 0x16, 0x3a, 0x52, 0x90, 0x8f, 0xf4, 0xc9, 0x46, 0x5a, - 0x63, 0x65, 0x9a, 0xe, 0x5b, 0x11, 0xb7, 0xcd, 0xc5, 0x86, 0x4a, 0x2c, 0xb8}; - lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x5f, 0x42, 0x82, 0xee, 0xa4, 0x6, 0xf6, 0x2f, 0xf3, 0xf3, 0xb6, 0x39, + 0x68, 0xdb, 0x44, 0x70, 0xa1, 0x45, 0xc9, 0x6e, 0x28, 0x82, 0x75}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4c, 0x3, 0xe2, 0xec, 0x9e, 0x18, 0x33, 0xbe, 0xdd, 0x8c, 0x9c, 0x81, 0x4d, 0x6a, + 0xd3, 0x6, 0x76, 0x2b, 0x1f, 0x55, 0xc5, 0x65, 0xdb, 0x19, 0x87, 0xdd, 0x91}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS2; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 14155; - uint8_t client_id_bytes[] = {0xbe, 0x49, 0x11, 0xbb, 0x7f}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.keep_alive = 23111; + uint8_t client_id_bytes[] = {0x80, 0x27, 0xa8, 0x7, 0xa5, 0xd6, 0x75, 0x22, 0x56, 0x76, 0x50, 0x61, 0x9a, + 0x79, 0xec, 0x17, 0xa5, 0x6e, 0x67, 0xd0, 0xaf, 0xe9, 0xc6, 0xea, 0xeb, 0x7}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xe1, 0xcb, 0x6d, 0x49, 0x42, 0x94, 0x93, 0x73}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x84, 0x4a, 0x63, 0xed, 0x23, 0xaf, 0x73, 0x95, 0xd0, 0x8c, 0xb, 0xaf, 0xc6, 0xc5, + 0x40, 0x62, 0x45, 0xff, 0xb1, 0x26, 0x34, 0xdf, 0x25, 0x25, 0xc2, 0xe5, 0x17}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5440,20 +5654,14 @@ TEST(Connect311QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\bA\DC1\DEL\213g\EMC\130^", _password = Just -// "\188\164\213\\P1\226\188\191\201\185\135\150z\216\157\DC4", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS1, _willTopic = "\171C0\171", _willMsg = -// "6\164j\195\226\206\EOT\186\FS?\207\245\154\164\223jR\224#2sJ\165N\145#H\196\159\146", _willProps = []}), -// _cleanSession = True, _keepAlive = 29647, _connID = "\176\248\150\&5VEy\GS\DC1kSt(`\136\SUB\233\233\156\174\213", -// _properties = []} +// ConnectRequest {_username = Just "\131)o", _password = Just "Y^ \171\220\234\182Th\NAK", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\SOHw\DC4\149\&5\197\t\RS\188\166\DLE\179", _willMsg = +// "L\173#e?~\241<", _willProps = []}), _cleanSession = False, _keepAlive = 15628, _connID = "\238", _properties = []} TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x66, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x73, 0xcf, 0x0, 0x15, 0xb0, - 0xf8, 0x96, 0x35, 0x56, 0x45, 0x79, 0x1d, 0x11, 0x6b, 0x53, 0x74, 0x28, 0x60, 0x88, 0x1a, - 0xe9, 0xe9, 0x9c, 0xae, 0xd5, 0x0, 0x4, 0xab, 0x43, 0x30, 0xab, 0x0, 0x1e, 0x36, 0xa4, - 0x6a, 0xc3, 0xe2, 0xce, 0x4, 0xba, 0x1c, 0x3f, 0xcf, 0xf5, 0x9a, 0xa4, 0xdf, 0x6a, 0x52, - 0xe0, 0x23, 0x32, 0x73, 0x4a, 0xa5, 0x4e, 0x91, 0x23, 0x48, 0xc4, 0x9f, 0x92, 0x0, 0xa, - 0x8, 0x41, 0x11, 0x7f, 0xd5, 0x67, 0x19, 0x43, 0x82, 0x5e, 0x0, 0x11, 0xbc, 0xa4, 0xd5, - 0x5c, 0x50, 0x31, 0xe2, 0xbc, 0xbf, 0xc9, 0xb9, 0x87, 0x96, 0x7a, 0xd8, 0x9d, 0x14}; + uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x3d, 0xc, 0x0, 0x1, + 0xee, 0x0, 0xc, 0x1, 0x77, 0x14, 0x95, 0x35, 0xc5, 0x9, 0x1e, 0xbc, 0xa6, 0x10, + 0xb3, 0x0, 0x8, 0x4c, 0xad, 0x23, 0x65, 0x3f, 0x7e, 0xf1, 0x3c, 0x0, 0x3, 0x83, + 0x29, 0x6f, 0x0, 0xa, 0x59, 0x5e, 0x20, 0xab, 0xdc, 0xea, 0xb6, 0x54, 0x68, 0x15}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5464,12 +5672,10 @@ TEST(Connect311QCTest, Encode9) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xab, 0x43, 0x30, 0xab}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x36, 0xa4, 0x6a, 0xc3, 0xe2, 0xce, 0x4, 0xba, 0x1c, 0x3f, - 0xcf, 0xf5, 0x9a, 0xa4, 0xdf, 0x6a, 0x52, 0xe0, 0x23, 0x32, - 0x73, 0x4a, 0xa5, 0x4e, 0x91, 0x23, 0x48, 0xc4, 0x9f, 0x92}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x1, 0x77, 0x14, 0x95, 0x35, 0xc5, 0x9, 0x1e, 0xbc, 0xa6, 0x10, 0xb3}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4c, 0xad, 0x23, 0x65, 0x3f, 0x7e, 0xf1, 0x3c}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -5477,18 +5683,16 @@ TEST(Connect311QCTest, Encode9) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 29647; - uint8_t client_id_bytes[] = {0xb0, 0xf8, 0x96, 0x35, 0x56, 0x45, 0x79, 0x1d, 0x11, 0x6b, 0x53, - 0x74, 0x28, 0x60, 0x88, 0x1a, 0xe9, 0xe9, 0x9c, 0xae, 0xd5}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 15628; + uint8_t client_id_bytes[] = {0xee}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x8, 0x41, 0x11, 0x7f, 0xd5, 0x67, 0x19, 0x43, 0x82, 0x5e}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x83, 0x29, 0x6f}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xbc, 0xa4, 0xd5, 0x5c, 0x50, 0x31, 0xe2, 0xbc, 0xbf, - 0xc9, 0xb9, 0x87, 0x96, 0x7a, 0xd8, 0x9d, 0x14}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x59, 0x5e, 0x20, 0xab, 0xdc, 0xea, 0xb6, 0x54, 0x68, 0x15}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5498,13 +5702,17 @@ TEST(Connect311QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\240\ETX\187\240'\219\214:\CANw", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\137\169\150c", _willMsg = "\189", _willProps = []}), -// _cleanSession = False, _keepAlive = 19444, _connID = "\151\173\128\254\189>\225\168\184@\169\179", _properties = []} +// ConnectRequest {_username = Just "\176mX\224\177{+\ENQ\221\228\184\181\192 \NUL\201\128\209", _password = Just +// "\215Dco.`\RSl\219\136A\134Z}X\247\&5HG\ETX", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, +// _willTopic = "\242 xK\204\160x\221\169\240", _willMsg = "\220\ACKG", _willProps = []}), _cleanSession = True, +// _keepAlive = 19143, _connID = "\176/i\144P\218\&5\t\229;\221\246\DC2\"", _properties = []} TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x2d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8c, 0x4b, 0xf4, 0x0, 0xc, 0x97, 0xad, - 0x80, 0xfe, 0xbd, 0x3e, 0xe1, 0xa8, 0xb8, 0x40, 0xa9, 0xb3, 0x0, 0x4, 0x89, 0xa9, 0x96, 0x63, - 0x0, 0x1, 0xbd, 0x0, 0xa, 0xf0, 0x3, 0xbb, 0xf0, 0x27, 0xdb, 0xd6, 0x3a, 0x18, 0x77}; + uint8_t pkt[] = {0x10, 0x55, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x4a, 0xc7, 0x0, 0xe, 0xb0, + 0x2f, 0x69, 0x90, 0x50, 0xda, 0x35, 0x9, 0xe5, 0x3b, 0xdd, 0xf6, 0x12, 0x22, 0x0, 0xa, + 0xf2, 0x20, 0x78, 0x4b, 0xcc, 0xa0, 0x78, 0xdd, 0xa9, 0xf0, 0x0, 0x3, 0xdc, 0x6, 0x47, + 0x0, 0x12, 0xb0, 0x6d, 0x58, 0xe0, 0xb1, 0x7b, 0x2b, 0x5, 0xdd, 0xe4, 0xb8, 0xb5, 0xc0, + 0x20, 0x0, 0xc9, 0x80, 0xd1, 0x0, 0x14, 0xd7, 0x44, 0x63, 0x6f, 0x2e, 0x60, 0x1e, 0x6c, + 0xdb, 0x88, 0x41, 0x86, 0x5a, 0x7d, 0x58, 0xf7, 0x35, 0x48, 0x47, 0x3}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5515,25 +5723,30 @@ TEST(Connect311QCTest, Encode10) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x89, 0xa9, 0x96, 0x63}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbd}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xf2, 0x20, 0x78, 0x4b, 0xcc, 0xa0, 0x78, 0xdd, 0xa9, 0xf0}; + lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xdc, 0x6, 0x47}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19444; - uint8_t client_id_bytes[] = {0x97, 0xad, 0x80, 0xfe, 0xbd, 0x3e, 0xe1, 0xa8, 0xb8, 0x40, 0xa9, 0xb3}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 19143; + uint8_t client_id_bytes[] = {0xb0, 0x2f, 0x69, 0x90, 0x50, 0xda, 0x35, 0x9, 0xe5, 0x3b, 0xdd, 0xf6, 0x12, 0x22}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf0, 0x3, 0xbb, 0xf0, 0x27, 0xdb, 0xd6, 0x3a, 0x18, 0x77}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb0, 0x6d, 0x58, 0xe0, 0xb1, 0x7b, 0x2b, 0x5, 0xdd, + 0xe4, 0xb8, 0xb5, 0xc0, 0x20, 0x0, 0xc9, 0x80, 0xd1}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0xd7, 0x44, 0x63, 0x6f, 0x2e, 0x60, 0x1e, 0x6c, 0xdb, 0x88, + 0x41, 0x86, 0x5a, 0x7d, 0x58, 0xf7, 0x35, 0x48, 0x47, 0x3}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5542,152 +5755,129 @@ TEST(Connect311QCTest, Encode10) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\167 \167\208\233f\167\246'\240T\252\&3!", _password = Just -// "\204ptBG\160\v\SUB\223!\EM\SI\STX\b\DEL+1Z", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, -// _willTopic = "\186To9\139\230@\227W\SUB\173\175\253\165\SI\195\133i\DC4\ESC\229\DC2=z\251\186\231", _willMsg = -// "rXO\rA\ESC\fQ\DC2\152\SO\ETB{\248\203\197%\175\203\235\227", _willProps = []}), _cleanSession = False, _keepAlive = -// 21475, _connID = "\130", _properties = []} +// ConnectRequest {_username = Just "9\246\141M+", _password = Just +// "BzT\194\145\200\DC1~\DC2\170\&9\EOT\DLE\215\STX\232\174n", _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 30004, _connID = "\ENQ\221\153\230\216\164\143FVb\206\243AV\250\128nq\CAN\233\230\147\239@u\239*", _properties = []} TEST(Connect311QCTest, Encode11) { - uint8_t pkt[] = {0x10, 0x65, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x53, 0xe3, 0x0, 0x1, 0x82, - 0x0, 0x1b, 0xba, 0x54, 0x6f, 0x39, 0x8b, 0xe6, 0x40, 0xe3, 0x57, 0x1a, 0xad, 0xaf, 0xfd, - 0xa5, 0xf, 0xc3, 0x85, 0x69, 0x14, 0x1b, 0xe5, 0x12, 0x3d, 0x7a, 0xfb, 0xba, 0xe7, 0x0, - 0x15, 0x72, 0x58, 0x4f, 0xd, 0x41, 0x1b, 0xc, 0x51, 0x12, 0x98, 0xe, 0x17, 0x7b, 0xf8, - 0xcb, 0xc5, 0x25, 0xaf, 0xcb, 0xeb, 0xe3, 0x0, 0xe, 0xa7, 0x20, 0xa7, 0xd0, 0xe9, 0x66, - 0xa7, 0xf6, 0x27, 0xf0, 0x54, 0xfc, 0x33, 0x21, 0x0, 0x12, 0xcc, 0x70, 0x74, 0x42, 0x47, - 0xa0, 0xb, 0x1a, 0xdf, 0x21, 0x19, 0xf, 0x2, 0x8, 0x7f, 0x2b, 0x31, 0x5a}; + uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x75, 0x34, 0x0, 0x1b, + 0x5, 0xdd, 0x99, 0xe6, 0xd8, 0xa4, 0x8f, 0x46, 0x56, 0x62, 0xce, 0xf3, 0x41, 0x56, + 0xfa, 0x80, 0x6e, 0x71, 0x18, 0xe9, 0xe6, 0x93, 0xef, 0x40, 0x75, 0xef, 0x2a, 0x0, + 0x5, 0x39, 0xf6, 0x8d, 0x4d, 0x2b, 0x0, 0x12, 0x42, 0x7a, 0x54, 0xc2, 0x91, 0xc8, + 0x11, 0x7e, 0x12, 0xaa, 0x39, 0x4, 0x10, 0xd7, 0x2, 0xe8, 0xae, 0x6e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xba, 0x54, 0x6f, 0x39, 0x8b, 0xe6, 0x40, 0xe3, 0x57, 0x1a, 0xad, 0xaf, 0xfd, 0xa5, - 0xf, 0xc3, 0x85, 0x69, 0x14, 0x1b, 0xe5, 0x12, 0x3d, 0x7a, 0xfb, 0xba, 0xe7}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x72, 0x58, 0x4f, 0xd, 0x41, 0x1b, 0xc, 0x51, 0x12, 0x98, 0xe, - 0x17, 0x7b, 0xf8, 0xcb, 0xc5, 0x25, 0xaf, 0xcb, 0xeb, 0xe3}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 21475; - uint8_t client_id_bytes[] = {0x82}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; + opts.keep_alive = 30004; + uint8_t client_id_bytes[] = {0x5, 0xdd, 0x99, 0xe6, 0xd8, 0xa4, 0x8f, 0x46, 0x56, 0x62, 0xce, 0xf3, 0x41, 0x56, + 0xfa, 0x80, 0x6e, 0x71, 0x18, 0xe9, 0xe6, 0x93, 0xef, 0x40, 0x75, 0xef, 0x2a}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa7, 0x20, 0xa7, 0xd0, 0xe9, 0x66, 0xa7, 0xf6, 0x27, 0xf0, 0x54, 0xfc, 0x33, 0x21}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x39, 0xf6, 0x8d, 0x4d, 0x2b}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xcc, 0x70, 0x74, 0x42, 0x47, 0xa0, 0xb, 0x1a, 0xdf, - 0x21, 0x19, 0xf, 0x2, 0x8, 0x7f, 0x2b, 0x31, 0x5a}; + uint8_t password_bytes[] = {0x42, 0x7a, 0x54, 0xc2, 0x91, 0xc8, 0x11, 0x7e, 0x12, + 0xaa, 0x39, 0x4, 0x10, 0xd7, 0x2, 0xe8, 0xae, 0x6e}; lwmqtt_string_t password = {18, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "4\244\&1\217\142\&8\NAK5", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "e;\194\&7\237P\201 w\216\149l\171W\RS\241>\135`\SYN\ENQ\197\t", -// _willMsg = "2\174", _willProps = []}), _cleanSession = True, _keepAlive = 29263, _connID = -// "\173Q\DC4\163\185\129\144\238\155\169Q\252K\131\227\&9\CAN\v\239", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "Q\GS\242\209", _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 6889, _connID = "hO\233g\n{qNO\160 ", _properties = []} TEST(Connect311QCTest, Encode12) { - uint8_t pkt[] = {0x10, 0x3c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x72, 0x4f, 0x0, 0x13, 0xad, 0x51, - 0x14, 0xa3, 0xb9, 0x81, 0x90, 0xee, 0x9b, 0xa9, 0x51, 0xfc, 0x4b, 0x83, 0xe3, 0x39, 0x18, 0xb, - 0xef, 0x0, 0x17, 0x65, 0x3b, 0xc2, 0x37, 0xed, 0x50, 0xc9, 0x20, 0x77, 0xd8, 0x95, 0x6c, 0xab, - 0x57, 0x1e, 0xf1, 0x3e, 0x87, 0x60, 0x16, 0x5, 0xc5, 0x9, 0x0, 0x2, 0x32, 0xae}; + uint8_t pkt[] = {0x10, 0x17, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x1a, 0xe9, 0x0, + 0xb, 0x68, 0x4f, 0xe9, 0x67, 0xa, 0x7b, 0x71, 0x4e, 0x4f, 0xa0, 0x20}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x65, 0x3b, 0xc2, 0x37, 0xed, 0x50, 0xc9, 0x20, 0x77, 0xd8, 0x95, 0x6c, - 0xab, 0x57, 0x1e, 0xf1, 0x3e, 0x87, 0x60, 0x16, 0x5, 0xc5, 0x9}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x32, 0xae}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 29263; - uint8_t client_id_bytes[] = {0xad, 0x51, 0x14, 0xa3, 0xb9, 0x81, 0x90, 0xee, 0x9b, 0xa9, - 0x51, 0xfc, 0x4b, 0x83, 0xe3, 0x39, 0x18, 0xb, 0xef}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.keep_alive = 6889; + uint8_t client_id_bytes[] = {0x68, 0x4f, 0xe9, 0x67, 0xa, 0x7b, 0x71, 0x4e, 0x4f, 0xa0, 0x20}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x34, 0xf4, 0x31, 0xd9, 0x8e, 0x38, 0x15, 0x35}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x51, 0x1d, 0xf2, 0xd1}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\199\154\ACK\130\147\145\141\149\SOH", _lastWill = Nothing, -// _cleanSession = True, _keepAlive = 26934, _connID = "\185\183=\217", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "", _willMsg = "\235\177\182N)\GS\253\200\252E\173b\141gO\165\169\ETX\va\209*", _willProps = []}), +// _cleanSession = True, _keepAlive = 8360, _connID = +// "\178Ip\r*\206Y\141(\255\184\&4\224\197=\217\172\EM\EOT\\'\RS\229u\172S\202", _properties = []} TEST(Connect311QCTest, Encode13) { - uint8_t pkt[] = {0x10, 0x10, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, - 0x2, 0x69, 0x36, 0x0, 0x4, 0xb9, 0xb7, 0x3d, 0xd9}; + uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x20, 0xa8, 0x0, 0x1b, 0xb2, 0x49, 0x70, + 0xd, 0x2a, 0xce, 0x59, 0x8d, 0x28, 0xff, 0xb8, 0x34, 0xe0, 0xc5, 0x3d, 0xd9, 0xac, 0x19, 0x4, 0x5c, + 0x27, 0x1e, 0xe5, 0x75, 0xac, 0x53, 0xca, 0x0, 0x0, 0x0, 0x16, 0xeb, 0xb1, 0xb6, 0x4e, 0x29, 0x1d, + 0xfd, 0xc8, 0xfc, 0x45, 0xad, 0x62, 0x8d, 0x67, 0x4f, 0xa5, 0xa9, 0x3, 0xb, 0x61, 0xd1, 0x2a}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xeb, 0xb1, 0xb6, 0x4e, 0x29, 0x1d, 0xfd, 0xc8, 0xfc, 0x45, 0xad, + 0x62, 0x8d, 0x67, 0x4f, 0xa5, 0xa9, 0x3, 0xb, 0x61, 0xd1, 0x2a}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 26934; - uint8_t client_id_bytes[] = {0xb9, 0xb7, 0x3d, 0xd9}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.keep_alive = 8360; + uint8_t client_id_bytes[] = {0xb2, 0x49, 0x70, 0xd, 0x2a, 0xce, 0x59, 0x8d, 0x28, 0xff, 0xb8, 0x34, 0xe0, 0xc5, + 0x3d, 0xd9, 0xac, 0x19, 0x4, 0x5c, 0x27, 0x1e, 0xe5, 0x75, 0xac, 0x53, 0xca}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xc7, 0x9a, 0x6, 0x82, 0x93, 0x91, 0x8d, 0x95, 0x1}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "-\247+\DC1\233}bt\ENQ\200\241\ENQ\SI\v\163F\173\246\236h\217\149Ur\237\DC3\244\208\217\EOT", _password = Just -// "\181\199$\147\180\ETX6\202", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\227\174\130\185\246$4`\SI^`\215\195\238\204OL\188\134\144\164\DLE^-\187\STX\DC4\224\178", _willMsg = -// "\210\221\DC4\SYN\212^\167\212v\131\142\DELq\191\136\237\&6\203\227.\181\SYN\138", _willProps = []}), _cleanSession = -// False, _keepAlive = 20204, _connID = "\140\212\218\244p", _properties = []} +// ConnectRequest {_username = Just "H\176\DC3\130\176@\132\210", _password = Just +// "\198\248\US\ETB\143\174JCT\DEL\221a\211\221;\179\128\182\154\207\189o", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS2, _willTopic = "\147.\146\246\203'\150]B\EMY\ETB\GS\tM\166q\196ug\DLE\t\191B", _willMsg = +// "\228\164\240r\184\245\201\DC2#9H\152\ETB\188\241\217\202\186\203\197D\220\162\&4\213", _willProps = []}), +// _cleanSession = True, _keepAlive = 28532, _connID = "y\245\130FF#\\[\227\&0", _properties = []} TEST(Connect311QCTest, Encode14) { - uint8_t pkt[] = {0x10, 0x73, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x4e, 0xec, 0x0, 0x5, 0x8c, 0xd4, 0xda, - 0xf4, 0x70, 0x0, 0x1d, 0xe3, 0xae, 0x82, 0xb9, 0xf6, 0x24, 0x34, 0x60, 0xf, 0x5e, 0x60, 0xd7, 0xc3, - 0xee, 0xcc, 0x4f, 0x4c, 0xbc, 0x86, 0x90, 0xa4, 0x10, 0x5e, 0x2d, 0xbb, 0x2, 0x14, 0xe0, 0xb2, 0x0, - 0x17, 0xd2, 0xdd, 0x14, 0x16, 0xd4, 0x5e, 0xa7, 0xd4, 0x76, 0x83, 0x8e, 0x7f, 0x71, 0xbf, 0x88, 0xed, - 0x36, 0xcb, 0xe3, 0x2e, 0xb5, 0x16, 0x8a, 0x0, 0x1e, 0x2d, 0xf7, 0x2b, 0x11, 0xe9, 0x7d, 0x62, 0x74, - 0x5, 0xc8, 0xf1, 0x5, 0xf, 0xb, 0xa3, 0x46, 0xad, 0xf6, 0xec, 0x68, 0xd9, 0x95, 0x55, 0x72, 0xed, - 0x13, 0xf4, 0xd0, 0xd9, 0x4, 0x0, 0x8, 0xb5, 0xc7, 0x24, 0x93, 0xb4, 0x3, 0x36, 0xca}; + uint8_t pkt[] = {0x10, 0x6d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x6f, 0x74, 0x0, 0xa, 0x79, 0xf5, + 0x82, 0x46, 0x46, 0x23, 0x5c, 0x5b, 0xe3, 0x30, 0x0, 0x18, 0x93, 0x2e, 0x92, 0xf6, 0xcb, 0x27, + 0x96, 0x5d, 0x42, 0x19, 0x59, 0x17, 0x1d, 0x9, 0x4d, 0xa6, 0x71, 0xc4, 0x75, 0x67, 0x10, 0x9, + 0xbf, 0x42, 0x0, 0x19, 0xe4, 0xa4, 0xf0, 0x72, 0xb8, 0xf5, 0xc9, 0x12, 0x23, 0x39, 0x48, 0x98, + 0x17, 0xbc, 0xf1, 0xd9, 0xca, 0xba, 0xcb, 0xc5, 0x44, 0xdc, 0xa2, 0x34, 0xd5, 0x0, 0x8, 0x48, + 0xb0, 0x13, 0x82, 0xb0, 0x40, 0x84, 0xd2, 0x0, 0x16, 0xc6, 0xf8, 0x1f, 0x17, 0x8f, 0xae, 0x4a, + 0x43, 0x54, 0x7f, 0xdd, 0x61, 0xd3, 0xdd, 0x3b, 0xb3, 0x80, 0xb6, 0x9a, 0xcf, 0xbd, 0x6f}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5698,31 +5888,30 @@ TEST(Connect311QCTest, Encode14) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe3, 0xae, 0x82, 0xb9, 0xf6, 0x24, 0x34, 0x60, 0xf, 0x5e, - 0x60, 0xd7, 0xc3, 0xee, 0xcc, 0x4f, 0x4c, 0xbc, 0x86, 0x90, - 0xa4, 0x10, 0x5e, 0x2d, 0xbb, 0x2, 0x14, 0xe0, 0xb2}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd2, 0xdd, 0x14, 0x16, 0xd4, 0x5e, 0xa7, 0xd4, 0x76, 0x83, 0x8e, 0x7f, - 0x71, 0xbf, 0x88, 0xed, 0x36, 0xcb, 0xe3, 0x2e, 0xb5, 0x16, 0x8a}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x93, 0x2e, 0x92, 0xf6, 0xcb, 0x27, 0x96, 0x5d, 0x42, 0x19, 0x59, 0x17, + 0x1d, 0x9, 0x4d, 0xa6, 0x71, 0xc4, 0x75, 0x67, 0x10, 0x9, 0xbf, 0x42}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe4, 0xa4, 0xf0, 0x72, 0xb8, 0xf5, 0xc9, 0x12, 0x23, 0x39, 0x48, 0x98, 0x17, + 0xbc, 0xf1, 0xd9, 0xca, 0xba, 0xcb, 0xc5, 0x44, 0xdc, 0xa2, 0x34, 0xd5}; + lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 20204; - uint8_t client_id_bytes[] = {0x8c, 0xd4, 0xda, 0xf4, 0x70}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 28532; + uint8_t client_id_bytes[] = {0x79, 0xf5, 0x82, 0x46, 0x46, 0x23, 0x5c, 0x5b, 0xe3, 0x30}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2d, 0xf7, 0x2b, 0x11, 0xe9, 0x7d, 0x62, 0x74, 0x5, 0xc8, 0xf1, 0x5, 0xf, 0xb, 0xa3, - 0x46, 0xad, 0xf6, 0xec, 0x68, 0xd9, 0x95, 0x55, 0x72, 0xed, 0x13, 0xf4, 0xd0, 0xd9, 0x4}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x48, 0xb0, 0x13, 0x82, 0xb0, 0x40, 0x84, 0xd2}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xb5, 0xc7, 0x24, 0x93, 0xb4, 0x3, 0x36, 0xca}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xc6, 0xf8, 0x1f, 0x17, 0x8f, 0xae, 0x4a, 0x43, 0x54, 0x7f, 0xdd, + 0x61, 0xd3, 0xdd, 0x3b, 0xb3, 0x80, 0xb6, 0x9a, 0xcf, 0xbd, 0x6f}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5732,16 +5921,18 @@ TEST(Connect311QCTest, Encode14) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "r=\231\144i:\207\214h\149\199\202J", _password = Just "2\202\ACK*\135", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "rx&4\204G@rz\177>", _willMsg = "\237\222\176\197", -// _willProps = []}), _cleanSession = False, _keepAlive = 11274, _connID = -// "\223\t\143\166\173\230\156\142\250\&1\248\EOT\185\ACK\235\144\155+\249\150\182\136\232\133\206", _properties = []} +// ConnectRequest {_username = Just "\232\220\210", _password = Just +// "Q\222\CAN\156\222j\201*\143\147\STX\155\152P\n\166#\139", _lastWill = Just (LastWill {_willRetain = False, _willQoS +// = QoS2, _willTopic = "\NAK\166\247\190f\227\STX", _willMsg = +// "Pu4\232\181\200\&73\211\251l\247WIl\248g\236i\218\139\136\182\208\241!\195\244\162", _willProps = []}), +// _cleanSession = False, _keepAlive = 16792, _connID = "\144\154@\235\163ha\251\SO\244\151\244\235", _properties = []} TEST(Connect311QCTest, Encode15) { - uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x2c, 0xa, 0x0, 0x19, 0xdf, 0x9, - 0x8f, 0xa6, 0xad, 0xe6, 0x9c, 0x8e, 0xfa, 0x31, 0xf8, 0x4, 0xb9, 0x6, 0xeb, 0x90, 0x9b, 0x2b, - 0xf9, 0x96, 0xb6, 0x88, 0xe8, 0x85, 0xce, 0x0, 0xb, 0x72, 0x78, 0x26, 0x34, 0xcc, 0x47, 0x40, - 0x72, 0x7a, 0xb1, 0x3e, 0x0, 0x4, 0xed, 0xde, 0xb0, 0xc5, 0x0, 0xd, 0x72, 0x3d, 0xe7, 0x90, - 0x69, 0x3a, 0xcf, 0xd6, 0x68, 0x95, 0xc7, 0xca, 0x4a, 0x0, 0x5, 0x32, 0xca, 0x6, 0x2a, 0x87}; + uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x41, 0x98, 0x0, 0xd, 0x90, 0x9a, + 0x40, 0xeb, 0xa3, 0x68, 0x61, 0xfb, 0xe, 0xf4, 0x97, 0xf4, 0xeb, 0x0, 0x7, 0x15, 0xa6, 0xf7, + 0xbe, 0x66, 0xe3, 0x2, 0x0, 0x1d, 0x50, 0x75, 0x34, 0xe8, 0xb5, 0xc8, 0x37, 0x33, 0xd3, 0xfb, + 0x6c, 0xf7, 0x57, 0x49, 0x6c, 0xf8, 0x67, 0xec, 0x69, 0xda, 0x8b, 0x88, 0xb6, 0xd0, 0xf1, 0x21, + 0xc3, 0xf4, 0xa2, 0x0, 0x3, 0xe8, 0xdc, 0xd2, 0x0, 0x12, 0x51, 0xde, 0x18, 0x9c, 0xde, 0x6a, + 0xc9, 0x2a, 0x8f, 0x93, 0x2, 0x9b, 0x98, 0x50, 0xa, 0xa6, 0x23, 0x8b}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5752,28 +5943,30 @@ TEST(Connect311QCTest, Encode15) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x72, 0x78, 0x26, 0x34, 0xcc, 0x47, 0x40, 0x72, 0x7a, 0xb1, 0x3e}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xed, 0xde, 0xb0, 0xc5}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x15, 0xa6, 0xf7, 0xbe, 0x66, 0xe3, 0x2}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x50, 0x75, 0x34, 0xe8, 0xb5, 0xc8, 0x37, 0x33, 0xd3, 0xfb, + 0x6c, 0xf7, 0x57, 0x49, 0x6c, 0xf8, 0x67, 0xec, 0x69, 0xda, + 0x8b, 0x88, 0xb6, 0xd0, 0xf1, 0x21, 0xc3, 0xf4, 0xa2}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 11274; - uint8_t client_id_bytes[] = {0xdf, 0x9, 0x8f, 0xa6, 0xad, 0xe6, 0x9c, 0x8e, 0xfa, 0x31, 0xf8, 0x4, 0xb9, - 0x6, 0xeb, 0x90, 0x9b, 0x2b, 0xf9, 0x96, 0xb6, 0x88, 0xe8, 0x85, 0xce}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.keep_alive = 16792; + uint8_t client_id_bytes[] = {0x90, 0x9a, 0x40, 0xeb, 0xa3, 0x68, 0x61, 0xfb, 0xe, 0xf4, 0x97, 0xf4, 0xeb}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x72, 0x3d, 0xe7, 0x90, 0x69, 0x3a, 0xcf, 0xd6, 0x68, 0x95, 0xc7, 0xca, 0x4a}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xe8, 0xdc, 0xd2}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x32, 0xca, 0x6, 0x2a, 0x87}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x51, 0xde, 0x18, 0x9c, 0xde, 0x6a, 0xc9, 0x2a, 0x8f, + 0x93, 0x2, 0x9b, 0x98, 0x50, 0xa, 0xa6, 0x23, 0x8b}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5783,17 +5976,19 @@ TEST(Connect311QCTest, Encode15) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "#Q\186\\\192N\NUL\ETB\159\205\a\194`T\211\EM\157\133\ACKf;Z\189\220\129\164", _willMsg = -// "\EOT\228!\252NLON\246\199\210g\235\225\255\130\139\v ", _willProps = []}), _cleanSession = True, _keepAlive = 13058, -// _connID = ".d\DC4\204\250e\224\180\140\158\RS3)G\143\172\SOST\ETBEX", _properties = []} +// ConnectRequest {_username = Just "\208\&08\153\253\129\180\139MgC\ACKe\252k\131\238w\f\234\212", _password = Just +// "\174\131\134S\237\RS", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "oa\v,+\129{\223N\216\&2}\SI\161-\165a\146\&7\248\166\224\189\SOH\ESC\182", _willMsg = "m]", _willProps = []}), +// _cleanSession = False, _keepAlive = 3974, _connID = +// "\203\150\211\212\222);\208\149\129\DC4~\242y\186\143\254U\154\SYNx\245\248\f\166m!", _properties = []} TEST(Connect311QCTest, Encode16) { - uint8_t pkt[]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ae, 0x83, 0x86, 0x53, 0xed, 0x1e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5804,25 +5999,31 @@ TEST(Connect311QCTest, Encode16) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x23, 0x51, 0xba, 0x5c, 0xc0, 0x4e, 0x0, 0x17, 0x9f, 0xcd, 0x7, 0xc2, 0x60, - 0x54, 0xd3, 0x19, 0x9d, 0x85, 0x6, 0x66, 0x3b, 0x5a, 0xbd, 0xdc, 0x81, 0xa4}; + uint8_t will_topic_bytes[] = {0x6f, 0x61, 0xb, 0x2c, 0x2b, 0x81, 0x7b, 0xdf, 0x4e, 0xd8, 0x32, 0x7d, 0xf, + 0xa1, 0x2d, 0xa5, 0x61, 0x92, 0x37, 0xf8, 0xa6, 0xe0, 0xbd, 0x1, 0x1b, 0xb6}; lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4, 0xe4, 0x21, 0xfc, 0x4e, 0x4c, 0x4f, 0x4e, 0xf6, 0xc7, - 0xd2, 0x67, 0xeb, 0xe1, 0xff, 0x82, 0x8b, 0xb, 0x20}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + uint8_t will_payload_bytes[] = {0x6d, 0x5d}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; + will.qos = LWMQTT_QOS2; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 13058; - uint8_t client_id_bytes[] = {0x2e, 0x64, 0x14, 0xcc, 0xfa, 0x65, 0xe0, 0xb4, 0x8c, 0x9e, 0x1e, - 0x33, 0x29, 0x47, 0x8f, 0xac, 0xe, 0x53, 0x54, 0x17, 0x45, 0x58}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 3974; + uint8_t client_id_bytes[] = {0xcb, 0x96, 0xd3, 0xd4, 0xde, 0x29, 0x3b, 0xd0, 0x95, 0x81, 0x14, 0x7e, 0xf2, 0x79, + 0xba, 0x8f, 0xfe, 0x55, 0x9a, 0x16, 0x78, 0xf5, 0xf8, 0xc, 0xa6, 0x6d, 0x21}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t username_bytes[] = {0xd0, 0x30, 0x38, 0x99, 0xfd, 0x81, 0xb4, 0x8b, 0x4d, 0x67, 0x43, + 0x6, 0x65, 0xfc, 0x6b, 0x83, 0xee, 0x77, 0xc, 0xea, 0xd4}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xae, 0x83, 0x86, 0x53, 0xed, 0x1e}; + lwmqtt_string_t password = {6, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5831,47 +6032,64 @@ TEST(Connect311QCTest, Encode16) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "-\157\STX\167\DC4\171\157t", _password = Just "/j-", _lastWill = Nothing, -// _cleanSession = False, _keepAlive = 2165, _connID = ";l\192\DC1N\156z\170\170\165[\f", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\188\129", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS0, _willTopic = "\129\&3\164\SI_\141bs\171\247\163v\159\181\150T\180\136Az", _willMsg = " +// /\189\141D\179\139\140\223\211:A\219\205Fu\DC1", _willProps = []}), _cleanSession = False, _keepAlive = 6602, _connID +// = "%\197u\242|QM/\NUL\239\144\a\176\173\138\248\143\&0>8", _properties = []} TEST(Connect311QCTest, Encode17) { - uint8_t pkt[] = {0x10, 0x27, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x8, 0x75, 0x0, 0xc, - 0x3b, 0x6c, 0xc0, 0x11, 0x4e, 0x9c, 0x7a, 0xaa, 0xaa, 0xa5, 0x5b, 0xc, 0x0, 0x8, - 0x2d, 0x9d, 0x2, 0xa7, 0x14, 0xab, 0x9d, 0x74, 0x0, 0x3, 0x2f, 0x6a, 0x2d}; + uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x4, 0x19, 0xca, 0x0, 0x14, 0x25, + 0xc5, 0x75, 0xf2, 0x7c, 0x51, 0x4d, 0x2f, 0x0, 0xef, 0x90, 0x7, 0xb0, 0xad, 0x8a, 0xf8, + 0x8f, 0x30, 0x3e, 0x38, 0x0, 0x14, 0x81, 0x33, 0xa4, 0xf, 0x5f, 0x8d, 0x62, 0x73, 0xab, + 0xf7, 0xa3, 0x76, 0x9f, 0xb5, 0x96, 0x54, 0xb4, 0x88, 0x41, 0x7a, 0x0, 0x11, 0x20, 0x2f, + 0xbd, 0x8d, 0x44, 0xb3, 0x8b, 0x8c, 0xdf, 0xd3, 0x3a, 0x41, 0xdb, 0xcd, 0x46, 0x75, 0x11}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x81, 0x33, 0xa4, 0xf, 0x5f, 0x8d, 0x62, 0x73, 0xab, 0xf7, + 0xa3, 0x76, 0x9f, 0xb5, 0x96, 0x54, 0xb4, 0x88, 0x41, 0x7a}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x20, 0x2f, 0xbd, 0x8d, 0x44, 0xb3, 0x8b, 0x8c, 0xdf, + 0xd3, 0x3a, 0x41, 0xdb, 0xcd, 0x46, 0x75, 0x11}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 2165; - uint8_t client_id_bytes[] = {0x3b, 0x6c, 0xc0, 0x11, 0x4e, 0x9c, 0x7a, 0xaa, 0xaa, 0xa5, 0x5b, 0xc}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.keep_alive = 6602; + uint8_t client_id_bytes[] = {0x25, 0xc5, 0x75, 0xf2, 0x7c, 0x51, 0x4d, 0x2f, 0x0, 0xef, + 0x90, 0x7, 0xb0, 0xad, 0x8a, 0xf8, 0x8f, 0x30, 0x3e, 0x38}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2d, 0x9d, 0x2, 0xa7, 0x14, 0xab, 0x9d, 0x74}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x2f, 0x6a, 0x2d}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xbc, 0x81}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "^a,Y\US\230/\202\240\t\229\218\191\SUBdl", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\170", _willMsg = -// "@d\157b\SYN\150\&0\164\ENQ\236O\149e\129\218\210wSKU\DC4y\SOH\188\163m\EOT", _willProps = []}), _cleanSession = -// True, _keepAlive = 10569, _connID = "\185Xg$ZH\152\132 !", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\134\162'b\147r\DC3", _lastWill = Just (LastWill {_willRetain +// = True, _willQoS = QoS0, _willTopic = "\196.\fm\178\&9\240", _willMsg = +// "\229Y\246\171\"\a\231Vp\200\169\156\&5%\n\165\146\ETB\221\209\128\228\231", _willProps = []}), _cleanSession = True, +// _keepAlive = 10739, _connID = "/", _properties = []} TEST(Connect311QCTest, Encode18) { - uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x29, 0x49, 0x0, 0xa, - 0xb9, 0x58, 0x67, 0x24, 0x5a, 0x48, 0x98, 0x84, 0x20, 0x21, 0x0, 0x1, 0xaa, 0x0, - 0x1b, 0x40, 0x64, 0x9d, 0x62, 0x16, 0x96, 0x30, 0xa4, 0x5, 0xec, 0x4f, 0x95, 0x65, - 0x81, 0xda, 0xd2, 0x77, 0x53, 0x4b, 0x55, 0x14, 0x79, 0x1, 0xbc, 0xa3, 0x6d, 0x4}; + uint8_t pkt[] = {0x10, 0x2f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x29, 0xf3, 0x0, 0x1, 0x2f, 0x0, 0x7, + 0xc4, 0x2e, 0xc, 0x6d, 0xb2, 0x39, 0xf0, 0x0, 0x17, 0xe5, 0x59, 0xf6, 0xab, 0x22, 0x7, 0xe7, 0x56, + 0x70, 0xc8, 0xa9, 0x9c, 0x35, 0x25, 0xa, 0xa5, 0x92, 0x17, 0xdd, 0xd1, 0x80, 0xe4, 0xe7}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5882,26 +6100,25 @@ TEST(Connect311QCTest, Encode18) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xaa}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x40, 0x64, 0x9d, 0x62, 0x16, 0x96, 0x30, 0xa4, 0x5, 0xec, 0x4f, 0x95, 0x65, 0x81, - 0xda, 0xd2, 0x77, 0x53, 0x4b, 0x55, 0x14, 0x79, 0x1, 0xbc, 0xa3, 0x6d, 0x4}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xc4, 0x2e, 0xc, 0x6d, 0xb2, 0x39, 0xf0}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe5, 0x59, 0xf6, 0xab, 0x22, 0x7, 0xe7, 0x56, 0x70, 0xc8, 0xa9, 0x9c, + 0x35, 0x25, 0xa, 0xa5, 0x92, 0x17, 0xdd, 0xd1, 0x80, 0xe4, 0xe7}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 10569; - uint8_t client_id_bytes[] = {0xb9, 0x58, 0x67, 0x24, 0x5a, 0x48, 0x98, 0x84, 0x20, 0x21}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; + opts.keep_alive = 10739; + uint8_t client_id_bytes[] = {0x2f}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x5e, 0x61, 0x2c, 0x59, 0x1f, 0xe6, 0x2f, 0xca, - 0xf0, 0x9, 0xe5, 0xda, 0xbf, 0x1a, 0x64, 0x6c}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x86, 0xa2, 0x27, 0x62, 0x93, 0x72, 0x13}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5911,50 +6128,71 @@ TEST(Connect311QCTest, Encode18) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\251\140\165-\247FkO\242Y\DC2\f\236\DC2\223pL\DC1+\246\255", _password = Nothing, -// _lastWill = Nothing, _cleanSession = False, _keepAlive = 692, _connID = -// "h\254\SUB\167\243\223\&6e\ACK\209\169\208{K\152\224:\222\217Se]1", _properties = []} +// ConnectRequest {_username = Just "\162\239\230\n3", _password = Just +// "\CAN\200\200D\180\211J@\181\217Sj\DEL\208\141\&8\135^$\175", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "Z\197\216\246\ETX\145\228\DC3\217", _willMsg = "5\204\&3\t\SI\254!\226\237\154", +// _willProps = []}), _cleanSession = False, _keepAlive = 24980, _connID = +// "f\246\\A\130\163\246\NUL\ESC\222\168?\SI\NULe\155\&9\215", _properties = []} TEST(Connect311QCTest, Encode19) { - uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x2, 0xb4, 0x0, 0x17, 0x68, - 0xfe, 0x1a, 0xa7, 0xf3, 0xdf, 0x36, 0x65, 0x6, 0xd1, 0xa9, 0xd0, 0x7b, 0x4b, 0x98, 0xe0, - 0x3a, 0xde, 0xd9, 0x53, 0x65, 0x5d, 0x31, 0x0, 0x15, 0xfb, 0x8c, 0xa5, 0x2d, 0xf7, 0x46, - 0x6b, 0x4f, 0xf2, 0x59, 0x12, 0xc, 0xec, 0x12, 0xdf, 0x70, 0x4c, 0x11, 0x2b, 0xf6, 0xff}; + uint8_t pkt[] = {0x10, 0x52, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x61, 0x94, 0x0, 0x12, 0x66, 0xf6, 0x5c, + 0x41, 0x82, 0xa3, 0xf6, 0x0, 0x1b, 0xde, 0xa8, 0x3f, 0xf, 0x0, 0x65, 0x9b, 0x39, 0xd7, 0x0, 0x9, + 0x5a, 0xc5, 0xd8, 0xf6, 0x3, 0x91, 0xe4, 0x13, 0xd9, 0x0, 0xa, 0x35, 0xcc, 0x33, 0x9, 0xf, 0xfe, + 0x21, 0xe2, 0xed, 0x9a, 0x0, 0x5, 0xa2, 0xef, 0xe6, 0xa, 0x33, 0x0, 0x14, 0x18, 0xc8, 0xc8, 0x44, + 0xb4, 0xd3, 0x4a, 0x40, 0xb5, 0xd9, 0x53, 0x6a, 0x7f, 0xd0, 0x8d, 0x38, 0x87, 0x5e, 0x24, 0xaf}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5a, 0xc5, 0xd8, 0xf6, 0x3, 0x91, 0xe4, 0x13, 0xd9}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x35, 0xcc, 0x33, 0x9, 0xf, 0xfe, 0x21, 0xe2, 0xed, 0x9a}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 692; - uint8_t client_id_bytes[] = {0x68, 0xfe, 0x1a, 0xa7, 0xf3, 0xdf, 0x36, 0x65, 0x6, 0xd1, 0xa9, 0xd0, - 0x7b, 0x4b, 0x98, 0xe0, 0x3a, 0xde, 0xd9, 0x53, 0x65, 0x5d, 0x31}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 24980; + uint8_t client_id_bytes[] = {0x66, 0xf6, 0x5c, 0x41, 0x82, 0xa3, 0xf6, 0x0, 0x1b, + 0xde, 0xa8, 0x3f, 0xf, 0x0, 0x65, 0x9b, 0x39, 0xd7}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xfb, 0x8c, 0xa5, 0x2d, 0xf7, 0x46, 0x6b, 0x4f, 0xf2, 0x59, 0x12, - 0xc, 0xec, 0x12, 0xdf, 0x70, 0x4c, 0x11, 0x2b, 0xf6, 0xff}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa2, 0xef, 0xe6, 0xa, 0x33}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x18, 0xc8, 0xc8, 0x44, 0xb4, 0xd3, 0x4a, 0x40, 0xb5, 0xd9, + 0x53, 0x6a, 0x7f, 0xd0, 0x8d, 0x38, 0x87, 0x5e, 0x24, 0xaf}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "NZ\205t\136\"\192\172", _password = Just ";", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS0, _willTopic = -// "I\178\221P\DC2\179\161\234\145\EOT-\160eY\DEL'\191\250\&5|\172\EOT\240", _willMsg = -// "D]Y\226\&7\ESC\249\US8w\142\212z\211\143@\168d\NUL\149\STX\220e2", _willProps = []}), _cleanSession = False, -// _keepAlive = 2830, _connID = "\244\148g", _properties = []} +// ConnectRequest {_username = Just "\223\202e-\159\bZ\GS", _password = Just +// "\210\145\"C\US\ESC(\195\234\165\212\157t\235\178", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, +// _willTopic = "1PwW$\"}\"/9\SOH\DC4a\252\212\170=b\209y\215\SO\216.F\160\139", _willMsg = +// "\254\255\178\RS\STXL\176\236\FS\129c\209", _willProps = []}), _cleanSession = True, _keepAlive = 21539, _connID = +// "t\221\220", _properties = []} TEST(Connect311QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0x4f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0xb, 0xe, 0x0, 0x3, 0xf4, 0x94, 0x67, - 0x0, 0x17, 0x49, 0xb2, 0xdd, 0x50, 0x12, 0xb3, 0xa1, 0xea, 0x91, 0x4, 0x2d, 0xa0, 0x65, 0x59, 0x7f, - 0x27, 0xbf, 0xfa, 0x35, 0x7c, 0xac, 0x4, 0xf0, 0x0, 0x18, 0x44, 0x5d, 0x59, 0xe2, 0x37, 0x1b, 0xf9, - 0x1f, 0x38, 0x77, 0x8e, 0xd4, 0x7a, 0xd3, 0x8f, 0x40, 0xa8, 0x64, 0x0, 0x95, 0x2, 0xdc, 0x65, 0x32, - 0x0, 0x8, 0x4e, 0x5a, 0xcd, 0x74, 0x88, 0x22, 0xc0, 0xac, 0x0, 0x1, 0x3b}; + uint8_t pkt[] = {0x10, 0x55, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x54, 0x23, 0x0, 0x3, 0x74, + 0xdd, 0xdc, 0x0, 0x1b, 0x31, 0x50, 0x77, 0x57, 0x24, 0x22, 0x7d, 0x22, 0x2f, 0x39, 0x1, + 0x14, 0x61, 0xfc, 0xd4, 0xaa, 0x3d, 0x62, 0xd1, 0x79, 0xd7, 0xe, 0xd8, 0x2e, 0x46, 0xa0, + 0x8b, 0x0, 0xc, 0xfe, 0xff, 0xb2, 0x1e, 0x2, 0x4c, 0xb0, 0xec, 0x1c, 0x81, 0x63, 0xd1, + 0x0, 0x8, 0xdf, 0xca, 0x65, 0x2d, 0x9f, 0x8, 0x5a, 0x1d, 0x0, 0xf, 0xd2, 0x91, 0x22, + 0x43, 0x1f, 0x1b, 0x28, 0xc3, 0xea, 0xa5, 0xd4, 0x9d, 0x74, 0xeb, 0xb2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5965,29 +6203,28 @@ TEST(Connect311QCTest, Encode20) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x49, 0xb2, 0xdd, 0x50, 0x12, 0xb3, 0xa1, 0xea, 0x91, 0x4, 0x2d, 0xa0, - 0x65, 0x59, 0x7f, 0x27, 0xbf, 0xfa, 0x35, 0x7c, 0xac, 0x4, 0xf0}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x44, 0x5d, 0x59, 0xe2, 0x37, 0x1b, 0xf9, 0x1f, 0x38, 0x77, 0x8e, 0xd4, - 0x7a, 0xd3, 0x8f, 0x40, 0xa8, 0x64, 0x0, 0x95, 0x2, 0xdc, 0x65, 0x32}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x31, 0x50, 0x77, 0x57, 0x24, 0x22, 0x7d, 0x22, 0x2f, 0x39, 0x1, 0x14, 0x61, 0xfc, + 0xd4, 0xaa, 0x3d, 0x62, 0xd1, 0x79, 0xd7, 0xe, 0xd8, 0x2e, 0x46, 0xa0, 0x8b}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfe, 0xff, 0xb2, 0x1e, 0x2, 0x4c, 0xb0, 0xec, 0x1c, 0x81, 0x63, 0xd1}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 2830; - uint8_t client_id_bytes[] = {0xf4, 0x94, 0x67}; + opts.clean_session = true; + opts.keep_alive = 21539; + uint8_t client_id_bytes[] = {0x74, 0xdd, 0xdc}; lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x4e, 0x5a, 0xcd, 0x74, 0x88, 0x22, 0xc0, 0xac}; + uint8_t username_bytes[] = {0xdf, 0xca, 0x65, 0x2d, 0x9f, 0x8, 0x5a, 0x1d}; lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x3b}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xd2, 0x91, 0x22, 0x43, 0x1f, 0x1b, 0x28, 0xc3, 0xea, 0xa5, 0xd4, 0x9d, 0x74, 0xeb, 0xb2}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5997,20 +6234,16 @@ TEST(Connect311QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\218\&6%\STX(5i0\189a\150\ENQ\229YH,0&^\167\f\254\209k", _password = Just -// "\202)\161\202\205\170z\SI\230\241\175\142\208\213\245\142]dM\EM\231\155\244", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = -// "\139\152\193\DC2\171\179\224m\168J\129\237\153t\SOH\ENQ\244G\203\EOT\US}\221\162", _willMsg = -// "\DLE\135\NAK^\193va\DC4\252\141-\RS", _willProps = []}), _cleanSession = True, _keepAlive = 11916, _connID = -// "z\209/\DEL\213B\229\RS\240B\238", _properties = []} +// ConnectRequest {_username = Just "\205lB\203\231\189}\136\179\155\DC1s\151L1\191\USz\163V\150\139n", _password = +// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\DC1\SO\218k9\194\251", +// _willMsg = "\220\247\191\205\141\195\128\255w", _willProps = []}), _cleanSession = False, _keepAlive = 11497, _connID +// = "zV\172\DC4\177\SI\214(\170\v\144\232}", _properties = []} TEST(Connect311QCTest, Encode21) { - uint8_t pkt[] = {0x10, 0x72, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x2e, 0x8c, 0x0, 0xb, 0x7a, 0xd1, 0x2f, - 0x7f, 0xd5, 0x42, 0xe5, 0x1e, 0xf0, 0x42, 0xee, 0x0, 0x18, 0x8b, 0x98, 0xc1, 0x12, 0xab, 0xb3, 0xe0, - 0x6d, 0xa8, 0x4a, 0x81, 0xed, 0x99, 0x74, 0x1, 0x5, 0xf4, 0x47, 0xcb, 0x4, 0x1f, 0x7d, 0xdd, 0xa2, - 0x0, 0xc, 0x10, 0x87, 0x15, 0x5e, 0xc1, 0x76, 0x61, 0x14, 0xfc, 0x8d, 0x2d, 0x1e, 0x0, 0x18, 0xda, - 0x36, 0x25, 0x2, 0x28, 0x35, 0x69, 0x30, 0xbd, 0x61, 0x96, 0x5, 0xe5, 0x59, 0x48, 0x2c, 0x30, 0x26, - 0x5e, 0xa7, 0xc, 0xfe, 0xd1, 0x6b, 0x0, 0x17, 0xca, 0x29, 0xa1, 0xca, 0xcd, 0xaa, 0x7a, 0xf, 0xe6, - 0xf1, 0xaf, 0x8e, 0xd0, 0xd5, 0xf5, 0x8e, 0x5d, 0x64, 0x4d, 0x19, 0xe7, 0x9b, 0xf4}; + uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x94, 0x2c, 0xe9, 0x0, 0xd, 0x7a, + 0x56, 0xac, 0x14, 0xb1, 0xf, 0xd6, 0x28, 0xaa, 0xb, 0x90, 0xe8, 0x7d, 0x0, 0x7, 0x11, + 0xe, 0xda, 0x6b, 0x39, 0xc2, 0xfb, 0x0, 0x9, 0xdc, 0xf7, 0xbf, 0xcd, 0x8d, 0xc3, 0x80, + 0xff, 0x77, 0x0, 0x17, 0xcd, 0x6c, 0x42, 0xcb, 0xe7, 0xbd, 0x7d, 0x88, 0xb3, 0x9b, 0x11, + 0x73, 0x97, 0x4c, 0x31, 0xbf, 0x1f, 0x7a, 0xa3, 0x56, 0x96, 0x8b, 0x6e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6021,31 +6254,26 @@ TEST(Connect311QCTest, Encode21) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8b, 0x98, 0xc1, 0x12, 0xab, 0xb3, 0xe0, 0x6d, 0xa8, 0x4a, 0x81, 0xed, - 0x99, 0x74, 0x1, 0x5, 0xf4, 0x47, 0xcb, 0x4, 0x1f, 0x7d, 0xdd, 0xa2}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x10, 0x87, 0x15, 0x5e, 0xc1, 0x76, 0x61, 0x14, 0xfc, 0x8d, 0x2d, 0x1e}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x11, 0xe, 0xda, 0x6b, 0x39, 0xc2, 0xfb}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xdc, 0xf7, 0xbf, 0xcd, 0x8d, 0xc3, 0x80, 0xff, 0x77}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 11916; - uint8_t client_id_bytes[] = {0x7a, 0xd1, 0x2f, 0x7f, 0xd5, 0x42, 0xe5, 0x1e, 0xf0, 0x42, 0xee}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 11497; + uint8_t client_id_bytes[] = {0x7a, 0x56, 0xac, 0x14, 0xb1, 0xf, 0xd6, 0x28, 0xaa, 0xb, 0x90, 0xe8, 0x7d}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xda, 0x36, 0x25, 0x2, 0x28, 0x35, 0x69, 0x30, 0xbd, 0x61, 0x96, 0x5, - 0xe5, 0x59, 0x48, 0x2c, 0x30, 0x26, 0x5e, 0xa7, 0xc, 0xfe, 0xd1, 0x6b}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xcd, 0x6c, 0x42, 0xcb, 0xe7, 0xbd, 0x7d, 0x88, 0xb3, 0x9b, 0x11, 0x73, + 0x97, 0x4c, 0x31, 0xbf, 0x1f, 0x7a, 0xa3, 0x56, 0x96, 0x8b, 0x6e}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xca, 0x29, 0xa1, 0xca, 0xcd, 0xaa, 0x7a, 0xf, 0xe6, 0xf1, 0xaf, 0x8e, - 0xd0, 0xd5, 0xf5, 0x8e, 0x5d, 0x64, 0x4d, 0x19, 0xe7, 0x9b, 0xf4}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6054,63 +6282,50 @@ TEST(Connect311QCTest, Encode21) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "\143y\166C\221w?;4\243\179\248z\136\a\221\DC3\228\DC1\156,\131\183sM\171&y", _lastWill = Just (LastWill {_willRetain -// = False, _willQoS = QoS2, _willTopic = "\226", _willMsg = "\240\178+p\166\192", _willProps = []}), _cleanSession = -// False, _keepAlive = 29711, _connID = "x2\200o\132\250", _properties = []} +// ConnectRequest {_username = Just "\251Z\240\194K\232\239\141AZ", _password = Just +// "\215]\EM\137\201\167\148\151\224z^h\231\180\213Uk+\147", _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 19360, _connID = "\156\242D9\182\133e\DC1\231\177\DC4", _properties = []} TEST(Connect311QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0x1d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x14, 0x74, 0xf, 0x0, 0x6, 0x78, 0x32, - 0xc8, 0x6f, 0x84, 0xfa, 0x0, 0x1, 0xe2, 0x0, 0x6, 0xf0, 0xb2, 0x2b, 0x70, 0xa6, 0xc0}; + uint8_t pkt[] = {0x10, 0x38, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x4b, 0xa0, 0x0, 0xb, 0x9c, + 0xf2, 0x44, 0x39, 0xb6, 0x85, 0x65, 0x11, 0xe7, 0xb1, 0x14, 0x0, 0xa, 0xfb, 0x5a, 0xf0, + 0xc2, 0x4b, 0xe8, 0xef, 0x8d, 0x41, 0x5a, 0x0, 0x13, 0xd7, 0x5d, 0x19, 0x89, 0xc9, 0xa7, + 0x94, 0x97, 0xe0, 0x7a, 0x5e, 0x68, 0xe7, 0xb4, 0xd5, 0x55, 0x6b, 0x2b, 0x93}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe2}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf0, 0xb2, 0x2b, 0x70, 0xa6, 0xc0}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 29711; - uint8_t client_id_bytes[] = {0x78, 0x32, 0xc8, 0x6f, 0x84, 0xfa}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.keep_alive = 19360; + uint8_t client_id_bytes[] = {0x9c, 0xf2, 0x44, 0x39, 0xb6, 0x85, 0x65, 0x11, 0xe7, 0xb1, 0x14}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x8f, 0x79, 0xa6, 0x43, 0xdd, 0x77, 0x3f, 0x3b, 0x34, 0xf3, 0xb3, 0xf8, 0x7a, 0x88, - 0x7, 0xdd, 0x13, 0xe4, 0x11, 0x9c, 0x2c, 0x83, 0xb7, 0x73, 0x4d, 0xab, 0x26, 0x79}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xfb, 0x5a, 0xf0, 0xc2, 0x4b, 0xe8, 0xef, 0x8d, 0x41, 0x5a}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xd7, 0x5d, 0x19, 0x89, 0xc9, 0xa7, 0x94, 0x97, 0xe0, 0x7a, + 0x5e, 0x68, 0xe7, 0xb4, 0xd5, 0x55, 0x6b, 0x2b, 0x93}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\157\244\252!\no\225e", _password = Just -// "\203+\193\206\143\177\CAN\NUL\b\229\143p\249\aoT\130\140\199\197\139\130", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "\188$&\229\204\146\186\244p\ACK\165dC\198G", _willMsg = -// ",n\136+E\195\136_K\222\148\132s\141{\231", _willProps = []}), _cleanSession = True, _keepAlive = 25534, _connID = -// "t\177\139,\191\139t\244\NAK\f\140!G\131k\141", _properties = []} +// ConnectRequest {_username = Just "X&4$#\150ffc\147", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS0, _willTopic = "\136x", _willMsg = "\170\173F9\211(\209\223@%\STX\NUL\175\144\213\136\224b", +// _willProps = []}), _cleanSession = False, _keepAlive = 19263, _connID = "\148\139\192+\177o\182\205", _properties = +// []} TEST(Connect311QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0x61, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x63, 0xbe, 0x0, 0x10, 0x74, 0xb1, 0x8b, - 0x2c, 0xbf, 0x8b, 0x74, 0xf4, 0x15, 0xc, 0x8c, 0x21, 0x47, 0x83, 0x6b, 0x8d, 0x0, 0xf, 0xbc, 0x24, - 0x26, 0xe5, 0xcc, 0x92, 0xba, 0xf4, 0x70, 0x6, 0xa5, 0x64, 0x43, 0xc6, 0x47, 0x0, 0x10, 0x2c, 0x6e, - 0x88, 0x2b, 0x45, 0xc3, 0x88, 0x5f, 0x4b, 0xde, 0x94, 0x84, 0x73, 0x8d, 0x7b, 0xe7, 0x0, 0x8, 0x9d, - 0xf4, 0xfc, 0x21, 0xa, 0x6f, 0xe1, 0x65, 0x0, 0x16, 0xcb, 0x2b, 0xc1, 0xce, 0x8f, 0xb1, 0x18, 0x0, - 0x8, 0xe5, 0x8f, 0x70, 0xf9, 0x7, 0x6f, 0x54, 0x82, 0x8c, 0xc7, 0xc5, 0x8b, 0x82}; + uint8_t pkt[] = {0x10, 0x38, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x84, 0x4b, 0x3f, 0x0, 0x8, 0x94, + 0x8b, 0xc0, 0x2b, 0xb1, 0x6f, 0xb6, 0xcd, 0x0, 0x2, 0x88, 0x78, 0x0, 0x12, 0xaa, 0xad, + 0x46, 0x39, 0xd3, 0x28, 0xd1, 0xdf, 0x40, 0x25, 0x2, 0x0, 0xaf, 0x90, 0xd5, 0x88, 0xe0, + 0x62, 0x0, 0xa, 0x58, 0x26, 0x34, 0x24, 0x23, 0x96, 0x66, 0x66, 0x63, 0x93}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6121,32 +6336,26 @@ TEST(Connect311QCTest, Encode23) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbc, 0x24, 0x26, 0xe5, 0xcc, 0x92, 0xba, 0xf4, - 0x70, 0x6, 0xa5, 0x64, 0x43, 0xc6, 0x47}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x2c, 0x6e, 0x88, 0x2b, 0x45, 0xc3, 0x88, 0x5f, - 0x4b, 0xde, 0x94, 0x84, 0x73, 0x8d, 0x7b, 0xe7}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x88, 0x78}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xaa, 0xad, 0x46, 0x39, 0xd3, 0x28, 0xd1, 0xdf, 0x40, + 0x25, 0x2, 0x0, 0xaf, 0x90, 0xd5, 0x88, 0xe0, 0x62}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 25534; - uint8_t client_id_bytes[] = {0x74, 0xb1, 0x8b, 0x2c, 0xbf, 0x8b, 0x74, 0xf4, - 0x15, 0xc, 0x8c, 0x21, 0x47, 0x83, 0x6b, 0x8d}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 19263; + uint8_t client_id_bytes[] = {0x94, 0x8b, 0xc0, 0x2b, 0xb1, 0x6f, 0xb6, 0xcd}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x9d, 0xf4, 0xfc, 0x21, 0xa, 0x6f, 0xe1, 0x65}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x58, 0x26, 0x34, 0x24, 0x23, 0x96, 0x66, 0x66, 0x63, 0x93}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xcb, 0x2b, 0xc1, 0xce, 0x8f, 0xb1, 0x18, 0x0, 0x8, 0xe5, 0x8f, - 0x70, 0xf9, 0x7, 0x6f, 0x54, 0x82, 0x8c, 0xc7, 0xc5, 0x8b, 0x82}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6155,52 +6364,72 @@ TEST(Connect311QCTest, Encode23) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\DC2K\SOH\205\130\243\197\138\251g", _password = Just -// "\203\162\176\223n\163\159\204\NAK\t+\212", _lastWill = Nothing, _cleanSession = True, _keepAlive = 31053, _connID = -// "X\134\206\232\134\243\221\DC1\252", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just +// "\169\134\229\177\141\167:\"\240_\168S\ETB~\228\190\175\174\ACK\168\191@\171\199\GSM\208h", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\173en(3\180\NAK\238\226z\SO\231\221<8u\183\188\229\221\231\131\185\v\203;", _willMsg = +// "z#W\234\STX\229\164\203\229\130\201\SOHy\205\&3\169>\205\160\203dE\ACK\255\213\164\225\ESC\163", _willProps = []}), +// _cleanSession = True, _keepAlive = 14436, _connID = +// "\"\179\&5mH+{\187\208\t`<\149\EOT\249\182\214\184\&8\198\201\139\186\&5", _properties = []} TEST(Connect311QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x2f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x79, 0x4d, 0x0, 0x9, 0x58, 0x86, 0xce, - 0xe8, 0x86, 0xf3, 0xdd, 0x11, 0xfc, 0x0, 0xa, 0x12, 0x4b, 0x1, 0xcd, 0x82, 0xf3, 0xc5, 0x8a, 0xfb, - 0x67, 0x0, 0xc, 0xcb, 0xa2, 0xb0, 0xdf, 0x6e, 0xa3, 0x9f, 0xcc, 0x15, 0x9, 0x2b, 0xd4}; + uint8_t pkt[] = {0x10, 0x5f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x38, 0x64, 0x0, 0x18, 0x22, 0xb3, 0x35, + 0x6d, 0x48, 0x2b, 0x7b, 0xbb, 0xd0, 0x9, 0x60, 0x3c, 0x95, 0x4, 0xf9, 0xb6, 0xd6, 0xb8, 0x38, 0xc6, + 0xc9, 0x8b, 0xba, 0x35, 0x0, 0x1a, 0xad, 0x65, 0x6e, 0x28, 0x33, 0xb4, 0x15, 0xee, 0xe2, 0x7a, 0xe, + 0xe7, 0xdd, 0x3c, 0x38, 0x75, 0xb7, 0xbc, 0xe5, 0xdd, 0xe7, 0x83, 0xb9, 0xb, 0xcb, 0x3b, 0x0, 0x1d, + 0x7a, 0x23, 0x57, 0xea, 0x2, 0xe5, 0xa4, 0xcb, 0xe5, 0x82, 0xc9, 0x1, 0x79, 0xcd, 0x33, 0xa9, 0x3e, + 0xcd, 0xa0, 0xcb, 0x64, 0x45, 0x6, 0xff, 0xd5, 0xa4, 0xe1, 0x1b, 0xa3}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xad, 0x65, 0x6e, 0x28, 0x33, 0xb4, 0x15, 0xee, 0xe2, 0x7a, 0xe, 0xe7, 0xdd, + 0x3c, 0x38, 0x75, 0xb7, 0xbc, 0xe5, 0xdd, 0xe7, 0x83, 0xb9, 0xb, 0xcb, 0x3b}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7a, 0x23, 0x57, 0xea, 0x2, 0xe5, 0xa4, 0xcb, 0xe5, 0x82, + 0xc9, 0x1, 0x79, 0xcd, 0x33, 0xa9, 0x3e, 0xcd, 0xa0, 0xcb, + 0x64, 0x45, 0x6, 0xff, 0xd5, 0xa4, 0xe1, 0x1b, 0xa3}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 31053; - uint8_t client_id_bytes[] = {0x58, 0x86, 0xce, 0xe8, 0x86, 0xf3, 0xdd, 0x11, 0xfc}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.keep_alive = 14436; + uint8_t client_id_bytes[] = {0x22, 0xb3, 0x35, 0x6d, 0x48, 0x2b, 0x7b, 0xbb, 0xd0, 0x9, 0x60, 0x3c, + 0x95, 0x4, 0xf9, 0xb6, 0xd6, 0xb8, 0x38, 0xc6, 0xc9, 0x8b, 0xba, 0x35}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x12, 0x4b, 0x1, 0xcd, 0x82, 0xf3, 0xc5, 0x8a, 0xfb, 0x67}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xcb, 0xa2, 0xb0, 0xdf, 0x6e, 0xa3, 0x9f, 0xcc, 0x15, 0x9, 0x2b, 0xd4}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xa9, 0x86, 0xe5, 0xb1, 0x8d, 0xa7, 0x3a, 0x22, 0xf0, 0x5f, 0xa8, 0x53, 0x17, 0x7e, + 0xe4, 0xbe, 0xaf, 0xae, 0x6, 0xa8, 0xbf, 0x40, 0xab, 0xc7, 0x1d, 0x4d, 0xd0, 0x68}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\SI\249\217\245+\148\214W4\194\166\EM\248\229\173\221\207!\207", _password = Just -// "\162\230\187s\155\185\166\184\194\DLE6", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic -// = "\NAK6\214\US\166`\243!\147\STX\254$x\152\221|]V\DC2\132\180{E#\STX|.\209\244", _willMsg = -// "\200\238p[\209Nf\186\211\186\213\164\&0\t\223\176", _willProps = []}), _cleanSession = True, _keepAlive = 12605, -// _connID = "\132\135\132`\t\238\191\184 \SOH\162", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "O\165\188\192\128\155\192a\198\EM?\198\230)}\161", _lastWill = +// Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "s\137\218\237\244]\194(\128\202w\240\147M6\232\218\245\251\&7hf\206t", _willMsg = +// "\238+y\253\141\&0--\219\143\226YM\140U\"dA\DLE\235\128", _willProps = []}), _cleanSession = False, _keepAlive = +// 3208, _connID = "\DC3P\129h", _properties = []} TEST(Connect311QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0x6a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x31, 0x3d, 0x0, 0xb, 0x84, 0x87, - 0x84, 0x60, 0x9, 0xee, 0xbf, 0xb8, 0x20, 0x1, 0xa2, 0x0, 0x1d, 0x15, 0x36, 0xd6, 0x1f, 0xa6, - 0x60, 0xf3, 0x21, 0x93, 0x2, 0xfe, 0x24, 0x78, 0x98, 0xdd, 0x7c, 0x5d, 0x56, 0x12, 0x84, 0xb4, - 0x7b, 0x45, 0x23, 0x2, 0x7c, 0x2e, 0xd1, 0xf4, 0x0, 0x10, 0xc8, 0xee, 0x70, 0x5b, 0xd1, 0x4e, - 0x66, 0xba, 0xd3, 0xba, 0xd5, 0xa4, 0x30, 0x9, 0xdf, 0xb0, 0x0, 0x13, 0xf, 0xf9, 0xd9, 0xf5, - 0x2b, 0x94, 0xd6, 0x57, 0x34, 0xc2, 0xa6, 0x19, 0xf8, 0xe5, 0xad, 0xdd, 0xcf, 0x21, 0xcf, 0x0, - 0xb, 0xa2, 0xe6, 0xbb, 0x73, 0x9b, 0xb9, 0xa6, 0xb8, 0xc2, 0x10, 0x36}; + uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2c, 0xc, 0x88, 0x0, 0x4, 0x13, 0x50, 0x81, + 0x68, 0x0, 0x18, 0x73, 0x89, 0xda, 0xed, 0xf4, 0x5d, 0xc2, 0x28, 0x80, 0xca, 0x77, 0xf0, 0x93, 0x4d, + 0x36, 0xe8, 0xda, 0xf5, 0xfb, 0x37, 0x68, 0x66, 0xce, 0x74, 0x0, 0x15, 0xee, 0x2b, 0x79, 0xfd, 0x8d, + 0x30, 0x2d, 0x2d, 0xdb, 0x8f, 0xe2, 0x59, 0x4d, 0x8c, 0x55, 0x22, 0x64, 0x41, 0x10, 0xeb, 0x80}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6211,12 +6440,12 @@ TEST(Connect311QCTest, Encode25) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x15, 0x36, 0xd6, 0x1f, 0xa6, 0x60, 0xf3, 0x21, 0x93, 0x2, 0xfe, 0x24, 0x78, 0x98, 0xdd, - 0x7c, 0x5d, 0x56, 0x12, 0x84, 0xb4, 0x7b, 0x45, 0x23, 0x2, 0x7c, 0x2e, 0xd1, 0xf4}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc8, 0xee, 0x70, 0x5b, 0xd1, 0x4e, 0x66, 0xba, - 0xd3, 0xba, 0xd5, 0xa4, 0x30, 0x9, 0xdf, 0xb0}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x73, 0x89, 0xda, 0xed, 0xf4, 0x5d, 0xc2, 0x28, 0x80, 0xca, 0x77, 0xf0, + 0x93, 0x4d, 0x36, 0xe8, 0xda, 0xf5, 0xfb, 0x37, 0x68, 0x66, 0xce, 0x74}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xee, 0x2b, 0x79, 0xfd, 0x8d, 0x30, 0x2d, 0x2d, 0xdb, 0x8f, 0xe2, + 0x59, 0x4d, 0x8c, 0x55, 0x22, 0x64, 0x41, 0x10, 0xeb, 0x80}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -6224,17 +6453,14 @@ TEST(Connect311QCTest, Encode25) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 12605; - uint8_t client_id_bytes[] = {0x84, 0x87, 0x84, 0x60, 0x9, 0xee, 0xbf, 0xb8, 0x20, 0x1, 0xa2}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 3208; + uint8_t client_id_bytes[] = {0x13, 0x50, 0x81, 0x68}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf, 0xf9, 0xd9, 0xf5, 0x2b, 0x94, 0xd6, 0x57, 0x34, 0xc2, - 0xa6, 0x19, 0xf8, 0xe5, 0xad, 0xdd, 0xcf, 0x21, 0xcf}; - lwmqtt_string_t username = {19, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xa2, 0xe6, 0xbb, 0x73, 0x9b, 0xb9, 0xa6, 0xb8, 0xc2, 0x10, 0x36}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x4f, 0xa5, 0xbc, 0xc0, 0x80, 0x9b, 0xc0, 0x61, + 0xc6, 0x19, 0x3f, 0xc6, 0xe6, 0x29, 0x7d, 0xa1}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6244,15 +6470,20 @@ TEST(Connect311QCTest, Encode25) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\222\FS\NUL", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "\236?v#\231\182\221\157[=\139|\191\209\208\147\164?\221=)\ETB?\217\223e", _willMsg = -// "n\212", _willProps = []}), _cleanSession = False, _keepAlive = 12313, _connID = "%W\235 -// )\183\218\188oO\152j\237\b!", _properties = []} +// ConnectRequest {_username = Just "\149\151\139\195\172z\255\139u#\163\fg,\230|\158{", _password = Just +// "Z\165\208\RS\195i\201D9m(Z ,\165\217Aa\137\ENQ\SO\180", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "\141-\179\ENQl~\217\164\234\131\134\134\207X", _willMsg = +// ";\NUL\DEL\NUL\RSHW\212\230\191L\211s)\181j\203\158\229\137", _willProps = []}), _cleanSession = True, _keepAlive = +// 32044, _connID = "\248\r\241\217\233\199#\171\195\&6}Wu\226i\209\194\149\251\&6X$\144\230", _properties = []} TEST(Connect311QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb4, 0x30, 0x19, 0x0, 0xf, 0x25, 0x57, 0xeb, - 0x20, 0x29, 0xb7, 0xda, 0xbc, 0x6f, 0x4f, 0x98, 0x6a, 0xed, 0x8, 0x21, 0x0, 0x1a, 0xec, 0x3f, 0x76, - 0x23, 0xe7, 0xb6, 0xdd, 0x9d, 0x5b, 0x3d, 0x8b, 0x7c, 0xbf, 0xd1, 0xd0, 0x93, 0xa4, 0x3f, 0xdd, 0x3d, - 0x29, 0x17, 0x3f, 0xd9, 0xdf, 0x65, 0x0, 0x2, 0x6e, 0xd4, 0x0, 0x3, 0xde, 0x1c, 0x0}; + uint8_t pkt[] = {0x10, 0x76, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe6, 0x7d, 0x2c, 0x0, 0x18, 0xf8, + 0xd, 0xf1, 0xd9, 0xe9, 0xc7, 0x23, 0xab, 0xc3, 0x36, 0x7d, 0x57, 0x75, 0xe2, 0x69, 0xd1, + 0xc2, 0x95, 0xfb, 0x36, 0x58, 0x24, 0x90, 0xe6, 0x0, 0xe, 0x8d, 0x2d, 0xb3, 0x5, 0x6c, + 0x7e, 0xd9, 0xa4, 0xea, 0x83, 0x86, 0x86, 0xcf, 0x58, 0x0, 0x14, 0x3b, 0x0, 0x7f, 0x0, + 0x1e, 0x48, 0x57, 0xd4, 0xe6, 0xbf, 0x4c, 0xd3, 0x73, 0x29, 0xb5, 0x6a, 0xcb, 0x9e, 0xe5, + 0x89, 0x0, 0x12, 0x95, 0x97, 0x8b, 0xc3, 0xac, 0x7a, 0xff, 0x8b, 0x75, 0x23, 0xa3, 0xc, + 0x67, 0x2c, 0xe6, 0x7c, 0x9e, 0x7b, 0x0, 0x16, 0x5a, 0xa5, 0xd0, 0x1e, 0xc3, 0x69, 0xc9, + 0x44, 0x39, 0x6d, 0x28, 0x5a, 0x20, 0x2c, 0xa5, 0xd9, 0x41, 0x61, 0x89, 0x5, 0xe, 0xb4}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6263,26 +6494,32 @@ TEST(Connect311QCTest, Encode26) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xec, 0x3f, 0x76, 0x23, 0xe7, 0xb6, 0xdd, 0x9d, 0x5b, 0x3d, 0x8b, 0x7c, 0xbf, - 0xd1, 0xd0, 0x93, 0xa4, 0x3f, 0xdd, 0x3d, 0x29, 0x17, 0x3f, 0xd9, 0xdf, 0x65}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6e, 0xd4}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x8d, 0x2d, 0xb3, 0x5, 0x6c, 0x7e, 0xd9, 0xa4, 0xea, 0x83, 0x86, 0x86, 0xcf, 0x58}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3b, 0x0, 0x7f, 0x0, 0x1e, 0x48, 0x57, 0xd4, 0xe6, 0xbf, + 0x4c, 0xd3, 0x73, 0x29, 0xb5, 0x6a, 0xcb, 0x9e, 0xe5, 0x89}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12313; - uint8_t client_id_bytes[] = {0x25, 0x57, 0xeb, 0x20, 0x29, 0xb7, 0xda, 0xbc, 0x6f, 0x4f, 0x98, 0x6a, 0xed, 0x8, 0x21}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 32044; + uint8_t client_id_bytes[] = {0xf8, 0xd, 0xf1, 0xd9, 0xe9, 0xc7, 0x23, 0xab, 0xc3, 0x36, 0x7d, 0x57, + 0x75, 0xe2, 0x69, 0xd1, 0xc2, 0x95, 0xfb, 0x36, 0x58, 0x24, 0x90, 0xe6}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xde, 0x1c, 0x0}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x95, 0x97, 0x8b, 0xc3, 0xac, 0x7a, 0xff, 0x8b, 0x75, + 0x23, 0xa3, 0xc, 0x67, 0x2c, 0xe6, 0x7c, 0x9e, 0x7b}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x5a, 0xa5, 0xd0, 0x1e, 0xc3, 0x69, 0xc9, 0x44, 0x39, 0x6d, 0x28, + 0x5a, 0x20, 0x2c, 0xa5, 0xd9, 0x41, 0x61, 0x89, 0x5, 0xe, 0xb4}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6291,18 +6528,19 @@ TEST(Connect311QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\ENQ\177\248\150\234\US\132\246q", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\183\FS\DC1\132\182jmFH\GS\201\141\226\&3\n", _willMsg = -// "\134\204\FS{\151\206b\190e\177\149\v\146\182\240\197\189NN\183\242\207\\BM\fs\198H", _willProps = []}), -// _cleanSession = True, _keepAlive = 13514, _connID = "\161 \149\244\226\242\217\139I -// p\234\"\249\DLE\216>p\SOV\CAN\207\131", _properties = []} +// ConnectRequest {_username = Just "|\236r\252\&0Ku{\146\ETX\ACKm\178\134\193P\SUB", _password = Just +// "mYo\132\144\131\150'\206lC{\157\159\174\ETX", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, +// _willTopic = "\129\242\250\251\220\214\242\EOTx\180\v4H\156w\139\247zR\199u\172r\136\155\198\SUB", _willMsg = +// "\166V\216\GS\135B\DC4\223\177\149\223\195\178\NUL\DLER\206/Q'O\128-\EOT\134", _willProps = []}), _cleanSession = +// False, _keepAlive = 12650, _connID = "\180N\165", _properties = []} TEST(Connect311QCTest, Encode27) { - uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x34, 0xca, 0x0, 0x17, 0xa1, - 0x20, 0x95, 0xf4, 0xe2, 0xf2, 0xd9, 0x8b, 0x49, 0x20, 0x70, 0xea, 0x22, 0xf9, 0x10, 0xd8, - 0x3e, 0x70, 0xe, 0x56, 0x18, 0xcf, 0x83, 0x0, 0xf, 0xb7, 0x1c, 0x11, 0x84, 0xb6, 0x6a, - 0x6d, 0x46, 0x48, 0x1d, 0xc9, 0x8d, 0xe2, 0x33, 0xa, 0x0, 0x1d, 0x86, 0xcc, 0x1c, 0x7b, - 0x97, 0xce, 0x62, 0xbe, 0x65, 0xb1, 0x95, 0xb, 0x92, 0xb6, 0xf0, 0xc5, 0xbd, 0x4e, 0x4e, - 0xb7, 0xf2, 0xcf, 0x5c, 0x42, 0x4d, 0xc, 0x73, 0xc6, 0x48}; + uint8_t pkt[] = {0x10, 0x6c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x31, 0x6a, 0x0, 0x3, 0xb4, 0x4e, + 0xa5, 0x0, 0x1b, 0x81, 0xf2, 0xfa, 0xfb, 0xdc, 0xd6, 0xf2, 0x4, 0x78, 0xb4, 0xb, 0x34, 0x48, + 0x9c, 0x77, 0x8b, 0xf7, 0x7a, 0x52, 0xc7, 0x75, 0xac, 0x72, 0x88, 0x9b, 0xc6, 0x1a, 0x0, 0x19, + 0xa6, 0x56, 0xd8, 0x1d, 0x87, 0x42, 0x14, 0xdf, 0xb1, 0x95, 0xdf, 0xc3, 0xb2, 0x0, 0x10, 0x52, + 0xce, 0x2f, 0x51, 0x27, 0x4f, 0x80, 0x2d, 0x4, 0x86, 0x0, 0x11, 0x7c, 0xec, 0x72, 0xfc, 0x30, + 0x4b, 0x75, 0x7b, 0x92, 0x3, 0x6, 0x6d, 0xb2, 0x86, 0xc1, 0x50, 0x1a, 0x0, 0x10, 0x6d, 0x59, + 0x6f, 0x84, 0x90, 0x83, 0x96, 0x27, 0xce, 0x6c, 0x43, 0x7b, 0x9d, 0x9f, 0xae, 0x3}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6313,28 +6551,31 @@ TEST(Connect311QCTest, Encode27) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb7, 0x1c, 0x11, 0x84, 0xb6, 0x6a, 0x6d, 0x46, - 0x48, 0x1d, 0xc9, 0x8d, 0xe2, 0x33, 0xa}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x86, 0xcc, 0x1c, 0x7b, 0x97, 0xce, 0x62, 0xbe, 0x65, 0xb1, - 0x95, 0xb, 0x92, 0xb6, 0xf0, 0xc5, 0xbd, 0x4e, 0x4e, 0xb7, - 0xf2, 0xcf, 0x5c, 0x42, 0x4d, 0xc, 0x73, 0xc6, 0x48}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x81, 0xf2, 0xfa, 0xfb, 0xdc, 0xd6, 0xf2, 0x4, 0x78, 0xb4, 0xb, 0x34, 0x48, 0x9c, + 0x77, 0x8b, 0xf7, 0x7a, 0x52, 0xc7, 0x75, 0xac, 0x72, 0x88, 0x9b, 0xc6, 0x1a}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa6, 0x56, 0xd8, 0x1d, 0x87, 0x42, 0x14, 0xdf, 0xb1, 0x95, 0xdf, 0xc3, 0xb2, + 0x0, 0x10, 0x52, 0xce, 0x2f, 0x51, 0x27, 0x4f, 0x80, 0x2d, 0x4, 0x86}; + lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 13514; - uint8_t client_id_bytes[] = {0xa1, 0x20, 0x95, 0xf4, 0xe2, 0xf2, 0xd9, 0x8b, 0x49, 0x20, 0x70, 0xea, - 0x22, 0xf9, 0x10, 0xd8, 0x3e, 0x70, 0xe, 0x56, 0x18, 0xcf, 0x83}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 12650; + uint8_t client_id_bytes[] = {0xb4, 0x4e, 0xa5}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x5, 0xb1, 0xf8, 0x96, 0xea, 0x1f, 0x84, 0xf6, 0x71}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x7c, 0xec, 0x72, 0xfc, 0x30, 0x4b, 0x75, 0x7b, 0x92, + 0x3, 0x6, 0x6d, 0xb2, 0x86, 0xc1, 0x50, 0x1a}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x6d, 0x59, 0x6f, 0x84, 0x90, 0x83, 0x96, 0x27, + 0xce, 0x6c, 0x43, 0x7b, 0x9d, 0x9f, 0xae, 0x3}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6344,71 +6585,41 @@ TEST(Connect311QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\218r\168\139R\217\209\a@\135\239\135\152\130\140\156\230\152>\156\160", _password -// = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\220\218\137\179z\158\vc\CAN\128\SUBU\DC3\175n\201P\218B", _willMsg = -// "\218\174\233=\151\&7\204\204\181\t\146\180O\189\173.`\244\151\180I@0\252", _willProps = []}), _cleanSession = True, -// _keepAlive = 5227, _connID = "_\201\&2\202<\161\171\209\244\241\165", _properties = []} +// ConnectRequest {_username = Just "\176\SUB(", _password = Nothing, _lastWill = Nothing, _cleanSession = False, +// _keepAlive = 9985, _connID = "\144\&3\142\215M", _properties = []} TEST(Connect311QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0x5d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xae, 0x14, 0x6b, 0x0, 0xb, 0x5f, 0xc9, - 0x32, 0xca, 0x3c, 0xa1, 0xab, 0xd1, 0xf4, 0xf1, 0xa5, 0x0, 0x13, 0xdc, 0xda, 0x89, 0xb3, 0x7a, - 0x9e, 0xb, 0x63, 0x18, 0x80, 0x1a, 0x55, 0x13, 0xaf, 0x6e, 0xc9, 0x50, 0xda, 0x42, 0x0, 0x18, - 0xda, 0xae, 0xe9, 0x3d, 0x97, 0x37, 0xcc, 0xcc, 0xb5, 0x9, 0x92, 0xb4, 0x4f, 0xbd, 0xad, 0x2e, - 0x60, 0xf4, 0x97, 0xb4, 0x49, 0x40, 0x30, 0xfc, 0x0, 0x15, 0xda, 0x72, 0xa8, 0x8b, 0x52, 0xd9, - 0xd1, 0x7, 0x40, 0x87, 0xef, 0x87, 0x98, 0x82, 0x8c, 0x9c, 0xe6, 0x98, 0x3e, 0x9c, 0xa0}; + uint8_t pkt[] = {0x10, 0x16, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x27, 0x1, + 0x0, 0x5, 0x90, 0x33, 0x8e, 0xd7, 0x4d, 0x0, 0x3, 0xb0, 0x1a, 0x28}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xdc, 0xda, 0x89, 0xb3, 0x7a, 0x9e, 0xb, 0x63, 0x18, 0x80, - 0x1a, 0x55, 0x13, 0xaf, 0x6e, 0xc9, 0x50, 0xda, 0x42}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xda, 0xae, 0xe9, 0x3d, 0x97, 0x37, 0xcc, 0xcc, 0xb5, 0x9, 0x92, 0xb4, - 0x4f, 0xbd, 0xad, 0x2e, 0x60, 0xf4, 0x97, 0xb4, 0x49, 0x40, 0x30, 0xfc}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 5227; - uint8_t client_id_bytes[] = {0x5f, 0xc9, 0x32, 0xca, 0x3c, 0xa1, 0xab, 0xd1, 0xf4, 0xf1, 0xa5}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 9985; + uint8_t client_id_bytes[] = {0x90, 0x33, 0x8e, 0xd7, 0x4d}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xda, 0x72, 0xa8, 0x8b, 0x52, 0xd9, 0xd1, 0x7, 0x40, 0x87, 0xef, - 0x87, 0x98, 0x82, 0x8c, 0x9c, 0xe6, 0x98, 0x3e, 0x9c, 0xa0}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb0, 0x1a, 0x28}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\SO\"\229\f\229\n\211x\145\nR\255A\196y\255\255\222\&1+\192nU\183\230", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\b)e\236\251\251F\231*\144\171\179\130", _willMsg = +// "\224$\244h\238M\173a\166,{\149\167\153\201{\142.\175\&3A=\249\214\DC1\254oO\186", _willProps = []}), _cleanSession = +// False, _keepAlive = 26056, _connID = "c\EM'\202qq<\213", _properties = []} TEST(Connect311QCTest, Encode30) { - uint8_t pkt[] = {0x10, 0x5e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x59, 0xd9, 0x0, 0x4, 0x4f, 0xf5, - 0x69, 0x1b, 0x0, 0x1e, 0x38, 0x63, 0x2d, 0xd1, 0x9e, 0x36, 0x8f, 0x43, 0x14, 0xda, 0x9a, 0xba, - 0x79, 0xc9, 0x1e, 0x9d, 0x4e, 0x9e, 0x7a, 0xb3, 0x70, 0x21, 0x69, 0xb0, 0x42, 0x85, 0x5d, 0xc1, - 0xca, 0x11, 0x0, 0x9, 0xa1, 0x6b, 0x56, 0x3b, 0xe7, 0xc8, 0x88, 0xc3, 0xf, 0x0, 0x18, 0x98, - 0xdd, 0xea, 0x71, 0xcb, 0x47, 0xd9, 0xc, 0x4e, 0x74, 0xe4, 0xd2, 0x96, 0x88, 0xb6, 0x69, 0x29, - 0xca, 0x8a, 0x98, 0xe7, 0xad, 0x91, 0xd6, 0x0, 0x7, 0x27, 0xb4, 0x8b, 0xc6, 0x53, 0x40, 0xd8}; + uint8_t pkt[] = {0x10, 0x52, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x65, 0xc8, 0x0, 0x8, 0x63, 0x19, 0x27, + 0xca, 0x71, 0x71, 0x3c, 0xd5, 0x0, 0xd, 0x8, 0x29, 0x65, 0xec, 0xfb, 0xfb, 0x46, 0xe7, 0x2a, 0x90, + 0xab, 0xb3, 0x82, 0x0, 0x1d, 0xe0, 0x24, 0xf4, 0x68, 0xee, 0x4d, 0xad, 0x61, 0xa6, 0x2c, 0x7b, 0x95, + 0xa7, 0x99, 0xc9, 0x7b, 0x8e, 0x2e, 0xaf, 0x33, 0x41, 0x3d, 0xf9, 0xd6, 0x11, 0xfe, 0x6f, 0x4f, 0xba, + 0x0, 0x1, 0x22, 0x0, 0xb, 0xdf, 0x3e, 0xff, 0xde, 0x31, 0x2b, 0xc0, 0x6e, 0x55, 0xb7, 0xe6}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6475,30 +6674,29 @@ TEST(Connect311QCTest, Encode30) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x38, 0x63, 0x2d, 0xd1, 0x9e, 0x36, 0x8f, 0x43, 0x14, 0xda, - 0x9a, 0xba, 0x79, 0xc9, 0x1e, 0x9d, 0x4e, 0x9e, 0x7a, 0xb3, - 0x70, 0x21, 0x69, 0xb0, 0x42, 0x85, 0x5d, 0xc1, 0xca, 0x11}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa1, 0x6b, 0x56, 0x3b, 0xe7, 0xc8, 0x88, 0xc3, 0xf}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x8, 0x29, 0x65, 0xec, 0xfb, 0xfb, 0x46, 0xe7, 0x2a, 0x90, 0xab, 0xb3, 0x82}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe0, 0x24, 0xf4, 0x68, 0xee, 0x4d, 0xad, 0x61, 0xa6, 0x2c, + 0x7b, 0x95, 0xa7, 0x99, 0xc9, 0x7b, 0x8e, 0x2e, 0xaf, 0x33, + 0x41, 0x3d, 0xf9, 0xd6, 0x11, 0xfe, 0x6f, 0x4f, 0xba}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 23001; - uint8_t client_id_bytes[] = {0x4f, 0xf5, 0x69, 0x1b}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 26056; + uint8_t client_id_bytes[] = {0x63, 0x19, 0x27, 0xca, 0x71, 0x71, 0x3c, 0xd5}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x98, 0xdd, 0xea, 0x71, 0xcb, 0x47, 0xd9, 0xc, 0x4e, 0x74, 0xe4, 0xd2, - 0x96, 0x88, 0xb6, 0x69, 0x29, 0xca, 0x8a, 0x98, 0xe7, 0xad, 0x91, 0xd6}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x22}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x27, 0xb4, 0x8b, 0xc6, 0x53, 0x40, 0xd8}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xdf, 0x3e, 0xff, 0xde, 0x31, 0x2b, 0xc0, 0x6e, 0x55, 0xb7, 0xe6}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6508,172 +6706,272 @@ TEST(Connect311QCTest, Encode30) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\DLEVW\161\173W!+\154\235\a\169\136(K\152\224\190I4y", -// _lastWill = Nothing, _cleanSession = True, _keepAlive = 3940, _connID = "\147b\SOH\234HL\237", _properties = -// [PropUserProperty "\229\209\255\159(\208\134\128'\139\240\217J\223T" "K\192\133"]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "\STX'd2\162\&8\201\179\247\166Y\212\\E\134\229", _willMsg = +// "\STX\227Q\213\190e/R\238\220$q\218Y~\146:~\ESCo\213\150\243\EM\156+r", _willProps = [PropAuthenticationData +// "\ETXF\215R\tc\193\146\155)L)t\228\209\160\&3",PropResponseInformation "\164=\207\DC1F#'",PropWillDelayInterval +// 28458,PropServerReference "rLeCgc9\145\228\139\222\\T\191\152ae\210\200$\253^\SI\212\207\183",PropReceiveMaximum +// 3407,PropContentType "\241\244\NAK\172u\202",PropMessageExpiryInterval 10130,PropTopicAlias +// 24003,PropWildcardSubscriptionAvailable 102,PropSharedSubscriptionAvailable 227,PropPayloadFormatIndicator +// 101,PropResponseTopic "e\233\141\253c{u\233F\157",PropSubscriptionIdentifier 29,PropSessionExpiryInterval +// 23489,PropTopicAlias 9645,PropTopicAliasMaximum 18361,PropResponseInformation "5Q\195[\231\v\220\175",PropMaximumQoS +// 161,PropWillDelayInterval 20412,PropSubscriptionIdentifier 22,PropSharedSubscriptionAvailable 163]}), _cleanSession = +// True, _keepAlive = 14707, _connID = "\r\239\133\224\t\138Z\SOHVQ\194n\b\"", _properties = [PropMessageExpiryInterval +// 17304,PropSharedSubscriptionAvailable 164,PropSubscriptionIdentifier 9,PropPayloadFormatIndicator +// 139,PropRequestResponseInformation 235,PropSessionExpiryInterval 29568,PropSharedSubscriptionAvailable +// 152,PropSubscriptionIdentifierAvailable 169,PropWildcardSubscriptionAvailable 44,PropMessageExpiryInterval +// 3448,PropSubscriptionIdentifierAvailable 209,PropMaximumPacketSize 15659,PropAuthenticationData +// "\SOHi<\231\155\175\202p\SUB\141\139,",PropContentType "\177\224\226",PropRequestResponseInformation +// 17,PropRetainAvailable 45,PropWillDelayInterval 25775,PropAssignedClientIdentifier +// "E\SYN\152\211\ACK\DLEQyB\ETB",PropWildcardSubscriptionAvailable 183,PropMaximumQoS 95,PropPayloadFormatIndicator +// 17,PropUserProperty "\204\EOT=*a\194\FSu\219" "\190\SUB\152*\f\185\210\192G",PropResponseTopic +// "\137B\219\251\200\RS\vO#\170r\162\SYNK\168\193\163Z\203$\249\130\218>\172",PropCorrelationData +// "\140ge\249\150\139]\140?\147",PropMessageExpiryInterval 2846,PropSubscriptionIdentifier 24,PropSessionExpiryInterval +// 13166,PropSubscriptionIdentifierAvailable 126,PropTopicAliasMaximum 21233,PropAuthenticationMethod +// "\203\165\NUL\CAN\237M\153M\198\213"]} TEST(Connect5QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x42, 0xf, 0x64, 0x17, 0x26, - 0x0, 0xf, 0xe5, 0xd1, 0xff, 0x9f, 0x28, 0xd0, 0x86, 0x80, 0x27, 0x8b, 0xf0, 0xd9, - 0x4a, 0xdf, 0x54, 0x0, 0x3, 0x4b, 0xc0, 0x85, 0x0, 0x7, 0x93, 0x62, 0x1, 0xea, - 0x48, 0x4c, 0xed, 0x0, 0x15, 0x10, 0x56, 0x57, 0xa1, 0xad, 0x57, 0x21, 0x2b, 0x9a, - 0xeb, 0x7, 0xa9, 0x88, 0x28, 0x4b, 0x98, 0xe0, 0xbe, 0x49, 0x34, 0x79}; + uint8_t pkt[] = { + 0x10, 0x8a, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe, 0x39, 0x73, 0xb3, 0x1, 0x2, 0x0, 0x0, 0x43, + 0x98, 0x2a, 0xa4, 0xb, 0x9, 0x1, 0x8b, 0x19, 0xeb, 0x11, 0x0, 0x0, 0x73, 0x80, 0x2a, 0x98, 0x29, 0xa9, 0x28, + 0x2c, 0x2, 0x0, 0x0, 0xd, 0x78, 0x29, 0xd1, 0x27, 0x0, 0x0, 0x3d, 0x2b, 0x16, 0x0, 0xc, 0x1, 0x69, 0x3c, + 0xe7, 0x9b, 0xaf, 0xca, 0x70, 0x1a, 0x8d, 0x8b, 0x2c, 0x3, 0x0, 0x3, 0xb1, 0xe0, 0xe2, 0x19, 0x11, 0x25, 0x2d, + 0x18, 0x0, 0x0, 0x64, 0xaf, 0x12, 0x0, 0xa, 0x45, 0x16, 0x98, 0xd3, 0x6, 0x10, 0x51, 0x79, 0x42, 0x17, 0x28, + 0xb7, 0x24, 0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x15, + 0xac, 0x75, 0xca, 0x2, 0x0, 0x0, 0x27, 0x92, 0x23, 0x5d, 0xc3, 0x28, 0x66, 0x2a, 0xe3, 0x1, 0x65, 0x8, 0x0, + 0xa, 0x65, 0xe9, 0x8d, 0xfd, 0x63, 0x7b, 0x75, 0xe9, 0x46, 0x9d, 0xb, 0x1d, 0x11, 0x0, 0x0, 0x5b, 0xc1, 0x23, + 0x25, 0xad, 0x22, 0x47, 0xb9, 0x1a, 0x0, 0x8, 0x35, 0x51, 0xc3, 0x5b, 0xe7, 0xb, 0xdc, 0xaf, 0x24, 0xa1, 0x18, + 0x0, 0x0, 0x4f, 0xbc, 0xb, 0x16, 0x2a, 0xa3, 0x0, 0x10, 0x2, 0x27, 0x64, 0x32, 0xa2, 0x38, 0xc9, 0xb3, 0xf7, + 0xa6, 0x59, 0xd4, 0x5c, 0x45, 0x86, 0xe5, 0x0, 0x1b, 0x2, 0xe3, 0x51, 0xd5, 0xbe, 0x65, 0x2f, 0x52, 0xee, 0xdc, + 0x24, 0x71, 0xda, 0x59, 0x7e, 0x92, 0x3a, 0x7e, 0x1b, 0x6f, 0xd5, 0x96, 0xf3, 0x19, 0x9c, 0x2b, 0x72}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x4b, 0xc0, 0x85}; - uint8_t bytesprops0[] = {0xe5, 0xd1, 0xff, 0x9f, 0x28, 0xd0, 0x86, 0x80, 0x27, 0x8b, 0xf0, 0xd9, 0x4a, 0xdf, 0x54}; + uint8_t bytesprops0[] = {0x1, 0x69, 0x3c, 0xe7, 0x9b, 0xaf, 0xca, 0x70, 0x1a, 0x8d, 0x8b, 0x2c}; + uint8_t bytesprops1[] = {0xb1, 0xe0, 0xe2}; + uint8_t bytesprops2[] = {0x45, 0x16, 0x98, 0xd3, 0x6, 0x10, 0x51, 0x79, 0x42, 0x17}; + uint8_t bytesprops4[] = {0xbe, 0x1a, 0x98, 0x2a, 0xc, 0xb9, 0xd2, 0xc0, 0x47}; + uint8_t bytesprops3[] = {0xcc, 0x4, 0x3d, 0x2a, 0x61, 0xc2, 0x1c, 0x75, 0xdb}; + uint8_t bytesprops5[] = {0x89, 0x42, 0xdb, 0xfb, 0xc8, 0x1e, 0xb, 0x4f, 0x23, 0xaa, 0x72, 0xa2, 0x16, + 0x4b, 0xa8, 0xc1, 0xa3, 0x5a, 0xcb, 0x24, 0xf9, 0x82, 0xda, 0x3e, 0xac}; + uint8_t bytesprops6[] = {0x8c, 0x67, 0x65, 0xf9, 0x96, 0x8b, 0x5d, 0x8c, 0x3f, 0x93}; + uint8_t bytesprops7[] = {0xcb, 0xa5, 0x0, 0x18, 0xed, 0x4d, 0x99, 0x4d, 0xc6, 0xd5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {3, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17304}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29568}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3448}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15659}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25775}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops3}, .v = {9, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2846}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13166}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21233}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x3, 0x46, 0xd7, 0x52, 0x9, 0x63, 0xc1, 0x92, 0x9b, + 0x29, 0x4c, 0x29, 0x74, 0xe4, 0xd1, 0xa0, 0x33}; + uint8_t byteswillprops1[] = {0xa4, 0x3d, 0xcf, 0x11, 0x46, 0x23, 0x27}; + uint8_t byteswillprops2[] = {0x72, 0x4c, 0x65, 0x43, 0x67, 0x63, 0x39, 0x91, 0xe4, 0x8b, 0xde, 0x5c, 0x54, + 0xbf, 0x98, 0x61, 0x65, 0xd2, 0xc8, 0x24, 0xfd, 0x5e, 0xf, 0xd4, 0xcf, 0xb7}; + uint8_t byteswillprops3[] = {0xf1, 0xf4, 0x15, 0xac, 0x75, 0xca}; + uint8_t byteswillprops4[] = {0x65, 0xe9, 0x8d, 0xfd, 0x63, 0x7b, 0x75, 0xe9, 0x46, 0x9d}; + uint8_t byteswillprops5[] = {0x35, 0x51, 0xc3, 0x5b, 0xe7, 0xb, 0xdc, 0xaf}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28458}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3407}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10130}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24003}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23489}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9645}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18361}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20412}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 163}}, + }; + + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2, 0x27, 0x64, 0x32, 0xa2, 0x38, 0xc9, 0xb3, + 0xf7, 0xa6, 0x59, 0xd4, 0x5c, 0x45, 0x86, 0xe5}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2, 0xe3, 0x51, 0xd5, 0xbe, 0x65, 0x2f, 0x52, 0xee, 0xdc, 0x24, 0x71, 0xda, 0x59, + 0x7e, 0x92, 0x3a, 0x7e, 0x1b, 0x6f, 0xd5, 0x96, 0xf3, 0x19, 0x9c, 0x2b, 0x72}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 3940; - uint8_t client_id_bytes[] = {0x93, 0x62, 0x1, 0xea, 0x48, 0x4c, 0xed}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.keep_alive = 14707; + uint8_t client_id_bytes[] = {0xd, 0xef, 0x85, 0xe0, 0x9, 0x8a, 0x5a, 0x1, 0x56, 0x51, 0xc2, 0x6e, 0x8, 0x22}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x10, 0x56, 0x57, 0xa1, 0xad, 0x57, 0x21, 0x2b, 0x9a, 0xeb, 0x7, - 0xa9, 0x88, 0x28, 0x4b, 0x98, 0xe0, 0xbe, 0x49, 0x34, 0x79}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\232f;/", _password = Just -// "T'\248\144\179\155V\209\NAK$l\134\169\165\244_\ACK\aa\US", _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS1, _willTopic = "h\165{\211B\214\169W\237", _willMsg = "", _willProps = [PropReasonString "\181I\231 -// \176\202\SI\218\160\177",PropSubscriptionIdentifier 6,PropCorrelationData -// "\171\237\&89\223.",PropPayloadFormatIndicator 60,PropRequestProblemInformation 29,PropServerReference -// "\189\252[\183\226\&1>\218\ACK\138:\183m@\SI\153[\SOH\150F\206\225",PropResponseTopic -// "\EMv\205\SOH",PropRequestProblemInformation 111,PropPayloadFormatIndicator 254,PropReasonString -// "\223~\166\171\189\179py\195\203\171",PropContentType -// "r\203S:(\n\SYNy\SUB/\n\178>8o\183\218\254\237Ie\192\RS];\222",PropSharedSubscriptionAvailable -// 28,PropTopicAliasMaximum 23838,PropMessageExpiryInterval 23226,PropTopicAlias 25172,PropUserProperty -// ";\254\128\220\DEL\130hZ\134" "R'\STXM",PropAssignedClientIdentifier -// "\139\235\158\153\SYN\209D\183T\SO\235\192D\166;*\151\&3\170\221b\177\218",PropSharedSubscriptionAvailable -// 198,PropTopicAlias 2061,PropPayloadFormatIndicator 216,PropTopicAliasMaximum 20856,PropSubscriptionIdentifier -// 25,PropAuthenticationMethod ", \169\160\&6\157\155\228",PropSubscriptionIdentifier 32]}), _cleanSession = False, -// _keepAlive = 13091, _connID = "k!a\t\182\181\230\207<\SUB\251\243b\250\216\131H", _properties = [PropCorrelationData -// "\211\164\134\176\182\163\EOTk\ESC\207:\178H\227\129Y\176\244\216\229t\128",PropServerReference -// "\SIT\255\132\203G}\DLEz\ETBzv\197p\153\ACK\144",PropContentType -// "\249\193\171n\204\ETB\164\200\185>\152\254\NAK\221E\163\209",PropSubscriptionIdentifierAvailable -// 135,PropPayloadFormatIndicator 87,PropWildcardSubscriptionAvailable 155,PropRequestProblemInformation -// 52,PropAuthenticationData "\227\216"]} +// ConnectRequest {_username = Nothing, _password = Just "\175\223\237\151\165\143\181\186", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\224\241\206\223", _willMsg = "<\185B\DC1", _willProps = +// [PropMessageExpiryInterval 1034,PropSessionExpiryInterval 31898,PropResponseTopic +// "\210v\SO\SUBo\176\252D\254E\201\249\215",PropReasonString +// "\160\149\135=Y\158\196\164U\181\234\146\SUB\254\165\&5\155\142",PropRequestProblemInformation +// 101,PropRequestProblemInformation 176,PropWildcardSubscriptionAvailable 20,PropWillDelayInterval +// 4616,PropRequestResponseInformation 145,PropWillDelayInterval 18288,PropMaximumQoS 156,PropPayloadFormatIndicator +// 62,PropRequestProblemInformation 18,PropSharedSubscriptionAvailable 115,PropTopicAliasMaximum +// 22616,PropResponseInformation +// "\DC2\175\214I\187\207\223\163\CAN\152\ACK\233\146\212\243\ACKz\EOT\SUB_p\133O4\129",PropTopicAlias +// 20857,PropMaximumQoS 196,PropReasonString "h\US\236\151=n\187\231\191",PropReceiveMaximum +// 19853,PropSubscriptionIdentifier 9,PropMaximumPacketSize 19027,PropContentType "\b\222\232\167?\RS\235\142\166"]}), +// _cleanSession = True, _keepAlive = 12709, _connID = "qR&\218b\224.r|a\206\139\226\174(\216\EM\193", _properties = +// [PropAuthenticationMethod "(\181n\166?J(\193mV\209\EOT\ETBf\STX\237\186",PropWildcardSubscriptionAvailable +// 1,PropMaximumPacketSize 21071,PropTopicAliasMaximum 31849,PropRequestResponseInformation 197,PropTopicAlias +// 8324,PropResponseInformation "\206\134T\208\173z\244\213rTxH\155N\212\221\137J\214\229\r\178",PropAuthenticationData +// "\241n\165:B\CAN\156\194\170\204\&9\a\217G",PropTopicAlias 14445,PropSharedSubscriptionAvailable +// 83,PropReceiveMaximum 5739,PropSessionExpiryInterval 6584]} TEST(Connect5QCTest, Encode2) { uint8_t pkt[] = { - 0x10, 0xd4, 0x2, 0x0, 0x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x4, 0x1a, 0x5f, 0x70, 0x85, 0x4f, + 0x34, 0x81, 0x23, 0x51, 0x79, 0x24, 0xc4, 0x1f, 0x0, 0x9, 0x68, 0x1f, 0xec, 0x97, 0x3d, 0x6e, 0xbb, 0xe7, 0xbf, + 0x21, 0x4d, 0x8d, 0xb, 0x9, 0x27, 0x0, 0x0, 0x4a, 0x53, 0x3, 0x0, 0x9, 0x8, 0xde, 0xe8, 0xa7, 0x3f, 0x1e, + 0xeb, 0x8e, 0xa6, 0x0, 0x4, 0xe0, 0xf1, 0xce, 0xdf, 0x0, 0x4, 0x3c, 0xb9, 0x42, 0x11, 0x0, 0x8, 0xaf, 0xdf, + 0xed, 0x97, 0xa5, 0x8f, 0xb5, 0xba}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd3, 0xa4, 0x86, 0xb0, 0xb6, 0xa3, 0x4, 0x6b, 0x1b, 0xcf, 0x3a, - 0xb2, 0x48, 0xe3, 0x81, 0x59, 0xb0, 0xf4, 0xd8, 0xe5, 0x74, 0x80}; - uint8_t bytesprops1[] = {0xf, 0x54, 0xff, 0x84, 0xcb, 0x47, 0x7d, 0x10, 0x7a, - 0x17, 0x7a, 0x76, 0xc5, 0x70, 0x99, 0x6, 0x90}; - uint8_t bytesprops2[] = {0xf9, 0xc1, 0xab, 0x6e, 0xcc, 0x17, 0xa4, 0xc8, 0xb9, - 0x3e, 0x98, 0xfe, 0x15, 0xdd, 0x45, 0xa3, 0xd1}; - uint8_t bytesprops3[] = {0xe3, 0xd8}; + uint8_t bytesprops0[] = {0x28, 0xb5, 0x6e, 0xa6, 0x3f, 0x4a, 0x28, 0xc1, 0x6d, + 0x56, 0xd1, 0x4, 0x17, 0x66, 0x2, 0xed, 0xba}; + uint8_t bytesprops1[] = {0xce, 0x86, 0x54, 0xd0, 0xad, 0x7a, 0xf4, 0xd5, 0x72, 0x54, 0x78, + 0x48, 0x9b, 0x4e, 0xd4, 0xdd, 0x89, 0x4a, 0xd6, 0xe5, 0xd, 0xb2}; + uint8_t bytesprops2[] = {0xf1, 0x6e, 0xa5, 0x3a, 0x42, 0x18, 0x9c, 0xc2, 0xaa, 0xcc, 0x39, 0x7, 0xd9, 0x47}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21071}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31849}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8324}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14445}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5739}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6584}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xb5, 0x49, 0xe7, 0x20, 0xb0, 0xca, 0xf, 0xda, 0xa0, 0xb1}; - uint8_t byteswillprops1[] = {0xab, 0xed, 0x38, 0x39, 0xdf, 0x2e}; - uint8_t byteswillprops2[] = {0xbd, 0xfc, 0x5b, 0xb7, 0xe2, 0x31, 0x3e, 0xda, 0x6, 0x8a, 0x3a, - 0xb7, 0x6d, 0x40, 0xf, 0x99, 0x5b, 0x1, 0x96, 0x46, 0xce, 0xe1}; - uint8_t byteswillprops3[] = {0x19, 0x76, 0xcd, 0x1}; - uint8_t byteswillprops4[] = {0xdf, 0x7e, 0xa6, 0xab, 0xbd, 0xb3, 0x70, 0x79, 0xc3, 0xcb, 0xab}; - uint8_t byteswillprops5[] = {0x72, 0xcb, 0x53, 0x3a, 0x28, 0xa, 0x16, 0x79, 0x1a, 0x2f, 0xa, 0xb2, 0x3e, - 0x38, 0x6f, 0xb7, 0xda, 0xfe, 0xed, 0x49, 0x65, 0xc0, 0x1e, 0x5d, 0x3b, 0xde}; - uint8_t byteswillprops7[] = {0x52, 0x27, 0x2, 0x4d}; - uint8_t byteswillprops6[] = {0x3b, 0xfe, 0x80, 0xdc, 0x7f, 0x82, 0x68, 0x5a, 0x86}; - uint8_t byteswillprops8[] = {0x8b, 0xeb, 0x9e, 0x99, 0x16, 0xd1, 0x44, 0xb7, 0x54, 0xe, 0xeb, 0xc0, - 0x44, 0xa6, 0x3b, 0x2a, 0x97, 0x33, 0xaa, 0xdd, 0x62, 0xb1, 0xda}; - uint8_t byteswillprops9[] = {0x2c, 0x20, 0xa9, 0xa0, 0x36, 0x9d, 0x9b, 0xe4}; + uint8_t byteswillprops0[] = {0xd2, 0x76, 0xe, 0x1a, 0x6f, 0xb0, 0xfc, 0x44, 0xfe, 0x45, 0xc9, 0xf9, 0xd7}; + uint8_t byteswillprops1[] = {0xa0, 0x95, 0x87, 0x3d, 0x59, 0x9e, 0xc4, 0xa4, 0x55, + 0xb5, 0xea, 0x92, 0x1a, 0xfe, 0xa5, 0x35, 0x9b, 0x8e}; + uint8_t byteswillprops2[] = {0x12, 0xaf, 0xd6, 0x49, 0xbb, 0xcf, 0xdf, 0xa3, 0x18, 0x98, 0x6, 0xe9, 0x92, + 0xd4, 0xf3, 0x6, 0x7a, 0x4, 0x1a, 0x5f, 0x70, 0x85, 0x4f, 0x34, 0x81}; + uint8_t byteswillprops3[] = {0x68, 0x1f, 0xec, 0x97, 0x3d, 0x6e, 0xbb, 0xe7, 0xbf}; + uint8_t byteswillprops4[] = {0x8, 0xde, 0xe8, 0xa7, 0x3f, 0x1e, 0xeb, 0x8e, 0xa6}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23838}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23226}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25172}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {9, (char*)&byteswillprops6}, .v = {4, (char*)&byteswillprops7}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2061}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20856}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 25}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 32}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1034}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31898}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4616}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18288}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22616}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20857}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19853}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19027}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops4}}}, }; - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x68, 0xa5, 0x7b, 0xd3, 0x42, 0xd6, 0xa9, 0x57, 0xed}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {23, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe0, 0xf1, 0xce, 0xdf}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3c, 0xb9, 0x42, 0x11}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 13091; - uint8_t client_id_bytes[] = {0x6b, 0x21, 0x61, 0x9, 0xb6, 0xb5, 0xe6, 0xcf, 0x3c, - 0x1a, 0xfb, 0xf3, 0x62, 0xfa, 0xd8, 0x83, 0x48}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 12709; + uint8_t client_id_bytes[] = {0x71, 0x52, 0x26, 0xda, 0x62, 0xe0, 0x2e, 0x72, 0x7c, + 0x61, 0xce, 0x8b, 0xe2, 0xae, 0x28, 0xd8, 0x19, 0xc1}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xe8, 0x66, 0x3b, 0x2f}; - lwmqtt_string_t username = {4, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x54, 0x27, 0xf8, 0x90, 0xb3, 0x9b, 0x56, 0xd1, 0x15, 0x24, - 0x6c, 0x86, 0xa9, 0xa5, 0xf4, 0x5f, 0x6, 0x7, 0x61, 0x1f}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xaf, 0xdf, 0xed, 0x97, 0xa5, 0x8f, 0xb5, 0xba}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -6683,298 +6981,239 @@ TEST(Connect5QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\211\228\SUB\176\198\221", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS0, _willTopic = "xpj95\230\&1\225?", _willMsg = "\248", _willProps = -// [PropCorrelationData "\197\&4\239I\150\236U\STX\234/",PropReceiveMaximum 17282,PropSubscriptionIdentifier -// 28,PropReasonString "\GSR\RS\SUB\152\158\135;\n\227",PropContentType "f\183\210n\156p\155\a\241<\248\255 -// \219\178`,a\226l\USC*\225w\DELVy\247",PropMaximumQoS 75,PropAuthenticationData -// "\183\254\148\233!:5`\197",PropServerKeepAlive 17308,PropMaximumQoS 249,PropMessageExpiryInterval -// 30756,PropRetainAvailable 189,PropRequestProblemInformation 94,PropMaximumPacketSize 5418,PropWillDelayInterval -// 13911,PropCorrelationData "\ETB\147\170~\240:\FS\DC1Z\173Uq}h\254\EM\195\252\DC11\232\128\249",PropReceiveMaximum -// 14720,PropRequestResponseInformation 131,PropMaximumPacketSize 31902]}), _cleanSession = True, _keepAlive = 2433, -// _connID = "\185\137\241\223?ec+\\U\r\DC1\GS\181\187\231\&9\243\232\195" "\207`\151\133O",PropReasonString -// "\209\174\214",PropMessageExpiryInterval 1097,PropMessageExpiryInterval 11875,PropRequestResponseInformation 8]} +// ConnectRequest {_username = Just "ZY*\212\&2v\CAN\238\SYN\243Z-\210z\SO\229X\164`\136 \ETB\246\182zw}0\148\v", +// _password = Just "\150\&2b)", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "KY\242", _willMsg = "]\169\158\183\223\181L\153xld\SI\SI\155\&6\211\239", _willProps = [PropPayloadFormatIndicator +// 220,PropSubscriptionIdentifierAvailable 110]}), _cleanSession = False, _keepAlive = 18195, _connID = +// "v\132\v6\r\164\241\&1VUf\239\GS\210\201!\158\240\&7\194", _properties = [PropUserProperty "a@jf\155l\144\ETB" +// "=\253\157\&1\197x\172n\183\254\167\224\&8\213[>\185\251\144Y",PropResponseInformation +// "'\167\&8.\139\212z\217\190\&8\172\211&",PropServerKeepAlive 21621,PropAuthenticationData +// "\DLEb\151\235K\180,>~\152\237IY",PropReceiveMaximum 10685,PropWillDelayInterval +// 31891,PropSubscriptionIdentifierAvailable 89,PropCorrelationData +// "~x\220\246\&6\168\221b:\183/\221\172\ETX\ENQ",PropMessageExpiryInterval 30900,PropAssignedClientIdentifier +// "<",PropWillDelayInterval 8778,PropMessageExpiryInterval 27,PropReceiveMaximum 16802]} TEST(Connect5QCTest, Encode5) { uint8_t pkt[] = { - 0x10, 0x8e, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x54, 0x74, 0x3d, 0xa5, 0x1, 0x22, 0x58, 0x32, 0x22, - 0x52, 0xb7, 0x1, 0x6f, 0xb, 0xf, 0x1a, 0x0, 0x15, 0x15, 0xe8, 0x9d, 0xaf, 0x82, 0x81, 0x47, 0x43, 0x1d, 0xfb, - 0x59, 0xc2, 0x19, 0x44, 0x20, 0x8e, 0x79, 0xb3, 0xfa, 0x25, 0x60, 0x12, 0x0, 0x1, 0x56, 0x1a, 0x0, 0x8, 0x19, - 0x7e, 0xcb, 0xd4, 0x5a, 0x83, 0x82, 0xd4, 0x3, 0x0, 0x19, 0xaf, 0xa1, 0x7d, 0xfe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5, 0x4c, 0x99, 0x78, 0x6c, 0x64, 0xf, 0xf, 0x9b, 0x36, 0xd3, 0xef, 0x0, 0x1e, 0x5a, 0x59, 0x2a, 0xd4, 0x32, + 0x76, 0x18, 0xee, 0x16, 0xf3, 0x5a, 0x2d, 0xd2, 0x7a, 0xe, 0xe5, 0x58, 0xa4, 0x60, 0x88, 0x20, 0x17, 0xf6, 0xb6, + 0x7a, 0x77, 0x7d, 0x30, 0x94, 0xb, 0x0, 0x4, 0x96, 0x32, 0x62, 0x29}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x15, 0xe8, 0x9d, 0xaf, 0x82, 0x81, 0x47, 0x43, 0x1d, 0xfb, 0x59, - 0xc2, 0x19, 0x44, 0x20, 0x8e, 0x79, 0xb3, 0xfa, 0x25, 0x60}; - uint8_t bytesprops1[] = {0x56}; - uint8_t bytesprops2[] = {0x19, 0x7e, 0xcb, 0xd4, 0x5a, 0x83, 0x82, 0xd4}; - uint8_t bytesprops3[] = {0xaf, 0xa1, 0x7d, 0xfe, 0x16, 0xa1, 0xf6, 0x47, 0xfd, 0xdf, 0x76, 0x39, 0xf, - 0x4a, 0xfb, 0x31, 0xc, 0xad, 0xd, 0x36, 0x8d, 0x7a, 0xcc, 0x89, 0x92}; - uint8_t bytesprops4[] = {0xc9, 0xe2, 0x32, 0xe4, 0xd7, 0x11, 0xfd, 0x15, 0x54, 0x92, 0x57, 0x19, 0x87, 0x82, 0x28}; - uint8_t bytesprops6[] = {0xcf, 0x60, 0x97, 0x85, 0x4f}; - uint8_t bytesprops5[] = {0x17, 0x73, 0xf1, 0x87, 0xa4, 0x9d, 0x86, 0x73, 0x11, - 0xd2, 0x3e, 0xb5, 0xbb, 0xe7, 0x39, 0xf3, 0xe8, 0xc3}; - uint8_t bytesprops7[] = {0xd1, 0xae, 0xd6}; + uint8_t bytesprops1[] = {0x3d, 0xfd, 0x9d, 0x31, 0xc5, 0x78, 0xac, 0x6e, 0xb7, 0xfe, + 0xa7, 0xe0, 0x38, 0xd5, 0x5b, 0x3e, 0xb9, 0xfb, 0x90, 0x59}; + uint8_t bytesprops0[] = {0x61, 0x40, 0x6a, 0x66, 0x9b, 0x6c, 0x90, 0x17}; + uint8_t bytesprops2[] = {0x27, 0xa7, 0x38, 0x2e, 0x8b, 0xd4, 0x7a, 0xd9, 0xbe, 0x38, 0xac, 0xd3, 0x26}; + uint8_t bytesprops3[] = {0x10, 0x62, 0x97, 0xeb, 0x4b, 0xb4, 0x2c, 0x3e, 0x7e, 0x98, 0xed, 0x49, 0x59}; + uint8_t bytesprops4[] = {0x7e, 0x78, 0xdc, 0xf6, 0x36, 0xa8, 0xdd, 0x62, 0x3a, 0xb7, 0x2f, 0xdd, 0xac, 0x3, 0x5}; + uint8_t bytesprops5[] = {0x3c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22578}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21175}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5064}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22275}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22844}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18627}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops5}, .v = {5, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1097}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11875}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21621}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10685}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31891}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30900}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8778}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16802}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25486}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 379}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 110}}, }; lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x87, 0x54, 0x87, 0x75, 0x84, 0x82, 0x4b}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3d, 0x8f, 0xb4, 0x46, 0x73, 0xae, 0x4f, 0x39, 0x4b, 0xc8, 0xf0, 0xfa, 0x2f, 0x8d, - 0xc6, 0x5, 0x25, 0x16, 0xc9, 0xe7, 0x6c, 0x67, 0x34, 0x6e, 0xcc, 0x1e, 0xf8, 0xd6}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x4b, 0x59, 0xf2}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5d, 0xa9, 0x9e, 0xb7, 0xdf, 0xb5, 0x4c, 0x99, 0x78, + 0x6c, 0x64, 0xf, 0xf, 0x9b, 0x36, 0xd3, 0xef}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 29757; - uint8_t client_id_bytes[] = {0xf0, 0x68, 0xf6, 0xa0, 0xbf, 0x81, 0x9d, 0x9b, 0xdb, 0xd3, 0xd7, 0xf6, 0xa2, 0xf1}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.keep_alive = 18195; + uint8_t client_id_bytes[] = {0x76, 0x84, 0xb, 0x36, 0xd, 0xa4, 0xf1, 0x31, 0x56, 0x55, + 0x66, 0xef, 0x1d, 0xd2, 0xc9, 0x21, 0x9e, 0xf0, 0x37, 0xc2}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xed, 0x4b, 0x77, 0x74, 0x1b, 0x33, 0xdc, 0x14, 0x66, 0x93, 0x3d, 0x7d, 0x83, 0x44, 0xc4, - 0xea, 0x80, 0xbb, 0xe9, 0x6a, 0x7b, 0x9, 0x8a, 0x3a, 0x28, 0x49, 0x0, 0xb7, 0xdc}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x5a, 0x59, 0x2a, 0xd4, 0x32, 0x76, 0x18, 0xee, 0x16, 0xf3, 0x5a, 0x2d, 0xd2, 0x7a, 0xe, + 0xe5, 0x58, 0xa4, 0x60, 0x88, 0x20, 0x17, 0xf6, 0xb6, 0x7a, 0x77, 0x7d, 0x30, 0x94, 0xb}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x96, 0x32, 0x62, 0x29}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -6984,187 +7223,97 @@ TEST(Connect5QCTest, Encode5) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\129R\188\238\ETB\248F\174*\164\231\GS\"\142\251\243\nM\151\128\196i2",PropAuthenticationMethod -// "{g\224\175\b\232\163\225_\136\149\167\194\NUL\202F\148d\252\EM\145\NAK\221\137",PropPayloadFormatIndicator -// 250,PropMessageExpiryInterval 14991,PropAuthenticationData -// "\b\248+\189\226\NAK\155,\144\192K\157h\214\ENQb*3&\194u\142\183U\SUB^/8\173",PropAssignedClientIdentifier -// "\173\147\"!d\166\242!\216\205\DC3\144\242\254\147#",PropSessionExpiryInterval 3173,PropResponseInformation -// "\250+\238\254\185\208E\156=u\192nQ\132A~\235h\251iV\165>*D",PropResponseTopic -// "\162\180\193\154\170\195\239\255\ACK\134S\147(lc\242I\132\216\SYN\173O\nbi)",PropAuthenticationMethod -// "",PropWillDelayInterval 11821,PropSubscriptionIdentifierAvailable 210,PropSubscriptionIdentifier -// 27,PropMaximumPacketSize 20831,PropWildcardSubscriptionAvailable 199,PropAssignedClientIdentifier -// "\230\139{\ESC\234\207v\138\GS\220>\191ml",PropContentType -// ",-b$\DLE-\CAN\218\ETB\132\132=Pl\247\186GL\180\184\216\247",PropMessageExpiryInterval -// 12214,PropRequestResponseInformation 241,PropCorrelationData -// "\135\148\128\210j\208Mf\232\166\231?\172\CAN\174\&7\248\181\&9>dj\201\138\231\163=I",PropResponseInformation -// "\190\STX7\147\139Jv<\254\219H,\187\SI+",PropRequestProblemInformation 99,PropResponseInformation -// "\ESCJ\134\206\US"]}), _cleanSession = False, _keepAlive = 24021, _connID = -// "\226\DC1b\162U#[l\222e\215\133\236\USO\246T\196\148]\bq\191\235\137az", _properties = [PropAuthenticationData -// "\DC18\250\166<\252r\SI\DC16#\239\159}\DEL\244 \fB",PropWildcardSubscriptionAvailable 6,PropTopicAlias -// 12941,PropRetainAvailable 48,PropMaximumQoS 208,PropWildcardSubscriptionAvailable 97,PropTopicAliasMaximum -// 25976,PropTopicAlias 23357,PropWildcardSubscriptionAvailable 56,PropMessageExpiryInterval -// 1922,PropSessionExpiryInterval 2342,PropAssignedClientIdentifier -// "\178\130\211\140\SI\219\185\212\243H\145`.\207\143\DLET\t-(\128",PropMessageExpiryInterval 26447,PropContentType -// "|\199B",PropRequestResponseInformation 91,PropSharedSubscriptionAvailable 115,PropAssignedClientIdentifier -// "\192\237\US>`\170\238\250cc\130\&33!\166\234\165>\173",PropMaximumQoS 37,PropContentType -// "\185\EMg\150\155\227\RS\163\183S",PropTopicAliasMaximum 16720,PropReasonString -// "a`\v\191\SUBpv\254\231\232E\149\233\t\167\ETX\ESC\163[\138U",PropTopicAlias 26061]} +// ConnectRequest {_username = Just "\STXjT\248\ACK\158\156\227\216x\233}\DC4q\198\140ca\207\230", _password = Nothing, +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "_\192D\194~\218adY0\244u\190og1\210Y\200", _willMsg = "\188\&4\154k=\225N", _willProps = [PropMaximumPacketSize +// 19884,PropWildcardSubscriptionAvailable 196,PropWildcardSubscriptionAvailable 154,PropAuthenticationData +// "\130\251\240\DC3\153M@\ACK\155\ESC@o9\224;3c\248X",PropResponseTopic "@\245\178\196U\228\169L*\217\163\ACK\240"]}), +// _cleanSession = True, _keepAlive = 16867, _connID = "h\ETX\237n0\202\ETX/\213\ESC\174\136'\218lQ\144\n\175\151\132", +// _properties = [PropResponseTopic "\193\167\185\189\222`\151Q", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS2, _willTopic = "\219\242^+:\f\EOT\173\175\&1\CAN\171\&8", _willMsg = +// "\172\220\161\161W~?%", _willProps = [PropPayloadFormatIndicator 66,PropTopicAlias 14799,PropReasonString +// "\DLE\198\234\232\141Q\171\186\225p3\US\EOT\182W\251\&3",PropServerKeepAlive 16361,PropAuthenticationMethod +// "\160\237\149\220ft\158\250S1\129\137\208\US\171[\SI\155\DLE\230",PropReasonString "",PropMaximumQoS +// 138,PropTopicAlias 19777,PropResponseInformation "\SUB\150\168xS\235\\\243\STX\n\ENQ\nf\STX\144\205\237H"]}), +// _cleanSession = False, _keepAlive = 9252, _connID = +// "\175\167p\FS\238\ni\164\&3*\183\243\186\129\SO\153{\225\138\236\216\213${|P^\248\148\128", _properties = +// [PropTopicAliasMaximum 7582,PropSessionExpiryInterval 9069,PropReasonString +// "\244\141\154\244\&4J?s\152\128\163\178\219\247\222\DLEk7\174\137s",PropSessionExpiryInterval +// 31866,PropAssignedClientIdentifier +// "\246Tu?9\161Bf\137]U\227x\FS,\"\226\205\&8f\213\FS\177\240<",PropMaximumPacketSize 18917,PropSubscriptionIdentifier +// 22,PropSharedSubscriptionAvailable 227,PropReasonString +// "R\ENQ\r\226\228/C\191\ETB\205\247\188\234+\146\202?",PropSubscriptionIdentifierAvailable +// 5,PropRequestResponseInformation 40,PropMessageExpiryInterval 32403,PropServerReference +// "\129LQ\129\218\230\ESC\165\"\191\226\179S\232\&8mj\EM`]hM\187]\CAN\226\DC4\228\234\249",PropReasonString +// "\217&\205\239n\NAK\EME \140J\148K",PropServerKeepAlive 23,PropRetainAvailable 128,PropSharedSubscriptionAvailable +// 203,PropRetainAvailable 242,PropUserProperty +// "o\"\157\151\199j\170W\145\229\145qK\FS\v\210w<\NAK\169\248z8\143\134\142K" "\166)QvC\215\\L\181\197\236\f\182\223"]} TEST(Connect5QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0xe5, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x40, 0x77, 0x4b, 0xbb, 0x1, 0x23, 0x75, - 0x76, 0x8, 0x0, 0x1d, 0xcf, 0xcb, 0x34, 0x6c, 0x36, 0x61, 0xe1, 0x7d, 0x5f, 0xda, 0xc8, 0x5f, 0x38, - 0x38, 0xba, 0x77, 0x23, 0x57, 0xb5, 0xcb, 0x3, 0xbc, 0x4b, 0xd8, 0xf8, 0xcf, 0x76, 0x78, 0x2c, 0x3, - 0x0, 0x8, 0x96, 0x32, 0xd2, 0xf4, 0xa8, 0x75, 0x71, 0xdb, 0x21, 0x1b, 0x47, 0x1f, 0x0, 0x14, 0xb8, - 0x59, 0xd8, 0x9e, 0xed, 0x58, 0x92, 0x98, 0xdd, 0x8f, 0xe7, 0xed, 0xe, 0x3f, 0xc6, 0x72, 0x82, 0x28, - 0x94, 0xf1, 0x21, 0x25, 0xb, 0x8, 0x0, 0x12, 0xa, 0x6, 0xbc, 0xa0, 0xe7, 0xbc, 0x69, 0xb9, 0x54, - 0xaa, 0x45, 0x36, 0xa6, 0x33, 0xf2, 0x1b, 0x96, 0x7d, 0x9, 0x0, 0x6, 0x5b, 0x5e, 0x59, 0xb5, 0x1a, - 0x81, 0x18, 0x0, 0x0, 0x2f, 0x8f, 0x8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 0xea, + 0xe8, 0x8d, 0x51, 0xab, 0xba, 0xe1, 0x70, 0x33, 0x1f, 0x4, 0xb6, 0x57, 0xfb, 0x33, 0x13, 0x3f, 0xe9, 0x15, 0x0, + 0x14, 0xa0, 0xed, 0x95, 0xdc, 0x66, 0x74, 0x9e, 0xfa, 0x53, 0x31, 0x81, 0x89, 0xd0, 0x1f, 0xab, 0x5b, 0xf, 0x9b, + 0x10, 0xe6, 0x1f, 0x0, 0x0, 0x24, 0x8a, 0x23, 0x4d, 0x41, 0x1a, 0x0, 0x12, 0x1a, 0x96, 0xa8, 0x78, 0x53, 0xeb, + 0x5c, 0xf3, 0x2, 0xa, 0x5, 0xa, 0x66, 0x2, 0x90, 0xcd, 0xed, 0x48, 0x0, 0xd, 0xdb, 0xf2, 0x5e, 0x2b, 0x3a, + 0xc, 0x4, 0xad, 0xaf, 0x31, 0x18, 0xab, 0x38, 0x0, 0x8, 0xac, 0xdc, 0xa1, 0xa1, 0x57, 0x7e, 0x3f, 0x25, 0x0, + 0xf, 0x19, 0x9f, 0x19, 0x0, 0x14, 0x5c, 0x2c, 0x8c, 0x6d, 0x6d, 0x47, 0x6c, 0xa2, 0xbb, 0xde, 0x0, 0x1a, 0x18, + 0xf9, 0x92, 0x66, 0x48, 0x16, 0xa1, 0x1f, 0x9a, 0xad, 0xf3, 0xb1, 0xf0, 0xd4, 0x6b, 0xcb, 0xdb, 0x3e, 0xc1, 0xa7, + 0xb9, 0xbd, 0xde, 0x60, 0x97, 0x51}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xcf, 0xcb, 0x34, 0x6c, 0x36, 0x61, 0xe1, 0x7d, 0x5f, 0xda, 0xc8, 0x5f, 0x38, 0x38, 0xba, - 0x77, 0x23, 0x57, 0xb5, 0xcb, 0x3, 0xbc, 0x4b, 0xd8, 0xf8, 0xcf, 0x76, 0x78, 0x2c}; - uint8_t bytesprops1[] = {0x96, 0x32, 0xd2, 0xf4, 0xa8, 0x75, 0x71, 0xdb}; - uint8_t bytesprops2[] = {0xb8, 0x59, 0xd8, 0x9e, 0xed, 0x58, 0x92, 0x98, 0xdd, 0x8f, - 0xe7, 0xed, 0xe, 0x3f, 0xc6, 0x72, 0x82, 0x28, 0x94, 0xf1}; - uint8_t bytesprops3[] = {0xa, 0x6, 0xbc, 0xa0, 0xe7, 0xbc, 0x69, 0xb9, 0x54, - 0xaa, 0x45, 0x36, 0xa6, 0x33, 0xf2, 0x1b, 0x96, 0x7d}; - uint8_t bytesprops4[] = {0x5b, 0x5e, 0x59, 0xb5, 0x1a, 0x81}; - uint8_t bytesprops5[] = {0x3b, 0x34, 0x18, 0xa6, 0x6f, 0x51, 0x3c, 0x4d, 0x2c}; - uint8_t bytesprops6[] = {0x4, 0x73, 0x69}; - uint8_t bytesprops7[] = {0x7b, 0x52, 0xd6, 0xb2, 0xee, 0x73, 0xb4, 0xb4, 0xe, 0x41, 0x62}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops9[] = {0xa0, 0x76, 0xa7, 0x9e, 0x1a, 0x30, 0x40, 0x3}; - uint8_t bytesprops10[] = {0x81, 0x52, 0x4a, 0xb5, 0x26, 0xcd, 0xc2}; + uint8_t bytesprops0[] = {0xf4, 0x8d, 0x9a, 0xf4, 0x34, 0x4a, 0x3f, 0x73, 0x98, 0x80, 0xa3, + 0xb2, 0xdb, 0xf7, 0xde, 0x10, 0x6b, 0x37, 0xae, 0x89, 0x73}; + uint8_t bytesprops1[] = {0xf6, 0x54, 0x75, 0x3f, 0x39, 0xa1, 0x42, 0x66, 0x89, 0x5d, 0x55, 0xe3, 0x78, + 0x1c, 0x2c, 0x22, 0xe2, 0xcd, 0x38, 0x66, 0xd5, 0x1c, 0xb1, 0xf0, 0x3c}; + uint8_t bytesprops2[] = {0x52, 0x5, 0xd, 0xe2, 0xe4, 0x2f, 0x43, 0xbf, 0x17, + 0xcd, 0xf7, 0xbc, 0xea, 0x2b, 0x92, 0xca, 0x3f}; + uint8_t bytesprops3[] = {0x81, 0x4c, 0x51, 0x81, 0xda, 0xe6, 0x1b, 0xa5, 0x22, 0xbf, 0xe2, 0xb3, 0x53, 0xe8, 0x38, + 0x6d, 0x6a, 0x19, 0x60, 0x5d, 0x68, 0x4d, 0xbb, 0x5d, 0x18, 0xe2, 0x14, 0xe4, 0xea, 0xf9}; + uint8_t bytesprops4[] = {0xd9, 0x26, 0xcd, 0xef, 0x6e, 0x15, 0x19, 0x45, 0x20, 0x8c, 0x4a, 0x94, 0x4b}; + uint8_t bytesprops6[] = {0xa6, 0x29, 0x51, 0x76, 0x43, 0xd7, 0x5c, 0x4c, 0xb5, 0xc5, 0xec, 0xc, 0xb6, 0xdf}; + uint8_t bytesprops5[] = {0x6f, 0x22, 0x9d, 0x97, 0xc7, 0x6a, 0xaa, 0x57, 0x91, 0xe5, 0x91, 0x71, 0x4b, 0x1c, + 0xb, 0xd2, 0x77, 0x3c, 0x15, 0xa9, 0xf8, 0x7a, 0x38, 0x8f, 0x86, 0x8e, 0x4b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30070}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6983}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9483}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12175}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9749}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26462}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21839}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7582}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9069}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31866}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18917}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32403}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops5}, .v = {14, (char*)&bytesprops6}}}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x10, 0xc6, 0xea, 0xe8, 0x8d, 0x51, 0xab, 0xba, 0xe1, + 0x70, 0x33, 0x1f, 0x4, 0xb6, 0x57, 0xfb, 0x33}; + uint8_t byteswillprops1[] = {0xa0, 0xed, 0x95, 0xdc, 0x66, 0x74, 0x9e, 0xfa, 0x53, 0x31, + 0x81, 0x89, 0xd0, 0x1f, 0xab, 0x5b, 0xf, 0x9b, 0x10, 0xe6}; + uint8_t byteswillprops2[] = {0}; + uint8_t byteswillprops3[] = {0x1a, 0x96, 0xa8, 0x78, 0x53, 0xeb, 0x5c, 0xf3, 0x2, + 0xa, 0x5, 0xa, 0x66, 0x2, 0x90, 0xcd, 0xed, 0x48}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14799}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16361}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19777}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops3}}}, + }; + + lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xdb, 0xf2, 0x5e, 0x2b, 0x3a, 0xc, 0x4, 0xad, 0xaf, 0x31, 0x18, 0xab, 0x38}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xac, 0xdc, 0xa1, 0xa1, 0x57, 0x7e, 0x3f, 0x25}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 30539; - uint8_t client_id_bytes[] = {0xe2, 0x5, 0xf4, 0xde, 0x49, 0x36, 0xd5, 0x6a, 0xca, 0x39, 0xe6, - 0xc6, 0xff, 0xad, 0x85, 0xef, 0x13, 0xe4, 0x86, 0xba, 0x5d}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.keep_alive = 9252; + uint8_t client_id_bytes[] = {0xaf, 0xa7, 0x70, 0x1c, 0xee, 0xa, 0x69, 0xa4, 0x33, 0x2a, + 0xb7, 0xf3, 0xba, 0x81, 0xe, 0x99, 0x7b, 0xe1, 0x8a, 0xec, + 0xd8, 0xd5, 0x24, 0x7b, 0x7c, 0x50, 0x5e, 0xf8, 0x94, 0x80}; + lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x69, 0xfa, 0x1c, 0xe3, 0x53}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x19, 0x9f, 0x19, 0x0, 0x14, 0x5c, 0x2c, 0x8c, 0x6d, 0x6d, 0x47, 0x6c, 0xa2, 0xbb, 0xde}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x18, 0xf9, 0x92, 0x66, 0x48, 0x16, 0xa1, 0x1f, 0x9a, 0xad, 0xf3, 0xb1, 0xf0, + 0xd4, 0x6b, 0xcb, 0xdb, 0x3e, 0xc1, 0xa7, 0xb9, 0xbd, 0xde, 0x60, 0x97, 0x51}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\225\203mIB\148\147s", _password = Nothing, _lastWill = Just (LastWill {_willRetain -// = False, _willQoS = QoS0, _willTopic = "`\SO\132\139\ESC\222W\198\STXb$", _willMsg = -// "j\225L%\SYN:R\144\143\244\201FZce\154\SO[\DC1\183\205\197\134J,\184", _willProps = [PropTopicAliasMaximum -// 16098,PropTopicAlias 13294,PropSubscriptionIdentifier 13,PropWillDelayInterval 3829,PropResponseInformation -// "",PropRequestResponseInformation 158,PropReasonString -// "\211\154\249\151\225\140v\SOH\143\234\204\NULcX`\185M\130\182",PropSubscriptionIdentifier 0,PropMaximumPacketSize -// 30261,PropServerReference "\151\170",PropTopicAlias 2905,PropRequestResponseInformation 163,PropRetainAvailable -// 244,PropWillDelayInterval 24559,PropServerKeepAlive 1251,PropReasonString -// "\238So\171\214\GS0\188\147\DEL\205[\211\&6\231\255\161\128\&3y:\USfN\240'\210\130E",PropCorrelationData -// "{\180\&9X\145\174\SI\r\197\172",PropMessageExpiryInterval 31230,PropUserProperty "q\175P\244\a\184\161\SYN" -// "\128b\212\147\139p",PropRequestResponseInformation 119]}), _cleanSession = False, _keepAlive = 14155, _connID = -// "\190I\DC1\187\DEL", _properties = [PropSubscriptionIdentifier 6,PropReceiveMaximum -// 27185,PropSharedSubscriptionAvailable 85,PropAssignedClientIdentifier -// "M~\220\251o\DC2\160L\144\134",PropRequestResponseInformation 39]} +// ConnectRequest {_username = Just "\132Jc\237#\175s\149\208\140\v\175\198\197@bE\255\177&4\223%%\194\229\ETB", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "_B\130\238\164\ACK\246/\243\243\182\&9h\219Dp\161E\201n(\130u", _willMsg = +// "L\ETX\226\236\158\CAN3\190\221\140\156\129Mj\211\ACKv+\USU\197e\219\EM\135\221\145", _willProps = +// [PropSubscriptionIdentifier 29]}), _cleanSession = False, _keepAlive = 23111, _connID = +// "\128'\168\a\165\214u\"VvPa\154y\236\ETB\165ng\208\175\233\198\234\235\a", _properties = +// [PropRequestResponseInformation 158,PropMaximumQoS 125,PropSharedSubscriptionAvailable 112,PropWillDelayInterval +// 4423,PropAuthenticationData "\171uy\199H{:\189",PropReasonString +// "%\168\209\RSLiy\NAK\242C\SO\rj\ENQ\237ln\148d\237",PropUserProperty +// "c\ACK\165\226\165}\198\253!\144\ENQ2\184R\180V\\\247P\227\189" +// "\134Gw\161\202\160U'\\Vw\138AJc",PropRequestResponseInformation 60,PropMessageExpiryInterval 8943,PropTopicAlias +// 6044,PropMaximumQoS 9,PropServerKeepAlive 982,PropSharedSubscriptionAvailable 31,PropWillDelayInterval +// 9182,PropReceiveMaximum 29774,PropSessionExpiryInterval 32009,PropServerKeepAlive 32136,PropMessageExpiryInterval +// 26395,PropMaximumQoS 5]} TEST(Connect5QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0xe7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x84, 0x37, 0x4b, 0x16, 0xb, 0x6, 0x21, - 0x6a, 0x31, 0x2a, 0x55, 0x12, 0x0, 0xa, 0x4d, 0x7e, 0xdc, 0xfb, 0x6f, 0x12, 0xa0, 0x4c, 0x90, 0x86, - 0x19, 0x27, 0x0, 0x5, 0xbe, 0x49, 0x11, 0xbb, 0x7f, 0x8a, 0x1, 0x22, 0x3e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44, 0x70, 0xa1, 0x45, 0xc9, 0x6e, 0x28, 0x82, 0x75, 0x0, 0x1b, 0x4c, 0x3, 0xe2, 0xec, 0x9e, 0x18, + 0x33, 0xbe, 0xdd, 0x8c, 0x9c, 0x81, 0x4d, 0x6a, 0xd3, 0x6, 0x76, 0x2b, 0x1f, 0x55, 0xc5, 0x65, 0xdb, + 0x19, 0x87, 0xdd, 0x91, 0x0, 0x1b, 0x84, 0x4a, 0x63, 0xed, 0x23, 0xaf, 0x73, 0x95, 0xd0, 0x8c, 0xb, + 0xaf, 0xc6, 0xc5, 0x40, 0x62, 0x45, 0xff, 0xb1, 0x26, 0x34, 0xdf, 0x25, 0x25, 0xc2, 0xe5, 0x17}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x4d, 0x7e, 0xdc, 0xfb, 0x6f, 0x12, 0xa0, 0x4c, 0x90, 0x86}; + uint8_t bytesprops0[] = {0xab, 0x75, 0x79, 0xc7, 0x48, 0x7b, 0x3a, 0xbd}; + uint8_t bytesprops1[] = {0x25, 0xa8, 0xd1, 0x1e, 0x4c, 0x69, 0x79, 0x15, 0xf2, 0x43, + 0xe, 0xd, 0x6a, 0x5, 0xed, 0x6c, 0x6e, 0x94, 0x64, 0xed}; + uint8_t bytesprops3[] = {0x86, 0x47, 0x77, 0xa1, 0xca, 0xa0, 0x55, 0x27, 0x5c, 0x56, 0x77, 0x8a, 0x41, 0x4a, 0x63}; + uint8_t bytesprops2[] = {0x63, 0x6, 0xa5, 0xe2, 0xa5, 0x7d, 0xc6, 0xfd, 0x21, 0x90, 0x5, + 0x32, 0xb8, 0x52, 0xb4, 0x56, 0x5c, 0xf7, 0x50, 0xe3, 0xbd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27185}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4423}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {15, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8943}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6044}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 982}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9182}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29774}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32009}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32136}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26395}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 5}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0}; - uint8_t byteswillprops1[] = {0xd3, 0x9a, 0xf9, 0x97, 0xe1, 0x8c, 0x76, 0x1, 0x8f, 0xea, - 0xcc, 0x0, 0x63, 0x58, 0x60, 0xb9, 0x4d, 0x82, 0xb6}; - uint8_t byteswillprops2[] = {0x97, 0xaa}; - uint8_t byteswillprops3[] = {0xee, 0x53, 0x6f, 0xab, 0xd6, 0x1d, 0x30, 0xbc, 0x93, 0x7f, 0xcd, 0x5b, 0xd3, 0x36, 0xe7, - 0xff, 0xa1, 0x80, 0x33, 0x79, 0x3a, 0x1f, 0x66, 0x4e, 0xf0, 0x27, 0xd2, 0x82, 0x45}; - uint8_t byteswillprops4[] = {0x7b, 0xb4, 0x39, 0x58, 0x91, 0xae, 0xf, 0xd, 0xc5, 0xac}; - uint8_t byteswillprops6[] = {0x80, 0x62, 0xd4, 0x93, 0x8b, 0x70}; - uint8_t byteswillprops5[] = {0x71, 0xaf, 0x50, 0xf4, 0x7, 0xb8, 0xa1, 0x16}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16098}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13294}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3829}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 0}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30261}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2905}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24559}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1251}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31230}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {8, (char*)&byteswillprops5}, .v = {6, (char*)&byteswillprops6}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, }; - lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x60, 0xe, 0x84, 0x8b, 0x1b, 0xde, 0x57, 0xc6, 0x2, 0x62, 0x24}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6a, 0xe1, 0x4c, 0x25, 0x16, 0x3a, 0x52, 0x90, 0x8f, 0xf4, 0xc9, 0x46, 0x5a, - 0x63, 0x65, 0x9a, 0xe, 0x5b, 0x11, 0xb7, 0xcd, 0xc5, 0x86, 0x4a, 0x2c, 0xb8}; - lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5f, 0x42, 0x82, 0xee, 0xa4, 0x6, 0xf6, 0x2f, 0xf3, 0xf3, 0xb6, 0x39, + 0x68, 0xdb, 0x44, 0x70, 0xa1, 0x45, 0xc9, 0x6e, 0x28, 0x82, 0x75}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4c, 0x3, 0xe2, 0xec, 0x9e, 0x18, 0x33, 0xbe, 0xdd, 0x8c, 0x9c, 0x81, 0x4d, 0x6a, + 0xd3, 0x6, 0x76, 0x2b, 0x1f, 0x55, 0xc5, 0x65, 0xdb, 0x19, 0x87, 0xdd, 0x91}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS2; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 14155; - uint8_t client_id_bytes[] = {0xbe, 0x49, 0x11, 0xbb, 0x7f}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.keep_alive = 23111; + uint8_t client_id_bytes[] = {0x80, 0x27, 0xa8, 0x7, 0xa5, 0xd6, 0x75, 0x22, 0x56, 0x76, 0x50, 0x61, 0x9a, + 0x79, 0xec, 0x17, 0xa5, 0x6e, 0x67, 0xd0, 0xaf, 0xe9, 0xc6, 0xea, 0xeb, 0x7}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xe1, 0xcb, 0x6d, 0x49, 0x42, 0x94, 0x93, 0x73}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x84, 0x4a, 0x63, 0xed, 0x23, 0xaf, 0x73, 0x95, 0xd0, 0x8c, 0xb, 0xaf, 0xc6, 0xc5, + 0x40, 0x62, 0x45, 0xff, 0xb1, 0x26, 0x34, 0xdf, 0x25, 0x25, 0xc2, 0xe5, 0x17}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7367,116 +7558,122 @@ TEST(Connect5QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\bA\DC1\DEL\213g\EMC\130^", _password = Just -// "\188\164\213\\P1\226\188\191\201\185\135\150z\216\157\DC4", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS1, _willTopic = "\171C0\171", _willMsg = -// "6\164j\195\226\206\EOT\186\FS?\207\245\154\164\223jR\224#2sJ\165N\145#H\196\159\146", _willProps = [PropMaximumQoS -// 144,PropAuthenticationMethod "\193<\182\202~\233P\204\174F\229MGp\DEL_@\138u\219\207\159d",PropResponseTopic -// "\164\151+\185\ENQ@\SYN\DLE\t\226\231\199k\155\ETX\204.\222%",PropSharedSubscriptionAvailable 34,PropReasonString -// "\166\135\167A\169\204\SYN\147\141\240\254\200ku\n~^B\212R\231\EM7\158",PropWillDelayInterval 10273,PropContentType -// "\190m\183\186\147b\198\236y\ENQ\239S\182\231\DC4\247\a\220\205\b\v}\192\n\151;\157\199\171\159",PropTopicAlias -// 16211,PropCorrelationData "\148\155t\SUB\205Evl\165\220\250"]}), _cleanSession = True, _keepAlive = 29647, _connID = -// "\176\248\150\&5VEy\GS\DC1kSt(`\136\SUB\233\233\156\174\213", _properties = [PropAuthenticationData -// "\241\\\187\251\178#S\140\135\&6\174\FS\230\&5r9\CAN!",PropContentType -// "\193\131QV\228\229K\STXr\205\215q\207}\229\r\236",PropMaximumPacketSize 11364,PropSessionExpiryInterval -// 7409,PropSharedSubscriptionAvailable 158,PropAuthenticationMethod "\225?m?\158\200aC",PropResponseTopic -// "",PropSharedSubscriptionAvailable 85,PropRetainAvailable 97,PropWildcardSubscriptionAvailable 211,PropResponseTopic -// "H!\241\128\ETX\\(\185\160\211\135\196\214\&4_\164",PropPayloadFormatIndicator 39,PropSessionExpiryInterval -// 3336,PropContentType " -// }\FS\US\t\172\167;l:\a\237\164\195\188\214\212#\212\177\157s\246x\231",PropSubscriptionIdentifierAvailable -// 74,PropAuthenticationMethod "f\172#\244\162\173F#\ETBc",PropMessageExpiryInterval 17913,PropContentType -// "\DC4\210:\237\RST_\158"]} +// ConnectRequest {_username = Just "\131)o", _password = Just "Y^ \171\220\234\182Th\NAK", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\SOHw\DC4\149\&5\197\t\RS\188\166\DLE\179", _willMsg = +// "L\173#e?~\241<", _willProps = [PropSessionExpiryInterval 7110,PropServerKeepAlive 24305,PropRetainAvailable +// 101,PropPayloadFormatIndicator 38,PropTopicAlias 22823,PropSubscriptionIdentifierAvailable 67,PropReasonString +// "\192\149\203\184\132\196\144\243\157J\164",PropSubscriptionIdentifier 21,PropResponseInformation +// "\NAK\186\220\217\220\163'\221",PropCorrelationData "\DLER5\185+",PropRequestResponseInformation +// 195,PropRetainAvailable 227,PropPayloadFormatIndicator 155,PropMessageExpiryInterval 26025,PropAuthenticationMethod +// "\160\153\184\173\252\195\209\ENQ\171u\SYN",PropResponseTopic +// "\192\198\129uw\235\226\227\&06\140&\183\&71F\131\239\SUB\158\DLE\187m",PropReceiveMaximum +// 25372,PropTopicAliasMaximum 16172,PropServerKeepAlive 18593,PropAuthenticationData +// "\ACK\208\166\225\168\184@\169\179", _properties = [PropMessageExpiryInterval 2574,PropContentType -// "\ETX\180^0\174\203\175h2\t\204\145\238\183\SI\144JP\142",PropSubscriptionIdentifier -// 30,PropSharedSubscriptionAvailable 232,PropContentType -// "-\233XZ\212\234\161R\165!MD\158\231\\\199\&0\232\138",PropAssignedClientIdentifier "s",PropMaximumQoS -// 151,PropAssignedClientIdentifier "q\162j\243\168Rj\EM -// _\246\203\221;\149\192\232y\RS\DLE\214\246\129\143\EM|a",PropWildcardSubscriptionAvailable 108,PropWillDelayInterval -// 1033,PropMessageExpiryInterval 24445,PropTopicAlias 23778,PropSessionExpiryInterval 16092,PropMaximumPacketSize -// 1282,PropServerKeepAlive 12039]} +// ConnectRequest {_username = Just "\176mX\224\177{+\ENQ\221\228\184\181\192 \NUL\201\128\209", _password = Just +// "\215Dco.`\RSl\219\136A\134Z}X\247\&5HG\ETX", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, +// _willTopic = "\242 xK\204\160x\221\169\240", _willMsg = "\220\ACKG", _willProps = [PropSessionExpiryInterval +// 16457,PropWildcardSubscriptionAvailable 225,PropMaximumPacketSize 18276,PropPayloadFormatIndicator +// 46,PropMaximumPacketSize 7510,PropResponseInformation "\167\n\bZ!s\223\224~\216nc\SIJ\189\ACK\DLE\DC4 +// \169\162\218",PropUserProperty "\215\245\170\f[\207\194(.FT\207\187\172F} " +// "\227\DC4\194-",PropWildcardSubscriptionAvailable 118,PropAuthenticationMethod +// "[\133H\EOT{\SUB",PropRequestResponseInformation 182,PropAuthenticationData +// "c\190$\209+\167D\148\f\189\204G\224\189\220[\222@9\178w\ENQ\166f\200|\250",PropMaximumQoS 180,PropReasonString " +// \203\163\254\208%\197n\132\180\231^9\165\&0^",PropReasonString +// "\193-\EOT\210\&1t\134\195T\143\147\169jj\DC2\SYN\SO\215\143\ETBt",PropPayloadFormatIndicator +// 169,PropSessionExpiryInterval 28492,PropAuthenticationMethod "\134\197(W\CAN\174\\\234\220R",PropTopicAliasMaximum +// 16101,PropMessageExpiryInterval 10137,PropReceiveMaximum 16797,PropSharedSubscriptionAvailable 199,PropReceiveMaximum +// 16828,PropReasonString "s)\n`}%\204c\186\209\220Z\249U\233\171d6c\201\SUBu\r\n",PropResponseTopic +// "\145\176Q\238",PropAuthenticationData "\247u\DC2\148+V\151\246q\172\138"]}), _cleanSession = True, _keepAlive = +// 19143, _connID = "\176/i\144P\218\&5\t\229;\221\246\DC2\"", _properties = [PropReceiveMaximum +// 12877,PropCorrelationData "\191\182\ENQp\189_\SIk\254}\159;?\252\&0\232",PropSubscriptionIdentifier 30,PropMaximumQoS +// 64,PropWildcardSubscriptionAvailable 100,PropPayloadFormatIndicator 163]} TEST(Connect5QCTest, Encode10) { uint8_t pkt[] = { - 0x10, 0xca, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8c, 0x4b, 0xf4, 0x75, 0x2, 0x0, 0x0, 0xa, 0xe, - 0x3, 0x0, 0x13, 0x3, 0xb4, 0x5e, 0x30, 0xae, 0xcb, 0xaf, 0x68, 0x32, 0x9, 0xcc, 0x91, 0xee, 0xb7, 0xf, 0x90, - 0x4a, 0x50, 0x8e, 0xb, 0x1e, 0x2a, 0xe8, 0x3, 0x0, 0x13, 0x2d, 0xe9, 0x58, 0x5a, 0xd4, 0xea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, 0x75, 0xd, 0xa, 0x8, 0x0, + 0x4, 0x91, 0xb0, 0x51, 0xee, 0x16, 0x0, 0xb, 0xf7, 0x75, 0x12, 0x94, 0x2b, 0x56, 0x97, 0xf6, 0x71, 0xac, 0x8a, + 0x0, 0xa, 0xf2, 0x20, 0x78, 0x4b, 0xcc, 0xa0, 0x78, 0xdd, 0xa9, 0xf0, 0x0, 0x3, 0xdc, 0x6, 0x47, 0x0, 0x12, + 0xb0, 0x6d, 0x58, 0xe0, 0xb1, 0x7b, 0x2b, 0x5, 0xdd, 0xe4, 0xb8, 0xb5, 0xc0, 0x20, 0x0, 0xc9, 0x80, 0xd1, 0x0, + 0x14, 0xd7, 0x44, 0x63, 0x6f, 0x2e, 0x60, 0x1e, 0x6c, 0xdb, 0x88, 0x41, 0x86, 0x5a, 0x7d, 0x58, 0xf7, 0x35, 0x48, + 0x47, 0x3}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x3, 0xb4, 0x5e, 0x30, 0xae, 0xcb, 0xaf, 0x68, 0x32, 0x9, - 0xcc, 0x91, 0xee, 0xb7, 0xf, 0x90, 0x4a, 0x50, 0x8e}; - uint8_t bytesprops1[] = {0x2d, 0xe9, 0x58, 0x5a, 0xd4, 0xea, 0xa1, 0x52, 0xa5, 0x21, - 0x4d, 0x44, 0x9e, 0xe7, 0x5c, 0xc7, 0x30, 0xe8, 0x8a}; - uint8_t bytesprops2[] = {0x73}; - uint8_t bytesprops3[] = {0x71, 0xa2, 0x6a, 0xf3, 0xa8, 0x52, 0x6a, 0x19, 0x20, 0x5f, 0xf6, 0xcb, 0xdd, 0x3b, - 0x95, 0xc0, 0xe8, 0x79, 0x1e, 0x10, 0xd6, 0xf6, 0x81, 0x8f, 0x19, 0x7c, 0x61}; + uint8_t bytesprops0[] = {0xbf, 0xb6, 0x5, 0x70, 0xbd, 0x5f, 0xf, 0x6b, + 0xfe, 0x7d, 0x9f, 0x3b, 0x3f, 0xfc, 0x30, 0xe8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2574}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 30}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1033}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24445}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23778}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16092}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1282}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12039}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12877}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 163}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x6b, 0x35, 0xcf, 0x4e, 0xb5, 0xc0, 0x57, 0x55, 0x2c, 0xf, 0x65, - 0x34, 0xac, 0xfe, 0xd2, 0x19, 0x7, 0x65, 0xb0, 0x10, 0x2d}; - uint8_t byteswillprops1[] = {0xa, 0x4a, 0xa6, 0x6a, 0xc2, 0x9e, 0xef, 0x3f, 0x59, 0x94, 0xe0, 0x9f, 0x8d, 0xad, 0xf1, - 0x1b, 0xbf, 0x49, 0x66, 0x8e, 0x11, 0xc9, 0xe6, 0xc7, 0x30, 0xfd, 0xf3, 0x30, 0x32}; - uint8_t byteswillprops2[] = {0x77, 0x12, 0xff, 0xd2, 0x85, 0xbf, 0xca, 0xd7, 0xf8, - 0x54, 0xb9, 0xa4, 0x87, 0x5, 0x5f, 0xb9, 0x61, 0x4a}; - uint8_t byteswillprops3[] = {0xb, 0x29, 0x4f, 0xe8, 0x50, 0x24, 0xce, 0x4b, 0x66, 0x3, - 0x3b, 0xb6, 0x33, 0x43, 0xc6, 0xbc, 0xf3, 0x66, 0xb7}; - uint8_t byteswillprops4[] = {0x3f, 0x8a, 0xca, 0x9, 0xbe, 0x8f, 0x78, 0xa, 0xc, 0x40, 0xc4}; - uint8_t byteswillprops5[] = {0xf7, 0x65, 0xf3, 0x5a, 0xc1, 0xca, 0x34, 0x46, 0x1a, 0x8, 0x30, 0xac, 0x37, - 0xfc, 0xa7, 0xf3, 0x72, 0x7f, 0xbe, 0x21, 0x61, 0x51, 0x8f, 0x3f, 0x55}; - uint8_t byteswillprops6[] = {0xbc, 0xdb, 0xa3, 0x5b, 0x66, 0x19, 0x89, 0x49, 0x29, 0x1e, 0x10}; + uint8_t byteswillprops0[] = {0xa7, 0xa, 0x8, 0x5a, 0x21, 0x73, 0xdf, 0xe0, 0x7e, 0xd8, 0x6e, + 0x63, 0xf, 0x4a, 0xbd, 0x6, 0x10, 0x14, 0x20, 0xa9, 0xa2, 0xda}; + uint8_t byteswillprops2[] = {0xe3, 0x14, 0xc2, 0x2d}; + uint8_t byteswillprops1[] = {0xd7, 0xf5, 0xaa, 0xc, 0x5b, 0xcf, 0xc2, 0x28, 0x2e, + 0x46, 0x54, 0xcf, 0xbb, 0xac, 0x46, 0x7d, 0x20}; + uint8_t byteswillprops3[] = {0x5b, 0x85, 0x48, 0x4, 0x7b, 0x1a}; + uint8_t byteswillprops4[] = {0x63, 0xbe, 0x24, 0xd1, 0x2b, 0xa7, 0x44, 0x94, 0xc, 0xbd, 0xcc, 0x47, 0xe0, 0xbd, + 0xdc, 0x5b, 0xde, 0x40, 0x39, 0xb2, 0x77, 0x5, 0xa6, 0x66, 0xc8, 0x7c, 0xfa}; + uint8_t byteswillprops5[] = {0x20, 0xcb, 0xa3, 0xfe, 0xd0, 0x25, 0xc5, 0x6e, + 0x84, 0xb4, 0xe7, 0x5e, 0x39, 0xa5, 0x30, 0x5e}; + uint8_t byteswillprops6[] = {0xc1, 0x2d, 0x4, 0xd2, 0x31, 0x74, 0x86, 0xc3, 0x54, 0x8f, 0x93, + 0xa9, 0x6a, 0x6a, 0x12, 0x16, 0xe, 0xd7, 0x8f, 0x17, 0x74}; + uint8_t byteswillprops7[] = {0x86, 0xc5, 0x28, 0x57, 0x18, 0xae, 0x5c, 0xea, 0xdc, 0x52}; + uint8_t byteswillprops8[] = {0x73, 0x29, 0xa, 0x60, 0x7d, 0x25, 0xcc, 0x63, 0xba, 0xd1, 0xdc, 0x5a, + 0xf9, 0x55, 0xe9, 0xab, 0x64, 0x36, 0x63, 0xc9, 0x1a, 0x75, 0xd, 0xa}; + uint8_t byteswillprops9[] = {0x91, 0xb0, 0x51, 0xee}; + uint8_t byteswillprops10[] = {0xf7, 0x75, 0x12, 0x94, 0x2b, 0x56, 0x97, 0xf6, 0x71, 0xac, 0x8a}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28426}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12835}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16457}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18276}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7510}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {17, (char*)&byteswillprops1}, .v = {4, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28492}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16101}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10137}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16797}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16828}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&byteswillprops10}}}, }; - lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x89, 0xa9, 0x96, 0x63}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbd}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf2, 0x20, 0x78, 0x4b, 0xcc, 0xa0, 0x78, 0xdd, 0xa9, 0xf0}; + lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xdc, 0x6, 0x47}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19444; - uint8_t client_id_bytes[] = {0x97, 0xad, 0x80, 0xfe, 0xbd, 0x3e, 0xe1, 0xa8, 0xb8, 0x40, 0xa9, 0xb3}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 19143; + uint8_t client_id_bytes[] = {0xb0, 0x2f, 0x69, 0x90, 0x50, 0xda, 0x35, 0x9, 0xe5, 0x3b, 0xdd, 0xf6, 0x12, 0x22}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf0, 0x3, 0xbb, 0xf0, 0x27, 0xdb, 0xd6, 0x3a, 0x18, 0x77}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb0, 0x6d, 0x58, 0xe0, 0xb1, 0x7b, 0x2b, 0x5, 0xdd, + 0xe4, 0xb8, 0xb5, 0xc0, 0x20, 0x0, 0xc9, 0x80, 0xd1}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0xd7, 0x44, 0x63, 0x6f, 0x2e, 0x60, 0x1e, 0x6c, 0xdb, 0x88, + 0x41, 0x86, 0x5a, 0x7d, 0x58, 0xf7, 0x35, 0x48, 0x47, 0x3}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7625,557 +7835,340 @@ TEST(Connect5QCTest, Encode10) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\167 \167\208\233f\167\246'\240T\252\&3!", _password = Just -// "\204ptBG\160\v\SUB\223!\EM\SI\STX\b\DEL+1Z", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, -// _willTopic = "\186To9\139\230@\227W\SUB\173\175\253\165\SI\195\133i\DC4\ESC\229\DC2=z\251\186\231", _willMsg = -// "rXO\rA\ESC\fQ\DC2\152\SO\ETB{\248\203\197%\175\203\235\227", _willProps = [PropWillDelayInterval -// 4229,PropCorrelationData ":",PropMessageExpiryInterval 31827,PropMessageExpiryInterval 29078,PropServerKeepAlive -// 16436,PropSubscriptionIdentifier 11,PropSubscriptionIdentifier 16,PropAuthenticationData -// "\DC2\v|\254{\179\DC2k\151o)\RS\DC3\SO\129\201\v\131X\246\141\225>\149\&2-9\249\250\162",PropSessionExpiryInterval -// 14463,PropCorrelationData -// "WH\EOTJ\167\aX\t\179\&7;\180\154\&6\153\171FO\DC2\236\173\139S\232",PropResponseInformation -// "\DC3\143;\129\163\239:\240R\248\188\179\129\t\139\&9m'\134#\250\150\166",PropAssignedClientIdentifier -// "F\152u\153_\155",PropMaximumPacketSize 7776,PropSharedSubscriptionAvailable 253,PropReasonString -// "\232\253\177s\247m\178\237\231\222\221",PropResponseInformation -// "\210\175\215\nM\134\211\218Jp\226R\EOT\US\232j\b\212\239\NAKA\253J\DLE\t\187\253\229\236",PropReceiveMaximum -// 9466,PropSubscriptionIdentifierAvailable 89,PropSubscriptionIdentifier 15,PropAuthenticationMethod "\140Dp\rR\250 -// \146\SO\158\149",PropAuthenticationData -// "p\163]\225!_\181WU!\231\238?\193r\169\138\165\155U\DC28\146\161\250\194\166",PropSessionExpiryInterval -// 5750,PropMessageExpiryInterval 28985,PropRetainAvailable 244]}), _cleanSession = False, _keepAlive = 21475, _connID = -// "\130", _properties = [PropReceiveMaximum 4893,PropAuthenticationMethod "",PropAuthenticationMethod -// "]\174\253\GS\146\NAK\236\245\227h\216\DC2g\241\174\212\253;",PropReceiveMaximum 1689,PropWillDelayInterval -// 27418,PropRequestProblemInformation 197,PropSubscriptionIdentifier 21,PropRequestProblemInformation 68,PropTopicAlias -// 16330,PropPayloadFormatIndicator 38,PropTopicAlias 22185,PropServerReference -// "p\255L\244A\193P\SYNh\143\200\168",PropSubscriptionIdentifierAvailable 184,PropMaximumPacketSize -// 25634,PropCorrelationData "\184U\173\203\ESCMtAA\229\184\223\203\222\190\137\195\&3\235",PropSessionExpiryInterval -// 338,PropSubscriptionIdentifierAvailable 21,PropAuthenticationMethod "\135$\145\153\SUB1\223\NUL\DC3\f\245"]} +// ConnectRequest {_username = Just "9\246\141M+", _password = Just +// "BzT\194\145\200\DC1~\DC2\170\&9\EOT\DLE\215\STX\232\174n", _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 30004, _connID = "\ENQ\221\153\230\216\164\143FVb\206\243AV\250\128nq\CAN\233\230\147\239@u\239*", _properties = +// [PropReasonString "!\ACK\198<\DC2DD\v/\193\228\234\204y&",PropServerKeepAlive 26008,PropAssignedClientIdentifier +// "\203\139\241_\177[\169\210\172\136\138b\214\220\ESC\243",PropRequestProblemInformation 140,PropMaximumQoS 107]} TEST(Connect5QCTest, Encode11) { - uint8_t pkt[] = { - 0x10, 0xcc, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x53, 0xe3, 0x72, 0x21, 0x13, 0x1d, 0x15, 0x0, - 0x0, 0x15, 0x0, 0x12, 0x5d, 0xae, 0xfd, 0x1d, 0x92, 0x15, 0xec, 0xf5, 0xe3, 0x68, 0xd8, 0x12, 0x67, 0xf1, 0xae, - 0xd4, 0xfd, 0x3b, 0x21, 0x6, 0x99, 0x18, 0x0, 0x0, 0x6b, 0x1a, 0x17, 0xc5, 0xb, 0x15, 0x17, 0x44, 0x23, 0x3f, - 0xca, 0x1, 0x26, 0x23, 0x56, 0xa9, 0x1c, 0x0, 0xc, 0x70, 0xff, 0x4c, 0xf4, 0x41, 0xc1, 0x50, 0x16, 0x68, 0x8f, - 0xc8, 0xa8, 0x29, 0xb8, 0x27, 0x0, 0x0, 0x64, 0x22, 0x9, 0x0, 0x13, 0xb8, 0x55, 0xad, 0xcb, 0x1b, 0x4d, 0x74, - 0x41, 0x41, 0xe5, 0xb8, 0xdf, 0xcb, 0xde, 0xbe, 0x89, 0xc3, 0x33, 0xeb, 0x11, 0x0, 0x0, 0x1, 0x52, 0x29, 0x15, - 0x15, 0x0, 0xb, 0x87, 0x24, 0x91, 0x99, 0x1a, 0x31, 0xdf, 0x0, 0x13, 0xc, 0xf5, 0x0, 0x1, 0x82, 0xf2, 0x1, - 0x18, 0x0, 0x0, 0x10, 0x85, 0x9, 0x0, 0x1, 0x3a, 0x2, 0x0, 0x0, 0x7c, 0x53, 0x2, 0x0, 0x0, 0x71, 0x96, - 0x13, 0x40, 0x34, 0xb, 0xb, 0xb, 0x10, 0x16, 0x0, 0x1e, 0x12, 0xb, 0x7c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41, 0x56, 0xfa, 0x80, 0x6e, 0x71, 0x18, 0xe9, 0xe6, 0x93, 0xef, 0x40, 0x75, 0xef, + 0x2a, 0x0, 0x5, 0x39, 0xf6, 0x8d, 0x4d, 0x2b, 0x0, 0x12, 0x42, 0x7a, 0x54, 0xc2, 0x91, 0xc8, 0x11, + 0x7e, 0x12, 0xaa, 0x39, 0x4, 0x10, 0xd7, 0x2, 0xe8, 0xae, 0x6e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x5d, 0xae, 0xfd, 0x1d, 0x92, 0x15, 0xec, 0xf5, 0xe3, - 0x68, 0xd8, 0x12, 0x67, 0xf1, 0xae, 0xd4, 0xfd, 0x3b}; - uint8_t bytesprops2[] = {0x70, 0xff, 0x4c, 0xf4, 0x41, 0xc1, 0x50, 0x16, 0x68, 0x8f, 0xc8, 0xa8}; - uint8_t bytesprops3[] = {0xb8, 0x55, 0xad, 0xcb, 0x1b, 0x4d, 0x74, 0x41, 0x41, 0xe5, - 0xb8, 0xdf, 0xcb, 0xde, 0xbe, 0x89, 0xc3, 0x33, 0xeb}; - uint8_t bytesprops4[] = {0x87, 0x24, 0x91, 0x99, 0x1a, 0x31, 0xdf, 0x0, 0x13, 0xc, 0xf5}; + uint8_t bytesprops0[] = {0x21, 0x6, 0xc6, 0x3c, 0x12, 0x44, 0x44, 0xb, 0x2f, 0xc1, 0xe4, 0xea, 0xcc, 0x79, 0x26}; + uint8_t bytesprops1[] = {0xcb, 0x8b, 0xf1, 0x5f, 0xb1, 0x5b, 0xa9, 0xd2, + 0xac, 0x88, 0x8a, 0x62, 0xd6, 0xdc, 0x1b, 0xf3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4893}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1689}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27418}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16330}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22185}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25634}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 338}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops4}}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x3a}; - uint8_t byteswillprops1[] = {0x12, 0xb, 0x7c, 0xfe, 0x7b, 0xb3, 0x12, 0x6b, 0x97, 0x6f, 0x29, 0x1e, 0x13, 0xe, 0x81, - 0xc9, 0xb, 0x83, 0x58, 0xf6, 0x8d, 0xe1, 0x3e, 0x95, 0x32, 0x2d, 0x39, 0xf9, 0xfa, 0xa2}; - uint8_t byteswillprops2[] = {0x57, 0x48, 0x4, 0x4a, 0xa7, 0x7, 0x58, 0x9, 0xb3, 0x37, 0x3b, 0xb4, - 0x9a, 0x36, 0x99, 0xab, 0x46, 0x4f, 0x12, 0xec, 0xad, 0x8b, 0x53, 0xe8}; - uint8_t byteswillprops3[] = {0x13, 0x8f, 0x3b, 0x81, 0xa3, 0xef, 0x3a, 0xf0, 0x52, 0xf8, 0xbc, 0xb3, - 0x81, 0x9, 0x8b, 0x39, 0x6d, 0x27, 0x86, 0x23, 0xfa, 0x96, 0xa6}; - uint8_t byteswillprops4[] = {0x46, 0x98, 0x75, 0x99, 0x5f, 0x9b}; - uint8_t byteswillprops5[] = {0xe8, 0xfd, 0xb1, 0x73, 0xf7, 0x6d, 0xb2, 0xed, 0xe7, 0xde, 0xdd}; - uint8_t byteswillprops6[] = {0xd2, 0xaf, 0xd7, 0xa, 0x4d, 0x86, 0xd3, 0xda, 0x4a, 0x70, 0xe2, 0x52, 0x4, 0x1f, 0xe8, - 0x6a, 0x8, 0xd4, 0xef, 0x15, 0x41, 0xfd, 0x4a, 0x10, 0x9, 0xbb, 0xfd, 0xe5, 0xec}; - uint8_t byteswillprops7[] = {0x8c, 0x44, 0x70, 0xd, 0x52, 0xfa, 0x20, 0x92, 0xe, 0x9e, 0x95}; - uint8_t byteswillprops8[] = {0x70, 0xa3, 0x5d, 0xe1, 0x21, 0x5f, 0xb5, 0x57, 0x55, 0x21, 0xe7, 0xee, 0x3f, 0xc1, - 0x72, 0xa9, 0x8a, 0xa5, 0x9b, 0x55, 0x12, 0x38, 0x92, 0xa1, 0xfa, 0xc2, 0xa6}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4229}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31827}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29078}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16436}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14463}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7776}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9466}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5750}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28985}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26008}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 107}}, }; - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xba, 0x54, 0x6f, 0x39, 0x8b, 0xe6, 0x40, 0xe3, 0x57, 0x1a, 0xad, 0xaf, 0xfd, 0xa5, - 0xf, 0xc3, 0x85, 0x69, 0x14, 0x1b, 0xe5, 0x12, 0x3d, 0x7a, 0xfb, 0xba, 0xe7}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x72, 0x58, 0x4f, 0xd, 0x41, 0x1b, 0xc, 0x51, 0x12, 0x98, 0xe, - 0x17, 0x7b, 0xf8, 0xcb, 0xc5, 0x25, 0xaf, 0xcb, 0xeb, 0xe3}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 21475; - uint8_t client_id_bytes[] = {0x82}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; + opts.keep_alive = 30004; + uint8_t client_id_bytes[] = {0x5, 0xdd, 0x99, 0xe6, 0xd8, 0xa4, 0x8f, 0x46, 0x56, 0x62, 0xce, 0xf3, 0x41, 0x56, + 0xfa, 0x80, 0x6e, 0x71, 0x18, 0xe9, 0xe6, 0x93, 0xef, 0x40, 0x75, 0xef, 0x2a}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa7, 0x20, 0xa7, 0xd0, 0xe9, 0x66, 0xa7, 0xf6, 0x27, 0xf0, 0x54, 0xfc, 0x33, 0x21}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x39, 0xf6, 0x8d, 0x4d, 0x2b}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xcc, 0x70, 0x74, 0x42, 0x47, 0xa0, 0xb, 0x1a, 0xdf, - 0x21, 0x19, 0xf, 0x2, 0x8, 0x7f, 0x2b, 0x31, 0x5a}; + uint8_t password_bytes[] = {0x42, 0x7a, 0x54, 0xc2, 0x91, 0xc8, 0x11, 0x7e, 0x12, + 0xaa, 0x39, 0x4, 0x10, 0xd7, 0x2, 0xe8, 0xae, 0x6e}; lwmqtt_string_t password = {18, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "4\244\&1\217\142\&8\NAK5", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "e;\194\&7\237P\201 w\216\149l\171W\RS\241>\135`\SYN\ENQ\197\t", -// _willMsg = "2\174", _willProps = [PropResponseTopic -// "\142\216\206=\187\ETB?OH\195r\237\129\133f\190\219\150\200\142\rK\138",PropSubscriptionIdentifier -// 6,PropAssignedClientIdentifier "\161\USlM\STXUg",PropWillDelayInterval 6334,PropWildcardSubscriptionAvailable -// 70,PropWildcardSubscriptionAvailable 240,PropServerReference -// "\194wP\163\231\SO+\217\&92\136w&\214\STX*\NUL\ENQ3\GS\DC1",PropResponseInformation -// "\200V%\185",PropSubscriptionIdentifierAvailable 99,PropContentType -// "\n\175\138Sa\198o;r-",PropWildcardSubscriptionAvailable 150,PropReasonString "\220S\139Qd",PropTopicAlias -// 14266,PropAssignedClientIdentifier "D|%\142M?\148eEE\155\182",PropMessageExpiryInterval -// 2407,PropRequestProblemInformation 31,PropTopicAlias 15204,PropMessageExpiryInterval 7923,PropUserProperty -// "8h\199\190hz\234\230\235N\148\197a\246\225P\251\ETXd^iG\188\184\136\131" -// "\146\222\ENQ\v\SO\211i]2\FS\SYN\220\244\200\231\179\FS\\\150\196\188\149\155",PropMaximumQoS -// 134,PropPayloadFormatIndicator 8,PropReasonString "M(\249"]}), _cleanSession = True, _keepAlive = 29263, _connID = -// "\173Q\DC4\163\185\129\144\238\155\169Q\252K\131\227\&9\CAN\v\239", _properties = [PropTopicAlias -// 25630,PropSubscriptionIdentifier 6,PropSharedSubscriptionAvailable 158,PropResponseTopic -// "{G\NAK&0YDEtI",PropServerKeepAlive 11245,PropResponseInformation -// "\190d\136\&1\171D+.C\177\ACK\SI\167\145\135",PropSessionExpiryInterval 15509,PropRetainAvailable -// 18,PropServerKeepAlive 5583,PropContentType "+?\144\188^\165\&73\RSe\249\246\RSOa\177\128o",PropMaximumQoS -// 152,PropCorrelationData "@'\253[z\129K\139N\241\t\148\198TD\247\&0\193\DC1v\FSoud",PropPayloadFormatIndicator 23]} +// ConnectRequest {_username = Nothing, _password = Just "Q\GS\242\209", _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 6889, _connID = "hO\233g\n{qNO\160 ", _properties = [PropMaximumPacketSize +// 2412,PropSubscriptionIdentifierAvailable 15,PropMessageExpiryInterval 12333,PropRetainAvailable +// 136,PropReceiveMaximum 18567,PropCorrelationData "\203\ETB5\237J\251\141\244",PropSharedSubscriptionAvailable +// 240,PropReceiveMaximum 17848,PropMessageExpiryInterval 16262,PropPayloadFormatIndicator +// 153,PropSubscriptionIdentifier 9,PropSharedSubscriptionAvailable 114,PropReceiveMaximum +// 7802,PropMessageExpiryInterval 2285,PropTopicAliasMaximum 27265]} TEST(Connect5QCTest, Encode12) { - uint8_t pkt[] = { - 0x10, 0xf8, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x72, 0x4f, 0x67, 0x23, 0x64, 0x1e, 0xb, 0x6, - 0x2a, 0x9e, 0x8, 0x0, 0xa, 0x7b, 0x47, 0x15, 0x26, 0x30, 0x59, 0x44, 0x45, 0x74, 0x49, 0x13, 0x2b, 0xed, 0x1a, - 0x0, 0xf, 0xbe, 0x64, 0x88, 0x31, 0xab, 0x44, 0x2b, 0x2e, 0x43, 0xb1, 0x6, 0xf, 0xa7, 0x91, 0x87, 0x11, 0x0, - 0x0, 0x3c, 0x95, 0x25, 0x12, 0x13, 0x15, 0xcf, 0x3, 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 0x0, 0x8, 0xed, 0x22, 0x6a, 0x81, 0x0, 0xb, 0x68, 0x4f, 0xe9, 0x67, 0xa, + 0x7b, 0x71, 0x4e, 0x4f, 0xa0, 0x20, 0x0, 0x4, 0x51, 0x1d, 0xf2, 0xd1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7b, 0x47, 0x15, 0x26, 0x30, 0x59, 0x44, 0x45, 0x74, 0x49}; - uint8_t bytesprops1[] = {0xbe, 0x64, 0x88, 0x31, 0xab, 0x44, 0x2b, 0x2e, 0x43, 0xb1, 0x6, 0xf, 0xa7, 0x91, 0x87}; - uint8_t bytesprops2[] = {0x2b, 0x3f, 0x90, 0xbc, 0x5e, 0xa5, 0x37, 0x33, 0x1e, - 0x65, 0xf9, 0xf6, 0x1e, 0x4f, 0x61, 0xb1, 0x80, 0x6f}; - uint8_t bytesprops3[] = {0x40, 0x27, 0xfd, 0x5b, 0x7a, 0x81, 0x4b, 0x8b, 0x4e, 0xf1, 0x9, 0x94, - 0xc6, 0x54, 0x44, 0xf7, 0x30, 0xc1, 0x11, 0x76, 0x1c, 0x6f, 0x75, 0x64}; + uint8_t bytesprops0[] = {0xcb, 0x17, 0x35, 0xed, 0x4a, 0xfb, 0x8d, 0xf4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25630}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11245}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15509}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5583}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x8e, 0xd8, 0xce, 0x3d, 0xbb, 0x17, 0x3f, 0x4f, 0x48, 0xc3, 0x72, 0xed, - 0x81, 0x85, 0x66, 0xbe, 0xdb, 0x96, 0xc8, 0x8e, 0xd, 0x4b, 0x8a}; - uint8_t byteswillprops1[] = {0xa1, 0x1f, 0x6c, 0x4d, 0x2, 0x55, 0x67}; - uint8_t byteswillprops2[] = {0xc2, 0x77, 0x50, 0xa3, 0xe7, 0xe, 0x2b, 0xd9, 0x39, 0x32, 0x88, - 0x77, 0x26, 0xd6, 0x2, 0x2a, 0x0, 0x5, 0x33, 0x1d, 0x11}; - uint8_t byteswillprops3[] = {0xc8, 0x56, 0x25, 0xb9}; - uint8_t byteswillprops4[] = {0xa, 0xaf, 0x8a, 0x53, 0x61, 0xc6, 0x6f, 0x3b, 0x72, 0x2d}; - uint8_t byteswillprops5[] = {0xdc, 0x53, 0x8b, 0x51, 0x64}; - uint8_t byteswillprops6[] = {0x44, 0x7c, 0x25, 0x8e, 0x4d, 0x3f, 0x94, 0x65, 0x45, 0x45, 0x9b, 0xb6}; - uint8_t byteswillprops8[] = {0x92, 0xde, 0x5, 0xb, 0xe, 0xd3, 0x69, 0x5d, 0x32, 0x1c, 0x16, 0xdc, - 0xf4, 0xc8, 0xe7, 0xb3, 0x1c, 0x5c, 0x96, 0xc4, 0xbc, 0x95, 0x9b}; - uint8_t byteswillprops7[] = {0x38, 0x68, 0xc7, 0xbe, 0x68, 0x7a, 0xea, 0xe6, 0xeb, 0x4e, 0x94, 0xc5, 0x61, - 0xf6, 0xe1, 0x50, 0xfb, 0x3, 0x64, 0x5e, 0x69, 0x47, 0xbc, 0xb8, 0x88, 0x83}; - uint8_t byteswillprops9[] = {0x4d, 0x28, 0xf9}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 6}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6334}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14266}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2407}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15204}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7923}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {26, (char*)&byteswillprops7}, .v = {23, (char*)&byteswillprops8}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2412}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12333}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18567}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17848}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16262}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7802}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2285}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27265}}, }; - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x65, 0x3b, 0xc2, 0x37, 0xed, 0x50, 0xc9, 0x20, 0x77, 0xd8, 0x95, 0x6c, - 0xab, 0x57, 0x1e, 0xf1, 0x3e, 0x87, 0x60, 0x16, 0x5, 0xc5, 0x9}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x32, 0xae}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 29263; - uint8_t client_id_bytes[] = {0xad, 0x51, 0x14, 0xa3, 0xb9, 0x81, 0x90, 0xee, 0x9b, 0xa9, - 0x51, 0xfc, 0x4b, 0x83, 0xe3, 0x39, 0x18, 0xb, 0xef}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.keep_alive = 6889; + uint8_t client_id_bytes[] = {0x68, 0x4f, 0xe9, 0x67, 0xa, 0x7b, 0x71, 0x4e, 0x4f, 0xa0, 0x20}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x34, 0xf4, 0x31, 0xd9, 0x8e, 0x38, 0x15, 0x35}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x51, 0x1d, 0xf2, 0xd1}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\199\154\ACK\130\147\145\141\149\SOH", _lastWill = Nothing, -// _cleanSession = True, _keepAlive = 26934, _connID = "\185\183=\217", _properties = [PropCorrelationData -// "\239\210u(+\143u\173",PropRetainAvailable 45,PropSessionExpiryInterval 25383,PropMessageExpiryInterval -// 21093,PropCorrelationData "",PropMaximumQoS 7,PropReceiveMaximum 14060,PropSharedSubscriptionAvailable -// 253,PropReasonString "@\200)\189\162a6\159\v{l\235s\ETB",PropRetainAvailable 171,PropReceiveMaximum -// 21217,PropServerKeepAlive 27975,PropSharedSubscriptionAvailable 209,PropSessionExpiryInterval -// 13956,PropMessageExpiryInterval 30032,PropAuthenticationData -// "+\221gp\SOH7\175\233J0\244@\242v\176H\237i\133:\139t\134N\226\160",PropSessionExpiryInterval -// 11445,PropReceiveMaximum 30403,PropAssignedClientIdentifier -// "\221\&0\135\ETB\216\RSV\222\201t)\SOHi\v\218\212\128\225\133",PropRequestResponseInformation -// 138,PropRequestProblemInformation 79,PropResponseInformation -// "F7]\188[\250&\195\146Qa\189\203_\181\237\SOH\GS\241\130q\194\236\209\STX\250\242",PropMessageExpiryInterval -// 10611,PropTopicAlias 15572,PropAuthenticationMethod "X\187\141\177\&8\220\244\210\&8\214\200\144",PropRetainAvailable -// 159,PropSubscriptionIdentifierAvailable 212]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "", _willMsg = "\235\177\182N)\GS\253\200\252E\173b\141gO\165\169\ETX\va\209*", _willProps = +// [PropSubscriptionIdentifier 30,PropSharedSubscriptionAvailable 90,PropMaximumPacketSize +// 102,PropRequestResponseInformation 81,PropAssignedClientIdentifier "`T\n@\232\SI\as\ESCC;i\r\DC4\251_\220I.7<\216o +// ",PropReasonString "\161A\141\140e5\231YCa;c5A\176\174\237\131\184w<\f;@",PropRetainAvailable +// 202,PropRequestProblemInformation 6,PropSubscriptionIdentifier 8,PropPayloadFormatIndicator +// 24,PropAuthenticationMethod "\213z\RS\233\164t\162\&2\199vBQ\221",PropRetainAvailable +// 241,PropRequestResponseInformation 83,PropReasonString "[i",PropWillDelayInterval 715]}), _cleanSession = True, +// _keepAlive = 8360, _connID = "\178Ip\r*\206Y\141(\255\184\&4\224\197=\217\172\EM\EOT\\'\RS\229u\172S\202", +// _properties = [PropMaximumPacketSize 16932,PropContentType "",PropServerKeepAlive +// 19286,PropRequestResponseInformation 79,PropContentType +// "\187%]\190:\169\235R8\DC1r\ESCM3\162W\194V",PropSessionExpiryInterval 8066,PropUserProperty "\171" +// "\170B\211\DLE\250\SI\243\214mv\SOQR\"\STX\200\&3]y",PropSubscriptionIdentifier 9,PropAuthenticationMethod +// "\254\182\139U\216UC\239\185f9\143\SOH",PropPayloadFormatIndicator 79]} TEST(Connect5QCTest, Encode13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0xd, 0x14, 0xfb, 0x5f, 0xdc, 0x49, 0x2e, 0x37, 0x3c, 0xd8, 0x6f, 0x20, 0x1f, 0x0, 0x18, 0xa1, 0x41, + 0x8d, 0x8c, 0x65, 0x35, 0xe7, 0x59, 0x43, 0x61, 0x3b, 0x63, 0x35, 0x41, 0xb0, 0xae, 0xed, 0x83, 0xb8, 0x77, 0x3c, + 0xc, 0x3b, 0x40, 0x25, 0xca, 0x17, 0x6, 0xb, 0x8, 0x1, 0x18, 0x15, 0x0, 0xd, 0xd5, 0x7a, 0x1e, 0xe9, 0xa4, + 0x74, 0xa2, 0x32, 0xc7, 0x76, 0x42, 0x51, 0xdd, 0x25, 0xf1, 0x19, 0x53, 0x1f, 0x0, 0x2, 0x5b, 0x69, 0x18, 0x0, + 0x0, 0x2, 0xcb, 0x0, 0x0, 0x0, 0x16, 0xeb, 0xb1, 0xb6, 0x4e, 0x29, 0x1d, 0xfd, 0xc8, 0xfc, 0x45, 0xad, 0x62, + 0x8d, 0x67, 0x4f, 0xa5, 0xa9, 0x3, 0xb, 0x61, 0xd1, 0x2a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xef, 0xd2, 0x75, 0x28, 0x2b, 0x8f, 0x75, 0xad}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x40, 0xc8, 0x29, 0xbd, 0xa2, 0x61, 0x36, 0x9f, 0xb, 0x7b, 0x6c, 0xeb, 0x73, 0x17}; - uint8_t bytesprops3[] = {0x2b, 0xdd, 0x67, 0x70, 0x1, 0x37, 0xaf, 0xe9, 0x4a, 0x30, 0xf4, 0x40, 0xf2, - 0x76, 0xb0, 0x48, 0xed, 0x69, 0x85, 0x3a, 0x8b, 0x74, 0x86, 0x4e, 0xe2, 0xa0}; - uint8_t bytesprops4[] = {0xdd, 0x30, 0x87, 0x17, 0xd8, 0x1e, 0x56, 0xde, 0xc9, 0x74, - 0x29, 0x1, 0x69, 0xb, 0xda, 0xd4, 0x80, 0xe1, 0x85}; - uint8_t bytesprops5[] = {0x46, 0x37, 0x5d, 0xbc, 0x5b, 0xfa, 0x26, 0xc3, 0x92, 0x51, 0x61, 0xbd, 0xcb, 0x5f, - 0xb5, 0xed, 0x1, 0x1d, 0xf1, 0x82, 0x71, 0xc2, 0xec, 0xd1, 0x2, 0xfa, 0xf2}; - uint8_t bytesprops6[] = {0x58, 0xbb, 0x8d, 0xb1, 0x38, 0xdc, 0xf4, 0xd2, 0x38, 0xd6, 0xc8, 0x90}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xbb, 0x25, 0x5d, 0xbe, 0x3a, 0xa9, 0xeb, 0x52, 0x38, + 0x11, 0x72, 0x1b, 0x4d, 0x33, 0xa2, 0x57, 0xc2, 0x56}; + uint8_t bytesprops3[] = {0xaa, 0x42, 0xd3, 0x10, 0xfa, 0xf, 0xf3, 0xd6, 0x6d, 0x76, + 0xe, 0x51, 0x52, 0x22, 0x2, 0xc8, 0x33, 0x5d, 0x79}; + uint8_t bytesprops2[] = {0xab}; + uint8_t bytesprops4[] = {0xfe, 0xb6, 0x8b, 0x55, 0xd8, 0x55, 0x43, 0xef, 0xb9, 0x66, 0x39, 0x8f, 0x1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25383}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21093}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14060}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21217}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27975}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13956}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30032}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11445}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30403}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10611}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15572}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16932}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19286}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8066}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops2}, .v = {19, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 79}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x60, 0x54, 0xa, 0x40, 0xe8, 0xf, 0x7, 0x73, 0x1b, 0x43, 0x3b, 0x69, + 0xd, 0x14, 0xfb, 0x5f, 0xdc, 0x49, 0x2e, 0x37, 0x3c, 0xd8, 0x6f, 0x20}; + uint8_t byteswillprops1[] = {0xa1, 0x41, 0x8d, 0x8c, 0x65, 0x35, 0xe7, 0x59, 0x43, 0x61, 0x3b, 0x63, + 0x35, 0x41, 0xb0, 0xae, 0xed, 0x83, 0xb8, 0x77, 0x3c, 0xc, 0x3b, 0x40}; + uint8_t byteswillprops2[] = {0xd5, 0x7a, 0x1e, 0xe9, 0xa4, 0x74, 0xa2, 0x32, 0xc7, 0x76, 0x42, 0x51, 0xdd}; + uint8_t byteswillprops3[] = {0x5b, 0x69}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 102}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 715}}, + }; + + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xeb, 0xb1, 0xb6, 0x4e, 0x29, 0x1d, 0xfd, 0xc8, 0xfc, 0x45, 0xad, + 0x62, 0x8d, 0x67, 0x4f, 0xa5, 0xa9, 0x3, 0xb, 0x61, 0xd1, 0x2a}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 26934; - uint8_t client_id_bytes[] = {0xb9, 0xb7, 0x3d, 0xd9}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.keep_alive = 8360; + uint8_t client_id_bytes[] = {0xb2, 0x49, 0x70, 0xd, 0x2a, 0xce, 0x59, 0x8d, 0x28, 0xff, 0xb8, 0x34, 0xe0, 0xc5, + 0x3d, 0xd9, 0xac, 0x19, 0x4, 0x5c, 0x27, 0x1e, 0xe5, 0x75, 0xac, 0x53, 0xca}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xc7, 0x9a, 0x6, 0x82, 0x93, 0x91, 0x8d, 0x95, 0x1}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "-\247+\DC1\233}bt\ENQ\200\241\ENQ\SI\v\163F\173\246\236h\217\149Ur\237\DC3\244\208\217\EOT", _password = Just -// "\181\199$\147\180\ETX6\202", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\227\174\130\185\246$4`\SI^`\215\195\238\204OL\188\134\144\164\DLE^-\187\STX\DC4\224\178", _willMsg = -// "\210\221\DC4\SYN\212^\167\212v\131\142\DELq\191\136\237\&6\203\227.\181\SYN\138", _willProps = -// [PropWildcardSubscriptionAvailable 185,PropCorrelationData "\253l\182o\221\205\214\SYNp\231\191",PropRetainAvailable -// 187,PropMessageExpiryInterval 30413,PropMaximumQoS 59,PropResponseInformation -// "\216\249>\184\207%.\243\214\DC4\200`",PropReasonString -// "\190\CAN\v\247\172\195q\177C\171\&5{\248\&3[\223\135\134'",PropAuthenticationMethod -// "\248\229=L\165=\DC4\241\181<\174\188q.",PropAuthenticationData -// "\145\184I3\218\156\139\153\b\133,\182\np\DC3\132\ENQ\243\ETX\240\167\DC1\194B\ETXyl",PropResponseTopic -// "\200\SO\240\223\234\&0",PropRequestProblemInformation 177,PropResponseTopic -// "!\152`\198\148\140\DC1Q\CAN\v\242\192\182 \198",PropReasonString "C\253/\215",PropResponseTopic -// "\182-\146Y\196\b\202\214\DC2\145\148\ESC=\180\255Q+",PropSubscriptionIdentifier 11,PropServerReference -// "\203\233\242\153\166\246X\235\&5'\144!>\240\207\DLE9\217xr\158\255\241.j{",PropAuthenticationData -// "k\228\t_\252\165RF\179{Z\EOT\207\201\197SY'\234\135k\166\152;\DEL\172\242",PropTopicAlias 27251,PropContentType -// "\EOT\r\174\154f\165\"\195\158\201\SOH",PropSharedSubscriptionAvailable 57,PropUserProperty -// "b\144\251\240\US\245\NAK(\SIo%l\178\174V\191\226zD" "\159",PropResponseTopic -// "\rFi\SO`Aij5\231q\185\US6",PropSubscriptionIdentifier 18,PropMessageExpiryInterval -// 28407,PropRequestResponseInformation 129,PropReasonString "4p\203\141\133\153s4HZ",PropCorrelationData -// "x\193\204\&6\206\247",PropAssignedClientIdentifier "\246\&4\US+\aN\161\239a",PropAuthenticationMethod -// "\129\150\201}<\207"]}), _cleanSession = False, _keepAlive = 20204, _connID = "\140\212\218\244p", _properties = -// [PropAuthenticationMethod "\146P\t\153Y\136",PropSubscriptionIdentifier 17,PropReceiveMaximum -// 2002,PropCorrelationData "\231\223i~=e\160\196\175\232\198\138}\222\DC2j",PropAuthenticationMethod -// "\253\250AU5B\ETB\255[\210",PropUserProperty "\190\ETX\148*+\189" "D/e\215G?\202w\197\NAK\157\221\204\v\247\245 -// &z\146\141\245\SYN\CAN\181",PropPayloadFormatIndicator 213,PropTopicAlias 7603]} +// ConnectRequest {_username = Just "H\176\DC3\130\176@\132\210", _password = Just +// "\198\248\US\ETB\143\174JCT\DEL\221a\211\221;\179\128\182\154\207\189o", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS2, _willTopic = "\147.\146\246\203'\150]B\EMY\ETB\GS\tM\166q\196ug\DLE\t\191B", _willMsg = +// "\228\164\240r\184\245\201\DC2#9H\152\ETB\188\241\217\202\186\203\197D\220\162\&4\213", _willProps = +// [PropAuthenticationData "\162\166",PropWildcardSubscriptionAvailable 231,PropResponseTopic +// "\242\RSV\214\153\ACK\189\142\227\173\222\148\&6\208\137",PropSharedSubscriptionAvailable 253,PropTopicAlias +// 19038,PropSubscriptionIdentifier 12,PropMaximumPacketSize 28927,PropRequestResponseInformation 68,PropRetainAvailable +// 193,PropUserProperty "\226B" "\148\ACK\191!\\e\132\FS\173\227\NULs\250\221TZ\205T\vA\DC3/",PropContentType +// "r\SOB\STX",PropMaximumQoS 189,PropResponseTopic "\219\&6\187\201\169j\253\ENQR",PropResponseInformation +// "\203z\241N\186\139\215\187\196\189",PropSessionExpiryInterval 29995,PropResponseTopic +// "\240\235\n\224\r\199\222e\131\191D9DRk",PropServerKeepAlive 16658,PropMaximumPacketSize 12740,PropTopicAlias +// 1507,PropMessageExpiryInterval 14889,PropSharedSubscriptionAvailable 226,PropReceiveMaximum +// 15043,PropMaximumPacketSize 26334,PropReceiveMaximum 23369,PropRequestResponseInformation 254,PropUserProperty +// "B\189\RS\134\173%}\SIY\220\217\215\184\153\ahbz" "I\226\231\186\181\214\155",PropMessageExpiryInterval +// 1596,PropWildcardSubscriptionAvailable 35]}), _cleanSession = True, _keepAlive = 28532, _connID = +// "y\245\130FF#\\[\227\&0", _properties = [PropWillDelayInterval 8113,PropAuthenticationMethod +// "\132\SOD\229T\134\165",PropWillDelayInterval 7510,PropReasonString "\253\ACK\136\183\&1\211\&3",PropTopicAlias +// 28415]} TEST(Connect5QCTest, Encode14) { uint8_t pkt[] = { - 0x10, 0xa0, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x4e, 0xec, 0x57, 0x15, 0x0, 0x6, 0x92, 0x50, - 0x9, 0x99, 0x59, 0x88, 0xb, 0x11, 0x21, 0x7, 0xd2, 0x9, 0x0, 0x10, 0xe7, 0xdf, 0x69, 0x7e, 0x3d, 0x65, 0xa0, - 0xc4, 0xaf, 0xe8, 0xc6, 0x8a, 0x7d, 0xde, 0x12, 0x6a, 0x15, 0x0, 0xa, 0xfd, 0xfa, 0x41, 0x55, 0x35, 0x42, 0x17, - 0xff, 0x5b, 0xd2, 0x26, 0x0, 0x6, 0xbe, 0x3, 0x94, 0x2a, 0x2b, 0xbd, 0x0, 0x19, 0x44, 0x2f, 0x65, 0xd7, 0x47, - 0x3f, 0xca, 0x77, 0xc5, 0x15, 0x9d, 0xdd, 0xcc, 0xb, 0xf7, 0xf5, 0x20, 0x26, 0x7a, 0x92, 0x8d, 0xf5, 0x16, 0x18, - 0xb5, 0x1, 0xd5, 0x23, 0x1d, 0xb3, 0x0, 0x5, 0x8c, 0xd4, 0xda, 0x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 0xd5, 0x0, 0x8, 0x48, 0xb0, 0x13, 0x82, 0xb0, 0x40, 0x84, 0xd2, 0x0, 0x16, 0xc6, 0xf8, + 0x1f, 0x17, 0x8f, 0xae, 0x4a, 0x43, 0x54, 0x7f, 0xdd, 0x61, 0xd3, 0xdd, 0x3b, 0xb3, 0x80, 0xb6, 0x9a, 0xcf, 0xbd, + 0x6f}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x92, 0x50, 0x9, 0x99, 0x59, 0x88}; - uint8_t bytesprops1[] = {0xe7, 0xdf, 0x69, 0x7e, 0x3d, 0x65, 0xa0, 0xc4, - 0xaf, 0xe8, 0xc6, 0x8a, 0x7d, 0xde, 0x12, 0x6a}; - uint8_t bytesprops2[] = {0xfd, 0xfa, 0x41, 0x55, 0x35, 0x42, 0x17, 0xff, 0x5b, 0xd2}; - uint8_t bytesprops4[] = {0x44, 0x2f, 0x65, 0xd7, 0x47, 0x3f, 0xca, 0x77, 0xc5, 0x15, 0x9d, 0xdd, 0xcc, - 0xb, 0xf7, 0xf5, 0x20, 0x26, 0x7a, 0x92, 0x8d, 0xf5, 0x16, 0x18, 0xb5}; - uint8_t bytesprops3[] = {0xbe, 0x3, 0x94, 0x2a, 0x2b, 0xbd}; + uint8_t bytesprops0[] = {0x84, 0xe, 0x44, 0xe5, 0x54, 0x86, 0xa5}; + uint8_t bytesprops1[] = {0xfd, 0x6, 0x88, 0xb7, 0x31, 0xd3, 0x33}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2002}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops3}, .v = {25, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7603}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8113}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7510}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28415}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xfd, 0x6c, 0xb6, 0x6f, 0xdd, 0xcd, 0xd6, 0x16, 0x70, 0xe7, 0xbf}; - uint8_t byteswillprops1[] = {0xd8, 0xf9, 0x3e, 0xb8, 0xcf, 0x25, 0x2e, 0xf3, 0xd6, 0x14, 0xc8, 0x60}; - uint8_t byteswillprops2[] = {0xbe, 0x18, 0xb, 0xf7, 0xac, 0xc3, 0x71, 0xb1, 0x43, 0xab, - 0x35, 0x7b, 0xf8, 0x33, 0x5b, 0xdf, 0x87, 0x86, 0x27}; - uint8_t byteswillprops3[] = {0xf8, 0xe5, 0x3d, 0x4c, 0xa5, 0x3d, 0x14, 0xf1, 0xb5, 0x3c, 0xae, 0xbc, 0x71, 0x2e}; - uint8_t byteswillprops4[] = {0x91, 0xb8, 0x49, 0x33, 0xda, 0x9c, 0x8b, 0x99, 0x8, 0x85, 0x2c, 0xb6, 0xa, 0x70, - 0x13, 0x84, 0x5, 0xf3, 0x3, 0xf0, 0xa7, 0x11, 0xc2, 0x42, 0x3, 0x79, 0x6c}; - uint8_t byteswillprops5[] = {0xc8, 0xe, 0xf0, 0xdf, 0xea, 0x30}; - uint8_t byteswillprops6[] = {0x21, 0x98, 0x60, 0xc6, 0x94, 0x8c, 0x11, 0x51, 0x18, 0xb, 0xf2, 0xc0, 0xb6, 0x20, 0xc6}; - uint8_t byteswillprops7[] = {0x43, 0xfd, 0x2f, 0xd7}; - uint8_t byteswillprops8[] = {0xb6, 0x2d, 0x92, 0x59, 0xc4, 0x8, 0xca, 0xd6, 0x12, - 0x91, 0x94, 0x1b, 0x3d, 0xb4, 0xff, 0x51, 0x2b}; - uint8_t byteswillprops9[] = {0xcb, 0xe9, 0xf2, 0x99, 0xa6, 0xf6, 0x58, 0xeb, 0x35, 0x27, 0x90, 0x21, 0x3e, - 0xf0, 0xcf, 0x10, 0x39, 0xd9, 0x78, 0x72, 0x9e, 0xff, 0xf1, 0x2e, 0x6a, 0x7b}; - uint8_t byteswillprops10[] = {0x6b, 0xe4, 0x9, 0x5f, 0xfc, 0xa5, 0x52, 0x46, 0xb3, 0x7b, 0x5a, 0x4, 0xcf, 0xc9, - 0xc5, 0x53, 0x59, 0x27, 0xea, 0x87, 0x6b, 0xa6, 0x98, 0x3b, 0x7f, 0xac, 0xf2}; - uint8_t byteswillprops11[] = {0x4, 0xd, 0xae, 0x9a, 0x66, 0xa5, 0x22, 0xc3, 0x9e, 0xc9, 0x1}; - uint8_t byteswillprops13[] = {0x9f}; - uint8_t byteswillprops12[] = {0x62, 0x90, 0xfb, 0xf0, 0x1f, 0xf5, 0x15, 0x28, 0xf, 0x6f, - 0x25, 0x6c, 0xb2, 0xae, 0x56, 0xbf, 0xe2, 0x7a, 0x44}; - uint8_t byteswillprops14[] = {0xd, 0x46, 0x69, 0xe, 0x60, 0x41, 0x69, 0x6a, 0x35, 0xe7, 0x71, 0xb9, 0x1f, 0x36}; - uint8_t byteswillprops15[] = {0x34, 0x70, 0xcb, 0x8d, 0x85, 0x99, 0x73, 0x34, 0x48, 0x5a}; - uint8_t byteswillprops16[] = {0x78, 0xc1, 0xcc, 0x36, 0xce, 0xf7}; - uint8_t byteswillprops17[] = {0xf6, 0x34, 0x1f, 0x2b, 0x7, 0x4e, 0xa1, 0xef, 0x61}; - uint8_t byteswillprops18[] = {0x81, 0x96, 0xc9, 0x7d, 0x3c, 0xcf}; + uint8_t byteswillprops0[] = {0xa2, 0xa6}; + uint8_t byteswillprops1[] = {0xf2, 0x1e, 0x56, 0xd6, 0x99, 0x6, 0xbd, 0x8e, 0xe3, 0xad, 0xde, 0x94, 0x36, 0xd0, 0x89}; + uint8_t byteswillprops3[] = {0x94, 0x6, 0xbf, 0x21, 0x5c, 0x65, 0x84, 0x1c, 0xad, 0xe3, 0x0, + 0x73, 0xfa, 0xdd, 0x54, 0x5a, 0xcd, 0x54, 0xb, 0x41, 0x13, 0x2f}; + uint8_t byteswillprops2[] = {0xe2, 0x42}; + uint8_t byteswillprops4[] = {0x72, 0xe, 0x42, 0x2}; + uint8_t byteswillprops5[] = {0xdb, 0x36, 0xbb, 0xc9, 0xa9, 0x6a, 0xfd, 0x5, 0x52}; + uint8_t byteswillprops6[] = {0xcb, 0x7a, 0xf1, 0x4e, 0xba, 0x8b, 0xd7, 0xbb, 0xc4, 0xbd}; + uint8_t byteswillprops7[] = {0xf0, 0xeb, 0xa, 0xe0, 0xd, 0xc7, 0xde, 0x65, 0x83, 0xbf, 0x44, 0x39, 0x44, 0x52, 0x6b}; + uint8_t byteswillprops9[] = {0x49, 0xe2, 0xe7, 0xba, 0xb5, 0xd6, 0x9b}; + uint8_t byteswillprops8[] = {0x42, 0xbd, 0x1e, 0x86, 0xad, 0x25, 0x7d, 0xf, 0x59, + 0xdc, 0xd9, 0xd7, 0xb8, 0x99, 0x7, 0x68, 0x62, 0x7a}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30413}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27251}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19038}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28927}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {2, (char*)&byteswillprops2}, .v = {22, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29995}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16658}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12740}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1507}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14889}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15043}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26334}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23369}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 254}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {19, (char*)&byteswillprops12}, .v = {1, (char*)&byteswillprops13}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&byteswillprops14}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 18}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28407}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops15}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops16}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops17}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops18}}}, + .value = {.pair = {.k = {18, (char*)&byteswillprops8}, .v = {7, (char*)&byteswillprops9}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1596}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, }; - lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe3, 0xae, 0x82, 0xb9, 0xf6, 0x24, 0x34, 0x60, 0xf, 0x5e, - 0x60, 0xd7, 0xc3, 0xee, 0xcc, 0x4f, 0x4c, 0xbc, 0x86, 0x90, - 0xa4, 0x10, 0x5e, 0x2d, 0xbb, 0x2, 0x14, 0xe0, 0xb2}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd2, 0xdd, 0x14, 0x16, 0xd4, 0x5e, 0xa7, 0xd4, 0x76, 0x83, 0x8e, 0x7f, - 0x71, 0xbf, 0x88, 0xed, 0x36, 0xcb, 0xe3, 0x2e, 0xb5, 0x16, 0x8a}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x93, 0x2e, 0x92, 0xf6, 0xcb, 0x27, 0x96, 0x5d, 0x42, 0x19, 0x59, 0x17, + 0x1d, 0x9, 0x4d, 0xa6, 0x71, 0xc4, 0x75, 0x67, 0x10, 0x9, 0xbf, 0x42}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe4, 0xa4, 0xf0, 0x72, 0xb8, 0xf5, 0xc9, 0x12, 0x23, 0x39, 0x48, 0x98, 0x17, + 0xbc, 0xf1, 0xd9, 0xca, 0xba, 0xcb, 0xc5, 0x44, 0xdc, 0xa2, 0x34, 0xd5}; + lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 20204; - uint8_t client_id_bytes[] = {0x8c, 0xd4, 0xda, 0xf4, 0x70}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 28532; + uint8_t client_id_bytes[] = {0x79, 0xf5, 0x82, 0x46, 0x46, 0x23, 0x5c, 0x5b, 0xe3, 0x30}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2d, 0xf7, 0x2b, 0x11, 0xe9, 0x7d, 0x62, 0x74, 0x5, 0xc8, 0xf1, 0x5, 0xf, 0xb, 0xa3, - 0x46, 0xad, 0xf6, 0xec, 0x68, 0xd9, 0x95, 0x55, 0x72, 0xed, 0x13, 0xf4, 0xd0, 0xd9, 0x4}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x48, 0xb0, 0x13, 0x82, 0xb0, 0x40, 0x84, 0xd2}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xb5, 0xc7, 0x24, 0x93, 0xb4, 0x3, 0x36, 0xca}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xc6, 0xf8, 0x1f, 0x17, 0x8f, 0xae, 0x4a, 0x43, 0x54, 0x7f, 0xdd, + 0x61, 0xd3, 0xdd, 0x3b, 0xb3, 0x80, 0xb6, 0x9a, 0xcf, 0xbd, 0x6f}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8185,141 +8178,139 @@ TEST(Connect5QCTest, Encode14) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "r=\231\144i:\207\214h\149\199\202J", _password = Just "2\202\ACK*\135", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "rx&4\204G@rz\177>", _willMsg = "\237\222\176\197", -// _willProps = [PropResponseInformation "\198\198\223u\a\169",PropRetainAvailable 233,PropServerReference -// "x\RS\SI\v\251\NAK\NAK\157\148\130%\152@b\232",PropAuthenticationData -// "L{\162\164EUW\167B|\224\138\133\186\146\&4\147\199\136U",PropPayloadFormatIndicator 12,PropMessageExpiryInterval -// 30724,PropMaximumQoS 44,PropSharedSubscriptionAvailable 110,PropWillDelayInterval 3149,PropAuthenticationMethod -// "W]\140\205m\173\199\SOHRz\176 \170\228w(\200\EMv",PropWildcardSubscriptionAvailable 88,PropTopicAliasMaximum -// 12841,PropAuthenticationData "\209,}0\154\144\219G\230\178\134\131S",PropMessageExpiryInterval -// 13071,PropReceiveMaximum 29819,PropSessionExpiryInterval 26236,PropSubscriptionIdentifierAvailable -// 62,PropSubscriptionIdentifierAvailable 223,PropPayloadFormatIndicator 153,PropTopicAlias 13671,PropTopicAliasMaximum -// 17153,PropWillDelayInterval 5290]}), _cleanSession = False, _keepAlive = 11274, _connID = -// "\223\t\143\166\173\230\156\142\250\&1\248\EOT\185\ACK\235\144\155+\249\150\182\136\232\133\206", _properties = -// [PropReceiveMaximum 8593,PropWildcardSubscriptionAvailable 11,PropRequestProblemInformation 0,PropAuthenticationData -// "\141\DLE/\fO\251}\246\ENQ\137\187\EMNq\DC4\227\253\151\237V",PropContentType -// "x\167\208\240\204\138\238\184J\181\SI\212\215\137",PropUserProperty -// "-\236\nC\144\225\&3j\FS\184U\RS\194l\182z\192|\202\195\158\191\149l.\177\204\240" -// "1\221\133\201\162\ETX\238\165\226\137\173\170",PropUserProperty "\250\191m\157\191N\186\&1\RS\231\ENQN" -// "\SUB\242^i=\134\142\DC3\242\226Q\SOH\141\138f\226\194\196\219\158\128Jt\131\ti",PropResponseInformation -// "\158\239\130\168\DC2u7\130%\144\\\GSa#\199'\227|y\192\182",PropSharedSubscriptionAvailable -// 40,PropRequestResponseInformation 156,PropContentType -// "\140\220d\189\208\DC1\159\169B\DC1\130\181\155\157h2\ETX\DEL\175}\231\132\a\196\222oY",PropCorrelationData "p5"]} +// ConnectRequest {_username = Just "\232\220\210", _password = Just +// "Q\222\CAN\156\222j\201*\143\147\STX\155\152P\n\166#\139", _lastWill = Just (LastWill {_willRetain = False, _willQoS +// = QoS2, _willTopic = "\NAK\166\247\190f\227\STX", _willMsg = +// "Pu4\232\181\200\&73\211\251l\247WIl\248g\236i\218\139\136\182\208\241!\195\244\162", _willProps = +// [PropAssignedClientIdentifier "\179\229\155(5)\221Vb\198I\"\142\239Nn\210\ESC\209-\ESCa",PropServerReference +// "\ESC\176x\EOT\239^r\v\242",PropWildcardSubscriptionAvailable 237,PropSubscriptionIdentifier +// 14,PropAuthenticationData +// "\145\231\151\ACK\174\232\212\178\DC3v\EOT\150\129B\215c\212\193c\DELd\137",PropMessageExpiryInterval 8788]}), +// _cleanSession = False, _keepAlive = 16792, _connID = "\144\154@\235\163ha\251\SO\244\151\244\235", _properties = +// [PropReasonString +// "\153\252\153\234\157\229lb\GS\201\f#d\239\DC2|Y\v\244\174\237\DC4\136\168\233A\148\220\143",PropServerKeepAlive +// 4154,PropTopicAlias 807,PropAssignedClientIdentifier "\SO;{>\RS\183}\239\229tL\200\147\242k5M",PropReasonString +// "+\r6\ETXV\214",PropSubscriptionIdentifier 10,PropResponseTopic +// "=G\163\128\221\STX\160\208\190]\DEL",PropMessageExpiryInterval 15432,PropMaximumPacketSize 7769,PropServerKeepAlive +// 18572,PropUserProperty "\215d\164\215\246LY\134\176\138\220" +// "q\199\EM\134\ETB\143\133\173\242U\224\&5\243\159\SO\144\CANi",PropContentType +// "\213(\"\163\159\144\214\129~\DEL\188nt$\236J\187:\130@\253\n\150\131;Cq",PropServerKeepAlive +// 23472,PropAuthenticationData "!w",PropSessionExpiryInterval 18606,PropSubscriptionIdentifierAvailable +// 170,PropMessageExpiryInterval 32525,PropSessionExpiryInterval 16843,PropMaximumQoS 235,PropMaximumPacketSize +// 1603,PropAuthenticationMethod "\STX\245\226\t",PropSharedSubscriptionAvailable 59,PropUserProperty +// "\240\212\181\250\165\139\166\129\219\192\195x;\249\133\ACK\220@\157O\183\161\227\DC4\140" +// "\241+\165S\140\231",PropSubscriptionIdentifier 8]} TEST(Connect5QCTest, Encode15) { uint8_t pkt[] = { - 0x10, 0xa5, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x2c, 0xa, 0xc6, 0x1, 0x21, 0x21, 0x91, 0x28, - 0xb, 0x17, 0x0, 0x16, 0x0, 0x14, 0x8d, 0x10, 0x2f, 0xc, 0x4f, 0xfb, 0x7d, 0xf6, 0x5, 0x89, 0xbb, 0x19, 0x4e, - 0x71, 0x14, 0xe3, 0xfd, 0x97, 0xed, 0x56, 0x3, 0x0, 0xe, 0x78, 0xa7, 0xd0, 0xf0, 0xcc, 0x8a, 0xee, 0xb8, 0x4a, - 0xb5, 0xf, 0xd4, 0xd7, 0x89, 0x26, 0x0, 0x1c, 0x2d, 0xec, 0xa, 0x43, 0x90, 0xe1, 0x33, 0x6a, 0x1c, 0xb8, 0x55, - 0x1e, 0xc2, 0x6c, 0xb6, 0x7a, 0xc0, 0x7c, 0xca, 0xc3, 0x9e, 0xbf, 0x95, 0x6c, 0x2e, 0xb1, 0xcc, 0xf0, 0x0, 0xc, - 0x31, 0xdd, 0x85, 0xc9, 0xa2, 0x3, 0xee, 0xa5, 0xe2, 0x89, 0xad, 0xaa, 0x26, 0x0, 0xc, 0xfa, 0xbf, 0x6d, 0x9d, - 0xbf, 0x4e, 0xba, 0x31, 0x1e, 0xe7, 0x5, 0x4e, 0x0, 0x1a, 0x1a, 0xf2, 0x5e, 0x69, 0x3d, 0x86, 0x8e, 0x13, 0xf2, - 0xe2, 0x51, 0x1, 0x8d, 0x8a, 0x66, 0xe2, 0xc2, 0xc4, 0xdb, 0x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0x49, 0x22, + 0x8e, 0xef, 0x4e, 0x6e, 0xd2, 0x1b, 0xd1, 0x2d, 0x1b, 0x61, 0x1c, 0x0, 0x9, 0x1b, 0xb0, 0x78, 0x4, 0xef, 0x5e, + 0x72, 0xb, 0xf2, 0x28, 0xed, 0xb, 0xe, 0x16, 0x0, 0x16, 0x91, 0xe7, 0x97, 0x6, 0xae, 0xe8, 0xd4, 0xb2, 0x13, + 0x76, 0x4, 0x96, 0x81, 0x42, 0xd7, 0x63, 0xd4, 0xc1, 0x63, 0x7f, 0x64, 0x89, 0x2, 0x0, 0x0, 0x22, 0x54, 0x0, + 0x7, 0x15, 0xa6, 0xf7, 0xbe, 0x66, 0xe3, 0x2, 0x0, 0x1d, 0x50, 0x75, 0x34, 0xe8, 0xb5, 0xc8, 0x37, 0x33, 0xd3, + 0xfb, 0x6c, 0xf7, 0x57, 0x49, 0x6c, 0xf8, 0x67, 0xec, 0x69, 0xda, 0x8b, 0x88, 0xb6, 0xd0, 0xf1, 0x21, 0xc3, 0xf4, + 0xa2, 0x0, 0x3, 0xe8, 0xdc, 0xd2, 0x0, 0x12, 0x51, 0xde, 0x18, 0x9c, 0xde, 0x6a, 0xc9, 0x2a, 0x8f, 0x93, 0x2, + 0x9b, 0x98, 0x50, 0xa, 0xa6, 0x23, 0x8b}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x8d, 0x10, 0x2f, 0xc, 0x4f, 0xfb, 0x7d, 0xf6, 0x5, 0x89, - 0xbb, 0x19, 0x4e, 0x71, 0x14, 0xe3, 0xfd, 0x97, 0xed, 0x56}; - uint8_t bytesprops1[] = {0x78, 0xa7, 0xd0, 0xf0, 0xcc, 0x8a, 0xee, 0xb8, 0x4a, 0xb5, 0xf, 0xd4, 0xd7, 0x89}; - uint8_t bytesprops3[] = {0x31, 0xdd, 0x85, 0xc9, 0xa2, 0x3, 0xee, 0xa5, 0xe2, 0x89, 0xad, 0xaa}; - uint8_t bytesprops2[] = {0x2d, 0xec, 0xa, 0x43, 0x90, 0xe1, 0x33, 0x6a, 0x1c, 0xb8, 0x55, 0x1e, 0xc2, 0x6c, - 0xb6, 0x7a, 0xc0, 0x7c, 0xca, 0xc3, 0x9e, 0xbf, 0x95, 0x6c, 0x2e, 0xb1, 0xcc, 0xf0}; - uint8_t bytesprops5[] = {0x1a, 0xf2, 0x5e, 0x69, 0x3d, 0x86, 0x8e, 0x13, 0xf2, 0xe2, 0x51, 0x1, 0x8d, - 0x8a, 0x66, 0xe2, 0xc2, 0xc4, 0xdb, 0x9e, 0x80, 0x4a, 0x74, 0x83, 0x9, 0x69}; - uint8_t bytesprops4[] = {0xfa, 0xbf, 0x6d, 0x9d, 0xbf, 0x4e, 0xba, 0x31, 0x1e, 0xe7, 0x5, 0x4e}; - uint8_t bytesprops6[] = {0x9e, 0xef, 0x82, 0xa8, 0x12, 0x75, 0x37, 0x82, 0x25, 0x90, 0x5c, - 0x1d, 0x61, 0x23, 0xc7, 0x27, 0xe3, 0x7c, 0x79, 0xc0, 0xb6}; - uint8_t bytesprops7[] = {0x8c, 0xdc, 0x64, 0xbd, 0xd0, 0x11, 0x9f, 0xa9, 0x42, 0x11, 0x82, 0xb5, 0x9b, 0x9d, - 0x68, 0x32, 0x3, 0x7f, 0xaf, 0x7d, 0xe7, 0x84, 0x7, 0xc4, 0xde, 0x6f, 0x59}; - uint8_t bytesprops8[] = {0x70, 0x35}; + uint8_t bytesprops0[] = {0x99, 0xfc, 0x99, 0xea, 0x9d, 0xe5, 0x6c, 0x62, 0x1d, 0xc9, 0xc, 0x23, 0x64, 0xef, 0x12, + 0x7c, 0x59, 0xb, 0xf4, 0xae, 0xed, 0x14, 0x88, 0xa8, 0xe9, 0x41, 0x94, 0xdc, 0x8f}; + uint8_t bytesprops1[] = {0xe, 0x3b, 0x7b, 0x3e, 0x1e, 0xb7, 0x7d, 0xef, 0xe5, + 0x74, 0x4c, 0xc8, 0x93, 0xf2, 0x6b, 0x35, 0x4d}; + uint8_t bytesprops2[] = {0x2b, 0xd, 0x36, 0x3, 0x56, 0xd6}; + uint8_t bytesprops3[] = {0x3d, 0x47, 0xa3, 0x80, 0xdd, 0x2, 0xa0, 0xd0, 0xbe, 0x5d, 0x7f}; + uint8_t bytesprops5[] = {0x71, 0xc7, 0x19, 0x86, 0x17, 0x8f, 0x85, 0xad, 0xf2, + 0x55, 0xe0, 0x35, 0xf3, 0x9f, 0xe, 0x90, 0x18, 0x69}; + uint8_t bytesprops4[] = {0xd7, 0x64, 0xa4, 0xd7, 0xf6, 0x4c, 0x59, 0x86, 0xb0, 0x8a, 0xdc}; + uint8_t bytesprops6[] = {0xd5, 0x28, 0x22, 0xa3, 0x9f, 0x90, 0xd6, 0x81, 0x7e, 0x7f, 0xbc, 0x6e, 0x74, 0x24, + 0xec, 0x4a, 0xbb, 0x3a, 0x82, 0x40, 0xfd, 0xa, 0x96, 0x83, 0x3b, 0x43, 0x71}; + uint8_t bytesprops7[] = {0x21, 0x77}; + uint8_t bytesprops8[] = {0x2, 0xf5, 0xe2, 0x9}; + uint8_t bytesprops10[] = {0xf1, 0x2b, 0xa5, 0x53, 0x8c, 0xe7}; + uint8_t bytesprops9[] = {0xf0, 0xd4, 0xb5, 0xfa, 0xa5, 0x8b, 0xa6, 0x81, 0xdb, 0xc0, 0xc3, 0x78, 0x3b, + 0xf9, 0x85, 0x6, 0xdc, 0x40, 0x9d, 0x4f, 0xb7, 0xa1, 0xe3, 0x14, 0x8c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8593}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops2}, .v = {12, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops4}, .v = {26, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4154}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 807}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15432}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7769}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18572}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops4}, .v = {18, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23472}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18606}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32525}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16843}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1603}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops9}, .v = {6, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc6, 0xc6, 0xdf, 0x75, 0x7, 0xa9}; - uint8_t byteswillprops1[] = {0x78, 0x1e, 0xf, 0xb, 0xfb, 0x15, 0x15, 0x9d, 0x94, 0x82, 0x25, 0x98, 0x40, 0x62, 0xe8}; - uint8_t byteswillprops2[] = {0x4c, 0x7b, 0xa2, 0xa4, 0x45, 0x55, 0x57, 0xa7, 0x42, 0x7c, - 0xe0, 0x8a, 0x85, 0xba, 0x92, 0x34, 0x93, 0xc7, 0x88, 0x55}; - uint8_t byteswillprops3[] = {0x57, 0x5d, 0x8c, 0xcd, 0x6d, 0xad, 0xc7, 0x1, 0x52, 0x7a, - 0xb0, 0x20, 0xaa, 0xe4, 0x77, 0x28, 0xc8, 0x19, 0x76}; - uint8_t byteswillprops4[] = {0xd1, 0x2c, 0x7d, 0x30, 0x9a, 0x90, 0xdb, 0x47, 0xe6, 0xb2, 0x86, 0x83, 0x53}; + uint8_t byteswillprops0[] = {0xb3, 0xe5, 0x9b, 0x28, 0x35, 0x29, 0xdd, 0x56, 0x62, 0xc6, 0x49, + 0x22, 0x8e, 0xef, 0x4e, 0x6e, 0xd2, 0x1b, 0xd1, 0x2d, 0x1b, 0x61}; + uint8_t byteswillprops1[] = {0x1b, 0xb0, 0x78, 0x4, 0xef, 0x5e, 0x72, 0xb, 0xf2}; + uint8_t byteswillprops2[] = {0x91, 0xe7, 0x97, 0x6, 0xae, 0xe8, 0xd4, 0xb2, 0x13, 0x76, 0x4, + 0x96, 0x81, 0x42, 0xd7, 0x63, 0xd4, 0xc1, 0x63, 0x7f, 0x64, 0x89}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30724}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3149}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12841}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13071}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29819}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26236}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13671}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17153}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5290}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8788}}, }; - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x72, 0x78, 0x26, 0x34, 0xcc, 0x47, 0x40, 0x72, 0x7a, 0xb1, 0x3e}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xed, 0xde, 0xb0, 0xc5}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x15, 0xa6, 0xf7, 0xbe, 0x66, 0xe3, 0x2}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x50, 0x75, 0x34, 0xe8, 0xb5, 0xc8, 0x37, 0x33, 0xd3, 0xfb, + 0x6c, 0xf7, 0x57, 0x49, 0x6c, 0xf8, 0x67, 0xec, 0x69, 0xda, + 0x8b, 0x88, 0xb6, 0xd0, 0xf1, 0x21, 0xc3, 0xf4, 0xa2}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 11274; - uint8_t client_id_bytes[] = {0xdf, 0x9, 0x8f, 0xa6, 0xad, 0xe6, 0x9c, 0x8e, 0xfa, 0x31, 0xf8, 0x4, 0xb9, - 0x6, 0xeb, 0x90, 0x9b, 0x2b, 0xf9, 0x96, 0xb6, 0x88, 0xe8, 0x85, 0xce}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.keep_alive = 16792; + uint8_t client_id_bytes[] = {0x90, 0x9a, 0x40, 0xeb, 0xa3, 0x68, 0x61, 0xfb, 0xe, 0xf4, 0x97, 0xf4, 0xeb}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x72, 0x3d, 0xe7, 0x90, 0x69, 0x3a, 0xcf, 0xd6, 0x68, 0x95, 0xc7, 0xca, 0x4a}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xe8, 0xdc, 0xd2}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x32, 0xca, 0x6, 0x2a, 0x87}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x51, 0xde, 0x18, 0x9c, 0xde, 0x6a, 0xc9, 0x2a, 0x8f, + 0x93, 0x2, 0x9b, 0x98, 0x50, 0xa, 0xa6, 0x23, 0x8b}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8329,186 +8320,132 @@ TEST(Connect5QCTest, Encode15) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "#Q\186\\\192N\NUL\ETB\159\205\a\194`T\211\EM\157\133\ACKf;Z\189\220\129\164", _willMsg = -// "\EOT\228!\252NLON\246\199\210g\235\225\255\130\139\v ", _willProps = [PropMaximumPacketSize 15164,PropResponseTopic -// "[X\186\ENQ\244",PropWildcardSubscriptionAvailable 129,PropContentType -// "\137\DLEHZIp'\222\212\195\246+{g_\155\199\244\162\GS\232\ACK\FS\227\241^",PropReceiveMaximum -// 14987,PropWildcardSubscriptionAvailable 119,PropResponseTopic -// "\243\133S;-\190\EOT\238\138\FSl\218\DC2\249\DC1*\fqJ\128\226R\181",PropMessageExpiryInterval -// 3660,PropCorrelationData "\252l\236\173\161\130\147\175ZO`\186\235?4\154[d l-\189\EOTd\139T",PropAuthenticationData -// "\b\164\ETX\171\133\221\191\DEL\245\159\137\186\129{\230\215_\136M\143\203\172D\137\129\EM",PropRetainAvailable -// 48,PropUserProperty "$\176w\130\170X\153NdQ\210+\134\215\ETX\227" -// "\206=\255&\220\130\131\b\ENQ\221f\146\162m\196y{\237\202\232\220@v\181\146-",PropReceiveMaximum 30893,PropServerReference -// "D",PropWildcardSubscriptionAvailable 103,PropServerKeepAlive 9030,PropRetainAvailable 158,PropMaximumPacketSize -// 17128,PropServerKeepAlive 13020,PropServerKeepAlive 17468]} +// ConnectRequest {_username = Just "\208\&08\153\253\129\180\139MgC\ACKe\252k\131\238w\f\234\212", _password = Just +// "\174\131\134S\237\RS", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "oa\v,+\129{\223N\216\&2}\SI\161-\165a\146\&7\248\166\224\189\SOH\ESC\182", _willMsg = "m]", _willProps = +// [PropMessageExpiryInterval 7966,PropReceiveMaximum 11454,PropTopicAliasMaximum 24638,PropCorrelationData +// "p\175>\180\160\170",PropCorrelationData "r\194\&1",PropResponseTopic "\134\DC4\197Knd +// \164n\NULU\194F!#\247*\151,\EM\184\249\CAN(\174.",PropRequestResponseInformation 39,PropWildcardSubscriptionAvailable +// 177,PropSubscriptionIdentifier 5,PropRequestResponseInformation 9,PropSubscriptionIdentifier +// 19,PropRequestProblemInformation 250,PropMaximumQoS 197,PropRequestProblemInformation 121,PropTopicAliasMaximum +// 28781,PropPayloadFormatIndicator 13,PropRequestResponseInformation 188,PropUserProperty "I~i\190\250" +// "\247\151\212\245=/P\218\160\218\DC2\186\232P\220\151n\STXW+\140\132l\221P\137\191Hn\173\243\209\180\171\208\128\CAN?Ii\FS#" +// "\GS\194>g\216yKl:\210@\f!\ESC.\201\130F\a\198\137??{\EOT9\200\235\ESC\211",PropMessageExpiryInterval +// 4108,PropRequestResponseInformation 206,PropTopicAliasMaximum 1362,PropMessageExpiryInterval 20063,PropUserProperty +// "\a\245\144%?!\255\206\199\227g" "\195_\203\179-\241\207\137\&27\135",PropSessionExpiryInterval +// 2669,PropRequestResponseInformation 237,PropUserProperty +// "\216\228\164\208\222\234m4\200\156\\\SUB\176\252\167>\227\217\SOH\252f\185\186/\245\220l.=\233" +// "\212\206v\243\&0\235g\200\250\188\207P\ETB\130\167\137@(\191_\139\DC3}\238\227",PropServerKeepAlive +// 13533,PropResponseInformation "\151\195\168\188?\165}",PropContentType +// "\182\152!\SO\214\245\202\210\FS&",PropMessageExpiryInterval 14172]}), _cleanSession = False, _keepAlive = 6602, +// _connID = "%\197u\242|QM/\NUL\239\144\a\176\173\138\248\143\&0>8", _properties = [PropMessageExpiryInterval +// 3109,PropSubscriptionIdentifier 11,PropWildcardSubscriptionAvailable 69,PropWildcardSubscriptionAvailable +// 86,PropContentType "\254B\140\166M\249F\180\b\DC1\168\f\234L\160}R9\235\156Fr\150",PropReceiveMaximum +// 10259,PropTopicAlias 18041,PropMessageExpiryInterval 29565,PropContentType +// "\DC1\ETB\251\238\242\222\186f\209\STX\197\US\239:P[W\222\&9\238-",PropMessageExpiryInterval +// 2224,PropSubscriptionIdentifierAvailable 181,PropWildcardSubscriptionAvailable 82,PropWillDelayInterval +// 17653,PropWillDelayInterval 32460,PropUserProperty +// "k\224`c\182a\166\232\&2\179\209\150\145\220\DLE~\213k\SI\177\138N\157m\211q\247\182\178O" +// "\244\204{\211\152\222\198Y\231M5NT\244\203\b9\129\CAN\254\RSS\t\242\222\140\160O\148\223",PropMaximumQoS +// 148,PropReceiveMaximum 1807,PropServerReference "\173\180\137",PropAuthenticationMethod +// ",\161\144",PropPayloadFormatIndicator 93,PropResponseInformation "\208nX~",PropPayloadFormatIndicator +// 225,PropMessageExpiryInterval 28847]} TEST(Connect5QCTest, Encode17) { - uint8_t pkt[] = {0x10, 0x84, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x8, 0x75, 0x5c, 0x29, 0x50, 0x1, - 0x99, 0x1, 0x2d, 0x22, 0x6d, 0x86, 0x19, 0xf8, 0x29, 0x23, 0x11, 0x0, 0x0, 0x37, 0x68, 0xb, 0x11, - 0x11, 0x0, 0x0, 0x62, 0x23, 0x19, 0x50, 0x19, 0xd6, 0xb, 0xb, 0x21, 0x5d, 0xd9, 0x26, 0x0, 0xe, - 0x51, 0xf9, 0xa3, 0xf9, 0x2d, 0xc5, 0xc5, 0x72, 0x5, 0xef, 0x1f, 0x65, 0xd6, 0x91, 0x0, 0x8, 0x19, - 0x49, 0xce, 0x47, 0x2e, 0xd, 0xb7, 0x76, 0x22, 0x28, 0x2c, 0x13, 0x75, 0xf1, 0x18, 0x0, 0x0, 0x4b, - 0x6b, 0x26, 0x0, 0xe, 0x76, 0xae, 0x85, 0x5b, 0xac, 0x36, 0x5, 0x97, 0xc8, 0xf2, 0x8a, 0xa7, 0xd5, - 0x27, 0x0, 0x1, 0xf9, 0x0, 0xc, 0x3b, 0x6c, 0xc0, 0x11, 0x4e, 0x9c, 0x7a, 0xaa, 0xaa, 0xa5, 0x5b, - 0xc, 0x0, 0x8, 0x2d, 0x9d, 0x2, 0xa7, 0x14, 0xab, 0x9d, 0x74, 0x0, 0x3, 0x2f, 0x6a, 0x2d}; + uint8_t pkt[] = { + 0x10, 0xdb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x44, 0x19, 0xca, 0xbd, 0x1, 0x2, 0x0, 0x0, 0xc, + 0x25, 0xb, 0xb, 0x28, 0x45, 0x28, 0x56, 0x3, 0x0, 0x17, 0xfe, 0x42, 0x8c, 0xa6, 0x4d, 0x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x1a, 0x0, 0x7, 0x97, 0xc3, 0xa8, 0xbc, 0x3f, 0xa5, 0x7d, 0x3, 0x0, 0xa, + 0xb6, 0x98, 0x21, 0xe, 0xd6, 0xf5, 0xca, 0xd2, 0x1c, 0x26, 0x2, 0x0, 0x0, 0x37, 0x5c, 0x0, 0x14, 0x81, 0x33, + 0xa4, 0xf, 0x5f, 0x8d, 0x62, 0x73, 0xab, 0xf7, 0xa3, 0x76, 0x9f, 0xb5, 0x96, 0x54, 0xb4, 0x88, 0x41, 0x7a, 0x0, + 0x11, 0x20, 0x2f, 0xbd, 0x8d, 0x44, 0xb3, 0x8b, 0x8c, 0xdf, 0xd3, 0x3a, 0x41, 0xdb, 0xcd, 0x46, 0x75, 0x11, 0x0, + 0x2, 0xbc, 0x81}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x19, 0x49, 0xce, 0x47, 0x2e, 0xd, 0xb7, 0x76}; - uint8_t bytesprops0[] = {0x51, 0xf9, 0xa3, 0xf9, 0x2d, 0xc5, 0xc5, 0x72, 0x5, 0xef, 0x1f, 0x65, 0xd6, 0x91}; - uint8_t bytesprops3[] = {0xf9}; - uint8_t bytesprops2[] = {0x76, 0xae, 0x85, 0x5b, 0xac, 0x36, 0x5, 0x97, 0xc8, 0xf2, 0x8a, 0xa7, 0xd5, 0x27}; + uint8_t bytesprops0[] = {0xfe, 0x42, 0x8c, 0xa6, 0x4d, 0xf9, 0x46, 0xb4, 0x8, 0x11, 0xa8, 0xc, + 0xea, 0x4c, 0xa0, 0x7d, 0x52, 0x39, 0xeb, 0x9c, 0x46, 0x72, 0x96}; + uint8_t bytesprops1[] = {0x11, 0x17, 0xfb, 0xee, 0xf2, 0xde, 0xba, 0x66, 0xd1, 0x2, 0xc5, + 0x1f, 0xef, 0x3a, 0x50, 0x5b, 0x57, 0xde, 0x39, 0xee, 0x2d}; + uint8_t bytesprops3[] = {0xf4, 0xcc, 0x7b, 0xd3, 0x98, 0xde, 0xc6, 0x59, 0xe7, 0x4d, 0x35, 0x4e, 0x54, 0xf4, 0xcb, + 0x8, 0x39, 0x81, 0x18, 0xfe, 0x1e, 0x53, 0x9, 0xf2, 0xde, 0x8c, 0xa0, 0x4f, 0x94, 0xdf}; + uint8_t bytesprops2[] = {0x6b, 0xe0, 0x60, 0x63, 0xb6, 0x61, 0xa6, 0xe8, 0x32, 0xb3, 0xd1, 0x96, 0x91, 0xdc, 0x10, + 0x7e, 0xd5, 0x6b, 0xf, 0xb1, 0x8a, 0x4e, 0x9d, 0x6d, 0xd3, 0x71, 0xf7, 0xb6, 0xb2, 0x4f}; + uint8_t bytesprops4[] = {0xad, 0xb4, 0x89}; + uint8_t bytesprops5[] = {0x2c, 0xa1, 0x90}; + uint8_t bytesprops6[] = {0xd0, 0x6e, 0x58, 0x7e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28038}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14184}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 17}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25123}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 11}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24025}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10284}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30193}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19307}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops2}, .v = {1, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3109}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10259}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18041}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29565}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2224}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17653}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32460}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops2}, .v = {30, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1807}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28847}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x1d, 0xc2, 0x3e, 0x67, 0xd8, 0x79, 0x4b, 0x6c, 0x3a, 0xd2, + 0x40, 0xc, 0x21, 0x1b, 0x2e, 0xc9, 0x82, 0x46, 0x7, 0xc6, + 0x89, 0x3f, 0x3f, 0x7b, 0x4, 0x39, 0xc8, 0xeb, 0x1b, 0xd3}; + uint8_t byteswillprops0[] = {0xd2, 0x3e, 0xdc, 0x97, 0x6e, 0x2, 0x57, 0x2b, 0x8c, 0x84, + 0x6c, 0xdd, 0x50, 0x89, 0xbf, 0x48, 0x6e, 0xad, 0xf3, 0xd1, + 0xb4, 0xab, 0xd0, 0x80, 0x18, 0x3f, 0x49, 0x69, 0x1c, 0x23}; + uint8_t byteswillprops3[] = {0xc3, 0x5f, 0xcb, 0xb3, 0x2d, 0xf1, 0xcf, 0x89, 0x32, 0x37, 0x87}; + uint8_t byteswillprops2[] = {0x7, 0xf5, 0x90, 0x25, 0x3f, 0x21, 0xff, 0xce, 0xc7, 0xe3, 0x67}; + uint8_t byteswillprops5[] = {0xd4, 0xce, 0x76, 0xf3, 0x30, 0xeb, 0x67, 0xc8, 0xfa, 0xbc, 0xcf, 0x50, 0x17, + 0x82, 0xa7, 0x89, 0x40, 0x28, 0xbf, 0x5f, 0x8b, 0x13, 0x7d, 0xee, 0xe3}; + uint8_t byteswillprops4[] = {0xd8, 0xe4, 0xa4, 0xd0, 0xde, 0xea, 0x6d, 0x34, 0xc8, 0x9c, + 0x5c, 0x1a, 0xb0, 0xfc, 0xa7, 0x3e, 0xe3, 0xd9, 0x1, 0xfc, + 0x66, 0xb9, 0xba, 0x2f, 0xf5, 0xdc, 0x6c, 0x2e, 0x3d, 0xe9}; + uint8_t byteswillprops6[] = {0x97, 0xc3, 0xa8, 0xbc, 0x3f, 0xa5, 0x7d}; + uint8_t byteswillprops7[] = {0xb6, 0x98, 0x21, 0xe, 0xd6, 0xf5, 0xca, 0xd2, 0x1c, 0x26}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {30, (char*)&byteswillprops0}, .v = {30, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4108}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1362}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20063}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {11, (char*)&byteswillprops2}, .v = {11, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2669}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {30, (char*)&byteswillprops4}, .v = {25, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13533}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14172}}, + }; + + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x81, 0x33, 0xa4, 0xf, 0x5f, 0x8d, 0x62, 0x73, 0xab, 0xf7, + 0xa3, 0x76, 0x9f, 0xb5, 0x96, 0x54, 0xb4, 0x88, 0x41, 0x7a}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x20, 0x2f, 0xbd, 0x8d, 0x44, 0xb3, 0x8b, 0x8c, 0xdf, + 0xd3, 0x3a, 0x41, 0xdb, 0xcd, 0x46, 0x75, 0x11}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 2165; - uint8_t client_id_bytes[] = {0x3b, 0x6c, 0xc0, 0x11, 0x4e, 0x9c, 0x7a, 0xaa, 0xaa, 0xa5, 0x5b, 0xc}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.keep_alive = 6602; + uint8_t client_id_bytes[] = {0x25, 0xc5, 0x75, 0xf2, 0x7c, 0x51, 0x4d, 0x2f, 0x0, 0xef, + 0x90, 0x7, 0xb0, 0xad, 0x8a, 0xf8, 0x8f, 0x30, 0x3e, 0x38}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2d, 0x9d, 0x2, 0xa7, 0x14, 0xab, 0x9d, 0x74}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x2f, 0x6a, 0x2d}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xbc, 0x81}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "^a,Y\US\230/\202\240\t\229\218\191\SUBdl", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\170", _willMsg = -// "@d\157b\SYN\150\&0\164\ENQ\236O\149e\129\218\210wSKU\DC4y\SOH\188\163m\EOT", _willProps = [PropReasonString -// "v\n\168/t\169",PropSubscriptionIdentifier 4,PropMessageExpiryInterval 21322,PropTopicAliasMaximum -// 9552,PropTopicAliasMaximum 24731,PropReceiveMaximum 29502,PropCorrelationData -// "n\196z\172-\214\141\173\168$Mx\DC4\184\&8",PropContentType -// "R\201aH\166*B\186\163/\145\235\174\US>S\DC4-\191\137\209\&7^\212y\DC1To\CAN",PropMessageExpiryInterval -// 3252,PropAuthenticationData "\EM\248",PropServerReference "",PropWillDelayInterval 21121,PropContentType -// "\193\193\234_\223G@\232^\136\218\233Y1'\DC4\204t\250",PropUserProperty "\168" -// "v\238\176\NAK\f\ETB7\ESCUU\222y?\163\159\175\189\159\v\186!-;fZ\152\NUL\US\245\138\130\241\EM\178\209:\207-"]} TEST(Connect5QCTest, Encode21) { uint8_t pkt[] = { - 0x10, 0xa2, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x2e, 0x8c, 0x47, 0x28, 0xcc, 0x11, 0x0, 0x0, - 0x13, 0x93, 0x18, 0x0, 0x0, 0x58, 0x1b, 0x1a, 0x0, 0x16, 0xcc, 0xdd, 0x3, 0xe3, 0xc7, 0x89, 0x8c, 0x45, 0xee, - 0xe5, 0x8, 0xc8, 0x49, 0x19, 0xb7, 0x5e, 0x14, 0x3d, 0xb3, 0xb0, 0x4d, 0x2e, 0x22, 0x45, 0x7a, 0x21, 0x71, 0xf2, - 0x16, 0x0, 0x6, 0xbe, 0x7a, 0x43, 0xe7, 0x99, 0xfe, 0x27, 0x0, 0x0, 0x43, 0x1c, 0x28, 0x3b, 0x25, 0x4e, 0x1a, - 0x0, 0x5, 0xb, 0xfb, 0x61, 0x9b, 0xed, 0x17, 0x9b, 0x0, 0xb, 0x7a, 0xd1, 0x2f, 0x7f, 0xd5, 0x42, 0xe5, 0x1e, - 0xf0, 0x42, 0xee, 0xe6, 0x1, 0x22, 0x5e, 0x4a, 0x17, 0xce, 0x12, 0x0, 0x14, 0x86, 0x45, 0x5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0x4f, 0x66, 0xac, 0x38, 0xf5, 0xb5, 0x55, 0xe3, 0xaf, 0x19, 0x9a, 0xb, 0x22, 0x29, 0x3d, 0x25, + 0x85, 0x11, 0x0, 0x0, 0x36, 0xb4, 0x19, 0x94, 0x13, 0x38, 0xb5, 0x12, 0x0, 0xa, 0x5e, 0xc2, 0x8d, 0x50, 0x9, + 0x8a, 0x4f, 0xc1, 0x33, 0xdd, 0x26, 0x0, 0x1c, 0x78, 0x8b, 0x8, 0xae, 0x2a, 0xae, 0x51, 0xe7, 0x1e, 0x65, 0xb, + 0xd9, 0xcb, 0x81, 0x75, 0x70, 0x80, 0x9a, 0x58, 0x33, 0x7f, 0xb6, 0x2d, 0x6, 0xbb, 0xdd, 0xef, 0x91, 0x0, 0x6, + 0xf2, 0xbe, 0x93, 0x74, 0x9c, 0x18, 0x1, 0x63, 0x27, 0x0, 0x0, 0x41, 0x45, 0x28, 0xd2, 0x0, 0x7, 0x11, 0xe, + 0xda, 0x6b, 0x39, 0xc2, 0xfb, 0x0, 0x9, 0xdc, 0xf7, 0xbf, 0xcd, 0x8d, 0xc3, 0x80, 0xff, 0x77, 0x0, 0x17, 0xcd, + 0x6c, 0x42, 0xcb, 0xe7, 0xbd, 0x7d, 0x88, 0xb3, 0x9b, 0x11, 0x73, 0x97, 0x4c, 0x31, 0xbf, 0x1f, 0x7a, 0xa3, 0x56, + 0x96, 0x8b, 0x6e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xcc, 0xdd, 0x3, 0xe3, 0xc7, 0x89, 0x8c, 0x45, 0xee, 0xe5, 0x8, - 0xc8, 0x49, 0x19, 0xb7, 0x5e, 0x14, 0x3d, 0xb3, 0xb0, 0x4d, 0x2e}; - uint8_t bytesprops1[] = {0xbe, 0x7a, 0x43, 0xe7, 0x99, 0xfe}; - uint8_t bytesprops2[] = {0xb, 0xfb, 0x61, 0x9b, 0xed}; + uint8_t bytesprops0[] = {0x5c, 0xaa, 0x93, 0xa6, 0x77, 0x61, 0x51, 0x91, 0x7d, 0x91, 0xe3, 0x4d, 0x85, 0x33, 0xd0, + 0x87, 0xc9, 0xb4, 0x55, 0xf1, 0x6c, 0x72, 0xca, 0x52, 0x8, 0xf5, 0x4b, 0x5b, 0xdd, 0x98}; + uint8_t bytesprops2[] = {0x29, 0x7, 0xef, 0x3e, 0x5a, 0x98, 0x0, 0x1f, 0xf5, + 0x8a, 0x82, 0xf1, 0x19, 0xb2, 0xd1, 0x3a, 0xcf, 0x2d}; + uint8_t bytesprops1[] = {0x5d, 0x50, 0x11, 0x51, 0x5f, 0x42, 0x45, 0x92, 0x61, 0x8d, + 0xa0, 0x61, 0x2e, 0x33, 0x6b, 0x13, 0xee, 0x14, 0x4b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5011}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22555}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17786}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29170}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17180}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4176}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 686}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x86, 0x45, 0x5, 0xe6, 0x82, 0x72, 0x8f, 0xb3, 0x51, 0xd6, - 0xf3, 0x1f, 0x39, 0xeb, 0xfa, 0x65, 0xf, 0x3a, 0x36, 0x99}; - uint8_t byteswillprops1[] = {0x2c, 0x3f, 0x61, 0x98, 0x1f, 0x8d, 0x23, 0xfd, 0x5b, 0x62, 0xf2, 0xb0}; - uint8_t byteswillprops2[] = {0x81, 0xfa, 0x40}; - uint8_t byteswillprops3[] = {0x26}; - uint8_t byteswillprops4[] = {0x5e, 0xc0, 0x3c, 0xfa, 0x16, 0x24, 0x9b, 0x1, 0x76, 0xc1, - 0x89, 0xc5, 0xf3, 0xd6, 0x86, 0xaa, 0xe5, 0x56, 0x1d, 0x9b, - 0x53, 0x5, 0x40, 0xcc, 0x3a, 0x40, 0x39, 0xea, 0x46, 0xe4}; - uint8_t byteswillprops5[] = {0x95, 0x23, 0x85, 0x80, 0x38, 0xf4, 0x2f, 0x5, 0x77, 0x1b, 0x12}; - uint8_t byteswillprops6[] = {0xd1, 0x5c, 0xa6, 0x2e, 0xee, 0xbb, 0x7a, 0xb4, 0xaa, 0xb2}; - uint8_t byteswillprops7[] = {0xb2, 0x2, 0x92, 0xec, 0x8d, 0xd2, 0x3c, 0xeb, 0xab, 0xf9, 0x17, 0x13, 0xaa, - 0x3, 0x95, 0xff, 0xd5, 0x26, 0x10, 0x40, 0x36, 0xb1, 0xa6, 0xad, 0xa3, 0xae}; - uint8_t byteswillprops8[] = {0x8, 0xa5, 0x37, 0x87, 0x51, 0x8a, 0xe7, 0x11, 0x5c, 0x2f, 0x3c, 0xb1, 0x6f, 0x1d, 0x82}; - uint8_t byteswillprops9[] = {0xb2, 0x7a, 0x17, 0x9d, 0x34, 0xa5}; + uint8_t byteswillprops0[] = {0xbc, 0x29, 0xdd, 0xd6, 0xc5, 0x5c, 0x64, 0x25, 0x2b, 0x36, 0x6a, + 0x82, 0x56, 0x32, 0xfa, 0xbd, 0x9f, 0x90, 0xc1, 0x83, 0xe3, 0xd8}; + uint8_t byteswillprops1[] = {0xac, 0xac, 0x89, 0x66, 0xe0, 0x51, 0x5, 0x4e, 0xee, 0x6e}; + uint8_t byteswillprops2[] = {0x38, 0x33, 0x6e, 0x40, 0xe4, 0xb0, 0xd, 0x88, 0x43, 0xa9, 0x4c, 0xc0, 0x6e, 0xce, + 0xbe, 0x7f, 0x1a, 0xe8, 0x1a, 0x8f, 0xb2, 0x31, 0x49, 0xdd, 0x34, 0xd2, 0xcb}; + uint8_t byteswillprops3[] = {0x3b, 0x38, 0xcb, 0x49, 0x3c, 0x4c, 0xcd, 0xf2, 0xeb, 0xa, 0x69, 0x69, + 0xec, 0xa7, 0x18, 0xe9, 0x41, 0x7d, 0xd8, 0xe2, 0xe, 0x8f, 0x2f, 0x89}; + uint8_t byteswillprops4[] = {0x4f, 0x66, 0xac, 0x38, 0xf5, 0xb5, 0x55, 0xe3, 0xaf}; + uint8_t byteswillprops5[] = {0x5e, 0xc2, 0x8d, 0x50, 0x9, 0x8a, 0x4f, 0xc1, 0x33, 0xdd}; + uint8_t byteswillprops7[] = {0xf2, 0xbe, 0x93, 0x74, 0x9c, 0x18}; + uint8_t byteswillprops6[] = {0x78, 0x8b, 0x8, 0xae, 0x2a, 0xae, 0x51, 0xe7, 0x1e, 0x65, 0xb, 0xd9, 0xcb, 0x81, + 0x75, 0x70, 0x80, 0x9a, 0x58, 0x33, 0x7f, 0xb6, 0x2d, 0x6, 0xbb, 0xdd, 0xef, 0x91}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24138}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18146}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9339}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19391}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15014}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14314}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1849}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23464}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11103}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29514}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25814}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25484}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20845}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10989}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11016}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6006}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 34}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14004}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14517}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {28, (char*)&byteswillprops6}, .v = {6, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16709}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, }; - lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8b, 0x98, 0xc1, 0x12, 0xab, 0xb3, 0xe0, 0x6d, 0xa8, 0x4a, 0x81, 0xed, - 0x99, 0x74, 0x1, 0x5, 0xf4, 0x47, 0xcb, 0x4, 0x1f, 0x7d, 0xdd, 0xa2}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x10, 0x87, 0x15, 0x5e, 0xc1, 0x76, 0x61, 0x14, 0xfc, 0x8d, 0x2d, 0x1e}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x11, 0xe, 0xda, 0x6b, 0x39, 0xc2, 0xfb}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xdc, 0xf7, 0xbf, 0xcd, 0x8d, 0xc3, 0x80, 0xff, 0x77}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 11916; - uint8_t client_id_bytes[] = {0x7a, 0xd1, 0x2f, 0x7f, 0xd5, 0x42, 0xe5, 0x1e, 0xf0, 0x42, 0xee}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 11497; + uint8_t client_id_bytes[] = {0x7a, 0x56, 0xac, 0x14, 0xb1, 0xf, 0xd6, 0x28, 0xaa, 0xb, 0x90, 0xe8, 0x7d}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xda, 0x36, 0x25, 0x2, 0x28, 0x35, 0x69, 0x30, 0xbd, 0x61, 0x96, 0x5, - 0xe5, 0x59, 0x48, 0x2c, 0x30, 0x26, 0x5e, 0xa7, 0xc, 0xfe, 0xd1, 0x6b}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xcd, 0x6c, 0x42, 0xcb, 0xe7, 0xbd, 0x7d, 0x88, 0xb3, 0x9b, 0x11, 0x73, + 0x97, 0x4c, 0x31, 0xbf, 0x1f, 0x7a, 0xa3, 0x56, 0x96, 0x8b, 0x6e}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xca, 0x29, 0xa1, 0xca, 0xcd, 0xaa, 0x7a, 0xf, 0xe6, 0xf1, 0xaf, 0x8e, - 0xd0, 0xd5, 0xf5, 0x8e, 0x5d, 0x64, 0x4d, 0x19, 0xe7, 0x9b, 0xf4}; - lwmqtt_string_t password = {23, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9080,263 +9082,234 @@ TEST(Connect5QCTest, Encode21) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "\143y\166C\221w?;4\243\179\248z\136\a\221\DC3\228\DC1\156,\131\183sM\171&y", _lastWill = Just (LastWill {_willRetain -// = False, _willQoS = QoS2, _willTopic = "\226", _willMsg = "\240\178+p\166\192", _willProps = -// [PropAuthenticationMethod "\SUB\161\133Q7\DEL\226G\183\168\163\195\134\201\239iO",PropTopicAliasMaximum -// 27269,PropSubscriptionIdentifier 12,PropReasonString "\157",PropAssignedClientIdentifier -// "\242nkL\v\SI=G\170\238\222\&3\tf\233\221C(\151j",PropMessageExpiryInterval 31488,PropMaximumQoS -// 47,PropSessionExpiryInterval 15063,PropSubscriptionIdentifier 27,PropRequestResponseInformation -// 156,PropRequestResponseInformation 43,PropAssignedClientIdentifier "\147\241\222E\179\&25",PropReceiveMaximum -// 72,PropReceiveMaximum 30761,PropTopicAliasMaximum 24233,PropCorrelationData -// "\146\216y\197\134\196\173\211{\aUgEE\214\EM\147\182\229",PropSharedSubscriptionAvailable 207,PropServerReference -// "?\171\170\169\249\215\229W\157\&9\SOH\237\186|",PropSubscriptionIdentifierAvailable -// 42,PropSubscriptionIdentifierAvailable 28,PropMessageExpiryInterval 11243,PropRetainAvailable 136,PropUserProperty -// "\192\178\209\202\233\216\206r\220\229a\171@\176W\236 IR\250B\214#\233!i\142x\rj",PropMaximumQoS +// 71,PropRetainAvailable 248,PropUserProperty "\229\213V\146U7\aP\132\135\175\166!-\203B\129\248\172\220\169" +// "a\219@\171\149\250\146Uc\166ZR",PropSessionExpiryInterval 6662,PropTopicAlias 27570,PropSubscriptionIdentifier +// 23,PropReceiveMaximum 7608]} TEST(Connect5QCTest, Encode22) { uint8_t pkt[] = { - 0x10, 0xb8, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x54, 0x74, 0xf, 0xb7, 0x1, 0x22, 0x4e, 0x82, 0x11, - 0x0, 0x0, 0x17, 0xb7, 0x26, 0x0, 0x10, 0xd1, 0x49, 0x30, 0xc, 0xcc, 0x8f, 0xde, 0xc7, 0xc2, 0x91, 0xeb, 0xa7, - 0xaa, 0xce, 0xa4, 0xb8, 0x0, 0x1e, 0x92, 0x2f, 0x63, 0x4a, 0x10, 0x3, 0xa2, 0x82, 0xe8, 0x3, 0x81, 0xa8, 0xef, - 0xf3, 0xc0, 0x55, 0x30, 0x79, 0xab, 0x79, 0xf4, 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0x0, 0x13, 0xd7, 0x5d, 0x19, + 0x89, 0xc9, 0xa7, 0x94, 0x97, 0xe0, 0x7a, 0x5e, 0x68, 0xe7, 0xb4, 0xd5, 0x55, 0x6b, 0x2b, 0x93}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x92, 0x2f, 0x63, 0x4a, 0x10, 0x3, 0xa2, 0x82, 0xe8, 0x3, 0x81, 0xa8, 0xef, 0xf3, 0xc0, - 0x55, 0x30, 0x79, 0xab, 0x79, 0xf4, 0x1e, 0x3d, 0xc3, 0x5b, 0x54, 0xe2, 0xb3, 0xc3, 0xd7}; - uint8_t bytesprops0[] = {0xd1, 0x49, 0x30, 0xc, 0xcc, 0x8f, 0xde, 0xc7, - 0xc2, 0x91, 0xeb, 0xa7, 0xaa, 0xce, 0xa4, 0xb8}; - uint8_t bytesprops2[] = {0x38, 0xd2, 0x29, 0x78, 0xfe, 0x73, 0x93, 0x30, 0x32, 0x8e}; - uint8_t bytesprops3[] = {0xb9, 0xa0, 0x10, 0x52, 0x4a, 0xf2}; - uint8_t bytesprops4[] = {0x54, 0x45, 0xda, 0xcc, 0xbf, 0xfe, 0x19, 0x6e, 0xf3, - 0x6f, 0x3b, 0xc7, 0x34, 0xd, 0x57, 0x79, 0x76, 0xed}; - uint8_t bytesprops5[] = {0xca, 0x6f, 0x5}; - uint8_t bytesprops6[] = {0xae}; - uint8_t bytesprops7[] = {0x85, 0xd2, 0x86, 0xc1, 0x7d, 0x3d, 0xf0, 0x61, 0xd4, 0x82}; - uint8_t bytesprops8[] = {0x7, 0xc7, 0xbe, 0x8a, 0xda}; - uint8_t bytesprops9[] = {0xe7, 0x4, 0x82, 0xa}; + uint8_t bytesprops0[] = {0x6f, 0x24, 0x5f, 0xf0, 0xb2, 0x2f, 0x7, 0x82, 0xe6, 0x7b, 0x26, 0x14}; + uint8_t bytesprops1[] = {0x30, 0xc8, 0x40, 0xad, 0x5, 0x59, 0xd7, 0xb8, 0x5d, 0x2c, 0xe8, 0xae, + 0x15, 0x4e, 0xc0, 0x19, 0x13, 0xc1, 0xa1, 0x68, 0x29, 0x90, 0x76}; + uint8_t bytesprops2[] = {0x3e, 0xce, 0x72, 0xdc, 0xe5, 0x61, 0xab, 0x40, 0xb0, 0x57, 0xec, 0x20, 0x49, + 0x52, 0xfa, 0x42, 0xd6, 0x23, 0xe9, 0x21, 0x69, 0x8e, 0x78, 0xd, 0x6a}; + uint8_t bytesprops4[] = {0x61, 0xdb, 0x40, 0xab, 0x95, 0xfa, 0x92, 0x55, 0x63, 0xa6, 0x5a, 0x52}; + uint8_t bytesprops3[] = {0xe5, 0xd5, 0x56, 0x92, 0x55, 0x37, 0x7, 0x50, 0x84, 0x87, 0xaf, + 0xa6, 0x21, 0x2d, 0xcb, 0x42, 0x81, 0xf8, 0xac, 0xdc, 0xa9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20098}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6071}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops0}, .v = {30, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10741}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20383}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6080}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24233}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27712}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26854}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 851}}, - }; - - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x1a, 0xa1, 0x85, 0x51, 0x37, 0x7f, 0xe2, 0x47, 0xb7, - 0xa8, 0xa3, 0xc3, 0x86, 0xc9, 0xef, 0x69, 0x4f}; - uint8_t byteswillprops1[] = {0x9d}; - uint8_t byteswillprops2[] = {0xf2, 0x6e, 0x6b, 0x4c, 0xb, 0xf, 0x3d, 0x47, 0xaa, 0xee, - 0xde, 0x33, 0x9, 0x66, 0xe9, 0xdd, 0x43, 0x28, 0x97, 0x6a}; - uint8_t byteswillprops3[] = {0x93, 0xf1, 0xde, 0x45, 0xb3, 0x32, 0x35}; - uint8_t byteswillprops4[] = {0x92, 0xd8, 0x79, 0xc5, 0x86, 0xc4, 0xad, 0xd3, 0x7b, 0x7, - 0x55, 0x67, 0x45, 0x45, 0xd6, 0x19, 0x93, 0xb6, 0xe5}; - uint8_t byteswillprops5[] = {0x3f, 0xab, 0xaa, 0xa9, 0xf9, 0xd7, 0xe5, 0x57, 0x9d, 0x39, 0x1, 0xed, 0xba, 0x7c}; - uint8_t byteswillprops7[] = {0x5b, 0x35, 0xcf, 0xe8, 0xc8, 0x9c, 0x6d, 0x67, 0xea, 0x84, 0x96, 0x2e, 0xb6, 0xd4, 0xf2, - 0x4e, 0xac, 0x6a, 0x9, 0xa7, 0x38, 0x70, 0x5e, 0x9c, 0xbf, 0x64, 0xe2, 0xd, 0x15}; - uint8_t byteswillprops6[] = {0xc0, 0xb2, 0xd1, 0xca, 0xe9, 0xd8, 0x3c, 0x4b, 0x8b, 0x3, 0x38, 0x0, 0x25, 0xad}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27269}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31488}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15063}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 72}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30761}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24233}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11243}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {14, (char*)&byteswillprops6}, .v = {29, (char*)&byteswillprops7}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15404}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17865}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20005}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12331}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops3}, .v = {12, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6662}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27570}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7608}}, }; - lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe2}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf0, 0xb2, 0x2b, 0x70, 0xa6, 0xc0}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 29711; - uint8_t client_id_bytes[] = {0x78, 0x32, 0xc8, 0x6f, 0x84, 0xfa}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.keep_alive = 19360; + uint8_t client_id_bytes[] = {0x9c, 0xf2, 0x44, 0x39, 0xb6, 0x85, 0x65, 0x11, 0xe7, 0xb1, 0x14}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x8f, 0x79, 0xa6, 0x43, 0xdd, 0x77, 0x3f, 0x3b, 0x34, 0xf3, 0xb3, 0xf8, 0x7a, 0x88, - 0x7, 0xdd, 0x13, 0xe4, 0x11, 0x9c, 0x2c, 0x83, 0xb7, 0x73, 0x4d, 0xab, 0x26, 0x79}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xfb, 0x5a, 0xf0, 0xc2, 0x4b, 0xe8, 0xef, 0x8d, 0x41, 0x5a}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xd7, 0x5d, 0x19, 0x89, 0xc9, 0xa7, 0x94, 0x97, 0xe0, 0x7a, + 0x5e, 0x68, 0xe7, 0xb4, 0xd5, 0x55, 0x6b, 0x2b, 0x93}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\157\244\252!\no\225e", _password = Just -// "\203+\193\206\143\177\CAN\NUL\b\229\143p\249\aoT\130\140\199\197\139\130", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "\188$&\229\204\146\186\244p\ACK\165dC\198G", _willMsg = -// ",n\136+E\195\136_K\222\148\132s\141{\231", _willProps = [PropCorrelationData -// "\EMI\134\SOc\159\SOH\243",PropSubscriptionIdentifier 15,PropReceiveMaximum 8553,PropAuthenticationData -// "\132]u\203\130\166\187\168t\240H\130|\r;3\222\159\129\231\215\181",PropResponseTopic -// "\253|\179&\159\255c",PropWillDelayInterval 17083,PropTopicAlias 3764,PropWildcardSubscriptionAvailable -// 106,PropMessageExpiryInterval 18550,PropResponseTopic -// "Md/\138TS<\159\233`\225f\202\197\DC1\SYNL\223\tbL\253\141f'^_*",PropServerKeepAlive 11002,PropResponseTopic -// "\207\218\236e\180*\NUL\241\169qc[a\f;\187&\131",PropPayloadFormatIndicator 209,PropPayloadFormatIndicator 65]}), -// _cleanSession = True, _keepAlive = 25534, _connID = "t\177\139,\191\139t\244\NAK\f\140!G\131k\141", _properties = -// [PropContentType "\253,\225\224\254?\255\224\211\SYNp\130\196\&3R",PropMessageExpiryInterval 18219]} +// ConnectRequest {_username = Just "X&4$#\150ffc\147", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS0, _willTopic = "\136x", _willMsg = "\170\173F9\211(\209\223@%\STX\NUL\175\144\213\136\224b", +// _willProps = [PropMessageExpiryInterval 9625,PropAuthenticationMethod "\187{!O\206- +// \183Q^W~3\245a\193\169\USR\ENQ\254\226\183\DC2\129\253\235\FSi.",PropSubscriptionIdentifierAvailable +// 104,PropResponseInformation " \179\176\139k959)\215\231Q\132p\211",PropServerReference "",PropTopicAliasMaximum +// 31363,PropSharedSubscriptionAvailable 49,PropResponseTopic "\173",PropMessageExpiryInterval +// 24639,PropPayloadFormatIndicator 162,PropContentType "\229\206}\210J\199a~_\190|\197!",PropReasonString +// "\131\137\201\203`\244&d\"\210u\185",PropTopicAlias 22635,PropSharedSubscriptionAvailable 41]}), _cleanSession = +// False, _keepAlive = 19263, _connID = "\148\139\192+\177o\182\205", _properties = [PropCorrelationData +// "\SYN\191\149\219v\247\v\192\228\227\187\&1\196&n\167!4R\SO\154(}2R6\230\138",PropReceiveMaximum +// 1086,PropResponseInformation "\236\162\DC1\rR\173\135\183\191\242/UN`d\207\219\198\157",PropResponseInformation +// "\151",PropMaximumPacketSize 32268,PropReceiveMaximum 2995,PropAssignedClientIdentifier +// "\203H\184\174",PropTopicAlias 23241,PropReasonString +// "\147\GS\DC11N\b\153\247\242bu7\DEL~\SOH\207}\247\a\174\195\183",PropWildcardSubscriptionAvailable +// 110,PropUserProperty "n\200\183\168\238N\r\139\230\182[\v" "e\204\GSfH)\183\180\176\225",PropResponseInformation +// "y<\195",PropPayloadFormatIndicator 144,PropResponseTopic "",PropServerKeepAlive 4691,PropAuthenticationMethod +// "kX\142&\218>\188\254n\226\145\167\213",PropCorrelationData +// "\254{\202\142\199\US\216I%\202W\218\245\DC2Kt\192\189",PropServerKeepAlive 21417,PropAuthenticationMethod +// "a\b\185\183:\193\206",PropResponseTopic "{\207\162\US\234\STXT\147\143S\t",PropContentType +// "\199\\J\v",PropMessageExpiryInterval 14422,PropRetainAvailable 4,PropAuthenticationMethod +// "&*\128\160\236\137\134\190b\167\191/\210m\167\162?h\254\"\234aO\STX.\181x\146\ACK<",PropCorrelationData +// "\DC2\225\253\&5\FSh2\205j+\200W\NUL\228\219\DLE]T\192\149\DC3\142eI",PropServerKeepAlive 6578]} TEST(Connect5QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0xf7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x63, 0xbe, 0x17, 0x3, 0x0, 0xf, - 0xfd, 0x2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xce, 0x2d, 0x20, 0xb7, 0x51, 0x5e, 0x57, 0x7e, 0x33, 0xf5, 0x61, 0xc1, 0xa9, 0x1f, 0x52, 0x5, 0xfe, + 0xe2, 0xb7, 0x12, 0x81, 0xfd, 0xeb, 0x1c, 0x69, 0x2e, 0x29, 0x68, 0x1a, 0x0, 0xf, 0x20, 0xb3, 0xb0, 0x8b, 0x6b, + 0x39, 0x35, 0x39, 0x29, 0xd7, 0xe7, 0x51, 0x84, 0x70, 0xd3, 0x1c, 0x0, 0x0, 0x22, 0x7a, 0x83, 0x2a, 0x31, 0x8, + 0x0, 0x1, 0xad, 0x2, 0x0, 0x0, 0x60, 0x3f, 0x1, 0xa2, 0x3, 0x0, 0xd, 0xe5, 0xce, 0x7d, 0xd2, 0x4a, 0xc7, + 0x61, 0x7e, 0x5f, 0xbe, 0x7c, 0xc5, 0x21, 0x1f, 0x0, 0xc, 0x83, 0x89, 0xc9, 0xcb, 0x60, 0xf4, 0x26, 0x64, 0x22, + 0xd2, 0x75, 0xb9, 0x23, 0x58, 0x6b, 0x2a, 0x29, 0x0, 0x2, 0x88, 0x78, 0x0, 0x12, 0xaa, 0xad, 0x46, 0x39, 0xd3, + 0x28, 0xd1, 0xdf, 0x40, 0x25, 0x2, 0x0, 0xaf, 0x90, 0xd5, 0x88, 0xe0, 0x62, 0x0, 0xa, 0x58, 0x26, 0x34, 0x24, + 0x23, 0x96, 0x66, 0x66, 0x63, 0x93}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xfd, 0x2c, 0xe1, 0xe0, 0xfe, 0x3f, 0xff, 0xe0, 0xd3, 0x16, 0x70, 0x82, 0xc4, 0x33, 0x52}; + uint8_t bytesprops0[] = {0x16, 0xbf, 0x95, 0xdb, 0x76, 0xf7, 0xb, 0xc0, 0xe4, 0xe3, 0xbb, 0x31, 0xc4, 0x26, + 0x6e, 0xa7, 0x21, 0x34, 0x52, 0xe, 0x9a, 0x28, 0x7d, 0x32, 0x52, 0x36, 0xe6, 0x8a}; + uint8_t bytesprops1[] = {0xec, 0xa2, 0x11, 0xd, 0x52, 0xad, 0x87, 0xb7, 0xbf, 0xf2, + 0x2f, 0x55, 0x4e, 0x60, 0x64, 0xcf, 0xdb, 0xc6, 0x9d}; + uint8_t bytesprops2[] = {0x97}; + uint8_t bytesprops3[] = {0xcb, 0x48, 0xb8, 0xae}; + uint8_t bytesprops4[] = {0x93, 0x1d, 0x11, 0x31, 0x4e, 0x8, 0x99, 0xf7, 0xf2, 0x62, 0x75, + 0x37, 0x7f, 0x7e, 0x1, 0xcf, 0x7d, 0xf7, 0x7, 0xae, 0xc3, 0xb7}; + uint8_t bytesprops6[] = {0x65, 0xcc, 0x1d, 0x66, 0x48, 0x29, 0xb7, 0xb4, 0xb0, 0xe1}; + uint8_t bytesprops5[] = {0x6e, 0xc8, 0xb7, 0xa8, 0xee, 0x4e, 0xd, 0x8b, 0xe6, 0xb6, 0x5b, 0xb}; + uint8_t bytesprops7[] = {0x79, 0x3c, 0xc3}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0x6b, 0x58, 0x8e, 0x26, 0xda, 0x3e, 0xbc, 0xfe, 0x6e, 0xe2, 0x91, 0xa7, 0xd5}; + uint8_t bytesprops10[] = {0xfe, 0x7b, 0xca, 0x8e, 0xc7, 0x1f, 0xd8, 0x49, 0x25, + 0xca, 0x57, 0xda, 0xf5, 0x12, 0x4b, 0x74, 0xc0, 0xbd}; + uint8_t bytesprops11[] = {0x61, 0x8, 0xb9, 0xb7, 0x3a, 0xc1, 0xce}; + uint8_t bytesprops12[] = {0x7b, 0xcf, 0xa2, 0x1f, 0xea, 0x2, 0x54, 0x93, 0x8f, 0x53, 0x9}; + uint8_t bytesprops13[] = {0xc7, 0x5c, 0x4a, 0xb}; + uint8_t bytesprops14[] = {0x26, 0x2a, 0x80, 0xa0, 0xec, 0x89, 0x86, 0xbe, 0x62, 0xa7, 0xbf, 0x2f, 0xd2, 0x6d, 0xa7, + 0xa2, 0x3f, 0x68, 0xfe, 0x22, 0xea, 0x61, 0x4f, 0x2, 0x2e, 0xb5, 0x78, 0x92, 0x6, 0x3c}; + uint8_t bytesprops15[] = {0x12, 0xe1, 0xfd, 0x35, 0x1c, 0x68, 0x32, 0xcd, 0x6a, 0x2b, 0xc8, 0x57, + 0x0, 0xe4, 0xdb, 0x10, 0x5d, 0x54, 0xc0, 0x95, 0x13, 0x8e, 0x65, 0x49}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18219}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1086}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32268}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2995}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23241}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops5}, .v = {10, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4691}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21417}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14422}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6578}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x19, 0x49, 0x86, 0xe, 0x63, 0x9f, 0x1, 0xf3}; - uint8_t byteswillprops1[] = {0x84, 0x5d, 0x75, 0xcb, 0x82, 0xa6, 0xbb, 0xa8, 0x74, 0xf0, 0x48, - 0x82, 0x7c, 0xd, 0x3b, 0x33, 0xde, 0x9f, 0x81, 0xe7, 0xd7, 0xb5}; - uint8_t byteswillprops2[] = {0xfd, 0x7c, 0xb3, 0x26, 0x9f, 0xff, 0x63}; - uint8_t byteswillprops3[] = {0x4d, 0x64, 0x2f, 0x8a, 0x54, 0x53, 0x3c, 0x9f, 0xe9, 0x60, 0xe1, 0x66, 0xca, 0xc5, - 0x11, 0x16, 0x4c, 0xdf, 0x9, 0x62, 0x4c, 0xfd, 0x8d, 0x66, 0x27, 0x5e, 0x5f, 0x2a}; - uint8_t byteswillprops4[] = {0xcf, 0xda, 0xec, 0x65, 0xb4, 0x2a, 0x0, 0xf1, 0xa9, - 0x71, 0x63, 0x5b, 0x61, 0xc, 0x3b, 0xbb, 0x26, 0x83}; + uint8_t byteswillprops0[] = {0xbb, 0x7b, 0x21, 0x4f, 0xce, 0x2d, 0x20, 0xb7, 0x51, 0x5e, + 0x57, 0x7e, 0x33, 0xf5, 0x61, 0xc1, 0xa9, 0x1f, 0x52, 0x5, + 0xfe, 0xe2, 0xb7, 0x12, 0x81, 0xfd, 0xeb, 0x1c, 0x69, 0x2e}; + uint8_t byteswillprops1[] = {0x20, 0xb3, 0xb0, 0x8b, 0x6b, 0x39, 0x35, 0x39, + 0x29, 0xd7, 0xe7, 0x51, 0x84, 0x70, 0xd3}; + uint8_t byteswillprops2[] = {0}; + uint8_t byteswillprops3[] = {0xad}; + uint8_t byteswillprops4[] = {0xe5, 0xce, 0x7d, 0xd2, 0x4a, 0xc7, 0x61, 0x7e, 0x5f, 0xbe, 0x7c, 0xc5, 0x21}; + uint8_t byteswillprops5[] = {0x83, 0x89, 0xc9, 0xcb, 0x60, 0xf4, 0x26, 0x64, 0x22, 0xd2, 0x75, 0xb9}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 15}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8553}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17083}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3764}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18550}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11002}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9625}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31363}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24639}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22635}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 41}}, }; lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbc, 0x24, 0x26, 0xe5, 0xcc, 0x92, 0xba, 0xf4, - 0x70, 0x6, 0xa5, 0x64, 0x43, 0xc6, 0x47}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x2c, 0x6e, 0x88, 0x2b, 0x45, 0xc3, 0x88, 0x5f, - 0x4b, 0xde, 0x94, 0x84, 0x73, 0x8d, 0x7b, 0xe7}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x88, 0x78}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xaa, 0xad, 0x46, 0x39, 0xd3, 0x28, 0xd1, 0xdf, 0x40, + 0x25, 0x2, 0x0, 0xaf, 0x90, 0xd5, 0x88, 0xe0, 0x62}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 25534; - uint8_t client_id_bytes[] = {0x74, 0xb1, 0x8b, 0x2c, 0xbf, 0x8b, 0x74, 0xf4, - 0x15, 0xc, 0x8c, 0x21, 0x47, 0x83, 0x6b, 0x8d}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 19263; + uint8_t client_id_bytes[] = {0x94, 0x8b, 0xc0, 0x2b, 0xb1, 0x6f, 0xb6, 0xcd}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x9d, 0xf4, 0xfc, 0x21, 0xa, 0x6f, 0xe1, 0x65}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x58, 0x26, 0x34, 0x24, 0x23, 0x96, 0x66, 0x66, 0x63, 0x93}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xcb, 0x2b, 0xc1, 0xce, 0x8f, 0xb1, 0x18, 0x0, 0x8, 0xe5, 0x8f, - 0x70, 0xf9, 0x7, 0x6f, 0x54, 0x82, 0x8c, 0xc7, 0xc5, 0x8b, 0x82}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9345,166 +9318,192 @@ TEST(Connect5QCTest, Encode23) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\DC2K\SOH\205\130\243\197\138\251g", _password = Just -// "\203\162\176\223n\163\159\204\NAK\t+\212", _lastWill = Nothing, _cleanSession = True, _keepAlive = 31053, _connID = -// "X\134\206\232\134\243\221\DC1\252", _properties = [PropAuthenticationData -// "}\SOH\129\&1\216S",PropSharedSubscriptionAvailable 26,PropWildcardSubscriptionAvailable 135,PropUserProperty -// "\r&\218\SOH\216{kV\142XS\182E\247D\162C" "\247\204w\212\157\255%\a\187K\v",PropMessageExpiryInterval -// 31117,PropServerKeepAlive 3900,PropRequestProblemInformation 83,PropRetainAvailable 226,PropTopicAlias -// 28186,PropMessageExpiryInterval 2261]} +// ConnectRequest {_username = Nothing, _password = Just +// "\169\134\229\177\141\167:\"\240_\168S\ETB~\228\190\175\174\ACK\168\191@\171\199\GSM\208h", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\173en(3\180\NAK\238\226z\SO\231\221<8u\183\188\229\221\231\131\185\v\203;", _willMsg = +// "z#W\234\STX\229\164\203\229\130\201\SOHy\205\&3\169>\205\160\203dE\ACK\255\213\164\225\ESC\163", _willProps = +// [PropRequestProblemInformation 242,PropAuthenticationData "",PropAuthenticationData +// "\"yp\192\175\146C?8Q\CAN\229/\SOp\156@\251\143\150\219\144$\DC2'",PropServerKeepAlive 23446,PropReasonString +// "\186\198\152Y\237\184\EOT\147\184\169\189H>",PropSharedSubscriptionAvailable 254,PropSessionExpiryInterval +// 20915,PropResponseTopic "EN\v\ENQ\164\&6\RS\NULY>\157\204\SUB",PropPayloadFormatIndicator +// 53,PropPayloadFormatIndicator 115,PropReasonString +// "\SIX6D\176\186&\222\EOT7\243\252\194\145",PropWildcardSubscriptionAvailable 157,PropContentType +// "B>\225z\253+\221\165",PropSessionExpiryInterval 8027,PropMaximumPacketSize 3910]}), _cleanSession = True, _keepAlive +// = 14436, _connID = "\"\179\&5mH+{\187\208\t`<\149\EOT\249\182\214\184\&8\198\201\139\186\&5", _properties = []} TEST(Connect5QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x72, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x79, 0x4d, 0x42, 0x16, 0x0, 0x6, 0x7d, - 0x1, 0x81, 0x31, 0xd8, 0x53, 0x2a, 0x1a, 0x28, 0x87, 0x26, 0x0, 0x11, 0xd, 0x26, 0xda, 0x1, 0xd8, - 0x7b, 0x6b, 0x56, 0x8e, 0x58, 0x53, 0xb6, 0x45, 0xf7, 0x44, 0xa2, 0x43, 0x0, 0xb, 0xf7, 0xcc, 0x77, - 0xd4, 0x9d, 0xff, 0x25, 0x7, 0xbb, 0x4b, 0xb, 0x2, 0x0, 0x0, 0x79, 0x8d, 0x13, 0xf, 0x3c, 0x17, - 0x53, 0x25, 0xe2, 0x23, 0x6e, 0x1a, 0x2, 0x0, 0x0, 0x8, 0xd5, 0x0, 0x9, 0x58, 0x86, 0xce, 0xe8, - 0x86, 0xf3, 0xdd, 0x11, 0xfc, 0x0, 0xa, 0x12, 0x4b, 0x1, 0xcd, 0x82, 0xf3, 0xc5, 0x8a, 0xfb, 0x67, - 0x0, 0xc, 0xcb, 0xa2, 0xb0, 0xdf, 0x6e, 0xa3, 0x9f, 0xcc, 0x15, 0x9, 0x2b, 0xd4}; + uint8_t pkt[] = {0x10, 0xf6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x56, 0x38, 0x64, 0x0, 0x0, 0x18, 0x22, + 0xb3, 0x35, 0x6d, 0x48, 0x2b, 0x7b, 0xbb, 0xd0, 0x9, 0x60, 0x3c, 0x95, 0x4, 0xf9, 0xb6, 0xd6, 0xb8, + 0x38, 0xc6, 0xc9, 0x8b, 0xba, 0x35, 0x77, 0x17, 0xf2, 0x16, 0x0, 0x0, 0x16, 0x0, 0x19, 0x22, 0x79, + 0x70, 0xc0, 0xaf, 0x92, 0x43, 0x3f, 0x38, 0x51, 0x18, 0xe5, 0x2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x4d, 0xd0, 0x68}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7d, 0x1, 0x81, 0x31, 0xd8, 0x53}; - uint8_t bytesprops2[] = {0xf7, 0xcc, 0x77, 0xd4, 0x9d, 0xff, 0x25, 0x7, 0xbb, 0x4b, 0xb}; - uint8_t bytesprops1[] = {0xd, 0x26, 0xda, 0x1, 0xd8, 0x7b, 0x6b, 0x56, 0x8e, - 0x58, 0x53, 0xb6, 0x45, 0xf7, 0x44, 0xa2, 0x43}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31117}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3900}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28186}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2261}}, + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops1[] = {0x22, 0x79, 0x70, 0xc0, 0xaf, 0x92, 0x43, 0x3f, 0x38, 0x51, 0x18, 0xe5, 0x2f, + 0xe, 0x70, 0x9c, 0x40, 0xfb, 0x8f, 0x96, 0xdb, 0x90, 0x24, 0x12, 0x27}; + uint8_t byteswillprops2[] = {0xba, 0xc6, 0x98, 0x59, 0xed, 0xb8, 0x4, 0x93, 0xb8, 0xa9, 0xbd, 0x48, 0x3e}; + uint8_t byteswillprops3[] = {0x45, 0x4e, 0xb, 0x5, 0xa4, 0x36, 0x1e, 0x0, 0x59, 0x3e, 0x9d, 0xcc, 0x1a}; + uint8_t byteswillprops4[] = {0xf, 0x58, 0x36, 0x44, 0xb0, 0xba, 0x26, 0xde, 0x4, 0x37, 0xf3, 0xfc, 0xc2, 0x91}; + uint8_t byteswillprops5[] = {0x42, 0x3e, 0xe1, 0x7a, 0xfd, 0x2b, 0xdd, 0xa5}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23446}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20915}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8027}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3910}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xad, 0x65, 0x6e, 0x28, 0x33, 0xb4, 0x15, 0xee, 0xe2, 0x7a, 0xe, 0xe7, 0xdd, + 0x3c, 0x38, 0x75, 0xb7, 0xbc, 0xe5, 0xdd, 0xe7, 0x83, 0xb9, 0xb, 0xcb, 0x3b}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7a, 0x23, 0x57, 0xea, 0x2, 0xe5, 0xa4, 0xcb, 0xe5, 0x82, + 0xc9, 0x1, 0x79, 0xcd, 0x33, 0xa9, 0x3e, 0xcd, 0xa0, 0xcb, + 0x64, 0x45, 0x6, 0xff, 0xd5, 0xa4, 0xe1, 0x1b, 0xa3}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 31053; - uint8_t client_id_bytes[] = {0x58, 0x86, 0xce, 0xe8, 0x86, 0xf3, 0xdd, 0x11, 0xfc}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.keep_alive = 14436; + uint8_t client_id_bytes[] = {0x22, 0xb3, 0x35, 0x6d, 0x48, 0x2b, 0x7b, 0xbb, 0xd0, 0x9, 0x60, 0x3c, + 0x95, 0x4, 0xf9, 0xb6, 0xd6, 0xb8, 0x38, 0xc6, 0xc9, 0x8b, 0xba, 0x35}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x12, 0x4b, 0x1, 0xcd, 0x82, 0xf3, 0xc5, 0x8a, 0xfb, 0x67}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xcb, 0xa2, 0xb0, 0xdf, 0x6e, 0xa3, 0x9f, 0xcc, 0x15, 0x9, 0x2b, 0xd4}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xa9, 0x86, 0xe5, 0xb1, 0x8d, 0xa7, 0x3a, 0x22, 0xf0, 0x5f, 0xa8, 0x53, 0x17, 0x7e, + 0xe4, 0xbe, 0xaf, 0xae, 0x6, 0xa8, 0xbf, 0x40, 0xab, 0xc7, 0x1d, 0x4d, 0xd0, 0x68}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\SI\249\217\245+\148\214W4\194\166\EM\248\229\173\221\207!\207", _password = Just -// "\162\230\187s\155\185\166\184\194\DLE6", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic -// = "\NAK6\214\US\166`\243!\147\STX\254$x\152\221|]V\DC2\132\180{E#\STX|.\209\244", _willMsg = -// "\200\238p[\209Nf\186\211\186\213\164\&0\t\223\176", _willProps = [PropMaximumQoS 157,PropReceiveMaximum -// 16723,PropServerKeepAlive 27480,PropMaximumQoS 253,PropSubscriptionIdentifierAvailable 139,PropWillDelayInterval -// 11494,PropServerReference "\131\DC38j\252,b\147\&5\198\144",PropReasonString -// "\243\148$\128-\210\196\ENQ\187\171ZP\178]\246\SI\182\243\133ST\150\176\159_F",PropTopicAlias 31551,PropResponseTopic -// "Qj\231\141\&6\136\207\146\131N\DEL\171%+\197\145'[",PropServerReference "zf",PropMaximumQoS -// 241,PropPayloadFormatIndicator 135,PropRequestResponseInformation 193,PropSubscriptionIdentifierAvailable -// 41,PropResponseInformation "\199k\128y",PropAssignedClientIdentifier "e\146\175\173y\189\235\CAN0"]}), _cleanSession -// = True, _keepAlive = 12605, _connID = "\132\135\132`\t\238\191\184 \SOH\162", _properties = -// [PropMessageExpiryInterval 20650,PropAuthenticationData -// ";Y\134\213\220\FS\145\157\247\194\a\148\212\228\146\GS\SYNpKh\129\SOR\230q\248\178>\225",PropMaximumQoS -// 209,PropSessionExpiryInterval 6705,PropResponseTopic -// "\190-F\201\158\164H\167\236=\188",PropSubscriptionIdentifierAvailable 19,PropTopicAlias -// 4285,PropSharedSubscriptionAvailable 74,PropAssignedClientIdentifier "\172\DC2%\190\136",PropReasonString -// "UP\235\245\192YI\\\201$e\225\130\ENQn<2\141",PropTopicAlias 15039,PropMaximumQoS 17,PropTopicAlias -// 22926,PropCorrelationData "\CAN\239\FS\DC4\177\164o\246&\207",PropMessageExpiryInterval 20290]} +// ConnectRequest {_username = Nothing, _password = Just "O\165\188\192\128\155\192a\198\EM?\198\230)}\161", _lastWill = +// Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "s\137\218\237\244]\194(\128\202w\240\147M6\232\218\245\251\&7hf\206t", _willMsg = +// "\238+y\253\141\&0--\219\143\226YM\140U\"dA\DLE\235\128", _willProps = [PropRequestProblemInformation +// 3,PropAuthenticationMethod "\229\183\172\208\ENQ\199\204(w\US\210\ETX6\164f",PropSubscriptionIdentifier +// 12,PropReceiveMaximum 7050,PropResponseTopic +// "\193uF,@T\253\131\198\206\251\135\187~\SOH\175\130\DC3\ENQ",PropServerKeepAlive 4117,PropAuthenticationData +// "\211\t\189\145\187\208\161\141\243y[E\235\213\FS\197H5$A(k",PropMaximumQoS 169,PropPayloadFormatIndicator +// 33,PropSubscriptionIdentifier 29,PropAuthenticationMethod +// "\162\206\f\219$\250\139\159\236}>E\199",PropSubscriptionIdentifierAvailable 188,PropMessageExpiryInterval +// 17531,PropPayloadFormatIndicator 197,PropMaximumQoS 196,PropRequestResponseInformation +// 21,PropRequestProblemInformation 250,PropRetainAvailable 235,PropRequestResponseInformation 123,PropTopicAliasMaximum +// 21710,PropResponseInformation +// "\SYN\194\142n\150\227\131\221\211\GS\vH\187\r@\171\229\178\166s\DC1\148\237X\249\&5*",PropMaximumQoS +// 195,PropAuthenticationMethod "]\r\178\ACK\247",PropServerReference +// "\163\225\&7\US\140\239\131\221\218fxe",PropAssignedClientIdentifier +// "\ESC\GS\SI\DC2l\243>Gr\150\186\145\&7\218\244\234\225c\171Vgq\207oE\187"]}), _cleanSession = False, _keepAlive = +// 3208, _connID = "\DC3P\129h", _properties = [PropTopicAlias 25688]} TEST(Connect5QCTest, Encode25) { uint8_t pkt[] = { - 0x10, 0xd8, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x31, 0x3d, 0x78, 0x2, 0x0, 0x0, 0x50, 0xaa, - 0x16, 0x0, 0x1d, 0x3b, 0x59, 0x86, 0xd5, 0xdc, 0x1c, 0x91, 0x9d, 0xf7, 0xc2, 0x7, 0x94, 0xd4, 0xe4, 0x92, 0x1d, - 0x16, 0x70, 0x4b, 0x68, 0x81, 0xe, 0x52, 0xe6, 0x71, 0xf8, 0xb2, 0x3e, 0xe1, 0x24, 0xd1, 0x11, 0x0, 0x0, 0x1a, - 0x31, 0x8, 0x0, 0xb, 0xbe, 0x2d, 0x46, 0xc9, 0x9e, 0xa4, 0x48, 0xa7, 0xec, 0x3d, 0xbc, 0x29, 0x13, 0x23, 0x10, - 0xbd, 0x2a, 0x4a, 0x12, 0x0, 0x5, 0xac, 0x12, 0x25, 0xbe, 0x88, 0x1f, 0x0, 0x12, 0x55, 0x50, 0xeb, 0xf5, 0xc0, - 0x59, 0x49, 0x5c, 0xc9, 0x24, 0x65, 0xe1, 0x82, 0x5, 0x6e, 0x3c, 0x32, 0x8d, 0x23, 0x3a, 0xbf, 0x24, 0x11, 0x23, - 0x59, 0x8e, 0x9, 0x0, 0xa, 0x18, 0xef, 0x1c, 0x14, 0xb1, 0xa4, 0x6f, 0xf6, 0x26, 0xcf, 0x2, 0x0, 0x0, 0x4f, - 0x42, 0x0, 0xb, 0x84, 0x87, 0x84, 0x60, 0x9, 0xee, 0xbf, 0xb8, 0x20, 0x1, 0xa2, 0x74,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x24, 0xc3, 0x15, 0x0, 0x5, 0x5d, 0xd, 0xb2, 0x6, 0xf7, 0x1c, 0x0, 0xc, 0xa3, 0xe1, 0x37, + 0x1f, 0x8c, 0xef, 0x83, 0xdd, 0xda, 0x66, 0x78, 0x65, 0x12, 0x0, 0x1a, 0x1b, 0x1d, 0xf, 0x12, 0x6c, 0xf3, 0x3e, + 0x47, 0x72, 0x96, 0xba, 0x91, 0x37, 0xda, 0xf4, 0xea, 0xe1, 0x63, 0xab, 0x56, 0x67, 0x71, 0xcf, 0x6f, 0x45, 0xbb, + 0x0, 0x18, 0x73, 0x89, 0xda, 0xed, 0xf4, 0x5d, 0xc2, 0x28, 0x80, 0xca, 0x77, 0xf0, 0x93, 0x4d, 0x36, 0xe8, 0xda, + 0xf5, 0xfb, 0x37, 0x68, 0x66, 0xce, 0x74, 0x0, 0x15, 0xee, 0x2b, 0x79, 0xfd, 0x8d, 0x30, 0x2d, 0x2d, 0xdb, 0x8f, + 0xe2, 0x59, 0x4d, 0x8c, 0x55, 0x22, 0x64, 0x41, 0x10, 0xeb, 0x80, 0x0, 0x10, 0x4f, 0xa5, 0xbc, 0xc0, 0x80, 0x9b, + 0xc0, 0x61, 0xc6, 0x19, 0x3f, 0xc6, 0xe6, 0x29, 0x7d, 0xa1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x3b, 0x59, 0x86, 0xd5, 0xdc, 0x1c, 0x91, 0x9d, 0xf7, 0xc2, 0x7, 0x94, 0xd4, 0xe4, 0x92, - 0x1d, 0x16, 0x70, 0x4b, 0x68, 0x81, 0xe, 0x52, 0xe6, 0x71, 0xf8, 0xb2, 0x3e, 0xe1}; - uint8_t bytesprops1[] = {0xbe, 0x2d, 0x46, 0xc9, 0x9e, 0xa4, 0x48, 0xa7, 0xec, 0x3d, 0xbc}; - uint8_t bytesprops2[] = {0xac, 0x12, 0x25, 0xbe, 0x88}; - uint8_t bytesprops3[] = {0x55, 0x50, 0xeb, 0xf5, 0xc0, 0x59, 0x49, 0x5c, 0xc9, - 0x24, 0x65, 0xe1, 0x82, 0x5, 0x6e, 0x3c, 0x32, 0x8d}; - uint8_t bytesprops4[] = {0x18, 0xef, 0x1c, 0x14, 0xb1, 0xa4, 0x6f, 0xf6, 0x26, 0xcf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20650}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6705}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4285}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15039}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22926}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20290}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25688}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x83, 0x13, 0x38, 0x6a, 0xfc, 0x2c, 0x62, 0x93, 0x35, 0xc6, 0x90}; - uint8_t byteswillprops1[] = {0xf3, 0x94, 0x24, 0x80, 0x2d, 0xd2, 0xc4, 0x5, 0xbb, 0xab, 0x5a, 0x50, 0xb2, - 0x5d, 0xf6, 0xf, 0xb6, 0xf3, 0x85, 0x53, 0x54, 0x96, 0xb0, 0x9f, 0x5f, 0x46}; - uint8_t byteswillprops2[] = {0x51, 0x6a, 0xe7, 0x8d, 0x36, 0x88, 0xcf, 0x92, 0x83, - 0x4e, 0x7f, 0xab, 0x25, 0x2b, 0xc5, 0x91, 0x27, 0x5b}; - uint8_t byteswillprops3[] = {0x7a, 0x66}; - uint8_t byteswillprops4[] = {0xc7, 0x6b, 0x80, 0x79}; - uint8_t byteswillprops5[] = {0x65, 0x92, 0xaf, 0xad, 0x79, 0xbd, 0xeb, 0x18, 0x30}; + uint8_t byteswillprops0[] = {0xe5, 0xb7, 0xac, 0xd0, 0x5, 0xc7, 0xcc, 0x28, 0x77, 0x1f, 0xd2, 0x3, 0x36, 0xa4, 0x66}; + uint8_t byteswillprops1[] = {0xc1, 0x75, 0x46, 0x2c, 0x40, 0x54, 0xfd, 0x83, 0xc6, 0xce, + 0xfb, 0x87, 0xbb, 0x7e, 0x1, 0xaf, 0x82, 0x13, 0x5}; + uint8_t byteswillprops2[] = {0xd3, 0x9, 0xbd, 0x91, 0xbb, 0xd0, 0xa1, 0x8d, 0xf3, 0x79, 0x5b, + 0x45, 0xeb, 0xd5, 0x1c, 0xc5, 0x48, 0x35, 0x24, 0x41, 0x28, 0x6b}; + uint8_t byteswillprops3[] = {0xa2, 0xce, 0xc, 0xdb, 0x24, 0xfa, 0x8b, 0x9f, 0xec, 0x7d, 0x3e, 0x45, 0xc7}; + uint8_t byteswillprops4[] = {0x16, 0xc2, 0x8e, 0x6e, 0x96, 0xe3, 0x83, 0xdd, 0xd3, 0x1d, 0xb, 0x48, 0xbb, 0xd, + 0x40, 0xab, 0xe5, 0xb2, 0xa6, 0x73, 0x11, 0x94, 0xed, 0x58, 0xf9, 0x35, 0x2a}; + uint8_t byteswillprops5[] = {0x5d, 0xd, 0xb2, 0x6, 0xf7}; + uint8_t byteswillprops6[] = {0xa3, 0xe1, 0x37, 0x1f, 0x8c, 0xef, 0x83, 0xdd, 0xda, 0x66, 0x78, 0x65}; + uint8_t byteswillprops7[] = {0x1b, 0x1d, 0xf, 0x12, 0x6c, 0xf3, 0x3e, 0x47, 0x72, 0x96, 0xba, 0x91, 0x37, + 0xda, 0xf4, 0xea, 0xe1, 0x63, 0xab, 0x56, 0x67, 0x71, 0xcf, 0x6f, 0x45, 0xbb}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16723}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27480}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11494}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31551}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7050}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4117}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17531}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21710}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&byteswillprops7}}}, }; - lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x15, 0x36, 0xd6, 0x1f, 0xa6, 0x60, 0xf3, 0x21, 0x93, 0x2, 0xfe, 0x24, 0x78, 0x98, 0xdd, - 0x7c, 0x5d, 0x56, 0x12, 0x84, 0xb4, 0x7b, 0x45, 0x23, 0x2, 0x7c, 0x2e, 0xd1, 0xf4}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc8, 0xee, 0x70, 0x5b, 0xd1, 0x4e, 0x66, 0xba, - 0xd3, 0xba, 0xd5, 0xa4, 0x30, 0x9, 0xdf, 0xb0}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x73, 0x89, 0xda, 0xed, 0xf4, 0x5d, 0xc2, 0x28, 0x80, 0xca, 0x77, 0xf0, + 0x93, 0x4d, 0x36, 0xe8, 0xda, 0xf5, 0xfb, 0x37, 0x68, 0x66, 0xce, 0x74}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xee, 0x2b, 0x79, 0xfd, 0x8d, 0x30, 0x2d, 0x2d, 0xdb, 0x8f, 0xe2, + 0x59, 0x4d, 0x8c, 0x55, 0x22, 0x64, 0x41, 0x10, 0xeb, 0x80}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -9512,17 +9511,14 @@ TEST(Connect5QCTest, Encode25) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 12605; - uint8_t client_id_bytes[] = {0x84, 0x87, 0x84, 0x60, 0x9, 0xee, 0xbf, 0xb8, 0x20, 0x1, 0xa2}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 3208; + uint8_t client_id_bytes[] = {0x13, 0x50, 0x81, 0x68}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf, 0xf9, 0xd9, 0xf5, 0x2b, 0x94, 0xd6, 0x57, 0x34, 0xc2, - 0xa6, 0x19, 0xf8, 0xe5, 0xad, 0xdd, 0xcf, 0x21, 0xcf}; - lwmqtt_string_t username = {19, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xa2, 0xe6, 0xbb, 0x73, 0x9b, 0xb9, 0xa6, 0xb8, 0xc2, 0x10, 0x36}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x4f, 0xa5, 0xbc, 0xc0, 0x80, 0x9b, 0xc0, 0x61, + 0xc6, 0x19, 0x3f, 0xc6, 0xe6, 0x29, 0x7d, 0xa1}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9532,113 +9528,90 @@ TEST(Connect5QCTest, Encode25) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\222\FS\NUL", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "\236?v#\231\182\221\157[=\139|\191\209\208\147\164?\221=)\ETB?\217\223e", _willMsg = -// "n\212", _willProps = [PropRequestResponseInformation 94,PropPayloadFormatIndicator 132,PropContentType -// "p\128\239\STX\229\200",PropCorrelationData -// "\168\239}\235\219\230\139\&9\232L\237\181\208P\226\SYN\"\213zF",PropSharedSubscriptionAvailable 131,PropMaximumQoS -// 210,PropSessionExpiryInterval 31642]}), _cleanSession = False, _keepAlive = 12313, _connID = "%W\235 -// )\183\218\188oO\152j\237\b!", _properties = [PropCorrelationData "",PropUserProperty -// "\219\242\DEL\229\232\&8\DC4\147\200\214@O0\216<\234\&4\159\204\231\139:^\204" -// "![s\250\196\NUL@\239?2\133\DC2\246\238\195V",PropTopicAliasMaximum 15720,PropMaximumPacketSize -// 32521,PropAuthenticationMethod "V",PropContentType -// "\228wB\STX\194\206%\CAN\253;\136\215\&4-\139\205\178\DC3_\234\146\226\199\ENQ",PropAuthenticationMethod -// "\t\169\192\150\246\214H\SYN\DC1`",PropUserProperty -// "\164\135\171\CAN\208\134:\172\201\184\ENQ\150s\183\181\241\202<\203\148q\249\t\148\137\176Ka\255\n" -// "\207\193\157\215D\164\FS{@\214\n",PropSharedSubscriptionAvailable 210,PropPayloadFormatIndicator -// 250,PropAuthenticationMethod "\140\250\165x\183l/)",PropServerKeepAlive 15023,PropServerKeepAlive -// 6531,PropUserProperty "\218 I\NULQ\196" "\EM\168\134\161z5\RSV\243\NAKZ\172e\219c\167"]} +// ConnectRequest {_username = Just "\149\151\139\195\172z\255\139u#\163\fg,\230|\158{", _password = Just +// "Z\165\208\RS\195i\201D9m(Z ,\165\217Aa\137\ENQ\SO\180", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "\141-\179\ENQl~\217\164\234\131\134\134\207X", _willMsg = +// ";\NUL\DEL\NUL\RSHW\212\230\191L\211s)\181j\203\158\229\137", _willProps = [PropAuthenticationMethod +// "\US\154\190)\184\149\NAK",PropTopicAlias 13388,PropWillDelayInterval 5881,PropWillDelayInterval +// 28801,PropSessionExpiryInterval 22600,PropTopicAlias 14648]}), _cleanSession = True, _keepAlive = 32044, _connID = +// "\248\r\241\217\233\199#\171\195\&6}Wu\226i\209\194\149\251\&6X$\144\230", _properties = [PropServerKeepAlive +// 16671,PropContentType "\130\SYNsO\170[*r\142\180q\146\244g\240\140\232",PropServerKeepAlive +// 5048,PropSubscriptionIdentifier 30,PropSharedSubscriptionAvailable 155,PropMessageExpiryInterval +// 25875,PropSharedSubscriptionAvailable 118,PropRequestProblemInformation 2,PropTopicAlias +// 30294,PropSessionExpiryInterval 23927,PropAuthenticationData "\138,H\185\139\&1\156\173"]} TEST(Connect5QCTest, Encode26) { - uint8_t pkt[] = { - 0x10, 0xb2, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb4, 0x30, 0x19, 0xc2, 0x1, 0x9, 0x0, 0x0, 0x26,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, 0x23, 0xab, 0xc3, 0x36, 0x7d, + 0x57, 0x75, 0xe2, 0x69, 0xd1, 0xc2, 0x95, 0xfb, 0x36, 0x58, 0x24, 0x90, 0xe6, 0x1f, 0x15, 0x0, 0x7, + 0x1f, 0x9a, 0xbe, 0x29, 0xb8, 0x95, 0x15, 0x23, 0x34, 0x4c, 0x18, 0x0, 0x0, 0x16, 0xf9, 0x18, 0x0, + 0x0, 0x70, 0x81, 0x11, 0x0, 0x0, 0x58, 0x48, 0x23, 0x39, 0x38, 0x0, 0xe, 0x8d, 0x2d, 0xb3, 0x5, + 0x6c, 0x7e, 0xd9, 0xa4, 0xea, 0x83, 0x86, 0x86, 0xcf, 0x58, 0x0, 0x14, 0x3b, 0x0, 0x7f, 0x0, 0x1e, + 0x48, 0x57, 0xd4, 0xe6, 0xbf, 0x4c, 0xd3, 0x73, 0x29, 0xb5, 0x6a, 0xcb, 0x9e, 0xe5, 0x89, 0x0, 0x12, + 0x95, 0x97, 0x8b, 0xc3, 0xac, 0x7a, 0xff, 0x8b, 0x75, 0x23, 0xa3, 0xc, 0x67, 0x2c, 0xe6, 0x7c, 0x9e, + 0x7b, 0x0, 0x16, 0x5a, 0xa5, 0xd0, 0x1e, 0xc3, 0x69, 0xc9, 0x44, 0x39, 0x6d, 0x28, 0x5a, 0x20, 0x2c, + 0xa5, 0xd9, 0x41, 0x61, 0x89, 0x5, 0xe, 0xb4}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops2[] = {0x21, 0x5b, 0x73, 0xfa, 0xc4, 0x0, 0x40, 0xef, - 0x3f, 0x32, 0x85, 0x12, 0xf6, 0xee, 0xc3, 0x56}; - uint8_t bytesprops1[] = {0xdb, 0xf2, 0x7f, 0xe5, 0xe8, 0x38, 0x14, 0x93, 0xc8, 0xd6, 0x40, 0x4f, - 0x30, 0xd8, 0x3c, 0xea, 0x34, 0x9f, 0xcc, 0xe7, 0x8b, 0x3a, 0x5e, 0xcc}; - uint8_t bytesprops3[] = {0x56}; - uint8_t bytesprops4[] = {0xe4, 0x77, 0x42, 0x2, 0xc2, 0xce, 0x25, 0x18, 0xfd, 0x3b, 0x88, 0xd7, - 0x34, 0x2d, 0x8b, 0xcd, 0xb2, 0x13, 0x5f, 0xea, 0x92, 0xe2, 0xc7, 0x5}; - uint8_t bytesprops5[] = {0x9, 0xa9, 0xc0, 0x96, 0xf6, 0xd6, 0x48, 0x16, 0x11, 0x60}; - uint8_t bytesprops7[] = {0xcf, 0xc1, 0x9d, 0xd7, 0x44, 0xa4, 0x1c, 0x7b, 0x40, 0xd6, 0xa}; - uint8_t bytesprops6[] = {0xa4, 0x87, 0xab, 0x18, 0xd0, 0x86, 0x3a, 0xac, 0xc9, 0xb8, 0x5, 0x96, 0x73, 0xb7, 0xb5, - 0xf1, 0xca, 0x3c, 0xcb, 0x94, 0x71, 0xf9, 0x9, 0x94, 0x89, 0xb0, 0x4b, 0x61, 0xff, 0xa}; - uint8_t bytesprops8[] = {0x8c, 0xfa, 0xa5, 0x78, 0xb7, 0x6c, 0x2f, 0x29}; - uint8_t bytesprops10[] = {0x19, 0xa8, 0x86, 0xa1, 0x7a, 0x35, 0x1e, 0x56, - 0xf3, 0x15, 0x5a, 0xac, 0x65, 0xdb, 0x63, 0xa7}; - uint8_t bytesprops9[] = {0xda, 0x20, 0x49, 0x0, 0x51, 0xc4}; + uint8_t bytesprops0[] = {0x82, 0x16, 0x73, 0x4f, 0xaa, 0x5b, 0x2a, 0x72, 0x8e, + 0xb4, 0x71, 0x92, 0xf4, 0x67, 0xf0, 0x8c, 0xe8}; + uint8_t bytesprops1[] = {0x8a, 0x2c, 0x48, 0xb9, 0x8b, 0x31, 0x9c, 0xad}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops1}, .v = {16, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15720}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32521}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops6}, .v = {11, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15023}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6531}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops9}, .v = {16, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16671}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5048}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25875}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30294}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23927}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x70, 0x80, 0xef, 0x2, 0xe5, 0xc8}; - uint8_t byteswillprops1[] = {0xa8, 0xef, 0x7d, 0xeb, 0xdb, 0xe6, 0x8b, 0x39, 0xe8, 0x4c, - 0xed, 0xb5, 0xd0, 0x50, 0xe2, 0x16, 0x22, 0xd5, 0x7a, 0x46}; + uint8_t byteswillprops0[] = {0x1f, 0x9a, 0xbe, 0x29, 0xb8, 0x95, 0x15}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31642}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13388}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5881}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28801}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22600}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14648}}, }; - lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xec, 0x3f, 0x76, 0x23, 0xe7, 0xb6, 0xdd, 0x9d, 0x5b, 0x3d, 0x8b, 0x7c, 0xbf, - 0xd1, 0xd0, 0x93, 0xa4, 0x3f, 0xdd, 0x3d, 0x29, 0x17, 0x3f, 0xd9, 0xdf, 0x65}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6e, 0xd4}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8d, 0x2d, 0xb3, 0x5, 0x6c, 0x7e, 0xd9, 0xa4, 0xea, 0x83, 0x86, 0x86, 0xcf, 0x58}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3b, 0x0, 0x7f, 0x0, 0x1e, 0x48, 0x57, 0xd4, 0xe6, 0xbf, + 0x4c, 0xd3, 0x73, 0x29, 0xb5, 0x6a, 0xcb, 0x9e, 0xe5, 0x89}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12313; - uint8_t client_id_bytes[] = {0x25, 0x57, 0xeb, 0x20, 0x29, 0xb7, 0xda, 0xbc, 0x6f, 0x4f, 0x98, 0x6a, 0xed, 0x8, 0x21}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 32044; + uint8_t client_id_bytes[] = {0xf8, 0xd, 0xf1, 0xd9, 0xe9, 0xc7, 0x23, 0xab, 0xc3, 0x36, 0x7d, 0x57, + 0x75, 0xe2, 0x69, 0xd1, 0xc2, 0x95, 0xfb, 0x36, 0x58, 0x24, 0x90, 0xe6}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xde, 0x1c, 0x0}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x95, 0x97, 0x8b, 0xc3, 0xac, 0x7a, 0xff, 0x8b, 0x75, + 0x23, 0xa3, 0xc, 0x67, 0x2c, 0xe6, 0x7c, 0x9e, 0x7b}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x5a, 0xa5, 0xd0, 0x1e, 0xc3, 0x69, 0xc9, 0x44, 0x39, 0x6d, 0x28, + 0x5a, 0x20, 0x2c, 0xa5, 0xd9, 0x41, 0x61, 0x89, 0x5, 0xe, 0xb4}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9647,98 +9620,95 @@ TEST(Connect5QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\ENQ\177\248\150\234\US\132\246q", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS2, _willTopic = "\183\FS\DC1\132\182jmFH\GS\201\141\226\&3\n", _willMsg = -// "\134\204\FS{\151\206b\190e\177\149\v\146\182\240\197\189NN\183\242\207\\BM\fs\198H", _willProps = -// [PropServerKeepAlive 253,PropWillDelayInterval 12369,PropAuthenticationMethod "6"]}), _cleanSession = True, -// _keepAlive = 13514, _connID = "\161 \149\244\226\242\217\139I p\234\"\249\DLE\216>p\SOV\CAN\207\131", _properties = -// [PropAuthenticationData -// "~\223\208\175\211\192iA\151\215\172P\184\236\142OE\201Y\204iO\225\209\219VY\203",PropUserProperty -// "E\208\251\CAN\177J\CAN\\\222lb&\194>\230\158" -// "\226\147\172\156B\153\226x\SOH\158\ETXU\GS\193\188Gt+\n\237-.u\133\149",PropTopicAliasMaximum -// 10312,PropRequestResponseInformation 21,PropServerKeepAlive 7697,PropServerReference -// "X\219",PropAssignedClientIdentifier -// "VJ\ENQ\167\243}\244\\\204k\158}CO\RSg\206$\143\220\180E\184\176\234\174\131\199\180",PropServerReference -// "\200\&8\251e\205\186v\SYNf\128\227\SYN8\141",PropTopicAliasMaximum 16471,PropTopicAlias 28347,PropServerKeepAlive -// 11503,PropAuthenticationData "\153U\163\173\234J\243\188\&2c\150\233"]} +// ConnectRequest {_username = Just "|\236r\252\&0Ku{\146\ETX\ACKm\178\134\193P\SUB", _password = Just +// "mYo\132\144\131\150'\206lC{\157\159\174\ETX", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, +// _willTopic = "\129\242\250\251\220\214\242\EOTx\180\v4H\156w\139\247zR\199u\172r\136\155\198\SUB", _willMsg = +// "\166V\216\GS\135B\DC4\223\177\149\223\195\178\NUL\DLER\206/Q'O\128-\EOT\134", _willProps = [PropResponseTopic +// "\130\241\197(\190\174\161!>\239\171\160C\134",PropWildcardSubscriptionAvailable 54,PropAuthenticationData +// "\154\197Y\137\254\DC4\149$\GS\234\&5\227a,\DC2\161[W\199{H\207\235MJ\154",PropSharedSubscriptionAvailable +// 18,PropTopicAliasMaximum 31321,PropTopicAlias 3735,PropReasonString "\216A\SOH\US\132e@S",PropSessionExpiryInterval +// 27865]}), _cleanSession = False, _keepAlive = 12650, _connID = "\180N\165", _properties = [PropUserProperty +// "\202\237c\v\218Sd\DC3p\214\137/r\128\188\&0sB\NUL5\"\138\206&s=\140\157A#" +// "\205>k@\231\182z%\159#\SUB\230\NUL",PropServerReference +// "a\129\178\132?\133\186\vro/\254\184b4\148\139",PropRetainAvailable 26,PropRequestProblemInformation +// 130,PropPayloadFormatIndicator 226,PropServerReference "\\\206"]} TEST(Connect5QCTest, Encode27) { uint8_t pkt[] = { - 0x10, 0x90, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x34, 0xca, 0xa3, 0x1, 0x16, 0x0, 0x1c, 0x7e, - 0xdf, 0xd0, 0xaf, 0xd3, 0xc0, 0x69, 0x41, 0x97, 0xd7, 0xac, 0x50, 0xb8, 0xec, 0x8e, 0x4f, 0x45, 0xc9, 0x59, 0xcc, - 0x69, 0x4f, 0xe1, 0xd1, 0xdb, 0x56, 0x59, 0xcb, 0x26, 0x0, 0x10, 0x45, 0xd0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, 0x7a, 0x59, + 0x23, 0xe, 0x97, 0x1f, 0x0, 0x8, 0xd8, 0x41, 0x1, 0x1f, 0x84, 0x65, 0x40, 0x53, 0x11, 0x0, 0x0, 0x6c, 0xd9, + 0x0, 0x1b, 0x81, 0xf2, 0xfa, 0xfb, 0xdc, 0xd6, 0xf2, 0x4, 0x78, 0xb4, 0xb, 0x34, 0x48, 0x9c, 0x77, 0x8b, 0xf7, + 0x7a, 0x52, 0xc7, 0x75, 0xac, 0x72, 0x88, 0x9b, 0xc6, 0x1a, 0x0, 0x19, 0xa6, 0x56, 0xd8, 0x1d, 0x87, 0x42, 0x14, + 0xdf, 0xb1, 0x95, 0xdf, 0xc3, 0xb2, 0x0, 0x10, 0x52, 0xce, 0x2f, 0x51, 0x27, 0x4f, 0x80, 0x2d, 0x4, 0x86, 0x0, + 0x11, 0x7c, 0xec, 0x72, 0xfc, 0x30, 0x4b, 0x75, 0x7b, 0x92, 0x3, 0x6, 0x6d, 0xb2, 0x86, 0xc1, 0x50, 0x1a, 0x0, + 0x10, 0x6d, 0x59, 0x6f, 0x84, 0x90, 0x83, 0x96, 0x27, 0xce, 0x6c, 0x43, 0x7b, 0x9d, 0x9f, 0xae, 0x3}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7e, 0xdf, 0xd0, 0xaf, 0xd3, 0xc0, 0x69, 0x41, 0x97, 0xd7, 0xac, 0x50, 0xb8, 0xec, - 0x8e, 0x4f, 0x45, 0xc9, 0x59, 0xcc, 0x69, 0x4f, 0xe1, 0xd1, 0xdb, 0x56, 0x59, 0xcb}; - uint8_t bytesprops2[] = {0xe2, 0x93, 0xac, 0x9c, 0x42, 0x99, 0xe2, 0x78, 0x1, 0x9e, 0x3, 0x55, 0x1d, - 0xc1, 0xbc, 0x47, 0x74, 0x2b, 0xa, 0xed, 0x2d, 0x2e, 0x75, 0x85, 0x95}; - uint8_t bytesprops1[] = {0x45, 0xd0, 0xfb, 0x18, 0xb1, 0x4a, 0x18, 0x5c, - 0xde, 0x6c, 0x62, 0x26, 0xc2, 0x3e, 0xe6, 0x9e}; - uint8_t bytesprops3[] = {0x58, 0xdb}; - uint8_t bytesprops4[] = {0x56, 0x4a, 0x5, 0xa7, 0xf3, 0x7d, 0xf4, 0x5c, 0xcc, 0x6b, 0x9e, 0x7d, 0x43, 0x4f, 0x1e, - 0x67, 0xce, 0x24, 0x8f, 0xdc, 0xb4, 0x45, 0xb8, 0xb0, 0xea, 0xae, 0x83, 0xc7, 0xb4}; - uint8_t bytesprops5[] = {0xc8, 0x38, 0xfb, 0x65, 0xcd, 0xba, 0x76, 0x16, 0x66, 0x80, 0xe3, 0x16, 0x38, 0x8d}; - uint8_t bytesprops6[] = {0x99, 0x55, 0xa3, 0xad, 0xea, 0x4a, 0xf3, 0xbc, 0x32, 0x63, 0x96, 0xe9}; + uint8_t bytesprops1[] = {0xcd, 0x3e, 0x6b, 0x40, 0xe7, 0xb6, 0x7a, 0x25, 0x9f, 0x23, 0x1a, 0xe6, 0x0}; + uint8_t bytesprops0[] = {0xca, 0xed, 0x63, 0xb, 0xda, 0x53, 0x64, 0x13, 0x70, 0xd6, 0x89, 0x2f, 0x72, 0x80, 0xbc, + 0x30, 0x73, 0x42, 0x0, 0x35, 0x22, 0x8a, 0xce, 0x26, 0x73, 0x3d, 0x8c, 0x9d, 0x41, 0x23}; + uint8_t bytesprops2[] = {0x61, 0x81, 0xb2, 0x84, 0x3f, 0x85, 0xba, 0xb, 0x72, + 0x6f, 0x2f, 0xfe, 0xb8, 0x62, 0x34, 0x94, 0x8b}; + uint8_t bytesprops3[] = {0x5c, 0xce}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {25, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10312}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7697}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 226}}, {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16471}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28347}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11503}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x36}; + uint8_t byteswillprops0[] = {0x82, 0xf1, 0xc5, 0x28, 0xbe, 0xae, 0xa1, 0x21, 0x3e, 0xef, 0xab, 0xa0, 0x43, 0x86}; + uint8_t byteswillprops1[] = {0x9a, 0xc5, 0x59, 0x89, 0xfe, 0x14, 0x95, 0x24, 0x1d, 0xea, 0x35, 0xe3, 0x61, + 0x2c, 0x12, 0xa1, 0x5b, 0x57, 0xc7, 0x7b, 0x48, 0xcf, 0xeb, 0x4d, 0x4a, 0x9a}; + uint8_t byteswillprops2[] = {0xd8, 0x41, 0x1, 0x1f, 0x84, 0x65, 0x40, 0x53}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 253}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12369}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31321}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3735}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27865}}, }; - lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb7, 0x1c, 0x11, 0x84, 0xb6, 0x6a, 0x6d, 0x46, - 0x48, 0x1d, 0xc9, 0x8d, 0xe2, 0x33, 0xa}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x86, 0xcc, 0x1c, 0x7b, 0x97, 0xce, 0x62, 0xbe, 0x65, 0xb1, - 0x95, 0xb, 0x92, 0xb6, 0xf0, 0xc5, 0xbd, 0x4e, 0x4e, 0xb7, - 0xf2, 0xcf, 0x5c, 0x42, 0x4d, 0xc, 0x73, 0xc6, 0x48}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x81, 0xf2, 0xfa, 0xfb, 0xdc, 0xd6, 0xf2, 0x4, 0x78, 0xb4, 0xb, 0x34, 0x48, 0x9c, + 0x77, 0x8b, 0xf7, 0x7a, 0x52, 0xc7, 0x75, 0xac, 0x72, 0x88, 0x9b, 0xc6, 0x1a}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa6, 0x56, 0xd8, 0x1d, 0x87, 0x42, 0x14, 0xdf, 0xb1, 0x95, 0xdf, 0xc3, 0xb2, + 0x0, 0x10, 0x52, 0xce, 0x2f, 0x51, 0x27, 0x4f, 0x80, 0x2d, 0x4, 0x86}; + lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 13514; - uint8_t client_id_bytes[] = {0xa1, 0x20, 0x95, 0xf4, 0xe2, 0xf2, 0xd9, 0x8b, 0x49, 0x20, 0x70, 0xea, - 0x22, 0xf9, 0x10, 0xd8, 0x3e, 0x70, 0xe, 0x56, 0x18, 0xcf, 0x83}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 12650; + uint8_t client_id_bytes[] = {0xb4, 0x4e, 0xa5}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x5, 0xb1, 0xf8, 0x96, 0xea, 0x1f, 0x84, 0xf6, 0x71}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x7c, 0xec, 0x72, 0xfc, 0x30, 0x4b, 0x75, 0x7b, 0x92, + 0x3, 0x6, 0x6d, 0xb2, 0x86, 0xc1, 0x50, 0x1a}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x6d, 0x59, 0x6f, 0x84, 0x90, 0x83, 0x96, 0x27, + 0xce, 0x6c, 0x43, 0x7b, 0x9d, 0x9f, 0xae, 0x3}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9748,327 +9718,167 @@ TEST(Connect5QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\218r\168\139R\217\209\a@\135\239\135\152\130\140\156\230\152>\156\160", _password -// = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\220\218\137\179z\158\vc\CAN\128\SUBU\DC3\175n\201P\218B", _willMsg = -// "\218\174\233=\151\&7\204\204\181\t\146\180O\189\173.`\244\151\180I@0\252", _willProps = [PropServerReference -// "\185+\ACKp,\DC348\155\178'\197\r\252[\191\ENQ",PropMessageExpiryInterval 16461,PropWillDelayInterval -// 14555,PropSharedSubscriptionAvailable 229,PropServerReference "",PropRequestResponseInformation -// 34,PropSubscriptionIdentifier 24,PropMessageExpiryInterval 1953,PropTopicAlias 5336,PropSubscriptionIdentifier -// 24,PropServerKeepAlive 13981,PropAuthenticationMethod -// "-K\136\175O\234\SOH\137\NAK\188\205\GSZ\214\132\148\198\227Xw\a1,\ETX\EOT#V$",PropSubscriptionIdentifierAvailable -// 56,PropReceiveMaximum 13755,PropAssignedClientIdentifier "bf7",PropReceiveMaximum -// 20468,PropRequestResponseInformation 110,PropContentType "\153\153",PropReasonString -// "#\SYNo\149\211",PropUserProperty "\RS8\192;E\232J\nye8\238:\153\183\178\137\NAK\238\147\207\CAN\192" -// "(\235\218\154b",PropRequestResponseInformation 211,PropRetainAvailable 23,PropPayloadFormatIndicator -// 148,PropCorrelationData "\161\132\186I\178'9\205lh}\144\187\249\NUL\177M\STX -// \RS\n\154\159SNY\188C\194#",PropAuthenticationData -// "\214\253\205\207\250\155\157\148\190\226/S\156\220\235q\233\SUBA\v\180$\FS\221\ESC\165",PropMaximumQoS -// 187,PropSessionExpiryInterval 14562,PropSubscriptionIdentifierAvailable 242,PropReceiveMaximum 292,PropResponseTopic -// "\129\155\197zP\186\229\156\180\132\&3\FS)\156\179\213q=,\n"]}), _cleanSession = True, _keepAlive = 5227, _connID = -// "_\201\&2\202<\161\171\209\244\241\165", _properties = [PropTopicAliasMaximum 16149,PropTopicAliasMaximum -// 24850,PropResponseInformation "\131\163\236\190\&3'\193\233\141\150M>\205",PropReceiveMaximum -// 31161,PropSessionExpiryInterval 25873,PropSessionExpiryInterval 27557,PropWillDelayInterval -// 14599,PropAuthenticationMethod "\170\130\148\203\162I\210\177z\150X",PropWildcardSubscriptionAvailable -// 242,PropCorrelationData "P^\237\248",PropTopicAlias 11716,PropWillDelayInterval 10255,PropAuthenticationMethod -// "\202\255\154\170\175\187\151\&2\145MT\131\NAK\SOH\227\EOTQ\NAK\160\237?L\245",PropCorrelationData -// "\152\218\"\206\241\224U\129>",PropSessionExpiryInterval 23109,PropWildcardSubscriptionAvailable -// 229,PropPayloadFormatIndicator 181,PropServerKeepAlive 21011,PropReceiveMaximum 7128,PropServerReference -// "\179v\181\158T\217i",PropMaximumPacketSize 17720,PropMessageExpiryInterval 5161,PropSharedSubscriptionAvailable -// 116,PropAssignedClientIdentifier "\DC2J\130\&2@\201s\172u)R\175"]} +// ConnectRequest {_username = Just "\176\SUB(", _password = Nothing, _lastWill = Nothing, _cleanSession = False, +// _keepAlive = 9985, _connID = "\144\&3\142\215M", _properties = [PropServerKeepAlive +// 12899,PropSharedSubscriptionAvailable 49,PropWillDelayInterval 12770,PropAuthenticationData +// "\209\&7\252\240\163X\180\180\245\147\153aL\134",PropWillDelayInterval 18290,PropRequestResponseInformation +// 60,PropRetainAvailable 253,PropWildcardSubscriptionAvailable 210,PropServerReference +// "\155\210\197\197?G\144",PropUserProperty "\ETB\188\RS\161\131\184\GS\189\223A/\202\178\153\145\190" +// "\253\195Wp\178\130[\195v\t\136\225-\168s\141P\177\210\n{\ETXF\EMqX\192\139",PropReasonString +// "\ETB\188\170_\NAK\246\216\237h\187\231\v\231.\226vs2\150]\171",PropSharedSubscriptionAvailable +// 198,PropAssignedClientIdentifier +// "\r\146{|\130>@\252'\b\219\184\153\232O\248\196\EMv.\204\166\133",PropSessionExpiryInterval +// 10846,PropRequestResponseInformation 221]} TEST(Connect5QCTest, Encode28) { - uint8_t pkt[] = { - 0x10, 0xfa, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xae, 0x14, 0x6b, 0xa1, 0x1, 0x22, 0x3f, 0x15, 0x22, - 0x61, 0x12, 0x1a, 0x0, 0xd, 0x83, 0xa3, 0xec, 0xbe, 0x33, 0x27, 0xc1, 0xe9, 0x8d, 0x96, 0x4d, 0x3e, 0xcd, 0x21, - 0x79, 0xb9, 0x11, 0x0, 0x0, 0x65, 0x11, 0x11, 0x0, 0x0, 0x6b, 0xa5, 0x18, 0x0, 0x0, 0x39, 0x7, 0x15, 0x0, - 0xb, 0xaa, 0x82, 0x94, 0xcb, 0xa2, 0x49, 0xd2, 0xb1, 0x7a, 0x96, 0x58, 0x28, 0xf2, 0x9, 0x0, 0x4, 0x50, 0x5e, - 0xed, 0xf8, 0x23, 0x2d, 0xc4, 0x18, 0x0, 0x0, 0x28, 0xf, 0x15, 0x0, 0x17, 0xca, 0xff, 0x9a, 0xaa, 0xaf, 0xbb, - 0x97, 0x32, 0x91, 0x4d, 0x54, 0x83, 0x15, 0x1, 0xe3, 0x4, 0x51, 0x15, 0xa0, 0xed, 0x3f, 0x4c, 0xf5, 0x9, 0x0, - 0x9, 0x98, 0xda, 0x22, 0xce, 0xf1, 0xe0, 0x55, 0x81, 0x3e, 0x11, 0x0, 0x0, 0x5a, 0x45, 0x28, 0xe5, 0x1, 0xb5, - 0x13, 0x52, 0x13, 0x21, 0x1b, 0xd8, 0x1c, 0x0, 0x7, 0xb3, 0x76, 0xb5, 0x9e, 0x54, 0xd9, 0x69, 0x27, 0x0, 0x0, - 0x45, 0x38, 0x2, 0x0, 0x0, 0x14, 0x29, 0x2a, 0x74, 0x12, 0x0, 0xc, 0x12, 0x4a, 0x82, 0x32, 0x40, 0xc9, 0x73, - 0xac, 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4, 0xf5, 0x93, 0x99, 0x61, 0x4c, 0x86, 0x18, 0x0, 0x0, 0x47, 0x72, 0x19, 0x3c, 0x25, 0xfd, + 0x28, 0xd2, 0x1c, 0x0, 0x7, 0x9b, 0xd2, 0xc5, 0xc5, 0x3f, 0x47, 0x90, 0x26, 0x0, 0x10, 0x17, 0xbc, + 0x1e, 0xa1, 0x83, 0xb8, 0x1d, 0xbd, 0xdf, 0x41, 0x2f, 0xca, 0xb2, 0x99, 0x91, 0xbe, 0x0, 0x1c, 0xfd, + 0xc3, 0x57, 0x70, 0xb2, 0x82, 0x5b, 0xc3, 0x76, 0x9, 0x88, 0xe1, 0x2d, 0xa8, 0x73, 0x8d, 0x50, 0xb1, + 0xd2, 0xa, 0x7b, 0x3, 0x46, 0x19, 0x71, 0x58, 0xc0, 0x8b, 0x1f, 0x0, 0x15, 0x17, 0xbc, 0xaa, 0x5f, + 0x15, 0xf6, 0xd8, 0xed, 0x68, 0xbb, 0xe7, 0xb, 0xe7, 0x2e, 0xe2, 0x76, 0x73, 0x32, 0x96, 0x5d, 0xab, + 0x2a, 0xc6, 0x12, 0x0, 0x17, 0xd, 0x92, 0x7b, 0x7c, 0x82, 0x3e, 0x40, 0xfc, 0x27, 0x8, 0xdb, 0xb8, + 0x99, 0xe8, 0x4f, 0xf8, 0xc4, 0x19, 0x76, 0x2e, 0xcc, 0xa6, 0x85, 0x11, 0x0, 0x0, 0x2a, 0x5e, 0x19, + 0xdd, 0x0, 0x5, 0x90, 0x33, 0x8e, 0xd7, 0x4d, 0x0, 0x3, 0xb0, 0x1a, 0x28}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x83, 0xa3, 0xec, 0xbe, 0x33, 0x27, 0xc1, 0xe9, 0x8d, 0x96, 0x4d, 0x3e, 0xcd}; - uint8_t bytesprops1[] = {0xaa, 0x82, 0x94, 0xcb, 0xa2, 0x49, 0xd2, 0xb1, 0x7a, 0x96, 0x58}; - uint8_t bytesprops2[] = {0x50, 0x5e, 0xed, 0xf8}; - uint8_t bytesprops3[] = {0xca, 0xff, 0x9a, 0xaa, 0xaf, 0xbb, 0x97, 0x32, 0x91, 0x4d, 0x54, 0x83, - 0x15, 0x1, 0xe3, 0x4, 0x51, 0x15, 0xa0, 0xed, 0x3f, 0x4c, 0xf5}; - uint8_t bytesprops4[] = {0x98, 0xda, 0x22, 0xce, 0xf1, 0xe0, 0x55, 0x81, 0x3e}; - uint8_t bytesprops5[] = {0xb3, 0x76, 0xb5, 0x9e, 0x54, 0xd9, 0x69}; - uint8_t bytesprops6[] = {0x12, 0x4a, 0x82, 0x32, 0x40, 0xc9, 0x73, 0xac, 0x75, 0x29, 0x52, 0xaf}; + uint8_t bytesprops0[] = {0xd1, 0x37, 0xfc, 0xf0, 0xa3, 0x58, 0xb4, 0xb4, 0xf5, 0x93, 0x99, 0x61, 0x4c, 0x86}; + uint8_t bytesprops1[] = {0x9b, 0xd2, 0xc5, 0xc5, 0x3f, 0x47, 0x90}; + uint8_t bytesprops3[] = {0xfd, 0xc3, 0x57, 0x70, 0xb2, 0x82, 0x5b, 0xc3, 0x76, 0x9, 0x88, 0xe1, 0x2d, 0xa8, + 0x73, 0x8d, 0x50, 0xb1, 0xd2, 0xa, 0x7b, 0x3, 0x46, 0x19, 0x71, 0x58, 0xc0, 0x8b}; + uint8_t bytesprops2[] = {0x17, 0xbc, 0x1e, 0xa1, 0x83, 0xb8, 0x1d, 0xbd, + 0xdf, 0x41, 0x2f, 0xca, 0xb2, 0x99, 0x91, 0xbe}; + uint8_t bytesprops4[] = {0x17, 0xbc, 0xaa, 0x5f, 0x15, 0xf6, 0xd8, 0xed, 0x68, 0xbb, 0xe7, + 0xb, 0xe7, 0x2e, 0xe2, 0x76, 0x73, 0x32, 0x96, 0x5d, 0xab}; + uint8_t bytesprops5[] = {0xd, 0x92, 0x7b, 0x7c, 0x82, 0x3e, 0x40, 0xfc, 0x27, 0x8, 0xdb, 0xb8, + 0x99, 0xe8, 0x4f, 0xf8, 0xc4, 0x19, 0x76, 0x2e, 0xcc, 0xa6, 0x85}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16149}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24850}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31161}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25873}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27557}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14599}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11716}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10255}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23109}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21011}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7128}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17720}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5161}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops6}}}, - }; - - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xb9, 0x2b, 0x6, 0x70, 0x2c, 0x13, 0x34, 0x38, 0x9b, - 0xb2, 0x27, 0xc5, 0xd, 0xfc, 0x5b, 0xbf, 0x5}; - uint8_t byteswillprops1[] = {0}; - uint8_t byteswillprops2[] = {0x2d, 0x4b, 0x88, 0xaf, 0x4f, 0xea, 0x1, 0x89, 0x15, 0xbc, 0xcd, 0x1d, 0x5a, 0xd6, - 0x84, 0x94, 0xc6, 0xe3, 0x58, 0x77, 0x7, 0x31, 0x2c, 0x3, 0x4, 0x23, 0x56, 0x24}; - uint8_t byteswillprops3[] = {0x62, 0x66, 0x37}; - uint8_t byteswillprops4[] = {0x99, 0x99}; - uint8_t byteswillprops5[] = {0x23, 0x16, 0x6f, 0x95, 0xd3}; - uint8_t byteswillprops7[] = {0x28, 0xeb, 0xda, 0x9a, 0x62}; - uint8_t byteswillprops6[] = {0x1e, 0x38, 0xc0, 0x3b, 0x45, 0xe8, 0x4a, 0xa, 0x79, 0x65, 0x38, 0xee, - 0x3a, 0x99, 0xb7, 0xb2, 0x89, 0x15, 0xee, 0x93, 0xcf, 0x18, 0xc0}; - uint8_t byteswillprops8[] = {0xa1, 0x84, 0xba, 0x49, 0xb2, 0x27, 0x39, 0xcd, 0x6c, 0x68, - 0x7d, 0x90, 0xbb, 0xf9, 0x0, 0xb1, 0x4d, 0x2, 0x20, 0x1e, - 0xa, 0x9a, 0x9f, 0x53, 0x4e, 0x59, 0xbc, 0x43, 0xc2, 0x23}; - uint8_t byteswillprops9[] = {0xd6, 0xfd, 0xcd, 0xcf, 0xfa, 0x9b, 0x9d, 0x94, 0xbe, 0xe2, 0x2f, 0x53, 0x9c, - 0xdc, 0xeb, 0x71, 0xe9, 0x1a, 0x41, 0xb, 0xb4, 0x24, 0x1c, 0xdd, 0x1b, 0xa5}; - uint8_t byteswillprops10[] = {0x81, 0x9b, 0xc5, 0x7a, 0x50, 0xba, 0xe5, 0x9c, 0xb4, 0x84, - 0x33, 0x1c, 0x29, 0x9c, 0xb3, 0xd5, 0x71, 0x3d, 0x2c, 0xa}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16461}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14555}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1953}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5336}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 24}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13981}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13755}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20468}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {23, (char*)&byteswillprops6}, .v = {5, (char*)&byteswillprops7}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14562}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 292}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12899}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12770}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18290}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops2}, .v = {28, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10846}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 221}}, }; - lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xdc, 0xda, 0x89, 0xb3, 0x7a, 0x9e, 0xb, 0x63, 0x18, 0x80, - 0x1a, 0x55, 0x13, 0xaf, 0x6e, 0xc9, 0x50, 0xda, 0x42}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xda, 0xae, 0xe9, 0x3d, 0x97, 0x37, 0xcc, 0xcc, 0xb5, 0x9, 0x92, 0xb4, - 0x4f, 0xbd, 0xad, 0x2e, 0x60, 0xf4, 0x97, 0xb4, 0x49, 0x40, 0x30, 0xfc}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 5227; - uint8_t client_id_bytes[] = {0x5f, 0xc9, 0x32, 0xca, 0x3c, 0xa1, 0xab, 0xd1, 0xf4, 0xf1, 0xa5}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 9985; + uint8_t client_id_bytes[] = {0x90, 0x33, 0x8e, 0xd7, 0x4d}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xda, 0x72, 0xa8, 0x8b, 0x52, 0xd9, 0xd1, 0x7, 0x40, 0x87, 0xef, - 0x87, 0x98, 0x82, 0x8c, 0x9c, 0xe6, 0x98, 0x3e, 0x9c, 0xa0}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xb0, 0x1a, 0x28}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\SO\"\229\f\229\n\211x\145\nR\255A\196y\255",PropAuthenticationMethod -// "\134\243\201\207\246x\240\RS\194P\GS\FSl\217\188\154\143\180\242$\139\197\173\210\233\b\179\134\138",PropResponseInformation -// "N#\153\&4OL\131\149y\145\216\&7"]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS2, _willTopic = "3\ENQ\159tA", _willMsg = "\253\&0\175\230\149U\228\219\161nq\159m\NAK", _willProps = +// [PropAuthenticationMethod "\159",PropSharedSubscriptionAvailable 237,PropMessageExpiryInterval +// 8765,PropSessionExpiryInterval 16121,PropAuthenticationData +// "\191\145\"\n\135\238O:l$8mT\255d\160\176\r\154A\SYN\254\131\219\243\172\182\179\169",PropReceiveMaximum +// 18457,PropServerKeepAlive 6360,PropServerReference ",\178\b\130<\221\195\152\220",PropReceiveMaximum 9970]}), +// _cleanSession = True, _keepAlive = 2853, _connID = "\223k\158\244\196\196\240\228\&8\134\t*", _properties = +// [PropTopicAliasMaximum 26453,PropRequestProblemInformation 200,PropWillDelayInterval 17617,PropResponseInformation +// "\DC4\130\208\233\165x;\179\SUB\v\183\146\245\167,}\254\202<\157",PropReceiveMaximum 2414,PropTopicAliasMaximum +// 7212,PropRequestResponseInformation 231,PropSubscriptionIdentifier 11,PropUserProperty "\tn\ESCq\tw" +// "`Q\240$\189\&5\209\214\172\FS\t\r\128\203\167O\DC3\202",PropRequestResponseInformation 6,PropUserProperty +// "\163\139\\Mi\144q" +// "\147\164Tv\195\SOH\208\FS\241Rq\158\&1\f\187\160B\225\141\230\253\189\a\EOT",PropPayloadFormatIndicator 31]} TEST(Connect5QCTest, Encode29) { - uint8_t pkt[] = { - 0x10, 0xb1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0xa, 0x6, 0xe8, 0x1, 0x1, 0x62, 0x9, 0x0, - 0x9, 0xb7, 0x2c, 0xe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0x9f, 0x2a, 0xed, 0x2, 0x0, 0x0, 0x22, 0x3d, 0x11, + 0x0, 0x0, 0x3e, 0xf9, 0x16, 0x0, 0x1d, 0xbf, 0x91, 0x22, 0xa, 0x87, 0xee, 0x4f, 0x3a, 0x6c, 0x24, + 0x38, 0x6d, 0x54, 0xff, 0x64, 0xa0, 0xb0, 0xd, 0x9a, 0x41, 0x16, 0xfe, 0x83, 0xdb, 0xf3, 0xac, 0xb6, + 0xb3, 0xa9, 0x21, 0x48, 0x19, 0x13, 0x18, 0xd8, 0x1c, 0x0, 0x9, 0x2c, 0xb2, 0x8, 0x82, 0x3c, 0xdd, + 0xc3, 0x98, 0xdc, 0x21, 0x26, 0xf2, 0x0, 0x5, 0x33, 0x5, 0x9f, 0x74, 0x41, 0x0, 0xe, 0xfd, 0x30, + 0xaf, 0xe6, 0x95, 0x55, 0xe4, 0xdb, 0xa1, 0x6e, 0x71, 0x9f, 0x6d, 0x15}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb7, 0x2c, 0xe3, 0x2f, 0x47, 0x1, 0xb8, 0x63, 0x2b}; - uint8_t bytesprops1[] = {0x31, 0x6e, 0x3c, 0x84, 0x11, 0x69, 0x87, 0x6a}; - uint8_t bytesprops2[] = {0x75, 0x55}; - uint8_t bytesprops3[] = {0xd0, 0xa8, 0xff, 0x3c, 0xe2, 0x7a, 0x66, 0xf7}; - uint8_t bytesprops4[] = {0x5f, 0x61, 0x89, 0x80, 0xce, 0x21, 0x7e, 0xd7, 0x4c, 0x46, 0x38, - 0xe5, 0xd7, 0x82, 0x6a, 0x6b, 0xa5, 0x93, 0x2a, 0x5a, 0xfd, 0xb5}; - uint8_t bytesprops5[] = {0x24, 0xd3, 0xa7, 0xfd, 0xe6, 0x25, 0x2b, 0x63, 0x50, 0xd0, 0x84, - 0x91, 0xed, 0x6b, 0xb5, 0x71, 0xe8, 0xb0, 0x40, 0xde, 0xa5, 0x71}; - uint8_t bytesprops6[] = {0x3a, 0xcc, 0x8b, 0xc6, 0x8d, 0x52, 0x6e, 0x6d, 0x6e, 0x5d, 0x53, 0xaf, - 0x8d, 0x8e, 0xcc, 0x12, 0x29, 0x85, 0xc8, 0x54, 0xee, 0x15, 0xb4, 0x2d}; - uint8_t bytesprops7[] = {0xe7, 0x4f, 0x3a, 0x3, 0x8c}; - uint8_t bytesprops8[] = {0xfa, 0x48, 0x1, 0xa5, 0x39, 0x13}; - uint8_t bytesprops9[] = {0xef, 0x31, 0xe7, 0x7, 0xa5, 0xb7, 0xa, 0xc4, 0x5a, - 0xf7, 0x84, 0x3c, 0x69, 0x66, 0x8e, 0x95, 0xd}; - uint8_t bytesprops10[] = {0xb9, 0x6e, 0x83, 0x36, 0xd9, 0x20, 0x0, 0x3e}; - uint8_t bytesprops11[] = {0x86, 0xf3, 0xc9, 0xcf, 0xf6, 0x78, 0xf0, 0x1e, 0xc2, 0x50, 0x1d, 0x1c, 0x6c, 0xd9, 0xbc, - 0x9a, 0x8f, 0xb4, 0xf2, 0x24, 0x8b, 0xc5, 0xad, 0xd2, 0xe9, 0x8, 0xb3, 0x86, 0x8a}; - uint8_t bytesprops12[] = {0x4e, 0x23, 0x99, 0x34, 0x4f, 0x4c, 0x83, 0x95, 0x79, 0x91, 0xd8, 0x37}; + uint8_t bytesprops0[] = {0x14, 0x82, 0xd0, 0xe9, 0xa5, 0x78, 0x3b, 0xb3, 0x1a, 0xb, + 0xb7, 0x92, 0xf5, 0xa7, 0x2c, 0x7d, 0xfe, 0xca, 0x3c, 0x9d}; + uint8_t bytesprops2[] = {0x60, 0x51, 0xf0, 0x24, 0xbd, 0x35, 0xd1, 0xd6, 0xac, + 0x1c, 0x9, 0xd, 0x80, 0xcb, 0xa7, 0x4f, 0x13, 0xca}; + uint8_t bytesprops1[] = {0x9, 0x6e, 0x1b, 0x71, 0x9, 0x77}; + uint8_t bytesprops4[] = {0x93, 0xa4, 0x54, 0x76, 0xc3, 0x1, 0xd0, 0x1c, 0xf1, 0x52, 0x71, 0x9e, + 0x31, 0xc, 0xbb, 0xa0, 0x42, 0xe1, 0x8d, 0xe6, 0xfd, 0xbd, 0x7, 0x4}; + uint8_t bytesprops3[] = {0xa3, 0x8b, 0x5c, 0x4d, 0x69, 0x90, 0x71}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13835}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21997}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19719}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26453}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17617}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2414}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7212}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {24, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 31}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xdc, 0xd5}; - uint8_t byteswillprops0[] = {0x82, 0xe4, 0x70, 0xf3, 0x42, 0xb0, 0x47, 0x53, 0xc2, 0x4d, - 0xed, 0xa1, 0x76, 0x1e, 0x4e, 0xc1, 0x96, 0xe6, 0xfb, 0x2f}; - uint8_t byteswillprops2[] = {0xad, 0x34, 0x8f, 0x6c, 0x2f, 0xe6, 0xe3, 0x3c, 0x32, 0xf9, 0xfb, 0x7e, 0x2a, - 0x4e, 0x2e, 0xa3, 0x6a, 0xfa, 0x24, 0x6f, 0x3c, 0x4b, 0x24, 0x3a, 0x8c}; + uint8_t byteswillprops0[] = {0x9f}; + uint8_t byteswillprops1[] = {0xbf, 0x91, 0x22, 0xa, 0x87, 0xee, 0x4f, 0x3a, 0x6c, 0x24, 0x38, 0x6d, 0x54, 0xff, 0x64, + 0xa0, 0xb0, 0xd, 0x9a, 0x41, 0x16, 0xfe, 0x83, 0xdb, 0xf3, 0xac, 0xb6, 0xb3, 0xa9}; + uint8_t byteswillprops2[] = {0x2c, 0xb2, 0x8, 0x82, 0x3c, 0xdd, 0xc3, 0x98, 0xdc}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14298}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28032}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {20, (char*)&byteswillprops0}, .v = {2, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17757}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17105}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13584}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22665}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 28}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8765}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16121}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18457}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6360}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9970}}, }; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x47, 0x4e, 0x8a, 0x55, 0x28, 0x1d, 0xe6, 0xf, - 0x2b, 0x58, 0x21, 0x54, 0x75, 0xd5, 0xbe}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x2d, 0xfe, 0xb1, 0x51, 0x8a, 0x57}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x33, 0x5, 0x9f, 0x74, 0x41}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfd, 0x30, 0xaf, 0xe6, 0x95, 0x55, 0xe4, 0xdb, 0xa1, 0x6e, 0x71, 0x9f, 0x6d, 0x15}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 2566; - uint8_t client_id_bytes[] = {0x45, 0x16, 0x7d, 0xe1, 0x3a, 0x75, 0x52, 0x47, 0xd5, 0x25, 0xcd, - 0x77, 0xbf, 0x7a, 0x46, 0x64, 0x97, 0x72, 0x9d, 0x6, 0xdb}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.keep_alive = 2853; + uint8_t client_id_bytes[] = {0xdf, 0x6b, 0x9e, 0xf4, 0xc4, 0xc4, 0xf0, 0xe4, 0x38, 0x86, 0x9, 0x2a}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xe, 0x22, 0xe5, 0xc, 0xe5, 0xa, 0xd3, 0x78, 0x91, 0xa, 0x52, - 0xff, 0x41, 0xc4, 0x79, 0xff, 0x3c, 0x54, 0x5b, 0x95, 0x3}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xa1, 0x27, 0xf1, 0xab, 0x32, 0x22, 0x71, 0xaa, 0xa5, 0x8b, 0xe9, - 0xf8, 0x9c, 0x74, 0xf4, 0x9e, 0xe7, 0xe9, 0x86, 0x71, 0x4e, 0x43}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10077,89 +9887,110 @@ TEST(Connect5QCTest, Encode29) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\152\221\234q\203G\217\fNt\228\210\150\136\182i)\202\138\152\231\173\145\214", -// _password = Just "'\180\139\198S@\216", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic -// = "8c-\209\158\&6\143C\DC4\218\154\186y\201\RS\157N\158z\179p!i\176B\133]\193\202\DC1", _willMsg = -// "\161kV;\231\200\136\195\SI", _willProps = [PropTopicAliasMaximum 7867,PropContentType -// "\131\192\204\245\195\230\148\171g\163\197Jbk[S",PropServerReference -// "n\165\CAN`\132\210\194\f\"G\f\239",PropWillDelayInterval 20782,PropUserProperty -// "\FS`\208\217}+g\aC2=\210l\r\ENQ\218\241\EOT\129b\SOH\198\143\&6" -// "\248\227\174{\166\130\133a\DC4\203",PropRetainAvailable 100]}), _cleanSession = True, _keepAlive = 23001, _connID = -// "O\245i\ESC", _properties = [PropServerReference "\180\SOH)",PropReceiveMaximum 29954,PropMessageExpiryInterval -// 22203,PropRequestProblemInformation 106,PropSessionExpiryInterval 18514,PropWillDelayInterval -// 23155,PropRequestResponseInformation 130,PropWildcardSubscriptionAvailable 7]} +// ConnectRequest {_username = Just "\"", _password = Just "\223>\255\222\&1+\192nU\183\230", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\b)e\236\251\251F\231*\144\171\179\130", _willMsg = +// "\224$\244h\238M\173a\166,{\149\167\153\201{\142.\175\&3A=\249\214\DC1\254oO\186", _willProps = +// [PropMessageExpiryInterval 10851,PropMessageExpiryInterval 30029,PropAuthenticationMethod +// "\SYN}\183n\181\198\138\&7@\146&\136\n\160Q\254\130\ACK\139\RS>\170G\166uc3+|\147",PropMaximumQoS +// 49,PropResponseInformation "3\232\160\231\154\143bE`l\193N",PropResponseTopic "\223\v$\227\161\185eK\135\DEL\182 +// $3\200~[",PropCorrelationData "\192\230\179\&08\196W\182\179\164w\182\151\DC3)",PropRequestResponseInformation +// 191,PropWillDelayInterval 16685,PropTopicAliasMaximum 10583,PropWildcardSubscriptionAvailable 161,PropReceiveMaximum +// 1963,PropContentType "\162\SI\"M\\-.\233\ETB\EM\133\185\136\230\&4\DC1W}l\187\209",PropAuthenticationData +// "\236\250\138P\198\129PP\ESC",PropReceiveMaximum 6355]}), _cleanSession = False, _keepAlive = 26056, _connID = +// "c\EM'\202qq<\213", _properties = [PropContentType "{\213\150S\SI\146h1\143",PropSessionExpiryInterval +// 9151,PropMaximumQoS 249,PropSubscriptionIdentifier 0,PropMessageExpiryInterval 6763,PropRequestProblemInformation +// 17,PropSubscriptionIdentifier 5,PropWillDelayInterval 10472,PropMessageExpiryInterval 3487,PropCorrelationData +// "\212"]} TEST(Connect5QCTest, Encode30) { - uint8_t pkt[] = {0x10, 0xd1, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x59, 0xd9, 0x1e, 0x1c, 0x0, 0x3, - 0xb4, 0x1, 0x29, 0x21, 0x75, 0x2, 0x2, 0x0, 0x0, 0x56, 0xbb, 0x17, 0x6a, 0x11, 0x0, 0x0, 0x48, - 0x52, 0x18, 0x0, 0x0, 0x5a, 0x73, 0x19, 0x82, 0x28, 0x7, 0x0, 0x4,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, 0x16, 0x0, + 0x9, 0xec, 0xfa, 0x8a, 0x50, 0xc6, 0x81, 0x50, 0x50, 0x1b, 0x21, 0x18, 0xd3, 0x0, 0xd, 0x8, 0x29, 0x65, 0xec, + 0xfb, 0xfb, 0x46, 0xe7, 0x2a, 0x90, 0xab, 0xb3, 0x82, 0x0, 0x1d, 0xe0, 0x24, 0xf4, 0x68, 0xee, 0x4d, 0xad, 0x61, + 0xa6, 0x2c, 0x7b, 0x95, 0xa7, 0x99, 0xc9, 0x7b, 0x8e, 0x2e, 0xaf, 0x33, 0x41, 0x3d, 0xf9, 0xd6, 0x11, 0xfe, 0x6f, + 0x4f, 0xba, 0x0, 0x1, 0x22, 0x0, 0xb, 0xdf, 0x3e, 0xff, 0xde, 0x31, 0x2b, 0xc0, 0x6e, 0x55, 0xb7, 0xe6}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb4, 0x1, 0x29}; + uint8_t bytesprops0[] = {0x7b, 0xd5, 0x96, 0x53, 0xf, 0x92, 0x68, 0x31, 0x8f}; + uint8_t bytesprops1[] = {0xd4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29954}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22203}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18514}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23155}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9151}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6763}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10472}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3487}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x83, 0xc0, 0xcc, 0xf5, 0xc3, 0xe6, 0x94, 0xab, - 0x67, 0xa3, 0xc5, 0x4a, 0x62, 0x6b, 0x5b, 0x53}; - uint8_t byteswillprops1[] = {0x6e, 0xa5, 0x18, 0x60, 0x84, 0xd2, 0xc2, 0xc, 0x22, 0x47, 0xc, 0xef}; - uint8_t byteswillprops3[] = {0xf8, 0xe3, 0xae, 0x7b, 0xa6, 0x82, 0x85, 0x61, 0x14, 0xcb}; - uint8_t byteswillprops2[] = {0x1c, 0x60, 0xd0, 0xd9, 0x7d, 0x2b, 0x67, 0x7, 0x43, 0x32, 0x3d, 0xd2, - 0x6c, 0xd, 0x5, 0xda, 0xf1, 0x4, 0x81, 0x62, 0x1, 0xc6, 0x8f, 0x36}; + uint8_t byteswillprops0[] = {0x16, 0x7d, 0xb7, 0x6e, 0xb5, 0xc6, 0x8a, 0x37, 0x40, 0x92, + 0x26, 0x88, 0xa, 0xa0, 0x51, 0xfe, 0x82, 0x6, 0x8b, 0x1e, + 0x3e, 0xaa, 0x47, 0xa6, 0x75, 0x63, 0x33, 0x2b, 0x7c, 0x93}; + uint8_t byteswillprops1[] = {0x33, 0xe8, 0xa0, 0xe7, 0x9a, 0x8f, 0x62, 0x45, 0x60, 0x6c, 0xc1, 0x4e}; + uint8_t byteswillprops2[] = {0xdf, 0xb, 0x24, 0xe3, 0xa1, 0xb9, 0x65, 0x4b, 0x87, + 0x7f, 0xb6, 0x20, 0x24, 0x33, 0xc8, 0x7e, 0x5b}; + uint8_t byteswillprops3[] = {0xc0, 0xe6, 0xb3, 0x30, 0x38, 0xc4, 0x57, 0xb6, + 0xb3, 0xa4, 0x77, 0xb6, 0x97, 0x13, 0x29}; + uint8_t byteswillprops4[] = {0xa2, 0xf, 0x22, 0x4d, 0x5c, 0x2d, 0x2e, 0xe9, 0x17, 0x19, 0x85, + 0xb9, 0x88, 0xe6, 0x34, 0x11, 0x57, 0x7d, 0x6c, 0xbb, 0xd1}; + uint8_t byteswillprops5[] = {0xec, 0xfa, 0x8a, 0x50, 0xc6, 0x81, 0x50, 0x50, 0x1b}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7867}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20782}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {24, (char*)&byteswillprops2}, .v = {10, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10851}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30029}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16685}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10583}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1963}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6355}}, }; - lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x38, 0x63, 0x2d, 0xd1, 0x9e, 0x36, 0x8f, 0x43, 0x14, 0xda, - 0x9a, 0xba, 0x79, 0xc9, 0x1e, 0x9d, 0x4e, 0x9e, 0x7a, 0xb3, - 0x70, 0x21, 0x69, 0xb0, 0x42, 0x85, 0x5d, 0xc1, 0xca, 0x11}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa1, 0x6b, 0x56, 0x3b, 0xe7, 0xc8, 0x88, 0xc3, 0xf}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8, 0x29, 0x65, 0xec, 0xfb, 0xfb, 0x46, 0xe7, 0x2a, 0x90, 0xab, 0xb3, 0x82}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe0, 0x24, 0xf4, 0x68, 0xee, 0x4d, 0xad, 0x61, 0xa6, 0x2c, + 0x7b, 0x95, 0xa7, 0x99, 0xc9, 0x7b, 0x8e, 0x2e, 0xaf, 0x33, + 0x41, 0x3d, 0xf9, 0xd6, 0x11, 0xfe, 0x6f, 0x4f, 0xba}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 23001; - uint8_t client_id_bytes[] = {0x4f, 0xf5, 0x69, 0x1b}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 26056; + uint8_t client_id_bytes[] = {0x63, 0x19, 0x27, 0xca, 0x71, 0x71, 0x3c, 0xd5}; + lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x98, 0xdd, 0xea, 0x71, 0xcb, 0x47, 0xd9, 0xc, 0x4e, 0x74, 0xe4, 0xd2, - 0x96, 0x88, 0xb6, 0x69, 0x29, 0xca, 0x8a, 0x98, 0xe7, 0xad, 0x91, 0xd6}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x22}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x27, 0xb4, 0x8b, 0xc6, 0x53, 0x40, 0xd8}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xdf, 0x3e, 0xff, 0xde, 0x31, 0x2b, 0xc0, 0x6e, 0x55, 0xb7, 0xe6}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10169,40 +10000,46 @@ TEST(Connect5QCTest, Encode30) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 5047 [("H\129E$_\201\142?\214\245~\170",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\EOT\171",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("|\130\163TL\202",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\147^\181B\US12\255U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\185\DC1\142\241\ENQ\"\ETX",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\139\130\222\tW\SI",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 14771 [("#\200Q\136b\STX\234p\149",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS2}),("\228_\193\193f_2@\169\173\&8\140\194\221c7\ACK|\ESC\249[\"Cm\187\155\170\176",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("#\f&\179\130I\157\181\213\&6fl\DC2\184\SYN\188\175\227&yeI",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\247St\244Y\\m\197\n\f\DC4A\EOT\nmG\183L\SOH\161J\132\a\150\&3\DC3SP\130\194",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("E\169\130\158J\214",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x3e, 0x13, 0xb7, 0x0, 0xc, 0x48, 0x81, 0x45, 0x24, 0x5f, 0xc9, 0x8e, 0x3f, 0xd6, 0xf5, - 0x7e, 0xaa, 0x2, 0x0, 0x2, 0x4, 0xab, 0x0, 0x0, 0x6, 0x7c, 0x82, 0xa3, 0x54, 0x4c, 0xca, - 0x1, 0x0, 0x9, 0x93, 0x5e, 0xb5, 0x42, 0x1f, 0x31, 0x32, 0xff, 0x55, 0x2, 0x0, 0x7, 0xb9, - 0x11, 0x8e, 0xf1, 0x5, 0x22, 0x3, 0x0, 0x0, 0x6, 0x8b, 0x82, 0xde, 0x9, 0x57, 0xf, 0x2}; + uint8_t pkt[] = {0x82, 0x70, 0x39, 0xb3, 0x0, 0x9, 0x23, 0xc8, 0x51, 0x88, 0x62, 0x2, 0xea, 0x70, 0x95, 0x2, 0x0, + 0x1c, 0xe4, 0x5f, 0xc1, 0xc1, 0x66, 0x5f, 0x32, 0x40, 0xa9, 0xad, 0x38, 0x8c, 0xc2, 0xdd, 0x63, 0x37, + 0x6, 0x7c, 0x1b, 0xf9, 0x5b, 0x22, 0x43, 0x6d, 0xbb, 0x9b, 0xaa, 0xb0, 0x0, 0x0, 0x16, 0x23, 0xc, + 0x26, 0xb3, 0x82, 0x49, 0x9d, 0xb5, 0xd5, 0x36, 0x66, 0x6c, 0x12, 0xb8, 0x16, 0xbc, 0xaf, 0xe3, 0x26, + 0x79, 0x65, 0x49, 0x2, 0x0, 0x1e, 0xf7, 0x53, 0x74, 0xf4, 0x59, 0x5c, 0x6d, 0xc5, 0xa, 0xc, 0x14, + 0x41, 0x4, 0xa, 0x6d, 0x47, 0xb7, 0x4c, 0x1, 0xa1, 0x4a, 0x84, 0x7, 0x96, 0x33, 0x13, 0x53, 0x50, + 0x82, 0xc2, 0x0, 0x0, 0x6, 0x45, 0xa9, 0x82, 0x9e, 0x4a, 0xd6, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x48, 0x81, 0x45, 0x24, 0x5f, 0xc9, 0x8e, 0x3f, 0xd6, 0xf5, 0x7e, 0xaa}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x23, 0xc8, 0x51, 0x88, 0x62, 0x2, 0xea, 0x70, 0x95}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4, 0xab}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe4, 0x5f, 0xc1, 0xc1, 0x66, 0x5f, 0x32, 0x40, 0xa9, 0xad, + 0x38, 0x8c, 0xc2, 0xdd, 0x63, 0x37, 0x6, 0x7c, 0x1b, 0xf9, + 0x5b, 0x22, 0x43, 0x6d, 0xbb, 0x9b, 0xaa, 0xb0}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7c, 0x82, 0xa3, 0x54, 0x4c, 0xca}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x23, 0xc, 0x26, 0xb3, 0x82, 0x49, 0x9d, 0xb5, 0xd5, 0x36, 0x66, + 0x6c, 0x12, 0xb8, 0x16, 0xbc, 0xaf, 0xe3, 0x26, 0x79, 0x65, 0x49}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x93, 0x5e, 0xb5, 0x42, 0x1f, 0x31, 0x32, 0xff, 0x55}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf7, 0x53, 0x74, 0xf4, 0x59, 0x5c, 0x6d, 0xc5, 0xa, 0xc, + 0x14, 0x41, 0x4, 0xa, 0x6d, 0x47, 0xb7, 0x4c, 0x1, 0xa1, + 0x4a, 0x84, 0x7, 0x96, 0x33, 0x13, 0x53, 0x50, 0x82, 0xc2}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb9, 0x11, 0x8e, 0xf1, 0x5, 0x22, 0x3}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x45, 0xa9, 0x82, 0x9e, 0x4a, 0xd6}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8b, 0x82, 0xde, 0x9, 0x57, 0xf}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -10211,60 +10048,97 @@ TEST(Subscribe311QCTest, Encode1) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5047, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14771, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3206 [("\DC12^",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS1}),("\184\136",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("$\217\231uJ\220\&4\205\163\&2\171'\203P\ESC\252\228\SOH\202",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 15521 [("`\189\"5\223\186\254\236\DC4y(\SYNn",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("r\ESC\204\199kn\141\&6\182\233~\DC4\158p$\220\NAK\GSm#",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("7m\NUL\DC2c\DC1\250\133",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\RS\\/\203\156\163\252S.\174\177kq\225p\148\163b\249\147e.\EOT\DC2k\206\177",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("/\b\177\207\ENQ\229\157k\212\ng\247\DC3\250K`\202tNp\249\223\135",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\157\187\230\229\224\196T",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\222\n\165\165\169%\204-\NUL\STX\192\143p4\221U",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\234\158xoF\217\SUB\128~\184\v",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\165)n:\242PZ@\244yx\255\DLEf\155\183\r\RSd\207",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0x23, 0xc, 0x86, 0x0, 0x3, 0x11, 0x32, 0x5e, 0x1, 0x0, 0x2, 0xb8, - 0x88, 0x1, 0x0, 0x13, 0x24, 0xd9, 0xe7, 0x75, 0x4a, 0xdc, 0x34, 0xcd, 0xa3, - 0x32, 0xab, 0x27, 0xcb, 0x50, 0x1b, 0xfc, 0xe4, 0x1, 0xca, 0x2}; + uint8_t pkt[] = {0x82, 0xae, 0x1, 0x3c, 0xa1, 0x0, 0xd, 0x60, 0xbd, 0x22, 0x35, 0xdf, 0xba, 0xfe, 0xec, 0x14, 0x79, + 0x28, 0x16, 0x6e, 0x2, 0x0, 0x14, 0x72, 0x1b, 0xcc, 0xc7, 0x6b, 0x6e, 0x8d, 0x36, 0xb6, 0xe9, 0x7e, + 0x14, 0x9e, 0x70, 0x24, 0xdc, 0x15, 0x1d, 0x6d, 0x23, 0x0, 0x0, 0x8, 0x37, 0x6d, 0x0, 0x12, 0x63, + 0x11, 0xfa, 0x85, 0x2, 0x0, 0x1b, 0x1e, 0x5c, 0x2f, 0xcb, 0x9c, 0xa3, 0xfc, 0x53, 0x2e, 0xae, 0xb1, + 0x6b, 0x71, 0xe1, 0x70, 0x94, 0xa3, 0x62, 0xf9, 0x93, 0x65, 0x2e, 0x4, 0x12, 0x6b, 0xce, 0xb1, 0x0, + 0x0, 0x17, 0x2f, 0x8, 0xb1, 0xcf, 0x5, 0xe5, 0x9d, 0x6b, 0xd4, 0xa, 0x67, 0xf7, 0x13, 0xfa, 0x4b, + 0x60, 0xca, 0x74, 0x4e, 0x70, 0xf9, 0xdf, 0x87, 0x1, 0x0, 0x7, 0x9d, 0xbb, 0xe6, 0xe5, 0xe0, 0xc4, + 0x54, 0x2, 0x0, 0x10, 0xde, 0xa, 0xa5, 0xa5, 0xa9, 0x25, 0xcc, 0x2d, 0x0, 0x2, 0xc0, 0x8f, 0x70, + 0x34, 0xdd, 0x55, 0x2, 0x0, 0xb, 0xea, 0x9e, 0x78, 0x6f, 0x46, 0xd9, 0x1a, 0x80, 0x7e, 0xb8, 0xb, + 0x2, 0x0, 0x14, 0xa5, 0x29, 0x6e, 0x3a, 0xf2, 0x50, 0x5a, 0x40, 0xf4, 0x79, 0x78, 0xff, 0x10, 0x66, + 0x9b, 0xb7, 0xd, 0x1e, 0x64, 0xcf, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x11, 0x32, 0x5e}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x60, 0xbd, 0x22, 0x35, 0xdf, 0xba, 0xfe, 0xec, 0x14, 0x79, 0x28, 0x16, 0x6e}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb8, 0x88}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x72, 0x1b, 0xcc, 0xc7, 0x6b, 0x6e, 0x8d, 0x36, 0xb6, 0xe9, + 0x7e, 0x14, 0x9e, 0x70, 0x24, 0xdc, 0x15, 0x1d, 0x6d, 0x23}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x24, 0xd9, 0xe7, 0x75, 0x4a, 0xdc, 0x34, 0xcd, 0xa3, 0x32, - 0xab, 0x27, 0xcb, 0x50, 0x1b, 0xfc, 0xe4, 0x1, 0xca}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x37, 0x6d, 0x0, 0x12, 0x63, 0x11, 0xfa, 0x85}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s3_bytes[] = {0x1e, 0x5c, 0x2f, 0xcb, 0x9c, 0xa3, 0xfc, 0x53, 0x2e, 0xae, 0xb1, 0x6b, 0x71, 0xe1, + 0x70, 0x94, 0xa3, 0x62, 0xf9, 0x93, 0x65, 0x2e, 0x4, 0x12, 0x6b, 0xce, 0xb1}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x2f, 0x8, 0xb1, 0xcf, 0x5, 0xe5, 0x9d, 0x6b, 0xd4, 0xa, 0x67, 0xf7, + 0x13, 0xfa, 0x4b, 0x60, 0xca, 0x74, 0x4e, 0x70, 0xf9, 0xdf, 0x87}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x9d, 0xbb, 0xe6, 0xe5, 0xe0, 0xc4, 0x54}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xde, 0xa, 0xa5, 0xa5, 0xa9, 0x25, 0xcc, 0x2d, + 0x0, 0x2, 0xc0, 0x8f, 0x70, 0x34, 0xdd, 0x55}; + lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xea, 0x9e, 0x78, 0x6f, 0x46, 0xd9, 0x1a, 0x80, 0x7e, 0xb8, 0xb}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa5, 0x29, 0x6e, 0x3a, 0xf2, 0x50, 0x5a, 0x40, 0xf4, 0x79, + 0x78, 0xff, 0x10, 0x66, 0x9b, 0xb7, 0xd, 0x1e, 0x64, 0xcf}; + lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -10272,43 +10146,69 @@ TEST(Subscribe311QCTest, Encode2) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3206, 3, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 13602 [("\183z",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2}),("1\166\179}\189\167\248\176&\209\EMo\162",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("`\230^\177X\132'\DLE}\211",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("4\242",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS -// = QoS2})] [] -TEST(Subscribe311QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x29, 0x35, 0x22, 0x0, 0x2, 0xb7, 0x7a, 0x2, 0x0, 0xd, 0x31, 0xa6, 0xb3, 0x7d, - 0xbd, 0xa7, 0xf8, 0xb0, 0x26, 0xd1, 0x19, 0x6f, 0xa2, 0x1, 0x0, 0xa, 0x60, 0xe6, 0x5e, - 0xb1, 0x58, 0x84, 0x27, 0x10, 0x7d, 0xd3, 0x2, 0x0, 0x2, 0x34, 0xf2, 0x2}; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15521, 9, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 32751 [("\244p\172\184\198D\143w^DY=\SOH*\198Or\168\&2S\EOT\201F\221 ",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("6\131\253\146v\146O(\180\253\DC3\176\254\187\231\176\157\130\246\146rL\164\149i\255!",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("5\250\218p\241}\189\209\ESC6)\141\164(\SOH\213",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode3) { + uint8_t pkt[] = {0x82, 0x4f, 0x7f, 0xef, 0x0, 0x19, 0xf4, 0x70, 0xac, 0xb8, 0xc6, 0x44, 0x8f, 0x77, 0x5e, 0x44, 0x59, + 0x3d, 0x1, 0x2a, 0xc6, 0x4f, 0x72, 0xa8, 0x32, 0x53, 0x4, 0xc9, 0x46, 0xdd, 0x20, 0x2, 0x0, 0x1b, + 0x36, 0x83, 0xfd, 0x92, 0x76, 0x92, 0x4f, 0x28, 0xb4, 0xfd, 0x13, 0xb0, 0xfe, 0xbb, 0xe7, 0xb0, 0x9d, + 0x82, 0xf6, 0x92, 0x72, 0x4c, 0xa4, 0x95, 0x69, 0xff, 0x21, 0x1, 0x0, 0x10, 0x35, 0xfa, 0xda, 0x70, + 0xf1, 0x7d, 0xbd, 0xd1, 0x1b, 0x36, 0x29, 0x8d, 0xa4, 0x28, 0x1, 0xd5, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xb7, 0x7a}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xf4, 0x70, 0xac, 0xb8, 0xc6, 0x44, 0x8f, 0x77, 0x5e, 0x44, 0x59, 0x3d, 0x1, + 0x2a, 0xc6, 0x4f, 0x72, 0xa8, 0x32, 0x53, 0x4, 0xc9, 0x46, 0xdd, 0x20}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x31, 0xa6, 0xb3, 0x7d, 0xbd, 0xa7, 0xf8, 0xb0, 0x26, 0xd1, 0x19, 0x6f, 0xa2}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x36, 0x83, 0xfd, 0x92, 0x76, 0x92, 0x4f, 0x28, 0xb4, 0xfd, 0x13, 0xb0, 0xfe, 0xbb, + 0xe7, 0xb0, 0x9d, 0x82, 0xf6, 0x92, 0x72, 0x4c, 0xa4, 0x95, 0x69, 0xff, 0x21}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x60, 0xe6, 0x5e, 0xb1, 0x58, 0x84, 0x27, 0x10, 0x7d, 0xd3}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x35, 0xfa, 0xda, 0x70, 0xf1, 0x7d, 0xbd, 0xd1, + 0x1b, 0x36, 0x29, 0x8d, 0xa4, 0x28, 0x1, 0xd5}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x34, 0xf2}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + lwmqtt_sub_options_t sub_opts[3]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -10321,78 +10221,68 @@ TEST(Subscribe311QCTest, Encode3) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13602, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32751, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14384 [("\FS\128\241\248\208\137C~(\163%\158w",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("5X8\205\211\235pK\ETBW@\NUL:\138\244U\176\143\vel\244x_\255\153",SubOptions {_retainHandling = +// SubscribeRequest 9203 [("\220\237 +// \185\218f\186\169G-\SYNR\157\129k\146\142\187\249\223Vy\168X\214\209B\212\ETX\183",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("r^\143\162\178\168\192\172\141.\SI\245\a\221\ETBN\254w\DC4\141\EMJ\141)3\194\246",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\t",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\144\194A\232\SOH\155\ESCL\\\214\&8\169\DC2\239\173\&0\DC4P:&",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("i\129\v\240\205@PA/",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("A!\225\138=",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\169\193\&8B\138\143\CAN~=\150\240\216U\168\DLECx\DEL(\245\135\&1G|1\144F",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS2}),("7t\b,\195X\ETB\163\b\239\189\161%<\186M\148Ge\DC1",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\214\204\149U\228E\GS\"\154\138tn6\214\212\252\GS\221\192",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\193\225~tM*M\ETX\160!",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("!\SI\216\183\f1\167N7\226\168",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\141\196\137sYG3\148\203O\177",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\n8\154\150]\ETX\218\235H",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode4) { - uint8_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0xdf, 0x56, 0x79, 0xa8, 0x58, 0xd6, 0xd1, 0x42, + 0xd4, 0x3, 0xb7, 0x2, 0x0, 0x14, 0x37, 0x74, 0x8, 0x2c, 0xc3, 0x58, 0x17, 0xa3, 0x8, 0xef, 0xbd, + 0xa1, 0x25, 0x3c, 0xba, 0x4d, 0x94, 0x47, 0x65, 0x11, 0x1, 0x0, 0x13, 0xd6, 0xcc, 0x95, 0x55, 0xe4, + 0x45, 0x1d, 0x22, 0x9a, 0x8a, 0x74, 0x6e, 0x36, 0xd6, 0xd4, 0xfc, 0x1d, 0xdd, 0xc0, 0x2, 0x0, 0xa, + 0xc1, 0xe1, 0x7e, 0x74, 0x4d, 0x2a, 0x4d, 0x3, 0xa0, 0x21, 0x1, 0x0, 0xb, 0x21, 0xf, 0xd8, 0xb7, + 0xc, 0x31, 0xa7, 0x4e, 0x37, 0xe2, 0xa8, 0x1, 0x0, 0xb, 0x8d, 0xc4, 0x89, 0x73, 0x59, 0x47, 0x33, + 0x94, 0xcb, 0x4f, 0xb1, 0x1, 0x0, 0x9, 0xa, 0x38, 0x9a, 0x96, 0x5d, 0x3, 0xda, 0xeb, 0x48, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x1c, 0x80, 0xf1, 0xf8, 0xd0, 0x89, 0x43, 0x7e, 0x28, 0xa3, 0x25, 0x9e, 0x77}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xdc, 0xed, 0x20, 0xb9, 0xda, 0x66, 0xba, 0xa9, 0x47, 0x2d, + 0x16, 0x52, 0x9d, 0x81, 0x6b, 0x92, 0x8e, 0xbb, 0xf9, 0xdf, + 0x56, 0x79, 0xa8, 0x58, 0xd6, 0xd1, 0x42, 0xd4, 0x3, 0xb7}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x35, 0x58, 0x38, 0xcd, 0xd3, 0xeb, 0x70, 0x4b, 0x17, 0x57, 0x40, 0x0, 0x3a, - 0x8a, 0xf4, 0x55, 0xb0, 0x8f, 0xb, 0x65, 0x6c, 0xf4, 0x78, 0x5f, 0xff, 0x99}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x37, 0x74, 0x8, 0x2c, 0xc3, 0x58, 0x17, 0xa3, 0x8, 0xef, + 0xbd, 0xa1, 0x25, 0x3c, 0xba, 0x4d, 0x94, 0x47, 0x65, 0x11}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x72, 0x5e, 0x8f, 0xa2, 0xb2, 0xa8, 0xc0, 0xac, 0x8d, 0x2e, 0xf, 0xf5, 0x7, 0xdd, - 0x17, 0x4e, 0xfe, 0x77, 0x14, 0x8d, 0x19, 0x4a, 0x8d, 0x29, 0x33, 0xc2, 0xf6}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd6, 0xcc, 0x95, 0x55, 0xe4, 0x45, 0x1d, 0x22, 0x9a, 0x8a, + 0x74, 0x6e, 0x36, 0xd6, 0xd4, 0xfc, 0x1d, 0xdd, 0xc0}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc1, 0xe1, 0x7e, 0x74, 0x4d, 0x2a, 0x4d, 0x3, 0xa0, 0x21}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x90, 0xc2, 0x41, 0xe8, 0x1, 0x9b, 0x1b, 0x4c, 0x5c, 0xd6, - 0x38, 0xa9, 0x12, 0xef, 0xad, 0x30, 0x14, 0x50, 0x3a, 0x26}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x21, 0xf, 0xd8, 0xb7, 0xc, 0x31, 0xa7, 0x4e, 0x37, 0xe2, 0xa8}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x69, 0x81, 0xb, 0xf0, 0xcd, 0x40, 0x50, 0x41, 0x2f}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x8d, 0xc4, 0x89, 0x73, 0x59, 0x47, 0x33, 0x94, 0xcb, 0x4f, 0xb1}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x41, 0x21, 0xe1, 0x8a, 0x3d}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xa, 0x38, 0x9a, 0x96, 0x5d, 0x3, 0xda, 0xeb, 0x48}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa9, 0xc1, 0x38, 0x42, 0x8a, 0x8f, 0x18, 0x7e, 0x3d, 0x96, 0xf0, 0xd8, 0x55, 0xa8, - 0x10, 0x43, 0x78, 0x7f, 0x28, 0xf5, 0x87, 0x31, 0x47, 0x7c, 0x31, 0x90, 0x46}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -10404,7 +10294,7 @@ TEST(Subscribe311QCTest, Encode4) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -10420,81 +10310,78 @@ TEST(Subscribe311QCTest, Encode4) { sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14384, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9203, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 10952 [("\189\131\143u\249\178\237\221\225\135\200_E",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\138:\130%\226\132\219i%\244x~=X\220\GS\224\244\133\144\194O\240\154",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\184*~\237,+2\155\&2P\221\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\172\&6\205I;\188o",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("-\ETB\193\208",SubOptions {_retainHandling = +// SubscribeRequest 7433 [("#\207",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\150",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\236",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\193\250\200\202",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\237c\182\248?\181\241\171\158",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ENQ\r\210U\140\DC2\148\199\188\163\197]",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1}),("yr \203n\154\&6\197\134\218xJ\DC4\144",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("8Y\218Q\175\&2",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS2}),("\189A\203\SYNq\144\&2\237\196d\226s\192\SUB",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("h\187\a\196\RS\\\235\216\SOH\fv3",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("/\185l>/\134\246\153\EOT\237\&5\v\213\STX\138\EOT\211a",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\DC4\STX\211\a-\145",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x76, 0x2a, 0xc8, 0x0, 0xd, 0xbd, 0x83, 0x8f, 0x75, 0xf9, 0xb2, 0xed, 0xdd, 0xe1, - 0x87, 0xc8, 0x5f, 0x45, 0x2, 0x0, 0x18, 0x8a, 0x3a, 0x82, 0x25, 0xe2, 0x84, 0xdb, 0x69, - 0x25, 0xf4, 0x78, 0x7e, 0x3d, 0x58, 0xdc, 0x1d, 0xe0, 0xf4, 0x85, 0x90, 0xc2, 0x4f, 0xf0, - 0x9a, 0x1, 0x0, 0xc, 0xb8, 0x2a, 0x7e, 0xed, 0x2c, 0x2b, 0x32, 0x9b, 0x32, 0x50, 0xdd, - 0xc5, 0x0, 0x0, 0x7, 0xac, 0x36, 0xcd, 0x49, 0x3b, 0xbc, 0x6f, 0x2, 0x0, 0x4, 0x2d, - 0x17, 0xc1, 0xd0, 0x1, 0x0, 0xc, 0x5, 0xd, 0xd2, 0x55, 0x8c, 0x12, 0x94, 0xc7, 0xbc, - 0xa3, 0xc5, 0x5d, 0x1, 0x0, 0xe, 0x79, 0x72, 0x20, 0xcb, 0x6e, 0x9a, 0x36, 0xc5, 0x86, - 0xda, 0x78, 0x4a, 0x14, 0x90, 0x1, 0x0, 0x6, 0x38, 0x59, 0xda, 0x51, 0xaf, 0x32, 0x2}; + uint8_t pkt[] = {0x82, 0x60, 0x1d, 0x9, 0x0, 0x2, 0x23, 0xcf, 0x2, 0x0, 0x1, 0x96, 0x0, 0x0, 0x1, 0xec, 0x1, + 0x0, 0x4, 0xc1, 0xfa, 0xc8, 0xca, 0x2, 0x0, 0x9, 0xed, 0x63, 0xb6, 0xf8, 0x3f, 0xb5, 0xf1, 0xab, + 0x9e, 0x2, 0x0, 0xe, 0xbd, 0x41, 0xcb, 0x16, 0x71, 0x90, 0x32, 0xed, 0xc4, 0x64, 0xe2, 0x73, 0xc0, + 0x1a, 0x2, 0x0, 0xc, 0x68, 0xbb, 0x7, 0xc4, 0x1e, 0x5c, 0xeb, 0xd8, 0x1, 0xc, 0x76, 0x33, 0x1, + 0x0, 0x12, 0x2f, 0xb9, 0x6c, 0x3e, 0x2f, 0x86, 0xf6, 0x99, 0x4, 0xed, 0x35, 0xb, 0xd5, 0x2, 0x8a, + 0x4, 0xd3, 0x61, 0x1, 0x0, 0x6, 0x14, 0x2, 0xd3, 0x7, 0x2d, 0x91, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xbd, 0x83, 0x8f, 0x75, 0xf9, 0xb2, 0xed, 0xdd, 0xe1, 0x87, 0xc8, 0x5f, 0x45}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x23, 0xcf}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8a, 0x3a, 0x82, 0x25, 0xe2, 0x84, 0xdb, 0x69, 0x25, 0xf4, 0x78, 0x7e, - 0x3d, 0x58, 0xdc, 0x1d, 0xe0, 0xf4, 0x85, 0x90, 0xc2, 0x4f, 0xf0, 0x9a}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x96}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb8, 0x2a, 0x7e, 0xed, 0x2c, 0x2b, 0x32, 0x9b, 0x32, 0x50, 0xdd, 0xc5}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xec}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xac, 0x36, 0xcd, 0x49, 0x3b, 0xbc, 0x6f}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc1, 0xfa, 0xc8, 0xca}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2d, 0x17, 0xc1, 0xd0}; - lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xed, 0x63, 0xb6, 0xf8, 0x3f, 0xb5, 0xf1, 0xab, 0x9e}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5, 0xd, 0xd2, 0x55, 0x8c, 0x12, 0x94, 0xc7, 0xbc, 0xa3, 0xc5, 0x5d}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xbd, 0x41, 0xcb, 0x16, 0x71, 0x90, 0x32, + 0xed, 0xc4, 0x64, 0xe2, 0x73, 0xc0, 0x1a}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x79, 0x72, 0x20, 0xcb, 0x6e, 0x9a, 0x36, - 0xc5, 0x86, 0xda, 0x78, 0x4a, 0x14, 0x90}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x68, 0xbb, 0x7, 0xc4, 0x1e, 0x5c, 0xeb, 0xd8, 0x1, 0xc, 0x76, 0x33}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x38, 0x59, 0xda, 0x51, 0xaf, 0x32}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x2f, 0xb9, 0x6c, 0x3e, 0x2f, 0x86, 0xf6, 0x99, 0x4, + 0xed, 0x35, 0xb, 0xd5, 0x2, 0x8a, 0x4, 0xd3, 0x61}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; + uint8_t topic_filter_s8_bytes[] = {0x14, 0x2, 0xd3, 0x7, 0x2d, 0x91}; + lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -10502,11 +10389,11 @@ TEST(Subscribe311QCTest, Encode5) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -10514,80 +10401,85 @@ TEST(Subscribe311QCTest, Encode5) { sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10952, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7433, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20143 -// [("N\178\188\208\255\162\DEL;\181\212\177\147\234\168\234)\194x\206K)\DC1\247\191\&4f\155",SubOptions +// SubscribeRequest 22949 [("\139\231\DC1\195J*\243\226Ip\ENQ\158\195U\254kO\229g",SubOptions +// QoS1}),("t\142\NAK)D\139\ENQ\188x\155mV\141\245\134\174\195\GS\187s\231\185\149\t\RSj\FS\NUL\165\217",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(",\255\175\ENQ\139\179%\241\252\148^\228T\243\DLE",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DEL\152",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\ACK\168&\158\RS\EM(\144%\ACKy\f\185=\229\161\139\170\SOH",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\RSMD\EM\154\220\162\b\165\174\174Z\246\DLE$\b\193",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS0}),("\229\234\&5\155\171\154\249^*-;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS0}),("\241\207\171\132k\CAN+\160\ETB\231\144C\128\166\166ud\201\218Y?\218\161\&9",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0x9d, 0x1, 0xd, 0x85, 0x0, 0x18, 0x2e, 0x4a, 0xab, 0x7f, 0xa0, 0xc2, 0xe1, 0xe1, 0xaf, - 0xd7, 0x2c, 0x42, 0x8c, 0x58, 0x11, 0xa, 0x60, 0x52, 0xb8, 0x6a, 0xa4, 0x5a, 0x42, 0x5, 0x2, - 0x0, 0xe, 0xf8, 0x61, 0xe1, 0xc9, 0x70, 0x11, 0xb5, 0x46, 0x76, 0xd2, 0xda, 0xe, 0xe0, 0x1a, - 0x1, 0x0, 0x3, 0x46, 0xef, 0xa0, 0x0, 0x0, 0x9, 0xb7, 0x2e, 0xf6, 0x79, 0xa4, 0xa2, 0xd0, - 0x79, 0x2, 0x0, 0x0, 0x16, 0xca, 0x82, 0xc0, 0x89, 0xe7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 0xcf, 0xab, 0x84, 0x6b, 0x18, 0x2b, 0xa0, 0x17, 0xe7, 0x90, 0x43, 0x80, 0xa6, 0xa6, 0x75, + 0x64, 0xc9, 0xda, 0x59, 0x3f, 0xda, 0xa1, 0x39, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x2e, 0x4a, 0xab, 0x7f, 0xa0, 0xc2, 0xe1, 0xe1, 0xaf, 0xd7, 0x2c, 0x42, - 0x8c, 0x58, 0x11, 0xa, 0x60, 0x52, 0xb8, 0x6a, 0xa4, 0x5a, 0x42, 0x5}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xe6, 0x1e, 0xd0, 0xe9, 0x5e, 0x5e, 0x9c}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf8, 0x61, 0xe1, 0xc9, 0x70, 0x11, 0xb5, 0x46, 0x76, 0xd2, 0xda, 0xe, 0xe0, 0x1a}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x25, 0xe0}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x46, 0xef, 0xa0}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf3, 0x69, 0x9f, 0xda, 0x24, 0x4a, 0x56, 0x86, 0x76, 0x4a}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb7, 0x2e, 0xf6, 0x79, 0xa4, 0xa2, 0xd0, 0x79, 0x2}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x4f, 0x71, 0x37, 0xdd, 0xd, 0xb9, 0x11, 0xc9, 0xeb, 0x85, 0x9d, 0x98}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xca, 0x82, 0xc0, 0x89, 0xe7, 0x2, 0xa4, 0x19, 0xc3, 0x7a, 0xa8, - 0x23, 0x54, 0x65, 0x6a, 0x81, 0x4f, 0x3e, 0x6b, 0x4f, 0xe5, 0x67}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x74, 0x8e, 0x15, 0x29, 0x44, 0x8b, 0x5, 0xbc, 0x78, 0x9b, + 0x6d, 0x56, 0x8d, 0xf5, 0x86, 0xae, 0xc3, 0x1d, 0xbb, 0x73, + 0xe7, 0xb9, 0x95, 0x9, 0x1e, 0x6a, 0x1c, 0x0, 0xa5, 0xd9}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x2c, 0xff, 0xaf, 0x5, 0x8b, 0xb3, 0x25, 0xf1, - 0xfc, 0x94, 0x5e, 0xe4, 0x54, 0xf3, 0x10}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe5, 0xea, 0x35, 0x9b, 0xab, 0x9a, 0xf9, 0x5e, 0x2a, 0x2d, 0x3b}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x7f, 0x98}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xf1, 0xcf, 0xab, 0x84, 0x6b, 0x18, 0x2b, 0xa0, 0x17, 0xe7, 0x90, 0x43, + 0x80, 0xa6, 0xa6, 0x75, 0x64, 0xc9, 0xda, 0x59, 0x3f, 0xda, 0xa1, 0x39}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0}; - lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x6, 0xa8, 0x26, 0x9e, 0x1e, 0x19, 0x28, 0x90, 0x25, 0x6, - 0x79, 0xc, 0xb9, 0x3d, 0xe5, 0xa1, 0x8b, 0xaa, 0x1}; - lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x1e, 0x4d, 0x44, 0x19, 0x9a, 0xdc, 0xa2, 0x8, 0xa5, - 0xae, 0xae, 0x5a, 0xf6, 0x10, 0x24, 0x8, 0xc1}; - lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -10684,11 +10558,11 @@ TEST(Subscribe311QCTest, Encode7) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -10696,157 +10570,197 @@ TEST(Subscribe311QCTest, Encode7) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3461, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26075, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 24628 [("J$\202\SOH\164s\193\241\FS\196\170\186\133\233\147!bV\164\233m\185\177wW",SubOptions +// SubscribeRequest 11400 [("\225\&5\173\150\r\146,\248\162\163Y\DEL2|\172\&5%\202\ACK4\172\NUL\167\172p/",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Pu\230B\171\159)-\n\236\132r\193f\179`H\140\168\r&\ESC\241\173\219\190",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS1}),("v[\184U\225<\149\162t\132\235c\194O8\NUL\164\208\ACK_\146\239\233\159",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\197M\bsT\208[\175\238zW@\152\DC4\194)\219",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\t\SI\188\&6\206\242m\207[-]#\NAK\"\232\161\161\ACKh\181;\208",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\163q\148\190U\238\215\136r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS1}),("\DLEsn\GS\187_\137\192\128\ETXz\ENQ\143\137\176U\183\158\ESC\174\213v\143\&9",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(",\206\248\177)K$\154\&6,n\168?\245\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x3b, 0x60, 0x34, 0x0, 0x19, 0x4a, 0x24, 0xca, 0x1, 0xa4, 0x73, 0xc1, 0xf1, 0x1c, 0xc4, - 0xaa, 0xba, 0x85, 0xe9, 0x93, 0x21, 0x62, 0x56, 0xa4, 0xe9, 0x6d, 0xb9, 0xb1,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b, + 0x24, 0x9a, 0x36, 0x2c, 0x6e, 0xa8, 0x3f, 0xf5, 0xd0, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x4a, 0x24, 0xca, 0x1, 0xa4, 0x73, 0xc1, 0xf1, 0x1c, 0xc4, 0xaa, 0xba, 0x85, - 0xe9, 0x93, 0x21, 0x62, 0x56, 0xa4, 0xe9, 0x6d, 0xb9, 0xb1, 0x77, 0x57}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xe1, 0x35, 0xad, 0x96, 0xd, 0x92, 0x2c, 0xf8, 0xa2, 0xa3, 0x59, 0x7f, 0x32, + 0x7c, 0xac, 0x35, 0x25, 0xca, 0x6, 0x34, 0xac, 0x0, 0xa7, 0xac, 0x70, 0x2f}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x50, 0x75, 0xe6, 0x42, 0xab, 0x9f, 0x29, 0x2d, 0xa, 0xec, 0x84, 0x72, 0xc1, - 0x66, 0xb3, 0x60, 0x48, 0x8c, 0xa8, 0xd, 0x26, 0x1b, 0xf1, 0xad, 0xdb, 0xbe}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x76, 0x5b, 0xb8, 0x55, 0xe1, 0x3c, 0x95, 0xa2, 0x74, 0x84, 0xeb, 0x63, + 0xc2, 0x4f, 0x38, 0x0, 0xa4, 0xd0, 0x6, 0x5f, 0x92, 0xef, 0xe9, 0x9f}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s2_bytes[] = {0xc5, 0x4d, 0x8, 0x73, 0x54, 0xd0, 0x5b, 0xaf, 0xee, + 0x7a, 0x57, 0x40, 0x98, 0x14, 0xc2, 0x29, 0xdb}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x9, 0xf, 0xbc, 0x36, 0xce, 0xf2, 0x6d, 0xcf, 0x5b, 0x2d, 0x5d, + 0x23, 0x15, 0x22, 0xe8, 0xa1, 0xa1, 0x6, 0x68, 0xb5, 0x3b, 0xd0}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa3, 0x71, 0x94, 0xbe, 0x55, 0xee, 0xd7, 0x88, 0x72}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x10, 0x73, 0x6e, 0x1d, 0xbb, 0x5f, 0x89, 0xc0, 0x80, 0x3, 0x7a, 0x5, + 0x8f, 0x89, 0xb0, 0x55, 0xb7, 0x9e, 0x1b, 0xae, 0xd5, 0x76, 0x8f, 0x39}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x2c, 0xce, 0xf8, 0xb1, 0x29, 0x4b, 0x24, 0x9a, + 0x36, 0x2c, 0x6e, 0xa8, 0x3f, 0xf5, 0xd0}; + lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24628, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11400, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27288 [("\217\135\214\SIKL\f\214\225\208\141\236\194:4\212\162{\DLE\CAN",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\203\193<\223\198\148=\252\DC3=x\192\203\215\231\&2\211",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("-.N5P\STXC\CAN",SubOptions {_retainHandling = +// SubscribeRequest 30378 [("\197\180 ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\222\170\NULu[\144\188\r\243\DC3\ETB\245:<^Y\247EW\176W\154\&9f\232\b\a\155",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\147\DLE\210K\RS,n\142:0O\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\STXs\187\214l$s\164\&9O\a\137M\132\197\"\151\179\229,\193\188^\173",SubOptions +// QoS1}),(".\147{<\247\180Q\202T.\f\185\134>\DC3n'T\FS\230\201\178}A",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(">9d\234/%\170N&\242h\234\206\134\134",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\252\138+\n\175\ETX\235\\s\224\216\249m\228WJ\fy\195\226\195#\182\139\215",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\143\237,\176$\130\243/\DLE\DEL\156\226\192\193I%D7a\SUB",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\160}\178\229\154'\175?\176I\167Y\243r+\148\192\&4\186X:\192\247r\246\132",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\DC4\128\162\SO\152]\188\DC1\184\174M\136\DC4\203\235\164\203\ACK\136\208\255N\133\250\173",SubOptions +// QoS2}),("%\217\254\154\133h\199\ACKo%\128\253;_D\137\226\\\175\&9\138\&5\241B\a2\212",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\241\189ww\ETX\164\226",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("?'h\n\240j\b\244;\129\DEL\203\169\ENQ\149\140\131\168h\137$",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS1}),("E\180D\152\180\232\246\212\187U\138\209\197\193\160\DC4\164j{\130\253\170",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\201mH\219\192\STX\SUB{H\142Q#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\213\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\ENQ]",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0xe6, 0x1, 0x6a, 0x98, 0x0, 0x14, 0xd9, 0x87, 0xd6, 0xf, 0x4b, 0x4c, 0xc, 0xd6, 0xe1, 0xd0, - 0x8d, 0xec, 0xc2, 0x3a, 0x34, 0xd4, 0xa2, 0x7b, 0x10, 0x18, 0x0, 0x0, 0x11, 0xcb, 0xc1, 0x3c, 0xdf, - 0xc6, 0x94, 0x3d, 0xfc, 0x13, 0x3d, 0x78, 0xc0, 0xcb, 0xd7, 0xe7, 0x32, 0xd3, 0x2, 0x0, 0x8, 0x2d, - 0x2e, 0x4e, 0x35, 0x50, 0x2, 0x43, 0x18, 0x2, 0x0, 0xc, 0x93, 0x10, 0xd2, 0x4b, 0x1e, 0x2c, 0x6e, - 0x8e, 0x3a, 0x30, 0x4f, 0xd9, 0x2, 0x0, 0x18, 0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x3a, 0x3c, 0x5e, 0x59, 0xf7, 0x45, 0x57, 0xb0, 0x57, + 0x9a, 0x39, 0x66, 0xe8, 0x8, 0x7, 0x9b, 0x1, 0x0, 0x18, 0x2e, 0x93, 0x7b, 0x3c, 0xf7, 0xb4, 0x51, + 0xca, 0x54, 0x2e, 0xc, 0xb9, 0x86, 0x3e, 0x13, 0x6e, 0x27, 0x54, 0x1c, 0xe6, 0xc9, 0xb2, 0x7d, 0x41, + 0x2, 0x0, 0xf, 0x3e, 0x39, 0x64, 0xea, 0x2f, 0x25, 0xaa, 0x4e, 0x26, 0xf2, 0x68, 0xea, 0xce, 0x86, + 0x86, 0x2, 0x0, 0x1b, 0x25, 0xd9, 0xfe, 0x9a, 0x85, 0x68, 0xc7, 0x6, 0x6f, 0x25, 0x80, 0xfd, 0x3b, + 0x5f, 0x44, 0x89, 0xe2, 0x5c, 0xaf, 0x39, 0x8a, 0x35, 0xf1, 0x42, 0x7, 0x32, 0xd4, 0x2, 0x0, 0x0, + 0x1, 0x0, 0x7, 0xf1, 0xbd, 0x77, 0x77, 0x3, 0xa4, 0xe2, 0x1, 0x0, 0x16, 0x45, 0xb4, 0x44, 0x98, + 0xb4, 0xe8, 0xf6, 0xd4, 0xbb, 0x55, 0x8a, 0xd1, 0xc5, 0xc1, 0xa0, 0x14, 0xa4, 0x6a, 0x7b, 0x82, 0xfd, + 0xaa, 0x1, 0x0, 0xc, 0xc9, 0x6d, 0x48, 0xdb, 0xc0, 0x2, 0x1a, 0x7b, 0x48, 0x8e, 0x51, 0x23, 0x0, + 0x0, 0x2, 0xd5, 0xd2, 0x0, 0x0, 0x2, 0x5, 0x5d, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd9, 0x87, 0xd6, 0xf, 0x4b, 0x4c, 0xc, 0xd6, 0xe1, 0xd0, - 0x8d, 0xec, 0xc2, 0x3a, 0x34, 0xd4, 0xa2, 0x7b, 0x10, 0x18}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xc5, 0xb4, 0x20}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcb, 0xc1, 0x3c, 0xdf, 0xc6, 0x94, 0x3d, 0xfc, 0x13, - 0x3d, 0x78, 0xc0, 0xcb, 0xd7, 0xe7, 0x32, 0xd3}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xde, 0xaa, 0x0, 0x75, 0x5b, 0x90, 0xbc, 0xd, 0xf3, 0x13, + 0x17, 0xf5, 0x3a, 0x3c, 0x5e, 0x59, 0xf7, 0x45, 0x57, 0xb0, + 0x57, 0x9a, 0x39, 0x66, 0xe8, 0x8, 0x7, 0x9b}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2d, 0x2e, 0x4e, 0x35, 0x50, 0x2, 0x43, 0x18}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2e, 0x93, 0x7b, 0x3c, 0xf7, 0xb4, 0x51, 0xca, 0x54, 0x2e, 0xc, 0xb9, + 0x86, 0x3e, 0x13, 0x6e, 0x27, 0x54, 0x1c, 0xe6, 0xc9, 0xb2, 0x7d, 0x41}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x93, 0x10, 0xd2, 0x4b, 0x1e, 0x2c, 0x6e, 0x8e, 0x3a, 0x30, 0x4f, 0xd9}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3e, 0x39, 0x64, 0xea, 0x2f, 0x25, 0xaa, 0x4e, + 0x26, 0xf2, 0x68, 0xea, 0xce, 0x86, 0x86}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2, 0x73, 0xbb, 0xd6, 0x6c, 0x24, 0x73, 0xa4, 0x39, 0x4f, 0x7, 0x89, - 0x4d, 0x84, 0xc5, 0x22, 0x97, 0xb3, 0xe5, 0x2c, 0xc1, 0xbc, 0x5e, 0xad}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x25, 0xd9, 0xfe, 0x9a, 0x85, 0x68, 0xc7, 0x6, 0x6f, 0x25, 0x80, 0xfd, 0x3b, 0x5f, + 0x44, 0x89, 0xe2, 0x5c, 0xaf, 0x39, 0x8a, 0x35, 0xf1, 0x42, 0x7, 0x32, 0xd4}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfc, 0x8a, 0x2b, 0xa, 0xaf, 0x3, 0xeb, 0x5c, 0x73, 0xe0, 0xd8, 0xf9, 0x6d, - 0xe4, 0x57, 0x4a, 0xc, 0x79, 0xc3, 0xe2, 0xc3, 0x23, 0xb6, 0x8b, 0xd7}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8f, 0xed, 0x2c, 0xb0, 0x24, 0x82, 0xf3, 0x2f, 0x10, 0x7f, - 0x9c, 0xe2, 0xc0, 0xc1, 0x49, 0x25, 0x44, 0x37, 0x61, 0x1a}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xf1, 0xbd, 0x77, 0x77, 0x3, 0xa4, 0xe2}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa0, 0x7d, 0xb2, 0xe5, 0x9a, 0x27, 0xaf, 0x3f, 0xb0, 0x49, 0xa7, 0x59, 0xf3, - 0x72, 0x2b, 0x94, 0xc0, 0x34, 0xba, 0x58, 0x3a, 0xc0, 0xf7, 0x72, 0xf6, 0x84}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x45, 0xb4, 0x44, 0x98, 0xb4, 0xe8, 0xf6, 0xd4, 0xbb, 0x55, 0x8a, + 0xd1, 0xc5, 0xc1, 0xa0, 0x14, 0xa4, 0x6a, 0x7b, 0x82, 0xfd, 0xaa}; + lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x14, 0x80, 0xa2, 0xe, 0x98, 0x5d, 0xbc, 0x11, 0xb8, 0xae, 0x4d, 0x88, 0x14, - 0xcb, 0xeb, 0xa4, 0xcb, 0x6, 0x88, 0xd0, 0xff, 0x4e, 0x85, 0xfa, 0xad}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xc9, 0x6d, 0x48, 0xdb, 0xc0, 0x2, 0x1a, 0x7b, 0x48, 0x8e, 0x51, 0x23}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x3f, 0x27, 0x68, 0xa, 0xf0, 0x6a, 0x8, 0xf4, 0x3b, 0x81, 0x7f, - 0xcb, 0xa9, 0x5, 0x95, 0x8c, 0x83, 0xa8, 0x68, 0x89, 0x24}; - lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0xd5, 0xd2}; + lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s10_bytes[] = {0x5, 0x5d}; + lwmqtt_string_t topic_filter_s10 = {2, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -10858,7 +10772,7 @@ TEST(Subscribe311QCTest, Encode9) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -10866,15 +10780,15 @@ TEST(Subscribe311QCTest, Encode9) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; @@ -10882,99 +10796,64 @@ TEST(Subscribe311QCTest, Encode9) { sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27288, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30378, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14432 [("\132\142U\243\225d\SO^\184\204\176\ng\214\232",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ap\172QO\204\154J[\145n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\RS\167x\142;=\175\194m}:\128\206\146\&5 PF\224\155",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\168c\156\132\130\233l",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS1}),("\138\204\153\191\242P(t/<\251\206\247P*\239f",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\SOH5\252\ETX\182\137\247D\155\b\175\SO\193\137\fS\148\225\133^a\a\207T\160",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\182\129\173\SUB\239\244",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),("\ACK\163\NAK\DC1\195\169\246\220\EMt-\224\251\210\190k\170\170\251\193\&0\DC1\208\233\&1\NUL1",SubOptions +// SubscribeRequest 19363 [("\171\&6)kL\250\200\246\241\214\221\252\198\159`\172N\210\247r\234Q1",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\n\SUB\192\143\n1\SYNu\131\135tm\186\224\200\235IQ4h>0",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("J\166;]\v@\SYNME\249\NAK -// \166\187\168h\EM,\194\193\148mF6\154d}\192",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\176\&9\ne\247S\212\228T\157k\157\139P\CAN\DC1\ESC\220\227$\252\ACK\217\192\128\128H\155\174",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS1}),("5\204P\216\&3\131s\130\228\239\253\SO\223",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("d!#X=\180_\191R\DEL\180\224\148\190i\152\228b",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\209\139\ACKUg\\\156\248\"\241\232*\SUB\148\"~\131c\rpq\ENQ\DC3\212\179y\RSX",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("_\231\198F\215\f\226\236\156vQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\225_l!\242_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 9790 [("\228F\148\174g\141\DC4\140\249o\196",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\177\151IY\145b\217z\r\205(B\253yT[~Z\183f\246^_IZ",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\n\173\216\DC2G\235Y\189fi\DC1\185g\229\bEH\252F\242\216\ACK\231\243\237\242",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(">A",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\163\133MU\FSV\131 +// V\b\ESC\210U\147\&0ma\248",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\250.\ETBh\239;\217\248\159\219\202\SOH\FS\135\218 \219\&3\ENQ\153s\199",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\207\SI/?@\201.\216\171h\187\128\242o|\144\158z,W\207\136",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0x79, 0x72, 0xb2, 0x0, 0x8, 0x5f, 0xf3, 0xe6, 0x88, 0x7f, 0xc0, 0x1, 0x81, 0x0, 0x0, - 0x1e, 0x29, 0x5e, 0xe0, 0x2d, 0x1e, 0x53, 0xbb, 0x84, 0x10, 0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 0x1c, 0x56, 0x83, 0x20, 0x56, 0x8, 0x1b, 0xd2, 0x55, 0x93, 0x30, 0x6d, 0x61, 0xf8, 0x0, + 0x0, 0x16, 0xfa, 0x2e, 0x17, 0x68, 0xef, 0x3b, 0xd9, 0xf8, 0x9f, 0xdb, 0xca, 0x1, 0x1c, 0x87, 0xda, + 0x20, 0xdb, 0x33, 0x5, 0x99, 0x73, 0xc7, 0x2, 0x0, 0x16, 0xcf, 0xf, 0x2f, 0x3f, 0x40, 0xc9, 0x2e, + 0xd8, 0xab, 0x68, 0xbb, 0x80, 0xf2, 0x6f, 0x7c, 0x90, 0x9e, 0x7a, 0x2c, 0x57, 0xcf, 0x88, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x5f, 0xf3, 0xe6, 0x88, 0x7f, 0xc0, 0x1, 0x81}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xe4, 0x46, 0x94, 0xae, 0x67, 0x8d, 0x14, 0x8c, 0xf9, 0x6f, 0xc4}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x29, 0x5e, 0xe0, 0x2d, 0x1e, 0x53, 0xbb, 0x84, 0x10, 0x9d, - 0xe4, 0x46, 0xec, 0xc1, 0x50, 0x2f, 0x3d, 0x20, 0x1f, 0xcb, - 0xa3, 0x64, 0x3c, 0xd, 0x3e, 0xe4, 0xef, 0xfd, 0xe, 0xdf}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb1, 0x97, 0x49, 0x59, 0x91, 0x62, 0xd9, 0x7a, 0xd, 0xcd, 0x28, 0x42, 0xfd, + 0x79, 0x54, 0x5b, 0x7e, 0x5a, 0xb7, 0x66, 0xf6, 0x5e, 0x5f, 0x49, 0x5a}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x64, 0x21, 0x23, 0x58, 0x3d, 0xb4, 0x5f, 0xbf, 0x52, - 0x7f, 0xb4, 0xe0, 0x94, 0xbe, 0x69, 0x98, 0xe4, 0x62}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa, 0xad, 0xd8, 0x12, 0x47, 0xeb, 0x59, 0xbd, 0x66, 0x69, 0x11, 0xb9, 0x67, + 0xe5, 0x8, 0x45, 0x48, 0xfc, 0x46, 0xf2, 0xd8, 0x6, 0xe7, 0xf3, 0xed, 0xf2}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd1, 0x8b, 0x6, 0x55, 0x67, 0x5c, 0x9c, 0xf8, 0x22, 0xf1, - 0xe8, 0x2a, 0x1a, 0x94, 0x22, 0x7e, 0x83, 0x63, 0xd, 0x70, - 0x71, 0x5, 0x13, 0xd4, 0xb3, 0x79, 0x1e, 0x58}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3e, 0x41}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5f, 0xe7, 0xc6, 0x46, 0xd7, 0xc, 0xe2, 0xec, 0x9c, 0x76, 0x51}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa3, 0x85, 0x4d, 0x55, 0x1c, 0x56, 0x83, 0x20, 0x56, + 0x8, 0x1b, 0xd2, 0x55, 0x93, 0x30, 0x6d, 0x61, 0xf8}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe1, 0x5f, 0x6c, 0x21, 0xf2, 0x5f}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xfa, 0x2e, 0x17, 0x68, 0xef, 0x3b, 0xd9, 0xf8, 0x9f, 0xdb, 0xca, + 0x1, 0x1c, 0x87, 0xda, 0x20, 0xdb, 0x33, 0x5, 0x99, 0x73, 0xc7}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0xcf, 0xf, 0x2f, 0x3f, 0x40, 0xc9, 0x2e, 0xd8, 0xab, 0x68, 0xbb, + 0x80, 0xf2, 0x6f, 0x7c, 0x90, 0x9e, 0x7a, 0x2c, 0x57, 0xcf, 0x88}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -11084,11 +10949,11 @@ TEST(Subscribe311QCTest, Encode11) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -11096,105 +10961,97 @@ TEST(Subscribe311QCTest, Encode11) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29362, 6, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 18382 -// [("\231\EM\193\193q\251\CAN\154\SYN\230\146\204c_\141w\148\DC3\215\RS!\ETXw\186x$n\182\231",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode12) { - uint8_t pkt[] = {0x82, 0x22, 0x47, 0xce, 0x0, 0x1d, 0xe7, 0x19, 0xc1, 0xc1, 0x71, 0xfb, - 0x18, 0x9a, 0x16, 0xe6, 0x92, 0xcc, 0x63, 0x5f, 0x8d, 0x77, 0x94, 0x13, - 0xd7, 0x1e, 0x21, 0x3, 0x77, 0xba, 0x78, 0x24, 0x6e, 0xb6, 0xe7, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xe7, 0x19, 0xc1, 0xc1, 0x71, 0xfb, 0x18, 0x9a, 0x16, 0xe6, - 0x92, 0xcc, 0x63, 0x5f, 0x8d, 0x77, 0x94, 0x13, 0xd7, 0x1e, - 0x21, 0x3, 0x77, 0xba, 0x78, 0x24, 0x6e, 0xb6, 0xe7}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18382, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9790, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3280 [("\252\153?\GSp",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// SubscribeRequest 29850 [("\ESC\148a",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, // _noLocal = False, _subQoS = -// QoS0}),("_\132\USe\201\201\207X\SI%\DC4\188n<\231p\ACK{\157\165\215\142\182\165\234\137\&6u",SubOptions +// QoS2}),("e\"\230B\SYNNm^{\160\218\FS\152\238\232\143\135\180\197\251D\202\205n\STX\161\f\175\165}",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\\3\146\160\169\t\156\ENQ\193$\238\197jL\b\216\252\216",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\ETX\240",SubOptions {_retainHandling = +// QoS0}),("]\RS\172\169\198\239\243#\136\243\DC37n\177\215k\167\243",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("Q\129=ls\SI\233\136\246\208\170\188\SUBg\134\155B",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("[=",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\174\230\194'q",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\a;J7U.\178\156\&8d\196\SO$\145\224\131Y\200\&2+;l",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("\\%\201\190\183\&1\138\217=~\181c\233?\138\160X",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("E\177t%H\185\EOTxHjzc\212\174}XI\SYNBe*\SOH\249Q6R\NUL-",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0x7b, 0xc, 0xd0, 0x0, 0x5, 0xfc, 0x99, 0x3f, 0x1d, 0x70, 0x0, 0x0, 0x1c, 0x5f, 0x84, - 0x1f, 0x65, 0xc9, 0xc9, 0xcf, 0x58, 0xf, 0x25, 0x14, 0xbc, 0x6e, 0x3c, 0xe7, 0x70, 0x6, 0x7b, - 0x9d, 0xa5, 0xd7, 0x8e, 0xb6, 0xa5, 0xea, 0x89, 0x36, 0x75, 0x2, 0x0, 0x12, 0x5c, 0x33, 0x92, - 0xa0, 0xa9, 0x9, 0x9c, 0x5, 0xc1, 0x24, 0xee, 0xc5, 0x6a, 0x4c, 0x8, 0xd8, 0xfc, 0xd8, 0x1, - 0x0, 0x2, 0x3, 0xf0, 0x1, 0x0, 0x16, 0x7, 0x3b, 0x4a, 0x37, 0x55, 0x2e, 0xb2, 0x9c, 0x38, - 0x64, 0xc4, 0xe, 0x24, 0x91, 0xe0, 0x83, 0x59, 0xc8, 0x32, 0x2b, 0x3b, 0x6c, 0x2, 0x0, 0x1c, - 0x45, 0xb1, 0x74, 0x25, 0x48, 0xb9, 0x4, 0x78, 0x48, 0x6a, 0x7a, 0x63, 0xd4, 0xae, 0x7d, 0x58, - 0x49, 0x16, 0x42, 0x65, 0x2a, 0x1, 0xf9, 0x51, 0x36, 0x52, 0x0, 0x2d, 0x2}; +// QoS1}),("\SI\159f\134\CAN%\254\185\194T\216\145[\248\229\214>\170\216\164",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\164r\209\EOTC\218[-BMGq\236>M\194\139H\216\165:R\132t\179\224\157C\147%",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode12) { + uint8_t pkt[] = {0x82, 0xab, 0x1, 0x74, 0x9a, 0x0, 0x3, 0x1b, 0x94, 0x61, 0x2, 0x0, 0x1e, 0x65, 0x22, 0xe6, + 0x42, 0x16, 0x4e, 0x6d, 0x5e, 0x7b, 0xa0, 0xda, 0x1c, 0x98, 0xee, 0xe8, 0x8f, 0x87, 0xb4, 0xc5, + 0xfb, 0x44, 0xca, 0xcd, 0x6e, 0x2, 0xa1, 0xc, 0xaf, 0xa5, 0x7d, 0x0, 0x0, 0x12, 0x5d, 0x1e, + 0xac, 0xa9, 0xc6, 0xef, 0xf3, 0x23, 0x88, 0xf3, 0x13, 0x37, 0x6e, 0xb1, 0xd7, 0x6b, 0xa7, 0xf3, + 0x1, 0x0, 0x11, 0x51, 0x81, 0x3d, 0x6c, 0x73, 0xf, 0xe9, 0x88, 0xf6, 0xd0, 0xaa, 0xbc, 0x1a, + 0x67, 0x86, 0x9b, 0x42, 0x0, 0x0, 0x2, 0x5b, 0x3d, 0x0, 0x0, 0x5, 0xae, 0xe6, 0xc2, 0x27, + 0x71, 0x2, 0x0, 0x11, 0x5c, 0x25, 0xc9, 0xbe, 0xb7, 0x31, 0x8a, 0xd9, 0x3d, 0x7e, 0xb5, 0x63, + 0xe9, 0x3f, 0x8a, 0xa0, 0x58, 0x1, 0x0, 0x14, 0xf, 0x9f, 0x66, 0x86, 0x18, 0x25, 0xfe, 0xb9, + 0xc2, 0x54, 0xd8, 0x91, 0x5b, 0xf8, 0xe5, 0xd6, 0x3e, 0xaa, 0xd8, 0xa4, 0x1, 0x0, 0x1e, 0xa4, + 0x72, 0xd1, 0x4, 0x43, 0xda, 0x5b, 0x2d, 0x42, 0x4d, 0x47, 0x71, 0xec, 0x3e, 0x4d, 0xc2, 0x8b, + 0x48, 0xd8, 0xa5, 0x3a, 0x52, 0x84, 0x74, 0xb3, 0xe0, 0x9d, 0x43, 0x93, 0x25, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xfc, 0x99, 0x3f, 0x1d, 0x70}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x1b, 0x94, 0x61}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5f, 0x84, 0x1f, 0x65, 0xc9, 0xc9, 0xcf, 0x58, 0xf, 0x25, - 0x14, 0xbc, 0x6e, 0x3c, 0xe7, 0x70, 0x6, 0x7b, 0x9d, 0xa5, - 0xd7, 0x8e, 0xb6, 0xa5, 0xea, 0x89, 0x36, 0x75}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x65, 0x22, 0xe6, 0x42, 0x16, 0x4e, 0x6d, 0x5e, 0x7b, 0xa0, + 0xda, 0x1c, 0x98, 0xee, 0xe8, 0x8f, 0x87, 0xb4, 0xc5, 0xfb, + 0x44, 0xca, 0xcd, 0x6e, 0x2, 0xa1, 0xc, 0xaf, 0xa5, 0x7d}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5c, 0x33, 0x92, 0xa0, 0xa9, 0x9, 0x9c, 0x5, 0xc1, - 0x24, 0xee, 0xc5, 0x6a, 0x4c, 0x8, 0xd8, 0xfc, 0xd8}; + uint8_t topic_filter_s2_bytes[] = {0x5d, 0x1e, 0xac, 0xa9, 0xc6, 0xef, 0xf3, 0x23, 0x88, + 0xf3, 0x13, 0x37, 0x6e, 0xb1, 0xd7, 0x6b, 0xa7, 0xf3}; lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3, 0xf0}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x51, 0x81, 0x3d, 0x6c, 0x73, 0xf, 0xe9, 0x88, 0xf6, + 0xd0, 0xaa, 0xbc, 0x1a, 0x67, 0x86, 0x9b, 0x42}; + lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7, 0x3b, 0x4a, 0x37, 0x55, 0x2e, 0xb2, 0x9c, 0x38, 0x64, 0xc4, - 0xe, 0x24, 0x91, 0xe0, 0x83, 0x59, 0xc8, 0x32, 0x2b, 0x3b, 0x6c}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x5b, 0x3d}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x45, 0xb1, 0x74, 0x25, 0x48, 0xb9, 0x4, 0x78, 0x48, 0x6a, - 0x7a, 0x63, 0xd4, 0xae, 0x7d, 0x58, 0x49, 0x16, 0x42, 0x65, - 0x2a, 0x1, 0xf9, 0x51, 0x36, 0x52, 0x0, 0x2d}; - lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xae, 0xe6, 0xc2, 0x27, 0x71}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s6_bytes[] = {0x5c, 0x25, 0xc9, 0xbe, 0xb7, 0x31, 0x8a, 0xd9, 0x3d, + 0x7e, 0xb5, 0x63, 0xe9, 0x3f, 0x8a, 0xa0, 0x58}; + lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf, 0x9f, 0x66, 0x86, 0x18, 0x25, 0xfe, 0xb9, 0xc2, 0x54, + 0xd8, 0x91, 0x5b, 0xf8, 0xe5, 0xd6, 0x3e, 0xaa, 0xd8, 0xa4}; + lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa4, 0x72, 0xd1, 0x4, 0x43, 0xda, 0x5b, 0x2d, 0x42, 0x4d, + 0x47, 0x71, 0xec, 0x3e, 0x4d, 0xc2, 0x8b, 0x48, 0xd8, 0xa5, + 0x3a, 0x52, 0x84, 0x74, 0xb3, 0xe0, 0x9d, 0x43, 0x93, 0x25}; + lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -11202,11 +11059,11 @@ TEST(Subscribe311QCTest, Encode13) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -11214,123 +11071,144 @@ TEST(Subscribe311QCTest, Encode13) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3280, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29850, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4639 [("\165\EM\DC2g\NUL",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\ESCH\249\163F",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\203\206z\136",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\156`s_",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0x20, 0x12, 0x1f, 0x0, 0x5, 0xa5, 0x19, 0x12, 0x67, 0x0, 0x2, 0x0, 0x5, 0x1b, 0x48, 0xf9, - 0xa3, 0x46, 0x1, 0x0, 0x4, 0xcb, 0xce, 0x7a, 0x88, 0x1, 0x0, 0x4, 0x9c, 0x60, 0x73, 0x5f, 0x1}; +// SubscribeRequest 18338 [("\162\249\GS\153yq\215F\221 \242",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\158\168o!e\ACK\247\202\128\152f\197m\\\176\247(\167\US\214\188ti\225\192",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode13) { + uint8_t pkt[] = {0x82, 0x2c, 0x47, 0xa2, 0x0, 0xb, 0xa2, 0xf9, 0x1d, 0x99, 0x79, 0x71, 0xd7, 0x46, 0xdd, 0x20, + 0xf2, 0x0, 0x0, 0x19, 0x9e, 0xa8, 0x6f, 0x21, 0x65, 0x6, 0xf7, 0xca, 0x80, 0x98, 0x66, 0xc5, + 0x6d, 0x5c, 0xb0, 0xf7, 0x28, 0xa7, 0x1f, 0xd6, 0xbc, 0x74, 0x69, 0xe1, 0xc0, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xa5, 0x19, 0x12, 0x67, 0x0}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xa2, 0xf9, 0x1d, 0x99, 0x79, 0x71, 0xd7, 0x46, 0xdd, 0x20, 0xf2}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1b, 0x48, 0xf9, 0xa3, 0x46}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9e, 0xa8, 0x6f, 0x21, 0x65, 0x6, 0xf7, 0xca, 0x80, 0x98, 0x66, 0xc5, 0x6d, + 0x5c, 0xb0, 0xf7, 0x28, 0xa7, 0x1f, 0xd6, 0xbc, 0x74, 0x69, 0xe1, 0xc0}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xcb, 0xce, 0x7a, 0x88}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9c, 0x60, 0x73, 0x5f}; - lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4639, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18338, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23421 [("\251(\b\221xT^\230i\US\136\EOT",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\239\134\214\190s\242G\b\155\159\231F\196",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS0}),("R\224\a\fdO\239\252\137\148rl,\DELe\145\206_\153\201\&4\149\173\208\\\n[\213\227",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\221A\172\SYN\229\189\v\177\194\tM6\158\244\184\129\CANc;T\142\&1@",SubOptions {_retainHandling = +// SubscribeRequest 4108 [("\199\233\131\SYNf\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("j\199\156\237c\EMH\246\212\232\&7\217aJ\193/\r\253\246>\215\t\221",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\159\222\ESC0\198\131\133\220\213\242\238\229\202\SUB\151\&4R\223cL\171r:\136\128\t\nV1@\206",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("\177\&6\255\208\&6s5\196\213\&7\242\172\v?\226_} r2\ENQB\225\136",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(",\181T\ETX\169&\SOH",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\231\185\DC3\162h\140[&\152A\151\t\128\157\a\143S",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\152\178\CAN\175Q\229h\DC19I\201\190>\230\164\181\242q51",SubOptions {_retainHandling = SendOnSubscribe, +// QoS0}),("f\169\228\149VWZ\202B'\230\219\143j\160GJ\187+\175\248;K\185",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\176O\235\183\144\ETX\224\ACK\173\237*\DLE\129\NUL\CAN\151",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\210\189\SI\243c",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\164\176\159\168\229\233v\159\v\223\227\158\207\190\216\187\203Z",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0xd0, 0x1, 0x72, 0xe5, 0x0, 0x1c, 0xd, 0xb1, 0xff, 0x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76, 0x9f, 0xb, 0xdf, 0xe3, 0x9e, - 0xcf, 0xbe, 0xd8, 0xbb, 0xcb, 0x5a, 0x2}; +// QoS0}),("`\ENQ\147P\ESC\152\157\138\168Qq\215\230\199\235I2[",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("X\148:\ENQ\215R\184\152\ACK\221\250\194\185W\248\155\FSI\t\132\251\148\146",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("v\189",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\145\160\130/\197z\202\198Uyv",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\176Xe",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\DC4\\d\168\230N\241",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode15) { + uint8_t pkt[] = {0x82, 0xc2, 0x1, 0x6f, 0xe6, 0x0, 0x17, 0xe0, 0x15, 0x5b, 0x8c, 0x96, 0x50, 0x77, 0xe6, 0x9a, 0x88, + 0x2c, 0x41, 0xec, 0x2b, 0x55, 0xc3, 0x73, 0x76, 0x89, 0x20, 0xa1, 0xfb, 0x4b, 0x2, 0x0, 0x18, 0xb1, + 0x36, 0xff, 0xd0, 0x36, 0x73, 0x35, 0xc4, 0xd5, 0x37, 0xf2, 0xac, 0xb, 0x3f, 0xe2, 0x5f, 0x7d, 0x20, + 0x72, 0x32, 0x5, 0x42, 0xe1, 0x88, 0x2, 0x0, 0x7, 0x2c, 0xb5, 0x54, 0x3, 0xa9, 0x26, 0x1, 0x0, + 0x0, 0x11, 0xe7, 0xb9, 0x13, 0xa2, 0x68, 0x8c, 0x5b, 0x26, 0x98, 0x41, 0x97, 0x9, 0x80, 0x9d, 0x7, + 0x8f, 0x53, 0x0, 0x0, 0x18, 0x66, 0xa9, 0xe4, 0x95, 0x56, 0x57, 0x5a, 0xca, 0x42, 0x27, 0xe6, 0xdb, + 0x8f, 0x6a, 0xa0, 0x47, 0x4a, 0xbb, 0x2b, 0xaf, 0xf8, 0x3b, 0x4b, 0xb9, 0x0, 0x0, 0x12, 0x60, 0x5, + 0x93, 0x50, 0x1b, 0x98, 0x9d, 0x8a, 0xa8, 0x51, 0x71, 0xd7, 0xe6, 0xc7, 0xeb, 0x49, 0x32, 0x5b, 0x2, + 0x0, 0x17, 0x58, 0x94, 0x3a, 0x5, 0xd7, 0x52, 0xb8, 0x98, 0x6, 0xdd, 0xfa, 0xc2, 0xb9, 0x57, 0xf8, + 0x9b, 0x1c, 0x49, 0x9, 0x84, 0xfb, 0x94, 0x92, 0x0, 0x0, 0x2, 0x76, 0xbd, 0x2, 0x0, 0xb, 0x91, + 0xa0, 0x82, 0x2f, 0xc5, 0x7a, 0xca, 0xc6, 0x55, 0x79, 0x76, 0x2, 0x0, 0x3, 0xb0, 0x58, 0x65, 0x2, + 0x0, 0x7, 0x14, 0x5c, 0x64, 0xa8, 0xe6, 0x4e, 0xf1, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd, 0xb1, 0xff, 0x38, 0xcd, 0x54, 0xdc, 0xdd, 0xc8, 0x49, - 0x87, 0xb3, 0x0, 0x8, 0x26, 0xd2, 0x3c, 0xa0, 0x76, 0x8b, - 0xae, 0x95, 0x70, 0xe2, 0x31, 0x2, 0xe3, 0xaa}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xe0, 0x15, 0x5b, 0x8c, 0x96, 0x50, 0x77, 0xe6, 0x9a, 0x88, 0x2c, 0x41, + 0xec, 0x2b, 0x55, 0xc3, 0x73, 0x76, 0x89, 0x20, 0xa1, 0xfb, 0x4b}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x15, 0x52, 0x4c, 0x69, 0xe, 0x21}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb1, 0x36, 0xff, 0xd0, 0x36, 0x73, 0x35, 0xc4, 0xd5, 0x37, 0xf2, 0xac, + 0xb, 0x3f, 0xe2, 0x5f, 0x7d, 0x20, 0x72, 0x32, 0x5, 0x42, 0xe1, 0x88}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5e, 0x24, 0xc3, 0xdd, 0x71, 0x59, 0x74, - 0x4b, 0x31, 0xa5, 0x6c, 0x59, 0xe6, 0xff}; - lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2c, 0xb5, 0x54, 0x3, 0xa9, 0x26, 0x1}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1d, 0xa4, 0xba, 0x96, 0xbf, 0xd, 0x9, 0x6f, 0xbd, 0xbe, 0x96, 0xb7, 0x29, - 0x29, 0x61, 0x19, 0xeb, 0x12, 0x42, 0x5c, 0xd7, 0x47, 0xed, 0x3a, 0xa1}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xe7, 0xb9, 0x13, 0xa2, 0x68, 0x8c, 0x5b, 0x26, 0x98, + 0x41, 0x97, 0x9, 0x80, 0x9d, 0x7, 0x8f, 0x53}; + lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x67, 0xb9, 0xe4, 0x5b, 0x11, 0x25, 0x36, 0x1c, 0x24, 0xfb, 0xef, - 0xd2, 0x85, 0x95, 0xb8, 0x36, 0x31, 0x4, 0x53, 0x83, 0xbe, 0x93}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x66, 0xa9, 0xe4, 0x95, 0x56, 0x57, 0x5a, 0xca, 0x42, 0x27, 0xe6, 0xdb, + 0x8f, 0x6a, 0xa0, 0x47, 0x4a, 0xbb, 0x2b, 0xaf, 0xf8, 0x3b, 0x4b, 0xb9}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x34, 0x54, 0x42, 0xeb, 0x4b, 0xd7, 0x4e, 0x22, 0xc6, 0x3e, 0x4c, - 0xab, 0x72, 0x3a, 0x88, 0x80, 0x9, 0xa, 0x56, 0x31, 0x40, 0xce}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x60, 0x5, 0x93, 0x50, 0x1b, 0x98, 0x9d, 0x8a, 0xa8, + 0x51, 0x71, 0xd7, 0xe6, 0xc7, 0xeb, 0x49, 0x32, 0x5b}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x98, 0xb2, 0x18, 0xaf, 0x51, 0xe5, 0x68, 0x11, 0x39, 0x49, - 0xc9, 0xbe, 0x3e, 0xe6, 0xa4, 0xb5, 0xf2, 0x71, 0x35, 0x31}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x58, 0x94, 0x3a, 0x5, 0xd7, 0x52, 0xb8, 0x98, 0x6, 0xdd, 0xfa, 0xc2, + 0xb9, 0x57, 0xf8, 0x9b, 0x1c, 0x49, 0x9, 0x84, 0xfb, 0x94, 0x92}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb0, 0x4f, 0xeb, 0xb7, 0x90, 0x3, 0xe0, 0x6, - 0xad, 0xed, 0x2a, 0x10, 0x81, 0x0, 0x18, 0x97}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x76, 0xbd}; + lwmqtt_string_t topic_filter_s7 = {2, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd2, 0xbd, 0xf, 0xf3, 0x63}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x91, 0xa0, 0x82, 0x2f, 0xc5, 0x7a, 0xca, 0xc6, 0x55, 0x79, 0x76}; + lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa4, 0xb0, 0x9f, 0xa8, 0xe5, 0xe9, 0x76, 0x9f, 0xb, - 0xdf, 0xe3, 0x9e, 0xcf, 0xbe, 0xd8, 0xbb, 0xcb, 0x5a}; - lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0xb0, 0x58, 0x65}; + lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s10_bytes[] = {0x14, 0x5c, 0x64, 0xa8, 0xe6, 0x4e, 0xf1}; + lwmqtt_string_t topic_filter_s10 = {7, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11454,7 +11346,7 @@ TEST(Subscribe311QCTest, Encode16) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -11462,23 +11354,23 @@ TEST(Subscribe311QCTest, Encode16) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].qos = LWMQTT_QOS2; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; @@ -11486,57 +11378,90 @@ TEST(Subscribe311QCTest, Encode16) { sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29413, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28646, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 6204 [("O\CAN\197/\176M5\196\CAN\225\129Lt\140(",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 31174 [(":\243\230#\164\248!\232\150\150+\138m\198\212\"\193f\129\SOH}K\195\171\150",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("4`MS\232\255\169oP\EOT\RS\198P\250r2\135\v\183FW\STX)\173",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\182\157\155]\RS\202Z\206F\192\t\240bW\211\158\163b\219\147F3>",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\173U\245\ACK\156A\ENQ\208\187\208\DELX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\188\246\170$\240\EM",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("K\167{\179J\RS\NAK3=*T4\208*\145\228\198h\252\246\248\a",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\"~R\129\189*P\134\186\ETB\222\230\&4\168^\237\146\ACK\240\190q\205\153U\SOH^|H",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode17) { - uint8_t pkt[] = {0x82, 0x65, 0x18, 0x3c, 0x0, 0xf, 0x4f, 0x18, 0xc5, 0x2f, 0xb0, 0x4d, 0x35, 0xc4, 0x18, - 0xe1, 0x81, 0x4c, 0x74, 0x8c, 0x28, 0x2, 0x0, 0x17, 0xb6, 0x9d, 0x9b, 0x5d, 0x1e, 0xca, - 0x5a, 0xce, 0x46, 0xc0, 0x9, 0xf0, 0x62, 0x57, 0xd3, 0x9e, 0xa3, 0x62, 0xdb, 0x93, 0x46, - 0x33, 0x3e, 0x2, 0x0, 0xc, 0xad, 0x55, 0xf5, 0x6, 0x9c, 0x41, 0x5, 0xd0, 0xbb, 0xd0, - 0x7f, 0x58, 0x1, 0x0, 0x6, 0xbc, 0xf6, 0xaa, 0x24, 0xf0, 0x19, 0x0, 0x0, 0x1c, 0x22, - 0x7e, 0x52, 0x81, 0xbd, 0x2a, 0x50, 0x86, 0xba, 0x17, 0xde, 0xe6, 0x34, 0xa8, 0x5e, 0xed, - 0x92, 0x6, 0xf0, 0xbe, 0x71, 0xcd, 0x99, 0x55, 0x1, 0x5e, 0x7c, 0x48, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x4f, 0x18, 0xc5, 0x2f, 0xb0, 0x4d, 0x35, 0xc4, - 0x18, 0xe1, 0x81, 0x4c, 0x74, 0x8c, 0x28}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; +// QoS0}),("\ETB\245\174A\225F\225\216j\197\147B\t\254\132\216\164\205\150K$\164lT\ETX\212mRv",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\180Sg\a&R\165\162\174g\178\253\GS*\197i\USu_&\229\201\131d\169\231@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\184l\ETX\225\&2\130\189\132\DC22N9\214\175@\197M\241/X#\ACKQ0\250q\DC4\r",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\253C7\NAK\203#\170",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\133\213\133\SUB\235\254\194\&5\223\143\241-\SUB\177n\233\211{\FSE",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode16) { + uint8_t pkt[] = {0x82, 0xd3, 0x1, 0x79, 0xc6, 0x0, 0x19, 0x3a, 0xf3, 0xe6, 0x23, 0xa4, 0xf8, 0x21, 0xe8, 0x96, 0x96, + 0x2b, 0x8a, 0x6d, 0xc6, 0xd4, 0x22, 0xc1, 0x66, 0x81, 0x1, 0x7d, 0x4b, 0xc3, 0xab, 0x96, 0x2, 0x0, + 0x18, 0x34, 0x60, 0x4d, 0x53, 0xe8, 0xff, 0xa9, 0x6f, 0x50, 0x4, 0x1e, 0xc6, 0x50, 0xfa, 0x72, 0x32, + 0x87, 0xb, 0xb7, 0x46, 0x57, 0x2, 0x29, 0xad, 0x2, 0x0, 0x16, 0x4b, 0xa7, 0x7b, 0xb3, 0x4a, 0x1e, + 0x15, 0x33, 0x3d, 0x2a, 0x54, 0x34, 0xd0, 0x2a, 0x91, 0xe4, 0xc6, 0x68, 0xfc, 0xf6, 0xf8, 0x7, 0x0, + 0x0, 0x1d, 0x17, 0xf5, 0xae, 0x41, 0xe1, 0x46, 0xe1, 0xd8, 0x6a, 0xc5, 0x93, 0x42, 0x9, 0xfe, 0x84, + 0xd8, 0xa4, 0xcd, 0x96, 0x4b, 0x24, 0xa4, 0x6c, 0x54, 0x3, 0xd4, 0x6d, 0x52, 0x76, 0x2, 0x0, 0x1b, + 0xb4, 0x53, 0x67, 0x7, 0x26, 0x52, 0xa5, 0xa2, 0xae, 0x67, 0xb2, 0xfd, 0x1d, 0x2a, 0xc5, 0x69, 0x1f, + 0x75, 0x5f, 0x26, 0xe5, 0xc9, 0x83, 0x64, 0xa9, 0xe7, 0x40, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1c, 0xb8, + 0x6c, 0x3, 0xe1, 0x32, 0x82, 0xbd, 0x84, 0x12, 0x32, 0x4e, 0x39, 0xd6, 0xaf, 0x40, 0xc5, 0x4d, 0xf1, + 0x2f, 0x58, 0x23, 0x6, 0x51, 0x30, 0xfa, 0x71, 0x14, 0xd, 0x0, 0x0, 0x7, 0xfd, 0x43, 0x37, 0x15, + 0xcb, 0x23, 0xaa, 0x0, 0x0, 0x14, 0x85, 0xd5, 0x85, 0x1a, 0xeb, 0xfe, 0xc2, 0x35, 0xdf, 0x8f, 0xf1, + 0x2d, 0x1a, 0xb1, 0x6e, 0xe9, 0xd3, 0x7b, 0x1c, 0x45, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x3a, 0xf3, 0xe6, 0x23, 0xa4, 0xf8, 0x21, 0xe8, 0x96, 0x96, 0x2b, 0x8a, 0x6d, + 0xc6, 0xd4, 0x22, 0xc1, 0x66, 0x81, 0x1, 0x7d, 0x4b, 0xc3, 0xab, 0x96}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb6, 0x9d, 0x9b, 0x5d, 0x1e, 0xca, 0x5a, 0xce, 0x46, 0xc0, 0x9, 0xf0, - 0x62, 0x57, 0xd3, 0x9e, 0xa3, 0x62, 0xdb, 0x93, 0x46, 0x33, 0x3e}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x34, 0x60, 0x4d, 0x53, 0xe8, 0xff, 0xa9, 0x6f, 0x50, 0x4, 0x1e, 0xc6, + 0x50, 0xfa, 0x72, 0x32, 0x87, 0xb, 0xb7, 0x46, 0x57, 0x2, 0x29, 0xad}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xad, 0x55, 0xf5, 0x6, 0x9c, 0x41, 0x5, 0xd0, 0xbb, 0xd0, 0x7f, 0x58}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4b, 0xa7, 0x7b, 0xb3, 0x4a, 0x1e, 0x15, 0x33, 0x3d, 0x2a, 0x54, + 0x34, 0xd0, 0x2a, 0x91, 0xe4, 0xc6, 0x68, 0xfc, 0xf6, 0xf8, 0x7}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xbc, 0xf6, 0xaa, 0x24, 0xf0, 0x19}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x17, 0xf5, 0xae, 0x41, 0xe1, 0x46, 0xe1, 0xd8, 0x6a, 0xc5, + 0x93, 0x42, 0x9, 0xfe, 0x84, 0xd8, 0xa4, 0xcd, 0x96, 0x4b, + 0x24, 0xa4, 0x6c, 0x54, 0x3, 0xd4, 0x6d, 0x52, 0x76}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x22, 0x7e, 0x52, 0x81, 0xbd, 0x2a, 0x50, 0x86, 0xba, 0x17, - 0xde, 0xe6, 0x34, 0xa8, 0x5e, 0xed, 0x92, 0x6, 0xf0, 0xbe, - 0x71, 0xcd, 0x99, 0x55, 0x1, 0x5e, 0x7c, 0x48}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xb4, 0x53, 0x67, 0x7, 0x26, 0x52, 0xa5, 0xa2, 0xae, 0x67, 0xb2, 0xfd, 0x1d, 0x2a, + 0xc5, 0x69, 0x1f, 0x75, 0x5f, 0x26, 0xe5, 0xc9, 0x83, 0x64, 0xa9, 0xe7, 0x40}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xb8, 0x6c, 0x3, 0xe1, 0x32, 0x82, 0xbd, 0x84, 0x12, 0x32, 0x4e, 0x39, 0xd6, 0xaf, + 0x40, 0xc5, 0x4d, 0xf1, 0x2f, 0x58, 0x23, 0x6, 0x51, 0x30, 0xfa, 0x71, 0x14, 0xd}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xfd, 0x43, 0x37, 0x15, 0xcb, 0x23, 0xaa}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x85, 0xd5, 0x85, 0x1a, 0xeb, 0xfe, 0xc2, 0x35, 0xdf, 0x8f, + 0xf1, 0x2d, 0x1a, 0xb1, 0x6e, 0xe9, 0xd3, 0x7b, 0x1c, 0x45}; + lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -11545,11 +11470,11 @@ TEST(Subscribe311QCTest, Encode17) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -11557,44 +11482,63 @@ TEST(Subscribe311QCTest, Encode17) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6204, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31174, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8030 [("\234\190\DEL\176\250cyY\218\176\196\212\214",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\153\174",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\185D\196\STX\DC3\194\198\144\b\211h\192\175\SI\250aJ\177\167",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("6\ETB\STXr\219j\151-\227",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode18) { - uint8_t pkt[] = {0x82, 0x39, 0x1f, 0x5e, 0x0, 0xd, 0xea, 0xbe, 0x7f, 0xb0, 0xfa, 0x63, 0x79, 0x59, 0xda, - 0xb0, 0xc4, 0xd4, 0xd6, 0x2, 0x0, 0x2, 0x99, 0xae, 0x1, 0x0, 0x13, 0xb9, 0x44, 0xc4, - 0x2, 0x13, 0xc2, 0xc6, 0x90, 0x8, 0xd3, 0x68, 0xc0, 0xaf, 0xf, 0xfa, 0x61, 0x4a, 0xb1, - 0xa7, 0x1, 0x0, 0x9, 0x36, 0x17, 0x2, 0x72, 0xdb, 0x6a, 0x97, 0x2d, 0xe3, 0x0}; +// SubscribeRequest 2900 [("\249J\154\194\178Mb\255\165\234\213K\141%\167\ESC\151\152\176\236\214",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("7\144\f>\ACKS$|\SI",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = +// QoS2}),("v\150\SO\163x\160B\220\209E\217\185\166\NAK\216\248(\172\194\189",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode22) { - uint8_t pkt[] = { - 0x82, 0xe0, 0x1, 0x1f, 0x3a, 0x0, 0x8, 0x77, 0xf8, 0x42, 0x6a, 0x17, 0x12, 0xe2, 0x55, 0x0, 0x0, 0x3, 0xbe, - 0xd9, 0x5b, 0x1, 0x0, 0x17, 0x34, 0x2f, 0xe1, 0xaf, 0x34, 0xb9, 0x35, 0x6a, 0xe4, 0xc3, 0xd9, 0xb8, 0x8e, 0x91, - 0x28, 0x37, 0x25, 0xa5, 0x66, 0x62, 0x5d, 0x9c, 0x2, 0x2, 0x0, 0x19, 0x83, 0x9c, 0xe1, 0x94, 0xb0, 0x4f, 0x35, - 0x3, 0xd5, 0xda, 0xd6, 0xae, 0xd6, 0x53, 0xf2, 0xc6, 0x59, 0x98, 0x32, 0x56, 0x25, 0xbc, 0xde, 0x1d, 0x38, 0x2, - 0x0, 0x1b, 0x31, 0x1f, 0xb0, 0x29, 0x16, 0x33, 0xe, 0xa, 0xa, 0x34, 0x72, 0xbc, 0xa5, 0x76, 0x6a, 0xd8, 0xbb, - 0x5d, 0x25, 0xf3, 0x32, 0x34, 0x34, 0x16, 0xba, 0xa6, 0xd, 0x1, 0x0, 0x15, 0xaa, 0x3a, 0xc5, 0xcf, 0xfe, 0x10, - 0xda, 0x63, 0xd, 0x86, 0xb8, 0xeb, 0x0, 0x71, 0x3f, 0xae, 0x92, 0x42, 0xe3, 0xf0, 0xd3, 0x2, 0x0, 0xf, 0x97, - 0xed, 0x48, 0xd7, 0x4d, 0x97, 0x14, 0x90, 0xe4, 0xb4, 0x63, 0xd2, 0xb, 0xc3, 0xfb, 0x0, 0x0, 0x1a, 0xa2, 0xff, - 0xfc, 0x11, 0x37, 0x8a, 0x33, 0x2e, 0x9f, 0x57, 0xef, 0xed, 0x7b, 0x5a, 0x2f, 0x54, 0xe, 0x84, 0xf6, 0xfb, 0xaa, - 0xf3, 0xba, 0xa2, 0xb1, 0x37, 0x2, 0x0, 0x1c, 0xe1, 0x29, 0x75, 0x1a, 0xb5, 0x23, 0x17, 0x84, 0x20, 0xd4, 0xee, - 0x47, 0x39, 0x7b, 0x7c, 0x2d, 0x7b, 0x68, 0x3a, 0x40, 0x72, 0x30, 0xba, 0x72, 0x14, 0xd6, 0xe1, 0x34, 0x1, 0x0, - 0x2, 0x6c, 0x24, 0x1, 0x0, 0xb, 0x3e, 0xd9, 0xb9, 0xa6, 0x15, 0xd8, 0xf8, 0x28, 0xac, 0xc2, 0xbd, 0x1}; +// QoS1}),("{\186\SIi\DLE\171\225\241\&6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("~J\231\169\143\142y\137\254m\135\249\196X\DC4J",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode20) { + uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x46, 0x21, 0x0, 0x5, 0xe6, 0x18, 0x9d, 0x2c, 0x51, 0x2, 0x0, 0x1, 0x57, + 0x1, 0x0, 0x12, 0x31, 0x2f, 0xda, 0x6b, 0x1, 0xc1, 0xea, 0xb0, 0x7a, 0x66, 0x42, 0xd7, 0xa6, + 0x2b, 0x11, 0x52, 0x7a, 0x63, 0x2, 0x0, 0x9, 0x3f, 0x4e, 0xdf, 0x34, 0x3c, 0xa7, 0xae, 0xde, + 0x34, 0x1, 0x0, 0x1e, 0xed, 0xb, 0xef, 0xf3, 0xaa, 0x30, 0x87, 0x90, 0xb2, 0x2a, 0x92, 0xc2, + 0x69, 0x66, 0x1f, 0xcb, 0x39, 0x27, 0xac, 0xa6, 0x7c, 0x80, 0x81, 0x6d, 0xbc, 0x7c, 0x6c, 0x8d, + 0x69, 0xa4, 0x0, 0x0, 0xa, 0xee, 0xe8, 0xb, 0x5, 0x20, 0xef, 0x1, 0x95, 0x9f, 0x50, 0x1, + 0x0, 0x17, 0xbf, 0xd9, 0x8b, 0x54, 0x21, 0x49, 0x74, 0xbc, 0x1e, 0x19, 0xf6, 0xab, 0xac, 0x86, + 0x75, 0xea, 0xaa, 0xa8, 0x52, 0xb9, 0x8b, 0xe5, 0x1b, 0x1, 0x0, 0x9, 0x7b, 0xba, 0xf, 0x69, + 0x10, 0xab, 0xe1, 0xf1, 0x36, 0x2, 0x0, 0x1, 0xa6, 0x0, 0x0, 0x0, 0x2, 0x0, 0x10, 0x7e, + 0x4a, 0xe7, 0xa9, 0x8f, 0x8e, 0x79, 0x89, 0xfe, 0x6d, 0x87, 0xf9, 0xc4, 0x58, 0x14, 0x4a, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x77, 0xf8, 0x42, 0x6a, 0x17, 0x12, 0xe2, 0x55}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xe6, 0x18, 0x9d, 0x2c, 0x51}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbe, 0xd9, 0x5b}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x57}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x34, 0x2f, 0xe1, 0xaf, 0x34, 0xb9, 0x35, 0x6a, 0xe4, 0xc3, 0xd9, 0xb8, - 0x8e, 0x91, 0x28, 0x37, 0x25, 0xa5, 0x66, 0x62, 0x5d, 0x9c, 0x2}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x31, 0x2f, 0xda, 0x6b, 0x1, 0xc1, 0xea, 0xb0, 0x7a, + 0x66, 0x42, 0xd7, 0xa6, 0x2b, 0x11, 0x52, 0x7a, 0x63}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x83, 0x9c, 0xe1, 0x94, 0xb0, 0x4f, 0x35, 0x3, 0xd5, 0xda, 0xd6, 0xae, 0xd6, - 0x53, 0xf2, 0xc6, 0x59, 0x98, 0x32, 0x56, 0x25, 0xbc, 0xde, 0x1d, 0x38}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3f, 0x4e, 0xdf, 0x34, 0x3c, 0xa7, 0xae, 0xde, 0x34}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x31, 0x1f, 0xb0, 0x29, 0x16, 0x33, 0xe, 0xa, 0xa, 0x34, 0x72, 0xbc, 0xa5, 0x76, - 0x6a, 0xd8, 0xbb, 0x5d, 0x25, 0xf3, 0x32, 0x34, 0x34, 0x16, 0xba, 0xa6, 0xd}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xed, 0xb, 0xef, 0xf3, 0xaa, 0x30, 0x87, 0x90, 0xb2, 0x2a, + 0x92, 0xc2, 0x69, 0x66, 0x1f, 0xcb, 0x39, 0x27, 0xac, 0xa6, + 0x7c, 0x80, 0x81, 0x6d, 0xbc, 0x7c, 0x6c, 0x8d, 0x69, 0xa4}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xaa, 0x3a, 0xc5, 0xcf, 0xfe, 0x10, 0xda, 0x63, 0xd, 0x86, 0xb8, - 0xeb, 0x0, 0x71, 0x3f, 0xae, 0x92, 0x42, 0xe3, 0xf0, 0xd3}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xee, 0xe8, 0xb, 0x5, 0x20, 0xef, 0x1, 0x95, 0x9f, 0x50}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x97, 0xed, 0x48, 0xd7, 0x4d, 0x97, 0x14, 0x90, - 0xe4, 0xb4, 0x63, 0xd2, 0xb, 0xc3, 0xfb}; - lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xbf, 0xd9, 0x8b, 0x54, 0x21, 0x49, 0x74, 0xbc, 0x1e, 0x19, 0xf6, 0xab, + 0xac, 0x86, 0x75, 0xea, 0xaa, 0xa8, 0x52, 0xb9, 0x8b, 0xe5, 0x1b}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa2, 0xff, 0xfc, 0x11, 0x37, 0x8a, 0x33, 0x2e, 0x9f, 0x57, 0xef, 0xed, 0x7b, - 0x5a, 0x2f, 0x54, 0xe, 0x84, 0xf6, 0xfb, 0xaa, 0xf3, 0xba, 0xa2, 0xb1, 0x37}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x7b, 0xba, 0xf, 0x69, 0x10, 0xab, 0xe1, 0xf1, 0x36}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe1, 0x29, 0x75, 0x1a, 0xb5, 0x23, 0x17, 0x84, 0x20, 0xd4, - 0xee, 0x47, 0x39, 0x7b, 0x7c, 0x2d, 0x7b, 0x68, 0x3a, 0x40, - 0x72, 0x30, 0xba, 0x72, 0x14, 0xd6, 0xe1, 0x34}; - lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xa6}; + lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x6c, 0x24}; - lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0}; + lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x3e, 0xd9, 0xb9, 0xa6, 0x15, 0xd8, 0xf8, 0x28, 0xac, 0xc2, 0xbd}; - lwmqtt_string_t topic_filter_s10 = {11, (char*)&topic_filter_s10_bytes}; + uint8_t topic_filter_s10_bytes[] = {0x7e, 0x4a, 0xe7, 0xa9, 0x8f, 0x8e, 0x79, 0x89, + 0xfe, 0x6d, 0x87, 0xf9, 0xc4, 0x58, 0x14, 0x4a}; + lwmqtt_string_t topic_filter_s10 = {16, (char*)&topic_filter_s10_bytes}; topic_filters[10] = topic_filter_s10; lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11962,19 +11803,19 @@ TEST(Subscribe311QCTest, Encode22) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; @@ -11982,15 +11823,15 @@ TEST(Subscribe311QCTest, Encode22) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].qos = LWMQTT_QOS2; sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].qos = LWMQTT_QOS2; sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[10].retain_as_published = false; sub_opts[10].no_local = false; @@ -12000,80 +11841,91 @@ TEST(Subscribe311QCTest, Encode22) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7994, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17953, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23842 [("\140\185\224\250R\251\"\210\238\130\148\253\176\167\230\DELx%",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("k\157(%\238\144\NAK\133\246\206\163w\161\180x5X\SI\SYN(\130\224u\222\247\155\175\200",SubOptions +// SubscribeRequest 26518 [("\NULJ\205v\253\154",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("j\182X\235\201r\170\214\STX\134\241\201\150\253\226\SYN",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\188k9#!@s.\150+\ETBF\197\DC3i\159Z\197,\214\167\253\245\aE",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("ap\232$>@\178\148\vR\208\227\232\190\&0*N>\US\202\188",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("+\194\188\205\157\178\221\t\245\213\254W\129\251A\aV\219\210\b\229<\149\204&\201\196\182U",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\222\146\234\140\195c\209LL$\222\179\153\DEL\208\218\132\209\214%\139\228\230",SubOptions {_retainHandling = +// QoS2}),("+b\142\ETB/\213xA\202y\175i)\183\171\142Yw_\228\&2\170\156 \129",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\CAN\151aE\174\174\225\221%N\238d\SI\187",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode23) { - uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x5d, 0x22, 0x0, 0x12, 0x8c, 0xb9, 0xe0, 0xfa, 0x52, 0xfb, 0x22, 0xd2, 0xee, - 0x82, 0x94, 0xfd, 0xb0, 0xa7, 0xe6, 0x7f, 0x78, 0x25, 0x1, 0x0, 0x1c, 0x6b, 0x9d, 0x28, 0x25, - 0xee, 0x90, 0x15, 0x85, 0xf6, 0xce, 0xa3, 0x77, 0xa1, 0xb4, 0x78, 0x35, 0x58, 0xf, 0x16, 0x28, - 0x82, 0xe0, 0x75, 0xde, 0xf7, 0x9b, 0xaf, 0xc8, 0x0, 0x0, 0x19, 0xbc, 0x6b, 0x39, 0x23, 0x21, - 0x40, 0x73, 0x2e, 0x96, 0x2b, 0x17, 0x46, 0xc5, 0x13, 0x69, 0x9f, 0x5a, 0xc5, 0x2c, 0xd6, 0xa7, - 0xfd, 0xf5, 0x7, 0x45, 0x0, 0x0, 0x1d, 0x2b, 0xc2, 0xbc, 0xcd, 0x9d, 0xb2, 0xdd, 0x9, 0xf5, - 0xd5, 0xfe, 0x57, 0x81, 0xfb, 0x41, 0x7, 0x56, 0xdb, 0xd2, 0x8, 0xe5, 0x3c, 0x95, 0xcc, 0x26, - 0xc9, 0xc4, 0xb6, 0x55, 0x2, 0x0, 0x17, 0xde, 0x92, 0xea, 0x8c, 0xc3, 0x63, 0xd1, 0x4c, 0x4c, - 0x24, 0xde, 0xb3, 0x99, 0x7f, 0xd0, 0xda, 0x84, 0xd1, 0xd6, 0x25, 0x8b, 0xe4, 0xe6, 0x1, 0x0, - 0xe, 0x18, 0x97, 0x61, 0x45, 0xae, 0xae, 0xe1, 0xdd, 0x25, 0x4e, 0xee, 0x64, 0xf, 0xbb, 0x2}; +// QoS0}),("A\187\CAN\243\184\211b\170\231tK\171\170R\216Gw\149i\252\163\&4U\209\180\245\226\249-\209\158\&5\245\NUL\234\DC10\214",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\218\246\226&[\153t\186\250\SI\199\252\144\201\139\191U?\SI\207?Q",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\242x\138*\224\132\237\229\218\231\&4\189|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DLE\EOT\229e\SO\165\202\190",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode22) { + uint8_t pkt[] = {0x82, 0x7f, 0x5b, 0xe3, 0x0, 0xc, 0x3a, 0x5a, 0xfd, 0xb3, 0xf6, 0x69, 0x9, 0x43, 0x14, 0xe1, 0xf4, + 0x6f, 0x0, 0x0, 0x11, 0x90, 0xf2, 0xf2, 0x38, 0xdf, 0x89, 0x70, 0x4c, 0x72, 0x43, 0xa9, 0xe9, 0x8e, + 0xcd, 0x3b, 0x50, 0xe3, 0x1, 0x0, 0x2, 0x5c, 0x9, 0x0, 0x0, 0x1b, 0x99, 0x24, 0xd1, 0x73, 0xce, + 0x76, 0x3e, 0x69, 0xfc, 0xa3, 0x34, 0x55, 0xd1, 0xb4, 0xf5, 0xe2, 0xf9, 0x2d, 0xd1, 0x9e, 0x35, 0xf5, + 0x0, 0xea, 0x11, 0x30, 0xd6, 0x1, 0x0, 0x0, 0x1, 0x0, 0x16, 0xda, 0xf6, 0xe2, 0x26, 0x5b, 0x99, + 0x74, 0xba, 0xfa, 0xf, 0xc7, 0xfc, 0x90, 0xc9, 0x8b, 0xbf, 0x55, 0x3f, 0xf, 0xcf, 0x3f, 0x51, 0x1, + 0x0, 0xd, 0xf2, 0x78, 0x8a, 0x2a, 0xe0, 0x84, 0xed, 0xe5, 0xda, 0xe7, 0x34, 0xbd, 0x7c, 0x2, 0x0, + 0x8, 0x10, 0x4, 0xe5, 0x65, 0xe, 0xa5, 0xca, 0xbe, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x4b, 0x33, 0xf, 0x91, 0x36, 0x4e, 0x98, 0xcd, 0xcf, 0xd3, 0xaf, 0xe2, 0x28}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x3a, 0x5a, 0xfd, 0xb3, 0xf6, 0x69, 0x9, 0x43, 0x14, 0xe1, 0xf4, 0x6f}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe8, 0x30, 0x1b, 0x31, 0x20, 0x7c, 0xc5, 0x94, 0x38, 0xe1, 0x18, 0x2a, 0xe5}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x90, 0xf2, 0xf2, 0x38, 0xdf, 0x89, 0x70, 0x4c, 0x72, + 0x43, 0xa9, 0xe9, 0x8e, 0xcd, 0x3b, 0x50, 0xe3}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; + uint8_t topic_filter_s2_bytes[] = {0x5c, 0x9}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x99, 0x24, 0xd1, 0x73, 0xce, 0x76, 0x3e, 0x69, 0xfc, 0xa3, 0x34, 0x55, 0xd1, 0xb4, + 0xf5, 0xe2, 0xf9, 0x2d, 0xd1, 0x9e, 0x35, 0xf5, 0x0, 0xea, 0x11, 0x30, 0xd6}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xda, 0xf6, 0xe2, 0x26, 0x5b, 0x99, 0x74, 0xba, 0xfa, 0xf, 0xc7, + 0xfc, 0x90, 0xc9, 0x8b, 0xbf, 0x55, 0x3f, 0xf, 0xcf, 0x3f, 0x51}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xf2, 0x78, 0x8a, 0x2a, 0xe0, 0x84, 0xed, 0xe5, 0xda, 0xe7, 0x34, 0xbd, 0x7c}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x10, 0x4, 0xe5, 0x65, 0xe, 0xa5, 0xca, 0xbe}; + lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26921, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23523, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21060 [("|\157\247\167%X\146\239\FSa@\163\225",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(".\147\177\f\201\211\245\229\237\RS",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\EOT\149z\193\&2\140\137\131\155#}#h\153\&4",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("oo\189n\216\174\b[\219d\225\166\b\146^/\138\130\132[\235",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\176\&5\141\&1\143<\138xIV~\187\\\234\250Sa\US\240\219w8vTXw",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\164\153\198\218k\176b\231\SO",SubOptions +// SubscribeRequest 10563 [("\168\239",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("b\DC2\247\191\181;_\144\ETX9R\f\212\n*;",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("M\245\139sC\176\233\&4\SI\136\188%\219\r\ENQ\SOS\142%*R8\171\v\149\180\155",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("F\143\188\229\139~\201\n\GSVs\v",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("M\203\202\148\227\243\227S\239h\b\165\&3\230\DC4B\DEL",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Y\156\203\236\EOT\225\149\165[\246\158\US(\248",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\140\170^\229\250K\220\216\241\233\146\"",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0x92, 0x1, 0x52, 0x44, 0x0, 0xd, 0x7c, 0x9d, 0xf7, 0xa7, 0x25, 0x58, 0x92, 0xef, 0x1c, 0x61, - 0x40, 0xa3, 0xe1, 0x1, 0x0, 0xa, 0x2e, 0x93, 0xb1, 0xc, 0xc9, 0xd3, 0xf5, 0xe5, 0xed, 0x1e, 0x1, - 0x0, 0xf, 0x4, 0x95, 0x7a, 0xc1, 0x32, 0x8c, 0x89, 0x83, 0x9b, 0x23, 0x7d, 0x23, 0x68, 0x99, 0x34, - 0x1, 0x0, 0x15, 0x6f, 0x6f, 0xbd, 0x6e, 0xd8, 0xae, 0x8, 0x5b, 0xdb, 0x64, 0xe1, 0xa6, 0x8, 0x92, - 0x5e, 0x2f, 0x8a, 0x82, 0x84, 0x5b, 0xeb, 0x2, 0x0, 0x1a, 0xb0, 0x35, 0x8d, 0x31, 0x8f, 0x3c, 0x8a, - 0x78, 0x49, 0x56, 0x7e, 0xbb, 0x5c, 0xea, 0xfa, 0x53, 0x61, 0x1f, 0xf0, 0xdb, 0x77, 0x38, 0x76, 0x54, - 0x58, 0x77, 0x1, 0x0, 0x9, 0xa4, 0x99, 0xc6, 0xda, 0x6b, 0xb0, 0x62, 0xe7, 0xe, 0x2, 0x0, 0xe, - 0x59, 0x9c, 0xcb, 0xec, 0x4, 0xe1, 0x95, 0xa5, 0x5b, 0xf6, 0x9e, 0x1f, 0x28, 0xf8, 0x2, 0x0, 0xc, - 0x8c, 0xaa, 0x5e, 0xe5, 0xfa, 0x4b, 0xdc, 0xd8, 0xf1, 0xe9, 0x92, 0x22, 0x0}; +// QoS2}),("\200\DC1P\EOT&",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\200k\212;\251\194\248\153",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("s\233\DEL\210\244\r\226\142\130\195R",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\228\164;\SUB'C\EM\168\199Z\168Yb\SO\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\210|7\DC3\f}\178\DC4\141\DC2\204\NUL\231\224\SOH|}",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0xa5, 0x1, 0x29, 0x43, 0x0, 0x2, 0xa8, 0xef, 0x0, 0x0, 0x10, 0x62, 0x12, 0xf7, 0xbf, 0xb5, + 0x3b, 0x5f, 0x90, 0x3, 0x39, 0x52, 0xc, 0xd4, 0xa, 0x2a, 0x3b, 0x1, 0x0, 0x1b, 0x4d, 0xf5, 0x8b, + 0x73, 0x43, 0xb0, 0xe9, 0x34, 0xf, 0x88, 0xbc, 0x25, 0xdb, 0xd, 0x5, 0xe, 0x53, 0x8e, 0x25, 0x2a, + 0x52, 0x38, 0xab, 0xb, 0x95, 0xb4, 0x9b, 0x1, 0x0, 0xc, 0x46, 0x8f, 0xbc, 0xe5, 0x8b, 0x7e, 0xc9, + 0xa, 0x1d, 0x56, 0x73, 0xb, 0x0, 0x0, 0x11, 0x4d, 0xcb, 0xca, 0x94, 0xe3, 0xf3, 0xe3, 0x53, 0xef, + 0x68, 0x8, 0xa5, 0x33, 0xe6, 0x14, 0x42, 0x7f, 0x2, 0x0, 0x5, 0xc8, 0x11, 0x50, 0x4, 0x26, 0x1, + 0x0, 0x8, 0xc8, 0x6b, 0xd4, 0x3b, 0xfb, 0xc2, 0xf8, 0x99, 0x2, 0x0, 0xb, 0x73, 0xe9, 0x7f, 0xd2, + 0xf4, 0xd, 0xe2, 0x8e, 0x82, 0xc3, 0x52, 0x2, 0x0, 0xf, 0xe4, 0xa4, 0x3b, 0x1a, 0x27, 0x43, 0x19, + 0xa8, 0xc7, 0x5a, 0xa8, 0x59, 0x62, 0xe, 0x19, 0x0, 0x0, 0x11, 0xd2, 0x7c, 0x37, 0x13, 0xc, 0x7d, + 0xb2, 0x14, 0x8d, 0x12, 0xcc, 0x0, 0xe7, 0xe0, 0x1, 0x7c, 0x7d, 0x0, 0x0, 0x0, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x7c, 0x9d, 0xf7, 0xa7, 0x25, 0x58, 0x92, 0xef, 0x1c, 0x61, 0x40, 0xa3, 0xe1}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xa8, 0xef}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2e, 0x93, 0xb1, 0xc, 0xc9, 0xd3, 0xf5, 0xe5, 0xed, 0x1e}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x62, 0x12, 0xf7, 0xbf, 0xb5, 0x3b, 0x5f, 0x90, + 0x3, 0x39, 0x52, 0xc, 0xd4, 0xa, 0x2a, 0x3b}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4, 0x95, 0x7a, 0xc1, 0x32, 0x8c, 0x89, 0x83, - 0x9b, 0x23, 0x7d, 0x23, 0x68, 0x99, 0x34}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4d, 0xf5, 0x8b, 0x73, 0x43, 0xb0, 0xe9, 0x34, 0xf, 0x88, 0xbc, 0x25, 0xdb, 0xd, + 0x5, 0xe, 0x53, 0x8e, 0x25, 0x2a, 0x52, 0x38, 0xab, 0xb, 0x95, 0xb4, 0x9b}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6f, 0x6f, 0xbd, 0x6e, 0xd8, 0xae, 0x8, 0x5b, 0xdb, 0x64, 0xe1, - 0xa6, 0x8, 0x92, 0x5e, 0x2f, 0x8a, 0x82, 0x84, 0x5b, 0xeb}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x46, 0x8f, 0xbc, 0xe5, 0x8b, 0x7e, 0xc9, 0xa, 0x1d, 0x56, 0x73, 0xb}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb0, 0x35, 0x8d, 0x31, 0x8f, 0x3c, 0x8a, 0x78, 0x49, 0x56, 0x7e, 0xbb, 0x5c, - 0xea, 0xfa, 0x53, 0x61, 0x1f, 0xf0, 0xdb, 0x77, 0x38, 0x76, 0x54, 0x58, 0x77}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x4d, 0xcb, 0xca, 0x94, 0xe3, 0xf3, 0xe3, 0x53, 0xef, + 0x68, 0x8, 0xa5, 0x33, 0xe6, 0x14, 0x42, 0x7f}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa4, 0x99, 0xc6, 0xda, 0x6b, 0xb0, 0x62, 0xe7, 0xe}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xc8, 0x11, 0x50, 0x4, 0x26}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x59, 0x9c, 0xcb, 0xec, 0x4, 0xe1, 0x95, 0xa5, 0x5b, 0xf6, 0x9e, 0x1f, 0x28, 0xf8}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xc8, 0x6b, 0xd4, 0x3b, 0xfb, 0xc2, 0xf8, 0x99}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x8c, 0xaa, 0x5e, 0xe5, 0xfa, 0x4b, 0xdc, 0xd8, 0xf1, 0xe9, 0x92, 0x22}; - lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x73, 0xe9, 0x7f, 0xd2, 0xf4, 0xd, 0xe2, 0x8e, 0x82, 0xc3, 0x52}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s8_bytes[] = {0xe4, 0xa4, 0x3b, 0x1a, 0x27, 0x43, 0x19, 0xa8, + 0xc7, 0x5a, 0xa8, 0x59, 0x62, 0xe, 0x19}; + lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xd2, 0x7c, 0x37, 0x13, 0xc, 0x7d, 0xb2, 0x14, 0x8d, + 0x12, 0xcc, 0x0, 0xe7, 0xe0, 0x1, 0x7c, 0x7d}; + lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -12194,15 +12133,15 @@ TEST(Subscribe311QCTest, Encode25) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -12210,47 +12149,98 @@ TEST(Subscribe311QCTest, Encode25) { sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21060, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10563, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18677 [("=\161\253\230\ACK|8",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("$wX\204\158I\216\&9c\142@\195\248\186>\SUBi\SYN\165H\212\242\&3;",SubOptions {_retainHandling = +// SubscribeRequest 30451 [("%\173",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("u\167Z\ENQ\NUL\246F\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1}),("$Gw\252Le",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\195\180\153\189\221_ip\198\147\v\EM\182\215\RS\225D\173=oL",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\216y\n\207uS5\157\EM\SYN\182\169\188\154",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0}),("\235g\164\247p\SUB~D\219!:\SOH_\192",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\153\231\243Nc7\160^\177\204:\236\247\fCy\174\181\172\131A",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x3f, 0x48, 0xf5, 0x0, 0x7, 0x3d, 0xa1, 0xfd, 0xe6, 0x6, 0x7c, 0x38, 0x0, 0x0, 0x18, 0x24, - 0x77, 0x58, 0xcc, 0x9e, 0x49, 0xd8, 0x39, 0x63, 0x8e, 0x40, 0xc3, 0xf8, 0xba, 0x3e, 0x1a, 0x69, 0x16, - 0xa5, 0x48, 0xd4, 0xf2, 0x33, 0x3b, 0x1, 0x0, 0x15, 0x99, 0xe7, 0xf3, 0x4e, 0x63, 0x37, 0xa0, 0x5e, - 0xb1, 0xcc, 0x3a, 0xec, 0xf7, 0xc, 0x43, 0x79, 0xae, 0xb5, 0xac, 0x83, 0x41, 0x2}; +// QoS2}),("\226(\200\&7F\131\255\223q\178;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS1}),("\228\218\198\182\168j&\DC2y\249>\132\\>\f\225\180\212\vV\188\EOTTx\215",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ETX",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode24) { + uint8_t pkt[] = {0x82, 0x8a, 0x1, 0x76, 0xf3, 0x0, 0x2, 0x25, 0xad, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0xc5, + 0x1, 0x0, 0x8, 0x75, 0xa7, 0x5a, 0x5, 0x0, 0xf6, 0x46, 0xba, 0x1, 0x0, 0x6, 0x24, 0x47, + 0x77, 0xfc, 0x4c, 0x65, 0x2, 0x0, 0x15, 0xc3, 0xb4, 0x99, 0xbd, 0xdd, 0x5f, 0x69, 0x70, 0xc6, + 0x93, 0xb, 0x19, 0xb6, 0xd7, 0x1e, 0xe1, 0x44, 0xad, 0x3d, 0x6f, 0x4c, 0x0, 0x0, 0xe, 0xd8, + 0x79, 0xa, 0xcf, 0x75, 0x53, 0x35, 0x9d, 0x19, 0x16, 0xb6, 0xa9, 0xbc, 0x9a, 0x0, 0x0, 0xe, + 0xeb, 0x67, 0xa4, 0xf7, 0x70, 0x1a, 0x7e, 0x44, 0xdb, 0x21, 0x3a, 0x1, 0x5f, 0xc0, 0x2, 0x0, + 0xb, 0xe2, 0x28, 0xc8, 0x37, 0x46, 0x83, 0xff, 0xdf, 0x71, 0xb2, 0x3b, 0x1, 0x0, 0x19, 0xe4, + 0xda, 0xc6, 0xb6, 0xa8, 0x6a, 0x26, 0x12, 0x79, 0xf9, 0x3e, 0x84, 0x5c, 0x3e, 0xc, 0xe1, 0xb4, + 0xd4, 0xb, 0x56, 0xbc, 0x4, 0x54, 0x78, 0xd7, 0x0, 0x0, 0x1, 0x3, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x3d, 0xa1, 0xfd, 0xe6, 0x6, 0x7c, 0x38}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x25, 0xad}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x24, 0x77, 0x58, 0xcc, 0x9e, 0x49, 0xd8, 0x39, 0x63, 0x8e, 0x40, 0xc3, - 0xf8, 0xba, 0x3e, 0x1a, 0x69, 0x16, 0xa5, 0x48, 0xd4, 0xf2, 0x33, 0x3b}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x99, 0xe7, 0xf3, 0x4e, 0x63, 0x37, 0xa0, 0x5e, 0xb1, 0xcc, 0x3a, - 0xec, 0xf7, 0xc, 0x43, 0x79, 0xae, 0xb5, 0xac, 0x83, 0x41}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc5}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; + uint8_t topic_filter_s3_bytes[] = {0x75, 0xa7, 0x5a, 0x5, 0x0, 0xf6, 0x46, 0xba}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x24, 0x47, 0x77, 0xfc, 0x4c, 0x65}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xc3, 0xb4, 0x99, 0xbd, 0xdd, 0x5f, 0x69, 0x70, 0xc6, 0x93, 0xb, + 0x19, 0xb6, 0xd7, 0x1e, 0xe1, 0x44, 0xad, 0x3d, 0x6f, 0x4c}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xd8, 0x79, 0xa, 0xcf, 0x75, 0x53, 0x35, 0x9d, 0x19, 0x16, 0xb6, 0xa9, 0xbc, 0x9a}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xeb, 0x67, 0xa4, 0xf7, 0x70, 0x1a, 0x7e, 0x44, 0xdb, 0x21, 0x3a, 0x1, 0x5f, 0xc0}; + lwmqtt_string_t topic_filter_s7 = {14, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe2, 0x28, 0xc8, 0x37, 0x46, 0x83, 0xff, 0xdf, 0x71, 0xb2, 0x3b}; + lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe4, 0xda, 0xc6, 0xb6, 0xa8, 0x6a, 0x26, 0x12, 0x79, 0xf9, 0x3e, 0x84, 0x5c, + 0x3e, 0xc, 0xe1, 0xb4, 0xd4, 0xb, 0x56, 0xbc, 0x4, 0x54, 0x78, 0xd7}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x3}; + lwmqtt_string_t topic_filter_s10 = {1, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -12259,86 +12249,106 @@ TEST(Subscribe311QCTest, Encode26) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18677, 3, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 15426 [(">,\208\132\222\237\163V\189v\141\DC4<\218\135\r(U",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0x17, 0x3c, 0x42, 0x0, 0x12, 0x3e, 0x2c, 0xd0, 0x84, 0xde, 0xed, 0xa3, - 0x56, 0xbd, 0x76, 0x8d, 0x14, 0x3c, 0xda, 0x87, 0xd, 0x28, 0x55, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x3e, 0x2c, 0xd0, 0x84, 0xde, 0xed, 0xa3, 0x56, 0xbd, - 0x76, 0x8d, 0x14, 0x3c, 0xda, 0x87, 0xd, 0x28, 0x55}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15426, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30451, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11166 [("\253",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("\160\191\253\EOT\221\233mn\DLE0\180\USn",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("F\137\196\196\246j\196\202xY\172\CANg",SubOptions +// SubscribeRequest 5141 [("\173\ff",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS1}),("Jm\241\231Tp\203~\220z\153^\194\DC4\227'q\242\ESC1\177\192Q\185\NAK\ETX\139",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\209\FS\DC3#w\220<\201Ou\SI\131]\154\159",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS2}),("`\161lN\DLE\160\DC1s:",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("6",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0x48, 0x2b, 0x9e, 0x0, 0x1, 0xfd, 0x1, 0x0, 0xd, 0xa0, 0xbf, 0xfd, 0x4, 0xdd, - 0xe9, 0x6d, 0x6e, 0x10, 0x30, 0xb4, 0x1f, 0x6e, 0x1, 0x0, 0xd, 0x46, 0x89, 0xc4, 0xc4, - 0xf6, 0x6a, 0xc4, 0xca, 0x78, 0x59, 0xac, 0x18, 0x67, 0x1, 0x0, 0xf, 0xd1, 0x1c, 0x13, - 0x23, 0x77, 0xdc, 0x3c, 0xc9, 0x4f, 0x75, 0xf, 0x83, 0x5d, 0x9a, 0x9f, 0x2, 0x0, 0x9, - 0x60, 0xa1, 0x6c, 0x4e, 0x10, 0xa0, 0x11, 0x73, 0x3a, 0x0, 0x0, 0x1, 0x36, 0x1}; +// QoS1}),("\227\229\242\245\173@\183\167\170\152\186\254\253<\SYN\223>|\242\237\137P8",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(";\204",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\153H\234.\165\EM\135u#\SO\b\141\141\185I\210.\241\136\224",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\186\197\SYN\130",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\251y\216\143Q\220\DC1\248\132\241\NUL\SI\DC3\b\230z\EM\166|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\148xP\RSO\SI",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode25) { + uint8_t pkt[] = {0x82, 0x82, 0x1, 0x14, 0x15, 0x0, 0x3, 0xad, 0xc, 0x66, 0x1, 0x0, 0x1b, 0x4a, 0x6d, 0xf1, 0xe7, + 0x54, 0x70, 0xcb, 0x7e, 0xdc, 0x7a, 0x99, 0x5e, 0xc2, 0x14, 0xe3, 0x27, 0x71, 0xf2, 0x1b, 0x31, 0xb1, + 0xc0, 0x51, 0xb9, 0x15, 0x3, 0x8b, 0x1, 0x0, 0x17, 0xe3, 0xe5, 0xf2, 0xf5, 0xad, 0x40, 0xb7, 0xa7, + 0xaa, 0x98, 0xba, 0xfe, 0xfd, 0x3c, 0x16, 0xdf, 0x3e, 0x7c, 0xf2, 0xed, 0x89, 0x50, 0x38, 0x0, 0x0, + 0x2, 0x3b, 0xcc, 0x2, 0x0, 0x14, 0x99, 0x48, 0xea, 0x2e, 0xa5, 0x19, 0x87, 0x75, 0x23, 0xe, 0x8, + 0x8d, 0x8d, 0xb9, 0x49, 0xd2, 0x2e, 0xf1, 0x88, 0xe0, 0x2, 0x0, 0x4, 0xba, 0xc5, 0x16, 0x82, 0x1, + 0x0, 0x13, 0xfb, 0x79, 0xd8, 0x8f, 0x51, 0xdc, 0x11, 0xf8, 0x84, 0xf1, 0x0, 0xf, 0x13, 0x8, 0xe6, + 0x7a, 0x19, 0xa6, 0x7c, 0x2, 0x0, 0x6, 0x94, 0x78, 0x50, 0x1e, 0x4f, 0xf, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xfd}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xad, 0xc, 0x66}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa0, 0xbf, 0xfd, 0x4, 0xdd, 0xe9, 0x6d, 0x6e, 0x10, 0x30, 0xb4, 0x1f, 0x6e}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4a, 0x6d, 0xf1, 0xe7, 0x54, 0x70, 0xcb, 0x7e, 0xdc, 0x7a, 0x99, 0x5e, 0xc2, 0x14, + 0xe3, 0x27, 0x71, 0xf2, 0x1b, 0x31, 0xb1, 0xc0, 0x51, 0xb9, 0x15, 0x3, 0x8b}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x46, 0x89, 0xc4, 0xc4, 0xf6, 0x6a, 0xc4, 0xca, 0x78, 0x59, 0xac, 0x18, 0x67}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe3, 0xe5, 0xf2, 0xf5, 0xad, 0x40, 0xb7, 0xa7, 0xaa, 0x98, 0xba, 0xfe, + 0xfd, 0x3c, 0x16, 0xdf, 0x3e, 0x7c, 0xf2, 0xed, 0x89, 0x50, 0x38}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd1, 0x1c, 0x13, 0x23, 0x77, 0xdc, 0x3c, 0xc9, - 0x4f, 0x75, 0xf, 0x83, 0x5d, 0x9a, 0x9f}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3b, 0xcc}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x60, 0xa1, 0x6c, 0x4e, 0x10, 0xa0, 0x11, 0x73, 0x3a}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x99, 0x48, 0xea, 0x2e, 0xa5, 0x19, 0x87, 0x75, 0x23, 0xe, + 0x8, 0x8d, 0x8d, 0xb9, 0x49, 0xd2, 0x2e, 0xf1, 0x88, 0xe0}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x36}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xba, 0xc5, 0x16, 0x82}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0xfb, 0x79, 0xd8, 0x8f, 0x51, 0xdc, 0x11, 0xf8, 0x84, 0xf1, + 0x0, 0xf, 0x13, 0x8, 0xe6, 0x7a, 0x19, 0xa6, 0x7c}; + lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x94, 0x78, 0x50, 0x1e, 0x4f, 0xf}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -12347,7 +12357,7 @@ TEST(Subscribe311QCTest, Encode28) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -12355,7 +12365,7 @@ TEST(Subscribe311QCTest, Encode28) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -12363,54 +12373,58 @@ TEST(Subscribe311QCTest, Encode28) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11166, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5141, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9472 [("\243\DC2\199A\218\167\CAN\SYN\220w\165\160\NAK",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\247\192Pw\199\196)T\SI\142wV\188!\138\241[\171",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("]\205\240x6\SI\137\238\166K\152\156\181ri\NUL\224\130^\f\190\132\156\170\149\199U\142n",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0x47, 0x25, 0x0, 0x0, 0xd, 0xf3, 0x12, 0xc7, 0x41, 0xda, 0xa7, 0x18, 0x16, 0xdc, - 0x77, 0xa5, 0xa0, 0x15, 0x2, 0x0, 0x12, 0xf7, 0xc0, 0x50, 0x77, 0xc7, 0xc4, 0x29, 0x54, - 0xf, 0x8e, 0x77, 0x56, 0xbc, 0x21, 0x8a, 0xf1, 0x5b, 0xab, 0x2, 0x0, 0x1d, 0x5d, 0xcd, - 0xf0, 0x78, 0x36, 0xf, 0x89, 0xee, 0xa6, 0x4b, 0x98, 0x9c, 0xb5, 0x72, 0x69, 0x0, 0xe0, - 0x82, 0x5e, 0xc, 0xbe, 0x84, 0x9c, 0xaa, 0x95, 0xc7, 0x55, 0x8e, 0x6e, 0x0}; +// SubscribeRequest 8922 [("8[\204Te\235\185\154\136\vI\148\223",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("/\242O\211\r\131\245\210\240\128\SI/@",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\149\136\194\189\ESC\130\154\195\138b\146\NUL\181d\RS\a\216\241\FS\252\144\&3\185$K",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode26) { + uint8_t pkt[] = {0x82, 0x3e, 0x22, 0xda, 0x0, 0xd, 0x38, 0x5b, 0xcc, 0x54, 0x65, 0xeb, 0xb9, 0x9a, 0x88, 0xb, + 0x49, 0x94, 0xdf, 0x0, 0x0, 0xd, 0x2f, 0xf2, 0x4f, 0xd3, 0xd, 0x83, 0xf5, 0xd2, 0xf0, 0x80, + 0xf, 0x2f, 0x40, 0x1, 0x0, 0x19, 0x95, 0x88, 0xc2, 0xbd, 0x1b, 0x82, 0x9a, 0xc3, 0x8a, 0x62, + 0x92, 0x0, 0xb5, 0x64, 0x1e, 0x7, 0xd8, 0xf1, 0x1c, 0xfc, 0x90, 0x33, 0xb9, 0x24, 0x4b, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xf3, 0x12, 0xc7, 0x41, 0xda, 0xa7, 0x18, 0x16, 0xdc, 0x77, 0xa5, 0xa0, 0x15}; + uint8_t topic_filter_s0_bytes[] = {0x38, 0x5b, 0xcc, 0x54, 0x65, 0xeb, 0xb9, 0x9a, 0x88, 0xb, 0x49, 0x94, 0xdf}; lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf7, 0xc0, 0x50, 0x77, 0xc7, 0xc4, 0x29, 0x54, 0xf, - 0x8e, 0x77, 0x56, 0xbc, 0x21, 0x8a, 0xf1, 0x5b, 0xab}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2f, 0xf2, 0x4f, 0xd3, 0xd, 0x83, 0xf5, 0xd2, 0xf0, 0x80, 0xf, 0x2f, 0x40}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5d, 0xcd, 0xf0, 0x78, 0x36, 0xf, 0x89, 0xee, 0xa6, 0x4b, - 0x98, 0x9c, 0xb5, 0x72, 0x69, 0x0, 0xe0, 0x82, 0x5e, 0xc, - 0xbe, 0x84, 0x9c, 0xaa, 0x95, 0xc7, 0x55, 0x8e, 0x6e}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x95, 0x88, 0xc2, 0xbd, 0x1b, 0x82, 0x9a, 0xc3, 0x8a, 0x62, 0x92, 0x0, 0xb5, + 0x64, 0x1e, 0x7, 0xd8, 0xf1, 0x1c, 0xfc, 0x90, 0x33, 0xb9, 0x24, 0x4b}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -12420,80 +12434,76 @@ TEST(Subscribe311QCTest, Encode29) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9472, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8922, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18189 [("\142\SUB\241ET\151\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("t\160\t\216\&0\193Dg",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\218\225\n\t_\\\243\201\136\236\156E\172\217C\208\EOTn\147\225\145",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\167NE\EOT\132/\SIWTa\223|'\178]?\227\170O",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\208\238\156.\186\253",SubOptions {_retainHandling = +// SubscribeRequest 10052 +// [("\197\182\247\NAK\225g\156\RSB\176\131>\210\163+gM\b]f\247\229C\139\206\250\&7\200N(",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\227\238\151ou]\230\234\ETB\aQ\170\218",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\249\a\164!\177YC\194\&0\183f\212\212Y\NAK\EOT\178\179",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("[",SubOptions +// QoS0}),("\244\237N\DC2\r\SIT\223\DC2\235\166\252\&3\164\242J2\185\ETB$\209#O\222",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SUBP\205",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\CANk+w\218\153\151\DEL\179U\STXl\DC2\SUBE\251\241\208",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\132B\f\206\169",SubOptions {_retainHandling = +// QoS2}),("\SO=\180\165\216\210V\143\215h\230\182\212\148\199\230\SUBO\128\ENQX\163\200\244<\DC2g9P\180",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("3z\NUL6\210\254\222.\146\237\247\DEL*_\251",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("j\196\220\190\210\153\196\134\169\GS\DC2\208m6\155{i\204i=Ln9\201O_\NAK#-\177",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("v\NUL\235\199\138\128\&3\DEL\202Q",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\239\216H\UStK\244\237\FSl#\234]\220Ll",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x97, 0x1, 0x47, 0xd, 0x0, 0x7, 0x8e, 0x1a, 0xf1, 0x45, 0x54, 0x97, 0xe8, 0x2, 0x0, - 0x8, 0x74, 0xa0, 0x9, 0xd8, 0x30, 0xc1, 0x44, 0x67, 0x1, 0x0, 0x15, 0xda, 0xe1, 0xa, 0x9, - 0x5f, 0x5c, 0xf3, 0xc9, 0x88, 0xec, 0x9c, 0x45, 0xac, 0xd9, 0x43, 0xd0, 0x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, 0x0, 0x1e, 0xe, 0x3d, 0xb4, 0xa5, 0xd8, 0xd2, 0x56, 0x8f, 0xd7, 0x68, 0xe6, 0xb6, + 0xd4, 0x94, 0xc7, 0xe6, 0x1a, 0x4f, 0x80, 0x5, 0x58, 0xa3, 0xc8, 0xf4, 0x3c, 0x12, 0x67, 0x39, 0x50, + 0xb4, 0x0, 0x0, 0xf, 0x33, 0x7a, 0x0, 0x36, 0xd2, 0xfe, 0xde, 0x2e, 0x92, 0xed, 0xf7, 0x7f, 0x2a, + 0x5f, 0xfb, 0x0, 0x0, 0x1e, 0x6a, 0xc4, 0xdc, 0xbe, 0xd2, 0x99, 0xc4, 0x86, 0xa9, 0x1d, 0x12, 0xd0, + 0x6d, 0x36, 0x9b, 0x7b, 0x69, 0xcc, 0x69, 0x3d, 0x4c, 0x6e, 0x39, 0xc9, 0x4f, 0x5f, 0x15, 0x23, 0x2d, + 0xb1, 0x0, 0x0, 0xa, 0x76, 0x0, 0xeb, 0xc7, 0x8a, 0x80, 0x33, 0x7f, 0xca, 0x51, 0x1, 0x0, 0x10, + 0xef, 0xd8, 0x48, 0x1f, 0x74, 0x4b, 0xf4, 0xed, 0x1c, 0x6c, 0x23, 0xea, 0x5d, 0xdc, 0x4c, 0x6c, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x8e, 0x1a, 0xf1, 0x45, 0x54, 0x97, 0xe8}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xc5, 0xb6, 0xf7, 0x15, 0xe1, 0x67, 0x9c, 0x1e, 0x42, 0xb0, + 0x83, 0x3e, 0xd2, 0xa3, 0x2b, 0x67, 0x4d, 0x8, 0x5d, 0x66, + 0xf7, 0xe5, 0x43, 0x8b, 0xce, 0xfa, 0x37, 0xc8, 0x4e, 0x28}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x74, 0xa0, 0x9, 0xd8, 0x30, 0xc1, 0x44, 0x67}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf4, 0xed, 0x4e, 0x12, 0xd, 0xf, 0x54, 0xdf, 0x12, 0xeb, 0xa6, 0xfc, + 0x33, 0xa4, 0xf2, 0x4a, 0x32, 0xb9, 0x17, 0x24, 0xd1, 0x23, 0x4f, 0xde}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xda, 0xe1, 0xa, 0x9, 0x5f, 0x5c, 0xf3, 0xc9, 0x88, 0xec, 0x9c, - 0x45, 0xac, 0xd9, 0x43, 0xd0, 0x4, 0x6e, 0x93, 0xe1, 0x91}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1a, 0x50, 0xcd}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa7, 0x4e, 0x45, 0x4, 0x84, 0x2f, 0xf, 0x57, 0x54, 0x61, - 0xdf, 0x7c, 0x27, 0xb2, 0x5d, 0x3f, 0xe3, 0xaa, 0x4f}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xe, 0x3d, 0xb4, 0xa5, 0xd8, 0xd2, 0x56, 0x8f, 0xd7, 0x68, + 0xe6, 0xb6, 0xd4, 0x94, 0xc7, 0xe6, 0x1a, 0x4f, 0x80, 0x5, + 0x58, 0xa3, 0xc8, 0xf4, 0x3c, 0x12, 0x67, 0x39, 0x50, 0xb4}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd0, 0xee, 0x9c, 0x2e, 0xba, 0xfd}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x33, 0x7a, 0x0, 0x36, 0xd2, 0xfe, 0xde, 0x2e, + 0x92, 0xed, 0xf7, 0x7f, 0x2a, 0x5f, 0xfb}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe3, 0xee, 0x97, 0x6f, 0x75, 0x5d, 0xe6, 0xea, 0x17, 0x7, 0x51, 0xaa, 0xda}; - lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x6a, 0xc4, 0xdc, 0xbe, 0xd2, 0x99, 0xc4, 0x86, 0xa9, 0x1d, + 0x12, 0xd0, 0x6d, 0x36, 0x9b, 0x7b, 0x69, 0xcc, 0x69, 0x3d, + 0x4c, 0x6e, 0x39, 0xc9, 0x4f, 0x5f, 0x15, 0x23, 0x2d, 0xb1}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x76, 0x0, 0xeb, 0xc7, 0x8a, 0x80, 0x33, 0x7f, 0xca, 0x51}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf9, 0x7, 0xa4, 0x21, 0xb1, 0x59, 0x43, 0xc2, 0x30, - 0xb7, 0x66, 0xd4, 0xd4, 0x59, 0x15, 0x4, 0xb2, 0xb3}; - lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xef, 0xd8, 0x48, 0x1f, 0x74, 0x4b, 0xf4, 0xed, + 0x1c, 0x6c, 0x23, 0xea, 0x5d, 0xdc, 0x4c, 0x6c}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x5b}; - lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x18, 0x6b, 0x2b, 0x77, 0xda, 0x99, 0x97, 0x7f, 0xb3, - 0x55, 0x2, 0x6c, 0x12, 0x1a, 0x45, 0xfb, 0xf1, 0xd0}; - lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x84, 0x42, 0xc, 0xce, 0xa9}; - lwmqtt_string_t topic_filter_s10 = {5, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -12501,19 +12511,19 @@ TEST(Subscribe311QCTest, Encode30) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -12525,5256 +12535,5901 @@ TEST(Subscribe311QCTest, Encode30) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18189, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10052, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 5047 [("H\129E$_\201\142?\214\245~\170",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\EOT\171",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("|\130\163TL\202",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\147^\181B\US12\255U",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal -// = False, _subQoS = QoS2}),("\185\DC1\142\241\ENQ\"\ETX",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\139\130\222\tW\SI",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropRetainAvailable -// 155,PropTopicAlias 4606,PropContentType -// "rE!\226\208\253(f%\144\226\238\210\235p\a\DC3;&\224[q\250T\181}\192",PropMessageExpiryInterval -// 16020,PropRetainAvailable 0] -TEST(Subscribe5QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x69, 0x13, 0xb7, 0x2a, 0x25, 0x9b, 0x23, 0x11, 0xfe, 0x3, 0x0, 0x1b, 0x72, 0x45, 0x21, - 0xe2, 0xd0, 0xfd, 0x28, 0x66, 0x25, 0x90, 0xe2, 0xee, 0xd2, 0xeb, 0x70, 0x7, 0x13, 0x3b, 0x26, - 0xe0, 0x5b, 0x71, 0xfa, 0x54, 0xb5, 0x7d, 0xc0, 0x2, 0x0, 0x0, 0x3e, 0x94, 0x25, 0x0, 0x0, - 0xc, 0x48, 0x81, 0x45, 0x24, 0x5f, 0xc9, 0x8e, 0x3f, 0xd6, 0xf5, 0x7e, 0xaa, 0xa, 0x0, 0x2, - 0x4, 0xab, 0x2c, 0x0, 0x6, 0x7c, 0x82, 0xa3, 0x54, 0x4c, 0xca, 0x2d, 0x0, 0x9, 0x93, 0x5e, - 0xb5, 0x42, 0x1f, 0x31, 0x32, 0xff, 0x55, 0x1a, 0x0, 0x7, 0xb9, 0x11, 0x8e, 0xf1, 0x5, 0x22, - 0x3, 0x0, 0x0, 0x6, 0x8b, 0x82, 0xde, 0x9, 0x57, 0xf, 0x2}; +// SubscribeRequest 12644 [("\185\166\&5\ACK\169\SOk",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode28) { + uint8_t pkt[] = {0x82, 0xf, 0x31, 0x64, 0x0, 0x7, 0xb9, 0xa6, 0x35, 0x6, 0xa9, 0xe, 0x6b, 0x1, 0x0, 0x0, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x48, 0x81, 0x45, 0x24, 0x5f, 0xc9, 0x8e, 0x3f, 0xd6, 0xf5, 0x7e, 0xaa}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xb9, 0xa6, 0x35, 0x6, 0xa9, 0xe, 0x6b}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4, 0xab}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7c, 0x82, 0xa3, 0x54, 0x4c, 0xca}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x93, 0x5e, 0xb5, 0x42, 0x1f, 0x31, 0x32, 0xff, 0x55}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12644, 2, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 4944 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("_k\r\DC2\f\SI\228\155\183\&2\NAK\NULR\a]\202\235\149",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("*>\177\186\&0]\214*\191\206q\"\231\248\230\193\194E\183\238!\241+\233\222,\198t\234\150",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("mP\215\162\&0:<\157\150\b\240m\ETX\235\218\SOH\255I\168\&5I\145\134^\EM",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode29) { + uint8_t pkt[] = {0x82, 0x57, 0x13, 0x50, 0x0, 0x0, 0x2, 0x0, 0x12, 0x5f, 0x6b, 0xd, 0x12, 0xc, 0xf, + 0xe4, 0x9b, 0xb7, 0x32, 0x15, 0x0, 0x52, 0x7, 0x5d, 0xca, 0xeb, 0x95, 0x2, 0x0, 0x1e, + 0x2a, 0x3e, 0xb1, 0xba, 0x30, 0x5d, 0xd6, 0x2a, 0xbf, 0xce, 0x71, 0x22, 0xe7, 0xf8, 0xe6, + 0xc1, 0xc2, 0x45, 0xb7, 0xee, 0x21, 0xf1, 0x2b, 0xe9, 0xde, 0x2c, 0xc6, 0x74, 0xea, 0x96, + 0x1, 0x0, 0x19, 0x6d, 0x50, 0xd7, 0xa2, 0x30, 0x3a, 0x3c, 0x9d, 0x96, 0x8, 0xf0, 0x6d, + 0x3, 0xeb, 0xda, 0x1, 0xff, 0x49, 0xa8, 0x35, 0x49, 0x91, 0x86, 0x5e, 0x19, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x5f, 0x6b, 0xd, 0x12, 0xc, 0xf, 0xe4, 0x9b, 0xb7, + 0x32, 0x15, 0x0, 0x52, 0x7, 0x5d, 0xca, 0xeb, 0x95}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x2a, 0x3e, 0xb1, 0xba, 0x30, 0x5d, 0xd6, 0x2a, 0xbf, 0xce, + 0x71, 0x22, 0xe7, 0xf8, 0xe6, 0xc1, 0xc2, 0x45, 0xb7, 0xee, + 0x21, 0xf1, 0x2b, 0xe9, 0xde, 0x2c, 0xc6, 0x74, 0xea, 0x96}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6d, 0x50, 0xd7, 0xa2, 0x30, 0x3a, 0x3c, 0x9d, 0x96, 0x8, 0xf0, 0x6d, 0x3, + 0xeb, 0xda, 0x1, 0xff, 0x49, 0xa8, 0x35, 0x49, 0x91, 0x86, 0x5e, 0x19}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4944, 4, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 10380 [("x#\177~\235\205^\211e\221\198\US_r6\166_\SUB\220\237ILW\169\182V\129",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("fv\DC4W\179\ETB\232\n\203",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\183Q\224\149\199H$\NAK\183\GS\164\130\219 $B\130J\247\250\205V\218",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("w\NAK{\230=\DC2\213",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),(".\240\210\165\146h\199\217\159k\147\SO.\155\246\245\233\STX\229P\168\196",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\226I\SYN\248",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("\150\230\233s",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2}),("\133\135\180\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("_D5",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("gN\213\255\202\196Gnm\180\&4\184Y\219kI\b\140\223\178\DC1u\248\215\132",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\209\EOT\FS\r\251\165\SO{I\218G\179\214\176\184\150\153\160\235\&0\226\aN",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode30) { + uint8_t pkt[] = { + 0x82, 0xba, 0x1, 0x28, 0x8c, 0x0, 0x1b, 0x78, 0x23, 0xb1, 0x7e, 0xeb, 0xcd, 0x5e, 0xd3, 0x65, 0xdd, 0xc6, 0x1f, + 0x5f, 0x72, 0x36, 0xa6, 0x5f, 0x1a, 0xdc, 0xed, 0x49, 0x4c, 0x57, 0xa9, 0xb6, 0x56, 0x81, 0x2, 0x0, 0x9, 0x66, + 0x76, 0x14, 0x57, 0xb3, 0x17, 0xe8, 0xa, 0xcb, 0x2, 0x0, 0x17, 0xb7, 0x51, 0xe0, 0x95, 0xc7, 0x48, 0x24, 0x15, + 0xb7, 0x1d, 0xa4, 0x82, 0xdb, 0x20, 0x24, 0x42, 0x82, 0x4a, 0xf7, 0xfa, 0xcd, 0x56, 0xda, 0x1, 0x0, 0x7, 0x77, + 0x15, 0x7b, 0xe6, 0x3d, 0x12, 0xd5, 0x2, 0x0, 0x16, 0x2e, 0xf0, 0xd2, 0xa5, 0x92, 0x68, 0xc7, 0xd9, 0x9f, 0x6b, + 0x93, 0xe, 0x2e, 0x9b, 0xf6, 0xf5, 0xe9, 0x2, 0xe5, 0x50, 0xa8, 0xc4, 0x1, 0x0, 0x4, 0xe2, 0x49, 0x16, 0xf8, + 0x0, 0x0, 0x4, 0x96, 0xe6, 0xe9, 0x73, 0x2, 0x0, 0x4, 0x85, 0x87, 0xb4, 0x19, 0x2, 0x0, 0x3, 0x5f, 0x44, + 0x35, 0x2, 0x0, 0x19, 0x67, 0x4e, 0xd5, 0xff, 0xca, 0xc4, 0x47, 0x6e, 0x6d, 0xb4, 0x34, 0xb8, 0x59, 0xdb, 0x6b, + 0x49, 0x8, 0x8c, 0xdf, 0xb2, 0x11, 0x75, 0xf8, 0xd7, 0x84, 0x0, 0x0, 0x17, 0xd1, 0x4, 0x1c, 0xd, 0xfb, 0xa5, + 0xe, 0x7b, 0x49, 0xda, 0x47, 0xb3, 0xd6, 0xb0, 0xb8, 0x96, 0x99, 0xa0, 0xeb, 0x30, 0xe2, 0x7, 0x4e, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x78, 0x23, 0xb1, 0x7e, 0xeb, 0xcd, 0x5e, 0xd3, 0x65, 0xdd, 0xc6, 0x1f, 0x5f, 0x72, + 0x36, 0xa6, 0x5f, 0x1a, 0xdc, 0xed, 0x49, 0x4c, 0x57, 0xa9, 0xb6, 0x56, 0x81}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x66, 0x76, 0x14, 0x57, 0xb3, 0x17, 0xe8, 0xa, 0xcb}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb7, 0x51, 0xe0, 0x95, 0xc7, 0x48, 0x24, 0x15, 0xb7, 0x1d, 0xa4, 0x82, + 0xdb, 0x20, 0x24, 0x42, 0x82, 0x4a, 0xf7, 0xfa, 0xcd, 0x56, 0xda}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x77, 0x15, 0x7b, 0xe6, 0x3d, 0x12, 0xd5}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb9, 0x11, 0x8e, 0xf1, 0x5, 0x22, 0x3}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2e, 0xf0, 0xd2, 0xa5, 0x92, 0x68, 0xc7, 0xd9, 0x9f, 0x6b, 0x93, + 0xe, 0x2e, 0x9b, 0xf6, 0xf5, 0xe9, 0x2, 0xe5, 0x50, 0xa8, 0xc4}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8b, 0x82, 0xde, 0x9, 0x57, 0xf}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe2, 0x49, 0x16, 0xf8}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0x96, 0xe6, 0xe9, 0x73}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x85, 0x87, 0xb4, 0x19}; + lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x5f, 0x44, 0x35}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x67, 0x4e, 0xd5, 0xff, 0xca, 0xc4, 0x47, 0x6e, 0x6d, 0xb4, 0x34, 0xb8, 0x59, + 0xdb, 0x6b, 0x49, 0x8, 0x8c, 0xdf, 0xb2, 0x11, 0x75, 0xf8, 0xd7, 0x84}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xd1, 0x4, 0x1c, 0xd, 0xfb, 0xa5, 0xe, 0x7b, 0x49, 0xda, 0x47, 0xb3, + 0xd6, 0xb0, 0xb8, 0x96, 0x99, 0xa0, 0xeb, 0x30, 0xe2, 0x7, 0x4e}; + lwmqtt_string_t topic_filter_s10 = {23, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - uint8_t bytesprops0[] = {0x72, 0x45, 0x21, 0xe2, 0xd0, 0xfd, 0x28, 0x66, 0x25, 0x90, 0xe2, 0xee, 0xd2, 0xeb, - 0x70, 0x7, 0x13, 0x3b, 0x26, 0xe0, 0x5b, 0x71, 0xfa, 0x54, 0xb5, 0x7d, 0xc0}; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10380, 11, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 14771 [("#\200Q\136b\STX\234p\149",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = True, _noLocal = False, _subQoS = +// QoS2}),("\228_\193\193f_2@\169\173\&8\140\194\221c7\ACK|\ESC\249[\"Cm\187\155\170\176",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("#\f&\179\130I\157\181\213\&6fl\DC2\184\SYN\188\175\227&yeI",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\247St\244Y\\m\197\n\f\DC4A\EOT\nmG\183L\SOH\161J\132\a\150\&3\DC3SP\130\194",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("E\169\130\158J\214",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] +// [PropUserProperty "\229\243\249(\129\186\nO\140\255\202\&5\v\DC2\218\203B1\131\169\177\149\177\EOT\165\214~" +// "\211\247:YI\DC1\143.\236Y\155\SYN'\235\145\169\FS]1\EOT\228\192",PropServerKeepAlive 1455,PropResponseInformation +// "\t\167\190z\213\168\147\SOH\202\148\SUB3\206\130.\231\165\161\210",PropUserProperty +// "\233\233J\221\187\196\165\142\211\228@=\183!\222\198\173\EOT\248\191\130\219\191\142\STX\185d\171kr" +// "g\246\164\194\225t\n\133\143\198\&8\b'\140\154\r'\NULU\159\DC1t\151(\149R\153]",PropReasonString +// "\207\198l\151\&9\171\208\156\231\149!\216R\233<\a\229p)\182\182.\246\156",PropRetainAvailable 26,PropUserProperty +// "\199\r\177\DC2\178\208\180!p" "0\NAK",PropWillDelayInterval 15578,PropMessageExpiryInterval +// 27005,PropSessionExpiryInterval 18827,PropRetainAvailable 55,PropMaximumPacketSize 15963,PropUserProperty +// "\249nY\175\185>" "J\SYNc\247\198\158\162Ik\222a\251\129\223\170\198\128 \154-\235 \240",PropAuthenticationMethod +// "\172\226\168\209\157\ETB\225q\167H\168\&7\185=x\244\249I\137\FS\ENQ#L\180r\EM\135d\159`",PropServerReference +// "\224\148;\f\"f\SO\178\v\175\227>\DLE\166\238'\t\128-\\\190<4",PropReceiveMaximum 1113,PropRequestProblemInformation +// 44,PropTopicAlias 28498,PropRequestResponseInformation 242,PropSessionExpiryInterval 28088,PropCorrelationData +// "OP\SOHf\199AD\217\DLE\173i3^\154\SI",PropWildcardSubscriptionAvailable 214,PropWildcardSubscriptionAvailable +// 89,PropAuthenticationMethod +// "Q\246\191M,\186%\152@H\231\248\187j\EOT\169v\"\132\205C\169\189!f6\199}",PropAuthenticationData +// "\253",PropSubscriptionIdentifier 15,PropPayloadFormatIndicator 63] +TEST(Subscribe5QCTest, Encode1) { + uint8_t pkt[] = { + 0x82, 0xec, 0x3, 0x39, 0xb3, 0xfa, 0x2, 0x26, 0x0, 0x1b, 0xe5, 0xf3, 0xf9, 0x28, 0x81, 0xba, 0xa, 0x4f, 0x8c, + 0xff, 0xca, 0x35, 0xb, 0x12, 0xda, 0xcb, 0x42, 0x31, 0x83, 0xa9, 0xb1, 0x95, 0xb1, 0x4, 0xa5, 0xd6, 0x7e, 0x0, + 0x16, 0xd3, 0xf7, 0x3a, 0x59, 0x49, 0x11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 0x1b, + 0xf9, 0x5b, 0x22, 0x43, 0x6d, 0xbb, 0x9b, 0xaa, 0xb0, 0x1c, 0x0, 0x16, 0x23, 0xc, 0x26, 0xb3, 0x82, 0x49, 0x9d, + 0xb5, 0xd5, 0x36, 0x66, 0x6c, 0x12, 0xb8, 0x16, 0xbc, 0xaf, 0xe3, 0x26, 0x79, 0x65, 0x49, 0x12, 0x0, 0x1e, 0xf7, + 0x53, 0x74, 0xf4, 0x59, 0x5c, 0x6d, 0xc5, 0xa, 0xc, 0x14, 0x41, 0x4, 0xa, 0x6d, 0x47, 0xb7, 0x4c, 0x1, 0xa1, + 0x4a, 0x84, 0x7, 0x96, 0x33, 0x13, 0x53, 0x50, 0x82, 0xc2, 0x1c, 0x0, 0x6, 0x45, 0xa9, 0x82, 0x9e, 0x4a, 0xd6, + 0x26}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x23, 0xc8, 0x51, 0x88, 0x62, 0x2, 0xea, 0x70, 0x95}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xe4, 0x5f, 0xc1, 0xc1, 0x66, 0x5f, 0x32, 0x40, 0xa9, 0xad, + 0x38, 0x8c, 0xc2, 0xdd, 0x63, 0x37, 0x6, 0x7c, 0x1b, 0xf9, + 0x5b, 0x22, 0x43, 0x6d, 0xbb, 0x9b, 0xaa, 0xb0}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x23, 0xc, 0x26, 0xb3, 0x82, 0x49, 0x9d, 0xb5, 0xd5, 0x36, 0x66, + 0x6c, 0x12, 0xb8, 0x16, 0xbc, 0xaf, 0xe3, 0x26, 0x79, 0x65, 0x49}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf7, 0x53, 0x74, 0xf4, 0x59, 0x5c, 0x6d, 0xc5, 0xa, 0xc, + 0x14, 0x41, 0x4, 0xa, 0x6d, 0x47, 0xb7, 0x4c, 0x1, 0xa1, + 0x4a, 0x84, 0x7, 0x96, 0x33, 0x13, 0x53, 0x50, 0x82, 0xc2}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x45, 0xa9, 0x82, 0x9e, 0x4a, 0xd6}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + uint8_t bytesprops1[] = {0xd3, 0xf7, 0x3a, 0x59, 0x49, 0x11, 0x8f, 0x2e, 0xec, 0x59, 0x9b, + 0x16, 0x27, 0xeb, 0x91, 0xa9, 0x1c, 0x5d, 0x31, 0x4, 0xe4, 0xc0}; + uint8_t bytesprops0[] = {0xe5, 0xf3, 0xf9, 0x28, 0x81, 0xba, 0xa, 0x4f, 0x8c, 0xff, 0xca, 0x35, 0xb, 0x12, + 0xda, 0xcb, 0x42, 0x31, 0x83, 0xa9, 0xb1, 0x95, 0xb1, 0x4, 0xa5, 0xd6, 0x7e}; + uint8_t bytesprops2[] = {0x9, 0xa7, 0xbe, 0x7a, 0xd5, 0xa8, 0x93, 0x1, 0xca, 0x94, + 0x1a, 0x33, 0xce, 0x82, 0x2e, 0xe7, 0xa5, 0xa1, 0xd2}; + uint8_t bytesprops4[] = {0x67, 0xf6, 0xa4, 0xc2, 0xe1, 0x74, 0xa, 0x85, 0x8f, 0xc6, 0x38, 0x8, 0x27, 0x8c, + 0x9a, 0xd, 0x27, 0x0, 0x55, 0x9f, 0x11, 0x74, 0x97, 0x28, 0x95, 0x52, 0x99, 0x5d}; + uint8_t bytesprops3[] = {0xe9, 0xe9, 0x4a, 0xdd, 0xbb, 0xc4, 0xa5, 0x8e, 0xd3, 0xe4, 0x40, 0x3d, 0xb7, 0x21, 0xde, + 0xc6, 0xad, 0x4, 0xf8, 0xbf, 0x82, 0xdb, 0xbf, 0x8e, 0x2, 0xb9, 0x64, 0xab, 0x6b, 0x72}; + uint8_t bytesprops5[] = {0xcf, 0xc6, 0x6c, 0x97, 0x39, 0xab, 0xd0, 0x9c, 0xe7, 0x95, 0x21, 0xd8, + 0x52, 0xe9, 0x3c, 0x7, 0xe5, 0x70, 0x29, 0xb6, 0xb6, 0x2e, 0xf6, 0x9c}; + uint8_t bytesprops7[] = {0x30, 0x15}; + uint8_t bytesprops6[] = {0xc7, 0xd, 0xb1, 0x12, 0xb2, 0xd0, 0xb4, 0x21, 0x70}; + uint8_t bytesprops9[] = {0x4a, 0x16, 0x63, 0xf7, 0xc6, 0x9e, 0xa2, 0x49, 0x6b, 0xde, 0x61, 0xfb, + 0x81, 0xdf, 0xaa, 0xc6, 0x80, 0x20, 0x9a, 0x2d, 0xeb, 0x20, 0xf0}; + uint8_t bytesprops8[] = {0xf9, 0x6e, 0x59, 0xaf, 0xb9, 0x3e}; + uint8_t bytesprops10[] = {0xac, 0xe2, 0xa8, 0xd1, 0x9d, 0x17, 0xe1, 0x71, 0xa7, 0x48, 0xa8, 0x37, 0xb9, 0x3d, 0x78, + 0xf4, 0xf9, 0x49, 0x89, 0x1c, 0x5, 0x23, 0x4c, 0xb4, 0x72, 0x19, 0x87, 0x64, 0x9f, 0x60}; + uint8_t bytesprops11[] = {0xe0, 0x94, 0x3b, 0xc, 0x22, 0x66, 0xe, 0xb2, 0xb, 0xaf, 0xe3, 0x3e, + 0x10, 0xa6, 0xee, 0x27, 0x9, 0x80, 0x2d, 0x5c, 0xbe, 0x3c, 0x34}; + uint8_t bytesprops12[] = {0x4f, 0x50, 0x1, 0x66, 0xc7, 0x41, 0x44, 0xd9, 0x10, 0xad, 0x69, 0x33, 0x5e, 0x9a, 0xf}; + uint8_t bytesprops13[] = {0x51, 0xf6, 0xbf, 0x4d, 0x2c, 0xba, 0x25, 0x98, 0x40, 0x48, 0xe7, 0xf8, 0xbb, 0x6a, + 0x4, 0xa9, 0x76, 0x22, 0x84, 0xcd, 0x43, 0xa9, 0xbd, 0x21, 0x66, 0x36, 0xc7, 0x7d}; + uint8_t bytesprops14[] = {0xfd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4606}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16020}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops0}, .v = {22, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1455}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops6}, .v = {2, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15578}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27005}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18827}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15963}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops8}, .v = {23, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1113}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28498}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28088}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 63}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5047, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14771, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3206 [("\DC12^",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS1}),("\184\136",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS1}),("$\217\231uJ\220\&4\205\163\&2\171'\203P\ESC\252\228\SOH\202",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] -// [PropReceiveMaximum 31812,PropSubscriptionIdentifierAvailable 200,PropMessageExpiryInterval 26308,PropServerKeepAlive -// 30441,PropTopicAliasMaximum 19633,PropWillDelayInterval 20710,PropCorrelationData -// "5\129\DLE\230\230\208\247\178\233\US",PropServerReference -// "\140\235\247\&2\198j\188\149\&8\243*\185\ETX\b\DEL\144\183Je\138\SI\227\193\218\239C\252"] +// SubscribeRequest 15521 [("`\189\"5\223\186\254\236\DC4y(\SYNn",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("r\ESC\204\199kn\141\&6\182\233~\DC4\158p$\220\NAK\GSm#",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("7m\NUL\DC2c\DC1\250\133",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\RS\\/\203\156\163\252S.\174\177kq\225p\148\163b\249\147e.\EOT\DC2k\206\177",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("/\b\177\207\ENQ\229\157k\212\ng\247\DC3\250K`\202tNp\249\223\135",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\157\187\230\229\224\196T",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS2}),("\222\n\165\165\169%\204-\NUL\STX\192\143p4\221U",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\234\158xoF\217\SUB\128~\184\v",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS2}),("\165)n:\242PZ@\244yx\255\DLEf\155\183\r\RSd\207",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] +// [PropAssignedClientIdentifier "\247",PropResponseInformation "\230M\DC4\241ta\STXf\US.T\215",PropTopicAliasMaximum +// 18295,PropRequestProblemInformation 191,PropAssignedClientIdentifier "\221\230\138+",PropWillDelayInterval +// 31886,PropTopicAliasMaximum 28209,PropTopicAliasMaximum 11036,PropCorrelationData "RVxA\197\192N\248",PropContentType +// "\165\NAKax&7h\217\DC3,+\159w\130\224&\198\"\195@\179\ESCy\155\147\164\DC3\169",PropUserProperty -// "#\152\SUB\245|\GSb\153`\v\145Ob\242\183\254\195" -// "\192\225d\NAK\239\r\239\211h*\134\228^\148\158\214-\217\140\231\SYN\199\203m\185\162",PropPayloadFormatIndicator -// 251,PropMessageExpiryInterval 17985,PropWildcardSubscriptionAvailable 47,PropRetainAvailable 9,PropCorrelationData -// "\DC1\DEL#)\r\231\FS\245Ta$\RS\171\182\246\219\r\211\NAK\SYN",PropRequestResponseInformation -// 138,PropMessageExpiryInterval 4082,PropServerReference " -// \204\255\&7\193\208u\SUB\142\&7\167\165vD\217xu\195\240\192\180\231\ACK\186",PropRetainAvailable -// 102,PropRequestResponseInformation 215,PropRequestResponseInformation 117] +// QoS2}),("7t\b,\195X\ETB\163\b\239\189\161%<\186M\148Ge\DC1",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\214\204\149U\228E\GS\"\154\138tn6\214\212\252\GS\221\192",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\193\225~tM*M\ETX\160!",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("!\SI\216\183\f1\167N7\226\168",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS1}),("\141\196\137sYG3\148\203O\177",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\n8\154\150]\ETX\218\235H",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS1})] [PropReasonString "\n\179\153\206j\235Q\NAKI,\184",PropMaximumPacketSize +// 13450,PropResponseTopic "\NUL\222,2\155\&3\a\SOH7\149\ETB\STX\199\&3\210\195\ETX\140\156\240\129",PropRetainAvailable +// 148,PropServerReference "*=3y\219\157\&5\SYN\ETB\135\132M?r\130\226\254\143\250",PropAssignedClientIdentifier +// "\t\bw\175[\SOr`\222\173lWK\143",PropSessionExpiryInterval 28089,PropResponseInformation +// "wi\210\173\141\239\DC2\b\135U=!\217\185\243\187(\EM\154<",PropCorrelationData +// "\166\218\156\237bLsm\"\EM",PropCorrelationData +// "\162\GS\192\157\162\SIFI\159|\148\220\&5\130\GS1\190\209.\DC2T2\216\r",PropMessageExpiryInterval +// 30374,PropWildcardSubscriptionAvailable 50,PropTopicAlias 21419,PropTopicAliasMaximum 32476] TEST(Subscribe5QCTest, Encode4) { uint8_t pkt[] = { - 0x82, 0xa7, 0x2, 0x38, 0x30, 0x8b, 0x1, 0xb, 0x1b, 0x24, 0x9f, 0x1a, 0x0, 0xa, 0x3e, 0x40, 0xb3, 0x1b, 0x79, - 0x9b, 0x93, 0xa4, 0x13, 0xa9, 0x26, 0x0, 0x11, 0x23, 0x98, 0x1a, 0xf5, 0x7c, 0x1d, 0x62, 0x99, 0x60, 0xb, 0x91, - 0x4f, 0x62, 0xf2, 0xb7, 0xfe, 0xc3, 0x0, 0x1a, 0xc0, 0xe1, 0x64, 0x15, 0xef, 0xd, 0xef, 0xd3, 0x68, 0x2a, 0x86, - 0xe4, 0x5e, 0x94, 0x9e, 0xd6, 0x2d, 0xd9, 0x8c, 0xe7, 0x16, 0xc7, 0xcb, 0x6d, 0xb9, 0xa2, 0x1, 0xfb, 0x2, 0x0, - 0x0, 0x46, 0x41, 0x28, 0x2f, 0x25, 0x9, 0x9, 0x0, 0x14, 0x11, 0x7f, 0x23, 0x29, 0xd, 0xe7, 0x1c, 0xf5, 0x54, - 0x61, 0x24, 0x1e, 0xab, 0xb6, 0xf6, 0xdb, 0xd, 0xd3, 0x15, 0x16, 0x19, 0x8a, 0x2, 0x0, 0x0, 0xf, 0xf2, 0x1c, - 0x0, 0x18, 0x20, 0xcc, 0xff, 0x37, 0xc1, 0xd0, 0x75, 0x1a, 0x8e, 0x37, 0xa7, 0xa5, 0x76, 0x44, 0xd9, 0x78, 0x75, - 0xc3, 0xf0, 0xc0, 0xb4, 0xe7, 0x6, 0xba, 0x25, 0x66, 0x19, 0xd7, 0x19, 0x75, 0x0, 0xd, 0x1c, 0x80, 0xf1, 0xf8, - 0xd0, 0x89, 0x43, 0x7e, 0x28, 0xa3, 0x25, 0x9e, 0x77, 0x19, 0x0, 0x1a, 0x35, 0x58, 0x38, 0xcd, 0xd3, 0xeb, 0x70, - 0x4b, 0x17, 0x57, 0x40, 0x0, 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0xc1, 0xe1, 0x7e, 0x74, 0x4d, 0x2a, 0x4d, 0x3, 0xa0, 0x21, 0x29, 0x0, 0xb, 0x21, + 0xf, 0xd8, 0xb7, 0xc, 0x31, 0xa7, 0x4e, 0x37, 0xe2, 0xa8, 0x25, 0x0, 0xb, 0x8d, 0xc4, 0x89, 0x73, 0x59, 0x47, + 0x33, 0x94, 0xcb, 0x4f, 0xb1, 0x1d, 0x0, 0x9, 0xa, 0x38, 0x9a, 0x96, 0x5d, 0x3, 0xda, 0xeb, 0x48, 0xd}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x1c, 0x80, 0xf1, 0xf8, 0xd0, 0x89, 0x43, 0x7e, 0x28, 0xa3, 0x25, 0x9e, 0x77}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xdc, 0xed, 0x20, 0xb9, 0xda, 0x66, 0xba, 0xa9, 0x47, 0x2d, + 0x16, 0x52, 0x9d, 0x81, 0x6b, 0x92, 0x8e, 0xbb, 0xf9, 0xdf, + 0x56, 0x79, 0xa8, 0x58, 0xd6, 0xd1, 0x42, 0xd4, 0x3, 0xb7}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x35, 0x58, 0x38, 0xcd, 0xd3, 0xeb, 0x70, 0x4b, 0x17, 0x57, 0x40, 0x0, 0x3a, - 0x8a, 0xf4, 0x55, 0xb0, 0x8f, 0xb, 0x65, 0x6c, 0xf4, 0x78, 0x5f, 0xff, 0x99}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x37, 0x74, 0x8, 0x2c, 0xc3, 0x58, 0x17, 0xa3, 0x8, 0xef, + 0xbd, 0xa1, 0x25, 0x3c, 0xba, 0x4d, 0x94, 0x47, 0x65, 0x11}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x72, 0x5e, 0x8f, 0xa2, 0xb2, 0xa8, 0xc0, 0xac, 0x8d, 0x2e, 0xf, 0xf5, 0x7, 0xdd, - 0x17, 0x4e, 0xfe, 0x77, 0x14, 0x8d, 0x19, 0x4a, 0x8d, 0x29, 0x33, 0xc2, 0xf6}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd6, 0xcc, 0x95, 0x55, 0xe4, 0x45, 0x1d, 0x22, 0x9a, 0x8a, + 0x74, 0x6e, 0x36, 0xd6, 0xd4, 0xfc, 0x1d, 0xdd, 0xc0}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc1, 0xe1, 0x7e, 0x74, 0x4d, 0x2a, 0x4d, 0x3, 0xa0, 0x21}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x90, 0xc2, 0x41, 0xe8, 0x1, 0x9b, 0x1b, 0x4c, 0x5c, 0xd6, - 0x38, 0xa9, 0x12, 0xef, 0xad, 0x30, 0x14, 0x50, 0x3a, 0x26}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x21, 0xf, 0xd8, 0xb7, 0xc, 0x31, 0xa7, 0x4e, 0x37, 0xe2, 0xa8}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x69, 0x81, 0xb, 0xf0, 0xcd, 0x40, 0x50, 0x41, 0x2f}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x8d, 0xc4, 0x89, 0x73, 0x59, 0x47, 0x33, 0x94, 0xcb, 0x4f, 0xb1}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x41, 0x21, 0xe1, 0x8a, 0x3d}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xa, 0x38, 0x9a, 0x96, 0x5d, 0x3, 0xda, 0xeb, 0x48}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa9, 0xc1, 0x38, 0x42, 0x8a, 0x8f, 0x18, 0x7e, 0x3d, 0x96, 0xf0, 0xd8, 0x55, 0xa8, - 0x10, 0x43, 0x78, 0x7f, 0x28, 0xf5, 0x87, 0x31, 0x47, 0x7c, 0x31, 0x90, 0x46}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; + sub_opts[4].no_local = true; sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; + sub_opts[5].no_local = true; sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - uint8_t bytesprops0[] = {0x3e, 0x40, 0xb3, 0x1b, 0x79, 0x9b, 0x93, 0xa4, 0x13, 0xa9}; - uint8_t bytesprops2[] = {0xc0, 0xe1, 0x64, 0x15, 0xef, 0xd, 0xef, 0xd3, 0x68, 0x2a, 0x86, 0xe4, 0x5e, - 0x94, 0x9e, 0xd6, 0x2d, 0xd9, 0x8c, 0xe7, 0x16, 0xc7, 0xcb, 0x6d, 0xb9, 0xa2}; - uint8_t bytesprops1[] = {0x23, 0x98, 0x1a, 0xf5, 0x7c, 0x1d, 0x62, 0x99, 0x60, - 0xb, 0x91, 0x4f, 0x62, 0xf2, 0xb7, 0xfe, 0xc3}; - uint8_t bytesprops3[] = {0x11, 0x7f, 0x23, 0x29, 0xd, 0xe7, 0x1c, 0xf5, 0x54, 0x61, - 0x24, 0x1e, 0xab, 0xb6, 0xf6, 0xdb, 0xd, 0xd3, 0x15, 0x16}; - uint8_t bytesprops4[] = {0x20, 0xcc, 0xff, 0x37, 0xc1, 0xd0, 0x75, 0x1a, 0x8e, 0x37, 0xa7, 0xa5, - 0x76, 0x44, 0xd9, 0x78, 0x75, 0xc3, 0xf0, 0xc0, 0xb4, 0xe7, 0x6, 0xba}; + uint8_t bytesprops0[] = {0xa, 0xb3, 0x99, 0xce, 0x6a, 0xeb, 0x51, 0x15, 0x49, 0x2c, 0xb8}; + uint8_t bytesprops1[] = {0x0, 0xde, 0x2c, 0x32, 0x9b, 0x33, 0x7, 0x1, 0x37, 0x95, 0x17, + 0x2, 0xc7, 0x33, 0xd2, 0xc3, 0x3, 0x8c, 0x9c, 0xf0, 0x81}; + uint8_t bytesprops2[] = {0x2a, 0x3d, 0x33, 0x79, 0xdb, 0x9d, 0x35, 0x16, 0x17, 0x87, + 0x84, 0x4d, 0x3f, 0x72, 0x82, 0xe2, 0xfe, 0x8f, 0xfa}; + uint8_t bytesprops3[] = {0x9, 0x8, 0x77, 0xaf, 0x5b, 0xe, 0x72, 0x60, 0xde, 0xad, 0x6c, 0x57, 0x4b, 0x8f}; + uint8_t bytesprops4[] = {0x77, 0x69, 0xd2, 0xad, 0x8d, 0xef, 0x12, 0x8, 0x87, 0x55, + 0x3d, 0x21, 0xd9, 0xb9, 0xf3, 0xbb, 0x28, 0x19, 0x9a, 0x3c}; + uint8_t bytesprops5[] = {0xa6, 0xda, 0x9c, 0xed, 0x62, 0x4c, 0x73, 0x6d, 0x22, 0x19}; + uint8_t bytesprops6[] = {0xa2, 0x1d, 0xc0, 0x9d, 0xa2, 0xf, 0x46, 0x49, 0x9f, 0x7c, 0x94, 0xdc, + 0x35, 0x82, 0x1d, 0x31, 0xbe, 0xd1, 0x2e, 0x12, 0x54, 0x32, 0xd8, 0xd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 27}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {26, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17985}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4082}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13450}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28089}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30374}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21419}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32476}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14384, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9203, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 10952 [("\189\131\143u\249\178\237\221\225\135\200_E",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\138:\130%\226\132\219i%\244x~=X\220\GS\224\244\133\144\194O\240\154",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\184*~\237,+2\155\&2P\221\197",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS0}),("\172\&6\205I;\188o",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("-\ETB\193\208",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ENQ\r\210U\140\DC2\148\199\188\163\197]",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("yr \203n\154\&6\197\134\218xJ\DC4\144",SubOptions +// SubscribeRequest 7433 [("#\207",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// True, _subQoS = QoS2}),("\150",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS0}),("\236",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS1}),("\193\250\200\202",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\237c\182\248?\181\241\171\158",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\189A\203\SYNq\144\&2\237\196d\226s\192\SUB",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("h\187\a\196\RS\\\235\216\SOH\fv3",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("8Y\218Q\175\&2",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = -// False, _subQoS = QoS2})] [PropReasonString "\ENQT\246",PropMaximumQoS 247,PropAuthenticationMethod -// "K\r0\153\217\FS",PropRequestResponseInformation 112,PropReceiveMaximum 11958,PropPayloadFormatIndicator -// 68,PropMaximumQoS 59] +// QoS1}),("/\185l>/\134\246\153\EOT\237\&5\v\213\STX\138\EOT\211a",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\DC4\STX\211\a-\145",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropSessionExpiryInterval +// 30141,PropSessionExpiryInterval 5579,PropRequestProblemInformation 110,PropRequestResponseInformation +// 9,PropResponseTopic "\ngq\235\NULZ\215n\221\154\171B\147",PropResponseInformation "My\133",PropServerReference +// "\195\130\175\208\156\189\194\183W\243\151f",PropResponseTopic "\246\248M'\DC3",PropRetainAvailable +// 235,PropRequestResponseInformation 66,PropSubscriptionIdentifier 8,PropMaximumQoS 144,PropMessageExpiryInterval +// 27935,PropUserProperty +// "\237\218\146\136\247\179\226\233%\t\208\244\GS5l\r&\141\180\220)\t\ENQS\155\160\217\214\204\GS" "\192\193"] TEST(Subscribe5QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x91, 0x1, 0x2a, 0xc8, 0x1a, 0x1f, 0x0, 0x3, 0x5, 0x54, 0xf6, 0x24, 0xf7, 0x15, 0x0, 0x6, - 0x4b, 0xd, 0x30, 0x99, 0xd9, 0x1c, 0x19, 0x70, 0x21, 0x2e, 0xb6, 0x1, 0x44, 0x24, 0x3b, 0x0, 0xd, - 0xbd, 0x83, 0x8f, 0x75, 0xf9, 0xb2, 0xed, 0xdd, 0xe1, 0x87, 0xc8, 0x5f, 0x45, 0x2, 0x0, 0x18, 0x8a, - 0x3a, 0x82, 0x25, 0xe2, 0x84, 0xdb, 0x69, 0x25, 0xf4, 0x78, 0x7e, 0x3d, 0x58, 0xdc, 0x1d, 0xe0, 0xf4, - 0x85, 0x90, 0xc2, 0x4f, 0xf0, 0x9a, 0x1d, 0x0, 0xc, 0xb8, 0x2a, 0x7e, 0xed, 0x2c, 0x2b, 0x32, 0x9b, - 0x32, 0x50, 0xdd, 0xc5, 0x1c, 0x0, 0x7, 0xac, 0x36, 0xcd, 0x49, 0x3b, 0xbc, 0x6f, 0x2e, 0x0, 0x4, - 0x2d, 0x17, 0xc1, 0xd0, 0x1, 0x0, 0xc, 0x5, 0xd, 0xd2, 0x55, 0x8c, 0x12, 0x94, 0xc7, 0xbc, 0xa3, - 0xc5, 0x5d, 0x2d, 0x0, 0xe, 0x79, 0x72, 0x20, 0xcb, 0x6e, 0x9a, 0x36, 0xc5, 0x86, 0xda, 0x78, 0x4a, - 0x14, 0x90, 0x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c, 0x76, 0x33, 0x1, 0x0, 0x12, 0x2f, 0xb9, 0x6c, 0x3e, 0x2f, 0x86, 0xf6, 0x99, 0x4, + 0xed, 0x35, 0xb, 0xd5, 0x2, 0x8a, 0x4, 0xd3, 0x61, 0x2d, 0x0, 0x6, 0x14, 0x2, 0xd3, 0x7, 0x2d, 0x91, 0x26}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xbd, 0x83, 0x8f, 0x75, 0xf9, 0xb2, 0xed, 0xdd, 0xe1, 0x87, 0xc8, 0x5f, 0x45}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x23, 0xcf}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8a, 0x3a, 0x82, 0x25, 0xe2, 0x84, 0xdb, 0x69, 0x25, 0xf4, 0x78, 0x7e, - 0x3d, 0x58, 0xdc, 0x1d, 0xe0, 0xf4, 0x85, 0x90, 0xc2, 0x4f, 0xf0, 0x9a}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x96}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb8, 0x2a, 0x7e, 0xed, 0x2c, 0x2b, 0x32, 0x9b, 0x32, 0x50, 0xdd, 0xc5}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xec}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xac, 0x36, 0xcd, 0x49, 0x3b, 0xbc, 0x6f}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc1, 0xfa, 0xc8, 0xca}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2d, 0x17, 0xc1, 0xd0}; - lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xed, 0x63, 0xb6, 0xf8, 0x3f, 0xb5, 0xf1, 0xab, 0x9e}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5, 0xd, 0xd2, 0x55, 0x8c, 0x12, 0x94, 0xc7, 0xbc, 0xa3, 0xc5, 0x5d}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xbd, 0x41, 0xcb, 0x16, 0x71, 0x90, 0x32, + 0xed, 0xc4, 0x64, 0xe2, 0x73, 0xc0, 0x1a}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x79, 0x72, 0x20, 0xcb, 0x6e, 0x9a, 0x36, - 0xc5, 0x86, 0xda, 0x78, 0x4a, 0x14, 0x90}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x68, 0xbb, 0x7, 0xc4, 0x1e, 0x5c, 0xeb, 0xd8, 0x1, 0xc, 0x76, 0x33}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x38, 0x59, 0xda, 0x51, 0xaf, 0x32}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x2f, 0xb9, 0x6c, 0x3e, 0x2f, 0x86, 0xf6, 0x99, 0x4, + 0xed, 0x35, 0xb, 0xd5, 0x2, 0x8a, 0x4, 0xd3, 0x61}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; + uint8_t topic_filter_s8_bytes[] = {0x14, 0x2, 0xd3, 0x7, 0x2d, 0x91}; + lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - uint8_t bytesprops0[] = {0x5, 0x54, 0xf6}; - uint8_t bytesprops1[] = {0x4b, 0xd, 0x30, 0x99, 0xd9, 0x1c}; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; + uint8_t bytesprops0[] = {0xa, 0x67, 0x71, 0xeb, 0x0, 0x5a, 0xd7, 0x6e, 0xdd, 0x9a, 0xab, 0x42, 0x93}; + uint8_t bytesprops1[] = {0x4d, 0x79, 0x85}; + uint8_t bytesprops2[] = {0xc3, 0x82, 0xaf, 0xd0, 0x9c, 0xbd, 0xc2, 0xb7, 0x57, 0xf3, 0x97, 0x66}; + uint8_t bytesprops3[] = {0xf6, 0xf8, 0x4d, 0x27, 0x13}; + uint8_t bytesprops5[] = {0xc0, 0xc1}; + uint8_t bytesprops4[] = {0xed, 0xda, 0x92, 0x88, 0xf7, 0xb3, 0xe2, 0xe9, 0x25, 0x9, 0xd0, 0xf4, 0x1d, 0x35, 0x6c, + 0xd, 0x26, 0x8d, 0xb4, 0xdc, 0x29, 0x9, 0x5, 0x53, 0x9b, 0xa0, 0xd9, 0xd6, 0xcc, 0x1d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11958}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30141}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5579}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27935}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10952, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7433, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20143 -// [("N\178\188\208\255\162\DEL;\181\212\177\147\234\168\234)\194x\206K)\DC1\247\191\&4f\155",SubOptions +// SubscribeRequest 22949 [("\139\231\DC1\195J*\243\226Ip\ENQ\158\195U\254\DC3n'T\FS\230\201\178}A",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),(">9d\234/%\170N&\242h\234\206\134\134",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("%\217\254\154\133h\199\ACKo%\128\253;_D\137\226\\\175\&9\138\&5\241B\a2\212",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\241\189ww\ETX\164\226",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("E\180D\152\180\232\246\212\187U\138\209\197\193\160\DC4\164j{\130\253\170",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\201mH\219\192\STX\SUB{H\142Q#",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS0}),("\213\210",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ENQ]",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropRequestResponseInformation +// 59,PropTopicAlias 944,PropReceiveMaximum 13237,PropTopicAliasMaximum 23923,PropRetainAvailable 252,PropContentType +// "",PropContentType +// "\141\179\244\230`@\DC3\220\213C\SYN\244\SYN\145\188\247U\254\134,\147yK\248)",PropSubscriptionIdentifier +// 5,PropMaximumPacketSize 6461,PropServerReference "?d\DLE\208\168\225\233\188\206",PropSubscriptionIdentifier +// 26,PropAssignedClientIdentifier "*\241\203\230\219LeU\139",PropWildcardSubscriptionAvailable +// 4,PropMessageExpiryInterval 1918,PropMessageExpiryInterval 4697,PropAuthenticationData +// "\135\234\147c[\170>\244\152\193!#\v\SOH\140O\r\244",PropMaximumQoS 63,PropReceiveMaximum 7339,PropTopicAlias +// 1259,PropSessionExpiryInterval 8341] TEST(Subscribe5QCTest, Encode9) { uint8_t pkt[] = { - 0x82, 0xb4, 0x2, 0x6a, 0x98, 0x4d, 0x11, 0x0, 0x0, 0x7, 0x94, 0x27, 0x0, 0x0, 0x76, 0x71, 0x11, 0x0, 0x0, - 0x7e, 0x4e, 0x26, 0x0, 0xa, 0x27, 0xf0, 0xf7, 0xf9, 0xc0, 0x6a, 0x82, 0xe9, 0x36, 0x85, 0x0, 0xa, 0x43, 0xb4, - 0x30, 0x8b, 0x4d, 0x99, 0x7b, 0xeb, 0x58, 0x40, 0x29, 0xda, 0x22, 0x34, 0x90, 0x3, 0x0, 0x13, 0x96, 0x1a, 0x64, - 0xa9, 0x7c, 0x52, 0xa, 0x93, 0x89, 0x5c, 0x9a, 0x82, 0x20, 0x48, 0x98, 0xb7, 0x85, 0x59, 0xc9, 0x13, 0x36, 0x91, - 0xb, 0x10, 0x28, 0xc2, 0x9, 0x0, 0x0, 0x0, 0x14, 0xd9, 0x87, 0xd6, 0xf, 0x4b, 0x4c, 0xc, 0xd6, 0xe1, 0xd0, - 0x8d, 0xec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xb0, 0x57, 0x9a, 0x39, 0x66, 0xe8, 0x8, 0x7, 0x9b, 0x2d, 0x0, 0x18, 0x2e, 0x93, 0x7b, + 0x3c, 0xf7, 0xb4, 0x51, 0xca, 0x54, 0x2e, 0xc, 0xb9, 0x86, 0x3e, 0x13, 0x6e, 0x27, 0x54, 0x1c, 0xe6, 0xc9, 0xb2, + 0x7d, 0x41, 0xe, 0x0, 0xf, 0x3e, 0x39, 0x64, 0xea, 0x2f, 0x25, 0xaa, 0x4e, 0x26, 0xf2, 0x68, 0xea, 0xce, 0x86, + 0x86, 0x22, 0x0, 0x1b, 0x25, 0xd9, 0xfe, 0x9a, 0x85, 0x68, 0xc7, 0x6, 0x6f, 0x25, 0x80, 0xfd, 0x3b, 0x5f, 0x44, + 0x89, 0xe2, 0x5c, 0xaf, 0x39, 0x8a, 0x35, 0xf1, 0x42, 0x7, 0x32, 0xd4, 0xe, 0x0, 0x0, 0x5, 0x0, 0x7, 0xf1, + 0xbd, 0x77, 0x77, 0x3, 0xa4, 0xe2, 0x15, 0x0, 0x16, 0x45, 0xb4, 0x44, 0x98, 0xb4, 0xe8, 0xf6, 0xd4, 0xbb, 0x55, + 0x8a, 0xd1, 0xc5, 0xc1, 0xa0, 0x14, 0xa4, 0x6a, 0x7b, 0x82, 0xfd, 0xaa, 0x29, 0x0, 0xc, 0xc9, 0x6d, 0x48, 0xdb, + 0xc0, 0x2, 0x1a, 0x7b, 0x48, 0x8e, 0x51, 0x23, 0x24, 0x0, 0x2, 0xd5, 0xd2, 0x20, 0x0, 0x2, 0x5, 0x5d, 0x2a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd9, 0x87, 0xd6, 0xf, 0x4b, 0x4c, 0xc, 0xd6, 0xe1, 0xd0, - 0x8d, 0xec, 0xc2, 0x3a, 0x34, 0xd4, 0xa2, 0x7b, 0x10, 0x18}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xc5, 0xb4, 0x20}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcb, 0xc1, 0x3c, 0xdf, 0xc6, 0x94, 0x3d, 0xfc, 0x13, - 0x3d, 0x78, 0xc0, 0xcb, 0xd7, 0xe7, 0x32, 0xd3}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xde, 0xaa, 0x0, 0x75, 0x5b, 0x90, 0xbc, 0xd, 0xf3, 0x13, + 0x17, 0xf5, 0x3a, 0x3c, 0x5e, 0x59, 0xf7, 0x45, 0x57, 0xb0, + 0x57, 0x9a, 0x39, 0x66, 0xe8, 0x8, 0x7, 0x9b}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2d, 0x2e, 0x4e, 0x35, 0x50, 0x2, 0x43, 0x18}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2e, 0x93, 0x7b, 0x3c, 0xf7, 0xb4, 0x51, 0xca, 0x54, 0x2e, 0xc, 0xb9, + 0x86, 0x3e, 0x13, 0x6e, 0x27, 0x54, 0x1c, 0xe6, 0xc9, 0xb2, 0x7d, 0x41}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x93, 0x10, 0xd2, 0x4b, 0x1e, 0x2c, 0x6e, 0x8e, 0x3a, 0x30, 0x4f, 0xd9}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3e, 0x39, 0x64, 0xea, 0x2f, 0x25, 0xaa, 0x4e, + 0x26, 0xf2, 0x68, 0xea, 0xce, 0x86, 0x86}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2, 0x73, 0xbb, 0xd6, 0x6c, 0x24, 0x73, 0xa4, 0x39, 0x4f, 0x7, 0x89, - 0x4d, 0x84, 0xc5, 0x22, 0x97, 0xb3, 0xe5, 0x2c, 0xc1, 0xbc, 0x5e, 0xad}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x25, 0xd9, 0xfe, 0x9a, 0x85, 0x68, 0xc7, 0x6, 0x6f, 0x25, 0x80, 0xfd, 0x3b, 0x5f, + 0x44, 0x89, 0xe2, 0x5c, 0xaf, 0x39, 0x8a, 0x35, 0xf1, 0x42, 0x7, 0x32, 0xd4}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfc, 0x8a, 0x2b, 0xa, 0xaf, 0x3, 0xeb, 0x5c, 0x73, 0xe0, 0xd8, 0xf9, 0x6d, - 0xe4, 0x57, 0x4a, 0xc, 0x79, 0xc3, 0xe2, 0xc3, 0x23, 0xb6, 0x8b, 0xd7}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8f, 0xed, 0x2c, 0xb0, 0x24, 0x82, 0xf3, 0x2f, 0x10, 0x7f, - 0x9c, 0xe2, 0xc0, 0xc1, 0x49, 0x25, 0x44, 0x37, 0x61, 0x1a}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xf1, 0xbd, 0x77, 0x77, 0x3, 0xa4, 0xe2}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa0, 0x7d, 0xb2, 0xe5, 0x9a, 0x27, 0xaf, 0x3f, 0xb0, 0x49, 0xa7, 0x59, 0xf3, - 0x72, 0x2b, 0x94, 0xc0, 0x34, 0xba, 0x58, 0x3a, 0xc0, 0xf7, 0x72, 0xf6, 0x84}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x45, 0xb4, 0x44, 0x98, 0xb4, 0xe8, 0xf6, 0xd4, 0xbb, 0x55, 0x8a, + 0xd1, 0xc5, 0xc1, 0xa0, 0x14, 0xa4, 0x6a, 0x7b, 0x82, 0xfd, 0xaa}; + lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x14, 0x80, 0xa2, 0xe, 0x98, 0x5d, 0xbc, 0x11, 0xb8, 0xae, 0x4d, 0x88, 0x14, - 0xcb, 0xeb, 0xa4, 0xcb, 0x6, 0x88, 0xd0, 0xff, 0x4e, 0x85, 0xfa, 0xad}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xc9, 0x6d, 0x48, 0xdb, 0xc0, 0x2, 0x1a, 0x7b, 0x48, 0x8e, 0x51, 0x23}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x3f, 0x27, 0x68, 0xa, 0xf0, 0x6a, 0x8, 0xf4, 0x3b, 0x81, 0x7f, - 0xcb, 0xa9, 0x5, 0x95, 0x8c, 0x83, 0xa8, 0x68, 0x89, 0x24}; - lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0xd5, 0xd2}; + lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + uint8_t topic_filter_s10_bytes[] = {0x5, 0x5d}; + lwmqtt_string_t topic_filter_s10 = {2, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; + sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = false; sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = true; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; sub_opts[8].no_local = true; sub_opts[9].qos = LWMQTT_QOS0; sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = true; - uint8_t bytesprops1[] = {0x43, 0xb4, 0x30, 0x8b, 0x4d, 0x99, 0x7b, 0xeb, 0x58, 0x40}; - uint8_t bytesprops0[] = {0x27, 0xf0, 0xf7, 0xf9, 0xc0, 0x6a, 0x82, 0xe9, 0x36, 0x85}; - uint8_t bytesprops2[] = {0x96, 0x1a, 0x64, 0xa9, 0x7c, 0x52, 0xa, 0x93, 0x89, 0x5c, - 0x9a, 0x82, 0x20, 0x48, 0x98, 0xb7, 0x85, 0x59, 0xc9}; - uint8_t bytesprops3[] = {0}; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = false; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x8d, 0xb3, 0xf4, 0xe6, 0x60, 0x40, 0x13, 0xdc, 0xd5, 0x43, 0x16, 0xf4, 0x16, + 0x91, 0xbc, 0xf7, 0x55, 0xfe, 0x86, 0x2c, 0x93, 0x79, 0x4b, 0xf8, 0x29}; + uint8_t bytesprops2[] = {0x3f, 0x64, 0x10, 0xd0, 0xa8, 0xe1, 0xe9, 0xbc, 0xce}; + uint8_t bytesprops3[] = {0x2a, 0xf1, 0xcb, 0xe6, 0xdb, 0x4c, 0x65, 0x55, 0x8b}; + uint8_t bytesprops4[] = {0x87, 0xea, 0x93, 0x63, 0x5b, 0xaa, 0x3e, 0xf4, 0x98, + 0xc1, 0x21, 0x23, 0xb, 0x1, 0x8c, 0x4f, 0xd, 0xf4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1940}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30321}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32334}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13456}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13969}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 16}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 944}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13237}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23923}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6461}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1918}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4697}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7339}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1259}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8341}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27288, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30378, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14432 [("\132\142U\243\225d\SO^\184\204\176\ng\214\232",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\ap\172QO\204\154J[\145n",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\RS\167x\142;=\175\194m}:\128\206\146\&5 PF\224\155",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\168c\156\132\130\233l",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\138\204\153\191\242P(t/<\251\206\247P*\239f",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\SOH5\252\ETX\182\137\247D\155\b\175\SO\193\137\fS\148\225\133^a\a\207T\160",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\182\129\173\SUB\239\244",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\ACK\163\NAK\DC1\195\169\246\220\EMt-\224\251\210\190k\170\170\251\193\&0\DC1\208\233\&1\NUL1",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\n\SUB\192\143\n1\SYNu\131\135tm\186\224\200\235IQ4h>0",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("J\166;]\v@\SYNME\249\NAK -// \166\187\168h\EM,\194\193\148mF6\154d}\192",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// True, _noLocal = False, _subQoS = -// QoS1}),("\176\&9\ne\247S\212\228T\157k\157\139P\CAN\DC1\ESC\220\227$\252\ACK\217\192\128\128H\155\174",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropUserProperty -// "\142\218\SUBH\163\ACK\169\148\204M" "\DC2\184j;\156\173\ETB\nU\188\EOT>\207\159\rD\r",PropPayloadFormatIndicator -// 237,PropWildcardSubscriptionAvailable 4,PropSubscriptionIdentifierAvailable 162,PropServerReference -// "\170\DELT6\SOH\168\158\ESCR\253\162\161\132t\192\188+\165\218\t\225\DC4\163B\172",PropSubscriptionIdentifierAvailable -// 175,PropRequestResponseInformation 80,PropResponseInformation "8d",PropRequestProblemInformation -// 63,PropRetainAvailable 48,PropServerKeepAlive 22450,PropReceiveMaximum 14219,PropResponseTopic -// "m\217k\nt7\148(\186~\133\140\245\237J\ENQ",PropUserProperty "" "3\146\248\203m\190`\138\151 -// r\200OT\133\145\ACK\ESC",PropResponseInformation "\RS\FSCx\152aH -// o\153\162\135\&3\246\\\236Q\167\132#\165\139O\161P",PropRequestProblemInformation 165,PropAuthenticationMethod -// "\194a\161\204\182 F\207\229\182E&C",PropMaximumQoS 35,PropAssignedClientIdentifier -// "\151\199\136{B\237\184\233\157~6\157Y\255\163v\161\t:",PropRequestProblemInformation -// 7,PropSharedSubscriptionAvailable 113] +// SubscribeRequest 19363 [("\171\&6)kL\250\200\246\241\214\221\252\198\159`\172N\210\247r\234Q1",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("5\204P\216\&3\131s\130\148\&8\DC4t\225\207\132 +// \160\151\204o\EOT_\GS",PropSubscriptionIdentifierAvailable 144,PropSessionExpiryInterval 8274,PropCorrelationData +// "%\ETX\202l9\220V,`\241\205\243u\FS\ETX\179z\172\241\174\128y\CANR\247",PropMaximumQoS 99,PropAuthenticationMethod +// "\206@`\200\221\GS",PropMessageExpiryInterval 32660] TEST(Subscribe5QCTest, Encode10) { uint8_t pkt[] = { - 0x82, 0xbd, 0x3, 0x38, 0x60, 0xc9, 0x1, 0x26, 0x0,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df, 0xfd, + 0x7d, 0x68, 0x25, 0x0, 0xc, 0xbc, 0x9c, 0x10, 0x93, 0xba, 0x3b, 0x4a, 0xca, 0x3c, 0xec, 0xe5, 0xab, 0x24}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x84, 0x8e, 0x55, 0xf3, 0xe1, 0x64, 0xe, 0x5e, - 0xb8, 0xcc, 0xb0, 0xa, 0x67, 0xd6, 0xe8}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xab, 0x36, 0x29, 0x6b, 0x4c, 0xfa, 0xc8, 0xf6, 0xf1, 0xd6, 0xdd, 0xfc, + 0xc6, 0x9f, 0x60, 0xac, 0x4e, 0xd2, 0xf7, 0x72, 0xea, 0x51, 0x31}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7, 0x70, 0xac, 0x51, 0x4f, 0xcc, 0x9a, 0x4a, 0x5b, 0x91, 0x6e}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x35, 0xcc, 0x50, 0xd8, 0x33, 0x83, 0x73, 0x82, + 0x3c, 0x55, 0xd1, 0x61, 0x88, 0xb7, 0x83}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1e, 0xa7, 0x78, 0x8e, 0x3b, 0x3d, 0xaf, 0xc2, 0x6d, 0x7d, - 0x3a, 0x80, 0xce, 0x92, 0x35, 0x20, 0x50, 0x46, 0xe0, 0x9b}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x51, 0x55, 0xa8, 0x16, 0xc7}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa8, 0x63, 0x9c, 0x84, 0x82, 0xe9, 0x6c}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf7, 0xec, 0x3b, 0xe5, 0x39, 0x85, 0xad, 0xd0, 0xd5, 0x54, 0xe8, 0xea, + 0x25, 0xe, 0x48, 0x9d, 0xc1, 0xf7, 0xad, 0x13, 0xa2, 0x18, 0xd7}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8a, 0xcc, 0x99, 0xbf, 0xf2, 0x50, 0x28, 0x74, 0x2f, - 0x3c, 0xfb, 0xce, 0xf7, 0x50, 0x2a, 0xef, 0x66}; - lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x4c, 0x77, 0x1, 0xae, 0xdf, 0xfd, 0x7d, 0x68}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1, 0x35, 0xfc, 0x3, 0xb6, 0x89, 0xf7, 0x44, 0x9b, 0x8, 0xaf, 0xe, 0xc1, - 0x89, 0xc, 0x53, 0x94, 0xe1, 0x85, 0x5e, 0x61, 0x7, 0xcf, 0x54, 0xa0}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xbc, 0x9c, 0x10, 0x93, 0xba, 0x3b, 0x4a, 0xca, 0x3c, 0xec, 0xe5, 0xab}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb6, 0x81, 0xad, 0x1a, 0xef, 0xf4}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6, 0xa3, 0x15, 0x11, 0xc3, 0xa9, 0xf6, 0xdc, 0x19, 0x74, 0x2d, 0xe0, 0xfb, 0xd2, - 0xbe, 0x6b, 0xaa, 0xaa, 0xfb, 0xc1, 0x30, 0x11, 0xd0, 0xe9, 0x31, 0x0, 0x31}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa, 0x1a, 0xc0, 0x8f, 0xa, 0x31, 0x16, 0x75, 0x83, 0x87, 0x74, - 0x6d, 0xba, 0xe0, 0xc8, 0xeb, 0x49, 0x51, 0x34, 0x68, 0x3e, 0x30}; - lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x4a, 0xa6, 0x3b, 0x5d, 0xb, 0x40, 0x16, 0x4d, 0x45, 0xf9, - 0x15, 0x20, 0xa6, 0xbb, 0xa8, 0x68, 0x19, 0x2c, 0xc2, 0xc1, - 0x94, 0x6d, 0x46, 0x36, 0x9a, 0x64, 0x7d, 0xc0}; - lwmqtt_string_t topic_filter_s9 = {28, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xb0, 0x39, 0xa, 0x65, 0xf7, 0x53, 0xd4, 0xe4, 0x54, 0x9d, - 0x6b, 0x9d, 0x8b, 0x50, 0x18, 0x11, 0x1b, 0xdc, 0xe3, 0x24, - 0xfc, 0x6, 0xd9, 0xc0, 0x80, 0x80, 0x48, 0x9b, 0xae}; - lwmqtt_string_t topic_filter_s10 = {29, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; + lwmqtt_sub_options_t sub_opts[6]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; + sub_opts[4].retain_as_published = false; sub_opts[4].no_local = true; sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = true; - uint8_t bytesprops1[] = {0x12, 0xb8, 0x6a, 0x3b, 0x9c, 0xad, 0x17, 0xa, 0x55, - 0xbc, 0x4, 0x3e, 0xcf, 0x9f, 0xd, 0x44, 0xd}; - uint8_t bytesprops0[] = {0x8e, 0xda, 0x1a, 0x48, 0xa3, 0x6, 0xa9, 0x94, 0xcc, 0x4d}; - uint8_t bytesprops2[] = {0xaa, 0x7f, 0x54, 0x36, 0x1, 0xa8, 0x9e, 0x1b, 0x52, 0xfd, 0xa2, 0xa1, 0x84, - 0x74, 0xc0, 0xbc, 0x2b, 0xa5, 0xda, 0x9, 0xe1, 0x14, 0xa3, 0x42, 0xac}; - uint8_t bytesprops3[] = {0x38, 0x64}; - uint8_t bytesprops4[] = {0x6d, 0xd9, 0x6b, 0xa, 0x74, 0x37, 0x94, 0x28, - 0xba, 0x7e, 0x85, 0x8c, 0xf5, 0xed, 0x4a, 0x5}; - uint8_t bytesprops6[] = {0x33, 0x92, 0xf8, 0xcb, 0x6d, 0xbe, 0x60, 0x8a, 0x97, - 0x20, 0x72, 0xc8, 0x4f, 0x54, 0x85, 0x91, 0x6, 0x1b}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops7[] = {0x1e, 0x1c, 0x43, 0x78, 0x98, 0x61, 0x48, 0x20, 0x6f, 0x99, 0xa2, 0x87, 0x33, - 0xf6, 0x5c, 0xec, 0x51, 0xa7, 0x84, 0x23, 0xa5, 0x8b, 0x4f, 0xa1, 0x50}; - uint8_t bytesprops8[] = {0xc2, 0x61, 0xa1, 0xcc, 0xb6, 0x20, 0x46, 0xcf, 0xe5, 0xb6, 0x45, 0x26, 0x43}; - uint8_t bytesprops9[] = {0x97, 0xc7, 0x88, 0x7b, 0x42, 0xed, 0xb8, 0xe9, 0x9d, 0x7e, - 0x36, 0x9d, 0x59, 0xff, 0xa3, 0x76, 0xa1, 0x9, 0x3a}; + uint8_t bytesprops0[] = {0x31, 0x91, 0xba, 0x7e, 0xca, 0xa2, 0x9c, 0xf2, 0xea, 0xdf, 0x7d, 0xf1, 0x88, 0x57, 0xd7, + 0x7d, 0x4f, 0x17, 0x6e, 0xe2, 0x2, 0xe4, 0xaa, 0x27, 0x0, 0xfa, 0x55, 0x56, 0xe9}; + uint8_t bytesprops1[] = {0x3f, 0xc1, 0xdc, 0x14, 0xc3, 0xdf, 0x4e, 0xc0, 0xf6, 0x78, 0xf6, 0x3a, 0x3c, 0x4b, 0x9d, + 0x49, 0xd0, 0xcc, 0x36, 0xca, 0xf1, 0x4a, 0xc9, 0xd2, 0xbb, 0x9f, 0xbc, 0x38, 0x1b, 0x88}; + uint8_t bytesprops2[] = {0x5f, 0xaf, 0x0, 0xa8, 0x7d, 0x4d, 0xdc, 0x73, 0x8e, 0xef, 0x7f, 0x3, 0xcb, 0xd6, + 0xe3, 0xcf, 0x0, 0x46, 0xba, 0xd4, 0xb9, 0xd0, 0xd4, 0x88, 0x47, 0x1f, 0x91, 0xad}; + uint8_t bytesprops3[] = {0xe2, 0x3b, 0x8, 0x61, 0x44}; + uint8_t bytesprops4[] = {0xd, 0x5b, 0xe}; + uint8_t bytesprops5[] = {0x4c, 0x9b, 0xff, 0x8b}; + uint8_t bytesprops6[] = {0x7d, 0x4e, 0x12, 0x27, 0xa3, 0xb9, 0x39, 0xfc, 0x79, 0xa8, 0x3e, 0x94, 0x38, + 0x14, 0x74, 0xe1, 0xcf, 0x84, 0x20, 0xa0, 0x97, 0xcc, 0x6f, 0x4, 0x5f, 0x1d}; + uint8_t bytesprops7[] = {0x25, 0x3, 0xca, 0x6c, 0x39, 0xdc, 0x56, 0x2c, 0x60, 0xf1, 0xcd, 0xf3, 0x75, + 0x1c, 0x3, 0xb3, 0x7a, 0xac, 0xf1, 0xae, 0x80, 0x79, 0x18, 0x52, 0xf7}; + uint8_t bytesprops8[] = {0xce, 0x40, 0x60, 0xc8, 0xdd, 0x1d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {17, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22450}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14219}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops5}, .v = {18, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31882}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1252}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8274}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32660}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14432, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19363, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29362 [("_\243\230\136\DEL\192\SOH\129",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),(")^\224-\RSS\187\132\DLE\157\228F\236\193P/= -// \US\203\163d<\r>\228\239\253\SO\223",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS0}),("d!#X=\180_\191R\DEL\180\224\148\190i\152\228b",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\209\139\ACKUg\\\156\248\"\241\232*\SUB\148\"~\131c\rpq\ENQ\DC3\212\179y\RSX",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("_\231\198F\215\f\226\236\156vQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS0}),("\225_l!\242_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// True, _noLocal = False, _subQoS = QoS0})] [PropSessionExpiryInterval 17671,PropPayloadFormatIndicator -// 109,PropReceiveMaximum 31944,PropMaximumQoS 115,PropAuthenticationMethod -// "AG\157\204\\\192q\186\177W\175=",PropSubscriptionIdentifierAvailable 57,PropSessionExpiryInterval -// 1970,PropTopicAliasMaximum 24957,PropCorrelationData -// "\217\180\148\160\CANiA\220z\140\188g*Oy\170\&2\230;\"\166\178\NUL\217\219<",PropAuthenticationMethod -// "7\SI",PropServerReference "\231\247\170\t\EM"] +// SubscribeRequest 9790 [("\228F\148\174g\141\DC4\140\249o\196",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\177\151IY\145b\217z\r\205(B\253yT[~Z\183f\246^_IZ",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\n\173\216\DC2G\235Y\189fi\DC1\185g\229\bEH\252F\242\216\ACK\231\243\237\242",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),(">A",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\163\133MU\FSV\131 +// V\b\ESC\210U\147\&0ma\248",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = +// True, _subQoS = QoS0}),("\250.\ETBh\239;\217\248\159\219\202\SOH\FS\135\218 \219\&3\ENQ\153s\199",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\207\SI/?@\201.\216\171h\187\128\242o|\144\158z,W\207\136",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropMessageExpiryInterval 28136,PropRetainAvailable +// 88,PropTopicAliasMaximum 14486,PropMaximumPacketSize 10234,PropPayloadFormatIndicator 110] TEST(Subscribe5QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0xc9, 0x1, 0x72, 0xb2, 0x4f, 0x11, 0x0, 0x0, 0x45, 0x7, 0x1, 0x6d, 0x21, 0x7c, 0xc8, 0x24, - 0x73, 0x15, 0x0, 0xc, 0x41, 0x47, 0x9d, 0xcc, 0x5c, 0xc0, 0x71, 0xba, 0xb1, 0x57, 0xaf, 0x3d, 0x29, - 0x39, 0x11, 0x0, 0x0, 0x7, 0xb2, 0x22, 0x61, 0x7d, 0x9, 0x0, 0x1a, 0xd9, 0xb4, 0x94, 0xa0, 0x18, - 0x69, 0x41, 0xdc, 0x7a, 0x8c, 0xbc, 0x67, 0x2a, 0x4f, 0x79, 0xaa, 0x32, 0xe6, 0x3b, 0x22, 0x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, 0x7a, 0xd, 0xcd, 0x28, 0x42, + 0xfd, 0x79, 0x54, 0x5b, 0x7e, 0x5a, 0xb7, 0x66, 0xf6, 0x5e, 0x5f, 0x49, 0x5a, 0x20, 0x0, 0x1a, 0xa, + 0xad, 0xd8, 0x12, 0x47, 0xeb, 0x59, 0xbd, 0x66, 0x69, 0x11, 0xb9, 0x67, 0xe5, 0x8, 0x45, 0x48, 0xfc, + 0x46, 0xf2, 0xd8, 0x6, 0xe7, 0xf3, 0xed, 0xf2, 0xa, 0x0, 0x2, 0x3e, 0x41, 0xd, 0x0, 0x12, 0xa3, + 0x85, 0x4d, 0x55, 0x1c, 0x56, 0x83, 0x20, 0x56, 0x8, 0x1b, 0xd2, 0x55, 0x93, 0x30, 0x6d, 0x61, 0xf8, + 0x24, 0x0, 0x16, 0xfa, 0x2e, 0x17, 0x68, 0xef, 0x3b, 0xd9, 0xf8, 0x9f, 0xdb, 0xca, 0x1, 0x1c, 0x87, + 0xda, 0x20, 0xdb, 0x33, 0x5, 0x99, 0x73, 0xc7, 0xa, 0x0, 0x16, 0xcf, 0xf, 0x2f, 0x3f, 0x40, 0xc9, + 0x2e, 0xd8, 0xab, 0x68, 0xbb, 0x80, 0xf2, 0x6f, 0x7c, 0x90, 0x9e, 0x7a, 0x2c, 0x57, 0xcf, 0x88, 0xc}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x5f, 0xf3, 0xe6, 0x88, 0x7f, 0xc0, 0x1, 0x81}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xe4, 0x46, 0x94, 0xae, 0x67, 0x8d, 0x14, 0x8c, 0xf9, 0x6f, 0xc4}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x29, 0x5e, 0xe0, 0x2d, 0x1e, 0x53, 0xbb, 0x84, 0x10, 0x9d, - 0xe4, 0x46, 0xec, 0xc1, 0x50, 0x2f, 0x3d, 0x20, 0x1f, 0xcb, - 0xa3, 0x64, 0x3c, 0xd, 0x3e, 0xe4, 0xef, 0xfd, 0xe, 0xdf}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb1, 0x97, 0x49, 0x59, 0x91, 0x62, 0xd9, 0x7a, 0xd, 0xcd, 0x28, 0x42, 0xfd, + 0x79, 0x54, 0x5b, 0x7e, 0x5a, 0xb7, 0x66, 0xf6, 0x5e, 0x5f, 0x49, 0x5a}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x64, 0x21, 0x23, 0x58, 0x3d, 0xb4, 0x5f, 0xbf, 0x52, - 0x7f, 0xb4, 0xe0, 0x94, 0xbe, 0x69, 0x98, 0xe4, 0x62}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa, 0xad, 0xd8, 0x12, 0x47, 0xeb, 0x59, 0xbd, 0x66, 0x69, 0x11, 0xb9, 0x67, + 0xe5, 0x8, 0x45, 0x48, 0xfc, 0x46, 0xf2, 0xd8, 0x6, 0xe7, 0xf3, 0xed, 0xf2}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd1, 0x8b, 0x6, 0x55, 0x67, 0x5c, 0x9c, 0xf8, 0x22, 0xf1, - 0xe8, 0x2a, 0x1a, 0x94, 0x22, 0x7e, 0x83, 0x63, 0xd, 0x70, - 0x71, 0x5, 0x13, 0xd4, 0xb3, 0x79, 0x1e, 0x58}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3e, 0x41}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5f, 0xe7, 0xc6, 0x46, 0xd7, 0xc, 0xe2, 0xec, 0x9c, 0x76, 0x51}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa3, 0x85, 0x4d, 0x55, 0x1c, 0x56, 0x83, 0x20, 0x56, + 0x8, 0x1b, 0xd2, 0x55, 0x93, 0x30, 0x6d, 0x61, 0xf8}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe1, 0x5f, 0x6c, 0x21, 0xf2, 0x5f}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xfa, 0x2e, 0x17, 0x68, 0xef, 0x3b, 0xd9, 0xf8, 0x9f, 0xdb, 0xca, + 0x1, 0x1c, 0x87, 0xda, 0x20, 0xdb, 0x33, 0x5, 0x99, 0x73, 0xc7}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0xcf, 0xf, 0x2f, 0x3f, 0x40, 0xc9, 0x2e, 0xd8, 0xab, 0x68, 0xbb, + 0x80, 0xf2, 0x6f, 0x7c, 0x90, 0x9e, 0x7a, 0x2c, 0x57, 0xcf, 0x88}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = true; sub_opts[5].no_local = false; - uint8_t bytesprops0[] = {0x41, 0x47, 0x9d, 0xcc, 0x5c, 0xc0, 0x71, 0xba, 0xb1, 0x57, 0xaf, 0x3d}; - uint8_t bytesprops1[] = {0xd9, 0xb4, 0x94, 0xa0, 0x18, 0x69, 0x41, 0xdc, 0x7a, 0x8c, 0xbc, 0x67, 0x2a, - 0x4f, 0x79, 0xaa, 0x32, 0xe6, 0x3b, 0x22, 0xa6, 0xb2, 0x0, 0xd9, 0xdb, 0x3c}; - uint8_t bytesprops2[] = {0x37, 0xf}; - uint8_t bytesprops3[] = {0xe7, 0xf7, 0xaa, 0x9, 0x19}; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17671}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31944}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1970}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24957}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28136}}, {.prop = (lwmqtt_prop_t)37, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14486}}, {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10234}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 110}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29362, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9790, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18382 -// [("\231\EM\193\193q\251\CAN\154\SYN\230\146\204c_\141w\148\DC3\215\RS!\ETXw\186x$n\182\231",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] -// [PropReasonString "\CANB\238hj\224\196'\158a\212\187\182@\252R\213t\232\172\160t",PropUserProperty -// "\134\SI)\190\160|\ETB\191L\190\230+\223\&7\165" "M\233\USZ\246\&7",PropWildcardSubscriptionAvailable -// 232,PropUserProperty "\GS\137\251W\186\DC2o" "\175!9x!",PropPayloadFormatIndicator 19,PropAuthenticationMethod -// "\155\207l_\130\157\153\NAK?\212(I\CAN\202\134NwZ\DC4\251",PropCorrelationData -// "<\133j\146\US%\245\222&u",PropSharedSubscriptionAvailable 232,PropCorrelationData -// "\192\182W\226\171\177^\223\192rK{\149\227\220",PropSubscriptionIdentifier 1,PropServerReference -// "",PropSubscriptionIdentifier 3,PropSubscriptionIdentifier 8,PropAssignedClientIdentifier -// "L-\191e\216",PropWillDelayInterval 25674,PropMessageExpiryInterval 17484,PropSessionExpiryInterval -// 4335,PropResponseTopic "~\ACK\DC3\218\190\SUB\195C\248t(!q\230/\238h\205\218\254\214",PropMessageExpiryInterval -// 2322,PropTopicAlias 2796,PropRequestProblemInformation 232,PropMaximumQoS 9,PropRequestResponseInformation -// 65,PropTopicAlias 26821,PropAssignedClientIdentifier -// "R\240a\227\151\225QM\213G\197\199*9\226\DEL\197\170\202\213J@\142&(\204",PropTopicAlias -// 9265,PropWildcardSubscriptionAvailable 53] +// SubscribeRequest 29850 [("\ESC\148a",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = +// QoS2}),("e\"\230B\SYNNm^{\160\218\FS\152\238\232\143\135\180\197\251D\202\205n\STX\161\f\175\165}",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("]\RS\172\169\198\239\243#\136\243\DC37n\177\215k\167\243",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("Q\129=ls\SI\233\136\246\208\170\188\SUBg\134\155B",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("[=",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\174\230\194'q",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\\%\201\190\183\&1\138\217=~\181c\233?\138\160X",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\SI\159f\134\CAN%\254\185\194T\216\145[\248\229\214>\170\216\164",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\164r\209\EOTC\218[-BMGq\236>M\194\139H\216\165:R\132t\179\224\157C\147%",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropMessageExpiryInterval +// 26319,PropSubscriptionIdentifier 27,PropAuthenticationMethod +// "\SOH\200\&0\232\SI\ACK\236\165P\233&\222\255\231\SO\200\128sY\162(|!\196\SI\247",PropServerReference +// "vO\174\253d8\v\150\DC2\STX\187^\am\192%\153w\DC2\205\v",PropCorrelationData "9\f\138b\248L\160\160\151 +// \GS\221",PropMessageExpiryInterval 11750,PropTopicAliasMaximum 14828,PropAuthenticationMethod +// "\140\188?\ACKn\238\FSL\NAK\DC1\SYNfM\166\t\162\ACK\221\212\154\t+\181S\152\SUB",PropMessageExpiryInterval +// 10067,PropRetainAvailable 35,PropServerKeepAlive 9584,PropAssignedClientIdentifier +// "<\209\173Y",PropMessageExpiryInterval 12571,PropTopicAliasMaximum 10964,PropPayloadFormatIndicator +// 229,PropAssignedClientIdentifier "\164\156\187",PropServerReference +// "\213\188\SYN\ENQ\232\182j\203\NAK\158",PropSubscriptionIdentifierAvailable 125,PropRetainAvailable +// 81,PropSharedSubscriptionAvailable 18,PropPayloadFormatIndicator 82,PropAssignedClientIdentifier +// "3\236;\DC4\134\228\232\182\245\167rK\247\169\184\166\&7]\DEL\STX5",PropReasonString "\STX\SYNg0\178\143\157y\208\&9 +// K<\133\244\232\t_\218,@\174Q\237\156",PropTopicAliasMaximum 964] TEST(Subscribe5QCTest, Encode12) { uint8_t pkt[] = { - 0x82, 0x8f, 0x2, 0x47, 0xce, 0xeb, 0x1, 0x1f, 0x0, 0x16, 0x18, 0x42, 0xee, 0x68, 0x6a, 0xe0, 0xc4, 0x27, 0x9e, - 0x61, 0xd4, 0xbb, 0xb6, 0x40, 0xfc, 0x52, 0xd5, 0x74, 0xe8, 0xac, 0xa0, 0x74, 0x26, 0x0, 0xf, 0x86, 0xf, 0x29, - 0xbe, 0xa0, 0x7c, 0x17, 0xbf, 0x4c, 0xbe, 0xe6, 0x2b, 0xdf, 0x37, 0xa5, 0x0, 0x6, 0x4d, 0xe9, 0x1f, 0x5a, 0xf6, - 0x37, 0x28, 0xe8, 0x26, 0x0, 0x7, 0x1d, 0x89, 0xfb, 0x57, 0xba, 0x12, 0x6f, 0x0, 0x5, 0xaf, 0x21, 0x39, 0x78, - 0x21, 0x1, 0x13, 0x15, 0x0, 0x14, 0x9b, 0xcf, 0x6c, 0x5f, 0x82, 0x9d, 0x99, 0x15, 0x3f, 0xd4, 0x28, 0x49, 0x18, - 0xca, 0x86, 0x4e, 0x77, 0x5a, 0x14, 0xfb, 0x9, 0x0, 0xa, 0x3c, 0x85, 0x6a, 0x92, 0x1f, 0x25, 0xf5, 0xde, 0x26, - 0x75, 0x2a, 0xe8, 0x9, 0x0, 0xf, 0xc0, 0xb6, 0x57, 0xe2, 0xab, 0xb1, 0x5e, 0xdf, 0xc0, 0x72, 0x4b, 0x7b, 0x95, - 0xe3, 0xdc, 0xb, 0x1, 0x1c, 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 0x16, 0x4e, 0x6d, 0x5e, 0x7b, 0xa0, 0xda, + 0x1c, 0x98, 0xee, 0xe8, 0x8f, 0x87, 0xb4, 0xc5, 0xfb, 0x44, 0xca, 0xcd, 0x6e, 0x2, 0xa1, 0xc, 0xaf, 0xa5, 0x7d, + 0x0, 0x0, 0x12, 0x5d, 0x1e, 0xac, 0xa9, 0xc6, 0xef, 0xf3, 0x23, 0x88, 0xf3, 0x13, 0x37, 0x6e, 0xb1, 0xd7, 0x6b, + 0xa7, 0xf3, 0x5, 0x0, 0x11, 0x51, 0x81, 0x3d, 0x6c, 0x73, 0xf, 0xe9, 0x88, 0xf6, 0xd0, 0xaa, 0xbc, 0x1a, 0x67, + 0x86, 0x9b, 0x42, 0x20, 0x0, 0x2, 0x5b, 0x3d, 0x14, 0x0, 0x5, 0xae, 0xe6, 0xc2, 0x27, 0x71, 0x12, 0x0, 0x11, + 0x5c, 0x25, 0xc9, 0xbe, 0xb7, 0x31, 0x8a, 0xd9, 0x3d, 0x7e, 0xb5, 0x63, 0xe9, 0x3f, 0x8a, 0xa0, 0x58, 0x19, 0x0, + 0x14, 0xf, 0x9f, 0x66, 0x86, 0x18, 0x25, 0xfe, 0xb9, 0xc2, 0x54, 0xd8, 0x91, 0x5b, 0xf8, 0xe5, 0xd6, 0x3e, 0xaa, + 0xd8, 0xa4, 0x15, 0x0, 0x1e, 0xa4, 0x72, 0xd1, 0x4, 0x43, 0xda, 0x5b, 0x2d, 0x42, 0x4d, 0x47, 0x71, 0xec, 0x3e, + 0x4d, 0xc2, 0x8b, 0x48, 0xd8, 0xa5, 0x3a, 0x52, 0x84, 0x74, 0xb3, 0xe0, 0x9d, 0x43, 0x93, 0x25, 0x2c}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xe7, 0x19, 0xc1, 0xc1, 0x71, 0xfb, 0x18, 0x9a, 0x16, 0xe6, - 0x92, 0xcc, 0x63, 0x5f, 0x8d, 0x77, 0x94, 0x13, 0xd7, 0x1e, - 0x21, 0x3, 0x77, 0xba, 0x78, 0x24, 0x6e, 0xb6, 0xe7}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x1b, 0x94, 0x61}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; + uint8_t topic_filter_s1_bytes[] = {0x65, 0x22, 0xe6, 0x42, 0x16, 0x4e, 0x6d, 0x5e, 0x7b, 0xa0, + 0xda, 0x1c, 0x98, 0xee, 0xe8, 0x8f, 0x87, 0xb4, 0xc5, 0xfb, + 0x44, 0xca, 0xcd, 0x6e, 0x2, 0xa1, 0xc, 0xaf, 0xa5, 0x7d}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5d, 0x1e, 0xac, 0xa9, 0xc6, 0xef, 0xf3, 0x23, 0x88, + 0xf3, 0x13, 0x37, 0x6e, 0xb1, 0xd7, 0x6b, 0xa7, 0xf3}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x51, 0x81, 0x3d, 0x6c, 0x73, 0xf, 0xe9, 0x88, 0xf6, + 0xd0, 0xaa, 0xbc, 0x1a, 0x67, 0x86, 0x9b, 0x42}; + lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x5b, 0x3d}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xae, 0xe6, 0xc2, 0x27, 0x71}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x5c, 0x25, 0xc9, 0xbe, 0xb7, 0x31, 0x8a, 0xd9, 0x3d, + 0x7e, 0xb5, 0x63, 0xe9, 0x3f, 0x8a, 0xa0, 0x58}; + lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf, 0x9f, 0x66, 0x86, 0x18, 0x25, 0xfe, 0xb9, 0xc2, 0x54, + 0xd8, 0x91, 0x5b, 0xf8, 0xe5, 0xd6, 0x3e, 0xaa, 0xd8, 0xa4}; + lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa4, 0x72, 0xd1, 0x4, 0x43, 0xda, 0x5b, 0x2d, 0x42, 0x4d, + 0x47, 0x71, 0xec, 0x3e, 0x4d, 0xc2, 0x8b, 0x48, 0xd8, 0xa5, + 0x3a, 0x52, 0x84, 0x74, 0xb3, 0xe0, 0x9d, 0x43, 0x93, 0x25}; + lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - uint8_t bytesprops0[] = {0x18, 0x42, 0xee, 0x68, 0x6a, 0xe0, 0xc4, 0x27, 0x9e, 0x61, 0xd4, - 0xbb, 0xb6, 0x40, 0xfc, 0x52, 0xd5, 0x74, 0xe8, 0xac, 0xa0, 0x74}; - uint8_t bytesprops2[] = {0x4d, 0xe9, 0x1f, 0x5a, 0xf6, 0x37}; - uint8_t bytesprops1[] = {0x86, 0xf, 0x29, 0xbe, 0xa0, 0x7c, 0x17, 0xbf, 0x4c, 0xbe, 0xe6, 0x2b, 0xdf, 0x37, 0xa5}; - uint8_t bytesprops4[] = {0xaf, 0x21, 0x39, 0x78, 0x21}; - uint8_t bytesprops3[] = {0x1d, 0x89, 0xfb, 0x57, 0xba, 0x12, 0x6f}; - uint8_t bytesprops5[] = {0x9b, 0xcf, 0x6c, 0x5f, 0x82, 0x9d, 0x99, 0x15, 0x3f, 0xd4, - 0x28, 0x49, 0x18, 0xca, 0x86, 0x4e, 0x77, 0x5a, 0x14, 0xfb}; - uint8_t bytesprops6[] = {0x3c, 0x85, 0x6a, 0x92, 0x1f, 0x25, 0xf5, 0xde, 0x26, 0x75}; - uint8_t bytesprops7[] = {0xc0, 0xb6, 0x57, 0xe2, 0xab, 0xb1, 0x5e, 0xdf, 0xc0, 0x72, 0x4b, 0x7b, 0x95, 0xe3, 0xdc}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops9[] = {0x4c, 0x2d, 0xbf, 0x65, 0xd8}; - uint8_t bytesprops10[] = {0x7e, 0x6, 0x13, 0xda, 0xbe, 0x1a, 0xc3, 0x43, 0xf8, 0x74, 0x28, - 0x21, 0x71, 0xe6, 0x2f, 0xee, 0x68, 0xcd, 0xda, 0xfe, 0xd6}; - uint8_t bytesprops11[] = {0x52, 0xf0, 0x61, 0xe3, 0x97, 0xe1, 0x51, 0x4d, 0xd5, 0x47, 0xc5, 0xc7, 0x2a, - 0x39, 0xe2, 0x7f, 0xc5, 0xaa, 0xca, 0xd5, 0x4a, 0x40, 0x8e, 0x26, 0x28, 0xcc}; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + uint8_t bytesprops0[] = {0x1, 0xc8, 0x30, 0xe8, 0xf, 0x6, 0xec, 0xa5, 0x50, 0xe9, 0x26, 0xde, 0xff, + 0xe7, 0xe, 0xc8, 0x80, 0x73, 0x59, 0xa2, 0x28, 0x7c, 0x21, 0xc4, 0xf, 0xf7}; + uint8_t bytesprops1[] = {0x76, 0x4f, 0xae, 0xfd, 0x64, 0x38, 0xb, 0x96, 0x12, 0x2, 0xbb, + 0x5e, 0x7, 0x6d, 0xc0, 0x25, 0x99, 0x77, 0x12, 0xcd, 0xb}; + uint8_t bytesprops2[] = {0x39, 0xc, 0x8a, 0x62, 0xf8, 0x4c, 0xa0, 0xa0, 0x97, 0x20, 0x1d, 0xdd}; + uint8_t bytesprops3[] = {0x8c, 0xbc, 0x3f, 0x6, 0x6e, 0xee, 0x1c, 0x4c, 0x15, 0x11, 0x16, 0x66, 0x4d, + 0xa6, 0x9, 0xa2, 0x6, 0xdd, 0xd4, 0x9a, 0x9, 0x2b, 0xb5, 0x53, 0x98, 0x1a}; + uint8_t bytesprops4[] = {0x3c, 0xd1, 0xad, 0x59}; + uint8_t bytesprops5[] = {0xa4, 0x9c, 0xbb}; + uint8_t bytesprops6[] = {0xd5, 0xbc, 0x16, 0x5, 0xe8, 0xb6, 0x6a, 0xcb, 0x15, 0x9e}; + uint8_t bytesprops7[] = {0x33, 0xec, 0x3b, 0x14, 0x86, 0xe4, 0xe8, 0xb6, 0xf5, 0xa7, 0x72, + 0x4b, 0xf7, 0xa9, 0xb8, 0xa6, 0x37, 0x5d, 0x7f, 0x2, 0x35}; + uint8_t bytesprops8[] = {0x2, 0x16, 0x67, 0x30, 0xb2, 0x8f, 0x9d, 0x79, 0xd0, 0x39, 0x20, 0x4b, 0x3c, + 0x85, 0xf4, 0xe8, 0x9, 0x5f, 0xda, 0x2c, 0x40, 0xae, 0x51, 0xed, 0x9c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 1}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 3}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25674}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17484}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4335}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2322}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2796}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26821}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9265}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26319}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11750}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14828}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10067}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9584}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12571}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10964}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 964}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18382, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29850, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3280 [("\252\153?\GSp",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS0}),("_\132\USe\201\201\207X\SI%\DC4\188n<\231p\ACK{\157\165\215\142\182\165\234\137\&6u",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\\3\146\160\169\t\156\ENQ\193$\238\197jL\b\216\252\216",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\ETX\240",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\a;J7U.\178\156\&8d\196\SO$\145\224\131Y\200\&2+;l",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("E\177t%H\185\EOTxHjzc\212\174}XI\SYNBe*\SOH\249Q6R\NUL-",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropRetainAvailable 175,PropAuthenticationData -// "\USv~\243c,\215\v\DC1\f6\144Fq\DC4\139\155\221\176s\STX)v\240",PropWildcardSubscriptionAvailable -// 10,PropRequestProblemInformation 16,PropCorrelationData "?}\242\DLE\167c\144\DEL\EOT\156j\153\147\136\225 -// l\SOH\217\193\172\ETBH\v\DLE\192\ACK\246",PropMaximumPacketSize 3641,PropReasonString -// "\186\162n\130\150\147\146D\211E\181\230C\128\128?\248\209G\153\246\208\197\n\213PJ\SUB\156\201",PropWildcardSubscriptionAvailable -// 100,PropSubscriptionIdentifier 7,PropUserProperty "\NUL\246\DLEZWL-\NAK,4\169[C\128[\163k\200" -// "\188V\202\176h\CAN\165\200\GS$TP|\171kc\199\191-\ACK\233\231.5\235[\197i\158\138",PropRetainAvailable -// 77,PropRequestProblemInformation 176] +// SubscribeRequest 18338 [("\162\249\GS\153yq\215F\221 \242",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\158\168o!e\ACK\247\202\128\152f\197m\\\176\247(\167\US\214\188ti\225\192",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] +// [PropWildcardSubscriptionAvailable 74,PropCorrelationData +// "\212\&9\241\219\226\155\134$\130\148\ETB",PropServerReference +// "\133\186\RS\134\232\203\&7\160\143\156BI\221",PropServerKeepAlive 21739,PropTopicAlias +// 16767,PropRequestResponseInformation 119,PropTopicAliasMaximum 17366,PropUserProperty +// "\242\188u\255\247\210E\191yL\224%\a\189\209\159\207&\246\209\DEL" +// "\155\&83\197\178\150\144|\151DO",PropReceiveMaximum 15132,PropWildcardSubscriptionAvailable +// 163,PropMessageExpiryInterval 24957,PropAssignedClientIdentifier +// "N\225O\f\254\177\232\162\171OZ\t\201\163x",PropWildcardSubscriptionAvailable 94,PropReceiveMaximum +// 29341,PropSubscriptionIdentifierAvailable 220,PropReceiveMaximum 73,PropCorrelationData +// "i\128\206\251\215,\255~\ACK\RS",PropReceiveMaximum 731,PropSessionExpiryInterval 14347] TEST(Subscribe5QCTest, Encode13) { uint8_t pkt[] = { - 0x82, 0xa0, 0x2, 0xc, 0xd0, 0xa3, 0x1, 0x25, 0xaf, 0x16, 0x0, 0x18, 0x1f, 0x76, 0x7e, 0xf3, 0x63, 0x2c, 0xd7, - 0xb, 0x11, 0xc, 0x36, 0x90, 0x46, 0x71, 0x14, 0x8b, 0x9b, 0xdd, 0xb0, 0x73, 0x2, 0x29, 0x76, 0xf0, 0x28, 0xa, - 0x17, 0x10, 0x9, 0x0, 0x1c, 0x3f, 0x7d, 0xf2, 0x10, 0xa7, 0x63, 0x90, 0x7f, 0x4, 0x9c, 0x6a, 0x99, 0x93, 0x88, - 0xe1, 0x20, 0x6c, 0x1, 0xd9, 0xc1, 0xac, 0x17, 0x48, 0xb, 0x10, 0xc0, 0x6, 0xf6, 0x27, 0x0, 0x0, 0xe, 0x39, - 0x1f, 0x0, 0x1e, 0xba, 0xa2, 0x6e, 0x82, 0x96, 0x93, 0x92, 0x44, 0xd3, 0x45, 0xb5, 0xe6, 0x43, 0x80, 0x80, 0x3f, - 0xf8, 0x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xb0, 0xf7, 0x28, 0xa7, 0x1f, 0xd6, 0xbc, 0x74, 0x69, 0xe1, 0xc0, 0x2c}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xfc, 0x99, 0x3f, 0x1d, 0x70}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xa2, 0xf9, 0x1d, 0x99, 0x79, 0x71, 0xd7, 0x46, 0xdd, 0x20, 0xf2}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5f, 0x84, 0x1f, 0x65, 0xc9, 0xc9, 0xcf, 0x58, 0xf, 0x25, - 0x14, 0xbc, 0x6e, 0x3c, 0xe7, 0x70, 0x6, 0x7b, 0x9d, 0xa5, - 0xd7, 0x8e, 0xb6, 0xa5, 0xea, 0x89, 0x36, 0x75}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9e, 0xa8, 0x6f, 0x21, 0x65, 0x6, 0xf7, 0xca, 0x80, 0x98, 0x66, 0xc5, 0x6d, + 0x5c, 0xb0, 0xf7, 0x28, 0xa7, 0x1f, 0xd6, 0xbc, 0x74, 0x69, 0xe1, 0xc0}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5c, 0x33, 0x92, 0xa0, 0xa9, 0x9, 0x9c, 0x5, 0xc1, - 0x24, 0xee, 0xc5, 0x6a, 0x4c, 0x8, 0xd8, 0xfc, 0xd8}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3, 0xf0}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7, 0x3b, 0x4a, 0x37, 0x55, 0x2e, 0xb2, 0x9c, 0x38, 0x64, 0xc4, - 0xe, 0x24, 0x91, 0xe0, 0x83, 0x59, 0xc8, 0x32, 0x2b, 0x3b, 0x6c}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x45, 0xb1, 0x74, 0x25, 0x48, 0xb9, 0x4, 0x78, 0x48, 0x6a, - 0x7a, 0x63, 0xd4, 0xae, 0x7d, 0x58, 0x49, 0x16, 0x42, 0x65, - 0x2a, 0x1, 0xf9, 0x51, 0x36, 0x52, 0x0, 0x2d}; - lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + lwmqtt_sub_options_t sub_opts[2]; sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - uint8_t bytesprops0[] = {0x1f, 0x76, 0x7e, 0xf3, 0x63, 0x2c, 0xd7, 0xb, 0x11, 0xc, 0x36, 0x90, - 0x46, 0x71, 0x14, 0x8b, 0x9b, 0xdd, 0xb0, 0x73, 0x2, 0x29, 0x76, 0xf0}; - uint8_t bytesprops1[] = {0x3f, 0x7d, 0xf2, 0x10, 0xa7, 0x63, 0x90, 0x7f, 0x4, 0x9c, 0x6a, 0x99, 0x93, 0x88, - 0xe1, 0x20, 0x6c, 0x1, 0xd9, 0xc1, 0xac, 0x17, 0x48, 0xb, 0x10, 0xc0, 0x6, 0xf6}; - uint8_t bytesprops2[] = {0xba, 0xa2, 0x6e, 0x82, 0x96, 0x93, 0x92, 0x44, 0xd3, 0x45, 0xb5, 0xe6, 0x43, 0x80, 0x80, - 0x3f, 0xf8, 0xd1, 0x47, 0x99, 0xf6, 0xd0, 0xc5, 0xa, 0xd5, 0x50, 0x4a, 0x1a, 0x9c, 0xc9}; - uint8_t bytesprops4[] = {0xbc, 0x56, 0xca, 0xb0, 0x68, 0x18, 0xa5, 0xc8, 0x1d, 0x24, 0x54, 0x50, 0x7c, 0xab, 0x6b, - 0x63, 0xc7, 0xbf, 0x2d, 0x6, 0xe9, 0xe7, 0x2e, 0x35, 0xeb, 0x5b, 0xc5, 0x69, 0x9e, 0x8a}; - uint8_t bytesprops3[] = {0x0, 0xf6, 0x10, 0x5a, 0x57, 0x4c, 0x2d, 0x15, 0x2c, - 0x34, 0xa9, 0x5b, 0x43, 0x80, 0x5b, 0xa3, 0x6b, 0xc8}; + sub_opts[1].no_local = true; + uint8_t bytesprops0[] = {0xd4, 0x39, 0xf1, 0xdb, 0xe2, 0x9b, 0x86, 0x24, 0x82, 0x94, 0x17}; + uint8_t bytesprops1[] = {0x85, 0xba, 0x1e, 0x86, 0xe8, 0xcb, 0x37, 0xa0, 0x8f, 0x9c, 0x42, 0x49, 0xdd}; + uint8_t bytesprops3[] = {0x9b, 0x38, 0x33, 0xc5, 0xb2, 0x96, 0x90, 0x7c, 0x97, 0x44, 0x4f}; + uint8_t bytesprops2[] = {0xf2, 0xbc, 0x75, 0xff, 0xf7, 0xd2, 0x45, 0xbf, 0x79, 0x4c, 0xe0, + 0x25, 0x7, 0xbd, 0xd1, 0x9f, 0xcf, 0x26, 0xf6, 0xd1, 0x7f}; + uint8_t bytesprops4[] = {0x4e, 0xe1, 0x4f, 0xc, 0xfe, 0xb1, 0xe8, 0xa2, 0xab, 0x4f, 0x5a, 0x9, 0xc9, 0xa3, 0x78}; + uint8_t bytesprops5[] = {0x69, 0x80, 0xce, 0xfb, 0xd7, 0x2c, 0xff, 0x7e, 0x6, 0x1e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3641}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops3}, .v = {30, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21739}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16767}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17366}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15132}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24957}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29341}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 73}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 731}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14347}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3280, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18338, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 4639 [("\165\EM\DC2g\NUL",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\ESCH\249\163F",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\203\206z\136",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\156`s_",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropUserProperty -// "+G\189" "\DC1\FS\216\210;\145\164)\NUL\226^\147\141\DC3\254f",PropRequestResponseInformation -// 121,PropWildcardSubscriptionAvailable 148,PropRetainAvailable 5,PropRequestProblemInformation -// 249,PropAuthenticationMethod "\213q@H\255\190o}\213K\132\141",PropTopicAlias 2644,PropUserProperty " " -// "\r\157]J\153\172\135",PropAuthenticationMethod "\148\199\SOH|\192G\223U\251\232",PropMessageExpiryInterval 24483] +// SubscribeRequest 4108 [("\199\233\131\SYNf\210",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = True, _noLocal = False, _subQoS = +// QoS0}),("j\199\156\237c\EMH\246\212\232\&7\217aJ\193/\r\253\246>\215\t\221",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("c\FSd\247?\136\249Y\DELc\167\ETX\185",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = False, _noLocal = True, _subQoS = +// QoS1}),("\165\213\140\159\225\192\145\NAK$mr\141CDwEw\US\152\180\NAK\GSO\142\188r",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\162\247i\170\139\236sr-\177\215M3e\144\ETX3#\STX`s&\254i\233\179\128\142\SI",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("[k\181}\136\187j<\FS\142\DC4\186\157\214\162",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\202\191;\254\&7%\136\210:\NAKeE\203\&0\DC1\nlG*@\183",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("X\134i\144\&7x\198",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\SO9;\183,",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\SOJ\248\&8\219-jq\145\166\228\144\139\DC4M\SYN\245\220\150.\193K\178\&3\149\132D",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] +// [PropSubscriptionIdentifierAvailable 201,PropResponseTopic +// "i\161o\252W\176m\244u<\139\191mc\222\238K\177\243\166",PropTopicAliasMaximum 30251,PropReceiveMaximum +// 3997,PropCorrelationData "\208r\ETX\173C",PropRequestProblemInformation 50,PropTopicAlias +// 222,PropMessageExpiryInterval 2395] TEST(Subscribe5QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0x72, 0x12, 0x1f, 0x51, 0x26, 0x0, 0x3, 0x2b, 0x47, 0xbd, 0x0, 0x10, 0x11, 0x1c, 0xd8, 0xd2, - 0x3b, 0x91, 0xa4, 0x29, 0x0, 0xe2, 0x5e, 0x93, 0x8d, 0x13, 0xfe, 0x66, 0x19, 0x79, 0x28, 0x94, 0x25, - 0x5, 0x17, 0xf9, 0x15, 0x0, 0xc, 0xd5, 0x71, 0x40, 0x48, 0xff, 0xbe, 0x6f, 0x7d, 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0x6d, 0x72, 0x8d, 0x43, 0x44, 0x77, 0x45, 0x77, 0x1f, 0x98, 0xb4, 0x15, 0x1d, 0x4f, 0x8e, 0xbc, + 0x72, 0x2, 0x0, 0x1d, 0xa2, 0xf7, 0x69, 0xaa, 0x8b, 0xec, 0x73, 0x72, 0x2d, 0xb1, 0xd7, 0x4d, 0x33, 0x65, 0x90, + 0x3, 0x33, 0x23, 0x2, 0x60, 0x73, 0x26, 0xfe, 0x69, 0xe9, 0xb3, 0x80, 0x8e, 0xf, 0xd, 0x0, 0xf, 0x5b, 0x6b, + 0xb5, 0x7d, 0x88, 0xbb, 0x6a, 0x3c, 0x1c, 0x8e, 0x14, 0xba, 0x9d, 0xd6, 0xa2, 0x26, 0x0, 0x15, 0xca, 0xbf, 0x3b, + 0xfe, 0x37, 0x25, 0x88, 0xd2, 0x3a, 0x15, 0x65, 0x45, 0xcb, 0x30, 0x11, 0xa, 0x6c, 0x47, 0x2a, 0x40, 0xb7, 0x19, + 0x0, 0x7, 0x58, 0x86, 0x69, 0x90, 0x37, 0x78, 0xc6, 0x1e, 0x0, 0x5, 0xe, 0x39, 0x3b, 0xb7, 0x2c, 0x6, 0x0, + 0x1b, 0xe, 0x4a, 0xf8, 0x38, 0xdb, 0x2d, 0x6a, 0x71, 0x91, 0xa6, 0xe4, 0x90, 0x8b, 0x14, 0x4d, 0x16, 0xf5, 0xdc, + 0x96, 0x2e, 0xc1, 0x4b, 0xb2, 0x33, 0x95, 0x84, 0x44, 0x24, 0x0, 0x0, 0x5}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xa5, 0x19, 0x12, 0x67, 0x0}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xc7, 0xe9, 0x83, 0x16, 0x66, 0xd2}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1b, 0x48, 0xf9, 0xa3, 0x46}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6a, 0xc7, 0x9c, 0xed, 0x63, 0x19, 0x48, 0xf6, 0xd4, 0xe8, 0x37, 0xd9, + 0x61, 0x4a, 0xc1, 0x2f, 0xd, 0xfd, 0xf6, 0x3e, 0xd7, 0x9, 0xdd}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xcb, 0xce, 0x7a, 0x88}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x63, 0x1c, 0x64, 0xf7, 0x3f, 0x88, 0xf9, 0x59, 0x7f, 0x63, 0xa7, 0x3, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9c, 0x60, 0x73, 0x5f}; - lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa5, 0xd5, 0x8c, 0x9f, 0xe1, 0xc0, 0x91, 0x15, 0x24, 0x6d, 0x72, 0x8d, 0x43, + 0x44, 0x77, 0x45, 0x77, 0x1f, 0x98, 0xb4, 0x15, 0x1d, 0x4f, 0x8e, 0xbc, 0x72}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + uint8_t topic_filter_s4_bytes[] = {0xa2, 0xf7, 0x69, 0xaa, 0x8b, 0xec, 0x73, 0x72, 0x2d, 0xb1, + 0xd7, 0x4d, 0x33, 0x65, 0x90, 0x3, 0x33, 0x23, 0x2, 0x60, + 0x73, 0x26, 0xfe, 0x69, 0xe9, 0xb3, 0x80, 0x8e, 0xf}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x5b, 0x6b, 0xb5, 0x7d, 0x88, 0xbb, 0x6a, 0x3c, + 0x1c, 0x8e, 0x14, 0xba, 0x9d, 0xd6, 0xa2}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xca, 0xbf, 0x3b, 0xfe, 0x37, 0x25, 0x88, 0xd2, 0x3a, 0x15, 0x65, + 0x45, 0xcb, 0x30, 0x11, 0xa, 0x6c, 0x47, 0x2a, 0x40, 0xb7}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x58, 0x86, 0x69, 0x90, 0x37, 0x78, 0xc6}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe, 0x39, 0x3b, 0xb7, 0x2c}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe, 0x4a, 0xf8, 0x38, 0xdb, 0x2d, 0x6a, 0x71, 0x91, 0xa6, 0xe4, 0x90, 0x8b, 0x14, + 0x4d, 0x16, 0xf5, 0xdc, 0x96, 0x2e, 0xc1, 0x4b, 0xb2, 0x33, 0x95, 0x84, 0x44}; + lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; + sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - uint8_t bytesprops1[] = {0x11, 0x1c, 0xd8, 0xd2, 0x3b, 0x91, 0xa4, 0x29, - 0x0, 0xe2, 0x5e, 0x93, 0x8d, 0x13, 0xfe, 0x66}; - uint8_t bytesprops0[] = {0x2b, 0x47, 0xbd}; - uint8_t bytesprops2[] = {0xd5, 0x71, 0x40, 0x48, 0xff, 0xbe, 0x6f, 0x7d, 0xd5, 0x4b, 0x84, 0x8d}; - uint8_t bytesprops4[] = {0xd, 0x9d, 0x5d, 0x4a, 0x99, 0xac, 0x87}; - uint8_t bytesprops3[] = {0x20}; - uint8_t bytesprops5[] = {0x94, 0xc7, 0x1, 0x7c, 0xc0, 0x47, 0xdf, 0x55, 0xfb, 0xe8}; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = true; + sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = true; + uint8_t bytesprops0[] = {0x69, 0xa1, 0x6f, 0xfc, 0x57, 0xb0, 0x6d, 0xf4, 0x75, 0x3c, + 0x8b, 0xbf, 0x6d, 0x63, 0xde, 0xee, 0x4b, 0xb1, 0xf3, 0xa6}; + uint8_t bytesprops1[] = {0xd0, 0x72, 0x3, 0xad, 0x43}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2644}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops3}, .v = {7, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24483}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30251}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3997}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 222}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2395}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4639, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4108, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23421 [("\251(\b\221xT^\230i\US\136\EOT",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\239\134\214\190s\242G\b\155\159\231F\196",SubOptions +// SubscribeRequest 28646 [("\224\NAK[\140\150Pw\230\154\136,A\236+U\195sv\137 \161\251K",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\177\&6\255\208\&6s5\196\213\&7\242\172\v?\226_} r2\ENQB\225\136",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(",\181T\ETX\169&\SOH",SubOptions // {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("R\224\a\fdO\239\252\137\148rl,\DELe\145\206_\153\201\&4\149\173\208\\\n[\213\227",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\221A\172\SYN\229\189\v\177\194\tM6\158\244\184\129\CANc;T\142\&1@",SubOptions {_retainHandling = +// QoS0}),("\231\185\DC3\162h\140[&\152A\151\t\128\157\a\143S",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("f\169\228\149VWZ\202B'\230\219\143j\160GJ\187+\175\248;K\185",SubOptions {_retainHandling = // SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\159\222\ESC0\198\131\133\220\213\242\238\229\202\SUB\151\&4R\223cL\171r:\136\128\t\nV1@\206",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\152\178\CAN\175Q\229h\DC19I\201\190>\230\164\181\242q51",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\176O\235\183\144\ETX\224\ACK\173\237*\DLE\129\NUL\CAN\151",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\210\189\SI\243c",SubOptions +// SubscribeRequest 31174 [(":\243\230#\164\248!\232\150\150+\138m\198\212\"\193f\129\SOH}K\195\171\150",SubOptions // {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\164\176\159\168\229\233v\159\v\223\227\158\207\190\216\187\203Z",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropTopicAlias -// 27259,PropServerKeepAlive 14117,PropContentType -// "\DLEh\182\216\DC2\t]\138Of\192M\ENQ\166\149)\188\139\US\213",PropRetainAvailable 33,PropResponseTopic -// "\243\v\247\US.+\207\227\161\209\150/D\237\225t",PropMaximumPacketSize 8492,PropPayloadFormatIndicator -// 3,PropResponseTopic -// "\STX\186\165\221l\193\221\SO2\159_\208\n\174\&1Q\240\229\243\201/\226X\162i\244\198",PropSharedSubscriptionAvailable -// 50,PropTopicAlias 22557,PropSubscriptionIdentifier 13,PropTopicAliasMaximum 8009,PropResponseTopic -// "\139\ACK|f\ACK\217\213u+\f\239\201\225K\199\213\ESC\189\EMv\214",PropSubscriptionIdentifierAvailable -// 104,PropResponseInformation "i\224\tR|\183\"\v\218\218x\245\199\SOH\203\234\231",PropRequestProblemInformation -// 71,PropRetainAvailable 129,PropSubscriptionIdentifierAvailable 84,PropAssignedClientIdentifier -// "!*\175\DC47\209",PropMessageExpiryInterval 466,PropMaximumPacketSize 2156,PropMaximumQoS -// 167,PropMessageExpiryInterval 23974,PropUserProperty "\168P\f\234\167SFw\231\245 \SYNPSo\NUL2j|" -// "~I",PropServerReference "\139\170w2P\143\241\193\DC3",PropReasonString -// "F\239j\220\140\132\DEL\191'\164\SYN\170[X\218\218\210\208ux\197?\186",PropWillDelayInterval 19569] +// QoS2}),("4`MS\232\255\169oP\EOT\RS\198P\250r2\135\v\183FW\STX)\173",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("K\167{\179J\RS\NAK3=*T4\208*\145\228\198h\252\246\248\a",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\ETB\245\174A\225F\225\216j\197\147B\t\254\132\216\164\205\150K$\164lT\ETX\212mRv",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\180Sg\a&R\165\162\174g\178\253\GS*\197i\USu_&\229\201\131d\169\231@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\184l\ETX\225\&2\130\189\132\DC22N9\214\175@\197M\241/X#\ACKQ0\250q\DC4\r",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\253C7\NAK\203#\170",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\133\213\133\SUB\235\254\194\&5\223\143\241-\SUB\177n\233\211{\FSE",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] +// [PropSubscriptionIdentifierAvailable 205,PropWildcardSubscriptionAvailable 32] TEST(Subscribe5QCTest, Encode16) { - uint8_t pkt[] = { - 0x82, 0xc6, 0x3, 0x72, 0xe5, 0xf4, 0x1, 0x23, 0x6a, 0x7b, 0x13, 0x37, 0x25, 0x3, 0x0, 0x14, 0x10, 0x68, 0xb6, - 0xd8, 0x12, 0x9, 0x5d, 0x8a, 0x4f, 0x66, 0xc0, 0x4d, 0x5, 0xa6, 0x95, 0x29, 0xbc, 0x8b, 0x1f, 0xd5, 0x25, 0x21, - 0x8, 0x0, 0x10, 0xf3, 0xb, 0xf7, 0x1f, 0x2e, 0x2b, 0xcf, 0xe3, 0xa1, 0xd1, 0x96, 0x2f, 0x44, 0xed, 0xe1, 0x74, - 0x27, 0x0, 0x0, 0x21, 0x2c, 0x1, 0x3, 0x8, 0x0, 0x1b, 0x2, 0xba, 0xa5, 0xdd, 0x6c, 0xc1, 0xdd, 0xe, 0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0x2f, 0x58, 0x23, 0x6, 0x51, 0x30, 0xfa, 0x71, 0x14, 0xd, 0x2c, 0x0, + 0x7, 0xfd, 0x43, 0x37, 0x15, 0xcb, 0x23, 0xaa, 0xc, 0x0, 0x14, 0x85, 0xd5, 0x85, 0x1a, 0xeb, 0xfe, + 0xc2, 0x35, 0xdf, 0x8f, 0xf1, 0x2d, 0x1a, 0xb1, 0x6e, 0xe9, 0xd3, 0x7b, 0x1c, 0x45, 0x2e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd, 0xb1, 0xff, 0x38, 0xcd, 0x54, 0xdc, 0xdd, 0xc8, 0x49, - 0x87, 0xb3, 0x0, 0x8, 0x26, 0xd2, 0x3c, 0xa0, 0x76, 0x8b, - 0xae, 0x95, 0x70, 0xe2, 0x31, 0x2, 0xe3, 0xaa}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x3a, 0xf3, 0xe6, 0x23, 0xa4, 0xf8, 0x21, 0xe8, 0x96, 0x96, 0x2b, 0x8a, 0x6d, + 0xc6, 0xd4, 0x22, 0xc1, 0x66, 0x81, 0x1, 0x7d, 0x4b, 0xc3, 0xab, 0x96}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x15, 0x52, 0x4c, 0x69, 0xe, 0x21}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x34, 0x60, 0x4d, 0x53, 0xe8, 0xff, 0xa9, 0x6f, 0x50, 0x4, 0x1e, 0xc6, + 0x50, 0xfa, 0x72, 0x32, 0x87, 0xb, 0xb7, 0x46, 0x57, 0x2, 0x29, 0xad}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5e, 0x24, 0xc3, 0xdd, 0x71, 0x59, 0x74, - 0x4b, 0x31, 0xa5, 0x6c, 0x59, 0xe6, 0xff}; - lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4b, 0xa7, 0x7b, 0xb3, 0x4a, 0x1e, 0x15, 0x33, 0x3d, 0x2a, 0x54, + 0x34, 0xd0, 0x2a, 0x91, 0xe4, 0xc6, 0x68, 0xfc, 0xf6, 0xf8, 0x7}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1d, 0xa4, 0xba, 0x96, 0xbf, 0xd, 0x9, 0x6f, 0xbd, 0xbe, 0x96, 0xb7, 0x29, - 0x29, 0x61, 0x19, 0xeb, 0x12, 0x42, 0x5c, 0xd7, 0x47, 0xed, 0x3a, 0xa1}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x17, 0xf5, 0xae, 0x41, 0xe1, 0x46, 0xe1, 0xd8, 0x6a, 0xc5, + 0x93, 0x42, 0x9, 0xfe, 0x84, 0xd8, 0xa4, 0xcd, 0x96, 0x4b, + 0x24, 0xa4, 0x6c, 0x54, 0x3, 0xd4, 0x6d, 0x52, 0x76}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x67, 0xb9, 0xe4, 0x5b, 0x11, 0x25, 0x36, 0x1c, 0x24, 0xfb, 0xef, - 0xd2, 0x85, 0x95, 0xb8, 0x36, 0x31, 0x4, 0x53, 0x83, 0xbe, 0x93}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xb4, 0x53, 0x67, 0x7, 0x26, 0x52, 0xa5, 0xa2, 0xae, 0x67, 0xb2, 0xfd, 0x1d, 0x2a, + 0xc5, 0x69, 0x1f, 0x75, 0x5f, 0x26, 0xe5, 0xc9, 0x83, 0x64, 0xa9, 0xe7, 0x40}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x34, 0x54, 0x42, 0xeb, 0x4b, 0xd7, 0x4e, 0x22, 0xc6, 0x3e, 0x4c, - 0xab, 0x72, 0x3a, 0x88, 0x80, 0x9, 0xa, 0x56, 0x31, 0x40, 0xce}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x98, 0xb2, 0x18, 0xaf, 0x51, 0xe5, 0x68, 0x11, 0x39, 0x49, - 0xc9, 0xbe, 0x3e, 0xe6, 0xa4, 0xb5, 0xf2, 0x71, 0x35, 0x31}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb8, 0x6c, 0x3, 0xe1, 0x32, 0x82, 0xbd, 0x84, 0x12, 0x32, 0x4e, 0x39, 0xd6, 0xaf, + 0x40, 0xc5, 0x4d, 0xf1, 0x2f, 0x58, 0x23, 0x6, 0x51, 0x30, 0xfa, 0x71, 0x14, 0xd}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb0, 0x4f, 0xeb, 0xb7, 0x90, 0x3, 0xe0, 0x6, - 0xad, 0xed, 0x2a, 0x10, 0x81, 0x0, 0x18, 0x97}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xfd, 0x43, 0x37, 0x15, 0xcb, 0x23, 0xaa}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd2, 0xbd, 0xf, 0xf3, 0x63}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x85, 0xd5, 0x85, 0x1a, 0xeb, 0xfe, 0xc2, 0x35, 0xdf, 0x8f, + 0xf1, 0x2d, 0x1a, 0xb1, 0x6e, 0xe9, 0xd3, 0x7b, 0x1c, 0x45}; + lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa4, 0xb0, 0x9f, 0xa8, 0xe5, 0xe9, 0x76, 0x9f, 0xb, - 0xdf, 0xe3, 0x9e, 0xcf, 0xbe, 0xd8, 0xbb, 0xcb, 0x5a}; - lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[8].retain_as_published = true; sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = false; - uint8_t bytesprops0[] = {0x10, 0x68, 0xb6, 0xd8, 0x12, 0x9, 0x5d, 0x8a, 0x4f, 0x66, - 0xc0, 0x4d, 0x5, 0xa6, 0x95, 0x29, 0xbc, 0x8b, 0x1f, 0xd5}; - uint8_t bytesprops1[] = {0xf3, 0xb, 0xf7, 0x1f, 0x2e, 0x2b, 0xcf, 0xe3, - 0xa1, 0xd1, 0x96, 0x2f, 0x44, 0xed, 0xe1, 0x74}; - uint8_t bytesprops2[] = {0x2, 0xba, 0xa5, 0xdd, 0x6c, 0xc1, 0xdd, 0xe, 0x32, 0x9f, 0x5f, 0xd0, 0xa, 0xae, - 0x31, 0x51, 0xf0, 0xe5, 0xf3, 0xc9, 0x2f, 0xe2, 0x58, 0xa2, 0x69, 0xf4, 0xc6}; - uint8_t bytesprops3[] = {0x8b, 0x6, 0x7c, 0x66, 0x6, 0xd9, 0xd5, 0x75, 0x2b, 0xc, 0xef, - 0xc9, 0xe1, 0x4b, 0xc7, 0xd5, 0x1b, 0xbd, 0x19, 0x76, 0xd6}; - uint8_t bytesprops4[] = {0x69, 0xe0, 0x9, 0x52, 0x7c, 0xb7, 0x22, 0xb, 0xda, - 0xda, 0x78, 0xf5, 0xc7, 0x1, 0xcb, 0xea, 0xe7}; - uint8_t bytesprops5[] = {0x21, 0x2a, 0xaf, 0x14, 0x37, 0xd1}; - uint8_t bytesprops7[] = {0x7e, 0x49}; - uint8_t bytesprops6[] = {0xa8, 0x50, 0xc, 0xea, 0xa7, 0x53, 0x46, 0x77, 0xe7, 0xf5, - 0x20, 0x16, 0x50, 0x53, 0x6f, 0x0, 0x32, 0x6a, 0x7c}; - uint8_t bytesprops8[] = {0x8b, 0xaa, 0x77, 0x32, 0x50, 0x8f, 0xf1, 0xc1, 0x13}; - uint8_t bytesprops9[] = {0x46, 0xef, 0x6a, 0xdc, 0x8c, 0x84, 0x7f, 0xbf, 0x27, 0xa4, 0x16, 0xaa, - 0x5b, 0x58, 0xda, 0xda, 0xd2, 0xd0, 0x75, 0x78, 0xc5, 0x3f, 0xba}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27259}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14117}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8492}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22557}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8009}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 466}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2156}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23974}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops6}, .v = {2, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19569}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 32}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29413, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31174, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 6204 [("O\CAN\197/\176M5\196\CAN\225\129Lt\140(",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\182\157\155]\RS\202Z\206F\192\t\240bW\211\158\163b\219\147F3>",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\173U\245\ACK\156A\ENQ\208\187\208\DELX",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\188\246\170$\240\EM",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\"~R\129\189*P\134\186\ETB\222\230\&4\168^\237\146\ACK\240\190q\205\153U\SOH^|H",SubOptions {_retainHandling -// = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropReceiveMaximum -// 9386,PropPayloadFormatIndicator 171,PropRequestResponseInformation 192,PropReceiveMaximum -// 26762,PropSharedSubscriptionAvailable 198,PropAuthenticationData -// "\149\153e\137\n\EM\204\228Ns\205\DC3\NUL\162\155\NAK:\223\&5\CAN\248C\201\206\194n",PropMaximumPacketSize -// 8554,PropAssignedClientIdentifier "\160\138K\208\201\152\209\224\173T\217!\172",PropMessageExpiryInterval -// 19029,PropCorrelationData "y\195\175\ETX",PropServerReference -// "\138cfZ.\147a#\SYN.K%\163\186S\132YK\EM&\131\ETBd\245",PropMaximumPacketSize 20156,PropReasonString -// "\252\147",PropRetainAvailable 63,PropRequestResponseInformation 77,PropWildcardSubscriptionAvailable -// 242,PropSharedSubscriptionAvailable 230,PropMaximumQoS 54,PropResponseTopic "\225\ETBX\215\DC1\NUL\a"] +// SubscribeRequest 2900 [("\249J\154\194\178Mb\255\165\234\213K\141%\167\ESC\151\152\176\236\214",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("7\144\f>\ACKS$|\SI",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal +// = True, _subQoS = QoS1}),("!",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal +// = True, _subQoS = +// QoS2}),("v\150\SO\163x\160B\220\209E\162\156\a!Z\251",PropSharedSubscriptionAvailable +// 77,PropSubscriptionIdentifier 24,PropResponseTopic +// "F\165\209\189x\225\202\STX\135\144\221F\251\219\168\212\235{",PropReasonString +// "\202y\176\144\&5\195\SOH\215\184\237S\SYN\190",PropReceiveMaximum 29384,PropResponseInformation +// "M\218\SO\164\227\GSw\192\188\SO\154W\204K=\247\144\&1\SYN\254V\238\155u\173f",PropWillDelayInterval +// 29671,PropServerReference "\aI\167\&9b\140\200V:F\165\248\234\232",PropAssignedClientIdentifier +// "q]\176\136i\167\"\228\184K\142\223Z\254\152M \DC4j`\EM\SI?E",PropWillDelayInterval +// 668,PropSharedSubscriptionAvailable 250,PropCorrelationData "\DC4$R\"\255",PropAuthenticationData +// "I-\189\176\141\242\a\135\251\210\184!\228;E>^\206g\147\147\DLE\NAK\FS\173k",PropMaximumQoS 10,PropRetainAvailable +// 36,PropAuthenticationData "\146\240E*+\204\247"] TEST(Subscribe5QCTest, Encode19) { uint8_t pkt[] = { - 0x82, 0xb5, 0x2, 0x64, 0xb, 0xfd, 0x1, 0x8, 0x0, 0x1d, 0x41, 0x56, 0x2f, 0xf9, 0x18, 0xbf, 0xd, 0xc9, 0x2d, - 0x9f, 0xaf, 0xe5, 0xa4, 0xa3, 0x7, 0x86, 0x75, 0x94, 0x0, 0x59, 0xe5, 0xb9, 0xb8, 0xbf, 0x5, 0x91, 0xe2, 0x7d, - 0x87, 0x8, 0x0, 0x13, 0xa7, 0xbc, 0x48, 0xda, 0xb9, 0xbb, 0x3d, 0x1e, 0xea, 0xbc, 0xd6, 0xce, 0xd6, 0x1e, 0xb4, - 0xf2, 0xc2, 0xb3, 0x47, 0xb, 0xd, 0x16, 0x0, 0xe, 0xa2, 0xff, 0xcd, 0xe1, 0xaf, 0x7c, 0x5d, 0xeb, 0x89, 0x34, - 0x9a, 0xd, 0xd5, 0xbf, 0x11, 0x0, 0x0, 0x38, 0x18, 0x1, 0x17, 0x26, 0x0, 0x9, 0x11, 0xa7, 0x67, 0xd7, 0xa6, - 0xb5, 0xe7, 0x4d, 0xd5, 0x0, 0x1c, 0x99, 0x8e, 0x1a, 0xfe, 0x15, 0x80, 0x59, 0x21, 0xc, 0x30, 0xb7, 0x89, 0x7d, - 0xb0, 0x16, 0x7f, 0x16, 0x29, 0x66, 0x51, 0x3b, 0xca, 0x7c, 0xaa, 0xa5, 0x89, 0x3d, 0xee, 0x1c, 0x0, 0x4, 0xe, - 0x82, 0xb8, 0xd5, 0x13, 0x69, 0xfb, 0x29, 0x6b, 0x2, 0x0, 0x0, 0x2e, 0xd0, 0x25, 0x39, 0x13, 0x51, 0xe7, 0xb, - 0x13, 0x3, 0x0, 0x2, 0x66, 0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 0x93, 0x10, 0x15, 0x1c, 0xad, 0x6b, 0x24, 0xa, 0x25, 0x24, + 0x16, 0x0, 0x7, 0x92, 0xf0, 0x45, 0x2a, 0x2b, 0xcc, 0xf7, 0x0, 0x10, 0xb3, 0xf3, 0xcc, 0xef, 0xbb, 0x4d, 0x24, + 0xc6, 0xf1, 0x2a, 0xe7, 0x7a, 0x5, 0x60, 0x58, 0x75, 0xa, 0x0, 0x15, 0x6b, 0x77, 0xb0, 0x7d, 0xee, 0xd, 0xc7, + 0x42, 0xbd, 0xb2, 0x44, 0xb3, 0x29, 0xb, 0x64, 0x22, 0xa, 0xe, 0x48, 0x55, 0x6c, 0x1c}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xc1, 0x26, 0xf5, 0xfd, 0xc0, 0x9e, 0x22, 0xc8, 0xb2, 0xdb, - 0xbb, 0xa0, 0xad, 0x76, 0x54, 0xcf, 0x14, 0xfd, 0xc8, 0x15, - 0x64, 0x5f, 0x38, 0xe4, 0x3a, 0xda, 0xee, 0x81}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xb3, 0xf3, 0xcc, 0xef, 0xbb, 0x4d, 0x24, 0xc6, + 0xf1, 0x2a, 0xe7, 0x7a, 0x5, 0x60, 0x58, 0x75}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xdb, 0xbd, 0xa6, 0xff, 0xc6, 0x30, 0xa4, 0x30, 0x1b, - 0x67, 0x1, 0x72, 0x3c, 0xfd, 0x4d, 0x73, 0x18, 0x3}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6b, 0x77, 0xb0, 0x7d, 0xee, 0xd, 0xc7, 0x42, 0xbd, 0xb2, 0x44, + 0xb3, 0x29, 0xb, 0x64, 0x22, 0xa, 0xe, 0x48, 0x55, 0x6c}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; + sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - uint8_t bytesprops0[] = {0x41, 0x56, 0x2f, 0xf9, 0x18, 0xbf, 0xd, 0xc9, 0x2d, 0x9f, 0xaf, 0xe5, 0xa4, 0xa3, 0x7, - 0x86, 0x75, 0x94, 0x0, 0x59, 0xe5, 0xb9, 0xb8, 0xbf, 0x5, 0x91, 0xe2, 0x7d, 0x87}; - uint8_t bytesprops1[] = {0xa7, 0xbc, 0x48, 0xda, 0xb9, 0xbb, 0x3d, 0x1e, 0xea, 0xbc, - 0xd6, 0xce, 0xd6, 0x1e, 0xb4, 0xf2, 0xc2, 0xb3, 0x47}; - uint8_t bytesprops2[] = {0xa2, 0xff, 0xcd, 0xe1, 0xaf, 0x7c, 0x5d, 0xeb, 0x89, 0x34, 0x9a, 0xd, 0xd5, 0xbf}; - uint8_t bytesprops4[] = {0x99, 0x8e, 0x1a, 0xfe, 0x15, 0x80, 0x59, 0x21, 0xc, 0x30, 0xb7, 0x89, 0x7d, 0xb0, - 0x16, 0x7f, 0x16, 0x29, 0x66, 0x51, 0x3b, 0xca, 0x7c, 0xaa, 0xa5, 0x89, 0x3d, 0xee}; - uint8_t bytesprops3[] = {0x11, 0xa7, 0x67, 0xd7, 0xa6, 0xb5, 0xe7, 0x4d, 0xd5}; - uint8_t bytesprops5[] = {0xe, 0x82, 0xb8, 0xd5}; - uint8_t bytesprops6[] = {0x66, 0x33}; - uint8_t bytesprops7[] = {0xb6, 0x6b, 0x9d, 0x5, 0x85, 0x53, 0xc9, 0x9f, 0x93, 0xb1, 0x3c, 0x30, 0x43, - 0xa2, 0x19, 0x20, 0x14, 0xb4, 0xa0, 0x77, 0x2, 0x8b, 0x72, 0xa2, 0xcc}; - uint8_t bytesprops8[] = {0xf7, 0x8e, 0xdd, 0x5a, 0xdc, 0x2f, 0xfb}; - uint8_t bytesprops10[] = {0xbc, 0xa9, 0x22, 0x44, 0x29, 0x8, 0x15, 0x7e, 0xba, 0xb2, 0x7c, 0x84, 0x3f, 0x50, 0xf2}; - uint8_t bytesprops9[] = {0x17, 0x86, 0x50}; - uint8_t bytesprops11[] = {0xb1, 0x8, 0xfb, 0x33, 0x4a, 0xf8, 0x1e, 0x6c, 0xe2, 0xc, 0xe7, 0x7, 0x5f, 0x85}; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + uint8_t bytesprops0[] = {0xc7, 0xfd, 0x7a, 0x19, 0x44, 0xca, 0x62, 0x96, + 0x4, 0x60, 0x52, 0xda, 0x39, 0x17, 0x13, 0x45}; + uint8_t bytesprops1[] = {0x6, 0x5, 0xaf, 0xf, 0x3a, 0x7c, 0xbf, 0x6d, 0xe9, 0x8b, 0x5f, 0x68, 0xef, + 0x5, 0xae, 0xfb, 0x2e, 0xc, 0x91, 0x3e, 0xa2, 0x9c, 0x7, 0x21, 0x5a, 0xfb}; + uint8_t bytesprops2[] = {0x46, 0xa5, 0xd1, 0xbd, 0x78, 0xe1, 0xca, 0x2, 0x87, + 0x90, 0xdd, 0x46, 0xfb, 0xdb, 0xa8, 0xd4, 0xeb, 0x7b}; + uint8_t bytesprops3[] = {0xca, 0x79, 0xb0, 0x90, 0x35, 0xc3, 0x1, 0xd7, 0xb8, 0xed, 0x53, 0x16, 0xbe}; + uint8_t bytesprops4[] = {0x4d, 0xda, 0xe, 0xa4, 0xe3, 0x1d, 0x77, 0xc0, 0xbc, 0xe, 0x9a, 0x57, 0xcc, + 0x4b, 0x3d, 0xf7, 0x90, 0x31, 0x16, 0xfe, 0x56, 0xee, 0x9b, 0x75, 0xad, 0x66}; + uint8_t bytesprops5[] = {0x7, 0x49, 0xa7, 0x39, 0x62, 0x8c, 0xc8, 0x56, 0x3a, 0x46, 0xa5, 0xf8, 0xea, 0xe8}; + uint8_t bytesprops6[] = {0x71, 0x5d, 0xb0, 0x88, 0x69, 0xa7, 0x22, 0xe4, 0xb8, 0x4b, 0x8e, 0xdf, + 0x5a, 0xfe, 0x98, 0x4d, 0x20, 0x14, 0x6a, 0x60, 0x19, 0xf, 0x3f, 0x45}; + uint8_t bytesprops7[] = {0x14, 0x24, 0x52, 0x22, 0xff}; + uint8_t bytesprops8[] = {0x49, 0x2d, 0xbd, 0xb0, 0x8d, 0xf2, 0x7, 0x87, 0xfb, 0xd2, 0xb8, 0x21, 0xe4, + 0x3b, 0x45, 0x3e, 0x5e, 0xce, 0x67, 0x93, 0x93, 0x10, 0x15, 0x1c, 0xad, 0x6b}; + uint8_t bytesprops9[] = {0x92, 0xf0, 0x45, 0x2a, 0x2b, 0xcc, 0xf7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 13}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14360}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27131}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11984}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20967}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 19}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19042}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26201}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10394}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8344}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops9}, .v = {15, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18124}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29384}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29671}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 668}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25611, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24276, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 20073 [("\150\229\151f\221S\227F9\174\140\214\205\194\&6",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("b'\220g\205\179\146\202\229\249\GS\151R#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = True, _subQoS = QoS1}),("\NAK",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\212m\205\&6\249'\241wU\144\246\172\DEL4b!*\199\&4K\220\225",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("h\235\206",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\252\156\160\253\208\193C\SI[\235\239\236\248\207J&b\135\248\157",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\SYN\167%\167C+\SOH\205\197\t3\244\136\RS\ETB\237:\n\EOTco\DC3~\160\135",SubOptions {_retainHandling = +} + +// SubscribeRequest 17953 [("\230\CAN\157,Q",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS2}),("W",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// True, _noLocal = True, _subQoS = QoS1}),("1/\218k\SOH\193\234\176zfB\215\166+\DC1Rzc",SubOptions {_retainHandling = // SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\131\204\157\FS\182\179\254}\198^zy\160P\255\NAK\192]\172\DLE(\173\129oIr\144u\212",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\230\212\130m\136\168\227\&6\206;\ACK\STX\242",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\249\t3\197x@\253D\DC4\"\229\193\219\163\145}\167\&9\182\145I",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("yW<\191",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] -// [PropAuthenticationData "\146\US\n\162'\207\224\248\&6j\183.(t\241J\DC1\t",PropMaximumPacketSize -// 10820,PropRequestResponseInformation 112,PropReceiveMaximum 16246,PropAssignedClientIdentifier -// "\241\130\203\133\CAN\217n\GS\aM\255\198\STX\b\214\241y\DC2\172\184|\159\202"] +// QoS2}),("?N\223\&4<\167\174\222\&4",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = +// QoS1}),("\237\v\239\243\170\&0\135\144\178*\146\194if\US\203\&9'\172\166|\128\129m\188|l\141i\164",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\238\232\v\ENQ +// \239\SOH\149\159P",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, +// _subQoS = QoS1}),("\191\217\139T!It\188\RS\EM\246\171\172\134u\234\170\168R\185\139\229\ESC",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("{\186\SIi\DLE\171\225\241\&6",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS2}),("\166",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = True, _subQoS = QoS2}),("~J\231\169\143\142y\137\254m\135\249\196X\DC4J",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropMaximumQoS +// 139,PropTopicAlias 22521,PropSubscriptionIdentifierAvailable 34,PropUserProperty "\SI+\143\241\230%<\231\227I\214" +// "\167\201<\233 \STX\165lB\229\219W\205Z\159\n\187\222",PropAuthenticationData +// "\207\143,\240\186\203\168\197\143\159\178\134\155\&6\SI\247\159\196\212\186\183gq\199\252\251",PropServerReference +// "!\208\170L_\177\174%\STX\188\206u\SOH;\255\&2\SO\129;\213\SYN\171",PropRequestProblemInformation +// 36,PropServerReference "\192\220AE\232t?/B\129\164\144\NUL\214\144\203q\US\206\EOT",PropPayloadFormatIndicator +// 172,PropWildcardSubscriptionAvailable 221,PropRequestResponseInformation 175,PropWildcardSubscriptionAvailable +// 251,PropWillDelayInterval 7152,PropSubscriptionIdentifier 31,PropCorrelationData +// "U\FSG\203\243\191\251{\\\r.\186\148\242U\SYN\192p\GS\204V",PropTopicAliasMaximum 21728,PropServerReference +// "\DC2\171}+\153\STX\242m\DC1\ACK\155 \235",PropResponseInformation "e",PropResponseTopic ""] TEST(Subscribe5QCTest, Encode20) { uint8_t pkt[] = { - 0x82, 0x84, 0x2, 0x4e, 0x69, 0x39, 0x16, 0x0, 0x12, 0x92, 0x1f, 0xa, 0xa2, 0x27, 0xcf, 0xe0, 0xf8, 0x36, 0x6a, - 0xb7, 0x2e, 0x28, 0x74, 0xf1, 0x4a, 0x11, 0x9, 0x27, 0x0, 0x0, 0x2a, 0x44, 0x19, 0x70, 0x21, 0x3f, 0x76, 0x12, - 0x0, 0x17, 0xf1, 0x82, 0xcb, 0x85, 0x18, 0xd9, 0x6e, 0x1d, 0x7, 0x4d, 0xff, 0xc6, 0x2, 0x8, 0xd6, 0xf1, 0x79, - 0x12, 0xac, 0xb8, 0x7c, 0x9f, 0xca, 0x0, 0xf, 0x96, 0xe5, 0x97, 0x66, 0xdd, 0x53, 0xe3, 0x46, 0x39, 0xae, 0x8c, - 0xd6, 0xcd, 0xc2, 0x36, 0x19, 0x0, 0xe, 0x62, 0x27, 0xdc, 0x67, 0xcd, 0xb3, 0x92, 0xca, 0xe5, 0xf9, 0x1d, 0x97, - 0x52, 0x23, 0x5, 0x0, 0x1, 0x15, 0x1a, 0x0, 0x16, 0xd4, 0x6d, 0xcd, 0x36, 0xf9, 0x27, 0xf1, 0x77, 0x55, 0x90, - 0xf6, 0xac, 0x7f, 0x34, 0x62, 0x21, 0x2a, 0xc7, 0x34, 0x4b, 0xdc, 0xe1, 0xe, 0x0, 0x3, 0x68, 0xeb, 0xce, 0xc, - 0x0, 0x14, 0xfc, 0x9c, 0xa0, 0xfd, 0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 0x2a, 0x92, 0xc2, 0x69, 0x66, 0x1f, 0xcb, 0x39, 0x27, 0xac, 0xa6, 0x7c, 0x80, 0x81, 0x6d, 0xbc, 0x7c, 0x6c, + 0x8d, 0x69, 0xa4, 0x1c, 0x0, 0xa, 0xee, 0xe8, 0xb, 0x5, 0x20, 0xef, 0x1, 0x95, 0x9f, 0x50, 0x2d, 0x0, 0x17, + 0xbf, 0xd9, 0x8b, 0x54, 0x21, 0x49, 0x74, 0xbc, 0x1e, 0x19, 0xf6, 0xab, 0xac, 0x86, 0x75, 0xea, 0xaa, 0xa8, 0x52, + 0xb9, 0x8b, 0xe5, 0x1b, 0x1, 0x0, 0x9, 0x7b, 0xba, 0xf, 0x69, 0x10, 0xab, 0xe1, 0xf1, 0x36, 0x2a, 0x0, 0x1, + 0xa6, 0x20, 0x0, 0x0, 0x2e, 0x0, 0x10, 0x7e, 0x4a, 0xe7, 0xa9, 0x8f, 0x8e, 0x79, 0x89, 0xfe, 0x6d, 0x87, 0xf9, + 0xc4, 0x58, 0x14, 0x4a, 0x1e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x96, 0xe5, 0x97, 0x66, 0xdd, 0x53, 0xe3, 0x46, - 0x39, 0xae, 0x8c, 0xd6, 0xcd, 0xc2, 0x36}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xe6, 0x18, 0x9d, 0x2c, 0x51}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x62, 0x27, 0xdc, 0x67, 0xcd, 0xb3, 0x92, - 0xca, 0xe5, 0xf9, 0x1d, 0x97, 0x52, 0x23}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x57}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x15}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x31, 0x2f, 0xda, 0x6b, 0x1, 0xc1, 0xea, 0xb0, 0x7a, + 0x66, 0x42, 0xd7, 0xa6, 0x2b, 0x11, 0x52, 0x7a, 0x63}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd4, 0x6d, 0xcd, 0x36, 0xf9, 0x27, 0xf1, 0x77, 0x55, 0x90, 0xf6, - 0xac, 0x7f, 0x34, 0x62, 0x21, 0x2a, 0xc7, 0x34, 0x4b, 0xdc, 0xe1}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3f, 0x4e, 0xdf, 0x34, 0x3c, 0xa7, 0xae, 0xde, 0x34}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x68, 0xeb, 0xce}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xed, 0xb, 0xef, 0xf3, 0xaa, 0x30, 0x87, 0x90, 0xb2, 0x2a, + 0x92, 0xc2, 0x69, 0x66, 0x1f, 0xcb, 0x39, 0x27, 0xac, 0xa6, + 0x7c, 0x80, 0x81, 0x6d, 0xbc, 0x7c, 0x6c, 0x8d, 0x69, 0xa4}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfc, 0x9c, 0xa0, 0xfd, 0xd0, 0xc1, 0x43, 0xf, 0x5b, 0xeb, - 0xef, 0xec, 0xf8, 0xcf, 0x4a, 0x26, 0x62, 0x87, 0xf8, 0x9d}; - lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xee, 0xe8, 0xb, 0x5, 0x20, 0xef, 0x1, 0x95, 0x9f, 0x50}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x16, 0xa7, 0x25, 0xa7, 0x43, 0x2b, 0x1, 0xcd, 0xc5, 0x9, 0x33, 0xf4, 0x88, - 0x1e, 0x17, 0xed, 0x3a, 0xa, 0x4, 0x63, 0x6f, 0x13, 0x7e, 0xa0, 0x87}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xbf, 0xd9, 0x8b, 0x54, 0x21, 0x49, 0x74, 0xbc, 0x1e, 0x19, 0xf6, 0xab, + 0xac, 0x86, 0x75, 0xea, 0xaa, 0xa8, 0x52, 0xb9, 0x8b, 0xe5, 0x1b}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x83, 0xcc, 0x9d, 0x1c, 0xb6, 0xb3, 0xfe, 0x7d, 0xc6, 0x5e, - 0x7a, 0x79, 0xa0, 0x50, 0xff, 0x15, 0xc0, 0x5d, 0xac, 0x10, - 0x28, 0xad, 0x81, 0x6f, 0x49, 0x72, 0x90, 0x75, 0xd4}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x7b, 0xba, 0xf, 0x69, 0x10, 0xab, 0xe1, 0xf1, 0x36}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe6, 0xd4, 0x82, 0x6d, 0x88, 0xa8, 0xe3, 0x36, 0xce, 0x3b, 0x6, 0x2, 0xf2}; - lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xa6}; + lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xf9, 0x9, 0x33, 0xc5, 0x78, 0x40, 0xfd, 0x44, 0x14, 0x22, 0xe5, - 0xc1, 0xdb, 0xa3, 0x91, 0x7d, 0xa7, 0x39, 0xb6, 0x91, 0x49}; - lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0}; + lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x79, 0x57, 0x3c, 0xbf}; - lwmqtt_string_t topic_filter_s10 = {4, (char*)&topic_filter_s10_bytes}; + uint8_t topic_filter_s10_bytes[] = {0x7e, 0x4a, 0xe7, 0xa9, 0x8f, 0x8e, 0x79, 0x89, + 0xfe, 0x6d, 0x87, 0xf9, 0xc4, 0x58, 0x14, 0x4a}; + lwmqtt_string_t topic_filter_s10 = {16, (char*)&topic_filter_s10_bytes}; topic_filters[10] = topic_filter_s10; lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = true; sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[7].retain_as_published = true; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; + sub_opts[8].no_local = false; sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = true; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[10].retain_as_published = true; sub_opts[10].no_local = true; - uint8_t bytesprops0[] = {0x92, 0x1f, 0xa, 0xa2, 0x27, 0xcf, 0xe0, 0xf8, 0x36, - 0x6a, 0xb7, 0x2e, 0x28, 0x74, 0xf1, 0x4a, 0x11, 0x9}; - uint8_t bytesprops1[] = {0xf1, 0x82, 0xcb, 0x85, 0x18, 0xd9, 0x6e, 0x1d, 0x7, 0x4d, 0xff, 0xc6, - 0x2, 0x8, 0xd6, 0xf1, 0x79, 0x12, 0xac, 0xb8, 0x7c, 0x9f, 0xca}; + uint8_t bytesprops1[] = {0xa7, 0xc9, 0x3c, 0xe9, 0x20, 0x2, 0xa5, 0x6c, 0x42, + 0xe5, 0xdb, 0x57, 0xcd, 0x5a, 0x9f, 0xa, 0xbb, 0xde}; + uint8_t bytesprops0[] = {0xf, 0x2b, 0x8f, 0xf1, 0xe6, 0x25, 0x3c, 0xe7, 0xe3, 0x49, 0xd6}; + uint8_t bytesprops2[] = {0xcf, 0x8f, 0x2c, 0xf0, 0xba, 0xcb, 0xa8, 0xc5, 0x8f, 0x9f, 0xb2, 0x86, 0x9b, + 0x36, 0xf, 0xf7, 0x9f, 0xc4, 0xd4, 0xba, 0xb7, 0x67, 0x71, 0xc7, 0xfc, 0xfb}; + uint8_t bytesprops3[] = {0x21, 0xd0, 0xaa, 0x4c, 0x5f, 0xb1, 0xae, 0x25, 0x2, 0xbc, 0xce, + 0x75, 0x1, 0x3b, 0xff, 0x32, 0xe, 0x81, 0x3b, 0xd5, 0x16, 0xab}; + uint8_t bytesprops4[] = {0xc0, 0xdc, 0x41, 0x45, 0xe8, 0x74, 0x3f, 0x2f, 0x42, 0x81, + 0xa4, 0x90, 0x0, 0xd6, 0x90, 0xcb, 0x71, 0x1f, 0xce, 0x4}; + uint8_t bytesprops5[] = {0x55, 0x1c, 0x47, 0xcb, 0xf3, 0xbf, 0xfb, 0x7b, 0x5c, 0xd, 0x2e, + 0xba, 0x94, 0xf2, 0x55, 0x16, 0xc0, 0x70, 0x1d, 0xcc, 0x56}; + uint8_t bytesprops6[] = {0x12, 0xab, 0x7d, 0x2b, 0x99, 0x2, 0xf2, 0x6d, 0x11, 0x6, 0x9b, 0x20, 0xeb}; + uint8_t bytesprops7[] = {0x65}; + uint8_t bytesprops8[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10820}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16246}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22521}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {18, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7152}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 31}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21728}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20073, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17953, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12782 [("\238\199\163\EOT$\228\173\174\EM\128vA\216",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\172,\203\248Z\129\GS\RSj.\208\aqM\178\167n7\235",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 26518 [("\NULJ\205v\253\154",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS2}),("j\182X\235\201r\170\214\STX\134\241\201\150\253\226\SYN",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("ap\232$>@\178\148\vR\208\227\232\190\&0*N>\US\202\188",SubOptions {_retainHandling = DoNotSendOnSubscribe, // _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\229.\210\152\ETB\234\229V\FS\177\214\ETBE\143D\ETB\222\154\157&\204\247\239",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\198\151\141\&8-\DEL\251\FS\a\CANfH\231*i\179\172\r\239_\141S(~Y\236",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("9oU\227^\\\129P74A\252\165^<\US\206\&6\148\182\&1\154\238\235\248\210\164\ENQ\ACK\184",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] -// [PropSharedSubscriptionAvailable 204,PropResponseInformation "E\170)=Q\201\t",PropAuthenticationData -// "\171\225\ETX;\176Zzi\246\195\237f\SI\199\232M\US\DC4\179*\160\177V\183\239n"] +// QoS2}),("+b\142\ETB/\213xA\202y\175i)\183\171\142Yw_\228\&2\170\156 \129",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("A\187\CAN\243\184\211b\170\231tK\171\170R\216Gw\149i\252\163\&4U\209\180\245\226\249-\209\158\&5\245\NUL\234\DC10\214",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\218\246\226&[\153t\186\250\SI\199\252\144\201\139\191U?\SI\207?Q",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\242x\138*\224\132\237\229\218\231\&4\189|",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DLE\EOT\229e\SO\165\202\190",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] +// [PropMessageExpiryInterval 1813,PropContentType "",PropAuthenticationMethod +// "\146*\STX\150>\233\167?\ra\EM\DEL",PropAuthenticationData +// "t[\132\EM\SI\175l[\SYN41\133\151\DC3\236q\195\CAN\131\232\211\213\188K_\229?",PropMessageExpiryInterval +// 22279,PropTopicAliasMaximum 29118,PropSubscriptionIdentifierAvailable 189,PropRequestProblemInformation +// 76,PropReceiveMaximum 22760,PropReasonString "CBVj\185\243 \ESC\176~a\231k",PropUserProperty +// "\242*\188\196\177\&5\DEL\bKv\207\SYN\215" "\250G\"u\198v`\238\198\DC1_\135\212f\201",PropAssignedClientIdentifier +// "\ETB9\171\SI\144\204\163\a)\232\251\242\DC1Q\132\228\&6\208\200\143Uj\EOT\ESC\135\241",PropSessionExpiryInterval +// 25871,PropSessionExpiryInterval 9023,PropAuthenticationData +// "\208\157Z\nlv\220\151\150\150\&5\169\&6J=\178",PropRequestProblemInformation 137,PropUserProperty +// "\157\a\SUB,\239\ENQ\166\254\246R\245\165\nA\146\255\&7\181V\157\193\DC3\188\230\225" +// "\135\163\189\173Ho\231s\182",PropSessionExpiryInterval 6015,PropReceiveMaximum +// 16296,PropRequestProblemInformation 137] +TEST(Subscribe5QCTest, Encode22) { + uint8_t pkt[] = { + 0x82, 0x91, 0x3, 0x5b, 0xe3, 0x90, 0x2, 0x2, 0x0, 0x0, 0x7, 0x15, 0x3, 0x0, 0x0, 0x15, 0x0, 0xc, 0x92, + 0x2a, 0x2, 0x96, 0x3e, 0xe9, 0xa7, 0x3f, 0xd, 0x61, 0x19, 0x7f, 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xbe, 0xa}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x3a, 0x5a, 0xfd, 0xb3, 0xf6, 0x69, 0x9, 0x43, 0x14, 0xe1, 0xf4, 0x6f}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x90, 0xf2, 0xf2, 0x38, 0xdf, 0x89, 0x70, 0x4c, 0x72, + 0x43, 0xa9, 0xe9, 0x8e, 0xcd, 0x3b, 0x50, 0xe3}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5c, 0x9}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x99, 0x24, 0xd1, 0x73, 0xce, 0x76, 0x3e, 0x69, 0xfc, 0xa3, 0x34, 0x55, 0xd1, 0xb4, + 0xf5, 0xe2, 0xf9, 0x2d, 0xd1, 0x9e, 0x35, 0xf5, 0x0, 0xea, 0x11, 0x30, 0xd6}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xda, 0xf6, 0xe2, 0x26, 0x5b, 0x99, 0x74, 0xba, 0xfa, 0xf, 0xc7, + 0xfc, 0x90, 0xc9, 0x8b, 0xbf, 0x55, 0x3f, 0xf, 0xcf, 0x3f, 0x51}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xf2, 0x78, 0x8a, 0x2a, 0xe0, 0x84, 0xed, 0xe5, 0xda, 0xe7, 0x34, 0xbd, 0x7c}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x10, 0x4, 0xe5, 0x65, 0xe, 0xa5, 0xca, 0xbe}; + lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x92, 0x2a, 0x2, 0x96, 0x3e, 0xe9, 0xa7, 0x3f, 0xd, 0x61, 0x19, 0x7f}; + uint8_t bytesprops2[] = {0x74, 0x5b, 0x84, 0x19, 0xf, 0xaf, 0x6c, 0x5b, 0x16, 0x34, 0x31, 0x85, 0x97, 0x13, + 0xec, 0x71, 0xc3, 0x18, 0x83, 0xe8, 0xd3, 0xd5, 0xbc, 0x4b, 0x5f, 0xe5, 0x3f}; + uint8_t bytesprops3[] = {0x43, 0x42, 0x56, 0x6a, 0xb9, 0xf3, 0x20, 0x1b, 0xb0, 0x7e, 0x61, 0xe7, 0x6b}; + uint8_t bytesprops5[] = {0xfa, 0x47, 0x22, 0x75, 0xc6, 0x76, 0x60, 0xee, 0xc6, 0x11, 0x5f, 0x87, 0xd4, 0x66, 0xc9}; + uint8_t bytesprops4[] = {0xf2, 0x2a, 0xbc, 0xc4, 0xb1, 0x35, 0x7f, 0x8, 0x4b, 0x76, 0xcf, 0x16, 0xd7}; + uint8_t bytesprops6[] = {0x17, 0x39, 0xab, 0xf, 0x90, 0xcc, 0xa3, 0x7, 0x29, 0xe8, 0xfb, 0xf2, 0x11, + 0x51, 0x84, 0xe4, 0x36, 0xd0, 0xc8, 0x8f, 0x55, 0x6a, 0x4, 0x1b, 0x87, 0xf1}; + uint8_t bytesprops7[] = {0xd0, 0x9d, 0x5a, 0xa, 0x6c, 0x76, 0xdc, 0x97, + 0x96, 0x96, 0x35, 0xa9, 0x36, 0x4a, 0x3d, 0xb2}; + uint8_t bytesprops9[] = {0x87, 0xa3, 0xbd, 0xad, 0x48, 0x3c, 0x76, 0xb7, 0x4b, 0xd1, 0x6, 0x20, 0x65, 0x2f, + 0x36, 0xe3, 0xdd, 0x69, 0x4, 0xb1, 0xe2, 0x29, 0xa1, 0x12, 0xd7, 0x66, 0xed, 0x5d}; + uint8_t bytesprops8[] = {0x9d, 0x7, 0x1a, 0x2c, 0xef, 0x5, 0xa6, 0xfe, 0xf6, 0x52, 0xf5, 0xa5, 0xa, + 0x41, 0x92, 0xff, 0x37, 0xb5, 0x56, 0x9d, 0xc1, 0x13, 0xbc, 0xe6, 0xe1}; + uint8_t bytesprops10[] = {0x7, 0x47, 0x56, 0x95, 0x64, 0xa8, 0x81, 0x55, 0x8f, 0x22, 0xa7, 0xe6, + 0x66, 0xb4, 0x9d, 0x43, 0xdf, 0x9c, 0xd9, 0x3e, 0x6f, 0xe7, 0x73, 0xb6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1813}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22279}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29118}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22760}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops4}, .v = {15, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25871}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9023}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops8}, .v = {28, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6015}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16296}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 137}}, + }; + + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23523, 8, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 10563 [("\168\239",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS0}),("b\DC2\247\191\181;_\144\ETX9R\f\212\n*;",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\151\237H\215M\151\DC4\144\228\180c\210\v\195\251",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\162\255\252\DC17\138\&3.\159W\239\237{Z/T\SO\132\246\251\170\243\186\162\177\&7",SubOptions +// QoS1}),("M\245\139sC\176\233\&4\SI\136\188%\219\r\ENQ\SOS\142%*R8\171\v\149\180\155",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("F\143\188\229\139~\201\n\GSVs\v",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("M\203\202\148\227\243\227S\239h\b\165\&3\230\DC4B\DEL",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\225)u\SUB\181#\ETB\132 \212\238G9{|-{h:@r0\186r\DC4\214\225\&4",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("l$",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),(">\217\185\166\NAK\216\248(\172\194\189",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS1})] [PropAuthenticationData "\170\159z\238\186^\223\210",PropServerKeepAlive -// 8290,PropTopicAliasMaximum 4943,PropSharedSubscriptionAvailable 22,PropTopicAliasMaximum 9948,PropAuthenticationData -// "\176p\192\156\US\n\217\139Z\202X\234\140y,\195\147",PropReasonString -// "\250\136A\138\143b\181]e/V\134l=\185\248\np\129\172(\RS\186\SI",PropResponseTopic -// "/\184\181>>\231\SO\219'\147\130\177\238r\233 Gx\198Fd\215\209\SYN.\DC2\SO\177\129+",PropReasonString -// "\170",PropContentType -// "\147Mq\ENQB!\247\143\237b\ACK#\163\176\179\ESC`\198\133\205zK\SOH]\204\172Z\203\165",PropMaximumPacketSize -// 31659,PropMaximumPacketSize 4540,PropResponseInformation -// "\233{\135\f\247y&\204\237\254\&7\ACK\CAND\135\r0\183L\DELGc\194YW",PropMessageExpiryInterval -// 24650,PropPayloadFormatIndicator 205,PropContentType -// "F\166\236\159f\US\230t0%\242\231\165\222P\SO\163\&0\fGGw\143_G7\158\187",PropServerReference -// "\199\162\220\164v\209\209\DC3\216\226\&4\215\CAN\GS\215-\150\170\169\176\193_\131\148\242\205h\b\198",PropResponseInformation -// "\NAK\210\128z\200\208>\190\217\132\227C\182\239v\172\173.3\SUBy\143\171\229\181\144A",PropReasonString -// ">\242N9\182",PropUserProperty "\158\141\252\150" -// "\172\ETB\165B\189\196\222\173\240\200\159K\NUL",PropAuthenticationMethod -// "\186\213\132\224\ETB\237\141\aa\ETB`\135\194\219\243\184?\v\235b\ESC\137\180B\199",PropAuthenticationMethod -// "\247-\159\142G4\250\223\&1\178\173\223\144)",PropAuthenticationMethod -// "\209\SOl\251\222\192\DC4\SOU\DC2\US\199i\211\193\248\138\GS\231\202\223\128\214\184^\135\240S",PropContentType -// "\159#\142\233\"\154\DC4\214ikm\150\RS",PropMessageExpiryInterval 7285] -TEST(Subscribe5QCTest, Encode22) { +// QoS2}),("\200\DC1P\EOT&",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS1}),("\200k\212;\251\194\248\153",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("s\233\DEL\210\244\r\226\142\130\195R",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\228\164;\SUB'C\EM\168\199Z\168Yb\SO\EM",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\210|7\DC3\f}\178\DC4\141\DC2\204\NUL\231\224\SOH|}",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropAuthenticationData +// "{",PropMessageExpiryInterval 5895,PropSubscriptionIdentifier 5,PropSessionExpiryInterval +// 25392,PropSharedSubscriptionAvailable 28,PropSubscriptionIdentifierAvailable 62,PropAuthenticationMethod +// "\159\DEL<\155\134%\196",PropAssignedClientIdentifier +// "\\,\192$\202\&5\255\220\ESC\189\244\239\&5@3\n\176\CAN}M,\f\239\216L\207\179o\f",PropPayloadFormatIndicator +// 192,PropAuthenticationData "\f\SI\229\195\254\&3",PropMaximumQoS 239,PropServerReference +// "\190\197Lr\tft\221\254\137\193\\\DC1\182\244x@I\\\223\247\137\206>\CAN\208\255",PropRequestProblemInformation +// 159,PropRetainAvailable 120,PropContentType +// "\EOTD\176\165\131\198\219T\145\236\US\177\&5[\n\STX\198\&7\143\CAN\b\201\186\f\129Kt",PropReasonString +// "\130\249\DC1B\134q\198\206_\217I\183d!P)\DC2\201\b\220\242\199;\220",PropCorrelationData +// "\180bx\129h\NUL\EM\191/\179lg\EM",PropCorrelationData "\175O",PropRetainAvailable 29,PropRequestProblemInformation +// 96,PropMessageExpiryInterval 19278,PropMessageExpiryInterval 32397,PropResponseInformation +// "\a\128Z\207qt\159\207\162\226q\SOH&\143(p\192n9_\216X \DC1\DLE\"\243f;",PropSubscriptionIdentifier +// 4,PropMaximumPacketSize 31914] +TEST(Subscribe5QCTest, Encode23) { uint8_t pkt[] = { - 0x82, 0xf5, 0x4, 0x1f, 0x3a, 0x93, 0x3, 0x16, 0x0, 0x8, 0xaa, 0x9f, 0x7a, 0xee, 0xba, 0x5e, 0xdf, 0xd2, 0x13, - 0x20, 0x62, 0x22, 0x13, 0x4f, 0x2a, 0x16, 0x22, 0x26, 0xdc, 0x16, 0x0, 0x11, 0xb0, 0x70, 0xc0, 0x9c, 0x1f, 0xa, - 0xd9, 0x8b, 0x5a, 0xca, 0x58, 0xea, 0x8c, 0x79, 0x2c, 0xc3, 0x93, 0x1f, 0x0, 0x18, 0xfa, 0x88, 0x41, 0x8a, 0x8f, - 0x62, 0xb5, 0x5d, 0x65, 0x2f, 0x56, 0x86, 0x6c, 0x3d, 0xb9, 0xf8, 0xa, 0x70, 0x81, 0xac, 0x28, 0x1e, 0xba, 0xf, - 0x8, 0x0, 0x1e, 0x2f, 0xb8, 0xb5, 0x3e, 0x3e, 0xe7, 0xe, 0xdb, 0x27, 0x93, 0x82, 0xb1, 0xee, 0x72, 0xe9, 0x20, - 0x47, 0x78, 0xc6, 0x46, 0x64, 0xd7, 0xd1, 0x16, 0x2e, 0x12, 0xe, 0xb1, 0x81, 0x2b, 0x1f, 0x0, 0x1, 0xaa, 0x3, - 0x0, 0x1d, 0x93, 0x4d, 0x71, 0x5, 0x42, 0x21, 0xf7, 0x8f, 0xed, 0x62, 0x6, 0x23, 0xa3, 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0x4, 0x27, 0x0, 0x0, 0x7c, 0xaa, + 0x0, 0x2, 0xa8, 0xef, 0x1c, 0x0, 0x10, 0x62, 0x12, 0xf7, 0xbf, 0xb5, 0x3b, 0x5f, 0x90, 0x3, 0x39, 0x52, 0xc, + 0xd4, 0xa, 0x2a, 0x3b, 0xd, 0x0, 0x1b, 0x4d, 0xf5, 0x8b, 0x73, 0x43, 0xb0, 0xe9, 0x34, 0xf, 0x88, 0xbc, 0x25, + 0xdb, 0xd, 0x5, 0xe, 0x53, 0x8e, 0x25, 0x2a, 0x52, 0x38, 0xab, 0xb, 0x95, 0xb4, 0x9b, 0x19, 0x0, 0xc, 0x46, + 0x8f, 0xbc, 0xe5, 0x8b, 0x7e, 0xc9, 0xa, 0x1d, 0x56, 0x73, 0xb, 0x10, 0x0, 0x11, 0x4d, 0xcb, 0xca, 0x94, 0xe3, + 0xf3, 0xe3, 0x53, 0xef, 0x68, 0x8, 0xa5, 0x33, 0xe6, 0x14, 0x42, 0x7f, 0xa, 0x0, 0x5, 0xc8, 0x11, 0x50, 0x4, + 0x26, 0x29, 0x0, 0x8, 0xc8, 0x6b, 0xd4, 0x3b, 0xfb, 0xc2, 0xf8, 0x99, 0x1a, 0x0, 0xb, 0x73, 0xe9, 0x7f, 0xd2, + 0xf4, 0xd, 0xe2, 0x8e, 0x82, 0xc3, 0x52, 0x1a, 0x0, 0xf, 0xe4, 0xa4, 0x3b, 0x1a, 0x27, 0x43, 0x19, 0xa8, 0xc7, + 0x5a, 0xa8, 0x59, 0x62, 0xe, 0x19, 0x14, 0x0, 0x11, 0xd2, 0x7c, 0x37, 0x13, 0xc, 0x7d, 0xb2, 0x14, 0x8d, 0x12, + 0xcc, 0x0, 0xe7, 0xe0, 0x1, 0x7c, 0x7d, 0x20, 0x0, 0x0, 0x26}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x77, 0xf8, 0x42, 0x6a, 0x17, 0x12, 0xe2, 0x55}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xa8, 0xef}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbe, 0xd9, 0x5b}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x62, 0x12, 0xf7, 0xbf, 0xb5, 0x3b, 0x5f, 0x90, + 0x3, 0x39, 0x52, 0xc, 0xd4, 0xa, 0x2a, 0x3b}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x34, 0x2f, 0xe1, 0xaf, 0x34, 0xb9, 0x35, 0x6a, 0xe4, 0xc3, 0xd9, 0xb8, - 0x8e, 0x91, 0x28, 0x37, 0x25, 0xa5, 0x66, 0x62, 0x5d, 0x9c, 0x2}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4d, 0xf5, 0x8b, 0x73, 0x43, 0xb0, 0xe9, 0x34, 0xf, 0x88, 0xbc, 0x25, 0xdb, 0xd, + 0x5, 0xe, 0x53, 0x8e, 0x25, 0x2a, 0x52, 0x38, 0xab, 0xb, 0x95, 0xb4, 0x9b}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x83, 0x9c, 0xe1, 0x94, 0xb0, 0x4f, 0x35, 0x3, 0xd5, 0xda, 0xd6, 0xae, 0xd6, - 0x53, 0xf2, 0xc6, 0x59, 0x98, 0x32, 0x56, 0x25, 0xbc, 0xde, 0x1d, 0x38}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x46, 0x8f, 0xbc, 0xe5, 0x8b, 0x7e, 0xc9, 0xa, 0x1d, 0x56, 0x73, 0xb}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x31, 0x1f, 0xb0, 0x29, 0x16, 0x33, 0xe, 0xa, 0xa, 0x34, 0x72, 0xbc, 0xa5, 0x76, - 0x6a, 0xd8, 0xbb, 0x5d, 0x25, 0xf3, 0x32, 0x34, 0x34, 0x16, 0xba, 0xa6, 0xd}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x4d, 0xcb, 0xca, 0x94, 0xe3, 0xf3, 0xe3, 0x53, 0xef, + 0x68, 0x8, 0xa5, 0x33, 0xe6, 0x14, 0x42, 0x7f}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xaa, 0x3a, 0xc5, 0xcf, 0xfe, 0x10, 0xda, 0x63, 0xd, 0x86, 0xb8, - 0xeb, 0x0, 0x71, 0x3f, 0xae, 0x92, 0x42, 0xe3, 0xf0, 0xd3}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xc8, 0x11, 0x50, 0x4, 0x26}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x97, 0xed, 0x48, 0xd7, 0x4d, 0x97, 0x14, 0x90, - 0xe4, 0xb4, 0x63, 0xd2, 0xb, 0xc3, 0xfb}; - lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xc8, 0x6b, 0xd4, 0x3b, 0xfb, 0xc2, 0xf8, 0x99}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa2, 0xff, 0xfc, 0x11, 0x37, 0x8a, 0x33, 0x2e, 0x9f, 0x57, 0xef, 0xed, 0x7b, - 0x5a, 0x2f, 0x54, 0xe, 0x84, 0xf6, 0xfb, 0xaa, 0xf3, 0xba, 0xa2, 0xb1, 0x37}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x73, 0xe9, 0x7f, 0xd2, 0xf4, 0xd, 0xe2, 0x8e, 0x82, 0xc3, 0x52}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe1, 0x29, 0x75, 0x1a, 0xb5, 0x23, 0x17, 0x84, 0x20, 0xd4, - 0xee, 0x47, 0x39, 0x7b, 0x7c, 0x2d, 0x7b, 0x68, 0x3a, 0x40, - 0x72, 0x30, 0xba, 0x72, 0x14, 0xd6, 0xe1, 0x34}; - lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xe4, 0xa4, 0x3b, 0x1a, 0x27, 0x43, 0x19, 0xa8, + 0xc7, 0x5a, 0xa8, 0x59, 0x62, 0xe, 0x19}; + lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x6c, 0x24}; - lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0xd2, 0x7c, 0x37, 0x13, 0xc, 0x7d, 0xb2, 0x14, 0x8d, + 0x12, 0xcc, 0x0, 0xe7, 0xe0, 0x1, 0x7c, 0x7d}; + lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x3e, 0xd9, 0xb9, 0xa6, 0x15, 0xd8, 0xf8, 0x28, 0xac, 0xc2, 0xbd}; - lwmqtt_string_t topic_filter_s10 = {11, (char*)&topic_filter_s10_bytes}; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; topic_filters[10] = topic_filter_s10; lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[6].retain_as_published = true; sub_opts[6].no_local = false; sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[7].retain_as_published = true; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = false; sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS1; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[10].retain_as_published = false; sub_opts[10].no_local = true; - uint8_t bytesprops0[] = {0xaa, 0x9f, 0x7a, 0xee, 0xba, 0x5e, 0xdf, 0xd2}; - uint8_t bytesprops1[] = {0xb0, 0x70, 0xc0, 0x9c, 0x1f, 0xa, 0xd9, 0x8b, 0x5a, - 0xca, 0x58, 0xea, 0x8c, 0x79, 0x2c, 0xc3, 0x93}; - uint8_t bytesprops2[] = {0xfa, 0x88, 0x41, 0x8a, 0x8f, 0x62, 0xb5, 0x5d, 0x65, 0x2f, 0x56, 0x86, - 0x6c, 0x3d, 0xb9, 0xf8, 0xa, 0x70, 0x81, 0xac, 0x28, 0x1e, 0xba, 0xf}; - uint8_t bytesprops3[] = {0x2f, 0xb8, 0xb5, 0x3e, 0x3e, 0xe7, 0xe, 0xdb, 0x27, 0x93, 0x82, 0xb1, 0xee, 0x72, 0xe9, - 0x20, 0x47, 0x78, 0xc6, 0x46, 0x64, 0xd7, 0xd1, 0x16, 0x2e, 0x12, 0xe, 0xb1, 0x81, 0x2b}; - uint8_t bytesprops4[] = {0xaa}; - uint8_t bytesprops5[] = {0x93, 0x4d, 0x71, 0x5, 0x42, 0x21, 0xf7, 0x8f, 0xed, 0x62, 0x6, 0x23, 0xa3, 0xb0, 0xb3, - 0x1b, 0x60, 0xc6, 0x85, 0xcd, 0x7a, 0x4b, 0x1, 0x5d, 0xcc, 0xac, 0x5a, 0xcb, 0xa5}; - uint8_t bytesprops6[] = {0xe9, 0x7b, 0x87, 0xc, 0xf7, 0x79, 0x26, 0xcc, 0xed, 0xfe, 0x37, 0x6, 0x18, - 0x44, 0x87, 0xd, 0x30, 0xb7, 0x4c, 0x7f, 0x47, 0x63, 0xc2, 0x59, 0x57}; - uint8_t bytesprops7[] = {0x46, 0xa6, 0xec, 0x9f, 0x66, 0x1f, 0xe6, 0x74, 0x30, 0x25, 0xf2, 0xe7, 0xa5, 0xde, - 0x50, 0xe, 0xa3, 0x30, 0xc, 0x47, 0x47, 0x77, 0x8f, 0x5f, 0x47, 0x37, 0x9e, 0xbb}; - uint8_t bytesprops8[] = {0xc7, 0xa2, 0xdc, 0xa4, 0x76, 0xd1, 0xd1, 0x13, 0xd8, 0xe2, 0x34, 0xd7, 0x18, 0x1d, 0xd7, - 0x2d, 0x96, 0xaa, 0xa9, 0xb0, 0xc1, 0x5f, 0x83, 0x94, 0xf2, 0xcd, 0x68, 0x8, 0xc6}; - uint8_t bytesprops9[] = {0x15, 0xd2, 0x80, 0x7a, 0xc8, 0xd0, 0x3e, 0xbe, 0xd9, 0x84, 0xe3, 0x43, 0xb6, 0xef, - 0x76, 0xac, 0xad, 0x2e, 0x33, 0x1a, 0x79, 0x8f, 0xab, 0xe5, 0xb5, 0x90, 0x41}; - uint8_t bytesprops10[] = {0x3e, 0xf2, 0x4e, 0x39, 0xb6}; - uint8_t bytesprops12[] = {0xac, 0x17, 0xa5, 0x42, 0xbd, 0xc4, 0xde, 0xad, 0xf0, 0xc8, 0x9f, 0x4b, 0x0}; - uint8_t bytesprops11[] = {0x9e, 0x8d, 0xfc, 0x96}; - uint8_t bytesprops13[] = {0xba, 0xd5, 0x84, 0xe0, 0x17, 0xed, 0x8d, 0x7, 0x61, 0x17, 0x60, 0x87, 0xc2, - 0xdb, 0xf3, 0xb8, 0x3f, 0xb, 0xeb, 0x62, 0x1b, 0x89, 0xb4, 0x42, 0xc7}; - uint8_t bytesprops14[] = {0xf7, 0x2d, 0x9f, 0x8e, 0x47, 0x34, 0xfa, 0xdf, 0x31, 0xb2, 0xad, 0xdf, 0x90, 0x29}; - uint8_t bytesprops15[] = {0xd1, 0xe, 0x6c, 0xfb, 0xde, 0xc0, 0x14, 0xe, 0x55, 0x12, 0x1f, 0xc7, 0x69, 0xd3, - 0xc1, 0xf8, 0x8a, 0x1d, 0xe7, 0xca, 0xdf, 0x80, 0xd6, 0xb8, 0x5e, 0x87, 0xf0, 0x53}; - uint8_t bytesprops16[] = {0x9f, 0x23, 0x8e, 0xe9, 0x22, 0x9a, 0x14, 0xd6, 0x69, 0x6b, 0x6d, 0x96, 0x1e}; + uint8_t bytesprops0[] = {0x7b}; + uint8_t bytesprops1[] = {0x9f, 0x7f, 0x3c, 0x9b, 0x86, 0x25, 0xc4}; + uint8_t bytesprops2[] = {0x5c, 0x2c, 0xc0, 0x24, 0xca, 0x35, 0xff, 0xdc, 0x1b, 0xbd, 0xf4, 0xef, 0x35, 0x40, 0x33, + 0xa, 0xb0, 0x18, 0x7d, 0x4d, 0x2c, 0xc, 0xef, 0xd8, 0x4c, 0xcf, 0xb3, 0x6f, 0xc}; + uint8_t bytesprops3[] = {0xc, 0xf, 0xe5, 0xc3, 0xfe, 0x33}; + uint8_t bytesprops4[] = {0xbe, 0xc5, 0x4c, 0x72, 0x9, 0x66, 0x74, 0xdd, 0xfe, 0x89, 0xc1, 0x5c, 0x11, 0xb6, + 0xf4, 0x78, 0x40, 0x49, 0x5c, 0xdf, 0xf7, 0x89, 0xce, 0x3e, 0x18, 0xd0, 0xff}; + uint8_t bytesprops5[] = {0x4, 0x44, 0xb0, 0xa5, 0x83, 0xc6, 0xdb, 0x54, 0x91, 0xec, 0x1f, 0xb1, 0x35, 0x5b, + 0xa, 0x2, 0xc6, 0x37, 0x8f, 0x18, 0x8, 0xc9, 0xba, 0xc, 0x81, 0x4b, 0x74}; + uint8_t bytesprops6[] = {0x82, 0xf9, 0x11, 0x42, 0x86, 0x71, 0xc6, 0xce, 0x5f, 0xd9, 0x49, 0xb7, + 0x64, 0x21, 0x50, 0x29, 0x12, 0xc9, 0x8, 0xdc, 0xf2, 0xc7, 0x3b, 0xdc}; + uint8_t bytesprops7[] = {0xb4, 0x62, 0x78, 0x81, 0x68, 0x0, 0x19, 0xbf, 0x2f, 0xb3, 0x6c, 0x67, 0x19}; + uint8_t bytesprops8[] = {0xaf, 0x4f}; + uint8_t bytesprops9[] = {0x7, 0x80, 0x5a, 0xcf, 0x71, 0x74, 0x9f, 0xcf, 0xa2, 0xe2, 0x71, 0x1, 0x26, 0x8f, 0x28, + 0x70, 0xc0, 0x6e, 0x39, 0x5f, 0xd8, 0x58, 0x20, 0x11, 0x10, 0x22, 0xf3, 0x66, 0x3b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8290}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4943}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9948}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31659}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4540}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24650}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops11}, .v = {13, (char*)&bytesprops12}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops15}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops16}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7285}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5895}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25392}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19278}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32397}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31914}}, }; lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7994, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10563, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23842 [("\140\185\224\250R\251\"\210\238\130\148\253\176\167\230\DELx%",SubOptions {_retainHandling -// = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("k\157(%\238\144\NAK\133\246\206\163w\161\180x5X\SI\SYN(\130\224u\222\247\155\175\200",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\188k9#!@s.\150+\ETBF\197\DC3i\159Z\197,\214\167\253\245\aE",SubOptions {_retainHandling = +// SubscribeRequest 30451 [("%\173",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS1}),("\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS1}),("u\167Z\ENQ\NUL\246F\186",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("$Gw\252Le",SubOptions {_retainHandling = // SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("+\194\188\205\157\178\221\t\245\213\254W\129\251A\aV\219\210\b\229<\149\204&\201\196\182U",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\222\146\234\140\195c\209LL$\222\179\153\DEL\208\218\132\209\214%\139\228\230",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\CAN\151aE\174\174\225\221%N\238d\SI\187",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropWillDelayInterval 6427,PropServerReference -// "r\241:\181\231\231xy\251w\214\145[",PropMessageExpiryInterval 8166,PropSessionExpiryInterval -// 1244,PropRequestProblemInformation 241,PropSharedSubscriptionAvailable 206,PropRequestProblemInformation -// 179,PropTopicAliasMaximum 3266,PropContentType "\220;\ACK\SOH\229\228&S9{b\143\171J\133$cX",PropReceiveMaximum -// 27044,PropPayloadFormatIndicator 233,PropCorrelationData -// "\158\t\SO\149G,o\EM\133\196\182\224\&7\230\171}*\DEL\\\238\195",PropUserProperty "D\246\216\237^\159\ENQ\150t Nb" -// "",PropUserProperty "\201\132@h\202\139\192\221\DC2\241m\175s;\182\FS\128\227\159\225\208\247\ETB\196\237\255\182g" -// "\214\250\131%\195\195IG\138X\250\217",PropWillDelayInterval 20526,PropSubscriptionIdentifier -// 8,PropSessionExpiryInterval 21501,PropSubscriptionIdentifier 31,PropMaximumPacketSize 30816,PropMessageExpiryInterval -// 12097,PropMaximumQoS 191,PropWillDelayInterval 14550,PropMessageExpiryInterval 10328,PropMessageExpiryInterval -// 19723,PropMaximumQoS 67,PropWillDelayInterval 31618,PropResponseTopic -// "\218\254\b\221\224\253\168\183\161\181\b\128\132\\>\f\225\180\212\vV\188\EOTTx\215",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\ETX",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropMaximumQoS +// 107,PropRequestProblemInformation 8,PropTopicAliasMaximum 31079,PropServerKeepAlive +// 30906,PropSharedSubscriptionAvailable 183,PropMaximumPacketSize 22245,PropAuthenticationMethod +// "\184\181\193\176\186\243\139\201\155\229\136\168\225\DC1\EOTYV\173\ESC\DC3\170",PropRetainAvailable +// 243,PropSubscriptionIdentifier 12,PropCorrelationData "\204\189\132U\215",PropServerReference +// "+\206\240JR\200\168\206\182-\209\163\171O\169:",PropUserProperty "\DC1\145\&2\DC2" "\DC4",PropServerReference +// "?\137hg\168\167N\186Ad\194\DC1",PropMaximumQoS 230,PropServerKeepAlive 16962,PropResponseTopic +// "\204\156l\167\ESC\172\142\223\248\214h[]",PropServerKeepAlive 17136,PropSubscriptionIdentifierAvailable +// 23,PropRequestProblemInformation 1,PropReasonString "\187Az\153H#\151\NULo",PropAuthenticationData +// "*\164",PropResponseTopic +// "\207\195\147\&6\198^\NAK\148Y\191d-\237\234\145\SYN\DLE\130\239\214\CAN\207\248",PropAuthenticationMethod +// "8Ty\200\190^\241T\220.\EM\237\158\ENQ\139\238\186\193\242%\146\205*\ENQ"] +TEST(Subscribe5QCTest, Encode24) { uint8_t pkt[] = { - 0x82, 0xfc, 0x2, 0x5d, 0x22, 0xdd, 0x1, 0x18, 0x0, 0x0, 0x19, 0x1b, 0x1c, 0x0, 0xd, 0x72, 0xf1, 0x3a, 0xb5, - 0xe7, 0xe7, 0x78, 0x79, 0xfb, 0x77, 0xd6, 0x91, 0x5b, 0x2, 0x0, 0x0, 0x1f, 0xe6, 0x11, 0x0, 0x0, 0x4, 0xdc, - 0x17, 0xf1, 0x2a, 0xce, 0x17, 0xb3, 0x22, 0xc, 0xc2, 0x3, 0x0, 0x12, 0xdc, 0x3b, 0x6, 0x1, 0xe5, 0xe4, 0x26, - 0x53, 0x39, 0x7b, 0x62, 0x8f, 0xab, 0x4a, 0x85, 0x24, 0x63, 0x58, 0x21, 0x69, 0xa4, 0x1, 0xe9, 0x9, 0x0, 0x15, - 0x9e, 0x9, 0xe, 0x95, 0x47, 0x2c, 0x6f, 0x19, 0x85, 0xc4, 0xb6, 0xe0, 0x37, 0xe6, 0xab, 0x7d, 0x2a, 0x7f, 0x5c, - 0xee, 0xc3, 0x26, 0x0, 0xc, 0x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 0xa4, 0xf7, 0x70, 0x1a, 0x7e, 0x44, + 0xdb, 0x21, 0x3a, 0x1, 0x5f, 0xc0, 0x16, 0x0, 0xb, 0xe2, 0x28, 0xc8, 0x37, 0x46, 0x83, 0xff, 0xdf, 0x71, 0xb2, + 0x3b, 0x29, 0x0, 0x19, 0xe4, 0xda, 0xc6, 0xb6, 0xa8, 0x6a, 0x26, 0x12, 0x79, 0xf9, 0x3e, 0x84, 0x5c, 0x3e, 0xc, + 0xe1, 0xb4, 0xd4, 0xb, 0x56, 0xbc, 0x4, 0x54, 0x78, 0xd7, 0xc, 0x0, 0x1, 0x3, 0x2c}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x8c, 0xb9, 0xe0, 0xfa, 0x52, 0xfb, 0x22, 0xd2, 0xee, - 0x82, 0x94, 0xfd, 0xb0, 0xa7, 0xe6, 0x7f, 0x78, 0x25}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x25, 0xad}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6b, 0x9d, 0x28, 0x25, 0xee, 0x90, 0x15, 0x85, 0xf6, 0xce, - 0xa3, 0x77, 0xa1, 0xb4, 0x78, 0x35, 0x58, 0xf, 0x16, 0x28, - 0x82, 0xe0, 0x75, 0xde, 0xf7, 0x9b, 0xaf, 0xc8}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xbc, 0x6b, 0x39, 0x23, 0x21, 0x40, 0x73, 0x2e, 0x96, 0x2b, 0x17, 0x46, 0xc5, - 0x13, 0x69, 0x9f, 0x5a, 0xc5, 0x2c, 0xd6, 0xa7, 0xfd, 0xf5, 0x7, 0x45}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc5}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2b, 0xc2, 0xbc, 0xcd, 0x9d, 0xb2, 0xdd, 0x9, 0xf5, 0xd5, - 0xfe, 0x57, 0x81, 0xfb, 0x41, 0x7, 0x56, 0xdb, 0xd2, 0x8, - 0xe5, 0x3c, 0x95, 0xcc, 0x26, 0xc9, 0xc4, 0xb6, 0x55}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x75, 0xa7, 0x5a, 0x5, 0x0, 0xf6, 0x46, 0xba}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xde, 0x92, 0xea, 0x8c, 0xc3, 0x63, 0xd1, 0x4c, 0x4c, 0x24, 0xde, 0xb3, - 0x99, 0x7f, 0xd0, 0xda, 0x84, 0xd1, 0xd6, 0x25, 0x8b, 0xe4, 0xe6}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x24, 0x47, 0x77, 0xfc, 0x4c, 0x65}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x18, 0x97, 0x61, 0x45, 0xae, 0xae, 0xe1, 0xdd, 0x25, 0x4e, 0xee, 0x64, 0xf, 0xbb}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xc3, 0xb4, 0x99, 0xbd, 0xdd, 0x5f, 0x69, 0x70, 0xc6, 0x93, 0xb, + 0x19, 0xb6, 0xd7, 0x1e, 0xe1, 0x44, 0xad, 0x3d, 0x6f, 0x4c}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + uint8_t topic_filter_s6_bytes[] = {0xd8, 0x79, 0xa, 0xcf, 0x75, 0x53, 0x35, 0x9d, 0x19, 0x16, 0xb6, 0xa9, 0xbc, 0x9a}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xeb, 0x67, 0xa4, 0xf7, 0x70, 0x1a, 0x7e, 0x44, 0xdb, 0x21, 0x3a, 0x1, 0x5f, 0xc0}; + lwmqtt_string_t topic_filter_s7 = {14, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe2, 0x28, 0xc8, 0x37, 0x46, 0x83, 0xff, 0xdf, 0x71, 0xb2, 0x3b}; + lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe4, 0xda, 0xc6, 0xb6, 0xa8, 0x6a, 0x26, 0x12, 0x79, 0xf9, 0x3e, 0x84, 0x5c, + 0x3e, 0xc, 0xe1, 0xb4, 0xd4, 0xb, 0x56, 0xbc, 0x4, 0x54, 0x78, 0xd7}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x3}; + lwmqtt_string_t topic_filter_s10 = {1, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = true; - uint8_t bytesprops0[] = {0x72, 0xf1, 0x3a, 0xb5, 0xe7, 0xe7, 0x78, 0x79, 0xfb, 0x77, 0xd6, 0x91, 0x5b}; - uint8_t bytesprops1[] = {0xdc, 0x3b, 0x6, 0x1, 0xe5, 0xe4, 0x26, 0x53, 0x39, - 0x7b, 0x62, 0x8f, 0xab, 0x4a, 0x85, 0x24, 0x63, 0x58}; - uint8_t bytesprops2[] = {0x9e, 0x9, 0xe, 0x95, 0x47, 0x2c, 0x6f, 0x19, 0x85, 0xc4, 0xb6, - 0xe0, 0x37, 0xe6, 0xab, 0x7d, 0x2a, 0x7f, 0x5c, 0xee, 0xc3}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops3[] = {0x44, 0xf6, 0xd8, 0xed, 0x5e, 0x9f, 0x5, 0x96, 0x74, 0x20, 0x4e, 0x62}; - uint8_t bytesprops6[] = {0xd6, 0xfa, 0x83, 0x25, 0xc3, 0xc3, 0x49, 0x47, 0x8a, 0x58, 0xfa, 0xd9}; - uint8_t bytesprops5[] = {0xc9, 0x84, 0x40, 0x68, 0xca, 0x8b, 0xc0, 0xdd, 0x12, 0xf1, 0x6d, 0xaf, 0x73, 0x3b, - 0xb6, 0x1c, 0x80, 0xe3, 0x9f, 0xe1, 0xd0, 0xf7, 0x17, 0xc4, 0xed, 0xff, 0xb6, 0x67}; - uint8_t bytesprops7[] = {0xda, 0xfe, 0x8, 0xdd, 0xe0, 0xfd, 0xa8, 0xb7, 0xa1, - 0xb5, 0x8, 0x80, 0x3c, 0x52, 0x2b, 0x5f, 0x55, 0xeb}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6427}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8166}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1244}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3266}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27044}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops3}, .v = {0, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops5}, .v = {12, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20526}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 8}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21501}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 31}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30816}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12097}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14550}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10328}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19723}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31618}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops7}}}, - }; - - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23842, 6, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 26921 [("K3\SI\145\&6N\152\205\207\211\175\226(",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\232\&0\ESC1 |\197\148\&8\225\CAN*\229",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] -// [PropReceiveMaximum 15170,PropMaximumQoS 125,PropServerKeepAlive 6331,PropAssignedClientIdentifier -// ">\211\130\153t\NAKk7\214D\ACKq\GS\150\243\233nW\160=\249(",PropReceiveMaximum 19285,PropSessionExpiryInterval -// 22725,PropSessionExpiryInterval 28884,PropSubscriptionIdentifierAvailable 49,PropSubscriptionIdentifierAvailable -// 194,PropRequestProblemInformation 1,PropTopicAliasMaximum 7896,PropSessionExpiryInterval 7833] -TEST(Subscribe5QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x5f, 0x69, 0x29, 0x3c, 0x21, 0x3b, 0x42, 0x24, 0x7d, 0x13, 0x18, 0xbb, 0x12, 0x0, 0x16, 0x3e, - 0xd3, 0x82, 0x99, 0x74, 0x15, 0x6b, 0x37, 0xd6, 0x44, 0x6, 0x71, 0x1d, 0x96, 0xf3, 0xe9, 0x6e, 0x57, - 0xa0, 0x3d, 0xf9, 0x28, 0x21, 0x4b, 0x55, 0x11, 0x0, 0x0, 0x58, 0xc5, 0x11, 0x0, 0x0, 0x70, 0xd4, - 0x29, 0x31, 0x29, 0xc2, 0x17, 0x1, 0x22, 0x1e, 0xd8, 0x11, 0x0, 0x0, 0x1e, 0x99, 0x0, 0xd, 0x4b, - 0x33, 0xf, 0x91, 0x36, 0x4e, 0x98, 0xcd, 0xcf, 0xd3, 0xaf, 0xe2, 0x28, 0xc, 0x0, 0xd, 0xe8, 0x30, - 0x1b, 0x31, 0x20, 0x7c, 0xc5, 0x94, 0x38, 0xe1, 0x18, 0x2a, 0xe5, 0x28}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x4b, 0x33, 0xf, 0x91, 0x36, 0x4e, 0x98, 0xcd, 0xcf, 0xd3, 0xaf, 0xe2, 0x28}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe8, 0x30, 0x1b, 0x31, 0x20, 0x7c, 0xc5, 0x94, 0x38, 0xe1, 0x18, 0x2a, 0xe5}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - uint8_t bytesprops0[] = {0x3e, 0xd3, 0x82, 0x99, 0x74, 0x15, 0x6b, 0x37, 0xd6, 0x44, 0x6, - 0x71, 0x1d, 0x96, 0xf3, 0xe9, 0x6e, 0x57, 0xa0, 0x3d, 0xf9, 0x28}; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = true; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = true; + uint8_t bytesprops0[] = {0xb8, 0xb5, 0xc1, 0xb0, 0xba, 0xf3, 0x8b, 0xc9, 0x9b, 0xe5, 0x88, + 0xa8, 0xe1, 0x11, 0x4, 0x59, 0x56, 0xad, 0x1b, 0x13, 0xaa}; + uint8_t bytesprops1[] = {0xcc, 0xbd, 0x84, 0x55, 0xd7}; + uint8_t bytesprops2[] = {0x2b, 0xce, 0xf0, 0x4a, 0x52, 0xc8, 0xa8, 0xce, + 0xb6, 0x2d, 0xd1, 0xa3, 0xab, 0x4f, 0xa9, 0x3a}; + uint8_t bytesprops4[] = {0x14}; + uint8_t bytesprops3[] = {0x11, 0x91, 0x32, 0x12}; + uint8_t bytesprops5[] = {0x3f, 0x89, 0x68, 0x67, 0xa8, 0xa7, 0x4e, 0xba, 0x41, 0x64, 0xc2, 0x11}; + uint8_t bytesprops6[] = {0xcc, 0x9c, 0x6c, 0xa7, 0x1b, 0xac, 0x8e, 0xdf, 0xf8, 0xd6, 0x68, 0x5b, 0x5d}; + uint8_t bytesprops7[] = {0xbb, 0x41, 0x7a, 0x99, 0x48, 0x23, 0x97, 0x0, 0x6f}; + uint8_t bytesprops8[] = {0x2a, 0xa4}; + uint8_t bytesprops9[] = {0xcf, 0xc3, 0x93, 0x36, 0xc6, 0x5e, 0x15, 0x94, 0x59, 0xbf, 0x64, 0x2d, + 0xed, 0xea, 0x91, 0x16, 0x10, 0x82, 0xef, 0xd6, 0x18, 0xcf, 0xf8}; + uint8_t bytesprops10[] = {0x38, 0x54, 0x79, 0xc8, 0xbe, 0x5e, 0xf1, 0x54, 0xdc, 0x2e, 0x19, 0xed, + 0x9e, 0x5, 0x8b, 0xee, 0xba, 0xc1, 0xf2, 0x25, 0x92, 0xcd, 0x2a, 0x5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15170}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6331}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19285}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22725}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28884}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31079}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30906}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22245}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops3}, .v = {1, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16962}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17136}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 23}}, {.prop = (lwmqtt_prop_t)23, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7896}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7833}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26921, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30451, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21060 [("|\157\247\167%X\146\239\FSa@\163\225",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),(".\147\177\f\201\211\245\229\237\RS",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\EOT\149z\193\&2\140\137\131\155#}#h\153\&4",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("oo\189n\216\174\b[\219d\225\166\b\146^/\138\130\132[\235",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\176\&5\141\&1\143<\138xIV~\187\\\234\250Sa\US\240\219w8vTXw",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\164\153\198\218k\176b\231\SO",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("Y\156\203\236\EOT\225\149\165[\246\158\US(\248",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\140\170^\229\250K\220\216\241\233\146\"",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 5141 [("\173\ff",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS1}),("Jm\241\231Tp\203~\220z\153^\194\DC4\227'q\242\ESC1\177\192Q\185\NAK\ETX\139",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\227\229\242\245\173@\183\167\170\152\186\254\253<\SYN\223>|\242\237\137P8",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),(";\204",SubOptions {_retainHandling +// = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\153H\234.\165\EM\135u#\SO\b\141\141\185I\210.\241\136\224",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\186\197\SYN\130",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\251y\216\143Q\220\DC1\248\132\241\NUL\SI\DC3\b\230z\EM\166|",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\148xP\RSO\SI",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] +// [PropMessageExpiryInterval 30180,PropServerKeepAlive 3352,PropWillDelayInterval 23523,PropMaximumPacketSize +// 1624,PropAuthenticationData "\176\NAKz3+\CANbr\137\DC4\rO\215>\176\235f|\136\US\STX",PropAuthenticationMethod +// "\DEL\158 \228q\246d\210S0\183U",PropMaximumPacketSize 11585,PropSubscriptionIdentifier 1,PropTopicAlias +// 32339,PropMessageExpiryInterval 23859,PropMaximumPacketSize 21817,PropResponseInformation +// "\190s0\DEL}",PropCorrelationData "\186\169)t,B\158\SOH\185g]\245",PropContentType +// "\227\254\&9\223M\166$\231\200#\129\232\224\243p",PropMessageExpiryInterval 20421,PropSubscriptionIdentifierAvailable +// 250,PropSubscriptionIdentifier 4,PropPayloadFormatIndicator 15,PropResponseInformation +// "\DC3\136O\222\211O",PropWillDelayInterval 12115,PropMessageExpiryInterval 5290,PropRequestProblemInformation +// 242,PropAuthenticationMethod +// "\SUBi\SYN\165H\212\242\&3;",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\153\231\243Nc7\160^\177\204:\236\247\fCy\174\181\172\131A",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropTopicAlias -// 19406,PropTopicAlias 1380,PropCorrelationData "\200\148\&2[\251\r\ETB\234",PropSubscriptionIdentifierAvailable -// 14,PropResponseTopic "\193/\209\206\US\155-",PropServerKeepAlive 3091,PropCorrelationData -// "N\230\178\252OC\DEL\174\253p\250;\223M\222F\SO",PropMaximumQoS 220,PropSubscriptionIdentifier -// 32,PropSubscriptionIdentifierAvailable 34,PropMessageExpiryInterval 12666,PropCorrelationData -// "\CAN",PropRequestResponseInformation 197,PropSessionExpiryInterval 5342,PropWillDelayInterval -// 9931,PropMessageExpiryInterval 4431,PropTopicAliasMaximum 24873,PropRequestProblemInformation 210,PropServerKeepAlive -// 20259,PropTopicAlias 32129,PropRequestProblemInformation 253,PropReasonString "\134",PropMessageExpiryInterval -// 22401,PropSharedSubscriptionAvailable 51,PropTopicAlias 8670,PropSharedSubscriptionAvailable 252,PropServerReference -// ".ae\252\215",PropAuthenticationMethod -// "\235C\205\250\RS\181:O\CAN\156\248\204,b\NUL\148\196g\183\151\161",PropReceiveMaximum 25059] +// SubscribeRequest 8922 [("8[\204Te\235\185\154\136\vI\148\223",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("/\242O\211\r\131\245\210\240\128\SI/@",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\149\136\194\189\ESC\130\154\195\138b\146\NUL\181d\RS\a\216\241\FS\252\144\&3\185$K",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropMaximumQoS +// 26,PropAssignedClientIdentifier +// "H\DC3\ETB\158\DC1'\220\194^\SOHz\SOH9\184[1h\188\b\RS=\DC4\136a\229\t6:",PropAssignedClientIdentifier +// "\163\208J\209&Yb|_iC>\231",PropWillDelayInterval 13933,PropRequestResponseInformation 204,PropWillDelayInterval +// 15339,PropWildcardSubscriptionAvailable 166] TEST(Subscribe5QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0xd5, 0x1, 0x48, 0xf5, 0x94, 0x1, 0x23, 0x4b, 0xce, 0x23, 0x5, 0x64, 0x9, 0x0, 0x8, 0xc8, - 0x94, 0x32, 0x5b, 0xfb, 0xd, 0x17, 0xea, 0x29, 0xe, 0x8, 0x0, 0x7, 0xc1, 0x2f, 0xd1, 0xce, 0x1f, - 0x9b, 0x2d, 0x13, 0xc, 0x13, 0x9, 0x0, 0x11, 0x4e, 0xe6, 0xb2, 0xfc, 0x4f, 0x43, 0x7f, 0xae, 0xfd, - 0x70, 0xfa, 0x3b, 0xdf, 0x4d, 0xde, 0x46, 0xe, 0x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0x1e, 0x3d, 0x14, + 0x88, 0x61, 0xe5, 0x9, 0x36, 0x3a, 0x12, 0x0, 0xd, 0xa3, 0xd0, 0x4a, 0xd1, 0x26, 0x59, 0x62, + 0x7c, 0x5f, 0x69, 0x43, 0x3e, 0xe7, 0x18, 0x0, 0x0, 0x36, 0x6d, 0x19, 0xcc, 0x18, 0x0, 0x0, + 0x3b, 0xeb, 0x28, 0xa6, 0x0, 0xd, 0x38, 0x5b, 0xcc, 0x54, 0x65, 0xeb, 0xb9, 0x9a, 0x88, 0xb, + 0x49, 0x94, 0xdf, 0x4, 0x0, 0xd, 0x2f, 0xf2, 0x4f, 0xd3, 0xd, 0x83, 0xf5, 0xd2, 0xf0, 0x80, + 0xf, 0x2f, 0x40, 0x11, 0x0, 0x19, 0x95, 0x88, 0xc2, 0xbd, 0x1b, 0x82, 0x9a, 0xc3, 0x8a, 0x62, + 0x92, 0x0, 0xb5, 0x64, 0x1e, 0x7, 0xd8, 0xf1, 0x1c, 0xfc, 0x90, 0x33, 0xb9, 0x24, 0x4b, 0x15}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x3d, 0xa1, 0xfd, 0xe6, 0x6, 0x7c, 0x38}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x38, 0x5b, 0xcc, 0x54, 0x65, 0xeb, 0xb9, 0x9a, 0x88, 0xb, 0x49, 0x94, 0xdf}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x24, 0x77, 0x58, 0xcc, 0x9e, 0x49, 0xd8, 0x39, 0x63, 0x8e, 0x40, 0xc3, - 0xf8, 0xba, 0x3e, 0x1a, 0x69, 0x16, 0xa5, 0x48, 0xd4, 0xf2, 0x33, 0x3b}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2f, 0xf2, 0x4f, 0xd3, 0xd, 0x83, 0xf5, 0xd2, 0xf0, 0x80, 0xf, 0x2f, 0x40}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x99, 0xe7, 0xf3, 0x4e, 0x63, 0x37, 0xa0, 0x5e, 0xb1, 0xcc, 0x3a, - 0xec, 0xf7, 0xc, 0x43, 0x79, 0xae, 0xb5, 0xac, 0x83, 0x41}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x95, 0x88, 0xc2, 0xbd, 0x1b, 0x82, 0x9a, 0xc3, 0x8a, 0x62, 0x92, 0x0, 0xb5, + 0x64, 0x1e, 0x7, 0xd8, 0xf1, 0x1c, 0xfc, 0x90, 0x33, 0xb9, 0x24, 0x4b}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; lwmqtt_sub_options_t sub_opts[3]; sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - uint8_t bytesprops0[] = {0xc8, 0x94, 0x32, 0x5b, 0xfb, 0xd, 0x17, 0xea}; - uint8_t bytesprops1[] = {0xc1, 0x2f, 0xd1, 0xce, 0x1f, 0x9b, 0x2d}; - uint8_t bytesprops2[] = {0x4e, 0xe6, 0xb2, 0xfc, 0x4f, 0x43, 0x7f, 0xae, 0xfd, - 0x70, 0xfa, 0x3b, 0xdf, 0x4d, 0xde, 0x46, 0xe}; - uint8_t bytesprops3[] = {0x18}; - uint8_t bytesprops4[] = {0x86}; - uint8_t bytesprops5[] = {0x2e, 0x61, 0x65, 0xfc, 0xd7}; - uint8_t bytesprops6[] = {0xeb, 0x43, 0xcd, 0xfa, 0x1e, 0xb5, 0x3a, 0x4f, 0x18, 0x9c, 0xf8, - 0xcc, 0x2c, 0x62, 0x0, 0x94, 0xc4, 0x67, 0xb7, 0x97, 0xa1}; + uint8_t bytesprops0[] = {0x48, 0x13, 0x17, 0x9e, 0x11, 0x27, 0xdc, 0xc2, 0x5e, 0x1, 0x7a, 0x1, 0x39, 0xb8, + 0x5b, 0x31, 0x68, 0xbc, 0x8, 0x1e, 0x3d, 0x14, 0x88, 0x61, 0xe5, 0x9, 0x36, 0x3a}; + uint8_t bytesprops1[] = {0xa3, 0xd0, 0x4a, 0xd1, 0x26, 0x59, 0x62, 0x7c, 0x5f, 0x69, 0x43, 0x3e, 0xe7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19406}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1380}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3091}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 32}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12666}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5342}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9931}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4431}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24873}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20259}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32129}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22401}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8670}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25059}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13933}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15339}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 166}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18677, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8922, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15426 [(">,\208\132\222\237\163V\189v\141\DC4<\218\135\r(U",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] -// [PropSubscriptionIdentifierAvailable 250,PropResponseInformation "\237t",PropMessageExpiryInterval -// 6544,PropMaximumQoS 212,PropRequestProblemInformation 23,PropRequestResponseInformation 220,PropResponseInformation -// "\236\250\185\236O\167\245\211\195\249\ETBfEj\164\152\174H<\"",PropServerKeepAlive 25666,PropWillDelayInterval -// 7275,PropRetainAvailable 129,PropResponseTopic -// "\ETX+\a\NUL\SUB\247\145\223\201\152k]3M\"\152\233om\139\SO\STX\174yQQj\163\227\167\SI",PropWildcardSubscriptionAvailable 63,PropAuthenticationMethod -// "\EM\163\200\208\DC1\149\182Q/\f)\161\206\252\221\142\&0C\219P%\158\245\202\154g",PropSharedSubscriptionAvailable -// 52,PropSessionExpiryInterval 15259] +// SubscribeRequest 10052 +// [("\197\182\247\NAK\225g\156\RSB\176\131>\210\163+gM\b]f\247\229C\139\206\250\&7\200N(",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\244\237N\DC2\r\SIT\223\DC2\235\166\252\&3\164\242J2\185\ETB$\209#O\222",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SUBP\205",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\SO=\180\165\216\210V\143\215h\230\182\212\148\199\230\SUBO\128\ENQX\163\200\244<\DC2g9P\180",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("3z\NUL6\210\254\222.\146\237\247\DEL*_\251",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("j\196\220\190\210\153\196\134\169\GS\DC2\208m6\155{i\204i=Ln9\201O_\NAK#-\177",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("v\NUL\235\199\138\128\&3\DEL\202Q",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS1}),("\239\216H\UStK\244\237\FSl#\234]\220Ll",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropUserProperty +// "\n!\209\175,1\NAK\164\145]\189" "",PropTopicAlias 29464,PropTopicAliasMaximum 9533,PropServerReference +// "O\218\NAK\253J\142D\197cU\128\219\235\SO\244_\171.v\231%\201",PropReceiveMaximum 3003,PropRetainAvailable +// 188,PropTopicAlias 24040,PropRequestProblemInformation 195,PropRequestResponseInformation 227,PropResponseInformation +// "\175\&4\144\136'\137\242\237B\189_M\154-\181\237B\232\155\207Z\145bc\211{\215",PropRequestResponseInformation +// 172,PropAuthenticationData +// "x*!\176\184[$\208\237\166J\192\184\151\134\218l\237\237\188\228B",PropRequestResponseInformation +// 8,PropSharedSubscriptionAvailable 95,PropAssignedClientIdentifier "\220\236\212<\250\230R\221V\165m0\254L"] TEST(Subscribe5QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0xe4, 0x1, 0x3c, 0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uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x3e, 0x2c, 0xd0, 0x84, 0xde, 0xed, 0xa3, 0x56, 0xbd, - 0x76, 0x8d, 0x14, 0x3c, 0xda, 0x87, 0xd, 0x28, 0x55}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xc5, 0xb6, 0xf7, 0x15, 0xe1, 0x67, 0x9c, 0x1e, 0x42, 0xb0, + 0x83, 0x3e, 0xd2, 0xa3, 0x2b, 0x67, 0x4d, 0x8, 0x5d, 0x66, + 0xf7, 0xe5, 0x43, 0x8b, 0xce, 0xfa, 0x37, 0xc8, 0x4e, 0x28}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + uint8_t topic_filter_s1_bytes[] = {0xf4, 0xed, 0x4e, 0x12, 0xd, 0xf, 0x54, 0xdf, 0x12, 0xeb, 0xa6, 0xfc, + 0x33, 0xa4, 0xf2, 0x4a, 0x32, 0xb9, 0x17, 0x24, 0xd1, 0x23, 0x4f, 0xde}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1a, 0x50, 0xcd}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe, 0x3d, 0xb4, 0xa5, 0xd8, 0xd2, 0x56, 0x8f, 0xd7, 0x68, + 0xe6, 0xb6, 0xd4, 0x94, 0xc7, 0xe6, 0x1a, 0x4f, 0x80, 0x5, + 0x58, 0xa3, 0xc8, 0xf4, 0x3c, 0x12, 0x67, 0x39, 0x50, 0xb4}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x33, 0x7a, 0x0, 0x36, 0xd2, 0xfe, 0xde, 0x2e, + 0x92, 0xed, 0xf7, 0x7f, 0x2a, 0x5f, 0xfb}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6a, 0xc4, 0xdc, 0xbe, 0xd2, 0x99, 0xc4, 0x86, 0xa9, 0x1d, + 0x12, 0xd0, 0x6d, 0x36, 0x9b, 0x7b, 0x69, 0xcc, 0x69, 0x3d, + 0x4c, 0x6e, 0x39, 0xc9, 0x4f, 0x5f, 0x15, 0x23, 0x2d, 0xb1}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x76, 0x0, 0xeb, 0xc7, 0x8a, 0x80, 0x33, 0x7f, 0xca, 0x51}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xef, 0xd8, 0x48, 0x1f, 0x74, 0x4b, 0xf4, 0xed, + 0x1c, 0x6c, 0x23, 0xea, 0x5d, 0xdc, 0x4c, 0x6c}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - uint8_t bytesprops0[] = {0xed, 0x74}; - uint8_t bytesprops1[] = {0xec, 0xfa, 0xb9, 0xec, 0x4f, 0xa7, 0xf5, 0xd3, 0xc3, 0xf9, - 0x17, 0x66, 0x45, 0x6a, 0xa4, 0x98, 0xae, 0x48, 0x3c, 0x22}; - uint8_t bytesprops2[] = {0x3, 0x2b, 0x7, 0x0, 0x1a, 0xf7, 0x91, 0xdf, 0xc9, 0x98, 0x6b, 0x5d, 0x33, 0x4d, - 0x22, 0x98, 0xe9, 0x6f, 0x6d, 0x8b, 0x3c, 0x6a, 0x8e, 0x2f, 0x27, 0xac, 0xda}; - uint8_t bytesprops3[] = {0x9c, 0x95, 0x4, 0xfc, 0x20, 0x93, 0xe8, 0x99, 0x8, 0x1a, 0xd6, 0x82, 0x53, 0x88, 0x9f, - 0x62, 0x5d, 0x3a, 0xf8, 0x2c, 0x37, 0x86, 0xef, 0xa3, 0x1a, 0x17, 0x54, 0x7, 0x7c, 0xe2}; - uint8_t bytesprops4[] = {0xa9, 0x1e, 0x66, 0xc6, 0x6a, 0x7f, 0x78, 0x2f, - 0x5f, 0x20, 0x5f, 0x87, 0x2c, 0xeb, 0x57, 0x27}; - uint8_t bytesprops5[] = {0xd7, 0xe, 0x91, 0x34, 0x23, 0x3e, 0xe, 0x2, 0xae, - 0x79, 0x51, 0x51, 0x6a, 0xa3, 0xe3, 0xa7, 0xf}; - uint8_t bytesprops6[] = {0x19, 0xa3, 0xc8, 0xd0, 0x11, 0x95, 0xb6, 0x51, 0x2f, 0xc, 0x29, 0xa1, 0xce, - 0xfc, 0xdd, 0x8e, 0x30, 0x43, 0xdb, 0x50, 0x25, 0x9e, 0xf5, 0xca, 0x9a, 0x67}; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = true; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops0[] = {0xa, 0x21, 0xd1, 0xaf, 0x2c, 0x31, 0x15, 0xa4, 0x91, 0x5d, 0xbd}; + uint8_t bytesprops2[] = {0x4f, 0xda, 0x15, 0xfd, 0x4a, 0x8e, 0x44, 0xc5, 0x63, 0x55, 0x80, + 0xdb, 0xeb, 0xe, 0xf4, 0x5f, 0xab, 0x2e, 0x76, 0xe7, 0x25, 0xc9}; + uint8_t bytesprops3[] = {0xaf, 0x34, 0x90, 0x88, 0x27, 0x89, 0xf2, 0xed, 0x42, 0xbd, 0x5f, 0x4d, 0x9a, 0x2d, + 0xb5, 0xed, 0x42, 0xe8, 0x9b, 0xcf, 0x5a, 0x91, 0x62, 0x63, 0xd3, 0x7b, 0xd7}; + uint8_t bytesprops4[] = {0x78, 0x2a, 0x21, 0xb0, 0xb8, 0x5b, 0x24, 0xd0, 0xed, 0xa6, 0x4a, + 0xc0, 0xb8, 0x97, 0x86, 0xda, 0x6c, 0xed, 0xed, 0xbc, 0xe4, 0x42}; + uint8_t bytesprops5[] = {0xdc, 0xec, 0xd4, 0x3c, 0xfa, 0xe6, 0x52, 0xdd, 0x56, 0xa5, 0x6d, 0x30, 0xfe, 0x4c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6544}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25666}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7275}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29319}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24182}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15259}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29464}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9533}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3003}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24040}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15426, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10052, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11166 [("\253",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS1}),("\160\191\253\EOT\221\233mn\DLE0\180\USn",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("F\137\196\196\246j\196\202xY\172\CANg",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1}),("\209\FS\DC3#w\220<\201Ou\SI\131]\154\159",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("`\161lN\DLE\160\DC1s:",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("6",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropMaximumPacketSize 4921,PropRequestProblemInformation 188,PropResponseInformation -// "L\161Fb\169\174\&5f\231,\161\\\ry\209g\"\143\195\165",PropAuthenticationMethod -// "\142\RS\EM\SYN\197\NUL\156\209\ESC\132\154!\129H\205)M\161\202|Y\169\231",PropResponseTopic -// "\169\GS",PropUserProperty "\184\DC2\243\227\251\129\a\165\150\201?\231\195\240\189g\219\203>\196" "",PropContentType -// "\EOT`",PropMessageExpiryInterval 13915,PropAuthenticationData -// "8\150\213m\SOH\144\203~to\151t\158\240(\236\&5\DLE\138\193A%H\240\169\217\242",PropMessageExpiryInterval -// 25559,PropRequestResponseInformation 9,PropReasonString -// "T\"\167\249\163R:\ETX\239\US\213az\243\&9\203\160\178\154^p\202d\180",PropMessageExpiryInterval -// 13397,PropRequestResponseInformation 230,PropSessionExpiryInterval 7107,PropWillDelayInterval -// 23581,PropPayloadFormatIndicator 126,PropUserProperty "" "\217^\154\&7\166>\ESC\181",PropRequestProblemInformation -// 8,PropMessageExpiryInterval 16882,PropContentType -// "y\193n\168C\148\202z\245\162\CANU\210`\242\a\SYNT\188\174\223\144\EM",PropSubscriptionIdentifierAvailable -// 150,PropResponseInformation "\159;\198\253\160\217g\246@@\223\162\151N \151",PropReasonString -// "\234\150D\213\160\186b\nE\"\218\228\204\253\159\219\SYN\223\DC2*[",PropRetainAvailable 99,PropServerKeepAlive -// 14604,PropSubscriptionIdentifier 12,PropContentType "y\234\236\&7;\191`5(pw",PropSubscriptionIdentifierAvailable 74] +// SubscribeRequest 12644 [("\185\166\&5\ACK\169\SOk",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropReceiveMaximum 7431,PropResponseTopic +// "\FS\253\196\NUL\224_XZl\140\163F\143,\193X",PropMaximumQoS 28,PropAuthenticationMethod "99",PropResponseInformation +// "\169\169\190\187|\197\DLE\198",PropResponseInformation "3_>"] TEST(Subscribe5QCTest, Encode28) { - uint8_t pkt[] = { - 0x82, 0xef, 0x2, 0x2b, 0x9e, 0xa5, 0x2, 0x27, 0x0, 0x0, 0x13, 0x39, 0x17, 0xbc, 0x1a, 0x0, 0x14, 0x4c, 0xa1, - 0x46, 0x62, 0xa9, 0xae, 0x35, 0x66, 0xe7, 0x2c, 0xa1, 0x5c, 0xd, 0x79, 0xd1, 0x67, 0x22, 0x8f, 0xc3, 0xa5, 0x15, - 0x0, 0x17, 0x8e, 0x1e, 0x19, 0x16, 0xc5, 0x0, 0x9c, 0xd1, 0x1b, 0x84, 0x9a, 0x21, 0x81, 0x48, 0xcd, 0x29, 0x4d, - 0xa1, 0xca, 0x7c, 0x59, 0xa9, 0xe7, 0x8, 0x0, 0x2, 0xa9, 0x1d, 0x26, 0x0, 0x14, 0xb8, 0x12, 0xf3, 0xe3, 0xfb, - 0x81, 0x7, 0xa5, 0x96, 0xc9, 0x3f, 0xe7, 0xc3, 0xf0, 0xbd, 0x67, 0xdb, 0xcb, 0x3e, 0xc4, 0x0, 0x0, 0x3, 0x0, - 0x2, 0x4, 0x60, 0x2, 0x0, 0x0, 0x36, 0x5b, 0x16, 0x0, 0x1b, 0x38, 0x96, 0xd5, 0x6d, 0x1, 0x90, 0xcb, 0x7e, - 0x74, 0x6f, 0x97, 0x74, 0x9e, 0xf0, 0x28, 0xec, 0x35, 0x10, 0x8a, 0xc1, 0x41, 0x25, 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x30, 0xb4, 0x1f, 0x6e, 0x5, 0x0, 0xd, 0x46, - 0x89, 0xc4, 0xc4, 0xf6, 0x6a, 0xc4, 0xca, 0x78, 0x59, 0xac, 0x18, 0x67, 0x11, 0x0, 0xf, 0xd1, 0x1c, 0x13, 0x23, - 0x77, 0xdc, 0x3c, 0xc9, 0x4f, 0x75, 0xf, 0x83, 0x5d, 0x9a, 0x9f, 0xa, 0x0, 0x9, 0x60, 0xa1, 0x6c, 0x4e, 0x10, - 0xa0, 0x11, 0x73, 0x3a, 0x8, 0x0, 0x1, 0x36, 0x11}; + uint8_t pkt[] = {0x82, 0x3e, 0x31, 0x64, 0x2e, 0x21, 0x1d, 0x7, 0x8, 0x0, 0x10, 0x1c, 0xfd, 0xc4, 0x0, 0xe0, + 0x5f, 0x58, 0x5a, 0x6c, 0x8c, 0xa3, 0x46, 0x8f, 0x2c, 0xc1, 0x58, 0x24, 0x1c, 0x15, 0x0, 0x2, + 0x39, 0x39, 0x1a, 0x0, 0x8, 0xa9, 0xa9, 0xbe, 0xbb, 0x7c, 0xc5, 0x10, 0xc6, 0x1a, 0x0, 0x3, + 0x33, 0x5f, 0x3e, 0x0, 0x7, 0xb9, 0xa6, 0x35, 0x6, 0xa9, 0xe, 0x6b, 0x29, 0x0, 0x0, 0x1d}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xfd}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xb9, 0xa6, 0x35, 0x6, 0xa9, 0xe, 0x6b}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa0, 0xbf, 0xfd, 0x4, 0xdd, 0xe9, 0x6d, 0x6e, 0x10, 0x30, 0xb4, 0x1f, 0x6e}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x46, 0x89, 0xc4, 0xc4, 0xf6, 0x6a, 0xc4, 0xca, 0x78, 0x59, 0xac, 0x18, 0x67}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd1, 0x1c, 0x13, 0x23, 0x77, 0xdc, 0x3c, 0xc9, - 0x4f, 0x75, 0xf, 0x83, 0x5d, 0x9a, 0x9f}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x60, 0xa1, 0x6c, 0x4e, 0x10, 0xa0, 0x11, 0x73, 0x3a}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x36}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + lwmqtt_sub_options_t sub_opts[2]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; + sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - uint8_t bytesprops0[] = {0x4c, 0xa1, 0x46, 0x62, 0xa9, 0xae, 0x35, 0x66, 0xe7, 0x2c, - 0xa1, 0x5c, 0xd, 0x79, 0xd1, 0x67, 0x22, 0x8f, 0xc3, 0xa5}; - uint8_t bytesprops1[] = {0x8e, 0x1e, 0x19, 0x16, 0xc5, 0x0, 0x9c, 0xd1, 0x1b, 0x84, 0x9a, 0x21, - 0x81, 0x48, 0xcd, 0x29, 0x4d, 0xa1, 0xca, 0x7c, 0x59, 0xa9, 0xe7}; - uint8_t bytesprops2[] = {0xa9, 0x1d}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops3[] = {0xb8, 0x12, 0xf3, 0xe3, 0xfb, 0x81, 0x7, 0xa5, 0x96, 0xc9, - 0x3f, 0xe7, 0xc3, 0xf0, 0xbd, 0x67, 0xdb, 0xcb, 0x3e, 0xc4}; - uint8_t bytesprops5[] = {0x4, 0x60}; - uint8_t bytesprops6[] = {0x38, 0x96, 0xd5, 0x6d, 0x1, 0x90, 0xcb, 0x7e, 0x74, 0x6f, 0x97, 0x74, 0x9e, 0xf0, - 0x28, 0xec, 0x35, 0x10, 0x8a, 0xc1, 0x41, 0x25, 0x48, 0xf0, 0xa9, 0xd9, 0xf2}; - uint8_t bytesprops7[] = {0x54, 0x22, 0xa7, 0xf9, 0xa3, 0x52, 0x3a, 0x3, 0xef, 0x1f, 0xd5, 0x61, - 0x7a, 0xf3, 0x39, 0xcb, 0xa0, 0xb2, 0x9a, 0x5e, 0x70, 0xca, 0x64, 0xb4}; - uint8_t bytesprops9[] = {0xd9, 0x5e, 0x9a, 0x37, 0xa6, 0x3e, 0x1b, 0xb5}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops10[] = {0x79, 0xc1, 0x6e, 0xa8, 0x43, 0x94, 0xca, 0x7a, 0xf5, 0xa2, 0x18, 0x55, - 0xd2, 0x60, 0xf2, 0x7, 0x16, 0x54, 0xbc, 0xae, 0xdf, 0x90, 0x19}; - uint8_t bytesprops11[] = {0x9f, 0x3b, 0xc6, 0xfd, 0xa0, 0xd9, 0x67, 0xf6, - 0x40, 0x40, 0xdf, 0xa2, 0x97, 0x4e, 0x20, 0x97}; - uint8_t bytesprops12[] = {0xea, 0x96, 0x44, 0xd5, 0xa0, 0xba, 0x62, 0xa, 0x45, 0x22, 0xda, - 0xe4, 0xcc, 0xfd, 0x9f, 0xdb, 0x16, 0xdf, 0x12, 0x2a, 0x5b}; - uint8_t bytesprops13[] = {0x79, 0xea, 0xec, 0x37, 0x3b, 0xbf, 0x60, 0x35, 0x28, 0x70, 0x77}; + uint8_t bytesprops0[] = {0x1c, 0xfd, 0xc4, 0x0, 0xe0, 0x5f, 0x58, 0x5a, + 0x6c, 0x8c, 0xa3, 0x46, 0x8f, 0x2c, 0xc1, 0x58}; + uint8_t bytesprops1[] = {0x39, 0x39}; + uint8_t bytesprops2[] = {0xa9, 0xa9, 0xbe, 0xbb, 0x7c, 0xc5, 0x10, 0xc6}; + uint8_t bytesprops3[] = {0x33, 0x5f, 0x3e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4921}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops3}, .v = {0, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13915}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25559}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13397}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7107}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23581}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops8}, .v = {8, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16882}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14604}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 12}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7431}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11166, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12644, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9472 [("\243\DC2\199A\218\167\CAN\SYN\220w\165\160\NAK",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\247\192Pw\199\196)T\SI\142wV\188!\138\241[\171",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("]\205\240x6\SI\137\238\166K\152\156\181ri\NUL\224\130^\f\190\132\156\170\149\199U\142n",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropSharedSubscriptionAvailable 99,PropReceiveMaximum 18943,PropRetainAvailable 72,PropRetainAvailable -// 59,PropSharedSubscriptionAvailable 37,PropPayloadFormatIndicator 14] +// SubscribeRequest 4944 [("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("_k\r\DC2\f\SI\228\155\183\&2\NAK\NULR\a]\202\235\149",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("*>\177\186\&0]\214*\191\206q\"\231\248\230\193\194E\183\238!\241+\233\222,\198t\234\150",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("mP\215\162\&0:<\157\150\b\240m\ETX\235\218\SOH\255I\168\&5I\145\134^\EM",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropServerKeepAlive +// 3031,PropTopicAlias 6809,PropWildcardSubscriptionAvailable 52,PropSubscriptionIdentifierAvailable +// 30,PropCorrelationData "n\167*\135\166\SOq\209\STX\EOT\221\NAK\160}'\179\ACK2M\179\US5\225\EMw",PropTopicAlias +// 10360,PropTopicAlias 21111,PropSubscriptionIdentifierAvailable 32,PropWillDelayInterval 537,PropTopicAlias +// 5672,PropContentType "\192\182\164\143X\175\218x",PropMessageExpiryInterval 6031,PropPayloadFormatIndicator +// 210,PropContentType "ih\217C\146U",PropReasonString +// "\223\129\163\176\232\&5+z\DC4\225\"\162*M",PropMessageExpiryInterval 28586,PropServerKeepAlive 20076,PropContentType +// ")\US\157\149\DC2\DC3\242\251L%\143\167U\220\212)c\216\SO"] TEST(Subscribe5QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0x55, 0x25, 0x0, 0xd, 0x2a, 0x63, 0x21, 0x49, 0xff, 0x25, 0x48, 0x25, 0x3b, 0x2a, - 0x25, 0x1, 0xe, 0x0, 0xd, 0xf3, 0x12, 0xc7, 0x41, 0xda, 0xa7, 0x18, 0x16, 0xdc, 0x77, - 0xa5, 0xa0, 0x15, 0x2, 0x0, 0x12, 0xf7, 0xc0, 0x50, 0x77, 0xc7, 0xc4, 0x29, 0x54, 0xf, - 0x8e, 0x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xf, 0xe4, 0x9b, 0xb7, 0x32, 0x15, 0x0, 0x52, + 0x7, 0x5d, 0xca, 0xeb, 0x95, 0x2e, 0x0, 0x1e, 0x2a, 0x3e, 0xb1, 0xba, 0x30, 0x5d, 0xd6, 0x2a, 0xbf, + 0xce, 0x71, 0x22, 0xe7, 0xf8, 0xe6, 0xc1, 0xc2, 0x45, 0xb7, 0xee, 0x21, 0xf1, 0x2b, 0xe9, 0xde, 0x2c, + 0xc6, 0x74, 0xea, 0x96, 0x5, 0x0, 0x19, 0x6d, 0x50, 0xd7, 0xa2, 0x30, 0x3a, 0x3c, 0x9d, 0x96, 0x8, + 0xf0, 0x6d, 0x3, 0xeb, 0xda, 0x1, 0xff, 0x49, 0xa8, 0x35, 0x49, 0x91, 0x86, 0x5e, 0x19, 0x29}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xf3, 0x12, 0xc7, 0x41, 0xda, 0xa7, 0x18, 0x16, 0xdc, 0x77, 0xa5, 0xa0, 0x15}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf7, 0xc0, 0x50, 0x77, 0xc7, 0xc4, 0x29, 0x54, 0xf, - 0x8e, 0x77, 0x56, 0xbc, 0x21, 0x8a, 0xf1, 0x5b, 0xab}; + uint8_t topic_filter_s1_bytes[] = {0x5f, 0x6b, 0xd, 0x12, 0xc, 0xf, 0xe4, 0x9b, 0xb7, + 0x32, 0x15, 0x0, 0x52, 0x7, 0x5d, 0xca, 0xeb, 0x95}; lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5d, 0xcd, 0xf0, 0x78, 0x36, 0xf, 0x89, 0xee, 0xa6, 0x4b, - 0x98, 0x9c, 0xb5, 0x72, 0x69, 0x0, 0xe0, 0x82, 0x5e, 0xc, - 0xbe, 0x84, 0x9c, 0xaa, 0x95, 0xc7, 0x55, 0x8e, 0x6e}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2a, 0x3e, 0xb1, 0xba, 0x30, 0x5d, 0xd6, 0x2a, 0xbf, 0xce, + 0x71, 0x22, 0xe7, 0xf8, 0xe6, 0xc1, 0xc2, 0x45, 0xb7, 0xee, + 0x21, 0xf1, 0x2b, 0xe9, 0xde, 0x2c, 0xc6, 0x74, 0xea, 0x96}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; + uint8_t topic_filter_s3_bytes[] = {0x6d, 0x50, 0xd7, 0xa2, 0x30, 0x3a, 0x3c, 0x9d, 0x96, 0x8, 0xf0, 0x6d, 0x3, + 0xeb, 0xda, 0x1, 0xff, 0x49, 0xa8, 0x35, 0x49, 0x91, 0x86, 0x5e, 0x19}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + uint8_t bytesprops0[] = {0x6e, 0xa7, 0x2a, 0x87, 0xa6, 0xe, 0x71, 0xd1, 0x2, 0x4, 0xdd, 0x15, 0xa0, + 0x7d, 0x27, 0xb3, 0x6, 0x32, 0x4d, 0xb3, 0x1f, 0x35, 0xe1, 0x19, 0x77}; + uint8_t bytesprops1[] = {0xc0, 0xb6, 0xa4, 0x8f, 0x58, 0xaf, 0xda, 0x78}; + uint8_t bytesprops2[] = {0x69, 0x68, 0xd9, 0x43, 0x92, 0x55}; + uint8_t bytesprops3[] = {0xdf, 0x81, 0xa3, 0xb0, 0xe8, 0x35, 0x2b, 0x7a, 0x14, 0xe1, 0x22, 0xa2, 0x2a, 0x4d}; + uint8_t bytesprops4[] = {0x29, 0x1f, 0x9d, 0x95, 0x12, 0x13, 0xf2, 0xfb, 0x4c, 0x25, + 0x8f, 0xa7, 0x55, 0xdc, 0xd4, 0x29, 0x63, 0xd8, 0xe}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18943}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 72}}, {.prop = (lwmqtt_prop_t)37, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 37}}, {.prop = (lwmqtt_prop_t)1, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3031}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6809}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10360}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21111}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 537}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5672}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6031}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28586}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20076}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9472, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4944, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18189 [("\142\SUB\241ET\151\232",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("t\160\t\216\&0\193Dg",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\218\225\n\t_\\\243\201\136\236\156E\172\217C\208\EOTn\147\225\145",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\167NE\EOT\132/\SIWTa\223|'\178]?\227\170O",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\208\238\156.\186\253",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\227\238\151ou]\230\234\ETB\aQ\170\218",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished -// = True, _noLocal = True, _subQoS = QoS2}),("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = True, _noLocal = True, _subQoS = QoS1}),("\249\a\164!\177YC\194\&0\183f\212\212Y\NAK\EOT\178\179",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("[",SubOptions +// SubscribeRequest 10380 [("x#\177~\235\205^\211e\221\198\US_r6\166_\SUB\220\237ILW\169\182V\129",SubOptions // {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\CANk+w\218\153\151\DEL\179U\STXl\DC2\SUBE\251\241\208",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\132B\f\206\169",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropPayloadFormatIndicator -// 202,PropMaximumPacketSize 29573,PropWillDelayInterval 21956,PropServerKeepAlive 15460,PropSubscriptionIdentifier -// 21,PropMessageExpiryInterval 4729,PropSubscriptionIdentifierAvailable 188,PropMessageExpiryInterval -// 19861,PropReceiveMaximum 28358,PropPayloadFormatIndicator 237,PropCorrelationData "\203",PropResponseInformation -// "\182@\161\SUB\vT\157f4|\253 \197\230\SYN\NUL\205\165\199\134E\129n0",PropRequestProblemInformation -// 104,PropReasonString -// "\146\191\144\196\DC1\151\178\173\173!\192\213\f\252\&5\142\EOTL\243\152\231\181\250\161\SOna\135\159",PropResponseTopic -// "\228\212\161\SI\254\252\172\209o\"8\151",PropContentType -// "\199i\162\&9\226\ETB\252\231\254`\230\213\194\211b\212\207,\165\&5p\162C0j>\ETX\SYN",PropSharedSubscriptionAvailable -// 68,PropMaximumPacketSize 10716,PropMessageExpiryInterval 10250,PropSubscriptionIdentifier 7,PropMaximumPacketSize -// 2136,PropResponseTopic "\194\171?\150TB"] +// QoS2}),("fv\DC4W\179\ETB\232\n\203",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS2}),("\183Q\224\149\199H$\NAK\183\GS\164\130\219 $B\130J\247\250\205V\218",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("w\NAK{\230=\DC2\213",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = +// True, _subQoS = QoS2}),(".\240\210\165\146h\199\217\159k\147\SO.\155\246\245\233\STX\229P\168\196",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\226I\SYN\248",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = +// True, _subQoS = QoS0}),("\150\230\233s",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS2}),("\133\135\180\EM",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("_D5",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("gN\213\255\202\196Gnm\180\&4\184Y\219kI\b\140\223\178\DC1u\248\215\132",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\209\EOT\FS\r\251\165\SO{I\218G\179\214\176\184\150\153\160\235\&0\226\aN",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropServerReference +// "\215F\133\CAN\255\253\132Oss\184>\176@s\156[\209\228\161h\251\235\GSkD",PropTopicAliasMaximum +// 20089,PropSubscriptionIdentifierAvailable 66,PropResponseInformation "#v5\132\197\129",PropResponseInformation +// "\228!3\192\&9\176,\162<\DELXm\203]+\246\205\164\156\180b9\208",PropRetainAvailable 206,PropContentType +// "\236`\219\207\149\219\223\210\FS-\FS\217:\SYN\164\157\&9@\220",PropContentType +// "c\196\&2<,JT\193W\221N\a",PropContentType "\236\248q\fZ3\153\&1\211\&7",PropSubscriptionIdentifierAvailable +// 6,PropTopicAliasMaximum 31885,PropCorrelationData +// "\SI\ETBX\132\212\230\140\163\183rr\SOHMy\212\141\250ZZ\172\241\189\154\&1f\"\141k",PropTopicAlias 2659] TEST(Subscribe5QCTest, Encode30) { uint8_t pkt[] = { - 0x82, 0xc6, 0x2, 0x47, 0xd, 0xad, 0x1, 0x1, 0xca, 0x27, 0x0, 0x0, 0x73, 0x85, 0x18, 0x0, 0x0, 0x55, 0xc4, - 0x13, 0x3c, 0x64, 0xb, 0x15, 0x2, 0x0, 0x0, 0x12, 0x79, 0x29, 0xbc, 0x2, 0x0, 0x0, 0x4d, 0x95, 0x21, 0x6e, - 0xc6, 0x1, 0xed, 0x9, 0x0, 0x1, 0xcb, 0x1a, 0x0, 0x18, 0xb6, 0x40, 0xa1, 0x1a, 0xb, 0x54, 0x9d, 0x66, 0x34, - 0x7c, 0xfd, 0x20, 0xc5, 0xe6, 0x16, 0x0, 0xcd, 0xa5, 0xc7, 0x86, 0x45, 0x81, 0x6e, 0x30, 0x17, 0x68, 0x1f, 0x0, - 0x1d, 0x92, 0xbf, 0x90, 0xc4, 0x11, 0x97, 0xb2, 0xad,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x6b, 0x49, 0x8, 0x8c, 0xdf, 0xb2, 0x11, 0x75, 0xf8, 0xd7, + 0x84, 0x8, 0x0, 0x17, 0xd1, 0x4, 0x1c, 0xd, 0xfb, 0xa5, 0xe, 0x7b, 0x49, 0xda, 0x47, 0xb3, 0xd6, 0xb0, 0xb8, + 0x96, 0x99, 0xa0, 0xeb, 0x30, 0xe2, 0x7, 0x4e, 0x22}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x8e, 0x1a, 0xf1, 0x45, 0x54, 0x97, 0xe8}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x78, 0x23, 0xb1, 0x7e, 0xeb, 0xcd, 0x5e, 0xd3, 0x65, 0xdd, 0xc6, 0x1f, 0x5f, 0x72, + 0x36, 0xa6, 0x5f, 0x1a, 0xdc, 0xed, 0x49, 0x4c, 0x57, 0xa9, 0xb6, 0x56, 0x81}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x74, 0xa0, 0x9, 0xd8, 0x30, 0xc1, 0x44, 0x67}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x66, 0x76, 0x14, 0x57, 0xb3, 0x17, 0xe8, 0xa, 0xcb}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xda, 0xe1, 0xa, 0x9, 0x5f, 0x5c, 0xf3, 0xc9, 0x88, 0xec, 0x9c, - 0x45, 0xac, 0xd9, 0x43, 0xd0, 0x4, 0x6e, 0x93, 0xe1, 0x91}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb7, 0x51, 0xe0, 0x95, 0xc7, 0x48, 0x24, 0x15, 0xb7, 0x1d, 0xa4, 0x82, + 0xdb, 0x20, 0x24, 0x42, 0x82, 0x4a, 0xf7, 0xfa, 0xcd, 0x56, 0xda}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa7, 0x4e, 0x45, 0x4, 0x84, 0x2f, 0xf, 0x57, 0x54, 0x61, - 0xdf, 0x7c, 0x27, 0xb2, 0x5d, 0x3f, 0xe3, 0xaa, 0x4f}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x77, 0x15, 0x7b, 0xe6, 0x3d, 0x12, 0xd5}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd0, 0xee, 0x9c, 0x2e, 0xba, 0xfd}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2e, 0xf0, 0xd2, 0xa5, 0x92, 0x68, 0xc7, 0xd9, 0x9f, 0x6b, 0x93, + 0xe, 0x2e, 0x9b, 0xf6, 0xf5, 0xe9, 0x2, 0xe5, 0x50, 0xa8, 0xc4}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe3, 0xee, 0x97, 0x6f, 0x75, 0x5d, 0xe6, 0xea, 0x17, 0x7, 0x51, 0xaa, 0xda}; - lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe2, 0x49, 0x16, 0xf8}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x96, 0xe6, 0xe9, 0x73}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf9, 0x7, 0xa4, 0x21, 0xb1, 0x59, 0x43, 0xc2, 0x30, - 0xb7, 0x66, 0xd4, 0xd4, 0x59, 0x15, 0x4, 0xb2, 0xb3}; - lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x85, 0x87, 0xb4, 0x19}; + lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x5b}; - lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x5f, 0x44, 0x35}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x18, 0x6b, 0x2b, 0x77, 0xda, 0x99, 0x97, 0x7f, 0xb3, - 0x55, 0x2, 0x6c, 0x12, 0x1a, 0x45, 0xfb, 0xf1, 0xd0}; - lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0x67, 0x4e, 0xd5, 0xff, 0xca, 0xc4, 0x47, 0x6e, 0x6d, 0xb4, 0x34, 0xb8, 0x59, + 0xdb, 0x6b, 0x49, 0x8, 0x8c, 0xdf, 0xb2, 0x11, 0x75, 0xf8, 0xd7, 0x84}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x84, 0x42, 0xc, 0xce, 0xa9}; - lwmqtt_string_t topic_filter_s10 = {5, (char*)&topic_filter_s10_bytes}; + uint8_t topic_filter_s10_bytes[] = {0xd1, 0x4, 0x1c, 0xd, 0xfb, 0xa5, 0xe, 0x7b, 0x49, 0xda, 0x47, 0xb3, + 0xd6, 0xb0, 0xb8, 0x96, 0x99, 0xa0, 0xeb, 0x30, 0xe2, 0x7, 0x4e}; + lwmqtt_string_t topic_filter_s10 = {23, (char*)&topic_filter_s10_bytes}; topic_filters[10] = topic_filter_s10; lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = false; sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = true; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].qos = LWMQTT_QOS2; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = false; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = true; sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[10].retain_as_published = true; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; sub_opts[10].no_local = false; - uint8_t bytesprops0[] = {0xcb}; - uint8_t bytesprops1[] = {0xb6, 0x40, 0xa1, 0x1a, 0xb, 0x54, 0x9d, 0x66, 0x34, 0x7c, 0xfd, 0x20, - 0xc5, 0xe6, 0x16, 0x0, 0xcd, 0xa5, 0xc7, 0x86, 0x45, 0x81, 0x6e, 0x30}; - uint8_t bytesprops2[] = {0x92, 0xbf, 0x90, 0xc4, 0x11, 0x97, 0xb2, 0xad, 0xad, 0x21, 0xc0, 0xd5, 0xc, 0xfc, 0x35, - 0x8e, 0x4, 0x4c, 0xf3, 0x98, 0xe7, 0xb5, 0xfa, 0xa1, 0xe, 0x6e, 0x61, 0x87, 0x9f}; - uint8_t bytesprops3[] = {0xe4, 0xd4, 0xa1, 0xf, 0xfe, 0xfc, 0xac, 0xd1, 0x6f, 0x22, 0x38, 0x97}; - uint8_t bytesprops4[] = {0xc7, 0x69, 0xa2, 0x39, 0xe2, 0x17, 0xfc, 0xe7, 0xfe, 0x60, 0xe6, 0xd5, 0xc2, 0xd3, - 0x62, 0xd4, 0xcf, 0x2c, 0xa5, 0x35, 0x70, 0xa2, 0x43, 0x30, 0x6a, 0x3e, 0x3, 0x16}; - uint8_t bytesprops5[] = {0xc2, 0xab, 0x3f, 0x96, 0x54, 0x42}; + uint8_t bytesprops0[] = {0xd7, 0x46, 0x85, 0x18, 0xff, 0xfd, 0x84, 0x4f, 0x73, 0x73, 0xb8, 0x3e, 0xb0, + 0x40, 0x73, 0x9c, 0x5b, 0xd1, 0xe4, 0xa1, 0x68, 0xfb, 0xeb, 0x1d, 0x6b, 0x44}; + uint8_t bytesprops1[] = {0x23, 0x76, 0x35, 0x84, 0xc5, 0x81}; + uint8_t bytesprops2[] = {0xe4, 0x21, 0x33, 0xc0, 0x39, 0xb0, 0x2c, 0xa2, 0x3c, 0x7f, 0x58, 0x6d, + 0xcb, 0x5d, 0x2b, 0xf6, 0xcd, 0xa4, 0x9c, 0xb4, 0x62, 0x39, 0xd0}; + uint8_t bytesprops3[] = {0xec, 0x60, 0xdb, 0xcf, 0x95, 0xdb, 0xdf, 0xd2, 0x1c, 0x2d, + 0x1c, 0xd9, 0x3a, 0x16, 0xa4, 0x9d, 0x39, 0x40, 0xdc}; + uint8_t bytesprops4[] = {0x63, 0xc4, 0x32, 0x3c, 0x2c, 0x4a, 0x54, 0xc1, 0x57, 0xdd, 0x4e, 0x7}; + uint8_t bytesprops5[] = {0xec, 0xf8, 0x71, 0xc, 0x5a, 0x33, 0x99, 0x31, 0xd3, 0x37}; + uint8_t bytesprops6[] = {0xf, 0x17, 0x58, 0x84, 0xd4, 0xe6, 0x8c, 0xa3, 0xb7, 0x72, 0x72, 0x1, 0x4d, 0x79, + 0xd4, 0x8d, 0xfa, 0x5a, 0x5a, 0xac, 0xf1, 0xbd, 0x9a, 0x31, 0x66, 0x22, 0x8d, 0x6b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29573}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21956}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15460}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 21}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4729}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19861}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28358}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10716}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10250}}, - {.prop = (lwmqtt_prop_t)11, .value = {.varint = 7}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2136}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20089}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31885}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2659}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18189, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10380, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeResponse 30748 [Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Right QoS0,Right QoS1,Right -// QoS1,Left SubErrNotAuthorized,Left SubErrNotAuthorized,Left SubErrNotAuthorized] [] +// SubscribeResponse 18259 [Right QoS0,Left SubErrNotAuthorized,Left SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode1) { - uint8_t pkt[] = {0x90, 0xb, 0x78, 0x1c, 0x1, 0x1, 0x83, 0x0, 0x1, 0x1, 0x87, 0x87, 0x87}; + uint8_t pkt[] = {0x90, 0x5, 0x47, 0x53, 0x0, 0x87, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 30748); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 18259); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); } -// SubscribeResponse 11486 [Right QoS1,Right QoS1,Right QoS1,Left SubErrNotAuthorized] [] +// SubscribeResponse 23769 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Right QoS1,Left +// SubErrUnspecifiedError,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode2) { - uint8_t pkt[] = {0x90, 0x6, 0x2c, 0xde, 0x1, 0x1, 0x1, 0x87}; + uint8_t pkt[] = {0x90, 0x8, 0x5c, 0xd9, 0xa1, 0x0, 0x1, 0x80, 0x1, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11486); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 23769); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); } -// SubscribeResponse 31056 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS0,Right -// QoS0,Right QoS1] [] +// SubscribeResponse 32439 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS2] [] TEST(SubACK311QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0x9, 0x79, 0x50, 0x87, 0x80, 0x2, 0x0, 0x0, 0x0, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 31056); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); -} - -// SubscribeResponse 7634 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS1] [] -TEST(SubACK311QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0x5, 0x1d, 0xd2, 0xa1, 0x2, 0x1}; + uint8_t pkt[] = {0x90, 0x5, 0x7e, 0xb7, 0xa1, 0x1, 0x2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[3]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7634); + EXPECT_EQ(packet_id, 32439); EXPECT_EQ(count, 3); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); } -// SubscribeResponse 17449 [Left SubErrUnspecifiedError,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Left -// SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right -// QoS2,Right QoS1] [] -TEST(SubACK311QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0xb, 0x44, 0x29, 0x80, 0x97, 0x80, 0x80, 0x91, 0x0, 0xa2, 0x2, 0x1}; +// SubscribeResponse 4983 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Right +// QoS2,Right QoS2,Right QoS1] [] +TEST(SubACK311QCTest, Decode4) { + uint8_t pkt[] = {0x90, 0xb, 0x13, 0x77, 0x9e, 0x97, 0xa1, 0x2, 0x0, 0xa1, 0x2, 0x2, 0x1}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[9]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17449); + EXPECT_EQ(packet_id, 4983); EXPECT_EQ(count, 9); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); } -// SubscribeResponse 27369 [Left SubErrImplementationSpecificError,Right QoS1,Right QoS0,Left -// SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS0,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Left -// SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported] [] -TEST(SubACK311QCTest, Decode6) { - uint8_t pkt[] = {0x90, 0xd, 0x6a, 0xe9, 0x83, 0x1, 0x0, 0x80, 0x2, 0x0, 0x0, 0x80, 0x87, 0x8f, 0xa1}; +// SubscribeResponse 13883 [Right QoS0,Left SubErrPacketIdentifierInUse,Left SubErrPacketIdentifierInUse,Right +// QoS0,Right QoS0,Left SubErrUnspecifiedError,Right QoS0] [] +TEST(SubACK311QCTest, Decode5) { + uint8_t pkt[] = {0x90, 0x9, 0x36, 0x3b, 0x0, 0x91, 0x91, 0x0, 0x0, 0x80, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27369); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 13883); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x80); EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], 0x80); - EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 9981 [Right QoS2,Right QoS1,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Right -// QoS2,Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Left SubErrUnspecifiedError] [] +// SubscribeResponse 7030 [Right QoS0] [] +TEST(SubACK311QCTest, Decode6) { + uint8_t pkt[] = {0x90, 0x3, 0x1b, 0x76, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7030); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +} + +// SubscribeResponse 27738 [Right QoS0,Right QoS2] [] TEST(SubACK311QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0xa, 0x26, 0xfd, 0x2, 0x1, 0x80, 0x91, 0x2, 0x83, 0x80, 0x80}; + uint8_t pkt[] = {0x90, 0x4, 0x6c, 0x5a, 0x0, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9981); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(packet_id, 27738); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); } -// SubscribeResponse 25704 [Right QoS1,Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError] [] +// SubscribeResponse 4324 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS0,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrSharedSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode8) { - uint8_t pkt[] = {0x90, 0x5, 0x64, 0x68, 0x1, 0x83, 0x80}; + uint8_t pkt[] = {0x90, 0x9, 0x10, 0xe4, 0x9e, 0x0, 0x0, 0x0, 0x9e, 0xa2, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25704); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(packet_id, 4324); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); } -// SubscribeResponse 27290 [Right QoS0,Right QoS1,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrPacketIdentifierInUse,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS2] [] +// SubscribeResponse 11281 [Left SubErrImplementationSpecificError,Right QoS1,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded] [] TEST(SubACK311QCTest, Decode9) { - uint8_t pkt[] = {0x90, 0xa, 0x6a, 0x9a, 0x0, 0x1, 0x1, 0x9e, 0x91, 0x1, 0x91, 0x2}; + uint8_t pkt[] = {0x90, 0x6, 0x2c, 0x11, 0x83, 0x1, 0xa1, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27290); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 11281); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); } -// SubscribeResponse 26187 [Left SubErrImplementationSpecificError,Right QoS1,Left SubErrImplementationSpecificError] [] +// SubscribeResponse 462 [Right QoS2,Right QoS2] [] TEST(SubACK311QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0x5, 0x66, 0x4b, 0x83, 0x1, 0x83}; + uint8_t pkt[] = {0x90, 0x4, 0x1, 0xce, 0x2, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26187); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(packet_id, 462); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); } -// SubscribeResponse 26384 [Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Right QoS1,Left -// SubErrNotAuthorized,Right QoS0,Right QoS1,Left SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS2] [] +// SubscribeResponse 28404 [Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Left +// SubErrSubscriptionIdentifiersNotSupported] [] TEST(SubACK311QCTest, Decode11) { - uint8_t pkt[] = {0x90, 0xd, 0x67, 0x10, 0x80, 0x80, 0x1, 0x87, 0x0, 0x1, 0x83, 0x97, 0xa1, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0x5, 0x6e, 0xf4, 0x8f, 0x83, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26384); - EXPECT_EQ(count, 11); + EXPECT_EQ(packet_id, 28404); + EXPECT_EQ(count, 3); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); } -// SubscribeResponse 24874 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrImplementationSpecificError,Right QoS1,Right QoS2] [] +// SubscribeResponse 12402 [Right QoS0] [] TEST(SubACK311QCTest, Decode12) { - uint8_t pkt[] = {0x90, 0x7, 0x61, 0x2a, 0x2, 0x9e, 0x83, 0x1, 0x2}; + uint8_t pkt[] = {0x90, 0x3, 0x30, 0x72, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24874); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 12402); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); } -// SubscribeResponse 25167 [Left SubErrQuotaExceeded] [] +// SubscribeResponse 4531 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS1,Right QoS0,Right +// QoS1,Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrNotAuthorized,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [] TEST(SubACK311QCTest, Decode13) { - uint8_t pkt[] = {0x90, 0x3, 0x62, 0x4f, 0x97}; + uint8_t pkt[] = {0x90, 0xc, 0x11, 0xb3, 0xa1, 0x2, 0x1, 0x0, 0x1, 0x91, 0x2, 0x87, 0xa1, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25167); - EXPECT_EQ(count, 1); + EXPECT_EQ(packet_id, 4531); + EXPECT_EQ(count, 10); EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); } -// SubscribeResponse 7252 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left SubErrUnspecifiedError,Right -// QoS2,Right QoS1,Right QoS2,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0] [] +// SubscribeResponse 28870 [Right QoS2,Right QoS0,Left SubErrPacketIdentifierInUse,Right QoS1] [] TEST(SubACK311QCTest, Decode14) { - uint8_t pkt[] = {0x90, 0xb, 0x1c, 0x54, 0xa2, 0x0, 0x80, 0x2, 0x1, 0x2, 0x0, 0xa1, 0x0}; + uint8_t pkt[] = {0x90, 0x6, 0x70, 0xc6, 0x2, 0x0, 0x91, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7252); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(packet_id, 28870); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); } -// SubscribeResponse 22592 [Left SubErrUnspecifiedError,Right QoS2,Right QoS0,Left -// SubErrSubscriptionIdentifiersNotSupported,Left SubErrPacketIdentifierInUse] [] +// SubscribeResponse 1085 [Right QoS0,Right QoS0,Left SubErrImplementationSpecificError,Left +// SubErrSubscriptionIdentifiersNotSupported] [] TEST(SubACK311QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0x7, 0x58, 0x40, 0x80, 0x2, 0x0, 0xa1, 0x91}; + uint8_t pkt[] = {0x90, 0x6, 0x4, 0x3d, 0x0, 0x0, 0x83, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 22592); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 1085); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); } -// SubscribeResponse 1930 [Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right QoS2,Left SubErrQuotaExceeded,Right QoS1,Left -// SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Left SubErrTopicFilterInvalid,Left -// SubErrTopicFilterInvalid,Left SubErrUnspecifiedError] [] +// SubscribeResponse 11089 [Right QoS1] [] TEST(SubACK311QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0xd, 0x7, 0x8a, 0xa2, 0xa2, 0x0, 0x2, 0x97, 0x1, 0xa1, 0x8f, 0x8f, 0x8f, 0x80}; + uint8_t pkt[] = {0x90, 0x3, 0x2b, 0x51, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1930); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], 0x80); - EXPECT_EQ(granted_qos_levels[10], 0x80); + EXPECT_EQ(packet_id, 11089); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); } -// SubscribeResponse 32288 [Right QoS1,Right QoS0,Right QoS1,Right QoS2,Left SubErrImplementationSpecificError,Right -// QoS1,Left SubErrQuotaExceeded,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrUnspecifiedError] [] +// SubscribeResponse 4816 [Left SubErrQuotaExceeded,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right +// QoS0,Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right QoS1,Left SubErrNotAuthorized,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0xd, 0x7e, 0x20, 0x1, 0x0, 0x1, 0x2, 0x83, 0x1, 0x97, 0x1, 0x91, 0x2, 0x80}; + uint8_t pkt[] = {0x90, 0xd, 0x12, 0xd0, 0x97, 0xa2, 0x2, 0x0, 0x1, 0x0, 0x87, 0x1, 0x87, 0x9e, 0xa2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[11]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32288); + EXPECT_EQ(packet_id, 4816); EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[6], 0x80); EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], 0x80); EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 8665 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left -// SubErrQuotaExceeded,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS2,Right QoS2] [] +// SubscribeResponse 24891 [Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1,Right QoS2,Left +// SubErrTopicFilterInvalid,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [] TEST(SubACK311QCTest, Decode18) { - uint8_t pkt[] = {0x90, 0x9, 0x21, 0xd9, 0x9e, 0x80, 0x97, 0x2, 0x8f, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0xb, 0x61, 0x3b, 0x80, 0x91, 0x9e, 0xa2, 0x1, 0x2, 0x8f, 0x1, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8665); - EXPECT_EQ(count, 7); + EXPECT_EQ(packet_id, 24891); + EXPECT_EQ(count, 9); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], 0x80); } -// SubscribeResponse 32158 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left -// SubErrWildcardSubscriptionsNotSupported] [] +// SubscribeResponse 22923 [Right QoS2,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS1] [] TEST(SubACK311QCTest, Decode19) { - uint8_t pkt[] = {0x90, 0x5, 0x7d, 0x9e, 0xa2, 0x0, 0xa2}; + uint8_t pkt[] = {0x90, 0xb, 0x59, 0x8b, 0x2, 0x1, 0xa1, 0x0, 0xa2, 0x2, 0x2, 0x8f, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32158); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 22923); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); } -// SubscribeResponse 9271 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS2,Right QoS0,Left -// SubErrQuotaExceeded,Right QoS0,Right QoS2] [] +// SubscribeResponse 25337 [Right QoS2,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS1,Right QoS2,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode20) { - uint8_t pkt[] = {0x90, 0x9, 0x24, 0x37, 0xa1, 0x1, 0x2, 0x0, 0x97, 0x0, 0x2}; + uint8_t pkt[] = {0x90, 0x9, 0x62, 0xf9, 0x2, 0x1, 0x8f, 0x1, 0x2, 0x0, 0x9e}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[7]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9271); + EXPECT_EQ(packet_id, 25337); EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); } -// SubscribeResponse 4115 [Left SubErrUnspecifiedError,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrNotAuthorized,Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError] [] +// SubscribeResponse 1262 [Left SubErrPacketIdentifierInUse,Right QoS0,Left SubErrPacketIdentifierInUse,Left +// SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Right QoS0,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrNotAuthorized,Right QoS2] [] TEST(SubACK311QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0x7, 0x10, 0x13, 0x80, 0x9e, 0x87, 0x9e, 0x80}; + uint8_t pkt[] = {0x90, 0xc, 0x4, 0xee, 0x91, 0x0, 0x91, 0x83, 0x83, 0x0, 0x0, 0x9e, 0x87, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4115); - EXPECT_EQ(count, 5); + EXPECT_EQ(packet_id, 1262); + EXPECT_EQ(count, 10); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); } -// SubscribeResponse 24961 [Right QoS2,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Left SubErrTopicFilterInvalid,Left -// SubErrQuotaExceeded,Right QoS0,Left SubErrQuotaExceeded,Right QoS2,Right QoS0] [] +// SubscribeResponse 21462 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right +// QoS1,Right QoS2,Right QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrTopicFilterInvalid,Left +// SubErrImplementationSpecificError,Right QoS2,Left SubErrNotAuthorized] [] TEST(SubACK311QCTest, Decode22) { - uint8_t pkt[] = {0x90, 0xc, 0x61, 0x81, 0x2, 0x0, 0x97, 0x0, 0x8f, 0x97, 0x0, 0x97, 0x2, 0x0}; + uint8_t pkt[] = {0x90, 0xd, 0x53, 0xd6, 0x2, 0xa2, 0x97, 0x1, 0x2, 0x0, 0x9e, 0x8f, 0x83, 0x2, 0x87}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24961); - EXPECT_EQ(count, 10); + EXPECT_EQ(packet_id, 21462); + EXPECT_EQ(count, 11); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x80); EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 18340 [Right QoS2,Left SubErrTopicFilterInvalid,Right QoS1,Left SubErrImplementationSpecificError] -// [] +// SubscribeResponse 12076 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrImplementationSpecificError,Right +// QoS2,Right QoS0,Right QoS2] [] TEST(SubACK311QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0x6, 0x47, 0xa4, 0x2, 0x8f, 0x1, 0x83}; + uint8_t pkt[] = {0x90, 0x7, 0x2f, 0x2c, 0xa1, 0x83, 0x2, 0x0, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18340); - EXPECT_EQ(count, 4); + EXPECT_EQ(packet_id, 12076); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); +} + +// SubscribeResponse 3799 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrImplementationSpecificError,Left SubErrTopicFilterInvalid,Right QoS2,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS0] [] +TEST(SubACK311QCTest, Decode24) { + uint8_t pkt[] = {0x90, 0xa, 0xe, 0xd7, 0x2, 0xa2, 0x83, 0x8f, 0x2, 0xa2, 0x2, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 3799); + EXPECT_EQ(count, 8); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); } -// SubscribeResponse 8517 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left -// SubErrSubscriptionIdentifiersNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS0] [] -TEST(SubACK311QCTest, Decode24) { - uint8_t pkt[] = {0x90, 0x8, 0x21, 0x45, 0x9e, 0x0, 0xa1, 0xa2, 0x2, 0x0}; +// SubscribeResponse 15314 [Left SubErrUnspecifiedError,Left SubErrTopicFilterInvalid,Left +// SubErrImplementationSpecificError] [] +TEST(SubACK311QCTest, Decode25) { + uint8_t pkt[] = {0x90, 0x5, 0x3b, 0xd2, 0x80, 0x8f, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8517); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 15314); + EXPECT_EQ(count, 3); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); } -// SubscribeResponse 31168 [Right QoS2,Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrNotAuthorized,Right QoS0,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left -// SubErrPacketIdentifierInUse,Left SubErrNotAuthorized] [] -TEST(SubACK311QCTest, Decode25) { - uint8_t pkt[] = {0x90, 0xb, 0x79, 0xc0, 0x2, 0x8f, 0xa1, 0x87, 0x0, 0x9e, 0x1, 0x91, 0x87}; +// SubscribeResponse 19515 [Left SubErrNotAuthorized,Right QoS1,Right QoS2,Left SubErrPacketIdentifierInUse,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Left SubErrUnspecifiedError,Left +// SubErrSubscriptionIdentifiersNotSupported] [] +TEST(SubACK311QCTest, Decode26) { + uint8_t pkt[] = {0x90, 0xb, 0x4c, 0x3b, 0x87, 0x1, 0x2, 0x91, 0x9e, 0x80, 0x0, 0x80, 0xa1}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[9]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 31168); + EXPECT_EQ(packet_id, 19515); EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[7], 0x80); EXPECT_EQ(granted_qos_levels[8], 0x80); } -// SubscribeResponse 6558 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left -// SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Right -// QoS1,Left SubErrTopicFilterInvalid] [] -TEST(SubACK311QCTest, Decode26) { - uint8_t pkt[] = {0x90, 0x9, 0x19, 0x9e, 0x9e, 0x0, 0x83, 0x83, 0x83, 0x1, 0x8f}; +// SubscribeResponse 14835 [Right QoS2,Right QoS2,Right QoS1,Left SubErrUnspecifiedError,Left +// SubErrImplementationSpecificError,Left SubErrNotAuthorized,Right QoS2] [] +TEST(SubACK311QCTest, Decode27) { + uint8_t pkt[] = {0x90, 0x9, 0x39, 0xf3, 0x2, 0x2, 0x1, 0x80, 0x83, 0x87, 0x2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[7]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6558); + EXPECT_EQ(packet_id, 14835); EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[3], 0x80); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); } -// SubscribeResponse 25528 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left -// SubErrUnspecifiedError,Left SubErrImplementationSpecificError,Right QoS2] [] -TEST(SubACK311QCTest, Decode27) { - uint8_t pkt[] = {0x90, 0x7, 0x63, 0xb8, 0x9e, 0x80, 0x80, 0x83, 0x2}; +// SubscribeResponse 3036 [Right QoS0,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError] [] +TEST(SubACK311QCTest, Decode28) { + uint8_t pkt[] = {0x90, 0x5, 0xb, 0xdc, 0x0, 0x87, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25528); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(packet_id, 3036); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); } -// SubscribeResponse 29497 [Right QoS2,Right QoS2,Right QoS2,Right QoS1,Right QoS2,Left SubErrPacketIdentifierInUse] [] -TEST(SubACK311QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0x8, 0x73, 0x39, 0x2, 0x2, 0x2, 0x1, 0x2, 0x91}; +// SubscribeResponse 8613 [Right QoS2] [] +TEST(SubACK311QCTest, Decode29) { + uint8_t pkt[] = {0x90, 0x3, 0x21, 0xa5, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29497); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 8613); + EXPECT_EQ(count, 1); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x80); } -// SubscribeResponse 9048 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS1,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS1,Right QoS2,Right QoS2,Left +// SubscribeResponse 14512 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right QoS1,Left // SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded] [] -TEST(SubACK311QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0xd, 0x23, 0x58, 0x87, 0x80, 0x87, 0x1, 0x9e, 0x1, 0x1, 0x2, 0x2, 0xa2, 0x97}; +TEST(SubACK311QCTest, Decode30) { + uint8_t pkt[] = {0x90, 0x7, 0x38, 0xb0, 0x9e, 0x91, 0x1, 0xa2, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9048); - EXPECT_EQ(count, 11); + EXPECT_EQ(packet_id, 14512); + EXPECT_EQ(count, 5); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], 0x80); - EXPECT_EQ(granted_qos_levels[10], 0x80); -} - -// SubscribeResponse 18118 [Right QoS1] [] -TEST(SubACK311QCTest, Decode30) { - uint8_t pkt[] = {0x90, 0x3, 0x46, 0xc6, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18118); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); } -// SubscribeResponse 30748 [Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Right QoS0,Right QoS1,Right -// QoS1,Left SubErrNotAuthorized,Left SubErrNotAuthorized,Left SubErrNotAuthorized] [PropAssignedClientIdentifier -// "",PropUserProperty "W\ESC\ACK\189t\NAK3\222" -// "\NUL\255\211{\199\176\144\GS\163\205\a>\178\NAK\r\NUL\134\207/\207\DEL\188\167\222\134\DEL",PropRetainAvailable -// 185,PropServerReference "x\233\186s\131\SI",PropRequestResponseInformation 88,PropRequestProblemInformation -// 231,PropSubscriptionIdentifier 26,PropMessageExpiryInterval 27266,PropResponseTopic -// "O$\158\ETX#\195x\SO\129\FS\249\189\178\STX\169\212;\202\154#\162\&7^,\193\201"] TEST(SubACK5QCTest, Decode2) { - uint8_t pkt[] = {0x90, 0x41, 0x2c, 0xde, 0x3a, 0x23, 0x9, 0x66, 0x3, 0x0, 0xd, 0x18, 0x50, 0x26, 0xab, 0x46, 0xfd, - 0x44, 0x8c, 0x8d, 0xce, 0x37, 0x88, 0x49, 0x1f, 0x0, 0x3, 0x7d, 0x30, 0x97, 0x28, 0x38, 0x25, 0x4b, - 0x16, 0x0, 0x15, 0xaf, 0x41, 0x17, 0x1c, 0x9a, 0xc4, 0x50, 0xb4, 0x15, 0xd5, 0x66, 0xe3, 0x4b, 0xb5, - 0x2e, 0x49, 0x9d, 0x82, 0x78, 0x5f, 0x97, 0xb, 0x12, 0x21, 0x53, 0xe0, 0x1, 0x1, 0x1, 0x87}; + uint8_t pkt[] = {0x90, 0x4c, 0x5c, 0xd9, 0x43, 0x21, 0x47, 0x63, 0x18, 0x0, 0x0, 0x51, 0xfe, 0x2, 0x0, 0x0, + 0x74, 0xb2, 0x1f, 0x0, 0x5, 0xbd, 0x6e, 0xe7, 0xa2, 0xf4, 0x25, 0x38, 0x2a, 0x73, 0x1c, 0x0, + 0xd, 0xa9, 0xcd, 0xad, 0x3f, 0x54, 0x41, 0x45, 0x40, 0xff, 0xa6, 0xd8, 0xce, 0x4f, 0x2, 0x0, + 0x0, 0x17, 0x4, 0x21, 0x3c, 0x30, 0x15, 0x0, 0xf, 0xbb, 0x25, 0xf5, 0xbf, 0x42, 0xc4, 0xbd, + 0x46, 0x3e, 0xa2, 0x37, 0x5e, 0x2c, 0xc1, 0xc9, 0xa1, 0x0, 0x1, 0x80, 0x1, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11486); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 23769); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x87); -} - -// SubscribeResponse 31056 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS0,Right -// QoS0,Right QoS1] [PropResponseTopic "\174F\192\SOH",PropRetainAvailable 191,PropTopicAliasMaximum -// 14314,PropSessionExpiryInterval 5431,PropResponseTopic "\NUL\136",PropWildcardSubscriptionAvailable -// 103,PropAuthenticationData "\151\237*\173\128\US\220\254\220G",PropAssignedClientIdentifier -// "\EOT\138\182Z\131p&\130\158",PropMaximumQoS 242,PropAuthenticationMethod -// "\134\253\169\198\187\233\&1\218\130;G\196\221T\NUL\166\204X\131\STX\b\150",PropReasonString -// "sEc=3N\227",PropResponseTopic -// "\217X(\255U\249\a\168\SI`\229\DC4|\232\147\ACK\195\213}\131\178\GS\166/u",PropMessageExpiryInterval -// 14554,PropSubscriptionIdentifier 15,PropSharedSubscriptionAvailable 101,PropMessageExpiryInterval 4159] + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0xA2); +} + +// SubscribeResponse 32439 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS2] +// [PropPayloadFormatIndicator 200,PropPayloadFormatIndicator 41,PropAuthenticationMethod +// "[D\143\DC2P\189\&2^",PropMessageExpiryInterval 11314,PropTopicAliasMaximum 29329,PropAssignedClientIdentifier +// "\GS\DEL\140\&8\140u\232\188\DC3u-1\ESC\200\181\NAK\a\246D\188%\242\191\179\189\175\209\210",PropSubscriptionIdentifier +// 13,PropServerReference "~l",PropAssignedClientIdentifier "\215\152\222\249Ru\193",PropRequestProblemInformation +// 22,PropTopicAlias 26497,PropMaximumQoS 118,PropMaximumPacketSize 16077,PropWillDelayInterval +// 31249,PropWillDelayInterval 29824,PropAuthenticationData "\237\236\224\DELvE\147!",PropContentType +// "^oe\164\131\243\246\164\162\203\218\229g\193\222h\f",PropServerReference "\169\141\240\189\167",PropServerReference +// "]%aq}\134a\176\192F\252\GS\CAN\236\176u\254\196",PropTopicAlias 10763,PropRequestResponseInformation 121] TEST(SubACK5QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0x8b, 0x1, 0x79, 0x50, 0x80, 0x1, 0x8, 0x0, 0x4, 0xae, 0x46, 0xc0, 0x1, 0x25, 0xbf, - 0x22, 0x37, 0xea, 0x11, 0x0, 0x0, 0x15, 0x37, 0x8, 0x0, 0x2, 0x0, 0x88, 0x28, 0x67, 0x16, - 0x0, 0xa, 0x97, 0xed, 0x2a, 0xad, 0x80, 0x1f, 0xdc, 0xfe, 0xdc, 0x47, 0x12, 0x0, 0x9, 0x4, - 0x8a, 0xb6, 0x5a, 0x83, 0x70, 0x26, 0x82, 0x9e, 0x24, 0xf2, 0x15, 0x0, 0x16, 0x86, 0xfd, 0xa9, - 0xc6, 0xbb, 0xe9, 0x31, 0xda, 0x82, 0x3b, 0x47, 0xc4, 0xdd, 0x54, 0x0, 0xa6, 0xcc, 0x58, 0x83, - 0x2, 0x8, 0x96, 0x1f, 0x0, 0x7, 0x73, 0x45, 0x63, 0x3d, 0x33, 0x4e, 0xe3, 0x8, 0x0, 0x19, - 0xd9, 0x58, 0x28, 0xff, 0x55, 0xf9, 0x7, 0xa8, 0xf, 0x60, 0xe5, 0x14, 0x7c, 0xe8, 0x93, 0x6, - 0xc3, 0xd5, 0x7d, 0x83, 0xb2, 0x1d, 0xa6, 0x2f, 0x75, 0x2, 0x0, 0x0, 0x38, 0xda, 0xb, 0xf, - 0x2a, 0x65, 0x2, 0x0, 0x0, 0x10, 0x3f, 0x87, 0x80, 0x2, 0x0, 0x0, 0x0, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 31056); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x87); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); -} - -// SubscribeResponse 7634 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS1] -// [PropWildcardSubscriptionAvailable 117,PropSessionExpiryInterval 19428,PropMaximumPacketSize 8971,PropMaximumQoS -// 43,PropRetainAvailable 125,PropMaximumPacketSize 11341,PropSharedSubscriptionAvailable 195,PropAuthenticationData -// "y\191)\242\\\STX\254\a\SI\GS'\159ak\230\140\164\162\130+\189\ESC",PropAssignedClientIdentifier -// "\254j\SUBjht\226\NUL\159-\145\203\151\RS\230\189Zo\174\254\141q\237\244",PropWildcardSubscriptionAvailable -// 152,PropMaximumQoS 35,PropTopicAliasMaximum 13672,PropSharedSubscriptionAvailable 216,PropAssignedClientIdentifier -// "\172\233",PropCorrelationData "\158\&1\t\137=]",PropSharedSubscriptionAvailable 150,PropMessageExpiryInterval -// 30357,PropReasonString "\188\"\207X\246\130\US\188R\253=\nQ\US\STX\132\169r",PropMaximumQoS 201,PropServerKeepAlive -// 8699,PropReasonString "\203\ENQ\145OC-2?\162\212",PropAuthenticationMethod -// "\221\156\SUB\142\236\138\128\nu\162\n\180\136j\229\228\&3",PropReceiveMaximum 9931] -TEST(SubACK5QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0xae, 0x1, 0x1d, 0xd2, 0xa7, 0x1, 0x28, 0x75, 0x11, 0x0, 0x0, 0x4b, 0xe4, 0x27, 0x0, 0x0, - 0x23, 0xb, 0x24, 0x2b, 0x25, 0x7d, 0x27, 0x0, 0x0, 0x2c, 0x4d, 0x2a, 0xc3, 0x16, 0x0, 0x16, 0x79, - 0xbf, 0x29, 0xf2, 0x5c, 0x2, 0xfe, 0x7, 0xf, 0x1d, 0x27, 0x9f, 0x61, 0x6b, 0xe6, 0x8c, 0xa4, 0xa2, - 0x82, 0x2b, 0xbd, 0x1b, 0x12, 0x0, 0x18, 0xfe, 0x6a, 0x1a, 0x6a, 0x68, 0x74, 0xe2, 0x0, 0x9f, 0x2d, - 0x91, 0xcb, 0x97, 0x1e, 0xe6, 0xbd, 0x5a, 0x6f, 0xae, 0xfe, 0x8d, 0x71, 0xed, 0xf4, 0x28, 0x98, 0x24, - 0x23, 0x22, 0x35, 0x68, 0x2a, 0xd8, 0x12, 0x0, 0x2, 0xac, 0xe9, 0x9, 0x0, 0x6, 0x9e, 0x31, 0x9, - 0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21, 0x3, 0x0, 0x11, 0x5e, 0x6f, 0x65, 0xa4, 0x83, + 0xf3, 0xf6, 0xa4, 0xa2, 0xcb, 0xda, 0xe5, 0x67, 0xc1, 0xde, 0x68, 0xc, 0x1c, 0x0, 0x5, 0xa9, 0x8d, + 0xf0, 0xbd, 0xa7, 0x1c, 0x0, 0x12, 0x5d, 0x25, 0x61, 0x71, 0x7d, 0x86, 0x61, 0xb0, 0xc0, 0x46, 0xfc, + 0x1d, 0x18, 0xec, 0xb0, 0x75, 0xfe, 0xc4, 0x23, 0x2a, 0xb, 0x19, 0x79, 0xa1, 0x1, 0x2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[3]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7634); + EXPECT_EQ(packet_id, 32439); EXPECT_EQ(count, 3); EXPECT_EQ(granted_qos_levels[0], 0xA1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); } -// SubscribeResponse 17449 [Left SubErrUnspecifiedError,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Left -// SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right -// QoS2,Right QoS1] [PropResponseInformation -// "\NAK\231\DC4$VU\152\205\ACK\138\245\171\157;\tw\183W",PropWillDelayInterval 2297,PropWillDelayInterval -// 6369,PropReceiveMaximum 14983,PropRetainAvailable 1,PropAuthenticationMethod -// "\r\156\&7*g\131\229\238\FSTN\211\135\182\225\153\146\147\194",PropTopicAliasMaximum 2942,PropTopicAlias -// 20633,PropRequestResponseInformation 3,PropReasonString "\212%",PropSubscriptionIdentifier -// 9,PropMessageExpiryInterval 25957,PropMaximumPacketSize 17017,PropResponseTopic -// ";\180\250D\ACK\235g_t\NAK6\174\137i\186E\182p\DLE\229;G\STX\181\237Y\191",PropPayloadFormatIndicator -// 92,PropRetainAvailable 102,PropRetainAvailable 170,PropRequestProblemInformation 152,PropUserProperty -// "\150\163\243\n\r\ETB\210\233\&3\176f\157\208\254m\175D\217\178[\226\169*\199\177\&6\145>\185" -// "\147\178\206\245\236D\222O\176\191\132y\196",PropRequestProblemInformation 141,PropRequestProblemInformation -// 72,PropTopicAlias 18280] -TEST(SubACK5QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0xbc, 0x1, 0x44, 0x29, 0xaf, 0x1, 0x1a, 0x0, 0x12, 0x15, 0xe7, 0x14, 0x24, 0x56, 0x55, - 0x98, 0xcd, 0x6, 0x8a, 0xf5, 0xab, 0x9d, 0x3b, 0x9, 0x77, 0xb7, 0x57, 0x18, 0x0, 0x0, 0x8, - 0xf9, 0x18, 0x0, 0x0, 0x18, 0xe1, 0x21, 0x3a, 0x87, 0x25, 0x1, 0x15, 0x0, 0x13, 0xd, 0x9c, - 0x37, 0x2a, 0x67, 0x83, 0xe5, 0xee, 0x1c, 0x54, 0x4e, 0xd3, 0x87, 0xb6, 0xe1, 0x99, 0x92, 0x93, - 0xc2, 0x22, 0xb, 0x7e, 0x23, 0x50, 0x99, 0x19, 0x3, 0x1f, 0x0, 0x2, 0xd4, 0x25, 0xb, 0x9, - 0x2, 0x0, 0x0, 0x65, 0x65, 0x27, 0x0, 0x0, 0x42, 0x79, 0x8, 0x0, 0x1b, 0x3b, 0xb4, 0xfa, - 0x44, 0x6, 0xeb, 0x67, 0x5f, 0x74, 0x15, 0x36, 0xae, 0x89, 0x69, 0xba, 0x45, 0xb6, 0x70, 0x10, - 0xe5, 0x3b, 0x47, 0x2, 0xb5, 0xed, 0x59, 0xbf, 0x1, 0x5c, 0x25, 0x66, 0x25, 0xaa, 0x17, 0x98, - 0x26, 0x0, 0x1d, 0x96, 0xa3, 0xf3, 0xa, 0xd, 0x17, 0xd2, 0xe9, 0x33, 0xb0, 0x66, 0x9d, 0xd0, - 0xfe, 0x6d, 0xaf, 0x44, 0xd9, 0xb2, 0x5b, 0xe2, 0xa9, 0x2a, 0xc7, 0xb1, 0x36, 0x91, 0x3e, 0xb9, - 0x0, 0xd, 0x93, 0xb2, 0xce, 0xf5, 0xec, 0x44, 0xde, 0x4f, 0xb0, 0xbf, 0x84, 0x79, 0xc4, 0x17, - 0x8d, 0x17, 0x48, 0x23, 0x47, 0x68, 0x80, 0x97, 0x80, 0x80, 0x91, 0x0, 0xa2, 0x2, 0x1}; +// SubscribeResponse 4983 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Right +// QoS2,Right QoS2,Right QoS1] [PropWillDelayInterval 17871,PropMessageExpiryInterval 4396,PropContentType +// "\197#\214s",PropSubscriptionIdentifierAvailable 4,PropTopicAliasMaximum 16000,PropReceiveMaximum +// 756,PropAssignedClientIdentifier "\n\177\b>\243C\230\&2\209\186a{"] +TEST(SubACK5QCTest, Decode4) { + uint8_t pkt[] = {0x90, 0x34, 0x13, 0x77, 0x28, 0x18, 0x0, 0x0, 0x45, 0xcf, 0x2, 0x0, 0x0, 0x11, + 0x2c, 0x3, 0x0, 0x4, 0xc5, 0x23, 0xd6, 0x73, 0x29, 0x4, 0x22, 0x3e, 0x80, 0x21, + 0x2, 0xf4, 0x12, 0x0, 0xc, 0xa, 0xb1, 0x8, 0x3e, 0xf3, 0x43, 0xe6, 0x32, 0xd1, + 0xba, 0x61, 0x7b, 0x9e, 0x97, 0xa1, 0x2, 0x0, 0xa1, 0x2, 0x2, 0x1}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[9]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17449); + EXPECT_EQ(packet_id, 4983); EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[0], 0x9E); EXPECT_EQ(granted_qos_levels[1], 0x97); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x91); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0xA2); + EXPECT_EQ(granted_qos_levels[2], 0xA1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0xA1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); } -// SubscribeResponse 27369 [Left SubErrImplementationSpecificError,Right QoS1,Right QoS0,Left -// SubErrUnspecifiedError,Right QoS2,Right QoS0,Right QoS0,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Left -// SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported] [PropContentType -// "\234\146\&0.\151\163\229p=\r\164R\252\DC1\158\239\163Xg\180\ESC\255",PropReasonString -// "bz\245\DC4\195\233\144\224}\159g\138c\131\238L\138Ts\208\t\214]\EM\175\238:\144\255\252",PropPayloadFormatIndicator -// 208,PropAssignedClientIdentifier "\EMTh\229.\194\ETX+\148\197\DC3f\225\206u",PropCorrelationData -// "\183d\136\140cm.\195\205}\147\206\187",PropRequestResponseInformation 174,PropTopicAlias -// 18785,PropWildcardSubscriptionAvailable 140,PropTopicAliasMaximum 7985,PropRetainAvailable 248,PropUserProperty -// "\207\195\177\241,\US\134\254\205\130#\161\214\132\DC3" -// "K\EM\154U\SI\171b\220$\SUBS\180\244\150\254:\147p\221\207^",PropSharedSubscriptionAvailable -// 205,PropPayloadFormatIndicator 226,PropRequestProblemInformation 220,PropResponseTopic -// "o\148\EOT\232?\v7\ESCl\ETX\200\&2\158\255\DEL\175\130\173\204\DC2\EOTj\134\172",PropAuthenticationData -// "\146]\ESC\DLE\RSR/\"x\153\232M\NAKF\187\RS\139\179\249{\207\&2\143\180\252a\198vY\151"] -TEST(SubACK5QCTest, Decode6) { - uint8_t pkt[] = {0x90, 0xe4, 0x1, 0x6a, 0xe9, 0xd5, 0x1, 0x3, 0x0, 0x16, 0xea, 0x92, 0x30, 0x2e, 0x97, 0xa3, 0xe5, - 0x70, 0x3d, 0xd, 0xa4, 0x52, 0xfc, 0x11, 0x9e, 0xef, 0xa3, 0x58, 0x67, 0xb4, 0x1b, 0xff, 0x1f, 0x0, - 0x1e, 0x62, 0x7a, 0xf5, 0x14, 0xc3, 0xe9, 0x90, 0xe0, 0x7d, 0x9f, 0x67, 0x8a, 0x63, 0x83, 0xee, 0x4c, - 0x8a, 0x54, 0x73, 0xd0, 0x9, 0xd6, 0x5d, 0x19, 0xaf, 0xee, 0x3a, 0x90, 0xff, 0xfc, 0x1, 0xd0, 0x12, - 0x0, 0xf, 0x19, 0x54, 0x68, 0xe5, 0x2e, 0xc2, 0x3, 0x2b, 0x94, 0xc5, 0x13, 0x66, 0xe1, 0xce, 0x75, - 0x9, 0x0, 0xd, 0xb7, 0x64, 0x88, 0x8c, 0x63, 0x6d, 0x2e, 0xc3, 0xcd, 0x7d, 0x93, 0xce, 0xbb, 0x19, - 0xae, 0x23, 0x49, 0x61, 0x28, 0x8c, 0x22, 0x1f, 0x31, 0x25, 0xf8, 0x26, 0x0, 0xf, 0xcf, 0xc3, 0xb1, - 0xf1, 0x2c, 0x1f, 0x86, 0xfe, 0xcd, 0x82, 0x23, 0xa1, 0xd6, 0x84, 0x13, 0x0, 0x15, 0x4b, 0x19, 0x9a, - 0x55, 0xf, 0xab, 0x62, 0xdc, 0x24, 0x1a, 0x53, 0xb4, 0xf4, 0x96, 0xfe, 0x3a, 0x93, 0x70, 0xdd, 0xcf, - 0x5e, 0x2a, 0xcd, 0x1, 0xe2, 0x17, 0xdc, 0x8, 0x0, 0x18, 0x6f, 0x94, 0x4, 0xe8, 0x3f, 0xb, 0x37, - 0x1b, 0x6c, 0x3, 0xc8, 0x32, 0x9e, 0xff, 0x7f, 0xaf, 0x82, 0xad, 0xcc, 0x12, 0x4, 0x6a, 0x86, 0xac, - 0x16, 0x0, 0x1e, 0x92, 0x5d, 0x1b, 0x10, 0x1e, 0x52, 0x2f, 0x22, 0x78, 0x99, 0xe8, 0x4d, 0x15, 0x46, - 0xbb, 0x1e, 0x8b, 0xb3, 0xf9, 0x7b, 0xcf, 0x32, 0x8f, 0xb4, 0xfc, 0x61, 0xc6, 0x76, 0x59, 0x97, 0x83, - 0x1, 0x0, 0x80, 0x2, 0x0, 0x0, 0x80, 0x87, 0x8f, 0xa1}; +// SubscribeResponse 13883 [Right QoS0,Left SubErrPacketIdentifierInUse,Left SubErrPacketIdentifierInUse,Right +// QoS0,Right QoS0,Left SubErrUnspecifiedError,Right QoS0] [PropRetainAvailable 105,PropRequestResponseInformation +// 236,PropSessionExpiryInterval 18710,PropRequestResponseInformation 120,PropSharedSubscriptionAvailable +// 214,PropAssignedClientIdentifier "\250\197\157\128",PropSharedSubscriptionAvailable 51,PropResponseInformation +// "\184\239s\133\&1\247\157\144n\239D\234G",PropContentType +// "\172\246\216\166\219B\239B\146",PropRequestProblemInformation 168,PropAssignedClientIdentifier +// "K1)\174\237\&7\SUB\129\&2\158\172\162\217\194b\210k\158b\a`\201s",PropPayloadFormatIndicator 22,PropServerReference +// "k;\135\212\CAN,\241\236\215K)u\231\236\226\135\215\130`\175\231\195\n",PropTopicAlias 23018,PropReceiveMaximum +// 8826,PropSubscriptionIdentifierAvailable 53,PropTopicAliasMaximum 18965,PropContentType +// "\253\SIw\\-\bU\230(\vX\SYNC\245\234",PropWildcardSubscriptionAvailable 204,PropMessageExpiryInterval +// 8078,PropReasonString +// "0C\NUL#\203:\NUL1d\168\142Hk\159\181\NAK\150\201\SUB\195_06f\165dr\220\235",PropMaximumPacketSize +// 13502,PropSubscriptionIdentifier 27,PropMaximumQoS 21,PropUserProperty "\136e\202\216\155%\140A\142" +// "\174_\v\190|8\162\196",PropSubscriptionIdentifierAvailable 212,PropWillDelayInterval 26280,PropMessageExpiryInterval +// 5506] +TEST(SubACK5QCTest, Decode5) { + uint8_t pkt[] = {0x90, 0xe4, 0x1, 0x36, 0x3b, 0xd9, 0x1, 0x25, 0x69, 0x19, 0xec, 0x11, 0x0, 0x0, 0x49, 0x16, 0x19, + 0x78, 0x2a, 0xd6, 0x12, 0x0, 0x4, 0xfa, 0xc5, 0x9d, 0x80, 0x2a, 0x33, 0x1a, 0x0, 0xd, 0xb8, 0xef, + 0x73, 0x85, 0x31, 0xf7, 0x9d, 0x90, 0x6e, 0xef, 0x44, 0xea, 0x47, 0x3, 0x0, 0x9, 0xac, 0xf6, 0xd8, + 0xa6, 0xdb, 0x42, 0xef, 0x42, 0x92, 0x17, 0xa8, 0x12, 0x0, 0x17, 0x4b, 0x31, 0x29, 0xae, 0xed, 0x37, + 0x1a, 0x81, 0x32, 0x9e, 0xac, 0xa2, 0xd9, 0xc2, 0x62, 0xd2, 0x6b, 0x9e, 0x62, 0x7, 0x60, 0xc9, 0x73, + 0x1, 0x16, 0x1c, 0x0, 0x17, 0x6b, 0x3b, 0x87, 0xd4, 0x18, 0x2c, 0xf1, 0xec, 0xd7, 0x4b, 0x29, 0x75, + 0xe7, 0xec, 0xe2, 0x87, 0xd7, 0x82, 0x60, 0xaf, 0xe7, 0xc3, 0xa, 0x23, 0x59, 0xea, 0x21, 0x22, 0x7a, + 0x29, 0x35, 0x22, 0x4a, 0x15, 0x3, 0x0, 0xf, 0xfd, 0xf, 0x77, 0x5c, 0x2d, 0x8, 0x55, 0xe6, 0x28, + 0xb, 0x58, 0x16, 0x43, 0xf5, 0xea, 0x28, 0xcc, 0x2, 0x0, 0x0, 0x1f, 0x8e, 0x1f, 0x0, 0x1d, 0x30, + 0x43, 0x0, 0x23, 0xcb, 0x3a, 0x0, 0x31, 0x64, 0xa8, 0x8e, 0x48, 0x6b, 0x9f, 0xb5, 0x15, 0x96, 0xc9, + 0x1a, 0xc3, 0x5f, 0x30, 0x36, 0x66, 0xa5, 0x64, 0x72, 0xdc, 0xeb, 0x27, 0x0, 0x0, 0x34, 0xbe, 0xb, + 0x1b, 0x24, 0x15, 0x26, 0x0, 0x9, 0x88, 0x65, 0xca, 0xd8, 0x9b, 0x25, 0x8c, 0x41, 0x8e, 0x0, 0x8, + 0xae, 0x5f, 0xb, 0xbe, 0x7c, 0x38, 0xa2, 0xc4, 0x29, 0xd4, 0x18, 0x0, 0x0, 0x66, 0xa8, 0x2, 0x0, + 0x0, 0x15, 0x82, 0x0, 0x91, 0x91, 0x0, 0x0, 0x80, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27369); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x83); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 13883); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x91); + EXPECT_EQ(granted_qos_levels[2], 0x91); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x80); EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x87); - EXPECT_EQ(granted_qos_levels[9], 0x8F); - EXPECT_EQ(granted_qos_levels[10], 0xA1); -} - -// SubscribeResponse 9981 [Right QoS2,Right QoS1,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Right -// QoS2,Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Left SubErrUnspecifiedError] -// [PropAuthenticationData "\152",PropMaximumQoS 127,PropTopicAlias 18865,PropCorrelationData -// "\EOT\ENQ\131\197Jh~\181Hr\177\SI\235:\132\247Av(",PropServerReference -// "t\EOT\203\168\221g\222\135\232>\fC\132_6\DLE\131\&5G\223K\161&\250\219\225Uq4N",PropWillDelayInterval -// 11881,PropRequestProblemInformation 159,PropMessageExpiryInterval 13721,PropCorrelationData -// "\242qt\128\153\anZ[\US\171",PropSubscriptionIdentifierAvailable 110,PropReasonString " \194\DLE\185\142\213t -// s%\159\n\214X\CAN\200p\DELVX)",PropCorrelationData -// "\215j}\SI\208!\142'?\STX\130\185\&3%L\218\ETB\212",PropSharedSubscriptionAvailable 42,PropAuthenticationData -// "H\149\252m\195\141\196\246\129/]\208P\162",PropRequestResponseInformation 32,PropSubscriptionIdentifierAvailable -// 41,PropWildcardSubscriptionAvailable 71,PropSharedSubscriptionAvailable 72] +} + +// SubscribeResponse 7030 [Right QoS0] [PropServerKeepAlive 16046,PropRetainAvailable 15,PropAssignedClientIdentifier +// "\214;\212s_I4",PropSubscriptionIdentifier 0,PropMessageExpiryInterval 25675,PropMaximumQoS +// 127,PropMessageExpiryInterval 15938,PropResponseInformation +// "O\195\200n*S\167A\183\149\191\SUBE\fj,n\156\246\250\239,\207",PropSessionExpiryInterval +// 17485,PropWildcardSubscriptionAvailable 94,PropMaximumQoS 248,PropServerReference +// "7}\190\ETBZ\183\150|\"O\155\ETB\171 \SOHF\198\231\159\SYN5\170\137\159!\179Q",PropUserProperty +// "\140?$\156\154a\206\210\163\215m" "\NUL\193\211nS\168\241\190",PropResponseInformation +// "B\216}4\155^f\a\160q6F\249>\224fL&\254\210j\204\167",PropServerKeepAlive 17141,PropSubscriptionIdentifierAvailable +// 84,PropResponseInformation +// "\172x\249\206\229\228\173\151BrI\247{\183\NUL\202nj0\179\156R\ETX:\149\235\192",PropMessageExpiryInterval +// 32669,PropReasonString "b\\\151\n\197\178\179\195f\253W\a\152\a\156}\t[\187\215\f\227\194*",PropAuthenticationData +// "0^\145\&3\240\DELM\148 R@F\247lw-\192\196\141w\ra\251c",PropMessageExpiryInterval 4202,PropAssignedClientIdentifier +// "f\185\234_L\239\&6N",PropAuthenticationData "2\203j`"] +TEST(SubACK5QCTest, Decode6) { + uint8_t pkt[] = {0x90, 0x8a, 0x2, 0x1b, 0x76, 0x85, 0x2, 0x13, 0x3e, 0xae, 0x25, 0xf, 0x12, 0x0, 0x7, 0xd6, 0x3b, + 0xd4, 0x73, 0x5f, 0x49, 0x34, 0xb, 0x0, 0x2, 0x0, 0x0, 0x64, 0x4b, 0x24, 0x7f, 0x2, 0x0, 0x0, + 0x3e, 0x42, 0x1a, 0x0, 0x17, 0x4f, 0xc3, 0xc8, 0x6e, 0x2a, 0x53, 0xa7, 0x41, 0xb7, 0x95, 0xbf, 0x1a, + 0x45, 0xc, 0x6a, 0x2c, 0x6e, 0x9c, 0xf6, 0xfa, 0xef, 0x2c, 0xcf, 0x11, 0x0, 0x0, 0x44, 0x4d, 0x28, + 0x5e, 0x24, 0xf8, 0x1c, 0x0, 0x1b, 0x37, 0x7d, 0xbe, 0x17, 0x5a, 0xb7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 0xcb, 0x6a, 0x60, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7030); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +} + +// SubscribeResponse 27738 [Right QoS0,Right QoS2] [PropWillDelayInterval 18364,PropRetainAvailable +// 74,PropMessageExpiryInterval 26631,PropRequestResponseInformation 103,PropUserProperty +// "\175\DC3\NULTO\218\&2\212L\RS\233\STX\157\161\&6\243\CAN\165\213\DLE" +// "\217D\178\168\231\ENQ\SUBl<\RSL~\213w\148$\146\129\197\173\DC2\189!\223\246\203\234\tX",PropRequestResponseInformation +// 33,PropTopicAliasMaximum 10285] TEST(SubACK5QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0xb0, 0x1, 0x26, 0xfd, 0xa4, 0x1, 0x16, 0x0, 0x1, 0x98, 0x24, 0x7f, 0x23, 0x49, 0xb1, 0x9, - 0x0, 0x13, 0x4, 0x5, 0x83, 0xc5, 0x4a, 0x68, 0x7e, 0xb5, 0x48, 0x72, 0xb1, 0xf, 0xeb, 0x3a, 0x84, - 0xf7, 0x41, 0x76, 0x28, 0x1c, 0x0, 0x1e, 0x74, 0x4, 0xcb, 0xa8, 0xdd, 0x67, 0xde, 0x87, 0xe8, 0x3e, - 0xc, 0x43, 0x84, 0x5f, 0x36, 0x10, 0x83, 0x35, 0x47, 0xdf, 0x4b, 0xa1, 0x26, 0xfa, 0xdb, 0xe1, 0x55, - 0x71, 0x34, 0x4e, 0x18, 0x0, 0x0, 0x2e, 0x69, 0x17, 0x9f, 0x2, 0x0, 0x0, 0x35, 0x99, 0x9, 0x0, - 0xb, 0xf2, 0x71, 0x74, 0x80, 0x99, 0x7, 0x6e, 0x5a, 0x5b, 0x1f, 0xab, 0x29, 0x6e, 0x1f, 0x0, 0x15, - 0x20, 0xc2, 0x10, 0xb9, 0x8e, 0xd5, 0x74, 0x20, 0x73, 0x25, 0x9f, 0xa, 0xd6, 0x58, 0x18, 0xc8, 0x70, - 0x7f, 0x56, 0x58, 0x29, 0x9, 0x0, 0x12, 0xd7, 0x6a, 0x7d, 0xf, 0xd0, 0x21, 0x8e, 0x27, 0x3f, 0x2, - 0x82, 0xb9, 0x33, 0x25, 0x4c, 0xda, 0x17, 0xd4, 0x2a, 0x2a, 0x16, 0x0, 0xe, 0x48, 0x95, 0xfc, 0x6d, - 0xc3, 0x8d, 0xc4, 0xf6, 0x81, 0x2f, 0x5d, 0xd0, 0x50, 0xa2, 0x19, 0x20, 0x29, 0x29, 0x28, 0x47, 0x2a, - 0x48, 0x2, 0x1, 0x80, 0x91, 0x2, 0x83, 0x80, 0x80}; + uint8_t pkt[] = {0x90, 0x4e, 0x6c, 0x5a, 0x49, 0x18, 0x0, 0x0, 0x47, 0xbc, 0x25, 0x4a, 0x2, 0x0, 0x0, 0x68, + 0x7, 0x19, 0x67, 0x26, 0x0, 0x14, 0xaf, 0x13, 0x0, 0x54, 0x4f, 0xda, 0x32, 0xd4, 0x4c, 0x1e, + 0xe9, 0x2, 0x9d, 0xa1, 0x36, 0xf3, 0x18, 0xa5, 0xd5, 0x10, 0x0, 0x1d, 0xd9, 0x44, 0xb2, 0xa8, + 0xe7, 0x5, 0x1a, 0x6c, 0x3c, 0x1e, 0x4c, 0x7e, 0xd5, 0x77, 0x94, 0x24, 0x92, 0x81, 0xc5, 0xad, + 0x12, 0xbd, 0x21, 0xdf, 0xf6, 0xcb, 0xea, 0x9, 0x58, 0x19, 0x21, 0x22, 0x28, 0x2d, 0x0, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9981); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x91); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x83); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(packet_id, 27738); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); } -// SubscribeResponse 25704 [Right QoS1,Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError] -// [PropWildcardSubscriptionAvailable 84,PropSessionExpiryInterval 13092,PropTopicAliasMaximum 19356] +// SubscribeResponse 4324 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS0,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrSharedSubscriptionsNotSupported] [PropMaximumQoS 32,PropReasonString +// "QqM\SOH\r\234H\200\tfW\128\&8\129\130",PropServerReference "\197F\ACKV",PropSharedSubscriptionAvailable +// 151,PropPayloadFormatIndicator 22,PropSessionExpiryInterval 25815,PropAuthenticationMethod +// "\SOH}\228~\168\230\&5?\156gM\211\134s",PropRequestResponseInformation 99,PropTopicAlias 10610,PropTopicAlias +// 17610,PropSharedSubscriptionAvailable 184,PropRetainAvailable 242,PropTopicAliasMaximum +// 25664,PropRequestProblemInformation 200,PropServerReference "\201\162\f\NAK\166\216\145",PropSubscriptionIdentifier +// 29,PropSubscriptionIdentifierAvailable 8,PropRequestResponseInformation 140,PropSessionExpiryInterval +// 13061,PropReceiveMaximum 25226,PropReasonString "\159u\FS\227~G\168mi\178y\178",PropAuthenticationData +// "$$\197V!\234\135\\C&\a",PropRetainAvailable 221,PropContentType +// "i\154\199?\188\EOT\152\188\148\154",PropRetainAvailable 148,PropAuthenticationData +// "\251\225\DC3\186\207\v\STX\"\b\226\184\131\226-\202\173\245\SO\140"] TEST(SubACK5QCTest, Decode8) { - uint8_t pkt[] = {0x90, 0x10, 0x64, 0x68, 0xa, 0x28, 0x54, 0x11, 0x0, - 0x0, 0x33, 0x24, 0x22, 0x4b, 0x9c, 0x1, 0x83, 0x80}; + uint8_t pkt[] = {0x90, 0xad, 0x1, 0x10, 0xe4, 0xa2, 0x1, 0x24, 0x20, 0x1f, 0x0, 0xf, 0x51, 0x71, 0x4d, 0x1, + 0xd, 0xea, 0x48, 0xc8, 0x9, 0x66, 0x57, 0x80, 0x38, 0x81, 0x82, 0x1c, 0x0, 0x4, 0xc5, 0x46, + 0x6, 0x56, 0x2a, 0x97, 0x1, 0x16, 0x11, 0x0, 0x0, 0x64, 0xd7, 0x15, 0x0, 0xe, 0x1, 0x7d, + 0xe4, 0x7e, 0xa8, 0xe6, 0x35, 0x3f, 0x9c, 0x67, 0x4d, 0xd3, 0x86, 0x73, 0x19, 0x63, 0x23, 0x29, + 0x72, 0x23, 0x44, 0xca, 0x2a, 0xb8, 0x25, 0xf2, 0x22, 0x64, 0x40, 0x17, 0xc8, 0x1c, 0x0, 0x7, + 0xc9, 0xa2, 0xc, 0x15, 0xa6, 0xd8, 0x91, 0xb, 0x1d, 0x29, 0x8, 0x19, 0x8c, 0x11, 0x0, 0x0, + 0x33, 0x5, 0x21, 0x62, 0x8a, 0x1f, 0x0, 0xc, 0x9f, 0x75, 0x1c, 0xe3, 0x7e, 0x47, 0xa8, 0x6d, + 0x69, 0xb2, 0x79, 0xb2, 0x16, 0x0, 0xb, 0x24, 0x24, 0xc5, 0x56, 0x21, 0xea, 0x87, 0x5c, 0x43, + 0x26, 0x7, 0x25, 0xdd, 0x3, 0x0, 0xa, 0x69, 0x9a, 0xc7, 0x3f, 0xbc, 0x4, 0x98, 0xbc, 0x94, + 0x9a, 0x25, 0x94, 0x16, 0x0, 0x13, 0xfb, 0xe1, 0x13, 0xba, 0xcf, 0xb, 0x2, 0x22, 0x8, 0xe2, + 0xb8, 0x83, 0xe2, 0x2d, 0xca, 0xad, 0xf5, 0xe, 0x8c, 0x9e, 0x0, 0x0, 0x0, 0x9e, 0xa2, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25704); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0x83); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(packet_id, 4324); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x9E); + EXPECT_EQ(granted_qos_levels[5], 0xA2); + EXPECT_EQ(granted_qos_levels[6], 0x9E); } -// SubscribeResponse 27290 [Right QoS0,Right QoS1,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrPacketIdentifierInUse,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS2] [PropSubscriptionIdentifier -// 24,PropReceiveMaximum 9995,PropAuthenticationMethod -// "\251\v\182\FS\250Q\241\212C\"K|N\249J+\200\137",PropRetainAvailable 189,PropServerReference -// "dN\213+\180\254m!\STX\182\r\204\182\&7\144\185\r\183\221\233\&3\159ki\209",PropWillDelayInterval -// 24527,PropSubscriptionIdentifier 19,PropContentType "\190/8\167\NUL",PropPayloadFormatIndicator 131,PropResponseTopic -// "",PropSessionExpiryInterval 13681,PropSessionExpiryInterval 3955,PropReceiveMaximum 13878,PropSubscriptionIdentifier -// 5,PropSessionExpiryInterval 4247,PropTopicAlias 6837,PropMessageExpiryInterval 32164] +// SubscribeResponse 11281 [Left SubErrImplementationSpecificError,Right QoS1,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded] [PropMaximumPacketSize +// 8437,PropMessageExpiryInterval 21940] TEST(SubACK5QCTest, Decode9) { - uint8_t pkt[] = {0x90, 0x73, 0x6a, 0x9a, 0x68, 0xb, 0x18, 0x21, 0x27, 0xb, 0x15, 0x0, 0x12, 0xfb, 0xb, 0xb6, 0x1c, - 0xfa, 0x51, 0xf1, 0xd4, 0x43, 0x22, 0x4b, 0x7c, 0x4e, 0xf9, 0x4a, 0x2b, 0xc8, 0x89, 0x25, 0xbd, 0x1c, - 0x0, 0x19, 0x64, 0x4e, 0xd5, 0x2b, 0xb4, 0xfe, 0x6d, 0x21, 0x2, 0xb6, 0xd, 0xcc, 0xb6, 0x37, 0x90, - 0xb9, 0xd, 0xb7, 0xdd, 0xe9, 0x33, 0x9f, 0x6b, 0x69, 0xd1, 0x18, 0x0, 0x0, 0x5f, 0xcf, 0xb, 0x13, - 0x3, 0x0, 0x5, 0xbe, 0x2f, 0x38, 0xa7, 0x0, 0x1, 0x83, 0x8, 0x0, 0x0, 0x11, 0x0, 0x0, 0x35, - 0x71, 0x11, 0x0, 0x0, 0xf, 0x73, 0x21, 0x36, 0x36, 0xb, 0x5, 0x11, 0x0, 0x0, 0x10, 0x97, 0x23, - 0x1a, 0xb5, 0x2, 0x0, 0x0, 0x7d, 0xa4, 0x0, 0x1, 0x1, 0x9e, 0x91, 0x1, 0x91, 0x2}; + uint8_t pkt[] = {0x90, 0x11, 0x2c, 0x11, 0xa, 0x27, 0x0, 0x0, 0x20, 0xf5, + 0x2, 0x0, 0x0, 0x55, 0xb4, 0x83, 0x1, 0xa1, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27290); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 11281); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x83); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x9E); - EXPECT_EQ(granted_qos_levels[4], 0x91); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x91); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0xA1); + EXPECT_EQ(granted_qos_levels[3], 0x97); } -// SubscribeResponse 26187 [Left SubErrImplementationSpecificError,Right QoS1,Left SubErrImplementationSpecificError] -// [PropMessageExpiryInterval 119,PropContentType "",PropServerReference "\140",PropAssignedClientIdentifier -// "b\173J\131\NAK\225\ETB0\128\DC3\161t`\SI\200\188\EOT\221\235\190\233Jp\226\133\205\ENQ`",PropRequestResponseInformation -// 20,PropAssignedClientIdentifier "\STXR\152?\189V\215\&0a\228\220?\239\NAK",PropAuthenticationMethod -// "S\FS\196\ACKElA\169>\147\165",PropRetainAvailable 147,PropMaximumQoS 250,PropSubscriptionIdentifier -// 19,PropSharedSubscriptionAvailable 48,PropMaximumPacketSize 14740,PropRetainAvailable 230,PropCorrelationData -// "\131|\198\219",PropUserProperty "\160\&9pU\209\220?l" ",;8c=A\\\147j\207\147F=\237\198\165\&5",PropMaximumPacketSize -// 14635,PropMaximumPacketSize 12754,PropPayloadFormatIndicator 40,PropSubscriptionIdentifier 13,PropResponseInformation -// "\f\147\&7\235\DC2\233\168#qoo\171\US\210\154\218e\204\190\&8",PropAuthenticationData -// "pQ\f\230Sr\142\&2\ETB/^[\225j\153\NAK\218-T\199\207$\224uH",PropReceiveMaximum 30595,PropRequestResponseInformation -// 43,PropContentType "36\210",PropAuthenticationData -// "\ETX\144y\161]\254w\163\EM\166\RS\213\133\253\CAN\158\157+4\220\198",PropMessageExpiryInterval 5797] +// SubscribeResponse 462 [Right QoS2,Right QoS2] [] TEST(SubACK5QCTest, Decode10) { - uint8_t pkt[] = { - 0x90, 0xf0, 0x1, 0x66, 0x4b, 0xe9, 0x1, 0x2, 0x0, 0x0, 0x0, 0x77, 0x3, 0x0, 0x0, 0x1c, 0x0, 0x1, 0x8c, - 0x12, 0x0, 0x1c, 0x62, 0xad, 0x4a, 0x83, 0x15, 0xe1, 0x17, 0x30, 0x80, 0x13, 0xa1, 0x74, 0x60, 0xf, 0xc8, 0xbc, - 0x4, 0xdd, 0xeb, 0xbe, 0xe9, 0x4a, 0x70, 0xe2, 0x85, 0xcd, 0x5, 0x60, 0x19, 0x14, 0x12, 0x0, 0xe, 0x2, 0x52, - 0x98, 0x3f, 0xbd, 0x56, 0xd7, 0x30, 0x61, 0xe4, 0xdc, 0x3f, 0xef, 0x15, 0x15, 0x0, 0xb, 0x53, 0x1c, 0xc4, 0x6, - 0x45, 0x6c, 0x41, 0xa9, 0x3e, 0x93, 0xa5, 0x25, 0x93, 0x24, 0xfa, 0xb, 0x13, 0x2a, 0x30, 0x27, 0x0, 0x0, 0x39, - 0x94, 0x25, 0xe6, 0x9, 0x0, 0x4, 0x83, 0x7c, 0xc6, 0xdb, 0x26, 0x0, 0x8, 0xa0, 0x39, 0x70, 0x55, 0xd1, 0xdc, - 0x3f, 0x6c, 0x0, 0x11, 0x2c, 0x3b, 0x38, 0x63, 0x3d, 0x41, 0x5c, 0x93, 0x6a, 0xcf, 0x93, 0x46, 0x3d, 0xed, 0xc6, - 0xa5, 0x35, 0x27, 0x0, 0x0, 0x39, 0x2b, 0x27, 0x0, 0x0, 0x31, 0xd2, 0x1, 0x28, 0xb, 0xd, 0x1a, 0x0, 0x14, - 0xc, 0x93, 0x37, 0xeb, 0x12, 0xe9, 0xa8, 0x23, 0x71, 0x6f, 0x6f, 0xab, 0x1f, 0xd2, 0x9a, 0xda, 0x65, 0xcc, 0xbe, - 0x38, 0x16, 0x0, 0x19, 0x70, 0x51, 0xc, 0xe6, 0x53, 0x72, 0x8e, 0x32, 0x17, 0x2f, 0x5e, 0x5b, 0xe1, 0x6a, 0x99, - 0x15, 0xda, 0x2d, 0x54, 0xc7, 0xcf, 0x24, 0xe0, 0x75, 0x48, 0x21, 0x77, 0x83, 0x19, 0x2b, 0x3, 0x0, 0x3, 0x33, - 0x36, 0xd2, 0x16, 0x0, 0x15, 0x3, 0x90, 0x79, 0xa1, 0x5d, 0xfe, 0x77, 0xa3, 0x19, 0xa6, 0x1e, 0xd5, 0x85, 0xfd, - 0x18, 0x9e, 0x9d, 0x2b, 0x34, 0xdc, 0xc6, 0x2, 0x0, 0x0, 0x16, 0xa5, 0x83, 0x1, 0x83}; + uint8_t pkt[] = {0x90, 0x5, 0x1, 0xce, 0x0, 0x2, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26187); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0x83); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x83); + EXPECT_EQ(packet_id, 462); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); } -// SubscribeResponse 26384 [Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Right QoS1,Left -// SubErrNotAuthorized,Right QoS0,Right QoS1,Left SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS2] [PropUserProperty "{\195\147\227k\139" -// "\174\SO\180\195\164&!}",PropMessageExpiryInterval 9881,PropMaximumQoS 232,PropResponseTopic -// "\174g\179\226\156l\223\176\DLE]+#\130 \128\135\196",PropMaximumPacketSize 12346,PropContentType "\193\216\252\189 -// \206*\228\201\ETX\222Z\172\215\SOH\188\224SC6\252e\152w",PropAssignedClientIdentifier "\US\210\ETB\198\137\215\&1U"] +// SubscribeResponse 28404 [Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Left +// SubErrSubscriptionIdentifiersNotSupported] [PropResponseTopic "\193 +// \204B\253`\179\135\ETBx\190G.K|lB%;8\191A9\129T",PropRequestResponseInformation +// 146,PropSubscriptionIdentifierAvailable 186,PropUserProperty "\173\NULQ\SYNQ\151\214\&8g\232c\239" +// ")\129\137\NUL/0\DEL\142\186\225\FS\247u\228\176\162d\170\CAN\165&",PropServerReference +// "\DC2\189\255\136\224\158\172\227s\139\206\170\155'\198\172\164\179\171\195\156\187\167rj",PropTopicAliasMaximum +// 18134,PropWildcardSubscriptionAvailable 34,PropReceiveMaximum 31787,PropTopicAliasMaximum 31526,PropReasonString +// "",PropWillDelayInterval 12886,PropCorrelationData +// "\185\224)\139y\198\a\134\NUL?\136\DC1\229\232\EOT%\245%\193\130\176\195\193\150\n>\133<\219",PropRequestResponseInformation +// 12,PropContentType "\221\129\249u\SO\240\141%\DC4 \RSS\DC4\131\208l\195di\ESC\238\137\EMl",PropAuthenticationData +// "\140F\207Q\ETB\b5\227\f\197Y\235\152\242\&9\214\172y+S\153t\210\&6(\132z\172\175JJE\US\ETX\ETB\184_\157",PropCorrelationData -// "\222\DC4\SI\195\210\246\SYNkqz[\160\255p\152\DC3Jd,,q\148\DC2\DC32\\",PropResponseTopic -// "\188==l\255\182JXe\150\&9\192l",PropResponseInformation -// "\133\DC36E_\255\178.7\f\130\250\181\250\&1l\210\231\129;K?\170\NUL\r\vWW",PropAuthenticationData -// "^\192",PropRequestProblemInformation 202,PropSessionExpiryInterval 9944,PropUserProperty -// "\239\STX\135\176x+\241\158\&7" "\225"] + EXPECT_EQ(granted_qos_levels[2], 0x91); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); +} + +// SubscribeResponse 1085 [Right QoS0,Right QoS0,Left SubErrImplementationSpecificError,Left +// SubErrSubscriptionIdentifiersNotSupported] [PropServerKeepAlive 6900,PropPayloadFormatIndicator +// 43,PropRequestProblemInformation 113,PropWildcardSubscriptionAvailable 45,PropTopicAliasMaximum +// 11413,PropAuthenticationData +// "gP\142\207\ENQ\158c\177\225Qa\v\135\SI\218\212\211\202\&0\SOH,#\196\205\234sB",PropMaximumPacketSize +// 479,PropServerReference "\184\179\147m9\248\202\182\149\159\246\180\154\SUB\185\190\ACK",PropAuthenticationMethod +// "\209J\135K\129\DC4\GS(\DC2",PropAuthenticationMethod +// "V\DC3#\206\153\199\138\216?|\206\182|\197\&5~\r\n\229",PropAuthenticationData +// "\r\241\226\212\US\162\211\179}\190L%\200Q\151*\\\DC3\SI",PropWillDelayInterval 13410,PropRetainAvailable +// 123,PropServerReference "\128\&2\194\a\162\184\ESC\215c1\177L\252\245\&12",PropWillDelayInterval 9499] TEST(SubACK5QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0xf7, 0x1, 0x58, 0x40, 0xee, 0x1, 0x12, 0x0, 0x2, 0xab, 0xcd, 0x28, 0xcf, 0x2a, 0x28, 0x21, - 0x1f, 0xde, 0x22, 0x51, 0x7c, 0x17, 0xa2, 0x1, 0xbc, 0x11, 0x0, 0x0, 0x1c, 0xf4, 0x27, 0x0, 0x0, - 0x8, 0x94, 0x22, 0x29, 0xa4, 0x1c, 0x0, 0x19, 0x9, 0xcb, 0x51, 0x8b, 0x9b, 0x9d, 0x53, 0xff, 0xb3, - 0xf1, 0x3d, 0x5c, 0xb, 0x21, 0xb8, 0xd, 0xe0, 0x9, 0xc0, 0xf7, 0x98, 0x35, 0x4e, 0x7a, 0x16, 0x29, - 0xdf, 0x2, 0x0, 0x0, 0x6b, 0xc, 0x18, 0x0, 0x0, 0x55, 0xbe, 0x1a, 0x0, 0x1a, 0x5d, 0x74, 0xd1, - 0xe6, 0x12, 0x5, 0xf8, 0xe, 0xb6, 0x15, 0x89, 0x69, 0x93, 0x95, 0x4e, 0x60, 0x67, 0x27, 0x68, 0xb3, - 0xa1, 0xe8, 0x82, 0x7c, 0xb1, 0xe1, 0x24, 0xa5, 0x26, 0x0, 0x4, 0x9d, 0x55, 0x21, 0x22, 0x0, 0x17, - 0xa4, 0x10, 0x3e, 0x2b, 0x53, 0x99, 0x74, 0xd2, 0x36, 0x28, 0x84, 0x7a, 0xac, 0xaf, 0x4a, 0x4a, 0x45, - 0x1f, 0x3, 0x17, 0xb8, 0x5f, 0x9d, 0x9, 0x0, 0x1a, 0xde, 0x14, 0xf, 0xc3, 0xd2, 0xf6, 0x16, 0x6b, - 0x71, 0x7a, 0x5b, 0xa0, 0xff, 0x70, 0x98, 0x13, 0x4a, 0x64, 0x2c, 0x2c, 0x71, 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0x7c, + 0xc5, 0x35, 0x7e, 0xd, 0xa, 0xe5, 0x16, 0x0, 0x13, 0xd, 0xf1, 0xe2, 0xd4, 0x1f, 0xa2, 0xd3, 0xb3, + 0x7d, 0xbe, 0x4c, 0x25, 0xc8, 0x51, 0x97, 0x2a, 0x5c, 0x13, 0xf, 0x18, 0x0, 0x0, 0x34, 0x62, 0x25, + 0x7b, 0x1c, 0x0, 0x10, 0x80, 0x32, 0xc2, 0x7, 0xa2, 0xb8, 0x1b, 0xd7, 0x63, 0x31, 0xb1, 0x4c, 0xfc, + 0xf5, 0x31, 0x32, 0x18, 0x0, 0x0, 0x25, 0x1b, 0x0, 0x0, 0x83, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 22592); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 1085); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x83); EXPECT_EQ(granted_qos_levels[3], 0xA1); - EXPECT_EQ(granted_qos_levels[4], 0x91); } -// SubscribeResponse 1930 [Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right QoS2,Left SubErrQuotaExceeded,Right QoS1,Left -// SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Left SubErrTopicFilterInvalid,Left -// SubErrTopicFilterInvalid,Left SubErrUnspecifiedError] [PropPayloadFormatIndicator 152,PropMessageExpiryInterval -// 4959,PropUserProperty "7\201b]v\237" -// "\SOH\159\194\223\SUBL\240\232\234\b\227\193\176y\216\&4\222\235\&7\141\163U",PropCorrelationData -// "\176\167l\148\185\207\204\165R\SI\145Q\DC3I\242\210F\216\160X;",PropSharedSubscriptionAvailable -// 200,PropAuthenticationMethod "\238\154D\219\219\&6\231\222\231\RS\212\180\SOH\155\ACK"] +// SubscribeResponse 11089 [Right QoS1] [PropReasonString "\247\194\179\147\202\DLE",PropTopicAlias +// 23245,PropAssignedClientIdentifier "xmZi\b\150@\214k%\140m\154H",PropUserProperty "R\v\214\NAK" +// "\190\&7\134\154\232\SIf\228\254\NAK\CANA\161\EOT*\GS\135\SO\DC2\188O|i",PropReasonString +// "\246F:\183\ESC+\"\225\207\209\163\153\202\151\DC1\\\140\167\200\206y\152|\ESCu%\196\153\239)",PropReceiveMaximum +// 6204,PropTopicAlias 26815,PropAuthenticationData +// "\219\163E\SUB\NULO\158\ESCs\ACK\185\vQ4\b\213\SUB:?M\239\196B\DC3",PropWillDelayInterval 15528,PropUserProperty +// "\165" "\234\244\189U\247Y\205\224\b\192\177\&6\228\131",PropAuthenticationData +// "\ETX\251\US\NAK\250\209\227\164D\206\149\213\175\&6)\DEL\190Y\217\252\DLEX\219\164J\159Z",PropServerReference +// "\f{\ACK\209$\201\197\225w\163\194\&23\228Y\252\233\v0\205\181",PropAssignedClientIdentifier +// "\229\163\204\171z\177YW\156\ACK\205N\136\151B\251\159l;",PropSessionExpiryInterval 8174,PropSessionExpiryInterval +// 26444] TEST(SubACK5QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0x62, 0x7, 0x8a, 0x54, 0x1, 0x98, 0x2, 0x0, 0x0, 0x13, 0x5f, 0x26, 0x0, 0x6, 0x37, 0xc9, - 0x62, 0x5d, 0x76, 0x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 0x3c, 0x23, 0x68, 0xbf, 0x16, 0x0, 0x18, 0xdb, 0xa3, 0x45, 0x1a, + 0x0, 0x4f, 0x9e, 0x1b, 0x73, 0x6, 0xb9, 0xb, 0x51, 0x34, 0x8, 0xd5, 0x1a, 0x3a, 0x3f, 0x4d, 0xef, 0xc4, 0x42, + 0x13, 0x18, 0x0, 0x0, 0x3c, 0xa8, 0x26, 0x0, 0x1, 0xa5, 0x0, 0xe, 0xea, 0xf4, 0xbd, 0x55, 0xf7, 0x59, 0xcd, + 0xe0, 0x8, 0xc0, 0xb1, 0x36, 0xe4, 0x83, 0x16, 0x0, 0x1b, 0x3, 0xfb, 0x1f, 0x15, 0xfa, 0xd1, 0xe3, 0xa4, 0x44, + 0xce, 0x95, 0xd5, 0xaf, 0x36, 0x29, 0x7f, 0xbe, 0x59, 0xd9, 0xfc, 0x10, 0x58, 0xdb, 0xa4, 0x4a, 0x9f, 0x5a, 0x1c, + 0x0, 0x15, 0xc, 0x7b, 0x6, 0xd1, 0x24, 0xc9, 0xc5, 0xe1, 0x77, 0xa3, 0xc2, 0x32, 0x33, 0xe4, 0x59, 0xfc, 0xe9, + 0xb, 0x30, 0xcd, 0xb5, 0x12, 0x0, 0x13, 0xe5, 0xa3, 0xcc, 0xab, 0x7a, 0xb1, 0x59, 0x57, 0x9c, 0x6, 0xcd, 0x4e, + 0x88, 0x97, 0x42, 0xfb, 0x9f, 0x6c, 0x3b, 0x11, 0x0, 0x0, 0x1f, 0xee, 0x11, 0x0, 0x0, 0x67, 0x4c, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1930); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0xA2); - EXPECT_EQ(granted_qos_levels[1], 0xA2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x97); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0xA1); - EXPECT_EQ(granted_qos_levels[7], 0x8F); - EXPECT_EQ(granted_qos_levels[8], 0x8F); - EXPECT_EQ(granted_qos_levels[9], 0x8F); - EXPECT_EQ(granted_qos_levels[10], 0x80); + EXPECT_EQ(packet_id, 11089); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); } -// SubscribeResponse 32288 [Right QoS1,Right QoS0,Right QoS1,Right QoS2,Left SubErrImplementationSpecificError,Right -// QoS1,Left SubErrQuotaExceeded,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrUnspecifiedError] -// [PropServerKeepAlive 23284,PropAssignedClientIdentifier -// "\190\249\154$@\SO\248G\209e\238:`O\254\242\151<\223",PropUserProperty -// "\ESCS\146a\EOT\245+\162\142\DEL\173\168\f\208C\200;\212\211,\253\238\154!\187\219\182o\130" -// "\235\157\162\209\247>c\EM\186O\NUL\150\220\EOTN\185",PropTopicAliasMaximum 30054,PropMaximumPacketSize -// 1391,PropSessionExpiryInterval 20428,PropSessionExpiryInterval 30001] +// SubscribeResponse 4816 [Left SubErrQuotaExceeded,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right +// QoS0,Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right QoS1,Left SubErrNotAuthorized,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported] [PropMessageExpiryInterval +// 20581,PropServerReference "\180\166@",PropReasonString "",PropUserProperty "\139\179\177\244" +// "0\DC4)\194",PropTopicAlias 948,PropReceiveMaximum 14675,PropSubscriptionIdentifierAvailable +// 199,PropTopicAliasMaximum 19310,PropWillDelayInterval 8080,PropCorrelationData +// "\137\243\196\196\178",PropTopicAliasMaximum 10347,PropMaximumQoS 180,PropMaximumQoS 19,PropServerReference +// "\175WZ\225p\199\160&\249\b\220\250z\155\136\178g\187_\218\192\168\&2\182\n\148\231",PropMessageExpiryInterval +// 15679,PropCorrelationData "\241W\243\&0\213z\NAK\182\194\DC3\148\192e\222\&1lz\DC1.\214",PropMaximumQoS +// 79,PropSubscriptionIdentifier 21] TEST(SubACK5QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0x6b, 0x7e, 0x20, 0x5d, 0x13, 0x5a, 0xf4, 0x12, 0x0, 0x13, 0xbe, 0xf9, 0x9a, 0x24, 0x40, - 0xe, 0xf8, 0x47, 0xd1, 0x65, 0xee, 0x3a, 0x60, 0x4f, 0xfe, 0xf2, 0x97, 0x3c, 0xdf, 0x26, 0x0, - 0x1d, 0x1b, 0x53, 0x92, 0x61, 0x4, 0xf5, 0x2b, 0xa2, 0x8e, 0x7f, 0xad, 0xa8, 0xc, 0xd0, 0x43, - 0xc8, 0x3b, 0xd4, 0xd3, 0x2c, 0xfd, 0xee, 0x9a, 0x21, 0xbb, 0xdb, 0xb6, 0x6f, 0x82, 0x0, 0x10, - 0xeb, 0x9d, 0xa2, 0xd1, 0xf7, 0x3e, 0x63, 0x19, 0xba, 0x4f, 0x0, 0x96, 0xdc, 0x4, 0x4e, 0xb9, - 0x22, 0x75, 0x66, 0x27, 0x0, 0x0, 0x5, 0x6f, 0x11, 0x0, 0x0, 0x4f, 0xcc, 0x11, 0x0, 0x0, - 0x75, 0x31, 0x1, 0x0, 0x1, 0x2, 0x83, 0x1, 0x97, 0x1, 0x91, 0x2, 0x80}; + uint8_t pkt[] = {0x90, 0x86, 0x1, 0x12, 0xd0, 0x78, 0x2, 0x0, 0x0, 0x50, 0x65, 0x1c, 0x0, 0x3, 0xb4, 0xa6, + 0x40, 0x1f, 0x0, 0x0, 0x26, 0x0, 0x4, 0x8b, 0xb3, 0xb1, 0xf4, 0x0, 0x4, 0x30, 0x14, 0x29, + 0xc2, 0x23, 0x3, 0xb4, 0x21, 0x39, 0x53, 0x29, 0xc7, 0x22, 0x4b, 0x6e, 0x18, 0x0, 0x0, 0x1f, + 0x90, 0x9, 0x0, 0x5, 0x89, 0xf3, 0xc4, 0xc4, 0xb2, 0x22, 0x28, 0x6b, 0x24, 0xb4, 0x24, 0x13, + 0x1c, 0x0, 0x1b, 0xaf, 0x57, 0x5a, 0xe1, 0x70, 0xc7, 0xa0, 0x26, 0xf9, 0x8, 0xdc, 0xfa, 0x7a, + 0x9b, 0x88, 0xb2, 0x67, 0xbb, 0x5f, 0xda, 0xc0, 0xa8, 0x32, 0xb6, 0xa, 0x94, 0xe7, 0x2, 0x0, + 0x0, 0x3d, 0x3f, 0x9, 0x0, 0x14, 0xf1, 0x57, 0xf3, 0x30, 0xd5, 0x7a, 0x15, 0xb6, 0xc2, 0x13, + 0x94, 0xc0, 0x65, 0xde, 0x31, 0x6c, 0x7a, 0x11, 0x2e, 0xd6, 0x24, 0x4f, 0xb, 0x15, 0x97, 0xa2, + 0x2, 0x0, 0x1, 0x0, 0x87, 0x1, 0x87, 0x9e, 0xa2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[11]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32288); + EXPECT_EQ(packet_id, 4816); EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x83); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x97); + EXPECT_EQ(granted_qos_levels[0], 0x97); + EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x87); EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0x91); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[10], 0x80); -} - -// SubscribeResponse 8665 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left -// SubErrQuotaExceeded,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS2,Right QoS2] [PropSharedSubscriptionAvailable -// 207,PropAssignedClientIdentifier -// "\249@q\US:\253\n\219\187\170X\168\DLE\154O@\DC4\186\255",PropRequestProblemInformation -// 174,PropRequestResponseInformation 157,PropRetainAvailable 88,PropWillDelayInterval -// 21067,PropSharedSubscriptionAvailable 113,PropResponseTopic "\207",PropWildcardSubscriptionAvailable -// 132,PropResponseInformation "\204$\250*\ACKiR",PropServerReference -// "\221\197\211\233G\GS\191_9i-\168\133f^)C\b",PropUserProperty "\199\143" -// "#N\192\243.R\244\DELT\191|\235,",PropMessageExpiryInterval 24446,PropTopicAliasMaximum -// 3665,PropSharedSubscriptionAvailable 102,PropReasonString -// "JG\149N\147\STXc|\191\210Z\156\246\249\128\252r",PropAssignedClientIdentifier -// "\236q\131\203\r\EM\ENQ!s)\201\245\176Q\185\133\243\145\143",PropWillDelayInterval 12649,PropServerReference ""] + EXPECT_EQ(granted_qos_levels[8], 0x87); + EXPECT_EQ(granted_qos_levels[9], 0x9E); + EXPECT_EQ(granted_qos_levels[10], 0xA2); +} + +// SubscribeResponse 24891 [Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1,Right QoS2,Left +// SubErrTopicFilterInvalid,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [PropContentType +// "\ESC\230\222\175\187\235\US",PropRequestProblemInformation 195,PropServerReference +// "SM\ACKT\184\216p?RH6M=q\DC4\bD\156\128\160\135\244\226(\227\&5\193.\200\132",PropContentType +// "3\218\236\ACK\243`\174\241\225\131\NULm\ETX\183\r\220.\164\144\182\&7k\253J\EM\247\173\171r",PropUserProperty +// "X'\231]\ESCzE\140\179t\191\135\216p" "",PropAuthenticationMethod +// "\156\138\ACK\184\147H\157=\233Y\144\135\b'd\243\251\196\NAKk\nW\171",PropServerReference +// "(\vP2Gn!E\186r*\161zs\198T",PropRequestProblemInformation 227,PropResponseTopic +// "\140C_\237D6\234'@\251\\\155|\184\162\130",PropReasonString +// "g\187s\f\242!t\135\140*\v\140\143B\143\129\188\140\141",PropResponseInformation +// "\193\204\DC4+9Y\200\&0\STX~\253\FS\232;",PropUserProperty +// "\209\STX\223\244\&8\be\242\198\179>\138Z\148\223\CAN\254h-\194\242\254\232@" "\254\246}@\195 +// \238\US\204f\202K\210X\202\225\218\207[\219\152J\171$\137",PropTopicAlias 20875,PropSubscriptionIdentifier +// 10,PropCorrelationData "\216\219~B+\224\185\nm \STX@\EOT\213\217\226\222",PropAuthenticationData +// "(\a\174p\182\180",PropTopicAlias 7307,PropResponseTopic +// "@\163!oz\178\136\155..\167\154\139r\t3",PropRequestProblemInformation 48,PropMessageExpiryInterval +// 22413,PropMessageExpiryInterval 27970,PropMaximumQoS 214,PropPayloadFormatIndicator 142,PropReceiveMaximum 26693] TEST(SubACK5QCTest, Decode18) { - uint8_t pkt[] = {0x90, 0xa5, 0x1, 0x21, 0xd9, 0x9a, 0x1, 0x2a, 0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0xd1, 0x2, 0xdf, 0xf4, 0x38, 0x8, 0x65, 0xf2, 0xc6, 0xb3, 0x3e, 0x8a, 0x5a, 0x94, 0xdf, 0x18, 0xfe, + 0x68, 0x2d, 0xc2, 0xf2, 0xfe, 0xe8, 0x40, 0x0, 0x19, 0xfe, 0xf6, 0x7d, 0x40, 0xc3, 0x20, 0xee, 0x1f, 0xcc, 0x66, + 0xca, 0x4b, 0xd2, 0x58, 0xca, 0xe1, 0xda, 0xcf, 0x5b, 0xdb, 0x98, 0x4a, 0xab, 0x24, 0x89, 0x23, 0x51, 0x8b, 0xb, + 0xa, 0x9, 0x0, 0x11, 0xd8, 0xdb, 0x7e, 0x42, 0x2b, 0xe0, 0xb9, 0xa, 0x6d, 0x20, 0x2, 0x40, 0x4, 0xd5, 0xd9, + 0xe2, 0xde, 0x16, 0x0, 0x6, 0x28, 0x7, 0xae, 0x70, 0xb6, 0xb4, 0x23, 0x1c, 0x8b, 0x8, 0x0, 0x10, 0x40, 0xa3, + 0x21, 0x6f, 0x7a, 0xb2, 0x88, 0x9b, 0x2e, 0x2e, 0xa7, 0x9a, 0x8b, 0x72, 0x9, 0x33, 0x17, 0x30, 0x2, 0x0, 0x0, + 0x57, 0x8d, 0x2, 0x0, 0x0, 0x6d, 0x42, 0x24, 0xd6, 0x1, 0x8e, 0x21, 0x68, 0x45, 0x80, 0x91, 0x9e, 0xa2, 0x1, + 0x2, 0x8f, 0x1, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8665); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x97); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x8F); + EXPECT_EQ(packet_id, 24891); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x91); + EXPECT_EQ(granted_qos_levels[2], 0x9E); + EXPECT_EQ(granted_qos_levels[3], 0xA2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x8F); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], 0xA1); } -// SubscribeResponse 32158 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left -// SubErrWildcardSubscriptionsNotSupported] [PropAssignedClientIdentifier -// "\181\252\207\137\ETBo\129\ESC1\139\131\n3P\230D",PropSubscriptionIdentifierAvailable 255,PropMessageExpiryInterval -// 10411,PropSubscriptionIdentifierAvailable 213,PropCorrelationData -// "\NAK\222\151\139\218l\216\150\245\132g\194cT\186\242d\STX\159:i\132\FS/J\SUBm",PropUserProperty -// "\158\230Q\241b2x0\186\132NB4X\129D\129\128PQ\139\STX\230\203\&8`" "\156",PropRetainAvailable 197,PropRetainAvailable -// 24,PropMessageExpiryInterval 18114,PropContentType "|\239\150\EM\NAK[\220\129o\151\128",PropTopicAliasMaximum -// 18832,PropAuthenticationData -// "\219\SYN\CAN\227\249S\DEL\CAN/\129\ETB\240X\213Sub\176%!\SYN\135*\EM\NAK$",PropSubscriptionIdentifierAvailable -// 236,PropContentType "'\227\STXp`\174\DEL",PropContentType "\EOT\222\FS0\177\218",PropAuthenticationMethod -// "\168\251\181s\167j\SUB\SI} \ENQv\187Oi\US\233\ENQ\213\157x\232\208j/a\132\237M\a",PropAuthenticationMethod -// "a(\145",PropTopicAliasMaximum 7553,PropCorrelationData "",PropWillDelayInterval 5167,PropReasonString -// "",PropReceiveMaximum 15579,PropAssignedClientIdentifier "\ACK.\173",PropServerReference -// "\136\202\179@\163\228\215\&5:I\201\180\221\186\161Tw\130\154\174A\212",PropAssignedClientIdentifier -// "\211s18",PropTopicAliasMaximum 5758,PropServerKeepAlive 16122] +// SubscribeResponse 22923 [Right QoS2,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS1] +// [PropMaximumPacketSize 18797,PropResponseInformation +// "\212J\205\SUB\n\241\166\204\142\167\143\158\224\173T\191\130P\238A`Z\FS\ENQ\NAKVM",PropServerReference +// "\165-!\195\&4\ETX1\\3\128Z7\152",PropRequestResponseInformation 221,PropTopicAliasMaximum 3412,PropMaximumPacketSize +// 23942,PropTopicAliasMaximum 19127,PropTopicAliasMaximum 22275,PropSubscriptionIdentifierAvailable +// 180,PropServerKeepAlive 9519,PropMaximumPacketSize 22991,PropRequestResponseInformation 242,PropMaximumPacketSize +// 2183,PropRetainAvailable 122,PropSessionExpiryInterval 11229,PropSubscriptionIdentifierAvailable +// 107,PropSharedSubscriptionAvailable 85,PropRequestProblemInformation 77,PropServerKeepAlive +// 24672,PropMaximumPacketSize 2021,PropMessageExpiryInterval 27111,PropWildcardSubscriptionAvailable +// 84,PropCorrelationData "NR\249\163\ETX\223\227\231",PropReasonString +// "\225\234\202\136\220\134\RSY&\197_\186n\DC3\t;\195g\192\DC3",PropTopicAlias 22559,PropResponseTopic +// "\183\239",PropResponseTopic "Ghf\r+e\215\245Ly\139\173\172\206\v +// \187\137\&0\131\219\225eK;\216\SYN\151\167",PropAssignedClientIdentifier "\187h\219\&3=\226\182\200L\253\206\SO\144"] TEST(SubACK5QCTest, Decode19) { - uint8_t pkt[] = { - 0x90, 0x91, 0x2, 0x7d, 0x9e, 0x8a, 0x2, 0x12, 0x0, 0x10, 0xb5, 0xfc, 0xcf, 0x89, 0x17, 0x6f, 0x81, 0x1b, 0x31, - 0x8b, 0x83, 0xa, 0x33, 0x50, 0xe6, 0x44, 0x29, 0xff, 0x2, 0x0, 0x0, 0x28, 0xab, 0x29, 0xd5, 0x9, 0x0, 0x1b, - 0x15, 0xde, 0x97, 0x8b, 0xda, 0x6c, 0xd8, 0x96, 0xf5, 0x84, 0x67, 0xc2, 0x63, 0x54, 0xba, 0xf2, 0x64, 0x2, 0x9f, - 0x3a, 0x69, 0x84, 0x1c, 0x2f, 0x4a, 0x1a, 0x6d, 0x26, 0x0, 0x1a, 0x9e, 0xe6, 0x51, 0xf1, 0x62, 0x32, 0x78, 0x30, - 0xba, 0x84, 0x4e, 0x42, 0x34, 0x58, 0x81, 0x44, 0x81, 0x80, 0x50, 0x51, 0x8b, 0x2, 0xe6, 0xcb, 0x38, 0x60, 0x0, - 0x1, 0x9c, 0x25, 0xc5, 0x25, 0x18, 0x2, 0x0, 0x0, 0x46, 0xc2, 0x3, 0x0, 0xb, 0x7c, 0xef, 0x96, 0x19, 0x15, - 0x5b, 0xdc, 0x81, 0x6f, 0x97, 0x80, 0x22, 0x49, 0x90, 0x16, 0x0, 0x1a, 0xdb, 0x16, 0x18, 0xe3, 0xf9, 0x53, 0x7f, - 0x18, 0x2f, 0x81, 0x17, 0xf0, 0x58, 0xd5, 0x53, 0x75, 0x62, 0xb0, 0x25, 0x21, 0x16, 0x87, 0x2a, 0x19, 0x15, 0x24, - 0x29, 0xec, 0x3, 0x0, 0x7, 0x27, 0xe3, 0x2, 0x70, 0x60, 0xae, 0x7f, 0x3, 0x0, 0x6, 0x4, 0xde, 0x1c, 0x30, - 0xb1, 0xda, 0x15, 0x0, 0x1e, 0xa8, 0xfb, 0xb5, 0x73, 0xa7, 0x6a, 0x1a, 0xf, 0x7d, 0x20, 0x5, 0x76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dd, 0x29, 0x6b, 0x2a, 0x55, + 0x17, 0x4d, 0x13, 0x60, 0x60, 0x27, 0x0, 0x0, 0x7, 0xe5, 0x2, 0x0, 0x0, 0x69, 0xe7, 0x28, 0x54, + 0x9, 0x0, 0x8, 0x4e, 0x52, 0xf9, 0xa3, 0x3, 0xdf, 0xe3, 0xe7, 0x1f, 0x0, 0x14, 0xe1, 0xea, 0xca, + 0x88, 0xdc, 0x86, 0x1e, 0x59, 0x26, 0xc5, 0x5f, 0xba, 0x6e, 0x13, 0x9, 0x3b, 0xc3, 0x67, 0xc0, 0x13, + 0x23, 0x58, 0x1f, 0x8, 0x0, 0x2, 0xb7, 0xef, 0x8, 0x0, 0x1d, 0x47, 0x68, 0x66, 0xd, 0x2b, 0x65, + 0xd7, 0xf5, 0x4c, 0x79, 0x8b, 0xad, 0xac, 0xce, 0xb, 0x20, 0xbb, 0x89, 0x30, 0x83, 0xdb, 0xe1, 0x65, + 0x4b, 0x3b, 0xd8, 0x16, 0x97, 0xa7, 0x12, 0x0, 0xd, 0xbb, 0x68, 0xdb, 0x33, 0x3d, 0xe2, 0xb6, 0xc8, + 0x4c, 0xfd, 0xce, 0xe, 0x90, 0x2, 0x1, 0xa1, 0x0, 0xa2, 0x2, 0x2, 0x8f, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32158); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0xA2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0xA2); + EXPECT_EQ(packet_id, 22923); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0xA1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0xA2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], 0x8F); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); } -// SubscribeResponse 9271 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS2,Right QoS0,Left -// SubErrQuotaExceeded,Right QoS0,Right QoS2] [PropReasonString -// "1\202]\141\169\238\189\178TQ\252\STX\172\201\151\132\237\250\158\229x",PropServerReference "\136\148 -// m\248\DC1W/O",PropRequestResponseInformation 28,PropSubscriptionIdentifier 25,PropWillDelayInterval -// 22265,PropWildcardSubscriptionAvailable 195,PropTopicAlias 18986,PropMaximumPacketSize -// 19940,PropSubscriptionIdentifier 11,PropMessageExpiryInterval 22097] +// SubscribeResponse 25337 [Right QoS2,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS1,Right QoS2,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported] [PropPayloadFormatIndicator 154,PropSharedSubscriptionAvailable +// 144,PropMaximumPacketSize 754,PropReceiveMaximum 29505,PropMessageExpiryInterval 25170,PropCorrelationData +// "\251nd\185V\225",PropAuthenticationData "\b\238\196\244\194\139\SI\182\170\245G\242",PropMaximumQoS +// 136,PropMaximumQoS 45,PropSessionExpiryInterval 23317,PropSessionExpiryInterval 15511,PropSubscriptionIdentifier +// 0,PropMaximumPacketSize 28677,PropAssignedClientIdentifier +// "\236\173\NUL\195\229\191\219\131\177\150B\rLw\231A\153\144HeA?\185\130h\157",PropPayloadFormatIndicator +// 13,PropSharedSubscriptionAvailable 132,PropResponseInformation "\253",PropMaximumPacketSize +// 13780,PropAuthenticationMethod "\t\190G^V\252\224\129&%\204\193\238\140\190|\163",PropRequestProblemInformation +// 15,PropAssignedClientIdentifier ",\195\224\190\151\SOH p\197\DC4\141\203\&3\168bczA\141\142\USq\209",PropReasonString +// "\180\SYN",PropUserProperty "hLv\163KA\DC2x\225\199\169l\SOHI\177\135Vb\132\164\146\141\235\DELpM-\232\135" +// "\216\255\147\186%\182]f}\189.\168\NAK\152\235h\243\192p?"] TEST(SubACK5QCTest, Decode20) { - uint8_t pkt[] = {0x90, 0x48, 0x24, 0x37, 0x3e, 0x1f, 0x0, 0x15, 0x31, 0xca, 0x5d, 0x8d, 0xa9, 0xee, 0xbd, - 0xb2, 0x54, 0x51, 0xfc, 0x2, 0xac, 0xc9, 0x97, 0x84, 0xed, 0xfa, 0x9e, 0xe5, 0x78, 0x1c, - 0x0, 0x9, 0x88, 0x94, 0x20, 0x6d, 0xf8, 0x11, 0x57, 0x2f, 0x4f, 0x19, 0x1c, 0xb, 0x19, - 0x18, 0x0, 0x0, 0x56, 0xf9, 0x28, 0xc3, 0x23, 0x4a, 0x2a, 0x27, 0x0, 0x0, 0x4d, 0xe4, - 0xb, 0xb, 0x2, 0x0, 0x0, 0x56, 0x51, 0xa1, 0x1, 0x2, 0x0, 0x97, 0x0, 0x2}; + uint8_t pkt[] = { + 0x90, 0xde, 0x1, 0x62, 0xf9, 0xd3, 0x1, 0x1, 0x9a, 0x2a, 0x90, 0x27, 0x0, 0x0, 0x2, 0xf2, 0x21, 0x73, 0x41, + 0x2, 0x0, 0x0, 0x62, 0x52, 0x9, 0x0, 0x6, 0xfb, 0x6e, 0x64, 0xb9, 0x56, 0xe1, 0x16, 0x0, 0xc, 0x8, 0xee, + 0xc4, 0xf4, 0xc2, 0x8b, 0xf, 0xb6, 0xaa, 0xf5, 0x47, 0xf2, 0x24, 0x88, 0x24, 0x2d, 0x11, 0x0, 0x0, 0x5b, 0x15, + 0x11, 0x0, 0x0, 0x3c, 0x97, 0xb, 0x0, 0x27, 0x0, 0x0, 0x70, 0x5, 0x12, 0x0, 0x1a, 0xec, 0xad, 0x0, 0xc3, + 0xe5, 0xbf, 0xdb, 0x83, 0xb1, 0x96, 0x42, 0xd, 0x4c, 0x77, 0xe7, 0x41, 0x99, 0x90, 0x48, 0x65, 0x41, 0x3f, 0xb9, + 0x82, 0x68, 0x9d, 0x1, 0xd, 0x2a, 0x84, 0x1a, 0x0, 0x1, 0xfd, 0x27, 0x0, 0x0, 0x35, 0xd4, 0x15, 0x0, 0x11, + 0x9, 0xbe, 0x47, 0x5e, 0x56, 0xfc, 0xe0, 0x81, 0x26, 0x25, 0xcc, 0xc1, 0xee, 0x8c, 0xbe, 0x7c, 0xa3, 0x17, 0xf, + 0x12, 0x0, 0x17, 0x2c, 0xc3, 0xe0, 0xbe, 0x97, 0x1, 0x20, 0x70, 0xc5, 0x14, 0x8d, 0xcb, 0x33, 0xa8, 0x62, 0x63, + 0x7a, 0x41, 0x8d, 0x8e, 0x1f, 0x71, 0xd1, 0x1f, 0x0, 0x2, 0xb4, 0x16, 0x26, 0x0, 0x1d, 0x68, 0x4c, 0x76, 0xa3, + 0x4b, 0x41, 0x12, 0x78, 0xe1, 0xc7, 0xa9, 0x6c, 0x1, 0x49, 0xb1, 0x87, 0x56, 0x62, 0x84, 0xa4, 0x92, 0x8d, 0xeb, + 0x7f, 0x70, 0x4d, 0x2d, 0xe8, 0x87, 0x0, 0x14, 0xd8, 0xff, 0x93, 0xba, 0x25, 0xb6, 0x5d, 0x66, 0x7d, 0xbd, 0x2e, + 0xa8, 0x15, 0x98, 0xeb, 0x68, 0xf3, 0xc0, 0x70, 0x3f, 0x2, 0x1, 0x8f, 0x1, 0x2, 0x0, 0x9e}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[7]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9271); + EXPECT_EQ(packet_id, 25337); EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0x97); + EXPECT_EQ(granted_qos_levels[2], 0x8F); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); -} - -// SubscribeResponse 4115 [Left SubErrUnspecifiedError,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrNotAuthorized,Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError] [PropTopicAlias -// 1711,PropReasonString "PZ\t<\222{\r\162",PropResponseTopic "a\129*\198\DEL\n",PropMessageExpiryInterval -// 23699,PropSharedSubscriptionAvailable 220] + EXPECT_EQ(granted_qos_levels[6], 0x9E); +} + +// SubscribeResponse 1262 [Left SubErrPacketIdentifierInUse,Right QoS0,Left SubErrPacketIdentifierInUse,Left +// SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Right QoS0,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrNotAuthorized,Right QoS2] [PropContentType +// "\242&\EOT-\\krC\197\234\&9J3\153GT",PropPayloadFormatIndicator 232,PropSharedSubscriptionAvailable +// 141,PropRetainAvailable 246,PropCorrelationData ">C\SUB\157.\208q\234\138\170lo\247\158\196\202",PropTopicAlias +// 31744,PropWildcardSubscriptionAvailable 209,PropMaximumQoS 222,PropMessageExpiryInterval 13653,PropUserProperty +// "\214G\194\254BG\220\253\136\252\149t\\~2\196\DLE\219\255\141\DC1o^" +// "u\151\220\DC3\151\DLE\248\&5\225\&9V$\145\"\f\173\f_\192}\DC1ynR\254\ESC$\239U@",PropWillDelayInterval +// 21923,PropAuthenticationData "\171h\DC4\156\n\222\136J",PropTopicAliasMaximum 1295,PropResponseTopic +// "z\134\&4\202*2\176\208S\224\\_/j\"",PropUserProperty "K\218\DC10\SUB\203" +// "\ESC\175\216?(~\212\192]\204\&8m\137\145q\195B"] TEST(SubACK5QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0x26, 0x10, 0x13, 0x1e, 0x23, 0x6, 0xaf, 0x1f, 0x0, 0x8, 0x50, 0x5a, 0x9, - 0x3c, 0xde, 0x7b, 0xd, 0xa2, 0x8, 0x0, 0x6, 0x61, 0x81, 0x2a, 0xc6, 0x7f, 0xa, - 0x2, 0x0, 0x0, 0x5c, 0x93, 0x2a, 0xdc, 0x80, 0x9e, 0x87, 0x9e, 0x80}; + uint8_t pkt[] = { + 0x90, 0xa5, 0x2, 0x4, 0xee, 0x97, 0x2, 0x3, 0x0, 0x10, 0xf2, 0x26, 0x4, 0x2d, 0x5c, 0x6b, 0x72, 0x43, 0xc5, + 0xea, 0x39, 0x4a, 0x33, 0x99, 0x47, 0x54, 0x1, 0xe8, 0x2a, 0x8d, 0x25, 0xf6, 0x9, 0x0, 0x10, 0x3e, 0x43, 0x1a, + 0x9d, 0x2e, 0xd0, 0x71, 0xea, 0x8a, 0xaa, 0x6c, 0x6f, 0xf7, 0x9e, 0xc4, 0xca, 0x23, 0x7c, 0x0, 0x28, 0xd1, 0x24, + 0xde, 0x2, 0x0, 0x0, 0x35, 0x55, 0x26, 0x0, 0x17, 0xd6, 0x47, 0xc2, 0xfe, 0x42, 0x47, 0xdc, 0xfd, 0x88, 0xfc, + 0x95, 0x74, 0x5c, 0x7e, 0x32, 0xc4, 0x10, 0xdb, 0xff, 0x8d, 0x11, 0x6f, 0x5e, 0x0, 0x1e, 0x75, 0x97, 0xdc, 0x13, + 0x97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xc3, + 0x42, 0x91, 0x0, 0x91, 0x83, 0x83, 0x0, 0x0, 0x9e, 0x87, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4115); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x9E); - EXPECT_EQ(granted_qos_levels[2], 0x87); - EXPECT_EQ(granted_qos_levels[3], 0x9E); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(packet_id, 1262); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x91); + EXPECT_EQ(granted_qos_levels[3], 0x83); + EXPECT_EQ(granted_qos_levels[4], 0x83); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x9E); + EXPECT_EQ(granted_qos_levels[8], 0x87); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); } -// SubscribeResponse 24961 [Right QoS2,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Left SubErrTopicFilterInvalid,Left -// SubErrQuotaExceeded,Right QoS0,Left SubErrQuotaExceeded,Right QoS2,Right QoS0] [PropServerReference -// "\nClt\172\176z6d\NUL\137\203\212\162QA\155\142\180p<\254\SI_qm",PropSubscriptionIdentifier -// 8,PropAssignedClientIdentifier "P\ETXqo\254\157\150\203Eu\226\141X\233\DEL\218Y\197`\NUL\b\152\134\SOHz\r"] +// SubscribeResponse 21462 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right +// QoS1,Right QoS2,Right QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrTopicFilterInvalid,Left +// SubErrImplementationSpecificError,Right QoS2,Left SubErrNotAuthorized] [PropServerKeepAlive +// 14397,PropSubscriptionIdentifier 32,PropTopicAliasMaximum 5258,PropCorrelationData +// "\ETBr\207\&0\138\175",PropMaximumPacketSize 2747,PropPayloadFormatIndicator 98,PropCorrelationData +// "\185\CANk\215\190*\211\174h\137t\163\154A",PropSubscriptionIdentifier 4,PropAuthenticationData +// "\n9?\132\SUBr\240\DEL\199\131\SYN\230f\132<\218\211\FS\DLE5\223\FS\213\n1\176j\144\129",PropTopicAlias +// 18531,PropSubscriptionIdentifierAvailable 150,PropRequestResponseInformation 101] TEST(SubACK5QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0x80, 0x1, 0x47, 0xa4, 0x79, 0x16, 0x0, 0x1a, 0xce, 0x7d, 0x1d, 0x3f, 0xf5, 0xf0, 0x1d, 0xd4, - 0x5, 0xc8, 0xfc, 0x2b, 0xe7, 0x44, 0x11, 0xe0, 0x36, 0xf8, 0x13, 0x91, 0xb5, 0xca, 0xa9, 0xcf, 0xfa, - 0x2d, 0x11, 0x0, 0x0, 0x9, 0x1d, 0x8, 0x0, 0xe, 0x46, 0x6a, 0x38, 0xdd, 0xb1, 0x4f, 0x3d, 0x6f, - 0x5f, 0x9e, 0x9, 0xaf, 0xe6, 0x0, 0x27, 0x0, 0x0, 0x15, 0x35, 0x15, 0x0, 0x1b, 0x8b, 0xdd, 0x11, - 0xfd, 0x7a, 0x92, 0x19, 0x5a, 0x66, 0xf, 0xd5, 0x37, 0x2a, 0x34, 0xae, 0xfe, 0x1e, 0x20, 0x16, 0x37, - 0xe2, 0xa3, 0xb3, 0x1, 0xce, 0x42, 0x0, 0x17, 0x36, 0x16, 0x0, 0x14, 0x6e, 0xf2, 0x59, 0xf0, 0x51, - 0x18, 0xcd, 0x35, 0x2b, 0x2a, 0xc5, 0xe7, 0x24, 0xa9, 0xb3, 0x1f, 0x7b, 0x4d, 0xab, 0xbb, 0x22, 0x7b, - 0xc5, 0x2a, 0x36, 0x2, 0x0, 0x0, 0x77, 0xc5, 0x2, 0x8f, 0x1, 0x83}; + uint8_t pkt[] = {0x90, 0x76, 0x2f, 0x2c, 0x6e, 0xb, 0x0, 0x25, 0xca, 0x26, 0x0, 0x1a, 0xe8, 0xb4, 0x81, + 0xd1, 0x70, 0xd8, 0x6f, 0x93, 0xff, 0x7a, 0x6f, 0xf6, 0x12, 0x25, 0x62, 0xe1, 0xae, 0x54, + 0x38, 0x35, 0x1e, 0xed, 0xea, 0x43, 0xa2, 0x24, 0x0, 0xa, 0xa1, 0xf7, 0x7b, 0xcc, 0x48, + 0xbd, 0xe9, 0x3e, 0x8a, 0xaf, 0x27, 0x0, 0x0, 0xa, 0xbb, 0x1, 0x62, 0x9, 0x0, 0xe, + 0xb9, 0x18, 0x6b, 0xd7, 0xbe, 0x2a, 0xd3, 0xae, 0x68, 0x89, 0x74, 0xa3, 0x9a, 0x41, 0xb, + 0x4, 0x16, 0x0, 0x1d, 0xa, 0x39, 0x3f, 0x84, 0x1a, 0x72, 0xf0, 0x7f, 0xc7, 0x83, 0x16, + 0xe6, 0x66, 0x84, 0x3c, 0xda, 0xd3, 0x1c, 0x10, 0x35, 0xdf, 0x1c, 0xd5, 0xa, 0x31, 0xb0, + 0x6a, 0x90, 0x81, 0x23, 0x48, 0x63, 0x29, 0x96, 0x19, 0x65, 0xa1, 0x83, 0x2, 0x0, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18340); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x8F); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x83); + EXPECT_EQ(packet_id, 12076); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); } -// SubscribeResponse 8517 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left -// SubErrSubscriptionIdentifiersNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS0] -// [PropServerReference "\164\213\242\159g\236h\176\&9x\EOTT%V\153\229\"w\234\184\182\236",PropSessionExpiryInterval -// 16327,PropServerReference "\200^\129",PropTopicAliasMaximum 11537,PropSubscriptionIdentifierAvailable -// 214,PropReasonString "A\216Y\246\141\163\189)\136\&2\237t\128\176%\SIB&",PropReceiveMaximum -// 16877,PropWillDelayInterval 22070,PropUserProperty -// "\227\f\224k\f\212\251\ENQ\221\172\az\210v]P\RS\DLE|\204\185\253e\130r\214\197\175=7" -// "5\ACK\214\194\&1\211'\238bA\USs\177\STX",PropAssignedClientIdentifier -// "\ETB\225[X#\SO\182,\234\214\203N\SOH\242\202\ETB\178\161\143\148\165\&0*\v\162L\174\242\fM",PropSharedSubscriptionAvailable -// 209,PropMessageExpiryInterval 26844,PropReceiveMaximum 13624,PropResponseTopic "\144",PropAuthenticationData -// ",\DC2\164\176\SI\ETB\"w\237_1\192\174",PropMaximumQoS 183,PropRequestResponseInformation 146,PropAuthenticationData -// "\186U\227f\140\f\136s\160\191\239\DC2M)D\DC1\196\\{5\176\151\189\SOH\241\DEL\128",PropRetainAvailable -// 246,PropMessageExpiryInterval 15562,PropContentType -// "\213P\201G\210\239\216\223\223\238\&7\203\215P\145a\229\157\DC2\156\DC1",PropPayloadFormatIndicator -// 118,PropAssignedClientIdentifier "",PropRequestProblemInformation 202,PropWillDelayInterval 30258] +// SubscribeResponse 3799 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrImplementationSpecificError,Left SubErrTopicFilterInvalid,Right QoS2,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS0] [PropSubscriptionIdentifier +// 16,PropAuthenticationMethod "",PropMaximumQoS 79,PropMessageExpiryInterval 18369,PropSubscriptionIdentifier +// 30,PropUserProperty "GQ\178\234\199\215\189\173TYU\202\221\201\238\192j\156\DC3e\196\150\b\236<" " +// \236\149-!\251\238\EOT9E\158\204",PropMaximumPacketSize 22281,PropServerKeepAlive 17526,PropResponseTopic +// "\231\146",PropAuthenticationData "9\141\&6s\243s\152\156\247\183\191.\DC3\192/^\225\193u",PropServerKeepAlive +// 28155,PropAssignedClientIdentifier "\144\140#;\RS\154\234\231",PropCorrelationData +// "Ug\228\168\NAK`\RS{\157O\152\&5\157)\237",PropMaximumPacketSize 12102,PropRetainAvailable 214,PropMaximumPacketSize +// 24583,PropTopicAliasMaximum 10997,PropRetainAvailable 249,PropServerKeepAlive 5371,PropUserProperty +// "yR\ACK1\228c\145\139S\SO-\161\239\170\215\252\165\254" +// "a\197\136\224\158\ESC\NUL\237\&9\139\157l\GS\f\f9\SO6",PropRetainAvailable 37,PropSharedSubscriptionAvailable +// 8,PropRequestResponseInformation 161,PropPayloadFormatIndicator 192,PropWillDelayInterval +// 14103,PropMessageExpiryInterval 3544,PropPayloadFormatIndicator 166,PropServerKeepAlive 1582] TEST(SubACK5QCTest, Decode24) { - uint8_t pkt[] = {0x90, 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, 0x90, 0x8c, 0x23, 0x3b, 0x1e, 0x9a, 0xea, 0xe7, 0x9, 0x0, + 0xf, 0x55, 0x67, 0xe4, 0xa8, 0x15, 0x60, 0x1e, 0x7b, 0x9d, 0x4f, 0x98, 0x35, 0x9d, 0x29, 0xed, 0x27, 0x0, 0x0, + 0x2f, 0x46, 0x25, 0xd6, 0x27, 0x0, 0x0, 0x60, 0x7, 0x22, 0x2a, 0xf5, 0x25, 0xf9, 0x13, 0x14, 0xfb, 0x26, 0x0, + 0x12, 0x79, 0x52, 0x6, 0x31, 0xe4, 0x63, 0x91, 0x8b, 0x53, 0xe, 0x2d, 0xa1, 0xef, 0xaa, 0xd7, 0xfc, 0xa5, 0xfe, + 0x0, 0x12, 0x61, 0xc5, 0x88, 0xe0, 0x9e, 0x1b, 0x0, 0xed, 0x39, 0x8b, 0x9d, 0x6c, 0x1d, 0xc, 0xc, 0x39, 0xe, + 0x36, 0x25, 0x25, 0x2a, 0x8, 0x19, 0xa1, 0x1, 0xc0, 0x18, 0x0, 0x0, 0x37, 0x17, 0x2, 0x0, 0x0, 0xd, 0xd8, + 0x1, 0xa6, 0x13, 0x6, 0x2e, 0x2, 0xa2, 0x83, 0x8f, 0x2, 0xa2, 0x2, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8517); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0xA1); - EXPECT_EQ(granted_qos_levels[3], 0xA2); + EXPECT_EQ(packet_id, 3799); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(granted_qos_levels[2], 0x83); + EXPECT_EQ(granted_qos_levels[3], 0x8F); EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0xA2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); } -// SubscribeResponse 31168 [Right QoS2,Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrNotAuthorized,Right QoS0,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left -// SubErrPacketIdentifierInUse,Left SubErrNotAuthorized] [PropSubscriptionIdentifierAvailable 144,PropUserProperty -// "\169r\208\173G\SOH\223\RS\220\129\249\198p2M\251w\151;Y\218\235\145\253Y\165n\242" -// "\ACK\196\134=\SI\145\227\EOTe\183\195\218\147\237",PropMessageExpiryInterval 21387,PropAssignedClientIdentifier -// "\146\201\243t\165\179\220\ENQ\138B\217d\132\rj\CAN\144"] +// SubscribeResponse 15314 [Left SubErrUnspecifiedError,Left SubErrTopicFilterInvalid,Left +// SubErrImplementationSpecificError] [PropServerKeepAlive 8169,PropAssignedClientIdentifier +// "\158\DC2x\SUB\168\174\218",PropMessageExpiryInterval 31274] TEST(SubACK5QCTest, Decode25) { - uint8_t pkt[] = {0x90, 0x56, 0x79, 0xc0, 0x4a, 0x29, 0x90, 0x26, 0x0, 0x1c, 0xa9, 0x72, 0xd0, 0xad, 0x47, - 0x1, 0xdf, 0x1e, 0xdc, 0x81, 0xf9, 0xc6, 0x70, 0x32, 0x4d, 0xfb, 0x77, 0x97, 0x3b, 0x59, - 0xda, 0xeb, 0x91, 0xfd, 0x59, 0xa5, 0x6e, 0xf2, 0x0, 0xe, 0x6, 0xc4, 0x86, 0x3d, 0xf, - 0x91, 0xe3, 0x4, 0x65, 0xb7, 0xc3, 0xda, 0x93, 0xed, 0x2, 0x0, 0x0, 0x53, 0x8b, 0x12, - 0x0, 0x11, 0x92, 0xc9, 0xf3, 0x74, 0xa5, 0xb3, 0xdc, 0x5, 0x8a, 0x42, 0xd9, 0x64, 0x84, - 0xd, 0x6a, 0x18, 0x90, 0x2, 0x8f, 0xa1, 0x87, 0x0, 0x9e, 0x1, 0x91, 0x87}; + uint8_t pkt[] = {0x90, 0x18, 0x3b, 0xd2, 0x12, 0x13, 0x1f, 0xe9, 0x12, 0x0, 0x7, 0x9e, 0x12, + 0x78, 0x1a, 0xa8, 0xae, 0xda, 0x2, 0x0, 0x0, 0x7a, 0x2a, 0x80, 0x8f, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 31168); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 15314); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x8F); - EXPECT_EQ(granted_qos_levels[2], 0xA1); - EXPECT_EQ(granted_qos_levels[3], 0x87); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], 0x9E); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], 0x91); - EXPECT_EQ(granted_qos_levels[8], 0x87); + EXPECT_EQ(granted_qos_levels[2], 0x83); } -// SubscribeResponse 6558 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left -// SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Right -// QoS1,Left SubErrTopicFilterInvalid] [PropServerReference "",PropSubscriptionIdentifierAvailable -// 103,PropReceiveMaximum 28000,PropMessageExpiryInterval 22245,PropServerReference -// "\DC4\229\&0\DC2\147\DC3\237\213\155\SUB\193\US\\\221\178H\243\STX\238\128S\207o\141",PropMessageExpiryInterval -// 12590,PropSessionExpiryInterval 2530,PropCorrelationData -// "7\211h\190\&6\237\163\131\128j\233\226\a\173`\254`e\151\rm*\222=\248\159",PropPayloadFormatIndicator -// 19,PropReasonString "\150\f\186P!~V\SOH\179\210\DC2L/\247\STX\190 1\SUB5l\173",PropMessageExpiryInterval -// 3585,PropSessionExpiryInterval 9887,PropRetainAvailable 104,PropSubscriptionIdentifierAvailable -// 50,PropSubscriptionIdentifierAvailable 222,PropAssignedClientIdentifier -// "F\227\DLE\165\228\199dI\210\SUB\DC3\215E\139",PropAuthenticationData "|\207N\146A",PropTopicAlias -// 32016,PropTopicAliasMaximum 26219] +// SubscribeResponse 19515 [Left SubErrNotAuthorized,Right QoS1,Right QoS2,Left SubErrPacketIdentifierInUse,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Left SubErrUnspecifiedError,Left +// SubErrSubscriptionIdentifiersNotSupported] [PropResponseTopic +// "\237\247`\NAK$\145\201\234*\STX\SYN\132d\ETX\EOT\DC2\236J\146\150\173\ENQX\ETX\219\170",PropRequestProblemInformation +// 238,PropRequestProblemInformation 125,PropResponseTopic "[L\137:RM\218\156C\172O!v\205",PropSessionExpiryInterval +// 3981,PropMessageExpiryInterval 2864,PropSharedSubscriptionAvailable 238,PropRequestProblemInformation +// 69,PropRetainAvailable 199,PropWildcardSubscriptionAvailable 7,PropMessageExpiryInterval 1188,PropMaximumQoS +// 57,PropRequestProblemInformation 236,PropWillDelayInterval 7491,PropAssignedClientIdentifier +// "r\250\136\152B&\204\241/0U\bs\216\ESCVG\217\255",PropResponseInformation +// "\133\184\225\145\135\217]FK\203\f\DC3\187\139l\173\184"] TEST(SubACK5QCTest, Decode26) { - uint8_t pkt[] = {0x90, 0xa4, 0x1, 0x19, 0x9e, 0x99, 0x1, 0x1c, 0x0, 0x0, 0x29, 0x67, 0x21, 0x6d, 0x60, 0x2, 0x0, - 0x0, 0x56, 0xe5, 0x1c, 0x0, 0x18, 0x14, 0xe5, 0x30, 0x12, 0x93, 0x13, 0xed, 0xd5, 0x9b, 0x1a, 0xc1, - 0x1f, 0x5c, 0xdd, 0xb2, 0x48, 0xf3, 0x2, 0xee, 0x80, 0x53, 0xcf, 0x6f, 0x8d, 0x2, 0x0, 0x0, 0x31, - 0x2e, 0x11, 0x0, 0x0, 0x9, 0xe2, 0x9, 0x0, 0x1a, 0x37, 0xd3, 0x68, 0xbe, 0x36, 0xed, 0xa3, 0x83, - 0x80, 0x6a, 0xe9, 0xe2, 0x7, 0xad, 0x60, 0xfe, 0x60, 0x65, 0x97, 0xd, 0x6d, 0x2a, 0xde, 0x3d, 0xf8, - 0x9f, 0x1, 0x13, 0x1f, 0x0, 0x16, 0x96, 0xc, 0xba, 0x50, 0x21, 0x7e, 0x56, 0x1, 0xb3, 0xd2, 0x12, - 0x4c, 0x2f, 0xf7, 0x2, 0xbe, 0x20, 0x31, 0x1a, 0x35, 0x6c, 0xad, 0x2, 0x0, 0x0, 0xe, 0x1, 0x11, - 0x0, 0x0, 0x26, 0x9f, 0x25, 0x68, 0x29, 0x32, 0x29, 0xde, 0x12, 0x0, 0xe, 0x46, 0xe3, 0x10, 0xa5, - 0xe4, 0xc7, 0x64, 0x49, 0xd2, 0x1a, 0x13, 0xd7, 0x45, 0x8b, 0x16, 0x0, 0x5, 0x7c, 0xcf, 0x4e, 0x92, - 0x41, 0x23, 0x7d, 0x10, 0x22, 0x66, 0x6b, 0x9e, 0x0, 0x83, 0x83, 0x83, 0x1, 0x8f}; + uint8_t pkt[] = {0x90, 0x88, 0x1, 0x4c, 0x3b, 0x7c, 0x8, 0x0, 0x1a, 0xed, 0xf7, 0x60, 0x15, 0x24, 0x91, 0xc9, + 0xea, 0x2a, 0x2, 0x16, 0x84, 0x64, 0x3, 0x4, 0x12, 0xec, 0x4a, 0x92, 0x96, 0xad, 0x5, 0x58, + 0x3, 0xdb, 0xaa, 0x17, 0xee, 0x17, 0x7d, 0x8, 0x0, 0xe, 0x5b, 0x4c, 0x89, 0x3a, 0x52, 0x4d, + 0xda, 0x9c, 0x43, 0xac, 0x4f, 0x21, 0x76, 0xcd, 0x11, 0x0, 0x0, 0xf, 0x8d, 0x2, 0x0, 0x0, + 0xb, 0x30, 0x2a, 0xee, 0x17, 0x45, 0x25, 0xc7, 0x28, 0x7, 0x2, 0x0, 0x0, 0x4, 0xa4, 0x24, + 0x39, 0x17, 0xec, 0x18, 0x0, 0x0, 0x1d, 0x43, 0x12, 0x0, 0x13, 0x72, 0xfa, 0x88, 0x98, 0x42, + 0x26, 0xcc, 0xf1, 0x2f, 0x30, 0x55, 0x8, 0x73, 0xd8, 0x1b, 0x56, 0x47, 0xd9, 0xff, 0x1a, 0x0, + 0x11, 0x85, 0xb8, 0xe1, 0x91, 0x87, 0xd9, 0x5d, 0x46, 0x4b, 0xcb, 0xc, 0x13, 0xbb, 0x8b, 0x6c, + 0xad, 0xb8, 0x87, 0x1, 0x2, 0x91, 0x9e, 0x80, 0x0, 0x80, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6558); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x83); - EXPECT_EQ(granted_qos_levels[3], 0x83); - EXPECT_EQ(granted_qos_levels[4], 0x83); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x8F); + EXPECT_EQ(packet_id, 19515); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x87); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x91); + EXPECT_EQ(granted_qos_levels[4], 0x9E); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0xA1); } -// SubscribeResponse 25528 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left -// SubErrUnspecifiedError,Left SubErrImplementationSpecificError,Right QoS2] [PropMessageExpiryInterval -// 30797,PropRetainAvailable 33,PropServerKeepAlive 21346,PropUserProperty "G\145\253\\M\131\224" -// "U",PropSubscriptionIdentifierAvailable 177] +// SubscribeResponse 14835 [Right QoS2,Right QoS2,Right QoS1,Left SubErrUnspecifiedError,Left +// SubErrImplementationSpecificError,Left SubErrNotAuthorized,Right QoS2] [PropCorrelationData +// "\188\STXP\176*.\244\176`\198\DC1l=Ra\251\226\231",PropMaximumPacketSize 9578,PropTopicAlias +// 26389,PropAuthenticationData "*\184\157",PropMessageExpiryInterval 13687,PropSubscriptionIdentifierAvailable +// 195,PropRequestProblemInformation 144,PropSessionExpiryInterval 25484,PropReasonString "}\221_\211-",PropContentType +// "}r\DC4#\ENQ\233\200\n\152(\173z|\STX\154!2/\RS\241",PropResponseInformation +// "\253\172R\ENQ\185\232WI\DEL\146\172\165{\209\DC4\DC4\135}\NUL}\157{\222\f",PropRequestResponseInformation +// 253,PropMessageExpiryInterval 20061,PropMessageExpiryInterval 26031,PropRequestResponseInformation +// 28,PropUserProperty "\247\&6\144b\177\157\141\161|\GSR\161F\229Jd\233p\DC1>N\206Nx\248)\249\ESC9" +// "W*L\132%]d\SI\FS\153\NAK\214\147g",PropUserProperty +// "\238\143\244q\176E\235\132\156\206\ENQ\235\DC2\184\134S\144Jo\SOc\151OL[" +// "V\223H\156\252ak4\150\212^1\169'\230\196\n6n\166",PropRequestResponseInformation 233,PropMaximumPacketSize +// 3867,PropRequestProblemInformation 24,PropRetainAvailable 135,PropSessionExpiryInterval +// 21423,PropAuthenticationMethod "",PropMessageExpiryInterval 29400,PropAuthenticationData +// "cM\159g#x\244r\t\211Z\245\132\178\145?\217mPV\194\t\179\148\r",PropUserProperty ")\by" +// "j\201V\169\237ipN",PropMaximumPacketSize 31853,PropSharedSubscriptionAvailable +// 54,PropSubscriptionIdentifierAvailable 164] TEST(SubACK5QCTest, Decode27) { - uint8_t pkt[] = {0x90, 0x21, 0x63, 0xb8, 0x19, 0x2, 0x0, 0x0, 0x78, 0x4d, 0x25, 0x21, - 0x13, 0x53, 0x62, 0x26, 0x0, 0x7, 0x47, 0x91, 0xfd, 0x5c, 0x4d, 0x83, - 0xe0, 0x0, 0x1, 0x55, 0x29, 0xb1, 0x9e, 0x80, 0x80, 0x83, 0x2}; + uint8_t pkt[] = { + 0x90, 0xb3, 0x2, 0x39, 0xf3, 0xa8, 0x2, 0x9, 0x0, 0x12, 0xbc, 0x2, 0x50, 0xb0, 0x2a, 0x2e, 0xf4, 0xb0, 0x60, + 0xc6, 0x11, 0x6c, 0x3d, 0x52, 0x61, 0xfb, 0xe2, 0xe7, 0x27, 0x0, 0x0, 0x25, 0x6a, 0x23, 0x67, 0x15, 0x16, 0x0, + 0x3, 0x2a, 0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 0xe9, + 0x27, 0x0, 0x0, 0xf, 0x1b, 0x17, 0x18, 0x25, 0x87, 0x11, 0x0, 0x0, 0x53, 0xaf, 0x15, 0x0, 0x0, 0x2, 0x0, + 0x0, 0x72, 0xd8, 0x16, 0x0, 0x19, 0x63, 0x4d, 0x9f, 0x67, 0x23, 0x78, 0xf4, 0x72, 0x9, 0xd3, 0x5a, 0xf5, 0x84, + 0xb2, 0x91, 0x3f, 0xd9, 0x6d, 0x50, 0x56, 0xc2, 0x9, 0xb3, 0x94, 0xd, 0x26, 0x0, 0x3, 0x29, 0x8, 0x79, 0x0, + 0x8, 0x6a, 0xc9, 0x56, 0xa9, 0xed, 0x69, 0x70, 0x4e, 0x27, 0x0, 0x0, 0x7c, 0x6d, 0x2a, 0x36, 0x29, 0xa4, 0x2, + 0x2, 0x1, 0x80, 0x83, 0x87, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25528); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x83); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 14835); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x83); + EXPECT_EQ(granted_qos_levels[5], 0x87); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); } -// SubscribeResponse 29497 [Right QoS2,Right QoS2,Right QoS2,Right QoS1,Right QoS2,Left SubErrPacketIdentifierInUse] -// [PropResponseTopic "\142\214",PropWildcardSubscriptionAvailable 159,PropServerKeepAlive 3120,PropResponseInformation -// "\196\181[.\250\238^\FS\197\218\DC38\202}h\136\fI\200&\209\192K\ENQ\253",PropRetainAvailable 200,PropRetainAvailable -// 136,PropTopicAliasMaximum 29048,PropRequestProblemInformation 129,PropUserProperty -// "2\230\CAN\157y\DC1w\130\179\189`\186Mz\SUBlK\237s\167. 4\168\ESC\205" -// "\207\129\251\149+\EOT\191\136",PropMaximumPacketSize 10414,PropReceiveMaximum 26546,PropRequestResponseInformation -// 24,PropResponseTopic "h\210\DEL\207m\156\151\219\136\231\157",PropAssignedClientIdentifier -// "t^$\170\239\&7\220S\133t\ACK",PropRequestResponseInformation 37,PropTopicAlias 26638,PropAuthenticationData -// "\244L?\243\SIr\RS~\136\a\196\207*\242\245\168U\161\222\167\131:M",PropAuthenticationMethod -// "UU\ESC\148\195\220\138\NAKS\207\140-\ENQ\228\137<\243\216\GS\164,\ENQ4\188\141\133",PropServerReference -// "\225\212\199\164\210\214\174\255\169",PropWillDelayInterval 4639,PropRequestProblemInformation 4,PropReasonString -// "?M\NAK>\DLE%\181j\SUB\US#\157\ETX\182\RSym\147\155\217\176\152\145)} \CANI",PropRequestProblemInformation 48] +// SubscribeResponse 3036 [Right QoS0,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError] +// [PropReceiveMaximum 25407,PropAuthenticationData +// "\224\236\221\b-K\221a\233\161,\229\f\228w5\176/\225\150\233C\245\178\ACK:\233\143\GS",PropResponseInformation +// "\136]j\GS\228*\181\236{\ACKbPk\166\243\218\131\\\nK.\SI\\\ENQc\145j%\232s",PropPayloadFormatIndicator +// 134,PropRetainAvailable 110,PropCorrelationData +// "\133T8\227~M+#|\156\164C\216\157\189\175\202@\160",PropCorrelationData +// "\182\244\248Gq\173b\226\180n\134\130\205QWY\133\226N\201\US\t\187\173\253~\187q\206"] TEST(SubACK5QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0xf6, 0x1, 0x73, 0x39, 0xec, 0x1, 0x8, 0x0, 0x2, 0x8e, 0xd6, 0x28, 0x9f, 0x13, 0xc, 0x30, - 0x1a, 0x0, 0x19, 0xc4, 0xb5, 0x5b, 0x2e, 0xfa, 0xee, 0x5e, 0x1c, 0xc5, 0xda, 0x13, 0x38, 0xca, 0x7d, - 0x68, 0x88, 0xc, 0x49, 0xc8, 0x26, 0xd1, 0xc0, 0x4b, 0x5, 0xfd, 0x25, 0xc8, 0x25, 0x88, 0x22, 0x71, - 0x78, 0x17, 0x81, 0x26, 0x0, 0x1a, 0x32, 0xe6, 0x18, 0x9d, 0x79, 0x11, 0x77, 0x82, 0xb3, 0xbd, 0x60, - 0xba, 0x4d, 0x7a, 0x1a, 0x6c, 0x4b, 0xed, 0x73, 0xa7, 0x2e, 0x20, 0x34, 0xa8, 0x1b, 0xcd, 0x0, 0x8, - 0xcf, 0x81, 0xfb, 0x95, 0x2b, 0x4, 0xbf, 0x88, 0x27, 0x0, 0x0, 0x28, 0xae, 0x21, 0x67, 0xb2, 0x19, - 0x18, 0x8, 0x0, 0xb, 0x68, 0xd2, 0x7f, 0xcf, 0x6d, 0x9c, 0x97, 0xdb, 0x88, 0xe7, 0x9d, 0x12, 0x0, - 0xb, 0x74, 0x5e, 0x24, 0xaa, 0xef, 0x37, 0xdc, 0x53, 0x85, 0x74, 0x6, 0x19, 0x25, 0x23, 0x68, 0xe, - 0x16, 0x0, 0x17, 0xf4, 0x4c, 0x3f, 0xf3, 0xf, 0x72, 0x1e, 0x7e, 0x88, 0x7, 0xc4, 0xcf, 0x2a, 0xf2, - 0xf5, 0xa8, 0x55, 0xa1, 0xde, 0xa7, 0x83, 0x3a, 0x4d, 0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d, 0xbd, 0xaf, 0xca, 0x40, 0xa0, 0x9, 0x0, + 0x1d, 0xb6, 0xf4, 0xf8, 0x47, 0x71, 0xad, 0x62, 0xe2, 0xb4, 0x6e, 0x86, 0x82, 0xcd, 0x51, 0x57, 0x59, + 0x85, 0xe2, 0x4e, 0xc9, 0x1f, 0x9, 0xbb, 0xad, 0xfd, 0x7e, 0xbb, 0x71, 0xce, 0x0, 0x87, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29497); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x91); + EXPECT_EQ(packet_id, 3036); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x87); + EXPECT_EQ(granted_qos_levels[2], 0x83); } -// SubscribeResponse 9048 [Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS1,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS1,Right QoS2,Right QoS2,Left -// SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded] [PropServerKeepAlive 29652,PropServerReference -// "N\209\227[l\245\198\167\182\145\188\246\138\176\RS\a<\134\208\201\&79Z\204",PropReasonString -// "\NUL\NUL\212\248\213\239\233\206%1\207\168\183s^\US\150\DC3\160\RS\155\STX/T\129\SO:\222\158\252",PropMessageExpiryInterval -// 11470,PropWillDelayInterval 10358,PropMaximumPacketSize 11999,PropSessionExpiryInterval 29249,PropCorrelationData -// "\216\NUL\209\252;v \168bc\tV6C4j\r`\255\252@\EOT\147$\151\214",PropAssignedClientIdentifier -// "\167\146n/\CAN\130T[\203B\141",PropSubscriptionIdentifierAvailable 217,PropSubscriptionIdentifier -// 28,PropServerReference "\SYN\221RL\DC1`\DLE\156",PropContentType -// "\219r\154{\159F\194\159\236\US\154\146p\141\250",PropSharedSubscriptionAvailable -// 153,PropSubscriptionIdentifierAvailable 48,PropPayloadFormatIndicator 21,PropResponseTopic -// "\136\148W\180A\251X\189\216\174\242\tr\221\248\230\199\208\196\241",PropContentType -// "D\\\242\156:qp\159z\194`\175#\STX\189\SO\130\137/\191\234"] +// SubscribeResponse 8613 [Right QoS2] [PropResponseInformation "\a",PropMaximumQoS +// 233,PropWildcardSubscriptionAvailable 130] TEST(SubACK5QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0xe3, 0x1, 0x23, 0x58, 0xd4, 0x1, 0x13, 0x73, 0xd4, 0x1c, 0x0, 0x18, 0x4e, 0xd1, 0xe3, 0x5b, - 0x6c, 0xf5, 0xc6, 0xa7, 0xb6, 0x91, 0xbc, 0xf6, 0x8a, 0xb0, 0x1e, 0x7, 0x3c, 0x86, 0xd0, 0xc9, 0x37, - 0x39, 0x5a, 0xcc, 0x1f, 0x0, 0x1e, 0x0, 0x0, 0xd4, 0xf8, 0xd5, 0xef, 0xe9, 0xce, 0x25, 0x31, 0xcf, - 0xa8, 0xb7, 0x73, 0x5e, 0x1f, 0x96, 0x13, 0xa0, 0x1e, 0x9b, 0x2, 0x2f, 0x54, 0x81, 0xe, 0x3a, 0xde, - 0x9e, 0xfc, 0x2, 0x0, 0x0, 0x2c, 0xce, 0x18, 0x0, 0x0, 0x28, 0x76, 0x27, 0x0, 0x0, 0x2e, 0xdf, - 0x11, 0x0, 0x0, 0x72, 0x41, 0x9, 0x0, 0x1a, 0xd8, 0x0, 0xd1, 0xfc, 0x3b, 0x76, 0x20, 0xa8, 0x62, - 0x63, 0x9, 0x56, 0x36, 0x43, 0x34, 0x6a, 0xd, 0x60, 0xff, 0xfc, 0x40, 0x4, 0x93, 0x24, 0x97, 0xd6, - 0x12, 0x0, 0xb, 0xa7, 0x92, 0x6e, 0x2f, 0x18, 0x82, 0x54, 0x5b, 0xcb, 0x42, 0x8d, 0x29, 0xd9, 0xb, - 0x1c, 0x1c, 0x0, 0x8, 0x16, 0xdd, 0x52, 0x4c, 0x11, 0x60, 0x10, 0x9c, 0x3, 0x0, 0xf, 0xdb, 0x72, - 0x9a, 0x7b, 0x9f, 0x46, 0xc2, 0x9f, 0xec, 0x1f, 0x9a, 0x92, 0x70, 0x8d, 0xfa, 0x2a, 0x99, 0x29, 0x30, - 0x1, 0x15, 0x8, 0x0, 0x14, 0x88, 0x94, 0x57, 0xb4, 0x41, 0xfb, 0x58, 0xbd, 0xd8, 0xae, 0xf2, 0x9, - 0x72, 0xdd, 0xf8, 0xe6, 0xc7, 0xd0, 0xc4, 0xf1, 0x3, 0x0, 0x15, 0x44, 0x5c, 0xf2, 0x9c, 0x3a, 0x71, - 0x70, 0x9f, 0x7a, 0xc2, 0x60, 0xaf, 0x23, 0x2, 0xbd, 0xe, 0x82, 0x89, 0x2f, 0xbf, 0xea, 0x87, 0x80, - 0x87, 0x1, 0x9e, 0x1, 0x1, 0x2, 0x2, 0xa2, 0x97}; + uint8_t pkt[] = {0x90, 0xc, 0x21, 0xa5, 0x8, 0x1a, 0x0, 0x1, 0x7, 0x24, 0xe9, 0x28, 0x82, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9048); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x87); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x87); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], 0x9E); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], 0xA2); - EXPECT_EQ(granted_qos_levels[10], 0x97); -} - -// SubscribeResponse 18118 [Right QoS1] [PropTopicAlias 32552,PropCorrelationData -// "\219\205T\187\223\203V\US\254$:\211\206\181\253\162\EOT",PropUserProperty -// "\a\128D[\207\ETBuDt\141CZ\160\240\222\195\233\n\153\133U\ETB\168" -// "v\243\229\bv{\251\193'\186\143\ETX\DC2\254\147\244Q\128\FS\r\DEL$\ts*\233\191g\249",PropRequestProblemInformation -// 47,PropSessionExpiryInterval 29723,PropServerKeepAlive 6447,PropRequestProblemInformation -// 42,PropMessageExpiryInterval 16508,PropServerReference "\128b~\229\132",PropAuthenticationMethod -// "\215\SUB",PropSubscriptionIdentifierAvailable 109,PropAssignedClientIdentifier -// "\223}\146:J)\225\226\GS#\EOTn\227E7\184\248'u\ACK\223@\140\227U",PropMaximumQoS 22,PropServerReference -// "\248\225G\SO\209kK \188",PropWillDelayInterval 1146,PropResponseInformation -// "\202\215k(\209\237GUT\b\134P\249\180k\248.{\SO\173^",PropUserProperty -// "\rf.E\SI\151oopgY\232\&5\134{f$\211\n4\150\t\149\238\181\175/Z\EMx" "\ENQ2\154;",PropPayloadFormatIndicator -// 77,PropResponseTopic " \162h\149\NULP\226\226e\219\RS\236, \252Wgvb\FSM\224\237\187\ETXZ",PropMaximumQoS -// 117,PropResponseTopic "OV\RS\213p$\SUB\135"] + EXPECT_EQ(packet_id, 8613); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); +} + +// SubscribeResponse 14512 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right QoS1,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded] [PropSharedSubscriptionAvailable 210] TEST(SubACK5QCTest, Decode30) { - uint8_t pkt[] = { - 0x90, 0x8f, 0x2, 0x46, 0xc6, 0x8a, 0x2, 0x23, 0x7f, 0x28, 0x9, 0x0, 0x11, 0xdb, 0xcd, 0x54, 0xbb, 0xdf, 0xcb, - 0x56, 0x1f, 0xfe, 0x24, 0x3a, 0xd3, 0xce, 0xb5, 0xfd, 0xa2, 0x4, 0x26, 0x0, 0x17, 0x7, 0x80, 0x44, 0x5b, 0xcf, - 0x17, 0x75, 0x44, 0x74, 0x8d, 0x43, 0x5a, 0xa0, 0xf0, 0xde, 0xc3, 0xe9, 0xa, 0x99, 0x85, 0x55, 0x17, 0xa8, 0x0, - 0x1d, 0x76, 0xf3, 0xe5, 0x8, 0x76, 0x7b, 0xfb, 0xc1, 0x27, 0xba, 0x8f, 0x3, 0x12, 0xfe, 0x93, 0xf4, 0x51, 0x80, - 0x1c, 0xd, 0x7f, 0x24, 0x9, 0x73, 0x2a, 0xe9, 0xbf, 0x67, 0xf9, 0x17, 0x2f, 0x11, 0x0, 0x0, 0x74, 0x1b, 0x13, - 0x19, 0x2f, 0x17, 0x2a, 0x2, 0x0, 0x0, 0x40, 0x7c, 0x1c, 0x0, 0x5, 0x80, 0x62, 0x7e, 0xe5, 0x84, 0x15, 0x0, - 0x2, 0xd7, 0x1a, 0x29, 0x6d, 0x12, 0x0, 0x19, 0xdf, 0x7d, 0x92, 0x3a, 0x4a, 0x29, 0xe1, 0xe2, 0x1d, 0x23, 0x4, - 0x6e, 0xe3, 0x45, 0x37, 0xb8, 0xf8, 0x27, 0x75, 0x6, 0xdf, 0x40, 0x8c, 0xe3, 0x55, 0x24, 0x16, 0x1c, 0x0, 0x9, - 0xf8, 0xe1, 0x47, 0xe, 0xd1, 0x6b, 0x4b, 0x20, 0xbc, 0x18, 0x0, 0x0, 0x4, 0x7a, 0x1a, 0x0, 0x15, 0xca, 0xd7, - 0x6b, 0x28, 0xd1, 0xed, 0x47, 0x55, 0x54, 0x8, 0x86, 0x50, 0xf9, 0xb4, 0x6b, 0xf8, 0x2e, 0x7b, 0xe, 0xad, 0x5e, - 0x26, 0x0, 0x1e, 0xd, 0x66, 0x2e, 0x45, 0xf, 0x97, 0x6f, 0x6f, 0x70, 0x67, 0x59, 0xe8, 0x35, 0x86, 0x7b, 0x66, - 0x24, 0xd3, 0xa, 0x34, 0x96, 0x9, 0x95, 0xee, 0xb5, 0xaf, 0x2f, 0x5a, 0x19, 0x78, 0x0, 0x4, 0x5, 0x32, 0x9a, - 0x3b, 0x1, 0x4d, 0x8, 0x0, 0x1a, 0x20, 0xa2, 0x68, 0x95, 0x0, 0x50, 0xe2, 0xe2, 0x65, 0xdb, 0x1e, 0xec, 0x2c, - 0x20, 0xfc, 0x57, 0x67, 0x76, 0x62, 0x1c, 0x4d, 0xe0, 0xed, 0xbb, 0x3, 0x5a, 0x24, 0x75, 0x8, 0x0, 0x8, 0x4f, - 0x56, 0x1e, 0xd5, 0x70, 0x24, 0x1a, 0x87, 0x1}; + uint8_t pkt[] = {0x90, 0xa, 0x38, 0xb0, 0x2, 0x2a, 0xd2, 0x9e, 0x91, 0x1, 0xa2, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18118); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 14512); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], 0x91); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0xA2); + EXPECT_EQ(granted_qos_levels[4], 0x97); } From 012bc4a791e8955486568079911904e6495cfce7 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Sat, 21 Sep 2019 01:02:42 -0700 Subject: [PATCH 20/26] Disconnect (now with reasons!) --- gentests/app/Main.hs | 49 + include/lwmqtt.h | 2 +- src/client.c | 16 +- src/helpers.c | 159 + src/helpers.h | 5 + src/packet.c | 205 +- src/packet.h | 5 +- tests/client.cpp | 14 +- tests/generated.cpp | 29754 ++++++++++++++++++----------------------- 9 files changed, 13298 insertions(+), 16911 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 1a7feff..2bb13c2 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -49,6 +49,9 @@ v311SubACKReq p50 = let (SubACKPkt p) = v311mask (SubACKPkt p50) in p v311ConnReq :: ConnectRequest -> ConnectRequest v311ConnReq p50 = let (ConnPkt p) = v311mask (ConnPkt p50) in p +v311DiscoClean :: DisconnectRequest -> DisconnectRequest +v311DiscoClean p50 = let (DisconnectPkt p) = v311mask (DisconnectPkt p50) in p + userFix :: ConnectRequest -> ConnectRequest userFix = ufix . pfix where @@ -316,6 +319,49 @@ genSubACKTest prot i p@(SubscribeResponse pid res _props) = do q5 SubErrSubscriptionIdentifiersNotSupported = "0xA1" q5 SubErrWildcardSubscriptionsNotSupported = "0xA2" +genDiscoTest :: ProtocolLevel -> Int -> DisconnectRequest -> String +genDiscoTest prot i p@(DisconnectRequest rsn props) = do + genTestFunc "Disco" "Encode" prot i p $ mconcat [ + "uint8_t buf[sizeof(pkt)+10] = { 0 };\n", + genProperties "props" props, + "size_t len = 0;\n", + "lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, ", protlvl prot, ", ", show (dr rsn), ", props);\n", + "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + "EXPECT_EQ(len, sizeof(pkt));\n", + "EXPECT_ARRAY_EQ(pkt, buf, len);\n" + ] + + where + dr DiscoNormalDisconnection = 0x00 + dr DiscoDisconnectWithWill = 0x04 + dr DiscoUnspecifiedError = 0x80 + dr DiscoMalformedPacket = 0x81 + dr DiscoProtocolError = 0x82 + dr DiscoImplementationSpecificError = 0x83 + dr DiscoNotAuthorized = 0x87 + dr DiscoServerBusy = 0x89 + dr DiscoServershuttingDown = 0x8B + dr DiscoKeepAliveTimeout = 0x8D + dr DiscoSessiontakenOver = 0x8e + dr DiscoTopicFilterInvalid = 0x8f + dr DiscoTopicNameInvalid = 0x90 + dr DiscoReceiveMaximumExceeded = 0x93 + dr DiscoTopicAliasInvalid = 0x94 + dr DiscoPacketTooLarge = 0x95 + dr DiscoMessageRateTooHigh = 0x96 + dr DiscoQuotaExceeded = 0x97 + dr DiscoAdministrativeAction = 0x98 + dr DiscoPayloadFormatInvalid = 0x99 + dr DiscoRetainNotSupported = 0x9a + dr DiscoQoSNotSupported = 0x9b + dr DiscoUseAnotherServer = 0x9c + dr DiscoServerMoved = 0x9d + dr DiscoSharedSubscriptionsNotSupported = 0x9e + dr DiscoConnectionRateExceeded = 0x9f + dr DiscoMaximumConnectTime = 0xa0 + dr DiscoSubscriptionIdentifiersNotSupported = 0xa1 + dr DiscoWildcardSubscriptionsNotSupported = 0xa2 + main :: IO () main = do putStrLn [r|#include @@ -359,6 +405,9 @@ extern "C" { f genSubACKTest Protocol311 (v311SubACKReq <$> subax) f genSubACKTest Protocol50 subax + discos <- replicateM numTests $ generate arbitrary + f genDiscoTest Protocol311 (v311DiscoClean <$> discos) + f genDiscoTest Protocol50 discos where f :: (ProtocolLevel -> Int -> a -> String) -> ProtocolLevel -> [a] -> IO () diff --git a/include/lwmqtt.h b/include/lwmqtt.h index 0c98516..8e98826 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -446,7 +446,7 @@ lwmqtt_err_t lwmqtt_unsubscribe_one(lwmqtt_client_t *client, lwmqtt_string_t top * @param timeout - The command timeout. * @return An error value. */ -lwmqtt_err_t lwmqtt_disconnect(lwmqtt_client_t *client, uint32_t timeout); +lwmqtt_err_t lwmqtt_disconnect(lwmqtt_client_t *client, uint8_t reason, lwmqtt_properties_t props, uint32_t timeout); /** * Will yield control to the client and receive incoming packets from the network. diff --git a/src/client.c b/src/client.c index dba2c6c..9e6d290 100644 --- a/src/client.c +++ b/src/client.c @@ -625,24 +625,18 @@ lwmqtt_err_t lwmqtt_publish(lwmqtt_client_t *client, lwmqtt_string_t topic, lwmq return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_disconnect(lwmqtt_client_t *client, uint32_t timeout) { +lwmqtt_err_t lwmqtt_disconnect(lwmqtt_client_t *client, uint8_t reason, lwmqtt_properties_t props, uint32_t timeout) { // set command timer client->timer_set(client->command_timer, timeout); - // encode disconnect packet - size_t len; - lwmqtt_err_t err = lwmqtt_encode_zero(client->write_buf, client->write_buf_size, &len, LWMQTT_DISCONNECT_PACKET); - if (err != LWMQTT_SUCCESS) { - return err; - } - - // send disconnected packet - err = lwmqtt_send_packet_in_buffer(client, len); + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_disconnect(client->write_buf, client->write_buf_size, &len, client->protocol, reason, props); if (err != LWMQTT_SUCCESS) { return err; } - return LWMQTT_SUCCESS; + return lwmqtt_send_packet_in_buffer(client, len); } lwmqtt_err_t lwmqtt_keep_alive(lwmqtt_client_t *client, uint32_t timeout) { diff --git a/src/helpers.c b/src/helpers.c index e9b36fb..3229df7 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -279,3 +279,162 @@ lwmqtt_err_t lwmqtt_write_varnum(uint8_t **buf, const uint8_t *buf_end, uint32_t return LWMQTT_SUCCESS; } + +static lwmqtt_err_t write_prop(uint8_t **buf, const uint8_t *buf_end, lwmqtt_property_t prop) { + lwmqtt_err_t err = lwmqtt_write_byte(buf, buf_end, prop.prop); + if (err != LWMQTT_SUCCESS) { + return err; + } + + switch (prop.prop) { + // one byte + case LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR: + case LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION: + case LWMQTT_PROP_MAXIMUM_QOS: + case LWMQTT_PROP_RETAIN_AVAILABLE: + case LWMQTT_PROP_REQUEST_RESPONSE_INFORMATION: + case LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE: + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE: + case LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE: + return lwmqtt_write_byte(buf, buf_end, prop.value.byte); + + // two byte int + case LWMQTT_PROP_SERVER_KEEP_ALIVE: + case LWMQTT_PROP_RECEIVE_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS: + return lwmqtt_write_num(buf, buf_end, prop.value.int16); + + // 4 byte int + case LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL: + case LWMQTT_PROP_SESSION_EXPIRY_INTERVAL: + case LWMQTT_PROP_WILL_DELAY_INTERVAL: + case LWMQTT_PROP_MAXIMUM_PACKET_SIZE: + return lwmqtt_write_num32(buf, buf_end, prop.value.int32); + + // Variable byte int + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: + return lwmqtt_write_varnum(buf, buf_end, prop.value.int32); + + // UTF-8 string + case LWMQTT_PROP_CONTENT_TYPE: + case LWMQTT_PROP_RESPONSE_TOPIC: + case LWMQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER: + case LWMQTT_PROP_AUTHENTICATION_METHOD: + case LWMQTT_PROP_RESPONSE_INFORMATION: + case LWMQTT_PROP_SERVER_REFERENCE: + case LWMQTT_PROP_REASON_STRING: + + // Arbitrary blobs as the same encoding. + case LWMQTT_PROP_CORRELATION_DATA: + case LWMQTT_PROP_AUTHENTICATION_DATA: + return lwmqtt_write_string(buf, buf_end, prop.value.str); + + case LWMQTT_PROP_USER_PROPERTY: + lwmqtt_write_string(buf, buf_end, prop.value.pair.k); + lwmqtt_write_string(buf, buf_end, prop.value.pair.v); + } + + return LWMQTT_SUCCESS; +} + +static size_t proplen(lwmqtt_property_t prop) { + int ll; + switch (prop.prop) { + // one byte + case LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR: + case LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION: + case LWMQTT_PROP_MAXIMUM_QOS: + case LWMQTT_PROP_RETAIN_AVAILABLE: + case LWMQTT_PROP_REQUEST_RESPONSE_INFORMATION: + case LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE: + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE: + case LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE: + return 2; + + // two byte int + case LWMQTT_PROP_SERVER_KEEP_ALIVE: + case LWMQTT_PROP_RECEIVE_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM: + case LWMQTT_PROP_TOPIC_ALIAS: + return 3; + + // 4 byte int + case LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL: + case LWMQTT_PROP_SESSION_EXPIRY_INTERVAL: + case LWMQTT_PROP_WILL_DELAY_INTERVAL: + case LWMQTT_PROP_MAXIMUM_PACKET_SIZE: + return 5; + + // Variable byte int + case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: + lwmqtt_varnum_length(prop.value.int32, &ll); + return 1 + ll; + + // UTF-8 string + case LWMQTT_PROP_CONTENT_TYPE: + case LWMQTT_PROP_RESPONSE_TOPIC: + case LWMQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER: + case LWMQTT_PROP_AUTHENTICATION_METHOD: + case LWMQTT_PROP_RESPONSE_INFORMATION: + case LWMQTT_PROP_SERVER_REFERENCE: + case LWMQTT_PROP_REASON_STRING: + + // Arbitrary blobs are the same encoding. + case LWMQTT_PROP_CORRELATION_DATA: + case LWMQTT_PROP_AUTHENTICATION_DATA: + return 3 + prop.value.str.len; + + case LWMQTT_PROP_USER_PROPERTY: + return 1 + 2 + prop.value.pair.k.len + 2 + prop.value.pair.v.len; + } + return 0; +} + +// Length of the properties, not including their length. +static size_t propsintlen(lwmqtt_properties_t props) { + uint32_t l = 0; + + for (int i = 0; i < props.len; i++) { + l += proplen(props.props[i]); + } + + return l; +} + +// Length of a properties set as it may appear on the wire (including +// the length of the length). +size_t lwmqtt_propslen(lwmqtt_protocol_t prot, lwmqtt_properties_t props) { + if (prot == LWMQTT_MQTT311) { + return 0; + } + + uint32_t l = propsintlen(props); + int ll; + // lwmqtt_err_t err = + lwmqtt_varnum_length(l, &ll); + + return l + ll; +} + +lwmqtt_err_t lwmqtt_write_props(uint8_t **buf, const uint8_t *buf_end, lwmqtt_protocol_t prot, + lwmqtt_properties_t props) { + if (prot == LWMQTT_MQTT311) { + return LWMQTT_SUCCESS; + } + + size_t len = propsintlen(props); + lwmqtt_err_t err = lwmqtt_write_varnum(buf, buf_end, len); + if (err != LWMQTT_SUCCESS) { + return err; + } + + for (int i = 0; i < props.len; i++) { + err = write_prop(buf, buf_end, props.props[i]); + if (err != LWMQTT_SUCCESS) { + return err; + } + } + + return LWMQTT_SUCCESS; +} diff --git a/src/helpers.h b/src/helpers.h index f23c511..a69fd59 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -138,4 +138,9 @@ lwmqtt_err_t lwmqtt_read_varnum(uint8_t **buf, const uint8_t *buf_end, uint32_t */ lwmqtt_err_t lwmqtt_write_varnum(uint8_t **buf, const uint8_t *buf_end, uint32_t varnum); +size_t lwmqtt_propslen(lwmqtt_protocol_t prot, lwmqtt_properties_t props); + +lwmqtt_err_t lwmqtt_write_props(uint8_t **buf, const uint8_t *buf_end, lwmqtt_protocol_t prot, + lwmqtt_properties_t props); + #endif diff --git a/src/packet.c b/src/packet.c index 781eaaf..14c4c0b 100644 --- a/src/packet.c +++ b/src/packet.c @@ -55,165 +55,6 @@ lwmqtt_err_t lwmqtt_detect_remaining_length(uint8_t *buf, size_t buf_len, uint32 return LWMQTT_SUCCESS; } -static size_t proplen(lwmqtt_property_t prop) { - int ll; - switch (prop.prop) { - // one byte - case LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR: - case LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION: - case LWMQTT_PROP_MAXIMUM_QOS: - case LWMQTT_PROP_RETAIN_AVAILABLE: - case LWMQTT_PROP_REQUEST_RESPONSE_INFORMATION: - case LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE: - case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE: - case LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE: - return 2; - - // two byte int - case LWMQTT_PROP_SERVER_KEEP_ALIVE: - case LWMQTT_PROP_RECEIVE_MAXIMUM: - case LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM: - case LWMQTT_PROP_TOPIC_ALIAS: - return 3; - - // 4 byte int - case LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL: - case LWMQTT_PROP_SESSION_EXPIRY_INTERVAL: - case LWMQTT_PROP_WILL_DELAY_INTERVAL: - case LWMQTT_PROP_MAXIMUM_PACKET_SIZE: - return 5; - - // Variable byte int - case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: - lwmqtt_varnum_length(prop.value.int32, &ll); - return 1 + ll; - - // UTF-8 string - case LWMQTT_PROP_CONTENT_TYPE: - case LWMQTT_PROP_RESPONSE_TOPIC: - case LWMQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER: - case LWMQTT_PROP_AUTHENTICATION_METHOD: - case LWMQTT_PROP_RESPONSE_INFORMATION: - case LWMQTT_PROP_SERVER_REFERENCE: - case LWMQTT_PROP_REASON_STRING: - - // Arbitrary blobs are the same encoding. - case LWMQTT_PROP_CORRELATION_DATA: - case LWMQTT_PROP_AUTHENTICATION_DATA: - return 3 + prop.value.str.len; - - case LWMQTT_PROP_USER_PROPERTY: - return 1 + 2 + prop.value.pair.k.len + 2 + prop.value.pair.v.len; - } - return 0; -} - -static lwmqtt_err_t write_prop(uint8_t **buf, const uint8_t *buf_end, lwmqtt_property_t prop) { - lwmqtt_err_t err = lwmqtt_write_byte(buf, buf_end, prop.prop); - if (err != LWMQTT_SUCCESS) { - return err; - } - - switch (prop.prop) { - // one byte - case LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR: - case LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION: - case LWMQTT_PROP_MAXIMUM_QOS: - case LWMQTT_PROP_RETAIN_AVAILABLE: - case LWMQTT_PROP_REQUEST_RESPONSE_INFORMATION: - case LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE: - case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE: - case LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE: - return lwmqtt_write_byte(buf, buf_end, prop.value.byte); - - // two byte int - case LWMQTT_PROP_SERVER_KEEP_ALIVE: - case LWMQTT_PROP_RECEIVE_MAXIMUM: - case LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM: - case LWMQTT_PROP_TOPIC_ALIAS: - return lwmqtt_write_num(buf, buf_end, prop.value.int16); - - // 4 byte int - case LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL: - case LWMQTT_PROP_SESSION_EXPIRY_INTERVAL: - case LWMQTT_PROP_WILL_DELAY_INTERVAL: - case LWMQTT_PROP_MAXIMUM_PACKET_SIZE: - return lwmqtt_write_num32(buf, buf_end, prop.value.int32); - - // Variable byte int - case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: - return lwmqtt_write_varnum(buf, buf_end, prop.value.int32); - - // UTF-8 string - case LWMQTT_PROP_CONTENT_TYPE: - case LWMQTT_PROP_RESPONSE_TOPIC: - case LWMQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER: - case LWMQTT_PROP_AUTHENTICATION_METHOD: - case LWMQTT_PROP_RESPONSE_INFORMATION: - case LWMQTT_PROP_SERVER_REFERENCE: - case LWMQTT_PROP_REASON_STRING: - - // Arbitrary blobs as the same encoding. - case LWMQTT_PROP_CORRELATION_DATA: - case LWMQTT_PROP_AUTHENTICATION_DATA: - return lwmqtt_write_string(buf, buf_end, prop.value.str); - - case LWMQTT_PROP_USER_PROPERTY: - lwmqtt_write_string(buf, buf_end, prop.value.pair.k); - lwmqtt_write_string(buf, buf_end, prop.value.pair.v); - } - - return LWMQTT_SUCCESS; -} - -// Length of the properties, not including their length. -static size_t propsintlen(lwmqtt_properties_t props) { - uint32_t l = 0; - - for (int i = 0; i < props.len; i++) { - l += proplen(props.props[i]); - } - - return l; -} - -// Length of a properties set as it may appear on the wire (including -// the length of the length). -static size_t propslen(lwmqtt_protocol_t prot, lwmqtt_properties_t props) { - if (prot == LWMQTT_MQTT311) { - return 0; - } - - uint32_t l = propsintlen(props); - int ll; - // lwmqtt_err_t err = - lwmqtt_varnum_length(l, &ll); - - return l + ll; -} - -static lwmqtt_err_t lwmqtt_write_props(uint8_t **buf, const uint8_t *buf_end, lwmqtt_protocol_t prot, - lwmqtt_properties_t props) { - if (prot == LWMQTT_MQTT311) { - return LWMQTT_SUCCESS; - } - - size_t len = propsintlen(props); - lwmqtt_err_t err = lwmqtt_write_varnum(buf, buf_end, len); - if (err != LWMQTT_SUCCESS) { - return err; - } - - for (int i = 0; i < props.len; i++) { - err = write_prop(buf, buf_end, props.props[i]); - if (err != LWMQTT_SUCCESS) { - return err; - } - } - - return LWMQTT_SUCCESS; -} - lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, lwmqtt_options_t options, lwmqtt_will_t *will) { // prepare pointers @@ -221,7 +62,7 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw uint8_t *buf_end = buf + buf_len; // fixed header is 10 - uint32_t rem_len = 10 + propslen(protocol, options.properties); + uint32_t rem_len = 10 + lwmqtt_propslen(protocol, options.properties); // add client id to remaining length rem_len += options.client_id.len + 2; @@ -229,7 +70,7 @@ lwmqtt_err_t lwmqtt_encode_connect(uint8_t *buf, size_t buf_len, size_t *len, lw // add will if present to remaining length if (will != NULL) { rem_len += will->topic.len + 2 + will->payload.len + 2; - rem_len += propslen(protocol, will->properties); + rem_len += lwmqtt_propslen(protocol, will->properties); } // add username if present to remaining length @@ -673,7 +514,7 @@ lwmqtt_err_t lwmqtt_encode_publish(uint8_t *buf, size_t buf_len, size_t *len, lw uint8_t *buf_end = buf + buf_len; // calculate remaining length - uint32_t rem_len = 2 + topic.len + (uint32_t)msg.payload_len + propslen(protocol, props); + uint32_t rem_len = 2 + topic.len + (uint32_t)msg.payload_len + lwmqtt_propslen(protocol, props); if (msg.qos > 0) { rem_len += 2; } @@ -756,7 +597,7 @@ lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, uint8_t *buf_end = buf + buf_len; // calculate remaining length - uint32_t rem_len = 2 + propslen(protocol, props); + uint32_t rem_len = 2 + lwmqtt_propslen(protocol, props); for (int i = 0; i < count; i++) { rem_len += 2 + topic_filters[i].len + 1; } @@ -957,3 +798,41 @@ lwmqtt_err_t lwmqtt_encode_unsubscribe(uint8_t *buf, size_t buf_len, size_t *len return LWMQTT_SUCCESS; } + +lwmqtt_err_t lwmqtt_encode_disconnect(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, + uint8_t reason, lwmqtt_properties_t props) { + uint8_t *buf_ptr = buf; + uint8_t *buf_end = buf_ptr + buf_len; + + uint8_t header = 0; + lwmqtt_write_bits(&header, LWMQTT_DISCONNECT_PACKET, 4, 4); + lwmqtt_err_t err = lwmqtt_write_byte(&buf_ptr, buf_end, header); + if (err != LWMQTT_SUCCESS) { + return err; + } + + uint32_t rem_len = 0; + if (protocol == LWMQTT_MQTT5) { + rem_len = 1 + lwmqtt_propslen(protocol, props); + } + + err = lwmqtt_write_varnum(&buf_ptr, buf_end, rem_len); + if (err != LWMQTT_SUCCESS) { + return err; + } + + if (protocol == LWMQTT_MQTT5) { + err = lwmqtt_write_byte(&buf_ptr, buf_end, reason); + if (err != LWMQTT_SUCCESS) { + return err; + } + + err = lwmqtt_write_props(&buf_ptr, buf_end, protocol, props); + if (err != LWMQTT_SUCCESS) { + return err; + } + } + + *len = buf_ptr - buf; + return LWMQTT_SUCCESS; +} diff --git a/src/packet.h b/src/packet.h index 9cb8f85..9c1ffef 100644 --- a/src/packet.h +++ b/src/packet.h @@ -75,7 +75,7 @@ lwmqtt_err_t lwmqtt_decode_connack(uint8_t *buf, size_t buf_len, lwmqtt_protocol lwmqtt_return_code_t *return_code); /** - * Encodes a zero (disconnect, pingreq) packet into the supplied buffer. + * Encodes a zero (pingreq) packet into the supplied buffer. * * @param buf - The buffer into which the packet will be encoded. * @param buf_len - The length of the specified buffer. @@ -85,6 +85,9 @@ lwmqtt_err_t lwmqtt_decode_connack(uint8_t *buf, size_t buf_len, lwmqtt_protocol */ lwmqtt_err_t lwmqtt_encode_zero(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_packet_type_t packet_type); +lwmqtt_err_t lwmqtt_encode_disconnect(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, + uint8_t reason, lwmqtt_properties_t props); + /** * Decodes an ack (puback, pubrec, pubrel, pubcomp, unsuback) packet from the supplied buffer. * diff --git a/tests/client.cpp b/tests/client.cpp index 11f3edc..1cdfaa2 100644 --- a/tests/client.cpp +++ b/tests/client.cpp @@ -101,7 +101,7 @@ TEST(Client, PublishSubscribeQOS0) { err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_disconnect(&client, COMMAND_TIMEOUT); + err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_unix_network_disconnect(&network); @@ -162,7 +162,7 @@ TEST(Client, PublishSubscribeQOS1) { err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_disconnect(&client, COMMAND_TIMEOUT); + err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_unix_network_disconnect(&network); @@ -223,7 +223,7 @@ TEST(Client, PublishSubscribeQOS2) { err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_disconnect(&client, COMMAND_TIMEOUT); + err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_unix_network_disconnect(&network); @@ -287,7 +287,7 @@ TEST(Client, BufferOverflow) { } } - err = lwmqtt_disconnect(&client, COMMAND_TIMEOUT); + err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_unix_network_disconnect(&network); @@ -348,7 +348,7 @@ TEST(Client, OverflowDropping) { } } - err = lwmqtt_disconnect(&client, COMMAND_TIMEOUT); + err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); ASSERT_EQ(counter, 0); @@ -411,7 +411,7 @@ TEST(Client, BigBuffersAndPayload) { err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_disconnect(&client, COMMAND_TIMEOUT); + err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_unix_network_disconnect(&network); @@ -474,7 +474,7 @@ TEST(Client, MultipleSubscriptions) { err = lwmqtt_unsubscribe(&client, 2, topic_filters, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); - err = lwmqtt_disconnect(&client, COMMAND_TIMEOUT); + err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_unix_network_disconnect(&network); diff --git a/tests/generated.cpp b/tests/generated.cpp index 9beaa97..cb7f12c 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,18415 +21,14713 @@ extern "C" { } \ } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "#\234\SI\231\179\228\175!\174\132/\ETXg\US\r\STX\178\203\151\187\DC3C", _pubPktID = 3425, _pubBody = ":\171^C\n", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = ";\135[\241\201\187\168\ETX\227\158\138\182\179\234\250\172\152\219\131\130!", _pubPktID = 24061, _pubBody = "\206\141\147\181o\253", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x32, 0x1f, 0x0, 0x16, 0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, 0x3, 0x67, - 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43, 0xd, 0x61, 0x3a, 0xab, 0x5e, 0x43, 0xa}; - uint8_t topic_bytes[] = {0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, - 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; +uint8_t pkt[] = {0x33, 0x1f, 0x0, 0x15, 0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21, 0x5d, 0xfd, 0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; + uint8_t topic_bytes[] = {0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x3a, 0xab, 0x5e, 0x43, 0xa}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 6; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3425, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24061, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "#\234\SI\231\179\228\175!\174\132/\ETXg\US\r\STX\178\203\151\187\DC3C", _pubPktID = 3425, _pubBody = ":\171^C\n", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = ";\135[\241\201\187\168\ETX\227\158\138\182\179\234\250\172\152\219\131\130!", _pubPktID = 24061, _pubBody = "\206\141\147\181o\253", _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x32, 0x1f, 0x0, 0x16, 0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, 0x3, 0x67, - 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43, 0xd, 0x61, 0x3a, 0xab, 0x5e, 0x43, 0xa}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x33, 0x1f, 0x0, 0x15, 0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21, 0x5d, 0xfd, 0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 24061); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); +EXPECT_EQ(msg.payload_len, 6); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, - 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x3a, 0xab, 0x5e, 0x43, 0xa}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 3425); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\158\245\154\154\236\CAN_4\221\253\192\177\172<\236c\171]F_", _pubPktID = 29370, _pubBody = -// "z\217-\243HF\176HG\200\166\159", _pubProps = []} +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\148\US\b\177\214\241A\128\215\138NRR\141\t\208\DC4\231\253\232\EM\205\r\162\157", _pubPktID = 0, _pubBody = "\DELQr", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x3c, 0x24, 0x0, 0x14, 0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, - 0xfd, 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f, 0x72, 0xba, - 0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; - uint8_t topic_bytes[] = {0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, 0xfd, - 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x19, 0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d, 0x7f, 0x51, 0x72}; + uint8_t topic_bytes[] = {0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = true; +uint8_t msg_bytes[] = {0x7f, 0x51, 0x72}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 3; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29370, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\158\245\154\154\236\CAN_4\221\253\192\177\172<\236c\171]F_", _pubPktID = 29370, _pubBody = -// "z\217-\243HF\176HG\200\166\159", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\148\US\b\177\214\241A\128\215\138NRR\141\t\208\DC4\231\253\232\EM\205\r\162\157", _pubPktID = 0, _pubBody = "\DELQr", _pubProps = []} TEST(Publish311QCTest, Decode2) { - uint8_t pkt[] = {0x3c, 0x24, 0x0, 0x14, 0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, - 0xfd, 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f, 0x72, 0xba, - 0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x19, 0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d, 0x7f, 0x51, 0x72}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7f, 0x51, 0x72}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); +EXPECT_EQ(msg.payload_len, 3); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, 0xfd, - 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 29370); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "uh{\218\a\247\172\148\ESC\ETB\187\138\184\255\vX\180\DC1\131\&0\219\216\SI\147\203\ETX)\218", _pubPktID = 0, -// _pubBody = "\207\DC1\209\235\144\141K\255\225\177/B\DC1\DC3\175\144", _pubProps = []} +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CANO\164\EM\236\160:x\bB\170\222ObK\201\DC1\168W}>\187\DC1", _pubPktID = 0, _pubBody = "", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x38, 0x2e, 0x0, 0x1c, 0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, - 0xb8, 0xff, 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda, - 0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; - uint8_t topic_bytes[] = {0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, 0xb8, 0xff, - 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, - 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x38, 0x19, 0x0, 0x17, 0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; + uint8_t topic_bytes[] = {0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = false; +uint8_t msg_bytes[] = {0}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 0; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "uh{\218\a\247\172\148\ESC\ETB\187\138\184\255\vX\180\DC1\131\&0\219\216\SI\147\203\ETX)\218", _pubPktID = 0, -// _pubBody = "\207\DC1\209\235\144\141K\255\225\177/B\DC1\DC3\175\144", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CANO\164\EM\236\160:x\bB\170\222ObK\201\DC1\168W}>\187\DC1", _pubPktID = 0, _pubBody = "", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x38, 0x2e, 0x0, 0x1c, 0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, - 0xb8, 0xff, 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda, - 0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x38, 0x19, 0x0, 0x17, 0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); +EXPECT_EQ(msg.payload_len, 0); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, 0xb8, 0xff, - 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, - 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\193)\128\208yd\SOi\134\237\DC2Ir\136\217", _pubPktID = 8430, _pubBody = -// "\138\214\&5p\ESCn,\183\152u\192\244\165\&1\147\140\172", _pubProps = []} -TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x3d, 0x24, 0x0, 0xf, 0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, - 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9, 0x20, 0xee, 0x8a, 0xd6, 0x35, 0x70, 0x1b, - 0x6e, 0x2c, 0xb7, 0x98, 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; - uint8_t topic_bytes[] = {0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x8a, 0xd6, 0x35, 0x70, 0x1b, 0x6e, 0x2c, 0xb7, 0x98, - 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; - lwmqtt_property_t propslist[] = {}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "]\151\151\159oP\170", _pubPktID = 14052, _pubBody = "\254\174c\158\219\&7\163j\130\179TW\155\250\141\164c", _pubProps = []} +TEST(Publish311QCTest, Encode4) { +uint8_t pkt[] = {0x3b, 0x1c, 0x0, 0x7, 0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa, 0x36, 0xe4, 0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; + uint8_t topic_bytes[] = {0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 17; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 8430, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 14052, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\193)\128\208yd\SOi\134\237\DC2Ir\136\217", _pubPktID = 8430, _pubBody = -// "\138\214\&5p\ESCn,\183\152u\192\244\165\&1\147\140\172", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "]\151\151\159oP\170", _pubPktID = 14052, _pubBody = "\254\174c\158\219\&7\163j\130\179TW\155\250\141\164c", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x3d, 0x24, 0x0, 0xf, 0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, - 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9, 0x20, 0xee, 0x8a, 0xd6, 0x35, 0x70, 0x1b, - 0x6e, 0x2c, 0xb7, 0x98, 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8a, 0xd6, 0x35, 0x70, 0x1b, 0x6e, 0x2c, 0xb7, 0x98, - 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; +uint8_t pkt[] = {0x3b, 0x1c, 0x0, 0x7, 0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa, 0x36, 0xe4, 0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 8430); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\DC2\184\144\&5\136\156E\174\237\230\175\SUB\153 \NAKk\EM\f", _pubPktID = 0, _pubBody = -// "i\232{\DC3k\GS\158\DLE|\218\236v\244>\145\172,\bR\165\255\174", _pubProps = []} -TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x31, 0x2a, 0x0, 0x12, 0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, 0xe6, 0xaf, - 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc, 0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, - 0x7c, 0xda, 0xec, 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; - uint8_t topic_bytes[] = {0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, - 0xe6, 0xaf, 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 14052); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); +EXPECT_EQ(msg.payload_len, 17); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, 0xda, 0xec, - 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; - lwmqtt_property_t propslist[] = {}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "F\129\169\SYN\215A[Qx}\223\&7NE\181\250\249\236\208\GSL\217\176\183\235\&0\189\247u_", _pubPktID = 26784, _pubBody = "\176\&0\158\138\138]\220(B\154\&3\224jV\159v+\130", _pubProps = []} +TEST(Publish311QCTest, Encode5) { +uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x1e, 0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f, 0x68, 0xa0, 0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; + uint8_t topic_bytes[] = {0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 18; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 26784, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\DC2\184\144\&5\136\156E\174\237\230\175\SUB\153 \NAKk\EM\f", _pubPktID = 0, _pubBody = -// "i\232{\DC3k\GS\158\DLE|\218\236v\244>\145\172,\bR\165\255\174", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "F\129\169\SYN\215A[Qx}\223\&7NE\181\250\249\236\208\GSL\217\176\183\235\&0\189\247u_", _pubPktID = 26784, _pubBody = "\176\&0\158\138\138]\220(B\154\&3\224jV\159v+\130", _pubProps = []} TEST(Publish311QCTest, Decode5) { - uint8_t pkt[] = {0x31, 0x2a, 0x0, 0x12, 0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, 0xe6, 0xaf, - 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc, 0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, - 0x7c, 0xda, 0xec, 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, - 0xe6, 0xaf, 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, 0xda, 0xec, - 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\251M\156e\192", _pubPktID = 0, -// _pubBody = "O\254\197\133\153\151~\137\172", _pubProps = []} +uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x1e, 0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f, 0x68, 0xa0, 0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f}; + lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 26784); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); +EXPECT_EQ(msg.payload_len, 18); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "IP\\2\223\164P[u\SI\DLEh\171x\188\185\177Q#\163v7L\224Y;5", _pubPktID = 14257, _pubBody = "\215Vs\129\239\168\165b\145\208\232`\245", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x31, 0x10, 0x0, 0x5, 0xfb, 0x4d, 0x9c, 0x65, 0xc0, - 0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; - uint8_t topic_bytes[] = {0xfb, 0x4d, 0x9c, 0x65, 0xc0}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; +uint8_t pkt[] = {0x35, 0x2c, 0x0, 0x1b, 0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35, 0x37, 0xb1, 0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; + uint8_t topic_bytes[] = {0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 13; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 14257, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\251M\156e\192", _pubPktID = 0, -// _pubBody = "O\254\197\133\153\151~\137\172", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "IP\\2\223\164P[u\SI\DLEh\171x\188\185\177Q#\163v7L\224Y;5", _pubPktID = 14257, _pubBody = "\215Vs\129\239\168\165b\145\208\232`\245", _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x31, 0x10, 0x0, 0x5, 0xfb, 0x4d, 0x9c, 0x65, 0xc0, - 0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x35, 0x2c, 0x0, 0x1b, 0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35, 0x37, 0xb1, 0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 14257); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); +EXPECT_EQ(msg.payload_len, 13); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xfb, 0x4d, 0x9c, 0x65, 0xc0}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\224@\143", _pubPktID = 6480, -// _pubBody = "p\191(\150l\241Y\SO\208g\192\EMT+\DLE\246\189f\179C\EOTFwX1\DC3I*A\n", _pubProps = []} +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "6\RS\235\193R\DEL\172\233\219\ETX\209a8\243\RS\229\&2a", _pubPktID = 10501, _pubBody = "*K\219};J\192L&\150k\230#\253#\163\207\128\170\174\GS{\t", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x3b, 0x25, 0x0, 0x3, 0xe0, 0x40, 0x8f, 0x19, 0x50, 0x70, 0xbf, 0x28, 0x96, - 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, 0xf6, 0xbd, - 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; - uint8_t topic_bytes[] = {0xe0, 0x40, 0x8f}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; +uint8_t pkt[] = {0x3d, 0x2d, 0x0, 0x12, 0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61, 0x29, 0x5, 0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; + uint8_t topic_bytes[] = {0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x70, 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, - 0xf6, 0xbd, 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 23; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6480, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10501, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\224@\143", _pubPktID = 6480, -// _pubBody = "p\191(\150l\241Y\SO\208g\192\EMT+\DLE\246\189f\179C\EOTFwX1\DC3I*A\n", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "6\RS\235\193R\DEL\172\233\219\ETX\209a8\243\RS\229\&2a", _pubPktID = 10501, _pubBody = "*K\219};J\192L&\150k\230#\253#\163\207\128\170\174\GS{\t", _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x3b, 0x25, 0x0, 0x3, 0xe0, 0x40, 0x8f, 0x19, 0x50, 0x70, 0xbf, 0x28, 0x96, - 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, 0xf6, 0xbd, - 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3d, 0x2d, 0x0, 0x12, 0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61, 0x29, 0x5, 0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 10501); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); +EXPECT_EQ(msg.payload_len, 23); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe0, 0x40, 0x8f}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x70, 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, - 0xf6, 0xbd, 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 6480); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\141\RSw\147`\NAK\ENQ\149f_Y\196\&3b\209U\150s\240\238\a\156\v\151~%\224P\244", _pubPktID = 0, _pubBody = -// "\220\213O", _pubProps = []} -TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x38, 0x22, 0x0, 0x1d, 0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, - 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, 0x55, 0x96, 0x73, 0xf0, 0xee, - 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4, 0xdc, 0xd5, 0x4f}; - uint8_t topic_bytes[] = {0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, - 0x55, 0x96, 0x73, 0xf0, 0xee, 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xdc, 0xd5, 0x4f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; - lwmqtt_property_t propslist[] = {}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\129\171\&3\ETBSN", _pubPktID = 5903, _pubBody = "zPg\212~f\130\171\232\241P\212\ENQ'\234'@\v\177;s\157z*\DC2{\148\&6|", _pubProps = []} +TEST(Publish311QCTest, Encode8) { +uint8_t pkt[] = {0x3c, 0x27, 0x0, 0x6, 0x81, 0xab, 0x33, 0x17, 0x53, 0x4e, 0x17, 0xf, 0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; + uint8_t topic_bytes[] = {0x81, 0xab, 0x33, 0x17, 0x53, 0x4e}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = false; +uint8_t msg_bytes[] = {0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 29; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5903, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\141\RSw\147`\NAK\ENQ\149f_Y\196\&3b\209U\150s\240\238\a\156\v\151~%\224P\244", _pubPktID = 0, _pubBody = -// "\220\213O", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\129\171\&3\ETBSN", _pubPktID = 5903, _pubBody = "zPg\212~f\130\171\232\241P\212\ENQ'\234'@\v\177;s\157z*\DC2{\148\&6|", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x38, 0x22, 0x0, 0x1d, 0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, - 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, 0x55, 0x96, 0x73, 0xf0, 0xee, - 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4, 0xdc, 0xd5, 0x4f}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3c, 0x27, 0x0, 0x6, 0x81, 0xab, 0x33, 0x17, 0x53, 0x4e, 0x17, 0xf, 0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x81, 0xab, 0x33, 0x17, 0x53, 0x4e}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 5903); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); +EXPECT_EQ(msg.payload_len, 29); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, - 0x55, 0x96, 0x73, 0xf0, 0xee, 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xdc, 0xd5, 0x4f}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\130\180J\210\214\ENQ\185\DC3T.\233,_\253N\188M\218\t\203\210\&9z\193w\227", _pubPktID = 5801, _pubBody = -// "e/2Y\147]W%\233\NUL\170j25\192", _pubProps = []} +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "f\145?\ETXkG", _pubPktID = 0, _pubBody = "z)\172\246\137o\201C\144\161\ETX\DC4\243V\SI\136\ETX\223\135V\253\SYN\a\200.", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x3a, 0x2d, 0x0, 0x1a, 0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, - 0x5f, 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3, 0x16, 0xa9, - 0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; - uint8_t topic_bytes[] = {0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, 0x5f, - 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x31, 0x21, 0x0, 0x6, 0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47, 0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; + uint8_t topic_bytes[] = {0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = true; +uint8_t msg_bytes[] = {0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 25; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5801, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\130\180J\210\214\ENQ\185\DC3T.\233,_\253N\188M\218\t\203\210\&9z\193w\227", _pubPktID = 5801, _pubBody = -// "e/2Y\147]W%\233\NUL\170j25\192", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "f\145?\ETXkG", _pubPktID = 0, _pubBody = "z)\172\246\137o\201C\144\161\ETX\DC4\243V\SI\136\ETX\223\135V\253\SYN\a\200.", _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x3a, 0x2d, 0x0, 0x1a, 0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, - 0x5f, 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3, 0x16, 0xa9, - 0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x31, 0x21, 0x0, 0x6, 0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47, 0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); +EXPECT_EQ(msg.payload_len, 25); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, 0x5f, - 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 5801); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "$hC\136_\134&\134\182\244\211M\211a\221[", _pubPktID = 25662, _pubBody = "", _pubProps = []} +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\155rvW\187y*a\164\152\nL\EMg}@\SYN\142\DC2", _pubPktID = 0, _pubBody = "\US\US\DLE\ESC\221J\DC3T\209\207\183rx\202;\229\224\EM\241z#\169X\166\139", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x3c, 0x14, 0x0, 0x10, 0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, - 0x86, 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b, 0x64, 0x3e}; - uint8_t topic_bytes[] = {0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, - 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x39, 0x2e, 0x0, 0x13, 0x9b, 0x72, 0x76, 0x57, 0xbb, 0x79, 0x2a, 0x61, 0xa4, 0x98, 0xa, 0x4c, 0x19, 0x67, 0x7d, 0x40, 0x16, 0x8e, 0x12, 0x1f, 0x1f, 0x10, 0x1b, 0xdd, 0x4a, 0x13, 0x54, 0xd1, 0xcf, 0xb7, 0x72, 0x78, 0xca, 0x3b, 0xe5, 0xe0, 0x19, 0xf1, 0x7a, 0x23, 0xa9, 0x58, 0xa6, 0x8b}; + uint8_t topic_bytes[] = {0x9b, 0x72, 0x76, 0x57, 0xbb, 0x79, 0x2a, 0x61, 0xa4, 0x98, 0xa, 0x4c, 0x19, 0x67, 0x7d, 0x40, 0x16, 0x8e, 0x12}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = true; +uint8_t msg_bytes[] = {0x1f, 0x1f, 0x10, 0x1b, 0xdd, 0x4a, 0x13, 0x54, 0xd1, 0xcf, 0xb7, 0x72, 0x78, 0xca, 0x3b, 0xe5, 0xe0, 0x19, 0xf1, 0x7a, 0x23, 0xa9, 0x58, 0xa6, 0x8b}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 25; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25662, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "$hC\136_\134&\134\182\244\211M\211a\221[", _pubPktID = 25662, _pubBody = "", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\155rvW\187y*a\164\152\nL\EMg}@\SYN\142\DC2", _pubPktID = 0, _pubBody = "\US\US\DLE\ESC\221J\DC3T\209\207\183rx\202;\229\224\EM\241z#\169X\166\139", _pubProps = []} TEST(Publish311QCTest, Decode10) { - uint8_t pkt[] = {0x3c, 0x14, 0x0, 0x10, 0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, - 0x86, 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b, 0x64, 0x3e}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x39, 0x2e, 0x0, 0x13, 0x9b, 0x72, 0x76, 0x57, 0xbb, 0x79, 0x2a, 0x61, 0xa4, 0x98, 0xa, 0x4c, 0x19, 0x67, 0x7d, 0x40, 0x16, 0x8e, 0x12, 0x1f, 0x1f, 0x10, 0x1b, 0xdd, 0x4a, 0x13, 0x54, 0xd1, 0xcf, 0xb7, 0x72, 0x78, 0xca, 0x3b, 0xe5, 0xe0, 0x19, 0xf1, 0x7a, 0x23, 0xa9, 0x58, 0xa6, 0x8b}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x9b, 0x72, 0x76, 0x57, 0xbb, 0x79, 0x2a, 0x61, 0xa4, 0x98, 0xa, 0x4c, 0x19, 0x67, 0x7d, 0x40, 0x16, 0x8e, 0x12}; + lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1f, 0x1f, 0x10, 0x1b, 0xdd, 0x4a, 0x13, 0x54, 0xd1, 0xcf, 0xb7, 0x72, 0x78, 0xca, 0x3b, 0xe5, 0xe0, 0x19, 0xf1, 0x7a, 0x23, 0xa9, 0x58, 0xa6, 0x8b}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); +EXPECT_EQ(msg.payload_len, 25); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, - 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b}; - lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 25662); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\181\165\155@\151\196\153>\212\208\158e;\229\178\rW&", _pubPktID = 28678, _pubBody = -// "\197b\187\ACKO^\130\182\SI\241\185\141\n\187P", _pubProps = []} +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "2n\201\176\229\EM\245*\ACK\SUB\177\b~\130\155,l", _pubPktID = 18294, _pubBody = "22", _pubProps = []} TEST(Publish311QCTest, Encode11) { - uint8_t pkt[] = {0x32, 0x25, 0x0, 0x12, 0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, - 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26, 0x70, 0x6, 0xc5, 0x62, - 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; - uint8_t topic_bytes[] = {0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, - 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; +uint8_t pkt[] = {0x33, 0x17, 0x0, 0x11, 0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c, 0x47, 0x76, 0x32, 0x32}; + uint8_t topic_bytes[] = {0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xc5, 0x62, 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x32, 0x32}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 2; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 28678, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 18294, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\181\165\155@\151\196\153>\212\208\158e;\229\178\rW&", _pubPktID = 28678, _pubBody = -// "\197b\187\ACKO^\130\182\SI\241\185\141\n\187P", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "2n\201\176\229\EM\245*\ACK\SUB\177\b~\130\155,l", _pubPktID = 18294, _pubBody = "22", _pubProps = []} TEST(Publish311QCTest, Decode11) { - uint8_t pkt[] = {0x32, 0x25, 0x0, 0x12, 0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, - 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26, 0x70, 0x6, 0xc5, 0x62, - 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x33, 0x17, 0x0, 0x11, 0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c, 0x47, 0x76, 0x32, 0x32}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c}; + lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x32, 0x32}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 18294); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); +EXPECT_EQ(msg.payload_len, 2); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, - 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc5, 0x62, 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 28678); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\196x\255\172\&4\CAN?V{\217\182\160\&3\169g\176\192\r\NAK\186s", _pubPktID = 0, _pubBody = "s", _pubProps = []} -TEST(Publish311QCTest, Encode12) { - uint8_t pkt[] = {0x39, 0x18, 0x0, 0x15, 0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, - 0xd9, 0xb6, 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73, 0x73}; - uint8_t topic_bytes[] = {0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, - 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x73}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; - lwmqtt_property_t propslist[] = {}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\SI\221\168J\184\157\208vn\224\GS", _pubPktID = 19130, _pubBody = "=m\162\166\ETX\DEL\SI?\155\155\229\193\RS\194\ETX^\144\196\"\134\199\t\254\147\&1\ESC\221\132", _pubProps = []} +TEST(Publish311QCTest, Encode12) { +uint8_t pkt[] = {0x3c, 0x2b, 0x0, 0xb, 0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d, 0x4a, 0xba, 0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; + uint8_t topic_bytes[] = {0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = false; +uint8_t msg_bytes[] = {0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 28; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 19130, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\196x\255\172\&4\CAN?V{\217\182\160\&3\169g\176\192\r\NAK\186s", _pubPktID = 0, _pubBody = "s", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\SI\221\168J\184\157\208vn\224\GS", _pubPktID = 19130, _pubBody = "=m\162\166\ETX\DEL\SI?\155\155\229\193\RS\194\ETX^\144\196\"\134\199\t\254\147\&1\ESC\221\132", _pubProps = []} TEST(Publish311QCTest, Decode12) { - uint8_t pkt[] = {0x39, 0x18, 0x0, 0x15, 0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, - 0xd9, 0xb6, 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73, 0x73}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, - 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x73}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\136@e", _pubPktID = 1120, _pubBody -// = "U\146=\184\GS9[\230\210\180\157\ENQ\204\240\DC36\FSl0\136\172^\RSr4t7\193\178", _pubProps = []} +uint8_t pkt[] = {0x3c, 0x2b, 0x0, 0xb, 0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d, 0x4a, 0xba, 0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 19130); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); +EXPECT_EQ(msg.payload_len, 28); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\n\159\143\162\210", _pubPktID = 3591, _pubBody = "\156|7\ETB|\195\202\&4y", _pubProps = []} TEST(Publish311QCTest, Encode13) { - uint8_t pkt[] = {0x35, 0x24, 0x0, 0x3, 0x88, 0x40, 0x65, 0x4, 0x60, 0x55, 0x92, 0x3d, 0xb8, - 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, 0x36, 0x1c, - 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; - uint8_t topic_bytes[] = {0x88, 0x40, 0x65}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; +uint8_t pkt[] = {0x32, 0x12, 0x0, 0x5, 0xa, 0x9f, 0x8f, 0xa2, 0xd2, 0xe, 0x7, 0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; + uint8_t topic_bytes[] = {0xa, 0x9f, 0x8f, 0xa2, 0xd2}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, - 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = false; +uint8_t msg_bytes[] = {0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 9; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1120, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3591, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\136@e", _pubPktID = 1120, _pubBody -// = "U\146=\184\GS9[\230\210\180\157\ENQ\204\240\DC36\FSl0\136\172^\RSr4t7\193\178", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\n\159\143\162\210", _pubPktID = 3591, _pubBody = "\156|7\ETB|\195\202\&4y", _pubProps = []} TEST(Publish311QCTest, Decode13) { - uint8_t pkt[] = {0x35, 0x24, 0x0, 0x3, 0x88, 0x40, 0x65, 0x4, 0x60, 0x55, 0x92, 0x3d, 0xb8, - 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, 0x36, 0x1c, - 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x32, 0x12, 0x0, 0x5, 0xa, 0x9f, 0x8f, 0xa2, 0xd2, 0xe, 0x7, 0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xa, 0x9f, 0x8f, 0xa2, 0xd2}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 3591); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); +EXPECT_EQ(msg.payload_len, 9); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x88, 0x40, 0x65}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, - 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 1120); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\156\129\b\202\ETB\"y\195\204\150S\DLE\231\CANg\207\&0\n\246~U\196\194\&5", _pubPktID = 17194, _pubBody = -// "\158\237", _pubProps = []} +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\158\ESC\165s\240j\195I_\176\246\204\148I\213T\244\169E", _pubPktID = 15997, _pubBody = "tS\247\226P\227\&3\NUL\222\DC37I\219'", _pubProps = []} TEST(Publish311QCTest, Encode14) { - uint8_t pkt[] = {0x33, 0x1e, 0x0, 0x18, 0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, - 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35, 0x43, 0x2a, 0x9e, 0xed}; - uint8_t topic_bytes[] = {0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, - 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x9e, 0xed}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x33, 0x25, 0x0, 0x13, 0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45, 0x3e, 0x7d, 0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; + uint8_t topic_bytes[] = {0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 14; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 17194, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15997, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\156\129\b\202\ETB\"y\195\204\150S\DLE\231\CANg\207\&0\n\246~U\196\194\&5", _pubPktID = 17194, _pubBody = -// "\158\237", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\158\ESC\165s\240j\195I_\176\246\204\148I\213T\244\169E", _pubPktID = 15997, _pubBody = "tS\247\226P\227\&3\NUL\222\DC37I\219'", _pubProps = []} TEST(Publish311QCTest, Decode14) { - uint8_t pkt[] = {0x33, 0x1e, 0x0, 0x18, 0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, - 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35, 0x43, 0x2a, 0x9e, 0xed}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, - 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35}; - lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9e, 0xed}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 17194); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// ")\223\215<\151R\ENQ\DC3I\131&\207\&4\179\156\CAN\SO", _pubPktID = 18606, _pubBody = "\208Zo\214\246#v", _pubProps = -// []} +uint8_t pkt[] = {0x33, 0x25, 0x0, 0x13, 0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45, 0x3e, 0x7d, 0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45}; + lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 15997); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); +EXPECT_EQ(msg.payload_len, 14); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\224\135\179\172\244\254\241]\218|\ESC\137/", _pubPktID = 30908, _pubBody = "\235c=\156\"\206\185spp`\235\216", _pubProps = []} TEST(Publish311QCTest, Encode15) { - uint8_t pkt[] = {0x35, 0x1c, 0x0, 0x11, 0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, 0x83, 0x26, - 0xcf, 0x34, 0xb3, 0x9c, 0x18, 0xe, 0x48, 0xae, 0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; - uint8_t topic_bytes[] = {0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, - 0x83, 0x26, 0xcf, 0x34, 0xb3, 0x9c, 0x18, 0xe}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x32, 0x1f, 0x0, 0xe, 0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f, 0x78, 0xbc, 0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; + uint8_t topic_bytes[] = {0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = false; +uint8_t msg_bytes[] = {0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 13; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 18606, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 30908, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// ")\223\215<\151R\ENQ\DC3I\131&\207\&4\179\156\CAN\SO", _pubPktID = 18606, _pubBody = "\208Zo\214\246#v", _pubProps = -// []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\224\135\179\172\244\254\241]\218|\ESC\137/", _pubPktID = 30908, _pubBody = "\235c=\156\"\206\185spp`\235\216", _pubProps = []} TEST(Publish311QCTest, Decode15) { - uint8_t pkt[] = {0x35, 0x1c, 0x0, 0x11, 0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, 0x83, 0x26, - 0xcf, 0x34, 0xb3, 0x9c, 0x18, 0xe, 0x48, 0xae, 0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, - 0x83, 0x26, 0xcf, 0x34, 0xb3, 0x9c, 0x18, 0xe}; - lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 18606); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\168E\247k\237\175\&5\SO\SYNU\224\160", _pubPktID = 28189, _pubBody = "", _pubProps = []} +uint8_t pkt[] = {0x32, 0x1f, 0x0, 0xe, 0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f, 0x78, 0xbc, 0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 30908); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); +EXPECT_EQ(msg.payload_len, 13); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\233\218E\235\207\216\&6b\236\246\&0?\169D\196\137\228\212\200\179\RS\159", _pubPktID = 7795, _pubBody = ")\a\246\&4J\134\237\148\159\143:\EOT\237lN\252D\144\179\163'7\208\193\240", _pubProps = []} TEST(Publish311QCTest, Encode16) { - uint8_t pkt[] = {0x35, 0x10, 0x0, 0xc, 0xa8, 0x45, 0xf7, 0x6b, 0xed, - 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0, 0x6e, 0x1d}; - uint8_t topic_bytes[] = {0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; +uint8_t pkt[] = {0x3d, 0x33, 0x0, 0x16, 0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f, 0x1e, 0x73, 0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; + uint8_t topic_bytes[] = {0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 25; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 28189, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7795, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\168E\247k\237\175\&5\SO\SYNU\224\160", _pubPktID = 28189, _pubBody = "", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\233\218E\235\207\216\&6b\236\246\&0?\169D\196\137\228\212\200\179\RS\159", _pubPktID = 7795, _pubBody = ")\a\246\&4J\134\237\148\159\143:\EOT\237lN\252D\144\179\163'7\208\193\240", _pubProps = []} TEST(Publish311QCTest, Decode16) { - uint8_t pkt[] = {0x35, 0x10, 0x0, 0xc, 0xa8, 0x45, 0xf7, 0x6b, 0xed, - 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0, 0x6e, 0x1d}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3d, 0x33, 0x0, 0x16, 0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f, 0x1e, 0x73, 0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 7795); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); +EXPECT_EQ(msg.payload_len, 25); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 28189); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\191\CAN?\r\149\&0\185\198\tZ\213\STX5\192\195", _pubPktID = 0, _pubBody = "\190\206\169pC<\142\135\&8\243", -// _pubProps = []} +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "i\236\180\192[~\199\179\163\147g\v\219?\135\190L\237\DC1\STX`", _pubPktID = 2871, _pubBody = "\166\217", _pubProps = []} TEST(Publish311QCTest, Encode17) { - uint8_t pkt[] = {0x39, 0x1b, 0x0, 0xf, 0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, - 0x2, 0x35, 0xc0, 0xc3, 0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; - uint8_t topic_bytes[] = {0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, 0x2, 0x35, 0xc0, 0xc3}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; +uint8_t pkt[] = {0x3d, 0x1b, 0x0, 0x15, 0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60, 0xb, 0x37, 0xa6, 0xd9}; + uint8_t topic_bytes[] = {0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0xa6, 0xd9}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 2; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2871, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\191\CAN?\r\149\&0\185\198\tZ\213\STX5\192\195", _pubPktID = 0, _pubBody = "\190\206\169pC<\142\135\&8\243", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "i\236\180\192[~\199\179\163\147g\v\219?\135\190L\237\DC1\STX`", _pubPktID = 2871, _pubBody = "\166\217", _pubProps = []} TEST(Publish311QCTest, Decode17) { - uint8_t pkt[] = {0x39, 0x1b, 0x0, 0xf, 0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, - 0x2, 0x35, 0xc0, 0xc3, 0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3d, 0x1b, 0x0, 0x15, 0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60, 0xb, 0x37, 0xa6, 0xd9}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa6, 0xd9}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 2871); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); +EXPECT_EQ(msg.payload_len, 2); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, 0x2, 0x35, 0xc0, 0xc3}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; - lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\209\227N0}\DEL\200\186\135Q\178Ab\227[N~\173\197\252P", _pubPktID = 17259, _pubBody = -// "\211\&9\214\163\194\138\\\205\223\162\148\156\131\232\SYN\215\213\DC4\174", _pubProps = []} -TEST(Publish311QCTest, Encode18) { - uint8_t pkt[] = {0x3d, 0x2c, 0x0, 0x15, 0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, 0x41, - 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50, 0x43, 0x6b, 0xd3, 0x39, 0xd6, 0xa3, 0xc2, - 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; - uint8_t topic_bytes[] = {0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, - 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, - 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; - lwmqtt_property_t propslist[] = {}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "bc", _pubPktID = 16588, _pubBody = "BE\CAN\DEL\135:\DLE\226{E\240\163\&8oT+~\213", _pubProps = []} +TEST(Publish311QCTest, Encode18) { +uint8_t pkt[] = {0x33, 0x18, 0x0, 0x2, 0x62, 0x63, 0x40, 0xcc, 0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; + uint8_t topic_bytes[] = {0x62, 0x63}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 18; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 17259, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16588, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\209\227N0}\DEL\200\186\135Q\178Ab\227[N~\173\197\252P", _pubPktID = 17259, _pubBody = -// "\211\&9\214\163\194\138\\\205\223\162\148\156\131\232\SYN\215\213\DC4\174", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "bc", _pubPktID = 16588, _pubBody = "BE\CAN\DEL\135:\DLE\226{E\240\163\&8oT+~\213", _pubProps = []} TEST(Publish311QCTest, Decode18) { - uint8_t pkt[] = {0x3d, 0x2c, 0x0, 0x15, 0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, 0x41, - 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50, 0x43, 0x6b, 0xd3, 0x39, 0xd6, 0xa3, 0xc2, - 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, - 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, - 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 17259); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\157\255\149\212\150\224\139\154J\197\&0C\166\189\203/\179f$J\197-\r\240\SUB\188;\r\173", _pubPktID = 22738, -// _pubBody = "\210\DC1\143z\164\179\bD\DELn", _pubProps = []} +uint8_t pkt[] = {0x33, 0x18, 0x0, 0x2, 0x62, 0x63, 0x40, 0xcc, 0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x62, 0x63}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 16588); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); +EXPECT_EQ(msg.payload_len, 18); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3\255\173\206\232\229\219\SOH\SUB\237\217\218}\ENQ\DC3", _pubPktID = 0, _pubBody = "\184", _pubProps = []} TEST(Publish311QCTest, Encode19) { - uint8_t pkt[] = {0x3c, 0x2b, 0x0, 0x1d, 0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, - 0x43, 0xa6, 0xbd, 0xcb, 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, - 0x3b, 0xd, 0xad, 0x58, 0xd2, 0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; - uint8_t topic_bytes[] = {0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, 0x43, 0xa6, 0xbd, 0xcb, - 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, 0x3b, 0xd, 0xad}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; +uint8_t pkt[] = {0x31, 0x12, 0x0, 0xf, 0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13, 0xb8}; + uint8_t topic_bytes[] = {0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = true; +uint8_t msg_bytes[] = {0xb8}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 1; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 22738, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\157\255\149\212\150\224\139\154J\197\&0C\166\189\203/\179f$J\197-\r\240\SUB\188;\r\173", _pubPktID = 22738, -// _pubBody = "\210\DC1\143z\164\179\bD\DELn", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3\255\173\206\232\229\219\SOH\SUB\237\217\218}\ENQ\DC3", _pubPktID = 0, _pubBody = "\184", _pubProps = []} TEST(Publish311QCTest, Decode19) { - uint8_t pkt[] = {0x3c, 0x2b, 0x0, 0x1d, 0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, - 0x43, 0xa6, 0xbd, 0xcb, 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, - 0x3b, 0xd, 0xad, 0x58, 0xd2, 0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x31, 0x12, 0x0, 0xf, 0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13, 0xb8}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb8}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); +EXPECT_EQ(msg.payload_len, 1); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, 0x43, 0xa6, 0xbd, 0xcb, - 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, 0x3b, 0xd, 0xad}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; - lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 22738); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 6071, _pubBody = -// "#\140\138\233\171\140\SOH9\165\168kP\138\237?\192\174", _pubProps = []} +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\134\&2\209f\v\148F\254 \253\tm", _pubPktID = 25649, _pubBody = "!mj\ACK\181\179\t\252S\212\144\149\130\150X", _pubProps = []} TEST(Publish311QCTest, Encode20) { - uint8_t pkt[] = {0x3b, 0x15, 0x0, 0x0, 0x17, 0xb7, 0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, - 0x1, 0x39, 0xa5, 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; +uint8_t pkt[] = {0x3b, 0x1f, 0x0, 0xc, 0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d, 0x64, 0x31, 0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; + uint8_t topic_bytes[] = {0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, - 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 15; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6071, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25649, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 6071, _pubBody = -// "#\140\138\233\171\140\SOH9\165\168kP\138\237?\192\174", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\134\&2\209f\v\148F\254 \253\tm", _pubPktID = 25649, _pubBody = "!mj\ACK\181\179\t\252S\212\144\149\130\150X", _pubProps = []} TEST(Publish311QCTest, Decode20) { - uint8_t pkt[] = {0x3b, 0x15, 0x0, 0x0, 0x17, 0xb7, 0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, - 0x1, 0x39, 0xa5, 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3b, 0x1f, 0x0, 0xc, 0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d, 0x64, 0x31, 0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 25649); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); +EXPECT_EQ(msg.payload_len, 15); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, - 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 6071); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "(topic.data), 2); +EXPECT_EQ(msg.payload_len, 3); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3c, 0x6d, 0x39}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb0, 0x85, 0xcb, 0x4a, 0x93, 0x41, 0xf0, 0x4b, 0xb9, 0x6b, 0x91, 0x3a, 0x22, - 0xea, 0xfc, 0xe2, 0xf8, 0x57, 0x7c, 0xda, 0xb, 0xf8, 0x2a, 0xa, 0x16}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 5951); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 29931, _pubBody = -// "\254t\DLE\GS|r\CAN\243)\RS\151\DC4/_\229b\\", _pubProps = []} +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "<\t\"\209\184\182u\179\DLE\NAK\195\141\EM\237\189}\143\EOT\STX\188|\188\t\USv\US\209\"\STX", _pubPktID = 17374, _pubBody = "\"=\237\FS\247\238\129>oH\131~\158k\231\193}\194\ESCu", _pubProps = []} TEST(Publish311QCTest, Encode22) { - uint8_t pkt[] = {0x3c, 0x15, 0x0, 0x0, 0x74, 0xeb, 0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, - 0x18, 0xf3, 0x29, 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; +uint8_t pkt[] = {0x3a, 0x35, 0x0, 0x1d, 0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2, 0x43, 0xde, 0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; + uint8_t topic_bytes[] = {0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, - 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = false; +uint8_t msg_bytes[] = {0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 20; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 29931, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 17374, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 29931, _pubBody = -// "\254t\DLE\GS|r\CAN\243)\RS\151\DC4/_\229b\\", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "<\t\"\209\184\182u\179\DLE\NAK\195\141\EM\237\189}\143\EOT\STX\188|\188\t\USv\US\209\"\STX", _pubPktID = 17374, _pubBody = "\"=\237\FS\247\238\129>oH\131~\158k\231\193}\194\ESCu", _pubProps = []} TEST(Publish311QCTest, Decode22) { - uint8_t pkt[] = {0x3c, 0x15, 0x0, 0x0, 0x74, 0xeb, 0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, - 0x18, 0xf3, 0x29, 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3a, 0x35, 0x0, 0x1d, 0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2, 0x43, 0xde, 0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 17374); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); +EXPECT_EQ(msg.payload_len, 20); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, - 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 29931); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\128\158-GrC\129\166\140\231\NULj!M4\SUB", _pubPktID = 0, _pubBody = -// "\228\ESC\231\DC3\136\217\177W_\ESCp\130\DC2\212,\158\236\215\204\207m\205", _pubProps = []} +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "L\250\DC3", _pubPktID = 6223, _pubBody = ".K\236\242\210\250\192\219\175h\175p\249", _pubProps = []} TEST(Publish311QCTest, Encode23) { - uint8_t pkt[] = {0x31, 0x28, 0x0, 0x10, 0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, 0x8c, 0xe7, - 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a, 0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, - 0x5f, 0x1b, 0x70, 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; - uint8_t topic_bytes[] = {0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, - 0x8c, 0xe7, 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, 0x1b, 0x70, - 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x35, 0x14, 0x0, 0x3, 0x4c, 0xfa, 0x13, 0x18, 0x4f, 0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; + uint8_t topic_bytes[] = {0x4c, 0xfa, 0x13}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 13; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 6223, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\128\158-GrC\129\166\140\231\NULj!M4\SUB", _pubPktID = 0, _pubBody = -// "\228\ESC\231\DC3\136\217\177W_\ESCp\130\DC2\212,\158\236\215\204\207m\205", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "L\250\DC3", _pubPktID = 6223, _pubBody = ".K\236\242\210\250\192\219\175h\175p\249", _pubProps = []} TEST(Publish311QCTest, Decode23) { - uint8_t pkt[] = {0x31, 0x28, 0x0, 0x10, 0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, 0x8c, 0xe7, - 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a, 0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, - 0x5f, 0x1b, 0x70, 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x35, 0x14, 0x0, 0x3, 0x4c, 0xfa, 0x13, 0x18, 0x4f, 0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x4c, 0xfa, 0x13}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 6223); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); +EXPECT_EQ(msg.payload_len, 13); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, - 0x8c, 0xe7, 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a}; - lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, 0x1b, 0x70, - 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "s\233\140\183\209=t\220\206\194\143\249\ETX\234\&5\b\144\f\246\250\US\193\193\178\226\201\156", _pubPktID = 8248, -// _pubBody = "v\196\240]\193r\165~\158\205\155'\206\&8\215s\248\196\250\&1\247", _pubProps = []} -TEST(Publish311QCTest, Encode24) { - uint8_t pkt[] = {0x34, 0x34, 0x0, 0x1b, 0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, - 0x8f, 0xf9, 0x3, 0xea, 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, - 0xe2, 0xc9, 0x9c, 0x20, 0x38, 0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, - 0xcd, 0x9b, 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; - uint8_t topic_bytes[] = {0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, 0x3, 0xea, - 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, - 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - lwmqtt_property_t propslist[] = {}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "^;.\197y\SO\163S\245~\178g\ETB", _pubPktID = 32148, _pubBody = "V\DC4\DC3 ZQ\164[\157n\197\162X\"*\220LH\RSF\206\255)Xpu!=", _pubProps = []} +TEST(Publish311QCTest, Encode24) { +uint8_t pkt[] = {0x34, 0x2d, 0x0, 0xd, 0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17, 0x7d, 0x94, 0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; + uint8_t topic_bytes[] = {0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = false; +uint8_t msg_bytes[] = {0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 28; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8248, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32148, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "s\233\140\183\209=t\220\206\194\143\249\ETX\234\&5\b\144\f\246\250\US\193\193\178\226\201\156", _pubPktID = 8248, -// _pubBody = "v\196\240]\193r\165~\158\205\155'\206\&8\215s\248\196\250\&1\247", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "^;.\197y\SO\163S\245~\178g\ETB", _pubPktID = 32148, _pubBody = "V\DC4\DC3 ZQ\164[\157n\197\162X\"*\220LH\RSF\206\255)Xpu!=", _pubProps = []} TEST(Publish311QCTest, Decode24) { - uint8_t pkt[] = {0x34, 0x34, 0x0, 0x1b, 0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, - 0x8f, 0xf9, 0x3, 0xea, 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, - 0xe2, 0xc9, 0x9c, 0x20, 0x38, 0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, - 0xcd, 0x9b, 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, 0x3, 0xea, - 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, - 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 8248); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\146;?\158\252\\a5\133\233\144\&9O\159\231\133\240}\DC1\200\&9\154a%\176Y", _pubPktID = 0, _pubBody = -// "\173\221\&2\157\129qMv\218\&6\216\165J\tp\242\205\&2\194t\243\161\STX?", _pubProps = []} +uint8_t pkt[] = {0x34, 0x2d, 0x0, 0xd, 0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17, 0x7d, 0x94, 0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 32148); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); +EXPECT_EQ(msg.payload_len, 28); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "Vk\181\201\ETXZ\DC4\208\170\201\tDEB\153]Q\232", _pubPktID = 2981, _pubBody = "\\>V\153p|W\163\148\254\SYN@q\238?", _pubProps = []} TEST(Publish311QCTest, Encode25) { - uint8_t pkt[] = {0x39, 0x34, 0x0, 0x1a, 0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, - 0x90, 0x39, 0x4f, 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, - 0xb0, 0x59, 0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, - 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; - uint8_t topic_bytes[] = {0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, 0x90, 0x39, 0x4f, - 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, 0xb0, 0x59}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, - 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x34, 0x25, 0x0, 0x12, 0x56, 0x6b, 0xb5, 0xc9, 0x3, 0x5a, 0x14, 0xd0, 0xaa, 0xc9, 0x9, 0x44, 0x45, 0x42, 0x99, 0x5d, 0x51, 0xe8, 0xb, 0xa5, 0x5c, 0x3e, 0x56, 0x99, 0x70, 0x7c, 0x57, 0xa3, 0x94, 0xfe, 0x16, 0x40, 0x71, 0xee, 0x3f}; + uint8_t topic_bytes[] = {0x56, 0x6b, 0xb5, 0xc9, 0x3, 0x5a, 0x14, 0xd0, 0xaa, 0xc9, 0x9, 0x44, 0x45, 0x42, 0x99, 0x5d, 0x51, 0xe8}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = false; +uint8_t msg_bytes[] = {0x5c, 0x3e, 0x56, 0x99, 0x70, 0x7c, 0x57, 0xa3, 0x94, 0xfe, 0x16, 0x40, 0x71, 0xee, 0x3f}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 15; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 2981, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\146;?\158\252\\a5\133\233\144\&9O\159\231\133\240}\DC1\200\&9\154a%\176Y", _pubPktID = 0, _pubBody = -// "\173\221\&2\157\129qMv\218\&6\216\165J\tp\242\205\&2\194t\243\161\STX?", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "Vk\181\201\ETXZ\DC4\208\170\201\tDEB\153]Q\232", _pubPktID = 2981, _pubBody = "\\>V\153p|W\163\148\254\SYN@q\238?", _pubProps = []} TEST(Publish311QCTest, Decode25) { - uint8_t pkt[] = {0x39, 0x34, 0x0, 0x1a, 0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, - 0x90, 0x39, 0x4f, 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, - 0xb0, 0x59, 0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, - 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x34, 0x25, 0x0, 0x12, 0x56, 0x6b, 0xb5, 0xc9, 0x3, 0x5a, 0x14, 0xd0, 0xaa, 0xc9, 0x9, 0x44, 0x45, 0x42, 0x99, 0x5d, 0x51, 0xe8, 0xb, 0xa5, 0x5c, 0x3e, 0x56, 0x99, 0x70, 0x7c, 0x57, 0xa3, 0x94, 0xfe, 0x16, 0x40, 0x71, 0xee, 0x3f}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x56, 0x6b, 0xb5, 0xc9, 0x3, 0x5a, 0x14, 0xd0, 0xaa, 0xc9, 0x9, 0x44, 0x45, 0x42, 0x99, 0x5d, 0x51, 0xe8}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5c, 0x3e, 0x56, 0x99, 0x70, 0x7c, 0x57, 0xa3, 0x94, 0xfe, 0x16, 0x40, 0x71, 0xee, 0x3f}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 2981); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); +EXPECT_EQ(msg.payload_len, 15); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, 0x90, 0x39, 0x4f, - 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, 0xb0, 0x59}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, - 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "?X\254\SIJ/\199\240\153I\171-\227\213\191\205\b\202\247\252\a\196\136\150\215K\\R", _pubPktID = 0, _pubBody = -// "\167\192W\238\177\207\SO\148\212\134\&6\145\223N\168", _pubProps = []} +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 12988, _pubBody = "\252Q\161\SUB\150\190\247\174s\151T8\149C\NAK9;)\159\188\140bs", _pubProps = []} TEST(Publish311QCTest, Encode26) { - uint8_t pkt[] = {0x31, 0x2d, 0x0, 0x1c, 0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, - 0xe3, 0xd5, 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52, - 0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; - uint8_t topic_bytes[] = {0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, 0xe3, 0xd5, - 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x33, 0x1b, 0x0, 0x0, 0x32, 0xbc, 0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 23; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 12988, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "?X\254\SIJ/\199\240\153I\171-\227\213\191\205\b\202\247\252\a\196\136\150\215K\\R", _pubPktID = 0, _pubBody = -// "\167\192W\238\177\207\SO\148\212\134\&6\145\223N\168", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 12988, _pubBody = "\252Q\161\SUB\150\190\247\174s\151T8\149C\NAK9;)\159\188\140bs", _pubProps = []} TEST(Publish311QCTest, Decode26) { - uint8_t pkt[] = {0x31, 0x2d, 0x0, 0x1c, 0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, - 0xe3, 0xd5, 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52, - 0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x33, 0x1b, 0x0, 0x0, 0x32, 0xbc, 0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 12988); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); +EXPECT_EQ(msg.payload_len, 23); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, 0xe3, 0xd5, - 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\144\167\130\179A", _pubPktID = 0, -// _pubBody = "\148\134\185\213\184\233\187\157\198\233\181\148_\215\n$@\169\251\210\184\f", _pubProps = []} -TEST(Publish311QCTest, Encode27) { - uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x5, 0x90, 0xa7, 0x82, 0xb3, 0x41, 0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, - 0x9d, 0xc6, 0xe9, 0xb5, 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; - uint8_t topic_bytes[] = {0x90, 0xa7, 0x82, 0xb3, 0x41}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, - 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; - lwmqtt_property_t propslist[] = {}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\a\206+\241_)~\225\174V\232:\184e", _pubPktID = 1045, _pubBody = "E\243x", _pubProps = []} +TEST(Publish311QCTest, Encode27) { +uint8_t pkt[] = {0x33, 0x15, 0x0, 0xe, 0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65, 0x4, 0x15, 0x45, 0xf3, 0x78}; + uint8_t topic_bytes[] = {0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x45, 0xf3, 0x78}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 3; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1045, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\144\167\130\179A", _pubPktID = 0, -// _pubBody = "\148\134\185\213\184\233\187\157\198\233\181\148_\215\n$@\169\251\210\184\f", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\a\206+\241_)~\225\174V\232:\184e", _pubPktID = 1045, _pubBody = "E\243x", _pubProps = []} TEST(Publish311QCTest, Decode27) { - uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x5, 0x90, 0xa7, 0x82, 0xb3, 0x41, 0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, - 0x9d, 0xc6, 0xe9, 0xb5, 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x33, 0x15, 0x0, 0xe, 0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65, 0x4, 0x15, 0x45, 0xf3, 0x78}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x45, 0xf3, 0x78}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 1045); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); +EXPECT_EQ(msg.payload_len, 3); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x90, 0xa7, 0x82, 0xb3, 0x41}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, - 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\187\249\143~(e\135", _pubProps = []} +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\193`\187\247\203\252\193V\159\209\143}w\180\219\226\"\181nuE\nC\175-\SUB\141", _pubPktID = 0, _pubBody = "\213(\SUB\v\FS\224\252\152%p_*#w\218\204\240\237>\246", _pubProps = []} TEST(Publish311QCTest, Encode28) { - uint8_t pkt[] = {0x39, 0x9, 0x0, 0x0, 0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; +uint8_t pkt[] = {0x30, 0x31, 0x0, 0x1b, 0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d, 0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; + uint8_t topic_bytes[] = {0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = false; +uint8_t msg_bytes[] = {0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 20; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\187\249\143~(e\135", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\193`\187\247\203\252\193V\159\209\143}w\180\219\226\"\181nuE\nC\175-\SUB\141", _pubPktID = 0, _pubBody = "\213(\SUB\v\FS\224\252\152%p_*#w\218\204\240\237>\246", _pubProps = []} TEST(Publish311QCTest, Decode28) { - uint8_t pkt[] = {0x39, 0x9, 0x0, 0x0, 0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x30, 0x31, 0x0, 0x1b, 0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d, 0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); +EXPECT_EQ(msg.payload_len, 20); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "h\137\169\166b`\193\RS\133\235I\188\167\&9\DC1\161uN\176\SOf\ACK-O\194\vo", _pubPktID = 7918, _pubBody = -// "G\142\SYN\154\171\162\185\ENQg\129\240\186 \199\202{\CAN\233\v^\170", _pubProps = []} -TEST(Publish311QCTest, Encode29) { - uint8_t pkt[] = {0x3a, 0x34, 0x0, 0x1b, 0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, - 0x49, 0xbc, 0xa7, 0x39, 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, - 0xc2, 0xb, 0x6f, 0x1e, 0xee, 0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, - 0x81, 0xf0, 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; - uint8_t topic_bytes[] = {0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, - 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0xc2, 0xb, 0x6f}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, - 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - lwmqtt_property_t propslist[] = {}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "}\180", _pubPktID = 11899, _pubBody = "\DC2\ACK%\181\DC3\164\204\173\204\223\DC2\161\&3uzk\152Xn\200\154d\154\143\245z\234", _pubProps = []} +TEST(Publish311QCTest, Encode29) { +uint8_t pkt[] = {0x34, 0x21, 0x0, 0x2, 0x7d, 0xb4, 0x2e, 0x7b, 0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; + uint8_t topic_bytes[] = {0x7d, 0xb4}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = false; +uint8_t msg_bytes[] = {0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 27; + + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7918, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 11899, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "h\137\169\166b`\193\RS\133\235I\188\167\&9\DC1\161uN\176\SOf\ACK-O\194\vo", _pubPktID = 7918, _pubBody = -// "G\142\SYN\154\171\162\185\ENQg\129\240\186 \199\202{\CAN\233\v^\170", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "}\180", _pubPktID = 11899, _pubBody = "\DC2\ACK%\181\DC3\164\204\173\204\223\DC2\161\&3uzk\152Xn\200\154d\154\143\245z\234", _pubProps = []} TEST(Publish311QCTest, Decode29) { - uint8_t pkt[] = {0x3a, 0x34, 0x0, 0x1b, 0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, - 0x49, 0xbc, 0xa7, 0x39, 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, - 0xc2, 0xb, 0x6f, 0x1e, 0xee, 0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, - 0x81, 0xf0, 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, - 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0xc2, 0xb, 0x6f}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, - 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 7918); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "k\r\250c\140\225\149\144@\133", -// _pubPktID = 0, _pubBody = "',/I\RSD\195\229\202", _pubProps = []} +uint8_t pkt[] = {0x34, 0x21, 0x0, 0x2, 0x7d, 0xb4, 0x2e, 0x7b, 0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7d, 0xb4}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 11899); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); +EXPECT_EQ(msg.payload_len, 27); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\tnz^#/~y\225", _pubPktID = 17773, _pubBody = "\130\\'n\215\&3\DC2\219\205\147\SOI\183c", _pubProps = []} TEST(Publish311QCTest, Encode30) { - uint8_t pkt[] = {0x30, 0x15, 0x0, 0xa, 0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, - 0x40, 0x85, 0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; - uint8_t topic_bytes[] = {0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, 0x40, 0x85}; +uint8_t pkt[] = {0x3b, 0x1c, 0x0, 0xa, 0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1, 0x45, 0x6d, 0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; + uint8_t topic_bytes[] = {0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1}; lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 14; - lwmqtt_property_t propslist[] = {}; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 17773, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "k\r\250c\140\225\149\144@\133", -// _pubPktID = 0, _pubBody = "',/I\RSD\195\229\202", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\tnz^#/~y\225", _pubPktID = 17773, _pubBody = "\130\\'n\215\&3\DC2\219\205\147\SOI\183c", _pubProps = []} TEST(Publish311QCTest, Decode30) { - uint8_t pkt[] = {0x30, 0x15, 0x0, 0xa, 0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, - 0x40, 0x85, 0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, 0x40, 0x85}; +uint8_t pkt[] = {0x3b, 0x1c, 0x0, 0xa, 0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1, 0x45, 0x6d, 0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1}; lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "#\234\SI\231\179\228\175!\174\132/\ETXg\US\r\STX\178\203\151\187\DC3C", _pubPktID = 3425, _pubBody = ":\171^C\n", -// _pubProps = [PropResponseTopic "^\255\219\212\234E\196\NAK\v\231\230\148(\SO\196'",PropResponseInformation -// "r{\180za]\185U\204\128\131@\226\&4b<",PropTopicAliasMaximum 25499]} -TEST(Publish5QCTest, Encode1) { - uint8_t pkt[] = {0x32, 0x49, 0x0, 0x16, 0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, - 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43, 0xd, 0x61, 0x29, 0x8, - 0x0, 0x10, 0x5e, 0xff, 0xdb, 0xd4, 0xea, 0x45, 0xc4, 0x15, 0xb, 0xe7, 0xe6, 0x94, 0x28, - 0xe, 0xc4, 0x27, 0x1a, 0x0, 0x10, 0x72, 0x7b, 0xb4, 0x7a, 0x61, 0x5d, 0xb9, 0x55, 0xcc, - 0x80, 0x83, 0x40, 0xe2, 0x34, 0x62, 0x3c, 0x22, 0x63, 0x9b, 0x3a, 0xab, 0x5e, 0x43, 0xa}; - uint8_t topic_bytes[] = {0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, - 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t exp_body_bytes[] = {0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 17773); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); +EXPECT_EQ(msg.payload_len, 14); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x3a, 0xab, 0x5e, 0x43, 0xa}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; - uint8_t bytesprops0[] = {0x5e, 0xff, 0xdb, 0xd4, 0xea, 0x45, 0xc4, 0x15, - 0xb, 0xe7, 0xe6, 0x94, 0x28, 0xe, 0xc4, 0x27}; - uint8_t bytesprops1[] = {0x72, 0x7b, 0xb4, 0x7a, 0x61, 0x5d, 0xb9, 0x55, - 0xcc, 0x80, 0x83, 0x40, 0xe2, 0x34, 0x62, 0x3c}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = ";\135[\241\201\187\168\ETX\227\158\138\182\179\234\250\172\152\219\131\130!", _pubPktID = 24061, _pubBody = "\206\141\147\181o\253", _pubProps = [PropReceiveMaximum 21932,PropResponseInformation "c",PropMessageExpiryInterval 8939,PropAuthenticationData "y-+h",PropAssignedClientIdentifier "\RS\196RZ\231\&1Uh\149\146\237\168\NULH6\177F\246?\173\&4\137",PropAuthenticationData "m\227^\190\239\&1\240\232\EM\EM\128\149",PropServerKeepAlive 8119,PropResponseInformation "^\181\206\129aT\236\140",PropMaximumQoS 52,PropRequestResponseInformation 210,PropReceiveMaximum 8685,PropResponseInformation "\195\129\177\EM\STX~\194\n\207\204I\144@\226",PropMessageExpiryInterval 8052,PropReasonString "\215\213\194@e\ENQ\228\160\&6\143\GSC\ENQ\237Y?\208WL\130\250fRp\234",PropAuthenticationData "\233\DC4\217\246,\196\&4|\ESC'\236\232\150\152",PropMessageExpiryInterval 26546,PropWillDelayInterval 17713,PropSessionExpiryInterval 9284,PropContentType "\ACK@\193\237\DEL\251\ENQ\180yY\193",PropSharedSubscriptionAvailable 36,PropPayloadFormatIndicator 21,PropRequestResponseInformation 253,PropAuthenticationMethod "\DC4\179\189\165`\r\184HTgYh\211X\243;\134\151aY",PropSessionExpiryInterval 11426,PropUserProperty "HG\241{qJ\211\174\DC3\240\196\SO\133\EOT\ENQ\242u\129" "\164\216q\n\STX\STX\198\193D+\229\177",PropAuthenticationMethod "\130p\171\204s\CAN\234\&0\206:,\248\194\NAK}`\142!Yn\199$\224f\242&\135",PropAuthenticationData "\166\196`\240\&2\v\DEL\141\244\DC1*\200\218\202\215\210m\234\SOH\207[\166",PropReasonString "\150\SUB\183",PropTopicAlias 18572,PropMaximumPacketSize 6297]} +TEST(Publish5QCTest, Encode1) { +uint8_t pkt[] = {0x33, 0xdb, 0x2, 0x0, 0x15, 0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21, 0x5d, 0xfd, 0xba, 0x2, 0x21, 0x55, 0xac, 0x1a, 0x0, 0x1, 0x63, 0x2, 0x0, 0x0, 0x22, 0xeb, 0x16, 0x0, 0x4, 0x79, 0x2d, 0x2b, 0x68, 0x12, 0x0, 0x16, 0x1e, 0xc4, 0x52, 0x5a, 0xe7, 0x31, 0x55, 0x68, 0x95, 0x92, 0xed, 0xa8, 0x0, 0x48, 0x36, 0xb1, 0x46, 0xf6, 0x3f, 0xad, 0x34, 0x89, 0x16, 0x0, 0xc, 0x6d, 0xe3, 0x5e, 0xbe, 0xef, 0x31, 0xf0, 0xe8, 0x19, 0x19, 0x80, 0x95, 0x13, 0x1f, 0xb7, 0x1a, 0x0, 0x8, 0x5e, 0xb5, 0xce, 0x81, 0x61, 0x54, 0xec, 0x8c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 0x8e, 0x21, 0x59, 0x6e, 0xc7, 0x24, 0xe0, 0x66, 0xf2, 0x26, 0x87, 0x16, 0x0, 0x16, 0xa6, 0xc4, 0x60, 0xf0, 0x32, 0xb, 0x7f, 0x8d, 0xf4, 0x11, 0x2a, 0xc8, 0xda, 0xca, 0xd7, 0xd2, 0x6d, 0xea, 0x1, 0xcf, 0x5b, 0xa6, 0x1f, 0x0, 0x3, 0x96, 0x1a, 0xb7, 0x23, 0x48, 0x8c, 0x27, 0x0, 0x0, 0x18, 0x99, 0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; + uint8_t topic_bytes[] = {0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 6; + + uint8_t bytesprops0[] = {0x63}; + uint8_t bytesprops1[] = {0x79, 0x2d, 0x2b, 0x68}; + uint8_t bytesprops2[] = {0x1e, 0xc4, 0x52, 0x5a, 0xe7, 0x31, 0x55, 0x68, 0x95, 0x92, 0xed, 0xa8, 0x0, 0x48, 0x36, 0xb1, 0x46, 0xf6, 0x3f, 0xad, 0x34, 0x89}; + uint8_t bytesprops3[] = {0x6d, 0xe3, 0x5e, 0xbe, 0xef, 0x31, 0xf0, 0xe8, 0x19, 0x19, 0x80, 0x95}; + uint8_t bytesprops4[] = {0x5e, 0xb5, 0xce, 0x81, 0x61, 0x54, 0xec, 0x8c}; + uint8_t bytesprops5[] = {0xc3, 0x81, 0xb1, 0x19, 0x2, 0x7e, 0xc2, 0xa, 0xcf, 0xcc, 0x49, 0x90, 0x40, 0xe2}; + uint8_t bytesprops6[] = {0xd7, 0xd5, 0xc2, 0x40, 0x65, 0x5, 0xe4, 0xa0, 0x36, 0x8f, 0x1d, 0x43, 0x5, 0xed, 0x59, 0x3f, 0xd0, 0x57, 0x4c, 0x82, 0xfa, 0x66, 0x52, 0x70, 0xea}; + uint8_t bytesprops7[] = {0xe9, 0x14, 0xd9, 0xf6, 0x2c, 0xc4, 0x34, 0x7c, 0x1b, 0x27, 0xec, 0xe8, 0x96, 0x98}; + uint8_t bytesprops8[] = {0x6, 0x40, 0xc1, 0xed, 0x7f, 0xfb, 0x5, 0xb4, 0x79, 0x59, 0xc1}; + uint8_t bytesprops9[] = {0x14, 0xb3, 0xbd, 0xa5, 0x60, 0xd, 0xb8, 0x48, 0x54, 0x67, 0x59, 0x68, 0xd3, 0x58, 0xf3, 0x3b, 0x86, 0x97, 0x61, 0x59}; + uint8_t bytesprops11[] = {0xa4, 0xd8, 0x71, 0xa, 0x2, 0x2, 0xc6, 0xc1, 0x44, 0x2b, 0xe5, 0xb1}; + uint8_t bytesprops10[] = {0x48, 0x47, 0xf1, 0x7b, 0x71, 0x4a, 0xd3, 0xae, 0x13, 0xf0, 0xc4, 0xe, 0x85, 0x4, 0x5, 0xf2, 0x75, 0x81}; + uint8_t bytesprops12[] = {0x82, 0x70, 0xab, 0xcc, 0x73, 0x18, 0xea, 0x30, 0xce, 0x3a, 0x2c, 0xf8, 0xc2, 0x15, 0x7d, 0x60, 0x8e, 0x21, 0x59, 0x6e, 0xc7, 0x24, 0xe0, 0x66, 0xf2, 0x26, 0x87}; + uint8_t bytesprops13[] = {0xa6, 0xc4, 0x60, 0xf0, 0x32, 0xb, 0x7f, 0x8d, 0xf4, 0x11, 0x2a, 0xc8, 0xda, 0xca, 0xd7, 0xd2, 0x6d, 0xea, 0x1, 0xcf, 0x5b, 0xa6}; + uint8_t bytesprops14[] = {0x96, 0x1a, 0xb7}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25499}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21932}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8939}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8119}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8685}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8052}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26546}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17713}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9284}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11426}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={18, (char*)&bytesprops10}, .v={12, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18572}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6297}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 3425, topic, msg, props); + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24061, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "#\234\SI\231\179\228\175!\174\132/\ETXg\US\r\STX\178\203\151\187\DC3C", _pubPktID = 3425, _pubBody = ":\171^C\n", -// _pubProps = [PropResponseTopic "^\255\219\212\234E\196\NAK\v\231\230\148(\SO\196'",PropResponseInformation -// "r{\180za]\185U\204\128\131@\226\&4b<",PropTopicAliasMaximum 25499]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = ";\135[\241\201\187\168\ETX\227\158\138\182\179\234\250\172\152\219\131\130!", _pubPktID = 24061, _pubBody = "\206\141\147\181o\253", _pubProps = [PropReceiveMaximum 21932,PropResponseInformation "c",PropMessageExpiryInterval 8939,PropAuthenticationData "y-+h",PropAssignedClientIdentifier "\RS\196RZ\231\&1Uh\149\146\237\168\NULH6\177F\246?\173\&4\137",PropAuthenticationData "m\227^\190\239\&1\240\232\EM\EM\128\149",PropServerKeepAlive 8119,PropResponseInformation "^\181\206\129aT\236\140",PropMaximumQoS 52,PropRequestResponseInformation 210,PropReceiveMaximum 8685,PropResponseInformation "\195\129\177\EM\STX~\194\n\207\204I\144@\226",PropMessageExpiryInterval 8052,PropReasonString "\215\213\194@e\ENQ\228\160\&6\143\GSC\ENQ\237Y?\208WL\130\250fRp\234",PropAuthenticationData "\233\DC4\217\246,\196\&4|\ESC'\236\232\150\152",PropMessageExpiryInterval 26546,PropWillDelayInterval 17713,PropSessionExpiryInterval 9284,PropContentType "\ACK@\193\237\DEL\251\ENQ\180yY\193",PropSharedSubscriptionAvailable 36,PropPayloadFormatIndicator 21,PropRequestResponseInformation 253,PropAuthenticationMethod "\DC4\179\189\165`\r\184HTgYh\211X\243;\134\151aY",PropSessionExpiryInterval 11426,PropUserProperty "HG\241{qJ\211\174\DC3\240\196\SO\133\EOT\ENQ\242u\129" "\164\216q\n\STX\STX\198\193D+\229\177",PropAuthenticationMethod "\130p\171\204s\CAN\234\&0\206:,\248\194\NAK}`\142!Yn\199$\224f\242&\135",PropAuthenticationData "\166\196`\240\&2\v\DEL\141\244\DC1*\200\218\202\215\210m\234\SOH\207[\166",PropReasonString "\150\SUB\183",PropTopicAlias 18572,PropMaximumPacketSize 6297]} TEST(Publish5QCTest, Decode1) { - uint8_t pkt[] = {0x32, 0x49, 0x0, 0x16, 0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, - 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43, 0xd, 0x61, 0x29, 0x8, - 0x0, 0x10, 0x5e, 0xff, 0xdb, 0xd4, 0xea, 0x45, 0xc4, 0x15, 0xb, 0xe7, 0xe6, 0x94, 0x28, - 0xe, 0xc4, 0x27, 0x1a, 0x0, 0x10, 0x72, 0x7b, 0xb4, 0x7a, 0x61, 0x5d, 0xb9, 0x55, 0xcc, - 0x80, 0x83, 0x40, 0xe2, 0x34, 0x62, 0x3c, 0x22, 0x63, 0x9b, 0x3a, 0xab, 0x5e, 0x43, 0xa}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x33, 0xdb, 0x2, 0x0, 0x15, 0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21, 0x5d, 0xfd, 0xba, 0x2, 0x21, 0x55, 0xac, 0x1a, 0x0, 0x1, 0x63, 0x2, 0x0, 0x0, 0x22, 0xeb, 0x16, 0x0, 0x4, 0x79, 0x2d, 0x2b, 0x68, 0x12, 0x0, 0x16, 0x1e, 0xc4, 0x52, 0x5a, 0xe7, 0x31, 0x55, 0x68, 0x95, 0x92, 0xed, 0xa8, 0x0, 0x48, 0x36, 0xb1, 0x46, 0xf6, 0x3f, 0xad, 0x34, 0x89, 0x16, 0x0, 0xc, 0x6d, 0xe3, 0x5e, 0xbe, 0xef, 0x31, 0xf0, 0xe8, 0x19, 0x19, 0x80, 0x95, 0x13, 0x1f, 0xb7, 0x1a, 0x0, 0x8, 0x5e, 0xb5, 0xce, 0x81, 0x61, 0x54, 0xec, 0x8c, 0x24, 0x34, 0x19, 0xd2, 0x21, 0x21, 0xed, 0x1a, 0x0, 0xe, 0xc3, 0x81, 0xb1, 0x19, 0x2, 0x7e, 0xc2, 0xa, 0xc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32, 0xb, 0x7f, 0x8d, 0xf4, 0x11, 0x2a, 0xc8, 0xda, 0xca, 0xd7, 0xd2, 0x6d, 0xea, 0x1, 0xcf, 0x5b, 0xa6, 0x1f, 0x0, 0x3, 0x96, 0x1a, 0xb7, 0x23, 0x48, 0x8c, 0x27, 0x0, 0x0, 0x18, 0x99, 0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 24061); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); +EXPECT_EQ(msg.payload_len, 6); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x23, 0xea, 0xf, 0xe7, 0xb3, 0xe4, 0xaf, 0x21, 0xae, 0x84, 0x2f, - 0x3, 0x67, 0x1f, 0xd, 0x2, 0xb2, 0xcb, 0x97, 0xbb, 0x13, 0x43}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x3a, 0xab, 0x5e, 0x43, 0xa}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 3425); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\158\245\154\154\236\CAN_4\221\253\192\177\172<\236c\171]F_", _pubPktID = 29370, _pubBody = -// "z\217-\243HF\176HG\200\166\159", _pubProps = [PropMessageExpiryInterval 25413,PropSessionExpiryInterval -// 10036,PropUserProperty "\160\240\177G:gT_+\234\197\143\176\230]\\\159\205v" -// "T\255\ACK\SO\247\163\US\248\163\142H\ACK\148\210\162\189S\137\251\152\223Gb\248",PropSessionExpiryInterval -// 19732,PropTopicAlias 30295,PropUserProperty "\173,q\227\&4\EOT\209\173\193WT\208l\SIH\152\&3" -// "J\184@",PropRequestProblemInformation 107,PropAssignedClientIdentifier "\162 -// \157\181\172\ETB\245\220\225:\200\235O\241T",PropPayloadFormatIndicator 248,PropMessageExpiryInterval -// 24928,PropRequestResponseInformation 194,PropServerKeepAlive 208]} -TEST(Publish5QCTest, Encode2) { - uint8_t pkt[] = {0x3c, 0xa0, 0x1, 0x0, 0x14, 0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, 0xfd, 0xc0, 0xb1, - 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f, 0x72, 0xba, 0x7b, 0x2, 0x0, 0x0, 0x63, 0x45, 0x11, - 0x0, 0x0, 0x27, 0x34, 0x26, 0x0, 0x13, 0xa0, 0xf0, 0xb1, 0x47, 0x3a, 0x67, 0x54, 0x5f, 0x2b, 0xea, - 0xc5, 0x8f, 0xb0, 0xe6, 0x5d, 0x5c, 0x9f, 0xcd, 0x76, 0x0, 0x18, 0x54, 0xff, 0x6, 0xe, 0xf7, 0xa3, - 0x1f, 0xf8, 0xa3, 0x8e, 0x48, 0x6, 0x94, 0xd2, 0xa2, 0xbd, 0x53, 0x89, 0xfb, 0x98, 0xdf, 0x47, 0x62, - 0xf8, 0x11, 0x0, 0x0, 0x4d, 0x14, 0x23, 0x76, 0x57, 0x26, 0x0, 0x11, 0xad, 0x2c, 0x71, 0xe3, 0x34, - 0x4, 0xd1, 0xad, 0xc1, 0x57, 0x54, 0xd0, 0x6c, 0xf, 0x48, 0x98, 0x33, 0x0, 0x3, 0x4a, 0xb8, 0x40, - 0x17, 0x6b, 0x12, 0x0, 0xf, 0xa2, 0x20, 0x9d, 0xb5, 0xac, 0x17, 0xf5, 0xdc, 0xe1, 0x3a, 0xc8, 0xeb, - 0x4f, 0xf1, 0x54, 0x1, 0xf8, 0x2, 0x0, 0x0, 0x61, 0x60, 0x19, 0xc2, 0x13, 0x0, 0xd0, 0x7a, 0xd9, - 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; - uint8_t topic_bytes[] = {0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, 0xfd, - 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; - - uint8_t bytesprops1[] = {0x54, 0xff, 0x6, 0xe, 0xf7, 0xa3, 0x1f, 0xf8, 0xa3, 0x8e, 0x48, 0x6, - 0x94, 0xd2, 0xa2, 0xbd, 0x53, 0x89, 0xfb, 0x98, 0xdf, 0x47, 0x62, 0xf8}; - uint8_t bytesprops0[] = {0xa0, 0xf0, 0xb1, 0x47, 0x3a, 0x67, 0x54, 0x5f, 0x2b, 0xea, - 0xc5, 0x8f, 0xb0, 0xe6, 0x5d, 0x5c, 0x9f, 0xcd, 0x76}; - uint8_t bytesprops3[] = {0x4a, 0xb8, 0x40}; - uint8_t bytesprops2[] = {0xad, 0x2c, 0x71, 0xe3, 0x34, 0x4, 0xd1, 0xad, 0xc1, - 0x57, 0x54, 0xd0, 0x6c, 0xf, 0x48, 0x98, 0x33}; - uint8_t bytesprops4[] = {0xa2, 0x20, 0x9d, 0xb5, 0xac, 0x17, 0xf5, 0xdc, 0xe1, 0x3a, 0xc8, 0xeb, 0x4f, 0xf1, 0x54}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\148\US\b\177\214\241A\128\215\138NRR\141\t\208\DC4\231\253\232\EM\205\r\162\157", _pubPktID = 0, _pubBody = "\DELQr", _pubProps = [PropCorrelationData "\189\129\175z\140\ETB\132",PropMessageExpiryInterval 31306,PropWildcardSubscriptionAvailable 199,PropContentType "\193B\DC3\184\200_",PropAssignedClientIdentifier "\200\131do}\205_\217~Z\149;\v\204\128",PropServerReference "\ENQ\135\165\f\196R\139>\214\231\DEL\208|\DC3\223H\152E\164",PropRequestProblemInformation 243,PropMaximumPacketSize 18984,PropTopicAlias 8169,PropRequestProblemInformation 2,PropMaximumQoS 70,PropWillDelayInterval 18634]} +TEST(Publish5QCTest, Encode2) { +uint8_t pkt[] = {0x31, 0x74, 0x0, 0x19, 0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d, 0x55, 0x9, 0x0, 0x7, 0xbd, 0x81, 0xaf, 0x7a, 0x8c, 0x17, 0x84, 0x2, 0x0, 0x0, 0x7a, 0x4a, 0x28, 0xc7, 0x3, 0x0, 0x6, 0xc1, 0x42, 0x13, 0xb8, 0xc8, 0x5f, 0x12, 0x0, 0xf, 0xc8, 0x83, 0x64, 0x6f, 0x7d, 0xcd, 0x5f, 0xd9, 0x7e, 0x5a, 0x95, 0x3b, 0xb, 0xcc, 0x80, 0x1c, 0x0, 0x13, 0x5, 0x87, 0xa5, 0xc, 0xc4, 0x52, 0x8b, 0x3e, 0xd6, 0xe7, 0x7f, 0xd0, 0x7c, 0x13, 0xdf, 0x48, 0x98, 0x45, 0xa4, 0x17, 0xf3, 0x27, 0x0, 0x0, 0x4a, 0x28, 0x23, 0x1f, 0xe9, 0x17, 0x2, 0x24, 0x46, 0x18, 0x0, 0x0, 0x48, 0xca, 0x7f, 0x51, 0x72}; + uint8_t topic_bytes[] = {0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = true; +uint8_t msg_bytes[] = {0x7f, 0x51, 0x72}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 3; + + uint8_t bytesprops0[] = {0xbd, 0x81, 0xaf, 0x7a, 0x8c, 0x17, 0x84}; + uint8_t bytesprops1[] = {0xc1, 0x42, 0x13, 0xb8, 0xc8, 0x5f}; + uint8_t bytesprops2[] = {0xc8, 0x83, 0x64, 0x6f, 0x7d, 0xcd, 0x5f, 0xd9, 0x7e, 0x5a, 0x95, 0x3b, 0xb, 0xcc, 0x80}; + uint8_t bytesprops3[] = {0x5, 0x87, 0xa5, 0xc, 0xc4, 0x52, 0x8b, 0x3e, 0xd6, 0xe7, 0x7f, 0xd0, 0x7c, 0x13, 0xdf, 0x48, 0x98, 0x45, 0xa4}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25413}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10036}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19732}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30295}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops2}, .v = {3, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24928}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 208}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31306}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18984}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8169}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18634}}, }; lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29370, topic, msg, props); +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\158\245\154\154\236\CAN_4\221\253\192\177\172<\236c\171]F_", _pubPktID = 29370, _pubBody = -// "z\217-\243HF\176HG\200\166\159", _pubProps = [PropMessageExpiryInterval 25413,PropSessionExpiryInterval -// 10036,PropUserProperty "\160\240\177G:gT_+\234\197\143\176\230]\\\159\205v" -// "T\255\ACK\SO\247\163\US\248\163\142H\ACK\148\210\162\189S\137\251\152\223Gb\248",PropSessionExpiryInterval -// 19732,PropTopicAlias 30295,PropUserProperty "\173,q\227\&4\EOT\209\173\193WT\208l\SIH\152\&3" -// "J\184@",PropRequestProblemInformation 107,PropAssignedClientIdentifier "\162 -// \157\181\172\ETB\245\220\225:\200\235O\241T",PropPayloadFormatIndicator 248,PropMessageExpiryInterval -// 24928,PropRequestResponseInformation 194,PropServerKeepAlive 208]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\148\US\b\177\214\241A\128\215\138NRR\141\t\208\DC4\231\253\232\EM\205\r\162\157", _pubPktID = 0, _pubBody = "\DELQr", _pubProps = [PropCorrelationData "\189\129\175z\140\ETB\132",PropMessageExpiryInterval 31306,PropWildcardSubscriptionAvailable 199,PropContentType "\193B\DC3\184\200_",PropAssignedClientIdentifier "\200\131do}\205_\217~Z\149;\v\204\128",PropServerReference "\ENQ\135\165\f\196R\139>\214\231\DEL\208|\DC3\223H\152E\164",PropRequestProblemInformation 243,PropMaximumPacketSize 18984,PropTopicAlias 8169,PropRequestProblemInformation 2,PropMaximumQoS 70,PropWillDelayInterval 18634]} TEST(Publish5QCTest, Decode2) { - uint8_t pkt[] = {0x3c, 0xa0, 0x1, 0x0, 0x14, 0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, 0xfd, 0xc0, 0xb1, - 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f, 0x72, 0xba, 0x7b, 0x2, 0x0, 0x0, 0x63, 0x45, 0x11, - 0x0, 0x0, 0x27, 0x34, 0x26, 0x0, 0x13, 0xa0, 0xf0, 0xb1, 0x47, 0x3a, 0x67, 0x54, 0x5f, 0x2b, 0xea, - 0xc5, 0x8f, 0xb0, 0xe6, 0x5d, 0x5c, 0x9f, 0xcd, 0x76, 0x0, 0x18, 0x54, 0xff, 0x6, 0xe, 0xf7, 0xa3, - 0x1f, 0xf8, 0xa3, 0x8e, 0x48, 0x6, 0x94, 0xd2, 0xa2, 0xbd, 0x53, 0x89, 0xfb, 0x98, 0xdf, 0x47, 0x62, - 0xf8, 0x11, 0x0, 0x0, 0x4d, 0x14, 0x23, 0x76, 0x57, 0x26, 0x0, 0x11, 0xad, 0x2c, 0x71, 0xe3, 0x34, - 0x4, 0xd1, 0xad, 0xc1, 0x57, 0x54, 0xd0, 0x6c, 0xf, 0x48, 0x98, 0x33, 0x0, 0x3, 0x4a, 0xb8, 0x40, - 0x17, 0x6b, 0x12, 0x0, 0xf, 0xa2, 0x20, 0x9d, 0xb5, 0xac, 0x17, 0xf5, 0xdc, 0xe1, 0x3a, 0xc8, 0xeb, - 0x4f, 0xf1, 0x54, 0x1, 0xf8, 0x2, 0x0, 0x0, 0x61, 0x60, 0x19, 0xc2, 0x13, 0x0, 0xd0, 0x7a, 0xd9, - 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x31, 0x74, 0x0, 0x19, 0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d, 0x55, 0x9, 0x0, 0x7, 0xbd, 0x81, 0xaf, 0x7a, 0x8c, 0x17, 0x84, 0x2, 0x0, 0x0, 0x7a, 0x4a, 0x28, 0xc7, 0x3, 0x0, 0x6, 0xc1, 0x42, 0x13, 0xb8, 0xc8, 0x5f, 0x12, 0x0, 0xf, 0xc8, 0x83, 0x64, 0x6f, 0x7d, 0xcd, 0x5f, 0xd9, 0x7e, 0x5a, 0x95, 0x3b, 0xb, 0xcc, 0x80, 0x1c, 0x0, 0x13, 0x5, 0x87, 0xa5, 0xc, 0xc4, 0x52, 0x8b, 0x3e, 0xd6, 0xe7, 0x7f, 0xd0, 0x7c, 0x13, 0xdf, 0x48, 0x98, 0x45, 0xa4, 0x17, 0xf3, 0x27, 0x0, 0x0, 0x4a, 0x28, 0x23, 0x1f, 0xe9, 0x17, 0x2, 0x24, 0x46, 0x18, 0x0, 0x0, 0x48, 0xca, 0x7f, 0x51, 0x72}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7f, 0x51, 0x72}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); +EXPECT_EQ(msg.payload_len, 3); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9e, 0xf5, 0x9a, 0x9a, 0xec, 0x18, 0x5f, 0x34, 0xdd, 0xfd, - 0xc0, 0xb1, 0xac, 0x3c, 0xec, 0x63, 0xab, 0x5d, 0x46, 0x5f}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7a, 0xd9, 0x2d, 0xf3, 0x48, 0x46, 0xb0, 0x48, 0x47, 0xc8, 0xa6, 0x9f}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 29370); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "uh{\218\a\247\172\148\ESC\ETB\187\138\184\255\vX\180\DC1\131\&0\219\216\SI\147\203\ETX)\218", _pubPktID = 0, -// _pubBody = "\207\DC1\209\235\144\141K\255\225\177/B\DC1\DC3\175\144", _pubProps = [PropReasonString -// "\213>\211\224^0\247\164\133Z\154(\198F?\240\167\&59\t\ETBj",PropResponseInformation -// "\211\147f\217\197\253\163U\135\&2",PropSharedSubscriptionAvailable 175,PropCorrelationData -// "r\242\151\207\149\ACKg\241\&3\159\138\171X\SYNA;\nM\223+",PropMessageExpiryInterval 22620,PropServerReference -// "@",PropCorrelationData -// "\153\193\147\164\207}\FSQo\227\224XA\n\206\231\170:\211O\189Z\180",PropRequestResponseInformation -// 223,PropUserProperty "\ENQ\246\&6@\143\RSgP\247\134\SIDH\243\f\DC2[\194\191\240gB\ACK\194\239y\173\230!\166" -// "\134\DELM\195\204\157\SUBy\SO)\241Lp3\GS\199m\129",PropSharedSubscriptionAvailable 20,PropReceiveMaximum -// 15739,PropTopicAliasMaximum 30129,PropMessageExpiryInterval 29406,PropCorrelationData -// "n\DC4\NAK\SOH",PropRetainAvailable 248,PropServerKeepAlive 22227,PropSessionExpiryInterval 18366,PropResponseTopic -// "jY\228\148\244\212\218h\157/'M\215\152\n\188\200\208z1",PropTopicAlias 22179,PropPayloadFormatIndicator -// 236,PropTopicAlias 16075,PropServerKeepAlive 12101]} -TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = {0x38, 0x89, 0x2, 0x0, 0x1c, 0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, - 0xb8, 0xff, 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93,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, 0x0, 0x47, 0xbe, 0x8, 0x0, 0x14, - 0x6a, 0x59, 0xe4, 0x94, 0xf4, 0xd4, 0xda, 0x68, 0x9d, 0x2f, 0x27, 0x4d, 0xd7, 0x98, 0xa, 0xbc, 0xc8, - 0xd0, 0x7a, 0x31, 0x23, 0x56, 0xa3, 0x1, 0xec, 0x23, 0x3e, 0xcb, 0x13, 0x2f, 0x45, 0xcf, 0x11, 0xd1, - 0xeb, 0x90, 0x8d, 0x4b, 0xff, 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; - uint8_t topic_bytes[] = {0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, 0xb8, 0xff, - 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, - 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; - - uint8_t bytesprops0[] = {0xd5, 0x3e, 0xd3, 0xe0, 0x5e, 0x30, 0xf7, 0xa4, 0x85, 0x5a, 0x9a, - 0x28, 0xc6, 0x46, 0x3f, 0xf0, 0xa7, 0x35, 0x39, 0x9, 0x17, 0x6a}; - uint8_t bytesprops1[] = {0xd3, 0x93, 0x66, 0xd9, 0xc5, 0xfd, 0xa3, 0x55, 0x87, 0x32}; - uint8_t bytesprops2[] = {0x72, 0xf2, 0x97, 0xcf, 0x95, 0x6, 0x67, 0xf1, 0x33, 0x9f, - 0x8a, 0xab, 0x58, 0x16, 0x41, 0x3b, 0xa, 0x4d, 0xdf, 0x2b}; - uint8_t bytesprops3[] = {0x40}; - uint8_t bytesprops4[] = {0x99, 0xc1, 0x93, 0xa4, 0xcf, 0x7d, 0x1c, 0x51, 0x6f, 0xe3, 0xe0, 0x58, - 0x41, 0xa, 0xce, 0xe7, 0xaa, 0x3a, 0xd3, 0x4f, 0xbd, 0x5a, 0xb4}; - uint8_t bytesprops6[] = {0x86, 0x7f, 0x4d, 0xc3, 0xcc, 0x9d, 0x1a, 0x79, 0xe, - 0x29, 0xf1, 0x4c, 0x70, 0x33, 0x1d, 0xc7, 0x6d, 0x81}; - uint8_t bytesprops5[] = {0x5, 0xf6, 0x36, 0x40, 0x8f, 0x1e, 0x67, 0x50, 0xf7, 0x86, 0xf, 0x44, 0x48, 0xf3, 0xc, - 0x12, 0x5b, 0xc2, 0xbf, 0xf0, 0x67, 0x42, 0x6, 0xc2, 0xef, 0x79, 0xad, 0xe6, 0x21, 0xa6}; - uint8_t bytesprops7[] = {0x6e, 0x14, 0x15, 0x1}; - uint8_t bytesprops8[] = {0x6a, 0x59, 0xe4, 0x94, 0xf4, 0xd4, 0xda, 0x68, 0x9d, 0x2f, - 0x27, 0x4d, 0xd7, 0x98, 0xa, 0xbc, 0xc8, 0xd0, 0x7a, 0x31}; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CANO\164\EM\236\160:x\bB\170\222ObK\201\DC1\168W}>\187\DC1", _pubPktID = 0, _pubBody = "", _pubProps = [PropServerKeepAlive 2018]} +TEST(Publish5QCTest, Encode3) { +uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x17, 0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11, 0x3, 0x13, 0x7, 0xe2}; + uint8_t topic_bytes[] = {0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = false; +uint8_t msg_bytes[] = {0}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 0; + + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22620}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops5}, .v = {18, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15739}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30129}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29406}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22227}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18366}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22179}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16075}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12101}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2018}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "uh{\218\a\247\172\148\ESC\ETB\187\138\184\255\vX\180\DC1\131\&0\219\216\SI\147\203\ETX)\218", _pubPktID = 0, -// _pubBody = "\207\DC1\209\235\144\141K\255\225\177/B\DC1\DC3\175\144", _pubProps = [PropReasonString -// "\213>\211\224^0\247\164\133Z\154(\198F?\240\167\&59\t\ETBj",PropResponseInformation -// "\211\147f\217\197\253\163U\135\&2",PropSharedSubscriptionAvailable 175,PropCorrelationData -// "r\242\151\207\149\ACKg\241\&3\159\138\171X\SYNA;\nM\223+",PropMessageExpiryInterval 22620,PropServerReference -// "@",PropCorrelationData -// "\153\193\147\164\207}\FSQo\227\224XA\n\206\231\170:\211O\189Z\180",PropRequestResponseInformation -// 223,PropUserProperty "\ENQ\246\&6@\143\RSgP\247\134\SIDH\243\f\DC2[\194\191\240gB\ACK\194\239y\173\230!\166" -// "\134\DELM\195\204\157\SUBy\SO)\241Lp3\GS\199m\129",PropSharedSubscriptionAvailable 20,PropReceiveMaximum -// 15739,PropTopicAliasMaximum 30129,PropMessageExpiryInterval 29406,PropCorrelationData -// "n\DC4\NAK\SOH",PropRetainAvailable 248,PropServerKeepAlive 22227,PropSessionExpiryInterval 18366,PropResponseTopic -// "jY\228\148\244\212\218h\157/'M\215\152\n\188\200\208z1",PropTopicAlias 22179,PropPayloadFormatIndicator -// 236,PropTopicAlias 16075,PropServerKeepAlive 12101]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CANO\164\EM\236\160:x\bB\170\222ObK\201\DC1\168W}>\187\DC1", _pubPktID = 0, _pubBody = "", _pubProps = [PropServerKeepAlive 2018]} TEST(Publish5QCTest, Decode3) { - uint8_t pkt[] = {0x38, 0x89, 0x2, 0x0, 0x1c, 0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, - 0xb8, 0xff, 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda, 0xd9, - 0x1, 0x1f, 0x0, 0x16, 0xd5, 0x3e, 0xd3, 0xe0, 0x5e, 0x30, 0xf7, 0xa4, 0x85, 0x5a, 0x9a, 0x28, 0xc6, - 0x46, 0x3f, 0xf0, 0xa7, 0x35, 0x39, 0x9, 0x17, 0x6a, 0x1a, 0x0, 0xa, 0xd3, 0x93, 0x66, 0xd9, 0xc5, - 0xfd, 0xa3, 0x55, 0x87, 0x32, 0x2a, 0xaf, 0x9, 0x0, 0x14, 0x72, 0xf2, 0x97, 0xcf, 0x95, 0x6, 0x67, - 0xf1, 0x33, 0x9f, 0x8a, 0xab, 0x58, 0x16, 0x41, 0x3b, 0xa, 0x4d, 0xdf, 0x2b, 0x2, 0x0, 0x0, 0x58, - 0x5c, 0x1c, 0x0, 0x1, 0x40, 0x9, 0x0, 0x17, 0x99, 0xc1, 0x93, 0xa4, 0xcf, 0x7d, 0x1c, 0x51, 0x6f, - 0xe3, 0xe0, 0x58, 0x41, 0xa, 0xce, 0xe7, 0xaa, 0x3a, 0xd3, 0x4f, 0xbd, 0x5a, 0xb4, 0x19, 0xdf, 0x26, - 0x0, 0x1e, 0x5, 0xf6, 0x36, 0x40, 0x8f, 0x1e, 0x67, 0x50, 0xf7, 0x86, 0xf, 0x44, 0x48, 0xf3, 0xc, - 0x12, 0x5b, 0xc2, 0xbf, 0xf0, 0x67, 0x42, 0x6, 0xc2, 0xef, 0x79, 0xad, 0xe6, 0x21, 0xa6, 0x0, 0x12, - 0x86, 0x7f, 0x4d, 0xc3, 0xcc, 0x9d, 0x1a, 0x79, 0xe, 0x29, 0xf1, 0x4c, 0x70, 0x33, 0x1d, 0xc7, 0x6d, - 0x81, 0x2a, 0x14, 0x21, 0x3d, 0x7b, 0x22, 0x75, 0xb1, 0x2, 0x0, 0x0, 0x72, 0xde, 0x9, 0x0, 0x4, - 0x6e, 0x14, 0x15, 0x1, 0x25, 0xf8, 0x13, 0x56, 0xd3, 0x11, 0x0, 0x0, 0x47, 0xbe, 0x8, 0x0, 0x14, - 0x6a, 0x59, 0xe4, 0x94, 0xf4, 0xd4, 0xda, 0x68, 0x9d, 0x2f, 0x27, 0x4d, 0xd7, 0x98, 0xa, 0xbc, 0xc8, - 0xd0, 0x7a, 0x31, 0x23, 0x56, 0xa3, 0x1, 0xec, 0x23, 0x3e, 0xcb, 0x13, 0x2f, 0x45, 0xcf, 0x11, 0xd1, - 0xeb, 0x90, 0x8d, 0x4b, 0xff, 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x17, 0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11, 0x3, 0x13, 0x7, 0xe2}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); +EXPECT_EQ(msg.payload_len, 0); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x75, 0x68, 0x7b, 0xda, 0x7, 0xf7, 0xac, 0x94, 0x1b, 0x17, 0xbb, 0x8a, 0xb8, 0xff, - 0xb, 0x58, 0xb4, 0x11, 0x83, 0x30, 0xdb, 0xd8, 0xf, 0x93, 0xcb, 0x3, 0x29, 0xda}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcf, 0x11, 0xd1, 0xeb, 0x90, 0x8d, 0x4b, 0xff, - 0xe1, 0xb1, 0x2f, 0x42, 0x11, 0x13, 0xaf, 0x90}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\193)\128\208yd\SOi\134\237\DC2Ir\136\217", _pubPktID = 8430, _pubBody = -// "\138\214\&5p\ESCn,\183\152u\192\244\165\&1\147\140\172", _pubProps = [PropReceiveMaximum -// 19627,PropSubscriptionIdentifier 11,PropPayloadFormatIndicator 254,PropAuthenticationMethod -// "\ETBO\172\EOT\165\CAN\201Y\189xl\153v\a\214\202\176\199",PropContentType "\245*.\194\146",PropMaximumPacketSize -// 15159,PropSubscriptionIdentifierAvailable 168,PropSharedSubscriptionAvailable 41,PropReasonString -// "_}\201lLo>9\n\217}\177",PropReasonString -// "\220[\167\&4h\244\217\222\142H\ETX\175F#\153\161y(O\EMZ\244*s!\174\247",PropPayloadFormatIndicator 155]} -TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = {0x3d, 0x81, 0x1, 0x0, 0xf, 0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, - 0x72, 0x88, 0xd9, 0x20, 0xee, 0x5c, 0x21, 0x4c, 0xab, 0xb, 0xb, 0x1, 0xfe, 0x15, 0x0, 0x12, 0x17, - 0x4f, 0xac, 0x4, 0xa5, 0x18, 0xc9, 0x59, 0xbd, 0x78, 0x6c, 0x99, 0x76, 0x7, 0xd6, 0xca, 0xb0, 0xc7, - 0x3, 0x0, 0x5, 0xf5, 0x2a, 0x2e, 0xc2, 0x92, 0x27, 0x0, 0x0, 0x3b, 0x37, 0x29, 0xa8, 0x2a, 0x29, - 0x1f, 0x0, 0xc, 0x5f, 0x7d, 0xc9, 0x6c, 0x4c, 0x6f, 0x3e, 0x39, 0xa, 0xd9, 0x7d, 0xb1, 0x1f, 0x0, - 0x1b, 0xdc, 0x5b, 0xa7, 0x34, 0x68, 0xf4, 0xd9, 0xde, 0x8e, 0x48, 0x3, 0xaf, 0x46, 0x23, 0x99, 0xa1, - 0x79, 0x28, 0x4f, 0x19, 0x5a, 0xf4, 0x2a, 0x73, 0x21, 0xae, 0xf7, 0x1, 0x9b, 0x8a, 0xd6, 0x35, 0x70, - 0x1b, 0x6e, 0x2c, 0xb7, 0x98, 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; - uint8_t topic_bytes[] = {0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x8a, 0xd6, 0x35, 0x70, 0x1b, 0x6e, 0x2c, 0xb7, 0x98, - 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; - - uint8_t bytesprops0[] = {0x17, 0x4f, 0xac, 0x4, 0xa5, 0x18, 0xc9, 0x59, 0xbd, - 0x78, 0x6c, 0x99, 0x76, 0x7, 0xd6, 0xca, 0xb0, 0xc7}; - uint8_t bytesprops1[] = {0xf5, 0x2a, 0x2e, 0xc2, 0x92}; - uint8_t bytesprops2[] = {0x5f, 0x7d, 0xc9, 0x6c, 0x4c, 0x6f, 0x3e, 0x39, 0xa, 0xd9, 0x7d, 0xb1}; - uint8_t bytesprops3[] = {0xdc, 0x5b, 0xa7, 0x34, 0x68, 0xf4, 0xd9, 0xde, 0x8e, 0x48, 0x3, 0xaf, 0x46, 0x23, - 0x99, 0xa1, 0x79, 0x28, 0x4f, 0x19, 0x5a, 0xf4, 0x2a, 0x73, 0x21, 0xae, 0xf7}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "]\151\151\159oP\170", _pubPktID = 14052, _pubBody = "\254\174c\158\219\&7\163j\130\179TW\155\250\141\164c", _pubProps = [PropResponseTopic "\218\139\158d\216\160\SUB\156h\198\176Jr\158\139\&0\196\194h\251\SOH\EOT\233Z\239\219\146",PropSessionExpiryInterval 3572,PropSubscriptionIdentifier 18,PropCorrelationData "4w\174@n\DC1\156\DC1(\CAN\240\164>/\140\&3~n#\175X\CAN\199\221\&4j\159Kf*",PropServerKeepAlive 5008,PropUserProperty "S\DC3[\235\174\129 pA\216\163\&2.\238\ETB>k\243" "\204\189\195iQ\144\132\211\217r\247\NUL\131\244t8\229@\196\244\174}X",PropTopicAlias 974,PropContentType "sQ",PropRequestResponseInformation 85,PropContentType "\t\175\244\144\207\SOH\181",PropSessionExpiryInterval 6517,PropSessionExpiryInterval 8268,PropSessionExpiryInterval 11191,PropSubscriptionIdentifierAvailable 225,PropMaximumPacketSize 26160,PropMaximumPacketSize 24248,PropSubscriptionIdentifierAvailable 187,PropCorrelationData "+\RS:!7\187\222\134`]\210\250\ACK\223W\130H\140\194$\255d\145\237\189\154N\SUB\152\221",PropWillDelayInterval 13076,PropSessionExpiryInterval 17784,PropTopicAliasMaximum 28192,PropReceiveMaximum 30677,PropSharedSubscriptionAvailable 104,PropMessageExpiryInterval 5065,PropRequestProblemInformation 113,PropRequestResponseInformation 239,PropMessageExpiryInterval 11285]} +TEST(Publish5QCTest, Encode4) { +uint8_t pkt[] = {0x3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0x21, 0x37, 0xbb, 0xde, 0x86, 0x60, 0x5d, 0xd2, 0xfa, 0x6, 0xdf, 0x57, 0x82, 0x48, 0x8c, 0xc2, 0x24, 0xff, 0x64, 0x91, 0xed, 0xbd, 0x9a, 0x4e, 0x1a, 0x98, 0xdd, 0x18, 0x0, 0x0, 0x33, 0x14, 0x11, 0x0, 0x0, 0x45, 0x78, 0x22, 0x6e, 0x20, 0x21, 0x77, 0xd5, 0x2a, 0x68, 0x2, 0x0, 0x0, 0x13, 0xc9, 0x17, 0x71, 0x19, 0xef, 0x2, 0x0, 0x0, 0x2c, 0x15, 0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; + uint8_t topic_bytes[] = {0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 17; + + uint8_t bytesprops0[] = {0xda, 0x8b, 0x9e, 0x64, 0xd8, 0xa0, 0x1a, 0x9c, 0x68, 0xc6, 0xb0, 0x4a, 0x72, 0x9e, 0x8b, 0x30, 0xc4, 0xc2, 0x68, 0xfb, 0x1, 0x4, 0xe9, 0x5a, 0xef, 0xdb, 0x92}; + uint8_t bytesprops1[] = {0x34, 0x77, 0xae, 0x40, 0x6e, 0x11, 0x9c, 0x11, 0x28, 0x18, 0xf0, 0xa4, 0x3e, 0x2f, 0x8c, 0x33, 0x7e, 0x6e, 0x23, 0xaf, 0x58, 0x18, 0xc7, 0xdd, 0x34, 0x6a, 0x9f, 0x4b, 0x66, 0x2a}; + uint8_t bytesprops3[] = {0xcc, 0xbd, 0xc3, 0x69, 0x51, 0x90, 0x84, 0xd3, 0xd9, 0x72, 0xf7, 0x0, 0x83, 0xf4, 0x74, 0x38, 0xe5, 0x40, 0xc4, 0xf4, 0xae, 0x7d, 0x58}; + uint8_t bytesprops2[] = {0x53, 0x13, 0x5b, 0xeb, 0xae, 0x81, 0x20, 0x70, 0x41, 0xd8, 0xa3, 0x32, 0x2e, 0xee, 0x17, 0x3e, 0x6b, 0xf3}; + uint8_t bytesprops4[] = {0x73, 0x51}; + uint8_t bytesprops5[] = {0x9, 0xaf, 0xf4, 0x90, 0xcf, 0x1, 0xb5}; + uint8_t bytesprops6[] = {0x2b, 0x1e, 0x3a, 0x21, 0x37, 0xbb, 0xde, 0x86, 0x60, 0x5d, 0xd2, 0xfa, 0x6, 0xdf, 0x57, 0x82, 0x48, 0x8c, 0xc2, 0x24, 0xff, 0x64, 0x91, 0xed, 0xbd, 0x9a, 0x4e, 0x1a, 0x98, 0xdd}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19627}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15159}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, - }; - - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 8430, topic, msg, props); + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3572}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5008}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={18, (char*)&bytesprops2}, .v={23, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 974}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6517}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8268}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11191}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26160}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24248}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13076}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17784}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28192}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30677}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5065}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11285}}, + }; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 14052, topic, msg, props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\193)\128\208yd\SOi\134\237\DC2Ir\136\217", _pubPktID = 8430, _pubBody = -// "\138\214\&5p\ESCn,\183\152u\192\244\165\&1\147\140\172", _pubProps = [PropReceiveMaximum -// 19627,PropSubscriptionIdentifier 11,PropPayloadFormatIndicator 254,PropAuthenticationMethod -// "\ETBO\172\EOT\165\CAN\201Y\189xl\153v\a\214\202\176\199",PropContentType "\245*.\194\146",PropMaximumPacketSize -// 15159,PropSubscriptionIdentifierAvailable 168,PropSharedSubscriptionAvailable 41,PropReasonString -// "_}\201lLo>9\n\217}\177",PropReasonString -// "\220[\167\&4h\244\217\222\142H\ETX\175F#\153\161y(O\EMZ\244*s!\174\247",PropPayloadFormatIndicator 155]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "]\151\151\159oP\170", _pubPktID = 14052, _pubBody = "\254\174c\158\219\&7\163j\130\179TW\155\250\141\164c", _pubProps = [PropResponseTopic "\218\139\158d\216\160\SUB\156h\198\176Jr\158\139\&0\196\194h\251\SOH\EOT\233Z\239\219\146",PropSessionExpiryInterval 3572,PropSubscriptionIdentifier 18,PropCorrelationData "4w\174@n\DC1\156\DC1(\CAN\240\164>/\140\&3~n#\175X\CAN\199\221\&4j\159Kf*",PropServerKeepAlive 5008,PropUserProperty "S\DC3[\235\174\129 pA\216\163\&2.\238\ETB>k\243" "\204\189\195iQ\144\132\211\217r\247\NUL\131\244t8\229@\196\244\174}X",PropTopicAlias 974,PropContentType "sQ",PropRequestResponseInformation 85,PropContentType "\t\175\244\144\207\SOH\181",PropSessionExpiryInterval 6517,PropSessionExpiryInterval 8268,PropSessionExpiryInterval 11191,PropSubscriptionIdentifierAvailable 225,PropMaximumPacketSize 26160,PropMaximumPacketSize 24248,PropSubscriptionIdentifierAvailable 187,PropCorrelationData "+\RS:!7\187\222\134`]\210\250\ACK\223W\130H\140\194$\255d\145\237\189\154N\SUB\152\221",PropWillDelayInterval 13076,PropSessionExpiryInterval 17784,PropTopicAliasMaximum 28192,PropReceiveMaximum 30677,PropSharedSubscriptionAvailable 104,PropMessageExpiryInterval 5065,PropRequestProblemInformation 113,PropRequestResponseInformation 239,PropMessageExpiryInterval 11285]} TEST(Publish5QCTest, Decode4) { - uint8_t pkt[] = {0x3d, 0x81, 0x1, 0x0, 0xf, 0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, - 0x72, 0x88, 0xd9, 0x20, 0xee, 0x5c, 0x21, 0x4c, 0xab, 0xb, 0xb, 0x1, 0xfe, 0x15, 0x0, 0x12, 0x17, - 0x4f, 0xac, 0x4, 0xa5, 0x18, 0xc9, 0x59, 0xbd, 0x78, 0x6c, 0x99, 0x76, 0x7, 0xd6, 0xca, 0xb0, 0xc7, - 0x3, 0x0, 0x5, 0xf5, 0x2a, 0x2e, 0xc2, 0x92, 0x27, 0x0, 0x0, 0x3b, 0x37, 0x29, 0xa8, 0x2a, 0x29, - 0x1f, 0x0, 0xc, 0x5f, 0x7d, 0xc9, 0x6c, 0x4c, 0x6f, 0x3e, 0x39, 0xa, 0xd9, 0x7d, 0xb1, 0x1f, 0x0, - 0x1b, 0xdc, 0x5b, 0xa7, 0x34, 0x68, 0xf4, 0xd9, 0xde, 0x8e, 0x48, 0x3, 0xaf, 0x46, 0x23, 0x99, 0xa1, - 0x79, 0x28, 0x4f, 0x19, 0x5a, 0xf4, 0x2a, 0x73, 0x21, 0xae, 0xf7, 0x1, 0x9b, 0x8a, 0xd6, 0x35, 0x70, - 0x1b, 0x6e, 0x2c, 0xb7, 0x98, 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc1, 0x29, 0x80, 0xd0, 0x79, 0x64, 0xe, 0x69, 0x86, 0xed, 0x12, 0x49, 0x72, 0x88, 0xd9}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8a, 0xd6, 0x35, 0x70, 0x1b, 0x6e, 0x2c, 0xb7, 0x98, - 0x75, 0xc0, 0xf4, 0xa5, 0x31, 0x93, 0x8c, 0xac}; +uint8_t pkt[] = {0x3b, 0x87, 0x2, 0x0, 0x7, 0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa, 0x36, 0xe4, 0xe9, 0x1, 0x8, 0x0, 0x1b, 0xda, 0x8b, 0x9e, 0x64, 0xd8, 0xa0, 0x1a, 0x9c, 0x68, 0xc6, 0xb0, 0x4a, 0x72, 0x9e, 0x8b, 0x30, 0xc4, 0xc2, 0x68, 0xfb, 0x1, 0x4, 0xe9, 0x5a, 0xef, 0xdb, 0x92, 0x11, 0x0, 0x0, 0xd, 0xf4, 0xb, 0x12, 0x9, 0x0, 0x1e, 0x34, 0x77, 0xae, 0x40, 0x6e, 0x11, 0x9c, 0x11, 0x28, 0x18, 0xf0, 0xa4, 0x3e, 0x2f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0x9b, 0xfa, 0x8d, 0xa4, 0x63}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 8430); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\DC2\184\144\&5\136\156E\174\237\230\175\SUB\153 \NAKk\EM\f", _pubPktID = 0, _pubBody = -// "i\232{\DC3k\GS\158\DLE|\218\236v\244>\145\172,\bR\165\255\174", _pubProps = [PropCorrelationData -// "\227\244",PropServerKeepAlive 1521,PropResponseTopic "\130%)hs"]} -TEST(Publish5QCTest, Encode5) { - uint8_t pkt[] = {0x31, 0x3b, 0x0, 0x12, 0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, 0xe6, 0xaf, 0x1a, - 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc, 0x10, 0x9, 0x0, 0x2, 0xe3, 0xf4, 0x13, 0x5, 0xf1, 0x8, - 0x0, 0x5, 0x82, 0x25, 0x29, 0x68, 0x73, 0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, - 0xda, 0xec, 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; - uint8_t topic_bytes[] = {0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, - 0xe6, 0xaf, 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 14052); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); +EXPECT_EQ(msg.payload_len, 17); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); +lwmqtt_string_t x = exp_topic; +x = exp_body; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, 0xda, 0xec, - 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; +} - uint8_t bytesprops0[] = {0xe3, 0xf4}; - uint8_t bytesprops1[] = {0x82, 0x25, 0x29, 0x68, 0x73}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "F\129\169\SYN\215A[Qx}\223\&7NE\181\250\249\236\208\GSL\217\176\183\235\&0\189\247u_", _pubPktID = 26784, _pubBody = "\176\&0\158\138\138]\220(B\154\&3\224jV\159v+\130", _pubProps = [PropServerReference "\171\NUL\255\181W#c)\213_\233\156l\214e7\223\159\SYN\138\186Na\129\231\200\222\187\SI",PropResponseInformation "9\247>''\242\222\229\ACK#n\DC4!\\\253\&4pA\238\158\195",PropCorrelationData "v\US\177M\242\DC2\171\229\194h\194\147\236KT\147",PropWildcardSubscriptionAvailable 249,PropAuthenticationMethod "\ACK\168\&7$\DEL\194wS\162",PropTopicAliasMaximum 28784,PropTopicAliasMaximum 19013,PropServerKeepAlive 3972,PropPayloadFormatIndicator 111,PropTopicAlias 4635,PropWillDelayInterval 6106,PropResponseTopic "!\248",PropSubscriptionIdentifier 16,PropResponseTopic "c4Pne\208y\197\194",PropContentType "3A\148\175\r",PropTopicAliasMaximum 8280,PropRequestResponseInformation 163,PropMaximumPacketSize 10851,PropReceiveMaximum 29504,PropMaximumPacketSize 24457,PropServerReference "/\164X\232R9B\249\173Y\ACK\144\ACK%\138a\STX\ETX\190}\250WU\169\164\183",PropServerKeepAlive 15970,PropAuthenticationMethod ";J6"]} +TEST(Publish5QCTest, Encode5) { +uint8_t pkt[] = {0x3d, 0xf5, 0x1, 0x0, 0x1e, 0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f, 0x68, 0xa0, 0xbf, 0x1, 0x1c, 0x0, 0x1d, 0xab, 0x0, 0xff, 0xb5, 0x57, 0x23, 0x63, 0x29, 0xd5, 0x5f, 0xe9, 0x9c, 0x6c, 0xd6, 0x65, 0x37, 0xdf, 0x9f, 0x16, 0x8a, 0xba, 0x4e, 0x61, 0x81, 0xe7, 0xc8, 0xde, 0xbb, 0xf, 0x1a, 0x0, 0x15, 0x39, 0xf7, 0x3e, 0x27, 0x27, 0xf2, 0xde, 0xe5, 0x6, 0x23, 0x6e, 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eb, 0x30, 0xbd, 0xf7, 0x75, 0x5f}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 18; + + uint8_t bytesprops0[] = {0xab, 0x0, 0xff, 0xb5, 0x57, 0x23, 0x63, 0x29, 0xd5, 0x5f, 0xe9, 0x9c, 0x6c, 0xd6, 0x65, 0x37, 0xdf, 0x9f, 0x16, 0x8a, 0xba, 0x4e, 0x61, 0x81, 0xe7, 0xc8, 0xde, 0xbb, 0xf}; + uint8_t bytesprops1[] = {0x39, 0xf7, 0x3e, 0x27, 0x27, 0xf2, 0xde, 0xe5, 0x6, 0x23, 0x6e, 0x14, 0x21, 0x5c, 0xfd, 0x34, 0x70, 0x41, 0xee, 0x9e, 0xc3}; + uint8_t bytesprops2[] = {0x76, 0x1f, 0xb1, 0x4d, 0xf2, 0x12, 0xab, 0xe5, 0xc2, 0x68, 0xc2, 0x93, 0xec, 0x4b, 0x54, 0x93}; + uint8_t bytesprops3[] = {0x6, 0xa8, 0x37, 0x24, 0x7f, 0xc2, 0x77, 0x53, 0xa2}; + uint8_t bytesprops4[] = {0x21, 0xf8}; + uint8_t bytesprops5[] = {0x63, 0x34, 0x50, 0x6e, 0x65, 0xd0, 0x79, 0xc5, 0xc2}; + uint8_t bytesprops6[] = {0x33, 0x41, 0x94, 0xaf, 0xd}; + uint8_t bytesprops7[] = {0x2f, 0xa4, 0x58, 0xe8, 0x52, 0x39, 0x42, 0xf9, 0xad, 0x59, 0x6, 0x90, 0x6, 0x25, 0x8a, 0x61, 0x2, 0x3, 0xbe, 0x7d, 0xfa, 0x57, 0x55, 0xa9, 0xa4, 0xb7}; + uint8_t bytesprops8[] = {0x3b, 0x4a, 0x36}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1521}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28784}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19013}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3972}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4635}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6106}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8280}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10851}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29504}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24457}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15970}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 26784, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\DC2\184\144\&5\136\156E\174\237\230\175\SUB\153 \NAKk\EM\f", _pubPktID = 0, _pubBody = -// "i\232{\DC3k\GS\158\DLE|\218\236v\244>\145\172,\bR\165\255\174", _pubProps = [PropCorrelationData -// "\227\244",PropServerKeepAlive 1521,PropResponseTopic "\130%)hs"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "F\129\169\SYN\215A[Qx}\223\&7NE\181\250\249\236\208\GSL\217\176\183\235\&0\189\247u_", _pubPktID = 26784, _pubBody = "\176\&0\158\138\138]\220(B\154\&3\224jV\159v+\130", _pubProps = [PropServerReference "\171\NUL\255\181W#c)\213_\233\156l\214e7\223\159\SYN\138\186Na\129\231\200\222\187\SI",PropResponseInformation "9\247>''\242\222\229\ACK#n\DC4!\\\253\&4pA\238\158\195",PropCorrelationData "v\US\177M\242\DC2\171\229\194h\194\147\236KT\147",PropWildcardSubscriptionAvailable 249,PropAuthenticationMethod "\ACK\168\&7$\DEL\194wS\162",PropTopicAliasMaximum 28784,PropTopicAliasMaximum 19013,PropServerKeepAlive 3972,PropPayloadFormatIndicator 111,PropTopicAlias 4635,PropWillDelayInterval 6106,PropResponseTopic "!\248",PropSubscriptionIdentifier 16,PropResponseTopic "c4Pne\208y\197\194",PropContentType "3A\148\175\r",PropTopicAliasMaximum 8280,PropRequestResponseInformation 163,PropMaximumPacketSize 10851,PropReceiveMaximum 29504,PropMaximumPacketSize 24457,PropServerReference "/\164X\232R9B\249\173Y\ACK\144\ACK%\138a\STX\ETX\190}\250WU\169\164\183",PropServerKeepAlive 15970,PropAuthenticationMethod ";J6"]} TEST(Publish5QCTest, Decode5) { - uint8_t pkt[] = {0x31, 0x3b, 0x0, 0x12, 0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, 0xe6, 0xaf, 0x1a, - 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc, 0x10, 0x9, 0x0, 0x2, 0xe3, 0xf4, 0x13, 0x5, 0xf1, 0x8, - 0x0, 0x5, 0x82, 0x25, 0x29, 0x68, 0x73, 0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, - 0xda, 0xec, 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x12, 0xb8, 0x90, 0x35, 0x88, 0x9c, 0x45, 0xae, 0xed, - 0xe6, 0xaf, 0x1a, 0x99, 0x20, 0x15, 0x6b, 0x19, 0xc}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x69, 0xe8, 0x7b, 0x13, 0x6b, 0x1d, 0x9e, 0x10, 0x7c, 0xda, 0xec, - 0x76, 0xf4, 0x3e, 0x91, 0xac, 0x2c, 0x8, 0x52, 0xa5, 0xff, 0xae}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\251M\156e\192", _pubPktID = 0, -// _pubBody = "O\254\197\133\153\151~\137\172", _pubProps = [PropCorrelationData "\164\SYNM",PropResponseInformation -// "\198\172\187",PropMessageExpiryInterval 15651,PropRetainAvailable 113,PropSharedSubscriptionAvailable -// 216,PropPayloadFormatIndicator 60,PropSessionExpiryInterval 32556,PropRetainAvailable 157,PropResponseTopic -// "bs\182\201\208\166\184\235s",PropSharedSubscriptionAvailable 161,PropCorrelationData -// "\251\167\&6W,g\154\DC2{\163\173\n\177\145\221\151\162\251\159;!o\232\SI\205]{\239\148\216",PropSubscriptionIdentifierAvailable -// 131,PropTopicAliasMaximum 30761,PropMaximumQoS 12,PropContentType -// "\214\132_\244\175\236=^\131\r1d!\223\173w\221",PropWillDelayInterval 27380,PropRequestProblemInformation -// 122,PropTopicAlias 19545,PropReasonString "\166\EOT\231\US\185",PropSubscriptionIdentifierAvailable 97]} +uint8_t pkt[] = {0x3d, 0xf5, 0x1, 0x0, 0x1e, 0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30,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 0x3e, 0x62, 0x15, 0x0, 0x3, 0x3b, 0x4a, 0x36, 0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f}; + lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 26784); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); +EXPECT_EQ(msg.payload_len, 18); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "IP\\2\223\164P[u\SI\DLEh\171x\188\185\177Q#\163v7L\224Y;5", _pubPktID = 14257, _pubBody = "\215Vs\129\239\168\165b\145\208\232`\245", _pubProps = [PropSessionExpiryInterval 4222,PropSubscriptionIdentifierAvailable 237,PropReasonString "6\175G3d\SO*\237\171\SO\234\f*`\253\166\201\&2\GS\204H\250\t\DLE\239",PropCorrelationData "\228",PropResponseTopic "\198$\r\206\225\242\139<\249",PropResponseInformation "\aO",PropUserProperty "\129\ETXH\149M\197\153>\237T\173\192" "\249\130.\189\196\248\154\154\163G",PropAssignedClientIdentifier "\215\161\223\nAr\172a#\252`!\188\208g\DEL~\f\RSx",PropReceiveMaximum 15611,PropAuthenticationMethod "\172\238\233\&0\220|E.3\250s8D-A%\251\&08\FS\215\201\136\186\142?",PropTopicAlias 27987,PropResponseInformation "n\142\194\\\150\183\193K\USk<\"\239\195",PropAssignedClientIdentifier "\150\134\239\143\183b&\198^1_\DEL\136\242\v\246a\fH\175\208\RS\198\141\176\"N=\140",PropServerKeepAlive 15578,PropTopicAliasMaximum 1748,PropContentType "r\ETX\t\ETB\bu.I\161\128K6\184d\138\"\SI;\b\184\"",PropContentType "1-\247a\147\147\ESC\183\&0\221y|7\SI(W\239n?",PropPayloadFormatIndicator 60,PropSubscriptionIdentifier 25,PropPayloadFormatIndicator 36,PropUserProperty "\"-m\172=\230\237\245\206\162\182\177\182\GS\165\250\190\141\252\168\173" "1",PropRequestResponseInformation 106,PropSubscriptionIdentifier 25,PropSubscriptionIdentifier 23]} TEST(Publish5QCTest, Encode6) { - uint8_t pkt[] = {0x31, 0x8d, 0x1, 0x0, 0x5, 0xfb, 0x4d, 0x9c, 0x65, 0xc0, 0x7c, 0x9, 0x0, 0x3, 0xa4, 0x16, - 0x4d, 0x1a, 0x0, 0x3, 0xc6, 0xac, 0xbb, 0x2, 0x0, 0x0, 0x3d, 0x23, 0x25, 0x71, 0x2a, 0xd8, - 0x1, 0x3c, 0x11, 0x0, 0x0, 0x7f, 0x2c, 0x25, 0x9d, 0x8, 0x0, 0x9, 0x62, 0x73, 0xb6, 0xc9, - 0xd0, 0xa6, 0xb8, 0xeb, 0x73, 0x2a, 0xa1, 0x9, 0x0, 0x1e, 0xfb, 0xa7, 0x36, 0x57, 0x2c, 0x67, - 0x9a, 0x12, 0x7b, 0xa3, 0xad, 0xa, 0xb1, 0x91, 0xdd, 0x97, 0xa2, 0xfb, 0x9f, 0x3b, 0x21, 0x6f, - 0xe8, 0xf, 0xcd, 0x5d, 0x7b, 0xef, 0x94, 0xd8, 0x29, 0x83, 0x22, 0x78, 0x29, 0x24, 0xc, 0x3, - 0x0, 0x11, 0xd6, 0x84, 0x5f, 0xf4, 0xaf, 0xec, 0x3d, 0x5e, 0x83, 0xd, 0x31, 0x64, 0x21, 0xdf, - 0xad, 0x77, 0xdd, 0x18, 0x0, 0x0, 0x6a, 0xf4, 0x17, 0x7a, 0x23, 0x4c, 0x59, 0x1f, 0x0, 0x5, - 0xa6, 0x4, 0xe7, 0x1f, 0xb9, 0x29, 0x61, 0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; - uint8_t topic_bytes[] = {0xfb, 0x4d, 0x9c, 0x65, 0xc0}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; - - uint8_t bytesprops0[] = {0xa4, 0x16, 0x4d}; - uint8_t bytesprops1[] = {0xc6, 0xac, 0xbb}; - uint8_t bytesprops2[] = {0x62, 0x73, 0xb6, 0xc9, 0xd0, 0xa6, 0xb8, 0xeb, 0x73}; - uint8_t bytesprops3[] = {0xfb, 0xa7, 0x36, 0x57, 0x2c, 0x67, 0x9a, 0x12, 0x7b, 0xa3, 0xad, 0xa, 0xb1, 0x91, 0xdd, - 0x97, 0xa2, 0xfb, 0x9f, 0x3b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, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 13; + + uint8_t bytesprops0[] = {0x36, 0xaf, 0x47, 0x33, 0x64, 0xe, 0x2a, 0xed, 0xab, 0xe, 0xea, 0xc, 0x2a, 0x60, 0xfd, 0xa6, 0xc9, 0x32, 0x1d, 0xcc, 0x48, 0xfa, 0x9, 0x10, 0xef}; + uint8_t bytesprops1[] = {0xe4}; + uint8_t bytesprops2[] = {0xc6, 0x24, 0xd, 0xce, 0xe1, 0xf2, 0x8b, 0x3c, 0xf9}; + uint8_t bytesprops3[] = {0x7, 0x4f}; + uint8_t bytesprops5[] = {0xf9, 0x82, 0x2e, 0xbd, 0xc4, 0xf8, 0x9a, 0x9a, 0xa3, 0x47}; + uint8_t bytesprops4[] = {0x81, 0x3, 0x48, 0x95, 0x4d, 0xc5, 0x99, 0x3e, 0xed, 0x54, 0xad, 0xc0}; + uint8_t bytesprops6[] = {0xd7, 0xa1, 0xdf, 0xa, 0x41, 0x72, 0xac, 0x61, 0x23, 0xfc, 0x60, 0x21, 0xbc, 0xd0, 0x67, 0x7f, 0x7e, 0xc, 0x1e, 0x78}; + uint8_t bytesprops7[] = {0xac, 0xee, 0xe9, 0x30, 0xdc, 0x7c, 0x45, 0x2e, 0x33, 0xfa, 0x73, 0x38, 0x44, 0x2d, 0x41, 0x25, 0xfb, 0x30, 0x38, 0x1c, 0xd7, 0xc9, 0x88, 0xba, 0x8e, 0x3f}; + uint8_t bytesprops8[] = {0x6e, 0x8e, 0xc2, 0x5c, 0x96, 0xb7, 0xc1, 0x4b, 0x1f, 0x6b, 0x3c, 0x22, 0xef, 0xc3}; + uint8_t bytesprops9[] = {0x96, 0x86, 0xef, 0x8f, 0xb7, 0x62, 0x26, 0xc6, 0x5e, 0x31, 0x5f, 0x7f, 0x88, 0xf2, 0xb, 0xf6, 0x61, 0xc, 0x48, 0xaf, 0xd0, 0x1e, 0xc6, 0x8d, 0xb0, 0x22, 0x4e, 0x3d, 0x8c}; + uint8_t bytesprops10[] = {0x72, 0x3, 0x9, 0x17, 0x8, 0x75, 0x2e, 0x49, 0xa1, 0x80, 0x4b, 0x36, 0xb8, 0x64, 0x8a, 0x22, 0xf, 0x3b, 0x8, 0xb8, 0x22}; + uint8_t bytesprops11[] = {0x31, 0x2d, 0xf7, 0x61, 0x93, 0x93, 0x1b, 0xb7, 0x30, 0xdd, 0x79, 0x7c, 0x37, 0xf, 0x28, 0x57, 0xef, 0x6e, 0x3f}; + uint8_t bytesprops13[] = {0x31}; + uint8_t bytesprops12[] = {0x22, 0x2d, 0x6d, 0xac, 0x3d, 0xe6, 0xed, 0xf5, 0xce, 0xa2, 0xb6, 0xb1, 0xb6, 0x1d, 0xa5, 0xfa, 0xbe, 0x8d, 0xfc, 0xa8, 0xad}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15651}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32556}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30761}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27380}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19545}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4222}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={12, (char*)&bytesprops4}, .v={10, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15611}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27987}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15578}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1748}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={21, (char*)&bytesprops12}, .v={1, (char*)&bytesprops13}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14257, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\251M\156e\192", _pubPktID = 0, -// _pubBody = "O\254\197\133\153\151~\137\172", _pubProps = [PropCorrelationData "\164\SYNM",PropResponseInformation -// "\198\172\187",PropMessageExpiryInterval 15651,PropRetainAvailable 113,PropSharedSubscriptionAvailable -// 216,PropPayloadFormatIndicator 60,PropSessionExpiryInterval 32556,PropRetainAvailable 157,PropResponseTopic -// "bs\182\201\208\166\184\235s",PropSharedSubscriptionAvailable 161,PropCorrelationData -// "\251\167\&6W,g\154\DC2{\163\173\n\177\145\221\151\162\251\159;!o\232\SI\205]{\239\148\216",PropSubscriptionIdentifierAvailable -// 131,PropTopicAliasMaximum 30761,PropMaximumQoS 12,PropContentType -// "\214\132_\244\175\236=^\131\r1d!\223\173w\221",PropWillDelayInterval 27380,PropRequestProblemInformation -// 122,PropTopicAlias 19545,PropReasonString "\166\EOT\231\US\185",PropSubscriptionIdentifierAvailable 97]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "IP\\2\223\164P[u\SI\DLEh\171x\188\185\177Q#\163v7L\224Y;5", _pubPktID = 14257, _pubBody = "\215Vs\129\239\168\165b\145\208\232`\245", _pubProps = [PropSessionExpiryInterval 4222,PropSubscriptionIdentifierAvailable 237,PropReasonString "6\175G3d\SO*\237\171\SO\234\f*`\253\166\201\&2\GS\204H\250\t\DLE\239",PropCorrelationData "\228",PropResponseTopic "\198$\r\206\225\242\139<\249",PropResponseInformation "\aO",PropUserProperty "\129\ETXH\149M\197\153>\237T\173\192" "\249\130.\189\196\248\154\154\163G",PropAssignedClientIdentifier "\215\161\223\nAr\172a#\252`!\188\208g\DEL~\f\RSx",PropReceiveMaximum 15611,PropAuthenticationMethod "\172\238\233\&0\220|E.3\250s8D-A%\251\&08\FS\215\201\136\186\142?",PropTopicAlias 27987,PropResponseInformation "n\142\194\\\150\183\193K\USk<\"\239\195",PropAssignedClientIdentifier "\150\134\239\143\183b&\198^1_\DEL\136\242\v\246a\fH\175\208\RS\198\141\176\"N=\140",PropServerKeepAlive 15578,PropTopicAliasMaximum 1748,PropContentType "r\ETX\t\ETB\bu.I\161\128K6\184d\138\"\SI;\b\184\"",PropContentType "1-\247a\147\147\ESC\183\&0\221y|7\SI(W\239n?",PropPayloadFormatIndicator 60,PropSubscriptionIdentifier 25,PropPayloadFormatIndicator 36,PropUserProperty "\"-m\172=\230\237\245\206\162\182\177\182\GS\165\250\190\141\252\168\173" "1",PropRequestResponseInformation 106,PropSubscriptionIdentifier 25,PropSubscriptionIdentifier 23]} TEST(Publish5QCTest, Decode6) { - uint8_t pkt[] = {0x31, 0x8d, 0x1, 0x0, 0x5, 0xfb, 0x4d, 0x9c, 0x65, 0xc0, 0x7c, 0x9, 0x0, 0x3, 0xa4, 0x16, - 0x4d, 0x1a, 0x0, 0x3, 0xc6, 0xac, 0xbb, 0x2, 0x0, 0x0, 0x3d, 0x23, 0x25, 0x71, 0x2a, 0xd8, - 0x1, 0x3c, 0x11, 0x0, 0x0, 0x7f, 0x2c, 0x25, 0x9d, 0x8, 0x0, 0x9, 0x62, 0x73, 0xb6, 0xc9, - 0xd0, 0xa6, 0xb8, 0xeb, 0x73, 0x2a, 0xa1, 0x9, 0x0, 0x1e, 0xfb, 0xa7, 0x36, 0x57, 0x2c, 0x67, - 0x9a, 0x12, 0x7b, 0xa3, 0xad, 0xa, 0xb1, 0x91, 0xdd, 0x97, 0xa2, 0xfb, 0x9f, 0x3b, 0x21, 0x6f, - 0xe8, 0xf, 0xcd, 0x5d, 0x7b, 0xef, 0x94, 0xd8, 0x29, 0x83, 0x22, 0x78, 0x29, 0x24, 0xc, 0x3, - 0x0, 0x11, 0xd6, 0x84, 0x5f, 0xf4, 0xaf, 0xec, 0x3d, 0x5e, 0x83, 0xd, 0x31, 0x64, 0x21, 0xdf, - 0xad, 0x77, 0xdd, 0x18, 0x0, 0x0, 0x6a, 0xf4, 0x17, 0x7a, 0x23, 0x4c, 0x59, 0x1f, 0x0, 0x5, - 0xa6, 0x4, 0xe7, 0x1f, 0xb9, 0x29, 0x61, 0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQ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e, 0xc2, 0x5c, 0x96, 0xb7, 0xc1, 0x4b, 0x1f, 0x6b, 0x3c, 0x22, 0xef, 0xc3, 0x12, 0x0, 0x1d, 0x96, 0x86, 0xef, 0x8f, 0xb7, 0x62, 0x26, 0xc6, 0x5e, 0x31, 0x5f, 0x7f, 0x88, 0xf2, 0xb, 0xf6, 0x61, 0xc, 0x48, 0xaf, 0xd0, 0x1e, 0xc6, 0x8d, 0xb0, 0x22, 0x4e, 0x3d, 0x8c, 0x13, 0x3c, 0xda, 0x22, 0x6, 0xd4, 0x3, 0x0, 0x15, 0x72, 0x3, 0x9, 0x17, 0x8, 0x75, 0x2e, 0x49, 0xa1, 0x80, 0x4b, 0x36, 0xb8, 0x64, 0x8a, 0x22, 0xf, 0x3b, 0x8, 0xb8, 0x22, 0x3, 0x0, 0x13, 0x31, 0x2d, 0xf7, 0x61, 0x93, 0x93, 0x1b, 0xb7, 0x30, 0xdd, 0x79, 0x7c, 0x37, 0xf, 0x28, 0x57, 0xef, 0x6e, 0x3f, 0x1, 0x3c, 0xb, 0x19, 0x1, 0x24, 0x26, 0x0, 0x15, 0x22, 0x2d, 0x6d, 0xac, 0x3d, 0xe6, 0xed, 0xf5, 0xce, 0xa2, 0xb6, 0xb1, 0xb6, 0x1d, 0xa5, 0xfa, 0xbe, 0x8d, 0xfc, 0xa8, 0xad, 0x0, 0x1, 0x31, 0x19, 0x6a, 0xb, 0x19, 0xb, 0x17, 0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 14257); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); +EXPECT_EQ(msg.payload_len, 13); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xfb, 0x4d, 0x9c, 0x65, 0xc0}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4f, 0xfe, 0xc5, 0x85, 0x99, 0x97, 0x7e, 0x89, 0xac}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\224@\143", _pubPktID = 6480, -// _pubBody = "p\191(\150l\241Y\SO\208g\192\EMT+\DLE\246\189f\179C\EOTFwX1\DC3I*A\n", _pubProps = -// [PropSubscriptionIdentifierAvailable 229,PropSubscriptionIdentifierAvailable 203,PropAssignedClientIdentifier -// "F\195\210\155",PropServerReference "\213\201\ESC\EOT\129|\187\139x",PropReceiveMaximum 23639,PropUserProperty -// "\SO\222O\NAK\188\216\b1\STX\138\158\205m\236D\fy\GS*\223\162\v\231\188\154B\ESC(i" "\178u\ETB\251\241\206\204:j\178 -// ",PropAuthenticationMethod "\167\SUB\235\224\179nC",PropCorrelationData "AH\143]M\202X\141\STX>",PropTopicAlias -// 7879,PropAssignedClientIdentifier "?8\196vb\209i\185\175\&5N\174{\250d\151w%",PropSubscriptionIdentifierAvailable -// 108,PropSharedSubscriptionAvailable 218,PropTopicAlias 27267,PropMaximumPacketSize 20290,PropResponseTopic -// "\EOT\135/c\153\173\178\192\184\207\DC4\ENQ\247\174\CANr\184\197\185\203\\\190\182H"]} -TEST(Publish5QCTest, Encode7) { - uint8_t pkt[] = {0x3b, 0xc4, 0x1, 0x0, 0x3, 0xe0, 0x40, 0x8f, 0x19, 0x50, 0x9d, 0x1, 0x29, 0xe5, 0x29, 0xcb, 0x12, - 0x0, 0x4, 0x46, 0xc3, 0xd2, 0x9b, 0x1c, 0x0, 0x9, 0xd5, 0xc9, 0x1b, 0x4, 0x81, 0x7c, 0xbb, 0x8b, - 0x78, 0x21, 0x5c, 0x57, 0x26, 0x0, 0x1d, 0xe, 0xde, 0x4f, 0x15, 0xbc, 0xd8, 0x8, 0x31, 0x2, 0x8a, - 0x9e, 0xcd, 0x6d, 0xec, 0x44, 0xc, 0x79, 0x1d, 0x2a, 0xdf, 0xa2, 0xb, 0xe7, 0xbc, 0x9a, 0x42, 0x1b, - 0x28, 0x69, 0x0, 0xb, 0xb2, 0x75, 0x17, 0xfb, 0xf1, 0xce, 0xcc, 0x3a, 0x6a, 0xb2, 0x20, 0x15, 0x0, - 0x7, 0xa7, 0x1a, 0xeb, 0xe0, 0xb3, 0x6e, 0x43, 0x9, 0x0, 0xa, 0x41, 0x48, 0x8f, 0x5d, 0x4d, 0xca, - 0x58, 0x8d, 0x2, 0x3e, 0x23, 0x1e, 0xc7, 0x12, 0x0, 0x12, 0x3f, 0x38, 0xc4, 0x76, 0x62, 0xd1, 0x69, - 0xb9, 0xaf, 0x35, 0x4e, 0xae, 0x7b, 0xfa, 0x64, 0x97, 0x77, 0x25, 0x29, 0x6c, 0x2a, 0xda, 0x23, 0x6a, - 0x83, 0x27, 0x0, 0x0, 0x4f, 0x42, 0x8, 0x0, 0x18, 0x4, 0x87, 0x2f, 0x63, 0x99, 0xad, 0xb2, 0xc0, - 0xb8, 0xcf, 0x14, 0x5, 0xf7, 0xae, 0x18, 0x72, 0xb8, 0xc5, 0xb9, 0xcb, 0x5c, 0xbe, 0xb6, 0x48, 0x70, - 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, 0xf6, 0xbd, 0x66, - 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; - uint8_t topic_bytes[] = {0xe0, 0x40, 0x8f}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x70, 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, - 0xf6, 0xbd, 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; - - uint8_t bytesprops0[] = {0x46, 0xc3, 0xd2, 0x9b}; - uint8_t bytesprops1[] = {0xd5, 0xc9, 0x1b, 0x4, 0x81, 0x7c, 0xbb, 0x8b, 0x78}; - uint8_t bytesprops3[] = {0xb2, 0x75, 0x17, 0xfb, 0xf1, 0xce, 0xcc, 0x3a, 0x6a, 0xb2, 0x20}; - uint8_t bytesprops2[] = {0xe, 0xde, 0x4f, 0x15, 0xbc, 0xd8, 0x8, 0x31, 0x2, 0x8a, 0x9e, 0xcd, 0x6d, 0xec, 0x44, - 0xc, 0x79, 0x1d, 0x2a, 0xdf, 0xa2, 0xb, 0xe7, 0xbc, 0x9a, 0x42, 0x1b, 0x28, 0x69}; - uint8_t bytesprops4[] = {0xa7, 0x1a, 0xeb, 0xe0, 0xb3, 0x6e, 0x43}; - uint8_t bytesprops5[] = {0x41, 0x48, 0x8f, 0x5d, 0x4d, 0xca, 0x58, 0x8d, 0x2, 0x3e}; - uint8_t bytesprops6[] = {0x3f, 0x38, 0xc4, 0x76, 0x62, 0xd1, 0x69, 0xb9, 0xaf, - 0x35, 0x4e, 0xae, 0x7b, 0xfa, 0x64, 0x97, 0x77, 0x25}; - uint8_t bytesprops7[] = {0x4, 0x87, 0x2f, 0x63, 0x99, 0xad, 0xb2, 0xc0, 0xb8, 0xcf, 0x14, 0x5, - 0xf7, 0xae, 0x18, 0x72, 0xb8, 0xc5, 0xb9, 0xcb, 0x5c, 0xbe, 0xb6, 0x48}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "6\RS\235\193R\DEL\172\233\219\ETX\209a8\243\RS\229\&2a", _pubPktID = 10501, _pubBody = "*K\219};J\192L&\150k\230#\253#\163\207\128\170\174\GS{\t", _pubProps = [PropMessageExpiryInterval 20953,PropRequestProblemInformation 35,PropReasonString "\239\&8\203",PropPayloadFormatIndicator 223,PropSharedSubscriptionAvailable 171,PropReasonString "\166o\v3\139\232g;\f\SI\"\147[Rr\DC2 p\243\ACK\r\206<6",PropWillDelayInterval 5646,PropMessageExpiryInterval 2935,PropResponseInformation "\ACKD6\229=@",PropContentType "\194",PropMessageExpiryInterval 3137,PropRetainAvailable 40,PropMaximumPacketSize 2855,PropReasonString "m8\255\n>\131Q\132-=\228\254\v\228\SYN",PropTopicAliasMaximum 818,PropSessionExpiryInterval 7249,PropSubscriptionIdentifier 21,PropServerKeepAlive 32278,PropTopicAlias 21281,PropResponseTopic "\211[",PropReasonString "~\175\237->\ENQ\146\144\202\223\143\148\201\197\ESC",PropRequestResponseInformation 158,PropTopicAliasMaximum 9622,PropSubscriptionIdentifierAvailable 9,PropMessageExpiryInterval 3827,PropReasonString "I\190\181\231\SYN\211;\NAK\245\&9\223\DC1\NAKR\148\197\223X\CANGp",PropAuthenticationMethod "\132\147\148\166\SYN\ACK\235\179\183\STX\137\193\DC3\136U\130\243\RS\162\233\165d",PropAuthenticationMethod "\f\249Y\216\201\209\248\&5\232\212\&4-\165d\202\145\&3&}\216\SUB",PropReasonString "\185B\160\232\167#\190j\177\157^\182\198\196_\192\184\207\246;\148B\215\208\137\179\b\204a"]} +TEST(Publish5QCTest, Encode7) { +uint8_t pkt[] = {0x3d, 0xac, 0x2, 0x0, 0x12, 0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61, 0x29, 0x5, 0xfd, 0x1, 0x2, 0x0, 0x0, 0x51, 0xd9, 0x17, 0x23, 0x1f, 0x0, 0x3, 0xef, 0x38, 0xcb, 0x1, 0xdf, 0x2a, 0xab, 0x1f, 0x0, 0x18, 0xa6, 0x6f, 0xb, 0x33, 0x8b, 0xe8, 0x67, 0x3b, 0xc, 0xf, 0x22, 0x93, 0x5b, 0x52, 0x72, 0x12, 0x20, 0x70, 0xf3, 0x6, 0xd, 0xce, 0x3c, 0x36, 0x18, 0x0, 0x0, 0x16, 0xe, 0x2, 0x0, 0x0, 0xb, 0x77, 0x1a, 0x0, 0x6, 0x6, 0x44, 0x36, 0xe5, 0x3d, 0x40, 0x3, 0x0, 0x1, 0xc2, 0x2, 0x0, 0x0, 0xc, 0x41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xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; + uint8_t topic_bytes[] = {0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 23; + + uint8_t bytesprops0[] = {0xef, 0x38, 0xcb}; + uint8_t bytesprops1[] = {0xa6, 0x6f, 0xb, 0x33, 0x8b, 0xe8, 0x67, 0x3b, 0xc, 0xf, 0x22, 0x93, 0x5b, 0x52, 0x72, 0x12, 0x20, 0x70, 0xf3, 0x6, 0xd, 0xce, 0x3c, 0x36}; + uint8_t bytesprops2[] = {0x6, 0x44, 0x36, 0xe5, 0x3d, 0x40}; + uint8_t bytesprops3[] = {0xc2}; + uint8_t bytesprops4[] = {0x6d, 0x38, 0xff, 0xa, 0x3e, 0x83, 0x51, 0x84, 0x2d, 0x3d, 0xe4, 0xfe, 0xb, 0xe4, 0x16}; + uint8_t bytesprops5[] = {0xd3, 0x5b}; + uint8_t bytesprops6[] = {0x7e, 0xaf, 0xed, 0x2d, 0x3e, 0x5, 0x92, 0x90, 0xca, 0xdf, 0x8f, 0x94, 0xc9, 0xc5, 0x1b}; + uint8_t bytesprops7[] = {0x49, 0xbe, 0xb5, 0xe7, 0x16, 0xd3, 0x3b, 0x15, 0xf5, 0x39, 0xdf, 0x11, 0x15, 0x52, 0x94, 0xc5, 0xdf, 0x58, 0x18, 0x47, 0x70}; + uint8_t bytesprops8[] = {0x84, 0x93, 0x94, 0xa6, 0x16, 0x6, 0xeb, 0xb3, 0xb7, 0x2, 0x89, 0xc1, 0x13, 0x88, 0x55, 0x82, 0xf3, 0x1e, 0xa2, 0xe9, 0xa5, 0x64}; + uint8_t bytesprops9[] = {0xc, 0xf9, 0x59, 0xd8, 0xc9, 0xd1, 0xf8, 0x35, 0xe8, 0xd4, 0x34, 0x2d, 0xa5, 0x64, 0xca, 0x91, 0x33, 0x26, 0x7d, 0xd8, 0x1a}; + uint8_t bytesprops10[] = {0xb9, 0x42, 0xa0, 0xe8, 0xa7, 0x23, 0xbe, 0x6a, 0xb1, 0x9d, 0x5e, 0xb6, 0xc6, 0xc4, 0x5f, 0xc0, 0xb8, 0xcf, 0xf6, 0x3b, 0x94, 0x42, 0xd7, 0xd0, 0x89, 0xb3, 0x8, 0xcc, 0x61}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23639}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7879}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27267}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20290}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20953}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5646}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2935}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3137}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2855}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 818}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7249}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32278}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21281}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9622}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3827}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6480, topic, msg, props); + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10501, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\224@\143", _pubPktID = 6480, -// _pubBody = "p\191(\150l\241Y\SO\208g\192\EMT+\DLE\246\189f\179C\EOTFwX1\DC3I*A\n", _pubProps = -// [PropSubscriptionIdentifierAvailable 229,PropSubscriptionIdentifierAvailable 203,PropAssignedClientIdentifier -// "F\195\210\155",PropServerReference "\213\201\ESC\EOT\129|\187\139x",PropReceiveMaximum 23639,PropUserProperty -// "\SO\222O\NAK\188\216\b1\STX\138\158\205m\236D\fy\GS*\223\162\v\231\188\154B\ESC(i" "\178u\ETB\251\241\206\204:j\178 -// ",PropAuthenticationMethod "\167\SUB\235\224\179nC",PropCorrelationData "AH\143]M\202X\141\STX>",PropTopicAlias -// 7879,PropAssignedClientIdentifier "?8\196vb\209i\185\175\&5N\174{\250d\151w%",PropSubscriptionIdentifierAvailable -// 108,PropSharedSubscriptionAvailable 218,PropTopicAlias 27267,PropMaximumPacketSize 20290,PropResponseTopic -// "\EOT\135/c\153\173\178\192\184\207\DC4\ENQ\247\174\CANr\184\197\185\203\\\190\182H"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "6\RS\235\193R\DEL\172\233\219\ETX\209a8\243\RS\229\&2a", _pubPktID = 10501, _pubBody = "*K\219};J\192L&\150k\230#\253#\163\207\128\170\174\GS{\t", _pubProps = [PropMessageExpiryInterval 20953,PropRequestProblemInformation 35,PropReasonString "\239\&8\203",PropPayloadFormatIndicator 223,PropSharedSubscriptionAvailable 171,PropReasonString "\166o\v3\139\232g;\f\SI\"\147[Rr\DC2 p\243\ACK\r\206<6",PropWillDelayInterval 5646,PropMessageExpiryInterval 2935,PropResponseInformation "\ACKD6\229=@",PropContentType "\194",PropMessageExpiryInterval 3137,PropRetainAvailable 40,PropMaximumPacketSize 2855,PropReasonString "m8\255\n>\131Q\132-=\228\254\v\228\SYN",PropTopicAliasMaximum 818,PropSessionExpiryInterval 7249,PropSubscriptionIdentifier 21,PropServerKeepAlive 32278,PropTopicAlias 21281,PropResponseTopic "\211[",PropReasonString "~\175\237->\ENQ\146\144\202\223\143\148\201\197\ESC",PropRequestResponseInformation 158,PropTopicAliasMaximum 9622,PropSubscriptionIdentifierAvailable 9,PropMessageExpiryInterval 3827,PropReasonString "I\190\181\231\SYN\211;\NAK\245\&9\223\DC1\NAKR\148\197\223X\CANGp",PropAuthenticationMethod "\132\147\148\166\SYN\ACK\235\179\183\STX\137\193\DC3\136U\130\243\RS\162\233\165d",PropAuthenticationMethod "\f\249Y\216\201\209\248\&5\232\212\&4-\165d\202\145\&3&}\216\SUB",PropReasonString "\185B\160\232\167#\190j\177\157^\182\198\196_\192\184\207\246;\148B\215\208\137\179\b\204a"]} TEST(Publish5QCTest, Decode7) { - uint8_t pkt[] = {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d, 0x66, - 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3d, 0xac, 0x2, 0x0, 0x12, 0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61, 0x29, 0x5, 0xfd, 0x1, 0x2, 0x0, 0x0, 0x51, 0xd9, 0x17, 0x23, 0x1f, 0x0, 0x3, 0xef, 0x38, 0xcb, 0x1, 0xdf, 0x2a, 0xab, 0x1f, 0x0, 0x18, 0xa6, 0x6f, 0xb, 0x33, 0x8b, 0xe8, 0x67, 0x3b, 0xc, 0xf, 0x22, 0x93, 0x5b, 0x52, 0x72, 0x12, 0x20, 0x70, 0xf3, 0x6, 0xd, 0xce, 0x3c, 0x36, 0x18, 0x0, 0x0, 0x16, 0xe, 0x2, 0x0, 0x0, 0xb, 0x77, 0x1a, 0x0, 0x6, 0x6, 0x44, 0x36, 0xe5, 0x3d, 0x40, 0x3, 0x0, 0x1, 0xc2, 0x2, 0x0, 0x0, 0xc, 0x41, 0x25, 0x28, 0x27, 0x0, 0x0, 0xb, 0x27, 0x1f, 0x0, 0xf, 0x6d, 0x38, 0xff, 0xa, 0x3e, 0x83, 0x51, 0x84, 0x2d, 0x3d, 0xe4, 0xfe, 0xb, 0xe4, 0x16, 0x22, 0x3, 0x32, 0x11, 0x0, 0x0, 0x1c, 0x51, 0xb, 0x15, 0x13, 0x7e, 0x16, 0x23, 0x53, 0x21, 0x8, 0x0, 0x2, 0xd3, 0x5b, 0x1f, 0x0, 0xf, 0x7e, 0xaf, 0xed, 0x2d, 0x3e, 0x5, 0x92, 0x90, 0xca, 0xdf, 0x8f, 0x94, 0xc9, 0xc5, 0x1b, 0x19, 0x9e, 0x22, 0x25, 0x96, 0x29, 0x9, 0x2, 0x0, 0x0, 0xe, 0xf3, 0x1f, 0x0, 0x15, 0x49, 0xbe, 0xb5, 0xe7, 0x16, 0xd3, 0x3b, 0x15, 0xf5, 0x39, 0xdf, 0x11, 0x15, 0x52, 0x94, 0xc5, 0xdf, 0x58, 0x18, 0x47, 0x70, 0x15, 0x0, 0x16, 0x84, 0x93, 0x94, 0xa6, 0x16, 0x6, 0xeb, 0xb3, 0xb7, 0x2, 0x89, 0xc1, 0x13, 0x88, 0x55, 0x82, 0xf3, 0x1e, 0xa2, 0xe9, 0xa5, 0x64, 0x15, 0x0, 0x15, 0xc, 0xf9, 0x59, 0xd8, 0xc9, 0xd1, 0xf8, 0x35, 0xe8, 0xd4, 0x34, 0x2d, 0xa5, 0x64, 0xca, 0x91, 0x33, 0x26, 0x7d, 0xd8, 0x1a, 0x1f, 0x0, 0x1d, 0xb9, 0x42, 0xa0, 0xe8, 0xa7, 0x23, 0xbe, 0x6a, 0xb1, 0x9d, 0x5e, 0xb6, 0xc6, 0xc4, 0x5f, 0xc0, 0xb8, 0xcf, 0xf6, 0x3b, 0x94, 0x42, 0xd7, 0xd0, 0x89, 0xb3, 0x8, 0xcc, 0x61, 0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 10501); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); +EXPECT_EQ(msg.payload_len, 23); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe0, 0x40, 0x8f}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x70, 0xbf, 0x28, 0x96, 0x6c, 0xf1, 0x59, 0xe, 0xd0, 0x67, 0xc0, 0x19, 0x54, 0x2b, 0x10, - 0xf6, 0xbd, 0x66, 0xb3, 0x43, 0x4, 0x46, 0x77, 0x58, 0x31, 0x13, 0x49, 0x2a, 0x41, 0xa}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 6480); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\141\RSw\147`\NAK\ENQ\149f_Y\196\&3b\209U\150s\240\238\a\156\v\151~%\224P\244", _pubPktID = 0, _pubBody = -// "\220\213O", _pubProps = [PropReceiveMaximum 18322,PropRetainAvailable 119,PropReasonString -// "\175\180[\213\230/\203\DC3\173b\160^\DC2\201Y\185\129w\fXw",PropPayloadFormatIndicator 175,PropMaximumQoS -// 179,PropMaximumQoS 174,PropAssignedClientIdentifier "(\217\225\156\ACK",PropResponseTopic -// "\217L\191\252oU\FSl\212\FS\222\213\242\224I\ETB\SO",PropMaximumPacketSize 19484,PropReceiveMaximum -// 32000,PropAssignedClientIdentifier "*u\157f\233aI\237",PropTopicAlias 6311,PropMessageExpiryInterval -// 1640,PropReceiveMaximum 7468,PropMessageExpiryInterval 16489,PropSessionExpiryInterval 3774,PropServerKeepAlive -// 13402,PropTopicAliasMaximum 2331,PropWildcardSubscriptionAvailable 197,PropAuthenticationMethod -// "\206H\160T\197P\CAN\v",PropCorrelationData "\247x\201\224\234b\195\145/\203\192",PropSubscriptionIdentifier -// 19,PropMessageExpiryInterval 16517,PropMaximumPacketSize 20293,PropRequestProblemInformation 92]} -TEST(Publish5QCTest, Encode8) { - uint8_t pkt[] = { - 0x38, 0xba, 0x1, 0x0, 0x1d, 0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, - 0xd1, 0x55, 0x96, 0x73, 0xf0, 0xee, 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4, 0x96, 0x1, 0x21, 0x47, - 0x92, 0x25, 0x77, 0x1f, 0x0, 0x15, 0xaf, 0xb4, 0x5b, 0xd5, 0xe6, 0x2f, 0xcb, 0x13, 0xad, 0x62, 0xa0, 0x5e, 0x12, - 0xc9, 0x59, 0xb9, 0x81, 0x77, 0xc, 0x58, 0x77, 0x1, 0xaf, 0x24, 0xb3, 0x24, 0xae, 0x12, 0x0, 0x5, 0x28, 0xd9, - 0xe1, 0x9c, 0x6, 0x8, 0x0, 0x11, 0xd9, 0x4c, 0xbf, 0xfc, 0x6f, 0x55, 0x1c, 0x6c, 0xd4, 0x1c, 0xde, 0xd5, 0xf2, - 0xe0, 0x49, 0x17, 0xe, 0x27, 0x0, 0x0, 0x4c, 0x1c, 0x21, 0x7d, 0x0, 0x12, 0x0, 0x8, 0x2a, 0x75, 0x9d, 0x66, - 0xe9, 0x61, 0x49, 0xed, 0x23, 0x18, 0xa7, 0x2, 0x0, 0x0, 0x6, 0x68, 0x21, 0x1d, 0x2c, 0x2, 0x0, 0x0, 0x40, - 0x69, 0x11, 0x0, 0x0, 0xe, 0xbe, 0x13, 0x34, 0x5a, 0x22, 0x9, 0x1b, 0x28, 0xc5, 0x15, 0x0, 0x8, 0xce, 0x48, - 0xa0, 0x54, 0xc5, 0x50, 0x18, 0xb, 0x9, 0x0, 0xb, 0xf7, 0x78, 0xc9, 0xe0, 0xea, 0x62, 0xc3, 0x91, 0x2f, 0xcb, - 0xc0, 0xb, 0x13, 0x2, 0x0, 0x0, 0x40, 0x85, 0x27, 0x0, 0x0, 0x4f, 0x45, 0x17, 0x5c, 0xdc, 0xd5, 0x4f}; - uint8_t topic_bytes[] = {0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, - 0x55, 0x96, 0x73, 0xf0, 0xee, 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xdc, 0xd5, 0x4f}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; - - uint8_t bytesprops0[] = {0xaf, 0xb4, 0x5b, 0xd5, 0xe6, 0x2f, 0xcb, 0x13, 0xad, 0x62, 0xa0, - 0x5e, 0x12, 0xc9, 0x59, 0xb9, 0x81, 0x77, 0xc, 0x58, 0x77}; - uint8_t bytesprops1[] = {0x28, 0xd9, 0xe1, 0x9c, 0x6}; - uint8_t bytesprops2[] = {0xd9, 0x4c, 0xbf, 0xfc, 0x6f, 0x55, 0x1c, 0x6c, 0xd4, - 0x1c, 0xde, 0xd5, 0xf2, 0xe0, 0x49, 0x17, 0xe}; - uint8_t bytesprops3[] = {0x2a, 0x75, 0x9d, 0x66, 0xe9, 0x61, 0x49, 0xed}; - uint8_t bytesprops4[] = {0xce, 0x48, 0xa0, 0x54, 0xc5, 0x50, 0x18, 0xb}; - uint8_t bytesprops5[] = {0xf7, 0x78, 0xc9, 0xe0, 0xea, 0x62, 0xc3, 0x91, 0x2f, 0xcb, 0xc0}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\129\171\&3\ETBSN", _pubPktID = 5903, _pubBody = "zPg\212~f\130\171\232\241P\212\ENQ'\234'@\v\177;s\157z*\DC2{\148\&6|", _pubProps = [PropServerKeepAlive 25004,PropRequestProblemInformation 146,PropTopicAlias 13436,PropServerKeepAlive 31880,PropPayloadFormatIndicator 16,PropMessageExpiryInterval 18537,PropAuthenticationData "",PropReasonString "\134\128\129\246\142\ETX]x",PropSessionExpiryInterval 1893,PropMaximumQoS 117,PropMaximumPacketSize 16084,PropTopicAlias 17664,PropTopicAlias 2670,PropServerKeepAlive 6931,PropTopicAliasMaximum 10342,PropUserProperty "\DC4\f{9\243\233\247\196" "\179\ETB\168\&8\STXk\158\SUB\\\132",PropMessageExpiryInterval 14066,PropUserProperty "" "\SO\220\&3oO>\198i\ENQv\147",PropAssignedClientIdentifier "\EMd\138\217\173\154\ETX\145\DC2\173\220\214",PropServerKeepAlive 19246,PropMaximumPacketSize 1458,PropTopicAliasMaximum 9667,PropContentType "I\139L?\197OGv3\t*, `N\138\244\206k\211\\"]} +TEST(Publish5QCTest, Encode8) { +uint8_t pkt[] = {0x3c, 0xbf, 0x1, 0x0, 0x6, 0x81, 0xab, 0x33, 0x17, 0x53, 0x4e, 0x17, 0xf, 0x96, 0x1, 0x13, 0x61, 0xac, 0x17, 0x92, 0x23, 0x34, 0x7c, 0x13, 0x7c, 0x88, 0x1, 0x10, 0x2, 0x0, 0x0, 0x48, 0x69, 0x16, 0x0, 0x0, 0x1f, 0x0, 0x8, 0x86, 0x80, 0x81, 0xf6, 0x8e, 0x3, 0x5d, 0x78, 0x11, 0x0, 0x0, 0x7, 0x65, 0x24, 0x75, 0x27, 0x0, 0x0, 0x3e, 0xd4, 0x23, 0x45, 0x0, 0x23, 0xa, 0x6e, 0x13, 0x1b, 0x13, 0x22, 0x28, 0x66, 0x26, 0x0, 0x8, 0x14, 0xc, 0x7b, 0x39, 0xf3, 0xe9, 0xf7, 0xc4, 0x0, 0xa, 0xb3, 0x17, 0xa8, 0x38, 0x2, 0x6b, 0x9e, 0x1a, 0x5c, 0x84, 0x2, 0x0, 0x0, 0x36, 0xf2, 0x26, 0x0, 0x0, 0x0, 0xb, 0xe, 0xdc, 0x33, 0x6f, 0x4f, 0x3e, 0xc6, 0x69, 0x5, 0x76, 0x93, 0x12, 0x0, 0xc, 0x19, 0x64, 0x8a, 0xd9, 0xad, 0x9a, 0x3, 0x91, 0x12, 0xad, 0xdc, 0xd6, 0x13, 0x4b, 0x2e, 0x27, 0x0, 0x0, 0x5, 0xb2, 0x22, 0x25, 0xc3, 0x3, 0x0, 0x15, 0x49, 0x8b, 0x4c, 0x3f, 0xc5, 0x4f, 0x47, 0x76, 0x33, 0x9, 0x2a, 0x2c, 0x20, 0x60, 0x4e, 0x8a, 0xf4, 0xce, 0x6b, 0xd3, 0x5c, 0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; + uint8_t topic_bytes[] = {0x81, 0xab, 0x33, 0x17, 0x53, 0x4e}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = false; +uint8_t msg_bytes[] = {0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 29; + + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x86, 0x80, 0x81, 0xf6, 0x8e, 0x3, 0x5d, 0x78}; + uint8_t bytesprops3[] = {0xb3, 0x17, 0xa8, 0x38, 0x2, 0x6b, 0x9e, 0x1a, 0x5c, 0x84}; + uint8_t bytesprops2[] = {0x14, 0xc, 0x7b, 0x39, 0xf3, 0xe9, 0xf7, 0xc4}; + uint8_t bytesprops5[] = {0xe, 0xdc, 0x33, 0x6f, 0x4f, 0x3e, 0xc6, 0x69, 0x5, 0x76, 0x93}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops6[] = {0x19, 0x64, 0x8a, 0xd9, 0xad, 0x9a, 0x3, 0x91, 0x12, 0xad, 0xdc, 0xd6}; + uint8_t bytesprops7[] = {0x49, 0x8b, 0x4c, 0x3f, 0xc5, 0x4f, 0x47, 0x76, 0x33, 0x9, 0x2a, 0x2c, 0x20, 0x60, 0x4e, 0x8a, 0xf4, 0xce, 0x6b, 0xd3, 0x5c}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18322}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19484}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32000}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6311}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1640}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7468}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16489}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3774}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13402}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2331}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16517}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20293}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25004}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13436}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31880}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18537}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1893}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16084}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17664}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2670}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6931}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10342}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={8, (char*)&bytesprops2}, .v={10, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14066}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={0, (char*)&bytesprops4}, .v={11, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19246}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1458}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9667}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5903, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\141\RSw\147`\NAK\ENQ\149f_Y\196\&3b\209U\150s\240\238\a\156\v\151~%\224P\244", _pubPktID = 0, _pubBody = -// "\220\213O", _pubProps = [PropReceiveMaximum 18322,PropRetainAvailable 119,PropReasonString -// "\175\180[\213\230/\203\DC3\173b\160^\DC2\201Y\185\129w\fXw",PropPayloadFormatIndicator 175,PropMaximumQoS -// 179,PropMaximumQoS 174,PropAssignedClientIdentifier "(\217\225\156\ACK",PropResponseTopic -// "\217L\191\252oU\FSl\212\FS\222\213\242\224I\ETB\SO",PropMaximumPacketSize 19484,PropReceiveMaximum -// 32000,PropAssignedClientIdentifier "*u\157f\233aI\237",PropTopicAlias 6311,PropMessageExpiryInterval -// 1640,PropReceiveMaximum 7468,PropMessageExpiryInterval 16489,PropSessionExpiryInterval 3774,PropServerKeepAlive -// 13402,PropTopicAliasMaximum 2331,PropWildcardSubscriptionAvailable 197,PropAuthenticationMethod -// "\206H\160T\197P\CAN\v",PropCorrelationData "\247x\201\224\234b\195\145/\203\192",PropSubscriptionIdentifier -// 19,PropMessageExpiryInterval 16517,PropMaximumPacketSize 20293,PropRequestProblemInformation 92]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\129\171\&3\ETBSN", _pubPktID = 5903, _pubBody = "zPg\212~f\130\171\232\241P\212\ENQ'\234'@\v\177;s\157z*\DC2{\148\&6|", _pubProps = [PropServerKeepAlive 25004,PropRequestProblemInformation 146,PropTopicAlias 13436,PropServerKeepAlive 31880,PropPayloadFormatIndicator 16,PropMessageExpiryInterval 18537,PropAuthenticationData "",PropReasonString "\134\128\129\246\142\ETX]x",PropSessionExpiryInterval 1893,PropMaximumQoS 117,PropMaximumPacketSize 16084,PropTopicAlias 17664,PropTopicAlias 2670,PropServerKeepAlive 6931,PropTopicAliasMaximum 10342,PropUserProperty "\DC4\f{9\243\233\247\196" "\179\ETB\168\&8\STXk\158\SUB\\\132",PropMessageExpiryInterval 14066,PropUserProperty "" "\SO\220\&3oO>\198i\ENQv\147",PropAssignedClientIdentifier "\EMd\138\217\173\154\ETX\145\DC2\173\220\214",PropServerKeepAlive 19246,PropMaximumPacketSize 1458,PropTopicAliasMaximum 9667,PropContentType "I\139L?\197OGv3\t*, `N\138\244\206k\211\\"]} TEST(Publish5QCTest, Decode8) { - uint8_t pkt[] = { - 0x38, 0xba, 0x1, 0x0, 0x1d, 0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, - 0xd1, 0x55, 0x96, 0x73, 0xf0, 0xee, 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4, 0x96, 0x1, 0x21, 0x47, - 0x92, 0x25, 0x77, 0x1f, 0x0, 0x15, 0xaf, 0xb4, 0x5b, 0xd5, 0xe6, 0x2f, 0xcb, 0x13, 0xad, 0x62, 0xa0, 0x5e, 0x12, - 0xc9, 0x59, 0xb9, 0x81, 0x77, 0xc, 0x58, 0x77, 0x1, 0xaf, 0x24, 0xb3, 0x24, 0xae, 0x12, 0x0, 0x5, 0x28, 0xd9, - 0xe1, 0x9c, 0x6, 0x8, 0x0, 0x11, 0xd9, 0x4c, 0xbf, 0xfc, 0x6f, 0x55, 0x1c, 0x6c, 0xd4, 0x1c, 0xde, 0xd5, 0xf2, - 0xe0, 0x49, 0x17, 0xe, 0x27, 0x0, 0x0, 0x4c, 0x1c, 0x21, 0x7d, 0x0, 0x12, 0x0, 0x8, 0x2a, 0x75, 0x9d, 0x66, - 0xe9, 0x61, 0x49, 0xed, 0x23, 0x18, 0xa7, 0x2, 0x0, 0x0, 0x6, 0x68, 0x21, 0x1d, 0x2c, 0x2, 0x0, 0x0, 0x40, - 0x69, 0x11, 0x0, 0x0, 0xe, 0xbe, 0x13, 0x34, 0x5a, 0x22, 0x9, 0x1b, 0x28, 0xc5, 0x15, 0x0, 0x8, 0xce, 0x48, - 0xa0, 0x54, 0xc5, 0x50, 0x18, 0xb, 0x9, 0x0, 0xb, 0xf7, 0x78, 0xc9, 0xe0, 0xea, 0x62, 0xc3, 0x91, 0x2f, 0xcb, - 0xc0, 0xb, 0x13, 0x2, 0x0, 0x0, 0x40, 0x85, 0x27, 0x0, 0x0, 0x4f, 0x45, 0x17, 0x5c, 0xdc, 0xd5, 0x4f}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3c, 0xbf, 0x1, 0x0, 0x6, 0x81, 0xab, 0x33, 0x17, 0x53, 0x4e, 0x17, 0xf, 0x96, 0x1, 0x13, 0x61, 0xac, 0x17, 0x92, 0x23, 0x34, 0x7c, 0x13, 0x7c, 0x88, 0x1, 0x10, 0x2, 0x0, 0x0, 0x48, 0x69, 0x16, 0x0, 0x0, 0x1f, 0x0, 0x8, 0x86, 0x80, 0x81, 0xf6, 0x8e, 0x3, 0x5d, 0x78, 0x11, 0x0, 0x0, 0x7, 0x65, 0x24, 0x75, 0x27, 0x0, 0x0, 0x3e, 0xd4, 0x23, 0x45, 0x0, 0x23, 0xa, 0x6e, 0x13, 0x1b, 0x13, 0x22, 0x28, 0x66, 0x26, 0x0, 0x8, 0x14, 0xc, 0x7b, 0x39, 0xf3, 0xe9, 0xf7, 0xc4, 0x0, 0xa, 0xb3, 0x17, 0xa8, 0x38, 0x2, 0x6b, 0x9e, 0x1a, 0x5c, 0x84, 0x2, 0x0, 0x0, 0x36, 0xf2, 0x26, 0x0, 0x0, 0x0, 0xb, 0xe, 0xdc, 0x33, 0x6f, 0x4f, 0x3e, 0xc6, 0x69, 0x5, 0x76, 0x93, 0x12, 0x0, 0xc, 0x19, 0x64, 0x8a, 0xd9, 0xad, 0x9a, 0x3, 0x91, 0x12, 0xad, 0xdc, 0xd6, 0x13, 0x4b, 0x2e, 0x27, 0x0, 0x0, 0x5, 0xb2, 0x22, 0x25, 0xc3, 0x3, 0x0, 0x15, 0x49, 0x8b, 0x4c, 0x3f, 0xc5, 0x4f, 0x47, 0x76, 0x33, 0x9, 0x2a, 0x2c, 0x20, 0x60, 0x4e, 0x8a, 0xf4, 0xce, 0x6b, 0xd3, 0x5c, 0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x81, 0xab, 0x33, 0x17, 0x53, 0x4e}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 5903); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); +EXPECT_EQ(msg.payload_len, 29); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x8d, 0x1e, 0x77, 0x93, 0x60, 0x15, 0x5, 0x95, 0x66, 0x5f, 0x59, 0xc4, 0x33, 0x62, 0xd1, - 0x55, 0x96, 0x73, 0xf0, 0xee, 0x7, 0x9c, 0xb, 0x97, 0x7e, 0x25, 0xe0, 0x50, 0xf4}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xdc, 0xd5, 0x4f}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\130\180J\210\214\ENQ\185\DC3T.\233,_\253N\188M\218\t\203\210\&9z\193w\227", _pubPktID = 5801, _pubBody = -// "e/2Y\147]W%\233\NUL\170j25\192", _pubProps = [PropUserProperty "+\173\131\ETX\156\246\222i\129\FS" -// "]\154C\131\170|\248P",PropContentType "\128\CAN\181Y",PropSubscriptionIdentifierAvailable -// 184,PropSharedSubscriptionAvailable 154,PropResponseInformation "!\174\152@#\171\248l\r\161\231\b4",PropTopicAlias -// 24162,PropResponseTopic -// "h\253\215\&3\165\155\178D\181\SO\SYNP\225\RS\175\226/\154\203\229\&9\205\132\225\203",PropMaximumQoS 62]} -TEST(Publish5QCTest, Encode9) { - uint8_t pkt[] = {0x3a, 0x81, 0x1, 0x0, 0x1a, 0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, - 0x5f, 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3, 0x16, 0xa9, 0x53, - 0x26, 0x0, 0xa, 0x2b, 0xad, 0x83, 0x3, 0x9c, 0xf6, 0xde, 0x69, 0x81, 0x1c, 0x0, 0x8, 0x5d, 0x9a, - 0x43, 0x83, 0xaa, 0x7c, 0xf8, 0x50, 0x3, 0x0, 0x4, 0x80, 0x18, 0xb5, 0x59, 0x29, 0xb8, 0x2a, 0x9a, - 0x1a, 0x0, 0xd, 0x21, 0xae, 0x98, 0x40, 0x23, 0xab, 0xf8, 0x6c, 0xd, 0xa1, 0xe7, 0x8, 0x34, 0x23, - 0x5e, 0x62, 0x8, 0x0, 0x19, 0x68, 0xfd, 0xd7, 0x33, 0xa5, 0x9b, 0xb2, 0x44, 0xb5, 0xe, 0x16, 0x50, - 0xe1, 0x1e, 0xaf, 0xe2, 0x2f, 0x9a, 0xcb, 0xe5, 0x39, 0xcd, 0x84, 0xe1, 0xcb, 0x24, 0x3e, 0x65, 0x2f, - 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; - uint8_t topic_bytes[] = {0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, 0x5f, - 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops1[] = {0x5d, 0x9a, 0x43, 0x83, 0xaa, 0x7c, 0xf8, 0x50}; - uint8_t bytesprops0[] = {0x2b, 0xad, 0x83, 0x3, 0x9c, 0xf6, 0xde, 0x69, 0x81, 0x1c}; - uint8_t bytesprops2[] = {0x80, 0x18, 0xb5, 0x59}; - uint8_t bytesprops3[] = {0x21, 0xae, 0x98, 0x40, 0x23, 0xab, 0xf8, 0x6c, 0xd, 0xa1, 0xe7, 0x8, 0x34}; - uint8_t bytesprops4[] = {0x68, 0xfd, 0xd7, 0x33, 0xa5, 0x9b, 0xb2, 0x44, 0xb5, 0xe, 0x16, 0x50, 0xe1, - 0x1e, 0xaf, 0xe2, 0x2f, 0x9a, 0xcb, 0xe5, 0x39, 0xcd, 0x84, 0xe1, 0xcb}; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "f\145?\ETXkG", _pubPktID = 0, _pubBody = "z)\172\246\137o\201C\144\161\ETX\DC4\243V\SI\136\ETX\223\135V\253\SYN\a\200.", _pubProps = [PropTopicAliasMaximum 31258,PropAssignedClientIdentifier ".\236\244\&2}I\NAK\164\152\251\\\176\&5\244'\245\152YXN\USq\218\249\DC4\SYN\ETX",PropRetainAvailable 81]} +TEST(Publish5QCTest, Encode9) { +uint8_t pkt[] = {0x31, 0x45, 0x0, 0x6, 0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47, 0x23, 0x22, 0x7a, 0x1a, 0x12, 0x0, 0x1b, 0x2e, 0xec, 0xf4, 0x32, 0x7d, 0x49, 0x15, 0xa4, 0x98, 0xfb, 0x5c, 0xb0, 0x35, 0xf4, 0x27, 0xf5, 0x98, 0x59, 0x58, 0x4e, 0x1f, 0x71, 0xda, 0xf9, 0x14, 0x16, 0x3, 0x25, 0x51, 0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; + uint8_t topic_bytes[] = {0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = true; +uint8_t msg_bytes[] = {0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 25; + + uint8_t bytesprops0[] = {0x2e, 0xec, 0xf4, 0x32, 0x7d, 0x49, 0x15, 0xa4, 0x98, 0xfb, 0x5c, 0xb0, 0x35, 0xf4, 0x27, 0xf5, 0x98, 0x59, 0x58, 0x4e, 0x1f, 0x71, 0xda, 0xf9, 0x14, 0x16, 0x3}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24162}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31258}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5801, topic, msg, props); + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\130\180J\210\214\ENQ\185\DC3T.\233,_\253N\188M\218\t\203\210\&9z\193w\227", _pubPktID = 5801, _pubBody = -// "e/2Y\147]W%\233\NUL\170j25\192", _pubProps = [PropUserProperty "+\173\131\ETX\156\246\222i\129\FS" -// "]\154C\131\170|\248P",PropContentType "\128\CAN\181Y",PropSubscriptionIdentifierAvailable -// 184,PropSharedSubscriptionAvailable 154,PropResponseInformation "!\174\152@#\171\248l\r\161\231\b4",PropTopicAlias -// 24162,PropResponseTopic -// "h\253\215\&3\165\155\178D\181\SO\SYNP\225\RS\175\226/\154\203\229\&9\205\132\225\203",PropMaximumQoS 62]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "f\145?\ETXkG", _pubPktID = 0, _pubBody = "z)\172\246\137o\201C\144\161\ETX\DC4\243V\SI\136\ETX\223\135V\253\SYN\a\200.", _pubProps = [PropTopicAliasMaximum 31258,PropAssignedClientIdentifier ".\236\244\&2}I\NAK\164\152\251\\\176\&5\244'\245\152YXN\USq\218\249\DC4\SYN\ETX",PropRetainAvailable 81]} TEST(Publish5QCTest, Decode9) { - uint8_t pkt[] = {0x3a, 0x81, 0x1, 0x0, 0x1a, 0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, - 0x5f, 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3, 0x16, 0xa9, 0x53, - 0x26, 0x0, 0xa, 0x2b, 0xad, 0x83, 0x3, 0x9c, 0xf6, 0xde, 0x69, 0x81, 0x1c, 0x0, 0x8, 0x5d, 0x9a, - 0x43, 0x83, 0xaa, 0x7c, 0xf8, 0x50, 0x3, 0x0, 0x4, 0x80, 0x18, 0xb5, 0x59, 0x29, 0xb8, 0x2a, 0x9a, - 0x1a, 0x0, 0xd, 0x21, 0xae, 0x98, 0x40, 0x23, 0xab, 0xf8, 0x6c, 0xd, 0xa1, 0xe7, 0x8, 0x34, 0x23, - 0x5e, 0x62, 0x8, 0x0, 0x19, 0x68, 0xfd, 0xd7, 0x33, 0xa5, 0x9b, 0xb2, 0x44, 0xb5, 0xe, 0x16, 0x50, - 0xe1, 0x1e, 0xaf, 0xe2, 0x2f, 0x9a, 0xcb, 0xe5, 0x39, 0xcd, 0x84, 0xe1, 0xcb, 0x24, 0x3e, 0x65, 0x2f, - 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x31, 0x45, 0x0, 0x6, 0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47, 0x23, 0x22, 0x7a, 0x1a, 0x12, 0x0, 0x1b, 0x2e, 0xec, 0xf4, 0x32, 0x7d, 0x49, 0x15, 0xa4, 0x98, 0xfb, 0x5c, 0xb0, 0x35, 0xf4, 0x27, 0xf5, 0x98, 0x59, 0x58, 0x4e, 0x1f, 0x71, 0xda, 0xf9, 0x14, 0x16, 0x3, 0x25, 0x51, 0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); +EXPECT_EQ(msg.payload_len, 25); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x82, 0xb4, 0x4a, 0xd2, 0xd6, 0x5, 0xb9, 0x13, 0x54, 0x2e, 0xe9, 0x2c, 0x5f, - 0xfd, 0x4e, 0xbc, 0x4d, 0xda, 0x9, 0xcb, 0xd2, 0x39, 0x7a, 0xc1, 0x77, 0xe3}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x65, 0x2f, 0x32, 0x59, 0x93, 0x5d, 0x57, 0x25, 0xe9, 0x0, 0xaa, 0x6a, 0x32, 0x35, 0xc0}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 5801); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "$hC\136_\134&\134\182\244\211M\211a\221[", _pubPktID = 25662, _pubBody = "", _pubProps = [PropAuthenticationData -// "\255b\ENQ\STX\nb\133\169\184\SI\143\EM^\SYN\165\207I\209\221\170\174\217",PropSharedSubscriptionAvailable -// 63,PropSessionExpiryInterval 27183,PropWillDelayInterval 524,PropSharedSubscriptionAvailable -// 96,PropRequestProblemInformation 230,PropTopicAliasMaximum 5870,PropReasonString -// "\156T\166",PropMessageExpiryInterval 5899,PropMessageExpiryInterval 9209,PropWillDelayInterval -// 6888,PropReceiveMaximum 2826,PropRequestResponseInformation 52]} -TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = {0x3c, 0x5b, 0x0, 0x10, 0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, 0xb6, 0xf4, 0xd3, 0x4d, - 0xd3, 0x61, 0xdd, 0x5b, 0x64, 0x3e, 0x46, 0x16, 0x0, 0x16, 0xff, 0x62, 0x5, 0x2, 0xa, 0x62, - 0x85, 0xa9, 0xb8, 0xf, 0x8f, 0x19, 0x5e, 0x16, 0xa5, 0xcf, 0x49, 0xd1, 0xdd, 0xaa, 0xae, 0xd9, - 0x2a, 0x3f, 0x11, 0x0, 0x0, 0x6a, 0x2f, 0x18, 0x0, 0x0, 0x2, 0xc, 0x2a, 0x60, 0x17, 0xe6, - 0x22, 0x16, 0xee, 0x1f, 0x0, 0x3, 0x9c, 0x54, 0xa6, 0x2, 0x0, 0x0, 0x17, 0xb, 0x2, 0x0, - 0x0, 0x23, 0xf9, 0x18, 0x0, 0x0, 0x1a, 0xe8, 0x21, 0xb, 0xa, 0x19, 0x34}; - uint8_t topic_bytes[] = {0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, - 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; - - uint8_t bytesprops0[] = {0xff, 0x62, 0x5, 0x2, 0xa, 0x62, 0x85, 0xa9, 0xb8, 0xf, 0x8f, - 0x19, 0x5e, 0x16, 0xa5, 0xcf, 0x49, 0xd1, 0xdd, 0xaa, 0xae, 0xd9}; - uint8_t bytesprops1[] = {0x9c, 0x54, 0xa6}; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\155rvW\187y*a\164\152\nL\EMg}@\SYN\142\DC2", _pubPktID = 0, _pubBody = "\US\US\DLE\ESC\221J\DC3T\209\207\183rx\202;\229\224\EM\241z#\169X\166\139", _pubProps = [PropServerKeepAlive 6612,PropResponseTopic "\211\178"]} +TEST(Publish5QCTest, Encode10) { +uint8_t pkt[] = {0x39, 0x37, 0x0, 0x13, 0x9b, 0x72, 0x76, 0x57, 0xbb, 0x79, 0x2a, 0x61, 0xa4, 0x98, 0xa, 0x4c, 0x19, 0x67, 0x7d, 0x40, 0x16, 0x8e, 0x12, 0x8, 0x13, 0x19, 0xd4, 0x8, 0x0, 0x2, 0xd3, 0xb2, 0x1f, 0x1f, 0x10, 0x1b, 0xdd, 0x4a, 0x13, 0x54, 0xd1, 0xcf, 0xb7, 0x72, 0x78, 0xca, 0x3b, 0xe5, 0xe0, 0x19, 0xf1, 0x7a, 0x23, 0xa9, 0x58, 0xa6, 0x8b}; + uint8_t topic_bytes[] = {0x9b, 0x72, 0x76, 0x57, 0xbb, 0x79, 0x2a, 0x61, 0xa4, 0x98, 0xa, 0x4c, 0x19, 0x67, 0x7d, 0x40, 0x16, 0x8e, 0x12}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = true; +uint8_t msg_bytes[] = {0x1f, 0x1f, 0x10, 0x1b, 0xdd, 0x4a, 0x13, 0x54, 0xd1, 0xcf, 0xb7, 0x72, 0x78, 0xca, 0x3b, 0xe5, 0xe0, 0x19, 0xf1, 0x7a, 0x23, 0xa9, 0x58, 0xa6, 0x8b}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 25; + + uint8_t bytesprops0[] = {0xd3, 0xb2}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27183}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 524}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5870}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5899}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9209}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6888}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2826}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 52}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25662, topic, msg, props); + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6612}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops0}}}, + }; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "$hC\136_\134&\134\182\244\211M\211a\221[", _pubPktID = 25662, _pubBody = "", _pubProps = [PropAuthenticationData -// "\255b\ENQ\STX\nb\133\169\184\SI\143\EM^\SYN\165\207I\209\221\170\174\217",PropSharedSubscriptionAvailable -// 63,PropSessionExpiryInterval 27183,PropWillDelayInterval 524,PropSharedSubscriptionAvailable -// 96,PropRequestProblemInformation 230,PropTopicAliasMaximum 5870,PropReasonString -// "\156T\166",PropMessageExpiryInterval 5899,PropMessageExpiryInterval 9209,PropWillDelayInterval -// 6888,PropReceiveMaximum 2826,PropRequestResponseInformation 52]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\155rvW\187y*a\164\152\nL\EMg}@\SYN\142\DC2", _pubPktID = 0, _pubBody = "\US\US\DLE\ESC\221J\DC3T\209\207\183rx\202;\229\224\EM\241z#\169X\166\139", _pubProps = [PropServerKeepAlive 6612,PropResponseTopic "\211\178"]} TEST(Publish5QCTest, Decode10) { - uint8_t pkt[] = {0x3c, 0x5b, 0x0, 0x10, 0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, 0xb6, 0xf4, 0xd3, 0x4d, - 0xd3, 0x61, 0xdd, 0x5b, 0x64, 0x3e, 0x46, 0x16, 0x0, 0x16, 0xff, 0x62, 0x5, 0x2, 0xa, 0x62, - 0x85, 0xa9, 0xb8, 0xf, 0x8f, 0x19, 0x5e, 0x16, 0xa5, 0xcf, 0x49, 0xd1, 0xdd, 0xaa, 0xae, 0xd9, - 0x2a, 0x3f, 0x11, 0x0, 0x0, 0x6a, 0x2f, 0x18, 0x0, 0x0, 0x2, 0xc, 0x2a, 0x60, 0x17, 0xe6, - 0x22, 0x16, 0xee, 0x1f, 0x0, 0x3, 0x9c, 0x54, 0xa6, 0x2, 0x0, 0x0, 0x17, 0xb, 0x2, 0x0, - 0x0, 0x23, 0xf9, 0x18, 0x0, 0x0, 0x1a, 0xe8, 0x21, 0xb, 0xa, 0x19, 0x34}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x39, 0x37, 0x0, 0x13, 0x9b, 0x72, 0x76, 0x57, 0xbb, 0x79, 0x2a, 0x61, 0xa4, 0x98, 0xa, 0x4c, 0x19, 0x67, 0x7d, 0x40, 0x16, 0x8e, 0x12, 0x8, 0x13, 0x19, 0xd4, 0x8, 0x0, 0x2, 0xd3, 0xb2, 0x1f, 0x1f, 0x10, 0x1b, 0xdd, 0x4a, 0x13, 0x54, 0xd1, 0xcf, 0xb7, 0x72, 0x78, 0xca, 0x3b, 0xe5, 0xe0, 0x19, 0xf1, 0x7a, 0x23, 0xa9, 0x58, 0xa6, 0x8b}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x9b, 0x72, 0x76, 0x57, 0xbb, 0x79, 0x2a, 0x61, 0xa4, 0x98, 0xa, 0x4c, 0x19, 0x67, 0x7d, 0x40, 0x16, 0x8e, 0x12}; + lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1f, 0x1f, 0x10, 0x1b, 0xdd, 0x4a, 0x13, 0x54, 0xd1, 0xcf, 0xb7, 0x72, 0x78, 0xca, 0x3b, 0xe5, 0xe0, 0x19, 0xf1, 0x7a, 0x23, 0xa9, 0x58, 0xa6, 0x8b}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); +EXPECT_EQ(msg.payload_len, 25); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x24, 0x68, 0x43, 0x88, 0x5f, 0x86, 0x26, 0x86, - 0xb6, 0xf4, 0xd3, 0x4d, 0xd3, 0x61, 0xdd, 0x5b}; - lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 25662); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\181\165\155@\151\196\153>\212\208\158e;\229\178\rW&", _pubPktID = 28678, _pubBody = -// "\197b\187\ACKO^\130\182\SI\241\185\141\n\187P", _pubProps = [PropReceiveMaximum 12673,PropMaximumPacketSize -// 3493,PropMaximumQoS 123,PropMessageExpiryInterval 17483,PropServerReference -// "\DEL\ESCn6\193\n(\153L6MThmB\NAK{\212\186\244\223\"\135\f\130",PropResponseTopic -// ".\ESCC\CANS\210\173i\158i\248|'!",PropMessageExpiryInterval 2389,PropSubscriptionIdentifier 33,PropServerKeepAlive -// 31451,PropServerReference "\177\ETB\255p\144u\190}\SIx\ETX&c]\198\b\214(\220b\134\172`",PropMaximumQoS -// 23,PropResponseInformation "\194\194\GS",PropMessageExpiryInterval 32044,PropAuthenticationData -// "\184f\226",PropResponseTopic "\142\185\246\137\"\204",PropMaximumPacketSize 32478,PropReasonString -// "d\212\208\206?",PropResponseInformation "\SOH\ACK\234z\206G+s\241\\+x\158\214\199\"",PropCorrelationData -// "\150\247\181\210K\208`\229\174\&1!\167,`",PropUserProperty "\223WA" "\232\148",PropTopicAliasMaximum -// 10581,PropAuthenticationMethod "b\164",PropCorrelationData "\154\223!_\216\254S\209\218\"\210",PropCorrelationData -// "?J\163\161\173q\187\225Z\159"]} -TEST(Publish5QCTest, Encode11) { - uint8_t pkt[] = { - 0x32, 0x81, 0x2, 0x0, 0x12, 0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, 0xd0, 0x9e, 0x65, 0x3b, 0xe5, - 0xb2, 0xd, 0x57, 0x26, 0x70, 0x6, 0xda, 0x1, 0x21, 0x31, 0x81, 0x27, 0x0, 0x0, 0xd, 0xa5, 0x24, 0x7b, 0x2, - 0x0, 0x0, 0x44, 0x4b, 0x1c, 0x0, 0x19, 0x7f, 0x1b, 0x6e, 0x36, 0xc1, 0xa, 0x28, 0x99, 0x4c, 0x36, 0x4d, 0x54, - 0x68, 0x6d, 0x42, 0x15, 0x7b, 0xd4, 0xba, 0xf4, 0xdf, 0x22, 0x87, 0xc, 0x82, 0x8, 0x0, 0xe, 0x2e, 0x1b, 0x43, - 0x18, 0x53, 0xd2, 0xad, 0x69, 0x9e, 0x69, 0xf8, 0x7c, 0x27, 0x21, 0x2, 0x0, 0x0, 0x9, 0x55, 0xb, 0x21, 0x13, - 0x7a, 0xdb, 0x1c, 0x0, 0x17, 0xb1, 0x17, 0xff, 0x70, 0x90, 0x75, 0xbe, 0x7d, 0xf, 0x78, 0x3, 0x26, 0x63, 0x5d, - 0xc6, 0x8, 0xd6, 0x28, 0xdc, 0x62, 0x86, 0xac, 0x60, 0x24, 0x17, 0x1a, 0x0, 0x3, 0xc2, 0xc2, 0x1d, 0x2, 0x0, - 0x0, 0x7d, 0x2c, 0x16, 0x0, 0x3, 0xb8, 0x66, 0xe2, 0x8, 0x0, 0x6, 0x8e, 0xb9, 0xf6, 0x89, 0x22, 0xcc, 0x27, - 0x0, 0x0, 0x7e, 0xde, 0x1f, 0x0, 0x5, 0x64, 0xd4, 0xd0, 0xce, 0x3f, 0x1a, 0x0, 0x10, 0x1, 0x6, 0xea, 0x7a, - 0xce, 0x47, 0x2b, 0x73, 0xf1, 0x5c, 0x2b, 0x78, 0x9e, 0xd6, 0xc7, 0x22, 0x9, 0x0, 0xe, 0x96, 0xf7, 0xb5, 0xd2, - 0x4b, 0xd0, 0x60, 0xe5, 0xae, 0x31, 0x21, 0xa7, 0x2c, 0x60, 0x26, 0x0, 0x3, 0xdf, 0x57, 0x41, 0x0, 0x2, 0xe8, - 0x94, 0x22, 0x29, 0x55, 0x15, 0x0, 0x2, 0x62, 0xa4, 0x9, 0x0, 0xb, 0x9a, 0xdf, 0x21, 0x5f, 0xd8, 0xfe, 0x53, - 0xd1, 0xda, 0x22, 0xd2, 0x9, 0x0, 0xa, 0x3f, 0x4a, 0xa3, 0xa1, 0xad, 0x71, 0xbb, 0xe1, 0x5a, 0x9f, 0xc5, 0x62, - 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; - uint8_t topic_bytes[] = {0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, - 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xc5, 0x62, 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0x7f, 0x1b, 0x6e, 0x36, 0xc1, 0xa, 0x28, 0x99, 0x4c, 0x36, 0x4d, 0x54, 0x68, - 0x6d, 0x42, 0x15, 0x7b, 0xd4, 0xba, 0xf4, 0xdf, 0x22, 0x87, 0xc, 0x82}; - uint8_t bytesprops1[] = {0x2e, 0x1b, 0x43, 0x18, 0x53, 0xd2, 0xad, 0x69, 0x9e, 0x69, 0xf8, 0x7c, 0x27, 0x21}; - uint8_t bytesprops2[] = {0xb1, 0x17, 0xff, 0x70, 0x90, 0x75, 0xbe, 0x7d, 0xf, 0x78, 0x3, 0x26, - 0x63, 0x5d, 0xc6, 0x8, 0xd6, 0x28, 0xdc, 0x62, 0x86, 0xac, 0x60}; - uint8_t bytesprops3[] = {0xc2, 0xc2, 0x1d}; - uint8_t bytesprops4[] = {0xb8, 0x66, 0xe2}; - uint8_t bytesprops5[] = {0x8e, 0xb9, 0xf6, 0x89, 0x22, 0xcc}; - uint8_t bytesprops6[] = {0x64, 0xd4, 0xd0, 0xce, 0x3f}; - uint8_t bytesprops7[] = {0x1, 0x6, 0xea, 0x7a, 0xce, 0x47, 0x2b, 0x73, - 0xf1, 0x5c, 0x2b, 0x78, 0x9e, 0xd6, 0xc7, 0x22}; - uint8_t bytesprops8[] = {0x96, 0xf7, 0xb5, 0xd2, 0x4b, 0xd0, 0x60, 0xe5, 0xae, 0x31, 0x21, 0xa7, 0x2c, 0x60}; - uint8_t bytesprops10[] = {0xe8, 0x94}; - uint8_t bytesprops9[] = {0xdf, 0x57, 0x41}; - uint8_t bytesprops11[] = {0x62, 0xa4}; - uint8_t bytesprops12[] = {0x9a, 0xdf, 0x21, 0x5f, 0xd8, 0xfe, 0x53, 0xd1, 0xda, 0x22, 0xd2}; - uint8_t bytesprops13[] = {0x3f, 0x4a, 0xa3, 0xa1, 0xad, 0x71, 0xbb, 0xe1, 0x5a, 0x9f}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "2n\201\176\229\EM\245*\ACK\SUB\177\b~\130\155,l", _pubPktID = 18294, _pubBody = "22", _pubProps = [PropTopicAlias 1825,PropServerKeepAlive 27568,PropMaximumPacketSize 32649,PropSessionExpiryInterval 12496,PropUserProperty "\191\&8m" "Zj\183\171\&9\190~\166\141\175\\\ACK8>\236\253Sa\DC2qTY\138\GS{w\214",PropReasonString "\SO~\152\246\198\247\169r"]} +TEST(Publish5QCTest, Encode11) { +uint8_t pkt[] = {0x33, 0x56, 0x0, 0x11, 0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c, 0x47, 0x76, 0x3e, 0x23, 0x7, 0x21, 0x13, 0x6b, 0xb0, 0x27, 0x0, 0x0, 0x7f, 0x89, 0x11, 0x0, 0x0, 0x30, 0xd0, 0x26, 0x0, 0x3, 0xbf, 0x38, 0x6d, 0x0, 0x1b, 0x5a, 0x6a, 0xb7, 0xab, 0x39, 0xbe, 0x7e, 0xa6, 0x8d, 0xaf, 0x5c, 0x6, 0x38, 0x3e, 0xec, 0xfd, 0x53, 0x61, 0x12, 0x71, 0x54, 0x59, 0x8a, 0x1d, 0x7b, 0x77, 0xd6, 0x1f, 0x0, 0x8, 0xe, 0x7e, 0x98, 0xf6, 0xc6, 0xf7, 0xa9, 0x72, 0x32, 0x32}; + uint8_t topic_bytes[] = {0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x32, 0x32}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 2; + + uint8_t bytesprops1[] = {0x5a, 0x6a, 0xb7, 0xab, 0x39, 0xbe, 0x7e, 0xa6, 0x8d, 0xaf, 0x5c, 0x6, 0x38, 0x3e, 0xec, 0xfd, 0x53, 0x61, 0x12, 0x71, 0x54, 0x59, 0x8a, 0x1d, 0x7b, 0x77, 0xd6}; + uint8_t bytesprops0[] = {0xbf, 0x38, 0x6d}; + uint8_t bytesprops2[] = {0xe, 0x7e, 0x98, 0xf6, 0xc6, 0xf7, 0xa9, 0x72}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12673}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3493}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17483}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2389}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 33}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31451}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32044}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32478}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops9}, .v = {2, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10581}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1825}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27568}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32649}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12496}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={3, (char*)&bytesprops0}, .v={27, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 28678, topic, msg, props); + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 18294, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\181\165\155@\151\196\153>\212\208\158e;\229\178\rW&", _pubPktID = 28678, _pubBody = -// "\197b\187\ACKO^\130\182\SI\241\185\141\n\187P", _pubProps = [PropReceiveMaximum 12673,PropMaximumPacketSize -// 3493,PropMaximumQoS 123,PropMessageExpiryInterval 17483,PropServerReference -// "\DEL\ESCn6\193\n(\153L6MThmB\NAK{\212\186\244\223\"\135\f\130",PropResponseTopic -// ".\ESCC\CANS\210\173i\158i\248|'!",PropMessageExpiryInterval 2389,PropSubscriptionIdentifier 33,PropServerKeepAlive -// 31451,PropServerReference "\177\ETB\255p\144u\190}\SIx\ETX&c]\198\b\214(\220b\134\172`",PropMaximumQoS -// 23,PropResponseInformation "\194\194\GS",PropMessageExpiryInterval 32044,PropAuthenticationData -// "\184f\226",PropResponseTopic "\142\185\246\137\"\204",PropMaximumPacketSize 32478,PropReasonString -// "d\212\208\206?",PropResponseInformation "\SOH\ACK\234z\206G+s\241\\+x\158\214\199\"",PropCorrelationData -// "\150\247\181\210K\208`\229\174\&1!\167,`",PropUserProperty "\223WA" "\232\148",PropTopicAliasMaximum -// 10581,PropAuthenticationMethod "b\164",PropCorrelationData "\154\223!_\216\254S\209\218\"\210",PropCorrelationData -// "?J\163\161\173q\187\225Z\159"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "2n\201\176\229\EM\245*\ACK\SUB\177\b~\130\155,l", _pubPktID = 18294, _pubBody = "22", _pubProps = [PropTopicAlias 1825,PropServerKeepAlive 27568,PropMaximumPacketSize 32649,PropSessionExpiryInterval 12496,PropUserProperty "\191\&8m" "Zj\183\171\&9\190~\166\141\175\\\ACK8>\236\253Sa\DC2qTY\138\GS{w\214",PropReasonString "\SO~\152\246\198\247\169r"]} TEST(Publish5QCTest, Decode11) { - uint8_t pkt[] = { - 0x32, 0x81, 0x2, 0x0, 0x12, 0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, 0xd0, 0x9e, 0x65, 0x3b, 0xe5, - 0xb2, 0xd, 0x57, 0x26, 0x70, 0x6, 0xda, 0x1, 0x21, 0x31, 0x81, 0x27, 0x0, 0x0, 0xd, 0xa5, 0x24, 0x7b, 0x2, - 0x0, 0x0, 0x44, 0x4b, 0x1c, 0x0, 0x19, 0x7f, 0x1b, 0x6e, 0x36, 0xc1, 0xa, 0x28, 0x99, 0x4c, 0x36, 0x4d, 0x54, - 0x68, 0x6d, 0x42, 0x15, 0x7b, 0xd4, 0xba, 0xf4, 0xdf, 0x22, 0x87, 0xc, 0x82, 0x8, 0x0, 0xe, 0x2e, 0x1b, 0x43, -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wmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb5, 0xa5, 0x9b, 0x40, 0x97, 0xc4, 0x99, 0x3e, 0xd4, - 0xd0, 0x9e, 0x65, 0x3b, 0xe5, 0xb2, 0xd, 0x57, 0x26}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc5, 0x62, 0xbb, 0x6, 0x4f, 0x5e, 0x82, 0xb6, 0xf, 0xf1, 0xb9, 0x8d, 0xa, 0xbb, 0x50}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 28678); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\196x\255\172\&4\CAN?V{\217\182\160\&3\169g\176\192\r\NAK\186s", _pubPktID = 0, _pubBody = "s", _pubProps = -// [PropMessageExpiryInterval 10907,PropAuthenticationMethod -// "\237\198\DC2\v\139Z98\248\172\ESC\176\STX\234\"\180]e\166\159\167Z",PropContentType -// ")\140\227\169\231!v",PropTopicAlias 19767,PropSubscriptionIdentifierAvailable 57,PropServerReference -// "\223\221\190\SUB\156\214\246\t_\190G\216\166\246FM_&\DC2Tf\SYNR\155M\DC3\222Wr",PropMessageExpiryInterval -// 27077,PropSessionExpiryInterval 6103,PropResponseInformation -// "\253\216\170*k\ACK\145\GS\232\187\ESC\136\&2\236\DEL",PropResponseTopic "[",PropResponseTopic -// "\140\176\137\SUBv!lk(\US\178\129\&2\188\149H[\209\219\DC1)"]} -TEST(Publish5QCTest, Encode12) { - uint8_t pkt[] = {0x39, 0x9f, 0x1, 0x0, 0x15, 0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, 0xa0, - 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73, 0x85, 0x1, 0x2, 0x0, 0x0, 0x2a, 0x9b, 0x15, - 0x0, 0x16, 0xed, 0xc6, 0x12, 0xb, 0x8b, 0x5a, 0x39, 0x38, 0xf8, 0xac, 0x1b, 0xb0, 0x2, 0xea, 0x22, - 0xb4, 0x5d, 0x65, 0xa6, 0x9f, 0xa7, 0x5a, 0x3, 0x0, 0x7, 0x29, 0x8c, 0xe3, 0xa9, 0xe7, 0x21, 0x76, - 0x23, 0x4d, 0x37, 0x29, 0x39, 0x1c, 0x0, 0x1d, 0xdf, 0xdd, 0xbe, 0x1a, 0x9c, 0xd6, 0xf6, 0x9, 0x5f, - 0xbe, 0x47, 0xd8, 0xa6, 0xf6, 0x46, 0x4d, 0x5f, 0x26, 0x12, 0x54, 0x66, 0x16, 0x52, 0x9b, 0x4d, 0x13, - 0xde, 0x57, 0x72, 0x2, 0x0, 0x0, 0x69, 0xc5, 0x11, 0x0, 0x0, 0x17, 0xd7, 0x1a, 0x0, 0xf, 0xfd, - 0xd8, 0xaa, 0x2a, 0x6b, 0x6, 0x91, 0x1d, 0xe8, 0xbb, 0x1b, 0x88, 0x32, 0xec, 0x7f, 0x8, 0x0, 0x1, - 0x5b, 0x8, 0x0, 0x15, 0x8c, 0xb0, 0x89, 0x1a, 0x76, 0x21, 0x6c, 0x6b, 0x28, 0x1f, 0xb2, 0x81, 0x32, - 0xbc, 0x95, 0x48, 0x5b, 0xd1, 0xdb, 0x11, 0x29, 0x73}; - uint8_t topic_bytes[] = {0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, - 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; +uint8_t pkt[] = {0x33, 0x56, 0x0, 0x11, 0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c, 0x47, 0x76, 0x3e, 0x23, 0x7, 0x21, 0x13, 0x6b, 0xb0, 0x27, 0x0, 0x0, 0x7f, 0x89, 0x11, 0x0, 0x0, 0x30, 0xd0, 0x26, 0x0, 0x3, 0xbf, 0x38, 0x6d, 0x0, 0x1b, 0x5a, 0x6a, 0xb7, 0xab, 0x39, 0xbe, 0x7e, 0xa6, 0x8d, 0xaf, 0x5c, 0x6, 0x38, 0x3e, 0xec, 0xfd, 0x53, 0x61, 0x12, 0x71, 0x54, 0x59, 0x8a, 0x1d, 0x7b, 0x77, 0xd6, 0x1f, 0x0, 0x8, 0xe, 0x7e, 0x98, 0xf6, 0xc6, 0xf7, 0xa9, 0x72, 0x32, 0x32}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c}; + lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x32, 0x32}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 18294); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); +EXPECT_EQ(msg.payload_len, 2); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x73}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; - - uint8_t bytesprops0[] = {0xed, 0xc6, 0x12, 0xb, 0x8b, 0x5a, 0x39, 0x38, 0xf8, 0xac, 0x1b, - 0xb0, 0x2, 0xea, 0x22, 0xb4, 0x5d, 0x65, 0xa6, 0x9f, 0xa7, 0x5a}; - uint8_t bytesprops1[] = {0x29, 0x8c, 0xe3, 0xa9, 0xe7, 0x21, 0x76}; - uint8_t bytesprops2[] = {0xdf, 0xdd, 0xbe, 0x1a, 0x9c, 0xd6, 0xf6, 0x9, 0x5f, 0xbe, 0x47, 0xd8, 0xa6, 0xf6, 0x46, - 0x4d, 0x5f, 0x26, 0x12, 0x54, 0x66, 0x16, 0x52, 0x9b, 0x4d, 0x13, 0xde, 0x57, 0x72}; - uint8_t bytesprops3[] = {0xfd, 0xd8, 0xaa, 0x2a, 0x6b, 0x6, 0x91, 0x1d, 0xe8, 0xbb, 0x1b, 0x88, 0x32, 0xec, 0x7f}; - uint8_t bytesprops4[] = {0x5b}; - uint8_t bytesprops5[] = {0x8c, 0xb0, 0x89, 0x1a, 0x76, 0x21, 0x6c, 0x6b, 0x28, 0x1f, 0xb2, - 0x81, 0x32, 0xbc, 0x95, 0x48, 0x5b, 0xd1, 0xdb, 0x11, 0x29}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\SI\221\168J\184\157\208vn\224\GS", _pubPktID = 19130, _pubBody = "=m\162\166\ETX\DEL\SI?\155\155\229\193\RS\194\ETX^\144\196\"\134\199\t\254\147\&1\ESC\221\132", _pubProps = [PropMessageExpiryInterval 10784,PropMaximumPacketSize 27458,PropAssignedClientIdentifier "G$v\235\218\"\220",PropAuthenticationMethod "\133",PropMaximumQoS 124,PropAssignedClientIdentifier "\228\220\169\131\254^\178\229\DC3\141\ESC\188NjB",PropReceiveMaximum 15546,PropSubscriptionIdentifierAvailable 23,PropWillDelayInterval 22707,PropWildcardSubscriptionAvailable 210,PropAssignedClientIdentifier "D3\203.C~\144\185r\v\ESC\211\151|\202\134\199y\b\213\US\135\190",PropAuthenticationMethod "\ETB;\223\&4\n\\M\ESC\188\132",PropAuthenticationData "\158U]a\252o\250\153\140\174\208ZV\205\SYNTw\149",PropMessageExpiryInterval 13702,PropSubscriptionIdentifier 27,PropPayloadFormatIndicator 144,PropWillDelayInterval 18493,PropServerReference "\US=r\ENQZ\174m\240\v%\SYN\186\207\135K",PropTopicAlias 14505,PropSharedSubscriptionAvailable 82,PropReceiveMaximum 19530,PropRequestProblemInformation 56,PropAuthenticationMethod "\150N\SO\230\134$\141\238\132\203P\noE\185YC+\NAKt\SO\158\245\242%X\156h\161\CAN",PropResponseTopic "!t\195\255Ea\140\248\250i\ESCmu\181\195.\241\n\v\147\211\177LtW\162",PropAuthenticationData "\164B\248,\195\GSB\225\242\SI\SO\172\251\220W3J\US\250\161\216\241\212V\223B\218XA",PropAuthenticationMethod "\232\213\&8\166x\STX4\171",PropResponseInformation "\215",PropAuthenticationData "*\170]\135\238\156\238\162\229\213\247\DC1\234G\r\182\200@\207o'",PropResponseInformation "w\SO.\186a\218\208\221*"]} +TEST(Publish5QCTest, Encode12) { +uint8_t pkt[] = {0x3c, 0xdc, 0x2, 0x0, 0xb, 0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d, 0x4a, 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9c, 0x68, 0xa1, 0x18, 0x8, 0x0, 0x1a, 0x21, 0x74, 0xc3, 0xff, 0x45, 0x61, 0x8c, 0xf8, 0xfa, 0x69, 0x1b, 0x6d, 0x75, 0xb5, 0xc3, 0x2e, 0xf1, 0xa, 0xb, 0x93, 0xd3, 0xb1, 0x4c, 0x74, 0x57, 0xa2, 0x16, 0x0, 0x1d, 0xa4, 0x42, 0xf8, 0x2c, 0xc3, 0x1d, 0x42, 0xe1, 0xf2, 0xf, 0xe, 0xac, 0xfb, 0xdc, 0x57, 0x33, 0x4a, 0x1f, 0xfa, 0xa1, 0xd8, 0xf1, 0xd4, 0x56, 0xdf, 0x42, 0xda, 0x58, 0x41, 0x15, 0x0, 0x8, 0xe8, 0xd5, 0x38, 0xa6, 0x78, 0x2, 0x34, 0xab, 0x1a, 0x0, 0x1, 0xd7, 0x16, 0x0, 0x15, 0x2a, 0xaa, 0x5d, 0x87, 0xee, 0x9c, 0xee, 0xa2, 0xe5, 0xd5, 0xf7, 0x11, 0xea, 0x47, 0xd, 0xb6, 0xc8, 0x40, 0xcf, 0x6f, 0x27, 0x1a, 0x0, 0x9, 0x77, 0xe, 0x2e, 0xba, 0x61, 0xda, 0xd0, 0xdd, 0x2a, 0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; + uint8_t topic_bytes[] = {0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = false; +uint8_t msg_bytes[] = {0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 28; + + uint8_t bytesprops0[] = {0x47, 0x24, 0x76, 0xeb, 0xda, 0x22, 0xdc}; + uint8_t bytesprops1[] = {0x85}; + uint8_t bytesprops2[] = {0xe4, 0xdc, 0xa9, 0x83, 0xfe, 0x5e, 0xb2, 0xe5, 0x13, 0x8d, 0x1b, 0xbc, 0x4e, 0x6a, 0x42}; + uint8_t bytesprops3[] = {0x44, 0x33, 0xcb, 0x2e, 0x43, 0x7e, 0x90, 0xb9, 0x72, 0xb, 0x1b, 0xd3, 0x97, 0x7c, 0xca, 0x86, 0xc7, 0x79, 0x8, 0xd5, 0x1f, 0x87, 0xbe}; + uint8_t bytesprops4[] = {0x17, 0x3b, 0xdf, 0x34, 0xa, 0x5c, 0x4d, 0x1b, 0xbc, 0x84}; + uint8_t bytesprops5[] = {0x9e, 0x55, 0x5d, 0x61, 0xfc, 0x6f, 0xfa, 0x99, 0x8c, 0xae, 0xd0, 0x5a, 0x56, 0xcd, 0x16, 0x54, 0x77, 0x95}; + uint8_t bytesprops6[] = {0x1f, 0x3d, 0x72, 0x5, 0x5a, 0xae, 0x6d, 0xf0, 0xb, 0x25, 0x16, 0xba, 0xcf, 0x87, 0x4b}; + uint8_t bytesprops7[] = {0x96, 0x4e, 0xe, 0xe6, 0x86, 0x24, 0x8d, 0xee, 0x84, 0xcb, 0x50, 0xa, 0x6f, 0x45, 0xb9, 0x59, 0x43, 0x2b, 0x15, 0x74, 0xe, 0x9e, 0xf5, 0xf2, 0x25, 0x58, 0x9c, 0x68, 0xa1, 0x18}; + uint8_t bytesprops8[] = {0x21, 0x74, 0xc3, 0xff, 0x45, 0x61, 0x8c, 0xf8, 0xfa, 0x69, 0x1b, 0x6d, 0x75, 0xb5, 0xc3, 0x2e, 0xf1, 0xa, 0xb, 0x93, 0xd3, 0xb1, 0x4c, 0x74, 0x57, 0xa2}; + uint8_t bytesprops9[] = {0xa4, 0x42, 0xf8, 0x2c, 0xc3, 0x1d, 0x42, 0xe1, 0xf2, 0xf, 0xe, 0xac, 0xfb, 0xdc, 0x57, 0x33, 0x4a, 0x1f, 0xfa, 0xa1, 0xd8, 0xf1, 0xd4, 0x56, 0xdf, 0x42, 0xda, 0x58, 0x41}; + uint8_t bytesprops10[] = {0xe8, 0xd5, 0x38, 0xa6, 0x78, 0x2, 0x34, 0xab}; + uint8_t bytesprops11[] = {0xd7}; + uint8_t bytesprops12[] = {0x2a, 0xaa, 0x5d, 0x87, 0xee, 0x9c, 0xee, 0xa2, 0xe5, 0xd5, 0xf7, 0x11, 0xea, 0x47, 0xd, 0xb6, 0xc8, 0x40, 0xcf, 0x6f, 0x27}; + uint8_t bytesprops13[] = {0x77, 0xe, 0x2e, 0xba, 0x61, 0xda, 0xd0, 0xdd, 0x2a}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10907}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19767}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27077}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6103}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10784}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27458}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15546}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22707}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13702}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18493}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14505}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19530}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops13}}}, + }; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 19130, topic, msg, props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\196x\255\172\&4\CAN?V{\217\182\160\&3\169g\176\192\r\NAK\186s", _pubPktID = 0, _pubBody = "s", _pubProps = -// [PropMessageExpiryInterval 10907,PropAuthenticationMethod -// "\237\198\DC2\v\139Z98\248\172\ESC\176\STX\234\"\180]e\166\159\167Z",PropContentType -// ")\140\227\169\231!v",PropTopicAlias 19767,PropSubscriptionIdentifierAvailable 57,PropServerReference -// "\223\221\190\SUB\156\214\246\t_\190G\216\166\246FM_&\DC2Tf\SYNR\155M\DC3\222Wr",PropMessageExpiryInterval -// 27077,PropSessionExpiryInterval 6103,PropResponseInformation -// "\253\216\170*k\ACK\145\GS\232\187\ESC\136\&2\236\DEL",PropResponseTopic "[",PropResponseTopic -// "\140\176\137\SUBv!lk(\US\178\129\&2\188\149H[\209\219\DC1)"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\SI\221\168J\184\157\208vn\224\GS", _pubPktID = 19130, _pubBody = "=m\162\166\ETX\DEL\SI?\155\155\229\193\RS\194\ETX^\144\196\"\134\199\t\254\147\&1\ESC\221\132", _pubProps = [PropMessageExpiryInterval 10784,PropMaximumPacketSize 27458,PropAssignedClientIdentifier "G$v\235\218\"\220",PropAuthenticationMethod "\133",PropMaximumQoS 124,PropAssignedClientIdentifier "\228\220\169\131\254^\178\229\DC3\141\ESC\188NjB",PropReceiveMaximum 15546,PropSubscriptionIdentifierAvailable 23,PropWillDelayInterval 22707,PropWildcardSubscriptionAvailable 210,PropAssignedClientIdentifier "D3\203.C~\144\185r\v\ESC\211\151|\202\134\199y\b\213\US\135\190",PropAuthenticationMethod "\ETB;\223\&4\n\\M\ESC\188\132",PropAuthenticationData "\158U]a\252o\250\153\140\174\208ZV\205\SYNTw\149",PropMessageExpiryInterval 13702,PropSubscriptionIdentifier 27,PropPayloadFormatIndicator 144,PropWillDelayInterval 18493,PropServerReference "\US=r\ENQZ\174m\240\v%\SYN\186\207\135K",PropTopicAlias 14505,PropSharedSubscriptionAvailable 82,PropReceiveMaximum 19530,PropRequestProblemInformation 56,PropAuthenticationMethod "\150N\SO\230\134$\141\238\132\203P\noE\185YC+\NAKt\SO\158\245\242%X\156h\161\CAN",PropResponseTopic "!t\195\255Ea\140\248\250i\ESCmu\181\195.\241\n\v\147\211\177LtW\162",PropAuthenticationData "\164B\248,\195\GSB\225\242\SI\SO\172\251\220W3J\US\250\161\216\241\212V\223B\218XA",PropAuthenticationMethod "\232\213\&8\166x\STX4\171",PropResponseInformation "\215",PropAuthenticationData "*\170]\135\238\156\238\162\229\213\247\DC1\234G\r\182\200@\207o'",PropResponseInformation "w\SO.\186a\218\208\221*"]} TEST(Publish5QCTest, Decode12) { - uint8_t pkt[] = {0x39, 0x9f, 0x1, 0x0, 0x15, 0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, 0xa0, - 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73, 0x85, 0x1, 0x2, 0x0, 0x0, 0x2a, 0x9b, 0x15, - 0x0, 0x16, 0xed, 0xc6, 0x12, 0xb, 0x8b, 0x5a, 0x39, 0x38, 0xf8, 0xac, 0x1b, 0xb0, 0x2, 0xea, 0x22, - 0xb4, 0x5d, 0x65, 0xa6, 0x9f, 0xa7, 0x5a, 0x3, 0x0, 0x7, 0x29, 0x8c, 0xe3, 0xa9, 0xe7, 0x21, 0x76, - 0x23, 0x4d, 0x37, 0x29, 0x39, 0x1c, 0x0, 0x1d, 0xdf, 0xdd, 0xbe, 0x1a, 0x9c, 0xd6, 0xf6, 0x9, 0x5f, - 0xbe, 0x47, 0xd8, 0xa6, 0xf6, 0x46, 0x4d, 0x5f, 0x26, 0x12, 0x54, 0x66, 0x16, 0x52, 0x9b, 0x4d, 0x13, - 0xde, 0x57, 0x72, 0x2, 0x0, 0x0, 0x69, 0xc5, 0x11, 0x0, 0x0, 0x17, 0xd7, 0x1a, 0x0, 0xf, 0xfd, - 0xd8, 0xaa, 0x2a, 0x6b, 0x6, 0x91, 0x1d, 0xe8, 0xbb, 0x1b, 0x88, 0x32, 0xec, 0x7f, 0x8, 0x0, 0x1, - 0x5b, 0x8, 0x0, 0x15, 0x8c, 0xb0, 0x89, 0x1a, 0x76, 0x21, 0x6c, 0x6b, 0x28, 0x1f, 0xb2, 0x81, 0x32, - 0xbc, 0x95, 0x48, 0x5b, 0xd1, 0xdb, 0x11, 0x29, 0x73}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc4, 0x78, 0xff, 0xac, 0x34, 0x18, 0x3f, 0x56, 0x7b, 0xd9, 0xb6, - 0xa0, 0x33, 0xa9, 0x67, 0xb0, 0xc0, 0xd, 0x15, 0xba, 0x73}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x73}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\136@e", _pubPktID = 1120, _pubBody -// = "U\146=\184\GS9[\230\210\180\157\ENQ\204\240\DC36\FSl0\136\172^\RSr4t7\193\178", _pubProps = [PropContentType -// "'\184m\204oOr",PropReceiveMaximum 29088,PropRequestProblemInformation 86,PropWildcardSubscriptionAvailable -// 125,PropCorrelationData "oW\220W\SUB%F\225\DC3\233\161\&6K\216`\216\FS\252\ENQ\253\216",PropCorrelationData -// ",?\185\148\172",PropReceiveMaximum 32523,PropResponseInformation -// "\233\152M\171Xg\DEL\141",PropPayloadFormatIndicator 86,PropResponseInformation -// "\183\156\197V\223w\US\228\190r@\FS$\189G\167.0^w\213\t\GSoX%",PropRetainAvailable 77,PropPayloadFormatIndicator -// 118,PropSubscriptionIdentifierAvailable 247,PropSubscriptionIdentifier 16]} +uint8_t pkt[] = {0x3c, 0xdc, 0x2, 0x0, 0xb, 0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d, 0x4a, 0xba, 0xaf, 0x2, 0x2, 0x0, 0x0, 0x2a, 0x20, 0x27, 0x0, 0x0, 0x6b, 0x42, 0x12, 0x0, 0x7, 0x47, 0x24, 0x76, 0xeb, 0xda, 0x22, 0xdc, 0x15, 0x0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1, 0xa, 0xb, 0x93, 0xd3, 0xb1, 0x4c, 0x74, 0x57, 0xa2, 0x16, 0x0, 0x1d, 0xa4, 0x42, 0xf8, 0x2c, 0xc3, 0x1d, 0x42, 0xe1, 0xf2, 0xf, 0xe, 0xac, 0xfb, 0xdc, 0x57, 0x33, 0x4a, 0x1f, 0xfa, 0xa1, 0xd8, 0xf1, 0xd4, 0x56, 0xdf, 0x42, 0xda, 0x58, 0x41, 0x15, 0x0, 0x8, 0xe8, 0xd5, 0x38, 0xa6, 0x78, 0x2, 0x34, 0xab, 0x1a, 0x0, 0x1, 0xd7, 0x16, 0x0, 0x15, 0x2a, 0xaa, 0x5d, 0x87, 0xee, 0x9c, 0xee, 0xa2, 0xe5, 0xd5, 0xf7, 0x11, 0xea, 0x47, 0xd, 0xb6, 0xc8, 0x40, 0xcf, 0x6f, 0x27, 0x1a, 0x0, 0x9, 0x77, 0xe, 0x2e, 0xba, 0x61, 0xda, 0xd0, 0xdd, 0x2a, 0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 19130); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); +EXPECT_EQ(msg.payload_len, 28); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\n\159\143\162\210", _pubPktID = 3591, _pubBody = "\156|7\ETB|\195\202\&4y", _pubProps = [PropTopicAlias 16866,PropPayloadFormatIndicator 161,PropWillDelayInterval 10125,PropTopicAliasMaximum 9943,PropAssignedClientIdentifier "\166}b\131\251\SI\238\142;\227K\136T\135V\247\161",PropUserProperty "" "\US&\214kE\128q\201\193`7",PropSubscriptionIdentifier 14,PropServerReference "\STXg4\v~\SYN",PropContentType "\180\GS\161\&3\158\249",PropContentType "s+\137|8\r'&\231D=7\234F\240UP\250Q\249\223xm",PropSharedSubscriptionAvailable 120,PropRetainAvailable 148,PropReceiveMaximum 21370,PropReceiveMaximum 15880,PropCorrelationData "\SYN\145\218\133",PropMaximumQoS 249,PropRetainAvailable 68,PropServerReference "\214\163?X\208\137\tL\204\249\150\193\138C\US\223\167\247\232=",PropWildcardSubscriptionAvailable 42,PropMessageExpiryInterval 15417,PropCorrelationData "\234\150\202\&8\208(\204\142&\190$|\SYNgY@\221\162\164",PropTopicAliasMaximum 15741,PropContentType "Yvww",PropSessionExpiryInterval 32202,PropPayloadFormatIndicator 229,PropResponseInformation "\164"]} TEST(Publish5QCTest, Encode13) { - uint8_t pkt[] = {0x35, 0x8b, 0x1, 0x0, 0x3, 0x88, 0x40, 0x65, 0x4, 0x60, 0x66, 0x3, 0x0, 0x7, 0x27, 0xb8, - 0x6d, 0xcc, 0x6f, 0x4f, 0x72, 0x21, 0x71, 0xa0, 0x17, 0x56, 0x28, 0x7d, 0x9, 0x0, 0x15, 0x6f, - 0x57, 0xdc, 0x57, 0x1a, 0x25, 0x46, 0xe1, 0x13, 0xe9, 0xa1, 0x36, 0x4b, 0xd8, 0x60, 0xd8, 0x1c, - 0xfc, 0x5, 0xfd, 0xd8, 0x9, 0x0, 0x5, 0x2c, 0x3f, 0xb9, 0x94, 0xac, 0x21, 0x7f, 0xb, 0x1a, - 0x0, 0x8, 0xe9, 0x98, 0x4d, 0xab, 0x58, 0x67, 0x7f, 0x8d, 0x1, 0x56, 0x1a, 0x0, 0x1a, 0xb7, - 0x9c, 0xc5, 0x56, 0xdf, 0x77, 0x1f, 0xe4, 0xbe, 0x72, 0x40, 0x1c, 0x24, 0xbd, 0x47, 0xa7, 0x2e, - 0x30, 0x5e, 0x77, 0xd5, 0x9, 0x1d, 0x6f, 0x58, 0x25, 0x25, 0x4d, 0x1, 0x76, 0x29, 0xf7, 0xb, - 0x10, 0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, - 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; - uint8_t topic_bytes[] = {0x88, 0x40, 0x65}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; +uint8_t pkt[] = {0x32, 0xd1, 0x1, 0x0, 0x5, 0xa, 0x9f, 0x8f, 0xa2, 0xd2, 0xe, 0x7, 0xbd, 0x1, 0x23, 0x41, 0xe2, 0x1, 0xa1, 0x18, 0x0, 0x0, 0x27, 0x8d, 0x22, 0x26, 0xd7, 0x12, 0x0, 0x11, 0xa6, 0x7d, 0x62, 0x83, 0xfb, 0xf, 0xee, 0x8e, 0x3b, 0xe3, 0x4b, 0x88, 0x54, 0x87, 0x56, 0xf7, 0xa1, 0x26, 0x0, 0x0, 0x0, 0xb, 0x1f, 0x26, 0xd6, 0x6b, 0x45, 0x80, 0x71, 0xc9, 0xc1, 0x60, 0x37, 0xb, 0xe, 0x1c, 0x0, 0x6, 0x2, 0x67, 0x34, 0xb, 0x7e, 0x16, 0x3, 0x0, 0x6, 0xb4, 0x1d, 0xa1, 0x33, 0x9e, 0xf9, 0x3, 0x0, 0x17, 0x73, 0x2b, 0x89, 0x7c, 0x38, 0xd, 0x27, 0x26, 0xe7, 0x44, 0x3d, 0x37, 0xea, 0x46, 0xf0, 0x55, 0x50, 0xfa, 0x51, 0xf9, 0xdf, 0x78, 0x6d, 0x2a, 0x78, 0x25, 0x94, 0x21, 0x53, 0x7a, 0x21, 0x3e, 0x8, 0x9, 0x0, 0x4, 0x16, 0x91, 0xda, 0x85, 0x24, 0xf9, 0x25, 0x44, 0x1c, 0x0, 0x14, 0xd6, 0xa3, 0x3f, 0x58, 0xd0, 0x89, 0x9, 0x4c, 0xcc, 0xf9, 0x96, 0xc1, 0x8a, 0x43, 0x1f, 0xdf, 0xa7, 0xf7, 0xe8, 0x3d, 0x28, 0x2a, 0x2, 0x0, 0x0, 0x3c, 0x39, 0x9, 0x0, 0x13, 0xea, 0x96, 0xca, 0x38, 0xd0, 0x28, 0xcc, 0x8e, 0x26, 0xbe, 0x24, 0x7c, 0x16, 0x67, 0x59, 0x40, 0xdd, 0xa2, 0xa4, 0x22, 0x3d, 0x7d, 0x3, 0x0, 0x4, 0x59, 0x76, 0x77, 0x77, 0x11, 0x0, 0x0, 0x7d, 0xca, 0x1, 0xe5, 0x1a, 0x0, 0x1, 0xa4, 0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; + uint8_t topic_bytes[] = {0xa, 0x9f, 0x8f, 0xa2, 0xd2}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, - 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; - - uint8_t bytesprops0[] = {0x27, 0xb8, 0x6d, 0xcc, 0x6f, 0x4f, 0x72}; - uint8_t bytesprops1[] = {0x6f, 0x57, 0xdc, 0x57, 0x1a, 0x25, 0x46, 0xe1, 0x13, 0xe9, 0xa1, - 0x36, 0x4b, 0xd8, 0x60, 0xd8, 0x1c, 0xfc, 0x5, 0xfd, 0xd8}; - uint8_t bytesprops2[] = {0x2c, 0x3f, 0xb9, 0x94, 0xac}; - uint8_t bytesprops3[] = {0xe9, 0x98, 0x4d, 0xab, 0x58, 0x67, 0x7f, 0x8d}; - uint8_t bytesprops4[] = {0xb7, 0x9c, 0xc5, 0x56, 0xdf, 0x77, 0x1f, 0xe4, 0xbe, 0x72, 0x40, 0x1c, 0x24, - 0xbd, 0x47, 0xa7, 0x2e, 0x30, 0x5e, 0x77, 0xd5, 0x9, 0x1d, 0x6f, 0x58, 0x25}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = false; +uint8_t msg_bytes[] = {0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 9; + uint8_t bytesprops0[] = {0xa6, 0x7d, 0x62, 0x83, 0xfb, 0xf, 0xee, 0x8e, 0x3b, 0xe3, 0x4b, 0x88, 0x54, 0x87, 0x56, 0xf7, 0xa1}; + uint8_t bytesprops2[] = {0x1f, 0x26, 0xd6, 0x6b, 0x45, 0x80, 0x71, 0xc9, 0xc1, 0x60, 0x37}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops3[] = {0x2, 0x67, 0x34, 0xb, 0x7e, 0x16}; + uint8_t bytesprops4[] = {0xb4, 0x1d, 0xa1, 0x33, 0x9e, 0xf9}; + uint8_t bytesprops5[] = {0x73, 0x2b, 0x89, 0x7c, 0x38, 0xd, 0x27, 0x26, 0xe7, 0x44, 0x3d, 0x37, 0xea, 0x46, 0xf0, 0x55, 0x50, 0xfa, 0x51, 0xf9, 0xdf, 0x78, 0x6d}; + uint8_t bytesprops6[] = {0x16, 0x91, 0xda, 0x85}; + uint8_t bytesprops7[] = {0xd6, 0xa3, 0x3f, 0x58, 0xd0, 0x89, 0x9, 0x4c, 0xcc, 0xf9, 0x96, 0xc1, 0x8a, 0x43, 0x1f, 0xdf, 0xa7, 0xf7, 0xe8, 0x3d}; + uint8_t bytesprops8[] = {0xea, 0x96, 0xca, 0x38, 0xd0, 0x28, 0xcc, 0x8e, 0x26, 0xbe, 0x24, 0x7c, 0x16, 0x67, 0x59, 0x40, 0xdd, 0xa2, 0xa4}; + uint8_t bytesprops9[] = {0x59, 0x76, 0x77, 0x77}; + uint8_t bytesprops10[] = {0xa4}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29088}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32523}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16866}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10125}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9943}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={0, (char*)&bytesprops1}, .v={11, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21370}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15880}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15417}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15741}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32202}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1120, topic, msg, props); + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 3591, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\136@e", _pubPktID = 1120, _pubBody -// = "U\146=\184\GS9[\230\210\180\157\ENQ\204\240\DC36\FSl0\136\172^\RSr4t7\193\178", _pubProps = [PropContentType -// "'\184m\204oOr",PropReceiveMaximum 29088,PropRequestProblemInformation 86,PropWildcardSubscriptionAvailable -// 125,PropCorrelationData "oW\220W\SUB%F\225\DC3\233\161\&6K\216`\216\FS\252\ENQ\253\216",PropCorrelationData -// ",?\185\148\172",PropReceiveMaximum 32523,PropResponseInformation -// "\233\152M\171Xg\DEL\141",PropPayloadFormatIndicator 86,PropResponseInformation -// "\183\156\197V\223w\US\228\190r@\FS$\189G\167.0^w\213\t\GSoX%",PropRetainAvailable 77,PropPayloadFormatIndicator -// 118,PropSubscriptionIdentifierAvailable 247,PropSubscriptionIdentifier 16]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\n\159\143\162\210", _pubPktID = 3591, _pubBody = "\156|7\ETB|\195\202\&4y", _pubProps = [PropTopicAlias 16866,PropPayloadFormatIndicator 161,PropWillDelayInterval 10125,PropTopicAliasMaximum 9943,PropAssignedClientIdentifier "\166}b\131\251\SI\238\142;\227K\136T\135V\247\161",PropUserProperty "" "\US&\214kE\128q\201\193`7",PropSubscriptionIdentifier 14,PropServerReference "\STXg4\v~\SYN",PropContentType "\180\GS\161\&3\158\249",PropContentType "s+\137|8\r'&\231D=7\234F\240UP\250Q\249\223xm",PropSharedSubscriptionAvailable 120,PropRetainAvailable 148,PropReceiveMaximum 21370,PropReceiveMaximum 15880,PropCorrelationData "\SYN\145\218\133",PropMaximumQoS 249,PropRetainAvailable 68,PropServerReference "\214\163?X\208\137\tL\204\249\150\193\138C\US\223\167\247\232=",PropWildcardSubscriptionAvailable 42,PropMessageExpiryInterval 15417,PropCorrelationData "\234\150\202\&8\208(\204\142&\190$|\SYNgY@\221\162\164",PropTopicAliasMaximum 15741,PropContentType "Yvww",PropSessionExpiryInterval 32202,PropPayloadFormatIndicator 229,PropResponseInformation "\164"]} TEST(Publish5QCTest, Decode13) { - uint8_t pkt[] = {0x35, 0x8b, 0x1, 0x0, 0x3, 0x88, 0x40, 0x65, 0x4, 0x60, 0x66, 0x3, 0x0, 0x7, 0x27, 0xb8, - 0x6d, 0xcc, 0x6f, 0x4f, 0x72, 0x21, 0x71, 0xa0, 0x17, 0x56, 0x28, 0x7d, 0x9, 0x0, 0x15, 0x6f, - 0x57, 0xdc, 0x57, 0x1a, 0x25, 0x46, 0xe1, 0x13, 0xe9, 0xa1, 0x36, 0x4b, 0xd8, 0x60, 0xd8, 0x1c, - 0xfc, 0x5, 0xfd, 0xd8, 0x9, 0x0, 0x5, 0x2c, 0x3f, 0xb9, 0x94, 0xac, 0x21, 0x7f, 0xb, 0x1a, - 0x0, 0x8, 0xe9, 0x98, 0x4d, 0xab, 0x58, 0x67, 0x7f, 0x8d, 0x1, 0x56, 0x1a, 0x0, 0x1a, 0xb7, - 0x9c, 0xc5, 0x56, 0xdf, 0x77, 0x1f, 0xe4, 0xbe, 0x72, 0x40, 0x1c, 0x24, 0xbd, 0x47, 0xa7, 0x2e, - 0x30, 0x5e, 0x77, 0xd5, 0x9, 0x1d, 0x6f, 0x58, 0x25, 0x25, 0x4d, 0x1, 0x76, 0x29, 0xf7, 0xb, - 0x10, 0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, - 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x32, 0xd1, 0x1, 0x0, 0x5, 0xa, 0x9f, 0x8f, 0xa2, 0xd2, 0xe, 0x7, 0xbd, 0x1, 0x23, 0x41, 0xe2, 0x1, 0xa1, 0x18, 0x0, 0x0, 0x27, 0x8d, 0x22, 0x26, 0xd7, 0x12, 0x0, 0x11, 0xa6, 0x7d, 0x62, 0x83, 0xfb, 0xf, 0xee, 0x8e, 0x3b, 0xe3, 0x4b, 0x88, 0x54, 0x87, 0x56, 0xf7, 0xa1, 0x26, 0x0, 0x0, 0x0, 0xb, 0x1f, 0x26, 0xd6, 0x6b, 0x45, 0x80, 0x71, 0xc9, 0xc1, 0x60, 0x37, 0xb, 0xe, 0x1c, 0x0, 0x6, 0x2, 0x67, 0x34, 0xb, 0x7e, 0x16, 0x3, 0x0, 0x6, 0xb4, 0x1d, 0xa1, 0x33, 0x9e, 0xf9, 0x3, 0x0, 0x17, 0x73, 0x2b, 0x89, 0x7c, 0x38, 0xd, 0x27, 0x26, 0xe7, 0x44, 0x3d, 0x37, 0xea, 0x46, 0xf0, 0x55, 0x50, 0xfa, 0x51, 0xf9, 0xdf, 0x78, 0x6d, 0x2a, 0x78, 0x25, 0x94, 0x21, 0x53, 0x7a, 0x21, 0x3e, 0x8, 0x9, 0x0, 0x4, 0x16, 0x91, 0xda, 0x85, 0x24, 0xf9, 0x25, 0x44, 0x1c, 0x0, 0x14, 0xd6, 0xa3, 0x3f, 0x58, 0xd0, 0x89, 0x9, 0x4c, 0xcc, 0xf9, 0x96, 0xc1, 0x8a, 0x43, 0x1f, 0xdf, 0xa7, 0xf7, 0xe8, 0x3d, 0x28, 0x2a, 0x2, 0x0, 0x0, 0x3c, 0x39, 0x9, 0x0, 0x13, 0xea, 0x96, 0xca, 0x38, 0xd0, 0x28, 0xcc, 0x8e, 0x26, 0xbe, 0x24, 0x7c, 0x16, 0x67, 0x59, 0x40, 0xdd, 0xa2, 0xa4, 0x22, 0x3d, 0x7d, 0x3, 0x0, 0x4, 0x59, 0x76, 0x77, 0x77, 0x11, 0x0, 0x0, 0x7d, 0xca, 0x1, 0xe5, 0x1a, 0x0, 0x1, 0xa4, 0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xa, 0x9f, 0x8f, 0xa2, 0xd2}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 3591); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); +EXPECT_EQ(msg.payload_len, 9); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x88, 0x40, 0x65}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x55, 0x92, 0x3d, 0xb8, 0x1d, 0x39, 0x5b, 0xe6, 0xd2, 0xb4, 0x9d, 0x5, 0xcc, 0xf0, 0x13, - 0x36, 0x1c, 0x6c, 0x30, 0x88, 0xac, 0x5e, 0x1e, 0x72, 0x34, 0x74, 0x37, 0xc1, 0xb2}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 1120); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\156\129\b\202\ETB\"y\195\204\150S\DLE\231\CANg\207\&0\n\246~U\196\194\&5", _pubPktID = 17194, _pubBody = -// "\158\237", _pubProps = [PropPayloadFormatIndicator 191,PropRequestProblemInformation -// 232,PropSubscriptionIdentifierAvailable 54,PropTopicAliasMaximum 1708,PropWildcardSubscriptionAvailable -// 116,PropAuthenticationData "o'\133\177\235t@\149A+\233\140\SOH",PropMessageExpiryInterval 5729,PropTopicAliasMaximum -// 16831,PropAuthenticationData -// "\200\SO\250\&6\144\192yG\211\STX\139\253\175\DC2\157\139\SUB\RS6\178\249\n'\186\206O\STX\b",PropRetainAvailable -// 38,PropTopicAlias 27395,PropMaximumQoS 187,PropPayloadFormatIndicator 196,PropMessageExpiryInterval -// 6396,PropServerKeepAlive 21502,PropRequestProblemInformation 199,PropWildcardSubscriptionAvailable -// 159,PropReceiveMaximum 21944,PropWillDelayInterval 24951,PropMaximumQoS 95,PropMessageExpiryInterval -// 9751,PropMaximumPacketSize 10710,PropRetainAvailable 207,PropSubscriptionIdentifierAvailable -// 106,PropSharedSubscriptionAvailable 187,PropServerReference "\139\211\238\132",PropCorrelationData -// "\SYN;\218\247|\212\231\156\bV\199z#5\223;\170H\189\220\174\224\GS8\250\206z\240",PropRetainAvailable -// 191,PropAuthenticationData -// "Z\SI\b&\163\ACKr0\208\150\188\EMV\FS\138\185r\227\229j",PropSubscriptionIdentifierAvailable 136]} -TEST(Publish5QCTest, Encode14) { - uint8_t pkt[] = {0x33, 0xd2, 0x1, 0x0, 0x18, 0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, - 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35, 0x43, 0x2a, 0xb2, 0x1, 0x1, - 0xbf, 0x17, 0xe8, 0x29, 0x36, 0x22, 0x6, 0xac, 0x28, 0x74, 0x16, 0x0, 0xd, 0x6f, 0x27, 0x85, 0xb1, - 0xeb, 0x74, 0x40, 0x95, 0x41, 0x2b, 0xe9, 0x8c, 0x1, 0x2, 0x0, 0x0, 0x16, 0x61, 0x22, 0x41, 0xbf, - 0x16, 0x0, 0x1c, 0xc8, 0xe, 0xfa, 0x36, 0x90, 0xc0, 0x79, 0x47, 0xd3, 0x2, 0x8b, 0xfd, 0xaf, 0x12, - 0x9d, 0x8b, 0x1a, 0x1e, 0x36, 0xb2, 0xf9, 0xa, 0x27, 0xba, 0xce, 0x4f, 0x2, 0x8, 0x25, 0x26, 0x23, - 0x6b, 0x3, 0x24, 0xbb, 0x1, 0xc4, 0x2, 0x0, 0x0, 0x18, 0xfc, 0x13, 0x53, 0xfe, 0x17, 0xc7, 0x28, - 0x9f, 0x21, 0x55, 0xb8, 0x18, 0x0, 0x0, 0x61, 0x77, 0x24, 0x5f, 0x2, 0x0, 0x0, 0x26, 0x17, 0x27, - 0x0, 0x0, 0x29, 0xd6, 0x25, 0xcf, 0x29, 0x6a, 0x2a, 0xbb, 0x1c, 0x0, 0x4, 0x8b, 0xd3, 0xee, 0x84, - 0x9, 0x0, 0x1c, 0x16, 0x3b, 0xda, 0xf7, 0x7c, 0xd4, 0xe7, 0x9c, 0x8, 0x56, 0xc7, 0x7a, 0x23, 0x35, - 0xdf, 0x3b, 0xaa, 0x48, 0xbd, 0xdc, 0xae, 0xe0, 0x1d, 0x38, 0xfa, 0xce, 0x7a, 0xf0, 0x25, 0xbf, 0x16, - 0x0, 0x14, 0x5a, 0xf, 0x8, 0x26, 0xa3, 0x6, 0x72, 0x30, 0xd0, 0x96, 0xbc, 0x19, 0x56, 0x1c, 0x8a, - 0xb9, 0x72, 0xe3, 0xe5, 0x6a, 0x29, 0x88, 0x9e, 0xed}; - uint8_t topic_bytes[] = {0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, - 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x9e, 0xed}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; - - uint8_t bytesprops0[] = {0x6f, 0x27, 0x85, 0xb1, 0xeb, 0x74, 0x40, 0x95, 0x41, 0x2b, 0xe9, 0x8c, 0x1}; - uint8_t bytesprops1[] = {0xc8, 0xe, 0xfa, 0x36, 0x90, 0xc0, 0x79, 0x47, 0xd3, 0x2, 0x8b, 0xfd, 0xaf, 0x12, - 0x9d, 0x8b, 0x1a, 0x1e, 0x36, 0xb2, 0xf9, 0xa, 0x27, 0xba, 0xce, 0x4f, 0x2, 0x8}; - uint8_t bytesprops2[] = {0x8b, 0xd3, 0xee, 0x84}; - uint8_t bytesprops3[] = {0x16, 0x3b, 0xda, 0xf7, 0x7c, 0xd4, 0xe7, 0x9c, 0x8, 0x56, 0xc7, 0x7a, 0x23, 0x35, - 0xdf, 0x3b, 0xaa, 0x48, 0xbd, 0xdc, 0xae, 0xe0, 0x1d, 0x38, 0xfa, 0xce, 0x7a, 0xf0}; - uint8_t bytesprops4[] = {0x5a, 0xf, 0x8, 0x26, 0xa3, 0x6, 0x72, 0x30, 0xd0, 0x96, - 0xbc, 0x19, 0x56, 0x1c, 0x8a, 0xb9, 0x72, 0xe3, 0xe5, 0x6a}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\158\ESC\165s\240j\195I_\176\246\204\148I\213T\244\169E", _pubPktID = 15997, _pubBody = "tS\247\226P\227\&3\NUL\222\DC37I\219'", _pubProps = [PropAuthenticationData "Z\144(\SO\168[T\179\224`}&\140\218\195",PropSubscriptionIdentifier 18,PropContentType "`.\177\&6C)4\240\226\GS\ENQ\135J\160=]]\EOT9\153\204/,\212L\129\248O",PropAuthenticationData "\188U\232\SUB\163\151;\177Z\222\t\STX\131]\245\158\&6Y\140",PropTopicAlias 6708,PropReceiveMaximum 12966,PropMaximumQoS 54,PropServerReference "o\180B;\169\150\161\FS\DC2jtr\154\150",PropAuthenticationData "V\138\t\160\208\SYN\DEL@\137\181Iz\238\240\US\213\205\212",PropWildcardSubscriptionAvailable 32,PropRequestProblemInformation 34,PropSubscriptionIdentifierAvailable 138]} +TEST(Publish5QCTest, Encode14) { +uint8_t pkt[] = {0x33, 0xa3, 0x1, 0x0, 0x13, 0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45, 0x3e, 0x7d, 0x7d, 0x16, 0x0, 0xf, 0x5a, 0x90, 0x28, 0xe, 0xa8, 0x5b, 0x54, 0xb3, 0xe0, 0x60, 0x7d, 0x26, 0x8c, 0xda, 0xc3, 0xb, 0x12, 0x3, 0x0, 0x1c, 0x60, 0x2e, 0xb1, 0x36, 0x43, 0x29, 0x34, 0xf0, 0xe2, 0x1d, 0x5, 0x87, 0x4a, 0xa0, 0x3d, 0x5d, 0x5d, 0x4, 0x39, 0x99, 0xcc, 0x2f, 0x2c, 0xd4, 0x4c, 0x81, 0xf8, 0x4f, 0x16, 0x0, 0x13, 0xbc, 0x55, 0xe8, 0x1a, 0xa3, 0x97, 0x3b, 0xb1, 0x5a, 0xde, 0x9, 0x2, 0x83, 0x5d, 0xf5, 0x9e, 0x36, 0x59, 0x8c, 0x23, 0x1a, 0x34, 0x21, 0x32, 0xa6, 0x24, 0x36, 0x1c, 0x0, 0xe, 0x6f, 0xb4, 0x42, 0x3b, 0xa9, 0x96, 0xa1, 0x1c, 0x12, 0x6a, 0x74, 0x72, 0x9a, 0x96, 0x16, 0x0, 0x12, 0x56, 0x8a, 0x9, 0xa0, 0xd0, 0x16, 0x7f, 0x40, 0x89, 0xb5, 0x49, 0x7a, 0xee, 0xf0, 0x1f, 0xd5, 0xcd, 0xd4, 0x28, 0x20, 0x17, 0x22, 0x29, 0x8a, 0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; + uint8_t topic_bytes[] = {0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 14; + + uint8_t bytesprops0[] = {0x5a, 0x90, 0x28, 0xe, 0xa8, 0x5b, 0x54, 0xb3, 0xe0, 0x60, 0x7d, 0x26, 0x8c, 0xda, 0xc3}; + uint8_t bytesprops1[] = {0x60, 0x2e, 0xb1, 0x36, 0x43, 0x29, 0x34, 0xf0, 0xe2, 0x1d, 0x5, 0x87, 0x4a, 0xa0, 0x3d, 0x5d, 0x5d, 0x4, 0x39, 0x99, 0xcc, 0x2f, 0x2c, 0xd4, 0x4c, 0x81, 0xf8, 0x4f}; + uint8_t bytesprops2[] = {0xbc, 0x55, 0xe8, 0x1a, 0xa3, 0x97, 0x3b, 0xb1, 0x5a, 0xde, 0x9, 0x2, 0x83, 0x5d, 0xf5, 0x9e, 0x36, 0x59, 0x8c}; + uint8_t bytesprops3[] = {0x6f, 0xb4, 0x42, 0x3b, 0xa9, 0x96, 0xa1, 0x1c, 0x12, 0x6a, 0x74, 0x72, 0x9a, 0x96}; + uint8_t bytesprops4[] = {0x56, 0x8a, 0x9, 0xa0, 0xd0, 0x16, 0x7f, 0x40, 0x89, 0xb5, 0x49, 0x7a, 0xee, 0xf0, 0x1f, 0xd5, 0xcd, 0xd4}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1708}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5729}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16831}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27395}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6396}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21502}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21944}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24951}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9751}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10710}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6708}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12966}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 17194, topic, msg, props); + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15997, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\156\129\b\202\ETB\"y\195\204\150S\DLE\231\CANg\207\&0\n\246~U\196\194\&5", _pubPktID = 17194, _pubBody = -// "\158\237", _pubProps = [PropPayloadFormatIndicator 191,PropRequestProblemInformation -// 232,PropSubscriptionIdentifierAvailable 54,PropTopicAliasMaximum 1708,PropWildcardSubscriptionAvailable -// 116,PropAuthenticationData "o'\133\177\235t@\149A+\233\140\SOH",PropMessageExpiryInterval 5729,PropTopicAliasMaximum -// 16831,PropAuthenticationData -// "\200\SO\250\&6\144\192yG\211\STX\139\253\175\DC2\157\139\SUB\RS6\178\249\n'\186\206O\STX\b",PropRetainAvailable -// 38,PropTopicAlias 27395,PropMaximumQoS 187,PropPayloadFormatIndicator 196,PropMessageExpiryInterval -// 6396,PropServerKeepAlive 21502,PropRequestProblemInformation 199,PropWildcardSubscriptionAvailable -// 159,PropReceiveMaximum 21944,PropWillDelayInterval 24951,PropMaximumQoS 95,PropMessageExpiryInterval -// 9751,PropMaximumPacketSize 10710,PropRetainAvailable 207,PropSubscriptionIdentifierAvailable -// 106,PropSharedSubscriptionAvailable 187,PropServerReference "\139\211\238\132",PropCorrelationData -// "\SYN;\218\247|\212\231\156\bV\199z#5\223;\170H\189\220\174\224\GS8\250\206z\240",PropRetainAvailable -// 191,PropAuthenticationData -// "Z\SI\b&\163\ACKr0\208\150\188\EMV\FS\138\185r\227\229j",PropSubscriptionIdentifierAvailable 136]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\158\ESC\165s\240j\195I_\176\246\204\148I\213T\244\169E", _pubPktID = 15997, _pubBody = "tS\247\226P\227\&3\NUL\222\DC37I\219'", _pubProps = [PropAuthenticationData "Z\144(\SO\168[T\179\224`}&\140\218\195",PropSubscriptionIdentifier 18,PropContentType "`.\177\&6C)4\240\226\GS\ENQ\135J\160=]]\EOT9\153\204/,\212L\129\248O",PropAuthenticationData "\188U\232\SUB\163\151;\177Z\222\t\STX\131]\245\158\&6Y\140",PropTopicAlias 6708,PropReceiveMaximum 12966,PropMaximumQoS 54,PropServerReference "o\180B;\169\150\161\FS\DC2jtr\154\150",PropAuthenticationData "V\138\t\160\208\SYN\DEL@\137\181Iz\238\240\US\213\205\212",PropWildcardSubscriptionAvailable 32,PropRequestProblemInformation 34,PropSubscriptionIdentifierAvailable 138]} TEST(Publish5QCTest, Decode14) { - uint8_t pkt[] = {0x33, 0xd2, 0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xf, 0x8, 0x26, 0xa3, 0x6, 0x72, 0x30, 0xd0, 0x96, 0xbc, 0x19, 0x56, 0x1c, 0x8a, - 0xb9, 0x72, 0xe3, 0xe5, 0x6a, 0x29, 0x88, 0x9e, 0xed}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9c, 0x81, 0x8, 0xca, 0x17, 0x22, 0x79, 0xc3, 0xcc, 0x96, 0x53, 0x10, - 0xe7, 0x18, 0x67, 0xcf, 0x30, 0xa, 0xf6, 0x7e, 0x55, 0xc4, 0xc2, 0x35}; - lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9e, 0xed}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 17194); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// ")\223\215<\151R\ENQ\DC3I\131&\207\&4\179\156\CAN\SO", _pubPktID = 18606, _pubBody = "\208Zo\214\246#v", _pubProps = -// [PropSubscriptionIdentifier 9,PropAuthenticationData -// "\242\231\FSo\223\180\b\241)\214pM\NAK\nH\138+h;&t8\STX\216\178q\251\137+",PropWildcardSubscriptionAvailable -// 246,PropSubscriptionIdentifier 4,PropTopicAliasMaximum 11929,PropSessionExpiryInterval 12227,PropTopicAliasMaximum -// 21923,PropWildcardSubscriptionAvailable 49,PropAssignedClientIdentifier "_\136\166 -// \GS\EM\ETX\220\ACK]\ENQ\196\&63\ACK\SI\197k\228a4,",PropMessageExpiryInterval 31165,PropAuthenticationMethod -// "\SYN\f\173\244Y\247z\160i9i\128C\178\201\143oM\ENQ\138\176@\192",PropCorrelationData -// "\197\"\194\214\241a\209\199U\138D\200\CAN\"7W\EOT$_#",PropResponseTopic "\237\202^\244",PropAssignedClientIdentifier -// "\239\147~\US3\222UK\186y\SOHG\226\163\DLE\152\242",PropReceiveMaximum 9627,PropReceiveMaximum -// 7912,PropAssignedClientIdentifier -// "\237\191\228d\245fu\215\255\222\171\170\229\DC2\184q>#\239\ab\252\188\211\r\247\147\ENQ",PropMaximumQoS -// 55,PropWillDelayInterval 17769,PropTopicAliasMaximum 28809,PropPayloadFormatIndicator 162]} +uint8_t pkt[] = {0x33, 0xa3, 0x1, 0x0, 0x13, 0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45, 0x3e, 0x7d, 0x7d, 0x16, 0x0, 0xf, 0x5a, 0x90, 0x28, 0xe, 0xa8, 0x5b, 0x54, 0xb3, 0xe0, 0x60, 0x7d, 0x26, 0x8c, 0xda, 0xc3, 0xb, 0x12, 0x3, 0x0, 0x1c, 0x60, 0x2e, 0xb1, 0x36, 0x43, 0x29, 0x34, 0xf0, 0xe2, 0x1d, 0x5, 0x87, 0x4a, 0xa0, 0x3d, 0x5d, 0x5d, 0x4, 0x39, 0x99, 0xcc, 0x2f, 0x2c, 0xd4, 0x4c, 0x81, 0xf8, 0x4f, 0x16, 0x0, 0x13, 0xbc, 0x55, 0xe8, 0x1a, 0xa3, 0x97, 0x3b, 0xb1, 0x5a, 0xde, 0x9, 0x2, 0x83, 0x5d, 0xf5, 0x9e, 0x36, 0x59, 0x8c, 0x23, 0x1a, 0x34, 0x21, 0x32, 0xa6, 0x24, 0x36, 0x1c, 0x0, 0xe, 0x6f, 0xb4, 0x42, 0x3b, 0xa9, 0x96, 0xa1, 0x1c, 0x12, 0x6a, 0x74, 0x72, 0x9a, 0x96, 0x16, 0x0, 0x12, 0x56, 0x8a, 0x9, 0xa0, 0xd0, 0x16, 0x7f, 0x40, 0x89, 0xb5, 0x49, 0x7a, 0xee, 0xf0, 0x1f, 0xd5, 0xcd, 0xd4, 0x28, 0x20, 0x17, 0x22, 0x29, 0x8a, 0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45}; + lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 15997); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); +EXPECT_EQ(msg.payload_len, 14); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\224\135\179\172\244\254\241]\218|\ESC\137/", _pubPktID = 30908, _pubBody = "\235c=\156\"\206\185spp`\235\216", _pubProps = [PropMessageExpiryInterval 6037,PropWillDelayInterval 28652,PropCorrelationData "\244zO@\192\189\&3)\US\177*\173\142\ENQ\144\218'\172\ETX\180O\DC3\156\205\206",PropSessionExpiryInterval 8920,PropWillDelayInterval 5875,PropSubscriptionIdentifier 9,PropReasonString "\166g\238\&9\US\DC2F\192dH\254\182\146\254",PropTopicAlias 32438,PropMessageExpiryInterval 10202,PropSubscriptionIdentifierAvailable 253,PropContentType "/\227\214\211",PropReasonString "K\182N",PropTopicAlias 10419,PropMessageExpiryInterval 18017,PropSubscriptionIdentifierAvailable 65,PropWillDelayInterval 743,PropRequestProblemInformation 232,PropSubscriptionIdentifierAvailable 126,PropRetainAvailable 132,PropRequestResponseInformation 184,PropReceiveMaximum 25871,PropMessageExpiryInterval 21303,PropCorrelationData "\211L\234\251\NAKtw\ETB\206L\157\190\244?2%\157",PropServerReference "\232T\205?\234\b\US{6\141\173\CAN(\GS\175/\238^\224\159R\244\130\208\202E",PropTopicAlias 15782,PropSharedSubscriptionAvailable 56]} TEST(Publish5QCTest, Encode15) { - uint8_t pkt[] = { - 0x35, 0xec, 0x1, 0x0, 0x11, 0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, 0x83, 0x26, 0xcf, 0x34, 0xb3, - 0x9c, 0x18, 0xe, 0x48, 0xae, 0xce, 0x1, 0xb, 0x9, 0x16, 0x0, 0x1d, 0xf2, 0xe7, 0x1c, 0x6f, 0xdf, 0xb4, 0x8, - 0xf1, 0x29, 0xd6, 0x70, 0x4d, 0x15, 0xa, 0x48, 0x8a, 0x2b, 0x68, 0x3b, 0x26, 0x74, 0x38, 0x2, 0xd8, 0xb2, 0x71, - 0xfb, 0x89, 0x2b, 0x28, 0xf6, 0xb, 0x4, 0x22, 0x2e, 0x99, 0x11, 0x0, 0x0, 0x2f, 0xc3, 0x22, 0x55, 0xa3, 0x28, - 0x31, 0x12, 0x0, 0x16, 0x5f, 0x88, 0xa6, 0x20, 0x1d, 0x19, 0x3, 0xdc, 0x6, 0x5d, 0x5, 0xc4, 0x36, 0x33, 0x6, - 0xf, 0xc5, 0x6b, 0xe4, 0x61, 0x34, 0x2c, 0x2, 0x0, 0x0, 0x79, 0xbd, 0x15, 0x0, 0x17, 0x16, 0xc, 0xad, 0xf4, - 0x59, 0xf7, 0x7a, 0xa0, 0x69, 0x39, 0x69, 0x80, 0x43, 0xb2, 0xc9, 0x8f, 0x6f, 0x4d, 0x5, 0x8a, 0xb0, 0x40, 0xc0, - 0x9, 0x0, 0x14, 0xc5, 0x22, 0xc2, 0xd6, 0xf1, 0x61, 0xd1, 0xc7, 0x55, 0x8a, 0x44, 0xc8, 0x18, 0x22, 0x37, 0x57, - 0x4, 0x24, 0x5f, 0x23, 0x8, 0x0, 0x4, 0xed, 0xca, 0x5e, 0xf4, 0x12, 0x0, 0x11, 0xef, 0x93, 0x7e, 0x1f, 0x33, - 0xde, 0x55, 0x4b, 0xba, 0x79, 0x1, 0x47, 0xe2, 0xa3, 0x10, 0x98, 0xf2, 0x21, 0x25, 0x9b, 0x21, 0x1e, 0xe8, 0x12, - 0x0, 0x1c, 0xed, 0xbf, 0xe4, 0x64, 0xf5, 0x66, 0x75, 0xd7, 0xff, 0xde, 0xab, 0xaa, 0xe5, 0x12, 0xb8, 0x71, 0x3e, - 0x23, 0xef, 0x7, 0x62, 0xfc, 0xbc, 0xd3, 0xd, 0xf7, 0x93, 0x5, 0x24, 0x37, 0x18, 0x0, 0x0, 0x45, 0x69, 0x22, - 0x70, 0x89, 0x1, 0xa2, 0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; - uint8_t topic_bytes[] = {0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, - 0x83, 0x26, 0xcf, 0x34, 0xb3, 0x9c, 0x18, 0xe}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; - - uint8_t bytesprops0[] = {0xf2, 0xe7, 0x1c, 0x6f, 0xdf, 0xb4, 0x8, 0xf1, 0x29, 0xd6, 0x70, 0x4d, 0x15, 0xa, 0x48, - 0x8a, 0x2b, 0x68, 0x3b, 0x26, 0x74, 0x38, 0x2, 0xd8, 0xb2, 0x71, 0xfb, 0x89, 0x2b}; - uint8_t bytesprops1[] = {0x5f, 0x88, 0xa6, 0x20, 0x1d, 0x19, 0x3, 0xdc, 0x6, 0x5d, 0x5, - 0xc4, 0x36, 0x33, 0x6, 0xf, 0xc5, 0x6b, 0xe4, 0x61, 0x34, 0x2c}; - uint8_t bytesprops2[] = {0x16, 0xc, 0xad, 0xf4, 0x59, 0xf7, 0x7a, 0xa0, 0x69, 0x39, 0x69, 0x80, - 0x43, 0xb2, 0xc9, 0x8f, 0x6f, 0x4d, 0x5, 0x8a, 0xb0, 0x40, 0xc0}; - uint8_t bytesprops3[] = {0xc5, 0x22, 0xc2, 0xd6, 0xf1, 0x61, 0xd1, 0xc7, 0x55, 0x8a, - 0x44, 0xc8, 0x18, 0x22, 0x37, 0x57, 0x4, 0x24, 0x5f, 0x23}; - uint8_t bytesprops4[] = {0xed, 0xca, 0x5e, 0xf4}; - uint8_t bytesprops5[] = {0xef, 0x93, 0x7e, 0x1f, 0x33, 0xde, 0x55, 0x4b, 0xba, - 0x79, 0x1, 0x47, 0xe2, 0xa3, 0x10, 0x98, 0xf2}; - uint8_t bytesprops6[] = {0xed, 0xbf, 0xe4, 0x64, 0xf5, 0x66, 0x75, 0xd7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xe8, 0x54, 0xcd, 0x3f, 0xea, 0x8, 0x1f, 0x7b, 0x36, 0x8d, 0xad, 0x18, 0x28, 0x1d, 0xaf, 0x2f, 0xee, 0x5e, 0xe0, 0x9f, 0x52, 0xf4, 0x82, 0xd0, 0xca, 0x45, 0x23, 0x3d, 0xa6, 0x2a, 0x38, 0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; + uint8_t topic_bytes[] = {0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = false; +uint8_t msg_bytes[] = {0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 13; + + uint8_t bytesprops0[] = {0xf4, 0x7a, 0x4f, 0x40, 0xc0, 0xbd, 0x33, 0x29, 0x1f, 0xb1, 0x2a, 0xad, 0x8e, 0x5, 0x90, 0xda, 0x27, 0xac, 0x3, 0xb4, 0x4f, 0x13, 0x9c, 0xcd, 0xce}; + uint8_t bytesprops1[] = {0xa6, 0x67, 0xee, 0x39, 0x1f, 0x12, 0x46, 0xc0, 0x64, 0x48, 0xfe, 0xb6, 0x92, 0xfe}; + uint8_t bytesprops2[] = {0x2f, 0xe3, 0xd6, 0xd3}; + uint8_t bytesprops3[] = {0x4b, 0xb6, 0x4e}; + uint8_t bytesprops4[] = {0xd3, 0x4c, 0xea, 0xfb, 0x15, 0x74, 0x77, 0x17, 0xce, 0x4c, 0x9d, 0xbe, 0xf4, 0x3f, 0x32, 0x25, 0x9d}; + uint8_t bytesprops5[] = {0xe8, 0x54, 0xcd, 0x3f, 0xea, 0x8, 0x1f, 0x7b, 0x36, 0x8d, 0xad, 0x18, 0x28, 0x1d, 0xaf, 0x2f, 0xee, 0x5e, 0xe0, 0x9f, 0x52, 0xf4, 0x82, 0xd0, 0xca, 0x45}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11929}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12227}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21923}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31165}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9627}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7912}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17769}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28809}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6037}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28652}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8920}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5875}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32438}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10202}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10419}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18017}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 743}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25871}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21303}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15782}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 56}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 18606, topic, msg, props); + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 30908, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// ")\223\215<\151R\ENQ\DC3I\131&\207\&4\179\156\CAN\SO", _pubPktID = 18606, _pubBody = "\208Zo\214\246#v", _pubProps = -// [PropSubscriptionIdentifier 9,PropAuthenticationData -// "\242\231\FSo\223\180\b\241)\214pM\NAK\nH\138+h;&t8\STX\216\178q\251\137+",PropWildcardSubscriptionAvailable -// 246,PropSubscriptionIdentifier 4,PropTopicAliasMaximum 11929,PropSessionExpiryInterval 12227,PropTopicAliasMaximum -// 21923,PropWildcardSubscriptionAvailable 49,PropAssignedClientIdentifier "_\136\166 -// \GS\EM\ETX\220\ACK]\ENQ\196\&63\ACK\SI\197k\228a4,",PropMessageExpiryInterval 31165,PropAuthenticationMethod -// "\SYN\f\173\244Y\247z\160i9i\128C\178\201\143oM\ENQ\138\176@\192",PropCorrelationData -// "\197\"\194\214\241a\209\199U\138D\200\CAN\"7W\EOT$_#",PropResponseTopic "\237\202^\244",PropAssignedClientIdentifier -// "\239\147~\US3\222UK\186y\SOHG\226\163\DLE\152\242",PropReceiveMaximum 9627,PropReceiveMaximum -// 7912,PropAssignedClientIdentifier -// "\237\191\228d\245fu\215\255\222\171\170\229\DC2\184q>#\239\ab\252\188\211\r\247\147\ENQ",PropMaximumQoS -// 55,PropWillDelayInterval 17769,PropTopicAliasMaximum 28809,PropPayloadFormatIndicator 162]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\224\135\179\172\244\254\241]\218|\ESC\137/", _pubPktID = 30908, _pubBody = "\235c=\156\"\206\185spp`\235\216", _pubProps = [PropMessageExpiryInterval 6037,PropWillDelayInterval 28652,PropCorrelationData "\244zO@\192\189\&3)\US\177*\173\142\ENQ\144\218'\172\ETX\180O\DC3\156\205\206",PropSessionExpiryInterval 8920,PropWillDelayInterval 5875,PropSubscriptionIdentifier 9,PropReasonString "\166g\238\&9\US\DC2F\192dH\254\182\146\254",PropTopicAlias 32438,PropMessageExpiryInterval 10202,PropSubscriptionIdentifierAvailable 253,PropContentType "/\227\214\211",PropReasonString "K\182N",PropTopicAlias 10419,PropMessageExpiryInterval 18017,PropSubscriptionIdentifierAvailable 65,PropWillDelayInterval 743,PropRequestProblemInformation 232,PropSubscriptionIdentifierAvailable 126,PropRetainAvailable 132,PropRequestResponseInformation 184,PropReceiveMaximum 25871,PropMessageExpiryInterval 21303,PropCorrelationData "\211L\234\251\NAKtw\ETB\206L\157\190\244?2%\157",PropServerReference "\232T\205?\234\b\US{6\141\173\CAN(\GS\175/\238^\224\159R\244\130\208\202E",PropTopicAlias 15782,PropSharedSubscriptionAvailable 56]} TEST(Publish5QCTest, Decode15) { - uint8_t pkt[] = { - 0x35, 0xec, 0x1, 0x0, 0x11, 0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, 0x83, 0x26, 0xcf, 0x34, 0xb3, - 0x9c, 0x18, 0xe, 0x48, 0xae, 0xce, 0x1, 0xb, 0x9, 0x16, 0x0, 0x1d, 0xf2, 0xe7, 0x1c, 0x6f, 0xdf, 0xb4, 0x8, - 0xf1, 0x29, 0xd6, 0x70, 0x4d, 0x15, 0xa, 0x48, 0x8a, 0x2b, 0x68, 0x3b, 0x26, 0x74, 0x38, 0x2, 0xd8, 0xb2, 0x71, - 0xfb, 0x89, 0x2b, 0x28, 0xf6, 0xb, 0x4, 0x22, 0x2e, 0x99, 0x11, 0x0, 0x0, 0x2f, 0xc3, 0x22, 0x55, 0xa3, 0x28, - 0x31, 0x12, 0x0, 0x16, 0x5f, 0x88, 0xa6, 0x20, 0x1d, 0x19, 0x3, 0xdc, 0x6, 0x5d, 0x5, 0xc4, 0x36, 0x33, 0x6, - 0xf, 0xc5, 0x6b, 0xe4, 0x61, 0x34, 0x2c, 0x2, 0x0, 0x0, 0x79, 0xbd, 0x15, 0x0, 0x17, 0x16, 0xc, 0xad, 0xf4, - 0x59, 0xf7, 0x7a, 0xa0, 0x69, 0x39, 0x69, 0x80, 0x43, 0xb2, 0xc9, 0x8f, 0x6f, 0x4d, 0x5, 0x8a, 0xb0, 0x40, 0xc0, - 0x9, 0x0, 0x14, 0xc5, 0x22, 0xc2, 0xd6, 0xf1, 0x61, 0xd1, 0xc7, 0x55, 0x8a, 0x44, 0xc8, 0x18, 0x22, 0x37, 0x57, - 0x4, 0x24, 0x5f, 0x23, 0x8, 0x0, 0x4, 0xed, 0xca, 0x5e, 0xf4, 0x12, 0x0, 0x11, 0xef, 0x93, 0x7e, 0x1f, 0x33, - 0xde, 0x55, 0x4b, 0xba, 0x79, 0x1, 0x47, 0xe2, 0xa3, 0x10, 0x98, 0xf2, 0x21, 0x25, 0x9b, 0x21, 0x1e, 0xe8, 0x12, - 0x0, 0x1c, 0xed, 0xbf, 0xe4, 0x64, 0xf5, 0x66, 0x75, 0xd7, 0xff, 0xde, 0xab, 0xaa, 0xe5, 0x12, 0xb8, 0x71, 0x3e, - 0x23, 0xef, 0x7, 0x62, 0xfc, 0xbc, 0xd3, 0xd, 0xf7, 0x93, 0x5, 0x24, 0x37, 0x18, 0x0, 0x0, 0x45, 0x69, 0x22, - 0x70, 0x89, 0x1, 0xa2, 0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x29, 0xdf, 0xd7, 0x3c, 0x97, 0x52, 0x5, 0x13, 0x49, - 0x83, 0x26, 0xcf, 0x34, 0xb3, 0x9c, 0x18, 0xe}; - lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd0, 0x5a, 0x6f, 0xd6, 0xf6, 0x23, 0x76}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 18606); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\168E\247k\237\175\&5\SO\SYNU\224\160", _pubPktID = 28189, _pubBody = "", _pubProps = [PropResponseInformation -// "Y\236\&2K\172\176\155\149\164\203\&1Q\173",PropWildcardSubscriptionAvailable 109]} +uint8_t pkt[] = {0x32, 0xd0, 0x1, 0x0, 0xe, 0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f, 0x78, 0xbc, 0xaf, 0x1, 0x2, 0x0, 0x0, 0x17, 0x95, 0x18, 0x0, 0x0, 0x6f, 0xec, 0x9, 0x0, 0x19, 0xf4, 0x7a, 0x4f, 0x40, 0xc0, 0xbd, 0x33, 0x29, 0x1f, 0xb1, 0x2a, 0xad, 0x8e, 0x5, 0x90, 0xda, 0x27, 0xac, 0x3, 0xb4, 0x4f, 0x13, 0x9c, 0xcd, 0xce, 0x11, 0x0, 0x0, 0x22, 0xd8, 0x18, 0x0, 0x0, 0x16, 0xf3, 0xb, 0x9, 0x1f, 0x0, 0xe, 0xa6, 0x67, 0xee, 0x39, 0x1f, 0x12, 0x46, 0xc0, 0x64, 0x48, 0xfe, 0xb6, 0x92, 0xfe, 0x23, 0x7e, 0xb6, 0x2, 0x0, 0x0, 0x27, 0xda, 0x29, 0xfd, 0x3, 0x0, 0x4, 0x2f, 0xe3, 0xd6, 0xd3, 0x1f, 0x0, 0x3, 0x4b, 0xb6, 0x4e, 0x23, 0x28, 0xb3, 0x2, 0x0, 0x0, 0x46, 0x61, 0x29, 0x41, 0x18, 0x0, 0x0, 0x2, 0xe7, 0x17, 0xe8, 0x29, 0x7e, 0x25, 0x84, 0x19, 0xb8, 0x21, 0x65, 0xf, 0x2, 0x0, 0x0, 0x53, 0x37, 0x9, 0x0, 0x11, 0xd3, 0x4c, 0xea, 0xfb, 0x15, 0x74, 0x77, 0x17, 0xce, 0x4c, 0x9d, 0xbe, 0xf4, 0x3f, 0x32, 0x25, 0x9d, 0x1c, 0x0, 0x1a, 0xe8, 0x54, 0xcd, 0x3f, 0xea, 0x8, 0x1f, 0x7b, 0x36, 0x8d, 0xad, 0x18, 0x28, 0x1d, 0xaf, 0x2f, 0xee, 0x5e, 0xe0, 0x9f, 0x52, 0xf4, 0x82, 0xd0, 0xca, 0x45, 0x23, 0x3d, 0xa6, 0x2a, 0x38, 0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 30908); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); +EXPECT_EQ(msg.payload_len, 13); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\233\218E\235\207\216\&6b\236\246\&0?\169D\196\137\228\212\200\179\RS\159", _pubPktID = 7795, _pubBody = ")\a\246\&4J\134\237\148\159\143:\EOT\237lN\252D\144\179\163'7\208\193\240", _pubProps = []} TEST(Publish5QCTest, Encode16) { - uint8_t pkt[] = {0x35, 0x23, 0x0, 0xc, 0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, - 0x55, 0xe0, 0xa0, 0x6e, 0x1d, 0x12, 0x1a, 0x0, 0xd, 0x59, 0xec, 0x32, 0x4b, - 0xac, 0xb0, 0x9b, 0x95, 0xa4, 0xcb, 0x31, 0x51, 0xad, 0x28, 0x6d}; - uint8_t topic_bytes[] = {0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; +uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x16, 0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f, 0x1e, 0x73, 0x0, 0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; + uint8_t topic_bytes[] = {0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; - uint8_t bytesprops0[] = {0x59, 0xec, 0x32, 0x4b, 0xac, 0xb0, 0x9b, 0x95, 0xa4, 0xcb, 0x31, 0x51, 0xad}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 25; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 109}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 28189, topic, msg, props); + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7795, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\168E\247k\237\175\&5\SO\SYNU\224\160", _pubPktID = 28189, _pubBody = "", _pubProps = [PropResponseInformation -// "Y\236\&2K\172\176\155\149\164\203\&1Q\173",PropWildcardSubscriptionAvailable 109]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\233\218E\235\207\216\&6b\236\246\&0?\169D\196\137\228\212\200\179\RS\159", _pubPktID = 7795, _pubBody = ")\a\246\&4J\134\237\148\159\143:\EOT\237lN\252D\144\179\163'7\208\193\240", _pubProps = []} TEST(Publish5QCTest, Decode16) { - uint8_t pkt[] = {0x35, 0x23, 0x0, 0xc, 0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, - 0x55, 0xe0, 0xa0, 0x6e, 0x1d, 0x12, 0x1a, 0x0, 0xd, 0x59, 0xec, 0x32, 0x4b, - 0xac, 0xb0, 0x9b, 0x95, 0xa4, 0xcb, 0x31, 0x51, 0xad, 0x28, 0x6d}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x16, 0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f, 0x1e, 0x73, 0x0, 0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 7795); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); +EXPECT_EQ(msg.payload_len, 25); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa8, 0x45, 0xf7, 0x6b, 0xed, 0xaf, 0x35, 0xe, 0x16, 0x55, 0xe0, 0xa0}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 28189); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\191\CAN?\r\149\&0\185\198\tZ\213\STX5\192\195", _pubPktID = 0, _pubBody = "\190\206\169pC<\142\135\&8\243", -// _pubProps = [PropRequestResponseInformation 30,PropReceiveMaximum 13794,PropSubscriptionIdentifierAvailable -// 193,PropResponseInformation "\204\198\191\192ND\FS\218\DC4",PropSubscriptionIdentifierAvailable 226,PropMaximumQoS -// 112,PropMaximumQoS 106,PropWillDelayInterval 19852,PropTopicAlias 29604,PropMessageExpiryInterval -// 2602,PropContentType ";O\147\155!<~\199\ETX\215\SOHcc\DC4i\247I\231"]} -TEST(Publish5QCTest, Encode17) { - uint8_t pkt[] = {0x39, 0x57, 0x0, 0xf, 0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, - 0x2, 0x35, 0xc0, 0xc3, 0x3b, 0x19, 0x1e, 0x21, 0x35, 0xe2, 0x29, 0xc1, 0x1a, 0x0, 0x9, - 0xcc, 0xc6, 0xbf, 0xc0, 0x4e, 0x44, 0x1c, 0xda, 0x14, 0x29, 0xe2, 0x24, 0x70, 0x24, 0x6a, - 0x18, 0x0, 0x0, 0x4d, 0x8c, 0x23, 0x73, 0xa4, 0x2, 0x0, 0x0, 0xa, 0x2a, 0x3, 0x0, - 0x12, 0x3b, 0x4f, 0x93, 0x9b, 0x21, 0x3c, 0x7e, 0xc7, 0x3, 0xd7, 0x1, 0x63, 0x63, 0x14, - 0x69, 0xf7, 0x49, 0xe7, 0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; - uint8_t topic_bytes[] = {0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, 0x2, 0x35, 0xc0, 0xc3}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; - uint8_t bytesprops0[] = {0xcc, 0xc6, 0xbf, 0xc0, 0x4e, 0x44, 0x1c, 0xda, 0x14}; - uint8_t bytesprops1[] = {0x3b, 0x4f, 0x93, 0x9b, 0x21, 0x3c, 0x7e, 0xc7, 0x3, - 0xd7, 0x1, 0x63, 0x63, 0x14, 0x69, 0xf7, 0x49, 0xe7}; +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "i\236\180\192[~\199\179\163\147g\v\219?\135\190L\237\DC1\STX`", _pubPktID = 2871, _pubBody = "\166\217", _pubProps = [PropUserProperty "\215|\bNh\138F\244s\162\207\164A\EMc\239\135" "H\f",PropResponseInformation "\211"]} +TEST(Publish5QCTest, Encode17) { +uint8_t pkt[] = {0x3d, 0x38, 0x0, 0x15, 0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60, 0xb, 0x37, 0x1c, 0x26, 0x0, 0x11, 0xd7, 0x7c, 0x8, 0x4e, 0x68, 0x8a, 0x46, 0xf4, 0x73, 0xa2, 0xcf, 0xa4, 0x41, 0x19, 0x63, 0xef, 0x87, 0x0, 0x2, 0x48, 0xc, 0x1a, 0x0, 0x1, 0xd3, 0xa6, 0xd9}; + uint8_t topic_bytes[] = {0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0xa6, 0xd9}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 2; + + uint8_t bytesprops1[] = {0x48, 0xc}; + uint8_t bytesprops0[] = {0xd7, 0x7c, 0x8, 0x4e, 0x68, 0x8a, 0x46, 0xf4, 0x73, 0xa2, 0xcf, 0xa4, 0x41, 0x19, 0x63, 0xef, 0x87}; + uint8_t bytesprops2[] = {0xd3}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13794}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19852}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29604}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2602}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, - }; - - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={17, (char*)&bytesprops0}, .v={2, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, + }; - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2871, topic, msg, props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\191\CAN?\r\149\&0\185\198\tZ\213\STX5\192\195", _pubPktID = 0, _pubBody = "\190\206\169pC<\142\135\&8\243", -// _pubProps = [PropRequestResponseInformation 30,PropReceiveMaximum 13794,PropSubscriptionIdentifierAvailable -// 193,PropResponseInformation "\204\198\191\192ND\FS\218\DC4",PropSubscriptionIdentifierAvailable 226,PropMaximumQoS -// 112,PropMaximumQoS 106,PropWillDelayInterval 19852,PropTopicAlias 29604,PropMessageExpiryInterval -// 2602,PropContentType ";O\147\155!<~\199\ETX\215\SOHcc\DC4i\247I\231"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "i\236\180\192[~\199\179\163\147g\v\219?\135\190L\237\DC1\STX`", _pubPktID = 2871, _pubBody = "\166\217", _pubProps = [PropUserProperty "\215|\bNh\138F\244s\162\207\164A\EMc\239\135" "H\f",PropResponseInformation "\211"]} TEST(Publish5QCTest, Decode17) { - uint8_t pkt[] = {0x39, 0x57, 0x0, 0xf, 0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, - 0x2, 0x35, 0xc0, 0xc3, 0x3b, 0x19, 0x1e, 0x21, 0x35, 0xe2, 0x29, 0xc1, 0x1a, 0x0, 0x9, - 0xcc, 0xc6, 0xbf, 0xc0, 0x4e, 0x44, 0x1c, 0xda, 0x14, 0x29, 0xe2, 0x24, 0x70, 0x24, 0x6a, - 0x18, 0x0, 0x0, 0x4d, 0x8c, 0x23, 0x73, 0xa4, 0x2, 0x0, 0x0, 0xa, 0x2a, 0x3, 0x0, - 0x12, 0x3b, 0x4f, 0x93, 0x9b, 0x21, 0x3c, 0x7e, 0xc7, 0x3, 0xd7, 0x1, 0x63, 0x63, 0x14, - 0x69, 0xf7, 0x49, 0xe7, 0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3d, 0x38, 0x0, 0x15, 0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60, 0xb, 0x37, 0x1c, 0x26, 0x0, 0x11, 0xd7, 0x7c, 0x8, 0x4e, 0x68, 0x8a, 0x46, 0xf4, 0x73, 0xa2, 0xcf, 0xa4, 0x41, 0x19, 0x63, 0xef, 0x87, 0x0, 0x2, 0x48, 0xc, 0x1a, 0x0, 0x1, 0xd3, 0xa6, 0xd9}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa6, 0xd9}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 2871); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); +EXPECT_EQ(msg.payload_len, 2); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xbf, 0x18, 0x3f, 0xd, 0x95, 0x30, 0xb9, 0xc6, 0x9, 0x5a, 0xd5, 0x2, 0x35, 0xc0, 0xc3}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbe, 0xce, 0xa9, 0x70, 0x43, 0x3c, 0x8e, 0x87, 0x38, 0xf3}; - lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\209\227N0}\DEL\200\186\135Q\178Ab\227[N~\173\197\252P", _pubPktID = 17259, _pubBody = -// "\211\&9\214\163\194\138\\\205\223\162\148\156\131\232\SYN\215\213\DC4\174", _pubProps = [PropReceiveMaximum -// 22801,PropAuthenticationData "\207\205\ESC\151",PropMaximumPacketSize 18459,PropTopicAlias 3707,PropRetainAvailable -// 96,PropServerReference "\230\129#r\158\231m+\FS\163,z\200\254\152",PropTopicAliasMaximum -// 23376,PropSubscriptionIdentifier 1,PropRetainAvailable 81,PropMessageExpiryInterval 31204,PropReasonString -// "\137\ENQ\150\185\218",PropPayloadFormatIndicator 122,PropMaximumPacketSize 6063,PropMessageExpiryInterval -// 14185,PropSharedSubscriptionAvailable 118,PropPayloadFormatIndicator 113,PropSubscriptionIdentifier -// 20,PropSubscriptionIdentifierAvailable 192,PropMessageExpiryInterval 21107,PropWildcardSubscriptionAvailable -// 3,PropServerKeepAlive 14528,PropCorrelationData "x",PropAuthenticationMethod "1z&[",PropMaximumQoS -// 46,PropSharedSubscriptionAvailable 61,PropMaximumQoS 55]} -TEST(Publish5QCTest, Encode18) { - uint8_t pkt[] = {0x3d, 0x96, 0x1, 0x0, 0x15, 0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, - 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50, 0x43, 0x6b, 0x69, 0x21, 0x59, 0x11, - 0x16, 0x0, 0x4, 0xcf, 0xcd, 0x1b, 0x97, 0x27, 0x0, 0x0, 0x48, 0x1b, 0x23, 0xe, 0x7b, 0x25, - 0x60, 0x1c, 0x0, 0xf, 0xe6, 0x81, 0x23, 0x72, 0x9e, 0xe7, 0x6d, 0x2b, 0x1c, 0xa3, 0x2c, 0x7a, - 0xc8, 0xfe, 0x98, 0x22, 0x5b, 0x50, 0xb, 0x1, 0x25, 0x51, 0x2, 0x0, 0x0, 0x79, 0xe4, 0x1f, - 0x0, 0x5, 0x89, 0x5, 0x96, 0xb9, 0xda, 0x1, 0x7a, 0x27, 0x0, 0x0, 0x17, 0xaf, 0x2, 0x0, - 0x0, 0x37, 0x69, 0x2a, 0x76, 0x1, 0x71, 0xb, 0x14, 0x29, 0xc0, 0x2, 0x0, 0x0, 0x52, 0x73, - 0x28, 0x3, 0x13, 0x38, 0xc0, 0x9, 0x0, 0x1, 0x78, 0x15, 0x0, 0x4, 0x31, 0x7a, 0x26, 0x5b, - 0x24, 0x2e, 0x2a, 0x3d, 0x24, 0x37, 0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, - 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; - uint8_t topic_bytes[] = {0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, - 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, - 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; - - uint8_t bytesprops0[] = {0xcf, 0xcd, 0x1b, 0x97}; - uint8_t bytesprops1[] = {0xe6, 0x81, 0x23, 0x72, 0x9e, 0xe7, 0x6d, 0x2b, 0x1c, 0xa3, 0x2c, 0x7a, 0xc8, 0xfe, 0x98}; - uint8_t bytesprops2[] = {0x89, 0x5, 0x96, 0xb9, 0xda}; - uint8_t bytesprops3[] = {0x78}; - uint8_t bytesprops4[] = {0x31, 0x7a, 0x26, 0x5b}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "bc", _pubPktID = 16588, _pubBody = "BE\CAN\DEL\135:\DLE\226{E\240\163\&8oT+~\213", _pubProps = [PropMaximumQoS 133,PropMaximumPacketSize 18313,PropCorrelationData "L",PropMessageExpiryInterval 12669,PropMessageExpiryInterval 6374,PropServerReference "n\234\217\197t\209\183\189\207\SUB\DEL\251\203+1L\146\141",PropMessageExpiryInterval 24703,PropReceiveMaximum 24739,PropRequestProblemInformation 194,PropRequestProblemInformation 79,PropWildcardSubscriptionAvailable 243,PropTopicAliasMaximum 393,PropReasonString "#l",PropMessageExpiryInterval 22807,PropAuthenticationMethod "\131\156",PropMessageExpiryInterval 18090]} +TEST(Publish5QCTest, Encode18) { +uint8_t pkt[] = {0x33, 0x68, 0x0, 0x2, 0x62, 0x63, 0x40, 0xcc, 0x4f, 0x24, 0x85, 0x27, 0x0, 0x0, 0x47, 0x89, 0x9, 0x0, 0x1, 0x4c, 0x2, 0x0, 0x0, 0x31, 0x7d, 0x2, 0x0, 0x0, 0x18, 0xe6, 0x1c, 0x0, 0x12, 0x6e, 0xea, 0xd9, 0xc5, 0x74, 0xd1, 0xb7, 0xbd, 0xcf, 0x1a, 0x7f, 0xfb, 0xcb, 0x2b, 0x31, 0x4c, 0x92, 0x8d, 0x2, 0x0, 0x0, 0x60, 0x7f, 0x21, 0x60, 0xa3, 0x17, 0xc2, 0x17, 0x4f, 0x28, 0xf3, 0x22, 0x1, 0x89, 0x1f, 0x0, 0x2, 0x23, 0x6c, 0x2, 0x0, 0x0, 0x59, 0x17, 0x15, 0x0, 0x2, 0x83, 0x9c, 0x2, 0x0, 0x0, 0x46, 0xaa, 0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; + uint8_t topic_bytes[] = {0x62, 0x63}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 18; + + uint8_t bytesprops0[] = {0x4c}; + uint8_t bytesprops1[] = {0x6e, 0xea, 0xd9, 0xc5, 0x74, 0xd1, 0xb7, 0xbd, 0xcf, 0x1a, 0x7f, 0xfb, 0xcb, 0x2b, 0x31, 0x4c, 0x92, 0x8d}; + uint8_t bytesprops2[] = {0x23, 0x6c}; + uint8_t bytesprops3[] = {0x83, 0x9c}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22801}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18459}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3707}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23376}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31204}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6063}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14185}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21107}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14528}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18313}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12669}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6374}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24703}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24739}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 393}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22807}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18090}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 17259, topic, msg, props); + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16588, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\209\227N0}\DEL\200\186\135Q\178Ab\227[N~\173\197\252P", _pubPktID = 17259, _pubBody = -// "\211\&9\214\163\194\138\\\205\223\162\148\156\131\232\SYN\215\213\DC4\174", _pubProps = [PropReceiveMaximum -// 22801,PropAuthenticationData "\207\205\ESC\151",PropMaximumPacketSize 18459,PropTopicAlias 3707,PropRetainAvailable -// 96,PropServerReference "\230\129#r\158\231m+\FS\163,z\200\254\152",PropTopicAliasMaximum -// 23376,PropSubscriptionIdentifier 1,PropRetainAvailable 81,PropMessageExpiryInterval 31204,PropReasonString -// "\137\ENQ\150\185\218",PropPayloadFormatIndicator 122,PropMaximumPacketSize 6063,PropMessageExpiryInterval -// 14185,PropSharedSubscriptionAvailable 118,PropPayloadFormatIndicator 113,PropSubscriptionIdentifier -// 20,PropSubscriptionIdentifierAvailable 192,PropMessageExpiryInterval 21107,PropWildcardSubscriptionAvailable -// 3,PropServerKeepAlive 14528,PropCorrelationData "x",PropAuthenticationMethod "1z&[",PropMaximumQoS -// 46,PropSharedSubscriptionAvailable 61,PropMaximumQoS 55]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "bc", _pubPktID = 16588, _pubBody = "BE\CAN\DEL\135:\DLE\226{E\240\163\&8oT+~\213", _pubProps = [PropMaximumQoS 133,PropMaximumPacketSize 18313,PropCorrelationData "L",PropMessageExpiryInterval 12669,PropMessageExpiryInterval 6374,PropServerReference "n\234\217\197t\209\183\189\207\SUB\DEL\251\203+1L\146\141",PropMessageExpiryInterval 24703,PropReceiveMaximum 24739,PropRequestProblemInformation 194,PropRequestProblemInformation 79,PropWildcardSubscriptionAvailable 243,PropTopicAliasMaximum 393,PropReasonString "#l",PropMessageExpiryInterval 22807,PropAuthenticationMethod "\131\156",PropMessageExpiryInterval 18090]} TEST(Publish5QCTest, Decode18) { - uint8_t pkt[] = {0x3d, 0x96, 0x1, 0x0, 0x15, 0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, - 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50, 0x43, 0x6b, 0x69, 0x21, 0x59, 0x11, - 0x16, 0x0, 0x4, 0xcf, 0xcd, 0x1b, 0x97, 0x27, 0x0, 0x0, 0x48, 0x1b, 0x23, 0xe, 0x7b, 0x25, - 0x60, 0x1c, 0x0, 0xf, 0xe6, 0x81, 0x23, 0x72, 0x9e, 0xe7, 0x6d, 0x2b, 0x1c, 0xa3, 0x2c, 0x7a, - 0xc8, 0xfe, 0x98, 0x22, 0x5b, 0x50, 0xb, 0x1, 0x25, 0x51, 0x2, 0x0, 0x0, 0x79, 0xe4, 0x1f, - 0x0, 0x5, 0x89, 0x5, 0x96, 0xb9, 0xda, 0x1, 0x7a, 0x27, 0x0, 0x0, 0x17, 0xaf, 0x2, 0x0, - 0x0, 0x37, 0x69, 0x2a, 0x76, 0x1, 0x71, 0xb, 0x14, 0x29, 0xc0, 0x2, 0x0, 0x0, 0x52, 0x73, - 0x28, 0x3, 0x13, 0x38, 0xc0, 0x9, 0x0, 0x1, 0x78, 0x15, 0x0, 0x4, 0x31, 0x7a, 0x26, 0x5b, - 0x24, 0x2e, 0x2a, 0x3d, 0x24, 0x37, 0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, - 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xd1, 0xe3, 0x4e, 0x30, 0x7d, 0x7f, 0xc8, 0xba, 0x87, 0x51, 0xb2, - 0x41, 0x62, 0xe3, 0x5b, 0x4e, 0x7e, 0xad, 0xc5, 0xfc, 0x50}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd3, 0x39, 0xd6, 0xa3, 0xc2, 0x8a, 0x5c, 0xcd, 0xdf, 0xa2, - 0x94, 0x9c, 0x83, 0xe8, 0x16, 0xd7, 0xd5, 0x14, 0xae}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 17259); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\157\255\149\212\150\224\139\154J\197\&0C\166\189\203/\179f$J\197-\r\240\SUB\188;\r\173", _pubPktID = 22738, -// _pubBody = "\210\DC1\143z\164\179\bD\DELn", _pubProps = [PropMessageExpiryInterval 27990,PropMaximumPacketSize -// 22586,PropAssignedClientIdentifier "o@Z\207\212\141\233\136\149Yk\178b=\134OgP\ENQ\171_",PropAuthenticationData -// "@6\200\241\163\154\211\181L",PropAuthenticationData "8r\237\205\195\141\167\190\173L",PropAuthenticationData -// "*\149\SYNC\208\FS\145T7oDG\206\213\&1\153\231\&2s\192i\ENQ\FS\170\158|\SYN\ENQ",PropReceiveMaximum -// 24325,PropCorrelationData -// "\128\r\194\188\187\vVbUN_\181\&8\142:\195\236_XF\165\168\CAN\f\150DV\192\147",PropResponseInformation -// "k\DC1\198M\EM\132\196\219\197\ETB+\254\ESC\138\209\182p-\158\251"]} +uint8_t pkt[] = {0x33, 0x68, 0x0, 0x2, 0x62, 0x63, 0x40, 0xcc, 0x4f, 0x24, 0x85, 0x27, 0x0, 0x0, 0x47, 0x89, 0x9, 0x0, 0x1, 0x4c, 0x2, 0x0, 0x0, 0x31, 0x7d, 0x2, 0x0, 0x0, 0x18, 0xe6, 0x1c, 0x0, 0x12, 0x6e, 0xea, 0xd9, 0xc5, 0x74, 0xd1, 0xb7, 0xbd, 0xcf, 0x1a, 0x7f, 0xfb, 0xcb, 0x2b, 0x31, 0x4c, 0x92, 0x8d, 0x2, 0x0, 0x0, 0x60, 0x7f, 0x21, 0x60, 0xa3, 0x17, 0xc2, 0x17, 0x4f, 0x28, 0xf3, 0x22, 0x1, 0x89, 0x1f, 0x0, 0x2, 0x23, 0x6c, 0x2, 0x0, 0x0, 0x59, 0x17, 0x15, 0x0, 0x2, 0x83, 0x9c, 0x2, 0x0, 0x0, 0x46, 0xaa, 0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x62, 0x63}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 16588); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); +EXPECT_EQ(msg.payload_len, 18); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3\255\173\206\232\229\219\SOH\SUB\237\217\218}\ENQ\DC3", _pubPktID = 0, _pubBody = "\184", _pubProps = [PropAuthenticationData "e\ESC\ESC\a\DC4o\EOT\197\137\215\223<\199'sz\ETXKw\195\&6\130\DC3\244",PropAuthenticationData "\138\228",PropSessionExpiryInterval 7762,PropWillDelayInterval 29687,PropAuthenticationMethod "\250\186&\163\132s\174\178Bt\136\203l\225~\151$",PropSharedSubscriptionAvailable 29,PropMaximumQoS 225]} TEST(Publish5QCTest, Encode19) { - uint8_t pkt[] = {0x3c, 0xc1, 0x1, 0x0, 0x1d, 0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, 0x43, - 0xa6, 0xbd, 0xcb, 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0x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xbd, 0xcb, - 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, 0x3b, 0xd, 0xad}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; - - uint8_t bytesprops0[] = {0x6f, 0x40, 0x5a, 0xcf, 0xd4, 0x8d, 0xe9, 0x88, 0x95, 0x59, 0x6b, - 0xb2, 0x62, 0x3d, 0x86, 0x4f, 0x67, 0x50, 0x5, 0xab, 0x5f}; - uint8_t bytesprops1[] = {0x40, 0x36, 0xc8, 0xf1, 0xa3, 0x9a, 0xd3, 0xb5, 0x4c}; - uint8_t bytesprops2[] = {0x38, 0x72, 0xed, 0xcd, 0xc3, 0x8d, 0xa7, 0xbe, 0xad, 0x4c}; - uint8_t bytesprops3[] = {0x2a, 0x95, 0x16, 0x43, 0xd0, 0x1c, 0x91, 0x54, 0x37, 0x6f, 0x44, 0x47, 0xce, 0xd5, - 0x31, 0x99, 0xe7, 0x32, 0x73, 0xc0, 0x69, 0x5, 0x1c, 0xaa, 0x9e, 0x7c, 0x16, 0x5}; - uint8_t bytesprops4[] = {0x80, 0xd, 0xc2, 0xbc, 0xbb, 0xb, 0x56, 0x62, 0x55, 0x4e, 0x5f, 0xb5, 0x38, 0x8e, 0x3a, - 0xc3, 0xec, 0x5f, 0x58, 0x46, 0xa5, 0xa8, 0x18, 0xc, 0x96, 0x44, 0x56, 0xc0, 0x93}; - uint8_t bytesprops5[] = {0x6b, 0x11, 0xc6, 0x4d, 0x19, 0x84, 0xc4, 0xdb, 0xc5, 0x17, - 0x2b, 0xfe, 0x1b, 0x8a, 0xd1, 0xb6, 0x70, 0x2d, 0x9e, 0xfb}; +uint8_t pkt[] = {0x31, 0x55, 0x0, 0xf, 0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13, 0x42, 0x16, 0x0, 0x18, 0x65, 0x1b, 0x1b, 0x7, 0x14, 0x6f, 0x4, 0xc5, 0x89, 0xd7, 0xdf, 0x3c, 0xc7, 0x27, 0x73, 0x7a, 0x3, 0x4b, 0x77, 0xc3, 0x36, 0x82, 0x13, 0xf4, 0x16, 0x0, 0x2, 0x8a, 0xe4, 0x11, 0x0, 0x0, 0x1e, 0x52, 0x18, 0x0, 0x0, 0x73, 0xf7, 0x15, 0x0, 0x11, 0xfa, 0xba, 0x26, 0xa3, 0x84, 0x73, 0xae, 0xb2, 0x42, 0x74, 0x88, 0xcb, 0x6c, 0xe1, 0x7e, 0x97, 0x24, 0x2a, 0x1d, 0x24, 0xe1, 0xb8}; + uint8_t topic_bytes[] = {0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = true; +uint8_t msg_bytes[] = {0xb8}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 1; + + uint8_t bytesprops0[] = {0x65, 0x1b, 0x1b, 0x7, 0x14, 0x6f, 0x4, 0xc5, 0x89, 0xd7, 0xdf, 0x3c, 0xc7, 0x27, 0x73, 0x7a, 0x3, 0x4b, 0x77, 0xc3, 0x36, 0x82, 0x13, 0xf4}; + uint8_t bytesprops1[] = {0x8a, 0xe4}; + uint8_t bytesprops2[] = {0xfa, 0xba, 0x26, 0xa3, 0x84, 0x73, 0xae, 0xb2, 0x42, 0x74, 0x88, 0xcb, 0x6c, 0xe1, 0x7e, 0x97, 0x24}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27990}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22586}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24325}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7762}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29687}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 225}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 22738, topic, msg, props); + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\157\255\149\212\150\224\139\154J\197\&0C\166\189\203/\179f$J\197-\r\240\SUB\188;\r\173", _pubPktID = 22738, -// _pubBody = "\210\DC1\143z\164\179\bD\DELn", _pubProps = [PropMessageExpiryInterval 27990,PropMaximumPacketSize -// 22586,PropAssignedClientIdentifier "o@Z\207\212\141\233\136\149Yk\178b=\134OgP\ENQ\171_",PropAuthenticationData -// "@6\200\241\163\154\211\181L",PropAuthenticationData "8r\237\205\195\141\167\190\173L",PropAuthenticationData -// "*\149\SYNC\208\FS\145T7oDG\206\213\&1\153\231\&2s\192i\ENQ\FS\170\158|\SYN\ENQ",PropReceiveMaximum -// 24325,PropCorrelationData -// "\128\r\194\188\187\vVbUN_\181\&8\142:\195\236_XF\165\168\CAN\f\150DV\192\147",PropResponseInformation -// "k\DC1\198M\EM\132\196\219\197\ETB+\254\ESC\138\209\182p-\158\251"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3\255\173\206\232\229\219\SOH\SUB\237\217\218}\ENQ\DC3", _pubPktID = 0, _pubBody = "\184", _pubProps = [PropAuthenticationData "e\ESC\ESC\a\DC4o\EOT\197\137\215\223<\199'sz\ETXKw\195\&6\130\DC3\244",PropAuthenticationData "\138\228",PropSessionExpiryInterval 7762,PropWillDelayInterval 29687,PropAuthenticationMethod "\250\186&\163\132s\174\178Bt\136\203l\225~\151$",PropSharedSubscriptionAvailable 29,PropMaximumQoS 225]} TEST(Publish5QCTest, Decode19) { - uint8_t pkt[] = {0x3c, 0xc1, 0x1, 0x0, 0x1d, 0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, 0x43, - 0xa6, 0xbd, 0xcb, 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, 0x3b, 0xd, 0xad, - 0x58, 0xd2, 0x94, 0x1, 0x2, 0x0, 0x0, 0x6d, 0x56, 0x27, 0x0, 0x0, 0x58, 0x3a, 0x12, 0x0, 0x15, - 0x6f, 0x40, 0x5a, 0xcf, 0xd4, 0x8d, 0xe9, 0x88, 0x95, 0x59, 0x6b, 0xb2, 0x62, 0x3d, 0x86, 0x4f, 0x67, - 0x50, 0x5, 0xab, 0x5f, 0x16, 0x0, 0x9, 0x40, 0x36, 0xc8, 0xf1, 0xa3, 0x9a, 0xd3, 0xb5, 0x4c, 0x16, - 0x0, 0xa, 0x38, 0x72, 0xed, 0xcd, 0xc3, 0x8d, 0xa7, 0xbe, 0xad, 0x4c, 0x16, 0x0, 0x1c, 0x2a, 0x95, - 0x16, 0x43, 0xd0, 0x1c, 0x91, 0x54, 0x37, 0x6f, 0x44, 0x47, 0xce, 0xd5, 0x31, 0x99, 0xe7, 0x32, 0x73, - 0xc0, 0x69, 0x5, 0x1c, 0xaa, 0x9e, 0x7c, 0x16, 0x5, 0x21, 0x5f, 0x5, 0x9, 0x0, 0x1d, 0x80, 0xd, - 0xc2, 0xbc, 0xbb, 0xb, 0x56, 0x62, 0x55, 0x4e, 0x5f, 0xb5, 0x38, 0x8e, 0x3a, 0xc3, 0xec, 0x5f, 0x58, - 0x46, 0xa5, 0xa8, 0x18, 0xc, 0x96, 0x44, 0x56, 0xc0, 0x93, 0x1a, 0x0, 0x14, 0x6b, 0x11, 0xc6, 0x4d, - 0x19, 0x84, 0xc4, 0xdb, 0xc5, 0x17, 0x2b, 0xfe, 0x1b, 0x8a, 0xd1, 0xb6, 0x70, 0x2d, 0x9e, 0xfb, 0xd2, - 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x31, 0x55, 0x0, 0xf, 0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13, 0x42, 0x16, 0x0, 0x18, 0x65, 0x1b, 0x1b, 0x7, 0x14, 0x6f, 0x4, 0xc5, 0x89, 0xd7, 0xdf, 0x3c, 0xc7, 0x27, 0x73, 0x7a, 0x3, 0x4b, 0x77, 0xc3, 0x36, 0x82, 0x13, 0xf4, 0x16, 0x0, 0x2, 0x8a, 0xe4, 0x11, 0x0, 0x0, 0x1e, 0x52, 0x18, 0x0, 0x0, 0x73, 0xf7, 0x15, 0x0, 0x11, 0xfa, 0xba, 0x26, 0xa3, 0x84, 0x73, 0xae, 0xb2, 0x42, 0x74, 0x88, 0xcb, 0x6c, 0xe1, 0x7e, 0x97, 0x24, 0x2a, 0x1d, 0x24, 0xe1, 0xb8}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb8}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); +EXPECT_EQ(msg.payload_len, 1); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9d, 0xff, 0x95, 0xd4, 0x96, 0xe0, 0x8b, 0x9a, 0x4a, 0xc5, 0x30, 0x43, 0xa6, 0xbd, 0xcb, - 0x2f, 0xb3, 0x66, 0x24, 0x4a, 0xc5, 0x2d, 0xd, 0xf0, 0x1a, 0xbc, 0x3b, 0xd, 0xad}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd2, 0x11, 0x8f, 0x7a, 0xa4, 0xb3, 0x8, 0x44, 0x7f, 0x6e}; - lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 22738); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 6071, _pubBody = -// "#\140\138\233\171\140\SOH9\165\168kP\138\237?\192\174", _pubProps = [PropSubscriptionIdentifier -// 19,PropCorrelationData -// "\163\146\223\STX\v\158\142\216vy\t\195\168r\DLEQ\201Z\185Lhw@\134\168G\193\190",PropAuthenticationMethod -// "\142{x",PropSharedSubscriptionAvailable 136,PropServerReference -// "\218\183r\155\128\141\192<\182\250\221B\189\ENQ@\195,\RS<\170\161\SI\168",PropUserProperty -// "y@J]\NULg\184\NUL\196Nz\151\STX\153[7\150\EM" -// "\172\CANzCe\244:\165\200P\180\146#\182\202`xq\129L\207\157a=\251[\191V\156",PropRetainAvailable -// 105,PropAssignedClientIdentifier "\167\STX\DELeb\254~\SI",PropSubscriptionIdentifierAvailable 150,PropResponseTopic -// "@\145\EOT$!(\200\DC3%\169",PropReasonString -// "\194\197\175\206\177\131\206?\176\209\128\STXW7\250/\250",PropWildcardSubscriptionAvailable -// 192,PropSubscriptionIdentifier 24,PropSharedSubscriptionAvailable 229,PropTopicAlias 19504,PropTopicAlias -// 5785,PropMessageExpiryInterval 5671,PropTopicAliasMaximum 8296,PropWildcardSubscriptionAvailable -// 156,PropAuthenticationMethod "\136.\180O\203\vUn\185\181\221oS\249lO\208\194>\249\135",PropServerReference -// "\169\&4:\213",PropSharedSubscriptionAvailable 158,PropAssignedClientIdentifier -// "T;\244I\214\197%\170\138\204\211\163R\ACKR]H[$\235Ik\ESC-r",PropTopicAliasMaximum -// 6908,PropSharedSubscriptionAvailable 103,PropAuthenticationMethod -// "\221x\RS\147qG\128\171\239\250\243&\159\226\198\DC1QA\vl\250o\194\195d\145\193"]} +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\134\&2\209f\v\148F\254 \253\tm", _pubPktID = 25649, _pubBody = "!mj\ACK\181\179\t\252S\212\144\149\130\150X", _pubProps = [PropRequestProblemInformation 125,PropMessageExpiryInterval 9893,PropWillDelayInterval 12742,PropContentType "\252\247q\147\&3\229\143\251\206O\238.\149\204C\151\193z\181\239\150G^j\EOTR\150j",PropPayloadFormatIndicator 218,PropServerKeepAlive 17321]} TEST(Publish5QCTest, Encode20) { - uint8_t pkt[] = { - 0x3b, 0xb4, 0x2, 0x0, 0x0, 0x17, 0xb7, 0x9d, 0x2, 0xb, 0x13, 0x9, 0x0, 0x1c, 0xa3, 0x92, 0xdf, 0x2, 0xb, - 0x9e, 0x8e, 0xd8, 0x76, 0x79, 0x9, 0xc3, 0xa8, 0x72, 0x10, 0x51, 0xc9, 0x5a, 0xb9, 0x4c, 0x68, 0x77, 0x40, 0x86, - 0xa8, 0x47, 0xc1, 0xbe, 0x15, 0x0, 0x3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x9e, 0x12, 0x0, 0x19, 0x54, 0x3b, 0xf4, 0x49, 0xd6, 0xc5, 0x25, 0xaa, 0x8a, 0xcc, 0xd3, 0xa3, 0x52, - 0x6, 0x52, 0x5d, 0x48, 0x5b, 0x24, 0xeb, 0x49, 0x6b, 0x1b, 0x2d, 0x72, 0x22, 0x1a, 0xfc, 0x2a, 0x67, 0x15, 0x0, - 0x1b, 0xdd, 0x78, 0x1e, 0x93, 0x71, 0x47, 0x80, 0xab, 0xef, 0xfa, 0xf3, 0x26, 0x9f, 0xe2, 0xc6, 0x11, 0x51, 0x41, - 0xb, 0x6c, 0xfa, 0x6f, 0xc2, 0xc3, 0x64, 0x91, 0xc1, 0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, 0xa8, - 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; +uint8_t pkt[] = {0x3b, 0x50, 0x0, 0xc, 0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d, 0x64, 0x31, 0x30, 0x17, 0x7d, 0x2, 0x0, 0x0, 0x26, 0xa5, 0x18, 0x0, 0x0, 0x31, 0xc6, 0x3, 0x0, 0x1c, 0xfc, 0xf7, 0x71, 0x93, 0x33, 0xe5, 0x8f, 0xfb, 0xce, 0x4f, 0xee, 0x2e, 0x95, 0xcc, 0x43, 0x97, 0xc1, 0x7a, 0xb5, 0xef, 0x96, 0x47, 0x5e, 0x6a, 0x4, 0x52, 0x96, 0x6a, 0x1, 0xda, 0x13, 0x43, 0xa9, 0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; + uint8_t topic_bytes[] = {0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, - 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; - - uint8_t bytesprops0[] = {0xa3, 0x92, 0xdf, 0x2, 0xb, 0x9e, 0x8e, 0xd8, 0x76, 0x79, 0x9, 0xc3, 0xa8, 0x72, - 0x10, 0x51, 0xc9, 0x5a, 0xb9, 0x4c, 0x68, 0x77, 0x40, 0x86, 0xa8, 0x47, 0xc1, 0xbe}; - uint8_t bytesprops1[] = {0x8e, 0x7b, 0x78}; - uint8_t bytesprops2[] = {0xda, 0xb7, 0x72, 0x9b, 0x80, 0x8d, 0xc0, 0x3c, 0xb6, 0xfa, 0xdd, 0x42, - 0xbd, 0x5, 0x40, 0xc3, 0x2c, 0x1e, 0x3c, 0xaa, 0xa1, 0xf, 0xa8}; - uint8_t bytesprops4[] = {0xac, 0x18, 0x7a, 0x43, 0x65, 0xf4, 0x3a, 0xa5, 0xc8, 0x50, 0xb4, 0x92, 0x23, 0xb6, 0xca, - 0x60, 0x78, 0x71, 0x81, 0x4c, 0xcf, 0x9d, 0x61, 0x3d, 0xfb, 0x5b, 0xbf, 0x56, 0x9c}; - uint8_t bytesprops3[] = {0x79, 0x40, 0x4a, 0x5d, 0x0, 0x67, 0xb8, 0x0, 0xc4, - 0x4e, 0x7a, 0x97, 0x2, 0x99, 0x5b, 0x37, 0x96, 0x19}; - uint8_t bytesprops5[] = {0xa7, 0x2, 0x7f, 0x65, 0x62, 0xfe, 0x7e, 0xf}; - uint8_t bytesprops6[] = {0x40, 0x91, 0x4, 0x24, 0x21, 0x28, 0xc8, 0x13, 0x25, 0xa9}; - uint8_t bytesprops7[] = {0xc2, 0xc5, 0xaf, 0xce, 0xb1, 0x83, 0xce, 0x3f, 0xb0, - 0xd1, 0x80, 0x2, 0x57, 0x37, 0xfa, 0x2f, 0xfa}; - uint8_t bytesprops8[] = {0x88, 0x2e, 0xb4, 0x4f, 0xcb, 0xb, 0x55, 0x6e, 0xb9, 0xb5, 0xdd, - 0x6f, 0x53, 0xf9, 0x6c, 0x4f, 0xd0, 0xc2, 0x3e, 0xf9, 0x87}; - uint8_t bytesprops9[] = {0xa9, 0x34, 0x3a, 0xd5}; - uint8_t bytesprops10[] = {0x54, 0x3b, 0xf4, 0x49, 0xd6, 0xc5, 0x25, 0xaa, 0x8a, 0xcc, 0xd3, 0xa3, 0x52, - 0x6, 0x52, 0x5d, 0x48, 0x5b, 0x24, 0xeb, 0x49, 0x6b, 0x1b, 0x2d, 0x72}; - uint8_t bytesprops11[] = {0xdd, 0x78, 0x1e, 0x93, 0x71, 0x47, 0x80, 0xab, 0xef, 0xfa, 0xf3, 0x26, 0x9f, 0xe2, - 0xc6, 0x11, 0x51, 0x41, 0xb, 0x6c, 0xfa, 0x6f, 0xc2, 0xc3, 0x64, 0x91, 0xc1}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 15; + uint8_t bytesprops0[] = {0xfc, 0xf7, 0x71, 0x93, 0x33, 0xe5, 0x8f, 0xfb, 0xce, 0x4f, 0xee, 0x2e, 0x95, 0xcc, 0x43, 0x97, 0xc1, 0x7a, 0xb5, 0xef, 0x96, 0x47, 0x5e, 0x6a, 0x4, 0x52, 0x96, 0x6a}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops3}, .v = {29, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19504}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5785}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5671}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8296}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6908}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9893}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12742}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17321}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6071, topic, msg, props); + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25649, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 6071, _pubBody = -// "#\140\138\233\171\140\SOH9\165\168kP\138\237?\192\174", _pubProps = [PropSubscriptionIdentifier -// 19,PropCorrelationData -// "\163\146\223\STX\v\158\142\216vy\t\195\168r\DLEQ\201Z\185Lhw@\134\168G\193\190",PropAuthenticationMethod -// "\142{x",PropSharedSubscriptionAvailable 136,PropServerReference -// "\218\183r\155\128\141\192<\182\250\221B\189\ENQ@\195,\RS<\170\161\SI\168",PropUserProperty -// "y@J]\NULg\184\NUL\196Nz\151\STX\153[7\150\EM" -// "\172\CANzCe\244:\165\200P\180\146#\182\202`xq\129L\207\157a=\251[\191V\156",PropRetainAvailable -// 105,PropAssignedClientIdentifier "\167\STX\DELeb\254~\SI",PropSubscriptionIdentifierAvailable 150,PropResponseTopic -// "@\145\EOT$!(\200\DC3%\169",PropReasonString -// "\194\197\175\206\177\131\206?\176\209\128\STXW7\250/\250",PropWildcardSubscriptionAvailable -// 192,PropSubscriptionIdentifier 24,PropSharedSubscriptionAvailable 229,PropTopicAlias 19504,PropTopicAlias -// 5785,PropMessageExpiryInterval 5671,PropTopicAliasMaximum 8296,PropWildcardSubscriptionAvailable -// 156,PropAuthenticationMethod "\136.\180O\203\vUn\185\181\221oS\249lO\208\194>\249\135",PropServerReference -// "\169\&4:\213",PropSharedSubscriptionAvailable 158,PropAssignedClientIdentifier -// "T;\244I\214\197%\170\138\204\211\163R\ACKR]H[$\235Ik\ESC-r",PropTopicAliasMaximum -// 6908,PropSharedSubscriptionAvailable 103,PropAuthenticationMethod -// "\221x\RS\147qG\128\171\239\250\243&\159\226\198\DC1QA\vl\250o\194\195d\145\193"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\134\&2\209f\v\148F\254 \253\tm", _pubPktID = 25649, _pubBody = "!mj\ACK\181\179\t\252S\212\144\149\130\150X", _pubProps = [PropRequestProblemInformation 125,PropMessageExpiryInterval 9893,PropWillDelayInterval 12742,PropContentType "\252\247q\147\&3\229\143\251\206O\238.\149\204C\151\193z\181\239\150G^j\EOTR\150j",PropPayloadFormatIndicator 218,PropServerKeepAlive 17321]} TEST(Publish5QCTest, Decode20) { - uint8_t pkt[] = { - 0x3b, 0xb4, 0x2, 0x0, 0x0, 0x17, 0xb7, 0x9d, 0x2, 0xb, 0x13, 0x9, 0x0, 0x1c, 0xa3, 0x92, 0xdf, 0x2, 0xb, - 0x9e, 0x8e, 0xd8, 0x76, 0x79, 0x9, 0xc3, 0xa8, 0x72, 0x10, 0x51, 0xc9, 0x5a, 0xb9, 0x4c, 0x68, 0x77, 0x40, 0x86, - 0xa8, 0x47, 0xc1, 0xbe, 0x15, 0x0, 0x3, 0x8e, 0x7b, 0x78, 0x2a, 0x88, 0x1c, 0x0, 0x17, 0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 0xc5, 0x25, 0xaa, 0x8a, 0xcc, 0xd3, 0xa3, 0x52, - 0x6, 0x52, 0x5d, 0x48, 0x5b, 0x24, 0xeb, 0x49, 0x6b, 0x1b, 0x2d, 0x72, 0x22, 0x1a, 0xfc, 0x2a, 0x67, 0x15, 0x0, - 0x1b, 0xdd, 0x78, 0x1e, 0x93, 0x71, 0x47, 0x80, 0xab, 0xef, 0xfa, 0xf3, 0x26, 0x9f, 0xe2, 0xc6, 0x11, 0x51, 0x41, - 0xb, 0x6c, 0xfa, 0x6f, 0xc2, 0xc3, 0x64, 0x91, 0xc1, 0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, 0xa8, - 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3b, 0x50, 0x0, 0xc, 0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d, 0x64, 0x31, 0x30, 0x17, 0x7d, 0x2, 0x0, 0x0, 0x26, 0xa5, 0x18, 0x0, 0x0, 0x31, 0xc6, 0x3, 0x0, 0x1c, 0xfc, 0xf7, 0x71, 0x93, 0x33, 0xe5, 0x8f, 0xfb, 0xce, 0x4f, 0xee, 0x2e, 0x95, 0xcc, 0x43, 0x97, 0xc1, 0x7a, 0xb5, 0xef, 0x96, 0x47, 0x5e, 0x6a, 0x4, 0x52, 0x96, 0x6a, 0x1, 0xda, 0x13, 0x43, 0xa9, 0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 25649); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); +EXPECT_EQ(msg.payload_len, 15); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x23, 0x8c, 0x8a, 0xe9, 0xab, 0x8c, 0x1, 0x39, 0xa5, - 0xa8, 0x6b, 0x50, 0x8a, 0xed, 0x3f, 0xc0, 0xae}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 6071); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "(topic.data), 2); +EXPECT_EQ(msg.payload_len, 3); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3c, 0x6d, 0x39}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb0, 0x85, 0xcb, 0x4a, 0x93, 0x41, 0xf0, 0x4b, 0xb9, 0x6b, 0x91, 0x3a, 0x22, - 0xea, 0xfc, 0xe2, 0xf8, 0x57, 0x7c, 0xda, 0xb, 0xf8, 0x2a, 0xa, 0x16}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 5951); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 29931, _pubBody = -// "\254t\DLE\GS|r\CAN\243)\RS\151\DC4/_\229b\\", _pubProps = [PropRequestProblemInformation -// 181,PropRequestResponseInformation 73,PropReceiveMaximum 30707,PropMessageExpiryInterval -// 19377,PropSessionExpiryInterval 22687,PropServerKeepAlive 23724,PropSharedSubscriptionAvailable -// 139,PropAuthenticationData "\217O<",PropWillDelayInterval 11547,PropContentType "<\fe\147(m]7",PropMaximumQoS -// 198,PropRequestResponseInformation 184,PropRequestResponseInformation 172,PropAssignedClientIdentifier -// "\247\250\229\235_\DLE\190\NAK\165\240\164\222aT\165~](\247",PropAssignedClientIdentifier -// "\185U\164\245\ACKeK\227N\157\166",PropMaximumQoS 191,PropRequestProblemInformation 2,PropContentType -// "\149\149\DC2\244\197\150\252M@\215\180\220_Z\140\&4\236\143CV\188\SYN\166",PropWildcardSubscriptionAvailable -// 154,PropUserProperty "\183\215\247~R0\158\GS\154\&8" -// "\202\181\GS\218\169!sB\248\r\SOF\197\178\246\188ai\252\175\SOJ\248",PropRequestProblemInformation -// 50,PropSubscriptionIdentifier 0,PropMaximumPacketSize 14544,PropAuthenticationData -// "y\135\&3`0\210\216h",PropUserProperty "\246o\197\SUB\228\224\224" -// "n\144)\182\215\251:\SO\189;\144\194\r\190b*\201u\DC4\183\225\160\GS\128",PropWillDelayInterval 15728]} -TEST(Publish5QCTest, Encode22) { - uint8_t pkt[] = { - 0x3c, 0xf0, 0x1, 0x0, 0x0, 0x74, 0xeb, 0xd9, 0x1, 0x17, 0xb5, 0x19, 0x49, 0x21, 0x77, 0xf3, 0x2, 0x0, 0x0, - 0x4b, 0xb1, 0x11, 0x0, 0x0, 0x58, 0x9f, 0x13, 0x5c, 0xac, 0x2a, 0x8b, 0x16, 0x0, 0x3, 0xd9, 0x4f, 0x3c, 0x18, - 0x0, 0x0, 0x2d, 0x1b, 0x3, 0x0, 0x8, 0x3c, 0xc, 0x65, 0x93, 0x28, 0x6d, 0x5d, 0x37, 0x24, 0xc6, 0x19, 0xb8, - 0x19, 0xac, 0x12, 0x0, 0x13, 0xf7, 0xfa, 0xe5, 0xeb, 0x5f, 0x10, 0xbe, 0x15, 0xa5, 0xf0, 0xa4, 0xde, 0x61, 0x54, - 0xa5, 0x7e, 0x5d, 0x28, 0xf7, 0x12, 0x0, 0xb, 0xb9, 0x55, 0xa4, 0xf5, 0x6, 0x65, 0x4b, 0xe3, 0x4e, 0x9d, 0xa6, - 0x24, 0xbf, 0x17, 0x2, 0x3, 0x0, 0x17, 0x95, 0x95, 0x12, 0xf4, 0xc5, 0x96, 0xfc, 0x4d, 0x40, 0xd7, 0xb4, 0xdc, - 0x5f, 0x5a, 0x8c, 0x34, 0xec, 0x8f, 0x43, 0x56, 0xbc, 0x16, 0xa6, 0x28, 0x9a, 0x26, 0x0, 0xa, 0xb7, 0xd7, 0xf7, - 0x7e, 0x52, 0x30, 0x9e, 0x1d, 0x9a, 0x38, 0x0, 0x17, 0xca, 0xb5, 0x1d, 0xda, 0xa9, 0x21, 0x73, 0x42, 0xf8, 0xd, - 0xe, 0x46, 0xc5, 0xb2, 0xf6, 0xbc, 0x61, 0x69, 0xfc, 0xaf, 0xe, 0x4a, 0xf8, 0x17, 0x32, 0xb, 0x0, 0x27, 0x0, - 0x0, 0x38, 0xd0, 0x16, 0x0, 0x8, 0x79, 0x87, 0x33, 0x60, 0x30, 0xd2, 0xd8, 0x68, 0x26, 0x0, 0x7, 0xf6, 0x6f, - 0xc5, 0x1a, 0xe4, 0xe0, 0xe0, 0x0, 0x18, 0x6e, 0x90, 0x29, 0xb6, 0xd7, 0xfb, 0x3a, 0xe, 0xbd, 0x3b, 0x90, 0xc2, - 0xd, 0xbe, 0x62, 0x2a, 0xc9, 0x75, 0x14, 0xb7, 0xe1, 0xa0, 0x1d, 0x80, 0x18, 0x0, 0x0, 0x3d, 0x70, 0xfe, 0x74, - 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, - 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; - - uint8_t bytesprops0[] = {0xd9, 0x4f, 0x3c}; - uint8_t bytesprops1[] = {0x3c, 0xc, 0x65, 0x93, 0x28, 0x6d, 0x5d, 0x37}; - uint8_t bytesprops2[] = {0xf7, 0xfa, 0xe5, 0xeb, 0x5f, 0x10, 0xbe, 0x15, 0xa5, 0xf0, - 0xa4, 0xde, 0x61, 0x54, 0xa5, 0x7e, 0x5d, 0x28, 0xf7}; - uint8_t bytesprops3[] = {0xb9, 0x55, 0xa4, 0xf5, 0x6, 0x65, 0x4b, 0xe3, 0x4e, 0x9d, 0xa6}; - uint8_t bytesprops4[] = {0x95, 0x95, 0x12, 0xf4, 0xc5, 0x96, 0xfc, 0x4d, 0x40, 0xd7, 0xb4, 0xdc, - 0x5f, 0x5a, 0x8c, 0x34, 0xec, 0x8f, 0x43, 0x56, 0xbc, 0x16, 0xa6}; - uint8_t bytesprops6[] = {0xca, 0xb5, 0x1d, 0xda, 0xa9, 0x21, 0x73, 0x42, 0xf8, 0xd, 0xe, 0x46, - 0xc5, 0xb2, 0xf6, 0xbc, 0x61, 0x69, 0xfc, 0xaf, 0xe, 0x4a, 0xf8}; - uint8_t bytesprops5[] = {0xb7, 0xd7, 0xf7, 0x7e, 0x52, 0x30, 0x9e, 0x1d, 0x9a, 0x38}; - uint8_t bytesprops7[] = {0x79, 0x87, 0x33, 0x60, 0x30, 0xd2, 0xd8, 0x68}; - uint8_t bytesprops9[] = {0x6e, 0x90, 0x29, 0xb6, 0xd7, 0xfb, 0x3a, 0xe, 0xbd, 0x3b, 0x90, 0xc2, - 0xd, 0xbe, 0x62, 0x2a, 0xc9, 0x75, 0x14, 0xb7, 0xe1, 0xa0, 0x1d, 0x80}; - uint8_t bytesprops8[] = {0xf6, 0x6f, 0xc5, 0x1a, 0xe4, 0xe0, 0xe0}; +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "<\t\"\209\184\182u\179\DLE\NAK\195\141\EM\237\189}\143\EOT\STX\188|\188\t\USv\US\209\"\STX", _pubPktID = 17374, _pubBody = "\"=\237\FS\247\238\129>oH\131~\158k\231\193}\194\ESCu", _pubProps = [PropWillDelayInterval 30493,PropResponseTopic "G\239\184\133\ETB~j'_\181t\194\148\221\231\SUB+\166\231\ETB\171\t,",PropWillDelayInterval 8185,PropContentType "[4:\219Gf\160\206\208qv\232\159\&8\190\211`\253\192\182\213\t",PropAssignedClientIdentifier "\145nCH\170\200\198[\135\249X\255\214\132\137(\234\179\223\190",PropSharedSubscriptionAvailable 64,PropMessageExpiryInterval 432,PropSubscriptionIdentifier 5,PropRetainAvailable 204,PropRequestResponseInformation 110,PropResponseTopic "\194\237\206\ACKh\ACK\132)\172\t\174\206\189\192,\161",PropRequestProblemInformation 68,PropSubscriptionIdentifierAvailable 215,PropReasonString "\DC1\168\133\202\NUL\146\148=\ACKg\172:\FSr\140\139\DC4\134\208\209\USR",PropUserProperty "\ENQ\255\SOHm\177\154f\207\198\147\186{tO\\z0\232\155\233\186\169\230" "\140\199",PropSessionExpiryInterval 30860,PropSessionExpiryInterval 31114,PropPayloadFormatIndicator 25,PropAssignedClientIdentifier "z=>'\171\235\192{\133AbA\172\178\175+\213\137a\r@",PropPayloadFormatIndicator 106,PropRequestResponseInformation 81,PropServerReference "1\162\156\135\224\162\243\243\216:{v;\213\204^\160\219\193\a\138\228OX\240C\150",PropCorrelationData "\f\179\FSBM"]} +TEST(Publish5QCTest, Encode22) { +uint8_t pkt[] = {0x3a, 0xb4, 0x2, 0x0, 0x1d, 0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2, 0x43, 0xde, 0xfd, 0x1, 0x18, 0x0, 0x0, 0x77, 0x1d, 0x8, 0x0, 0x17, 0x47, 0xef, 0xb8, 0x85, 0x17, 0x7e, 0x6a, 0x27, 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, 0x2b, 0xd5, 0x89, 0x61, 0xd, 0x40, 0x1, 0x6a, 0x19, 0x51, 0x1c, 0x0, 0x1b, 0x31, 0xa2, 0x9c, 0x87, 0xe0, 0xa2, 0xf3, 0xf3, 0xd8, 0x3a, 0x7b, 0x76, 0x3b, 0xd5, 0xcc, 0x5e, 0xa0, 0xdb, 0xc1, 0x7, 0x8a, 0xe4, 0x4f, 0x58, 0xf0, 0x43, 0x96, 0x9, 0x0, 0x5, 0xc, 0xb3, 0x1c, 0x42, 0x4d, 0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; + uint8_t topic_bytes[] = {0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = false; +uint8_t msg_bytes[] = {0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 20; + + uint8_t bytesprops0[] = {0x47, 0xef, 0xb8, 0x85, 0x17, 0x7e, 0x6a, 0x27, 0x5f, 0xb5, 0x74, 0xc2, 0x94, 0xdd, 0xe7, 0x1a, 0x2b, 0xa6, 0xe7, 0x17, 0xab, 0x9, 0x2c}; + uint8_t bytesprops1[] = {0x5b, 0x34, 0x3a, 0xdb, 0x47, 0x66, 0xa0, 0xce, 0xd0, 0x71, 0x76, 0xe8, 0x9f, 0x38, 0xbe, 0xd3, 0x60, 0xfd, 0xc0, 0xb6, 0xd5, 0x9}; + uint8_t bytesprops2[] = {0x91, 0x6e, 0x43, 0x48, 0xaa, 0xc8, 0xc6, 0x5b, 0x87, 0xf9, 0x58, 0xff, 0xd6, 0x84, 0x89, 0x28, 0xea, 0xb3, 0xdf, 0xbe}; + uint8_t bytesprops3[] = {0xc2, 0xed, 0xce, 0x6, 0x68, 0x6, 0x84, 0x29, 0xac, 0x9, 0xae, 0xce, 0xbd, 0xc0, 0x2c, 0xa1}; + uint8_t bytesprops4[] = {0x11, 0xa8, 0x85, 0xca, 0x0, 0x92, 0x94, 0x3d, 0x6, 0x67, 0xac, 0x3a, 0x1c, 0x72, 0x8c, 0x8b, 0x14, 0x86, 0xd0, 0xd1, 0x1f, 0x52}; + uint8_t bytesprops6[] = {0x8c, 0xc7}; + uint8_t bytesprops5[] = {0x5, 0xff, 0x1, 0x6d, 0xb1, 0x9a, 0x66, 0xcf, 0xc6, 0x93, 0xba, 0x7b, 0x74, 0x4f, 0x5c, 0x7a, 0x30, 0xe8, 0x9b, 0xe9, 0xba, 0xa9, 0xe6}; + uint8_t bytesprops7[] = {0x7a, 0x3d, 0x3e, 0x27, 0xab, 0xeb, 0xc0, 0x7b, 0x85, 0x41, 0x62, 0x41, 0xac, 0xb2, 0xaf, 0x2b, 0xd5, 0x89, 0x61, 0xd, 0x40}; + uint8_t bytesprops8[] = {0x31, 0xa2, 0x9c, 0x87, 0xe0, 0xa2, 0xf3, 0xf3, 0xd8, 0x3a, 0x7b, 0x76, 0x3b, 0xd5, 0xcc, 0x5e, 0xa0, 0xdb, 0xc1, 0x7, 0x8a, 0xe4, 0x4f, 0x58, 0xf0, 0x43, 0x96}; + uint8_t bytesprops9[] = {0xc, 0xb3, 0x1c, 0x42, 0x4d}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30707}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19377}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22687}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23724}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11547}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops5}, .v = {23, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14544}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops8}, .v = {24, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15728}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30493}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8185}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 432}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={23, (char*)&bytesprops5}, .v={2, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30860}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31114}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 29931, topic, msg, props); + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 17374, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 29931, _pubBody = -// "\254t\DLE\GS|r\CAN\243)\RS\151\DC4/_\229b\\", _pubProps = [PropRequestProblemInformation -// 181,PropRequestResponseInformation 73,PropReceiveMaximum 30707,PropMessageExpiryInterval -// 19377,PropSessionExpiryInterval 22687,PropServerKeepAlive 23724,PropSharedSubscriptionAvailable -// 139,PropAuthenticationData "\217O<",PropWillDelayInterval 11547,PropContentType "<\fe\147(m]7",PropMaximumQoS -// 198,PropRequestResponseInformation 184,PropRequestResponseInformation 172,PropAssignedClientIdentifier -// "\247\250\229\235_\DLE\190\NAK\165\240\164\222aT\165~](\247",PropAssignedClientIdentifier -// "\185U\164\245\ACKeK\227N\157\166",PropMaximumQoS 191,PropRequestProblemInformation 2,PropContentType -// "\149\149\DC2\244\197\150\252M@\215\180\220_Z\140\&4\236\143CV\188\SYN\166",PropWildcardSubscriptionAvailable -// 154,PropUserProperty "\183\215\247~R0\158\GS\154\&8" -// "\202\181\GS\218\169!sB\248\r\SOF\197\178\246\188ai\252\175\SOJ\248",PropRequestProblemInformation -// 50,PropSubscriptionIdentifier 0,PropMaximumPacketSize 14544,PropAuthenticationData -// "y\135\&3`0\210\216h",PropUserProperty "\246o\197\SUB\228\224\224" -// "n\144)\182\215\251:\SO\189;\144\194\r\190b*\201u\DC4\183\225\160\GS\128",PropWillDelayInterval 15728]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "<\t\"\209\184\182u\179\DLE\NAK\195\141\EM\237\189}\143\EOT\STX\188|\188\t\USv\US\209\"\STX", _pubPktID = 17374, _pubBody = "\"=\237\FS\247\238\129>oH\131~\158k\231\193}\194\ESCu", _pubProps = [PropWillDelayInterval 30493,PropResponseTopic "G\239\184\133\ETB~j'_\181t\194\148\221\231\SUB+\166\231\ETB\171\t,",PropWillDelayInterval 8185,PropContentType "[4:\219Gf\160\206\208qv\232\159\&8\190\211`\253\192\182\213\t",PropAssignedClientIdentifier "\145nCH\170\200\198[\135\249X\255\214\132\137(\234\179\223\190",PropSharedSubscriptionAvailable 64,PropMessageExpiryInterval 432,PropSubscriptionIdentifier 5,PropRetainAvailable 204,PropRequestResponseInformation 110,PropResponseTopic "\194\237\206\ACKh\ACK\132)\172\t\174\206\189\192,\161",PropRequestProblemInformation 68,PropSubscriptionIdentifierAvailable 215,PropReasonString "\DC1\168\133\202\NUL\146\148=\ACKg\172:\FSr\140\139\DC4\134\208\209\USR",PropUserProperty "\ENQ\255\SOHm\177\154f\207\198\147\186{tO\\z0\232\155\233\186\169\230" "\140\199",PropSessionExpiryInterval 30860,PropSessionExpiryInterval 31114,PropPayloadFormatIndicator 25,PropAssignedClientIdentifier "z=>'\171\235\192{\133AbA\172\178\175+\213\137a\r@",PropPayloadFormatIndicator 106,PropRequestResponseInformation 81,PropServerReference "1\162\156\135\224\162\243\243\216:{v;\213\204^\160\219\193\a\138\228OX\240C\150",PropCorrelationData "\f\179\FSBM"]} TEST(Publish5QCTest, Decode22) { - uint8_t pkt[] = { - 0x3c, 0xf0, 0x1, 0x0, 0x0, 0x74, 0xeb, 0xd9, 0x1, 0x17, 0xb5, 0x19, 0x49, 0x21, 0x77, 0xf3, 0x2, 0x0, 0x0, - 0x4b, 0xb1, 0x11, 0x0, 0x0, 0x58, 0x9f, 0x13, 0x5c, 0xac, 0x2a, 0x8b, 0x16, 0x0, 0x3, 0xd9, 0x4f, 0x3c, 0x18, - 0x0, 0x0, 0x2d, 0x1b, 0x3, 0x0, 0x8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 0x7c, 0x72, 0x18, 0xf3, 0x29, 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x3a, 0xb4, 0x2, 0x0, 0x1d, 0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2, 0x43, 0xde, 0xfd, 0x1, 0x18, 0x0, 0x0, 0x77, 0x1d, 0x8, 0x0, 0x17, 0x47, 0xef, 0xb8, 0x85, 0x17, 0x7e, 0x6a, 0x27, 0x5f, 0xb5, 0x74, 0xc2, 0x94, 0xdd, 0xe7, 0x1a, 0x2b, 0xa6, 0xe7, 0x17, 0xab, 0x9, 0x2c, 0x18, 0x0, 0x0, 0x1f, 0xf9, 0x3, 0x0, 0x16, 0x5b, 0x34, 0x3a, 0xdb, 0x47, 0x66, 0xa0, 0xce, 0xd0, 0x71, 0x76, 0xe8, 0x9f, 0x38, 0xbe, 0xd3, 0x60, 0xfd, 0xc0, 0xb6, 0xd5, 0x9, 0x12, 0x0, 0x14, 0x91, 0x6e, 0x43, 0x48, 0xaa, 0xc8, 0xc6, 0x5b, 0x87, 0xf9, 0x58, 0xff, 0xd6, 0x84, 0x89, 0x28, 0xea, 0xb3, 0xdf, 0xbe, 0x2a, 0x40, 0x2, 0x0, 0x0, 0x1, 0xb0, 0xb, 0x5, 0x25, 0xcc, 0x19, 0x6e, 0x8, 0x0, 0x10, 0xc2, 0xed, 0xce, 0x6, 0x68, 0x6, 0x84, 0x29, 0xac, 0x9, 0xae, 0xce, 0xbd, 0xc0, 0x2c, 0xa1, 0x17, 0x44, 0x29, 0xd7, 0x1f, 0x0, 0x16, 0x11, 0xa8, 0x85, 0xca, 0x0, 0x92, 0x94, 0x3d, 0x6, 0x67, 0xac, 0x3a, 0x1c, 0x72, 0x8c, 0x8b, 0x14, 0x86, 0xd0, 0xd1, 0x1f, 0x52, 0x26, 0x0, 0x17, 0x5, 0xff, 0x1, 0x6d, 0xb1, 0x9a, 0x66, 0xcf, 0xc6, 0x93, 0xba, 0x7b, 0x74, 0x4f, 0x5c, 0x7a, 0x30, 0xe8, 0x9b, 0xe9, 0xba, 0xa9, 0xe6, 0x0, 0x2, 0x8c, 0xc7, 0x11, 0x0, 0x0, 0x78, 0x8c, 0x11, 0x0, 0x0, 0x79, 0x8a, 0x1, 0x19, 0x12, 0x0, 0x15, 0x7a, 0x3d, 0x3e, 0x27, 0xab, 0xeb, 0xc0, 0x7b, 0x85, 0x41, 0x62, 0x41, 0xac, 0xb2, 0xaf, 0x2b, 0xd5, 0x89, 0x61, 0xd, 0x40, 0x1, 0x6a, 0x19, 0x51, 0x1c, 0x0, 0x1b, 0x31, 0xa2, 0x9c, 0x87, 0xe0, 0xa2, 0xf3, 0xf3, 0xd8, 0x3a, 0x7b, 0x76, 0x3b, 0xd5, 0xcc, 0x5e, 0xa0, 0xdb, 0xc1, 0x7, 0x8a, 0xe4, 0x4f, 0x58, 0xf0, 0x43, 0x96, 0x9, 0x0, 0x5, 0xc, 0xb3, 0x1c, 0x42, 0x4d, 0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 17374); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); +EXPECT_EQ(msg.payload_len, 20); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfe, 0x74, 0x10, 0x1d, 0x7c, 0x72, 0x18, 0xf3, 0x29, - 0x1e, 0x97, 0x14, 0x2f, 0x5f, 0xe5, 0x62, 0x5c}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 29931); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\128\158-GrC\129\166\140\231\NULj!M4\SUB", _pubPktID = 0, _pubBody = -// "\228\ESC\231\DC3\136\217\177W_\ESCp\130\DC2\212,\158\236\215\204\207m\205", _pubProps = -// [PropRequestProblemInformation 64,PropAuthenticationData -// "\133\236\132T\RS\149\164\140f\220\200\200",PropServerReference "\138s\200\181\144r\224\190C+;",PropContentType -// "\t\153\142ji\206\236\156$*\136\DC4\n\202(\172xCXc\204",PropMaximumQoS 114,PropRetainAvailable -// 94,PropSessionExpiryInterval 24598,PropAssignedClientIdentifier -// "`\202\237]t\131\179M\226\218\250\160)\227\167\&0\154\n\DC2]\DLE\US\150?\234B\239\139\242",PropWillDelayInterval -// 28070,PropSessionExpiryInterval 12851,PropMaximumQoS 89,PropRequestResponseInformation 13,PropTopicAlias -// 13547,PropSessionExpiryInterval 10014,PropSessionExpiryInterval 19691,PropAuthenticationMethod -// "\198<\129\214\246",PropSessionExpiryInterval 12398,PropMessageExpiryInterval 29590,PropRequestProblemInformation -// 102,PropServerKeepAlive 12804,PropSubscriptionIdentifierAvailable 177,PropServerReference "\175",PropServerKeepAlive -// 16845]} +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "L\250\DC3", _pubPktID = 6223, _pubBody = ".K\236\242\210\250\192\219\175h\175p\249", _pubProps = [PropSessionExpiryInterval 21695,PropSubscriptionIdentifierAvailable 48,PropUserProperty "h\160\209\172\SYN\ENQ\165\230=\215\207\137\244\DC3\NUL|\145\&6\153\193\140~f\SI\246/" "\231u2\n-\196\188\203F",PropServerKeepAlive 11554,PropAssignedClientIdentifier "\243\&8]\161ZF\r\166\198el\182",PropCorrelationData "\a_\228\&3Ve<\FS[i\238\r\169\188y\187\FS0\145o_8\160t\186",PropResponseInformation "\189\FS\136\EM7\131T\SUB\239\167\221\232\tA\ETX\235n\205",PropTopicAliasMaximum 25457,PropWildcardSubscriptionAvailable 204,PropTopicAliasMaximum 32590,PropPayloadFormatIndicator 81,PropMessageExpiryInterval 27542,PropRequestResponseInformation 163,PropCorrelationData "K\240\248\217\EMt\176\249y\177\DC4\ENQ\134\198\&21\200\NAK\155",PropPayloadFormatIndicator 193,PropServerKeepAlive 20073,PropSubscriptionIdentifierAvailable 37,PropTopicAliasMaximum 7907,PropSessionExpiryInterval 4906]} TEST(Publish5QCTest, Encode23) { - uint8_t pkt[] = {0x31, 0xc5, 0x1, 0x0, 0x10, 0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, 0x8c, 0xe7, 0x0, 0x6a, - 0x21, 0x4d, 0x34, 0x1a, 0x9b, 0x1, 0x17, 0x40, 0x16, 0x0, 0xc, 0x85, 0xec, 0x84, 0x54, 0x1e, 0x95, - 0xa4, 0x8c, 0x66, 0xdc, 0xc8, 0xc8, 0x1c, 0x0, 0xb, 0x8a, 0x73, 0xc8, 0xb5, 0x90, 0x72, 0xe0, 0xbe, - 0x43, 0x2b, 0x3b, 0x3, 0x0, 0x15, 0x9, 0x99, 0x8e, 0x6a, 0x69, 0xce, 0xec, 0x9c, 0x24, 0x2a, 0x88, - 0x14, 0xa, 0xca, 0x28, 0xac, 0x78, 0x43, 0x58, 0x63, 0xcc, 0x24, 0x72, 0x25, 0x5e, 0x11, 0x0, 0x0, - 0x60, 0x16, 0x12, 0x0, 0x1d, 0x60, 0xca, 0xed, 0x5d, 0x74, 0x83, 0xb3, 0x4d, 0xe2, 0xda, 0xfa, 0xa0, - 0x29, 0xe3, 0xa7, 0x30, 0x9a, 0xa, 0x12, 0x5d, 0x10, 0x1f, 0x96, 0x3f, 0xea, 0x42, 0xef, 0x8b, 0xf2, - 0x18, 0x0, 0x0, 0x6d, 0xa6, 0x11, 0x0, 0x0, 0x32, 0x33, 0x24, 0x59, 0x19, 0xd, 0x23, 0x34, 0xeb, - 0x11, 0x0, 0x0, 0x27, 0x1e, 0x11, 0x0, 0x0, 0x4c, 0xeb, 0x15, 0x0, 0x5, 0xc6, 0x3c, 0x81, 0xd6, - 0xf6, 0x11, 0x0, 0x0, 0x30, 0x6e, 0x2, 0x0, 0x0, 0x73, 0x96, 0x17, 0x66, 0x13, 0x32, 0x4, 0x29, - 0xb1, 0x1c, 0x0, 0x1, 0xaf, 0x13, 0x41, 0xcd, 0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, - 0x1b, 0x70, 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; - uint8_t topic_bytes[] = {0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, - 0x8c, 0xe7, 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, 0x1b, 0x70, - 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; - - uint8_t bytesprops0[] = {0x85, 0xec, 0x84, 0x54, 0x1e, 0x95, 0xa4, 0x8c, 0x66, 0xdc, 0xc8, 0xc8}; - uint8_t bytesprops1[] = {0x8a, 0x73, 0xc8, 0xb5, 0x90, 0x72, 0xe0, 0xbe, 0x43, 0x2b, 0x3b}; - uint8_t bytesprops2[] = {0x9, 0x99, 0x8e, 0x6a, 0x69, 0xce, 0xec, 0x9c, 0x24, 0x2a, 0x88, - 0x14, 0xa, 0xca, 0x28, 0xac, 0x78, 0x43, 0x58, 0x63, 0xcc}; - uint8_t bytesprops3[] = {0x60, 0xca, 0xed, 0x5d, 0x74, 0x83, 0xb3, 0x4d, 0xe2, 0xda, 0xfa, 0xa0, 0x29, 0xe3, 0xa7, - 0x30, 0x9a, 0xa, 0x12, 0x5d, 0x10, 0x1f, 0x96, 0x3f, 0xea, 0x42, 0xef, 0x8b, 0xf2}; - uint8_t bytesprops4[] = {0xc6, 0x3c, 0x81, 0xd6, 0xf6}; - uint8_t bytesprops5[] = {0xaf}; +uint8_t pkt[] = {0x35, 0xbe, 0x1, 0x0, 0x3, 0x4c, 0xfa, 0x13, 0x18, 0x4f, 0xa8, 0x1, 0x11, 0x0, 0x0, 0x54, 0xbf, 0x29, 0x30, 0x26, 0x0, 0x1a, 0x68, 0xa0, 0xd1, 0xac, 0x16, 0x5, 0xa5, 0xe6, 0x3d, 0xd7, 0xcf, 0x89, 0xf4, 0x13, 0x0, 0x7c, 0x91, 0x36, 0x99, 0xc1, 0x8c, 0x7e, 0x66, 0xf, 0xf6, 0x2f, 0x0, 0x9, 0xe7, 0x75, 0x32, 0xa, 0x2d, 0xc4, 0xbc, 0xcb, 0x46, 0x13, 0x2d, 0x22, 0x12, 0x0, 0xc, 0xf3, 0x38, 0x5d, 0xa1, 0x5a, 0x46, 0xd, 0xa6, 0xc6, 0x65, 0x6c, 0xb6, 0x9, 0x0, 0x19, 0x7, 0x5f, 0xe4, 0x33, 0x56, 0x65, 0x3c, 0x1c, 0x5b, 0x69, 0xee, 0xd, 0xa9, 0xbc, 0x79, 0xbb, 0x1c, 0x30, 0x91, 0x6f, 0x5f, 0x38, 0xa0, 0x74, 0xba, 0x1a, 0x0, 0x12, 0xbd, 0x1c, 0x88, 0x19, 0x37, 0x83, 0x54, 0x1a, 0xef, 0xa7, 0xdd, 0xe8, 0x9, 0x41, 0x3, 0xeb, 0x6e, 0xcd, 0x22, 0x63, 0x71, 0x28, 0xcc, 0x22, 0x7f, 0x4e, 0x1, 0x51, 0x2, 0x0, 0x0, 0x6b, 0x96, 0x19, 0xa3, 0x9, 0x0, 0x13, 0x4b, 0xf0, 0xf8, 0xd9, 0x19, 0x74, 0xb0, 0xf9, 0x79, 0xb1, 0x14, 0x5, 0x86, 0xc6, 0x32, 0x31, 0xc8, 0x15, 0x9b, 0x1, 0xc1, 0x13, 0x4e, 0x69, 0x29, 0x25, 0x22, 0x1e, 0xe3, 0x11, 0x0, 0x0, 0x13, 0x2a, 0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; + uint8_t topic_bytes[] = {0x4c, 0xfa, 0x13}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = true; +uint8_t msg_bytes[] = {0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 13; + + uint8_t bytesprops1[] = {0xe7, 0x75, 0x32, 0xa, 0x2d, 0xc4, 0xbc, 0xcb, 0x46}; + uint8_t bytesprops0[] = {0x68, 0xa0, 0xd1, 0xac, 0x16, 0x5, 0xa5, 0xe6, 0x3d, 0xd7, 0xcf, 0x89, 0xf4, 0x13, 0x0, 0x7c, 0x91, 0x36, 0x99, 0xc1, 0x8c, 0x7e, 0x66, 0xf, 0xf6, 0x2f}; + uint8_t bytesprops2[] = {0xf3, 0x38, 0x5d, 0xa1, 0x5a, 0x46, 0xd, 0xa6, 0xc6, 0x65, 0x6c, 0xb6}; + uint8_t bytesprops3[] = {0x7, 0x5f, 0xe4, 0x33, 0x56, 0x65, 0x3c, 0x1c, 0x5b, 0x69, 0xee, 0xd, 0xa9, 0xbc, 0x79, 0xbb, 0x1c, 0x30, 0x91, 0x6f, 0x5f, 0x38, 0xa0, 0x74, 0xba}; + uint8_t bytesprops4[] = {0xbd, 0x1c, 0x88, 0x19, 0x37, 0x83, 0x54, 0x1a, 0xef, 0xa7, 0xdd, 0xe8, 0x9, 0x41, 0x3, 0xeb, 0x6e, 0xcd}; + uint8_t bytesprops5[] = {0x4b, 0xf0, 0xf8, 0xd9, 0x19, 0x74, 0xb0, 0xf9, 0x79, 0xb1, 0x14, 0x5, 0x86, 0xc6, 0x32, 0x31, 0xc8, 0x15, 0x9b}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24598}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28070}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12851}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13547}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10014}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19691}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12398}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29590}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12804}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16845}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21695}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={26, (char*)&bytesprops0}, .v={9, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11554}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25457}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32590}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27542}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20073}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7907}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4906}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 6223, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\128\158-GrC\129\166\140\231\NULj!M4\SUB", _pubPktID = 0, _pubBody = -// "\228\ESC\231\DC3\136\217\177W_\ESCp\130\DC2\212,\158\236\215\204\207m\205", _pubProps = -// [PropRequestProblemInformation 64,PropAuthenticationData -// "\133\236\132T\RS\149\164\140f\220\200\200",PropServerReference "\138s\200\181\144r\224\190C+;",PropContentType -// "\t\153\142ji\206\236\156$*\136\DC4\n\202(\172xCXc\204",PropMaximumQoS 114,PropRetainAvailable -// 94,PropSessionExpiryInterval 24598,PropAssignedClientIdentifier -// "`\202\237]t\131\179M\226\218\250\160)\227\167\&0\154\n\DC2]\DLE\US\150?\234B\239\139\242",PropWillDelayInterval -// 28070,PropSessionExpiryInterval 12851,PropMaximumQoS 89,PropRequestResponseInformation 13,PropTopicAlias -// 13547,PropSessionExpiryInterval 10014,PropSessionExpiryInterval 19691,PropAuthenticationMethod -// "\198<\129\214\246",PropSessionExpiryInterval 12398,PropMessageExpiryInterval 29590,PropRequestProblemInformation -// 102,PropServerKeepAlive 12804,PropSubscriptionIdentifierAvailable 177,PropServerReference "\175",PropServerKeepAlive -// 16845]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "L\250\DC3", _pubPktID = 6223, _pubBody = ".K\236\242\210\250\192\219\175h\175p\249", _pubProps = [PropSessionExpiryInterval 21695,PropSubscriptionIdentifierAvailable 48,PropUserProperty "h\160\209\172\SYN\ENQ\165\230=\215\207\137\244\DC3\NUL|\145\&6\153\193\140~f\SI\246/" "\231u2\n-\196\188\203F",PropServerKeepAlive 11554,PropAssignedClientIdentifier "\243\&8]\161ZF\r\166\198el\182",PropCorrelationData "\a_\228\&3Ve<\FS[i\238\r\169\188y\187\FS0\145o_8\160t\186",PropResponseInformation "\189\FS\136\EM7\131T\SUB\239\167\221\232\tA\ETX\235n\205",PropTopicAliasMaximum 25457,PropWildcardSubscriptionAvailable 204,PropTopicAliasMaximum 32590,PropPayloadFormatIndicator 81,PropMessageExpiryInterval 27542,PropRequestResponseInformation 163,PropCorrelationData "K\240\248\217\EMt\176\249y\177\DC4\ENQ\134\198\&21\200\NAK\155",PropPayloadFormatIndicator 193,PropServerKeepAlive 20073,PropSubscriptionIdentifierAvailable 37,PropTopicAliasMaximum 7907,PropSessionExpiryInterval 4906]} TEST(Publish5QCTest, Decode23) { - uint8_t pkt[] = {0x31, 0xc5, 0x1, 0x0, 0x10, 0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, 0x8c, 0xe7, 0x0, 0x6a, - 0x21, 0x4d, 0x34, 0x1a, 0x9b, 0x1, 0x17, 0x40, 0x16, 0x0, 0xc, 0x85, 0xec, 0x84, 0x54, 0x1e, 0x95, - 0xa4, 0x8c, 0x66, 0xdc, 0xc8, 0xc8, 0x1c, 0x0, 0xb, 0x8a, 0x73, 0xc8, 0xb5, 0x90, 0x72, 0xe0, 0xbe, - 0x43, 0x2b, 0x3b, 0x3, 0x0, 0x15, 0x9, 0x99, 0x8e, 0x6a, 0x69, 0xce, 0xec, 0x9c, 0x24, 0x2a, 0x88, - 0x14, 0xa, 0xca, 0x28, 0xac, 0x78, 0x43, 0x58, 0x63, 0xcc, 0x24, 0x72, 0x25, 0x5e, 0x11, 0x0, 0x0, - 0x60, 0x16, 0x12, 0x0, 0x1d, 0x60, 0xca, 0xed, 0x5d, 0x74, 0x83, 0xb3, 0x4d, 0xe2, 0xda, 0xfa, 0xa0, - 0x29, 0xe3, 0xa7, 0x30, 0x9a, 0xa, 0x12, 0x5d, 0x10, 0x1f, 0x96, 0x3f, 0xea, 0x42, 0xef, 0x8b, 0xf2, - 0x18, 0x0, 0x0, 0x6d, 0xa6, 0x11, 0x0, 0x0, 0x32, 0x33, 0x24, 0x59, 0x19, 0xd, 0x23, 0x34, 0xeb, - 0x11, 0x0, 0x0, 0x27, 0x1e, 0x11, 0x0, 0x0, 0x4c, 0xeb, 0x15, 0x0, 0x5, 0xc6, 0x3c, 0x81, 0xd6, - 0xf6, 0x11, 0x0, 0x0, 0x30, 0x6e, 0x2, 0x0, 0x0, 0x73, 0x96, 0x17, 0x66, 0x13, 0x32, 0x4, 0x29, - 0xb1, 0x1c, 0x0, 0x1, 0xaf, 0x13, 0x41, 0xcd, 0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, - 0x1b, 0x70, 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x35, 0xbe, 0x1, 0x0, 0x3, 0x4c, 0xfa, 0x13, 0x18, 0x4f, 0xa8, 0x1, 0x11, 0x0, 0x0, 0x54, 0xbf, 0x29, 0x30, 0x26, 0x0, 0x1a, 0x68, 0xa0, 0xd1, 0xac, 0x16, 0x5, 0xa5, 0xe6, 0x3d, 0xd7, 0xcf, 0x89, 0xf4, 0x13, 0x0, 0x7c, 0x91, 0x36, 0x99, 0xc1, 0x8c, 0x7e, 0x66, 0xf, 0xf6, 0x2f, 0x0, 0x9, 0xe7, 0x75, 0x32, 0xa, 0x2d, 0xc4, 0xbc, 0xcb, 0x46, 0x13, 0x2d, 0x22, 0x12, 0x0, 0xc, 0xf3, 0x38, 0x5d, 0xa1, 0x5a, 0x46, 0xd, 0xa6, 0xc6, 0x65, 0x6c, 0xb6, 0x9, 0x0, 0x19, 0x7, 0x5f, 0xe4, 0x33, 0x56, 0x65, 0x3c, 0x1c, 0x5b, 0x69, 0xee, 0xd, 0xa9, 0xbc, 0x79, 0xbb, 0x1c, 0x30, 0x91, 0x6f, 0x5f, 0x38, 0xa0, 0x74, 0xba, 0x1a, 0x0, 0x12, 0xbd, 0x1c, 0x88, 0x19, 0x37, 0x83, 0x54, 0x1a, 0xef, 0xa7, 0xdd, 0xe8, 0x9, 0x41, 0x3, 0xeb, 0x6e, 0xcd, 0x22, 0x63, 0x71, 0x28, 0xcc, 0x22, 0x7f, 0x4e, 0x1, 0x51, 0x2, 0x0, 0x0, 0x6b, 0x96, 0x19, 0xa3, 0x9, 0x0, 0x13, 0x4b, 0xf0, 0xf8, 0xd9, 0x19, 0x74, 0xb0, 0xf9, 0x79, 0xb1, 0x14, 0x5, 0x86, 0xc6, 0x32, 0x31, 0xc8, 0x15, 0x9b, 0x1, 0xc1, 0x13, 0x4e, 0x69, 0x29, 0x25, 0x22, 0x1e, 0xe3, 0x11, 0x0, 0x0, 0x13, 0x2a, 0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x4c, 0xfa, 0x13}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 6223); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); +EXPECT_EQ(msg.payload_len, 13); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x80, 0x9e, 0x2d, 0x47, 0x72, 0x43, 0x81, 0xa6, - 0x8c, 0xe7, 0x0, 0x6a, 0x21, 0x4d, 0x34, 0x1a}; - lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xe4, 0x1b, 0xe7, 0x13, 0x88, 0xd9, 0xb1, 0x57, 0x5f, 0x1b, 0x70, - 0x82, 0x12, 0xd4, 0x2c, 0x9e, 0xec, 0xd7, 0xcc, 0xcf, 0x6d, 0xcd}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "s\233\140\183\209=t\220\206\194\143\249\ETX\234\&5\b\144\f\246\250\US\193\193\178\226\201\156", _pubPktID = 8248, -// _pubBody = "v\196\240]\193r\165~\158\205\155'\206\&8\215s\248\196\250\&1\247", _pubProps = -// [PropWildcardSubscriptionAvailable 105,PropUserProperty "w\143\189\202" -// ")|\ENQ`\155\193\250\159\177\170\174K\SI\147\200g\246\177",PropResponseInformation -// "\163\145C\159Hw6\169\\\132G`_;d\v\206\135xsk",PropSessionExpiryInterval 9513,PropMessageExpiryInterval -// 2757,PropAuthenticationData -// "\128q1v\189\\=\215\166Ym\186\205\223\204m\237\255\146\215\198ef\218d\187\170\207\198",PropTopicAlias -// 16031,PropServerKeepAlive 8395,PropSessionExpiryInterval 13943,PropReceiveMaximum -// 28503,PropRequestResponseInformation 118,PropResponseTopic "$\187",PropServerReference -// "r\178\201\CAN\197\227U\132\210\178\b\223",PropSharedSubscriptionAvailable 190,PropRequestProblemInformation -// 186,PropMaximumQoS 207]} -TEST(Publish5QCTest, Encode24) { - uint8_t pkt[] = {0x34, 0xbf, 0x1, 0x0, 0x1b, 0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, - 0x3, 0xea, 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c, 0x20, 0x38, - 0x89, 0x1, 0x28, 0x69, 0x26, 0x0, 0x4, 0x77, 0x8f, 0xbd, 0xca, 0x0, 0x12, 0x29, 0x7c, 0x5, 0x60, - 0x9b, 0xc1, 0xfa, 0x9f, 0xb1, 0xaa, 0xae, 0x4b, 0xf, 0x93, 0xc8, 0x67, 0xf6, 0xb1, 0x1a, 0x0, 0x15, - 0xa3, 0x91, 0x43, 0x9f, 0x48, 0x77, 0x36, 0xa9, 0x5c, 0x84, 0x47, 0x60, 0x5f, 0x3b, 0x64, 0xb, 0xce, - 0x87, 0x78, 0x73, 0x6b, 0x11, 0x0, 0x0, 0x25, 0x29, 0x2, 0x0, 0x0, 0xa, 0xc5, 0x16, 0x0, 0x1d, - 0x80, 0x71, 0x31, 0x76, 0xbd, 0x5c, 0x3d, 0xd7, 0xa6, 0x59, 0x6d, 0xba, 0xcd, 0xdf, 0xcc, 0x6d, 0xed, - 0xff, 0x92, 0xd7, 0xc6, 0x65, 0x66, 0xda, 0x64, 0xbb, 0xaa, 0xcf, 0xc6, 0x23, 0x3e, 0x9f, 0x13, 0x20, - 0xcb, 0x11, 0x0, 0x0, 0x36, 0x77, 0x21, 0x6f, 0x57, 0x19, 0x76, 0x8, 0x0, 0x2, 0x24, 0xbb, 0x1c, - 0x0, 0xc, 0x72, 0xb2, 0xc9, 0x18, 0xc5, 0xe3, 0x55, 0x84, 0xd2, 0xb2, 0x8, 0xdf, 0x2a, 0xbe, 0x17, - 0xba, 0x24, 0xcf, 0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, 0x27, 0xce, 0x38, - 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; - uint8_t topic_bytes[] = {0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, 0x3, 0xea, - 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, - 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - - uint8_t bytesprops1[] = {0x29, 0x7c, 0x5, 0x60, 0x9b, 0xc1, 0xfa, 0x9f, 0xb1, - 0xaa, 0xae, 0x4b, 0xf, 0x93, 0xc8, 0x67, 0xf6, 0xb1}; - uint8_t bytesprops0[] = {0x77, 0x8f, 0xbd, 0xca}; - uint8_t bytesprops2[] = {0xa3, 0x91, 0x43, 0x9f, 0x48, 0x77, 0x36, 0xa9, 0x5c, 0x84, 0x47, - 0x60, 0x5f, 0x3b, 0x64, 0xb, 0xce, 0x87, 0x78, 0x73, 0x6b}; - uint8_t bytesprops3[] = {0x80, 0x71, 0x31, 0x76, 0xbd, 0x5c, 0x3d, 0xd7, 0xa6, 0x59, 0x6d, 0xba, 0xcd, 0xdf, 0xcc, - 0x6d, 0xed, 0xff, 0x92, 0xd7, 0xc6, 0x65, 0x66, 0xda, 0x64, 0xbb, 0xaa, 0xcf, 0xc6}; - uint8_t bytesprops4[] = {0x24, 0xbb}; - uint8_t bytesprops5[] = {0x72, 0xb2, 0xc9, 0x18, 0xc5, 0xe3, 0x55, 0x84, 0xd2, 0xb2, 0x8, 0xdf}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "^;.\197y\SO\163S\245~\178g\ETB", _pubPktID = 32148, _pubBody = "V\DC4\DC3 ZQ\164[\157n\197\162X\"*\220LH\RSF\206\255)Xpu!=", _pubProps = [PropSharedSubscriptionAvailable 5]} +TEST(Publish5QCTest, Encode24) { +uint8_t pkt[] = {0x34, 0x30, 0x0, 0xd, 0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17, 0x7d, 0x94, 0x2, 0x2a, 0x5, 0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; + uint8_t topic_bytes[] = {0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = false; +uint8_t msg_bytes[] = {0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 28; + + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops0}, .v = {18, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9513}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2757}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16031}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8395}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13943}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28503}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 5}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 8248, topic, msg, props); + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32148, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "s\233\140\183\209=t\220\206\194\143\249\ETX\234\&5\b\144\f\246\250\US\193\193\178\226\201\156", _pubPktID = 8248, -// _pubBody = "v\196\240]\193r\165~\158\205\155'\206\&8\215s\248\196\250\&1\247", _pubProps = -// [PropWildcardSubscriptionAvailable 105,PropUserProperty "w\143\189\202" -// ")|\ENQ`\155\193\250\159\177\170\174K\SI\147\200g\246\177",PropResponseInformation -// "\163\145C\159Hw6\169\\\132G`_;d\v\206\135xsk",PropSessionExpiryInterval 9513,PropMessageExpiryInterval -// 2757,PropAuthenticationData -// "\128q1v\189\\=\215\166Ym\186\205\223\204m\237\255\146\215\198ef\218d\187\170\207\198",PropTopicAlias -// 16031,PropServerKeepAlive 8395,PropSessionExpiryInterval 13943,PropReceiveMaximum -// 28503,PropRequestResponseInformation 118,PropResponseTopic "$\187",PropServerReference -// "r\178\201\CAN\197\227U\132\210\178\b\223",PropSharedSubscriptionAvailable 190,PropRequestProblemInformation -// 186,PropMaximumQoS 207]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "^;.\197y\SO\163S\245~\178g\ETB", _pubPktID = 32148, _pubBody = "V\DC4\DC3 ZQ\164[\157n\197\162X\"*\220LH\RSF\206\255)Xpu!=", _pubProps = [PropSharedSubscriptionAvailable 5]} TEST(Publish5QCTest, Decode24) { - uint8_t pkt[] = {0x34, 0xbf, 0x1, 0x0, 0x1b, 0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, - 0x3, 0xea, 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c, 0x20, 0x38, - 0x89, 0x1, 0x28, 0x69, 0x26, 0x0, 0x4, 0x77, 0x8f, 0xbd, 0xca, 0x0, 0x12, 0x29, 0x7c, 0x5, 0x60, - 0x9b, 0xc1, 0xfa, 0x9f, 0xb1, 0xaa, 0xae, 0x4b, 0xf, 0x93, 0xc8, 0x67, 0xf6, 0xb1, 0x1a, 0x0, 0x15, - 0xa3, 0x91, 0x43, 0x9f, 0x48, 0x77, 0x36, 0xa9, 0x5c, 0x84, 0x47, 0x60, 0x5f, 0x3b, 0x64, 0xb, 0xce, - 0x87, 0x78, 0x73, 0x6b, 0x11, 0x0, 0x0, 0x25, 0x29, 0x2, 0x0, 0x0, 0xa, 0xc5, 0x16, 0x0, 0x1d, - 0x80, 0x71, 0x31, 0x76, 0xbd, 0x5c, 0x3d, 0xd7, 0xa6, 0x59, 0x6d, 0xba, 0xcd, 0xdf, 0xcc, 0x6d, 0xed, - 0xff, 0x92, 0xd7, 0xc6, 0x65, 0x66, 0xda, 0x64, 0xbb, 0xaa, 0xcf, 0xc6, 0x23, 0x3e, 0x9f, 0x13, 0x20, - 0xcb, 0x11, 0x0, 0x0, 0x36, 0x77, 0x21, 0x6f, 0x57, 0x19, 0x76, 0x8, 0x0, 0x2, 0x24, 0xbb, 0x1c, - 0x0, 0xc, 0x72, 0xb2, 0xc9, 0x18, 0xc5, 0xe3, 0x55, 0x84, 0xd2, 0xb2, 0x8, 0xdf, 0x2a, 0xbe, 0x17, - 0xba, 0x24, 0xcf, 0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, 0x27, 0xce, 0x38, - 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x73, 0xe9, 0x8c, 0xb7, 0xd1, 0x3d, 0x74, 0xdc, 0xce, 0xc2, 0x8f, 0xf9, 0x3, 0xea, - 0x35, 0x8, 0x90, 0xc, 0xf6, 0xfa, 0x1f, 0xc1, 0xc1, 0xb2, 0xe2, 0xc9, 0x9c}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x76, 0xc4, 0xf0, 0x5d, 0xc1, 0x72, 0xa5, 0x7e, 0x9e, 0xcd, 0x9b, - 0x27, 0xce, 0x38, 0xd7, 0x73, 0xf8, 0xc4, 0xfa, 0x31, 0xf7}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 8248); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\146;?\158\252\\a5\133\233\144\&9O\159\231\133\240}\DC1\200\&9\154a%\176Y", _pubPktID = 0, _pubBody = -// "\173\221\&2\157\129qMv\218\&6\216\165J\tp\242\205\&2\194t\243\161\STX?", _pubProps = -// [PropWildcardSubscriptionAvailable 100,PropSharedSubscriptionAvailable 223,PropTopicAlias 20373,PropMaximumPacketSize -// 5572,PropSessionExpiryInterval 738,PropReceiveMaximum 29296,PropWildcardSubscriptionAvailable -// 214,PropSharedSubscriptionAvailable 228,PropSubscriptionIdentifier 0,PropAuthenticationData -// "\236\161\148?\223\SI\130#I",PropSubscriptionIdentifier 17,PropMaximumQoS 12,PropServerKeepAlive 1836,PropContentType -// "Y\170\163\218\n\143\197\168\143\229\156Ja\129\214\"$v\216",PropWillDelayInterval 30892]} +uint8_t pkt[] = {0x34, 0x30, 0x0, 0xd, 0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17, 0x7d, 0x94, 0x2, 0x2a, 0x5, 0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 32148); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); +EXPECT_EQ(msg.payload_len, 28); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "Vk\181\201\ETXZ\DC4\208\170\201\tDEB\153]Q\232", _pubPktID = 2981, _pubBody = "\\>V\153p|W\163\148\254\SYN@q\238?", _pubProps = [PropPayloadFormatIndicator 104,PropMaximumQoS 226,PropWildcardSubscriptionAvailable 205,PropWildcardSubscriptionAvailable 60,PropCorrelationData "\235\225\DLE\160\166;(topic.data), 18); +EXPECT_EQ(msg.payload_len, 15); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x92, 0x3b, 0x3f, 0x9e, 0xfc, 0x5c, 0x61, 0x35, 0x85, 0xe9, 0x90, 0x39, 0x4f, - 0x9f, 0xe7, 0x85, 0xf0, 0x7d, 0x11, 0xc8, 0x39, 0x9a, 0x61, 0x25, 0xb0, 0x59}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xad, 0xdd, 0x32, 0x9d, 0x81, 0x71, 0x4d, 0x76, 0xda, 0x36, 0xd8, 0xa5, - 0x4a, 0x9, 0x70, 0xf2, 0xcd, 0x32, 0xc2, 0x74, 0xf3, 0xa1, 0x2, 0x3f}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "?X\254\SIJ/\199\240\153I\171-\227\213\191\205\b\202\247\252\a\196\136\150\215K\\R", _pubPktID = 0, _pubBody = -// "\167\192W\238\177\207\SO\148\212\134\&6\145\223N\168", _pubProps = [PropMaximumPacketSize -// 23071,PropSessionExpiryInterval 11860,PropRequestResponseInformation 15,PropCorrelationData -// "\SYN",PropTopicAliasMaximum 12529,PropAssignedClientIdentifier "C",PropWillDelayInterval -// 30896,PropSubscriptionIdentifier 30,PropReceiveMaximum 4366,PropCorrelationData "\221",PropMaximumQoS -// 167,PropRequestProblemInformation 224,PropContentType -// "\148\196\176\241\190\170\&7W\182\250\168\GS\226\169\206\233\SIkrvq",PropAssignedClientIdentifier -// "\178\162|J\232\216\158\186\133\ENQ\234w",PropServerKeepAlive 7326,PropResponseInformation -// "\176\251\199\&7F&\234\137\129\248\n\209&\194\161d\221{\158\156\164",PropCorrelationData -// "\244\255\209\153\183\DC1N\168",PropMaximumQoS 49,PropRetainAvailable 71,PropTopicAliasMaximum 7503]} +} + + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 12988, _pubBody = "\252Q\161\SUB\150\190\247\174s\151T8\149C\NAK9;)\159\188\140bs", _pubProps = [PropRequestProblemInformation 31,PropAssignedClientIdentifier "\DC3\182\192\154\225\188^@\162S\227\251\178",PropAuthenticationMethod "l\171X\185\ETBzS\160",PropRetainAvailable 56,PropSubscriptionIdentifier 3,PropResponseTopic "\rGO4\241\253\189",PropPayloadFormatIndicator 10,PropWillDelayInterval 27162,PropUserProperty "\t|Q\220\160\SOH\160\DC4%\208\208\DELV\221 \157\205\&4\162" "\133t\211\178\159\232\204HKv|y\SOH\224\&6\234",PropAssignedClientIdentifier "",PropRequestProblemInformation 241,PropServerKeepAlive 24630,PropMessageExpiryInterval 3172,PropUserProperty "R\191\DC2\242Ix\135\156.\141\205i\155\174\196\&1" "\SYN\160.\234\RS)",PropSubscriptionIdentifier 19,PropUserProperty "\146[\196\170\191+\231(y#\US,\151\224\ETB\233\215\142)#\ETX\ENQ\214\&0\253\200" "\237.\226]\171\248\148\189j\162\RS\247Z\ETX\165\207\224o\137",PropSharedSubscriptionAvailable 62,PropSubscriptionIdentifier 10,PropAuthenticationData "\184\&2\244\200\164nX5\251\191:\249z\172\168\210;\182\NAK\190C\179\147W\237Q\192\196"]} TEST(Publish5QCTest, Encode26) { - uint8_t pkt[] = {0x31, 0xab, 0x1, 0x0, 0x1c, 0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, - 0x2d, 0xe3, 0xd5, 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, - 0x52, 0x7d, 0x27, 0x0, 0x0, 0x5a, 0x1f, 0x11, 0x0, 0x0, 0x2e, 0x54, 0x19, 0xf, 0x9, 0x0, - 0x1, 0x16, 0x22, 0x30, 0xf1, 0x12, 0x0, 0x1, 0x43, 0x18, 0x0, 0x0, 0x78, 0xb0, 0xb, 0x1e, - 0x21, 0x11, 0xe, 0x9, 0x0, 0x1, 0xdd, 0x24, 0xa7, 0x17, 0xe0, 0x3, 0x0, 0x15, 0x94, 0xc4, - 0xb0, 0xf1, 0xbe, 0xaa, 0x37, 0x57, 0xb6, 0xfa, 0xa8, 0x1d, 0xe2, 0xa9, 0xce, 0xe9, 0xf, 0x6b, - 0x72, 0x76, 0x71, 0x12, 0x0, 0xc, 0xb2, 0xa2, 0x7c, 0x4a, 0xe8, 0xd8, 0x9e, 0xba, 0x85, 0x5, - 0xea, 0x77, 0x13, 0x1c, 0x9e, 0x1a, 0x0, 0x15, 0xb0, 0xfb, 0xc7, 0x37, 0x46, 0x26, 0xea, 0x89, - 0x81, 0xf8, 0xa, 0xd1, 0x26, 0xc2, 0xa1, 0x64, 0xdd, 0x7b, 0x9e, 0x9c, 0xa4, 0x9, 0x0, 0x8, - 0xf4, 0xff, 0xd1, 0x99, 0xb7, 0x11, 0x4e, 0xa8, 0x24, 0x31, 0x25, 0x47, 0x22, 0x1d, 0x4f, 0xa7, - 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; - uint8_t topic_bytes[] = {0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, 0xe3, 0xd5, - 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0x16}; - uint8_t bytesprops1[] = {0x43}; - uint8_t bytesprops2[] = {0xdd}; - uint8_t bytesprops3[] = {0x94, 0xc4, 0xb0, 0xf1, 0xbe, 0xaa, 0x37, 0x57, 0xb6, 0xfa, 0xa8, - 0x1d, 0xe2, 0xa9, 0xce, 0xe9, 0xf, 0x6b, 0x72, 0x76, 0x71}; - uint8_t bytesprops4[] = {0xb2, 0xa2, 0x7c, 0x4a, 0xe8, 0xd8, 0x9e, 0xba, 0x85, 0x5, 0xea, 0x77}; - uint8_t bytesprops5[] = {0xb0, 0xfb, 0xc7, 0x37, 0x46, 0x26, 0xea, 0x89, 0x81, 0xf8, 0xa, - 0xd1, 0x26, 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 0x30, 0xfd, 0xc8, 0x0, 0x13, 0xed, 0x2e, 0xe2, 0x5d, 0xab, 0xf8, 0x94, 0xbd, 0x6a, 0xa2, 0x1e, 0xf7, 0x5a, 0x3, 0xa5, 0xcf, 0xe0, 0x6f, 0x89, 0x2a, 0x3e, 0xb, 0xa, 0x16, 0x0, 0x1c, 0xb8, 0x32, 0xf4, 0xc8, 0xa4, 0x6e, 0x58, 0x35, 0xfb, 0xbf, 0x3a, 0xf9, 0x7a, 0xac, 0xa8, 0xd2, 0x3b, 0xb6, 0x15, 0xbe, 0x43, 0xb3, 0x93, 0x57, 0xed, 0x51, 0xc0, 0xc4, 0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 23; + + uint8_t bytesprops0[] = {0x13, 0xb6, 0xc0, 0x9a, 0xe1, 0xbc, 0x5e, 0x40, 0xa2, 0x53, 0xe3, 0xfb, 0xb2}; + uint8_t bytesprops1[] = {0x6c, 0xab, 0x58, 0xb9, 0x17, 0x7a, 0x53, 0xa0}; + uint8_t bytesprops2[] = {0xd, 0x47, 0x4f, 0x34, 0xf1, 0xfd, 0xbd}; + uint8_t bytesprops4[] = {0x85, 0x74, 0xd3, 0xb2, 0x9f, 0xe8, 0xcc, 0x48, 0x4b, 0x76, 0x7c, 0x79, 0x1, 0xe0, 0x36, 0xea}; + uint8_t bytesprops3[] = {0x9, 0x7c, 0x51, 0xdc, 0xa0, 0x1, 0xa0, 0x14, 0x25, 0xd0, 0xd0, 0x7f, 0x56, 0xdd, 0x20, 0x9d, 0xcd, 0x34, 0xa2}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops7[] = {0x16, 0xa0, 0x2e, 0xea, 0x1e, 0x29}; + uint8_t bytesprops6[] = {0x52, 0xbf, 0x12, 0xf2, 0x49, 0x78, 0x87, 0x9c, 0x2e, 0x8d, 0xcd, 0x69, 0x9b, 0xae, 0xc4, 0x31}; + uint8_t bytesprops9[] = {0xed, 0x2e, 0xe2, 0x5d, 0xab, 0xf8, 0x94, 0xbd, 0x6a, 0xa2, 0x1e, 0xf7, 0x5a, 0x3, 0xa5, 0xcf, 0xe0, 0x6f, 0x89}; + uint8_t bytesprops8[] = {0x92, 0x5b, 0xc4, 0xaa, 0xbf, 0x2b, 0xe7, 0x28, 0x79, 0x23, 0x1f, 0x2c, 0x97, 0xe0, 0x17, 0xe9, 0xd7, 0x8e, 0x29, 0x23, 0x3, 0x5, 0xd6, 0x30, 0xfd, 0xc8}; + uint8_t bytesprops10[] = {0xb8, 0x32, 0xf4, 0xc8, 0xa4, 0x6e, 0x58, 0x35, 0xfb, 0xbf, 0x3a, 0xf9, 0x7a, 0xac, 0xa8, 0xd2, 0x3b, 0xb6, 0x15, 0xbe, 0x43, 0xb3, 0x93, 0x57, 0xed, 0x51, 0xc0, 0xc4}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23071}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11860}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12529}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30896}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4366}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7326}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7503}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27162}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={19, (char*)&bytesprops3}, .v={16, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24630}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3172}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={16, (char*)&bytesprops6}, .v={6, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={26, (char*)&bytesprops8}, .v={19, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 12988, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "?X\254\SIJ/\199\240\153I\171-\227\213\191\205\b\202\247\252\a\196\136\150\215K\\R", _pubPktID = 0, _pubBody = -// "\167\192W\238\177\207\SO\148\212\134\&6\145\223N\168", _pubProps = [PropMaximumPacketSize -// 23071,PropSessionExpiryInterval 11860,PropRequestResponseInformation 15,PropCorrelationData -// "\SYN",PropTopicAliasMaximum 12529,PropAssignedClientIdentifier "C",PropWillDelayInterval -// 30896,PropSubscriptionIdentifier 30,PropReceiveMaximum 4366,PropCorrelationData "\221",PropMaximumQoS -// 167,PropRequestProblemInformation 224,PropContentType -// "\148\196\176\241\190\170\&7W\182\250\168\GS\226\169\206\233\SIkrvq",PropAssignedClientIdentifier -// "\178\162|J\232\216\158\186\133\ENQ\234w",PropServerKeepAlive 7326,PropResponseInformation -// "\176\251\199\&7F&\234\137\129\248\n\209&\194\161d\221{\158\156\164",PropCorrelationData -// "\244\255\209\153\183\DC1N\168",PropMaximumQoS 49,PropRetainAvailable 71,PropTopicAliasMaximum 7503]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 12988, _pubBody = "\252Q\161\SUB\150\190\247\174s\151T8\149C\NAK9;)\159\188\140bs", _pubProps = [PropRequestProblemInformation 31,PropAssignedClientIdentifier "\DC3\182\192\154\225\188^@\162S\227\251\178",PropAuthenticationMethod "l\171X\185\ETBzS\160",PropRetainAvailable 56,PropSubscriptionIdentifier 3,PropResponseTopic "\rGO4\241\253\189",PropPayloadFormatIndicator 10,PropWillDelayInterval 27162,PropUserProperty "\t|Q\220\160\SOH\160\DC4%\208\208\DELV\221 \157\205\&4\162" "\133t\211\178\159\232\204HKv|y\SOH\224\&6\234",PropAssignedClientIdentifier "",PropRequestProblemInformation 241,PropServerKeepAlive 24630,PropMessageExpiryInterval 3172,PropUserProperty "R\191\DC2\242Ix\135\156.\141\205i\155\174\196\&1" "\SYN\160.\234\RS)",PropSubscriptionIdentifier 19,PropUserProperty "\146[\196\170\191+\231(y#\US,\151\224\ETB\233\215\142)#\ETX\ENQ\214\&0\253\200" "\237.\226]\171\248\148\189j\162\RS\247Z\ETX\165\207\224o\137",PropSharedSubscriptionAvailable 62,PropSubscriptionIdentifier 10,PropAuthenticationData "\184\&2\244\200\164nX5\251\191:\249z\172\168\210;\182\NAK\190C\179\147W\237Q\192\196"]} TEST(Publish5QCTest, Decode26) { - uint8_t pkt[] = {0x31, 0xab, 0x1, 0x0, 0x1c, 0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, - 0x2d, 0xe3, 0xd5, 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, - 0x52, 0x7d, 0x27, 0x0, 0x0, 0x5a, 0x1f, 0x11, 0x0, 0x0, 0x2e, 0x54, 0x19, 0xf, 0x9, 0x0, - 0x1, 0x16, 0x22, 0x30, 0xf1, 0x12, 0x0, 0x1, 0x43, 0x18, 0x0, 0x0, 0x78, 0xb0, 0xb, 0x1e, - 0x21, 0x11, 0xe, 0x9, 0x0, 0x1, 0xdd, 0x24, 0xa7, 0x17, 0xe0, 0x3, 0x0, 0x15, 0x94, 0xc4, - 0xb0, 0xf1, 0xbe, 0xaa, 0x37, 0x57, 0xb6, 0xfa, 0xa8, 0x1d, 0xe2, 0xa9, 0xce, 0xe9, 0xf, 0x6b, - 0x72, 0x76, 0x71, 0x12, 0x0, 0xc, 0xb2, 0xa2, 0x7c, 0x4a, 0xe8, 0xd8, 0x9e, 0xba, 0x85, 0x5, - 0xea, 0x77, 0x13, 0x1c, 0x9e, 0x1a, 0x0, 0x15, 0xb0, 0xfb, 0xc7, 0x37, 0x46, 0x26, 0xea, 0x89, - 0x81, 0xf8, 0xa, 0xd1, 0x26, 0xc2, 0xa1, 0x64, 0xdd, 0x7b, 0x9e, 0x9c, 0xa4, 0x9, 0x0, 0x8, - 0xf4, 0xff, 0xd1, 0x99, 0xb7, 0x11, 0x4e, 0xa8, 0x24, 0x31, 0x25, 0x47, 0x22, 0x1d, 0x4f, 0xa7, - 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props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 0xa5, 0xcf, 0xe0, 0x6f, 0x89, 0x2a, 0x3e, 0xb, 0xa, 0x16, 0x0, 0x1c, 0xb8, 0x32, 0xf4, 0xc8, 0xa4, 0x6e, 0x58, 0x35, 0xfb, 0xbf, 0x3a, 0xf9, 0x7a, 0xac, 0xa8, 0xd2, 0x3b, 0xb6, 0x15, 0xbe, 0x43, 0xb3, 0x93, 0x57, 0xed, 0x51, 0xc0, 0xc4, 0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 12988); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); +EXPECT_EQ(msg.payload_len, 23); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3f, 0x58, 0xfe, 0xf, 0x4a, 0x2f, 0xc7, 0xf0, 0x99, 0x49, 0xab, 0x2d, 0xe3, 0xd5, - 0xbf, 0xcd, 0x8, 0xca, 0xf7, 0xfc, 0x7, 0xc4, 0x88, 0x96, 0xd7, 0x4b, 0x5c, 0x52}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa7, 0xc0, 0x57, 0xee, 0xb1, 0xcf, 0xe, 0x94, 0xd4, 0x86, 0x36, 0x91, 0xdf, 0x4e, 0xa8}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\144\167\130\179A", _pubPktID = 0, -// _pubBody = "\148\134\185\213\184\233\187\157\198\233\181\148_\215\n$@\169\251\210\184\f", _pubProps = -// [PropAuthenticationMethod -// "|\143q\195\251M\191\232h\177P\223+GO\216\205\SOHt\NUL\195\166\215\149\248\DC1\172\175",PropWildcardSubscriptionAvailable -// 110,PropServerKeepAlive 4553,PropUserProperty "\171nt\205N@\181\158\130" -// "\132&\133\171(\158\191\141\134\NUL9~]\166\v\US\175Ke5{z\155\DEL\220Q#\144\210L",PropRequestProblemInformation -// 209,PropMessageExpiryInterval 18135,PropRetainAvailable 50,PropSharedSubscriptionAvailable -// 25,PropRequestResponseInformation 116,PropAssignedClientIdentifier "\222~\174\197]x}\tt",PropAssignedClientIdentifier -// "\254m\222~\246c\236\EMxgc\n\133\DC3\161\215\138\189\196\160\239v\195\214",PropServerReference -// "v\228\245!.}\DC4\234\167y\248\193\145\163\128\133\234\222\154\155'\216\ETX\182\149\196\FS\198$",PropContentType -// "\194\157\134\206L\155\159T\181\225\202\251\165\135\218V/M\SO\\\182\&7\tb\186y",PropServerKeepAlive -// 28713,PropAssignedClientIdentifier -// "\184\NUL\195X\133\147\177JY\136\198\SUB$\231<\SUB\154\166\214\180\193/\FS",PropResponseInformation -// "\157+6\169",PropRequestResponseInformation 231,PropWillDelayInterval 27240,PropMaximumPacketSize -// 2824,PropRequestResponseInformation 113,PropPayloadFormatIndicator 71,PropServerReference -// "!4\CAN\241\142\181j",PropWillDelayInterval 28393,PropResponseInformation "(\174\188e",PropMaximumPacketSize 15079]} -TEST(Publish5QCTest, Encode27) { - uint8_t pkt[] = {0x38, 0xaf, 0x2, 0x0, 0x5, 0x90, 0xa7, 0x82, 0xb3, 0x41, 0x90, 0x2, 0x15, 0x0, 0x1c, 0x7c, 0x8f, - 0x71, 0xc3, 0xfb, 0x4d, 0xbf, 0xe8, 0x68, 0xb1, 0x50, 0xdf, 0x2b, 0x47, 0x4f, 0xd8, 0xcd, 0x1, 0x74, - 0x0, 0xc3, 0xa6, 0xd7, 0x95, 0xf8, 0x11, 0xac, 0xaf, 0x28, 0x6e, 0x13, 0x11, 0xc9, 0x26, 0x0, 0x9, - 0xab, 0x6e, 0x74, 0xcd, 0x4e, 0x40, 0xb5, 0x9e, 0x82, 0x0, 0x1e, 0x84, 0x26, 0x85, 0xab, 0x28, 0x9e, - 0xbf, 0x8d, 0x86, 0x0, 0x39, 0x7e, 0x5d, 0xa6, 0xb, 0x1f, 0xaf, 0x4b, 0x65, 0x35, 0x7b, 0x7a, 0x9b, - 0x7f, 0xdc, 0x51, 0x23, 0x90, 0xd2, 0x4c, 0x17, 0xd1, 0x2, 0x0, 0x0, 0x46, 0xd7, 0x25, 0x32, 0x2a, - 0x19, 0x19, 0x74, 0x12, 0x0, 0x9, 0xde, 0x7e, 0xae, 0xc5, 0x5d, 0x78, 0x7d, 0x9, 0x74, 0x12, 0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0xd2, 0xb8, 0xc}; - uint8_t topic_bytes[] = {0x90, 0xa7, 0x82, 0xb3, 0x41}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, - 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; - - uint8_t bytesprops0[] = {0x7c, 0x8f, 0x71, 0xc3, 0xfb, 0x4d, 0xbf, 0xe8, 0x68, 0xb1, 0x50, 0xdf, 0x2b, 0x47, - 0x4f, 0xd8, 0xcd, 0x1, 0x74, 0x0, 0xc3, 0xa6, 0xd7, 0x95, 0xf8, 0x11, 0xac, 0xaf}; - uint8_t bytesprops2[] = {0x84, 0x26, 0x85, 0xab, 0x28, 0x9e, 0xbf, 0x8d, 0x86, 0x0, 0x39, 0x7e, 0x5d, 0xa6, 0xb, - 0x1f, 0xaf, 0x4b, 0x65, 0x35, 0x7b, 0x7a, 0x9b, 0x7f, 0xdc, 0x51, 0x23, 0x90, 0xd2, 0x4c}; - uint8_t bytesprops1[] = {0xab, 0x6e, 0x74, 0xcd, 0x4e, 0x40, 0xb5, 0x9e, 0x82}; - uint8_t bytesprops3[] = {0xde, 0x7e, 0xae, 0xc5, 0x5d, 0x78, 0x7d, 0x9, 0x74}; - uint8_t bytesprops4[] = {0xfe, 0x6d, 0xde, 0x7e, 0xf6, 0x63, 0xec, 0x19, 0x78, 0x67, 0x63, 0xa, - 0x85, 0x13, 0xa1, 0xd7, 0x8a, 0xbd, 0xc4, 0xa0, 0xef, 0x76, 0xc3, 0xd6}; - uint8_t bytesprops5[] = {0x76, 0xe4, 0xf5, 0x21, 0x2e, 0x7d, 0x14, 0xea, 0xa7, 0x79, 0xf8, 0xc1, 0x91, 0xa3, 0x80, - 0x85, 0xea, 0xde, 0x9a, 0x9b, 0x27, 0xd8, 0x3, 0xb6, 0x95, 0xc4, 0x1c, 0xc6, 0x24}; - uint8_t bytesprops6[] = {0xc2, 0x9d, 0x86, 0xce, 0x4c, 0x9b, 0x9f, 0x54, 0xb5, 0xe1, 0xca, 0xfb, 0xa5, - 0x87, 0xda, 0x56, 0x2f, 0x4d, 0xe, 0x5c, 0xb6, 0x37, 0x9, 0x62, 0xba, 0x79}; - uint8_t bytesprops7[] = {0xb8, 0x0, 0xc3, 0x58, 0x85, 0x93, 0xb1, 0x4a, 0x59, 0x88, 0xc6, 0x1a, - 0x24, 0xe7, 0x3c, 0x1a, 0x9a, 0xa6, 0xd6, 0xb4, 0xc1, 0x2f, 0x1c}; - uint8_t bytesprops8[] = {0x9d, 0x2b, 0x36, 0xa9}; - uint8_t bytesprops9[] = {0x21, 0x34, 0x18, 0xf1, 0x8e, 0xb5, 0x6a}; - uint8_t bytesprops10[] = {0x28, 0xae, 0xbc, 0x65}; +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\a\206+\241_)~\225\174V\232:\184e", _pubPktID = 1045, _pubBody = "E\243x", _pubProps = [PropUserProperty "\135O\CAN\f(\133\158\229\237\&0:g$\SUB((\243W\228" "6\214\190\&0\238[\170\&5k\222\192?`\202,j\166\STX[\DLE\211\228\214\230\191\210\216W",PropUserProperty "Q\199y\153\173\ENQ\161\205DUN\128\231\149" "Eh\176\198\182\233\162\153#a\157\v\DLE\STX\135\NAK\201\128H\140",PropRequestResponseInformation 104,PropAssignedClientIdentifier "w\147\SUB\154RXi#\179\241\169k/E\187\170\US\SI(o]ZT\177\EM<\178",PropAuthenticationMethod "\206\160\SYN\ETB\231\245WV@\DELv\235",PropSessionExpiryInterval 9123,PropRequestProblemInformation 198,PropSharedSubscriptionAvailable 144,PropWildcardSubscriptionAvailable 30,PropTopicAlias 14192,PropTopicAliasMaximum 28876,PropContentType "\218\195\141G\183\247\135+\242fa\220\239\167\173u\SI\235\141",PropRequestProblemInformation 177,PropSessionExpiryInterval 85,PropReceiveMaximum 15015,PropResponseTopic "t$S\140\222\&6",PropRetainAvailable 130,PropPayloadFormatIndicator 149,PropResponseInformation "%!",PropResponseInformation "#z\191\231\149\EM\218\t\SYN?\202p\207\225\150c\t\228",PropUserProperty "\213z\f\194<\151" "\233\STX\184a),>\245I&\184\241\tE\224\ESC0h\130\138\254\206\209!M",PropServerKeepAlive 22611,PropCorrelationData "\128}\SO\223\179\158\136EI\244\145\ESCHq\DC4>:+\242\129\196I\245&\196\241",PropMessageExpiryInterval 9516,PropRetainAvailable 117,PropTopicAliasMaximum 18796,PropAuthenticationData "\228*W"]} +TEST(Publish5QCTest, Encode27) { +uint8_t pkt[] = {0x33, 0xcd, 0x2, 0x0, 0xe, 0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65, 0x4, 0x15, 0xb6, 0x2, 0x26, 0x0, 0x13, 0x87, 0x4f, 0x18, 0xc, 0x28, 0x85, 0x9e, 0xe5, 0xed, 0x30, 0x3a, 0x67, 0x24, 0x1a, 0x28, 0x28, 0xf3, 0x57, 0xe4, 0x0, 0x1c, 0x36, 0xd6, 0xbe, 0x30, 0xee, 0x5b, 0xaa, 0x35, 0x6b, 0xde, 0xc0, 0x3f, 0x60, 0xca, 0x2c, 0x6a, 0xa6, 0x2, 0x5b, 0x10, 0xd3, 0xe4, 0xd6, 0xe6, 0xbf, 0xd2, 0xd8, 0x57, 0x26, 0x0, 0xe, 0x51, 0xc7, 0x79, 0x99, 0xad, 0x5, 0xa1, 0xcd, 0x44, 0x55, 0x4e, 0x80, 0xe7, 0x95, 0x0, 0x14, 0x45, 0x68, 0xb0, 0xc6, 0xb6, 0xe9, 0xa2, 0x99, 0x23, 0x61, 0x9d, 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b3, 0x9e, 0x88, 0x45, 0x49, 0xf4, 0x91, 0x1b, 0x48, 0x71, 0x14, 0x3e, 0x3a, 0x2b, 0xf2, 0x81, 0xc4, 0x49, 0xf5, 0x26, 0xc4, 0xf1, 0x2, 0x0, 0x0, 0x25, 0x2c, 0x25, 0x75, 0x22, 0x49, 0x6c, 0x16, 0x0, 0x3, 0xe4, 0x2a, 0x57, 0x45, 0xf3, 0x78}; + uint8_t topic_bytes[] = {0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x45, 0xf3, 0x78}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 3; + + uint8_t bytesprops1[] = {0x36, 0xd6, 0xbe, 0x30, 0xee, 0x5b, 0xaa, 0x35, 0x6b, 0xde, 0xc0, 0x3f, 0x60, 0xca, 0x2c, 0x6a, 0xa6, 0x2, 0x5b, 0x10, 0xd3, 0xe4, 0xd6, 0xe6, 0xbf, 0xd2, 0xd8, 0x57}; + uint8_t bytesprops0[] = {0x87, 0x4f, 0x18, 0xc, 0x28, 0x85, 0x9e, 0xe5, 0xed, 0x30, 0x3a, 0x67, 0x24, 0x1a, 0x28, 0x28, 0xf3, 0x57, 0xe4}; + uint8_t bytesprops3[] = {0x45, 0x68, 0xb0, 0xc6, 0xb6, 0xe9, 0xa2, 0x99, 0x23, 0x61, 0x9d, 0xb, 0x10, 0x2, 0x87, 0x15, 0xc9, 0x80, 0x48, 0x8c}; + uint8_t bytesprops2[] = {0x51, 0xc7, 0x79, 0x99, 0xad, 0x5, 0xa1, 0xcd, 0x44, 0x55, 0x4e, 0x80, 0xe7, 0x95}; + uint8_t bytesprops4[] = {0x77, 0x93, 0x1a, 0x9a, 0x52, 0x58, 0x69, 0x23, 0xb3, 0xf1, 0xa9, 0x6b, 0x2f, 0x45, 0xbb, 0xaa, 0x1f, 0xf, 0x28, 0x6f, 0x5d, 0x5a, 0x54, 0xb1, 0x19, 0x3c, 0xb2}; + uint8_t bytesprops5[] = {0xce, 0xa0, 0x16, 0x17, 0xe7, 0xf5, 0x57, 0x56, 0x40, 0x7f, 0x76, 0xeb}; + uint8_t bytesprops6[] = {0xda, 0xc3, 0x8d, 0x47, 0xb7, 0xf7, 0x87, 0x2b, 0xf2, 0x66, 0x61, 0xdc, 0xef, 0xa7, 0xad, 0x75, 0xf, 0xeb, 0x8d}; + uint8_t bytesprops7[] = {0x74, 0x24, 0x53, 0x8c, 0xde, 0x36}; + uint8_t bytesprops8[] = {0x25, 0x21}; + uint8_t bytesprops9[] = {0x23, 0x7a, 0xbf, 0xe7, 0x95, 0x19, 0xda, 0x9, 0x16, 0x3f, 0xca, 0x70, 0xcf, 0xe1, 0x96, 0x63, 0x9, 0xe4}; + uint8_t bytesprops11[] = {0xe9, 0x2, 0xb8, 0x61, 0x29, 0x2c, 0x3e, 0xf5, 0x49, 0x26, 0xb8, 0xf1, 0x9, 0x45, 0xe0, 0x1b, 0x30, 0x68, 0x82, 0x8a, 0xfe, 0xce, 0xd1, 0x21, 0x4d}; + uint8_t bytesprops10[] = {0xd5, 0x7a, 0xc, 0xc2, 0x3c, 0x97}; + uint8_t bytesprops12[] = {0x80, 0x7d, 0xe, 0xdf, 0xb3, 0x9e, 0x88, 0x45, 0x49, 0xf4, 0x91, 0x1b, 0x48, 0x71, 0x14, 0x3e, 0x3a, 0x2b, 0xf2, 0x81, 0xc4, 0x49, 0xf5, 0x26, 0xc4, 0xf1}; + uint8_t bytesprops13[] = {0xe4, 0x2a, 0x57}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4553}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18135}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28713}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27240}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2824}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28393}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15079}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={19, (char*)&bytesprops0}, .v={28, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={14, (char*)&bytesprops2}, .v={20, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9123}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14192}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28876}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 85}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15015}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={6, (char*)&bytesprops10}, .v={25, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22611}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9516}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18796}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops13}}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1045, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\144\167\130\179A", _pubPktID = 0, -// _pubBody = "\148\134\185\213\184\233\187\157\198\233\181\148_\215\n$@\169\251\210\184\f", _pubProps = -// [PropAuthenticationMethod -// "|\143q\195\251M\191\232h\177P\223+GO\216\205\SOHt\NUL\195\166\215\149\248\DC1\172\175",PropWildcardSubscriptionAvailable -// 110,PropServerKeepAlive 4553,PropUserProperty "\171nt\205N@\181\158\130" -// "\132&\133\171(\158\191\141\134\NUL9~]\166\v\US\175Ke5{z\155\DEL\220Q#\144\210L",PropRequestProblemInformation -// 209,PropMessageExpiryInterval 18135,PropRetainAvailable 50,PropSharedSubscriptionAvailable -// 25,PropRequestResponseInformation 116,PropAssignedClientIdentifier "\222~\174\197]x}\tt",PropAssignedClientIdentifier -// "\254m\222~\246c\236\EMxgc\n\133\DC3\161\215\138\189\196\160\239v\195\214",PropServerReference -// "v\228\245!.}\DC4\234\167y\248\193\145\163\128\133\234\222\154\155'\216\ETX\182\149\196\FS\198$",PropContentType -// "\194\157\134\206L\155\159T\181\225\202\251\165\135\218V/M\SO\\\182\&7\tb\186y",PropServerKeepAlive -// 28713,PropAssignedClientIdentifier -// "\184\NUL\195X\133\147\177JY\136\198\SUB$\231<\SUB\154\166\214\180\193/\FS",PropResponseInformation -// "\157+6\169",PropRequestResponseInformation 231,PropWillDelayInterval 27240,PropMaximumPacketSize -// 2824,PropRequestResponseInformation 113,PropPayloadFormatIndicator 71,PropServerReference -// "!4\CAN\241\142\181j",PropWillDelayInterval 28393,PropResponseInformation "(\174\188e",PropMaximumPacketSize 15079]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\a\206+\241_)~\225\174V\232:\184e", _pubPktID = 1045, _pubBody = "E\243x", _pubProps = [PropUserProperty "\135O\CAN\f(\133\158\229\237\&0:g$\SUB((\243W\228" "6\214\190\&0\238[\170\&5k\222\192?`\202,j\166\STX[\DLE\211\228\214\230\191\210\216W",PropUserProperty "Q\199y\153\173\ENQ\161\205DUN\128\231\149" "Eh\176\198\182\233\162\153#a\157\v\DLE\STX\135\NAK\201\128H\140",PropRequestResponseInformation 104,PropAssignedClientIdentifier "w\147\SUB\154RXi#\179\241\169k/E\187\170\US\SI(o]ZT\177\EM<\178",PropAuthenticationMethod "\206\160\SYN\ETB\231\245WV@\DELv\235",PropSessionExpiryInterval 9123,PropRequestProblemInformation 198,PropSharedSubscriptionAvailable 144,PropWildcardSubscriptionAvailable 30,PropTopicAlias 14192,PropTopicAliasMaximum 28876,PropContentType "\218\195\141G\183\247\135+\242fa\220\239\167\173u\SI\235\141",PropRequestProblemInformation 177,PropSessionExpiryInterval 85,PropReceiveMaximum 15015,PropResponseTopic "t$S\140\222\&6",PropRetainAvailable 130,PropPayloadFormatIndicator 149,PropResponseInformation "%!",PropResponseInformation "#z\191\231\149\EM\218\t\SYN?\202p\207\225\150c\t\228",PropUserProperty "\213z\f\194<\151" "\233\STX\184a),>\245I&\184\241\tE\224\ESC0h\130\138\254\206\209!M",PropServerKeepAlive 22611,PropCorrelationData "\128}\SO\223\179\158\136EI\244\145\ESCHq\DC4>:+\242\129\196I\245&\196\241",PropMessageExpiryInterval 9516,PropRetainAvailable 117,PropTopicAliasMaximum 18796,PropAuthenticationData "\228*W"]} TEST(Publish5QCTest, Decode27) { - uint8_t pkt[] = {0x38, 0xaf, 0x2, 0x0, 0x5, 0x90, 0xa7, 0x82, 0xb3, 0x41, 0x90, 0x2, 0x15, 0x0, 0x1c, 0x7c, 0x8f, - 0x71, 0xc3, 0xfb, 0x4d, 0xbf, 0xe8, 0x68, 0xb1, 0x50, 0xdf, 0x2b, 0x47, 0x4f, 0xd8, 0xcd, 0x1, 0x74, - 0x0, 0xc3, 0xa6, 0xd7, 0x95, 0xf8, 0x11, 0xac, 0xaf, 0x28, 0x6e, 0x13, 0x11, 0xc9, 0x26, 0x0, 0x9, - 0xab, 0x6e, 0x74, 0xcd, 0x4e, 0x40, 0xb5, 0x9e, 0x82, 0x0, 0x1e, 0x84, 0x26, 0x85, 0xab, 0x28, 0x9e, - 0xbf, 0x8d, 0x86, 0x0, 0x39, 0x7e, 0x5d, 0xa6, 0xb, 0x1f, 0xaf, 0x4b, 0x65, 0x35, 0x7b, 0x7a, 0x9b, - 0x7f, 0xdc, 0x51, 0x23, 0x90, 0xd2, 0x4c, 0x17, 0xd1, 0x2, 0x0, 0x0, 0x46, 0xd7, 0x25, 0x32, 0x2a, - 0x19, 0x19, 0x74, 0x12, 0x0, 0x9, 0xde, 0x7e, 0xae, 0xc5, 0x5d, 0x78, 0x7d, 0x9, 0x74, 0x12, 0x0, - 0x18, 0xfe, 0x6d, 0xde, 0x7e, 0xf6, 0x63, 0xec, 0x19, 0x78, 0x67, 0x63, 0xa, 0x85, 0x13, 0xa1, 0xd7, - 0x8a, 0xbd, 0xc4, 0xa0, 0xef, 0x76, 0xc3, 0xd6, 0x1c, 0x0, 0x1d, 0x76, 0xe4, 0xf5, 0x21, 0x2e, 0x7d, - 0x14, 0xea, 0xa7, 0x79, 0xf8, 0xc1, 0x91, 0xa3, 0x80, 0x85, 0xea, 0xde, 0x9a, 0x9b, 0x27, 0xd8, 0x3, - 0xb6, 0x95, 0xc4, 0x1c, 0xc6, 0x24, 0x3, 0x0, 0x1a, 0xc2, 0x9d, 0x86, 0xce, 0x4c, 0x9b, 0x9f, 0x54, - 0xb5, 0xe1, 0xca, 0xfb, 0xa5, 0x87, 0xda, 0x56, 0x2f, 0x4d, 0xe, 0x5c, 0xb6, 0x37, 0x9, 0x62, 0xba, - 0x79, 0x13, 0x70, 0x29, 0x12, 0x0, 0x17, 0xb8, 0x0, 0xc3, 0x58, 0x85, 0x93, 0xb1, 0x4a, 0x59, 0x88, - 0xc6, 0x1a, 0x24, 0xe7, 0x3c, 0x1a, 0x9a, 0xa6, 0xd6, 0xb4, 0xc1, 0x2f, 0x1c, 0x1a, 0x0, 0x4, 0x9d, - 0x2b, 0x36, 0xa9, 0x19, 0xe7, 0x18, 0x0, 0x0, 0x6a, 0x68, 0x27, 0x0, 0x0, 0xb, 0x8, 0x19, 0x71, - 0x1, 0x47, 0x1c, 0x0, 0x7, 0x21, 0x34, 0x18, 0xf1, 0x8e, 0xb5, 0x6a, 0x18, 0x0, 0x0, 0x6e, 0xe9, - 0x1a, 0x0, 0x4, 0x28, 0xae, 0xbc, 0x65, 0x27, 0x0, 0x0, 0x3a, 0xe7, 0x94, 0x86, 0xb9, 0xd5, 0xb8, - 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x33, 0xcd, 0x2, 0x0, 0xe, 0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65, 0x4, 0x15, 0xb6, 0x2, 0x26, 0x0, 0x13, 0x87, 0x4f, 0x18, 0xc, 0x28, 0x85, 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0x1, 0x95, 0x1a, 0x0, 0x2, 0x25, 0x21, 0x1a, 0x0, 0x12, 0x23, 0x7a, 0xbf, 0xe7, 0x95, 0x19, 0xda, 0x9, 0x16, 0x3f, 0xca, 0x70, 0xcf, 0xe1, 0x96, 0x63, 0x9, 0xe4, 0x26, 0x0, 0x6, 0xd5, 0x7a, 0xc, 0xc2, 0x3c, 0x97, 0x0, 0x19, 0xe9, 0x2, 0xb8, 0x61, 0x29, 0x2c, 0x3e, 0xf5, 0x49, 0x26, 0xb8, 0xf1, 0x9, 0x45, 0xe0, 0x1b, 0x30, 0x68, 0x82, 0x8a, 0xfe, 0xce, 0xd1, 0x21, 0x4d, 0x13, 0x58, 0x53, 0x9, 0x0, 0x1a, 0x80, 0x7d, 0xe, 0xdf, 0xb3, 0x9e, 0x88, 0x45, 0x49, 0xf4, 0x91, 0x1b, 0x48, 0x71, 0x14, 0x3e, 0x3a, 0x2b, 0xf2, 0x81, 0xc4, 0x49, 0xf5, 0x26, 0xc4, 0xf1, 0x2, 0x0, 0x0, 0x25, 0x2c, 0x25, 0x75, 0x22, 0x49, 0x6c, 0x16, 0x0, 0x3, 0xe4, 0x2a, 0x57, 0x45, 0xf3, 0x78}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x45, 0xf3, 0x78}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 1045); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); +EXPECT_EQ(msg.payload_len, 3); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x90, 0xa7, 0x82, 0xb3, 0x41}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x94, 0x86, 0xb9, 0xd5, 0xb8, 0xe9, 0xbb, 0x9d, 0xc6, 0xe9, 0xb5, - 0x94, 0x5f, 0xd7, 0xa, 0x24, 0x40, 0xa9, 0xfb, 0xd2, 0xb8, 0xc}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\187\249\143~(e\135", _pubProps = [PropSubscriptionIdentifier 20,PropUserProperty -// "\147\196\GS\178\rB9Y\145\CAN\135\233\179\rW\206" "\153\161\SUB\158\183;\192\CAN\US",PropAuthenticationData -// "",PropPayloadFormatIndicator 50,PropCorrelationData -// "P\SUB\136\&8\132\234f\SUB\196\232\&0\134\192\160\ETXB@\205\&4b\232\129\218~",PropReceiveMaximum 18515,PropMaximumQoS -// 108,PropTopicAliasMaximum 19988,PropRetainAvailable 87,PropMessageExpiryInterval 13619,PropSessionExpiryInterval -// 14566,PropAuthenticationMethod -// "\SO\222\190\199\&2\241*\185[\130\253%\255B1\131FP\163S\179\SUB\182\180\138\CAN\169",PropResponseTopic -// "\251\240\vp>\CAN,97\189!o\f\148\231",PropSubscriptionIdentifier 18,PropMessageExpiryInterval 21618,PropContentType -// "\172\211&\ESC\156\DEL\218\242\254\150Z\133\165\165\NAK,\182\STX\151H",PropServerReference -// "\220\DC2_\200\153`\227\190\NUL\188\216\143\DC1\214\135\CAN",PropReasonString -// "\130\DC3\149\&9\215\245\254",PropMaximumPacketSize 4301,PropAuthenticationData "\FS?",PropMaximumPacketSize -// 16401,PropRetainAvailable 43,PropServerReference "\"Uz\195\199B\176\226\187\CAN4\186\189\163"]} -TEST(Publish5QCTest, Encode28) { - uint8_t pkt[] = { - 0x39, 0xec, 0x1, 0x0, 0x0, 0xe1, 0x1, 0xb, 0x14, 0x26, 0x0, 0x10, 0x93, 0xc4, 0x1d, 0xb2, 0xd, 0x42, 0x39, - 0x59, 0x91, 0x18, 0x87, 0xe9, 0xb3, 0xd, 0x57, 0xce, 0x0, 0x9, 0x99, 0xa1, 0x1a, 0x9e, 0xb7, 0x3b, 0xc0, 0x18, - 0x1f, 0x16, 0x0, 0x0, 0x1, 0x32, 0x9, 0x0, 0x18, 0x50, 0x1a, 0x88, 0x38, 0x84, 0xea, 0x66, 0x1a, 0xc4, 0xe8, - 0x30, 0x86, 0xc0, 0xa0, 0x3, 0x42, 0x40, 0xcd, 0x34, 0x62, 0xe8, 0x81, 0xda, 0x7e, 0x21, 0x48, 0x53, 0x24, 0x6c, - 0x22, 0x4e, 0x14, 0x25, 0x57, 0x2, 0x0, 0x0, 0x35, 0x33, 0x11, 0x0, 0x0, 0x38, 0xe6, 0x15, 0x0, 0x1b, 0xe, - 0xde, 0xbe, 0xc7, 0x32, 0xf1, 0x2a, 0xb9, 0x5b, 0x82, 0xfd, 0x25, 0xff, 0x42, 0x31, 0x83, 0x46, 0x50, 0xa3, 0x53, - 0xb3, 0x1a, 0xb6, 0xb4, 0x8a, 0x18, 0xa9, 0x8, 0x0, 0xf, 0xfb, 0xf0, 0xb, 0x70, 0x3e, 0x18, 0x2c, 0x39, 0x37, - 0xbd, 0x21, 0x6f, 0xc, 0x94, 0xe7, 0xb, 0x12, 0x2, 0x0, 0x0, 0x54, 0x72, 0x3, 0x0, 0x14, 0xac, 0xd3, 0x26, - 0x1b, 0x9c, 0x7f, 0xda, 0xf2, 0xfe, 0x96, 0x5a, 0x85, 0xa5, 0xa5, 0x15, 0x2c, 0xb6, 0x2, 0x97, 0x48, 0x1c, 0x0, - 0x10, 0xdc, 0x12, 0x5f, 0xc8, 0x99, 0x60, 0xe3, 0xbe, 0x0, 0xbc, 0xd8, 0x8f, 0x11, 0xd6, 0x87, 0x18, 0x1f, 0x0, - 0x7, 0x82, 0x13, 0x95, 0x39, 0xd7, 0xf5, 0xfe, 0x27, 0x0, 0x0, 0x10, 0xcd, 0x16, 0x0, 0x2, 0x1c, 0x3f, 0x27, - 0x0, 0x0, 0x40, 0x11, 0x25, 0x2b, 0x1c, 0x0, 0xe, 0x22, 0x55, 0x7a, 0xc3, 0xc7, 0x42, 0xb0, 0xe2, 0xbb, 0x18, - 0x34, 0xba, 0xbd, 0xa3, 0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; - - uint8_t bytesprops1[] = {0x99, 0xa1, 0x1a, 0x9e, 0xb7, 0x3b, 0xc0, 0x18, 0x1f}; - uint8_t bytesprops0[] = {0x93, 0xc4, 0x1d, 0xb2, 0xd, 0x42, 0x39, 0x59, - 0x91, 0x18, 0x87, 0xe9, 0xb3, 0xd, 0x57, 0xce}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x50, 0x1a, 0x88, 0x38, 0x84, 0xea, 0x66, 0x1a, 0xc4, 0xe8, 0x30, 0x86, - 0xc0, 0xa0, 0x3, 0x42, 0x40, 0xcd, 0x34, 0x62, 0xe8, 0x81, 0xda, 0x7e}; - uint8_t bytesprops4[] = {0xe, 0xde, 0xbe, 0xc7, 0x32, 0xf1, 0x2a, 0xb9, 0x5b, 0x82, 0xfd, 0x25, 0xff, 0x42, - 0x31, 0x83, 0x46, 0x50, 0xa3, 0x53, 0xb3, 0x1a, 0xb6, 0xb4, 0x8a, 0x18, 0xa9}; - uint8_t bytesprops5[] = {0xfb, 0xf0, 0xb, 0x70, 0x3e, 0x18, 0x2c, 0x39, 0x37, 0xbd, 0x21, 0x6f, 0xc, 0x94, 0xe7}; - uint8_t bytesprops6[] = {0xac, 0xd3, 0x26, 0x1b, 0x9c, 0x7f, 0xda, 0xf2, 0xfe, 0x96, - 0x5a, 0x85, 0xa5, 0xa5, 0x15, 0x2c, 0xb6, 0x2, 0x97, 0x48}; - uint8_t bytesprops7[] = {0xdc, 0x12, 0x5f, 0xc8, 0x99, 0x60, 0xe3, 0xbe, - 0x0, 0xbc, 0xd8, 0x8f, 0x11, 0xd6, 0x87, 0x18}; - uint8_t bytesprops8[] = {0x82, 0x13, 0x95, 0x39, 0xd7, 0xf5, 0xfe}; - uint8_t bytesprops9[] = {0x1c, 0x3f}; - uint8_t bytesprops10[] = {0x22, 0x55, 0x7a, 0xc3, 0xc7, 0x42, 0xb0, 0xe2, 0xbb, 0x18, 0x34, 0xba, 0xbd, 0xa3}; +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\193`\187\247\203\252\193V\159\209\143}w\180\219\226\"\181nuE\nC\175-\SUB\141", _pubPktID = 0, _pubBody = "\213(\SUB\v\FS\224\252\152%p_*#w\218\204\240\237>\246", _pubProps = [PropReceiveMaximum 9423,PropMaximumQoS 52,PropSubscriptionIdentifierAvailable 143,PropRetainAvailable 169,PropServerKeepAlive 17612,PropWildcardSubscriptionAvailable 23,PropAssignedClientIdentifier "\185\154~\209#\ETB\140\220vi|\205P@|`\238^\137\194\250\207P",PropServerReference "bg\130Bs\SOHk\175\225\&1\206\186\129\234;m\149\163?\198\197\vI2",PropAuthenticationMethod "#\180\rR\SYN\146\154\238\163\163\204\225rk\221.UERH\ETB",PropCorrelationData "\173D\232\150\212",PropMessageExpiryInterval 22176,PropServerKeepAlive 26594,PropServerKeepAlive 339,PropServerReference "\EM\159S\176\t\228\156\DC1\227H\US\155\"q.\250\222\223\159\DC4\SOo\234[",PropSharedSubscriptionAvailable 144,PropSubscriptionIdentifierAvailable 236,PropRetainAvailable 111,PropCorrelationData "\198\144\221\167\158*\SYN\b\194\216",PropServerKeepAlive 20480,PropReceiveMaximum 24642,PropWildcardSubscriptionAvailable 206,PropMaximumQoS 243,PropAuthenticationData "\224M\n\225]e\226\213\239\&8\188=\234",PropAuthenticationMethod "\175\142\209/I\209\159\DEL\254i",PropWillDelayInterval 15570,PropAuthenticationData "&\EM'6a\253=f\231D\155",PropCorrelationData "\131\160\210\223\151\207%?S\219\DC4\US\129H\207\DLE\213p\CAN\136T"]} +TEST(Publish5QCTest, Encode28) { +uint8_t pkt[] = {0x30, 0xa1, 0x2, 0x0, 0x1b, 0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d, 0xee, 0x1, 0x21, 0x24, 0xcf, 0x24, 0x34, 0x29, 0x8f, 0x25, 0xa9, 0x13, 0x44, 0xcc, 0x28, 0x17, 0x12, 0x0, 0x17, 0xb9, 0x9a, 0x7e, 0xd1, 0x23, 0x17, 0x8c, 0xdc, 0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 0x0, 0x15, 0x83, 0xa0, 0xd2, 0xdf, 0x97, 0xcf, 0x25, 0x3f, 0x53, 0xdb, 0x14, 0x1f, 0x81, 0x48, 0xcf, 0x10, 0xd5, 0x70, 0x18, 0x88, 0x54, 0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; + uint8_t topic_bytes[] = {0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS0; +msg.retained = false; +uint8_t msg_bytes[] = {0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 20; + + uint8_t bytesprops0[] = {0xb9, 0x9a, 0x7e, 0xd1, 0x23, 0x17, 0x8c, 0xdc, 0x76, 0x69, 0x7c, 0xcd, 0x50, 0x40, 0x7c, 0x60, 0xee, 0x5e, 0x89, 0xc2, 0xfa, 0xcf, 0x50}; + uint8_t bytesprops1[] = {0x62, 0x67, 0x82, 0x42, 0x73, 0x1, 0x6b, 0xaf, 0xe1, 0x31, 0xce, 0xba, 0x81, 0xea, 0x3b, 0x6d, 0x95, 0xa3, 0x3f, 0xc6, 0xc5, 0xb, 0x49, 0x32}; + uint8_t bytesprops2[] = {0x23, 0xb4, 0xd, 0x52, 0x16, 0x92, 0x9a, 0xee, 0xa3, 0xa3, 0xcc, 0xe1, 0x72, 0x6b, 0xdd, 0x2e, 0x55, 0x45, 0x52, 0x48, 0x17}; + uint8_t bytesprops3[] = {0xad, 0x44, 0xe8, 0x96, 0xd4}; + uint8_t bytesprops4[] = {0x19, 0x9f, 0x53, 0xb0, 0x9, 0xe4, 0x9c, 0x11, 0xe3, 0x48, 0x1f, 0x9b, 0x22, 0x71, 0x2e, 0xfa, 0xde, 0xdf, 0x9f, 0x14, 0xe, 0x6f, 0xea, 0x5b}; + uint8_t bytesprops5[] = {0xc6, 0x90, 0xdd, 0xa7, 0x9e, 0x2a, 0x16, 0x8, 0xc2, 0xd8}; + uint8_t bytesprops6[] = {0xe0, 0x4d, 0xa, 0xe1, 0x5d, 0x65, 0xe2, 0xd5, 0xef, 0x38, 0xbc, 0x3d, 0xea}; + uint8_t bytesprops7[] = {0xaf, 0x8e, 0xd1, 0x2f, 0x49, 0xd1, 0x9f, 0x7f, 0xfe, 0x69}; + uint8_t bytesprops8[] = {0x26, 0x19, 0x27, 0x36, 0x61, 0xfd, 0x3d, 0x66, 0xe7, 0x44, 0x9b}; + uint8_t bytesprops9[] = {0x83, 0xa0, 0xd2, 0xdf, 0x97, 0xcf, 0x25, 0x3f, 0x53, 0xdb, 0x14, 0x1f, 0x81, 0x48, 0xcf, 0x10, 0xd5, 0x70, 0x18, 0x88, 0x54}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops0}, .v = {9, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18515}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19988}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13619}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14566}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21618}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4301}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16401}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9423}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17612}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22176}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26594}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 339}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20480}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24642}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15570}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\187\249\143~(e\135", _pubProps = [PropSubscriptionIdentifier 20,PropUserProperty -// "\147\196\GS\178\rB9Y\145\CAN\135\233\179\rW\206" "\153\161\SUB\158\183;\192\CAN\US",PropAuthenticationData -// "",PropPayloadFormatIndicator 50,PropCorrelationData -// "P\SUB\136\&8\132\234f\SUB\196\232\&0\134\192\160\ETXB@\205\&4b\232\129\218~",PropReceiveMaximum 18515,PropMaximumQoS -// 108,PropTopicAliasMaximum 19988,PropRetainAvailable 87,PropMessageExpiryInterval 13619,PropSessionExpiryInterval -// 14566,PropAuthenticationMethod -// "\SO\222\190\199\&2\241*\185[\130\253%\255B1\131FP\163S\179\SUB\182\180\138\CAN\169",PropResponseTopic -// "\251\240\vp>\CAN,97\189!o\f\148\231",PropSubscriptionIdentifier 18,PropMessageExpiryInterval 21618,PropContentType -// "\172\211&\ESC\156\DEL\218\242\254\150Z\133\165\165\NAK,\182\STX\151H",PropServerReference -// "\220\DC2_\200\153`\227\190\NUL\188\216\143\DC1\214\135\CAN",PropReasonString -// "\130\DC3\149\&9\215\245\254",PropMaximumPacketSize 4301,PropAuthenticationData "\FS?",PropMaximumPacketSize -// 16401,PropRetainAvailable 43,PropServerReference "\"Uz\195\199B\176\226\187\CAN4\186\189\163"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\193`\187\247\203\252\193V\159\209\143}w\180\219\226\"\181nuE\nC\175-\SUB\141", _pubPktID = 0, _pubBody = "\213(\SUB\v\FS\224\252\152%p_*#w\218\204\240\237>\246", _pubProps = [PropReceiveMaximum 9423,PropMaximumQoS 52,PropSubscriptionIdentifierAvailable 143,PropRetainAvailable 169,PropServerKeepAlive 17612,PropWildcardSubscriptionAvailable 23,PropAssignedClientIdentifier "\185\154~\209#\ETB\140\220vi|\205P@|`\238^\137\194\250\207P",PropServerReference "bg\130Bs\SOHk\175\225\&1\206\186\129\234;m\149\163?\198\197\vI2",PropAuthenticationMethod "#\180\rR\SYN\146\154\238\163\163\204\225rk\221.UERH\ETB",PropCorrelationData "\173D\232\150\212",PropMessageExpiryInterval 22176,PropServerKeepAlive 26594,PropServerKeepAlive 339,PropServerReference "\EM\159S\176\t\228\156\DC1\227H\US\155\"q.\250\222\223\159\DC4\SOo\234[",PropSharedSubscriptionAvailable 144,PropSubscriptionIdentifierAvailable 236,PropRetainAvailable 111,PropCorrelationData "\198\144\221\167\158*\SYN\b\194\216",PropServerKeepAlive 20480,PropReceiveMaximum 24642,PropWildcardSubscriptionAvailable 206,PropMaximumQoS 243,PropAuthenticationData "\224M\n\225]e\226\213\239\&8\188=\234",PropAuthenticationMethod "\175\142\209/I\209\159\DEL\254i",PropWillDelayInterval 15570,PropAuthenticationData "&\EM'6a\253=f\231D\155",PropCorrelationData "\131\160\210\223\151\207%?S\219\DC4\US\129H\207\DLE\213p\CAN\136T"]} TEST(Publish5QCTest, Decode28) { - uint8_t pkt[] = { - 0x39, 0xec, 0x1, 0x0, 0x0, 0xe1, 0x1, 0xb, 0x14, 0x26, 0x0, 0x10, 0x93, 0xc4, 0x1d, 0xb2, 0xd, 0x42, 0x39, - 0x59, 0x91, 0x18, 0x87, 0xe9, 0xb3, 0xd, 0x57, 0xce, 0x0, 0x9, 0x99, 0xa1, 0x1a, 0x9e, 0xb7, 0x3b, 0xc0, 0x18, - 0x1f, 0x16, 0x0, 0x0, 0x1, 0x32, 0x9, 0x0, 0x18, 0x50, 0x1a, 0x88, 0x38, 0x84, 0xea, 0x66, 0x1a, 0xc4, 0xe8, - 0x30, 0x86, 0xc0, 0xa0, 0x3, 0x42, 0x40, 0xcd, 0x34, 0x62, 0xe8, 0x81, 0xda, 0x7e, 0x21, 0x48, 0x53, 0x24, 0x6c, - 0x22, 0x4e, 0x14, 0x25, 0x57, 0x2, 0x0, 0x0, 0x35, 0x33, 0x11, 0x0, 0x0, 0x38, 0xe6, 0x15, 0x0, 0x1b, 0xe, - 0xde, 0xbe, 0xc7, 0x32, 0xf1, 0x2a, 0xb9, 0x5b, 0x82, 0xfd, 0x25, 0xff, 0x42, 0x31, 0x83, 0x46, 0x50, 0xa3, 0x53, - 0xb3, 0x1a, 0xb6, 0xb4, 0x8a, 0x18, 0xa9, 0x8, 0x0, 0xf, 0xfb, 0xf0, 0xb, 0x70, 0x3e, 0x18, 0x2c, 0x39, 0x37, - 0xbd, 0x21, 0x6f, 0xc, 0x94, 0xe7, 0xb, 0x12, 0x2, 0x0, 0x0, 0x54, 0x72, 0x3, 0x0, 0x14, 0xac, 0xd3, 0x26, - 0x1b, 0x9c, 0x7f, 0xda, 0xf2, 0xfe, 0x96, 0x5a, 0x85, 0xa5, 0xa5, 0x15, 0x2c, 0xb6, 0x2, 0x97, 0x48, 0x1c, 0x0, - 0x10, 0xdc, 0x12, 0x5f, 0xc8, 0x99, 0x60, 0xe3, 0xbe, 0x0, 0xbc, 0xd8, 0x8f, 0x11, 0xd6, 0x87, 0x18, 0x1f, 0x0, - 0x7, 0x82, 0x13, 0x95, 0x39, 0xd7, 0xf5, 0xfe, 0x27, 0x0, 0x0, 0x10, 0xcd, 0x16, 0x0, 0x2, 0x1c, 0x3f, 0x27, - 0x0, 0x0, 0x40, 0x11, 0x25, 0x2b, 0x1c, 0x0, 0xe, 0x22, 0x55, 0x7a, 0xc3, 0xc7, 0x42, 0xb0, 0xe2, 0xbb, 0x18, - 0x34, 0xba, 0xbd, 0xa3, 0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); +uint8_t pkt[] = {0x30, 0xa1, 0x2, 0x0, 0x1b, 0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8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0xa, 0xe1, 0x5d, 0x65, 0xe2, 0xd5, 0xef, 0x38, 0xbc, 0x3d, 0xea, 0x15, 0x0, 0xa, 0xaf, 0x8e, 0xd1, 0x2f, 0x49, 0xd1, 0x9f, 0x7f, 0xfe, 0x69, 0x18, 0x0, 0x0, 0x3c, 0xd2, 0x16, 0x0, 0xb, 0x26, 0x19, 0x27, 0x36, 0x61, 0xfd, 0x3d, 0x66, 0xe7, 0x44, 0x9b, 0x9, 0x0, 0x15, 0x83, 0xa0, 0xd2, 0xdf, 0x97, 0xcf, 0x25, 0x3f, 0x53, 0xdb, 0x14, 0x1f, 0x81, 0x48, 0xcf, 0x10, 0xd5, 0x70, 0x18, 0x88, 0x54, 0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS0); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 0); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); +EXPECT_EQ(msg.payload_len, 20); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); +lwmqtt_string_t x = exp_topic; +x = exp_body; - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbb, 0xf9, 0x8f, 0x7e, 0x28, 0x65, 0x87}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "h\137\169\166b`\193\RS\133\235I\188\167\&9\DC1\161uN\176\SOf\ACK-O\194\vo", _pubPktID = 7918, _pubBody = -// "G\142\SYN\154\171\162\185\ENQg\129\240\186 \199\202{\CAN\233\v^\170", _pubProps = [PropSubscriptionIdentifier -// 18,PropMessageExpiryInterval 2493,PropSessionExpiryInterval 20854,PropResponseTopic -// "\t\132-\200\130\192\134\236\159\SOH~\253\143\138\GS\185!)j\144\239{\n\134\188",PropSharedSubscriptionAvailable -// 152,PropCorrelationData "\EM%8\187\233Y\200\164\219.GZ#\153\183\&6\143\239\243\147\224",PropAssignedClientIdentifier -// "k",PropSubscriptionIdentifierAvailable 36,PropWildcardSubscriptionAvailable 46,PropTopicAliasMaximum -// 7511,PropAuthenticationData "\184\174\234\255\250\US6\STX\131\180\DC1\237&\152*:\247",PropResponseTopic -// "\183\SUB\180\189\164\RS/q\223\236\207b\162\251D\SYN",PropResponseInformation "",PropRequestProblemInformation -// 120,PropAuthenticationMethod "^\206'R\156",PropUserProperty "\222u\CAN\221!\202\131\129S/v\146U" -// "=UHL\166\246C\150\167\157\CAN\155\141M+T\203\238\170|",PropUserProperty "" -// "D/z\167\SO\145\170\157?sY\207I\132(4d\206!&?o;\130",PropSubscriptionIdentifier 26]} -TEST(Publish5QCTest, Encode29) { - uint8_t pkt[] = { - 0x3a, 0xfc, 0x1, 0x0, 0x1b, 0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, - 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0xc2, 0xb, 0x6f, 0x1e, 0xee, 0xc6, 0x1, 0xb, 0x12, - 0x2, 0x0, 0x0, 0x9, 0xbd, 0x11, 0x0, 0x0, 0x51, 0x76, 0x8, 0x0, 0x19, 0x9, 0x84, 0x2d, 0xc8, 0x82, 0xc0, - 0x86, 0xec, 0x9f, 0x1, 0x7e, 0xfd, 0x8f, 0x8a, 0x1d, 0xb9, 0x21, 0x29, 0x6a, 0x90, 0xef, 0x7b, 0xa, 0x86, 0xbc, - 0x2a, 0x98, 0x9, 0x0, 0x15, 0x19, 0x25, 0x38, 0xbb, 0xe9, 0x59, 0xc8, 0xa4, 0xdb, 0x2e, 0x47, 0x5a, 0x23, 0x99, - 0xb7, 0x36, 0x8f, 0xef, 0xf3, 0x93, 0xe0, 0x12, 0x0, 0x1, 0x6b, 0x29, 0x24, 0x28, 0x2e, 0x22, 0x1d, 0x57, 0x16, - 0x0, 0x11, 0xb8, 0xae, 0xea, 0xff, 0xfa, 0x1f, 0x36, 0x2, 0x83, 0xb4, 0x11, 0xed, 0x26, 0x98, 0x2a, 0x3a, 0xf7, - 0x8, 0x0, 0x10, 0xb7, 0x1a, 0xb4, 0xbd, 0xa4, 0x1e, 0x2f, 0x71, 0xdf, 0xec, 0xcf, 0x62, 0xa2, 0xfb, 0x44, 0x16, - 0x1a, 0x0, 0x0, 0x17, 0x78, 0x15, 0x0, 0x5, 0x5e, 0xce, 0x27, 0x52, 0x9c, 0x26, 0x0, 0xd, 0xde, 0x75, 0x18, - 0xdd, 0x21, 0xca, 0x83, 0x81, 0x53, 0x2f, 0x76, 0x92, 0x55, 0x0, 0x14, 0x3d, 0x55, 0x48, 0x4c, 0xa6, 0xf6, 0x43, - 0x96, 0xa7, 0x9d, 0x18, 0x9b, 0x8d, 0x4d, 0x2b, 0x54, 0xcb, 0xee, 0xaa, 0x7c, 0x26, 0x0, 0x0, 0x0, 0x18, 0x44, - 0x2f, 0x7a, 0xa7, 0xe, 0x91, 0xaa, 0x9d, 0x3f, 0x73, 0x59, 0xcf, 0x49, 0x84, 0x28, 0x34, 0x64, 0xce, 0x21, 0x26, - 0x3f, 0x6f, 0x3b, 0x82, 0xb, 0x1a, 0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, 0xba, 0x20, - 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; - uint8_t topic_bytes[] = {0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, - 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0xc2, 0xb, 0x6f}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; +} - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, - 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - - uint8_t bytesprops0[] = {0x9, 0x84, 0x2d, 0xc8, 0x82, 0xc0, 0x86, 0xec, 0x9f, 0x1, 0x7e, 0xfd, 0x8f, - 0x8a, 0x1d, 0xb9, 0x21, 0x29, 0x6a, 0x90, 0xef, 0x7b, 0xa, 0x86, 0xbc}; - uint8_t bytesprops1[] = {0x19, 0x25, 0x38, 0xbb, 0xe9, 0x59, 0xc8, 0xa4, 0xdb, 0x2e, 0x47, - 0x5a, 0x23, 0x99, 0xb7, 0x36, 0x8f, 0xef, 0xf3, 0x93, 0xe0}; - uint8_t bytesprops2[] = {0x6b}; - uint8_t bytesprops3[] = {0xb8, 0xae, 0xea, 0xff, 0xfa, 0x1f, 0x36, 0x2, 0x83, - 0xb4, 0x11, 0xed, 0x26, 0x98, 0x2a, 0x3a, 0xf7}; - uint8_t bytesprops4[] = {0xb7, 0x1a, 0xb4, 0xbd, 0xa4, 0x1e, 0x2f, 0x71, - 0xdf, 0xec, 0xcf, 0x62, 0xa2, 0xfb, 0x44, 0x16}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0x5e, 0xce, 0x27, 0x52, 0x9c}; - uint8_t bytesprops8[] = {0x3d, 0x55, 0x48, 0x4c, 0xa6, 0xf6, 0x43, 0x96, 0xa7, 0x9d, - 0x18, 0x9b, 0x8d, 0x4d, 0x2b, 0x54, 0xcb, 0xee, 0xaa, 0x7c}; - uint8_t bytesprops7[] = {0xde, 0x75, 0x18, 0xdd, 0x21, 0xca, 0x83, 0x81, 0x53, 0x2f, 0x76, 0x92, 0x55}; - uint8_t bytesprops10[] = {0x44, 0x2f, 0x7a, 0xa7, 0xe, 0x91, 0xaa, 0x9d, 0x3f, 0x73, 0x59, 0xcf, - 0x49, 0x84, 0x28, 0x34, 0x64, 0xce, 0x21, 0x26, 0x3f, 0x6f, 0x3b, 0x82}; - uint8_t bytesprops9[] = {0}; +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "}\180", _pubPktID = 11899, _pubBody = "\DC2\ACK%\181\DC3\164\204\173\204\223\DC2\161\&3uzk\152Xn\200\154d\154\143\245z\234", _pubProps = [PropTopicAliasMaximum 7896,PropResponseInformation "S9",PropRequestProblemInformation 238,PropTopicAlias 5269,PropWildcardSubscriptionAvailable 89,PropAuthenticationData "Q\239\248\130D\175\208\216\245\175\251-j\166\254}?r",PropTopicAliasMaximum 13548,PropMaximumPacketSize 11043,PropTopicAliasMaximum 13191,PropMessageExpiryInterval 29315,PropServerReference "\193$\226\145\182\194\&5\164",PropWillDelayInterval 17549,PropSubscriptionIdentifier 5,PropReceiveMaximum 20528,PropMessageExpiryInterval 4596,PropServerReference "\190",PropResponseTopic "r-\150\ACKj;\171p\DLE\240F\139r\NUL\233\144\145P\222\255\191\164/G\EOTi\133",PropAssignedClientIdentifier "\184\239^\234\179hA\255\\\DC3\US",PropResponseTopic "\196\DLE\186\253\138hei\SYN\250",PropMaximumPacketSize 1183,PropContentType "\178\207h\154\174\205\178\169\DC2\t-\FS\131u",PropTopicAliasMaximum 4401,PropUserProperty "^\146;=I\fvo\187\SOH\200\202S\DC3I\151" ".\168g\207z\DC1\248\234\DC2\b\143\175D\204\228m\139\141\206&W|\US\157\235\176B~\128N",PropPayloadFormatIndicator 126,PropTopicAliasMaximum 698]} +TEST(Publish5QCTest, Encode29) { +uint8_t pkt[] = {0x34, 0xff, 0x1, 0x0, 0x2, 0x7d, 0xb4, 0x2e, 0x7b, 0xdc, 0x1, 0x22, 0x1e, 0xd8, 0x1a, 0x0, 0x2, 0x53, 0x39, 0x17, 0xee, 0x23, 0x14, 0x95, 0x28, 0x59, 0x16, 0x0, 0x12, 0x51, 0xef, 0xf8, 0x82, 0x44, 0xaf, 0xd0, 0xd8, 0xf5, 0xaf, 0xfb, 0x2d, 0x6a, 0xa6, 0xfe, 0x7d, 0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a4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; + uint8_t topic_bytes[] = {0x7d, 0xb4}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS2; +msg.retained = false; +uint8_t msg_bytes[] = {0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 27; + + uint8_t bytesprops0[] = {0x53, 0x39}; + uint8_t bytesprops1[] = {0x51, 0xef, 0xf8, 0x82, 0x44, 0xaf, 0xd0, 0xd8, 0xf5, 0xaf, 0xfb, 0x2d, 0x6a, 0xa6, 0xfe, 0x7d, 0x3f, 0x72}; + uint8_t bytesprops2[] = {0xc1, 0x24, 0xe2, 0x91, 0xb6, 0xc2, 0x35, 0xa4}; + uint8_t bytesprops3[] = {0xbe}; + uint8_t bytesprops4[] = {0x72, 0x2d, 0x96, 0x6, 0x6a, 0x3b, 0xab, 0x70, 0x10, 0xf0, 0x46, 0x8b, 0x72, 0x0, 0xe9, 0x90, 0x91, 0x50, 0xde, 0xff, 0xbf, 0xa4, 0x2f, 0x47, 0x4, 0x69, 0x85}; + uint8_t bytesprops5[] = {0xb8, 0xef, 0x5e, 0xea, 0xb3, 0x68, 0x41, 0xff, 0x5c, 0x13, 0x1f}; + uint8_t bytesprops6[] = {0xc4, 0x10, 0xba, 0xfd, 0x8a, 0x68, 0x65, 0x69, 0x16, 0xfa}; + uint8_t bytesprops7[] = {0xb2, 0xcf, 0x68, 0x9a, 0xae, 0xcd, 0xb2, 0xa9, 0x12, 0x9, 0x2d, 0x1c, 0x83, 0x75}; + uint8_t bytesprops9[] = {0x2e, 0xa8, 0x67, 0xcf, 0x7a, 0x11, 0xf8, 0xea, 0x12, 0x8, 0x8f, 0xaf, 0x44, 0xcc, 0xe4, 0x6d, 0x8b, 0x8d, 0xce, 0x26, 0x57, 0x7c, 0x1f, 0x9d, 0xeb, 0xb0, 0x42, 0x7e, 0x80, 0x4e}; + uint8_t bytesprops8[] = {0x5e, 0x92, 0x3b, 0x3d, 0x49, 0xc, 0x76, 0x6f, 0xbb, 0x1, 0xc8, 0xca, 0x53, 0x13, 0x49, 0x97}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2493}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20854}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7511}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops7}, .v = {20, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops9}, .v = {24, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7896}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5269}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13548}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11043}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13191}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29315}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17549}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20528}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4596}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1183}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4401}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={16, (char*)&bytesprops8}, .v={30, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 698}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7918, topic, msg, props); + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 11899, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "h\137\169\166b`\193\RS\133\235I\188\167\&9\DC1\161uN\176\SOf\ACK-O\194\vo", _pubPktID = 7918, _pubBody = -// "G\142\SYN\154\171\162\185\ENQg\129\240\186 \199\202{\CAN\233\v^\170", _pubProps = [PropSubscriptionIdentifier -// 18,PropMessageExpiryInterval 2493,PropSessionExpiryInterval 20854,PropResponseTopic -// "\t\132-\200\130\192\134\236\159\SOH~\253\143\138\GS\185!)j\144\239{\n\134\188",PropSharedSubscriptionAvailable -// 152,PropCorrelationData "\EM%8\187\233Y\200\164\219.GZ#\153\183\&6\143\239\243\147\224",PropAssignedClientIdentifier -// "k",PropSubscriptionIdentifierAvailable 36,PropWildcardSubscriptionAvailable 46,PropTopicAliasMaximum -// 7511,PropAuthenticationData "\184\174\234\255\250\US6\STX\131\180\DC1\237&\152*:\247",PropResponseTopic -// "\183\SUB\180\189\164\RS/q\223\236\207b\162\251D\SYN",PropResponseInformation "",PropRequestProblemInformation -// 120,PropAuthenticationMethod "^\206'R\156",PropUserProperty "\222u\CAN\221!\202\131\129S/v\146U" -// "=UHL\166\246C\150\167\157\CAN\155\141M+T\203\238\170|",PropUserProperty "" -// "D/z\167\SO\145\170\157?sY\207I\132(4d\206!&?o;\130",PropSubscriptionIdentifier 26]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "}\180", _pubPktID = 11899, _pubBody = "\DC2\ACK%\181\DC3\164\204\173\204\223\DC2\161\&3uzk\152Xn\200\154d\154\143\245z\234", _pubProps = [PropTopicAliasMaximum 7896,PropResponseInformation "S9",PropRequestProblemInformation 238,PropTopicAlias 5269,PropWildcardSubscriptionAvailable 89,PropAuthenticationData "Q\239\248\130D\175\208\216\245\175\251-j\166\254}?r",PropTopicAliasMaximum 13548,PropMaximumPacketSize 11043,PropTopicAliasMaximum 13191,PropMessageExpiryInterval 29315,PropServerReference "\193$\226\145\182\194\&5\164",PropWillDelayInterval 17549,PropSubscriptionIdentifier 5,PropReceiveMaximum 20528,PropMessageExpiryInterval 4596,PropServerReference "\190",PropResponseTopic "r-\150\ACKj;\171p\DLE\240F\139r\NUL\233\144\145P\222\255\191\164/G\EOTi\133",PropAssignedClientIdentifier "\184\239^\234\179hA\255\\\DC3\US",PropResponseTopic "\196\DLE\186\253\138hei\SYN\250",PropMaximumPacketSize 1183,PropContentType "\178\207h\154\174\205\178\169\DC2\t-\FS\131u",PropTopicAliasMaximum 4401,PropUserProperty "^\146;=I\fvo\187\SOH\200\202S\DC3I\151" ".\168g\207z\DC1\248\234\DC2\b\143\175D\204\228m\139\141\206&W|\US\157\235\176B~\128N",PropPayloadFormatIndicator 126,PropTopicAliasMaximum 698]} TEST(Publish5QCTest, Decode29) { - uint8_t pkt[] = { - 0x3a, 0xfc, 0x1, 0x0, 0x1b, 0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, - 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0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0x73, 0x59, 0xcf, 0x49, 0x84, 0x28, 0x34, 0x64, 0xce, 0x21, 0x26, - 0x3f, 0x6f, 0x3b, 0x82, 0xb, 0x1a, 0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, 0xba, 0x20, - 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x68, 0x89, 0xa9, 0xa6, 0x62, 0x60, 0xc1, 0x1e, 0x85, 0xeb, 0x49, 0xbc, 0xa7, 0x39, - 0x11, 0xa1, 0x75, 0x4e, 0xb0, 0xe, 0x66, 0x6, 0x2d, 0x4f, 0xc2, 0xb, 0x6f}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x47, 0x8e, 0x16, 0x9a, 0xab, 0xa2, 0xb9, 0x5, 0x67, 0x81, 0xf0, - 0xba, 0x20, 0xc7, 0xca, 0x7b, 0x18, 0xe9, 0xb, 0x5e, 0xaa}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 7918); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "k\r\250c\140\225\149\144@\133", -// _pubPktID = 0, _pubBody = "',/I\RSD\195\229\202", _pubProps = [PropResponseInformation -// "gd\181",PropMessageExpiryInterval 12250]} +uint8_t pkt[] = {0x34, 0xff, 0x1, 0x0, 0x2, 0x7d, 0xb4, 0x2e, 0x7b, 0xdc, 0x1, 0x22, 0x1e, 0xd8, 0x1a, 0x0, 0x2, 0x53, 0x39, 0x17, 0xee, 0x23, 0x14, 0x95, 0x28, 0x59, 0x16, 0x0, 0x12, 0x51, 0xef, 0xf8, 0x82, 0x44, 0xaf, 0xd0, 0xd8, 0xf5, 0xaf, 0xfb, 0x2d, 0x6a, 0xa6, 0xfe, 0x7d, 0x3f, 0x72, 0x22, 0x34, 0xec, 0x27, 0x0, 0x0, 0x2b, 0x23, 0x22, 0x33, 0x87, 0x2, 0x0, 0x0, 0x72, 0x83, 0x1c, 0x0, 0x8, 0xc1, 0x24, 0xe2, 0x91, 0xb6, 0xc2, 0x35, 0xa4, 0x18, 0x0, 0x0, 0x44, 0x8d, 0xb, 0x5, 0x21, 0x50, 0x30, 0x2, 0x0, 0x0, 0x11, 0xf4, 0x1c, 0x0, 0x1, 0xbe, 0x8, 0x0, 0x1b, 0x72, 0x2d, 0x96, 0x6, 0x6a, 0x3b, 0xab, 0x70, 0x10, 0xf0, 0x46, 0x8b, 0x72, 0x0, 0xe9, 0x90, 0x91, 0x50, 0xde, 0xff, 0xbf, 0xa4, 0x2f, 0x47, 0x4, 0x69, 0x85, 0x12, 0x0, 0xb, 0xb8, 0xef, 0x5e, 0xea, 0xb3, 0x68, 0x41, 0xff, 0x5c, 0x13, 0x1f, 0x8, 0x0, 0xa, 0xc4, 0x10, 0xba, 0xfd, 0x8a, 0x68, 0x65, 0x69, 0x16, 0xfa, 0x27, 0x0, 0x0, 0x4, 0x9f, 0x3, 0x0, 0xe, 0xb2, 0xcf, 0x68, 0x9a, 0xae, 0xcd, 0xb2, 0xa9, 0x12, 0x9, 0x2d, 0x1c, 0x83, 0x75, 0x22, 0x11, 0x31, 0x26, 0x0, 0x10, 0x5e, 0x92, 0x3b, 0x3d, 0x49, 0xc, 0x76, 0x6f, 0xbb, 0x1, 0xc8, 0xca, 0x53, 0x13, 0x49, 0x97, 0x0, 0x1e, 0x2e, 0xa8, 0x67, 0xcf, 0x7a, 0x11, 0xf8, 0xea, 0x12, 0x8, 0x8f, 0xaf, 0x44, 0xcc, 0xe4, 0x6d, 0x8b, 0x8d, 0xce, 0x26, 0x57, 0x7c, 0x1f, 0x9d, 0xeb, 0xb0, 0x42, 0x7e, 0x80, 0x4e, 0x1, 0x7e, 0x22, 0x2, 0xba, 0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7d, 0xb4}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, false); +EXPECT_EQ(msg.qos, LWMQTT_QOS2); +EXPECT_EQ(msg.retained, false); +EXPECT_EQ(packet_id, 11899); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); +EXPECT_EQ(msg.payload_len, 27); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); +lwmqtt_string_t x = exp_topic; +x = exp_body; + +} + + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\tnz^#/~y\225", _pubPktID = 17773, _pubBody = "\130\\'n\215\&3\DC2\219\205\147\SOI\183c", _pubProps = [PropRequestProblemInformation 236]} TEST(Publish5QCTest, Encode30) { - uint8_t pkt[] = {0x30, 0x21, 0x0, 0xa, 0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, - 0x40, 0x85, 0xb, 0x1a, 0x0, 0x3, 0x67, 0x64, 0xb5, 0x2, 0x0, 0x0, - 0x2f, 0xda, 0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; - uint8_t topic_bytes[] = {0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, 0x40, 0x85}; +uint8_t pkt[] = {0x3b, 0x1f, 0x0, 0xa, 0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1, 0x45, 0x6d, 0x2, 0x17, 0xec, 0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; + uint8_t topic_bytes[] = {0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1}; lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; - msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; - - uint8_t bytesprops0[] = {0x67, 0x64, 0xb5}; + uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_message_t msg = lwmqtt_default_message; +msg.qos = LWMQTT_QOS1; +msg.retained = true; +uint8_t msg_bytes[] = {0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; +msg.payload = (unsigned char*)&msg_bytes; +msg.payload_len = 14; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12250}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 236}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 17773, topic, msg, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "k\r\250c\140\225\149\144@\133", -// _pubPktID = 0, _pubBody = "',/I\RSD\195\229\202", _pubProps = [PropResponseInformation -// "gd\181",PropMessageExpiryInterval 12250]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\tnz^#/~y\225", _pubPktID = 17773, _pubBody = "\130\\'n\215\&3\DC2\219\205\147\SOI\183c", _pubProps = [PropRequestProblemInformation 236]} TEST(Publish5QCTest, Decode30) { - uint8_t pkt[] = {0x30, 0x21, 0x0, 0xa, 0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, - 0x40, 0x85, 0xb, 0x1a, 0x0, 0x3, 0x67, 0x64, 0xb5, 0x2, 0x0, 0x0, - 0x2f, 0xda, 0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; - bool dup; - uint16_t packet_id; - lwmqtt_string_t topic; - lwmqtt_message_t msg; - lwmqtt_serialized_properties_t props; - lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x6b, 0xd, 0xfa, 0x63, 0x8c, 0xe1, 0x95, 0x90, 0x40, 0x85}; +uint8_t pkt[] = {0x3b, 0x1f, 0x0, 0xa, 0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1, 0x45, 0x6d, 0x2, 0x17, 0xec, 0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; +bool dup; +uint16_t packet_id; +lwmqtt_string_t topic; +lwmqtt_message_t msg; +lwmqtt_serialized_properties_t props; +lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); + +EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1}; lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x27, 0x2c, 0x2f, 0x49, 0x1e, 0x44, 0xc3, 0xe5, 0xca}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); - lwmqtt_string_t x = exp_topic; - x = exp_body; -} - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "\STX'd2\162\&8\201\179\247\166Y\212\\E\134\229", _willMsg = -// "\STX\227Q\213\190e/R\238\220$q\218Y~\146:~\ESCo\213\150\243\EM\156+r", _willProps = []}), _cleanSession = True, -// _keepAlive = 14707, _connID = "\r\239\133\224\t\138Z\SOHVQ\194n\b\"", _properties = []} -TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x39, 0x73, 0x0, 0xe, 0xd, - 0xef, 0x85, 0xe0, 0x9, 0x8a, 0x5a, 0x1, 0x56, 0x51, 0xc2, 0x6e, 0x8, 0x22, 0x0, 0x10, - 0x2, 0x27, 0x64, 0x32, 0xa2, 0x38, 0xc9, 0xb3, 0xf7, 0xa6, 0x59, 0xd4, 0x5c, 0x45, 0x86, - 0xe5, 0x0, 0x1b, 0x2, 0xe3, 0x51, 0xd5, 0xbe, 0x65, 0x2f, 0x52, 0xee, 0xdc, 0x24, 0x71, - 0xda, 0x59, 0x7e, 0x92, 0x3a, 0x7e, 0x1b, 0x6f, 0xd5, 0x96, 0xf3, 0x19, 0x9c, 0x2b, 0x72}; - uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t exp_body_bytes[] = {0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; +EXPECT_EQ(dup, true); +EXPECT_EQ(msg.qos, LWMQTT_QOS1); +EXPECT_EQ(msg.retained, true); +EXPECT_EQ(packet_id, 17773); +EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); +EXPECT_EQ(msg.payload_len, 14); +EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); +lwmqtt_string_t x = exp_topic; +x = exp_body; - lwmqtt_property_t propslist[] = {}; +} - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - lwmqtt_property_t willpropslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Just "<\200\232q\179c\222\168\a\186M\US\251I\210\222w\195H8\NUL\242!X\199s\219\245\165i", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "e\166s3\SOH\158_\232u5y\249\184aJ\194\246\220\226\184\209\223\EM", _willMsg = "_\245\131\131I\205\b\225\ETB\152\SO\152\&0\ENQ\145<\158\t4:\135", _willProps = []}), _cleanSession = False, _keepAlive = 14400, _connID = "\NAK\178o-", _properties = []} +TEST(Connect311QCTest, Encode1) { +uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2c, 0x38, 0x40, 0x0, 0x4, 0x15, 0xb2, 0x6f, 0x2d, 0x0, 0x17, 0x65, 0xa6, 0x73, 0x33, 0x1, 0x9e, 0x5f, 0xe8, 0x75, 0x35, 0x79, 0xf9, 0xb8, 0x61, 0x4a, 0xc2, 0xf6, 0xdc, 0xe2, 0xb8, 0xd1, 0xdf, 0x19, 0x0, 0x15, 0x5f, 0xf5, 0x83, 0x83, 0x49, 0xcd, 0x8, 0xe1, 0x17, 0x98, 0xe, 0x98, 0x30, 0x5, 0x91, 0x3c, 0x9e, 0x9, 0x34, 0x3a, 0x87}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2, 0x27, 0x64, 0x32, 0xa2, 0x38, 0xc9, 0xb3, - 0xf7, 0xa6, 0x59, 0xd4, 0x5c, 0x45, 0x86, 0xe5}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x2, 0xe3, 0x51, 0xd5, 0xbe, 0x65, 0x2f, 0x52, 0xee, 0xdc, 0x24, 0x71, 0xda, 0x59, - 0x7e, 0x92, 0x3a, 0x7e, 0x1b, 0x6f, 0xd5, 0x96, 0xf3, 0x19, 0x9c, 0x2b, 0x72}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14707; - uint8_t client_id_bytes[] = {0xd, 0xef, 0x85, 0xe0, 0x9, 0x8a, 0x5a, 0x1, 0x56, 0x51, 0xc2, 0x6e, 0x8, 0x22}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0x65, 0xa6, 0x73, 0x33, 0x1, 0x9e, 0x5f, 0xe8, 0x75, 0x35, 0x79, 0xf9, 0xb8, 0x61, 0x4a, 0xc2, 0xf6, 0xdc, 0xe2, 0xb8, 0xd1, 0xdf, 0x19}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5f, 0xf5, 0x83, 0x83, 0x49, 0xcd, 0x8, 0xe1, 0x17, 0x98, 0xe, 0x98, 0x30, 0x5, 0x91, 0x3c, 0x9e, 0x9, 0x34, 0x3a, 0x87}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 14400; + uint8_t client_id_bytes[] = {0x15, 0xb2, 0x6f, 0x2d}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x3c, 0xc8, 0xe8, 0x71, 0xb3, 0x63, 0xde, 0xa8, 0x7, 0xba, 0x4d, 0x1f, 0xfb, 0x49, 0xd2, 0xde, 0x77, 0xc3, 0x48, 0x38, 0x0, 0xf2, 0x21, 0x58, 0xc7, 0x73, 0xdb, 0xf5, 0xa5, 0x69}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\175\223\237\151\165\143\181\186", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\224\241\206\223", _willMsg = "<\185B\DC1", _willProps = []}), -// _cleanSession = True, _keepAlive = 12709, _connID = "qR&\218b\224.r|a\206\139\226\174(\216\EM\193", _properties = []} -TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x2a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x31, 0xa5, 0x0, 0x12, 0x71, - 0x52, 0x26, 0xda, 0x62, 0xe0, 0x2e, 0x72, 0x7c, 0x61, 0xce, 0x8b, 0xe2, 0xae, 0x28, 0xd8, - 0x19, 0xc1, 0x0, 0x4, 0xe0, 0xf1, 0xce, 0xdf, 0x0, 0x4, 0x3c, 0xb9, 0x42, 0x11}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\157\&7\160\&4!<\152o", _willMsg = "\207\206*\r\196x\199J", _willProps = []}), _cleanSession = False, _keepAlive = 22372, _connID = "\153\215g\142q\253\SUB\139\224jU\202Kb\220Q\233\DC2\137\&5", _properties = []} +TEST(Connect311QCTest, Encode2) { +uint8_t pkt[] = {0x10, 0x34, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x57, 0x64, 0x0, 0x14, 0x99, 0xd7, 0x67, 0x8e, 0x71, 0xfd, 0x1a, 0x8b, 0xe0, 0x6a, 0x55, 0xca, 0x4b, 0x62, 0xdc, 0x51, 0xe9, 0x12, 0x89, 0x35, 0x0, 0x8, 0x9d, 0x37, 0xa0, 0x34, 0x21, 0x3c, 0x98, 0x6f, 0x0, 0x8, 0xcf, 0xce, 0x2a, 0xd, 0xc4, 0x78, 0xc7, 0x4a}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe0, 0xf1, 0xce, 0xdf}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3c, 0xb9, 0x42, 0x11}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 12709; - uint8_t client_id_bytes[] = {0x71, 0x52, 0x26, 0xda, 0x62, 0xe0, 0x2e, 0x72, 0x7c, - 0x61, 0xce, 0x8b, 0xe2, 0xae, 0x28, 0xd8, 0x19, 0xc1}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xaf, 0xdf, 0xed, 0x97, 0xa5, 0x8f, 0xb5, 0xba}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0x9d, 0x37, 0xa0, 0x34, 0x21, 0x3c, 0x98, 0x6f}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xcf, 0xce, 0x2a, 0xd, 0xc4, 0x78, 0xc7, 0x4a}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 22372; + uint8_t client_id_bytes[] = {0x99, 0xd7, 0x67, 0x8e, 0x71, 0xfd, 0x1a, 0x8b, 0xe0, 0x6a, 0x55, 0xca, 0x4b, 0x62, 0xdc, 0x51, 0xe9, 0x12, 0x89, 0x35}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; +opts.client_id = client_id; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\223\255G", _password = Just "#\227\223\166s\STX2\230O\200nx\147\&0y\STX", -// _lastWill = Nothing, _cleanSession = False, _keepAlive = 17542, _connID = "S_\ACKjq\165\200(O\181\US\v\216", -// _properties = []} -TEST(Connect311QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0x30, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x44, 0x86, 0x0, 0xd, 0x53, 0x5f, 0x6, - 0x6a, 0x71, 0xa5, 0xc8, 0x28, 0x4f, 0xb5, 0x1f, 0xb, 0xd8, 0x0, 0x3, 0xdf, 0xff, 0x47, 0x0, 0x10, - 0x23, 0xe3, 0xdf, 0xa6, 0x73, 0x2, 0x32, 0xe6, 0x4f, 0xc8, 0x6e, 0x78, 0x93, 0x30, 0x79, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "\210\154\156`\157$\167\211\ACK|\EMc\FS\DC4;\244\132\247\250\DC1p\226", _password = Just "\250\211\178\rK\SUB\US\221G\171\f\202\222h\195\201\142\SOH\178\141\RS\179\234d\191G\245\249", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\166\245E _4\192:\130\134\233", _willMsg = "\199!\216\227\149HhD#\178\nH@\210\185:C\147\183\168", _willProps = []}), _cleanSession = False, _keepAlive = 11307, _connID = "\214\137\207{L;\190\191\172O\206z4\183", _properties = []} +TEST(Connect311QCTest, Encode3) { +uint8_t pkt[] = {0x10, 0x73, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x2c, 0x2b, 0x0, 0xe, 0xd6, 0x89, 0xcf, 0x7b, 0x4c, 0x3b, 0xbe, 0xbf, 0xac, 0x4f, 0xce, 0x7a, 0x34, 0xb7, 0x0, 0xb, 0xa6, 0xf5, 0x45, 0x20, 0x5f, 0x34, 0xc0, 0x3a, 0x82, 0x86, 0xe9, 0x0, 0x14, 0xc7, 0x21, 0xd8, 0xe3, 0x95, 0x48, 0x68, 0x44, 0x23, 0xb2, 0xa, 0x48, 0x40, 0xd2, 0xb9, 0x3a, 0x43, 0x93, 0xb7, 0xa8, 0x0, 0x16, 0xd2, 0x9a, 0x9c, 0x60, 0x9d, 0x24, 0xa7, 0xd3, 0x6, 0x7c, 0x19, 0x63, 0x1c, 0x14, 0x3b, 0xf4, 0x84, 0xf7, 0xfa, 0x11, 0x70, 0xe2, 0x0, 0x1c, 0xfa, 0xd3, 0xb2, 0xd, 0x4b, 0x1a, 0x1f, 0xdd, 0x47, 0xab, 0xc, 0xca, 0xde, 0x68, 0xc3, 0xc9, 0x8e, 0x1, 0xb2, 0x8d, 0x1e, 0xb3, 0xea, 0x64, 0xbf, 0x47, 0xf5, 0xf9}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 17542; - uint8_t client_id_bytes[] = {0x53, 0x5f, 0x6, 0x6a, 0x71, 0xa5, 0xc8, 0x28, 0x4f, 0xb5, 0x1f, 0xb, 0xd8}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xdf, 0xff, 0x47}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x23, 0xe3, 0xdf, 0xa6, 0x73, 0x2, 0x32, 0xe6, - 0x4f, 0xc8, 0x6e, 0x78, 0x93, 0x30, 0x79, 0x2}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\228O\159\147\140e", _password = Just -// "I7\205O\249\210\201\ACK\248\fH\247\&4\ENQ\139\231o\196", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 1450, _connID = "m\207\182 \176\137\206\172\198Q\255\173\143\SYN\154\153\143\208\181\155ao_\227\206", _properties = -// []} -TEST(Connect311QCTest, Encode4) { - uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x5, 0xaa, 0x0, 0x19, 0x6d, 0xcf, 0xb6, - 0x20, 0xb0, 0x89, 0xce, 0xac, 0xc6, 0x51, 0xff, 0xad, 0x8f, 0x16, 0x9a, 0x99, 0x8f, 0xd0, 0xb5, 0x9b, - 0x61, 0x6f, 0x5f, 0xe3, 0xce, 0x0, 0x6, 0xe4, 0x4f, 0x9f, 0x93, 0x8c, 0x65, 0x0, 0x12, 0x49, 0x37, - 0xcd, 0x4f, 0xf9, 0xd2, 0xc9, 0x6, 0xf8, 0xc, 0x48, 0xf7, 0x34, 0x5, 0x8b, 0xe7, 0x6f, 0xc4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; - lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa6, 0xf5, 0x45, 0x20, 0x5f, 0x34, 0xc0, 0x3a, 0x82, 0x86, 0xe9}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc7, 0x21, 0xd8, 0xe3, 0x95, 0x48, 0x68, 0x44, 0x23, 0xb2, 0xa, 0x48, 0x40, 0xd2, 0xb9, 0x3a, 0x43, 0x93, 0xb7, 0xa8}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS0; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 11307; + uint8_t client_id_bytes[] = {0xd6, 0x89, 0xcf, 0x7b, 0x4c, 0x3b, 0xbe, 0xbf, 0xac, 0x4f, 0xce, 0x7a, 0x34, 0xb7}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xd2, 0x9a, 0x9c, 0x60, 0x9d, 0x24, 0xa7, 0xd3, 0x6, 0x7c, 0x19, 0x63, 0x1c, 0x14, 0x3b, 0xf4, 0x84, 0xf7, 0xfa, 0x11, 0x70, 0xe2}; + lwmqtt_string_t username = {22, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0xfa, 0xd3, 0xb2, 0xd, 0x4b, 0x1a, 0x1f, 0xdd, 0x47, 0xab, 0xc, 0xca, 0xde, 0x68, 0xc3, 0xc9, 0x8e, 0x1, 0xb2, 0x8d, 0x1e, 0xb3, 0xea, 0x64, 0xbf, 0x47, 0xf5, 0xf9}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 1450; - uint8_t client_id_bytes[] = {0x6d, 0xcf, 0xb6, 0x20, 0xb0, 0x89, 0xce, 0xac, 0xc6, 0x51, 0xff, 0xad, 0x8f, - 0x16, 0x9a, 0x99, 0x8f, 0xd0, 0xb5, 0x9b, 0x61, 0x6f, 0x5f, 0xe3, 0xce}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xe4, 0x4f, 0x9f, 0x93, 0x8c, 0x65}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x49, 0x37, 0xcd, 0x4f, 0xf9, 0xd2, 0xc9, 0x6, 0xf8, - 0xc, 0x48, 0xf7, 0x34, 0x5, 0x8b, 0xe7, 0x6f, 0xc4}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "ZY*\212\&2v\CAN\238\SYN\243Z-\210z\SO\229X\164`\136 \ETB\246\182zw}0\148\v", -// _password = Just "\150\&2b)", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = -// "KY\242", _willMsg = "]\169\158\183\223\181L\153xld\SI\SI\155\&6\211\239", _willProps = []}), _cleanSession = False, -// _keepAlive = 18195, _connID = "v\132\v6\r\164\241\&1VUf\239\GS\210\201!\158\240\&7\194", _properties = []} -TEST(Connect311QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0x5e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x47, 0x13, 0x0, 0x14, 0x76, 0x84, - 0xb, 0x36, 0xd, 0xa4, 0xf1, 0x31, 0x56, 0x55, 0x66, 0xef, 0x1d, 0xd2, 0xc9, 0x21, 0x9e, 0xf0, - 0x37, 0xc2, 0x0, 0x3, 0x4b, 0x59, 0xf2, 0x0, 0x11, 0x5d, 0xa9, 0x9e, 0xb7, 0xdf, 0xb5, 0x4c, - 0x99, 0x78, 0x6c, 0x64, 0xf, 0xf, 0x9b, 0x36, 0xd3, 0xef, 0x0, 0x1e, 0x5a, 0x59, 0x2a, 0xd4, - 0x32, 0x76, 0x18, 0xee, 0x16, 0xf3, 0x5a, 0x2d, 0xd2, 0x7a, 0xe, 0xe5, 0x58, 0xa4, 0x60, 0x88, - 0x20, 0x17, 0xf6, 0xb6, 0x7a, 0x77, 0x7d, 0x30, 0x94, 0xb, 0x0, 0x4, 0x96, 0x32, 0x62, 0x29}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "\129&\239\168\247MW\197\EOT\DEL\231\f9.aTK,o\DC324I\149\171", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\192\172\136", _willMsg = "W\132\155\204", _willProps = []}), _cleanSession = True, _keepAlive = 16616, _connID = "f4\EOTKMC\199\173\161\251\151", _properties = []} +TEST(Connect311QCTest, Encode4) { +uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa6, 0x40, 0xe8, 0x0, 0xb, 0x66, 0x34, 0x4, 0x4b, 0x4d, 0x43, 0xc7, 0xad, 0xa1, 0xfb, 0x97, 0x0, 0x3, 0xc0, 0xac, 0x88, 0x0, 0x4, 0x57, 0x84, 0x9b, 0xcc, 0x0, 0x19, 0x81, 0x26, 0xef, 0xa8, 0xf7, 0x4d, 0x57, 0xc5, 0x4, 0x7f, 0xe7, 0xc, 0x39, 0x2e, 0x61, 0x54, 0x4b, 0x2c, 0x6f, 0x13, 0x32, 0x34, 0x49, 0x95, 0xab}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4b, 0x59, 0xf2}; + uint8_t will_topic_bytes[] = {0xc0, 0xac, 0x88}; lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5d, 0xa9, 0x9e, 0xb7, 0xdf, 0xb5, 0x4c, 0x99, 0x78, - 0x6c, 0x64, 0xf, 0xf, 0x9b, 0x36, 0xd3, 0xef}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 18195; - uint8_t client_id_bytes[] = {0x76, 0x84, 0xb, 0x36, 0xd, 0xa4, 0xf1, 0x31, 0x56, 0x55, - 0x66, 0xef, 0x1d, 0xd2, 0xc9, 0x21, 0x9e, 0xf0, 0x37, 0xc2}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x5a, 0x59, 0x2a, 0xd4, 0x32, 0x76, 0x18, 0xee, 0x16, 0xf3, 0x5a, 0x2d, 0xd2, 0x7a, 0xe, - 0xe5, 0x58, 0xa4, 0x60, 0x88, 0x20, 0x17, 0xf6, 0xb6, 0x7a, 0x77, 0x7d, 0x30, 0x94, 0xb}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x96, 0x32, 0x62, 0x29}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_payload_bytes[] = {0x57, 0x84, 0x9b, 0xcc}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS0; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 16616; + uint8_t client_id_bytes[] = {0x66, 0x34, 0x4, 0x4b, 0x4d, 0x43, 0xc7, 0xad, 0xa1, 0xfb, 0x97}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x81, 0x26, 0xef, 0xa8, 0xf7, 0x4d, 0x57, 0xc5, 0x4, 0x7f, 0xe7, 0xc, 0x39, 0x2e, 0x61, 0x54, 0x4b, 0x2c, 0x6f, 0x13, 0x32, 0x34, 0x49, 0x95, 0xab}; + lwmqtt_string_t username = {25, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\STXjT\248\ACK\158\156\227\216x\233}\DC4q\198\140ca\207\230", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "_\192D\194~\218adY0\244u\190og1\210Y\200", _willMsg = "\188\&4\154k=\225N", _willProps = []}), _cleanSession = True, -// _keepAlive = 16867, _connID = "h\ETX\237n0\202\ETX/\213\ESC\174\136'\218lQ\144\n\175\151\132", _properties = []} -TEST(Connect311QCTest, Encode6) { - uint8_t pkt[] = {0x10, 0x55, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x96, 0x41, 0xe3, 0x0, 0x15, 0x68, - 0x3, 0xed, 0x6e, 0x30, 0xca, 0x3, 0x2f, 0xd5, 0x1b, 0xae, 0x88, 0x27, 0xda, 0x6c, 0x51, - 0x90, 0xa, 0xaf, 0x97, 0x84, 0x0, 0x13, 0x5f, 0xc0, 0x44, 0xc2, 0x7e, 0xda, 0x61, 0x64, - 0x59, 0x30, 0xf4, 0x75, 0xbe, 0x6f, 0x67, 0x31, 0xd2, 0x59, 0xc8, 0x0, 0x7, 0xbc, 0x34, - 0x9a, 0x6b, 0x3d, 0xe1, 0x4e, 0x0, 0x14, 0x2, 0x6a, 0x54, 0xf8, 0x6, 0x9e, 0x9c, 0xe3, - 0xd8, 0x78, 0xe9, 0x7d, 0x14, 0x71, 0xc6, 0x8c, 0x63, 0x61, 0xcf, 0xe6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "?w\155e\220+\213:#.\196F\193\167\185\189\222`\151Q", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "\219\242^+:\f\EOT\173\175\&1\CAN\171\&8", _willMsg = -// "\172\220\161\161W~?%", _willProps = []}), _cleanSession = False, _keepAlive = 9252, _connID = -// "\175\167p\FS\238\ni\164\&3*\183\243\186\129\SO\153{\225\138\236\216\213${|P^\248\148\128", _properties = []} -TEST(Connect311QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0x70, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x24, 0x24, 0x0, 0x1e, 0xaf, 0xa7, 0x70, - 0x1c, 0xee, 0xa, 0x69, 0xa4, 0x33, 0x2a, 0xb7, 0xf3, 0xba, 0x81, 0xe, 0x99, 0x7b, 0xe1, 0x8a, 0xec, - 0xd8, 0xd5, 0x24, 0x7b, 0x7c, 0x50, 0x5e, 0xf8, 0x94, 0x80, 0x0, 0xd, 0xdb, 0xf2, 0x5e, 0x2b, 0x3a, - 0xc, 0x4, 0xad, 0xaf, 0x31, 0x18, 0xab, 0x38, 0x0, 0x8, 0xac, 0xdc, 0xa1, 0xa1, 0x57, 0x7e, 0x3f, - 0x25, 0x0, 0xf, 0x19, 0x9f, 0x19, 0x0, 0x14, 0x5c, 0x2c, 0x8c, 0x6d, 0x6d, 0x47, 0x6c, 0xa2, 0xbb, - 0xde, 0x0, 0x1a, 0x18, 0xf9, 0x92, 0x66, 0x48, 0x16, 0xa1, 0x1f, 0x9a, 0xad, 0xf3, 0xb1, 0xf0, 0xd4, - 0x6b, 0xcb, 0xdb, 0x3e, 0xc1, 0xa7, 0xb9, 0xbd, 0xde, 0x60, 0x97, 0x51}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\231\215\CAN\203\225\ETX1\228\EM$\170", _willMsg = "v\245\158;\210\154\234\241O\186u[,<\NAK'r>", _willProps = []}), _cleanSession = True, _keepAlive = 30216, _connID = "\ETBtE\131\"\233<\193T\DLE", _properties = []} +TEST(Connect311QCTest, Encode6) { +uint8_t pkt[] = {0x10, 0x37, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x76, 0x8, 0x0, 0xa, 0x17, 0x74, 0x45, 0x83, 0x22, 0xe9, 0x3c, 0xc1, 0x54, 0x10, 0x0, 0xb, 0xe7, 0xd7, 0x18, 0xcb, 0xe1, 0x3, 0x31, 0xe4, 0x19, 0x24, 0xaa, 0x0, 0x12, 0x76, 0xf5, 0x9e, 0x3b, 0xd2, 0x9a, 0xea, 0xf1, 0x4f, 0xba, 0x75, 0x5b, 0x2c, 0x3c, 0x15, 0x27, 0x72, 0x3e}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xdb, 0xf2, 0x5e, 0x2b, 0x3a, 0xc, 0x4, 0xad, 0xaf, 0x31, 0x18, 0xab, 0x38}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xac, 0xdc, 0xa1, 0xa1, 0x57, 0x7e, 0x3f, 0x25}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 9252; - uint8_t client_id_bytes[] = {0xaf, 0xa7, 0x70, 0x1c, 0xee, 0xa, 0x69, 0xa4, 0x33, 0x2a, - 0xb7, 0xf3, 0xba, 0x81, 0xe, 0x99, 0x7b, 0xe1, 0x8a, 0xec, - 0xd8, 0xd5, 0x24, 0x7b, 0x7c, 0x50, 0x5e, 0xf8, 0x94, 0x80}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x19, 0x9f, 0x19, 0x0, 0x14, 0x5c, 0x2c, 0x8c, 0x6d, 0x6d, 0x47, 0x6c, 0xa2, 0xbb, 0xde}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x18, 0xf9, 0x92, 0x66, 0x48, 0x16, 0xa1, 0x1f, 0x9a, 0xad, 0xf3, 0xb1, 0xf0, - 0xd4, 0x6b, 0xcb, 0xdb, 0x3e, 0xc1, 0xa7, 0xb9, 0xbd, 0xde, 0x60, 0x97, 0x51}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0xe7, 0xd7, 0x18, 0xcb, 0xe1, 0x3, 0x31, 0xe4, 0x19, 0x24, 0xaa}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x76, 0xf5, 0x9e, 0x3b, 0xd2, 0x9a, 0xea, 0xf1, 0x4f, 0xba, 0x75, 0x5b, 0x2c, 0x3c, 0x15, 0x27, 0x72, 0x3e}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 30216; + uint8_t client_id_bytes[] = {0x17, 0x74, 0x45, 0x83, 0x22, 0xe9, 0x3c, 0xc1, 0x54, 0x10}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; +opts.client_id = client_id; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\132Jc\237#\175s\149\208\140\v\175\198\197@bE\255\177&4\223%%\194\229\ETB", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "_B\130\238\164\ACK\246/\243\243\182\&9h\219Dp\161E\201n(\130u", _willMsg = -// "L\ETX\226\236\158\CAN3\190\221\140\156\129Mj\211\ACKv+\USU\197e\219\EM\135\221\145", _willProps = []}), -// _cleanSession = False, _keepAlive = 23111, _connID = -// "\128'\168\a\165\214u\"VvPa\154y\236\ETB\165ng\208\175\233\198\234\235\a", _properties = []} -TEST(Connect311QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x79, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb4, 0x5a, 0x47, 0x0, 0x1a, 0x80, 0x27, - 0xa8, 0x7, 0xa5, 0xd6, 0x75, 0x22, 0x56, 0x76, 0x50, 0x61, 0x9a, 0x79, 0xec, 0x17, 0xa5, 0x6e, - 0x67, 0xd0, 0xaf, 0xe9, 0xc6, 0xea, 0xeb, 0x7, 0x0, 0x17, 0x5f, 0x42, 0x82, 0xee, 0xa4, 0x6, - 0xf6, 0x2f, 0xf3, 0xf3, 0xb6, 0x39, 0x68, 0xdb, 0x44, 0x70, 0xa1, 0x45, 0xc9, 0x6e, 0x28, 0x82, - 0x75, 0x0, 0x1b, 0x4c, 0x3, 0xe2, 0xec, 0x9e, 0x18, 0x33, 0xbe, 0xdd, 0x8c, 0x9c, 0x81, 0x4d, - 0x6a, 0xd3, 0x6, 0x76, 0x2b, 0x1f, 0x55, 0xc5, 0x65, 0xdb, 0x19, 0x87, 0xdd, 0x91, 0x0, 0x1b, - 0x84, 0x4a, 0x63, 0xed, 0x23, 0xaf, 0x73, 0x95, 0xd0, 0x8c, 0xb, 0xaf, 0xc6, 0xc5, 0x40, 0x62, - 0x45, 0xff, 0xb1, 0x26, 0x34, 0xdf, 0x25, 0x25, 0xc2, 0xe5, 0x17}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - - lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; +// ConnectRequest {_username = Just "\184\RS2\175$\t.Y\176C6\139.\188\209\208\199", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "k_hun\216\209\212\219%\193\NAK[\175\250\232\STX\214\196)\SOH\135\SO\t", _willMsg = "\216\193J\242J\215\b\166\FS\181,u\246W&\128\245\STXbo\142d\186\234!\250\EM\219\136", _willProps = []}), _cleanSession = True, _keepAlive = 12402, _connID = "\157\DC4\228=k\DLE5N\171\v+\185\227", _properties = []} +TEST(Connect311QCTest, Encode7) { +uint8_t pkt[] = {0x10, 0x65, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0x30, 0x72, 0x0, 0xd, 0x9d, 0x14, 0xe4, 0x3d, 0x6b, 0x10, 0x35, 0x4e, 0xab, 0xb, 0x2b, 0xb9, 0xe3, 0x0, 0x18, 0x6b, 0x5f, 0x68, 0x75, 0x6e, 0xd8, 0xd1, 0xd4, 0xdb, 0x25, 0xc1, 0x15, 0x5b, 0xaf, 0xfa, 0xe8, 0x2, 0xd6, 0xc4, 0x29, 0x1, 0x87, 0xe, 0x9, 0x0, 0x1d, 0xd8, 0xc1, 0x4a, 0xf2, 0x4a, 0xd7, 0x8, 0xa6, 0x1c, 0xb5, 0x2c, 0x75, 0xf6, 0x57, 0x26, 0x80, 0xf5, 0x2, 0x62, 0x6f, 0x8e, 0x64, 0xba, 0xea, 0x21, 0xfa, 0x19, 0xdb, 0x88, 0x0, 0x11, 0xb8, 0x1e, 0x32, 0xaf, 0x24, 0x9, 0x2e, 0x59, 0xb0, 0x43, 0x36, 0x8b, 0x2e, 0xbc, 0xd1, 0xd0, 0xc7}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; - lwmqtt_property_t willpropslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5f, 0x42, 0x82, 0xee, 0xa4, 0x6, 0xf6, 0x2f, 0xf3, 0xf3, 0xb6, 0x39, - 0x68, 0xdb, 0x44, 0x70, 0xa1, 0x45, 0xc9, 0x6e, 0x28, 0x82, 0x75}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4c, 0x3, 0xe2, 0xec, 0x9e, 0x18, 0x33, 0xbe, 0xdd, 0x8c, 0x9c, 0x81, 0x4d, 0x6a, - 0xd3, 0x6, 0x76, 0x2b, 0x1f, 0x55, 0xc5, 0x65, 0xdb, 0x19, 0x87, 0xdd, 0x91}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 23111; - uint8_t client_id_bytes[] = {0x80, 0x27, 0xa8, 0x7, 0xa5, 0xd6, 0x75, 0x22, 0x56, 0x76, 0x50, 0x61, 0x9a, - 0x79, 0xec, 0x17, 0xa5, 0x6e, 0x67, 0xd0, 0xaf, 0xe9, 0xc6, 0xea, 0xeb, 0x7}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x84, 0x4a, 0x63, 0xed, 0x23, 0xaf, 0x73, 0x95, 0xd0, 0x8c, 0xb, 0xaf, 0xc6, 0xc5, - 0x40, 0x62, 0x45, 0xff, 0xb1, 0x26, 0x34, 0xdf, 0x25, 0x25, 0xc2, 0xe5, 0x17}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0x6b, 0x5f, 0x68, 0x75, 0x6e, 0xd8, 0xd1, 0xd4, 0xdb, 0x25, 0xc1, 0x15, 0x5b, 0xaf, 0xfa, 0xe8, 0x2, 0xd6, 0xc4, 0x29, 0x1, 0x87, 0xe, 0x9}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd8, 0xc1, 0x4a, 0xf2, 0x4a, 0xd7, 0x8, 0xa6, 0x1c, 0xb5, 0x2c, 0x75, 0xf6, 0x57, 0x26, 0x80, 0xf5, 0x2, 0x62, 0x6f, 0x8e, 0x64, 0xba, 0xea, 0x21, 0xfa, 0x19, 0xdb, 0x88}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 12402; + uint8_t client_id_bytes[] = {0x9d, 0x14, 0xe4, 0x3d, 0x6b, 0x10, 0x35, 0x4e, 0xab, 0xb, 0x2b, 0xb9, 0xe3}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xb8, 0x1e, 0x32, 0xaf, 0x24, 0x9, 0x2e, 0x59, 0xb0, 0x43, 0x36, 0x8b, 0x2e, 0xbc, 0xd1, 0xd0, 0xc7}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\131)o", _password = Just "Y^ \171\220\234\182Th\NAK", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\SOHw\DC4\149\&5\197\t\RS\188\166\DLE\179", _willMsg = -// "L\173#e?~\241<", _willProps = []}), _cleanSession = False, _keepAlive = 15628, _connID = "\238", _properties = []} -TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x36, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x3d, 0xc, 0x0, 0x1, - 0xee, 0x0, 0xc, 0x1, 0x77, 0x14, 0x95, 0x35, 0xc5, 0x9, 0x1e, 0xbc, 0xa6, 0x10, - 0xb3, 0x0, 0x8, 0x4c, 0xad, 0x23, 0x65, 0x3f, 0x7e, 0xf1, 0x3c, 0x0, 0x3, 0x83, - 0x29, 0x6f, 0x0, 0xa, 0x59, 0x5e, 0x20, 0xab, 0xdc, 0xea, 0xb6, 0x54, 0x68, 0x15}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Just "W\DC2v\185\154.x\154\183R\236\DC4\SI\179\251\231", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\230,\132\194wK\251\ENQ\NUL\154\229\223\206\215", _willMsg = "\149\250\&2EL\189\206", _willProps = []}), _cleanSession = True, _keepAlive = 4527, _connID = "\140Kc\DC2\DC2\249`", _properties = []} +TEST(Connect311QCTest, Encode8) { +uint8_t pkt[] = {0x10, 0x2c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x11, 0xaf, 0x0, 0x7, 0x8c, 0x4b, 0x63, 0x12, 0x12, 0xf9, 0x60, 0x0, 0xe, 0xe6, 0x2c, 0x84, 0xc2, 0x77, 0x4b, 0xfb, 0x5, 0x0, 0x9a, 0xe5, 0xdf, 0xce, 0xd7, 0x0, 0x7, 0x95, 0xfa, 0x32, 0x45, 0x4c, 0xbd, 0xce}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1, 0x77, 0x14, 0x95, 0x35, 0xc5, 0x9, 0x1e, 0xbc, 0xa6, 0x10, 0xb3}; - lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4c, 0xad, 0x23, 0x65, 0x3f, 0x7e, 0xf1, 0x3c}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 15628; - uint8_t client_id_bytes[] = {0xee}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x83, 0x29, 0x6f}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x59, 0x5e, 0x20, 0xab, 0xdc, 0xea, 0xb6, 0x54, 0x68, 0x15}; - lwmqtt_string_t password = {10, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0xe6, 0x2c, 0x84, 0xc2, 0x77, 0x4b, 0xfb, 0x5, 0x0, 0x9a, 0xe5, 0xdf, 0xce, 0xd7}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x95, 0xfa, 0x32, 0x45, 0x4c, 0xbd, 0xce}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 4527; + uint8_t client_id_bytes[] = {0x8c, 0x4b, 0x63, 0x12, 0x12, 0xf9, 0x60}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x57, 0x12, 0x76, 0xb9, 0x9a, 0x2e, 0x78, 0x9a, 0xb7, 0x52, 0xec, 0x14, 0xf, 0xb3, 0xfb, 0xe7}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\176mX\224\177{+\ENQ\221\228\184\181\192 \NUL\201\128\209", _password = Just -// "\215Dco.`\RSl\219\136A\134Z}X\247\&5HG\ETX", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, -// _willTopic = "\242 xK\204\160x\221\169\240", _willMsg = "\220\ACKG", _willProps = []}), _cleanSession = True, -// _keepAlive = 19143, _connID = "\176/i\144P\218\&5\t\229;\221\246\DC2\"", _properties = []} -TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x55, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x4a, 0xc7, 0x0, 0xe, 0xb0, - 0x2f, 0x69, 0x90, 0x50, 0xda, 0x35, 0x9, 0xe5, 0x3b, 0xdd, 0xf6, 0x12, 0x22, 0x0, 0xa, - 0xf2, 0x20, 0x78, 0x4b, 0xcc, 0xa0, 0x78, 0xdd, 0xa9, 0xf0, 0x0, 0x3, 0xdc, 0x6, 0x47, - 0x0, 0x12, 0xb0, 0x6d, 0x58, 0xe0, 0xb1, 0x7b, 0x2b, 0x5, 0xdd, 0xe4, 0xb8, 0xb5, 0xc0, - 0x20, 0x0, 0xc9, 0x80, 0xd1, 0x0, 0x14, 0xd7, 0x44, 0x63, 0x6f, 0x2e, 0x60, 0x1e, 0x6c, - 0xdb, 0x88, 0x41, 0x86, 0x5a, 0x7d, 0x58, 0xf7, 0x35, 0x48, 0x47, 0x3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Just "A\ESC'\139\188\167\DEL0\247\183\225\230dn1\207\&4a+\229#\149s\233\178Lz\188B", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "1\210\DC3\DC47O", _willMsg = "M\176\215\\\188\144\&2\213\199\175\GS", _willProps = []}), _cleanSession = False, _keepAlive = 26060, _connID = "'M\238\158*c\NUL\197&]T\231\237\226\255e=\SUB]&\188\246", _properties = []} +TEST(Connect311QCTest, Encode9) { +uint8_t pkt[] = {0x10, 0x37, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x65, 0xcc, 0x0, 0x16, 0x27, 0x4d, 0xee, 0x9e, 0x2a, 0x63, 0x0, 0xc5, 0x26, 0x5d, 0x54, 0xe7, 0xed, 0xe2, 0xff, 0x65, 0x3d, 0x1a, 0x5d, 0x26, 0xbc, 0xf6, 0x0, 0x6, 0x31, 0xd2, 0x13, 0x14, 0x37, 0x4f, 0x0, 0xb, 0x4d, 0xb0, 0xd7, 0x5c, 0xbc, 0x90, 0x32, 0xd5, 0xc7, 0xaf, 0x1d}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf2, 0x20, 0x78, 0x4b, 0xcc, 0xa0, 0x78, 0xdd, 0xa9, 0xf0}; - lwmqtt_string_t will_topic = {10, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xdc, 0x6, 0x47}; - lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 19143; - uint8_t client_id_bytes[] = {0xb0, 0x2f, 0x69, 0x90, 0x50, 0xda, 0x35, 0x9, 0xe5, 0x3b, 0xdd, 0xf6, 0x12, 0x22}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xb0, 0x6d, 0x58, 0xe0, 0xb1, 0x7b, 0x2b, 0x5, 0xdd, - 0xe4, 0xb8, 0xb5, 0xc0, 0x20, 0x0, 0xc9, 0x80, 0xd1}; - lwmqtt_string_t username = {18, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd7, 0x44, 0x63, 0x6f, 0x2e, 0x60, 0x1e, 0x6c, 0xdb, 0x88, - 0x41, 0x86, 0x5a, 0x7d, 0x58, 0xf7, 0x35, 0x48, 0x47, 0x3}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t will_topic_bytes[] = {0x31, 0xd2, 0x13, 0x14, 0x37, 0x4f}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4d, 0xb0, 0xd7, 0x5c, 0xbc, 0x90, 0x32, 0xd5, 0xc7, 0xaf, 0x1d}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 26060; + uint8_t client_id_bytes[] = {0x27, 0x4d, 0xee, 0x9e, 0x2a, 0x63, 0x0, 0xc5, 0x26, 0x5d, 0x54, 0xe7, 0xed, 0xe2, 0xff, 0x65, 0x3d, 0x1a, 0x5d, 0x26, 0xbc, 0xf6}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x41, 0x1b, 0x27, 0x8b, 0xbc, 0xa7, 0x7f, 0x30, 0xf7, 0xb7, 0xe1, 0xe6, 0x64, 0x6e, 0x31, 0xcf, 0x34, 0x61, 0x2b, 0xe5, 0x23, 0x95, 0x73, 0xe9, 0xb2, 0x4c, 0x7a, 0xbc, 0x42}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// ConnectRequest {_username = Just "\203\215'q\192;\253\158\131\"\185\255\168\f\227", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\DC3]\143\242\EOT8\146", _willMsg = "\230\207C'/^Ln\SOH\ACK\239\208\&6\227\162B~\222\142", _willProps = []}), _cleanSession = False, _keepAlive = 18009, _connID = "\223\157;e\ACKs*\NUL\134N\151K\212g\170", _properties = []} +TEST(Connect311QCTest, Encode10) { +uint8_t pkt[] = {0x10, 0x4a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0x46, 0x59, 0x0, 0xf, 0xdf, 0x9d, 0x3b, 0x65, 0x6, 0x73, 0x2a, 0x0, 0x86, 0x4e, 0x97, 0x4b, 0xd4, 0x67, 0xaa, 0x0, 0x7, 0x13, 0x5d, 0x8f, 0xf2, 0x4, 0x38, 0x92, 0x0, 0x13, 0xe6, 0xcf, 0x43, 0x27, 0x2f, 0x5e, 0x4c, 0x6e, 0x1, 0x6, 0xef, 0xd0, 0x36, 0xe3, 0xa2, 0x42, 0x7e, 0xde, 0x8e, 0x0, 0xf, 0xcb, 0xd7, 0x27, 0x71, 0xc0, 0x3b, 0xfd, 0x9e, 0x83, 0x22, 0xb9, 0xff, 0xa8, 0xc, 0xe3}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; -// ConnectRequest {_username = Just "9\246\141M+", _password = Just -// "BzT\194\145\200\DC1~\DC2\170\&9\EOT\DLE\215\STX\232\174n", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 30004, _connID = "\ENQ\221\153\230\216\164\143FVb\206\243AV\250\128nq\CAN\233\230\147\239@u\239*", _properties = []} -TEST(Connect311QCTest, Encode11) { - uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x75, 0x34, 0x0, 0x1b, - 0x5, 0xdd, 0x99, 0xe6, 0xd8, 0xa4, 0x8f, 0x46, 0x56, 0x62, 0xce, 0xf3, 0x41, 0x56, - 0xfa, 0x80, 0x6e, 0x71, 0x18, 0xe9, 0xe6, 0x93, 0xef, 0x40, 0x75, 0xef, 0x2a, 0x0, - 0x5, 0x39, 0xf6, 0x8d, 0x4d, 0x2b, 0x0, 0x12, 0x42, 0x7a, 0x54, 0xc2, 0x91, 0xc8, - 0x11, 0x7e, 0x12, 0xaa, 0x39, 0x4, 0x10, 0xd7, 0x2, 0xe8, 0xae, 0x6e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; - lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x13, 0x5d, 0x8f, 0xf2, 0x4, 0x38, 0x92}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe6, 0xcf, 0x43, 0x27, 0x2f, 0x5e, 0x4c, 0x6e, 0x1, 0x6, 0xef, 0xd0, 0x36, 0xe3, 0xa2, 0x42, 0x7e, 0xde, 0x8e}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 18009; + uint8_t client_id_bytes[] = {0xdf, 0x9d, 0x3b, 0x65, 0x6, 0x73, 0x2a, 0x0, 0x86, 0x4e, 0x97, 0x4b, 0xd4, 0x67, 0xaa}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xcb, 0xd7, 0x27, 0x71, 0xc0, 0x3b, 0xfd, 0x9e, 0x83, 0x22, 0xb9, 0xff, 0xa8, 0xc, 0xe3}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 30004; - uint8_t client_id_bytes[] = {0x5, 0xdd, 0x99, 0xe6, 0xd8, 0xa4, 0x8f, 0x46, 0x56, 0x62, 0xce, 0xf3, 0x41, 0x56, - 0xfa, 0x80, 0x6e, 0x71, 0x18, 0xe9, 0xe6, 0x93, 0xef, 0x40, 0x75, 0xef, 0x2a}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x39, 0xf6, 0x8d, 0x4d, 0x2b}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x42, 0x7a, 0x54, 0xc2, 0x91, 0xc8, 0x11, 0x7e, 0x12, - 0xaa, 0x39, 0x4, 0x10, 0xd7, 0x2, 0xe8, 0xae, 0x6e}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "Q\GS\242\209", _lastWill = Nothing, _cleanSession = True, -// _keepAlive = 6889, _connID = "hO\233g\n{qNO\160 ", _properties = []} -TEST(Connect311QCTest, Encode12) { - uint8_t pkt[] = {0x10, 0x17, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x1a, 0xe9, 0x0, - 0xb, 0x68, 0x4f, 0xe9, 0x67, 0xa, 0x7b, 0x71, 0x4e, 0x4f, 0xa0, 0x20}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Just "\SOH\169\149X", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\185\164\201\218\t\RS\138w4\237\150O\188z}W", _willMsg = "<\195\167\FSW", _willProps = []}), _cleanSession = True, _keepAlive = 29930, _connID = "\b7o\203\f\197", _properties = []} +TEST(Connect311QCTest, Encode11) { +uint8_t pkt[] = {0x10, 0x2b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2e, 0x74, 0xea, 0x0, 0x6, 0x8, 0x37, 0x6f, 0xcb, 0xc, 0xc5, 0x0, 0x10, 0xb9, 0xa4, 0xc9, 0xda, 0x9, 0x1e, 0x8a, 0x77, 0x34, 0xed, 0x96, 0x4f, 0xbc, 0x7a, 0x7d, 0x57, 0x0, 0x5, 0x3c, 0xc3, 0xa7, 0x1c, 0x57}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 6889; - uint8_t client_id_bytes[] = {0x68, 0x4f, 0xe9, 0x67, 0xa, 0x7b, 0x71, 0x4e, 0x4f, 0xa0, 0x20}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x51, 0x1d, 0xf2, 0xd1}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb9, 0xa4, 0xc9, 0xda, 0x9, 0x1e, 0x8a, 0x77, 0x34, 0xed, 0x96, 0x4f, 0xbc, 0x7a, 0x7d, 0x57}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3c, 0xc3, 0xa7, 0x1c, 0x57}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 29930; + uint8_t client_id_bytes[] = {0x8, 0x37, 0x6f, 0xcb, 0xc, 0xc5}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x1, 0xa9, 0x95, 0x58}; lwmqtt_string_t password = {4, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "", _willMsg = "\235\177\182N)\GS\253\200\252E\173b\141gO\165\169\ETX\va\209*", _willProps = []}), -// _cleanSession = True, _keepAlive = 8360, _connID = -// "\178Ip\r*\206Y\141(\255\184\&4\224\197=\217\172\EM\EOT\\'\RS\229u\172S\202", _properties = []} -TEST(Connect311QCTest, Encode13) { - uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x20, 0xa8, 0x0, 0x1b, 0xb2, 0x49, 0x70, - 0xd, 0x2a, 0xce, 0x59, 0x8d, 0x28, 0xff, 0xb8, 0x34, 0xe0, 0xc5, 0x3d, 0xd9, 0xac, 0x19, 0x4, 0x5c, - 0x27, 0x1e, 0xe5, 0x75, 0xac, 0x53, 0xca, 0x0, 0x0, 0x0, 0x16, 0xeb, 0xb1, 0xb6, 0x4e, 0x29, 0x1d, - 0xfd, 0xc8, 0xfc, 0x45, 0xad, 0x62, 0x8d, 0x67, 0x4f, 0xa5, 0xa9, 0x3, 0xb, 0x61, 0xd1, 0x2a}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "xj\DC2d\147j\242\141\DC1\253\179o\188", _password = Just "\144\238/&m", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\191\197a\194u\133\135\244\211\170\162\129\161\&6\225\&2", _willMsg = "\218\f", _willProps = []}), _cleanSession = False, _keepAlive = 15412, _connID = "\176\143\160_\\\166\148\213\226\224\CAN>\238\v\168\163", _properties = []} +TEST(Connect311QCTest, Encode12) { +uint8_t pkt[] = {0x10, 0x48, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x3c, 0x34, 0x0, 0x10, 0xb0, 0x8f, 0xa0, 0x5f, 0x5c, 0xa6, 0x94, 0xd5, 0xe2, 0xe0, 0x18, 0x3e, 0xee, 0xb, 0xa8, 0xa3, 0x0, 0x10, 0xbf, 0xc5, 0x61, 0xc2, 0x75, 0x85, 0x87, 0xf4, 0xd3, 0xaa, 0xa2, 0x81, 0xa1, 0x36, 0xe1, 0x32, 0x0, 0x2, 0xda, 0xc, 0x0, 0xd, 0x78, 0x6a, 0x12, 0x64, 0x93, 0x6a, 0xf2, 0x8d, 0x11, 0xfd, 0xb3, 0x6f, 0xbc, 0x0, 0x5, 0x90, 0xee, 0x2f, 0x26, 0x6d}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xbf, 0xc5, 0x61, 0xc2, 0x75, 0x85, 0x87, 0xf4, 0xd3, 0xaa, 0xa2, 0x81, 0xa1, 0x36, 0xe1, 0x32}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xda, 0xc}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS0; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 15412; + uint8_t client_id_bytes[] = {0xb0, 0x8f, 0xa0, 0x5f, 0x5c, 0xa6, 0x94, 0xd5, 0xe2, 0xe0, 0x18, 0x3e, 0xee, 0xb, 0xa8, 0xa3}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x78, 0x6a, 0x12, 0x64, 0x93, 0x6a, 0xf2, 0x8d, 0x11, 0xfd, 0xb3, 0x6f, 0xbc}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x90, 0xee, 0x2f, 0x26, 0x6d}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// ConnectRequest {_username = Nothing, _password = Just "\128p\220>r\201\195\&0\200", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\DC3l\244\169\203\EOT\129\173\&4\NUL\252\RS\184\133V\249z\191:P~GH\EM\193\SOH29\254e", _willMsg = "mvB", _willProps = []}), _cleanSession = True, _keepAlive = 30313, _connID = "\215\250VLG@\204B\"\166$HJ", _properties = []} +TEST(Connect311QCTest, Encode13) { +uint8_t pkt[] = {0x10, 0x3e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x76, 0x69, 0x0, 0xd, 0xd7, 0xfa, 0x56, 0x4c, 0x47, 0x40, 0xcc, 0x42, 0x22, 0xa6, 0x24, 0x48, 0x4a, 0x0, 0x1e, 0x13, 0x6c, 0xf4, 0xa9, 0xcb, 0x4, 0x81, 0xad, 0x34, 0x0, 0xfc, 0x1e, 0xb8, 0x85, 0x56, 0xf9, 0x7a, 0xbf, 0x3a, 0x50, 0x7e, 0x47, 0x48, 0x19, 0xc1, 0x1, 0x32, 0x39, 0xfe, 0x65, 0x0, 0x3, 0x6d, 0x76, 0x42}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; - lwmqtt_property_t willpropslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xeb, 0xb1, 0xb6, 0x4e, 0x29, 0x1d, 0xfd, 0xc8, 0xfc, 0x45, 0xad, - 0x62, 0x8d, 0x67, 0x4f, 0xa5, 0xa9, 0x3, 0xb, 0x61, 0xd1, 0x2a}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 8360; - uint8_t client_id_bytes[] = {0xb2, 0x49, 0x70, 0xd, 0x2a, 0xce, 0x59, 0x8d, 0x28, 0xff, 0xb8, 0x34, 0xe0, 0xc5, - 0x3d, 0xd9, 0xac, 0x19, 0x4, 0x5c, 0x27, 0x1e, 0xe5, 0x75, 0xac, 0x53, 0xca}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0x13, 0x6c, 0xf4, 0xa9, 0xcb, 0x4, 0x81, 0xad, 0x34, 0x0, 0xfc, 0x1e, 0xb8, 0x85, 0x56, 0xf9, 0x7a, 0xbf, 0x3a, 0x50, 0x7e, 0x47, 0x48, 0x19, 0xc1, 0x1, 0x32, 0x39, 0xfe, 0x65}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6d, 0x76, 0x42}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 30313; + uint8_t client_id_bytes[] = {0xd7, 0xfa, 0x56, 0x4c, 0x47, 0x40, 0xcc, 0x42, 0x22, 0xa6, 0x24, 0x48, 0x4a}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x80, 0x70, 0xdc, 0x3e, 0x72, 0xc9, 0xc3, 0x30, 0xc8}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "H\176\DC3\130\176@\132\210", _password = Just -// "\198\248\US\ETB\143\174JCT\DEL\221a\211\221;\179\128\182\154\207\189o", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS2, _willTopic = "\147.\146\246\203'\150]B\EMY\ETB\GS\tM\166q\196ug\DLE\t\191B", _willMsg = -// "\228\164\240r\184\245\201\DC2#9H\152\ETB\188\241\217\202\186\203\197D\220\162\&4\213", _willProps = []}), -// _cleanSession = True, _keepAlive = 28532, _connID = "y\245\130FF#\\[\227\&0", _properties = []} -TEST(Connect311QCTest, Encode14) { - uint8_t pkt[] = {0x10, 0x6d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x6f, 0x74, 0x0, 0xa, 0x79, 0xf5, - 0x82, 0x46, 0x46, 0x23, 0x5c, 0x5b, 0xe3, 0x30, 0x0, 0x18, 0x93, 0x2e, 0x92, 0xf6, 0xcb, 0x27, - 0x96, 0x5d, 0x42, 0x19, 0x59, 0x17, 0x1d, 0x9, 0x4d, 0xa6, 0x71, 0xc4, 0x75, 0x67, 0x10, 0x9, - 0xbf, 0x42, 0x0, 0x19, 0xe4, 0xa4, 0xf0, 0x72, 0xb8, 0xf5, 0xc9, 0x12, 0x23, 0x39, 0x48, 0x98, - 0x17, 0xbc, 0xf1, 0xd9, 0xca, 0xba, 0xcb, 0xc5, 0x44, 0xdc, 0xa2, 0x34, 0xd5, 0x0, 0x8, 0x48, - 0xb0, 0x13, 0x82, 0xb0, 0x40, 0x84, 0xd2, 0x0, 0x16, 0xc6, 0xf8, 0x1f, 0x17, 0x8f, 0xae, 0x4a, - 0x43, 0x54, 0x7f, 0xdd, 0x61, 0xd3, 0xdd, 0x3b, 0xb3, 0x80, 0xb6, 0x9a, 0xcf, 0xbd, 0x6f}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "\b\247\147N", _password = Just "\158\238\145\147\144\128C\149\133Syv\234\ESC?", _lastWill = Nothing, _cleanSession = True, _keepAlive = 13836, _connID = "", _properties = []} +TEST(Connect311QCTest, Encode14) { +uint8_t pkt[] = {0x10, 0x23, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x36, 0xc, 0x0, 0x0, 0x0, 0x4, 0x8, 0xf7, 0x93, 0x4e, 0x0, 0xf, 0x9e, 0xee, 0x91, 0x93, 0x90, 0x80, 0x43, 0x95, 0x85, 0x53, 0x79, 0x76, 0xea, 0x1b, 0x3f}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 13836; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x8, 0xf7, 0x93, 0x4e}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x9e, 0xee, 0x91, 0x93, 0x90, 0x80, 0x43, 0x95, 0x85, 0x53, 0x79, 0x76, 0xea, 0x1b, 0x3f}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x93, 0x2e, 0x92, 0xf6, 0xcb, 0x27, 0x96, 0x5d, 0x42, 0x19, 0x59, 0x17, - 0x1d, 0x9, 0x4d, 0xa6, 0x71, 0xc4, 0x75, 0x67, 0x10, 0x9, 0xbf, 0x42}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe4, 0xa4, 0xf0, 0x72, 0xb8, 0xf5, 0xc9, 0x12, 0x23, 0x39, 0x48, 0x98, 0x17, - 0xbc, 0xf1, 0xd9, 0xca, 0xba, 0xcb, 0xc5, 0x44, 0xdc, 0xa2, 0x34, 0xd5}; - lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 28532; - uint8_t client_id_bytes[] = {0x79, 0xf5, 0x82, 0x46, 0x46, 0x23, 0x5c, 0x5b, 0xe3, 0x30}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x48, 0xb0, 0x13, 0x82, 0xb0, 0x40, 0x84, 0xd2}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xc6, 0xf8, 0x1f, 0x17, 0x8f, 0xae, 0x4a, 0x43, 0x54, 0x7f, 0xdd, - 0x61, 0xd3, 0xdd, 0x3b, 0xb3, 0x80, 0xb6, 0x9a, 0xcf, 0xbd, 0x6f}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\232\220\210", _password = Just -// "Q\222\CAN\156\222j\201*\143\147\STX\155\152P\n\166#\139", _lastWill = Just (LastWill {_willRetain = False, _willQoS -// = QoS2, _willTopic = "\NAK\166\247\190f\227\STX", _willMsg = -// "Pu4\232\181\200\&73\211\251l\247WIl\248g\236i\218\139\136\182\208\241!\195\244\162", _willProps = []}), -// _cleanSession = False, _keepAlive = 16792, _connID = "\144\154@\235\163ha\251\SO\244\151\244\235", _properties = []} -TEST(Connect311QCTest, Encode15) { - uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x41, 0x98, 0x0, 0xd, 0x90, 0x9a, - 0x40, 0xeb, 0xa3, 0x68, 0x61, 0xfb, 0xe, 0xf4, 0x97, 0xf4, 0xeb, 0x0, 0x7, 0x15, 0xa6, 0xf7, - 0xbe, 0x66, 0xe3, 0x2, 0x0, 0x1d, 0x50, 0x75, 0x34, 0xe8, 0xb5, 0xc8, 0x37, 0x33, 0xd3, 0xfb, - 0x6c, 0xf7, 0x57, 0x49, 0x6c, 0xf8, 0x67, 0xec, 0x69, 0xda, 0x8b, 0x88, 0xb6, 0xd0, 0xf1, 0x21, - 0xc3, 0xf4, 0xa2, 0x0, 0x3, 0xe8, 0xdc, 0xd2, 0x0, 0x12, 0x51, 0xde, 0x18, 0x9c, 0xde, 0x6a, - 0xc9, 0x2a, 0x8f, 0x93, 0x2, 0x9b, 0x98, 0x50, 0xa, 0xa6, 0x23, 0x8b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "A;\168\224\240\237\DC1\US`k\228D\201 \211vE.\203\STX&", _password = Just "\229\SYN\236\252jrj\246\DLE=x", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\241\&5\180\235\133=\135\224", _willMsg = "+r\156\250\&3\164\138\npj\245=\238\182N^\ra\151\161", _willProps = []}), _cleanSession = False, _keepAlive = 4733, _connID = "\v\ETX,\204b\141\136r!r\DC3a-\138\249M7\afg\EOT\139\228W", _properties = []} +TEST(Connect311QCTest, Encode15) { +uint8_t pkt[] = {0x10, 0x68, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x12, 0x7d, 0x0, 0x18, 0xb, 0x3, 0x2c, 0xcc, 0x62, 0x8d, 0x88, 0x72, 0x21, 0x72, 0x13, 0x61, 0x2d, 0x8a, 0xf9, 0x4d, 0x37, 0x7, 0x66, 0x67, 0x4, 0x8b, 0xe4, 0x57, 0x0, 0x8, 0xf1, 0x35, 0xb4, 0xeb, 0x85, 0x3d, 0x87, 0xe0, 0x0, 0x14, 0x2b, 0x72, 0x9c, 0xfa, 0x33, 0xa4, 0x8a, 0xa, 0x70, 0x6a, 0xf5, 0x3d, 0xee, 0xb6, 0x4e, 0x5e, 0xd, 0x61, 0x97, 0xa1, 0x0, 0x15, 0x41, 0x3b, 0xa8, 0xe0, 0xf0, 0xed, 0x11, 0x1f, 0x60, 0x6b, 0xe4, 0x44, 0xc9, 0x20, 0xd3, 0x76, 0x45, 0x2e, 0xcb, 0x2, 0x26, 0x0, 0xb, 0xe5, 0x16, 0xec, 0xfc, 0x6a, 0x72, 0x6a, 0xf6, 0x10, 0x3d, 0x78}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x15, 0xa6, 0xf7, 0xbe, 0x66, 0xe3, 0x2}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x50, 0x75, 0x34, 0xe8, 0xb5, 0xc8, 0x37, 0x33, 0xd3, 0xfb, - 0x6c, 0xf7, 0x57, 0x49, 0x6c, 0xf8, 0x67, 0xec, 0x69, 0xda, - 0x8b, 0x88, 0xb6, 0xd0, 0xf1, 0x21, 0xc3, 0xf4, 0xa2}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 16792; - uint8_t client_id_bytes[] = {0x90, 0x9a, 0x40, 0xeb, 0xa3, 0x68, 0x61, 0xfb, 0xe, 0xf4, 0x97, 0xf4, 0xeb}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xe8, 0xdc, 0xd2}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x51, 0xde, 0x18, 0x9c, 0xde, 0x6a, 0xc9, 0x2a, 0x8f, - 0x93, 0x2, 0x9b, 0x98, 0x50, 0xa, 0xa6, 0x23, 0x8b}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0xf1, 0x35, 0xb4, 0xeb, 0x85, 0x3d, 0x87, 0xe0}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2b, 0x72, 0x9c, 0xfa, 0x33, 0xa4, 0x8a, 0xa, 0x70, 0x6a, 0xf5, 0x3d, 0xee, 0xb6, 0x4e, 0x5e, 0xd, 0x61, 0x97, 0xa1}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 4733; + uint8_t client_id_bytes[] = {0xb, 0x3, 0x2c, 0xcc, 0x62, 0x8d, 0x88, 0x72, 0x21, 0x72, 0x13, 0x61, 0x2d, 0x8a, 0xf9, 0x4d, 0x37, 0x7, 0x66, 0x67, 0x4, 0x8b, 0xe4, 0x57}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x41, 0x3b, 0xa8, 0xe0, 0xf0, 0xed, 0x11, 0x1f, 0x60, 0x6b, 0xe4, 0x44, 0xc9, 0x20, 0xd3, 0x76, 0x45, 0x2e, 0xcb, 0x2, 0x26}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0xe5, 0x16, 0xec, 0xfc, 0x6a, 0x72, 0x6a, 0xf6, 0x10, 0x3d, 0x78}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\208\&08\153\253\129\180\139MgC\ACKe\252k\131\238w\f\234\212", _password = Just -// "\174\131\134S\237\RS", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "oa\v,+\129{\223N\216\&2}\SI\161-\165a\146\&7\248\166\224\189\SOH\ESC\182", _willMsg = "m]", _willProps = []}), -// _cleanSession = False, _keepAlive = 3974, _connID = -// "\203\150\211\212\222);\208\149\129\DC4~\242y\186\143\254U\154\SYNx\245\248\f\166m!", _properties = []} -TEST(Connect311QCTest, Encode16) { - uint8_t pkt[] = {0x10, 0x66, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0xf, 0x86, 0x0, 0x1b, 0xcb, - 0x96, 0xd3, 0xd4, 0xde, 0x29, 0x3b, 0xd0, 0x95, 0x81, 0x14, 0x7e, 0xf2, 0x79, 0xba, 0x8f, - 0xfe, 0x55, 0x9a, 0x16, 0x78, 0xf5, 0xf8, 0xc, 0xa6, 0x6d, 0x21, 0x0, 0x1a, 0x6f, 0x61, - 0xb, 0x2c, 0x2b, 0x81, 0x7b, 0xdf, 0x4e, 0xd8, 0x32, 0x7d, 0xf, 0xa1, 0x2d, 0xa5, 0x61, - 0x92, 0x37, 0xf8, 0xa6, 0xe0, 0xbd, 0x1, 0x1b, 0xb6, 0x0, 0x2, 0x6d, 0x5d, 0x0, 0x15, - 0xd0, 0x30, 0x38, 0x99, 0xfd, 0x81, 0xb4, 0x8b, 0x4d, 0x67, 0x43, 0x6, 0x65, 0xfc, 0x6b, - 0x83, 0xee, 0x77, 0xc, 0xea, 0xd4, 0x0, 0x6, 0xae, 0x83, 0x86, 0x53, 0xed, 0x1e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "\172\&0m\236P\216\191\220\208y\146\237\159\163\244Q\136\214\218\197\202\DC3(d\vm\142\GSO\DC3", _password = Just "\EM\a\ACKM\203i\200\227NY:", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\170\n\217\SO\CANI8\208\NAK", _willMsg = "", _willProps = []}), _cleanSession = True, _keepAlive = 25021, _connID = "h\216P$\178\190\228\190\138\FS", _properties = []} +TEST(Connect311QCTest, Encode16) { +uint8_t pkt[] = {0x10, 0x50, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x61, 0xbd, 0x0, 0xa, 0x68, 0xd8, 0x50, 0x24, 0xb2, 0xbe, 0xe4, 0xbe, 0x8a, 0x1c, 0x0, 0x9, 0xaa, 0xa, 0xd9, 0xe, 0x18, 0x49, 0x38, 0xd0, 0x15, 0x0, 0x0, 0x0, 0x1e, 0xac, 0x30, 0x6d, 0xec, 0x50, 0xd8, 0xbf, 0xdc, 0xd0, 0x79, 0x92, 0xed, 0x9f, 0xa3, 0xf4, 0x51, 0x88, 0xd6, 0xda, 0xc5, 0xca, 0x13, 0x28, 0x64, 0xb, 0x6d, 0x8e, 0x1d, 0x4f, 0x13, 0x0, 0xb, 0x19, 0x7, 0x6, 0x4d, 0xcb, 0x69, 0xc8, 0xe3, 0x4e, 0x59, 0x3a}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6f, 0x61, 0xb, 0x2c, 0x2b, 0x81, 0x7b, 0xdf, 0x4e, 0xd8, 0x32, 0x7d, 0xf, - 0xa1, 0x2d, 0xa5, 0x61, 0x92, 0x37, 0xf8, 0xa6, 0xe0, 0xbd, 0x1, 0x1b, 0xb6}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6d, 0x5d}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3974; - uint8_t client_id_bytes[] = {0xcb, 0x96, 0xd3, 0xd4, 0xde, 0x29, 0x3b, 0xd0, 0x95, 0x81, 0x14, 0x7e, 0xf2, 0x79, - 0xba, 0x8f, 0xfe, 0x55, 0x9a, 0x16, 0x78, 0xf5, 0xf8, 0xc, 0xa6, 0x6d, 0x21}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xd0, 0x30, 0x38, 0x99, 0xfd, 0x81, 0xb4, 0x8b, 0x4d, 0x67, 0x43, - 0x6, 0x65, 0xfc, 0x6b, 0x83, 0xee, 0x77, 0xc, 0xea, 0xd4}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xae, 0x83, 0x86, 0x53, 0xed, 0x1e}; - lwmqtt_string_t password = {6, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0xaa, 0xa, 0xd9, 0xe, 0x18, 0x49, 0x38, 0xd0, 0x15}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 25021; + uint8_t client_id_bytes[] = {0x68, 0xd8, 0x50, 0x24, 0xb2, 0xbe, 0xe4, 0xbe, 0x8a, 0x1c}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xac, 0x30, 0x6d, 0xec, 0x50, 0xd8, 0xbf, 0xdc, 0xd0, 0x79, 0x92, 0xed, 0x9f, 0xa3, 0xf4, 0x51, 0x88, 0xd6, 0xda, 0xc5, 0xca, 0x13, 0x28, 0x64, 0xb, 0x6d, 0x8e, 0x1d, 0x4f, 0x13}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x19, 0x7, 0x6, 0x4d, 0xcb, 0x69, 0xc8, 0xe3, 0x4e, 0x59, 0x3a}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\188\129", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS0, _willTopic = "\129\&3\164\SI_\141bs\171\247\163v\159\181\150T\180\136Az", _willMsg = " -// /\189\141D\179\139\140\223\211:A\219\205Fu\DC1", _willProps = []}), _cleanSession = False, _keepAlive = 6602, _connID -// = "%\197u\242|QM/\NUL\239\144\a\176\173\138\248\143\&0>8", _properties = []} -TEST(Connect311QCTest, Encode17) { - uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x4, 0x19, 0xca, 0x0, 0x14, 0x25, - 0xc5, 0x75, 0xf2, 0x7c, 0x51, 0x4d, 0x2f, 0x0, 0xef, 0x90, 0x7, 0xb0, 0xad, 0x8a, 0xf8, - 0x8f, 0x30, 0x3e, 0x38, 0x0, 0x14, 0x81, 0x33, 0xa4, 0xf, 0x5f, 0x8d, 0x62, 0x73, 0xab, - 0xf7, 0xa3, 0x76, 0x9f, 0xb5, 0x96, 0x54, 0xb4, 0x88, 0x41, 0x7a, 0x0, 0x11, 0x20, 0x2f, - 0xbd, 0x8d, 0x44, 0xb3, 0x8b, 0x8c, 0xdf, 0xd3, 0x3a, 0x41, 0xdb, 0xcd, 0x46, 0x75, 0x11}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "-\\\US\191>B\216\175\176\r\209#\187\163", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = ",R\166,\231d\190T\\4\f\152s\ENQ\214\188\159\242\200\STX\212yX\237", _willMsg = "G\242R!yU\157\129c\166", _willProps = []}), _cleanSession = True, _keepAlive = 13547, _connID = "r\251\173\&4c\162{\179\188\SO\213\162/\US\158ej\186\DC43\174\157\&4(u\213\US\164E", _properties = []} +TEST(Connect311QCTest, Encode17) { +uint8_t pkt[] = {0x10, 0x5f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb6, 0x34, 0xeb, 0x0, 0x1d, 0x72, 0xfb, 0xad, 0x34, 0x63, 0xa2, 0x7b, 0xb3, 0xbc, 0xe, 0xd5, 0xa2, 0x2f, 0x1f, 0x9e, 0x65, 0x6a, 0xba, 0x14, 0x33, 0xae, 0x9d, 0x34, 0x28, 0x75, 0xd5, 0x1f, 0xa4, 0x45, 0x0, 0x18, 0x2c, 0x52, 0xa6, 0x2c, 0xe7, 0x64, 0xbe, 0x54, 0x5c, 0x34, 0xc, 0x98, 0x73, 0x5, 0xd6, 0xbc, 0x9f, 0xf2, 0xc8, 0x2, 0xd4, 0x79, 0x58, 0xed, 0x0, 0xa, 0x47, 0xf2, 0x52, 0x21, 0x79, 0x55, 0x9d, 0x81, 0x63, 0xa6, 0x0, 0xe, 0x2d, 0x5c, 0x1f, 0xbf, 0x3e, 0x42, 0xd8, 0xaf, 0xb0, 0xd, 0xd1, 0x23, 0xbb, 0xa3}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2c, 0x52, 0xa6, 0x2c, 0xe7, 0x64, 0xbe, 0x54, 0x5c, 0x34, 0xc, 0x98, 0x73, 0x5, 0xd6, 0xbc, 0x9f, 0xf2, 0xc8, 0x2, 0xd4, 0x79, 0x58, 0xed}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x47, 0xf2, 0x52, 0x21, 0x79, 0x55, 0x9d, 0x81, 0x63, 0xa6}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 13547; + uint8_t client_id_bytes[] = {0x72, 0xfb, 0xad, 0x34, 0x63, 0xa2, 0x7b, 0xb3, 0xbc, 0xe, 0xd5, 0xa2, 0x2f, 0x1f, 0x9e, 0x65, 0x6a, 0xba, 0x14, 0x33, 0xae, 0x9d, 0x34, 0x28, 0x75, 0xd5, 0x1f, 0xa4, 0x45}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x2d, 0x5c, 0x1f, 0xbf, 0x3e, 0x42, 0xd8, 0xaf, 0xb0, 0xd, 0xd1, 0x23, 0xbb, 0xa3}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// ConnectRequest {_username = Just "\232g\222\&1\254\EM\195}\FS\159h\255\DC4J\131:\250\139\243\245L\SYN\132\237\145\218l\149\147D", _password = Just "\216\SYN", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\RScg\195\250\136\246\225\255\166Lm\165\206\183\159", _willMsg = "\222\238\244.\139OJ", _willProps = []}), _cleanSession = True, _keepAlive = 24226, _connID = "\171!\155o/ F\SO\201\168\DLE~\DC4*", _properties = []} +TEST(Connect311QCTest, Encode18) { +uint8_t pkt[] = {0x10, 0x59, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x5e, 0xa2, 0x0, 0xe, 0xab, 0x21, 0x9b, 0x6f, 0x2f, 0x20, 0x46, 0xe, 0xc9, 0xa8, 0x10, 0x7e, 0x14, 0x2a, 0x0, 0x10, 0x1e, 0x63, 0x67, 0xc3, 0xfa, 0x88, 0xf6, 0xe1, 0xff, 0xa6, 0x4c, 0x6d, 0xa5, 0xce, 0xb7, 0x9f, 0x0, 0x7, 0xde, 0xee, 0xf4, 0x2e, 0x8b, 0x4f, 0x4a, 0x0, 0x1e, 0xe8, 0x67, 0xde, 0x31, 0xfe, 0x19, 0xc3, 0x7d, 0x1c, 0x9f, 0x68, 0xff, 0x14, 0x4a, 0x83, 0x3a, 0xfa, 0x8b, 0xf3, 0xf5, 0x4c, 0x16, 0x84, 0xed, 0x91, 0xda, 0x6c, 0x95, 0x93, 0x44, 0x0, 0x2, 0xd8, 0x16}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; - lwmqtt_property_t willpropslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x81, 0x33, 0xa4, 0xf, 0x5f, 0x8d, 0x62, 0x73, 0xab, 0xf7, - 0xa3, 0x76, 0x9f, 0xb5, 0x96, 0x54, 0xb4, 0x88, 0x41, 0x7a}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x20, 0x2f, 0xbd, 0x8d, 0x44, 0xb3, 0x8b, 0x8c, 0xdf, - 0xd3, 0x3a, 0x41, 0xdb, 0xcd, 0x46, 0x75, 0x11}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 6602; - uint8_t client_id_bytes[] = {0x25, 0xc5, 0x75, 0xf2, 0x7c, 0x51, 0x4d, 0x2f, 0x0, 0xef, - 0x90, 0x7, 0xb0, 0xad, 0x8a, 0xf8, 0x8f, 0x30, 0x3e, 0x38}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xbc, 0x81}; + uint8_t will_topic_bytes[] = {0x1e, 0x63, 0x67, 0xc3, 0xfa, 0x88, 0xf6, 0xe1, 0xff, 0xa6, 0x4c, 0x6d, 0xa5, 0xce, 0xb7, 0x9f}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xde, 0xee, 0xf4, 0x2e, 0x8b, 0x4f, 0x4a}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 24226; + uint8_t client_id_bytes[] = {0xab, 0x21, 0x9b, 0x6f, 0x2f, 0x20, 0x46, 0xe, 0xc9, 0xa8, 0x10, 0x7e, 0x14, 0x2a}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xe8, 0x67, 0xde, 0x31, 0xfe, 0x19, 0xc3, 0x7d, 0x1c, 0x9f, 0x68, 0xff, 0x14, 0x4a, 0x83, 0x3a, 0xfa, 0x8b, 0xf3, 0xf5, 0x4c, 0x16, 0x84, 0xed, 0x91, 0xda, 0x6c, 0x95, 0x93, 0x44}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0xd8, 0x16}; lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\134\162'b\147r\DC3", _lastWill = Just (LastWill {_willRetain -// = True, _willQoS = QoS0, _willTopic = "\196.\fm\178\&9\240", _willMsg = -// "\229Y\246\171\"\a\231Vp\200\169\156\&5%\n\165\146\ETB\221\209\128\228\231", _willProps = []}), _cleanSession = True, -// _keepAlive = 10739, _connID = "/", _properties = []} -TEST(Connect311QCTest, Encode18) { - uint8_t pkt[] = {0x10, 0x2f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x29, 0xf3, 0x0, 0x1, 0x2f, 0x0, 0x7, - 0xc4, 0x2e, 0xc, 0x6d, 0xb2, 0x39, 0xf0, 0x0, 0x17, 0xe5, 0x59, 0xf6, 0xab, 0x22, 0x7, 0xe7, 0x56, - 0x70, 0xc8, 0xa9, 0x9c, 0x35, 0x25, 0xa, 0xa5, 0x92, 0x17, 0xdd, 0xd1, 0x80, 0xe4, 0xe7}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "'\216\163|\221m\165\171\236!\179M84\232bZ\149\154\234\158", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\184\185\180\202\170\173g\tsp\221\170\169{\210\160\247\SOH\tG\158N5", _willMsg = "\\\RS/%&ik\DC2\234\228\US\198.*o\190$\DC1\234\187\154\212\129", _willProps = []}), _cleanSession = False, _keepAlive = 10411, _connID = "V\EOTi\ETB\252n}!\239\188\234\&2;b\241\237$\230\184\167\154\163\NUL\206\175", _properties = []} +TEST(Connect311QCTest, Encode19) { +uint8_t pkt[] = {0x10, 0x6e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb4, 0x28, 0xab, 0x0, 0x19, 0x56, 0x4, 0x69, 0x17, 0xfc, 0x6e, 0x7d, 0x21, 0xef, 0xbc, 0xea, 0x32, 0x3b, 0x62, 0xf1, 0xed, 0x24, 0xe6, 0xb8, 0xa7, 0x9a, 0xa3, 0x0, 0xce, 0xaf, 0x0, 0x17, 0xb8, 0xb9, 0xb4, 0xca, 0xaa, 0xad, 0x67, 0x9, 0x73, 0x70, 0xdd, 0xaa, 0xa9, 0x7b, 0xd2, 0xa0, 0xf7, 0x1, 0x9, 0x47, 0x9e, 0x4e, 0x35, 0x0, 0x17, 0x5c, 0x1e, 0x2f, 0x25, 0x26, 0x69, 0x6b, 0x12, 0xea, 0xe4, 0x1f, 0xc6, 0x2e, 0x2a, 0x6f, 0xbe, 0x24, 0x11, 0xea, 0xbb, 0x9a, 0xd4, 0x81, 0x0, 0x15, 0x27, 0xd8, 0xa3, 0x7c, 0xdd, 0x6d, 0xa5, 0xab, 0xec, 0x21, 0xb3, 0x4d, 0x38, 0x34, 0xe8, 0x62, 0x5a, 0x95, 0x9a, 0xea, 0x9e}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc4, 0x2e, 0xc, 0x6d, 0xb2, 0x39, 0xf0}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe5, 0x59, 0xf6, 0xab, 0x22, 0x7, 0xe7, 0x56, 0x70, 0xc8, 0xa9, 0x9c, - 0x35, 0x25, 0xa, 0xa5, 0x92, 0x17, 0xdd, 0xd1, 0x80, 0xe4, 0xe7}; + uint8_t will_topic_bytes[] = {0xb8, 0xb9, 0xb4, 0xca, 0xaa, 0xad, 0x67, 0x9, 0x73, 0x70, 0xdd, 0xaa, 0xa9, 0x7b, 0xd2, 0xa0, 0xf7, 0x1, 0x9, 0x47, 0x9e, 0x4e, 0x35}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5c, 0x1e, 0x2f, 0x25, 0x26, 0x69, 0x6b, 0x12, 0xea, 0xe4, 0x1f, 0xc6, 0x2e, 0x2a, 0x6f, 0xbe, 0x24, 0x11, 0xea, 0xbb, 0x9a, 0xd4, 0x81}; lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 10739; - uint8_t client_id_bytes[] = {0x2f}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x86, 0xa2, 0x27, 0x62, 0x93, 0x72, 0x13}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 10411; + uint8_t client_id_bytes[] = {0x56, 0x4, 0x69, 0x17, 0xfc, 0x6e, 0x7d, 0x21, 0xef, 0xbc, 0xea, 0x32, 0x3b, 0x62, 0xf1, 0xed, 0x24, 0xe6, 0xb8, 0xa7, 0x9a, 0xa3, 0x0, 0xce, 0xaf}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x27, 0xd8, 0xa3, 0x7c, 0xdd, 0x6d, 0xa5, 0xab, 0xec, 0x21, 0xb3, 0x4d, 0x38, 0x34, 0xe8, 0x62, 0x5a, 0x95, 0x9a, 0xea, 0x9e}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\162\239\230\n3", _password = Just -// "\CAN\200\200D\180\211J@\181\217Sj\DEL\208\141\&8\135^$\175", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "Z\197\216\246\ETX\145\228\DC3\217", _willMsg = "5\204\&3\t\SI\254!\226\237\154", -// _willProps = []}), _cleanSession = False, _keepAlive = 24980, _connID = -// "f\246\\A\130\163\246\NUL\ESC\222\168?\SI\NULe\155\&9\215", _properties = []} -TEST(Connect311QCTest, Encode19) { - uint8_t pkt[] = {0x10, 0x52, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf4, 0x61, 0x94, 0x0, 0x12, 0x66, 0xf6, 0x5c, - 0x41, 0x82, 0xa3, 0xf6, 0x0, 0x1b, 0xde, 0xa8, 0x3f, 0xf, 0x0, 0x65, 0x9b, 0x39, 0xd7, 0x0, 0x9, - 0x5a, 0xc5, 0xd8, 0xf6, 0x3, 0x91, 0xe4, 0x13, 0xd9, 0x0, 0xa, 0x35, 0xcc, 0x33, 0x9, 0xf, 0xfe, - 0x21, 0xe2, 0xed, 0x9a, 0x0, 0x5, 0xa2, 0xef, 0xe6, 0xa, 0x33, 0x0, 0x14, 0x18, 0xc8, 0xc8, 0x44, - 0xb4, 0xd3, 0x4a, 0x40, 0xb5, 0xd9, 0x53, 0x6a, 0x7f, 0xd0, 0x8d, 0x38, 0x87, 0x5e, 0x24, 0xaf}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "\238E\235\195\176i4\ETX\156\201\169\199m\192\SO\135|\184\247", _password = Just "\148!\GS\GS3\143\183\154J\SOF\207+\154$\189\201\133\152\220\230c\213i", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\176\187R!\190\252\137", _willMsg = "\CAN\202\249i\219", _willProps = []}), _cleanSession = True, _keepAlive = 11619, _connID = ")G\205}(\"\172\143lX\215\SYNQT\CAN7\194\138\RS\DELr3\144\SIn\185\210y", _properties = []} +TEST(Connect311QCTest, Encode20) { +uint8_t pkt[] = {0x10, 0x67, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x2d, 0x63, 0x0, 0x1c, 0x29, 0x47, 0xcd, 0x7d, 0x28, 0x22, 0xac, 0x8f, 0x6c, 0x58, 0xd7, 0x16, 0x51, 0x54, 0x18, 0x37, 0xc2, 0x8a, 0x1e, 0x7f, 0x72, 0x33, 0x90, 0xf, 0x6e, 0xb9, 0xd2, 0x79, 0x0, 0x7, 0xb0, 0xbb, 0x52, 0x21, 0xbe, 0xfc, 0x89, 0x0, 0x5, 0x18, 0xca, 0xf9, 0x69, 0xdb, 0x0, 0x13, 0xee, 0x45, 0xeb, 0xc3, 0xb0, 0x69, 0x34, 0x3, 0x9c, 0xc9, 0xa9, 0xc7, 0x6d, 0xc0, 0xe, 0x87, 0x7c, 0xb8, 0xf7, 0x0, 0x18, 0x94, 0x21, 0x1d, 0x1d, 0x33, 0x8f, 0xb7, 0x9a, 0x4a, 0xe, 0x46, 0xcf, 0x2b, 0x9a, 0x24, 0xbd, 0xc9, 0x85, 0x98, 0xdc, 0xe6, 0x63, 0xd5, 0x69}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5a, 0xc5, 0xd8, 0xf6, 0x3, 0x91, 0xe4, 0x13, 0xd9}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x35, 0xcc, 0x33, 0x9, 0xf, 0xfe, 0x21, 0xe2, 0xed, 0x9a}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 24980; - uint8_t client_id_bytes[] = {0x66, 0xf6, 0x5c, 0x41, 0x82, 0xa3, 0xf6, 0x0, 0x1b, - 0xde, 0xa8, 0x3f, 0xf, 0x0, 0x65, 0x9b, 0x39, 0xd7}; + uint8_t will_topic_bytes[] = {0xb0, 0xbb, 0x52, 0x21, 0xbe, 0xfc, 0x89}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x18, 0xca, 0xf9, 0x69, 0xdb}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 11619; + uint8_t client_id_bytes[] = {0x29, 0x47, 0xcd, 0x7d, 0x28, 0x22, 0xac, 0x8f, 0x6c, 0x58, 0xd7, 0x16, 0x51, 0x54, 0x18, 0x37, 0xc2, 0x8a, 0x1e, 0x7f, 0x72, 0x33, 0x90, 0xf, 0x6e, 0xb9, 0xd2, 0x79}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xee, 0x45, 0xeb, 0xc3, 0xb0, 0x69, 0x34, 0x3, 0x9c, 0xc9, 0xa9, 0xc7, 0x6d, 0xc0, 0xe, 0x87, 0x7c, 0xb8, 0xf7}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x94, 0x21, 0x1d, 0x1d, 0x33, 0x8f, 0xb7, 0x9a, 0x4a, 0xe, 0x46, 0xcf, 0x2b, 0x9a, 0x24, 0xbd, 0xc9, 0x85, 0x98, 0xdc, 0xe6, 0x63, 0xd5, 0x69}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// ConnectRequest {_username = Just ";\196\214\158d\DC1\NAK\SUB\139)\218\190\184\241\CANP\STX3V\208&);\255\169\182\226\231`", _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 10023, _connID = "\158\&0\SO\215\199\&6&\NUL\172!u\226\224\240J\178nI", _properties = []} +TEST(Connect311QCTest, Encode21) { +uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x27, 0x27, 0x0, 0x12, 0x9e, 0x30, 0xe, 0xd7, 0xc7, 0x36, 0x26, 0x0, 0xac, 0x21, 0x75, 0xe2, 0xe0, 0xf0, 0x4a, 0xb2, 0x6e, 0x49, 0x0, 0x1d, 0x3b, 0xc4, 0xd6, 0x9e, 0x64, 0x11, 0x15, 0x1a, 0x8b, 0x29, 0xda, 0xbe, 0xb8, 0xf1, 0x18, 0x50, 0x2, 0x33, 0x56, 0xd0, 0x26, 0x29, 0x3b, 0xff, 0xa9, 0xb6, 0xe2, 0xe7, 0x60}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 10023; + uint8_t client_id_bytes[] = {0x9e, 0x30, 0xe, 0xd7, 0xc7, 0x36, 0x26, 0x0, 0xac, 0x21, 0x75, 0xe2, 0xe0, 0xf0, 0x4a, 0xb2, 0x6e, 0x49}; lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa2, 0xef, 0xe6, 0xa, 0x33}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x18, 0xc8, 0xc8, 0x44, 0xb4, 0xd3, 0x4a, 0x40, 0xb5, 0xd9, - 0x53, 0x6a, 0x7f, 0xd0, 0x8d, 0x38, 0x87, 0x5e, 0x24, 0xaf}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +opts.client_id = client_id; + uint8_t username_bytes[] = {0x3b, 0xc4, 0xd6, 0x9e, 0x64, 0x11, 0x15, 0x1a, 0x8b, 0x29, 0xda, 0xbe, 0xb8, 0xf1, 0x18, 0x50, 0x2, 0x33, 0x56, 0xd0, 0x26, 0x29, 0x3b, 0xff, 0xa9, 0xb6, 0xe2, 0xe7, 0x60}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\223\202e-\159\bZ\GS", _password = Just -// "\210\145\"C\US\ESC(\195\234\165\212\157t\235\178", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, -// _willTopic = "1PwW$\"}\"/9\SOH\DC4a\252\212\170=b\209y\215\SO\216.F\160\139", _willMsg = -// "\254\255\178\RS\STXL\176\236\FS\129c\209", _willProps = []}), _cleanSession = True, _keepAlive = 21539, _connID = -// "t\221\220", _properties = []} -TEST(Connect311QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0x55, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x54, 0x23, 0x0, 0x3, 0x74, - 0xdd, 0xdc, 0x0, 0x1b, 0x31, 0x50, 0x77, 0x57, 0x24, 0x22, 0x7d, 0x22, 0x2f, 0x39, 0x1, - 0x14, 0x61, 0xfc, 0xd4, 0xaa, 0x3d, 0x62, 0xd1, 0x79, 0xd7, 0xe, 0xd8, 0x2e, 0x46, 0xa0, - 0x8b, 0x0, 0xc, 0xfe, 0xff, 0xb2, 0x1e, 0x2, 0x4c, 0xb0, 0xec, 0x1c, 0x81, 0x63, 0xd1, - 0x0, 0x8, 0xdf, 0xca, 0x65, 0x2d, 0x9f, 0x8, 0x5a, 0x1d, 0x0, 0xf, 0xd2, 0x91, 0x22, - 0x43, 0x1f, 0x1b, 0x28, 0xc3, 0xea, 0xa5, 0xd4, 0x9d, 0x74, 0xeb, 0xb2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "F\208\168\t~)z\vT8=\231\137\f\197\180\&5\169O\b\222\153\175\180H\193b\154%", _password = Just "\NAK^\RS\171Ce0\DLE\151\171\237L\167#", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\ESCn\STX\167<\196\189\197", _willMsg = "G\NAK\158\v\STX\173\140y\131", _willProps = []}), _cleanSession = True, _keepAlive = 17115, _connID = "\224\239\SYNj", _properties = []} +TEST(Connect311QCTest, Encode22) { +uint8_t pkt[] = {0x10, 0x54, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x42, 0xdb, 0x0, 0x4, 0xe0, 0xef, 0x16, 0x6a, 0x0, 0x8, 0x1b, 0x6e, 0x2, 0xa7, 0x3c, 0xc4, 0xbd, 0xc5, 0x0, 0x9, 0x47, 0x15, 0x9e, 0xb, 0x2, 0xad, 0x8c, 0x79, 0x83, 0x0, 0x1d, 0x46, 0xd0, 0xa8, 0x9, 0x7e, 0x29, 0x7a, 0xb, 0x54, 0x38, 0x3d, 0xe7, 0x89, 0xc, 0xc5, 0xb4, 0x35, 0xa9, 0x4f, 0x8, 0xde, 0x99, 0xaf, 0xb4, 0x48, 0xc1, 0x62, 0x9a, 0x25, 0x0, 0xe, 0x15, 0x5e, 0x1e, 0xab, 0x43, 0x65, 0x30, 0x10, 0x97, 0xab, 0xed, 0x4c, 0xa7, 0x23}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x31, 0x50, 0x77, 0x57, 0x24, 0x22, 0x7d, 0x22, 0x2f, 0x39, 0x1, 0x14, 0x61, 0xfc, - 0xd4, 0xaa, 0x3d, 0x62, 0xd1, 0x79, 0xd7, 0xe, 0xd8, 0x2e, 0x46, 0xa0, 0x8b}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfe, 0xff, 0xb2, 0x1e, 0x2, 0x4c, 0xb0, 0xec, 0x1c, 0x81, 0x63, 0xd1}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 21539; - uint8_t client_id_bytes[] = {0x74, 0xdd, 0xdc}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xdf, 0xca, 0x65, 0x2d, 0x9f, 0x8, 0x5a, 0x1d}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd2, 0x91, 0x22, 0x43, 0x1f, 0x1b, 0x28, 0xc3, 0xea, 0xa5, 0xd4, 0x9d, 0x74, 0xeb, 0xb2}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0x1b, 0x6e, 0x2, 0xa7, 0x3c, 0xc4, 0xbd, 0xc5}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x47, 0x15, 0x9e, 0xb, 0x2, 0xad, 0x8c, 0x79, 0x83}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 17115; + uint8_t client_id_bytes[] = {0xe0, 0xef, 0x16, 0x6a}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x46, 0xd0, 0xa8, 0x9, 0x7e, 0x29, 0x7a, 0xb, 0x54, 0x38, 0x3d, 0xe7, 0x89, 0xc, 0xc5, 0xb4, 0x35, 0xa9, 0x4f, 0x8, 0xde, 0x99, 0xaf, 0xb4, 0x48, 0xc1, 0x62, 0x9a, 0x25}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x15, 0x5e, 0x1e, 0xab, 0x43, 0x65, 0x30, 0x10, 0x97, 0xab, 0xed, 0x4c, 0xa7, 0x23}; + lwmqtt_string_t password = {14, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\205lB\203\231\189}\136\179\155\DC1s\151L1\191\USz\163V\150\139n", _password = -// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\DC1\SO\218k9\194\251", -// _willMsg = "\220\247\191\205\141\195\128\255w", _willProps = []}), _cleanSession = False, _keepAlive = 11497, _connID -// = "zV\172\DC4\177\SI\214(\170\v\144\232}", _properties = []} -TEST(Connect311QCTest, Encode21) { - uint8_t pkt[] = {0x10, 0x46, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x94, 0x2c, 0xe9, 0x0, 0xd, 0x7a, - 0x56, 0xac, 0x14, 0xb1, 0xf, 0xd6, 0x28, 0xaa, 0xb, 0x90, 0xe8, 0x7d, 0x0, 0x7, 0x11, - 0xe, 0xda, 0x6b, 0x39, 0xc2, 0xfb, 0x0, 0x9, 0xdc, 0xf7, 0xbf, 0xcd, 0x8d, 0xc3, 0x80, - 0xff, 0x77, 0x0, 0x17, 0xcd, 0x6c, 0x42, 0xcb, 0xe7, 0xbd, 0x7d, 0x88, 0xb3, 0x9b, 0x11, - 0x73, 0x97, 0x4c, 0x31, 0xbf, 0x1f, 0x7a, 0xa3, 0x56, 0x96, 0x8b, 0x6e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Just "_\181", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\130\CANG\157\a\138\188H\194", _willMsg = "\131;\DEL\244\175\170\170\225\172", _willProps = []}), _cleanSession = True, _keepAlive = 18273, _connID = "\DLEX\181cI5\156\142^\212\200\ETX\254\162\223\136\ETB\142\251p\163", _properties = []} +TEST(Connect311QCTest, Encode23) { +uint8_t pkt[] = {0x10, 0x37, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x47, 0x61, 0x0, 0x15, 0x10, 0x58, 0xb5, 0x63, 0x49, 0x35, 0x9c, 0x8e, 0x5e, 0xd4, 0xc8, 0x3, 0xfe, 0xa2, 0xdf, 0x88, 0x17, 0x8e, 0xfb, 0x70, 0xa3, 0x0, 0x9, 0x82, 0x18, 0x47, 0x9d, 0x7, 0x8a, 0xbc, 0x48, 0xc2, 0x0, 0x9, 0x83, 0x3b, 0x7f, 0xf4, 0xaf, 0xaa, 0xaa, 0xe1, 0xac}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x11, 0xe, 0xda, 0x6b, 0x39, 0xc2, 0xfb}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xdc, 0xf7, 0xbf, 0xcd, 0x8d, 0xc3, 0x80, 0xff, 0x77}; + uint8_t will_topic_bytes[] = {0x82, 0x18, 0x47, 0x9d, 0x7, 0x8a, 0xbc, 0x48, 0xc2}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x83, 0x3b, 0x7f, 0xf4, 0xaf, 0xaa, 0xaa, 0xe1, 0xac}; lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 11497; - uint8_t client_id_bytes[] = {0x7a, 0x56, 0xac, 0x14, 0xb1, 0xf, 0xd6, 0x28, 0xaa, 0xb, 0x90, 0xe8, 0x7d}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xcd, 0x6c, 0x42, 0xcb, 0xe7, 0xbd, 0x7d, 0x88, 0xb3, 0x9b, 0x11, 0x73, - 0x97, 0x4c, 0x31, 0xbf, 0x1f, 0x7a, 0xa3, 0x56, 0x96, 0x8b, 0x6e}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS0; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 18273; + uint8_t client_id_bytes[] = {0x10, 0x58, 0xb5, 0x63, 0x49, 0x35, 0x9c, 0x8e, 0x5e, 0xd4, 0xc8, 0x3, 0xfe, 0xa2, 0xdf, 0x88, 0x17, 0x8e, 0xfb, 0x70, 0xa3}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x5f, 0xb5}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\251Z\240\194K\232\239\141AZ", _password = Just -// "\215]\EM\137\201\167\148\151\224z^h\231\180\213Uk+\147", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 19360, _connID = "\156\242D9\182\133e\DC1\231\177\DC4", _properties = []} -TEST(Connect311QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0x38, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x4b, 0xa0, 0x0, 0xb, 0x9c, - 0xf2, 0x44, 0x39, 0xb6, 0x85, 0x65, 0x11, 0xe7, 0xb1, 0x14, 0x0, 0xa, 0xfb, 0x5a, 0xf0, - 0xc2, 0x4b, 0xe8, 0xef, 0x8d, 0x41, 0x5a, 0x0, 0x13, 0xd7, 0x5d, 0x19, 0x89, 0xc9, 0xa7, - 0x94, 0x97, 0xe0, 0x7a, 0x5e, 0x68, 0xe7, 0xb4, 0xd5, 0x55, 0x6b, 0x2b, 0x93}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\212\138\190Q;W\148\195", _willMsg = "\213;", _willProps = []}), _cleanSession = True, _keepAlive = 31629, _connID = "\157f\DC3.", _properties = []} +TEST(Connect311QCTest, Encode24) { +uint8_t pkt[] = {0x10, 0x1e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x7b, 0x8d, 0x0, 0x4, 0x9d, 0x66, 0x13, 0x2e, 0x0, 0x8, 0xd4, 0x8a, 0xbe, 0x51, 0x3b, 0x57, 0x94, 0xc3, 0x0, 0x2, 0xd5, 0x3b}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19360; - uint8_t client_id_bytes[] = {0x9c, 0xf2, 0x44, 0x39, 0xb6, 0x85, 0x65, 0x11, 0xe7, 0xb1, 0x14}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xfb, 0x5a, 0xf0, 0xc2, 0x4b, 0xe8, 0xef, 0x8d, 0x41, 0x5a}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd7, 0x5d, 0x19, 0x89, 0xc9, 0xa7, 0x94, 0x97, 0xe0, 0x7a, - 0x5e, 0x68, 0xe7, 0xb4, 0xd5, 0x55, 0x6b, 0x2b, 0x93}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd4, 0x8a, 0xbe, 0x51, 0x3b, 0x57, 0x94, 0xc3}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd5, 0x3b}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 31629; + uint8_t client_id_bytes[] = {0x9d, 0x66, 0x13, 0x2e}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; +opts.client_id = client_id; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "X&4$#\150ffc\147", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS0, _willTopic = "\136x", _willMsg = "\170\173F9\211(\209\223@%\STX\NUL\175\144\213\136\224b", -// _willProps = []}), _cleanSession = False, _keepAlive = 19263, _connID = "\148\139\192+\177o\182\205", _properties = -// []} -TEST(Connect311QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0x38, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x84, 0x4b, 0x3f, 0x0, 0x8, 0x94, - 0x8b, 0xc0, 0x2b, 0xb1, 0x6f, 0xb6, 0xcd, 0x0, 0x2, 0x88, 0x78, 0x0, 0x12, 0xaa, 0xad, - 0x46, 0x39, 0xd3, 0x28, 0xd1, 0xdf, 0x40, 0x25, 0x2, 0x0, 0xaf, 0x90, 0xd5, 0x88, 0xe0, - 0x62, 0x0, 0xa, 0x58, 0x26, 0x34, 0x24, 0x23, 0x96, 0x66, 0x66, 0x63, 0x93}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "\252\245y:\200\b\234\&6\225\SYN\158z\238&\CAN\175\138", _password = Just "|\218-vl\SYN\222f\159V\138\232\203", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "5Y\164\&1`u\255\252\&8\171&", _willMsg = "n\STX\DC2\DEL_\171\ENQ\171\145\175\ESC6\158\&2\246\f%h\190\233O\232\175\190\128\STX\178\210\245l", _willProps = []}), _cleanSession = False, _keepAlive = 21783, _connID = "56\NAK,s\168\165\247\235\SOP\239\239\194\155\NAK\181iBp\RS\239\ACK\131\a\157\SUB\150]", _properties = []} +TEST(Connect311QCTest, Encode25) { +uint8_t pkt[] = {0x10, 0x78, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x55, 0x17, 0x0, 0x1d, 0x35, 0x36, 0x15, 0x2c, 0x73, 0xa8, 0xa5, 0xf7, 0xeb, 0xe, 0x50, 0xef, 0xef, 0xc2, 0x9b, 0x15, 0xb5, 0x69, 0x42, 0x70, 0x1e, 0xef, 0x6, 0x83, 0x7, 0x9d, 0x1a, 0x96, 0x5d, 0x0, 0xb, 0x35, 0x59, 0xa4, 0x31, 0x60, 0x75, 0xff, 0xfc, 0x38, 0xab, 0x26, 0x0, 0x1e, 0x6e, 0x2, 0x12, 0x7f, 0x5f, 0xab, 0x5, 0xab, 0x91, 0xaf, 0x1b, 0x36, 0x9e, 0x32, 0xf6, 0xc, 0x25, 0x68, 0xbe, 0xe9, 0x4f, 0xe8, 0xaf, 0xbe, 0x80, 0x2, 0xb2, 0xd2, 0xf5, 0x6c, 0x0, 0x11, 0xfc, 0xf5, 0x79, 0x3a, 0xc8, 0x8, 0xea, 0x36, 0xe1, 0x16, 0x9e, 0x7a, 0xee, 0x26, 0x18, 0xaf, 0x8a, 0x0, 0xd, 0x7c, 0xda, 0x2d, 0x76, 0x6c, 0x16, 0xde, 0x66, 0x9f, 0x56, 0x8a, 0xe8, 0xcb}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x88, 0x78}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xaa, 0xad, 0x46, 0x39, 0xd3, 0x28, 0xd1, 0xdf, 0x40, - 0x25, 0x2, 0x0, 0xaf, 0x90, 0xd5, 0x88, 0xe0, 0x62}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19263; - uint8_t client_id_bytes[] = {0x94, 0x8b, 0xc0, 0x2b, 0xb1, 0x6f, 0xb6, 0xcd}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x58, 0x26, 0x34, 0x24, 0x23, 0x96, 0x66, 0x66, 0x63, 0x93}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0x35, 0x59, 0xa4, 0x31, 0x60, 0x75, 0xff, 0xfc, 0x38, 0xab, 0x26}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6e, 0x2, 0x12, 0x7f, 0x5f, 0xab, 0x5, 0xab, 0x91, 0xaf, 0x1b, 0x36, 0x9e, 0x32, 0xf6, 0xc, 0x25, 0x68, 0xbe, 0xe9, 0x4f, 0xe8, 0xaf, 0xbe, 0x80, 0x2, 0xb2, 0xd2, 0xf5, 0x6c}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 21783; + uint8_t client_id_bytes[] = {0x35, 0x36, 0x15, 0x2c, 0x73, 0xa8, 0xa5, 0xf7, 0xeb, 0xe, 0x50, 0xef, 0xef, 0xc2, 0x9b, 0x15, 0xb5, 0x69, 0x42, 0x70, 0x1e, 0xef, 0x6, 0x83, 0x7, 0x9d, 0x1a, 0x96, 0x5d}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xfc, 0xf5, 0x79, 0x3a, 0xc8, 0x8, 0xea, 0x36, 0xe1, 0x16, 0x9e, 0x7a, 0xee, 0x26, 0x18, 0xaf, 0x8a}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x7c, 0xda, 0x2d, 0x76, 0x6c, 0x16, 0xde, 0x66, 0x9f, 0x56, 0x8a, 0xe8, 0xcb}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "\169\134\229\177\141\167:\"\240_\168S\ETB~\228\190\175\174\ACK\168\191@\171\199\GSM\208h", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\173en(3\180\NAK\238\226z\SO\231\221<8u\183\188\229\221\231\131\185\v\203;", _willMsg = -// "z#W\234\STX\229\164\203\229\130\201\SOHy\205\&3\169>\205\160\203dE\ACK\255\213\164\225\ESC\163", _willProps = []}), -// _cleanSession = True, _keepAlive = 14436, _connID = -// "\"\179\&5mH+{\187\208\t`<\149\EOT\249\182\214\184\&8\198\201\139\186\&5", _properties = []} -TEST(Connect311QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x5f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x16, 0x38, 0x64, 0x0, 0x18, 0x22, 0xb3, 0x35, - 0x6d, 0x48, 0x2b, 0x7b, 0xbb, 0xd0, 0x9, 0x60, 0x3c, 0x95, 0x4, 0xf9, 0xb6, 0xd6, 0xb8, 0x38, 0xc6, - 0xc9, 0x8b, 0xba, 0x35, 0x0, 0x1a, 0xad, 0x65, 0x6e, 0x28, 0x33, 0xb4, 0x15, 0xee, 0xe2, 0x7a, 0xe, - 0xe7, 0xdd, 0x3c, 0x38, 0x75, 0xb7, 0xbc, 0xe5, 0xdd, 0xe7, 0x83, 0xb9, 0xb, 0xcb, 0x3b, 0x0, 0x1d, - 0x7a, 0x23, 0x57, 0xea, 0x2, 0xe5, 0xa4, 0xcb, 0xe5, 0x82, 0xc9, 0x1, 0x79, 0xcd, 0x33, 0xa9, 0x3e, - 0xcd, 0xa0, 0xcb, 0x64, 0x45, 0x6, 0xff, 0xd5, 0xa4, 0xe1, 0x1b, 0xa3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "\223*\129F(\130\&4\142\220[3\138\202/U\241z\144\214\227\&9\162\164\149", _password = Just "k\177\238>\207X\198i\188\175\151\215\&4\250\DC2\133\DC3\208", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "", _willMsg = "O\f\163R\254G\172]\199\227#f/\147[\SI", _willProps = []}), _cleanSession = False, _keepAlive = 1168, _connID = "\t\208\CAN'\235Mek\SI\DC2;\237\GS\194~\SOH,", _properties = []} +TEST(Connect311QCTest, Encode26) { +uint8_t pkt[] = {0x10, 0x5f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x4, 0x90, 0x0, 0x11, 0x9, 0xd0, 0x18, 0x27, 0xeb, 0x4d, 0x65, 0x6b, 0xf, 0x12, 0x3b, 0xed, 0x1d, 0xc2, 0x7e, 0x1, 0x2c, 0x0, 0x0, 0x0, 0x10, 0x4f, 0xc, 0xa3, 0x52, 0xfe, 0x47, 0xac, 0x5d, 0xc7, 0xe3, 0x23, 0x66, 0x2f, 0x93, 0x5b, 0xf, 0x0, 0x18, 0xdf, 0x2a, 0x81, 0x46, 0x28, 0x82, 0x34, 0x8e, 0xdc, 0x5b, 0x33, 0x8a, 0xca, 0x2f, 0x55, 0xf1, 0x7a, 0x90, 0xd6, 0xe3, 0x39, 0xa2, 0xa4, 0x95, 0x0, 0x12, 0x6b, 0xb1, 0xee, 0x3e, 0xcf, 0x58, 0xc6, 0x69, 0xbc, 0xaf, 0x97, 0xd7, 0x34, 0xfa, 0x12, 0x85, 0x13, 0xd0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xad, 0x65, 0x6e, 0x28, 0x33, 0xb4, 0x15, 0xee, 0xe2, 0x7a, 0xe, 0xe7, 0xdd, - 0x3c, 0x38, 0x75, 0xb7, 0xbc, 0xe5, 0xdd, 0xe7, 0x83, 0xb9, 0xb, 0xcb, 0x3b}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7a, 0x23, 0x57, 0xea, 0x2, 0xe5, 0xa4, 0xcb, 0xe5, 0x82, - 0xc9, 0x1, 0x79, 0xcd, 0x33, 0xa9, 0x3e, 0xcd, 0xa0, 0xcb, - 0x64, 0x45, 0x6, 0xff, 0xd5, 0xa4, 0xe1, 0x1b, 0xa3}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14436; - uint8_t client_id_bytes[] = {0x22, 0xb3, 0x35, 0x6d, 0x48, 0x2b, 0x7b, 0xbb, 0xd0, 0x9, 0x60, 0x3c, - 0x95, 0x4, 0xf9, 0xb6, 0xd6, 0xb8, 0x38, 0xc6, 0xc9, 0x8b, 0xba, 0x35}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xa9, 0x86, 0xe5, 0xb1, 0x8d, 0xa7, 0x3a, 0x22, 0xf0, 0x5f, 0xa8, 0x53, 0x17, 0x7e, - 0xe4, 0xbe, 0xaf, 0xae, 0x6, 0xa8, 0xbf, 0x40, 0xab, 0xc7, 0x1d, 0x4d, 0xd0, 0x68}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4f, 0xc, 0xa3, 0x52, 0xfe, 0x47, 0xac, 0x5d, 0xc7, 0xe3, 0x23, 0x66, 0x2f, 0x93, 0x5b, 0xf}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 1168; + uint8_t client_id_bytes[] = {0x9, 0xd0, 0x18, 0x27, 0xeb, 0x4d, 0x65, 0x6b, 0xf, 0x12, 0x3b, 0xed, 0x1d, 0xc2, 0x7e, 0x1, 0x2c}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xdf, 0x2a, 0x81, 0x46, 0x28, 0x82, 0x34, 0x8e, 0xdc, 0x5b, 0x33, 0x8a, 0xca, 0x2f, 0x55, 0xf1, 0x7a, 0x90, 0xd6, 0xe3, 0x39, 0xa2, 0xa4, 0x95}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x6b, 0xb1, 0xee, 0x3e, 0xcf, 0x58, 0xc6, 0x69, 0xbc, 0xaf, 0x97, 0xd7, 0x34, 0xfa, 0x12, 0x85, 0x13, 0xd0}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "O\165\188\192\128\155\192a\198\EM?\198\230)}\161", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "s\137\218\237\244]\194(\128\202w\240\147M6\232\218\245\251\&7hf\206t", _willMsg = -// "\238+y\253\141\&0--\219\143\226YM\140U\"dA\DLE\235\128", _willProps = []}), _cleanSession = False, _keepAlive = -// 3208, _connID = "\DC3P\129h", _properties = []} -TEST(Connect311QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2c, 0xc, 0x88, 0x0, 0x4, 0x13, 0x50, 0x81, - 0x68, 0x0, 0x18, 0x73, 0x89, 0xda, 0xed, 0xf4, 0x5d, 0xc2, 0x28, 0x80, 0xca, 0x77, 0xf0, 0x93, 0x4d, - 0x36, 0xe8, 0xda, 0xf5, 0xfb, 0x37, 0x68, 0x66, 0xce, 0x74, 0x0, 0x15, 0xee, 0x2b, 0x79, 0xfd, 0x8d, - 0x30, 0x2d, 0x2d, 0xdb, 0x8f, 0xe2, 0x59, 0x4d, 0x8c, 0x55, 0x22, 0x64, 0x41, 0x10, 0xeb, 0x80}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "\220\&2", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\174'\200lI", _willMsg = "\GS\ETXa\251\147I\r\201>\212r\195\DC1\164\SO!", _willProps = []}), _cleanSession = True, _keepAlive = 6357, _connID = "\200", _properties = []} +TEST(Connect311QCTest, Encode27) { +uint8_t pkt[] = {0x10, 0x2a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb6, 0x18, 0xd5, 0x0, 0x1, 0xc8, 0x0, 0x5, 0xae, 0x27, 0xc8, 0x6c, 0x49, 0x0, 0x10, 0x1d, 0x3, 0x61, 0xfb, 0x93, 0x49, 0xd, 0xc9, 0x3e, 0xd4, 0x72, 0xc3, 0x11, 0xa4, 0xe, 0x21, 0x0, 0x2, 0xdc, 0x32}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x73, 0x89, 0xda, 0xed, 0xf4, 0x5d, 0xc2, 0x28, 0x80, 0xca, 0x77, 0xf0, - 0x93, 0x4d, 0x36, 0xe8, 0xda, 0xf5, 0xfb, 0x37, 0x68, 0x66, 0xce, 0x74}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xee, 0x2b, 0x79, 0xfd, 0x8d, 0x30, 0x2d, 0x2d, 0xdb, 0x8f, 0xe2, - 0x59, 0x4d, 0x8c, 0x55, 0x22, 0x64, 0x41, 0x10, 0xeb, 0x80}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3208; - uint8_t client_id_bytes[] = {0x13, 0x50, 0x81, 0x68}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x4f, 0xa5, 0xbc, 0xc0, 0x80, 0x9b, 0xc0, 0x61, - 0xc6, 0x19, 0x3f, 0xc6, 0xe6, 0x29, 0x7d, 0xa1}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0xae, 0x27, 0xc8, 0x6c, 0x49}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1d, 0x3, 0x61, 0xfb, 0x93, 0x49, 0xd, 0xc9, 0x3e, 0xd4, 0x72, 0xc3, 0x11, 0xa4, 0xe, 0x21}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 6357; + uint8_t client_id_bytes[] = {0xc8}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xdc, 0x32}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\149\151\139\195\172z\255\139u#\163\fg,\230|\158{", _password = Just -// "Z\165\208\RS\195i\201D9m(Z ,\165\217Aa\137\ENQ\SO\180", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\141-\179\ENQl~\217\164\234\131\134\134\207X", _willMsg = -// ";\NUL\DEL\NUL\RSHW\212\230\191L\211s)\181j\203\158\229\137", _willProps = []}), _cleanSession = True, _keepAlive = -// 32044, _connID = "\248\r\241\217\233\199#\171\195\&6}Wu\226i\209\194\149\251\&6X$\144\230", _properties = []} -TEST(Connect311QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0x76, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe6, 0x7d, 0x2c, 0x0, 0x18, 0xf8, - 0xd, 0xf1, 0xd9, 0xe9, 0xc7, 0x23, 0xab, 0xc3, 0x36, 0x7d, 0x57, 0x75, 0xe2, 0x69, 0xd1, - 0xc2, 0x95, 0xfb, 0x36, 0x58, 0x24, 0x90, 0xe6, 0x0, 0xe, 0x8d, 0x2d, 0xb3, 0x5, 0x6c, - 0x7e, 0xd9, 0xa4, 0xea, 0x83, 0x86, 0x86, 0xcf, 0x58, 0x0, 0x14, 0x3b, 0x0, 0x7f, 0x0, - 0x1e, 0x48, 0x57, 0xd4, 0xe6, 0xbf, 0x4c, 0xd3, 0x73, 0x29, 0xb5, 0x6a, 0xcb, 0x9e, 0xe5, - 0x89, 0x0, 0x12, 0x95, 0x97, 0x8b, 0xc3, 0xac, 0x7a, 0xff, 0x8b, 0x75, 0x23, 0xa3, 0xc, - 0x67, 0x2c, 0xe6, 0x7c, 0x9e, 0x7b, 0x0, 0x16, 0x5a, 0xa5, 0xd0, 0x1e, 0xc3, 0x69, 0xc9, - 0x44, 0x39, 0x6d, 0x28, 0x5a, 0x20, 0x2c, 0xa5, 0xd9, 0x41, 0x61, 0x89, 0x5, 0xe, 0xb4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - - lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; +// ConnectRequest {_username = Nothing, _password = Just "\138P\246\r\139dV\214\134\172RuyQ\235d\SI&A\169\ETX\151\187swD", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "Q\190\197\213\216\168{>!\220\238\251Zm\n\219\233\RSM\158\210\250\228\168", _willMsg = "e\227;s\172;", _willProps = []}), _cleanSession = True, _keepAlive = 10491, _connID = "", _properties = []} +TEST(Connect311QCTest, Encode28) { +uint8_t pkt[] = {0x10, 0x2e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x28, 0xfb, 0x0, 0x0, 0x0, 0x18, 0x51, 0xbe, 0xc5, 0xd5, 0xd8, 0xa8, 0x7b, 0x3e, 0x21, 0xdc, 0xee, 0xfb, 0x5a, 0x6d, 0xa, 0xdb, 0xe9, 0x1e, 0x4d, 0x9e, 0xd2, 0xfa, 0xe4, 0xa8, 0x0, 0x6, 0x65, 0xe3, 0x3b, 0x73, 0xac, 0x3b}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; - lwmqtt_property_t willpropslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8d, 0x2d, 0xb3, 0x5, 0x6c, 0x7e, 0xd9, 0xa4, 0xea, 0x83, 0x86, 0x86, 0xcf, 0x58}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3b, 0x0, 0x7f, 0x0, 0x1e, 0x48, 0x57, 0xd4, 0xe6, 0xbf, - 0x4c, 0xd3, 0x73, 0x29, 0xb5, 0x6a, 0xcb, 0x9e, 0xe5, 0x89}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 32044; - uint8_t client_id_bytes[] = {0xf8, 0xd, 0xf1, 0xd9, 0xe9, 0xc7, 0x23, 0xab, 0xc3, 0x36, 0x7d, 0x57, - 0x75, 0xe2, 0x69, 0xd1, 0xc2, 0x95, 0xfb, 0x36, 0x58, 0x24, 0x90, 0xe6}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x95, 0x97, 0x8b, 0xc3, 0xac, 0x7a, 0xff, 0x8b, 0x75, - 0x23, 0xa3, 0xc, 0x67, 0x2c, 0xe6, 0x7c, 0x9e, 0x7b}; - lwmqtt_string_t username = {18, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x5a, 0xa5, 0xd0, 0x1e, 0xc3, 0x69, 0xc9, 0x44, 0x39, 0x6d, 0x28, - 0x5a, 0x20, 0x2c, 0xa5, 0xd9, 0x41, 0x61, 0x89, 0x5, 0xe, 0xb4}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0x51, 0xbe, 0xc5, 0xd5, 0xd8, 0xa8, 0x7b, 0x3e, 0x21, 0xdc, 0xee, 0xfb, 0x5a, 0x6d, 0xa, 0xdb, 0xe9, 0x1e, 0x4d, 0x9e, 0xd2, 0xfa, 0xe4, 0xa8}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x65, 0xe3, 0x3b, 0x73, 0xac, 0x3b}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 10491; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x8a, 0x50, 0xf6, 0xd, 0x8b, 0x64, 0x56, 0xd6, 0x86, 0xac, 0x52, 0x75, 0x79, 0x51, 0xeb, 0x64, 0xf, 0x26, 0x41, 0xa9, 0x3, 0x97, 0xbb, 0x73, 0x77, 0x44}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "|\236r\252\&0Ku{\146\ETX\ACKm\178\134\193P\SUB", _password = Just -// "mYo\132\144\131\150'\206lC{\157\159\174\ETX", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, -// _willTopic = "\129\242\250\251\220\214\242\EOTx\180\v4H\156w\139\247zR\199u\172r\136\155\198\SUB", _willMsg = -// "\166V\216\GS\135B\DC4\223\177\149\223\195\178\NUL\DLER\206/Q'O\128-\EOT\134", _willProps = []}), _cleanSession = -// False, _keepAlive = 12650, _connID = "\180N\165", _properties = []} -TEST(Connect311QCTest, Encode27) { - uint8_t pkt[] = {0x10, 0x6c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x31, 0x6a, 0x0, 0x3, 0xb4, 0x4e, - 0xa5, 0x0, 0x1b, 0x81, 0xf2, 0xfa, 0xfb, 0xdc, 0xd6, 0xf2, 0x4, 0x78, 0xb4, 0xb, 0x34, 0x48, - 0x9c, 0x77, 0x8b, 0xf7, 0x7a, 0x52, 0xc7, 0x75, 0xac, 0x72, 0x88, 0x9b, 0xc6, 0x1a, 0x0, 0x19, - 0xa6, 0x56, 0xd8, 0x1d, 0x87, 0x42, 0x14, 0xdf, 0xb1, 0x95, 0xdf, 0xc3, 0xb2, 0x0, 0x10, 0x52, - 0xce, 0x2f, 0x51, 0x27, 0x4f, 0x80, 0x2d, 0x4, 0x86, 0x0, 0x11, 0x7c, 0xec, 0x72, 0xfc, 0x30, - 0x4b, 0x75, 0x7b, 0x92, 0x3, 0x6, 0x6d, 0xb2, 0x86, 0xc1, 0x50, 0x1a, 0x0, 0x10, 0x6d, 0x59, - 0x6f, 0x84, 0x90, 0x83, 0x96, 0x27, 0xce, 0x6c, 0x43, 0x7b, 0x9d, 0x9f, 0xae, 0x3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "\136\ETX\185\158{\133u\SUB]M\158\149j", _password = Just "\236\211\185\RS\166i\ENQ\145\208h\157\v\ESC!", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\224\ESC\"\DLEM\r\165\238\&9\230\141", _willMsg = "C\129\147\222\&7Q.1.", _willProps = []}), _cleanSession = True, _keepAlive = 12875, _connID = "j", _properties = []} +TEST(Connect311QCTest, Encode29) { +uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x32, 0x4b, 0x0, 0x1, 0x6a, 0x0, 0xb, 0xe0, 0x1b, 0x22, 0x10, 0x4d, 0xd, 0xa5, 0xee, 0x39, 0xe6, 0x8d, 0x0, 0x9, 0x43, 0x81, 0x93, 0xde, 0x37, 0x51, 0x2e, 0x31, 0x2e, 0x0, 0xd, 0x88, 0x3, 0xb9, 0x9e, 0x7b, 0x85, 0x75, 0x1a, 0x5d, 0x4d, 0x9e, 0x95, 0x6a, 0x0, 0xe, 0xec, 0xd3, 0xb9, 0x1e, 0xa6, 0x69, 0x5, 0x91, 0xd0, 0x68, 0x9d, 0xb, 0x1b, 0x21}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x81, 0xf2, 0xfa, 0xfb, 0xdc, 0xd6, 0xf2, 0x4, 0x78, 0xb4, 0xb, 0x34, 0x48, 0x9c, - 0x77, 0x8b, 0xf7, 0x7a, 0x52, 0xc7, 0x75, 0xac, 0x72, 0x88, 0x9b, 0xc6, 0x1a}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa6, 0x56, 0xd8, 0x1d, 0x87, 0x42, 0x14, 0xdf, 0xb1, 0x95, 0xdf, 0xc3, 0xb2, - 0x0, 0x10, 0x52, 0xce, 0x2f, 0x51, 0x27, 0x4f, 0x80, 0x2d, 0x4, 0x86}; - lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12650; - uint8_t client_id_bytes[] = {0xb4, 0x4e, 0xa5}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x7c, 0xec, 0x72, 0xfc, 0x30, 0x4b, 0x75, 0x7b, 0x92, - 0x3, 0x6, 0x6d, 0xb2, 0x86, 0xc1, 0x50, 0x1a}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6d, 0x59, 0x6f, 0x84, 0x90, 0x83, 0x96, 0x27, - 0xce, 0x6c, 0x43, 0x7b, 0x9d, 0x9f, 0xae, 0x3}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0xe0, 0x1b, 0x22, 0x10, 0x4d, 0xd, 0xa5, 0xee, 0x39, 0xe6, 0x8d}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x43, 0x81, 0x93, 0xde, 0x37, 0x51, 0x2e, 0x31, 0x2e}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 12875; + uint8_t client_id_bytes[] = {0x6a}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x88, 0x3, 0xb9, 0x9e, 0x7b, 0x85, 0x75, 0x1a, 0x5d, 0x4d, 0x9e, 0x95, 0x6a}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0xec, 0xd3, 0xb9, 0x1e, 0xa6, 0x69, 0x5, 0x91, 0xd0, 0x68, 0x9d, 0xb, 0x1b, 0x21}; + lwmqtt_string_t password = {14, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\176\SUB(", _password = Nothing, _lastWill = Nothing, _cleanSession = False, -// _keepAlive = 9985, _connID = "\144\&3\142\215M", _properties = []} -TEST(Connect311QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0x16, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x27, 0x1, - 0x0, 0x5, 0x90, 0x33, 0x8e, 0xd7, 0x4d, 0x0, 0x3, 0xb0, 0x1a, 0x28}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Just "\CAN`l\229\237\255", _password = Just "\192o\213\179\182\245\198(\236\EOT\NAK/", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\246\227\176\175_4\EOT{\143\204\150", _willMsg = "\209\190U\246\210\133\207\145\&9\229", _willProps = []}), _cleanSession = True, _keepAlive = 67, _connID = "\246Q\170N+\132\254\213*\162\243\n", _properties = []} +TEST(Connect311QCTest, Encode30) { +uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x0, 0x43, 0x0, 0xc, 0xf6, 0x51, 0xaa, 0x4e, 0x2b, 0x84, 0xfe, 0xd5, 0x2a, 0xa2, 0xf3, 0xa, 0x0, 0xb, 0xf6, 0xe3, 0xb0, 0xaf, 0x5f, 0x34, 0x4, 0x7b, 0x8f, 0xcc, 0x96, 0x0, 0xa, 0xd1, 0xbe, 0x55, 0xf6, 0xd2, 0x85, 0xcf, 0x91, 0x39, 0xe5, 0x0, 0x6, 0x18, 0x60, 0x6c, 0xe5, 0xed, 0xff, 0x0, 0xc, 0xc0, 0x6f, 0xd5, 0xb3, 0xb6, 0xf5, 0xc6, 0x28, 0xec, 0x4, 0x15, 0x2f}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 9985; - uint8_t client_id_bytes[] = {0x90, 0x33, 0x8e, 0xd7, 0x4d}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xb0, 0x1a, 0x28}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); +lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + }; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf6, 0xe3, 0xb0, 0xaf, 0x5f, 0x34, 0x4, 0x7b, 0x8f, 0xcc, 0x96}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd1, 0xbe, 0x55, 0xf6, 0xd2, 0x85, 0xcf, 0x91, 0x39, 0xe5}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 67; + uint8_t client_id_bytes[] = {0xf6, 0x51, 0xaa, 0x4e, 0x2b, 0x84, 0xfe, 0xd5, 0x2a, 0xa2, 0xf3, 0xa}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x18, 0x60, 0x6c, 0xe5, 0xed, 0xff}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0xc0, 0x6f, 0xd5, 0xb3, 0xb6, 0xf5, 0xc6, 0x28, 0xec, 0x4, 0x15, 0x2f}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS2, _willTopic = "3\ENQ\159tA", _willMsg = "\253\&0\175\230\149U\228\219\161nq\159m\NAK", _willProps = []}), -// _cleanSession = True, _keepAlive = 2853, _connID = "\223k\158\244\196\196\240\228\&8\134\t*", _properties = []} -TEST(Connect311QCTest, Encode29) { - uint8_t pkt[] = {0x10, 0x2f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0xb, 0x25, 0x0, 0xc, 0xdf, 0x6b, 0x9e, - 0xf4, 0xc4, 0xc4, 0xf0, 0xe4, 0x38, 0x86, 0x9, 0x2a, 0x0, 0x5, 0x33, 0x5, 0x9f, 0x74, 0x41, 0x0, - 0xe, 0xfd, 0x30, 0xaf, 0xe6, 0x95, 0x55, 0xe4, 0xdb, 0xa1, 0x6e, 0x71, 0x9f, 0x6d, 0x15}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Just "<\200\232q\179c\222\168\a\186M\US\251I\210\222w\195H8\NUL\242!X\199s\219\245\165i", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "e\166s3\SOH\158_\232u5y\249\184aJ\194\246\220\226\184\209\223\EM", _willMsg = "_\245\131\131I\205\b\225\ETB\152\SO\152\&0\ENQ\145<\158\t4:\135", _willProps = [PropTopicAliasMaximum 7039,PropSubscriptionIdentifierAvailable 245,PropAuthenticationData "KG\228\255L\167F",PropSubscriptionIdentifierAvailable 22,PropServerReference ".\206C\196\172 \EOT\159(\176\165Q",PropServerReference "f\DLEQ\253\131{d2\133[\199\nI\218\244\FS\191\202\&2\163\199\222\STX",PropRequestProblemInformation 23,PropWillDelayInterval 29502,PropSubscriptionIdentifier 10,PropWildcardSubscriptionAvailable 198,PropPayloadFormatIndicator 55,PropRequestResponseInformation 58,PropCorrelationData "yj4\159\SYN\184\133[\183p\173\DC2\205\US\241\224z\252\EOT\182\200\RS3",PropTopicAlias 31480,PropSubscriptionIdentifier 21,PropContentType "\232(\167f\165\"\ETB\151\CAN\172",PropMaximumPacketSize 18233,PropServerKeepAlive 27264,PropAuthenticationData "\168\CAN\190%\218\174p!\248\233\DC2\v\235\182\166s\ENQQ\143m\253\221\232",PropTopicAliasMaximum 11399,PropMaximumQoS 81,PropRequestProblemInformation 184,PropResponseInformation "\248.\192<\SYNJ 2\DC4\246+\166\FSah\DC1&j\SOHY\198\162\215",PropUserProperty "\182\236d\169o]" "O\250",PropServerKeepAlive 30187,PropSubscriptionIdentifier 32,PropMessageExpiryInterval 30375,PropSubscriptionIdentifierAvailable 114]}), _cleanSession = False, _keepAlive = 14400, _connID = "\NAK\178o-", _properties = [PropRequestProblemInformation 183]} +TEST(Connect5QCTest, Encode1) { +uint8_t pkt[] = {0x10, 0xb6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6c, 0x38, 0x40, 0x2, 0x17, 0xb7, 0x0, 0x4, 0x15, 0xb2, 0x6f, 0x2d, 0xd1, 0x1, 0x22, 0x1b, 0x7f, 0x29, 0xf5, 0x16, 0x0, 0x7, 0x4b, 0x47, 0xe4, 0xff, 0x4c, 0xa7, 0x46, 0x29, 0x16, 0x1c, 0x0, 0xc, 0x2e, 0xce, 0x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6, 0x73, 0x33, 0x1, 0x9e, 0x5f, 0xe8, 0x75, 0x35, 0x79, 0xf9, 0xb8, 0x61, 0x4a, 0xc2, 0xf6, 0xdc, 0xe2, 0xb8, 0xd1, 0xdf, 0x19, 0x0, 0x15, 0x5f, 0xf5, 0x83, 0x83, 0x49, 0xcd, 0x8, 0xe1, 0x17, 0x98, 0xe, 0x98, 0x30, 0x5, 0x91, 0x3c, 0x9e, 0x9, 0x34, 0x3a, 0x87, 0x0, 0x1e, 0x3c, 0xc8, 0xe8, 0x71, 0xb3, 0x63, 0xde, 0xa8, 0x7, 0xba, 0x4d, 0x1f, 0xfb, 0x49, 0xd2, 0xde, 0x77, 0xc3, 0x48, 0x38, 0x0, 0xf2, 0x21, 0x58, 0xc7, 0x73, 0xdb, 0xf5, 0xa5, 0x69}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 183}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x4b, 0x47, 0xe4, 0xff, 0x4c, 0xa7, 0x46}; + uint8_t byteswillprops1[] = {0x2e, 0xce, 0x43, 0xc4, 0xac, 0x20, 0x4, 0x9f, 0x28, 0xb0, 0xa5, 0x51}; + uint8_t byteswillprops2[] = {0x66, 0x10, 0x51, 0xfd, 0x83, 0x7b, 0x64, 0x32, 0x85, 0x5b, 0xc7, 0xa, 0x49, 0xda, 0xf4, 0x1c, 0xbf, 0xca, 0x32, 0xa3, 0xc7, 0xde, 0x2}; + uint8_t byteswillprops3[] = {0x79, 0x6a, 0x34, 0x9f, 0x16, 0xb8, 0x85, 0x5b, 0xb7, 0x70, 0xad, 0x12, 0xcd, 0x1f, 0xf1, 0xe0, 0x7a, 0xfc, 0x4, 0xb6, 0xc8, 0x1e, 0x33}; + uint8_t byteswillprops4[] = {0xe8, 0x28, 0xa7, 0x66, 0xa5, 0x22, 0x17, 0x97, 0x18, 0xac}; + uint8_t byteswillprops5[] = {0xa8, 0x18, 0xbe, 0x25, 0xda, 0xae, 0x70, 0x21, 0xf8, 0xe9, 0x12, 0xb, 0xeb, 0xb6, 0xa6, 0x73, 0x5, 0x51, 0x8f, 0x6d, 0xfd, 0xdd, 0xe8}; + uint8_t byteswillprops6[] = {0xf8, 0x2e, 0xc0, 0x3c, 0x16, 0x4a, 0x20, 0x32, 0x14, 0xf6, 0x2b, 0xa6, 0x1c, 0x61, 0x68, 0x11, 0x26, 0x6a, 0x1, 0x59, 0xc6, 0xa2, 0xd7}; + uint8_t byteswillprops8[] = {0x4f, 0xfa}; + uint8_t byteswillprops7[] = {0xb6, 0xec, 0x64, 0xa9, 0x6f, 0x5d}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7039}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29502}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31480}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18233}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27264}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11399}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={6, (char*)&byteswillprops7}, .v={2, (char*)&byteswillprops8}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30187}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 32}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30375}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 114}}, + }; - lwmqtt_property_t willpropslist[] = {}; + lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x65, 0xa6, 0x73, 0x33, 0x1, 0x9e, 0x5f, 0xe8, 0x75, 0x35, 0x79, 0xf9, 0xb8, 0x61, 0x4a, 0xc2, 0xf6, 0xdc, 0xe2, 0xb8, 0xd1, 0xdf, 0x19}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5f, 0xf5, 0x83, 0x83, 0x49, 0xcd, 0x8, 0xe1, 0x17, 0x98, 0xe, 0x98, 0x30, 0x5, 0x91, 0x3c, 0x9e, 0x9, 0x34, 0x3a, 0x87}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 14400; + uint8_t client_id_bytes[] = {0x15, 0xb2, 0x6f, 0x2d}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x3c, 0xc8, 0xe8, 0x71, 0xb3, 0x63, 0xde, 0xa8, 0x7, 0xba, 0x4d, 0x1f, 0xfb, 0x49, 0xd2, 0xde, 0x77, 0xc3, 0x48, 0x38, 0x0, 0xf2, 0x21, 0x58, 0xc7, 0x73, 0xdb, 0xf5, 0xa5, 0x69}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x33, 0x5, 0x9f, 0x74, 0x41}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfd, 0x30, 0xaf, 0xe6, 0x95, 0x55, 0xe4, 0xdb, 0xa1, 0x6e, 0x71, 0x9f, 0x6d, 0x15}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 2853; - uint8_t client_id_bytes[] = {0xdf, 0x6b, 0x9e, 0xf4, 0xc4, 0xc4, 0xf0, 0xe4, 0x38, 0x86, 0x9, 0x2a}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\"", _password = Just "\223>\255\222\&1+\192nU\183\230", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\b)e\236\251\251F\231*\144\171\179\130", _willMsg = -// "\224$\244h\238M\173a\166,{\149\167\153\201{\142.\175\&3A=\249\214\DC1\254oO\186", _willProps = []}), _cleanSession = -// False, _keepAlive = 26056, _connID = "c\EM'\202qq<\213", _properties = []} -TEST(Connect311QCTest, Encode30) { - uint8_t pkt[] = {0x10, 0x52, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x65, 0xc8, 0x0, 0x8, 0x63, 0x19, 0x27, - 0xca, 0x71, 0x71, 0x3c, 0xd5, 0x0, 0xd, 0x8, 0x29, 0x65, 0xec, 0xfb, 0xfb, 0x46, 0xe7, 0x2a, 0x90, - 0xab, 0xb3, 0x82, 0x0, 0x1d, 0xe0, 0x24, 0xf4, 0x68, 0xee, 0x4d, 0xad, 0x61, 0xa6, 0x2c, 0x7b, 0x95, - 0xa7, 0x99, 0xc9, 0x7b, 0x8e, 0x2e, 0xaf, 0x33, 0x41, 0x3d, 0xf9, 0xd6, 0x11, 0xfe, 0x6f, 0x4f, 0xba, - 0x0, 0x1, 0x22, 0x0, 0xb, 0xdf, 0x3e, 0xff, 0xde, 0x31, 0x2b, 0xc0, 0x6e, 0x55, 0xb7, 0xe6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = {}; +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\157\&7\160\&4!<\152o", _willMsg = "\207\206*\r\196x\199J", _willProps = [PropReasonString "\191\132\SUB\210l}\tp\172\203",PropCorrelationData "lg\184\168q$[\198\239h\CAN\255\200\246\177\148`\GS\155\SYN\156#\167\208x",PropSubscriptionIdentifier 1,PropContentType "\t\138\220%J\192P\139s\DELI\189E}\a\RS7\242\US\195\202\SOH\146",PropSharedSubscriptionAvailable 101,PropServerKeepAlive 32013,PropTopicAliasMaximum 29954]}), _cleanSession = False, _keepAlive = 22372, _connID = "\153\215g\142q\253\SUB\139\224jU\202Kb\220Q\233\DC2\137\&5", _properties = [PropPayloadFormatIndicator 102,PropAuthenticationMethod "^\139\ACK\ENQ]\198\245\245\249\233f\162\212\187\246?5U'\158V",PropRequestProblemInformation 63,PropAuthenticationMethod "J\232\225\186e\159",PropRetainAvailable 205,PropSessionExpiryInterval 7662,PropServerKeepAlive 30100,PropMaximumQoS 218,PropContentType "\198\&4C\185\252<\207@1\145",PropSessionExpiryInterval 18186,PropReasonString "{\136\214\vX\146\142\137\199\&8\216\bC\216\&2\243\241\193^\151}\DC1\238\246\150M\252\140\138\148",PropTopicAlias 14329,PropTopicAliasMaximum 24864,PropMaximumPacketSize 1959,PropAssignedClientIdentifier "\251\155GO\172\STX\164\DC1\236\SO\152+3\202\131:&1\155\220\197\&5\210>",PropSubscriptionIdentifier 20,PropRequestProblemInformation 235,PropTopicAlias 22057,PropContentType "\154O\FS\174\199T\236tb\202D",PropSharedSubscriptionAvailable 138,PropResponseTopic "\210\254\STX\186).\v]\145Y\tl\154oJ\STX\135\STXd\250\254",PropAssignedClientIdentifier "\RS\234-\177J7R\241\216\r\181Pc<&\ENQ\229\197",PropMessageExpiryInterval 9209,PropSharedSubscriptionAvailable 80,PropResponseTopic "f\220\GSj5|YH\"-\149:\210%",PropReasonString "\207Y\247",PropUserProperty "\fO" "\\\217\130\161`\204]\227nYDd\144(G.q\141\131 d\215\ETX8\164",PropAssignedClientIdentifier "\165\243\249m\158\221s\250s\199\237j\187&\168\DC4;Y\200\151u"]} +TEST(Connect5QCTest, Encode2) { +uint8_t pkt[] = {0x10, 0xa8, 0x3, 0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c0, 0x50, 0x8b, 0x73, 0x7f, 0x49, 0xbd, 0x45, 0x7d, 0x7, 0x1e, 0x37, 0xf2, 0x1f, 0xc3, 0xca, 0x1, 0x92, 0x2a, 0x65, 0x13, 0x7d, 0xd, 0x22, 0x75, 0x2, 0x0, 0x8, 0x9d, 0x37, 0xa0, 0x34, 0x21, 0x3c, 0x98, 0x6f, 0x0, 0x8, 0xcf, 0xce, 0x2a, 0xd, 0xc4, 0x78, 0xc7, 0x4a}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x5e, 0x8b, 0x6, 0x5, 0x5d, 0xc6, 0xf5, 0xf5, 0xf9, 0xe9, 0x66, 0xa2, 0xd4, 0xbb, 0xf6, 0x3f, 0x35, 0x55, 0x27, 0x9e, 0x56}; + uint8_t bytesprops1[] = {0x4a, 0xe8, 0xe1, 0xba, 0x65, 0x9f}; + uint8_t bytesprops2[] = {0xc6, 0x34, 0x43, 0xb9, 0xfc, 0x3c, 0xcf, 0x40, 0x31, 0x91}; + uint8_t bytesprops3[] = {0x7b, 0x88, 0xd6, 0xb, 0x58, 0x92, 0x8e, 0x89, 0xc7, 0x38, 0xd8, 0x8, 0x43, 0xd8, 0x32, 0xf3, 0xf1, 0xc1, 0x5e, 0x97, 0x7d, 0x11, 0xee, 0xf6, 0x96, 0x4d, 0xfc, 0x8c, 0x8a, 0x94}; + uint8_t bytesprops4[] = {0xfb, 0x9b, 0x47, 0x4f, 0xac, 0x2, 0xa4, 0x11, 0xec, 0xe, 0x98, 0x2b, 0x33, 0xca, 0x83, 0x3a, 0x26, 0x31, 0x9b, 0xdc, 0xc5, 0x35, 0xd2, 0x3e}; + uint8_t bytesprops5[] = {0x9a, 0x4f, 0x1c, 0xae, 0xc7, 0x54, 0xec, 0x74, 0x62, 0xca, 0x44}; + uint8_t bytesprops6[] = {0xd2, 0xfe, 0x2, 0xba, 0x29, 0x2e, 0xb, 0x5d, 0x91, 0x59, 0x9, 0x6c, 0x9a, 0x6f, 0x4a, 0x2, 0x87, 0x2, 0x64, 0xfa, 0xfe}; + uint8_t bytesprops7[] = {0x1e, 0xea, 0x2d, 0xb1, 0x4a, 0x37, 0x52, 0xf1, 0xd8, 0xd, 0xb5, 0x50, 0x63, 0x3c, 0x26, 0x5, 0xe5, 0xc5}; + uint8_t bytesprops8[] = {0x66, 0xdc, 0x1d, 0x6a, 0x35, 0x7c, 0x59, 0x48, 0x22, 0x2d, 0x95, 0x3a, 0xd2, 0x25}; + uint8_t bytesprops9[] = {0xcf, 0x59, 0xf7}; + uint8_t bytesprops11[] = {0x5c, 0xd9, 0x82, 0xa1, 0x60, 0xcc, 0x5d, 0xe3, 0x6e, 0x59, 0x44, 0x64, 0x90, 0x28, 0x47, 0x2e, 0x71, 0x8d, 0x83, 0x20, 0x64, 0xd7, 0x3, 0x38, 0xa4}; + uint8_t bytesprops10[] = {0xc, 0x4f}; + uint8_t bytesprops12[] = {0xa5, 0xf3, 0xf9, 0x6d, 0x9e, 0xdd, 0x73, 0xfa, 0x73, 0xc7, 0xed, 0x6a, 0xbb, 0x26, 0xa8, 0x14, 0x3b, 0x59, 0xc8, 0x97, 0x75}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7662}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30100}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18186}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14329}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24864}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1959}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22057}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9209}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={2, (char*)&bytesprops10}, .v={25, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops12}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xbf, 0x84, 0x1a, 0xd2, 0x6c, 0x7d, 0x9, 0x70, 0xac, 0xcb}; + uint8_t byteswillprops1[] = {0x6c, 0x67, 0xb8, 0xa8, 0x71, 0x24, 0x5b, 0xc6, 0xef, 0x68, 0x18, 0xff, 0xc8, 0xf6, 0xb1, 0x94, 0x60, 0x1d, 0x9b, 0x16, 0x9c, 0x23, 0xa7, 0xd0, 0x78}; + uint8_t byteswillprops2[] = {0x9, 0x8a, 0xdc, 0x25, 0x4a, 0xc0, 0x50, 0x8b, 0x73, 0x7f, 0x49, 0xbd, 0x45, 0x7d, 0x7, 0x1e, 0x37, 0xf2, 0x1f, 0xc3, 0xca, 0x1, 0x92}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32013}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29954}}, + }; - lwmqtt_property_t willpropslist[] = {}; + lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9d, 0x37, 0xa0, 0x34, 0x21, 0x3c, 0x98, 0x6f}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xcf, 0xce, 0x2a, 0xd, 0xc4, 0x78, 0xc7, 0x4a}; + lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 22372; + uint8_t client_id_bytes[] = {0x99, 0xd7, 0x67, 0x8e, 0x71, 0xfd, 0x1a, 0x8b, 0xe0, 0x6a, 0x55, 0xca, 0x4b, 0x62, 0xdc, 0x51, 0xe9, 0x12, 0x89, 0x35}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; +opts.client_id = client_id; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8, 0x29, 0x65, 0xec, 0xfb, 0xfb, 0x46, 0xe7, 0x2a, 0x90, 0xab, 0xb3, 0x82}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe0, 0x24, 0xf4, 0x68, 0xee, 0x4d, 0xad, 0x61, 0xa6, 0x2c, - 0x7b, 0x95, 0xa7, 0x99, 0xc9, 0x7b, 0x8e, 0x2e, 0xaf, 0x33, - 0x41, 0x3d, 0xf9, 0xd6, 0x11, 0xfe, 0x6f, 0x4f, 0xba}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 26056; - uint8_t client_id_bytes[] = {0x63, 0x19, 0x27, 0xca, 0x71, 0x71, 0x3c, 0xd5}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x22}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xdf, 0x3e, 0xff, 0xde, 0x31, 0x2b, 0xc0, 0x6e, 0x55, 0xb7, 0xe6}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "\STX'd2\162\&8\201\179\247\166Y\212\\E\134\229", _willMsg = -// "\STX\227Q\213\190e/R\238\220$q\218Y~\146:~\ESCo\213\150\243\EM\156+r", _willProps = [PropAuthenticationData -// "\ETXF\215R\tc\193\146\155)L)t\228\209\160\&3",PropResponseInformation "\164=\207\DC1F#'",PropWillDelayInterval -// 28458,PropServerReference "rLeCgc9\145\228\139\222\\T\191\152ae\210\200$\253^\SI\212\207\183",PropReceiveMaximum -// 3407,PropContentType "\241\244\NAK\172u\202",PropMessageExpiryInterval 10130,PropTopicAlias -// 24003,PropWildcardSubscriptionAvailable 102,PropSharedSubscriptionAvailable 227,PropPayloadFormatIndicator -// 101,PropResponseTopic "e\233\141\253c{u\233F\157",PropSubscriptionIdentifier 29,PropSessionExpiryInterval -// 23489,PropTopicAlias 9645,PropTopicAliasMaximum 18361,PropResponseInformation "5Q\195[\231\v\220\175",PropMaximumQoS -// 161,PropWillDelayInterval 20412,PropSubscriptionIdentifier 22,PropSharedSubscriptionAvailable 163]}), _cleanSession = -// True, _keepAlive = 14707, _connID = "\r\239\133\224\t\138Z\SOHVQ\194n\b\"", _properties = [PropMessageExpiryInterval -// 17304,PropSharedSubscriptionAvailable 164,PropSubscriptionIdentifier 9,PropPayloadFormatIndicator -// 139,PropRequestResponseInformation 235,PropSessionExpiryInterval 29568,PropSharedSubscriptionAvailable -// 152,PropSubscriptionIdentifierAvailable 169,PropWildcardSubscriptionAvailable 44,PropMessageExpiryInterval -// 3448,PropSubscriptionIdentifierAvailable 209,PropMaximumPacketSize 15659,PropAuthenticationData -// "\SOHi<\231\155\175\202p\SUB\141\139,",PropContentType "\177\224\226",PropRequestResponseInformation -// 17,PropRetainAvailable 45,PropWillDelayInterval 25775,PropAssignedClientIdentifier -// "E\SYN\152\211\ACK\DLEQyB\ETB",PropWildcardSubscriptionAvailable 183,PropMaximumQoS 95,PropPayloadFormatIndicator -// 17,PropUserProperty "\204\EOT=*a\194\FSu\219" "\190\SUB\152*\f\185\210\192G",PropResponseTopic -// "\137B\219\251\200\RS\vO#\170r\162\SYNK\168\193\163Z\203$\249\130\218>\172",PropCorrelationData -// "\140ge\249\150\139]\140?\147",PropMessageExpiryInterval 2846,PropSubscriptionIdentifier 24,PropSessionExpiryInterval -// 13166,PropSubscriptionIdentifierAvailable 126,PropTopicAliasMaximum 21233,PropAuthenticationMethod -// "\203\165\NUL\CAN\237M\153M\198\213"]} -TEST(Connect5QCTest, Encode1) { - uint8_t pkt[] = { - 0x10, 0x8a, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe, 0x39, 0x73, 0xb3, 0x1, 0x2, 0x0, 0x0, 0x43, - 0x98, 0x2a, 0xa4, 0xb, 0x9, 0x1, 0x8b, 0x19, 0xeb, 0x11, 0x0, 0x0, 0x73, 0x80, 0x2a, 0x98, 0x29, 0xa9, 0x28, - 0x2c, 0x2, 0x0, 0x0, 0xd, 0x78, 0x29, 0xd1, 0x27, 0x0, 0x0, 0x3d, 0x2b, 0x16, 0x0, 0xc, 0x1, 0x69, 0x3c, - 0xe7, 0x9b, 0xaf, 0xca, 0x70, 0x1a, 0x8d, 0x8b, 0x2c, 0x3, 0x0, 0x3, 0xb1, 0xe0, 0xe2, 0x19, 0x11, 0x25, 0x2d, - 0x18, 0x0, 0x0, 0x64, 0xaf, 0x12, 0x0, 0xa, 0x45, 0x16, 0x98, 0xd3, 0x6, 0x10, 0x51, 0x79, 0x42, 0x17, 0x28, - 0xb7, 0x24, 0x5f, 0x1, 0x11, 0x26, 0x0, 0x9, 0xcc, 0x4, 0x3d, 0x2a, 0x61, 0xc2, 0x1c, 0x75, 0xdb, 0x0, 0x9, - 0xbe, 0x1a, 0x98, 0x2a, 0xc, 0xb9, 0xd2, 0xc0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, 0x7b, 0x75, 0xe9, 0x46, 0x9d, 0xb, 0x1d, 0x11, 0x0, 0x0, 0x5b, 0xc1, 0x23, - 0x25, 0xad, 0x22, 0x47, 0xb9, 0x1a, 0x0, 0x8, 0x35, 0x51, 0xc3, 0x5b, 0xe7, 0xb, 0xdc, 0xaf, 0x24, 0xa1, 0x18, - 0x0, 0x0, 0x4f, 0xbc, 0xb, 0x16, 0x2a, 0xa3, 0x0, 0x10, 0x2, 0x27, 0x64, 0x32, 0xa2, 0x38, 0xc9, 0xb3, 0xf7, - 0xa6, 0x59, 0xd4, 0x5c, 0x45, 0x86, 0xe5, 0x0, 0x1b, 0x2, 0xe3, 0x51, 0xd5, 0xbe, 0x65, 0x2f, 0x52, 0xee, 0xdc, - 0x24, 0x71, 0xda, 0x59, 0x7e, 0x92, 0x3a, 0x7e, 0x1b, 0x6f, 0xd5, 0x96, 0xf3, 0x19, 0x9c, 0x2b, 0x72}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1, 0x69, 0x3c, 0xe7, 0x9b, 0xaf, 0xca, 0x70, 0x1a, 0x8d, 0x8b, 0x2c}; - uint8_t bytesprops1[] = {0xb1, 0xe0, 0xe2}; - uint8_t bytesprops2[] = {0x45, 0x16, 0x98, 0xd3, 0x6, 0x10, 0x51, 0x79, 0x42, 0x17}; - uint8_t bytesprops4[] = {0xbe, 0x1a, 0x98, 0x2a, 0xc, 0xb9, 0xd2, 0xc0, 0x47}; - uint8_t bytesprops3[] = {0xcc, 0x4, 0x3d, 0x2a, 0x61, 0xc2, 0x1c, 0x75, 0xdb}; - uint8_t bytesprops5[] = {0x89, 0x42, 0xdb, 0xfb, 0xc8, 0x1e, 0xb, 0x4f, 0x23, 0xaa, 0x72, 0xa2, 0x16, - 0x4b, 0xa8, 0xc1, 0xa3, 0x5a, 0xcb, 0x24, 0xf9, 0x82, 0xda, 0x3e, 0xac}; - uint8_t bytesprops6[] = {0x8c, 0x67, 0x65, 0xf9, 0x96, 0x8b, 0x5d, 0x8c, 0x3f, 0x93}; - uint8_t bytesprops7[] = {0xcb, 0xa5, 0x0, 0x18, 0xed, 0x4d, 0x99, 0x4d, 0xc6, 0xd5}; +// ConnectRequest {_username = Just "\210\154\156`\157$\167\211\ACK|\EMc\FS\DC4;\244\132\247\250\DC1p\226", _password = Just "\250\211\178\rK\SUB\US\221G\171\f\202\222h\195\201\142\SOH\178\141\RS\179\234d\191G\245\249", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\166\245E _4\192:\130\134\233", _willMsg = "\199!\216\227\149HhD#\178\nH@\210\185:C\147\183\168", _willProps = [PropRetainAvailable 201,PropSubscriptionIdentifier 28,PropCorrelationData "\193\bY",PropContentType "\DC1I\ACK\ACK\160\174#k\n+\194k#x.\185\166`\245\DELM\209dRs\SIC\240\&3\195",PropServerKeepAlive 8768,PropSharedSubscriptionAvailable 108,PropAssignedClientIdentifier "\202\SI\DC1\ESC\ETB\EM\SI\159a\173]\SUB\RST\241\NULX\243\139i\ENQ\241*\DC2#\135bQ\159",PropReasonString "\175\211\164",PropAuthenticationMethod "K\210\166",PropMaximumQoS 129,PropMessageExpiryInterval 5457,PropMessageExpiryInterval 28978,PropSharedSubscriptionAvailable 15,PropSessionExpiryInterval 17136]}), _cleanSession = False, _keepAlive = 11307, _connID = "\214\137\207{L;\190\191\172O\206z4\183", _properties = [PropAuthenticationMethod "\195\178\201+\211\146\r\182\&3z\204(\217\STX",PropRetainAvailable 112,PropMessageExpiryInterval 18289,PropSubscriptionIdentifier 11,PropCorrelationData "\227MN\223J\ETBa\218\179\156",PropAuthenticationData "\235V\247H*\ESCht\241\146\212:\172\250\149Q\156\205",PropResponseInformation "\250\ESC\fV\212\225\247(\EM\170\SOZ\209\142\188\218\154\EOT",PropPayloadFormatIndicator 209,PropSubscriptionIdentifierAvailable 203,PropRequestProblemInformation 213,PropRetainAvailable 99,PropWildcardSubscriptionAvailable 54,PropCorrelationData "\SYN:G\DC4\129\rb\159U\189\147",PropServerKeepAlive 19775,PropPayloadFormatIndicator 42,PropServerReference "yB\217",PropServerReference "S\204$oc\132WG\237\139\f|\158\207q",PropRetainAvailable 53,PropTopicAliasMaximum 8890,PropSubscriptionIdentifierAvailable 141,PropServerReference "\DLE\163\200\240\189\RS/J\SOH>\DC1\v\232h/o3$\FS\NULD\150\215\142&h\CAN\182\234",PropMaximumQoS 4,PropAuthenticationMethod "\ESC\175\r\230\167\232\253c\132GY",PropSharedSubscriptionAvailable 179,PropAssignedClientIdentifier "\239\CAN\154\181\NUL\SI$\221\247t\249hug/\STX\140qQ\155",PropSessionExpiryInterval 31964,PropReasonString "\US\ESCFm9\232vg\220X\148\b\231-",PropUserProperty "S\152\255\161\183g]\234" "",PropResponseInformation "\175\RS\210\129\"\230\175?\SO\ETXu\186\217)\201\136\SI\133!\160'\189\254\248\199r\159",PropTopicAlias 10779]} +TEST(Connect5QCTest, Encode3) { +uint8_t pkt[] = {0x10, 0xff, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc4, 0x2c, 0x2b, 0x9a, 0x2, 0x15, 0x0, 0xe, 0xc3, 0xb2, 0xc9, 0x2b, 0xd3, 0x92, 0xd, 0xb6, 0x33, 0x7a, 0xcc, 0x28, 0xd9, 0x2, 0x25, 0x70, 0x2, 0x0, 0x0, 0x47, 0x71, 0xb, 0xb, 0x9, 0x0, 0xa, 0xe3, 0x4d, 0x4e, 0xdf, 0x4a, 0x17, 0x61, 0xda, 0xb3, 0x9c, 0x16, 0x0, 0x12, 0xeb, 0x56, 0xf7, 0x48, 0x2a, 0x1b, 0x68, 0x74, 0xf1, 0x92, 0xd4, 0x3a, 0xac, 0xfa, 0x95, 0x51, 0x9c, 0xcd, 0x1a, 0x0, 0x12, 0xfa, 0x1b, 0xc, 0x56, 0xd4, 0xe1, 0xf7, 0x28, 0x19, 0xaa, 0xe, 0x5a, 0xd1, 0x8e, 0xbc, 0xda, 0x9a, 0x4, 0x1, 0xd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, 0x3b, 0xf4, 0x84, 0xf7, 0xfa, 0x11, 0x70, 0xe2, 0x0, 0x1c, 0xfa, 0xd3, 0xb2, 0xd, 0x4b, 0x1a, 0x1f, 0xdd, 0x47, 0xab, 0xc, 0xca, 0xde, 0x68, 0xc3, 0xc9, 0x8e, 0x1, 0xb2, 0x8d, 0x1e, 0xb3, 0xea, 0x64, 0xbf, 0x47, 0xf5, 0xf9}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xc3, 0xb2, 0xc9, 0x2b, 0xd3, 0x92, 0xd, 0xb6, 0x33, 0x7a, 0xcc, 0x28, 0xd9, 0x2}; + uint8_t bytesprops1[] = {0xe3, 0x4d, 0x4e, 0xdf, 0x4a, 0x17, 0x61, 0xda, 0xb3, 0x9c}; + uint8_t bytesprops2[] = {0xeb, 0x56, 0xf7, 0x48, 0x2a, 0x1b, 0x68, 0x74, 0xf1, 0x92, 0xd4, 0x3a, 0xac, 0xfa, 0x95, 0x51, 0x9c, 0xcd}; + uint8_t bytesprops3[] = {0xfa, 0x1b, 0xc, 0x56, 0xd4, 0xe1, 0xf7, 0x28, 0x19, 0xaa, 0xe, 0x5a, 0xd1, 0x8e, 0xbc, 0xda, 0x9a, 0x4}; + uint8_t bytesprops4[] = {0x16, 0x3a, 0x47, 0x14, 0x81, 0xd, 0x62, 0x9f, 0x55, 0xbd, 0x93}; + uint8_t bytesprops5[] = {0x79, 0x42, 0xd9}; + uint8_t bytesprops6[] = {0x53, 0xcc, 0x24, 0x6f, 0x63, 0x84, 0x57, 0x47, 0xed, 0x8b, 0xc, 0x7c, 0x9e, 0xcf, 0x71}; + uint8_t bytesprops7[] = {0x10, 0xa3, 0xc8, 0xf0, 0xbd, 0x1e, 0x2f, 0x4a, 0x1, 0x3e, 0x11, 0xb, 0xe8, 0x68, 0x2f, 0x6f, 0x33, 0x24, 0x1c, 0x0, 0x44, 0x96, 0xd7, 0x8e, 0x26, 0x68, 0x18, 0xb6, 0xea}; + uint8_t bytesprops8[] = {0x1b, 0xaf, 0xd, 0xe6, 0xa7, 0xe8, 0xfd, 0x63, 0x84, 0x47, 0x59}; + uint8_t bytesprops9[] = {0xef, 0x18, 0x9a, 0xb5, 0x0, 0xf, 0x24, 0xdd, 0xf7, 0x74, 0xf9, 0x68, 0x75, 0x67, 0x2f, 0x2, 0x8c, 0x71, 0x51, 0x9b}; + uint8_t bytesprops10[] = {0x1f, 0x1b, 0x46, 0x6d, 0x39, 0xe8, 0x76, 0x67, 0xdc, 0x58, 0x94, 0x8, 0xe7, 0x2d}; + uint8_t bytesprops12[] = {0}; + uint8_t bytesprops11[] = {0x53, 0x98, 0xff, 0xa1, 0xb7, 0x67, 0x5d, 0xea}; + uint8_t bytesprops13[] = {0xaf, 0x1e, 0xd2, 0x81, 0x22, 0xe6, 0xaf, 0x3f, 0xe, 0x3, 0x75, 0xba, 0xd9, 0x29, 0xc9, 0x88, 0xf, 0x85, 0x21, 0xa0, 0x27, 0xbd, 0xfe, 0xf8, 0xc7, 0x72, 0x9f}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17304}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29568}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3448}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15659}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25775}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops3}, .v = {9, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2846}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13166}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21233}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18289}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19775}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8890}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31964}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={8, (char*)&bytesprops11}, .v={0, (char*)&bytesprops12}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10779}}, }; lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x3, 0x46, 0xd7, 0x52, 0x9, 0x63, 0xc1, 0x92, 0x9b, - 0x29, 0x4c, 0x29, 0x74, 0xe4, 0xd1, 0xa0, 0x33}; - uint8_t byteswillprops1[] = {0xa4, 0x3d, 0xcf, 0x11, 0x46, 0x23, 0x27}; - uint8_t byteswillprops2[] = {0x72, 0x4c, 0x65, 0x43, 0x67, 0x63, 0x39, 0x91, 0xe4, 0x8b, 0xde, 0x5c, 0x54, - 0xbf, 0x98, 0x61, 0x65, 0xd2, 0xc8, 0x24, 0xfd, 0x5e, 0xf, 0xd4, 0xcf, 0xb7}; - uint8_t byteswillprops3[] = {0xf1, 0xf4, 0x15, 0xac, 0x75, 0xca}; - uint8_t byteswillprops4[] = {0x65, 0xe9, 0x8d, 0xfd, 0x63, 0x7b, 0x75, 0xe9, 0x46, 0x9d}; - uint8_t byteswillprops5[] = {0x35, 0x51, 0xc3, 0x5b, 0xe7, 0xb, 0xdc, 0xaf}; - +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xc1, 0x8, 0x59}; + uint8_t byteswillprops1[] = {0x11, 0x49, 0x6, 0x6, 0xa0, 0xae, 0x23, 0x6b, 0xa, 0x2b, 0xc2, 0x6b, 0x23, 0x78, 0x2e, 0xb9, 0xa6, 0x60, 0xf5, 0x7f, 0x4d, 0xd1, 0x64, 0x52, 0x73, 0xf, 0x43, 0xf0, 0x33, 0xc3}; + uint8_t byteswillprops2[] = {0xca, 0xf, 0x11, 0x1b, 0x17, 0x19, 0xf, 0x9f, 0x61, 0xad, 0x5d, 0x1a, 0x1e, 0x54, 0xf1, 0x0, 0x58, 0xf3, 0x8b, 0x69, 0x5, 0xf1, 0x2a, 0x12, 0x23, 0x87, 0x62, 0x51, 0x9f}; + uint8_t byteswillprops3[] = {0xaf, 0xd3, 0xa4}; + uint8_t byteswillprops4[] = {0x4b, 0xd2, 0xa6}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28458}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3407}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10130}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24003}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23489}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9645}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18361}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20412}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8768}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5457}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28978}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17136}}, }; - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2, 0x27, 0x64, 0x32, 0xa2, 0x38, 0xc9, 0xb3, - 0xf7, 0xa6, 0x59, 0xd4, 0x5c, 0x45, 0x86, 0xe5}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x2, 0xe3, 0x51, 0xd5, 0xbe, 0x65, 0x2f, 0x52, 0xee, 0xdc, 0x24, 0x71, 0xda, 0x59, - 0x7e, 0x92, 0x3a, 0x7e, 0x1b, 0x6f, 0xd5, 0x96, 0xf3, 0x19, 0x9c, 0x2b, 0x72}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14707; - uint8_t client_id_bytes[] = {0xd, 0xef, 0x85, 0xe0, 0x9, 0x8a, 0x5a, 0x1, 0x56, 0x51, 0xc2, 0x6e, 0x8, 0x22}; + lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa6, 0xf5, 0x45, 0x20, 0x5f, 0x34, 0xc0, 0x3a, 0x82, 0x86, 0xe9}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xc7, 0x21, 0xd8, 0xe3, 0x95, 0x48, 0x68, 0x44, 0x23, 0xb2, 0xa, 0x48, 0x40, 0xd2, 0xb9, 0x3a, 0x43, 0x93, 0xb7, 0xa8}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS0; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 11307; + uint8_t client_id_bytes[] = {0xd6, 0x89, 0xcf, 0x7b, 0x4c, 0x3b, 0xbe, 0xbf, 0xac, 0x4f, 0xce, 0x7a, 0x34, 0xb7}; lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); +opts.client_id = client_id; + uint8_t username_bytes[] = {0xd2, 0x9a, 0x9c, 0x60, 0x9d, 0x24, 0xa7, 0xd3, 0x6, 0x7c, 0x19, 0x63, 0x1c, 0x14, 0x3b, 0xf4, 0x84, 0xf7, 0xfa, 0x11, 0x70, 0xe2}; + lwmqtt_string_t username = {22, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0xfa, 0xd3, 0xb2, 0xd, 0x4b, 0x1a, 0x1f, 0xdd, 0x47, 0xab, 0xc, 0xca, 0xde, 0x68, 0xc3, 0xc9, 0x8e, 0x1, 0xb2, 0x8d, 0x1e, 0xb3, 0xea, 0x64, 0xbf, 0x47, 0xf5, 0xf9}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\175\223\237\151\165\143\181\186", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\224\241\206\223", _willMsg = "<\185B\DC1", _willProps = -// [PropMessageExpiryInterval 1034,PropSessionExpiryInterval 31898,PropResponseTopic -// "\210v\SO\SUBo\176\252D\254E\201\249\215",PropReasonString -// "\160\149\135=Y\158\196\164U\181\234\146\SUB\254\165\&5\155\142",PropRequestProblemInformation -// 101,PropRequestProblemInformation 176,PropWildcardSubscriptionAvailable 20,PropWillDelayInterval -// 4616,PropRequestResponseInformation 145,PropWillDelayInterval 18288,PropMaximumQoS 156,PropPayloadFormatIndicator -// 62,PropRequestProblemInformation 18,PropSharedSubscriptionAvailable 115,PropTopicAliasMaximum -// 22616,PropResponseInformation -// "\DC2\175\214I\187\207\223\163\CAN\152\ACK\233\146\212\243\ACKz\EOT\SUB_p\133O4\129",PropTopicAlias -// 20857,PropMaximumQoS 196,PropReasonString "h\US\236\151=n\187\231\191",PropReceiveMaximum -// 19853,PropSubscriptionIdentifier 9,PropMaximumPacketSize 19027,PropContentType "\b\222\232\167?\RS\235\142\166"]}), -// _cleanSession = True, _keepAlive = 12709, _connID = "qR&\218b\224.r|a\206\139\226\174(\216\EM\193", _properties = -// [PropAuthenticationMethod "(\181n\166?J(\193mV\209\EOT\ETBf\STX\237\186",PropWildcardSubscriptionAvailable -// 1,PropMaximumPacketSize 21071,PropTopicAliasMaximum 31849,PropRequestResponseInformation 197,PropTopicAlias -// 8324,PropResponseInformation "\206\134T\208\173z\244\213rTxH\155N\212\221\137J\214\229\r\178",PropAuthenticationData -// "\241n\165:B\CAN\156\194\170\204\&9\a\217G",PropTopicAlias 14445,PropSharedSubscriptionAvailable -// 83,PropReceiveMaximum 5739,PropSessionExpiryInterval 6584]} -TEST(Connect5QCTest, Encode2) { - uint8_t pkt[] = { - 0x10, 0xa0, 0x2, 0x0, 0x4, 0x4d, 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x3e, 0x17, 0x12, 0x2a, 0x73, 0x22, 0x58, 0x58, 0x1a, 0x0, 0x19, 0x12, 0xaf, 0xd6, 0x49, - 0xbb, 0xcf, 0xdf, 0xa3, 0x18, 0x98, 0x6, 0xe9, 0x92, 0xd4, 0xf3, 0x6, 0x7a, 0x4, 0x1a, 0x5f, 0x70, 0x85, 0x4f, - 0x34, 0x81, 0x23, 0x51, 0x79, 0x24, 0xc4, 0x1f, 0x0, 0x9, 0x68, 0x1f, 0xec, 0x97, 0x3d, 0x6e, 0xbb, 0xe7, 0xbf, - 0x21, 0x4d, 0x8d, 0xb, 0x9, 0x27, 0x0, 0x0, 0x4a, 0x53, 0x3, 0x0, 0x9, 0x8, 0xde, 0xe8, 0xa7, 0x3f, 0x1e, - 0xeb, 0x8e, 0xa6, 0x0, 0x4, 0xe0, 0xf1, 0xce, 0xdf, 0x0, 0x4, 0x3c, 0xb9, 0x42, 0x11, 0x0, 0x8, 0xaf, 0xdf, - 0xed, 0x97, 0xa5, 0x8f, 0xb5, 0xba}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x28, 0xb5, 0x6e, 0xa6, 0x3f, 0x4a, 0x28, 0xc1, 0x6d, - 0x56, 0xd1, 0x4, 0x17, 0x66, 0x2, 0xed, 0xba}; - uint8_t bytesprops1[] = {0xce, 0x86, 0x54, 0xd0, 0xad, 0x7a, 0xf4, 0xd5, 0x72, 0x54, 0x78, - 0x48, 0x9b, 0x4e, 0xd4, 0xdd, 0x89, 0x4a, 0xd6, 0xe5, 0xd, 0xb2}; - uint8_t bytesprops2[] = {0xf1, 0x6e, 0xa5, 0x3a, 0x42, 0x18, 0x9c, 0xc2, 0xaa, 0xcc, 0x39, 0x7, 0xd9, 0x47}; +// ConnectRequest {_username = Just "\129&\239\168\247MW\197\EOT\DEL\231\f9.aTK,o\DC324I\149\171", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\192\172\136", _willMsg = "W\132\155\204", _willProps = [PropPayloadFormatIndicator 155,PropMessageExpiryInterval 7104,PropSubscriptionIdentifierAvailable 240,PropWildcardSubscriptionAvailable 11,PropTopicAliasMaximum 6238,PropTopicAliasMaximum 29991,PropReceiveMaximum 26159,PropRetainAvailable 19,PropRetainAvailable 242,PropServerKeepAlive 28945,PropMaximumQoS 199,PropTopicAliasMaximum 29426,PropReasonString "z*\"w4\210\198\167lND\230\195\233\\\165\EMbqO\195\219\220\207!\140/\n\188",PropMaximumQoS 118,PropReasonString "\SYNHn\136\t\175f?\132",PropMessageExpiryInterval 13081,PropAuthenticationData "9\239\STXg\130G\212\245\186\154j\175\253\175 \183\167\164\135\202\247O",PropRequestResponseInformation 224,PropSubscriptionIdentifierAvailable 16,PropMessageExpiryInterval 19854,PropResponseTopic "\131\224G\170\&5\ETX\228\223\149",PropRetainAvailable 124,PropSubscriptionIdentifierAvailable 77]}), _cleanSession = True, _keepAlive = 16616, _connID = "f4\EOTKMC\199\173\161\251\151", _properties = [PropRequestProblemInformation 43,PropMessageExpiryInterval 1208,PropRetainAvailable 117,PropRequestResponseInformation 191,PropSharedSubscriptionAvailable 108,PropMaximumQoS 22,PropContentType "\171\234\131Ip)\rbbg\161\&5\148\209\t\223;\170\253\247\ETXi\131F\237pn",PropCorrelationData "",PropAuthenticationMethod " \SI\202\229",PropSharedSubscriptionAvailable 75]} +TEST(Connect5QCTest, Encode4) { +uint8_t pkt[] = {0x10, 0xfe, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xa6, 0x40, 0xe8, 0x39, 0x17, 0x2b, 0x2, 0x0, 0x0, 0x4, 0xb8, 0x25, 0x75, 0x19, 0xbf, 0x2a, 0x6c, 0x24, 0x16, 0x3, 0x0, 0x1b, 0xab, 0xea, 0x83, 0x49, 0x70, 0x29, 0xd, 0x62, 0x62, 0x67, 0xa1, 0x35, 0x94, 0xd1, 0x9, 0xdf, 0x3b, 0xaa, 0xfd, 0xf7, 0x3, 0x69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, 0x39, 0x2e, 0x61, 0x54, 0x4b, 0x2c, 0x6f, 0x13, 0x32, 0x34, 0x49, 0x95, 0xab}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xab, 0xea, 0x83, 0x49, 0x70, 0x29, 0xd, 0x62, 0x62, 0x67, 0xa1, 0x35, 0x94, 0xd1, 0x9, 0xdf, 0x3b, 0xaa, 0xfd, 0xf7, 0x3, 0x69, 0x83, 0x46, 0xed, 0x70, 0x6e}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x20, 0xf, 0xca, 0xe5}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21071}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31849}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8324}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14445}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5739}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6584}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1208}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 75}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd2, 0x76, 0xe, 0x1a, 0x6f, 0xb0, 0xfc, 0x44, 0xfe, 0x45, 0xc9, 0xf9, 0xd7}; - uint8_t byteswillprops1[] = {0xa0, 0x95, 0x87, 0x3d, 0x59, 0x9e, 0xc4, 0xa4, 0x55, - 0xb5, 0xea, 0x92, 0x1a, 0xfe, 0xa5, 0x35, 0x9b, 0x8e}; - uint8_t byteswillprops2[] = {0x12, 0xaf, 0xd6, 0x49, 0xbb, 0xcf, 0xdf, 0xa3, 0x18, 0x98, 0x6, 0xe9, 0x92, - 0xd4, 0xf3, 0x6, 0x7a, 0x4, 0x1a, 0x5f, 0x70, 0x85, 0x4f, 0x34, 0x81}; - uint8_t byteswillprops3[] = {0x68, 0x1f, 0xec, 0x97, 0x3d, 0x6e, 0xbb, 0xe7, 0xbf}; - uint8_t byteswillprops4[] = {0x8, 0xde, 0xe8, 0xa7, 0x3f, 0x1e, 0xeb, 0x8e, 0xa6}; - + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x7a, 0x2a, 0x22, 0x77, 0x34, 0xd2, 0xc6, 0xa7, 0x6c, 0x4e, 0x44, 0xe6, 0xc3, 0xe9, 0x5c, 0xa5, 0x19, 0x62, 0x71, 0x4f, 0xc3, 0xdb, 0xdc, 0xcf, 0x21, 0x8c, 0x2f, 0xa, 0xbc}; + uint8_t byteswillprops1[] = {0x16, 0x48, 0x6e, 0x88, 0x9, 0xaf, 0x66, 0x3f, 0x84}; + uint8_t byteswillprops2[] = {0x39, 0xef, 0x2, 0x67, 0x82, 0x47, 0xd4, 0xf5, 0xba, 0x9a, 0x6a, 0xaf, 0xfd, 0xaf, 0x20, 0xb7, 0xa7, 0xa4, 0x87, 0xca, 0xf7, 0x4f}; + uint8_t byteswillprops3[] = {0x83, 0xe0, 0x47, 0xaa, 0x35, 0x3, 0xe4, 0xdf, 0x95}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1034}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31898}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4616}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18288}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22616}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20857}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19853}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19027}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7104}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6238}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29991}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26159}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28945}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29426}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13081}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19854}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 77}}, }; lwmqtt_properties_t willprops = {23, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe0, 0xf1, 0xce, 0xdf}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3c, 0xb9, 0x42, 0x11}; + uint8_t will_topic_bytes[] = {0xc0, 0xac, 0x88}; + lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x57, 0x84, 0x9b, 0xcc}; lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 12709; - uint8_t client_id_bytes[] = {0x71, 0x52, 0x26, 0xda, 0x62, 0xe0, 0x2e, 0x72, 0x7c, - 0x61, 0xce, 0x8b, 0xe2, 0xae, 0x28, 0xd8, 0x19, 0xc1}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xaf, 0xdf, 0xed, 0x97, 0xa5, 0x8f, 0xb5, 0xba}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS0; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 16616; + uint8_t client_id_bytes[] = {0x66, 0x34, 0x4, 0x4b, 0x4d, 0x43, 0xc7, 0xad, 0xa1, 0xfb, 0x97}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x81, 0x26, 0xef, 0xa8, 0xf7, 0x4d, 0x57, 0xc5, 0x4, 0x7f, 0xe7, 0xc, 0x39, 0x2e, 0x61, 0x54, 0x4b, 0x2c, 0x6f, 0x13, 0x32, 0x34, 0x49, 0x95, 0xab}; + lwmqtt_string_t username = {25, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\223\255G", _password = Just "#\227\223\166s\STX2\230O\200nx\147\&0y\STX", -// _lastWill = Nothing, _cleanSession = False, _keepAlive = 17542, _connID = "S_\ACKjq\165\200(O\181\US\v\216", -// _properties = [PropReasonString -// "\GS5\184CN\212\220\251F\248Ns^d\215\bP\215\f(\229L\242\198\226CA\212\f\163",PropAuthenticationData -// "\\%r;\180,\250\&5@\181\240H]\DC3",PropCorrelationData -// "\172\SUB\153\180\166\193\140\&9\237\t\252b\187\142\168R+\153\188Y\167\149\DC3\216",PropCorrelationData -// "\RS\177nf\SOHNjf\136\154WH\200\SOH\191\248\134\t\145d\251C\165\DC4",PropSubscriptionIdentifier -// 4,PropWildcardSubscriptionAvailable 38,PropResponseTopic -// "^Aj$\254\245\247\151yq\149@\222u/\192\246\147\176b~{V\147\209\155\CAN\191",PropServerReference -// "h\231\169g\ENQ\v\US\US\185}\ESC\ESCg\DC3b",PropAuthenticationData "\130\218\159",PropServerKeepAlive -// 12114,PropSharedSubscriptionAvailable 195,PropSharedSubscriptionAvailable 239,PropResponseTopic -// "N\164\216\a\188\227v\DEL\242\SIt\SO\141\&0k\244",PropAuthenticationData -// "\STXj\219\249\b\236\255\212]",PropRetainAvailable 142,PropPayloadFormatIndicator 108,PropMessageExpiryInterval -// 16583]} -TEST(Connect5QCTest, Encode3) { - uint8_t pkt[] = { - 0x10, 0x84, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x44, 0x86, 0xd2, 0x1,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0x8d, 0x30, 0x6b, 0xf4, 0x16, 0x0, 0x9, 0x2, 0x6a, - 0xdb, 0xf9, 0x8, 0xec, 0xff, 0xd4, 0x5d, 0x25, 0x8e, 0x1, 0x6c, 0x2, 0x0, 0x0, 0x40, 0xc7, 0x0, 0xd, 0x53, - 0x5f, 0x6, 0x6a, 0x71, 0xa5, 0xc8, 0x28, 0x4f, 0xb5, 0x1f, 0xb, 0xd8, 0x0, 0x3, 0xdf, 0xff, 0x47, 0x0, 0x10, - 0x23, 0xe3, 0xdf, 0xa6, 0x73, 0x2, 0x32, 0xe6, 0x4f, 0xc8, 0x6e, 0x78, 0x93, 0x30, 0x79, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1d, 0x35, 0xb8, 0x43, 0x4e, 0xd4, 0xdc, 0xfb, 0x46, 0xf8, 0x4e, 0x73, 0x5e, 0x64, 0xd7, - 0x8, 0x50, 0xd7, 0xc, 0x28, 0xe5, 0x4c, 0xf2, 0xc6, 0xe2, 0x43, 0x41, 0xd4, 0xc, 0xa3}; - uint8_t bytesprops1[] = {0x5c, 0x25, 0x72, 0x3b, 0xb4, 0x2c, 0xfa, 0x35, 0x40, 0xb5, 0xf0, 0x48, 0x5d, 0x13}; - uint8_t bytesprops2[] = {0xac, 0x1a, 0x99, 0xb4, 0xa6, 0xc1, 0x8c, 0x39, 0xed, 0x9, 0xfc, 0x62, - 0xbb, 0x8e, 0xa8, 0x52, 0x2b, 0x99, 0xbc, 0x59, 0xa7, 0x95, 0x13, 0xd8}; - uint8_t bytesprops3[] = {0x1e, 0xb1, 0x6e, 0x66, 0x1, 0x4e, 0x6a, 0x66, 0x88, 0x9a, 0x57, 0x48, - 0xc8, 0x1, 0xbf, 0xf8, 0x86, 0x9, 0x91, 0x64, 0xfb, 0x43, 0xa5, 0x14}; - uint8_t bytesprops4[] = {0x5e, 0x41, 0x6a, 0x24, 0xfe, 0xf5, 0xf7, 0x97, 0x79, 0x71, 0x95, 0x40, 0xde, 0x75, - 0x2f, 0xc0, 0xf6, 0x93, 0xb0, 0x62, 0x7e, 0x7b, 0x56, 0x93, 0xd1, 0x9b, 0x18, 0xbf}; - uint8_t bytesprops5[] = {0x68, 0xe7, 0xa9, 0x67, 0x5, 0xb, 0x1f, 0x1f, 0xb9, 0x7d, 0x1b, 0x1b, 0x67, 0x13, 0x62}; - uint8_t bytesprops6[] = {0x82, 0xda, 0x9f}; - uint8_t bytesprops7[] = {0x4e, 0xa4, 0xd8, 0x7, 0xbc, 0xe3, 0x76, 0x7f, 0xf2, 0xf, 0x74, 0xe, 0x8d, 0x30, 0x6b, 0xf4}; - uint8_t bytesprops8[] = {0x2, 0x6a, 0xdb, 0xf9, 0x8, 0xec, 0xff, 0xd4, 0x5d}; +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "?w\155e\220+\213:#.\196F1\243\198\178\&6\133\t\231\160c\FS\249\191\241\146\DC3H\175[x\229",PropMessageExpiryInterval 2953,PropServerReference "?7\176\173\&1P\147G\211\209\181\177\EOT\164A\247&\174\243\207\t\255(",PropRequestProblemInformation 97,PropReasonString "\SIL\192\248",PropAssignedClientIdentifier "\217\247j\247f\253k\188e\232\234\nB\247\253\213\142{3`"]} +TEST(Connect5QCTest, Encode5) { +uint8_t pkt[] = {0x10, 0xe2, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2c, 0x62, 0xe4, 0x67, 0x22, 0x40, 0x69, 0x23, 0x44, 0xf8, 0x29, 0xb8, 0x22, 0x72, 0xe3, 0x15, 0x0, 0x1a, 0x94, 0x34, 0x4f, 0xa3, 0x3e, 0x31, 0xf3, 0xc6, 0xb2, 0x36, 0x85, 0x9, 0xe7, 0xa0, 0x63, 0x1c, 0xf9, 0xbf, 0xf1, 0x92, 0x13, 0x48, 0xaf, 0x5b, 0x78, 0xe5, 0x2, 0x0, 0x0, 0xb, 0x89, 0x1c,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, 0x5f, 0xbc, 0xf0, 0x23, 0xf, 0xa4, 0x25, 0xe, 0x19, 0x68, 0x13, 0x60, 0x48, 0x17, 0xfb, 0xb, 0x9, 0x25, 0xdd, 0x1a, 0x0, 0x1b, 0x60, 0x5b, 0xdc, 0xb4, 0x2, 0x1d, 0x57, 0x35, 0x95, 0xf1, 0x7c, 0x78, 0xf9, 0x4d, 0x3, 0xa3, 0xfc, 0xc4, 0x73, 0x24, 0x50, 0x88, 0x55, 0xa2, 0xee, 0xe7, 0x9d, 0x11, 0x0, 0x0, 0x8, 0xf1, 0xb, 0xa, 0x28, 0x3, 0x19, 0xb1, 0x0, 0xf, 0x3f, 0x77, 0x9b, 0x65, 0xdc, 0x2b, 0xd5, 0x3a, 0x23, 0x2e, 0xc4, 0x46, 0x3c, 0x4d, 0xf7, 0x0, 0x1e, 0xa3, 0xe2, 0x3a, 0xf4, 0x16, 0x84, 0x95, 0x44, 0x5f, 0xef, 0x61, 0xf2, 0x78, 0xa7, 0x78, 0xd3, 0x2d, 0xd7, 0xdb, 0x90, 0x94, 0x67, 0xeb, 0x69, 0xef, 0xf6, 0x8f, 0xcc, 0x74, 0x4b}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x94, 0x34, 0x4f, 0xa3, 0x3e, 0x31, 0xf3, 0xc6, 0xb2, 0x36, 0x85, 0x9, 0xe7, 0xa0, 0x63, 0x1c, 0xf9, 0xbf, 0xf1, 0x92, 0x13, 0x48, 0xaf, 0x5b, 0x78, 0xe5}; + uint8_t bytesprops1[] = {0x3f, 0x37, 0xb0, 0xad, 0x31, 0x50, 0x93, 0x47, 0xd3, 0xd1, 0xb5, 0xb1, 0x4, 0xa4, 0x41, 0xf7, 0x26, 0xae, 0xf3, 0xcf, 0x9, 0xff, 0x28}; + uint8_t bytesprops2[] = {0xf, 0x4c, 0xc0, 0xf8}; + uint8_t bytesprops3[] = {0xd9, 0xf7, 0x6a, 0xf7, 0x66, 0xfd, 0x6b, 0xbc, 0x65, 0xe8, 0xea, 0xa, 0x42, 0xf7, 0xfd, 0xd5, 0x8e, 0x7b, 0x33, 0x60}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12114}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16583}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16489}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17656}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29411}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2953}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 17542; - uint8_t client_id_bytes[] = {0x53, 0x5f, 0x6, 0x6a, 0x71, 0xa5, 0xc8, 0x28, 0x4f, 0xb5, 0x1f, 0xb, 0xd8}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xdf, 0xff, 0x47}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x23, 0xe3, 0xdf, 0xa6, 0x73, 0x2, 0x32, 0xe6, - 0x4f, 0xc8, 0x6e, 0x78, 0x93, 0x30, 0x79, 0x2}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x15, 0xf0, 0xe8, 0x44, 0x5e, 0xf8, 0x89, 0x94, 0x6e, 0x89, 0x96, 0xfb, 0xa1, 0x85, 0x5c, 0xe5, 0x99, 0x3, 0x88, 0x33, 0xe, 0xaa, 0x45, 0x14}; + uint8_t byteswillprops1[] = {0x1f, 0xe1, 0xa2, 0x4e, 0x53, 0xd4, 0x37, 0x8d, 0xe, 0x7b, 0x39, 0x29, 0xe4, 0x9a, 0xe6, 0xb1, 0xe9, 0x55, 0x69, 0x11, 0xf2, 0x58, 0x95, 0x5b, 0x6e, 0xc2, 0x25, 0x6f, 0x2d, 0xd1}; + uint8_t byteswillprops2[] = {0xb6, 0xeb, 0xb3, 0x86, 0x65, 0x67, 0xa5, 0x51, 0xf, 0x29, 0xdd, 0x7c, 0x1e, 0x7, 0x23, 0x34, 0xb0, 0xcf, 0x6d, 0x70, 0xc4, 0x7d, 0x8b, 0x46, 0xd0, 0x53, 0x3f, 0x61, 0xc1}; + uint8_t byteswillprops4[] = {0x3c, 0x65, 0x39, 0x76, 0x5f, 0xbc, 0xf0}; + uint8_t byteswillprops3[] = {0x83, 0x54, 0x9c, 0x19, 0x25, 0x73, 0x67, 0x5d, 0x12, 0x8d, 0xbd, 0x20, 0xfb, 0xa2, 0xfb, 0x68}; + uint8_t byteswillprops5[] = {0x60, 0x5b, 0xdc, 0xb4, 0x2, 0x1d, 0x57, 0x35, 0x95, 0xf1, 0x7c, 0x78, 0xf9, 0x4d, 0x3, 0xa3, 0xfc, 0xc4, 0x73, 0x24, 0x50, 0x88, 0x55, 0xa2, 0xee, 0xe7, 0x9d}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22700}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={16, (char*)&byteswillprops3}, .v={7, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4004}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24648}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2289}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 177}}, + }; + + lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x3f, 0x77, 0x9b, 0x65, 0xdc, 0x2b, 0xd5, 0x3a, 0x23, 0x2e, 0xc4, 0x46, 0x3c, 0x4d, 0xf7}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa3, 0xe2, 0x3a, 0xf4, 0x16, 0x84, 0x95, 0x44, 0x5f, 0xef, 0x61, 0xf2, 0x78, 0xa7, 0x78, 0xd3, 0x2d, 0xd7, 0xdb, 0x90, 0x94, 0x67, 0xeb, 0x69, 0xef, 0xf6, 0x8f, 0xcc, 0x74, 0x4b}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 25316; + uint8_t client_id_bytes[] = {0x8}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; +opts.client_id = client_id; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\228O\159\147\140e", _password = Just -// "I7\205O\249\210\201\ACK\248\fH\247\&4\ENQ\139\231o\196", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 1450, _connID = "m\207\182 \176\137\206\172\198Q\255\173\143\SYN\154\153\143\208\181\155ao_\227\206", _properties = -// [PropRetainAvailable 254,PropResponseInformation -// "\161\130\218n\239\254X\173\165\167\128\132\CANzm\138\r\159\&0'C",PropReceiveMaximum 9284,PropContentType "iQ,\140\SI\NAK\235\188\v\134Q\218\213\143\RS",PropSharedSubscriptionAvailable 12]}), _cleanSession = True, _keepAlive = 30216, _connID = "\ETBtE\131\"\233<\193T\DLE", _properties = [PropWildcardSubscriptionAvailable 162,PropSubscriptionIdentifierAvailable 89,PropSessionExpiryInterval 5666,PropWillDelayInterval 1242,PropSubscriptionIdentifierAvailable 81,PropSubscriptionIdentifier 8,PropMaximumQoS 148,PropResponseInformation "p\SOH\140\134$X\131!`X`\ETB\141\229\196k\148\NAK",PropRequestResponseInformation 46,PropSubscriptionIdentifierAvailable 132,PropAssignedClientIdentifier "\206\&7\199\224\173\140C_]\157\246\159",PropMessageExpiryInterval 24801,PropAuthenticationData "\158\230\a\254\249",PropCorrelationData "\174\158\250\154\197\159nC\129\164",PropReasonString "jzM`*j\192\&31\137\t\DLEl\161\US\148-U\EOT\213C\212\146\212\201g\243",PropMaximumPacketSize 31605,PropAuthenticationMethod "\182\140\&4o\131\FSp\209\145\200\187\175\136k\EM=\186I'L",PropWillDelayInterval 21259,PropMaximumQoS 69,PropMaximumPacketSize 27562,PropPayloadFormatIndicator 66,PropResponseTopic "\198]\248\STX\135\248",PropWillDelayInterval 26956]} +TEST(Connect5QCTest, Encode6) { +uint8_t pkt[] = {0x10, 0xb7, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0x76, 0x8, 0xac, 0x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cf, 0x6c, 0x1a, 0xc5, 0x31, 0x32, 0x33, 0xb2, 0x8f, 0x1b, 0x0, 0x7c, 0xf6, 0x63, 0xb0, 0x73, 0xab, 0xdc, 0x50, 0x4f, 0xbc, 0xf5, 0x0, 0xb5, 0x19, 0x55, 0x16, 0x0, 0x18, 0x88, 0x84, 0x40, 0x64, 0x5d, 0xa7, 0x6c, 0x92, 0x2, 0x3e, 0xad, 0xa5, 0xa7, 0x80, 0x84, 0x18, 0x7a, 0x6d, 0x8a, 0xd, 0x9f, 0x30, 0x27, 0x43, 0x21, 0x24, 0x44, 0x3, 0x0, 0xf, 0x69, 0x51, 0x2c, 0x8c, 0xf, 0x15, 0xeb, 0xbc, 0xb, 0x86, 0x51, 0xda, 0xd5, 0x8f, 0x1e, 0x2a, 0xc, 0x0, 0xb, 0xe7, 0xd7, 0x18, 0xcb, 0xe1, 0x3, 0x31, 0xe4, 0x19, 0x24, 0xaa, 0x0, 0x12, 0x76, 0xf5, 0x9e, 0x3b, 0xd2, 0x9a, 0xea, 0xf1, 0x4f, 0xba, 0x75, 0x5b, 0x2c, 0x3c, 0x15, 0x27, 0x72, 0x3e}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x70, 0x1, 0x8c, 0x86, 0x24, 0x58, 0x83, 0x21, 0x60, 0x58, 0x60, 0x17, 0x8d, 0xe5, 0xc4, 0x6b, 0x94, 0x15}; + uint8_t bytesprops1[] = {0xce, 0x37, 0xc7, 0xe0, 0xad, 0x8c, 0x43, 0x5f, 0x5d, 0x9d, 0xf6, 0x9f}; + uint8_t bytesprops2[] = {0x9e, 0xe6, 0x7, 0xfe, 0xf9}; + uint8_t bytesprops3[] = {0xae, 0x9e, 0xfa, 0x9a, 0xc5, 0x9f, 0x6e, 0x43, 0x81, 0xa4}; + uint8_t bytesprops4[] = {0x6a, 0x7a, 0x4d, 0x60, 0x2a, 0x6a, 0xc0, 0x33, 0x31, 0x89, 0x9, 0x10, 0x6c, 0xa1, 0x1f, 0x94, 0x2d, 0x55, 0x4, 0xd5, 0x43, 0xd4, 0x92, 0xd4, 0xc9, 0x67, 0xf3}; + uint8_t bytesprops5[] = {0xb6, 0x8c, 0x34, 0x6f, 0x83, 0x1c, 0x70, 0xd1, 0x91, 0xc8, 0xbb, 0xaf, 0x88, 0x6b, 0x19, 0x3d, 0xba, 0x49, 0x27, 0x4c}; + uint8_t bytesprops6[] = {0xc6, 0x5d, 0xf8, 0x2, 0x87, 0xf8}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2257}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops1}, .v = {23, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5666}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1242}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24801}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31605}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21259}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27562}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26956}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 1450; - uint8_t client_id_bytes[] = {0x6d, 0xcf, 0xb6, 0x20, 0xb0, 0x89, 0xce, 0xac, 0xc6, 0x51, 0xff, 0xad, 0x8f, - 0x16, 0x9a, 0x99, 0x8f, 0xd0, 0xb5, 0x9b, 0x61, 0x6f, 0x5f, 0xe3, 0xce}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xe4, 0x4f, 0x9f, 0x93, 0x8c, 0x65}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x49, 0x37, 0xcd, 0x4f, 0xf9, 0xd2, 0xc9, 0x6, 0xf8, - 0xc, 0x48, 0xf7, 0x34, 0x5, 0x8b, 0xe7, 0x6f, 0xc4}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xe1, 0x11, 0xcf, 0x6c, 0x1a, 0xc5, 0x31, 0x32, 0x33, 0xb2, 0x8f, 0x1b, 0x0, 0x7c, 0xf6, 0x63, 0xb0, 0x73, 0xab, 0xdc, 0x50, 0x4f, 0xbc, 0xf5, 0x0, 0xb5}; + uint8_t byteswillprops1[] = {0x88, 0x84, 0x40, 0x64, 0x5d, 0xa7, 0x6c, 0x92, 0x2, 0x3e, 0xad, 0xa5, 0xa7, 0x80, 0x84, 0x18, 0x7a, 0x6d, 0x8a, 0xd, 0x9f, 0x30, 0x27, 0x43}; + uint8_t byteswillprops2[] = {0x69, 0x51, 0x2c, 0x8c, 0xf, 0x15, 0xeb, 0xbc, 0xb, 0x86, 0x51, 0xda, 0xd5, 0x8f, 0x1e}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9284}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 12}}, + }; + + lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe7, 0xd7, 0x18, 0xcb, 0xe1, 0x3, 0x31, 0xe4, 0x19, 0x24, 0xaa}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x76, 0xf5, 0x9e, 0x3b, 0xd2, 0x9a, 0xea, 0xf1, 0x4f, 0xba, 0x75, 0x5b, 0x2c, 0x3c, 0x15, 0x27, 0x72, 0x3e}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 30216; + uint8_t client_id_bytes[] = {0x17, 0x74, 0x45, 0x83, 0x22, 0xe9, 0x3c, 0xc1, 0x54, 0x10}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; +opts.client_id = client_id; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "ZY*\212\&2v\CAN\238\SYN\243Z-\210z\SO\229X\164`\136 \ETB\246\182zw}0\148\v", -// _password = Just "\150\&2b)", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = -// "KY\242", _willMsg = "]\169\158\183\223\181L\153xld\SI\SI\155\&6\211\239", _willProps = [PropPayloadFormatIndicator -// 220,PropSubscriptionIdentifierAvailable 110]}), _cleanSession = False, _keepAlive = 18195, _connID = -// "v\132\v6\r\164\241\&1VUf\239\GS\210\201!\158\240\&7\194", _properties = [PropUserProperty "a@jf\155l\144\ETB" -// "=\253\157\&1\197x\172n\183\254\167\224\&8\213[>\185\251\144Y",PropResponseInformation -// "'\167\&8.\139\212z\217\190\&8\172\211&",PropServerKeepAlive 21621,PropAuthenticationData -// "\DLEb\151\235K\180,>~\152\237IY",PropReceiveMaximum 10685,PropWillDelayInterval -// 31891,PropSubscriptionIdentifierAvailable 89,PropCorrelationData -// "~x\220\246\&6\168\221b:\183/\221\172\ETX\ENQ",PropMessageExpiryInterval 30900,PropAssignedClientIdentifier -// "<",PropWillDelayInterval 8778,PropMessageExpiryInterval 27,PropReceiveMaximum 16802]} -TEST(Connect5QCTest, Encode5) { - uint8_t pkt[] = { - 0x10, 0xda, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x47, 0x13, 0x76, 0x26, 0x0, 0x8, 0x61, 0x40, - 0x6a, 0x66, 0x9b, 0x6c, 0x90, 0x17, 0x0, 0x14, 0x3d, 0xfd, 0x9d, 0x31, 0xc5, 0x78, 0xac, 0x6e, 0xb7, 0xfe, 0xa7, - 0xe0, 0x38, 0xd5, 0x5b, 0x3e, 0xb9, 0xfb, 0x90, 0x59, 0x1a, 0x0, 0xd, 0x27, 0xa7, 0x38, 0x2e, 0x8b, 0xd4, 0x7a, - 0xd9, 0xbe, 0x38, 0xac, 0xd3, 0x26, 0x13, 0x54, 0x75, 0x16, 0x0, 0xd, 0x10, 0x62, 0x97, 0xeb, 0x4b, 0xb4, 0x2c, - 0x3e, 0x7e, 0x98, 0xed, 0x49, 0x59, 0x21, 0x29, 0xbd, 0x18, 0x0, 0x0, 0x7c, 0x93, 0x29, 0x59, 0x9, 0x0, 0xf, - 0x7e, 0x78, 0xdc, 0xf6, 0x36, 0xa8, 0xdd, 0x62, 0x3a, 0xb7, 0x2f, 0xdd, 0xac, 0x3, 0x5, 0x2, 0x0, 0x0, 0x78, - 0xb4, 0x12, 0x0, 0x1, 0x3c, 0x18, 0x0, 0x0, 0x22, 0x4a, 0x2, 0x0, 0x0, 0x0, 0x1b, 0x21, 0x41, 0xa2, 0x0, - 0x14, 0x76, 0x84, 0xb, 0x36, 0xd, 0xa4, 0xf1, 0x31, 0x56, 0x55, 0x66, 0xef, 0x1d, 0xd2, 0xc9, 0x21, 0x9e, 0xf0, - 0x37, 0xc2, 0x4, 0x1, 0xdc, 0x29, 0x6e, 0x0, 0x3, 0x4b, 0x59, 0xf2, 0x0, 0x11, 0x5d, 0xa9, 0x9e, 0xb7, 0xdf, - 0xb5, 0x4c, 0x99, 0x78, 0x6c, 0x64, 0xf, 0xf, 0x9b, 0x36, 0xd3, 0xef, 0x0, 0x1e, 0x5a, 0x59, 0x2a, 0xd4, 0x32, - 0x76, 0x18, 0xee, 0x16, 0xf3, 0x5a, 0x2d, 0xd2, 0x7a, 0xe, 0xe5, 0x58, 0xa4, 0x60, 0x88, 0x20, 0x17, 0xf6, 0xb6, - 0x7a, 0x77, 0x7d, 0x30, 0x94, 0xb, 0x0, 0x4, 0x96, 0x32, 0x62, 0x29}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x3d, 0xfd, 0x9d, 0x31, 0xc5, 0x78, 0xac, 0x6e, 0xb7, 0xfe, - 0xa7, 0xe0, 0x38, 0xd5, 0x5b, 0x3e, 0xb9, 0xfb, 0x90, 0x59}; - uint8_t bytesprops0[] = {0x61, 0x40, 0x6a, 0x66, 0x9b, 0x6c, 0x90, 0x17}; - uint8_t bytesprops2[] = {0x27, 0xa7, 0x38, 0x2e, 0x8b, 0xd4, 0x7a, 0xd9, 0xbe, 0x38, 0xac, 0xd3, 0x26}; - uint8_t bytesprops3[] = {0x10, 0x62, 0x97, 0xeb, 0x4b, 0xb4, 0x2c, 0x3e, 0x7e, 0x98, 0xed, 0x49, 0x59}; - uint8_t bytesprops4[] = {0x7e, 0x78, 0xdc, 0xf6, 0x36, 0xa8, 0xdd, 0x62, 0x3a, 0xb7, 0x2f, 0xdd, 0xac, 0x3, 0x5}; - uint8_t bytesprops5[] = {0x3c}; +// ConnectRequest {_username = Just "\184\RS2\175$\t.Y\176C6\139.\188\209\208\199", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "k_hun\216\209\212\219%\193\NAK[\175\250\232\STX\214\196)\SOH\135\SO\t", _willMsg = "\216\193J\242J\215\b\166\FS\181,u\246W&\128\245\STXbo\142d\186\234!\250\EM\219\136", _willProps = [PropReasonString "",PropMessageExpiryInterval 4624,PropResponseTopic "\213\DEL}kO\DEL\146",PropReasonString "\CAN-\226@y\"\CAN:\248\183[D\142\204\156\146UqcW\187\194y\166_",PropSubscriptionIdentifier 20,PropServerKeepAlive 2189,PropUserProperty "\215o\"\224" "r\232\167=4\234\&4KwD\234\165\rf\249\226d\ETX}\178\STX\250\220V\213\SYN",PropTopicAliasMaximum 16445,PropMessageExpiryInterval 10243,PropResponseTopic "g\163\135\157\132\136c\231",PropCorrelationData "",PropMaximumPacketSize 21568,PropMessageExpiryInterval 3075,PropRequestProblemInformation 212,PropContentType "\171\151S\147\US\171\134\150\200\CAN?J\142f\175\n\162O",PropSubscriptionIdentifier 12,PropWillDelayInterval 14729,PropSessionExpiryInterval 21067,PropSharedSubscriptionAvailable 108,PropAuthenticationMethod "\186%]\DC1\NUL\210c\248\SIgFOe\DC3\DC4\134a\DLE",PropResponseInformation "\130&\193\188k\150y\141\198~\196+",PropContentType "",PropServerReference "de\214OR\139\249",PropServerKeepAlive 2475,PropResponseInformation "jO",PropWillDelayInterval 6987,PropSubscriptionIdentifier 14,PropRequestProblemInformation 79,PropServerKeepAlive 7409]}), _cleanSession = True, _keepAlive = 12402, _connID = "\157\DC4\228=k\DLE5N\171\v+\185\227", _properties = [PropRetainAvailable 103,PropRetainAvailable 113,PropAssignedClientIdentifier "\154(\NAK\187\209\146y\252F\ACKo\143\157\229\217{\174\144\141{\224",PropAssignedClientIdentifier "\185/\163\236\252",PropPayloadFormatIndicator 77,PropPayloadFormatIndicator 49,PropReceiveMaximum 25543,PropMessageExpiryInterval 22717,PropWildcardSubscriptionAvailable 20,PropSubscriptionIdentifierAvailable 7,PropAuthenticationData "\129\245\EOT\240\STX\SO\138\133",PropRequestProblemInformation 10,PropResponseTopic "\178p\185P\147\147:L\r\153\152[\224\201~\187\ENQ",PropResponseInformation "\130\144\DC4\CAN\US\247\&0#$5\217\133\204\&7\155\141a9\DLE\vt4",PropServerKeepAlive 6182,PropTopicAliasMaximum 26231,PropSessionExpiryInterval 10906,PropSharedSubscriptionAvailable 79,PropSubscriptionIdentifierAvailable 173,PropSubscriptionIdentifier 32]} +TEST(Connect5QCTest, Encode7) { +uint8_t pkt[] = {0x10, 0xc7, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0x30, 0x72, 0x7f, 0x25, 0x67, 0x25, 0x71, 0x12, 0x0, 0x15, 0x9a, 0x28, 0x15, 0xbb, 0xd1, 0x92, 0x79, 0xfc, 0x46, 0x6, 0x6f, 0x8f, 0x9d, 0xe5, 0xd9, 0x7b, 0xae, 0x90, 0x8d, 0x7b, 0xe0, 0x12, 0x0, 0x5, 0xb9, 0x2f, 0xa3, 0xec, 0xfc, 0x1, 0x4d, 0x1, 0x31, 0x21, 0x63, 0xc7, 0x2, 0x0, 0x0, 0x58, 0xbd, 0x28, 0x14, 0x29, 0x7, 0x16, 0x0, 0x8, 0x81, 0xf5, 0x4, 0xf0, 0x2, 0xe, 0x8a, 0x85, 0x17, 0xa, 0x8, 0x0, 0x11, 0xb2, 0x70, 0xb9, 0x50, 0x93, 0x93, 0x3a, 0x4c, 0xd, 0x99, 0x98, 0x5b, 0xe0, 0xc9, 0x7e, 0xbb, 0x5, 0x1a, 0x0, 0x16, 0x82, 0x90, 0x14, 0x18, 0x1f, 0xf7, 0x30, 0x23, 0x24, 0x35, 0xd9, 0x85, 0xcc, 0x37, 0x9b, 0x8d, 0x61, 0x39, 0x10, 0xb, 0x74, 0x34, 0x13, 0x18, 0x26, 0x22, 0x66, 0x77, 0x11, 0x0, 0x0, 0x2a, 0x9a, 0x2a, 0x4f, 0x29, 0xad, 0xb, 0x20, 0x0, 0xd, 0x9d, 0x14, 0xe4, 0x3d, 0x6b, 0x10, 0x35, 0x4e, 0xab, 0xb, 0x2b, 0xb9, 0xe3, 0xe0, 0x1, 0x1f, 0x0, 0x0, 0x2, 0x0, 0x0, 0x12, 0x10, 0x8, 0x0, 0x7, 0xd5, 0x7f, 0x7d, 0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9, 0xab, 0x1a, 0x0, 0x2, 0x6a, 0x4f, 0x18, 0x0, 0x0, 0x1b, 0x4b, 0xb, 0xe, 0x17, 0x4f, 0x13, 0x1c, 0xf1, 0x0, 0x18, 0x6b, 0x5f, 0x68, 0x75, 0x6e, 0xd8, 0xd1, 0xd4, 0xdb, 0x25, 0xc1, 0x15, 0x5b, 0xaf, 0xfa, 0xe8, 0x2, 0xd6, 0xc4, 0x29, 0x1, 0x87, 0xe, 0x9, 0x0, 0x1d, 0xd8, 0xc1, 0x4a, 0xf2, 0x4a, 0xd7, 0x8, 0xa6, 0x1c, 0xb5, 0x2c, 0x75, 0xf6, 0x57, 0x26, 0x80, 0xf5, 0x2, 0x62, 0x6f, 0x8e, 0x64, 0xba, 0xea, 0x21, 0xfa, 0x19, 0xdb, 0x88, 0x0, 0x11, 0xb8, 0x1e, 0x32, 0xaf, 0x24, 0x9, 0x2e, 0x59, 0xb0, 0x43, 0x36, 0x8b, 0x2e, 0xbc, 0xd1, 0xd0, 0xc7}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x9a, 0x28, 0x15, 0xbb, 0xd1, 0x92, 0x79, 0xfc, 0x46, 0x6, 0x6f, 0x8f, 0x9d, 0xe5, 0xd9, 0x7b, 0xae, 0x90, 0x8d, 0x7b, 0xe0}; + uint8_t bytesprops1[] = {0xb9, 0x2f, 0xa3, 0xec, 0xfc}; + uint8_t bytesprops2[] = {0x81, 0xf5, 0x4, 0xf0, 0x2, 0xe, 0x8a, 0x85}; + uint8_t bytesprops3[] = {0xb2, 0x70, 0xb9, 0x50, 0x93, 0x93, 0x3a, 0x4c, 0xd, 0x99, 0x98, 0x5b, 0xe0, 0xc9, 0x7e, 0xbb, 0x5}; + uint8_t bytesprops4[] = {0x82, 0x90, 0x14, 0x18, 0x1f, 0xf7, 0x30, 0x23, 0x24, 0x35, 0xd9, 0x85, 0xcc, 0x37, 0x9b, 0x8d, 0x61, 0x39, 0x10, 0xb, 0x74, 0x34}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21621}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10685}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31891}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30900}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8778}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16802}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25543}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22717}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6182}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26231}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10906}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 32}}, + }; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops1[] = {0xd5, 0x7f, 0x7d, 0x6b, 0x4f, 0x7f, 0x92}; + uint8_t byteswillprops2[] = {0x18, 0x2d, 0xe2, 0x40, 0x79, 0x22, 0x18, 0x3a, 0xf8, 0xb7, 0x5b, 0x44, 0x8e, 0xcc, 0x9c, 0x92, 0x55, 0x71, 0x63, 0x57, 0xbb, 0xc2, 0x79, 0xa6, 0x5f}; + uint8_t byteswillprops4[] = {0x72, 0xe8, 0xa7, 0x3d, 0x34, 0xea, 0x34, 0x4b, 0x77, 0x44, 0xea, 0xa5, 0xd, 0x66, 0xf9, 0xe2, 0x64, 0x3, 0x7d, 0xb2, 0x2, 0xfa, 0xdc, 0x56, 0xd5, 0x16}; + uint8_t byteswillprops3[] = {0xd7, 0x6f, 0x22, 0xe0}; + uint8_t byteswillprops5[] = {0x67, 0xa3, 0x87, 0x9d, 0x84, 0x88, 0x63, 0xe7}; + uint8_t byteswillprops6[] = {0}; + uint8_t byteswillprops7[] = {0xab, 0x97, 0x53, 0x93, 0x1f, 0xab, 0x86, 0x96, 0xc8, 0x18, 0x3f, 0x4a, 0x8e, 0x66, 0xaf, 0xa, 0xa2, 0x4f}; + uint8_t byteswillprops8[] = {0xba, 0x25, 0x5d, 0x11, 0x0, 0xd2, 0x63, 0xf8, 0xf, 0x67, 0x46, 0x4f, 0x65, 0x13, 0x14, 0x86, 0x61, 0x10}; + uint8_t byteswillprops9[] = {0x82, 0x26, 0xc1, 0xbc, 0x6b, 0x96, 0x79, 0x8d, 0xc6, 0x7e, 0xc4, 0x2b}; + uint8_t byteswillprops10[] = {0}; + uint8_t byteswillprops11[] = {0x64, 0x65, 0xd6, 0x4f, 0x52, 0x8b, 0xf9}; + uint8_t byteswillprops12[] = {0x6a, 0x4f}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4624}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2189}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={4, (char*)&byteswillprops3}, .v={26, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16445}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10243}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21568}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3075}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14729}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21067}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2475}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&byteswillprops12}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6987}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7409}}, }; - lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4b, 0x59, 0xf2}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5d, 0xa9, 0x9e, 0xb7, 0xdf, 0xb5, 0x4c, 0x99, 0x78, - 0x6c, 0x64, 0xf, 0xf, 0x9b, 0x36, 0xd3, 0xef}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 18195; - uint8_t client_id_bytes[] = {0x76, 0x84, 0xb, 0x36, 0xd, 0xa4, 0xf1, 0x31, 0x56, 0x55, - 0x66, 0xef, 0x1d, 0xd2, 0xc9, 0x21, 0x9e, 0xf0, 0x37, 0xc2}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x5a, 0x59, 0x2a, 0xd4, 0x32, 0x76, 0x18, 0xee, 0x16, 0xf3, 0x5a, 0x2d, 0xd2, 0x7a, 0xe, - 0xe5, 0x58, 0xa4, 0x60, 0x88, 0x20, 0x17, 0xf6, 0xb6, 0x7a, 0x77, 0x7d, 0x30, 0x94, 0xb}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x96, 0x32, 0x62, 0x29}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x6b, 0x5f, 0x68, 0x75, 0x6e, 0xd8, 0xd1, 0xd4, 0xdb, 0x25, 0xc1, 0x15, 0x5b, 0xaf, 0xfa, 0xe8, 0x2, 0xd6, 0xc4, 0x29, 0x1, 0x87, 0xe, 0x9}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd8, 0xc1, 0x4a, 0xf2, 0x4a, 0xd7, 0x8, 0xa6, 0x1c, 0xb5, 0x2c, 0x75, 0xf6, 0x57, 0x26, 0x80, 0xf5, 0x2, 0x62, 0x6f, 0x8e, 0x64, 0xba, 0xea, 0x21, 0xfa, 0x19, 0xdb, 0x88}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 12402; + uint8_t client_id_bytes[] = {0x9d, 0x14, 0xe4, 0x3d, 0x6b, 0x10, 0x35, 0x4e, 0xab, 0xb, 0x2b, 0xb9, 0xe3}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xb8, 0x1e, 0x32, 0xaf, 0x24, 0x9, 0x2e, 0x59, 0xb0, 0x43, 0x36, 0x8b, 0x2e, 0xbc, 0xd1, 0xd0, 0xc7}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\STXjT\248\ACK\158\156\227\216x\233}\DC4q\198\140ca\207\230", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "_\192D\194~\218adY0\244u\190og1\210Y\200", _willMsg = "\188\&4\154k=\225N", _willProps = [PropMaximumPacketSize -// 19884,PropWildcardSubscriptionAvailable 196,PropWildcardSubscriptionAvailable 154,PropAuthenticationData -// "\130\251\240\DC3\153M@\ACK\155\ESC@o9\224;3c\248X",PropResponseTopic "@\245\178\196U\228\169L*\217\163\ACK\240"]}), -// _cleanSession = True, _keepAlive = 16867, _connID = "h\ETX\237n0\202\ETX/\213\ESC\174\136'\218lQ\144\n\175\151\132", -// _properties = [PropResponseTopic "\193\167\185\189\222`\151Q", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS2, _willTopic = "\219\242^+:\f\EOT\173\175\&1\CAN\171\&8", _willMsg = -// "\172\220\161\161W~?%", _willProps = [PropPayloadFormatIndicator 66,PropTopicAlias 14799,PropReasonString -// "\DLE\198\234\232\141Q\171\186\225p3\US\EOT\182W\251\&3",PropServerKeepAlive 16361,PropAuthenticationMethod -// "\160\237\149\220ft\158\250S1\129\137\208\US\171[\SI\155\DLE\230",PropReasonString "",PropMaximumQoS -// 138,PropTopicAlias 19777,PropResponseInformation "\SUB\150\168xS\235\\\243\STX\n\ENQ\nf\STX\144\205\237H"]}), -// _cleanSession = False, _keepAlive = 9252, _connID = -// "\175\167p\FS\238\ni\164\&3*\183\243\186\129\SO\153{\225\138\236\216\213${|P^\248\148\128", _properties = -// [PropTopicAliasMaximum 7582,PropSessionExpiryInterval 9069,PropReasonString -// "\244\141\154\244\&4J?s\152\128\163\178\219\247\222\DLEk7\174\137s",PropSessionExpiryInterval -// 31866,PropAssignedClientIdentifier -// "\246Tu?9\161Bf\137]U\227x\FS,\"\226\205\&8f\213\FS\177\240<",PropMaximumPacketSize 18917,PropSubscriptionIdentifier -// 22,PropSharedSubscriptionAvailable 227,PropReasonString -// "R\ENQ\r\226\228/C\191\ETB\205\247\188\234+\146\202?",PropSubscriptionIdentifierAvailable -// 5,PropRequestResponseInformation 40,PropMessageExpiryInterval 32403,PropServerReference -// "\129LQ\129\218\230\ESC\165\"\191\226\179S\232\&8mj\EM`]hM\187]\CAN\226\DC4\228\234\249",PropReasonString -// "\217&\205\239n\NAK\EME \140J\148K",PropServerKeepAlive 23,PropRetainAvailable 128,PropSharedSubscriptionAvailable -// 203,PropRetainAvailable 242,PropUserProperty -// "o\"\157\151\199j\170W\145\229\145qK\FS\v\210w<\NAK\169\248z8\143\134\142K" "\166)QvC\215\\L\181\197\236\f\182\223"]} -TEST(Connect5QCTest, Encode7) { - uint8_t pkt[] = { - 0x10, 0x92, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x24, 0x24, 0xcf, 0x1, 0x22, 0x1d, 0x9e, 0x11, - 0x0, 0x0, 0x23, 0x6d, 0x1f, 0x0, 0x15, 0xf4, 0x8d, 0x9a, 0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 0xbd, 0xde, 0x60, 0x97, 0x51}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf4, 0x8d, 0x9a, 0xf4, 0x34, 0x4a, 0x3f, 0x73, 0x98, 0x80, 0xa3, - 0xb2, 0xdb, 0xf7, 0xde, 0x10, 0x6b, 0x37, 0xae, 0x89, 0x73}; - uint8_t bytesprops1[] = {0xf6, 0x54, 0x75, 0x3f, 0x39, 0xa1, 0x42, 0x66, 0x89, 0x5d, 0x55, 0xe3, 0x78, - 0x1c, 0x2c, 0x22, 0xe2, 0xcd, 0x38, 0x66, 0xd5, 0x1c, 0xb1, 0xf0, 0x3c}; - uint8_t bytesprops2[] = {0x52, 0x5, 0xd, 0xe2, 0xe4, 0x2f, 0x43, 0xbf, 0x17, - 0xcd, 0xf7, 0xbc, 0xea, 0x2b, 0x92, 0xca, 0x3f}; - uint8_t bytesprops3[] = {0x81, 0x4c, 0x51, 0x81, 0xda, 0xe6, 0x1b, 0xa5, 0x22, 0xbf, 0xe2, 0xb3, 0x53, 0xe8, 0x38, - 0x6d, 0x6a, 0x19, 0x60, 0x5d, 0x68, 0x4d, 0xbb, 0x5d, 0x18, 0xe2, 0x14, 0xe4, 0xea, 0xf9}; - uint8_t bytesprops4[] = {0xd9, 0x26, 0xcd, 0xef, 0x6e, 0x15, 0x19, 0x45, 0x20, 0x8c, 0x4a, 0x94, 0x4b}; - uint8_t bytesprops6[] = {0xa6, 0x29, 0x51, 0x76, 0x43, 0xd7, 0x5c, 0x4c, 0xb5, 0xc5, 0xec, 0xc, 0xb6, 0xdf}; - uint8_t bytesprops5[] = {0x6f, 0x22, 0x9d, 0x97, 0xc7, 0x6a, 0xaa, 0x57, 0x91, 0xe5, 0x91, 0x71, 0x4b, 0x1c, - 0xb, 0xd2, 0x77, 0x3c, 0x15, 0xa9, 0xf8, 0x7a, 0x38, 0x8f, 0x86, 0x8e, 0x4b}; +// ConnectRequest {_username = Nothing, _password = Just "A\ESC'\139\188\167\DEL0\247\183\225\230dn1\207\&4a+\229#\149s\233\178Lz\188B", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "1\210\DC3\DC47O", _willMsg = "M\176\215\\\188\144\&2\213\199\175\GS", _willProps = [PropMessageExpiryInterval 361,PropSubscriptionIdentifier 6,PropSubscriptionIdentifier 2,PropMessageExpiryInterval 19895,PropAuthenticationData "\SI_\168\181n\245\154%L",PropTopicAliasMaximum 1020]}), _cleanSession = False, _keepAlive = 26060, _connID = "'M\238\158*c\NUL\197&]T\231\237\226\255e=\SUB]&\188\246", _properties = [PropWillDelayInterval 11494,PropAssignedClientIdentifier ",/\244\&5\ENQ\132\247\241\134\177w\SUBT\255p\SI!\t\212]\131U",PropMessageExpiryInterval 30996,PropAuthenticationData "m':\SI:\142$",PropRequestResponseInformation 238,PropSubscriptionIdentifier 30,PropRequestResponseInformation 236,PropTopicAliasMaximum 14621,PropSharedSubscriptionAvailable 236,PropMessageExpiryInterval 1407,PropMessageExpiryInterval 30953,PropSessionExpiryInterval 968,PropMaximumQoS 254,PropContentType "\237\159X!\201\EOT\r\130Ml#\a*e\249\148\227m\248\ENQ\250\188\242:d\235\181\243j",PropTopicAlias 28456,PropAuthenticationData "<",PropRequestResponseInformation 12,PropSessionExpiryInterval 13244,PropRequestResponseInformation 44,PropTopicAliasMaximum 10093,PropAuthenticationMethod "|\235\"\144\&5\180\201\&6ra\159r\199A(Gol.\GS",PropSessionExpiryInterval 31640,PropMaximumQoS 21,PropMaximumPacketSize 27543]} +TEST(Connect5QCTest, Encode9) { +uint8_t pkt[] = {0x10, 0x95, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x74, 0x65, 0xcc, 0x9f, 0x1, 0x18, 0x0, 0x0, 0x2c, 0xe6, 0x12, 0x0, 0x16, 0x2c, 0x2f, 0xf4, 0x35, 0x5, 0x84, 0xf7, 0xf1, 0x86, 0xb1, 0x77, 0x1a, 0x54, 0xff, 0x70, 0xf, 0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 0x31, 0xd2, 0x13, 0x14, 0x37, 0x4f, 0x0, 0xb, 0x4d, 0xb0, 0xd7, 0x5c, 0xbc, 0x90, 0x32, 0xd5, 0xc7, 0xaf, 0x1d, 0x0, 0x1d, 0x41, 0x1b, 0x27, 0x8b, 0xbc, 0xa7, 0x7f, 0x30, 0xf7, 0xb7, 0xe1, 0xe6, 0x64, 0x6e, 0x31, 0xcf, 0x34, 0x61, 0x2b, 0xe5, 0x23, 0x95, 0x73, 0xe9, 0xb2, 0x4c, 0x7a, 0xbc, 0x42}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x2c, 0x2f, 0xf4, 0x35, 0x5, 0x84, 0xf7, 0xf1, 0x86, 0xb1, 0x77, 0x1a, 0x54, 0xff, 0x70, 0xf, 0x21, 0x9, 0xd4, 0x5d, 0x83, 0x55}; + uint8_t bytesprops1[] = {0x6d, 0x27, 0x3a, 0xf, 0x3a, 0x8e, 0x24}; + uint8_t bytesprops2[] = {0xed, 0x9f, 0x58, 0x21, 0xc9, 0x4, 0xd, 0x82, 0x4d, 0x6c, 0x23, 0x7, 0x2a, 0x65, 0xf9, 0x94, 0xe3, 0x6d, 0xf8, 0x5, 0xfa, 0xbc, 0xf2, 0x3a, 0x64, 0xeb, 0xb5, 0xf3, 0x6a}; + uint8_t bytesprops3[] = {0x3c}; + uint8_t bytesprops4[] = {0x7c, 0xeb, 0x22, 0x90, 0x35, 0xb4, 0xc9, 0x36, 0x72, 0x61, 0x9f, 0x72, 0xc7, 0x41, 0x28, 0x47, 0x6f, 0x6c, 0x2e, 0x1d}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7582}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9069}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31866}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18917}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32403}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops5}, .v = {14, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11494}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30996}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14621}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1407}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30953}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 968}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28456}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13244}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10093}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31640}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27543}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x10, 0xc6, 0xea, 0xe8, 0x8d, 0x51, 0xab, 0xba, 0xe1, - 0x70, 0x33, 0x1f, 0x4, 0xb6, 0x57, 0xfb, 0x33}; - uint8_t byteswillprops1[] = {0xa0, 0xed, 0x95, 0xdc, 0x66, 0x74, 0x9e, 0xfa, 0x53, 0x31, - 0x81, 0x89, 0xd0, 0x1f, 0xab, 0x5b, 0xf, 0x9b, 0x10, 0xe6}; - uint8_t byteswillprops2[] = {0}; - uint8_t byteswillprops3[] = {0x1a, 0x96, 0xa8, 0x78, 0x53, 0xeb, 0x5c, 0xf3, 0x2, - 0xa, 0x5, 0xa, 0x66, 0x2, 0x90, 0xcd, 0xed, 0x48}; - + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xf, 0x5f, 0xa8, 0xb5, 0x6e, 0xf5, 0x9a, 0x25, 0x4c}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14799}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16361}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19777}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops3}}}, - }; - - lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xdb, 0xf2, 0x5e, 0x2b, 0x3a, 0xc, 0x4, 0xad, 0xaf, 0x31, 0x18, 0xab, 0x38}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xac, 0xdc, 0xa1, 0xa1, 0x57, 0x7e, 0x3f, 0x25}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 9252; - uint8_t client_id_bytes[] = {0xaf, 0xa7, 0x70, 0x1c, 0xee, 0xa, 0x69, 0xa4, 0x33, 0x2a, - 0xb7, 0xf3, 0xba, 0x81, 0xe, 0x99, 0x7b, 0xe1, 0x8a, 0xec, - 0xd8, 0xd5, 0x24, 0x7b, 0x7c, 0x50, 0x5e, 0xf8, 0x94, 0x80}; - lwmqtt_string_t client_id = {30, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x19, 0x9f, 0x19, 0x0, 0x14, 0x5c, 0x2c, 0x8c, 0x6d, 0x6d, 0x47, 0x6c, 0xa2, 0xbb, 0xde}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x18, 0xf9, 0x92, 0x66, 0x48, 0x16, 0xa1, 0x1f, 0x9a, 0xad, 0xf3, 0xb1, 0xf0, - 0xd4, 0x6b, 0xcb, 0xdb, 0x3e, 0xc1, 0xa7, 0xb9, 0xbd, 0xde, 0x60, 0x97, 0x51}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\132Jc\237#\175s\149\208\140\v\175\198\197@bE\255\177&4\223%%\194\229\ETB", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "_B\130\238\164\ACK\246/\243\243\182\&9h\219Dp\161E\201n(\130u", _willMsg = -// "L\ETX\226\236\158\CAN3\190\221\140\156\129Mj\211\ACKv+\USU\197e\219\EM\135\221\145", _willProps = -// [PropSubscriptionIdentifier 29]}), _cleanSession = False, _keepAlive = 23111, _connID = -// "\128'\168\a\165\214u\"VvPa\154y\236\ETB\165ng\208\175\233\198\234\235\a", _properties = -// [PropRequestResponseInformation 158,PropMaximumQoS 125,PropSharedSubscriptionAvailable 112,PropWillDelayInterval -// 4423,PropAuthenticationData "\171uy\199H{:\189",PropReasonString -// "%\168\209\RSLiy\NAK\242C\SO\rj\ENQ\237ln\148d\237",PropUserProperty -// "c\ACK\165\226\165}\198\253!\144\ENQ2\184R\180V\\\247P\227\189" -// "\134Gw\161\202\160U'\\Vw\138AJc",PropRequestResponseInformation 60,PropMessageExpiryInterval 8943,PropTopicAlias -// 6044,PropMaximumQoS 9,PropServerKeepAlive 982,PropSharedSubscriptionAvailable 31,PropWillDelayInterval -// 9182,PropReceiveMaximum 29774,PropSessionExpiryInterval 32009,PropServerKeepAlive 32136,PropMessageExpiryInterval -// 26395,PropMaximumQoS 5]} -TEST(Connect5QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0xfb, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb4, 0x5a, 0x47, 0x7e, 0x19, 0x9e, 0x24, - 0x7d, 0x2a, 0x70, 0x18, 0x0, 0x0, 0x11, 0x47, 0x16, 0x0, 0x8, 0xab, 0x75, 0x79, 0xc7, 0x48, 0x7b, - 0x3a, 0xbd, 0x1f, 0x0, 0x14, 0x25, 0xa8, 0xd1, 0x1e, 0x4c, 0x69, 0x79, 0x15, 0xf2, 0x43, 0xe, 0xd, - 0x6a, 0x5, 0xed, 0x6c, 0x6e, 0x94, 0x64, 0xed, 0x26, 0x0, 0x15, 0x63, 0x6, 0xa5, 0xe2, 0xa5, 0x7d, - 0xc6, 0xfd, 0x21, 0x90, 0x5, 0x32, 0xb8, 0x52, 0xb4, 0x56, 0x5c, 0xf7, 0x50, 0xe3, 0xbd, 0x0, 0xf, - 0x86, 0x47, 0x77, 0xa1, 0xca, 0xa0, 0x55, 0x27, 0x5c, 0x56, 0x77, 0x8a, 0x41, 0x4a, 0x63, 0x19, 0x3c, - 0x2, 0x0, 0x0, 0x22, 0xef, 0x23, 0x17, 0x9c, 0x24, 0x9, 0x13, 0x3, 0xd6, 0x2a, 0x1f, 0x18, 0x0, - 0x0, 0x23, 0xde, 0x21, 0x74, 0x4e, 0x11, 0x0, 0x0, 0x7d, 0x9, 0x13, 0x7d, 0x88, 0x2, 0x0, 0x0, - 0x67, 0x1b, 0x24, 0x5, 0x0, 0x1a, 0x80, 0x27, 0xa8, 0x7, 0xa5, 0xd6, 0x75, 0x22, 0x56, 0x76, 0x50, - 0x61, 0x9a, 0x79, 0xec, 0x17, 0xa5, 0x6e, 0x67, 0xd0, 0xaf, 0xe9, 0xc6, 0xea, 0xeb, 0x7, 0x2, 0xb, - 0x1d, 0x0, 0x17, 0x5f, 0x42, 0x82, 0xee, 0xa4, 0x6, 0xf6, 0x2f, 0xf3, 0xf3, 0xb6, 0x39, 0x68, 0xdb, - 0x44, 0x70, 0xa1, 0x45, 0xc9, 0x6e, 0x28, 0x82, 0x75, 0x0, 0x1b, 0x4c, 0x3, 0xe2, 0xec, 0x9e, 0x18, - 0x33, 0xbe, 0xdd, 0x8c, 0x9c, 0x81, 0x4d, 0x6a, 0xd3, 0x6, 0x76, 0x2b, 0x1f, 0x55, 0xc5, 0x65, 0xdb, - 0x19, 0x87, 0xdd, 0x91, 0x0, 0x1b, 0x84, 0x4a, 0x63, 0xed, 0x23, 0xaf, 0x73, 0x95, 0xd0, 0x8c, 0xb, - 0xaf, 0xc6, 0xc5, 0x40, 0x62, 0x45, 0xff, 0xb1, 0x26, 0x34, 0xdf, 0x25, 0x25, 0xc2, 0xe5, 0x17}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xab, 0x75, 0x79, 0xc7, 0x48, 0x7b, 0x3a, 0xbd}; - uint8_t bytesprops1[] = {0x25, 0xa8, 0xd1, 0x1e, 0x4c, 0x69, 0x79, 0x15, 0xf2, 0x43, - 0xe, 0xd, 0x6a, 0x5, 0xed, 0x6c, 0x6e, 0x94, 0x64, 0xed}; - uint8_t bytesprops3[] = {0x86, 0x47, 0x77, 0xa1, 0xca, 0xa0, 0x55, 0x27, 0x5c, 0x56, 0x77, 0x8a, 0x41, 0x4a, 0x63}; - uint8_t bytesprops2[] = {0x63, 0x6, 0xa5, 0xe2, 0xa5, 0x7d, 0xc6, 0xfd, 0x21, 0x90, 0x5, - 0x32, 0xb8, 0x52, 0xb4, 0x56, 0x5c, 0xf7, 0x50, 0xe3, 0xbd}; + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 361}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19895}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1020}}, + }; + lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x31, 0xd2, 0x13, 0x14, 0x37, 0x4f}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4d, 0xb0, 0xd7, 0x5c, 0xbc, 0x90, 0x32, 0xd5, 0xc7, 0xaf, 0x1d}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 26060; + uint8_t client_id_bytes[] = {0x27, 0x4d, 0xee, 0x9e, 0x2a, 0x63, 0x0, 0xc5, 0x26, 0x5d, 0x54, 0xe7, 0xed, 0xe2, 0xff, 0x65, 0x3d, 0x1a, 0x5d, 0x26, 0xbc, 0xf6}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x41, 0x1b, 0x27, 0x8b, 0xbc, 0xa7, 0x7f, 0x30, 0xf7, 0xb7, 0xe1, 0xe6, 0x64, 0x6e, 0x31, 0xcf, 0x34, 0x61, 0x2b, 0xe5, 0x23, 0x95, 0x73, 0xe9, 0xb2, 0x4c, 0x7a, 0xbc, 0x42}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// ConnectRequest {_username = Just "\203\215'q\192;\253\158\131\"\185\255\168\f\227", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\DC3]\143\242\EOT8\146", _willMsg = "\230\207C'/^Ln\SOH\ACK\239\208\&6\227\162B~\222\142", _willProps = [PropWillDelayInterval 17500,PropRequestResponseInformation 248,PropRetainAvailable 9,PropWildcardSubscriptionAvailable 55,PropMessageExpiryInterval 31929,PropSubscriptionIdentifierAvailable 9,PropRequestProblemInformation 73,PropResponseInformation "J\176]\182\141\ng\175\165\170\191\DEL\179\177\208>IH\r\201\182z\132\150\142\228",PropRetainAvailable 202,PropReceiveMaximum 14731,PropTopicAlias 17969,PropRetainAvailable 131,PropReasonString "\178",PropTopicAlias 22210,PropAuthenticationData "\216\&88\168tf",PropSubscriptionIdentifierAvailable 158]}), _cleanSession = False, _keepAlive = 18009, _connID = "\223\157;e\ACKs*\NUL\134N\151K\212g\170", _properties = [PropReceiveMaximum 1627,PropReasonString "X\161\197!\DC2?\214FK \195W~\199'b",PropServerReference "\US\135\141Xj\ESC\NUL\169\155\161*\143\156\177)\158> \148\DC4\173N\139\197\189B\198\170T",PropMaximumPacketSize 23850,PropSharedSubscriptionAvailable 158,PropMaximumQoS 85,PropServerKeepAlive 3440,PropResponseTopic "\134]\241\ENQ\243\&1\180l+\137\132\220\FSQ\243tky\EOTD@\216m\134Z<`\255G\149",PropSubscriptionIdentifier 7,PropMessageExpiryInterval 9423,PropSubscriptionIdentifier 16,PropMaximumPacketSize 31638,PropWildcardSubscriptionAvailable 226,PropServerReference "\145\128\137\173h\DC1s\129\251\210\184",PropReceiveMaximum 29008,PropMaximumPacketSize 9586,PropTopicAlias 11288,PropSubscriptionIdentifier 25,PropTopicAliasMaximum 16372,PropAuthenticationMethod "A\187\EOT\132\169]\244\205",PropWildcardSubscriptionAvailable 83]} +TEST(Connect5QCTest, Encode10)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xd4, 0x67, 0xaa, 0x4d, 0x18, 0x0, 0x0, 0x44, 0x5c, 0x19, 0xf8, 0x25, 0x9, 0x28, 0x37, 0x2, 0x0, 0x0, 0x7c, 0xb9, 0x29, 0x9, 0x17, 0x49, 0x1a, 0x0, 0x1a, 0x4a, 0xb0, 0x5d, 0xb6, 0x8d, 0xa, 0x67, 0xaf, 0xa5, 0xaa, 0xbf, 0x7f, 0xb3, 0xb1, 0xd0, 0x3e, 0x49, 0x48, 0xd, 0xc9, 0xb6, 0x7a, 0x84, 0x96, 0x8e, 0xe4, 0x25, 0xca, 0x21, 0x39, 0x8b, 0x23, 0x46, 0x31, 0x25, 0x83, 0x1f, 0x0, 0x1, 0xb2, 0x23, 0x56, 0xc2, 0x16, 0x0, 0x6, 0xd8, 0x38, 0x38, 0xa8, 0x74, 0x66, 0x29, 0x9e, 0x0, 0x7, 0x13, 0x5d, 0x8f, 0xf2, 0x4, 0x38, 0x92, 0x0, 0x13, 0xe6, 0xcf, 0x43, 0x27, 0x2f, 0x5e, 0x4c, 0x6e, 0x1, 0x6, 0xef, 0xd0, 0x36, 0xe3, 0xa2, 0x42, 0x7e, 0xde, 0x8e, 0x0, 0xf, 0xcb, 0xd7, 0x27, 0x71, 0xc0, 0x3b, 0xfd, 0x9e, 0x83, 0x22, 0xb9, 0xff, 0xa8, 0xc, 0xe3}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x58, 0xa1, 0xc5, 0x21, 0x12, 0x3f, 0xd6, 0x46, 0x4b, 0x20, 0xc3, 0x57, 0x7e, 0xc7, 0x27, 0x62}; + uint8_t bytesprops1[] = {0x1f, 0x87, 0x8d, 0x58, 0x6a, 0x1b, 0x0, 0xa9, 0x9b, 0xa1, 0x2a, 0x8f, 0x9c, 0xb1, 0x29, 0x9e, 0x3e, 0x20, 0x94, 0x14, 0xad, 0x4e, 0x8b, 0xc5, 0xbd, 0x42, 0xc6, 0xaa, 0x54}; + uint8_t bytesprops2[] = {0x86, 0x5d, 0xf1, 0x5, 0xf3, 0x31, 0xb4, 0x6c, 0x2b, 0x89, 0x84, 0xdc, 0x1c, 0x51, 0xf3, 0x74, 0x6b, 0x79, 0x4, 0x44, 0x40, 0xd8, 0x6d, 0x86, 0x5a, 0x3c, 0x60, 0xff, 0x47, 0x95}; + uint8_t bytesprops3[] = {0x91, 0x80, 0x89, 0xad, 0x68, 0x11, 0x73, 0x81, 0xfb, 0xd2, 0xb8}; + uint8_t bytesprops4[] = {0x41, 0xbb, 0x4, 0x84, 0xa9, 0x5d, 0xf4, 0xcd}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4423}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {15, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8943}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6044}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 982}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9182}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29774}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32009}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32136}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26395}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1627}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23850}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3440}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9423}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31638}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29008}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9586}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11288}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16372}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 83}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x4a, 0xb0, 0x5d, 0xb6, 0x8d, 0xa, 0x67, 0xaf, 0xa5, 0xaa, 0xbf, 0x7f, 0xb3, 0xb1, 0xd0, 0x3e, 0x49, 0x48, 0xd, 0xc9, 0xb6, 0x7a, 0x84, 0x96, 0x8e, 0xe4}; + uint8_t byteswillprops1[] = {0xb2}; + uint8_t byteswillprops2[] = {0xd8, 0x38, 0x38, 0xa8, 0x74, 0x66}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17500}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31929}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14731}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17969}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22210}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, }; - lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5f, 0x42, 0x82, 0xee, 0xa4, 0x6, 0xf6, 0x2f, 0xf3, 0xf3, 0xb6, 0x39, - 0x68, 0xdb, 0x44, 0x70, 0xa1, 0x45, 0xc9, 0x6e, 0x28, 0x82, 0x75}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4c, 0x3, 0xe2, 0xec, 0x9e, 0x18, 0x33, 0xbe, 0xdd, 0x8c, 0x9c, 0x81, 0x4d, 0x6a, - 0xd3, 0x6, 0x76, 0x2b, 0x1f, 0x55, 0xc5, 0x65, 0xdb, 0x19, 0x87, 0xdd, 0x91}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 23111; - uint8_t client_id_bytes[] = {0x80, 0x27, 0xa8, 0x7, 0xa5, 0xd6, 0x75, 0x22, 0x56, 0x76, 0x50, 0x61, 0x9a, - 0x79, 0xec, 0x17, 0xa5, 0x6e, 0x67, 0xd0, 0xaf, 0xe9, 0xc6, 0xea, 0xeb, 0x7}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x84, 0x4a, 0x63, 0xed, 0x23, 0xaf, 0x73, 0x95, 0xd0, 0x8c, 0xb, 0xaf, 0xc6, 0xc5, - 0x40, 0x62, 0x45, 0xff, 0xb1, 0x26, 0x34, 0xdf, 0x25, 0x25, 0xc2, 0xe5, 0x17}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x13, 0x5d, 0x8f, 0xf2, 0x4, 0x38, 0x92}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe6, 0xcf, 0x43, 0x27, 0x2f, 0x5e, 0x4c, 0x6e, 0x1, 0x6, 0xef, 0xd0, 0x36, 0xe3, 0xa2, 0x42, 0x7e, 0xde, 0x8e}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 18009; + uint8_t client_id_bytes[] = {0xdf, 0x9d, 0x3b, 0x65, 0x6, 0x73, 0x2a, 0x0, 0x86, 0x4e, 0x97, 0x4b, 0xd4, 0x67, 0xaa}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xcb, 0xd7, 0x27, 0x71, 0xc0, 0x3b, 0xfd, 0x9e, 0x83, 0x22, 0xb9, 0xff, 0xa8, 0xc, 0xe3}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\131)o", _password = Just "Y^ \171\220\234\182Th\NAK", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\SOHw\DC4\149\&5\197\t\RS\188\166\DLE\179", _willMsg = -// "L\173#e?~\241<", _willProps = [PropSessionExpiryInterval 7110,PropServerKeepAlive 24305,PropRetainAvailable -// 101,PropPayloadFormatIndicator 38,PropTopicAlias 22823,PropSubscriptionIdentifierAvailable 67,PropReasonString -// "\192\149\203\184\132\196\144\243\157J\164",PropSubscriptionIdentifier 21,PropResponseInformation -// "\NAK\186\220\217\220\163'\221",PropCorrelationData "\DLER5\185+",PropRequestResponseInformation -// 195,PropRetainAvailable 227,PropPayloadFormatIndicator 155,PropMessageExpiryInterval 26025,PropAuthenticationMethod -// "\160\153\184\173\252\195\209\ENQ\171u\SYN",PropResponseTopic -// "\192\198\129uw\235\226\227\&06\140&\183\&71F\131\239\SUB\158\DLE\187m",PropReceiveMaximum -// 25372,PropTopicAliasMaximum 16172,PropServerKeepAlive 18593,PropAuthenticationData -// "\ACK\208\166dD=fT\232\180|\252^\209\181W\141\149\GS-F4b\247\EM\n\228",PropMaximumPacketSize 16566,PropPayloadFormatIndicator 169,PropPayloadFormatIndicator 237,PropAuthenticationData "\205\ESC\182N\221g.\ACK\155\143\221!}XZW\222\219\249\158=\176F1",PropSubscriptionIdentifierAvailable 210,PropServerKeepAlive 7363,PropWillDelayInterval 406,PropServerReference "Gc\rt\190\198\rv\184\245\SI\145C\NUL\240\219\SOj\230",PropSessionExpiryInterval 26332,PropResponseTopic "\226z\145r\204\214K\173\216\234H06",PropAuthenticationData "x\210\209C\129\r`\132",PropServerKeepAlive 16373,PropMaximumQoS 223,PropMaximumQoS 215,PropMessageExpiryInterval 12607,PropRetainAvailable 161,PropRequestProblemInformation 185]} +TEST(Connect5QCTest, Encode11) { +uint8_t pkt[] = {0x10, 0xaf, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6e, 0x74, 0xea, 0xa7, 0x1, 0x3, 0x0, 0x5, 0x77, 0x4b, 0xcf, 0x5f, 0x40, 0x2, 0x0, 0x0, 0x5c, 0x9b, 0xb, 0x19, 0x2, 0x0, 0x0, 0x7f, 0xad, 0x29, 0x2d, 0x1a, 0x0, 0x1a, 0xa0, 0x3e, 0x64, 0x44, 0x3d, 0x66, 0x54, 0xe8, 0xb4, 0x7c, 0xfc, 0x5e, 0xd1, 0xb5, 0x57, 0x8d, 0x95, 0x1d, 0x2d, 0x46, 0x34, 0x62, 0xf7, 0x19, 0xa, 0xe4, 0x27, 0x0, 0x0, 0x40, 0xb6, 0x1, 0xa9, 0x1, 0xed, 0x16, 0x0, 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, 0xfa, 0xa6, 0x8f, 0x64, 0x74, 0x7a, 0xb, 0xe, 0x0, 0x10, 0xb9, 0xa4, 0xc9, 0xda, 0x9, 0x1e, 0x8a, 0x77, 0x34, 0xed, 0x96, 0x4f, 0xbc, 0x7a, 0x7d, 0x57, 0x0, 0x5, 0x3c, 0xc3, 0xa7, 0x1c, 0x57, 0x0, 0x4, 0x1, 0xa9, 0x95, 0x58}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x77, 0x4b, 0xcf, 0x5f, 0x40}; + uint8_t bytesprops1[] = {0xa0, 0x3e, 0x64, 0x44, 0x3d, 0x66, 0x54, 0xe8, 0xb4, 0x7c, 0xfc, 0x5e, 0xd1, 0xb5, 0x57, 0x8d, 0x95, 0x1d, 0x2d, 0x46, 0x34, 0x62, 0xf7, 0x19, 0xa, 0xe4}; + uint8_t bytesprops2[] = {0xcd, 0x1b, 0xb6, 0x4e, 0xdd, 0x67, 0x2e, 0x6, 0x9b, 0x8f, 0xdd, 0x21, 0x7d, 0x58, 0x5a, 0x57, 0xde, 0xdb, 0xf9, 0x9e, 0x3d, 0xb0, 0x46, 0x31}; + uint8_t bytesprops3[] = {0x47, 0x63, 0xd, 0x74, 0xbe, 0xc6, 0xd, 0x76, 0xb8, 0xf5, 0xf, 0x91, 0x43, 0x0, 0xf0, 0xdb, 0xe, 0x6a, 0xe6}; + uint8_t bytesprops4[] = {0xe2, 0x7a, 0x91, 0x72, 0xcc, 0xd6, 0x4b, 0xad, 0xd8, 0xea, 0x48, 0x30, 0x36}; + uint8_t bytesprops5[] = {0x78, 0xd2, 0xd1, 0x43, 0x81, 0xd, 0x60, 0x84}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28951}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19994}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17366}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4974}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23518}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2025}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6285}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2907}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23707}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32685}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16566}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7363}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 406}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26332}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16373}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12607}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 185}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc0, 0x95, 0xcb, 0xb8, 0x84, 0xc4, 0x90, 0xf3, 0x9d, 0x4a, 0xa4}; - uint8_t byteswillprops1[] = {0x15, 0xba, 0xdc, 0xd9, 0xdc, 0xa3, 0x27, 0xdd}; - uint8_t byteswillprops2[] = {0x10, 0x52, 0x35, 0xb9, 0x2b}; - uint8_t byteswillprops3[] = {0xa0, 0x99, 0xb8, 0xad, 0xfc, 0xc3, 0xd1, 0x5, 0xab, 0x75, 0x16}; - uint8_t byteswillprops4[] = {0xc0, 0xc6, 0x81, 0x75, 0x77, 0xeb, 0xe2, 0xe3, 0x30, 0x36, 0x8c, 0x26, - 0xb7, 0x37, 0x31, 0x46, 0x83, 0xef, 0x1a, 0x9e, 0x10, 0xbb, 0x6d}; - uint8_t byteswillprops5[] = {0x6, 0xd0, 0xa6, 0x3c, 0x50, 0xba, 0x18, 0x57, 0xf, 0xd2, 0x23, 0x33, 0x19, 0xf8, - 0x90, 0x9e, 0x7c, 0x78, 0x8e, 0x26, 0xf3, 0xd5, 0xad, 0x9d, 0xbe, 0xbc, 0x80, 0x84}; - + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x2, 0xbd, 0xa9}; + uint8_t byteswillprops0[] = {0xd7}; + uint8_t byteswillprops2[] = {0x75, 0x9b, 0xc7, 0x35, 0x55, 0x2d, 0x5a, 0xb5, 0xb8, 0x97, 0x71, 0xe0, 0x71, 0x50, 0x27, 0xef, 0x8, 0x10, 0xe3, 0xd1, 0xa, 0x61, 0xaa, 0x2, 0x61, 0x46, 0x3d}; + uint8_t byteswillprops3[] = {0x2b, 0xe2, 0x6c, 0xf8, 0xa2, 0x41, 0xfa, 0xa6, 0x8f, 0x64, 0x74, 0x7a}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7110}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24305}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22823}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26025}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25372}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16172}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18593}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26543}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18099}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28918}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={1, (char*)&byteswillprops0}, .v={3, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27782}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28886}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31815}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25282}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19094}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5566}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, }; - lwmqtt_properties_t willprops = {23, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1, 0x77, 0x14, 0x95, 0x35, 0xc5, 0x9, 0x1e, 0xbc, 0xa6, 0x10, 0xb3}; - lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4c, 0xad, 0x23, 0x65, 0x3f, 0x7e, 0xf1, 0x3c}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 15628; - uint8_t client_id_bytes[] = {0xee}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x83, 0x29, 0x6f}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x59, 0x5e, 0x20, 0xab, 0xdc, 0xea, 0xb6, 0x54, 0x68, 0x15}; - lwmqtt_string_t password = {10, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb9, 0xa4, 0xc9, 0xda, 0x9, 0x1e, 0x8a, 0x77, 0x34, 0xed, 0x96, 0x4f, 0xbc, 0x7a, 0x7d, 0x57}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3c, 0xc3, 0xa7, 0x1c, 0x57}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 29930; + uint8_t client_id_bytes[] = {0x8, 0x37, 0x6f, 0xcb, 0xc, 0xc5}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x1, 0xa9, 0x95, 0x58}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\176mX\224\177{+\ENQ\221\228\184\181\192 \NUL\201\128\209", _password = Just -// "\215Dco.`\RSl\219\136A\134Z}X\247\&5HG\ETX", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, -// _willTopic = "\242 xK\204\160x\221\169\240", _willMsg = "\220\ACKG", _willProps = [PropSessionExpiryInterval -// 16457,PropWildcardSubscriptionAvailable 225,PropMaximumPacketSize 18276,PropPayloadFormatIndicator -// 46,PropMaximumPacketSize 7510,PropResponseInformation "\167\n\bZ!s\223\224~\216nc\SIJ\189\ACK\DLE\DC4 -// \169\162\218",PropUserProperty "\215\245\170\f[\207\194(.FT\207\187\172F} " -// "\227\DC4\194-",PropWildcardSubscriptionAvailable 118,PropAuthenticationMethod -// "[\133H\EOT{\SUB",PropRequestResponseInformation 182,PropAuthenticationData -// "c\190$\209+\167D\148\f\189\204G\224\189\220[\222@9\178w\ENQ\166f\200|\250",PropMaximumQoS 180,PropReasonString " -// \203\163\254\208%\197n\132\180\231^9\165\&0^",PropReasonString -// "\193-\EOT\210\&1t\134\195T\143\147\169jj\DC2\SYN\SO\215\143\ETBt",PropPayloadFormatIndicator -// 169,PropSessionExpiryInterval 28492,PropAuthenticationMethod "\134\197(W\CAN\174\\\234\220R",PropTopicAliasMaximum -// 16101,PropMessageExpiryInterval 10137,PropReceiveMaximum 16797,PropSharedSubscriptionAvailable 199,PropReceiveMaximum -// 16828,PropReasonString "s)\n`}%\204c\186\209\220Z\249U\233\171d6c\201\SUBu\r\n",PropResponseTopic -// "\145\176Q\238",PropAuthenticationData "\247u\DC2\148+V\151\246q\172\138"]}), _cleanSession = True, _keepAlive = -// 19143, _connID = "\176/i\144P\218\&5\t\229;\221\246\DC2\"", _properties = [PropReceiveMaximum -// 12877,PropCorrelationData "\191\182\ENQp\189_\SIk\254}\159;?\252\&0\232",PropSubscriptionIdentifier 30,PropMaximumQoS -// 64,PropWildcardSubscriptionAvailable 100,PropPayloadFormatIndicator 163]} -TEST(Connect5QCTest, Encode10) { - uint8_t pkt[] = { - 0x10, 0xe8, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x4a, 0xc7, 0x1e, 0x21, 0x32, 0x4d, 0x9, 0x0, - 0x10, 0xbf, 0xb6, 0x5, 0x70, 0xbd, 0x5f, 0xf, 0x6b, 0xfe, 0x7d, 0x9f, 0x3b, 0x3f, 0xfc, 0x30, 0xe8, 0xb, 0x1e, - 0x24, 0x40, 0x28, 0x64, 0x1, 0xa3, 0x0, 0xe, 0xb0, 0x2f, 0x69, 0x90, 0x50, 0xda, 0x35, 0x9, 0xe5, 0x3b, 0xdd, - 0xf6, 0x12, 0x22, 0xf2, 0x1, 0x11, 0x0, 0x0, 0x40, 0x49, 0x28, 0xe1, 0x27, 0x0, 0x0, 0x47, 0x64, 0x1, 0x2e, - 0x27, 0x0, 0x0, 0x1d, 0x56, 0x1a, 0x0, 0x16, 0xa7, 0xa, 0x8, 0x5a, 0x21, 0x73, 0xdf, 0xe0, 0x7e, 0xd8, 0x6e, - 0x63, 0xf, 0x4a, 0xbd, 0x6, 0x10, 0x14, 0x20, 0xa9, 0xa2, 0xda, 0x26, 0x0, 0x11, 0xd7, 0xf5, 0xaa, 0xc, 0x5b, - 0xcf, 0xc2, 0x28, 0x2e, 0x46, 0x54, 0xcf, 0xbb, 0xac, 0x46, 0x7d, 0x20, 0x0, 0x4, 0xe3, 0x14, 0xc2, 0x2d, 0x28, - 0x76, 0x15, 0x0, 0x6, 0x5b, 0x85, 0x48, 0x4, 0x7b, 0x1a, 0x19, 0xb6, 0x16, 0x0, 0x1b, 0x63, 0xbe, 0x24, 0xd1, - 0x2b, 0xa7, 0x44, 0x94, 0xc, 0xbd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 0x44, 0x63, 0x6f, 0x2e, 0x60, 0x1e, 0x6c, 0xdb, 0x88, 0x41, 0x86, 0x5a, 0x7d, 0x58, 0xf7, 0x35, 0x48, - 0x47, 0x3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xbf, 0xb6, 0x5, 0x70, 0xbd, 0x5f, 0xf, 0x6b, - 0xfe, 0x7d, 0x9f, 0x3b, 0x3f, 0xfc, 0x30, 0xe8}; +// ConnectRequest {_username = Just "xj\DC2d\147j\242\141\DC1\253\179o\188", _password = Just "\144\238/&m", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\191\197a\194u\133\135\244\211\170\162\129\161\&6\225\&2", _willMsg = "\218\f", _willProps = [PropPayloadFormatIndicator 192,PropTopicAliasMaximum 11735,PropWildcardSubscriptionAvailable 161,PropWillDelayInterval 8437,PropRequestResponseInformation 154,PropRequestResponseInformation 0,PropRequestProblemInformation 121,PropTopicAlias 5703,PropMessageExpiryInterval 30855,PropServerKeepAlive 21347,PropAssignedClientIdentifier "\232\&70\185N\179E\n]\254b/fTX\DC1C\167Au{\f\234\137",PropRequestProblemInformation 98,PropPayloadFormatIndicator 8]}), _cleanSession = False, _keepAlive = 15412, _connID = "\176\143\160_\\\166\148\213\226\224\CAN>\238\v\168\163", _properties = [PropAssignedClientIdentifier "\146\ETB<\248$\206\222\226\t\163_",PropMessageExpiryInterval 5227,PropTopicAlias 787,PropMaximumQoS 108,PropResponseInformation "K\161qr\DC4\207\217\225\185\142A)\188\&9^\175\244\130&}\225\204d\b\184\167\225\STX\b\151",PropContentType "\189 ",PropMessageExpiryInterval 19245,PropRequestProblemInformation 210,PropSessionExpiryInterval 32723,PropRequestResponseInformation 208,PropTopicAliasMaximum 32403,PropSessionExpiryInterval 11781,PropMaximumPacketSize 27425,PropMessageExpiryInterval 21128,PropRequestProblemInformation 119,PropAuthenticationData "\249\DLE\224\255\SOH\171l.`\165O\179\&9\NUL\246\180\148\&9\221\STX\r\159",PropServerReference "_\218\138\225p\ETX\STX\202\157X",PropResponseTopic "\150\135\239hji\149\DC26\153\190\201\253Y/\252\167\242.J=z\161\200\DC3",PropPayloadFormatIndicator 251]} +TEST(Connect5QCTest, Encode12) { +uint8_t pkt[] = {0x10, 0xab, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x3c, 0x34, 0xa4, 0x1, 0x12, 0x0, 0xb, 0x92, 0x17, 0x3c, 0xf8, 0x24, 0xce, 0xde, 0xe2, 0x9, 0xa3, 0x5f, 0x2, 0x0, 0x0, 0x14, 0x6b, 0x23, 0x3, 0x13, 0x24, 0x6c, 0x1a, 0x0, 0x1e, 0x4b, 0xa1, 0x71, 0x72, 0x14, 0xcf, 0xd9, 0xe1, 0xb9, 0x8e, 0x41, 0x29, 0xbc, 0x39, 0x5e, 0xaf, 0xf4, 0x82, 0x26, 0x7d, 0xe1, 0xcc, 0x64, 0x8, 0xb8, 0xa7, 0xe1, 0x2, 0x8, 0x97, 0x3, 0x0, 0x2, 0xbd, 0x20, 0x2, 0x0, 0x0, 0x4b, 0x2d, 0x17, 0xd2, 0x11, 0x0, 0x0, 0x7f, 0xd3, 0x19, 0xd0, 0x22, 0x7e, 0x93, 0x11, 0x0, 0x0, 0x2e, 0x5, 0x27, 0x0, 0x0, 0x6b, 0x21, 0x2, 0x0, 0x0, 0x52, 0x88, 0x17, 0x77, 0x16, 0x0, 0x16, 0xf9, 0x10, 0xe0, 0xff, 0x1, 0xab, 0x6c, 0x2e, 0x60, 0xa5, 0x4f, 0xb3, 0x39, 0x0, 0xf6, 0xb4, 0x94, 0x39, 0xdd, 0x2, 0xd, 0x9f, 0x1c, 0x0, 0xa, 0x5f, 0xda, 0x8a, 0xe1, 0x70, 0x3, 0x2, 0xca, 0x9d, 0x58, 0x8, 0x0, 0x19, 0x96, 0x87, 0xef, 0x68, 0x6a, 0x69, 0x95, 0x12, 0x36, 0x99, 0xbe, 0xc9, 0xfd, 0x59, 0x2f, 0xfc, 0xa7, 0xf2, 0x2e, 0x4a, 0x3d, 0x7a, 0xa1, 0xc8, 0x13, 0x1, 0xfb, 0x0, 0x10, 0xb0, 0x8f, 0xa0, 0x5f, 0x5c, 0xa6, 0x94, 0xd5, 0xe2, 0xe0, 0x18, 0x3e, 0xee, 0xb, 0xa8, 0xa3, 0x3c, 0x1, 0xc0, 0x22, 0x2d, 0xd7, 0x28, 0xa1, 0x18, 0x0, 0x0, 0x20, 0xf5, 0x19, 0x9a, 0x19, 0x0, 0x17, 0x79, 0x23, 0x16, 0x47, 0x2, 0x0, 0x0, 0x78, 0x87, 0x13, 0x53, 0x63, 0x12, 0x0, 0x18, 0xe8, 0x37, 0x30, 0xb9, 0x4e, 0xb3, 0x45, 0xa, 0x5d, 0xfe, 0x62, 0x2f, 0x66, 0x54, 0x58, 0x11, 0x43, 0xa7, 0x41, 0x75, 0x7b, 0xc, 0xea, 0x89, 0x17, 0x62, 0x1, 0x8, 0x0, 0x10, 0xbf, 0xc5, 0x61, 0xc2, 0x75, 0x85, 0x87, 0xf4, 0xd3, 0xaa, 0xa2, 0x81, 0xa1, 0x36, 0xe1, 0x32, 0x0, 0x2, 0xda, 0xc, 0x0, 0xd, 0x78, 0x6a, 0x12, 0x64, 0x93, 0x6a, 0xf2, 0x8d, 0x11, 0xfd, 0xb3, 0x6f, 0xbc, 0x0, 0x5, 0x90, 0xee, 0x2f, 0x26, 0x6d}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x92, 0x17, 0x3c, 0xf8, 0x24, 0xce, 0xde, 0xe2, 0x9, 0xa3, 0x5f}; + uint8_t bytesprops1[] = {0x4b, 0xa1, 0x71, 0x72, 0x14, 0xcf, 0xd9, 0xe1, 0xb9, 0x8e, 0x41, 0x29, 0xbc, 0x39, 0x5e, 0xaf, 0xf4, 0x82, 0x26, 0x7d, 0xe1, 0xcc, 0x64, 0x8, 0xb8, 0xa7, 0xe1, 0x2, 0x8, 0x97}; + uint8_t bytesprops2[] = {0xbd, 0x20}; + uint8_t bytesprops3[] = {0xf9, 0x10, 0xe0, 0xff, 0x1, 0xab, 0x6c, 0x2e, 0x60, 0xa5, 0x4f, 0xb3, 0x39, 0x0, 0xf6, 0xb4, 0x94, 0x39, 0xdd, 0x2, 0xd, 0x9f}; + uint8_t bytesprops4[] = {0x5f, 0xda, 0x8a, 0xe1, 0x70, 0x3, 0x2, 0xca, 0x9d, 0x58}; + uint8_t bytesprops5[] = {0x96, 0x87, 0xef, 0x68, 0x6a, 0x69, 0x95, 0x12, 0x36, 0x99, 0xbe, 0xc9, 0xfd, 0x59, 0x2f, 0xfc, 0xa7, 0xf2, 0x2e, 0x4a, 0x3d, 0x7a, 0xa1, 0xc8, 0x13}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12877}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5227}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 787}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19245}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32723}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32403}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11781}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27425}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21128}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 251}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xa7, 0xa, 0x8, 0x5a, 0x21, 0x73, 0xdf, 0xe0, 0x7e, 0xd8, 0x6e, - 0x63, 0xf, 0x4a, 0xbd, 0x6, 0x10, 0x14, 0x20, 0xa9, 0xa2, 0xda}; - uint8_t byteswillprops2[] = {0xe3, 0x14, 0xc2, 0x2d}; - uint8_t byteswillprops1[] = {0xd7, 0xf5, 0xaa, 0xc, 0x5b, 0xcf, 0xc2, 0x28, 0x2e, - 0x46, 0x54, 0xcf, 0xbb, 0xac, 0x46, 0x7d, 0x20}; - uint8_t byteswillprops3[] = {0x5b, 0x85, 0x48, 0x4, 0x7b, 0x1a}; - uint8_t byteswillprops4[] = {0x63, 0xbe, 0x24, 0xd1, 0x2b, 0xa7, 0x44, 0x94, 0xc, 0xbd, 0xcc, 0x47, 0xe0, 0xbd, - 0xdc, 0x5b, 0xde, 0x40, 0x39, 0xb2, 0x77, 0x5, 0xa6, 0x66, 0xc8, 0x7c, 0xfa}; - uint8_t byteswillprops5[] = {0x20, 0xcb, 0xa3, 0xfe, 0xd0, 0x25, 0xc5, 0x6e, - 0x84, 0xb4, 0xe7, 0x5e, 0x39, 0xa5, 0x30, 0x5e}; - uint8_t byteswillprops6[] = {0xc1, 0x2d, 0x4, 0xd2, 0x31, 0x74, 0x86, 0xc3, 0x54, 0x8f, 0x93, - 0xa9, 0x6a, 0x6a, 0x12, 0x16, 0xe, 0xd7, 0x8f, 0x17, 0x74}; - uint8_t byteswillprops7[] = {0x86, 0xc5, 0x28, 0x57, 0x18, 0xae, 0x5c, 0xea, 0xdc, 0x52}; - uint8_t byteswillprops8[] = {0x73, 0x29, 0xa, 0x60, 0x7d, 0x25, 0xcc, 0x63, 0xba, 0xd1, 0xdc, 0x5a, - 0xf9, 0x55, 0xe9, 0xab, 0x64, 0x36, 0x63, 0xc9, 0x1a, 0x75, 0xd, 0xa}; - uint8_t byteswillprops9[] = {0x91, 0xb0, 0x51, 0xee}; - uint8_t byteswillprops10[] = {0xf7, 0x75, 0x12, 0x94, 0x2b, 0x56, 0x97, 0xf6, 0x71, 0xac, 0x8a}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xe8, 0x37, 0x30, 0xb9, 0x4e, 0xb3, 0x45, 0xa, 0x5d, 0xfe, 0x62, 0x2f, 0x66, 0x54, 0x58, 0x11, 0x43, 0xa7, 0x41, 0x75, 0x7b, 0xc, 0xea, 0x89}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11735}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8437}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5703}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30855}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21347}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, + }; + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xbf, 0xc5, 0x61, 0xc2, 0x75, 0x85, 0x87, 0xf4, 0xd3, 0xaa, 0xa2, 0x81, 0xa1, 0x36, 0xe1, 0x32}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xda, 0xc}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS0; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 15412; + uint8_t client_id_bytes[] = {0xb0, 0x8f, 0xa0, 0x5f, 0x5c, 0xa6, 0x94, 0xd5, 0xe2, 0xe0, 0x18, 0x3e, 0xee, 0xb, 0xa8, 0xa3}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x78, 0x6a, 0x12, 0x64, 0x93, 0x6a, 0xf2, 0x8d, 0x11, 0xfd, 0xb3, 0x6f, 0xbc}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x90, 0xee, 0x2f, 0x26, 0x6d}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// ConnectRequest {_username = Nothing, _password = Just "\128p\220>r\201\195\&0\200", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\DC3l\244\169\203\EOT\129\173\&4\NUL\252\RS\184\133V\249z\191:P~GH\EM\193\SOH29\254e", _willMsg = "mvB", _willProps = [PropTopicAlias 32015,PropReceiveMaximum 20354,PropServerReference "a\230\147k\173c",PropRetainAvailable 141,PropContentType "\152\187&ci^\244\182{\166-\152\239\213 \216\242Z;nE~\235k\157\206",PropTopicAlias 4971,PropSharedSubscriptionAvailable 136,PropTopicAliasMaximum 21122,PropServerReference "\195%\SOo\170(\237",PropReceiveMaximum 30880,PropContentType " \237>Nx?\234\210\128\231\243\202\229\252r\191y\ETX9\214",PropTopicAliasMaximum 944,PropSessionExpiryInterval 4649,PropResponseTopic "0\DC4wb\235\170\196\188",PropSubscriptionIdentifier 5,PropPayloadFormatIndicator 92,PropSubscriptionIdentifier 23,PropMaximumQoS 170,PropCorrelationData "'",PropSubscriptionIdentifierAvailable 121,PropServerKeepAlive 11697,PropSessionExpiryInterval 32682,PropReceiveMaximum 10853,PropPayloadFormatIndicator 94,PropSubscriptionIdentifierAvailable 249]}), _cleanSession = True, _keepAlive = 30313, _connID = "\215\250VLG@\204B\"\166$HJ", _properties = [PropRequestResponseInformation 42,PropSubscriptionIdentifier 17,PropAuthenticationMethod "i\134\SO\230!|\133\173[O{6W&\161\175",PropReasonString "^@",PropMessageExpiryInterval 12544,PropServerReference "\SOH\168\246Bt\EOTQt,\158)\SYN\r=",PropAssignedClientIdentifier "a\212\EM\DC4H\239\196F\154QVS\157u\218\US\155'uB\245\152\SI",PropSessionExpiryInterval 2313,PropSharedSubscriptionAvailable 135,PropMessageExpiryInterval 6040,PropMessageExpiryInterval 14534,PropAssignedClientIdentifier "\DC4*\231\182",PropResponseTopic "F\r#\DC1\203\&23\132\ETX4l\199",PropWildcardSubscriptionAvailable 202,PropResponseInformation "\231\&5\130,\230\162\SYNO\184\CAN!?LV\SUB\155\200e\174\214\238",PropCorrelationData "Y\202\227\r",PropSessionExpiryInterval 239]} +TEST(Connect5QCTest, Encode15) { +uint8_t pkt[] = {0x10, 0xfe, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x12, 0x7d, 0x5b, 0x1, 0x92, 0x15, 0x0, 0x9, 0x1a, 0x96, 0x3e, 0x27, 0x75, 0x42, 0xf5, 0x98, 0xf, 0x11, 0x0, 0x0, 0x9, 0x9, 0x2a, 0x87, 0x2, 0x0, 0x0, 0x17, 0x98, 0x2, 0x0, 0x0, 0x38, 0xc6, 0x12, 0x0, 0x4, 0x14, 0x2a, 0xe7, 0xb6, 0x8, 0x0, 0xc, 0x46, 0xd, 0x23, 0x11, 0xcb, 0x32, 0x33, 0x84, 0x3, 0x34, 0x6c, 0xc7, 0x28, 0xca, 0x1a, 0x0, 0x15, 0xe7, 0x35, 0x82, 0x2c, 0xe6, 0xa2, 0x16, 0x4f, 0xb8, 0x18, 0x21, 0x3f, 0x4c, 0x56, 0x1a, 0x9b, 0xc8, 0x65, 0xae, 0xd6, 0xee, 0x9, 0x0, 0x4, 0x59, 0xca, 0xe3, 0xd, 0x11, 0x0, 0x0, 0x0, 0xef, 0x0, 0x18, 0xb, 0x3, 0x2c, 0xcc, 0x62, 0x8d, 0x88, 0x72, 0x21, 0x72, 0x13, 0x61, 0x2d, 0x8a, 0xf9, 0x4d, 0x37, 0x7, 0x66, 0x67, 0x4, 0x8b, 0xe4, 0x57, 0x39, 0x3, 0x0, 0x12, 0x3, 0xc3, 0x87, 0xd4, 0x63, 0xde, 0x46, 0xe0, 0xbc, 0xca, 0xef, 0xb9, 0x8f, 0xec, 0xb0, 0x5b, 0xf3, 0x34, 0x9, 0x0, 0x6, 0x68, 0x25, 0x6b, 0xa1, 0xc9, 0xbf, 0x1, 0xa6, 0x23, 0x59, 0x20, 0x19, 0x54, 0x18, 0x0, 0x0, 0x48, 0x2f, 0x19, 0x84, 0x29, 0xca, 0x1, 0xd2, 0xb, 0x13, 0x11, 0x0, 0x0, 0x9, 0xe6, 0x25, 0x81, 0x0, 0x8, 0xf1, 0x35, 0xb4, 0xeb, 0x85, 0x3d, 0x87, 0xe0, 0x0, 0x14, 0x2b, 0x72, 0x9c, 0xfa, 0x33, 0xa4, 0x8a, 0xa, 0x70, 0x6a, 0xf5, 0x3d, 0xee, 0xb6, 0x4e, 0x5e, 0xd, 0x61, 0x97, 0xa1, 0x0, 0x15, 0x41, 0x3b, 0xa8, 0xe0, 0xf0, 0xed, 0x11, 0x1f, 0x60, 0x6b, 0xe4, 0x44, 0xc9, 0x20, 0xd3, 0x76, 0x45, 0x2e, 0xcb, 0x2, 0x26, 0x0, 0xb, 0xe5, 0x16, 0xec, 0xfc, 0x6a, 0x72, 0x6a, 0xf6, 0x10, 0x3d, 0x78}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x1a, 0x96, 0x3e, 0x27, 0x75, 0x42, 0xf5, 0x98, 0xf}; + uint8_t bytesprops1[] = {0x14, 0x2a, 0xe7, 0xb6}; + uint8_t bytesprops2[] = {0x46, 0xd, 0x23, 0x11, 0xcb, 0x32, 0x33, 0x84, 0x3, 0x34, 0x6c, 0xc7}; + uint8_t bytesprops3[] = {0xe7, 0x35, 0x82, 0x2c, 0xe6, 0xa2, 0x16, 0x4f, 0xb8, 0x18, 0x21, 0x3f, 0x4c, 0x56, 0x1a, 0x9b, 0xc8, 0x65, 0xae, 0xd6, 0xee}; + uint8_t bytesprops4[] = {0x59, 0xca, 0xe3, 0xd}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2412}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12333}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18567}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17848}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16262}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7802}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2285}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27265}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2313}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6040}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14534}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 239}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 6889; - uint8_t client_id_bytes[] = {0x68, 0x4f, 0xe9, 0x67, 0xa, 0x7b, 0x71, 0x4e, 0x4f, 0xa0, 0x20}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x51, 0x1d, 0xf2, 0xd1}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x3, 0xc3, 0x87, 0xd4, 0x63, 0xde, 0x46, 0xe0, 0xbc, 0xca, 0xef, 0xb9, 0x8f, 0xec, 0xb0, 0x5b, 0xf3, 0x34}; + uint8_t byteswillprops1[] = {0x68, 0x25, 0x6b, 0xa1, 0xc9, 0xbf}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22816}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18479}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2534}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, + }; + + lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf1, 0x35, 0xb4, 0xeb, 0x85, 0x3d, 0x87, 0xe0}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2b, 0x72, 0x9c, 0xfa, 0x33, 0xa4, 0x8a, 0xa, 0x70, 0x6a, 0xf5, 0x3d, 0xee, 0xb6, 0x4e, 0x5e, 0xd, 0x61, 0x97, 0xa1}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 4733; + uint8_t client_id_bytes[] = {0xb, 0x3, 0x2c, 0xcc, 0x62, 0x8d, 0x88, 0x72, 0x21, 0x72, 0x13, 0x61, 0x2d, 0x8a, 0xf9, 0x4d, 0x37, 0x7, 0x66, 0x67, 0x4, 0x8b, 0xe4, 0x57}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x41, 0x3b, 0xa8, 0xe0, 0xf0, 0xed, 0x11, 0x1f, 0x60, 0x6b, 0xe4, 0x44, 0xc9, 0x20, 0xd3, 0x76, 0x45, 0x2e, 0xcb, 0x2, 0x26}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0xe5, 0x16, 0xec, 0xfc, 0x6a, 0x72, 0x6a, 0xf6, 0x10, 0x3d, 0x78}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "", _willMsg = "\235\177\182N)\GS\253\200\252E\173b\141gO\165\169\ETX\va\209*", _willProps = -// [PropSubscriptionIdentifier 30,PropSharedSubscriptionAvailable 90,PropMaximumPacketSize -// 102,PropRequestResponseInformation 81,PropAssignedClientIdentifier "`T\n@\232\SI\as\ESCC;i\r\DC4\251_\220I.7<\216o -// ",PropReasonString "\161A\141\140e5\231YCa;c5A\176\174\237\131\184w<\f;@",PropRetainAvailable -// 202,PropRequestProblemInformation 6,PropSubscriptionIdentifier 8,PropPayloadFormatIndicator -// 24,PropAuthenticationMethod "\213z\RS\233\164t\162\&2\199vBQ\221",PropRetainAvailable -// 241,PropRequestResponseInformation 83,PropReasonString "[i",PropWillDelayInterval 715]}), _cleanSession = True, -// _keepAlive = 8360, _connID = "\178Ip\r*\206Y\141(\255\184\&4\224\197=\217\172\EM\EOT\\'\RS\229u\172S\202", -// _properties = [PropMaximumPacketSize 16932,PropContentType "",PropServerKeepAlive -// 19286,PropRequestResponseInformation 79,PropContentType -// "\187%]\190:\169\235R8\DC1r\ESCM3\162W\194V",PropSessionExpiryInterval 8066,PropUserProperty "\171" -// "\170B\211\DLE\250\SI\243\214mv\SOQR\"\STX\200\&3]y",PropSubscriptionIdentifier 9,PropAuthenticationMethod -// "\254\182\139U\216UC\239\185f9\143\SOH",PropPayloadFormatIndicator 79]} -TEST(Connect5QCTest, Encode13) { - uint8_t pkt[] = { - 0x10, 0xfe, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe, 0x20, 0xa8, 0x54, 0x27, 0x0, 0x0, 0x42, 0x24, - 0x3, 0x0, 0x0, 0x13, 0x4b, 0x56, 0x19, 0x4f, 0x3, 0x0, 0x12, 0xbb, 0x25, 0x5d, 0xbe, 0x3a, 0xa9, 0xeb, 0x52, - 0x38, 0x11, 0x72, 0x1b, 0x4d, 0x33, 0xa2, 0x57, 0xc2, 0x56, 0x11, 0x0, 0x0, 0x1f, 0x82, 0x26, 0x0, 0x1, 0xab, - 0x0, 0x13, 0xaa, 0x42, 0xd3, 0x10, 0xfa, 0xf, 0xf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x61, 0xd1, 0x2a}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xbb, 0x25, 0x5d, 0xbe, 0x3a, 0xa9, 0xeb, 0x52, 0x38, - 0x11, 0x72, 0x1b, 0x4d, 0x33, 0xa2, 0x57, 0xc2, 0x56}; - uint8_t bytesprops3[] = {0xaa, 0x42, 0xd3, 0x10, 0xfa, 0xf, 0xf3, 0xd6, 0x6d, 0x76, - 0xe, 0x51, 0x52, 0x22, 0x2, 0xc8, 0x33, 0x5d, 0x79}; - uint8_t bytesprops2[] = {0xab}; - uint8_t bytesprops4[] = {0xfe, 0xb6, 0x8b, 0x55, 0xd8, 0x55, 0x43, 0xef, 0xb9, 0x66, 0x39, 0x8f, 0x1}; +// ConnectRequest {_username = Just "\172\&0m\236P\216\191\220\208y\146\237\159\163\244Q\136\214\218\197\202\DC3(d\vm\142\GSO\DC3", _password = Just "\EM\a\ACKM\203i\200\227NY:", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\170\n\217\SO\CANI8\208\NAK", _willMsg = "", _willProps = [PropSharedSubscriptionAvailable 53,PropReasonString "\232\182\US_9\185\154\139\t\185\&9\187\225E*cC",PropResponseInformation "\206\DC4\SOH\251\&1M\232\134\129\145\251\t(",PropWildcardSubscriptionAvailable 94,PropSubscriptionIdentifier 11,PropWillDelayInterval 8513,PropSubscriptionIdentifierAvailable 166,PropRequestProblemInformation 92,PropMaximumQoS 16,PropSessionExpiryInterval 13745,PropServerReference "\182X\129:>\131\222\176vsk\255^\188\216\253\247X\142@\197\226u\164\NUL",PropServerKeepAlive 18267,PropResponseInformation "\132s\v\135\131\227\&9o;O\207,\129Al\241!u\222",PropTopicAlias 19785,PropUserProperty "\FS\177\SI-'\152\174\245\n\130\207\229\r\222 c4\188\196#" "\176o\253\216\DC4MT\140\NAK\129:\GS\146\\}`\n("]}), _cleanSession = True, _keepAlive = 25021, _connID = "h\216P$\178\190\228\190\138\FS", _properties = [PropMaximumQoS 85,PropReasonString "\205\229\152m\250\252hu\EOTu\135\230BP\199H\202)\220\RS\164\200\221\DC4",PropResponseTopic "<\212\221Um\DEL\133L8*\144\205\232\197w\231o\161\181\STX\208\232\SOH",PropSessionExpiryInterval 13715,PropMaximumQoS 51]} +TEST(Connect5QCTest, Encode16) { +uint8_t pkt[] = {0x10, 0xae, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x61, 0xbd, 0x3e, 0x24, 0x55, 0x1f, 0x0, 0x18, 0xcd, 0xe5, 0x98, 0x6d, 0xfa, 0xfc, 0x68, 0x75, 0x4, 0x75, 0x87, 0xe6, 0x42, 0x50, 0xc7, 0x48, 0xca, 0x29, 0xdc, 0x1e, 0xa4, 0xc8, 0xdd, 0x14, 0x8, 0x0, 0x17, 0x3c, 0xd4, 0xdd, 0x55, 0x6d, 0x7f, 0x85, 0x4c, 0x38, 0x2a, 0x90, 0xcd, 0xe8, 0xc5, 0x77, 0xe7, 0x6f, 0xa1, 0xb5, 0x2, 0xd0, 0xe8, 0x1, 0x11, 0x0, 0x0, 0x35, 0x93, 0x24, 0x33, 0x0, 0xa, 0x68, 0xd8, 0x50, 0x24, 0xb2, 0xbe, 0xe4, 0xbe, 0x8a, 0x1c, 0x9d, 0x1, 0x2a, 0x35, 0x1f, 0x0, 0x11, 0xe8, 0xb6, 0x1f, 0x5f, 0x39, 0xb9, 0x9a, 0x8b, 0x9, 0xb9, 0x39, 0xbb, 0xe1, 0x45, 0x2a, 0x63, 0x43, 0x1a, 0x0, 0xd, 0xce, 0x14, 0x1, 0xfb, 0x31, 0x4d, 0xe8, 0x86, 0x81, 0x91, 0xfb, 0x9, 0x28, 0x28, 0x5e, 0xb, 0xb, 0x18, 0x0, 0x0, 0x21, 0x41, 0x29, 0xa6, 0x17, 0x5c, 0x24, 0x10, 0x11, 0x0, 0x0, 0x35, 0xb1, 0x1c, 0x0, 0x19, 0xb6, 0x58, 0x81, 0x3a, 0x3e, 0x83, 0xde, 0xb0, 0x76, 0x73, 0x6b, 0xff, 0x5e, 0xbc, 0xd8, 0xfd, 0xf7, 0x58, 0x8e, 0x40, 0xc5, 0xe2, 0x75, 0xa4, 0x0, 0x13, 0x47, 0x5b, 0x1a, 0x0, 0x13, 0x84, 0x73, 0xb, 0x87, 0x83, 0xe3, 0x39, 0x6f, 0x3b, 0x4f, 0xcf, 0x2c, 0x81, 0x41, 0x6c, 0xf1, 0x21, 0x75, 0xde, 0x23, 0x4d, 0x49, 0x26, 0x0, 0x14, 0x1c, 0xb1, 0xf, 0x2d, 0x27, 0x98, 0xae, 0xf5, 0xa, 0x82, 0xcf, 0xe5, 0xd, 0xde, 0x20, 0x63, 0x34, 0xbc, 0xc4, 0x23, 0x0, 0x12, 0xb0, 0x6f, 0xfd, 0xd8, 0x14, 0x4d, 0x54, 0x8c, 0x15, 0x81, 0x3a, 0x1d, 0x92, 0x5c, 0x7d, 0x60, 0xa, 0x28, 0x0, 0x9, 0xaa, 0xa, 0xd9, 0xe, 0x18, 0x49, 0x38, 0xd0, 0x15, 0x0, 0x0, 0x0, 0x1e, 0xac, 0x30, 0x6d, 0xec, 0x50, 0xd8, 0xbf, 0xdc, 0xd0, 0x79, 0x92, 0xed, 0x9f, 0xa3, 0xf4, 0x51, 0x88, 0xd6, 0xda, 0xc5, 0xca, 0x13, 0x28, 0x64, 0xb, 0x6d, 0x8e, 0x1d, 0x4f, 0x13, 0x0, 0xb, 0x19, 0x7, 0x6, 0x4d, 0xcb, 0x69, 0xc8, 0xe3, 0x4e, 0x59, 0x3a}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xcd, 0xe5, 0x98, 0x6d, 0xfa, 0xfc, 0x68, 0x75, 0x4, 0x75, 0x87, 0xe6, 0x42, 0x50, 0xc7, 0x48, 0xca, 0x29, 0xdc, 0x1e, 0xa4, 0xc8, 0xdd, 0x14}; + uint8_t bytesprops1[] = {0x3c, 0xd4, 0xdd, 0x55, 0x6d, 0x7f, 0x85, 0x4c, 0x38, 0x2a, 0x90, 0xcd, 0xe8, 0xc5, 0x77, 0xe7, 0x6f, 0xa1, 0xb5, 0x2, 0xd0, 0xe8, 0x1}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16932}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19286}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8066}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops2}, .v = {19, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13715}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 51}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x60, 0x54, 0xa, 0x40, 0xe8, 0xf, 0x7, 0x73, 0x1b, 0x43, 0x3b, 0x69, - 0xd, 0x14, 0xfb, 0x5f, 0xdc, 0x49, 0x2e, 0x37, 0x3c, 0xd8, 0x6f, 0x20}; - uint8_t byteswillprops1[] = {0xa1, 0x41, 0x8d, 0x8c, 0x65, 0x35, 0xe7, 0x59, 0x43, 0x61, 0x3b, 0x63, - 0x35, 0x41, 0xb0, 0xae, 0xed, 0x83, 0xb8, 0x77, 0x3c, 0xc, 0x3b, 0x40}; - uint8_t byteswillprops2[] = {0xd5, 0x7a, 0x1e, 0xe9, 0xa4, 0x74, 0xa2, 0x32, 0xc7, 0x76, 0x42, 0x51, 0xdd}; - uint8_t byteswillprops3[] = {0x5b, 0x69}; - + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xe8, 0xb6, 0x1f, 0x5f, 0x39, 0xb9, 0x9a, 0x8b, 0x9, 0xb9, 0x39, 0xbb, 0xe1, 0x45, 0x2a, 0x63, 0x43}; + uint8_t byteswillprops1[] = {0xce, 0x14, 0x1, 0xfb, 0x31, 0x4d, 0xe8, 0x86, 0x81, 0x91, 0xfb, 0x9, 0x28}; + uint8_t byteswillprops2[] = {0xb6, 0x58, 0x81, 0x3a, 0x3e, 0x83, 0xde, 0xb0, 0x76, 0x73, 0x6b, 0xff, 0x5e, 0xbc, 0xd8, 0xfd, 0xf7, 0x58, 0x8e, 0x40, 0xc5, 0xe2, 0x75, 0xa4, 0x0}; + uint8_t byteswillprops3[] = {0x84, 0x73, 0xb, 0x87, 0x83, 0xe3, 0x39, 0x6f, 0x3b, 0x4f, 0xcf, 0x2c, 0x81, 0x41, 0x6c, 0xf1, 0x21, 0x75, 0xde}; + uint8_t byteswillprops5[] = {0xb0, 0x6f, 0xfd, 0xd8, 0x14, 0x4d, 0x54, 0x8c, 0x15, 0x81, 0x3a, 0x1d, 0x92, 0x5c, 0x7d, 0x60, 0xa, 0x28}; + uint8_t byteswillprops4[] = {0x1c, 0xb1, 0xf, 0x2d, 0x27, 0x98, 0xae, 0xf5, 0xa, 0x82, 0xcf, 0xe5, 0xd, 0xde, 0x20, 0x63, 0x34, 0xbc, 0xc4, 0x23}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 102}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 715}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8513}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13745}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18267}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19785}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={20, (char*)&byteswillprops4}, .v={18, (char*)&byteswillprops5}}}}, }; lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xeb, 0xb1, 0xb6, 0x4e, 0x29, 0x1d, 0xfd, 0xc8, 0xfc, 0x45, 0xad, - 0x62, 0x8d, 0x67, 0x4f, 0xa5, 0xa9, 0x3, 0xb, 0x61, 0xd1, 0x2a}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 8360; - uint8_t client_id_bytes[] = {0xb2, 0x49, 0x70, 0xd, 0x2a, 0xce, 0x59, 0x8d, 0x28, 0xff, 0xb8, 0x34, 0xe0, 0xc5, - 0x3d, 0xd9, 0xac, 0x19, 0x4, 0x5c, 0x27, 0x1e, 0xe5, 0x75, 0xac, 0x53, 0xca}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + uint8_t will_topic_bytes[] = {0xaa, 0xa, 0xd9, 0xe, 0x18, 0x49, 0x38, 0xd0, 0x15}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 25021; + uint8_t client_id_bytes[] = {0x68, 0xd8, 0x50, 0x24, 0xb2, 0xbe, 0xe4, 0xbe, 0x8a, 0x1c}; + lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xac, 0x30, 0x6d, 0xec, 0x50, 0xd8, 0xbf, 0xdc, 0xd0, 0x79, 0x92, 0xed, 0x9f, 0xa3, 0xf4, 0x51, 0x88, 0xd6, 0xda, 0xc5, 0xca, 0x13, 0x28, 0x64, 0xb, 0x6d, 0x8e, 0x1d, 0x4f, 0x13}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x19, 0x7, 0x6, 0x4d, 0xcb, 0x69, 0xc8, 0xe3, 0x4e, 0x59, 0x3a}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "H\176\DC3\130\176@\132\210", _password = Just -// "\198\248\US\ETB\143\174JCT\DEL\221a\211\221;\179\128\182\154\207\189o", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS2, _willTopic = "\147.\146\246\203'\150]B\EMY\ETB\GS\tM\166q\196ug\DLE\t\191B", _willMsg = -// "\228\164\240r\184\245\201\DC2#9H\152\ETB\188\241\217\202\186\203\197D\220\162\&4\213", _willProps = -// [PropAuthenticationData "\162\166",PropWildcardSubscriptionAvailable 231,PropResponseTopic -// "\242\RSV\214\153\ACK\189\142\227\173\222\148\&6\208\137",PropSharedSubscriptionAvailable 253,PropTopicAlias -// 19038,PropSubscriptionIdentifier 12,PropMaximumPacketSize 28927,PropRequestResponseInformation 68,PropRetainAvailable -// 193,PropUserProperty "\226B" "\148\ACK\191!\\e\132\FS\173\227\NULs\250\221TZ\205T\vA\DC3/",PropContentType -// "r\SOB\STX",PropMaximumQoS 189,PropResponseTopic "\219\&6\187\201\169j\253\ENQR",PropResponseInformation -// "\203z\241N\186\139\215\187\196\189",PropSessionExpiryInterval 29995,PropResponseTopic -// "\240\235\n\224\r\199\222e\131\191D9DRk",PropServerKeepAlive 16658,PropMaximumPacketSize 12740,PropTopicAlias -// 1507,PropMessageExpiryInterval 14889,PropSharedSubscriptionAvailable 226,PropReceiveMaximum -// 15043,PropMaximumPacketSize 26334,PropReceiveMaximum 23369,PropRequestResponseInformation 254,PropUserProperty -// "B\189\RS\134\173%}\SIY\220\217\215\184\153\ahbz" "I\226\231\186\181\214\155",PropMessageExpiryInterval -// 1596,PropWildcardSubscriptionAvailable 35]}), _cleanSession = True, _keepAlive = 28532, _connID = -// "y\245\130FF#\\[\227\&0", _properties = [PropWillDelayInterval 8113,PropAuthenticationMethod -// "\132\SOD\229T\134\165",PropWillDelayInterval 7510,PropReasonString "\253\ACK\136\183\&1\211\&3",PropTopicAlias -// 28415]} -TEST(Connect5QCTest, Encode14) { - uint8_t pkt[] = { - 0x10, 0xd4, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x6f, 0x74, 0x21, 0x18, 0x0, 0x0, 0x1f, 0xb1, - 0x15, 0x0, 0x7, 0x84, 0xe, 0x44, 0xe5, 0x54, 0x86, 0xa5, 0x18, 0x0, 0x0, 0x1d, 0x56, 0x1f, 0x0, 0x7, 0xfd, - 0x6, 0x88, 0xb7, 0x31, 0xd3, 0x33, 0x23, 0x6e, 0xff, 0x0, 0xa, 0x79, 0xf5, 0x82, 0x46, 0x46, 0x23, 0x5c, 0x5b, - 0xe3, 0x30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d6, 0x9b, 0x2, 0x0, 0x0, 0x6, 0x3c, 0x28, 0x23, 0x0, 0x18, 0x93, 0x2e, 0x92, 0xf6, 0xcb, 0x27, 0x96, 0x5d, - 0x42, 0x19, 0x59, 0x17, 0x1d, 0x9, 0x4d, 0xa6, 0x71, 0xc4, 0x75, 0x67, 0x10, 0x9, 0xbf, 0x42, 0x0, 0x19, 0xe4, - 0xa4, 0xf0, 0x72, 0xb8, 0xf5, 0xc9, 0x12, 0x23, 0x39, 0x48, 0x98, 0x17, 0xbc, 0xf1, 0xd9, 0xca, 0xba, 0xcb, 0xc5, - 0x44, 0xdc, 0xa2, 0x34, 0xd5, 0x0, 0x8, 0x48, 0xb0, 0x13, 0x82, 0xb0, 0x40, 0x84, 0xd2, 0x0, 0x16, 0xc6, 0xf8, - 0x1f, 0x17, 0x8f, 0xae, 0x4a, 0x43, 0x54, 0x7f, 0xdd, 0x61, 0xd3, 0xdd, 0x3b, 0xb3, 0x80, 0xb6, 0x9a, 0xcf, 0xbd, - 0x6f}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x84, 0xe, 0x44, 0xe5, 0x54, 0x86, 0xa5}; - uint8_t bytesprops1[] = {0xfd, 0x6, 0x88, 0xb7, 0x31, 0xd3, 0x33}; +// ConnectRequest {_username = Just "-\\\US\191>B\216\175\176\r\209#\187\163", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = ",R\166,\231d\190T\\4\f\152s\ENQ\214\188\159\242\200\STX\212yX\237", _willMsg = "G\242R!yU\157\129c\166", _willProps = [PropAuthenticationData "\EMK\SOH\DC3\202\&3\154\145\145^\221\f+\134-\174\249t\214",PropResponseInformation "\252\FS*,m\EM\159fX\226\175)",PropSessionExpiryInterval 99,PropTopicAlias 29786,PropResponseInformation "-$\190u\208\f\179\133+i+\172\213\227q\220\FS\157\217~\162\DC2\194U\238\&9\bl\174/",PropPayloadFormatIndicator 186,PropContentType "6V\EM\155.\151@,\150\172\218\CANpA\129\DEL",PropResponseInformation "\DC2j\193\r9\225\SUB\151\242\182\&6\211\158\237\194Q\142\&8r\194\255\167\166\RS\219\245XZg\215",PropAuthenticationMethod "x",PropMessageExpiryInterval 8608,PropResponseTopic "a\ACK\168\EM\218\\u\STXQ\226\SI,AO\158_!\ENQ\203",PropSubscriptionIdentifierAvailable 157,PropMaximumQoS 60,PropServerKeepAlive 20958,PropSharedSubscriptionAvailable 131,PropUserProperty "\215\&7\250\fS-\SI" "\227\249\215\206\205h\143\132\&0O5\247(\197\168\128{x",PropReceiveMaximum 19818,PropAuthenticationMethod "\v\184\&1\136R\164\245\208z\143\214\143#\252\159\129\221*I\189\150",PropTopicAlias 17514,PropAuthenticationData "\150\200\nX.\180yZV`\220\154",PropResponseInformation "\215"]}), _cleanSession = True, _keepAlive = 13547, _connID = "r\251\173\&4c\162{\179\188\SO\213\162/\US\158ej\186\DC43\174\157\&4(u\213\US\164E", _properties = [PropAuthenticationData "\DC4\195\a\137\252\139\139\170",PropTopicAliasMaximum 20467,PropServerReference "~\210v\151\253ca\DLEz>\173\193\244\237\189\150\a\224 \ACK",PropTopicAlias 7863,PropSubscriptionIdentifier 19,PropPayloadFormatIndicator 248,PropRequestResponseInformation 182,PropResponseTopic "\236\131T7\252\&7\DC4\r\219\153\DC4jD\246\vr\224\158\229\248\136L?\187wL\167",PropPayloadFormatIndicator 88,PropMaximumPacketSize 32441]} +TEST(Connect5QCTest, Encode17) { +uint8_t pkt[] = {0x10, 0xb0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb6, 0x34, 0xeb, 0x53, 0x16, 0x0, 0x8, 0x14, 0xc3, 0x7, 0x89, 0xfc, 0x8b, 0x8b, 0xaa, 0x22, 0x4f, 0xf3, 0x1c, 0x0, 0x14, 0x7e, 0xd2, 0x76, 0x97, 0xfd, 0x63, 0x61, 0x10, 0x7a, 0x3e, 0xad, 0xc1, 0xf4, 0xed, 0xbd, 0x96, 0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, 0xbf, 0x3e, 0x42, 0xd8, 0xaf, 0xb0, 0xd, 0xd1, 0x23, 0xbb, 0xa3}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x14, 0xc3, 0x7, 0x89, 0xfc, 0x8b, 0x8b, 0xaa}; + uint8_t bytesprops1[] = {0x7e, 0xd2, 0x76, 0x97, 0xfd, 0x63, 0x61, 0x10, 0x7a, 0x3e, 0xad, 0xc1, 0xf4, 0xed, 0xbd, 0x96, 0x7, 0xe0, 0x20, 0x6}; + uint8_t bytesprops2[] = {0xec, 0x83, 0x54, 0x37, 0xfc, 0x37, 0x14, 0xd, 0xdb, 0x99, 0x14, 0x6a, 0x44, 0xf6, 0xb, 0x72, 0xe0, 0x9e, 0xe5, 0xf8, 0x88, 0x4c, 0x3f, 0xbb, 0x77, 0x4c, 0xa7}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8113}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7510}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28415}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20467}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7863}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32441}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xa2, 0xa6}; - uint8_t byteswillprops1[] = {0xf2, 0x1e, 0x56, 0xd6, 0x99, 0x6, 0xbd, 0x8e, 0xe3, 0xad, 0xde, 0x94, 0x36, 0xd0, 0x89}; - uint8_t byteswillprops3[] = {0x94, 0x6, 0xbf, 0x21, 0x5c, 0x65, 0x84, 0x1c, 0xad, 0xe3, 0x0, - 0x73, 0xfa, 0xdd, 0x54, 0x5a, 0xcd, 0x54, 0xb, 0x41, 0x13, 0x2f}; - uint8_t byteswillprops2[] = {0xe2, 0x42}; - uint8_t byteswillprops4[] = {0x72, 0xe, 0x42, 0x2}; - uint8_t byteswillprops5[] = {0xdb, 0x36, 0xbb, 0xc9, 0xa9, 0x6a, 0xfd, 0x5, 0x52}; - uint8_t byteswillprops6[] = {0xcb, 0x7a, 0xf1, 0x4e, 0xba, 0x8b, 0xd7, 0xbb, 0xc4, 0xbd}; - uint8_t byteswillprops7[] = {0xf0, 0xeb, 0xa, 0xe0, 0xd, 0xc7, 0xde, 0x65, 0x83, 0xbf, 0x44, 0x39, 0x44, 0x52, 0x6b}; - uint8_t byteswillprops9[] = {0x49, 0xe2, 0xe7, 0xba, 0xb5, 0xd6, 0x9b}; - uint8_t byteswillprops8[] = {0x42, 0xbd, 0x1e, 0x86, 0xad, 0x25, 0x7d, 0xf, 0x59, - 0xdc, 0xd9, 0xd7, 0xb8, 0x99, 0x7, 0x68, 0x62, 0x7a}; - + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x19, 0x4b, 0x1, 0x13, 0xca, 0x33, 0x9a, 0x91, 0x91, 0x5e, 0xdd, 0xc, 0x2b, 0x86, 0x2d, 0xae, 0xf9, 0x74, 0xd6}; + uint8_t byteswillprops1[] = {0xfc, 0x1c, 0x2a, 0x2c, 0x6d, 0x19, 0x9f, 0x66, 0x58, 0xe2, 0xaf, 0x29}; + uint8_t byteswillprops2[] = {0x2d, 0x24, 0xbe, 0x75, 0xd0, 0xc, 0xb3, 0x85, 0x2b, 0x69, 0x2b, 0xac, 0xd5, 0xe3, 0x71, 0xdc, 0x1c, 0x9d, 0xd9, 0x7e, 0xa2, 0x12, 0xc2, 0x55, 0xee, 0x39, 0x8, 0x6c, 0xae, 0x2f}; + uint8_t byteswillprops3[] = {0x36, 0x56, 0x19, 0x9b, 0x2e, 0x97, 0x40, 0x2c, 0x96, 0xac, 0xda, 0x18, 0x70, 0x41, 0x81, 0x7f}; + uint8_t byteswillprops4[] = {0x12, 0x6a, 0xc1, 0xd, 0x39, 0xe1, 0x1a, 0x97, 0xf2, 0xb6, 0x36, 0xd3, 0x9e, 0xed, 0xc2, 0x51, 0x8e, 0x38, 0x72, 0xc2, 0xff, 0xa7, 0xa6, 0x1e, 0xdb, 0xf5, 0x58, 0x5a, 0x67, 0xd7}; + uint8_t byteswillprops5[] = {0x78}; + uint8_t byteswillprops6[] = {0x61, 0x6, 0xa8, 0x19, 0xda, 0x5c, 0x75, 0x2, 0x51, 0xe2, 0xf, 0x2c, 0x41, 0x4f, 0x9e, 0x5f, 0x21, 0x5, 0xcb}; + uint8_t byteswillprops8[] = {0xe3, 0xf9, 0xd7, 0xce, 0xcd, 0x68, 0x8f, 0x84, 0x30, 0x4f, 0x35, 0xf7, 0x28, 0xc5, 0xa8, 0x80, 0x7b, 0x78}; + uint8_t byteswillprops7[] = {0xd7, 0x37, 0xfa, 0xc, 0x53, 0x2d, 0xf}; + uint8_t byteswillprops9[] = {0xb, 0xb8, 0x31, 0x88, 0x52, 0xa4, 0xf5, 0xd0, 0x7a, 0x8f, 0xd6, 0x8f, 0x23, 0xfc, 0x9f, 0x81, 0xdd, 0x2a, 0x49, 0xbd, 0x96}; + uint8_t byteswillprops10[] = {0x96, 0xc8, 0xa, 0x58, 0x2e, 0xb4, 0x79, 0x5a, 0x56, 0x60, 0xdc, 0x9a}; + uint8_t byteswillprops11[] = {0xd7}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19038}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28927}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {2, (char*)&byteswillprops2}, .v = {22, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29995}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16658}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12740}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1507}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14889}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15043}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26334}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23369}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {18, (char*)&byteswillprops8}, .v = {7, (char*)&byteswillprops9}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1596}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 99}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29786}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8608}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20958}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={7, (char*)&byteswillprops7}, .v={18, (char*)&byteswillprops8}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19818}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17514}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&byteswillprops11}}}, }; - lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x93, 0x2e, 0x92, 0xf6, 0xcb, 0x27, 0x96, 0x5d, 0x42, 0x19, 0x59, 0x17, - 0x1d, 0x9, 0x4d, 0xa6, 0x71, 0xc4, 0x75, 0x67, 0x10, 0x9, 0xbf, 0x42}; + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2c, 0x52, 0xa6, 0x2c, 0xe7, 0x64, 0xbe, 0x54, 0x5c, 0x34, 0xc, 0x98, 0x73, 0x5, 0xd6, 0xbc, 0x9f, 0xf2, 0xc8, 0x2, 0xd4, 0x79, 0x58, 0xed}; lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe4, 0xa4, 0xf0, 0x72, 0xb8, 0xf5, 0xc9, 0x12, 0x23, 0x39, 0x48, 0x98, 0x17, - 0xbc, 0xf1, 0xd9, 0xca, 0xba, 0xcb, 0xc5, 0x44, 0xdc, 0xa2, 0x34, 0xd5}; - lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 28532; - uint8_t client_id_bytes[] = {0x79, 0xf5, 0x82, 0x46, 0x46, 0x23, 0x5c, 0x5b, 0xe3, 0x30}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x48, 0xb0, 0x13, 0x82, 0xb0, 0x40, 0x84, 0xd2}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xc6, 0xf8, 0x1f, 0x17, 0x8f, 0xae, 0x4a, 0x43, 0x54, 0x7f, 0xdd, - 0x61, 0xd3, 0xdd, 0x3b, 0xb3, 0x80, 0xb6, 0x9a, 0xcf, 0xbd, 0x6f}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\232\220\210", _password = Just -// "Q\222\CAN\156\222j\201*\143\147\STX\155\152P\n\166#\139", _lastWill = Just (LastWill {_willRetain = False, _willQoS -// = QoS2, _willTopic = "\NAK\166\247\190f\227\STX", _willMsg = -// "Pu4\232\181\200\&73\211\251l\247WIl\248g\236i\218\139\136\182\208\241!\195\244\162", _willProps = -// [PropAssignedClientIdentifier "\179\229\155(5)\221Vb\198I\"\142\239Nn\210\ESC\209-\ESCa",PropServerReference -// "\ESC\176x\EOT\239^r\v\242",PropWildcardSubscriptionAvailable 237,PropSubscriptionIdentifier -// 14,PropAuthenticationData -// "\145\231\151\ACK\174\232\212\178\DC3v\EOT\150\129B\215c\212\193c\DELd\137",PropMessageExpiryInterval 8788]}), -// _cleanSession = False, _keepAlive = 16792, _connID = "\144\154@\235\163ha\251\SO\244\151\244\235", _properties = -// [PropReasonString -// "\153\252\153\234\157\229lb\GS\201\f#d\239\DC2|Y\v\244\174\237\DC4\136\168\233A\148\220\143",PropServerKeepAlive -// 4154,PropTopicAlias 807,PropAssignedClientIdentifier "\SO;{>\RS\183}\239\229tL\200\147\242k5M",PropReasonString -// "+\r6\ETXV\214",PropSubscriptionIdentifier 10,PropResponseTopic -// "=G\163\128\221\STX\160\208\190]\DEL",PropMessageExpiryInterval 15432,PropMaximumPacketSize 7769,PropServerKeepAlive -// 18572,PropUserProperty "\215d\164\215\246LY\134\176\138\220" -// "q\199\EM\134\ETB\143\133\173\242U\224\&5\243\159\SO\144\CANi",PropContentType -// "\213(\"\163\159\144\214\129~\DEL\188nt$\236J\187:\130@\253\n\150\131;Cq",PropServerKeepAlive -// 23472,PropAuthenticationData "!w",PropSessionExpiryInterval 18606,PropSubscriptionIdentifierAvailable -// 170,PropMessageExpiryInterval 32525,PropSessionExpiryInterval 16843,PropMaximumQoS 235,PropMaximumPacketSize -// 1603,PropAuthenticationMethod "\STX\245\226\t",PropSharedSubscriptionAvailable 59,PropUserProperty -// "\240\212\181\250\165\139\166\129\219\192\195x;\249\133\ACK\220@\157O\183\161\227\DC4\140" -// "\241+\165S\140\231",PropSubscriptionIdentifier 8]} -TEST(Connect5QCTest, Encode15) { - uint8_t pkt[] = { - 0x10, 0x93, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x41, 0x98, 0xef, 0x1, 0x1f, 0x0, 0x1d, 0x99, - 0xfc, 0x99, 0xea, 0x9d, 0xe5, 0x6c, 0x62, 0x1d, 0xc9, 0xc, 0x23, 0x64, 0xef, 0x12, 0x7c, 0x59, 0xb, 0xf4, 0xae, - 0xed, 0x14, 0x88, 0xa8, 0xe9, 0x41, 0x94, 0xdc, 0x8f, 0x13, 0x10, 0x3a, 0x23, 0x3, 0x27, 0x12, 0x0, 0x11, 0xe, - 0x3b, 0x7b, 0x3e, 0x1e, 0xb7, 0x7d, 0xef, 0xe5, 0x74, 0x4c, 0xc8, 0x93, 0xf2, 0x6b, 0x35, 0x4d, 0x1f, 0x0, 0x6, - 0x2b, 0xd, 0x36, 0x3, 0x56, 0xd6, 0xb, 0xa, 0x8, 0x0, 0xb, 0x3d, 0x47, 0xa3, 0x80, 0xdd, 0x2, 0xa0, 0xd0, - 0xbe, 0x5d, 0x7f, 0x2, 0x0, 0x0, 0x3c, 0x48, 0x27, 0x0, 0x0, 0x1e, 0x59, 0x13, 0x48, 0x8c, 0x26, 0x0, 0xb, - 0xd7,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0x4, 0xef, 0x5e, - 0x72, 0xb, 0xf2, 0x28, 0xed, 0xb, 0xe, 0x16, 0x0, 0x16, 0x91, 0xe7, 0x97, 0x6, 0xae, 0xe8, 0xd4, 0xb2, 0x13, - 0x76, 0x4, 0x96, 0x81, 0x42, 0xd7, 0x63, 0xd4, 0xc1, 0x63, 0x7f, 0x64, 0x89, 0x2, 0x0, 0x0, 0x22, 0x54, 0x0, - 0x7, 0x15, 0xa6, 0xf7, 0xbe, 0x66, 0xe3, 0x2, 0x0, 0x1d, 0x50, 0x75, 0x34, 0xe8, 0xb5, 0xc8, 0x37, 0x33, 0xd3, - 0xfb, 0x6c, 0xf7, 0x57, 0x49, 0x6c, 0xf8, 0x67, 0xec, 0x69, 0xda, 0x8b, 0x88, 0xb6, 0xd0, 0xf1, 0x21, 0xc3, 0xf4, - 0xa2, 0x0, 0x3, 0xe8, 0xdc, 0xd2, 0x0, 0x12, 0x51, 0xde, 0x18, 0x9c, 0xde, 0x6a, 0xc9, 0x2a, 0x8f, 0x93, 0x2, - 0x9b, 0x98, 0x50, 0xa, 0xa6, 0x23, 0x8b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x99, 0xfc, 0x99, 0xea, 0x9d, 0xe5, 0x6c, 0x62, 0x1d, 0xc9, 0xc, 0x23, 0x64, 0xef, 0x12, - 0x7c, 0x59, 0xb, 0xf4, 0xae, 0xed, 0x14, 0x88, 0xa8, 0xe9, 0x41, 0x94, 0xdc, 0x8f}; - uint8_t bytesprops1[] = {0xe, 0x3b, 0x7b, 0x3e, 0x1e, 0xb7, 0x7d, 0xef, 0xe5, - 0x74, 0x4c, 0xc8, 0x93, 0xf2, 0x6b, 0x35, 0x4d}; - uint8_t bytesprops2[] = {0x2b, 0xd, 0x36, 0x3, 0x56, 0xd6}; - uint8_t bytesprops3[] = {0x3d, 0x47, 0xa3, 0x80, 0xdd, 0x2, 0xa0, 0xd0, 0xbe, 0x5d, 0x7f}; - uint8_t bytesprops5[] = {0x71, 0xc7, 0x19, 0x86, 0x17, 0x8f, 0x85, 0xad, 0xf2, - 0x55, 0xe0, 0x35, 0xf3, 0x9f, 0xe, 0x90, 0x18, 0x69}; - uint8_t bytesprops4[] = {0xd7, 0x64, 0xa4, 0xd7, 0xf6, 0x4c, 0x59, 0x86, 0xb0, 0x8a, 0xdc}; - uint8_t bytesprops6[] = {0xd5, 0x28, 0x22, 0xa3, 0x9f, 0x90, 0xd6, 0x81, 0x7e, 0x7f, 0xbc, 0x6e, 0x74, 0x24, - 0xec, 0x4a, 0xbb, 0x3a, 0x82, 0x40, 0xfd, 0xa, 0x96, 0x83, 0x3b, 0x43, 0x71}; - uint8_t bytesprops7[] = {0x21, 0x77}; - uint8_t bytesprops8[] = {0x2, 0xf5, 0xe2, 0x9}; - uint8_t bytesprops10[] = {0xf1, 0x2b, 0xa5, 0x53, 0x8c, 0xe7}; - uint8_t bytesprops9[] = {0xf0, 0xd4, 0xb5, 0xfa, 0xa5, 0x8b, 0xa6, 0x81, 0xdb, 0xc0, 0xc3, 0x78, 0x3b, - 0xf9, 0x85, 0x6, 0xdc, 0x40, 0x9d, 0x4f, 0xb7, 0xa1, 0xe3, 0x14, 0x8c}; - + uint8_t will_payload_bytes[] = {0x47, 0xf2, 0x52, 0x21, 0x79, 0x55, 0x9d, 0x81, 0x63, 0xa6}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 13547; + uint8_t client_id_bytes[] = {0x72, 0xfb, 0xad, 0x34, 0x63, 0xa2, 0x7b, 0xb3, 0xbc, 0xe, 0xd5, 0xa2, 0x2f, 0x1f, 0x9e, 0x65, 0x6a, 0xba, 0x14, 0x33, 0xae, 0x9d, 0x34, 0x28, 0x75, 0xd5, 0x1f, 0xa4, 0x45}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x2d, 0x5c, 0x1f, 0xbf, 0x3e, 0x42, 0xd8, 0xaf, 0xb0, 0xd, 0xd1, 0x23, 0xbb, 0xa3}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// ConnectRequest {_username = Just "\232g\222\&1\254\EM\195}\FS\159h\255\DC4J\131:\250\139\243\245L\SYN\132\237\145\218l\149\147D", _password = Just "\216\SYN", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\RScg\195\250\136\246\225\255\166Lm\165\206\183\159", _willMsg = "\222\238\244.\139OJ", _willProps = [PropAuthenticationMethod "\226\222\ENQ\183\159\153{\172",PropMessageExpiryInterval 27045,PropServerReference "\EM\215\133",PropWillDelayInterval 27246,PropRequestResponseInformation 32,PropMaximumPacketSize 5739,PropContentType "\ETB\200\133}\199\192\185\154\215\189zH\208\200\148\DLEef",PropSubscriptionIdentifierAvailable 126,PropWillDelayInterval 27782,PropAssignedClientIdentifier "\SUB\200\204\249\153\NAK\208\160&\DC2|\t{I\220}\174",PropWillDelayInterval 2942,PropServerReference "|\137f\208\164Y"]}), _cleanSession = True, _keepAlive = 24226, _connID = "\171!\155o/ F\SO\201\168\DLE~\DC4*", _properties = [PropSharedSubscriptionAvailable 193,PropServerReference "|>\135\195Ne\DC4\rZ\195\149\\M+\222\229\233Z\205\250!\166\203\ENQ;H\163\237\160\193",PropReasonString "",PropServerKeepAlive 13435,PropResponseInformation "G^|\US,",PropRequestResponseInformation 100,PropMessageExpiryInterval 16479,PropMaximumQoS 141,PropSharedSubscriptionAvailable 7,PropResponseInformation "%",PropAssignedClientIdentifier "G\143e\243\ENQ\140v\130\184\GS\166ZP\165\167\ETX",PropMaximumPacketSize 4489,PropAssignedClientIdentifier "\SOH{8\SI\SOH\145\198\189\n",PropUserProperty "\FS\a(\221\vhE\SYN\171\203\&6w\130\RS<" "\ETX\205\187\187\219\&8\159$\153\DC20^\253u\198\149\176\DLE\203I&\241\250\197\171\176",PropReasonString "\223\227\225",PropSessionExpiryInterval 2978,PropUserProperty "\226\225\229\235\CANlF\139\194\129\218uo" "\SI\197t\226\173m^#\217*+\141\153\236\GS\185/\166\242&\167d\152,\216\a\245\231\&2",PropWillDelayInterval 21460,PropContentType "[h",PropMessageExpiryInterval 21321,PropWillDelayInterval 26395,PropPayloadFormatIndicator 242,PropContentType "\RS`"]} +TEST(Connect5QCTest, Encode18) { +uint8_t pkt[] = {0x10, 0xa3, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x5e, 0xa2, 0xe7, 0x1, 0x2a, 0xc1, 0x1c, 0x0, 0x1e, 0x7c, 0x3e, 0x87, 0xc3, 0x4e, 0x65, 0x14, 0xd, 0x5a, 0xc3, 0x95, 0x5c, 0x4d, 0x2b, 0xde, 0xe5, 0xe9, 0x5a, 0xcd, 0xfa, 0x21, 0xa6, 0xcb, 0x5, 0x3b, 0x48, 0xa3, 0xed, 0xa0, 0xc1, 0x1f, 0x0, 0x0, 0x13, 0x34, 0x7b, 0x1a, 0x0, 0x5, 0x47, 0x5e, 0x7c, 0x1f, 0x2c, 0x19, 0x64, 0x2, 0x0, 0x0, 0x40, 0x5f, 0x24, 0x8d, 0x2a, 0x7, 0x1a, 0x0, 0x1, 0x25, 0x12, 0x0, 0x10, 0x47, 0x8f, 0x65, 0xf3, 0x5, 0x8c, 0x76, 0x82, 0xb8, 0x1d, 0xa6, 0x5a, 0x50, 0xa5, 0xa7, 0x3, 0x27, 0x0, 0x0, 0x11, 0x89, 0x12, 0x0, 0x9, 0x1, 0x7b, 0x38, 0xf,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12, 0x17, 0xc8, 0x85, 0x7d, 0xc7, 0xc0, 0xb9, 0x9a, 0xd7, 0xbd, 0x7a, 0x48, 0xd0, 0xc8, 0x94, 0x10, 0x65, 0x66, 0x29, 0x7e, 0x18, 0x0, 0x0, 0x6c, 0x86, 0x12, 0x0, 0x11, 0x1a, 0xc8, 0xcc, 0xf9, 0x99, 0x15, 0xd0, 0xa0, 0x26, 0x12, 0x7c, 0x9, 0x7b, 0x49, 0xdc, 0x7d, 0xae, 0x18, 0x0, 0x0, 0xb, 0x7e, 0x1c, 0x0, 0x6, 0x7c, 0x89, 0x66, 0xd0, 0xa4, 0x59, 0x0, 0x10, 0x1e, 0x63, 0x67, 0xc3, 0xfa, 0x88, 0xf6, 0xe1, 0xff, 0xa6, 0x4c, 0x6d, 0xa5, 0xce, 0xb7, 0x9f, 0x0, 0x7, 0xde, 0xee, 0xf4, 0x2e, 0x8b, 0x4f, 0x4a, 0x0, 0x1e, 0xe8, 0x67, 0xde, 0x31, 0xfe, 0x19, 0xc3, 0x7d, 0x1c, 0x9f, 0x68, 0xff, 0x14, 0x4a, 0x83, 0x3a, 0xfa, 0x8b, 0xf3, 0xf5, 0x4c, 0x16, 0x84, 0xed, 0x91, 0xda, 0x6c, 0x95, 0x93, 0x44, 0x0, 0x2, 0xd8, 0x16}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x7c, 0x3e, 0x87, 0xc3, 0x4e, 0x65, 0x14, 0xd, 0x5a, 0xc3, 0x95, 0x5c, 0x4d, 0x2b, 0xde, 0xe5, 0xe9, 0x5a, 0xcd, 0xfa, 0x21, 0xa6, 0xcb, 0x5, 0x3b, 0x48, 0xa3, 0xed, 0xa0, 0xc1}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x47, 0x5e, 0x7c, 0x1f, 0x2c}; + uint8_t bytesprops3[] = {0x25}; + uint8_t bytesprops4[] = {0x47, 0x8f, 0x65, 0xf3, 0x5, 0x8c, 0x76, 0x82, 0xb8, 0x1d, 0xa6, 0x5a, 0x50, 0xa5, 0xa7, 0x3}; + uint8_t bytesprops5[] = {0x1, 0x7b, 0x38, 0xf, 0x1, 0x91, 0xc6, 0xbd, 0xa}; + uint8_t bytesprops7[] = {0x3, 0xcd, 0xbb, 0xbb, 0xdb, 0x38, 0x9f, 0x24, 0x99, 0x12, 0x30, 0x5e, 0xfd, 0x75, 0xc6, 0x95, 0xb0, 0x10, 0xcb, 0x49, 0x26, 0xf1, 0xfa, 0xc5, 0xab, 0xb0}; + uint8_t bytesprops6[] = {0x1c, 0x7, 0x28, 0xdd, 0xb, 0x68, 0x45, 0x16, 0xab, 0xcb, 0x36, 0x77, 0x82, 0x1e, 0x3c}; + uint8_t bytesprops8[] = {0xdf, 0xe3, 0xe1}; + uint8_t bytesprops10[] = {0xf, 0xc5, 0x74, 0xe2, 0xad, 0x6d, 0x5e, 0x23, 0xd9, 0x2a, 0x2b, 0x8d, 0x99, 0xec, 0x1d, 0xb9, 0x2f, 0xa6, 0xf2, 0x26, 0xa7, 0x64, 0x98, 0x2c, 0xd8, 0x7, 0xf5, 0xe7, 0x32}; + uint8_t bytesprops9[] = {0xe2, 0xe1, 0xe5, 0xeb, 0x18, 0x6c, 0x46, 0x8b, 0xc2, 0x81, 0xda, 0x75, 0x6f}; + uint8_t bytesprops11[] = {0x5b, 0x68}; + uint8_t bytesprops12[] = {0x1e, 0x60}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4154}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 807}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15432}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7769}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18572}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops4}, .v = {18, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23472}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18606}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32525}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16843}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1603}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops9}, .v = {6, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13435}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16479}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4489}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={15, (char*)&bytesprops6}, .v={26, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2978}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={13, (char*)&bytesprops9}, .v={29, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21460}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21321}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26395}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops12}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xb3, 0xe5, 0x9b, 0x28, 0x35, 0x29, 0xdd, 0x56, 0x62, 0xc6, 0x49, - 0x22, 0x8e, 0xef, 0x4e, 0x6e, 0xd2, 0x1b, 0xd1, 0x2d, 0x1b, 0x61}; - uint8_t byteswillprops1[] = {0x1b, 0xb0, 0x78, 0x4, 0xef, 0x5e, 0x72, 0xb, 0xf2}; - uint8_t byteswillprops2[] = {0x91, 0xe7, 0x97, 0x6, 0xae, 0xe8, 0xd4, 0xb2, 0x13, 0x76, 0x4, - 0x96, 0x81, 0x42, 0xd7, 0x63, 0xd4, 0xc1, 0x63, 0x7f, 0x64, 0x89}; - + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xe2, 0xde, 0x5, 0xb7, 0x9f, 0x99, 0x7b, 0xac}; + uint8_t byteswillprops1[] = {0x19, 0xd7, 0x85}; + uint8_t byteswillprops2[] = {0x17, 0xc8, 0x85, 0x7d, 0xc7, 0xc0, 0xb9, 0x9a, 0xd7, 0xbd, 0x7a, 0x48, 0xd0, 0xc8, 0x94, 0x10, 0x65, 0x66}; + uint8_t byteswillprops3[] = {0x1a, 0xc8, 0xcc, 0xf9, 0x99, 0x15, 0xd0, 0xa0, 0x26, 0x12, 0x7c, 0x9, 0x7b, 0x49, 0xdc, 0x7d, 0xae}; + uint8_t byteswillprops4[] = {0x7c, 0x89, 0x66, 0xd0, 0xa4, 0x59}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8788}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27045}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27246}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5739}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27782}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2942}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&byteswillprops4}}}, }; - lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x15, 0xa6, 0xf7, 0xbe, 0x66, 0xe3, 0x2}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x50, 0x75, 0x34, 0xe8, 0xb5, 0xc8, 0x37, 0x33, 0xd3, 0xfb, - 0x6c, 0xf7, 0x57, 0x49, 0x6c, 0xf8, 0x67, 0xec, 0x69, 0xda, - 0x8b, 0x88, 0xb6, 0xd0, 0xf1, 0x21, 0xc3, 0xf4, 0xa2}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 16792; - uint8_t client_id_bytes[] = {0x90, 0x9a, 0x40, 0xeb, 0xa3, 0x68, 0x61, 0xfb, 0xe, 0xf4, 0x97, 0xf4, 0xeb}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xe8, 0xdc, 0xd2}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x51, 0xde, 0x18, 0x9c, 0xde, 0x6a, 0xc9, 0x2a, 0x8f, - 0x93, 0x2, 0x9b, 0x98, 0x50, 0xa, 0xa6, 0x23, 0x8b}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1e, 0x63, 0x67, 0xc3, 0xfa, 0x88, 0xf6, 0xe1, 0xff, 0xa6, 0x4c, 0x6d, 0xa5, 0xce, 0xb7, 0x9f}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xde, 0xee, 0xf4, 0x2e, 0x8b, 0x4f, 0x4a}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 24226; + uint8_t client_id_bytes[] = {0xab, 0x21, 0x9b, 0x6f, 0x2f, 0x20, 0x46, 0xe, 0xc9, 0xa8, 0x10, 0x7e, 0x14, 0x2a}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xe8, 0x67, 0xde, 0x31, 0xfe, 0x19, 0xc3, 0x7d, 0x1c, 0x9f, 0x68, 0xff, 0x14, 0x4a, 0x83, 0x3a, 0xfa, 0x8b, 0xf3, 0xf5, 0x4c, 0x16, 0x84, 0xed, 0x91, 0xda, 0x6c, 0x95, 0x93, 0x44}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0xd8, 0x16}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\208\&08\153\253\129\180\139MgC\ACKe\252k\131\238w\f\234\212", _password = Just -// "\174\131\134S\237\RS", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "oa\v,+\129{\223N\216\&2}\SI\161-\165a\146\&7\248\166\224\189\SOH\ESC\182", _willMsg = "m]", _willProps = -// [PropMessageExpiryInterval 7966,PropReceiveMaximum 11454,PropTopicAliasMaximum 24638,PropCorrelationData -// "p\175>\180\160\170",PropCorrelationData "r\194\&1",PropResponseTopic "\134\DC4\197Knd -// \164n\NULU\194F!#\247*\151,\EM\184\249\CAN(\174.",PropRequestResponseInformation 39,PropWildcardSubscriptionAvailable -// 177,PropSubscriptionIdentifier 5,PropRequestResponseInformation 9,PropSubscriptionIdentifier -// 19,PropRequestProblemInformation 250,PropMaximumQoS 197,PropRequestProblemInformation 121,PropTopicAliasMaximum -// 28781,PropPayloadFormatIndicator 13,PropRequestResponseInformation 188,PropUserProperty "I~i\190\250" -// "\247\151\212\245=/P\218\160\218\DC2\186\232P\220\151n\STXW+\140\132l\221P\137\191Hn\173\243\209\180\171\208\128\CAN?Ii\FS#" -// "\GS\194>g\216yKl:\210@\f!\ESC.\201\130F\a\198\137??{\EOT9\200\235\ESC\211",PropMessageExpiryInterval -// 4108,PropRequestResponseInformation 206,PropTopicAliasMaximum 1362,PropMessageExpiryInterval 20063,PropUserProperty -// "\a\245\144%?!\255\206\199\227g" "\195_\203\179-\241\207\137\&27\135",PropSessionExpiryInterval -// 2669,PropRequestResponseInformation 237,PropUserProperty -// "\216\228\164\208\222\234m4\200\156\\\SUB\176\252\167>\227\217\SOH\252f\185\186/\245\220l.=\233" -// "\212\206v\243\&0\235g\200\250\188\207P\ETB\130\167\137@(\191_\139\DC3}\238\227",PropServerKeepAlive -// 13533,PropResponseInformation "\151\195\168\188?\165}",PropContentType -// "\182\152!\SO\214\245\202\210\FS&",PropMessageExpiryInterval 14172]}), _cleanSession = False, _keepAlive = 6602, -// _connID = "%\197u\242|QM/\NUL\239\144\a\176\173\138\248\143\&0>8", _properties = [PropMessageExpiryInterval -// 3109,PropSubscriptionIdentifier 11,PropWildcardSubscriptionAvailable 69,PropWildcardSubscriptionAvailable -// 86,PropContentType "\254B\140\166M\249F\180\b\DC1\168\f\234L\160}R9\235\156Fr\150",PropReceiveMaximum -// 10259,PropTopicAlias 18041,PropMessageExpiryInterval 29565,PropContentType -// "\DC1\ETB\251\238\242\222\186f\209\STX\197\US\239:P[W\222\&9\238-",PropMessageExpiryInterval -// 2224,PropSubscriptionIdentifierAvailable 181,PropWildcardSubscriptionAvailable 82,PropWillDelayInterval -// 17653,PropWillDelayInterval 32460,PropUserProperty -// "k\224`c\182a\166\232\&2\179\209\150\145\220\DLE~\213k\SI\177\138N\157m\211q\247\182\178O" -// "\244\204{\211\152\222\198Y\231M5NT\244\203\b9\129\CAN\254\RSS\t\242\222\140\160O\148\223",PropMaximumQoS -// 148,PropReceiveMaximum 1807,PropServerReference "\173\180\137",PropAuthenticationMethod -// ",\161\144",PropPayloadFormatIndicator 93,PropResponseInformation "\208nX~",PropPayloadFormatIndicator -// 225,PropMessageExpiryInterval 28847]} -TEST(Connect5QCTest, Encode17) { - uint8_t pkt[] = { - 0x10, 0xdb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x44, 0x19, 0xca, 0xbd, 0x1, 0x2, 0x0, 0x0, 0xc, - 0x25, 0xb, 0xb, 0x28, 0x45, 0x28, 0x56, 0x3, 0x0, 0x17, 0xfe, 0x42, 0x8c, 0xa6, 0x4d, 0xf9, 0x46, 0xb4, 0x8, - 0x11, 0xa8, 0xc, 0xea, 0x4c, 0xa0, 0x7d, 0x52, 0x39, 0xeb, 0x9c, 0x46, 0x72, 0x96, 0x21, 0x28, 0x13, 0x23, 0x46, - 0x79, 0x2, 0x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, 0x0, 0x37, 0x5c, 0x0, 0x14, 0x81, 0x33, - 0xa4, 0xf, 0x5f, 0x8d, 0x62, 0x73, 0xab, 0xf7, 0xa3, 0x76, 0x9f, 0xb5, 0x96, 0x54, 0xb4, 0x88, 0x41, 0x7a, 0x0, - 0x11, 0x20, 0x2f, 0xbd, 0x8d, 0x44, 0xb3, 0x8b, 0x8c, 0xdf, 0xd3, 0x3a, 0x41, 0xdb, 0xcd, 0x46, 0x75, 0x11, 0x0, - 0x2, 0xbc, 0x81}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xfe, 0x42, 0x8c, 0xa6, 0x4d, 0xf9, 0x46, 0xb4, 0x8, 0x11, 0xa8, 0xc, - 0xea, 0x4c, 0xa0, 0x7d, 0x52, 0x39, 0xeb, 0x9c, 0x46, 0x72, 0x96}; - uint8_t bytesprops1[] = {0x11, 0x17, 0xfb, 0xee, 0xf2, 0xde, 0xba, 0x66, 0xd1, 0x2, 0xc5, - 0x1f, 0xef, 0x3a, 0x50, 0x5b, 0x57, 0xde, 0x39, 0xee, 0x2d}; - uint8_t bytesprops3[] = {0xf4, 0xcc, 0x7b, 0xd3, 0x98, 0xde, 0xc6, 0x59, 0xe7, 0x4d, 0x35, 0x4e, 0x54, 0xf4, 0xcb, - 0x8, 0x39, 0x81, 0x18, 0xfe, 0x1e, 0x53, 0x9, 0xf2, 0xde, 0x8c, 0xa0, 0x4f, 0x94, 0xdf}; - uint8_t bytesprops2[] = {0x6b, 0xe0, 0x60, 0x63, 0xb6, 0x61, 0xa6, 0xe8, 0x32, 0xb3, 0xd1, 0x96, 0x91, 0xdc, 0x10, - 0x7e, 0xd5, 0x6b, 0xf, 0xb1, 0x8a, 0x4e, 0x9d, 0x6d, 0xd3, 0x71, 0xf7, 0xb6, 0xb2, 0x4f}; - uint8_t bytesprops4[] = {0xad, 0xb4, 0x89}; - uint8_t bytesprops5[] = {0x2c, 0xa1, 0x90}; - uint8_t bytesprops6[] = {0xd0, 0x6e, 0x58, 0x7e}; +// ConnectRequest {_username = Just "\238E\235\195\176i4\ETX\156\201\169\199m\192\SO\135|\184\247", _password = Just "\148!\GS\GS3\143\183\154J\SOF\207+\154$\189\201\133\152\220\230c\213i", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\176\187R!\190\252\137", _willMsg = "\CAN\202\249i\219", _willProps = [PropAuthenticationData "\a\167\247[w%\132",PropMaximumPacketSize 7772,PropRetainAvailable 12,PropUserProperty "W\184\249=-\141\255O\171\135" "\"sR\193",PropWildcardSubscriptionAvailable 189,PropSessionExpiryInterval 32113,PropRequestProblemInformation 100,PropContentType "*",PropPayloadFormatIndicator 34,PropSubscriptionIdentifier 23,PropMessageExpiryInterval 14823,PropSharedSubscriptionAvailable 28,PropPayloadFormatIndicator 105,PropWillDelayInterval 25676,PropSubscriptionIdentifierAvailable 19,PropSubscriptionIdentifierAvailable 139,PropServerReference "\168\226\184UW\a\247u\SOH\189\168\GS\208x\DELr\238\&2\131\136\252\DC1wb@\253\187\216",PropResponseTopic "\139\&3\222\139u\151\EOT\197\227\FS\229\RS&)\228\203.\146\134"]}), _cleanSession = True, _keepAlive = 11619, _connID = ")G\205}(\"\172\143lX\215\SYNQT\CAN7\194\138\RS\DELr3\144\SIn\185\210y", _properties = [PropWillDelayInterval 12505,PropTopicAlias 25947,PropSubscriptionIdentifier 27,PropAuthenticationMethod "\245\232\ENQ\165\ETX_\"M\202^\131\NAK",PropReasonString "5\248\&0`O)Yc\SUB\193%\213k&\194\222\228\162K\CAN\ENQ\rYU\175",PropResponseInformation "\202A\DC3\NUL\183R(\251\165",PropSubscriptionIdentifierAvailable 112,PropMessageExpiryInterval 32467,PropMaximumQoS 119,PropTopicAliasMaximum 1295,PropRequestResponseInformation 31,PropUserProperty "p~\202\210\160\r\232\207\139\190\185Q\\\184\216\EM\205b\206E[C\203U\231R$" "\203\253\162HA\ETB!",PropMessageExpiryInterval 14912,PropResponseTopic "\EOT^\DC4\187\166\157\NAK\SUB\168#\160\FS\192\f\164=\201b",PropReasonString "\RS\ACK\170W",PropSubscriptionIdentifierAvailable 181,PropAuthenticationMethod "p\b\FSb\rR\162\SO\241\212\&4\252\155\141\187\183m\182",PropCorrelationData "",PropReceiveMaximum 13177,PropResponseInformation "{\240\147\201uL\197\198\225\201\163\139\161&\197\SYN\NUL",PropReasonString "9)I7\165\177\139",PropAssignedClientIdentifier "\163Li\247\216\205=\219;\166\186\170\234\186\181\153",PropSubscriptionIdentifier 25,PropReceiveMaximum 31829,PropPayloadFormatIndicator 122,PropCorrelationData "\EM\168M`\160\142j",PropContentType "\194\217\DC4c\131\142\217\205",PropServerKeepAlive 7189,PropMessageExpiryInterval 22850,PropServerKeepAlive 32407]} +TEST(Connect5QCTest, Encode20) { +uint8_t pkt[] = {0x10, 0xf2, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x2d, 0x63, 0x8c, 0x2, 0x18, 0x0, 0x0, 0x30, 0xd9, 0x23, 0x65, 0x5b, 0xb, 0x1b, 0x15, 0x0, 0xc, 0xf5, 0xe8, 0x5, 0xa5, 0x3, 0x5f, 0x22, 0x4d, 0xca, 0x5e, 0x83, 0x15, 0x1f, 0x0, 0x19, 0x35, 0xf8, 0x30, 0x60, 0x4f, 0x29, 0x59, 0x63, 0x1a, 0xc1, 0x25, 0xd5, 0x6b, 0x26, 0xc2, 0xde, 0xe4, 0xa2, 0x4b, 0x18, 0x5, 0xd, 0x59, 0x55, 0xaf, 0x1a, 0x0, 0x9, 0xca, 0x41, 0x13, 0x0, 0xb7, 0x52, 0x28, 0xfb, 0xa5, 0x29, 0x70, 0x2, 0x0, 0x0, 0x7e, 0xd3, 0x24, 0x77, 0x22, 0x5, 0xf, 0x19, 0x1f, 0x26, 0x0, 0x1b, 0x70, 0x7e, 0xca, 0xd2, 0xa0, 0xd, 0xe8, 0xcf, 0x8b, 0xbe, 0xb9, 0x51, 0x5c, 0xb8, 0xd8, 0x19,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0x9a, 0x24, 0xbd, 0xc9, 0x85, 0x98, 0xdc, 0xe6, 0x63, 0xd5, 0x69}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xf5, 0xe8, 0x5, 0xa5, 0x3, 0x5f, 0x22, 0x4d, 0xca, 0x5e, 0x83, 0x15}; + uint8_t bytesprops1[] = {0x35, 0xf8, 0x30, 0x60, 0x4f, 0x29, 0x59, 0x63, 0x1a, 0xc1, 0x25, 0xd5, 0x6b, 0x26, 0xc2, 0xde, 0xe4, 0xa2, 0x4b, 0x18, 0x5, 0xd, 0x59, 0x55, 0xaf}; + uint8_t bytesprops2[] = {0xca, 0x41, 0x13, 0x0, 0xb7, 0x52, 0x28, 0xfb, 0xa5}; + uint8_t bytesprops4[] = {0xcb, 0xfd, 0xa2, 0x48, 0x41, 0x17, 0x21}; + uint8_t bytesprops3[] = {0x70, 0x7e, 0xca, 0xd2, 0xa0, 0xd, 0xe8, 0xcf, 0x8b, 0xbe, 0xb9, 0x51, 0x5c, 0xb8, 0xd8, 0x19, 0xcd, 0x62, 0xce, 0x45, 0x5b, 0x43, 0xcb, 0x55, 0xe7, 0x52, 0x24}; + uint8_t bytesprops5[] = {0x4, 0x5e, 0x14, 0xbb, 0xa6, 0x9d, 0x15, 0x1a, 0xa8, 0x23, 0xa0, 0x1c, 0xc0, 0xc, 0xa4, 0x3d, 0xc9, 0x62}; + uint8_t bytesprops6[] = {0x1e, 0x6, 0xaa, 0x57}; + uint8_t bytesprops7[] = {0x70, 0x8, 0x1c, 0x62, 0xd, 0x52, 0xa2, 0xe, 0xf1, 0xd4, 0x34, 0xfc, 0x9b, 0x8d, 0xbb, 0xb7, 0x6d, 0xb6}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0x7b, 0xf0, 0x93, 0xc9, 0x75, 0x4c, 0xc5, 0xc6, 0xe1, 0xc9, 0xa3, 0x8b, 0xa1, 0x26, 0xc5, 0x16, 0x0}; + uint8_t bytesprops10[] = {0x39, 0x29, 0x49, 0x37, 0xa5, 0xb1, 0x8b}; + uint8_t bytesprops11[] = {0xa3, 0x4c, 0x69, 0xf7, 0xd8, 0xcd, 0x3d, 0xdb, 0x3b, 0xa6, 0xba, 0xaa, 0xea, 0xba, 0xb5, 0x99}; + uint8_t bytesprops12[] = {0x19, 0xa8, 0x4d, 0x60, 0xa0, 0x8e, 0x6a}; + uint8_t bytesprops13[] = {0xc2, 0xd9, 0x14, 0x63, 0x83, 0x8e, 0xd9, 0xcd}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3109}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10259}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18041}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29565}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2224}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17653}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32460}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops2}, .v = {30, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1807}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28847}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12505}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25947}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32467}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1295}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={27, (char*)&bytesprops3}, .v={7, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14912}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13177}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31829}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7189}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22850}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32407}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x1d, 0xc2, 0x3e, 0x67, 0xd8, 0x79, 0x4b, 0x6c, 0x3a, 0xd2, - 0x40, 0xc, 0x21, 0x1b, 0x2e, 0xc9, 0x82, 0x46, 0x7, 0xc6, - 0x89, 0x3f, 0x3f, 0x7b, 0x4, 0x39, 0xc8, 0xeb, 0x1b, 0xd3}; - uint8_t byteswillprops0[] = {0xd2, 0x3e, 0xdc, 0x97, 0x6e, 0x2, 0x57, 0x2b, 0x8c, 0x84, - 0x6c, 0xdd, 0x50, 0x89, 0xbf, 0x48, 0x6e, 0xad, 0xf3, 0xd1, - 0xb4, 0xab, 0xd0, 0x80, 0x18, 0x3f, 0x49, 0x69, 0x1c, 0x23}; - uint8_t byteswillprops3[] = {0xc3, 0x5f, 0xcb, 0xb3, 0x2d, 0xf1, 0xcf, 0x89, 0x32, 0x37, 0x87}; - uint8_t byteswillprops2[] = {0x7, 0xf5, 0x90, 0x25, 0x3f, 0x21, 0xff, 0xce, 0xc7, 0xe3, 0x67}; - uint8_t byteswillprops5[] = {0xd4, 0xce, 0x76, 0xf3, 0x30, 0xeb, 0x67, 0xc8, 0xfa, 0xbc, 0xcf, 0x50, 0x17, - 0x82, 0xa7, 0x89, 0x40, 0x28, 0xbf, 0x5f, 0x8b, 0x13, 0x7d, 0xee, 0xe3}; - uint8_t byteswillprops4[] = {0xd8, 0xe4, 0xa4, 0xd0, 0xde, 0xea, 0x6d, 0x34, 0xc8, 0x9c, - 0x5c, 0x1a, 0xb0, 0xfc, 0xa7, 0x3e, 0xe3, 0xd9, 0x1, 0xfc, - 0x66, 0xb9, 0xba, 0x2f, 0xf5, 0xdc, 0x6c, 0x2e, 0x3d, 0xe9}; - uint8_t byteswillprops6[] = {0x97, 0xc3, 0xa8, 0xbc, 0x3f, 0xa5, 0x7d}; - uint8_t byteswillprops7[] = {0xb6, 0x98, 0x21, 0xe, 0xd6, 0xf5, 0xca, 0xd2, 0x1c, 0x26}; - + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x7, 0xa7, 0xf7, 0x5b, 0x77, 0x25, 0x84}; + uint8_t byteswillprops2[] = {0x22, 0x73, 0x52, 0xc1}; + uint8_t byteswillprops1[] = {0x57, 0xb8, 0xf9, 0x3d, 0x2d, 0x8d, 0xff, 0x4f, 0xab, 0x87}; + uint8_t byteswillprops3[] = {0x2a}; + uint8_t byteswillprops4[] = {0xa8, 0xe2, 0xb8, 0x55, 0x57, 0x7, 0xf7, 0x75, 0x1, 0xbd, 0xa8, 0x1d, 0xd0, 0x78, 0x7f, 0x72, 0xee, 0x32, 0x83, 0x88, 0xfc, 0x11, 0x77, 0x62, 0x40, 0xfd, 0xbb, 0xd8}; + uint8_t byteswillprops5[] = {0x8b, 0x33, 0xde, 0x8b, 0x75, 0x97, 0x4, 0xc5, 0xe3, 0x1c, 0xe5, 0x1e, 0x26, 0x29, 0xe4, 0xcb, 0x2e, 0x92, 0x86}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {30, (char*)&byteswillprops0}, .v = {30, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4108}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1362}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20063}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {11, (char*)&byteswillprops2}, .v = {11, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2669}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {30, (char*)&byteswillprops4}, .v = {25, (char*)&byteswillprops5}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13533}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14172}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7772}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={10, (char*)&byteswillprops1}, .v={4, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32113}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14823}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25676}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops5}}}, }; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x81, 0x33, 0xa4, 0xf, 0x5f, 0x8d, 0x62, 0x73, 0xab, 0xf7, - 0xa3, 0x76, 0x9f, 0xb5, 0x96, 0x54, 0xb4, 0x88, 0x41, 0x7a}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x20, 0x2f, 0xbd, 0x8d, 0x44, 0xb3, 0x8b, 0x8c, 0xdf, - 0xd3, 0x3a, 0x41, 0xdb, 0xcd, 0x46, 0x75, 0x11}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 6602; - uint8_t client_id_bytes[] = {0x25, 0xc5, 0x75, 0xf2, 0x7c, 0x51, 0x4d, 0x2f, 0x0, 0xef, - 0x90, 0x7, 0xb0, 0xad, 0x8a, 0xf8, 0x8f, 0x30, 0x3e, 0x38}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xbc, 0x81}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb0, 0xbb, 0x52, 0x21, 0xbe, 0xfc, 0x89}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x18, 0xca, 0xf9, 0x69, 0xdb}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 11619; + uint8_t client_id_bytes[] = {0x29, 0x47, 0xcd, 0x7d, 0x28, 0x22, 0xac, 0x8f, 0x6c, 0x58, 0xd7, 0x16, 0x51, 0x54, 0x18, 0x37, 0xc2, 0x8a, 0x1e, 0x7f, 0x72, 0x33, 0x90, 0xf, 0x6e, 0xb9, 0xd2, 0x79}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xee, 0x45, 0xeb, 0xc3, 0xb0, 0x69, 0x34, 0x3, 0x9c, 0xc9, 0xa9, 0xc7, 0x6d, 0xc0, 0xe, 0x87, 0x7c, 0xb8, 0xf7}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x94, 0x21, 0x1d, 0x1d, 0x33, 0x8f, 0xb7, 0x9a, 0x4a, 0xe, 0x46, 0xcf, 0x2b, 0x9a, 0x24, 0xbd, 0xc9, 0x85, 0x98, 0xdc, 0xe6, 0x63, 0xd5, 0x69}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// ConnectRequest {_username = Just ";\196\214\158d\DC1\NAK\SUB\139)\218\190\184\241\CANP\STX3V\208&);\255\169\182\226\231`", _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 10023, _connID = "\158\&0\SO\215\199\&6&\NUL\172!u\226\224\240J\178nI", _properties = [PropWildcardSubscriptionAvailable 29,PropRequestProblemInformation 46,PropSharedSubscriptionAvailable 126,PropPayloadFormatIndicator 254,PropWillDelayInterval 20124,PropMessageExpiryInterval 27963]} +TEST(Connect5QCTest, Encode21) { +uint8_t pkt[] = {0x10, 0x50, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x80, 0x27, 0x27, 0x12, 0x28, 0x1d, 0x17, 0x2e, 0x2a, 0x7e, 0x1, 0xfe, 0x18, 0x0, 0x0, 0x4e, 0x9c, 0x2, 0x0, 0x0, 0x6d, 0x3b, 0x0, 0x12, 0x9e, 0x30, 0xe, 0xd7, 0xc7, 0x36, 0x26, 0x0, 0xac, 0x21, 0x75, 0xe2, 0xe0, 0xf0, 0x4a, 0xb2, 0x6e, 0x49, 0x0, 0x1d, 0x3b, 0xc4, 0xd6, 0x9e, 0x64, 0x11, 0x15, 0x1a, 0x8b, 0x29, 0xda, 0xbe, 0xb8, 0xf1, 0x18, 0x50, 0x2, 0x33, 0x56, 0xd0, 0x26, 0x29, 0x3b, 0xff, 0xa9, 0xb6, 0xe2, 0xe7, 0x60}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20124}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27963}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 10023; + uint8_t client_id_bytes[] = {0x9e, 0x30, 0xe, 0xd7, 0xc7, 0x36, 0x26, 0x0, 0xac, 0x21, 0x75, 0xe2, 0xe0, 0xf0, 0x4a, 0xb2, 0x6e, 0x49}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x3b, 0xc4, 0xd6, 0x9e, 0x64, 0x11, 0x15, 0x1a, 0x8b, 0x29, 0xda, 0xbe, 0xb8, 0xf1, 0x18, 0x50, 0x2, 0x33, 0x56, 0xd0, 0x26, 0x29, 0x3b, 0xff, 0xa9, 0xb6, 0xe2, 0xe7, 0x60}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\134\162'b\147r\DC3", _lastWill = Just (LastWill {_willRetain -// = True, _willQoS = QoS0, _willTopic = "\196.\fm\178\&9\240", _willMsg = -// "\229Y\246\171\"\a\231Vp\200\169\156\&5%\n\165\146\ETB\221\209\128\228\231", _willProps = [PropResponseInformation -// "\aN\190\161\RS\197[\\+\148\176\209\250Q\189\ETX5+\225\152\191\173o1\234\240\131",PropSessionExpiryInterval -// 28040,PropCorrelationData "\249w\163\153j\158\143\164\216f\203",PropSharedSubscriptionAvailable 80,PropReceiveMaximum -// 18583,PropTopicAlias 16615,PropTopicAlias 7143,PropWillDelayInterval 22637,PropMaximumQoS 178,PropResponseTopic -// "\181\164\"\EM\212\248{\t\207e\STXa\DLEs\241\251\130\240\135\160M\164I_\186v\SYN0\207",PropSubscriptionIdentifierAvailable -// 168,PropServerReference -// "\145\238\189,\215v\248\191;\250!\135W\ENQ\a\131\134\143x\171\241\t[\194",PropSessionExpiryInterval -// 12339,PropServerKeepAlive 3373,PropRequestProblemInformation 76,PropMaximumQoS 56,PropWildcardSubscriptionAvailable -// 72,PropTopicAlias 23315,PropCorrelationData "\139\243\GSnf\191\f\f<\229\199;\132\253\240",PropContentType -// "?0\255\GS\US\229\135'\161\219_\FSi\225",PropReceiveMaximum 14738,PropReceiveMaximum 9219,PropWillDelayInterval -// 18512,PropRetainAvailable 202,PropMaximumQoS 249]}), _cleanSession = True, _keepAlive = 10739, _connID = "/", -// _properties = [PropMessageExpiryInterval 15549,PropPayloadFormatIndicator 45,PropReasonString "\248\US -// \142,s\204\151\242",PropMaximumQoS 172,PropAuthenticationData -// "sv<\SO\199\224\242H9*\190\238\232s\212X4\213\234\153n",PropResponseInformation -// "\FSo}\192\n\139\139\f,\NULbc4",PropSubscriptionIdentifier 2,PropPayloadFormatIndicator 100,PropWillDelayInterval -// 22944,PropAuthenticationMethod "p\197\v\255y\216\238$\241\246q\147\166e",PropMaximumPacketSize 16444,PropTopicAlias -// 32554,PropAuthenticationMethod "\210\172m'\"\221x\188\158\231\132\199\SOH\155\187%\236\223:\205",PropCorrelationData -// "9",PropTopicAliasMaximum 12747,PropWillDelayInterval 12510,PropContentType -// "e\253ia\245\204\ESC\243mC<\228\204\179Z",PropUserProperty -// "GT\236\CANX\170A`\180u\142\138\&0\SO_*\150\203Rwj\163\DC1\231\138\&9Z" -// "\186\138'\133\ENQ\NAK\SUB^\ESC\194\ACK\222\202\254k\DC1\215A\186,\SI\192q\161\229\144\189\172",PropSubscriptionIdentifier -// 24,PropServerKeepAlive 14714,PropContentType "\211&C",PropServerKeepAlive 6186,PropSharedSubscriptionAvailable 208]} -TEST(Connect5QCTest, Encode18) { - uint8_t pkt[] = { - 0x10, 0xdf, 0x3, 0x0, 0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0xd, 0x2d, - 0x17, 0x4c, 0x24, 0x38, 0x28, 0x48, 0x23, 0x5b, 0x13, 0x9, 0x0, 0xf, 0x8b, 0xf3, 0x1d, 0x6e, 0x66, 0xbf, 0xc, - 0xc, 0x3c, 0xe5, 0xc7, 0x3b, 0x84, 0xfd, 0xf0, 0x3, 0x0, 0xe, 0x3f, 0x30, 0xff, 0x1d, 0x1f, 0xe5, 0x87, 0x27, - 0xa1, 0xdb, 0x5f, 0x1c, 0x69, 0xe1, 0x21, 0x39, 0x92, 0x21, 0x24, 0x3, 0x18, 0x0, 0x0, 0x48, 0x50, 0x25, 0xca, - 0x24, 0xf9, 0x0, 0x7, 0xc4, 0x2e, 0xc, 0x6d, 0xb2, 0x39, 0xf0, 0x0, 0x17, 0xe5, 0x59, 0xf6, 0xab, 0x22, 0x7, - 0xe7, 0x56, 0x70, 0xc8, 0xa9, 0x9c, 0x35, 0x25, 0xa, 0xa5, 0x92, 0x17, 0xdd, 0xd1, 0x80, 0xe4, 0xe7, 0x0, 0x7, - 0x86, 0xa2, 0x27, 0x62, 0x93, 0x72, 0x13}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf8, 0x1f, 0x20, 0x8e, 0x2c, 0x73, 0xcc, 0x97, 0xf2}; - uint8_t bytesprops1[] = {0x73, 0x76, 0x3c, 0xe, 0xc7, 0xe0, 0xf2, 0x48, 0x39, 0x2a, 0xbe, - 0xee, 0xe8, 0x73, 0xd4, 0x58, 0x34, 0xd5, 0xea, 0x99, 0x6e}; - uint8_t bytesprops2[] = {0x1c, 0x6f, 0x7d, 0xc0, 0xa, 0x8b, 0x8b, 0xc, 0x2c, 0x0, 0x62, 0x63, 0x34}; - uint8_t bytesprops3[] = {0x70, 0xc5, 0xb, 0xff, 0x79, 0xd8, 0xee, 0x24, 0xf1, 0xf6, 0x71, 0x93, 0xa6, 0x65}; - uint8_t bytesprops4[] = {0xd2, 0xac, 0x6d, 0x27, 0x22, 0xdd, 0x78, 0xbc, 0x9e, 0xe7, - 0x84, 0xc7, 0x1, 0x9b, 0xbb, 0x25, 0xec, 0xdf, 0x3a, 0xcd}; - uint8_t bytesprops5[] = {0x39}; - uint8_t bytesprops6[] = {0x65, 0xfd, 0x69, 0x61, 0xf5, 0xcc, 0x1b, 0xf3, 0x6d, 0x43, 0x3c, 0xe4, 0xcc, 0xb3, 0x5a}; - uint8_t bytesprops8[] = {0xba, 0x8a, 0x27, 0x85, 0x5, 0x15, 0x1a, 0x5e, 0x1b, 0xc2, 0x6, 0xde, 0xca, 0xfe, - 0x6b, 0x11, 0xd7, 0x41, 0xba, 0x2c, 0xf, 0xc0, 0x71, 0xa1, 0xe5, 0x90, 0xbd, 0xac}; - uint8_t bytesprops7[] = {0x47, 0x54, 0xec, 0x18, 0x58, 0xaa, 0x41, 0x60, 0xb4, 0x75, 0x8e, 0x8a, 0x30, 0xe, - 0x5f, 0x2a, 0x96, 0xcb, 0x52, 0x77, 0x6a, 0xa3, 0x11, 0xe7, 0x8a, 0x39, 0x5a}; - uint8_t bytesprops9[] = {0xd3, 0x26, 0x43}; +// ConnectRequest {_username = Just "F\208\168\t~)z\vT8=\231\137\f\197\180\&5\169O\b\222\153\175\180H\193b\154%", _password = Just "\NAK^\RS\171Ce0\DLE\151\171\237L\167#", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\ESCn\STX\167<\196\189\197", _willMsg = "G\NAK\158\v\STX\173\140y\131", _willProps = [PropReasonString "\173)\174\184\DC1\238\&9!\155\158\137%F\172\\\170\226",PropTopicAlias 27587,PropResponseTopic "\204)\152\174\216\139SN\195\157o\176A\166n\165H\229x\225\213",PropContentType "\222\135\SUB\213]d\245\199\DC2\137\190\163\STX^{\152\232\199\&6\141\246\227\199\144",PropUserProperty "\145\US\168\139n0\243dF" "\178LO\128\199",PropSharedSubscriptionAvailable 81,PropResponseTopic "u\ACK\234#\136<\251Lj\200]\143\CAN\t\131\242zy\145\138r\196\\*e\171\b\145\239",PropAuthenticationMethod "m\167\219\175\t\219\175\254efh\210\211D\198F\130qH\206\209"]}), _cleanSession = True, _keepAlive = 17115, _connID = "\224\239\SYNj", _properties = [PropSubscriptionIdentifierAvailable 168,PropAssignedClientIdentifier "\154\245\&7\STXZ\tW",PropMessageExpiryInterval 9213,PropTopicAliasMaximum 20311,PropResponseInformation "\ENQ\246R\134\192\&5",PropMaximumQoS 232,PropSubscriptionIdentifier 22]} +TEST(Connect5QCTest, Encode22) { +uint8_t pkt[] = {0x10, 0x8f, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x42, 0xdb, 0x21, 0x29, 0xa8, 0x12, 0x0, 0x7, 0x9a, 0xf5, 0x37, 0x2, 0x5a, 0x9, 0x57, 0x2, 0x0, 0x0, 0x23, 0xfd, 0x22, 0x4f, 0x57, 0x1a, 0x0, 0x6, 0x5, 0xf6, 0x52, 0x86, 0xc0, 0x35, 0x24, 0xe8, 0xb, 0x16, 0x0, 0x4, 0xe0, 0xef, 0x16, 0x6a, 0x97, 0x1, 0x1f, 0x0, 0x11, 0xad, 0x29, 0xae, 0xb8, 0x11, 0xee, 0x39, 0x21, 0x9b, 0x9e, 0x89, 0x25, 0x46, 0xac, 0x5c, 0xaa, 0xe2, 0x23, 0x6b, 0xc3, 0x8, 0x0, 0x15, 0xcc, 0x29, 0x98, 0xae, 0xd8, 0x8b, 0x53, 0x4e, 0xc3, 0x9d, 0x6f, 0xb0, 0x41, 0xa6, 0x6e, 0xa5, 0x48, 0xe5, 0x78, 0xe1, 0xd5, 0x3, 0x0, 0x18, 0xde, 0x87, 0x1a, 0xd5, 0x5d, 0x64, 0xf5, 0xc7, 0x12, 0x89, 0xbe, 0xa3, 0x2, 0x5e, 0x7b, 0x98, 0xe8, 0xc7, 0x36, 0x8d, 0xf6, 0xe3, 0xc7, 0x90, 0x26, 0x0, 0x9, 0x91, 0x1f, 0xa8, 0x8b, 0x6e, 0x30, 0xf3, 0x64, 0x46, 0x0, 0x5, 0xb2, 0x4c, 0x4f, 0x80, 0xc7, 0x2a, 0x51, 0x8, 0x0, 0x1d, 0x75, 0x6, 0xea, 0x23, 0x88, 0x3c, 0xfb, 0x4c, 0x6a, 0xc8, 0x5d, 0x8f, 0x18, 0x9, 0x83, 0xf2, 0x7a, 0x79, 0x91, 0x8a, 0x72, 0xc4, 0x5c, 0x2a, 0x65, 0xab, 0x8, 0x91, 0xef, 0x15, 0x0, 0x15, 0x6d, 0xa7, 0xdb, 0xaf, 0x9, 0xdb, 0xaf, 0xfe, 0x65, 0x66, 0x68, 0xd2, 0xd3, 0x44, 0xc6, 0x46, 0x82, 0x71, 0x48, 0xce, 0xd1, 0x0, 0x8, 0x1b, 0x6e, 0x2, 0xa7, 0x3c, 0xc4, 0xbd, 0xc5, 0x0, 0x9, 0x47, 0x15, 0x9e, 0xb, 0x2, 0xad, 0x8c, 0x79, 0x83, 0x0, 0x1d, 0x46, 0xd0, 0xa8, 0x9, 0x7e, 0x29, 0x7a, 0xb, 0x54, 0x38, 0x3d, 0xe7, 0x89, 0xc, 0xc5, 0xb4, 0x35, 0xa9, 0x4f, 0x8, 0xde, 0x99, 0xaf, 0xb4, 0x48, 0xc1, 0x62, 0x9a, 0x25, 0x0, 0xe, 0x15, 0x5e, 0x1e, 0xab, 0x43, 0x65, 0x30, 0x10, 0x97, 0xab, 0xed, 0x4c, 0xa7, 0x23}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x9a, 0xf5, 0x37, 0x2, 0x5a, 0x9, 0x57}; + uint8_t bytesprops1[] = {0x5, 0xf6, 0x52, 0x86, 0xc0, 0x35}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15549}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22944}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16444}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32554}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12747}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12510}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops7}, .v = {28, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14714}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6186}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9213}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20311}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x7, 0x4e, 0xbe, 0xa1, 0x1e, 0xc5, 0x5b, 0x5c, 0x2b, 0x94, 0xb0, 0xd1, 0xfa, 0x51, - 0xbd, 0x3, 0x35, 0x2b, 0xe1, 0x98, 0xbf, 0xad, 0x6f, 0x31, 0xea, 0xf0, 0x83}; - uint8_t byteswillprops1[] = {0xf9, 0x77, 0xa3, 0x99, 0x6a, 0x9e, 0x8f, 0xa4, 0xd8, 0x66, 0xcb}; - uint8_t byteswillprops2[] = {0xb5, 0xa4, 0x22, 0x19, 0xd4, 0xf8, 0x7b, 0x9, 0xcf, 0x65, 0x2, 0x61, 0x10, 0x73, 0xf1, - 0xfb, 0x82, 0xf0, 0x87, 0xa0, 0x4d, 0xa4, 0x49, 0x5f, 0xba, 0x76, 0x16, 0x30, 0xcf}; - uint8_t byteswillprops3[] = {0x91, 0xee, 0xbd, 0x2c, 0xd7, 0x76, 0xf8, 0xbf, 0x3b, 0xfa, 0x21, 0x87, - 0x57, 0x5, 0x7, 0x83, 0x86, 0x8f, 0x78, 0xab, 0xf1, 0x9, 0x5b, 0xc2}; - uint8_t byteswillprops4[] = {0x8b, 0xf3, 0x1d, 0x6e, 0x66, 0xbf, 0xc, 0xc, 0x3c, 0xe5, 0xc7, 0x3b, 0x84, 0xfd, 0xf0}; - uint8_t byteswillprops5[] = {0x3f, 0x30, 0xff, 0x1d, 0x1f, 0xe5, 0x87, 0x27, 0xa1, 0xdb, 0x5f, 0x1c, 0x69, 0xe1}; - + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xad, 0x29, 0xae, 0xb8, 0x11, 0xee, 0x39, 0x21, 0x9b, 0x9e, 0x89, 0x25, 0x46, 0xac, 0x5c, 0xaa, 0xe2}; + uint8_t byteswillprops1[] = {0xcc, 0x29, 0x98, 0xae, 0xd8, 0x8b, 0x53, 0x4e, 0xc3, 0x9d, 0x6f, 0xb0, 0x41, 0xa6, 0x6e, 0xa5, 0x48, 0xe5, 0x78, 0xe1, 0xd5}; + uint8_t byteswillprops2[] = {0xde, 0x87, 0x1a, 0xd5, 0x5d, 0x64, 0xf5, 0xc7, 0x12, 0x89, 0xbe, 0xa3, 0x2, 0x5e, 0x7b, 0x98, 0xe8, 0xc7, 0x36, 0x8d, 0xf6, 0xe3, 0xc7, 0x90}; + uint8_t byteswillprops4[] = {0xb2, 0x4c, 0x4f, 0x80, 0xc7}; + uint8_t byteswillprops3[] = {0x91, 0x1f, 0xa8, 0x8b, 0x6e, 0x30, 0xf3, 0x64, 0x46}; + uint8_t byteswillprops5[] = {0x75, 0x6, 0xea, 0x23, 0x88, 0x3c, 0xfb, 0x4c, 0x6a, 0xc8, 0x5d, 0x8f, 0x18, 0x9, 0x83, 0xf2, 0x7a, 0x79, 0x91, 0x8a, 0x72, 0xc4, 0x5c, 0x2a, 0x65, 0xab, 0x8, 0x91, 0xef}; + uint8_t byteswillprops6[] = {0x6d, 0xa7, 0xdb, 0xaf, 0x9, 0xdb, 0xaf, 0xfe, 0x65, 0x66, 0x68, 0xd2, 0xd3, 0x44, 0xc6, 0x46, 0x82, 0x71, 0x48, 0xce, 0xd1}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28040}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18583}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16615}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7143}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22637}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12339}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3373}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23315}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14738}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9219}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18512}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27587}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={9, (char*)&byteswillprops3}, .v={5, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&byteswillprops6}}}, }; - lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc4, 0x2e, 0xc, 0x6d, 0xb2, 0x39, 0xf0}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe5, 0x59, 0xf6, 0xab, 0x22, 0x7, 0xe7, 0x56, 0x70, 0xc8, 0xa9, 0x9c, - 0x35, 0x25, 0xa, 0xa5, 0x92, 0x17, 0xdd, 0xd1, 0x80, 0xe4, 0xe7}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 10739; - uint8_t client_id_bytes[] = {0x2f}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x86, 0xa2, 0x27, 0x62, 0x93, 0x72, 0x13}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1b, 0x6e, 0x2, 0xa7, 0x3c, 0xc4, 0xbd, 0xc5}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x47, 0x15, 0x9e, 0xb, 0x2, 0xad, 0x8c, 0x79, 0x83}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 17115; + uint8_t client_id_bytes[] = {0xe0, 0xef, 0x16, 0x6a}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x46, 0xd0, 0xa8, 0x9, 0x7e, 0x29, 0x7a, 0xb, 0x54, 0x38, 0x3d, 0xe7, 0x89, 0xc, 0xc5, 0xb4, 0x35, 0xa9, 0x4f, 0x8, 0xde, 0x99, 0xaf, 0xb4, 0x48, 0xc1, 0x62, 0x9a, 0x25}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x15, 0x5e, 0x1e, 0xab, 0x43, 0x65, 0x30, 0x10, 0x97, 0xab, 0xed, 0x4c, 0xa7, 0x23}; + lwmqtt_string_t password = {14, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\162\239\230\n3", _password = Just -// "\CAN\200\200D\180\211J@\181\217Sj\DEL\208\141\&8\135^$\175", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "Z\197\216\246\ETX\145\228\DC3\217", _willMsg = "5\204\&3\t\SI\254!\226\237\154", -// _willProps = [PropAuthenticationData "X\237%\141\238\&7\SI\148\251\228\129",PropReceiveMaximum -// 19888,PropWildcardSubscriptionAvailable 111,PropUserProperty "M[\146" -// "\138\214\230\US\200\ENQ\NULo0+S9O<\244\215n\250K\154\197\133\254\DC3\156"]}), _cleanSession = False, _keepAlive = -// 24980, _connID = "f\246\\A\130\163\246\NUL\ESC\222\168?\SI\NULe\155\&9\215", _properties = [PropAuthenticationMethod -// " O[\249\154\248{j:\133\135\254y'Y\DC1t\154C#\229$x"]} -TEST(Connect5QCTest, Encode19) { - uint8_t pkt[] = {0x10, 0xa2, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x61, 0x94, 0x1a, 0x15, 0x0, 0x17, - 0x20, 0x4f, 0x5b, 0xf9, 0x9a, 0xf8, 0x7b, 0x6a, 0x3a, 0x85, 0x87, 0xfe, 0x79, 0x27, 0x59, 0x11, 0x74, - 0x9a, 0x43, 0x23, 0xe5, 0x24, 0x78, 0x0, 0x12, 0x66, 0xf6, 0x5c, 0x41, 0x82, 0xa3, 0xf6, 0x0, 0x1b, - 0xde, 0xa8, 0x3f, 0xf, 0x0, 0x65, 0x9b, 0x39, 0xd7, 0x34, 0x16, 0x0, 0xb, 0x58, 0xed, 0x25, 0x8d, - 0xee, 0x37, 0xf, 0x94, 0xfb, 0xe4, 0x81, 0x21, 0x4d, 0xb0, 0x28, 0x6f, 0x26, 0x0, 0x3, 0x4d, 0x5b, - 0x92, 0x0, 0x19, 0x8a, 0xd6, 0xe6, 0x1f, 0xc8, 0x5, 0x0, 0x6f, 0x30, 0x2b, 0x53, 0x39, 0x4f, 0x3c, - 0xf4, 0xd7, 0x6e, 0xfa, 0x4b, 0x9a, 0xc5, 0x85, 0xfe, 0x13, 0x9c, 0x0, 0x9, 0x5a, 0xc5, 0xd8, 0xf6, - 0x3, 0x91, 0xe4, 0x13, 0xd9, 0x0, 0xa, 0x35, 0xcc, 0x33, 0x9, 0xf, 0xfe, 0x21, 0xe2, 0xed, 0x9a, - 0x0, 0x5, 0xa2, 0xef, 0xe6, 0xa, 0x33, 0x0, 0x14, 0x18, 0xc8, 0xc8, 0x44, 0xb4, 0xd3, 0x4a, 0x40, - 0xb5, 0xd9, 0x53, 0x6a, 0x7f, 0xd0, 0x8d, 0x38, 0x87, 0x5e, 0x24, 0xaf}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x20, 0x4f, 0x5b, 0xf9, 0x9a, 0xf8, 0x7b, 0x6a, 0x3a, 0x85, 0x87, 0xfe, - 0x79, 0x27, 0x59, 0x11, 0x74, 0x9a, 0x43, 0x23, 0xe5, 0x24, 0x78}; +// ConnectRequest {_username = Nothing, _password = Just "_\181", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\130\CANG\157\a\138\188H\194", _willMsg = "\131;\DEL\244\175\170\170\225\172", _willProps = [PropAuthenticationMethod "\233\128E\an\188`"]}), _cleanSession = True, _keepAlive = 18273, _connID = "\DLEX\181cI5\156\142^\212\200\ETX\254\162\223\136\ETB\142\251p\163", _properties = [PropReasonString "i\231\190\203.\209#\225\135\199\205\137\FSfFpvw\163\250",PropSessionExpiryInterval 1250,PropWildcardSubscriptionAvailable 81,PropSessionExpiryInterval 5483,PropWillDelayInterval 888,PropAuthenticationData "e\t7\236\157\207\230",PropSharedSubscriptionAvailable 216,PropRequestProblemInformation 171,PropTopicAlias 15760,PropSubscriptionIdentifierAvailable 181,PropTopicAlias 7274,PropSubscriptionIdentifierAvailable 117,PropSubscriptionIdentifier 1,PropAssignedClientIdentifier "\129\219<\175\235\149\199Q\213\237\&5\172\232\159\"",PropRetainAvailable 42,PropTopicAliasMaximum 20244,PropTopicAliasMaximum 20476,PropTopicAlias 14196,PropMaximumQoS 225,PropRequestProblemInformation 103,PropPayloadFormatIndicator 124,PropAssignedClientIdentifier "\174\143\DLE\RS\251,\251\233BMg",PropReasonString ";IY\242s\198A\245\191\ETX",PropWillDelayInterval 7562,PropSessionExpiryInterval 24082,PropSubscriptionIdentifier 4,PropMessageExpiryInterval 30805,PropTopicAliasMaximum 20501,PropRetainAvailable 120]} +TEST(Connect5QCTest, Encode23) { +uint8_t pkt[] = {0x10, 0xde, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x46, 0x47, 0x61, 0x96, 0x1, 0x1f, 0x0, 0x14, 0x69, 0xe7, 0xbe,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 0x83, 0x3b, 0x7f, 0xf4, 0xaf, 0xaa, 0xaa, 0xe1, 0xac, 0x0, 0x2, 0x5f, 0xb5}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x69, 0xe7, 0xbe, 0xcb, 0x2e, 0xd1, 0x23, 0xe1, 0x87, 0xc7, 0xcd, 0x89, 0x1c, 0x66, 0x46, 0x70, 0x76, 0x77, 0xa3, 0xfa}; + uint8_t bytesprops1[] = {0x65, 0x9, 0x37, 0xec, 0x9d, 0xcf, 0xe6}; + uint8_t bytesprops2[] = {0x81, 0xdb, 0x3c, 0xaf, 0xeb, 0x95, 0xc7, 0x51, 0xd5, 0xed, 0x35, 0xac, 0xe8, 0x9f, 0x22}; + uint8_t bytesprops3[] = {0xae, 0x8f, 0x10, 0x1e, 0xfb, 0x2c, 0xfb, 0xe9, 0x42, 0x4d, 0x67}; + uint8_t bytesprops4[] = {0x3b, 0x49, 0x59, 0xf2, 0x73, 0xc6, 0x41, 0xf5, 0xbf, 0x3}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1250}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5483}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 888}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15760}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7274}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20244}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20476}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14196}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7562}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24082}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30805}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20501}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 120}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x58, 0xed, 0x25, 0x8d, 0xee, 0x37, 0xf, 0x94, 0xfb, 0xe4, 0x81}; - uint8_t byteswillprops2[] = {0x8a, 0xd6, 0xe6, 0x1f, 0xc8, 0x5, 0x0, 0x6f, 0x30, 0x2b, 0x53, 0x39, 0x4f, - 0x3c, 0xf4, 0xd7, 0x6e, 0xfa, 0x4b, 0x9a, 0xc5, 0x85, 0xfe, 0x13, 0x9c}; - uint8_t byteswillprops1[] = {0x4d, 0x5b, 0x92}; - + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xe9, 0x80, 0x45, 0x7, 0x6e, 0xbc, 0x60}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19888}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {3, (char*)&byteswillprops1}, .v = {25, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&byteswillprops0}}}, }; - lwmqtt_properties_t willprops = {4, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5a, 0xc5, 0xd8, 0xf6, 0x3, 0x91, 0xe4, 0x13, 0xd9}; + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x82, 0x18, 0x47, 0x9d, 0x7, 0x8a, 0xbc, 0x48, 0xc2}; lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x35, 0xcc, 0x33, 0x9, 0xf, 0xfe, 0x21, 0xe2, 0xed, 0x9a}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 24980; - uint8_t client_id_bytes[] = {0x66, 0xf6, 0x5c, 0x41, 0x82, 0xa3, 0xf6, 0x0, 0x1b, - 0xde, 0xa8, 0x3f, 0xf, 0x0, 0x65, 0x9b, 0x39, 0xd7}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa2, 0xef, 0xe6, 0xa, 0x33}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x18, 0xc8, 0xc8, 0x44, 0xb4, 0xd3, 0x4a, 0x40, 0xb5, 0xd9, - 0x53, 0x6a, 0x7f, 0xd0, 0x8d, 0x38, 0x87, 0x5e, 0x24, 0xaf}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + uint8_t will_payload_bytes[] = {0x83, 0x3b, 0x7f, 0xf4, 0xaf, 0xaa, 0xaa, 0xe1, 0xac}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS0; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 18273; + uint8_t client_id_bytes[] = {0x10, 0x58, 0xb5, 0x63, 0x49, 0x35, 0x9c, 0x8e, 0x5e, 0xd4, 0xc8, 0x3, 0xfe, 0xa2, 0xdf, 0x88, 0x17, 0x8e, 0xfb, 0x70, 0xa3}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x5f, 0xb5}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\223\202e-\159\bZ\GS", _password = Just -// "\210\145\"C\US\ESC(\195\234\165\212\157t\235\178", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, -// _willTopic = "1PwW$\"}\"/9\SOH\DC4a\252\212\170=b\209y\215\SO\216.F\160\139", _willMsg = -// "\254\255\178\RS\STXL\176\236\FS\129c\209", _willProps = [PropTopicAliasMaximum 1471,PropRequestResponseInformation -// 39,PropWillDelayInterval 3636,PropSubscriptionIdentifier 20,PropMessageExpiryInterval -// 1482,PropSharedSubscriptionAvailable 6,PropSubscriptionIdentifier 23,PropMessageExpiryInterval -// 6790,PropMessageExpiryInterval 18889]}), _cleanSession = True, _keepAlive = 21539, _connID = "t\221\220", _properties -// = [PropAuthenticationData "T\135\150\&7\221#\170\233*",PropSessionExpiryInterval -// 30337,PropWildcardSubscriptionAvailable 123,PropMaximumPacketSize 7248,PropServerReference -// "0u\158W\248\234\&7\227\157\168\165\206\DC4/?B\US*",PropMessageExpiryInterval 27127,PropTopicAlias -// 19939,PropUserProperty " J\200" "\244\137\164\166\130",PropReceiveMaximum 30118,PropTopicAliasMaximum -// 8100,PropResponseTopic "a\223\198\234\207{\228",PropRetainAvailable 116]} -TEST(Connect5QCTest, Encode20) { - uint8_t pkt[] = { - 0x10, 0xca, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x54, 0x23, 0x54, 0x16, 0x0, 0x9, 0x54, 0x87, - 0x96, 0x37, 0xdd, 0x23, 0xaa, 0xe9, 0x2a, 0x11, 0x0, 0x0, 0x76, 0x81, 0x28, 0x7b, 0x27, 0x0, 0x0, 0x1c, 0x50, - 0x1c, 0x0, 0x12, 0x30, 0x75, 0x9e, 0x57, 0xf8, 0xea, 0x37, 0xe3, 0x9d, 0xa8, 0xa5, 0xce, 0x14, 0x2f, 0x3f, 0x42, - 0x1f, 0x2a, 0x2, 0x0, 0x0, 0x69, 0xf7, 0x23, 0x4d, 0xe3, 0x26, 0x0, 0x3, 0x20, 0x4a, 0xc8, 0x0, 0x5, 0xf4, - 0x89, 0xa4, 0xa6, 0x82, 0x21, 0x75, 0xa6, 0x22, 0x1f, 0xa4, 0x8, 0x0, 0x7, 0x61, 0xdf, 0xc6, 0xea, 0xcf, 0x7b, - 0xe4, 0x25, 0x74, 0x0, 0x3, 0x74, 0xdd, 0xdc, 0x1f, 0x22, 0x5, 0xbf, 0x19, 0x27, 0x18, 0x0, 0x0, 0xe, 0x34, - 0xb, 0x14, 0x2, 0x0, 0x0, 0x5, 0xca, 0x2a, 0x6, 0xb, 0x17, 0x2, 0x0, 0x0, 0x1a, 0x86, 0x2, 0x0, 0x0, - 0x49, 0xc9, 0x0, 0x1b, 0x31, 0x50, 0x77, 0x57, 0x24, 0x22, 0x7d, 0x22, 0x2f, 0x39, 0x1, 0x14, 0x61, 0xfc, 0xd4, - 0xaa, 0x3d, 0x62, 0xd1, 0x79, 0xd7, 0xe, 0xd8, 0x2e, 0x46, 0xa0, 0x8b, 0x0, 0xc, 0xfe, 0xff, 0xb2, 0x1e, 0x2, - 0x4c, 0xb0, 0xec, 0x1c, 0x81, 0x63, 0xd1, 0x0, 0x8, 0xdf, 0xca, 0x65, 0x2d, 0x9f, 0x8, 0x5a, 0x1d, 0x0, 0xf, - 0xd2, 0x91, 0x22, 0x43, 0x1f, 0x1b, 0x28, 0xc3, 0xea, 0xa5, 0xd4, 0x9d, 0x74, 0xeb, 0xb2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x54, 0x87, 0x96, 0x37, 0xdd, 0x23, 0xaa, 0xe9, 0x2a}; - uint8_t bytesprops1[] = {0x30, 0x75, 0x9e, 0x57, 0xf8, 0xea, 0x37, 0xe3, 0x9d, - 0xa8, 0xa5, 0xce, 0x14, 0x2f, 0x3f, 0x42, 0x1f, 0x2a}; - uint8_t bytesprops3[] = {0xf4, 0x89, 0xa4, 0xa6, 0x82}; - uint8_t bytesprops2[] = {0x20, 0x4a, 0xc8}; - uint8_t bytesprops4[] = {0x61, 0xdf, 0xc6, 0xea, 0xcf, 0x7b, 0xe4}; +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\212\138\190Q;W\148\195", _willMsg = "\213;", _willProps = [PropRequestResponseInformation 2,PropMessageExpiryInterval 22680,PropResponseTopic "\204\192\149\210\EOT)f\201\214\244\148\177Lv\196\128)\244D\ETX",PropCorrelationData "\EM\140\SUB\SI\168\CAN\144V1\t\US\223",PropTopicAlias 1847,PropResponseInformation "\252\165\241\SO~\228a\245?\160\199\172\216",PropSessionExpiryInterval 5571,PropWildcardSubscriptionAvailable 194,PropReasonString "&\189\DC4Rt\133\199\251\DC1\155h\240*\252%\167\\\229g\ETB\227\253\223\232\162\177",PropCorrelationData "a#\150\220D\147\v\221\140.|.\155\t#\140\&5\143P",PropTopicAliasMaximum 18078,PropSessionExpiryInterval 28214,PropWillDelayInterval 17859,PropPayloadFormatIndicator 221,PropAssignedClientIdentifier "\DC1\188H\ETX\196\187V\SYN{\155\FS`\190\185\236{\RS\247\197\234",PropCorrelationData "\153(\182\&6\248'\187\192pQ_\190",PropMessageExpiryInterval 10563,PropSharedSubscriptionAvailable 99,PropWildcardSubscriptionAvailable 171,PropMessageExpiryInterval 18957,PropWillDelayInterval 9477]}), _cleanSession = True, _keepAlive = 31629, _connID = "\157f\DC3.", _properties = [PropAuthenticationMethod "1\n\210\129\DLE\ETX\164\NUL",PropTopicAliasMaximum 10014,PropSessionExpiryInterval 18349,PropContentType "H\167\200\\\131\189\EOT#",PropReasonString "}\142\164:\156\189\239\194\222\139v\184\164\132\248|@\135\247\&3\201UU\200",PropAuthenticationData "\136\254\243X\ACK\DC2\f",PropUserProperty "\CAN\223T\156\133\157\136\SOH\213\133\199" "\253pj\128\188\230\179i\165C",PropAuthenticationData "\251\235\CAN\255,X\ESC\FS\v\150\ETBW7\ACK\214",PropAssignedClientIdentifier "\212\238\130\t\STXH\169e\176\&9\182\251\143r\147gcp\187\202\166\128",PropAssignedClientIdentifier "g\231\214\157\243\207_\129?\CANbF\199\DC1\131\229\252\157\US\135\adv\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0, 0x0, 0x4a, 0xd, 0x18, 0x0, 0x0, 0x25, 0x5, 0x0, 0x8, 0xd4, 0x8a, 0xbe, 0x51, 0x3b, 0x57, 0x94, 0xc3, 0x0, 0x2, 0xd5, 0x3b}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x31, 0xa, 0xd2, 0x81, 0x10, 0x3, 0xa4, 0x0}; + uint8_t bytesprops1[] = {0x48, 0xa7, 0xc8, 0x5c, 0x83, 0xbd, 0x4, 0x23}; + uint8_t bytesprops2[] = {0x7d, 0x8e, 0xa4, 0x3a, 0x9c, 0xbd, 0xef, 0xc2, 0xde, 0x8b, 0x76, 0xb8, 0xa4, 0x84, 0xf8, 0x7c, 0x40, 0x87, 0xf7, 0x33, 0xc9, 0x55, 0x55, 0xc8}; + uint8_t bytesprops3[] = {0x88, 0xfe, 0xf3, 0x58, 0x6, 0x12, 0xc}; + uint8_t bytesprops5[] = {0xfd, 0x70, 0x6a, 0x80, 0xbc, 0xe6, 0xb3, 0x69, 0xa5, 0x43}; + uint8_t bytesprops4[] = {0x18, 0xdf, 0x54, 0x9c, 0x85, 0x9d, 0x88, 0x1, 0xd5, 0x85, 0xc7}; + uint8_t bytesprops6[] = {0xfb, 0xeb, 0x18, 0xff, 0x2c, 0x58, 0x1b, 0x1c, 0xb, 0x96, 0x17, 0x57, 0x37, 0x6, 0xd6}; + uint8_t bytesprops7[] = {0xd4, 0xee, 0x82, 0x9, 0x2, 0x48, 0xa9, 0x65, 0xb0, 0x39, 0xb6, 0xfb, 0x8f, 0x72, 0x93, 0x67, 0x63, 0x70, 0xbb, 0xca, 0xa6, 0x80}; + uint8_t bytesprops8[] = {0x67, 0xe7, 0xd6, 0x9d, 0xf3, 0xcf, 0x5f, 0x81, 0x3f, 0x18, 0x62, 0x46, 0xc7, 0x11, 0x83, 0xe5, 0xfc, 0x9d, 0x1f, 0x87, 0x7, 0x64, 0x76, 0xc0, 0x77}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30337}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7248}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27127}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19939}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops2}, .v = {5, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30118}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8100}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10014}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18349}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={11, (char*)&bytesprops4}, .v={10, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xcc, 0xc0, 0x95, 0xd2, 0x4, 0x29, 0x66, 0xc9, 0xd6, 0xf4, 0x94, 0xb1, 0x4c, 0x76, 0xc4, 0x80, 0x29, 0xf4, 0x44, 0x3}; + uint8_t byteswillprops1[] = {0x19, 0x8c, 0x1a, 0xf, 0xa8, 0x18, 0x90, 0x56, 0x31, 0x9, 0x1f, 0xdf}; + uint8_t byteswillprops2[] = {0xfc, 0xa5, 0xf1, 0xe, 0x7e, 0xe4, 0x61, 0xf5, 0x3f, 0xa0, 0xc7, 0xac, 0xd8}; + uint8_t byteswillprops3[] = {0x26, 0xbd, 0x14, 0x52, 0x74, 0x85, 0xc7, 0xfb, 0x11, 0x9b, 0x68, 0xf0, 0x2a, 0xfc, 0x25, 0xa7, 0x5c, 0xe5, 0x67, 0x17, 0xe3, 0xfd, 0xdf, 0xe8, 0xa2, 0xb1}; + uint8_t byteswillprops4[] = {0x61, 0x23, 0x96, 0xdc, 0x44, 0x93, 0xb, 0xdd, 0x8c, 0x2e, 0x7c, 0x2e, 0x9b, 0x9, 0x23, 0x8c, 0x35, 0x8f, 0x50}; + uint8_t byteswillprops5[] = {0x11, 0xbc, 0x48, 0x3, 0xc4, 0xbb, 0x56, 0x16, 0x7b, 0x9b, 0x1c, 0x60, 0xbe, 0xb9, 0xec, 0x7b, 0x1e, 0xf7, 0xc5, 0xea}; + uint8_t byteswillprops6[] = {0x99, 0x28, 0xb6, 0x36, 0xf8, 0x27, 0xbb, 0xc0, 0x70, 0x51, 0x5f, 0xbe}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1471}}, {.prop = (lwmqtt_prop_t)25, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3636}}, {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1482}}, {.prop = (lwmqtt_prop_t)42, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6790}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18889}}, - }; - - lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x31, 0x50, 0x77, 0x57, 0x24, 0x22, 0x7d, 0x22, 0x2f, 0x39, 0x1, 0x14, 0x61, 0xfc, - 0xd4, 0xaa, 0x3d, 0x62, 0xd1, 0x79, 0xd7, 0xe, 0xd8, 0x2e, 0x46, 0xa0, 0x8b}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfe, 0xff, 0xb2, 0x1e, 0x2, 0x4c, 0xb0, 0xec, 0x1c, 0x81, 0x63, 0xd1}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 21539; - uint8_t client_id_bytes[] = {0x74, 0xdd, 0xdc}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xdf, 0xca, 0x65, 0x2d, 0x9f, 0x8, 0x5a, 0x1d}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd2, 0x91, 0x22, 0x43, 0x1f, 0x1b, 0x28, 0xc3, 0xea, 0xa5, 0xd4, 0x9d, 0x74, 0xeb, 0xb2}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// ConnectRequest {_username = Just "\205lB\203\231\189}\136\179\155\DC1s\151L1\191\USz\163V\150\139n", _password = -// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\DC1\SO\218k9\194\251", -// _willMsg = "\220\247\191\205\141\195\128\255w", _willProps = [PropRetainAvailable -// 188,PropWildcardSubscriptionAvailable 107,PropSharedSubscriptionAvailable 51,PropRequestProblemInformation -// 3,PropCorrelationData "\188)\221\214\197\\d%+6j\130V2\250\189\159\144\193\131\227\216",PropMessageExpiryInterval -// 20845,PropServerKeepAlive 10989,PropTopicAlias 11016,PropPayloadFormatIndicator -// 109,PropSubscriptionIdentifierAvailable 136,PropSessionExpiryInterval 6006,PropCorrelationData -// "\172\172\137f\224Q\ENQN\238n",PropCorrelationData -// "83n@\228\176\r\136C\169L\192n\206\190\DEL\SUB\232\SUB\143\178\&1I\221\&4\210\203",PropServerReference -// ";8\203IZ\152\NUL\US\245\138\130\241\EM\178\209:\207-"]} -TEST(Connect5QCTest, Encode21) { - uint8_t pkt[] = { - 0x10, 0xfc, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x94, 0x2c, 0xe9, 0x57, 0x25, 0x3a, 0xb, 0xc, 0x9, - 0x0, 0x1e, 0x5c, 0xaa, 0x93, 0xa6, 0x77, 0x61, 0x51, 0x91, 0x7d, 0x91, 0xe3, 0x4d, 0x85, 0x33, 0xd0, 0x87, 0xc9, - 0xb4, 0x55, 0xf1, 0x6c, 0x72, 0xca, 0x52, 0x8, 0xf5, 0x4b, 0x5b, 0xdd, 0x98, 0x22, 0x10, 0x50, 0x2, 0x0, 0x0, - 0x2, 0xae, 0x26, 0x0, 0x13, 0x5d, 0x50, 0x11, 0x51, 0x5f, 0x42, 0x45, 0x92, 0x61, 0x8d, 0xa0, 0x61, 0x2e, 0x33,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 0x22, 0x29, 0x3d, 0x25, - 0x85, 0x11, 0x0, 0x0, 0x36, 0xb4, 0x19, 0x94, 0x13, 0x38, 0xb5, 0x12, 0x0, 0xa, 0x5e, 0xc2, 0x8d, 0x50, 0x9, - 0x8a, 0x4f, 0xc1, 0x33, 0xdd, 0x26, 0x0, 0x1c, 0x78, 0x8b, 0x8, 0xae, 0x2a, 0xae, 0x51, 0xe7, 0x1e, 0x65, 0xb, - 0xd9, 0xcb, 0x81, 0x75, 0x70, 0x80, 0x9a, 0x58, 0x33, 0x7f, 0xb6, 0x2d, 0x6, 0xbb, 0xdd, 0xef, 0x91, 0x0, 0x6, - 0xf2, 0xbe, 0x93, 0x74, 0x9c, 0x18, 0x1, 0x63, 0x27, 0x0, 0x0, 0x41, 0x45, 0x28, 0xd2, 0x0, 0x7, 0x11, 0xe, - 0xda, 0x6b, 0x39, 0xc2, 0xfb, 0x0, 0x9, 0xdc, 0xf7, 0xbf, 0xcd, 0x8d, 0xc3, 0x80, 0xff, 0x77, 0x0, 0x17, 0xcd, - 0x6c, 0x42, 0xcb, 0xe7, 0xbd, 0x7d, 0x88, 0xb3, 0x9b, 0x11, 0x73, 0x97, 0x4c, 0x31, 0xbf, 0x1f, 0x7a, 0xa3, 0x56, - 0x96, 0x8b, 0x6e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x5c, 0xaa, 0x93, 0xa6, 0x77, 0x61, 0x51, 0x91, 0x7d, 0x91, 0xe3, 0x4d, 0x85, 0x33, 0xd0, - 0x87, 0xc9, 0xb4, 0x55, 0xf1, 0x6c, 0x72, 0xca, 0x52, 0x8, 0xf5, 0x4b, 0x5b, 0xdd, 0x98}; - uint8_t bytesprops2[] = {0x29, 0x7, 0xef, 0x3e, 0x5a, 0x98, 0x0, 0x1f, 0xf5, - 0x8a, 0x82, 0xf1, 0x19, 0xb2, 0xd1, 0x3a, 0xcf, 0x2d}; - uint8_t bytesprops1[] = {0x5d, 0x50, 0x11, 0x51, 0x5f, 0x42, 0x45, 0x92, 0x61, 0x8d, - 0xa0, 0x61, 0x2e, 0x33, 0x6b, 0x13, 0xee, 0x14, 0x4b}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4176}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 686}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22680}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1847}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5571}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18078}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28214}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17859}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10563}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18957}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9477}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xbc, 0x29, 0xdd, 0xd6, 0xc5, 0x5c, 0x64, 0x25, 0x2b, 0x36, 0x6a, - 0x82, 0x56, 0x32, 0xfa, 0xbd, 0x9f, 0x90, 0xc1, 0x83, 0xe3, 0xd8}; - uint8_t byteswillprops1[] = {0xac, 0xac, 0x89, 0x66, 0xe0, 0x51, 0x5, 0x4e, 0xee, 0x6e}; - uint8_t byteswillprops2[] = {0x38, 0x33, 0x6e, 0x40, 0xe4, 0xb0, 0xd, 0x88, 0x43, 0xa9, 0x4c, 0xc0, 0x6e, 0xce, - 0xbe, 0x7f, 0x1a, 0xe8, 0x1a, 0x8f, 0xb2, 0x31, 0x49, 0xdd, 0x34, 0xd2, 0xcb}; - uint8_t byteswillprops3[] = {0x3b, 0x38, 0xcb, 0x49, 0x3c, 0x4c, 0xcd, 0xf2, 0xeb, 0xa, 0x69, 0x69, - 0xec, 0xa7, 0x18, 0xe9, 0x41, 0x7d, 0xd8, 0xe2, 0xe, 0x8f, 0x2f, 0x89}; - uint8_t byteswillprops4[] = {0x4f, 0x66, 0xac, 0x38, 0xf5, 0xb5, 0x55, 0xe3, 0xaf}; - uint8_t byteswillprops5[] = {0x5e, 0xc2, 0x8d, 0x50, 0x9, 0x8a, 0x4f, 0xc1, 0x33, 0xdd}; - uint8_t byteswillprops7[] = {0xf2, 0xbe, 0x93, 0x74, 0x9c, 0x18}; - uint8_t byteswillprops6[] = {0x78, 0x8b, 0x8, 0xae, 0x2a, 0xae, 0x51, 0xe7, 0x1e, 0x65, 0xb, 0xd9, 0xcb, 0x81, - 0x75, 0x70, 0x80, 0x9a, 0x58, 0x33, 0x7f, 0xb6, 0x2d, 0x6, 0xbb, 0xdd, 0xef, 0x91}; + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd4, 0x8a, 0xbe, 0x51, 0x3b, 0x57, 0x94, 0xc3}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd5, 0x3b}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 31629; + uint8_t client_id_bytes[] = {0x9d, 0x66, 0x13, 0x2e}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; +opts.client_id = client_id; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20845}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10989}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11016}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6006}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 34}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14004}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14517}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {28, (char*)&byteswillprops6}, .v = {6, (char*)&byteswillprops7}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16709}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, - }; - - lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x11, 0xe, 0xda, 0x6b, 0x39, 0xc2, 0xfb}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xdc, 0xf7, 0xbf, 0xcd, 0x8d, 0xc3, 0x80, 0xff, 0x77}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 11497; - uint8_t client_id_bytes[] = {0x7a, 0x56, 0xac, 0x14, 0xb1, 0xf, 0xd6, 0x28, 0xaa, 0xb, 0x90, 0xe8, 0x7d}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xcd, 0x6c, 0x42, 0xcb, 0xe7, 0xbd, 0x7d, 0x88, 0xb3, 0x9b, 0x11, 0x73, - 0x97, 0x4c, 0x31, 0xbf, 0x1f, 0x7a, 0xa3, 0x56, 0x96, 0x8b, 0x6e}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\251Z\240\194K\232\239\141AZ", _password = Just -// "\215]\EM\137\201\167\148\151\224z^h\231\180\213Uk+\147", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 19360, _connID = "\156\242D9\182\133e\DC1\231\177\DC4", _properties = [PropRequestProblemInformation -// 118,PropTopicAliasMaximum 17865,PropResponseTopic "o$_\240\178/\a\130\230{&\DC4",PropContentType -// "0\200@\173\ENQY\215\184],\232\174\NAKN\192\EM\DC3\193\161h)\144v",PropSessionExpiryInterval -// 20005,PropSessionExpiryInterval 12331,PropRequestProblemInformation 173,PropWildcardSubscriptionAvailable -// 61,PropMaximumQoS 107,PropCorrelationData ">\206r\220\229a\171@\176W\236 IR\250B\214#\233!i\142x\rj",PropMaximumQoS -// 71,PropRetainAvailable 248,PropUserProperty "\229\213V\146U7\aP\132\135\175\166!-\203B\129\248\172\220\169" -// "a\219@\171\149\250\146Uc\166ZR",PropSessionExpiryInterval 6662,PropTopicAlias 27570,PropSubscriptionIdentifier -// 23,PropReceiveMaximum 7608]} -TEST(Connect5QCTest, Encode22) { - uint8_t pkt[] = { - 0x10, 0xcb, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x4b, 0xa0, 0x91, 0x1, 0x17, 0x76, 0x22, 0x45, - 0xc9, 0x8, 0x0, 0xc, 0x6f, 0x24, 0x5f, 0xf0, 0xb2, 0x2f, 0x7, 0x82, 0xe6, 0x7b, 0x26, 0x14, 0x3, 0x0, 0x17, - 0x30, 0xc8, 0x40, 0xad, 0x5, 0x59, 0xd7, 0xb8, 0x5d, 0x2c, 0xe8, 0xae, 0x15, 0x4e, 0xc0, 0x19, 0x13, 0xc1, 0xa1, - 0x68, 0x29, 0x90, 0x76, 0x11, 0x0, 0x0, 0x4e, 0x25, 0x11, 0x0, 0x0, 0x30, 0x2b, 0x17, 0xad, 0x28, 0x3d, 0x24, - 0x6b, 0x9, 0x0, 0x19, 0x3e, 0xce, 0x72, 0xdc, 0xe5, 0x61, 0xab, 0x40, 0xb0, 0x57, 0xec, 0x20, 0x49, 0x52, 0xfa, - 0x42, 0xd6, 0x23, 0xe9, 0x21, 0x69, 0x8e, 0x78, 0xd, 0x6a, 0x24, 0x47, 0x25, 0xf8, 0x26, 0x0, 0x15, 0xe5, 0xd5, - 0x56, 0x92, 0x55, 0x37, 0x7, 0x50, 0x84, 0x87, 0xaf, 0xa6, 0x21, 0x2d, 0xcb, 0x42, 0x81, 0xf8, 0xac, 0xdc, 0xa9, - 0x0, 0xc, 0x61, 0xdb, 0x40, 0xab, 0x95, 0xfa, 0x92, 0x55, 0x63, 0xa6, 0x5a, 0x52, 0x11, 0x0, 0x0, 0x1a, 0x6, - 0x23, 0x6b, 0xb2, 0xb, 0x17, 0x21, 0x1d, 0xb8, 0x0, 0xb, 0x9c, 0xf2, 0x44, 0x39, 0xb6, 0x85, 0x65, 0x11, 0xe7, - 0xb1, 0x14, 0x0, 0xa, 0xfb, 0x5a, 0xf0, 0xc2, 0x4b, 0xe8, 0xef, 0x8d, 0x41, 0x5a, 0x0, 0x13, 0xd7, 0x5d, 0x19, - 0x89, 0xc9, 0xa7, 0x94, 0x97, 0xe0, 0x7a, 0x5e, 0x68, 0xe7, 0xb4, 0xd5, 0x55, 0x6b, 0x2b, 0x93}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x6f, 0x24, 0x5f, 0xf0, 0xb2, 0x2f, 0x7, 0x82, 0xe6, 0x7b, 0x26, 0x14}; - uint8_t bytesprops1[] = {0x30, 0xc8, 0x40, 0xad, 0x5, 0x59, 0xd7, 0xb8, 0x5d, 0x2c, 0xe8, 0xae, - 0x15, 0x4e, 0xc0, 0x19, 0x13, 0xc1, 0xa1, 0x68, 0x29, 0x90, 0x76}; - uint8_t bytesprops2[] = {0x3e, 0xce, 0x72, 0xdc, 0xe5, 0x61, 0xab, 0x40, 0xb0, 0x57, 0xec, 0x20, 0x49, - 0x52, 0xfa, 0x42, 0xd6, 0x23, 0xe9, 0x21, 0x69, 0x8e, 0x78, 0xd, 0x6a}; - uint8_t bytesprops4[] = {0x61, 0xdb, 0x40, 0xab, 0x95, 0xfa, 0x92, 0x55, 0x63, 0xa6, 0x5a, 0x52}; - uint8_t bytesprops3[] = {0xe5, 0xd5, 0x56, 0x92, 0x55, 0x37, 0x7, 0x50, 0x84, 0x87, 0xaf, - 0xa6, 0x21, 0x2d, 0xcb, 0x42, 0x81, 0xf8, 0xac, 0xdc, 0xa9}; +// ConnectRequest {_username = Just "\252\245y:\200\b\234\&6\225\SYN\158z\238&\CAN\175\138", _password = Just "|\218-vl\SYN\222f\159V\138\232\203", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "5Y\164\&1`u\255\252\&8\171&", _willMsg = "n\STX\DC2\DEL_\171\ENQ\171\145\175\ESC6\158\&2\246\f%h\190\233O\232\175\190\128\STX\178\210\245l", _willProps = [PropContentType "\228;\253g4\186^\190Y\132L3El",PropSubscriptionIdentifierAvailable 36,PropUserProperty "<=\160\146\223\164\219\191\202\ENQ\DEL\154=H\217m\137\160\187" "\162\171=\164\188\254n\226\145\167\213",PropCorrelationData -// "\254{\202\142\199\US\216I%\202W\218\245\DC2Kt\192\189",PropServerKeepAlive 21417,PropAuthenticationMethod -// "a\b\185\183:\193\206",PropResponseTopic "{\207\162\US\234\STXT\147\143S\t",PropContentType -// "\199\\J\v",PropMessageExpiryInterval 14422,PropRetainAvailable 4,PropAuthenticationMethod -// "&*\128\160\236\137\134\190b\167\191/\210m\167\162?h\254\"\234aO\STX.\181x\146\ACK<",PropCorrelationData -// "\DC2\225\253\&5\FSh2\205j+\200W\NUL\228\219\DLE]T\192\149\DC3\142eI",PropServerKeepAlive 6578]} -TEST(Connect5QCTest, Encode23) { - uint8_t pkt[] = { - 0x10, 0xcb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x84, 0x4b, 0x3f, 0x9f, 0x2, 0x9, 0x0, 0x1c, 0x16, - 0xbf, 0x95, 0xdb, 0x76, 0xf7, 0xb, 0xc0, 0xe4, 0xe3, 0xbb, 0x31, 0xc4, 0x26, 0x6e, 0xa7, 0x21, 0x34, 0x52, 0xe, - 0x9a, 0x28, 0x7d, 0x32, 0x52, 0x36, 0xe6, 0x8a, 0x21, 0x4, 0x3e, 0x1a, 0x0, 0x13, 0xec, 0xa2, 0x11, 0xd, 0x52, - 0xad, 0x87, 0xb7, 0xbf, 0xf2, 0x2f, 0x55, 0x4e, 0x60, 0x64, 0xcf, 0xdb, 0xc6, 0x9d, 0x1a, 0x0, 0x1, 0x97, 0x27, - 0x0, 0x0, 0x7e, 0xc, 0x21, 0xb, 0xb3, 0x12, 0x0, 0x4, 0xcb, 0x48, 0xb8, 0xae, 0x23, 0x5a, 0xc9, 0x1f, 0x0, - 0x16, 0x93, 0x1d, 0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b, - 0xc8, 0x57, 0x0, 0xe4, 0xdb, 0x10, 0x5d, 0x54, 0xc0, 0x95, 0x13, 0x8e, 0x65, 0x49, 0x13, 0x19, 0xb2, 0x0, 0x8, - 0x94, 0x8b, 0xc0, 0x2b, 0xb1, 0x6f, 0xb6, 0xcd, 0x71, 0x2, 0x0, 0x0, 0x25, 0x99, 0x15, 0x0, 0x1e, 0xbb, 0x7b, - 0x21, 0x4f, 0xce, 0x2d, 0x20, 0xb7, 0x51, 0x5e, 0x57, 0x7e, 0x33, 0xf5, 0x61, 0xc1, 0xa9, 0x1f, 0x52, 0x5, 0xfe, - 0xe2, 0xb7, 0x12, 0x81, 0xfd, 0xeb, 0x1c, 0x69, 0x2e, 0x29, 0x68, 0x1a, 0x0, 0xf, 0x20, 0xb3, 0xb0, 0x8b, 0x6b, - 0x39, 0x35, 0x39, 0x29, 0xd7, 0xe7, 0x51, 0x84, 0x70, 0xd3, 0x1c, 0x0, 0x0, 0x22, 0x7a, 0x83, 0x2a, 0x31, 0x8, - 0x0, 0x1, 0xad, 0x2, 0x0, 0x0, 0x60, 0x3f, 0x1, 0xa2, 0x3, 0x0, 0xd, 0xe5, 0xce, 0x7d, 0xd2, 0x4a, 0xc7, - 0x61, 0x7e, 0x5f, 0xbe, 0x7c, 0xc5, 0x21, 0x1f, 0x0, 0xc, 0x83, 0x89, 0xc9, 0xcb, 0x60, 0xf4, 0x26, 0x64, 0x22, - 0xd2, 0x75, 0xb9, 0x23, 0x58, 0x6b, 0x2a, 0x29, 0x0, 0x2, 0x88, 0x78, 0x0, 0x12, 0xaa, 0xad, 0x46, 0x39, 0xd3, - 0x28, 0xd1, 0xdf, 0x40, 0x25, 0x2, 0x0, 0xaf, 0x90, 0xd5, 0x88, 0xe0, 0x62, 0x0, 0xa, 0x58, 0x26, 0x34, 0x24, - 0x23, 0x96, 0x66, 0x66, 0x63, 0x93}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x16, 0xbf, 0x95, 0xdb, 0x76, 0xf7, 0xb, 0xc0, 0xe4, 0xe3, 0xbb, 0x31, 0xc4, 0x26, - 0x6e, 0xa7, 0x21, 0x34, 0x52, 0xe, 0x9a, 0x28, 0x7d, 0x32, 0x52, 0x36, 0xe6, 0x8a}; - uint8_t bytesprops1[] = {0xec, 0xa2, 0x11, 0xd, 0x52, 0xad, 0x87, 0xb7, 0xbf, 0xf2, - 0x2f, 0x55, 0x4e, 0x60, 0x64, 0xcf, 0xdb, 0xc6, 0x9d}; - uint8_t bytesprops2[] = {0x97}; - uint8_t bytesprops3[] = {0xcb, 0x48, 0xb8, 0xae}; - uint8_t bytesprops4[] = {0x93, 0x1d, 0x11, 0x31, 0x4e, 0x8, 0x99, 0xf7, 0xf2, 0x62, 0x75, - 0x37, 0x7f, 0x7e, 0x1, 0xcf, 0x7d, 0xf7, 0x7, 0xae, 0xc3, 0xb7}; - uint8_t bytesprops6[] = {0x65, 0xcc, 0x1d, 0x66, 0x48, 0x29, 0xb7, 0xb4, 0xb0, 0xe1}; - uint8_t bytesprops5[] = {0x6e, 0xc8, 0xb7, 0xa8, 0xee, 0x4e, 0xd, 0x8b, 0xe6, 0xb6, 0x5b, 0xb}; - uint8_t bytesprops7[] = {0x79, 0x3c, 0xc3}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops9[] = {0x6b, 0x58, 0x8e, 0x26, 0xda, 0x3e, 0xbc, 0xfe, 0x6e, 0xe2, 0x91, 0xa7, 0xd5}; - uint8_t bytesprops10[] = {0xfe, 0x7b, 0xca, 0x8e, 0xc7, 0x1f, 0xd8, 0x49, 0x25, - 0xca, 0x57, 0xda, 0xf5, 0x12, 0x4b, 0x74, 0xc0, 0xbd}; - uint8_t bytesprops11[] = {0x61, 0x8, 0xb9, 0xb7, 0x3a, 0xc1, 0xce}; - uint8_t bytesprops12[] = {0x7b, 0xcf, 0xa2, 0x1f, 0xea, 0x2, 0x54, 0x93, 0x8f, 0x53, 0x9}; - uint8_t bytesprops13[] = {0xc7, 0x5c, 0x4a, 0xb}; - uint8_t bytesprops14[] = {0x26, 0x2a, 0x80, 0xa0, 0xec, 0x89, 0x86, 0xbe, 0x62, 0xa7, 0xbf, 0x2f, 0xd2, 0x6d, 0xa7, - 0xa2, 0x3f, 0x68, 0xfe, 0x22, 0xea, 0x61, 0x4f, 0x2, 0x2e, 0xb5, 0x78, 0x92, 0x6, 0x3c}; - uint8_t bytesprops15[] = {0x12, 0xe1, 0xfd, 0x35, 0x1c, 0x68, 0x32, 0xcd, 0x6a, 0x2b, 0xc8, 0x57, - 0x0, 0xe4, 0xdb, 0x10, 0x5d, 0x54, 0xc0, 0x95, 0x13, 0x8e, 0x65, 0x49}; +// ConnectRequest {_username = Just "\223*\129F(\130\&4\142\220[3\138\202/U\241z\144\214\227\&9\162\164\149", _password = Just "k\177\238>\207X\198i\188\175\151\215\&4\250\DC2\133\DC3\208", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "", _willMsg = "O\f\163R\254G\172]\199\227#f/\147[\SI", _willProps = [PropSubscriptionIdentifier 22,PropMessageExpiryInterval 29484,PropSubscriptionIdentifierAvailable 190,PropMaximumPacketSize 24579,PropTopicAliasMaximum 5448,PropMaximumQoS 22,PropCorrelationData "\209\204\165\223\218\222\200N#\207",PropContentType "\227F\ACKS\147\240=\219\SUBa|\213w\227`",PropMaximumPacketSize 30812,PropMaximumPacketSize 12528,PropPayloadFormatIndicator 190,PropSubscriptionIdentifier 25,PropTopicAlias 30923,PropServerReference "\233W\US\136\152\174T\192\209C\253\158\226\161\146rp\172\DEL\205r\211wE\221\145\147",PropAuthenticationMethod "\n~\180\194v\180\181-\226\&3r\165\142.\229\229n\138\&0L\FS\205!;^",PropSharedSubscriptionAvailable 136,PropWildcardSubscriptionAvailable 41,PropSharedSubscriptionAvailable 117,PropTopicAlias 25089,PropMaximumQoS 67]}), _cleanSession = False, _keepAlive = 1168, _connID = "\t\208\CAN'\235Mek\SI\DC2;\237\GS\194~\SOH,", _properties = [PropAssignedClientIdentifier "\222d\SYN;4\DELQt~#2s\SO\171\146t'I\231\ACK\n\242\128\244\173\219s-\FS",PropRequestResponseInformation 138,PropReasonString "\186E\DEL\DC3\223o\251vX7\245\179\197\157",PropRetainAvailable 242,PropRequestProblemInformation 122,PropResponseInformation "\135b\EM\248\205\&9\197\134'\205\237Z\202\175\SUB,",PropReasonString "\252z\244n\166\153dEG*\221Yt\213\132",PropResponseInformation "\203\253\173]",PropServerReference ")\198\236\207\&8",PropSubscriptionIdentifier 28,PropMaximumQoS 187,PropMaximumPacketSize 31216,PropRetainAvailable 158,PropSessionExpiryInterval 28,PropResponseTopic "\142\239\FS\211\&8\151\240\n\156\205\146\137\253\v\130/\GS\131\234/\fit#\171\221\155\ETX\148}",PropRequestResponseInformation 182,PropResponseTopic "\139\255\158\207&\128\252A\DC3\180hl\149\b",PropSessionExpiryInterval 12368,PropMaximumPacketSize 2358,PropPayloadFormatIndicator 99,PropResponseTopic "\209\183\&1\168\EM\169\&4",PropWillDelayInterval 190,PropAssignedClientIdentifier "w\204\DC2\180\245\133\186\225L\DC1\182\248\GS\190\137V\223\189\246\254",PropMaximumQoS 123,PropMessageExpiryInterval 11858,PropWillDelayInterval 24601]} +TEST(Connect5QCTest, Encode26) { +uint8_t pkt[] = {0x10, 0xd8, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x4, 0x90, 0xed, 0x1, 0x12, 0x0, 0x1d, 0xde, 0x64, 0x16, 0x3b, 0x34, 0x7f, 0x51, 0x74, 0x7e, 0x23, 0x32, 0x73, 0xe, 0xab, 0x92, 0x74, 0x27, 0x49, 0xe7, 0x6, 0xa, 0xf2, 0x80, 0xf4, 0xad, 0xdb, 0x73, 0x2d, 0x1c, 0x19, 0x8a, 0x1f, 0x0, 0xe, 0xba, 0x45, 0x7f, 0x13, 0xdf, 0x6f, 0xfb, 0x76, 0x58, 0x37, 0xf5, 0xb3, 0xc5, 0x9d, 0x25, 0xf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1, 0x7a, 0x90, 0xd6, 0xe3, 0x39, 0xa2, 0xa4, 0x95, 0x0, 0x12, 0x6b, 0xb1, 0xee, 0x3e, 0xcf, 0x58, 0xc6, 0x69, 0xbc, 0xaf, 0x97, 0xd7, 0x34, 0xfa, 0x12, 0x85, 0x13, 0xd0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xde, 0x64, 0x16, 0x3b, 0x34, 0x7f, 0x51, 0x74, 0x7e, 0x23, 0x32, 0x73, 0xe, 0xab, 0x92, 0x74, 0x27, 0x49, 0xe7, 0x6, 0xa, 0xf2, 0x80, 0xf4, 0xad, 0xdb, 0x73, 0x2d, 0x1c}; + uint8_t bytesprops1[] = {0xba, 0x45, 0x7f, 0x13, 0xdf, 0x6f, 0xfb, 0x76, 0x58, 0x37, 0xf5, 0xb3, 0xc5, 0x9d}; + uint8_t bytesprops2[] = {0x87, 0x62, 0x19, 0xf8, 0xcd, 0x39, 0xc5, 0x86, 0x27, 0xcd, 0xed, 0x5a, 0xca, 0xaf, 0x1a, 0x2c}; + uint8_t bytesprops3[] = {0xfc, 0x7a, 0xf4, 0x6e, 0xa6, 0x99, 0x64, 0x45, 0x47, 0x2a, 0xdd, 0x59, 0x74, 0xd5, 0x84}; + uint8_t bytesprops4[] = {0xcb, 0xfd, 0xad, 0x5d}; + uint8_t bytesprops5[] = {0x29, 0xc6, 0xec, 0xcf, 0x38}; + uint8_t bytesprops6[] = {0x8e, 0xef, 0x1c, 0xd3, 0x38, 0x97, 0xf0, 0xa, 0x9c, 0xcd, 0x92, 0x89, 0xfd, 0xb, 0x82, 0x2f, 0x1d, 0x83, 0xea, 0x2f, 0xc, 0x69, 0x74, 0x23, 0xab, 0xdd, 0x9b, 0x3, 0x94, 0x7d}; + uint8_t bytesprops7[] = {0x8b, 0xff, 0x9e, 0xcf, 0x26, 0x80, 0xfc, 0x41, 0x13, 0xb4, 0x68, 0x6c, 0x95, 0x8}; + uint8_t bytesprops8[] = {0xd1, 0xb7, 0x31, 0xa8, 0x19, 0xa9, 0x34}; + uint8_t bytesprops9[] = {0x77, 0xcc, 0x12, 0xb4, 0xf5, 0x85, 0xba, 0xe1, 0x4c, 0x11, 0xb6, 0xf8, 0x1d, 0xbe, 0x89, 0x56, 0xdf, 0xbd, 0xf6, 0xfe}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1086}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32268}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2995}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23241}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops5}, .v = {10, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4691}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21417}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14422}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops15}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6578}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31216}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12368}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2358}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 190}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11858}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24601}}, }; lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xbb, 0x7b, 0x21, 0x4f, 0xce, 0x2d, 0x20, 0xb7, 0x51, 0x5e, - 0x57, 0x7e, 0x33, 0xf5, 0x61, 0xc1, 0xa9, 0x1f, 0x52, 0x5, - 0xfe, 0xe2, 0xb7, 0x12, 0x81, 0xfd, 0xeb, 0x1c, 0x69, 0x2e}; - uint8_t byteswillprops1[] = {0x20, 0xb3, 0xb0, 0x8b, 0x6b, 0x39, 0x35, 0x39, - 0x29, 0xd7, 0xe7, 0x51, 0x84, 0x70, 0xd3}; - uint8_t byteswillprops2[] = {0}; - uint8_t byteswillprops3[] = {0xad}; - uint8_t byteswillprops4[] = {0xe5, 0xce, 0x7d, 0xd2, 0x4a, 0xc7, 0x61, 0x7e, 0x5f, 0xbe, 0x7c, 0xc5, 0x21}; - uint8_t byteswillprops5[] = {0x83, 0x89, 0xc9, 0xcb, 0x60, 0xf4, 0x26, 0x64, 0x22, 0xd2, 0x75, 0xb9}; - +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xd1, 0xcc, 0xa5, 0xdf, 0xda, 0xde, 0xc8, 0x4e, 0x23, 0xcf}; + uint8_t byteswillprops1[] = {0xe3, 0x46, 0x6, 0x53, 0x93, 0xf0, 0x3d, 0xdb, 0x1a, 0x61, 0x7c, 0xd5, 0x77, 0xe3, 0x60}; + uint8_t byteswillprops2[] = {0xe9, 0x57, 0x1f, 0x88, 0x98, 0xae, 0x54, 0xc0, 0xd1, 0x43, 0xfd, 0x9e, 0xe2, 0xa1, 0x92, 0x72, 0x70, 0xac, 0x7f, 0xcd, 0x72, 0xd3, 0x77, 0x45, 0xdd, 0x91, 0x93}; + uint8_t byteswillprops3[] = {0xa, 0x7e, 0xb4, 0xc2, 0x76, 0xb4, 0xb5, 0x2d, 0xe2, 0x33, 0x72, 0xa5, 0x8e, 0x2e, 0xe5, 0xe5, 0x6e, 0x8a, 0x30, 0x4c, 0x1c, 0xcd, 0x21, 0x3b, 0x5e}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9625}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31363}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24639}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22635}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29484}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24579}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5448}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30812}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12528}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30923}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25089}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 67}}, }; - lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x88, 0x78}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xaa, 0xad, 0x46, 0x39, 0xd3, 0x28, 0xd1, 0xdf, 0x40, - 0x25, 0x2, 0x0, 0xaf, 0x90, 0xd5, 0x88, 0xe0, 0x62}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19263; - uint8_t client_id_bytes[] = {0x94, 0x8b, 0xc0, 0x2b, 0xb1, 0x6f, 0xb6, 0xcd}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x58, 0x26, 0x34, 0x24, 0x23, 0x96, 0x66, 0x66, 0x63, 0x93}; - lwmqtt_string_t username = {10, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4f, 0xc, 0xa3, 0x52, 0xfe, 0x47, 0xac, 0x5d, 0xc7, 0xe3, 0x23, 0x66, 0x2f, 0x93, 0x5b, 0xf}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = false; +opts.keep_alive = 1168; + uint8_t client_id_bytes[] = {0x9, 0xd0, 0x18, 0x27, 0xeb, 0x4d, 0x65, 0x6b, 0xf, 0x12, 0x3b, 0xed, 0x1d, 0xc2, 0x7e, 0x1, 0x2c}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xdf, 0x2a, 0x81, 0x46, 0x28, 0x82, 0x34, 0x8e, 0xdc, 0x5b, 0x33, 0x8a, 0xca, 0x2f, 0x55, 0xf1, 0x7a, 0x90, 0xd6, 0xe3, 0x39, 0xa2, 0xa4, 0x95}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0x6b, 0xb1, 0xee, 0x3e, 0xcf, 0x58, 0xc6, 0x69, 0xbc, 0xaf, 0x97, 0xd7, 0x34, 0xfa, 0x12, 0x85, 0x13, 0xd0}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "\169\134\229\177\141\167:\"\240_\168S\ETB~\228\190\175\174\ACK\168\191@\171\199\GSM\208h", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\173en(3\180\NAK\238\226z\SO\231\221<8u\183\188\229\221\231\131\185\v\203;", _willMsg = -// "z#W\234\STX\229\164\203\229\130\201\SOHy\205\&3\169>\205\160\203dE\ACK\255\213\164\225\ESC\163", _willProps = -// [PropRequestProblemInformation 242,PropAuthenticationData "",PropAuthenticationData -// "\"yp\192\175\146C?8Q\CAN\229/\SOp\156@\251\143\150\219\144$\DC2'",PropServerKeepAlive 23446,PropReasonString -// "\186\198\152Y\237\184\EOT\147\184\169\189H>",PropSharedSubscriptionAvailable 254,PropSessionExpiryInterval -// 20915,PropResponseTopic "EN\v\ENQ\164\&6\RS\NULY>\157\204\SUB",PropPayloadFormatIndicator -// 53,PropPayloadFormatIndicator 115,PropReasonString -// "\SIX6D\176\186&\222\EOT7\243\252\194\145",PropWildcardSubscriptionAvailable 157,PropContentType -// "B>\225z\253+\221\165",PropSessionExpiryInterval 8027,PropMaximumPacketSize 3910]}), _cleanSession = True, _keepAlive -// = 14436, _connID = "\"\179\&5mH+{\187\208\t`<\149\EOT\249\182\214\184\&8\198\201\139\186\&5", _properties = []} -TEST(Connect5QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0xf6, 0x1, 0x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 0x23, 0x57, 0xea, 0x2, 0xe5, 0xa4, 0xcb, 0xe5, 0x82, 0xc9, 0x1, 0x79, 0xcd, - 0x33, 0xa9, 0x3e, 0xcd, 0xa0, 0xcb, 0x64, 0x45, 0x6, 0xff, 0xd5, 0xa4, 0xe1, 0x1b, 0xa3, 0x0, 0x1c, - 0xa9, 0x86, 0xe5, 0xb1, 0x8d, 0xa7, 0x3a, 0x22, 0xf0, 0x5f, 0xa8, 0x53, 0x17, 0x7e, 0xe4, 0xbe, 0xaf, - 0xae, 0x6, 0xa8, 0xbf, 0x40, 0xab, 0xc7, 0x1d, 0x4d, 0xd0, 0x68}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - - lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0}; - uint8_t byteswillprops1[] = {0x22, 0x79, 0x70, 0xc0, 0xaf, 0x92, 0x43, 0x3f, 0x38, 0x51, 0x18, 0xe5, 0x2f, - 0xe, 0x70, 0x9c, 0x40, 0xfb, 0x8f, 0x96, 0xdb, 0x90, 0x24, 0x12, 0x27}; - uint8_t byteswillprops2[] = {0xba, 0xc6, 0x98, 0x59, 0xed, 0xb8, 0x4, 0x93, 0xb8, 0xa9, 0xbd, 0x48, 0x3e}; - uint8_t byteswillprops3[] = {0x45, 0x4e, 0xb, 0x5, 0xa4, 0x36, 0x1e, 0x0, 0x59, 0x3e, 0x9d, 0xcc, 0x1a}; - uint8_t byteswillprops4[] = {0xf, 0x58, 0x36, 0x44, 0xb0, 0xba, 0x26, 0xde, 0x4, 0x37, 0xf3, 0xfc, 0xc2, 0x91}; - uint8_t byteswillprops5[] = {0x42, 0x3e, 0xe1, 0x7a, 0xfd, 0x2b, 0xdd, 0xa5}; +// ConnectRequest {_username = Just "\220\&2", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\174'\200lI", _willMsg = "\GS\ETXa\251\147I\r\201>\212r\195\DC1\164\SO!", _willProps = [PropCorrelationData "\213\240\188\235\211q\133\230\201c|\186#/c \216@\152\207\247qx\154",PropReasonString "",PropWildcardSubscriptionAvailable 115,PropRequestProblemInformation 42,PropPayloadFormatIndicator 100,PropResponseTopic "\ESC\202\134\192\EOT\136D\176\195Re\162\130\176H$\219T\GS\140\206\213\244\DC2.'s",PropPayloadFormatIndicator 234,PropCorrelationData "\220\RS-\147\218\a\201-\200",PropServerReference "\b\246H\240\NULVy\131\188\239\208\159J\242\EM\185\193v\166\&8\EOT\ENQ<\NUL#\209",PropServerKeepAlive 21725,PropPayloadFormatIndicator 67,PropReceiveMaximum 20662,PropWillDelayInterval 3391,PropResponseTopic "\187\235\SO\205\188\214u;}%2\171z\168\179\255\150\f\NAK\193_\192\174t",PropSubscriptionIdentifier 19,PropWildcardSubscriptionAvailable 231,PropMaximumPacketSize 10332,PropAuthenticationData "\CANt!K=c$\169\181\138\233Q\200#\156Q\210\153\EOT}5|\241\193v\t\149\214-",PropMaximumQoS 239,PropAssignedClientIdentifier "\249\&0=\193S\184\SI\225\139\141\152A(\204c\195y\ESCuR\177\145j\128\149",PropWildcardSubscriptionAvailable 226]}), _cleanSession = True, _keepAlive = 6357, _connID = "\200", _properties = [PropUserProperty "\193\162\129\r\170q\170\236\201\f\155\ETX\144:" "\159\158\STX)\141Q\217\237\236k\DLE",PropPayloadFormatIndicator 247,PropAssignedClientIdentifier "T(\218\253\246\215\f\205\ENQ\159\193\ETBX\DC1\215 \236\222gw\157\r \237\178",PropPayloadFormatIndicator 98,PropRequestResponseInformation 123,PropSubscriptionIdentifierAvailable 14,PropReceiveMaximum 3111,PropMaximumPacketSize 10786,PropRequestResponseInformation 127,PropSubscriptionIdentifierAvailable 109,PropRetainAvailable 43,PropMessageExpiryInterval 27459,PropWillDelayInterval 1445,PropWildcardSubscriptionAvailable 190,PropCorrelationData "9=\212a\137\DC3\SI~\225\208\241\214\157E\f\249\&3",PropMaximumQoS 232,PropMessageExpiryInterval 2828,PropTopicAliasMaximum 31253,PropAssignedClientIdentifier "y.\194\255G\SUB",PropAuthenticationData "\204K(\235\164\167 ?\165\STX=>P\143\246\239\164\197\&8\r\219\165\CAN\129Be",PropPayloadFormatIndicator 36,PropSessionExpiryInterval 30771,PropReasonString "g\201",PropRetainAvailable 233,PropResponseTopic "\246\200",PropAuthenticationMethod "\161\215{",PropMessageExpiryInterval 6761,PropSubscriptionIdentifier 13,PropSubscriptionIdentifierAvailable 86,PropSharedSubscriptionAvailable 210]} +TEST(Connect5QCTest, Encode27) { +uint8_t pkt[] = {0x10, 0xd0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb6, 0x18, 0xd5, 0xc4, 0x1, 0x26, 0x0, 0xe, 0xc1, 0xa2, 0x81, 0xd, 0xaa, 0x71, 0xaa, 0xec, 0xc9, 0xc, 0x9b, 0x3, 0x90, 0x3a, 0x0, 0xb, 0x9f, 0x9e, 0x2, 0x29, 0x8d, 0x51, 0xd9, 0xed, 0xec, 0x6b, 0x10, 0x1, 0xf7, 0x12, 0x0, 0x19, 0x54, 0x28, 0xda, 0xfd, 0xf6, 0xd7, 0xc, 0xcd, 0x5, 0x9f, 0xc1, 0x17, 0x58, 0x11, 0xd7, 0x20, 0xec, 0xde, 0x67, 0x77, 0x9d, 0xd, 0x20, 0xed, 0xb2, 0x1, 0x62, 0x19, 0x7b, 0x29, 0xe, 0x21, 0xc, 0x27, 0x27, 0x0, 0x0, 0x2a, 0x22, 0x19, 0x7f, 0x29, 0x6d, 0x25, 0x2b, 0x2, 0x0, 0x0, 0x6b, 0x43, 0x18, 0x0, 0x0, 0x5, 0xa5, 0x28, 0xbe, 0x9, 0x0, 0x11, 0x39, 0x3d, 0xd4, 0x61, 0x89, 0x13, 0xf, 0x7e, 0xe1, 0xd0, 0xf1, 0xd6, 0x9d, 0x45, 0xc, 0xf9, 0x33, 0x24, 0xe8, 0x2, 0x0, 0x0, 0x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c, 0x0, 0x23, 0xd1, 0x13, 0x54, 0xdd, 0x1, 0x43, 0x21, 0x50, 0xb6, 0x18, 0x0, 0x0, 0xd, 0x3f, 0x8, 0x0, 0x18, 0xbb, 0xeb, 0xe, 0xcd, 0xbc, 0xd6, 0x75, 0x3b, 0x7d, 0x25, 0x32, 0xab, 0x7a, 0xa8, 0xb3, 0xff, 0x96, 0xc, 0x15, 0xc1, 0x5f, 0xc0, 0xae, 0x74, 0xb, 0x13, 0x28, 0xe7, 0x27, 0x0, 0x0, 0x28, 0x5c, 0x16, 0x0, 0x1d, 0x18, 0x74, 0x21, 0x4b, 0x3d, 0x63, 0x24, 0xa9, 0xb5, 0x8a, 0xe9, 0x51, 0xc8, 0x23, 0x9c, 0x51, 0xd2, 0x99, 0x4, 0x7d, 0x35, 0x7c, 0xf1, 0xc1, 0x76, 0x9, 0x95, 0xd6, 0x2d, 0x24, 0xef, 0x12, 0x0, 0x19, 0xf9, 0x30, 0x3d, 0xc1, 0x53, 0xb8, 0xf, 0xe1, 0x8b, 0x8d, 0x98, 0x41, 0x28, 0xcc, 0x63, 0xc3, 0x79, 0x1b, 0x75, 0x52, 0xb1, 0x91, 0x6a, 0x80, 0x95, 0x28, 0xe2, 0x0, 0x5, 0xae, 0x27, 0xc8, 0x6c, 0x49, 0x0, 0x10, 0x1d, 0x3, 0x61, 0xfb, 0x93, 0x49, 0xd, 0xc9, 0x3e, 0xd4, 0x72, 0xc3, 0x11, 0xa4, 0xe, 0x21, 0x0, 0x2, 0xdc, 0x32}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops1[] = {0x9f, 0x9e, 0x2, 0x29, 0x8d, 0x51, 0xd9, 0xed, 0xec, 0x6b, 0x10}; + uint8_t bytesprops0[] = {0xc1, 0xa2, 0x81, 0xd, 0xaa, 0x71, 0xaa, 0xec, 0xc9, 0xc, 0x9b, 0x3, 0x90, 0x3a}; + uint8_t bytesprops2[] = {0x54, 0x28, 0xda, 0xfd, 0xf6, 0xd7, 0xc, 0xcd, 0x5, 0x9f, 0xc1, 0x17, 0x58, 0x11, 0xd7, 0x20, 0xec, 0xde, 0x67, 0x77, 0x9d, 0xd, 0x20, 0xed, 0xb2}; + uint8_t bytesprops3[] = {0x39, 0x3d, 0xd4, 0x61, 0x89, 0x13, 0xf, 0x7e, 0xe1, 0xd0, 0xf1, 0xd6, 0x9d, 0x45, 0xc, 0xf9, 0x33}; + uint8_t bytesprops4[] = {0x79, 0x2e, 0xc2, 0xff, 0x47, 0x1a}; + uint8_t bytesprops5[] = {0xcc, 0x4b, 0x28, 0xeb, 0xa4, 0xa7, 0x20, 0x3f, 0xa5, 0x2, 0x3d, 0x3e, 0x50, 0x8f, 0xf6, 0xef, 0xa4, 0xc5, 0x38, 0xd, 0xdb, 0xa5, 0x18, 0x81, 0x42, 0x65}; + uint8_t bytesprops6[] = {0x67, 0xc9}; + uint8_t bytesprops7[] = {0xf6, 0xc8}; + uint8_t bytesprops8[] = {0xa1, 0xd7, 0x7b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={14, (char*)&bytesprops0}, .v={11, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3111}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10786}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27459}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1445}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2828}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31253}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30771}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6761}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, + }; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xd5, 0xf0, 0xbc, 0xeb, 0xd3, 0x71, 0x85, 0xe6, 0xc9, 0x63, 0x7c, 0xba, 0x23, 0x2f, 0x63, 0x20, 0xd8, 0x40, 0x98, 0xcf, 0xf7, 0x71, 0x78, 0x9a}; + uint8_t byteswillprops1[] = {0}; + uint8_t byteswillprops2[] = {0x1b, 0xca, 0x86, 0xc0, 0x4, 0x88, 0x44, 0xb0, 0xc3, 0x52, 0x65, 0xa2, 0x82, 0xb0, 0x48, 0x24, 0xdb, 0x54, 0x1d, 0x8c, 0xce, 0xd5, 0xf4, 0x12, 0x2e, 0x27, 0x73}; + uint8_t byteswillprops3[] = {0xdc, 0x1e, 0x2d, 0x93, 0xda, 0x7, 0xc9, 0x2d, 0xc8}; + uint8_t byteswillprops4[] = {0x8, 0xf6, 0x48, 0xf0, 0x0, 0x56, 0x79, 0x83, 0xbc, 0xef, 0xd0, 0x9f, 0x4a, 0xf2, 0x19, 0xb9, 0xc1, 0x76, 0xa6, 0x38, 0x4, 0x5, 0x3c, 0x0, 0x23, 0xd1}; + uint8_t byteswillprops5[] = {0xbb, 0xeb, 0xe, 0xcd, 0xbc, 0xd6, 0x75, 0x3b, 0x7d, 0x25, 0x32, 0xab, 0x7a, 0xa8, 0xb3, 0xff, 0x96, 0xc, 0x15, 0xc1, 0x5f, 0xc0, 0xae, 0x74}; + uint8_t byteswillprops6[] = {0x18, 0x74, 0x21, 0x4b, 0x3d, 0x63, 0x24, 0xa9, 0xb5, 0x8a, 0xe9, 0x51, 0xc8, 0x23, 0x9c, 0x51, 0xd2, 0x99, 0x4, 0x7d, 0x35, 0x7c, 0xf1, 0xc1, 0x76, 0x9, 0x95, 0xd6, 0x2d}; + uint8_t byteswillprops7[] = {0xf9, 0x30, 0x3d, 0xc1, 0x53, 0xb8, 0xf, 0xe1, 0x8b, 0x8d, 0x98, 0x41, 0x28, 0xcc, 0x63, 0xc3, 0x79, 0x1b, 0x75, 0x52, 0xb1, 0x91, 0x6a, 0x80, 0x95}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23446}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20915}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8027}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3910}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21725}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20662}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3391}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10332}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, }; - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xad, 0x65, 0x6e, 0x28, 0x33, 0xb4, 0x15, 0xee, 0xe2, 0x7a, 0xe, 0xe7, 0xdd, - 0x3c, 0x38, 0x75, 0xb7, 0xbc, 0xe5, 0xdd, 0xe7, 0x83, 0xb9, 0xb, 0xcb, 0x3b}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7a, 0x23, 0x57, 0xea, 0x2, 0xe5, 0xa4, 0xcb, 0xe5, 0x82, - 0xc9, 0x1, 0x79, 0xcd, 0x33, 0xa9, 0x3e, 0xcd, 0xa0, 0xcb, - 0x64, 0x45, 0x6, 0xff, 0xd5, 0xa4, 0xe1, 0x1b, 0xa3}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14436; - uint8_t client_id_bytes[] = {0x22, 0xb3, 0x35, 0x6d, 0x48, 0x2b, 0x7b, 0xbb, 0xd0, 0x9, 0x60, 0x3c, - 0x95, 0x4, 0xf9, 0xb6, 0xd6, 0xb8, 0x38, 0xc6, 0xc9, 0x8b, 0xba, 0x35}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xa9, 0x86, 0xe5, 0xb1, 0x8d, 0xa7, 0x3a, 0x22, 0xf0, 0x5f, 0xa8, 0x53, 0x17, 0x7e, - 0xe4, 0xbe, 0xaf, 0xae, 0x6, 0xa8, 0xbf, 0x40, 0xab, 0xc7, 0x1d, 0x4d, 0xd0, 0x68}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xae, 0x27, 0xc8, 0x6c, 0x49}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1d, 0x3, 0x61, 0xfb, 0x93, 0x49, 0xd, 0xc9, 0x3e, 0xd4, 0x72, 0xc3, 0x11, 0xa4, 0xe, 0x21}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 6357; + uint8_t client_id_bytes[] = {0xc8}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0xdc, 0x32}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; +opts.username = username; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "O\165\188\192\128\155\192a\198\EM?\198\230)}\161", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "s\137\218\237\244]\194(\128\202w\240\147M6\232\218\245\251\&7hf\206t", _willMsg = -// "\238+y\253\141\&0--\219\143\226YM\140U\"dA\DLE\235\128", _willProps = [PropRequestProblemInformation -// 3,PropAuthenticationMethod "\229\183\172\208\ENQ\199\204(w\US\210\ETX6\164f",PropSubscriptionIdentifier -// 12,PropReceiveMaximum 7050,PropResponseTopic -// "\193uF,@T\253\131\198\206\251\135\187~\SOH\175\130\DC3\ENQ",PropServerKeepAlive 4117,PropAuthenticationData -// "\211\t\189\145\187\208\161\141\243y[E\235\213\FS\197H5$A(k",PropMaximumQoS 169,PropPayloadFormatIndicator -// 33,PropSubscriptionIdentifier 29,PropAuthenticationMethod -// "\162\206\f\219$\250\139\159\236}>E\199",PropSubscriptionIdentifierAvailable 188,PropMessageExpiryInterval -// 17531,PropPayloadFormatIndicator 197,PropMaximumQoS 196,PropRequestResponseInformation -// 21,PropRequestProblemInformation 250,PropRetainAvailable 235,PropRequestResponseInformation 123,PropTopicAliasMaximum -// 21710,PropResponseInformation -// "\SYN\194\142n\150\227\131\221\211\GS\vH\187\r@\171\229\178\166s\DC1\148\237X\249\&5*",PropMaximumQoS -// 195,PropAuthenticationMethod "]\r\178\ACK\247",PropServerReference -// "\163\225\&7\US\140\239\131\221\218fxe",PropAssignedClientIdentifier -// "\ESC\GS\SI\DC2l\243>Gr\150\186\145\&7\218\244\234\225c\171Vgq\207oE\187"]}), _cleanSession = False, _keepAlive = -// 3208, _connID = "\DC3P\129h", _properties = [PropTopicAlias 25688]} -TEST(Connect5QCTest, Encode25) { - uint8_t pkt[] = { - 0x10, 0xa4, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6c, 0xc, 0x88, 0x3, 0x23, 0x64, 0x58, 0x0, 0x4, - 0x13, 0x50, 0x81, 0x68, 0xcb, 0x1, 0x17, 0x3, 0x15, 0x0, 0xf, 0xe5, 0xb7, 0xac, 0xd0, 0x5, 0xc7, 0xcc, 0x28, - 0x77, 0x1f, 0xd2, 0x3, 0x36, 0xa4, 0x66, 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, 0xed, 0xf4, 0x5d, 0xc2, 0x28, 0x80, 0xca, 0x77, 0xf0, 0x93, 0x4d, 0x36, 0xe8, 0xda, - 0xf5, 0xfb, 0x37, 0x68, 0x66, 0xce, 0x74, 0x0, 0x15, 0xee, 0x2b, 0x79, 0xfd, 0x8d, 0x30, 0x2d, 0x2d, 0xdb, 0x8f, - 0xe2, 0x59, 0x4d, 0x8c, 0x55, 0x22, 0x64, 0x41, 0x10, 0xeb, 0x80, 0x0, 0x10, 0x4f, 0xa5, 0xbc, 0xc0, 0x80, 0x9b, - 0xc0, 0x61, 0xc6, 0x19, 0x3f, 0xc6, 0xe6, 0x29, 0x7d, 0xa1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ConnectRequest {_username = Nothing, _password = Just "\138P\246\r\139dV\214\134\172RuyQ\235d\SI&A\169\ETX\151\187swD", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "Q\190\197\213\216\168{>!\220\238\251Zm\n\219\233\RSM\158\210\250\228\168", _willMsg = "e\227;s\172;", _willProps = [PropWildcardSubscriptionAvailable 135,PropUserProperty "H;\237\136\172Z\223\243\194G\162\189\b\253\185\147\&6\191\178\220\144d" "\233\r\133\ENQ7|\219\241m/\133\166D\155\DC2?i\SI\168\NULH\248\247\196\176",PropMessageExpiryInterval 23691,PropUserProperty "\212\220\r\SYN=)!K\200\146\177\210+\146gE\EOT\r\204)}\n\128\253\152\EOT\SO" "\183o\129n\154\160\141\FS\253\221\&3",PropServerReference "\199\&3\160\228\158\159/:\214g\248o\190\154T\199l\SOH\SO\183\142'\158\aX",PropAssignedClientIdentifier "\225\138",PropMessageExpiryInterval 16206,PropTopicAliasMaximum 12753,PropRequestResponseInformation 221,PropMaximumQoS 41,PropMaximumQoS 48,PropSubscriptionIdentifierAvailable 187,PropAuthenticationData "S\132\252\128\234\206\190!\227\163U]\160 \144\150\252)\n_",PropWildcardSubscriptionAvailable 10,PropWildcardSubscriptionAvailable 178,PropRetainAvailable 10,PropMaximumPacketSize 28852,PropAuthenticationMethod "\156vp6\253\160\172\226\221K\219z\224\SUB",PropRetainAvailable 246,PropServerKeepAlive 21476]}), _cleanSession = True, _keepAlive = 10491, _connID = "", _properties = [PropRequestProblemInformation 88,PropTopicAliasMaximum 26258,PropResponseInformation "\SOH\210\EOTt\180>\196\184\r!\200\243\237\241!w\197\183\&6 \239\NAK$B~\158zh",PropResponseTopic "A\222y\r\177d\221\241\195\130\233@\163\150?\153\130\153.Y\136\233\253",PropCorrelationData "\229\243\255X\176\208uq<}\180\145\211\235#",PropAssignedClientIdentifier "\240\227\229\SI\129K\198L\US|\244\220-K\202e/\ESC\155",PropResponseInformation "\215\192r\218T^\204\155#\175\NUL\FS\133\184U\174\145\177\STX>{\205",PropSubscriptionIdentifierAvailable 56,PropWillDelayInterval 11136,PropPayloadFormatIndicator 30,PropWillDelayInterval 5641,PropAuthenticationMethod "\171",PropResponseInformation "\176\133\\Lqu\161\ESC\232\237",PropAuthenticationMethod "\204Y\132\SOH\DEL\153C\218\164I\214\140:IC",PropMessageExpiryInterval 6360,PropRequestResponseInformation 48,PropServerReference "\134\180\170\207\172\233\149\163\210\ENQe\205\164\226:\211\143\ENQ\195\232\159",PropRetainAvailable 248,PropSubscriptionIdentifier 14,PropReceiveMaximum 13659,PropSessionExpiryInterval 23673,PropSharedSubscriptionAvailable 205,PropServerKeepAlive 19558]} +TEST(Connect5QCTest, Encode28) { +uint8_t pkt[] = {0x10, 0xfd, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x28, 0xfb, 0xe0, 0x1, 0x17, 0x58, 0x22, 0x66, 0x92, 0x1a, 0x0, 0x1c, 0x1, 0xd2, 0x4, 0x74, 0xb4, 0x3e, 0xc4, 0xb8, 0xd, 0x21, 0xc8, 0xf3, 0xed, 0xf1, 0x21, 0x77, 0xc5, 0xb7, 0x36, 0x20, 0xef, 0x15, 0x24, 0x42, 0x7e, 0x9e, 0x7a, 0x68, 0x8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b4, 0x15, 0x0, 0xe, 0x9c, 0x76, 0x70, 0x36, 0xfd, 0xa0, 0xac, 0xe2, 0xdd, 0x4b, 0xdb, 0x7a, 0xe0, 0x1a, 0x25, 0xf6, 0x13, 0x53, 0xe4, 0x0, 0x18, 0x51, 0xbe, 0xc5, 0xd5, 0xd8, 0xa8, 0x7b, 0x3e, 0x21, 0xdc, 0xee, 0xfb, 0x5a, 0x6d, 0xa, 0xdb, 0xe9, 0x1e, 0x4d, 0x9e, 0xd2, 0xfa, 0xe4, 0xa8, 0x0, 0x6, 0x65, 0xe3, 0x3b, 0x73, 0xac, 0x3b, 0x0, 0x1a, 0x8a, 0x50, 0xf6, 0xd, 0x8b, 0x64, 0x56, 0xd6, 0x86, 0xac, 0x52, 0x75, 0x79, 0x51, 0xeb, 0x64, 0xf, 0x26, 0x41, 0xa9, 0x3, 0x97, 0xbb, 0x73, 0x77, 0x44}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x1, 0xd2, 0x4, 0x74, 0xb4, 0x3e, 0xc4, 0xb8, 0xd, 0x21, 0xc8, 0xf3, 0xed, 0xf1, 0x21, 0x77, 0xc5, 0xb7, 0x36, 0x20, 0xef, 0x15, 0x24, 0x42, 0x7e, 0x9e, 0x7a, 0x68}; + uint8_t bytesprops1[] = {0x41, 0xde, 0x79, 0xd, 0xb1, 0x64, 0xdd, 0xf1, 0xc3, 0x82, 0xe9, 0x40, 0xa3, 0x96, 0x3f, 0x99, 0x82, 0x99, 0x2e, 0x59, 0x88, 0xe9, 0xfd}; + uint8_t bytesprops2[] = {0xe5, 0xf3, 0xff, 0x58, 0xb0, 0xd0, 0x75, 0x71, 0x3c, 0x7d, 0xb4, 0x91, 0xd3, 0xeb, 0x23}; + uint8_t bytesprops3[] = {0xf0, 0xe3, 0xe5, 0xf, 0x81, 0x4b, 0xc6, 0x4c, 0x1f, 0x7c, 0xf4, 0xdc, 0x2d, 0x4b, 0xca, 0x65, 0x2f, 0x1b, 0x9b}; + uint8_t bytesprops4[] = {0xd7, 0xc0, 0x72, 0xda, 0x54, 0x5e, 0xcc, 0x9b, 0x23, 0xaf, 0x0, 0x1c, 0x85, 0xb8, 0x55, 0xae, 0x91, 0xb1, 0x2, 0x3e, 0x7b, 0xcd}; + uint8_t bytesprops5[] = {0xab}; + uint8_t bytesprops6[] = {0xb0, 0x85, 0x5c, 0x4c, 0x71, 0x75, 0xa1, 0x1b, 0xe8, 0xed}; + uint8_t bytesprops7[] = {0xcc, 0x59, 0x84, 0x1, 0x7f, 0x99, 0x43, 0xda, 0xa4, 0x49, 0xd6, 0x8c, 0x3a, 0x49, 0x43}; + uint8_t bytesprops8[] = {0x86, 0xb4, 0xaa, 0xcf, 0xac, 0xe9, 0x95, 0xa3, 0xd2, 0x5, 0x65, 0xcd, 0xa4, 0xe2, 0x3a, 0xd3, 0x8f, 0x5, 0xc3, 0xe8, 0x9f}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25688}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26258}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11136}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5641}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6360}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13659}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23673}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19558}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe5, 0xb7, 0xac, 0xd0, 0x5, 0xc7, 0xcc, 0x28, 0x77, 0x1f, 0xd2, 0x3, 0x36, 0xa4, 0x66}; - uint8_t byteswillprops1[] = {0xc1, 0x75, 0x46, 0x2c, 0x40, 0x54, 0xfd, 0x83, 0xc6, 0xce, - 0xfb, 0x87, 0xbb, 0x7e, 0x1, 0xaf, 0x82, 0x13, 0x5}; - uint8_t byteswillprops2[] = {0xd3, 0x9, 0xbd, 0x91, 0xbb, 0xd0, 0xa1, 0x8d, 0xf3, 0x79, 0x5b, - 0x45, 0xeb, 0xd5, 0x1c, 0xc5, 0x48, 0x35, 0x24, 0x41, 0x28, 0x6b}; - uint8_t byteswillprops3[] = {0xa2, 0xce, 0xc, 0xdb, 0x24, 0xfa, 0x8b, 0x9f, 0xec, 0x7d, 0x3e, 0x45, 0xc7}; - uint8_t byteswillprops4[] = {0x16, 0xc2, 0x8e, 0x6e, 0x96, 0xe3, 0x83, 0xdd, 0xd3, 0x1d, 0xb, 0x48, 0xbb, 0xd, - 0x40, 0xab, 0xe5, 0xb2, 0xa6, 0x73, 0x11, 0x94, 0xed, 0x58, 0xf9, 0x35, 0x2a}; - uint8_t byteswillprops5[] = {0x5d, 0xd, 0xb2, 0x6, 0xf7}; - uint8_t byteswillprops6[] = {0xa3, 0xe1, 0x37, 0x1f, 0x8c, 0xef, 0x83, 0xdd, 0xda, 0x66, 0x78, 0x65}; - uint8_t byteswillprops7[] = {0x1b, 0x1d, 0xf, 0x12, 0x6c, 0xf3, 0x3e, 0x47, 0x72, 0x96, 0xba, 0x91, 0x37, - 0xda, 0xf4, 0xea, 0xe1, 0x63, 0xab, 0x56, 0x67, 0x71, 0xcf, 0x6f, 0x45, 0xbb}; - + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xe9, 0xd, 0x85, 0x5, 0x37, 0x7c, 0xdb, 0xf1, 0x6d, 0x2f, 0x85, 0xa6, 0x44, 0x9b, 0x12, 0x3f, 0x69, 0xf, 0xa8, 0x0, 0x48, 0xf8, 0xf7, 0xc4, 0xb0}; + uint8_t byteswillprops0[] = {0x48, 0x3b, 0xed, 0x88, 0xac, 0x5a, 0xdf, 0xf3, 0xc2, 0x47, 0xa2, 0xbd, 0x8, 0xfd, 0xb9, 0x93, 0x36, 0xbf, 0xb2, 0xdc, 0x90, 0x64}; + uint8_t byteswillprops3[] = {0xb7, 0x6f, 0x81, 0x6e, 0x9a, 0xa0, 0x8d, 0x1c, 0xfd, 0xdd, 0x33}; + uint8_t byteswillprops2[] = {0xd4, 0xdc, 0xd, 0x16, 0x3d, 0x29, 0x21, 0x4b, 0xc8, 0x92, 0xb1, 0xd2, 0x2b, 0x92, 0x67, 0x45, 0x4, 0xd, 0xcc, 0x29, 0x7d, 0xa, 0x80, 0xfd, 0x98, 0x4, 0xe}; + uint8_t byteswillprops4[] = {0xc7, 0x33, 0xa0, 0xe4, 0x9e, 0x9f, 0x2f, 0x3a, 0xd6, 0x67, 0xf8, 0x6f, 0xbe, 0x9a, 0x54, 0xc7, 0x6c, 0x1, 0xe, 0xb7, 0x8e, 0x27, 0x9e, 0x7, 0x58}; + uint8_t byteswillprops5[] = {0xe1, 0x8a}; + uint8_t byteswillprops6[] = {0x53, 0x84, 0xfc, 0x80, 0xea, 0xce, 0xbe, 0x21, 0xe3, 0xa3, 0x55, 0x5d, 0xa0, 0x20, 0x90, 0x96, 0xfc, 0x29, 0xa, 0x5f}; + uint8_t byteswillprops7[] = {0x9c, 0x76, 0x70, 0x36, 0xfd, 0xa0, 0xac, 0xe2, 0xdd, 0x4b, 0xdb, 0x7a, 0xe0, 0x1a}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7050}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4117}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17531}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21710}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={22, (char*)&byteswillprops0}, .v={25, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23691}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={27, (char*)&byteswillprops2}, .v={11, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16206}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12753}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28852}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21476}}, }; - lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x73, 0x89, 0xda, 0xed, 0xf4, 0x5d, 0xc2, 0x28, 0x80, 0xca, 0x77, 0xf0, - 0x93, 0x4d, 0x36, 0xe8, 0xda, 0xf5, 0xfb, 0x37, 0x68, 0x66, 0xce, 0x74}; + lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x51, 0xbe, 0xc5, 0xd5, 0xd8, 0xa8, 0x7b, 0x3e, 0x21, 0xdc, 0xee, 0xfb, 0x5a, 0x6d, 0xa, 0xdb, 0xe9, 0x1e, 0x4d, 0x9e, 0xd2, 0xfa, 0xe4, 0xa8}; lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xee, 0x2b, 0x79, 0xfd, 0x8d, 0x30, 0x2d, 0x2d, 0xdb, 0x8f, 0xe2, - 0x59, 0x4d, 0x8c, 0x55, 0x22, 0x64, 0x41, 0x10, 0xeb, 0x80}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3208; - uint8_t client_id_bytes[] = {0x13, 0x50, 0x81, 0x68}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x4f, 0xa5, 0xbc, 0xc0, 0x80, 0x9b, 0xc0, 0x61, - 0xc6, 0x19, 0x3f, 0xc6, 0xe6, 0x29, 0x7d, 0xa1}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + uint8_t will_payload_bytes[] = {0x65, 0xe3, 0x3b, 0x73, 0xac, 0x3b}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 10491; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t password_bytes[] = {0x8a, 0x50, 0xf6, 0xd, 0x8b, 0x64, 0x56, 0xd6, 0x86, 0xac, 0x52, 0x75, 0x79, 0x51, 0xeb, 0x64, 0xf, 0x26, 0x41, 0xa9, 0x3, 0x97, 0xbb, 0x73, 0x77, 0x44}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\149\151\139\195\172z\255\139u#\163\fg,\230|\158{", _password = Just -// "Z\165\208\RS\195i\201D9m(Z ,\165\217Aa\137\ENQ\SO\180", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\141-\179\ENQl~\217\164\234\131\134\134\207X", _willMsg = -// ";\NUL\DEL\NUL\RSHW\212\230\191L\211s)\181j\203\158\229\137", _willProps = [PropAuthenticationMethod -// "\US\154\190)\184\149\NAK",PropTopicAlias 13388,PropWillDelayInterval 5881,PropWillDelayInterval -// 28801,PropSessionExpiryInterval 22600,PropTopicAlias 14648]}), _cleanSession = True, _keepAlive = 32044, _connID = -// "\248\r\241\217\233\199#\171\195\&6}Wu\226i\209\194\149\251\&6X$\144\230", _properties = [PropServerKeepAlive -// 16671,PropContentType "\130\SYNsO\170[*r\142\180q\146\244g\240\140\232",PropServerKeepAlive -// 5048,PropSubscriptionIdentifier 30,PropSharedSubscriptionAvailable 155,PropMessageExpiryInterval -// 25875,PropSharedSubscriptionAvailable 118,PropRequestProblemInformation 2,PropTopicAlias -// 30294,PropSessionExpiryInterval 23927,PropAuthenticationData "\138,H\185\139\&1\156\173"]} -TEST(Connect5QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0xd1, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe6, 0x7d, 0x2c, 0x3a, 0x13, 0x41, 0x1f, - 0x3, 0x0, 0x11, 0x82, 0x16, 0x73, 0x4f, 0xaa, 0x5b, 0x2a, 0x72, 0x8e, 0xb4, 0x71, 0x92, 0xf4, 0x67, - 0xf0, 0x8c, 0xe8, 0x13, 0x13, 0xb8, 0xb, 0x1e, 0x2a, 0x9b, 0x2, 0x0, 0x0, 0x65, 0x13, 0x2a, 0x76, - 0x17, 0x2, 0x23, 0x76, 0x56, 0x11, 0x0, 0x0, 0x5d, 0x77, 0x16, 0x0, 0x8, 0x8a, 0x2c, 0x48, 0xb9, - 0x8b, 0x31, 0x9c, 0xad, 0x0, 0x18, 0xf8, 0xd, 0xf1, 0xd9, 0xe9, 0xc7, 0x23, 0xab, 0xc3, 0x36, 0x7d, - 0x57, 0x75, 0xe2, 0x69, 0xd1, 0xc2, 0x95, 0xfb, 0x36, 0x58, 0x24, 0x90, 0xe6, 0x1f, 0x15, 0x0, 0x7, - 0x1f, 0x9a, 0xbe, 0x29, 0xb8, 0x95, 0x15, 0x23, 0x34, 0x4c, 0x18, 0x0, 0x0, 0x16, 0xf9, 0x18, 0x0, - 0x0, 0x70, 0x81, 0x11, 0x0, 0x0, 0x58, 0x48, 0x23, 0x39, 0x38, 0x0, 0xe, 0x8d, 0x2d, 0xb3, 0x5, - 0x6c, 0x7e, 0xd9, 0xa4, 0xea, 0x83, 0x86, 0x86, 0xcf, 0x58, 0x0, 0x14, 0x3b, 0x0, 0x7f, 0x0, 0x1e, - 0x48, 0x57, 0xd4, 0xe6, 0xbf, 0x4c, 0xd3, 0x73, 0x29, 0xb5, 0x6a, 0xcb, 0x9e, 0xe5, 0x89, 0x0, 0x12, - 0x95, 0x97, 0x8b, 0xc3, 0xac, 0x7a, 0xff, 0x8b, 0x75, 0x23, 0xa3, 0xc, 0x67, 0x2c, 0xe6, 0x7c, 0x9e, - 0x7b, 0x0, 0x16, 0x5a, 0xa5, 0xd0, 0x1e, 0xc3, 0x69, 0xc9, 0x44, 0x39, 0x6d, 0x28, 0x5a, 0x20, 0x2c, - 0xa5, 0xd9, 0x41, 0x61, 0x89, 0x5, 0xe, 0xb4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x82, 0x16, 0x73, 0x4f, 0xaa, 0x5b, 0x2a, 0x72, 0x8e, - 0xb4, 0x71, 0x92, 0xf4, 0x67, 0xf0, 0x8c, 0xe8}; - uint8_t bytesprops1[] = {0x8a, 0x2c, 0x48, 0xb9, 0x8b, 0x31, 0x9c, 0xad}; +// ConnectRequest {_username = Just "\136\ETX\185\158{\133u\SUB]M\158\149j", _password = Just "\236\211\185\RS\166i\ENQ\145\208h\157\v\ESC!", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\224\ESC\"\DLEM\r\165\238\&9\230\141", _willMsg = "C\129\147\222\&7Q.1.", _willProps = [PropResponseTopic "\197\166\166lRU\205",PropServerKeepAlive 12229,PropSubscriptionIdentifier 12,PropContentType "\ax\186g!H\DC3\138\247Gs\228=z\162n\195$N\196&\182fj\181c\132y",PropTopicAlias 25969,PropUserProperty "ib\148\149.\202Z \ACK\140\136N\130L\199I\138" "\175\171\198\204\161P\222K\141\DC2%Bp\237\135O\rE\165\t",PropTopicAlias 29830,PropUserProperty "@l\248\ETX\221\SOH\169\192\ETB\192k\205>Z\207\186\&6c.\200\179+3\"$J\ACK\DC3c\DLE" "\158Ck5\ESC\173\175\\\130\v/\176\209\128K\NAK\n\156)\173",PropTopicAliasMaximum 30754,PropSubscriptionIdentifier 6,PropCorrelationData "\STXf\232\146\b\188\224\253\227M\236\&0v\ETB\135<\160\164\234\US%\202\DC1s",PropTopicAlias 21576,PropPayloadFormatIndicator 191,PropSubscriptionIdentifierAvailable 85,PropRequestProblemInformation 105,PropRetainAvailable 36,PropResponseInformation "2\254\146\215\ESCW,\142Wz\171\\#\vZ4\240\146\209&)\SYN\140N\169v",PropTopicAlias 19080,PropServerReference "\\\132\162(8\DC2\163\188\138A\244\243lJ[\DELu\160J",PropUserProperty "\DC4\186\217x\NULB\148\235UE v-" "\154T\166\235\DC2\NUL`\141\188\\\aeo\190\249"]}), _cleanSession = True, _keepAlive = 12875, _connID = "j", _properties = [PropServerReference "\164\DC4\181\229",PropWildcardSubscriptionAvailable 34,PropTopicAlias 25379,PropResponseInformation "\173X\157#Y\239Z\170\161\145D_\159r\227<\246%\252\237h\230G\EM\158\191\129\NUL\142V"]} +TEST(Connect5QCTest, Encode29) { +uint8_t pkt[] = {0x10, 0x8b, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x32, 0x4b, 0x2d, 0x1c, 0x0, 0x4, 0xa4, 0x14, 0xb5, 0xe5, 0x28, 0x22, 0x23, 0x63, 0x23, 0x1a, 0x0, 0x1e, 0xad, 0x58, 0x9d, 0x23, 0x59, 0xef, 0x5a, 0xaa, 0xa1, 0x91, 0x44, 0x5f, 0x9f, 0x72, 0xe3, 0x3c, 0xf6, 0x25, 0xfc, 0xed, 0x68, 0xe6, 0x47, 0x19, 0x9e, 0xbf, 0x81, 0x0, 0x8e, 0x56, 0x0, 0x1, 0x6a, 0x97, 0x2, 0x8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, 0x24, 0x1a, 0x0, 0x1a, 0x32, 0xfe, 0x92, 0xd7, 0x1b, 0x57, 0x2c, 0x8e, 0x57, 0x7a, 0xab, 0x5c, 0x23, 0xb, 0x5a, 0x34, 0xf0, 0x92, 0xd1, 0x26, 0x29, 0x16, 0x8c, 0x4e, 0xa9, 0x76, 0x23, 0x4a, 0x88, 0x1c, 0x0, 0x13, 0x5c, 0x84, 0xa2, 0x28, 0x38, 0x12, 0xa3, 0xbc, 0x8a, 0x41, 0xf4, 0xf3, 0x6c, 0x4a, 0x5b, 0x7f, 0x75, 0xa0, 0x4a, 0x26, 0x0, 0xd, 0x14, 0xba, 0xd9, 0x78, 0x0, 0x42, 0x94, 0xeb, 0x55, 0x45, 0x20, 0x76, 0x2d, 0x0, 0xf, 0x9a, 0x54, 0xa6, 0xeb, 0x12, 0x0, 0x60, 0x8d, 0xbc, 0x5c, 0x7, 0x65, 0x6f, 0xbe, 0xf9, 0x0, 0xb, 0xe0, 0x1b, 0x22, 0x10, 0x4d, 0xd, 0xa5, 0xee, 0x39, 0xe6, 0x8d, 0x0, 0x9, 0x43, 0x81, 0x93, 0xde, 0x37, 0x51, 0x2e, 0x31, 0x2e, 0x0, 0xd, 0x88, 0x3, 0xb9, 0x9e, 0x7b, 0x85, 0x75, 0x1a, 0x5d, 0x4d, 0x9e, 0x95, 0x6a, 0x0, 0xe, 0xec, 0xd3, 0xb9, 0x1e, 0xa6, 0x69, 0x5, 0x91, 0xd0, 0x68, 0x9d, 0xb, 0x1b, 0x21}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xa4, 0x14, 0xb5, 0xe5}; + uint8_t bytesprops1[] = {0xad, 0x58, 0x9d, 0x23, 0x59, 0xef, 0x5a, 0xaa, 0xa1, 0x91, 0x44, 0x5f, 0x9f, 0x72, 0xe3, 0x3c, 0xf6, 0x25, 0xfc, 0xed, 0x68, 0xe6, 0x47, 0x19, 0x9e, 0xbf, 0x81, 0x0, 0x8e, 0x56}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16671}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5048}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25875}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30294}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23927}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops1}}}, - }; - - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x1f, 0x9a, 0xbe, 0x29, 0xb8, 0x95, 0x15}; + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25379}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, + }; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xc5, 0xa6, 0xa6, 0x6c, 0x52, 0x55, 0xcd}; + uint8_t byteswillprops1[] = {0x7, 0x78, 0xba, 0x67, 0x21, 0x48, 0x13, 0x8a, 0xf7, 0x47, 0x73, 0xe4, 0x3d, 0x7a, 0xa2, 0x6e, 0xc3, 0x24, 0x4e, 0xc4, 0x26, 0xb6, 0x66, 0x6a, 0xb5, 0x63, 0x84, 0x79}; + uint8_t byteswillprops3[] = {0xaf, 0xab, 0xc6, 0xcc, 0xa1, 0x50, 0xde, 0x4b, 0x8d, 0x12, 0x25, 0x42, 0x70, 0xed, 0x87, 0x4f, 0xd, 0x45, 0xa5, 0x9}; + uint8_t byteswillprops2[] = {0x69, 0x62, 0x94, 0x95, 0x2e, 0xca, 0x5a, 0x20, 0x6, 0x8c, 0x88, 0x4e, 0x82, 0x4c, 0xc7, 0x49, 0x8a}; + uint8_t byteswillprops5[] = {0x9e, 0x43, 0x6b, 0x35, 0x1b, 0xad, 0xaf, 0x5c, 0x82, 0xb, 0x2f, 0xb0, 0xd1, 0x80, 0x4b, 0x15, 0xa, 0x9c, 0x29, 0xad}; + uint8_t byteswillprops4[] = {0x40, 0x6c, 0xf8, 0x3, 0xdd, 0x1, 0xa9, 0xc0, 0x17, 0xc0, 0x6b, 0xcd, 0x3e, 0x5a, 0xcf, 0xba, 0x36, 0x63, 0x2e, 0xc8, 0xb3, 0x2b, 0x33, 0x22, 0x24, 0x4a, 0x6, 0x13, 0x63, 0x10}; + uint8_t byteswillprops6[] = {0x2, 0x66, 0xe8, 0x92, 0x8, 0xbc, 0xe0, 0xfd, 0xe3, 0x4d, 0xec, 0x30, 0x76, 0x17, 0x87, 0x3c, 0xa0, 0xa4, 0xea, 0x1f, 0x25, 0xca, 0x11, 0x73}; + uint8_t byteswillprops7[] = {0x32, 0xfe, 0x92, 0xd7, 0x1b, 0x57, 0x2c, 0x8e, 0x57, 0x7a, 0xab, 0x5c, 0x23, 0xb, 0x5a, 0x34, 0xf0, 0x92, 0xd1, 0x26, 0x29, 0x16, 0x8c, 0x4e, 0xa9, 0x76}; + uint8_t byteswillprops8[] = {0x5c, 0x84, 0xa2, 0x28, 0x38, 0x12, 0xa3, 0xbc, 0x8a, 0x41, 0xf4, 0xf3, 0x6c, 0x4a, 0x5b, 0x7f, 0x75, 0xa0, 0x4a}; + uint8_t byteswillprops10[] = {0x9a, 0x54, 0xa6, 0xeb, 0x12, 0x0, 0x60, 0x8d, 0xbc, 0x5c, 0x7, 0x65, 0x6f, 0xbe, 0xf9}; + uint8_t byteswillprops9[] = {0x14, 0xba, 0xd9, 0x78, 0x0, 0x42, 0x94, 0xeb, 0x55, 0x45, 0x20, 0x76, 0x2d}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13388}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5881}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28801}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22600}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14648}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12229}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25969}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={17, (char*)&byteswillprops2}, .v={20, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29830}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={30, (char*)&byteswillprops4}, .v={20, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30754}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21576}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19080}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={13, (char*)&byteswillprops9}, .v={15, (char*)&byteswillprops10}}}}, }; - lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8d, 0x2d, 0xb3, 0x5, 0x6c, 0x7e, 0xd9, 0xa4, 0xea, 0x83, 0x86, 0x86, 0xcf, 0x58}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3b, 0x0, 0x7f, 0x0, 0x1e, 0x48, 0x57, 0xd4, 0xe6, 0xbf, - 0x4c, 0xd3, 0x73, 0x29, 0xb5, 0x6a, 0xcb, 0x9e, 0xe5, 0x89}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 32044; - uint8_t client_id_bytes[] = {0xf8, 0xd, 0xf1, 0xd9, 0xe9, 0xc7, 0x23, 0xab, 0xc3, 0x36, 0x7d, 0x57, - 0x75, 0xe2, 0x69, 0xd1, 0xc2, 0x95, 0xfb, 0x36, 0x58, 0x24, 0x90, 0xe6}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x95, 0x97, 0x8b, 0xc3, 0xac, 0x7a, 0xff, 0x8b, 0x75, - 0x23, 0xa3, 0xc, 0x67, 0x2c, 0xe6, 0x7c, 0x9e, 0x7b}; - lwmqtt_string_t username = {18, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x5a, 0xa5, 0xd0, 0x1e, 0xc3, 0x69, 0xc9, 0x44, 0x39, 0x6d, 0x28, - 0x5a, 0x20, 0x2c, 0xa5, 0xd9, 0x41, 0x61, 0x89, 0x5, 0xe, 0xb4}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe0, 0x1b, 0x22, 0x10, 0x4d, 0xd, 0xa5, 0xee, 0x39, 0xe6, 0x8d}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x43, 0x81, 0x93, 0xde, 0x37, 0x51, 0x2e, 0x31, 0x2e}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS2; +will.retained = true; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 12875; + uint8_t client_id_bytes[] = {0x6a}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x88, 0x3, 0xb9, 0x9e, 0x7b, 0x85, 0x75, 0x1a, 0x5d, 0x4d, 0x9e, 0x95, 0x6a}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0xec, 0xd3, 0xb9, 0x1e, 0xa6, 0x69, 0x5, 0x91, 0xd0, 0x68, 0x9d, 0xb, 0x1b, 0x21}; + lwmqtt_string_t password = {14, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "|\236r\252\&0Ku{\146\ETX\ACKm\178\134\193P\SUB", _password = Just -// "mYo\132\144\131\150'\206lC{\157\159\174\ETX", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, -// _willTopic = "\129\242\250\251\220\214\242\EOTx\180\v4H\156w\139\247zR\199u\172r\136\155\198\SUB", _willMsg = -// "\166V\216\GS\135B\DC4\223\177\149\223\195\178\NUL\DLER\206/Q'O\128-\EOT\134", _willProps = [PropResponseTopic -// "\130\241\197(\190\174\161!>\239\171\160C\134",PropWildcardSubscriptionAvailable 54,PropAuthenticationData -// "\154\197Y\137\254\DC4\149$\GS\234\&5\227a,\DC2\161[W\199{H\207\235MJ\154",PropSharedSubscriptionAvailable -// 18,PropTopicAliasMaximum 31321,PropTopicAlias 3735,PropReasonString "\216A\SOH\US\132e@S",PropSessionExpiryInterval -// 27865]}), _cleanSession = False, _keepAlive = 12650, _connID = "\180N\165", _properties = [PropUserProperty -// "\202\237c\v\218Sd\DC3p\214\137/r\128\188\&0sB\NUL5\"\138\206&s=\140\157A#" -// "\205>k@\231\182z%\159#\SUB\230\NUL",PropServerReference -// "a\129\178\132?\133\186\vro/\254\184b4\148\139",PropRetainAvailable 26,PropRequestProblemInformation -// 130,PropPayloadFormatIndicator 226,PropServerReference "\\\206"]} -TEST(Connect5QCTest, Encode27) { - uint8_t pkt[] = { - 0x10, 0x85, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x31, 0x6a, 0x4f, 0x26, 0x0, 0x1e, 0xca, 0xed, - 0x63, 0xb, 0xda, 0x53, 0x64, 0x13, 0x70, 0xd6, 0x89, 0x2f, 0x72, 0x80, 0xbc, 0x30, 0x73, 0x42, 0x0, 0x35, 0x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, 0x2d, 0x4, 0x86, 0x0, - 0x11, 0x7c, 0xec, 0x72, 0xfc, 0x30, 0x4b, 0x75, 0x7b, 0x92, 0x3, 0x6, 0x6d, 0xb2, 0x86, 0xc1, 0x50, 0x1a, 0x0, - 0x10, 0x6d, 0x59, 0x6f, 0x84, 0x90, 0x83, 0x96, 0x27, 0xce, 0x6c, 0x43, 0x7b, 0x9d, 0x9f, 0xae, 0x3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0xcd, 0x3e, 0x6b, 0x40, 0xe7, 0xb6, 0x7a, 0x25, 0x9f, 0x23, 0x1a, 0xe6, 0x0}; - uint8_t bytesprops0[] = {0xca, 0xed, 0x63, 0xb, 0xda, 0x53, 0x64, 0x13, 0x70, 0xd6, 0x89, 0x2f, 0x72, 0x80, 0xbc, - 0x30, 0x73, 0x42, 0x0, 0x35, 0x22, 0x8a, 0xce, 0x26, 0x73, 0x3d, 0x8c, 0x9d, 0x41, 0x23}; - uint8_t bytesprops2[] = {0x61, 0x81, 0xb2, 0x84, 0x3f, 0x85, 0xba, 0xb, 0x72, - 0x6f, 0x2f, 0xfe, 0xb8, 0x62, 0x34, 0x94, 0x8b}; - uint8_t bytesprops3[] = {0x5c, 0xce}; +// ConnectRequest {_username = Just "\CAN`l\229\237\255", _password = Just "\192o\213\179\182\245\198(\236\EOT\NAK/", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\246\227\176\175_4\EOT{\143\204\150", _willMsg = "\209\190U\246\210\133\207\145\&9\229", _willProps = [PropWillDelayInterval 4001,PropMaximumQoS 57,PropCorrelationData "\244f7$\202%B\243\ACK\163\234F",PropPayloadFormatIndicator 247,PropMessageExpiryInterval 25320,PropAssignedClientIdentifier "G\182\246T\225\187d\CAN\153P\185\135\t\171",PropContentType "B\ETBg-oJN*\196\DEL\246>Cx\173zb\DC1",PropMaximumPacketSize 29438,PropTopicAliasMaximum 27453,PropMaximumPacketSize 28785,PropTopicAlias 12980,PropCorrelationData "\154t?\190\192\210\&8\149[x\151\241d&O1\176\\\205\170*k\193~\DEL\144\201\252",PropMaximumQoS 20,PropSharedSubscriptionAvailable 167,PropSessionExpiryInterval 29157,PropAuthenticationMethod "\206C(\DC4",PropResponseTopic "\167\STX\176Aj\150\&4\NAK\197\212;\228m\225\v\217\189\248\STXS",PropMessageExpiryInterval 27021,PropContentType "\201\DC3}x[~S\163r,\204?\SI\173\221\&9*X+?\137",PropContentType "\\M",PropWillDelayInterval 5654,PropCorrelationData "\137V\239}\209\243n$\204\196\201\GS\211\218",PropWillDelayInterval 15136,PropSharedSubscriptionAvailable 79]}), _cleanSession = True, _keepAlive = 67, _connID = "\246Q\170N+\132\254\213*\162\243\n", _properties = [PropReceiveMaximum 28097,PropReceiveMaximum 3524,PropWillDelayInterval 14155,PropServerKeepAlive 22395,PropCorrelationData "\DC1M\188\&6\200O\161U",PropSharedSubscriptionAvailable 152,PropAuthenticationData "\176zC\EOT\fn\166\175\153\fo\182\196?\183\244\237\199\202\234\254\152",PropCorrelationData "@\238\194\STX\226\SO-",PropSessionExpiryInterval 15111,PropPayloadFormatIndicator 144,PropAuthenticationData "\173\209\193\158\222\186\192e\DC4\182\136\DC4=5 \171\239y\190\224`\150",PropPayloadFormatIndicator 83]} +TEST(Connect5QCTest, Encode30) { +uint8_t pkt[] = {0x10, 0x82, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x0, 0x43, 0x60, 0x21, 0x6d, 0xc1, 0x21, 0xd, 0xc4, 0x18, 0x0, 0x0, 0x37, 0x4b, 0x13, 0x57, 0x7b, 0x9, 0x0, 0x8, 0x11, 0x4d, 0xbc, 0x36, 0xc8, 0x4f, 0xa1, 0x55, 0x2a, 0x98, 0x16, 0x0, 0x16, 0xb0, 0x7a, 0x43, 0x4, 0xc, 0x6e, 0xa6, 0xaf, 0x99, 0xc, 0x6f, 0xb6, 0xc4, 0x3f, 0xb7, 0xf4, 0xed, 0xc7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x2d}; + uint8_t bytesprops3[] = {0xad, 0xd1, 0xc1, 0x9e, 0xde, 0xba, 0xc0, 0x65, 0x14, 0xb6, 0x88, 0x14, 0x3d, 0x35, 0x20, 0xab, 0xef, 0x79, 0xbe, 0xe0, 0x60, 0x96}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28097}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3524}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14155}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22395}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15111}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x82, 0xf1, 0xc5, 0x28, 0xbe, 0xae, 0xa1, 0x21, 0x3e, 0xef, 0xab, 0xa0, 0x43, 0x86}; - uint8_t byteswillprops1[] = {0x9a, 0xc5, 0x59, 0x89, 0xfe, 0x14, 0x95, 0x24, 0x1d, 0xea, 0x35, 0xe3, 0x61, - 0x2c, 0x12, 0xa1, 0x5b, 0x57, 0xc7, 0x7b, 0x48, 0xcf, 0xeb, 0x4d, 0x4a, 0x9a}; - uint8_t byteswillprops2[] = {0xd8, 0x41, 0x1, 0x1f, 0x84, 0x65, 0x40, 0x53}; - + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; +lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xf4, 0x66, 0x37, 0x24, 0xca, 0x25, 0x42, 0xf3, 0x6, 0xa3, 0xea, 0x46}; + uint8_t byteswillprops1[] = {0x47, 0xb6, 0xf6, 0x54, 0xe1, 0xbb, 0x64, 0x18, 0x99, 0x50, 0xb9, 0x87, 0x9, 0xab}; + uint8_t byteswillprops2[] = {0x42, 0x17, 0x67, 0x2d, 0x6f, 0x4a, 0x4e, 0x2a, 0xc4, 0x7f, 0xf6, 0x3e, 0x43, 0x78, 0xad, 0x7a, 0x62, 0x11}; + uint8_t byteswillprops3[] = {0x9a, 0x74, 0x3f, 0xbe, 0xc0, 0xd2, 0x38, 0x95, 0x5b, 0x78, 0x97, 0xf1, 0x64, 0x26, 0x4f, 0x31, 0xb0, 0x5c, 0xcd, 0xaa, 0x2a, 0x6b, 0xc1, 0x7e, 0x7f, 0x90, 0xc9, 0xfc}; + uint8_t byteswillprops4[] = {0xce, 0x43, 0x28, 0x14}; + uint8_t byteswillprops5[] = {0xa7, 0x2, 0xb0, 0x41, 0x6a, 0x96, 0x34, 0x15, 0xc5, 0xd4, 0x3b, 0xe4, 0x6d, 0xe1, 0xb, 0xd9, 0xbd, 0xf8, 0x2, 0x53}; + uint8_t byteswillprops6[] = {0xc9, 0x13, 0x7d, 0x78, 0x5b, 0x7e, 0x53, 0xa3, 0x72, 0x2c, 0xcc, 0x3f, 0xf, 0xad, 0xdd, 0x39, 0x2a, 0x58, 0x2b, 0x3f, 0x89}; + uint8_t byteswillprops7[] = {0x5c, 0x4d}; + uint8_t byteswillprops8[] = {0x89, 0x56, 0xef, 0x7d, 0xd1, 0xf3, 0x6e, 0x24, 0xcc, 0xc4, 0xc9, 0x1d, 0xd3, 0xda}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31321}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3735}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27865}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4001}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25320}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29438}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27453}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28785}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12980}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29157}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27021}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5654}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15136}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, }; - lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x81, 0xf2, 0xfa, 0xfb, 0xdc, 0xd6, 0xf2, 0x4, 0x78, 0xb4, 0xb, 0x34, 0x48, 0x9c, - 0x77, 0x8b, 0xf7, 0x7a, 0x52, 0xc7, 0x75, 0xac, 0x72, 0x88, 0x9b, 0xc6, 0x1a}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa6, 0x56, 0xd8, 0x1d, 0x87, 0x42, 0x14, 0xdf, 0xb1, 0x95, 0xdf, 0xc3, 0xb2, - 0x0, 0x10, 0x52, 0xce, 0x2f, 0x51, 0x27, 0x4f, 0x80, 0x2d, 0x4, 0x86}; - lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12650; - uint8_t client_id_bytes[] = {0xb4, 0x4e, 0xa5}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x7c, 0xec, 0x72, 0xfc, 0x30, 0x4b, 0x75, 0x7b, 0x92, - 0x3, 0x6, 0x6d, 0xb2, 0x86, 0xc1, 0x50, 0x1a}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6d, 0x59, 0x6f, 0x84, 0x90, 0x83, 0x96, 0x27, - 0xce, 0x6c, 0x43, 0x7b, 0x9d, 0x9f, 0xae, 0x3}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf6, 0xe3, 0xb0, 0xaf, 0x5f, 0x34, 0x4, 0x7b, 0x8f, 0xcc, 0x96}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd1, 0xbe, 0x55, 0xf6, 0xd2, 0x85, 0xcf, 0x91, 0x39, 0xe5}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; +will.topic = will_topic; +will.payload = will_payload; +will.qos = LWMQTT_QOS1; +will.retained = false; +will.properties = willprops; +lwmqtt_options_t opts = lwmqtt_default_options; +opts.properties = props; +opts.clean_session = true; +opts.keep_alive = 67; + uint8_t client_id_bytes[] = {0xf6, 0x51, 0xaa, 0x4e, 0x2b, 0x84, 0xfe, 0xd5, 0x2a, 0xa2, 0xf3, 0xa}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; +opts.client_id = client_id; + uint8_t username_bytes[] = {0x18, 0x60, 0x6c, 0xe5, 0xed, 0xff}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; +opts.username = username; + uint8_t password_bytes[] = {0xc0, 0x6f, 0xd5, 0xb3, 0xb6, 0xf5, 0xc6, 0x28, 0xec, 0x4, 0x15, 0x2f}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; +opts.password = password; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\176\SUB(", _password = Nothing, _lastWill = Nothing, _cleanSession = False, -// _keepAlive = 9985, _connID = "\144\&3\142\215M", _properties = [PropServerKeepAlive -// 12899,PropSharedSubscriptionAvailable 49,PropWillDelayInterval 12770,PropAuthenticationData -// "\209\&7\252\240\163X\180\180\245\147\153aL\134",PropWillDelayInterval 18290,PropRequestResponseInformation -// 60,PropRetainAvailable 253,PropWildcardSubscriptionAvailable 210,PropServerReference -// "\155\210\197\197?G\144",PropUserProperty "\ETB\188\RS\161\131\184\GS\189\223A/\202\178\153\145\190" -// "\253\195Wp\178\130[\195v\t\136\225-\168s\141P\177\210\n{\ETXF\EMqX\192\139",PropReasonString -// "\ETB\188\170_\NAK\246\216\237h\187\231\v\231.\226vs2\150]\171",PropSharedSubscriptionAvailable -// 198,PropAssignedClientIdentifier -// "\r\146{|\130>@\252'\b\219\184\153\232O\248\196\EMv.\204\166\133",PropSessionExpiryInterval -// 10846,PropRequestResponseInformation 221]} -TEST(Connect5QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0xb4, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x80, 0x27, 0x1, 0x9c, 0x1, 0x13, 0x32, - 0x63, 0x2a, 0x31, 0x18, 0x0, 0x0, 0x31, 0xe2, 0x16, 0x0, 0xe, 0xd1, 0x37, 0xfc, 0xf0, 0xa3, 0x58, - 0xb4, 0xb4, 0xf5, 0x93, 0x99, 0x61, 0x4c, 0x86, 0x18, 0x0, 0x0, 0x47, 0x72, 0x19, 0x3c, 0x25, 0xfd, - 0x28, 0xd2, 0x1c, 0x0, 0x7, 0x9b, 0xd2, 0xc5, 0xc5, 0x3f, 0x47, 0x90, 0x26, 0x0, 0x10, 0x17, 0xbc, - 0x1e, 0xa1, 0x83, 0xb8, 0x1d, 0xbd, 0xdf, 0x41, 0x2f, 0xca, 0xb2, 0x99, 0x91, 0xbe, 0x0, 0x1c, 0xfd, - 0xc3, 0x57, 0x70, 0xb2, 0x82, 0x5b, 0xc3, 0x76, 0x9, 0x88, 0xe1, 0x2d, 0xa8, 0x73, 0x8d, 0x50, 0xb1, - 0xd2, 0xa, 0x7b, 0x3, 0x46, 0x19, 0x71, 0x58, 0xc0, 0x8b, 0x1f, 0x0, 0x15, 0x17, 0xbc, 0xaa, 0x5f, - 0x15, 0xf6, 0xd8, 0xed, 0x68, 0xbb, 0xe7, 0xb, 0xe7, 0x2e, 0xe2, 0x76, 0x73, 0x32, 0x96, 0x5d, 0xab, - 0x2a, 0xc6, 0x12, 0x0, 0x17, 0xd, 0x92, 0x7b, 0x7c, 0x82, 0x3e, 0x40, 0xfc, 0x27, 0x8, 0xdb, 0xb8, - 0x99, 0xe8, 0x4f, 0xf8, 0xc4, 0x19, 0x76, 0x2e, 0xcc, 0xa6, 0x85, 0x11, 0x0, 0x0, 0x2a, 0x5e, 0x19, - 0xdd, 0x0, 0x5, 0x90, 0x33, 0x8e, 0xd7, 0x4d, 0x0, 0x3, 0xb0, 0x1a, 0x28}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd1, 0x37, 0xfc, 0xf0, 0xa3, 0x58, 0xb4, 0xb4, 0xf5, 0x93, 0x99, 0x61, 0x4c, 0x86}; - uint8_t bytesprops1[] = {0x9b, 0xd2, 0xc5, 0xc5, 0x3f, 0x47, 0x90}; - uint8_t bytesprops3[] = {0xfd, 0xc3, 0x57, 0x70, 0xb2, 0x82, 0x5b, 0xc3, 0x76, 0x9, 0x88, 0xe1, 0x2d, 0xa8, - 0x73, 0x8d, 0x50, 0xb1, 0xd2, 0xa, 0x7b, 0x3, 0x46, 0x19, 0x71, 0x58, 0xc0, 0x8b}; - uint8_t bytesprops2[] = {0x17, 0xbc, 0x1e, 0xa1, 0x83, 0xb8, 0x1d, 0xbd, - 0xdf, 0x41, 0x2f, 0xca, 0xb2, 0x99, 0x91, 0xbe}; - uint8_t bytesprops4[] = {0x17, 0xbc, 0xaa, 0x5f, 0x15, 0xf6, 0xd8, 0xed, 0x68, 0xbb, 0xe7, - 0xb, 0xe7, 0x2e, 0xe2, 0x76, 0x73, 0x32, 0x96, 0x5d, 0xab}; - uint8_t bytesprops5[] = {0xd, 0x92, 0x7b, 0x7c, 0x82, 0x3e, 0x40, 0xfc, 0x27, 0x8, 0xdb, 0xb8, - 0x99, 0xe8, 0x4f, 0xf8, 0xc4, 0x19, 0x76, 0x2e, 0xcc, 0xa6, 0x85}; +// SubscribeRequest 2235 [("\ETB\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode1) { +uint8_t pkt[] = {0x82, 0x7, 0x8, 0xbb, 0x0, 0x2, 0x17, 0xa6, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x17, 0xa6}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; +lwmqtt_sub_options_t sub_opts[1]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12899}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12770}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18290}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops2}, .v = {28, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10846}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 221}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 9985; - uint8_t client_id_bytes[] = {0x90, 0x33, 0x8e, 0xd7, 0x4d}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xb0, 0x1a, 0x28}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2235, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS2, _willTopic = "3\ENQ\159tA", _willMsg = "\253\&0\175\230\149U\228\219\161nq\159m\NAK", _willProps = -// [PropAuthenticationMethod "\159",PropSharedSubscriptionAvailable 237,PropMessageExpiryInterval -// 8765,PropSessionExpiryInterval 16121,PropAuthenticationData -// "\191\145\"\n\135\238O:l$8mT\255d\160\176\r\154A\SYN\254\131\219\243\172\182\179\169",PropReceiveMaximum -// 18457,PropServerKeepAlive 6360,PropServerReference ",\178\b\130<\221\195\152\220",PropReceiveMaximum 9970]}), -// _cleanSession = True, _keepAlive = 2853, _connID = "\223k\158\244\196\196\240\228\&8\134\t*", _properties = -// [PropTopicAliasMaximum 26453,PropRequestProblemInformation 200,PropWillDelayInterval 17617,PropResponseInformation -// "\DC4\130\208\233\165x;\179\SUB\v\183\146\245\167,}\254\202<\157",PropReceiveMaximum 2414,PropTopicAliasMaximum -// 7212,PropRequestResponseInformation 231,PropSubscriptionIdentifier 11,PropUserProperty "\tn\ESCq\tw" -// "`Q\240$\189\&5\209\214\172\FS\t\r\128\203\167O\DC3\202",PropRequestResponseInformation 6,PropUserProperty -// "\163\139\\Mi\144q" -// "\147\164Tv\195\SOH\208\FS\241Rq\158\&1\f\187\160B\225\141\230\253\189\a\EOT",PropPayloadFormatIndicator 31]} -TEST(Connect5QCTest, Encode29) { - uint8_t pkt[] = {0x10, 0xe6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x36, 0xb, 0x25, 0x70, 0x22, 0x67, 0x55, - 0x17, 0xc8, 0x18, 0x0, 0x0, 0x44, 0xd1, 0x1a, 0x0, 0x14, 0x14, 0x82, 0xd0, 0xe9, 0xa5, 0x78, 0x3b, - 0xb3, 0x1a, 0xb, 0xb7, 0x92, 0xf5, 0xa7, 0x2c, 0x7d, 0xfe, 0xca, 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6d, 0x15}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x14, 0x82, 0xd0, 0xe9, 0xa5, 0x78, 0x3b, 0xb3, 0x1a, 0xb, - 0xb7, 0x92, 0xf5, 0xa7, 0x2c, 0x7d, 0xfe, 0xca, 0x3c, 0x9d}; - uint8_t bytesprops2[] = {0x60, 0x51, 0xf0, 0x24, 0xbd, 0x35, 0xd1, 0xd6, 0xac, - 0x1c, 0x9, 0xd, 0x80, 0xcb, 0xa7, 0x4f, 0x13, 0xca}; - uint8_t bytesprops1[] = {0x9, 0x6e, 0x1b, 0x71, 0x9, 0x77}; - uint8_t bytesprops4[] = {0x93, 0xa4, 0x54, 0x76, 0xc3, 0x1, 0xd0, 0x1c, 0xf1, 0x52, 0x71, 0x9e, - 0x31, 0xc, 0xbb, 0xa0, 0x42, 0xe1, 0x8d, 0xe6, 0xfd, 0xbd, 0x7, 0x4}; - uint8_t bytesprops3[] = {0xa3, 0x8b, 0x5c, 0x4d, 0x69, 0x90, 0x71}; +// SubscribeRequest 29400 [("\212\DELo=\194\186\&8\213\&6\b,\218\ENQ\155\244\161a\159\ACK\242\223\233\ACK\SYN6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\174~\129qh",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("]\227w\FS\n\152\156\253\203\254\v\GS\210(\226\v\EM3[\242\222\232\132Q\168",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\128\&1\237)\RS\197\ETX\206~I\228\227\&6\250\192",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\243\&8\184<\190N\253\&8W\223\234Fz\221`\148\176\134\&0",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\222\162\216\&7\t",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("9\EM\253\233\240M\232\ACK\223^|\r\141\205",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\147\255\160\143\132\225\&4\223\147\145\161\211\149\230\&4p\181",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\140\167\v\DLE\221\215\250;d}?\220\&0\"\DC2\178 \169,*\172\131HV\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\149\SI\158\RS\147\170\156\220\146",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode2) { +uint8_t pkt[] = {0x82, 0xc2, 0x1, 0x72, 0xd8, 0x0, 0x19, 0xd4, 0x7f, 0x6f, 0x3d, 0xc2, 0xba, 0x38, 0xd5, 0x36, 0x8, 0x2c, 0xda, 0x5, 0x9b, 0xf4, 0xa1, 0x61, 0x9f, 0x6, 0xf2, 0xdf, 0xe9, 0x6, 0x16, 0x36, 0x2, 0x0, 0x5, 0xae, 0x7e, 0x81, 0x71, 0x68, 0x0, 0x0, 0x19, 0x5d, 0xe3, 0x77, 0x1c, 0xa, 0x98, 0x9c, 0xfd, 0xcb, 0xfe, 0xb, 0x1d, 0xd2, 0x28, 0xe2, 0xb, 0x19, 0x33, 0x5b, 0xf2, 0xde, 0xe8, 0x84, 0x51, 0xa8, 0x2, 0x0, 0xf, 0x80, 0x31, 0xed, 0x29, 0x1e, 0xc5, 0x3, 0xce, 0x7e, 0x49, 0xe4, 0xe3, 0x36, 0xfa, 0xc0, 0x1, 0x0, 0x13, 0xf3, 0x38, 0xb8, 0x3c, 0xbe, 0x4e, 0xfd, 0x38, 0x57, 0xdf, 0xea, 0x46, 0x7a, 0xdd, 0x60, 0x94, 0xb0, 0x86, 0x30, 0x0, 0x0, 0x5, 0xde, 0xa2, 0xd8, 0x37, 0x9, 0x2, 0x0, 0xe, 0x39, 0x19, 0xfd, 0xe9, 0xf0, 0x4d, 0xe8, 0x6, 0xdf, 0x5e, 0x7c, 0xd, 0x8d, 0xcd, 0x2, 0x0, 0x0, 0x1, 0x0, 0x11, 0x93, 0xff, 0xa0, 0x8f, 0x84, 0xe1, 0x34, 0xdf, 0x93, 0x91, 0xa1, 0xd3, 0x95, 0xe6, 0x34, 0x70, 0xb5, 0x0, 0x0, 0x19, 0x8c, 0xa7, 0xb, 0x10, 0xdd, 0xd7, 0xfa, 0x3b, 0x64, 0x7d, 0x3f, 0xdc, 0x30, 0x22, 0x12, 0xb2, 0x20, 0xa9, 0x2c, 0x2a, 0xac, 0x83, 0x48, 0x56, 0xae, 0x0, 0x0, 0x9, 0x95, 0xf, 0x9e, 0x1e, 0x93, 0xaa, 0x9c, 0xdc, 0x92, 0x2}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xd4, 0x7f, 0x6f, 0x3d, 0xc2, 0xba, 0x38, 0xd5, 0x36, 0x8, 0x2c, 0xda, 0x5, 0x9b, 0xf4, 0xa1, 0x61, 0x9f, 0x6, 0xf2, 0xdf, 0xe9, 0x6, 0x16, 0x36}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xae, 0x7e, 0x81, 0x71, 0x68}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5d, 0xe3, 0x77, 0x1c, 0xa, 0x98, 0x9c, 0xfd, 0xcb, 0xfe, 0xb, 0x1d, 0xd2, 0x28, 0xe2, 0xb, 0x19, 0x33, 0x5b, 0xf2, 0xde, 0xe8, 0x84, 0x51, 0xa8}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x80, 0x31, 0xed, 0x29, 0x1e, 0xc5, 0x3, 0xce, 0x7e, 0x49, 0xe4, 0xe3, 0x36, 0xfa, 0xc0}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xf3, 0x38, 0xb8, 0x3c, 0xbe, 0x4e, 0xfd, 0x38, 0x57, 0xdf, 0xea, 0x46, 0x7a, 0xdd, 0x60, 0x94, 0xb0, 0x86, 0x30}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xde, 0xa2, 0xd8, 0x37, 0x9}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x39, 0x19, 0xfd, 0xe9, 0xf0, 0x4d, 0xe8, 0x6, 0xdf, 0x5e, 0x7c, 0xd, 0x8d, 0xcd}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x93, 0xff, 0xa0, 0x8f, 0x84, 0xe1, 0x34, 0xdf, 0x93, 0x91, 0xa1, 0xd3, 0x95, 0xe6, 0x34, 0x70, 0xb5}; + lwmqtt_string_t topic_filter_s8 = {17, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x8c, 0xa7, 0xb, 0x10, 0xdd, 0xd7, 0xfa, 0x3b, 0x64, 0x7d, 0x3f, 0xdc, 0x30, 0x22, 0x12, 0xb2, 0x20, 0xa9, 0x2c, 0x2a, 0xac, 0x83, 0x48, 0x56, 0xae}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; +topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x95, 0xf, 0x9e, 0x1e, 0x93, 0xaa, 0x9c, 0xdc, 0x92}; + lwmqtt_string_t topic_filter_s10 = {9, (char*)&topic_filter_s10_bytes}; +topic_filters[10] = topic_filter_s10; +lwmqtt_sub_options_t sub_opts[11]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS0; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS2; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS0; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS2; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; +sub_opts[6].qos = LWMQTT_QOS2; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = false; +sub_opts[6].no_local = false; +sub_opts[7].qos = LWMQTT_QOS1; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = false; +sub_opts[8].qos = LWMQTT_QOS0; +sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[8].retain_as_published = false; +sub_opts[8].no_local = false; +sub_opts[9].qos = LWMQTT_QOS0; +sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[9].retain_as_published = false; +sub_opts[9].no_local = false; +sub_opts[10].qos = LWMQTT_QOS2; +sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[10].retain_as_published = false; +sub_opts[10].no_local = false; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26453}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17617}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2414}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7212}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {24, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 31}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x9f}; - uint8_t byteswillprops1[] = {0xbf, 0x91, 0x22, 0xa, 0x87, 0xee, 0x4f, 0x3a, 0x6c, 0x24, 0x38, 0x6d, 0x54, 0xff, 0x64, - 0xa0, 0xb0, 0xd, 0x9a, 0x41, 0x16, 0xfe, 0x83, 0xdb, 0xf3, 0xac, 0xb6, 0xb3, 0xa9}; - uint8_t byteswillprops2[] = {0x2c, 0xb2, 0x8, 0x82, 0x3c, 0xdd, 0xc3, 0x98, 0xdc}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8765}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16121}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18457}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6360}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9970}}, - }; - - lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x33, 0x5, 0x9f, 0x74, 0x41}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfd, 0x30, 0xaf, 0xe6, 0x95, 0x55, 0xe4, 0xdb, 0xa1, 0x6e, 0x71, 0x9f, 0x6d, 0x15}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 2853; - uint8_t client_id_bytes[] = {0xdf, 0x6b, 0x9e, 0xf4, 0xc4, 0xc4, 0xf0, 0xe4, 0x38, 0x86, 0x9, 0x2a}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29400, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// ConnectRequest {_username = Just "\"", _password = Just "\223>\255\222\&1+\192nU\183\230", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\b)e\236\251\251F\231*\144\171\179\130", _willMsg = -// "\224$\244h\238M\173a\166,{\149\167\153\201{\142.\175\&3A=\249\214\DC1\254oO\186", _willProps = -// [PropMessageExpiryInterval 10851,PropMessageExpiryInterval 30029,PropAuthenticationMethod -// "\SYN}\183n\181\198\138\&7@\146&\136\n\160Q\254\130\ACK\139\RS>\170G\166uc3+|\147",PropMaximumQoS -// 49,PropResponseInformation "3\232\160\231\154\143bE`l\193N",PropResponseTopic "\223\v$\227\161\185eK\135\DEL\182 -// $3\200~[",PropCorrelationData "\192\230\179\&08\196W\182\179\164w\182\151\DC3)",PropRequestResponseInformation -// 191,PropWillDelayInterval 16685,PropTopicAliasMaximum 10583,PropWildcardSubscriptionAvailable 161,PropReceiveMaximum -// 1963,PropContentType "\162\SI\"M\\-.\233\ETB\EM\133\185\136\230\&4\DC1W}l\187\209",PropAuthenticationData -// "\236\250\138P\198\129PP\ESC",PropReceiveMaximum 6355]}), _cleanSession = False, _keepAlive = 26056, _connID = -// "c\EM'\202qq<\213", _properties = [PropContentType "{\213\150S\SI\146h1\143",PropSessionExpiryInterval -// 9151,PropMaximumQoS 249,PropSubscriptionIdentifier 0,PropMessageExpiryInterval 6763,PropRequestProblemInformation -// 17,PropSubscriptionIdentifier 5,PropWillDelayInterval 10472,PropMessageExpiryInterval 3487,PropCorrelationData -// "\212"]} -TEST(Connect5QCTest, Encode30) { - uint8_t pkt[] = { - 0x10, 0x99, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x65, 0xc8, 0x2c, 0x3, 0x0, 0x9, 0x7b, 0xd5, - 0x96, 0x53, 0xf, 0x92, 0x68, 0x31, 0x8f, 0x11, 0x0, 0x0, 0x23, 0xbf, 0x24, 0xf9, 0xb, 0x0, 0x2, 0x0, 0x0, - 0x1a, 0x6b, 0x17, 0x11, 0xb, 0x5, 0x18, 0x0, 0x0, 0x28, 0xe8, 0x2, 0x0, 0x0, 0xd, 0x9f, 0x9, 0x0, 0x1, - 0xd4, 0x0, 0x8, 0x63, 0x19, 0x27, 0xca, 0x71, 0x71, 0x3c, 0xd5, 0x98, 0x1, 0x2, 0x0, 0x0, 0x2a, 0x63, 0x2, - 0x0, 0x0, 0x75, 0x4d, 0x15, 0x0, 0x1e, 0x16, 0x7d, 0xb7, 0x6e, 0xb5, 0xc6, 0x8a, 0x37, 0x40, 0x92, 0x26, 0x88, - 0xa, 0xa0, 0x51, 0xfe, 0x82, 0x6, 0x8b, 0x1e, 0x3e, 0xaa, 0x47, 0xa6, 0x75, 0x63, 0x33, 0x2b, 0x7c, 0x93, 0x24, - 0x31, 0x1a, 0x0, 0xc, 0x33, 0xe8, 0xa0, 0xe7, 0x9a, 0x8f, 0x62, 0x45, 0x60, 0x6c, 0xc1, 0x4e, 0x8, 0x0, 0x11, - 0xdf, 0xb, 0x24, 0xe3, 0xa1, 0xb9, 0x65, 0x4b, 0x87, 0x7f, 0xb6, 0x20, 0x24, 0x33, 0xc8, 0x7e, 0x5b, 0x9, 0x0, - 0xf, 0xc0, 0xe6, 0xb3, 0x30, 0x38, 0xc4, 0x57, 0xb6, 0xb3, 0xa4, 0x77, 0xb6, 0x97, 0x13, 0x29, 0x19, 0xbf, 0x18, - 0x0, 0x0, 0x41, 0x2d, 0x22, 0x29, 0x57, 0x28, 0xa1, 0x21, 0x7, 0xab, 0x3, 0x0, 0x15, 0xa2, 0xf, 0x22, 0x4d, - 0x5c, 0x2d, 0x2e, 0xe9, 0x17, 0x19, 0x85, 0xb9, 0x88, 0xe6, 0x34, 0x11, 0x57, 0x7d, 0x6c, 0xbb, 0xd1, 0x16, 0x0, - 0x9, 0xec, 0xfa, 0x8a, 0x50, 0xc6, 0x81, 0x50, 0x50, 0x1b, 0x21, 0x18, 0xd3, 0x0, 0xd, 0x8, 0x29, 0x65, 0xec, - 0xfb, 0xfb, 0x46, 0xe7, 0x2a, 0x90, 0xab, 0xb3, 0x82, 0x0, 0x1d, 0xe0, 0x24, 0xf4, 0x68, 0xee, 0x4d, 0xad, 0x61, - 0xa6, 0x2c, 0x7b, 0x95, 0xa7, 0x99, 0xc9, 0x7b, 0x8e, 0x2e, 0xaf, 0x33, 0x41, 0x3d, 0xf9, 0xd6, 0x11, 0xfe, 0x6f, - 0x4f, 0xba, 0x0, 0x1, 0x22, 0x0, 0xb, 0xdf, 0x3e, 0xff, 0xde, 0x31, 0x2b, 0xc0, 0x6e, 0x55, 0xb7, 0xe6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7b, 0xd5, 0x96, 0x53, 0xf, 0x92, 0x68, 0x31, 0x8f}; - uint8_t bytesprops1[] = {0xd4}; +// SubscribeRequest 11000 [("\154\198\171-\233\SYNUL\216%\n\196\&6\192\157\&0\159\216\186k\249\227>K\DC3\236",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("w7jl\r\b\213",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\EOT\185\158\227\RSDU",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("6U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\141\150T,\250\229\217f\217\SO\239FB\251\CAN",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(")\254=\198'J\DC1\DC1$\210av\158m\162)\146\132\224\191\n\232\145",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("BK\228\209\196\156\140\244?2\144\USP3z2..\DC2`\129D",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SO\154",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode3) { +uint8_t pkt[] = {0x82, 0x85, 0x1, 0x2a, 0xf8, 0x0, 0x1a, 0x9a, 0xc6, 0xab, 0x2d, 0xe9, 0x16, 0x55, 0x4c, 0xd8, 0x25, 0xa, 0xc4, 0x36, 0xc0, 0x9d, 0x30, 0x9f, 0xd8, 0xba, 0x6b, 0xf9, 0xe3, 0x3e, 0x4b, 0x13, 0xec, 0x0, 0x0, 0x7, 0x77, 0x37, 0x6a, 0x6c, 0xd, 0x8, 0xd5, 0x2, 0x0, 0x7, 0x4, 0xb9, 0x9e, 0xe3, 0x1e, 0x44, 0x55, 0x0, 0x0, 0x2, 0x36, 0x55, 0x1, 0x0, 0xf, 0x8d, 0x96, 0x54, 0x2c, 0xfa, 0xe5, 0xd9, 0x66, 0xd9, 0xe, 0xef, 0x46, 0x42, 0xfb, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0, 0x17, 0x29, 0xfe, 0x3d, 0xc6, 0x27, 0x4a, 0x11, 0x11, 0x24, 0xd2, 0x61, 0x76, 0x9e, 0x6d, 0xa2, 0x29, 0x92, 0x84, 0xe0, 0xbf, 0xa, 0xe8, 0x91, 0x0, 0x0, 0x16, 0x42, 0x4b, 0xe4, 0xd1, 0xc4, 0x9c, 0x8c, 0xf4, 0x3f, 0x32, 0x90, 0x1f, 0x50, 0x33, 0x7a, 0x32, 0x2e, 0x2e, 0x12, 0x60, 0x81, 0x44, 0x0, 0x0, 0x2, 0xe, 0x9a, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x9a, 0xc6, 0xab, 0x2d, 0xe9, 0x16, 0x55, 0x4c, 0xd8, 0x25, 0xa, 0xc4, 0x36, 0xc0, 0x9d, 0x30, 0x9f, 0xd8, 0xba, 0x6b, 0xf9, 0xe3, 0x3e, 0x4b, 0x13, 0xec}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x77, 0x37, 0x6a, 0x6c, 0xd, 0x8, 0xd5}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4, 0xb9, 0x9e, 0xe3, 0x1e, 0x44, 0x55}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x36, 0x55}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x8d, 0x96, 0x54, 0x2c, 0xfa, 0xe5, 0xd9, 0x66, 0xd9, 0xe, 0xef, 0x46, 0x42, 0xfb, 0x18}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x29, 0xfe, 0x3d, 0xc6, 0x27, 0x4a, 0x11, 0x11, 0x24, 0xd2, 0x61, 0x76, 0x9e, 0x6d, 0xa2, 0x29, 0x92, 0x84, 0xe0, 0xbf, 0xa, 0xe8, 0x91}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x42, 0x4b, 0xe4, 0xd1, 0xc4, 0x9c, 0x8c, 0xf4, 0x3f, 0x32, 0x90, 0x1f, 0x50, 0x33, 0x7a, 0x32, 0x2e, 0x2e, 0x12, 0x60, 0x81, 0x44}; + lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe, 0x9a}; + lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; +lwmqtt_sub_options_t sub_opts[9]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS0; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; +sub_opts[6].qos = LWMQTT_QOS0; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = false; +sub_opts[6].no_local = false; +sub_opts[7].qos = LWMQTT_QOS0; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = false; +sub_opts[8].qos = LWMQTT_QOS1; +sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[8].retain_as_published = false; +sub_opts[8].no_local = false; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9151}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6763}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10472}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3487}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, - }; - - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x16, 0x7d, 0xb7, 0x6e, 0xb5, 0xc6, 0x8a, 0x37, 0x40, 0x92, - 0x26, 0x88, 0xa, 0xa0, 0x51, 0xfe, 0x82, 0x6, 0x8b, 0x1e, - 0x3e, 0xaa, 0x47, 0xa6, 0x75, 0x63, 0x33, 0x2b, 0x7c, 0x93}; - uint8_t byteswillprops1[] = {0x33, 0xe8, 0xa0, 0xe7, 0x9a, 0x8f, 0x62, 0x45, 0x60, 0x6c, 0xc1, 0x4e}; - uint8_t byteswillprops2[] = {0xdf, 0xb, 0x24, 0xe3, 0xa1, 0xb9, 0x65, 0x4b, 0x87, - 0x7f, 0xb6, 0x20, 0x24, 0x33, 0xc8, 0x7e, 0x5b}; - uint8_t byteswillprops3[] = {0xc0, 0xe6, 0xb3, 0x30, 0x38, 0xc4, 0x57, 0xb6, - 0xb3, 0xa4, 0x77, 0xb6, 0x97, 0x13, 0x29}; - uint8_t byteswillprops4[] = {0xa2, 0xf, 0x22, 0x4d, 0x5c, 0x2d, 0x2e, 0xe9, 0x17, 0x19, 0x85, - 0xb9, 0x88, 0xe6, 0x34, 0x11, 0x57, 0x7d, 0x6c, 0xbb, 0xd1}; - uint8_t byteswillprops5[] = {0xec, 0xfa, 0x8a, 0x50, 0xc6, 0x81, 0x50, 0x50, 0x1b}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10851}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30029}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16685}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10583}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1963}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6355}}, }; - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8, 0x29, 0x65, 0xec, 0xfb, 0xfb, 0x46, 0xe7, 0x2a, 0x90, 0xab, 0xb3, 0x82}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe0, 0x24, 0xf4, 0x68, 0xee, 0x4d, 0xad, 0x61, 0xa6, 0x2c, - 0x7b, 0x95, 0xa7, 0x99, 0xc9, 0x7b, 0x8e, 0x2e, 0xaf, 0x33, - 0x41, 0x3d, 0xf9, 0xd6, 0x11, 0xfe, 0x6f, 0x4f, 0xba}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 26056; - uint8_t client_id_bytes[] = {0x63, 0x19, 0x27, 0xca, 0x71, 0x71, 0x3c, 0xd5}; - lwmqtt_string_t client_id = {8, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x22}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xdf, 0x3e, 0xff, 0xde, 0x31, 0x2b, 0xc0, 0x6e, 0x55, 0xb7, 0xe6}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11000, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 14771 [("#\200Q\136b\STX\234p\149",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS2}),("\228_\193\193f_2@\169\173\&8\140\194\221c7\ACK|\ESC\249[\"Cm\187\155\170\176",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("#\f&\179\130I\157\181\213\&6fl\DC2\184\SYN\188\175\227&yeI",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\247St\244Y\\m\197\n\f\DC4A\EOT\nmG\183L\SOH\161J\132\a\150\&3\DC3SP\130\194",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("E\169\130\158J\214",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x70, 0x39, 0xb3, 0x0, 0x9, 0x23, 0xc8, 0x51, 0x88, 0x62, 0x2, 0xea, 0x70, 0x95, 0x2, 0x0, - 0x1c, 0xe4, 0x5f, 0xc1, 0xc1, 0x66, 0x5f, 0x32, 0x40, 0xa9, 0xad, 0x38, 0x8c, 0xc2, 0xdd, 0x63, 0x37, - 0x6, 0x7c, 0x1b, 0xf9, 0x5b, 0x22, 0x43, 0x6d, 0xbb, 0x9b, 0xaa, 0xb0, 0x0, 0x0, 0x16, 0x23, 0xc, - 0x26, 0xb3, 0x82, 0x49, 0x9d, 0xb5, 0xd5, 0x36, 0x66, 0x6c, 0x12, 0xb8, 0x16, 0xbc, 0xaf, 0xe3, 0x26, - 0x79, 0x65, 0x49, 0x2, 0x0, 0x1e, 0xf7, 0x53, 0x74, 0xf4, 0x59, 0x5c, 0x6d, 0xc5, 0xa, 0xc, 0x14, - 0x41, 0x4, 0xa, 0x6d, 0x47, 0xb7, 0x4c, 0x1, 0xa1, 0x4a, 0x84, 0x7, 0x96, 0x33, 0x13, 0x53, 0x50, - 0x82, 0xc2, 0x0, 0x0, 0x6, 0x45, 0xa9, 0x82, 0x9e, 0x4a, 0xd6, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x23, 0xc8, 0x51, 0x88, 0x62, 0x2, 0xea, 0x70, 0x95}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe4, 0x5f, 0xc1, 0xc1, 0x66, 0x5f, 0x32, 0x40, 0xa9, 0xad, - 0x38, 0x8c, 0xc2, 0xdd, 0x63, 0x37, 0x6, 0x7c, 0x1b, 0xf9, - 0x5b, 0x22, 0x43, 0x6d, 0xbb, 0x9b, 0xaa, 0xb0}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x23, 0xc, 0x26, 0xb3, 0x82, 0x49, 0x9d, 0xb5, 0xd5, 0x36, 0x66, - 0x6c, 0x12, 0xb8, 0x16, 0xbc, 0xaf, 0xe3, 0x26, 0x79, 0x65, 0x49}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf7, 0x53, 0x74, 0xf4, 0x59, 0x5c, 0x6d, 0xc5, 0xa, 0xc, - 0x14, 0x41, 0x4, 0xa, 0x6d, 0x47, 0xb7, 0x4c, 0x1, 0xa1, - 0x4a, 0x84, 0x7, 0x96, 0x33, 0x13, 0x53, 0x50, 0x82, 0xc2}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x45, 0xa9, 0x82, 0x9e, 0x4a, 0xd6}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - - lwmqtt_property_t propslist[] = {}; + +// SubscribeRequest 21792 [("6\208Y0\251\199\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("GX\147{(\182\223\141\GSB;\164\153/\133\DC2s",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode4) { +uint8_t pkt[] = {0x82, 0x20, 0x55, 0x20, 0x0, 0x7, 0x36, 0xd0, 0x59, 0x30, 0xfb, 0xc7, 0x19, 0x1, 0x0, 0x11, 0x47, 0x58, 0x93, 0x7b, 0x28, 0xb6, 0xdf, 0x8d, 0x1d, 0x42, 0x3b, 0xa4, 0x99, 0x2f, 0x85, 0x12, 0x73, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x36, 0xd0, 0x59, 0x30, 0xfb, 0xc7, 0x19}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x47, 0x58, 0x93, 0x7b, 0x28, 0xb6, 0xdf, 0x8d, 0x1d, 0x42, 0x3b, 0xa4, 0x99, 0x2f, 0x85, 0x12, 0x73}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; +lwmqtt_sub_options_t sub_opts[2]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14771, 5, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21792, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 15521 [("`\189\"5\223\186\254\236\DC4y(\SYNn",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("r\ESC\204\199kn\141\&6\182\233~\DC4\158p$\220\NAK\GSm#",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("7m\NUL\DC2c\DC1\250\133",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\RS\\/\203\156\163\252S.\174\177kq\225p\148\163b\249\147e.\EOT\DC2k\206\177",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("/\b\177\207\ENQ\229\157k\212\ng\247\DC3\250K`\202tNp\249\223\135",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\157\187\230\229\224\196T",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\222\n\165\165\169%\204-\NUL\STX\192\143p4\221U",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\234\158xoF\217\SUB\128~\184\v",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\165)n:\242PZ@\244yx\255\DLEf\155\183\r\RSd\207",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0xae, 0x1, 0x3c, 0xa1, 0x0, 0xd, 0x60, 0xbd, 0x22, 0x35, 0xdf, 0xba, 0xfe, 0xec, 0x14, 0x79, - 0x28, 0x16, 0x6e, 0x2, 0x0, 0x14, 0x72, 0x1b, 0xcc, 0xc7, 0x6b, 0x6e, 0x8d, 0x36, 0xb6, 0xe9, 0x7e, - 0x14, 0x9e, 0x70, 0x24, 0xdc, 0x15, 0x1d, 0x6d, 0x23, 0x0, 0x0, 0x8, 0x37, 0x6d, 0x0, 0x12, 0x63, - 0x11, 0xfa, 0x85, 0x2, 0x0, 0x1b, 0x1e, 0x5c, 0x2f, 0xcb, 0x9c, 0xa3, 0xfc, 0x53, 0x2e, 0xae, 0xb1, - 0x6b, 0x71, 0xe1, 0x70, 0x94, 0xa3, 0x62, 0xf9, 0x93, 0x65, 0x2e, 0x4, 0x12, 0x6b, 0xce, 0xb1, 0x0, - 0x0, 0x17, 0x2f, 0x8, 0xb1, 0xcf, 0x5, 0xe5, 0x9d, 0x6b, 0xd4, 0xa, 0x67, 0xf7, 0x13, 0xfa, 0x4b, - 0x60, 0xca, 0x74, 0x4e, 0x70, 0xf9, 0xdf, 0x87, 0x1, 0x0, 0x7, 0x9d, 0xbb, 0xe6, 0xe5, 0xe0, 0xc4, - 0x54, 0x2, 0x0, 0x10, 0xde, 0xa, 0xa5, 0xa5, 0xa9, 0x25, 0xcc, 0x2d, 0x0, 0x2, 0xc0, 0x8f, 0x70, - 0x34, 0xdd, 0x55, 0x2, 0x0, 0xb, 0xea, 0x9e, 0x78, 0x6f, 0x46, 0xd9, 0x1a, 0x80, 0x7e, 0xb8, 0xb, - 0x2, 0x0, 0x14, 0xa5, 0x29, 0x6e, 0x3a, 0xf2, 0x50, 0x5a, 0x40, 0xf4, 0x79, 0x78, 0xff, 0x10, 0x66, - 0x9b, 0xb7, 0xd, 0x1e, 0x64, 0xcf, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x60, 0xbd, 0x22, 0x35, 0xdf, 0xba, 0xfe, 0xec, 0x14, 0x79, 0x28, 0x16, 0x6e}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x72, 0x1b, 0xcc, 0xc7, 0x6b, 0x6e, 0x8d, 0x36, 0xb6, 0xe9, - 0x7e, 0x14, 0x9e, 0x70, 0x24, 0xdc, 0x15, 0x1d, 0x6d, 0x23}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x37, 0x6d, 0x0, 0x12, 0x63, 0x11, 0xfa, 0x85}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1e, 0x5c, 0x2f, 0xcb, 0x9c, 0xa3, 0xfc, 0x53, 0x2e, 0xae, 0xb1, 0x6b, 0x71, 0xe1, - 0x70, 0x94, 0xa3, 0x62, 0xf9, 0x93, 0x65, 0x2e, 0x4, 0x12, 0x6b, 0xce, 0xb1}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2f, 0x8, 0xb1, 0xcf, 0x5, 0xe5, 0x9d, 0x6b, 0xd4, 0xa, 0x67, 0xf7, - 0x13, 0xfa, 0x4b, 0x60, 0xca, 0x74, 0x4e, 0x70, 0xf9, 0xdf, 0x87}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x9d, 0xbb, 0xe6, 0xe5, 0xe0, 0xc4, 0x54}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xde, 0xa, 0xa5, 0xa5, 0xa9, 0x25, 0xcc, 0x2d, - 0x0, 0x2, 0xc0, 0x8f, 0x70, 0x34, 0xdd, 0x55}; - lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xea, 0x9e, 0x78, 0x6f, 0x46, 0xd9, 0x1a, 0x80, 0x7e, 0xb8, 0xb}; - lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa5, 0x29, 0x6e, 0x3a, 0xf2, 0x50, 0x5a, 0x40, 0xf4, 0x79, - 0x78, 0xff, 0x10, 0x66, 0x9b, 0xb7, 0xd, 0x1e, 0x64, 0xcf}; - lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - - lwmqtt_property_t propslist[] = {}; + +// SubscribeRequest 20269 [("\220\133\254]\185%\213_\189\199t$[\170m\232m\SOf3c\226",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode5) { +uint8_t pkt[] = {0x82, 0x1b, 0x4f, 0x2d, 0x0, 0x16, 0xdc, 0x85, 0xfe, 0x5d, 0xb9, 0x25, 0xd5, 0x5f, 0xbd, 0xc7, 0x74, 0x24, 0x5b, 0xaa, 0x6d, 0xe8, 0x6d, 0xe, 0x66, 0x33, 0x63, 0xe2, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xdc, 0x85, 0xfe, 0x5d, 0xb9, 0x25, 0xd5, 0x5f, 0xbd, 0xc7, 0x74, 0x24, 0x5b, 0xaa, 0x6d, 0xe8, 0x6d, 0xe, 0x66, 0x33, 0x63, 0xe2}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; +lwmqtt_sub_options_t sub_opts[1]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15521, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20269, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 32751 [("\244p\172\184\198D\143w^DY=\SOH*\198Or\168\&2S\EOT\201F\221 ",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("6\131\253\146v\146O(\180\253\DC3\176\254\187\231\176\157\130\246\146rL\164\149i\255!",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("5\250\218p\241}\189\209\ESC6)\141\164(\SOH\213",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x4f, 0x7f, 0xef, 0x0, 0x19, 0xf4, 0x70, 0xac, 0xb8, 0xc6, 0x44, 0x8f, 0x77, 0x5e, 0x44, 0x59, - 0x3d, 0x1, 0x2a, 0xc6, 0x4f, 0x72, 0xa8, 0x32, 0x53, 0x4, 0xc9, 0x46, 0xdd, 0x20, 0x2, 0x0, 0x1b, - 0x36, 0x83, 0xfd, 0x92, 0x76, 0x92, 0x4f, 0x28, 0xb4, 0xfd, 0x13, 0xb0, 0xfe, 0xbb, 0xe7, 0xb0, 0x9d, - 0x82, 0xf6, 0x92, 0x72, 0x4c, 0xa4, 0x95, 0x69, 0xff, 0x21, 0x1, 0x0, 0x10, 0x35, 0xfa, 0xda, 0x70, - 0xf1, 0x7d, 0xbd, 0xd1, 0x1b, 0x36, 0x29, 0x8d, 0xa4, 0x28, 0x1, 0xd5, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xf4, 0x70, 0xac, 0xb8, 0xc6, 0x44, 0x8f, 0x77, 0x5e, 0x44, 0x59, 0x3d, 0x1, - 0x2a, 0xc6, 0x4f, 0x72, 0xa8, 0x32, 0x53, 0x4, 0xc9, 0x46, 0xdd, 0x20}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x36, 0x83, 0xfd, 0x92, 0x76, 0x92, 0x4f, 0x28, 0xb4, 0xfd, 0x13, 0xb0, 0xfe, 0xbb, - 0xe7, 0xb0, 0x9d, 0x82, 0xf6, 0x92, 0x72, 0x4c, 0xa4, 0x95, 0x69, 0xff, 0x21}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x35, 0xfa, 0xda, 0x70, 0xf1, 0x7d, 0xbd, 0xd1, - 0x1b, 0x36, 0x29, 0x8d, 0xa4, 0x28, 0x1, 0xd5}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - - lwmqtt_property_t propslist[] = {}; + +// SubscribeRequest 27793 [("\175\175\230\214\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(",\DEL[\SO\253\205\b\135j\ESC\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\224\206y\244\197V\182\157Q\232\248H\131\180\228B\FS\DC2\SO\159\243w",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\197\204\211\195h[\RSa&\150PL\SO\231\187\173\192P|q\240\r\139-\232\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\164\169|\199\van\145$\211<3\180)>\173Xgz:\225\DC4\163\212\141\177h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SUBl",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode6) { +uint8_t pkt[] = {0x82, 0x71, 0x6c, 0x91, 0x0, 0x5, 0xaf, 0xaf, 0xe6, 0xd6, 0x32, 0x1, 0x0, 0xb, 0x2c, 0x7f, 0x5b, 0xe, 0xfd, 0xcd, 0x8, 0x87, 0x6a, 0x1b, 0xd9, 0x0, 0x0, 0x16, 0xe0, 0xce, 0x79, 0xf4, 0xc5, 0x56, 0xb6, 0x9d, 0x51, 0xe8, 0xf8, 0x48, 0x83, 0xb4, 0xe4, 0x42, 0x1c, 0x12, 0xe, 0x9f, 0xf3, 0x77, 0x1, 0x0, 0x1a, 0xc5, 0xcc, 0xd3, 0xc3, 0x68, 0x5b, 0x1e, 0x61, 0x26, 0x96, 0x50, 0x4c, 0xe, 0xe7, 0xbb, 0xad, 0xc0, 0x50, 0x7c, 0x71, 0xf0, 0xd, 0x8b, 0x2d, 0xe8, 0xc5, 0x0, 0x0, 0x1b, 0xa4, 0xa9, 0x7c, 0xc7, 0xb, 0x61, 0x6e, 0x91, 0x24, 0xd3, 0x3c, 0x33, 0xb4, 0x29, 0x3e, 0xad, 0x58, 0x67, 0x7a, 0x3a, 0xe1, 0x14, 0xa3, 0xd4, 0x8d, 0xb1, 0x68, 0x1, 0x0, 0x2, 0x1a, 0x6c, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xaf, 0xaf, 0xe6, 0xd6, 0x32}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2c, 0x7f, 0x5b, 0xe, 0xfd, 0xcd, 0x8, 0x87, 0x6a, 0x1b, 0xd9}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe0, 0xce, 0x79, 0xf4, 0xc5, 0x56, 0xb6, 0x9d, 0x51, 0xe8, 0xf8, 0x48, 0x83, 0xb4, 0xe4, 0x42, 0x1c, 0x12, 0xe, 0x9f, 0xf3, 0x77}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xc5, 0xcc, 0xd3, 0xc3, 0x68, 0x5b, 0x1e, 0x61, 0x26, 0x96, 0x50, 0x4c, 0xe, 0xe7, 0xbb, 0xad, 0xc0, 0x50, 0x7c, 0x71, 0xf0, 0xd, 0x8b, 0x2d, 0xe8, 0xc5}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa4, 0xa9, 0x7c, 0xc7, 0xb, 0x61, 0x6e, 0x91, 0x24, 0xd3, 0x3c, 0x33, 0xb4, 0x29, 0x3e, 0xad, 0x58, 0x67, 0x7a, 0x3a, 0xe1, 0x14, 0xa3, 0xd4, 0x8d, 0xb1, 0x68}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1a, 0x6c}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; +lwmqtt_sub_options_t sub_opts[6]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS0; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS0; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS1; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32751, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27793, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 9203 [("\220\237 -// \185\218f\186\169G-\SYNR\157\129k\146\142\187\249\223Vy\168X\214\209B\212\ETX\183",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("7t\b,\195X\ETB\163\b\239\189\161%<\186M\148Ge\DC1",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\214\204\149U\228E\GS\"\154\138tn6\214\212\252\GS\221\192",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\193\225~tM*M\ETX\160!",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("!\SI\216\183\f1\167N7\226\168",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\141\196\137sYG3\148\203O\177",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\n8\154\150]\ETX\218\235H",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0x85, 0x1, 0x23, 0xf3, 0x0, 0x1e, 0xdc, 0xed, 0x20, 0xb9, 0xda, 0x66, 0xba, 0xa9, 0x47, 0x2d, - 0x16, 0x52, 0x9d, 0x81, 0x6b, 0x92, 0x8e, 0xbb, 0xf9, 0xdf, 0x56, 0x79, 0xa8, 0x58, 0xd6, 0xd1, 0x42, - 0xd4, 0x3, 0xb7, 0x2, 0x0, 0x14, 0x37, 0x74, 0x8, 0x2c, 0xc3, 0x58, 0x17, 0xa3, 0x8, 0xef, 0xbd, - 0xa1, 0x25, 0x3c, 0xba, 0x4d, 0x94, 0x47, 0x65, 0x11, 0x1, 0x0, 0x13, 0xd6, 0xcc, 0x95, 0x55, 0xe4, - 0x45, 0x1d, 0x22, 0x9a, 0x8a, 0x74, 0x6e, 0x36, 0xd6, 0xd4, 0xfc, 0x1d, 0xdd, 0xc0, 0x2, 0x0, 0xa, - 0xc1, 0xe1, 0x7e, 0x74, 0x4d, 0x2a, 0x4d, 0x3, 0xa0, 0x21, 0x1, 0x0, 0xb, 0x21, 0xf, 0xd8, 0xb7, - 0xc, 0x31, 0xa7, 0x4e, 0x37, 0xe2, 0xa8, 0x1, 0x0, 0xb, 0x8d, 0xc4, 0x89, 0x73, 0x59, 0x47, 0x33, - 0x94, 0xcb, 0x4f, 0xb1, 0x1, 0x0, 0x9, 0xa, 0x38, 0x9a, 0x96, 0x5d, 0x3, 0xda, 0xeb, 0x48, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xdc, 0xed, 0x20, 0xb9, 0xda, 0x66, 0xba, 0xa9, 0x47, 0x2d, - 0x16, 0x52, 0x9d, 0x81, 0x6b, 0x92, 0x8e, 0xbb, 0xf9, 0xdf, - 0x56, 0x79, 0xa8, 0x58, 0xd6, 0xd1, 0x42, 0xd4, 0x3, 0xb7}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x37, 0x74, 0x8, 0x2c, 0xc3, 0x58, 0x17, 0xa3, 0x8, 0xef, - 0xbd, 0xa1, 0x25, 0x3c, 0xba, 0x4d, 0x94, 0x47, 0x65, 0x11}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd6, 0xcc, 0x95, 0x55, 0xe4, 0x45, 0x1d, 0x22, 0x9a, 0x8a, - 0x74, 0x6e, 0x36, 0xd6, 0xd4, 0xfc, 0x1d, 0xdd, 0xc0}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc1, 0xe1, 0x7e, 0x74, 0x4d, 0x2a, 0x4d, 0x3, 0xa0, 0x21}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x21, 0xf, 0xd8, 0xb7, 0xc, 0x31, 0xa7, 0x4e, 0x37, 0xe2, 0xa8}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8d, 0xc4, 0x89, 0x73, 0x59, 0x47, 0x33, 0x94, 0xcb, 0x4f, 0xb1}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa, 0x38, 0x9a, 0x96, 0x5d, 0x3, 0xda, 0xeb, 0x48}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - - lwmqtt_property_t propslist[] = {}; + +// SubscribeRequest 30311 [("a\220\187\230\175\184\177\131\&8n\180}\229Z",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\234\199\181\DC1N\b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode7) { +uint8_t pkt[] = {0x82, 0x1f, 0x76, 0x67, 0x0, 0xe, 0x61, 0xdc, 0xbb, 0xe6, 0xaf, 0xb8, 0xb1, 0x83, 0x38, 0x6e, 0xb4, 0x7d, 0xe5, 0x5a, 0x0, 0x0, 0x6, 0xea, 0xc7, 0xb5, 0x11, 0x4e, 0x8, 0x2, 0x0, 0x0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x61, 0xdc, 0xbb, 0xe6, 0xaf, 0xb8, 0xb1, 0x83, 0x38, 0x6e, 0xb4, 0x7d, 0xe5, 0x5a}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xea, 0xc7, 0xb5, 0x11, 0x4e, 0x8}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; +lwmqtt_sub_options_t sub_opts[3]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9203, 7, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30311, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 7433 [("#\207",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\150",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\236",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("\193\250\200\202",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\237c\182\248?\181\241\171\158",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\189A\203\SYNq\144\&2\237\196d\226s\192\SUB",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("h\187\a\196\RS\\\235\216\SOH\fv3",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("/\185l>/\134\246\153\EOT\237\&5\v\213\STX\138\EOT\211a",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\DC4\STX\211\a-\145",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x60, 0x1d, 0x9, 0x0, 0x2, 0x23, 0xcf, 0x2, 0x0, 0x1, 0x96, 0x0, 0x0, 0x1, 0xec, 0x1, - 0x0, 0x4, 0xc1, 0xfa, 0xc8, 0xca, 0x2, 0x0, 0x9, 0xed, 0x63, 0xb6, 0xf8, 0x3f, 0xb5, 0xf1, 0xab, - 0x9e, 0x2, 0x0, 0xe, 0xbd, 0x41, 0xcb, 0x16, 0x71, 0x90, 0x32, 0xed, 0xc4, 0x64, 0xe2, 0x73, 0xc0, - 0x1a, 0x2, 0x0, 0xc, 0x68, 0xbb, 0x7, 0xc4, 0x1e, 0x5c, 0xeb, 0xd8, 0x1, 0xc, 0x76, 0x33, 0x1, - 0x0, 0x12, 0x2f, 0xb9, 0x6c, 0x3e, 0x2f, 0x86, 0xf6, 0x99, 0x4, 0xed, 0x35, 0xb, 0xd5, 0x2, 0x8a, - 0x4, 0xd3, 0x61, 0x1, 0x0, 0x6, 0x14, 0x2, 0xd3, 0x7, 0x2d, 0x91, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x23, 0xcf}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x96}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xec}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc1, 0xfa, 0xc8, 0xca}; - lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xed, 0x63, 0xb6, 0xf8, 0x3f, 0xb5, 0xf1, 0xab, 0x9e}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xbd, 0x41, 0xcb, 0x16, 0x71, 0x90, 0x32, - 0xed, 0xc4, 0x64, 0xe2, 0x73, 0xc0, 0x1a}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x68, 0xbb, 0x7, 0xc4, 0x1e, 0x5c, 0xeb, 0xd8, 0x1, 0xc, 0x76, 0x33}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x2f, 0xb9, 0x6c, 0x3e, 0x2f, 0x86, 0xf6, 0x99, 0x4, - 0xed, 0x35, 0xb, 0xd5, 0x2, 0x8a, 0x4, 0xd3, 0x61}; - lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x14, 0x2, 0xd3, 0x7, 0x2d, 0x91}; - lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - - lwmqtt_property_t propslist[] = {}; + +// SubscribeRequest 32651 [("\168U\NULn\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k\141i\169",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\ESC\250F\175_R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\187\219|!\193M\251\187\176h\ETB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\155m$\224\202\136\212\255\150=\242\197\195P\SUB\211",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\193\143\128\SOH5\150K6\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode8) { +uint8_t pkt[] = {0x82, 0x47, 0x7f, 0x8b, 0x0, 0x5, 0xa8, 0x55, 0x0, 0x6e, 0x94, 0x0, 0x0, 0x4, 0x6b, 0x8d, 0x69, 0xa9, 0x1, 0x0, 0x6, 0x1b, 0xfa, 0x46, 0xaf, 0x5f, 0x52, 0x2, 0x0, 0xb, 0xbb, 0xdb, 0x7c, 0x21, 0xc1, 0x4d, 0xfb, 0xbb, 0xb0, 0x68, 0x17, 0x0, 0x0, 0x10, 0x9b, 0x6d, 0x24, 0xe0, 0xca, 0x88, 0xd4, 0xff, 0x96, 0x3d, 0xf2, 0xc5, 0xc3, 0x50, 0x1a, 0xd3, 0x2, 0x0, 0x9, 0xc1, 0x8f, 0x80, 0x1, 0x35, 0x96, 0x4b, 0x36, 0x2, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xa8, 0x55, 0x0, 0x6e, 0x94}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6b, 0x8d, 0x69, 0xa9}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1b, 0xfa, 0x46, 0xaf, 0x5f, 0x52}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xbb, 0xdb, 0x7c, 0x21, 0xc1, 0x4d, 0xfb, 0xbb, 0xb0, 0x68, 0x17}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9b, 0x6d, 0x24, 0xe0, 0xca, 0x88, 0xd4, 0xff, 0x96, 0x3d, 0xf2, 0xc5, 0xc3, 0x50, 0x1a, 0xd3}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xc1, 0x8f, 0x80, 0x1, 0x35, 0x96, 0x4b, 0x36, 0x2}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; +lwmqtt_sub_options_t sub_opts[6]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS2; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS0; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS2; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7433, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32651, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 22949 [("\139\231\DC1\195J*\243\226Ip\ENQ\158\195U\254\DC3n'T\FS\230\201\178}A",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(">9d\234/%\170N&\242h\234\206\134\134",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("%\217\254\154\133h\199\ACKo%\128\253;_D\137\226\\\175\&9\138\&5\241B\a2\212",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\241\189ww\ETX\164\226",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("E\180D\152\180\232\246\212\187U\138\209\197\193\160\DC4\164j{\130\253\170",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\201mH\219\192\STX\SUB{H\142Q#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\213\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\ENQ]",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest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of(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xc5, 0xb4, 0x20}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xde, 0xaa, 0x0, 0x75, 0x5b, 0x90, 0xbc, 0xd, 0xf3, 0x13, - 0x17, 0xf5, 0x3a, 0x3c, 0x5e, 0x59, 0xf7, 0x45, 0x57, 0xb0, - 0x57, 0x9a, 0x39, 0x66, 0xe8, 0x8, 0x7, 0x9b}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2e, 0x93, 0x7b, 0x3c, 0xf7, 0xb4, 0x51, 0xca, 0x54, 0x2e, 0xc, 0xb9, - 0x86, 0x3e, 0x13, 0x6e, 0x27, 0x54, 0x1c, 0xe6, 0xc9, 0xb2, 0x7d, 0x41}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3e, 0x39, 0x64, 0xea, 0x2f, 0x25, 0xaa, 0x4e, - 0x26, 0xf2, 0x68, 0xea, 0xce, 0x86, 0x86}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x25, 0xd9, 0xfe, 0x9a, 0x85, 0x68, 0xc7, 0x6, 0x6f, 0x25, 0x80, 0xfd, 0x3b, 0x5f, - 0x44, 0x89, 0xe2, 0x5c, 0xaf, 0x39, 0x8a, 0x35, 0xf1, 0x42, 0x7, 0x32, 0xd4}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf1, 0xbd, 0x77, 0x77, 0x3, 0xa4, 0xe2}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x45, 0xb4, 0x44, 0x98, 0xb4, 0xe8, 0xf6, 0xd4, 0xbb, 0x55, 0x8a, - 0xd1, 0xc5, 0xc1, 0xa0, 0x14, 0xa4, 0x6a, 0x7b, 0x82, 0xfd, 0xaa}; - lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc9, 0x6d, 0x48, 0xdb, 0xc0, 0x2, 0x1a, 0x7b, 0x48, 0x8e, 0x51, 0x23}; - lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xd5, 0xd2}; - lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x5, 0x5d}; - lwmqtt_string_t topic_filter_s10 = {2, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; - - lwmqtt_property_t propslist[] = {}; + +// SubscribeRequest 21412 [("w\218]r\ESC\143A",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\163\133MU\FSV\131 -// V\b\ESC\210U\147\&0ma\248",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\250.\ETBh\239;\217\248\159\219\202\SOH\FS\135\218 \219\&3\ENQ\153s\199",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\207\SI/?@\201.\216\171h\187\128\242o|\144\158z,W\207\136",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0x95, 0x1, 0x26, 0x3e, 0x0, 0xb, 0xe4, 0x46, 0x94, 0xae, 0x67, 0x8d, 0x14, 0x8c, 0xf9, 0x6f, - 0xc4, 0x0, 0x0, 0x19, 0xb1, 0x97, 0x49, 0x59, 0x91, 0x62, 0xd9, 0x7a, 0xd, 0xcd, 0x28, 0x42, 0xfd, - 0x79, 0x54, 0x5b, 0x7e, 0x5a, 0xb7, 0x66, 0xf6, 0x5e, 0x5f, 0x49, 0x5a, 0x0, 0x0, 0x1a, 0xa, 0xad, - 0xd8, 0x12, 0x47, 0xeb, 0x59, 0xbd, 0x66, 0x69, 0x11, 0xb9, 0x67, 0xe5, 0x8, 0x45, 0x48, 0xfc, 0x46, - 0xf2, 0xd8, 0x6, 0xe7, 0xf3, 0xed, 0xf2, 0x2, 0x0, 0x2, 0x3e, 0x41, 0x1, 0x0, 0x12, 0xa3, 0x85, - 0x4d, 0x55, 0x1c, 0x56, 0x83, 0x20, 0x56, 0x8, 0x1b, 0xd2, 0x55, 0x93, 0x30, 0x6d, 0x61, 0xf8, 0x0, - 0x0, 0x16, 0xfa, 0x2e, 0x17, 0x68, 0xef, 0x3b, 0xd9, 0xf8, 0x9f, 0xdb, 0xca, 0x1, 0x1c, 0x87, 0xda, - 0x20, 0xdb, 0x33, 0x5, 0x99, 0x73, 0xc7, 0x2, 0x0, 0x16, 0xcf, 0xf, 0x2f, 0x3f, 0x40, 0xc9, 0x2e, - 0xd8, 0xab, 0x68, 0xbb, 0x80, 0xf2, 0x6f, 0x7c, 0x90, 0x9e, 0x7a, 0x2c, 0x57, 0xcf, 0x88, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xe4, 0x46, 0x94, 0xae, 0x67, 0x8d, 0x14, 0x8c, 0xf9, 0x6f, 0xc4}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb1, 0x97, 0x49, 0x59, 0x91, 0x62, 0xd9, 0x7a, 0xd, 0xcd, 0x28, 0x42, 0xfd, - 0x79, 0x54, 0x5b, 0x7e, 0x5a, 0xb7, 0x66, 0xf6, 0x5e, 0x5f, 0x49, 0x5a}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa, 0xad, 0xd8, 0x12, 0x47, 0xeb, 0x59, 0xbd, 0x66, 0x69, 0x11, 0xb9, 0x67, - 0xe5, 0x8, 0x45, 0x48, 0xfc, 0x46, 0xf2, 0xd8, 0x6, 0xe7, 0xf3, 0xed, 0xf2}; - lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3e, 0x41}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa3, 0x85, 0x4d, 0x55, 0x1c, 0x56, 0x83, 0x20, 0x56, - 0x8, 0x1b, 0xd2, 0x55, 0x93, 0x30, 0x6d, 0x61, 0xf8}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfa, 0x2e, 0x17, 0x68, 0xef, 0x3b, 0xd9, 0xf8, 0x9f, 0xdb, 0xca, - 0x1, 0x1c, 0x87, 0xda, 0x20, 0xdb, 0x33, 0x5, 0x99, 0x73, 0xc7}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xcf, 0xf, 0x2f, 0x3f, 0x40, 0xc9, 0x2e, 0xd8, 0xab, 0x68, 0xbb, - 0x80, 0xf2, 0x6f, 0x7c, 0x90, 0x9e, 0x7a, 0x2c, 0x57, 0xcf, 0x88}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - - lwmqtt_property_t propslist[] = {}; +// SubscribeRequest 10276 [("\SYN\144\218\230l\154\217\219\225\DLE\150m\141\195\222\183#N\DC1\219)\226\a\206y\204\150\RS\214\178",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("R\229\195\208\168\199\145\206\150\202|l\251\139`[\165@GL\SI\229\191!\183s\t\184\153",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode13) { +uint8_t pkt[] = {0x82, 0x43, 0x28, 0x24, 0x0, 0x1e, 0x16, 0x90, 0xda, 0xe6, 0x6c, 0x9a, 0xd9, 0xdb, 0xe1, 0x10, 0x96, 0x6d, 0x8d, 0xc3, 0xde, 0xb7, 0x23, 0x4e, 0x11, 0xdb, 0x29, 0xe2, 0x7, 0xce, 0x79, 0xcc, 0x96, 0x1e, 0xd6, 0xb2, 0x0, 0x0, 0x1d, 0x52, 0xe5, 0xc3, 0xd0, 0xa8, 0xc7, 0x91, 0xce, 0x96, 0xca, 0x7c, 0x6c, 0xfb, 0x8b, 0x60, 0x5b, 0xa5, 0x40, 0x47, 0x4c, 0xf, 0xe5, 0xbf, 0x21, 0xb7, 0x73, 0x9, 0xb8, 0x99, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x16, 0x90, 0xda, 0xe6, 0x6c, 0x9a, 0xd9, 0xdb, 0xe1, 0x10, 0x96, 0x6d, 0x8d, 0xc3, 0xde, 0xb7, 0x23, 0x4e, 0x11, 0xdb, 0x29, 0xe2, 0x7, 0xce, 0x79, 0xcc, 0x96, 0x1e, 0xd6, 0xb2}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x52, 0xe5, 0xc3, 0xd0, 0xa8, 0xc7, 0x91, 0xce, 0x96, 0xca, 0x7c, 0x6c, 0xfb, 0x8b, 0x60, 0x5b, 0xa5, 0x40, 0x47, 0x4c, 0xf, 0xe5, 0xbf, 0x21, 0xb7, 0x73, 0x9, 0xb8, 0x99}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; +lwmqtt_sub_options_t sub_opts[2]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS0; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9790, 7, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10276, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 29850 [("\ESC\148a",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("e\"\230B\SYNNm^{\160\218\FS\152\238\232\143\135\180\197\251D\202\205n\STX\161\f\175\165}",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("]\RS\172\169\198\239\243#\136\243\DC37n\177\215k\167\243",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("Q\129=ls\SI\233\136\246\208\170\188\SUBg\134\155B",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("[=",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\174\230\194'q",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\\%\201\190\183\&1\138\217=~\181c\233?\138\160X",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\SI\159f\134\CAN%\254\185\194T\216\145[\248\229\214>\170\216\164",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\164r\209\EOTC\218[-BMGq\236>M\194\139H\216\165:R\132t\179\224\157C\147%",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode12) { - uint8_t pkt[] = {0x82, 0xab, 0x1, 0x74, 0x9a, 0x0, 0x3, 0x1b, 0x94, 0x61, 0x2, 0x0, 0x1e, 0x65, 0x22, 0xe6, - 0x42, 0x16, 0x4e, 0x6d, 0x5e, 0x7b, 0xa0, 0xda, 0x1c, 0x98, 0xee, 0xe8, 0x8f, 0x87, 0xb4, 0xc5, - 0xfb, 0x44, 0xca, 0xcd, 0x6e, 0x2, 0xa1, 0xc, 0xaf, 0xa5, 0x7d, 0x0, 0x0, 0x12, 0x5d, 0x1e, - 0xac, 0xa9, 0xc6, 0xef, 0xf3, 0x23, 0x88, 0xf3, 0x13, 0x37, 0x6e, 0xb1, 0xd7, 0x6b, 0xa7, 0xf3, - 0x1, 0x0, 0x11, 0x51, 0x81, 0x3d, 0x6c, 0x73, 0xf, 0xe9, 0x88, 0xf6, 0xd0, 0xaa, 0xbc, 0x1a, - 0x67, 0x86, 0x9b, 0x42, 0x0, 0x0, 0x2, 0x5b, 0x3d, 0x0, 0x0, 0x5, 0xae, 0xe6, 0xc2, 0x27, - 0x71, 0x2, 0x0, 0x11, 0x5c, 0x25, 0xc9, 0xbe, 0xb7, 0x31, 0x8a, 0xd9, 0x3d, 0x7e, 0xb5, 0x63, - 0xe9, 0x3f, 0x8a, 0xa0, 0x58, 0x1, 0x0, 0x14, 0xf, 0x9f, 0x66, 0x86, 0x18, 0x25, 0xfe, 0xb9, - 0xc2, 0x54, 0xd8, 0x91, 0x5b, 0xf8, 0xe5, 0xd6, 0x3e, 0xaa, 0xd8, 0xa4, 0x1, 0x0, 0x1e, 0xa4, - 0x72, 0xd1, 0x4, 0x43, 0xda, 0x5b, 0x2d, 0x42, 0x4d, 0x47, 0x71, 0xec, 0x3e, 0x4d, 0xc2, 0x8b, - 0x48, 0xd8, 0xa5, 0x3a, 0x52, 0x84, 0x74, 0xb3, 0xe0, 0x9d, 0x43, 0x93, 0x25, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x1b, 0x94, 0x61}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x65, 0x22, 0xe6, 0x42, 0x16, 0x4e, 0x6d, 0x5e, 0x7b, 0xa0, - 0xda, 0x1c, 0x98, 0xee, 0xe8, 0x8f, 0x87, 0xb4, 0xc5, 0xfb, - 0x44, 0xca, 0xcd, 0x6e, 0x2, 0xa1, 0xc, 0xaf, 0xa5, 0x7d}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5d, 0x1e, 0xac, 0xa9, 0xc6, 0xef, 0xf3, 0x23, 0x88, - 0xf3, 0x13, 0x37, 0x6e, 0xb1, 0xd7, 0x6b, 0xa7, 0xf3}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x51, 0x81, 0x3d, 0x6c, 0x73, 0xf, 0xe9, 0x88, 0xf6, - 0xd0, 0xaa, 0xbc, 0x1a, 0x67, 0x86, 0x9b, 0x42}; - lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5b, 0x3d}; - lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xae, 0xe6, 0xc2, 0x27, 0x71}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5c, 0x25, 0xc9, 0xbe, 0xb7, 0x31, 0x8a, 0xd9, 0x3d, - 0x7e, 0xb5, 0x63, 0xe9, 0x3f, 0x8a, 0xa0, 0x58}; - lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf, 0x9f, 0x66, 0x86, 0x18, 0x25, 0xfe, 0xb9, 0xc2, 0x54, - 0xd8, 0x91, 0x5b, 0xf8, 0xe5, 0xd6, 0x3e, 0xaa, 0xd8, 0xa4}; - lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa4, 0x72, 0xd1, 0x4, 0x43, 0xda, 0x5b, 0x2d, 0x42, 0x4d, - 0x47, 0x71, 0xec, 0x3e, 0x4d, 0xc2, 0x8b, 0x48, 0xd8, 0xa5, - 0x3a, 0x52, 0x84, 0x74, 0xb3, 0xe0, 0x9d, 0x43, 0x93, 0x25}; - lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29850, 9, topic_filters, sub_opts, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18338 [("\162\249\GS\153yq\215F\221 \242",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\158\168o!e\ACK\247\202\128\152f\197m\\\176\247(\167\US\214\188ti\225\192",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0x2c, 0x47, 0xa2, 0x0, 0xb, 0xa2, 0xf9, 0x1d, 0x99, 0x79, 0x71, 0xd7, 0x46, 0xdd, 0x20, - 0xf2, 0x0, 0x0, 0x19, 0x9e, 0xa8, 0x6f, 0x21, 0x65, 0x6, 0xf7, 0xca, 0x80, 0x98, 0x66, 0xc5, - 0x6d, 0x5c, 0xb0, 0xf7, 0x28, 0xa7, 0x1f, 0xd6, 0xbc, 0x74, 0x69, 0xe1, 0xc0, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xa2, 0xf9, 0x1d, 0x99, 0x79, 0x71, 0xd7, 0x46, 0xdd, 0x20, 0xf2}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9e, 0xa8, 0x6f, 0x21, 0x65, 0x6, 0xf7, 0xca, 0x80, 0x98, 0x66, 0xc5, 0x6d, - 0x5c, 0xb0, 0xf7, 0x28, 0xa7, 0x1f, 0xd6, 0xbc, 0x74, 0x69, 0xe1, 0xc0}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18338, 2, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} -// SubscribeRequest 4108 [("\199\233\131\SYNf\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("j\199\156\237c\EMH\246\212\232\&7\217aJ\193/\r\253\246>\215\t\221",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("c\FSd\247?\136\249Y\DELc\167\ETX\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS1}),("\165\213\140\159\225\192\145\NAK$mr\141CDwEw\US\152\180\NAK\GSO\142\188r",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\162\247i\170\139\236sr-\177\215M3e\144\ETX3#\STX`s&\254i\233\179\128\142\SI",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("[k\181}\136\187j<\FS\142\DC4\186\157\214\162",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\202\191;\254\&7%\136\210:\NAKeE\203\&0\DC1\nlG*@\183",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("X\134i\144\&7x\198",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\SO9;\183,",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\SOJ\248\&8\219-jq\145\166\228\144\139\DC4M\SYN\245\220\150.\193K\178\&3\149\132D",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 7750 [("\191\131\229\247n\DC4\170]A\183\163\132",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\209U\"`\185\222\252RC|G\202#\161P\240\SYN\DLE;@\172\251\188dV",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\188t\246J\ETX\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\154<\139\";}\250\187\&0pG\224\173\148\216\238#R\187\168\142\190",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("}\146\176\ncE\212\185:\132-\DLE9\ETB[r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("m\DC3\169\GSX\164\&5\158\RS\153\235W8\CANp",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\151\209",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("$U\214\224\143\199M\166v\143\&6\241\STX\DC2U\245\144\153\135n\161\146\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\247\ACK\228'\209\245\RS\\\148\ACK\254\187\255gl\215",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\229rp:\145\167\ACK\191\188\195\US\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0xcf, 0x1, 0x10, 0xc, 0x0, 0x6, 0xc7, 0xe9, 0x83, 0x16, 0x66, 0xd2, 0x0, 0x0, 0x17, 0x6a, - 0xc7, 0x9c, 0xed, 0x63, 0x19, 0x48, 0xf6, 0xd4, 0xe8, 0x37, 0xd9, 0x61, 0x4a, 0xc1, 0x2f, 0xd, 0xfd, - 0xf6, 0x3e, 0xd7, 0x9, 0xdd, 0x0, 0x0, 0xd, 0x63, 0x1c, 0x64, 0xf7, 0x3f, 0x88, 0xf9, 0x59, 0x7f, - 0x63, 0xa7, 0x3, 0xb9, 0x1, 0x0, 0x1a, 0xa5, 0xd5, 0x8c, 0x9f, 0xe1, 0xc0, 0x91, 0x15, 0x24, 0x6d, - 0x72, 0x8d, 0x43, 0x44, 0x77, 0x45, 0x77, 0x1f, 0x98, 0xb4, 0x15, 0x1d, 0x4f, 0x8e, 0xbc, 0x72, 0x2, - 0x0, 0x1d, 0xa2, 0xf7, 0x69, 0xaa, 0x8b, 0xec, 0x73, 0x72, 0x2d, 0xb1, 0xd7, 0x4d, 0x33, 0x65, 0x90, - 0x3, 0x33, 0x23, 0x2, 0x60, 0x73, 0x26, 0xfe, 0x69, 0xe9, 0xb3, 0x80, 0x8e, 0xf, 0x1, 0x0, 0xf, - 0x5b, 0x6b, 0xb5, 0x7d, 0x88, 0xbb, 0x6a, 0x3c, 0x1c, 0x8e, 0x14, 0xba, 0x9d, 0xd6, 0xa2, 0x2, 0x0, - 0x15, 0xca, 0xbf, 0x3b, 0xfe, 0x37, 0x25, 0x88, 0xd2, 0x3a, 0x15, 0x65, 0x45, 0xcb, 0x30, 0x11, 0xa, - 0x6c, 0x47, 0x2a, 0x40, 0xb7, 0x1, 0x0, 0x7, 0x58, 0x86, 0x69, 0x90, 0x37, 0x78, 0xc6, 0x2, 0x0, - 0x5, 0xe, 0x39, 0x3b, 0xb7, 0x2c, 0x2, 0x0, 0x1b, 0xe, 0x4a, 0xf8, 0x38, 0xdb, 0x2d, 0x6a, 0x71, - 0x91, 0xa6, 0xe4, 0x90, 0x8b, 0x14, 0x4d, 0x16, 0xf5, 0xdc, 0x96, 0x2e, 0xc1, 0x4b, 0xb2, 0x33, 0x95, - 0x84, 0x44, 0x0, 0x0, 0x0, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xc7, 0xe9, 0x83, 0x16, 0x66, 0xd2}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6a, 0xc7, 0x9c, 0xed, 0x63, 0x19, 0x48, 0xf6, 0xd4, 0xe8, 0x37, 0xd9, - 0x61, 0x4a, 0xc1, 0x2f, 0xd, 0xfd, 0xf6, 0x3e, 0xd7, 0x9, 0xdd}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x63, 0x1c, 0x64, 0xf7, 0x3f, 0x88, 0xf9, 0x59, 0x7f, 0x63, 0xa7, 0x3, 0xb9}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa5, 0xd5, 0x8c, 0x9f, 0xe1, 0xc0, 0x91, 0x15, 0x24, 0x6d, 0x72, 0x8d, 0x43, - 0x44, 0x77, 0x45, 0x77, 0x1f, 0x98, 0xb4, 0x15, 0x1d, 0x4f, 0x8e, 0xbc, 0x72}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa2, 0xf7, 0x69, 0xaa, 0x8b, 0xec, 0x73, 0x72, 0x2d, 0xb1, - 0xd7, 0x4d, 0x33, 0x65, 0x90, 0x3, 0x33, 0x23, 0x2, 0x60, - 0x73, 0x26, 0xfe, 0x69, 0xe9, 0xb3, 0x80, 0x8e, 0xf}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5b, 0x6b, 0xb5, 0x7d, 0x88, 0xbb, 0x6a, 0x3c, - 0x1c, 0x8e, 0x14, 0xba, 0x9d, 0xd6, 0xa2}; +uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x1e, 0x46, 0x0, 0xc, 0xbf, 0x83, 0xe5, 0xf7, 0x6e, 0x14, 0xaa, 0x5d, 0x41, 0xb7, 0xa3, 0x84, 0x2, 0x0, 0x19, 0xd1, 0x55, 0x22, 0x60, 0xb9, 0xde, 0xfc, 0x52, 0x43, 0x7c, 0x47, 0xca, 0x23, 0xa1, 0x50, 0xf0, 0x16, 0x10, 0x3b, 0x40, 0xac, 0xfb, 0xbc, 0x64, 0x56, 0x1, 0x0, 0x6, 0xbc, 0x74, 0xf6, 0x4a, 0x3, 0xae, 0x1, 0x0, 0x16, 0x9a, 0x3c, 0x8b, 0x22, 0x3b, 0x7d, 0xfa, 0xbb, 0x30, 0x70, 0x47, 0xe0, 0xad, 0x94, 0xd8, 0xee, 0x23, 0x52, 0xbb, 0xa8, 0x8e, 0xbe, 0x2, 0x0, 0x10, 0x7d, 0x92, 0xb0, 0xa, 0x63, 0x45, 0xd4, 0xb9, 0x3a, 0x84, 0x2d, 0x10, 0x39, 0x17, 0x5b, 0x72, 0x2, 0x0, 0xf, 0x6d, 0x13, 0xa9, 0x1d, 0x58, 0xa4, 0x35, 0x9e, 0x1e, 0x99, 0xeb, 0x57, 0x38, 0x18, 0x70, 0x0, 0x0, 0x2, 0x97, 0xd1, 0x0, 0x0, 0x17, 0x24, 0x55, 0xd6, 0xe0, 0x8f, 0xc7, 0x4d, 0xa6, 0x76, 0x8f, 0x36, 0xf1, 0x2, 0x12, 0x55, 0xf5, 0x90, 0x99, 0x87, 0x6e, 0xa1, 0x92, 0x1, 0x2, 0x0, 0x10, 0xf7, 0x6, 0xe4, 0x27, 0xd1, 0xf5, 0x1e, 0x5c, 0x94, 0x6, 0xfe, 0xbb, 0xff, 0x67, 0x6c, 0xd7, 0x1, 0x0, 0xc, 0xe5, 0x72, 0x70, 0x3a, 0x91, 0xa7, 0x6, 0xbf, 0xbc, 0xc3, 0x1f, 0x5c, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xbf, 0x83, 0xe5, 0xf7, 0x6e, 0x14, 0xaa, 0x5d, 0x41, 0xb7, 0xa3, 0x84}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd1, 0x55, 0x22, 0x60, 0xb9, 0xde, 0xfc, 0x52, 0x43, 0x7c, 0x47, 0xca, 0x23, 0xa1, 0x50, 0xf0, 0x16, 0x10, 0x3b, 0x40, 0xac, 0xfb, 0xbc, 0x64, 0x56}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xbc, 0x74, 0xf6, 0x4a, 0x3, 0xae}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x9a, 0x3c, 0x8b, 0x22, 0x3b, 0x7d, 0xfa, 0xbb, 0x30, 0x70, 0x47, 0xe0, 0xad, 0x94, 0xd8, 0xee, 0x23, 0x52, 0xbb, 0xa8, 0x8e, 0xbe}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x7d, 0x92, 0xb0, 0xa, 0x63, 0x45, 0xd4, 0xb9, 0x3a, 0x84, 0x2d, 0x10, 0x39, 0x17, 0x5b, 0x72}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6d, 0x13, 0xa9, 0x1d, 0x58, 0xa4, 0x35, 0x9e, 0x1e, 0x99, 0xeb, 0x57, 0x38, 0x18, 0x70}; lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xca, 0xbf, 0x3b, 0xfe, 0x37, 0x25, 0x88, 0xd2, 0x3a, 0x15, 0x65, - 0x45, 0xcb, 0x30, 0x11, 0xa, 0x6c, 0x47, 0x2a, 0x40, 0xb7}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x58, 0x86, 0x69, 0x90, 0x37, 0x78, 0xc6}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe, 0x39, 0x3b, 0xb7, 0x2c}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe, 0x4a, 0xf8, 0x38, 0xdb, 0x2d, 0x6a, 0x71, 0x91, 0xa6, 0xe4, 0x90, 0x8b, 0x14, - 0x4d, 0x16, 0xf5, 0xdc, 0x96, 0x2e, 0xc1, 0x4b, 0xb2, 0x33, 0x95, 0x84, 0x44}; - lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0}; - lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS1; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; - - lwmqtt_property_t propslist[] = {}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x97, 0xd1}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x24, 0x55, 0xd6, 0xe0, 0x8f, 0xc7, 0x4d, 0xa6, 0x76, 0x8f, 0x36, 0xf1, 0x2, 0x12, 0x55, 0xf5, 0x90, 0x99, 0x87, 0x6e, 0xa1, 0x92, 0x1}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xf7, 0x6, 0xe4, 0x27, 0xd1, 0xf5, 0x1e, 0x5c, 0x94, 0x6, 0xfe, 0xbb, 0xff, 0x67, 0x6c, 0xd7}; + lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe5, 0x72, 0x70, 0x3a, 0x91, 0xa7, 0x6, 0xbf, 0xbc, 0xc3, 0x1f, 0x5c}; + lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; +topic_filters[9] = topic_filter_s9; +lwmqtt_sub_options_t sub_opts[10]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS2; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS2; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; +sub_opts[6].qos = LWMQTT_QOS0; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = false; +sub_opts[6].no_local = false; +sub_opts[7].qos = LWMQTT_QOS2; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = false; +sub_opts[8].qos = LWMQTT_QOS1; +sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[8].retain_as_published = false; +sub_opts[8].no_local = false; +sub_opts[9].qos = LWMQTT_QOS1; +sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[9].retain_as_published = false; +sub_opts[9].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4108, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7750, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 28646 [("\224\NAK[\140\150Pw\230\154\136,A\236+U\195sv\137 \161\251K",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\177\&6\255\208\&6s5\196\213\&7\242\172\v?\226_} r2\ENQB\225\136",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(",\181T\ETX\169&\SOH",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\231\185\DC3\162h\140[&\152A\151\t\128\157\a\143S",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("f\169\228\149VWZ\202B'\230\219\143j\160GJ\187+\175\248;K\185",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("`\ENQ\147P\ESC\152\157\138\168Qq\215\230\199\235I2[",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("X\148:\ENQ\215R\184\152\ACK\221\250\194\185W\248\155\FSI\t\132\251\148\146",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("v\189",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\145\160\130/\197z\202\198Uyv",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\176Xe",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\DC4\\d\168\230N\241",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] + +// SubscribeRequest 6922 [("\176\131\178\223z\196\&7\244P\255\198\182\182Y\250e&\173\215\129\SOH\185\nQ7\NULK\SOH*",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("Xv\191Qn\146\ACK\CAN\159\&1\251U\202\233B\r\158\234\237",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\142\196\245\228Y{#1\n\227\151\215>O\213\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("l\232\254\201\210\146\&9\138\199\199?\n`~(#\223\NUL\152\142\194\&0\227\213>",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\183Gl\161\243g%\128",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode15) { - uint8_t pkt[] = {0x82, 0xc2, 0x1, 0x6f, 0xe6, 0x0, 0x17, 0xe0, 0x15, 0x5b, 0x8c, 0x96, 0x50, 0x77, 0xe6, 0x9a, 0x88, - 0x2c, 0x41, 0xec, 0x2b, 0x55, 0xc3, 0x73, 0x76, 0x89, 0x20, 0xa1, 0xfb, 0x4b, 0x2, 0x0, 0x18, 0xb1, - 0x36, 0xff, 0xd0, 0x36, 0x73, 0x35, 0xc4, 0xd5, 0x37, 0xf2, 0xac, 0xb, 0x3f, 0xe2, 0x5f, 0x7d, 0x20, - 0x72, 0x32, 0x5, 0x42, 0xe1, 0x88, 0x2, 0x0, 0x7, 0x2c, 0xb5, 0x54, 0x3, 0xa9, 0x26, 0x1, 0x0, - 0x0, 0x11, 0xe7, 0xb9, 0x13, 0xa2, 0x68, 0x8c, 0x5b, 0x26, 0x98, 0x41, 0x97, 0x9, 0x80, 0x9d, 0x7, - 0x8f, 0x53, 0x0, 0x0, 0x18, 0x66, 0xa9, 0xe4, 0x95, 0x56, 0x57, 0x5a, 0xca, 0x42, 0x27, 0xe6, 0xdb, - 0x8f, 0x6a, 0xa0, 0x47, 0x4a, 0xbb, 0x2b, 0xaf, 0xf8, 0x3b, 0x4b, 0xb9, 0x0, 0x0, 0x12, 0x60, 0x5, - 0x93, 0x50, 0x1b, 0x98, 0x9d, 0x8a, 0xa8, 0x51, 0x71, 0xd7, 0xe6, 0xc7, 0xeb, 0x49, 0x32, 0x5b, 0x2, - 0x0, 0x17, 0x58, 0x94, 0x3a, 0x5, 0xd7, 0x52, 0xb8, 0x98, 0x6, 0xdd, 0xfa, 0xc2, 0xb9, 0x57, 0xf8, - 0x9b, 0x1c, 0x49, 0x9, 0x84, 0xfb, 0x94, 0x92, 0x0, 0x0, 0x2, 0x76, 0xbd, 0x2, 0x0, 0xb, 0x91, - 0xa0, 0x82, 0x2f, 0xc5, 0x7a, 0xca, 0xc6, 0x55, 0x79, 0x76, 0x2, 0x0, 0x3, 0xb0, 0x58, 0x65, 0x2, - 0x0, 0x7, 0x14, 0x5c, 0x64, 0xa8, 0xe6, 0x4e, 0xf1, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xe0, 0x15, 0x5b, 0x8c, 0x96, 0x50, 0x77, 0xe6, 0x9a, 0x88, 0x2c, 0x41, - 0xec, 0x2b, 0x55, 0xc3, 0x73, 0x76, 0x89, 0x20, 0xa1, 0xfb, 0x4b}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb1, 0x36, 0xff, 0xd0, 0x36, 0x73, 0x35, 0xc4, 0xd5, 0x37, 0xf2, 0xac, - 0xb, 0x3f, 0xe2, 0x5f, 0x7d, 0x20, 0x72, 0x32, 0x5, 0x42, 0xe1, 0x88}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2c, 0xb5, 0x54, 0x3, 0xa9, 0x26, 0x1}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe7, 0xb9, 0x13, 0xa2, 0x68, 0x8c, 0x5b, 0x26, 0x98, - 0x41, 0x97, 0x9, 0x80, 0x9d, 0x7, 0x8f, 0x53}; - lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x66, 0xa9, 0xe4, 0x95, 0x56, 0x57, 0x5a, 0xca, 0x42, 0x27, 0xe6, 0xdb, - 0x8f, 0x6a, 0xa0, 0x47, 0x4a, 0xbb, 0x2b, 0xaf, 0xf8, 0x3b, 0x4b, 0xb9}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x60, 0x5, 0x93, 0x50, 0x1b, 0x98, 0x9d, 0x8a, 0xa8, - 0x51, 0x71, 0xd7, 0xe6, 0xc7, 0xeb, 0x49, 0x32, 0x5b}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x58, 0x94, 0x3a, 0x5, 0xd7, 0x52, 0xb8, 0x98, 0x6, 0xdd, 0xfa, 0xc2, - 0xb9, 0x57, 0xf8, 0x9b, 0x1c, 0x49, 0x9, 0x84, 0xfb, 0x94, 0x92}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x76, 0xbd}; - lwmqtt_string_t topic_filter_s7 = {2, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x91, 0xa0, 0x82, 0x2f, 0xc5, 0x7a, 0xca, 0xc6, 0x55, 0x79, 0x76}; - lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xb0, 0x58, 0x65}; - lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x14, 0x5c, 0x64, 0xa8, 0xe6, 0x4e, 0xf1}; - lwmqtt_string_t topic_filter_s10 = {7, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS1; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x82, 0x72, 0x1b, 0xa, 0x0, 0x1d, 0xb0, 0x83, 0xb2, 0xdf, 0x7a, 0xc4, 0x37, 0xf4, 0x50, 0xff, 0xc6, 0xb6, 0xb6, 0x59, 0xfa, 0x65, 0x26, 0xad, 0xd7, 0x81, 0x1, 0xb9, 0xa, 0x51, 0x37, 0x0, 0x4b, 0x1, 0x2a, 0x1, 0x0, 0x13, 0x58, 0x76, 0xbf, 0x51, 0x6e, 0x92, 0x6, 0x18, 0x9f, 0x31, 0xfb, 0x55, 0xca, 0xe9, 0x42, 0xd, 0x9e, 0xea, 0xed, 0x1, 0x0, 0x10, 0x8e, 0xc4, 0xf5, 0xe4, 0x59, 0x7b, 0x23, 0x31, 0xa, 0xe3, 0x97, 0xd7, 0x3e, 0x4f, 0xd5, 0x83, 0x1, 0x0, 0x19, 0x6c, 0xe8, 0xfe, 0xc9, 0xd2, 0x92, 0x39, 0x8a, 0xc7, 0xc7, 0x3f, 0xa, 0x60, 0x7e, 0x28, 0x23, 0xdf, 0x0, 0x98, 0x8e, 0xc2, 0x30, 0xe3, 0xd5, 0x3e, 0x2, 0x0, 0x8, 0xb7, 0x47, 0x6c, 0xa1, 0xf3, 0x67, 0x25, 0x80, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xb0, 0x83, 0xb2, 0xdf, 0x7a, 0xc4, 0x37, 0xf4, 0x50, 0xff, 0xc6, 0xb6, 0xb6, 0x59, 0xfa, 0x65, 0x26, 0xad, 0xd7, 0x81, 0x1, 0xb9, 0xa, 0x51, 0x37, 0x0, 0x4b, 0x1, 0x2a}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x58, 0x76, 0xbf, 0x51, 0x6e, 0x92, 0x6, 0x18, 0x9f, 0x31, 0xfb, 0x55, 0xca, 0xe9, 0x42, 0xd, 0x9e, 0xea, 0xed}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x8e, 0xc4, 0xf5, 0xe4, 0x59, 0x7b, 0x23, 0x31, 0xa, 0xe3, 0x97, 0xd7, 0x3e, 0x4f, 0xd5, 0x83}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6c, 0xe8, 0xfe, 0xc9, 0xd2, 0x92, 0x39, 0x8a, 0xc7, 0xc7, 0x3f, 0xa, 0x60, 0x7e, 0x28, 0x23, 0xdf, 0x0, 0x98, 0x8e, 0xc2, 0x30, 0xe3, 0xd5, 0x3e}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xb7, 0x47, 0x6c, 0xa1, 0xf3, 0x67, 0x25, 0x80}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; +lwmqtt_sub_options_t sub_opts[5]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS2; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS1; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28646, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6922, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 31174 [(":\243\230#\164\248!\232\150\150+\138m\198\212\"\193f\129\SOH}K\195\171\150",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("4`MS\232\255\169oP\EOT\RS\198P\250r2\135\v\183FW\STX)\173",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("K\167{\179J\RS\NAK3=*T4\208*\145\228\198h\252\246\248\a",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\ETB\245\174A\225F\225\216j\197\147B\t\254\132\216\164\205\150K$\164lT\ETX\212mRv",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\180Sg\a&R\165\162\174g\178\253\GS*\197i\USu_&\229\201\131d\169\231@",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\184l\ETX\225\&2\130\189\132\DC22N9\214\175@\197M\241/X#\ACKQ0\250q\DC4\r",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\253C7\NAK\203#\170",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\133\213\133\SUB\235\254\194\&5\223\143\241-\SUB\177n\233\211{\FSE",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] + +// SubscribeRequest 26316 [("\229\199\211Bm\186\243W\161\139O{A ^F\180,!5y\243\EOT\166\226opy\131\ESC",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Z\153\&6\215(\215\EM\137\140\252",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("U\\N\255a\146",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\174\\\247w\175\SYN\148o\191E\n[\197\SO\197a\175\227\236",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\DC2\180\170\148L1[`@[\253\159,\136`\ESC\229\DEL5\210\193\ESC@\131\152\212",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\141\&8\227\131\152p\224\162\146\228\175V \142\191QR\139g\188\165vf",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("N\240`q\204\255|\b\156A\227\238",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0xd3, 0x1, 0x79, 0xc6, 0x0, 0x19, 0x3a, 0xf3, 0xe6, 0x23, 0xa4, 0xf8, 0x21, 0xe8, 0x96, 0x96, - 0x2b, 0x8a, 0x6d, 0xc6, 0xd4, 0x22, 0xc1, 0x66, 0x81, 0x1, 0x7d, 0x4b, 0xc3, 0xab, 0x96, 0x2, 0x0, - 0x18, 0x34, 0x60, 0x4d, 0x53, 0xe8, 0xff, 0xa9, 0x6f, 0x50, 0x4, 0x1e, 0xc6, 0x50, 0xfa, 0x72, 0x32, - 0x87, 0xb, 0xb7, 0x46, 0x57, 0x2, 0x29, 0xad, 0x2, 0x0, 0x16, 0x4b, 0xa7, 0x7b, 0xb3, 0x4a, 0x1e, - 0x15, 0x33, 0x3d, 0x2a, 0x54, 0x34, 0xd0, 0x2a, 0x91, 0xe4, 0xc6, 0x68, 0xfc, 0xf6, 0xf8, 0x7, 0x0, - 0x0, 0x1d, 0x17, 0xf5, 0xae, 0x41, 0xe1, 0x46, 0xe1, 0xd8, 0x6a, 0xc5, 0x93, 0x42, 0x9, 0xfe, 0x84, - 0xd8, 0xa4, 0xcd, 0x96, 0x4b, 0x24, 0xa4, 0x6c, 0x54, 0x3, 0xd4, 0x6d, 0x52, 0x76, 0x2, 0x0, 0x1b, - 0xb4, 0x53, 0x67, 0x7, 0x26, 0x52, 0xa5, 0xa2, 0xae, 0x67, 0xb2, 0xfd, 0x1d, 0x2a, 0xc5, 0x69, 0x1f, - 0x75, 0x5f, 0x26, 0xe5, 0xc9, 0x83, 0x64, 0xa9, 0xe7, 0x40, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1c, 0xb8, - 0x6c, 0x3, 0xe1, 0x32, 0x82, 0xbd, 0x84, 0x12, 0x32, 0x4e, 0x39, 0xd6, 0xaf, 0x40, 0xc5, 0x4d, 0xf1, - 0x2f, 0x58, 0x23, 0x6, 0x51, 0x30, 0xfa, 0x71, 0x14, 0xd, 0x0, 0x0, 0x7, 0xfd, 0x43, 0x37, 0x15, - 0xcb, 0x23, 0xaa, 0x0, 0x0, 0x14, 0x85, 0xd5, 0x85, 0x1a, 0xeb, 0xfe, 0xc2, 0x35, 0xdf, 0x8f, 0xf1, - 0x2d, 0x1a, 0xb1, 0x6e, 0xe9, 0xd3, 0x7b, 0x1c, 0x45, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x3a, 0xf3, 0xe6, 0x23, 0xa4, 0xf8, 0x21, 0xe8, 0x96, 0x96, 0x2b, 0x8a, 0x6d, - 0xc6, 0xd4, 0x22, 0xc1, 0x66, 0x81, 0x1, 0x7d, 0x4b, 0xc3, 0xab, 0x96}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x34, 0x60, 0x4d, 0x53, 0xe8, 0xff, 0xa9, 0x6f, 0x50, 0x4, 0x1e, 0xc6, - 0x50, 0xfa, 0x72, 0x32, 0x87, 0xb, 0xb7, 0x46, 0x57, 0x2, 0x29, 0xad}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4b, 0xa7, 0x7b, 0xb3, 0x4a, 0x1e, 0x15, 0x33, 0x3d, 0x2a, 0x54, - 0x34, 0xd0, 0x2a, 0x91, 0xe4, 0xc6, 0x68, 0xfc, 0xf6, 0xf8, 0x7}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x17, 0xf5, 0xae, 0x41, 0xe1, 0x46, 0xe1, 0xd8, 0x6a, 0xc5, - 0x93, 0x42, 0x9, 0xfe, 0x84, 0xd8, 0xa4, 0xcd, 0x96, 0x4b, - 0x24, 0xa4, 0x6c, 0x54, 0x3, 0xd4, 0x6d, 0x52, 0x76}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb4, 0x53, 0x67, 0x7, 0x26, 0x52, 0xa5, 0xa2, 0xae, 0x67, 0xb2, 0xfd, 0x1d, 0x2a, - 0xc5, 0x69, 0x1f, 0x75, 0x5f, 0x26, 0xe5, 0xc9, 0x83, 0x64, 0xa9, 0xe7, 0x40}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; +uint8_t pkt[] = {0x82, 0x98, 0x1, 0x66, 0xcc, 0x0, 0x1e, 0xe5, 0xc7, 0xd3, 0x42, 0x6d, 0xba, 0xf3, 0x57, 0xa1, 0x8b, 0x4f, 0x7b, 0x41, 0x20, 0x5e, 0x46, 0xb4, 0x2c, 0x21, 0x35, 0x79, 0xf3, 0x4, 0xa6, 0xe2, 0x6f, 0x70, 0x79, 0x83, 0x1b, 0x2, 0x0, 0xa, 0x5a, 0x99, 0x36, 0xd7, 0x28, 0xd7, 0x19, 0x89, 0x8c, 0xfc, 0x2, 0x0, 0x6, 0x55, 0x5c, 0x4e, 0xff, 0x61, 0x92, 0x0, 0x0, 0x13, 0xae, 0x5c, 0xf7, 0x77, 0xaf, 0x16, 0x94, 0x6f, 0xbf, 0x45, 0xa, 0x5b, 0xc5, 0xe, 0xc5, 0x61, 0xaf, 0xe3, 0xec, 0x1, 0x0, 0x1a, 0x12, 0xb4, 0xaa, 0x94, 0x4c, 0x31, 0x5b, 0x60, 0x40, 0x5b, 0xfd, 0x9f, 0x2c, 0x88, 0x60, 0x1b, 0xe5, 0x7f, 0x35, 0xd2, 0xc1, 0x1b, 0x40, 0x83, 0x98, 0xd4, 0x2, 0x0, 0x0, 0x0, 0x0, 0x17, 0x8d, 0x38, 0xe3, 0x83, 0x98, 0x70, 0xe0, 0xa2, 0x92, 0xe4, 0xaf, 0x56, 0x20, 0x8e, 0xbf, 0x51, 0x52, 0x8b, 0x67, 0xbc, 0xa5, 0x76, 0x66, 0x2, 0x0, 0xc, 0x4e, 0xf0, 0x60, 0x71, 0xcc, 0xff, 0x7c, 0x8, 0x9c, 0x41, 0xe3, 0xee, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xe5, 0xc7, 0xd3, 0x42, 0x6d, 0xba, 0xf3, 0x57, 0xa1, 0x8b, 0x4f, 0x7b, 0x41, 0x20, 0x5e, 0x46, 0xb4, 0x2c, 0x21, 0x35, 0x79, 0xf3, 0x4, 0xa6, 0xe2, 0x6f, 0x70, 0x79, 0x83, 0x1b}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x5a, 0x99, 0x36, 0xd7, 0x28, 0xd7, 0x19, 0x89, 0x8c, 0xfc}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x55, 0x5c, 0x4e, 0xff, 0x61, 0x92}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xae, 0x5c, 0xf7, 0x77, 0xaf, 0x16, 0x94, 0x6f, 0xbf, 0x45, 0xa, 0x5b, 0xc5, 0xe, 0xc5, 0x61, 0xaf, 0xe3, 0xec}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x12, 0xb4, 0xaa, 0x94, 0x4c, 0x31, 0x5b, 0x60, 0x40, 0x5b, 0xfd, 0x9f, 0x2c, 0x88, 0x60, 0x1b, 0xe5, 0x7f, 0x35, 0xd2, 0xc1, 0x1b, 0x40, 0x83, 0x98, 0xd4}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; uint8_t topic_filter_s5_bytes[] = {0}; lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb8, 0x6c, 0x3, 0xe1, 0x32, 0x82, 0xbd, 0x84, 0x12, 0x32, 0x4e, 0x39, 0xd6, 0xaf, - 0x40, 0xc5, 0x4d, 0xf1, 0x2f, 0x58, 0x23, 0x6, 0x51, 0x30, 0xfa, 0x71, 0x14, 0xd}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xfd, 0x43, 0x37, 0x15, 0xcb, 0x23, 0xaa}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x85, 0xd5, 0x85, 0x1a, 0xeb, 0xfe, 0xc2, 0x35, 0xdf, 0x8f, - 0xf1, 0x2d, 0x1a, 0xb1, 0x6e, 0xe9, 0xd3, 0x7b, 0x1c, 0x45}; - lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - - lwmqtt_property_t propslist[] = {}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8d, 0x38, 0xe3, 0x83, 0x98, 0x70, 0xe0, 0xa2, 0x92, 0xe4, 0xaf, 0x56, 0x20, 0x8e, 0xbf, 0x51, 0x52, 0x8b, 0x67, 0xbc, 0xa5, 0x76, 0x66}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x4e, 0xf0, 0x60, 0x71, 0xcc, 0xff, 0x7c, 0x8, 0x9c, 0x41, 0xe3, 0xee}; + lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; +lwmqtt_sub_options_t sub_opts[8]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS2; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; +sub_opts[6].qos = LWMQTT_QOS2; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = false; +sub_opts[6].no_local = false; +sub_opts[7].qos = LWMQTT_QOS0; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31174, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26316, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 2900 [("\249J\154\194\178Mb\255\165\234\213K\141%\167\ESC\151\152\176\236\214",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("7\144\f>\ACKS$|\SI",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("!",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = -// QoS2}),("v\150\SO\163x\160B\220\209E\210\170r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\198\138\161\233\v\180\STX\241\207\221\150\234\128)\130\nF\209\ETX\GSVdb",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\148y\243\207\167\176HiA\209\148mB\219\169\138\169c\r\173b\150Q\247\153}\221F",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\243\171\216\165!\EOT,g\235G\164 2\206\211-\b-D\218",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode19) { - uint8_t pkt[] = {0x82, 0x2d, 0x5e, 0xd4, 0x0, 0x10, 0xb3, 0xf3, 0xcc, 0xef, 0xbb, 0x4d, 0x24, 0xc6, 0xf1, 0x2a, - 0xe7, 0x7a, 0x5, 0x60, 0x58, 0x75, 0x2, 0x0, 0x15, 0x6b, 0x77, 0xb0, 0x7d, 0xee, 0xd, 0xc7, - 0x42, 0xbd, 0xb2, 0x44, 0xb3, 0x29, 0xb, 0x64, 0x22, 0xa, 0xe, 0x48, 0x55, 0x6c, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xb3, 0xf3, 0xcc, 0xef, 0xbb, 0x4d, 0x24, 0xc6, - 0xf1, 0x2a, 0xe7, 0x7a, 0x5, 0x60, 0x58, 0x75}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6b, 0x77, 0xb0, 0x7d, 0xee, 0xd, 0xc7, 0x42, 0xbd, 0xb2, 0x44, - 0xb3, 0x29, 0xb, 0x64, 0x22, 0xa, 0xe, 0x48, 0x55, 0x6c}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x82, 0x62, 0xc, 0x50, 0x0, 0xa, 0xdd, 0x6a, 0x47, 0xa2, 0x41, 0xd0, 0x3e, 0xd2, 0xaa, 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0x17, 0xc6, 0x8a, 0xa1, 0xe9, 0xb, 0xb4, 0x2, 0xf1, 0xcf, 0xdd, 0x96, 0xea, 0x80, 0x29, 0x82, 0xa, 0x46, 0xd1, 0x3, 0x1d, 0x56, 0x64, 0x62, 0x0, 0x0, 0x1c, 0x94, 0x79, 0xf3, 0xcf, 0xa7, 0xb0, 0x48, 0x69, 0x41, 0xd1, 0x94, 0x6d, 0x42, 0xdb, 0xa9, 0x8a, 0xa9, 0x63, 0xd, 0xad, 0x62, 0x96, 0x51, 0xf7, 0x99, 0x7d, 0xdd, 0x46, 0x1, 0x0, 0x14, 0xf3, 0xab, 0xd8, 0xa5, 0x21, 0x4, 0x2c, 0x67, 0xeb, 0x47, 0xa4, 0x20, 0x32, 0xce, 0xd3, 0x2d, 0x8, 0x2d, 0x44, 0xda, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xdd, 0x6a, 0x47, 0xa2, 0x41, 0xd0, 0x3e, 0xd2, 0xaa, 0x72}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc6, 0x8a, 0xa1, 0xe9, 0xb, 0xb4, 0x2, 0xf1, 0xcf, 0xdd, 0x96, 0xea, 0x80, 0x29, 0x82, 0xa, 0x46, 0xd1, 0x3, 0x1d, 0x56, 0x64, 0x62}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x94, 0x79, 0xf3, 0xcf, 0xa7, 0xb0, 0x48, 0x69, 0x41, 0xd1, 0x94, 0x6d, 0x42, 0xdb, 0xa9, 0x8a, 0xa9, 0x63, 0xd, 0xad, 0x62, 0x96, 0x51, 0xf7, 0x99, 0x7d, 0xdd, 0x46}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xf3, 0xab, 0xd8, 0xa5, 0x21, 0x4, 0x2c, 0x67, 0xeb, 0x47, 0xa4, 0x20, 0x32, 0xce, 0xd3, 0x2d, 0x8, 0x2d, 0x44, 0xda}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; +lwmqtt_sub_options_t sub_opts[5]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS0; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS1; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24276, 2, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3152, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 17953 [("\230\CAN\157,Q",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("W",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("1/\218k\SOH\193\234\176zfB\215\166+\DC1Rzc",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("?N\223\&4<\167\174\222\&4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS1}),("\237\v\239\243\170\&0\135\144\178*\146\194if\US\203\&9'\172\166|\128\129m\188|l\141i\164",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\238\232\v\ENQ -// \239\SOH\149\159P",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\191\217\139T!It\188\RS\EM\246\171\172\134u\234\170\168R\185\139\229\ESC",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("{\186\SIi\DLE\171\225\241\&6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("~J\231\169\143\142y\137\254m\135\249\196X\DC4J",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] + +// SubscribeRequest 17142 [("e0\211\n(1\a[m\192\250\134\179R\156:\DEL\217\&3\143Z\228\186\224\US\128\164\194\167\223",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\236^:\SYNW\249\182\&7>\191\130\SUB\146'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(":\200\140\238\238\173\241A\v\155\186\&9#m$\204\SUBe?Qr\214<3Q9O\214",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(" \139\195\231G\f\SOHqD*F\221%F\SYN\142\&7\207\252",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("@\217Q\249+\DLE\152\DLE\237\v\180[",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\207\SI\195\138W\141H2\157b?\147N\147# a%\239\181G\236[m\NULx",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\226>An\226G\185\FS",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\131\189l\133\133\tg\128\139\&9<\151y<\197o\204\221\132\&6\151\253\213\196\&3\221i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode20) { - uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x46, 0x21, 0x0, 0x5, 0xe6, 0x18, 0x9d, 0x2c, 0x51, 0x2, 0x0, 0x1, 0x57, - 0x1, 0x0, 0x12, 0x31, 0x2f, 0xda, 0x6b, 0x1, 0xc1, 0xea, 0xb0, 0x7a, 0x66, 0x42, 0xd7, 0xa6, - 0x2b, 0x11, 0x52, 0x7a, 0x63, 0x2, 0x0, 0x9, 0x3f, 0x4e, 0xdf, 0x34, 0x3c, 0xa7, 0xae, 0xde, - 0x34, 0x1, 0x0, 0x1e, 0xed, 0xb, 0xef, 0xf3, 0xaa, 0x30, 0x87, 0x90, 0xb2, 0x2a, 0x92, 0xc2, - 0x69, 0x66, 0x1f, 0xcb, 0x39, 0x27, 0xac, 0xa6, 0x7c, 0x80, 0x81, 0x6d, 0xbc, 0x7c, 0x6c, 0x8d, - 0x69, 0xa4, 0x0, 0x0, 0xa, 0xee, 0xe8, 0xb, 0x5, 0x20, 0xef, 0x1, 0x95, 0x9f, 0x50, 0x1, - 0x0, 0x17, 0xbf, 0xd9, 0x8b, 0x54, 0x21, 0x49, 0x74, 0xbc, 0x1e, 0x19, 0xf6, 0xab, 0xac, 0x86, - 0x75, 0xea, 0xaa, 0xa8, 0x52, 0xb9, 0x8b, 0xe5, 0x1b, 0x1, 0x0, 0x9, 0x7b, 0xba, 0xf, 0x69, - 0x10, 0xab, 0xe1, 0xf1, 0x36, 0x2, 0x0, 0x1, 0xa6, 0x0, 0x0, 0x0, 0x2, 0x0, 0x10, 0x7e, - 0x4a, 0xe7, 0xa9, 0x8f, 0x8e, 0x79, 0x89, 0xfe, 0x6d, 0x87, 0xf9, 0xc4, 0x58, 0x14, 0x4a, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xe6, 0x18, 0x9d, 0x2c, 0x51}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x57}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x31, 0x2f, 0xda, 0x6b, 0x1, 0xc1, 0xea, 0xb0, 0x7a, - 0x66, 0x42, 0xd7, 0xa6, 0x2b, 0x11, 0x52, 0x7a, 0x63}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3f, 0x4e, 0xdf, 0x34, 0x3c, 0xa7, 0xae, 0xde, 0x34}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xed, 0xb, 0xef, 0xf3, 0xaa, 0x30, 0x87, 0x90, 0xb2, 0x2a, - 0x92, 0xc2, 0x69, 0x66, 0x1f, 0xcb, 0x39, 0x27, 0xac, 0xa6, - 0x7c, 0x80, 0x81, 0x6d, 0xbc, 0x7c, 0x6c, 0x8d, 0x69, 0xa4}; - lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xee, 0xe8, 0xb, 0x5, 0x20, 0xef, 0x1, 0x95, 0x9f, 0x50}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbf, 0xd9, 0x8b, 0x54, 0x21, 0x49, 0x74, 0xbc, 0x1e, 0x19, 0xf6, 0xab, - 0xac, 0x86, 0x75, 0xea, 0xaa, 0xa8, 0x52, 0xb9, 0x8b, 0xe5, 0x1b}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7b, 0xba, 0xf, 0x69, 0x10, 0xab, 0xe1, 0xf1, 0x36}; - lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa6}; - lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0}; - lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x7e, 0x4a, 0xe7, 0xa9, 0x8f, 0x8e, 0x79, 0x89, - 0xfe, 0x6d, 0x87, 0xf9, 0xc4, 0x58, 0x14, 0x4a}; - lwmqtt_string_t topic_filter_s10 = {16, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x82, 0xbe, 0x1, 0x42, 0xf6, 0x0, 0x1e, 0x65, 0x30, 0xd3, 0xa, 0x28, 0x31, 0x7, 0x5b, 0x6d, 0xc0, 0xfa, 0x86, 0xb3, 0x52, 0x9c, 0x3a, 0x7f, 0xd9, 0x33, 0x8f, 0x5a, 0xe4, 0xba, 0xe0, 0x1f, 0x80, 0xa4, 0xc2, 0xa7, 0xdf, 0x2, 0x0, 0xe, 0xec, 0x5e, 0x3a, 0x16, 0x57, 0xf9, 0xb6, 0x37, 0x3e, 0xbf, 0x82, 0x1a, 0x92, 0x27, 0x0, 0x0, 0x1c, 0x3a, 0xc8, 0x8c, 0xee, 0xee, 0xad, 0xf1, 0x41, 0xb, 0x9b, 0xba, 0x39, 0x23, 0x6d, 0x24, 0xcc, 0x1a, 0x65, 0x3f, 0x51, 0x72, 0xd6, 0x3c, 0x33, 0x51, 0x39, 0x4f, 0xd6, 0x2, 0x0, 0x13, 0x20, 0x8b, 0xc3, 0xe7, 0x47, 0xc, 0x1, 0x71, 0x44, 0x2a, 0x46, 0xdd, 0x25, 0x46, 0x16, 0x8e, 0x37, 0xcf, 0xfc, 0x0, 0x0, 0xc, 0x40, 0xd9, 0x51, 0xf9, 0x2b, 0x10, 0x98, 0x10, 0xed, 0xb, 0xb4, 0x5b, 0x1, 0x0, 0x1a, 0xcf, 0xf, 0xc3, 0x8a, 0x57, 0x8d, 0x48, 0x32, 0x9d, 0x62, 0x3f, 0x93, 0x4e, 0x93, 0x23, 0x20, 0x61, 0x25, 0xef, 0xb5, 0x47, 0xec, 0x5b, 0x6d, 0x0, 0x78, 0x1, 0x0, 0x8, 0xe2, 0x3e, 0x41, 0x6e, 0xe2, 0x47, 0xb9, 0x1c, 0x0, 0x0, 0x1b, 0x83, 0xbd, 0x6c, 0x85, 0x85, 0x9, 0x67, 0x80, 0x8b, 0x39, 0x3c, 0x97, 0x79, 0x3c, 0xc5, 0x6f, 0xcc, 0xdd, 0x84, 0x36, 0x97, 0xfd, 0xd5, 0xc4, 0x33, 0xdd, 0x69, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x65, 0x30, 0xd3, 0xa, 0x28, 0x31, 0x7, 0x5b, 0x6d, 0xc0, 0xfa, 0x86, 0xb3, 0x52, 0x9c, 0x3a, 0x7f, 0xd9, 0x33, 0x8f, 0x5a, 0xe4, 0xba, 0xe0, 0x1f, 0x80, 0xa4, 0xc2, 0xa7, 0xdf}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xec, 0x5e, 0x3a, 0x16, 0x57, 0xf9, 0xb6, 0x37, 0x3e, 0xbf, 0x82, 0x1a, 0x92, 0x27}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x3a, 0xc8, 0x8c, 0xee, 0xee, 0xad, 0xf1, 0x41, 0xb, 0x9b, 0xba, 0x39, 0x23, 0x6d, 0x24, 0xcc, 0x1a, 0x65, 0x3f, 0x51, 0x72, 0xd6, 0x3c, 0x33, 0x51, 0x39, 0x4f, 0xd6}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x20, 0x8b, 0xc3, 0xe7, 0x47, 0xc, 0x1, 0x71, 0x44, 0x2a, 0x46, 0xdd, 0x25, 0x46, 0x16, 0x8e, 0x37, 0xcf, 0xfc}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x40, 0xd9, 0x51, 0xf9, 0x2b, 0x10, 0x98, 0x10, 0xed, 0xb, 0xb4, 0x5b}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xcf, 0xf, 0xc3, 0x8a, 0x57, 0x8d, 0x48, 0x32, 0x9d, 0x62, 0x3f, 0x93, 0x4e, 0x93, 0x23, 0x20, 0x61, 0x25, 0xef, 0xb5, 0x47, 0xec, 0x5b, 0x6d, 0x0, 0x78}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xe2, 0x3e, 0x41, 0x6e, 0xe2, 0x47, 0xb9, 0x1c}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x83, 0xbd, 0x6c, 0x85, 0x85, 0x9, 0x67, 0x80, 0x8b, 0x39, 0x3c, 0x97, 0x79, 0x3c, 0xc5, 0x6f, 0xcc, 0xdd, 0x84, 0x36, 0x97, 0xfd, 0xd5, 0xc4, 0x33, 0xdd, 0x69}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; +lwmqtt_sub_options_t sub_opts[8]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS0; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS2; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS0; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS1; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS1; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; +sub_opts[6].qos = LWMQTT_QOS0; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = false; +sub_opts[6].no_local = false; +sub_opts[7].qos = LWMQTT_QOS1; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17953, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17142, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 26518 [("\NULJ\205v\253\154",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("j\182X\235\201r\170\214\STX\134\241\201\150\253\226\SYN",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("ap\232$>@\178\148\vR\208\227\232\190\&0*N>\US\202\188",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("+b\142\ETB/\213xA\202y\175i)\183\171\142Yw_\228\&2\170\156 \129",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("A\187\CAN\243\184\211b\170\231tK\171\170R\216Gw\149i\252\163\&4U\209\180\245\226\249-\209\158\&5\245\NUL\234\DC10\214",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\218\246\226&[\153t\186\250\SI\199\252\144\201\139\191U?\SI\207?Q",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\242x\138*\224\132\237\229\218\231\&4\189|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DLE\EOT\229e\SO\165\202\190",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] + +// SubscribeRequest 26425 [("\145\NAK7\199",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\GSs0\DC1\171V\137\&9\159w\132\ESC\169\234\155\213",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\\\142Z\247\242sCn\US\191q!\148^!i\196\133\n\205\140Ar\136\133",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\235e\220\167>\DLE*\133\128\145\180\DC3t\129\&8",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\218\188\137$}\EOT4\238\239\232|~\185\169R\141\196\189R\151",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\173\US{0hp\194\172Up\210?\133\204\227\&0\160\137\183\158\212\217z\228\208\130\164\213\ACK\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\217\199\165J\206\133\254\160,k\ETB\144\186\EOT\ETXKN=\160\SYN\200K\f\208\155%\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\DEL\210\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\211\225\228\234\188g\203A\222\NUL!\191\194\&0\194\&0\144@(A\232\&8\176N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode22) { - uint8_t pkt[] = {0x82, 0x7f, 0x5b, 0xe3, 0x0, 0xc, 0x3a, 0x5a, 0xfd, 0xb3, 0xf6, 0x69, 0x9, 0x43, 0x14, 0xe1, 0xf4, - 0x6f, 0x0, 0x0, 0x11, 0x90, 0xf2, 0xf2, 0x38, 0xdf, 0x89, 0x70, 0x4c, 0x72, 0x43, 0xa9, 0xe9, 0x8e, - 0xcd, 0x3b, 0x50, 0xe3, 0x1, 0x0, 0x2, 0x5c, 0x9, 0x0, 0x0, 0x1b, 0x99, 0x24, 0xd1, 0x73, 0xce, - 0x76, 0x3e, 0x69, 0xfc, 0xa3, 0x34, 0x55, 0xd1, 0xb4, 0xf5, 0xe2, 0xf9, 0x2d, 0xd1, 0x9e, 0x35, 0xf5, - 0x0, 0xea, 0x11, 0x30, 0xd6, 0x1, 0x0, 0x0, 0x1, 0x0, 0x16, 0xda, 0xf6, 0xe2, 0x26, 0x5b, 0x99, - 0x74, 0xba, 0xfa, 0xf, 0xc7, 0xfc, 0x90, 0xc9, 0x8b, 0xbf, 0x55, 0x3f, 0xf, 0xcf, 0x3f, 0x51, 0x1, - 0x0, 0xd, 0xf2, 0x78, 0x8a, 0x2a, 0xe0, 0x84, 0xed, 0xe5, 0xda, 0xe7, 0x34, 0xbd, 0x7c, 0x2, 0x0, - 0x8, 0x10, 0x4, 0xe5, 0x65, 0xe, 0xa5, 0xca, 0xbe, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x3a, 0x5a, 0xfd, 0xb3, 0xf6, 0x69, 0x9, 0x43, 0x14, 0xe1, 0xf4, 0x6f}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x90, 0xf2, 0xf2, 0x38, 0xdf, 0x89, 0x70, 0x4c, 0x72, - 0x43, 0xa9, 0xe9, 0x8e, 0xcd, 0x3b, 0x50, 0xe3}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5c, 0x9}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x99, 0x24, 0xd1, 0x73, 0xce, 0x76, 0x3e, 0x69, 0xfc, 0xa3, 0x34, 0x55, 0xd1, 0xb4, - 0xf5, 0xe2, 0xf9, 0x2d, 0xd1, 0x9e, 0x35, 0xf5, 0x0, 0xea, 0x11, 0x30, 0xd6}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xda, 0xf6, 0xe2, 0x26, 0x5b, 0x99, 0x74, 0xba, 0xfa, 0xf, 0xc7, - 0xfc, 0x90, 0xc9, 0x8b, 0xbf, 0x55, 0x3f, 0xf, 0xcf, 0x3f, 0x51}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf2, 0x78, 0x8a, 0x2a, 0xe0, 0x84, 0xed, 0xe5, 0xda, 0xe7, 0x34, 0xbd, 0x7c}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x10, 0x4, 0xe5, 0x65, 0xe, 0xa5, 0xca, 0xbe}; - lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x82, 0xc1, 0x1, 0x67, 0x39, 0x0, 0x4, 0x91, 0x15, 0x37, 0xc7, 0x1, 0x0, 0x10, 0x1d, 0x73, 0x30, 0x11, 0xab, 0x56, 0x89, 0x39, 0x9f, 0x77, 0x84, 0x1b, 0xa9, 0xea, 0x9b, 0xd5, 0x2, 0x0, 0x19, 0x5c, 0x8e, 0x5a, 0xf7, 0xf2, 0x73, 0x43, 0x6e, 0x1f, 0xbf, 0x71, 0x21, 0x94, 0x5e, 0x21, 0x69, 0xc4, 0x85, 0xa, 0xcd, 0x8c, 0x41, 0x72, 0x88, 0x85, 0x0, 0x0, 0xf, 0xeb, 0x65, 0xdc, 0xa7, 0x3e, 0x10, 0x2a, 0x85, 0x80, 0x91, 0xb4, 0x13, 0x74, 0x81, 0x38, 0x1, 0x0, 0x14, 0xda, 0xbc, 0x89, 0x24, 0x7d, 0x4, 0x34, 0xee, 0xef, 0xe8, 0x7c, 0x7e, 0xb9, 0xa9, 0x52, 0x8d, 0xc4, 0xbd, 0x52, 0x97, 0x0, 0x0, 0x1e, 0xad, 0x1f, 0x7b, 0x30, 0x68, 0x70, 0xc2, 0xac, 0x55, 0x70, 0xd2, 0x3f, 0x85, 0xcc, 0xe3, 0x30, 0xa0, 0x89, 0xb7, 0x9e, 0xd4, 0xd9, 0x7a, 0xe4, 0xd0, 0x82, 0xa4, 0xd5, 0x6, 0xd2, 0x0, 0x0, 0x1b, 0xd9, 0xc7, 0xa5, 0x4a, 0xce, 0x85, 0xfe, 0xa0, 0x2c, 0x6b, 0x17, 0x90, 0xba, 0x4, 0x3, 0x4b, 0x4e, 0x3d, 0xa0, 0x16, 0xc8, 0x4b, 0xc, 0xd0, 0x9b, 0x25, 0xb4, 0x1, 0x0, 0x3, 0x7f, 0xd2, 0xba, 0x2, 0x0, 0x18, 0xd3, 0xe1, 0xe4, 0xea, 0xbc, 0x67, 0xcb, 0x41, 0xde, 0x0, 0x21, 0xbf, 0xc2, 0x30, 0xc2, 0x30, 0x90, 0x40, 0x28, 0x41, 0xe8, 0x38, 0xb0, 0x4e, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x91, 0x15, 0x37, 0xc7}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x1d, 0x73, 0x30, 0x11, 0xab, 0x56, 0x89, 0x39, 0x9f, 0x77, 0x84, 0x1b, 0xa9, 0xea, 0x9b, 0xd5}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5c, 0x8e, 0x5a, 0xf7, 0xf2, 0x73, 0x43, 0x6e, 0x1f, 0xbf, 0x71, 0x21, 0x94, 0x5e, 0x21, 0x69, 0xc4, 0x85, 0xa, 0xcd, 0x8c, 0x41, 0x72, 0x88, 0x85}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xeb, 0x65, 0xdc, 0xa7, 0x3e, 0x10, 0x2a, 0x85, 0x80, 0x91, 0xb4, 0x13, 0x74, 0x81, 0x38}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xda, 0xbc, 0x89, 0x24, 0x7d, 0x4, 0x34, 0xee, 0xef, 0xe8, 0x7c, 0x7e, 0xb9, 0xa9, 0x52, 0x8d, 0xc4, 0xbd, 0x52, 0x97}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xad, 0x1f, 0x7b, 0x30, 0x68, 0x70, 0xc2, 0xac, 0x55, 0x70, 0xd2, 0x3f, 0x85, 0xcc, 0xe3, 0x30, 0xa0, 0x89, 0xb7, 0x9e, 0xd4, 0xd9, 0x7a, 0xe4, 0xd0, 0x82, 0xa4, 0xd5, 0x6, 0xd2}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xd9, 0xc7, 0xa5, 0x4a, 0xce, 0x85, 0xfe, 0xa0, 0x2c, 0x6b, 0x17, 0x90, 0xba, 0x4, 0x3, 0x4b, 0x4e, 0x3d, 0xa0, 0x16, 0xc8, 0x4b, 0xc, 0xd0, 0x9b, 0x25, 0xb4}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x7f, 0xd2, 0xba}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd3, 0xe1, 0xe4, 0xea, 0xbc, 0x67, 0xcb, 0x41, 0xde, 0x0, 0x21, 0xbf, 0xc2, 0x30, 0xc2, 0x30, 0x90, 0x40, 0x28, 0x41, 0xe8, 0x38, 0xb0, 0x4e}; + lwmqtt_string_t topic_filter_s8 = {24, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; +lwmqtt_sub_options_t sub_opts[9]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS0; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; +sub_opts[6].qos = LWMQTT_QOS1; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = false; +sub_opts[6].no_local = false; +sub_opts[7].qos = LWMQTT_QOS2; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = false; +sub_opts[8].qos = LWMQTT_QOS1; +sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[8].retain_as_published = false; +sub_opts[8].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23523, 8, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26425, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 10563 [("\168\239",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("b\DC2\247\191\181;_\144\ETX9R\f\212\n*;",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("M\245\139sC\176\233\&4\SI\136\188%\219\r\ENQ\SOS\142%*R8\171\v\149\180\155",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("F\143\188\229\139~\201\n\GSVs\v",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("M\203\202\148\227\243\227S\239h\b\165\&3\230\DC4B\DEL",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\200\DC1P\EOT&",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\200k\212;\251\194\248\153",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("s\233\DEL\210\244\r\226\142\130\195R",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\228\164;\SUB'C\EM\168\199Z\168Yb\SO\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\210|7\DC3\f}\178\DC4\141\DC2\204\NUL\231\224\SOH|}",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] + +// SubscribeRequest 17320 [("\144\175\&0\194y\215$\SO\132\\>\f\225\180\212\vV\188\EOTTx\215",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ETX",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] + +// SubscribeRequest 9349 [("D\161",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\147\GS\140\221\194\249\&2H$\160\&9Z\247\201\&7\235\133\210M{r\146uJY\ESC",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\234\216\197\146-.:|#\186\SUB}\134",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("]/.\208\EOT\195\224Ig\238x\219\254 \178",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\168\232\NAK\137\231\230}~\178]6\246",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("V\129f)\206Y\b\216\222\223*\132k\193\163\213\&2)",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\249\201\EMx\233\208\197*\228\149\179\213\158,\166q\253>\US",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\140\252\NAKZ\ENQ\201\234\204\151\235\251\198\234\190\DC2\NULi\211\201",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x8a, 0x1, 0x76, 0xf3, 0x0, 0x2, 0x25, 0xad, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0xc5, - 0x1, 0x0, 0x8, 0x75, 0xa7, 0x5a, 0x5, 0x0, 0xf6, 0x46, 0xba, 0x1, 0x0, 0x6, 0x24, 0x47, - 0x77, 0xfc, 0x4c, 0x65, 0x2, 0x0, 0x15, 0xc3, 0xb4, 0x99, 0xbd, 0xdd, 0x5f, 0x69, 0x70, 0xc6, - 0x93, 0xb, 0x19, 0xb6, 0xd7, 0x1e, 0xe1, 0x44, 0xad, 0x3d, 0x6f, 0x4c, 0x0, 0x0, 0xe, 0xd8, - 0x79, 0xa, 0xcf, 0x75, 0x53, 0x35, 0x9d, 0x19, 0x16, 0xb6, 0xa9, 0xbc, 0x9a, 0x0, 0x0, 0xe, - 0xeb, 0x67, 0xa4, 0xf7, 0x70, 0x1a, 0x7e, 0x44, 0xdb, 0x21, 0x3a, 0x1, 0x5f, 0xc0, 0x2, 0x0, - 0xb, 0xe2, 0x28, 0xc8, 0x37, 0x46, 0x83, 0xff, 0xdf, 0x71, 0xb2, 0x3b, 0x1, 0x0, 0x19, 0xe4, - 0xda, 0xc6, 0xb6, 0xa8, 0x6a, 0x26, 0x12, 0x79, 0xf9, 0x3e, 0x84, 0x5c, 0x3e, 0xc, 0xe1, 0xb4, - 0xd4, 0xb, 0x56, 0xbc, 0x4, 0x54, 0x78, 0xd7, 0x0, 0x0, 0x1, 0x3, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x25, 0xad}; +uint8_t pkt[] = {0x82, 0x99, 0x1, 0x24, 0x85, 0x0, 0x2, 0x44, 0xa1, 0x0, 0x0, 0x1a, 0x93, 0x1d, 0x8c, 0xdd, 0xc2, 0xf9, 0x32, 0x48, 0x24, 0xa0, 0x39, 0x5a, 0xf7, 0xc9, 0x37, 0xeb, 0x85, 0xd2, 0x4d, 0x7b, 0x72, 0x92, 0x75, 0x4a, 0x59, 0x1b, 0x1, 0x0, 0xd, 0xea, 0xd8, 0xc5, 0x92, 0x2d, 0x2e, 0x3a, 0x7c, 0x23, 0xba, 0x1a, 0x7d, 0x86, 0x2, 0x0, 0x0, 0x2, 0x0, 0xf, 0x5d, 0x2f, 0x2e, 0xd0, 0x4, 0xc3, 0xe0, 0x49, 0x67, 0xee, 0x78, 0xdb, 0xfe, 0x20, 0xb2, 0x2, 0x0, 0xc, 0xa8, 0xe8, 0x15, 0x89, 0xe7, 0xe6, 0x7d, 0x7e, 0xb2, 0x5d, 0x36, 0xf6, 0x2, 0x0, 0x12, 0x56, 0x81, 0x66, 0x29, 0xce, 0x59, 0x8, 0xd8, 0xde, 0xdf, 0x2a, 0x84, 0x6b, 0xc1, 0xa3, 0xd5, 0x32, 0x29, 0x0, 0x0, 0x13, 0xf9, 0xc9, 0x19, 0x78, 0xe9, 0xd0, 0xc5, 0x2a, 0xe4, 0x95, 0xb3, 0xd5, 0x9e, 0x2c, 0xa6, 0x71, 0xfd, 0x3e, 0x1f, 0x2, 0x0, 0x13, 0x8c, 0xfc, 0x15, 0x5a, 0x5, 0xc9, 0xea, 0xcc, 0x97, 0xeb, 0xfb, 0xc6, 0xea, 0xbe, 0x12, 0x0, 0x69, 0xd3, 0xc9, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x44, 0xa1}; lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc5}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x75, 0xa7, 0x5a, 0x5, 0x0, 0xf6, 0x46, 0xba}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x24, 0x47, 0x77, 0xfc, 0x4c, 0x65}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc3, 0xb4, 0x99, 0xbd, 0xdd, 0x5f, 0x69, 0x70, 0xc6, 0x93, 0xb, - 0x19, 0xb6, 0xd7, 0x1e, 0xe1, 0x44, 0xad, 0x3d, 0x6f, 0x4c}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xd8, 0x79, 0xa, 0xcf, 0x75, 0x53, 0x35, 0x9d, 0x19, 0x16, 0xb6, 0xa9, 0xbc, 0x9a}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xeb, 0x67, 0xa4, 0xf7, 0x70, 0x1a, 0x7e, 0x44, 0xdb, 0x21, 0x3a, 0x1, 0x5f, 0xc0}; - lwmqtt_string_t topic_filter_s7 = {14, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe2, 0x28, 0xc8, 0x37, 0x46, 0x83, 0xff, 0xdf, 0x71, 0xb2, 0x3b}; - lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe4, 0xda, 0xc6, 0xb6, 0xa8, 0x6a, 0x26, 0x12, 0x79, 0xf9, 0x3e, 0x84, 0x5c, - 0x3e, 0xc, 0xe1, 0xb4, 0xd4, 0xb, 0x56, 0xbc, 0x4, 0x54, 0x78, 0xd7}; - lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x3}; - lwmqtt_string_t topic_filter_s10 = {1, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; - - lwmqtt_property_t propslist[] = {}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x93, 0x1d, 0x8c, 0xdd, 0xc2, 0xf9, 0x32, 0x48, 0x24, 0xa0, 0x39, 0x5a, 0xf7, 0xc9, 0x37, 0xeb, 0x85, 0xd2, 0x4d, 0x7b, 0x72, 0x92, 0x75, 0x4a, 0x59, 0x1b}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xea, 0xd8, 0xc5, 0x92, 0x2d, 0x2e, 0x3a, 0x7c, 0x23, 0xba, 0x1a, 0x7d, 0x86}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x5d, 0x2f, 0x2e, 0xd0, 0x4, 0xc3, 0xe0, 0x49, 0x67, 0xee, 0x78, 0xdb, 0xfe, 0x20, 0xb2}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa8, 0xe8, 0x15, 0x89, 0xe7, 0xe6, 0x7d, 0x7e, 0xb2, 0x5d, 0x36, 0xf6}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x56, 0x81, 0x66, 0x29, 0xce, 0x59, 0x8, 0xd8, 0xde, 0xdf, 0x2a, 0x84, 0x6b, 0xc1, 0xa3, 0xd5, 0x32, 0x29}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf9, 0xc9, 0x19, 0x78, 0xe9, 0xd0, 0xc5, 0x2a, 0xe4, 0x95, 0xb3, 0xd5, 0x9e, 0x2c, 0xa6, 0x71, 0xfd, 0x3e, 0x1f}; + lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x8c, 0xfc, 0x15, 0x5a, 0x5, 0xc9, 0xea, 0xcc, 0x97, 0xeb, 0xfb, 0xc6, 0xea, 0xbe, 0x12, 0x0, 0x69, 0xd3, 0xc9}; + lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; +lwmqtt_sub_options_t sub_opts[9]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS2; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS2; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS2; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS2; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; +sub_opts[6].qos = LWMQTT_QOS0; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = false; +sub_opts[6].no_local = false; +sub_opts[7].qos = LWMQTT_QOS2; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = false; +sub_opts[8].qos = LWMQTT_QOS1; +sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[8].retain_as_published = false; +sub_opts[8].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30451, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9349, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 5141 [("\173\ff",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS1}),("Jm\241\231Tp\203~\220z\153^\194\DC4\227'q\242\ESC1\177\192Q\185\NAK\ETX\139",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\227\229\242\245\173@\183\167\170\152\186\254\253<\SYN\223>|\242\237\137P8",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(";\204",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\153H\234.\165\EM\135u#\SO\b\141\141\185I\210.\241\136\224",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\186\197\SYN\130",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\251y\216\143Q\220\DC1\248\132\241\NUL\SI\DC3\b\230z\EM\166|",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\148xP\RSO\SI",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] + +// SubscribeRequest 26963 [("\222\194M\DEL\152\197,\190??\b\237\DELK\244.\212\133\159\247{\238\US7[\151\DC1",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\171\141\177\173\n\EM\129,\143\DC4\167\162\191<,",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("{\146\138\133s9`\172\155`\205#\CAN\160\193h\188\DC3K\205\253<\255g\DC4c\246",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("'\170\221]\SIq\189\192\ESCH\r5\163\154D",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0x82, 0x1, 0x14, 0x15, 0x0, 0x3, 0xad, 0xc, 0x66, 0x1, 0x0, 0x1b, 0x4a, 0x6d, 0xf1, 0xe7, - 0x54, 0x70, 0xcb, 0x7e, 0xdc, 0x7a, 0x99, 0x5e, 0xc2, 0x14, 0xe3, 0x27, 0x71, 0xf2, 0x1b, 0x31, 0xb1, - 0xc0, 0x51, 0xb9, 0x15, 0x3, 0x8b, 0x1, 0x0, 0x17, 0xe3, 0xe5, 0xf2, 0xf5, 0xad, 0x40, 0xb7, 0xa7, - 0xaa, 0x98, 0xba, 0xfe, 0xfd, 0x3c, 0x16, 0xdf, 0x3e, 0x7c, 0xf2, 0xed, 0x89, 0x50, 0x38, 0x0, 0x0, - 0x2, 0x3b, 0xcc, 0x2, 0x0, 0x14, 0x99, 0x48, 0xea, 0x2e, 0xa5, 0x19, 0x87, 0x75, 0x23, 0xe, 0x8, - 0x8d, 0x8d, 0xb9, 0x49, 0xd2, 0x2e, 0xf1, 0x88, 0xe0, 0x2, 0x0, 0x4, 0xba, 0xc5, 0x16, 0x82, 0x1, - 0x0, 0x13, 0xfb, 0x79, 0xd8, 0x8f, 0x51, 0xdc, 0x11, 0xf8, 0x84, 0xf1, 0x0, 0xf, 0x13, 0x8, 0xe6, - 0x7a, 0x19, 0xa6, 0x7c, 0x2, 0x0, 0x6, 0x94, 0x78, 0x50, 0x1e, 0x4f, 0xf, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xad, 0xc, 0x66}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4a, 0x6d, 0xf1, 0xe7, 0x54, 0x70, 0xcb, 0x7e, 0xdc, 0x7a, 0x99, 0x5e, 0xc2, 0x14, - 0xe3, 0x27, 0x71, 0xf2, 0x1b, 0x31, 0xb1, 0xc0, 0x51, 0xb9, 0x15, 0x3, 0x8b}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe3, 0xe5, 0xf2, 0xf5, 0xad, 0x40, 0xb7, 0xa7, 0xaa, 0x98, 0xba, 0xfe, - 0xfd, 0x3c, 0x16, 0xdf, 0x3e, 0x7c, 0xf2, 0xed, 0x89, 0x50, 0x38}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3b, 0xcc}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x99, 0x48, 0xea, 0x2e, 0xa5, 0x19, 0x87, 0x75, 0x23, 0xe, - 0x8, 0x8d, 0x8d, 0xb9, 0x49, 0xd2, 0x2e, 0xf1, 0x88, 0xe0}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xba, 0xc5, 0x16, 0x82}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xfb, 0x79, 0xd8, 0x8f, 0x51, 0xdc, 0x11, 0xf8, 0x84, 0xf1, - 0x0, 0xf, 0x13, 0x8, 0xe6, 0x7a, 0x19, 0xa6, 0x7c}; - lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x94, 0x78, 0x50, 0x1e, 0x4f, 0xf}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x82, 0x66, 0x69, 0x53, 0x0, 0x1b, 0xde, 0xc2, 0x4d, 0x7f, 0x98, 0xc5, 0x2c, 0xbe, 0x3f, 0x3f, 0x8, 0xed, 0x7f, 0x4b, 0xf4, 0x2e, 0xd4, 0x85, 0x9f, 0xf7, 0x7b, 0xee, 0x1f, 0x37, 0x5b, 0x97, 0x11, 0x2, 0x0, 0xf, 0xab, 0x8d, 0xb1, 0xad, 0xa, 0x19, 0x81, 0x2c, 0x8f, 0x14, 0xa7, 0xa2, 0xbf, 0x3c, 0x2c, 0x2, 0x0, 0x1b, 0x7b, 0x92, 0x8a, 0x85, 0x73, 0x39, 0x60, 0xac, 0x9b, 0x60, 0xcd, 0x23, 0x18, 0xa0, 0xc1, 0x68, 0xbc, 0x13, 0x4b, 0xcd, 0xfd, 0x3c, 0xff, 0x67, 0x14, 0x63, 0xf6, 0x1, 0x0, 0xf, 0x27, 0xaa, 0xdd, 0x5d, 0xf, 0x71, 0xbd, 0xc0, 0x1b, 0x48, 0xd, 0x35, 0xa3, 0x9a, 0x44, 0x1, 0x0, 0x1, 0x69, 0x2}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xde, 0xc2, 0x4d, 0x7f, 0x98, 0xc5, 0x2c, 0xbe, 0x3f, 0x3f, 0x8, 0xed, 0x7f, 0x4b, 0xf4, 0x2e, 0xd4, 0x85, 0x9f, 0xf7, 0x7b, 0xee, 0x1f, 0x37, 0x5b, 0x97, 0x11}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xab, 0x8d, 0xb1, 0xad, 0xa, 0x19, 0x81, 0x2c, 0x8f, 0x14, 0xa7, 0xa2, 0xbf, 0x3c, 0x2c}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x7b, 0x92, 0x8a, 0x85, 0x73, 0x39, 0x60, 0xac, 0x9b, 0x60, 0xcd, 0x23, 0x18, 0xa0, 0xc1, 0x68, 0xbc, 0x13, 0x4b, 0xcd, 0xfd, 0x3c, 0xff, 0x67, 0x14, 0x63, 0xf6}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x27, 0xaa, 0xdd, 0x5d, 0xf, 0x71, 0xbd, 0xc0, 0x1b, 0x48, 0xd, 0x35, 0xa3, 0x9a, 0x44}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x69}; + lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; +lwmqtt_sub_options_t sub_opts[5]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS2; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5141, 8, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26963, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 8922 [("8[\204Te\235\185\154\136\vI\148\223",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("/\242O\211\r\131\245\210\240\128\SI/@",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\149\136\194\189\ESC\130\154\195\138b\146\NUL\181d\RS\a\216\241\FS\252\144\&3\185$K",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] + +// SubscribeRequest 21870 [("@\DC1\168\&4q^o\128\193 R\129Q\n\SO \156\223\234\178\252\158\217=",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\v\202\226\206G",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\159W\DC30=\CAN%",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\138O\209\212z\EOTK",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("3\240\148o\129\n\158\&8\NULd\193\134\132\129z\132z\219`{\235W\144_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x3e, 0x22, 0xda, 0x0, 0xd, 0x38, 0x5b, 0xcc, 0x54, 0x65, 0xeb, 0xb9, 0x9a, 0x88, 0xb, - 0x49, 0x94, 0xdf, 0x0, 0x0, 0xd, 0x2f, 0xf2, 0x4f, 0xd3, 0xd, 0x83, 0xf5, 0xd2, 0xf0, 0x80, - 0xf, 0x2f, 0x40, 0x1, 0x0, 0x19, 0x95, 0x88, 0xc2, 0xbd, 0x1b, 0x82, 0x9a, 0xc3, 0x8a, 0x62, - 0x92, 0x0, 0xb5, 0x64, 0x1e, 0x7, 0xd8, 0xf1, 0x1c, 0xfc, 0x90, 0x33, 0xb9, 0x24, 0x4b, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x38, 0x5b, 0xcc, 0x54, 0x65, 0xeb, 0xb9, 0x9a, 0x88, 0xb, 0x49, 0x94, 0xdf}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2f, 0xf2, 0x4f, 0xd3, 0xd, 0x83, 0xf5, 0xd2, 0xf0, 0x80, 0xf, 0x2f, 0x40}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x95, 0x88, 0xc2, 0xbd, 0x1b, 0x82, 0x9a, 0xc3, 0x8a, 0x62, 0x92, 0x0, 0xb5, - 0x64, 0x1e, 0x7, 0xd8, 0xf1, 0x1c, 0xfc, 0x90, 0x33, 0xb9, 0x24, 0x4b}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x82, 0x54, 0x55, 0x6e, 0x0, 0x18, 0x40, 0x11, 0xa8, 0x34, 0x71, 0x5e, 0x6f, 0x80, 0xc1, 0x20, 0x52, 0x81, 0x51, 0xa, 0xe, 0x20, 0x9c, 0xdf, 0xea, 0xb2, 0xfc, 0x9e, 0xd9, 0x3d, 0x2, 0x0, 0x5, 0xb, 0xca, 0xe2, 0xce, 0x47, 0x2, 0x0, 0x7, 0x9f, 0x57, 0x13, 0x30, 0x3d, 0x18, 0x25, 0x2, 0x0, 0x7, 0x8a, 0x4f, 0xd1, 0xd4, 0x7a, 0x4, 0x4b, 0x2, 0x0, 0x18, 0x33, 0xf0, 0x94, 0x6f, 0x81, 0xa, 0x9e, 0x38, 0x0, 0x64, 0xc1, 0x86, 0x84, 0x81, 0x7a, 0x84, 0x7a, 0xdb, 0x60, 0x7b, 0xeb, 0x57, 0x90, 0x5f, 0x2}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x40, 0x11, 0xa8, 0x34, 0x71, 0x5e, 0x6f, 0x80, 0xc1, 0x20, 0x52, 0x81, 0x51, 0xa, 0xe, 0x20, 0x9c, 0xdf, 0xea, 0xb2, 0xfc, 0x9e, 0xd9, 0x3d}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb, 0xca, 0xe2, 0xce, 0x47}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x9f, 0x57, 0x13, 0x30, 0x3d, 0x18, 0x25}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8a, 0x4f, 0xd1, 0xd4, 0x7a, 0x4, 0x4b}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x33, 0xf0, 0x94, 0x6f, 0x81, 0xa, 0x9e, 0x38, 0x0, 0x64, 0xc1, 0x86, 0x84, 0x81, 0x7a, 0x84, 0x7a, 0xdb, 0x60, 0x7b, 0xeb, 0x57, 0x90, 0x5f}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; +lwmqtt_sub_options_t sub_opts[5]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS2; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS2; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS2; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8922, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21870, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 10052 -// [("\197\182\247\NAK\225g\156\RSB\176\131>\210\163+gM\b]f\247\229C\139\206\250\&7\200N(",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\244\237N\DC2\r\SIT\223\DC2\235\166\252\&3\164\242J2\185\ETB$\209#O\222",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SUBP\205",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\SO=\180\165\216\210V\143\215h\230\182\212\148\199\230\SUBO\128\ENQX\163\200\244<\DC2g9P\180",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("3z\NUL6\210\254\222.\146\237\247\DEL*_\251",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("j\196\220\190\210\153\196\134\169\GS\DC2\208m6\155{i\204i=Ln9\201O_\NAK#-\177",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("v\NUL\235\199\138\128\&3\DEL\202Q",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\239\216H\UStK\244\237\FSl#\234]\220Ll",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] + +// SubscribeRequest 6154 [("\DEL\244\227\193\248L\DC2\249\249h\217u_u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\146\226X\227zoKZ\172C$\DC1>",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\USpH\130\\\EOT\ESCo\r\205\249d\215\243\246\EM\243\\Oy\195\147\&9<\249A\230\&5\ETX.",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\186Uah\251?\236m\133\v\215",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\f\193y\211\&9\163\188\237\SYN8\198\DC34\130\218\203\&3~\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\255+\137v\184\215Pix\170R\252{l\130\254\212yQ\223@l\SI\130i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\137\236\&92",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("{\"\202\130",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\221u\223w",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\249\137\219n\139\f\238\208lT0\201\209\SI\135\237\182\212\185\190\244\220\177\180B\229",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\\([*\EOTn\145\175\236G\176\&8\240\STX\170\SUB[c",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0xb8, 0x1, 0x27, 0x44, 0x0, 0x1e, 0xc5, 0xb6, 0xf7, 0x15, 0xe1, 0x67, 0x9c, 0x1e, 0x42, 0xb0, - 0x83, 0x3e, 0xd2, 0xa3, 0x2b, 0x67, 0x4d, 0x8, 0x5d, 0x66, 0xf7, 0xe5, 0x43, 0x8b, 0xce, 0xfa, 0x37, - 0xc8, 0x4e, 0x28, 0x0, 0x0, 0x18, 0xf4, 0xed, 0x4e, 0x12, 0xd, 0xf, 0x54, 0xdf, 0x12, 0xeb, 0xa6, - 0xfc, 0x33, 0xa4, 0xf2, 0x4a, 0x32, 0xb9, 0x17, 0x24, 0xd1, 0x23, 0x4f, 0xde, 0x1, 0x0, 0x3, 0x1a, - 0x50, 0xcd, 0x2, 0x0, 0x1e, 0xe, 0x3d, 0xb4, 0xa5, 0xd8, 0xd2, 0x56, 0x8f, 0xd7, 0x68, 0xe6, 0xb6, - 0xd4, 0x94, 0xc7, 0xe6, 0x1a, 0x4f, 0x80, 0x5, 0x58, 0xa3, 0xc8, 0xf4, 0x3c, 0x12, 0x67, 0x39, 0x50, - 0xb4, 0x0, 0x0, 0xf, 0x33, 0x7a, 0x0, 0x36, 0xd2, 0xfe, 0xde, 0x2e, 0x92, 0xed, 0xf7, 0x7f, 0x2a, - 0x5f, 0xfb, 0x0, 0x0, 0x1e, 0x6a, 0xc4, 0xdc, 0xbe, 0xd2, 0x99, 0xc4, 0x86, 0xa9, 0x1d, 0x12, 0xd0, - 0x6d, 0x36, 0x9b, 0x7b, 0x69, 0xcc, 0x69, 0x3d, 0x4c, 0x6e, 0x39, 0xc9, 0x4f, 0x5f, 0x15, 0x23, 0x2d, - 0xb1, 0x0, 0x0, 0xa, 0x76, 0x0, 0xeb, 0xc7, 0x8a, 0x80, 0x33, 0x7f, 0xca, 0x51, 0x1, 0x0, 0x10, - 0xef, 0xd8, 0x48, 0x1f, 0x74, 0x4b, 0xf4, 0xed, 0x1c, 0x6c, 0x23, 0xea, 0x5d, 0xdc, 0x4c, 0x6c, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xc5, 0xb6, 0xf7, 0x15, 0xe1, 0x67, 0x9c, 0x1e, 0x42, 0xb0, - 0x83, 0x3e, 0xd2, 0xa3, 0x2b, 0x67, 0x4d, 0x8, 0x5d, 0x66, - 0xf7, 0xe5, 0x43, 0x8b, 0xce, 0xfa, 0x37, 0xc8, 0x4e, 0x28}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf4, 0xed, 0x4e, 0x12, 0xd, 0xf, 0x54, 0xdf, 0x12, 0xeb, 0xa6, 0xfc, - 0x33, 0xa4, 0xf2, 0x4a, 0x32, 0xb9, 0x17, 0x24, 0xd1, 0x23, 0x4f, 0xde}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1a, 0x50, 0xcd}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe, 0x3d, 0xb4, 0xa5, 0xd8, 0xd2, 0x56, 0x8f, 0xd7, 0x68, - 0xe6, 0xb6, 0xd4, 0x94, 0xc7, 0xe6, 0x1a, 0x4f, 0x80, 0x5, - 0x58, 0xa3, 0xc8, 0xf4, 0x3c, 0x12, 0x67, 0x39, 0x50, 0xb4}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x33, 0x7a, 0x0, 0x36, 0xd2, 0xfe, 0xde, 0x2e, - 0x92, 0xed, 0xf7, 0x7f, 0x2a, 0x5f, 0xfb}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6a, 0xc4, 0xdc, 0xbe, 0xd2, 0x99, 0xc4, 0x86, 0xa9, 0x1d, - 0x12, 0xd0, 0x6d, 0x36, 0x9b, 0x7b, 0x69, 0xcc, 0x69, 0x3d, - 0x4c, 0x6e, 0x39, 0xc9, 0x4f, 0x5f, 0x15, 0x23, 0x2d, 0xb1}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x76, 0x0, 0xeb, 0xc7, 0x8a, 0x80, 0x33, 0x7f, 0xca, 0x51}; - lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xef, 0xd8, 0x48, 0x1f, 0x74, 0x4b, 0xf4, 0xed, - 0x1c, 0x6c, 0x23, 0xea, 0x5d, 0xdc, 0x4c, 0x6c}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x82, 0xcb, 0x1, 0x18, 0xa, 0x0, 0xe, 0x7f, 0xf4, 0xe3, 0xc1, 0xf8, 0x4c, 0x12, 0xf9, 0xf9, 0x68, 0xd9, 0x75, 0x5f, 0x75, 0x1, 0x0, 0xd, 0x92, 0xe2, 0x58, 0xe3, 0x7a, 0x6f, 0x4b, 0x5a, 0xac, 0x43, 0x24, 0x11, 0x3e, 0x2, 0x0, 0x1e, 0x1f, 0x70, 0x48, 0x82, 0x5c, 0x4, 0x1b, 0x6f, 0xd, 0xcd, 0xf9, 0x64, 0xd7, 0xf3, 0xf6, 0x19, 0xf3, 0x5c, 0x4f, 0x79, 0xc3, 0x93, 0x39, 0x3c, 0xf9, 0x41, 0xe6, 0x35, 0x3, 0x2e, 0x1, 0x0, 0xb, 0xba, 0x55, 0x61, 0x68, 0xfb, 0x3f, 0xec, 0x6d, 0x85, 0xb, 0xd7, 0x1, 0x0, 0x13, 0xc, 0xc1, 0x79, 0xd3, 0x39, 0xa3, 0xbc, 0xed, 0x16, 0x38, 0xc6, 0x13, 0x34, 0x82, 0xda, 0xcb, 0x33, 0x7e, 0x5c, 0x0, 0x0, 0x19, 0xff, 0x2b, 0x89, 0x76, 0xb8, 0xd7, 0x50, 0x69, 0x78, 0xaa, 0x52, 0xfc, 0x7b, 0x6c, 0x82, 0xfe, 0xd4, 0x79, 0x51, 0xdf, 0x40, 0x6c, 0xf, 0x82, 0x69, 0x0, 0x0, 0x4, 0x89, 0xec, 0x39, 0x32, 0x2, 0x0, 0x4, 0x7b, 0x22, 0xca, 0x82, 0x0, 0x0, 0x4, 0xdd, 0x75, 0xdf, 0x77, 0x1, 0x0, 0x1a, 0xf9, 0x89, 0xdb, 0x6e, 0x8b, 0xc, 0xee, 0xd0, 0x6c, 0x54, 0x30, 0xc9, 0xd1, 0xf, 0x87, 0xed, 0xb6, 0xd4, 0xb9, 0xbe, 0xf4, 0xdc, 0xb1, 0xb4, 0x42, 0xe5, 0x2, 0x0, 0x12, 0x5c, 0x28, 0x5b, 0x2a, 0x4, 0x6e, 0x91, 0xaf, 0xec, 0x47, 0xb0, 0x38, 0xf0, 0x2, 0xaa, 0x1a, 0x5b, 0x63, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x7f, 0xf4, 0xe3, 0xc1, 0xf8, 0x4c, 0x12, 0xf9, 0xf9, 0x68, 0xd9, 0x75, 0x5f, 0x75}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x92, 0xe2, 0x58, 0xe3, 0x7a, 0x6f, 0x4b, 0x5a, 0xac, 0x43, 0x24, 0x11, 0x3e}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1f, 0x70, 0x48, 0x82, 0x5c, 0x4, 0x1b, 0x6f, 0xd, 0xcd, 0xf9, 0x64, 0xd7, 0xf3, 0xf6, 0x19, 0xf3, 0x5c, 0x4f, 0x79, 0xc3, 0x93, 0x39, 0x3c, 0xf9, 0x41, 0xe6, 0x35, 0x3, 0x2e}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xba, 0x55, 0x61, 0x68, 0xfb, 0x3f, 0xec, 0x6d, 0x85, 0xb, 0xd7}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xc, 0xc1, 0x79, 0xd3, 0x39, 0xa3, 0xbc, 0xed, 0x16, 0x38, 0xc6, 0x13, 0x34, 0x82, 0xda, 0xcb, 0x33, 0x7e, 0x5c}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xff, 0x2b, 0x89, 0x76, 0xb8, 0xd7, 0x50, 0x69, 0x78, 0xaa, 0x52, 0xfc, 0x7b, 0x6c, 0x82, 0xfe, 0xd4, 0x79, 0x51, 0xdf, 0x40, 0x6c, 0xf, 0x82, 0x69}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x89, 0xec, 0x39, 0x32}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x7b, 0x22, 0xca, 0x82}; + lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xdd, 0x75, 0xdf, 0x77}; + lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xf9, 0x89, 0xdb, 0x6e, 0x8b, 0xc, 0xee, 0xd0, 0x6c, 0x54, 0x30, 0xc9, 0xd1, 0xf, 0x87, 0xed, 0xb6, 0xd4, 0xb9, 0xbe, 0xf4, 0xdc, 0xb1, 0xb4, 0x42, 0xe5}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; +topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x5c, 0x28, 0x5b, 0x2a, 0x4, 0x6e, 0x91, 0xaf, 0xec, 0x47, 0xb0, 0x38, 0xf0, 0x2, 0xaa, 0x1a, 0x5b, 0x63}; + lwmqtt_string_t topic_filter_s10 = {18, (char*)&topic_filter_s10_bytes}; +topic_filters[10] = topic_filter_s10; +lwmqtt_sub_options_t sub_opts[11]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS0; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; +sub_opts[6].qos = LWMQTT_QOS2; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = false; +sub_opts[6].no_local = false; +sub_opts[7].qos = LWMQTT_QOS0; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = false; +sub_opts[8].qos = LWMQTT_QOS1; +sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[8].retain_as_published = false; +sub_opts[8].no_local = false; +sub_opts[9].qos = LWMQTT_QOS2; +sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[9].retain_as_published = false; +sub_opts[9].no_local = false; +sub_opts[10].qos = LWMQTT_QOS1; +sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[10].retain_as_published = false; +sub_opts[10].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10052, 8, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6154, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 12644 [("\185\166\&5\ACK\169\SOk",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1})] [] + +// SubscribeRequest 7912 [("\182\167\151\163VQ\156;\242Q\187<\193\&4\145-\243Y\208\152E?\200&\SYN\US",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\FS?\153\174\206\185MuW\176b\183\172\134",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\223\224s\US\169\&0bC\ENQQ\200\221\248qE\235\255B\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0xf, 0x31, 0x64, 0x0, 0x7, 0xb9, 0xa6, 0x35, 0x6, 0xa9, 0xe, 0x6b, 0x1, 0x0, 0x0, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xb9, 0xa6, 0x35, 0x6, 0xa9, 0xe, 0x6b}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x82, 0x46, 0x1e, 0xe8, 0x0, 0x1a, 0xb6, 0xa7, 0x97, 0xa3, 0x56, 0x51, 0x9c, 0x3b, 0xf2, 0x51, 0xbb, 0x3c, 0xc1, 0x34, 0x91, 0x2d, 0xf3, 0x59, 0xd0, 0x98, 0x45, 0x3f, 0xc8, 0x26, 0x16, 0x1f, 0x1, 0x0, 0xe, 0x1c, 0x3f, 0x99, 0xae, 0xce, 0xb9, 0x4d, 0x75, 0x57, 0xb0, 0x62, 0xb7, 0xac, 0x86, 0x0, 0x0, 0x13, 0xdf, 0xe0, 0x73, 0x1f, 0xa9, 0x30, 0x62, 0x43, 0x5, 0x51, 0xc8, 0xdd, 0xf8, 0x71, 0x45, 0xeb, 0xff, 0x42, 0xa, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xb6, 0xa7, 0x97, 0xa3, 0x56, 0x51, 0x9c, 0x3b, 0xf2, 0x51, 0xbb, 0x3c, 0xc1, 0x34, 0x91, 0x2d, 0xf3, 0x59, 0xd0, 0x98, 0x45, 0x3f, 0xc8, 0x26, 0x16, 0x1f}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x1c, 0x3f, 0x99, 0xae, 0xce, 0xb9, 0x4d, 0x75, 0x57, 0xb0, 0x62, 0xb7, 0xac, 0x86}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xdf, 0xe0, 0x73, 0x1f, 0xa9, 0x30, 0x62, 0x43, 0x5, 0x51, 0xc8, 0xdd, 0xf8, 0x71, 0x45, 0xeb, 0xff, 0x42, 0xa}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; +lwmqtt_sub_options_t sub_opts[3]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS0; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12644, 2, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7912, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 4944 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("_k\r\DC2\f\SI\228\155\183\&2\NAK\NULR\a]\202\235\149",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("*>\177\186\&0]\214*\191\206q\"\231\248\230\193\194E\183\238!\241+\233\222,\198t\234\150",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("mP\215\162\&0:<\157\150\b\240m\ETX\235\218\SOH\255I\168\&5I\145\134^\EM",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] + +// SubscribeRequest 1410 [("\146)\134\170\232\238\169\149\192\144\173`=4\225}\DC2\181\176\234\SUB-\173\SI\204",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\157\225\208\231:\189\b\244\171\243J\204\GS\233\177\CAN\210v\FS\NUL\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DC3\166\143e\196",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0x57, 0x13, 0x50, 0x0, 0x0, 0x2, 0x0, 0x12, 0x5f, 0x6b, 0xd, 0x12, 0xc, 0xf, - 0xe4, 0x9b, 0xb7, 0x32, 0x15, 0x0, 0x52, 0x7, 0x5d, 0xca, 0xeb, 0x95, 0x2, 0x0, 0x1e, - 0x2a, 0x3e, 0xb1, 0xba, 0x30, 0x5d, 0xd6, 0x2a, 0xbf, 0xce, 0x71, 0x22, 0xe7, 0xf8, 0xe6, - 0xc1, 0xc2, 0x45, 0xb7, 0xee, 0x21, 0xf1, 0x2b, 0xe9, 0xde, 0x2c, 0xc6, 0x74, 0xea, 0x96, - 0x1, 0x0, 0x19, 0x6d, 0x50, 0xd7, 0xa2, 0x30, 0x3a, 0x3c, 0x9d, 0x96, 0x8, 0xf0, 0x6d, - 0x3, 0xeb, 0xda, 0x1, 0xff, 0x49, 0xa8, 0x35, 0x49, 0x91, 0x86, 0x5e, 0x19, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5f, 0x6b, 0xd, 0x12, 0xc, 0xf, 0xe4, 0x9b, 0xb7, - 0x32, 0x15, 0x0, 0x52, 0x7, 0x5d, 0xca, 0xeb, 0x95}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2a, 0x3e, 0xb1, 0xba, 0x30, 0x5d, 0xd6, 0x2a, 0xbf, 0xce, - 0x71, 0x22, 0xe7, 0xf8, 0xe6, 0xc1, 0xc2, 0x45, 0xb7, 0xee, - 0x21, 0xf1, 0x2b, 0xe9, 0xde, 0x2c, 0xc6, 0x74, 0xea, 0x96}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6d, 0x50, 0xd7, 0xa2, 0x30, 0x3a, 0x3c, 0x9d, 0x96, 0x8, 0xf0, 0x6d, 0x3, - 0xeb, 0xda, 0x1, 0xff, 0x49, 0xa8, 0x35, 0x49, 0x91, 0x86, 0x5e, 0x19}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x82, 0x3e, 0x5, 0x82, 0x0, 0x19, 0x92, 0x29, 0x86, 0xaa, 0xe8, 0xee, 0xa9, 0x95, 0xc0, 0x90, 0xad, 0x60, 0x3d, 0x34, 0xe1, 0x7d, 0x12, 0xb5, 0xb0, 0xea, 0x1a, 0x2d, 0xad, 0xf, 0xcc, 0x0, 0x0, 0x15, 0x9d, 0xe1, 0xd0, 0xe7, 0x3a, 0xbd, 0x8, 0xf4, 0xab, 0xf3, 0x4a, 0xcc, 0x1d, 0xe9, 0xb1, 0x18, 0xd2, 0x76, 0x1c, 0x0, 0x19, 0x2, 0x0, 0x5, 0x13, 0xa6, 0x8f, 0x65, 0xc4, 0x1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x92, 0x29, 0x86, 0xaa, 0xe8, 0xee, 0xa9, 0x95, 0xc0, 0x90, 0xad, 0x60, 0x3d, 0x34, 0xe1, 0x7d, 0x12, 0xb5, 0xb0, 0xea, 0x1a, 0x2d, 0xad, 0xf, 0xcc}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x9d, 0xe1, 0xd0, 0xe7, 0x3a, 0xbd, 0x8, 0xf4, 0xab, 0xf3, 0x4a, 0xcc, 0x1d, 0xe9, 0xb1, 0x18, 0xd2, 0x76, 0x1c, 0x0, 0x19}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x13, 0xa6, 0x8f, 0x65, 0xc4}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; +lwmqtt_sub_options_t sub_opts[3]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4944, 4, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1410, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 10380 [("x#\177~\235\205^\211e\221\198\US_r6\166_\SUB\220\237ILW\169\182V\129",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("fv\DC4W\179\ETB\232\n\203",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\183Q\224\149\199H$\NAK\183\GS\164\130\219 $B\130J\247\250\205V\218",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("w\NAK{\230=\DC2\213",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),(".\240\210\165\146h\199\217\159k\147\SO.\155\246\245\233\STX\229P\168\196",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\226I\SYN\248",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("\150\230\233s",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2}),("\133\135\180\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("_D5",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("gN\213\255\202\196Gnm\180\&4\184Y\219kI\b\140\223\178\DC1u\248\215\132",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\209\EOT\FS\r\251\165\SO{I\218G\179\214\176\184\150\153\160\235\&0\226\aN",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] + +// SubscribeRequest 21007 [("K\148\168\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("r\233o\161\151.",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("a\216\169\218\&7\t\173\212\208C|\f\221",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\209\136\244\253\211\NAK\191-\a\196\188\224\129\178_\238\170[\218\131$jr\220U\162:",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode30) { - uint8_t pkt[] = { - 0x82, 0xba, 0x1, 0x28, 0x8c, 0x0, 0x1b, 0x78, 0x23, 0xb1, 0x7e, 0xeb, 0xcd, 0x5e, 0xd3, 0x65, 0xdd, 0xc6, 0x1f, - 0x5f, 0x72, 0x36, 0xa6, 0x5f, 0x1a, 0xdc, 0xed, 0x49, 0x4c, 0x57, 0xa9, 0xb6, 0x56, 0x81, 0x2, 0x0, 0x9, 0x66, - 0x76, 0x14, 0x57, 0xb3, 0x17, 0xe8, 0xa, 0xcb, 0x2, 0x0, 0x17, 0xb7, 0x51, 0xe0, 0x95, 0xc7, 0x48, 0x24, 0x15, - 0xb7, 0x1d, 0xa4, 0x82, 0xdb, 0x20, 0x24, 0x42, 0x82, 0x4a, 0xf7, 0xfa, 0xcd, 0x56, 0xda, 0x1, 0x0, 0x7, 0x77, - 0x15, 0x7b, 0xe6, 0x3d, 0x12, 0xd5, 0x2, 0x0, 0x16, 0x2e, 0xf0, 0xd2, 0xa5, 0x92, 0x68, 0xc7, 0xd9, 0x9f, 0x6b, - 0x93, 0xe, 0x2e, 0x9b, 0xf6, 0xf5, 0xe9, 0x2, 0xe5, 0x50, 0xa8, 0xc4, 0x1, 0x0, 0x4, 0xe2, 0x49, 0x16, 0xf8, - 0x0, 0x0, 0x4, 0x96, 0xe6, 0xe9, 0x73, 0x2, 0x0, 0x4, 0x85, 0x87, 0xb4, 0x19, 0x2, 0x0, 0x3, 0x5f, 0x44, - 0x35, 0x2, 0x0, 0x19, 0x67, 0x4e, 0xd5, 0xff, 0xca, 0xc4, 0x47, 0x6e, 0x6d, 0xb4, 0x34, 0xb8, 0x59, 0xdb, 0x6b, - 0x49, 0x8, 0x8c, 0xdf, 0xb2, 0x11, 0x75, 0xf8, 0xd7, 0x84, 0x0, 0x0, 0x17, 0xd1, 0x4, 0x1c, 0xd, 0xfb, 0xa5, - 0xe, 0x7b, 0x49, 0xda, 0x47, 0xb3, 0xd6, 0xb0, 0xb8, 0x96, 0x99, 0xa0, 0xeb, 0x30, 0xe2, 0x7, 0x4e, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x78, 0x23, 0xb1, 0x7e, 0xeb, 0xcd, 0x5e, 0xd3, 0x65, 0xdd, 0xc6, 0x1f, 0x5f, 0x72, - 0x36, 0xa6, 0x5f, 0x1a, 0xdc, 0xed, 0x49, 0x4c, 0x57, 0xa9, 0xb6, 0x56, 0x81}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x66, 0x76, 0x14, 0x57, 0xb3, 0x17, 0xe8, 0xa, 0xcb}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb7, 0x51, 0xe0, 0x95, 0xc7, 0x48, 0x24, 0x15, 0xb7, 0x1d, 0xa4, 0x82, - 0xdb, 0x20, 0x24, 0x42, 0x82, 0x4a, 0xf7, 0xfa, 0xcd, 0x56, 0xda}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x77, 0x15, 0x7b, 0xe6, 0x3d, 0x12, 0xd5}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2e, 0xf0, 0xd2, 0xa5, 0x92, 0x68, 0xc7, 0xd9, 0x9f, 0x6b, 0x93, - 0xe, 0x2e, 0x9b, 0xf6, 0xf5, 0xe9, 0x2, 0xe5, 0x50, 0xa8, 0xc4}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe2, 0x49, 0x16, 0xf8}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x96, 0xe6, 0xe9, 0x73}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x85, 0x87, 0xb4, 0x19}; - lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x5f, 0x44, 0x35}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x67, 0x4e, 0xd5, 0xff, 0xca, 0xc4, 0x47, 0x6e, 0x6d, 0xb4, 0x34, 0xb8, 0x59, - 0xdb, 0x6b, 0x49, 0x8, 0x8c, 0xdf, 0xb2, 0x11, 0x75, 0xf8, 0xd7, 0x84}; - lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xd1, 0x4, 0x1c, 0xd, 0xfb, 0xa5, 0xe, 0x7b, 0x49, 0xda, 0x47, 0xb3, - 0xd6, 0xb0, 0xb8, 0x96, 0x99, 0xa0, 0xeb, 0x30, 0xe2, 0x7, 0x4e}; - lwmqtt_string_t topic_filter_s10 = {23, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; - - lwmqtt_property_t propslist[] = {}; +uint8_t pkt[] = {0x82, 0x40, 0x52, 0xf, 0x0, 0x4, 0x4b, 0x94, 0xa8, 0x1, 0x2, 0x0, 0x6, 0x72, 0xe9, 0x6f, 0xa1, 0x97, 0x2e, 0x2, 0x0, 0xd, 0x61, 0xd8, 0xa9, 0xda, 0x37, 0x9, 0xad, 0xd4, 0xd0, 0x43, 0x7c, 0xc, 0xdd, 0x0, 0x0, 0x1b, 0xd1, 0x88, 0xf4, 0xfd, 0xd3, 0x15, 0xbf, 0x2d, 0x7, 0xc4, 0xbc, 0xe0, 0x81, 0xb2, 0x5f, 0xee, 0xaa, 0x5b, 0xda, 0x83, 0x24, 0x6a, 0x72, 0xdc, 0x55, 0xa2, 0x3a, 0x2}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x4b, 0x94, 0xa8, 0x1}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x72, 0xe9, 0x6f, 0xa1, 0x97, 0x2e}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x61, 0xd8, 0xa9, 0xda, 0x37, 0x9, 0xad, 0xd4, 0xd0, 0x43, 0x7c, 0xc, 0xdd}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd1, 0x88, 0xf4, 0xfd, 0xd3, 0x15, 0xbf, 0x2d, 0x7, 0xc4, 0xbc, 0xe0, 0x81, 0xb2, 0x5f, 0xee, 0xaa, 0x5b, 0xda, 0x83, 0x24, 0x6a, 0x72, 0xdc, 0x55, 0xa2, 0x3a}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; +lwmqtt_sub_options_t sub_opts[4]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS2; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; + + lwmqtt_property_t propslist[] = { + }; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10380, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21007, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 14771 [("#\200Q\136b\STX\234p\149",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = True, _noLocal = False, _subQoS = -// QoS2}),("\228_\193\193f_2@\169\173\&8\140\194\221c7\ACK|\ESC\249[\"Cm\187\155\170\176",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("#\f&\179\130I\157\181\213\&6fl\DC2\184\SYN\188\175\227&yeI",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\247St\244Y\\m\197\n\f\DC4A\EOT\nmG\183L\SOH\161J\132\a\150\&3\DC3SP\130\194",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("E\169\130\158J\214",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] -// [PropUserProperty "\229\243\249(\129\186\nO\140\255\202\&5\v\DC2\218\203B1\131\169\177\149\177\EOT\165\214~" -// "\211\247:YI\DC1\143.\236Y\155\SYN'\235\145\169\FS]1\EOT\228\192",PropServerKeepAlive 1455,PropResponseInformation -// "\t\167\190z\213\168\147\SOH\202\148\SUB3\206\130.\231\165\161\210",PropUserProperty -// "\233\233J\221\187\196\165\142\211\228@=\183!\222\198\173\EOT\248\191\130\219\191\142\STX\185d\171kr" -// "g\246\164\194\225t\n\133\143\198\&8\b'\140\154\r'\NULU\159\DC1t\151(\149R\153]",PropReasonString -// "\207\198l\151\&9\171\208\156\231\149!\216R\233<\a\229p)\182\182.\246\156",PropRetainAvailable 26,PropUserProperty -// "\199\r\177\DC2\178\208\180!p" "0\NAK",PropWillDelayInterval 15578,PropMessageExpiryInterval -// 27005,PropSessionExpiryInterval 18827,PropRetainAvailable 55,PropMaximumPacketSize 15963,PropUserProperty -// "\249nY\175\185>" "J\SYNc\247\198\158\162Ik\222a\251\129\223\170\198\128 \154-\235 \240",PropAuthenticationMethod -// "\172\226\168\209\157\ETB\225q\167H\168\&7\185=x\244\249I\137\FS\ENQ#L\180r\EM\135d\159`",PropServerReference -// "\224\148;\f\"f\SO\178\v\175\227>\DLE\166\238'\t\128-\\\190<4",PropReceiveMaximum 1113,PropRequestProblemInformation -// 44,PropTopicAlias 28498,PropRequestResponseInformation 242,PropSessionExpiryInterval 28088,PropCorrelationData -// "OP\SOHf\199AD\217\DLE\173i3^\154\SI",PropWildcardSubscriptionAvailable 214,PropWildcardSubscriptionAvailable -// 89,PropAuthenticationMethod -// "Q\246\191M,\186%\152@H\231\248\187j\EOT\169v\"\132\205C\169\189!f6\199}",PropAuthenticationData -// "\253",PropSubscriptionIdentifier 15,PropPayloadFormatIndicator 63] -TEST(Subscribe5QCTest, Encode1) { - uint8_t pkt[] = { - 0x82, 0xec, 0x3, 0x39, 0xb3, 0xfa, 0x2, 0x26, 0x0, 0x1b, 0xe5, 0xf3, 0xf9, 0x28, 0x81, 0xba, 0xa, 0x4f, 0x8c, - 0xff, 0xca, 0x35, 0xb, 0x12, 0xda, 0xcb, 0x42, 0x31, 0x83, 0xa9, 0xb1, 0x95, 0xb1, 0x4, 0xa5, 0xd6, 0x7e, 0x0, - 0x16, 0xd3, 0xf7, 0x3a, 0x59, 0x49, 0x11, 0x8f, 0x2e, 0xec, 0x59, 0x9b, 0x16, 0x27, 0xeb, 0x91, 0xa9, 0x1c, 0x5d, -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, 0x16, 0x23, 0xc, 0x26, 0xb3, 0x82, 0x49, 0x9d, - 0xb5, 0xd5, 0x36, 0x66, 0x6c, 0x12, 0xb8, 0x16, 0xbc, 0xaf, 0xe3, 0x26, 0x79, 0x65, 0x49, 0x12, 0x0, 0x1e, 0xf7, - 0x53, 0x74, 0xf4, 0x59, 0x5c, 0x6d, 0xc5, 0xa, 0xc, 0x14, 0x41, 0x4, 0xa, 0x6d, 0x47, 0xb7, 0x4c, 0x1, 0xa1, - 0x4a, 0x84, 0x7, 0x96, 0x33, 0x13, 0x53, 0x50, 0x82, 0xc2, 0x1c, 0x0, 0x6, 0x45, 0xa9, 0x82, 0x9e, 0x4a, 0xd6, - 0x26}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x23, 0xc8, 0x51, 0x88, 0x62, 0x2, 0xea, 0x70, 0x95}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe4, 0x5f, 0xc1, 0xc1, 0x66, 0x5f, 0x32, 0x40, 0xa9, 0xad, - 0x38, 0x8c, 0xc2, 0xdd, 0x63, 0x37, 0x6, 0x7c, 0x1b, 0xf9, - 0x5b, 0x22, 0x43, 0x6d, 0xbb, 0x9b, 0xaa, 0xb0}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x23, 0xc, 0x26, 0xb3, 0x82, 0x49, 0x9d, 0xb5, 0xd5, 0x36, 0x66, - 0x6c, 0x12, 0xb8, 0x16, 0xbc, 0xaf, 0xe3, 0x26, 0x79, 0x65, 0x49}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf7, 0x53, 0x74, 0xf4, 0x59, 0x5c, 0x6d, 0xc5, 0xa, 0xc, - 0x14, 0x41, 0x4, 0xa, 0x6d, 0x47, 0xb7, 0x4c, 0x1, 0xa1, - 0x4a, 0x84, 0x7, 0x96, 0x33, 0x13, 0x53, 0x50, 0x82, 0xc2}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x45, 0xa9, 0x82, 0x9e, 0x4a, 0xd6}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - uint8_t bytesprops1[] = {0xd3, 0xf7, 0x3a, 0x59, 0x49, 0x11, 0x8f, 0x2e, 0xec, 0x59, 0x9b, - 0x16, 0x27, 0xeb, 0x91, 0xa9, 0x1c, 0x5d, 0x31, 0x4, 0xe4, 0xc0}; - uint8_t bytesprops0[] = {0xe5, 0xf3, 0xf9, 0x28, 0x81, 0xba, 0xa, 0x4f, 0x8c, 0xff, 0xca, 0x35, 0xb, 0x12, - 0xda, 0xcb, 0x42, 0x31, 0x83, 0xa9, 0xb1, 0x95, 0xb1, 0x4, 0xa5, 0xd6, 0x7e}; - uint8_t bytesprops2[] = {0x9, 0xa7, 0xbe, 0x7a, 0xd5, 0xa8, 0x93, 0x1, 0xca, 0x94, - 0x1a, 0x33, 0xce, 0x82, 0x2e, 0xe7, 0xa5, 0xa1, 0xd2}; - uint8_t bytesprops4[] = {0x67, 0xf6, 0xa4, 0xc2, 0xe1, 0x74, 0xa, 0x85, 0x8f, 0xc6, 0x38, 0x8, 0x27, 0x8c, - 0x9a, 0xd, 0x27, 0x0, 0x55, 0x9f, 0x11, 0x74, 0x97, 0x28, 0x95, 0x52, 0x99, 0x5d}; - uint8_t bytesprops3[] = {0xe9, 0xe9, 0x4a, 0xdd, 0xbb, 0xc4, 0xa5, 0x8e, 0xd3, 0xe4, 0x40, 0x3d, 0xb7, 0x21, 0xde, - 0xc6, 0xad, 0x4, 0xf8, 0xbf, 0x82, 0xdb, 0xbf, 0x8e, 0x2, 0xb9, 0x64, 0xab, 0x6b, 0x72}; - uint8_t bytesprops5[] = {0xcf, 0xc6, 0x6c, 0x97, 0x39, 0xab, 0xd0, 0x9c, 0xe7, 0x95, 0x21, 0xd8, - 0x52, 0xe9, 0x3c, 0x7, 0xe5, 0x70, 0x29, 0xb6, 0xb6, 0x2e, 0xf6, 0x9c}; - uint8_t bytesprops7[] = {0x30, 0x15}; - uint8_t bytesprops6[] = {0xc7, 0xd, 0xb1, 0x12, 0xb2, 0xd0, 0xb4, 0x21, 0x70}; - uint8_t bytesprops9[] = {0x4a, 0x16, 0x63, 0xf7, 0xc6, 0x9e, 0xa2, 0x49, 0x6b, 0xde, 0x61, 0xfb, - 0x81, 0xdf, 0xaa, 0xc6, 0x80, 0x20, 0x9a, 0x2d, 0xeb, 0x20, 0xf0}; - uint8_t bytesprops8[] = {0xf9, 0x6e, 0x59, 0xaf, 0xb9, 0x3e}; - uint8_t bytesprops10[] = {0xac, 0xe2, 0xa8, 0xd1, 0x9d, 0x17, 0xe1, 0x71, 0xa7, 0x48, 0xa8, 0x37, 0xb9, 0x3d, 0x78, - 0xf4, 0xf9, 0x49, 0x89, 0x1c, 0x5, 0x23, 0x4c, 0xb4, 0x72, 0x19, 0x87, 0x64, 0x9f, 0x60}; - uint8_t bytesprops11[] = {0xe0, 0x94, 0x3b, 0xc, 0x22, 0x66, 0xe, 0xb2, 0xb, 0xaf, 0xe3, 0x3e, - 0x10, 0xa6, 0xee, 0x27, 0x9, 0x80, 0x2d, 0x5c, 0xbe, 0x3c, 0x34}; - uint8_t bytesprops12[] = {0x4f, 0x50, 0x1, 0x66, 0xc7, 0x41, 0x44, 0xd9, 0x10, 0xad, 0x69, 0x33, 0x5e, 0x9a, 0xf}; - uint8_t bytesprops13[] = {0x51, 0xf6, 0xbf, 0x4d, 0x2c, 0xba, 0x25, 0x98, 0x40, 0x48, 0xe7, 0xf8, 0xbb, 0x6a, - 0x4, 0xa9, 0x76, 0x22, 0x84, 0xcd, 0x43, 0xa9, 0xbd, 0x21, 0x66, 0x36, 0xc7, 0x7d}; - uint8_t bytesprops14[] = {0xfd}; +// SubscribeRequest 2235 [("\ETB\166",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropResponseInformation "\212\ETB\233\246\147\144G\DEL",PropSessionExpiryInterval 21137,PropUserProperty "\SYN\191\240\CANC" "p[",PropServerKeepAlive 12069,PropAssignedClientIdentifier "\130E\SUB >\SI\216\230R\235\ACK\FS\133jfq7/\210\198\210\161ys#",PropResponseTopic "\152\r\178\143\233\ACK0Ke\148\190\169Q4.]\130n\180\138\128\238\184=",PropAuthenticationMethod "4\167\136t\196\ESC\236\GS,3\188\aV\132\&2\192^\NUL\182\154\NAK'\a\130",PropSessionExpiryInterval 25074,PropSharedSubscriptionAvailable 100,PropRequestResponseInformation 36,PropSubscriptionIdentifier 18,PropMessageExpiryInterval 9123,PropUserProperty "\228\250F\165=\137\176\213Z\248\154ho\187\ENQ\176\184\136m\f\DC2\224\130\149A|\215\186\185" "\210q\217@\219;%\aB\196",PropTopicAlias 27031,PropUserProperty "y\135\164\169\250\159" "\247A\SO\DC3\147\182\240C|\f\129R\129\156/\SYN\160\216\244\ETB2\160\134\245}\132",PropWillDelayInterval 2441,PropMaximumQoS 72,PropAssignedClientIdentifier "o\SUB\239\t\r\SOH\245\134gu\GS\131b\SOH\"\208\177\164\&0\192V"] +TEST(Subscribe5QCTest, Encode1) { +uint8_t pkt[] = {0x82, 0xfd, 0x1, 0x8, 0xbb, 0xf4, 0x1, 0x1a, 0x0, 0x8, 0xd4, 0x17, 0xe9, 0xf6, 0x93, 0x90, 0x47, 0x7f, 0x11, 0x0, 0x0, 0x52, 0x91, 0x26, 0x0, 0x5, 0x16, 0xbf, 0xf0, 0x18, 0x43, 0x0, 0x2, 0x70, 0x5b, 0x13, 0x2f, 0x25, 0x12, 0x0, 0x19, 0x82, 0x45, 0x1a, 0x20, 0x3e, 0xf, 0xd8, 0xe6, 0x52, 0xeb, 0x6, 0x1c, 0x85, 0x6a, 0x66, 0x71, 0x37, 0x2f, 0xd2, 0xc6, 0xd2, 0xa1, 0x79, 0x73, 0x23, 0x8, 0x0, 0x18, 0x98, 0xd, 0xb2, 0x8f, 0xe9, 0x6, 0x30, 0x4b, 0x65, 0x94, 0xbe, 0xa9, 0x51, 0x34, 0x2e, 0x5d, 0x82, 0x6e, 0xb4, 0x8a, 0x80, 0xee, 0xb8, 0x3d, 0x15, 0x0, 0x18, 0x34, 0xa7, 0x88, 0x74, 0xc4, 0x1b, 0xec, 0x1d, 0x2c, 0x33, 0xbc, 0x7, 0x56, 0x84, 0x32, 0xc0, 0x5e, 0x0, 0xb6, 0x9a, 0x15, 0x27, 0x7, 0x82, 0x11, 0x0, 0x0, 0x61, 0xf2, 0x2a, 0x64, 0x19, 0x24, 0xb, 0x12, 0x2, 0x0, 0x0, 0x23, 0xa3, 0x26, 0x0, 0x1d, 0xe4, 0xfa, 0x46, 0xa5, 0x3d, 0x89, 0xb0, 0xd5, 0x5a, 0xf8, 0x9a, 0x68, 0x6f, 0xbb, 0x5, 0xb0, 0xb8, 0x88, 0x6d, 0xc, 0x12, 0xe0, 0x82, 0x95, 0x41, 0x7c, 0xd7, 0xba, 0xb9, 0x0, 0xa, 0xd2, 0x71, 0xd9, 0x40, 0xdb, 0x3b, 0x25, 0x7, 0x42, 0xc4, 0x23, 0x69, 0x97, 0x26, 0x0, 0x6, 0x79, 0x87, 0xa4, 0xa9, 0xfa, 0x9f, 0x0, 0x1a, 0xf7, 0x41, 0xe, 0x13, 0x93, 0xb6, 0xf0, 0x43, 0x7c, 0xc, 0x81, 0x52, 0x81, 0x9c, 0x2f, 0x16, 0xa0, 0xd8, 0xf4, 0x17, 0x32, 0xa0, 0x86, 0xf5, 0x7d, 0x84, 0x18, 0x0, 0x0, 0x9, 0x89, 0x24, 0x48, 0x12, 0x0, 0x15, 0x6f, 0x1a, 0xef, 0x9, 0xd, 0x1, 0xf5, 0x86, 0x67, 0x75, 0x1d, 0x83, 0x62, 0x1, 0x22, 0xd0, 0xb1, 0xa4, 0x30, 0xc0, 0x56, 0x0, 0x2, 0x17, 0xa6, 0x28}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x17, 0xa6}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; +lwmqtt_sub_options_t sub_opts[1]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[0].retain_as_published = true; +sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0xd4, 0x17, 0xe9, 0xf6, 0x93, 0x90, 0x47, 0x7f}; + uint8_t bytesprops2[] = {0x70, 0x5b}; + uint8_t bytesprops1[] = {0x16, 0xbf, 0xf0, 0x18, 0x43}; + uint8_t bytesprops3[] = {0x82, 0x45, 0x1a, 0x20, 0x3e, 0xf, 0xd8, 0xe6, 0x52, 0xeb, 0x6, 0x1c, 0x85, 0x6a, 0x66, 0x71, 0x37, 0x2f, 0xd2, 0xc6, 0xd2, 0xa1, 0x79, 0x73, 0x23}; + uint8_t bytesprops4[] = {0x98, 0xd, 0xb2, 0x8f, 0xe9, 0x6, 0x30, 0x4b, 0x65, 0x94, 0xbe, 0xa9, 0x51, 0x34, 0x2e, 0x5d, 0x82, 0x6e, 0xb4, 0x8a, 0x80, 0xee, 0xb8, 0x3d}; + uint8_t bytesprops5[] = {0x34, 0xa7, 0x88, 0x74, 0xc4, 0x1b, 0xec, 0x1d, 0x2c, 0x33, 0xbc, 0x7, 0x56, 0x84, 0x32, 0xc0, 0x5e, 0x0, 0xb6, 0x9a, 0x15, 0x27, 0x7, 0x82}; + uint8_t bytesprops7[] = {0xd2, 0x71, 0xd9, 0x40, 0xdb, 0x3b, 0x25, 0x7, 0x42, 0xc4}; + uint8_t bytesprops6[] = {0xe4, 0xfa, 0x46, 0xa5, 0x3d, 0x89, 0xb0, 0xd5, 0x5a, 0xf8, 0x9a, 0x68, 0x6f, 0xbb, 0x5, 0xb0, 0xb8, 0x88, 0x6d, 0xc, 0x12, 0xe0, 0x82, 0x95, 0x41, 0x7c, 0xd7, 0xba, 0xb9}; + uint8_t bytesprops9[] = {0xf7, 0x41, 0xe, 0x13, 0x93, 0xb6, 0xf0, 0x43, 0x7c, 0xc, 0x81, 0x52, 0x81, 0x9c, 0x2f, 0x16, 0xa0, 0xd8, 0xf4, 0x17, 0x32, 0xa0, 0x86, 0xf5, 0x7d, 0x84}; + uint8_t bytesprops8[] = {0x79, 0x87, 0xa4, 0xa9, 0xfa, 0x9f}; + uint8_t bytesprops10[] = {0x6f, 0x1a, 0xef, 0x9, 0xd, 0x1, 0xf5, 0x86, 0x67, 0x75, 0x1d, 0x83, 0x62, 0x1, 0x22, 0xd0, 0xb1, 0xa4, 0x30, 0xc0, 0x56}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops0}, .v = {22, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1455}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops6}, .v = {2, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15578}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27005}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18827}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15963}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops8}, .v = {23, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1113}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28498}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28088}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21137}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={5, (char*)&bytesprops1}, .v={2, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12069}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25074}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9123}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={29, (char*)&bytesprops6}, .v={10, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27031}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={6, (char*)&bytesprops8}, .v={26, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2441}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14771, 5, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2235, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 15521 [("`\189\"5\223\186\254\236\DC4y(\SYNn",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("r\ESC\204\199kn\141\&6\182\233~\DC4\158p$\220\NAK\GSm#",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("7m\NUL\DC2c\DC1\250\133",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\RS\\/\203\156\163\252S.\174\177kq\225p\148\163b\249\147e.\EOT\DC2k\206\177",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("/\b\177\207\ENQ\229\157k\212\ng\247\DC3\250K`\202tNp\249\223\135",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\157\187\230\229\224\196T",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS2}),("\222\n\165\165\169%\204-\NUL\STX\192\143p4\221U",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\234\158xoF\217\SUB\128~\184\v",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS2}),("\165)n:\242PZ@\244yx\255\DLEf\155\183\r\RSd\207",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] -// [PropAssignedClientIdentifier "\247",PropResponseInformation "\230M\DC4\241ta\STXf\US.T\215",PropTopicAliasMaximum -// 18295,PropRequestProblemInformation 191,PropAssignedClientIdentifier "\221\230\138+",PropWillDelayInterval -// 31886,PropTopicAliasMaximum 28209,PropTopicAliasMaximum 11036,PropCorrelationData "RVxA\197\192N\248",PropContentType -// "\165\NAKax&7h\217\DC3,+\159w\130\224&\198\"\195K\DC3\236",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("w7jl\r\b\213",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\EOT\185\158\227\RSDU",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("6U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\141\150T,\250\229\217f\217\SO\239FB\251\CAN",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),(")\254=\198'J\DC1\DC1$\210av\158m\162)\146\132\224\191\n\232\145",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("BK\228\209\196\156\140\244?2\144\USP3z2..\DC2`\129D",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\SO\154",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropAssignedClientIdentifier "\185K\r\236v1\206\""] +TEST(Subscribe5QCTest, Encode3) { +uint8_t pkt[] = {0x82, 0x91, 0x1, 0x2a, 0xf8, 0xb, 0x12, 0x0, 0x8, 0xb9, 0x4b, 0xd, 0xec, 0x76, 0x31, 0xce, 0x22, 0x0, 0x1a, 0x9a, 0xc6, 0xab, 0x2d, 0xe9, 0x16, 0x55, 0x4c, 0xd8, 0x25, 0xa, 0xc4, 0x36, 0xc0, 0x9d, 0x30, 0x9f, 0xd8, 0xba, 0x6b, 0xf9, 0xe3, 0x3e, 0x4b, 0x13, 0xec, 0x18, 0x0, 0x7, 0x77, 0x37, 0x6a, 0x6c, 0xd, 0x8, 0xd5, 0x22, 0x0, 0x7, 0x4, 0xb9, 0x9e, 0xe3, 0x1e, 0x44, 0x55, 0x0, 0x0, 0x2, 0x36, 0x55, 0x5, 0x0, 0xf, 0x8d, 0x96, 0x54, 0x2c, 0xfa, 0xe5, 0xd9, 0x66, 0xd9, 0xe, 0xef, 0x46, 0x42, 0xfb, 0x18, 0x18, 0x0, 0x0, 0x4, 0x0, 0x17, 0x29, 0xfe, 0x3d, 0xc6, 0x27, 0x4a, 0x11, 0x11, 0x24, 0xd2, 0x61, 0x76, 0x9e, 0x6d, 0xa2, 0x29, 0x92, 0x84, 0xe0, 0xbf, 0xa, 0xe8, 0x91, 0x4, 0x0, 0x16, 0x42, 0x4b, 0xe4, 0xd1, 0xc4, 0x9c, 0x8c, 0xf4, 0x3f, 0x32, 0x90, 0x1f, 0x50, 0x33, 0x7a, 0x32, 0x2e, 0x2e, 0x12, 0x60, 0x81, 0x44, 0x8, 0x0, 0x2, 0xe, 0x9a, 0x19}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x9a, 0xc6, 0xab, 0x2d, 0xe9, 0x16, 0x55, 0x4c, 0xd8, 0x25, 0xa, 0xc4, 0x36, 0xc0, 0x9d, 0x30, 0x9f, 0xd8, 0xba, 0x6b, 0xf9, 0xe3, 0x3e, 0x4b, 0x13, 0xec}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x77, 0x37, 0x6a, 0x6c, 0xd, 0x8, 0xd5}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4, 0xb9, 0x9e, 0xe3, 0x1e, 0x44, 0x55}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x36, 0x55}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x8d, 0x96, 0x54, 0x2c, 0xfa, 0xe5, 0xd9, 0x66, 0xd9, 0xe, 0xef, 0x46, 0x42, 0xfb, 0x18}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x29, 0xfe, 0x3d, 0xc6, 0x27, 0x4a, 0x11, 0x11, 0x24, 0xd2, 0x61, 0x76, 0x9e, 0x6d, 0xa2, 0x29, 0x92, 0x84, 0xe0, 0xbf, 0xa, 0xe8, 0x91}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x42, 0x4b, 0xe4, 0xd1, 0xc4, 0x9c, 0x8c, 0xf4, 0x3f, 0x32, 0x90, 0x1f, 0x50, 0x33, 0x7a, 0x32, 0x2e, 0x2e, 0x12, 0x60, 0x81, 0x44}; + lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xe, 0x9a}; + lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; +lwmqtt_sub_options_t sub_opts[9]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[0].retain_as_published = true; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = true; +sub_opts[4].qos = LWMQTT_QOS0; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[4].retain_as_published = true; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = true; +sub_opts[6].qos = LWMQTT_QOS0; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = false; +sub_opts[6].no_local = true; +sub_opts[7].qos = LWMQTT_QOS0; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = true; +sub_opts[7].no_local = false; +sub_opts[8].qos = LWMQTT_QOS1; +sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[8].retain_as_published = true; +sub_opts[8].no_local = false; + uint8_t bytesprops0[] = {0xb9, 0x4b, 0xd, 0xec, 0x76, 0x31, 0xce, 0x22}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24247}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16175}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32751, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11000, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 9203 [("\220\237 -// \185\218f\186\169G-\SYNR\157\129k\146\142\187\249\223Vy\168X\214\209B\212\ETX\183",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("7t\b,\195X\ETB\163\b\239\189\161%<\186M\148Ge\DC1",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\214\204\149U\228E\GS\"\154\138tn6\214\212\252\GS\221\192",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\193\225~tM*M\ETX\160!",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("!\SI\216\183\f1\167N7\226\168",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS1}),("\141\196\137sYG3\148\203O\177",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\n8\154\150]\ETX\218\235H",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS1})] [PropReasonString "\n\179\153\206j\235Q\NAKI,\184",PropMaximumPacketSize -// 13450,PropResponseTopic "\NUL\222,2\155\&3\a\SOH7\149\ETB\STX\199\&3\210\195\ETX\140\156\240\129",PropRetainAvailable -// 148,PropServerReference "*=3y\219\157\&5\SYN\ETB\135\132M?r\130\226\254\143\250",PropAssignedClientIdentifier -// "\t\bw\175[\SOr`\222\173lWK\143",PropSessionExpiryInterval 28089,PropResponseInformation -// "wi\210\173\141\239\DC2\b\135U=!\217\185\243\187(\EM\154<",PropCorrelationData -// "\166\218\156\237bLsm\"\EM",PropCorrelationData -// "\162\GS\192\157\162\SIFI\159|\148\220\&5\130\GS1\190\209.\DC2T2\216\r",PropMessageExpiryInterval -// 30374,PropWildcardSubscriptionAvailable 50,PropTopicAlias 21419,PropTopicAliasMaximum 32476] -TEST(Subscribe5QCTest, Encode4) { - uint8_t pkt[] = { - 0x82, 0xac, 0x2, 0x23, 0xf3, 0xa5, 0x1, 0x1f, 0x0, 0xb, 0xa, 0xb3, 0x99, 0xce, 0x6a, 0xeb, 0x51, 0x15, 0x49, - 0x2c, 0xb8, 0x27, 0x0, 0x0, 0x34, 0x8a, 0x8, 0x0, 0x15, 0x0, 0xde, 0x2c, 0x32, 0x9b, 0x33, 0x7, 0x1, 0x37, - 0x95, 0x17, 0x2, 0xc7, 0x33, 0xd2, 0xc3, 0x3, 0x8c, 0x9c, 0xf0, 0x81, 0x25, 0x94, 0x1c, 0x0, 0x13, 0x2a, 0x3d, - 0x33, 0x79, 0xdb, 0x9d, 0x35, 0x16, 0x17, 0x87, 0x84, 0x4d, 0x3f, 0x72, 0x82, 0xe2, 0xfe, 0x8f, 0xfa, 0x12, 0x0, - 0xe, 0x9, 0x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x21, - 0xf, 0xd8, 0xb7, 0xc, 0x31, 0xa7, 0x4e, 0x37, 0xe2, 0xa8, 0x25, 0x0, 0xb, 0x8d, 0xc4, 0x89, 0x73, 0x59, 0x47, - 0x33, 0x94, 0xcb, 0x4f, 0xb1, 0x1d, 0x0, 0x9, 0xa, 0x38, 0x9a, 0x96, 0x5d, 0x3, 0xda, 0xeb, 0x48, 0xd}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xdc, 0xed, 0x20, 0xb9, 0xda, 0x66, 0xba, 0xa9, 0x47, 0x2d, - 0x16, 0x52, 0x9d, 0x81, 0x6b, 0x92, 0x8e, 0xbb, 0xf9, 0xdf, - 0x56, 0x79, 0xa8, 0x58, 0xd6, 0xd1, 0x42, 0xd4, 0x3, 0xb7}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x37, 0x74, 0x8, 0x2c, 0xc3, 0x58, 0x17, 0xa3, 0x8, 0xef, - 0xbd, 0xa1, 0x25, 0x3c, 0xba, 0x4d, 0x94, 0x47, 0x65, 0x11}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd6, 0xcc, 0x95, 0x55, 0xe4, 0x45, 0x1d, 0x22, 0x9a, 0x8a, - 0x74, 0x6e, 0x36, 0xd6, 0xd4, 0xfc, 0x1d, 0xdd, 0xc0}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc1, 0xe1, 0x7e, 0x74, 0x4d, 0x2a, 0x4d, 0x3, 0xa0, 0x21}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x21, 0xf, 0xd8, 0xb7, 0xc, 0x31, 0xa7, 0x4e, 0x37, 0xe2, 0xa8}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8d, 0xc4, 0x89, 0x73, 0x59, 0x47, 0x33, 0x94, 0xcb, 0x4f, 0xb1}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa, 0x38, 0x9a, 0x96, 0x5d, 0x3, 0xda, 0xeb, 0x48}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; - uint8_t bytesprops0[] = {0xa, 0xb3, 0x99, 0xce, 0x6a, 0xeb, 0x51, 0x15, 0x49, 0x2c, 0xb8}; - uint8_t bytesprops1[] = {0x0, 0xde, 0x2c, 0x32, 0x9b, 0x33, 0x7, 0x1, 0x37, 0x95, 0x17, - 0x2, 0xc7, 0x33, 0xd2, 0xc3, 0x3, 0x8c, 0x9c, 0xf0, 0x81}; - uint8_t bytesprops2[] = {0x2a, 0x3d, 0x33, 0x79, 0xdb, 0x9d, 0x35, 0x16, 0x17, 0x87, - 0x84, 0x4d, 0x3f, 0x72, 0x82, 0xe2, 0xfe, 0x8f, 0xfa}; - uint8_t bytesprops3[] = {0x9, 0x8, 0x77, 0xaf, 0x5b, 0xe, 0x72, 0x60, 0xde, 0xad, 0x6c, 0x57, 0x4b, 0x8f}; - uint8_t bytesprops4[] = {0x77, 0x69, 0xd2, 0xad, 0x8d, 0xef, 0x12, 0x8, 0x87, 0x55, - 0x3d, 0x21, 0xd9, 0xb9, 0xf3, 0xbb, 0x28, 0x19, 0x9a, 0x3c}; - uint8_t bytesprops5[] = {0xa6, 0xda, 0x9c, 0xed, 0x62, 0x4c, 0x73, 0x6d, 0x22, 0x19}; - uint8_t bytesprops6[] = {0xa2, 0x1d, 0xc0, 0x9d, 0xa2, 0xf, 0x46, 0x49, 0x9f, 0x7c, 0x94, 0xdc, - 0x35, 0x82, 0x1d, 0x31, 0xbe, 0xd1, 0x2e, 0x12, 0x54, 0x32, 0xd8, 0xd}; +// SubscribeRequest 21792 [("6\208Y0\251\199\EM",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("GX\147{(\182\223\141\GSB;\164\153/\133\DC2s",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropSubscriptionIdentifier 6,PropTopicAliasMaximum 11050,PropAssignedClientIdentifier "\GS\236\&8\194\187\187\209\221\&2S\177J\231\&7\ESC\177s\CAN\134\158H\136\229\215\t\EM\RS\r\STX"] +TEST(Subscribe5QCTest, Encode4) { +uint8_t pkt[] = {0x82, 0x46, 0x55, 0x20, 0x25, 0xb, 0x6, 0x22, 0x2b, 0x2a, 0x12, 0x0, 0x1d, 0x1d, 0xec, 0x38, 0xc2, 0xbb, 0xbb, 0xd1, 0xdd, 0x32, 0x53, 0xb1, 0x4a, 0xe7, 0x37, 0x1b, 0xb1, 0x73, 0x18, 0x86, 0x9e, 0x48, 0x88, 0xe5, 0xd7, 0x9, 0x19, 0x1e, 0xd, 0x2, 0x0, 0x7, 0x36, 0xd0, 0x59, 0x30, 0xfb, 0xc7, 0x19, 0x21, 0x0, 0x11, 0x47, 0x58, 0x93, 0x7b, 0x28, 0xb6, 0xdf, 0x8d, 0x1d, 0x42, 0x3b, 0xa4, 0x99, 0x2f, 0x85, 0x12, 0x73, 0x11}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x36, 0xd0, 0x59, 0x30, 0xfb, 0xc7, 0x19}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x47, 0x58, 0x93, 0x7b, 0x28, 0xb6, 0xdf, 0x8d, 0x1d, 0x42, 0x3b, 0xa4, 0x99, 0x2f, 0x85, 0x12, 0x73}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; +lwmqtt_sub_options_t sub_opts[2]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; + uint8_t bytesprops0[] = {0x1d, 0xec, 0x38, 0xc2, 0xbb, 0xbb, 0xd1, 0xdd, 0x32, 0x53, 0xb1, 0x4a, 0xe7, 0x37, 0x1b, 0xb1, 0x73, 0x18, 0x86, 0x9e, 0x48, 0x88, 0xe5, 0xd7, 0x9, 0x19, 0x1e, 0xd, 0x2}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13450}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28089}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30374}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21419}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32476}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11050}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9203, 7, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21792, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 7433 [("#\207",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS2}),("\150",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS0}),("\236",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS1}),("\193\250\200\202",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\237c\182\248?\181\241\171\158",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\189A\203\SYNq\144\&2\237\196d\226s\192\SUB",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("h\187\a\196\RS\\\235\216\SOH\fv3",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("/\185l>/\134\246\153\EOT\237\&5\v\213\STX\138\EOT\211a",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\DC4\STX\211\a-\145",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropSessionExpiryInterval -// 30141,PropSessionExpiryInterval 5579,PropRequestProblemInformation 110,PropRequestResponseInformation -// 9,PropResponseTopic "\ngq\235\NULZ\215n\221\154\171B\147",PropResponseInformation "My\133",PropServerReference -// "\195\130\175\208\156\189\194\183W\243\151f",PropResponseTopic "\246\248M'\DC3",PropRetainAvailable -// 235,PropRequestResponseInformation 66,PropSubscriptionIdentifier 8,PropMaximumQoS 144,PropMessageExpiryInterval -// 27935,PropUserProperty -// "\237\218\146\136\247\179\226\233%\t\208\244\GS5l\r&\141\180\220)\t\ENQS\155\160\217\214\204\GS" "\192\193"] -TEST(Subscribe5QCTest, Encode5) { - uint8_t pkt[] = { - 0x82, 0xce, 0x1, 0x1d, 0x9, 0x6d, 0x11, 0x0, 0x0, 0x75, 0xbd, 0x11, 0x0, 0x0, 0x15, 0xcb, 0x17, 0x6e, 0x19, - 0x9, 0x8, 0x0, 0xd, 0xa, 0x67, 0x71, 0xeb, 0x0, 0x5a, 0xd7, 0x6e, 0xdd, 0x9a, 0xab, 0x42, 0x93, 0x1a, 0x0, - 0x3, 0x4d, 0x79, 0x85, 0x1c, 0x0, 0xc, 0xc3, 0x82, 0xaf, 0xd0, 0x9c, 0xbd, 0xc2, 0xb7, 0x57, 0xf3, 0x97, 0x66, - 0x8, 0x0, 0x5, 0xf6, 0xf8, 0x4d, 0x27, 0x13, 0x25, 0xeb, 0x19, 0x42, 0xb, 0x8, 0x24, 0x90, 0x2, 0x0, 0x0, - 0x6d, 0x1f, 0x26, 0x0, 0x1e, 0xed, 0xda, 0x92, 0x88, 0xf7, 0xb3, 0xe2, 0xe9, 0x25, 0x9, 0xd0, 0xf4, 0x1d, 0x35, - 0x6c, 0xd, 0x26, 0x8d, 0xb4, 0xdc, 0x29, 0x9, 0x5, 0x53, 0x9b, 0xa0, 0xd9, 0xd6, 0xcc, 0x1d, 0x0, 0x2, 0xc0, - 0xc1, 0x0, 0x2, 0x23, 0xcf, 0x6, 0x0, 0x1, 0x96, 0x10, 0x0, 0x1, 0xec, 0x2d, 0x0, 0x4, 0xc1, 0xfa, 0xc8, - 0xca, 0x1e, 0x0, 0x9, 0xed, 0x63, 0xb6, 0xf8, 0x3f, 0xb5, 0xf1, 0xab, 0x9e, 0x2e, 0x0, 0xe, 0xbd, 0x41, 0xcb, - 0x16, 0x71, 0x90, 0x32, 0xed, 0xc4, 0x64, 0xe2, 0x73, 0xc0, 0x1a, 0x12, 0x0, 0xc, 0x68, 0xbb, 0x7, 0xc4, 0x1e, - 0x5c, 0xeb, 0xd8, 0x1, 0xc, 0x76, 0x33, 0x1, 0x0, 0x12, 0x2f, 0xb9, 0x6c, 0x3e, 0x2f, 0x86, 0xf6, 0x99, 0x4, - 0xed, 0x35, 0xb, 0xd5, 0x2, 0x8a, 0x4, 0xd3, 0x61, 0x2d, 0x0, 0x6, 0x14, 0x2, 0xd3, 0x7, 0x2d, 0x91, 0x26}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x23, 0xcf}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x96}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xec}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc1, 0xfa, 0xc8, 0xca}; - lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xed, 0x63, 0xb6, 0xf8, 0x3f, 0xb5, 0xf1, 0xab, 0x9e}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xbd, 0x41, 0xcb, 0x16, 0x71, 0x90, 0x32, - 0xed, 0xc4, 0x64, 0xe2, 0x73, 0xc0, 0x1a}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x68, 0xbb, 0x7, 0xc4, 0x1e, 0x5c, 0xeb, 0xd8, 0x1, 0xc, 0x76, 0x33}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x2f, 0xb9, 0x6c, 0x3e, 0x2f, 0x86, 0xf6, 0x99, 0x4, - 0xed, 0x35, 0xb, 0xd5, 0x2, 0x8a, 0x4, 0xd3, 0x61}; - lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x14, 0x2, 0xd3, 0x7, 0x2d, 0x91}; - lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; - uint8_t bytesprops0[] = {0xa, 0x67, 0x71, 0xeb, 0x0, 0x5a, 0xd7, 0x6e, 0xdd, 0x9a, 0xab, 0x42, 0x93}; - uint8_t bytesprops1[] = {0x4d, 0x79, 0x85}; - uint8_t bytesprops2[] = {0xc3, 0x82, 0xaf, 0xd0, 0x9c, 0xbd, 0xc2, 0xb7, 0x57, 0xf3, 0x97, 0x66}; - uint8_t bytesprops3[] = {0xf6, 0xf8, 0x4d, 0x27, 0x13}; - uint8_t bytesprops5[] = {0xc0, 0xc1}; - uint8_t bytesprops4[] = {0xed, 0xda, 0x92, 0x88, 0xf7, 0xb3, 0xe2, 0xe9, 0x25, 0x9, 0xd0, 0xf4, 0x1d, 0x35, 0x6c, - 0xd, 0x26, 0x8d, 0xb4, 0xdc, 0x29, 0x9, 0x5, 0x53, 0x9b, 0xa0, 0xd9, 0xd6, 0xcc, 0x1d}; +// SubscribeRequest 20269 [("\220\133\254]\185%\213_\189\199t$[\170m\232m\SOf3c\226",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropAssignedClientIdentifier "\194n\183\206\180\237Qv\155\133\NAKGE\158\135\"Dn\200\RSe\246\224N>N\217k",PropAssignedClientIdentifier "w\ETXh\244\160\&3\234\205\235Bq",PropMaximumPacketSize 15446,PropSessionExpiryInterval 5053,PropContentType "F\216GO\237\212\244#",PropAuthenticationMethod "",PropSubscriptionIdentifierAvailable 116,PropReceiveMaximum 19775,PropSubscriptionIdentifierAvailable 85,PropWildcardSubscriptionAvailable 61,PropResponseTopic "\t",PropRequestResponseInformation 152,PropServerKeepAlive 7792,PropAssignedClientIdentifier "\195\201\132",PropRequestResponseInformation 241,PropServerKeepAlive 9998,PropMaximumPacketSize 7241,PropSessionExpiryInterval 9777,PropSubscriptionIdentifierAvailable 184,PropResponseTopic "\142F\DC1\212\ESC\236j8",PropRequestResponseInformation 237,PropContentType "\DC2\US\RS\178\US\152\DC1\225\205\n\140\191\153\188q\159\152\174\&9\132\208\235\196\ESC\199\NUL",PropResponseInformation "$\211\243#\n:)L\169S",PropMaximumPacketSize 13967,PropRequestProblemInformation 31,PropAuthenticationData "\tgj\146\166\193\&9\212LhA{\b>",PropReceiveMaximum 17429,PropAuthenticationData "#\203>\CANSd\205+\CAN",PropSessionExpiryInterval 1396] +TEST(Subscribe5QCTest, Encode5) { +uint8_t pkt[] = {0x82, 0xee, 0x1, 0x4f, 0x2d, 0xd1, 0x1, 0x12, 0x0, 0x1c, 0xc2, 0x6e, 0xb7, 0xce, 0xb4, 0xed, 0x51, 0x76, 0x9b, 0x85, 0x15, 0x47, 0x45, 0x9e, 0x87, 0x22, 0x44, 0x6e, 0xc8, 0x1e, 0x65, 0xf6, 0xe0, 0x4e, 0x3e, 0x4e, 0xd9, 0x6b, 0x12, 0x0, 0xb, 0x77, 0x3, 0x68, 0xf4, 0xa0, 0x33, 0xea, 0xcd, 0xeb, 0x42, 0x71, 0x27, 0x0, 0x0, 0x3c, 0x56, 0x11, 0x0, 0x0, 0x13, 0xbd, 0x3, 0x0, 0x8, 0x46, 0xd8, 0x47, 0x4f, 0xed, 0xd4, 0xf4, 0x23, 0x15, 0x0, 0x0, 0x29, 0x74, 0x21, 0x4d, 0x3f, 0x29, 0x55, 0x28, 0x3d, 0x8, 0x0, 0x1, 0x9, 0x19, 0x98, 0x13, 0x1e, 0x70, 0x12, 0x0, 0x3, 0xc3, 0xc9, 0x84, 0x19, 0xf1, 0x13, 0x27, 0xe, 0x27, 0x0, 0x0, 0x1c, 0x49, 0x11, 0x0, 0x0, 0x26, 0x31, 0x29, 0xb8, 0x8, 0x0, 0x8, 0x8e, 0x46, 0x11, 0xd4, 0x1b, 0xec, 0x6a, 0x38, 0x19, 0xed, 0x3, 0x0, 0x1a, 0x12, 0x1f, 0x1e, 0xb2, 0x1f, 0x98, 0x11, 0xe1, 0xcd, 0xa, 0x8c, 0xbf, 0x99, 0xbc, 0x71, 0x9f, 0x98, 0xae, 0x39, 0x84, 0xd0, 0xeb, 0xc4, 0x1b, 0xc7, 0x0, 0x1a, 0x0, 0xa, 0x24, 0xd3, 0xf3, 0x23, 0xa, 0x3a, 0x29, 0x4c, 0xa9, 0x53, 0x27, 0x0, 0x0, 0x36, 0x8f, 0x17, 0x1f, 0x16, 0x0, 0xe, 0x9, 0x67, 0x6a, 0x92, 0xa6, 0xc1, 0x39, 0xd4, 0x4c, 0x68, 0x41, 0x7b, 0x8, 0x3e, 0x21, 0x44, 0x15, 0x16, 0x0, 0x9, 0x23, 0xcb, 0x3e, 0x18, 0x53, 0x64, 0xcd, 0x2b, 0x18, 0x11, 0x0, 0x0, 0x5, 0x74, 0x0, 0x16, 0xdc, 0x85, 0xfe, 0x5d, 0xb9, 0x25, 0xd5, 0x5f, 0xbd, 0xc7, 0x74, 0x24, 0x5b, 0xaa, 0x6d, 0xe8, 0x6d, 0xe, 0x66, 0x33, 0x63, 0xe2, 0x29}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xdc, 0x85, 0xfe, 0x5d, 0xb9, 0x25, 0xd5, 0x5f, 0xbd, 0xc7, 0x74, 0x24, 0x5b, 0xaa, 0x6d, 0xe8, 0x6d, 0xe, 0x66, 0x33, 0x63, 0xe2}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; +lwmqtt_sub_options_t sub_opts[1]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[0].retain_as_published = true; +sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0xc2, 0x6e, 0xb7, 0xce, 0xb4, 0xed, 0x51, 0x76, 0x9b, 0x85, 0x15, 0x47, 0x45, 0x9e, 0x87, 0x22, 0x44, 0x6e, 0xc8, 0x1e, 0x65, 0xf6, 0xe0, 0x4e, 0x3e, 0x4e, 0xd9, 0x6b}; + uint8_t bytesprops1[] = {0x77, 0x3, 0x68, 0xf4, 0xa0, 0x33, 0xea, 0xcd, 0xeb, 0x42, 0x71}; + uint8_t bytesprops2[] = {0x46, 0xd8, 0x47, 0x4f, 0xed, 0xd4, 0xf4, 0x23}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x9}; + uint8_t bytesprops5[] = {0xc3, 0xc9, 0x84}; + uint8_t bytesprops6[] = {0x8e, 0x46, 0x11, 0xd4, 0x1b, 0xec, 0x6a, 0x38}; + uint8_t bytesprops7[] = {0x12, 0x1f, 0x1e, 0xb2, 0x1f, 0x98, 0x11, 0xe1, 0xcd, 0xa, 0x8c, 0xbf, 0x99, 0xbc, 0x71, 0x9f, 0x98, 0xae, 0x39, 0x84, 0xd0, 0xeb, 0xc4, 0x1b, 0xc7, 0x0}; + uint8_t bytesprops8[] = {0x24, 0xd3, 0xf3, 0x23, 0xa, 0x3a, 0x29, 0x4c, 0xa9, 0x53}; + uint8_t bytesprops9[] = {0x9, 0x67, 0x6a, 0x92, 0xa6, 0xc1, 0x39, 0xd4, 0x4c, 0x68, 0x41, 0x7b, 0x8, 0x3e}; + uint8_t bytesprops10[] = {0x23, 0xcb, 0x3e, 0x18, 0x53, 0x64, 0xcd, 0x2b, 0x18}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30141}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5579}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27935}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15446}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5053}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19775}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7792}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9998}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7241}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9777}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13967}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17429}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1396}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7433, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20269, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 22949 [("\139\231\DC1\195J*\243\226Ip\ENQ\158\195U\2549d\234/%\170N&\242h\234\206\134\134",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("%\217\254\154\133h\199\ACKo%\128\253;_D\137\226\\\175\&9\138\&5\241B\a2\212",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\241\189ww\ETX\164\226",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("E\180D\152\180\232\246\212\187U\138\209\197\193\160\DC4\164j{\130\253\170",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\201mH\219\192\STX\SUB{H\142Q#",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS0}),("\213\210",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\ENQ]",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropRequestResponseInformation -// 59,PropTopicAlias 944,PropReceiveMaximum 13237,PropTopicAliasMaximum 23923,PropRetainAvailable 252,PropContentType -// "",PropContentType -// "\141\179\244\230`@\DC3\220\213C\SYN\244\SYN\145\188\247U\254\134,\147yK\248)",PropSubscriptionIdentifier -// 5,PropMaximumPacketSize 6461,PropServerReference "?d\DLE\208\168\225\233\188\206",PropSubscriptionIdentifier -// 26,PropAssignedClientIdentifier "*\241\203\230\219LeU\139",PropWildcardSubscriptionAvailable -// 4,PropMessageExpiryInterval 1918,PropMessageExpiryInterval 4697,PropAuthenticationData -// "\135\234\147c[\170>\244\152\193!#\v\SOH\140O\r\244",PropMaximumQoS 63,PropReceiveMaximum 7339,PropTopicAlias -// 1259,PropSessionExpiryInterval 8341] -TEST(Subscribe5QCTest, Encode9) { - uint8_t pkt[] = { - 0x82, 0xad, 0x2, 0x76, 0xaa, 0x7b, 0x19, 0x3b, 0x23, 0x3, 0xb0, 0x21, 0x33, 0xb5, 0x22, 0x5d, 0x73, 0x25, 0xfc, - 0x3, 0x0, 0x0, 0x3, 0x0, 0x19, 0x8d, 0xb3, 0xf4, 0xe6, 0x60, 0x40, 0x13, 0xdc, 0xd5, 0x43, 0x16, 0xf4, 0x16, - 0x91, 0xbc, 0xf7, 0x55, 0xfe, 0x86, 0x2c, 0x93, 0x79, 0x4b, 0xf8, 0x29, 0xb, 0x5, 0x27, 0x0, 0x0, 0x19, 0x3d, - 0x1c, 0x0, 0x9, 0x3f, 0x64, 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0x77, 0x3, 0xa4, 0xe2, 0x15, 0x0, 0x16, 0x45, 0xb4, 0x44, 0x98, 0xb4, 0xe8, 0xf6, 0xd4, 0xbb, 0x55, - 0x8a, 0xd1, 0xc5, 0xc1, 0xa0, 0x14, 0xa4, 0x6a, 0x7b, 0x82, 0xfd, 0xaa, 0x29, 0x0, 0xc, 0xc9, 0x6d, 0x48, 0xdb, - 0xc0, 0x2, 0x1a, 0x7b, 0x48, 0x8e, 0x51, 0x23, 0x24, 0x0, 0x2, 0xd5, 0xd2, 0x20, 0x0, 0x2, 0x5, 0x5d, 0x2a}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xc5, 0xb4, 0x20}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xde, 0xaa, 0x0, 0x75, 0x5b, 0x90, 0xbc, 0xd, 0xf3, 0x13, - 0x17, 0xf5, 0x3a, 0x3c, 0x5e, 0x59, 0xf7, 0x45, 0x57, 0xb0, - 0x57, 0x9a, 0x39, 0x66, 0xe8, 0x8, 0x7, 0x9b}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2e, 0x93, 0x7b, 0x3c, 0xf7, 0xb4, 0x51, 0xca, 0x54, 0x2e, 0xc, 0xb9, - 0x86, 0x3e, 0x13, 0x6e, 0x27, 0x54, 0x1c, 0xe6, 0xc9, 0xb2, 0x7d, 0x41}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3e, 0x39, 0x64, 0xea, 0x2f, 0x25, 0xaa, 0x4e, - 0x26, 0xf2, 0x68, 0xea, 0xce, 0x86, 0x86}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x25, 0xd9, 0xfe, 0x9a, 0x85, 0x68, 0xc7, 0x6, 0x6f, 0x25, 0x80, 0xfd, 0x3b, 0x5f, - 0x44, 0x89, 0xe2, 0x5c, 0xaf, 0x39, 0x8a, 0x35, 0xf1, 0x42, 0x7, 0x32, 0xd4}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf1, 0xbd, 0x77, 0x77, 0x3, 0xa4, 0xe2}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x45, 0xb4, 0x44, 0x98, 0xb4, 0xe8, 0xf6, 0xd4, 0xbb, 0x55, 0x8a, - 0xd1, 0xc5, 0xc1, 0xa0, 0x14, 0xa4, 0x6a, 0x7b, 0x82, 0xfd, 0xaa}; - lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc9, 0x6d, 0x48, 0xdb, 0xc0, 0x2, 0x1a, 0x7b, 0x48, 0x8e, 0x51, 0x23}; - lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xd5, 0xd2}; - lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x5, 0x5d}; - lwmqtt_string_t topic_filter_s10 = {2, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[10].retain_as_published = true; - sub_opts[10].no_local = false; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x8d, 0xb3, 0xf4, 0xe6, 0x60, 0x40, 0x13, 0xdc, 0xd5, 0x43, 0x16, 0xf4, 0x16, - 0x91, 0xbc, 0xf7, 0x55, 0xfe, 0x86, 0x2c, 0x93, 0x79, 0x4b, 0xf8, 0x29}; - uint8_t bytesprops2[] = {0x3f, 0x64, 0x10, 0xd0, 0xa8, 0xe1, 0xe9, 0xbc, 0xce}; - uint8_t bytesprops3[] = {0x2a, 0xf1, 0xcb, 0xe6, 0xdb, 0x4c, 0x65, 0x55, 0x8b}; - uint8_t bytesprops4[] = {0x87, 0xea, 0x93, 0x63, 0x5b, 0xaa, 0x3e, 0xf4, 0x98, - 0xc1, 0x21, 0x23, 0xb, 0x1, 0x8c, 0x4f, 0xd, 0xf4}; +// SubscribeRequest 15465 [("\234y<\176R ]*\193\136",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\DC3v\b\SOH9",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("6'\ACK}p\CAN\144g\147~\200\182&\173\176\128%ev\142\SIT\254\138\&1h\US\169\210R",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropWillDelayInterval 2288,PropCorrelationData "\211\FS\ACK&\a\251\EOT\184RW\193l8K\249",PropAuthenticationMethod "\158N2 qL\156\209\141.\218{\137\206\234\159F(\187\195\215\246k2\139\177",PropCorrelationData "\251\\\SYN\244\&7\208\199\248\t\170\&5\146\155\172j\231\177\137\211\ETBK\136\SOH\133",PropPayloadFormatIndicator 176,PropMaximumPacketSize 8470,PropCorrelationData "^\243\179\128\DC4M.bt\r\186.",PropAuthenticationData "K\185\137\&9\155Sa\FS\199k\200R.\142y\158\158]\220\188\STX\r=\RS\185"] +TEST(Subscribe5QCTest, Encode9) { +uint8_t pkt[] = {0x82, 0xbb, 0x1, 0x3c, 0x69, 0x81, 0x1, 0x18, 0x0, 0x0, 0x8, 0xf0, 0x9, 0x0, 0xf, 0xd3, 0x1c, 0x6, 0x26, 0x7, 0xfb, 0x4, 0xb8, 0x52, 0x57, 0xc1, 0x6c, 0x38, 0x4b, 0xf9, 0x15, 0x0, 0x1a, 0x9e, 0x4e, 0x32, 0x20, 0x71, 0x4c, 0x9c, 0xd1, 0x8d, 0x2e, 0xda, 0x7b, 0x89, 0xce, 0xea, 0x9f, 0x46, 0x28, 0xbb, 0xc3, 0xd7, 0xf6, 0x6b, 0x32, 0x8b, 0xb1, 0x9, 0x0, 0x18, 0xfb, 0x5c, 0x16, 0xf4, 0x37, 0xd0, 0xc7, 0xf8, 0x9, 0xaa, 0x35, 0x92, 0x9b, 0xac, 0x6a, 0xe7, 0xb1, 0x89, 0xd3, 0x17, 0x4b, 0x88, 0x1, 0x85, 0x1, 0xb0, 0x27, 0x0, 0x0, 0x21, 0x16, 0x9, 0x0, 0xc, 0x5e, 0xf3, 0xb3, 0x80, 0x14, 0x4d, 0x2e, 0x62, 0x74, 0xd, 0xba, 0x2e, 0x16, 0x0, 0x19, 0x4b, 0xb9, 0x89, 0x39, 0x9b, 0x53, 0x61, 0x1c, 0xc7, 0x6b, 0xc8, 0x52, 0x2e, 0x8e, 0x79, 0x9e, 0x9e, 0x5d, 0xdc, 0xbc, 0x2, 0xd, 0x3d, 0x1e, 0xb9, 0x0, 0xa, 0xea, 0x79, 0x3c, 0xb0, 0x52, 0x20, 0x5d, 0x2a, 0xc1, 0x88, 0x11, 0x0, 0x5, 0x13, 0x76, 0x8, 0x1, 0x39, 0x25, 0x0, 0x1e, 0x36, 0x27, 0x6, 0x7d, 0x70, 0x18, 0x90, 0x67, 0x93, 0x7e, 0xc8, 0xb6, 0x26, 0xad, 0xb0, 0x80, 0x25, 0x65, 0x76, 0x8e, 0xf, 0x54, 0xfe, 0x8a, 0x31, 0x68, 0x1f, 0xa9, 0xd2, 0x52, 0x1c}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xea, 0x79, 0x3c, 0xb0, 0x52, 0x20, 0x5d, 0x2a, 0xc1, 0x88}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x13, 0x76, 0x8, 0x1, 0x39}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x36, 0x27, 0x6, 0x7d, 0x70, 0x18, 0x90, 0x67, 0x93, 0x7e, 0xc8, 0xb6, 0x26, 0xad, 0xb0, 0x80, 0x25, 0x65, 0x76, 0x8e, 0xf, 0x54, 0xfe, 0x8a, 0x31, 0x68, 0x1f, 0xa9, 0xd2, 0x52}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; +lwmqtt_sub_options_t sub_opts[3]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = true; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[2].retain_as_published = true; +sub_opts[2].no_local = true; + uint8_t bytesprops0[] = {0xd3, 0x1c, 0x6, 0x26, 0x7, 0xfb, 0x4, 0xb8, 0x52, 0x57, 0xc1, 0x6c, 0x38, 0x4b, 0xf9}; + uint8_t bytesprops1[] = {0x9e, 0x4e, 0x32, 0x20, 0x71, 0x4c, 0x9c, 0xd1, 0x8d, 0x2e, 0xda, 0x7b, 0x89, 0xce, 0xea, 0x9f, 0x46, 0x28, 0xbb, 0xc3, 0xd7, 0xf6, 0x6b, 0x32, 0x8b, 0xb1}; + uint8_t bytesprops2[] = {0xfb, 0x5c, 0x16, 0xf4, 0x37, 0xd0, 0xc7, 0xf8, 0x9, 0xaa, 0x35, 0x92, 0x9b, 0xac, 0x6a, 0xe7, 0xb1, 0x89, 0xd3, 0x17, 0x4b, 0x88, 0x1, 0x85}; + uint8_t bytesprops3[] = {0x5e, 0xf3, 0xb3, 0x80, 0x14, 0x4d, 0x2e, 0x62, 0x74, 0xd, 0xba, 0x2e}; + uint8_t bytesprops4[] = {0x4b, 0xb9, 0x89, 0x39, 0x9b, 0x53, 0x61, 0x1c, 0xc7, 0x6b, 0xc8, 0x52, 0x2e, 0x8e, 0x79, 0x9e, 0x9e, 0x5d, 0xdc, 0xbc, 0x2, 0xd, 0x3d, 0x1e, 0xb9}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 944}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13237}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23923}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6461}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1918}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4697}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7339}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1259}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8341}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2288}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8470}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30378, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15465, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 19363 [("\171\&6)kL\250\200\246\241\214\221\252\198\159`\172N\210\247r\234Q1",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("5\204P\216\&3\131s\130\148\&8\DC4t\225\207\132 -// \160\151\204o\EOT_\GS",PropSubscriptionIdentifierAvailable 144,PropSessionExpiryInterval 8274,PropCorrelationData -// "%\ETX\202l9\220V,`\241\205\243u\FS\ETX\179z\172\241\174\128y\CANR\247",PropMaximumQoS 99,PropAuthenticationMethod -// "\206@`\200\221\GS",PropMessageExpiryInterval 32660] -TEST(Subscribe5QCTest, Encode10) { - uint8_t pkt[] = { - 0x82, 0xc1, 0x2, 0x4b, 0xa3, 0xd5, 0x1, 0x1c, 0x0, 0x1d, 0x31, 0x91, 0xba, 0x7e, 0xca, 0xa2, 0x9c, 0xf2, - 0xea, 0xdf, 0x7d, 0xf1, 0x88, 0x57, 0xd7, 0x7d, 0x4f, 0x17, 0x6e, 0xe2, 0x2, 0xe4, 0xaa, 0x27, 0x0, 0xfa, - 0x55, 0x56, 0xe9, 0x29, 0x8f, 0x15, 0x0, 0x1e, 0x3f, 0xc1, 0xdc, 0x14, 0xc3, 0xdf, 0x4e, 0xc0, 0xf6, 0x78, - 0xf6, 0x3a, 0x3c, 0x4b, 0x9d, 0x49, 0xd0, 0xcc, 0x36, 0xca, 0xf1, 0x4a, 0xc9, 0xd2, 0xbb, 0x9f, 0xbc, 0x38, - 0x1b, 0x88, 0x24, 0xa7, 0x2a, 0xc9, 0x24, 0x28, 0x23, 0x7c, 0x8a, 0x15, 0x0, 0x1c, 0x5f, 0xaf, 0x0, 0xa8, - 0x7d, 0x4d, 0xdc, 0x73, 0x8e, 0xef, 0x7f, 0x3, 0xcb, 0xd6, 0xe3, 0xcf, 0x0, 0x46, 0xba, 0xd4, 0xb9, 0xd0, - 0xd4, 0x88, 0x47, 0x1f, 0x91, 0xad, 0x1f, 0x0, 0x5, 0xe2, 0x3b, 0x8, 0x61, 0x44, 0x2, 0x0, 0x0, 0x4, - 0xe4, 0x15, 0x0, 0x3, 0xd, 0x5b, 0xe,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, 0xe5, 0xab, 0x24}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xab, 0x36, 0x29, 0x6b, 0x4c, 0xfa, 0xc8, 0xf6, 0xf1, 0xd6, 0xdd, 0xfc, - 0xc6, 0x9f, 0x60, 0xac, 0x4e, 0xd2, 0xf7, 0x72, 0xea, 0x51, 0x31}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x35, 0xcc, 0x50, 0xd8, 0x33, 0x83, 0x73, 0x82, - 0x3c, 0x55, 0xd1, 0x61, 0x88, 0xb7, 0x83}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x51, 0x55, 0xa8, 0x16, 0xc7}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf7, 0xec, 0x3b, 0xe5, 0x39, 0x85, 0xad, 0xd0, 0xd5, 0x54, 0xe8, 0xea, - 0x25, 0xe, 0x48, 0x9d, 0xc1, 0xf7, 0xad, 0x13, 0xa2, 0x18, 0xd7}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4c, 0x77, 0x1, 0xae, 0xdf, 0xfd, 0x7d, 0x68}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xbc, 0x9c, 0x10, 0x93, 0xba, 0x3b, 0x4a, 0xca, 0x3c, 0xec, 0xe5, 0xab}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - uint8_t bytesprops0[] = {0x31, 0x91, 0xba, 0x7e, 0xca, 0xa2, 0x9c, 0xf2, 0xea, 0xdf, 0x7d, 0xf1, 0x88, 0x57, 0xd7, - 0x7d, 0x4f, 0x17, 0x6e, 0xe2, 0x2, 0xe4, 0xaa, 0x27, 0x0, 0xfa, 0x55, 0x56, 0xe9}; - uint8_t bytesprops1[] = {0x3f, 0xc1, 0xdc, 0x14, 0xc3, 0xdf, 0x4e, 0xc0, 0xf6, 0x78, 0xf6, 0x3a, 0x3c, 0x4b, 0x9d, - 0x49, 0xd0, 0xcc, 0x36, 0xca, 0xf1, 0x4a, 0xc9, 0xd2, 0xbb, 0x9f, 0xbc, 0x38, 0x1b, 0x88}; - uint8_t bytesprops2[] = {0x5f, 0xaf, 0x0, 0xa8, 0x7d, 0x4d, 0xdc, 0x73, 0x8e, 0xef, 0x7f, 0x3, 0xcb, 0xd6, - 0xe3, 0xcf, 0x0, 0x46, 0xba, 0xd4, 0xb9, 0xd0, 0xd4, 0x88, 0x47, 0x1f, 0x91, 0xad}; - uint8_t bytesprops3[] = {0xe2, 0x3b, 0x8, 0x61, 0x44}; - uint8_t bytesprops4[] = {0xd, 0x5b, 0xe}; - uint8_t bytesprops5[] = {0x4c, 0x9b, 0xff, 0x8b}; - uint8_t bytesprops6[] = {0x7d, 0x4e, 0x12, 0x27, 0xa3, 0xb9, 0x39, 0xfc, 0x79, 0xa8, 0x3e, 0x94, 0x38, - 0x14, 0x74, 0xe1, 0xcf, 0x84, 0x20, 0xa0, 0x97, 0xcc, 0x6f, 0x4, 0x5f, 0x1d}; - uint8_t bytesprops7[] = {0x25, 0x3, 0xca, 0x6c, 0x39, 0xdc, 0x56, 0x2c, 0x60, 0xf1, 0xcd, 0xf3, 0x75, - 0x1c, 0x3, 0xb3, 0x7a, 0xac, 0xf1, 0xae, 0x80, 0x79, 0x18, 0x52, 0xf7}; - uint8_t bytesprops8[] = {0xce, 0x40, 0x60, 0xc8, 0xdd, 0x1d}; +// SubscribeRequest 31381 [("\230\234.\186\229\249Tuf\222\188\DC4 \193J\t\DLE}\156<\255\150\156\146\136\132\a",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\143\&6\250ODD\155\192\210\157\152",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\240ni\SUB}\189/\167\&4\ACK\213\129o\150",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropWildcardSubscriptionAvailable 59] +TEST(Subscribe5QCTest, Encode10) { +uint8_t pkt[] = {0x82, 0x42, 0x7a, 0x95, 0x2, 0x28, 0x3b, 0x0, 0x1b, 0xe6, 0xea, 0x2e, 0xba, 0xe5, 0xf9, 0x54, 0x75, 0x66, 0xde, 0xbc, 0x14, 0x20, 0xc1, 0x4a, 0x9, 0x10, 0x7d, 0x9c, 0x3c, 0xff, 0x96, 0x9c, 0x92, 0x88, 0x84, 0x7, 0xe, 0x0, 0xb, 0x8f, 0x36, 0xfa, 0x4f, 0x44, 0x44, 0x9b, 0xc0, 0xd2, 0x9d, 0x98, 0x1d, 0x0, 0xe, 0xf0, 0x6e, 0x69, 0x1a, 0x7d, 0xbd, 0x2f, 0xa7, 0x34, 0x6, 0xd5, 0x81, 0x6f, 0x96, 0x20}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xe6, 0xea, 0x2e, 0xba, 0xe5, 0xf9, 0x54, 0x75, 0x66, 0xde, 0xbc, 0x14, 0x20, 0xc1, 0x4a, 0x9, 0x10, 0x7d, 0x9c, 0x3c, 0xff, 0x96, 0x9c, 0x92, 0x88, 0x84, 0x7}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x8f, 0x36, 0xfa, 0x4f, 0x44, 0x44, 0x9b, 0xc0, 0xd2, 0x9d, 0x98}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xf0, 0x6e, 0x69, 0x1a, 0x7d, 0xbd, 0x2f, 0xa7, 0x34, 0x6, 0xd5, 0x81, 0x6f, 0x96}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; +lwmqtt_sub_options_t sub_opts[3]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = true; +sub_opts[0].no_local = true; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[1].retain_as_published = true; +sub_opts[1].no_local = true; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31882}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1252}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8274}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32660}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 59}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19363, 6, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31381, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 9790 [("\228F\148\174g\141\DC4\140\249o\196",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\177\151IY\145b\217z\r\205(B\253yT[~Z\183f\246^_IZ",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\n\173\216\DC2G\235Y\189fi\DC1\185g\229\bEH\252F\242\216\ACK\231\243\237\242",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),(">A",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\163\133MU\FSV\131 -// V\b\ESC\210U\147\&0ma\248",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS0}),("\250.\ETBh\239;\217\248\159\219\202\SOH\FS\135\218 \219\&3\ENQ\153s\199",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\207\SI/?@\201.\216\171h\187\128\242o|\144\158z,W\207\136",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropMessageExpiryInterval 28136,PropRetainAvailable -// 88,PropTopicAliasMaximum 14486,PropMaximumPacketSize 10234,PropPayloadFormatIndicator 110] -TEST(Subscribe5QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0xa7, 0x1, 0x26, 0x3e, 0x11, 0x2, 0x0, 0x0, 0x6d, 0xe8, 0x25, 0x58, 0x22, 0x38, 0x96, 0x27, - 0x0, 0x0, 0x27, 0xfa, 0x1, 0x6e, 0x0, 0xb, 0xe4, 0x46, 0x94, 0xae, 0x67, 0x8d, 0x14, 0x8c, 0xf9, - 0x6f, 0xc4, 0x1c, 0x0, 0x19, 0xb1, 0x97, 0x49, 0x59, 0x91, 0x62, 0xd9, 0x7a, 0xd, 0xcd, 0x28, 0x42, - 0xfd, 0x79, 0x54, 0x5b, 0x7e, 0x5a, 0xb7, 0x66, 0xf6, 0x5e, 0x5f, 0x49, 0x5a, 0x20, 0x0, 0x1a, 0xa, - 0xad, 0xd8, 0x12, 0x47, 0xeb, 0x59, 0xbd, 0x66, 0x69, 0x11, 0xb9, 0x67, 0xe5, 0x8, 0x45, 0x48, 0xfc, - 0x46, 0xf2, 0xd8, 0x6, 0xe7, 0xf3, 0xed, 0xf2, 0xa, 0x0, 0x2, 0x3e, 0x41, 0xd, 0x0, 0x12, 0xa3, - 0x85, 0x4d, 0x55, 0x1c, 0x56, 0x83, 0x20, 0x56, 0x8, 0x1b, 0xd2, 0x55, 0x93, 0x30, 0x6d, 0x61, 0xf8, - 0x24, 0x0, 0x16, 0xfa, 0x2e, 0x17, 0x68, 0xef, 0x3b, 0xd9, 0xf8, 0x9f, 0xdb, 0xca, 0x1, 0x1c, 0x87, - 0xda, 0x20, 0xdb, 0x33, 0x5, 0x99, 0x73, 0xc7, 0xa, 0x0, 0x16, 0xcf, 0xf, 0x2f, 0x3f, 0x40, 0xc9, - 0x2e, 0xd8, 0xab, 0x68, 0xbb, 0x80, 0xf2, 0x6f, 0x7c, 0x90, 0x9e, 0x7a, 0x2c, 0x57, 0xcf, 0x88, 0xc}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xe4, 0x46, 0x94, 0xae, 0x67, 0x8d, 0x14, 0x8c, 0xf9, 0x6f, 0xc4}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb1, 0x97, 0x49, 0x59, 0x91, 0x62, 0xd9, 0x7a, 0xd, 0xcd, 0x28, 0x42, 0xfd, - 0x79, 0x54, 0x5b, 0x7e, 0x5a, 0xb7, 0x66, 0xf6, 0x5e, 0x5f, 0x49, 0x5a}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa, 0xad, 0xd8, 0x12, 0x47, 0xeb, 0x59, 0xbd, 0x66, 0x69, 0x11, 0xb9, 0x67, - 0xe5, 0x8, 0x45, 0x48, 0xfc, 0x46, 0xf2, 0xd8, 0x6, 0xe7, 0xf3, 0xed, 0xf2}; - lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3e, 0x41}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa3, 0x85, 0x4d, 0x55, 0x1c, 0x56, 0x83, 0x20, 0x56, - 0x8, 0x1b, 0xd2, 0x55, 0x93, 0x30, 0x6d, 0x61, 0xf8}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfa, 0x2e, 0x17, 0x68, 0xef, 0x3b, 0xd9, 0xf8, 0x9f, 0xdb, 0xca, - 0x1, 0x1c, 0x87, 0xda, 0x20, 0xdb, 0x33, 0x5, 0x99, 0x73, 0xc7}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xcf, 0xf, 0x2f, 0x3f, 0x40, 0xc9, 0x2e, 0xd8, 0xab, 0x68, 0xbb, - 0x80, 0xf2, 0x6f, 0x7c, 0x90, 0x9e, 0x7a, 0x2c, 0x57, 0xcf, 0x88}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; +// SubscribeRequest 25357 [("+\142\146\175\bU\244B\225\175s\255)",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationMethod "\236\175\129\179\DC4\166\179eCC\159\132\217\US\196\243\158\232h\208\148\236\&6c",PropMaximumQoS 88,PropMaximumQoS 51,PropAssignedClientIdentifier "\254",PropAuthenticationMethod "\243_td\f\NAK\v\205\253\237^\155\217i\225V\STX8\134\218\176\205",PropSubscriptionIdentifierAvailable 137,PropRequestProblemInformation 79,PropServerReference "(\153U\SO\202\SI]94",PropResponseInformation "\DEL\179%W\177+\f\141\155\243@%\199X\241\133V/-\173\t_\137'",PropRequestResponseInformation 175,PropMessageExpiryInterval 24849,PropTopicAliasMaximum 8185,PropWildcardSubscriptionAvailable 101,PropServerKeepAlive 23055,PropServerReference "\236\254R\169\GS\134\197X\215k\163\187\t\237\&2\205\227\167\227`",PropAuthenticationData "!\233L8T\128\191\&8\DC1\182\134\147\134\224\208I={*\246\252\205L[%\131",PropCorrelationData "\211CJ\205b\130`b\179\225\f\DEL\188\&1\136Y\204$!n\233\ESC\197\130\FS\222\202\144s\194",PropAuthenticationData "\DLE\DLEt\164\135\&4\182\134l\192wt\NAKwx\138\163\157\175\240J\228\130E\230",PropServerReference "\163\DC1\175&|\177\&7I\210\196u\227\US\204\168Y",PropSubscriptionIdentifier 23] +TEST(Subscribe5QCTest, Encode11) { +uint8_t pkt[] = {0x82, 0x90, 0x2, 0x63, 0xd, 0xfc, 0x1, 0x15, 0x0, 0x18, 0xec, 0xaf, 0x81, 0xb3, 0x14, 0xa6, 0xb3, 0x65, 0x43, 0x43, 0x9f, 0x84, 0xd9, 0x1f, 0xc4, 0xf3, 0x9e, 0xe8, 0x68, 0xd0, 0x94, 0xec, 0x36, 0x63, 0x24, 0x58, 0x24, 0x33, 0x12, 0x0, 0x1, 0xfe, 0x15, 0x0, 0x16, 0xf3, 0x5f, 0x74, 0x64, 0xc, 0x15, 0xb, 0xcd, 0xfd, 0xed, 0x5e, 0x9b, 0xd9, 0x69, 0xe1, 0x56, 0x2, 0x38, 0x86, 0xda, 0xb0, 0xcd, 0x29, 0x89, 0x17, 0x4f,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, 0x0, 0xd, 0x2b, 0x8e, 0x92, 0xaf, 0x8, 0x55, 0xf4, 0x42, 0xe1, 0xaf, 0x73, 0xff, 0x29, 0x20}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x2b, 0x8e, 0x92, 0xaf, 0x8, 0x55, 0xf4, 0x42, 0xe1, 0xaf, 0x73, 0xff, 0x29}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; +lwmqtt_sub_options_t sub_opts[1]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0xec, 0xaf, 0x81, 0xb3, 0x14, 0xa6, 0xb3, 0x65, 0x43, 0x43, 0x9f, 0x84, 0xd9, 0x1f, 0xc4, 0xf3, 0x9e, 0xe8, 0x68, 0xd0, 0x94, 0xec, 0x36, 0x63}; + uint8_t bytesprops1[] = {0xfe}; + uint8_t bytesprops2[] = {0xf3, 0x5f, 0x74, 0x64, 0xc, 0x15, 0xb, 0xcd, 0xfd, 0xed, 0x5e, 0x9b, 0xd9, 0x69, 0xe1, 0x56, 0x2, 0x38, 0x86, 0xda, 0xb0, 0xcd}; + uint8_t bytesprops3[] = {0x28, 0x99, 0x55, 0xe, 0xca, 0xf, 0x5d, 0x39, 0x34}; + uint8_t bytesprops4[] = {0x7f, 0xb3, 0x25, 0x57, 0xb1, 0x2b, 0xc, 0x8d, 0x9b, 0xf3, 0x40, 0x25, 0xc7, 0x58, 0xf1, 0x85, 0x56, 0x2f, 0x2d, 0xad, 0x9, 0x5f, 0x89, 0x27}; + uint8_t bytesprops5[] = {0xec, 0xfe, 0x52, 0xa9, 0x1d, 0x86, 0xc5, 0x58, 0xd7, 0x6b, 0xa3, 0xbb, 0x9, 0xed, 0x32, 0xcd, 0xe3, 0xa7, 0xe3, 0x60}; + uint8_t bytesprops6[] = {0x21, 0xe9, 0x4c, 0x38, 0x54, 0x80, 0xbf, 0x38, 0x11, 0xb6, 0x86, 0x93, 0x86, 0xe0, 0xd0, 0x49, 0x3d, 0x7b, 0x2a, 0xf6, 0xfc, 0xcd, 0x4c, 0x5b, 0x25, 0x83}; + uint8_t bytesprops7[] = {0xd3, 0x43, 0x4a, 0xcd, 0x62, 0x82, 0x60, 0x62, 0xb3, 0xe1, 0xc, 0x7f, 0xbc, 0x31, 0x88, 0x59, 0xcc, 0x24, 0x21, 0x6e, 0xe9, 0x1b, 0xc5, 0x82, 0x1c, 0xde, 0xca, 0x90, 0x73, 0xc2}; + uint8_t bytesprops8[] = {0x10, 0x10, 0x74, 0xa4, 0x87, 0x34, 0xb6, 0x86, 0x6c, 0xc0, 0x77, 0x74, 0x15, 0x77, 0x78, 0x8a, 0xa3, 0x9d, 0xaf, 0xf0, 0x4a, 0xe4, 0x82, 0x45, 0xe6}; + uint8_t bytesprops9[] = {0xa3, 0x11, 0xaf, 0x26, 0x7c, 0xb1, 0x37, 0x49, 0xd2, 0xc4, 0x75, 0xe3, 0x1f, 0xcc, 0xa8, 0x59}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28136}}, {.prop = (lwmqtt_prop_t)37, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14486}}, {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10234}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24849}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8185}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23055}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9790, 7, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25357, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 29850 [("\ESC\148a",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = -// QoS2}),("e\"\230B\SYNNm^{\160\218\FS\152\238\232\143\135\180\197\251D\202\205n\STX\161\f\175\165}",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("]\RS\172\169\198\239\243#\136\243\DC37n\177\215k\167\243",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("Q\129=ls\SI\233\136\246\208\170\188\SUBg\134\155B",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("[=",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\174\230\194'q",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\\%\201\190\183\&1\138\217=~\181c\233?\138\160X",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\SI\159f\134\CAN%\254\185\194T\216\145[\248\229\214>\170\216\164",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\164r\209\EOTC\218[-BMGq\236>M\194\139H\216\165:R\132t\179\224\157C\147%",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropMessageExpiryInterval -// 26319,PropSubscriptionIdentifier 27,PropAuthenticationMethod -// "\SOH\200\&0\232\SI\ACK\236\165P\233&\222\255\231\SO\200\128sY\162(|!\196\SI\247",PropServerReference -// "vO\174\253d8\v\150\DC2\STX\187^\am\192%\153w\DC2\205\v",PropCorrelationData "9\f\138b\248L\160\160\151 -// \GS\221",PropMessageExpiryInterval 11750,PropTopicAliasMaximum 14828,PropAuthenticationMethod -// "\140\188?\ACKn\238\FSL\NAK\DC1\SYNfM\166\t\162\ACK\221\212\154\t+\181S\152\SUB",PropMessageExpiryInterval -// 10067,PropRetainAvailable 35,PropServerKeepAlive 9584,PropAssignedClientIdentifier -// "<\209\173Y",PropMessageExpiryInterval 12571,PropTopicAliasMaximum 10964,PropPayloadFormatIndicator -// 229,PropAssignedClientIdentifier "\164\156\187",PropServerReference -// "\213\188\SYN\ENQ\232\182j\203\NAK\158",PropSubscriptionIdentifierAvailable 125,PropRetainAvailable -// 81,PropSharedSubscriptionAvailable 18,PropPayloadFormatIndicator 82,PropAssignedClientIdentifier -// "3\236;\DC4\134\228\232\182\245\167rK\247\169\184\166\&7]\DEL\STX5",PropReasonString "\STX\SYNg0\178\143\157y\208\&9 -// K<\133\244\232\t_\218,@\174Q\237\156",PropTopicAliasMaximum 964] -TEST(Subscribe5QCTest, Encode12) { - uint8_t pkt[] = { - 0x82, 0x8a, 0x3, 0x74, 0x9a, 0xdd, 0x1, 0x2, 0x0, 0x0, 0x66, 0xcf, 0xb, 0x1b, 0x15, 0x0, 0x1a, 0x1, 0xc8, - 0x30, 0xe8, 0xf, 0x6, 0xec, 0xa5, 0x50, 0xe9, 0x26, 0xde, 0xff, 0xe7, 0xe, 0xc8, 0x80, 0x73, 0x59, 0xa2, 0x28, - 0x7c, 0x21, 0xc4, 0xf, 0xf7, 0x1c, 0x0, 0x15, 0x76, 0x4f, 0xae, 0xfd, 0x64, 0x38, 0xb, 0x96, 0x12, 0x2, 0xbb, - 0x5e, 0x7, 0x6d, 0xc0, 0x25, 0x99, 0x77, 0x12, 0xcd, 0xb, 0x9, 0x0, 0xc, 0x39, 0xc, 0x8a, 0x62, 0xf8, 0x4c, - 0xa0, 0xa0, 0x97, 0x20, 0x1d, 0xdd, 0x2, 0x0, 0x0, 0x2d, 0xe6, 0x22, 0x39, 0xec, 0x15, 0x0, 0x1a, 0x8c, 0xbc, - 0x3f, 0x6, 0x6e, 0xee, 0x1c, 0x4c, 0x15, 0x11, 0x16, 0x66, 0x4d, 0xa6, 0x9, 0xa2, 0x6, 0xdd, 0xd4, 0x9a, 0x9, - 0x2b, 0xb5, 0x53, 0x98, 0x1a, 0x2, 0x0, 0x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0x20, 0x0, 0x2, 0x5b, 0x3d, 0x14, 0x0, 0x5, 0xae, 0xe6, 0xc2, 0x27, 0x71, 0x12, 0x0, 0x11, - 0x5c, 0x25, 0xc9, 0xbe, 0xb7, 0x31, 0x8a, 0xd9, 0x3d, 0x7e, 0xb5, 0x63, 0xe9, 0x3f, 0x8a, 0xa0, 0x58, 0x19, 0x0, - 0x14, 0xf, 0x9f, 0x66, 0x86, 0x18, 0x25, 0xfe, 0xb9, 0xc2, 0x54, 0xd8, 0x91, 0x5b, 0xf8, 0xe5, 0xd6, 0x3e, 0xaa, - 0xd8, 0xa4, 0x15, 0x0, 0x1e, 0xa4, 0x72, 0xd1, 0x4, 0x43, 0xda, 0x5b, 0x2d, 0x42, 0x4d, 0x47, 0x71, 0xec, 0x3e, - 0x4d, 0xc2, 0x8b, 0x48, 0xd8, 0xa5, 0x3a, 0x52, 0x84, 0x74, 0xb3, 0xe0, 0x9d, 0x43, 0x93, 0x25, 0x2c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x1b, 0x94, 0x61}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x65, 0x22, 0xe6, 0x42, 0x16, 0x4e, 0x6d, 0x5e, 0x7b, 0xa0, - 0xda, 0x1c, 0x98, 0xee, 0xe8, 0x8f, 0x87, 0xb4, 0xc5, 0xfb, - 0x44, 0xca, 0xcd, 0x6e, 0x2, 0xa1, 0xc, 0xaf, 0xa5, 0x7d}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5d, 0x1e, 0xac, 0xa9, 0xc6, 0xef, 0xf3, 0x23, 0x88, - 0xf3, 0x13, 0x37, 0x6e, 0xb1, 0xd7, 0x6b, 0xa7, 0xf3}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x51, 0x81, 0x3d, 0x6c, 0x73, 0xf, 0xe9, 0x88, 0xf6, - 0xd0, 0xaa, 0xbc, 0x1a, 0x67, 0x86, 0x9b, 0x42}; - lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5b, 0x3d}; - lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xae, 0xe6, 0xc2, 0x27, 0x71}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5c, 0x25, 0xc9, 0xbe, 0xb7, 0x31, 0x8a, 0xd9, 0x3d, - 0x7e, 0xb5, 0x63, 0xe9, 0x3f, 0x8a, 0xa0, 0x58}; - lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf, 0x9f, 0x66, 0x86, 0x18, 0x25, 0xfe, 0xb9, 0xc2, 0x54, - 0xd8, 0x91, 0x5b, 0xf8, 0xe5, 0xd6, 0x3e, 0xaa, 0xd8, 0xa4}; - lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa4, 0x72, 0xd1, 0x4, 0x43, 0xda, 0x5b, 0x2d, 0x42, 0x4d, - 0x47, 0x71, 0xec, 0x3e, 0x4d, 0xc2, 0x8b, 0x48, 0xd8, 0xa5, - 0x3a, 0x52, 0x84, 0x74, 0xb3, 0xe0, 0x9d, 0x43, 0x93, 0x25}; - lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = true; - uint8_t bytesprops0[] = {0x1, 0xc8, 0x30, 0xe8, 0xf, 0x6, 0xec, 0xa5, 0x50, 0xe9, 0x26, 0xde, 0xff, - 0xe7, 0xe, 0xc8, 0x80, 0x73, 0x59, 0xa2, 0x28, 0x7c, 0x21, 0xc4, 0xf, 0xf7}; - uint8_t bytesprops1[] = {0x76, 0x4f, 0xae, 0xfd, 0x64, 0x38, 0xb, 0x96, 0x12, 0x2, 0xbb, - 0x5e, 0x7, 0x6d, 0xc0, 0x25, 0x99, 0x77, 0x12, 0xcd, 0xb}; - uint8_t bytesprops2[] = {0x39, 0xc, 0x8a, 0x62, 0xf8, 0x4c, 0xa0, 0xa0, 0x97, 0x20, 0x1d, 0xdd}; - uint8_t bytesprops3[] = {0x8c, 0xbc, 0x3f, 0x6, 0x6e, 0xee, 0x1c, 0x4c, 0x15, 0x11, 0x16, 0x66, 0x4d, - 0xa6, 0x9, 0xa2, 0x6, 0xdd, 0xd4, 0x9a, 0x9, 0x2b, 0xb5, 0x53, 0x98, 0x1a}; - uint8_t bytesprops4[] = {0x3c, 0xd1, 0xad, 0x59}; - uint8_t bytesprops5[] = {0xa4, 0x9c, 0xbb}; - uint8_t bytesprops6[] = {0xd5, 0xbc, 0x16, 0x5, 0xe8, 0xb6, 0x6a, 0xcb, 0x15, 0x9e}; - uint8_t bytesprops7[] = {0x33, 0xec, 0x3b, 0x14, 0x86, 0xe4, 0xe8, 0xb6, 0xf5, 0xa7, 0x72, - 0x4b, 0xf7, 0xa9, 0xb8, 0xa6, 0x37, 0x5d, 0x7f, 0x2, 0x35}; - uint8_t bytesprops8[] = {0x2, 0x16, 0x67, 0x30, 0xb2, 0x8f, 0x9d, 0x79, 0xd0, 0x39, 0x20, 0x4b, 0x3c, - 0x85, 0xf4, 0xe8, 0x9, 0x5f, 0xda, 0x2c, 0x40, 0xae, 0x51, 0xed, 0x9c}; +// SubscribeRequest 21412 [("w\218]r\ESC\143}\r\199\224\149",PropMessageExpiryInterval 8464,PropRequestResponseInformation 192,PropAssignedClientIdentifier "\212\215\253#\214$\160\&0\163\237\128\134\US?\180\212\219"] +TEST(Subscribe5QCTest, Encode12) { +uint8_t pkt[] = {0x82, 0x49, 0x53, 0xa4, 0x39, 0x24, 0x99, 0x15, 0x0, 0x5, 0xcf, 0x30, 0x3a, 0xa5, 0x4f, 0x15, 0x0, 0x11, 0x61, 0xa, 0x29, 0x2b, 0x6f, 0x80, 0x4f, 0xdf, 0x3, 0xf3, 0x4, 0x3e, 0x7d, 0xd, 0xc7, 0xe0, 0x95, 0x2, 0x0, 0x0, 0x21, 0x10, 0x19, 0xc0, 0x12, 0x0, 0x11, 0xd4, 0xd7, 0xfd, 0x23, 0xd6, 0x24, 0xa0, 0x30, 0xa3, 0xed, 0x80, 0x86, 0x1f, 0x3f, 0xb4, 0xd4, 0xdb, 0x0, 0xa, 0x77, 0xda, 0x5d, 0x72, 0x1b, 0x8f, 0x3c, 0x71, 0xf2, 0x4c, 0x4}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x77, 0xda, 0x5d, 0x72, 0x1b, 0x8f, 0x3c, 0x71, 0xf2, 0x4c}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; +lwmqtt_sub_options_t sub_opts[1]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = true; + uint8_t bytesprops0[] = {0xcf, 0x30, 0x3a, 0xa5, 0x4f}; + uint8_t bytesprops1[] = {0x61, 0xa, 0x29, 0x2b, 0x6f, 0x80, 0x4f, 0xdf, 0x3, 0xf3, 0x4, 0x3e, 0x7d, 0xd, 0xc7, 0xe0, 0x95}; + uint8_t bytesprops2[] = {0xd4, 0xd7, 0xfd, 0x23, 0xd6, 0x24, 0xa0, 0x30, 0xa3, 0xed, 0x80, 0x86, 0x1f, 0x3f, 0xb4, 0xd4, 0xdb}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26319}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11750}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14828}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10067}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9584}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12571}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10964}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 964}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8464}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29850, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21412, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 18338 [("\162\249\GS\153yq\215F\221 \242",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\158\168o!e\ACK\247\202\128\152f\197m\\\176\247(\167\US\214\188ti\225\192",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] -// [PropWildcardSubscriptionAvailable 74,PropCorrelationData -// "\212\&9\241\219\226\155\134$\130\148\ETB",PropServerReference -// "\133\186\RS\134\232\203\&7\160\143\156BI\221",PropServerKeepAlive 21739,PropTopicAlias -// 16767,PropRequestResponseInformation 119,PropTopicAliasMaximum 17366,PropUserProperty -// "\242\188u\255\247\210E\191yL\224%\a\189\209\159\207&\246\209\DEL" -// "\155\&83\197\178\150\144|\151DO",PropReceiveMaximum 15132,PropWildcardSubscriptionAvailable -// 163,PropMessageExpiryInterval 24957,PropAssignedClientIdentifier -// "N\225O\f\254\177\232\162\171OZ\t\201\163x",PropWildcardSubscriptionAvailable 94,PropReceiveMaximum -// 29341,PropSubscriptionIdentifierAvailable 220,PropReceiveMaximum 73,PropCorrelationData -// "i\128\206\251\215,\255~\ACK\RS",PropReceiveMaximum 731,PropSessionExpiryInterval 14347] -TEST(Subscribe5QCTest, Encode13) { - uint8_t pkt[] = { - 0x82, 0xb9, 0x1, 0x47, 0xa2, 0x8b, 0x1, 0x28, 0x4a, 0x9, 0x0, 0xb, 0xd4, 0x39, 0xf1, 0xdb, 0xe2, 0x9b, 0x86, - 0x24, 0x82, 0x94, 0x17, 0x1c, 0x0, 0xd, 0x85, 0xba, 0x1e, 0x86, 0xe8, 0xcb, 0x37, 0xa0, 0x8f, 0x9c, 0x42, 0x49, - 0xdd, 0x13, 0x54, 0xeb, 0x23, 0x41, 0x7f, 0x19, 0x77, 0x22, 0x43, 0xd6, 0x26, 0x0, 0x15, 0xf2, 0xbc, 0x75, 0xff, - 0xf7, 0xd2, 0x45, 0xbf, 0x79, 0x4c, 0xe0, 0x25, 0x7, 0xbd, 0xd1, 0x9f, 0xcf, 0x26, 0xf6, 0xd1, 0x7f, 0x0, 0xb, - 0x9b, 0x38, 0x33, 0xc5, 0xb2, 0x96, 0x90, 0x7c, 0x97, 0x44, 0x4f, 0x21, 0x3b, 0x1c, 0x28, 0xa3, 0x2, 0x0, 0x0, - 0x61, 0x7d, 0x12, 0x0, 0xf, 0x4e, 0xe1, 0x4f, 0xc, 0xfe, 0xb1, 0xe8, 0xa2, 0xab, 0x4f, 0x5a, 0x9, 0xc9, 0xa3, - 0x78, 0x28, 0x5e, 0x21, 0x72, 0x9d, 0x29, 0xdc, 0x21, 0x0, 0x49, 0x9, 0x0, 0xa, 0x69, 0x80, 0xce, 0xfb, 0xd7, - 0x2c, 0xff, 0x7e, 0x6, 0x1e, 0x21, 0x2, 0xdb, 0x11, 0x0, 0x0, 0x38, 0xb, 0x0, 0xb, 0xa2, 0xf9, 0x1d, 0x99, - 0x79, 0x71, 0xd7, 0x46, 0xdd, 0x20, 0xf2, 0x1c, 0x0, 0x19, 0x9e, 0xa8, 0x6f, 0x21, 0x65, 0x6, 0xf7, 0xca, 0x80, - 0x98, 0x66, 0xc5, 0x6d, 0x5c, 0xb0, 0xf7, 0x28, 0xa7, 0x1f, 0xd6, 0xbc, 0x74, 0x69, 0xe1, 0xc0, 0x2c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xa2, 0xf9, 0x1d, 0x99, 0x79, 0x71, 0xd7, 0x46, 0xdd, 0x20, 0xf2}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9e, 0xa8, 0x6f, 0x21, 0x65, 0x6, 0xf7, 0xca, 0x80, 0x98, 0x66, 0xc5, 0x6d, - 0x5c, 0xb0, 0xf7, 0x28, 0xa7, 0x1f, 0xd6, 0xbc, 0x74, 0x69, 0xe1, 0xc0}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - uint8_t bytesprops0[] = {0xd4, 0x39, 0xf1, 0xdb, 0xe2, 0x9b, 0x86, 0x24, 0x82, 0x94, 0x17}; - uint8_t bytesprops1[] = {0x85, 0xba, 0x1e, 0x86, 0xe8, 0xcb, 0x37, 0xa0, 0x8f, 0x9c, 0x42, 0x49, 0xdd}; - uint8_t bytesprops3[] = {0x9b, 0x38, 0x33, 0xc5, 0xb2, 0x96, 0x90, 0x7c, 0x97, 0x44, 0x4f}; - uint8_t bytesprops2[] = {0xf2, 0xbc, 0x75, 0xff, 0xf7, 0xd2, 0x45, 0xbf, 0x79, 0x4c, 0xe0, - 0x25, 0x7, 0xbd, 0xd1, 0x9f, 0xcf, 0x26, 0xf6, 0xd1, 0x7f}; - uint8_t bytesprops4[] = {0x4e, 0xe1, 0x4f, 0xc, 0xfe, 0xb1, 0xe8, 0xa2, 0xab, 0x4f, 0x5a, 0x9, 0xc9, 0xa3, 0x78}; - uint8_t bytesprops5[] = {0x69, 0x80, 0xce, 0xfb, 0xd7, 0x2c, 0xff, 0x7e, 0x6, 0x1e}; +// SubscribeRequest 10276 [("\SYN\144\218\230l\154\217\219\225\DLE\150m\141\195\222\183#N\DC1\219)\226\a\206y\204\150\RS\214\178",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("R\229\195\208\168\199\145\206\150\202|l\251\139`[\165@GL\SI\229\191!\183s\t\184\153",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationMethod "\\\238\220\219NN_\DELm(\138\183\164O\215q\195n\231#\208\182\DC3\RSJ",PropAuthenticationMethod "\DC3\156",PropTopicAlias 26024,PropResponseTopic "2\n0\139\212\176\255\&8\243b)\a\222n\233N\222\149\208]s\154\147",PropRequestResponseInformation 121,PropAuthenticationData "\162\140\203\163\170\250\194\153\144O4\162;\137\215\168\129\216S\244v\251\&0V\ACKL6",PropMaximumPacketSize 9941,PropResponseInformation "\235\208g\251\DLEO\192\&1\201\STX\ESC\238\183",PropPayloadFormatIndicator 104,PropSessionExpiryInterval 25608,PropAuthenticationMethod "\239",PropWildcardSubscriptionAvailable 163,PropTopicAliasMaximum 2138,PropAuthenticationMethod "+\189\240\243\152G-\185\254\v\152\161\146\&6",PropAuthenticationMethod "7\\)",PropMessageExpiryInterval 9959,PropWillDelayInterval 14260,PropMaximumQoS 41,PropServerReference "4",PropReasonString "\200\215\155\212\DC4\144\239\244\247q",PropWildcardSubscriptionAvailable 249,PropMaximumPacketSize 13691,PropTopicAlias 25895,PropReceiveMaximum 13454] +TEST(Subscribe5QCTest, Encode13) { +uint8_t pkt[] = {0x82, 0x89, 0x2, 0x28, 0x24, 0xc4, 0x1, 0x15, 0x0, 0x19, 0x5c, 0xee, 0xdc, 0xdb, 0x4e, 0x4e, 0x5f, 0x7f, 0x6d, 0x28, 0x8a, 0xb7, 0xa4, 0x4f, 0xd7, 0x71, 0xc3, 0x6e, 0xe7, 0x23, 0xd0, 0xb6, 0x13, 0x1e, 0x4a, 0x15, 0x0, 0x2, 0x13, 0x9c, 0x23, 0x65, 0xa8, 0x8, 0x0, 0x17, 0x32, 0xa, 0x30, 0x8b, 0xd4, 0xb0, 0xff, 0x38, 0xf3, 0x62, 0x29, 0x7, 0xde, 0x6e, 0xe9, 0x4e, 0xde, 0x95, 0xd0, 0x5d, 0x73, 0x9a, 0x93, 0x19, 0x79, 0x16, 0x0, 0x1b, 0xa2, 0x8c, 0xcb, 0xa3, 0xaa, 0xfa, 0xc2, 0x99, 0x90, 0x4f, 0x34, 0xa2, 0x3b, 0x89, 0xd7, 0xa8, 0x81, 0xd8, 0x53, 0xf4, 0x76, 0xfb, 0x30, 0x56, 0x6, 0x4c, 0x36, 0x27, 0x0, 0x0, 0x26, 0xd5, 0x1a, 0x0, 0xd, 0xeb, 0xd0, 0x67, 0xfb, 0x10, 0x4f, 0xc0, 0x31, 0xc9, 0x2, 0x1b, 0xee, 0xb7, 0x1, 0x68, 0x11, 0x0, 0x0, 0x64, 0x8, 0x15, 0x0, 0x1, 0xef, 0x28, 0xa3, 0x22, 0x8, 0x5a, 0x15, 0x0, 0xe, 0x2b, 0xbd, 0xf0, 0xf3, 0x98, 0x47, 0x2d, 0xb9, 0xfe, 0xb, 0x98, 0xa1, 0x92, 0x36, 0x15, 0x0, 0x3, 0x37, 0x5c, 0x29, 0x2, 0x0, 0x0, 0x26, 0xe7, 0x18, 0x0, 0x0, 0x37, 0xb4, 0x24, 0x29, 0x1c, 0x0, 0x1, 0x34, 0x1f, 0x0, 0xa, 0xc8, 0xd7, 0x9b, 0xd4, 0x14, 0x90, 0xef, 0xf4, 0xf7, 0x71, 0x28, 0xf9, 0x27, 0x0, 0x0, 0x35, 0x7b, 0x23, 0x65, 0x27, 0x21, 0x34, 0x8e, 0x0, 0x1e, 0x16, 0x90, 0xda, 0xe6, 0x6c, 0x9a, 0xd9, 0xdb, 0xe1, 0x10, 0x96, 0x6d, 0x8d, 0xc3, 0xde, 0xb7, 0x23, 0x4e, 0x11, 0xdb, 0x29, 0xe2, 0x7, 0xce, 0x79, 0xcc, 0x96, 0x1e, 0xd6, 0xb2, 0x10, 0x0, 0x1d, 0x52, 0xe5, 0xc3, 0xd0, 0xa8, 0xc7, 0x91, 0xce, 0x96, 0xca, 0x7c, 0x6c, 0xfb, 0x8b, 0x60, 0x5b, 0xa5, 0x40, 0x47, 0x4c, 0xf, 0xe5, 0xbf, 0x21, 0xb7, 0x73, 0x9, 0xb8, 0x99, 0x10}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x16, 0x90, 0xda, 0xe6, 0x6c, 0x9a, 0xd9, 0xdb, 0xe1, 0x10, 0x96, 0x6d, 0x8d, 0xc3, 0xde, 0xb7, 0x23, 0x4e, 0x11, 0xdb, 0x29, 0xe2, 0x7, 0xce, 0x79, 0xcc, 0x96, 0x1e, 0xd6, 0xb2}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x52, 0xe5, 0xc3, 0xd0, 0xa8, 0xc7, 0x91, 0xce, 0x96, 0xca, 0x7c, 0x6c, 0xfb, 0x8b, 0x60, 0x5b, 0xa5, 0x40, 0x47, 0x4c, 0xf, 0xe5, 0xbf, 0x21, 0xb7, 0x73, 0x9, 0xb8, 0x99}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; +lwmqtt_sub_options_t sub_opts[2]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS0; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; + uint8_t bytesprops0[] = {0x5c, 0xee, 0xdc, 0xdb, 0x4e, 0x4e, 0x5f, 0x7f, 0x6d, 0x28, 0x8a, 0xb7, 0xa4, 0x4f, 0xd7, 0x71, 0xc3, 0x6e, 0xe7, 0x23, 0xd0, 0xb6, 0x13, 0x1e, 0x4a}; + uint8_t bytesprops1[] = {0x13, 0x9c}; + uint8_t bytesprops2[] = {0x32, 0xa, 0x30, 0x8b, 0xd4, 0xb0, 0xff, 0x38, 0xf3, 0x62, 0x29, 0x7, 0xde, 0x6e, 0xe9, 0x4e, 0xde, 0x95, 0xd0, 0x5d, 0x73, 0x9a, 0x93}; + uint8_t bytesprops3[] = {0xa2, 0x8c, 0xcb, 0xa3, 0xaa, 0xfa, 0xc2, 0x99, 0x90, 0x4f, 0x34, 0xa2, 0x3b, 0x89, 0xd7, 0xa8, 0x81, 0xd8, 0x53, 0xf4, 0x76, 0xfb, 0x30, 0x56, 0x6, 0x4c, 0x36}; + uint8_t bytesprops4[] = {0xeb, 0xd0, 0x67, 0xfb, 0x10, 0x4f, 0xc0, 0x31, 0xc9, 0x2, 0x1b, 0xee, 0xb7}; + uint8_t bytesprops5[] = {0xef}; + uint8_t bytesprops6[] = {0x2b, 0xbd, 0xf0, 0xf3, 0x98, 0x47, 0x2d, 0xb9, 0xfe, 0xb, 0x98, 0xa1, 0x92, 0x36}; + uint8_t bytesprops7[] = {0x37, 0x5c, 0x29}; + uint8_t bytesprops8[] = {0x34}; + uint8_t bytesprops9[] = {0xc8, 0xd7, 0x9b, 0xd4, 0x14, 0x90, 0xef, 0xf4, 0xf7, 0x71}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21739}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16767}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17366}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15132}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24957}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29341}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 73}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 731}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14347}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26024}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9941}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25608}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2138}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9959}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14260}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13691}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25895}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13454}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18338, 2, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10276, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 4108 [("\199\233\131\SYNf\210",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished -// = True, _noLocal = False, _subQoS = -// QoS0}),("j\199\156\237c\EMH\246\212\232\&7\217aJ\193/\r\253\246>\215\t\221",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("c\FSd\247?\136\249Y\DELc\167\ETX\185",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = False, _noLocal = True, _subQoS = -// QoS1}),("\165\213\140\159\225\192\145\NAK$mr\141CDwEw\US\152\180\NAK\GSO\142\188r",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\162\247i\170\139\236sr-\177\215M3e\144\ETX3#\STX`s&\254i\233\179\128\142\SI",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("[k\181}\136\187j<\FS\142\DC4\186\157\214\162",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\202\191;\254\&7%\136\210:\NAKeE\203\&0\DC1\nlG*@\183",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("X\134i\144\&7x\198",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\SO9;\183,",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\SOJ\248\&8\219-jq\145\166\228\144\139\DC4M\SYN\245\220\150.\193K\178\&3\149\132D",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] -// [PropSubscriptionIdentifierAvailable 201,PropResponseTopic -// "i\161o\252W\176m\244u<\139\191mc\222\238K\177\243\166",PropTopicAliasMaximum 30251,PropReceiveMaximum -// 3997,PropCorrelationData "\208r\ETX\173C",PropRequestProblemInformation 50,PropTopicAlias -// 222,PropMessageExpiryInterval 2395] + +// SubscribeRequest 7750 [("\191\131\229\247n\DC4\170]A\183\163\132",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\209U\"`\185\222\252RC|G\202#\161P\240\SYN\DLE;@\172\251\188dV",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\188t\246J\ETX\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\154<\139\";}\250\187\&0pG\224\173\148\216\238#R\187\168\142\190",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("}\146\176\ncE\212\185:\132-\DLE9\ETB[r",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("m\DC3\169\GSX\164\&5\158\RS\153\235W8\CANp",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\151\209",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("$U\214\224\143\199M\166v\143\&6\241\STX\DC2U\245\144\153\135n\161\146\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\247\ACK\228'\209\245\RS\\\148\ACK\254\187\255gl\215",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\229rp:\145\167\ACK\191\188\195\US\\",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropWillDelayInterval 882,PropReasonString "1\ENQ\r\238\181 \ACK\ag\200\196j\157{c\173",PropWillDelayInterval 16738,PropAuthenticationData "\CAN\231",PropReasonString ".\161\&5g\NUL\183\147\197#k\157\GSz1)",PropMaximumQoS 208,PropRequestProblemInformation 104,PropUserProperty "\\\188t\\+Vg\177\139\206 \211\236=AU\161;\199f}\153-z\DC3\156\177\159\132\248" ":\138\203\NAKa\NUL\178\130\160(\SYN^\223\226:U\DC3\215\155\129\160\ETB",PropAssignedClientIdentifier "\225",PropRetainAvailable 233,PropAssignedClientIdentifier "\161S\232K\203",PropRequestProblemInformation 70,PropContentType "\192M\"greI\199\177}Z])",PropTopicAliasMaximum 692,PropMaximumQoS 117,PropRequestResponseInformation 183,PropTopicAliasMaximum 2828,PropReceiveMaximum 13055,PropReceiveMaximum 14438,PropWildcardSubscriptionAvailable 164,PropPayloadFormatIndicator 120,PropResponseInformation "\SYN\DEL%\222\178u\248\132\247\212\229u\155Iu\217\182@I\ETB\"X",PropTopicAlias 26576] TEST(Subscribe5QCTest, Encode14) { - uint8_t pkt[] = { - 0x82, 0x81, 0x2, 0x10, 0xc, 0x31, 0x29, 0xc9, 0x8, 0x0, 0x14, 0x69, 0xa1, 0x6f, 0xfc, 0x57, 0xb0, 0x6d, 0xf4, - 0x75, 0x3c, 0x8b, 0xbf, 0x6d, 0x63, 0xde, 0xee, 0x4b, 0xb1, 0xf3, 0xa6, 0x22, 0x76, 0x2b, 0x21, 0xf, 0x9d, 0x9, - 0x0, 0x5, 0xd0, 0x72, 0x3, 0xad, 0x43, 0x17, 0x32, 0x23, 0x0, 0xde, 0x2, 0x0, 0x0, 0x9, 0x5b, 0x0, 0x6, - 0xc7, 0xe9, 0x83, 0x16, 0x66, 0xd2, 0x18, 0x0, 0x17, 0x6a, 0xc7, 0x9c, 0xed, 0x63, 0x19, 0x48, 0xf6, 0xd4, 0xe8, - 0x37, 0xd9, 0x61, 0x4a, 0xc1, 0x2f, 0xd, 0xfd, 0xf6, 0x3e, 0xd7, 0x9, 0xdd, 0x14, 0x0, 0xd, 0x63, 0x1c, 0x64, - 0xf7, 0x3f, 0x88, 0xf9, 0x59, 0x7f, 0x63, 0xa7, 0x3, 0xb9, 0x25, 0x0, 0x1a, 0xa5, 0xd5, 0x8c, 0x9f, 0xe1, 0xc0, - 0x91, 0x15, 0x24, 0x6d, 0x72, 0x8d, 0x43, 0x44, 0x77, 0x45, 0x77, 0x1f, 0x98, 0xb4, 0x15, 0x1d, 0x4f, 0x8e, 0xbc, - 0x72, 0x2, 0x0, 0x1d, 0xa2, 0xf7, 0x69, 0xaa, 0x8b, 0xec, 0x73, 0x72, 0x2d, 0xb1, 0xd7, 0x4d, 0x33, 0x65, 0x90, - 0x3, 0x33, 0x23, 0x2, 0x60, 0x73, 0x26, 0xfe, 0x69, 0xe9, 0xb3, 0x80, 0x8e, 0xf, 0xd, 0x0, 0xf, 0x5b, 0x6b, - 0xb5, 0x7d, 0x88, 0xbb, 0x6a, 0x3c, 0x1c, 0x8e, 0x14, 0xba, 0x9d, 0xd6, 0xa2, 0x26, 0x0, 0x15, 0xca, 0xbf, 0x3b, - 0xfe, 0x37, 0x25, 0x88, 0xd2, 0x3a, 0x15, 0x65, 0x45, 0xcb, 0x30, 0x11, 0xa, 0x6c, 0x47, 0x2a, 0x40, 0xb7, 0x19, - 0x0, 0x7, 0x58, 0x86, 0x69, 0x90, 0x37, 0x78, 0xc6, 0x1e, 0x0, 0x5, 0xe, 0x39, 0x3b, 0xb7, 0x2c, 0x6, 0x0, - 0x1b, 0xe, 0x4a, 0xf8, 0x38, 0xdb, 0x2d, 0x6a, 0x71, 0x91, 0xa6, 0xe4, 0x90, 0x8b, 0x14, 0x4d, 0x16, 0xf5, 0xdc, - 0x96, 0x2e, 0xc1, 0x4b, 0xb2, 0x33, 0x95, 0x84, 0x44, 0x24, 0x0, 0x0, 0x5}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xc7, 0xe9, 0x83, 0x16, 0x66, 0xd2}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6a, 0xc7, 0x9c, 0xed, 0x63, 0x19, 0x48, 0xf6, 0xd4, 0xe8, 0x37, 0xd9, - 0x61, 0x4a, 0xc1, 0x2f, 0xd, 0xfd, 0xf6, 0x3e, 0xd7, 0x9, 0xdd}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x63, 0x1c, 0x64, 0xf7, 0x3f, 0x88, 0xf9, 0x59, 0x7f, 0x63, 0xa7, 0x3, 0xb9}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa5, 0xd5, 0x8c, 0x9f, 0xe1, 0xc0, 0x91, 0x15, 0x24, 0x6d, 0x72, 0x8d, 0x43, - 0x44, 0x77, 0x45, 0x77, 0x1f, 0x98, 0xb4, 0x15, 0x1d, 0x4f, 0x8e, 0xbc, 0x72}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa2, 0xf7, 0x69, 0xaa, 0x8b, 0xec, 0x73, 0x72, 0x2d, 0xb1, - 0xd7, 0x4d, 0x33, 0x65, 0x90, 0x3, 0x33, 0x23, 0x2, 0x60, - 0x73, 0x26, 0xfe, 0x69, 0xe9, 0xb3, 0x80, 0x8e, 0xf}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5b, 0x6b, 0xb5, 0x7d, 0x88, 0xbb, 0x6a, 0x3c, - 0x1c, 0x8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91, 0xa7, 0x6, 0xbf, 0xbc, 0xc3, 0x1f, 0x5c, 0x1d}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xbf, 0x83, 0xe5, 0xf7, 0x6e, 0x14, 0xaa, 0x5d, 0x41, 0xb7, 0xa3, 0x84}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd1, 0x55, 0x22, 0x60, 0xb9, 0xde, 0xfc, 0x52, 0x43, 0x7c, 0x47, 0xca, 0x23, 0xa1, 0x50, 0xf0, 0x16, 0x10, 0x3b, 0x40, 0xac, 0xfb, 0xbc, 0x64, 0x56}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xbc, 0x74, 0xf6, 0x4a, 0x3, 0xae}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x9a, 0x3c, 0x8b, 0x22, 0x3b, 0x7d, 0xfa, 0xbb, 0x30, 0x70, 0x47, 0xe0, 0xad, 0x94, 0xd8, 0xee, 0x23, 0x52, 0xbb, 0xa8, 0x8e, 0xbe}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x7d, 0x92, 0xb0, 0xa, 0x63, 0x45, 0xd4, 0xb9, 0x3a, 0x84, 0x2d, 0x10, 0x39, 0x17, 0x5b, 0x72}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x6d, 0x13, 0xa9, 0x1d, 0x58, 0xa4, 0x35, 0x9e, 0x1e, 0x99, 0xeb, 0x57, 0x38, 0x18, 0x70}; lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xca, 0xbf, 0x3b, 0xfe, 0x37, 0x25, 0x88, 0xd2, 0x3a, 0x15, 0x65, - 0x45, 0xcb, 0x30, 0x11, 0xa, 0x6c, 0x47, 0x2a, 0x40, 0xb7}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x58, 0x86, 0x69, 0x90, 0x37, 0x78, 0xc6}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe, 0x39, 0x3b, 0xb7, 0x2c}; - lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe, 0x4a, 0xf8, 0x38, 0xdb, 0x2d, 0x6a, 0x71, 0x91, 0xa6, 0xe4, 0x90, 0x8b, 0x14, - 0x4d, 0x16, 0xf5, 0xdc, 0x96, 0x2e, 0xc1, 0x4b, 0xb2, 0x33, 0x95, 0x84, 0x44}; - lwmqtt_string_t topic_filter_s9 = {27, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0}; - lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = true; - sub_opts[10].qos = LWMQTT_QOS1; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = true; - uint8_t bytesprops0[] = {0x69, 0xa1, 0x6f, 0xfc, 0x57, 0xb0, 0x6d, 0xf4, 0x75, 0x3c, - 0x8b, 0xbf, 0x6d, 0x63, 0xde, 0xee, 0x4b, 0xb1, 0xf3, 0xa6}; - uint8_t bytesprops1[] = {0xd0, 0x72, 0x3, 0xad, 0x43}; - +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x97, 0xd1}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x24, 0x55, 0xd6, 0xe0, 0x8f, 0xc7, 0x4d, 0xa6, 0x76, 0x8f, 0x36, 0xf1, 0x2, 0x12, 0x55, 0xf5, 0x90, 0x99, 0x87, 0x6e, 0xa1, 0x92, 0x1}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xf7, 0x6, 0xe4, 0x27, 0xd1, 0xf5, 0x1e, 0x5c, 0x94, 0x6, 0xfe, 0xbb, 0xff, 0x67, 0x6c, 0xd7}; + lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe5, 0x72, 0x70, 0x3a, 0x91, 0xa7, 0x6, 0xbf, 0xbc, 0xc3, 0x1f, 0x5c}; + lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; +topic_filters[9] = topic_filter_s9; +lwmqtt_sub_options_t sub_opts[10]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = true; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS2; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS2; +sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[4].retain_as_published = true; +sub_opts[4].no_local = true; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[5].retain_as_published = true; +sub_opts[5].no_local = true; +sub_opts[6].qos = LWMQTT_QOS0; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = true; +sub_opts[6].no_local = true; +sub_opts[7].qos = LWMQTT_QOS2; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = true; +sub_opts[8].qos = LWMQTT_QOS1; +sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[8].retain_as_published = true; +sub_opts[8].no_local = false; +sub_opts[9].qos = LWMQTT_QOS1; +sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[9].retain_as_published = true; +sub_opts[9].no_local = true; + uint8_t bytesprops0[] = {0x31, 0x5, 0xd, 0xee, 0xb5, 0x20, 0x6, 0x7, 0x67, 0xc8, 0xc4, 0x6a, 0x9d, 0x7b, 0x63, 0xad}; + uint8_t bytesprops1[] = {0x18, 0xe7}; + uint8_t bytesprops2[] = {0x2e, 0xa1, 0x35, 0x67, 0x0, 0xb7, 0x93, 0xc5, 0x23, 0x6b, 0x9d, 0x1d, 0x7a, 0x31, 0x29}; + uint8_t bytesprops4[] = {0x3a, 0x8a, 0xcb, 0x15, 0x61, 0x0, 0xb2, 0x82, 0xa0, 0x28, 0x16, 0x5e, 0xdf, 0xe2, 0x3a, 0x55, 0x13, 0xd7, 0x9b, 0x81, 0xa0, 0x17}; + uint8_t bytesprops3[] = {0x5c, 0xbc, 0x74, 0x5c, 0x2b, 0x56, 0x67, 0xb1, 0x8b, 0xce, 0x20, 0xd3, 0xec, 0x3d, 0x41, 0x55, 0xa1, 0x3b, 0xc7, 0x66, 0x7d, 0x99, 0x2d, 0x7a, 0x13, 0x9c, 0xb1, 0x9f, 0x84, 0xf8}; + uint8_t bytesprops5[] = {0xe1}; + uint8_t bytesprops6[] = {0xa1, 0x53, 0xe8, 0x4b, 0xcb}; + uint8_t bytesprops7[] = {0xc0, 0x4d, 0x22, 0x67, 0x72, 0x65, 0x49, 0xc7, 0xb1, 0x7d, 0x5a, 0x5d, 0x29}; + uint8_t bytesprops8[] = {0x16, 0x7f, 0x25, 0xde, 0xb2, 0x75, 0xf8, 0x84, 0xf7, 0xd4, 0xe5, 0x75, 0x9b, 0x49, 0x75, 0xd9, 0xb6, 0x40, 0x49, 0x17, 0x22, 0x58}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30251}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3997}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 222}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2395}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 882}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16738}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={30, (char*)&bytesprops3}, .v={22, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 692}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2828}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13055}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14438}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26576}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4108, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7750, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 28646 [("\224\NAK[\140\150Pw\230\154\136,A\236+U\195sv\137 \161\251K",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\177\&6\255\208\&6s5\196\213\&7\242\172\v?\226_} r2\ENQB\225\136",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(",\181T\ETX\169&\SOH",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\231\185\DC3\162h\140[&\152A\151\t\128\157\a\143S",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("f\169\228\149VWZ\202B'\230\219\143j\160GJ\187+\175\248;K\185",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("`\ENQ\147P\ESC\152\157\138\168Qq\215\230\199\235I2[",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("X\148:\ENQ\215R\184\152\ACK\221\250\194\185W\248\155\FSI\t\132\251\148\146",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("v\189",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\145\160\130/\197z\202\198Uyv",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS2}),("\176Xe",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\DC4\\d\168\230N\241",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic -// "\207)",PropSessionExpiryInterval 16655,PropWildcardSubscriptionAvailable 72,PropUserProperty -// "\ETB\GS\140\138\145+\232?O\213\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("l\232\254\201\210\146\&9\138\199\199?\n`~(#\223\NUL\152\142\194\&0\227\213>",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\183Gl\161\243g%\128",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropResponseInformation "\175iA^\225\203\ACK\FSE\175e\DLE\NAK\189\253\249\194J\181^\134\158\ETBQ\ESC\EOT",PropTopicAlias 2462,PropAssignedClientIdentifier "\251\171*\164\251Q\158\154q\214\194\144\239v\217\200\220\CAN\201\SI\a\192\255\FS",PropReceiveMaximum 11788,PropWillDelayInterval 4283,PropAuthenticationData "=B\238\177b\179\162\DC3\246\254\228s",PropSubscriptionIdentifierAvailable 66,PropTopicAlias 11878,PropMessageExpiryInterval 17512,PropServerKeepAlive 19493,PropAuthenticationMethod "\149\217\196\177z\245\161\240[\169\FSZ1z\SUBH\EOT\166\250\193\197\218",PropTopicAliasMaximum 16410,PropMessageExpiryInterval 8324,PropCorrelationData "\206\247\&5\148\231\220z\179\&6\169l7\235\237\161\241\t\208\152 \158\&9\179\240\136\188h"] +TEST(Subscribe5QCTest, Encode15) { +uint8_t pkt[] = {0x82, 0x92, 0x2, 0x1b, 0xa, 0x9e, 0x1, 0x1a, 0x0, 0x1a, 0xaf, 0x69, 0x41, 0x5e, 0xe1, 0xcb, 0x6, 0x1c, 0x45, 0xaf, 0x65, 0x10, 0x15, 0xbd, 0xfd, 0xf9, 0xc2, 0x4a, 0xb5, 0x5e, 0x86, 0x9e, 0x17, 0x51, 0x1b, 0x4, 0x23, 0x9, 0x9e, 0x12, 0x0, 0x18, 0xfb, 0xab, 0x2a, 0xa4, 0xfb, 0x51, 0x9e, 0x9a, 0x71, 0xd6, 0xc2, 0x90, 0xef, 0x76, 0xd9, 0xc8, 0xdc, 0x18, 0xc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c7, 0xc7, 0x3f, 0xa, 0x60, 0x7e, 0x28, 0x23, 0xdf, 0x0, 0x98, 0x8e, 0xc2, 0x30, 0xe3, 0xd5, 0x3e, 0x26, 0x0, 0x8, 0xb7, 0x47, 0x6c, 0xa1, 0xf3, 0x67, 0x25, 0x80, 0xd}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xb0, 0x83, 0xb2, 0xdf, 0x7a, 0xc4, 0x37, 0xf4, 0x50, 0xff, 0xc6, 0xb6, 0xb6, 0x59, 0xfa, 0x65, 0x26, 0xad, 0xd7, 0x81, 0x1, 0xb9, 0xa, 0x51, 0x37, 0x0, 0x4b, 0x1, 0x2a}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x58, 0x76, 0xbf, 0x51, 0x6e, 0x92, 0x6, 0x18, 0x9f, 0x31, 0xfb, 0x55, 0xca, 0xe9, 0x42, 0xd, 0x9e, 0xea, 0xed}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x8e, 0xc4, 0xf5, 0xe4, 0x59, 0x7b, 0x23, 0x31, 0xa, 0xe3, 0x97, 0xd7, 0x3e, 0x4f, 0xd5, 0x83}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6c, 0xe8, 0xfe, 0xc9, 0xd2, 0x92, 0x39, 0x8a, 0xc7, 0xc7, 0x3f, 0xa, 0x60, 0x7e, 0x28, 0x23, 0xdf, 0x0, 0x98, 0x8e, 0xc2, 0x30, 0xe3, 0xd5, 0x3e}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xb7, 0x47, 0x6c, 0xa1, 0xf3, 0x67, 0x25, 0x80}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; +lwmqtt_sub_options_t sub_opts[5]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = true; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = true; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = true; +sub_opts[2].no_local = true; +sub_opts[3].qos = LWMQTT_QOS2; +sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = true; +sub_opts[4].qos = LWMQTT_QOS1; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = true; +sub_opts[4].no_local = true; + uint8_t bytesprops0[] = {0xaf, 0x69, 0x41, 0x5e, 0xe1, 0xcb, 0x6, 0x1c, 0x45, 0xaf, 0x65, 0x10, 0x15, 0xbd, 0xfd, 0xf9, 0xc2, 0x4a, 0xb5, 0x5e, 0x86, 0x9e, 0x17, 0x51, 0x1b, 0x4}; + uint8_t bytesprops1[] = {0xfb, 0xab, 0x2a, 0xa4, 0xfb, 0x51, 0x9e, 0x9a, 0x71, 0xd6, 0xc2, 0x90, 0xef, 0x76, 0xd9, 0xc8, 0xdc, 0x18, 0xc9, 0xf, 0x7, 0xc0, 0xff, 0x1c}; + uint8_t bytesprops2[] = {0x3d, 0x42, 0xee, 0xb1, 0x62, 0xb3, 0xa2, 0x13, 0xf6, 0xfe, 0xe4, 0x73}; + uint8_t bytesprops3[] = {0x95, 0xd9, 0xc4, 0xb1, 0x7a, 0xf5, 0xa1, 0xf0, 0x5b, 0xa9, 0x1c, 0x5a, 0x31, 0x7a, 0x1a, 0x48, 0x4, 0xa6, 0xfa, 0xc1, 0xc5, 0xda}; + uint8_t bytesprops4[] = {0xce, 0xf7, 0x35, 0x94, 0xe7, 0xdc, 0x7a, 0xb3, 0x36, 0xa9, 0x6c, 0x37, 0xeb, 0xed, 0xa1, 0xf1, 0x9, 0xd0, 0x98, 0x20, 0x9e, 0x39, 0xb3, 0xf0, 0x88, 0xbc, 0x68}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16655}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2462}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11788}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4283}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11878}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17512}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19493}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16410}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8324}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops4}}}, }; lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28646, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6922, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 31174 [(":\243\230#\164\248!\232\150\150+\138m\198\212\"\193f\129\SOH}K\195\171\150",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("4`MS\232\255\169oP\EOT\RS\198P\250r2\135\v\183FW\STX)\173",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("K\167{\179J\RS\NAK3=*T4\208*\145\228\198h\252\246\248\a",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\ETB\245\174A\225F\225\216j\197\147B\t\254\132\216\164\205\150K$\164lT\ETX\212mRv",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\180Sg\a&R\165\162\174g\178\253\GS*\197i\USu_&\229\201\131d\169\231@",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\184l\ETX\225\&2\130\189\132\DC22N9\214\175@\197M\241/X#\ACKQ0\250q\DC4\r",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\253C7\NAK\203#\170",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\133\213\133\SUB\235\254\194\&5\223\143\241-\SUB\177n\233\211{\FSE",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] -// [PropSubscriptionIdentifierAvailable 205,PropWildcardSubscriptionAvailable 32] + +// SubscribeRequest 26316 [("\229\199\211Bm\186\243W\161\139O{A ^F\180,!5y\243\EOT\166\226opy\131\ESC",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Z\153\&6\215(\215\EM\137\140\252",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("U\\N\255a\146",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\174\\\247w\175\SYN\148o\191E\n[\197\SO\197a\175\227\236",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\DC2\180\170\148L1[`@[\253\159,\136`\ESC\229\DEL5\210\193\ESC@\131\152\212",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\141\&8\227\131\152p\224\162\146\228\175V \142\191QR\139g\188\165vf",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("N\240`q\204\255|\b\156A\227\238",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropMaximumPacketSize 17342,PropPayloadFormatIndicator 202,PropRequestProblemInformation 206,PropTopicAlias 20086,PropWildcardSubscriptionAvailable 171,PropMaximumQoS 190,PropMaximumQoS 87,PropMessageExpiryInterval 29692,PropUserProperty "m\165\210)cD" "\158c\252?'\245\170R*\146\200\208\FS\202p\ENQ",PropServerReference "\201\220\231\219\214\200\231T1\229c\171\238\143\133n\228gd(@\213\SUB",PropMessageExpiryInterval 6551,PropAssignedClientIdentifier "ki\218\160DW=\241\172\244\207\198\STX\130Zm'",PropAssignedClientIdentifier "\212\173\r\148\SOH`\169\241\138\214%\176\239\190\158\&1\160\128\&6Z\SO#\145T\145A]\224\v",PropSessionExpiryInterval 20280,PropPayloadFormatIndicator 72,PropMessageExpiryInterval 21059,PropContentType "\155\221\158",PropTopicAlias 14,PropContentType "W\149`w,f\206\ETXx\184~\142\201\214O\FS",PropSubscriptionIdentifier 0,PropTopicAliasMaximum 15849,PropRetainAvailable 48,PropMessageExpiryInterval 25313] TEST(Subscribe5QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0xd8, 0x1, 0x79, 0xc6, 0x4, 0x29, 0xcd, 0x28, 0x20, 0x0, 0x19, 0x3a, 0xf3, 0xe6, 0x23, 0xa4, - 0xf8, 0x21, 0xe8, 0x96, 0x96, 0x2b, 0x8a, 0x6d, 0xc6, 0xd4, 0x22, 0xc1, 0x66, 0x81, 0x1, 0x7d, 0x4b, - 0xc3, 0x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buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x3a, 0xf3, 0xe6, 0x23, 0xa4, 0xf8, 0x21, 0xe8, 0x96, 0x96, 0x2b, 0x8a, 0x6d, - 0xc6, 0xd4, 0x22, 0xc1, 0x66, 0x81, 0x1, 0x7d, 0x4b, 0xc3, 0xab, 0x96}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x34, 0x60, 0x4d, 0x53, 0xe8, 0xff, 0xa9, 0x6f, 0x50, 0x4, 0x1e, 0xc6, - 0x50, 0xfa, 0x72, 0x32, 0x87, 0xb, 0xb7, 0x46, 0x57, 0x2, 0x29, 0xad}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4b, 0xa7, 0x7b, 0xb3, 0x4a, 0x1e, 0x15, 0x33, 0x3d, 0x2a, 0x54, - 0x34, 0xd0, 0x2a, 0x91, 0xe4, 0xc6, 0x68, 0xfc, 0xf6, 0xf8, 0x7}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x17, 0xf5, 0xae, 0x41, 0xe1, 0x46, 0xe1, 0xd8, 0x6a, 0xc5, - 0x93, 0x42, 0x9, 0xfe, 0x84, 0xd8, 0xa4, 0xcd, 0x96, 0x4b, - 0x24, 0xa4, 0x6c, 0x54, 0x3, 0xd4, 0x6d, 0x52, 0x76}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb4, 0x53, 0x67, 0x7, 0x26, 0x52, 0xa5, 0xa2, 0xae, 0x67, 0xb2, 0xfd, 0x1d, 0x2a, - 0xc5, 0x69, 0x1f, 0x75, 0x5f, 0x26, 0xe5, 0xc9, 0x83, 0x64, 0xa9, 0xe7, 0x40}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; +uint8_t pkt[] = {0x82, 0xd3, 0x2, 0x66, 0xcc, 0xb9, 0x1, 0x27, 0x0, 0x0, 0x43, 0xbe, 0x1, 0xca, 0x17, 0xce, 0x23, 0x4e, 0x76, 0x28, 0xab, 0x24, 0xbe, 0x24, 0x57, 0x2, 0x0, 0x0, 0x73, 0xfc, 0x26, 0x0, 0x6, 0x6d, 0xa5, 0xd2, 0x29, 0x63, 0x44, 0x0, 0x10, 0x9e, 0x63, 0xfc, 0x3f, 0x27, 0xf5, 0xaa, 0x52, 0x2a, 0x92, 0xc8, 0xd0, 0x1c, 0xca, 0x70, 0x5, 0x1c, 0x0, 0x17, 0xc9, 0xdc, 0xe7, 0xdb, 0xd6, 0xc8, 0xe7, 0x54, 0x31, 0xe5, 0x63, 0xab, 0xee, 0x8f, 0x85, 0x6e, 0xe4, 0x67, 0x64, 0x28, 0x40, 0xd5, 0x1a, 0x2, 0x0, 0x0, 0x19, 0x97, 0x12, 0x0, 0x11, 0x6b, 0x69, 0xda, 0xa0, 0x44, 0x57, 0x3d, 0xf1, 0xac, 0xf4, 0xcf, 0xc6, 0x2, 0x82, 0x5a, 0x6d, 0x27, 0x12, 0x0, 0x1d, 0xd4, 0xad, 0xd, 0x94, 0x1, 0x60, 0xa9, 0xf1, 0x8a, 0xd6, 0x25, 0xb0, 0xef, 0xbe, 0x9e, 0x31, 0xa0, 0x80, 0x36, 0x5a, 0xe, 0x23, 0x91, 0x54, 0x91, 0x41, 0x5d, 0xe0, 0xb, 0x11, 0x0, 0x0, 0x4f, 0x38, 0x1, 0x48, 0x2, 0x0, 0x0, 0x52, 0x43, 0x3, 0x0, 0x3, 0x9b, 0xdd, 0x9e, 0x23, 0x0, 0xe, 0x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ic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xe5, 0xc7, 0xd3, 0x42, 0x6d, 0xba, 0xf3, 0x57, 0xa1, 0x8b, 0x4f, 0x7b, 0x41, 0x20, 0x5e, 0x46, 0xb4, 0x2c, 0x21, 0x35, 0x79, 0xf3, 0x4, 0xa6, 0xe2, 0x6f, 0x70, 0x79, 0x83, 0x1b}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x5a, 0x99, 0x36, 0xd7, 0x28, 0xd7, 0x19, 0x89, 0x8c, 0xfc}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x55, 0x5c, 0x4e, 0xff, 0x61, 0x92}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xae, 0x5c, 0xf7, 0x77, 0xaf, 0x16, 0x94, 0x6f, 0xbf, 0x45, 0xa, 0x5b, 0xc5, 0xe, 0xc5, 0x61, 0xaf, 0xe3, 0xec}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x12, 0xb4, 0xaa, 0x94, 0x4c, 0x31, 0x5b, 0x60, 0x40, 0x5b, 0xfd, 0x9f, 0x2c, 0x88, 0x60, 0x1b, 0xe5, 0x7f, 0x35, 0xd2, 0xc1, 0x1b, 0x40, 0x83, 0x98, 0xd4}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; uint8_t topic_filter_s5_bytes[] = {0}; lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb8, 0x6c, 0x3, 0xe1, 0x32, 0x82, 0xbd, 0x84, 0x12, 0x32, 0x4e, 0x39, 0xd6, 0xaf, - 0x40, 0xc5, 0x4d, 0xf1, 0x2f, 0x58, 0x23, 0x6, 0x51, 0x30, 0xfa, 0x71, 0x14, 0xd}; - lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xfd, 0x43, 0x37, 0x15, 0xcb, 0x23, 0xaa}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x85, 0xd5, 0x85, 0x1a, 0xeb, 0xfe, 0xc2, 0x35, 0xdf, 0x8f, - 0xf1, 0x2d, 0x1a, 0xb1, 0x6e, 0xe9, 0xd3, 0x7b, 0x1c, 0x45}; - lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = true; - +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8d, 0x38, 0xe3, 0x83, 0x98, 0x70, 0xe0, 0xa2, 0x92, 0xe4, 0xaf, 0x56, 0x20, 0x8e, 0xbf, 0x51, 0x52, 0x8b, 0x67, 0xbc, 0xa5, 0x76, 0x66}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x4e, 0xf0, 0x60, 0x71, 0xcc, 0xff, 0x7c, 0x8, 0x9c, 0x41, 0xe3, 0xee}; + lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; +lwmqtt_sub_options_t sub_opts[8]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = true; +sub_opts[1].no_local = true; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = true; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[3].retain_as_published = true; +sub_opts[3].no_local = true; +sub_opts[4].qos = LWMQTT_QOS2; +sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; +sub_opts[6].qos = LWMQTT_QOS2; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[6].retain_as_published = true; +sub_opts[6].no_local = true; +sub_opts[7].qos = LWMQTT_QOS0; +sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[7].retain_as_published = true; +sub_opts[7].no_local = false; + uint8_t bytesprops1[] = {0x9e, 0x63, 0xfc, 0x3f, 0x27, 0xf5, 0xaa, 0x52, 0x2a, 0x92, 0xc8, 0xd0, 0x1c, 0xca, 0x70, 0x5}; + uint8_t bytesprops0[] = {0x6d, 0xa5, 0xd2, 0x29, 0x63, 0x44}; + uint8_t bytesprops2[] = {0xc9, 0xdc, 0xe7, 0xdb, 0xd6, 0xc8, 0xe7, 0x54, 0x31, 0xe5, 0x63, 0xab, 0xee, 0x8f, 0x85, 0x6e, 0xe4, 0x67, 0x64, 0x28, 0x40, 0xd5, 0x1a}; + uint8_t bytesprops3[] = {0x6b, 0x69, 0xda, 0xa0, 0x44, 0x57, 0x3d, 0xf1, 0xac, 0xf4, 0xcf, 0xc6, 0x2, 0x82, 0x5a, 0x6d, 0x27}; + uint8_t bytesprops4[] = {0xd4, 0xad, 0xd, 0x94, 0x1, 0x60, 0xa9, 0xf1, 0x8a, 0xd6, 0x25, 0xb0, 0xef, 0xbe, 0x9e, 0x31, 0xa0, 0x80, 0x36, 0x5a, 0xe, 0x23, 0x91, 0x54, 0x91, 0x41, 0x5d, 0xe0, 0xb}; + uint8_t bytesprops5[] = {0x9b, 0xdd, 0x9e}; + uint8_t bytesprops6[] = {0x57, 0x95, 0x60, 0x77, 0x2c, 0x66, 0xce, 0x3, 0x78, 0xb8, 0x7e, 0x8e, 0xc9, 0xd6, 0x4f, 0x1c}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17342}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20086}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29692}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={6, (char*)&bytesprops0}, .v={16, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6551}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20280}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21059}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15849}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25313}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31174, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26316, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 2900 [("\249J\154\194\178Mb\255\165\234\213K\141%\167\ESC\151\152\176\236\214",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("7\144\f>\ACKS$|\SI",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal -// = True, _subQoS = QoS1}),("!",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal -// = True, _subQoS = -// QoS2}),("v\150\SO\163x\160B\220\209E\162\156\a!Z\251",PropSharedSubscriptionAvailable -// 77,PropSubscriptionIdentifier 24,PropResponseTopic -// "F\165\209\189x\225\202\STX\135\144\221F\251\219\168\212\235{",PropReasonString -// "\202y\176\144\&5\195\SOH\215\184\237S\SYN\190",PropReceiveMaximum 29384,PropResponseInformation -// "M\218\SO\164\227\GSw\192\188\SO\154W\204K=\247\144\&1\SYN\254V\238\155u\173f",PropWillDelayInterval -// 29671,PropServerReference "\aI\167\&9b\140\200V:F\165\248\234\232",PropAssignedClientIdentifier -// "q]\176\136i\167\"\228\184K\142\223Z\254\152M \DC4j`\EM\SI?E",PropWillDelayInterval -// 668,PropSharedSubscriptionAvailable 250,PropCorrelationData "\DC4$R\"\255",PropAuthenticationData -// "I-\189\176\141\242\a\135\251\210\184!\228;E>^\206g\147\147\DLE\NAK\FS\173k",PropMaximumQoS 10,PropRetainAvailable -// 36,PropAuthenticationData "\146\240E*+\204\247"] -TEST(Subscribe5QCTest, Encode19) { - uint8_t pkt[] = { - 0x82, 0x96, 0x2, 0x5e, 0xd4, 0xe7, 0x1, 0x22, 0x46, 0xcc, 0x1f, 0x0, 0x10, 0xc7, 0xfd, 0x7a, 0x19, 0x44, 0xca, - 0x62, 0x96, 0x4, 0x60, 0x52, 0xda, 0x39, 0x17, 0x13, 0x45, 0x12, 0x0, 0x1a, 0x6, 0x5, 0xaf, 0xf, 0x3a, 0x7c, - 0xbf, 0x6d, 0xe9, 0x8b, 0x5f, 0x68, 0xef, 0x5, 0xae, 0xfb, 0x2e, 0xc, 0x91, 0x3e, 0xa2, 0x9c, 0x7, 0x21, 0x5a, - 0xfb, 0x2a, 0x4d, 0xb, 0x18, 0x8, 0x0, 0x12, 0x46, 0xa5, 0xd1, 0xbd, 0x78, 0xe1, 0xca, 0x2, 0x87, 0x90, 0xdd, - 0x46, 0xfb, 0xdb, 0xa8, 0xd4, 0xeb, 0x7b, 0x1f, 0x0, 0xd, 0xca, 0x79, 0xb0, 0x90, 0x35, 0xc3, 0x1, 0xd7, 0xb8, - 0xed, 0x53, 0x16, 0xbe, 0x21, 0x72, 0xc8, 0x1a, 0x0, 0x1a, 0x4d, 0xda, 0xe, 0xa4, 0xe3, 0x1d, 0x77, 0xc0, 0xbc, - 0xe, 0x9a, 0x57, 0xcc, 0x4b, 0x3d, 0xf7, 0x90, 0x31, 0x16, 0xfe, 0x56, 0xee, 0x9b, 0x75, 0xad, 0x66, 0x18, 0x0, - 0x0, 0x73, 0xe7, 0x1c, 0x0, 0xe, 0x7, 0x49, 0xa7, 0x39, 0x62, 0x8c, 0xc8, 0x56, 0x3a, 0x46, 0xa5, 0xf8, 0xea, - 0xe8, 0x12, 0x0, 0x18, 0x71, 0x5d, 0xb0, 0x88, 0x69, 0xa7, 0x22, 0xe4, 0xb8, 0x4b, 0x8e, 0xdf, 0x5a, 0xfe, 0x98, - 0x4d, 0x20, 0x14, 0x6a, 0x60, 0x19, 0xf, 0x3f, 0x45, 0x18, 0x0, 0x0, 0x2, 0x9c, 0x2a, 0xfa, 0x9, 0x0, 0x5, - 0x14, 0x24, 0x52, 0x22, 0xff, 0x16, 0x0, 0x1a, 0x49, 0x2d, 0xbd, 0xb0, 0x8d, 0xf2, 0x7, 0x87, 0xfb, 0xd2, 0xb8, - 0x21, 0xe4, 0x3b, 0x45, 0x3e, 0x5e, 0xce, 0x67, 0x93, 0x93, 0x10, 0x15, 0x1c, 0xad, 0x6b, 0x24, 0xa, 0x25, 0x24, - 0x16, 0x0, 0x7, 0x92, 0xf0, 0x45, 0x2a, 0x2b, 0xcc, 0xf7, 0x0, 0x10, 0xb3, 0xf3, 0xcc, 0xef, 0xbb, 0x4d, 0x24, - 0xc6, 0xf1, 0x2a, 0xe7, 0x7a, 0x5, 0x60, 0x58, 0x75, 0xa, 0x0, 0x15, 0x6b, 0x77, 0xb0, 0x7d, 0xee, 0xd, 0xc7, - 0x42, 0xbd, 0xb2, 0x44, 0xb3, 0x29, 0xb, 0x64, 0x22, 0xa, 0xe, 0x48, 0x55, 0x6c, 0x1c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xb3, 0xf3, 0xcc, 0xef, 0xbb, 0x4d, 0x24, 0xc6, - 0xf1, 0x2a, 0xe7, 0x7a, 0x5, 0x60, 0x58, 0x75}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6b, 0x77, 0xb0, 0x7d, 0xee, 0xd, 0xc7, 0x42, 0xbd, 0xb2, 0x44, - 0xb3, 0x29, 0xb, 0x64, 0x22, 0xa, 0xe, 0x48, 0x55, 0x6c}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - uint8_t bytesprops0[] = {0xc7, 0xfd, 0x7a, 0x19, 0x44, 0xca, 0x62, 0x96, - 0x4, 0x60, 0x52, 0xda, 0x39, 0x17, 0x13, 0x45}; - uint8_t bytesprops1[] = {0x6, 0x5, 0xaf, 0xf, 0x3a, 0x7c, 0xbf, 0x6d, 0xe9, 0x8b, 0x5f, 0x68, 0xef, - 0x5, 0xae, 0xfb, 0x2e, 0xc, 0x91, 0x3e, 0xa2, 0x9c, 0x7, 0x21, 0x5a, 0xfb}; - uint8_t bytesprops2[] = {0x46, 0xa5, 0xd1, 0xbd, 0x78, 0xe1, 0xca, 0x2, 0x87, - 0x90, 0xdd, 0x46, 0xfb, 0xdb, 0xa8, 0xd4, 0xeb, 0x7b}; - uint8_t bytesprops3[] = {0xca, 0x79, 0xb0, 0x90, 0x35, 0xc3, 0x1, 0xd7, 0xb8, 0xed, 0x53, 0x16, 0xbe}; - uint8_t bytesprops4[] = {0x4d, 0xda, 0xe, 0xa4, 0xe3, 0x1d, 0x77, 0xc0, 0xbc, 0xe, 0x9a, 0x57, 0xcc, - 0x4b, 0x3d, 0xf7, 0x90, 0x31, 0x16, 0xfe, 0x56, 0xee, 0x9b, 0x75, 0xad, 0x66}; - uint8_t bytesprops5[] = {0x7, 0x49, 0xa7, 0x39, 0x62, 0x8c, 0xc8, 0x56, 0x3a, 0x46, 0xa5, 0xf8, 0xea, 0xe8}; - uint8_t bytesprops6[] = {0x71, 0x5d, 0xb0, 0x88, 0x69, 0xa7, 0x22, 0xe4, 0xb8, 0x4b, 0x8e, 0xdf, - 0x5a, 0xfe, 0x98, 0x4d, 0x20, 0x14, 0x6a, 0x60, 0x19, 0xf, 0x3f, 0x45}; - uint8_t bytesprops7[] = {0x14, 0x24, 0x52, 0x22, 0xff}; - uint8_t bytesprops8[] = {0x49, 0x2d, 0xbd, 0xb0, 0x8d, 0xf2, 0x7, 0x87, 0xfb, 0xd2, 0xb8, 0x21, 0xe4, - 0x3b, 0x45, 0x3e, 0x5e, 0xce, 0x67, 0x93, 0x93, 0x10, 0x15, 0x1c, 0xad, 0x6b}; - uint8_t bytesprops9[] = {0x92, 0xf0, 0x45, 0x2a, 0x2b, 0xcc, 0xf7}; +// SubscribeRequest 3152 [("\221jG\162A\208>\210\170r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\198\138\161\233\v\180\STX\241\207\221\150\234\128)\130\nF\209\ETX\GSVdb",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\148y\243\207\167\176HiA\209\148mB\219\169\138\169c\r\173b\150Q\247\153}\221F",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\243\171\216\165!\EOT,g\235G\164 2\206\211-\b-D\218",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropPayloadFormatIndicator 48,PropTopicAlias 5835,PropMessageExpiryInterval 29048,PropResponseInformation "\188\164\EM\205@\235\tL6\213\238\233A\EM\194\\\229\247 \ESC&\211(\ETB",PropSubscriptionIdentifierAvailable 228,PropContentType "S\171\ETX\b\139\191Y\219\234\&3j]\193\195u2\215\153",PropResponseTopic "\167\225N{\142\r\163\214\133\155\188\EOT\231\151<\DLE\SUB",PropMaximumPacketSize 13133,PropRequestResponseInformation 229,PropRequestProblemInformation 75] +TEST(Subscribe5QCTest, Encode19) { +uint8_t pkt[] = {0x82, 0xbc, 0x1, 0xc, 0x50, 0x59, 0x1, 0x30, 0x23, 0x16, 0xcb, 0x2, 0x0, 0x0, 0x71, 0x78, 0x1a, 0x0, 0x18, 0xbc, 0xa4, 0x19, 0xcd, 0x40, 0xeb, 0x9, 0x4c, 0x36, 0xd5, 0xee, 0xe9, 0x41, 0x19, 0xc2, 0x5c, 0xe5, 0xf7, 0x20, 0x1b, 0x26, 0xd3, 0x28, 0x17, 0x29, 0xe4, 0x3, 0x0, 0x12, 0x53, 0xab, 0x3, 0x8, 0x8b, 0xbf, 0x59, 0xdb, 0xea, 0x33, 0x6a, 0x5d, 0xc1, 0xc3, 0x75, 0x32, 0xd7, 0x99, 0x8, 0x0, 0x11, 0xa7, 0xe1, 0x4e, 0x7b, 0x8e, 0xd, 0xa3, 0xd6, 0x85, 0x9b, 0xbc, 0x4, 0xe7, 0x97, 0x3c, 0x10, 0x1a, 0x27, 0x0, 0x0, 0x33, 0x4d, 0x19, 0xe5, 0x17, 0x4b, 0x0, 0xa, 0xdd, 0x6a, 0x47, 0xa2, 0x41, 0xd0, 0x3e, 0xd2, 0xaa, 0x72, 0x8, 0x0, 0x0, 0x0, 0x0, 0x17, 0xc6, 0x8a, 0xa1, 0xe9, 0xb, 0xb4, 0x2, 0xf1, 0xcf, 0xdd, 0x96, 0xea, 0x80, 0x29, 0x82, 0xa, 0x46, 0xd1, 0x3, 0x1d, 0x56, 0x64, 0x62, 0x0, 0x0, 0x1c, 0x94, 0x79, 0xf3, 0xcf, 0xa7, 0xb0, 0x48, 0x69, 0x41, 0xd1, 0x94, 0x6d, 0x42, 0xdb, 0xa9, 0x8a, 0xa9, 0x63, 0xd, 0xad, 0x62, 0x96, 0x51, 0xf7, 0x99, 0x7d, 0xdd, 0x46, 0x15, 0x0, 0x14, 0xf3, 0xab, 0xd8, 0xa5, 0x21, 0x4, 0x2c, 0x67, 0xeb, 0x47, 0xa4, 0x20, 0x32, 0xce, 0xd3, 0x2d, 0x8, 0x2d, 0x44, 0xda, 0x11}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xdd, 0x6a, 0x47, 0xa2, 0x41, 0xd0, 0x3e, 0xd2, 0xaa, 0x72}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc6, 0x8a, 0xa1, 0xe9, 0xb, 0xb4, 0x2, 0xf1, 0xcf, 0xdd, 0x96, 0xea, 0x80, 0x29, 0x82, 0xa, 0x46, 0xd1, 0x3, 0x1d, 0x56, 0x64, 0x62}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x94, 0x79, 0xf3, 0xcf, 0xa7, 0xb0, 0x48, 0x69, 0x41, 0xd1, 0x94, 0x6d, 0x42, 0xdb, 0xa9, 0x8a, 0xa9, 0x63, 0xd, 0xad, 0x62, 0x96, 0x51, 0xf7, 0x99, 0x7d, 0xdd, 0x46}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xf3, 0xab, 0xd8, 0xa5, 0x21, 0x4, 0x2c, 0x67, 0xeb, 0x47, 0xa4, 0x20, 0x32, 0xce, 0xd3, 0x2d, 0x8, 0x2d, 0x44, 0xda}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; +lwmqtt_sub_options_t sub_opts[5]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = true; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS0; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = true; +sub_opts[4].qos = LWMQTT_QOS1; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = false; + uint8_t bytesprops0[] = {0xbc, 0xa4, 0x19, 0xcd, 0x40, 0xeb, 0x9, 0x4c, 0x36, 0xd5, 0xee, 0xe9, 0x41, 0x19, 0xc2, 0x5c, 0xe5, 0xf7, 0x20, 0x1b, 0x26, 0xd3, 0x28, 0x17}; + uint8_t bytesprops1[] = {0x53, 0xab, 0x3, 0x8, 0x8b, 0xbf, 0x59, 0xdb, 0xea, 0x33, 0x6a, 0x5d, 0xc1, 0xc3, 0x75, 0x32, 0xd7, 0x99}; + uint8_t bytesprops2[] = {0xa7, 0xe1, 0x4e, 0x7b, 0x8e, 0xd, 0xa3, 0xd6, 0x85, 0x9b, 0xbc, 0x4, 0xe7, 0x97, 0x3c, 0x10, 0x1a}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18124}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29384}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29671}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 668}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5835}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29048}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13133}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 75}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24276, 2, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3152, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 17953 [("\230\CAN\157,Q",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS2}),("W",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// True, _noLocal = True, _subQoS = QoS1}),("1/\218k\SOH\193\234\176zfB\215\166+\DC1Rzc",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("?N\223\&4<\167\174\222\&4",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = -// QoS1}),("\237\v\239\243\170\&0\135\144\178*\146\194if\US\203\&9'\172\166|\128\129m\188|l\141i\164",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\238\232\v\ENQ -// \239\SOH\149\159P",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, -// _subQoS = QoS1}),("\191\217\139T!It\188\RS\EM\246\171\172\134u\234\170\168R\185\139\229\ESC",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("{\186\SIi\DLE\171\225\241\&6",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS2}),("\166",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = True, _noLocal = True, _subQoS = QoS2}),("~J\231\169\143\142y\137\254m\135\249\196X\DC4J",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropMaximumQoS -// 139,PropTopicAlias 22521,PropSubscriptionIdentifierAvailable 34,PropUserProperty "\SI+\143\241\230%<\231\227I\214" -// "\167\201<\233 \STX\165lB\229\219W\205Z\159\n\187\222",PropAuthenticationData -// "\207\143,\240\186\203\168\197\143\159\178\134\155\&6\SI\247\159\196\212\186\183gq\199\252\251",PropServerReference -// "!\208\170L_\177\174%\STX\188\206u\SOH;\255\&2\SO\129;\213\SYN\171",PropRequestProblemInformation -// 36,PropServerReference "\192\220AE\232t?/B\129\164\144\NUL\214\144\203q\US\206\EOT",PropPayloadFormatIndicator -// 172,PropWildcardSubscriptionAvailable 221,PropRequestResponseInformation 175,PropWildcardSubscriptionAvailable -// 251,PropWillDelayInterval 7152,PropSubscriptionIdentifier 31,PropCorrelationData -// "U\FSG\203\243\191\251{\\\r.\186\148\242U\SYN\192p\GS\204V",PropTopicAliasMaximum 21728,PropServerReference -// "\DC2\171}+\153\STX\242m\DC1\ACK\155 \235",PropResponseInformation "e",PropResponseTopic ""] -TEST(Subscribe5QCTest, Encode20) { - uint8_t pkt[] = { - 0x82, 0xd8, 0x2, 0x46, 0x21, 0xb9, 0x1, 0x24, 0x8b, 0x23, 0x57, 0xf9, 0x29, 0x22, 0x26, 0x0, 0xb, 0xf, 0x2b, - 0x8f, 0xf1, 0xe6, 0x25, 0x3c, 0xe7, 0xe3, 0x49, 0xd6, 0x0, 0x12, 0xa7, 0xc9, 0x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 0xa6, 0x2b, 0x11, 0x52, 0x7a, 0x63, 0x16, 0x0, 0x9, 0x3f, - 0x4e, 0xdf, 0x34, 0x3c, 0xa7, 0xae, 0xde, 0x34, 0x25, 0x0, 0x1e, 0xed, 0xb, 0xef, 0xf3, 0xaa, 0x30, 0x87, 0x90, - 0xb2, 0x2a, 0x92, 0xc2, 0x69, 0x66, 0x1f, 0xcb, 0x39, 0x27, 0xac, 0xa6, 0x7c, 0x80, 0x81, 0x6d, 0xbc, 0x7c, 0x6c, - 0x8d, 0x69, 0xa4, 0x1c, 0x0, 0xa, 0xee, 0xe8, 0xb, 0x5, 0x20, 0xef, 0x1, 0x95, 0x9f, 0x50, 0x2d, 0x0, 0x17, - 0xbf, 0xd9, 0x8b, 0x54, 0x21, 0x49, 0x74, 0xbc, 0x1e, 0x19, 0xf6, 0xab, 0xac, 0x86, 0x75, 0xea, 0xaa, 0xa8, 0x52, - 0xb9, 0x8b, 0xe5, 0x1b, 0x1, 0x0, 0x9, 0x7b, 0xba, 0xf, 0x69, 0x10, 0xab, 0xe1, 0xf1, 0x36, 0x2a, 0x0, 0x1, - 0xa6, 0x20, 0x0, 0x0, 0x2e, 0x0, 0x10, 0x7e, 0x4a, 0xe7, 0xa9, 0x8f, 0x8e, 0x79, 0x89, 0xfe, 0x6d, 0x87, 0xf9, - 0xc4, 0x58, 0x14, 0x4a, 0x1e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xe6, 0x18, 0x9d, 0x2c, 0x51}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x57}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x31, 0x2f, 0xda, 0x6b, 0x1, 0xc1, 0xea, 0xb0, 0x7a, - 0x66, 0x42, 0xd7, 0xa6, 0x2b, 0x11, 0x52, 0x7a, 0x63}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3f, 0x4e, 0xdf, 0x34, 0x3c, 0xa7, 0xae, 0xde, 0x34}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xed, 0xb, 0xef, 0xf3, 0xaa, 0x30, 0x87, 0x90, 0xb2, 0x2a, - 0x92, 0xc2, 0x69, 0x66, 0x1f, 0xcb, 0x39, 0x27, 0xac, 0xa6, - 0x7c, 0x80, 0x81, 0x6d, 0xbc, 0x7c, 0x6c, 0x8d, 0x69, 0xa4}; - lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xee, 0xe8, 0xb, 0x5, 0x20, 0xef, 0x1, 0x95, 0x9f, 0x50}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbf, 0xd9, 0x8b, 0x54, 0x21, 0x49, 0x74, 0xbc, 0x1e, 0x19, 0xf6, 0xab, - 0xac, 0x86, 0x75, 0xea, 0xaa, 0xa8, 0x52, 0xb9, 0x8b, 0xe5, 0x1b}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7b, 0xba, 0xf, 0x69, 0x10, 0xab, 0xe1, 0xf1, 0x36}; - lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa6}; - lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0}; - lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x7e, 0x4a, 0xe7, 0xa9, 0x8f, 0x8e, 0x79, 0x89, - 0xfe, 0x6d, 0x87, 0xf9, 0xc4, 0x58, 0x14, 0x4a}; - lwmqtt_string_t topic_filter_s10 = {16, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = true; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[10].retain_as_published = true; - sub_opts[10].no_local = true; - uint8_t bytesprops1[] = {0xa7, 0xc9, 0x3c, 0xe9, 0x20, 0x2, 0xa5, 0x6c, 0x42, - 0xe5, 0xdb, 0x57, 0xcd, 0x5a, 0x9f, 0xa, 0xbb, 0xde}; - uint8_t bytesprops0[] = {0xf, 0x2b, 0x8f, 0xf1, 0xe6, 0x25, 0x3c, 0xe7, 0xe3, 0x49, 0xd6}; - uint8_t bytesprops2[] = {0xcf, 0x8f, 0x2c, 0xf0, 0xba, 0xcb, 0xa8, 0xc5, 0x8f, 0x9f, 0xb2, 0x86, 0x9b, - 0x36, 0xf, 0xf7, 0x9f, 0xc4, 0xd4, 0xba, 0xb7, 0x67, 0x71, 0xc7, 0xfc, 0xfb}; - uint8_t bytesprops3[] = {0x21, 0xd0, 0xaa, 0x4c, 0x5f, 0xb1, 0xae, 0x25, 0x2, 0xbc, 0xce, - 0x75, 0x1, 0x3b, 0xff, 0x32, 0xe, 0x81, 0x3b, 0xd5, 0x16, 0xab}; - uint8_t bytesprops4[] = {0xc0, 0xdc, 0x41, 0x45, 0xe8, 0x74, 0x3f, 0x2f, 0x42, 0x81, - 0xa4, 0x90, 0x0, 0xd6, 0x90, 0xcb, 0x71, 0x1f, 0xce, 0x4}; - uint8_t bytesprops5[] = {0x55, 0x1c, 0x47, 0xcb, 0xf3, 0xbf, 0xfb, 0x7b, 0x5c, 0xd, 0x2e, - 0xba, 0x94, 0xf2, 0x55, 0x16, 0xc0, 0x70, 0x1d, 0xcc, 0x56}; - uint8_t bytesprops6[] = {0x12, 0xab, 0x7d, 0x2b, 0x99, 0x2, 0xf2, 0x6d, 0x11, 0x6, 0x9b, 0x20, 0xeb}; - uint8_t bytesprops7[] = {0x65}; - uint8_t bytesprops8[] = {0}; +// SubscribeRequest 17142 [("e0\211\n(1\a[m\192\250\134\179R\156:\DEL\217\&3\143Z\228\186\224\US\128\164\194\167\223",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\236^:\SYNW\249\182\&7>\191\130\SUB\146'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(":\200\140\238\238\173\241A\v\155\186\&9#m$\204\SUBe?Qr\214<3Q9O\214",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),(" \139\195\231G\f\SOHqD*F\221%F\SYN\142\&7\207\252",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("@\217Q\249+\DLE\152\DLE\237\v\180[",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\207\SI\195\138W\141H2\157b?\147N\147# a%\239\181G\236[m\NULx",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\226>An\226G\185\FS",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\131\189l\133\133\tg\128\139\&9<\151y<\197o\204\221\132\&6\151\253\213\196\&3\221i",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic "=\250i{\136y\SUB\224.\228\&8GLxb\151\171>N\NAK\243",PropCorrelationData "=v2\173n\EOT\FS\170s\182",PropTopicAliasMaximum 26880,PropTopicAlias 15262,PropMaximumQoS 40,PropSubscriptionIdentifierAvailable 189,PropServerReference "V\ETX\203\218\214\138\&14n7\172oZ\135\234\210\237\143\SO",PropRequestProblemInformation 46,PropTopicAlias 24607,PropSubscriptionIdentifier 7,PropServerKeepAlive 27192,PropSessionExpiryInterval 623,PropReceiveMaximum 27376,PropReasonString "B!\188\137'\FSL\213",PropSubscriptionIdentifierAvailable 49,PropAuthenticationMethod "\249Jo\182\210\182\168p>\ENQ&S\155\189P\DEL\179\239\&5\160\163iaGi\218<\159\240v",PropMessageExpiryInterval 2499,PropTopicAliasMaximum 12723] +TEST(Subscribe5QCTest, Encode20) { +uint8_t pkt[] = {0x82, 0xcd, 0x2, 0x42, 0xf6, 0x8d, 0x1, 0x8, 0x0, 0x15, 0x3d, 0xfa, 0x69, 0x7b, 0x88, 0x79, 0x1a, 0xe0, 0x2e, 0xe4, 0x38, 0x47, 0x4c, 0x78, 0x62, 0x97, 0xab, 0x3e, 0x4e, 0x15, 0xf3, 0x9, 0x0, 0xa, 0x3d, 0x76, 0x32, 0xad, 0x6e, 0x4, 0x1c, 0xaa, 0x73, 0xb6, 0x22, 0x69, 0x0, 0x23, 0x3b, 0x9e, 0x24, 0x28, 0x29, 0xbd, 0x1c, 0x0, 0x13, 0x56, 0x3, 0xcb, 0xda, 0xd6, 0x8a, 0x31, 0x34, 0x6e, 0x37, 0xac, 0x6f, 0x5a, 0x87, 0xea, 0xd2, 0xed, 0x8f, 0xe, 0x17, 0x2e, 0x23, 0x60, 0x1f, 0xb, 0x7, 0x13, 0x6a, 0x38, 0x11, 0x0, 0x0, 0x2, 0x6f, 0x21, 0x6a, 0xf0, 0x1f, 0x0, 0x8, 0x42, 0x21, 0xbc, 0x89, 0x27, 0x1c, 0x4c, 0xd5, 0x29, 0x31, 0x15, 0x0, 0x1e, 0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, 0x3e, 0x41, 0x6e, 0xe2, 0x47, 0xb9, 0x1c, 0x2c, 0x0, 0x1b, 0x83, 0xbd, 0x6c, 0x85, 0x85, 0x9, 0x67, 0x80, 0x8b, 0x39, 0x3c, 0x97, 0x79, 0x3c, 0xc5, 0x6f, 0xcc, 0xdd, 0x84, 0x36, 0x97, 0xfd, 0xd5, 0xc4, 0x33, 0xdd, 0x69, 0x21}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x65, 0x30, 0xd3, 0xa, 0x28, 0x31, 0x7, 0x5b, 0x6d, 0xc0, 0xfa, 0x86, 0xb3, 0x52, 0x9c, 0x3a, 0x7f, 0xd9, 0x33, 0x8f, 0x5a, 0xe4, 0xba, 0xe0, 0x1f, 0x80, 0xa4, 0xc2, 0xa7, 0xdf}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xec, 0x5e, 0x3a, 0x16, 0x57, 0xf9, 0xb6, 0x37, 0x3e, 0xbf, 0x82, 0x1a, 0x92, 0x27}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x3a, 0xc8, 0x8c, 0xee, 0xee, 0xad, 0xf1, 0x41, 0xb, 0x9b, 0xba, 0x39, 0x23, 0x6d, 0x24, 0xcc, 0x1a, 0x65, 0x3f, 0x51, 0x72, 0xd6, 0x3c, 0x33, 0x51, 0x39, 0x4f, 0xd6}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x20, 0x8b, 0xc3, 0xe7, 0x47, 0xc, 0x1, 0x71, 0x44, 0x2a, 0x46, 0xdd, 0x25, 0x46, 0x16, 0x8e, 0x37, 0xcf, 0xfc}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x40, 0xd9, 0x51, 0xf9, 0x2b, 0x10, 0x98, 0x10, 0xed, 0xb, 0xb4, 0x5b}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xcf, 0xf, 0xc3, 0x8a, 0x57, 0x8d, 0x48, 0x32, 0x9d, 0x62, 0x3f, 0x93, 0x4e, 0x93, 0x23, 0x20, 0x61, 0x25, 0xef, 0xb5, 0x47, 0xec, 0x5b, 0x6d, 0x0, 0x78}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xe2, 0x3e, 0x41, 0x6e, 0xe2, 0x47, 0xb9, 0x1c}; + lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x83, 0xbd, 0x6c, 0x85, 0x85, 0x9, 0x67, 0x80, 0x8b, 0x39, 0x3c, 0x97, 0x79, 0x3c, 0xc5, 0x6f, 0xcc, 0xdd, 0x84, 0x36, 0x97, 0xfd, 0xd5, 0xc4, 0x33, 0xdd, 0x69}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; +lwmqtt_sub_options_t sub_opts[8]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[0].retain_as_published = true; +sub_opts[0].no_local = true; +sub_opts[1].qos = LWMQTT_QOS0; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS2; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = true; +sub_opts[2].no_local = false; +sub_opts[3].qos = LWMQTT_QOS0; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = true; +sub_opts[4].qos = LWMQTT_QOS1; +sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[4].retain_as_published = true; +sub_opts[4].no_local = true; +sub_opts[5].qos = LWMQTT_QOS1; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = true; +sub_opts[6].qos = LWMQTT_QOS0; +sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[6].retain_as_published = true; +sub_opts[6].no_local = true; +sub_opts[7].qos = LWMQTT_QOS1; +sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = false; + uint8_t bytesprops0[] = {0x3d, 0xfa, 0x69, 0x7b, 0x88, 0x79, 0x1a, 0xe0, 0x2e, 0xe4, 0x38, 0x47, 0x4c, 0x78, 0x62, 0x97, 0xab, 0x3e, 0x4e, 0x15, 0xf3}; + uint8_t bytesprops1[] = {0x3d, 0x76, 0x32, 0xad, 0x6e, 0x4, 0x1c, 0xaa, 0x73, 0xb6}; + uint8_t bytesprops2[] = {0x56, 0x3, 0xcb, 0xda, 0xd6, 0x8a, 0x31, 0x34, 0x6e, 0x37, 0xac, 0x6f, 0x5a, 0x87, 0xea, 0xd2, 0xed, 0x8f, 0xe}; + uint8_t bytesprops3[] = {0x42, 0x21, 0xbc, 0x89, 0x27, 0x1c, 0x4c, 0xd5}; + uint8_t bytesprops4[] = {0xf9, 0x4a, 0x6f, 0xb6, 0xd2, 0xb6, 0xa8, 0x70, 0x3e, 0x5, 0x26, 0x53, 0x9b, 0xbd, 0x50, 0x7f, 0xb3, 0xef, 0x35, 0xa0, 0xa3, 0x69, 0x61, 0x47, 0x69, 0xda, 0x3c, 0x9f, 0xf0, 0x76}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22521}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {18, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7152}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 31}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21728}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26880}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15262}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24607}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27192}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 623}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27376}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2499}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12723}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17953, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17142, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 26518 [("\NULJ\205v\253\154",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS2}),("j\182X\235\201r\170\214\STX\134\241\201\150\253\226\SYN",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("ap\232$>@\178\148\vR\208\227\232\190\&0*N>\US\202\188",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("+b\142\ETB/\213xA\202y\175i)\183\171\142Yw_\228\&2\170\156 \129",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("A\187\CAN\243\184\211b\170\231tK\171\170R\216Gw\149i\252\163\&4U\209\180\245\226\249-\209\158\&5\245\NUL\234\DC10\214",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\218\246\226&[\153t\186\250\SI\199\252\144\201\139\191U?\SI\207?Q",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\242x\138*\224\132\237\229\218\231\&4\189|",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DLE\EOT\229e\SO\165\202\190",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] -// [PropMessageExpiryInterval 1813,PropContentType "",PropAuthenticationMethod -// "\146*\STX\150>\233\167?\ra\EM\DEL",PropAuthenticationData -// "t[\132\EM\SI\175l[\SYN41\133\151\DC3\236q\195\CAN\131\232\211\213\188K_\229?",PropMessageExpiryInterval -// 22279,PropTopicAliasMaximum 29118,PropSubscriptionIdentifierAvailable 189,PropRequestProblemInformation -// 76,PropReceiveMaximum 22760,PropReasonString "CBVj\185\243 \ESC\176~a\231k",PropUserProperty -// "\242*\188\196\177\&5\DEL\bKv\207\SYN\215" "\250G\"u\198v`\238\198\DC1_\135\212f\201",PropAssignedClientIdentifier -// "\ETB9\171\SI\144\204\163\a)\232\251\242\DC1Q\132\228\&6\208\200\143Uj\EOT\ESC\135\241",PropSessionExpiryInterval -// 25871,PropSessionExpiryInterval 9023,PropAuthenticationData -// "\208\157Z\nlv\220\151\150\150\&5\169\&6J=\178",PropRequestProblemInformation 137,PropUserProperty -// "\157\a\SUB,\239\ENQ\166\254\246R\245\165\nA\146\255\&7\181V\157\193\DC3\188\230\225" -// "\135\163\189\173Ho\231s\182",PropSessionExpiryInterval 6015,PropReceiveMaximum -// 16296,PropRequestProblemInformation 137] -TEST(Subscribe5QCTest, Encode22) { - uint8_t pkt[] = { - 0x82, 0x91, 0x3, 0x5b, 0xe3, 0x90, 0x2, 0x2, 0x0, 0x0, 0x7, 0x15, 0x3, 0x0, 0x0, 0x15, 0x0, 0xc, 0x92, - 0x2a, 0x2, 0x96, 0x3e, 0xe9, 0xa7, 0x3f, 0xd, 0x61, 0x19, 0x7f, 0x16, 0x0, 0x1b, 0x74, 0x5b, 0x84, 0x19, 0xf, - 0xaf, 0x6c, 0x5b, 0x16, 0x34, 0x31, 0x85, 0x97, 0x13, 0xec, 0x71, 0xc3, 0x18, 0x83, 0xe8, 0xd3, 0xd5, 0xbc, 0x4b, - 0x5f, 0xe5, 0x3f, 0x2, 0x0, 0x0, 0x57, 0x7, 0x22, 0x71, 0xbe, 0x29, 0xbd, 0x17, 0x4c, 0x21, 0x58, 0xe8, 0x1f, - 0x0, 0xd, 0x43, 0x42, 0x56, 0x6a, 0xb9, 0xf3, 0x20, 0x1b, 0xb0, 0x7e, 0x61, 0xe7, 0x6b, 0x26, 0x0, 0xd, 0xf2, - 0x2a, 0xbc, 0xc4, 0xb1, 0x35, 0x7f, 0x8, 0x4b, 0x76, 0xcf, 0x16, 0xd7, 0x0, 0xf, 0xfa, 0x47, 0x22, 0x75, 0xc6, - 0x76, 0x60, 0xee, 0xc6, 0x11, 0x5f, 0x87, 0xd4, 0x66, 0xc9, 0x12, 0x0, 0x1a, 0x17, 0x39, 0xab, 0xf, 0x90, 0xc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0xc, 0x0, 0x1b, 0x99, 0x24, - 0xd1, 0x73, 0xce, 0x76, 0x3e, 0x69, 0xfc, 0xa3, 0x34, 0x55, 0xd1, 0xb4, 0xf5, 0xe2, 0xf9, 0x2d, 0xd1, 0x9e, 0x35, - 0xf5, 0x0, 0xea, 0x11, 0x30, 0xd6, 0x25, 0x0, 0x0, 0x19, 0x0, 0x16, 0xda, 0xf6, 0xe2, 0x26, 0x5b, 0x99, 0x74, - 0xba, 0xfa, 0xf, 0xc7, 0xfc, 0x90, 0xc9, 0x8b, 0xbf, 0x55, 0x3f, 0xf, 0xcf, 0x3f, 0x51, 0x15, 0x0, 0xd, 0xf2, - 0x78, 0x8a, 0x2a, 0xe0, 0x84, 0xed, 0xe5, 0xda, 0xe7, 0x34, 0xbd, 0x7c, 0x22, 0x0, 0x8, 0x10, 0x4, 0xe5, 0x65, - 0xe, 0xa5, 0xca, 0xbe, 0xa}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x3a, 0x5a, 0xfd, 0xb3, 0xf6, 0x69, 0x9, 0x43, 0x14, 0xe1, 0xf4, 0x6f}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x90, 0xf2, 0xf2, 0x38, 0xdf, 0x89, 0x70, 0x4c, 0x72, - 0x43, 0xa9, 0xe9, 0x8e, 0xcd, 0x3b, 0x50, 0xe3}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5c, 0x9}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x99, 0x24, 0xd1, 0x73, 0xce, 0x76, 0x3e, 0x69, 0xfc, 0xa3, 0x34, 0x55, 0xd1, 0xb4, - 0xf5, 0xe2, 0xf9, 0x2d, 0xd1, 0x9e, 0x35, 0xf5, 0x0, 0xea, 0x11, 0x30, 0xd6}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xda, 0xf6, 0xe2, 0x26, 0x5b, 0x99, 0x74, 0xba, 0xfa, 0xf, 0xc7, - 0xfc, 0x90, 0xc9, 0x8b, 0xbf, 0x55, 0x3f, 0xf, 0xcf, 0x3f, 0x51}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf2, 0x78, 0x8a, 0x2a, 0xe0, 0x84, 0xed, 0xe5, 0xda, 0xe7, 0x34, 0xbd, 0x7c}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x10, 0x4, 0xe5, 0x65, 0xe, 0xa5, 0xca, 0xbe}; - lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x92, 0x2a, 0x2, 0x96, 0x3e, 0xe9, 0xa7, 0x3f, 0xd, 0x61, 0x19, 0x7f}; - uint8_t bytesprops2[] = {0x74, 0x5b, 0x84, 0x19, 0xf, 0xaf, 0x6c, 0x5b, 0x16, 0x34, 0x31, 0x85, 0x97, 0x13, - 0xec, 0x71, 0xc3, 0x18, 0x83, 0xe8, 0xd3, 0xd5, 0xbc, 0x4b, 0x5f, 0xe5, 0x3f}; - uint8_t bytesprops3[] = {0x43, 0x42, 0x56, 0x6a, 0xb9, 0xf3, 0x20, 0x1b, 0xb0, 0x7e, 0x61, 0xe7, 0x6b}; - uint8_t bytesprops5[] = {0xfa, 0x47, 0x22, 0x75, 0xc6, 0x76, 0x60, 0xee, 0xc6, 0x11, 0x5f, 0x87, 0xd4, 0x66, 0xc9}; - uint8_t bytesprops4[] = {0xf2, 0x2a, 0xbc, 0xc4, 0xb1, 0x35, 0x7f, 0x8, 0x4b, 0x76, 0xcf, 0x16, 0xd7}; - uint8_t bytesprops6[] = {0x17, 0x39, 0xab, 0xf, 0x90, 0xcc, 0xa3, 0x7, 0x29, 0xe8, 0xfb, 0xf2, 0x11, - 0x51, 0x84, 0xe4, 0x36, 0xd0, 0xc8, 0x8f, 0x55, 0x6a, 0x4, 0x1b, 0x87, 0xf1}; - uint8_t bytesprops7[] = {0xd0, 0x9d, 0x5a, 0xa, 0x6c, 0x76, 0xdc, 0x97, - 0x96, 0x96, 0x35, 0xa9, 0x36, 0x4a, 0x3d, 0xb2}; - uint8_t bytesprops9[] = {0x87, 0xa3, 0xbd, 0xad, 0x48, 0x3c, 0x76, 0xb7, 0x4b, 0xd1, 0x6, 0x20, 0x65, 0x2f, - 0x36, 0xe3, 0xdd, 0x69, 0x4, 0xb1, 0xe2, 0x29, 0xa1, 0x12, 0xd7, 0x66, 0xed, 0x5d}; - uint8_t bytesprops8[] = {0x9d, 0x7, 0x1a, 0x2c, 0xef, 0x5, 0xa6, 0xfe, 0xf6, 0x52, 0xf5, 0xa5, 0xa, - 0x41, 0x92, 0xff, 0x37, 0xb5, 0x56, 0x9d, 0xc1, 0x13, 0xbc, 0xe6, 0xe1}; - uint8_t bytesprops10[] = {0x7, 0x47, 0x56, 0x95, 0x64, 0xa8, 0x81, 0x55, 0x8f, 0x22, 0xa7, 0xe6, - 0x66, 0xb4, 0x9d, 0x43, 0xdf, 0x9c, 0xd9, 0x3e, 0x6f, 0xe7, 0x73, 0xb6}; +// SubscribeRequest 26425 [("\145\NAK7\199",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\GSs0\DC1\171V\137\&9\159w\132\ESC\169\234\155\213",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\\\142Z\247\242sCn\US\191q!\148^!i\196\133\n\205\140Ar\136\133",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\235e\220\167>\DLE*\133\128\145\180\DC3t\129\&8",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\218\188\137$}\EOT4\238\239\232|~\185\169R\141\196\189R\151",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\173\US{0hp\194\172Up\210?\133\204\227\&0\160\137\183\158\212\217z\228\208\130\164\213\ACK\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\217\199\165J\206\133\254\160,k\ETB\144\186\EOT\ETXKN=\160\SYN\200K\f\208\155%\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\DEL\210\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\211\225\228\234\188g\203A\222\NUL!\191\194\&0\194\&0\144@(A\232\&8\176N",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropReasonString "\163\196\DC1\US\DC4\186sL\238L",PropTopicAlias 7143,PropWildcardSubscriptionAvailable 82,PropMessageExpiryInterval 15875,PropSharedSubscriptionAvailable 168,PropSubscriptionIdentifier 4,PropCorrelationData "r\174\213\240w\SYN\252\\'",PropReasonString "@\181\143\177\163\176\192\169\183\215\231z\170O\DLEy\246\176\223W?\156\rx\DC3\154\201\140",PropAuthenticationData "`1p\163\252\SI\202\233\247\130]7\ENQ\f\RSW+dp\233]3\fr\197\233\SO\130\ENQ",PropRequestProblemInformation 2,PropCorrelationData "[\172\179=",PropSessionExpiryInterval 20694,PropSessionExpiryInterval 19861,PropRequestProblemInformation 17,PropMessageExpiryInterval 26061,PropRequestResponseInformation 228,PropWildcardSubscriptionAvailable 202,PropPayloadFormatIndicator 193,PropWildcardSubscriptionAvailable 120,PropRetainAvailable 37,PropMessageExpiryInterval 28337,PropRetainAvailable 100,PropTopicAlias 2850] +TEST(Subscribe5QCTest, Encode22) { +uint8_t pkt[] = {0x82, 0xd7, 0x2, 0x67, 0x39, 0x94, 0x1, 0x1f, 0x0, 0xa, 0xa3, 0xc4, 0x11, 0x1f, 0x14, 0xba, 0x73, 0x4c, 0xee, 0x4c, 0x23, 0x1b, 0xe7, 0x28, 0x52, 0x2, 0x0, 0x0, 0x3e, 0x3, 0x2a, 0xa8, 0xb, 0x4, 0x9, 0x0, 0x9, 0x72, 0xae, 0xd5, 0xf0, 0x77, 0x16, 0xfc, 0x5c, 0x27, 0x1f, 0x0, 0x1c, 0x40, 0xb5, 0x8f, 0xb1, 0xa3, 0xb0, 0xc0, 0xa9, 0xb7, 0xd7, 0xe7, 0x7a, 0xaa, 0x4f, 0x10, 0x79, 0xf6, 0xb0, 0xdf, 0x57, 0x3f, 0x9c, 0xd, 0x78, 0x13, 0x9a, 0xc9, 0x8c, 0x16, 0x0, 0x1d, 0x60, 0x31, 0x70, 0xa3, 0xfc, 0xf, 0xca, 0xe9, 0xf7, 0x82, 0x5d, 0x37, 0x5, 0xc, 0x1e, 0x57, 0x2b, 0x64, 0x70, 0xe9, 0x5d, 0x33, 0xc, 0x72, 0xc5, 0xe9, 0xe, 0x82, 0x5, 0x17, 0x2, 0x9, 0x0, 0x4, 0x5b, 0xac, 0xb3, 0x3d, 0x11, 0x0, 0x0, 0x50, 0xd6, 0x11, 0x0, 0x0, 0x4d, 0x95, 0x17, 0x11, 0x2, 0x0, 0x0, 0x65, 0xcd, 0x19, 0xe4, 0x28, 0xca, 0x1, 0xc1, 0x28, 0x78, 0x25, 0x25, 0x2, 0x0, 0x0, 0x6e, 0xb1, 0x25, 0x64, 0x23, 0xb, 0x22, 0x0, 0x4, 0x91, 0x15, 0x37, 0xc7, 0x9, 0x0, 0x10, 0x1d, 0x73, 0x30, 0x11, 0xab, 0x56, 0x89, 0x39, 0x9f, 0x77, 0x84, 0x1b, 0xa9, 0xea, 0x9b, 0xd5, 0x2, 0x0, 0x19, 0x5c, 0x8e, 0x5a, 0xf7, 0xf2, 0x73, 0x43, 0x6e, 0x1f, 0xbf, 0x71, 0x21, 0x94, 0x5e, 0x21, 0x69, 0xc4, 0x85, 0xa, 0xcd, 0x8c, 0x41, 0x72, 0x88, 0x85, 0x1c, 0x0, 0xf, 0xeb, 0x65, 0xdc, 0xa7, 0x3e, 0x10, 0x2a, 0x85, 0x80, 0x91, 0xb4, 0x13, 0x74, 0x81, 0x38, 0x25, 0x0, 0x14, 0xda, 0xbc, 0x89, 0x24, 0x7d, 0x4, 0x34, 0xee, 0xef, 0xe8, 0x7c, 0x7e, 0xb9, 0xa9, 0x52, 0x8d, 0xc4, 0xbd, 0x52, 0x97, 0x1c, 0x0, 0x1e, 0xad, 0x1f, 0x7b, 0x30, 0x68, 0x70, 0xc2, 0xac, 0x55, 0x70, 0xd2, 0x3f, 0x85, 0xcc, 0xe3, 0x30, 0xa0, 0x89, 0xb7, 0x9e, 0xd4, 0xd9, 0x7a, 0xe4, 0xd0, 0x82, 0xa4, 0xd5, 0x6, 0xd2, 0xc, 0x0, 0x1b, 0xd9, 0xc7, 0xa5, 0x4a, 0xce, 0x85, 0xfe, 0xa0, 0x2c, 0x6b, 0x17, 0x90, 0xba, 0x4, 0x3, 0x4b, 0x4e, 0x3d, 0xa0, 0x16, 0xc8, 0x4b, 0xc, 0xd0, 0x9b, 0x25, 0xb4, 0xd, 0x0, 0x3, 0x7f, 0xd2, 0xba, 0x2, 0x0, 0x18, 0xd3, 0xe1, 0xe4, 0xea, 0xbc, 0x67, 0xcb, 0x41, 0xde, 0x0, 0x21, 0xbf, 0xc2, 0x30, 0xc2, 0x30, 0x90, 0x40, 0x28, 0x41, 0xe8, 0x38, 0xb0, 0x4e, 0x29}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x91, 0x15, 0x37, 0xc7}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x1d, 0x73, 0x30, 0x11, 0xab, 0x56, 0x89, 0x39, 0x9f, 0x77, 0x84, 0x1b, 0xa9, 0xea, 0x9b, 0xd5}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5c, 0x8e, 0x5a, 0xf7, 0xf2, 0x73, 0x43, 0x6e, 0x1f, 0xbf, 0x71, 0x21, 0x94, 0x5e, 0x21, 0x69, 0xc4, 0x85, 0xa, 0xcd, 0x8c, 0x41, 0x72, 0x88, 0x85}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xeb, 0x65, 0xdc, 0xa7, 0x3e, 0x10, 0x2a, 0x85, 0x80, 0x91, 0xb4, 0x13, 0x74, 0x81, 0x38}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xda, 0xbc, 0x89, 0x24, 0x7d, 0x4, 0x34, 0xee, 0xef, 0xe8, 0x7c, 0x7e, 0xb9, 0xa9, 0x52, 0x8d, 0xc4, 0xbd, 0x52, 0x97}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xad, 0x1f, 0x7b, 0x30, 0x68, 0x70, 0xc2, 0xac, 0x55, 0x70, 0xd2, 0x3f, 0x85, 0xcc, 0xe3, 0x30, 0xa0, 0x89, 0xb7, 0x9e, 0xd4, 0xd9, 0x7a, 0xe4, 0xd0, 0x82, 0xa4, 0xd5, 0x6, 0xd2}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xd9, 0xc7, 0xa5, 0x4a, 0xce, 0x85, 0xfe, 0xa0, 0x2c, 0x6b, 0x17, 0x90, 0xba, 0x4, 0x3, 0x4b, 0x4e, 0x3d, 0xa0, 0x16, 0xc8, 0x4b, 0xc, 0xd0, 0x9b, 0x25, 0xb4}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x7f, 0xd2, 0xba}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd3, 0xe1, 0xe4, 0xea, 0xbc, 0x67, 0xcb, 0x41, 0xde, 0x0, 0x21, 0xbf, 0xc2, 0x30, 0xc2, 0x30, 0x90, 0x40, 0x28, 0x41, 0xe8, 0x38, 0xb0, 0x4e}; + lwmqtt_string_t topic_filter_s8 = {24, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; +lwmqtt_sub_options_t sub_opts[9]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = true; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[2].retain_as_published = true; +sub_opts[2].no_local = true; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = true; +sub_opts[4].qos = LWMQTT_QOS0; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[4].retain_as_published = true; +sub_opts[4].no_local = true; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[5].retain_as_published = true; +sub_opts[5].no_local = true; +sub_opts[6].qos = LWMQTT_QOS1; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[6].retain_as_published = true; +sub_opts[6].no_local = true; +sub_opts[7].qos = LWMQTT_QOS2; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[7].retain_as_published = false; +sub_opts[7].no_local = false; +sub_opts[8].qos = LWMQTT_QOS1; +sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[8].retain_as_published = true; +sub_opts[8].no_local = false; + uint8_t bytesprops0[] = {0xa3, 0xc4, 0x11, 0x1f, 0x14, 0xba, 0x73, 0x4c, 0xee, 0x4c}; + uint8_t bytesprops1[] = {0x72, 0xae, 0xd5, 0xf0, 0x77, 0x16, 0xfc, 0x5c, 0x27}; + uint8_t bytesprops2[] = {0x40, 0xb5, 0x8f, 0xb1, 0xa3, 0xb0, 0xc0, 0xa9, 0xb7, 0xd7, 0xe7, 0x7a, 0xaa, 0x4f, 0x10, 0x79, 0xf6, 0xb0, 0xdf, 0x57, 0x3f, 0x9c, 0xd, 0x78, 0x13, 0x9a, 0xc9, 0x8c}; + uint8_t bytesprops3[] = {0x60, 0x31, 0x70, 0xa3, 0xfc, 0xf, 0xca, 0xe9, 0xf7, 0x82, 0x5d, 0x37, 0x5, 0xc, 0x1e, 0x57, 0x2b, 0x64, 0x70, 0xe9, 0x5d, 0x33, 0xc, 0x72, 0xc5, 0xe9, 0xe, 0x82, 0x5}; + uint8_t bytesprops4[] = {0x5b, 0xac, 0xb3, 0x3d}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1813}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22279}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29118}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22760}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops4}, .v = {15, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25871}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9023}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops8}, .v = {28, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6015}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16296}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7143}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15875}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20694}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19861}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26061}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28337}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2850}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23523, 8, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26425, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 10563 [("\168\239",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS0}),("b\DC2\247\191\181;_\144\ETX9R\f\212\n*;",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("M\245\139sC\176\233\&4\SI\136\188%\219\r\ENQ\SOS\142%*R8\171\v\149\180\155",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("F\143\188\229\139~\201\n\GSVs\v",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("M\203\202\148\227\243\227S\239h\b\165\&3\230\DC4B\DEL",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\200\DC1P\EOT&",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = -// False, _subQoS = QoS1}),("\200k\212;\251\194\248\153",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("s\233\DEL\210\244\r\226\142\130\195R",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\228\164;\SUB'C\EM\168\199Z\168Yb\SO\EM",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\210|7\DC3\f}\178\DC4\141\DC2\204\NUL\231\224\SOH|}",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropAuthenticationData -// "{",PropMessageExpiryInterval 5895,PropSubscriptionIdentifier 5,PropSessionExpiryInterval -// 25392,PropSharedSubscriptionAvailable 28,PropSubscriptionIdentifierAvailable 62,PropAuthenticationMethod -// "\159\DEL<\155\134%\196",PropAssignedClientIdentifier -// "\\,\192$\202\&5\255\220\ESC\189\244\239\&5@3\n\176\CAN}M,\f\239\216L\207\179o\f",PropPayloadFormatIndicator -// 192,PropAuthenticationData "\f\SI\229\195\254\&3",PropMaximumQoS 239,PropServerReference -// "\190\197Lr\tft\221\254\137\193\\\DC1\182\244x@I\\\223\247\137\206>\CAN\208\255",PropRequestProblemInformation -// 159,PropRetainAvailable 120,PropContentType -// "\EOTD\176\165\131\198\219T\145\236\US\177\&5[\n\STX\198\&7\143\CAN\b\201\186\f\129Kt",PropReasonString -// "\130\249\DC1B\134q\198\206_\217I\183d!P)\DC2\201\b\220\242\199;\220",PropCorrelationData -// "\180bx\129h\NUL\EM\191/\179lg\EM",PropCorrelationData "\175O",PropRetainAvailable 29,PropRequestProblemInformation -// 96,PropMessageExpiryInterval 19278,PropMessageExpiryInterval 32397,PropResponseInformation -// "\a\128Z\207qt\159\207\162\226q\SOH&\143(p\192n9_\216X \DC1\DLE\"\243f;",PropSubscriptionIdentifier -// 4,PropMaximumPacketSize 31914] -TEST(Subscribe5QCTest, Encode23) { - uint8_t pkt[] = { - 0x82, 0x97, 0x3, 0x29, 0x43, 0xf0, 0x1, 0x16, 0x0, 0x1, 0x7b, 0x2, 0x0, 0x0, 0x17, 0x7, 0xb, 0x5, 0x11, - 0x0, 0x0, 0x63, 0x30, 0x2a, 0x1c, 0x29, 0x3e, 0x15, 0x0, 0x7, 0x9f, 0x7f, 0x3c, 0x9b, 0x86, 0x25, 0xc4, 0x12, - 0x0, 0x1d, 0x5c, 0x2c, 0xc0, 0x24, 0xca, 0x35, 0xff, 0xdc, 0x1b, 0xbd, 0xf4, 0xef, 0x35, 0x40, 0x33, 0xa, 0xb0, - 0x18, 0x7d, 0x4d, 0x2c, 0xc, 0xef, 0xd8, 0x4c, 0xcf, 0xb3, 0x6f, 0xc, 0x1, 0xc0, 0x16, 0x0, 0x6, 0xc, 0xf, - 0xe5, 0xc3, 0xfe, 0x33, 0x24, 0xef, 0x1c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, 0xd, 0x0, 0x1b, 0x4d, 0xf5, 0x8b, 0x73, 0x43, 0xb0, 0xe9, 0x34, 0xf, 0x88, 0xbc, 0x25, - 0xdb, 0xd, 0x5, 0xe, 0x53, 0x8e, 0x25, 0x2a, 0x52, 0x38, 0xab, 0xb, 0x95, 0xb4, 0x9b, 0x19, 0x0, 0xc, 0x46, - 0x8f, 0xbc, 0xe5, 0x8b, 0x7e, 0xc9, 0xa, 0x1d, 0x56, 0x73, 0xb, 0x10, 0x0, 0x11, 0x4d, 0xcb, 0xca, 0x94, 0xe3, - 0xf3, 0xe3, 0x53, 0xef, 0x68, 0x8, 0xa5, 0x33, 0xe6, 0x14, 0x42, 0x7f, 0xa, 0x0, 0x5, 0xc8, 0x11, 0x50, 0x4, - 0x26, 0x29, 0x0, 0x8, 0xc8, 0x6b, 0xd4, 0x3b, 0xfb, 0xc2, 0xf8, 0x99, 0x1a, 0x0, 0xb, 0x73, 0xe9, 0x7f, 0xd2, - 0xf4, 0xd, 0xe2, 0x8e, 0x82, 0xc3, 0x52, 0x1a, 0x0, 0xf, 0xe4, 0xa4, 0x3b, 0x1a, 0x27, 0x43, 0x19, 0xa8, 0xc7, - 0x5a, 0xa8, 0x59, 0x62, 0xe, 0x19, 0x14, 0x0, 0x11, 0xd2, 0x7c, 0x37, 0x13, 0xc, 0x7d, 0xb2, 0x14, 0x8d, 0x12, - 0xcc, 0x0, 0xe7, 0xe0, 0x1, 0x7c, 0x7d, 0x20, 0x0, 0x0, 0x26}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xa8, 0xef}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x62, 0x12, 0xf7, 0xbf, 0xb5, 0x3b, 0x5f, 0x90, - 0x3, 0x39, 0x52, 0xc, 0xd4, 0xa, 0x2a, 0x3b}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4d, 0xf5, 0x8b, 0x73, 0x43, 0xb0, 0xe9, 0x34, 0xf, 0x88, 0xbc, 0x25, 0xdb, 0xd, - 0x5, 0xe, 0x53, 0x8e, 0x25, 0x2a, 0x52, 0x38, 0xab, 0xb, 0x95, 0xb4, 0x9b}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x46, 0x8f, 0xbc, 0xe5, 0x8b, 0x7e, 0xc9, 0xa, 0x1d, 0x56, 0x73, 0xb}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4d, 0xcb, 0xca, 0x94, 0xe3, 0xf3, 0xe3, 0x53, 0xef, - 0x68, 0x8, 0xa5, 0x33, 0xe6, 0x14, 0x42, 0x7f}; - lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc8, 0x11, 0x50, 0x4, 0x26}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc8, 0x6b, 0xd4, 0x3b, 0xfb, 0xc2, 0xf8, 0x99}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x73, 0xe9, 0x7f, 0xd2, 0xf4, 0xd, 0xe2, 0x8e, 0x82, 0xc3, 0x52}; - lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe4, 0xa4, 0x3b, 0x1a, 0x27, 0x43, 0x19, 0xa8, - 0xc7, 0x5a, 0xa8, 0x59, 0x62, 0xe, 0x19}; - lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xd2, 0x7c, 0x37, 0x13, 0xc, 0x7d, 0xb2, 0x14, 0x8d, - 0x12, 0xcc, 0x0, 0xe7, 0xe0, 0x1, 0x7c, 0x7d}; - lwmqtt_string_t topic_filter_s9 = {17, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0}; - lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = true; - uint8_t bytesprops0[] = {0x7b}; - uint8_t bytesprops1[] = {0x9f, 0x7f, 0x3c, 0x9b, 0x86, 0x25, 0xc4}; - uint8_t bytesprops2[] = {0x5c, 0x2c, 0xc0, 0x24, 0xca, 0x35, 0xff, 0xdc, 0x1b, 0xbd, 0xf4, 0xef, 0x35, 0x40, 0x33, - 0xa, 0xb0, 0x18, 0x7d, 0x4d, 0x2c, 0xc, 0xef, 0xd8, 0x4c, 0xcf, 0xb3, 0x6f, 0xc}; - uint8_t bytesprops3[] = {0xc, 0xf, 0xe5, 0xc3, 0xfe, 0x33}; - uint8_t bytesprops4[] = {0xbe, 0xc5, 0x4c, 0x72, 0x9, 0x66, 0x74, 0xdd, 0xfe, 0x89, 0xc1, 0x5c, 0x11, 0xb6, - 0xf4, 0x78, 0x40, 0x49, 0x5c, 0xdf, 0xf7, 0x89, 0xce, 0x3e, 0x18, 0xd0, 0xff}; - uint8_t bytesprops5[] = {0x4, 0x44, 0xb0, 0xa5, 0x83, 0xc6, 0xdb, 0x54, 0x91, 0xec, 0x1f, 0xb1, 0x35, 0x5b, - 0xa, 0x2, 0xc6, 0x37, 0x8f, 0x18, 0x8, 0xc9, 0xba, 0xc, 0x81, 0x4b, 0x74}; - uint8_t bytesprops6[] = {0x82, 0xf9, 0x11, 0x42, 0x86, 0x71, 0xc6, 0xce, 0x5f, 0xd9, 0x49, 0xb7, - 0x64, 0x21, 0x50, 0x29, 0x12, 0xc9, 0x8, 0xdc, 0xf2, 0xc7, 0x3b, 0xdc}; - uint8_t bytesprops7[] = {0xb4, 0x62, 0x78, 0x81, 0x68, 0x0, 0x19, 0xbf, 0x2f, 0xb3, 0x6c, 0x67, 0x19}; - uint8_t bytesprops8[] = {0xaf, 0x4f}; - uint8_t bytesprops9[] = {0x7, 0x80, 0x5a, 0xcf, 0x71, 0x74, 0x9f, 0xcf, 0xa2, 0xe2, 0x71, 0x1, 0x26, 0x8f, 0x28, - 0x70, 0xc0, 0x6e, 0x39, 0x5f, 0xd8, 0x58, 0x20, 0x11, 0x10, 0x22, 0xf3, 0x66, 0x3b}; +// SubscribeRequest 17320 [("\144\175\&0\194y\215$\SO\132\\>\f\225\180\212\vV\188\EOTTx\215",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\ETX",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropMaximumQoS -// 107,PropRequestProblemInformation 8,PropTopicAliasMaximum 31079,PropServerKeepAlive -// 30906,PropSharedSubscriptionAvailable 183,PropMaximumPacketSize 22245,PropAuthenticationMethod -// "\184\181\193\176\186\243\139\201\155\229\136\168\225\DC1\EOTYV\173\ESC\DC3\170",PropRetainAvailable -// 243,PropSubscriptionIdentifier 12,PropCorrelationData "\204\189\132U\215",PropServerReference -// "+\206\240JR\200\168\206\182-\209\163\171O\169:",PropUserProperty "\DC1\145\&2\DC2" "\DC4",PropServerReference -// "?\137hg\168\167N\186Ad\194\DC1",PropMaximumQoS 230,PropServerKeepAlive 16962,PropResponseTopic -// "\204\156l\167\ESC\172\142\223\248\214h[]",PropServerKeepAlive 17136,PropSubscriptionIdentifierAvailable -// 23,PropRequestProblemInformation 1,PropReasonString "\187Az\153H#\151\NULo",PropAuthenticationData -// "*\164",PropResponseTopic -// "\207\195\147\&6\198^\NAK\148Y\191d-\237\234\145\SYN\DLE\130\239\214\CAN\207\248",PropAuthenticationMethod -// "8Ty\200\190^\241T\220.\EM\237\158\ENQ\139\238\186\193\242%\146\205*\ENQ"] + +// SubscribeRequest 9349 [("D\161",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\147\GS\140\221\194\249\&2H$\160\&9Z\247\201\&7\235\133\210M{r\146uJY\ESC",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\234\216\197\146-.:|#\186\SUB}\134",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("]/.\208\EOT\195\224Ig\238x\219\254 \178",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\168\232\NAK\137\231\230}~\178]6\246",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("V\129f)\206Y\b\216\222\223*\132k\193\163\213\&2)",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\249\201\EMx\233\208\197*\228\149\179\213\158,\166q\253>\US",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\140\252\NAKZ\ENQ\201\234\204\151\235\251\198\234\190\DC2\NULi\211\201",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReceiveMaximum 28279,PropMaximumQoS 210,PropMaximumQoS 185,PropWildcardSubscriptionAvailable 25] TEST(Subscribe5QCTest, Encode24) { - uint8_t pkt[] = { - 0x82, 0xcf, 0x2, 0x76, 0xf3, 0xc3, 0x1, 0x24, 0x6b, 0x17, 0x8, 0x22, 0x79, 0x67, 0x13, 0x78, 0xba, 0x2a, 0xb7, - 0x27, 0x0, 0x0, 0x56, 0xe5, 0x15, 0x0, 0x15, 0xb8, 0xb5, 0xc1, 0xb0, 0xba, 0xf3, 0x8b, 0xc9, 0x9b, 0xe5, 0x88, - 0xa8, 0xe1, 0x11, 0x4, 0x59, 0x56, 0xad, 0x1b, 0x13, 0xaa, 0x25, 0xf3, 0xb, 0xc, 0x9, 0x0, 0x5, 0xcc, 0xbd, - 0x84, 0x55, 0xd7, 0x1c, 0x0, 0x10, 0x2b, 0xce, 0xf0, 0x4a, 0x52, 0xc8, 0xa8, 0xce, 0xb6, 0x2d, 0xd1, 0xa3, 0xab, - 0x4f, 0xa9, 0x3a, 0x26, 0x0, 0x4, 0x11, 0x91, 0x32, 0x12, 0x0, 0x1, 0x14, 0x1c, 0x0, 0xc, 0x3f, 0x89, 0x68, - 0x67, 0xa8, 0xa7, 0x4e, 0xba, 0x41, 0x64, 0xc2, 0x11, 0x24, 0xe6, 0x13, 0x42, 0x42, 0x8, 0x0, 0xd, 0xcc, 0x9c, - 0x6c, 0xa7, 0x1b, 0xac, 0x8e, 0xdf, 0xf8, 0xd6, 0x68, 0x5b, 0x5d, 0x13, 0x42, 0xf0, 0x29, 0x17, 0x17, 0x1, 0x1f, - 0x0, 0x9, 0xbb, 0x41, 0x7a, 0x99, 0x48, 0x23, 0x97, 0x0, 0x6f, 0x16, 0x0, 0x2, 0x2a, 0xa4, 0x8, 0x0, 0x17, - 0xcf, 0xc3, 0x93, 0x36, 0xc6, 0x5e, 0x15, 0x94, 0x59, 0xbf, 0x64, 0x2d, 0xed, 0xea, 0x91, 0x16, 0x10, 0x82, 0xef, - 0xd6, 0x18, 0xcf, 0xf8, 0x15, 0x0, 0x18, 0x38, 0x54, 0x79, 0xc8, 0xbe, 0x5e, 0xf1, 0x54, 0xdc, 0x2e, 0x19, 0xed, - 0x9e, 0x5, 0x8b, 0xee, 0xba, 0xc1, 0xf2, 0x25, 0x92, 0xcd, 0x2a, 0x5, 0x0, 0x2, 0x25, 0xad, 0x10, 0x0, 0x0, - 0x15, 0x0, 0x1, 0xc5, 0xd, 0x0, 0x8, 0x75, 0xa7, 0x5a, 0x5, 0x0, 0xf6, 0x46, 0xba, 0x9, 0x0, 0x6, 0x24, - 0x47, 0x77, 0xfc, 0x4c, 0x65, 0x16, 0x0, 0x15, 0xc3, 0xb4, 0x99, 0xbd, 0xdd, 0x5f, 0x69, 0x70, 0xc6, 0x93, 0xb, - 0x19, 0xb6, 0xd7, 0x1e, 0xe1, 0x44, 0xad, 0x3d, 0x6f, 0x4c, 0x2c, 0x0, 0xe, 0xd8, 0x79, 0xa, 0xcf, 0x75, 0x53, - 0x35, 0x9d, 0x19, 0x16, 0xb6, 0xa9, 0xbc, 0x9a, 0x0, 0x0, 0xe, 0xeb, 0x67, 0xa4, 0xf7, 0x70, 0x1a, 0x7e, 0x44, - 0xdb, 0x21, 0x3a, 0x1, 0x5f, 0xc0, 0x16, 0x0, 0xb, 0xe2, 0x28, 0xc8, 0x37, 0x46, 0x83, 0xff, 0xdf, 0x71, 0xb2, - 0x3b, 0x29, 0x0, 0x19, 0xe4, 0xda, 0xc6, 0xb6, 0xa8, 0x6a, 0x26, 0x12, 0x79, 0xf9, 0x3e, 0x84, 0x5c, 0x3e, 0xc, - 0xe1, 0xb4, 0xd4, 0xb, 0x56, 0xbc, 0x4, 0x54, 0x78, 0xd7, 0xc, 0x0, 0x1, 0x3, 0x2c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x25, 0xad}; +uint8_t pkt[] = {0x82, 0xa3, 0x1, 0x24, 0x85, 0x9, 0x21, 0x6e, 0x77, 0x24, 0xd2, 0x24, 0xb9, 0x28, 0x19, 0x0, 0x2, 0x44, 0xa1, 0x2c, 0x0, 0x1a, 0x93, 0x1d, 0x8c, 0xdd, 0xc2, 0xf9, 0x32, 0x48, 0x24, 0xa0, 0x39, 0x5a, 0xf7, 0xc9, 0x37, 0xeb, 0x85, 0xd2, 0x4d, 0x7b, 0x72, 0x92, 0x75, 0x4a, 0x59, 0x1b, 0x1, 0x0, 0xd, 0xea, 0xd8, 0xc5, 0x92, 0x2d, 0x2e, 0x3a, 0x7c, 0x23, 0xba, 0x1a, 0x7d, 0x86, 0x16, 0x0, 0x0, 0x22, 0x0, 0xf, 0x5d, 0x2f, 0x2e, 0xd0, 0x4, 0xc3, 0xe0, 0x49, 0x67, 0xee, 0x78, 0xdb, 0xfe, 0x20, 0xb2, 0x1a, 0x0, 0xc, 0xa8, 0xe8, 0x15, 0x89, 0xe7, 0xe6, 0x7d, 0x7e, 0xb2, 0x5d, 0x36, 0xf6, 0x22, 0x0, 0x12, 0x56, 0x81, 0x66, 0x29, 0xce, 0x59, 0x8, 0xd8, 0xde, 0xdf, 0x2a, 0x84, 0x6b, 0xc1, 0xa3, 0xd5, 0x32, 0x29, 0x18, 0x0, 0x13, 0xf9, 0xc9, 0x19, 0x78, 0xe9, 0xd0, 0xc5, 0x2a, 0xe4, 0x95, 0xb3, 0xd5, 0x9e, 0x2c, 0xa6, 0x71, 0xfd, 0x3e, 0x1f, 0x2e, 0x0, 0x13, 0x8c, 0xfc, 0x15, 0x5a, 0x5, 0xc9, 0xea, 0xcc, 0x97, 0xeb, 0xfb, 0xc6, 0xea, 0xbe, 0x12, 0x0, 0x69, 0xd3, 0xc9, 0x21}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x44, 0xa1}; lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc5}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x75, 0xa7, 0x5a, 0x5, 0x0, 0xf6, 0x46, 0xba}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x24, 0x47, 0x77, 0xfc, 0x4c, 0x65}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc3, 0xb4, 0x99, 0xbd, 0xdd, 0x5f, 0x69, 0x70, 0xc6, 0x93, 0xb, - 0x19, 0xb6, 0xd7, 0x1e, 0xe1, 0x44, 0xad, 0x3d, 0x6f, 0x4c}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xd8, 0x79, 0xa, 0xcf, 0x75, 0x53, 0x35, 0x9d, 0x19, 0x16, 0xb6, 0xa9, 0xbc, 0x9a}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xeb, 0x67, 0xa4, 0xf7, 0x70, 0x1a, 0x7e, 0x44, 0xdb, 0x21, 0x3a, 0x1, 0x5f, 0xc0}; - lwmqtt_string_t topic_filter_s7 = {14, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe2, 0x28, 0xc8, 0x37, 0x46, 0x83, 0xff, 0xdf, 0x71, 0xb2, 0x3b}; - lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe4, 0xda, 0xc6, 0xb6, 0xa8, 0x6a, 0x26, 0x12, 0x79, 0xf9, 0x3e, 0x84, 0x5c, - 0x3e, 0xc, 0xe1, 0xb4, 0xd4, 0xb, 0x56, 0xbc, 0x4, 0x54, 0x78, 0xd7}; - lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x3}; - lwmqtt_string_t topic_filter_s10 = {1, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = true; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[10].retain_as_published = true; - sub_opts[10].no_local = true; - uint8_t bytesprops0[] = {0xb8, 0xb5, 0xc1, 0xb0, 0xba, 0xf3, 0x8b, 0xc9, 0x9b, 0xe5, 0x88, - 0xa8, 0xe1, 0x11, 0x4, 0x59, 0x56, 0xad, 0x1b, 0x13, 0xaa}; - uint8_t bytesprops1[] = {0xcc, 0xbd, 0x84, 0x55, 0xd7}; - uint8_t bytesprops2[] = {0x2b, 0xce, 0xf0, 0x4a, 0x52, 0xc8, 0xa8, 0xce, - 0xb6, 0x2d, 0xd1, 0xa3, 0xab, 0x4f, 0xa9, 0x3a}; - uint8_t bytesprops4[] = {0x14}; - uint8_t bytesprops3[] = {0x11, 0x91, 0x32, 0x12}; - uint8_t bytesprops5[] = {0x3f, 0x89, 0x68, 0x67, 0xa8, 0xa7, 0x4e, 0xba, 0x41, 0x64, 0xc2, 0x11}; - uint8_t bytesprops6[] = {0xcc, 0x9c, 0x6c, 0xa7, 0x1b, 0xac, 0x8e, 0xdf, 0xf8, 0xd6, 0x68, 0x5b, 0x5d}; - uint8_t bytesprops7[] = {0xbb, 0x41, 0x7a, 0x99, 0x48, 0x23, 0x97, 0x0, 0x6f}; - uint8_t bytesprops8[] = {0x2a, 0xa4}; - uint8_t bytesprops9[] = {0xcf, 0xc3, 0x93, 0x36, 0xc6, 0x5e, 0x15, 0x94, 0x59, 0xbf, 0x64, 0x2d, - 0xed, 0xea, 0x91, 0x16, 0x10, 0x82, 0xef, 0xd6, 0x18, 0xcf, 0xf8}; - uint8_t bytesprops10[] = {0x38, 0x54, 0x79, 0xc8, 0xbe, 0x5e, 0xf1, 0x54, 0xdc, 0x2e, 0x19, 0xed, - 0x9e, 0x5, 0x8b, 0xee, 0xba, 0xc1, 0xf2, 0x25, 0x92, 0xcd, 0x2a, 0x5}; - +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x93, 0x1d, 0x8c, 0xdd, 0xc2, 0xf9, 0x32, 0x48, 0x24, 0xa0, 0x39, 0x5a, 0xf7, 0xc9, 0x37, 0xeb, 0x85, 0xd2, 0x4d, 0x7b, 0x72, 0x92, 0x75, 0x4a, 0x59, 0x1b}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xea, 0xd8, 0xc5, 0x92, 0x2d, 0x2e, 0x3a, 0x7c, 0x23, 0xba, 0x1a, 0x7d, 0x86}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x5d, 0x2f, 0x2e, 0xd0, 0x4, 0xc3, 0xe0, 0x49, 0x67, 0xee, 0x78, 0xdb, 0xfe, 0x20, 0xb2}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa8, 0xe8, 0x15, 0x89, 0xe7, 0xe6, 0x7d, 0x7e, 0xb2, 0x5d, 0x36, 0xf6}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x56, 0x81, 0x66, 0x29, 0xce, 0x59, 0x8, 0xd8, 0xde, 0xdf, 0x2a, 0x84, 0x6b, 0xc1, 0xa3, 0xd5, 0x32, 0x29}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf9, 0xc9, 0x19, 0x78, 0xe9, 0xd0, 0xc5, 0x2a, 0xe4, 0x95, 0xb3, 0xd5, 0x9e, 0x2c, 0xa6, 0x71, 0xfd, 0x3e, 0x1f}; + lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x8c, 0xfc, 0x15, 0x5a, 0x5, 0xc9, 0xea, 0xcc, 0x97, 0xeb, 0xfb, 0xc6, 0xea, 0xbe, 0x12, 0x0, 0x69, 0xd3, 0xc9}; + lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; +lwmqtt_sub_options_t sub_opts[9]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[0].retain_as_published = true; +sub_opts[0].no_local = true; +sub_opts[1].qos = LWMQTT_QOS1; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS2; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = true; +sub_opts[3].qos = LWMQTT_QOS2; +sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = false; +sub_opts[4].qos = LWMQTT_QOS2; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[4].retain_as_published = true; +sub_opts[4].no_local = false; +sub_opts[5].qos = LWMQTT_QOS2; +sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = false; +sub_opts[6].qos = LWMQTT_QOS0; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[6].retain_as_published = true; +sub_opts[6].no_local = false; +sub_opts[7].qos = LWMQTT_QOS2; +sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[7].retain_as_published = true; +sub_opts[7].no_local = true; +sub_opts[8].qos = LWMQTT_QOS1; +sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[8].retain_as_published = false; +sub_opts[8].no_local = false; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31079}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30906}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22245}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops3}, .v = {1, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16962}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17136}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28279}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30451, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9349, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 5141 [("\173\ff",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS1}),("Jm\241\231Tp\203~\220z\153^\194\DC4\227'q\242\ESC1\177\192Q\185\NAK\ETX\139",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\227\229\242\245\173@\183\167\170\152\186\254\253<\SYN\223>|\242\237\137P8",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),(";\204",SubOptions {_retainHandling -// = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\153H\234.\165\EM\135u#\SO\b\141\141\185I\210.\241\136\224",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\186\197\SYN\130",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\251y\216\143Q\220\DC1\248\132\241\NUL\SI\DC3\b\230z\EM\166|",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\148xP\RSO\SI",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] -// [PropMessageExpiryInterval 30180,PropServerKeepAlive 3352,PropWillDelayInterval 23523,PropMaximumPacketSize -// 1624,PropAuthenticationData "\176\NAKz3+\CANbr\137\DC4\rO\215>\176\235f|\136\US\STX",PropAuthenticationMethod -// "\DEL\158 \228q\246d\210S0\183U",PropMaximumPacketSize 11585,PropSubscriptionIdentifier 1,PropTopicAlias -// 32339,PropMessageExpiryInterval 23859,PropMaximumPacketSize 21817,PropResponseInformation -// "\190s0\DEL}",PropCorrelationData "\186\169)t,B\158\SOH\185g]\245",PropContentType -// "\227\254\&9\223M\166$\231\200#\129\232\224\243p",PropMessageExpiryInterval 20421,PropSubscriptionIdentifierAvailable -// 250,PropSubscriptionIdentifier 4,PropPayloadFormatIndicator 15,PropResponseInformation -// "\DC3\136O\222\211O",PropWillDelayInterval 12115,PropMessageExpiryInterval 5290,PropRequestProblemInformation -// 242,PropAuthenticationMethod -// "\231",PropWillDelayInterval 13933,PropRequestResponseInformation 204,PropWillDelayInterval -// 15339,PropWildcardSubscriptionAvailable 166] -TEST(Subscribe5QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x7e, 0x22, 0xda, 0x3f, 0x24, 0x1a, 0x12, 0x0, 0x1c, 0x48, 0x13, 0x17, 0x9e, 0x11, 0x27, - 0xdc, 0xc2, 0x5e, 0x1, 0x7a, 0x1, 0x39, 0xb8, 0x5b, 0x31, 0x68, 0xbc, 0x8, 0x1e, 0x3d, 0x14, - 0x88, 0x61, 0xe5, 0x9, 0x36, 0x3a, 0x12, 0x0, 0xd, 0xa3, 0xd0, 0x4a, 0xd1, 0x26, 0x59, 0x62, - 0x7c, 0x5f, 0x69, 0x43, 0x3e, 0xe7, 0x18, 0x0, 0x0, 0x36, 0x6d, 0x19, 0xcc, 0x18, 0x0, 0x0, - 0x3b, 0xeb, 0x28, 0xa6, 0x0, 0xd, 0x38, 0x5b, 0xcc, 0x54, 0x65, 0xeb, 0xb9, 0x9a, 0x88, 0xb, - 0x49, 0x94, 0xdf, 0x4, 0x0, 0xd, 0x2f, 0xf2, 0x4f, 0xd3, 0xd, 0x83, 0xf5, 0xd2, 0xf0, 0x80, - 0xf, 0x2f, 0x40, 0x11, 0x0, 0x19, 0x95, 0x88, 0xc2, 0xbd, 0x1b, 0x82, 0x9a, 0xc3, 0x8a, 0x62, - 0x92, 0x0, 0xb5, 0x64, 0x1e, 0x7, 0xd8, 0xf1, 0x1c, 0xfc, 0x90, 0x33, 0xb9, 0x24, 0x4b, 0x15}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x38, 0x5b, 0xcc, 0x54, 0x65, 0xeb, 0xb9, 0x9a, 0x88, 0xb, 0x49, 0x94, 0xdf}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2f, 0xf2, 0x4f, 0xd3, 0xd, 0x83, 0xf5, 0xd2, 0xf0, 0x80, 0xf, 0x2f, 0x40}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x95, 0x88, 0xc2, 0xbd, 0x1b, 0x82, 0x9a, 0xc3, 0x8a, 0x62, 0x92, 0x0, 0xb5, - 0x64, 0x1e, 0x7, 0xd8, 0xf1, 0x1c, 0xfc, 0x90, 0x33, 0xb9, 0x24, 0x4b}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - uint8_t bytesprops0[] = {0x48, 0x13, 0x17, 0x9e, 0x11, 0x27, 0xdc, 0xc2, 0x5e, 0x1, 0x7a, 0x1, 0x39, 0xb8, - 0x5b, 0x31, 0x68, 0xbc, 0x8, 0x1e, 0x3d, 0x14, 0x88, 0x61, 0xe5, 0x9, 0x36, 0x3a}; - uint8_t bytesprops1[] = {0xa3, 0xd0, 0x4a, 0xd1, 0x26, 0x59, 0x62, 0x7c, 0x5f, 0x69, 0x43, 0x3e, 0xe7}; +// SubscribeRequest 21870 [("@\DC1\168\&4q^o\128\193 R\129Q\n\SO \156\223\234\178\252\158\217=",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\v\202\226\206G",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\159W\DC30=\CAN%",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\138O\209\212z\EOTK",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("3\240\148o\129\n\158\&8\NULd\193\134\132\129z\132z\219`{\235W\144_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropReceiveMaximum 18596,PropMaximumPacketSize 20980,PropMessageExpiryInterval 5884,PropReasonString "H\243Jo{\STX\232\242\171\EOT2\150\146\144c\EOT\172p",PropMaximumPacketSize 4083] +TEST(Subscribe5QCTest, Encode26) { +uint8_t pkt[] = {0x82, 0x7c, 0x55, 0x6e, 0x27, 0x21, 0x48, 0xa4, 0x27, 0x0, 0x0, 0x51, 0xf4, 0x2, 0x0, 0x0, 0x16, 0xfc, 0x1f, 0x0, 0x12, 0x48, 0xf3, 0x4a, 0x6f, 0x7b, 0x2, 0xe8, 0xf2, 0xab, 0x4, 0x32, 0x96, 0x92, 0x90, 0x63, 0x4, 0xac, 0x70, 0x27, 0x0, 0x0, 0xf, 0xf3, 0x0, 0x18, 0x40, 0x11, 0xa8, 0x34, 0x71, 0x5e, 0x6f, 0x80, 0xc1, 0x20, 0x52, 0x81, 0x51, 0xa, 0xe, 0x20, 0x9c, 0xdf, 0xea, 0xb2, 0xfc, 0x9e, 0xd9, 0x3d, 0x2e, 0x0, 0x5, 0xb, 0xca, 0xe2, 0xce, 0x47, 0x1e, 0x0, 0x7, 0x9f, 0x57, 0x13, 0x30, 0x3d, 0x18, 0x25, 0x2e, 0x0, 0x7, 0x8a, 0x4f, 0xd1, 0xd4, 0x7a, 0x4, 0x4b, 0xe, 0x0, 0x18, 0x33, 0xf0, 0x94, 0x6f, 0x81, 0xa, 0x9e, 0x38, 0x0, 0x64, 0xc1, 0x86, 0x84, 0x81, 0x7a, 0x84, 0x7a, 0xdb, 0x60, 0x7b, 0xeb, 0x57, 0x90, 0x5f, 0xe}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x40, 0x11, 0xa8, 0x34, 0x71, 0x5e, 0x6f, 0x80, 0xc1, 0x20, 0x52, 0x81, 0x51, 0xa, 0xe, 0x20, 0x9c, 0xdf, 0xea, 0xb2, 0xfc, 0x9e, 0xd9, 0x3d}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb, 0xca, 0xe2, 0xce, 0x47}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x9f, 0x57, 0x13, 0x30, 0x3d, 0x18, 0x25}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8a, 0x4f, 0xd1, 0xd4, 0x7a, 0x4, 0x4b}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x33, 0xf0, 0x94, 0x6f, 0x81, 0xa, 0x9e, 0x38, 0x0, 0x64, 0xc1, 0x86, 0x84, 0x81, 0x7a, 0x84, 0x7a, 0xdb, 0x60, 0x7b, 0xeb, 0x57, 0x90, 0x5f}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; +lwmqtt_sub_options_t sub_opts[5]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[0].retain_as_published = true; +sub_opts[0].no_local = true; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[1].retain_as_published = true; +sub_opts[1].no_local = true; +sub_opts[2].qos = LWMQTT_QOS2; +sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[2].retain_as_published = true; +sub_opts[2].no_local = true; +sub_opts[3].qos = LWMQTT_QOS2; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[3].retain_as_published = true; +sub_opts[3].no_local = true; +sub_opts[4].qos = LWMQTT_QOS2; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = true; +sub_opts[4].no_local = true; + uint8_t bytesprops0[] = {0x48, 0xf3, 0x4a, 0x6f, 0x7b, 0x2, 0xe8, 0xf2, 0xab, 0x4, 0x32, 0x96, 0x92, 0x90, 0x63, 0x4, 0xac, 0x70}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13933}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15339}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18596}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20980}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5884}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4083}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8922, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21870, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 10052 -// [("\197\182\247\NAK\225g\156\RSB\176\131>\210\163+gM\b]f\247\229C\139\206\250\&7\200N(",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\244\237N\DC2\r\SIT\223\DC2\235\166\252\&3\164\242J2\185\ETB$\209#O\222",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SUBP\205",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\SO=\180\165\216\210V\143\215h\230\182\212\148\199\230\SUBO\128\ENQX\163\200\244<\DC2g9P\180",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("3z\NUL6\210\254\222.\146\237\247\DEL*_\251",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("j\196\220\190\210\153\196\134\169\GS\DC2\208m6\155{i\204i=Ln9\201O_\NAK#-\177",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("v\NUL\235\199\138\128\&3\DEL\202Q",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS1}),("\239\216H\UStK\244\237\FSl#\234]\220Ll",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropUserProperty -// "\n!\209\175,1\NAK\164\145]\189" "",PropTopicAlias 29464,PropTopicAliasMaximum 9533,PropServerReference -// "O\218\NAK\253J\142D\197cU\128\219\235\SO\244_\171.v\231%\201",PropReceiveMaximum 3003,PropRetainAvailable -// 188,PropTopicAlias 24040,PropRequestProblemInformation 195,PropRequestResponseInformation 227,PropResponseInformation -// "\175\&4\144\136'\137\242\237B\189_M\154-\181\237B\232\155\207Z\145bc\211{\215",PropRequestResponseInformation -// 172,PropAuthenticationData -// "x*!\176\184[$\208\237\166J\192\184\151\134\218l\237\237\188\228B",PropRequestResponseInformation -// 8,PropSharedSubscriptionAvailable 95,PropAssignedClientIdentifier "\220\236\212<\250\230R\221V\165m0\254L"] -TEST(Subscribe5QCTest, Encode27) { - uint8_t pkt[] = { - 0x82, 0xc3, 0x2, 0x27, 0x44, 0x89, 0x1, 0x26, 0x0, 0xb, 0xa, 0x21, 0xd1, 0xaf, 0x2c, 0x31, 0x15, 0xa4, 0x91, - 0x5d, 0xbd, 0x0, 0x0, 0x23, 0x73, 0x18, 0x22, 0x25, 0x3d, 0x1c, 0x0, 0x16, 0x4f, 0xda, 0x15, 0xfd, 0x4a, 0x8e, - 0x44, 0xc5, 0x63, 0x55, 0x80, 0xdb, 0xeb, 0xe, 0xf4, 0x5f, 0xab, 0x2e, 0x76, 0xe7, 0x25, 0xc9, 0x21, 0xb, 0xbb, - 0x25, 0xbc, 0x23, 0x5d, 0xe8, 0x17, 0xc3, 0x19, 0xe3, 0x1a, 0x0, 0x1b, 0xaf, 0x34, 0x90, 0x88, 0x27, 0x89, 0xf2, - 0xed, 0x42, 0xbd, 0x5f, 0x4d, 0x9a, 0x2d, 0xb5, 0xed, 0x42, 0xe8, 0x9b, 0x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xa9, 0x1d, 0x12, 0xd0, 0x6d, 0x36, 0x9b, 0x7b, 0x69, 0xcc, 0x69, 0x3d, 0x4c, 0x6e, - 0x39, 0xc9, 0x4f, 0x5f, 0x15, 0x23, 0x2d, 0xb1, 0x2c, 0x0, 0xa, 0x76, 0x0, 0xeb, 0xc7, 0x8a, 0x80, 0x33, 0x7f, - 0xca, 0x51, 0xd, 0x0, 0x10, 0xef, 0xd8, 0x48, 0x1f, 0x74, 0x4b, 0xf4, 0xed, 0x1c, 0x6c, 0x23, 0xea, 0x5d, 0xdc, - 0x4c, 0x6c, 0x4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xc5, 0xb6, 0xf7, 0x15, 0xe1, 0x67, 0x9c, 0x1e, 0x42, 0xb0, - 0x83, 0x3e, 0xd2, 0xa3, 0x2b, 0x67, 0x4d, 0x8, 0x5d, 0x66, - 0xf7, 0xe5, 0x43, 0x8b, 0xce, 0xfa, 0x37, 0xc8, 0x4e, 0x28}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf4, 0xed, 0x4e, 0x12, 0xd, 0xf, 0x54, 0xdf, 0x12, 0xeb, 0xa6, 0xfc, - 0x33, 0xa4, 0xf2, 0x4a, 0x32, 0xb9, 0x17, 0x24, 0xd1, 0x23, 0x4f, 0xde}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1a, 0x50, 0xcd}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe, 0x3d, 0xb4, 0xa5, 0xd8, 0xd2, 0x56, 0x8f, 0xd7, 0x68, - 0xe6, 0xb6, 0xd4, 0x94, 0xc7, 0xe6, 0x1a, 0x4f, 0x80, 0x5, - 0x58, 0xa3, 0xc8, 0xf4, 0x3c, 0x12, 0x67, 0x39, 0x50, 0xb4}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x33, 0x7a, 0x0, 0x36, 0xd2, 0xfe, 0xde, 0x2e, - 0x92, 0xed, 0xf7, 0x7f, 0x2a, 0x5f, 0xfb}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6a, 0xc4, 0xdc, 0xbe, 0xd2, 0x99, 0xc4, 0x86, 0xa9, 0x1d, - 0x12, 0xd0, 0x6d, 0x36, 0x9b, 0x7b, 0x69, 0xcc, 0x69, 0x3d, - 0x4c, 0x6e, 0x39, 0xc9, 0x4f, 0x5f, 0x15, 0x23, 0x2d, 0xb1}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x76, 0x0, 0xeb, 0xc7, 0x8a, 0x80, 0x33, 0x7f, 0xca, 0x51}; - lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xef, 0xd8, 0x48, 0x1f, 0x74, 0x4b, 0xf4, 0xed, - 0x1c, 0x6c, 0x23, 0xea, 0x5d, 0xdc, 0x4c, 0x6c}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = true; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops0[] = {0xa, 0x21, 0xd1, 0xaf, 0x2c, 0x31, 0x15, 0xa4, 0x91, 0x5d, 0xbd}; - uint8_t bytesprops2[] = {0x4f, 0xda, 0x15, 0xfd, 0x4a, 0x8e, 0x44, 0xc5, 0x63, 0x55, 0x80, - 0xdb, 0xeb, 0xe, 0xf4, 0x5f, 0xab, 0x2e, 0x76, 0xe7, 0x25, 0xc9}; - uint8_t bytesprops3[] = {0xaf, 0x34, 0x90, 0x88, 0x27, 0x89, 0xf2, 0xed, 0x42, 0xbd, 0x5f, 0x4d, 0x9a, 0x2d, - 0xb5, 0xed, 0x42, 0xe8, 0x9b, 0xcf, 0x5a, 0x91, 0x62, 0x63, 0xd3, 0x7b, 0xd7}; - uint8_t bytesprops4[] = {0x78, 0x2a, 0x21, 0xb0, 0xb8, 0x5b, 0x24, 0xd0, 0xed, 0xa6, 0x4a, - 0xc0, 0xb8, 0x97, 0x86, 0xda, 0x6c, 0xed, 0xed, 0xbc, 0xe4, 0x42}; - uint8_t bytesprops5[] = {0xdc, 0xec, 0xd4, 0x3c, 0xfa, 0xe6, 0x52, 0xdd, 0x56, 0xa5, 0x6d, 0x30, 0xfe, 0x4c}; +// SubscribeRequest 6154 [("\DEL\244\227\193\248L\DC2\249\249h\217u_u",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\146\226X\227zoKZ\172C$\DC1>",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\USpH\130\\\EOT\ESCo\r\205\249d\215\243\246\EM\243\\Oy\195\147\&9<\249A\230\&5\ETX.",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\186Uah\251?\236m\133\v\215",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\f\193y\211\&9\163\188\237\SYN8\198\DC34\130\218\203\&3~\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\255+\137v\184\215Pix\170R\252{l\130\254\212yQ\223@l\SI\130i",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\137\236\&92",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("{\"\202\130",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\221u\223w",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\249\137\219n\139\f\238\208lT0\201\209\SI\135\237\182\212\185\190\244\220\177\180B\229",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\\([*\EOTn\145\175\236G\176\&8\240\STX\170\SUB[c",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropWillDelayInterval 18072,PropRequestProblemInformation 247,PropWildcardSubscriptionAvailable 13,PropAssignedClientIdentifier "pq\141\159\215]}S\235!qs",PropRequestResponseInformation 251,PropReasonString "\219\251S\148",PropUserProperty "\US\228\156\DC1\240`p%\137\140\230\164\\R\196\224" "\SO\250{\SUB\159\191\213\185",PropRequestResponseInformation 24,PropAuthenticationMethod "",PropServerReference "\SOH\176\197K\191\185\142>\244\DC13e9\201\253\183\DEL\249&\187\191\222\150D",PropTopicAlias 32300,PropPayloadFormatIndicator 3,PropWildcardSubscriptionAvailable 185,PropAuthenticationData "/",PropMaximumQoS 220,PropServerKeepAlive 4339,PropTopicAliasMaximum 14185,PropSessionExpiryInterval 886,PropUserProperty "<\245\DELf\142\168\168\154\243\184\DC1\189\CAN\146\197k\226\235?rc\170E:" "p\214\176\DC2\129",PropRequestResponseInformation 207,PropCorrelationData "@\212\214d\236`\143q\DELW\DC1\t\\p+\a\179\DC2\240]IW\GS\"",PropResponseTopic "",PropContentType "\176\181c\ETX)\179w?$a\248\250$\247=\n\159\151\156\135",PropUserProperty "O\132" "u\232\177\ACK;\191\&2\164\144.\158\135\194ho\251\153:\n\240\200\FSu",PropWildcardSubscriptionAvailable 59,PropMessageExpiryInterval 6310,PropServerReference "z\v\DLE\239h\129\&3\204%\254\NULF!\228bS>",PropRequestResponseInformation 10,PropTopicAliasMaximum 8987,PropUserProperty "R\GS9>f" "^\ETX\174\173K\197c\221\132L\249CY\179\208\207\154-\223"] +TEST(Subscribe5QCTest, Encode27) { +uint8_t pkt[] = {0x82, 0xf7, 0x3, 0x18, 0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0x6d, 0x85, 0xb, 0xd7, 0x1d, 0x0, 0x13, 0xc, 0xc1, 0x79, 0xd3, 0x39, 0xa3, 0xbc, 0xed, 0x16, 0x38, 0xc6, 0x13, 0x34, 0x82, 0xda, 0xcb, 0x33, 0x7e, 0x5c, 0x4, 0x0, 0x19, 0xff, 0x2b, 0x89, 0x76, 0xb8, 0xd7, 0x50, 0x69, 0x78, 0xaa, 0x52, 0xfc, 0x7b, 0x6c, 0x82, 0xfe, 0xd4, 0x79, 0x51, 0xdf, 0x40, 0x6c, 0xf, 0x82, 0x69, 0x14, 0x0, 0x4, 0x89, 0xec, 0x39, 0x32, 0x1a, 0x0, 0x4, 0x7b, 0x22, 0xca, 0x82, 0x1c, 0x0, 0x4, 0xdd, 0x75, 0xdf, 0x77, 0x1d, 0x0, 0x1a, 0xf9, 0x89, 0xdb, 0x6e, 0x8b, 0xc, 0xee, 0xd0, 0x6c, 0x54, 0x30, 0xc9, 0xd1, 0xf, 0x87, 0xed, 0xb6, 0xd4, 0xb9, 0xbe, 0xf4, 0xdc, 0xb1, 0xb4, 0x42, 0xe5, 0x6, 0x0, 0x12, 0x5c, 0x28, 0x5b, 0x2a, 0x4, 0x6e, 0x91, 0xaf, 0xec, 0x47, 0xb0, 0x38, 0xf0, 0x2, 0xaa, 0x1a, 0x5b, 0x63, 0xd}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x7f, 0xf4, 0xe3, 0xc1, 0xf8, 0x4c, 0x12, 0xf9, 0xf9, 0x68, 0xd9, 0x75, 0x5f, 0x75}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x92, 0xe2, 0x58, 0xe3, 0x7a, 0x6f, 0x4b, 0x5a, 0xac, 0x43, 0x24, 0x11, 0x3e}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1f, 0x70, 0x48, 0x82, 0x5c, 0x4, 0x1b, 0x6f, 0xd, 0xcd, 0xf9, 0x64, 0xd7, 0xf3, 0xf6, 0x19, 0xf3, 0x5c, 0x4f, 0x79, 0xc3, 0x93, 0x39, 0x3c, 0xf9, 0x41, 0xe6, 0x35, 0x3, 0x2e}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xba, 0x55, 0x61, 0x68, 0xfb, 0x3f, 0xec, 0x6d, 0x85, 0xb, 0xd7}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xc, 0xc1, 0x79, 0xd3, 0x39, 0xa3, 0xbc, 0xed, 0x16, 0x38, 0xc6, 0x13, 0x34, 0x82, 0xda, 0xcb, 0x33, 0x7e, 0x5c}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; +topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xff, 0x2b, 0x89, 0x76, 0xb8, 0xd7, 0x50, 0x69, 0x78, 0xaa, 0x52, 0xfc, 0x7b, 0x6c, 0x82, 0xfe, 0xd4, 0x79, 0x51, 0xdf, 0x40, 0x6c, 0xf, 0x82, 0x69}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; +topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x89, 0xec, 0x39, 0x32}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; +topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x7b, 0x22, 0xca, 0x82}; + lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; +topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xdd, 0x75, 0xdf, 0x77}; + lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; +topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xf9, 0x89, 0xdb, 0x6e, 0x8b, 0xc, 0xee, 0xd0, 0x6c, 0x54, 0x30, 0xc9, 0xd1, 0xf, 0x87, 0xed, 0xb6, 0xd4, 0xb9, 0xbe, 0xf4, 0xdc, 0xb1, 0xb4, 0x42, 0xe5}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; +topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x5c, 0x28, 0x5b, 0x2a, 0x4, 0x6e, 0x91, 0xaf, 0xec, 0x47, 0xb0, 0x38, 0xf0, 0x2, 0xaa, 0x1a, 0x5b, 0x63}; + lwmqtt_string_t topic_filter_s10 = {18, (char*)&topic_filter_s10_bytes}; +topic_filters[10] = topic_filter_s10; +lwmqtt_sub_options_t sub_opts[11]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[0].retain_as_published = true; +sub_opts[0].no_local = true; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[1].retain_as_published = true; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[2].retain_as_published = true; +sub_opts[2].no_local = true; +sub_opts[3].qos = LWMQTT_QOS1; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[3].retain_as_published = true; +sub_opts[3].no_local = true; +sub_opts[4].qos = LWMQTT_QOS0; +sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[4].retain_as_published = false; +sub_opts[4].no_local = true; +sub_opts[5].qos = LWMQTT_QOS0; +sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[5].retain_as_published = false; +sub_opts[5].no_local = true; +sub_opts[6].qos = LWMQTT_QOS2; +sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[6].retain_as_published = true; +sub_opts[6].no_local = false; +sub_opts[7].qos = LWMQTT_QOS0; +sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[7].retain_as_published = true; +sub_opts[7].no_local = true; +sub_opts[8].qos = LWMQTT_QOS1; +sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[8].retain_as_published = true; +sub_opts[8].no_local = true; +sub_opts[9].qos = LWMQTT_QOS2; +sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[9].retain_as_published = false; +sub_opts[9].no_local = true; +sub_opts[10].qos = LWMQTT_QOS1; +sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[10].retain_as_published = true; +sub_opts[10].no_local = true; + uint8_t bytesprops0[] = {0x70, 0x71, 0x8d, 0x9f, 0xd7, 0x5d, 0x7d, 0x53, 0xeb, 0x21, 0x71, 0x73}; + uint8_t bytesprops1[] = {0xdb, 0xfb, 0x53, 0x94}; + uint8_t bytesprops3[] = {0xe, 0xfa, 0x7b, 0x1a, 0x9f, 0xbf, 0xd5, 0xb9}; + uint8_t bytesprops2[] = {0x1f, 0xe4, 0x9c, 0x11, 0xf0, 0x60, 0x70, 0x25, 0x89, 0x8c, 0xe6, 0xa4, 0x5c, 0x52, 0xc4, 0xe0}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0x1, 0xb0, 0xc5, 0x4b, 0xbf, 0xb9, 0x8e, 0x3e, 0xf4, 0x11, 0x33, 0x65, 0x39, 0xc9, 0xfd, 0xb7, 0x7f, 0xf9, 0x26, 0xbb, 0xbf, 0xde, 0x96, 0x44}; + uint8_t bytesprops6[] = {0x2f}; + uint8_t bytesprops8[] = {0x70, 0xd6, 0xb0, 0x12, 0x81}; + uint8_t bytesprops7[] = {0x3c, 0xf5, 0x7f, 0x66, 0x8e, 0xa8, 0xa8, 0x9a, 0xf3, 0xb8, 0x11, 0xbd, 0x18, 0x92, 0xc5, 0x6b, 0xe2, 0xeb, 0x3f, 0x72, 0x63, 0xaa, 0x45, 0x3a}; + uint8_t bytesprops9[] = {0x40, 0xd4, 0xd6, 0x64, 0xec, 0x60, 0x8f, 0x71, 0x7f, 0x57, 0x11, 0x9, 0x5c, 0x70, 0x2b, 0x7, 0xb3, 0x12, 0xf0, 0x5d, 0x49, 0x57, 0x1d, 0x22}; + uint8_t bytesprops10[] = {0}; + uint8_t bytesprops11[] = {0xb0, 0xb5, 0x63, 0x3, 0x29, 0xb3, 0x77, 0x3f, 0x24, 0x61, 0xf8, 0xfa, 0x24, 0xf7, 0x3d, 0xa, 0x9f, 0x97, 0x9c, 0x87}; + uint8_t bytesprops13[] = {0x75, 0xe8, 0xb1, 0x6, 0x3b, 0xbf, 0x32, 0xa4, 0x90, 0x2e, 0x9e, 0x87, 0xc2, 0x68, 0x6f, 0xfb, 0x99, 0x3a, 0xa, 0xf0, 0xc8, 0x1c, 0x75}; + uint8_t bytesprops12[] = {0x4f, 0x84}; + uint8_t bytesprops14[] = {0x7a, 0xb, 0x10, 0xef, 0x68, 0x81, 0x33, 0xcc, 0x25, 0xfe, 0x0, 0x46, 0x21, 0xe4, 0x62, 0x53, 0x3e}; + uint8_t bytesprops16[] = {0x5e, 0x3, 0xae, 0xad, 0x4b, 0xc5, 0x63, 0xdd, 0x84, 0x4c, 0xf9, 0x43, 0x59, 0xb3, 0xd0, 0xcf, 0x9a, 0x2d, 0xdf}; + uint8_t bytesprops15[] = {0x52, 0x1d, 0x39, 0x3e, 0x66}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29464}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9533}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3003}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24040}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18072}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={16, (char*)&bytesprops2}, .v={8, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32300}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4339}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14185}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 886}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={24, (char*)&bytesprops7}, .v={5, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={2, (char*)&bytesprops12}, .v={23, (char*)&bytesprops13}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6310}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8987}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={5, (char*)&bytesprops15}, .v={19, (char*)&bytesprops16}}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10052, 8, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6154, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 12644 [("\185\166\&5\ACK\169\SOk",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropReceiveMaximum 7431,PropResponseTopic -// "\FS\253\196\NUL\224_XZl\140\163F\143,\193X",PropMaximumQoS 28,PropAuthenticationMethod "99",PropResponseInformation -// "\169\169\190\187|\197\DLE\198",PropResponseInformation "3_>"] -TEST(Subscribe5QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0x3e, 0x31, 0x64, 0x2e, 0x21, 0x1d, 0x7, 0x8, 0x0, 0x10, 0x1c, 0xfd, 0xc4, 0x0, 0xe0, - 0x5f, 0x58, 0x5a, 0x6c, 0x8c, 0xa3, 0x46, 0x8f, 0x2c, 0xc1, 0x58, 0x24, 0x1c, 0x15, 0x0, 0x2, - 0x39, 0x39, 0x1a, 0x0, 0x8, 0xa9, 0xa9, 0xbe, 0xbb, 0x7c, 0xc5, 0x10, 0xc6, 0x1a, 0x0, 0x3, - 0x33, 0x5f, 0x3e, 0x0, 0x7, 0xb9, 0xa6, 0x35, 0x6, 0xa9, 0xe, 0x6b, 0x29, 0x0, 0x0, 0x1d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xb9, 0xa6, 0x35, 0x6, 0xa9, 0xe, 0x6b}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - uint8_t bytesprops0[] = {0x1c, 0xfd, 0xc4, 0x0, 0xe0, 0x5f, 0x58, 0x5a, - 0x6c, 0x8c, 0xa3, 0x46, 0x8f, 0x2c, 0xc1, 0x58}; - uint8_t bytesprops1[] = {0x39, 0x39}; - uint8_t bytesprops2[] = {0xa9, 0xa9, 0xbe, 0xbb, 0x7c, 0xc5, 0x10, 0xc6}; - uint8_t bytesprops3[] = {0x33, 0x5f, 0x3e}; +// SubscribeRequest 7912 [("\182\167\151\163VQ\156;\242Q\187<\193\&4\145-\243Y\208\152E?\200&\SYN\US",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\FS?\153\174\206\185MuW\176b\183\172\134",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\223\224s\US\169\&0bC\ENQQ\200\221\248qE\235\255B\n",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerReference "\152\224[5B",PropTopicAlias 477,PropUserProperty "\130\CANs\f4-\245\227" "46\200\238\DLEf\176\GS\192j#\183r\CAN\234\ENQ\133\249",PropResponseTopic "\GS\200\&9\209\216\182\137<\185\170\147\234\&2\132\171\181rh\137",PropReceiveMaximum 30574,PropRequestProblemInformation 32] +TEST(Subscribe5QCTest, Encode28) { +uint8_t pkt[] = {0x82, 0x8c, 0x1, 0x1e, 0xe8, 0x45, 0x1c, 0x0, 0x5, 0x98, 0xe0, 0x5b, 0x35, 0x42, 0x23, 0x1, 0xdd, 0x26, 0x0, 0x8, 0x82, 0x18, 0x73, 0xc, 0x34, 0x2d, 0xf5, 0xe3, 0x0, 0x12, 0x34, 0x36, 0xc8, 0xee, 0x10, 0x66, 0xb0, 0x1d, 0xc0, 0x6a, 0x23, 0xb7, 0x72, 0x18, 0xea, 0x5, 0x85, 0xf9, 0x8, 0x0, 0x13, 0x1d, 0xc8, 0x39, 0xd1, 0xd8, 0xb6, 0x89, 0x3c, 0xb9, 0xaa, 0x93, 0xea, 0x32, 0x84, 0xab, 0xb5, 0x72, 0x68, 0x89, 0x21, 0x77, 0x6e, 0x17, 0x20, 0x0, 0x1a, 0xb6, 0xa7, 0x97, 0xa3, 0x56, 0x51, 0x9c, 0x3b, 0xf2, 0x51, 0xbb, 0x3c, 0xc1, 0x34, 0x91, 0x2d, 0xf3, 0x59, 0xd0, 0x98, 0x45, 0x3f, 0xc8, 0x26, 0x16, 0x1f, 0x15, 0x0, 0xe, 0x1c, 0x3f, 0x99, 0xae, 0xce, 0xb9, 0x4d, 0x75, 0x57, 0xb0, 0x62, 0xb7, 0xac, 0x86, 0x24, 0x0, 0x13, 0xdf, 0xe0, 0x73, 0x1f, 0xa9, 0x30, 0x62, 0x43, 0x5, 0x51, 0xc8, 0xdd, 0xf8, 0x71, 0x45, 0xeb, 0xff, 0x42, 0xa, 0x21}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xb6, 0xa7, 0x97, 0xa3, 0x56, 0x51, 0x9c, 0x3b, 0xf2, 0x51, 0xbb, 0x3c, 0xc1, 0x34, 0x91, 0x2d, 0xf3, 0x59, 0xd0, 0x98, 0x45, 0x3f, 0xc8, 0x26, 0x16, 0x1f}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x1c, 0x3f, 0x99, 0xae, 0xce, 0xb9, 0x4d, 0x75, 0x57, 0xb0, 0x62, 0xb7, 0xac, 0x86}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xdf, 0xe0, 0x73, 0x1f, 0xa9, 0x30, 0x62, 0x43, 0x5, 0x51, 0xc8, 0xdd, 0xf8, 0x71, 0x45, 0xeb, 0xff, 0x42, 0xa}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; +lwmqtt_sub_options_t sub_opts[3]; +sub_opts[0].qos = LWMQTT_QOS1; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = true; +sub_opts[1].qos = LWMQTT_QOS0; +sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = true; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = false; + uint8_t bytesprops0[] = {0x98, 0xe0, 0x5b, 0x35, 0x42}; + uint8_t bytesprops2[] = {0x34, 0x36, 0xc8, 0xee, 0x10, 0x66, 0xb0, 0x1d, 0xc0, 0x6a, 0x23, 0xb7, 0x72, 0x18, 0xea, 0x5, 0x85, 0xf9}; + uint8_t bytesprops1[] = {0x82, 0x18, 0x73, 0xc, 0x34, 0x2d, 0xf5, 0xe3}; + uint8_t bytesprops3[] = {0x1d, 0xc8, 0x39, 0xd1, 0xd8, 0xb6, 0x89, 0x3c, 0xb9, 0xaa, 0x93, 0xea, 0x32, 0x84, 0xab, 0xb5, 0x72, 0x68, 0x89}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7431}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 477}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={8, (char*)&bytesprops1}, .v={18, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30574}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 32}}, }; lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12644, 2, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7912, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 4944 [("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("_k\r\DC2\f\SI\228\155\183\&2\NAK\NULR\a]\202\235\149",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("*>\177\186\&0]\214*\191\206q\"\231\248\230\193\194E\183\238!\241+\233\222,\198t\234\150",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("mP\215\162\&0:<\157\150\b\240m\ETX\235\218\SOH\255I\168\&5I\145\134^\EM",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropServerKeepAlive -// 3031,PropTopicAlias 6809,PropWildcardSubscriptionAvailable 52,PropSubscriptionIdentifierAvailable -// 30,PropCorrelationData "n\167*\135\166\SOq\209\STX\EOT\221\NAK\160}'\179\ACK2M\179\US5\225\EMw",PropTopicAlias -// 10360,PropTopicAlias 21111,PropSubscriptionIdentifierAvailable 32,PropWillDelayInterval 537,PropTopicAlias -// 5672,PropContentType "\192\182\164\143X\175\218x",PropMessageExpiryInterval 6031,PropPayloadFormatIndicator -// 210,PropContentType "ih\217C\146U",PropReasonString -// "\223\129\163\176\232\&5+z\DC4\225\"\162*M",PropMessageExpiryInterval 28586,PropServerKeepAlive 20076,PropContentType -// ")\US\157\149\DC2\DC3\242\251L%\143\167U\220\212)c\216\SO"] -TEST(Subscribe5QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0xd9, 0x1, 0x13, 0x50, 0x80, 0x1, 0x13, 0xb, 0xd7, 0x23, 0x1a, 0x99, 0x28, 0x34, 0x29, 0x1e, - 0x9, 0x0, 0x19, 0x6e, 0xa7, 0x2a, 0x87, 0xa6, 0xe, 0x71, 0xd1, 0x2, 0x4, 0xdd, 0x15, 0xa0, 0x7d, - 0x27, 0xb3, 0x6, 0x32, 0x4d, 0xb3, 0x1f, 0x35, 0xe1, 0x19, 0x77, 0x23, 0x28, 0x78, 0x23, 0x52, 0x77, - 0x29, 0x20, 0x18, 0x0, 0x0, 0x2, 0x19, 0x23, 0x16, 0x28, 0x3, 0x0, 0x8, 0xc0, 0xb6, 0xa4, 0x8f, - 0x58, 0xaf, 0xda, 0x78, 0x2, 0x0, 0x0, 0x17, 0x8f, 0x1, 0xd2, 0x3, 0x0, 0x6, 0x69, 0x68, 0xd9, - 0x43, 0x92, 0x55, 0x1f, 0x0, 0xe, 0xdf, 0x81, 0xa3, 0xb0, 0xe8, 0x35, 0x2b, 0x7a, 0x14, 0xe1, 0x22, - 0xa2, 0x2a, 0x4d, 0x2, 0x0, 0x0, 0x6f, 0xaa, 0x13, 0x4e, 0x6c, 0x3, 0x0, 0x13, 0x29, 0x1f, 0x9d, - 0x95, 0x12, 0x13, 0xf2, 0xfb, 0x4c, 0x25, 0x8f, 0xa7, 0x55, 0xdc, 0xd4, 0x29, 0x63, 0xd8, 0xe, 0x0, - 0x0, 0x22, 0x0, 0x12, 0x5f, 0x6b, 0xd, 0x12, 0xc, 0xf, 0xe4, 0x9b, 0xb7, 0x32, 0x15, 0x0, 0x52, - 0x7, 0x5d, 0xca, 0xeb, 0x95, 0x2e, 0x0, 0x1e, 0x2a, 0x3e, 0xb1, 0xba, 0x30, 0x5d, 0xd6, 0x2a, 0xbf, - 0xce, 0x71, 0x22, 0xe7, 0xf8, 0xe6, 0xc1, 0xc2, 0x45, 0xb7, 0xee, 0x21, 0xf1, 0x2b, 0xe9, 0xde, 0x2c, - 0xc6, 0x74, 0xea, 0x96, 0x5, 0x0, 0x19, 0x6d, 0x50, 0xd7, 0xa2, 0x30, 0x3a, 0x3c, 0x9d, 0x96, 0x8, - 0xf0, 0x6d, 0x3, 0xeb, 0xda, 0x1, 0xff, 0x49, 0xa8, 0x35, 0x49, 0x91, 0x86, 0x5e, 0x19, 0x29}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5f, 0x6b, 0xd, 0x12, 0xc, 0xf, 0xe4, 0x9b, 0xb7, - 0x32, 0x15, 0x0, 0x52, 0x7, 0x5d, 0xca, 0xeb, 0x95}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2a, 0x3e, 0xb1, 0xba, 0x30, 0x5d, 0xd6, 0x2a, 0xbf, 0xce, - 0x71, 0x22, 0xe7, 0xf8, 0xe6, 0xc1, 0xc2, 0x45, 0xb7, 0xee, - 0x21, 0xf1, 0x2b, 0xe9, 0xde, 0x2c, 0xc6, 0x74, 0xea, 0x96}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6d, 0x50, 0xd7, 0xa2, 0x30, 0x3a, 0x3c, 0x9d, 0x96, 0x8, 0xf0, 0x6d, 0x3, - 0xeb, 0xda, 0x1, 0xff, 0x49, 0xa8, 0x35, 0x49, 0x91, 0x86, 0x5e, 0x19}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - uint8_t bytesprops0[] = {0x6e, 0xa7, 0x2a, 0x87, 0xa6, 0xe, 0x71, 0xd1, 0x2, 0x4, 0xdd, 0x15, 0xa0, - 0x7d, 0x27, 0xb3, 0x6, 0x32, 0x4d, 0xb3, 0x1f, 0x35, 0xe1, 0x19, 0x77}; - uint8_t bytesprops1[] = {0xc0, 0xb6, 0xa4, 0x8f, 0x58, 0xaf, 0xda, 0x78}; - uint8_t bytesprops2[] = {0x69, 0x68, 0xd9, 0x43, 0x92, 0x55}; - uint8_t bytesprops3[] = {0xdf, 0x81, 0xa3, 0xb0, 0xe8, 0x35, 0x2b, 0x7a, 0x14, 0xe1, 0x22, 0xa2, 0x2a, 0x4d}; - uint8_t bytesprops4[] = {0x29, 0x1f, 0x9d, 0x95, 0x12, 0x13, 0xf2, 0xfb, 0x4c, 0x25, - 0x8f, 0xa7, 0x55, 0xdc, 0xd4, 0x29, 0x63, 0xd8, 0xe}; +// SubscribeRequest 1410 [("\146)\134\170\232\238\169\149\192\144\173`=4\225}\DC2\181\176\234\SUB-\173\SI\204",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\157\225\208\231:\189\b\244\171\243J\204\GS\233\177\CAN\210v\FS\NUL\EM",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DC3\166\143e\196",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropRequestProblemInformation 29,PropTopicAlias 657,PropSessionExpiryInterval 1894,PropResponseTopic "$S",PropRequestResponseInformation 124,PropTopicAlias 1690,PropUserProperty "N\136xM3\136\222ru\f\176\175\DC1\230\NAK=\v\166\163\DELN\145X\210\215~\STXJz" "\220_x\128;I\ENQ\219\229\217\&7\198+\175\169\196\&7\233E^\210\198\146\ETB.]\RS\"q",PropPayloadFormatIndicator 229,PropRequestResponseInformation 121,PropRequestProblemInformation 171,PropPayloadFormatIndicator 152,PropMessageExpiryInterval 13952,PropServerReference "Q\225\246\218\234\194\NAKbVF^\f\214",PropAuthenticationData ")\254\245\174&:r!\160\SUB\218Y",PropUserProperty "\243\255y" "I",PropServerKeepAlive 9699,PropTopicAlias 857,PropServerKeepAlive 16613,PropServerKeepAlive 21324,PropMaximumQoS 131,PropRequestResponseInformation 48] +TEST(Subscribe5QCTest, Encode29) { +uint8_t pkt[] = {0x82, 0xd8, 0x1, 0x5, 0x82, 0x98, 0x1, 0x17, 0x1d, 0x23, 0x2, 0x91, 0x11, 0x0, 0x0, 0x7, 0x66, 0x8, 0x0, 0x2, 0x24, 0x53, 0x19, 0x7c, 0x23, 0x6, 0x9a, 0x26, 0x0, 0x1d, 0x4e, 0x88, 0x78, 0x4d, 0x33, 0x88, 0xde, 0x72, 0x75, 0xc, 0xb0, 0xaf, 0x11, 0xe6, 0x15, 0x3d, 0xb, 0xa6, 0xa3, 0x7f, 0x4e, 0x91, 0x58, 0xd2, 0xd7, 0x7e, 0x2, 0x4a, 0x7a, 0x0, 0x1d, 0xdc, 0x5f, 0x78, 0x80, 0x3b, 0x49, 0x5, 0xdb, 0xe5, 0xd9, 0x37, 0xc6, 0x2b, 0xaf, 0xa9, 0xc4, 0x37, 0xe9, 0x45, 0x5e, 0xd2, 0xc6, 0x92, 0x17, 0x2e, 0x5d, 0x1e, 0x22, 0x71, 0x1, 0xe5, 0x19, 0x79, 0x17, 0xab, 0x1, 0x98, 0x2, 0x0, 0x0, 0x36, 0x80, 0x1c, 0x0, 0xd, 0x51, 0xe1, 0xf6, 0xda, 0xea, 0xc2, 0x15, 0x62, 0x56, 0x46, 0x5e, 0xc, 0xd6, 0x16, 0x0, 0xc, 0x29, 0xfe, 0xf5, 0xae, 0x26, 0x3a, 0x72, 0x21, 0xa0, 0x1a, 0xda, 0x59, 0x26, 0x0, 0x3, 0xf3, 0xff, 0x79, 0x0, 0x1, 0x49, 0x13, 0x25, 0xe3, 0x23, 0x3, 0x59, 0x13, 0x40, 0xe5, 0x13, 0x53, 0x4c, 0x24, 0x83, 0x19, 0x30, 0x0, 0x19, 0x92, 0x29, 0x86, 0xaa, 0xe8, 0xee, 0xa9, 0x95, 0xc0, 0x90, 0xad, 0x60, 0x3d, 0x34, 0xe1, 0x7d, 0x12, 0xb5, 0xb0, 0xea, 0x1a, 0x2d, 0xad, 0xf, 0xcc, 0x14, 0x0, 0x15, 0x9d, 0xe1, 0xd0, 0xe7, 0x3a, 0xbd, 0x8, 0xf4, 0xab, 0xf3, 0x4a, 0xcc, 0x1d, 0xe9, 0xb1, 0x18, 0xd2, 0x76, 0x1c, 0x0, 0x19, 0x22, 0x0, 0x5, 0x13, 0xa6, 0x8f, 0x65, 0xc4, 0x9}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x92, 0x29, 0x86, 0xaa, 0xe8, 0xee, 0xa9, 0x95, 0xc0, 0x90, 0xad, 0x60, 0x3d, 0x34, 0xe1, 0x7d, 0x12, 0xb5, 0xb0, 0xea, 0x1a, 0x2d, 0xad, 0xf, 0xcc}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x9d, 0xe1, 0xd0, 0xe7, 0x3a, 0xbd, 0x8, 0xf4, 0xab, 0xf3, 0x4a, 0xcc, 0x1d, 0xe9, 0xb1, 0x18, 0xd2, 0x76, 0x1c, 0x0, 0x19}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x13, 0xa6, 0x8f, 0x65, 0xc4}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; +lwmqtt_sub_options_t sub_opts[3]; +sub_opts[0].qos = LWMQTT_QOS0; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = true; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[1].retain_as_published = false; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS1; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = true; +sub_opts[2].no_local = false; + uint8_t bytesprops0[] = {0x24, 0x53}; + uint8_t bytesprops2[] = {0xdc, 0x5f, 0x78, 0x80, 0x3b, 0x49, 0x5, 0xdb, 0xe5, 0xd9, 0x37, 0xc6, 0x2b, 0xaf, 0xa9, 0xc4, 0x37, 0xe9, 0x45, 0x5e, 0xd2, 0xc6, 0x92, 0x17, 0x2e, 0x5d, 0x1e, 0x22, 0x71}; + uint8_t bytesprops1[] = {0x4e, 0x88, 0x78, 0x4d, 0x33, 0x88, 0xde, 0x72, 0x75, 0xc, 0xb0, 0xaf, 0x11, 0xe6, 0x15, 0x3d, 0xb, 0xa6, 0xa3, 0x7f, 0x4e, 0x91, 0x58, 0xd2, 0xd7, 0x7e, 0x2, 0x4a, 0x7a}; + uint8_t bytesprops3[] = {0x51, 0xe1, 0xf6, 0xda, 0xea, 0xc2, 0x15, 0x62, 0x56, 0x46, 0x5e, 0xc, 0xd6}; + uint8_t bytesprops4[] = {0x29, 0xfe, 0xf5, 0xae, 0x26, 0x3a, 0x72, 0x21, 0xa0, 0x1a, 0xda, 0x59}; + uint8_t bytesprops6[] = {0x49}; + uint8_t bytesprops5[] = {0xf3, 0xff, 0x79}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3031}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6809}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10360}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21111}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 537}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5672}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6031}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28586}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20076}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 657}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1894}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1690}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={29, (char*)&bytesprops1}, .v={29, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13952}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={3, (char*)&bytesprops5}, .v={1, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9699}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 857}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16613}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21324}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4944, 4, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1410, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeRequest 10380 [("x#\177~\235\205^\211e\221\198\US_r6\166_\SUB\220\237ILW\169\182V\129",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("fv\DC4W\179\ETB\232\n\203",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS2}),("\183Q\224\149\199H$\NAK\183\GS\164\130\219 $B\130J\247\250\205V\218",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("w\NAK{\230=\DC2\213",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = -// True, _subQoS = QoS2}),(".\240\210\165\146h\199\217\159k\147\SO.\155\246\245\233\STX\229P\168\196",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\226I\SYN\248",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS0}),("\150\230\233s",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS2}),("\133\135\180\EM",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("_D5",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("gN\213\255\202\196Gnm\180\&4\184Y\219kI\b\140\223\178\DC1u\248\215\132",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\209\EOT\FS\r\251\165\SO{I\218G\179\214\176\184\150\153\160\235\&0\226\aN",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropServerReference -// "\215F\133\CAN\255\253\132Oss\184>\176@s\156[\209\228\161h\251\235\GSkD",PropTopicAliasMaximum -// 20089,PropSubscriptionIdentifierAvailable 66,PropResponseInformation "#v5\132\197\129",PropResponseInformation -// "\228!3\192\&9\176,\162<\DELXm\203]+\246\205\164\156\180b9\208",PropRetainAvailable 206,PropContentType -// "\236`\219\207\149\219\223\210\FS-\FS\217:\SYN\164\157\&9@\220",PropContentType -// "c\196\&2<,JT\193W\221N\a",PropContentType "\236\248q\fZ3\153\&1\211\&7",PropSubscriptionIdentifierAvailable -// 6,PropTopicAliasMaximum 31885,PropCorrelationData -// "\SI\ETBX\132\212\230\140\163\183rr\SOHMy\212\141\250ZZ\172\241\189\154\&1f\"\141k",PropTopicAlias 2659] + +// SubscribeRequest 21007 [("K\148\168\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("r\233o\161\151.",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("a\216\169\218\&7\t\173\212\208C|\f\221",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\209\136\244\253\211\NAK\191-\a\196\188\224\129\178_\238\170[\218\131$jr\220U\162:",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropAssignedClientIdentifier ")\152\165PL!\SOH\237s\235"] TEST(Subscribe5QCTest, Encode30) { - uint8_t pkt[] = { - 0x82, 0xdc, 0x2, 0x28, 0x8c, 0xa0, 0x1, 0x1c, 0x0, 0x1a, 0xd7, 0x46, 0x85, 0x18, 0xff, 0xfd, 0x84, 0x4f, 0x73, - 0x73, 0xb8, 0x3e, 0xb0, 0x40, 0x73, 0x9c, 0x5b, 0xd1, 0xe4, 0xa1, 0x68, 0xfb, 0xeb, 0x1d, 0x6b, 0x44, 0x22, 0x4e, - 0x79, 0x29, 0x42, 0x1a, 0x0, 0x6, 0x23, 0x76, 0x35, 0x84, 0xc5, 0x81, 0x1a, 0x0, 0x17, 0xe4, 0x21, 0x33, 0xc0, - 0x39, 0xb0, 0x2c, 0xa2, 0x3c, 0x7f, 0x58, 0x6d, 0xcb, 0x5d, 0x2b, 0xf6, 0xcd, 0xa4, 0x9c, 0xb4, 0x62, 0x39, 0xd0, - 0x25, 0xce, 0x3, 0x0, 0x13, 0xec, 0x60, 0xdb, 0xcf, 0x95, 0xdb, 0xdf, 0xd2, 0x1c, 0x2d, 0x1c, 0xd9, 0x3a, 0x16, - 0xa4, 0x9d, 0x39, 0x40, 0xdc, 0x3, 0x0, 0xc, 0x63, 0xc4, 0x32, 0x3c, 0x2c, 0x4a, 0x54, 0xc1, 0x57, 0xdd, 0x4e, - 0x7, 0x3, 0x0, 0xa, 0xec, 0xf8, 0x71, 0xc, 0x5a, 0x33, 0x99, 0x31, 0xd3, 0x37, 0x29, 0x6, 0x22, 0x7c, 0x8d, - 0x9, 0x0, 0x1c, 0xf, 0x17, 0x58, 0x84, 0xd4, 0xe6, 0x8c, 0xa3, 0xb7, 0x72, 0x72, 0x1, 0x4d, 0x79, 0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0x49, 0xda, 0x47, 0xb3, 0xd6, 0xb0, 0xb8, - 0x96, 0x99, 0xa0, 0xeb, 0x30, 0xe2, 0x7, 0x4e, 0x22}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x78, 0x23, 0xb1, 0x7e, 0xeb, 0xcd, 0x5e, 0xd3, 0x65, 0xdd, 0xc6, 0x1f, 0x5f, 0x72, - 0x36, 0xa6, 0x5f, 0x1a, 0xdc, 0xed, 0x49, 0x4c, 0x57, 0xa9, 0xb6, 0x56, 0x81}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x66, 0x76, 0x14, 0x57, 0xb3, 0x17, 0xe8, 0xa, 0xcb}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb7, 0x51, 0xe0, 0x95, 0xc7, 0x48, 0x24, 0x15, 0xb7, 0x1d, 0xa4, 0x82, - 0xdb, 0x20, 0x24, 0x42, 0x82, 0x4a, 0xf7, 0xfa, 0xcd, 0x56, 0xda}; - lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x77, 0x15, 0x7b, 0xe6, 0x3d, 0x12, 0xd5}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2e, 0xf0, 0xd2, 0xa5, 0x92, 0x68, 0xc7, 0xd9, 0x9f, 0x6b, 0x93, - 0xe, 0x2e, 0x9b, 0xf6, 0xf5, 0xe9, 0x2, 0xe5, 0x50, 0xa8, 0xc4}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe2, 0x49, 0x16, 0xf8}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x96, 0xe6, 0xe9, 0x73}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x85, 0x87, 0xb4, 0x19}; - lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x5f, 0x44, 0x35}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x67, 0x4e, 0xd5, 0xff, 0xca, 0xc4, 0x47, 0x6e, 0x6d, 0xb4, 0x34, 0xb8, 0x59, - 0xdb, 0x6b, 0x49, 0x8, 0x8c, 0xdf, 0xb2, 0x11, 0x75, 0xf8, 0xd7, 0x84}; - lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xd1, 0x4, 0x1c, 0xd, 0xfb, 0xa5, 0xe, 0x7b, 0x49, 0xda, 0x47, 0xb3, - 0xd6, 0xb0, 0xb8, 0x96, 0x99, 0xa0, 0xeb, 0x30, 0xe2, 0x7, 0x4e}; - lwmqtt_string_t topic_filter_s10 = {23, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; - uint8_t bytesprops0[] = {0xd7, 0x46, 0x85, 0x18, 0xff, 0xfd, 0x84, 0x4f, 0x73, 0x73, 0xb8, 0x3e, 0xb0, - 0x40, 0x73, 0x9c, 0x5b, 0xd1, 0xe4, 0xa1, 0x68, 0xfb, 0xeb, 0x1d, 0x6b, 0x44}; - uint8_t bytesprops1[] = {0x23, 0x76, 0x35, 0x84, 0xc5, 0x81}; - uint8_t bytesprops2[] = {0xe4, 0x21, 0x33, 0xc0, 0x39, 0xb0, 0x2c, 0xa2, 0x3c, 0x7f, 0x58, 0x6d, - 0xcb, 0x5d, 0x2b, 0xf6, 0xcd, 0xa4, 0x9c, 0xb4, 0x62, 0x39, 0xd0}; - uint8_t bytesprops3[] = {0xec, 0x60, 0xdb, 0xcf, 0x95, 0xdb, 0xdf, 0xd2, 0x1c, 0x2d, - 0x1c, 0xd9, 0x3a, 0x16, 0xa4, 0x9d, 0x39, 0x40, 0xdc}; - uint8_t bytesprops4[] = {0x63, 0xc4, 0x32, 0x3c, 0x2c, 0x4a, 0x54, 0xc1, 0x57, 0xdd, 0x4e, 0x7}; - uint8_t bytesprops5[] = {0xec, 0xf8, 0x71, 0xc, 0x5a, 0x33, 0x99, 0x31, 0xd3, 0x37}; - uint8_t bytesprops6[] = {0xf, 0x17, 0x58, 0x84, 0xd4, 0xe6, 0x8c, 0xa3, 0xb7, 0x72, 0x72, 0x1, 0x4d, 0x79, - 0xd4, 0x8d, 0xfa, 0x5a, 0x5a, 0xac, 0xf1, 0xbd, 0x9a, 0x31, 0x66, 0x22, 0x8d, 0x6b}; - +uint8_t pkt[] = {0x82, 0x4e, 0x52, 0xf, 0xd, 0x12, 0x0, 0xa, 0x29, 0x98, 0xa5, 0x50, 0x4c, 0x21, 0x1, 0xed, 0x73, 0xeb, 0x0, 0x4, 0x4b, 0x94, 0xa8, 0x1, 0x2, 0x0, 0x6, 0x72, 0xe9, 0x6f, 0xa1, 0x97, 0x2e, 0x2a, 0x0, 0xd, 0x61, 0xd8, 0xa9, 0xda, 0x37, 0x9, 0xad, 0xd4, 0xd0, 0x43, 0x7c, 0xc, 0xdd, 0x4, 0x0, 0x1b, 0xd1, 0x88, 0xf4, 0xfd, 0xd3, 0x15, 0xbf, 0x2d, 0x7, 0xc4, 0xbc, 0xe0, 0x81, 0xb2, 0x5f, 0xee, 0xaa, 0x5b, 0xda, 0x83, 0x24, 0x6a, 0x72, 0xdc, 0x55, 0xa2, 0x3a, 0x16}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; +lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x4b, 0x94, 0xa8, 0x1}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; +topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x72, 0xe9, 0x6f, 0xa1, 0x97, 0x2e}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; +topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x61, 0xd8, 0xa9, 0xda, 0x37, 0x9, 0xad, 0xd4, 0xd0, 0x43, 0x7c, 0xc, 0xdd}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; +topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd1, 0x88, 0xf4, 0xfd, 0xd3, 0x15, 0xbf, 0x2d, 0x7, 0xc4, 0xbc, 0xe0, 0x81, 0xb2, 0x5f, 0xee, 0xaa, 0x5b, 0xda, 0x83, 0x24, 0x6a, 0x72, 0xdc, 0x55, 0xa2, 0x3a}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; +topic_filters[3] = topic_filter_s3; +lwmqtt_sub_options_t sub_opts[4]; +sub_opts[0].qos = LWMQTT_QOS2; +sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[0].retain_as_published = false; +sub_opts[0].no_local = false; +sub_opts[1].qos = LWMQTT_QOS2; +sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; +sub_opts[1].retain_as_published = true; +sub_opts[1].no_local = false; +sub_opts[2].qos = LWMQTT_QOS0; +sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; +sub_opts[2].retain_as_published = false; +sub_opts[2].no_local = true; +sub_opts[3].qos = LWMQTT_QOS2; +sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; +sub_opts[3].retain_as_published = false; +sub_opts[3].no_local = true; + uint8_t bytesprops0[] = {0x29, 0x98, 0xa5, 0x50, 0x4c, 0x21, 0x1, 0xed, 0x73, 0xeb}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20089}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31885}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2659}}, - }; - - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10380, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21007, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); + } -// SubscribeResponse 18259 [Right QoS0,Left SubErrNotAuthorized,Left SubErrWildcardSubscriptionsNotSupported] [] + +// SubscribeResponse 6377 [Right QoS0,Right QoS0,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0] [] TEST(SubACK311QCTest, Decode1) { - uint8_t pkt[] = {0x90, 0x5, 0x47, 0x53, 0x0, 0x87, 0xa2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18259); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); -} +uint8_t pkt[] = {0x90, 0x7, 0x18, 0xe9, 0x0, 0x0, 0x1, 0xa1, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 6377); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[3], 0x80); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); -// SubscribeResponse 23769 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Right QoS1,Left -// SubErrUnspecifiedError,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] [] -TEST(SubACK311QCTest, Decode2) { - uint8_t pkt[] = {0x90, 0x8, 0x5c, 0xd9, 0xa1, 0x0, 0x1, 0x80, 0x1, 0xa2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 23769); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x80); } -// SubscribeResponse 32439 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS2] [] + +// SubscribeResponse 22342 [Left SubErrQuotaExceeded,Right QoS2,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS1,Right QoS0] [] +TEST(SubACK311QCTest, Decode2) { +uint8_t pkt[] = {0x90, 0xd, 0x57, 0x46, 0x97, 0x2, 0xa1, 0x9e, 0x1, 0x8f, 0x0, 0x91, 0x0, 0x1, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[11]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 11, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 22342); +EXPECT_EQ(count, 11); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], 0x80); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[5], 0x80); +EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[7], 0x80); +EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); + +} + + +// SubscribeResponse 20403 [Left SubErrImplementationSpecificError,Left SubErrNotAuthorized,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [] TEST(SubACK311QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0x5, 0x7e, 0xb7, 0xa1, 0x1, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32439); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); +uint8_t pkt[] = {0x90, 0x6, 0x4f, 0xb3, 0x83, 0x87, 0xa1, 0x1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[4]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 4, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 20403); +EXPECT_EQ(count, 4); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], 0x80); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + } -// SubscribeResponse 4983 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Right -// QoS2,Right QoS2,Right QoS1] [] + +// SubscribeResponse 8789 [Left SubErrUnspecifiedError,Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0xb, 0x13, 0x77, 0x9e, 0x97, 0xa1, 0x2, 0x0, 0xa1, 0x2, 0x2, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4983); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); -} - -// SubscribeResponse 13883 [Right QoS0,Left SubErrPacketIdentifierInUse,Left SubErrPacketIdentifierInUse,Right -// QoS0,Right QoS0,Left SubErrUnspecifiedError,Right QoS0] [] -TEST(SubACK311QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0x9, 0x36, 0x3b, 0x0, 0x91, 0x91, 0x0, 0x0, 0x80, 0x0}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13883); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); -} - -// SubscribeResponse 7030 [Right QoS0] [] -TEST(SubACK311QCTest, Decode6) { - uint8_t pkt[] = {0x90, 0x3, 0x1b, 0x76, 0x0}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7030); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +uint8_t pkt[] = {0x90, 0x7, 0x22, 0x55, 0x80, 0x9e, 0x97, 0x1, 0xa2}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 8789); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], 0x80); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[4], 0x80); + } -// SubscribeResponse 27738 [Right QoS0,Right QoS2] [] + +// SubscribeResponse 2708 [Right QoS1,Right QoS2,Right QoS0,Right QoS0,Left SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS1,Right QoS0,Right QoS1] [] +TEST(SubACK311QCTest, Decode5) { +uint8_t pkt[] = {0x90, 0xd, 0xa, 0x94, 0x1, 0x2, 0x0, 0x0, 0x8f, 0xa2, 0x2, 0x1, 0x1, 0x0, 0x1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[11]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 11, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 2708); +EXPECT_EQ(count, 11); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[4], 0x80); +EXPECT_EQ(granted_qos_levels[5], 0x80); +EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS1); + +} + + +// SubscribeResponse 12793 [Left SubErrTopicFilterInvalid,Right QoS0,Right QoS0,Right QoS2,Left SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [] +TEST(SubACK311QCTest, Decode6) { +uint8_t pkt[] = {0x90, 0xa, 0x31, 0xf9, 0x8f, 0x0, 0x0, 0x2, 0x8f, 0xa2, 0x1, 0xa1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[8]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 8, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 12793); +EXPECT_EQ(count, 8); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[4], 0x80); +EXPECT_EQ(granted_qos_levels[5], 0x80); +EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[7], 0x80); + +} + + +// SubscribeResponse 16851 [Left SubErrNotAuthorized] [] TEST(SubACK311QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0x4, 0x6c, 0x5a, 0x0, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27738); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +uint8_t pkt[] = {0x90, 0x3, 0x41, 0xd3, 0x87}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[1]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 16851); +EXPECT_EQ(count, 1); +EXPECT_EQ(granted_qos_levels[0], 0x80); + } -// SubscribeResponse 4324 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS0,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrSharedSubscriptionsNotSupported] [] + +// SubscribeResponse 23680 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Left SubErrUnspecifiedError,Right QoS2,Right QoS2,Right QoS2,Right QoS1,Right QoS0,Right QoS0,Left SubErrImplementationSpecificError,Left SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode8) { - uint8_t pkt[] = {0x90, 0x9, 0x10, 0xe4, 0x9e, 0x0, 0x0, 0x0, 0x9e, 0xa2, 0x9e}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4324); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); -} - -// SubscribeResponse 11281 [Left SubErrImplementationSpecificError,Right QoS1,Left -// SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded] [] +uint8_t pkt[] = {0x90, 0xd, 0x5c, 0x80, 0xa1, 0x8f, 0x80, 0x2, 0x2, 0x2, 0x1, 0x0, 0x0, 0x83, 0x8f}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[11]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 11, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 23680); +EXPECT_EQ(count, 11); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], 0x80); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[9], 0x80); +EXPECT_EQ(granted_qos_levels[10], 0x80); + +} + + +// SubscribeResponse 7955 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrImplementationSpecificError,Right QoS2,Right QoS2,Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError,Left SubErrNotAuthorized] [] TEST(SubACK311QCTest, Decode9) { - uint8_t pkt[] = {0x90, 0x6, 0x2c, 0x11, 0x83, 0x1, 0xa1, 0x97}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11281); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); -} - -// SubscribeResponse 462 [Right QoS2,Right QoS2] [] +uint8_t pkt[] = {0x90, 0xa, 0x1f, 0x13, 0x1, 0xa1, 0x83, 0x2, 0x2, 0x97, 0x83, 0x87}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[8]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 8, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 7955); +EXPECT_EQ(count, 8); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[1], 0x80); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[5], 0x80); +EXPECT_EQ(granted_qos_levels[6], 0x80); +EXPECT_EQ(granted_qos_levels[7], 0x80); + +} + + +// SubscribeResponse 29704 [Right QoS2,Right QoS0,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS2] [] TEST(SubACK311QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0x4, 0x1, 0xce, 0x2, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 462); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -} - -// SubscribeResponse 28404 [Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Left -// SubErrSubscriptionIdentifiersNotSupported] [] +uint8_t pkt[] = {0x90, 0xb, 0x74, 0x8, 0x2, 0x0, 0x1, 0x9e, 0xa1, 0x0, 0x9e, 0x0, 0x2}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[9]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 9, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 29704); +EXPECT_EQ(count, 9); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[3], 0x80); +EXPECT_EQ(granted_qos_levels[4], 0x80); +EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[6], 0x80); +EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + +} + + +// SubscribeResponse 251 [Left SubErrNotAuthorized,Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded,Right QoS2,Right QoS2] [] TEST(SubACK311QCTest, Decode11) { - uint8_t pkt[] = {0x90, 0x5, 0x6e, 0xf4, 0x8f, 0x83, 0xa1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 28404); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); -} - -// SubscribeResponse 12402 [Right QoS0] [] +uint8_t pkt[] = {0x90, 0x9, 0x0, 0xfb, 0x87, 0x87, 0x80, 0x91, 0x97, 0x2, 0x2}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[7]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 7, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 251); +EXPECT_EQ(count, 7); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], 0x80); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], 0x80); +EXPECT_EQ(granted_qos_levels[4], 0x80); +EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + +} + + +// SubscribeResponse 4144 [Right QoS2] [] TEST(SubACK311QCTest, Decode12) { - uint8_t pkt[] = {0x90, 0x3, 0x30, 0x72, 0x0}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12402); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +uint8_t pkt[] = {0x90, 0x3, 0x10, 0x30, 0x2}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[1]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 4144); +EXPECT_EQ(count, 1); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + } -// SubscribeResponse 4531 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS1,Right QoS0,Right -// QoS1,Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrNotAuthorized,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [] + +// SubscribeResponse 22442 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS0] [] TEST(SubACK311QCTest, Decode13) { - uint8_t pkt[] = {0x90, 0xc, 0x11, 0xb3, 0xa1, 0x2, 0x1, 0x0, 0x1, 0x91, 0x2, 0x87, 0xa1, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4531); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); -} - -// SubscribeResponse 28870 [Right QoS2,Right QoS0,Left SubErrPacketIdentifierInUse,Right QoS1] [] +uint8_t pkt[] = {0x90, 0x4, 0x57, 0xaa, 0xa2, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[2]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 2, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 22442); +EXPECT_EQ(count, 2); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + +} + + +// SubscribeResponse 5149 [Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS2,Right QoS2,Left SubErrImplementationSpecificError] [] TEST(SubACK311QCTest, Decode14) { - uint8_t pkt[] = {0x90, 0x6, 0x70, 0xc6, 0x2, 0x0, 0x91, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 28870); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); +uint8_t pkt[] = {0x90, 0x8, 0x14, 0x1d, 0x91, 0x0, 0x2, 0x2, 0x2, 0x83}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 5149); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[5], 0x80); + } -// SubscribeResponse 1085 [Right QoS0,Right QoS0,Left SubErrImplementationSpecificError,Left -// SubErrSubscriptionIdentifiersNotSupported] [] + +// SubscribeResponse 27317 [Left SubErrPacketIdentifierInUse,Left SubErrTopicFilterInvalid,Right QoS2,Right QoS0,Right QoS0,Right QoS2] [] TEST(SubACK311QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0x6, 0x4, 0x3d, 0x0, 0x0, 0x83, 0xa1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1085); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); +uint8_t pkt[] = {0x90, 0x8, 0x6a, 0xb5, 0x91, 0x8f, 0x2, 0x0, 0x0, 0x2}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 27317); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], 0x80); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + } -// SubscribeResponse 11089 [Right QoS1] [] + +// SubscribeResponse 30611 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS0,Right QoS2,Right QoS1] [] TEST(SubACK311QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0x3, 0x2b, 0x51, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11089); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); +uint8_t pkt[] = {0x90, 0x7, 0x77, 0x93, 0xa1, 0x2, 0x0, 0x2, 0x1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 30611); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + } -// SubscribeResponse 4816 [Left SubErrQuotaExceeded,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right -// QoS0,Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right QoS1,Left SubErrNotAuthorized,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported] [] + +// SubscribeResponse 14554 [Right QoS0,Right QoS2,Left SubErrUnspecifiedError,Right QoS0] [] TEST(SubACK311QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0xd, 0x12, 0xd0, 0x97, 0xa2, 0x2, 0x0, 0x1, 0x0, 0x87, 0x1, 0x87, 0x9e, 0xa2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4816); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], 0x80); - EXPECT_EQ(granted_qos_levels[10], 0x80); -} - -// SubscribeResponse 24891 [Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1,Right QoS2,Left -// SubErrTopicFilterInvalid,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [] +uint8_t pkt[] = {0x90, 0x6, 0x38, 0xda, 0x0, 0x2, 0x80, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[4]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 4, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 14554); +EXPECT_EQ(count, 4); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + +} + + +// SubscribeResponse 22626 [Right QoS2,Right QoS1,Left SubErrImplementationSpecificError,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode18) { - uint8_t pkt[] = {0x90, 0xb, 0x61, 0x3b, 0x80, 0x91, 0x9e, 0xa2, 0x1, 0x2, 0x8f, 0x1, 0xa1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24891); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0x80); -} - -// SubscribeResponse 22923 [Right QoS2,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS1] [] +uint8_t pkt[] = {0x90, 0x8, 0x58, 0x62, 0x2, 0x1, 0x83, 0x2, 0x2, 0x9e}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 22626); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[5], 0x80); + +} + + +// SubscribeResponse 22779 [Right QoS0] [] TEST(SubACK311QCTest, Decode19) { - uint8_t pkt[] = {0x90, 0xb, 0x59, 0x8b, 0x2, 0x1, 0xa1, 0x0, 0xa2, 0x2, 0x2, 0x8f, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 22923); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); -} - -// SubscribeResponse 25337 [Right QoS2,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS1,Right QoS2,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported] [] +uint8_t pkt[] = {0x90, 0x3, 0x58, 0xfb, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[1]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 22779); +EXPECT_EQ(count, 1); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + +} + + +// SubscribeResponse 12719 [Left SubErrNotAuthorized,Right QoS0] [] TEST(SubACK311QCTest, Decode20) { - uint8_t pkt[] = {0x90, 0x9, 0x62, 0xf9, 0x2, 0x1, 0x8f, 0x1, 0x2, 0x0, 0x9e}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25337); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x80); -} - -// SubscribeResponse 1262 [Left SubErrPacketIdentifierInUse,Right QoS0,Left SubErrPacketIdentifierInUse,Left -// SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Right QoS0,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrNotAuthorized,Right QoS2] [] +uint8_t pkt[] = {0x90, 0x4, 0x31, 0xaf, 0x87, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[2]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 2, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 12719); +EXPECT_EQ(count, 2); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + +} + + +// SubscribeResponse 18524 [Right QoS2] [] TEST(SubACK311QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0xc, 0x4, 0xee, 0x91, 0x0, 0x91, 0x83, 0x83, 0x0, 0x0, 0x9e, 0x87, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1262); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); -} - -// SubscribeResponse 21462 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right -// QoS1,Right QoS2,Right QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrTopicFilterInvalid,Left -// SubErrImplementationSpecificError,Right QoS2,Left SubErrNotAuthorized] [] +uint8_t pkt[] = {0x90, 0x3, 0x48, 0x5c, 0x2}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[1]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 18524); +EXPECT_EQ(count, 1); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + +} + + +// SubscribeResponse 12697 [Left SubErrPacketIdentifierInUse,Left SubErrPacketIdentifierInUse,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrNotAuthorized] [] TEST(SubACK311QCTest, Decode22) { - uint8_t pkt[] = {0x90, 0xd, 0x53, 0xd6, 0x2, 0xa2, 0x97, 0x1, 0x2, 0x0, 0x9e, 0x8f, 0x83, 0x2, 0x87}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21462); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[10], 0x80); -} - -// SubscribeResponse 12076 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrImplementationSpecificError,Right -// QoS2,Right QoS0,Right QoS2] [] +uint8_t pkt[] = {0x90, 0x8, 0x31, 0x99, 0x91, 0x91, 0xa2, 0x9e, 0xa1, 0x87}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 12697); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], 0x80); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], 0x80); +EXPECT_EQ(granted_qos_levels[4], 0x80); +EXPECT_EQ(granted_qos_levels[5], 0x80); + +} + + +// SubscribeResponse 1694 [Left SubErrSubscriptionIdentifiersNotSupported] [] TEST(SubACK311QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0x7, 0x2f, 0x2c, 0xa1, 0x83, 0x2, 0x0, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12076); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); -} - -// SubscribeResponse 3799 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrImplementationSpecificError,Left SubErrTopicFilterInvalid,Right QoS2,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS0] [] +uint8_t pkt[] = {0x90, 0x3, 0x6, 0x9e, 0xa1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[1]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 1694); +EXPECT_EQ(count, 1); +EXPECT_EQ(granted_qos_levels[0], 0x80); + +} + + +// SubscribeResponse 30899 [Right QoS1] [] TEST(SubACK311QCTest, Decode24) { - uint8_t pkt[] = {0x90, 0xa, 0xe, 0xd7, 0x2, 0xa2, 0x83, 0x8f, 0x2, 0xa2, 0x2, 0x0}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3799); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); -} - -// SubscribeResponse 15314 [Left SubErrUnspecifiedError,Left SubErrTopicFilterInvalid,Left -// SubErrImplementationSpecificError] [] +uint8_t pkt[] = {0x90, 0x3, 0x78, 0xb3, 0x1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[1]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 30899); +EXPECT_EQ(count, 1); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + +} + + +// SubscribeResponse 15 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS2] [] TEST(SubACK311QCTest, Decode25) { - uint8_t pkt[] = {0x90, 0x5, 0x3b, 0xd2, 0x80, 0x8f, 0x83}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15314); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); +uint8_t pkt[] = {0x90, 0x8, 0x0, 0xf, 0xa1, 0x2, 0x2, 0x9e, 0x0, 0x2}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 15); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[3], 0x80); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + } -// SubscribeResponse 19515 [Left SubErrNotAuthorized,Right QoS1,Right QoS2,Left SubErrPacketIdentifierInUse,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Left SubErrUnspecifiedError,Left -// SubErrSubscriptionIdentifiersNotSupported] [] + +// SubscribeResponse 13923 [Right QoS2,Left SubErrNotAuthorized,Right QoS1,Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded] [] TEST(SubACK311QCTest, Decode26) { - uint8_t pkt[] = {0x90, 0xb, 0x4c, 0x3b, 0x87, 0x1, 0x2, 0x91, 0x9e, 0x80, 0x0, 0x80, 0xa1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19515); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); -} - -// SubscribeResponse 14835 [Right QoS2,Right QoS2,Right QoS1,Left SubErrUnspecifiedError,Left -// SubErrImplementationSpecificError,Left SubErrNotAuthorized,Right QoS2] [] +uint8_t pkt[] = {0x90, 0x7, 0x36, 0x63, 0x2, 0x87, 0x1, 0x91, 0x97}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 13923); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[1], 0x80); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[3], 0x80); +EXPECT_EQ(granted_qos_levels[4], 0x80); + +} + + +// SubscribeResponse 6677 [Right QoS0,Right QoS1,Left SubErrImplementationSpecificError,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError] [] TEST(SubACK311QCTest, Decode27) { - uint8_t pkt[] = {0x90, 0x9, 0x39, 0xf3, 0x2, 0x2, 0x1, 0x80, 0x83, 0x87, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14835); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); -} - -// SubscribeResponse 3036 [Right QoS0,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError] [] +uint8_t pkt[] = {0x90, 0xd, 0x1a, 0x15, 0x0, 0x1, 0x83, 0x1, 0x91, 0x0, 0x2, 0x2, 0x9e, 0x1, 0x83}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[11]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 11, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 6677); +EXPECT_EQ(count, 11); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[4], 0x80); +EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[8], 0x80); +EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[10], 0x80); + +} + + +// SubscribeResponse 12919 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported] [] TEST(SubACK311QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0x5, 0xb, 0xdc, 0x0, 0x87, 0x83}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3036); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); +uint8_t pkt[] = {0x90, 0x7, 0x32, 0x77, 0x2, 0x91, 0x1, 0x0, 0xa1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 12919); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[1], 0x80); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[4], 0x80); + } -// SubscribeResponse 8613 [Right QoS2] [] + +// SubscribeResponse 20520 [Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right QoS0,Left SubErrImplementationSpecificError] [] TEST(SubACK311QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0x3, 0x21, 0xa5, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8613); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); +uint8_t pkt[] = {0x90, 0x7, 0x50, 0x28, 0x1, 0x0, 0x87, 0x0, 0x83}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 20520); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[4], 0x80); + } -// SubscribeResponse 14512 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right QoS1,Left -// SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded] [] + +// SubscribeResponse 2699 [Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded,Left SubErrQuotaExceeded,Right QoS1,Right QoS0,Left SubErrQuotaExceeded] [] TEST(SubACK311QCTest, Decode30) { - uint8_t pkt[] = {0x90, 0x7, 0x38, 0xb0, 0x9e, 0x91, 0x1, 0xa2, 0x97}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14512); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); -} - -// SubscribeResponse 18259 [Right QoS0,Left SubErrNotAuthorized,Left SubErrWildcardSubscriptionsNotSupported] -// [PropContentType "\190r\158\201\DC4U\EM\193\&6",PropMessageExpiryInterval 16837,PropPayloadFormatIndicator -// 207,PropReasonString "HB\185\&6\128\NUL\165[\130g(\n\186q7SV&i4\DLE\224ZYn\134\&5",PropRequestProblemInformation -// 131,PropSubscriptionIdentifier 14,PropRequestProblemInformation 176,PropWildcardSubscriptionAvailable -// 245,PropContentType "\149\146%\140h\248\156@Ts\233\t",PropAuthenticationMethod -// "<\207\202D\134\132\148v\215\164\nw\139U\222!\ESC\255HN\235\241\197[\237c",PropSubscriptionIdentifierAvailable -// 117,PropSharedSubscriptionAvailable 155,PropSessionExpiryInterval 24344,PropSharedSubscriptionAvailable -// 210,PropServerReference -// "\201\SO\215/\225C\DC4\SO\SI1\226h\196\142\201:\137\241\235S1L",PropServerKeepAlive 25850,PropRequestProblemInformation 60,PropAuthenticationMethod "\230\241\255QY-\t\214\EOTR#CsI\246\140\158T\140\235\186\DC4\CAN\n<\ACK",PropResponseInformation "n\223/\ETX({\SO\v\203\"\189\234Bi1\239\STX",PropMessageExpiryInterval 13351,PropReasonString "\181\239D\145%\195.n\163P)\199\142\205\206\246P\STX\204B\246\222\169\219",PropWillDelayInterval 28861,PropReasonString "(\SI\239\225\129\231>\136r\214.\190",PropSubscriptionIdentifierAvailable 235,PropMessageExpiryInterval 16397,PropResponseTopic "\US\NAK\163\143",PropAuthenticationMethod "yx6%\165|\156\129\215\DLE\FSe\208|\128\146C\198",PropMaximumQoS 172] TEST(SubACK5QCTest, Decode1) { - uint8_t pkt[] = {0x90, 0xf9, 0x1, 0x47, 0x53, 0xf2, 0x1, 0x3, 0x0, 0x9, 0xbe, 0x72, 0x9e, 0xc9, 0x14, 0x55, 0x19, - 0xc1, 0x36, 0x2, 0x0, 0x0, 0x41, 0xc5, 0x1, 0xcf, 0x1f, 0x0, 0x1b, 0x48, 0x42, 0xb9, 0x36, 0x80, - 0x0, 0xa5, 0x5b, 0x82, 0x67, 0x28, 0xa, 0xba, 0x71, 0x37, 0x53, 0x56, 0x26, 0x69, 0x34, 0x10, 0xe0, - 0x5a, 0x59, 0x6e, 0x86, 0x35, 0x17, 0x83, 0xb, 0xe, 0x17, 0xb0, 0x28, 0xf5, 0x3, 0x0, 0xc, 0x95, - 0x92, 0x25, 0x8c, 0x68, 0xf8, 0x9c, 0x40, 0x54, 0x73, 0xe9, 0x9, 0x15, 0x0, 0x1a, 0x3c, 0xcf, 0xca, - 0x44, 0x86, 0x84, 0x94, 0x76, 0xd7, 0xa4, 0xa, 0x77, 0x8b, 0x55, 0xde, 0x21, 0x1b, 0xff, 0x48, 0x4e, - 0xeb, 0xf1, 0xc5, 0x5b, 0xed, 0x63, 0x29, 0x75, 0x2a, 0x9b, 0x11, 0x0, 0x0, 0x5f, 0x18, 0x2a, 0xd2, - 0x1c, 0x0, 0x18, 0xc9, 0xe, 0xd7, 0x2f, 0xe1, 0x43, 0x14, 0xe, 0xf, 0x31, 0xe2, 0x68, 0xc4, 0x8e, - 0xc9, 0x3a, 0x89, 0xf1, 0x3c, 0x50, 0xf9, 0xf9, 0x83, 0xb1, 0x18, 0x0, 0x0, 0x3, 0x5e, 0x1c, 0x0, - 0x19, 0xa3, 0xb, 0x1e, 0x9, 0x69, 0x53, 0xb6, 0x8a, 0x4c, 0x84, 0xec, 0x65, 0xa8, 0x21, 0x69, 0xb1, - 0xca, 0x83, 0x5f, 0x33, 0xf3, 0x6b, 0x23, 0xd8, 0x40, 0x1c, 0x0, 0x10, 0x94, 0x19, 0x18, 0xab, 0x96, - 0x7b, 0x2e, 0xd1, 0xc5, 0x9b, 0x4e, 0xee, 0xe4, 0x24, 0x2a, 0xa4, 0x1, 0x43, 0x18, 0x0, 0x0, 0x5d, - 0x6b, 0x29, 0x13, 0x1f, 0x0, 0x1b, 0xde, 0x35, 0xbb, 0x8f, 0xea, 0x6d, 0xe4, 0x88, 0x5, 0xfa, 0x84, - 0x49, 0x68, 0xa4, 0xb4, 0x8b, 0x27, 0xb1, 0x8b, 0xcc, 0x73, 0x8, 0xa7, 0x38, 0x67, 0x18, 0xb9, 0x3, - 0x0, 0x4, 0x91, 0xb7, 0x86, 0xee, 0x1, 0x41, 0x21, 0x54, 0x96, 0x0, 0x87, 0xa2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18259); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x87); - EXPECT_EQ(granted_qos_levels[2], 0xA2); -} - -// SubscribeResponse 23769 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Right QoS1,Left -// SubErrUnspecifiedError,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] [PropReceiveMaximum -// 18275,PropWillDelayInterval 20990,PropMessageExpiryInterval 29874,PropReasonString -// "\189n\231\162\244",PropRetainAvailable 56,PropSharedSubscriptionAvailable 115,PropServerReference -// "\169\205\173?TAE@\255\166\216\206O",PropMessageExpiryInterval 5892,PropReceiveMaximum 15408,PropAuthenticationMethod -// "\187%\245\191B\196\189F>\162\&7^,\193\201"] +uint8_t pkt[] = {0x90, 0xad, 0x2, 0x18, 0xe9, 0xa4, 0x2, 0x18, 0x0, 0x0, 0x54, 0x30, 0x28, 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0xb, 0xcb, 0x22, 0xbd, 0xea, 0x42, 0x69, 0x31, 0xef, 0x2, 0x2, 0x0, 0x0, 0x34, 0x27, 0x1f, 0x0, 0x18, 0xb5, 0xef, 0x44, 0x91, 0x25, 0xc3, 0x2e, 0x6e, 0xa3, 0x50, 0x29, 0xc7, 0x8e, 0xcd, 0xce, 0xf6, 0x50, 0x2, 0xcc, 0x42, 0xf6, 0xde, 0xa9, 0xdb, 0x18, 0x0, 0x0, 0x70, 0xbd, 0x1f, 0x0, 0xc, 0x28, 0xf, 0xef, 0xe1, 0x81, 0xe7, 0x3e, 0x88, 0x72, 0xd6, 0x2e, 0xbe, 0x29, 0xeb, 0x2, 0x0, 0x0, 0x40, 0xd, 0x8, 0x0, 0x4, 0x1f, 0x15, 0xa3, 0x8f, 0x15, 0x0, 0x12, 0x79, 0x78, 0x36, 0x25, 0xa5, 0x7c, 0x9c, 0x81, 0xd7, 0x10, 0x1c, 0x65, 0xd0, 0x7c, 0x80, 0x92, 0x43, 0xc6, 0x24, 0xac, 0x0, 0x0, 0x1, 0xa1, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 6377); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[3], 0xA1); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + +} + + +// SubscribeResponse 22342 [Left SubErrQuotaExceeded,Right QoS2,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS1,Right QoS0] [PropRetainAvailable 40,PropMessageExpiryInterval 30950,PropServerKeepAlive 31863,PropResponseTopic "\222x\188\&6!\172\253\138\155%\239(l8\147#\175\&4\195*\155l\240",PropAssignedClientIdentifier "\164w\200(\168Z\134\186\138\&1\254>\236\234\212E\151\215\144\142",PropPayloadFormatIndicator 49,PropUserProperty "f\250\132\NUL\229q\185\172 \132" "$\US",PropReasonString "*!\201\223\197s\135\213k\156\190\186H\SUB\164o\242\&2\ACK\221\SOH[U}\183\179\232\239\172",PropSessionExpiryInterval 12524,PropResponseInformation "\224\155\178\155\234f",PropTopicAlias 25820,PropMessageExpiryInterval 11088,PropUserProperty "\173!\US\234\f#j32" "\GSJ+I\189]\206\240\160\156D"] TEST(SubACK5QCTest, Decode2) { - uint8_t pkt[] = {0x90, 0x4c, 0x5c, 0xd9, 0x43, 0x21, 0x47, 0x63, 0x18, 0x0, 0x0, 0x51, 0xfe, 0x2, 0x0, 0x0, - 0x74, 0xb2, 0x1f, 0x0, 0x5, 0xbd, 0x6e, 0xe7, 0xa2, 0xf4, 0x25, 0x38, 0x2a, 0x73, 0x1c, 0x0, - 0xd, 0xa9, 0xcd, 0xad, 0x3f, 0x54, 0x41, 0x45, 0x40, 0xff, 0xa6, 0xd8, 0xce, 0x4f, 0x2, 0x0, - 0x0, 0x17, 0x4, 0x21, 0x3c, 0x30, 0x15, 0x0, 0xf, 0xbb, 0x25, 0xf5, 0xbf, 0x42, 0xc4, 0xbd, - 0x46, 0x3e, 0xa2, 0x37, 0x5e, 0x2c, 0xc1, 0xc9, 0xa1, 0x0, 0x1, 0x80, 0x1, 0xa2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 23769); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], 0xA1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0xA2); -} - -// SubscribeResponse 32439 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS2] -// [PropPayloadFormatIndicator 200,PropPayloadFormatIndicator 41,PropAuthenticationMethod -// "[D\143\DC2P\189\&2^",PropMessageExpiryInterval 11314,PropTopicAliasMaximum 29329,PropAssignedClientIdentifier -// "\GS\DEL\140\&8\140u\232\188\DC3u-1\ESC\200\181\NAK\a\246D\188%\242\191\179\189\175\209\210",PropSubscriptionIdentifier -// 13,PropServerReference "~l",PropAssignedClientIdentifier "\215\152\222\249Ru\193",PropRequestProblemInformation -// 22,PropTopicAlias 26497,PropMaximumQoS 118,PropMaximumPacketSize 16077,PropWillDelayInterval -// 31249,PropWillDelayInterval 29824,PropAuthenticationData "\237\236\224\DELvE\147!",PropContentType -// "^oe\164\131\243\246\164\162\203\218\229g\193\222h\f",PropServerReference "\169\141\240\189\167",PropServerReference -// "]%aq}\134a\176\192F\252\GS\CAN\236\176u\254\196",PropTopicAlias 10763,PropRequestResponseInformation 121] +uint8_t pkt[] = {0x90, 0xac, 0x1, 0x57, 0x46, 0x9d, 0x1, 0x25, 0x28, 0x2, 0x0, 0x0, 0x78, 0xe6, 0x13, 0x7c, 0x77, 0x8, 0x0, 0x17, 0xde, 0x78, 0xbc, 0x36, 0x21, 0xac, 0xfd, 0x8a, 0x9b, 0x25, 0xef, 0x28, 0x6c, 0x38, 0x93, 0x23, 0xaf, 0x34, 0xc3, 0x2a, 0x9b, 0x6c, 0xf0, 0x12, 0x0, 0x14, 0xa4, 0x77, 0xc8, 0x28, 0xa8, 0x5a, 0x86, 0xba, 0x8a, 0x31, 0xfe, 0x3e, 0xec, 0xea, 0xd4, 0x45, 0x97, 0xd7, 0x90, 0x8e, 0x1, 0x31, 0x26, 0x0, 0xa, 0x66, 0xfa, 0x84, 0x0, 0xe5, 0x71, 0xb9, 0xac, 0x20, 0x84, 0x0, 0x2, 0x24, 0x1f, 0x1f, 0x0, 0x1d, 0x2a, 0x21, 0xc9, 0xdf, 0xc5, 0x73, 0x87, 0xd5, 0x6b, 0x9c, 0xbe, 0xba, 0x48, 0x1a, 0xa4, 0x6f, 0xf2, 0x32, 0x6, 0xdd, 0x1, 0x5b, 0x55, 0x7d, 0xb7, 0xb3, 0xe8, 0xef, 0xac, 0x11, 0x0, 0x0, 0x30, 0xec, 0x1a, 0x0, 0x6, 0xe0, 0x9b, 0xb2, 0x9b, 0xea, 0x66, 0x23, 0x64, 0xdc, 0x2, 0x0, 0x0, 0x2b, 0x50, 0x26, 0x0, 0x9, 0xad, 0x21, 0x1f, 0xea, 0xc, 0x23, 0x6a, 0x33, 0x32, 0x0, 0xb, 0x1d, 0x4a, 0x2b, 0x49, 0xbd, 0x5d, 0xce, 0xf0, 0xa0, 0x9c, 0x44, 0x97, 0x2, 0xa1, 0x9e, 0x1, 0x8f, 0x0, 0x91, 0x0, 0x1, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[11]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 11, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 22342); +EXPECT_EQ(count, 11); +EXPECT_EQ(granted_qos_levels[0], 0x97); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[2], 0xA1); +EXPECT_EQ(granted_qos_levels[3], 0x9E); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[5], 0x8F); +EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[7], 0x91); +EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); + +} + + +// SubscribeResponse 20403 [Left SubErrImplementationSpecificError,Left SubErrNotAuthorized,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [PropSharedSubscriptionAvailable 232,PropRequestProblemInformation 75,PropResponseInformation "\201\208\FS0\215\215~\DC1\141\142^\214s\202z\245rb\246\240//",PropReceiveMaximum 32008,PropSubscriptionIdentifierAvailable 248,PropReasonString "]\205Ugu\148\255i\230\195C\240",PropCorrelationData "\132'\nD\vRv\141\&1\224\220\233;\145\&1eJI\164\225\144\148\230\131\231\&7",PropUserProperty "\160\213\RS-S\171\171W\241\206\239\137\ENQ\b\229\&8\229r\182\ESC+\157\\\148m5\227@g\142" "\STX?nttV\255C<%\SUB\135\225\237",PropAuthenticationMethod "\SUB\223\177\189x\208\194\164\&1f_\ETB3\168VOx\157\172",PropReceiveMaximum 9817,PropSubscriptionIdentifierAvailable 127,PropAuthenticationMethod "\253e\EMx+\147K+u\RSQU\173\194\145x7d+(\241\152\CANmk\NUL\179",PropMaximumQoS 70,PropSessionExpiryInterval 14477,PropAssignedClientIdentifier "Y\141\ENQ\251\160\244f\154\&8yv\174\177\DEL/\202\"\189\143\185J",PropPayloadFormatIndicator 111,PropMessageExpiryInterval 21491,PropRequestProblemInformation 109,PropSessionExpiryInterval 24691,PropCorrelationData "",PropMaximumPacketSize 10757,PropContentType "",PropWildcardSubscriptionAvailable 136] TEST(SubACK5QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0xa5, 0x1, 0x7e, 0xb7, 0x9e, 0x1, 0x1, 0xc8, 0x1, 0x29, 0x15, 0x0, 0x8, 0x5b, 0x44, 0x8f, - 0x12, 0x50, 0xbd, 0x32, 0x5e, 0x2, 0x0, 0x0, 0x2c, 0x32, 0x22, 0x72, 0x91, 0x12, 0x0, 0x1c, 0x1d, - 0x7f, 0x8c, 0x38, 0x8c, 0x75, 0xe8, 0xbc, 0x13, 0x75, 0x2d, 0x31, 0x1b, 0xc8, 0xb5, 0x15, 0x7, 0xf6, - 0x44, 0xbc, 0x25, 0xf2, 0xbf, 0xb3, 0xbd, 0xaf, 0xd1, 0xd2, 0xb, 0xd, 0x1c, 0x0, 0x2, 0x7e, 0x6c, - 0x12, 0x0, 0x7, 0xd7, 0x98, 0xde, 0xf9, 0x52, 0x75, 0xc1, 0x17, 0x16, 0x23, 0x67, 0x81, 0x24, 0x76, - 0x27, 0x0, 0x0, 0x3e, 0xcd, 0x18, 0x0, 0x0, 0x7a, 0x11, 0x18, 0x0, 0x0, 0x74, 0x80, 0x16, 0x0, - 0x8, 0xed, 0xec, 0xe0, 0x7f, 0x76, 0x45, 0x93, 0x21, 0x3, 0x0, 0x11, 0x5e, 0x6f, 0x65, 0xa4, 0x83, - 0xf3, 0xf6, 0xa4, 0xa2, 0xcb, 0xda, 0xe5, 0x67, 0xc1, 0xde, 0x68, 0xc, 0x1c, 0x0, 0x5, 0xa9, 0x8d, - 0xf0, 0xbd, 0xa7, 0x1c, 0x0, 0x12, 0x5d, 0x25, 0x61, 0x71, 0x7d, 0x86, 0x61, 0xb0, 0xc0, 0x46, 0xfc, - 0x1d, 0x18, 0xec, 0xb0, 0x75, 0xfe, 0xc4, 0x23, 0x2a, 0xb, 0x19, 0x79, 0xa1, 0x1, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32439); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0xA1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); -} - -// SubscribeResponse 4983 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Right -// QoS2,Right QoS2,Right QoS1] [PropWillDelayInterval 17871,PropMessageExpiryInterval 4396,PropContentType -// "\197#\214s",PropSubscriptionIdentifierAvailable 4,PropTopicAliasMaximum 16000,PropReceiveMaximum -// 756,PropAssignedClientIdentifier "\n\177\b>\243C\230\&2\209\186a{"] +uint8_t pkt[] = {0x90, 0xfa, 0x1, 0x4f, 0xb3, 0xf2, 0x1, 0x2a, 0xe8, 0x17, 0x4b, 0x1a, 0x0, 0x16, 0xc9, 0xd0, 0x1c, 0x30, 0xd7, 0xd7, 0x7e, 0x11, 0x8d, 0x8e, 0x5e, 0xd6, 0x73, 0xca, 0x7a, 0xf5, 0x72, 0x62, 0xf6, 0xf0, 0x2f, 0x2f, 0x21, 0x7d, 0x8, 0x29, 0xf8, 0x1f, 0x0, 0xc, 0x5d, 0xcd, 0x55, 0x67, 0x75, 0x94, 0xff, 0x69, 0xe6, 0xc3, 0x43, 0xf0, 0x9, 0x0, 0x1a, 0x84, 0x27, 0xa, 0x44, 0xb, 0x52, 0x76, 0x8d, 0x31, 0xe0, 0xdc, 0xe9, 0x3b, 0x91, 0x31, 0x65, 0x4a, 0x49, 0xa4, 0xe1, 0x90, 0x94, 0xe6, 0x83, 0xe7, 0x37, 0x26, 0x0, 0x1e, 0xa0, 0xd5, 0x1e, 0x2d, 0x53, 0xab, 0xab, 0x57, 0xf1, 0xce, 0xef, 0x89, 0x5, 0x8, 0xe5, 0x38, 0xe5, 0x72, 0xb6, 0x1b, 0x2b, 0x9d, 0x5c, 0x94, 0x6d, 0x35, 0xe3, 0x40, 0x67, 0x8e, 0x0, 0xe, 0x2, 0x3f, 0x6e, 0x74, 0x74, 0x56, 0xff, 0x43, 0x3c, 0x25, 0x1a, 0x87, 0xe1, 0xed, 0x15, 0x0, 0x13, 0x1a, 0xdf, 0xb1, 0xbd, 0x78, 0xd0, 0xc2, 0xa4, 0x31, 0x66, 0x5f, 0x17, 0x33, 0xa8, 0x56, 0x4f, 0x78, 0x9d, 0xac, 0x21, 0x26, 0x59, 0x29, 0x7f, 0x15, 0x0, 0x1b, 0xfd, 0x65, 0x19, 0x78, 0x2b, 0x93, 0x4b, 0x2b, 0x75, 0x1e, 0x51, 0x55, 0xad, 0xc2, 0x91, 0x78, 0x37, 0x64, 0x2b, 0x28, 0xf1, 0x98, 0x18, 0x6d, 0x6b, 0x0, 0xb3, 0x24, 0x46, 0x11, 0x0, 0x0, 0x38, 0x8d, 0x12, 0x0, 0x15, 0x59, 0x8d, 0x5, 0xfb, 0xa0, 0xf4, 0x66, 0x9a, 0x38, 0x79, 0x76, 0xae, 0xb1, 0x7f, 0x2f, 0xca, 0x22, 0xbd, 0x8f, 0xb9, 0x4a, 0x1, 0x6f, 0x2, 0x0, 0x0, 0x53, 0xf3, 0x17, 0x6d, 0x11, 0x0, 0x0, 0x60, 0x73, 0x9, 0x0, 0x0, 0x27, 0x0, 0x0, 0x2a, 0x5, 0x3, 0x0, 0x0, 0x28, 0x88, 0x83, 0x87, 0xa1, 0x1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[4]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 4, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 20403); +EXPECT_EQ(count, 4); +EXPECT_EQ(granted_qos_levels[0], 0x83); +EXPECT_EQ(granted_qos_levels[1], 0x87); +EXPECT_EQ(granted_qos_levels[2], 0xA1); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + +} + + +// SubscribeResponse 8789 [Left SubErrUnspecifiedError,Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] [PropPayloadFormatIndicator 151,PropAssignedClientIdentifier "I\177\215\239\226q",PropServerReference "\RS\SYNE/\157m\NUL\133/l\ETB\138\168Spf\129,\133",PropAuthenticationData "\192\219\tc;\217,r\245V Z\190)\239\232\185\160w\SO\170\n\189\217\214sk\SUB\ETB?",PropSharedSubscriptionAvailable 245,PropResponseInformation "~R9\"\244fY\203\182\137:\194\183\&3`\ACK\170\245\226\164",PropMaximumPacketSize 26769,PropReasonString "R\206\163\GS,\DC4\170\247\249\139\174\188\138\147I\180\&5\t\b\143\250\134\132\255b\180\223c\211\238",PropContentType "\\\215\138\196\229hF%=\246\152\168e\138\a'P}\227rA#\211n\156",PropUserProperty "|f\176\f\162\196\168s\148\182+\171\183\208\142\224\157x+ z\217\US\128\159\215u\NAK",PropRequestProblemInformation 184,PropMessageExpiryInterval 21818,PropReasonString "\"\245\214\SI\147\180nJUX\205O\231\144\155\CAN)\184\205c\157P\US\234\246\n\203\235bn",PropAuthenticationMethod "A^o\DEL/6\180\163(\248\242\153y\218\STXp\201-\n",PropRequestProblemInformation 184,PropResponseInformation ""] TEST(SubACK5QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0x34, 0x13, 0x77, 0x28, 0x18, 0x0, 0x0, 0x45, 0xcf, 0x2, 0x0, 0x0, 0x11, - 0x2c, 0x3, 0x0, 0x4, 0xc5, 0x23, 0xd6, 0x73, 0x29, 0x4, 0x22, 0x3e, 0x80, 0x21, - 0x2, 0xf4, 0x12, 0x0, 0xc, 0xa, 0xb1, 0x8, 0x3e, 0xf3, 0x43, 0xe6, 0x32, 0xd1, - 0xba, 0x61, 0x7b, 0x9e, 0x97, 0xa1, 0x2, 0x0, 0xa1, 0x2, 0x2, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4983); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], 0x97); - EXPECT_EQ(granted_qos_levels[2], 0xA1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], 0xA1); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); -} - -// SubscribeResponse 13883 [Right QoS0,Left SubErrPacketIdentifierInUse,Left SubErrPacketIdentifierInUse,Right -// QoS0,Right QoS0,Left SubErrUnspecifiedError,Right QoS0] [PropRetainAvailable 105,PropRequestResponseInformation -// 236,PropSessionExpiryInterval 18710,PropRequestResponseInformation 120,PropSharedSubscriptionAvailable -// 214,PropAssignedClientIdentifier "\250\197\157\128",PropSharedSubscriptionAvailable 51,PropResponseInformation -// "\184\239s\133\&1\247\157\144n\239D\234G",PropContentType -// "\172\246\216\166\219B\239B\146",PropRequestProblemInformation 168,PropAssignedClientIdentifier -// "K1)\174\237\&7\SUB\129\&2\158\172\162\217\194b\210k\158b\a`\201s",PropPayloadFormatIndicator 22,PropServerReference -// "k;\135\212\CAN,\241\236\215K)u\231\236\226\135\215\130`\175\231\195\n",PropTopicAlias 23018,PropReceiveMaximum -// 8826,PropSubscriptionIdentifierAvailable 53,PropTopicAliasMaximum 18965,PropContentType -// "\253\SIw\\-\bU\230(\vX\SYNC\245\234",PropWildcardSubscriptionAvailable 204,PropMessageExpiryInterval -// 8078,PropReasonString -// "0C\NUL#\203:\NUL1d\168\142Hk\159\181\NAK\150\201\SUB\195_06f\165dr\220\235",PropMaximumPacketSize -// 13502,PropSubscriptionIdentifier 27,PropMaximumQoS 21,PropUserProperty "\136e\202\216\155%\140A\142" -// "\174_\v\190|8\162\196",PropSubscriptionIdentifierAvailable 212,PropWillDelayInterval 26280,PropMessageExpiryInterval -// 5506] +uint8_t pkt[] = {0x90, 0xa5, 0x2, 0x22, 0x55, 0x9c, 0x2, 0x1, 0x97, 0x12, 0x0, 0x6, 0x49, 0xb1, 0xd7, 0xef, 0xe2, 0x71, 0x1c, 0x0, 0x13, 0x1e, 0x16, 0x45, 0x2f, 0x9d, 0x6d, 0x0, 0x85, 0x2f, 0x6c, 0x17, 0x8a, 0xa8, 0x53, 0x70, 0x66, 0x81, 0x2c, 0x85, 0x16, 0x0, 0x1e, 0xc0, 0xdb, 0x9, 0x63, 0x3b, 0xd9, 0x2c, 0x72, 0xf5, 0x56, 0x20, 0x5a, 0xbe, 0x29, 0xef, 0xe8, 0xb9, 0xa0, 0x77, 0xe, 0xaa, 0xa, 0xbd, 0xd9, 0xd6, 0x73, 0x6b, 0x1a, 0x17, 0x3f, 0x2a, 0xf5, 0x1a, 0x0, 0x14, 0x7e, 0x52, 0x39, 0x22, 0xf4, 0x66, 0x59, 0xcb, 0xb6, 0x89, 0x3a, 0xc2, 0xb7, 0x33, 0x60, 0x6, 0xaa, 0xf5, 0xe2, 0xa4, 0x27, 0x0, 0x0, 0x68, 0x91, 0x1f, 0x0, 0x1e, 0x52, 0xce, 0xa3, 0x1d, 0x2c, 0x14, 0xaa, 0xf7, 0xf9, 0x8b, 0xae, 0xbc, 0x8a, 0x93, 0x49, 0xb4, 0x35, 0x9, 0x8, 0x8f, 0xfa, 0x86, 0x84, 0xff, 0x62, 0xb4, 0xdf, 0x63, 0xd3, 0xee, 0x3, 0x0, 0x19, 0x5c, 0xd7, 0x8a, 0xc4, 0xe5, 0x68, 0x46, 0x25, 0x3d, 0xf6, 0x98, 0xa8, 0x65, 0x8a, 0x7, 0x27, 0x50, 0x7d, 0xe3, 0x72, 0x41, 0x23, 0xd3, 0x6e, 0x9c, 0x26, 0x0, 0x1e, 0x7c, 0x66, 0xb0, 0xc, 0xa2, 0xc4, 0xa8, 0x73, 0x94, 0xb6, 0x2b, 0xab, 0x3c, 0x43, 0xf5, 0x1a, 0x18, 0x97, 0x8, 0x2e, 0xb1, 0x27, 0x9d, 0x2c, 0xef, 0xf4, 0x57, 0xbc, 0x55, 0xe3, 0x0, 0x19, 0x3b, 0x79, 0x4b, 0xea, 0x27, 0xfe, 0x36, 0x9a, 0x3e, 0xb7, 0xd0, 0x8e, 0xe0, 0x9d, 0x78, 0x2b, 0x20, 0x7a, 0xd9, 0x1f, 0x80, 0x9f, 0xd7, 0x75, 0x15, 0x17, 0xb8, 0x2, 0x0, 0x0, 0x55, 0x3a, 0x1f, 0x0, 0x1e, 0x22, 0xf5, 0xd6, 0xf, 0x93, 0xb4, 0x6e, 0x4a, 0x55, 0x58, 0xcd, 0x4f, 0xe7, 0x90, 0x9b, 0x18, 0x29, 0xb8, 0xcd, 0x63, 0x9d, 0x50, 0x1f, 0xea, 0xf6, 0xa, 0xcb, 0xeb, 0x62, 0x6e, 0x15, 0x0, 0x13, 0x41, 0x5e, 0x6f, 0x7f, 0x2f, 0x36, 0xb4, 0xa3, 0x28, 0xf8, 0xf2, 0x99, 0x79, 0xda, 0x2, 0x70, 0xc9, 0x2d, 0xa, 0x17, 0xb8, 0x1a, 0x0, 0x0, 0x80, 0x9e, 0x97, 0x1, 0xa2}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 8789); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], 0x80); +EXPECT_EQ(granted_qos_levels[1], 0x9E); +EXPECT_EQ(granted_qos_levels[2], 0x97); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[4], 0xA2); + +} + + +// SubscribeResponse 2708 [Right QoS1,Right QoS2,Right QoS0,Right QoS0,Left SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS1,Right QoS0,Right QoS1] [PropAuthenticationData "\137&t\240\241\CAN\201\212\173\255t\tyG\245\189\157!@\193Y\ENQ%a\237\133",PropMaximumPacketSize 1523] TEST(SubACK5QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0xe4, 0x1, 0x36, 0x3b, 0xd9, 0x1, 0x25, 0x69, 0x19, 0xec, 0x11, 0x0, 0x0, 0x49, 0x16, 0x19, - 0x78, 0x2a, 0xd6, 0x12, 0x0, 0x4, 0xfa, 0xc5, 0x9d, 0x80, 0x2a, 0x33, 0x1a, 0x0, 0xd, 0xb8, 0xef, - 0x73, 0x85, 0x31, 0xf7, 0x9d, 0x90, 0x6e, 0xef, 0x44, 0xea, 0x47, 0x3, 0x0, 0x9, 0xac, 0xf6, 0xd8, - 0xa6, 0xdb, 0x42, 0xef, 0x42, 0x92, 0x17, 0xa8, 0x12, 0x0, 0x17, 0x4b, 0x31, 0x29, 0xae, 0xed, 0x37, - 0x1a, 0x81, 0x32, 0x9e, 0xac, 0xa2, 0xd9, 0xc2, 0x62, 0xd2, 0x6b, 0x9e, 0x62, 0x7, 0x60, 0xc9, 0x73, - 0x1, 0x16, 0x1c, 0x0, 0x17, 0x6b, 0x3b, 0x87, 0xd4, 0x18, 0x2c, 0xf1, 0xec, 0xd7, 0x4b, 0x29, 0x75, - 0xe7, 0xec, 0xe2, 0x87, 0xd7, 0x82, 0x60, 0xaf, 0xe7, 0xc3, 0xa, 0x23, 0x59, 0xea, 0x21, 0x22, 0x7a, - 0x29, 0x35, 0x22, 0x4a, 0x15, 0x3, 0x0, 0xf, 0xfd, 0xf, 0x77, 0x5c, 0x2d, 0x8, 0x55, 0xe6, 0x28, - 0xb, 0x58, 0x16, 0x43, 0xf5, 0xea, 0x28, 0xcc, 0x2, 0x0, 0x0, 0x1f, 0x8e, 0x1f, 0x0, 0x1d, 0x30, - 0x43, 0x0, 0x23, 0xcb, 0x3a, 0x0, 0x31, 0x64, 0xa8, 0x8e, 0x48, 0x6b, 0x9f, 0xb5, 0x15, 0x96, 0xc9, - 0x1a, 0xc3, 0x5f, 0x30, 0x36, 0x66, 0xa5, 0x64, 0x72, 0xdc, 0xeb, 0x27, 0x0, 0x0, 0x34, 0xbe, 0xb, - 0x1b, 0x24, 0x15, 0x26, 0x0, 0x9, 0x88, 0x65, 0xca, 0xd8, 0x9b, 0x25, 0x8c, 0x41, 0x8e, 0x0, 0x8, - 0xae, 0x5f, 0xb, 0xbe, 0x7c, 0x38, 0xa2, 0xc4, 0x29, 0xd4, 0x18, 0x0, 0x0, 0x66, 0xa8, 0x2, 0x0, - 0x0, 0x15, 0x82, 0x0, 0x91, 0x91, 0x0, 0x0, 0x80, 0x0}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13883); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x91); - EXPECT_EQ(granted_qos_levels[2], 0x91); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); -} - -// SubscribeResponse 7030 [Right QoS0] [PropServerKeepAlive 16046,PropRetainAvailable 15,PropAssignedClientIdentifier -// "\214;\212s_I4",PropSubscriptionIdentifier 0,PropMessageExpiryInterval 25675,PropMaximumQoS -// 127,PropMessageExpiryInterval 15938,PropResponseInformation -// "O\195\200n*S\167A\183\149\191\SUBE\fj,n\156\246\250\239,\207",PropSessionExpiryInterval -// 17485,PropWildcardSubscriptionAvailable 94,PropMaximumQoS 248,PropServerReference -// "7}\190\ETBZ\183\150|\"O\155\ETB\171 \SOHF\198\231\159\SYN5\170\137\159!\179Q",PropUserProperty -// "\140?$\156\154a\206\210\163\215m" "\NUL\193\211nS\168\241\190",PropResponseInformation -// "B\216}4\155^f\a\160q6F\249>\224fL&\254\210j\204\167",PropServerKeepAlive 17141,PropSubscriptionIdentifierAvailable -// 84,PropResponseInformation -// "\172x\249\206\229\228\173\151BrI\247{\183\NUL\202nj0\179\156R\ETX:\149\235\192",PropMessageExpiryInterval -// 32669,PropReasonString "b\\\151\n\197\178\179\195f\253W\a\152\a\156}\t[\187\215\f\227\194*",PropAuthenticationData -// "0^\145\&3\240\DELM\148 R@F\247lw-\192\196\141w\ra\251c",PropMessageExpiryInterval 4202,PropAssignedClientIdentifier -// "f\185\234_L\239\&6N",PropAuthenticationData "2\203j`"] +uint8_t pkt[] = {0x90, 0x30, 0xa, 0x94, 0x22, 0x16, 0x0, 0x1a, 0x89, 0x26, 0x74, 0xf0, 0xf1, 0x18, 0xc9, 0xd4, 0xad, 0xff, 0x74, 0x9, 0x79, 0x47, 0xf5, 0xbd, 0x9d, 0x21, 0x40, 0xc1, 0x59, 0x5, 0x25, 0x61, 0xed, 0x85, 0x27, 0x0, 0x0, 0x5, 0xf3, 0x1, 0x2, 0x0, 0x0, 0x8f, 0xa2, 0x2, 0x1, 0x1, 0x0, 0x1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[11]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 11, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 2708); +EXPECT_EQ(count, 11); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[4], 0x8F); +EXPECT_EQ(granted_qos_levels[5], 0xA2); +EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS1); + +} + + +// SubscribeResponse 12793 [Left SubErrTopicFilterInvalid,Right QoS0,Right QoS0,Right QoS2,Left SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [PropUserProperty "\SO3\200y\203\r\DC2\208\DLE9v\r\152Q-\167\&8\187}\ACK\NUL" "\129\&5",PropCorrelationData "\139f\SOH\245\STX\169\238^r\229hV\206\180",PropWillDelayInterval 16972,PropSubscriptionIdentifier 27,PropRequestProblemInformation 54,PropAuthenticationMethod "J\175\145\EOT\225L\241f`GZ\US\CANnj\129s\139+\238\245R",PropUserProperty "\146\226\170\198\238\ETX\216\191M\203\236l\131\217x7J\150\226" "|\244\ETBe#\CAN\206\173\168\250\245\SO\221J\SI\248b\248\232\177;\242\155",PropRequestResponseInformation 193,PropResponseTopic "`\132\189\196\203\224\128\252\SO\166\252`f\GS\172\SOQ\DC2\216\220\SO\182\255\SYN",PropServerKeepAlive 19627,PropMaximumPacketSize 8916,PropSubscriptionIdentifier 21,PropAssignedClientIdentifier "\158\t\SYN)H\153\&0\230?\NAK\DC4",PropPayloadFormatIndicator 209,PropAssignedClientIdentifier "\185\162+\152JG\200(\162&",PropServerReference "\164\195\DC2\249J\NUL\191\136\138_\137r\241\\\211\236'\n8\200\160Wb\147\172\196\SYN\221",PropSessionExpiryInterval 28997,PropMessageExpiryInterval 8313,PropUserProperty "\200\189\192\FS\240\DC29\138\249\238\NULX\165" "\SYN\STX\233I\245s\183\232xW\207\&5\254\139\228O\SOH\CAN>\138&\244\vy\226\155#\DC1\165",PropTopicAliasMaximum 24813,PropRequestProblemInformation 181,PropResponseTopic "\DC28\202\175\242\US\226\166\244\142\DEL\144\234}",PropSessionExpiryInterval 19284,PropMaximumQoS 251,PropResponseInformation "q\242\NUL -\210?@lk",PropUserProperty "\STX\211\252\225\139\&7\159\198\fl7i\132\254:$\249\153\237^\221L\194Sq\"\t\DC1" "\129`m\145\225\252-",PropWillDelayInterval 11295,PropMaximumQoS 2] TEST(SubACK5QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0x5, 0x1, 0xce, 0x0, 0x2, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 462); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -} - -// SubscribeResponse 28404 [Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Left -// SubErrSubscriptionIdentifiersNotSupported] [PropResponseTopic "\193 -// \204B\253`\179\135\ETBx\190G.K|lB%;8\191A9\129T",PropRequestResponseInformation -// 146,PropSubscriptionIdentifierAvailable 186,PropUserProperty "\173\NULQ\SYNQ\151\214\&8g\232c\239" -// ")\129\137\NUL/0\DEL\142\186\225\FS\247u\228\176\162d\170\CAN\165&",PropServerReference -// "\DC2\189\255\136\224\158\172\227s\139\206\170\155'\198\172\164\179\171\195\156\187\167rj",PropTopicAliasMaximum -// 18134,PropWildcardSubscriptionAvailable 34,PropReceiveMaximum 31787,PropTopicAliasMaximum 31526,PropReasonString -// "",PropWillDelayInterval 12886,PropCorrelationData -// "\185\224)\139y\198\a\134\NUL?\136\DC1\229\232\EOT%\245%\193\130\176\195\193\150\n>\133<\219",PropRequestResponseInformation -// 12,PropContentType "\221\129\249u\SO\240\141%\DC4 \RSS\DC4\131\208l\195di\ESC\238\137\EMl",PropAuthenticationData -// "\140F\207Q\ETB\b5\227\f\197Y\235\152\242\&9\214\172y\219n\233\158-\165\148\166O\168\226\EMk\206\NUL\229",PropRequestProblemInformation 124] TEST(SubACK5QCTest, Decode14) { - uint8_t pkt[] = {0x90, 0x93, 0x1, 0x70, 0xc6, 0x8b, 0x1, 0x2, 0x0, 0x0, 0x5a, 0x96, 0x3, 0x0, 0x10, 0x3b, 0x55, - 0x85, 0x64, 0x4f, 0xda, 0xc1, 0xde, 0x8f, 0x9a, 0xf6, 0x2, 0x99, 0x6, 0x63, 0x96, 0x1f, 0x0, 0x1b, - 0x49, 0xc, 0x39, 0x47, 0xe5, 0x10, 0x56, 0x5d, 0x11, 0x2e, 0x6d, 0x9b, 0x7d, 0x54, 0xe0, 0x9e, 0xb4, - 0xd1, 0xb3, 0xeb, 0x38, 0x87, 0xe0, 0x6, 0x1d, 0xd0, 0x81, 0x15, 0x0, 0x8, 0xe8, 0xc2, 0x5, 0x46, - 0x6a, 0xb, 0x55, 0x4d, 0x18, 0x0, 0x0, 0x3d, 0xe8, 0x3, 0x0, 0x1c, 0x5b, 0x7d, 0x4b, 0x2f, 0xef, - 0x6e, 0xd8, 0x62, 0x5e, 0x58, 0x6d, 0x21, 0x16, 0x9a, 0xc4, 0xe6, 0xde, 0xb2, 0x14, 0xf7, 0xa2, 0x4c, - 0x38, 0xf6, 0x9c, 0xc1, 0x31, 0x51, 0x15, 0x0, 0x1, 0x3c, 0x12, 0x0, 0x18, 0xdc, 0x6, 0x69, 0xc, - 0xc3, 0xcb, 0x2c, 0x5, 0x2a, 0xdc, 0xe7, 0x6c, 0xe1, 0xa8, 0x61, 0xda, 0xa6, 0xe8, 0xe, 0x6f, 0x42, - 0xe2, 0x8e, 0x2e, 0x17, 0x24, 0x13, 0x39, 0x5e, 0x24, 0x10, 0x2, 0x0, 0x91, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 28870); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x91); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); -} - -// SubscribeResponse 1085 [Right QoS0,Right QoS0,Left SubErrImplementationSpecificError,Left -// SubErrSubscriptionIdentifiersNotSupported] [PropServerKeepAlive 6900,PropPayloadFormatIndicator -// 43,PropRequestProblemInformation 113,PropWildcardSubscriptionAvailable 45,PropTopicAliasMaximum -// 11413,PropAuthenticationData -// "gP\142\207\ENQ\158c\177\225Qa\v\135\SI\218\212\211\202\&0\SOH,#\196\205\234sB",PropMaximumPacketSize -// 479,PropServerReference "\184\179\147m9\248\202\182\149\159\246\180\154\SUB\185\190\ACK",PropAuthenticationMethod -// "\209J\135K\129\DC4\GS(\DC2",PropAuthenticationMethod -// "V\DC3#\206\153\199\138\216?|\206\182|\197\&5~\r\n\229",PropAuthenticationData -// "\r\241\226\212\US\162\211\179}\190L%\200Q\151*\\\DC3\SI",PropWillDelayInterval 13410,PropRetainAvailable -// 123,PropServerReference "\128\&2\194\a\162\184\ESC\215c1\177L\252\245\&12",PropWillDelayInterval 9499] +uint8_t pkt[] = {0x90, 0x2d, 0x14, 0x1d, 0x24, 0x2, 0x0, 0x0, 0x1f, 0x90, 0xb, 0x17, 0x16, 0x0, 0x0, 0x1a, 0x0, 0x15, 0x1, 0x2, 0xd8, 0xb2, 0x3e, 0xdb, 0x6e, 0xe9, 0x9e, 0x2d, 0xa5, 0x94, 0xa6, 0x4f, 0xa8, 0xe2, 0x19, 0x6b, 0xce, 0x0, 0xe5, 0x17, 0x7c, 0x91, 0x0, 0x2, 0x2, 0x2, 0x83}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 5149); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], 0x91); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[5], 0x83); + +} + + +// SubscribeResponse 27317 [Left SubErrPacketIdentifierInUse,Left SubErrTopicFilterInvalid,Right QoS2,Right QoS0,Right QoS0,Right QoS2] [PropContentType "?\DC4\SI\172~\166\149dp\182\170F\165\163i\150\ENQ\no",PropPayloadFormatIndicator 192,PropSessionExpiryInterval 26985,PropUserProperty "\246)\SI\242c" "?\US\166\SOH\187\250\&3\183\&1O\247\&7Hq",PropTopicAlias 26253,PropWillDelayInterval 23496,PropAuthenticationMethod "\245\189\184\180$D\170\208\v\206\168\SUB\145f\212",PropContentType "qS+",PropTopicAliasMaximum 12139,PropTopicAlias 28751,PropContentType "W\219\180\DC3\144\230"] TEST(SubACK5QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0xa2, 0x1, 0x4, 0x3d, 0x9a, 0x1, 0x13, 0x1a, 0xf4, 0x1, 0x2b, 0x17, 0x71, 0x28, 0x2d, 0x22, - 0x2c, 0x95, 0x16, 0x0, 0x1b, 0x67, 0x50, 0x8e, 0xcf, 0x5, 0x9e, 0x63, 0xb1, 0xe1, 0x51, 0x61, 0xb, - 0x87, 0xf, 0xda, 0xd4, 0xd3, 0xca, 0x30, 0x1, 0x2c, 0x23, 0xc4, 0xcd, 0xea, 0x73, 0x42, 0x27, 0x0, - 0x0, 0x1, 0xdf, 0x1c, 0x0, 0x11, 0xb8, 0xb3, 0x93, 0x6d, 0x39, 0xf8, 0xca, 0xb6, 0x95, 0x9f, 0xf6, - 0xb4, 0x9a, 0x1a, 0xb9, 0xbe, 0x6, 0x15, 0x0, 0x9, 0xd1, 0x4a, 0x87, 0x4b, 0x81, 0x14, 0x1d, 0x28, - 0x12, 0x15, 0x0, 0x13, 0x56, 0x13, 0x23, 0xce, 0x99, 0xc7, 0x8a, 0xd8, 0x3f, 0x7c, 0xce, 0xb6, 0x7c, - 0xc5, 0x35, 0x7e, 0xd, 0xa, 0xe5, 0x16, 0x0, 0x13, 0xd, 0xf1, 0xe2, 0xd4, 0x1f, 0xa2, 0xd3, 0xb3, - 0x7d, 0xbe, 0x4c, 0x25, 0xc8, 0x51, 0x97, 0x2a, 0x5c, 0x13, 0xf, 0x18, 0x0, 0x0, 0x34, 0x62, 0x25, - 0x7b, 0x1c, 0x0, 0x10, 0x80, 0x32, 0xc2, 0x7, 0xa2, 0xb8, 0x1b, 0xd7, 0x63, 0x31, 0xb1, 0x4c, 0xfc, - 0xf5, 0x31, 0x32, 0x18, 0x0, 0x0, 0x25, 0x1b, 0x0, 0x0, 0x83, 0xa1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1085); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x83); - EXPECT_EQ(granted_qos_levels[3], 0xA1); -} - -// SubscribeResponse 11089 [Right QoS1] [PropReasonString "\247\194\179\147\202\DLE",PropTopicAlias -// 23245,PropAssignedClientIdentifier "xmZi\b\150@\214k%\140m\154H",PropUserProperty "R\v\214\NAK" -// "\190\&7\134\154\232\SIf\228\254\NAK\CANA\161\EOT*\GS\135\SO\DC2\188O|i",PropReasonString -// "\246F:\183\ESC+\"\225\207\209\163\153\202\151\DC1\\\140\167\200\206y\152|\ESCu%\196\153\239)",PropReceiveMaximum -// 6204,PropTopicAlias 26815,PropAuthenticationData -// "\219\163E\SUB\NULO\158\ESCs\ACK\185\vQ4\b\213\SUB:?M\239\196B\DC3",PropWillDelayInterval 15528,PropUserProperty -// "\165" "\234\244\189U\247Y\205\224\b\192\177\&6\228\131",PropAuthenticationData -// "\ETX\251\US\NAK\250\209\227\164D\206\149\213\175\&6)\DEL\190Y\217\252\DLEX\219\164J\159Z",PropServerReference -// "\f{\ACK\209$\201\197\225w\163\194\&23\228Y\252\233\v0\205\181",PropAssignedClientIdentifier -// "\229\163\204\171z\177YW\156\ACK\205N\136\151B\251\159l;",PropSessionExpiryInterval 8174,PropSessionExpiryInterval -// 26444] +uint8_t pkt[] = {0x90, 0x6d, 0x6a, 0xb5, 0x64, 0x3, 0x0, 0x13, 0x3f, 0x14, 0xf, 0xac, 0x7e, 0xa6, 0x95, 0x64, 0x70, 0xb6, 0xaa, 0x46, 0xa5, 0xa3, 0x69, 0x96, 0x5, 0xa, 0x6f, 0x1, 0xc0, 0x11, 0x0, 0x0, 0x69, 0x69, 0x26, 0x0, 0x5, 0xf6, 0x29, 0xf, 0xf2, 0x63, 0x0, 0xe, 0x3f, 0x1f, 0xa6, 0x1, 0xbb, 0xfa, 0x33, 0xb7, 0x31, 0x4f, 0xf7, 0x37, 0x48, 0x71, 0x23, 0x66, 0x8d, 0x18, 0x0, 0x0, 0x5b, 0xc8, 0x15, 0x0, 0xf, 0xf5, 0xbd, 0xb8, 0xb4, 0x24, 0x44, 0xaa, 0xd0, 0xb, 0xce, 0xa8, 0x1a, 0x91, 0x66, 0xd4, 0x3, 0x0, 0x3, 0x71, 0x53, 0x2b, 0x22, 0x2f, 0x6b, 0x23, 0x70, 0x4f, 0x3, 0x0, 0x6, 0x57, 0xdb, 0xb4, 0x13, 0x90, 0xe6, 0x91, 0x8f, 0x2, 0x0, 0x0, 0x2}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 27317); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], 0x91); +EXPECT_EQ(granted_qos_levels[1], 0x8F); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + +} + + +// SubscribeResponse 30611 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS0,Right QoS2,Right QoS1] [PropMessageExpiryInterval 27493,PropSharedSubscriptionAvailable 220,PropAssignedClientIdentifier "\236\DEL\\\204\242k0\152N\206\215\132@\148\155\177\133'\167"] TEST(SubACK5QCTest, Decode16) { - uint8_t pkt[] = { - 0x90, 0xf3, 0x1, 0x2b, 0x51, 0xee, 0x1, 0x1f, 0x0, 0x6, 0xf7, 0xc2, 0xb3, 0x93, 0xca, 0x10, 0x23, 0x5a, 0xcd, - 0x12, 0x0, 0xe, 0x78, 0x6d, 0x5a, 0x69, 0x8, 0x96, 0x40, 0xd6, 0x6b, 0x25, 0x8c, 0x6d, 0x9a, 0x48, 0x26, 0x0, - 0x4, 0x52, 0xb, 0xd6, 0x15, 0x0, 0x17, 0xbe, 0x37, 0x86, 0x9a, 0xe8, 0xf, 0x66, 0xe4, 0xfe, 0x15, 0x18, 0x41, - 0xa1, 0x4, 0x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 0x4c, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11089); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); -} - -// SubscribeResponse 4816 [Left SubErrQuotaExceeded,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right -// QoS0,Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right QoS1,Left SubErrNotAuthorized,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported] [PropMessageExpiryInterval -// 20581,PropServerReference "\180\166@",PropReasonString "",PropUserProperty "\139\179\177\244" -// "0\DC4)\194",PropTopicAlias 948,PropReceiveMaximum 14675,PropSubscriptionIdentifierAvailable -// 199,PropTopicAliasMaximum 19310,PropWillDelayInterval 8080,PropCorrelationData -// "\137\243\196\196\178",PropTopicAliasMaximum 10347,PropMaximumQoS 180,PropMaximumQoS 19,PropServerReference -// "\175WZ\225p\199\160&\249\b\220\250z\155\136\178g\187_\218\192\168\&2\182\n\148\231",PropMessageExpiryInterval -// 15679,PropCorrelationData "\241W\243\&0\213z\NAK\182\194\DC3\148\192e\222\&1lz\DC1.\214",PropMaximumQoS -// 79,PropSubscriptionIdentifier 21] +uint8_t pkt[] = {0x90, 0x25, 0x77, 0x93, 0x1d, 0x2, 0x0, 0x0, 0x6b, 0x65, 0x2a, 0xdc, 0x12, 0x0, 0x13, 0xec, 0x7f, 0x5c, 0xcc, 0xf2, 0x6b, 0x30, 0x98, 0x4e, 0xce, 0xd7, 0x84, 0x40, 0x94, 0x9b, 0xb1, 0x85, 0x27, 0xa7, 0xa1, 0x2, 0x0, 0x2, 0x1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 30611); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], 0xA1); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + +} + + +// SubscribeResponse 14554 [Right QoS0,Right QoS2,Left SubErrUnspecifiedError,Right QoS0] [PropTopicAlias 11229,PropMessageExpiryInterval 32396,PropResponseInformation "\183\153$\145\176\192ng\231nM\b\160\147\253U\243\ACKA-\165#\EOT\159\DC1\US",PropAuthenticationData "'n\159d\176?3\204k\217&%\197",PropRetainAvailable 250,PropMessageExpiryInterval 5575,PropAuthenticationData "\136\177\162\173\241\152\"\173\204\DELO\DLE",PropTopicAliasMaximum 27880,PropWillDelayInterval 235,PropSubscriptionIdentifierAvailable 3,PropMaximumQoS 55,PropSharedSubscriptionAvailable 5,PropRequestProblemInformation 163,PropSubscriptionIdentifier 8,PropSubscriptionIdentifier 22,PropUserProperty "\\I.D<\143\213\195\147\157)\CANK\149\138\255/a\226\196\184<\169\201\227\\\132\188b_" "\DC1\SYN\217z\203}\ETX\187;\\",PropWillDelayInterval 11365,PropPayloadFormatIndicator 116,PropServerReference "\211\237\176\193\SYN",PropResponseInformation "\\v\SUBGzm\185\162\157)\200@!\235#\243I\237\146\NUL\132X",PropCorrelationData "\251\174.\203c\245c\ACKT\CAN\154\174)\224{\138\214#\251p:\210c\161",PropTopicAliasMaximum 23726,PropRetainAvailable 113,PropRequestResponseInformation 121,PropAuthenticationData "5\248\&1\239td\129\183\143\\",PropSessionExpiryInterval 15701,PropRequestResponseInformation 200,PropTopicAliasMaximum 14994,PropServerReference "y\166\163i\EMq|\DC1",PropAuthenticationData ")\213\253\152q\243FH\211\ENQm\135\188\&9\232\146\176\189H\CAN\227"] TEST(SubACK5QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0x86, 0x1, 0x12, 0xd0, 0x78, 0x2, 0x0, 0x0, 0x50, 0x65, 0x1c, 0x0, 0x3, 0xb4, 0xa6, - 0x40, 0x1f, 0x0, 0x0, 0x26, 0x0, 0x4, 0x8b, 0xb3, 0xb1, 0xf4, 0x0, 0x4, 0x30, 0x14, 0x29, - 0xc2, 0x23, 0x3, 0xb4, 0x21, 0x39, 0x53, 0x29, 0xc7, 0x22, 0x4b, 0x6e, 0x18, 0x0, 0x0, 0x1f, - 0x90, 0x9, 0x0, 0x5, 0x89, 0xf3, 0xc4, 0xc4, 0xb2, 0x22, 0x28, 0x6b, 0x24, 0xb4, 0x24, 0x13, - 0x1c, 0x0, 0x1b, 0xaf, 0x57, 0x5a, 0xe1, 0x70, 0xc7, 0xa0, 0x26, 0xf9, 0x8, 0xdc, 0xfa, 0x7a, - 0x9b, 0x88, 0xb2, 0x67, 0xbb, 0x5f, 0xda, 0xc0, 0xa8, 0x32, 0xb6, 0xa, 0x94, 0xe7, 0x2, 0x0, - 0x0, 0x3d, 0x3f, 0x9, 0x0, 0x14, 0xf1, 0x57, 0xf3, 0x30, 0xd5, 0x7a, 0x15, 0xb6, 0xc2, 0x13, - 0x94, 0xc0, 0x65, 0xde, 0x31, 0x6c, 0x7a, 0x11, 0x2e, 0xd6, 0x24, 0x4f, 0xb, 0x15, 0x97, 0xa2, - 0x2, 0x0, 0x1, 0x0, 0x87, 0x1, 0x87, 0x9e, 0xa2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4816); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x97); - EXPECT_EQ(granted_qos_levels[1], 0xA2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x87); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0x87); - EXPECT_EQ(granted_qos_levels[9], 0x9E); - EXPECT_EQ(granted_qos_levels[10], 0xA2); -} - -// SubscribeResponse 24891 [Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1,Right QoS2,Left -// SubErrTopicFilterInvalid,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [PropContentType -// "\ESC\230\222\175\187\235\US",PropRequestProblemInformation 195,PropServerReference -// "SM\ACKT\184\216p?RH6M=q\DC4\bD\156\128\160\135\244\226(\227\&5\193.\200\132",PropContentType -// "3\218\236\ACK\243`\174\241\225\131\NULm\ETX\183\r\220.\164\144\182\&7k\253J\EM\247\173\171r",PropUserProperty -// "X'\231]\ESCzE\140\179t\191\135\216p" "",PropAuthenticationMethod -// "\156\138\ACK\184\147H\157=\233Y\144\135\b'd\243\251\196\NAKk\nW\171",PropServerReference -// "(\vP2Gn!E\186r*\161zs\198T",PropRequestProblemInformation 227,PropResponseTopic -// "\140C_\237D6\234'@\251\\\155|\184\162\130",PropReasonString -// "g\187s\f\242!t\135\140*\v\140\143B\143\129\188\140\141",PropResponseInformation -// "\193\204\DC4+9Y\200\&0\STX~\253\FS\232;",PropUserProperty -// "\209\STX\223\244\&8\be\242\198\179>\138Z\148\223\CAN\254h-\194\242\254\232@" "\254\246}@\195 -// \238\US\204f\202K\210X\202\225\218\207[\219\152J\171$\137",PropTopicAlias 20875,PropSubscriptionIdentifier -// 10,PropCorrelationData "\216\219~B+\224\185\nm \STX@\EOT\213\217\226\222",PropAuthenticationData -// "(\a\174p\182\180",PropTopicAlias 7307,PropResponseTopic -// "@\163!oz\178\136\155..\167\154\139r\t3",PropRequestProblemInformation 48,PropMessageExpiryInterval -// 22413,PropMessageExpiryInterval 27970,PropMaximumQoS 214,PropPayloadFormatIndicator 142,PropReceiveMaximum 26693] +uint8_t pkt[] = {0x90, 0x98, 0x2, 0x38, 0xda, 0x90, 0x2, 0x23, 0x2b, 0xdd, 0x2, 0x0, 0x0, 0x7e, 0x8c, 0x1a, 0x0, 0x1a, 0xb7, 0x99, 0x24, 0x91, 0xb0, 0xc0, 0x6e, 0x67, 0xe7, 0x6e, 0x4d, 0x8, 0xa0, 0x93, 0xfd, 0x55, 0xf3, 0x6, 0x41, 0x2d, 0xa5, 0x23, 0x4, 0x9f, 0x11, 0x1f, 0x16, 0x0, 0xd, 0x27, 0x6e, 0x9f, 0x64, 0xb0, 0x3f, 0x33, 0xcc, 0x6b, 0xd9, 0x26, 0x25, 0xc5, 0x25, 0xfa, 0x2, 0x0, 0x0, 0x15, 0xc7, 0x16, 0x0, 0xc, 0x88, 0xb1, 0xa2, 0xad, 0xf1, 0x98, 0x22, 0xad, 0xcc, 0x7f, 0x4f, 0x10, 0x22, 0x6c, 0xe8, 0x18, 0x0, 0x0, 0x0, 0xeb, 0x29, 0x3, 0x24, 0x37, 0x2a, 0x5, 0x17, 0xa3, 0xb, 0x8, 0xb, 0x16, 0x26, 0x0, 0x1e, 0x5c, 0x49, 0x2e, 0x44, 0x3c, 0x8f, 0xd5, 0xc3, 0x93, 0x9d, 0x29, 0x18, 0x4b, 0x95, 0x8a, 0xff, 0x2f, 0x61, 0xe2, 0xc4, 0xb8, 0x3c, 0xa9, 0xc9, 0xe3, 0x5c, 0x84, 0xbc, 0x62, 0x5f, 0x0, 0xa, 0x11, 0x16, 0xd9, 0x7a, 0xcb, 0x7d, 0x3, 0xbb, 0x3b, 0x5c, 0x18, 0x0, 0x0, 0x2c, 0x65, 0x1, 0x74, 0x1c, 0x0, 0x5, 0xd3, 0xed, 0xb0, 0xc1, 0x16, 0x1a, 0x0, 0x16, 0x5c, 0x76, 0x1a, 0x47, 0x7a, 0x6d, 0xb9, 0xa2, 0x9d, 0x29, 0xc8, 0x40, 0x21, 0xeb, 0x23, 0xf3, 0x49, 0xed, 0x92, 0x0, 0x84, 0x58, 0x9, 0x0, 0x18, 0xfb, 0xae, 0x2e, 0xcb, 0x63, 0xf5, 0x63, 0x6, 0x54, 0x18, 0x9a, 0xae, 0x29, 0xe0, 0x7b, 0x8a, 0xd6, 0x23, 0xfb, 0x70, 0x3a, 0xd2, 0x63, 0xa1, 0x22, 0x5c, 0xae, 0x25, 0x71, 0x19, 0x79, 0x16, 0x0, 0xa, 0x35, 0xf8, 0x31, 0xef, 0x74, 0x64, 0x81, 0xb7, 0x8f, 0x5c, 0x11, 0x0, 0x0, 0x3d, 0x55, 0x19, 0xc8, 0x22, 0x3a, 0x92, 0x1c, 0x0, 0x8, 0x79, 0xa6, 0xa3, 0x69, 0x19, 0x71, 0x7c, 0x11, 0x16, 0x0, 0x15, 0x29, 0xd5, 0xfd, 0x98, 0x71, 0xf3, 0x46, 0x48, 0xd3, 0x5, 0x6d, 0x87, 0xbc, 0x39, 0xe8, 0x92, 0xb0, 0xbd, 0x48, 0x18, 0xe3, 0x0, 0x2, 0x80, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[4]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 4, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 14554); +EXPECT_EQ(count, 4); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[2], 0x80); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + +} + + +// SubscribeResponse 22626 [Right QoS2,Right QoS1,Left SubErrImplementationSpecificError,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported] [PropContentType "\NAKQs\155\134\195\&7\191\171",PropResponseTopic "z\151",PropWildcardSubscriptionAvailable 95,PropCorrelationData "Y\180\142\DC2\249\235\141\137\v_\b\166\197\176\n\174k/\237\175\181{\190",PropServerReference "Xd\225\NUL\190jz\r\187\247\ETX[;\221\210\168\241l*\216\ACK\GS",PropWildcardSubscriptionAvailable 46,PropSharedSubscriptionAvailable 119,PropContentType "\247\173\146D\186\166s\171\EMs\171\233\140aE\188z.bQ\DEL\140\226",PropWildcardSubscriptionAvailable 21,PropContentType "\ETB\187\202\162\212q\DC2\214^\176\131\128X$}\185F",PropMaximumPacketSize 16829,PropReasonString "j\146z\153",PropSharedSubscriptionAvailable 43,PropRequestResponseInformation 33,PropMessageExpiryInterval 11523,PropAuthenticationMethod "\213\SO\191\202",PropContentType "\GS\131\DC3\233\213pd\242\131A@\146E\199",PropResponseInformation "\150\241\SI\SYN[\196",PropReasonString "\206Ck\149\215\221",PropReasonString "\223\DC45\167\185\177jw)\164\221:\252\199\147\245\239\147\SOH\v",PropServerKeepAlive 2942] TEST(SubACK5QCTest, Decode18) { - uint8_t pkt[] = { - 0x90, 0xd7, 0x2, 0x61, 0x3b, 0xca, 0x2, 0x3, 0x0, 0x7, 0x1b, 0xe6, 0xde, 0xaf, 0xbb, 0xeb, 0x1f, 0x17, 0xc3, - 0x1c, 0x0, 0x1e, 0x53, 0x4d, 0x6, 0x54, 0xb8, 0xd8, 0x70, 0x3f, 0x52, 0x48, 0x36, 0x4d, 0x3d, 0x71, 0x14, 0x8, - 0x44, 0x9c, 0x80, 0xa0, 0x87, 0xf4, 0xe2, 0x28, 0xe3, 0x35, 0xc1, 0x2e, 0xc8, 0x84, 0x3, 0x0, 0x1d, 0x33, 0xda, - 0xec, 0x6, 0xf3, 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c, 0x66, - 0xca, 0x4b, 0xd2, 0x58, 0xca, 0xe1, 0xda, 0xcf, 0x5b, 0xdb, 0x98, 0x4a, 0xab, 0x24, 0x89, 0x23, 0x51, 0x8b, 0xb, - 0xa, 0x9, 0x0, 0x11, 0xd8, 0xdb, 0x7e, 0x42, 0x2b, 0xe0, 0xb9, 0xa, 0x6d, 0x20, 0x2, 0x40, 0x4, 0xd5, 0xd9, - 0xe2, 0xde, 0x16, 0x0, 0x6, 0x28, 0x7, 0xae, 0x70, 0xb6, 0xb4, 0x23, 0x1c, 0x8b, 0x8, 0x0, 0x10, 0x40, 0xa3, - 0x21, 0x6f, 0x7a, 0xb2, 0x88, 0x9b, 0x2e, 0x2e, 0xa7, 0x9a, 0x8b, 0x72, 0x9, 0x33, 0x17, 0x30, 0x2, 0x0, 0x0, - 0x57, 0x8d, 0x2, 0x0, 0x0, 0x6d, 0x42, 0x24, 0xd6, 0x1, 0x8e, 0x21, 0x68, 0x45, 0x80, 0x91, 0x9e, 0xa2, 0x1, - 0x2, 0x8f, 0x1, 0xa1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24891); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x91); - EXPECT_EQ(granted_qos_levels[2], 0x9E); - EXPECT_EQ(granted_qos_levels[3], 0xA2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0x8F); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0xA1); -} - -// SubscribeResponse 22923 [Right QoS2,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS1] -// [PropMaximumPacketSize 18797,PropResponseInformation -// "\212J\205\SUB\n\241\166\204\142\167\143\158\224\173T\191\130P\238A`Z\FS\ENQ\NAKVM",PropServerReference -// "\165-!\195\&4\ETX1\\3\128Z7\152",PropRequestResponseInformation 221,PropTopicAliasMaximum 3412,PropMaximumPacketSize -// 23942,PropTopicAliasMaximum 19127,PropTopicAliasMaximum 22275,PropSubscriptionIdentifierAvailable -// 180,PropServerKeepAlive 9519,PropMaximumPacketSize 22991,PropRequestResponseInformation 242,PropMaximumPacketSize -// 2183,PropRetainAvailable 122,PropSessionExpiryInterval 11229,PropSubscriptionIdentifierAvailable -// 107,PropSharedSubscriptionAvailable 85,PropRequestProblemInformation 77,PropServerKeepAlive -// 24672,PropMaximumPacketSize 2021,PropMessageExpiryInterval 27111,PropWildcardSubscriptionAvailable -// 84,PropCorrelationData "NR\249\163\ETX\223\227\231",PropReasonString -// "\225\234\202\136\220\134\RSY&\197_\186n\DC3\t;\195g\192\DC3",PropTopicAlias 22559,PropResponseTopic -// "\183\239",PropResponseTopic "Ghf\r+e\215\245Ly\139\173\172\206\v -// \187\137\&0\131\219\225eK;\216\SYN\151\167",PropAssignedClientIdentifier "\187h\219\&3=\226\182\200L\253\206\SO\144"] +uint8_t pkt[] = {0x90, 0xdd, 0x1, 0x58, 0x62, 0xd3, 0x1, 0x3, 0x0, 0x9, 0x15, 0x51, 0x73, 0x9b, 0x86, 0xc3, 0x37, 0xbf, 0xab, 0x8, 0x0, 0x2, 0x7a, 0x97, 0x28, 0x5f, 0x9, 0x0, 0x17, 0x59, 0xb4, 0x8e, 0x12, 0xf9, 0xeb, 0x8d, 0x89, 0xb, 0x5f, 0x8, 0xa6, 0xc5, 0xb0, 0xa, 0xae, 0x6b, 0x2f, 0xed, 0xaf, 0xb5, 0x7b, 0xbe, 0x1c, 0x0, 0x16, 0x58, 0x64, 0xe1, 0x0, 0xbe, 0x6a, 0x7a, 0xd, 0xbb, 0xf7, 0x3, 0x5b, 0x3b, 0xdd, 0xd2, 0xa8, 0xf1, 0x6c, 0x2a, 0xd8, 0x6, 0x1d, 0x28, 0x2e, 0x2a, 0x77, 0x3, 0x0, 0x17, 0xf7, 0xad, 0x92, 0x44, 0xba, 0xa6, 0x73, 0xab, 0x19, 0x73, 0xab, 0xe9, 0x8c, 0x61, 0x45, 0xbc, 0x7a, 0x2e, 0x62, 0x51, 0x7f, 0x8c, 0xe2, 0x28, 0x15, 0x3, 0x0, 0x11, 0x17, 0xbb, 0xca, 0xa2, 0xd4, 0x71, 0x12, 0xd6, 0x5e, 0xb0, 0x83, 0x80, 0x58, 0x24, 0x7d, 0xb9, 0x46, 0x27, 0x0, 0x0, 0x41, 0xbd, 0x1f, 0x0, 0x4, 0x6a, 0x92, 0x7a, 0x99, 0x2a, 0x2b, 0x19, 0x21, 0x2, 0x0, 0x0, 0x2d, 0x3, 0x15, 0x0, 0x4, 0xd5, 0xe, 0xbf, 0xca, 0x3, 0x0, 0xe, 0x1d, 0x83, 0x13, 0xe9, 0xd5, 0x70, 0x64, 0xf2, 0x83, 0x41, 0x40, 0x92, 0x45, 0xc7, 0x1a, 0x0, 0x6, 0x96, 0xf1, 0xf, 0x16, 0x5b, 0xc4, 0x1f, 0x0, 0x6, 0xce, 0x43, 0x6b, 0x95, 0xd7, 0xdd, 0x1f, 0x0, 0x14, 0xdf, 0x14, 0x35, 0xa7, 0xb9, 0xb1, 0x6a, 0x77, 0x29, 0xa4, 0xdd, 0x3a, 0xfc, 0xc7, 0x93, 0xf5, 0xef, 0x93, 0x1, 0xb, 0x13, 0xb, 0x7e, 0x2, 0x1, 0x83, 0x2, 0x2, 0x9e}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 22626); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[2], 0x83); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[5], 0x9E); + +} + + +// SubscribeResponse 22779 [Right QoS0] [PropReceiveMaximum 29958,PropUserProperty "V\171\199J\148\167\152\DC2Y\DEL(\168\222F\189u>y\159(:\230\213(\203\162m\DELs1" "\DLE\230\222\163\163Bhd",PropRequestProblemInformation 33,PropTopicAliasMaximum 13111,PropRequestProblemInformation 159,PropSessionExpiryInterval 24873,PropRequestProblemInformation 74,PropSubscriptionIdentifier 7,PropSessionExpiryInterval 694,PropWillDelayInterval 1746,PropAuthenticationMethod "\ETB\tp9\166\DC3\183",PropMaximumPacketSize 32621,PropServerReference "\151\202^\135\235\227\DLEGFc]\236\142\184\128\248\156]\136\186C",PropPayloadFormatIndicator 120,PropMaximumQoS 100,PropMessageExpiryInterval 11802] TEST(SubACK5QCTest, Decode19) { - uint8_t pkt[] = {0x90, 0xd7, 0x1, 0x59, 0x8b, 0xca, 0x1, 0x27, 0x0, 0x0, 0x49, 0x6d, 0x1a, 0x0, 0x1b, 0xd4, 0x4a, - 0xcd, 0x1a, 0xa, 0xf1, 0xa6, 0xcc, 0x8e, 0xa7, 0x8f, 0x9e, 0xe0, 0xad, 0x54, 0xbf, 0x82, 0x50, 0xee, - 0x41, 0x60, 0x5a, 0x1c, 0x5, 0x15, 0x56, 0x4d, 0x1c, 0x0, 0xd, 0xa5, 0x2d, 0x21, 0xc3, 0x34, 0x3, - 0x31, 0x5c, 0x33, 0x80, 0x5a, 0x37, 0x98, 0x19, 0xdd, 0x22, 0xd, 0x54, 0x27, 0x0, 0x0, 0x5d, 0x86, - 0x22, 0x4a, 0xb7, 0x22, 0x57, 0x3, 0x29, 0xb4, 0x13, 0x25, 0x2f, 0x27, 0x0, 0x0, 0x59, 0xcf, 0x19, - 0xf2, 0x27, 0x0, 0x0, 0x8, 0x87, 0x25, 0x7a, 0x11, 0x0, 0x0, 0x2b, 0xdd, 0x29, 0x6b, 0x2a, 0x55, - 0x17, 0x4d, 0x13, 0x60, 0x60, 0x27, 0x0, 0x0, 0x7, 0xe5, 0x2, 0x0, 0x0, 0x69, 0xe7, 0x28, 0x54, - 0x9, 0x0, 0x8, 0x4e, 0x52, 0xf9, 0xa3, 0x3, 0xdf, 0xe3, 0xe7, 0x1f, 0x0, 0x14, 0xe1, 0xea, 0xca, - 0x88, 0xdc, 0x86, 0x1e, 0x59, 0x26, 0xc5, 0x5f, 0xba, 0x6e, 0x13, 0x9, 0x3b, 0xc3, 0x67, 0xc0, 0x13, - 0x23, 0x58, 0x1f, 0x8, 0x0, 0x2, 0xb7, 0xef, 0x8, 0x0, 0x1d, 0x47, 0x68, 0x66, 0xd, 0x2b, 0x65, - 0xd7, 0xf5, 0x4c, 0x79, 0x8b, 0xad, 0xac, 0xce, 0xb, 0x20, 0xbb, 0x89, 0x30, 0x83, 0xdb, 0xe1, 0x65, - 0x4b, 0x3b, 0xd8, 0x16, 0x97, 0xa7, 0x12, 0x0, 0xd, 0xbb, 0x68, 0xdb, 0x33, 0x3d, 0xe2, 0xb6, 0xc8, - 0x4c, 0xfd, 0xce, 0xe, 0x90, 0x2, 0x1, 0xa1, 0x0, 0xa2, 0x2, 0x2, 0x8f, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 22923); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0xA1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0xA2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], 0x8F); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); -} - -// SubscribeResponse 25337 [Right QoS2,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS1,Right QoS2,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported] [PropPayloadFormatIndicator 154,PropSharedSubscriptionAvailable -// 144,PropMaximumPacketSize 754,PropReceiveMaximum 29505,PropMessageExpiryInterval 25170,PropCorrelationData -// "\251nd\185V\225",PropAuthenticationData "\b\238\196\244\194\139\SI\182\170\245G\242",PropMaximumQoS -// 136,PropMaximumQoS 45,PropSessionExpiryInterval 23317,PropSessionExpiryInterval 15511,PropSubscriptionIdentifier -// 0,PropMaximumPacketSize 28677,PropAssignedClientIdentifier -// "\236\173\NUL\195\229\191\219\131\177\150B\rLw\231A\153\144HeA?\185\130h\157",PropPayloadFormatIndicator -// 13,PropSharedSubscriptionAvailable 132,PropResponseInformation "\253",PropMaximumPacketSize -// 13780,PropAuthenticationMethod "\t\190G^V\252\224\129&%\204\193\238\140\190|\163",PropRequestProblemInformation -// 15,PropAssignedClientIdentifier ",\195\224\190\151\SOH p\197\DC4\141\203\&3\168bczA\141\142\USq\209",PropReasonString -// "\180\SYN",PropUserProperty "hLv\163KA\DC2x\225\199\169l\SOHI\177\135Vb\132\164\146\141\235\DELpM-\232\135" -// "\216\255\147\186%\182]f}\189.\168\NAK\152\235h\243\192p?"] +uint8_t pkt[] = {0x90, 0x7c, 0x58, 0xfb, 0x78, 0x21, 0x75, 0x6, 0x26, 0x0, 0x1e, 0x56, 0xab, 0xc7, 0x4a, 0x94, 0xa7, 0x98, 0x12, 0x59, 0x7f, 0x28, 0xa8, 0xde, 0x46, 0xbd, 0x75, 0x3e, 0x79, 0x9f, 0x28, 0x3a, 0xe6, 0xd5, 0x28, 0xcb, 0xa2, 0x6d, 0x7f, 0x73, 0x31, 0x0, 0x8, 0x10, 0xe6, 0xde, 0xa3, 0xa3, 0x42, 0x68, 0x64, 0x17, 0x21, 0x22, 0x33, 0x37, 0x17, 0x9f, 0x11, 0x0, 0x0, 0x61, 0x29, 0x17, 0x4a, 0xb, 0x7, 0x11, 0x0, 0x0, 0x2, 0xb6, 0x18, 0x0, 0x0, 0x6, 0xd2, 0x15, 0x0, 0x7, 0x17, 0x9, 0x70, 0x39, 0xa6, 0x13, 0xb7, 0x27, 0x0, 0x0, 0x7f, 0x6d, 0x1c, 0x0, 0x15, 0x97, 0xca, 0x5e, 0x87, 0xeb, 0xe3, 0x10, 0x47, 0x46, 0x63, 0x5d, 0xec, 0x8e, 0xb8, 0x80, 0xf8, 0x9c, 0x5d, 0x88, 0xba, 0x43, 0x1, 0x78, 0x24, 0x64, 0x2, 0x0, 0x0, 0x2e, 0x1a, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[1]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 1, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 22779); +EXPECT_EQ(count, 1); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + +} + + +// SubscribeResponse 12719 [Left SubErrNotAuthorized,Right QoS0] [PropServerReference "On\212\204\ACK\209\154\SYN\211\240\142\200\150e\196\205\231\182k#zX\243\133\134\252\185",PropMessageExpiryInterval 8103,PropRetainAvailable 64,PropRequestProblemInformation 145,PropWillDelayInterval 29614,PropRequestProblemInformation 189,PropAssignedClientIdentifier "\SUB\170",PropTopicAlias 12053,PropServerReference "",PropServerKeepAlive 16570,PropAuthenticationData "a\255\197g\177(\228\\\145\SYN\208&l",PropContentType "\201\&1\255\&5\140L\239J^'\200I\158\199,$\164\214\213",PropMaximumQoS 168,PropAuthenticationMethod "\161\202\242?\244\&9\149\181\177\169v \217",PropResponseTopic "\207T\201-\208\160\192\248\vWR\179\132",PropReasonString "\146i\153\200\b\\b\232\157a--_\155e\192",PropRetainAvailable 3,PropCorrelationData "\141",PropSharedSubscriptionAvailable 187,PropResponseTopic "\CAN\133\226qc\NUL\150\134\154\SUB5&\225Y1&\a}\173\255\133\148z@\207",PropCorrelationData "M,\EM7\137\200\US\159{",PropTopicAlias 24670,PropMaximumPacketSize 19132,PropAssignedClientIdentifier "8\160AH\SI\RS\ng\200\&9P\217\240\&0\236\168\164f&\t",PropRetainAvailable 254,PropAuthenticationMethod "\254\154'i\SUB\DC2\"K\179><\r\188\CAN9\252>\195\DC3\ETX\147g\188\&5\132l"] TEST(SubACK5QCTest, Decode20) { - uint8_t pkt[] = { - 0x90, 0xde, 0x1, 0x62, 0xf9, 0xd3, 0x1, 0x1, 0x9a, 0x2a, 0x90, 0x27, 0x0, 0x0, 0x2, 0xf2, 0x21, 0x73, 0x41, - 0x2, 0x0, 0x0, 0x62, 0x52, 0x9, 0x0, 0x6, 0xfb, 0x6e, 0x64, 0xb9, 0x56, 0xe1, 0x16, 0x0, 0xc, 0x8, 0xee, - 0xc4, 0xf4, 0xc2, 0x8b, 0xf, 0xb6, 0xaa, 0xf5, 0x47, 0xf2, 0x24, 0x88, 0x24, 0x2d, 0x11, 0x0, 0x0, 0x5b, 0x15, - 0x11, 0x0, 0x0, 0x3c, 0x97, 0xb, 0x0, 0x27, 0x0, 0x0, 0x70, 0x5, 0x12, 0x0, 0x1a, 0xec, 0xad, 0x0, 0xc3, - 0xe5, 0xbf, 0xdb, 0x83, 0xb1, 0x96, 0x42, 0xd, 0x4c, 0x77, 0xe7, 0x41, 0x99, 0x90, 0x48, 0x65, 0x41, 0x3f, 0xb9, - 0x82, 0x68, 0x9d, 0x1, 0xd, 0x2a, 0x84, 0x1a, 0x0, 0x1, 0xfd, 0x27, 0x0, 0x0, 0x35, 0xd4, 0x15, 0x0, 0x11, - 0x9, 0xbe, 0x47, 0x5e, 0x56, 0xfc, 0xe0, 0x81, 0x26, 0x25, 0xcc, 0xc1, 0xee, 0x8c, 0xbe, 0x7c, 0xa3, 0x17, 0xf, - 0x12, 0x0, 0x17, 0x2c, 0xc3, 0xe0, 0xbe, 0x97, 0x1, 0x20, 0x70, 0xc5, 0x14, 0x8d, 0xcb, 0x33, 0xa8, 0x62, 0x63, - 0x7a, 0x41, 0x8d, 0x8e, 0x1f, 0x71, 0xd1, 0x1f, 0x0, 0x2, 0xb4, 0x16, 0x26, 0x0, 0x1d, 0x68, 0x4c, 0x76, 0xa3, - 0x4b, 0x41, 0x12, 0x78, 0xe1, 0xc7, 0xa9, 0x6c, 0x1, 0x49, 0xb1, 0x87, 0x56, 0x62, 0x84, 0xa4, 0x92, 0x8d, 0xeb, - 0x7f, 0x70, 0x4d, 0x2d, 0xe8, 0x87, 0x0, 0x14, 0xd8, 0xff, 0x93, 0xba, 0x25, 0xb6, 0x5d, 0x66, 0x7d, 0xbd, 0x2e, - 0xa8, 0x15, 0x98, 0xeb, 0x68, 0xf3, 0xc0, 0x70, 0x3f, 0x2, 0x1, 0x8f, 0x1, 0x2, 0x0, 0x9e}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25337); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x8F); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x9E); -} - -// SubscribeResponse 1262 [Left SubErrPacketIdentifierInUse,Right QoS0,Left SubErrPacketIdentifierInUse,Left -// SubErrImplementationSpecificError,Left SubErrImplementationSpecificError,Right QoS0,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrNotAuthorized,Right QoS2] [PropContentType -// "\242&\EOT-\\krC\197\234\&9J3\153GT",PropPayloadFormatIndicator 232,PropSharedSubscriptionAvailable -// 141,PropRetainAvailable 246,PropCorrelationData ">C\SUB\157.\208q\234\138\170lo\247\158\196\202",PropTopicAlias -// 31744,PropWildcardSubscriptionAvailable 209,PropMaximumQoS 222,PropMessageExpiryInterval 13653,PropUserProperty -// "\214G\194\254BG\220\253\136\252\149t\\~2\196\DLE\219\255\141\DC1o^" -// "u\151\220\DC3\151\DLE\248\&5\225\&9V$\145\"\f\173\f_\192}\DC1ynR\254\ESC$\239U@",PropWillDelayInterval -// 21923,PropAuthenticationData "\171h\DC4\156\n\222\136J",PropTopicAliasMaximum 1295,PropResponseTopic -// "z\134\&4\202*2\176\208S\224\\_/j\"",PropUserProperty "K\218\DC10\SUB\203" -// "\ESC\175\216?(~\212\192]\204\&8m\137\145q\195B"] +uint8_t pkt[] = {0x90, 0x8b, 0x2, 0x31, 0xaf, 0x85, 0x2, 0x1c, 0x0, 0x1b, 0x4f, 0x6e, 0xd4, 0xcc, 0x6, 0xd1, 0x9a, 0x16, 0xd3, 0xf0, 0x8e, 0xc8, 0x96, 0x65, 0xc4, 0xcd, 0xe7, 0xb6, 0x6b, 0x23, 0x7a, 0x58, 0xf3, 0x85, 0x86, 0xfc, 0xb9, 0x2, 0x0, 0x0, 0x1f, 0xa7, 0x25, 0x40, 0x17, 0x91, 0x18, 0x0, 0x0, 0x73, 0xae, 0x17, 0xbd, 0x12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 0x9a, 0x27, 0x69, 0x1a, 0x12, 0x22, 0x4b, 0xb3, 0x3e, 0x3c, 0xd, 0xbc, 0x18, 0x39, 0xfc, 0x3e, 0xc3, 0x13, 0x3, 0x93, 0x67, 0xbc, 0x35, 0x84, 0x6c, 0x87, 0x0}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[2]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 2, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 12719); +EXPECT_EQ(count, 2); +EXPECT_EQ(granted_qos_levels[0], 0x87); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + +} + + +// SubscribeResponse 18524 [Right QoS2] [PropMaximumPacketSize 20730,PropWillDelayInterval 25373,PropSubscriptionIdentifierAvailable 57,PropWillDelayInterval 24371,PropRetainAvailable 14,PropRequestResponseInformation 160,PropAssignedClientIdentifier "4aG\n\131\189t\148\217b\209\209k\251\DC3\205\&5\186\173\133G.\147\145",PropTopicAliasMaximum 30097,PropPayloadFormatIndicator 113,PropWildcardSubscriptionAvailable 52,PropReasonString "q\SOHAL\FS\164vC\145\154\250\244\"\167\246\ESC",PropRequestResponseInformation 19] TEST(SubACK5QCTest, Decode21) { - uint8_t pkt[] = { - 0x90, 0xa5, 0x2, 0x4, 0xee, 0x97, 0x2, 0x3, 0x0, 0x10, 0xf2, 0x26, 0x4, 0x2d, 0x5c, 0x6b, 0x72, 0x43, 0xc5, - 0xea, 0x39, 0x4a, 0x33, 0x99, 0x47, 0x54, 0x1, 0xe8, 0x2a, 0x8d, 0x25, 0xf6, 0x9, 0x0, 0x10, 0x3e, 0x43, 0x1a, - 0x9d, 0x2e, 0xd0, 0x71, 0xea, 0x8a, 0xaa, 0x6c, 0x6f, 0xf7, 0x9e, 0xc4, 0xca, 0x23, 0x7c, 0x0, 0x28, 0xd1, 0x24, - 0xde, 0x2, 0x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 0xb0, 0xd0, 0x53, 0xe0, 0x5c, 0x5f, 0x2f, 0x6a, 0x22, 0x26, 0x0, 0x6, 0x4b, 0xda, 0x11, 0x30, 0x1a, - 0xcb, 0x0, 0x11, 0x1b, 0xaf, 0xd8, 0x3f, 0x28, 0x7e, 0xd4, 0xc0, 0x5d, 0xcc, 0x38, 0x6d, 0x89, 0x91, 0x71, 0xc3, - 0x42, 0x91, 0x0, 0x91, 0x83, 0x83, 0x0, 0x0, 0x9e, 0x87, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1262); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x91); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x91); - EXPECT_EQ(granted_qos_levels[3], 0x83); - EXPECT_EQ(granted_qos_levels[4], 0x83); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x9E); - EXPECT_EQ(granted_qos_levels[8], 0x87); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); -} - -// SubscribeResponse 21462 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right -// QoS1,Right QoS2,Right QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrTopicFilterInvalid,Left -// SubErrImplementationSpecificError,Right QoS2,Left SubErrNotAuthorized] [PropServerKeepAlive -// 14397,PropSubscriptionIdentifier 32,PropTopicAliasMaximum 5258,PropCorrelationData -// "\ETBr\207\&0\138\175",PropMaximumPacketSize 2747,PropPayloadFormatIndicator 98,PropCorrelationData -// "\185\CANk\215\190*\211\174h\137t\163\154A",PropSubscriptionIdentifier 4,PropAuthenticationData -// "\n9?\132\SUBr\240\DEL\199\131\SYN\230f\132<\218\211\FS\DLE5\223\FS\213\n1\176j\144\129",PropTopicAlias -// 18531,PropSubscriptionIdentifierAvailable 150,PropRequestResponseInformation 101] +uint8_t pkt[] = {0x90, 0x3e, 0x31, 0x99, 0x35, 0x19, 0x41, 0x29, 0x96, 0x1f, 0x0, 0x7, 0x29, 0x8, 0xdf, 0xd5, 0xad, 0x29, 0x1d, 0x26, 0x0, 0x0, 0x0, 0x9, 0xa0, 0x29, 0x92, 0xc, 0xa7, 0x14, 0x69, 0x5c, 0x92, 0x2, 0x0, 0x0, 0x6c, 0x5b, 0x19, 0x57, 0x16, 0x0, 0x6, 0x5f, 0x81, 0x5b, 0x30, 0x5d, 0x96, 0x19, 0x51, 0x24, 0xea, 0x2, 0x0, 0x0, 0x2, 0xad, 0x91, 0x91, 0xa2, 0x9e, 0xa1, 0x87}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 12697); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], 0x91); +EXPECT_EQ(granted_qos_levels[1], 0x91); +EXPECT_EQ(granted_qos_levels[2], 0xA2); +EXPECT_EQ(granted_qos_levels[3], 0x9E); +EXPECT_EQ(granted_qos_levels[4], 0xA1); +EXPECT_EQ(granted_qos_levels[5], 0x87); + +} + + +// SubscribeResponse 1694 [Left SubErrSubscriptionIdentifiersNotSupported] [PropSubscriptionIdentifier 29,PropRequestResponseInformation 43,PropMaximumPacketSize 2393,PropServerReference "`\253ve\"\180\148jD\DLEh\181?\225\205\ETB|\150)\DC2B\237|\155\191\EMi\ETX",PropWillDelayInterval 2584,PropServerReference "\152\129\248\ETB=\210\"\132",PropResponseTopic "\164I4uR\"\CAN/\218\252",PropRequestResponseInformation 236,PropWillDelayInterval 10307,PropMaximumPacketSize 21415,PropMessageExpiryInterval 11498,PropAssignedClientIdentifier "VB\b\171vn\237D\128\145\189\DEL\135\FS\235\185\238\SO\128\140\STX",PropReasonString "\204\188\153\162\248\a\SO\187\162Z\224R\252h?\\M \207W\238F\DC2p$\241K\234\171\240",PropReasonString "\198\194\180\NUL",PropResponseTopic "]",PropAuthenticationMethod "\187\196\SO\248\161\215T\166\252\237\248\ETX\177\241\ETB\169\SO\175\&6\151\&4H"] TEST(SubACK5QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0x76, 0x2f, 0x2c, 0x6e, 0xb, 0x0, 0x25, 0xca, 0x26, 0x0, 0x1a, 0xe8, 0xb4, 0x81, - 0xd1, 0x70, 0xd8, 0x6f, 0x93, 0xff, 0x7a, 0x6f, 0xf6, 0x12, 0x25, 0x62, 0xe1, 0xae, 0x54, - 0x38, 0x35, 0x1e, 0xed, 0xea, 0x43, 0xa2, 0x24, 0x0, 0xa, 0xa1, 0xf7, 0x7b, 0xcc, 0x48, - 0xbd, 0xe9, 0x3e, 0x8a, 0xaf, 0x27, 0x0, 0x0, 0xa, 0xbb, 0x1, 0x62, 0x9, 0x0, 0xe, - 0xb9, 0x18, 0x6b, 0xd7, 0xbe, 0x2a, 0xd3, 0xae, 0x68, 0x89, 0x74, 0xa3, 0x9a, 0x41, 0xb, - 0x4, 0x16, 0x0, 0x1d, 0xa, 0x39, 0x3f, 0x84, 0x1a, 0x72, 0xf0, 0x7f, 0xc7, 0x83, 0x16, - 0xe6, 0x66, 0x84, 0x3c, 0xda, 0xd3, 0x1c, 0x10, 0x35, 0xdf, 0x1c, 0xd5, 0xa, 0x31, 0xb0, - 0x6a, 0x90, 0x81, 0x23, 0x48, 0x63, 0x29, 0x96, 0x19, 0x65, 0xa1, 0x83, 0x2, 0x0, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12076); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0xA1); - EXPECT_EQ(granted_qos_levels[1], 0x83); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); -} - -// SubscribeResponse 3799 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrImplementationSpecificError,Left SubErrTopicFilterInvalid,Right QoS2,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS0] [PropSubscriptionIdentifier -// 16,PropAuthenticationMethod "",PropMaximumQoS 79,PropMessageExpiryInterval 18369,PropSubscriptionIdentifier -// 30,PropUserProperty "GQ\178\234\199\215\189\173TYU\202\221\201\238\192j\156\DC3e\196\150\b\236<" " -// \236\149-!\251\238\EOT9E\158\204",PropMaximumPacketSize 22281,PropServerKeepAlive 17526,PropResponseTopic -// "\231\146",PropAuthenticationData "9\141\&6s\243s\152\156\247\183\191.\DC3\192/^\225\193u",PropServerKeepAlive -// 28155,PropAssignedClientIdentifier "\144\140#;\RS\154\234\231",PropCorrelationData -// "Ug\228\168\NAK`\RS{\157O\152\&5\157)\237",PropMaximumPacketSize 12102,PropRetainAvailable 214,PropMaximumPacketSize -// 24583,PropTopicAliasMaximum 10997,PropRetainAvailable 249,PropServerKeepAlive 5371,PropUserProperty -// "yR\ACK1\228c\145\139S\SO-\161\239\170\215\252\165\254" -// "a\197\136\224\158\ESC\NUL\237\&9\139\157l\GS\f\f9\SO6",PropRetainAvailable 37,PropSharedSubscriptionAvailable -// 8,PropRequestResponseInformation 161,PropPayloadFormatIndicator 192,PropWillDelayInterval -// 14103,PropMessageExpiryInterval 3544,PropPayloadFormatIndicator 166,PropServerKeepAlive 1582] +uint8_t pkt[] = {0x90, 0xb8, 0x1, 0x6, 0x9e, 0xb3, 0x1, 0xb, 0x1d, 0x19, 0x2b, 0x27, 0x0, 0x0, 0x9, 0x59, 0x1c, 0x0, 0x1c, 0x60, 0xfd, 0x76, 0x65, 0x22, 0xb4, 0x94, 0x6a, 0x44, 0x10, 0x68, 0xb5, 0x3f, 0xe1, 0xcd, 0x17, 0x7c, 0x96, 0x29, 0x12, 0x42, 0xed, 0x7c, 0x9b, 0xbf, 0x19, 0x69, 0x3, 0x18, 0x0, 0x0, 0xa, 0x18, 0x1c, 0x0, 0x8, 0x98, 0x81, 0xf8, 0x17, 0x3d, 0xd2, 0x22, 0x84, 0x8, 0x0, 0xa, 0xa4, 0x49, 0x34, 0x75, 0x52, 0x22, 0x18, 0x2f, 0xda, 0xfc, 0x19, 0xec, 0x18, 0x0, 0x0, 0x28, 0x43, 0x27, 0x0, 0x0, 0x53, 0xa7, 0x2, 0x0, 0x0, 0x2c, 0xea, 0x12, 0x0, 0x15, 0x56, 0x42, 0x8, 0xab, 0x76, 0x6e, 0xed, 0x44, 0x80, 0x91, 0xbd, 0x7f, 0x87, 0x1c, 0xeb, 0xb9, 0xee, 0xe, 0x80, 0x8c, 0x2, 0x1f, 0x0, 0x1e, 0xcc, 0xbc, 0x99, 0xa2, 0xf8, 0x7, 0xe, 0xbb, 0xa2, 0x5a, 0xe0, 0x52, 0xfc, 0x68, 0x3f, 0x5c, 0x4d, 0x20, 0xcf, 0x57, 0xee, 0x46, 0x12, 0x70, 0x24, 0xf1, 0x4b, 0xea, 0xab, 0xf0, 0x1f, 0x0, 0x4, 0xc6, 0xc2, 0xb4, 0x0, 0x8, 0x0, 0x1, 0x5d, 0x15, 0x0, 0x16, 0xbb, 0xc4, 0xe, 0xf8, 0xa1, 0xd7, 0x54, 0xa6, 0xfc, 0xed, 0xf8, 0x3, 0xb1, 0xf1, 0x17, 0xa9, 0xe, 0xaf, 0x36, 0x97, 0x34, 0x48, 0xa1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[1]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 1, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 1694); +EXPECT_EQ(count, 1); +EXPECT_EQ(granted_qos_levels[0], 0xA1); + +} + + +// SubscribeResponse 30899 [Right QoS1] [PropReceiveMaximum 27644,PropReceiveMaximum 8426,PropAuthenticationMethod "\245\194\219\EOT\156",PropTopicAlias 5286,PropMessageExpiryInterval 19925,PropMaximumQoS 126,PropWillDelayInterval 3267,PropMessageExpiryInterval 21796,PropReasonString "\174a\208\rg\222\233Z\129\163\150\&6\185\248,O\128\237",PropAuthenticationData "",PropReasonString "\EOT\t\173\&9\255\216LP\138'\EM\170x\198\235\a\CAN\196\217E!\EM\239\DC2",PropServerReference "29\139D\215\128\151\198\190\247\205)r\DC4\DC4Y\178\DC1\131",PropSubscriptionIdentifier 3,PropRequestResponseInformation 129,PropReasonString "\133\&5\EM\RS<\DEL\228\157|\215\244|\143\231\219\173Ol~V\166\162x\235E}\193\ENQ\218V",PropRequestResponseInformation 21,PropRequestResponseInformation 29,PropResponseInformation "R\151fy\168\191\234\146\"\CAN_\181\&4\"\223m\243A\NAK",PropResponseInformation "W\207v\217\244D!y\242\ACK",PropMessageExpiryInterval 9026,PropResponseInformation "\ESCvURy\155\138\133\253\143\ESC\254",PropContentType "\225\135\187\173\171\v.\243R\133\252\253\STX",PropContentType "]\206\US\t\139",PropAuthenticationData "\182\184\223D\211\ETX\243 )\139\156\251\&1\227\248"] TEST(SubACK5QCTest, Decode24) { - uint8_t pkt[] = { - 0x90, 0xdb, 0x1, 0xe, 0xd7, 0xcf, 0x1, 0xb, 0x10, 0x15, 0x0, 0x0, 0x24, 0x4f, 0x2, 0x0, 0x0, 0x47, 0xc1, - 0xb, 0x1e,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 0xa6, 0x13, 0x6, 0x2e, 0x2, 0xa2, 0x83, 0x8f, 0x2, 0xa2, 0x2, 0x0}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3799); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0xA2); - EXPECT_EQ(granted_qos_levels[2], 0x83); - EXPECT_EQ(granted_qos_levels[3], 0x8F); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0xA2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); -} - -// SubscribeResponse 15314 [Left SubErrUnspecifiedError,Left SubErrTopicFilterInvalid,Left -// SubErrImplementationSpecificError] [PropServerKeepAlive 8169,PropAssignedClientIdentifier -// "\158\DC2x\SUB\168\174\218",PropMessageExpiryInterval 31274] +uint8_t pkt[] = {0x90, 0xfa, 0x1, 0x78, 0xb3, 0xf5, 0x1, 0x21, 0x6b, 0xfc, 0x21, 0x20, 0xea, 0x15, 0x0, 0x5, 0xf5, 0xc2, 0xdb, 0x4, 0x9c, 0x23, 0x14, 0xa6, 0x2, 0x0, 0x0, 0x4d, 0xd5, 0x24, 0x7e, 0x18, 0x0, 0x0, 0xc, 0xc3, 0x2, 0x0, 0x0, 0x55, 0x24, 0x1f, 0x0, 0x12, 0xae, 0x61, 0xd0, 0xd, 0x67, 0xde, 0xe9, 0x5a, 0x81, 0xa3, 0x96, 0x36, 0xb9, 0xf8, 0x2c, 0x4f, 0x80, 0xed, 0x16, 0x0, 0x0, 0x1f, 0x0, 0x18, 0x4, 0x9, 0xad, 0x39, 0xff, 0xd8, 0x4c, 0x50, 0x8a, 0x27, 0x19, 0xaa, 0x78, 0xc6, 0xeb, 0x7, 0x18, 0xc4, 0xd9, 0x45, 0x21, 0x19, 0xef, 0x12, 0x1c, 0x0, 0x13, 0x32, 0x39, 0x8b, 0x44, 0xd7, 0x80, 0x97, 0xc6, 0xbe, 0xf7, 0xcd, 0x29, 0x72, 0x14, 0x14, 0x59, 0xb2, 0x11, 0x83, 0xb, 0x3, 0x19, 0x81, 0x1f, 0x0, 0x1e, 0x85, 0x35, 0x19, 0x1e, 0x3c, 0x7f, 0xe4, 0x9d, 0x7c, 0xd7, 0xf4, 0x7c, 0x8f, 0xe7, 0xdb, 0xad, 0x4f, 0x6c, 0x7e, 0x56, 0xa6, 0xa2, 0x78, 0xeb, 0x45, 0x7d, 0xc1, 0x5, 0xda, 0x56, 0x19, 0x15, 0x19, 0x1d, 0x1a, 0x0, 0x13, 0x52, 0x97, 0x66, 0x79, 0xa8, 0xbf, 0xea, 0x92, 0x22, 0x18, 0x5f, 0xb5, 0x34, 0x22, 0xdf, 0x6d, 0xf3, 0x41, 0x15, 0x1a, 0x0, 0xa, 0x57, 0xcf, 0x76, 0xd9, 0xf4, 0x44, 0x21, 0x79, 0xf2, 0x6, 0x2, 0x0, 0x0, 0x23, 0x42, 0x1a, 0x0, 0xc, 0x1b, 0x76, 0x55, 0x52, 0x79, 0x9b, 0x8a, 0x85, 0xfd, 0x8f, 0x1b, 0xfe, 0x3, 0x0, 0xd, 0xe1, 0x87, 0xbb, 0xad, 0xab, 0xb, 0x2e, 0xf3, 0x52, 0x85, 0xfc, 0xfd, 0x2, 0x3, 0x0, 0x5, 0x5d, 0xce, 0x1f, 0x9, 0x8b, 0x16, 0x0, 0xf, 0xb6, 0xb8, 0xdf, 0x44, 0xd3, 0x3, 0xf3, 0x20, 0x29, 0x8b, 0x9c, 0xfb, 0x31, 0xe3, 0xf8, 0x1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[1]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 1, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 30899); +EXPECT_EQ(count, 1); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + +} + + +// SubscribeResponse 15 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS2] [PropMaximumQoS 216,PropServerReference "A1\"\208\250\203&",PropWildcardSubscriptionAvailable 128,PropMaximumPacketSize 15978,PropUserProperty "W\146\r$\SI\aP&\149|v\208\222\US\128C\217\&4\159\209\128Z@Z" "\CAN+2\131\218!ZZz\192\142",PropResponseTopic ".\216\246&\RSF\130\136k\159\&3\197_[\138\v\145",PropSessionExpiryInterval 29247,PropServerKeepAlive 20272,PropCorrelationData "~N\219\182!\f^\247\172\ACK\148\254\153\159\221\208\129\FS\141\CAN\177\213C\219\135rU",PropResponseTopic "HU\222\186tp\236\RS(\174w\249\GS\220\NAK3t\156\160\147a\145w",PropMessageExpiryInterval 23404,PropMaximumQoS 41] TEST(SubACK5QCTest, Decode25) { - uint8_t pkt[] = {0x90, 0x18, 0x3b, 0xd2, 0x12, 0x13, 0x1f, 0xe9, 0x12, 0x0, 0x7, 0x9e, 0x12, - 0x78, 0x1a, 0xa8, 0xae, 0xda, 0x2, 0x0, 0x0, 0x7a, 0x2a, 0x80, 0x8f, 0x83}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15314); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x8F); - EXPECT_EQ(granted_qos_levels[2], 0x83); -} - -// SubscribeResponse 19515 [Left SubErrNotAuthorized,Right QoS1,Right QoS2,Left SubErrPacketIdentifierInUse,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Left SubErrUnspecifiedError,Left -// SubErrSubscriptionIdentifiersNotSupported] [PropResponseTopic -// "\237\247`\NAK$\145\201\234*\STX\SYN\132d\ETX\EOT\DC2\236J\146\150\173\ENQX\ETX\219\170",PropRequestProblemInformation -// 238,PropRequestProblemInformation 125,PropResponseTopic "[L\137:RM\218\156C\172O!v\205",PropSessionExpiryInterval -// 3981,PropMessageExpiryInterval 2864,PropSharedSubscriptionAvailable 238,PropRequestProblemInformation -// 69,PropRetainAvailable 199,PropWildcardSubscriptionAvailable 7,PropMessageExpiryInterval 1188,PropMaximumQoS -// 57,PropRequestProblemInformation 236,PropWillDelayInterval 7491,PropAssignedClientIdentifier -// "r\250\136\152B&\204\241/0U\bs\216\ESCVG\217\255",PropResponseInformation -// "\133\184\225\145\135\217]FK\203\f\DC3\187\139l\173\184"] +uint8_t pkt[] = {0x90, 0xa0, 0x1, 0x0, 0xf, 0x96, 0x1, 0x24, 0xd8, 0x1c, 0x0, 0x7, 0x41, 0x31, 0x22, 0xd0, 0xfa, 0xcb, 0x26, 0x28, 0x80, 0x27, 0x0, 0x0, 0x3e, 0x6a, 0x26, 0x0, 0x18, 0x57, 0x92, 0xd, 0x24, 0xf, 0x7, 0x50, 0x26, 0x95, 0x7c, 0x76, 0xd0, 0xde, 0x1f, 0x80, 0x43, 0xd9, 0x34, 0x9f, 0xd1, 0x80, 0x5a, 0x40, 0x5a, 0x0, 0xb, 0x18, 0x2b, 0x32, 0x83, 0xda, 0x21, 0x5a, 0x5a, 0x7a, 0xc0, 0x8e, 0x8, 0x0, 0x11, 0x2e, 0xd8, 0xf6, 0x26, 0x1e, 0x46, 0x82, 0x88, 0x6b, 0x9f, 0x33, 0xc5, 0x5f, 0x5b, 0x8a, 0xb, 0x91, 0x11, 0x0, 0x0, 0x72, 0x3f, 0x13, 0x4f, 0x30, 0x9, 0x0, 0x1b, 0x7e, 0x4e, 0xdb, 0xb6, 0x21, 0xc, 0x5e, 0xf7, 0xac, 0x6, 0x94, 0xfe, 0x99, 0x9f, 0xdd, 0xd0, 0x81, 0x1c, 0x8d, 0x18, 0xb1, 0xd5, 0x43, 0xdb, 0x87, 0x72, 0x55, 0x8, 0x0, 0x17, 0x48, 0x55, 0xde, 0xba, 0x74, 0x70, 0xec, 0x1e, 0x28, 0xae, 0x77, 0xf9, 0x1d, 0xdc, 0x15, 0x33, 0x74, 0x9c, 0xa0, 0x93, 0x61, 0x91, 0x77, 0x2, 0x0, 0x0, 0x5b, 0x6c, 0x24, 0x29, 0xa1, 0x2, 0x2, 0x9e, 0x0, 0x2}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 15); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], 0xA1); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[3], 0x9E); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + +} + + +// SubscribeResponse 13923 [Right QoS2,Left SubErrNotAuthorized,Right QoS1,Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded] [PropContentType "\DC3\SUB@,\185k\226",PropSubscriptionIdentifier 12,PropMessageExpiryInterval 9419,PropReceiveMaximum 31538,PropServerReference "\154\168\128c",PropTopicAliasMaximum 16842,PropServerReference "aXA\247\138<\132:\161\198v",PropMaximumQoS 114,PropMessageExpiryInterval 15881,PropReceiveMaximum 9017,PropSharedSubscriptionAvailable 191,PropUserProperty "" "\NAK\193Ab\228\&4_\150\DEL\rd\128{\208I\163)/\SI\188\255\&1\132",PropUserProperty "\203\173\DC41\139\160\252" "\DC2r\208",PropUserProperty "\145s\208\152\243q\CAN\SYNbG\154J\144\193\157&\SOH\131k\250" "]L\172\152",PropMessageExpiryInterval 2098,PropServerReference "\154\203\&6\ETX\n\EOT\136P\186\208w6\215\143:_\EOT\254R\213L*^#\193E\142i",PropSubscriptionIdentifierAvailable 127,PropMaximumQoS 12,PropMaximumQoS 156] TEST(SubACK5QCTest, Decode26) { - uint8_t pkt[] = {0x90, 0x88, 0x1, 0x4c, 0x3b, 0x7c, 0x8, 0x0, 0x1a, 0xed, 0xf7, 0x60, 0x15, 0x24, 0x91, 0xc9, - 0xea, 0x2a, 0x2, 0x16, 0x84, 0x64, 0x3, 0x4, 0x12, 0xec, 0x4a, 0x92, 0x96, 0xad, 0x5, 0x58, - 0x3, 0xdb, 0xaa, 0x17, 0xee, 0x17, 0x7d, 0x8, 0x0, 0xe, 0x5b, 0x4c, 0x89, 0x3a, 0x52, 0x4d, - 0xda, 0x9c, 0x43, 0xac, 0x4f, 0x21, 0x76, 0xcd, 0x11, 0x0, 0x0, 0xf, 0x8d, 0x2, 0x0, 0x0, - 0xb, 0x30, 0x2a, 0xee, 0x17, 0x45, 0x25, 0xc7, 0x28, 0x7, 0x2, 0x0, 0x0, 0x4, 0xa4, 0x24, - 0x39, 0x17, 0xec, 0x18, 0x0, 0x0, 0x1d, 0x43, 0x12, 0x0, 0x13, 0x72, 0xfa, 0x88, 0x98, 0x42, - 0x26, 0xcc, 0xf1, 0x2f, 0x30, 0x55, 0x8, 0x73, 0xd8, 0x1b, 0x56, 0x47, 0xd9, 0xff, 0x1a, 0x0, - 0x11, 0x85, 0xb8, 0xe1, 0x91, 0x87, 0xd9, 0x5d, 0x46, 0x4b, 0xcb, 0xc, 0x13, 0xbb, 0x8b, 0x6c, - 0xad, 0xb8, 0x87, 0x1, 0x2, 0x91, 0x9e, 0x80, 0x0, 0x80, 0xa1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19515); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x87); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x91); - EXPECT_EQ(granted_qos_levels[4], 0x9E); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0xA1); -} - -// SubscribeResponse 14835 [Right QoS2,Right QoS2,Right QoS1,Left SubErrUnspecifiedError,Left -// SubErrImplementationSpecificError,Left SubErrNotAuthorized,Right QoS2] [PropCorrelationData -// "\188\STXP\176*.\244\176`\198\DC1l=Ra\251\226\231",PropMaximumPacketSize 9578,PropTopicAlias -// 26389,PropAuthenticationData "*\184\157",PropMessageExpiryInterval 13687,PropSubscriptionIdentifierAvailable -// 195,PropRequestProblemInformation 144,PropSessionExpiryInterval 25484,PropReasonString "}\221_\211-",PropContentType -// "}r\DC4#\ENQ\233\200\n\152(\173z|\STX\154!2/\RS\241",PropResponseInformation -// "\253\172R\ENQ\185\232WI\DEL\146\172\165{\209\DC4\DC4\135}\NUL}\157{\222\f",PropRequestResponseInformation -// 253,PropMessageExpiryInterval 20061,PropMessageExpiryInterval 26031,PropRequestResponseInformation -// 28,PropUserProperty "\247\&6\144b\177\157\141\161|\GSR\161F\229Jd\233p\DC1>N\206Nx\248)\249\ESC9" -// "W*L\132%]d\SI\FS\153\NAK\214\147g",PropUserProperty -// "\238\143\244q\176E\235\132\156\206\ENQ\235\DC2\184\134S\144Jo\SOc\151OL[" -// "V\223H\156\252ak4\150\212^1\169'\230\196\n6n\166",PropRequestResponseInformation 233,PropMaximumPacketSize -// 3867,PropRequestProblemInformation 24,PropRetainAvailable 135,PropSessionExpiryInterval -// 21423,PropAuthenticationMethod "",PropMessageExpiryInterval 29400,PropAuthenticationData -// "cM\159g#x\244r\t\211Z\245\132\178\145?\217mPV\194\t\179\148\r",PropUserProperty ")\by" -// "j\201V\169\237ipN",PropMaximumPacketSize 31853,PropSharedSubscriptionAvailable -// 54,PropSubscriptionIdentifierAvailable 164] +uint8_t pkt[] = {0x90, 0xb3, 0x1, 0x36, 0x63, 0xaa, 0x1, 0x3, 0x0, 0x7, 0x13, 0x1a, 0x40, 0x2c, 0xb9, 0x6b, 0xe2, 0xb, 0xc, 0x2, 0x0, 0x0, 0x24, 0xcb, 0x21, 0x7b, 0x32, 0x1c, 0x0, 0x4, 0x9a, 0xa8, 0x80, 0x63, 0x22, 0x41, 0xca, 0x1c, 0x0, 0xb, 0x61, 0x58, 0x41, 0xf7, 0x8a, 0x3c, 0x84, 0x3a, 0xa1, 0xc6, 0x76, 0x24, 0x72, 0x2, 0x0, 0x0, 0x3e, 0x9, 0x21, 0x23, 0x39, 0x2a, 0xbf, 0x26, 0x0, 0x0, 0x0, 0x17, 0x15, 0xc1, 0x41, 0x62, 0xe4, 0x34, 0x5f, 0x96, 0x7f, 0xd, 0x64, 0x80, 0x7b, 0xd0, 0x49, 0xa3, 0x29, 0x2f, 0xf, 0xbc, 0xff, 0x31, 0x84, 0x26, 0x0, 0x7, 0xcb, 0xad, 0x14, 0x31, 0x8b, 0xa0, 0xfc, 0x0, 0x3, 0x12, 0x72, 0xd0, 0x26, 0x0, 0x14, 0x91, 0x73, 0xd0, 0x98, 0xf3, 0x71, 0x18, 0x16, 0x62, 0x47, 0x9a, 0x4a, 0x90, 0xc1, 0x9d, 0x26, 0x1, 0x83, 0x6b, 0xfa, 0x0, 0x4, 0x5d, 0x4c, 0xac, 0x98, 0x2, 0x0, 0x0, 0x8, 0x32, 0x1c, 0x0, 0x1c, 0x9a, 0xcb, 0x36, 0x3, 0xa, 0x4, 0x88, 0x50, 0xba, 0xd0, 0x77, 0x36, 0xd7, 0x8f, 0x3a, 0x5f, 0x4, 0xfe, 0x52, 0xd5, 0x4c, 0x2a, 0x5e, 0x23, 0xc1, 0x45, 0x8e, 0x69, 0x29, 0x7f, 0x24, 0xc, 0x24, 0x9c, 0x2, 0x87, 0x1, 0x91, 0x97}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 13923); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[1], 0x87); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[3], 0x91); +EXPECT_EQ(granted_qos_levels[4], 0x97); + +} + + +// SubscribeResponse 6677 [Right QoS0,Right QoS1,Left SubErrImplementationSpecificError,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError] [PropSessionExpiryInterval 14683,PropSessionExpiryInterval 21434,PropAuthenticationData "D#\252\208F\157P\215J \205\186\251\251\139",PropAuthenticationData "\179\247",PropPayloadFormatIndicator 176,PropResponseTopic "\201\244\179\185o\NAK\177\\H\192\ETB\229\170\164\242T\136\149w",PropSubscriptionIdentifierAvailable 152,PropSharedSubscriptionAvailable 60,PropRetainAvailable 141,PropReceiveMaximum 27371,PropSubscriptionIdentifierAvailable 227,PropSubscriptionIdentifierAvailable 154,PropRetainAvailable 162,PropWillDelayInterval 19822,PropAssignedClientIdentifier "c",PropServerKeepAlive 6408,PropResponseInformation "\bF\129f\199\228\201\255\255\176\156\&1\238",PropReceiveMaximum 16984,PropSubscriptionIdentifier 28,PropAuthenticationData "\r\129\228\233\202R\160\164\240w\173\SUB\NULB?\245\204O\210\150\&5\226\141W\239\130\160G",PropMessageExpiryInterval 15050,PropAuthenticationMethod "\SOH\168\SYN!\224\166\237\228_\181\202\136\141\156\217\&9\252-\213\138>",PropResponseTopic "\250\217\206t\"\223\DC2Y\131\FS\139+\DEL\209h~\162\197YV>\DEL",PropServerKeepAlive 11130,PropSharedSubscriptionAvailable 136] TEST(SubACK5QCTest, Decode27) { - uint8_t pkt[] = { - 0x90, 0xb3, 0x2, 0x39, 0xf3, 0xa8, 0x2, 0x9, 0x0, 0x12, 0xbc, 0x2, 0x50, 0xb0, 0x2a, 0x2e, 0xf4, 0xb0, 0x60, - 0xc6, 0x11, 0x6c, 0x3d, 0x52, 0x61, 0xfb, 0xe2, 0xe7, 0x27, 0x0, 0x0, 0x25, 0x6a, 0x23, 0x67, 0x15, 0x16, 0x0, - 0x3, 0x2a, 0xb8, 0x9d, 0x2, 0x0, 0x0, 0x35, 0x77, 0x29, 0xc3, 0x17, 0x90, 0x11, 0x0, 0x0, 0x63, 0x8c, 0x1f, - 0x0, 0x5, 0x7d, 0xdd, 0x5f, 0xd3, 0x2d, 0x3, 0x0, 0x14, 0x7d, 0x72, 0x14, 0x23, 0x5, 0xe9, 0xc8, 0xa, 0x98, - 0x28, 0xad, 0x7a, 0x7c, 0x2, 0x9a, 0x21, 0x32, 0x2f, 0x1e, 0xf1, 0x1a, 0x0, 0x18, 0xfd, 0xac, 0x52, 0x5, 0xb9, - 0xe8, 0x57, 0x49, 0x7f, 0x92, 0xac, 0xa5, 0x7b, 0xd1, 0x14, 0x14, 0x87, 0x7d, 0x0, 0x7d, 0x9d, 0x7b, 0xde, 0xc, - 0x19, 0xfd, 0x2, 0x0, 0x0, 0x4e, 0x5d, 0x2, 0x0, 0x0,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- int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14835); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x83); - EXPECT_EQ(granted_qos_levels[5], 0x87); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); -} - -// SubscribeResponse 3036 [Right QoS0,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError] -// [PropReceiveMaximum 25407,PropAuthenticationData -// "\224\236\221\b-K\221a\233\161,\229\f\228w5\176/\225\150\233C\245\178\ACK:\233\143\GS",PropResponseInformation -// "\136]j\GS\228*\181\236{\ACKbPk\166\243\218\131\\\nK.\SI\\\ENQc\145j%\232s",PropPayloadFormatIndicator -// 134,PropRetainAvailable 110,PropCorrelationData -// "\133T8\227~M+#|\156\164C\216\157\189\175\202@\160",PropCorrelationData -// "\182\244\248Gq\173b\226\180n\134\130\205QWY\133\226N\201\US\t\187\173\253~\187q\206"] +uint8_t pkt[] = {0x90, 0xd2, 0x1, 0x1a, 0x15, 0xc3, 0x1, 0x11, 0x0, 0x0, 0x39, 0x5b, 0x11, 0x0, 0x0, 0x53, 0xba, 0x16, 0x0, 0xf, 0x44, 0x23, 0xfc, 0xd0, 0x46, 0x9d, 0x50, 0xd7, 0x4a, 0x20, 0xcd, 0xba, 0xfb, 0xfb, 0x8b, 0x16, 0x0, 0x2, 0xb3, 0xf7, 0x1, 0xb0, 0x8, 0x0, 0x13, 0xc9, 0xf4, 0xb3, 0xb9, 0x6f, 0x15, 0xb1, 0x5c, 0x48, 0xc0, 0x17, 0xe5, 0xaa, 0xa4, 0xf2, 0x54, 0x88, 0x95, 0x77, 0x29, 0x98, 0x2a, 0x3c, 0x25, 0x8d, 0x21, 0x6a, 0xeb, 0x29, 0xe3, 0x29, 0x9a, 0x25, 0xa2, 0x18, 0x0, 0x0, 0x4d, 0x6e, 0x12, 0x0, 0x1, 0x63, 0x13, 0x19, 0x8, 0x1a, 0x0, 0xd, 0x8, 0x46, 0x81, 0x66, 0xc7, 0xe4, 0xc9, 0xff, 0xff, 0xb0, 0x9c, 0x31, 0xee, 0x21, 0x42, 0x58, 0xb, 0x1c, 0x16, 0x0, 0x1c, 0xd, 0x81, 0xe4, 0xe9, 0xca, 0x52, 0xa0, 0xa4, 0xf0, 0x77, 0xad, 0x1a, 0x0, 0x42, 0x3f, 0xf5, 0xcc, 0x4f, 0xd2, 0x96, 0x35, 0xe2, 0x8d, 0x57, 0xef, 0x82, 0xa0, 0x47, 0x2, 0x0, 0x0, 0x3a, 0xca, 0x15, 0x0, 0x15, 0x1, 0xa8, 0x16, 0x21, 0xe0, 0xa6, 0xed, 0xe4, 0x5f, 0xb5, 0xca, 0x88, 0x8d, 0x9c, 0xd9, 0x39, 0xfc, 0x2d, 0xd5, 0x8a, 0x3e, 0x8, 0x0, 0x16, 0xfa, 0xd9, 0xce, 0x74, 0x22, 0xdf, 0x12, 0x59, 0x83, 0x1c, 0x8b, 0x2b, 0x7f, 0xd1, 0x68, 0x7e, 0xa2, 0xc5, 0x59, 0x56, 0x3e, 0x7f, 0x13, 0x2b, 0x7a, 0x2a, 0x88, 0x0, 0x1, 0x83, 0x1, 0x91, 0x0, 0x2, 0x2, 0x9e, 0x1, 0x83}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[11]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 11, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 6677); +EXPECT_EQ(count, 11); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[2], 0x83); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[4], 0x91); +EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[8], 0x9E); +EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[10], 0x83); + +} + + +// SubscribeResponse 12919 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported] [PropAuthenticationData "f\224~\151\161Ar\218B\165\171\200\130\128\253C\CAN\154\n\153$\ENQ\194\180\148\DC4\223",PropUserProperty "\DC2:#\184q]" "\NAK!_k\236\\m\170\201\173u\149\ETXD:\178\129\164\&6i",PropSubscriptionIdentifier 14,PropRequestResponseInformation 152,PropMessageExpiryInterval 30660,PropSubscriptionIdentifier 5,PropMessageExpiryInterval 24332,PropReceiveMaximum 32249,PropContentType "\178\174=\US~0v\136\187\229\252\f",PropRetainAvailable 253,PropSubscriptionIdentifierAvailable 1,PropServerKeepAlive 19906,PropSubscriptionIdentifierAvailable 54,PropAssignedClientIdentifier "\174o\138z\186\200\184@",PropSubscriptionIdentifier 19,PropWillDelayInterval 7801,PropResponseInformation "\160\SYN#s",PropCorrelationData "\145\SOH\144\133\ETBtn\172w\195j\164\161\205\151\229o\231\168%@UK",PropRequestResponseInformation 101,PropMaximumQoS 213,PropServerReference "u\RS\228\212T:Oz>\154\176\231La-\164,\166",PropCorrelationData "\169\SOH \\\197\209x:\b\176\t\226\\\222\GS\178IV\RSE\190\ETB\252",PropPayloadFormatIndicator 140,PropRequestResponseInformation 93,PropWildcardSubscriptionAvailable 15,PropMaximumPacketSize 21743,PropSubscriptionIdentifierAvailable 12,PropResponseInformation "iv\SI\219)\164\b\253\223\n\t\235\NAK\219"] TEST(SubACK5QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0x84, 0x1, 0xb, 0xdc, 0x7e, 0x21, 0x63, 0x3f, 0x16, 0x0, 0x1d, 0xe0, 0xec, 0xdd, 0x8, 0x2d, - 0x4b, 0xdd, 0x61, 0xe9, 0xa1, 0x2c, 0xe5, 0xc, 0xe4, 0x77, 0x35, 0xb0, 0x2f, 0xe1, 0x96, 0xe9, 0x43, - 0xf5, 0xb2, 0x6, 0x3a, 0xe9, 0x8f, 0x1d, 0x1a, 0x0, 0x1e, 0x88, 0x5d, 0x6a, 0x1d, 0xe4, 0x2a, 0xb5, - 0xec, 0x7b, 0x6, 0x62, 0x50, 0x6b, 0xa6, 0xf3, 0xda, 0x83, 0x5c, 0xa, 0x4b, 0x2e, 0xf, 0x5c, 0x5, - 0x63, 0x91, 0x6a, 0x25, 0xe8, 0x73, 0x1, 0x86, 0x25, 0x6e, 0x9, 0x0, 0x13, 0x85, 0x54, 0x38, 0xe3, - 0x7e, 0x4d, 0x2b, 0x23, 0x7c, 0x9c, 0xa4, 0x43, 0xd8, 0x9d, 0xbd, 0xaf, 0xca, 0x40, 0xa0, 0x9, 0x0, - 0x1d, 0xb6, 0xf4, 0xf8, 0x47, 0x71, 0xad, 0x62, 0xe2, 0xb4, 0x6e, 0x86, 0x82, 0xcd, 0x51, 0x57, 0x59, - 0x85, 0xe2, 0x4e, 0xc9, 0x1f, 0x9, 0xbb, 0xad, 0xfd, 0x7e, 0xbb, 0x71, 0xce, 0x0, 0x87, 0x83}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3036); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x87); - EXPECT_EQ(granted_qos_levels[2], 0x83); +uint8_t pkt[] = {0x90, 0xf5, 0x1, 0x32, 0x77, 0xec, 0x1, 0x16, 0x0, 0x1b, 0x66, 0xe0, 0x7e, 0x97, 0xa1, 0x41, 0x72, 0xda, 0x42, 0xa5, 0xab, 0xc8, 0x82, 0x80, 0xfd, 0x43, 0x18, 0x9a, 0xa, 0x99, 0x24, 0x5, 0xc2, 0xb4, 0x94, 0x14, 0xdf, 0x26, 0x0, 0x6, 0x12, 0x3a, 0x23, 0xb8, 0x71, 0x5d, 0x0, 0x14, 0x15, 0x21, 0x5f, 0x6b, 0xec, 0x5c, 0x6d, 0xaa, 0xc9, 0xad, 0x75, 0x95, 0x3, 0x44, 0x3a, 0xb2, 0x81, 0xa4, 0x36, 0x69, 0xb, 0xe, 0x19, 0x98, 0x2, 0x0, 0x0, 0x77, 0xc4, 0xb, 0x5, 0x2, 0x0, 0x0, 0x5f, 0xc, 0x21, 0x7d, 0xf9, 0x3, 0x0, 0xc, 0xb2, 0xae, 0x3d, 0x1f, 0x7e, 0x30, 0x76, 0x88, 0xbb, 0xe5, 0xfc, 0xc, 0x25, 0xfd, 0x29, 0x1, 0x13, 0x4d, 0xc2, 0x29, 0x36, 0x12, 0x0, 0x8, 0xae, 0x6f, 0x8a, 0x7a, 0xba, 0xc8, 0xb8, 0x40, 0xb, 0x13, 0x18, 0x0, 0x0, 0x1e, 0x79, 0x1a, 0x0, 0x4, 0xa0, 0x16, 0x23, 0x73, 0x9, 0x0, 0x17, 0x91, 0x1, 0x90, 0x85, 0x17, 0x74, 0x6e, 0xac, 0x77, 0xc3, 0x6a, 0xa4, 0xa1, 0xcd, 0x97, 0xe5, 0x6f, 0xe7, 0xa8, 0x25, 0x40, 0x55, 0x4b, 0x19, 0x65, 0x24, 0xd5, 0x1c, 0x0, 0x12, 0x75, 0x1e, 0xe4, 0xd4, 0x54, 0x3a, 0x4f, 0x7a, 0x3e, 0x9a, 0xb0, 0xe7, 0x4c, 0x61, 0x2d, 0xa4, 0x2c, 0xa6, 0x9, 0x0, 0x17, 0xa9, 0x1, 0x20, 0x5c, 0xc5, 0xd1, 0x78, 0x3a, 0x8, 0xb0, 0x9, 0xe2, 0x5c, 0xde, 0x1d, 0xb2, 0x49, 0x56, 0x1e, 0x45, 0xbe, 0x17, 0xfc, 0x1, 0x8c, 0x19, 0x5d, 0x28, 0xf, 0x27, 0x0, 0x0, 0x54, 0xef, 0x29, 0xc, 0x1a, 0x0, 0xe, 0x69, 0x76, 0xf, 0xdb, 0x29, 0xa4, 0x8, 0xfd, 0xdf, 0xa, 0x9, 0xeb, 0x15, 0xdb, 0x2, 0x91, 0x1, 0x0, 0xa1}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[5]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 12919); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); +EXPECT_EQ(granted_qos_levels[1], 0x91); +EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[4], 0xA1); + } -// SubscribeResponse 8613 [Right QoS2] [PropResponseInformation "\a",PropMaximumQoS -// 233,PropWildcardSubscriptionAvailable 130] + +// SubscribeResponse 20520 [Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right QoS0,Left SubErrImplementationSpecificError] [PropSubscriptionIdentifierAvailable 144,PropTopicAliasMaximum 10170,PropMaximumPacketSize 22999,PropRequestProblemInformation 220,PropAuthenticationData "X\238{\218f),",PropSessionExpiryInterval 21080,PropRequestProblemInformation 67,PropAuthenticationData "\SYN\189\&4\180\225\156\&8\246\DEL\151bX\148n\196@\247\214\132\&4\177\245h\179S\\\215EF",PropAuthenticationMethod "\249,\163\207\134\ESC\176?GbZ<4\218\164\207{",PropSharedSubscriptionAvailable 247,PropRequestResponseInformation 63,PropServerKeepAlive 12124,PropServerReference "_\\\235\181\236)\227\219\190\194\&9#|\233\204\200",PropMessageExpiryInterval 10858,PropRequestResponseInformation 207,PropSessionExpiryInterval 24059,PropReasonString "\NUL\EOT\228\DC3",PropContentType "\177N6\250\204j~\172\199cO\176\130\180 \225ba\206\US",PropAuthenticationData "K\RS\133c\ENQ\143\199\n7s\240IJ\187",PropMessageExpiryInterval 27212,PropSubscriptionIdentifier 10,PropRequestResponseInformation 203,PropTopicAlias 16606,PropAuthenticationMethod "9V\188\255\225\218\&5\DC1\247\NUL",PropWildcardSubscriptionAvailable 206,PropMaximumQoS 9,PropRetainAvailable 230,PropSharedSubscriptionAvailable 159,PropMaximumPacketSize 1549] TEST(SubACK5QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0xc, 0x21, 0xa5, 0x8, 0x1a, 0x0, 0x1, 0x7, 0x24, 0xe9, 0x28, 0x82, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8613); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); +uint8_t pkt[] = {0x90, 0xd5, 0x1, 0x50, 0x28, 0xcc, 0x1, 0x29, 0x90, 0x22, 0x27, 0xba, 0x27, 0x0, 0x0, 0x59, 0xd7, 0x17, 0xdc, 0x16, 0x0, 0x7, 0x58, 0xee, 0x7b, 0xda, 0x66, 0x29, 0x2c, 0x11, 0x0, 0x0, 0x52, 0x58, 0x17, 0x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lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 20520); +EXPECT_EQ(count, 5); +EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[2], 0x87); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[4], 0x83); + } -// SubscribeResponse 14512 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right QoS1,Left -// SubErrWildcardSubscriptionsNotSupported,Left SubErrQuotaExceeded] [PropSharedSubscriptionAvailable 210] + +// SubscribeResponse 2699 [Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded,Left SubErrQuotaExceeded,Right QoS1,Right QoS0,Left SubErrQuotaExceeded] [PropResponseTopic "",PropSessionExpiryInterval 8424] TEST(SubACK5QCTest, Decode30) { - uint8_t pkt[] = {0x90, 0xa, 0x38, 0xb0, 0x2, 0x2a, 0xd2, 0x9e, 0x91, 0x1, 0xa2, 0x97}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14512); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], 0x91); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0xA2); - EXPECT_EQ(granted_qos_levels[4], 0x97); +uint8_t pkt[] = {0x90, 0x11, 0xa, 0x8b, 0x8, 0x8, 0x0, 0x0, 0x11, 0x0, 0x0, 0x20, 0xe8, 0x91, 0x97, 0x97, 0x1, 0x0, 0x97}; +uint16_t packet_id; +int count; +lwmqtt_qos_t granted_qos_levels[6]; +lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(packet_id, 2699); +EXPECT_EQ(count, 6); +EXPECT_EQ(granted_qos_levels[0], 0x91); +EXPECT_EQ(granted_qos_levels[1], 0x97); +EXPECT_EQ(granted_qos_levels[2], 0x97); +EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); +EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); +EXPECT_EQ(granted_qos_levels[5], 0x97); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode1) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode2) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode3) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + } + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode4) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode5) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode6) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode7) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode8) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode9) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode10) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode11) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode12) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode13) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode14) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode15) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode16) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode17) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode18) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode19) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode20) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode21) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode22) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode23) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode24) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode25) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode26) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode27) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode28) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode29) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoNormalDisconnection [] +TEST(Disco311QCTest, Encode30) { +uint8_t pkt[] = {0xe0, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoMessageRateTooHigh [PropReasonString "\225\ENQ<\232\197\144\236\DLESJ\182g~~\230\252\ETX\231",PropContentType "\205\232\136\DC3Z~\156x\FS\223\228\203",PropWillDelayInterval 26618,PropCorrelationData "\228\r\236\237\t\188\136\EOTo\204tPm\DEL\232{'\153\209\196",PropTopicAlias 6948,PropSubscriptionIdentifier 23,PropAssignedClientIdentifier "\238\214\184\137D\251",PropMessageExpiryInterval 6626,PropAssignedClientIdentifier "\151e\219\254\131\134\177\f`\155\194\&3\SUB]\147\ESC\151",PropSharedSubscriptionAvailable 191,PropPayloadFormatIndicator 226,PropAssignedClientIdentifier "S\DC3%x\146\184\210\242\ENQf\228@S-\ETX\231\\\t\173^]\254\231B#S%6",PropTopicAliasMaximum 13418,PropResponseTopic "\bo\208~\176vG\EM\171=",PropWillDelayInterval 5695,PropCorrelationData "t\207\138\SOHXL\139R\201\200\220\145m",PropMessageExpiryInterval 4237,PropReceiveMaximum 27811,PropSubscriptionIdentifierAvailable 116,PropResponseTopic "",PropMessageExpiryInterval 25556,PropMaximumQoS 160,PropResponseTopic "O8\t\226\169\146\ENQ\159s\181\te\226\137\154\"",PropCorrelationData "\144\\X[\203\148\246D>\141 \233S\143",PropRequestProblemInformation 170,PropServerKeepAlive 12755] +TEST(Disco5QCTest, Encode1) { +uint8_t pkt[] = {0xe0, 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x74, 0x8, 0x0, 0x0, 0x2, 0x0, 0x0, 0x63, 0xd4, 0x24, 0xa0, 0x8, 0x0, 0x10, 0x4f, 0x38, 0x9, 0xe2, 0xa9, 0x92, 0x5, 0x9f, 0x73, 0xb5, 0x9, 0x65, 0xe2, 0x89, 0x9a, 0x22, 0x9, 0x0, 0xe, 0x90, 0x5c, 0x58, 0x5b, 0xcb, 0x94, 0xf6, 0x44, 0x3e, 0x8d, 0x20, 0xe9, 0x53, 0x8f, 0x17, 0xaa, 0x13, 0x31, 0xd3}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xe1, 0x5, 0x3c, 0xe8, 0xc5, 0x90, 0xec, 0x10, 0x53, 0x4a, 0xb6, 0x67, 0x7e, 0x7e, 0xe6, 0xfc, 0x3, 0xe7}; + uint8_t bytesprops1[] = {0xcd, 0xe8, 0x88, 0x13, 0x5a, 0x7e, 0x9c, 0x78, 0x1c, 0xdf, 0xe4, 0xcb}; + uint8_t bytesprops2[] = {0xe4, 0xd, 0xec, 0xed, 0x9, 0xbc, 0x88, 0x4, 0x6f, 0xcc, 0x74, 0x50, 0x6d, 0x7f, 0xe8, 0x7b, 0x27, 0x99, 0xd1, 0xc4}; + uint8_t bytesprops3[] = {0xee, 0xd6, 0xb8, 0x89, 0x44, 0xfb}; + uint8_t bytesprops4[] = {0x97, 0x65, 0xdb, 0xfe, 0x83, 0x86, 0xb1, 0xc, 0x60, 0x9b, 0xc2, 0x33, 0x1a, 0x5d, 0x93, 0x1b, 0x97}; + uint8_t bytesprops5[] = {0x53, 0x13, 0x25, 0x78, 0x92, 0xb8, 0xd2, 0xf2, 0x5, 0x66, 0xe4, 0x40, 0x53, 0x2d, 0x3, 0xe7, 0x5c, 0x9, 0xad, 0x5e, 0x5d, 0xfe, 0xe7, 0x42, 0x23, 0x53, 0x25, 0x36}; + uint8_t bytesprops6[] = {0x8, 0x6f, 0xd0, 0x7e, 0xb0, 0x76, 0x47, 0x19, 0xab, 0x3d}; + uint8_t bytesprops7[] = {0x74, 0xcf, 0x8a, 0x1, 0x58, 0x4c, 0x8b, 0x52, 0xc9, 0xc8, 0xdc, 0x91, 0x6d}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0x4f, 0x38, 0x9, 0xe2, 0xa9, 0x92, 0x5, 0x9f, 0x73, 0xb5, 0x9, 0x65, 0xe2, 0x89, 0x9a, 0x22}; + uint8_t bytesprops10[] = {0x90, 0x5c, 0x58, 0x5b, 0xcb, 0x94, 0xf6, 0x44, 0x3e, 0x8d, 0x20, 0xe9, 0x53, 0x8f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26618}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6948}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6626}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13418}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5695}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4237}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27811}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25556}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12755}}, + }; + + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 150, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoKeepAliveTimeout [PropSubscriptionIdentifier 16,PropReasonString "\DLEC\171",PropAuthenticationMethod "z\161_a\195\160\230m",PropResponseInformation "c.\DC3f\238\255-\174\148\222\152\231BA\SYN\252",PropReasonString "\186]H\146bz\\\228PE)?\155 \SUB\255{",PropReceiveMaximum 18866,PropAuthenticationData "kz\227\GS\219\205",PropWillDelayInterval 29972,PropUserProperty "\233\137\rD\208_\149\227\254\ETB\216\203\243a\147\"\USJ\242\182\143W\231k\162\243\rIb\252" "JT\231\143S\v\166^q\134;\EOT\149PX\145\148\STX\168\&8\169j\245\237",PropContentType "\143\195AB\161\151\234\SOv\243",PropRetainAvailable 162,PropSharedSubscriptionAvailable 171,PropWildcardSubscriptionAvailable 64,PropAuthenticationData "\226(\221",PropSessionExpiryInterval 15912,PropSubscriptionIdentifierAvailable 56,PropMaximumPacketSize 11188,PropRequestResponseInformation 77,PropServerReference "zc,\221?\r\255\250\DLE\222h\130K\247\169\176K\135\198\244JZ\159\192\215",PropMaximumPacketSize 19726,PropRequestResponseInformation 136,PropResponseTopic "\203\192\185)#\SOH\a\219\206<\b\FS\219\\",PropResponseTopic "WzS\142r\209\176\231\213\203!2\NUL!^\205\199\147\155\216\SI\200|2",PropMessageExpiryInterval 31378,PropRetainAvailable 155,PropServerKeepAlive 12042] +TEST(Disco5QCTest, Encode2) { +uint8_t pkt[] = {0xe0, 0x89, 0x2, 0x8d, 0x86, 0x2, 0xb, 0x10, 0x1f, 0x0, 0x3, 0x10, 0x43, 0xab, 0x15, 0x0, 0x8, 0x7a, 0xa1, 0x5f, 0x61, 0xc3, 0xa0, 0xe6, 0x6d, 0x1a, 0x0, 0x10, 0x63, 0x2e, 0x13, 0x66, 0xee, 0xff, 0x2d, 0xae, 0x94, 0xde, 0x98, 0xe7, 0x42, 0x41, 0x16, 0xfc, 0x1f, 0x0, 0x11, 0xba, 0x5d, 0x48, 0x92, 0x62, 0x7a, 0x5c, 0xe4, 0x50, 0x45, 0x29, 0x3f, 0x9b, 0x20, 0x1a, 0xff, 0x7b, 0x21, 0x49, 0xb2, 0x16, 0x0, 0x6, 0x6b, 0x7a, 0xe3, 0x1d, 0xdb, 0xcd, 0x18, 0x0, 0x0, 0x75, 0x14, 0x26, 0x0, 0x1e, 0xe9, 0x89, 0xd, 0x44, 0xd0, 0x5f, 0x95, 0xe3, 0xfe, 0x17, 0xd8, 0xcb, 0xf3, 0x61, 0x93, 0x22, 0x1f, 0x4a, 0xf2, 0xb6, 0x8f, 0x57, 0xe7, 0x6b, 0xa2, 0xf3, 0xd, 0x49, 0x62, 0xfc, 0x0, 0x18, 0x4a, 0x54, 0xe7, 0x8f, 0x53, 0xb, 0xa6, 0x5e, 0x71, 0x86, 0x3b, 0x4, 0x95, 0x50, 0x58, 0x91, 0x94, 0x2, 0xa8, 0x38, 0xa9, 0x6a, 0xf5, 0xed, 0x3, 0x0, 0xa, 0x8f, 0xc3, 0x41, 0x42, 0xa1, 0x97, 0xea, 0xe, 0x76, 0xf3, 0x25, 0xa2, 0x2a, 0xab, 0x28, 0x40, 0x16, 0x0, 0x3, 0xe2, 0x28, 0xdd, 0x11, 0x0, 0x0, 0x3e, 0x28, 0x29, 0x38, 0x27, 0x0, 0x0, 0x2b, 0xb4, 0x19, 0x4d, 0x1c, 0x0, 0x19, 0x7a, 0x63, 0x2c, 0xdd, 0x3f, 0xd, 0xff, 0xfa, 0x10, 0xde, 0x68, 0x82, 0x4b, 0xf7, 0xa9, 0xb0, 0x4b, 0x87, 0xc6, 0xf4, 0x4a, 0x5a, 0x9f, 0xc0, 0xd7, 0x27, 0x0, 0x0, 0x4d, 0xe, 0x19, 0x88, 0x8, 0x0, 0xe, 0xcb, 0xc0, 0xb9, 0x29, 0x23, 0x1, 0x7, 0xdb, 0xce, 0x3c, 0x8, 0x1c, 0xdb, 0x5c, 0x8, 0x0, 0x18, 0x57, 0x7a, 0x53, 0x8e, 0x72, 0xd1, 0xb0, 0xe7, 0xd5, 0xcb, 0x21, 0x32, 0x0, 0x21, 0x5e, 0xcd, 0xc7, 0x93, 0x9b, 0xd8, 0xf, 0xc8, 0x7c, 0x32, 0x2, 0x0, 0x0, 0x7a, 0x92, 0x25, 0x9b, 0x13, 0x2f, 0xa}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x10, 0x43, 0xab}; + uint8_t bytesprops1[] = {0x7a, 0xa1, 0x5f, 0x61, 0xc3, 0xa0, 0xe6, 0x6d}; + uint8_t bytesprops2[] = {0x63, 0x2e, 0x13, 0x66, 0xee, 0xff, 0x2d, 0xae, 0x94, 0xde, 0x98, 0xe7, 0x42, 0x41, 0x16, 0xfc}; + uint8_t bytesprops3[] = {0xba, 0x5d, 0x48, 0x92, 0x62, 0x7a, 0x5c, 0xe4, 0x50, 0x45, 0x29, 0x3f, 0x9b, 0x20, 0x1a, 0xff, 0x7b}; + uint8_t bytesprops4[] = {0x6b, 0x7a, 0xe3, 0x1d, 0xdb, 0xcd}; + uint8_t bytesprops6[] = {0x4a, 0x54, 0xe7, 0x8f, 0x53, 0xb, 0xa6, 0x5e, 0x71, 0x86, 0x3b, 0x4, 0x95, 0x50, 0x58, 0x91, 0x94, 0x2, 0xa8, 0x38, 0xa9, 0x6a, 0xf5, 0xed}; + uint8_t bytesprops5[] = {0xe9, 0x89, 0xd, 0x44, 0xd0, 0x5f, 0x95, 0xe3, 0xfe, 0x17, 0xd8, 0xcb, 0xf3, 0x61, 0x93, 0x22, 0x1f, 0x4a, 0xf2, 0xb6, 0x8f, 0x57, 0xe7, 0x6b, 0xa2, 0xf3, 0xd, 0x49, 0x62, 0xfc}; + uint8_t bytesprops7[] = {0x8f, 0xc3, 0x41, 0x42, 0xa1, 0x97, 0xea, 0xe, 0x76, 0xf3}; + uint8_t bytesprops8[] = {0xe2, 0x28, 0xdd}; + uint8_t bytesprops9[] = {0x7a, 0x63, 0x2c, 0xdd, 0x3f, 0xd, 0xff, 0xfa, 0x10, 0xde, 0x68, 0x82, 0x4b, 0xf7, 0xa9, 0xb0, 0x4b, 0x87, 0xc6, 0xf4, 0x4a, 0x5a, 0x9f, 0xc0, 0xd7}; + uint8_t bytesprops10[] = {0xcb, 0xc0, 0xb9, 0x29, 0x23, 0x1, 0x7, 0xdb, 0xce, 0x3c, 0x8, 0x1c, 0xdb, 0x5c}; + uint8_t bytesprops11[] = {0x57, 0x7a, 0x53, 0x8e, 0x72, 0xd1, 0xb0, 0xe7, 0xd5, 0xcb, 0x21, 0x32, 0x0, 0x21, 0x5e, 0xcd, 0xc7, 0x93, 0x9b, 0xd8, 0xf, 0xc8, 0x7c, 0x32}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18866}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29972}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={30, (char*)&bytesprops5}, .v={24, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15912}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11188}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19726}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31378}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12042}}, + }; + + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 141, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoTopicNameInvalid [PropSubscriptionIdentifier 29,PropServerKeepAlive 7482,PropAuthenticationData "\STX\FS7\ENQ",PropMessageExpiryInterval 19184,PropSubscriptionIdentifierAvailable 165,PropResponseInformation "\DC1\201<\140\241N\169px\233\166_Z\196\185\131:\246\240S\205",PropSubscriptionIdentifierAvailable 196,PropSubscriptionIdentifier 21,PropSubscriptionIdentifierAvailable 193] +TEST(Disco5QCTest, Encode3) { +uint8_t pkt[] = {0xe0, 0x33, 0x90, 0x31, 0xb, 0x1d, 0x13, 0x1d, 0x3a, 0x16, 0x0, 0x4, 0x2, 0x1c, 0x37, 0x5, 0x2, 0x0, 0x0, 0x4a, 0xf0, 0x29, 0xa5, 0x1a, 0x0, 0x15, 0x11, 0xc9, 0x3c, 0x8c, 0xf1, 0x4e, 0xa9, 0x70, 0x78, 0xe9, 0xa6, 0x5f, 0x5a, 0xc4, 0xb9, 0x83, 0x3a, 0xf6, 0xf0, 0x53, 0xcd, 0x29, 0xc4, 0xb, 0x15, 0x29, 0xc1}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x2, 0x1c, 0x37, 0x5}; + uint8_t bytesprops1[] = {0x11, 0xc9, 0x3c, 0x8c, 0xf1, 0x4e, 0xa9, 0x70, 0x78, 0xe9, 0xa6, 0x5f, 0x5a, 0xc4, 0xb9, 0x83, 0x3a, 0xf6, 0xf0, 0x53, 0xcd}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7482}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19184}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 193}}, + }; + + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoKeepAliveTimeout [PropContentType "j\214j",PropSubscriptionIdentifier 5,PropMessageExpiryInterval 16922,PropResponseInformation "\203\148\158\DELn\245\199\n\v\141",PropCorrelationData "\166T-\f\139\137M=A\192\230\ETB\129",PropCorrelationData "j\145\225=W\215\169\GS\255_T\205\148"] +TEST(Disco5QCTest, Encode4) { +uint8_t pkt[] = {0xe0, 0x3c, 0x8d, 0x3a, 0x3, 0x0, 0x3, 0x6a, 0xd6, 0x6a, 0xb, 0x5, 0x2, 0x0, 0x0, 0x42, 0x1a, 0x1a, 0x0, 0xa, 0xcb, 0x94, 0x9e, 0x7f, 0x6e, 0xf5, 0xc7, 0xa, 0xb, 0x8d, 0x9, 0x0, 0xd, 0xa6, 0x54, 0x2d, 0xc, 0x8b, 0x89, 0x4d, 0x3d, 0x41, 0xc0, 0xe6, 0x17, 0x81, 0x9, 0x0, 0xd, 0x6a, 0x91, 0xe1, 0x3d, 0x57, 0xd7, 0xa9, 0x1d, 0xff, 0x5f, 0x54, 0xcd, 0x94}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x6a, 0xd6, 0x6a}; + uint8_t bytesprops1[] = {0xcb, 0x94, 0x9e, 0x7f, 0x6e, 0xf5, 0xc7, 0xa, 0xb, 0x8d}; + uint8_t bytesprops2[] = {0xa6, 0x54, 0x2d, 0xc, 0x8b, 0x89, 0x4d, 0x3d, 0x41, 0xc0, 0xe6, 0x17, 0x81}; + uint8_t bytesprops3[] = {0x6a, 0x91, 0xe1, 0x3d, 0x57, 0xd7, 0xa9, 0x1d, 0xff, 0x5f, 0x54, 0xcd, 0x94}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16922}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops3}}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 141, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoQoSNotSupported [PropTopicAlias 24397,PropReceiveMaximum 21691,PropContentType "\180n\NAK\249M\179\130\189:\158\145",PropSharedSubscriptionAvailable 27,PropContentType "\241=\180G\NAK\142",PropAssignedClientIdentifier "+\254P\217D\137\218r`\160\248|\142\&5\179\DC3C4G~",PropSharedSubscriptionAvailable 87,PropMaximumPacketSize 10553,PropTopicAlias 30553,PropSubscriptionIdentifier 15,PropTopicAlias 22925,PropResponseTopic "\NULR\ETX}\248$\164\207z\173.Z\136\249o\185\196\140\166",PropSubscriptionIdentifier 6,PropSharedSubscriptionAvailable 64,PropPayloadFormatIndicator 146,PropMaximumQoS 24,PropRetainAvailable 210,PropServerKeepAlive 23235,PropTopicAlias 14682,PropReasonString "-N\188\"\GS}I\158t\132W",PropMessageExpiryInterval 4570,PropSubscriptionIdentifierAvailable 144,PropAuthenticationData "<"] +TEST(Disco5QCTest, Encode5) { +uint8_t pkt[] = {0xe0, 0x87, 0x1, 0x9b, 0x84, 0x1, 0x23, 0x5f, 0x4d, 0x21, 0x54, 0xbb, 0x3, 0x0, 0xb, 0xb4, 0x6e, 0x15, 0xf9, 0x4d, 0xb3, 0x82, 0xbd, 0x3a, 0x9e, 0x91, 0x2a, 0x1b, 0x3, 0x0, 0x6, 0xf1, 0x3d, 0xb4, 0x47, 0x15, 0x8e, 0x12, 0x0, 0x14, 0x2b, 0xfe, 0x50, 0xd9, 0x44, 0x89, 0xda, 0x72, 0x60, 0xa0, 0xf8, 0x7c, 0x8e, 0x35, 0xb3, 0x13, 0x43, 0x34, 0x47, 0x7e, 0x2a, 0x57, 0x27, 0x0, 0x0, 0x29, 0x39, 0x23, 0x77, 0x59, 0xb, 0xf, 0x23, 0x59, 0x8d, 0x8, 0x0, 0x13, 0x0, 0x52, 0x3, 0x7d, 0xf8, 0x24, 0xa4, 0xcf, 0x7a, 0xad, 0x2e, 0x5a, 0x88, 0xf9, 0x6f, 0xb9, 0xc4, 0x8c, 0xa6, 0xb, 0x6, 0x2a, 0x40, 0x1, 0x92, 0x24, 0x18, 0x25, 0xd2, 0x13, 0x5a, 0xc3, 0x23, 0x39, 0x5a, 0x1f, 0x0, 0xb, 0x2d, 0x4e, 0xbc, 0x22, 0x1d, 0x7d, 0x49, 0x9e, 0x74, 0x84, 0x57, 0x2, 0x0, 0x0, 0x11, 0xda, 0x29, 0x90, 0x16, 0x0, 0x1, 0x3c}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xb4, 0x6e, 0x15, 0xf9, 0x4d, 0xb3, 0x82, 0xbd, 0x3a, 0x9e, 0x91}; + uint8_t bytesprops1[] = {0xf1, 0x3d, 0xb4, 0x47, 0x15, 0x8e}; + uint8_t bytesprops2[] = {0x2b, 0xfe, 0x50, 0xd9, 0x44, 0x89, 0xda, 0x72, 0x60, 0xa0, 0xf8, 0x7c, 0x8e, 0x35, 0xb3, 0x13, 0x43, 0x34, 0x47, 0x7e}; + uint8_t bytesprops3[] = {0x0, 0x52, 0x3, 0x7d, 0xf8, 0x24, 0xa4, 0xcf, 0x7a, 0xad, 0x2e, 0x5a, 0x88, 0xf9, 0x6f, 0xb9, 0xc4, 0x8c, 0xa6}; + uint8_t bytesprops4[] = {0x2d, 0x4e, 0xbc, 0x22, 0x1d, 0x7d, 0x49, 0x9e, 0x74, 0x84, 0x57}; + uint8_t bytesprops5[] = {0x3c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24397}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21691}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10553}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30553}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22925}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23235}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14682}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4570}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops5}}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoConnectionRateExceeded [PropUserProperty "\150\ACKW\r_\178\224\254\203\251y\190m\185\142\am\160x\DC4\181\209\162]" "\227\133U\226\&4\213\186\167\NUL\233I\174]\144\144\v\173=\194\DC2\166H\220\236\243",PropWildcardSubscriptionAvailable 112,PropAuthenticationMethod "\147\140\SO$\189.\247h\152\&5\160\181\183^\231\172\182",PropPayloadFormatIndicator 194,PropRetainAvailable 213] +TEST(Disco5QCTest, Encode6) { +uint8_t pkt[] = {0xe0, 0x52, 0x9f, 0x50, 0x26, 0x0, 0x18, 0x96, 0x6, 0x57, 0xd, 0x5f, 0xb2, 0xe0, 0xfe, 0xcb, 0xfb, 0x79, 0xbe, 0x6d, 0xb9, 0x8e, 0x7, 0x6d, 0xa0, 0x78, 0x14, 0xb5, 0xd1, 0xa2, 0x5d, 0x0, 0x19, 0xe3, 0x85, 0x55, 0xe2, 0x34, 0xd5, 0xba, 0xa7, 0x0, 0xe9, 0x49, 0xae, 0x5d, 0x90, 0x90, 0xb, 0xad, 0x3d, 0xc2, 0x12, 0xa6, 0x48, 0xdc, 0xec, 0xf3, 0x28, 0x70, 0x15, 0x0, 0x11, 0x93, 0x8c, 0xe, 0x24, 0xbd, 0x2e, 0xf7, 0x68, 0x98, 0x35, 0xa0, 0xb5, 0xb7, 0x5e, 0xe7, 0xac, 0xb6, 0x1, 0xc2, 0x25, 0xd5}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops1[] = {0xe3, 0x85, 0x55, 0xe2, 0x34, 0xd5, 0xba, 0xa7, 0x0, 0xe9, 0x49, 0xae, 0x5d, 0x90, 0x90, 0xb, 0xad, 0x3d, 0xc2, 0x12, 0xa6, 0x48, 0xdc, 0xec, 0xf3}; + uint8_t bytesprops0[] = {0x96, 0x6, 0x57, 0xd, 0x5f, 0xb2, 0xe0, 0xfe, 0xcb, 0xfb, 0x79, 0xbe, 0x6d, 0xb9, 0x8e, 0x7, 0x6d, 0xa0, 0x78, 0x14, 0xb5, 0xd1, 0xa2, 0x5d}; + uint8_t bytesprops2[] = {0x93, 0x8c, 0xe, 0x24, 0xbd, 0x2e, 0xf7, 0x68, 0x98, 0x35, 0xa0, 0xb5, 0xb7, 0x5e, 0xe7, 0xac, 0xb6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={24, (char*)&bytesprops0}, .v={25, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 213}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoTopicFilterInvalid [PropTopicAliasMaximum 7050,PropRequestProblemInformation 59,PropMaximumPacketSize 14933,PropContentType "a\187\241l\134&\203N\CAN\194\&25,\172\ETX\239\189L\ETXOc\187",PropResponseInformation "\227;\195#r\237\150\245we\176|\207\ENQ\237\SI|\144\194\202@\181\217LH\amK",PropAuthenticationMethod "|_\202\226\237\225u\ETB\248\EM\178}\162v\177&\"\228^H",PropRequestResponseInformation 147] +TEST(Disco5QCTest, Encode7) { +uint8_t pkt[] = {0xe0, 0x5d, 0x8f, 0x5b, 0x22, 0x1b, 0x8a, 0x17, 0x3b, 0x27, 0x0, 0x0, 0x3a, 0x55, 0x3, 0x0, 0x16, 0x61, 0xbb, 0xf1, 0x6c, 0x86, 0x26, 0xcb, 0x4e, 0x18, 0xc2, 0x32, 0x35, 0x2c, 0xac, 0x3, 0xef, 0xbd, 0x4c, 0x3, 0x4f, 0x63, 0xbb, 0x1a, 0x0, 0x1c, 0xe3, 0x3b, 0xc3, 0x23, 0x72, 0xed, 0x96, 0xf5, 0x77, 0x65, 0xb0, 0x7c, 0xcf, 0x5, 0xed, 0xf, 0x7c, 0x90, 0xc2, 0xca, 0x40, 0xb5, 0xd9, 0x4c, 0x48, 0x7, 0x6d, 0x4b, 0x15, 0x0, 0x14, 0x7c, 0x5f, 0xca, 0xe2, 0xed, 0xe1, 0x75, 0x17, 0xf8, 0x19, 0xb2, 0x7d, 0xa2, 0x76, 0xb1, 0x26, 0x22, 0xe4, 0x5e, 0x48, 0x19, 0x93}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x61, 0xbb, 0xf1, 0x6c, 0x86, 0x26, 0xcb, 0x4e, 0x18, 0xc2, 0x32, 0x35, 0x2c, 0xac, 0x3, 0xef, 0xbd, 0x4c, 0x3, 0x4f, 0x63, 0xbb}; + uint8_t bytesprops1[] = {0xe3, 0x3b, 0xc3, 0x23, 0x72, 0xed, 0x96, 0xf5, 0x77, 0x65, 0xb0, 0x7c, 0xcf, 0x5, 0xed, 0xf, 0x7c, 0x90, 0xc2, 0xca, 0x40, 0xb5, 0xd9, 0x4c, 0x48, 0x7, 0x6d, 0x4b}; + uint8_t bytesprops2[] = {0x7c, 0x5f, 0xca, 0xe2, 0xed, 0xe1, 0x75, 0x17, 0xf8, 0x19, 0xb2, 0x7d, 0xa2, 0x76, 0xb1, 0x26, 0x22, 0xe4, 0x5e, 0x48}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7050}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14933}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 147}}, + }; + + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 143, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoServerMoved [PropAuthenticationData "\133\aV\218f{\DEL+0Z\254\160\142\DC2{*`\bb^d\ACK\183\174nO\174",PropRetainAvailable 100,PropUserProperty "\130\226" "f+\145\172\214a%\153\151\186",PropRetainAvailable 2,PropServerKeepAlive 19057,PropAssignedClientIdentifier "#X\b\242~:\246X\SUBo\155v~\ESC\189\185\159i\203",PropCorrelationData "\199z\242Bv\210\&0\187\240\144\198\247",PropAuthenticationData ">L^\162\189L\b\166\v\FS\139Q&\EM4\232\156\231\212H\174\244\t\188\202\154",PropSharedSubscriptionAvailable 88,PropMaximumPacketSize 12821,PropAssignedClientIdentifier "R\179\151\210~Yl5\218\208k\180\159K\176\138",PropAuthenticationMethod "\v\188k\163W\SOH",PropReasonString "\162\SOH\180HL\222\245H\v\DC3",PropReceiveMaximum 20007,PropWillDelayInterval 23538,PropMessageExpiryInterval 21495,PropResponseInformation "\149\241\223\&2\EM\NAK\249G",PropMessageExpiryInterval 13410,PropResponseInformation "\166\235k0\187Z\202\248\195\173\STX\232O\131\217\n\165\197}\201\137\148\152\242-\202",PropMessageExpiryInterval 22642,PropRequestProblemInformation 120,PropResponseInformation "n\NAK3\174T\146\196\SI\170\147\&2p\129\255um6\194\DC3\ETB+[\147\&6\146\202\"(",PropRetainAvailable 42,PropRequestProblemInformation 109,PropMaximumPacketSize 25224] +TEST(Disco5QCTest, Encode8) { +uint8_t pkt[] = {0xe0, 0x94, 0x2, 0x9d, 0x91, 0x2, 0x16, 0x0, 0x1b, 0x85, 0x7, 0x56, 0xda, 0x66, 0x7b, 0x7f, 0x2b, 0x30, 0x5a, 0xfe, 0xa0, 0x8e, 0x12, 0x7b, 0x2a, 0x60, 0x8, 0x62, 0x5e, 0x64, 0x6, 0xb7, 0xae, 0x6e, 0x4f, 0xae, 0x25, 0x64, 0x26, 0x0, 0x2, 0x82, 0xe2, 0x0, 0xa, 0x66, 0x2b, 0x91, 0xac, 0xd6, 0x61, 0x25, 0x99, 0x97, 0xba, 0x25, 0x2, 0x13, 0x4a, 0x71, 0x12, 0x0, 0x13, 0x23, 0x58, 0x8, 0xf2, 0x7e, 0x3a, 0xf6, 0x58, 0x1a, 0x6f, 0x9b, 0x76, 0x7e, 0x1b, 0xbd, 0xb9, 0x9f, 0x69, 0xcb, 0x9, 0x0, 0xc, 0xc7, 0x7a, 0xf2, 0x42, 0x76, 0xd2, 0x30, 0xbb, 0xf0, 0x90, 0xc6, 0xf7, 0x16, 0x0, 0x1a, 0x3e, 0x4c, 0x5e, 0xa2, 0xbd, 0x4c, 0x8, 0xa6, 0xb, 0x1c, 0x8b, 0x51, 0x26, 0x19, 0x34, 0xe8, 0x9c, 0xe7, 0xd4, 0x48, 0xae, 0xf4, 0x9, 0xbc, 0xca, 0x9a, 0x2a, 0x58, 0x27, 0x0, 0x0, 0x32, 0x15, 0x12, 0x0, 0x10, 0x52, 0xb3, 0x97, 0xd2, 0x7e, 0x59, 0x6c, 0x35, 0xda, 0xd0, 0x6b, 0xb4, 0x9f, 0x4b, 0xb0, 0x8a, 0x15, 0x0, 0x6, 0xb, 0xbc, 0x6b, 0xa3, 0x57, 0x1, 0x1f, 0x0, 0xa, 0xa2, 0x1, 0xb4, 0x48, 0x4c, 0xde, 0xf5, 0x48, 0xb, 0x13, 0x21, 0x4e, 0x27, 0x18, 0x0, 0x0, 0x5b, 0xf2, 0x2, 0x0, 0x0, 0x53, 0xf7, 0x1a, 0x0, 0x8, 0x95, 0xf1, 0xdf, 0x32, 0x19, 0x15, 0xf9, 0x47, 0x2, 0x0, 0x0, 0x34, 0x62, 0x1a, 0x0, 0x1a, 0xa6, 0xeb, 0x6b, 0x30, 0xbb, 0x5a, 0xca, 0xf8, 0xc3, 0xad, 0x2, 0xe8, 0x4f, 0x83, 0xd9, 0xa, 0xa5, 0xc5, 0x7d, 0xc9, 0x89, 0x94, 0x98, 0xf2, 0x2d, 0xca, 0x2, 0x0, 0x0, 0x58, 0x72, 0x17, 0x78, 0x1a, 0x0, 0x1c, 0x6e, 0x15, 0x33, 0xae, 0x54, 0x92, 0xc4, 0xf, 0xaa, 0x93, 0x32, 0x70, 0x81, 0xff, 0x75, 0x6d, 0x36, 0xc2, 0x13, 0x17, 0x2b, 0x5b, 0x93, 0x36, 0x92, 0xca, 0x22, 0x28, 0x25, 0x2a, 0x17, 0x6d, 0x27, 0x0, 0x0, 0x62, 0x88}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x85, 0x7, 0x56, 0xda, 0x66, 0x7b, 0x7f, 0x2b, 0x30, 0x5a, 0xfe, 0xa0, 0x8e, 0x12, 0x7b, 0x2a, 0x60, 0x8, 0x62, 0x5e, 0x64, 0x6, 0xb7, 0xae, 0x6e, 0x4f, 0xae}; + uint8_t bytesprops2[] = {0x66, 0x2b, 0x91, 0xac, 0xd6, 0x61, 0x25, 0x99, 0x97, 0xba}; + uint8_t bytesprops1[] = {0x82, 0xe2}; + uint8_t bytesprops3[] = {0x23, 0x58, 0x8, 0xf2, 0x7e, 0x3a, 0xf6, 0x58, 0x1a, 0x6f, 0x9b, 0x76, 0x7e, 0x1b, 0xbd, 0xb9, 0x9f, 0x69, 0xcb}; + uint8_t bytesprops4[] = {0xc7, 0x7a, 0xf2, 0x42, 0x76, 0xd2, 0x30, 0xbb, 0xf0, 0x90, 0xc6, 0xf7}; + uint8_t bytesprops5[] = {0x3e, 0x4c, 0x5e, 0xa2, 0xbd, 0x4c, 0x8, 0xa6, 0xb, 0x1c, 0x8b, 0x51, 0x26, 0x19, 0x34, 0xe8, 0x9c, 0xe7, 0xd4, 0x48, 0xae, 0xf4, 0x9, 0xbc, 0xca, 0x9a}; + uint8_t bytesprops6[] = {0x52, 0xb3, 0x97, 0xd2, 0x7e, 0x59, 0x6c, 0x35, 0xda, 0xd0, 0x6b, 0xb4, 0x9f, 0x4b, 0xb0, 0x8a}; + uint8_t bytesprops7[] = {0xb, 0xbc, 0x6b, 0xa3, 0x57, 0x1}; + uint8_t bytesprops8[] = {0xa2, 0x1, 0xb4, 0x48, 0x4c, 0xde, 0xf5, 0x48, 0xb, 0x13}; + uint8_t bytesprops9[] = {0x95, 0xf1, 0xdf, 0x32, 0x19, 0x15, 0xf9, 0x47}; + uint8_t bytesprops10[] = {0xa6, 0xeb, 0x6b, 0x30, 0xbb, 0x5a, 0xca, 0xf8, 0xc3, 0xad, 0x2, 0xe8, 0x4f, 0x83, 0xd9, 0xa, 0xa5, 0xc5, 0x7d, 0xc9, 0x89, 0x94, 0x98, 0xf2, 0x2d, 0xca}; + uint8_t bytesprops11[] = {0x6e, 0x15, 0x33, 0xae, 0x54, 0x92, 0xc4, 0xf, 0xaa, 0x93, 0x32, 0x70, 0x81, 0xff, 0x75, 0x6d, 0x36, 0xc2, 0x13, 0x17, 0x2b, 0x5b, 0x93, 0x36, 0x92, 0xca, 0x22, 0x28}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={2, (char*)&bytesprops1}, .v={10, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19057}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12821}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20007}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23538}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21495}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13410}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22642}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25224}}, + }; + + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 157, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoReceiveMaximumExceeded [PropServerKeepAlive 16952,PropMessageExpiryInterval 27410,PropResponseInformation "\135\SOHA\239\&0yy\227f\189\169\\\155\&6\233\164Ly\180\183",PropServerKeepAlive 29488,PropUserProperty "\197A\138t#\164\247\192" "\176\139K9\227M+ GBHp[,\205\&0\155`1\214QY1\220\187\217\255",PropUserProperty "oZJ\246\&1\200C\251\164\148\ENQ\200/\223\187+\228\FS\CANOM" "Z\154x6\247\138oFY\RS^\237",PropReasonString "\168\141\189f\166",PropSessionExpiryInterval 7969] +TEST(Disco5QCTest, Encode12) { +uint8_t pkt[] = {0xe0, 0x91, 0x1, 0x95, 0x8e, 0x1, 0x22, 0xb, 0x2, 0x2, 0x0, 0x0, 0x6f, 0x61, 0x17, 0x5d, 0x2, 0x0, 0x0, 0x25, 0xe4, 0x1f, 0x0, 0x1d, 0x30, 0xf4, 0x27, 0x26, 0xa, 0x55, 0x1a, 0xa2, 0x88, 0x65, 0x6, 0x6c, 0x75, 0xf3, 0x5e, 0xa8, 0x40, 0x7f, 0x8, 0x20, 0x45, 0x50, 0x34, 0xbc, 0x32, 0x83, 0x3d, 0x59, 0x9b, 0x27, 0x0, 0x0, 0x3f, 0x74, 0x2, 0x0, 0x0, 0x6f, 0xf8, 0x1, 0x65, 0x24, 0x9d, 0x1c, 0x0, 0x1e, 0x4a, 0xbf, 0x4, 0xda, 0x19, 0xaf, 0x70, 0x1d, 0x68, 0x20, 0x83, 0xaa, 0xb2, 0x76, 0x38, 0x53, 0x41, 0x8c, 0x6f, 0x28, 0xe7, 0xf5, 0xc7, 0x72, 0x7d, 0x4f, 0x1a, 0xbf, 0x61, 0xf6, 0x19, 0xe8, 0x11, 0x0, 0x0, 0x14, 0x8a, 0x1c, 0x0, 0x19, 0xfe, 0x49, 0xbd, 0xd7, 0x34, 0x6c, 0x2, 0xc9, 0x6c, 0x2f, 0xbe, 0x24, 0xf3, 0x14, 0xae, 0x6b, 0xbf, 0x92, 0x3e, 0x6f, 0x46, 0x59, 0x1e, 0x5e, 0xed, 0x1f, 0x0, 0x5, 0xa8, 0x8d, 0xbd, 0x66, 0xa6, 0x11, 0x0, 0x0, 0x1f, 0x21}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x30, 0xf4, 0x27, 0x26, 0xa, 0x55, 0x1a, 0xa2, 0x88, 0x65, 0x6, 0x6c, 0x75, 0xf3, 0x5e, 0xa8, 0x40, 0x7f, 0x8, 0x20, 0x45, 0x50, 0x34, 0xbc, 0x32, 0x83, 0x3d, 0x59, 0x9b}; + uint8_t bytesprops1[] = {0x4a, 0xbf, 0x4, 0xda, 0x19, 0xaf, 0x70, 0x1d, 0x68, 0x20, 0x83, 0xaa, 0xb2, 0x76, 0x38, 0x53, 0x41, 0x8c, 0x6f, 0x28, 0xe7, 0xf5, 0xc7, 0x72, 0x7d, 0x4f, 0x1a, 0xbf, 0x61, 0xf6}; + uint8_t bytesprops2[] = {0xfe, 0x49, 0xbd, 0xd7, 0x34, 0x6c, 0x2, 0xc9, 0x6c, 0x2f, 0xbe, 0x24, 0xf3, 0x14, 0xae, 0x6b, 0xbf, 0x92, 0x3e, 0x6f, 0x46, 0x59, 0x1e, 0x5e, 0xed}; + uint8_t bytesprops3[] = {0xa8, 0x8d, 0xbd, 0x66, 0xa6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2818}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28513}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9700}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16244}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28664}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5258}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7969}}, + }; + + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 149, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoSubscriptionIdentifiersNotSupported [] +TEST(Disco5QCTest, Encode13) { +uint8_t pkt[] = {0xe0, 0x2, 0xa1, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 161, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoTopicNameInvalid [] +TEST(Disco5QCTest, Encode14) { +uint8_t pkt[] = {0xe0, 0x2, 0x90, 0x0}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + + lwmqtt_property_t propslist[] = { + }; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoImplementationSpecificError [PropContentType "1\178F\173\196\r\132A",PropWillDelayInterval 6837,PropServerReference "<|v\228CL\169i\237\172",PropTopicAlias 11493,PropServerKeepAlive 19636,PropAssignedClientIdentifier "\129\v\157\205\163",PropTopicAlias 2516] +TEST(Disco5QCTest, Encode15) { +uint8_t pkt[] = {0xe0, 0x30, 0x83, 0x2e, 0x3, 0x0, 0x8, 0x31, 0xb2, 0x46, 0xad, 0xc4, 0xd, 0x84, 0x41, 0x18, 0x0, 0x0, 0x1a, 0xb5, 0x1c, 0x0, 0xa, 0x3c, 0x7c, 0x76, 0xe4, 0x43, 0x4c, 0xa9, 0x69, 0xed, 0xac, 0x23, 0x2c, 0xe5, 0x13, 0x4c, 0xb4, 0x12, 0x0, 0x5, 0x81, 0xb, 0x9d, 0xcd, 0xa3, 0x23, 0x9, 0xd4}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x31, 0xb2, 0x46, 0xad, 0xc4, 0xd, 0x84, 0x41}; + uint8_t bytesprops1[] = {0x3c, 0x7c, 0x76, 0xe4, 0x43, 0x4c, 0xa9, 0x69, 0xed, 0xac}; + uint8_t bytesprops2[] = {0x81, 0xb, 0x9d, 0xcd, 0xa3}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6837}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11493}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19636}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2516}}, + }; + + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 131, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoDisconnectWithWill [PropUserProperty ",AK}%a\ESC1c\200\143\134\ESCnN\213\&3" "3\ETXcK\228\241\226\185\248g;\230\CANa\233\189KJ",PropRequestResponseInformation 51,PropCorrelationData "\213\175\164\189\170|",PropContentType "p\CANg\128",PropUserProperty "\171\217.\157`Tc\211\152c\207SmoTlG5Y" "\247p\221\SI\219",PropAuthenticationData "w\ETB\220]zk\212\157{\244\SO:Q-\222U'\218\250\197",PropMessageExpiryInterval 6020,PropSharedSubscriptionAvailable 8,PropContentType ")\250\234\RS\137\154",PropSharedSubscriptionAvailable 51,PropWildcardSubscriptionAvailable 176,PropAuthenticationData "Ot\EOT\222\223\&6\252\139\175\172j\131t`\139\NAK",PropResponseInformation "\"\246\152\142LU\142vr{\171\SUB\138{S\200\ENQ\144q\241 \vG\186",PropUserProperty "\128\ACK\152V\179\163\228x\ESC\160\230\EOT\195\&5\206.yXJf\226=85,lc" "\SO\131\DEL\215\SYN\213\166\183\248L.@7m\245\133\128r\197",PropContentType "\220\199|\NUL/\208.",PropCorrelationData "\f\235\245\219\201\129\152\204\145\148\US7\173\225f\207\r>\201q Q\238\213\247\195\DLE\213\"",PropTopicAliasMaximum 2107,PropCorrelationData "Q\171\138\205N\132\224\212\223\USF\DC2\177C\231\ETB\DLEF\163",PropSubscriptionIdentifier 1,PropServerKeepAlive 24248,PropRequestProblemInformation 138,PropAssignedClientIdentifier "\221\200\223\136\181\179X&i|\251\210\223)$x\US",PropContentType "\150\EM\130",PropRequestResponseInformation 41,PropMessageExpiryInterval 21178,PropContentType "\181\240}\139'\f"] +TEST(Disco5QCTest, Encode16) { +uint8_t pkt[] = {0xe0, 0xda, 0x2, 0x4, 0xd7, 0x2, 0x26, 0x0, 0x11, 0x2c, 0x41, 0x4b, 0x7d, 0x25, 0x61, 0x1b, 0x31, 0x63, 0xc8, 0x8f, 0x86, 0x1b, 0x6e, 0x4e, 0xd5, 0x33, 0x0, 0x12, 0x33, 0x3, 0x63, 0x4b, 0xe4, 0xf1, 0xe2, 0xb9, 0xf8, 0x67, 0x3b, 0xe6, 0x18, 0x61, 0xe9, 0xbd, 0x4b, 0x4a, 0x19, 0x33, 0x9, 0x0, 0x6, 0xd5, 0xaf, 0xa4, 0xbd, 0xaa, 0x7c, 0x3, 0x0, 0x4, 0x70, 0x18, 0x67, 0x80, 0x26, 0x0, 0x13, 0xab, 0xd9, 0x2e, 0x9d, 0x60, 0x54, 0x63, 0xd3, 0x98, 0x63, 0xcf, 0x53, 0x6d, 0x6f, 0x54, 0x6c, 0x47, 0x35, 0x59, 0x0, 0x5, 0xf7, 0x70, 0xdd, 0xf, 0xdb, 0x16, 0x0, 0x14, 0x77, 0x17, 0xdc, 0x5d, 0x7a, 0x6b, 0xd4, 0x9d, 0x7b, 0xf4, 0xe, 0x3a, 0x51, 0x2d, 0xde, 0x55, 0x27, 0xda, 0xfa, 0xc5, 0x2, 0x0, 0x0, 0x17, 0x84, 0x2a, 0x8, 0x3, 0x0, 0x6, 0x29, 0xfa, 0xea, 0x1e, 0x89, 0x9a, 0x2a, 0x33, 0x28, 0xb0, 0x16, 0x0, 0x10, 0x4f, 0x74, 0x4, 0xde, 0xdf, 0x36, 0xfc, 0x8b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, 0x2, 0x0, 0x0, 0x52, 0xba, 0x3, 0x0, 0x6, 0xb5, 0xf0, 0x7d, 0x8b, 0x27, 0xc}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops1[] = {0x33, 0x3, 0x63, 0x4b, 0xe4, 0xf1, 0xe2, 0xb9, 0xf8, 0x67, 0x3b, 0xe6, 0x18, 0x61, 0xe9, 0xbd, 0x4b, 0x4a}; + uint8_t bytesprops0[] = {0x2c, 0x41, 0x4b, 0x7d, 0x25, 0x61, 0x1b, 0x31, 0x63, 0xc8, 0x8f, 0x86, 0x1b, 0x6e, 0x4e, 0xd5, 0x33}; + uint8_t bytesprops2[] = {0xd5, 0xaf, 0xa4, 0xbd, 0xaa, 0x7c}; + uint8_t bytesprops3[] = {0x70, 0x18, 0x67, 0x80}; + uint8_t bytesprops5[] = {0xf7, 0x70, 0xdd, 0xf, 0xdb}; + uint8_t bytesprops4[] = {0xab, 0xd9, 0x2e, 0x9d, 0x60, 0x54, 0x63, 0xd3, 0x98, 0x63, 0xcf, 0x53, 0x6d, 0x6f, 0x54, 0x6c, 0x47, 0x35, 0x59}; + uint8_t bytesprops6[] = {0x77, 0x17, 0xdc, 0x5d, 0x7a, 0x6b, 0xd4, 0x9d, 0x7b, 0xf4, 0xe, 0x3a, 0x51, 0x2d, 0xde, 0x55, 0x27, 0xda, 0xfa, 0xc5}; + uint8_t bytesprops7[] = {0x29, 0xfa, 0xea, 0x1e, 0x89, 0x9a}; + uint8_t bytesprops8[] = {0x4f, 0x74, 0x4, 0xde, 0xdf, 0x36, 0xfc, 0x8b, 0xaf, 0xac, 0x6a, 0x83, 0x74, 0x60, 0x8b, 0x15}; + uint8_t bytesprops9[] = {0x22, 0xf6, 0x98, 0x8e, 0x4c, 0x55, 0x8e, 0x76, 0x72, 0x7b, 0xab, 0x1a, 0x8a, 0x7b, 0x53, 0xc8, 0x5, 0x90, 0x71, 0xf1, 0x20, 0xb, 0x47, 0xba}; + uint8_t bytesprops11[] = {0xe, 0x83, 0x7f, 0xd7, 0x16, 0xd5, 0xa6, 0xb7, 0xf8, 0x4c, 0x2e, 0x40, 0x37, 0x6d, 0xf5, 0x85, 0x80, 0x72, 0xc5}; + uint8_t bytesprops10[] = {0x80, 0x6, 0x98, 0x56, 0xb3, 0xa3, 0xe4, 0x78, 0x1b, 0xa0, 0xe6, 0x4, 0xc3, 0x35, 0xce, 0x2e, 0x79, 0x58, 0x4a, 0x66, 0xe2, 0x3d, 0x38, 0x35, 0x2c, 0x6c, 0x63}; + uint8_t bytesprops12[] = {0xdc, 0xc7, 0x7c, 0x0, 0x2f, 0xd0, 0x2e}; + uint8_t bytesprops13[] = {0xc, 0xeb, 0xf5, 0xdb, 0xc9, 0x81, 0x98, 0xcc, 0x91, 0x94, 0x1f, 0x37, 0xad, 0xe1, 0x66, 0xcf, 0xd, 0x3e, 0xc9, 0x71, 0x20, 0x51, 0xee, 0xd5, 0xf7, 0xc3, 0x10, 0xd5, 0x22}; + uint8_t bytesprops14[] = {0x51, 0xab, 0x8a, 0xcd, 0x4e, 0x84, 0xe0, 0xd4, 0xdf, 0x1f, 0x46, 0x12, 0xb1, 0x43, 0xe7, 0x17, 0x10, 0x46, 0xa3}; + uint8_t bytesprops15[] = {0xdd, 0xc8, 0xdf, 0x88, 0xb5, 0xb3, 0x58, 0x26, 0x69, 0x7c, 0xfb, 0xd2, 0xdf, 0x29, 0x24, 0x78, 0x1f}; + uint8_t bytesprops16[] = {0x96, 0x19, 0x82}; + uint8_t bytesprops17[] = {0xb5, 0xf0, 0x7d, 0x8b, 0x27, 0xc}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={17, (char*)&bytesprops0}, .v={18, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={19, (char*)&bytesprops4}, .v={5, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6020}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={27, (char*)&bytesprops10}, .v={19, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2107}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24248}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops16}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21178}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops17}}}, + }; + + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoKeepAliveTimeout [PropSubscriptionIdentifier 12,PropMaximumPacketSize 27576,PropAuthenticationMethod "r\213\205@*(~\169\246\157(\204a\FSu\232\181",PropAuthenticationMethod "\232\150\a",PropResponseTopic "<921^\207",PropWillDelayInterval 8261,PropWillDelayInterval 20923,PropContentType " \CAN\162\SYN\SOH\NUL\214<\216\218b\NUL#\NUL\STXV\237\EOT",PropMessageExpiryInterval 9198,PropTopicAliasMaximum 5712,PropMessageExpiryInterval 4543,PropResponseInformation "\143\232\CAN\187\155\210gD?",PropMaximumPacketSize 20356,PropRequestResponseInformation 250,PropMaximumQoS 33,PropSessionExpiryInterval 26369,PropUserProperty "3n\227\245\163|\199R\SI\232\199\165\239\161S\141CGR\US\"\170\204\187" "h\238]\187/\157\179",PropAuthenticationMethod "\203\DC4\136\144\202\ETXV\241y\190\DC3Ug5\170\205W\255\151U;\155R",PropAuthenticationData "1\164\129\147Y\183\&0O\146\169\STX\185X\188\219=b\237\249=\129\253",PropPayloadFormatIndicator 54,PropResponseInformation "Y\226\153.\192+\129y\234\CAN\226\188\246\230",PropServerKeepAlive 27270] +TEST(Disco5QCTest, Encode17) { +uint8_t pkt[] = {0xe0, 0xe0, 0x1, 0x8d, 0xdd, 0x1, 0xb, 0xc, 0x27, 0x0, 0x0, 0x6b, 0xb8, 0x15, 0x0, 0x11, 0x72, 0xd5, 0xcd, 0x40, 0x2a, 0x28, 0x7e, 0xa9, 0xf6, 0x9d, 0x28, 0xcc, 0x61, 0x1c, 0x75, 0xe8, 0xb5, 0x15, 0x0, 0x3, 0xe8, 0x96, 0x7, 0x8, 0x0, 0x6, 0x3c, 0x39, 0x32, 0x31, 0x5e, 0xcf, 0x18, 0x0, 0x0, 0x20, 0x45, 0x18, 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x9d, 0x28, 0xcc, 0x61, 0x1c, 0x75, 0xe8, 0xb5}; + uint8_t bytesprops1[] = {0xe8, 0x96, 0x7}; + uint8_t bytesprops2[] = {0x3c, 0x39, 0x32, 0x31, 0x5e, 0xcf}; + uint8_t bytesprops3[] = {0x20, 0x18, 0xa2, 0x16, 0x1, 0x0, 0xd6, 0x3c, 0xd8, 0xda, 0x62, 0x0, 0x23, 0x0, 0x2, 0x56, 0xed, 0x4}; + uint8_t bytesprops4[] = {0x8f, 0xe8, 0x18, 0xbb, 0x9b, 0xd2, 0x67, 0x44, 0x3f}; + uint8_t bytesprops6[] = {0x68, 0xee, 0x5d, 0xbb, 0x2f, 0x9d, 0xb3}; + uint8_t bytesprops5[] = {0x33, 0x6e, 0xe3, 0xf5, 0xa3, 0x7c, 0xc7, 0x52, 0xf, 0xe8, 0xc7, 0xa5, 0xef, 0xa1, 0x53, 0x8d, 0x43, 0x47, 0x52, 0x1f, 0x22, 0xaa, 0xcc, 0xbb}; + uint8_t bytesprops7[] = {0xcb, 0x14, 0x88, 0x90, 0xca, 0x3, 0x56, 0xf1, 0x79, 0xbe, 0x13, 0x55, 0x67, 0x35, 0xaa, 0xcd, 0x57, 0xff, 0x97, 0x55, 0x3b, 0x9b, 0x52}; + uint8_t bytesprops8[] = {0x31, 0xa4, 0x81, 0x93, 0x59, 0xb7, 0x30, 0x4f, 0x92, 0xa9, 0x2, 0xb9, 0x58, 0xbc, 0xdb, 0x3d, 0x62, 0xed, 0xf9, 0x3d, 0x81, 0xfd}; + uint8_t bytesprops9[] = {0x59, 0xe2, 0x99, 0x2e, 0xc0, 0x2b, 0x81, 0x79, 0xea, 0x18, 0xe2, 0xbc, 0xf6, 0xe6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27576}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8261}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20923}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9198}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5712}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4543}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20356}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26369}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={24, (char*)&bytesprops5}, .v={7, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27270}}, + }; + + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 141, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoPayloadFormatInvalid [PropServerReference "\175\212N\225\&9\US0\230\184\130c'\236",PropReceiveMaximum 29122,PropSharedSubscriptionAvailable 74,PropPayloadFormatIndicator 231,PropMessageExpiryInterval 10411] +TEST(Disco5QCTest, Encode18) { +uint8_t pkt[] = {0xe0, 0x1e, 0x99, 0x1c, 0x1c, 0x0, 0xd, 0xaf, 0xd4, 0x4e, 0xe1, 0x39, 0x1f, 0x30, 0xe6, 0xb8, 0x82, 0x63, 0x27, 0xec, 0x21, 0x71, 0xc2, 0x2a, 0x4a, 0x1, 0xe7, 0x2, 0x0, 0x0, 0x28, 0xab}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xaf, 0xd4, 0x4e, 0xe1, 0x39, 0x1f, 0x30, 0xe6, 0xb8, 0x82, 0x63, 0x27, 0xec}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29122}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10411}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 153, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoWildcardSubscriptionsNotSupported [PropRequestProblemInformation 181,PropAuthenticationData "@\ESC\171\213\ENQ\246\&2V\162\238",PropResponseInformation "\129\224i\141\250\208\177",PropWillDelayInterval 13537,PropResponseTopic "\240,\217\SOr\139\147T\a\\\166\135\248\128xe\DC1_\vc\239\165C[\207\246\&6\225\230",PropMaximumQoS 197,PropRequestResponseInformation 14,PropAssignedClientIdentifier ")'\r\233\252\DC4\172\253\232\216\156\188e\NAK/\DC1\152\\\192W.",PropServerReference "\DC4y\207KL",PropMessageExpiryInterval 21283] +TEST(Disco5QCTest, Encode19) { +uint8_t pkt[] = {0xe0, 0x69, 0xa2, 0x67, 0x17, 0xb5, 0x16, 0x0, 0xa, 0x40, 0x1b, 0xab, 0xd5, 0x5, 0xf6, 0x32, 0x56, 0xa2, 0xee, 0x1a, 0x0, 0x7, 0x81, 0xe0, 0x69, 0x8d, 0xfa, 0xd0, 0xb1, 0x18, 0x0, 0x0, 0x34, 0xe1, 0x8, 0x0, 0x1d, 0xf0, 0x2c, 0xd9, 0xe, 0x72, 0x8b, 0x93, 0x54, 0x7, 0x5c, 0xa6, 0x87, 0xf8, 0x80, 0x78, 0x65, 0x11, 0x5f, 0xb, 0x63, 0xef, 0xa5, 0x43, 0x5b, 0xcf, 0xf6, 0x36, 0xe1, 0xe6, 0x24, 0xc5, 0x19, 0xe, 0x12, 0x0, 0x15, 0x29, 0x27, 0xd, 0xe9, 0xfc, 0x14, 0xac, 0xfd, 0xe8, 0xd8, 0x9c, 0xbc, 0x65, 0x15, 0x2f, 0x11, 0x98, 0x5c, 0xc0, 0x57, 0x2e, 0x1c, 0x0, 0x5, 0x14, 0x79, 0xcf, 0x4b, 0x4c, 0x2, 0x0, 0x0, 0x53, 0x23}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x40, 0x1b, 0xab, 0xd5, 0x5, 0xf6, 0x32, 0x56, 0xa2, 0xee}; + uint8_t bytesprops1[] = {0x81, 0xe0, 0x69, 0x8d, 0xfa, 0xd0, 0xb1}; + uint8_t bytesprops2[] = {0xf0, 0x2c, 0xd9, 0xe, 0x72, 0x8b, 0x93, 0x54, 0x7, 0x5c, 0xa6, 0x87, 0xf8, 0x80, 0x78, 0x65, 0x11, 0x5f, 0xb, 0x63, 0xef, 0xa5, 0x43, 0x5b, 0xcf, 0xf6, 0x36, 0xe1, 0xe6}; + uint8_t bytesprops3[] = {0x29, 0x27, 0xd, 0xe9, 0xfc, 0x14, 0xac, 0xfd, 0xe8, 0xd8, 0x9c, 0xbc, 0x65, 0x15, 0x2f, 0x11, 0x98, 0x5c, 0xc0, 0x57, 0x2e}; + uint8_t bytesprops4[] = {0x14, 0x79, 0xcf, 0x4b, 0x4c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13537}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21283}}, + }; + + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 162, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoRetainNotSupported [PropRequestResponseInformation 43,PropMaximumPacketSize 26732,PropSessionExpiryInterval 11092,PropAuthenticationData ". 6\253\225\231\250\150F\177n"] +TEST(Disco5QCTest, Encode20) { +uint8_t pkt[] = {0xe0, 0x1c, 0x9a, 0x1a, 0x19, 0x2b, 0x27, 0x0, 0x0, 0x68, 0x6c, 0x11, 0x0, 0x0, 0x2b, 0x54, 0x16, 0x0, 0xb, 0x2e, 0x20, 0x36, 0xfd, 0xe1, 0xe7, 0xfa, 0x96, 0x46, 0xb1, 0x6e}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x2e, 0x20, 0x36, 0xfd, 0xe1, 0xe7, 0xfa, 0x96, 0x46, 0xb1, 0x6e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26732}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11092}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops0}}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 154, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoDisconnectWithWill [PropServerReference "\166G\177\198e\DC2\DLEr|\231=k\"\217\170\180\164\237\230\214\SYNd\218W\DC2\208",PropRequestProblemInformation 143,PropSubscriptionIdentifier 22,PropMaximumQoS 108] +TEST(Disco5QCTest, Encode21) { +uint8_t pkt[] = {0xe0, 0x25, 0x4, 0x23, 0x1c, 0x0, 0x1a, 0xa6, 0x47, 0xb1, 0xc6, 0x65, 0x12, 0x10, 0x72, 0x7c, 0xe7, 0x3d, 0x6b, 0x22, 0xd9, 0xaa, 0xb4, 0xa4, 0xed, 0xe6, 0xd6, 0x16, 0x64, 0xda, 0x57, 0x12, 0xd0, 0x17, 0x8f, 0xb, 0x16, 0x24, 0x6c}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xa6, 0x47, 0xb1, 0xc6, 0x65, 0x12, 0x10, 0x72, 0x7c, 0xe7, 0x3d, 0x6b, 0x22, 0xd9, 0xaa, 0xb4, 0xa4, 0xed, 0xe6, 0xd6, 0x16, 0x64, 0xda, 0x57, 0x12, 0xd0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoTopicNameInvalid [PropCorrelationData "9\GSX\227\194\168\FS\191\201\219\133\236g",PropUserProperty "\243" "]\238hX\198\183\132\224?\167/\181=yZ{z\178",PropAuthenticationMethod "/\142\aU1\\\186}>V\189`Ap^W%\229[",PropWildcardSubscriptionAvailable 160,PropResponseTopic "(\188\130#",PropReasonString "\150_Z0ef",PropSubscriptionIdentifierAvailable 53,PropReceiveMaximum 12034,PropServerKeepAlive 2916,PropSessionExpiryInterval 10487,PropWillDelayInterval 13840,PropSubscriptionIdentifier 3,PropWildcardSubscriptionAvailable 35,PropReasonString ";H\170\254e=\164\v\213\165\148\134,\226\179uB",PropResponseTopic "5.\184\ETX\194\211\&3\DC3F\133\200\184\222\153\166\207J",PropServerKeepAlive 27368,PropSessionExpiryInterval 10893,PropTopicAliasMaximum 6988] +TEST(Disco5QCTest, Encode22) { +uint8_t pkt[] = {0xe0, 0x9c, 0x1, 0x90, 0x99, 0x1, 0x9, 0x0, 0xd, 0x39, 0x1d, 0x58, 0xe3, 0xc2, 0xa8, 0x1c, 0xbf, 0xc9, 0xdb, 0x85, 0xec, 0x67, 0x26, 0x0, 0x1, 0xf3, 0x0, 0x12, 0x5d, 0xee, 0x68, 0x58, 0xc6, 0xb7, 0x84, 0xe0, 0x3f, 0xa7, 0x2f, 0xb5, 0x3d, 0x79, 0x5a, 0x7b, 0x7a, 0xb2, 0x15, 0x0, 0x13, 0x2f, 0x8e, 0x7, 0x55, 0x31, 0x5c, 0xba, 0x7d, 0x3e, 0x56, 0xbd, 0x60, 0x41, 0x70, 0x5e, 0x57, 0x25, 0xe5, 0x5b, 0x28, 0xa0, 0x8, 0x0, 0x4, 0x28, 0xbc, 0x82, 0x23, 0x1f, 0x0, 0x6, 0x96, 0x5f, 0x5a, 0x30, 0x65, 0x66, 0x29, 0x35, 0x21, 0x2f, 0x2, 0x13, 0xb, 0x64, 0x11, 0x0, 0x0, 0x28, 0xf7, 0x18, 0x0, 0x0, 0x36, 0x10, 0xb, 0x3, 0x28, 0x23, 0x1f, 0x0, 0x11, 0x3b, 0x48, 0xaa, 0xfe, 0x65, 0x3d, 0xa4, 0xb, 0xd5, 0xa5, 0x94, 0x86, 0x2c, 0xe2, 0xb3, 0x75, 0x42, 0x8, 0x0, 0x11, 0x35, 0x2e, 0xb8, 0x3, 0xc2, 0xd3, 0x33, 0x13, 0x46, 0x85, 0xc8, 0xb8, 0xde, 0x99, 0xa6, 0xcf, 0x4a, 0x13, 0x6a, 0xe8, 0x11, 0x0, 0x0, 0x2a, 0x8d, 0x22, 0x1b, 0x4c}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x39, 0x1d, 0x58, 0xe3, 0xc2, 0xa8, 0x1c, 0xbf, 0xc9, 0xdb, 0x85, 0xec, 0x67}; + uint8_t bytesprops2[] = {0x5d, 0xee, 0x68, 0x58, 0xc6, 0xb7, 0x84, 0xe0, 0x3f, 0xa7, 0x2f, 0xb5, 0x3d, 0x79, 0x5a, 0x7b, 0x7a, 0xb2}; + uint8_t bytesprops1[] = {0xf3}; + uint8_t bytesprops3[] = {0x2f, 0x8e, 0x7, 0x55, 0x31, 0x5c, 0xba, 0x7d, 0x3e, 0x56, 0xbd, 0x60, 0x41, 0x70, 0x5e, 0x57, 0x25, 0xe5, 0x5b}; + uint8_t bytesprops4[] = {0x28, 0xbc, 0x82, 0x23}; + uint8_t bytesprops5[] = {0x96, 0x5f, 0x5a, 0x30, 0x65, 0x66}; + uint8_t bytesprops6[] = {0x3b, 0x48, 0xaa, 0xfe, 0x65, 0x3d, 0xa4, 0xb, 0xd5, 0xa5, 0x94, 0x86, 0x2c, 0xe2, 0xb3, 0x75, 0x42}; + uint8_t bytesprops7[] = {0x35, 0x2e, 0xb8, 0x3, 0xc2, 0xd3, 0x33, 0x13, 0x46, 0x85, 0xc8, 0xb8, 0xde, 0x99, 0xa6, 0xcf, 0x4a}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={1, (char*)&bytesprops1}, .v={18, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12034}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2916}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10487}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13840}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27368}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10893}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6988}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoDisconnectWithWill [PropMessageExpiryInterval 31906,PropServerKeepAlive 11688,PropAuthenticationData "\219\215\SI\228Z\ETX\158&\241Om\234)\US\230{=e\189M",PropMaximumQoS 32,PropUserProperty "3\ENQ*\175\DC1c\251\DLE\210f\197\206\199\CAN\237\ACKFx\215" "]\137\&4\EM\232[\243}N^\253S\142\239\238\t8\213-!\129",PropAuthenticationMethod "\204\169\222\&4C\229\EOT\177\143\241\196Od\176,At\199\167\134\206\254\253o\147\143N\232"] +TEST(Disco5QCTest, Encode23) { +uint8_t pkt[] = {0xe0, 0x6f, 0x4, 0x6d, 0x2, 0x0, 0x0, 0x7c, 0xa2, 0x13, 0x2d, 0xa8, 0x16, 0x0, 0x14, 0xdb, 0xd7, 0xf, 0xe4, 0x5a, 0x3, 0x9e, 0x26, 0xf1, 0x4f, 0x6d, 0xea, 0x29, 0x1f, 0xe6, 0x7b, 0x3d, 0x65, 0xbd, 0x4d, 0x24, 0x20, 0x26, 0x0, 0x13, 0x33, 0x5, 0x2a, 0xaf, 0x11, 0x63, 0xfb, 0x10, 0xd2, 0x66, 0xc5, 0xce, 0xc7, 0x18, 0xed, 0x6, 0x46, 0x78, 0xd7, 0x0, 0x15, 0x5d, 0x89, 0x34, 0x19, 0xe8, 0x5b, 0xf3, 0x7d, 0x4e, 0x5e, 0xfd, 0x53, 0x8e, 0xef, 0xee, 0x9, 0x38, 0xd5, 0x2d, 0x21, 0x81, 0x15, 0x0, 0x1c, 0xcc, 0xa9, 0xde, 0x34, 0x43, 0xe5, 0x4, 0xb1, 0x8f, 0xf1, 0xc4, 0x4f, 0x64, 0xb0, 0x2c, 0x41, 0x74, 0xc7, 0xa7, 0x86, 0xce, 0xfe, 0xfd, 0x6f, 0x93, 0x8f, 0x4e, 0xe8}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0xdb, 0xd7, 0xf, 0xe4, 0x5a, 0x3, 0x9e, 0x26, 0xf1, 0x4f, 0x6d, 0xea, 0x29, 0x1f, 0xe6, 0x7b, 0x3d, 0x65, 0xbd, 0x4d}; + uint8_t bytesprops2[] = {0x5d, 0x89, 0x34, 0x19, 0xe8, 0x5b, 0xf3, 0x7d, 0x4e, 0x5e, 0xfd, 0x53, 0x8e, 0xef, 0xee, 0x9, 0x38, 0xd5, 0x2d, 0x21, 0x81}; + uint8_t bytesprops1[] = {0x33, 0x5, 0x2a, 0xaf, 0x11, 0x63, 0xfb, 0x10, 0xd2, 0x66, 0xc5, 0xce, 0xc7, 0x18, 0xed, 0x6, 0x46, 0x78, 0xd7}; + uint8_t bytesprops3[] = {0xcc, 0xa9, 0xde, 0x34, 0x43, 0xe5, 0x4, 0xb1, 0x8f, 0xf1, 0xc4, 0x4f, 0x64, 0xb0, 0x2c, 0x41, 0x74, 0xc7, 0xa7, 0x86, 0xce, 0xfe, 0xfd, 0x6f, 0x93, 0x8f, 0x4e, 0xe8}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31906}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11688}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={19, (char*)&bytesprops1}, .v={21, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops3}}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoWildcardSubscriptionsNotSupported [PropResponseInformation "H\162?|+\SUB}\US\t\180k=\208",PropTopicAlias 30601,PropSubscriptionIdentifier 13,PropUserProperty "\205\129\SYN\199k^\192F\234\153L\136\193\131@d\FS\247^\132" "\131\NUL\135\233\133\212\237\230h",PropAssignedClientIdentifier "\253\235\248\160W\232\204\201\EM\NAK\170\200\205Kd\b\160\224\244E\204\t@a\225\217\ESC\157\186|",PropMessageExpiryInterval 9535,PropContentType "\r\252\178\GS\ESC\164/\191m\150d\255Q",PropRequestResponseInformation 253,PropTopicAlias 1395,PropMaximumPacketSize 9375,PropContentType "\231\"\181&<",PropTopicAliasMaximum 17101,PropRetainAvailable 52,PropRetainAvailable 122,PropMaximumQoS 55,PropRequestResponseInformation 156,PropWildcardSubscriptionAvailable 248,PropMessageExpiryInterval 25630,PropSessionExpiryInterval 676,PropAuthenticationMethod "`\226",PropSubscriptionIdentifierAvailable 77,PropWildcardSubscriptionAvailable 115,PropAuthenticationData "\182\143\250\253vR\150F\226\137J\150\191\198\EM\248\216\NUL?>"] +TEST(Disco5QCTest, Encode24) { +uint8_t pkt[] = {0xe0, 0xb9, 0x1, 0xa2, 0xb6, 0x1, 0x1a, 0x0, 0xd, 0x48, 0xa2, 0x3f, 0x7c, 0x2b, 0x1a, 0x7d, 0x1f, 0x9, 0xb4, 0x6b, 0x3d, 0xd0, 0x23, 0x77, 0x89, 0xb, 0xd, 0x26, 0x0, 0x14, 0xcd, 0x81, 0x16, 0xc7, 0x6b, 0x5e, 0xc0, 0x46, 0xea, 0x99, 0x4c, 0x88, 0xc1, 0x83, 0x40, 0x64, 0x1c, 0xf7, 0x5e, 0x84, 0x0, 0x9, 0x83, 0x0, 0x87, 0xe9, 0x85, 0xd4, 0xed, 0xe6, 0x68, 0x12, 0x0, 0x1e, 0xfd, 0xeb, 0xf8, 0xa0, 0x57, 0xe8, 0xcc, 0xc9, 0x19, 0x15, 0xaa, 0xc8, 0xcd, 0x4b, 0x64, 0x8, 0xa0, 0xe0, 0xf4, 0x45, 0xcc, 0x9, 0x40, 0x61, 0xe1, 0xd9, 0x1b, 0x9d, 0xba, 0x7c, 0x2, 0x0, 0x0, 0x25, 0x3f, 0x3, 0x0, 0xd, 0xd, 0xfc, 0xb2, 0x1d, 0x1b, 0xa4, 0x2f, 0xbf, 0x6d, 0x96, 0x64, 0xff, 0x51, 0x19, 0xfd, 0x23, 0x5, 0x73, 0x27, 0x0, 0x0, 0x24, 0x9f, 0x3, 0x0, 0x5, 0xe7, 0x22, 0xb5, 0x26, 0x3c, 0x22, 0x42, 0xcd, 0x25, 0x34, 0x25, 0x7a, 0x24, 0x37, 0x19, 0x9c, 0x28, 0xf8, 0x2, 0x0, 0x0, 0x64, 0x1e, 0x11, 0x0, 0x0, 0x2, 0xa4, 0x15, 0x0, 0x2, 0x60, 0xe2, 0x29, 0x4d, 0x28, 0x73, 0x16, 0x0, 0x14, 0xb6, 0x8f, 0xfa, 0xfd, 0x76, 0x52, 0x96, 0x46, 0xe2, 0x89, 0x4a, 0x96, 0xbf, 0xc6, 0x19, 0xf8, 0xd8, 0x0, 0x3f, 0x3e}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x48, 0xa2, 0x3f, 0x7c, 0x2b, 0x1a, 0x7d, 0x1f, 0x9, 0xb4, 0x6b, 0x3d, 0xd0}; + uint8_t bytesprops2[] = {0x83, 0x0, 0x87, 0xe9, 0x85, 0xd4, 0xed, 0xe6, 0x68}; + uint8_t bytesprops1[] = {0xcd, 0x81, 0x16, 0xc7, 0x6b, 0x5e, 0xc0, 0x46, 0xea, 0x99, 0x4c, 0x88, 0xc1, 0x83, 0x40, 0x64, 0x1c, 0xf7, 0x5e, 0x84}; + uint8_t bytesprops3[] = {0xfd, 0xeb, 0xf8, 0xa0, 0x57, 0xe8, 0xcc, 0xc9, 0x19, 0x15, 0xaa, 0xc8, 0xcd, 0x4b, 0x64, 0x8, 0xa0, 0xe0, 0xf4, 0x45, 0xcc, 0x9, 0x40, 0x61, 0xe1, 0xd9, 0x1b, 0x9d, 0xba, 0x7c}; + uint8_t bytesprops4[] = {0xd, 0xfc, 0xb2, 0x1d, 0x1b, 0xa4, 0x2f, 0xbf, 0x6d, 0x96, 0x64, 0xff, 0x51}; + uint8_t bytesprops5[] = {0xe7, 0x22, 0xb5, 0x26, 0x3c}; + uint8_t bytesprops6[] = {0x60, 0xe2}; + uint8_t bytesprops7[] = {0xb6, 0x8f, 0xfa, 0xfd, 0x76, 0x52, 0x96, 0x46, 0xe2, 0x89, 0x4a, 0x96, 0xbf, 0xc6, 0x19, 0xf8, 0xd8, 0x0, 0x3f, 0x3e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30601}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={20, (char*)&bytesprops1}, .v={9, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9535}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1395}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9375}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17101}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25630}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 676}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops7}}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 162, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoSessiontakenOver [PropRequestProblemInformation 147,PropMessageExpiryInterval 9332,PropRequestResponseInformation 40,PropResponseInformation "p@d\ESCG.\GS\ENQYk\146",PropSubscriptionIdentifierAvailable 113,PropMessageExpiryInterval 27708,PropServerKeepAlive 21312,PropAuthenticationMethod "\135][)\217\DC4\240\v@\146\210\SO|\ETB\196\148\SI\v&eot\168\173\149\230\247",PropSessionExpiryInterval 18569,PropRequestResponseInformation 98,PropResponseTopic "D\157\149n\nd@\206\195_ZW\162\186\SUB\205\ETX\228\DC1\225\r-\214",PropRequestProblemInformation 73,PropWildcardSubscriptionAvailable 141,PropAssignedClientIdentifier "\194d?Y\181\ESC\194u\DEL\149\215\&3g&Q\SI\v\134\189\167b\134\DLE\214",PropReceiveMaximum 12656,PropRequestProblemInformation 62,PropResponseInformation "\170\232\143G\220\241",PropTopicAlias 28685] +TEST(Disco5QCTest, Encode25) { +uint8_t pkt[] = {0xe0, 0x93, 0x1, 0x8e, 0x90, 0x1, 0x17, 0x93, 0x2, 0x0, 0x0, 0x24, 0x74, 0x19, 0x28, 0x1a, 0x0, 0xb, 0x70, 0x40, 0x64, 0x1b, 0x47, 0x2e, 0x1d, 0x5, 0x59, 0x6b, 0x92, 0x29, 0x71, 0x2, 0x0, 0x0, 0x6c, 0x3c, 0x13, 0x53, 0x40, 0x15, 0x0, 0x1b, 0x87, 0x5d, 0x5b, 0x29, 0xd9, 0x14, 0xf0, 0xb, 0x40, 0x92, 0xd2, 0xe, 0x7c, 0x17, 0xc4, 0x94, 0xf, 0xb, 0x26, 0x65, 0x6f, 0x74, 0xa8, 0xad, 0x95, 0xe6, 0xf7, 0x11, 0x0, 0x0, 0x48, 0x89, 0x19, 0x62, 0x8, 0x0, 0x17, 0x44, 0x9d, 0x95, 0x6e, 0xa, 0x64, 0x40, 0xce, 0xc3, 0x5f, 0x5a, 0x57, 0xa2, 0xba, 0x1a, 0xcd, 0x3, 0xe4, 0x11, 0xe1, 0xd, 0x2d, 0xd6, 0x17, 0x49, 0x28, 0x8d, 0x12, 0x0, 0x18, 0xc2, 0x64, 0x3f, 0x59, 0xb5, 0x1b, 0xc2, 0x75, 0x7f, 0x95, 0xd7, 0x33, 0x67, 0x26, 0x51, 0xf, 0xb, 0x86, 0xbd, 0xa7, 0x62, 0x86, 0x10, 0xd6, 0x21, 0x31, 0x70, 0x17, 0x3e, 0x1a, 0x0, 0x6, 0xaa, 0xe8, 0x8f, 0x47, 0xdc, 0xf1, 0x23, 0x70, 0xd}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x70, 0x40, 0x64, 0x1b, 0x47, 0x2e, 0x1d, 0x5, 0x59, 0x6b, 0x92}; + uint8_t bytesprops1[] = {0x87, 0x5d, 0x5b, 0x29, 0xd9, 0x14, 0xf0, 0xb, 0x40, 0x92, 0xd2, 0xe, 0x7c, 0x17, 0xc4, 0x94, 0xf, 0xb, 0x26, 0x65, 0x6f, 0x74, 0xa8, 0xad, 0x95, 0xe6, 0xf7}; + uint8_t bytesprops2[] = {0x44, 0x9d, 0x95, 0x6e, 0xa, 0x64, 0x40, 0xce, 0xc3, 0x5f, 0x5a, 0x57, 0xa2, 0xba, 0x1a, 0xcd, 0x3, 0xe4, 0x11, 0xe1, 0xd, 0x2d, 0xd6}; + uint8_t bytesprops3[] = {0xc2, 0x64, 0x3f, 0x59, 0xb5, 0x1b, 0xc2, 0x75, 0x7f, 0x95, 0xd7, 0x33, 0x67, 0x26, 0x51, 0xf, 0xb, 0x86, 0xbd, 0xa7, 0x62, 0x86, 0x10, 0xd6}; + uint8_t bytesprops4[] = {0xaa, 0xe8, 0x8f, 0x47, 0xdc, 0xf1}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9332}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27708}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21312}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18569}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12656}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28685}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 142, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoDisconnectWithWill [PropRetainAvailable 130,PropAuthenticationMethod "\NUL\175\222#\241w\211H\140/4\249\v\GS\209\138/\SI~\209",PropAuthenticationMethod "\\\200\SYN\152\131\144<\133\204*\249\180=\185\254G\156\223>)\226[^\237K\ESC3",PropMaximumPacketSize 8572,PropSubscriptionIdentifier 9,PropRetainAvailable 54,PropTopicAlias 1970,PropServerKeepAlive 23614,PropServerKeepAlive 10526,PropRetainAvailable 214,PropSharedSubscriptionAvailable 41,PropResponseTopic "\DEL\EM|\231\226S",PropSharedSubscriptionAvailable 109,PropResponseInformation "",PropWillDelayInterval 281,PropTopicAlias 7326,PropMaximumPacketSize 26693,PropContentType "S\141l\161\207\&3\249\&9\209D\207\&9\197G\134\176c\136<\US\EOTVH\147\231\138\136\186\201\SYN",PropUserProperty "\132\254\170S\168\SOH$\201\199>\151\EM\233.\129y\214" ">G)",PropTopicAlias 32372] +TEST(Disco5QCTest, Encode27) { +uint8_t pkt[] = {0xe0, 0xdf, 0x1, 0x93, 0xdc, 0x1, 0x29, 0xc3, 0x29, 0x76, 0x28, 0x39, 0x2a, 0x97, 0x29, 0xdf, 0x28, 0x7f, 0x1, 0x10, 0x12, 0x0, 0x1, 0x88, 0x15, 0x0, 0x1c, 0x21, 0xcf, 0x4c, 0x7f, 0xda, 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0x3, 0x3e, 0x47, 0x29, 0x23, 0x7e, 0x74}; +uint8_t buf[sizeof(pkt)+10] = { 0 }; + uint8_t bytesprops0[] = {0x88}; + uint8_t bytesprops1[] = {0x21, 0xcf, 0x4c, 0x7f, 0xda, 0x1, 0xf8, 0x9a, 0x88, 0x0, 0x91, 0xb2, 0x90, 0xb3, 0x73, 0x43, 0x80, 0xdb, 0x82, 0xc0, 0x98, 0xab, 0xeb, 0x3f, 0x1f, 0xe9, 0x72, 0x2b}; + uint8_t bytesprops2[] = {0xfe, 0x6c, 0xba, 0xc5, 0xb1, 0x1e, 0xa4, 0xe9, 0x57, 0xd3, 0x2b, 0x58, 0xc9, 0xe1, 0x5b, 0x24, 0xe9, 0xc4, 0xa6, 0x3e, 0xf, 0x7e, 0xd1}; + uint8_t bytesprops3[] = {0x5c, 0xc8, 0x16, 0x98, 0x83, 0x90, 0x3c, 0x85, 0xcc, 0x2a, 0xf9, 0xb4, 0x3d, 0xb9, 0xfe, 0x47, 0x9c, 0xdf, 0x3e, 0x29, 0xe2, 0x5b, 0x5e, 0xed, 0x4b, 0x1b, 0x33}; + uint8_t bytesprops4[] = {0x7f, 0x19, 0x7c, 0xe7, 0xe2, 0x53}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0x53, 0x8d, 0x6c, 0xa1, 0xcf, 0x33, 0xf9, 0x39, 0xd1, 0x44, 0xcf, 0x39, 0xc5, 0x47, 0x86, 0xb0, 0x63, 0x88, 0x3c, 0x1f, 0x4, 0x56, 0x48, 0x93, 0xe7, 0x8a, 0x88, 0xba, 0xc9, 0x16}; + uint8_t bytesprops8[] = {0x3e, 0x47, 0x29}; + uint8_t bytesprops7[] = {0x84, 0xfe, 0xaa, 0x53, 0xa8, 0x1, 0x24, 0xc9, 0xc7, 0x3e, 0x97, 0x19, 0xe9, 0x2e, 0x81, 0x79, 0xd6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2710}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8572}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1970}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23614}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10526}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 281}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7326}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26693}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={17, (char*)&bytesprops7}, .v={3, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32372}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; +size_t len = 0; +lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 147, props); +EXPECT_EQ(err, LWMQTT_SUCCESS); +EXPECT_EQ(len, sizeof(pkt)); +EXPECT_ARRAY_EQ(pkt, buf, len); + +} + + +// DisconnectRequest DiscoQuotaExceeded [PropServerReference "e\227\135\rV\154\ESC\NAK\SI!9s\164]\166(xw\210\239",PropCorrelationData "\v\201\204i\228\149\223\235\226\197\164 Date: Sat, 21 Sep 2019 10:30:13 -0700 Subject: [PATCH 21/26] v5 unsubscribe requests --- gentests/app/Main.hs | 29 +- include/lwmqtt.h | 6 +- src/client.c | 12 +- src/packet.c | 12 +- src/packet.h | 5 +- tests/client.cpp | 10 +- tests/generated.cpp | 34118 ++++++++++++++++++++++++++--------------- tests/packet.cpp | 4 +- 8 files changed, 21509 insertions(+), 12687 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 2bb13c2..5e98e65 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -43,6 +43,9 @@ v311PubReq p50 = let (PublishPkt p) = v311mask (PublishPkt p50) in p v311SubReq :: SubscribeRequest -> SubscribeRequest v311SubReq p50 = let (SubscribePkt p) = v311mask (SubscribePkt p50) in p +v311UnsubReq :: UnsubscribeRequest -> UnsubscribeRequest +v311UnsubReq p50 = let (UnsubscribePkt p) = v311mask (UnsubscribePkt p50) in p + v311SubACKReq :: SubscribeResponse -> SubscribeResponse v311SubACKReq p50 = let (SubACKPkt p) = v311mask (SubACKPkt p50) in p @@ -200,6 +203,26 @@ genPublishTest prot i p@PublishRequest{..} = "lwmqtt_string_t x = exp_topic;\nx = exp_body;\n" ] +genUnsubTest :: ProtocolLevel -> Int -> UnsubscribeRequest -> String +genUnsubTest prot i p@(UnsubscribeRequest pid subs props) = do + genTestFunc "Unsubscribe" "Encode" prot i p $ mconcat [ + "uint8_t buf[sizeof(pkt)+10] = { 0 };\n", + genProperties "props" props, + encodeFilters, + "size_t len;\n", + "lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, ", protlvl prot, ", ", show pid, ", ", + show (length subs), ", topic_filters, props);\n", + " EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + " EXPECT_ARRAY_EQ(pkt, buf, len);\n" + ] + where + encodeFilters = "lwmqtt_string_t topic_filters[" <> show (length subs) <> "];\n" <> + concatMap aSub (zip [0..] subs) + where aSub :: (Int, BL.ByteString) -> String + aSub (i', t) = mconcat [ + encodeString ("topic_filter_s" <> show i') t, + "topic_filters[", show i', "] = topic_filter_s", show i', ";\n" + ] genSubTest :: ProtocolLevel -> Int -> SubscribeRequest -> String genSubTest prot i p@(SubscribeRequest pid subs props) = do @@ -405,8 +428,12 @@ extern "C" { f genSubACKTest Protocol311 (v311SubACKReq <$> subax) f genSubACKTest Protocol50 subax + unsubs <- replicateM numTests $ generate arbitrary + f genUnsubTest Protocol311 (v311UnsubReq <$> unsubs) + f genUnsubTest Protocol50 unsubs + discos <- replicateM numTests $ generate arbitrary - f genDiscoTest Protocol311 (v311DiscoClean <$> discos) + f genDiscoTest Protocol311 (take 2 $ v311DiscoClean <$> discos) -- these are all the same f genDiscoTest Protocol50 discos where diff --git a/include/lwmqtt.h b/include/lwmqtt.h index 8e98826..e34c34b 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -425,7 +425,8 @@ lwmqtt_err_t lwmqtt_subscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic * @param timeout - The command timeout. * @return An error value. */ -lwmqtt_err_t lwmqtt_unsubscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, uint32_t timeout); +lwmqtt_err_t lwmqtt_unsubscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, + lwmqtt_properties_t props, uint32_t timeout); /** * Will send an unsubscribe packet with a single topic filter and wait for the unsuback to complete. @@ -437,7 +438,8 @@ lwmqtt_err_t lwmqtt_unsubscribe(lwmqtt_client_t *client, int count, lwmqtt_strin * @param timeout - The command timeout. * @return An error value. */ -lwmqtt_err_t lwmqtt_unsubscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, uint32_t timeout); +lwmqtt_err_t lwmqtt_unsubscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, lwmqtt_properties_t props, + uint32_t timeout); /** * Will send a disconnect packet and finish the client. diff --git a/src/client.c b/src/client.c index 9e6d290..c19f6a8 100644 --- a/src/client.c +++ b/src/client.c @@ -526,14 +526,15 @@ lwmqtt_err_t lwmqtt_subscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic return lwmqtt_subscribe(client, 1, &topic_filter, &opts, timeout); } -lwmqtt_err_t lwmqtt_unsubscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, uint32_t timeout) { +lwmqtt_err_t lwmqtt_unsubscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, + lwmqtt_properties_t props, uint32_t timeout) { // set command timer client->timer_set(client->command_timer, timeout); // encode unsubscribe packet size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(client->write_buf, client->write_buf_size, &len, - lwmqtt_get_next_packet_id(client), count, topic_filter); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(client->write_buf, client->write_buf_size, &len, client->protocol, + lwmqtt_get_next_packet_id(client), count, topic_filter, props); if (err != LWMQTT_SUCCESS) { return err; } @@ -564,8 +565,9 @@ lwmqtt_err_t lwmqtt_unsubscribe(lwmqtt_client_t *client, int count, lwmqtt_strin return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_unsubscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, uint32_t timeout) { - return lwmqtt_unsubscribe(client, 1, &topic_filter, timeout); +lwmqtt_err_t lwmqtt_unsubscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, lwmqtt_properties_t props, + uint32_t timeout) { + return lwmqtt_unsubscribe(client, 1, &topic_filter, props, timeout); } lwmqtt_err_t lwmqtt_publish(lwmqtt_client_t *client, lwmqtt_string_t topic, lwmqtt_message_t message, diff --git a/src/packet.c b/src/packet.c index 14c4c0b..3ce2901 100644 --- a/src/packet.c +++ b/src/packet.c @@ -739,14 +739,15 @@ lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_encode_unsubscribe(uint8_t *buf, size_t buf_len, size_t *len, uint16_t packet_id, int count, - lwmqtt_string_t *topic_filters) { +lwmqtt_err_t lwmqtt_encode_unsubscribe(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, + uint16_t packet_id, int count, lwmqtt_string_t *topic_filters, + lwmqtt_properties_t props) { // prepare pointer uint8_t *buf_ptr = buf; uint8_t *buf_end = buf + buf_len; // calculate remaining length - uint32_t rem_len = 2; + uint32_t rem_len = 2 + lwmqtt_propslen(protocol, props); for (int i = 0; i < count; i++) { rem_len += 2 + topic_filters[i].len; } @@ -785,6 +786,11 @@ lwmqtt_err_t lwmqtt_encode_unsubscribe(uint8_t *buf, size_t buf_len, size_t *len return err; } + err = lwmqtt_write_props(&buf_ptr, buf_end, protocol, props); + if (err != LWMQTT_SUCCESS) { + return err; + } + // write topics for (int i = 0; i < count; i++) { err = lwmqtt_write_string(&buf_ptr, buf_end, topic_filters[i]); diff --git a/src/packet.h b/src/packet.h index 9c1ffef..13b54ff 100644 --- a/src/packet.h +++ b/src/packet.h @@ -187,7 +187,8 @@ lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet * @param topic_filters - The array of topic filters. * @return An error value. */ -lwmqtt_err_t lwmqtt_encode_unsubscribe(uint8_t *buf, size_t buf_len, size_t *len, uint16_t packet_id, int count, - lwmqtt_string_t *topic_filters); +lwmqtt_err_t lwmqtt_encode_unsubscribe(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, + uint16_t packet_id, int count, lwmqtt_string_t *topic_filters, + lwmqtt_properties_t props); #endif // LWMQTT_PACKET_H diff --git a/tests/client.cpp b/tests/client.cpp index 1cdfaa2..3925809 100644 --- a/tests/client.cpp +++ b/tests/client.cpp @@ -98,7 +98,7 @@ TEST(Client, PublishSubscribeQOS0) { } } - err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), COMMAND_TIMEOUT); + err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); @@ -159,7 +159,7 @@ TEST(Client, PublishSubscribeQOS1) { } } - err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), COMMAND_TIMEOUT); + err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); @@ -220,7 +220,7 @@ TEST(Client, PublishSubscribeQOS2) { } } - err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), COMMAND_TIMEOUT); + err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); @@ -408,7 +408,7 @@ TEST(Client, BigBuffersAndPayload) { } } - err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), COMMAND_TIMEOUT); + err = lwmqtt_unsubscribe_one(&client, lwmqtt_string("lwmqtt"), empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); @@ -471,7 +471,7 @@ TEST(Client, MultipleSubscriptions) { } } - err = lwmqtt_unsubscribe(&client, 2, topic_filters, COMMAND_TIMEOUT); + err = lwmqtt_unsubscribe(&client, 2, topic_filters, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); err = lwmqtt_disconnect(&client, 0, empty_props, COMMAND_TIMEOUT); diff --git a/tests/generated.cpp b/tests/generated.cpp index cb7f12c..f062ca8 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,14713 +21,23497 @@ extern "C" { } \ } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = ";\135[\241\201\187\168\ETX\227\158\138\182\179\234\250\172\152\219\131\130!", _pubPktID = 24061, _pubBody = "\206\141\147\181o\253", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\137\189\213\133\214H\EM\161\170\241\136", _pubPktID = 0, _pubBody = "\217\146\229\195\163\175\196\174y0d\141b\146", +// _pubProps = []} TEST(Publish311QCTest, Encode1) { -uint8_t pkt[] = {0x33, 0x1f, 0x0, 0x15, 0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21, 0x5d, 0xfd, 0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; - uint8_t topic_bytes[] = {0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x1b, 0x0, 0xb, 0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88, + 0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + uint8_t topic_bytes[] = {0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 6; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24061, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = ";\135[\241\201\187\168\ETX\227\158\138\182\179\234\250\172\152\219\131\130!", _pubPktID = 24061, _pubBody = "\206\141\147\181o\253", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\137\189\213\133\214H\EM\161\170\241\136", _pubPktID = 0, _pubBody = "\217\146\229\195\163\175\196\174y0d\141b\146", +// _pubProps = []} TEST(Publish311QCTest, Decode1) { -uint8_t pkt[] = {0x33, 0x1f, 0x0, 0x15, 0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21, 0x5d, 0xfd, 0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; - lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 24061); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); -EXPECT_EQ(msg.payload_len, 6); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x31, 0x1b, 0x0, 0xb, 0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88, + 0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\148\US\b\177\214\241A\128\215\138NRR\141\t\208\DC4\231\253\232\EM\205\r\162\157", _pubPktID = 0, _pubBody = "\DELQr", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\183\249", _pubPktID = 0, _pubBody +// = "M\EOTga\US?`w\167\&6\152\SI\NAKC\168>\173<\149\213m,5\235\133\r\180\190\195", _pubProps = []} TEST(Publish311QCTest, Encode2) { -uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x19, 0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d, 0x7f, 0x51, 0x72}; - uint8_t topic_bytes[] = {0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x21, 0x0, 0x2, 0xb7, 0xf9, 0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, + 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, 0x3e, 0xad, 0x3c, + 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + uint8_t topic_bytes[] = {0xb7, 0xf9}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS0; -msg.retained = true; -uint8_t msg_bytes[] = {0x7f, 0x51, 0x72}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 3; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, + 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\148\US\b\177\214\241A\128\215\138NRR\141\t\208\DC4\231\253\232\EM\205\r\162\157", _pubPktID = 0, _pubBody = "\DELQr", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\183\249", _pubPktID = 0, _pubBody +// = "M\EOTga\US?`w\167\&6\152\SI\NAKC\168>\173<\149\213m,5\235\133\r\180\190\195", _pubProps = []} TEST(Publish311QCTest, Decode2) { -uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x19, 0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d, 0x7f, 0x51, 0x72}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7f, 0x51, 0x72}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS0); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 0); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); -EXPECT_EQ(msg.payload_len, 3); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x30, 0x21, 0x0, 0x2, 0xb7, 0xf9, 0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, + 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, 0x3e, 0xad, 0x3c, + 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CANO\164\EM\236\160:x\bB\170\222ObK\201\DC1\168W}>\187\DC1", _pubPktID = 0, _pubBody = "", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xb7, 0xf9}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, + 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\DC1\157\ns\ETX0?\130,\153\&5(\EM\NAK\235tg/\223cz\215\188l", _pubPktID = 23951, _pubBody = "\252\STX\212\139", +// _pubProps = []} TEST(Publish311QCTest, Encode3) { -uint8_t pkt[] = {0x38, 0x19, 0x0, 0x17, 0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; - uint8_t topic_bytes[] = {0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS0; -msg.retained = false; -uint8_t msg_bytes[] = {0}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 0; - - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x3a, 0x20, 0x0, 0x18, 0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, + 0x2c, 0x99, 0x35, 0x28, 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, + 0x7a, 0xd7, 0xbc, 0x6c, 0x5d, 0x8f, 0xfc, 0x2, 0xd4, 0x8b}; + uint8_t topic_bytes[] = {0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, + 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xbc, 0x6c}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xfc, 0x2, 0xd4, 0x8b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 23951, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CANO\164\EM\236\160:x\bB\170\222ObK\201\DC1\168W}>\187\DC1", _pubPktID = 0, _pubBody = "", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\DC1\157\ns\ETX0?\130,\153\&5(\EM\NAK\235tg/\223cz\215\188l", _pubPktID = 23951, _pubBody = "\252\STX\212\139", +// _pubProps = []} TEST(Publish311QCTest, Decode3) { -uint8_t pkt[] = {0x38, 0x19, 0x0, 0x17, 0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS0); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 0); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); -EXPECT_EQ(msg.payload_len, 0); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x3a, 0x20, 0x0, 0x18, 0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, + 0x2c, 0x99, 0x35, 0x28, 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, + 0x7a, 0xd7, 0xbc, 0x6c, 0x5d, 0x8f, 0xfc, 0x2, 0xd4, 0x8b}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "]\151\151\159oP\170", _pubPktID = 14052, _pubBody = "\254\174c\158\219\&7\163j\130\179TW\155\250\141\164c", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, + 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xbc, 0x6c}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfc, 0x2, 0xd4, 0x8b}; + lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 23951); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 4); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "2]\237\233\224\238", _pubPktID = +// 32430, _pubBody = "\\7\a}d\f\191)\250N\n\r\240\169\178\184]", _pubProps = []} TEST(Publish311QCTest, Encode4) { -uint8_t pkt[] = {0x3b, 0x1c, 0x0, 0x7, 0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa, 0x36, 0xe4, 0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; - uint8_t topic_bytes[] = {0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x1b, 0x0, 0x6, 0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee, 0x7e, 0xae, 0x5c, 0x37, 0x7, + 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; + uint8_t topic_bytes[] = {0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 17; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x5c, 0x37, 0x7, 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, + 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 17; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 14052, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32430, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "]\151\151\159oP\170", _pubPktID = 14052, _pubBody = "\254\174c\158\219\&7\163j\130\179TW\155\250\141\164c", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "2]\237\233\224\238", _pubPktID = +// 32430, _pubBody = "\\7\a}d\f\191)\250N\n\r\240\169\178\184]", _pubProps = []} TEST(Publish311QCTest, Decode4) { -uint8_t pkt[] = {0x3b, 0x1c, 0x0, 0x7, 0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa, 0x36, 0xe4, 0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 14052); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); -EXPECT_EQ(msg.payload_len, 17); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x35, 0x1b, 0x0, 0x6, 0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee, 0x7e, 0xae, 0x5c, 0x37, 0x7, + 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "F\129\169\SYN\215A[Qx}\223\&7NE\181\250\249\236\208\GSL\217\176\183\235\&0\189\247u_", _pubPktID = 26784, _pubBody = "\176\&0\158\138\138]\220(B\154\&3\224jV\159v+\130", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5c, 0x37, 0x7, 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, + 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 32430); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "V\156\142\176", _pubPktID = 29213, +// _pubBody = "\EM\FSK\190t\254o\168\200\&9\131(\254Z\138g\243jL|\137\220", _pubProps = []} TEST(Publish311QCTest, Encode5) { -uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x1e, 0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f, 0x68, 0xa0, 0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; - uint8_t topic_bytes[] = {0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 18; - - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x35, 0x1e, 0x0, 0x4, 0x56, 0x9c, 0x8e, 0xb0, 0x72, 0x1d, 0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, + 0x6f, 0xa8, 0xc8, 0x39, 0x83, 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + uint8_t topic_bytes[] = {0x56, 0x9c, 0x8e, 0xb0}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, 0x6f, 0xa8, 0xc8, 0x39, 0x83, + 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 26784, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29213, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "F\129\169\SYN\215A[Qx}\223\&7NE\181\250\249\236\208\GSL\217\176\183\235\&0\189\247u_", _pubPktID = 26784, _pubBody = "\176\&0\158\138\138]\220(B\154\&3\224jV\159v+\130", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "V\156\142\176", _pubPktID = 29213, +// _pubBody = "\EM\FSK\190t\254o\168\200\&9\131(\254Z\138g\243jL|\137\220", _pubProps = []} TEST(Publish311QCTest, Decode5) { -uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x1e, 0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f, 0x68, 0xa0, 0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f}; - lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 26784); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); -EXPECT_EQ(msg.payload_len, 18); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x35, 0x1e, 0x0, 0x4, 0x56, 0x9c, 0x8e, 0xb0, 0x72, 0x1d, 0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, + 0x6f, 0xa8, 0xc8, 0x39, 0x83, 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "IP\\2\223\164P[u\SI\DLEh\171x\188\185\177Q#\163v7L\224Y;5", _pubPktID = 14257, _pubBody = "\215Vs\129\239\168\165b\145\208\232`\245", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x56, 0x9c, 0x8e, 0xb0}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, 0x6f, 0xa8, 0xc8, 0x39, 0x83, + 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 29213); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "j-w\135im\135", _pubPktID = 15185, +// _pubBody = "\178\183W\163D\179", _pubProps = []} TEST(Publish311QCTest, Encode6) { -uint8_t pkt[] = {0x35, 0x2c, 0x0, 0x1b, 0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35, 0x37, 0xb1, 0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; - uint8_t topic_bytes[] = {0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x11, 0x0, 0x7, 0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, + 0x87, 0x3b, 0x51, 0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + uint8_t topic_bytes[] = {0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 13; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 6; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 14257, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15185, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "IP\\2\223\164P[u\SI\DLEh\171x\188\185\177Q#\163v7L\224Y;5", _pubPktID = 14257, _pubBody = "\215Vs\129\239\168\165b\145\208\232`\245", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "j-w\135im\135", _pubPktID = 15185, +// _pubBody = "\178\183W\163D\179", _pubProps = []} TEST(Publish311QCTest, Decode6) { -uint8_t pkt[] = {0x35, 0x2c, 0x0, 0x1b, 0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35, 0x37, 0xb1, 0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 14257); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); -EXPECT_EQ(msg.payload_len, 13); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x35, 0x11, 0x0, 0x7, 0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, + 0x87, 0x3b, 0x51, 0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "6\RS\235\193R\DEL\172\233\219\ETX\209a8\243\RS\229\&2a", _pubPktID = 10501, _pubBody = "*K\219};J\192L&\150k\230#\253#\163\207\128\170\174\GS{\t", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 15185); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129\166\ACK\241", _pubPktID = 26446, +// _pubBody = "h'uL\n\225\221gp\182{\140\DC4\136\151c\170\191\r|\214\197\&7", _pubProps = []} TEST(Publish311QCTest, Encode7) { -uint8_t pkt[] = {0x3d, 0x2d, 0x0, 0x12, 0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61, 0x29, 0x5, 0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; - uint8_t topic_bytes[] = {0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 23; - - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x3d, 0x1f, 0x0, 0x4, 0x81, 0xa6, 0x6, 0xf1, 0x67, 0x4e, 0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, + 0x67, 0x70, 0xb6, 0x7b, 0x8c, 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + uint8_t topic_bytes[] = {0x81, 0xa6, 0x6, 0xf1}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, 0x67, 0x70, 0xb6, 0x7b, 0x8c, + 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 23; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 10501, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 26446, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "6\RS\235\193R\DEL\172\233\219\ETX\209a8\243\RS\229\&2a", _pubPktID = 10501, _pubBody = "*K\219};J\192L&\150k\230#\253#\163\207\128\170\174\GS{\t", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129\166\ACK\241", _pubPktID = 26446, +// _pubBody = "h'uL\n\225\221gp\182{\140\DC4\136\151c\170\191\r|\214\197\&7", _pubProps = []} TEST(Publish311QCTest, Decode7) { -uint8_t pkt[] = {0x3d, 0x2d, 0x0, 0x12, 0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61, 0x29, 0x5, 0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 10501); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); -EXPECT_EQ(msg.payload_len, 23); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x3d, 0x1f, 0x0, 0x4, 0x81, 0xa6, 0x6, 0xf1, 0x67, 0x4e, 0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, + 0x67, 0x70, 0xb6, 0x7b, 0x8c, 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\129\171\&3\ETBSN", _pubPktID = 5903, _pubBody = "zPg\212~f\130\171\232\241P\212\ENQ'\234'@\v\177;s\157z*\DC2{\148\&6|", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x81, 0xa6, 0x6, 0xf1}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, 0x67, 0x70, 0xb6, 0x7b, 0x8c, + 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 26446); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "}\250\132\234S\200EV\164\175\218\237D", _pubPktID = 25658, _pubBody = +// "\DLE\DC3\242\235C\134\216h\196\ETB\255\169\164\222", _pubProps = []} TEST(Publish311QCTest, Encode8) { -uint8_t pkt[] = {0x3c, 0x27, 0x0, 0x6, 0x81, 0xab, 0x33, 0x17, 0x53, 0x4e, 0x17, 0xf, 0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; - uint8_t topic_bytes[] = {0x81, 0xab, 0x33, 0x17, 0x53, 0x4e}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x1f, 0x0, 0xd, 0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44, + 0x64, 0x3a, 0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + uint8_t topic_bytes[] = {0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = false; -uint8_t msg_bytes[] = {0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 29; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5903, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25658, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\129\171\&3\ETBSN", _pubPktID = 5903, _pubBody = "zPg\212~f\130\171\232\241P\212\ENQ'\234'@\v\177;s\157z*\DC2{\148\&6|", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "}\250\132\234S\200EV\164\175\218\237D", _pubPktID = 25658, _pubBody = +// "\DLE\DC3\242\235C\134\216h\196\ETB\255\169\164\222", _pubProps = []} TEST(Publish311QCTest, Decode8) { -uint8_t pkt[] = {0x3c, 0x27, 0x0, 0x6, 0x81, 0xab, 0x33, 0x17, 0x53, 0x4e, 0x17, 0xf, 0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x81, 0xab, 0x33, 0x17, 0x53, 0x4e}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 5903); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); -EXPECT_EQ(msg.payload_len, 29); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x3d, 0x1f, 0x0, 0xd, 0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44, + 0x64, 0x3a, 0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "f\145?\ETXkG", _pubPktID = 0, _pubBody = "z)\172\246\137o\201C\144\161\ETX\DC4\243V\SI\136\ETX\223\135V\253\SYN\a\200.", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 25658); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\ETB\EM\FSn\\^\219_\249\191\CAN\146\196\142\252x\187\173 \r\244[B\136h\210\180", _pubPktID = 12697, _pubBody = +// "\208\EOT\241", _pubProps = []} TEST(Publish311QCTest, Encode9) { -uint8_t pkt[] = {0x31, 0x21, 0x0, 0x6, 0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47, 0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; - uint8_t topic_bytes[] = {0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x1b, 0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, + 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, + 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4, 0x31, 0x99, 0xd0, 0x4, 0xf1}; + uint8_t topic_bytes[] = {0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, + 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS0; -msg.retained = true; -uint8_t msg_bytes[] = {0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 25; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xd0, 0x4, 0xf1}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 12697, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "f\145?\ETXkG", _pubPktID = 0, _pubBody = "z)\172\246\137o\201C\144\161\ETX\DC4\243V\SI\136\ETX\223\135V\253\SYN\a\200.", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\ETB\EM\FSn\\^\219_\249\191\CAN\146\196\142\252x\187\173 \r\244[B\136h\210\180", _pubPktID = 12697, _pubBody = +// "\208\EOT\241", _pubProps = []} TEST(Publish311QCTest, Decode9) { -uint8_t pkt[] = {0x31, 0x21, 0x0, 0x6, 0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47, 0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS0); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 0); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); -EXPECT_EQ(msg.payload_len, 25); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x1b, 0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, + 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, + 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4, 0x31, 0x99, 0xd0, 0x4, 0xf1}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\155rvW\187y*a\164\152\nL\EMg}@\SYN\142\DC2", _pubPktID = 0, _pubBody = "\US\US\DLE\ESC\221J\DC3T\209\207\183rx\202;\229\224\EM\241z#\169X\166\139", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, + 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd0, 0x4, 0xf1}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 12697); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\207\219\241(topic.data), 19); -EXPECT_EQ(msg.payload_len, 25); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x39, 0x23, 0x0, 0x8, 0xcf, 0xdb, 0xf1, 0x3c, 0x61, 0xc4, 0x62, 0xd, 0xf8, + 0xff, 0xd1, 0x80, 0x73, 0xa9, 0xb3, 0xf5, 0xcb, 0x2e, 0x1c, 0x28, 0xb3, 0x6f, + 0x3, 0x6b, 0xd, 0x27, 0x78, 0xef, 0x17, 0x3d, 0xbd, 0x3e, 0x71}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "2n\201\176\229\EM\245*\ACK\SUB\177\b~\130\155,l", _pubPktID = 18294, _pubBody = "22", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xcf, 0xdb, 0xf1, 0x3c, 0x61, 0xc4, 0x62, 0xd}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf8, 0xff, 0xd1, 0x80, 0x73, 0xa9, 0xb3, 0xf5, 0xcb, 0x2e, 0x1c, 0x28, 0xb3, + 0x6f, 0x3, 0x6b, 0xd, 0x27, 0x78, 0xef, 0x17, 0x3d, 0xbd, 0x3e, 0x71}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\218\230\US\223|\136nz\184\f)s\246ht", _pubPktID = 0, _pubBody = "\209", _pubProps = []} TEST(Publish311QCTest, Encode11) { -uint8_t pkt[] = {0x33, 0x17, 0x0, 0x11, 0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c, 0x47, 0x76, 0x32, 0x32}; - uint8_t topic_bytes[] = {0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x12, 0x0, 0xf, 0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, + 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74, 0xd1}; + uint8_t topic_bytes[] = {0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x32, 0x32}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 2; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xd1}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 18294, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "2n\201\176\229\EM\245*\ACK\SUB\177\b~\130\155,l", _pubPktID = 18294, _pubBody = "22", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\218\230\US\223|\136nz\184\f)s\246ht", _pubPktID = 0, _pubBody = "\209", _pubProps = []} TEST(Publish311QCTest, Decode11) { -uint8_t pkt[] = {0x33, 0x17, 0x0, 0x11, 0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c, 0x47, 0x76, 0x32, 0x32}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c}; - lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x32, 0x32}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 18294); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); -EXPECT_EQ(msg.payload_len, 2); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x39, 0x12, 0x0, 0xf, 0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, + 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74, 0xd1}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\SI\221\168J\184\157\208vn\224\GS", _pubPktID = 19130, _pubBody = "=m\162\166\ETX\DEL\SI?\155\155\229\193\RS\194\ETX^\144\196\"\134\199\t\254\147\&1\ESC\221\132", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd1}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\185\207+s\131Y\252\238R\EOT\183\224\v\195'\154V\SUB\214", _pubPktID = 0, _pubBody = +// "n\190=U\SI\224\255\fT\157I\150?Z\SI\215\177\163\143\SUB", _pubProps = []} TEST(Publish311QCTest, Encode12) { -uint8_t pkt[] = {0x3c, 0x2b, 0x0, 0xb, 0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d, 0x4a, 0xba, 0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; - uint8_t topic_bytes[] = {0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x29, 0x0, 0x13, 0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, 0xb7, + 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6, 0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, + 0xc, 0x54, 0x9d, 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + uint8_t topic_bytes[] = {0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, + 0xb7, 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = false; -uint8_t msg_bytes[] = {0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 28; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, + 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 20; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 19130, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\SI\221\168J\184\157\208vn\224\GS", _pubPktID = 19130, _pubBody = "=m\162\166\ETX\DEL\SI?\155\155\229\193\RS\194\ETX^\144\196\"\134\199\t\254\147\&1\ESC\221\132", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\185\207+s\131Y\252\238R\EOT\183\224\v\195'\154V\SUB\214", _pubPktID = 0, _pubBody = +// "n\190=U\SI\224\255\fT\157I\150?Z\SI\215\177\163\143\SUB", _pubProps = []} TEST(Publish311QCTest, Decode12) { -uint8_t pkt[] = {0x3c, 0x2b, 0x0, 0xb, 0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d, 0x4a, 0xba, 0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 19130); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); -EXPECT_EQ(msg.payload_len, 28); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x31, 0x29, 0x0, 0x13, 0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, 0xb7, + 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6, 0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, + 0xc, 0x54, 0x9d, 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\n\159\143\162\210", _pubPktID = 3591, _pubBody = "\156|7\ETB|\195\202\&4y", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, + 0xb7, 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6}; + lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, + 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "-\224\164\222\163\DLE\224\218\229\CAN!n\rZ\193Y\DC3r\129\219T\172\139\252\&2~", _pubPktID = 8532, _pubBody = +// "\145b$\DEL\237\176\245E\250\186\STX\US|\163\f\221\190&\238\vu\US", _pubProps = []} TEST(Publish311QCTest, Encode13) { -uint8_t pkt[] = {0x32, 0x12, 0x0, 0x5, 0xa, 0x9f, 0x8f, 0xa2, 0xd2, 0xe, 0x7, 0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; - uint8_t topic_bytes[] = {0xa, 0x9f, 0x8f, 0xa2, 0xd2}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = false; -uint8_t msg_bytes[] = {0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 9; - - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x1a, 0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, + 0x21, 0x6e, 0xd, 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, + 0x32, 0x7e, 0x21, 0x54, 0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, + 0x2, 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; + uint8_t topic_bytes[] = {0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, 0x21, 0x6e, 0xd, + 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, 0x32, 0x7e}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, 0x2, + 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3591, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 8532, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\n\159\143\162\210", _pubPktID = 3591, _pubBody = "\156|7\ETB|\195\202\&4y", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "-\224\164\222\163\DLE\224\218\229\CAN!n\rZ\193Y\DC3r\129\219T\172\139\252\&2~", _pubPktID = 8532, _pubBody = +// "\145b$\DEL\237\176\245E\250\186\STX\US|\163\f\221\190&\238\vu\US", _pubProps = []} TEST(Publish311QCTest, Decode13) { -uint8_t pkt[] = {0x32, 0x12, 0x0, 0x5, 0xa, 0x9f, 0x8f, 0xa2, 0xd2, 0xe, 0x7, 0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa, 0x9f, 0x8f, 0xa2, 0xd2}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 3591); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); -EXPECT_EQ(msg.payload_len, 9); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x1a, 0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, + 0x21, 0x6e, 0xd, 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, + 0x32, 0x7e, 0x21, 0x54, 0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, + 0x2, 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\158\ESC\165s\240j\195I_\176\246\204\148I\213T\244\169E", _pubPktID = 15997, _pubBody = "tS\247\226P\227\&3\NUL\222\DC37I\219'", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, 0x21, 0x6e, 0xd, + 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, 0x32, 0x7e}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, 0x2, + 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 8532); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "8(\GS\144\187\237\&8\196sz", +// _pubPktID = 0, _pubBody = "0zBlyt\159", _pubProps = []} TEST(Publish311QCTest, Encode14) { -uint8_t pkt[] = {0x33, 0x25, 0x0, 0x13, 0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45, 0x3e, 0x7d, 0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; - uint8_t topic_bytes[] = {0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x13, 0x0, 0xa, 0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, + 0xc4, 0x73, 0x7a, 0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + uint8_t topic_bytes[] = {0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 14; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 7; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15997, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\158\ESC\165s\240j\195I_\176\246\204\148I\213T\244\169E", _pubPktID = 15997, _pubBody = "tS\247\226P\227\&3\NUL\222\DC37I\219'", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "8(\GS\144\187\237\&8\196sz", +// _pubPktID = 0, _pubBody = "0zBlyt\159", _pubProps = []} TEST(Publish311QCTest, Decode14) { -uint8_t pkt[] = {0x33, 0x25, 0x0, 0x13, 0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45, 0x3e, 0x7d, 0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45}; - lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 15997); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); -EXPECT_EQ(msg.payload_len, 14); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x39, 0x13, 0x0, 0xa, 0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, + 0xc4, 0x73, 0x7a, 0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\224\135\179\172\244\254\241]\218|\ESC\137/", _pubPktID = 30908, _pubBody = "\235c=\156\"\206\185spp`\235\216", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ")F\t\CAN\159&z\212\EOT\210y\239\190\EOT\131b\161\153I\235\162", _pubPktID = 2063, _pubBody = +// "\SUB\236\&0\ENQ\ACK1\246q@\SUB\224\&3{\175\RS\142k\"", _pubProps = []} TEST(Publish311QCTest, Encode15) { -uint8_t pkt[] = {0x32, 0x1f, 0x0, 0xe, 0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f, 0x78, 0xbc, 0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; - uint8_t topic_bytes[] = {0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x2b, 0x0, 0x15, 0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, + 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2, 0x8, 0xf, 0x1a, 0xec, 0x30, + 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + uint8_t topic_bytes[] = {0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, + 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = false; -uint8_t msg_bytes[] = {0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 13; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x1a, 0xec, 0x30, 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, + 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 18; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 30908, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 2063, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\224\135\179\172\244\254\241]\218|\ESC\137/", _pubPktID = 30908, _pubBody = "\235c=\156\"\206\185spp`\235\216", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ")F\t\CAN\159&z\212\EOT\210y\239\190\EOT\131b\161\153I\235\162", _pubPktID = 2063, _pubBody = +// "\SUB\236\&0\ENQ\ACK1\246q@\SUB\224\&3{\175\RS\142k\"", _pubProps = []} TEST(Publish311QCTest, Decode15) { -uint8_t pkt[] = {0x32, 0x1f, 0x0, 0xe, 0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f, 0x78, 0xbc, 0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 30908); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); -EXPECT_EQ(msg.payload_len, 13); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x34, 0x2b, 0x0, 0x15, 0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, + 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2, 0x8, 0xf, 0x1a, 0xec, 0x30, + 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -} - - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\233\218E\235\207\216\&6b\236\246\&0?\169D\196\137\228\212\200\179\RS\159", _pubPktID = 7795, _pubBody = ")\a\246\&4J\134\237\148\159\143:\EOT\237lN\252D\144\179\163'7\208\193\240", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, + 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1a, 0xec, 0x30, 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, + 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 2063); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\\Z\DLE\\x\DC3\192\DLE", _pubPktID = +// 15081, _pubBody = "\213\141\182\137f\134\150z.K\232\224o\177\FS\156\198\158\CAN\ESC", _pubProps = []} TEST(Publish311QCTest, Encode16) { -uint8_t pkt[] = {0x3d, 0x33, 0x0, 0x16, 0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f, 0x1e, 0x73, 0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; - uint8_t topic_bytes[] = {0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 25; - - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x35, 0x20, 0x0, 0x8, 0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10, + 0x3a, 0xe9, 0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, + 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + uint8_t topic_bytes[] = {0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, + 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 20; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7795, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15081, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\233\218E\235\207\216\&6b\236\246\&0?\169D\196\137\228\212\200\179\RS\159", _pubPktID = 7795, _pubBody = ")\a\246\&4J\134\237\148\159\143:\EOT\237lN\252D\144\179\163'7\208\193\240", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\\Z\DLE\\x\DC3\192\DLE", _pubPktID = +// 15081, _pubBody = "\213\141\182\137f\134\150z.K\232\224o\177\FS\156\198\158\CAN\ESC", _pubProps = []} TEST(Publish311QCTest, Decode16) { -uint8_t pkt[] = {0x3d, 0x33, 0x0, 0x16, 0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f, 0x1e, 0x73, 0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 7795); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); -EXPECT_EQ(msg.payload_len, 25); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x35, 0x20, 0x0, 0x8, 0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10, + 0x3a, 0xe9, 0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, + 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "i\236\180\192[~\199\179\163\147g\v\219?\135\190L\237\DC1\STX`", _pubPktID = 2871, _pubBody = "\166\217", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, + 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 15081); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "~2\242\136\211*\DEL", _pubPktID = +// 30428, _pubBody = "\253ET\175\214\175\205\211w\196\ETX\f-\214\144\194", _pubProps = []} TEST(Publish311QCTest, Encode17) { -uint8_t pkt[] = {0x3d, 0x1b, 0x0, 0x15, 0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60, 0xb, 0x37, 0xa6, 0xd9}; - uint8_t topic_bytes[] = {0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x1b, 0x0, 0x7, 0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f, 0x76, 0xdc, 0xfd, 0x45, + 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + uint8_t topic_bytes[] = {0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0xa6, 0xd9}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 2; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xfd, 0x45, 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 16; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 2871, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30428, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "i\236\180\192[~\199\179\163\147g\v\219?\135\190L\237\DC1\STX`", _pubPktID = 2871, _pubBody = "\166\217", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "~2\242\136\211*\DEL", _pubPktID = +// 30428, _pubBody = "\253ET\175\214\175\205\211w\196\ETX\f-\214\144\194", _pubProps = []} TEST(Publish311QCTest, Decode17) { -uint8_t pkt[] = {0x3d, 0x1b, 0x0, 0x15, 0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60, 0xb, 0x37, 0xa6, 0xd9}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa6, 0xd9}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 2871); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); -EXPECT_EQ(msg.payload_len, 2); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x3b, 0x1b, 0x0, 0x7, 0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f, 0x76, 0xdc, 0xfd, 0x45, + 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "bc", _pubPktID = 16588, _pubBody = "BE\CAN\DEL\135:\DLE\226{E\240\163\&8oT+~\213", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfd, 0x45, 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, + 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 30428); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "dG\194+K1e\237n\253\EM\US\222\156\216K\173\158+\228\&9E\185\CAN\147`\203un\n", _pubPktID = 16078, _pubBody = "", +// _pubProps = []} TEST(Publish311QCTest, Encode18) { -uint8_t pkt[] = {0x33, 0x18, 0x0, 0x2, 0x62, 0x63, 0x40, 0xcc, 0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; - uint8_t topic_bytes[] = {0x62, 0x63}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x22, 0x0, 0x1e, 0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, + 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, 0x4b, 0xad, 0x9e, 0x2b, 0xe4, + 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa, 0x3e, 0xce}; + uint8_t topic_bytes[] = {0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, + 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 18; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 0; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16588, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16078, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "bc", _pubPktID = 16588, _pubBody = "BE\CAN\DEL\135:\DLE\226{E\240\163\&8oT+~\213", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "dG\194+K1e\237n\253\EM\US\222\156\216K\173\158+\228\&9E\185\CAN\147`\203un\n", _pubPktID = 16078, _pubBody = "", +// _pubProps = []} TEST(Publish311QCTest, Decode18) { -uint8_t pkt[] = {0x33, 0x18, 0x0, 0x2, 0x62, 0x63, 0x40, 0xcc, 0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x62, 0x63}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 16588); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); -EXPECT_EQ(msg.payload_len, 18); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x32, 0x22, 0x0, 0x1e, 0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, + 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, 0x4b, 0xad, 0x9e, 0x2b, 0xe4, + 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa, 0x3e, 0xce}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3\255\173\206\232\229\219\SOH\SUB\237\217\218}\ENQ\DC3", _pubPktID = 0, _pubBody = "\184", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, + 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa}; + lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 16078); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "?\DC1;Y\196\211\145n\198\234\233\176_,\224\194\182X\250J\NUL_\198\186\&5\173\224W", _pubPktID = 0, _pubBody = +// "\189?\ag\226\204+\195v\STX4\147\165\167h\131}n\149j\208", _pubProps = []} TEST(Publish311QCTest, Encode19) { -uint8_t pkt[] = {0x31, 0x12, 0x0, 0xf, 0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13, 0xb8}; - uint8_t topic_bytes[] = {0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS0; -msg.retained = true; -uint8_t msg_bytes[] = {0xb8}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 1; - - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x30, 0x33, 0x0, 0x1c, 0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, + 0xe9, 0xb0, 0x5f, 0x2c, 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, + 0x35, 0xad, 0xe0, 0x57, 0xbd, 0x3f, 0x7, 0x67, 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, + 0x34, 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; + uint8_t topic_bytes[] = {0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, 0xe9, 0xb0, 0x5f, 0x2c, + 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, 0x35, 0xad, 0xe0, 0x57}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xbd, 0x3f, 0x7, 0x67, 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, 0x34, + 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 21; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3\255\173\206\232\229\219\SOH\SUB\237\217\218}\ENQ\DC3", _pubPktID = 0, _pubBody = "\184", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "?\DC1;Y\196\211\145n\198\234\233\176_,\224\194\182X\250J\NUL_\198\186\&5\173\224W", _pubPktID = 0, _pubBody = +// "\189?\ag\226\204+\195v\STX4\147\165\167h\131}n\149j\208", _pubProps = []} TEST(Publish311QCTest, Decode19) { -uint8_t pkt[] = {0x31, 0x12, 0x0, 0xf, 0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13, 0xb8}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb8}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS0); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 0); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); -EXPECT_EQ(msg.payload_len, 1); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x30, 0x33, 0x0, 0x1c, 0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, + 0xe9, 0xb0, 0x5f, 0x2c, 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, + 0x35, 0xad, 0xe0, 0x57, 0xbd, 0x3f, 0x7, 0x67, 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, + 0x34, 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\134\&2\209f\v\148F\254 \253\tm", _pubPktID = 25649, _pubBody = "!mj\ACK\181\179\t\252S\212\144\149\130\150X", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, 0xe9, 0xb0, 0x5f, 0x2c, + 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, 0x35, 0xad, 0xe0, 0x57}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbd, 0x3f, 0x7, 0x67, 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, 0x34, + 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "D\SUBc\224\DC3\202\&3\187\&84T\240", _pubPktID = 22665, _pubBody = +// "EV\174.\183\&1Q\DC1\216V\203p>q=x\132\163(\239\143\135b\236\137\&6", _pubProps = []} TEST(Publish311QCTest, Encode20) { -uint8_t pkt[] = {0x3b, 0x1f, 0x0, 0xc, 0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d, 0x64, 0x31, 0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; - uint8_t topic_bytes[] = {0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d}; + uint8_t pkt[] = {0x32, 0x2a, 0x0, 0xc, 0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, + 0xf0, 0x58, 0x89, 0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, + 0x3e, 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + uint8_t topic_bytes[] = {0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, 0xf0}; lwmqtt_string_t topic = {12, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 15; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, 0x3e, + 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25649, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 22665, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\134\&2\209f\v\148F\254 \253\tm", _pubPktID = 25649, _pubBody = "!mj\ACK\181\179\t\252S\212\144\149\130\150X", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "D\SUBc\224\DC3\202\&3\187\&84T\240", _pubPktID = 22665, _pubBody = +// "EV\174.\183\&1Q\DC1\216V\203p>q=x\132\163(\239\143\135b\236\137\&6", _pubProps = []} TEST(Publish311QCTest, Decode20) { -uint8_t pkt[] = {0x3b, 0x1f, 0x0, 0xc, 0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d, 0x64, 0x31, 0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 25649); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); -EXPECT_EQ(msg.payload_len, 15); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x32, 0x2a, 0x0, 0xc, 0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, + 0xf0, 0x58, 0x89, 0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, + 0x3e, 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -} - - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "|\218", _pubPktID = 20394, _pubBody = "\153\SO\176", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, 0xf0}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, 0x3e, + 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 22665); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\230\f\162\233\EOT\DC3\171\130\175!\217\131n\254\197\128m$;\254w\217O\ETX0\241c\223", _pubPktID = 0, _pubBody = +// ";]t:N\225`\ETX\239\239R\FS\135\144", _pubProps = []} TEST(Publish311QCTest, Encode21) { -uint8_t pkt[] = {0x3d, 0x9, 0x0, 0x2, 0x7c, 0xda, 0x4f, 0xaa, 0x99, 0xe, 0xb0}; - uint8_t topic_bytes[] = {0x7c, 0xda}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0x99, 0xe, 0xb0}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 3; - - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x39, 0x2c, 0x0, 0x1c, 0xe6, 0xc, 0xa2, 0xe9, 0x4, 0x13, 0xab, 0x82, 0xaf, 0x21, 0xd9, 0x83, + 0x6e, 0xfe, 0xc5, 0x80, 0x6d, 0x24, 0x3b, 0xfe, 0x77, 0xd9, 0x4f, 0x3, 0x30, 0xf1, 0x63, 0xdf, + 0x3b, 0x5d, 0x74, 0x3a, 0x4e, 0xe1, 0x60, 0x3, 0xef, 0xef, 0x52, 0x1c, 0x87, 0x90}; + uint8_t topic_bytes[] = {0xe6, 0xc, 0xa2, 0xe9, 0x4, 0x13, 0xab, 0x82, 0xaf, 0x21, 0xd9, 0x83, 0x6e, 0xfe, + 0xc5, 0x80, 0x6d, 0x24, 0x3b, 0xfe, 0x77, 0xd9, 0x4f, 0x3, 0x30, 0xf1, 0x63, 0xdf}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x3b, 0x5d, 0x74, 0x3a, 0x4e, 0xe1, 0x60, 0x3, 0xef, 0xef, 0x52, 0x1c, 0x87, 0x90}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 20394, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "|\218", _pubPktID = 20394, _pubBody = "\153\SO\176", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\230\f\162\233\EOT\DC3\171\130\175!\217\131n\254\197\128m$;\254w\217O\ETX0\241c\223", _pubPktID = 0, _pubBody = +// ";]t:N\225`\ETX\239\239R\FS\135\144", _pubProps = []} TEST(Publish311QCTest, Decode21) { -uint8_t pkt[] = {0x3d, 0x9, 0x0, 0x2, 0x7c, 0xda, 0x4f, 0xaa, 0x99, 0xe, 0xb0}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7c, 0xda}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x99, 0xe, 0xb0}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 20394); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); -EXPECT_EQ(msg.payload_len, 3); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x39, 0x2c, 0x0, 0x1c, 0xe6, 0xc, 0xa2, 0xe9, 0x4, 0x13, 0xab, 0x82, 0xaf, 0x21, 0xd9, 0x83, + 0x6e, 0xfe, 0xc5, 0x80, 0x6d, 0x24, 0x3b, 0xfe, 0x77, 0xd9, 0x4f, 0x3, 0x30, 0xf1, 0x63, 0xdf, + 0x3b, 0x5d, 0x74, 0x3a, 0x4e, 0xe1, 0x60, 0x3, 0xef, 0xef, 0x52, 0x1c, 0x87, 0x90}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "<\t\"\209\184\182u\179\DLE\NAK\195\141\EM\237\189}\143\EOT\STX\188|\188\t\USv\US\209\"\STX", _pubPktID = 17374, _pubBody = "\"=\237\FS\247\238\129>oH\131~\158k\231\193}\194\ESCu", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xe6, 0xc, 0xa2, 0xe9, 0x4, 0x13, 0xab, 0x82, 0xaf, 0x21, 0xd9, 0x83, 0x6e, 0xfe, + 0xc5, 0x80, 0x6d, 0x24, 0x3b, 0xfe, 0x77, 0xd9, 0x4f, 0x3, 0x30, 0xf1, 0x63, 0xdf}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x3b, 0x5d, 0x74, 0x3a, 0x4e, 0xe1, 0x60, 0x3, 0xef, 0xef, 0x52, 0x1c, 0x87, 0x90}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\DEL\ETX\153\229\248dS\153`\SOH\167\230\142f\DC1\233\135#<\250\245dX!\172\177\&9,\148", _pubPktID = 23552, _pubBody +// = "\165\207\195k*4\RS", _pubProps = []} TEST(Publish311QCTest, Encode22) { -uint8_t pkt[] = {0x3a, 0x35, 0x0, 0x1d, 0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2, 0x43, 0xde, 0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; - uint8_t topic_bytes[] = {0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2}; + uint8_t pkt[] = {0x3d, 0x28, 0x0, 0x1d, 0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, + 0xa7, 0xe6, 0x8e, 0x66, 0x11, 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, + 0xac, 0xb1, 0x39, 0x2c, 0x94, 0x5c, 0x0, 0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + uint8_t topic_bytes[] = {0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, 0x8e, 0x66, 0x11, + 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, 0x94}; lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = false; -uint8_t msg_bytes[] = {0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 20; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 7; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 17374, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 23552, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "<\t\"\209\184\182u\179\DLE\NAK\195\141\EM\237\189}\143\EOT\STX\188|\188\t\USv\US\209\"\STX", _pubPktID = 17374, _pubBody = "\"=\237\FS\247\238\129>oH\131~\158k\231\193}\194\ESCu", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\DEL\ETX\153\229\248dS\153`\SOH\167\230\142f\DC1\233\135#<\250\245dX!\172\177\&9,\148", _pubPktID = 23552, _pubBody +// = "\165\207\195k*4\RS", _pubProps = []} TEST(Publish311QCTest, Decode22) { -uint8_t pkt[] = {0x3a, 0x35, 0x0, 0x1d, 0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2, 0x43, 0xde, 0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 17374); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); -EXPECT_EQ(msg.payload_len, 20); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x3d, 0x28, 0x0, 0x1d, 0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, + 0xa7, 0xe6, 0x8e, 0x66, 0x11, 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, + 0xac, 0xb1, 0x39, 0x2c, 0x94, 0x5c, 0x0, 0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "L\250\DC3", _pubPktID = 6223, _pubBody = ".K\236\242\210\250\192\219\175h\175p\249", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, 0x8e, 0x66, 0x11, + 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, 0x94}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 23552); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163\132d\157\149", _pubPktID = +// 24502, _pubBody = "\224h\ACK", _pubProps = []} TEST(Publish311QCTest, Encode23) { -uint8_t pkt[] = {0x35, 0x14, 0x0, 0x3, 0x4c, 0xfa, 0x13, 0x18, 0x4f, 0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; - uint8_t topic_bytes[] = {0x4c, 0xfa, 0x13}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0xc, 0x0, 0x5, 0xa3, 0x84, 0x64, 0x9d, 0x95, 0x5f, 0xb6, 0xe0, 0x68, 0x6}; + uint8_t topic_bytes[] = {0xa3, 0x84, 0x64, 0x9d, 0x95}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 13; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xe0, 0x68, 0x6}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 6223, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24502, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "L\250\DC3", _pubPktID = 6223, _pubBody = ".K\236\242\210\250\192\219\175h\175p\249", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163\132d\157\149", _pubPktID = +// 24502, _pubBody = "\224h\ACK", _pubProps = []} TEST(Publish311QCTest, Decode23) { -uint8_t pkt[] = {0x35, 0x14, 0x0, 0x3, 0x4c, 0xfa, 0x13, 0x18, 0x4f, 0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x4c, 0xfa, 0x13}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 6223); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); -EXPECT_EQ(msg.payload_len, 13); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x34, 0xc, 0x0, 0x5, 0xa3, 0x84, 0x64, 0x9d, 0x95, 0x5f, 0xb6, 0xe0, 0x68, 0x6}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "^;.\197y\SO\163S\245~\178g\ETB", _pubPktID = 32148, _pubBody = "V\DC4\DC3 ZQ\164[\157n\197\162X\"*\220LH\RSF\206\255)Xpu!=", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xa3, 0x84, 0x64, 0x9d, 0x95}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xe0, 0x68, 0x6}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 24502); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\153\164\218\195=\160\170\223\157 +// b%X\222\199hG0\198K3y\207\128J\188\176\225", _pubPktID = 0, _pubBody = "\SOH\191\156", _pubProps = []} TEST(Publish311QCTest, Encode24) { -uint8_t pkt[] = {0x34, 0x2d, 0x0, 0xd, 0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17, 0x7d, 0x94, 0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; - uint8_t topic_bytes[] = {0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = false; -uint8_t msg_bytes[] = {0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 28; - - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x38, 0x21, 0x0, 0x1c, 0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, + 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, + 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1, 0x1, 0xbf, 0x9c}; + uint8_t topic_bytes[] = {0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, + 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x1, 0xbf, 0x9c}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32148, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "^;.\197y\SO\163S\245~\178g\ETB", _pubPktID = 32148, _pubBody = "V\DC4\DC3 ZQ\164[\157n\197\162X\"*\220LH\RSF\206\255)Xpu!=", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\153\164\218\195=\160\170\223\157 +// b%X\222\199hG0\198K3y\207\128J\188\176\225", _pubPktID = 0, _pubBody = "\SOH\191\156", _pubProps = []} TEST(Publish311QCTest, Decode24) { -uint8_t pkt[] = {0x34, 0x2d, 0x0, 0xd, 0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17, 0x7d, 0x94, 0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 32148); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); -EXPECT_EQ(msg.payload_len, 28); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x38, 0x21, 0x0, 0x1c, 0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, + 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, + 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1, 0x1, 0xbf, 0x9c}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "Vk\181\201\ETXZ\DC4\208\170\201\tDEB\153]Q\232", _pubPktID = 2981, _pubBody = "\\>V\153p|W\163\148\254\SYN@q\238?", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, + 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1, 0xbf, 0x9c}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "Z\162]m\132\183R\SUBWRu", _pubPktID +// = 13838, _pubBody = +// "{&\208\GS\139\141\&9\162*\207\153\136\148\172\STX\190\162e\RS\\\163\194\141\DC1\SYN\156\204\236", _pubProps = []} TEST(Publish311QCTest, Encode25) { -uint8_t pkt[] = {0x34, 0x25, 0x0, 0x12, 0x56, 0x6b, 0xb5, 0xc9, 0x3, 0x5a, 0x14, 0xd0, 0xaa, 0xc9, 0x9, 0x44, 0x45, 0x42, 0x99, 0x5d, 0x51, 0xe8, 0xb, 0xa5, 0x5c, 0x3e, 0x56, 0x99, 0x70, 0x7c, 0x57, 0xa3, 0x94, 0xfe, 0x16, 0x40, 0x71, 0xee, 0x3f}; - uint8_t topic_bytes[] = {0x56, 0x6b, 0xb5, 0xc9, 0x3, 0x5a, 0x14, 0xd0, 0xaa, 0xc9, 0x9, 0x44, 0x45, 0x42, 0x99, 0x5d, 0x51, 0xe8}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x2b, 0x0, 0xb, 0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75, + 0x36, 0xe, 0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, + 0xac, 0x2, 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; + uint8_t topic_bytes[] = {0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = false; -uint8_t msg_bytes[] = {0x5c, 0x3e, 0x56, 0x99, 0x70, 0x7c, 0x57, 0xa3, 0x94, 0xfe, 0x16, 0x40, 0x71, 0xee, 0x3f}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 15; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, 0xac, + 0x2, 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 28; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 2981, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13838, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "Vk\181\201\ETXZ\DC4\208\170\201\tDEB\153]Q\232", _pubPktID = 2981, _pubBody = "\\>V\153p|W\163\148\254\SYN@q\238?", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "Z\162]m\132\183R\SUBWRu", _pubPktID +// = 13838, _pubBody = +// "{&\208\GS\139\141\&9\162*\207\153\136\148\172\STX\190\162e\RS\\\163\194\141\DC1\SYN\156\204\236", _pubProps = []} TEST(Publish311QCTest, Decode25) { -uint8_t pkt[] = {0x34, 0x25, 0x0, 0x12, 0x56, 0x6b, 0xb5, 0xc9, 0x3, 0x5a, 0x14, 0xd0, 0xaa, 0xc9, 0x9, 0x44, 0x45, 0x42, 0x99, 0x5d, 0x51, 0xe8, 0xb, 0xa5, 0x5c, 0x3e, 0x56, 0x99, 0x70, 0x7c, 0x57, 0xa3, 0x94, 0xfe, 0x16, 0x40, 0x71, 0xee, 0x3f}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x56, 0x6b, 0xb5, 0xc9, 0x3, 0x5a, 0x14, 0xd0, 0xaa, 0xc9, 0x9, 0x44, 0x45, 0x42, 0x99, 0x5d, 0x51, 0xe8}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5c, 0x3e, 0x56, 0x99, 0x70, 0x7c, 0x57, 0xa3, 0x94, 0xfe, 0x16, 0x40, 0x71, 0xee, 0x3f}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 2981); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); -EXPECT_EQ(msg.payload_len, 15); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 12988, _pubBody = "\252Q\161\SUB\150\190\247\174s\151T8\149C\NAK9;)\159\188\140bs", _pubProps = []} + uint8_t pkt[] = {0x3a, 0x2b, 0x0, 0xb, 0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75, + 0x36, 0xe, 0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, + 0xac, 0x2, 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, 0xac, + 0x2, 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 13838); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\245\STX\252\CAN\215\187\FS^!\141\191\250|\190\164I\153\169,U`", _pubPktID = 10215, _pubBody = +// "\199r\153\234\&0UY.\201J\198\SO", _pubProps = []} TEST(Publish311QCTest, Encode26) { -uint8_t pkt[] = {0x33, 0x1b, 0x0, 0x0, 0x32, 0xbc, 0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x25, 0x0, 0x15, 0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, + 0x8d, 0xbf, 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60, 0x27, + 0xe7, 0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + uint8_t topic_bytes[] = {0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, + 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 23; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 12988, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10215, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 12988, _pubBody = "\252Q\161\SUB\150\190\247\174s\151T8\149C\NAK9;)\159\188\140bs", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\245\STX\252\CAN\215\187\FS^!\141\191\250|\190\164I\153\169,U`", _pubPktID = 10215, _pubBody = +// "\199r\153\234\&0UY.\201J\198\SO", _pubProps = []} TEST(Publish311QCTest, Decode26) { -uint8_t pkt[] = {0x33, 0x1b, 0x0, 0x0, 0x32, 0xbc, 0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 12988); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); -EXPECT_EQ(msg.payload_len, 23); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x33, 0x25, 0x0, 0x15, 0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, + 0x8d, 0xbf, 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60, 0x27, + 0xe7, 0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\a\206+\241_)~\225\174V\232:\184e", _pubPktID = 1045, _pubBody = "E\243x", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, + 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10215); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\187\192\216\&6]J\244\v\252\&6\149\EOT\128\ETX", _pubPktID = 11476, _pubBody = +// "\254&\138\150\179\238u\252\176\246'\140\196", _pubProps = []} TEST(Publish311QCTest, Encode27) { -uint8_t pkt[] = {0x33, 0x15, 0x0, 0xe, 0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65, 0x4, 0x15, 0x45, 0xf3, 0x78}; - uint8_t topic_bytes[] = {0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65}; + uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0xe, 0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, + 0x3, 0x2c, 0xd4, 0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + uint8_t topic_bytes[] = {0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, 0x3}; lwmqtt_string_t topic = {14, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x45, 0xf3, 0x78}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 3; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 1045, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 11476, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\a\206+\241_)~\225\174V\232:\184e", _pubPktID = 1045, _pubBody = "E\243x", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\187\192\216\&6]J\244\v\252\&6\149\EOT\128\ETX", _pubPktID = 11476, _pubBody = +// "\254&\138\150\179\238u\252\176\246'\140\196", _pubProps = []} TEST(Publish311QCTest, Decode27) { -uint8_t pkt[] = {0x33, 0x15, 0x0, 0xe, 0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65, 0x4, 0x15, 0x45, 0xf3, 0x78}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x45, 0xf3, 0x78}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 1045); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); -EXPECT_EQ(msg.payload_len, 3); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0xe, 0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, + 0x3, 0x2c, 0xd4, 0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\193`\187\247\203\252\193V\159\209\143}w\180\219\226\"\181nuE\nC\175-\SUB\141", _pubPktID = 0, _pubBody = "\213(\SUB\v\FS\224\252\152%p_*#w\218\204\240\237>\246", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, 0x3}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 11476); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "/\USs\188\193\156\202\143\244\215\159fj\184\STX\DC3\217", _pubPktID = 0, _pubBody = "\213T\157\156*`\174Ad\219\206", +// _pubProps = []} TEST(Publish311QCTest, Encode28) { -uint8_t pkt[] = {0x30, 0x31, 0x0, 0x1b, 0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d, 0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; - uint8_t topic_bytes[] = {0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x11, 0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, 0xd7, 0x9f, 0x66, + 0x6a, 0xb8, 0x2, 0x13, 0xd9, 0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + uint8_t topic_bytes[] = {0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, + 0xd7, 0x9f, 0x66, 0x6a, 0xb8, 0x2, 0x13, 0xd9}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS0; -msg.retained = false; -uint8_t msg_bytes[] = {0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 20; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 11; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\193`\187\247\203\252\193V\159\209\143}w\180\219\226\"\181nuE\nC\175-\SUB\141", _pubPktID = 0, _pubBody = "\213(\SUB\v\FS\224\252\152%p_*#w\218\204\240\237>\246", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "/\USs\188\193\156\202\143\244\215\159fj\184\STX\DC3\217", _pubPktID = 0, _pubBody = "\213T\157\156*`\174Ad\219\206", +// _pubProps = []} TEST(Publish311QCTest, Decode28) { -uint8_t pkt[] = {0x30, 0x31, 0x0, 0x1b, 0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d, 0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS0); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 0); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); -EXPECT_EQ(msg.payload_len, 20); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x11, 0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, 0xd7, 0x9f, 0x66, + 0x6a, 0xb8, 0x2, 0x13, 0xd9, 0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -} - - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "}\180", _pubPktID = 11899, _pubBody = "\DC2\ACK%\181\DC3\164\204\173\204\223\DC2\161\&3uzk\152Xn\200\154d\154\143\245z\234", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, + 0xd7, 0x9f, 0x66, 0x6a, 0xb8, 0x2, 0x13, 0xd9}; + lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\ETXJ\240r\220\200\DLE=\219m\152\EM\205\US\144", _pubPktID = 32504, _pubBody = +// "C\158&\185\DLE\NUL\239\237\184+\SO<\134\"R\EM\232\230\222\ENQ", _pubProps = []} TEST(Publish311QCTest, Encode29) { -uint8_t pkt[] = {0x34, 0x21, 0x0, 0x2, 0x7d, 0xb4, 0x2e, 0x7b, 0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; - uint8_t topic_bytes[] = {0x7d, 0xb4}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x27, 0x0, 0xf, 0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, + 0x98, 0x19, 0xcd, 0x1f, 0x90, 0x7e, 0xf8, 0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, + 0xed, 0xb8, 0x2b, 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + uint8_t topic_bytes[] = {0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, 0xcd, 0x1f, 0x90}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = false; -uint8_t msg_bytes[] = {0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 27; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, + 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 20; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 11899, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32504, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "}\180", _pubPktID = 11899, _pubBody = "\DC2\ACK%\181\DC3\164\204\173\204\223\DC2\161\&3uzk\152Xn\200\154d\154\143\245z\234", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\ETXJ\240r\220\200\DLE=\219m\152\EM\205\US\144", _pubPktID = 32504, _pubBody = +// "C\158&\185\DLE\NUL\239\237\184+\SO<\134\"R\EM\232\230\222\ENQ", _pubProps = []} TEST(Publish311QCTest, Decode29) { -uint8_t pkt[] = {0x34, 0x21, 0x0, 0x2, 0x7d, 0xb4, 0x2e, 0x7b, 0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7d, 0xb4}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 11899); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); -EXPECT_EQ(msg.payload_len, 27); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x35, 0x27, 0x0, 0xf, 0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, + 0x98, 0x19, 0xcd, 0x1f, 0x90, 0x7e, 0xf8, 0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, + 0xed, 0xb8, 0x2b, 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\tnz^#/~y\225", _pubPktID = 17773, _pubBody = "\130\\'n\215\&3\DC2\219\205\147\SOI\183c", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, 0xcd, 0x1f, 0x90}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, + 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 32504); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CAN\n\131L\223F1\229", _pubPktID = +// 0, _pubBody = "\138\228\212\203", _pubProps = []} TEST(Publish311QCTest, Encode30) { -uint8_t pkt[] = {0x3b, 0x1c, 0x0, 0xa, 0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1, 0x45, 0x6d, 0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; - uint8_t topic_bytes[] = {0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0xe, 0x0, 0x8, 0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5, 0x8a, 0xe4, 0xd4, 0xcb}; + uint8_t topic_bytes[] = {0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 14; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x8a, 0xe4, 0xd4, 0xcb}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 17773, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\tnz^#/~y\225", _pubPktID = 17773, _pubBody = "\130\\'n\215\&3\DC2\219\205\147\SOI\183c", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CAN\n\131L\223F1\229", _pubPktID = +// 0, _pubBody = "\138\228\212\203", _pubProps = []} TEST(Publish311QCTest, Decode30) { -uint8_t pkt[] = {0x3b, 0x1c, 0x0, 0xa, 0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1, 0x45, 0x6d, 0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 17773); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); -EXPECT_EQ(msg.payload_len, 14); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x30, 0xe, 0x0, 0x8, 0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5, 0x8a, 0xe4, 0xd4, 0xcb}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8a, 0xe4, 0xd4, 0xcb}; + lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 4); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\137\189\213\133\214H\EM\161\170\241\136", _pubPktID = 0, _pubBody = "\217\146\229\195\163\175\196\174y0d\141b\146", +// _pubProps = [PropWildcardSubscriptionAvailable 153,PropTopicAliasMaximum 3171,PropContentType +// "\EOT6\189\bp\217'\191\164\GS:\157\177o\254",PropAuthenticationData +// "E]\238\185\207#\n\145\&2\233\253\140\&0",PropTopicAliasMaximum 14538,PropSubscriptionIdentifierAvailable +// 92,PropSubscriptionIdentifier 5,PropRetainAvailable 55,PropReasonString +// "{\167_\GS\209\244\179\245",PropMessageExpiryInterval 27769,PropReasonString +// "\188l\201\168\179\&5\231\253\230\157\226\161\149{\173\DLE\177\222!\146\b.@",PropMaximumQoS 165,PropServerKeepAlive +// 1411,PropMessageExpiryInterval 19809]} +TEST(Publish5QCTest, Encode1) { + uint8_t pkt[] = {0x31, 0x80, 0x1, 0x0, 0xb, 0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88, 0x64, + 0x28, 0x99, 0x22, 0xc, 0x63, 0x3, 0x0, 0xf, 0x4, 0x36, 0xbd, 0x8, 0x70, 0xd9, 0x27, 0xbf, 0xa4, + 0x1d, 0x3a, 0x9d, 0xb1, 0x6f, 0xfe, 0x16, 0x0, 0xd, 0x45, 0x5d, 0xee, 0xb9, 0xcf, 0x23, 0xa, 0x91, + 0x32, 0xe9, 0xfd, 0x8c, 0x30, 0x22, 0x38, 0xca, 0x29, 0x5c, 0xb, 0x5, 0x25, 0x37, 0x1f, 0x0, 0x8, + 0x7b, 0xa7, 0x5f, 0x1d, 0xd1, 0xf4, 0xb3, 0xf5, 0x2, 0x0, 0x0, 0x6c, 0x79, 0x1f, 0x0, 0x17, 0xbc, + 0x6c, 0xc9, 0xa8, 0xb3, 0x35, 0xe7, 0xfd, 0xe6, 0x9d, 0xe2, 0xa1, 0x95, 0x7b, 0xad, 0x10, 0xb1, 0xde, + 0x21, 0x92, 0x8, 0x2e, 0x40, 0x24, 0xa5, 0x13, 0x5, 0x83, 0x2, 0x0, 0x0, 0x4d, 0x61, 0xd9, 0x92, + 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + uint8_t topic_bytes[] = {0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = ";\135[\241\201\187\168\ETX\227\158\138\182\179\234\250\172\152\219\131\130!", _pubPktID = 24061, _pubBody = "\206\141\147\181o\253", _pubProps = [PropReceiveMaximum 21932,PropResponseInformation "c",PropMessageExpiryInterval 8939,PropAuthenticationData "y-+h",PropAssignedClientIdentifier "\RS\196RZ\231\&1Uh\149\146\237\168\NULH6\177F\246?\173\&4\137",PropAuthenticationData "m\227^\190\239\&1\240\232\EM\EM\128\149",PropServerKeepAlive 8119,PropResponseInformation "^\181\206\129aT\236\140",PropMaximumQoS 52,PropRequestResponseInformation 210,PropReceiveMaximum 8685,PropResponseInformation "\195\129\177\EM\STX~\194\n\207\204I\144@\226",PropMessageExpiryInterval 8052,PropReasonString "\215\213\194@e\ENQ\228\160\&6\143\GSC\ENQ\237Y?\208WL\130\250fRp\234",PropAuthenticationData "\233\DC4\217\246,\196\&4|\ESC'\236\232\150\152",PropMessageExpiryInterval 26546,PropWillDelayInterval 17713,PropSessionExpiryInterval 9284,PropContentType "\ACK@\193\237\DEL\251\ENQ\180yY\193",PropSharedSubscriptionAvailable 36,PropPayloadFormatIndicator 21,PropRequestResponseInformation 253,PropAuthenticationMethod "\DC4\179\189\165`\r\184HTgYh\211X\243;\134\151aY",PropSessionExpiryInterval 11426,PropUserProperty "HG\241{qJ\211\174\DC3\240\196\SO\133\EOT\ENQ\242u\129" "\164\216q\n\STX\STX\198\193D+\229\177",PropAuthenticationMethod "\130p\171\204s\CAN\234\&0\206:,\248\194\NAK}`\142!Yn\199$\224f\242&\135",PropAuthenticationData "\166\196`\240\&2\v\DEL\141\244\DC1*\200\218\202\215\210m\234\SOH\207[\166",PropReasonString "\150\SUB\183",PropTopicAlias 18572,PropMaximumPacketSize 6297]} -TEST(Publish5QCTest, Encode1) { -uint8_t pkt[] = {0x33, 0xdb, 0x2, 0x0, 0x15, 0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21, 0x5d, 0xfd, 0xba, 0x2, 0x21, 0x55, 0xac, 0x1a, 0x0, 0x1, 0x63, 0x2, 0x0, 0x0, 0x22, 0xeb, 0x16, 0x0, 0x4, 0x79, 0x2d, 0x2b, 0x68, 0x12, 0x0, 0x16, 0x1e, 0xc4, 0x52, 0x5a, 0xe7, 0x31, 0x55, 0x68, 0x95, 0x92, 0xed, 0xa8, 0x0, 0x48, 0x36, 0xb1, 0x46, 0xf6, 0x3f, 0xad, 0x34, 0x89, 0x16, 0x0, 0xc, 0x6d, 0xe3, 0x5e, 0xbe, 0xef, 0x31, 0xf0, 0xe8, 0x19, 0x19, 0x80, 0x95, 0x13, 0x1f, 0xb7, 0x1a, 0x0, 0x8, 0x5e, 0xb5, 0xce, 0x81, 0x61, 0x54, 0xec, 0x8c, 0x24, 0x34, 0x19, 0xd2, 0x21, 0x21, 0xed, 0x1a, 0x0, 0xe, 0xc3, 0x81, 0xb1, 0x19, 0x2, 0x7e, 0xc2, 0xa, 0xcf, 0xcc, 0x49, 0x90, 0x40, 0xe2, 0x2, 0x0, 0x0, 0x1f, 0x74, 0x1f, 0x0, 0x19, 0xd7, 0xd5, 0xc2, 0x40, 0x65, 0x5, 0xe4, 0xa0, 0x36, 0x8f, 0x1d, 0x43, 0x5, 0xed, 0x59, 0x3f, 0xd0,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18, 0x99, 0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; - uint8_t topic_bytes[] = {0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t bytesprops0[] = {0x4, 0x36, 0xbd, 0x8, 0x70, 0xd9, 0x27, 0xbf, 0xa4, 0x1d, 0x3a, 0x9d, 0xb1, 0x6f, 0xfe}; + uint8_t bytesprops1[] = {0x45, 0x5d, 0xee, 0xb9, 0xcf, 0x23, 0xa, 0x91, 0x32, 0xe9, 0xfd, 0x8c, 0x30}; + uint8_t bytesprops2[] = {0x7b, 0xa7, 0x5f, 0x1d, 0xd1, 0xf4, 0xb3, 0xf5}; + uint8_t bytesprops3[] = {0xbc, 0x6c, 0xc9, 0xa8, 0xb3, 0x35, 0xe7, 0xfd, 0xe6, 0x9d, 0xe2, 0xa1, + 0x95, 0x7b, 0xad, 0x10, 0xb1, 0xde, 0x21, 0x92, 0x8, 0x2e, 0x40}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 6; - - uint8_t bytesprops0[] = {0x63}; - uint8_t bytesprops1[] = {0x79, 0x2d, 0x2b, 0x68}; - uint8_t bytesprops2[] = {0x1e, 0xc4, 0x52, 0x5a, 0xe7, 0x31, 0x55, 0x68, 0x95, 0x92, 0xed, 0xa8, 0x0, 0x48, 0x36, 0xb1, 0x46, 0xf6, 0x3f, 0xad, 0x34, 0x89}; - uint8_t bytesprops3[] = {0x6d, 0xe3, 0x5e, 0xbe, 0xef, 0x31, 0xf0, 0xe8, 0x19, 0x19, 0x80, 0x95}; - uint8_t bytesprops4[] = {0x5e, 0xb5, 0xce, 0x81, 0x61, 0x54, 0xec, 0x8c}; - uint8_t bytesprops5[] = {0xc3, 0x81, 0xb1, 0x19, 0x2, 0x7e, 0xc2, 0xa, 0xcf, 0xcc, 0x49, 0x90, 0x40, 0xe2}; - uint8_t bytesprops6[] = {0xd7, 0xd5, 0xc2, 0x40, 0x65, 0x5, 0xe4, 0xa0, 0x36, 0x8f, 0x1d, 0x43, 0x5, 0xed, 0x59, 0x3f, 0xd0, 0x57, 0x4c, 0x82, 0xfa, 0x66, 0x52, 0x70, 0xea}; - uint8_t bytesprops7[] = {0xe9, 0x14, 0xd9, 0xf6, 0x2c, 0xc4, 0x34, 0x7c, 0x1b, 0x27, 0xec, 0xe8, 0x96, 0x98}; - uint8_t bytesprops8[] = {0x6, 0x40, 0xc1, 0xed, 0x7f, 0xfb, 0x5, 0xb4, 0x79, 0x59, 0xc1}; - uint8_t bytesprops9[] = {0x14, 0xb3, 0xbd, 0xa5, 0x60, 0xd, 0xb8, 0x48, 0x54, 0x67, 0x59, 0x68, 0xd3, 0x58, 0xf3, 0x3b, 0x86, 0x97, 0x61, 0x59}; - uint8_t bytesprops11[] = {0xa4, 0xd8, 0x71, 0xa, 0x2, 0x2, 0xc6, 0xc1, 0x44, 0x2b, 0xe5, 0xb1}; - uint8_t bytesprops10[] = {0x48, 0x47, 0xf1, 0x7b, 0x71, 0x4a, 0xd3, 0xae, 0x13, 0xf0, 0xc4, 0xe, 0x85, 0x4, 0x5, 0xf2, 0x75, 0x81}; - uint8_t bytesprops12[] = {0x82, 0x70, 0xab, 0xcc, 0x73, 0x18, 0xea, 0x30, 0xce, 0x3a, 0x2c, 0xf8, 0xc2, 0x15, 0x7d, 0x60, 0x8e, 0x21, 0x59, 0x6e, 0xc7, 0x24, 0xe0, 0x66, 0xf2, 0x26, 0x87}; - uint8_t bytesprops13[] = {0xa6, 0xc4, 0x60, 0xf0, 0x32, 0xb, 0x7f, 0x8d, 0xf4, 0x11, 0x2a, 0xc8, 0xda, 0xca, 0xd7, 0xd2, 0x6d, 0xea, 0x1, 0xcf, 0x5b, 0xa6}; - uint8_t bytesprops14[] = {0x96, 0x1a, 0xb7}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21932}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8939}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8119}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8685}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8052}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26546}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17713}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9284}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11426}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={18, (char*)&bytesprops10}, .v={12, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18572}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6297}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3171}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14538}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27769}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1411}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19809}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24061, topic, msg, props); + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = ";\135[\241\201\187\168\ETX\227\158\138\182\179\234\250\172\152\219\131\130!", _pubPktID = 24061, _pubBody = "\206\141\147\181o\253", _pubProps = [PropReceiveMaximum 21932,PropResponseInformation "c",PropMessageExpiryInterval 8939,PropAuthenticationData "y-+h",PropAssignedClientIdentifier "\RS\196RZ\231\&1Uh\149\146\237\168\NULH6\177F\246?\173\&4\137",PropAuthenticationData "m\227^\190\239\&1\240\232\EM\EM\128\149",PropServerKeepAlive 8119,PropResponseInformation "^\181\206\129aT\236\140",PropMaximumQoS 52,PropRequestResponseInformation 210,PropReceiveMaximum 8685,PropResponseInformation "\195\129\177\EM\STX~\194\n\207\204I\144@\226",PropMessageExpiryInterval 8052,PropReasonString "\215\213\194@e\ENQ\228\160\&6\143\GSC\ENQ\237Y?\208WL\130\250fRp\234",PropAuthenticationData "\233\DC4\217\246,\196\&4|\ESC'\236\232\150\152",PropMessageExpiryInterval 26546,PropWillDelayInterval 17713,PropSessionExpiryInterval 9284,PropContentType "\ACK@\193\237\DEL\251\ENQ\180yY\193",PropSharedSubscriptionAvailable 36,PropPayloadFormatIndicator 21,PropRequestResponseInformation 253,PropAuthenticationMethod "\DC4\179\189\165`\r\184HTgYh\211X\243;\134\151aY",PropSessionExpiryInterval 11426,PropUserProperty "HG\241{qJ\211\174\DC3\240\196\SO\133\EOT\ENQ\242u\129" "\164\216q\n\STX\STX\198\193D+\229\177",PropAuthenticationMethod "\130p\171\204s\CAN\234\&0\206:,\248\194\NAK}`\142!Yn\199$\224f\242&\135",PropAuthenticationData "\166\196`\240\&2\v\DEL\141\244\DC1*\200\218\202\215\210m\234\SOH\207[\166",PropReasonString "\150\SUB\183",PropTopicAlias 18572,PropMaximumPacketSize 6297]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\137\189\213\133\214H\EM\161\170\241\136", _pubPktID = 0, _pubBody = "\217\146\229\195\163\175\196\174y0d\141b\146", +// _pubProps = [PropWildcardSubscriptionAvailable 153,PropTopicAliasMaximum 3171,PropContentType +// "\EOT6\189\bp\217'\191\164\GS:\157\177o\254",PropAuthenticationData +// "E]\238\185\207#\n\145\&2\233\253\140\&0",PropTopicAliasMaximum 14538,PropSubscriptionIdentifierAvailable +// 92,PropSubscriptionIdentifier 5,PropRetainAvailable 55,PropReasonString +// "{\167_\GS\209\244\179\245",PropMessageExpiryInterval 27769,PropReasonString +// "\188l\201\168\179\&5\231\253\230\157\226\161\149{\173\DLE\177\222!\146\b.@",PropMaximumQoS 165,PropServerKeepAlive +// 1411,PropMessageExpiryInterval 19809]} TEST(Publish5QCTest, Decode1) { -uint8_t pkt[] = {0x33, 0xdb, 0x2, 0x0, 0x15, 0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21, 0x5d, 0xfd, 0xba, 0x2, 0x21, 0x55, 0xac, 0x1a, 0x0, 0x1, 0x63, 0x2, 0x0, 0x0, 0x22, 0xeb, 0x16, 0x0, 0x4, 0x79, 0x2d, 0x2b, 0x68, 0x12, 0x0, 0x16, 0x1e, 0xc4, 0x52, 0x5a, 0xe7, 0x31, 0x55, 0x68, 0x95, 0x92, 0xed, 0xa8, 0x0, 0x48, 0x36, 0xb1, 0x46, 0xf6, 0x3f, 0xad, 0x34, 0x89, 0x16, 0x0, 0xc, 0x6d, 0xe3, 0x5e, 0xbe, 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b, 0xe5, 0xb1, 0x15, 0x0, 0x1b, 0x82, 0x70, 0xab, 0xcc, 0x73, 0x18, 0xea, 0x30, 0xce, 0x3a, 0x2c, 0xf8, 0xc2, 0x15, 0x7d, 0x60, 0x8e, 0x21, 0x59, 0x6e, 0xc7, 0x24, 0xe0, 0x66, 0xf2, 0x26, 0x87, 0x16, 0x0, 0x16, 0xa6, 0xc4, 0x60, 0xf0, 0x32, 0xb, 0x7f, 0x8d, 0xf4, 0x11, 0x2a, 0xc8, 0xda, 0xca, 0xd7, 0xd2, 0x6d, 0xea, 0x1, 0xcf, 0x5b, 0xa6, 0x1f, 0x0, 0x3, 0x96, 0x1a, 0xb7, 0x23, 0x48, 0x8c, 0x27, 0x0, 0x0, 0x18, 0x99, 0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3b, 0x87, 0x5b, 0xf1, 0xc9, 0xbb, 0xa8, 0x3, 0xe3, 0x9e, 0x8a, 0xb6, 0xb3, 0xea, 0xfa, 0xac, 0x98, 0xdb, 0x83, 0x82, 0x21}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xce, 0x8d, 0x93, 0xb5, 0x6f, 0xfd}; - lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 24061); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); -EXPECT_EQ(msg.payload_len, 6); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x31, 0x80, 0x1, 0x0, 0xb, 0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88, 0x64, + 0x28, 0x99, 0x22, 0xc, 0x63, 0x3, 0x0, 0xf, 0x4, 0x36, 0xbd, 0x8, 0x70, 0xd9, 0x27, 0xbf, 0xa4, + 0x1d, 0x3a, 0x9d, 0xb1, 0x6f, 0xfe, 0x16, 0x0, 0xd, 0x45, 0x5d, 0xee, 0xb9, 0xcf, 0x23, 0xa, 0x91, + 0x32, 0xe9, 0xfd, 0x8c, 0x30, 0x22, 0x38, 0xca, 0x29, 0x5c, 0xb, 0x5, 0x25, 0x37, 0x1f, 0x0, 0x8, + 0x7b, 0xa7, 0x5f, 0x1d, 0xd1, 0xf4, 0xb3, 0xf5, 0x2, 0x0, 0x0, 0x6c, 0x79, 0x1f, 0x0, 0x17, 0xbc, + 0x6c, 0xc9, 0xa8, 0xb3, 0x35, 0xe7, 0xfd, 0xe6, 0x9d, 0xe2, 0xa1, 0x95, 0x7b, 0xad, 0x10, 0xb1, 0xde, + 0x21, 0x92, 0x8, 0x2e, 0x40, 0x24, 0xa5, 0x13, 0x5, 0x83, 0x2, 0x0, 0x0, 0x4d, 0x61, 0xd9, 0x92, + 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\183\249", _pubPktID = 0, _pubBody +// = "M\EOTga\US?`w\167\&6\152\SI\NAKC\168>\173<\149\213m,5\235\133\r\180\190\195", _pubProps = +// [PropMessageExpiryInterval 32152,PropCorrelationData "};Zy2w\196\SO\158\155\212\US\145[\216\208&",PropResponseTopic +// "P\154\n\168\222q\EM\191\&7\247\208",PropResponseTopic +// "r\164\175\171\SUB=\160D'v\154\167",PropSharedSubscriptionAvailable 114,PropAssignedClientIdentifier +// "\179\247$\SYN\214\231\223\235+=SuY\244g\138\&4\198\158o\155\209\187\159v\153\230\203",PropMessageExpiryInterval +// 7971,PropReasonString "\167\SI\144j\r\230\207Q\139\&7\ETX\248[\154",PropMessageExpiryInterval +// 10952,PropRequestResponseInformation 148,PropReasonString "\139[\171\224!~\164\210",PropAssignedClientIdentifier +// "\138\169\SIV\231",PropAuthenticationData "\188\155\136o\243O\194",PropResponseInformation +// "[<\225\130\225\223\&4\134\CAN{0\188\209Bt\128\152A\133\a\n",PropSessionExpiryInterval +// 24494,PropSharedSubscriptionAvailable 202,PropResponseInformation +// "B\173n\FSD1\197\a\211v\144\152\184\188B",PropAuthenticationData +// "C2\202\128H\DC3\136\188\194v3\235\231\198\149\251zc",PropMaximumPacketSize 32261,PropRequestProblemInformation +// 61,PropSubscriptionIdentifierAvailable 184,PropResponseTopic +// "L\EM\147\234\201\193\t\EM\245*p\205\138\182O",PropUserProperty "o\US\ESC\155\160\221f\176\141\NAK\159" +// "\ETX\222o\DC4\169\130O\132\SYN\141\DC3",PropContentType +// "\DC1\195\185v\167\r\175N.\207\128\USM\147?*\nA\248\161\133\244\186{\251+\STX",PropContentType +// "\138n[`C$",PropRetainAvailable 205]} +TEST(Publish5QCTest, Encode2) { + uint8_t pkt[] = { + 0x30, 0xd9, 0x2, 0x0, 0x2, 0xb7, 0xf9, 0xb6, 0x2, 0x2, 0x0, 0x0, 0x7d, 0x98, 0x9, 0x0, 0x11, 0x7d, 0x3b, + 0x5a, 0x79, 0x32, 0x77, 0xc4, 0xe, 0x9e, 0x9b, 0xd4, 0x1f, 0x91, 0x5b, 0xd8, 0xd0, 0x26, 0x8, 0x0, 0xb, 0x50, + 0x9a, 0xa, 0xa8, 0xde, 0x71, 0x19, 0xbf, 0x37, 0xf7, 0xd0, 0x8, 0x0, 0xc, 0x72, 0xa4, 0xaf, 0xab, 0x1a, 0x3d, + 0xa0, 0x44, 0x27, 0x76, 0x9a, 0xa7, 0x2a, 0x72, 0x12, 0x0, 0x1c, 0xb3, 0xf7, 0x24, 0x16, 0xd6, 0xe7, 0xdf, 0xeb, + 0x2b, 0x3d, 0x53, 0x75, 0x59, 0xf4, 0x67, 0x8a, 0x34, 0xc6, 0x9e, 0x6f, 0x9b, 0xd1, 0xbb, 0x9f, 0x76, 0x99, 0xe6, + 0xcb, 0x2, 0x0, 0x0, 0x1f, 0x23, 0x1f, 0x0, 0xe, 0xa7, 0xf, 0x90, 0x6a, 0xd, 0xe6, 0xcf, 0x51, 0x8b, 0x37, + 0x3, 0xf8, 0x5b, 0x9a, 0x2, 0x0, 0x0, 0x2a, 0xc8, 0x19, 0x94, 0x1f, 0x0, 0x8, 0x8b, 0x5b, 0xab, 0xe0, 0x21, + 0x7e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 0x4, 0x67, 0x61, + 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, + 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + uint8_t topic_bytes[] = {0xb7, 0xf9}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, + 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 29; + + uint8_t bytesprops0[] = {0x7d, 0x3b, 0x5a, 0x79, 0x32, 0x77, 0xc4, 0xe, 0x9e, + 0x9b, 0xd4, 0x1f, 0x91, 0x5b, 0xd8, 0xd0, 0x26}; + uint8_t bytesprops1[] = {0x50, 0x9a, 0xa, 0xa8, 0xde, 0x71, 0x19, 0xbf, 0x37, 0xf7, 0xd0}; + uint8_t bytesprops2[] = {0x72, 0xa4, 0xaf, 0xab, 0x1a, 0x3d, 0xa0, 0x44, 0x27, 0x76, 0x9a, 0xa7}; + uint8_t bytesprops3[] = {0xb3, 0xf7, 0x24, 0x16, 0xd6, 0xe7, 0xdf, 0xeb, 0x2b, 0x3d, 0x53, 0x75, 0x59, 0xf4, + 0x67, 0x8a, 0x34, 0xc6, 0x9e, 0x6f, 0x9b, 0xd1, 0xbb, 0x9f, 0x76, 0x99, 0xe6, 0xcb}; + uint8_t bytesprops4[] = {0xa7, 0xf, 0x90, 0x6a, 0xd, 0xe6, 0xcf, 0x51, 0x8b, 0x37, 0x3, 0xf8, 0x5b, 0x9a}; + uint8_t bytesprops5[] = {0x8b, 0x5b, 0xab, 0xe0, 0x21, 0x7e, 0xa4, 0xd2}; + uint8_t bytesprops6[] = {0x8a, 0xa9, 0xf, 0x56, 0xe7}; + uint8_t bytesprops7[] = {0xbc, 0x9b, 0x88, 0x6f, 0xf3, 0x4f, 0xc2}; + uint8_t bytesprops8[] = {0x5b, 0x3c, 0xe1, 0x82, 0xe1, 0xdf, 0x34, 0x86, 0x18, 0x7b, 0x30, + 0xbc, 0xd1, 0x42, 0x74, 0x80, 0x98, 0x41, 0x85, 0x7, 0xa}; + uint8_t bytesprops9[] = {0x42, 0xad, 0x6e, 0x1c, 0x44, 0x31, 0xc5, 0x7, 0xd3, 0x76, 0x90, 0x98, 0xb8, 0xbc, 0x42}; + uint8_t bytesprops10[] = {0x43, 0x32, 0xca, 0x80, 0x48, 0x13, 0x88, 0xbc, 0xc2, + 0x76, 0x33, 0xeb, 0xe7, 0xc6, 0x95, 0xfb, 0x7a, 0x63}; + uint8_t bytesprops11[] = {0x4c, 0x19, 0x93, 0xea, 0xc9, 0xc1, 0x9, 0x19, 0xf5, 0x2a, 0x70, 0xcd, 0x8a, 0xb6, 0x4f}; + uint8_t bytesprops13[] = {0x3, 0xde, 0x6f, 0x14, 0xa9, 0x82, 0x4f, 0x84, 0x16, 0x8d, 0x13}; + uint8_t bytesprops12[] = {0x6f, 0x1f, 0x1b, 0x9b, 0xa0, 0xdd, 0x66, 0xb0, 0x8d, 0x15, 0x9f}; + uint8_t bytesprops14[] = {0x11, 0xc3, 0xb9, 0x76, 0xa7, 0xd, 0xaf, 0x4e, 0x2e, 0xcf, 0x80, 0x1f, 0x4d, 0x93, + 0x3f, 0x2a, 0xa, 0x41, 0xf8, 0xa1, 0x85, 0xf4, 0xba, 0x7b, 0xfb, 0x2b, 0x2}; + uint8_t bytesprops15[] = {0x8a, 0x6e, 0x5b, 0x60, 0x43, 0x24}; -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\148\US\b\177\214\241A\128\215\138NRR\141\t\208\DC4\231\253\232\EM\205\r\162\157", _pubPktID = 0, _pubBody = "\DELQr", _pubProps = [PropCorrelationData "\189\129\175z\140\ETB\132",PropMessageExpiryInterval 31306,PropWildcardSubscriptionAvailable 199,PropContentType "\193B\DC3\184\200_",PropAssignedClientIdentifier "\200\131do}\205_\217~Z\149;\v\204\128",PropServerReference "\ENQ\135\165\f\196R\139>\214\231\DEL\208|\DC3\223H\152E\164",PropRequestProblemInformation 243,PropMaximumPacketSize 18984,PropTopicAlias 8169,PropRequestProblemInformation 2,PropMaximumQoS 70,PropWillDelayInterval 18634]} -TEST(Publish5QCTest, Encode2) { -uint8_t pkt[] = {0x31, 0x74, 0x0, 0x19, 0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d, 0x55, 0x9, 0x0, 0x7, 0xbd, 0x81, 0xaf, 0x7a, 0x8c, 0x17, 0x84, 0x2, 0x0, 0x0, 0x7a, 0x4a, 0x28, 0xc7, 0x3, 0x0, 0x6, 0xc1, 0x42, 0x13, 0xb8, 0xc8, 0x5f, 0x12, 0x0, 0xf, 0xc8, 0x83, 0x64, 0x6f, 0x7d, 0xcd, 0x5f, 0xd9, 0x7e, 0x5a, 0x95, 0x3b, 0xb, 0xcc, 0x80, 0x1c, 0x0, 0x13, 0x5, 0x87, 0xa5, 0xc, 0xc4, 0x52, 0x8b, 0x3e, 0xd6, 0xe7, 0x7f, 0xd0, 0x7c, 0x13, 0xdf, 0x48, 0x98, 0x45, 0xa4, 0x17, 0xf3, 0x27, 0x0, 0x0, 0x4a, 0x28, 0x23, 0x1f, 0xe9, 0x17, 0x2, 0x24, 0x46, 0x18, 0x0, 0x0, 0x48, 0xca, 0x7f, 0x51, 0x72}; - uint8_t topic_bytes[] = {0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS0; -msg.retained = true; -uint8_t msg_bytes[] = {0x7f, 0x51, 0x72}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 3; - - uint8_t bytesprops0[] = {0xbd, 0x81, 0xaf, 0x7a, 0x8c, 0x17, 0x84}; - uint8_t bytesprops1[] = {0xc1, 0x42, 0x13, 0xb8, 0xc8, 0x5f}; - uint8_t bytesprops2[] = {0xc8, 0x83, 0x64, 0x6f, 0x7d, 0xcd, 0x5f, 0xd9, 0x7e, 0x5a, 0x95, 0x3b, 0xb, 0xcc, 0x80}; - uint8_t bytesprops3[] = {0x5, 0x87, 0xa5, 0xc, 0xc4, 0x52, 0x8b, 0x3e, 0xd6, 0xe7, 0x7f, 0xd0, 0x7c, 0x13, 0xdf, 0x48, 0x98, 0x45, 0xa4}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31306}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18984}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8169}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18634}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32152}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7971}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10952}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24494}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32261}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {11, (char*)&bytesprops12}, .v = {11, (char*)&bytesprops13}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 205}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\148\US\b\177\214\241A\128\215\138NRR\141\t\208\DC4\231\253\232\EM\205\r\162\157", _pubPktID = 0, _pubBody = "\DELQr", _pubProps = [PropCorrelationData "\189\129\175z\140\ETB\132",PropMessageExpiryInterval 31306,PropWildcardSubscriptionAvailable 199,PropContentType "\193B\DC3\184\200_",PropAssignedClientIdentifier "\200\131do}\205_\217~Z\149;\v\204\128",PropServerReference "\ENQ\135\165\f\196R\139>\214\231\DEL\208|\DC3\223H\152E\164",PropRequestProblemInformation 243,PropMaximumPacketSize 18984,PropTopicAlias 8169,PropRequestProblemInformation 2,PropMaximumQoS 70,PropWillDelayInterval 18634]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\183\249", _pubPktID = 0, _pubBody +// = "M\EOTga\US?`w\167\&6\152\SI\NAKC\168>\173<\149\213m,5\235\133\r\180\190\195", _pubProps = +// [PropMessageExpiryInterval 32152,PropCorrelationData "};Zy2w\196\SO\158\155\212\US\145[\216\208&",PropResponseTopic +// "P\154\n\168\222q\EM\191\&7\247\208",PropResponseTopic +// "r\164\175\171\SUB=\160D'v\154\167",PropSharedSubscriptionAvailable 114,PropAssignedClientIdentifier +// "\179\247$\SYN\214\231\223\235+=SuY\244g\138\&4\198\158o\155\209\187\159v\153\230\203",PropMessageExpiryInterval +// 7971,PropReasonString "\167\SI\144j\r\230\207Q\139\&7\ETX\248[\154",PropMessageExpiryInterval +// 10952,PropRequestResponseInformation 148,PropReasonString "\139[\171\224!~\164\210",PropAssignedClientIdentifier +// "\138\169\SIV\231",PropAuthenticationData "\188\155\136o\243O\194",PropResponseInformation +// "[<\225\130\225\223\&4\134\CAN{0\188\209Bt\128\152A\133\a\n",PropSessionExpiryInterval +// 24494,PropSharedSubscriptionAvailable 202,PropResponseInformation +// "B\173n\FSD1\197\a\211v\144\152\184\188B",PropAuthenticationData +// "C2\202\128H\DC3\136\188\194v3\235\231\198\149\251zc",PropMaximumPacketSize 32261,PropRequestProblemInformation +// 61,PropSubscriptionIdentifierAvailable 184,PropResponseTopic +// "L\EM\147\234\201\193\t\EM\245*p\205\138\182O",PropUserProperty "o\US\ESC\155\160\221f\176\141\NAK\159" +// "\ETX\222o\DC4\169\130O\132\SYN\141\DC3",PropContentType +// "\DC1\195\185v\167\r\175N.\207\128\USM\147?*\nA\248\161\133\244\186{\251+\STX",PropContentType +// "\138n[`C$",PropRetainAvailable 205]} TEST(Publish5QCTest, Decode2) { -uint8_t pkt[] = {0x31, 0x74, 0x0, 0x19, 0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d, 0x55, 0x9, 0x0, 0x7, 0xbd, 0x81, 0xaf, 0x7a, 0x8c, 0x17, 0x84, 0x2, 0x0, 0x0, 0x7a, 0x4a, 0x28, 0xc7, 0x3, 0x0, 0x6, 0xc1, 0x42, 0x13, 0xb8, 0xc8, 0x5f, 0x12, 0x0, 0xf, 0xc8, 0x83, 0x64, 0x6f, 0x7d, 0xcd, 0x5f, 0xd9, 0x7e, 0x5a, 0x95, 0x3b, 0xb, 0xcc, 0x80, 0x1c, 0x0, 0x13, 0x5, 0x87, 0xa5, 0xc, 0xc4, 0x52, 0x8b, 0x3e, 0xd6, 0xe7, 0x7f, 0xd0, 0x7c, 0x13, 0xdf, 0x48, 0x98, 0x45, 0xa4, 0x17, 0xf3, 0x27, 0x0, 0x0, 0x4a, 0x28, 0x23, 0x1f, 0xe9, 0x17, 0x2, 0x24, 0x46, 0x18, 0x0, 0x0, 0x48, 0xca, 0x7f, 0x51, 0x72}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x94, 0x1f, 0x8, 0xb1, 0xd6, 0xf1, 0x41, 0x80, 0xd7, 0x8a, 0x4e, 0x52, 0x52, 0x8d, 0x9, 0xd0, 0x14, 0xe7, 0xfd, 0xe8, 0x19, 0xcd, 0xd, 0xa2, 0x9d}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7f, 0x51, 0x72}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS0); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 0); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); -EXPECT_EQ(msg.payload_len, 3); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = { + 0x30, 0xd9, 0x2, 0x0, 0x2, 0xb7, 0xf9, 0xb6, 0x2, 0x2, 0x0, 0x0, 0x7d, 0x98, 0x9, 0x0, 0x11, 0x7d, 0x3b, + 0x5a, 0x79, 0x32, 0x77, 0xc4, 0xe, 0x9e, 0x9b, 0xd4, 0x1f, 0x91, 0x5b, 0xd8, 0xd0, 0x26, 0x8, 0x0, 0xb, 0x50, + 0x9a, 0xa, 0xa8, 0xde, 0x71, 0x19, 0xbf, 0x37, 0xf7, 0xd0, 0x8, 0x0, 0xc, 0x72, 0xa4, 0xaf, 0xab, 0x1a, 0x3d, + 0xa0, 0x44, 0x27, 0x76, 0x9a, 0xa7, 0x2a, 0x72, 0x12, 0x0, 0x1c, 0xb3, 0xf7, 0x24, 0x16, 0xd6, 0xe7, 0xdf, 0xeb, + 0x2b, 0x3d, 0x53, 0x75, 0x59, 0xf4, 0x67, 0x8a, 0x34, 0xc6, 0x9e, 0x6f, 0x9b, 0xd1, 0xbb, 0x9f, 0x76, 0x99, 0xe6, + 0xcb, 0x2, 0x0, 0x0, 0x1f, 0x23, 0x1f, 0x0, 0xe, 0xa7, 0xf, 0x90, 0x6a, 0xd, 0xe6, 0xcf, 0x51, 0x8b, 0x37, + 0x3, 0xf8, 0x5b, 0x9a, 0x2, 0x0, 0x0, 0x2a, 0xc8, 0x19, 0x94, 0x1f, 0x0, 0x8, 0x8b, 0x5b, 0xab, 0xe0, 0x21, + 0x7e, 0xa4, 0xd2, 0x12, 0x0, 0x5, 0x8a, 0xa9, 0xf, 0x56, 0xe7, 0x16, 0x0, 0x7, 0xbc, 0x9b, 0x88, 0x6f, 0xf3, + 0x4f, 0xc2, 0x1a, 0x0, 0x15, 0x5b, 0x3c, 0xe1, 0x82, 0xe1, 0xdf, 0x34, 0x86, 0x18, 0x7b, 0x30, 0xbc, 0xd1, 0x42, + 0x74, 0x80, 0x98, 0x41, 0x85, 0x7, 0xa, 0x11, 0x0, 0x0, 0x5f, 0xae, 0x2a, 0xca, 0x1a, 0x0, 0xf, 0x42, 0xad, + 0x6e, 0x1c, 0x44, 0x31, 0xc5, 0x7, 0xd3, 0x76, 0x90, 0x98, 0xb8, 0xbc, 0x42, 0x16, 0x0, 0x12, 0x43, 0x32, 0xca, + 0x80, 0x48, 0x13, 0x88, 0xbc, 0xc2, 0x76, 0x33, 0xeb, 0xe7, 0xc6, 0x95, 0xfb, 0x7a, 0x63, 0x27, 0x0, 0x0, 0x7e, + 0x5, 0x17, 0x3d, 0x29, 0xb8, 0x8, 0x0, 0xf, 0x4c, 0x19, 0x93, 0xea, 0xc9, 0xc1, 0x9, 0x19, 0xf5, 0x2a, 0x70, + 0xcd, 0x8a, 0xb6, 0x4f, 0x26, 0x0, 0xb, 0x6f, 0x1f, 0x1b, 0x9b, 0xa0, 0xdd, 0x66, 0xb0, 0x8d, 0x15, 0x9f, 0x0, + 0xb, 0x3, 0xde, 0x6f, 0x14, 0xa9, 0x82, 0x4f, 0x84, 0x16, 0x8d, 0x13, 0x3, 0x0, 0x1b, 0x11, 0xc3, 0xb9, 0x76, + 0xa7, 0xd, 0xaf, 0x4e, 0x2e, 0xcf, 0x80, 0x1f, 0x4d, 0x93, 0x3f, 0x2a, 0xa, 0x41, 0xf8, 0xa1, 0x85, 0xf4, 0xba, + 0x7b, 0xfb, 0x2b, 0x2, 0x3, 0x0, 0x6, 0x8a, 0x6e, 0x5b, 0x60, 0x43, 0x24, 0x25, 0xcd, 0x4d, 0x4, 0x67, 0x61, + 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, + 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CANO\164\EM\236\160:x\bB\170\222ObK\201\DC1\168W}>\187\DC1", _pubPktID = 0, _pubBody = "", _pubProps = [PropServerKeepAlive 2018]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xb7, 0xf9}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, + 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\DC1\157\ns\ETX0?\130,\153\&5(\EM\NAK\235tg/\223cz\215\188l", _pubPktID = 23951, _pubBody = "\252\STX\212\139", +// _pubProps = [PropReceiveMaximum 2885,PropSubscriptionIdentifierAvailable 134,PropCorrelationData +// "4\178\DEL\235\196_\225<\219\177\197\GS\ENQ\167I\213\168N\155\163",PropMessageExpiryInterval +// 30572,PropSubscriptionIdentifierAvailable 249,PropTopicAliasMaximum 2600,PropRetainAvailable +// 111,PropResponseInformation "\235\188\191\218\&7\232t\203P\218%\190\184\209s\173\NAK\rY",PropMaximumPacketSize +// 27511,PropAuthenticationMethod +// "d$6\228\131\179\242\218\235\EM8\169\141HK\146\177\167)\253\133\137\172",PropMaximumPacketSize +// 13586,PropServerReference "\249X\232\RS\228\225\207(3\vn\153\170\200Ds\157\201\ENQ1\234W\167",PropServerReference +// "uMy\144F\248<\231\215\221\184z\132Wm}\ETX",PropTopicAlias 14062,PropResponseTopic +// "\195\172\153\209|\153\DC2K\138\230y\250\NUL\189\ACKV\NAKn!",PropAuthenticationData +// "Q5\182q\140\DLEu\153\164a\149\157?>]D\195\142\DC1",PropResponseInformation +// "9\139\232\228\EM",PropAssignedClientIdentifier "3\189w=\ESC",PropSubscriptionIdentifierAvailable +// 19,PropAuthenticationMethod +// "\174\235B\200\147\145\192\156B\SOHV\228`\182\245\217\233\165\138c\190\GS\DC1u\157K\187\234\207",PropSessionExpiryInterval +// 16713,PropResponseInformation "M\194\151d\163\182\EOT.\208\ACK\183\&9\159]3:\187",PropSharedSubscriptionAvailable +// 144,PropTopicAliasMaximum 11118,PropAuthenticationData "\f\EM\DEL\155\167\236;-J^~n_\162"]} TEST(Publish5QCTest, Encode3) { -uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x17, 0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11, 0x3, 0x13, 0x7, 0xe2}; - uint8_t topic_bytes[] = {0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS0; -msg.retained = false; -uint8_t msg_bytes[] = {0}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 0; + uint8_t pkt[] = { + 0x3a, 0xc2, 0x2, 0x0, 0x18, 0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, 0x19, 0x15, + 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xbc, 0x6c, 0x5d, 0x8f, 0xa0, 0x2, 0x21, 0xb, 0x45, 0x29, 0x86, + 0x9, 0x0, 0x14, 0x34, 0xb2, 0x7f, 0xeb, 0xc4, 0x5f, 0xe1, 0x3c, 0xdb, 0xb1, 0xc5, 0x1d, 0x5, 0xa7, 0x49, 0xd5, + 0xa8, 0x4e, 0x9b, 0xa3, 0x2, 0x0, 0x0, 0x77, 0x6c, 0x29, 0xf9, 0x22, 0xa, 0x28, 0x25, 0x6f, 0x1a, 0x0, 0x13, + 0xeb, 0xbc, 0xbf, 0xda, 0x37, 0xe8, 0x74, 0xcb, 0x50, 0xda, 0x25, 0xbe, 0xb8, 0xd1, 0x73, 0xad, 0x15, 0xd, 0x59, + 0x27, 0x0, 0x0, 0x6b, 0x77, 0x15, 0x0, 0x17, 0x64, 0x24, 0x36, 0xe4, 0x83, 0xb3, 0xf2, 0xda, 0xeb, 0x19, 0x38, + 0xa9, 0x8d, 0x48, 0x4b, 0x92, 0xb1, 0xa7, 0x29, 0xfd, 0x85, 0x89, 0xac, 0x27, 0x0, 0x0, 0x35, 0x12, 0x1c, 0x0, + 0x17, 0xf9, 0x58, 0xe8, 0x1e, 0xe4, 0xe1, 0xcf, 0x28, 0x33, 0xb, 0x6e, 0x99, 0xaa, 0xc8, 0x44, 0x73, 0x9d, 0xc9, + 0x5, 0x31, 0xea, 0x57, 0xa7, 0x1c, 0x0, 0x11, 0x75, 0x4d, 0x79, 0x90, 0x46, 0xf8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c, 0x6c}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xfc, 0x2, 0xd4, 0x8b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; + + uint8_t bytesprops0[] = {0x34, 0xb2, 0x7f, 0xeb, 0xc4, 0x5f, 0xe1, 0x3c, 0xdb, 0xb1, + 0xc5, 0x1d, 0x5, 0xa7, 0x49, 0xd5, 0xa8, 0x4e, 0x9b, 0xa3}; + uint8_t bytesprops1[] = {0xeb, 0xbc, 0xbf, 0xda, 0x37, 0xe8, 0x74, 0xcb, 0x50, 0xda, + 0x25, 0xbe, 0xb8, 0xd1, 0x73, 0xad, 0x15, 0xd, 0x59}; + uint8_t bytesprops2[] = {0x64, 0x24, 0x36, 0xe4, 0x83, 0xb3, 0xf2, 0xda, 0xeb, 0x19, 0x38, 0xa9, + 0x8d, 0x48, 0x4b, 0x92, 0xb1, 0xa7, 0x29, 0xfd, 0x85, 0x89, 0xac}; + uint8_t bytesprops3[] = {0xf9, 0x58, 0xe8, 0x1e, 0xe4, 0xe1, 0xcf, 0x28, 0x33, 0xb, 0x6e, 0x99, + 0xaa, 0xc8, 0x44, 0x73, 0x9d, 0xc9, 0x5, 0x31, 0xea, 0x57, 0xa7}; + uint8_t bytesprops4[] = {0x75, 0x4d, 0x79, 0x90, 0x46, 0xf8, 0x3c, 0xe7, 0xd7, + 0xdd, 0xb8, 0x7a, 0x84, 0x57, 0x6d, 0x7d, 0x3}; + uint8_t bytesprops5[] = {0xc3, 0xac, 0x99, 0xd1, 0x7c, 0x99, 0x12, 0x4b, 0x8a, 0xe6, + 0x79, 0xfa, 0x0, 0xbd, 0x6, 0x56, 0x15, 0x6e, 0x21}; + uint8_t bytesprops6[] = {0x51, 0x35, 0xb6, 0x71, 0x8c, 0x10, 0x75, 0x99, 0xa4, 0x61, + 0x95, 0x9d, 0x3f, 0x3e, 0x5d, 0x44, 0xc3, 0x8e, 0x11}; + uint8_t bytesprops7[] = {0x39, 0x8b, 0xe8, 0xe4, 0x19}; + uint8_t bytesprops8[] = {0x33, 0xbd, 0x77, 0x3d, 0x1b}; + uint8_t bytesprops9[] = {0xae, 0xeb, 0x42, 0xc8, 0x93, 0x91, 0xc0, 0x9c, 0x42, 0x1, 0x56, 0xe4, 0x60, 0xb6, 0xf5, + 0xd9, 0xe9, 0xa5, 0x8a, 0x63, 0xbe, 0x1d, 0x11, 0x75, 0x9d, 0x4b, 0xbb, 0xea, 0xcf}; + uint8_t bytesprops10[] = {0x4d, 0xc2, 0x97, 0x64, 0xa3, 0xb6, 0x4, 0x2e, 0xd0, + 0x6, 0xb7, 0x39, 0x9f, 0x5d, 0x33, 0x3a, 0xbb}; + uint8_t bytesprops11[] = {0xc, 0x19, 0x7f, 0x9b, 0xa7, 0xec, 0x3b, 0x2d, 0x4a, 0x5e, 0x7e, 0x6e, 0x5f, 0xa2}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2018}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2885}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30572}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2600}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27511}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13586}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14062}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16713}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11118}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 23951, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CANO\164\EM\236\160:x\bB\170\222ObK\201\DC1\168W}>\187\DC1", _pubPktID = 0, _pubBody = "", _pubProps = [PropServerKeepAlive 2018]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\DC1\157\ns\ETX0?\130,\153\&5(\EM\NAK\235tg/\223cz\215\188l", _pubPktID = 23951, _pubBody = "\252\STX\212\139", +// _pubProps = [PropReceiveMaximum 2885,PropSubscriptionIdentifierAvailable 134,PropCorrelationData +// "4\178\DEL\235\196_\225<\219\177\197\GS\ENQ\167I\213\168N\155\163",PropMessageExpiryInterval +// 30572,PropSubscriptionIdentifierAvailable 249,PropTopicAliasMaximum 2600,PropRetainAvailable +// 111,PropResponseInformation "\235\188\191\218\&7\232t\203P\218%\190\184\209s\173\NAK\rY",PropMaximumPacketSize +// 27511,PropAuthenticationMethod +// "d$6\228\131\179\242\218\235\EM8\169\141HK\146\177\167)\253\133\137\172",PropMaximumPacketSize +// 13586,PropServerReference "\249X\232\RS\228\225\207(3\vn\153\170\200Ds\157\201\ENQ1\234W\167",PropServerReference +// "uMy\144F\248<\231\215\221\184z\132Wm}\ETX",PropTopicAlias 14062,PropResponseTopic +// "\195\172\153\209|\153\DC2K\138\230y\250\NUL\189\ACKV\NAKn!",PropAuthenticationData +// "Q5\182q\140\DLEu\153\164a\149\157?>]D\195\142\DC1",PropResponseInformation +// "9\139\232\228\EM",PropAssignedClientIdentifier "3\189w=\ESC",PropSubscriptionIdentifierAvailable +// 19,PropAuthenticationMethod +// "\174\235B\200\147\145\192\156B\SOHV\228`\182\245\217\233\165\138c\190\GS\DC1u\157K\187\234\207",PropSessionExpiryInterval +// 16713,PropResponseInformation "M\194\151d\163\182\EOT.\208\ACK\183\&9\159]3:\187",PropSharedSubscriptionAvailable +// 144,PropTopicAliasMaximum 11118,PropAuthenticationData "\f\EM\DEL\155\167\236;-J^~n_\162"]} TEST(Publish5QCTest, Decode3) { -uint8_t pkt[] = {0x38, 0x1d, 0x0, 0x17, 0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11, 0x3, 0x13, 0x7, 0xe2}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x18, 0x4f, 0xa4, 0x19, 0xec, 0xa0, 0x3a, 0x78, 0x8, 0x42, 0xaa, 0xde, 0x4f, 0x62, 0x4b, 0xc9, 0x11, 0xa8, 0x57, 0x7d, 0x3e, 0xbb, 0x11}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS0); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 0); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); -EXPECT_EQ(msg.payload_len, 0); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = { + 0x3a, 0xc2, 0x2, 0x0, 0x18, 0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, 0x19, 0x15, + 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xbc, 0x6c, 0x5d, 0x8f, 0xa0, 0x2, 0x21, 0xb, 0x45, 0x29, 0x86, + 0x9, 0x0, 0x14, 0x34, 0xb2, 0x7f, 0xeb, 0xc4, 0x5f, 0xe1, 0x3c, 0xdb, 0xb1, 0xc5, 0x1d, 0x5, 0xa7, 0x49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0x0, 0x1d, 0xae, 0xeb, + 0x42, 0xc8, 0x93, 0x91, 0xc0, 0x9c, 0x42, 0x1, 0x56, 0xe4, 0x60, 0xb6, 0xf5, 0xd9, 0xe9, 0xa5, 0x8a, 0x63, 0xbe, + 0x1d, 0x11, 0x75, 0x9d, 0x4b, 0xbb, 0xea, 0xcf, 0x11, 0x0, 0x0, 0x41, 0x49, 0x1a, 0x0, 0x11, 0x4d, 0xc2, 0x97, + 0x64, 0xa3, 0xb6, 0x4, 0x2e, 0xd0, 0x6, 0xb7, 0x39, 0x9f, 0x5d, 0x33, 0x3a, 0xbb, 0x2a, 0x90, 0x22, 0x2b, 0x6e, + 0x16, 0x0, 0xe, 0xc, 0x19, 0x7f, 0x9b, 0xa7, 0xec, 0x3b, 0x2d, 0x4a, 0x5e, 0x7e, 0x6e, 0x5f, 0xa2, 0xfc, 0x2, + 0xd4, 0x8b}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, + 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xbc, 0x6c}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfc, 0x2, 0xd4, 0x8b}; + lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 23951); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 4); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "2]\237\233\224\238", _pubPktID = +// 32430, _pubBody = "\\7\a}d\f\191)\250N\n\r\240\169\178\184]", _pubProps = [PropResponseInformation +// "",PropMessageExpiryInterval 21151,PropMessageExpiryInterval 151,PropReasonString +// "\230\215Z\157U\190\241f\174\150{\183\NAK\239\204\n\150\183\128AV\144\n",PropMaximumPacketSize +// 11185,PropMaximumPacketSize 25334,PropSubscriptionIdentifierAvailable 124,PropReceiveMaximum +// 12433,PropCorrelationData "G\192\206\131\145\SOH\255>\211&\136\161$!`^G",PropServerKeepAlive +// 19132,PropServerReference "q\RS\RSB\\\204\182\165",PropRetainAvailable 93,PropServerKeepAlive 1218,PropMaximumQoS +// 66,PropPayloadFormatIndicator 228,PropResponseInformation +// "\138[\247\246\166\GS\CANx\RS\188",PropAssignedClientIdentifier +// "\229\203\GS\146I\202t\182\230%\238O\DC1\237\222\219\175\213VT\186\154\DC3d\251\138A\SI",PropMaximumQoS +// 44,PropMessageExpiryInterval 8113,PropMaximumQoS 61,PropRequestResponseInformation +// 120,PropSubscriptionIdentifierAvailable 168,PropReceiveMaximum 6126,PropResponseInformation +// "?g%\180\ETB0\226\191W\198!K\175\f\240\159\186W\210\166L\188\SYN\136\EM\199\229\&9",PropPayloadFormatIndicator +// 19,PropMaximumQoS 97]} +TEST(Publish5QCTest, Encode4) { + uint8_t pkt[] = { + 0x35, 0xdd, 0x1, 0x0, 0x6, 0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee, 0x7e, 0xae, 0xc0, 0x1, 0x1a, 0x0, 0x0, 0x2, + 0x0, 0x0, 0x52, 0x9f, 0x2, 0x0, 0x0, 0x0, 0x97, 0x1f, 0x0, 0x17, 0xe6, 0xd7, 0x5a, 0x9d, 0x55, 0xbe, 0xf1, + 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topic_bytes[] = {0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee}; + lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x5c, 0x37, 0x7, 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, + 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 17; -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "]\151\151\159oP\170", _pubPktID = 14052, _pubBody = "\254\174c\158\219\&7\163j\130\179TW\155\250\141\164c", _pubProps = [PropResponseTopic "\218\139\158d\216\160\SUB\156h\198\176Jr\158\139\&0\196\194h\251\SOH\EOT\233Z\239\219\146",PropSessionExpiryInterval 3572,PropSubscriptionIdentifier 18,PropCorrelationData "4w\174@n\DC1\156\DC1(\CAN\240\164>/\140\&3~n#\175X\CAN\199\221\&4j\159Kf*",PropServerKeepAlive 5008,PropUserProperty "S\DC3[\235\174\129 pA\216\163\&2.\238\ETB>k\243" "\204\189\195iQ\144\132\211\217r\247\NUL\131\244t8\229@\196\244\174}X",PropTopicAlias 974,PropContentType "sQ",PropRequestResponseInformation 85,PropContentType "\t\175\244\144\207\SOH\181",PropSessionExpiryInterval 6517,PropSessionExpiryInterval 8268,PropSessionExpiryInterval 11191,PropSubscriptionIdentifierAvailable 225,PropMaximumPacketSize 26160,PropMaximumPacketSize 24248,PropSubscriptionIdentifierAvailable 187,PropCorrelationData "+\RS:!7\187\222\134`]\210\250\ACK\223W\130H\140\194$\255d\145\237\189\154N\SUB\152\221",PropWillDelayInterval 13076,PropSessionExpiryInterval 17784,PropTopicAliasMaximum 28192,PropReceiveMaximum 30677,PropSharedSubscriptionAvailable 104,PropMessageExpiryInterval 5065,PropRequestProblemInformation 113,PropRequestResponseInformation 239,PropMessageExpiryInterval 11285]} -TEST(Publish5QCTest, Encode4) { -uint8_t pkt[] = {0x3b, 0x87, 0x2, 0x0, 0x7, 0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa, 0x36, 0xe4, 0xe9, 0x1, 0x8, 0x0, 0x1b, 0xda, 0x8b, 0x9e, 0x64, 0xd8, 0xa0, 0x1a, 0x9c, 0x68, 0xc6, 0xb0, 0x4a, 0x72, 0x9e, 0x8b, 0x30, 0xc4, 0xc2, 0x68, 0xfb, 0x1, 0x4, 0xe9, 0x5a, 0xef, 0xdb, 0x92, 0x11, 0x0, 0x0, 0xd, 0xf4, 0xb, 0x12, 0x9, 0x0, 0x1e, 0x34, 0x77, 0xae, 0x40, 0x6e, 0x11, 0x9c, 0x11, 0x28, 0x18, 0xf0, 0xa4, 0x3e, 0x2f, 0x8c, 0x33, 0x7e, 0x6e, 0x23, 0xaf, 0x58, 0x18, 0xc7, 0xdd, 0x34, 0x6a, 0x9f, 0x4b, 0x66, 0x2a, 0x13, 0x13, 0x90, 0x26, 0x0, 0x12, 0x53, 0x13, 0x5b, 0xeb, 0xae, 0x81, 0x20, 0x70, 0x41, 0xd8, 0xa3, 0x32, 0x2e, 0xee, 0x17, 0x3e, 0x6b, 0xf3, 0x0, 0x17, 0xcc, 0xbd, 0xc3, 0x69, 0x51, 0x90, 0x84, 0xd3, 0xd9, 0x72, 0xf7, 0x0, 0x83, 0xf4, 0x74, 0x38, 0xe5, 0x40, 0xc4, 0xf4, 0xae, 0x7d, 0x58, 0x23, 0x3, 0xce, 0x3, 0x0, 0x2, 0x73, 0x51, 0x19, 0x55, 0x3, 0x0, 0x7, 0x9, 0xaf, 0xf4, 0x90, 0xcf, 0x1, 0xb5, 0x11, 0x0, 0x0, 0x19, 0x75, 0x11, 0x0, 0x0, 0x20, 0x4c, 0x11, 0x0, 0x0, 0x2b, 0xb7, 0x29, 0xe1, 0x27, 0x0, 0x0, 0x66, 0x30, 0x27, 0x0, 0x0, 0x5e, 0xb8, 0x29, 0xbb, 0x9, 0x0, 0x1e, 0x2b, 0x1e, 0x3a, 0x21, 0x37, 0xbb, 0xde, 0x86, 0x60, 0x5d, 0xd2, 0xfa, 0x6, 0xdf, 0x57, 0x82, 0x48, 0x8c, 0xc2, 0x24, 0xff, 0x64, 0x91, 0xed, 0xbd, 0x9a, 0x4e, 0x1a, 0x98, 0xdd, 0x18, 0x0, 0x0, 0x33, 0x14, 0x11, 0x0, 0x0, 0x45, 0x78, 0x22, 0x6e, 0x20, 0x21, 0x77, 0xd5, 0x2a, 0x68, 0x2, 0x0, 0x0, 0x13, 0xc9, 0x17, 0x71, 0x19, 0xef, 0x2, 0x0, 0x0, 0x2c, 0x15, 0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; - uint8_t topic_bytes[] = {0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xe6, 0xd7, 0x5a, 0x9d, 0x55, 0xbe, 0xf1, 0x66, 0xae, 0x96, 0x7b, 0xb7, + 0x15, 0xef, 0xcc, 0xa, 0x96, 0xb7, 0x80, 0x41, 0x56, 0x90, 0xa}; + uint8_t bytesprops2[] = {0x47, 0xc0, 0xce, 0x83, 0x91, 0x1, 0xff, 0x3e, 0xd3, + 0x26, 0x88, 0xa1, 0x24, 0x21, 0x60, 0x5e, 0x47}; + uint8_t bytesprops3[] = {0x71, 0x1e, 0x1e, 0x42, 0x5c, 0xcc, 0xb6, 0xa5}; + uint8_t bytesprops4[] = {0x8a, 0x5b, 0xf7, 0xf6, 0xa6, 0x1d, 0x18, 0x78, 0x1e, 0xbc}; + uint8_t bytesprops5[] = {0xe5, 0xcb, 0x1d, 0x92, 0x49, 0xca, 0x74, 0xb6, 0xe6, 0x25, 0xee, 0x4f, 0x11, 0xed, + 0xde, 0xdb, 0xaf, 0xd5, 0x56, 0x54, 0xba, 0x9a, 0x13, 0x64, 0xfb, 0x8a, 0x41, 0xf}; + uint8_t bytesprops6[] = {0x3f, 0x67, 0x25, 0xb4, 0x17, 0x30, 0xe2, 0xbf, 0x57, 0xc6, 0x21, 0x4b, 0xaf, 0xc, + 0xf0, 0x9f, 0xba, 0x57, 0xd2, 0xa6, 0x4c, 0xbc, 0x16, 0x88, 0x19, 0xc7, 0xe5, 0x39}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 17; - - uint8_t bytesprops0[] = {0xda, 0x8b, 0x9e, 0x64, 0xd8, 0xa0, 0x1a, 0x9c, 0x68, 0xc6, 0xb0, 0x4a, 0x72, 0x9e, 0x8b, 0x30, 0xc4, 0xc2, 0x68, 0xfb, 0x1, 0x4, 0xe9, 0x5a, 0xef, 0xdb, 0x92}; - uint8_t bytesprops1[] = {0x34, 0x77, 0xae, 0x40, 0x6e, 0x11, 0x9c, 0x11, 0x28, 0x18, 0xf0, 0xa4, 0x3e, 0x2f, 0x8c, 0x33, 0x7e, 0x6e, 0x23, 0xaf, 0x58, 0x18, 0xc7, 0xdd, 0x34, 0x6a, 0x9f, 0x4b, 0x66, 0x2a}; - uint8_t bytesprops3[] = {0xcc, 0xbd, 0xc3, 0x69, 0x51, 0x90, 0x84, 0xd3, 0xd9, 0x72, 0xf7, 0x0, 0x83, 0xf4, 0x74, 0x38, 0xe5, 0x40, 0xc4, 0xf4, 0xae, 0x7d, 0x58}; - uint8_t bytesprops2[] = {0x53, 0x13, 0x5b, 0xeb, 0xae, 0x81, 0x20, 0x70, 0x41, 0xd8, 0xa3, 0x32, 0x2e, 0xee, 0x17, 0x3e, 0x6b, 0xf3}; - uint8_t bytesprops4[] = {0x73, 0x51}; - uint8_t bytesprops5[] = {0x9, 0xaf, 0xf4, 0x90, 0xcf, 0x1, 0xb5}; - uint8_t bytesprops6[] = {0x2b, 0x1e, 0x3a, 0x21, 0x37, 0xbb, 0xde, 0x86, 0x60, 0x5d, 0xd2, 0xfa, 0x6, 0xdf, 0x57, 0x82, 0x48, 0x8c, 0xc2, 0x24, 0xff, 0x64, 0x91, 0xed, 0xbd, 0x9a, 0x4e, 0x1a, 0x98, 0xdd}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3572}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5008}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={18, (char*)&bytesprops2}, .v={23, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 974}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6517}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8268}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11191}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26160}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24248}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13076}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17784}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28192}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30677}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5065}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11285}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21151}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 151}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11185}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25334}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12433}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19132}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1218}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8113}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6126}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 97}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 14052, topic, msg, props); + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32430, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "]\151\151\159oP\170", _pubPktID = 14052, _pubBody = "\254\174c\158\219\&7\163j\130\179TW\155\250\141\164c", _pubProps = [PropResponseTopic "\218\139\158d\216\160\SUB\156h\198\176Jr\158\139\&0\196\194h\251\SOH\EOT\233Z\239\219\146",PropSessionExpiryInterval 3572,PropSubscriptionIdentifier 18,PropCorrelationData "4w\174@n\DC1\156\DC1(\CAN\240\164>/\140\&3~n#\175X\CAN\199\221\&4j\159Kf*",PropServerKeepAlive 5008,PropUserProperty "S\DC3[\235\174\129 pA\216\163\&2.\238\ETB>k\243" "\204\189\195iQ\144\132\211\217r\247\NUL\131\244t8\229@\196\244\174}X",PropTopicAlias 974,PropContentType "sQ",PropRequestResponseInformation 85,PropContentType "\t\175\244\144\207\SOH\181",PropSessionExpiryInterval 6517,PropSessionExpiryInterval 8268,PropSessionExpiryInterval 11191,PropSubscriptionIdentifierAvailable 225,PropMaximumPacketSize 26160,PropMaximumPacketSize 24248,PropSubscriptionIdentifierAvailable 187,PropCorrelationData "+\RS:!7\187\222\134`]\210\250\ACK\223W\130H\140\194$\255d\145\237\189\154N\SUB\152\221",PropWillDelayInterval 13076,PropSessionExpiryInterval 17784,PropTopicAliasMaximum 28192,PropReceiveMaximum 30677,PropSharedSubscriptionAvailable 104,PropMessageExpiryInterval 5065,PropRequestProblemInformation 113,PropRequestResponseInformation 239,PropMessageExpiryInterval 11285]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "2]\237\233\224\238", _pubPktID = +// 32430, _pubBody = "\\7\a}d\f\191)\250N\n\r\240\169\178\184]", _pubProps = [PropResponseInformation +// "",PropMessageExpiryInterval 21151,PropMessageExpiryInterval 151,PropReasonString +// "\230\215Z\157U\190\241f\174\150{\183\NAK\239\204\n\150\183\128AV\144\n",PropMaximumPacketSize +// 11185,PropMaximumPacketSize 25334,PropSubscriptionIdentifierAvailable 124,PropReceiveMaximum +// 12433,PropCorrelationData "G\192\206\131\145\SOH\255>\211&\136\161$!`^G",PropServerKeepAlive +// 19132,PropServerReference "q\RS\RSB\\\204\182\165",PropRetainAvailable 93,PropServerKeepAlive 1218,PropMaximumQoS +// 66,PropPayloadFormatIndicator 228,PropResponseInformation +// "\138[\247\246\166\GS\CANx\RS\188",PropAssignedClientIdentifier +// "\229\203\GS\146I\202t\182\230%\238O\DC1\237\222\219\175\213VT\186\154\DC3d\251\138A\SI",PropMaximumQoS +// 44,PropMessageExpiryInterval 8113,PropMaximumQoS 61,PropRequestResponseInformation +// 120,PropSubscriptionIdentifierAvailable 168,PropReceiveMaximum 6126,PropResponseInformation +// "?g%\180\ETB0\226\191W\198!K\175\f\240\159\186W\210\166L\188\SYN\136\EM\199\229\&9",PropPayloadFormatIndicator +// 19,PropMaximumQoS 97]} TEST(Publish5QCTest, Decode4) { -uint8_t pkt[] = {0x3b, 0x87, 0x2, 0x0, 0x7, 0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa, 0x36, 0xe4, 0xe9, 0x1, 0x8, 0x0, 0x1b, 0xda, 0x8b, 0x9e, 0x64, 0xd8, 0xa0, 0x1a, 0x9c, 0x68, 0xc6, 0xb0, 0x4a, 0x72, 0x9e, 0x8b, 0x30, 0xc4, 0xc2, 0x68, 0xfb, 0x1, 0x4, 0xe9, 0x5a, 0xef, 0xdb, 0x92, 0x11, 0x0, 0x0, 0xd, 0xf4, 0xb, 0x12, 0x9, 0x0, 0x1e, 0x34, 0x77, 0xae, 0x40, 0x6e, 0x11, 0x9c, 0x11, 0x28, 0x18, 0xf0, 0xa4, 0x3e, 0x2f, 0x8c, 0x33, 0x7e, 0x6e, 0x23, 0xaf, 0x58, 0x18, 0xc7, 0xdd, 0x34, 0x6a, 0x9f, 0x4b, 0x66, 0x2a, 0x13, 0x13, 0x90, 0x26, 0x0, 0x12, 0x53, 0x13, 0x5b, 0xeb, 0xae, 0x81, 0x20, 0x70, 0x41, 0xd8, 0xa3, 0x32, 0x2e, 0xee, 0x17, 0x3e, 0x6b, 0xf3, 0x0, 0x17, 0xcc, 0xbd, 0xc3, 0x69, 0x51, 0x90, 0x84, 0xd3, 0xd9, 0x72, 0xf7, 0x0, 0x83, 0xf4, 0x74, 0x38, 0xe5, 0x40, 0xc4, 0xf4, 0xae, 0x7d, 0x58, 0x23, 0x3, 0xce, 0x3, 0x0, 0x2, 0x73, 0x51, 0x19, 0x55, 0x3, 0x0, 0x7, 0x9, 0xaf, 0xf4, 0x90, 0xcf, 0x1, 0xb5, 0x11, 0x0, 0x0, 0x19, 0x75, 0x11, 0x0, 0x0, 0x20, 0x4c, 0x11, 0x0, 0x0, 0x2b, 0xb7, 0x29, 0xe1, 0x27, 0x0, 0x0, 0x66, 0x30, 0x27, 0x0, 0x0, 0x5e, 0xb8, 0x29, 0xbb, 0x9, 0x0, 0x1e, 0x2b, 0x1e, 0x3a, 0x21, 0x37, 0xbb, 0xde, 0x86, 0x60, 0x5d, 0xd2, 0xfa, 0x6, 0xdf, 0x57, 0x82, 0x48, 0x8c, 0xc2, 0x24, 0xff, 0x64, 0x91, 0xed, 0xbd, 0x9a, 0x4e, 0x1a, 0x98, 0xdd, 0x18, 0x0, 0x0, 0x33, 0x14, 0x11, 0x0, 0x0, 0x45, 0x78, 0x22, 0x6e, 0x20, 0x21, 0x77, 0xd5, 0x2a, 0x68, 0x2, 0x0, 0x0, 0x13, 0xc9, 0x17, 0x71, 0x19, 0xef, 0x2, 0x0, 0x0, 0x2c, 0x15, 0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5d, 0x97, 0x97, 0x9f, 0x6f, 0x50, 0xaa}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfe, 0xae, 0x63, 0x9e, 0xdb, 0x37, 0xa3, 0x6a, 0x82, 0xb3, 0x54, 0x57, 0x9b, 0xfa, 0x8d, 0xa4, 0x63}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 14052); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); -EXPECT_EQ(msg.payload_len, 17); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = { + 0x35, 0xdd, 0x1, 0x0, 0x6, 0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee, 0x7e, 0xae, 0xc0, 0x1, 0x1a, 0x0, 0x0, 0x2, + 0x0, 0x0, 0x52, 0x9f, 0x2, 0x0, 0x0, 0x0, 0x97, 0x1f, 0x0, 0x17, 0xe6, 0xd7, 0x5a, 0x9d, 0x55, 0xbe, 0xf1, + 0x66, 0xae, 0x96, 0x7b, 0xb7, 0x15, 0xef, 0xcc, 0xa, 0x96, 0xb7, 0x80, 0x41, 0x56, 0x90, 0xa, 0x27, 0x0, 0x0, + 0x2b, 0xb1, 0x27, 0x0, 0x0, 0x62, 0xf6, 0x29, 0x7c, 0x21, 0x30, 0x91, 0x9, 0x0, 0x11, 0x47, 0xc0, 0xce, 0x83, + 0x91, 0x1, 0xff, 0x3e, 0xd3, 0x26, 0x88, 0xa1, 0x24, 0x21, 0x60, 0x5e, 0x47, 0x13, 0x4a, 0xbc, 0x1c, 0x0, 0x8, + 0x71, 0x1e, 0x1e, 0x42, 0x5c, 0xcc, 0xb6, 0xa5, 0x25, 0x5d, 0x13, 0x4, 0xc2, 0x24, 0x42, 0x1, 0xe4, 0x1a, 0x0, + 0xa, 0x8a, 0x5b, 0xf7, 0xf6, 0xa6, 0x1d, 0x18, 0x78, 0x1e, 0xbc, 0x12, 0x0, 0x1c, 0xe5, 0xcb, 0x1d, 0x92, 0x49, + 0xca, 0x74, 0xb6, 0xe6, 0x25, 0xee, 0x4f, 0x11, 0xed, 0xde, 0xdb, 0xaf, 0xd5, 0x56, 0x54, 0xba, 0x9a, 0x13, 0x64, + 0xfb, 0x8a, 0x41, 0xf, 0x24, 0x2c, 0x2, 0x0, 0x0, 0x1f, 0xb1, 0x24, 0x3d, 0x19, 0x78, 0x29, 0xa8, 0x21, 0x17, + 0xee, 0x1a, 0x0, 0x1c, 0x3f, 0x67, 0x25, 0xb4, 0x17, 0x30, 0xe2, 0xbf, 0x57, 0xc6, 0x21, 0x4b, 0xaf, 0xc, 0xf0, + 0x9f, 0xba, 0x57, 0xd2, 0xa6, 0x4c, 0xbc, 0x16, 0x88, 0x19, 0xc7, 0xe5, 0x39, 0x1, 0x13, 0x24, 0x61, 0x5c, 0x37, + 0x7, 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} - - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "F\129\169\SYN\215A[Qx}\223\&7NE\181\250\249\236\208\GSL\217\176\183\235\&0\189\247u_", _pubPktID = 26784, _pubBody = "\176\&0\158\138\138]\220(B\154\&3\224jV\159v+\130", _pubProps = [PropServerReference "\171\NUL\255\181W#c)\213_\233\156l\214e7\223\159\SYN\138\186Na\129\231\200\222\187\SI",PropResponseInformation "9\247>''\242\222\229\ACK#n\DC4!\\\253\&4pA\238\158\195",PropCorrelationData "v\US\177M\242\DC2\171\229\194h\194\147\236KT\147",PropWildcardSubscriptionAvailable 249,PropAuthenticationMethod "\ACK\168\&7$\DEL\194wS\162",PropTopicAliasMaximum 28784,PropTopicAliasMaximum 19013,PropServerKeepAlive 3972,PropPayloadFormatIndicator 111,PropTopicAlias 4635,PropWillDelayInterval 6106,PropResponseTopic "!\248",PropSubscriptionIdentifier 16,PropResponseTopic "c4Pne\208y\197\194",PropContentType "3A\148\175\r",PropTopicAliasMaximum 8280,PropRequestResponseInformation 163,PropMaximumPacketSize 10851,PropReceiveMaximum 29504,PropMaximumPacketSize 24457,PropServerReference "/\164X\232R9B\249\173Y\ACK\144\ACK%\138a\STX\ETX\190}\250WU\169\164\183",PropServerKeepAlive 15970,PropAuthenticationMethod ";J6"]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee}; + lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5c, 0x37, 0x7, 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, + 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 32430); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "V\156\142\176", _pubPktID = 29213, +// _pubBody = "\EM\FSK\190t\254o\168\200\&9\131(\254Z\138g\243jL|\137\220", _pubProps = [PropMaximumPacketSize +// 3871,PropMaximumQoS 160,PropMessageExpiryInterval 10386,PropRequestResponseInformation +// 71,PropRequestProblemInformation 55,PropRetainAvailable 35,PropReceiveMaximum 27736,PropMessageExpiryInterval +// 15681,PropMaximumQoS 67,PropAuthenticationData "{jG\fFZ\241\EM\239G\254",PropResponseInformation +// "TW\FS{r\"\SI\182\168\b\182X\154\207@\195\192\248\&92\185>\DC3`\243\SYN",PropReasonString +// "\139\171\245\232",PropMessageExpiryInterval 15064,PropPayloadFormatIndicator 3,PropRequestProblemInformation +// 14,PropSubscriptionIdentifierAvailable 35,PropWillDelayInterval 5426,PropRequestProblemInformation +// 178,PropContentType "\136\206\198#c\DEL\219",PropResponseInformation "3\n",PropRetainAvailable 192,PropTopicAlias +// 19843,PropMaximumPacketSize 12373,PropRetainAvailable 239,PropContentType +// "!\164\212\179e\SO$\195nqq\153a\252\246\234\194\245\188",PropResponseTopic "\152",PropWillDelayInterval +// 22627,PropRequestResponseInformation 4]} TEST(Publish5QCTest, Encode5) { -uint8_t pkt[] = {0x3d, 0xf5, 0x1, 0x0, 0x1e, 0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f, 0x68, 0xa0, 0xbf, 0x1, 0x1c, 0x0, 0x1d, 0xab, 0x0, 0xff, 0xb5, 0x57, 0x23, 0x63, 0x29, 0xd5, 0x5f, 0xe9, 0x9c, 0x6c, 0xd6, 0x65, 0x37, 0xdf, 0x9f, 0x16, 0x8a, 0xba, 0x4e, 0x61, 0x81, 0xe7, 0xc8, 0xde, 0xbb, 0xf, 0x1a, 0x0, 0x15, 0x39, 0xf7, 0x3e, 0x27, 0x27, 0xf2, 0xde, 0xe5, 0x6, 0x23, 0x6e, 0x14, 0x21, 0x5c, 0xfd, 0x34, 0x70, 0x41, 0xee, 0x9e, 0xc3, 0x9, 0x0, 0x10, 0x76, 0x1f, 0xb1, 0x4d, 0xf2, 0x12, 0xab, 0xe5, 0xc2, 0x68, 0xc2, 0x93, 0xec, 0x4b, 0x54, 0x93, 0x28, 0xf9, 0x15, 0x0, 0x9, 0x6, 0xa8, 0x37, 0x24, 0x7f, 0xc2, 0x77, 0x53, 0xa2, 0x22, 0x70, 0x70, 0x22, 0x4a, 0x45, 0x13, 0xf, 0x84, 0x1, 0x6f, 0x23, 0x12, 0x1b, 0x18, 0x0, 0x0, 0x17, 0xda, 0x8, 0x0, 0x2, 0x21, 0xf8, 0xb, 0x10, 0x8, 0x0, 0x9, 0x63, 0x34, 0x50, 0x6e, 0x65, 0xd0, 0x79, 0xc5, 0xc2, 0x3, 0x0, 0x5, 0x33, 0x41, 0x94, 0xaf, 0xd, 0x22, 0x20, 0x58, 0x19, 0xa3, 0x27, 0x0, 0x0, 0x2a, 0x63, 0x21, 0x73, 0x40, 0x27, 0x0, 0x0, 0x5f, 0x89, 0x1c, 0x0, 0x1a, 0x2f, 0xa4, 0x58, 0xe8, 0x52, 0x39, 0x42, 0xf9, 0xad, 0x59, 0x6, 0x90, 0x6, 0x25, 0x8a, 0x61, 0x2, 0x3, 0xbe, 0x7d, 0xfa, 0x57, 0x55, 0xa9, 0xa4, 0xb7, 0x13, 0x3e, 0x62, 0x15, 0x0, 0x3, 0x3b, 0x4a, 0x36, 0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; - uint8_t topic_bytes[] = {0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0xbc, 0x1, 0x0, 0x4, 0x56, 0x9c, 0x8e, 0xb0, 0x72, 0x1d, 0x9c, 0x1, 0x27, 0x0, 0x0, + 0xf, 0x1f, 0x24, 0xa0, 0x2, 0x0, 0x0, 0x28, 0x92, 0x19, 0x47, 0x17, 0x37, 0x25, 0x23, 0x21, + 0x6c, 0x58, 0x2, 0x0, 0x0, 0x3d, 0x41, 0x24, 0x43, 0x16, 0x0, 0xb, 0x7b, 0x6a, 0x47, 0xc, + 0x46, 0x5a, 0xf1, 0x19, 0xef, 0x47, 0xfe, 0x1a, 0x0, 0x1a, 0x54, 0x57, 0x1c, 0x7b, 0x72, 0x22, + 0xf, 0xb6, 0xa8, 0x8, 0xb6, 0x58, 0x9a, 0xcf, 0x40, 0xc3, 0xc0, 0xf8, 0x39, 0x32, 0xb9, 0x3e, + 0x13, 0x60, 0xf3, 0x16, 0x1f, 0x0, 0x4, 0x8b, 0xab, 0xf5, 0xe8, 0x2, 0x0, 0x0, 0x3a, 0xd8, + 0x1, 0x3, 0x17, 0xe, 0x29, 0x23, 0x18, 0x0, 0x0, 0x15, 0x32, 0x17, 0xb2, 0x3, 0x0, 0x7, + 0x88, 0xce, 0xc6, 0x23, 0x63, 0x7f, 0xdb, 0x1a, 0x0, 0x2, 0x33, 0xa, 0x25, 0xc0, 0x23, 0x4d, + 0x83, 0x27, 0x0, 0x0, 0x30, 0x55, 0x25, 0xef, 0x3, 0x0, 0x13, 0x21, 0xa4, 0xd4, 0xb3, 0x65, + 0xe, 0x24, 0xc3, 0x6e, 0x71, 0x71, 0x99, 0x61, 0xfc, 0xf6, 0xea, 0xc2, 0xf5, 0xbc, 0x8, 0x0, + 0x1, 0x98, 0x18, 0x0, 0x0, 0x58, 0x63, 0x19, 0x4, 0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, 0x6f, + 0xa8, 0xc8, 0x39, 0x83, 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + uint8_t topic_bytes[] = {0x56, 0x9c, 0x8e, 0xb0}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, 0x6f, 0xa8, 0xc8, 0x39, 0x83, + 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + uint8_t bytesprops0[] = {0x7b, 0x6a, 0x47, 0xc, 0x46, 0x5a, 0xf1, 0x19, 0xef, 0x47, 0xfe}; + uint8_t bytesprops1[] = {0x54, 0x57, 0x1c, 0x7b, 0x72, 0x22, 0xf, 0xb6, 0xa8, 0x8, 0xb6, 0x58, 0x9a, + 0xcf, 0x40, 0xc3, 0xc0, 0xf8, 0x39, 0x32, 0xb9, 0x3e, 0x13, 0x60, 0xf3, 0x16}; + uint8_t bytesprops2[] = {0x8b, 0xab, 0xf5, 0xe8}; + uint8_t bytesprops3[] = {0x88, 0xce, 0xc6, 0x23, 0x63, 0x7f, 0xdb}; + uint8_t bytesprops4[] = {0x33, 0xa}; + uint8_t bytesprops5[] = {0x21, 0xa4, 0xd4, 0xb3, 0x65, 0xe, 0x24, 0xc3, 0x6e, 0x71, + 0x71, 0x99, 0x61, 0xfc, 0xf6, 0xea, 0xc2, 0xf5, 0xbc}; + uint8_t bytesprops6[] = {0x98}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 18; - - uint8_t bytesprops0[] = {0xab, 0x0, 0xff, 0xb5, 0x57, 0x23, 0x63, 0x29, 0xd5, 0x5f, 0xe9, 0x9c, 0x6c, 0xd6, 0x65, 0x37, 0xdf, 0x9f, 0x16, 0x8a, 0xba, 0x4e, 0x61, 0x81, 0xe7, 0xc8, 0xde, 0xbb, 0xf}; - uint8_t bytesprops1[] = {0x39, 0xf7, 0x3e, 0x27, 0x27, 0xf2, 0xde, 0xe5, 0x6, 0x23, 0x6e, 0x14, 0x21, 0x5c, 0xfd, 0x34, 0x70, 0x41, 0xee, 0x9e, 0xc3}; - uint8_t bytesprops2[] = {0x76, 0x1f, 0xb1, 0x4d, 0xf2, 0x12, 0xab, 0xe5, 0xc2, 0x68, 0xc2, 0x93, 0xec, 0x4b, 0x54, 0x93}; - uint8_t bytesprops3[] = {0x6, 0xa8, 0x37, 0x24, 0x7f, 0xc2, 0x77, 0x53, 0xa2}; - uint8_t bytesprops4[] = {0x21, 0xf8}; - uint8_t bytesprops5[] = {0x63, 0x34, 0x50, 0x6e, 0x65, 0xd0, 0x79, 0xc5, 0xc2}; - uint8_t bytesprops6[] = {0x33, 0x41, 0x94, 0xaf, 0xd}; - uint8_t bytesprops7[] = {0x2f, 0xa4, 0x58, 0xe8, 0x52, 0x39, 0x42, 0xf9, 0xad, 0x59, 0x6, 0x90, 0x6, 0x25, 0x8a, 0x61, 0x2, 0x3, 0xbe, 0x7d, 0xfa, 0x57, 0x55, 0xa9, 0xa4, 0xb7}; - uint8_t bytesprops8[] = {0x3b, 0x4a, 0x36}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28784}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19013}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3972}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4635}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6106}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8280}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10851}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29504}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24457}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15970}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops8}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3871}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10386}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27736}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15681}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15064}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5426}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19843}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12373}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22627}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 4}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 26784, topic, msg, props); + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29213, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "F\129\169\SYN\215A[Qx}\223\&7NE\181\250\249\236\208\GSL\217\176\183\235\&0\189\247u_", _pubPktID = 26784, _pubBody = "\176\&0\158\138\138]\220(B\154\&3\224jV\159v+\130", _pubProps = [PropServerReference "\171\NUL\255\181W#c)\213_\233\156l\214e7\223\159\SYN\138\186Na\129\231\200\222\187\SI",PropResponseInformation "9\247>''\242\222\229\ACK#n\DC4!\\\253\&4pA\238\158\195",PropCorrelationData "v\US\177M\242\DC2\171\229\194h\194\147\236KT\147",PropWildcardSubscriptionAvailable 249,PropAuthenticationMethod "\ACK\168\&7$\DEL\194wS\162",PropTopicAliasMaximum 28784,PropTopicAliasMaximum 19013,PropServerKeepAlive 3972,PropPayloadFormatIndicator 111,PropTopicAlias 4635,PropWillDelayInterval 6106,PropResponseTopic "!\248",PropSubscriptionIdentifier 16,PropResponseTopic "c4Pne\208y\197\194",PropContentType "3A\148\175\r",PropTopicAliasMaximum 8280,PropRequestResponseInformation 163,PropMaximumPacketSize 10851,PropReceiveMaximum 29504,PropMaximumPacketSize 24457,PropServerReference "/\164X\232R9B\249\173Y\ACK\144\ACK%\138a\STX\ETX\190}\250WU\169\164\183",PropServerKeepAlive 15970,PropAuthenticationMethod ";J6"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "V\156\142\176", _pubPktID = 29213, +// _pubBody = "\EM\FSK\190t\254o\168\200\&9\131(\254Z\138g\243jL|\137\220", _pubProps = [PropMaximumPacketSize +// 3871,PropMaximumQoS 160,PropMessageExpiryInterval 10386,PropRequestResponseInformation +// 71,PropRequestProblemInformation 55,PropRetainAvailable 35,PropReceiveMaximum 27736,PropMessageExpiryInterval +// 15681,PropMaximumQoS 67,PropAuthenticationData "{jG\fFZ\241\EM\239G\254",PropResponseInformation +// "TW\FS{r\"\SI\182\168\b\182X\154\207@\195\192\248\&92\185>\DC3`\243\SYN",PropReasonString +// "\139\171\245\232",PropMessageExpiryInterval 15064,PropPayloadFormatIndicator 3,PropRequestProblemInformation +// 14,PropSubscriptionIdentifierAvailable 35,PropWillDelayInterval 5426,PropRequestProblemInformation +// 178,PropContentType "\136\206\198#c\DEL\219",PropResponseInformation "3\n",PropRetainAvailable 192,PropTopicAlias +// 19843,PropMaximumPacketSize 12373,PropRetainAvailable 239,PropContentType +// "!\164\212\179e\SO$\195nqq\153a\252\246\234\194\245\188",PropResponseTopic "\152",PropWillDelayInterval +// 22627,PropRequestResponseInformation 4]} TEST(Publish5QCTest, Decode5) { -uint8_t pkt[] = {0x3d, 0xf5, 0x1, 0x0, 0x1e, 0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f, 0x68, 0xa0, 0xbf, 0x1, 0x1c, 0x0, 0x1d, 0xab, 0x0, 0xff, 0xb5, 0x57, 0x23, 0x63, 0x29, 0xd5, 0x5f, 0xe9, 0x9c, 0x6c, 0xd6, 0x65, 0x37, 0xdf, 0x9f, 0x16, 0x8a, 0xba, 0x4e, 0x61, 0x81, 0xe7, 0xc8, 0xde, 0xbb, 0xf, 0x1a, 0x0, 0x15, 0x39, 0xf7, 0x3e, 0x27, 0x27, 0xf2, 0xde, 0xe5, 0x6, 0x23, 0x6e, 0x14, 0x21, 0x5c, 0xfd, 0x34, 0x70, 0x41, 0xee, 0x9e, 0xc3, 0x9, 0x0, 0x10, 0x76, 0x1f, 0xb1, 0x4d, 0xf2, 0x12, 0xab, 0xe5, 0xc2, 0x68, 0xc2, 0x93, 0xec, 0x4b, 0x54, 0x93, 0x28, 0xf9, 0x15, 0x0, 0x9, 0x6, 0xa8, 0x37, 0x24, 0x7f, 0xc2, 0x77, 0x53, 0xa2, 0x22, 0x70, 0x70, 0x22, 0x4a, 0x45, 0x13, 0xf, 0x84, 0x1, 0x6f, 0x23, 0x12, 0x1b, 0x18, 0x0, 0x0, 0x17, 0xda, 0x8, 0x0, 0x2, 0x21, 0xf8, 0xb, 0x10, 0x8, 0x0, 0x9, 0x63, 0x34, 0x50, 0x6e, 0x65, 0xd0, 0x79, 0xc5, 0xc2, 0x3, 0x0, 0x5, 0x33, 0x41, 0x94, 0xaf, 0xd, 0x22, 0x20, 0x58, 0x19, 0xa3, 0x27, 0x0, 0x0, 0x2a, 0x63, 0x21, 0x73, 0x40, 0x27, 0x0, 0x0, 0x5f, 0x89, 0x1c, 0x0, 0x1a, 0x2f, 0xa4, 0x58, 0xe8, 0x52, 0x39, 0x42, 0xf9, 0xad, 0x59, 0x6, 0x90, 0x6, 0x25, 0x8a, 0x61, 0x2, 0x3, 0xbe, 0x7d, 0xfa, 0x57, 0x55, 0xa9, 0xa4, 0xb7, 0x13, 0x3e, 0x62, 0x15, 0x0, 0x3, 0x3b, 0x4a, 0x36, 0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x46, 0x81, 0xa9, 0x16, 0xd7, 0x41, 0x5b, 0x51, 0x78, 0x7d, 0xdf, 0x37, 0x4e, 0x45, 0xb5, 0xfa, 0xf9, 0xec, 0xd0, 0x1d, 0x4c, 0xd9, 0xb0, 0xb7, 0xeb, 0x30, 0xbd, 0xf7, 0x75, 0x5f}; - lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb0, 0x30, 0x9e, 0x8a, 0x8a, 0x5d, 0xdc, 0x28, 0x42, 0x9a, 0x33, 0xe0, 0x6a, 0x56, 0x9f, 0x76, 0x2b, 0x82}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 26784); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); -EXPECT_EQ(msg.payload_len, 18); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x35, 0xbc, 0x1, 0x0, 0x4, 0x56, 0x9c, 0x8e, 0xb0, 0x72, 0x1d, 0x9c, 0x1, 0x27, 0x0, 0x0, + 0xf, 0x1f, 0x24, 0xa0, 0x2, 0x0, 0x0, 0x28, 0x92, 0x19, 0x47, 0x17, 0x37, 0x25, 0x23, 0x21, + 0x6c, 0x58, 0x2, 0x0, 0x0, 0x3d, 0x41, 0x24, 0x43, 0x16, 0x0, 0xb, 0x7b, 0x6a, 0x47, 0xc, + 0x46, 0x5a, 0xf1, 0x19, 0xef, 0x47, 0xfe, 0x1a, 0x0, 0x1a, 0x54, 0x57, 0x1c, 0x7b, 0x72, 0x22, + 0xf, 0xb6, 0xa8, 0x8, 0xb6, 0x58, 0x9a, 0xcf, 0x40, 0xc3, 0xc0, 0xf8, 0x39, 0x32, 0xb9, 0x3e, + 0x13, 0x60, 0xf3, 0x16, 0x1f, 0x0, 0x4, 0x8b, 0xab, 0xf5, 0xe8, 0x2, 0x0, 0x0, 0x3a, 0xd8, + 0x1, 0x3, 0x17, 0xe, 0x29, 0x23, 0x18, 0x0, 0x0, 0x15, 0x32, 0x17, 0xb2, 0x3, 0x0, 0x7, + 0x88, 0xce, 0xc6, 0x23, 0x63, 0x7f, 0xdb, 0x1a, 0x0, 0x2, 0x33, 0xa, 0x25, 0xc0, 0x23, 0x4d, + 0x83, 0x27, 0x0, 0x0, 0x30, 0x55, 0x25, 0xef, 0x3, 0x0, 0x13, 0x21, 0xa4, 0xd4, 0xb3, 0x65, + 0xe, 0x24, 0xc3, 0x6e, 0x71, 0x71, 0x99, 0x61, 0xfc, 0xf6, 0xea, 0xc2, 0xf5, 0xbc, 0x8, 0x0, + 0x1, 0x98, 0x18, 0x0, 0x0, 0x58, 0x63, 0x19, 0x4, 0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, 0x6f, + 0xa8, 0xc8, 0x39, 0x83, 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x56, 0x9c, 0x8e, 0xb0}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, 0x6f, 0xa8, 0xc8, 0x39, 0x83, + 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 29213); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "j-w\135im\135", _pubPktID = 15185, +// _pubBody = "\178\183W\163D\179", _pubProps = [PropResponseTopic +// "\FS\n\NULY#r\132\&4\DEL%\206{/7V=\ETB\195W\192,\229\135\162\ETB\250\175\194\170",PropServerKeepAlive +// 4458,PropSharedSubscriptionAvailable 33,PropSessionExpiryInterval 14022,PropSubscriptionIdentifierAvailable +// 239,PropServerReference "\164\228\204[\165\224\229)\SYN66\195{\211\227u\EM\249",PropMessageExpiryInterval 808]} +TEST(Publish5QCTest, Encode6) { + uint8_t pkt[] = {0x35, 0x58, 0x0, 0x7, 0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87, 0x3b, 0x51, 0x46, 0x8, + 0x0, 0x1d, 0x1c, 0xa, 0x0, 0x59, 0x23, 0x72, 0x84, 0x34, 0x7f, 0x25, 0xce, 0x7b, 0x2f, + 0x37, 0x56, 0x3d, 0x17, 0xc3, 0x57, 0xc0, 0x2c, 0xe5, 0x87, 0xa2, 0x17, 0xfa, 0xaf, 0xc2, + 0xaa, 0x13, 0x11, 0x6a, 0x2a, 0x21, 0x11, 0x0, 0x0, 0x36, 0xc6, 0x29, 0xef, 0x1c, 0x0, + 0x12, 0xa4, 0xe4, 0xcc, 0x5b, 0xa5, 0xe0, 0xe5, 0x29, 0x16, 0x36, 0x36, 0xc3, 0x7b, 0xd3, + 0xe3, 0x75, 0x19, 0xf9, 0x2, 0x0, 0x0, 0x3, 0x28, 0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + uint8_t topic_bytes[] = {0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 6; -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "IP\\2\223\164P[u\SI\DLEh\171x\188\185\177Q#\163v7L\224Y;5", _pubPktID = 14257, _pubBody = "\215Vs\129\239\168\165b\145\208\232`\245", _pubProps = [PropSessionExpiryInterval 4222,PropSubscriptionIdentifierAvailable 237,PropReasonString "6\175G3d\SO*\237\171\SO\234\f*`\253\166\201\&2\GS\204H\250\t\DLE\239",PropCorrelationData "\228",PropResponseTopic "\198$\r\206\225\242\139<\249",PropResponseInformation "\aO",PropUserProperty "\129\ETXH\149M\197\153>\237T\173\192" "\249\130.\189\196\248\154\154\163G",PropAssignedClientIdentifier "\215\161\223\nAr\172a#\252`!\188\208g\DEL~\f\RSx",PropReceiveMaximum 15611,PropAuthenticationMethod "\172\238\233\&0\220|E.3\250s8D-A%\251\&08\FS\215\201\136\186\142?",PropTopicAlias 27987,PropResponseInformation "n\142\194\\\150\183\193K\USk<\"\239\195",PropAssignedClientIdentifier "\150\134\239\143\183b&\198^1_\DEL\136\242\v\246a\fH\175\208\RS\198\141\176\"N=\140",PropServerKeepAlive 15578,PropTopicAliasMaximum 1748,PropContentType "r\ETX\t\ETB\bu.I\161\128K6\184d\138\"\SI;\b\184\"",PropContentType "1-\247a\147\147\ESC\183\&0\221y|7\SI(W\239n?",PropPayloadFormatIndicator 60,PropSubscriptionIdentifier 25,PropPayloadFormatIndicator 36,PropUserProperty "\"-m\172=\230\237\245\206\162\182\177\182\GS\165\250\190\141\252\168\173" "1",PropRequestResponseInformation 106,PropSubscriptionIdentifier 25,PropSubscriptionIdentifier 23]} -TEST(Publish5QCTest, Encode6) { -uint8_t pkt[] = {0x35, 0xc7, 0x2, 0x0, 0x1b, 0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35, 0x37, 0xb1, 0x99, 0x2, 0x11, 0x0, 0x0, 0x10, 0x7e, 0x29, 0xed, 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6, 0xd4, 0x3, 0x0, 0x15, 0x72, 0x3, 0x9, 0x17, 0x8, 0x75, 0x2e, 0x49, 0xa1, 0x80, 0x4b, 0x36, 0xb8, 0x64, 0x8a, 0x22, 0xf, 0x3b, 0x8, 0xb8, 0x22, 0x3, 0x0, 0x13, 0x31, 0x2d, 0xf7, 0x61, 0x93, 0x93, 0x1b, 0xb7, 0x30, 0xdd, 0x79, 0x7c, 0x37, 0xf, 0x28, 0x57, 0xef, 0x6e, 0x3f, 0x1, 0x3c, 0xb, 0x19, 0x1, 0x24, 0x26, 0x0, 0x15, 0x22, 0x2d, 0x6d, 0xac, 0x3d, 0xe6, 0xed, 0xf5, 0xce, 0xa2, 0xb6, 0xb1, 0xb6, 0x1d, 0xa5, 0xfa, 0xbe, 0x8d, 0xfc, 0xa8, 0xad, 0x0, 0x1, 0x31, 0x19, 0x6a, 0xb, 0x19, 0xb, 0x17, 0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; - uint8_t topic_bytes[] = {0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t bytesprops0[] = {0x1c, 0xa, 0x0, 0x59, 0x23, 0x72, 0x84, 0x34, 0x7f, 0x25, 0xce, 0x7b, 0x2f, 0x37, 0x56, + 0x3d, 0x17, 0xc3, 0x57, 0xc0, 0x2c, 0xe5, 0x87, 0xa2, 0x17, 0xfa, 0xaf, 0xc2, 0xaa}; + uint8_t bytesprops1[] = {0xa4, 0xe4, 0xcc, 0x5b, 0xa5, 0xe0, 0xe5, 0x29, 0x16, + 0x36, 0x36, 0xc3, 0x7b, 0xd3, 0xe3, 0x75, 0x19, 0xf9}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 13; - - uint8_t bytesprops0[] = {0x36, 0xaf, 0x47, 0x33, 0x64, 0xe, 0x2a, 0xed, 0xab, 0xe, 0xea, 0xc, 0x2a, 0x60, 0xfd, 0xa6, 0xc9, 0x32, 0x1d, 0xcc, 0x48, 0xfa, 0x9, 0x10, 0xef}; - uint8_t bytesprops1[] = {0xe4}; - uint8_t bytesprops2[] = {0xc6, 0x24, 0xd, 0xce, 0xe1, 0xf2, 0x8b, 0x3c, 0xf9}; - uint8_t bytesprops3[] = {0x7, 0x4f}; - uint8_t bytesprops5[] = {0xf9, 0x82, 0x2e, 0xbd, 0xc4, 0xf8, 0x9a, 0x9a, 0xa3, 0x47}; - uint8_t bytesprops4[] = {0x81, 0x3, 0x48, 0x95, 0x4d, 0xc5, 0x99, 0x3e, 0xed, 0x54, 0xad, 0xc0}; - uint8_t bytesprops6[] = {0xd7, 0xa1, 0xdf, 0xa, 0x41, 0x72, 0xac, 0x61, 0x23, 0xfc, 0x60, 0x21, 0xbc, 0xd0, 0x67, 0x7f, 0x7e, 0xc, 0x1e, 0x78}; - uint8_t bytesprops7[] = {0xac, 0xee, 0xe9, 0x30, 0xdc, 0x7c, 0x45, 0x2e, 0x33, 0xfa, 0x73, 0x38, 0x44, 0x2d, 0x41, 0x25, 0xfb, 0x30, 0x38, 0x1c, 0xd7, 0xc9, 0x88, 0xba, 0x8e, 0x3f}; - uint8_t bytesprops8[] = {0x6e, 0x8e, 0xc2, 0x5c, 0x96, 0xb7, 0xc1, 0x4b, 0x1f, 0x6b, 0x3c, 0x22, 0xef, 0xc3}; - uint8_t bytesprops9[] = {0x96, 0x86, 0xef, 0x8f, 0xb7, 0x62, 0x26, 0xc6, 0x5e, 0x31, 0x5f, 0x7f, 0x88, 0xf2, 0xb, 0xf6, 0x61, 0xc, 0x48, 0xaf, 0xd0, 0x1e, 0xc6, 0x8d, 0xb0, 0x22, 0x4e, 0x3d, 0x8c}; - uint8_t bytesprops10[] = {0x72, 0x3, 0x9, 0x17, 0x8, 0x75, 0x2e, 0x49, 0xa1, 0x80, 0x4b, 0x36, 0xb8, 0x64, 0x8a, 0x22, 0xf, 0x3b, 0x8, 0xb8, 0x22}; - uint8_t bytesprops11[] = {0x31, 0x2d, 0xf7, 0x61, 0x93, 0x93, 0x1b, 0xb7, 0x30, 0xdd, 0x79, 0x7c, 0x37, 0xf, 0x28, 0x57, 0xef, 0x6e, 0x3f}; - uint8_t bytesprops13[] = {0x31}; - uint8_t bytesprops12[] = {0x22, 0x2d, 0x6d, 0xac, 0x3d, 0xe6, 0xed, 0xf5, 0xce, 0xa2, 0xb6, 0xb1, 0xb6, 0x1d, 0xa5, 0xfa, 0xbe, 0x8d, 0xfc, 0xa8, 0xad}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4222}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={12, (char*)&bytesprops4}, .v={10, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15611}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27987}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15578}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1748}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={21, (char*)&bytesprops12}, .v={1, (char*)&bytesprops13}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4458}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14022}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 808}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14257, topic, msg, props); + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15185, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "IP\\2\223\164P[u\SI\DLEh\171x\188\185\177Q#\163v7L\224Y;5", _pubPktID = 14257, _pubBody = "\215Vs\129\239\168\165b\145\208\232`\245", _pubProps = [PropSessionExpiryInterval 4222,PropSubscriptionIdentifierAvailable 237,PropReasonString "6\175G3d\SO*\237\171\SO\234\f*`\253\166\201\&2\GS\204H\250\t\DLE\239",PropCorrelationData "\228",PropResponseTopic "\198$\r\206\225\242\139<\249",PropResponseInformation "\aO",PropUserProperty "\129\ETXH\149M\197\153>\237T\173\192" "\249\130.\189\196\248\154\154\163G",PropAssignedClientIdentifier "\215\161\223\nAr\172a#\252`!\188\208g\DEL~\f\RSx",PropReceiveMaximum 15611,PropAuthenticationMethod "\172\238\233\&0\220|E.3\250s8D-A%\251\&08\FS\215\201\136\186\142?",PropTopicAlias 27987,PropResponseInformation "n\142\194\\\150\183\193K\USk<\"\239\195",PropAssignedClientIdentifier "\150\134\239\143\183b&\198^1_\DEL\136\242\v\246a\fH\175\208\RS\198\141\176\"N=\140",PropServerKeepAlive 15578,PropTopicAliasMaximum 1748,PropContentType "r\ETX\t\ETB\bu.I\161\128K6\184d\138\"\SI;\b\184\"",PropContentType "1-\247a\147\147\ESC\183\&0\221y|7\SI(W\239n?",PropPayloadFormatIndicator 60,PropSubscriptionIdentifier 25,PropPayloadFormatIndicator 36,PropUserProperty "\"-m\172=\230\237\245\206\162\182\177\182\GS\165\250\190\141\252\168\173" "1",PropRequestResponseInformation 106,PropSubscriptionIdentifier 25,PropSubscriptionIdentifier 23]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "j-w\135im\135", _pubPktID = 15185, +// _pubBody = "\178\183W\163D\179", _pubProps = [PropResponseTopic +// "\FS\n\NULY#r\132\&4\DEL%\206{/7V=\ETB\195W\192,\229\135\162\ETB\250\175\194\170",PropServerKeepAlive +// 4458,PropSharedSubscriptionAvailable 33,PropSessionExpiryInterval 14022,PropSubscriptionIdentifierAvailable +// 239,PropServerReference "\164\228\204[\165\224\229)\SYN66\195{\211\227u\EM\249",PropMessageExpiryInterval 808]} TEST(Publish5QCTest, Decode6) { -uint8_t pkt[] = {0x35, 0xc7, 0x2, 0x0, 0x1b, 0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35, 0x37, 0xb1, 0x99, 0x2, 0x11, 0x0, 0x0, 0x10, 0x7e, 0x29, 0xed, 0x1f, 0x0, 0x19, 0x36, 0xaf, 0x47, 0x33, 0x64, 0xe, 0x2a, 0xed, 0xab, 0xe, 0xea, 0xc, 0x2a, 0x60, 0xfd, 0xa6, 0xc9, 0x32, 0x1d, 0xcc, 0x48, 0xfa, 0x9, 0x10, 0xef, 0x9, 0x0, 0x1, 0xe4, 0x8, 0x0, 0x9, 0xc6, 0x24, 0xd, 0xce, 0xe1, 0xf2, 0x8b, 0x3c, 0xf9, 0x1a, 0x0, 0x2, 0x7, 0x4f, 0x26, 0x0, 0xc, 0x81, 0x3, 0x48, 0x95, 0x4d, 0xc5, 0x99, 0x3e, 0xed, 0x54, 0xad, 0xc0, 0x0, 0xa, 0xf9, 0x82, 0x2e, 0xbd, 0xc4, 0xf8, 0x9a, 0x9a, 0xa3, 0x47, 0x12, 0x0, 0x14, 0xd7, 0xa1, 0xdf, 0xa, 0x41, 0x72, 0xac, 0x61, 0x23, 0xfc, 0x60, 0x21, 0xbc, 0xd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0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x49, 0x50, 0x5c, 0x32, 0xdf, 0xa4, 0x50, 0x5b, 0x75, 0xf, 0x10, 0x68, 0xab, 0x78, 0xbc, 0xb9, 0xb1, 0x51, 0x23, 0xa3, 0x76, 0x37, 0x4c, 0xe0, 0x59, 0x3b, 0x35}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd7, 0x56, 0x73, 0x81, 0xef, 0xa8, 0xa5, 0x62, 0x91, 0xd0, 0xe8, 0x60, 0xf5}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 14257); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); -EXPECT_EQ(msg.payload_len, 13); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x35, 0x58, 0x0, 0x7, 0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87, 0x3b, 0x51, 0x46, 0x8, + 0x0, 0x1d, 0x1c, 0xa, 0x0, 0x59, 0x23, 0x72, 0x84, 0x34, 0x7f, 0x25, 0xce, 0x7b, 0x2f, + 0x37, 0x56, 0x3d, 0x17, 0xc3, 0x57, 0xc0, 0x2c, 0xe5, 0x87, 0xa2, 0x17, 0xfa, 0xaf, 0xc2, + 0xaa, 0x13, 0x11, 0x6a, 0x2a, 0x21, 0x11, 0x0, 0x0, 0x36, 0xc6, 0x29, 0xef, 0x1c, 0x0, + 0x12, 0xa4, 0xe4, 0xcc, 0x5b, 0xa5, 0xe0, 0xe5, 0x29, 0x16, 0x36, 0x36, 0xc3, 0x7b, 0xd3, + 0xe3, 0x75, 0x19, 0xf9, 0x2, 0x0, 0x0, 0x3, 0x28, 0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "6\RS\235\193R\DEL\172\233\219\ETX\209a8\243\RS\229\&2a", _pubPktID = 10501, _pubBody = "*K\219};J\192L&\150k\230#\253#\163\207\128\170\174\GS{\t", _pubProps = [PropMessageExpiryInterval 20953,PropRequestProblemInformation 35,PropReasonString "\239\&8\203",PropPayloadFormatIndicator 223,PropSharedSubscriptionAvailable 171,PropReasonString "\166o\v3\139\232g;\f\SI\"\147[Rr\DC2 p\243\ACK\r\206<6",PropWillDelayInterval 5646,PropMessageExpiryInterval 2935,PropResponseInformation "\ACKD6\229=@",PropContentType "\194",PropMessageExpiryInterval 3137,PropRetainAvailable 40,PropMaximumPacketSize 2855,PropReasonString "m8\255\n>\131Q\132-=\228\254\v\228\SYN",PropTopicAliasMaximum 818,PropSessionExpiryInterval 7249,PropSubscriptionIdentifier 21,PropServerKeepAlive 32278,PropTopicAlias 21281,PropResponseTopic "\211[",PropReasonString "~\175\237->\ENQ\146\144\202\223\143\148\201\197\ESC",PropRequestResponseInformation 158,PropTopicAliasMaximum 9622,PropSubscriptionIdentifierAvailable 9,PropMessageExpiryInterval 3827,PropReasonString "I\190\181\231\SYN\211;\NAK\245\&9\223\DC1\NAKR\148\197\223X\CANGp",PropAuthenticationMethod "\132\147\148\166\SYN\ACK\235\179\183\STX\137\193\DC3\136U\130\243\RS\162\233\165d",PropAuthenticationMethod "\f\249Y\216\201\209\248\&5\232\212\&4-\165d\202\145\&3&}\216\SUB",PropReasonString "\185B\160\232\167#\190j\177\157^\182\198\196_\192\184\207\246;\148B\215\208\137\179\b\204a"]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 15185); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129\166\ACK\241", _pubPktID = 26446, +// _pubBody = "h'uL\n\225\221gp\182{\140\DC4\136\151c\170\191\r|\214\197\&7", _pubProps = [PropPayloadFormatIndicator +// 170,PropCorrelationData "&Gz\228\136\t\SUBx!V_@\228",PropAuthenticationMethod "\161e",PropRetainAvailable +// 105,PropMessageExpiryInterval 22688]} TEST(Publish5QCTest, Encode7) { -uint8_t pkt[] = {0x3d, 0xac, 0x2, 0x0, 0x12, 0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61, 0x29, 0x5, 0xfd, 0x1, 0x2, 0x0, 0x0, 0x51, 0xd9, 0x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0x0, 0x15, 0xc, 0xf9, 0x59, 0xd8, 0xc9, 0xd1, 0xf8, 0x35, 0xe8, 0xd4, 0x34, 0x2d, 0xa5, 0x64, 0xca, 0x91, 0x33, 0x26, 0x7d, 0xd8, 0x1a, 0x1f, 0x0, 0x1d, 0xb9, 0x42, 0xa0, 0xe8, 0xa7, 0x23, 0xbe, 0x6a, 0xb1, 0x9d, 0x5e, 0xb6, 0xc6, 0xc4, 0x5f, 0xc0, 0xb8, 0xcf, 0xf6, 0x3b, 0x94, 0x42, 0xd7, 0xd0, 0x89, 0xb3, 0x8, 0xcc, 0x61, 0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; - uint8_t topic_bytes[] = {0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 23; - - uint8_t bytesprops0[] = {0xef, 0x38, 0xcb}; - uint8_t bytesprops1[] = {0xa6, 0x6f, 0xb, 0x33, 0x8b, 0xe8, 0x67, 0x3b, 0xc, 0xf, 0x22, 0x93, 0x5b, 0x52, 0x72, 0x12, 0x20, 0x70, 0xf3, 0x6, 0xd, 0xce, 0x3c, 0x36}; - uint8_t bytesprops2[] = {0x6, 0x44, 0x36, 0xe5, 0x3d, 0x40}; - uint8_t bytesprops3[] = {0xc2}; - uint8_t bytesprops4[] = {0x6d, 0x38, 0xff, 0xa, 0x3e, 0x83, 0x51, 0x84, 0x2d, 0x3d, 0xe4, 0xfe, 0xb, 0xe4, 0x16}; - uint8_t bytesprops5[] = {0xd3, 0x5b}; - uint8_t bytesprops6[] = {0x7e, 0xaf, 0xed, 0x2d, 0x3e, 0x5, 0x92, 0x90, 0xca, 0xdf, 0x8f, 0x94, 0xc9, 0xc5, 0x1b}; - uint8_t bytesprops7[] = {0x49, 0xbe, 0xb5, 0xe7, 0x16, 0xd3, 0x3b, 0x15, 0xf5, 0x39, 0xdf, 0x11, 0x15, 0x52, 0x94, 0xc5, 0xdf, 0x58, 0x18, 0x47, 0x70}; - uint8_t bytesprops8[] = {0x84, 0x93, 0x94, 0xa6, 0x16, 0x6, 0xeb, 0xb3, 0xb7, 0x2, 0x89, 0xc1, 0x13, 0x88, 0x55, 0x82, 0xf3, 0x1e, 0xa2, 0xe9, 0xa5, 0x64}; - uint8_t bytesprops9[] = {0xc, 0xf9, 0x59, 0xd8, 0xc9, 0xd1, 0xf8, 0x35, 0xe8, 0xd4, 0x34, 0x2d, 0xa5, 0x64, 0xca, 0x91, 0x33, 0x26, 0x7d, 0xd8, 0x1a}; - uint8_t bytesprops10[] = {0xb9, 0x42, 0xa0, 0xe8, 0xa7, 0x23, 0xbe, 0x6a, 0xb1, 0x9d, 0x5e, 0xb6, 0xc6, 0xc4, 0x5f, 0xc0, 0xb8, 0xcf, 0xf6, 0x3b, 0x94, 0x42, 0xd7, 0xd0, 0x89, 0xb3, 0x8, 0xcc, 0x61}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20953}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5646}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2935}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3137}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2855}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 818}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7249}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32278}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21281}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9622}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3827}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops10}}}, + uint8_t pkt[] = {0x3d, 0x3e, 0x0, 0x4, 0x81, 0xa6, 0x6, 0xf1, 0x67, 0x4e, 0x1e, 0x1, 0xaa, 0x9, 0x0, 0xd, + 0x26, 0x47, 0x7a, 0xe4, 0x88, 0x9, 0x1a, 0x78, 0x21, 0x56, 0x5f, 0x40, 0xe4, 0x15, 0x0, 0x2, + 0xa1, 0x65, 0x25, 0x69, 0x2, 0x0, 0x0, 0x58, 0xa0, 0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, + 0x67, 0x70, 0xb6, 0x7b, 0x8c, 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + uint8_t topic_bytes[] = {0x81, 0xa6, 0x6, 0xf1}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, 0x67, 0x70, 0xb6, 0x7b, 0x8c, + 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 23; + + uint8_t bytesprops0[] = {0x26, 0x47, 0x7a, 0xe4, 0x88, 0x9, 0x1a, 0x78, 0x21, 0x56, 0x5f, 0x40, 0xe4}; + uint8_t bytesprops1[] = {0xa1, 0x65}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22688}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 10501, topic, msg, props); + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 26446, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "6\RS\235\193R\DEL\172\233\219\ETX\209a8\243\RS\229\&2a", _pubPktID = 10501, _pubBody = "*K\219};J\192L&\150k\230#\253#\163\207\128\170\174\GS{\t", _pubProps = [PropMessageExpiryInterval 20953,PropRequestProblemInformation 35,PropReasonString "\239\&8\203",PropPayloadFormatIndicator 223,PropSharedSubscriptionAvailable 171,PropReasonString "\166o\v3\139\232g;\f\SI\"\147[Rr\DC2 p\243\ACK\r\206<6",PropWillDelayInterval 5646,PropMessageExpiryInterval 2935,PropResponseInformation "\ACKD6\229=@",PropContentType "\194",PropMessageExpiryInterval 3137,PropRetainAvailable 40,PropMaximumPacketSize 2855,PropReasonString "m8\255\n>\131Q\132-=\228\254\v\228\SYN",PropTopicAliasMaximum 818,PropSessionExpiryInterval 7249,PropSubscriptionIdentifier 21,PropServerKeepAlive 32278,PropTopicAlias 21281,PropResponseTopic "\211[",PropReasonString "~\175\237->\ENQ\146\144\202\223\143\148\201\197\ESC",PropRequestResponseInformation 158,PropTopicAliasMaximum 9622,PropSubscriptionIdentifierAvailable 9,PropMessageExpiryInterval 3827,PropReasonString "I\190\181\231\SYN\211;\NAK\245\&9\223\DC1\NAKR\148\197\223X\CANGp",PropAuthenticationMethod "\132\147\148\166\SYN\ACK\235\179\183\STX\137\193\DC3\136U\130\243\RS\162\233\165d",PropAuthenticationMethod "\f\249Y\216\201\209\248\&5\232\212\&4-\165d\202\145\&3&}\216\SUB",PropReasonString "\185B\160\232\167#\190j\177\157^\182\198\196_\192\184\207\246;\148B\215\208\137\179\b\204a"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129\166\ACK\241", _pubPktID = 26446, +// _pubBody = "h'uL\n\225\221gp\182{\140\DC4\136\151c\170\191\r|\214\197\&7", _pubProps = [PropPayloadFormatIndicator +// 170,PropCorrelationData "&Gz\228\136\t\SUBx!V_@\228",PropAuthenticationMethod "\161e",PropRetainAvailable +// 105,PropMessageExpiryInterval 22688]} TEST(Publish5QCTest, Decode7) { -uint8_t pkt[] = {0x3d, 0xac, 0x2, 0x0, 0x12, 0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61, 0x29, 0x5, 0xfd, 0x1, 0x2, 0x0, 0x0, 0x51, 0xd9, 0x17, 0x23, 0x1f, 0x0, 0x3, 0xef, 0x38, 0xcb, 0x1, 0xdf, 0x2a, 0xab, 0x1f, 0x0, 0x18, 0xa6, 0x6f, 0xb, 0x33, 0x8b, 0xe8, 0x67, 0x3b, 0xc, 0xf, 0x22, 0x93, 0x5b, 0x52, 0x72, 0x12, 0x20, 0x70, 0xf3, 0x6, 0xd, 0xce, 0x3c, 0x36, 0x18, 0x0, 0x0, 0x16, 0xe, 0x2, 0x0, 0x0, 0xb, 0x77, 0x1a, 0x0, 0x6, 0x6, 0x44, 0x36, 0xe5, 0x3d, 0x40, 0x3, 0x0, 0x1, 0xc2, 0x2, 0x0, 0x0, 0xc, 0x41, 0x25, 0x28, 0x27, 0x0, 0x0, 0xb, 0x27, 0x1f, 0x0, 0xf, 0x6d, 0x38, 0xff, 0xa, 0x3e, 0x83, 0x51, 0x84, 0x2d, 0x3d, 0xe4, 0x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qtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x36, 0x1e, 0xeb, 0xc1, 0x52, 0x7f, 0xac, 0xe9, 0xdb, 0x3, 0xd1, 0x61, 0x38, 0xf3, 0x1e, 0xe5, 0x32, 0x61}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2a, 0x4b, 0xdb, 0x7d, 0x3b, 0x4a, 0xc0, 0x4c, 0x26, 0x96, 0x6b, 0xe6, 0x23, 0xfd, 0x23, 0xa3, 0xcf, 0x80, 0xaa, 0xae, 0x1d, 0x7b, 0x9}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 10501); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); -EXPECT_EQ(msg.payload_len, 23); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x3d, 0x3e, 0x0, 0x4, 0x81, 0xa6, 0x6, 0xf1, 0x67, 0x4e, 0x1e, 0x1, 0xaa, 0x9, 0x0, 0xd, + 0x26, 0x47, 0x7a, 0xe4, 0x88, 0x9, 0x1a, 0x78, 0x21, 0x56, 0x5f, 0x40, 0xe4, 0x15, 0x0, 0x2, + 0xa1, 0x65, 0x25, 0x69, 0x2, 0x0, 0x0, 0x58, 0xa0, 0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, + 0x67, 0x70, 0xb6, 0x7b, 0x8c, 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x81, 0xa6, 0x6, 0xf1}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, 0x67, 0x70, 0xb6, 0x7b, 0x8c, + 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 26446); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "}\250\132\234S\200EV\164\175\218\237D", _pubPktID = 25658, _pubBody = +// "\DLE\DC3\242\235C\134\216h\196\ETB\255\169\164\222", _pubProps = [PropResponseTopic +// "\164\ETX\255\SYN\169a\EM\237\135\219?\183(\DLE2i\254\191?s\217\SI\229\243&\130",PropMessageExpiryInterval +// 16431,PropReasonString "\218\232\&8_\216\202'@\227\ACK|\252\NUL\ACK\235",PropRetainAvailable +// 227,PropSessionExpiryInterval 1125,PropCorrelationData +// "\188\180-\146\252\250Y\134|\255\169\224\228\226\&8\169\195\229o",PropServerKeepAlive 31922,PropReceiveMaximum +// 13953,PropResponseTopic "*}",PropReceiveMaximum 10205,PropRequestProblemInformation +// 46,PropWildcardSubscriptionAvailable 199,PropServerKeepAlive 17597,PropMaximumQoS 236,PropServerReference +// "\ENQI\177\187%LN\EM,\168d\215\245\220\170\203\247\DC2~E\SI\139\ACK\RS\189d\183;9",PropRetainAvailable +// 170,PropPayloadFormatIndicator 164,PropServerKeepAlive 13334,PropServerKeepAlive 20469,PropRequestResponseInformation +// 170,PropServerKeepAlive 964,PropSharedSubscriptionAvailable 117,PropAssignedClientIdentifier +// "\244=\"\141i\204\DC1\ENQ\r\DLE\ESC\rqV\251\DC1\188\213i\148q",PropTopicAliasMaximum 28761]} +TEST(Publish5QCTest, Encode8) { + uint8_t pkt[] = {0x3d, 0xd5, 0x1, 0x0, 0xd, 0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, + 0x44, 0x64, 0x3a, 0xb4, 0x1, 0x8, 0x0, 0x1a, 0xa4, 0x3, 0xff, 0x16, 0xa9, 0x61, 0x19, 0xed, 0x87, + 0xdb, 0x3f, 0xb7, 0x28, 0x10, 0x32, 0x69, 0xfe, 0xbf, 0x3f, 0x73, 0xd9, 0xf, 0xe5, 0xf3, 0x26, 0x82, + 0x2, 0x0, 0x0, 0x40, 0x2f, 0x1f, 0x0, 0xf, 0xda, 0xe8, 0x38, 0x5f, 0xd8, 0xca, 0x27, 0x40, 0xe3, + 0x6, 0x7c, 0xfc, 0x0, 0x6, 0xeb, 0x25, 0xe3, 0x11, 0x0, 0x0, 0x4, 0x65, 0x9, 0x0, 0x13, 0xbc, + 0xb4, 0x2d, 0x92, 0xfc, 0xfa, 0x59, 0x86, 0x7c, 0xff, 0xa9, 0xe0, 0xe4, 0xe2, 0x38, 0xa9, 0xc3, 0xe5, + 0x6f, 0x13, 0x7c, 0xb2, 0x21, 0x36, 0x81, 0x8, 0x0, 0x2, 0x2a, 0x7d, 0x21, 0x27, 0xdd, 0x17, 0x2e, + 0x28, 0xc7, 0x13, 0x44, 0xbd, 0x24, 0xec, 0x1c, 0x0, 0x1d, 0x5, 0x49, 0xb1, 0xbb, 0x25, 0x4c, 0x4e, + 0x19, 0x2c, 0xa8, 0x64, 0xd7, 0xf5, 0xdc, 0xaa, 0xcb, 0xf7, 0x12, 0x7e, 0x45, 0xf, 0x8b, 0x6, 0x1e, + 0xbd, 0x64, 0xb7, 0x3b, 0x39, 0x25, 0xaa, 0x1, 0xa4, 0x13, 0x34, 0x16, 0x13, 0x4f, 0xf5, 0x19, 0xaa, + 0x13, 0x3, 0xc4, 0x2a, 0x75, 0x12, 0x0, 0x15, 0xf4, 0x3d, 0x22, 0x8d, 0x69, 0xcc, 0x11, 0x5, 0xd, + 0x10, 0x1b, 0xd, 0x71, 0x56, 0xfb, 0x11, 0xbc, 0xd5, 0x69, 0x94, 0x71, 0x22, 0x70, 0x59, 0x10, 0x13, + 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + uint8_t topic_bytes[] = {0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; + + uint8_t bytesprops0[] = {0xa4, 0x3, 0xff, 0x16, 0xa9, 0x61, 0x19, 0xed, 0x87, 0xdb, 0x3f, 0xb7, 0x28, + 0x10, 0x32, 0x69, 0xfe, 0xbf, 0x3f, 0x73, 0xd9, 0xf, 0xe5, 0xf3, 0x26, 0x82}; + uint8_t bytesprops1[] = {0xda, 0xe8, 0x38, 0x5f, 0xd8, 0xca, 0x27, 0x40, 0xe3, 0x6, 0x7c, 0xfc, 0x0, 0x6, 0xeb}; + uint8_t bytesprops2[] = {0xbc, 0xb4, 0x2d, 0x92, 0xfc, 0xfa, 0x59, 0x86, 0x7c, 0xff, + 0xa9, 0xe0, 0xe4, 0xe2, 0x38, 0xa9, 0xc3, 0xe5, 0x6f}; + uint8_t bytesprops3[] = {0x2a, 0x7d}; + uint8_t bytesprops4[] = {0x5, 0x49, 0xb1, 0xbb, 0x25, 0x4c, 0x4e, 0x19, 0x2c, 0xa8, 0x64, 0xd7, 0xf5, 0xdc, 0xaa, + 0xcb, 0xf7, 0x12, 0x7e, 0x45, 0xf, 0x8b, 0x6, 0x1e, 0xbd, 0x64, 0xb7, 0x3b, 0x39}; + uint8_t bytesprops5[] = {0xf4, 0x3d, 0x22, 0x8d, 0x69, 0xcc, 0x11, 0x5, 0xd, 0x10, 0x1b, + 0xd, 0x71, 0x56, 0xfb, 0x11, 0xbc, 0xd5, 0x69, 0x94, 0x71}; -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\129\171\&3\ETBSN", _pubPktID = 5903, _pubBody = "zPg\212~f\130\171\232\241P\212\ENQ'\234'@\v\177;s\157z*\DC2{\148\&6|", _pubProps = [PropServerKeepAlive 25004,PropRequestProblemInformation 146,PropTopicAlias 13436,PropServerKeepAlive 31880,PropPayloadFormatIndicator 16,PropMessageExpiryInterval 18537,PropAuthenticationData "",PropReasonString "\134\128\129\246\142\ETX]x",PropSessionExpiryInterval 1893,PropMaximumQoS 117,PropMaximumPacketSize 16084,PropTopicAlias 17664,PropTopicAlias 2670,PropServerKeepAlive 6931,PropTopicAliasMaximum 10342,PropUserProperty "\DC4\f{9\243\233\247\196" "\179\ETB\168\&8\STXk\158\SUB\\\132",PropMessageExpiryInterval 14066,PropUserProperty "" "\SO\220\&3oO>\198i\ENQv\147",PropAssignedClientIdentifier "\EMd\138\217\173\154\ETX\145\DC2\173\220\214",PropServerKeepAlive 19246,PropMaximumPacketSize 1458,PropTopicAliasMaximum 9667,PropContentType "I\139L?\197OGv3\t*, `N\138\244\206k\211\\"]} -TEST(Publish5QCTest, Encode8) { -uint8_t pkt[] = {0x3c, 0xbf, 0x1, 0x0, 0x6, 0x81, 0xab, 0x33, 0x17, 0x53, 0x4e, 0x17, 0xf, 0x96, 0x1, 0x13, 0x61, 0xac, 0x17, 0x92, 0x23, 0x34, 0x7c, 0x13, 0x7c, 0x88, 0x1, 0x10, 0x2, 0x0, 0x0, 0x48, 0x69, 0x16, 0x0, 0x0, 0x1f, 0x0, 0x8, 0x86, 0x80, 0x81, 0xf6, 0x8e, 0x3, 0x5d, 0x78, 0x11, 0x0, 0x0, 0x7, 0x65, 0x24, 0x75, 0x27, 0x0, 0x0, 0x3e, 0xd4, 0x23, 0x45, 0x0, 0x23, 0xa, 0x6e, 0x13, 0x1b, 0x13, 0x22, 0x28, 0x66, 0x26, 0x0, 0x8, 0x14, 0xc, 0x7b, 0x39, 0xf3, 0xe9, 0xf7, 0xc4, 0x0, 0xa, 0xb3, 0x17, 0xa8, 0x38, 0x2, 0x6b, 0x9e, 0x1a, 0x5c, 0x84, 0x2, 0x0, 0x0, 0x36, 0xf2, 0x26, 0x0, 0x0, 0x0, 0xb, 0xe, 0xdc, 0x33, 0x6f, 0x4f, 0x3e, 0xc6, 0x69, 0x5, 0x76, 0x93, 0x12, 0x0, 0xc, 0x19, 0x64, 0x8a, 0xd9, 0xad, 0x9a, 0x3, 0x91, 0x12, 0xad, 0xdc, 0xd6, 0x13, 0x4b, 0x2e, 0x27, 0x0, 0x0, 0x5, 0xb2, 0x22, 0x25, 0xc3, 0x3, 0x0, 0x15, 0x49, 0x8b, 0x4c, 0x3f, 0xc5, 0x4f, 0x47, 0x76, 0x33, 0x9, 0x2a, 0x2c, 0x20, 0x60, 0x4e, 0x8a, 0xf4, 0xce, 0x6b, 0xd3, 0x5c, 0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; - uint8_t topic_bytes[] = {0x81, 0xab, 0x33, 0x17, 0x53, 0x4e}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = false; -uint8_t msg_bytes[] = {0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 29; - - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x86, 0x80, 0x81, 0xf6, 0x8e, 0x3, 0x5d, 0x78}; - uint8_t bytesprops3[] = {0xb3, 0x17, 0xa8, 0x38, 0x2, 0x6b, 0x9e, 0x1a, 0x5c, 0x84}; - uint8_t bytesprops2[] = {0x14, 0xc, 0x7b, 0x39, 0xf3, 0xe9, 0xf7, 0xc4}; - uint8_t bytesprops5[] = {0xe, 0xdc, 0x33, 0x6f, 0x4f, 0x3e, 0xc6, 0x69, 0x5, 0x76, 0x93}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops6[] = {0x19, 0x64, 0x8a, 0xd9, 0xad, 0x9a, 0x3, 0x91, 0x12, 0xad, 0xdc, 0xd6}; - uint8_t bytesprops7[] = {0x49, 0x8b, 0x4c, 0x3f, 0xc5, 0x4f, 0x47, 0x76, 0x33, 0x9, 0x2a, 0x2c, 0x20, 0x60, 0x4e, 0x8a, 0xf4, 0xce, 0x6b, 0xd3, 0x5c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25004}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13436}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31880}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18537}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1893}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16084}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17664}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2670}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6931}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10342}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={8, (char*)&bytesprops2}, .v={10, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14066}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={0, (char*)&bytesprops4}, .v={11, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19246}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1458}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9667}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops7}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16431}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1125}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31922}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13953}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10205}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17597}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13334}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20469}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 964}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28761}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5903, topic, msg, props); + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25658, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\129\171\&3\ETBSN", _pubPktID = 5903, _pubBody = "zPg\212~f\130\171\232\241P\212\ENQ'\234'@\v\177;s\157z*\DC2{\148\&6|", _pubProps = [PropServerKeepAlive 25004,PropRequestProblemInformation 146,PropTopicAlias 13436,PropServerKeepAlive 31880,PropPayloadFormatIndicator 16,PropMessageExpiryInterval 18537,PropAuthenticationData "",PropReasonString "\134\128\129\246\142\ETX]x",PropSessionExpiryInterval 1893,PropMaximumQoS 117,PropMaximumPacketSize 16084,PropTopicAlias 17664,PropTopicAlias 2670,PropServerKeepAlive 6931,PropTopicAliasMaximum 10342,PropUserProperty "\DC4\f{9\243\233\247\196" "\179\ETB\168\&8\STXk\158\SUB\\\132",PropMessageExpiryInterval 14066,PropUserProperty "" "\SO\220\&3oO>\198i\ENQv\147",PropAssignedClientIdentifier "\EMd\138\217\173\154\ETX\145\DC2\173\220\214",PropServerKeepAlive 19246,PropMaximumPacketSize 1458,PropTopicAliasMaximum 9667,PropContentType "I\139L?\197OGv3\t*, `N\138\244\206k\211\\"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "}\250\132\234S\200EV\164\175\218\237D", _pubPktID = 25658, _pubBody = +// "\DLE\DC3\242\235C\134\216h\196\ETB\255\169\164\222", _pubProps = [PropResponseTopic +// "\164\ETX\255\SYN\169a\EM\237\135\219?\183(\DLE2i\254\191?s\217\SI\229\243&\130",PropMessageExpiryInterval +// 16431,PropReasonString "\218\232\&8_\216\202'@\227\ACK|\252\NUL\ACK\235",PropRetainAvailable +// 227,PropSessionExpiryInterval 1125,PropCorrelationData +// "\188\180-\146\252\250Y\134|\255\169\224\228\226\&8\169\195\229o",PropServerKeepAlive 31922,PropReceiveMaximum +// 13953,PropResponseTopic "*}",PropReceiveMaximum 10205,PropRequestProblemInformation +// 46,PropWildcardSubscriptionAvailable 199,PropServerKeepAlive 17597,PropMaximumQoS 236,PropServerReference +// "\ENQI\177\187%LN\EM,\168d\215\245\220\170\203\247\DC2~E\SI\139\ACK\RS\189d\183;9",PropRetainAvailable +// 170,PropPayloadFormatIndicator 164,PropServerKeepAlive 13334,PropServerKeepAlive 20469,PropRequestResponseInformation +// 170,PropServerKeepAlive 964,PropSharedSubscriptionAvailable 117,PropAssignedClientIdentifier +// "\244=\"\141i\204\DC1\ENQ\r\DLE\ESC\rqV\251\DC1\188\213i\148q",PropTopicAliasMaximum 28761]} TEST(Publish5QCTest, Decode8) { -uint8_t pkt[] = {0x3c, 0xbf, 0x1, 0x0, 0x6, 0x81, 0xab, 0x33, 0x17, 0x53, 0x4e, 0x17, 0xf, 0x96, 0x1, 0x13, 0x61, 0xac, 0x17, 0x92, 0x23, 0x34, 0x7c, 0x13, 0x7c, 0x88, 0x1, 0x10, 0x2, 0x0, 0x0, 0x48, 0x69, 0x16, 0x0, 0x0, 0x1f, 0x0, 0x8, 0x86, 0x80, 0x81, 0xf6, 0x8e, 0x3, 0x5d, 0x78, 0x11, 0x0, 0x0, 0x7, 0x65, 0x24, 0x75, 0x27, 0x0, 0x0, 0x3e, 0xd4, 0x23, 0x45, 0x0, 0x23, 0xa, 0x6e, 0x13, 0x1b, 0x13, 0x22, 0x28, 0x66, 0x26, 0x0, 0x8, 0x14, 0xc, 0x7b, 0x39, 0xf3, 0xe9, 0xf7, 0xc4, 0x0, 0xa, 0xb3, 0x17, 0xa8, 0x38, 0x2, 0x6b, 0x9e, 0x1a, 0x5c, 0x84, 0x2, 0x0, 0x0, 0x36, 0xf2, 0x26, 0x0, 0x0, 0x0, 0xb, 0xe, 0xdc, 0x33, 0x6f, 0x4f, 0x3e, 0xc6, 0x69, 0x5, 0x76, 0x93, 0x12, 0x0, 0xc, 0x19, 0x64, 0x8a, 0xd9, 0xad, 0x9a, 0x3, 0x91, 0x12, 0xad, 0xdc, 0xd6, 0x13, 0x4b, 0x2e, 0x27, 0x0, 0x0, 0x5, 0xb2, 0x22, 0x25, 0xc3, 0x3, 0x0, 0x15, 0x49, 0x8b, 0x4c, 0x3f, 0xc5, 0x4f, 0x47, 0x76, 0x33, 0x9, 0x2a, 0x2c, 0x20, 0x60, 0x4e, 0x8a, 0xf4, 0xce, 0x6b, 0xd3, 0x5c, 0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x81, 0xab, 0x33, 0x17, 0x53, 0x4e}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7a, 0x50, 0x67, 0xd4, 0x7e, 0x66, 0x82, 0xab, 0xe8, 0xf1, 0x50, 0xd4, 0x5, 0x27, 0xea, 0x27, 0x40, 0xb, 0xb1, 0x3b, 0x73, 0x9d, 0x7a, 0x2a, 0x12, 0x7b, 0x94, 0x36, 0x7c}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 5903); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); -EXPECT_EQ(msg.payload_len, 29); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x3d, 0xd5, 0x1, 0x0, 0xd, 0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, + 0x44, 0x64, 0x3a, 0xb4, 0x1, 0x8, 0x0, 0x1a, 0xa4, 0x3, 0xff, 0x16, 0xa9, 0x61, 0x19, 0xed, 0x87, + 0xdb, 0x3f, 0xb7, 0x28, 0x10, 0x32, 0x69, 0xfe, 0xbf, 0x3f, 0x73, 0xd9, 0xf, 0xe5, 0xf3, 0x26, 0x82, + 0x2, 0x0, 0x0, 0x40, 0x2f, 0x1f, 0x0, 0xf, 0xda, 0xe8, 0x38, 0x5f, 0xd8, 0xca, 0x27, 0x40, 0xe3, + 0x6, 0x7c, 0xfc, 0x0, 0x6, 0xeb, 0x25, 0xe3, 0x11, 0x0, 0x0, 0x4, 0x65, 0x9, 0x0, 0x13, 0xbc, + 0xb4, 0x2d, 0x92, 0xfc, 0xfa, 0x59, 0x86, 0x7c, 0xff, 0xa9, 0xe0, 0xe4, 0xe2, 0x38, 0xa9, 0xc3, 0xe5, + 0x6f, 0x13, 0x7c, 0xb2, 0x21, 0x36, 0x81, 0x8, 0x0, 0x2, 0x2a, 0x7d, 0x21, 0x27, 0xdd, 0x17, 0x2e, + 0x28, 0xc7, 0x13, 0x44, 0xbd, 0x24, 0xec, 0x1c, 0x0, 0x1d, 0x5, 0x49, 0xb1, 0xbb, 0x25, 0x4c, 0x4e, + 0x19, 0x2c, 0xa8, 0x64, 0xd7, 0xf5, 0xdc, 0xaa, 0xcb, 0xf7, 0x12, 0x7e, 0x45, 0xf, 0x8b, 0x6, 0x1e, + 0xbd, 0x64, 0xb7, 0x3b, 0x39, 0x25, 0xaa, 0x1, 0xa4, 0x13, 0x34, 0x16, 0x13, 0x4f, 0xf5, 0x19, 0xaa, + 0x13, 0x3, 0xc4, 0x2a, 0x75, 0x12, 0x0, 0x15, 0xf4, 0x3d, 0x22, 0x8d, 0x69, 0xcc, 0x11, 0x5, 0xd, + 0x10, 0x1b, 0xd, 0x71, 0x56, 0xfb, 0x11, 0xbc, 0xd5, 0x69, 0x94, 0x71, 0x22, 0x70, 0x59, 0x10, 0x13, + 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "f\145?\ETXkG", _pubPktID = 0, _pubBody = "z)\172\246\137o\201C\144\161\ETX\DC4\243V\SI\136\ETX\223\135V\253\SYN\a\200.", _pubProps = [PropTopicAliasMaximum 31258,PropAssignedClientIdentifier ".\236\244\&2}I\NAK\164\152\251\\\176\&5\244'\245\152YXN\USq\218\249\DC4\SYN\ETX",PropRetainAvailable 81]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 25658); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\ETB\EM\FSn\\^\219_\249\191\CAN\146\196\142\252x\187\173 \r\244[B\136h\210\180", _pubPktID = 12697, _pubBody = +// "\208\EOT\241", _pubProps = [PropResponseTopic "\195\162",PropResponseInformation "\184\204f\153",PropTopicAlias +// 10643,PropMaximumQoS 120,PropMessageExpiryInterval 15357,PropMessageExpiryInterval 24217,PropSubscriptionIdentifier +// 4,PropServerKeepAlive 10759,PropResponseTopic "N\153\&4\249$\156\145\144\176\&1}\r\254\202\227",PropRetainAvailable +// 246,PropAuthenticationData "\179w\r\235\190+",PropMessageExpiryInterval 27852,PropTopicAliasMaximum +// 11775,PropRetainAvailable 87,PropAssignedClientIdentifier "\233\211e6\244",PropSharedSubscriptionAvailable +// 174,PropResponseInformation "\140\216\225W\195\218\136;\SYN\CANX?\DC3\192",PropSessionExpiryInterval +// 27739,PropServerReference "\134\235\135P\n0d0\223^\163\253",PropSubscriptionIdentifierAvailable +// 158,PropServerReference "\251C",PropSessionExpiryInterval 4686,PropTopicAlias 31565,PropServerReference +// "l\133\fk\169\243\159",PropServerReference +// "u6\224\199\176\250\&3\US\213\215#\\K?\226A\249\&54\160",PropWillDelayInterval 196,PropTopicAlias 23560]} TEST(Publish5QCTest, Encode9) { -uint8_t pkt[] = {0x31, 0x45, 0x0, 0x6, 0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47, 0x23, 0x22, 0x7a, 0x1a, 0x12, 0x0, 0x1b, 0x2e, 0xec, 0xf4, 0x32, 0x7d, 0x49, 0x15, 0xa4, 0x98, 0xfb, 0x5c, 0xb0, 0x35, 0xf4, 0x27, 0xf5, 0x98, 0x59, 0x58, 0x4e, 0x1f, 0x71, 0xda, 0xf9, 0x14, 0x16, 0x3, 0x25, 0x51, 0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; - uint8_t topic_bytes[] = {0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0xd2, 0x1, 0x0, 0x1b, 0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, + 0xc4, 0x8e, 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4, 0x31, 0x99, + 0xae, 0x1, 0x8, 0x0, 0x2, 0xc3, 0xa2, 0x1a, 0x0, 0x4, 0xb8, 0xcc, 0x66, 0x99, 0x23, 0x29, 0x93, + 0x24, 0x78, 0x2, 0x0, 0x0, 0x3b, 0xfd, 0x2, 0x0, 0x0, 0x5e, 0x99, 0xb, 0x4, 0x13, 0x2a, 0x7, + 0x8, 0x0, 0xf, 0x4e, 0x99, 0x34, 0xf9, 0x24, 0x9c, 0x91, 0x90, 0xb0, 0x31, 0x7d, 0xd, 0xfe, 0xca, + 0xe3, 0x25, 0xf6, 0x16, 0x0, 0x6, 0xb3, 0x77, 0xd, 0xeb, 0xbe, 0x2b, 0x2, 0x0, 0x0, 0x6c, 0xcc, + 0x22, 0x2d, 0xff, 0x25, 0x57, 0x12, 0x0, 0x5, 0xe9, 0xd3, 0x65, 0x36, 0xf4, 0x2a, 0xae, 0x1a, 0x0, + 0xe, 0x8c, 0xd8, 0xe1, 0x57, 0xc3, 0xda, 0x88, 0x3b, 0x16, 0x18, 0x58, 0x3f, 0x13, 0xc0, 0x11, 0x0, + 0x0, 0x6c, 0x5b, 0x1c, 0x0, 0xc, 0x86, 0xeb, 0x87, 0x50, 0xa, 0x30, 0x64, 0x30, 0xdf, 0x5e, 0xa3, + 0xfd, 0x29, 0x9e, 0x1c, 0x0, 0x2, 0xfb, 0x43, 0x11, 0x0, 0x0, 0x12, 0x4e, 0x23, 0x7b, 0x4d, 0x1c, + 0x0, 0x7, 0x6c, 0x85, 0xc, 0x6b, 0xa9, 0xf3, 0x9f, 0x1c, 0x0, 0x14, 0x75, 0x36, 0xe0, 0xc7, 0xb0, + 0xfa, 0x33, 0x1f, 0xd5, 0xd7, 0x23, 0x5c, 0x4b, 0x3f, 0xe2, 0x41, 0xf9, 0x35, 0x34, 0xa0, 0x18, 0x0, + 0x0, 0x0, 0xc4, 0x23, 0x5c, 0x8, 0xd0, 0x4, 0xf1}; + uint8_t topic_bytes[] = {0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, + 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS0; -msg.retained = true; -uint8_t msg_bytes[] = {0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 25; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xd0, 0x4, 0xf1}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; + + uint8_t bytesprops0[] = {0xc3, 0xa2}; + uint8_t bytesprops1[] = {0xb8, 0xcc, 0x66, 0x99}; + uint8_t bytesprops2[] = {0x4e, 0x99, 0x34, 0xf9, 0x24, 0x9c, 0x91, 0x90, 0xb0, 0x31, 0x7d, 0xd, 0xfe, 0xca, 0xe3}; + uint8_t bytesprops3[] = {0xb3, 0x77, 0xd, 0xeb, 0xbe, 0x2b}; + uint8_t bytesprops4[] = {0xe9, 0xd3, 0x65, 0x36, 0xf4}; + uint8_t bytesprops5[] = {0x8c, 0xd8, 0xe1, 0x57, 0xc3, 0xda, 0x88, 0x3b, 0x16, 0x18, 0x58, 0x3f, 0x13, 0xc0}; + uint8_t bytesprops6[] = {0x86, 0xeb, 0x87, 0x50, 0xa, 0x30, 0x64, 0x30, 0xdf, 0x5e, 0xa3, 0xfd}; + uint8_t bytesprops7[] = {0xfb, 0x43}; + uint8_t bytesprops8[] = {0x6c, 0x85, 0xc, 0x6b, 0xa9, 0xf3, 0x9f}; + uint8_t bytesprops9[] = {0x75, 0x36, 0xe0, 0xc7, 0xb0, 0xfa, 0x33, 0x1f, 0xd5, 0xd7, + 0x23, 0x5c, 0x4b, 0x3f, 0xe2, 0x41, 0xf9, 0x35, 0x34, 0xa0}; - uint8_t bytesprops0[] = {0x2e, 0xec, 0xf4, 0x32, 0x7d, 0x49, 0x15, 0xa4, 0x98, 0xfb, 0x5c, 0xb0, 0x35, 0xf4, 0x27, 0xf5, 0x98, 0x59, 0x58, 0x4e, 0x1f, 0x71, 0xda, 0xf9, 0x14, 0x16, 0x3}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31258}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10643}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15357}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24217}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10759}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27852}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11775}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27739}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4686}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31565}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 196}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23560}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 12697, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "f\145?\ETXkG", _pubPktID = 0, _pubBody = "z)\172\246\137o\201C\144\161\ETX\DC4\243V\SI\136\ETX\223\135V\253\SYN\a\200.", _pubProps = [PropTopicAliasMaximum 31258,PropAssignedClientIdentifier ".\236\244\&2}I\NAK\164\152\251\\\176\&5\244'\245\152YXN\USq\218\249\DC4\SYN\ETX",PropRetainAvailable 81]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\ETB\EM\FSn\\^\219_\249\191\CAN\146\196\142\252x\187\173 \r\244[B\136h\210\180", _pubPktID = 12697, _pubBody = +// "\208\EOT\241", _pubProps = [PropResponseTopic "\195\162",PropResponseInformation "\184\204f\153",PropTopicAlias +// 10643,PropMaximumQoS 120,PropMessageExpiryInterval 15357,PropMessageExpiryInterval 24217,PropSubscriptionIdentifier +// 4,PropServerKeepAlive 10759,PropResponseTopic "N\153\&4\249$\156\145\144\176\&1}\r\254\202\227",PropRetainAvailable +// 246,PropAuthenticationData "\179w\r\235\190+",PropMessageExpiryInterval 27852,PropTopicAliasMaximum +// 11775,PropRetainAvailable 87,PropAssignedClientIdentifier "\233\211e6\244",PropSharedSubscriptionAvailable +// 174,PropResponseInformation "\140\216\225W\195\218\136;\SYN\CANX?\DC3\192",PropSessionExpiryInterval +// 27739,PropServerReference "\134\235\135P\n0d0\223^\163\253",PropSubscriptionIdentifierAvailable +// 158,PropServerReference "\251C",PropSessionExpiryInterval 4686,PropTopicAlias 31565,PropServerReference +// "l\133\fk\169\243\159",PropServerReference +// "u6\224\199\176\250\&3\US\213\215#\\K?\226A\249\&54\160",PropWillDelayInterval 196,PropTopicAlias 23560]} TEST(Publish5QCTest, Decode9) { -uint8_t pkt[] = {0x31, 0x45, 0x0, 0x6, 0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47, 0x23, 0x22, 0x7a, 0x1a, 0x12, 0x0, 0x1b, 0x2e, 0xec, 0xf4, 0x32, 0x7d, 0x49, 0x15, 0xa4, 0x98, 0xfb, 0x5c, 0xb0, 0x35, 0xf4, 0x27, 0xf5, 0x98, 0x59, 0x58, 0x4e, 0x1f, 0x71, 0xda, 0xf9, 0x14, 0x16, 0x3, 0x25, 0x51, 0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x66, 0x91, 0x3f, 0x3, 0x6b, 0x47}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7a, 0x29, 0xac, 0xf6, 0x89, 0x6f, 0xc9, 0x43, 0x90, 0xa1, 0x3, 0x14, 0xf3, 0x56, 0xf, 0x88, 0x3, 0xdf, 0x87, 0x56, 0xfd, 0x16, 0x7, 0xc8, 0x2e}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS0); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 0); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); -EXPECT_EQ(msg.payload_len, 25); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x3c, 0xd2, 0x1, 0x0, 0x1b, 0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, + 0xc4, 0x8e, 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4, 0x31, 0x99, + 0xae, 0x1, 0x8, 0x0, 0x2, 0xc3, 0xa2, 0x1a, 0x0, 0x4, 0xb8, 0xcc, 0x66, 0x99, 0x23, 0x29, 0x93, + 0x24, 0x78, 0x2, 0x0, 0x0, 0x3b, 0xfd, 0x2, 0x0, 0x0, 0x5e, 0x99, 0xb, 0x4, 0x13, 0x2a, 0x7, + 0x8, 0x0, 0xf, 0x4e, 0x99, 0x34, 0xf9, 0x24, 0x9c, 0x91, 0x90, 0xb0, 0x31, 0x7d, 0xd, 0xfe, 0xca, + 0xe3, 0x25, 0xf6, 0x16, 0x0, 0x6, 0xb3, 0x77, 0xd, 0xeb, 0xbe, 0x2b, 0x2, 0x0, 0x0, 0x6c, 0xcc, + 0x22, 0x2d, 0xff, 0x25, 0x57, 0x12, 0x0, 0x5, 0xe9, 0xd3, 0x65, 0x36, 0xf4, 0x2a, 0xae, 0x1a, 0x0, + 0xe, 0x8c, 0xd8, 0xe1, 0x57, 0xc3, 0xda, 0x88, 0x3b, 0x16, 0x18, 0x58, 0x3f, 0x13, 0xc0, 0x11, 0x0, + 0x0, 0x6c, 0x5b, 0x1c, 0x0, 0xc, 0x86, 0xeb, 0x87, 0x50, 0xa, 0x30, 0x64, 0x30, 0xdf, 0x5e, 0xa3, + 0xfd, 0x29, 0x9e, 0x1c, 0x0, 0x2, 0xfb, 0x43, 0x11, 0x0, 0x0, 0x12, 0x4e, 0x23, 0x7b, 0x4d, 0x1c, + 0x0, 0x7, 0x6c, 0x85, 0xc, 0x6b, 0xa9, 0xf3, 0x9f, 0x1c, 0x0, 0x14, 0x75, 0x36, 0xe0, 0xc7, 0xb0, + 0xfa, 0x33, 0x1f, 0xd5, 0xd7, 0x23, 0x5c, 0x4b, 0x3f, 0xe2, 0x41, 0xf9, 0x35, 0x34, 0xa0, 0x18, 0x0, + 0x0, 0x0, 0xc4, 0x23, 0x5c, 0x8, 0xd0, 0x4, 0xf1}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} - - -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\155rvW\187y*a\164\152\nL\EMg}@\SYN\142\DC2", _pubPktID = 0, _pubBody = "\US\US\DLE\ESC\221J\DC3T\209\207\183rx\202;\229\224\EM\241z#\169X\166\139", _pubProps = [PropServerKeepAlive 6612,PropResponseTopic "\211\178"]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, + 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd0, 0x4, 0xf1}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 12697); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\207\219\241(topic.data), 19); -EXPECT_EQ(msg.payload_len, 25); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x39, 0xa2, 0x1, 0x0, 0x8, 0xcf, 0xdb, 0xf1, 0x3c, 0x61, 0xc4, 0x62, 0xd, 0x7e, 0x29, 0x71, 0x28, + 0xb7, 0x2, 0x0, 0x0, 0x5f, 0x22, 0x26, 0x0, 0x1, 0x5f, 0x0, 0x18, 0xa1, 0xb0, 0xd9, 0x6a, 0x34, + 0x70, 0x99, 0x62, 0xa, 0x7c, 0x67, 0xa7, 0xf0, 0x9e, 0xd4, 0x5d, 0x23, 0xf8, 0x3f, 0x52, 0x8f, 0x21, + 0x67, 0x2b, 0x18, 0x0, 0x0, 0x14, 0x68, 0x8, 0x0, 0x5, 0xff, 0xca, 0xfb, 0x2d, 0x97, 0x11, 0x0, + 0x0, 0x10, 0x7c, 0x1a, 0x0, 0xd, 0x10, 0x1c, 0x68, 0x16, 0x9b, 0x74, 0x8d, 0x21, 0x6f, 0xab, 0xb3, + 0x56, 0x18, 0x1a, 0x0, 0xd, 0xef, 0x21, 0x4e, 0x79, 0xb2, 0x11, 0xdb, 0xc6, 0x9, 0x7a, 0x4b, 0x46, + 0x3c, 0x29, 0x87, 0x23, 0x20, 0x9d, 0x2, 0x0, 0x0, 0xf, 0xc1, 0x17, 0x41, 0x18, 0x0, 0x0, 0x49, + 0x76, 0x15, 0x0, 0xf, 0xbb, 0xbd, 0x9a, 0x69, 0xa9, 0x16, 0x80, 0x7c, 0x14, 0x58, 0x25, 0x7, 0xf2, + 0x76, 0xcc, 0x28, 0x71, 0xf8, 0xff, 0xd1, 0x80, 0x73, 0xa9, 0xb3, 0xf5, 0xcb, 0x2e, 0x1c, 0x28, 0xb3, + 0x6f, 0x3, 0x6b, 0xd, 0x27, 0x78, 0xef, 0x17, 0x3d, 0xbd, 0x3e, 0x71}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "2n\201\176\229\EM\245*\ACK\SUB\177\b~\130\155,l", _pubPktID = 18294, _pubBody = "22", _pubProps = [PropTopicAlias 1825,PropServerKeepAlive 27568,PropMaximumPacketSize 32649,PropSessionExpiryInterval 12496,PropUserProperty "\191\&8m" "Zj\183\171\&9\190~\166\141\175\\\ACK8>\236\253Sa\DC2qTY\138\GS{w\214",PropReasonString "\SO~\152\246\198\247\169r"]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xcf, 0xdb, 0xf1, 0x3c, 0x61, 0xc4, 0x62, 0xd}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf8, 0xff, 0xd1, 0x80, 0x73, 0xa9, 0xb3, 0xf5, 0xcb, 0x2e, 0x1c, 0x28, 0xb3, + 0x6f, 0x3, 0x6b, 0xd, 0x27, 0x78, 0xef, 0x17, 0x3d, 0xbd, 0x3e, 0x71}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\218\230\US\223|\136nz\184\f)s\246ht", _pubPktID = 0, _pubBody = "\209", _pubProps = [PropRequestResponseInformation +// 63,PropTopicAliasMaximum 25586,PropWildcardSubscriptionAvailable 35,PropSubscriptionIdentifier +// 0,PropPayloadFormatIndicator 212,PropMaximumPacketSize 7906,PropMessageExpiryInterval 15199,PropResponseInformation +// "{\254\252\147e\184hx-\250\171\SYN\158\133\252\194\176\219\140:m",PropUserProperty +// "\166i\GS\b\231\ENQ\190\NUL\229\174\182\"" +// "V\193g\167\200\186\&5\246P\159d\225\&5\209\219sS",PropSubscriptionIdentifierAvailable 136,PropWillDelayInterval +// 32300,PropMaximumPacketSize 22829,PropAuthenticationData +// "\184\221\227|\240\152\182\167\DC1\DELY\143x-",PropRequestProblemInformation 233,PropAuthenticationMethod +// "x\139\214\b\199\&3\175j\245W\160M\200\220\194\212\148:\184",PropRequestProblemInformation +// 146,PropSubscriptionIdentifier 28,PropSubscriptionIdentifierAvailable 116,PropServerReference +// "g\140\&0%\146(\175\165\141`\254\204\170\132",PropTopicAliasMaximum 25801]} TEST(Publish5QCTest, Encode11) { -uint8_t pkt[] = {0x33, 0x56, 0x0, 0x11, 0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c, 0x47, 0x76, 0x3e, 0x23, 0x7, 0x21, 0x13, 0x6b, 0xb0, 0x27, 0x0, 0x0, 0x7f, 0x89, 0x11, 0x0, 0x0, 0x30, 0xd0, 0x26, 0x0, 0x3, 0xbf, 0x38, 0x6d, 0x0, 0x1b, 0x5a, 0x6a, 0xb7, 0xab, 0x39, 0xbe, 0x7e, 0xa6, 0x8d, 0xaf, 0x5c, 0x6, 0x38, 0x3e, 0xec, 0xfd, 0x53, 0x61, 0x12, 0x71, 0x54, 0x59, 0x8a, 0x1d, 0x7b, 0x77, 0xd6, 0x1f, 0x0, 0x8, 0xe, 0x7e, 0x98, 0xf6, 0xc6, 0xf7, 0xa9, 0x72, 0x32, 0x32}; - uint8_t topic_bytes[] = {0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0xb2, 0x1, 0x0, 0xf, 0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, + 0xf6, 0x68, 0x74, 0x9e, 0x1, 0x19, 0x3f, 0x22, 0x63, 0xf2, 0x28, 0x23, 0xb, 0x0, 0x1, 0xd4, 0x27, + 0x0, 0x0, 0x1e, 0xe2, 0x2, 0x0, 0x0, 0x3b, 0x5f, 0x1a, 0x0, 0x15, 0x7b, 0xfe, 0xfc, 0x93, 0x65, + 0xb8, 0x68, 0x78, 0x2d, 0xfa, 0xab, 0x16, 0x9e, 0x85, 0xfc, 0xc2, 0xb0, 0xdb, 0x8c, 0x3a, 0x6d, 0x26, + 0x0, 0xc, 0xa6, 0x69, 0x1d, 0x8, 0xe7, 0x5, 0xbe, 0x0, 0xe5, 0xae, 0xb6, 0x22, 0x0, 0x11, 0x56, + 0xc1, 0x67, 0xa7, 0xc8, 0xba, 0x35, 0xf6, 0x50, 0x9f, 0x64, 0xe1, 0x35, 0xd1, 0xdb, 0x73, 0x53, 0x29, + 0x88, 0x18, 0x0, 0x0, 0x7e, 0x2c, 0x27, 0x0, 0x0, 0x59, 0x2d, 0x16, 0x0, 0xe, 0xb8, 0xdd, 0xe3, + 0x7c, 0xf0, 0x98, 0xb6, 0xa7, 0x11, 0x7f, 0x59, 0x8f, 0x78, 0x2d, 0x17, 0xe9, 0x15, 0x0, 0x13, 0x78, + 0x8b, 0xd6, 0x8, 0xc7, 0x33, 0xaf, 0x6a, 0xf5, 0x57, 0xa0, 0x4d, 0xc8, 0xdc, 0xc2, 0xd4, 0x94, 0x3a, + 0xb8, 0x17, 0x92, 0xb, 0x1c, 0x29, 0x74, 0x1c, 0x0, 0xe, 0x67, 0x8c, 0x30, 0x25, 0x92, 0x28, 0xaf, + 0xa5, 0x8d, 0x60, 0xfe, 0xcc, 0xaa, 0x84, 0x22, 0x64, 0xc9, 0xd1}; + uint8_t topic_bytes[] = {0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x32, 0x32}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 2; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xd1}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 1; + + uint8_t bytesprops0[] = {0x7b, 0xfe, 0xfc, 0x93, 0x65, 0xb8, 0x68, 0x78, 0x2d, 0xfa, 0xab, + 0x16, 0x9e, 0x85, 0xfc, 0xc2, 0xb0, 0xdb, 0x8c, 0x3a, 0x6d}; + uint8_t bytesprops2[] = {0x56, 0xc1, 0x67, 0xa7, 0xc8, 0xba, 0x35, 0xf6, 0x50, + 0x9f, 0x64, 0xe1, 0x35, 0xd1, 0xdb, 0x73, 0x53}; + uint8_t bytesprops1[] = {0xa6, 0x69, 0x1d, 0x8, 0xe7, 0x5, 0xbe, 0x0, 0xe5, 0xae, 0xb6, 0x22}; + uint8_t bytesprops3[] = {0xb8, 0xdd, 0xe3, 0x7c, 0xf0, 0x98, 0xb6, 0xa7, 0x11, 0x7f, 0x59, 0x8f, 0x78, 0x2d}; + uint8_t bytesprops4[] = {0x78, 0x8b, 0xd6, 0x8, 0xc7, 0x33, 0xaf, 0x6a, 0xf5, 0x57, + 0xa0, 0x4d, 0xc8, 0xdc, 0xc2, 0xd4, 0x94, 0x3a, 0xb8}; + uint8_t bytesprops5[] = {0x67, 0x8c, 0x30, 0x25, 0x92, 0x28, 0xaf, 0xa5, 0x8d, 0x60, 0xfe, 0xcc, 0xaa, 0x84}; - uint8_t bytesprops1[] = {0x5a, 0x6a, 0xb7, 0xab, 0x39, 0xbe, 0x7e, 0xa6, 0x8d, 0xaf, 0x5c, 0x6, 0x38, 0x3e, 0xec, 0xfd, 0x53, 0x61, 0x12, 0x71, 0x54, 0x59, 0x8a, 0x1d, 0x7b, 0x77, 0xd6}; - uint8_t bytesprops0[] = {0xbf, 0x38, 0x6d}; - uint8_t bytesprops2[] = {0xe, 0x7e, 0x98, 0xf6, 0xc6, 0xf7, 0xa9, 0x72}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1825}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27568}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32649}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12496}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={3, (char*)&bytesprops0}, .v={27, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25586}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7906}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15199}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops1}, .v = {17, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32300}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22829}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25801}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 18294, topic, msg, props); + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "2n\201\176\229\EM\245*\ACK\SUB\177\b~\130\155,l", _pubPktID = 18294, _pubBody = "22", _pubProps = [PropTopicAlias 1825,PropServerKeepAlive 27568,PropMaximumPacketSize 32649,PropSessionExpiryInterval 12496,PropUserProperty "\191\&8m" "Zj\183\171\&9\190~\166\141\175\\\ACK8>\236\253Sa\DC2qTY\138\GS{w\214",PropReasonString "\SO~\152\246\198\247\169r"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\218\230\US\223|\136nz\184\f)s\246ht", _pubPktID = 0, _pubBody = "\209", _pubProps = [PropRequestResponseInformation +// 63,PropTopicAliasMaximum 25586,PropWildcardSubscriptionAvailable 35,PropSubscriptionIdentifier +// 0,PropPayloadFormatIndicator 212,PropMaximumPacketSize 7906,PropMessageExpiryInterval 15199,PropResponseInformation +// "{\254\252\147e\184hx-\250\171\SYN\158\133\252\194\176\219\140:m",PropUserProperty +// "\166i\GS\b\231\ENQ\190\NUL\229\174\182\"" +// "V\193g\167\200\186\&5\246P\159d\225\&5\209\219sS",PropSubscriptionIdentifierAvailable 136,PropWillDelayInterval +// 32300,PropMaximumPacketSize 22829,PropAuthenticationData +// "\184\221\227|\240\152\182\167\DC1\DELY\143x-",PropRequestProblemInformation 233,PropAuthenticationMethod +// "x\139\214\b\199\&3\175j\245W\160M\200\220\194\212\148:\184",PropRequestProblemInformation +// 146,PropSubscriptionIdentifier 28,PropSubscriptionIdentifierAvailable 116,PropServerReference +// "g\140\&0%\146(\175\165\141`\254\204\170\132",PropTopicAliasMaximum 25801]} TEST(Publish5QCTest, Decode11) { -uint8_t pkt[] = {0x33, 0x56, 0x0, 0x11, 0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c, 0x47, 0x76, 0x3e, 0x23, 0x7, 0x21, 0x13, 0x6b, 0xb0, 0x27, 0x0, 0x0, 0x7f, 0x89, 0x11, 0x0, 0x0, 0x30, 0xd0, 0x26, 0x0, 0x3, 0xbf, 0x38, 0x6d, 0x0, 0x1b, 0x5a, 0x6a, 0xb7, 0xab, 0x39, 0xbe, 0x7e, 0xa6, 0x8d, 0xaf, 0x5c, 0x6, 0x38, 0x3e, 0xec, 0xfd, 0x53, 0x61, 0x12, 0x71, 0x54, 0x59, 0x8a, 0x1d, 0x7b, 0x77, 0xd6, 0x1f, 0x0, 0x8, 0xe, 0x7e, 0x98, 0xf6, 0xc6, 0xf7, 0xa9, 0x72, 0x32, 0x32}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x32, 0x6e, 0xc9, 0xb0, 0xe5, 0x19, 0xf5, 0x2a, 0x6, 0x1a, 0xb1, 0x8, 0x7e, 0x82, 0x9b, 0x2c, 0x6c}; - lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x32, 0x32}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 18294); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); -EXPECT_EQ(msg.payload_len, 2); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x39, 0xb2, 0x1, 0x0, 0xf, 0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, + 0xf6, 0x68, 0x74, 0x9e, 0x1, 0x19, 0x3f, 0x22, 0x63, 0xf2, 0x28, 0x23, 0xb, 0x0, 0x1, 0xd4, 0x27, + 0x0, 0x0, 0x1e, 0xe2, 0x2, 0x0, 0x0, 0x3b, 0x5f, 0x1a, 0x0, 0x15, 0x7b, 0xfe, 0xfc, 0x93, 0x65, + 0xb8, 0x68, 0x78, 0x2d, 0xfa, 0xab, 0x16, 0x9e, 0x85, 0xfc, 0xc2, 0xb0, 0xdb, 0x8c, 0x3a, 0x6d, 0x26, + 0x0, 0xc, 0xa6, 0x69, 0x1d, 0x8, 0xe7, 0x5, 0xbe, 0x0, 0xe5, 0xae, 0xb6, 0x22, 0x0, 0x11, 0x56, + 0xc1, 0x67, 0xa7, 0xc8, 0xba, 0x35, 0xf6, 0x50, 0x9f, 0x64, 0xe1, 0x35, 0xd1, 0xdb, 0x73, 0x53, 0x29, + 0x88, 0x18, 0x0, 0x0, 0x7e, 0x2c, 0x27, 0x0, 0x0, 0x59, 0x2d, 0x16, 0x0, 0xe, 0xb8, 0xdd, 0xe3, + 0x7c, 0xf0, 0x98, 0xb6, 0xa7, 0x11, 0x7f, 0x59, 0x8f, 0x78, 0x2d, 0x17, 0xe9, 0x15, 0x0, 0x13, 0x78, + 0x8b, 0xd6, 0x8, 0xc7, 0x33, 0xaf, 0x6a, 0xf5, 0x57, 0xa0, 0x4d, 0xc8, 0xdc, 0xc2, 0xd4, 0x94, 0x3a, + 0xb8, 0x17, 0x92, 0xb, 0x1c, 0x29, 0x74, 0x1c, 0x0, 0xe, 0x67, 0x8c, 0x30, 0x25, 0x92, 0x28, 0xaf, + 0xa5, 0x8d, 0x60, 0xfe, 0xcc, 0xaa, 0x84, 0x22, 0x64, 0xc9, 0xd1}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd1}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\185\207+s\131Y\252\238R\EOT\183\224\v\195'\154V\SUB\214", _pubPktID = 0, _pubBody = +// "n\190=U\SI\224\255\fT\157I\150?Z\SI\215\177\163\143\SUB", _pubProps = [PropUserProperty +// "\144.\193YAI\228\215\n(3\DEL\226\244y\234V\196" +// "\194\246d\nv\220\222\238\190\CAN\198vx\170\137",PropSharedSubscriptionAvailable 143]} +TEST(Publish5QCTest, Encode12) { + uint8_t pkt[] = {0x31, 0x52, 0x0, 0x13, 0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, 0xb7, 0xe0, 0xb, + 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6, 0x28, 0x26, 0x0, 0x12, 0x90, 0x2e, 0xc1, 0x59, 0x41, 0x49, 0xe4, + 0xd7, 0xa, 0x28, 0x33, 0x7f, 0xe2, 0xf4, 0x79, 0xea, 0x56, 0xc4, 0x0, 0xf, 0xc2, 0xf6, 0x64, 0xa, + 0x76, 0xdc, 0xde, 0xee, 0xbe, 0x18, 0xc6, 0x76, 0x78, 0xaa, 0x89, 0x2a, 0x8f, 0x6e, 0xbe, 0x3d, 0x55, + 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + uint8_t topic_bytes[] = {0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, + 0xb7, 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, + 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 20; -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\SI\221\168J\184\157\208vn\224\GS", _pubPktID = 19130, _pubBody = "=m\162\166\ETX\DEL\SI?\155\155\229\193\RS\194\ETX^\144\196\"\134\199\t\254\147\&1\ESC\221\132", _pubProps = [PropMessageExpiryInterval 10784,PropMaximumPacketSize 27458,PropAssignedClientIdentifier "G$v\235\218\"\220",PropAuthenticationMethod "\133",PropMaximumQoS 124,PropAssignedClientIdentifier "\228\220\169\131\254^\178\229\DC3\141\ESC\188NjB",PropReceiveMaximum 15546,PropSubscriptionIdentifierAvailable 23,PropWillDelayInterval 22707,PropWildcardSubscriptionAvailable 210,PropAssignedClientIdentifier "D3\203.C~\144\185r\v\ESC\211\151|\202\134\199y\b\213\US\135\190",PropAuthenticationMethod "\ETB;\223\&4\n\\M\ESC\188\132",PropAuthenticationData "\158U]a\252o\250\153\140\174\208ZV\205\SYNTw\149",PropMessageExpiryInterval 13702,PropSubscriptionIdentifier 27,PropPayloadFormatIndicator 144,PropWillDelayInterval 18493,PropServerReference "\US=r\ENQZ\174m\240\v%\SYN\186\207\135K",PropTopicAlias 14505,PropSharedSubscriptionAvailable 82,PropReceiveMaximum 19530,PropRequestProblemInformation 56,PropAuthenticationMethod "\150N\SO\230\134$\141\238\132\203P\noE\185YC+\NAKt\SO\158\245\242%X\156h\161\CAN",PropResponseTopic "!t\195\255Ea\140\248\250i\ESCmu\181\195.\241\n\v\147\211\177LtW\162",PropAuthenticationData "\164B\248,\195\GSB\225\242\SI\SO\172\251\220W3J\US\250\161\216\241\212V\223B\218XA",PropAuthenticationMethod "\232\213\&8\166x\STX4\171",PropResponseInformation "\215",PropAuthenticationData "*\170]\135\238\156\238\162\229\213\247\DC1\234G\r\182\200@\207o'",PropResponseInformation "w\SO.\186a\218\208\221*"]} -TEST(Publish5QCTest, Encode12) { -uint8_t pkt[] = {0x3c, 0xdc, 0x2, 0x0, 0xb, 0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d, 0x4a, 0xba, 0xaf, 0x2, 0x2, 0x0, 0x0, 0x2a, 0x20, 0x27, 0x0, 0x0, 0x6b, 0x42, 0x12, 0x0, 0x7, 0x47, 0x24, 0x76, 0xeb, 0xda, 0x22, 0xdc, 0x15, 0x0, 0x1, 0x85, 0x24, 0x7c, 0x12, 0x0, 0xf, 0xe4, 0xdc, 0xa9, 0x83, 0xfe, 0x5e, 0xb2, 0xe5, 0x13, 0x8d, 0x1b, 0xbc, 0x4e, 0x6a, 0x42, 0x21, 0x3c, 0xba, 0x29, 0x17, 0x18, 0x0, 0x0, 0x58, 0xb3, 0x28, 0xd2, 0x12, 0x0, 0x17, 0x44, 0x33, 0xcb, 0x2e, 0x43, 0x7e, 0x90, 0xb9, 0x72, 0xb, 0x1b, 0xd3, 0x97, 0x7c, 0xca, 0x86, 0xc7, 0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, 0x1, 0xd7, 0x16, 0x0, 0x15, 0x2a, 0xaa, 0x5d, 0x87, 0xee, 0x9c, 0xee, 0xa2, 0xe5, 0xd5, 0xf7, 0x11, 0xea, 0x47, 0xd, 0xb6, 0xc8, 0x40, 0xcf, 0x6f, 0x27, 0x1a, 0x0, 0x9, 0x77, 0xe, 0x2e, 0xba, 0x61, 0xda, 0xd0, 0xdd, 0x2a, 0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; - uint8_t topic_bytes[] = {0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t bytesprops1[] = {0xc2, 0xf6, 0x64, 0xa, 0x76, 0xdc, 0xde, 0xee, 0xbe, 0x18, 0xc6, 0x76, 0x78, 0xaa, 0x89}; + uint8_t bytesprops0[] = {0x90, 0x2e, 0xc1, 0x59, 0x41, 0x49, 0xe4, 0xd7, 0xa, + 0x28, 0x33, 0x7f, 0xe2, 0xf4, 0x79, 0xea, 0x56, 0xc4}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = false; -uint8_t msg_bytes[] = {0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 28; - - uint8_t bytesprops0[] = {0x47, 0x24, 0x76, 0xeb, 0xda, 0x22, 0xdc}; - uint8_t bytesprops1[] = {0x85}; - uint8_t bytesprops2[] = {0xe4, 0xdc, 0xa9, 0x83, 0xfe, 0x5e, 0xb2, 0xe5, 0x13, 0x8d, 0x1b, 0xbc, 0x4e, 0x6a, 0x42}; - uint8_t bytesprops3[] = {0x44, 0x33, 0xcb, 0x2e, 0x43, 0x7e, 0x90, 0xb9, 0x72, 0xb, 0x1b, 0xd3, 0x97, 0x7c, 0xca, 0x86, 0xc7, 0x79, 0x8, 0xd5, 0x1f, 0x87, 0xbe}; - uint8_t bytesprops4[] = {0x17, 0x3b, 0xdf, 0x34, 0xa, 0x5c, 0x4d, 0x1b, 0xbc, 0x84}; - uint8_t bytesprops5[] = {0x9e, 0x55, 0x5d, 0x61, 0xfc, 0x6f, 0xfa, 0x99, 0x8c, 0xae, 0xd0, 0x5a, 0x56, 0xcd, 0x16, 0x54, 0x77, 0x95}; - uint8_t bytesprops6[] = {0x1f, 0x3d, 0x72, 0x5, 0x5a, 0xae, 0x6d, 0xf0, 0xb, 0x25, 0x16, 0xba, 0xcf, 0x87, 0x4b}; - uint8_t bytesprops7[] = {0x96, 0x4e, 0xe, 0xe6, 0x86, 0x24, 0x8d, 0xee, 0x84, 0xcb, 0x50, 0xa, 0x6f, 0x45, 0xb9, 0x59, 0x43, 0x2b, 0x15, 0x74, 0xe, 0x9e, 0xf5, 0xf2, 0x25, 0x58, 0x9c, 0x68, 0xa1, 0x18}; - uint8_t bytesprops8[] = {0x21, 0x74, 0xc3, 0xff, 0x45, 0x61, 0x8c, 0xf8, 0xfa, 0x69, 0x1b, 0x6d, 0x75, 0xb5, 0xc3, 0x2e, 0xf1, 0xa, 0xb, 0x93, 0xd3, 0xb1, 0x4c, 0x74, 0x57, 0xa2}; - uint8_t bytesprops9[] = {0xa4, 0x42, 0xf8, 0x2c, 0xc3, 0x1d, 0x42, 0xe1, 0xf2, 0xf, 0xe, 0xac, 0xfb, 0xdc, 0x57, 0x33, 0x4a, 0x1f, 0xfa, 0xa1, 0xd8, 0xf1, 0xd4, 0x56, 0xdf, 0x42, 0xda, 0x58, 0x41}; - uint8_t bytesprops10[] = {0xe8, 0xd5, 0x38, 0xa6, 0x78, 0x2, 0x34, 0xab}; - uint8_t bytesprops11[] = {0xd7}; - uint8_t bytesprops12[] = {0x2a, 0xaa, 0x5d, 0x87, 0xee, 0x9c, 0xee, 0xa2, 0xe5, 0xd5, 0xf7, 0x11, 0xea, 0x47, 0xd, 0xb6, 0xc8, 0x40, 0xcf, 0x6f, 0x27}; - uint8_t bytesprops13[] = {0x77, 0xe, 0x2e, 0xba, 0x61, 0xda, 0xd0, 0xdd, 0x2a}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10784}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27458}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15546}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22707}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13702}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18493}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14505}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19530}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops13}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops0}, .v = {15, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 143}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 19130, topic, msg, props); + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\SI\221\168J\184\157\208vn\224\GS", _pubPktID = 19130, _pubBody = "=m\162\166\ETX\DEL\SI?\155\155\229\193\RS\194\ETX^\144\196\"\134\199\t\254\147\&1\ESC\221\132", _pubProps = [PropMessageExpiryInterval 10784,PropMaximumPacketSize 27458,PropAssignedClientIdentifier "G$v\235\218\"\220",PropAuthenticationMethod "\133",PropMaximumQoS 124,PropAssignedClientIdentifier "\228\220\169\131\254^\178\229\DC3\141\ESC\188NjB",PropReceiveMaximum 15546,PropSubscriptionIdentifierAvailable 23,PropWillDelayInterval 22707,PropWildcardSubscriptionAvailable 210,PropAssignedClientIdentifier "D3\203.C~\144\185r\v\ESC\211\151|\202\134\199y\b\213\US\135\190",PropAuthenticationMethod "\ETB;\223\&4\n\\M\ESC\188\132",PropAuthenticationData "\158U]a\252o\250\153\140\174\208ZV\205\SYNTw\149",PropMessageExpiryInterval 13702,PropSubscriptionIdentifier 27,PropPayloadFormatIndicator 144,PropWillDelayInterval 18493,PropServerReference "\US=r\ENQZ\174m\240\v%\SYN\186\207\135K",PropTopicAlias 14505,PropSharedSubscriptionAvailable 82,PropReceiveMaximum 19530,PropRequestProblemInformation 56,PropAuthenticationMethod "\150N\SO\230\134$\141\238\132\203P\noE\185YC+\NAKt\SO\158\245\242%X\156h\161\CAN",PropResponseTopic "!t\195\255Ea\140\248\250i\ESCmu\181\195.\241\n\v\147\211\177LtW\162",PropAuthenticationData "\164B\248,\195\GSB\225\242\SI\SO\172\251\220W3J\US\250\161\216\241\212V\223B\218XA",PropAuthenticationMethod "\232\213\&8\166x\STX4\171",PropResponseInformation "\215",PropAuthenticationData "*\170]\135\238\156\238\162\229\213\247\DC1\234G\r\182\200@\207o'",PropResponseInformation "w\SO.\186a\218\208\221*"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\185\207+s\131Y\252\238R\EOT\183\224\v\195'\154V\SUB\214", _pubPktID = 0, _pubBody = +// "n\190=U\SI\224\255\fT\157I\150?Z\SI\215\177\163\143\SUB", _pubProps = [PropUserProperty +// "\144.\193YAI\228\215\n(3\DEL\226\244y\234V\196" +// "\194\246d\nv\220\222\238\190\CAN\198vx\170\137",PropSharedSubscriptionAvailable 143]} TEST(Publish5QCTest, Decode12) { -uint8_t pkt[] = {0x3c, 0xdc, 0x2, 0x0, 0xb, 0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d, 0x4a, 0xba, 0xaf, 0x2, 0x2, 0x0, 0x0, 0x2a, 0x20, 0x27, 0x0, 0x0, 0x6b, 0x42, 0x12, 0x0, 0x7, 0x47, 0x24, 0x76, 0xeb, 0xda, 0x22, 0xdc, 0x15, 0x0, 0x1, 0x85, 0x24, 0x7c, 0x12, 0x0, 0xf, 0xe4, 0xdc, 0xa9, 0x83, 0xfe, 0x5e, 0xb2, 0xe5, 0x13, 0x8d, 0x1b, 0xbc, 0x4e, 0x6a, 0x42, 0x21, 0x3c, 0xba, 0x29, 0x17, 0x18, 0x0, 0x0, 0x58, 0xb3, 0x28, 0xd2, 0x12, 0x0, 0x17, 0x44, 0x33, 0xcb, 0x2e, 0x43, 0x7e, 0x90, 0xb9, 0x72, 0xb, 0x1b, 0xd3, 0x97, 0x7c, 0xca, 0x86, 0xc7, 0x79, 0x8, 0xd5, 0x1f, 0x87, 0xbe, 0x15, 0x0, 0xa, 0x17, 0x3b, 0xdf, 0x34, 0xa, 0x5c, 0x4d, 0x1b, 0xbc, 0x84, 0x16, 0x0, 0x12, 0x9e, 0x55, 0x5d, 0x61, 0xfc, 0x6f, 0xfa, 0x99, 0x8c, 0xae, 0xd0, 0x5a, 0x56, 0xcd, 0x16, 0x54, 0x77, 0x95, 0x2, 0x0, 0x0, 0x35, 0x86, 0xb, 0x1b, 0x1, 0x90, 0x18, 0x0, 0x0, 0x48, 0x3d, 0x1c, 0x0, 0xf, 0x1f, 0x3d, 0x72, 0x5, 0x5a, 0xae, 0x6d, 0xf0, 0xb, 0x25, 0x16, 0xba, 0xcf, 0x87,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packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf, 0xdd, 0xa8, 0x4a, 0xb8, 0x9d, 0xd0, 0x76, 0x6e, 0xe0, 0x1d}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x3d, 0x6d, 0xa2, 0xa6, 0x3, 0x7f, 0xf, 0x3f, 0x9b, 0x9b, 0xe5, 0xc1, 0x1e, 0xc2, 0x3, 0x5e, 0x90, 0xc4, 0x22, 0x86, 0xc7, 0x9, 0xfe, 0x93, 0x31, 0x1b, 0xdd, 0x84}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 19130); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); -EXPECT_EQ(msg.payload_len, 28); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x31, 0x52, 0x0, 0x13, 0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, 0xb7, 0xe0, 0xb, + 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6, 0x28, 0x26, 0x0, 0x12, 0x90, 0x2e, 0xc1, 0x59, 0x41, 0x49, 0xe4, + 0xd7, 0xa, 0x28, 0x33, 0x7f, 0xe2, 0xf4, 0x79, 0xea, 0x56, 0xc4, 0x0, 0xf, 0xc2, 0xf6, 0x64, 0xa, + 0x76, 0xdc, 0xde, 0xee, 0xbe, 0x18, 0xc6, 0x76, 0x78, 0xaa, 0x89, 0x2a, 0x8f, 0x6e, 0xbe, 0x3d, 0x55, + 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} - - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\n\159\143\162\210", _pubPktID = 3591, _pubBody = "\156|7\ETB|\195\202\&4y", _pubProps = [PropTopicAlias 16866,PropPayloadFormatIndicator 161,PropWillDelayInterval 10125,PropTopicAliasMaximum 9943,PropAssignedClientIdentifier "\166}b\131\251\SI\238\142;\227K\136T\135V\247\161",PropUserProperty "" "\US&\214kE\128q\201\193`7",PropSubscriptionIdentifier 14,PropServerReference "\STXg4\v~\SYN",PropContentType "\180\GS\161\&3\158\249",PropContentType "s+\137|8\r'&\231D=7\234F\240UP\250Q\249\223xm",PropSharedSubscriptionAvailable 120,PropRetainAvailable 148,PropReceiveMaximum 21370,PropReceiveMaximum 15880,PropCorrelationData "\SYN\145\218\133",PropMaximumQoS 249,PropRetainAvailable 68,PropServerReference "\214\163?X\208\137\tL\204\249\150\193\138C\US\223\167\247\232=",PropWildcardSubscriptionAvailable 42,PropMessageExpiryInterval 15417,PropCorrelationData "\234\150\202\&8\208(\204\142&\190$|\SYNgY@\221\162\164",PropTopicAliasMaximum 15741,PropContentType "Yvww",PropSessionExpiryInterval 32202,PropPayloadFormatIndicator 229,PropResponseInformation "\164"]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, + 0xb7, 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6}; + lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, + 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "-\224\164\222\163\DLE\224\218\229\CAN!n\rZ\193Y\DC3r\129\219T\172\139\252\&2~", _pubPktID = 8532, _pubBody = +// "\145b$\DEL\237\176\245E\250\186\STX\US|\163\f\221\190&\238\vu\US", _pubProps = [PropSubscriptionIdentifierAvailable +// 34,PropMessageExpiryInterval 11891,PropResponseInformation +// "-\225]\247aFq\176\244g[\SYN\129\131\161\164\154-\f\129\147*\154M\225\242\169\237\ENQZ",PropSubscriptionIdentifierAvailable +// 249,PropContentType +// "\164KI\192\b\GSW\"\143O\137\197\ETBhML8\223\145\RS\US\181\129\STXHc<\243\165\225",PropAuthenticationMethod +// "\136\&0\244\233\166=Bk%69\245\211|",PropResponseInformation "J\233\157\144<",PropWildcardSubscriptionAvailable +// 58,PropMessageExpiryInterval 16260,PropRetainAvailable 130,PropAuthenticationMethod +// "\"\187\183\218\237\174\186\161K\CAN\236V\153\227",PropMaximumQoS 17,PropAuthenticationData +// "\190\140\f",PropPayloadFormatIndicator 52,PropRequestProblemInformation 200,PropSessionExpiryInterval +// 11292,PropPayloadFormatIndicator 217,PropAssignedClientIdentifier +// "\153\159m+\233\f/,qrA\217\151%<@\253\170\134>I\137",PropMaximumQoS 157,PropServerKeepAlive +// 21812,PropRequestProblemInformation 111,PropResponseInformation "hw\171",PropAuthenticationData +// "\214",PropReceiveMaximum 30617]} TEST(Publish5QCTest, Encode13) { -uint8_t pkt[] = {0x32, 0xd1, 0x1, 0x0, 0x5, 0xa, 0x9f, 0x8f, 0xa2, 0xd2, 0xe, 0x7, 0xbd, 0x1, 0x23, 0x41, 0xe2, 0x1, 0xa1, 0x18, 0x0, 0x0, 0x27, 0x8d, 0x22, 0x26, 0xd7, 0x12, 0x0, 0x11, 0xa6, 0x7d, 0x62, 0x83, 0xfb, 0xf, 0xee, 0x8e, 0x3b, 0xe3, 0x4b, 0x88, 0x54, 0x87, 0x56, 0xf7, 0xa1, 0x26, 0x0, 0x0, 0x0, 0xb, 0x1f, 0x26, 0xd6, 0x6b, 0x45, 0x80, 0x71, 0xc9, 0xc1, 0x60, 0x37, 0xb, 0xe, 0x1c, 0x0, 0x6, 0x2, 0x67, 0x34, 0xb, 0x7e, 0x16, 0x3, 0x0, 0x6, 0xb4, 0x1d, 0xa1, 0x33, 0x9e, 0xf9, 0x3, 0x0, 0x17, 0x73, 0x2b, 0x89, 0x7c, 0x38, 0xd, 0x27, 0x26, 0xe7, 0x44, 0x3d, 0x37, 0xea, 0x46, 0xf0, 0x55, 0x50, 0xfa, 0x51, 0xf9, 0xdf, 0x78, 0x6d, 0x2a, 0x78, 0x25, 0x94, 0x21, 0x53, 0x7a, 0x21, 0x3e, 0x8, 0x9, 0x0, 0x4, 0x16, 0x91, 0xda, 0x85, 0x24, 0xf9, 0x25, 0x44, 0x1c, 0x0, 0x14, 0xd6, 0xa3, 0x3f, 0x58, 0xd0, 0x89, 0x9, 0x4c, 0xcc, 0xf9, 0x96, 0xc1, 0x8a, 0x43, 0x1f, 0xdf, 0xa7, 0xf7, 0xe8, 0x3d, 0x28, 0x2a, 0x2, 0x0, 0x0, 0x3c, 0x39, 0x9, 0x0, 0x13, 0xea, 0x96, 0xca, 0x38, 0xd0, 0x28, 0xcc, 0x8e, 0x26, 0xbe, 0x24, 0x7c, 0x16, 0x67, 0x59, 0x40, 0xdd, 0xa2, 0xa4, 0x22, 0x3d, 0x7d, 0x3, 0x0, 0x4, 0x59, 0x76, 0x77, 0x77, 0x11, 0x0, 0x0, 0x7d, 0xca, 0x1, 0xe5, 0x1a, 0x0, 0x1, 0xa4, 0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; - uint8_t topic_bytes[] = {0xa, 0x9f, 0x8f, 0xa2, 0xd2}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = false; -uint8_t msg_bytes[] = {0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 9; + uint8_t pkt[] = { + 0x3d, 0xf4, 0x1, 0x0, 0x1a, 0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, 0x21, 0x6e, 0xd, 0x5a, + 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, 0x32, 0x7e, 0x21, 0x54, 0xbe, 0x1, 0x29, 0x22, 0x2, + 0x0, 0x0, 0x2e, 0x73, 0x1a, 0x0, 0x1e, 0x2d, 0xe1, 0x5d, 0xf7, 0x61, 0x46, 0x71, 0xb0, 0xf4, 0x67, 0x5b, 0x16, + 0x81, 0x83, 0xa1, 0xa4, 0x9a, 0x2d, 0xc, 0x81, 0x93, 0x2a, 0x9a, 0x4d, 0xe1, 0xf2, 0xa9, 0xed, 0x5, 0x5a, 0x29, + 0xf9, 0x3, 0x0, 0x1e,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x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, 0x32, 0x7e}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, 0x2, + 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 22; + + uint8_t bytesprops0[] = {0x2d, 0xe1, 0x5d, 0xf7, 0x61, 0x46, 0x71, 0xb0, 0xf4, 0x67, 0x5b, 0x16, 0x81, 0x83, 0xa1, + 0xa4, 0x9a, 0x2d, 0xc, 0x81, 0x93, 0x2a, 0x9a, 0x4d, 0xe1, 0xf2, 0xa9, 0xed, 0x5, 0x5a}; + uint8_t bytesprops1[] = {0xa4, 0x4b, 0x49, 0xc0, 0x8, 0x1d, 0x57, 0x22, 0x8f, 0x4f, 0x89, 0xc5, 0x17, 0x68, 0x4d, + 0x4c, 0x38, 0xdf, 0x91, 0x1e, 0x1f, 0xb5, 0x81, 0x2, 0x48, 0x63, 0x3c, 0xf3, 0xa5, 0xe1}; + uint8_t bytesprops2[] = {0x88, 0x30, 0xf4, 0xe9, 0xa6, 0x3d, 0x42, 0x6b, 0x25, 0x36, 0x39, 0xf5, 0xd3, 0x7c}; + uint8_t bytesprops3[] = {0x4a, 0xe9, 0x9d, 0x90, 0x3c}; + uint8_t bytesprops4[] = {0x22, 0xbb, 0xb7, 0xda, 0xed, 0xae, 0xba, 0xa1, 0x4b, 0x18, 0xec, 0x56, 0x99, 0xe3}; + uint8_t bytesprops5[] = {0xbe, 0x8c, 0xc}; + uint8_t bytesprops6[] = {0x99, 0x9f, 0x6d, 0x2b, 0xe9, 0xc, 0x2f, 0x2c, 0x71, 0x72, 0x41, + 0xd9, 0x97, 0x25, 0x3c, 0x40, 0xfd, 0xaa, 0x86, 0x3e, 0x49, 0x89}; + uint8_t bytesprops7[] = {0x68, 0x77, 0xab}; + uint8_t bytesprops8[] = {0xd6}; - uint8_t bytesprops0[] = {0xa6, 0x7d, 0x62, 0x83, 0xfb, 0xf, 0xee, 0x8e, 0x3b, 0xe3, 0x4b, 0x88, 0x54, 0x87, 0x56, 0xf7, 0xa1}; - uint8_t bytesprops2[] = {0x1f, 0x26, 0xd6, 0x6b, 0x45, 0x80, 0x71, 0xc9, 0xc1, 0x60, 0x37}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops3[] = {0x2, 0x67, 0x34, 0xb, 0x7e, 0x16}; - uint8_t bytesprops4[] = {0xb4, 0x1d, 0xa1, 0x33, 0x9e, 0xf9}; - uint8_t bytesprops5[] = {0x73, 0x2b, 0x89, 0x7c, 0x38, 0xd, 0x27, 0x26, 0xe7, 0x44, 0x3d, 0x37, 0xea, 0x46, 0xf0, 0x55, 0x50, 0xfa, 0x51, 0xf9, 0xdf, 0x78, 0x6d}; - uint8_t bytesprops6[] = {0x16, 0x91, 0xda, 0x85}; - uint8_t bytesprops7[] = {0xd6, 0xa3, 0x3f, 0x58, 0xd0, 0x89, 0x9, 0x4c, 0xcc, 0xf9, 0x96, 0xc1, 0x8a, 0x43, 0x1f, 0xdf, 0xa7, 0xf7, 0xe8, 0x3d}; - uint8_t bytesprops8[] = {0xea, 0x96, 0xca, 0x38, 0xd0, 0x28, 0xcc, 0x8e, 0x26, 0xbe, 0x24, 0x7c, 0x16, 0x67, 0x59, 0x40, 0xdd, 0xa2, 0xa4}; - uint8_t bytesprops9[] = {0x59, 0x76, 0x77, 0x77}; - uint8_t bytesprops10[] = {0xa4}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16866}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10125}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9943}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={0, (char*)&bytesprops1}, .v={11, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21370}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15880}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15417}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15741}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32202}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops10}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11891}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16260}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11292}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21812}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30617}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 3591, topic, msg, props); + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 8532, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\n\159\143\162\210", _pubPktID = 3591, _pubBody = "\156|7\ETB|\195\202\&4y", _pubProps = [PropTopicAlias 16866,PropPayloadFormatIndicator 161,PropWillDelayInterval 10125,PropTopicAliasMaximum 9943,PropAssignedClientIdentifier "\166}b\131\251\SI\238\142;\227K\136T\135V\247\161",PropUserProperty "" "\US&\214kE\128q\201\193`7",PropSubscriptionIdentifier 14,PropServerReference "\STXg4\v~\SYN",PropContentType "\180\GS\161\&3\158\249",PropContentType "s+\137|8\r'&\231D=7\234F\240UP\250Q\249\223xm",PropSharedSubscriptionAvailable 120,PropRetainAvailable 148,PropReceiveMaximum 21370,PropReceiveMaximum 15880,PropCorrelationData "\SYN\145\218\133",PropMaximumQoS 249,PropRetainAvailable 68,PropServerReference "\214\163?X\208\137\tL\204\249\150\193\138C\US\223\167\247\232=",PropWildcardSubscriptionAvailable 42,PropMessageExpiryInterval 15417,PropCorrelationData "\234\150\202\&8\208(\204\142&\190$|\SYNgY@\221\162\164",PropTopicAliasMaximum 15741,PropContentType "Yvww",PropSessionExpiryInterval 32202,PropPayloadFormatIndicator 229,PropResponseInformation "\164"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "-\224\164\222\163\DLE\224\218\229\CAN!n\rZ\193Y\DC3r\129\219T\172\139\252\&2~", _pubPktID = 8532, _pubBody = +// "\145b$\DEL\237\176\245E\250\186\STX\US|\163\f\221\190&\238\vu\US", _pubProps = [PropSubscriptionIdentifierAvailable +// 34,PropMessageExpiryInterval 11891,PropResponseInformation +// "-\225]\247aFq\176\244g[\SYN\129\131\161\164\154-\f\129\147*\154M\225\242\169\237\ENQZ",PropSubscriptionIdentifierAvailable +// 249,PropContentType +// "\164KI\192\b\GSW\"\143O\137\197\ETBhML8\223\145\RS\US\181\129\STXHc<\243\165\225",PropAuthenticationMethod +// "\136\&0\244\233\166=Bk%69\245\211|",PropResponseInformation "J\233\157\144<",PropWildcardSubscriptionAvailable +// 58,PropMessageExpiryInterval 16260,PropRetainAvailable 130,PropAuthenticationMethod +// "\"\187\183\218\237\174\186\161K\CAN\236V\153\227",PropMaximumQoS 17,PropAuthenticationData +// "\190\140\f",PropPayloadFormatIndicator 52,PropRequestProblemInformation 200,PropSessionExpiryInterval +// 11292,PropPayloadFormatIndicator 217,PropAssignedClientIdentifier +// "\153\159m+\233\f/,qrA\217\151%<@\253\170\134>I\137",PropMaximumQoS 157,PropServerKeepAlive +// 21812,PropRequestProblemInformation 111,PropResponseInformation "hw\171",PropAuthenticationData +// "\214",PropReceiveMaximum 30617]} TEST(Publish5QCTest, Decode13) { -uint8_t pkt[] = {0x32, 0xd1, 0x1, 0x0, 0x5, 0xa, 0x9f, 0x8f, 0xa2, 0xd2, 0xe, 0x7, 0xbd, 0x1, 0x23, 0x41, 0xe2, 0x1, 0xa1, 0x18, 0x0, 0x0, 0x27, 0x8d, 0x22, 0x26, 0xd7, 0x12, 0x0, 0x11, 0xa6, 0x7d, 0x62, 0x83, 0xfb, 0xf, 0xee, 0x8e, 0x3b, 0xe3, 0x4b, 0x88, 0x54, 0x87, 0x56, 0xf7, 0xa1, 0x26, 0x0, 0x0, 0x0, 0xb, 0x1f, 0x26, 0xd6, 0x6b, 0x45, 0x80, 0x71, 0xc9, 0xc1, 0x60, 0x37, 0xb, 0xe, 0x1c, 0x0, 0x6, 0x2, 0x67, 0x34, 0xb, 0x7e, 0x16, 0x3, 0x0, 0x6, 0xb4, 0x1d, 0xa1, 0x33, 0x9e, 0xf9, 0x3, 0x0, 0x17, 0x73, 0x2b, 0x89, 0x7c, 0x38, 0xd, 0x27, 0x26, 0xe7, 0x44, 0x3d, 0x37, 0xea, 0x46, 0xf0, 0x55, 0x50, 0xfa, 0x51, 0xf9, 0xdf, 0x78, 0x6d, 0x2a, 0x78, 0x25, 0x94, 0x21, 0x53, 0x7a, 0x21, 0x3e, 0x8, 0x9, 0x0, 0x4, 0x16, 0x91, 0xda, 0x85, 0x24, 0xf9, 0x25, 0x44, 0x1c, 0x0, 0x14, 0xd6, 0xa3, 0x3f, 0x58, 0xd0, 0x89, 0x9, 0x4c, 0xcc, 0xf9, 0x96, 0xc1, 0x8a, 0x43, 0x1f, 0xdf, 0xa7, 0xf7, 0xe8, 0x3d, 0x28, 0x2a, 0x2, 0x0, 0x0, 0x3c, 0x39, 0x9, 0x0, 0x13, 0xea, 0x96, 0xca, 0x38, 0xd0, 0x28, 0xcc, 0x8e, 0x26, 0xbe, 0x24, 0x7c, 0x16, 0x67, 0x59, 0x40, 0xdd, 0xa2, 0xa4, 0x22, 0x3d, 0x7d, 0x3, 0x0, 0x4, 0x59, 0x76, 0x77, 0x77, 0x11, 0x0, 0x0, 0x7d, 0xca, 0x1, 0xe5, 0x1a, 0x0, 0x1, 0xa4, 0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa, 0x9f, 0x8f, 0xa2, 0xd2}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9c, 0x7c, 0x37, 0x17, 0x7c, 0xc3, 0xca, 0x34, 0x79}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 3591); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); -EXPECT_EQ(msg.payload_len, 9); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = { + 0x3d, 0xf4, 0x1, 0x0, 0x1a, 0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, 0x21, 0x6e, 0xd, 0x5a, + 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, 0x32, 0x7e, 0x21, 0x54, 0xbe, 0x1, 0x29, 0x22, 0x2, + 0x0, 0x0, 0x2e, 0x73, 0x1a, 0x0, 0x1e, 0x2d, 0xe1, 0x5d, 0xf7, 0x61, 0x46, 0x71, 0xb0, 0xf4, 0x67, 0x5b, 0x16, + 0x81, 0x83, 0xa1, 0xa4, 0x9a, 0x2d, 0xc, 0x81, 0x93, 0x2a, 0x9a, 0x4d, 0xe1, 0xf2, 0xa9, 0xed, 0x5, 0x5a, 0x29, + 0xf9, 0x3, 0x0, 0x1e, 0xa4, 0x4b, 0x49, 0xc0, 0x8, 0x1d, 0x57, 0x22, 0x8f, 0x4f, 0x89, 0xc5, 0x17, 0x68, 0x4d, + 0x4c, 0x38, 0xdf, 0x91, 0x1e, 0x1f, 0xb5, 0x81, 0x2, 0x48, 0x63, 0x3c, 0xf3, 0xa5, 0xe1, 0x15, 0x0, 0xe, 0x88, + 0x30, 0xf4, 0xe9, 0xa6, 0x3d, 0x42, 0x6b, 0x25, 0x36, 0x39, 0xf5, 0xd3, 0x7c, 0x1a, 0x0, 0x5, 0x4a, 0xe9, 0x9d, + 0x90, 0x3c, 0x28, 0x3a, 0x2, 0x0, 0x0, 0x3f, 0x84, 0x25, 0x82, 0x15, 0x0, 0xe, 0x22, 0xbb, 0xb7, 0xda, 0xed, + 0xae, 0xba, 0xa1, 0x4b, 0x18, 0xec, 0x56, 0x99, 0xe3, 0x24, 0x11, 0x16, 0x0, 0x3, 0xbe, 0x8c, 0xc, 0x1, 0x34, + 0x17, 0xc8, 0x11, 0x0, 0x0, 0x2c, 0x1c, 0x1, 0xd9, 0x12, 0x0, 0x16, 0x99, 0x9f, 0x6d, 0x2b, 0xe9, 0xc, 0x2f, + 0x2c, 0x71, 0x72, 0x41, 0xd9, 0x97, 0x25, 0x3c, 0x40, 0xfd, 0xaa, 0x86, 0x3e, 0x49, 0x89, 0x24, 0x9d, 0x13, 0x55, + 0x34, 0x17, 0x6f, 0x1a, 0x0, 0x3, 0x68, 0x77, 0xab, 0x16, 0x0, 0x1, 0xd6, 0x21, 0x77, 0x99, 0x91, 0x62, 0x24, + 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, 0x2, 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, 0x21, 0x6e, 0xd, + 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, 0x32, 0x7e}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, 0x2, + 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 8532); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "8(\GS\144\187\237\&8\196sz", +// _pubPktID = 0, _pubBody = "0zBlyt\159", _pubProps = [PropPayloadFormatIndicator 91,PropRequestProblemInformation +// 77,PropContentType +// "\DC24\251\ETB\ETXn\ENQ\ACK\193\242\131\218\t5\168\152\182\138\170\fJ",PropRequestProblemInformation +// 91,PropMaximumQoS 160,PropTopicAliasMaximum 30380,PropServerReference "",PropReceiveMaximum 26494,PropReceiveMaximum +// 31778,PropResponseInformation "\154\139\156\128?",PropSubscriptionIdentifier 28,PropRetainAvailable +// 93,PropAuthenticationData "\173?",PropReceiveMaximum 10352,PropTopicAlias 27723,PropMessageExpiryInterval +// 1735,PropMessageExpiryInterval 5242,PropTopicAliasMaximum 13186,PropCorrelationData +// "5\217\230;g)\247\203)\151",PropAuthenticationData +// "\144\144c\202x(\237O\236\177\201\166?\230\233\&3\152\146x\144\184",PropSharedSubscriptionAvailable +// 48,PropRetainAvailable 107,PropUserProperty "\ACK<\227\130\129%\141" "1\203\190\US",PropRetainAvailable 90]} +TEST(Publish5QCTest, Encode14) { + uint8_t pkt[] = {0x39, 0xa0, 0x1, 0x0, 0xa, 0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a, 0x8b, 0x1, + 0x1, 0x5b, 0x17, 0x4d, 0x3, 0x0, 0x15, 0x12, 0x34, 0xfb, 0x17, 0x3, 0x6e, 0x5, 0x6, 0xc1, 0xf2, + 0x83, 0xda, 0x9, 0x35, 0xa8, 0x98, 0xb6, 0x8a, 0xaa, 0xc, 0x4a, 0x17, 0x5b, 0x24, 0xa0, 0x22, 0x76, + 0xac, 0x1c, 0x0, 0x0, 0x21, 0x67, 0x7e, 0x21, 0x7c, 0x22, 0x1a, 0x0, 0x5, 0x9a, 0x8b, 0x9c, 0x80, + 0x3f, 0xb, 0x1c, 0x25, 0x5d, 0x16, 0x0, 0x2, 0xad, 0x3f, 0x21, 0x28, 0x70, 0x23, 0x6c, 0x4b, 0x2, + 0x0, 0x0, 0x6, 0xc7, 0x2, 0x0, 0x0, 0x14, 0x7a, 0x22, 0x33, 0x82, 0x9, 0x0, 0xa, 0x35, 0xd9, + 0xe6, 0x3b, 0x67, 0x29, 0xf7, 0xcb, 0x29, 0x97, 0x16, 0x0, 0x15, 0x90, 0x90, 0x63, 0xca, 0x78, 0x28, + 0xed, 0x4f, 0xec, 0xb1, 0xc9, 0xa6, 0x3f, 0xe6, 0xe9, 0x33, 0x98, 0x92, 0x78, 0x90, 0xb8, 0x2a, 0x30, + 0x25, 0x6b, 0x26, 0x0, 0x7, 0x6, 0x3c, 0xe3, 0x82, 0x81, 0x25, 0x8d, 0x0, 0x4, 0x31, 0xcb, 0xbe, + 0x1f, 0x25, 0x5a, 0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + uint8_t topic_bytes[] = {0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 7; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\158\ESC\165s\240j\195I_\176\246\204\148I\213T\244\169E", _pubPktID = 15997, _pubBody = "tS\247\226P\227\&3\NUL\222\DC37I\219'", _pubProps = [PropAuthenticationData "Z\144(\SO\168[T\179\224`}&\140\218\195",PropSubscriptionIdentifier 18,PropContentType "`.\177\&6C)4\240\226\GS\ENQ\135J\160=]]\EOT9\153\204/,\212L\129\248O",PropAuthenticationData "\188U\232\SUB\163\151;\177Z\222\t\STX\131]\245\158\&6Y\140",PropTopicAlias 6708,PropReceiveMaximum 12966,PropMaximumQoS 54,PropServerReference "o\180B;\169\150\161\FS\DC2jtr\154\150",PropAuthenticationData "V\138\t\160\208\SYN\DEL@\137\181Iz\238\240\US\213\205\212",PropWildcardSubscriptionAvailable 32,PropRequestProblemInformation 34,PropSubscriptionIdentifierAvailable 138]} -TEST(Publish5QCTest, Encode14) { -uint8_t pkt[] = {0x33, 0xa3, 0x1, 0x0, 0x13, 0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45, 0x3e, 0x7d, 0x7d, 0x16, 0x0, 0xf, 0x5a, 0x90, 0x28, 0xe, 0xa8, 0x5b, 0x54, 0xb3, 0xe0, 0x60, 0x7d, 0x26, 0x8c, 0xda, 0xc3, 0xb, 0x12, 0x3, 0x0, 0x1c, 0x60, 0x2e, 0xb1, 0x36, 0x43, 0x29, 0x34, 0xf0, 0xe2, 0x1d, 0x5, 0x87, 0x4a, 0xa0, 0x3d, 0x5d, 0x5d, 0x4, 0x39, 0x99, 0xcc, 0x2f, 0x2c, 0xd4, 0x4c, 0x81, 0xf8, 0x4f, 0x16, 0x0, 0x13, 0xbc, 0x55, 0xe8, 0x1a, 0xa3, 0x97, 0x3b, 0xb1, 0x5a, 0xde, 0x9, 0x2, 0x83, 0x5d, 0xf5, 0x9e, 0x36, 0x59, 0x8c, 0x23, 0x1a, 0x34, 0x21, 0x32, 0xa6, 0x24, 0x36, 0x1c, 0x0, 0xe, 0x6f, 0xb4, 0x42, 0x3b, 0xa9, 0x96, 0xa1, 0x1c, 0x12, 0x6a, 0x74, 0x72, 0x9a, 0x96, 0x16, 0x0, 0x12, 0x56, 0x8a, 0x9, 0xa0, 0xd0, 0x16, 0x7f, 0x40, 0x89, 0xb5, 0x49, 0x7a, 0xee, 0xf0, 0x1f, 0xd5, 0xcd, 0xd4, 0x28, 0x20, 0x17, 0x22, 0x29, 0x8a, 0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; - uint8_t topic_bytes[] = {0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t bytesprops0[] = {0x12, 0x34, 0xfb, 0x17, 0x3, 0x6e, 0x5, 0x6, 0xc1, 0xf2, 0x83, + 0xda, 0x9, 0x35, 0xa8, 0x98, 0xb6, 0x8a, 0xaa, 0xc, 0x4a}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x9a, 0x8b, 0x9c, 0x80, 0x3f}; + uint8_t bytesprops3[] = {0xad, 0x3f}; + uint8_t bytesprops4[] = {0x35, 0xd9, 0xe6, 0x3b, 0x67, 0x29, 0xf7, 0xcb, 0x29, 0x97}; + uint8_t bytesprops5[] = {0x90, 0x90, 0x63, 0xca, 0x78, 0x28, 0xed, 0x4f, 0xec, 0xb1, 0xc9, + 0xa6, 0x3f, 0xe6, 0xe9, 0x33, 0x98, 0x92, 0x78, 0x90, 0xb8}; + uint8_t bytesprops7[] = {0x31, 0xcb, 0xbe, 0x1f}; + uint8_t bytesprops6[] = {0x6, 0x3c, 0xe3, 0x82, 0x81, 0x25, 0x8d}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 14; - - uint8_t bytesprops0[] = {0x5a, 0x90, 0x28, 0xe, 0xa8, 0x5b, 0x54, 0xb3, 0xe0, 0x60, 0x7d, 0x26, 0x8c, 0xda, 0xc3}; - uint8_t bytesprops1[] = {0x60, 0x2e, 0xb1, 0x36, 0x43, 0x29, 0x34, 0xf0, 0xe2, 0x1d, 0x5, 0x87, 0x4a, 0xa0, 0x3d, 0x5d, 0x5d, 0x4, 0x39, 0x99, 0xcc, 0x2f, 0x2c, 0xd4, 0x4c, 0x81, 0xf8, 0x4f}; - uint8_t bytesprops2[] = {0xbc, 0x55, 0xe8, 0x1a, 0xa3, 0x97, 0x3b, 0xb1, 0x5a, 0xde, 0x9, 0x2, 0x83, 0x5d, 0xf5, 0x9e, 0x36, 0x59, 0x8c}; - uint8_t bytesprops3[] = {0x6f, 0xb4, 0x42, 0x3b, 0xa9, 0x96, 0xa1, 0x1c, 0x12, 0x6a, 0x74, 0x72, 0x9a, 0x96}; - uint8_t bytesprops4[] = {0x56, 0x8a, 0x9, 0xa0, 0xd0, 0x16, 0x7f, 0x40, 0x89, 0xb5, 0x49, 0x7a, 0xee, 0xf0, 0x1f, 0xd5, 0xcd, 0xd4}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6708}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12966}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 138}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30380}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26494}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31778}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10352}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27723}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1735}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5242}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13186}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops6}, .v = {4, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15997, topic, msg, props); + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\158\ESC\165s\240j\195I_\176\246\204\148I\213T\244\169E", _pubPktID = 15997, _pubBody = "tS\247\226P\227\&3\NUL\222\DC37I\219'", _pubProps = [PropAuthenticationData "Z\144(\SO\168[T\179\224`}&\140\218\195",PropSubscriptionIdentifier 18,PropContentType "`.\177\&6C)4\240\226\GS\ENQ\135J\160=]]\EOT9\153\204/,\212L\129\248O",PropAuthenticationData "\188U\232\SUB\163\151;\177Z\222\t\STX\131]\245\158\&6Y\140",PropTopicAlias 6708,PropReceiveMaximum 12966,PropMaximumQoS 54,PropServerReference "o\180B;\169\150\161\FS\DC2jtr\154\150",PropAuthenticationData "V\138\t\160\208\SYN\DEL@\137\181Iz\238\240\US\213\205\212",PropWildcardSubscriptionAvailable 32,PropRequestProblemInformation 34,PropSubscriptionIdentifierAvailable 138]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "8(\GS\144\187\237\&8\196sz", +// _pubPktID = 0, _pubBody = "0zBlyt\159", _pubProps = [PropPayloadFormatIndicator 91,PropRequestProblemInformation +// 77,PropContentType +// "\DC24\251\ETB\ETXn\ENQ\ACK\193\242\131\218\t5\168\152\182\138\170\fJ",PropRequestProblemInformation +// 91,PropMaximumQoS 160,PropTopicAliasMaximum 30380,PropServerReference "",PropReceiveMaximum 26494,PropReceiveMaximum +// 31778,PropResponseInformation "\154\139\156\128?",PropSubscriptionIdentifier 28,PropRetainAvailable +// 93,PropAuthenticationData "\173?",PropReceiveMaximum 10352,PropTopicAlias 27723,PropMessageExpiryInterval +// 1735,PropMessageExpiryInterval 5242,PropTopicAliasMaximum 13186,PropCorrelationData +// "5\217\230;g)\247\203)\151",PropAuthenticationData +// "\144\144c\202x(\237O\236\177\201\166?\230\233\&3\152\146x\144\184",PropSharedSubscriptionAvailable +// 48,PropRetainAvailable 107,PropUserProperty "\ACK<\227\130\129%\141" "1\203\190\US",PropRetainAvailable 90]} TEST(Publish5QCTest, Decode14) { -uint8_t pkt[] = {0x33, 0xa3, 0x1, 0x0, 0x13, 0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45, 0x3e, 0x7d, 0x7d, 0x16, 0x0, 0xf, 0x5a, 0x90, 0x28, 0xe, 0xa8, 0x5b, 0x54, 0xb3, 0xe0, 0x60, 0x7d, 0x26, 0x8c, 0xda, 0xc3, 0xb, 0x12, 0x3, 0x0, 0x1c, 0x60, 0x2e, 0xb1, 0x36, 0x43, 0x29, 0x34, 0xf0, 0xe2, 0x1d, 0x5, 0x87, 0x4a, 0xa0, 0x3d, 0x5d, 0x5d, 0x4, 0x39, 0x99, 0xcc, 0x2f, 0x2c, 0xd4, 0x4c, 0x81, 0xf8, 0x4f, 0x16, 0x0, 0x13, 0xbc, 0x55, 0xe8, 0x1a, 0xa3, 0x97, 0x3b, 0xb1, 0x5a, 0xde, 0x9, 0x2, 0x83, 0x5d, 0xf5, 0x9e, 0x36, 0x59, 0x8c, 0x23, 0x1a, 0x34, 0x21, 0x32, 0xa6, 0x24, 0x36, 0x1c, 0x0, 0xe, 0x6f, 0xb4, 0x42, 0x3b, 0xa9, 0x96, 0xa1, 0x1c, 0x12, 0x6a, 0x74, 0x72, 0x9a, 0x96, 0x16, 0x0, 0x12, 0x56, 0x8a, 0x9, 0xa0, 0xd0, 0x16, 0x7f, 0x40, 0x89, 0xb5, 0x49, 0x7a, 0xee, 0xf0, 0x1f, 0xd5, 0xcd, 0xd4, 0x28, 0x20, 0x17, 0x22, 0x29, 0x8a, 0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9e, 0x1b, 0xa5, 0x73, 0xf0, 0x6a, 0xc3, 0x49, 0x5f, 0xb0, 0xf6, 0xcc, 0x94, 0x49, 0xd5, 0x54, 0xf4, 0xa9, 0x45}; - lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x74, 0x53, 0xf7, 0xe2, 0x50, 0xe3, 0x33, 0x0, 0xde, 0x13, 0x37, 0x49, 0xdb, 0x27}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 15997); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); -EXPECT_EQ(msg.payload_len, 14); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x39, 0xa0, 0x1, 0x0, 0xa, 0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a, 0x8b, 0x1, + 0x1, 0x5b, 0x17, 0x4d, 0x3, 0x0, 0x15, 0x12, 0x34, 0xfb, 0x17, 0x3, 0x6e, 0x5, 0x6, 0xc1, 0xf2, + 0x83, 0xda, 0x9, 0x35, 0xa8, 0x98, 0xb6, 0x8a, 0xaa, 0xc, 0x4a, 0x17, 0x5b, 0x24, 0xa0, 0x22, 0x76, + 0xac, 0x1c, 0x0, 0x0, 0x21, 0x67, 0x7e, 0x21, 0x7c, 0x22, 0x1a, 0x0, 0x5, 0x9a, 0x8b, 0x9c, 0x80, + 0x3f, 0xb, 0x1c, 0x25, 0x5d, 0x16, 0x0, 0x2, 0xad, 0x3f, 0x21, 0x28, 0x70, 0x23, 0x6c, 0x4b, 0x2, + 0x0, 0x0, 0x6, 0xc7, 0x2, 0x0, 0x0, 0x14, 0x7a, 0x22, 0x33, 0x82, 0x9, 0x0, 0xa, 0x35, 0xd9, + 0xe6, 0x3b, 0x67, 0x29, 0xf7, 0xcb, 0x29, 0x97, 0x16, 0x0, 0x15, 0x90, 0x90, 0x63, 0xca, 0x78, 0x28, + 0xed, 0x4f, 0xec, 0xb1, 0xc9, 0xa6, 0x3f, 0xe6, 0xe9, 0x33, 0x98, 0x92, 0x78, 0x90, 0xb8, 0x2a, 0x30, + 0x25, 0x6b, 0x26, 0x0, 0x7, 0x6, 0x3c, 0xe3, 0x82, 0x81, 0x25, 0x8d, 0x0, 0x4, 0x31, 0xcb, 0xbe, + 0x1f, 0x25, 0x5a, 0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ")F\t\CAN\159&z\212\EOT\210y\239\190\EOT\131b\161\153I\235\162", _pubPktID = 2063, _pubBody = +// "\SUB\236\&0\ENQ\ACK1\246q@\SUB\224\&3{\175\RS\142k\"", _pubProps = [PropServerReference +// "\179\230jv\218d=N\245\220i\172\188\168mEau\252\DC1E\192\159\253?\150\167w",PropResponseTopic +// "^mt\fM\ESC\224\240\251c\240",PropTopicAliasMaximum 4110,PropAssignedClientIdentifier "\vP"]} +TEST(Publish5QCTest, Encode15) { + uint8_t pkt[] = {0x34, 0x61, 0x0, 0x15, 0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, 0xef, 0xbe, + 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2, 0x8, 0xf, 0x35, 0x1c, 0x0, 0x1c, 0xb3, 0xe6, 0x6a, + 0x76, 0xda, 0x64, 0x3d, 0x4e, 0xf5, 0xdc, 0x69, 0xac, 0xbc, 0xa8, 0x6d, 0x45, 0x61, 0x75, 0xfc, 0x11, + 0x45, 0xc0, 0x9f, 0xfd, 0x3f, 0x96, 0xa7, 0x77, 0x8, 0x0, 0xb, 0x5e, 0x6d, 0x74, 0xc, 0x4d, 0x1b, + 0xe0, 0xf0, 0xfb, 0x63, 0xf0, 0x22, 0x10, 0xe, 0x12, 0x0, 0x2, 0xb, 0x50, 0x1a, 0xec, 0x30, 0x5, + 0x6, 0x31, 0xf6, 0x71, 0x40, 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + uint8_t topic_bytes[] = {0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, + 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x1a, 0xec, 0x30, 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, + 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 18; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\224\135\179\172\244\254\241]\218|\ESC\137/", _pubPktID = 30908, _pubBody = "\235c=\156\"\206\185spp`\235\216", _pubProps = [PropMessageExpiryInterval 6037,PropWillDelayInterval 28652,PropCorrelationData "\244zO@\192\189\&3)\US\177*\173\142\ENQ\144\218'\172\ETX\180O\DC3\156\205\206",PropSessionExpiryInterval 8920,PropWillDelayInterval 5875,PropSubscriptionIdentifier 9,PropReasonString "\166g\238\&9\US\DC2F\192dH\254\182\146\254",PropTopicAlias 32438,PropMessageExpiryInterval 10202,PropSubscriptionIdentifierAvailable 253,PropContentType "/\227\214\211",PropReasonString "K\182N",PropTopicAlias 10419,PropMessageExpiryInterval 18017,PropSubscriptionIdentifierAvailable 65,PropWillDelayInterval 743,PropRequestProblemInformation 232,PropSubscriptionIdentifierAvailable 126,PropRetainAvailable 132,PropRequestResponseInformation 184,PropReceiveMaximum 25871,PropMessageExpiryInterval 21303,PropCorrelationData "\211L\234\251\NAKtw\ETB\206L\157\190\244?2%\157",PropServerReference "\232T\205?\234\b\US{6\141\173\CAN(\GS\175/\238^\224\159R\244\130\208\202E",PropTopicAlias 15782,PropSharedSubscriptionAvailable 56]} -TEST(Publish5QCTest, Encode15) { -uint8_t pkt[] = {0x32, 0xd0, 0x1, 0x0, 0xe, 0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f, 0x78, 0xbc, 0xaf, 0x1, 0x2, 0x0, 0x0, 0x17, 0x95, 0x18, 0x0, 0x0, 0x6f, 0xec, 0x9, 0x0, 0x19, 0xf4, 0x7a, 0x4f, 0x40, 0xc0, 0xbd, 0x33, 0x29, 0x1f, 0xb1, 0x2a, 0xad, 0x8e, 0x5, 0x90, 0xda, 0x27, 0xac, 0x3, 0xb4, 0x4f, 0x13, 0x9c, 0xcd, 0xce, 0x11, 0x0, 0x0, 0x22, 0xd8, 0x18, 0x0, 0x0, 0x16, 0xf3, 0xb, 0x9, 0x1f, 0x0, 0xe, 0xa6, 0x67, 0xee, 0x39, 0x1f, 0x12, 0x46, 0xc0, 0x64, 0x48, 0xfe, 0xb6, 0x92, 0xfe, 0x23, 0x7e, 0xb6, 0x2, 0x0, 0x0, 0x27, 0xda, 0x29, 0xfd, 0x3, 0x0, 0x4, 0x2f, 0xe3, 0xd6, 0xd3, 0x1f, 0x0, 0x3, 0x4b, 0xb6, 0x4e, 0x23, 0x28, 0xb3, 0x2, 0x0, 0x0, 0x46, 0x61, 0x29, 0x41, 0x18, 0x0, 0x0, 0x2, 0xe7, 0x17, 0xe8, 0x29, 0x7e, 0x25, 0x84, 0x19, 0xb8, 0x21, 0x65, 0xf, 0x2, 0x0, 0x0, 0x53, 0x37, 0x9, 0x0, 0x11, 0xd3, 0x4c, 0xea, 0xfb, 0x15, 0x74, 0x77, 0x17, 0xce, 0x4c, 0x9d, 0xbe, 0xf4, 0x3f, 0x32, 0x25, 0x9d, 0x1c, 0x0, 0x1a, 0xe8, 0x54, 0xcd, 0x3f, 0xea, 0x8, 0x1f, 0x7b, 0x36, 0x8d, 0xad, 0x18, 0x28, 0x1d, 0xaf, 0x2f, 0xee, 0x5e, 0xe0, 0x9f, 0x52, 0xf4, 0x82, 0xd0, 0xca, 0x45, 0x23, 0x3d, 0xa6, 0x2a, 0x38, 0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; - uint8_t topic_bytes[] = {0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t bytesprops0[] = {0xb3, 0xe6, 0x6a, 0x76, 0xda, 0x64, 0x3d, 0x4e, 0xf5, 0xdc, 0x69, 0xac, 0xbc, 0xa8, + 0x6d, 0x45, 0x61, 0x75, 0xfc, 0x11, 0x45, 0xc0, 0x9f, 0xfd, 0x3f, 0x96, 0xa7, 0x77}; + uint8_t bytesprops1[] = {0x5e, 0x6d, 0x74, 0xc, 0x4d, 0x1b, 0xe0, 0xf0, 0xfb, 0x63, 0xf0}; + uint8_t bytesprops2[] = {0xb, 0x50}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = false; -uint8_t msg_bytes[] = {0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 13; - - uint8_t bytesprops0[] = {0xf4, 0x7a, 0x4f, 0x40, 0xc0, 0xbd, 0x33, 0x29, 0x1f, 0xb1, 0x2a, 0xad, 0x8e, 0x5, 0x90, 0xda, 0x27, 0xac, 0x3, 0xb4, 0x4f, 0x13, 0x9c, 0xcd, 0xce}; - uint8_t bytesprops1[] = {0xa6, 0x67, 0xee, 0x39, 0x1f, 0x12, 0x46, 0xc0, 0x64, 0x48, 0xfe, 0xb6, 0x92, 0xfe}; - uint8_t bytesprops2[] = {0x2f, 0xe3, 0xd6, 0xd3}; - uint8_t bytesprops3[] = {0x4b, 0xb6, 0x4e}; - uint8_t bytesprops4[] = {0xd3, 0x4c, 0xea, 0xfb, 0x15, 0x74, 0x77, 0x17, 0xce, 0x4c, 0x9d, 0xbe, 0xf4, 0x3f, 0x32, 0x25, 0x9d}; - uint8_t bytesprops5[] = {0xe8, 0x54, 0xcd, 0x3f, 0xea, 0x8, 0x1f, 0x7b, 0x36, 0x8d, 0xad, 0x18, 0x28, 0x1d, 0xaf, 0x2f, 0xee, 0x5e, 0xe0, 0x9f, 0x52, 0xf4, 0x82, 0xd0, 0xca, 0x45}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6037}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28652}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8920}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5875}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32438}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10202}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10419}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18017}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 743}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25871}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21303}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15782}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 56}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4110}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 30908, topic, msg, props); + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 2063, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\233\224\135\179\172\244\254\241]\218|\ESC\137/", _pubPktID = 30908, _pubBody = "\235c=\156\"\206\185spp`\235\216", _pubProps = [PropMessageExpiryInterval 6037,PropWillDelayInterval 28652,PropCorrelationData "\244zO@\192\189\&3)\US\177*\173\142\ENQ\144\218'\172\ETX\180O\DC3\156\205\206",PropSessionExpiryInterval 8920,PropWillDelayInterval 5875,PropSubscriptionIdentifier 9,PropReasonString "\166g\238\&9\US\DC2F\192dH\254\182\146\254",PropTopicAlias 32438,PropMessageExpiryInterval 10202,PropSubscriptionIdentifierAvailable 253,PropContentType "/\227\214\211",PropReasonString "K\182N",PropTopicAlias 10419,PropMessageExpiryInterval 18017,PropSubscriptionIdentifierAvailable 65,PropWillDelayInterval 743,PropRequestProblemInformation 232,PropSubscriptionIdentifierAvailable 126,PropRetainAvailable 132,PropRequestResponseInformation 184,PropReceiveMaximum 25871,PropMessageExpiryInterval 21303,PropCorrelationData "\211L\234\251\NAKtw\ETB\206L\157\190\244?2%\157",PropServerReference "\232T\205?\234\b\US{6\141\173\CAN(\GS\175/\238^\224\159R\244\130\208\202E",PropTopicAlias 15782,PropSharedSubscriptionAvailable 56]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// ")F\t\CAN\159&z\212\EOT\210y\239\190\EOT\131b\161\153I\235\162", _pubPktID = 2063, _pubBody = +// "\SUB\236\&0\ENQ\ACK1\246q@\SUB\224\&3{\175\RS\142k\"", _pubProps = [PropServerReference +// "\179\230jv\218d=N\245\220i\172\188\168mEau\252\DC1E\192\159\253?\150\167w",PropResponseTopic +// "^mt\fM\ESC\224\240\251c\240",PropTopicAliasMaximum 4110,PropAssignedClientIdentifier "\vP"]} TEST(Publish5QCTest, Decode15) { -uint8_t pkt[] = {0x32, 0xd0, 0x1, 0x0, 0xe, 0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f, 0x78, 0xbc, 0xaf, 0x1, 0x2, 0x0, 0x0, 0x17, 0x95, 0x18, 0x0, 0x0, 0x6f, 0xec, 0x9, 0x0, 0x19, 0xf4, 0x7a, 0x4f, 0x40, 0xc0, 0xbd, 0x33, 0x29, 0x1f, 0xb1, 0x2a, 0xad, 0x8e, 0x5, 0x90, 0xda, 0x27, 0xac, 0x3, 0xb4, 0x4f, 0x13, 0x9c, 0xcd, 0xce, 0x11, 0x0, 0x0, 0x22, 0xd8, 0x18, 0x0, 0x0, 0x16, 0xf3, 0xb, 0x9, 0x1f, 0x0, 0xe, 0xa6, 0x67, 0xee, 0x39, 0x1f, 0x12, 0x46, 0xc0, 0x64, 0x48, 0xfe, 0xb6, 0x92, 0xfe, 0x23, 0x7e, 0xb6, 0x2, 0x0, 0x0, 0x27, 0xda, 0x29, 0xfd, 0x3, 0x0, 0x4, 0x2f, 0xe3, 0xd6, 0xd3, 0x1f, 0x0, 0x3, 0x4b, 0xb6, 0x4e, 0x23, 0x28, 0xb3, 0x2, 0x0, 0x0, 0x46, 0x61, 0x29, 0x41, 0x18, 0x0, 0x0, 0x2, 0xe7, 0x17, 0xe8, 0x29, 0x7e, 0x25, 0x84, 0x19, 0xb8, 0x21, 0x65, 0xf, 0x2, 0x0, 0x0, 0x53, 0x37, 0x9, 0x0, 0x11, 0xd3, 0x4c, 0xea, 0xfb, 0x15, 0x74, 0x77, 0x17, 0xce, 0x4c, 0x9d, 0xbe, 0xf4, 0x3f, 0x32, 0x25, 0x9d, 0x1c, 0x0, 0x1a, 0xe8, 0x54, 0xcd, 0x3f, 0xea, 0x8, 0x1f, 0x7b, 0x36, 0x8d, 0xad, 0x18, 0x28, 0x1d, 0xaf, 0x2f, 0xee, 0x5e, 0xe0, 0x9f, 0x52, 0xf4, 0x82, 0xd0, 0xca, 0x45, 0x23, 0x3d, 0xa6, 0x2a, 0x38, 0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe9, 0xe0, 0x87, 0xb3, 0xac, 0xf4, 0xfe, 0xf1, 0x5d, 0xda, 0x7c, 0x1b, 0x89, 0x2f}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xeb, 0x63, 0x3d, 0x9c, 0x22, 0xce, 0xb9, 0x73, 0x70, 0x70, 0x60, 0xeb, 0xd8}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 30908); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); -EXPECT_EQ(msg.payload_len, 13); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x34, 0x61, 0x0, 0x15, 0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, 0xef, 0xbe, + 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2, 0x8, 0xf, 0x35, 0x1c, 0x0, 0x1c, 0xb3, 0xe6, 0x6a, + 0x76, 0xda, 0x64, 0x3d, 0x4e, 0xf5, 0xdc, 0x69, 0xac, 0xbc, 0xa8, 0x6d, 0x45, 0x61, 0x75, 0xfc, 0x11, + 0x45, 0xc0, 0x9f, 0xfd, 0x3f, 0x96, 0xa7, 0x77, 0x8, 0x0, 0xb, 0x5e, 0x6d, 0x74, 0xc, 0x4d, 0x1b, + 0xe0, 0xf0, 0xfb, 0x63, 0xf0, 0x22, 0x10, 0xe, 0x12, 0x0, 0x2, 0xb, 0x50, 0x1a, 0xec, 0x30, 0x5, + 0x6, 0x31, 0xf6, 0x71, 0x40, 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\233\218E\235\207\216\&6b\236\246\&0?\169D\196\137\228\212\200\179\RS\159", _pubPktID = 7795, _pubBody = ")\a\246\&4J\134\237\148\159\143:\EOT\237lN\252D\144\179\163'7\208\193\240", _pubProps = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, + 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1a, 0xec, 0x30, 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, + 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 2063); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\\Z\DLE\\x\DC3\192\DLE", _pubPktID = +// 15081, _pubBody = "\213\141\182\137f\134\150z.K\232\224o\177\FS\156\198\158\CAN\ESC", _pubProps = [PropReceiveMaximum +// 14518,PropRequestResponseInformation 171,PropReceiveMaximum 527,PropAssignedClientIdentifier "\RSn",PropMaximumQoS +// 222,PropPayloadFormatIndicator 176,PropAuthenticationData "-\214\204Mp)\167\137 +// \168\158\STX\STX\214\SO*\241\SOH\190",PropSessionExpiryInterval 10088,PropMessageExpiryInterval +// 28009,PropPayloadFormatIndicator 206,PropTopicAlias 15441,PropWillDelayInterval 23877,PropContentType +// "\251\US\200b",PropSharedSubscriptionAvailable 0,PropSubscriptionIdentifier 12,PropCorrelationData +// "r\132n\170X\196\194\207U\167\ENQ\249\161\t\128\253\204",PropSharedSubscriptionAvailable 71]} TEST(Publish5QCTest, Encode16) { -uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x16, 0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f, 0x1e, 0x73, 0x0, 0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; - uint8_t topic_bytes[] = {0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x7d, 0x0, 0x8, 0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10, 0x3a, 0xe9, 0x5c, 0x21, + 0x38, 0xb6, 0x19, 0xab, 0x21, 0x2, 0xf, 0x12, 0x0, 0x2, 0x1e, 0x6e, 0x24, 0xde, 0x1, 0xb0, + 0x16, 0x0, 0x13, 0x2d, 0xd6, 0xcc, 0x4d, 0x70, 0x29, 0xa7, 0x89, 0x20, 0xa8, 0x9e, 0x2, 0x2, + 0xd6, 0xe, 0x2a, 0xf1, 0x1, 0xbe, 0x11, 0x0, 0x0, 0x27, 0x68, 0x2, 0x0, 0x0, 0x6d, 0x69, + 0x1, 0xce, 0x23, 0x3c, 0x51, 0x18, 0x0, 0x0, 0x5d, 0x45, 0x3, 0x0, 0x4, 0xfb, 0x1f, 0xc8, + 0x62, 0x2a, 0x0, 0xb, 0xc, 0x9, 0x0, 0x11, 0x72, 0x84, 0x6e, 0xaa, 0x58, 0xc4, 0xc2, 0xcf, + 0x55, 0xa7, 0x5, 0xf9, 0xa1, 0x9, 0x80, 0xfd, 0xcc, 0x2a, 0x47, 0xd5, 0x8d, 0xb6, 0x89, 0x66, + 0x86, 0x96, 0x7a, 0x2e, 0x4b, 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + uint8_t topic_bytes[] = {0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, + 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 20; + + uint8_t bytesprops0[] = {0x1e, 0x6e}; + uint8_t bytesprops1[] = {0x2d, 0xd6, 0xcc, 0x4d, 0x70, 0x29, 0xa7, 0x89, 0x20, 0xa8, + 0x9e, 0x2, 0x2, 0xd6, 0xe, 0x2a, 0xf1, 0x1, 0xbe}; + uint8_t bytesprops2[] = {0xfb, 0x1f, 0xc8, 0x62}; + uint8_t bytesprops3[] = {0x72, 0x84, 0x6e, 0xaa, 0x58, 0xc4, 0xc2, 0xcf, 0x55, + 0xa7, 0x5, 0xf9, 0xa1, 0x9, 0x80, 0xfd, 0xcc}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 25; - - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14518}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 527}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10088}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28009}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15441}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23877}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 71}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7795, topic, msg, props); + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15081, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\233\218E\235\207\216\&6b\236\246\&0?\169D\196\137\228\212\200\179\RS\159", _pubPktID = 7795, _pubBody = ")\a\246\&4J\134\237\148\159\143:\EOT\237lN\252D\144\179\163'7\208\193\240", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\\Z\DLE\\x\DC3\192\DLE", _pubPktID = +// 15081, _pubBody = "\213\141\182\137f\134\150z.K\232\224o\177\FS\156\198\158\CAN\ESC", _pubProps = [PropReceiveMaximum +// 14518,PropRequestResponseInformation 171,PropReceiveMaximum 527,PropAssignedClientIdentifier "\RSn",PropMaximumQoS +// 222,PropPayloadFormatIndicator 176,PropAuthenticationData "-\214\204Mp)\167\137 +// \168\158\STX\STX\214\SO*\241\SOH\190",PropSessionExpiryInterval 10088,PropMessageExpiryInterval +// 28009,PropPayloadFormatIndicator 206,PropTopicAlias 15441,PropWillDelayInterval 23877,PropContentType +// "\251\US\200b",PropSharedSubscriptionAvailable 0,PropSubscriptionIdentifier 12,PropCorrelationData +// "r\132n\170X\196\194\207U\167\ENQ\249\161\t\128\253\204",PropSharedSubscriptionAvailable 71]} TEST(Publish5QCTest, Decode16) { -uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x16, 0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f, 0x1e, 0x73, 0x0, 0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe9, 0xda, 0x45, 0xeb, 0xcf, 0xd8, 0x36, 0x62, 0xec, 0xf6, 0x30, 0x3f, 0xa9, 0x44, 0xc4, 0x89, 0xe4, 0xd4, 0xc8, 0xb3, 0x1e, 0x9f}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x29, 0x7, 0xf6, 0x34, 0x4a, 0x86, 0xed, 0x94, 0x9f, 0x8f, 0x3a, 0x4, 0xed, 0x6c, 0x4e, 0xfc, 0x44, 0x90, 0xb3, 0xa3, 0x27, 0x37, 0xd0, 0xc1, 0xf0}; - lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 7795); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); -EXPECT_EQ(msg.payload_len, 25); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x35, 0x7d, 0x0, 0x8, 0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10, 0x3a, 0xe9, 0x5c, 0x21, + 0x38, 0xb6, 0x19, 0xab, 0x21, 0x2, 0xf, 0x12, 0x0, 0x2, 0x1e, 0x6e, 0x24, 0xde, 0x1, 0xb0, + 0x16, 0x0, 0x13, 0x2d, 0xd6, 0xcc, 0x4d, 0x70, 0x29, 0xa7, 0x89, 0x20, 0xa8, 0x9e, 0x2, 0x2, + 0xd6, 0xe, 0x2a, 0xf1, 0x1, 0xbe, 0x11, 0x0, 0x0, 0x27, 0x68, 0x2, 0x0, 0x0, 0x6d, 0x69, + 0x1, 0xce, 0x23, 0x3c, 0x51, 0x18, 0x0, 0x0, 0x5d, 0x45, 0x3, 0x0, 0x4, 0xfb, 0x1f, 0xc8, + 0x62, 0x2a, 0x0, 0xb, 0xc, 0x9, 0x0, 0x11, 0x72, 0x84, 0x6e, 0xaa, 0x58, 0xc4, 0xc2, 0xcf, + 0x55, 0xa7, 0x5, 0xf9, 0xa1, 0x9, 0x80, 0xfd, 0xcc, 0x2a, 0x47, 0xd5, 0x8d, 0xb6, 0x89, 0x66, + 0x86, 0x96, 0x7a, 0x2e, 0x4b, 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "i\236\180\192[~\199\179\163\147g\v\219?\135\190L\237\DC1\STX`", _pubPktID = 2871, _pubBody = "\166\217", _pubProps = [PropUserProperty "\215|\bNh\138F\244s\162\207\164A\EMc\239\135" "H\f",PropResponseInformation "\211"]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, + 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 15081); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "~2\242\136\211*\DEL", _pubPktID = +// 30428, _pubBody = "\253ET\175\214\175\205\211w\196\ETX\f-\214\144\194", _pubProps = [PropServerKeepAlive +// 4003,PropMessageExpiryInterval 15782,PropRetainAvailable 134]} TEST(Publish5QCTest, Encode17) { -uint8_t pkt[] = {0x3d, 0x38, 0x0, 0x15, 0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60, 0xb, 0x37, 0x1c, 0x26, 0x0, 0x11, 0xd7, 0x7c, 0x8, 0x4e, 0x68, 0x8a, 0x46, 0xf4, 0x73, 0xa2, 0xcf, 0xa4, 0x41, 0x19, 0x63, 0xef, 0x87, 0x0, 0x2, 0x48, 0xc, 0x1a, 0x0, 0x1, 0xd3, 0xa6, 0xd9}; - uint8_t topic_bytes[] = {0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x26, 0x0, 0x7, 0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f, 0x76, 0xdc, 0xa, + 0x13, 0xf, 0xa3, 0x2, 0x0, 0x0, 0x3d, 0xa6, 0x25, 0x86, 0xfd, 0x45, 0x54, 0xaf, + 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + uint8_t topic_bytes[] = {0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0xa6, 0xd9}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 2; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xfd, 0x45, 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 16; - uint8_t bytesprops1[] = {0x48, 0xc}; - uint8_t bytesprops0[] = {0xd7, 0x7c, 0x8, 0x4e, 0x68, 0x8a, 0x46, 0xf4, 0x73, 0xa2, 0xcf, 0xa4, 0x41, 0x19, 0x63, 0xef, 0x87}; - uint8_t bytesprops2[] = {0xd3}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={17, (char*)&bytesprops0}, .v={2, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4003}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15782}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 134}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 2871, topic, msg, props); + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 30428, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "i\236\180\192[~\199\179\163\147g\v\219?\135\190L\237\DC1\STX`", _pubPktID = 2871, _pubBody = "\166\217", _pubProps = [PropUserProperty "\215|\bNh\138F\244s\162\207\164A\EMc\239\135" "H\f",PropResponseInformation "\211"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "~2\242\136\211*\DEL", _pubPktID = +// 30428, _pubBody = "\253ET\175\214\175\205\211w\196\ETX\f-\214\144\194", _pubProps = [PropServerKeepAlive +// 4003,PropMessageExpiryInterval 15782,PropRetainAvailable 134]} TEST(Publish5QCTest, Decode17) { -uint8_t pkt[] = {0x3d, 0x38, 0x0, 0x15, 0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60, 0xb, 0x37, 0x1c, 0x26, 0x0, 0x11, 0xd7, 0x7c, 0x8, 0x4e, 0x68, 0x8a, 0x46, 0xf4, 0x73, 0xa2, 0xcf, 0xa4, 0x41, 0x19, 0x63, 0xef, 0x87, 0x0, 0x2, 0x48, 0xc, 0x1a, 0x0, 0x1, 0xd3, 0xa6, 0xd9}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x69, 0xec, 0xb4, 0xc0, 0x5b, 0x7e, 0xc7, 0xb3, 0xa3, 0x93, 0x67, 0xb, 0xdb, 0x3f, 0x87, 0xbe, 0x4c, 0xed, 0x11, 0x2, 0x60}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa6, 0xd9}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 2871); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); -EXPECT_EQ(msg.payload_len, 2); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x3b, 0x26, 0x0, 0x7, 0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f, 0x76, 0xdc, 0xa, + 0x13, 0xf, 0xa3, 0x2, 0x0, 0x0, 0x3d, 0xa6, 0x25, 0x86, 0xfd, 0x45, 0x54, 0xaf, + 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfd, 0x45, 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, + 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 30428); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "dG\194+K1e\237n\253\EM\US\222\156\216K\173\158+\228\&9E\185\CAN\147`\203un\n", _pubPktID = 16078, _pubBody = "", +// _pubProps = [PropResponseTopic +// "\166\242\248\192\207\220\249z\141t\a`\222\EM\183Op(5\226QK'\245\150\nI\SOHR3",PropTopicAliasMaximum +// 26890,PropMaximumQoS 179,PropMessageExpiryInterval 8868,PropSubscriptionIdentifierAvailable 112,PropReasonString +// "\229\ENQ\190m\206\t\130\134\b\131\134\235+\166bi\138\163\172\186\NAKJ\a\SYN\138C\184K",PropRequestResponseInformation +// 172]} +TEST(Publish5QCTest, Encode18) { + uint8_t pkt[] = {0x32, 0x71, 0x0, 0x1e, 0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, + 0x9c, 0xd8, 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa, + 0x3e, 0xce, 0x4e, 0x8, 0x0, 0x1e, 0xa6, 0xf2, 0xf8, 0xc0, 0xcf, 0xdc, 0xf9, 0x7a, 0x8d, 0x74, 0x7, + 0x60, 0xde, 0x19, 0xb7, 0x4f, 0x70, 0x28, 0x35, 0xe2, 0x51, 0x4b, 0x27, 0xf5, 0x96, 0xa, 0x49, 0x1, + 0x52, 0x33, 0x22, 0x69, 0xa, 0x24, 0xb3, 0x2, 0x0, 0x0, 0x22, 0xa4, 0x29, 0x70, 0x1f, 0x0, 0x1c, + 0xe5, 0x5, 0xbe, 0x6d, 0xce, 0x9, 0x82, 0x86, 0x8, 0x83, 0x86, 0xeb, 0x2b, 0xa6, 0x62, 0x69, 0x8a, + 0xa3, 0xac, 0xba, 0x15, 0x4a, 0x7, 0x16, 0x8a, 0x43, 0xb8, 0x4b, 0x19, 0xac}; + uint8_t topic_bytes[] = {0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, + 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 0; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "bc", _pubPktID = 16588, _pubBody = "BE\CAN\DEL\135:\DLE\226{E\240\163\&8oT+~\213", _pubProps = [PropMaximumQoS 133,PropMaximumPacketSize 18313,PropCorrelationData "L",PropMessageExpiryInterval 12669,PropMessageExpiryInterval 6374,PropServerReference "n\234\217\197t\209\183\189\207\SUB\DEL\251\203+1L\146\141",PropMessageExpiryInterval 24703,PropReceiveMaximum 24739,PropRequestProblemInformation 194,PropRequestProblemInformation 79,PropWildcardSubscriptionAvailable 243,PropTopicAliasMaximum 393,PropReasonString "#l",PropMessageExpiryInterval 22807,PropAuthenticationMethod "\131\156",PropMessageExpiryInterval 18090]} -TEST(Publish5QCTest, Encode18) { -uint8_t pkt[] = {0x33, 0x68, 0x0, 0x2, 0x62, 0x63, 0x40, 0xcc, 0x4f, 0x24, 0x85, 0x27, 0x0, 0x0, 0x47, 0x89, 0x9, 0x0, 0x1, 0x4c, 0x2, 0x0, 0x0, 0x31, 0x7d, 0x2, 0x0, 0x0, 0x18, 0xe6, 0x1c, 0x0, 0x12, 0x6e, 0xea, 0xd9, 0xc5, 0x74, 0xd1, 0xb7, 0xbd, 0xcf, 0x1a, 0x7f, 0xfb, 0xcb, 0x2b, 0x31, 0x4c, 0x92, 0x8d, 0x2, 0x0, 0x0, 0x60, 0x7f, 0x21, 0x60, 0xa3, 0x17, 0xc2, 0x17, 0x4f, 0x28, 0xf3, 0x22, 0x1, 0x89, 0x1f, 0x0, 0x2, 0x23, 0x6c, 0x2, 0x0, 0x0, 0x59, 0x17, 0x15, 0x0, 0x2, 0x83, 0x9c, 0x2, 0x0, 0x0, 0x46, 0xaa, 0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; - uint8_t topic_bytes[] = {0x62, 0x63}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t bytesprops0[] = {0xa6, 0xf2, 0xf8, 0xc0, 0xcf, 0xdc, 0xf9, 0x7a, 0x8d, 0x74, 0x7, 0x60, 0xde, 0x19, 0xb7, + 0x4f, 0x70, 0x28, 0x35, 0xe2, 0x51, 0x4b, 0x27, 0xf5, 0x96, 0xa, 0x49, 0x1, 0x52, 0x33}; + uint8_t bytesprops1[] = {0xe5, 0x5, 0xbe, 0x6d, 0xce, 0x9, 0x82, 0x86, 0x8, 0x83, 0x86, 0xeb, 0x2b, 0xa6, + 0x62, 0x69, 0x8a, 0xa3, 0xac, 0xba, 0x15, 0x4a, 0x7, 0x16, 0x8a, 0x43, 0xb8, 0x4b}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 18; - - uint8_t bytesprops0[] = {0x4c}; - uint8_t bytesprops1[] = {0x6e, 0xea, 0xd9, 0xc5, 0x74, 0xd1, 0xb7, 0xbd, 0xcf, 0x1a, 0x7f, 0xfb, 0xcb, 0x2b, 0x31, 0x4c, 0x92, 0x8d}; - uint8_t bytesprops2[] = {0x23, 0x6c}; - uint8_t bytesprops3[] = {0x83, 0x9c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18313}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12669}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6374}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24703}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24739}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 393}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22807}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18090}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26890}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8868}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16588, topic, msg, props); + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16078, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "bc", _pubPktID = 16588, _pubBody = "BE\CAN\DEL\135:\DLE\226{E\240\163\&8oT+~\213", _pubProps = [PropMaximumQoS 133,PropMaximumPacketSize 18313,PropCorrelationData "L",PropMessageExpiryInterval 12669,PropMessageExpiryInterval 6374,PropServerReference "n\234\217\197t\209\183\189\207\SUB\DEL\251\203+1L\146\141",PropMessageExpiryInterval 24703,PropReceiveMaximum 24739,PropRequestProblemInformation 194,PropRequestProblemInformation 79,PropWildcardSubscriptionAvailable 243,PropTopicAliasMaximum 393,PropReasonString "#l",PropMessageExpiryInterval 22807,PropAuthenticationMethod "\131\156",PropMessageExpiryInterval 18090]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "dG\194+K1e\237n\253\EM\US\222\156\216K\173\158+\228\&9E\185\CAN\147`\203un\n", _pubPktID = 16078, _pubBody = "", +// _pubProps = [PropResponseTopic +// "\166\242\248\192\207\220\249z\141t\a`\222\EM\183Op(5\226QK'\245\150\nI\SOHR3",PropTopicAliasMaximum +// 26890,PropMaximumQoS 179,PropMessageExpiryInterval 8868,PropSubscriptionIdentifierAvailable 112,PropReasonString +// "\229\ENQ\190m\206\t\130\134\b\131\134\235+\166bi\138\163\172\186\NAKJ\a\SYN\138C\184K",PropRequestResponseInformation +// 172]} TEST(Publish5QCTest, Decode18) { -uint8_t pkt[] = {0x33, 0x68, 0x0, 0x2, 0x62, 0x63, 0x40, 0xcc, 0x4f, 0x24, 0x85, 0x27, 0x0, 0x0, 0x47, 0x89, 0x9, 0x0, 0x1, 0x4c, 0x2, 0x0, 0x0, 0x31, 0x7d, 0x2, 0x0, 0x0, 0x18, 0xe6, 0x1c, 0x0, 0x12, 0x6e, 0xea, 0xd9, 0xc5, 0x74, 0xd1, 0xb7, 0xbd, 0xcf, 0x1a, 0x7f, 0xfb, 0xcb, 0x2b, 0x31, 0x4c, 0x92, 0x8d, 0x2, 0x0, 0x0, 0x60, 0x7f, 0x21, 0x60, 0xa3, 0x17, 0xc2, 0x17, 0x4f, 0x28, 0xf3, 0x22, 0x1, 0x89, 0x1f, 0x0, 0x2, 0x23, 0x6c, 0x2, 0x0, 0x0, 0x59, 0x17, 0x15, 0x0, 0x2, 0x83, 0x9c, 0x2, 0x0, 0x0, 0x46, 0xaa, 0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x62, 0x63}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x42, 0x45, 0x18, 0x7f, 0x87, 0x3a, 0x10, 0xe2, 0x7b, 0x45, 0xf0, 0xa3, 0x38, 0x6f, 0x54, 0x2b, 0x7e, 0xd5}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 16588); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); -EXPECT_EQ(msg.payload_len, 18); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x32, 0x71, 0x0, 0x1e, 0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, + 0x9c, 0xd8, 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa, + 0x3e, 0xce, 0x4e, 0x8, 0x0, 0x1e, 0xa6, 0xf2, 0xf8, 0xc0, 0xcf, 0xdc, 0xf9, 0x7a, 0x8d, 0x74, 0x7, + 0x60, 0xde, 0x19, 0xb7, 0x4f, 0x70, 0x28, 0x35, 0xe2, 0x51, 0x4b, 0x27, 0xf5, 0x96, 0xa, 0x49, 0x1, + 0x52, 0x33, 0x22, 0x69, 0xa, 0x24, 0xb3, 0x2, 0x0, 0x0, 0x22, 0xa4, 0x29, 0x70, 0x1f, 0x0, 0x1c, + 0xe5, 0x5, 0xbe, 0x6d, 0xce, 0x9, 0x82, 0x86, 0x8, 0x83, 0x86, 0xeb, 0x2b, 0xa6, 0x62, 0x69, 0x8a, + 0xa3, 0xac, 0xba, 0x15, 0x4a, 0x7, 0x16, 0x8a, 0x43, 0xb8, 0x4b, 0x19, 0xac}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3\255\173\206\232\229\219\SOH\SUB\237\217\218}\ENQ\DC3", _pubPktID = 0, _pubBody = "\184", _pubProps = [PropAuthenticationData "e\ESC\ESC\a\DC4o\EOT\197\137\215\223<\199'sz\ETXKw\195\&6\130\DC3\244",PropAuthenticationData "\138\228",PropSessionExpiryInterval 7762,PropWillDelayInterval 29687,PropAuthenticationMethod "\250\186&\163\132s\174\178Bt\136\203l\225~\151$",PropSharedSubscriptionAvailable 29,PropMaximumQoS 225]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, + 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa}; + lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0}; + lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 16078); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); + EXPECT_EQ(msg.payload_len, 0); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "?\DC1;Y\196\211\145n\198\234\233\176_,\224\194\182X\250J\NUL_\198\186\&5\173\224W", _pubPktID = 0, _pubBody = +// "\189?\ag\226\204+\195v\STX4\147\165\167h\131}n\149j\208", _pubProps = [PropWildcardSubscriptionAvailable +// 0,PropCorrelationData +// "\192\253\172\134\180\240\188A\202\151\153^\148\&0\153\251|\227\151\207))\207U`",PropRetainAvailable +// 202,PropUserProperty "\151\180#\EOT1\US\252.\STX\224\214\210\\\192\242\213^\193\SUB\149\175\165\193!V" +// "\145\&0\189\&0\253\&5\165\SUB\140\140g`c\SOH",PropSubscriptionIdentifier 3,PropSubscriptionIdentifierAvailable +// 175,PropContentType "",PropServerKeepAlive 10995,PropWillDelayInterval 29838,PropTopicAliasMaximum +// 12765,PropUserProperty "\249\223\142_B\DELAQ\NAKr\155]\254'h\178Q\140\212\ETX\230\240\151td\213g" +// "E",PropAssignedClientIdentifier "\SOH\EMJd|\185_6\232",PropMaximumQoS 36,PropSubscriptionIdentifierAvailable +// 226,PropResponseInformation "\250?\140\DC1\211\RS\238rpe\EM\253[8\147y",PropReasonString +// "\221\166\174\SI",PropResponseInformation "t4\SYNQ\140W'_i\v6",PropServerReference +// "\210\245\151\236",PropTopicAliasMaximum 8057,PropAssignedClientIdentifier "\159RG\156",PropCorrelationData +// "~\249\195\160\166Y2\154L\150i \ACKr\242\181\DLE8d\221\175\215\176\202\248\216\163",PropReceiveMaximum +// 3286,PropSubscriptionIdentifierAvailable 245,PropTopicAliasMaximum 5386,PropReceiveMaximum +// 8489,PropRequestResponseInformation 31,PropPayloadFormatIndicator 106,PropWillDelayInterval +// 8799,PropResponseInformation +// "Z\216\187\SOH\169\207\180vs\177\&8\216\150\v\174\195\245\187\250vq(X\SYN\197Z",PropMessageExpiryInterval 22785]} TEST(Publish5QCTest, Encode19) { -uint8_t pkt[] = {0x31, 0x55, 0x0, 0xf, 0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13, 0x42, 0x16, 0x0, 0x18, 0x65, 0x1b, 0x1b, 0x7, 0x14, 0x6f, 0x4, 0xc5, 0x89, 0xd7, 0xdf, 0x3c, 0xc7, 0x27, 0x73, 0x7a, 0x3, 0x4b, 0x77, 0xc3, 0x36, 0x82, 0x13, 0xf4, 0x16, 0x0, 0x2, 0x8a, 0xe4, 0x11, 0x0, 0x0, 0x1e, 0x52, 0x18, 0x0, 0x0, 0x73, 0xf7, 0x15, 0x0, 0x11, 0xfa, 0xba, 0x26, 0xa3, 0x84, 0x73, 0xae, 0xb2, 0x42, 0x74, 0x88, 0xcb, 0x6c, 0xe1, 0x7e, 0x97, 0x24, 0x2a, 0x1d, 0x24, 0xe1, 0xb8}; - uint8_t topic_bytes[] = {0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS0; -msg.retained = true; -uint8_t msg_bytes[] = {0xb8}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 1; + uint8_t pkt[] = { + 0x30, 0xd1, 0x2, 0x0, 0x1c, 0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, 0xe9, 0xb0, 0x5f, 0x2c, + 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, 0x35, 0xad, 0xe0, 0x57, 0x9c, 0x2, 0x28, 0x0, 0x9, + 0x0, 0x19, 0xc0, 0xfd, 0xac, 0x86, 0xb4, 0xf0, 0xbc, 0x41, 0xca, 0x97, 0x99, 0x5e, 0x94, 0x30, 0x99, 0xfb, 0x7c, + 0xe3, 0x97, 0xcf, 0x29, 0x29, 0xcf, 0x55, 0x60, 0x25, 0xca, 0x26, 0x0, 0x19, 0x97, 0xb4, 0x23, 0x4, 0x31, 0x1f, + 0xfc, 0x2e, 0x2, 0xe0, 0xd6, 0xd2, 0x5c, 0xc0, 0xf2, 0xd5, 0x5e, 0xc1, 0x1a, 0x95, 0xaf, 0xa5, 0xc1, 0x21, 0x56, +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x22, 0x5f, + 0x1a, 0x0, 0x1a, 0x5a, 0xd8, 0xbb, 0x1, 0xa9, 0xcf, 0xb4, 0x76, 0x73, 0xb1, 0x38, 0xd8, 0x96, 0xb, 0xae, 0xc3, + 0xf5, 0xbb, 0xfa, 0x76, 0x71, 0x28, 0x58, 0x16, 0xc5, 0x5a, 0x2, 0x0, 0x0, 0x59, 0x1, 0xbd, 0x3f, 0x7, 0x67, + 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, 0x34, 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; + uint8_t topic_bytes[] = {0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, 0xe9, 0xb0, 0x5f, 0x2c, + 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, 0x35, 0xad, 0xe0, 0x57}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xbd, 0x3f, 0x7, 0x67, 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, 0x34, + 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 21; + + uint8_t bytesprops0[] = {0xc0, 0xfd, 0xac, 0x86, 0xb4, 0xf0, 0xbc, 0x41, 0xca, 0x97, 0x99, 0x5e, 0x94, + 0x30, 0x99, 0xfb, 0x7c, 0xe3, 0x97, 0xcf, 0x29, 0x29, 0xcf, 0x55, 0x60}; + uint8_t bytesprops2[] = {0x91, 0x30, 0xbd, 0x30, 0xfd, 0x35, 0xa5, 0x1a, 0x8c, 0x8c, 0x67, 0x60, 0x63, 0x1}; + uint8_t bytesprops1[] = {0x97, 0xb4, 0x23, 0x4, 0x31, 0x1f, 0xfc, 0x2e, 0x2, 0xe0, 0xd6, 0xd2, 0x5c, + 0xc0, 0xf2, 0xd5, 0x5e, 0xc1, 0x1a, 0x95, 0xaf, 0xa5, 0xc1, 0x21, 0x56}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops5[] = {0x45}; + uint8_t bytesprops4[] = {0xf9, 0xdf, 0x8e, 0x5f, 0x42, 0x7f, 0x41, 0x51, 0x15, 0x72, 0x9b, 0x5d, 0xfe, 0x27, + 0x68, 0xb2, 0x51, 0x8c, 0xd4, 0x3, 0xe6, 0xf0, 0x97, 0x74, 0x64, 0xd5, 0x67}; + uint8_t bytesprops6[] = {0x1, 0x19, 0x4a, 0x64, 0x7c, 0xb9, 0x5f, 0x36, 0xe8}; + uint8_t bytesprops7[] = {0xfa, 0x3f, 0x8c, 0x11, 0xd3, 0x1e, 0xee, 0x72, + 0x70, 0x65, 0x19, 0xfd, 0x5b, 0x38, 0x93, 0x79}; + uint8_t bytesprops8[] = {0xdd, 0xa6, 0xae, 0xf}; + uint8_t bytesprops9[] = {0x74, 0x34, 0x16, 0x51, 0x8c, 0x57, 0x27, 0x5f, 0x69, 0xb, 0x36}; + uint8_t bytesprops10[] = {0xd2, 0xf5, 0x97, 0xec}; + uint8_t bytesprops11[] = {0x9f, 0x52, 0x47, 0x9c}; + uint8_t bytesprops12[] = {0x7e, 0xf9, 0xc3, 0xa0, 0xa6, 0x59, 0x32, 0x9a, 0x4c, 0x96, 0x69, 0x20, 0x6, 0x72, + 0xf2, 0xb5, 0x10, 0x38, 0x64, 0xdd, 0xaf, 0xd7, 0xb0, 0xca, 0xf8, 0xd8, 0xa3}; + uint8_t bytesprops13[] = {0x5a, 0xd8, 0xbb, 0x1, 0xa9, 0xcf, 0xb4, 0x76, 0x73, 0xb1, 0x38, 0xd8, 0x96, + 0xb, 0xae, 0xc3, 0xf5, 0xbb, 0xfa, 0x76, 0x71, 0x28, 0x58, 0x16, 0xc5, 0x5a}; - uint8_t bytesprops0[] = {0x65, 0x1b, 0x1b, 0x7, 0x14, 0x6f, 0x4, 0xc5, 0x89, 0xd7, 0xdf, 0x3c, 0xc7, 0x27, 0x73, 0x7a, 0x3, 0x4b, 0x77, 0xc3, 0x36, 0x82, 0x13, 0xf4}; - uint8_t bytesprops1[] = {0x8a, 0xe4}; - uint8_t bytesprops2[] = {0xfa, 0xba, 0x26, 0xa3, 0x84, 0x73, 0xae, 0xb2, 0x42, 0x74, 0x88, 0xcb, 0x6c, 0xe1, 0x7e, 0x97, 0x24}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7762}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29687}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops1}, .v = {14, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10995}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29838}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12765}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops4}, .v = {1, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8057}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3286}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5386}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8489}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8799}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22785}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DC3\255\173\206\232\229\219\SOH\SUB\237\217\218}\ENQ\DC3", _pubPktID = 0, _pubBody = "\184", _pubProps = [PropAuthenticationData "e\ESC\ESC\a\DC4o\EOT\197\137\215\223<\199'sz\ETXKw\195\&6\130\DC3\244",PropAuthenticationData "\138\228",PropSessionExpiryInterval 7762,PropWillDelayInterval 29687,PropAuthenticationMethod "\250\186&\163\132s\174\178Bt\136\203l\225~\151$",PropSharedSubscriptionAvailable 29,PropMaximumQoS 225]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "?\DC1;Y\196\211\145n\198\234\233\176_,\224\194\182X\250J\NUL_\198\186\&5\173\224W", _pubPktID = 0, _pubBody = +// "\189?\ag\226\204+\195v\STX4\147\165\167h\131}n\149j\208", _pubProps = [PropWildcardSubscriptionAvailable +// 0,PropCorrelationData +// "\192\253\172\134\180\240\188A\202\151\153^\148\&0\153\251|\227\151\207))\207U`",PropRetainAvailable +// 202,PropUserProperty "\151\180#\EOT1\US\252.\STX\224\214\210\\\192\242\213^\193\SUB\149\175\165\193!V" +// "\145\&0\189\&0\253\&5\165\SUB\140\140g`c\SOH",PropSubscriptionIdentifier 3,PropSubscriptionIdentifierAvailable +// 175,PropContentType "",PropServerKeepAlive 10995,PropWillDelayInterval 29838,PropTopicAliasMaximum +// 12765,PropUserProperty "\249\223\142_B\DELAQ\NAKr\155]\254'h\178Q\140\212\ETX\230\240\151td\213g" +// "E",PropAssignedClientIdentifier "\SOH\EMJd|\185_6\232",PropMaximumQoS 36,PropSubscriptionIdentifierAvailable +// 226,PropResponseInformation "\250?\140\DC1\211\RS\238rpe\EM\253[8\147y",PropReasonString +// "\221\166\174\SI",PropResponseInformation "t4\SYNQ\140W'_i\v6",PropServerReference +// "\210\245\151\236",PropTopicAliasMaximum 8057,PropAssignedClientIdentifier "\159RG\156",PropCorrelationData +// "~\249\195\160\166Y2\154L\150i \ACKr\242\181\DLE8d\221\175\215\176\202\248\216\163",PropReceiveMaximum +// 3286,PropSubscriptionIdentifierAvailable 245,PropTopicAliasMaximum 5386,PropReceiveMaximum +// 8489,PropRequestResponseInformation 31,PropPayloadFormatIndicator 106,PropWillDelayInterval +// 8799,PropResponseInformation +// "Z\216\187\SOH\169\207\180vs\177\&8\216\150\v\174\195\245\187\250vq(X\SYN\197Z",PropMessageExpiryInterval 22785]} TEST(Publish5QCTest, Decode19) { -uint8_t pkt[] = {0x31, 0x55, 0x0, 0xf, 0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13, 0x42, 0x16, 0x0, 0x18, 0x65, 0x1b, 0x1b, 0x7, 0x14, 0x6f, 0x4, 0xc5, 0x89, 0xd7, 0xdf, 0x3c, 0xc7, 0x27, 0x73, 0x7a, 0x3, 0x4b, 0x77, 0xc3, 0x36, 0x82, 0x13, 0xf4, 0x16, 0x0, 0x2, 0x8a, 0xe4, 0x11, 0x0, 0x0, 0x1e, 0x52, 0x18, 0x0, 0x0, 0x73, 0xf7, 0x15, 0x0, 0x11, 0xfa, 0xba, 0x26, 0xa3, 0x84, 0x73, 0xae, 0xb2, 0x42, 0x74, 0x88, 0xcb, 0x6c, 0xe1, 0x7e, 0x97, 0x24, 0x2a, 0x1d, 0x24, 0xe1, 0xb8}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x13, 0xff, 0xad, 0xce, 0xe8, 0xe5, 0xdb, 0x1, 0x1a, 0xed, 0xd9, 0xda, 0x7d, 0x5, 0x13}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb8}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS0); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 0); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); -EXPECT_EQ(msg.payload_len, 1); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = { + 0x30, 0xd1, 0x2, 0x0, 0x1c, 0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, 0xe9, 0xb0, 0x5f, 0x2c, + 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, 0x35, 0xad, 0xe0, 0x57, 0x9c, 0x2, 0x28, 0x0, 0x9, + 0x0, 0x19, 0xc0, 0xfd, 0xac, 0x86, 0xb4, 0xf0, 0xbc, 0x41, 0xca, 0x97, 0x99, 0x5e, 0x94, 0x30, 0x99, 0xfb, 0x7c, + 0xe3, 0x97, 0xcf, 0x29, 0x29, 0xcf, 0x55, 0x60, 0x25, 0xca, 0x26, 0x0, 0x19, 0x97, 0xb4, 0x23, 0x4, 0x31, 0x1f, + 0xfc, 0x2e, 0x2, 0xe0, 0xd6, 0xd2, 0x5c, 0xc0, 0xf2, 0xd5, 0x5e, 0xc1, 0x1a, 0x95, 0xaf, 0xa5, 0xc1, 0x21, 0x56, + 0x0, 0xe, 0x91, 0x30, 0xbd, 0x30, 0xfd, 0x35, 0xa5, 0x1a, 0x8c, 0x8c, 0x67, 0x60, 0x63, 0x1, 0xb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0xd8, 0x96, 0xb, 0xae, 0xc3, + 0xf5, 0xbb, 0xfa, 0x76, 0x71, 0x28, 0x58, 0x16, 0xc5, 0x5a, 0x2, 0x0, 0x0, 0x59, 0x1, 0xbd, 0x3f, 0x7, 0x67, + 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, 0x34, 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} - - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\134\&2\209f\v\148F\254 \253\tm", _pubPktID = 25649, _pubBody = "!mj\ACK\181\179\t\252S\212\144\149\130\150X", _pubProps = [PropRequestProblemInformation 125,PropMessageExpiryInterval 9893,PropWillDelayInterval 12742,PropContentType "\252\247q\147\&3\229\143\251\206O\238.\149\204C\151\193z\181\239\150G^j\EOTR\150j",PropPayloadFormatIndicator 218,PropServerKeepAlive 17321]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, 0xe9, 0xb0, 0x5f, 0x2c, + 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, 0x35, 0xad, 0xe0, 0x57}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbd, 0x3f, 0x7, 0x67, 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, 0x34, + 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "D\SUBc\224\DC3\202\&3\187\&84T\240", _pubPktID = 22665, _pubBody = +// "EV\174.\183\&1Q\DC1\216V\203p>q=x\132\163(\239\143\135b\236\137\&6", _pubProps = [PropTopicAlias +// 1081,PropContentType "3\205\199\242_=",PropWildcardSubscriptionAvailable 83,PropUserProperty "F\217%]\244\163G\239" +// "\156\129",PropPayloadFormatIndicator 159,PropServerReference +// "\226\"\247\195\163\GSS%\184\r\215t\186\211",PropResponseInformation +// "\174\249z\CAN\248\219\SI\138}\152",PropAssignedClientIdentifier +// "!j\154E\128o\220\EOT\251=\135\221i\180\RS",PropMaximumPacketSize 30968,PropReasonString +// "\157\&3U\GS\139\&1-\250\SOH\177\245\128\STX",PropCorrelationData +// "\EOT\189\NULoWjA\177\237\168\215-\225",PropWildcardSubscriptionAvailable 11]} TEST(Publish5QCTest, Encode20) { -uint8_t pkt[] = {0x3b, 0x50, 0x0, 0xc, 0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d, 0x64, 0x31, 0x30, 0x17, 0x7d, 0x2, 0x0, 0x0, 0x26, 0xa5, 0x18, 0x0, 0x0, 0x31, 0xc6, 0x3, 0x0, 0x1c, 0xfc, 0xf7, 0x71, 0x93, 0x33, 0xe5, 0x8f, 0xfb, 0xce, 0x4f, 0xee, 0x2e, 0x95, 0xcc, 0x43, 0x97, 0xc1, 0x7a, 0xb5, 0xef, 0x96, 0x47, 0x5e, 0x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xd8, 0x56, 0xcb, 0x70, 0x3e, 0x71, 0x3d, + 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + uint8_t topic_bytes[] = {0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, 0xf0}; lwmqtt_string_t topic = {12, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 15; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, 0x3e, + 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 26; + + uint8_t bytesprops0[] = {0x33, 0xcd, 0xc7, 0xf2, 0x5f, 0x3d}; + uint8_t bytesprops2[] = {0x9c, 0x81}; + uint8_t bytesprops1[] = {0x46, 0xd9, 0x25, 0x5d, 0xf4, 0xa3, 0x47, 0xef}; + uint8_t bytesprops3[] = {0xe2, 0x22, 0xf7, 0xc3, 0xa3, 0x1d, 0x53, 0x25, 0xb8, 0xd, 0xd7, 0x74, 0xba, 0xd3}; + uint8_t bytesprops4[] = {0xae, 0xf9, 0x7a, 0x18, 0xf8, 0xdb, 0xf, 0x8a, 0x7d, 0x98}; + uint8_t bytesprops5[] = {0x21, 0x6a, 0x9a, 0x45, 0x80, 0x6f, 0xdc, 0x4, 0xfb, 0x3d, 0x87, 0xdd, 0x69, 0xb4, 0x1e}; + uint8_t bytesprops6[] = {0x9d, 0x33, 0x55, 0x1d, 0x8b, 0x31, 0x2d, 0xfa, 0x1, 0xb1, 0xf5, 0x80, 0x2}; + uint8_t bytesprops7[] = {0x4, 0xbd, 0x0, 0x6f, 0x57, 0x6a, 0x41, 0xb1, 0xed, 0xa8, 0xd7, 0x2d, 0xe1}; - uint8_t bytesprops0[] = {0xfc, 0xf7, 0x71, 0x93, 0x33, 0xe5, 0x8f, 0xfb, 0xce, 0x4f, 0xee, 0x2e, 0x95, 0xcc, 0x43, 0x97, 0xc1, 0x7a, 0xb5, 0xef, 0x96, 0x47, 0x5e, 0x6a, 0x4, 0x52, 0x96, 0x6a}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9893}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12742}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17321}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1081}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops1}, .v = {2, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30968}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25649, topic, msg, props); + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 22665, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\134\&2\209f\v\148F\254 \253\tm", _pubPktID = 25649, _pubBody = "!mj\ACK\181\179\t\252S\212\144\149\130\150X", _pubProps = [PropRequestProblemInformation 125,PropMessageExpiryInterval 9893,PropWillDelayInterval 12742,PropContentType "\252\247q\147\&3\229\143\251\206O\238.\149\204C\151\193z\181\239\150G^j\EOTR\150j",PropPayloadFormatIndicator 218,PropServerKeepAlive 17321]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "D\SUBc\224\DC3\202\&3\187\&84T\240", _pubPktID = 22665, _pubBody = +// "EV\174.\183\&1Q\DC1\216V\203p>q=x\132\163(\239\143\135b\236\137\&6", _pubProps = [PropTopicAlias +// 1081,PropContentType "3\205\199\242_=",PropWildcardSubscriptionAvailable 83,PropUserProperty "F\217%]\244\163G\239" +// "\156\129",PropPayloadFormatIndicator 159,PropServerReference +// "\226\"\247\195\163\GSS%\184\r\215t\186\211",PropResponseInformation +// "\174\249z\CAN\248\219\SI\138}\152",PropAssignedClientIdentifier +// "!j\154E\128o\220\EOT\251=\135\221i\180\RS",PropMaximumPacketSize 30968,PropReasonString +// "\157\&3U\GS\139\&1-\250\SOH\177\245\128\STX",PropCorrelationData +// "\EOT\189\NULoWjA\177\237\168\215-\225",PropWildcardSubscriptionAvailable 11]} TEST(Publish5QCTest, Decode20) { -uint8_t pkt[] = {0x3b, 0x50, 0x0, 0xc, 0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d, 0x64, 0x31, 0x30, 0x17, 0x7d, 0x2, 0x0, 0x0, 0x26, 0xa5, 0x18, 0x0, 0x0, 0x31, 0xc6, 0x3, 0x0, 0x1c, 0xfc, 0xf7, 0x71, 0x93, 0x33, 0xe5, 0x8f, 0xfb, 0xce, 0x4f, 0xee, 0x2e, 0x95, 0xcc, 0x43, 0x97, 0xc1, 0x7a, 0xb5, 0xef, 0x96, 0x47, 0x5e, 0x6a, 0x4, 0x52, 0x96, 0x6a, 0x1, 0xda, 0x13, 0x43, 0xa9, 0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x86, 0x32, 0xd1, 0x66, 0xb, 0x94, 0x46, 0xfe, 0x20, 0xfd, 0x9, 0x6d}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x21, 0x6d, 0x6a, 0x6, 0xb5, 0xb3, 0x9, 0xfc, 0x53, 0xd4, 0x90, 0x95, 0x82, 0x96, 0x58}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 25649); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); -EXPECT_EQ(msg.payload_len, 15); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} + uint8_t pkt[] = {0x32, 0xa1, 0x1, 0x0, 0xc, 0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, 0xf0, + 0x58, 0x89, 0x76, 0x23, 0x4, 0x39, 0x3, 0x0, 0x6, 0x33, 0xcd, 0xc7, 0xf2, 0x5f, 0x3d, 0x28, 0x53, + 0x26, 0x0, 0x8, 0x46, 0xd9, 0x25, 0x5d, 0xf4, 0xa3, 0x47, 0xef, 0x0, 0x2, 0x9c, 0x81, 0x1, 0x9f, + 0x1c, 0x0, 0xe, 0xe2, 0x22, 0xf7, 0xc3, 0xa3, 0x1d, 0x53, 0x25, 0xb8, 0xd, 0xd7, 0x74, 0xba, 0xd3, + 0x1a, 0x0, 0xa, 0xae, 0xf9, 0x7a, 0x18, 0xf8, 0xdb, 0xf, 0x8a, 0x7d, 0x98, 0x12, 0x0, 0xf, 0x21, + 0x6a, 0x9a, 0x45, 0x80, 0x6f, 0xdc, 0x4, 0xfb, 0x3d, 0x87, 0xdd, 0x69, 0xb4, 0x1e, 0x27, 0x0, 0x0, + 0x78, 0xf8, 0x1f, 0x0, 0xd, 0x9d, 0x33, 0x55, 0x1d, 0x8b, 0x31, 0x2d, 0xfa, 0x1, 0xb1, 0xf5, 0x80, + 0x2, 0x9, 0x0, 0xd, 0x4, 0xbd, 0x0, 0x6f, 0x57, 0x6a, 0x41, 0xb1, 0xed, 0xa8, 0xd7, 0x2d, 0xe1, + 0x28, 0xb, 0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, 0x3e, 0x71, 0x3d, + 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "|\218", _pubPktID = 20394, _pubBody = "\153\SO\176", _pubProps = [PropAssignedClientIdentifier "\SI\n\150!\196\164",PropResponseTopic "\ACK\163\157\162#a\230E\167\179\232\140\192\FS5\ACK\200\219\164*h(topic.data), 12); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\230\f\162\233\EOT\DC3\171\130\175!\217\131n\254\197\128m$;\254w\217O\ETX0\241c\223", _pubPktID = 0, _pubBody = +// ";]t:N\225`\ETX\239\239R\FS\135\144", _pubProps = [PropRequestProblemInformation +// 94,PropSubscriptionIdentifierAvailable 215,PropUserProperty "\229" +// "\246\173\&5\184\&1\a)\174\169p\228Rz\241\n}9j\215\&1\220~\187\SYN\168\149\DELe(\215",PropSubscriptionIdentifier +// 28,PropResponseTopic "Y\213\SOHf;a\135\217",PropContentType +// "\v\135\236su\221\217\202\247\152\&1?\227ycg",PropUserProperty "\DEL\200L\174_\175\242\200" "\199",PropMaximumQoS +// 242,PropReceiveMaximum 3177,PropAuthenticationMethod "\135\238",PropMessageExpiryInterval 25546]} TEST(Publish5QCTest, Encode21) { -uint8_t pkt[] = {0x3d, 0xb3, 0x1, 0x0, 0x2, 0x7c, 0xda, 0x4f, 0xaa, 0xa8, 0x1, 0x12, 0x0, 0x6, 0xf, 0xa, 0x96, 0x21, 0xc4, 0xa4, 0x8, 0x0, 0x17, 0x6, 0xa3, 0x9d, 0xa2, 0x23, 0x61, 0xe6, 0x45, 0xa7, 0xb3, 0xe8, 0x8c, 0xc0, 0x1c, 0x35, 0x6, 0xc8, 0xdb, 0xa4, 0x2a, 0x68, 0x3c, 0x61, 0x2, 0x0, 0x0, 0x56, 0x9f, 0x29, 0xf5, 0x29, 0xf8, 0x19, 0x17, 0x27, 0x0, 0x0, 0x40, 0xdd, 0x2, 0x0, 0x0, 0x2f, 0xb1, 0x11, 0x0, 0x0, 0x7a, 0x98, 0x11, 0x0, 0x0, 0x2e, 0x29, 0x19, 0x50, 0x12, 0x0, 0x12, 0x66, 0x11, 0x9c, 0x9d, 0xb2, 0x9a, 0xe2, 0xc3, 0x1e, 0x7e, 0x4a, 0xac, 0xe2, 0x94, 0x65, 0x56, 0xcc, 0xbb, 0x2a, 0x48, 0x21, 0x16, 0xec, 0x27, 0x0, 0x0, 0x4d, 0x90, 0x13, 0x64, 0xf1, 0x13, 0x48, 0x8c, 0x25, 0x5a, 0x2, 0x0, 0x0, 0x4e, 0xbc, 0x13, 0x59, 0xd1, 0x17, 0x2e, 0x1, 0xd, 0x16, 0x0, 0x2, 0x7d, 0x25, 0x16, 0x0, 0x11, 0x6a, 0x97, 0xd3, 0x22, 0x9a, 0xf3, 0xa8, 0x6, 0xb4, 0xf2, 0x59, 0xfd, 0x33, 0x98, 0xf4, 0x43, 0x17, 0x2a, 0xcb, 0x1a, 0x0, 0x13, 0xe7, 0xad, 0x6b, 0xc9, 0xee, 0x7b, 0x33, 0xa3, 0xc1, 0xda, 0xc0, 0x55, 0x1c, 0x1d, 0x83, 0x58, 0x4c, 0x80, 0x8, 0x99, 0xe, 0xb0}; - uint8_t topic_bytes[] = {0x7c, 0xda}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x92, 0x1, 0x0, 0x1c, 0xe6, 0xc, 0xa2, 0xe9, 0x4, 0x13, 0xab, 0x82, 0xaf, 0x21, 0xd9, 0x83, + 0x6e, 0xfe, 0xc5, 0x80, 0x6d, 0x24, 0x3b, 0xfe, 0x77, 0xd9, 0x4f, 0x3, 0x30, 0xf1, 0x63, 0xdf, 0x65, + 0x17, 0x5e, 0x29, 0xd7, 0x26, 0x0, 0x1, 0xe5, 0x0, 0x1e, 0xf6, 0xad, 0x35, 0xb8, 0x31, 0x7, 0x29, + 0xae, 0xa9, 0x70, 0xe4, 0x52, 0x7a, 0xf1, 0xa, 0x7d, 0x39, 0x6a, 0xd7, 0x31, 0xdc, 0x7e, 0xbb, 0x16, + 0xa8, 0x95, 0x7f, 0x65, 0x28, 0xd7, 0xb, 0x1c, 0x8, 0x0, 0x8, 0x59, 0xd5, 0x1, 0x66, 0x3b, 0x61, + 0x87, 0xd9, 0x3, 0x0, 0x10, 0xb, 0x87, 0xec, 0x73, 0x75, 0xdd, 0xd9, 0xca, 0xf7, 0x98, 0x31, 0x3f, + 0xe3, 0x79, 0x63, 0x67, 0x26, 0x0, 0x8, 0x7f, 0xc8, 0x4c, 0xae, 0x5f, 0xaf, 0xf2, 0xc8, 0x0, 0x1, + 0xc7, 0x24, 0xf2, 0x21, 0xc, 0x69, 0x15, 0x0, 0x2, 0x87, 0xee, 0x2, 0x0, 0x0, 0x63, 0xca, 0x3b, + 0x5d, 0x74, 0x3a, 0x4e, 0xe1, 0x60, 0x3, 0xef, 0xef, 0x52, 0x1c, 0x87, 0x90}; + uint8_t topic_bytes[] = {0xe6, 0xc, 0xa2, 0xe9, 0x4, 0x13, 0xab, 0x82, 0xaf, 0x21, 0xd9, 0x83, 0x6e, 0xfe, + 0xc5, 0x80, 0x6d, 0x24, 0x3b, 0xfe, 0x77, 0xd9, 0x4f, 0x3, 0x30, 0xf1, 0x63, 0xdf}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x3b, 0x5d, 0x74, 0x3a, 0x4e, 0xe1, 0x60, 0x3, 0xef, 0xef, 0x52, 0x1c, 0x87, 0x90}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 14; + + uint8_t bytesprops1[] = {0xf6, 0xad, 0x35, 0xb8, 0x31, 0x7, 0x29, 0xae, 0xa9, 0x70, 0xe4, 0x52, 0x7a, 0xf1, 0xa, + 0x7d, 0x39, 0x6a, 0xd7, 0x31, 0xdc, 0x7e, 0xbb, 0x16, 0xa8, 0x95, 0x7f, 0x65, 0x28, 0xd7}; + uint8_t bytesprops0[] = {0xe5}; + uint8_t bytesprops2[] = {0x59, 0xd5, 0x1, 0x66, 0x3b, 0x61, 0x87, 0xd9}; + uint8_t bytesprops3[] = {0xb, 0x87, 0xec, 0x73, 0x75, 0xdd, 0xd9, 0xca, + 0xf7, 0x98, 0x31, 0x3f, 0xe3, 0x79, 0x63, 0x67}; + uint8_t bytesprops5[] = {0xc7}; + uint8_t bytesprops4[] = {0x7f, 0xc8, 0x4c, 0xae, 0x5f, 0xaf, 0xf2, 0xc8}; + uint8_t bytesprops6[] = {0x87, 0xee}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0x99, 0xe, 0xb0}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 3; - - uint8_t bytesprops0[] = {0xf, 0xa, 0x96, 0x21, 0xc4, 0xa4}; - uint8_t bytesprops1[] = {0x6, 0xa3, 0x9d, 0xa2, 0x23, 0x61, 0xe6, 0x45, 0xa7, 0xb3, 0xe8, 0x8c, 0xc0, 0x1c, 0x35, 0x6, 0xc8, 0xdb, 0xa4, 0x2a, 0x68, 0x3c, 0x61}; - uint8_t bytesprops2[] = {0x66, 0x11, 0x9c, 0x9d, 0xb2, 0x9a, 0xe2, 0xc3, 0x1e, 0x7e, 0x4a, 0xac, 0xe2, 0x94, 0x65, 0x56, 0xcc, 0xbb}; - uint8_t bytesprops3[] = {0x7d, 0x25}; - uint8_t bytesprops4[] = {0x6a, 0x97, 0xd3, 0x22, 0x9a, 0xf3, 0xa8, 0x6, 0xb4, 0xf2, 0x59, 0xfd, 0x33, 0x98, 0xf4, 0x43, 0x17}; - uint8_t bytesprops5[] = {0xe7, 0xad, 0x6b, 0xc9, 0xee, 0x7b, 0x33, 0xa3, 0xc1, 0xda, 0xc0, 0x55, 0x1c, 0x1d, 0x83, 0x58, 0x4c, 0x80, 0x8}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22175}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16605}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12209}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31384}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11817}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5868}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19856}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25841}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18572}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20156}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22993}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 20394, topic, msg, props); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {30, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops4}, .v = {1, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3177}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25546}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "|\218", _pubPktID = 20394, _pubBody = "\153\SO\176", _pubProps = [PropAssignedClientIdentifier "\SI\n\150!\196\164",PropResponseTopic "\ACK\163\157\162#a\230E\167\179\232\140\192\FS5\ACK\200\219\164*h(topic.data), 2); -EXPECT_EQ(msg.payload_len, 3); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x39, 0x92, 0x1, 0x0, 0x1c, 0xe6, 0xc, 0xa2, 0xe9, 0x4, 0x13, 0xab, 0x82, 0xaf, 0x21, 0xd9, 0x83, + 0x6e, 0xfe, 0xc5, 0x80, 0x6d, 0x24, 0x3b, 0xfe, 0x77, 0xd9, 0x4f, 0x3, 0x30, 0xf1, 0x63, 0xdf, 0x65, + 0x17, 0x5e, 0x29, 0xd7, 0x26, 0x0, 0x1, 0xe5, 0x0, 0x1e, 0xf6, 0xad, 0x35, 0xb8, 0x31, 0x7, 0x29, + 0xae, 0xa9, 0x70, 0xe4, 0x52, 0x7a, 0xf1, 0xa, 0x7d, 0x39, 0x6a, 0xd7, 0x31, 0xdc, 0x7e, 0xbb, 0x16, + 0xa8, 0x95, 0x7f, 0x65, 0x28, 0xd7, 0xb, 0x1c, 0x8, 0x0, 0x8, 0x59, 0xd5, 0x1, 0x66, 0x3b, 0x61, + 0x87, 0xd9, 0x3, 0x0, 0x10, 0xb, 0x87, 0xec, 0x73, 0x75, 0xdd, 0xd9, 0xca, 0xf7, 0x98, 0x31, 0x3f, + 0xe3, 0x79, 0x63, 0x67, 0x26, 0x0, 0x8, 0x7f, 0xc8, 0x4c, 0xae, 0x5f, 0xaf, 0xf2, 0xc8, 0x0, 0x1, + 0xc7, 0x24, 0xf2, 0x21, 0xc, 0x69, 0x15, 0x0, 0x2, 0x87, 0xee, 0x2, 0x0, 0x0, 0x63, 0xca, 0x3b, + 0x5d, 0x74, 0x3a, 0x4e, 0xe1, 0x60, 0x3, 0xef, 0xef, 0x52, 0x1c, 0x87, 0x90}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "<\t\"\209\184\182u\179\DLE\NAK\195\141\EM\237\189}\143\EOT\STX\188|\188\t\USv\US\209\"\STX", _pubPktID = 17374, _pubBody = "\"=\237\FS\247\238\129>oH\131~\158k\231\193}\194\ESCu", _pubProps = [PropWillDelayInterval 30493,PropResponseTopic "G\239\184\133\ETB~j'_\181t\194\148\221\231\SUB+\166\231\ETB\171\t,",PropWillDelayInterval 8185,PropContentType "[4:\219Gf\160\206\208qv\232\159\&8\190\211`\253\192\182\213\t",PropAssignedClientIdentifier "\145nCH\170\200\198[\135\249X\255\214\132\137(\234\179\223\190",PropSharedSubscriptionAvailable 64,PropMessageExpiryInterval 432,PropSubscriptionIdentifier 5,PropRetainAvailable 204,PropRequestResponseInformation 110,PropResponseTopic "\194\237\206\ACKh\ACK\132)\172\t\174\206\189\192,\161",PropRequestProblemInformation 68,PropSubscriptionIdentifierAvailable 215,PropReasonString "\DC1\168\133\202\NUL\146\148=\ACKg\172:\FSr\140\139\DC4\134\208\209\USR",PropUserProperty "\ENQ\255\SOHm\177\154f\207\198\147\186{tO\\z0\232\155\233\186\169\230" "\140\199",PropSessionExpiryInterval 30860,PropSessionExpiryInterval 31114,PropPayloadFormatIndicator 25,PropAssignedClientIdentifier "z=>'\171\235\192{\133AbA\172\178\175+\213\137a\r@",PropPayloadFormatIndicator 106,PropRequestResponseInformation 81,PropServerReference "1\162\156\135\224\162\243\243\216:{v;\213\204^\160\219\193\a\138\228OX\240C\150",PropCorrelationData "\f\179\FSBM"]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xe6, 0xc, 0xa2, 0xe9, 0x4, 0x13, 0xab, 0x82, 0xaf, 0x21, 0xd9, 0x83, 0x6e, 0xfe, + 0xc5, 0x80, 0x6d, 0x24, 0x3b, 0xfe, 0x77, 0xd9, 0x4f, 0x3, 0x30, 0xf1, 0x63, 0xdf}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x3b, 0x5d, 0x74, 0x3a, 0x4e, 0xe1, 0x60, 0x3, 0xef, 0xef, 0x52, 0x1c, 0x87, 0x90}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\DEL\ETX\153\229\248dS\153`\SOH\167\230\142f\DC1\233\135#<\250\245dX!\172\177\&9,\148", _pubPktID = 23552, _pubBody +// = "\165\207\195k*4\RS", _pubProps = [PropTopicAliasMaximum 20288,PropMaximumQoS 217]} TEST(Publish5QCTest, Encode22) { -uint8_t pkt[] = {0x3a, 0xb4, 0x2, 0x0, 0x1d, 0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3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x6b, 0x2a, 0x34, 0x1e}; + uint8_t topic_bytes[] = {0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, 0x8e, 0x66, 0x11, + 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, 0x94}; lwmqtt_string_t topic = {29, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = false; -uint8_t msg_bytes[] = {0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 20; - - uint8_t bytesprops0[] = {0x47, 0xef, 0xb8, 0x85, 0x17, 0x7e, 0x6a, 0x27, 0x5f, 0xb5, 0x74, 0xc2, 0x94, 0xdd, 0xe7, 0x1a, 0x2b, 0xa6, 0xe7, 0x17, 0xab, 0x9, 0x2c}; - uint8_t bytesprops1[] = {0x5b, 0x34, 0x3a, 0xdb, 0x47, 0x66, 0xa0, 0xce, 0xd0, 0x71, 0x76, 0xe8, 0x9f, 0x38, 0xbe, 0xd3, 0x60, 0xfd, 0xc0, 0xb6, 0xd5, 0x9}; - uint8_t bytesprops2[] = {0x91, 0x6e, 0x43, 0x48, 0xaa, 0xc8, 0xc6, 0x5b, 0x87, 0xf9, 0x58, 0xff, 0xd6, 0x84, 0x89, 0x28, 0xea, 0xb3, 0xdf, 0xbe}; - uint8_t bytesprops3[] = {0xc2, 0xed, 0xce, 0x6, 0x68, 0x6, 0x84, 0x29, 0xac, 0x9, 0xae, 0xce, 0xbd, 0xc0, 0x2c, 0xa1}; - uint8_t bytesprops4[] = {0x11, 0xa8, 0x85, 0xca, 0x0, 0x92, 0x94, 0x3d, 0x6, 0x67, 0xac, 0x3a, 0x1c, 0x72, 0x8c, 0x8b, 0x14, 0x86, 0xd0, 0xd1, 0x1f, 0x52}; - uint8_t bytesprops6[] = {0x8c, 0xc7}; - uint8_t bytesprops5[] = {0x5, 0xff, 0x1, 0x6d, 0xb1, 0x9a, 0x66, 0xcf, 0xc6, 0x93, 0xba, 0x7b, 0x74, 0x4f, 0x5c, 0x7a, 0x30, 0xe8, 0x9b, 0xe9, 0xba, 0xa9, 0xe6}; - uint8_t bytesprops7[] = {0x7a, 0x3d, 0x3e, 0x27, 0xab, 0xeb, 0xc0, 0x7b, 0x85, 0x41, 0x62, 0x41, 0xac, 0xb2, 0xaf, 0x2b, 0xd5, 0x89, 0x61, 0xd, 0x40}; - uint8_t bytesprops8[] = {0x31, 0xa2, 0x9c, 0x87, 0xe0, 0xa2, 0xf3, 0xf3, 0xd8, 0x3a, 0x7b, 0x76, 0x3b, 0xd5, 0xcc, 0x5e, 0xa0, 0xdb, 0xc1, 0x7, 0x8a, 0xe4, 0x4f, 0x58, 0xf0, 0x43, 0x96}; - uint8_t bytesprops9[] = {0xc, 0xb3, 0x1c, 0x42, 0x4d}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30493}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8185}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 432}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={23, (char*)&bytesprops5}, .v={2, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30860}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31114}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops9}}}, + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 7; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20288}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 217}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 17374, topic, msg, props); + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 23552, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "<\t\"\209\184\182u\179\DLE\NAK\195\141\EM\237\189}\143\EOT\STX\188|\188\t\USv\US\209\"\STX", _pubPktID = 17374, _pubBody = "\"=\237\FS\247\238\129>oH\131~\158k\231\193}\194\ESCu", _pubProps = [PropWillDelayInterval 30493,PropResponseTopic "G\239\184\133\ETB~j'_\181t\194\148\221\231\SUB+\166\231\ETB\171\t,",PropWillDelayInterval 8185,PropContentType "[4:\219Gf\160\206\208qv\232\159\&8\190\211`\253\192\182\213\t",PropAssignedClientIdentifier "\145nCH\170\200\198[\135\249X\255\214\132\137(\234\179\223\190",PropSharedSubscriptionAvailable 64,PropMessageExpiryInterval 432,PropSubscriptionIdentifier 5,PropRetainAvailable 204,PropRequestResponseInformation 110,PropResponseTopic "\194\237\206\ACKh\ACK\132)\172\t\174\206\189\192,\161",PropRequestProblemInformation 68,PropSubscriptionIdentifierAvailable 215,PropReasonString "\DC1\168\133\202\NUL\146\148=\ACKg\172:\FSr\140\139\DC4\134\208\209\USR",PropUserProperty "\ENQ\255\SOHm\177\154f\207\198\147\186{tO\\z0\232\155\233\186\169\230" "\140\199",PropSessionExpiryInterval 30860,PropSessionExpiryInterval 31114,PropPayloadFormatIndicator 25,PropAssignedClientIdentifier "z=>'\171\235\192{\133AbA\172\178\175+\213\137a\r@",PropPayloadFormatIndicator 106,PropRequestResponseInformation 81,PropServerReference "1\162\156\135\224\162\243\243\216:{v;\213\204^\160\219\193\a\138\228OX\240C\150",PropCorrelationData "\f\179\FSBM"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\DEL\ETX\153\229\248dS\153`\SOH\167\230\142f\DC1\233\135#<\250\245dX!\172\177\&9,\148", _pubPktID = 23552, _pubBody +// = "\165\207\195k*4\RS", _pubProps = [PropTopicAliasMaximum 20288,PropMaximumQoS 217]} TEST(Publish5QCTest, Decode22) { -uint8_t pkt[] = {0x3a, 0xb4, 0x2, 0x0, 0x1d, 0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2, 0x43, 0xde, 0xfd, 0x1, 0x18, 0x0, 0x0, 0x77, 0x1d, 0x8, 0x0, 0x17, 0x47, 0xef, 0xb8, 0x85, 0x17, 0x7e, 0x6a, 0x27, 0x5f, 0xb5, 0x74, 0xc2, 0x94, 0xdd, 0xe7, 0x1a, 0x2b, 0xa6, 0xe7, 0x17, 0xab, 0x9, 0x2c, 0x18, 0x0, 0x0, 0x1f, 0xf9, 0x3, 0x0, 0x16, 0x5b, 0x34, 0x3a, 0xdb, 0x47, 0x66, 0xa0, 0xce, 0xd0, 0x71, 0x76, 0xe8, 0x9f, 0x38, 0xbe, 0xd3, 0x60, 0xfd, 0xc0, 0xb6, 0xd5, 0x9, 0x12, 0x0, 0x14, 0x91, 0x6e, 0x43, 0x48, 0xaa, 0xc8, 0xc6, 0x5b, 0x87, 0xf9, 0x58, 0xff, 0xd6, 0x84, 0x89, 0x28, 0xea, 0xb3, 0xdf, 0xbe, 0x2a, 0x40, 0x2, 0x0, 0x0, 0x1, 0xb0, 0xb, 0x5, 0x25, 0xcc, 0x19, 0x6e, 0x8, 0x0, 0x10, 0xc2, 0xed, 0xce, 0x6, 0x68, 0x6, 0x84, 0x29, 0xac, 0x9, 0xae, 0xce, 0xbd, 0xc0, 0x2c, 0xa1, 0x17, 0x44, 0x29, 0xd7, 0x1f, 0x0, 0x16, 0x11, 0xa8, 0x85, 0xca, 0x0, 0x92, 0x94, 0x3d, 0x6, 0x67, 0xac, 0x3a, 0x1c, 0x72, 0x8c, 0x8b, 0x14, 0x86, 0xd0, 0xd1, 0x1f, 0x52, 0x26, 0x0, 0x17, 0x5, 0xff, 0x1, 0x6d, 0xb1, 0x9a, 0x66, 0xcf, 0xc6, 0x93, 0xba, 0x7b, 0x74, 0x4f, 0x5c, 0x7a, 0x30, 0xe8, 0x9b, 0xe9, 0xba, 0xa9, 0xe6, 0x0, 0x2, 0x8c, 0xc7, 0x11, 0x0, 0x0, 0x78, 0x8c, 0x11, 0x0, 0x0, 0x79, 0x8a, 0x1, 0x19, 0x12, 0x0, 0x15, 0x7a, 0x3d, 0x3e, 0x27, 0xab, 0xeb, 0xc0, 0x7b, 0x85, 0x41, 0x62, 0x41, 0xac, 0xb2, 0xaf, 0x2b, 0xd5, 0x89, 0x61, 0xd, 0x40, 0x1, 0x6a, 0x19, 0x51, 0x1c, 0x0, 0x1b, 0x31, 0xa2, 0x9c, 0x87, 0xe0, 0xa2, 0xf3, 0xf3, 0xd8, 0x3a, 0x7b, 0x76, 0x3b, 0xd5, 0xcc, 0x5e, 0xa0, 0xdb, 0xc1, 0x7, 0x8a, 0xe4, 0x4f, 0x58, 0xf0, 0x43, 0x96, 0x9, 0x0, 0x5, 0xc, 0xb3, 0x1c, 0x42, 0x4d, 0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3c, 0x9, 0x22, 0xd1, 0xb8, 0xb6, 0x75, 0xb3, 0x10, 0x15, 0xc3, 0x8d, 0x19, 0xed, 0xbd, 0x7d, 0x8f, 0x4, 0x2, 0xbc, 0x7c, 0xbc, 0x9, 0x1f, 0x76, 0x1f, 0xd1, 0x22, 0x2}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x22, 0x3d, 0xed, 0x1c, 0xf7, 0xee, 0x81, 0x3e, 0x6f, 0x48, 0x83, 0x7e, 0x9e, 0x6b, 0xe7, 0xc1, 0x7d, 0xc2, 0x1b, 0x75}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 17374); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); -EXPECT_EQ(msg.payload_len, 20); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x3d, 0x2e, 0x0, 0x1d, 0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, + 0x8e, 0x66, 0x11, 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, + 0x94, 0x5c, 0x0, 0x5, 0x22, 0x4f, 0x40, 0x24, 0xd9, 0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, 0x8e, 0x66, 0x11, + 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, 0x94}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 23552); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163\132d\157\149", _pubPktID = +// 24502, _pubBody = "\224h\ACK", _pubProps = [PropPayloadFormatIndicator 187,PropResponseInformation +// ".*R\129t\184\132\SUB\242\DLE2\NAK,\143\210\228c\205\161\215\190\237\179?\132\234[y",PropSubscriptionIdentifierAvailable +// 240,PropAssignedClientIdentifier "o",PropWillDelayInterval 26051,PropMaximumQoS 161,PropResponseInformation +// "\190\DC3\DC2|G\249q\226\RS\234\&7\157\ETX",PropAuthenticationMethod "z\249i\131&\198\228K",PropMessageExpiryInterval +// 6283,PropResponseTopic +// "\NAK\134\DEL\151qC\134\ESC;\247\184Dviu=\191\170\145\140\248\DC1\130\191F(z\SUB",PropAuthenticationMethod "Y\\N- +// \156\253\226\133}\147",PropSubscriptionIdentifierAvailable 116,PropAuthenticationData +// "\219n\154\210\157J\152\FSy\147`\CANN\245\197#C\190\128z\239\197",PropServerKeepAlive 1560,PropPayloadFormatIndicator +// 234,PropSharedSubscriptionAvailable 60,PropUserProperty +// "\224\184V\SYN\204\172\&4p\194\161\179,\220\&2$Y\129\DC2\233X\136\&3\233" +// "\253L\236\\\187Y\242FO-7d\145",PropPayloadFormatIndicator 5,PropServerReference +// "\250\DC1MA,\252\243\147\209^[\252\249\r",PropAuthenticationData +// "{V\255|\170\183%i\135\166a\254w\169\185xh$",PropMaximumQoS 99,PropServerReference +// "\137_\191\221\195;\207.",PropReceiveMaximum 1647]} +TEST(Publish5QCTest, Encode23) { + uint8_t pkt[] = {0x34, 0x8c, 0x2, 0x0, 0x5, 0xa3, 0x84, 0x64, 0x9d, 0x95, 0x5f, 0xb6, 0xfe, 0x1, 0x1, 0xbb, 0x1a, + 0x0, 0x1c, 0x2e, 0x2a, 0x52, 0x81, 0x74, 0xb8, 0x84, 0x1a, 0xf2, 0x10, 0x32, 0x15, 0x2c, 0x8f, 0xd2, + 0xe4, 0x63, 0xcd, 0xa1, 0xd7, 0xbe, 0xed, 0xb3, 0x3f, 0x84, 0xea, 0x5b, 0x79, 0x29, 0xf0, 0x12, 0x0, + 0x1, 0x6f, 0x18, 0x0, 0x0, 0x65, 0xc3, 0x24, 0xa1, 0x1a, 0x0, 0xd, 0xbe, 0x13, 0x12, 0x7c, 0x47, + 0xf9, 0x71, 0xe2, 0x1e, 0xea, 0x37, 0x9d, 0x3, 0x15, 0x0, 0x8, 0x7a, 0xf9, 0x69, 0x83, 0x26, 0xc6, + 0xe4, 0x4b, 0x2, 0x0, 0x0, 0x18, 0x8b, 0x8, 0x0, 0x1c, 0x15, 0x86, 0x7f, 0x97, 0x71, 0x43, 0x86, + 0x1b, 0x3b, 0xf7, 0xb8, 0x44, 0x76, 0x69, 0x75, 0x3d, 0xbf, 0xaa, 0x91, 0x8c, 0xf8, 0x11, 0x82, 0xbf, + 0x46, 0x28, 0x7a, 0x1a, 0x15, 0x0, 0xb, 0x59, 0x5c, 0x4e, 0x2d, 0x20, 0x9c, 0xfd, 0xe2, 0x85, 0x7d, + 0x93, 0x29, 0x74, 0x16, 0x0, 0x16, 0xdb, 0x6e, 0x9a, 0xd2, 0x9d, 0x4a, 0x98, 0x1c, 0x79, 0x93, 0x60, + 0x18, 0x4e, 0xf5, 0xc5, 0x23, 0x43, 0xbe, 0x80, 0x7a, 0xef, 0xc5, 0x13, 0x6, 0x18, 0x1, 0xea, 0x2a, + 0x3c, 0x26, 0x0, 0x17, 0xe0, 0xb8, 0x56, 0x16, 0xcc, 0xac, 0x34, 0x70, 0xc2, 0xa1, 0xb3, 0x2c, 0xdc, + 0x32, 0x24, 0x59, 0x81, 0x12, 0xe9, 0x58, 0x88, 0x33, 0xe9, 0x0, 0xd, 0xfd, 0x4c, 0xec, 0x5c, 0xbb, + 0x59, 0xf2, 0x46, 0x4f, 0x2d, 0x37, 0x64, 0x91, 0x1, 0x5, 0x1c, 0x0, 0xe, 0xfa, 0x11, 0x4d, 0x41, + 0x2c, 0xfc, 0xf3, 0x93, 0xd1, 0x5e, 0x5b, 0xfc, 0xf9, 0xd, 0x16, 0x0, 0x12, 0x7b, 0x56, 0xff, 0x7c, + 0xaa, 0xb7, 0x25, 0x69, 0x87, 0xa6, 0x61, 0xfe, 0x77, 0xa9, 0xb9, 0x78, 0x68, 0x24, 0x24, 0x63, 0x1c, + 0x0, 0x8, 0x89, 0x5f, 0xbf, 0xdd, 0xc3, 0x3b, 0xcf, 0x2e, 0x21, 0x6, 0x6f, 0xe0, 0x68, 0x6}; + uint8_t topic_bytes[] = {0xa3, 0x84, 0x64, 0x9d, 0x95}; + lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xe0, 0x68, 0x6}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; + + uint8_t bytesprops0[] = {0x2e, 0x2a, 0x52, 0x81, 0x74, 0xb8, 0x84, 0x1a, 0xf2, 0x10, 0x32, 0x15, 0x2c, 0x8f, + 0xd2, 0xe4, 0x63, 0xcd, 0xa1, 0xd7, 0xbe, 0xed, 0xb3, 0x3f, 0x84, 0xea, 0x5b, 0x79}; + uint8_t bytesprops1[] = {0x6f}; + uint8_t bytesprops2[] = {0xbe, 0x13, 0x12, 0x7c, 0x47, 0xf9, 0x71, 0xe2, 0x1e, 0xea, 0x37, 0x9d, 0x3}; + uint8_t bytesprops3[] = {0x7a, 0xf9, 0x69, 0x83, 0x26, 0xc6, 0xe4, 0x4b}; + uint8_t bytesprops4[] = {0x15, 0x86, 0x7f, 0x97, 0x71, 0x43, 0x86, 0x1b, 0x3b, 0xf7, 0xb8, 0x44, 0x76, 0x69, + 0x75, 0x3d, 0xbf, 0xaa, 0x91, 0x8c, 0xf8, 0x11, 0x82, 0xbf, 0x46, 0x28, 0x7a, 0x1a}; + uint8_t bytesprops5[] = {0x59, 0x5c, 0x4e, 0x2d, 0x20, 0x9c, 0xfd, 0xe2, 0x85, 0x7d, 0x93}; + uint8_t bytesprops6[] = {0xdb, 0x6e, 0x9a, 0xd2, 0x9d, 0x4a, 0x98, 0x1c, 0x79, 0x93, 0x60, + 0x18, 0x4e, 0xf5, 0xc5, 0x23, 0x43, 0xbe, 0x80, 0x7a, 0xef, 0xc5}; + uint8_t bytesprops8[] = {0xfd, 0x4c, 0xec, 0x5c, 0xbb, 0x59, 0xf2, 0x46, 0x4f, 0x2d, 0x37, 0x64, 0x91}; + uint8_t bytesprops7[] = {0xe0, 0xb8, 0x56, 0x16, 0xcc, 0xac, 0x34, 0x70, 0xc2, 0xa1, 0xb3, 0x2c, + 0xdc, 0x32, 0x24, 0x59, 0x81, 0x12, 0xe9, 0x58, 0x88, 0x33, 0xe9}; + uint8_t bytesprops9[] = {0xfa, 0x11, 0x4d, 0x41, 0x2c, 0xfc, 0xf3, 0x93, 0xd1, 0x5e, 0x5b, 0xfc, 0xf9, 0xd}; + uint8_t bytesprops10[] = {0x7b, 0x56, 0xff, 0x7c, 0xaa, 0xb7, 0x25, 0x69, 0x87, + 0xa6, 0x61, 0xfe, 0x77, 0xa9, 0xb9, 0x78, 0x68, 0x24}; + uint8_t bytesprops11[] = {0x89, 0x5f, 0xbf, 0xdd, 0xc3, 0x3b, 0xcf, 0x2e}; -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "L\250\DC3", _pubPktID = 6223, _pubBody = ".K\236\242\210\250\192\219\175h\175p\249", _pubProps = [PropSessionExpiryInterval 21695,PropSubscriptionIdentifierAvailable 48,PropUserProperty "h\160\209\172\SYN\ENQ\165\230=\215\207\137\244\DC3\NUL|\145\&6\153\193\140~f\SI\246/" "\231u2\n-\196\188\203F",PropServerKeepAlive 11554,PropAssignedClientIdentifier "\243\&8]\161ZF\r\166\198el\182",PropCorrelationData "\a_\228\&3Ve<\FS[i\238\r\169\188y\187\FS0\145o_8\160t\186",PropResponseInformation "\189\FS\136\EM7\131T\SUB\239\167\221\232\tA\ETX\235n\205",PropTopicAliasMaximum 25457,PropWildcardSubscriptionAvailable 204,PropTopicAliasMaximum 32590,PropPayloadFormatIndicator 81,PropMessageExpiryInterval 27542,PropRequestResponseInformation 163,PropCorrelationData "K\240\248\217\EMt\176\249y\177\DC4\ENQ\134\198\&21\200\NAK\155",PropPayloadFormatIndicator 193,PropServerKeepAlive 20073,PropSubscriptionIdentifierAvailable 37,PropTopicAliasMaximum 7907,PropSessionExpiryInterval 4906]} -TEST(Publish5QCTest, Encode23) { -uint8_t pkt[] = {0x35, 0xbe, 0x1, 0x0, 0x3, 0x4c, 0xfa, 0x13, 0x18, 0x4f, 0xa8, 0x1, 0x11, 0x0, 0x0, 0x54, 0xbf, 0x29, 0x30, 0x26, 0x0, 0x1a, 0x68, 0xa0, 0xd1, 0xac, 0x16, 0x5, 0xa5, 0xe6, 0x3d, 0xd7, 0xcf, 0x89, 0xf4, 0x13, 0x0, 0x7c, 0x91, 0x36, 0x99, 0xc1, 0x8c, 0x7e, 0x66, 0xf, 0xf6, 0x2f, 0x0, 0x9, 0xe7, 0x75, 0x32, 0xa, 0x2d, 0xc4, 0xbc, 0xcb, 0x46, 0x13, 0x2d, 0x22, 0x12, 0x0, 0xc, 0xf3, 0x38, 0x5d, 0xa1, 0x5a, 0x46, 0xd, 0xa6, 0xc6, 0x65, 0x6c, 0xb6, 0x9, 0x0, 0x19, 0x7, 0x5f, 0xe4, 0x33, 0x56, 0x65, 0x3c, 0x1c, 0x5b, 0x69, 0xee, 0xd, 0xa9, 0xbc, 0x79, 0xbb, 0x1c, 0x30, 0x91, 0x6f, 0x5f, 0x38, 0xa0, 0x74, 0xba, 0x1a, 0x0, 0x12, 0xbd, 0x1c, 0x88, 0x19, 0x37, 0x83, 0x54, 0x1a, 0xef, 0xa7, 0xdd, 0xe8, 0x9, 0x41, 0x3, 0xeb, 0x6e, 0xcd, 0x22, 0x63, 0x71, 0x28, 0xcc, 0x22, 0x7f, 0x4e, 0x1, 0x51, 0x2, 0x0, 0x0, 0x6b, 0x96, 0x19, 0xa3, 0x9, 0x0, 0x13, 0x4b, 0xf0, 0xf8, 0xd9, 0x19, 0x74, 0xb0, 0xf9, 0x79, 0xb1, 0x14, 0x5, 0x86, 0xc6, 0x32, 0x31, 0xc8, 0x15, 0x9b, 0x1, 0xc1, 0x13, 0x4e, 0x69, 0x29, 0x25, 0x22, 0x1e, 0xe3, 0x11, 0x0, 0x0, 0x13, 0x2a, 0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; - uint8_t topic_bytes[] = {0x4c, 0xfa, 0x13}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = true; -uint8_t msg_bytes[] = {0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 13; - - uint8_t bytesprops1[] = {0xe7, 0x75, 0x32, 0xa, 0x2d, 0xc4, 0xbc, 0xcb, 0x46}; - uint8_t bytesprops0[] = {0x68, 0xa0, 0xd1, 0xac, 0x16, 0x5, 0xa5, 0xe6, 0x3d, 0xd7, 0xcf, 0x89, 0xf4, 0x13, 0x0, 0x7c, 0x91, 0x36, 0x99, 0xc1, 0x8c, 0x7e, 0x66, 0xf, 0xf6, 0x2f}; - uint8_t bytesprops2[] = {0xf3, 0x38, 0x5d, 0xa1, 0x5a, 0x46, 0xd, 0xa6, 0xc6, 0x65, 0x6c, 0xb6}; - uint8_t bytesprops3[] = {0x7, 0x5f, 0xe4, 0x33, 0x56, 0x65, 0x3c, 0x1c, 0x5b, 0x69, 0xee, 0xd, 0xa9, 0xbc, 0x79, 0xbb, 0x1c, 0x30, 0x91, 0x6f, 0x5f, 0x38, 0xa0, 0x74, 0xba}; - uint8_t bytesprops4[] = {0xbd, 0x1c, 0x88, 0x19, 0x37, 0x83, 0x54, 0x1a, 0xef, 0xa7, 0xdd, 0xe8, 0x9, 0x41, 0x3, 0xeb, 0x6e, 0xcd}; - uint8_t bytesprops5[] = {0x4b, 0xf0, 0xf8, 0xd9, 0x19, 0x74, 0xb0, 0xf9, 0x79, 0xb1, 0x14, 0x5, 0x86, 0xc6, 0x32, 0x31, 0xc8, 0x15, 0x9b}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21695}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={26, (char*)&bytesprops0}, .v={9, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11554}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25457}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32590}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27542}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20073}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7907}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4906}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26051}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6283}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1560}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops7}, .v = {13, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1647}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 6223, topic, msg, props); + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24502, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "L\250\DC3", _pubPktID = 6223, _pubBody = ".K\236\242\210\250\192\219\175h\175p\249", _pubProps = [PropSessionExpiryInterval 21695,PropSubscriptionIdentifierAvailable 48,PropUserProperty "h\160\209\172\SYN\ENQ\165\230=\215\207\137\244\DC3\NUL|\145\&6\153\193\140~f\SI\246/" "\231u2\n-\196\188\203F",PropServerKeepAlive 11554,PropAssignedClientIdentifier "\243\&8]\161ZF\r\166\198el\182",PropCorrelationData "\a_\228\&3Ve<\FS[i\238\r\169\188y\187\FS0\145o_8\160t\186",PropResponseInformation "\189\FS\136\EM7\131T\SUB\239\167\221\232\tA\ETX\235n\205",PropTopicAliasMaximum 25457,PropWildcardSubscriptionAvailable 204,PropTopicAliasMaximum 32590,PropPayloadFormatIndicator 81,PropMessageExpiryInterval 27542,PropRequestResponseInformation 163,PropCorrelationData "K\240\248\217\EMt\176\249y\177\DC4\ENQ\134\198\&21\200\NAK\155",PropPayloadFormatIndicator 193,PropServerKeepAlive 20073,PropSubscriptionIdentifierAvailable 37,PropTopicAliasMaximum 7907,PropSessionExpiryInterval 4906]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163\132d\157\149", _pubPktID = +// 24502, _pubBody = "\224h\ACK", _pubProps = [PropPayloadFormatIndicator 187,PropResponseInformation +// ".*R\129t\184\132\SUB\242\DLE2\NAK,\143\210\228c\205\161\215\190\237\179?\132\234[y",PropSubscriptionIdentifierAvailable +// 240,PropAssignedClientIdentifier "o",PropWillDelayInterval 26051,PropMaximumQoS 161,PropResponseInformation +// "\190\DC3\DC2|G\249q\226\RS\234\&7\157\ETX",PropAuthenticationMethod "z\249i\131&\198\228K",PropMessageExpiryInterval +// 6283,PropResponseTopic +// "\NAK\134\DEL\151qC\134\ESC;\247\184Dviu=\191\170\145\140\248\DC1\130\191F(z\SUB",PropAuthenticationMethod "Y\\N- +// \156\253\226\133}\147",PropSubscriptionIdentifierAvailable 116,PropAuthenticationData +// "\219n\154\210\157J\152\FSy\147`\CANN\245\197#C\190\128z\239\197",PropServerKeepAlive 1560,PropPayloadFormatIndicator +// 234,PropSharedSubscriptionAvailable 60,PropUserProperty +// "\224\184V\SYN\204\172\&4p\194\161\179,\220\&2$Y\129\DC2\233X\136\&3\233" +// "\253L\236\\\187Y\242FO-7d\145",PropPayloadFormatIndicator 5,PropServerReference +// "\250\DC1MA,\252\243\147\209^[\252\249\r",PropAuthenticationData +// "{V\255|\170\183%i\135\166a\254w\169\185xh$",PropMaximumQoS 99,PropServerReference +// "\137_\191\221\195;\207.",PropReceiveMaximum 1647]} TEST(Publish5QCTest, Decode23) { -uint8_t pkt[] = {0x35, 0xbe, 0x1, 0x0, 0x3, 0x4c, 0xfa, 0x13, 0x18, 0x4f, 0xa8, 0x1, 0x11, 0x0, 0x0, 0x54, 0xbf, 0x29, 0x30, 0x26, 0x0, 0x1a, 0x68, 0xa0, 0xd1, 0xac, 0x16, 0x5, 0xa5, 0xe6, 0x3d, 0xd7, 0xcf, 0x89, 0xf4, 0x13, 0x0, 0x7c, 0x91, 0x36, 0x99, 0xc1, 0x8c, 0x7e, 0x66, 0xf, 0xf6, 0x2f, 0x0, 0x9, 0xe7, 0x75, 0x32, 0xa, 0x2d, 0xc4, 0xbc, 0xcb, 0x46, 0x13, 0x2d, 0x22, 0x12, 0x0, 0xc, 0xf3, 0x38, 0x5d, 0xa1, 0x5a, 0x46, 0xd, 0xa6, 0xc6, 0x65, 0x6c, 0xb6, 0x9, 0x0, 0x19, 0x7, 0x5f, 0xe4, 0x33, 0x56, 0x65, 0x3c, 0x1c, 0x5b, 0x69, 0xee, 0xd, 0xa9, 0xbc, 0x79, 0xbb, 0x1c, 0x30, 0x91, 0x6f, 0x5f, 0x38, 0xa0, 0x74, 0xba, 0x1a, 0x0, 0x12, 0xbd, 0x1c, 0x88, 0x19, 0x37, 0x83, 0x54, 0x1a, 0xef, 0xa7, 0xdd, 0xe8, 0x9, 0x41, 0x3, 0xeb, 0x6e, 0xcd, 0x22, 0x63, 0x71, 0x28, 0xcc, 0x22, 0x7f, 0x4e, 0x1, 0x51, 0x2, 0x0, 0x0, 0x6b, 0x96, 0x19, 0xa3, 0x9, 0x0, 0x13, 0x4b, 0xf0, 0xf8, 0xd9, 0x19, 0x74, 0xb0, 0xf9, 0x79, 0xb1, 0x14, 0x5, 0x86, 0xc6, 0x32, 0x31, 0xc8, 0x15, 0x9b, 0x1, 0xc1, 0x13, 0x4e, 0x69, 0x29, 0x25, 0x22, 0x1e, 0xe3, 0x11, 0x0, 0x0, 0x13, 0x2a, 0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x4c, 0xfa, 0x13}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2e, 0x4b, 0xec, 0xf2, 0xd2, 0xfa, 0xc0, 0xdb, 0xaf, 0x68, 0xaf, 0x70, 0xf9}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 6223); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); -EXPECT_EQ(msg.payload_len, 13); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x34, 0x8c, 0x2, 0x0, 0x5, 0xa3, 0x84, 0x64, 0x9d, 0x95, 0x5f, 0xb6, 0xfe, 0x1, 0x1, 0xbb, 0x1a, + 0x0, 0x1c, 0x2e, 0x2a, 0x52, 0x81, 0x74, 0xb8, 0x84, 0x1a, 0xf2, 0x10, 0x32, 0x15, 0x2c, 0x8f, 0xd2, + 0xe4, 0x63, 0xcd, 0xa1, 0xd7, 0xbe, 0xed, 0xb3, 0x3f, 0x84, 0xea, 0x5b, 0x79, 0x29, 0xf0, 0x12, 0x0, + 0x1, 0x6f, 0x18, 0x0, 0x0, 0x65, 0xc3, 0x24, 0xa1, 0x1a, 0x0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, 0xb9, 0x78, 0x68, 0x24, 0x24, 0x63, 0x1c, + 0x0, 0x8, 0x89, 0x5f, 0xbf, 0xdd, 0xc3, 0x3b, 0xcf, 0x2e, 0x21, 0x6, 0x6f, 0xe0, 0x68, 0x6}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} - - -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "^;.\197y\SO\163S\245~\178g\ETB", _pubPktID = 32148, _pubBody = "V\DC4\DC3 ZQ\164[\157n\197\162X\"*\220LH\RSF\206\255)Xpu!=", _pubProps = [PropSharedSubscriptionAvailable 5]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xa3, 0x84, 0x64, 0x9d, 0x95}; + lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xe0, 0x68, 0x6}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 24502); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\153\164\218\195=\160\170\223\157 +// b%X\222\199hG0\198K3y\207\128J\188\176\225", _pubPktID = 0, _pubBody = "\SOH\191\156", _pubProps = +// [PropServerKeepAlive 29860,PropAuthenticationMethod +// "\246\EOT\240\184\137\197\234\173b<\139\208",PropSubscriptionIdentifierAvailable 117]} TEST(Publish5QCTest, Encode24) { -uint8_t pkt[] = {0x34, 0x30, 0x0, 0xd, 0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17, 0x7d, 0x94, 0x2, 0x2a, 0x5, 0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; - uint8_t topic_bytes[] = {0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = false; -uint8_t msg_bytes[] = {0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 28; + uint8_t pkt[] = {0x38, 0x36, 0x0, 0x1c, 0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, + 0x62, 0x25, 0x58, 0xde, 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, + 0x4a, 0xbc, 0xb0, 0xe1, 0x14, 0x13, 0x74, 0xa4, 0x15, 0x0, 0xc, 0xf6, 0x4, 0xf0, + 0xb8, 0x89, 0xc5, 0xea, 0xad, 0x62, 0x3c, 0x8b, 0xd0, 0x29, 0x75, 0x1, 0xbf, 0x9c}; + uint8_t topic_bytes[] = {0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, + 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x1, 0xbf, 0x9c}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 3; + + uint8_t bytesprops0[] = {0xf6, 0x4, 0xf0, 0xb8, 0x89, 0xc5, 0xea, 0xad, 0x62, 0x3c, 0x8b, 0xd0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29860}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 117}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32148, topic, msg, props); + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "^;.\197y\SO\163S\245~\178g\ETB", _pubPktID = 32148, _pubBody = "V\DC4\DC3 ZQ\164[\157n\197\162X\"*\220LH\RSF\206\255)Xpu!=", _pubProps = [PropSharedSubscriptionAvailable 5]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\153\164\218\195=\160\170\223\157 +// b%X\222\199hG0\198K3y\207\128J\188\176\225", _pubPktID = 0, _pubBody = "\SOH\191\156", _pubProps = +// [PropServerKeepAlive 29860,PropAuthenticationMethod +// "\246\EOT\240\184\137\197\234\173b<\139\208",PropSubscriptionIdentifierAvailable 117]} TEST(Publish5QCTest, Decode24) { -uint8_t pkt[] = {0x34, 0x30, 0x0, 0xd, 0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17, 0x7d, 0x94, 0x2, 0x2a, 0x5, 0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5e, 0x3b, 0x2e, 0xc5, 0x79, 0xe, 0xa3, 0x53, 0xf5, 0x7e, 0xb2, 0x67, 0x17}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x56, 0x14, 0x13, 0x20, 0x5a, 0x51, 0xa4, 0x5b, 0x9d, 0x6e, 0xc5, 0xa2, 0x58, 0x22, 0x2a, 0xdc, 0x4c, 0x48, 0x1e, 0x46, 0xce, 0xff, 0x29, 0x58, 0x70, 0x75, 0x21, 0x3d}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 32148); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); -EXPECT_EQ(msg.payload_len, 28); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x38, 0x36, 0x0, 0x1c, 0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, + 0x62, 0x25, 0x58, 0xde, 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, + 0x4a, 0xbc, 0xb0, 0xe1, 0x14, 0x13, 0x74, 0xa4, 0x15, 0x0, 0xc, 0xf6, 0x4, 0xf0, + 0xb8, 0x89, 0xc5, 0xea, 0xad, 0x62, 0x3c, 0x8b, 0xd0, 0x29, 0x75, 0x1, 0xbf, 0x9c}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, + 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1, 0xbf, 0x9c}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "Z\162]m\132\183R\SUBWRu", _pubPktID +// = 13838, _pubBody = +// "{&\208\GS\139\141\&9\162*\207\153\136\148\172\STX\190\162e\RS\\\163\194\141\DC1\SYN\156\204\236", _pubProps = +// [PropMaximumQoS 172,PropCorrelationData "(",PropMessageExpiryInterval 4898,PropPayloadFormatIndicator +// 242,PropSubscriptionIdentifierAvailable 76,PropResponseInformation +// "S\154\150\166\EOT\224\208\&9\NUL\190\210]6\179\219\166\173x*",PropAuthenticationData +// "\146X\192<|\200\215\DC1\204\206\a\205,\164\ETB\SI\226;c\ETB4",PropWildcardSubscriptionAvailable 121]} +TEST(Publish5QCTest, Encode25) { + uint8_t pkt[] = {0x3a, 0x6b, 0x0, 0xb, 0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75, 0x36, + 0xe, 0x3f, 0x24, 0xac, 0x9, 0x0, 0x1, 0x28, 0x2, 0x0, 0x0, 0x13, 0x22, 0x1, 0xf2, 0x29, + 0x4c, 0x1a, 0x0, 0x13, 0x53, 0x9a, 0x96, 0xa6, 0x4, 0xe0, 0xd0, 0x39, 0x0, 0xbe, 0xd2, 0x5d, + 0x36, 0xb3, 0xdb, 0xa6, 0xad, 0x78, 0x2a, 0x16, 0x0, 0x15, 0x92, 0x58, 0xc0, 0x3c, 0x7c, 0xc8, + 0xd7, 0x11, 0xcc, 0xce, 0x7, 0xcd, 0x2c, 0xa4, 0x17, 0xf, 0xe2, 0x3b, 0x63, 0x17, 0x34, 0x28, + 0x79, 0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, 0xac, 0x2, + 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; + uint8_t topic_bytes[] = {0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, 0xac, + 0x2, 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 28; + + uint8_t bytesprops0[] = {0x28}; + uint8_t bytesprops1[] = {0x53, 0x9a, 0x96, 0xa6, 0x4, 0xe0, 0xd0, 0x39, 0x0, 0xbe, + 0xd2, 0x5d, 0x36, 0xb3, 0xdb, 0xa6, 0xad, 0x78, 0x2a}; + uint8_t bytesprops2[] = {0x92, 0x58, 0xc0, 0x3c, 0x7c, 0xc8, 0xd7, 0x11, 0xcc, 0xce, 0x7, + 0xcd, 0x2c, 0xa4, 0x17, 0xf, 0xe2, 0x3b, 0x63, 0x17, 0x34}; -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "Vk\181\201\ETXZ\DC4\208\170\201\tDEB\153]Q\232", _pubPktID = 2981, _pubBody = "\\>V\153p|W\163\148\254\SYN@q\238?", _pubProps = [PropPayloadFormatIndicator 104,PropMaximumQoS 226,PropWildcardSubscriptionAvailable 205,PropWildcardSubscriptionAvailable 60,PropCorrelationData "\235\225\DLE\160\166;(topic.data), 18); -EXPECT_EQ(msg.payload_len, 15); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - - -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 12988, _pubBody = "\252Q\161\SUB\150\190\247\174s\151T8\149C\NAK9;)\159\188\140bs", _pubProps = [PropRequestProblemInformation 31,PropAssignedClientIdentifier "\DC3\182\192\154\225\188^@\162S\227\251\178",PropAuthenticationMethod "l\171X\185\ETBzS\160",PropRetainAvailable 56,PropSubscriptionIdentifier 3,PropResponseTopic "\rGO4\241\253\189",PropPayloadFormatIndicator 10,PropWillDelayInterval 27162,PropUserProperty "\t|Q\220\160\SOH\160\DC4%\208\208\DELV\221 \157\205\&4\162" "\133t\211\178\159\232\204HKv|y\SOH\224\&6\234",PropAssignedClientIdentifier "",PropRequestProblemInformation 241,PropServerKeepAlive 24630,PropMessageExpiryInterval 3172,PropUserProperty "R\191\DC2\242Ix\135\156.\141\205i\155\174\196\&1" "\SYN\160.\234\RS)",PropSubscriptionIdentifier 19,PropUserProperty "\146[\196\170\191+\231(y#\US,\151\224\ETB\233\215\142)#\ETX\ENQ\214\&0\253\200" "\237.\226]\171\248\148\189j\162\RS\247Z\ETX\165\207\224o\137",PropSharedSubscriptionAvailable 62,PropSubscriptionIdentifier 10,PropAuthenticationData "\184\&2\244\200\164nX5\251\191:\249z\172\168\210;\182\NAK\190C\179\147W\237Q\192\196"]} -TEST(Publish5QCTest, Encode26) { -uint8_t pkt[] = {0x33, 0xf6, 0x1, 0x0, 0x0, 0x32, 0xbc, 0xd9, 0x1, 0x17, 0x1f, 0x12, 0x0, 0xd, 0x13, 0xb6, 0xc0, 0x9a, 0xe1, 0xbc, 0x5e, 0x40, 0xa2, 0x53, 0xe3, 0xfb, 0xb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0x3b, 0xb6, 0x15, 0xbe, 0x43, 0xb3, 0x93, 0x57, 0xed, 0x51, 0xc0, 0xc4, 0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; - - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 23; - - uint8_t bytesprops0[] = {0x13, 0xb6, 0xc0, 0x9a, 0xe1, 0xbc, 0x5e, 0x40, 0xa2, 0x53, 0xe3, 0xfb, 0xb2}; - uint8_t bytesprops1[] = {0x6c, 0xab, 0x58, 0xb9, 0x17, 0x7a, 0x53, 0xa0}; - uint8_t bytesprops2[] = {0xd, 0x47, 0x4f, 0x34, 0xf1, 0xfd, 0xbd}; - uint8_t bytesprops4[] = {0x85, 0x74, 0xd3, 0xb2, 0x9f, 0xe8, 0xcc, 0x48, 0x4b, 0x76, 0x7c, 0x79, 0x1, 0xe0, 0x36, 0xea}; - uint8_t bytesprops3[] = {0x9, 0x7c, 0x51, 0xdc, 0xa0, 0x1, 0xa0, 0x14, 0x25, 0xd0, 0xd0, 0x7f, 0x56, 0xdd, 0x20, 0x9d, 0xcd, 0x34, 0xa2}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops7[] = {0x16, 0xa0, 0x2e, 0xea, 0x1e, 0x29}; - uint8_t bytesprops6[] = {0x52, 0xbf, 0x12, 0xf2, 0x49, 0x78, 0x87, 0x9c, 0x2e, 0x8d, 0xcd, 0x69, 0x9b, 0xae, 0xc4, 0x31}; - uint8_t bytesprops9[] = {0xed, 0x2e, 0xe2, 0x5d, 0xab, 0xf8, 0x94, 0xbd, 0x6a, 0xa2, 0x1e, 0xf7, 0x5a, 0x3, 0xa5, 0xcf, 0xe0, 0x6f, 0x89}; - uint8_t bytesprops8[] = {0x92, 0x5b, 0xc4, 0xaa, 0xbf, 0x2b, 0xe7, 0x28, 0x79, 0x23, 0x1f, 0x2c, 0x97, 0xe0, 0x17, 0xe9, 0xd7, 0x8e, 0x29, 0x23, 0x3, 0x5, 0xd6, 0x30, 0xfd, 0xc8}; - uint8_t bytesprops10[] = {0xb8, 0x32, 0xf4, 0xc8, 0xa4, 0x6e, 0x58, 0x35, 0xfb, 0xbf, 0x3a, 0xf9, 0x7a, 0xac, 0xa8, 0xd2, 0x3b, 0xb6, 0x15, 0xbe, 0x43, 0xb3, 0x93, 0x57, 0xed, 0x51, 0xc0, 0xc4}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27162}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={19, (char*)&bytesprops3}, .v={16, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24630}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3172}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={16, (char*)&bytesprops6}, .v={6, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={26, (char*)&bytesprops8}, .v={19, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops10}}}, - }; + uint8_t pkt[] = {0x3a, 0x6b, 0x0, 0xb, 0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75, 0x36, + 0xe, 0x3f, 0x24, 0xac, 0x9, 0x0, 0x1, 0x28, 0x2, 0x0, 0x0, 0x13, 0x22, 0x1, 0xf2, 0x29, + 0x4c, 0x1a, 0x0, 0x13, 0x53, 0x9a, 0x96, 0xa6, 0x4, 0xe0, 0xd0, 0x39, 0x0, 0xbe, 0xd2, 0x5d, + 0x36, 0xb3, 0xdb, 0xa6, 0xad, 0x78, 0x2a, 0x16, 0x0, 0x15, 0x92, 0x58, 0xc0, 0x3c, 0x7c, 0xc8, + 0xd7, 0x11, 0xcc, 0xce, 0x7, 0xcd, 0x2c, 0xa4, 0x17, 0xf, 0xe2, 0x3b, 0x63, 0x17, 0x34, 0x28, + 0x79, 0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, 0xac, 0x2, + 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 12988, topic, msg, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, 0xac, + 0x2, 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 13838); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\245\STX\252\CAN\215\187\FS^!\141\191\250|\190\164I\153\169,U`", _pubPktID = 10215, _pubBody = +// "\199r\153\234\&0UY.\201J\198\SO", _pubProps = [PropWildcardSubscriptionAvailable 107,PropMaximumPacketSize +// 1844,PropContentType "\US\202C\131\167o",PropResponseTopic "",PropSubscriptionIdentifierAvailable +// 105,PropSubscriptionIdentifierAvailable 186,PropReasonString "Ry\SUB\\",PropTopicAlias 32557,PropMaximumQoS +// 23,PropRequestProblemInformation 72,PropSessionExpiryInterval 30830,PropTopicAlias 29267,PropTopicAlias +// 1624,PropReceiveMaximum 23007,PropRetainAvailable 148]} +TEST(Publish5QCTest, Encode26) { + uint8_t pkt[] = {0x33, 0x5b, 0x0, 0x15, 0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, 0xfa, + 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60, 0x27, 0xe7, 0x35, 0x28, 0x6b, 0x27, 0x0, + 0x0, 0x7, 0x34, 0x3, 0x0, 0x6, 0x1f, 0xca, 0x43, 0x83, 0xa7, 0x6f, 0x8, 0x0, 0x0, 0x29, + 0x69, 0x29, 0xba, 0x1f, 0x0, 0x4, 0x52, 0x79, 0x1a, 0x5c, 0x23, 0x7f, 0x2d, 0x24, 0x17, 0x17, + 0x48, 0x11, 0x0, 0x0, 0x78, 0x6e, 0x23, 0x72, 0x53, 0x23, 0x6, 0x58, 0x21, 0x59, 0xdf, 0x25, + 0x94, 0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + uint8_t topic_bytes[] = {0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, + 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 12; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 12988, _pubBody = "\252Q\161\SUB\150\190\247\174s\151T8\149C\NAK9;)\159\188\140bs", _pubProps = [PropRequestProblemInformation 31,PropAssignedClientIdentifier "\DC3\182\192\154\225\188^@\162S\227\251\178",PropAuthenticationMethod "l\171X\185\ETBzS\160",PropRetainAvailable 56,PropSubscriptionIdentifier 3,PropResponseTopic "\rGO4\241\253\189",PropPayloadFormatIndicator 10,PropWillDelayInterval 27162,PropUserProperty "\t|Q\220\160\SOH\160\DC4%\208\208\DELV\221 \157\205\&4\162" "\133t\211\178\159\232\204HKv|y\SOH\224\&6\234",PropAssignedClientIdentifier "",PropRequestProblemInformation 241,PropServerKeepAlive 24630,PropMessageExpiryInterval 3172,PropUserProperty "R\191\DC2\242Ix\135\156.\141\205i\155\174\196\&1" "\SYN\160.\234\RS)",PropSubscriptionIdentifier 19,PropUserProperty "\146[\196\170\191+\231(y#\US,\151\224\ETB\233\215\142)#\ETX\ENQ\214\&0\253\200" "\237.\226]\171\248\148\189j\162\RS\247Z\ETX\165\207\224o\137",PropSharedSubscriptionAvailable 62,PropSubscriptionIdentifier 10,PropAuthenticationData "\184\&2\244\200\164nX5\251\191:\249z\172\168\210;\182\NAK\190C\179\147W\237Q\192\196"]} -TEST(Publish5QCTest, Decode26) { -uint8_t pkt[] = {0x33, 0xf6, 0x1, 0x0, 0x0, 0x32, 0xbc, 0xd9, 0x1, 0x17, 0x1f, 0x12, 0x0, 0xd, 0x13, 0xb6, 0xc0, 0x9a, 0xe1, 0xbc, 0x5e, 0x40, 0xa2, 0x53, 0xe3, 0xfb, 0xb2, 0x15, 0x0, 0x8, 0x6c, 0xab, 0x58, 0xb9, 0x17, 0x7a, 0x53, 0xa0, 0x25, 0x38, 0xb, 0x3, 0x8, 0x0, 0x7, 0xd, 0x47, 0x4f, 0x34, 0xf1, 0xfd,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, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfc, 0x51, 0xa1, 0x1a, 0x96, 0xbe, 0xf7, 0xae, 0x73, 0x97, 0x54, 0x38, 0x95, 0x43, 0x15, 0x39, 0x3b, 0x29, 0x9f, 0xbc, 0x8c, 0x62, 0x73}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 12988); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); -EXPECT_EQ(msg.payload_len, 23); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t bytesprops0[] = {0x1f, 0xca, 0x43, 0x83, 0xa7, 0x6f}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x52, 0x79, 0x1a, 0x5c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1844}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32557}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30830}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29267}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1624}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23007}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 148}}, + }; + + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10215, topic, msg, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\245\STX\252\CAN\215\187\FS^!\141\191\250|\190\164I\153\169,U`", _pubPktID = 10215, _pubBody = +// "\199r\153\234\&0UY.\201J\198\SO", _pubProps = [PropWildcardSubscriptionAvailable 107,PropMaximumPacketSize +// 1844,PropContentType "\US\202C\131\167o",PropResponseTopic "",PropSubscriptionIdentifierAvailable +// 105,PropSubscriptionIdentifierAvailable 186,PropReasonString "Ry\SUB\\",PropTopicAlias 32557,PropMaximumQoS +// 23,PropRequestProblemInformation 72,PropSessionExpiryInterval 30830,PropTopicAlias 29267,PropTopicAlias +// 1624,PropReceiveMaximum 23007,PropRetainAvailable 148]} +TEST(Publish5QCTest, Decode26) { + uint8_t pkt[] = {0x33, 0x5b, 0x0, 0x15, 0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, 0xfa, + 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60, 0x27, 0xe7, 0x35, 0x28, 0x6b, 0x27, 0x0, + 0x0, 0x7, 0x34, 0x3, 0x0, 0x6, 0x1f, 0xca, 0x43, 0x83, 0xa7, 0x6f, 0x8, 0x0, 0x0, 0x29, + 0x69, 0x29, 0xba, 0x1f, 0x0, 0x4, 0x52, 0x79, 0x1a, 0x5c, 0x23, 0x7f, 0x2d, 0x24, 0x17, 0x17, + 0x48, 0x11, 0x0, 0x0, 0x78, 0x6e, 0x23, 0x72, 0x53, 0x23, 0x6, 0x58, 0x21, 0x59, 0xdf, 0x25, + 0x94, 0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\a\206+\241_)~\225\174V\232:\184e", _pubPktID = 1045, _pubBody = "E\243x", _pubProps = [PropUserProperty "\135O\CAN\f(\133\158\229\237\&0:g$\SUB((\243W\228" "6\214\190\&0\238[\170\&5k\222\192?`\202,j\166\STX[\DLE\211\228\214\230\191\210\216W",PropUserProperty "Q\199y\153\173\ENQ\161\205DUN\128\231\149" "Eh\176\198\182\233\162\153#a\157\v\DLE\STX\135\NAK\201\128H\140",PropRequestResponseInformation 104,PropAssignedClientIdentifier "w\147\SUB\154RXi#\179\241\169k/E\187\170\US\SI(o]ZT\177\EM<\178",PropAuthenticationMethod "\206\160\SYN\ETB\231\245WV@\DELv\235",PropSessionExpiryInterval 9123,PropRequestProblemInformation 198,PropSharedSubscriptionAvailable 144,PropWildcardSubscriptionAvailable 30,PropTopicAlias 14192,PropTopicAliasMaximum 28876,PropContentType "\218\195\141G\183\247\135+\242fa\220\239\167\173u\SI\235\141",PropRequestProblemInformation 177,PropSessionExpiryInterval 85,PropReceiveMaximum 15015,PropResponseTopic "t$S\140\222\&6",PropRetainAvailable 130,PropPayloadFormatIndicator 149,PropResponseInformation "%!",PropResponseInformation "#z\191\231\149\EM\218\t\SYN?\202p\207\225\150c\t\228",PropUserProperty "\213z\f\194<\151" "\233\STX\184a),>\245I&\184\241\tE\224\ESC0h\130\138\254\206\209!M",PropServerKeepAlive 22611,PropCorrelationData "\128}\SO\223\179\158\136EI\244\145\ESCHq\DC4>:+\242\129\196I\245&\196\241",PropMessageExpiryInterval 9516,PropRetainAvailable 117,PropTopicAliasMaximum 18796,PropAuthenticationData "\228*W"]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, + 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10215); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\187\192\216\&6]J\244\v\252\&6\149\EOT\128\ETX", _pubPktID = 11476, _pubBody = +// "\254&\138\150\179\238u\252\176\246'\140\196", _pubProps = [PropServerReference +// "\158s\136m\193\205\148G\247g\SI\GS\NAK\188\135\r"]} TEST(Publish5QCTest, Encode27) { -uint8_t pkt[] = {0x33, 0xcd, 0x2, 0x0, 0xe, 0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65, 0x4, 0x15, 0xb6, 0x2, 0x26, 0x0, 0x13, 0x87, 0x4f, 0x18, 0xc, 0x28, 0x85, 0x9e, 0xe5, 0xed, 0x30, 0x3a, 0x67, 0x24, 0x1a, 0x28, 0x28, 0xf3, 0x57, 0xe4, 0x0, 0x1c, 0x36, 0xd6, 0xbe, 0x30, 0xee, 0x5b, 0xaa, 0x35, 0x6b, 0xde, 0xc0, 0x3f, 0x60, 0xca, 0x2c, 0x6a, 0xa6, 0x2, 0x5b, 0x10, 0xd3, 0xe4, 0xd6, 0xe6, 0xbf, 0xd2, 0xd8, 0x57, 0x26, 0x0, 0xe, 0x51, 0xc7, 0x79, 0x99, 0xad, 0x5, 0xa1, 0xcd, 0x44, 0x55, 0x4e, 0x80, 0xe7, 0x95, 0x0, 0x14, 0x45, 0x68, 0xb0, 0xc6, 0xb6, 0xe9, 0xa2, 0x99, 0x23, 0x61, 0x9d, 0xb, 0x10, 0x2, 0x87, 0x15, 0xc9, 0x80, 0x48, 0x8c, 0x19, 0x68, 0x12, 0x0, 0x1b, 0x77, 0x93, 0x1a, 0x9a, 0x52, 0x58, 0x69, 0x23, 0xb3, 0xf1, 0xa9, 0x6b, 0x2f, 0x45, 0xbb, 0xaa, 0x1f, 0xf, 0x28, 0x6f, 0x5d, 0x5a, 0x54, 0xb1, 0x19, 0x3c, 0xb2, 0x15, 0x0, 0xc, 0xce, 0xa0, 0x16, 0x17, 0xe7, 0xf5, 0x57, 0x56, 0x40, 0x7f, 0x76, 0xeb, 0x11, 0x0, 0x0, 0x23, 0xa3, 0x17, 0xc6, 0x2a, 0x90, 0x28, 0x1e, 0x23, 0x37, 0x70, 0x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a, 0xf4, 0xb, 0xfc, 0x36, + 0x95, 0x4, 0x80, 0x3, 0x2c, 0xd4, 0x13, 0x1c, 0x0, 0x10, 0x9e, 0x73, 0x88, 0x6d, + 0xc1, 0xcd, 0x94, 0x47, 0xf7, 0x67, 0xf, 0x1d, 0x15, 0xbc, 0x87, 0xd, 0xfe, 0x26, + 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + uint8_t topic_bytes[] = {0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, 0x3}; lwmqtt_string_t topic = {14, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x45, 0xf3, 0x78}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 3; - - uint8_t bytesprops1[] = {0x36, 0xd6, 0xbe, 0x30, 0xee, 0x5b, 0xaa, 0x35, 0x6b, 0xde, 0xc0, 0x3f, 0x60, 0xca, 0x2c, 0x6a, 0xa6, 0x2, 0x5b, 0x10, 0xd3, 0xe4, 0xd6, 0xe6, 0xbf, 0xd2, 0xd8, 0x57}; - uint8_t bytesprops0[] = {0x87, 0x4f, 0x18, 0xc, 0x28, 0x85, 0x9e, 0xe5, 0xed, 0x30, 0x3a, 0x67, 0x24, 0x1a, 0x28, 0x28, 0xf3, 0x57, 0xe4}; - uint8_t bytesprops3[] = {0x45, 0x68, 0xb0, 0xc6, 0xb6, 0xe9, 0xa2, 0x99, 0x23, 0x61, 0x9d, 0xb, 0x10, 0x2, 0x87, 0x15, 0xc9, 0x80, 0x48, 0x8c}; - uint8_t bytesprops2[] = {0x51, 0xc7, 0x79, 0x99, 0xad, 0x5, 0xa1, 0xcd, 0x44, 0x55, 0x4e, 0x80, 0xe7, 0x95}; - uint8_t bytesprops4[] = {0x77, 0x93, 0x1a, 0x9a, 0x52, 0x58, 0x69, 0x23, 0xb3, 0xf1, 0xa9, 0x6b, 0x2f, 0x45, 0xbb, 0xaa, 0x1f, 0xf, 0x28, 0x6f, 0x5d, 0x5a, 0x54, 0xb1, 0x19, 0x3c, 0xb2}; - uint8_t bytesprops5[] = {0xce, 0xa0, 0x16, 0x17, 0xe7, 0xf5, 0x57, 0x56, 0x40, 0x7f, 0x76, 0xeb}; - uint8_t bytesprops6[] = {0xda, 0xc3, 0x8d, 0x47, 0xb7, 0xf7, 0x87, 0x2b, 0xf2, 0x66, 0x61, 0xdc, 0xef, 0xa7, 0xad, 0x75, 0xf, 0xeb, 0x8d}; - uint8_t bytesprops7[] = {0x74, 0x24, 0x53, 0x8c, 0xde, 0x36}; - uint8_t bytesprops8[] = {0x25, 0x21}; - uint8_t bytesprops9[] = {0x23, 0x7a, 0xbf, 0xe7, 0x95, 0x19, 0xda, 0x9, 0x16, 0x3f, 0xca, 0x70, 0xcf, 0xe1, 0x96, 0x63, 0x9, 0xe4}; - uint8_t bytesprops11[] = {0xe9, 0x2, 0xb8, 0x61, 0x29, 0x2c, 0x3e, 0xf5, 0x49, 0x26, 0xb8, 0xf1, 0x9, 0x45, 0xe0, 0x1b, 0x30, 0x68, 0x82, 0x8a, 0xfe, 0xce, 0xd1, 0x21, 0x4d}; - uint8_t bytesprops10[] = {0xd5, 0x7a, 0xc, 0xc2, 0x3c, 0x97}; - uint8_t bytesprops12[] = {0x80, 0x7d, 0xe, 0xdf, 0xb3, 0x9e, 0x88, 0x45, 0x49, 0xf4, 0x91, 0x1b, 0x48, 0x71, 0x14, 0x3e, 0x3a, 0x2b, 0xf2, 0x81, 0xc4, 0x49, 0xf5, 0x26, 0xc4, 0xf1}; - uint8_t bytesprops13[] = {0xe4, 0x2a, 0x57}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={19, (char*)&bytesprops0}, .v={28, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={14, (char*)&bytesprops2}, .v={20, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9123}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14192}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28876}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 85}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15015}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={6, (char*)&bytesprops10}, .v={25, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22611}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9516}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18796}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops13}}}, - }; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 13; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 1045, topic, msg, props); + uint8_t bytesprops0[] = {0x9e, 0x73, 0x88, 0x6d, 0xc1, 0xcd, 0x94, 0x47, + 0xf7, 0x67, 0xf, 0x1d, 0x15, 0xbc, 0x87, 0xd}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, + }; -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\a\206+\241_)~\225\174V\232:\184e", _pubPktID = 1045, _pubBody = "E\243x", _pubProps = [PropUserProperty "\135O\CAN\f(\133\158\229\237\&0:g$\SUB((\243W\228" "6\214\190\&0\238[\170\&5k\222\192?`\202,j\166\STX[\DLE\211\228\214\230\191\210\216W",PropUserProperty "Q\199y\153\173\ENQ\161\205DUN\128\231\149" "Eh\176\198\182\233\162\153#a\157\v\DLE\STX\135\NAK\201\128H\140",PropRequestResponseInformation 104,PropAssignedClientIdentifier "w\147\SUB\154RXi#\179\241\169k/E\187\170\US\SI(o]ZT\177\EM<\178",PropAuthenticationMethod "\206\160\SYN\ETB\231\245WV@\DELv\235",PropSessionExpiryInterval 9123,PropRequestProblemInformation 198,PropSharedSubscriptionAvailable 144,PropWildcardSubscriptionAvailable 30,PropTopicAlias 14192,PropTopicAliasMaximum 28876,PropContentType "\218\195\141G\183\247\135+\242fa\220\239\167\173u\SI\235\141",PropRequestProblemInformation 177,PropSessionExpiryInterval 85,PropReceiveMaximum 15015,PropResponseTopic "t$S\140\222\&6",PropRetainAvailable 130,PropPayloadFormatIndicator 149,PropResponseInformation "%!",PropResponseInformation "#z\191\231\149\EM\218\t\SYN?\202p\207\225\150c\t\228",PropUserProperty "\213z\f\194<\151" "\233\STX\184a),>\245I&\184\241\tE\224\ESC0h\130\138\254\206\209!M",PropServerKeepAlive 22611,PropCorrelationData "\128}\SO\223\179\158\136EI\244\145\ESCHq\DC4>:+\242\129\196I\245&\196\241",PropMessageExpiryInterval 9516,PropRetainAvailable 117,PropTopicAliasMaximum 18796,PropAuthenticationData "\228*W"]} -TEST(Publish5QCTest, Decode27) { -uint8_t pkt[] = {0x33, 0xcd, 0x2, 0x0, 0xe, 0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65, 0x4, 0x15, 0xb6, 0x2, 0x26, 0x0, 0x13, 0x87, 0x4f, 0x18, 0xc, 0x28, 0x85, 0x9e, 0xe5, 0xed, 0x30, 0x3a, 0x67, 0x24, 0x1a, 0x28, 0x28, 0xf3, 0x57, 0xe4, 0x0, 0x1c, 0x36, 0xd6, 0xbe, 0x30, 0xee, 0x5b, 0xaa, 0x35, 0x6b, 0xde, 0xc0, 0x3f, 0x60, 0xca, 0x2c, 0x6a, 0xa6, 0x2, 0x5b, 0x10, 0xd3, 0xe4, 0xd6, 0xe6, 0xbf, 0xd2, 0xd8, 0x57, 0x26, 0x0, 0xe, 0x51, 0xc7, 0x79, 0x99, 0xad, 0x5, 0xa1, 0xcd, 0x44, 0x55, 0x4e, 0x80, 0xe7, 0x95, 0x0, 0x14, 0x45, 0x68, 0xb0, 0xc6, 0xb6, 0xe9, 0xa2, 0x99,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7d, 0xe, 0xdf, 0xb3, 0x9e, 0x88, 0x45, 0x49, 0xf4, 0x91, 0x1b, 0x48, 0x71, 0x14, 0x3e, 0x3a, 0x2b, 0xf2, 0x81, 0xc4, 0x49, 0xf5, 0x26, 0xc4, 0xf1, 0x2, 0x0, 0x0, 0x25, 0x2c, 0x25, 0x75, 0x22, 0x49, 0x6c, 0x16, 0x0, 0x3, 0xe4, 0x2a, 0x57, 0x45, 0xf3, 0x78}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7, 0xce, 0x2b, 0xf1, 0x5f, 0x29, 0x7e, 0xe1, 0xae, 0x56, 0xe8, 0x3a, 0xb8, 0x65}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x45, 0xf3, 0x78}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 1045); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); -EXPECT_EQ(msg.payload_len, 3); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); -lwmqtt_string_t x = exp_topic; -x = exp_body; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 11476, topic, msg, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\187\192\216\&6]J\244\v\252\&6\149\EOT\128\ETX", _pubPktID = 11476, _pubBody = +// "\254&\138\150\179\238u\252\176\246'\140\196", _pubProps = [PropServerReference +// "\158s\136m\193\205\148G\247g\SI\GS\NAK\188\135\r"]} +TEST(Publish5QCTest, Decode27) { + uint8_t pkt[] = {0x3a, 0x33, 0x0, 0xe, 0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, + 0x95, 0x4, 0x80, 0x3, 0x2c, 0xd4, 0x13, 0x1c, 0x0, 0x10, 0x9e, 0x73, 0x88, 0x6d, + 0xc1, 0xcd, 0x94, 0x47, 0xf7, 0x67, 0xf, 0x1d, 0x15, 0xbc, 0x87, 0xd, 0xfe, 0x26, + 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\193`\187\247\203\252\193V\159\209\143}w\180\219\226\"\181nuE\nC\175-\SUB\141", _pubPktID = 0, _pubBody = "\213(\SUB\v\FS\224\252\152%p_*#w\218\204\240\237>\246", _pubProps = [PropReceiveMaximum 9423,PropMaximumQoS 52,PropSubscriptionIdentifierAvailable 143,PropRetainAvailable 169,PropServerKeepAlive 17612,PropWildcardSubscriptionAvailable 23,PropAssignedClientIdentifier "\185\154~\209#\ETB\140\220vi|\205P@|`\238^\137\194\250\207P",PropServerReference "bg\130Bs\SOHk\175\225\&1\206\186\129\234;m\149\163?\198\197\vI2",PropAuthenticationMethod "#\180\rR\SYN\146\154\238\163\163\204\225rk\221.UERH\ETB",PropCorrelationData "\173D\232\150\212",PropMessageExpiryInterval 22176,PropServerKeepAlive 26594,PropServerKeepAlive 339,PropServerReference "\EM\159S\176\t\228\156\DC1\227H\US\155\"q.\250\222\223\159\DC4\SOo\234[",PropSharedSubscriptionAvailable 144,PropSubscriptionIdentifierAvailable 236,PropRetainAvailable 111,PropCorrelationData "\198\144\221\167\158*\SYN\b\194\216",PropServerKeepAlive 20480,PropReceiveMaximum 24642,PropWildcardSubscriptionAvailable 206,PropMaximumQoS 243,PropAuthenticationData "\224M\n\225]e\226\213\239\&8\188=\234",PropAuthenticationMethod "\175\142\209/I\209\159\DEL\254i",PropWillDelayInterval 15570,PropAuthenticationData "&\EM'6a\253=f\231D\155",PropCorrelationData "\131\160\210\223\151\207%?S\219\DC4\US\129H\207\DLE\213p\CAN\136T"]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, 0x3}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 11476); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "/\USs\188\193\156\202\143\244\215\159fj\184\STX\DC3\217", _pubPktID = 0, _pubBody = "\213T\157\156*`\174Ad\219\206", +// _pubProps = [PropServerKeepAlive 4269,PropRequestProblemInformation 153,PropServerKeepAlive +// 27842,PropMessageExpiryInterval 1195,PropMaximumQoS 247,PropMessageExpiryInterval 16305,PropReasonString +// "\223\146\n\193=EP\214\252+\245",PropTopicAliasMaximum 5510,PropServerReference +// "i\250S\ETB\179\t4Af$\255\173\188\204\STX\236\165",PropServerKeepAlive 9985,PropResponseTopic +// ":\219f\210",PropServerKeepAlive 3868,PropMaximumPacketSize 7322,PropContentType +// "\213\128\229\164F$\188\238L\161\STX\143",PropSubscriptionIdentifierAvailable 38,PropUserProperty +// "\198\NAK\NAKY<\165\a\220\161\US\207\SYN\227\&3\194\179\137lp ww,\FS\ETB\ETB\DC2\132\195" +// "D\181\230\136\&8@\STX\212\EM/3R\186\167\&4\157\145\187\227\ENQ\250\151\&0\225\174",PropSharedSubscriptionAvailable +// 204,PropRetainAvailable 215,PropWillDelayInterval 7511,PropServerKeepAlive 30724,PropWildcardSubscriptionAvailable +// 219,PropMaximumQoS 149,PropMessageExpiryInterval 21863,PropUserProperty "" +// "\218\186\SO\DC2\143\139\242\136_\129P\EM\144\243up\144\231\DC2",PropMaximumQoS 53,PropServerReference +// "\DLEG\146=}|\NUL\131\228#Y0\EM\129~\139$\136T\STX\225\194\158]\DC4\"",PropMaximumPacketSize 3760]} TEST(Publish5QCTest, Encode28) { -uint8_t pkt[] = {0x30, 0xa1, 0x2, 0x0, 0x1b, 0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d, 0xee, 0x1, 0x21, 0x24, 0xcf, 0x24, 0x34, 0x29, 0x8f, 0x25, 0xa9, 0x13, 0x44, 0xcc, 0x28, 0x17, 0x12, 0x0, 0x17, 0xb9, 0x9a, 0x7e, 0xd1, 0x23, 0x17, 0x8c, 0xdc, 0x76, 0x69, 0x7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x83, 0xa0, 0xd2, 0xdf, 0x97, 0xcf, 0x25, 0x3f, 0x53, 0xdb, 0x14, 0x1f, 0x81, 0x48, 0xcf, 0x10, 0xd5, 0x70, 0x18, 0x88, 0x54, 0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; - uint8_t topic_bytes[] = {0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x88, 0x2, 0x0, 0x11, 0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, 0xd7, 0x9f, 0x66, + 0x6a, 0xb8, 0x2, 0x13, 0xd9, 0xe8, 0x1, 0x13, 0x10, 0xad, 0x17, 0x99, 0x13, 0x6c, 0xc2, 0x2, 0x0, + 0x0, 0x4, 0xab, 0x24, 0xf7, 0x2, 0x0, 0x0, 0x3f, 0xb1, 0x1f, 0x0, 0xb, 0xdf, 0x92, 0xa, 0xc1, + 0x3d, 0x45, 0x50, 0xd6, 0xfc, 0x2b, 0xf5, 0x22, 0x15, 0x86, 0x1c, 0x0, 0x11, 0x69, 0xfa, 0x53, 0x17, + 0xb3, 0x9, 0x34, 0x41, 0x66, 0x24, 0xff, 0xad, 0xbc, 0xcc, 0x2, 0xec, 0xa5, 0x13, 0x27, 0x1, 0x8, + 0x0, 0x4, 0x3a, 0xdb, 0x66, 0xd2, 0x13, 0xf, 0x1c, 0x27, 0x0, 0x0, 0x1c, 0x9a, 0x3, 0x0, 0xc, + 0xd5, 0x80, 0xe5, 0xa4, 0x46, 0x24, 0xbc, 0xee, 0x4c, 0xa1, 0x2, 0x8f, 0x29, 0x26, 0x26, 0x0, 0x1d, + 0xc6, 0x15, 0x15, 0x59, 0x3c, 0xa5, 0x7, 0xdc, 0xa1, 0x1f, 0xcf, 0x16, 0xe3, 0x33, 0xc2, 0xb3, 0x89, + 0x6c, 0x70, 0x20, 0x77, 0x77, 0x2c, 0x1c, 0x17, 0x17, 0x12, 0x84, 0xc3, 0x0, 0x19, 0x44, 0xb5, 0xe6, + 0x88, 0x38, 0x40, 0x2, 0xd4, 0x19, 0x2f, 0x33, 0x52, 0xba, 0xa7, 0x34, 0x9d, 0x91, 0xbb, 0xe3, 0x5, + 0xfa, 0x97, 0x30, 0xe1, 0xae, 0x2a, 0xcc, 0x25, 0xd7, 0x18, 0x0, 0x0, 0x1d, 0x57, 0x13, 0x78, 0x4, + 0x28, 0xdb, 0x24, 0x95, 0x2, 0x0, 0x0, 0x55, 0x67, 0x26, 0x0, 0x0, 0x0, 0x13, 0xda, 0xba, 0xe, + 0x12, 0x8f, 0x8b, 0xf2, 0x88, 0x5f, 0x81, 0x50, 0x19, 0x90, 0xf3, 0x75, 0x70, 0x90, 0xe7, 0x12, 0x24, + 0x35, 0x1c, 0x0, 0x1a, 0x10, 0x47, 0x92, 0x3d, 0x7d, 0x7c, 0x0, 0x83, 0xe4, 0x23, 0x59, 0x30, 0x19, + 0x81, 0x7e, 0x8b, 0x24, 0x88, 0x54, 0x2, 0xe1, 0xc2, 0x9e, 0x5d, 0x14, 0x22, 0x27, 0x0, 0x0, 0xe, + 0xb0, 0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + uint8_t topic_bytes[] = {0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, + 0xd7, 0x9f, 0x66, 0x6a, 0xb8, 0x2, 0x13, 0xd9}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 11; + + uint8_t bytesprops0[] = {0xdf, 0x92, 0xa, 0xc1, 0x3d, 0x45, 0x50, 0xd6, 0xfc, 0x2b, 0xf5}; + uint8_t bytesprops1[] = {0x69, 0xfa, 0x53, 0x17, 0xb3, 0x9, 0x34, 0x41, 0x66, + 0x24, 0xff, 0xad, 0xbc, 0xcc, 0x2, 0xec, 0xa5}; + uint8_t bytesprops2[] = {0x3a, 0xdb, 0x66, 0xd2}; + uint8_t bytesprops3[] = {0xd5, 0x80, 0xe5, 0xa4, 0x46, 0x24, 0xbc, 0xee, 0x4c, 0xa1, 0x2, 0x8f}; + uint8_t bytesprops5[] = {0x44, 0xb5, 0xe6, 0x88, 0x38, 0x40, 0x2, 0xd4, 0x19, 0x2f, 0x33, 0x52, 0xba, + 0xa7, 0x34, 0x9d, 0x91, 0xbb, 0xe3, 0x5, 0xfa, 0x97, 0x30, 0xe1, 0xae}; + uint8_t bytesprops4[] = {0xc6, 0x15, 0x15, 0x59, 0x3c, 0xa5, 0x7, 0xdc, 0xa1, 0x1f, 0xcf, 0x16, 0xe3, 0x33, 0xc2, + 0xb3, 0x89, 0x6c, 0x70, 0x20, 0x77, 0x77, 0x2c, 0x1c, 0x17, 0x17, 0x12, 0x84, 0xc3}; + uint8_t bytesprops7[] = {0xda, 0xba, 0xe, 0x12, 0x8f, 0x8b, 0xf2, 0x88, 0x5f, 0x81, + 0x50, 0x19, 0x90, 0xf3, 0x75, 0x70, 0x90, 0xe7, 0x12}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops8[] = {0x10, 0x47, 0x92, 0x3d, 0x7d, 0x7c, 0x0, 0x83, 0xe4, 0x23, 0x59, 0x30, 0x19, + 0x81, 0x7e, 0x8b, 0x24, 0x88, 0x54, 0x2, 0xe1, 0xc2, 0x9e, 0x5d, 0x14, 0x22}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS0; -msg.retained = false; -uint8_t msg_bytes[] = {0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 20; - - uint8_t bytesprops0[] = {0xb9, 0x9a, 0x7e, 0xd1, 0x23, 0x17, 0x8c, 0xdc, 0x76, 0x69, 0x7c, 0xcd, 0x50, 0x40, 0x7c, 0x60, 0xee, 0x5e, 0x89, 0xc2, 0xfa, 0xcf, 0x50}; - uint8_t bytesprops1[] = {0x62, 0x67, 0x82, 0x42, 0x73, 0x1, 0x6b, 0xaf, 0xe1, 0x31, 0xce, 0xba, 0x81, 0xea, 0x3b, 0x6d, 0x95, 0xa3, 0x3f, 0xc6, 0xc5, 0xb, 0x49, 0x32}; - uint8_t bytesprops2[] = {0x23, 0xb4, 0xd, 0x52, 0x16, 0x92, 0x9a, 0xee, 0xa3, 0xa3, 0xcc, 0xe1, 0x72, 0x6b, 0xdd, 0x2e, 0x55, 0x45, 0x52, 0x48, 0x17}; - uint8_t bytesprops3[] = {0xad, 0x44, 0xe8, 0x96, 0xd4}; - uint8_t bytesprops4[] = {0x19, 0x9f, 0x53, 0xb0, 0x9, 0xe4, 0x9c, 0x11, 0xe3, 0x48, 0x1f, 0x9b, 0x22, 0x71, 0x2e, 0xfa, 0xde, 0xdf, 0x9f, 0x14, 0xe, 0x6f, 0xea, 0x5b}; - uint8_t bytesprops5[] = {0xc6, 0x90, 0xdd, 0xa7, 0x9e, 0x2a, 0x16, 0x8, 0xc2, 0xd8}; - uint8_t bytesprops6[] = {0xe0, 0x4d, 0xa, 0xe1, 0x5d, 0x65, 0xe2, 0xd5, 0xef, 0x38, 0xbc, 0x3d, 0xea}; - uint8_t bytesprops7[] = {0xaf, 0x8e, 0xd1, 0x2f, 0x49, 0xd1, 0x9f, 0x7f, 0xfe, 0x69}; - uint8_t bytesprops8[] = {0x26, 0x19, 0x27, 0x36, 0x61, 0xfd, 0x3d, 0x66, 0xe7, 0x44, 0x9b}; - uint8_t bytesprops9[] = {0x83, 0xa0, 0xd2, 0xdf, 0x97, 0xcf, 0x25, 0x3f, 0x53, 0xdb, 0x14, 0x1f, 0x81, 0x48, 0xcf, 0x10, 0xd5, 0x70, 0x18, 0x88, 0x54}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9423}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17612}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22176}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26594}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 339}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20480}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24642}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15570}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops9}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4269}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27842}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1195}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16305}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5510}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9985}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3868}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7322}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {25, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7511}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30724}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21863}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops6}, .v = {19, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3760}}, }; lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\193`\187\247\203\252\193V\159\209\143}w\180\219\226\"\181nuE\nC\175-\SUB\141", _pubPktID = 0, _pubBody = "\213(\SUB\v\FS\224\252\152%p_*#w\218\204\240\237>\246", _pubProps = [PropReceiveMaximum 9423,PropMaximumQoS 52,PropSubscriptionIdentifierAvailable 143,PropRetainAvailable 169,PropServerKeepAlive 17612,PropWildcardSubscriptionAvailable 23,PropAssignedClientIdentifier "\185\154~\209#\ETB\140\220vi|\205P@|`\238^\137\194\250\207P",PropServerReference "bg\130Bs\SOHk\175\225\&1\206\186\129\234;m\149\163?\198\197\vI2",PropAuthenticationMethod "#\180\rR\SYN\146\154\238\163\163\204\225rk\221.UERH\ETB",PropCorrelationData "\173D\232\150\212",PropMessageExpiryInterval 22176,PropServerKeepAlive 26594,PropServerKeepAlive 339,PropServerReference "\EM\159S\176\t\228\156\DC1\227H\US\155\"q.\250\222\223\159\DC4\SOo\234[",PropSharedSubscriptionAvailable 144,PropSubscriptionIdentifierAvailable 236,PropRetainAvailable 111,PropCorrelationData "\198\144\221\167\158*\SYN\b\194\216",PropServerKeepAlive 20480,PropReceiveMaximum 24642,PropWildcardSubscriptionAvailable 206,PropMaximumQoS 243,PropAuthenticationData "\224M\n\225]e\226\213\239\&8\188=\234",PropAuthenticationMethod "\175\142\209/I\209\159\DEL\254i",PropWillDelayInterval 15570,PropAuthenticationData "&\EM'6a\253=f\231D\155",PropCorrelationData "\131\160\210\223\151\207%?S\219\DC4\US\129H\207\DLE\213p\CAN\136T"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "/\USs\188\193\156\202\143\244\215\159fj\184\STX\DC3\217", _pubPktID = 0, _pubBody = "\213T\157\156*`\174Ad\219\206", +// _pubProps = [PropServerKeepAlive 4269,PropRequestProblemInformation 153,PropServerKeepAlive +// 27842,PropMessageExpiryInterval 1195,PropMaximumQoS 247,PropMessageExpiryInterval 16305,PropReasonString +// "\223\146\n\193=EP\214\252+\245",PropTopicAliasMaximum 5510,PropServerReference +// "i\250S\ETB\179\t4Af$\255\173\188\204\STX\236\165",PropServerKeepAlive 9985,PropResponseTopic +// ":\219f\210",PropServerKeepAlive 3868,PropMaximumPacketSize 7322,PropContentType +// "\213\128\229\164F$\188\238L\161\STX\143",PropSubscriptionIdentifierAvailable 38,PropUserProperty +// "\198\NAK\NAKY<\165\a\220\161\US\207\SYN\227\&3\194\179\137lp ww,\FS\ETB\ETB\DC2\132\195" +// "D\181\230\136\&8@\STX\212\EM/3R\186\167\&4\157\145\187\227\ENQ\250\151\&0\225\174",PropSharedSubscriptionAvailable +// 204,PropRetainAvailable 215,PropWillDelayInterval 7511,PropServerKeepAlive 30724,PropWildcardSubscriptionAvailable +// 219,PropMaximumQoS 149,PropMessageExpiryInterval 21863,PropUserProperty "" +// "\218\186\SO\DC2\143\139\242\136_\129P\EM\144\243up\144\231\DC2",PropMaximumQoS 53,PropServerReference +// "\DLEG\146=}|\NUL\131\228#Y0\EM\129~\139$\136T\STX\225\194\158]\DC4\"",PropMaximumPacketSize 3760]} TEST(Publish5QCTest, Decode28) { -uint8_t pkt[] = {0x30, 0xa1, 0x2, 0x0, 0x1b, 0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d, 0xee, 0x1, 0x21, 0x24, 0xcf, 0x24, 0x34, 0x29, 0x8f, 0x25, 0xa9, 0x13, 0x44, 0xcc, 0x28, 0x17, 0x12, 0x0, 0x17, 0xb9, 0x9a, 0x7e, 0xd1, 0x23, 0x17, 0x8c, 0xdc, 0x76, 0x69, 0x7c, 0xcd, 0x50, 0x40, 0x7c, 0x60, 0xee, 0x5e, 0x89, 0xc2, 0xfa, 0xcf, 0x50, 0x1c, 0x0, 0x18, 0x62, 0x67, 0x82, 0x42, 0x73, 0x1, 0x6b, 0xaf, 0xe1, 0x31, 0xce, 0xba, 0x81, 0xea, 0x3b, 0x6d, 0x95, 0xa3, 0x3f, 0xc6, 0xc5, 0xb, 0x49, 0x32, 0x15, 0x0, 0x15, 0x23, 0xb4, 0xd, 0x52, 0x16, 0x92, 0x9a, 0xee, 0xa3, 0xa3, 0xcc, 0xe1, 0x72, 0x6b, 0xdd, 0x2e, 0x55, 0x45, 0x52, 0x48, 0x17, 0x9, 0x0, 0x5, 0xad, 0x44, 0xe8, 0x96, 0xd4, 0x2, 0x0, 0x0, 0x56, 0xa0, 0x13, 0x67, 0xe2, 0x13, 0x1, 0x53, 0x1c, 0x0, 0x18, 0x19, 0x9f, 0x53, 0xb0, 0x9, 0xe4, 0x9c, 0x11, 0xe3, 0x48, 0x1f, 0x9b, 0x22, 0x71, 0x2e, 0xfa, 0xde, 0xdf, 0x9f, 0x14, 0xe, 0x6f, 0xea, 0x5b, 0x2a, 0x90, 0x29, 0xec, 0x25, 0x6f, 0x9, 0x0, 0xa, 0xc6, 0x90, 0xdd, 0xa7, 0x9e, 0x2a, 0x16, 0x8, 0xc2, 0xd8, 0x13, 0x50, 0x0, 0x21, 0x60, 0x42, 0x28, 0xce, 0x24, 0xf3, 0x16, 0x0, 0xd, 0xe0, 0x4d, 0xa, 0xe1, 0x5d, 0x65, 0xe2, 0xd5, 0xef, 0x38, 0xbc, 0x3d, 0xea, 0x15, 0x0, 0xa, 0xaf, 0x8e, 0xd1, 0x2f, 0x49, 0xd1, 0x9f, 0x7f, 0xfe, 0x69, 0x18, 0x0, 0x0, 0x3c, 0xd2, 0x16, 0x0, 0xb, 0x26, 0x19, 0x27, 0x36, 0x61, 0xfd, 0x3d, 0x66, 0xe7, 0x44, 0x9b, 0x9, 0x0, 0x15, 0x83, 0xa0, 0xd2, 0xdf, 0x97, 0xcf, 0x25, 0x3f, 0x53, 0xdb, 0x14, 0x1f, 0x81, 0x48, 0xcf, 0x10, 0xd5, 0x70, 0x18, 0x88, 0x54, 0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc1, 0x60, 0xbb, 0xf7, 0xcb, 0xfc, 0xc1, 0x56, 0x9f, 0xd1, 0x8f, 0x7d, 0x77, 0xb4, 0xdb, 0xe2, 0x22, 0xb5, 0x6e, 0x75, 0x45, 0xa, 0x43, 0xaf, 0x2d, 0x1a, 0x8d}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd5, 0x28, 0x1a, 0xb, 0x1c, 0xe0, 0xfc, 0x98, 0x25, 0x70, 0x5f, 0x2a, 0x23, 0x77, 0xda, 0xcc, 0xf0, 0xed, 0x3e, 0xf6}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS0); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 0); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); -EXPECT_EQ(msg.payload_len, 20); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x31, 0x88, 0x2, 0x0, 0x11, 0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, 0xd7, 0x9f, 0x66, + 0x6a, 0xb8, 0x2, 0x13, 0xd9, 0xe8, 0x1, 0x13, 0x10, 0xad, 0x17, 0x99, 0x13, 0x6c, 0xc2, 0x2, 0x0, + 0x0, 0x4, 0xab, 0x24, 0xf7, 0x2, 0x0, 0x0, 0x3f, 0xb1, 0x1f, 0x0, 0xb, 0xdf, 0x92, 0xa, 0xc1, + 0x3d, 0x45, 0x50, 0xd6, 0xfc, 0x2b, 0xf5, 0x22, 0x15, 0x86, 0x1c, 0x0, 0x11, 0x69, 0xfa, 0x53, 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xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "}\180", _pubPktID = 11899, _pubBody = "\DC2\ACK%\181\DC3\164\204\173\204\223\DC2\161\&3uzk\152Xn\200\154d\154\143\245z\234", _pubProps = [PropTopicAliasMaximum 7896,PropResponseInformation "S9",PropRequestProblemInformation 238,PropTopicAlias 5269,PropWildcardSubscriptionAvailable 89,PropAuthenticationData "Q\239\248\130D\175\208\216\245\175\251-j\166\254}?r",PropTopicAliasMaximum 13548,PropMaximumPacketSize 11043,PropTopicAliasMaximum 13191,PropMessageExpiryInterval 29315,PropServerReference "\193$\226\145\182\194\&5\164",PropWillDelayInterval 17549,PropSubscriptionIdentifier 5,PropReceiveMaximum 20528,PropMessageExpiryInterval 4596,PropServerReference "\190",PropResponseTopic "r-\150\ACKj;\171p\DLE\240F\139r\NUL\233\144\145P\222\255\191\164/G\EOTi\133",PropAssignedClientIdentifier "\184\239^\234\179hA\255\\\DC3\US",PropResponseTopic "\196\DLE\186\253\138hei\SYN\250",PropMaximumPacketSize 1183,PropContentType "\178\207h\154\174\205\178\169\DC2\t-\FS\131u",PropTopicAliasMaximum 4401,PropUserProperty "^\146;=I\fvo\187\SOH\200\202S\DC3I\151" ".\168g\207z\DC1\248\234\DC2\b\143\175D\204\228m\139\141\206&W|\US\157\235\176B~\128N",PropPayloadFormatIndicator 126,PropTopicAliasMaximum 698]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, + 0xd7, 0x9f, 0x66, 0x6a, 0xb8, 0x2, 0x13, 0xd9}; + lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\ETXJ\240r\220\200\DLE=\219m\152\EM\205\US\144", _pubPktID = 32504, _pubBody = +// "C\158&\185\DLE\NUL\239\237\184+\SO<\134\"R\EM\232\230\222\ENQ", _pubProps = [PropTopicAliasMaximum +// 16938,PropReasonString "j\226\ESC\188$J\155(i\223\251\150#\b\151\SOH",PropPayloadFormatIndicator +// 58,PropWildcardSubscriptionAvailable 104,PropAssignedClientIdentifier "`e",PropAssignedClientIdentifier +// "#[\181+\157\182\245\229\145\255\205zB\245x\140o\205\197P\143s\168f\146\154\221\224\221}",PropContentType +// "\132\162)q\NUL\239\140\&2\SOH\165W\174\162\203\246\159\230f\DELF%",PropRetainAvailable 62,PropContentType +// "/*%Z@",PropReasonString +// "\219\239\161\255rX\129\250qmI\184\159v5\199\238\147<\252xx\\\164\&09\253",PropRequestProblemInformation +// 30,PropSharedSubscriptionAvailable 155,PropMessageExpiryInterval 14356,PropWildcardSubscriptionAvailable +// 212,PropContentType "\202\182",PropResponseTopic +// "\180mv\t-\239\239\142\252_\214!\129\192%\218\230\147\&7\211L\ENQ\153\180",PropServerKeepAlive +// 26081,PropRetainAvailable 68]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f, 0xbb, 0x1, 0xc8, 0xca, 0x53, 0x13, 0x49, 0x97, 0x0, 0x1e, 0x2e, 0xa8, 0x67, 0xcf, 0x7a, 0x11, 0xf8, 0xea, 0x12, 0x8, 0x8f, 0xaf, 0x44, 0xcc, 0xe4, 0x6d, 0x8b, 0x8d, 0xce, 0x26, 0x57, 0x7c, 0x1f, 0x9d, 0xeb, 0xb0, 0x42, 0x7e, 0x80, 0x4e, 0x1, 0x7e, 0x22, 0x2, 0xba, 0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; - uint8_t topic_bytes[] = {0x7d, 0xb4}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0xd9, 0x1, 0x0, 0xf, 0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, + 0xcd, 0x1f, 0x90, 0x7e, 0xf8, 0xb0, 0x1, 0x22, 0x42, 0x2a, 0x1f, 0x0, 0x10, 0x6a, 0xe2, 0x1b, 0xbc, + 0x24, 0x4a, 0x9b, 0x28, 0x69, 0xdf, 0xfb, 0x96, 0x23, 0x8, 0x97, 0x1, 0x1, 0x3a, 0x28, 0x68, 0x12, + 0x0, 0x2, 0x60, 0x65, 0x12, 0x0, 0x1e, 0x23, 0x5b, 0xb5, 0x2b, 0x9d, 0xb6, 0xf5, 0xe5, 0x91, 0xff, + 0xcd, 0x7a, 0x42, 0xf5, 0x78, 0x8c, 0x6f, 0xcd, 0xc5, 0x50, 0x8f, 0x73, 0xa8, 0x66, 0x92, 0x9a, 0xdd, + 0xe0, 0xdd, 0x7d, 0x3, 0x0, 0x15, 0x84, 0xa2, 0x29, 0x71, 0x0, 0xef, 0x8c, 0x32, 0x1, 0xa5, 0x57, + 0xae, 0xa2, 0xcb, 0xf6, 0x9f, 0xe6, 0x66, 0x7f, 0x46, 0x25, 0x25, 0x3e, 0x3, 0x0, 0x5, 0x2f, 0x2a, + 0x25, 0x5a, 0x40, 0x1f, 0x0, 0x1b, 0xdb, 0xef, 0xa1, 0xff, 0x72, 0x58, 0x81, 0xfa, 0x71, 0x6d, 0x49, + 0xb8, 0x9f, 0x76, 0x35, 0xc7, 0xee, 0x93, 0x3c, 0xfc, 0x78, 0x78, 0x5c, 0xa4, 0x30, 0x39, 0xfd, 0x17, + 0x1e, 0x2a, 0x9b, 0x2, 0x0, 0x0, 0x38, 0x14, 0x28, 0xd4, 0x3, 0x0, 0x2, 0xca, 0xb6, 0x8, 0x0, + 0x18, 0xb4, 0x6d, 0x76, 0x9, 0x2d, 0xef, 0xef, 0x8e, 0xfc, 0x5f, 0xd6, 0x21, 0x81, 0xc0, 0x25, 0xda, + 0xe6, 0x93, 0x37, 0xd3, 0x4c, 0x5, 0x99, 0xb4, 0x13, 0x65, 0xe1, 0x25, 0x44, 0x43, 0x9e, 0x26, 0xb9, + 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + uint8_t topic_bytes[] = {0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, 0xcd, 0x1f, 0x90}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS2; -msg.retained = false; -uint8_t msg_bytes[] = {0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 27; - - uint8_t bytesprops0[] = {0x53, 0x39}; - uint8_t bytesprops1[] = {0x51, 0xef, 0xf8, 0x82, 0x44, 0xaf, 0xd0, 0xd8, 0xf5, 0xaf, 0xfb, 0x2d, 0x6a, 0xa6, 0xfe, 0x7d, 0x3f, 0x72}; - uint8_t bytesprops2[] = {0xc1, 0x24, 0xe2, 0x91, 0xb6, 0xc2, 0x35, 0xa4}; - uint8_t bytesprops3[] = {0xbe}; - uint8_t bytesprops4[] = {0x72, 0x2d, 0x96, 0x6, 0x6a, 0x3b, 0xab, 0x70, 0x10, 0xf0, 0x46, 0x8b, 0x72, 0x0, 0xe9, 0x90, 0x91, 0x50, 0xde, 0xff, 0xbf, 0xa4, 0x2f, 0x47, 0x4, 0x69, 0x85}; - uint8_t bytesprops5[] = {0xb8, 0xef, 0x5e, 0xea, 0xb3, 0x68, 0x41, 0xff, 0x5c, 0x13, 0x1f}; - uint8_t bytesprops6[] = {0xc4, 0x10, 0xba, 0xfd, 0x8a, 0x68, 0x65, 0x69, 0x16, 0xfa}; - uint8_t bytesprops7[] = {0xb2, 0xcf, 0x68, 0x9a, 0xae, 0xcd, 0xb2, 0xa9, 0x12, 0x9, 0x2d, 0x1c, 0x83, 0x75}; - uint8_t bytesprops9[] = {0x2e, 0xa8, 0x67, 0xcf, 0x7a, 0x11, 0xf8, 0xea, 0x12, 0x8, 0x8f, 0xaf, 0x44, 0xcc, 0xe4, 0x6d, 0x8b, 0x8d, 0xce, 0x26, 0x57, 0x7c, 0x1f, 0x9d, 0xeb, 0xb0, 0x42, 0x7e, 0x80, 0x4e}; - uint8_t bytesprops8[] = {0x5e, 0x92, 0x3b, 0x3d, 0x49, 0xc, 0x76, 0x6f, 0xbb, 0x1, 0xc8, 0xca, 0x53, 0x13, 0x49, 0x97}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7896}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5269}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13548}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11043}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13191}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29315}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17549}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20528}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4596}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1183}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4401}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={16, (char*)&bytesprops8}, .v={30, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 698}}, + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, + 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 20; + + uint8_t bytesprops0[] = {0x6a, 0xe2, 0x1b, 0xbc, 0x24, 0x4a, 0x9b, 0x28, + 0x69, 0xdf, 0xfb, 0x96, 0x23, 0x8, 0x97, 0x1}; + uint8_t bytesprops1[] = {0x60, 0x65}; + uint8_t bytesprops2[] = {0x23, 0x5b, 0xb5, 0x2b, 0x9d, 0xb6, 0xf5, 0xe5, 0x91, 0xff, 0xcd, 0x7a, 0x42, 0xf5, 0x78, + 0x8c, 0x6f, 0xcd, 0xc5, 0x50, 0x8f, 0x73, 0xa8, 0x66, 0x92, 0x9a, 0xdd, 0xe0, 0xdd, 0x7d}; + uint8_t bytesprops3[] = {0x84, 0xa2, 0x29, 0x71, 0x0, 0xef, 0x8c, 0x32, 0x1, 0xa5, 0x57, + 0xae, 0xa2, 0xcb, 0xf6, 0x9f, 0xe6, 0x66, 0x7f, 0x46, 0x25}; + uint8_t bytesprops4[] = {0x2f, 0x2a, 0x25, 0x5a, 0x40}; + uint8_t bytesprops5[] = {0xdb, 0xef, 0xa1, 0xff, 0x72, 0x58, 0x81, 0xfa, 0x71, 0x6d, 0x49, 0xb8, 0x9f, 0x76, + 0x35, 0xc7, 0xee, 0x93, 0x3c, 0xfc, 0x78, 0x78, 0x5c, 0xa4, 0x30, 0x39, 0xfd}; + uint8_t bytesprops6[] = {0xca, 0xb6}; + uint8_t bytesprops7[] = {0xb4, 0x6d, 0x76, 0x9, 0x2d, 0xef, 0xef, 0x8e, 0xfc, 0x5f, 0xd6, 0x21, + 0x81, 0xc0, 0x25, 0xda, 0xe6, 0x93, 0x37, 0xd3, 0x4c, 0x5, 0x99, 0xb4}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16938}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14356}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26081}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 11899, topic, msg, props); + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32504, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "}\180", _pubPktID = 11899, _pubBody = "\DC2\ACK%\181\DC3\164\204\173\204\223\DC2\161\&3uzk\152Xn\200\154d\154\143\245z\234", _pubProps = [PropTopicAliasMaximum 7896,PropResponseInformation "S9",PropRequestProblemInformation 238,PropTopicAlias 5269,PropWildcardSubscriptionAvailable 89,PropAuthenticationData "Q\239\248\130D\175\208\216\245\175\251-j\166\254}?r",PropTopicAliasMaximum 13548,PropMaximumPacketSize 11043,PropTopicAliasMaximum 13191,PropMessageExpiryInterval 29315,PropServerReference "\193$\226\145\182\194\&5\164",PropWillDelayInterval 17549,PropSubscriptionIdentifier 5,PropReceiveMaximum 20528,PropMessageExpiryInterval 4596,PropServerReference "\190",PropResponseTopic "r-\150\ACKj;\171p\DLE\240F\139r\NUL\233\144\145P\222\255\191\164/G\EOTi\133",PropAssignedClientIdentifier "\184\239^\234\179hA\255\\\DC3\US",PropResponseTopic "\196\DLE\186\253\138hei\SYN\250",PropMaximumPacketSize 1183,PropContentType "\178\207h\154\174\205\178\169\DC2\t-\FS\131u",PropTopicAliasMaximum 4401,PropUserProperty "^\146;=I\fvo\187\SOH\200\202S\DC3I\151" ".\168g\207z\DC1\248\234\DC2\b\143\175D\204\228m\139\141\206&W|\US\157\235\176B~\128N",PropPayloadFormatIndicator 126,PropTopicAliasMaximum 698]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\ETXJ\240r\220\200\DLE=\219m\152\EM\205\US\144", _pubPktID = 32504, _pubBody = +// "C\158&\185\DLE\NUL\239\237\184+\SO<\134\"R\EM\232\230\222\ENQ", _pubProps = [PropTopicAliasMaximum +// 16938,PropReasonString "j\226\ESC\188$J\155(i\223\251\150#\b\151\SOH",PropPayloadFormatIndicator +// 58,PropWildcardSubscriptionAvailable 104,PropAssignedClientIdentifier "`e",PropAssignedClientIdentifier +// "#[\181+\157\182\245\229\145\255\205zB\245x\140o\205\197P\143s\168f\146\154\221\224\221}",PropContentType +// "\132\162)q\NUL\239\140\&2\SOH\165W\174\162\203\246\159\230f\DELF%",PropRetainAvailable 62,PropContentType +// "/*%Z@",PropReasonString +// "\219\239\161\255rX\129\250qmI\184\159v5\199\238\147<\252xx\\\164\&09\253",PropRequestProblemInformation +// 30,PropSharedSubscriptionAvailable 155,PropMessageExpiryInterval 14356,PropWildcardSubscriptionAvailable +// 212,PropContentType "\202\182",PropResponseTopic +// "\180mv\t-\239\239\142\252_\214!\129\192%\218\230\147\&7\211L\ENQ\153\180",PropServerKeepAlive +// 26081,PropRetainAvailable 68]} TEST(Publish5QCTest, Decode29) { -uint8_t pkt[] = {0x34, 0xff, 0x1, 0x0, 0x2, 0x7d, 0xb4, 0x2e, 0x7b, 0xdc, 0x1, 0x22, 0x1e, 0xd8, 0x1a, 0x0, 0x2, 0x53, 0x39, 0x17, 0xee, 0x23, 0x14, 0x95, 0x28, 0x59, 0x16, 0x0, 0x12, 0x51, 0xef, 0xf8, 0x82, 0x44, 0xaf, 0xd0, 0xd8, 0xf5, 0xaf, 0xfb, 0x2d, 0x6a, 0xa6, 0xfe, 0x7d, 0x3f, 0x72, 0x22, 0x34, 0xec, 0x27, 0x0, 0x0, 0x2b, 0x23, 0x22, 0x33, 0x87, 0x2, 0x0, 0x0, 0x72, 0x83, 0x1c, 0x0, 0x8, 0xc1, 0x24, 0xe2, 0x91, 0xb6, 0xc2, 0x35, 0xa4, 0x18, 0x0, 0x0, 0x44, 0x8d, 0xb, 0x5, 0x21, 0x50, 0x30, 0x2, 0x0, 0x0, 0x11, 0xf4, 0x1c, 0x0, 0x1, 0xbe, 0x8, 0x0, 0x1b, 0x72, 0x2d, 0x96, 0x6, 0x6a, 0x3b, 0xab, 0x70, 0x10, 0xf0, 0x46, 0x8b, 0x72, 0x0, 0xe9, 0x90, 0x91, 0x50, 0xde, 0xff, 0xbf, 0xa4, 0x2f, 0x47, 0x4, 0x69, 0x85, 0x12, 0x0, 0xb, 0xb8, 0xef, 0x5e, 0xea, 0xb3, 0x68, 0x41, 0xff, 0x5c, 0x13, 0x1f, 0x8, 0x0, 0xa, 0xc4, 0x10, 0xba, 0xfd, 0x8a, 0x68, 0x65, 0x69, 0x16, 0xfa, 0x27, 0x0, 0x0, 0x4, 0x9f, 0x3, 0x0, 0xe, 0xb2, 0xcf, 0x68, 0x9a, 0xae, 0xcd, 0xb2, 0xa9, 0x12, 0x9, 0x2d, 0x1c, 0x83, 0x75, 0x22, 0x11, 0x31, 0x26, 0x0, 0x10, 0x5e, 0x92, 0x3b, 0x3d, 0x49, 0xc, 0x76, 0x6f, 0xbb, 0x1, 0xc8, 0xca, 0x53, 0x13, 0x49, 0x97, 0x0, 0x1e, 0x2e, 0xa8, 0x67, 0xcf, 0x7a, 0x11, 0xf8, 0xea, 0x12, 0x8, 0x8f, 0xaf, 0x44, 0xcc, 0xe4, 0x6d, 0x8b, 0x8d, 0xce, 0x26, 0x57, 0x7c, 0x1f, 0x9d, 0xeb, 0xb0, 0x42, 0x7e, 0x80, 0x4e, 0x1, 0x7e, 0x22, 0x2, 0xba, 0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7d, 0xb4}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x12, 0x6, 0x25, 0xb5, 0x13, 0xa4, 0xcc, 0xad, 0xcc, 0xdf, 0x12, 0xa1, 0x33, 0x75, 0x7a, 0x6b, 0x98, 0x58, 0x6e, 0xc8, 0x9a, 0x64, 0x9a, 0x8f, 0xf5, 0x7a, 0xea}; - lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, false); -EXPECT_EQ(msg.qos, LWMQTT_QOS2); -EXPECT_EQ(msg.retained, false); -EXPECT_EQ(packet_id, 11899); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); -EXPECT_EQ(msg.payload_len, 27); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); -lwmqtt_string_t x = exp_topic; -x = exp_body; + uint8_t pkt[] = {0x35, 0xd9, 0x1, 0x0, 0xf, 0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, + 0xcd, 0x1f, 0x90, 0x7e, 0xf8, 0xb0, 0x1, 0x22, 0x42, 0x2a, 0x1f, 0x0, 0x10, 0x6a, 0xe2, 0x1b, 0xbc, + 0x24, 0x4a, 0x9b, 0x28, 0x69, 0xdf, 0xfb, 0x96, 0x23, 0x8, 0x97, 0x1, 0x1, 0x3a, 0x28, 0x68, 0x12, + 0x0, 0x2, 0x60, 0x65, 0x12, 0x0, 0x1e, 0x23, 0x5b, 0xb5, 0x2b, 0x9d, 0xb6, 0xf5, 0xe5, 0x91, 0xff, + 0xcd, 0x7a, 0x42, 0xf5, 0x78, 0x8c, 0x6f, 0xcd, 0xc5, 0x50, 0x8f, 0x73, 0xa8, 0x66, 0x92, 0x9a, 0xdd, + 0xe0, 0xdd, 0x7d, 0x3, 0x0, 0x15, 0x84, 0xa2, 0x29, 0x71, 0x0, 0xef, 0x8c, 0x32, 0x1, 0xa5, 0x57, + 0xae, 0xa2, 0xcb, 0xf6, 0x9f, 0xe6, 0x66, 0x7f, 0x46, 0x25, 0x25, 0x3e, 0x3, 0x0, 0x5, 0x2f, 0x2a, + 0x25, 0x5a, 0x40, 0x1f, 0x0, 0x1b, 0xdb, 0xef, 0xa1, 0xff, 0x72, 0x58, 0x81, 0xfa, 0x71, 0x6d, 0x49, + 0xb8, 0x9f, 0x76, 0x35, 0xc7, 0xee, 0x93, 0x3c, 0xfc, 0x78, 0x78, 0x5c, 0xa4, 0x30, 0x39, 0xfd, 0x17, + 0x1e, 0x2a, 0x9b, 0x2, 0x0, 0x0, 0x38, 0x14, 0x28, 0xd4, 0x3, 0x0, 0x2, 0xca, 0xb6, 0x8, 0x0, + 0x18, 0xb4, 0x6d, 0x76, 0x9, 0x2d, 0xef, 0xef, 0x8e, 0xfc, 0x5f, 0xd6, 0x21, 0x81, 0xc0, 0x25, 0xda, + 0xe6, 0x93, 0x37, 0xd3, 0x4c, 0x5, 0x99, 0xb4, 0x13, 0x65, 0xe1, 0x25, 0x44, 0x43, 0x9e, 0x26, 0xb9, + 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -} - - -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\tnz^#/~y\225", _pubPktID = 17773, _pubBody = "\130\\'n\215\&3\DC2\219\205\147\SOI\183c", _pubProps = [PropRequestProblemInformation 236]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, 0xcd, 0x1f, 0x90}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, + 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 32504); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CAN\n\131L\223F1\229", _pubPktID = +// 0, _pubBody = "\138\228\212\203", _pubProps = [PropWildcardSubscriptionAvailable 206,PropReasonString +// "\149N\204\172\138N\250[\183\171"]} TEST(Publish5QCTest, Encode30) { -uint8_t pkt[] = {0x3b, 0x1f, 0x0, 0xa, 0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1, 0x45, 0x6d, 0x2, 0x17, 0xec, 0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; - uint8_t topic_bytes[] = {0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x1e, 0x0, 0x8, 0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5, 0xf, 0x28, 0xce, 0x1f, + 0x0, 0xa, 0x95, 0x4e, 0xcc, 0xac, 0x8a, 0x4e, 0xfa, 0x5b, 0xb7, 0xab, 0x8a, 0xe4, 0xd4, 0xcb}; + uint8_t topic_bytes[] = {0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_message_t msg = lwmqtt_default_message; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x8a, 0xe4, 0xd4, 0xcb}; + msg.payload = (unsigned char*)&msg_bytes; + msg.payload_len = 4; - uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_message_t msg = lwmqtt_default_message; -msg.qos = LWMQTT_QOS1; -msg.retained = true; -uint8_t msg_bytes[] = {0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; -msg.payload = (unsigned char*)&msg_bytes; -msg.payload_len = 14; + uint8_t bytesprops0[] = {0x95, 0x4e, 0xcc, 0xac, 0x8a, 0x4e, 0xfa, 0x5b, 0xb7, 0xab}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 17773, topic, msg, props); + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\tnz^#/~y\225", _pubPktID = 17773, _pubBody = "\130\\'n\215\&3\DC2\219\205\147\SOI\183c", _pubProps = [PropRequestProblemInformation 236]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CAN\n\131L\223F1\229", _pubPktID = +// 0, _pubBody = "\138\228\212\203", _pubProps = [PropWildcardSubscriptionAvailable 206,PropReasonString +// "\149N\204\172\138N\250[\183\171"]} TEST(Publish5QCTest, Decode30) { -uint8_t pkt[] = {0x3b, 0x1f, 0x0, 0xa, 0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1, 0x45, 0x6d, 0x2, 0x17, 0xec, 0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; -bool dup; -uint16_t packet_id; -lwmqtt_string_t topic; -lwmqtt_message_t msg; -lwmqtt_serialized_properties_t props; -lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); - -EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x96, 0x9, 0x6e, 0x7a, 0x5e, 0x23, 0x2f, 0x7e, 0x79, 0xe1}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x82, 0x5c, 0x27, 0x6e, 0xd7, 0x33, 0x12, 0xdb, 0xcd, 0x93, 0xe, 0x49, 0xb7, 0x63}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; -EXPECT_EQ(dup, true); -EXPECT_EQ(msg.qos, LWMQTT_QOS1); -EXPECT_EQ(msg.retained, true); -EXPECT_EQ(packet_id, 17773); -EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); -EXPECT_EQ(msg.payload_len, 14); -EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); -lwmqtt_string_t x = exp_topic; -x = exp_body; - -} - + uint8_t pkt[] = {0x30, 0x1e, 0x0, 0x8, 0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5, 0xf, 0x28, 0xce, 0x1f, + 0x0, 0xa, 0x95, 0x4e, 0xcc, 0xac, 0x8a, 0x4e, 0xfa, 0x5b, 0xb7, 0xab, 0x8a, 0xe4, 0xd4, 0xcb}; + bool dup; + uint16_t packet_id; + lwmqtt_string_t topic; + lwmqtt_message_t msg; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); -// ConnectRequest {_username = Nothing, _password = Just "<\200\232q\179c\222\168\a\186M\US\251I\210\222w\195H8\NUL\242!X\199s\219\245\165i", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "e\166s3\SOH\158_\232u5y\249\184aJ\194\246\220\226\184\209\223\EM", _willMsg = "_\245\131\131I\205\b\225\ETB\152\SO\152\&0\ENQ\145<\158\t4:\135", _willProps = []}), _cleanSession = False, _keepAlive = 14400, _connID = "\NAK\178o-", _properties = []} + EXPECT_EQ(err, LWMQTT_SUCCESS); + uint8_t exp_topic_bytes[] = {0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8a, 0xe4, 0xd4, 0xcb}; + lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 4); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + lwmqtt_string_t x = exp_topic; + x = exp_body; +} + +// ConnectRequest {_username = Just "su\219", _password = Just "\245\218", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS2, _willTopic = "\200\218\ENQ\194\150u=", _willMsg = "18\181\155\177B\144\135#\186\ESC", +// _willProps = []}), _cleanSession = True, _keepAlive = 23341, _connID = "\167\130W\226#\FSJ:\239#\154)\178i", +// _properties = []} TEST(Connect311QCTest, Encode1) { -uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2c, 0x38, 0x40, 0x0, 0x4, 0x15, 0xb2, 0x6f, 0x2d, 0x0, 0x17, 0x65, 0xa6, 0x73, 0x33, 0x1, 0x9e, 0x5f, 0xe8, 0x75, 0x35, 0x79, 0xf9, 0xb8, 0x61, 0x4a, 0xc2, 0xf6, 0xdc, 0xe2, 0xb8, 0xd1, 0xdf, 0x19, 0x0, 0x15, 0x5f, 0xf5, 0x83, 0x83, 0x49, 0xcd, 0x8, 0xe1, 0x17, 0x98, 0xe, 0x98, 0x30, 0x5, 0x91, 0x3c, 0x9e, 0x9, 0x34, 0x3a, 0x87}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x5b, 0x2d, 0x0, 0xe, 0xa7, + 0x82, 0x57, 0xe2, 0x23, 0x1c, 0x4a, 0x3a, 0xef, 0x23, 0x9a, 0x29, 0xb2, 0x69, 0x0, 0x7, + 0xc8, 0xda, 0x5, 0xc2, 0x96, 0x75, 0x3d, 0x0, 0xb, 0x31, 0x38, 0xb5, 0x9b, 0xb1, 0x42, + 0x90, 0x87, 0x23, 0xba, 0x1b, 0x0, 0x3, 0x73, 0x75, 0xdb, 0x0, 0x2, 0xf5, 0xda}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x65, 0xa6, 0x73, 0x33, 0x1, 0x9e, 0x5f, 0xe8, 0x75, 0x35, 0x79, 0xf9, 0xb8, 0x61, 0x4a, 0xc2, 0xf6, 0xdc, 0xe2, 0xb8, 0xd1, 0xdf, 0x19}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5f, 0xf5, 0x83, 0x83, 0x49, 0xcd, 0x8, 0xe1, 0x17, 0x98, 0xe, 0x98, 0x30, 0x5, 0x91, 0x3c, 0x9e, 0x9, 0x34, 0x3a, 0x87}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 14400; - uint8_t client_id_bytes[] = {0x15, 0xb2, 0x6f, 0x2d}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x3c, 0xc8, 0xe8, 0x71, 0xb3, 0x63, 0xde, 0xa8, 0x7, 0xba, 0x4d, 0x1f, 0xfb, 0x49, 0xd2, 0xde, 0x77, 0xc3, 0x48, 0x38, 0x0, 0xf2, 0x21, 0x58, 0xc7, 0x73, 0xdb, 0xf5, 0xa5, 0x69}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_property_t willpropslist[] = {}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc8, 0xda, 0x5, 0xc2, 0x96, 0x75, 0x3d}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x31, 0x38, 0xb5, 0x9b, 0xb1, 0x42, 0x90, 0x87, 0x23, 0xba, 0x1b}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23341; + uint8_t client_id_bytes[] = {0xa7, 0x82, 0x57, 0xe2, 0x23, 0x1c, 0x4a, 0x3a, 0xef, 0x23, 0x9a, 0x29, 0xb2, 0x69}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x73, 0x75, 0xdb}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf5, 0xda}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\157\&7\160\&4!<\152o", _willMsg = "\207\206*\r\196x\199J", _willProps = []}), _cleanSession = False, _keepAlive = 22372, _connID = "\153\215g\142q\253\SUB\139\224jU\202Kb\220Q\233\DC2\137\&5", _properties = []} +// ConnectRequest {_username = Just "P\166UwM\219C\247)G\246N\221{\180_\252\165e\v\208q\130c\RS\211C<", _password = Just +// "\130\CAN3\224\145\232]\239\145\186\165\178v\169N=\a+\t -", _lastWill = Just (LastWill {_willRetain = True, _willQoS +// = QoS0, _willTopic = "\\\179", _willMsg = "\165\154\226\EOTH\244,\148\217\b|", _willProps = []}), _cleanSession = +// False, _keepAlive = 18048, _connID = +// "J\190\236\SO\209A\240R\155\STX:\190\166-\217C\169\EM\134\160\170\226\251I\v\238\&6\208\149", _properties = []} TEST(Connect311QCTest, Encode2) { -uint8_t pkt[] = {0x10, 0x34, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x57, 0x64, 0x0, 0x14, 0x99, 0xd7, 0x67, 0x8e, 0x71, 0xfd, 0x1a, 0x8b, 0xe0, 0x6a, 0x55, 0xca, 0x4b, 0x62, 0xdc, 0x51, 0xe9, 0x12, 0x89, 0x35, 0x0, 0x8, 0x9d, 0x37, 0xa0, 0x34, 0x21, 0x3c, 0x98, 0x6f, 0x0, 0x8, 0xcf, 0xce, 0x2a, 0xd, 0xc4, 0x78, 0xc7, 0x4a}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + uint8_t pkt[] = {0x10, 0x6f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x46, 0x80, 0x0, 0x1d, 0x4a, 0xbe, 0xec, + 0xe, 0xd1, 0x41, 0xf0, 0x52, 0x9b, 0x2, 0x3a, 0xbe, 0xa6, 0x2d, 0xd9, 0x43, 0xa9, 0x19, 0x86, 0xa0, + 0xaa, 0xe2, 0xfb, 0x49, 0xb, 0xee, 0x36, 0xd0, 0x95, 0x0, 0x2, 0x5c, 0xb3, 0x0, 0xb, 0xa5, 0x9a, + 0xe2, 0x4, 0x48, 0xf4, 0x2c, 0x94, 0xd9, 0x8, 0x7c, 0x0, 0x1c, 0x50, 0xa6, 0x55, 0x77, 0x4d, 0xdb, + 0x43, 0xf7, 0x29, 0x47, 0xf6, 0x4e, 0xdd, 0x7b, 0xb4, 0x5f, 0xfc, 0xa5, 0x65, 0xb, 0xd0, 0x71, 0x82, + 0x63, 0x1e, 0xd3, 0x43, 0x3c, 0x0, 0x15, 0x82, 0x18, 0x33, 0xe0, 0x91, 0xe8, 0x5d, 0xef, 0x91, 0xba, + 0xa5, 0xb2, 0x76, 0xa9, 0x4e, 0x3d, 0x7, 0x2b, 0x9, 0x20, 0x2d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9d, 0x37, 0xa0, 0x34, 0x21, 0x3c, 0x98, 0x6f}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xcf, 0xce, 0x2a, 0xd, 0xc4, 0x78, 0xc7, 0x4a}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 22372; - uint8_t client_id_bytes[] = {0x99, 0xd7, 0x67, 0x8e, 0x71, 0xfd, 0x1a, 0x8b, 0xe0, 0x6a, 0x55, 0xca, 0x4b, 0x62, 0xdc, 0x51, 0xe9, 0x12, 0x89, 0x35}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; -opts.client_id = client_id; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - -} - - -// ConnectRequest {_username = Just "\210\154\156`\157$\167\211\ACK|\EMc\FS\DC4;\244\132\247\250\DC1p\226", _password = Just "\250\211\178\rK\SUB\US\221G\171\f\202\222h\195\201\142\SOH\178\141\RS\179\234d\191G\245\249", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\166\245E _4\192:\130\134\233", _willMsg = "\199!\216\227\149HhD#\178\nH@\210\185:C\147\183\168", _willProps = []}), _cleanSession = False, _keepAlive = 11307, _connID = "\214\137\207{L;\190\191\172O\206z4\183", _properties = []} -TEST(Connect311QCTest, Encode3) { -uint8_t pkt[] = {0x10, 0x73, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x2c, 0x2b, 0x0, 0xe, 0xd6, 0x89, 0xcf, 0x7b, 0x4c, 0x3b, 0xbe, 0xbf, 0xac, 0x4f, 0xce, 0x7a, 0x34, 0xb7, 0x0, 0xb, 0xa6, 0xf5, 0x45, 0x20, 0x5f, 0x34, 0xc0, 0x3a, 0x82, 0x86, 0xe9, 0x0, 0x14, 0xc7, 0x21, 0xd8, 0xe3, 0x95, 0x48, 0x68, 0x44, 0x23, 0xb2, 0xa, 0x48, 0x40, 0xd2, 0xb9, 0x3a, 0x43, 0x93, 0xb7, 0xa8, 0x0, 0x16, 0xd2, 0x9a, 0x9c, 0x60, 0x9d, 0x24, 0xa7, 0xd3, 0x6, 0x7c, 0x19, 0x63, 0x1c, 0x14, 0x3b, 0xf4, 0x84, 0xf7, 0xfa, 0x11, 0x70, 0xe2, 0x0, 0x1c, 0xfa, 0xd3, 0xb2, 0xd, 0x4b, 0x1a, 0x1f, 0xdd, 0x47, 0xab, 0xc, 0xca, 0xde, 0x68, 0xc3, 0xc9, 0x8e, 0x1, 0xb2, 0x8d, 0x1e, 0xb3, 0xea, 0x64, 0xbf, 0x47, 0xf5, 0xf9}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa6, 0xf5, 0x45, 0x20, 0x5f, 0x34, 0xc0, 0x3a, 0x82, 0x86, 0xe9}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc7, 0x21, 0xd8, 0xe3, 0x95, 0x48, 0x68, 0x44, 0x23, 0xb2, 0xa, 0x48, 0x40, 0xd2, 0xb9, 0x3a, 0x43, 0x93, 0xb7, 0xa8}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS0; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 11307; - uint8_t client_id_bytes[] = {0xd6, 0x89, 0xcf, 0x7b, 0x4c, 0x3b, 0xbe, 0xbf, 0xac, 0x4f, 0xce, 0x7a, 0x34, 0xb7}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xd2, 0x9a, 0x9c, 0x60, 0x9d, 0x24, 0xa7, 0xd3, 0x6, 0x7c, 0x19, 0x63, 0x1c, 0x14, 0x3b, 0xf4, 0x84, 0xf7, 0xfa, 0x11, 0x70, 0xe2}; - lwmqtt_string_t username = {22, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0xfa, 0xd3, 0xb2, 0xd, 0x4b, 0x1a, 0x1f, 0xdd, 0x47, 0xab, 0xc, 0xca, 0xde, 0x68, 0xc3, 0xc9, 0x8e, 0x1, 0xb2, 0x8d, 0x1e, 0xb3, 0xea, 0x64, 0xbf, 0x47, 0xf5, 0xf9}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_property_t willpropslist[] = {}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5c, 0xb3}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa5, 0x9a, 0xe2, 0x4, 0x48, 0xf4, 0x2c, 0x94, 0xd9, 0x8, 0x7c}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 18048; + uint8_t client_id_bytes[] = {0x4a, 0xbe, 0xec, 0xe, 0xd1, 0x41, 0xf0, 0x52, 0x9b, 0x2, 0x3a, 0xbe, 0xa6, 0x2d, 0xd9, + 0x43, 0xa9, 0x19, 0x86, 0xa0, 0xaa, 0xe2, 0xfb, 0x49, 0xb, 0xee, 0x36, 0xd0, 0x95}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x50, 0xa6, 0x55, 0x77, 0x4d, 0xdb, 0x43, 0xf7, 0x29, 0x47, 0xf6, 0x4e, 0xdd, 0x7b, + 0xb4, 0x5f, 0xfc, 0xa5, 0x65, 0xb, 0xd0, 0x71, 0x82, 0x63, 0x1e, 0xd3, 0x43, 0x3c}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x82, 0x18, 0x33, 0xe0, 0x91, 0xe8, 0x5d, 0xef, 0x91, 0xba, 0xa5, + 0xb2, 0x76, 0xa9, 0x4e, 0x3d, 0x7, 0x2b, 0x9, 0x20, 0x2d}; + lwmqtt_string_t password = {21, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "2\SYN9\139\255u\201\DEL\234\DEL\164@W\249\SUB\225B\154\170*\\H\246:b\164", +// _password = Just "+ZTUH\240]\158$\252\179\130\182\154hK", _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\248\227\198;\219P\186\DC1\SO\130\166<\193j\180\&3\199\231BD@\235", _willMsg = "\231", _willProps +// = []}), _cleanSession = True, _keepAlive = 16330, _connID = "\v\176\184\NULR", _properties = []} +TEST(Connect311QCTest, Encode3) { + uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x3f, 0xca, 0x0, 0x5, 0xb, 0xb0, + 0xb8, 0x0, 0x52, 0x0, 0x16, 0xf8, 0xe3, 0xc6, 0x3b, 0xdb, 0x50, 0xba, 0x11, 0xe, 0x82, 0xa6, + 0x3c, 0xc1, 0x6a, 0xb4, 0x33, 0xc7, 0xe7, 0x42, 0x44, 0x40, 0xeb, 0x0, 0x1, 0xe7, 0x0, 0x1a, + 0x32, 0x16, 0x39, 0x8b, 0xff, 0x75, 0xc9, 0x7f, 0xea, 0x7f, 0xa4, 0x40, 0x57, 0xf9, 0x1a, 0xe1, + 0x42, 0x9a, 0xaa, 0x2a, 0x5c, 0x48, 0xf6, 0x3a, 0x62, 0xa4, 0x0, 0x10, 0x2b, 0x5a, 0x54, 0x55, + 0x48, 0xf0, 0x5d, 0x9e, 0x24, 0xfc, 0xb3, 0x82, 0xb6, 0x9a, 0x68, 0x4b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// ConnectRequest {_username = Just "\129&\239\168\247MW\197\EOT\DEL\231\f9.aTK,o\DC324I\149\171", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\192\172\136", _willMsg = "W\132\155\204", _willProps = []}), _cleanSession = True, _keepAlive = 16616, _connID = "f4\EOTKMC\199\173\161\251\151", _properties = []} -TEST(Connect311QCTest, Encode4) { -uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa6, 0x40, 0xe8, 0x0, 0xb, 0x66, 0x34, 0x4, 0x4b, 0x4d, 0x43, 0xc7, 0xad, 0xa1, 0xfb, 0x97, 0x0, 0x3, 0xc0, 0xac, 0x88, 0x0, 0x4, 0x57, 0x84, 0x9b, 0xcc, 0x0, 0x19, 0x81, 0x26, 0xef, 0xa8, 0xf7, 0x4d, 0x57, 0xc5, 0x4, 0x7f, 0xe7, 0xc, 0x39, 0x2e, 0x61, 0x54, 0x4b, 0x2c, 0x6f, 0x13, 0x32, 0x34, 0x49, 0x95, 0xab}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc0, 0xac, 0x88}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x57, 0x84, 0x9b, 0xcc}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS0; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 16616; - uint8_t client_id_bytes[] = {0x66, 0x34, 0x4, 0x4b, 0x4d, 0x43, 0xc7, 0xad, 0xa1, 0xfb, 0x97}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x81, 0x26, 0xef, 0xa8, 0xf7, 0x4d, 0x57, 0xc5, 0x4, 0x7f, 0xe7, 0xc, 0x39, 0x2e, 0x61, 0x54, 0x4b, 0x2c, 0x6f, 0x13, 0x32, 0x34, 0x49, 0x95, 0xab}; - lwmqtt_string_t username = {25, (char*)&username_bytes}; -opts.username = username; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_property_t willpropslist[] = {}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf8, 0xe3, 0xc6, 0x3b, 0xdb, 0x50, 0xba, 0x11, 0xe, 0x82, 0xa6, + 0x3c, 0xc1, 0x6a, 0xb4, 0x33, 0xc7, 0xe7, 0x42, 0x44, 0x40, 0xeb}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe7}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 16330; + uint8_t client_id_bytes[] = {0xb, 0xb0, 0xb8, 0x0, 0x52}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x32, 0x16, 0x39, 0x8b, 0xff, 0x75, 0xc9, 0x7f, 0xea, 0x7f, 0xa4, 0x40, 0x57, + 0xf9, 0x1a, 0xe1, 0x42, 0x9a, 0xaa, 0x2a, 0x5c, 0x48, 0xf6, 0x3a, 0x62, 0xa4}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x2b, 0x5a, 0x54, 0x55, 0x48, 0xf0, 0x5d, 0x9e, + 0x24, 0xfc, 0xb3, 0x82, 0xb6, 0x9a, 0x68, 0x4b}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "\SOH\222\148y4W7\221\234\219\249G\176i\153\&7C\174\DC3\201\168", _password = +// Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\182\DC2\202\175'\175", +// _willMsg = "FT\180\227 ,\DLEhU\147g\249\210sn\150=>P\234h4\234\150\&6T\137\149\192\216", _willProps = []}), +// _cleanSession = True, _keepAlive = 30046, _connID = "A'\216\131\251\208\218\DC4\152\230\198\239\a", _properties = []} +TEST(Connect311QCTest, Encode4) { + uint8_t pkt[] = {0x10, 0x58, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa6, 0x75, 0x5e, 0x0, 0xd, 0x41, + 0x27, 0xd8, 0x83, 0xfb, 0xd0, 0xda, 0x14, 0x98, 0xe6, 0xc6, 0xef, 0x7, 0x0, 0x6, 0xb6, + 0x12, 0xca, 0xaf, 0x27, 0xaf, 0x0, 0x1e, 0x46, 0x54, 0xb4, 0xe3, 0x20, 0x2c, 0x10, 0x68, + 0x55, 0x93, 0x67, 0xf9, 0xd2, 0x73, 0x6e, 0x96, 0x3d, 0x3e, 0x50, 0xea, 0x68, 0x34, 0xea, + 0x96, 0x36, 0x54, 0x89, 0x95, 0xc0, 0xd8, 0x0, 0x15, 0x1, 0xde, 0x94, 0x79, 0x34, 0x57, + 0x37, 0xdd, 0xea, 0xdb, 0xf9, 0x47, 0xb0, 0x69, 0x99, 0x37, 0x43, 0xae, 0x13, 0xc9, 0xa8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "?w\155e\220+\213:#.\196F\250\DC2jTpG*a)\199u\169\200c\ETB\200\246\180\&5\171\157S\185", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\189>\247Z\247\130\236\149k\150\218\181\\-Za%\"\153\153\249\154\229\155\174\154", _willMsg = +// "1\183yF.\202\190\&0\172\233\196\243\200;e\233\133N\232/T\223\157-)\ESC\144\SYN9", _willProps = []}), _cleanSession = +// True, _keepAlive = 26688, _connID = "\246\249\133]\247\EOTD,\146\246\247\159\145\&1O\239Y\129\183+\237\ACK\b", +// _properties = []} +TEST(Connect311QCTest, Encode10) { + uint8_t pkt[] = {0x10, 0x88, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x68, 0x40, 0x0, 0x17, 0xf6, + 0xf9, 0x85, 0x5d, 0xf7, 0x4, 0x44, 0x2c, 0x92, 0xf6, 0xf7, 0x9f, 0x91, 0x31, 0x4f, 0xef, 0x59, + 0x81, 0xb7, 0x2b, 0xed, 0x6, 0x8, 0x0, 0x1a, 0xbd, 0x3e, 0xf7, 0x5a, 0xf7, 0x82, 0xec, 0x95, + 0x6b, 0x96, 0xda, 0xb5, 0x5c, 0x2d, 0x5a, 0x61, 0x25, 0x22, 0x99, 0x99, 0xf9, 0x9a, 0xe5, 0x9b, + 0xae, 0x9a, 0x0, 0x1d, 0x31, 0xb7, 0x79, 0x46, 0x2e, 0xca, 0xbe, 0x30, 0xac, 0xe9, 0xc4, 0xf3, + 0xc8, 0x3b, 0x65, 0xe9, 0x85, 0x4e, 0xe8, 0x2f, 0x54, 0xdf, 0x9d, 0x2d, 0x29, 0x1b, 0x90, 0x16, + 0x39, 0x0, 0x8, 0xf4, 0xa0, 0xdd, 0x30, 0xe6, 0xce, 0x6d, 0xac, 0x0, 0x1e, 0xa5, 0xb7, 0x25, + 0xfb, 0x58, 0x2e, 0x3e, 0xfa, 0x12, 0x6a, 0x54, 0x70, 0x47, 0x2a, 0x61, 0x29, 0xc7, 0x75, 0xa9, + 0xc8, 0x63, 0x17, 0xc8, 0xf6, 0xb4, 0x35, 0xab, 0x9d, 0x53, 0xb9}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb9, 0xa4, 0xc9, 0xda, 0x9, 0x1e, 0x8a, 0x77, 0x34, 0xed, 0x96, 0x4f, 0xbc, 0x7a, 0x7d, 0x57}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3c, 0xc3, 0xa7, 0x1c, 0x57}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 29930; - uint8_t client_id_bytes[] = {0x8, 0x37, 0x6f, 0xcb, 0xc, 0xc5}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x1, 0xa9, 0x95, 0x58}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_property_t willpropslist[] = {}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xbd, 0x3e, 0xf7, 0x5a, 0xf7, 0x82, 0xec, 0x95, 0x6b, 0x96, 0xda, 0xb5, 0x5c, + 0x2d, 0x5a, 0x61, 0x25, 0x22, 0x99, 0x99, 0xf9, 0x9a, 0xe5, 0x9b, 0xae, 0x9a}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x31, 0xb7, 0x79, 0x46, 0x2e, 0xca, 0xbe, 0x30, 0xac, 0xe9, + 0xc4, 0xf3, 0xc8, 0x3b, 0x65, 0xe9, 0x85, 0x4e, 0xe8, 0x2f, + 0x54, 0xdf, 0x9d, 0x2d, 0x29, 0x1b, 0x90, 0x16, 0x39}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 26688; + uint8_t client_id_bytes[] = {0xf6, 0xf9, 0x85, 0x5d, 0xf7, 0x4, 0x44, 0x2c, 0x92, 0xf6, 0xf7, 0x9f, + 0x91, 0x31, 0x4f, 0xef, 0x59, 0x81, 0xb7, 0x2b, 0xed, 0x6, 0x8}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xf4, 0xa0, 0xdd, 0x30, 0xe6, 0xce, 0x6d, 0xac}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xa5, 0xb7, 0x25, 0xfb, 0x58, 0x2e, 0x3e, 0xfa, 0x12, 0x6a, 0x54, 0x70, 0x47, 0x2a, 0x61, + 0x29, 0xc7, 0x75, 0xa9, 0xc8, 0x63, 0x17, 0xc8, 0xf6, 0xb4, 0x35, 0xab, 0x9d, 0x53, 0xb9}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "\169\&9\US\187\DC1", _password = Just +// "\184\193\180:Dky-1\229\177\RS\US\181{h{\187\237\157K\222kRL\242Z\NAK\214", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS1, _willTopic = "", _willMsg = +// "\251Q\218\169\218\207sq\185c\DC2s\f\\\246'R\RS%\242v\DEL\204f\195I\159`&", _willProps = []}), _cleanSession = False, +// _keepAlive = 13305, _connID = "\207\241K\128\152Q\EMw\238\135PC\202L\142.\156)~\213\212\205", _properties = []} +TEST(Connect311QCTest, Encode11) { + uint8_t pkt[] = {0x10, 0x69, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x33, 0xf9, 0x0, 0x16, 0xcf, 0xf1, + 0x4b, 0x80, 0x98, 0x51, 0x19, 0x77, 0xee, 0x87, 0x50, 0x43, 0xca, 0x4c, 0x8e, 0x2e, 0x9c, 0x29, + 0x7e, 0xd5, 0xd4, 0xcd, 0x0, 0x0, 0x0, 0x1d, 0xfb, 0x51, 0xda, 0xa9, 0xda, 0xcf, 0x73, 0x71, + 0xb9, 0x63, 0x12, 0x73, 0xc, 0x5c, 0xf6, 0x27, 0x52, 0x1e, 0x25, 0xf2, 0x76, 0x7f, 0xcc, 0x66, + 0xc3, 0x49, 0x9f, 0x60, 0x26, 0x0, 0x5, 0xa9, 0x39, 0x1f, 0xbb, 0x11, 0x0, 0x1d, 0xb8, 0xc1, + 0xb4, 0x3a, 0x44, 0x6b, 0x79, 0x2d, 0x31, 0xe5, 0xb1, 0x1e, 0x1f, 0xb5, 0x7b, 0x68, 0x7b, 0xbb, + 0xed, 0x9d, 0x4b, 0xde, 0x6b, 0x52, 0x4c, 0xf2, 0x5a, 0x15, 0xd6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// ConnectRequest {_username = Just "xj\DC2d\147j\242\141\DC1\253\179o\188", _password = Just "\144\238/&m", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\191\197a\194u\133\135\244\211\170\162\129\161\&6\225\&2", _willMsg = "\218\f", _willProps = []}), _cleanSession = False, _keepAlive = 15412, _connID = "\176\143\160_\\\166\148\213\226\224\CAN>\238\v\168\163", _properties = []} -TEST(Connect311QCTest, Encode12) { -uint8_t pkt[] = {0x10, 0x48, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x3c, 0x34, 0x0, 0x10, 0xb0, 0x8f, 0xa0, 0x5f, 0x5c, 0xa6, 0x94, 0xd5, 0xe2, 0xe0, 0x18, 0x3e, 0xee, 0xb, 0xa8, 0xa3, 0x0, 0x10, 0xbf, 0xc5, 0x61, 0xc2, 0x75, 0x85, 0x87, 0xf4, 0xd3, 0xaa, 0xa2, 0x81, 0xa1, 0x36, 0xe1, 0x32, 0x0, 0x2, 0xda, 0xc, 0x0, 0xd, 0x78, 0x6a, 0x12, 0x64, 0x93, 0x6a, 0xf2, 0x8d, 0x11, 0xfd, 0xb3, 0x6f, 0xbc, 0x0, 0x5, 0x90, 0xee, 0x2f, 0x26, 0x6d}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbf, 0xc5, 0x61, 0xc2, 0x75, 0x85, 0x87, 0xf4, 0xd3, 0xaa, 0xa2, 0x81, 0xa1, 0x36, 0xe1, 0x32}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xda, 0xc}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS0; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 15412; - uint8_t client_id_bytes[] = {0xb0, 0x8f, 0xa0, 0x5f, 0x5c, 0xa6, 0x94, 0xd5, 0xe2, 0xe0, 0x18, 0x3e, 0xee, 0xb, 0xa8, 0xa3}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x78, 0x6a, 0x12, 0x64, 0x93, 0x6a, 0xf2, 0x8d, 0x11, 0xfd, 0xb3, 0x6f, 0xbc}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0x90, 0xee, 0x2f, 0x26, 0x6d}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfb, 0x51, 0xda, 0xa9, 0xda, 0xcf, 0x73, 0x71, 0xb9, 0x63, + 0x12, 0x73, 0xc, 0x5c, 0xf6, 0x27, 0x52, 0x1e, 0x25, 0xf2, + 0x76, 0x7f, 0xcc, 0x66, 0xc3, 0x49, 0x9f, 0x60, 0x26}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 13305; + uint8_t client_id_bytes[] = {0xcf, 0xf1, 0x4b, 0x80, 0x98, 0x51, 0x19, 0x77, 0xee, 0x87, 0x50, + 0x43, 0xca, 0x4c, 0x8e, 0x2e, 0x9c, 0x29, 0x7e, 0xd5, 0xd4, 0xcd}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa9, 0x39, 0x1f, 0xbb, 0x11}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xb8, 0xc1, 0xb4, 0x3a, 0x44, 0x6b, 0x79, 0x2d, 0x31, 0xe5, 0xb1, 0x1e, 0x1f, 0xb5, 0x7b, + 0x68, 0x7b, 0xbb, 0xed, 0x9d, 0x4b, 0xde, 0x6b, 0x52, 0x4c, 0xf2, 0x5a, 0x15, 0xd6}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "\245\186\233\209\154JNY{\148\171\215\226hh\DELD\236\162\206", _password = Nothing, +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "J}|\FS", _willMsg = +// "\230\222{\SO\US\159a\182$\177", _willProps = []}), _cleanSession = False, _keepAlive = 17990, _connID = +// "\164\DC3\215\130\131\167\153>\200\244\244\GS\132\139\&8", _properties = []} +TEST(Connect311QCTest, Encode12) { + uint8_t pkt[] = {0x10, 0x43, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0x46, 0x46, 0x0, 0xf, + 0xa4, 0x13, 0xd7, 0x82, 0x83, 0xa7, 0x99, 0x3e, 0xc8, 0xf4, 0xf4, 0x1d, 0x84, 0x8b, + 0x38, 0x0, 0x4, 0x4a, 0x7d, 0x7c, 0x1c, 0x0, 0xa, 0xe6, 0xde, 0x7b, 0xe, 0x1f, + 0x9f, 0x61, 0xb6, 0x24, 0xb1, 0x0, 0x14, 0xf5, 0xba, 0xe9, 0xd1, 0x9a, 0x4a, 0x4e, + 0x59, 0x7b, 0x94, 0xab, 0xd7, 0xe2, 0x68, 0x68, 0x7f, 0x44, 0xec, 0xa2, 0xce}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// ConnectRequest {_username = Nothing, _password = Just "\128p\220>r\201\195\&0\200", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\DC3l\244\169\203\EOT\129\173\&4\NUL\252\RS\184\133V\249z\191:P~GH\EM\193\SOH29\254e", _willMsg = "mvB", _willProps = []}), _cleanSession = True, _keepAlive = 30313, _connID = "\215\250VLG@\204B\"\166$HJ", _properties = []} -TEST(Connect311QCTest, Encode13) { -uint8_t pkt[] = {0x10, 0x3e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x76, 0x69, 0x0, 0xd, 0xd7, 0xfa, 0x56, 0x4c, 0x47, 0x40, 0xcc, 0x42, 0x22, 0xa6, 0x24, 0x48, 0x4a, 0x0, 0x1e, 0x13, 0x6c, 0xf4, 0xa9, 0xcb, 0x4, 0x81, 0xad, 0x34, 0x0, 0xfc, 0x1e, 0xb8, 0x85, 0x56, 0xf9, 0x7a, 0xbf, 0x3a, 0x50, 0x7e, 0x47, 0x48, 0x19, 0xc1, 0x1, 0x32, 0x39, 0xfe, 0x65, 0x0, 0x3, 0x6d, 0x76, 0x42}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x13, 0x6c, 0xf4, 0xa9, 0xcb, 0x4, 0x81, 0xad, 0x34, 0x0, 0xfc, 0x1e, 0xb8, 0x85, 0x56, 0xf9, 0x7a, 0xbf, 0x3a, 0x50, 0x7e, 0x47, 0x48, 0x19, 0xc1, 0x1, 0x32, 0x39, 0xfe, 0x65}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6d, 0x76, 0x42}; - lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 30313; - uint8_t client_id_bytes[] = {0xd7, 0xfa, 0x56, 0x4c, 0x47, 0x40, 0xcc, 0x42, 0x22, 0xa6, 0x24, 0x48, 0x4a}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x80, 0x70, 0xdc, 0x3e, 0x72, 0xc9, 0xc3, 0x30, 0xc8}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_property_t willpropslist[] = {}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4a, 0x7d, 0x7c, 0x1c}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe6, 0xde, 0x7b, 0xe, 0x1f, 0x9f, 0x61, 0xb6, 0x24, 0xb1}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 17990; + uint8_t client_id_bytes[] = {0xa4, 0x13, 0xd7, 0x82, 0x83, 0xa7, 0x99, 0x3e, + 0xc8, 0xf4, 0xf4, 0x1d, 0x84, 0x8b, 0x38}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xf5, 0xba, 0xe9, 0xd1, 0x9a, 0x4a, 0x4e, 0x59, 0x7b, 0x94, + 0xab, 0xd7, 0xe2, 0x68, 0x68, 0x7f, 0x44, 0xec, 0xa2, 0xce}; + lwmqtt_string_t username = {20, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Nothing, _password = Just "\250\200\162\134OF\FS\CAN\131=\SI\ESC", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\205\193\146C\176\DC1{T\189hD\173\188\SOH\198h\252B\216\175\176\r\209#\187\163", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = ",R\166,\231d\190T\\4\f\152s\ENQ\214\188\159\242\200\STX\212yX\237", _willMsg = "G\242R!yU\157\129c\166", _willProps = []}), _cleanSession = True, _keepAlive = 13547, _connID = "r\251\173\&4c\162{\179\188\SO\213\162/\US\158ej\186\DC43\174\157\&4(u\213\US\164E", _properties = []} -TEST(Connect311QCTest, Encode17) { -uint8_t pkt[] = {0x10, 0x5f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb6, 0x34, 0xeb, 0x0, 0x1d, 0x72, 0xfb, 0xad, 0x34, 0x63, 0xa2, 0x7b, 0xb3, 0xbc, 0xe, 0xd5, 0xa2, 0x2f, 0x1f, 0x9e, 0x65, 0x6a, 0xba, 0x14, 0x33, 0xae, 0x9d, 0x34, 0x28, 0x75, 0xd5, 0x1f, 0xa4, 0x45, 0x0, 0x18, 0x2c, 0x52, 0xa6, 0x2c, 0xe7, 0x64, 0xbe, 0x54, 0x5c, 0x34, 0xc, 0x98, 0x73, 0x5, 0xd6, 0xbc, 0x9f, 0xf2, 0xc8, 0x2, 0xd4, 0x79, 0x58, 0xed, 0x0, 0xa, 0x47, 0xf2, 0x52, 0x21, 0x79, 0x55, 0x9d, 0x81, 0x63, 0xa6, 0x0, 0xe, 0x2d, 0x5c, 0x1f, 0xbf, 0x3e, 0x42, 0xd8, 0xaf, 0xb0, 0xd, 0xd1, 0x23, 0xbb, 0xa3}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + uint8_t will_topic_bytes[] = {0xc2, 0x13, 0xc9, 0xad, 0x69, 0xea, 0x50, 0x29, + 0x9f, 0xf1, 0x4e, 0xd0, 0x6c, 0x85, 0x47}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd0, 0xfa, 0xc0, 0xa0}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 737; + uint8_t client_id_bytes[] = {0xcc, 0x72, 0x8a, 0xd2, 0x99, 0x3e, 0xa1, 0x4b, 0x19, + 0x77, 0x15, 0xd, 0x14, 0xbc, 0x9e, 0x5a, 0x6, 0x36}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "=\244\ESCz\EM\205Q\216 \211\&62\EM\238\244\239O D\136", _password = Just +// "\CANj\v\180\161\237\198h\184_NXO\223\DC1p$\175\183/*\178\186v2Z\USe\145", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS2, _willTopic = ":\229v?0H", _willProps = +// []}), _cleanSession = False, _keepAlive = 176, _connID = +// "\164\181\166\128r\129\SUB\184rUbzJ\177WIU+\158\DEL\SOH\NAK\164\169", _properties = []} +TEST(Connect311QCTest, Encode20) { + uint8_t pkt[] = {0x10, 0x70, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x0, 0xb0, 0x0, 0x18, 0xa4, 0xb5, 0xa6, + 0x80, 0x72, 0x81, 0x1a, 0xb8, 0x72, 0x55, 0x62, 0x7a, 0x4a, 0xb1, 0x57, 0x49, 0x55, 0x2b, 0x9e, 0x7f, + 0x1, 0x15, 0xa4, 0xa9, 0x0, 0x1e, 0x86, 0x71, 0xa1, 0xec, 0xd9, 0x5c, 0xee, 0x33, 0x7a, 0x92, 0xc, + 0xba, 0xc6, 0xd3, 0x75, 0xfa, 0x5f, 0xd, 0xc2, 0x8d, 0x74, 0x7e, 0xa8, 0x77, 0xe1, 0x74, 0xab, 0x87, + 0x69, 0xe5, 0x0, 0x1b, 0xa4, 0xfc, 0x4, 0xcb, 0xc5, 0xa6, 0xab, 0x42, 0xb1, 0x91, 0x14, 0xbe, 0x13, + 0xcd, 0x15, 0x8f, 0x9d, 0x1a, 0xb1, 0xf8, 0x15, 0x81, 0xde, 0x7f, 0x3e, 0x30, 0x48, 0x0, 0x3, 0xa7, + 0x56, 0x76, 0x0, 0x8, 0x1f, 0x65, 0x66, 0x4d, 0x63, 0x59, 0xf5, 0x73}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// ConnectRequest {_username = Just ";\196\214\158d\DC1\NAK\SUB\139)\218\190\184\241\CANP\STX3V\208&);\255\169\182\226\231`", _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 10023, _connID = "\158\&0\SO\215\199\&6&\NUL\172!u\226\224\240J\178nI", _properties = []} -TEST(Connect311QCTest, Encode21) { -uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x27, 0x27, 0x0, 0x12, 0x9e, 0x30, 0xe, 0xd7, 0xc7, 0x36, 0x26, 0x0, 0xac, 0x21, 0x75, 0xe2, 0xe0, 0xf0, 0x4a, 0xb2, 0x6e, 0x49, 0x0, 0x1d, 0x3b, 0xc4, 0xd6, 0x9e, 0x64, 0x11, 0x15, 0x1a, 0x8b, 0x29, 0xda, 0xbe, 0xb8, 0xf1, 0x18, 0x50, 0x2, 0x33, 0x56, 0xd0, 0x26, 0x29, 0x3b, 0xff, 0xa9, 0xb6, 0xe2, 0xe7, 0x60}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 10023; - uint8_t client_id_bytes[] = {0x9e, 0x30, 0xe, 0xd7, 0xc7, 0x36, 0x26, 0x0, 0xac, 0x21, 0x75, 0xe2, 0xe0, 0xf0, 0x4a, 0xb2, 0x6e, 0x49}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x3b, 0xc4, 0xd6, 0x9e, 0x64, 0x11, 0x15, 0x1a, 0x8b, 0x29, 0xda, 0xbe, 0xb8, 0xf1, 0x18, 0x50, 0x2, 0x33, 0x56, 0xd0, 0x26, 0x29, 0x3b, 0xff, 0xa9, 0xb6, 0xe2, 0xe7, 0x60}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; -opts.username = username; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_will_t will = lwmqtt_default_will; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t willpropslist[] = {}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x86, 0x71, 0xa1, 0xec, 0xd9, 0x5c, 0xee, 0x33, 0x7a, 0x92, + 0xc, 0xba, 0xc6, 0xd3, 0x75, 0xfa, 0x5f, 0xd, 0xc2, 0x8d, + 0x74, 0x7e, 0xa8, 0x77, 0xe1, 0x74, 0xab, 0x87, 0x69, 0xe5}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa4, 0xfc, 0x4, 0xcb, 0xc5, 0xa6, 0xab, 0x42, 0xb1, 0x91, 0x14, 0xbe, 0x13, 0xcd, + 0x15, 0x8f, 0x9d, 0x1a, 0xb1, 0xf8, 0x15, 0x81, 0xde, 0x7f, 0x3e, 0x30, 0x48}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 176; + uint8_t client_id_bytes[] = {0xa4, 0xb5, 0xa6, 0x80, 0x72, 0x81, 0x1a, 0xb8, 0x72, 0x55, 0x62, 0x7a, + 0x4a, 0xb1, 0x57, 0x49, 0x55, 0x2b, 0x9e, 0x7f, 0x1, 0x15, 0xa4, 0xa9}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa7, 0x56, 0x76}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x1f, 0x65, 0x66, 0x4d, 0x63, 0x59, 0xf5, 0x73}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "g\164\GS\251\214\154t\217\140l\213\150&{\211\130", _password = Just +// "\187\ESC\201\164\156\195h\241\250v8\t\179\193\251[*\142", _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 20540, _connID = "\255k\192]Rmr[\146o,\129", _properties = []} +TEST(Connect311QCTest, Encode21) { + uint8_t pkt[] = {0x10, 0x3e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x50, 0x3c, 0x0, 0xc, 0xff, 0x6b, + 0xc0, 0x5d, 0x52, 0x6d, 0x72, 0x5b, 0x92, 0x6f, 0x2c, 0x81, 0x0, 0x10, 0x67, 0xa4, 0x1d, 0xfb, + 0xd6, 0x9a, 0x74, 0xd9, 0x8c, 0x6c, 0xd5, 0x96, 0x26, 0x7b, 0xd3, 0x82, 0x0, 0x12, 0xbb, 0x1b, + 0xc9, 0xa4, 0x9c, 0xc3, 0x68, 0xf1, 0xfa, 0x76, 0x38, 0x9, 0xb3, 0xc1, 0xfb, 0x5b, 0x2a, 0x8e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; -// ConnectRequest {_username = Just "F\208\168\t~)z\vT8=\231\137\f\197\180\&5\169O\b\222\153\175\180H\193b\154%", _password = Just "\NAK^\RS\171Ce0\DLE\151\171\237L\167#", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\ESCn\STX\167<\196\189\197", _willMsg = "G\NAK\158\v\STX\173\140y\131", _willProps = []}), _cleanSession = True, _keepAlive = 17115, _connID = "\224\239\SYNj", _properties = []} + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 20540; + uint8_t client_id_bytes[] = {0xff, 0x6b, 0xc0, 0x5d, 0x52, 0x6d, 0x72, 0x5b, 0x92, 0x6f, 0x2c, 0x81}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x67, 0xa4, 0x1d, 0xfb, 0xd6, 0x9a, 0x74, 0xd9, + 0x8c, 0x6c, 0xd5, 0x96, 0x26, 0x7b, 0xd3, 0x82}; + lwmqtt_string_t username = {16, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xbb, 0x1b, 0xc9, 0xa4, 0x9c, 0xc3, 0x68, 0xf1, 0xfa, + 0x76, 0x38, 0x9, 0xb3, 0xc1, 0xfb, 0x5b, 0x2a, 0x8e}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\130\153\246\DLEX\252\184\254\209\234/\229\190\&1k\ENQ\DC1\DEL\186", _password = +// Just "\152\245\222\230\235\f!z\243\&9\224P\250\231\236#\205V", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS1, _willTopic = "\199\149\CAND\190\238\210\161\204\&8C\192\168'\162\198\250\r\142\&0\250", _willMsg = +// "OUI", _willProps = []}), _cleanSession = False, _keepAlive = 63, _connID = +// "\FS\196\a\216\236\229ts[;\209\141\182\141\154#\226\&7H.\199\195\f-\159\183\252c\235", _properties = []} TEST(Connect311QCTest, Encode22) { -uint8_t pkt[] = {0x10, 0x54, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x42, 0xdb, 0x0, 0x4, 0xe0, 0xef, 0x16, 0x6a, 0x0, 0x8, 0x1b, 0x6e, 0x2, 0xa7, 0x3c, 0xc4, 0xbd, 0xc5, 0x0, 0x9, 0x47, 0x15, 0x9e, 0xb, 0x2, 0xad, 0x8c, 0x79, 0x83, 0x0, 0x1d, 0x46, 0xd0, 0xa8, 0x9, 0x7e, 0x29, 0x7a, 0xb, 0x54, 0x38, 0x3d, 0xe7, 0x89, 0xc, 0xc5, 0xb4, 0x35, 0xa9, 0x4f, 0x8, 0xde, 0x99, 0xaf, 0xb4, 0x48, 0xc1, 0x62, 0x9a, 0x25, 0x0, 0xe, 0x15, 0x5e, 0x1e, 0xab, 0x43, 0x65, 0x30, 0x10, 0x97, 0xab, 0xed, 0x4c, 0xa7, 0x23}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x10, 0x6e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x0, 0x3f, 0x0, 0x1d, 0x1c, 0xc4, + 0x7, 0xd8, 0xec, 0xe5, 0x74, 0x73, 0x5b, 0x3b, 0xd1, 0x8d, 0xb6, 0x8d, 0x9a, 0x23, 0xe2, 0x37, + 0x48, 0x2e, 0xc7, 0xc3, 0xc, 0x2d, 0x9f, 0xb7, 0xfc, 0x63, 0xeb, 0x0, 0x15, 0xc7, 0x95, 0x18, + 0x44, 0xbe, 0xee, 0xd2, 0xa1, 0xcc, 0x38, 0x43, 0xc0, 0xa8, 0x27, 0xa2, 0xc6, 0xfa, 0xd, 0x8e, + 0x30, 0xfa, 0x0, 0x3, 0x4f, 0x55, 0x49, 0x0, 0x13, 0x82, 0x99, 0xf6, 0x10, 0x58, 0xfc, 0xb8, + 0xfe, 0xd1, 0xea, 0x2f, 0xe5, 0xbe, 0x31, 0x6b, 0x5, 0x11, 0x7f, 0xba, 0x0, 0x12, 0x98, 0xf5, + 0xde, 0xe6, 0xeb, 0xc, 0x21, 0x7a, 0xf3, 0x39, 0xe0, 0x50, 0xfa, 0xe7, 0xec, 0x23, 0xcd, 0x56}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1b, 0x6e, 0x2, 0xa7, 0x3c, 0xc4, 0xbd, 0xc5}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x47, 0x15, 0x9e, 0xb, 0x2, 0xad, 0x8c, 0x79, 0x83}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 17115; - uint8_t client_id_bytes[] = {0xe0, 0xef, 0x16, 0x6a}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x46, 0xd0, 0xa8, 0x9, 0x7e, 0x29, 0x7a, 0xb, 0x54, 0x38, 0x3d, 0xe7, 0x89, 0xc, 0xc5, 0xb4, 0x35, 0xa9, 0x4f, 0x8, 0xde, 0x99, 0xaf, 0xb4, 0x48, 0xc1, 0x62, 0x9a, 0x25}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0x15, 0x5e, 0x1e, 0xab, 0x43, 0x65, 0x30, 0x10, 0x97, 0xab, 0xed, 0x4c, 0xa7, 0x23}; - lwmqtt_string_t password = {14, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - -} - - -// ConnectRequest {_username = Nothing, _password = Just "_\181", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\130\CANG\157\a\138\188H\194", _willMsg = "\131;\DEL\244\175\170\170\225\172", _willProps = []}), _cleanSession = True, _keepAlive = 18273, _connID = "\DLEX\181cI5\156\142^\212\200\ETX\254\162\223\136\ETB\142\251p\163", _properties = []} + uint8_t will_topic_bytes[] = {0xc7, 0x95, 0x18, 0x44, 0xbe, 0xee, 0xd2, 0xa1, 0xcc, 0x38, 0x43, + 0xc0, 0xa8, 0x27, 0xa2, 0xc6, 0xfa, 0xd, 0x8e, 0x30, 0xfa}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4f, 0x55, 0x49}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 63; + uint8_t client_id_bytes[] = {0x1c, 0xc4, 0x7, 0xd8, 0xec, 0xe5, 0x74, 0x73, 0x5b, 0x3b, 0xd1, 0x8d, 0xb6, 0x8d, 0x9a, + 0x23, 0xe2, 0x37, 0x48, 0x2e, 0xc7, 0xc3, 0xc, 0x2d, 0x9f, 0xb7, 0xfc, 0x63, 0xeb}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x82, 0x99, 0xf6, 0x10, 0x58, 0xfc, 0xb8, 0xfe, 0xd1, 0xea, + 0x2f, 0xe5, 0xbe, 0x31, 0x6b, 0x5, 0x11, 0x7f, 0xba}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x98, 0xf5, 0xde, 0xe6, 0xeb, 0xc, 0x21, 0x7a, 0xf3, + 0x39, 0xe0, 0x50, 0xfa, 0xe7, 0xec, 0x23, 0xcd, 0x56}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "\RS\167\162\&6\154\242\173\187\159\228M\149\143\133]\FS%\242\219\239\232\172\&7\STX\236\&3\229", _password = Just +// "\223\143\v\237\t/\227\FS\210\243\130\206\v\180\r", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, +// _willTopic = " \SI\153\ACK\213(Df\150\253\194\171\158r\205\203cW", _willMsg = +// "\221\140d\205\238w\156m\218w\195\&4\189\&2\208\177", _willProps = []}), _cleanSession = False, _keepAlive = 32455, +// _connID = "\199f\232=\172\DEL\148R>\167\\X;\235 \DC1\189\173\203WE\245", _properties = []} TEST(Connect311QCTest, Encode23) { -uint8_t pkt[] = {0x10, 0x37, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x47, 0x61, 0x0, 0x15, 0x10, 0x58, 0xb5, 0x63, 0x49, 0x35, 0x9c, 0x8e, 0x5e, 0xd4, 0xc8, 0x3, 0xfe, 0xa2, 0xdf, 0x88, 0x17, 0x8e, 0xfb, 0x70, 0xa3, 0x0, 0x9, 0x82, 0x18, 0x47, 0x9d, 0x7, 0x8a, 0xbc, 0x48, 0xc2, 0x0, 0x9, 0x83, 0x3b, 0x7f, 0xf4, 0xaf, 0xaa, 0xaa, 0xe1, 0xac}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x10, 0x76, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x7e, 0xc7, 0x0, 0x16, 0xc7, + 0x66, 0xe8, 0x3d, 0xac, 0x7f, 0x94, 0x52, 0x3e, 0xa7, 0x5c, 0x58, 0x3b, 0xeb, 0x20, 0x11, + 0xbd, 0xad, 0xcb, 0x57, 0x45, 0xf5, 0x0, 0x12, 0x20, 0xf, 0x99, 0x6, 0xd5, 0x28, 0x44, + 0x66, 0x96, 0xfd, 0xc2, 0xab, 0x9e, 0x72, 0xcd, 0xcb, 0x63, 0x57, 0x0, 0x10, 0xdd, 0x8c, + 0x64, 0xcd, 0xee, 0x77, 0x9c, 0x6d, 0xda, 0x77, 0xc3, 0x34, 0xbd, 0x32, 0xd0, 0xb1, 0x0, + 0x1b, 0x1e, 0xa7, 0xa2, 0x36, 0x9a, 0xf2, 0xad, 0xbb, 0x9f, 0xe4, 0x4d, 0x95, 0x8f, 0x85, + 0x5d, 0x1c, 0x25, 0xf2, 0xdb, 0xef, 0xe8, 0xac, 0x37, 0x2, 0xec, 0x33, 0xe5, 0x0, 0xf, + 0xdf, 0x8f, 0xb, 0xed, 0x9, 0x2f, 0xe3, 0x1c, 0xd2, 0xf3, 0x82, 0xce, 0xb, 0xb4, 0xd}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x82, 0x18, 0x47, 0x9d, 0x7, 0x8a, 0xbc, 0x48, 0xc2}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x83, 0x3b, 0x7f, 0xf4, 0xaf, 0xaa, 0xaa, 0xe1, 0xac}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS0; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 18273; - uint8_t client_id_bytes[] = {0x10, 0x58, 0xb5, 0x63, 0x49, 0x35, 0x9c, 0x8e, 0x5e, 0xd4, 0xc8, 0x3, 0xfe, 0xa2, 0xdf, 0x88, 0x17, 0x8e, 0xfb, 0x70, 0xa3}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x5f, 0xb5}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0x20, 0xf, 0x99, 0x6, 0xd5, 0x28, 0x44, 0x66, 0x96, + 0xfd, 0xc2, 0xab, 0x9e, 0x72, 0xcd, 0xcb, 0x63, 0x57}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xdd, 0x8c, 0x64, 0xcd, 0xee, 0x77, 0x9c, 0x6d, + 0xda, 0x77, 0xc3, 0x34, 0xbd, 0x32, 0xd0, 0xb1}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32455; + uint8_t client_id_bytes[] = {0xc7, 0x66, 0xe8, 0x3d, 0xac, 0x7f, 0x94, 0x52, 0x3e, 0xa7, 0x5c, + 0x58, 0x3b, 0xeb, 0x20, 0x11, 0xbd, 0xad, 0xcb, 0x57, 0x45, 0xf5}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x1e, 0xa7, 0xa2, 0x36, 0x9a, 0xf2, 0xad, 0xbb, 0x9f, 0xe4, 0x4d, 0x95, 0x8f, 0x85, + 0x5d, 0x1c, 0x25, 0xf2, 0xdb, 0xef, 0xe8, 0xac, 0x37, 0x2, 0xec, 0x33, 0xe5}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xdf, 0x8f, 0xb, 0xed, 0x9, 0x2f, 0xe3, 0x1c, 0xd2, 0xf3, 0x82, 0xce, 0xb, 0xb4, 0xd}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = +// 14647, _connID = "\173\255n}\129\NAK", _properties = []} +TEST(Connect311QCTest, Encode24) { + uint8_t pkt[] = {0x10, 0x12, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, + 0x39, 0x37, 0x0, 0x6, 0xad, 0xff, 0x6e, 0x7d, 0x81, 0x15}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 14647; + uint8_t client_id_bytes[] = {0xad, 0xff, 0x6e, 0x7d, 0x81, 0x15}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "/&", _password = Just +// "8\SUB\143\t\ESC\220%\187\ESC1\163\&9\253\207\185F\t\213N\NUL\"", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS0, _willTopic = "\209Ho\130\233\&6\203E\189\STX\204\202LG\160\188C[\GS&\169w\NUL\208\161", _willMsg = +// "C", _willProps = []}), _cleanSession = False, _keepAlive = 17899, _connID = ".hc\n\135\206/\236\&0\221\216\155\236", +// _properties = []} +TEST(Connect311QCTest, Encode25) { + uint8_t pkt[] = {0x10, 0x52, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x45, 0xeb, 0x0, 0xd, 0x2e, 0x68, 0x63, + 0xa, 0x87, 0xce, 0x2f, 0xec, 0x30, 0xdd, 0xd8, 0x9b, 0xec, 0x0, 0x19, 0xd1, 0x48, 0x6f, 0x82, 0xe9, + 0x36, 0xcb, 0x45, 0xbd, 0x2, 0xcc, 0xca, 0x4c, 0x47, 0xa0, 0xbc, 0x43, 0x5b, 0x1d, 0x26, 0xa9, 0x77, + 0x0, 0xd0, 0xa1, 0x0, 0x1, 0x43, 0x0, 0x2, 0x2f, 0x26, 0x0, 0x15, 0x38, 0x1a, 0x8f, 0x9, 0x1b, + 0xdc, 0x25, 0xbb, 0x1b, 0x31, 0xa3, 0x39, 0xfd, 0xcf, 0xb9, 0x46, 0x9, 0xd5, 0x4e, 0x0, 0x22}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\212\138\190Q;W\148\195", _willMsg = "\213;", _willProps = []}), _cleanSession = True, _keepAlive = 31629, _connID = "\157f\DC3.", _properties = []} -TEST(Connect311QCTest, Encode24) { -uint8_t pkt[] = {0x10, 0x1e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x7b, 0x8d, 0x0, 0x4, 0x9d, 0x66, 0x13, 0x2e, 0x0, 0x8, 0xd4, 0x8a, 0xbe, 0x51, 0x3b, 0x57, 0x94, 0xc3, 0x0, 0x2, 0xd5, 0x3b}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd4, 0x8a, 0xbe, 0x51, 0x3b, 0x57, 0x94, 0xc3}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd5, 0x3b}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 31629; - uint8_t client_id_bytes[] = {0x9d, 0x66, 0x13, 0x2e}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; -opts.client_id = client_id; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_property_t willpropslist[] = {}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd1, 0x48, 0x6f, 0x82, 0xe9, 0x36, 0xcb, 0x45, 0xbd, 0x2, 0xcc, 0xca, 0x4c, + 0x47, 0xa0, 0xbc, 0x43, 0x5b, 0x1d, 0x26, 0xa9, 0x77, 0x0, 0xd0, 0xa1}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x43}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 17899; + uint8_t client_id_bytes[] = {0x2e, 0x68, 0x63, 0xa, 0x87, 0xce, 0x2f, 0xec, 0x30, 0xdd, 0xd8, 0x9b, 0xec}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x2f, 0x26}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x38, 0x1a, 0x8f, 0x9, 0x1b, 0xdc, 0x25, 0xbb, 0x1b, 0x31, 0xa3, + 0x39, 0xfd, 0xcf, 0xb9, 0x46, 0x9, 0xd5, 0x4e, 0x0, 0x22}; + lwmqtt_string_t password = {21, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "N\203\159\210\235ac\RS\168\231\220r'\253\200\162\192\166\149\231\221", _password = +// Just "\174,\168L\134y\NUL\129\t\237\152\134\184\222\US\168\208\"|\246\140=\236\196~\b\150\246\216\164", _lastWill = +// Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\218I\179[\161\209\ESC}h\205FPB@K\133", _willMsg +// = "2\215\135\225\197N", _willProps = []}), _cleanSession = False, _keepAlive = 30481, _connID = +// "\132\129b\222=>\197\164\SO\236\234\204O\202\240\150\&0\186\167", _properties = []} +TEST(Connect311QCTest, Encode26) { + uint8_t pkt[] = {0x10, 0x70, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x77, 0x11, 0x0, 0x13, 0x84, 0x81, 0x62, + 0xde, 0x3d, 0x3e, 0xc5, 0xa4, 0xe, 0xec, 0xea, 0xcc, 0x4f, 0xca, 0xf0, 0x96, 0x30, 0xba, 0xa7, 0x0, + 0x10, 0xda, 0x49, 0xb3, 0x5b, 0xa1, 0xd1, 0x1b, 0x7d, 0x68, 0xcd, 0x46, 0x50, 0x42, 0x40, 0x4b, 0x85, + 0x0, 0x6, 0x32, 0xd7, 0x87, 0xe1, 0xc5, 0x4e, 0x0, 0x15, 0x4e, 0xcb, 0x9f, 0xd2, 0xeb, 0x61, 0x63, + 0x1e, 0xa8, 0xe7, 0xdc, 0x72, 0x27, 0xfd, 0xc8, 0xa2, 0xc0, 0xa6, 0x95, 0xe7, 0xdd, 0x0, 0x1e, 0xae, + 0x2c, 0xa8, 0x4c, 0x86, 0x79, 0x0, 0x81, 0x9, 0xed, 0x98, 0x86, 0xb8, 0xde, 0x1f, 0xa8, 0xd0, 0x22, + 0x7c, 0xf6, 0x8c, 0x3d, 0xec, 0xc4, 0x7e, 0x8, 0x96, 0xf6, 0xd8, 0xa4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// ConnectRequest {_username = Just "\252\245y:\200\b\234\&6\225\SYN\158z\238&\CAN\175\138", _password = Just "|\218-vl\SYN\222f\159V\138\232\203", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "5Y\164\&1`u\255\252\&8\171&", _willMsg = "n\STX\DC2\DEL_\171\ENQ\171\145\175\ESC6\158\&2\246\f%h\190\233O\232\175\190\128\STX\178\210\245l", _willProps = []}), _cleanSession = False, _keepAlive = 21783, _connID = "56\NAK,s\168\165\247\235\SOP\239\239\194\155\NAK\181iBp\RS\239\ACK\131\a\157\SUB\150]", _properties = []} -TEST(Connect311QCTest, Encode25) { -uint8_t pkt[] = {0x10, 0x78, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x55, 0x17, 0x0, 0x1d, 0x35, 0x36, 0x15, 0x2c, 0x73, 0xa8, 0xa5, 0xf7, 0xeb, 0xe, 0x50, 0xef, 0xef, 0xc2, 0x9b, 0x15, 0xb5, 0x69, 0x42, 0x70, 0x1e, 0xef, 0x6, 0x83, 0x7, 0x9d, 0x1a, 0x96, 0x5d, 0x0, 0xb, 0x35, 0x59, 0xa4, 0x31, 0x60, 0x75, 0xff, 0xfc, 0x38, 0xab, 0x26, 0x0, 0x1e, 0x6e, 0x2, 0x12, 0x7f, 0x5f, 0xab, 0x5, 0xab, 0x91, 0xaf, 0x1b, 0x36, 0x9e, 0x32, 0xf6, 0xc, 0x25, 0x68, 0xbe, 0xe9, 0x4f, 0xe8, 0xaf, 0xbe, 0x80, 0x2, 0xb2, 0xd2, 0xf5, 0x6c, 0x0, 0x11, 0xfc, 0xf5, 0x79, 0x3a, 0xc8, 0x8, 0xea, 0x36, 0xe1, 0x16, 0x9e, 0x7a, 0xee, 0x26, 0x18, 0xaf, 0x8a, 0x0, 0xd, 0x7c, 0xda, 0x2d, 0x76, 0x6c, 0x16, 0xde, 0x66, 0x9f, 0x56, 0x8a, 0xe8, 0xcb}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x35, 0x59, 0xa4, 0x31, 0x60, 0x75, 0xff, 0xfc, 0x38, 0xab, 0x26}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6e, 0x2, 0x12, 0x7f, 0x5f, 0xab, 0x5, 0xab, 0x91, 0xaf, 0x1b, 0x36, 0x9e, 0x32, 0xf6, 0xc, 0x25, 0x68, 0xbe, 0xe9, 0x4f, 0xe8, 0xaf, 0xbe, 0x80, 0x2, 0xb2, 0xd2, 0xf5, 0x6c}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 21783; - uint8_t client_id_bytes[] = {0x35, 0x36, 0x15, 0x2c, 0x73, 0xa8, 0xa5, 0xf7, 0xeb, 0xe, 0x50, 0xef, 0xef, 0xc2, 0x9b, 0x15, 0xb5, 0x69, 0x42, 0x70, 0x1e, 0xef, 0x6, 0x83, 0x7, 0x9d, 0x1a, 0x96, 0x5d}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xfc, 0xf5, 0x79, 0x3a, 0xc8, 0x8, 0xea, 0x36, 0xe1, 0x16, 0x9e, 0x7a, 0xee, 0x26, 0x18, 0xaf, 0x8a}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0x7c, 0xda, 0x2d, 0x76, 0x6c, 0x16, 0xde, 0x66, 0x9f, 0x56, 0x8a, 0xe8, 0xcb}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_property_t willpropslist[] = {}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xda, 0x49, 0xb3, 0x5b, 0xa1, 0xd1, 0x1b, 0x7d, + 0x68, 0xcd, 0x46, 0x50, 0x42, 0x40, 0x4b, 0x85}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x32, 0xd7, 0x87, 0xe1, 0xc5, 0x4e}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 30481; + uint8_t client_id_bytes[] = {0x84, 0x81, 0x62, 0xde, 0x3d, 0x3e, 0xc5, 0xa4, 0xe, 0xec, + 0xea, 0xcc, 0x4f, 0xca, 0xf0, 0x96, 0x30, 0xba, 0xa7}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x4e, 0xcb, 0x9f, 0xd2, 0xeb, 0x61, 0x63, 0x1e, 0xa8, 0xe7, 0xdc, + 0x72, 0x27, 0xfd, 0xc8, 0xa2, 0xc0, 0xa6, 0x95, 0xe7, 0xdd}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xae, 0x2c, 0xa8, 0x4c, 0x86, 0x79, 0x0, 0x81, 0x9, 0xed, 0x98, 0x86, 0xb8, 0xde, 0x1f, + 0xa8, 0xd0, 0x22, 0x7c, 0xf6, 0x8c, 0x3d, 0xec, 0xc4, 0x7e, 0x8, 0x96, 0xf6, 0xd8, 0xa4}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "eBV0^b\231\GS\250\n\203\224", _password = Just +// "\240\177\187\244\250c\"\200Pw\189\163m|\131\&5*\177\169]", _lastWill = Just (LastWill {_willRetain = True, _willQoS +// = QoS1, _willTopic = "\b,([w\253\205\CAN\167\199\238\&0\171\SOHj\206\NUL\245\243\144\169\b\226\180\134\154}\214\194", +// _willMsg = "\181aO\128(\188\ETB", _willProps = []}), _cleanSession = False, _keepAlive = 3521, _connID = +// "\205A\247\ACK\129\&6\196\202\192<\208z\234>\ETB\DC2\195\208\221\STX\DC1L\146s", _properties = []} +TEST(Connect311QCTest, Encode27) { + uint8_t pkt[] = {0x10, 0x70, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0xd, 0xc1, 0x0, 0x18, 0xcd, 0x41, 0xf7, + 0x6, 0x81, 0x36, 0xc4, 0xca, 0xc0, 0x3c, 0xd0, 0x7a, 0xea, 0x3e, 0x17, 0x12, 0xc3, 0xd0, 0xdd, 0x2, + 0x11, 0x4c, 0x92, 0x73, 0x0, 0x1d, 0x8, 0x2c, 0x28, 0x5b, 0x77, 0xfd, 0xcd, 0x18, 0xa7, 0xc7, 0xee, + 0x30, 0xab, 0x1, 0x6a, 0xce, 0x0, 0xf5, 0xf3, 0x90, 0xa9, 0x8, 0xe2, 0xb4, 0x86, 0x9a, 0x7d, 0xd6, + 0xc2, 0x0, 0x7, 0xb5, 0x61, 0x4f, 0x80, 0x28, 0xbc, 0x17, 0x0, 0xc, 0x65, 0x42, 0x56, 0x30, 0x5e, + 0x62, 0xe7, 0x1d, 0xfa, 0xa, 0xcb, 0xe0, 0x0, 0x14, 0xf0, 0xb1, 0xbb, 0xf4, 0xfa, 0x63, 0x22, 0xc8, + 0x50, 0x77, 0xbd, 0xa3, 0x6d, 0x7c, 0x83, 0x35, 0x2a, 0xb1, 0xa9, 0x5d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// ConnectRequest {_username = Just "\223*\129F(\130\&4\142\220[3\138\202/U\241z\144\214\227\&9\162\164\149", _password = Just "k\177\238>\207X\198i\188\175\151\215\&4\250\DC2\133\DC3\208", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "", _willMsg = "O\f\163R\254G\172]\199\227#f/\147[\SI", _willProps = []}), _cleanSession = False, _keepAlive = 1168, _connID = "\t\208\CAN'\235Mek\SI\DC2;\237\GS\194~\SOH,", _properties = []} -TEST(Connect311QCTest, Encode26) { -uint8_t pkt[] = {0x10, 0x5f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x4, 0x90, 0x0, 0x11, 0x9, 0xd0, 0x18, 0x27, 0xeb, 0x4d, 0x65, 0x6b, 0xf, 0x12, 0x3b, 0xed, 0x1d, 0xc2, 0x7e, 0x1, 0x2c, 0x0, 0x0, 0x0, 0x10, 0x4f, 0xc, 0xa3, 0x52, 0xfe, 0x47, 0xac, 0x5d, 0xc7, 0xe3, 0x23, 0x66, 0x2f, 0x93, 0x5b, 0xf, 0x0, 0x18, 0xdf, 0x2a, 0x81, 0x46, 0x28, 0x82, 0x34, 0x8e, 0xdc, 0x5b, 0x33, 0x8a, 0xca, 0x2f, 0x55, 0xf1, 0x7a, 0x90, 0xd6, 0xe3, 0x39, 0xa2, 0xa4, 0x95, 0x0, 0x12, 0x6b, 0xb1, 0xee, 0x3e, 0xcf, 0x58, 0xc6, 0x69, 0xbc, 0xaf, 0x97, 0xd7, 0x34, 0xfa, 0x12, 0x85, 0x13, 0xd0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4f, 0xc, 0xa3, 0x52, 0xfe, 0x47, 0xac, 0x5d, 0xc7, 0xe3, 0x23, 0x66, 0x2f, 0x93, 0x5b, 0xf}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 1168; - uint8_t client_id_bytes[] = {0x9, 0xd0, 0x18, 0x27, 0xeb, 0x4d, 0x65, 0x6b, 0xf, 0x12, 0x3b, 0xed, 0x1d, 0xc2, 0x7e, 0x1, 0x2c}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xdf, 0x2a, 0x81, 0x46, 0x28, 0x82, 0x34, 0x8e, 0xdc, 0x5b, 0x33, 0x8a, 0xca, 0x2f, 0x55, 0xf1, 0x7a, 0x90, 0xd6, 0xe3, 0x39, 0xa2, 0xa4, 0x95}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0x6b, 0xb1, 0xee, 0x3e, 0xcf, 0x58, 0xc6, 0x69, 0xbc, 0xaf, 0x97, 0xd7, 0x34, 0xfa, 0x12, 0x85, 0x13, 0xd0}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_property_t willpropslist[] = {}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8, 0x2c, 0x28, 0x5b, 0x77, 0xfd, 0xcd, 0x18, 0xa7, 0xc7, 0xee, 0x30, 0xab, 0x1, 0x6a, + 0xce, 0x0, 0xf5, 0xf3, 0x90, 0xa9, 0x8, 0xe2, 0xb4, 0x86, 0x9a, 0x7d, 0xd6, 0xc2}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb5, 0x61, 0x4f, 0x80, 0x28, 0xbc, 0x17}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3521; + uint8_t client_id_bytes[] = {0xcd, 0x41, 0xf7, 0x6, 0x81, 0x36, 0xc4, 0xca, 0xc0, 0x3c, 0xd0, 0x7a, + 0xea, 0x3e, 0x17, 0x12, 0xc3, 0xd0, 0xdd, 0x2, 0x11, 0x4c, 0x92, 0x73}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x65, 0x42, 0x56, 0x30, 0x5e, 0x62, 0xe7, 0x1d, 0xfa, 0xa, 0xcb, 0xe0}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf0, 0xb1, 0xbb, 0xf4, 0xfa, 0x63, 0x22, 0xc8, 0x50, 0x77, + 0xbd, 0xa3, 0x6d, 0x7c, 0x83, 0x35, 0x2a, 0xb1, 0xa9, 0x5d}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Nothing, _password = Just +// "\v\169[\202\FS\206\145\142I\167&I\169k\b\160XudF\138\227\147V\252\193\134\197", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\223\&5$\DELC3\210\149\FS\188b\147\NUL\203\&8\177\&6\141S\"\236\215C", _willMsg = +// "\137Fydy\130\218\t\246Eu\206\188[\241P\186\235\236", _willProps = []}), _cleanSession = True, _keepAlive = 17383, +// _connID = "\146\157\196~\185Q\216\228Q\237\164K\154M\STX\226\133\244\158\188\177 \245\198\168", _properties = []} +TEST(Connect311QCTest, Encode28) { + uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2e, 0x43, 0xe7, 0x0, 0x19, 0x92, + 0x9d, 0xc4, 0x7e, 0xb9, 0x51, 0xd8, 0xe4, 0x51, 0xed, 0xa4, 0x4b, 0x9a, 0x4d, 0x2, 0xe2, + 0x85, 0xf4, 0x9e, 0xbc, 0xb1, 0x20, 0xf5, 0xc6, 0xa8, 0x0, 0x17, 0xdf, 0x35, 0x24, 0x7f, + 0x43, 0x33, 0xd2, 0x95, 0x1c, 0xbc, 0x62, 0x93, 0x0, 0xcb, 0x38, 0xb1, 0x36, 0x8d, 0x53, + 0x22, 0xec, 0xd7, 0x43, 0x0, 0x13, 0x89, 0x46, 0x79, 0x64, 0x79, 0x82, 0xda, 0x9, 0xf6, + 0x45, 0x75, 0xce, 0xbc, 0x5b, 0xf1, 0x50, 0xba, 0xeb, 0xec}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// ConnectRequest {_username = Just "\220\&2", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\174'\200lI", _willMsg = "\GS\ETXa\251\147I\r\201>\212r\195\DC1\164\SO!", _willProps = []}), _cleanSession = True, _keepAlive = 6357, _connID = "\200", _properties = []} -TEST(Connect311QCTest, Encode27) { -uint8_t pkt[] = {0x10, 0x2a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb6, 0x18, 0xd5, 0x0, 0x1, 0xc8, 0x0, 0x5, 0xae, 0x27, 0xc8, 0x6c, 0x49, 0x0, 0x10, 0x1d, 0x3, 0x61, 0xfb, 0x93, 0x49, 0xd, 0xc9, 0x3e, 0xd4, 0x72, 0xc3, 0x11, 0xa4, 0xe, 0x21, 0x0, 0x2, 0xdc, 0x32}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xae, 0x27, 0xc8, 0x6c, 0x49}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1d, 0x3, 0x61, 0xfb, 0x93, 0x49, 0xd, 0xc9, 0x3e, 0xd4, 0x72, 0xc3, 0x11, 0xa4, 0xe, 0x21}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 6357; - uint8_t client_id_bytes[] = {0xc8}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xdc, 0x32}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; -opts.username = username; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + uint8_t will_topic_bytes[] = {0xdf, 0x35, 0x24, 0x7f, 0x43, 0x33, 0xd2, 0x95, 0x1c, 0xbc, 0x62, 0x93, + 0x0, 0xcb, 0x38, 0xb1, 0x36, 0x8d, 0x53, 0x22, 0xec, 0xd7, 0x43}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x89, 0x46, 0x79, 0x64, 0x79, 0x82, 0xda, 0x9, 0xf6, 0x45, + 0x75, 0xce, 0xbc, 0x5b, 0xf1, 0x50, 0xba, 0xeb, 0xec}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 17383; + uint8_t client_id_bytes[] = {0x92, 0x9d, 0xc4, 0x7e, 0xb9, 0x51, 0xd8, 0xe4, 0x51, 0xed, 0xa4, 0x4b, 0x9a, + 0x4d, 0x2, 0xe2, 0x85, 0xf4, 0x9e, 0xbc, 0xb1, 0x20, 0xf5, 0xc6, 0xa8}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xb, 0xa9, 0x5b, 0xca, 0x1c, 0xce, 0x91, 0x8e, 0x49, 0xa7, 0x26, 0x49, 0xa9, 0x6b, + 0x8, 0xa0, 0x58, 0x75, 0x64, 0x46, 0x8a, 0xe3, 0x93, 0x56, 0xfc, 0xc1, 0x86, 0xc5}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\167\237\156Mq\176\&7F\133;p\STX\164\219,\196,U\NUL\171\ETB\144M", _password = Just +// "\150'c\159\ETX\DC2\144\212TY\230:\SOHvc'\218\154\US2#1\183\&7", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS2, _willTopic = "\STX\r\249A\250?#\SI\142\224\207\203C3\203\129\232\238\f>C\SUB\149\221\198\\1", +// _willMsg = "u}g.\134\182\153", _willProps = []}), _cleanSession = False, _keepAlive = 2013, _connID = +// "\255\RST!?\165@\128+YC\181-\250\193\183\233\&7\RS\197x\SUB[?\f\227t", _properties = []} +TEST(Connect311QCTest, Encode29) { + uint8_t pkt[] = {0x10, 0x80, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x7, 0xdd, 0x0, 0x1b, 0xff, 0x1e, + 0x54, 0x21, 0x3f, 0xa5, 0x40, 0x80, 0x2b, 0x59, 0x43, 0xb5, 0x2d, 0xfa, 0xc1, 0xb7, 0xe9, 0x37, 0x1e, + 0xc5, 0x78, 0x1a, 0x5b, 0x3f, 0xc, 0xe3, 0x74, 0x0, 0x1b, 0x2, 0xd, 0xf9, 0x41, 0xfa, 0x3f, 0x23, + 0xf, 0x8e, 0xe0, 0xcf, 0xcb, 0x43, 0x33, 0xcb, 0x81, 0xe8, 0xee, 0xc, 0x3e, 0x43, 0x1a, 0x95, 0xdd, + 0xc6, 0x5c, 0x31, 0x0, 0x7, 0x75, 0x7d, 0x67, 0x2e, 0x86, 0xb6, 0x99, 0x0, 0x17, 0xa7, 0xed, 0x9c, + 0x4d, 0x71, 0xb0, 0x37, 0x46, 0x85, 0x3b, 0x70, 0x2, 0xa4, 0xdb, 0x2c, 0xc4, 0x2c, 0x55, 0x0, 0xab, + 0x17, 0x90, 0x4d, 0x0, 0x18, 0x96, 0x27, 0x63, 0x9f, 0x3, 0x12, 0x90, 0xd4, 0x54, 0x59, 0xe6, 0x3a, + 0x1, 0x76, 0x63, 0x27, 0xda, 0x9a, 0x1f, 0x32, 0x23, 0x31, 0xb7, 0x37}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t willpropslist[] = {}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2, 0xd, 0xf9, 0x41, 0xfa, 0x3f, 0x23, 0xf, 0x8e, 0xe0, 0xcf, 0xcb, 0x43, 0x33, + 0xcb, 0x81, 0xe8, 0xee, 0xc, 0x3e, 0x43, 0x1a, 0x95, 0xdd, 0xc6, 0x5c, 0x31}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x75, 0x7d, 0x67, 0x2e, 0x86, 0xb6, 0x99}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 2013; + uint8_t client_id_bytes[] = {0xff, 0x1e, 0x54, 0x21, 0x3f, 0xa5, 0x40, 0x80, 0x2b, 0x59, 0x43, 0xb5, 0x2d, 0xfa, + 0xc1, 0xb7, 0xe9, 0x37, 0x1e, 0xc5, 0x78, 0x1a, 0x5b, 0x3f, 0xc, 0xe3, 0x74}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa7, 0xed, 0x9c, 0x4d, 0x71, 0xb0, 0x37, 0x46, 0x85, 0x3b, 0x70, 0x2, + 0xa4, 0xdb, 0x2c, 0xc4, 0x2c, 0x55, 0x0, 0xab, 0x17, 0x90, 0x4d}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x96, 0x27, 0x63, 0x9f, 0x3, 0x12, 0x90, 0xd4, 0x54, 0x59, 0xe6, 0x3a, + 0x1, 0x76, 0x63, 0x27, 0xda, 0x9a, 0x1f, 0x32, 0x23, 0x31, 0xb7, 0x37}; + lwmqtt_string_t password = {24, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Nothing, _password = Just "\182\240\189\t", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS2, _willTopic = "\187M\164\160l,v\190\218\204Q\220\172R\151\151>", _willMsg = +// "B\157i\190\132.u\233\158\DC3\242]\255\133\181\186\255Z\240\188\227", _willProps = []}), _cleanSession = False, +// _keepAlive = 1282, _connID = "(\191\136\201\182\228\133S\r\250\189X", _properties = []} +TEST(Connect311QCTest, Encode30) { + uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x14, 0x5, 0x2, 0x0, 0xc, + 0x28, 0xbf, 0x88, 0xc9, 0xb6, 0xe4, 0x85, 0x53, 0xd, 0xfa, 0xbd, 0x58, 0x0, 0x11, + 0xbb, 0x4d, 0xa4, 0xa0, 0x6c, 0x2c, 0x76, 0xbe, 0xda, 0xcc, 0x51, 0xdc, 0xac, 0x52, + 0x97, 0x97, 0x3e, 0x0, 0x15, 0x42, 0x9d, 0x69, 0xbe, 0x84, 0x2e, 0x75, 0xe9, 0x9e, + 0x13, 0xf2, 0x5d, 0xff, 0x85, 0xb5, 0xba, 0xff, 0x5a, 0xf0, 0xbc, 0xe3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// ConnectRequest {_username = Nothing, _password = Just "\138P\246\r\139dV\214\134\172RuyQ\235d\SI&A\169\ETX\151\187swD", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "Q\190\197\213\216\168{>!\220\238\251Zm\n\219\233\RSM\158\210\250\228\168", _willMsg = "e\227;s\172;", _willProps = []}), _cleanSession = True, _keepAlive = 10491, _connID = "", _properties = []} -TEST(Connect311QCTest, Encode28) { -uint8_t pkt[] = {0x10, 0x2e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x28, 0xfb, 0x0, 0x0, 0x0, 0x18, 0x51, 0xbe, 0xc5, 0xd5, 0xd8, 0xa8, 0x7b, 0x3e, 0x21, 0xdc, 0xee, 0xfb, 0x5a, 0x6d, 0xa, 0xdb, 0xe9, 0x1e, 0x4d, 0x9e, 0xd2, 0xfa, 0xe4, 0xa8, 0x0, 0x6, 0x65, 0xe3, 0x3b, 0x73, 0xac, 0x3b}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = { - }; + lwmqtt_will_t will = lwmqtt_default_will; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x51, 0xbe, 0xc5, 0xd5, 0xd8, 0xa8, 0x7b, 0x3e, 0x21, 0xdc, 0xee, 0xfb, 0x5a, 0x6d, 0xa, 0xdb, 0xe9, 0x1e, 0x4d, 0x9e, 0xd2, 0xfa, 0xe4, 0xa8}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x65, 0xe3, 0x3b, 0x73, 0xac, 0x3b}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 10491; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x8a, 0x50, 0xf6, 0xd, 0x8b, 0x64, 0x56, 0xd6, 0x86, 0xac, 0x52, 0x75, 0x79, 0x51, 0xeb, 0x64, 0xf, 0x26, 0x41, 0xa9, 0x3, 0x97, 0xbb, 0x73, 0x77, 0x44}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_property_t willpropslist[] = {}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xbb, 0x4d, 0xa4, 0xa0, 0x6c, 0x2c, 0x76, 0xbe, 0xda, + 0xcc, 0x51, 0xdc, 0xac, 0x52, 0x97, 0x97, 0x3e}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x42, 0x9d, 0x69, 0xbe, 0x84, 0x2e, 0x75, 0xe9, 0x9e, 0x13, 0xf2, + 0x5d, 0xff, 0x85, 0xb5, 0xba, 0xff, 0x5a, 0xf0, 0xbc, 0xe3}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 1282; + uint8_t client_id_bytes[] = {0x28, 0xbf, 0x88, 0xc9, 0xb6, 0xe4, 0x85, 0x53, 0xd, 0xfa, 0xbd, 0x58}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xb6, 0xf0, 0xbd, 0x9}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "su\219", _password = Just "\245\218", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS2, _willTopic = "\200\218\ENQ\194\150u=", _willMsg = "18\181\155\177B\144\135#\186\ESC", +// _willProps = [PropSessionExpiryInterval 16907,PropAssignedClientIdentifier +// "\164\251\183\146\189\248\f",PropUserProperty "\\\139\180" "\167",PropMessageExpiryInterval +// 20439,PropSharedSubscriptionAvailable 246,PropUserProperty +// "\DC1\128\246\210l\192\248BjzSY\197\NUL\157Hg^\156\132\139" "&H\FSo \156'\216!",PropResponseInformation +// "\165\203\195\162I\140\153\179\147\&3\DC2\242\178L9\177UI\130U\147\RS\234%\231",PropPayloadFormatIndicator +// 212,PropUserProperty "GM\163\t\158T\226\SYN\243\160\235a\176" "`",PropContentType +// "\134\160\vZT\ACK\149\220`",PropSessionExpiryInterval 4579,PropTopicAliasMaximum 22244,PropServerKeepAlive +// 14992,PropMaximumQoS 181,PropServerReference +// "\247\231\181\b\148\177\DEL\240\196\157v?e\f\243\STX\DC2\173\205\205D\152P\239\135 0o",PropAuthenticationMethod +// "3\ETB\218\156/y\239S\RS8\232@m\221|)\200\&7\SI\">:6\185z^\174\220\237n",PropSubscriptionIdentifier +// 27,PropSubscriptionIdentifierAvailable 58,PropMessageExpiryInterval 15968,PropSubscriptionIdentifierAvailable +// 192,PropRetainAvailable 143]}), _cleanSession = True, _keepAlive = 23341, _connID = +// "\167\130W\226#\FSJ:\239#\154)\178i", _properties = [PropAuthenticationData +// "\157\176%_\142\166jk\138\199\158\226\b\197\181J\142\196\218",PropSubscriptionIdentifierAvailable +// 241,PropTopicAliasMaximum 30873,PropSessionExpiryInterval 8383,PropServerKeepAlive 20280,PropResponseTopic +// "\164\FSf?\227\250d\224",PropAuthenticationData +// "\222\STX\SI\169\158\193\143\207\141",PropSubscriptionIdentifierAvailable 189,PropAssignedClientIdentifier +// "",PropCorrelationData "6\140\253\228\176L\DC4K\181M1\179^\"\157do\250",PropTopicAlias 2954,PropTopicAlias +// 9070,PropWildcardSubscriptionAvailable 163,PropRequestProblemInformation 192,PropReasonString +// "KN\219Q\US\SOH\202h\213\NUL\a\166JF\231\ESC\250\249\136\203\SYN\a\249\DLE\242",PropMessageExpiryInterval +// 5860,PropRequestResponseInformation 76,PropSharedSubscriptionAvailable 184]} +TEST(Connect5QCTest, Encode1) { + uint8_t pkt[] = { + 0x10, 0x99, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x5b, 0x2d, 0x83, 0x1, 0x16, 0x0, 0x13, 0x9d, + 0xb0, 0x25, 0x5f, 0x8e, 0xa6, 0x6a, 0x6b, 0x8a, 0xc7, 0x9e, 0xe2, 0x8, 0xc5, 0xb5, 0x4a, 0x8e, 0xc4, 0xda, 0x29, + 0xf1, 0x22, 0x78, 0x99, 0x11, 0x0, 0x0, 0x20, 0xbf, 0x13, 0x4f, 0x38, 0x8, 0x0, 0x8, 0xa4, 0x1c, 0x66, 0x3f, + 0xe3, 0xfa, 0x64, 0xe0, 0x16, 0x0, 0x9, 0xde, 0x2, 0xf, 0xa9, 0x9e, 0xc1, 0x8f, 0xcf, 0x8d, 0x29, 0xbd, 0x12, + 0x0, 0x0, 0x9, 0x0, 0x12, 0x36, 0x8c, 0xfd, 0xe4, 0xb0, 0x4c, 0x14, 0x4b, 0xb5, 0x4d, 0x31, 0xb3, 0x5e, 0x22, + 0x9d, 0x64, 0x6f, 0xfa, 0x23, 0xb, 0x8a, 0x23, 0x23, 0x6e, 0x28, 0xa3, 0x17, 0xc0, 0x1f, 0x0, 0x19, 0x4b, 0x4e, + 0xdb, 0x51, 0x1f, 0x1, 0xca, 0x68, 0xd5, 0x0, 0x7, 0xa6, 0x4a, 0x46, 0xe7, 0x1b, 0xfa, 0xf9, 0x88, 0xcb, 0x16, + 0x7, 0xf9, 0x10, 0xf2, 0x2, 0x0, 0x0, 0x16, 0xe4, 0x19, 0x4c, 0x2a, 0xb8, 0x0, 0xe, 0xa7, 0x82, 0x57, 0xe2, + 0x23, 0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xda, 0x9c, + 0x2f, 0x79, 0xef, 0x53, 0x1e, 0x38, 0xe8, 0x40, 0x6d, 0xdd, 0x7c, 0x29, 0xc8, 0x37, 0xf, 0x22, 0x3e, 0x3a, 0x36, + 0xb9, 0x7a, 0x5e, 0xae, 0xdc, 0xed, 0x6e, 0xb, 0x1b, 0x29, 0x3a, 0x2, 0x0, 0x0, 0x3e, 0x60, 0x29, 0xc0, 0x25, + 0x8f, 0x0, 0x7, 0xc8, 0xda, 0x5, 0xc2, 0x96, 0x75, 0x3d, 0x0, 0xb, 0x31, 0x38, 0xb5, 0x9b, 0xb1, 0x42, 0x90, + 0x87, 0x23, 0xba, 0x1b, 0x0, 0x3, 0x73, 0x75, 0xdb, 0x0, 0x2, 0xf5, 0xda}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x9d, 0xb0, 0x25, 0x5f, 0x8e, 0xa6, 0x6a, 0x6b, 0x8a, 0xc7, + 0x9e, 0xe2, 0x8, 0xc5, 0xb5, 0x4a, 0x8e, 0xc4, 0xda}; + uint8_t bytesprops1[] = {0xa4, 0x1c, 0x66, 0x3f, 0xe3, 0xfa, 0x64, 0xe0}; + uint8_t bytesprops2[] = {0xde, 0x2, 0xf, 0xa9, 0x9e, 0xc1, 0x8f, 0xcf, 0x8d}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x36, 0x8c, 0xfd, 0xe4, 0xb0, 0x4c, 0x14, 0x4b, 0xb5, + 0x4d, 0x31, 0xb3, 0x5e, 0x22, 0x9d, 0x64, 0x6f, 0xfa}; + uint8_t bytesprops5[] = {0x4b, 0x4e, 0xdb, 0x51, 0x1f, 0x1, 0xca, 0x68, 0xd5, 0x0, 0x7, 0xa6, 0x4a, + 0x46, 0xe7, 0x1b, 0xfa, 0xf9, 0x88, 0xcb, 0x16, 0x7, 0xf9, 0x10, 0xf2}; -// ConnectRequest {_username = Just "\136\ETX\185\158{\133u\SUB]M\158\149j", _password = Just "\236\211\185\RS\166i\ENQ\145\208h\157\v\ESC!", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\224\ESC\"\DLEM\r\165\238\&9\230\141", _willMsg = "C\129\147\222\&7Q.1.", _willProps = []}), _cleanSession = True, _keepAlive = 12875, _connID = "j", _properties = []} -TEST(Connect311QCTest, Encode29) { -uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x32, 0x4b, 0x0, 0x1, 0x6a, 0x0, 0xb, 0xe0, 0x1b, 0x22, 0x10, 0x4d, 0xd, 0xa5, 0xee, 0x39, 0xe6, 0x8d, 0x0, 0x9, 0x43, 0x81, 0x93, 0xde, 0x37, 0x51, 0x2e, 0x31, 0x2e, 0x0, 0xd, 0x88, 0x3, 0xb9, 0x9e, 0x7b, 0x85, 0x75, 0x1a, 0x5d, 0x4d, 0x9e, 0x95, 0x6a, 0x0, 0xe, 0xec, 0xd3, 0xb9, 0x1e, 0xa6, 0x69, 0x5, 0x91, 0xd0, 0x68, 0x9d, 0xb, 0x1b, 0x21}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30873}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8383}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20280}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2954}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9070}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5860}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 184}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xa4, 0xfb, 0xb7, 0x92, 0xbd, 0xf8, 0xc}; + uint8_t byteswillprops2[] = {0xa7}; + uint8_t byteswillprops1[] = {0x5c, 0x8b, 0xb4}; + uint8_t byteswillprops4[] = {0x26, 0x48, 0x1c, 0x6f, 0x20, 0x9c, 0x27, 0xd8, 0x21}; + uint8_t byteswillprops3[] = {0x11, 0x80, 0xf6, 0xd2, 0x6c, 0xc0, 0xf8, 0x42, 0x6a, 0x7a, 0x53, + 0x59, 0xc5, 0x0, 0x9d, 0x48, 0x67, 0x5e, 0x9c, 0x84, 0x8b}; + uint8_t byteswillprops5[] = {0xa5, 0xcb, 0xc3, 0xa2, 0x49, 0x8c, 0x99, 0xb3, 0x93, 0x33, 0x12, 0xf2, 0xb2, + 0x4c, 0x39, 0xb1, 0x55, 0x49, 0x82, 0x55, 0x93, 0x1e, 0xea, 0x25, 0xe7}; + uint8_t byteswillprops7[] = {0x60}; + uint8_t byteswillprops6[] = {0x47, 0x4d, 0xa3, 0x9, 0x9e, 0x54, 0xe2, 0x16, 0xf3, 0xa0, 0xeb, 0x61, 0xb0}; + uint8_t byteswillprops8[] = {0x86, 0xa0, 0xb, 0x5a, 0x54, 0x6, 0x95, 0xdc, 0x60}; + uint8_t byteswillprops9[] = {0xf7, 0xe7, 0xb5, 0x8, 0x94, 0xb1, 0x7f, 0xf0, 0xc4, 0x9d, 0x76, 0x3f, 0x65, 0xc, + 0xf3, 0x2, 0x12, 0xad, 0xcd, 0xcd, 0x44, 0x98, 0x50, 0xef, 0x87, 0x20, 0x30, 0x6f}; + uint8_t byteswillprops10[] = {0x33, 0x17, 0xda, 0x9c, 0x2f, 0x79, 0xef, 0x53, 0x1e, 0x38, + 0xe8, 0x40, 0x6d, 0xdd, 0x7c, 0x29, 0xc8, 0x37, 0xf, 0x22, + 0x3e, 0x3a, 0x36, 0xb9, 0x7a, 0x5e, 0xae, 0xdc, 0xed, 0x6e}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16907}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {3, (char*)&byteswillprops1}, .v = {1, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20439}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {21, (char*)&byteswillprops3}, .v = {9, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {13, (char*)&byteswillprops6}, .v = {1, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4579}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22244}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14992}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15968}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 143}}, }; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe0, 0x1b, 0x22, 0x10, 0x4d, 0xd, 0xa5, 0xee, 0x39, 0xe6, 0x8d}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x43, 0x81, 0x93, 0xde, 0x37, 0x51, 0x2e, 0x31, 0x2e}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 12875; - uint8_t client_id_bytes[] = {0x6a}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x88, 0x3, 0xb9, 0x9e, 0x7b, 0x85, 0x75, 0x1a, 0x5d, 0x4d, 0x9e, 0x95, 0x6a}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0xec, 0xd3, 0xb9, 0x1e, 0xa6, 0x69, 0x5, 0x91, 0xd0, 0x68, 0x9d, 0xb, 0x1b, 0x21}; - lwmqtt_string_t password = {14, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc8, 0xda, 0x5, 0xc2, 0x96, 0x75, 0x3d}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x31, 0x38, 0xb5, 0x9b, 0xb1, 0x42, 0x90, 0x87, 0x23, 0xba, 0x1b}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23341; + uint8_t client_id_bytes[] = {0xa7, 0x82, 0x57, 0xe2, 0x23, 0x1c, 0x4a, 0x3a, 0xef, 0x23, 0x9a, 0x29, 0xb2, 0x69}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x73, 0x75, 0xdb}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf5, 0xda}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "P\166UwM\219C\247)G\246N\221{\180_\252\165e\v\208q\130c\RS\211C<", _password = Just +// "\130\CAN3\224\145\232]\239\145\186\165\178v\169N=\a+\t -", _lastWill = Just (LastWill {_willRetain = True, _willQoS +// = QoS0, _willTopic = "\\\179", _willMsg = "\165\154\226\EOTH\244,\148\217\b|", _willProps = [PropResponseInformation +// "\205P3r\166<\147\167\NULn\165\251\136"]}), _cleanSession = False, _keepAlive = 18048, _connID = +// "J\190\236\SO\209A\240R\155\STX:\190\166-\217C\169\EM\134\160\170\226\251I\v\238\&6\208\149", _properties = +// [PropResponseTopic "c\255^XR\248\&9 \183\213\251\&8W\FSr\\fJ\186\145q]\DEL\211sK\196\STX",PropMessageExpiryInterval +// 5918,PropRetainAvailable 159,PropUserProperty "\DC3\219\232\138\178\245\178\169\DC3" +// "\GS\188\&9\151\191M\236|\162",PropServerReference "\199,s\205\185yN8\170\132\144\138",PropReceiveMaximum +// 23323,PropAuthenticationData "v_\138\&4F E\219\SO\210d\213\138\166o\133t<\179\153\158",PropUserProperty +// "\CAN\194\CAN\191\171f;\a\238\222}\211\133\170>\DC2\212\DC3*\159\140\231\201\231V\DEL\158\206R\NUL" "f\229\a\160"]} +TEST(Connect5QCTest, Encode2) { + uint8_t pkt[] = { + 0x10, 0x90, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x46, 0x80, 0x8e, 0x1, 0x8, 0x0, 0x1c, 0x63, + 0xff, 0x5e, 0x58, 0x52, 0xf8, 0x39, 0x20, 0xb7, 0xd5, 0xfb, 0x38, 0x57, 0x1c, 0x72, 0x5c, 0x66, 0x4a, 0xba, 0x91, + 0x71, 0x5d, 0x7f, 0xd3, 0x73, 0x4b, 0xc4, 0x2, 0x2, 0x0, 0x0, 0x17, 0x1e, 0x25, 0x9f, 0x26, 0x0, 0x9, 0x13, + 0xdb, 0xe8, 0x8a, 0xb2, 0xf5, 0xb2, 0xa9, 0x13, 0x0, 0x9, 0x1d, 0xbc, 0x39, 0x97, 0xbf, 0x4d, 0xec, 0x7c, 0xa2, + 0x1c, 0x0, 0xc, 0xc7, 0x2c, 0x73, 0xcd, 0xb9, 0x79, 0x4e, 0x38, 0xaa, 0x84, 0x90, 0x8a, 0x21, 0x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[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x63, 0xff, 0x5e, 0x58, 0x52, 0xf8, 0x39, 0x20, 0xb7, 0xd5, 0xfb, 0x38, 0x57, 0x1c, + 0x72, 0x5c, 0x66, 0x4a, 0xba, 0x91, 0x71, 0x5d, 0x7f, 0xd3, 0x73, 0x4b, 0xc4, 0x2}; + uint8_t bytesprops2[] = {0x1d, 0xbc, 0x39, 0x97, 0xbf, 0x4d, 0xec, 0x7c, 0xa2}; + uint8_t bytesprops1[] = {0x13, 0xdb, 0xe8, 0x8a, 0xb2, 0xf5, 0xb2, 0xa9, 0x13}; + uint8_t bytesprops3[] = {0xc7, 0x2c, 0x73, 0xcd, 0xb9, 0x79, 0x4e, 0x38, 0xaa, 0x84, 0x90, 0x8a}; + uint8_t bytesprops4[] = {0x76, 0x5f, 0x8a, 0x34, 0x46, 0x20, 0x45, 0xdb, 0xe, 0xd2, 0x64, + 0xd5, 0x8a, 0xa6, 0x6f, 0x85, 0x74, 0x3c, 0xb3, 0x99, 0x9e}; + uint8_t bytesprops6[] = {0x66, 0xe5, 0x7, 0xa0}; + uint8_t bytesprops5[] = {0x18, 0xc2, 0x18, 0xbf, 0xab, 0x66, 0x3b, 0x7, 0xee, 0xde, 0x7d, 0xd3, 0x85, 0xaa, 0x3e, + 0x12, 0xd4, 0x13, 0x2a, 0x9f, 0x8c, 0xe7, 0xc9, 0xe7, 0x56, 0x7f, 0x9e, 0xce, 0x52, 0x0}; -// ConnectRequest {_username = Just "\CAN`l\229\237\255", _password = Just "\192o\213\179\182\245\198(\236\EOT\NAK/", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\246\227\176\175_4\EOT{\143\204\150", _willMsg = "\209\190U\246\210\133\207\145\&9\229", _willProps = []}), _cleanSession = True, _keepAlive = 67, _connID = "\246Q\170N+\132\254\213*\162\243\n", _properties = []} -TEST(Connect311QCTest, Encode30) { -uint8_t pkt[] = {0x10, 0x47, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x0, 0x43, 0x0, 0xc, 0xf6, 0x51, 0xaa, 0x4e, 0x2b, 0x84, 0xfe, 0xd5, 0x2a, 0xa2, 0xf3, 0xa, 0x0, 0xb, 0xf6, 0xe3, 0xb0, 0xaf, 0x5f, 0x34, 0x4, 0x7b, 0x8f, 0xcc, 0x96, 0x0, 0xa, 0xd1, 0xbe, 0x55, 0xf6, 0xd2, 0x85, 0xcf, 0x91, 0x39, 0xe5, 0x0, 0x6, 0x18, 0x60, 0x6c, 0xe5, 0xed, 0xff, 0x0, 0xc, 0xc0, 0x6f, 0xd5, 0xb3, 0xb6, 0xf5, 0xc6, 0x28, 0xec, 0x4, 0x15, 0x2f}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5918}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops1}, .v = {9, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23323}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops5}, .v = {4, (char*)&bytesprops6}}}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xcd, 0x50, 0x33, 0x72, 0xa6, 0x3c, 0x93, 0xa7, 0x0, 0x6e, 0xa5, 0xfb, 0x88}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops0}}}, }; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf6, 0xe3, 0xb0, 0xaf, 0x5f, 0x34, 0x4, 0x7b, 0x8f, 0xcc, 0x96}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd1, 0xbe, 0x55, 0xf6, 0xd2, 0x85, 0xcf, 0x91, 0x39, 0xe5}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 67; - uint8_t client_id_bytes[] = {0xf6, 0x51, 0xaa, 0x4e, 0x2b, 0x84, 0xfe, 0xd5, 0x2a, 0xa2, 0xf3, 0xa}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x18, 0x60, 0x6c, 0xe5, 0xed, 0xff}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0xc0, 0x6f, 0xd5, 0xb3, 0xb6, 0xf5, 0xc6, 0x28, 0xec, 0x4, 0x15, 0x2f}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x5c, 0xb3}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa5, 0x9a, 0xe2, 0x4, 0x48, 0xf4, 0x2c, 0x94, 0xd9, 0x8, 0x7c}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 18048; + uint8_t client_id_bytes[] = {0x4a, 0xbe, 0xec, 0xe, 0xd1, 0x41, 0xf0, 0x52, 0x9b, 0x2, 0x3a, 0xbe, 0xa6, 0x2d, 0xd9, + 0x43, 0xa9, 0x19, 0x86, 0xa0, 0xaa, 0xe2, 0xfb, 0x49, 0xb, 0xee, 0x36, 0xd0, 0x95}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x50, 0xa6, 0x55, 0x77, 0x4d, 0xdb, 0x43, 0xf7, 0x29, 0x47, 0xf6, 0x4e, 0xdd, 0x7b, + 0xb4, 0x5f, 0xfc, 0xa5, 0x65, 0xb, 0xd0, 0x71, 0x82, 0x63, 0x1e, 0xd3, 0x43, 0x3c}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x82, 0x18, 0x33, 0xe0, 0x91, 0xe8, 0x5d, 0xef, 0x91, 0xba, 0xa5, + 0xb2, 0x76, 0xa9, 0x4e, 0x3d, 0x7, 0x2b, 0x9, 0x20, 0x2d}; + lwmqtt_string_t password = {21, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "2\SYN9\139\255u\201\DEL\234\DEL\164@W\249\SUB\225B\154\170*\\H\246:b\164", +// _password = Just "+ZTUH\240]\158$\252\179\130\182\154hK", _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\248\227\198;\219P\186\DC1\SO\130\166<\193j\180\&3\199\231BD@\235", _willMsg = "\231", _willProps +// = [PropResponseInformation "\188",PropMaximumQoS 180,PropPayloadFormatIndicator 242,PropRequestResponseInformation +// 85,PropUserProperty "p\151\153Fo\162\&4\DC2\140\236\179\186\248Q\247\200\228F?\135Z" +// "\DEL\134\&2\190]\200A(6B",PropAssignedClientIdentifier +// "i0\232\188\215\215Q\168\f\184\146\208\147M\165`\223\254\183\245\ESC=\135\151\228\SOH\173",PropSubscriptionIdentifierAvailable +// 175,PropMessageExpiryInterval 31995,PropSubscriptionIdentifier 4,PropSharedSubscriptionAvailable 43]}), _cleanSession +// = True, _keepAlive = 16330, _connID = "\v\176\184\NULR", _properties = [PropSubscriptionIdentifier +// 8,PropRetainAvailable 107,PropSubscriptionIdentifierAvailable 148,PropResponseInformation +// ")\ESC\231\233\US\140\254\254Q[\180\DC3\STX[\136\191O]\161\208=\207\222Ar\NUL\235w",PropRetainAvailable +// 4,PropMessageExpiryInterval 7551,PropReasonString "Q\177\223\156\161%\220",PropRetainAvailable 208]} +TEST(Connect5QCTest, Encode3) { + uint8_t pkt[] = { + 0x10, 0xeb, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x3f, 0xca, 0x38, 0xb, 0x8, 0x25, 0x6b, 0x29, + 0x94, 0x1a, 0x0, 0x1c, 0x29, 0x1b, 0xe7, 0xe9, 0x1f, 0x8c, 0xfe, 0xfe, 0x51, 0x5b, 0xb4, 0x13, 0x2, 0x5b, 0x88, + 0xbf, 0x4f, 0x5d, 0xa1, 0xd0, 0x3d, 0xcf, 0xde, 0x41, 0x72, 0x0, 0xeb, 0x77, 0x25, 0x4, 0x2, 0x0, 0x0, 0x1d, + 0x7f, 0x1f, 0x0, 0x7, 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{0x29, 0x1b, 0xe7, 0xe9, 0x1f, 0x8c, 0xfe, 0xfe, 0x51, 0x5b, 0xb4, 0x13, 0x2, 0x5b, + 0x88, 0xbf, 0x4f, 0x5d, 0xa1, 0xd0, 0x3d, 0xcf, 0xde, 0x41, 0x72, 0x0, 0xeb, 0x77}; + uint8_t bytesprops1[] = {0x51, 0xb1, 0xdf, 0x9c, 0xa1, 0x25, 0xdc}; -// ConnectRequest {_username = Nothing, _password = Just "<\200\232q\179c\222\168\a\186M\US\251I\210\222w\195H8\NUL\242!X\199s\219\245\165i", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "e\166s3\SOH\158_\232u5y\249\184aJ\194\246\220\226\184\209\223\EM", _willMsg = "_\245\131\131I\205\b\225\ETB\152\SO\152\&0\ENQ\145<\158\t4:\135", _willProps = [PropTopicAliasMaximum 7039,PropSubscriptionIdentifierAvailable 245,PropAuthenticationData "KG\228\255L\167F",PropSubscriptionIdentifierAvailable 22,PropServerReference ".\206C\196\172 \EOT\159(\176\165Q",PropServerReference "f\DLEQ\253\131{d2\133[\199\nI\218\244\FS\191\202\&2\163\199\222\STX",PropRequestProblemInformation 23,PropWillDelayInterval 29502,PropSubscriptionIdentifier 10,PropWildcardSubscriptionAvailable 198,PropPayloadFormatIndicator 55,PropRequestResponseInformation 58,PropCorrelationData "yj4\159\SYN\184\133[\183p\173\DC2\205\US\241\224z\252\EOT\182\200\RS3",PropTopicAlias 31480,PropSubscriptionIdentifier 21,PropContentType "\232(\167f\165\"\ETB\151\CAN\172",PropMaximumPacketSize 18233,PropServerKeepAlive 27264,PropAuthenticationData "\168\CAN\190%\218\174p!\248\233\DC2\v\235\182\166s\ENQQ\143m\253\221\232",PropTopicAliasMaximum 11399,PropMaximumQoS 81,PropRequestProblemInformation 184,PropResponseInformation "\248.\192<\SYNJ 2\DC4\246+\166\FSah\DC1&j\SOHY\198\162\215",PropUserProperty "\182\236d\169o]" "O\250",PropServerKeepAlive 30187,PropSubscriptionIdentifier 32,PropMessageExpiryInterval 30375,PropSubscriptionIdentifierAvailable 114]}), _cleanSession = False, _keepAlive = 14400, _connID = "\NAK\178o-", _properties = [PropRequestProblemInformation 183]} -TEST(Connect5QCTest, Encode1) { -uint8_t pkt[] = {0x10, 0xb6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6c, 0x38, 0x40, 0x2, 0x17, 0xb7, 0x0, 0x4, 0x15, 0xb2, 0x6f, 0x2d, 0xd1, 0x1, 0x22, 0x1b, 0x7f, 0x29, 0xf5, 0x16, 0x0, 0x7, 0x4b, 0x47, 0xe4, 0xff, 0x4c, 0xa7, 0x46, 0x29, 0x16, 0x1c, 0x0, 0xc, 0x2e, 0xce, 0x43, 0xc4, 0xac, 0x20, 0x4, 0x9f, 0x28, 0xb0, 0xa5, 0x51, 0x1c, 0x0, 0x17, 0x66, 0x10, 0x51, 0xfd, 0x83, 0x7b, 0x64, 0x32, 0x85, 0x5b, 0xc7, 0xa, 0x49, 0xda, 0xf4, 0x1c, 0xbf, 0xca, 0x32, 0xa3, 0xc7, 0xde, 0x2, 0x17, 0x17, 0x18, 0x0, 0x0, 0x73, 0x3e, 0xb, 0xa, 0x28, 0xc6, 0x1, 0x37, 0x19, 0x3a, 0x9, 0x0, 0x17, 0x79, 0x6a, 0x34, 0x9f, 0x16, 0xb8, 0x85, 0x5b, 0xb7, 0x70, 0xad, 0x12, 0xcd, 0x1f, 0xf1, 0xe0, 0x7a, 0xfc, 0x4, 0xb6, 0xc8, 0x1e, 0x33, 0x23, 0x7a, 0xf8, 0xb, 0x15, 0x3, 0x0, 0xa, 0xe8, 0x28, 0xa7, 0x66, 0xa5, 0x22, 0x17, 0x97, 0x18, 0xac, 0x27, 0x0, 0x0, 0x47, 0x39, 0x13, 0x6a, 0x80, 0x16, 0x0, 0x17, 0xa8, 0x18, 0xbe, 0x25, 0xda, 0xae, 0x70, 0x21, 0xf8, 0xe9, 0x12, 0xb, 0xeb, 0xb6, 0xa6, 0x73, 0x5, 0x51, 0x8f, 0x6d, 0xfd, 0xdd, 0xe8, 0x22, 0x2c, 0x87, 0x24, 0x51, 0x17, 0xb8, 0x1a, 0x0, 0x17, 0xf8, 0x2e, 0xc0, 0x3c, 0x16, 0x4a, 0x20, 0x32, 0x14, 0xf6, 0x2b, 0xa6, 0x1c, 0x61, 0x68, 0x11, 0x26, 0x6a, 0x1, 0x59, 0xc6, 0xa2, 0xd7, 0x26, 0x0, 0x6, 0xb6, 0xec, 0x64, 0xa9, 0x6f, 0x5d, 0x0, 0x2, 0x4f, 0xfa, 0x13, 0x75, 0xeb, 0xb, 0x20, 0x2, 0x0, 0x0, 0x76, 0xa7, 0x29, 0x72, 0x0, 0x17, 0x65, 0xa6, 0x73, 0x33, 0x1, 0x9e, 0x5f, 0xe8, 0x75, 0x35, 0x79, 0xf9, 0xb8, 0x61, 0x4a, 0xc2, 0xf6, 0xdc, 0xe2, 0xb8, 0xd1, 0xdf, 0x19, 0x0, 0x15, 0x5f, 0xf5, 0x83, 0x83, 0x49, 0xcd, 0x8, 0xe1, 0x17, 0x98, 0xe, 0x98, 0x30, 0x5, 0x91, 0x3c, 0x9e, 0x9, 0x34, 0x3a, 0x87, 0x0, 0x1e, 0x3c, 0xc8, 0xe8, 0x71, 0xb3, 0x63, 0xde, 0xa8, 0x7, 0xba, 0x4d, 0x1f, 0xfb, 0x49, 0xd2, 0xde, 0x77, 0xc3, 0x48, 0x38, 0x0, 0xf2, 0x21, 0x58, 0xc7, 0x73, 0xdb, 0xf5, 0xa5, 0x69}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7551}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 208}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x4b, 0x47, 0xe4, 0xff, 0x4c, 0xa7, 0x46}; - uint8_t byteswillprops1[] = {0x2e, 0xce, 0x43, 0xc4, 0xac, 0x20, 0x4, 0x9f, 0x28, 0xb0, 0xa5, 0x51}; - uint8_t byteswillprops2[] = {0x66, 0x10, 0x51, 0xfd, 0x83, 0x7b, 0x64, 0x32, 0x85, 0x5b, 0xc7, 0xa, 0x49, 0xda, 0xf4, 0x1c, 0xbf, 0xca, 0x32, 0xa3, 0xc7, 0xde, 0x2}; - uint8_t byteswillprops3[] = {0x79, 0x6a, 0x34, 0x9f, 0x16, 0xb8, 0x85, 0x5b, 0xb7, 0x70, 0xad, 0x12, 0xcd, 0x1f, 0xf1, 0xe0, 0x7a, 0xfc, 0x4, 0xb6, 0xc8, 0x1e, 0x33}; - uint8_t byteswillprops4[] = {0xe8, 0x28, 0xa7, 0x66, 0xa5, 0x22, 0x17, 0x97, 0x18, 0xac}; - uint8_t byteswillprops5[] = {0xa8, 0x18, 0xbe, 0x25, 0xda, 0xae, 0x70, 0x21, 0xf8, 0xe9, 0x12, 0xb, 0xeb, 0xb6, 0xa6, 0x73, 0x5, 0x51, 0x8f, 0x6d, 0xfd, 0xdd, 0xe8}; - uint8_t byteswillprops6[] = {0xf8, 0x2e, 0xc0, 0x3c, 0x16, 0x4a, 0x20, 0x32, 0x14, 0xf6, 0x2b, 0xa6, 0x1c, 0x61, 0x68, 0x11, 0x26, 0x6a, 0x1, 0x59, 0xc6, 0xa2, 0xd7}; - uint8_t byteswillprops8[] = {0x4f, 0xfa}; - uint8_t byteswillprops7[] = {0xb6, 0xec, 0x64, 0xa9, 0x6f, 0x5d}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7039}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29502}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31480}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18233}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27264}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11399}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={6, (char*)&byteswillprops7}, .v={2, (char*)&byteswillprops8}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30187}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 32}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30375}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 114}}, - }; - - lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x65, 0xa6, 0x73, 0x33, 0x1, 0x9e, 0x5f, 0xe8, 0x75, 0x35, 0x79, 0xf9, 0xb8, 0x61, 0x4a, 0xc2, 0xf6, 0xdc, 0xe2, 0xb8, 0xd1, 0xdf, 0x19}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5f, 0xf5, 0x83, 0x83, 0x49, 0xcd, 0x8, 0xe1, 0x17, 0x98, 0xe, 0x98, 0x30, 0x5, 0x91, 0x3c, 0x9e, 0x9, 0x34, 0x3a, 0x87}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 14400; - uint8_t client_id_bytes[] = {0x15, 0xb2, 0x6f, 0x2d}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x3c, 0xc8, 0xe8, 0x71, 0xb3, 0x63, 0xde, 0xa8, 0x7, 0xba, 0x4d, 0x1f, 0xfb, 0x49, 0xd2, 0xde, 0x77, 0xc3, 0x48, 0x38, 0x0, 0xf2, 0x21, 0x58, 0xc7, 0x73, 0xdb, 0xf5, 0xa5, 0x69}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xbc}; + uint8_t byteswillprops2[] = {0x7f, 0x86, 0x32, 0xbe, 0x5d, 0xc8, 0x41, 0x28, 0x36, 0x42}; + uint8_t byteswillprops1[] = {0x70, 0x97, 0x99, 0x46, 0x6f, 0xa2, 0x34, 0x12, 0x8c, 0xec, 0xb3, + 0xba, 0xf8, 0x51, 0xf7, 0xc8, 0xe4, 0x46, 0x3f, 0x87, 0x5a}; + uint8_t byteswillprops3[] = {0x69, 0x30, 0xe8, 0xbc, 0xd7, 0xd7, 0x51, 0xa8, 0xc, 0xb8, 0x92, 0xd0, 0x93, 0x4d, + 0xa5, 0x60, 0xdf, 0xfe, 0xb7, 0xf5, 0x1b, 0x3d, 0x87, 0x97, 0xe4, 0x1, 0xad}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {21, (char*)&byteswillprops1}, .v = {10, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31995}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 43}}, + }; + + lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf8, 0xe3, 0xc6, 0x3b, 0xdb, 0x50, 0xba, 0x11, 0xe, 0x82, 0xa6, + 0x3c, 0xc1, 0x6a, 0xb4, 0x33, 0xc7, 0xe7, 0x42, 0x44, 0x40, 0xeb}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe7}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 16330; + uint8_t client_id_bytes[] = {0xb, 0xb0, 0xb8, 0x0, 0x52}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x32, 0x16, 0x39, 0x8b, 0xff, 0x75, 0xc9, 0x7f, 0xea, 0x7f, 0xa4, 0x40, 0x57, + 0xf9, 0x1a, 0xe1, 0x42, 0x9a, 0xaa, 0x2a, 0x5c, 0x48, 0xf6, 0x3a, 0x62, 0xa4}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x2b, 0x5a, 0x54, 0x55, 0x48, 0xf0, 0x5d, 0x9e, + 0x24, 0xfc, 0xb3, 0x82, 0xb6, 0x9a, 0x68, 0x4b}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "\SOH\222\148y4W7\221\234\219\249G\176i\153\&7C\174\DC3\201\168", _password = +// Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\182\DC2\202\175'\175", +// _willMsg = "FT\180\227 ,\DLEhU\147g\249\210sn\150=>P\234h4\234\150\&6T\137\149\192\216", _willProps = +// [PropWildcardSubscriptionAvailable 106,PropRetainAvailable 244,PropRequestProblemInformation +// 51,PropSharedSubscriptionAvailable 219,PropMaximumQoS 11,PropSubscriptionIdentifier 16,PropSubscriptionIdentifier +// 26,PropCorrelationData "\r\243~\154\NUL\248\252y)\252\144\214\SOH\249\186\&1",PropSubscriptionIdentifierAvailable +// 202,PropMaximumPacketSize 19589,PropResponseInformation +// "\173\208\ACK\n\200\251\198<=\DC2\246b\207\211\216\165.",PropServerReference "\ENQ",PropWillDelayInterval +// 25985,PropSharedSubscriptionAvailable 114,PropResponseInformation "7\246\&2",PropMessageExpiryInterval +// 909,PropServerKeepAlive 24831,PropSubscriptionIdentifier 8,PropUserProperty "G\130\229" +// "\241z\186g\224\158R\130C\246\140\ENQ^s/\236\199\ENQU\GSl\US\r`\246",PropPayloadFormatIndicator +// 231,PropWillDelayInterval 29690,PropRequestResponseInformation 152,PropAssignedClientIdentifier +// "Y\253\201\&1\226\&0\250Ql\188\153\224C\231\DC4\225\229\238I>\141]\184e\236\201\165",PropTopicAlias +// 132,PropReceiveMaximum 7672,PropReasonString "#\nH\t\192\223\223>R\179q\144\ETB",PropSharedSubscriptionAvailable +// 4,PropMaximumPacketSize 4671,PropTopicAlias 22943,PropMessageExpiryInterval 29025]}), _cleanSession = True, +// _keepAlive = 30046, _connID = "A'\216\131\251\208\218\DC4\152\230\198\239\a", _properties = +// [PropMessageExpiryInterval 23903,PropSubscriptionIdentifier 0,PropUserProperty "v\235" +// "\b4\NAK\ACK,\141\US\230T\228[\EOT0vu\ENQ?",PropServerReference +// "\216TZ\165/>\146\146\160\237)\208o\EOT\234",PropServerReference ";\173U1|\DLE\197M\147\241\178Y +// Q[\STX\243R\233\150o\172zb\130",PropPayloadFormatIndicator 196,PropCorrelationData +// "\234\DC1\243\ESC\233\vH\202",PropRequestResponseInformation 37,PropContentType ""]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dd, 0xea, 0xdb, 0xf9, 0x47, 0xb0, 0x69, 0x99, 0x37, + 0x43, 0xae, 0x13, 0xc9, 0xa8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x8, 0x34, 0x15, 0x6, 0x2c, 0x8d, 0x1f, 0xe6, 0x54, + 0xe4, 0x5b, 0x4, 0x30, 0x76, 0x75, 0x5, 0x3f}; + uint8_t bytesprops0[] = {0x76, 0xeb}; + uint8_t bytesprops2[] = {0xd8, 0x54, 0x5a, 0xa5, 0x2f, 0x3e, 0x92, 0x92, 0xa0, 0xed, 0x29, 0xd0, 0x6f, 0x4, 0xea}; + uint8_t bytesprops3[] = {0x3b, 0xad, 0x55, 0x31, 0x7c, 0x10, 0xc5, 0x4d, 0x93, 0xf1, 0xb2, 0x59, 0x20, + 0x51, 0x5b, 0x2, 0xf3, 0x52, 0xe9, 0x96, 0x6f, 0xac, 0x7a, 0x62, 0x82}; + uint8_t bytesprops4[] = {0xea, 0x11, 0xf3, 0x1b, 0xe9, 0xb, 0x48, 0xca}; + uint8_t bytesprops5[] = {0}; -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\157\&7\160\&4!<\152o", _willMsg = "\207\206*\r\196x\199J", _willProps = [PropReasonString "\191\132\SUB\210l}\tp\172\203",PropCorrelationData "lg\184\168q$[\198\239h\CAN\255\200\246\177\148`\GS\155\SYN\156#\167\208x",PropSubscriptionIdentifier 1,PropContentType "\t\138\220%J\192P\139s\DELI\189E}\a\RS7\242\US\195\202\SOH\146",PropSharedSubscriptionAvailable 101,PropServerKeepAlive 32013,PropTopicAliasMaximum 29954]}), _cleanSession = False, _keepAlive = 22372, _connID = "\153\215g\142q\253\SUB\139\224jU\202Kb\220Q\233\DC2\137\&5", _properties = [PropPayloadFormatIndicator 102,PropAuthenticationMethod "^\139\ACK\ENQ]\198\245\245\249\233f\162\212\187\246?5U'\158V",PropRequestProblemInformation 63,PropAuthenticationMethod "J\232\225\186e\159",PropRetainAvailable 205,PropSessionExpiryInterval 7662,PropServerKeepAlive 30100,PropMaximumQoS 218,PropContentType "\198\&4C\185\252<\207@1\145",PropSessionExpiryInterval 18186,PropReasonString "{\136\214\vX\146\142\137\199\&8\216\bC\216\&2\243\241\193^\151}\DC1\238\246\150M\252\140\138\148",PropTopicAlias 14329,PropTopicAliasMaximum 24864,PropMaximumPacketSize 1959,PropAssignedClientIdentifier "\251\155GO\172\STX\164\DC1\236\SO\152+3\202\131:&1\155\220\197\&5\210>",PropSubscriptionIdentifier 20,PropRequestProblemInformation 235,PropTopicAlias 22057,PropContentType "\154O\FS\174\199T\236tb\202D",PropSharedSubscriptionAvailable 138,PropResponseTopic "\210\254\STX\186).\v]\145Y\tl\154oJ\STX\135\STXd\250\254",PropAssignedClientIdentifier "\RS\234-\177J7R\241\216\r\181Pc<&\ENQ\229\197",PropMessageExpiryInterval 9209,PropSharedSubscriptionAvailable 80,PropResponseTopic "f\220\GSj5|YH\"-\149:\210%",PropReasonString "\207Y\247",PropUserProperty "\fO" "\\\217\130\161`\204]\227nYDd\144(G.q\141\131 d\215\ETX8\164",PropAssignedClientIdentifier "\165\243\249m\158\221s\250s\199\237j\187&\168\DC4;Y\200\151u"]} -TEST(Connect5QCTest, Encode2) { -uint8_t pkt[] = {0x10, 0xa8, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc, 0x57, 0x64, 0xa4, 0x2, 0x1, 0x66, 0x15, 0x0, 0x15, 0x5e, 0x8b, 0x6, 0x5, 0x5d, 0xc6, 0xf5, 0xf5, 0xf9, 0xe9, 0x66, 0xa2, 0xd4, 0xbb, 0xf6, 0x3f, 0x35, 0x55, 0x27, 0x9e, 0x56, 0x17, 0x3f, 0x15, 0x0, 0x6, 0x4a, 0xe8, 0xe1, 0xba, 0x65, 0x9f, 0x25, 0xcd, 0x11, 0x0, 0x0, 0x1d, 0xee, 0x13, 0x75, 0x94, 0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, 0xc6, 0xf5, 0xf5, 0xf9, 0xe9, 0x66, 0xa2, 0xd4, 0xbb, 0xf6, 0x3f, 0x35, 0x55, 0x27, 0x9e, 0x56}; - uint8_t bytesprops1[] = {0x4a, 0xe8, 0xe1, 0xba, 0x65, 0x9f}; - uint8_t bytesprops2[] = {0xc6, 0x34, 0x43, 0xb9, 0xfc, 0x3c, 0xcf, 0x40, 0x31, 0x91}; - uint8_t bytesprops3[] = {0x7b, 0x88, 0xd6, 0xb, 0x58, 0x92, 0x8e, 0x89, 0xc7, 0x38, 0xd8, 0x8, 0x43, 0xd8, 0x32, 0xf3, 0xf1, 0xc1, 0x5e, 0x97, 0x7d, 0x11, 0xee, 0xf6, 0x96, 0x4d, 0xfc, 0x8c, 0x8a, 0x94}; - uint8_t bytesprops4[] = {0xfb, 0x9b, 0x47, 0x4f, 0xac, 0x2, 0xa4, 0x11, 0xec, 0xe, 0x98, 0x2b, 0x33, 0xca, 0x83, 0x3a, 0x26, 0x31, 0x9b, 0xdc, 0xc5, 0x35, 0xd2, 0x3e}; - uint8_t bytesprops5[] = {0x9a, 0x4f, 0x1c, 0xae, 0xc7, 0x54, 0xec, 0x74, 0x62, 0xca, 0x44}; - uint8_t bytesprops6[] = {0xd2, 0xfe, 0x2, 0xba, 0x29, 0x2e, 0xb, 0x5d, 0x91, 0x59, 0x9, 0x6c, 0x9a, 0x6f, 0x4a, 0x2, 0x87, 0x2, 0x64, 0xfa, 0xfe}; - uint8_t bytesprops7[] = {0x1e, 0xea, 0x2d, 0xb1, 0x4a, 0x37, 0x52, 0xf1, 0xd8, 0xd, 0xb5, 0x50, 0x63, 0x3c, 0x26, 0x5, 0xe5, 0xc5}; - uint8_t bytesprops8[] = {0x66, 0xdc, 0x1d, 0x6a, 0x35, 0x7c, 0x59, 0x48, 0x22, 0x2d, 0x95, 0x3a, 0xd2, 0x25}; - uint8_t bytesprops9[] = {0xcf, 0x59, 0xf7}; - uint8_t bytesprops11[] = {0x5c, 0xd9, 0x82, 0xa1, 0x60, 0xcc, 0x5d, 0xe3, 0x6e, 0x59, 0x44, 0x64, 0x90, 0x28, 0x47, 0x2e, 0x71, 0x8d, 0x83, 0x20, 0x64, 0xd7, 0x3, 0x38, 0xa4}; - uint8_t bytesprops10[] = {0xc, 0x4f}; - uint8_t bytesprops12[] = {0xa5, 0xf3, 0xf9, 0x6d, 0x9e, 0xdd, 0x73, 0xfa, 0x73, 0xc7, 0xed, 0x6a, 0xbb, 0x26, 0xa8, 0x14, 0x3b, 0x59, 0xc8, 0x97, 0x75}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7662}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30100}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18186}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14329}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24864}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1959}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22057}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9209}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={2, (char*)&bytesprops10}, .v={25, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops12}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23903}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops0}, .v = {17, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xbf, 0x84, 0x1a, 0xd2, 0x6c, 0x7d, 0x9, 0x70, 0xac, 0xcb}; - uint8_t byteswillprops1[] = {0x6c, 0x67, 0xb8, 0xa8, 0x71, 0x24, 0x5b, 0xc6, 0xef, 0x68, 0x18, 0xff, 0xc8, 0xf6, 0xb1, 0x94, 0x60, 0x1d, 0x9b, 0x16, 0x9c, 0x23, 0xa7, 0xd0, 0x78}; - uint8_t byteswillprops2[] = {0x9, 0x8a, 0xdc, 0x25, 0x4a, 0xc0, 0x50, 0x8b, 0x73, 0x7f, 0x49, 0xbd, 0x45, 0x7d, 0x7, 0x1e, 0x37, 0xf2, 0x1f, 0xc3, 0xca, 0x1, 0x92}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32013}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29954}}, - }; - - lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x9d, 0x37, 0xa0, 0x34, 0x21, 0x3c, 0x98, 0x6f}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xcf, 0xce, 0x2a, 0xd, 0xc4, 0x78, 0xc7, 0x4a}; - lwmqtt_string_t will_payload = {8, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 22372; - uint8_t client_id_bytes[] = {0x99, 0xd7, 0x67, 0x8e, 0x71, 0xfd, 0x1a, 0x8b, 0xe0, 0x6a, 0x55, 0xca, 0x4b, 0x62, 0xdc, 0x51, 0xe9, 0x12, 0x89, 0x35}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; -opts.client_id = client_id; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - -} - - -// ConnectRequest {_username = Just "\210\154\156`\157$\167\211\ACK|\EMc\FS\DC4;\244\132\247\250\DC1p\226", _password = Just "\250\211\178\rK\SUB\US\221G\171\f\202\222h\195\201\142\SOH\178\141\RS\179\234d\191G\245\249", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\166\245E _4\192:\130\134\233", _willMsg = "\199!\216\227\149HhD#\178\nH@\210\185:C\147\183\168", _willProps = [PropRetainAvailable 201,PropSubscriptionIdentifier 28,PropCorrelationData "\193\bY",PropContentType "\DC1I\ACK\ACK\160\174#k\n+\194k#x.\185\166`\245\DELM\209dRs\SIC\240\&3\195",PropServerKeepAlive 8768,PropSharedSubscriptionAvailable 108,PropAssignedClientIdentifier "\202\SI\DC1\ESC\ETB\EM\SI\159a\173]\SUB\RST\241\NULX\243\139i\ENQ\241*\DC2#\135bQ\159",PropReasonString "\175\211\164",PropAuthenticationMethod "K\210\166",PropMaximumQoS 129,PropMessageExpiryInterval 5457,PropMessageExpiryInterval 28978,PropSharedSubscriptionAvailable 15,PropSessionExpiryInterval 17136]}), _cleanSession = False, _keepAlive = 11307, _connID = "\214\137\207{L;\190\191\172O\206z4\183", _properties = [PropAuthenticationMethod "\195\178\201+\211\146\r\182\&3z\204(\217\STX",PropRetainAvailable 112,PropMessageExpiryInterval 18289,PropSubscriptionIdentifier 11,PropCorrelationData "\227MN\223J\ETBa\218\179\156",PropAuthenticationData "\235V\247H*\ESCht\241\146\212:\172\250\149Q\156\205",PropResponseInformation "\250\ESC\fV\212\225\247(\EM\170\SOZ\209\142\188\218\154\EOT",PropPayloadFormatIndicator 209,PropSubscriptionIdentifierAvailable 203,PropRequestProblemInformation 213,PropRetainAvailable 99,PropWildcardSubscriptionAvailable 54,PropCorrelationData "\SYN:G\DC4\129\rb\159U\189\147",PropServerKeepAlive 19775,PropPayloadFormatIndicator 42,PropServerReference "yB\217",PropServerReference "S\204$oc\132WG\237\139\f|\158\207q",PropRetainAvailable 53,PropTopicAliasMaximum 8890,PropSubscriptionIdentifierAvailable 141,PropServerReference "\DLE\163\200\240\189\RS/J\SOH>\DC1\v\232h/o3$\FS\NULD\150\215\142&h\CAN\182\234",PropMaximumQoS 4,PropAuthenticationMethod "\ESC\175\r\230\167\232\253c\132GY",PropSharedSubscriptionAvailable 179,PropAssignedClientIdentifier "\239\CAN\154\181\NUL\SI$\221\247t\249hug/\STX\140qQ\155",PropSessionExpiryInterval 31964,PropReasonString "\US\ESCFm9\232vg\220X\148\b\231-",PropUserProperty "S\152\255\161\183g]\234" "",PropResponseInformation "\175\RS\210\129\"\230\175?\SO\ETXu\186\217)\201\136\SI\133!\160'\189\254\248\199r\159",PropTopicAlias 10779]} -TEST(Connect5QCTest, Encode3) { -uint8_t pkt[] = {0x10, 0xff, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc4, 0x2c, 0x2b, 0x9a, 0x2, 0x15, 0x0, 0xe, 0xc3, 0xb2, 0xc9, 0x2b, 0xd3, 0x92, 0xd, 0xb6, 0x33, 0x7a, 0xcc, 0x28, 0xd9, 0x2, 0x25, 0x70, 0x2, 0x0, 0x0, 0x47, 0x71, 0xb, 0xb, 0x9, 0x0, 0xa, 0xe3, 0x4d, 0x4e, 0xdf, 0x4a, 0x17, 0x61, 0xda, 0xb3, 0x9c, 0x16, 0x0, 0x12, 0xeb, 0x56, 0xf7, 0x48, 0x2a, 0x1b, 0x68, 0x74, 0xf1, 0x92, 0xd4, 0x3a, 0xac, 0xfa, 0x95, 0x51, 0x9c, 0xcd, 0x1a, 0x0, 0x12, 0xfa, 0x1b, 0xc, 0x56, 0xd4,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 0x16, 0xd2, 0x9a, 0x9c, 0x60, 0x9d, 0x24, 0xa7, 0xd3, 0x6, 0x7c, 0x19, 0x63, 0x1c, 0x14, 0x3b, 0xf4, 0x84, 0xf7, 0xfa, 0x11, 0x70, 0xe2, 0x0, 0x1c, 0xfa, 0xd3, 0xb2, 0xd, 0x4b, 0x1a, 0x1f, 0xdd, 0x47, 0xab, 0xc, 0xca, 0xde, 0x68, 0xc3, 0xc9, 0x8e, 0x1, 0xb2, 0x8d, 0x1e, 0xb3, 0xea, 0x64, 0xbf, 0x47, 0xf5, 0xf9}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xc3, 0xb2, 0xc9, 0x2b, 0xd3, 0x92, 0xd, 0xb6, 0x33, 0x7a, 0xcc, 0x28, 0xd9, 0x2}; - uint8_t bytesprops1[] = {0xe3, 0x4d, 0x4e, 0xdf, 0x4a, 0x17, 0x61, 0xda, 0xb3, 0x9c}; - uint8_t bytesprops2[] = {0xeb, 0x56, 0xf7, 0x48, 0x2a, 0x1b, 0x68, 0x74, 0xf1, 0x92, 0xd4, 0x3a, 0xac, 0xfa, 0x95, 0x51, 0x9c, 0xcd}; - uint8_t bytesprops3[] = {0xfa, 0x1b, 0xc, 0x56, 0xd4, 0xe1, 0xf7, 0x28, 0x19, 0xaa, 0xe, 0x5a, 0xd1, 0x8e, 0xbc, 0xda, 0x9a, 0x4}; - uint8_t bytesprops4[] = {0x16, 0x3a, 0x47, 0x14, 0x81, 0xd, 0x62, 0x9f, 0x55, 0xbd, 0x93}; - uint8_t bytesprops5[] = {0x79, 0x42, 0xd9}; - uint8_t bytesprops6[] = {0x53, 0xcc, 0x24, 0x6f, 0x63, 0x84, 0x57, 0x47, 0xed, 0x8b, 0xc, 0x7c, 0x9e, 0xcf, 0x71}; - uint8_t bytesprops7[] = {0x10, 0xa3, 0xc8, 0xf0, 0xbd, 0x1e, 0x2f, 0x4a, 0x1, 0x3e, 0x11, 0xb, 0xe8, 0x68, 0x2f, 0x6f, 0x33, 0x24, 0x1c, 0x0, 0x44, 0x96, 0xd7, 0x8e, 0x26, 0x68, 0x18, 0xb6, 0xea}; - uint8_t bytesprops8[] = {0x1b, 0xaf, 0xd, 0xe6, 0xa7, 0xe8, 0xfd, 0x63, 0x84, 0x47, 0x59}; - uint8_t bytesprops9[] = {0xef, 0x18, 0x9a, 0xb5, 0x0, 0xf, 0x24, 0xdd, 0xf7, 0x74, 0xf9, 0x68, 0x75, 0x67, 0x2f, 0x2, 0x8c, 0x71, 0x51, 0x9b}; - uint8_t bytesprops10[] = {0x1f, 0x1b, 0x46, 0x6d, 0x39, 0xe8, 0x76, 0x67, 0xdc, 0x58, 0x94, 0x8, 0xe7, 0x2d}; - uint8_t bytesprops12[] = {0}; - uint8_t bytesprops11[] = {0x53, 0x98, 0xff, 0xa1, 0xb7, 0x67, 0x5d, 0xea}; - uint8_t bytesprops13[] = {0xaf, 0x1e, 0xd2, 0x81, 0x22, 0xe6, 0xaf, 0x3f, 0xe, 0x3, 0x75, 0xba, 0xd9, 0x29, 0xc9, 0x88, 0xf, 0x85, 0x21, 0xa0, 0x27, 0xbd, 0xfe, 0xf8, 0xc7, 0x72, 0x9f}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18289}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19775}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8890}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31964}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={8, (char*)&bytesprops11}, .v={0, (char*)&bytesprops12}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10779}}, - }; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xd, 0xf3, 0x7e, 0x9a, 0x0, 0xf8, 0xfc, 0x79, + 0x29, 0xfc, 0x90, 0xd6, 0x1, 0xf9, 0xba, 0x31}; + uint8_t byteswillprops1[] = {0xad, 0xd0, 0x6, 0xa, 0xc8, 0xfb, 0xc6, 0x3c, 0x3d, + 0x12, 0xf6, 0x62, 0xcf, 0xd3, 0xd8, 0xa5, 0x2e}; + uint8_t byteswillprops2[] = {0x5}; + uint8_t byteswillprops3[] = {0x37, 0xf6, 0x32}; + uint8_t byteswillprops5[] = {0xf1, 0x7a, 0xba, 0x67, 0xe0, 0x9e, 0x52, 0x82, 0x43, 0xf6, 0x8c, 0x5, 0x5e, + 0x73, 0x2f, 0xec, 0xc7, 0x5, 0x55, 0x1d, 0x6c, 0x1f, 0xd, 0x60, 0xf6}; + uint8_t byteswillprops4[] = {0x47, 0x82, 0xe5}; + uint8_t byteswillprops6[] = {0x59, 0xfd, 0xc9, 0x31, 0xe2, 0x30, 0xfa, 0x51, 0x6c, 0xbc, 0x99, 0xe0, 0x43, 0xe7, + 0x14, 0xe1, 0xe5, 0xee, 0x49, 0x3e, 0x8d, 0x5d, 0xb8, 0x65, 0xec, 0xc9, 0xa5}; + uint8_t byteswillprops7[] = {0x23, 0xa, 0x48, 0x9, 0xc0, 0xdf, 0xdf, 0x3e, 0x52, 0xb3, 0x71, 0x90, 0x17}; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc1, 0x8, 0x59}; - uint8_t byteswillprops1[] = {0x11, 0x49, 0x6, 0x6, 0xa0, 0xae, 0x23, 0x6b, 0xa, 0x2b, 0xc2, 0x6b, 0x23, 0x78, 0x2e, 0xb9, 0xa6, 0x60, 0xf5, 0x7f, 0x4d, 0xd1, 0x64, 0x52, 0x73, 0xf, 0x43, 0xf0, 0x33, 0xc3}; - uint8_t byteswillprops2[] = {0xca, 0xf, 0x11, 0x1b, 0x17, 0x19, 0xf, 0x9f, 0x61, 0xad, 0x5d, 0x1a, 0x1e, 0x54, 0xf1, 0x0, 0x58, 0xf3, 0x8b, 0x69, 0x5, 0xf1, 0x2a, 0x12, 0x23, 0x87, 0x62, 0x51, 0x9f}; - uint8_t byteswillprops3[] = {0xaf, 0xd3, 0xa4}; - uint8_t byteswillprops4[] = {0x4b, 0xd2, 0xa6}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8768}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5457}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28978}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17136}}, - }; - - lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa6, 0xf5, 0x45, 0x20, 0x5f, 0x34, 0xc0, 0x3a, 0x82, 0x86, 0xe9}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xc7, 0x21, 0xd8, 0xe3, 0x95, 0x48, 0x68, 0x44, 0x23, 0xb2, 0xa, 0x48, 0x40, 0xd2, 0xb9, 0x3a, 0x43, 0x93, 0xb7, 0xa8}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS0; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 11307; - uint8_t client_id_bytes[] = {0xd6, 0x89, 0xcf, 0x7b, 0x4c, 0x3b, 0xbe, 0xbf, 0xac, 0x4f, 0xce, 0x7a, 0x34, 0xb7}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xd2, 0x9a, 0x9c, 0x60, 0x9d, 0x24, 0xa7, 0xd3, 0x6, 0x7c, 0x19, 0x63, 0x1c, 0x14, 0x3b, 0xf4, 0x84, 0xf7, 0xfa, 0x11, 0x70, 0xe2}; - lwmqtt_string_t username = {22, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0xfa, 0xd3, 0xb2, 0xd, 0x4b, 0x1a, 0x1f, 0xdd, 0x47, 0xab, 0xc, 0xca, 0xde, 0x68, 0xc3, 0xc9, 0x8e, 0x1, 0xb2, 0x8d, 0x1e, 0xb3, 0xea, 0x64, 0xbf, 0x47, 0xf5, 0xf9}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19589}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25985}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 909}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24831}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {3, (char*)&byteswillprops4}, .v = {25, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29690}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 132}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7672}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4671}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22943}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29025}}, + }; + + lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb6, 0x12, 0xca, 0xaf, 0x27, 0xaf}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x46, 0x54, 0xb4, 0xe3, 0x20, 0x2c, 0x10, 0x68, 0x55, 0x93, + 0x67, 0xf9, 0xd2, 0x73, 0x6e, 0x96, 0x3d, 0x3e, 0x50, 0xea, + 0x68, 0x34, 0xea, 0x96, 0x36, 0x54, 0x89, 0x95, 0xc0, 0xd8}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 30046; + uint8_t client_id_bytes[] = {0x41, 0x27, 0xd8, 0x83, 0xfb, 0xd0, 0xda, 0x14, 0x98, 0xe6, 0xc6, 0xef, 0x7}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x1, 0xde, 0x94, 0x79, 0x34, 0x57, 0x37, 0xdd, 0xea, 0xdb, 0xf9, + 0x47, 0xb0, 0x69, 0x99, 0x37, 0x43, 0xae, 0x13, 0xc9, 0xa8}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "~\247\167\ACK\232\156\SYN\185\229`S\252", _password = Just +// "\f\149\174\193\181\&4\229ys\252zT\227\DC2\247\&2\216\183\132)\183\"#-\226\142", _lastWill = Nothing, _cleanSession = +// True, _keepAlive = 2932, _connID = "\199h5A\DC2\179`\178Q\DLE\ACK\182\ENQ\248Do\214\145o\SOi7\155\164\232G\239\ENQ\r",PropTopicAliasMaximum +// 23410,PropMessageExpiryInterval 27313,PropSessionExpiryInterval 25863,PropAuthenticationMethod +// "\218\246\&4\t\220C\199\193\ETXrtR\ACK\142.\NAK\149\139\156\192\133\163)\206\142",PropTopicAliasMaximum +// 31669,PropMessageExpiryInterval 2051,PropResponseInformation "",PropTopicAlias 288,PropPayloadFormatIndicator +// 69,PropServerKeepAlive 11992,PropAssignedClientIdentifier +// "\233\SYN\180\160\178\135\162\199RFI\204&d\239\184\168\237ey\ETX\214\CAN",PropPayloadFormatIndicator +// 209,PropAuthenticationData "",PropPayloadFormatIndicator 240,PropAssignedClientIdentifier +// "\NUL\r\223\128\168_\249\211\192e\a\246\251\SII/"]}), _cleanSession = False, _keepAlive = 16105, _connID = +// "\233#\162\&4\221v1'\194j\182\178J\225\247nx\168\166\148\147M\199\156\229Cz\134\EOT", _properties = [PropTopicAlias +// 27063,PropRequestResponseInformation 177,PropReasonString "",PropSharedSubscriptionAvailable +// 46,PropSubscriptionIdentifier 15,PropServerReference ":\216\237",PropMessageExpiryInterval 11345,PropServerKeepAlive +// 24364,PropResponseTopic "\168\199\129\177\157\193N/*8~W:",PropAuthenticationMethod +// "\162i\210\r\205\225\139\195\SYN\129\163\164\160Zc\173",PropSharedSubscriptionAvailable 93,PropServerKeepAlive +// 19517,PropWildcardSubscriptionAvailable 52,PropWillDelayInterval 7303,PropRequestProblemInformation +// 7,PropRequestProblemInformation 233,PropTopicAlias 3877,PropMessageExpiryInterval 11804,PropWillDelayInterval +// 5288,PropSessionExpiryInterval 19779,PropResponseTopic "\\Z\225\n\212'\202#\250",PropTopicAliasMaximum +// 5401,PropTopicAlias 7665,PropSubscriptionIdentifier 20,PropMaximumQoS 18,PropSubscriptionIdentifier 5]} +TEST(Connect5QCTest, Encode6) { + uint8_t pkt[] = { + 0x10, 0xbd, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc, 0x3e, 0xe9, 0x77, 0x23, 0x69, 0xb7, 0x19, 0xb1, + 0x1f, 0x0, 0x0, 0x2a, 0x2e, 0xb, 0xf, 0x1c, 0x0, 0x3, 0x3a, 0xd8, 0xed, 0x2, 0x0, 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 0x9, 0xdc, 0x43, 0xc7, 0xc1, 0x3, 0x72, + 0x74, 0x52, 0x6, 0x8e, 0x2e, 0x15, 0x95, 0x8b, 0x9c, 0xc0, 0x85, 0xa3, 0x29, 0xce, 0x8e, 0x22, 0x7b, 0xb5, 0x2, + 0x0, 0x0, 0x8, 0x3, 0x1a, 0x0, 0x0, 0x23, 0x1, 0x20, 0x1, 0x45, 0x13, 0x2e, 0xd8, 0x12, 0x0, 0x17, 0xe9, + 0x16, 0xb4, 0xa0, 0xb2, 0x87, 0xa2, 0xc7, 0x52, 0x46, 0x49, 0xcc, 0x26, 0x64, 0xef, 0xb8, 0xa8, 0xed, 0x65, 0x79, + 0x3, 0xd6, 0x18, 0x1, 0xd1, 0x16, 0x0, 0x0, 0x1, 0xf0, 0x12, 0x0, 0x10, 0x0, 0xd, 0xdf, 0x80, 0xa8, 0x5f, + 0xf9, 0xd3, 0xc0, 0x65, 0x7, 0xf6, 0xfb, 0xf, 0x49, 0x2f, 0x0, 0x0, 0x0, 0x2, 0x1f, 0x6d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x3a, 0xd8, 0xed}; + uint8_t bytesprops2[] = {0xa8, 0xc7, 0x81, 0xb1, 0x9d, 0xc1, 0x4e, 0x2f, 0x2a, 0x38, 0x7e, 0x57, 0x3a}; + uint8_t bytesprops3[] = {0xa2, 0x69, 0xd2, 0xd, 0xcd, 0xe1, 0x8b, 0xc3, + 0x16, 0x81, 0xa3, 0xa4, 0xa0, 0x5a, 0x63, 0xad}; + uint8_t bytesprops4[] = {0x5c, 0x5a, 0xe1, 0xa, 0xd4, 0x27, 0xca, 0x23, 0xfa}; -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "?w\155e\220+\213:#.\196F1\243\198\178\&6\133\t\231\160c\FS\249\191\241\146\DC3H\175[x\229",PropMessageExpiryInterval 2953,PropServerReference "?7\176\173\&1P\147G\211\209\181\177\EOT\164A\247&\174\243\207\t\255(",PropRequestProblemInformation 97,PropReasonString "\SIL\192\248",PropAssignedClientIdentifier "\217\247j\247f\253k\188e\232\234\nB\247\253\213\142{3`"]} -TEST(Connect5QCTest, Encode5) { -uint8_t pkt[] = {0x10, 0xe2, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2c, 0x62, 0xe4, 0x67, 0x22, 0x40, 0x69, 0x23, 0x44, 0xf8, 0x29, 0xb8, 0x22, 0x72, 0xe3, 0x15, 0x0, 0x1a, 0x94, 0x34, 0x4f, 0xa3, 0x3e, 0x31, 0xf3, 0xc6, 0xb2, 0x36, 0x85, 0x9, 0xe7, 0xa0, 0x63, 0x1c, 0xf9, 0xbf, 0xf1, 0x92, 0x13, 0x48, 0xaf, 0x5b, 0x78, 0xe5, 0x2, 0x0, 0x0, 0xb, 0x89, 0x1c, 0x0, 0x17, 0x3f, 0x37, 0xb0, 0xad, 0x31, 0x50, 0x93, 0x47, 0xd3, 0xd1, 0xb5, 0xb1, 0x4, 0xa4, 0x41, 0xf7, 0x26, 0xae, 0xf3, 0xcf, 0x9, 0xff, 0x28, 0x17, 0x61, 0x1f, 0x0, 0x4, 0xf, 0x4c, 0xc0, 0xf8, 0x12, 0x0, 0x14, 0xd9, 0xf7, 0x6a, 0xf7, 0x66, 0xfd, 0x6b, 0xbc, 0x65, 0xe8, 0xea, 0xa, 0x42, 0xf7, 0xfd, 0xd5, 0x8e, 0x7b, 0x33, 0x60, 0x0, 0x1, 0x8, 0xba, 0x1, 0x1f, 0x0, 0x18, 0x15, 0xf0, 0xe8, 0x44, 0x5e, 0xf8, 0x89, 0x94, 0x6e, 0x89, 0x96, 0xfb, 0xa1, 0x85, 0x5c, 0xe5, 0x99, 0x3, 0x88, 0x33, 0xe, 0xaa, 0x45, 0x14, 0x11, 0x0, 0x0, 0x58, 0xac, 0x25, 0x9b, 0x12, 0x0, 0x1e, 0x1f,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90, 0x94, 0x67, 0xeb, 0x69, 0xef, 0xf6, 0x8f, 0xcc, 0x74, 0x4b}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x94, 0x34, 0x4f, 0xa3, 0x3e, 0x31, 0xf3, 0xc6, 0xb2, 0x36, 0x85, 0x9, 0xe7, 0xa0, 0x63, 0x1c, 0xf9, 0xbf, 0xf1, 0x92, 0x13, 0x48, 0xaf, 0x5b, 0x78, 0xe5}; - uint8_t bytesprops1[] = {0x3f, 0x37, 0xb0, 0xad, 0x31, 0x50, 0x93, 0x47, 0xd3, 0xd1, 0xb5, 0xb1, 0x4, 0xa4, 0x41, 0xf7, 0x26, 0xae, 0xf3, 0xcf, 0x9, 0xff, 0x28}; - uint8_t bytesprops2[] = {0xf, 0x4c, 0xc0, 0xf8}; - uint8_t bytesprops3[] = {0xd9, 0xf7, 0x6a, 0xf7, 0x66, 0xfd, 0x6b, 0xbc, 0x65, 0xe8, 0xea, 0xa, 0x42, 0xf7, 0xfd, 0xd5, 0x8e, 0x7b, 0x33, 0x60}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16489}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17656}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29411}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2953}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27063}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11345}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24364}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19517}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7303}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3877}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11804}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5288}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19779}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5401}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7665}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x15, 0xf0, 0xe8, 0x44, 0x5e, 0xf8, 0x89, 0x94, 0x6e, 0x89, 0x96, 0xfb, 0xa1, 0x85, 0x5c, 0xe5, 0x99, 0x3, 0x88, 0x33, 0xe, 0xaa, 0x45, 0x14}; - uint8_t byteswillprops1[] = {0x1f, 0xe1, 0xa2, 0x4e, 0x53, 0xd4, 0x37, 0x8d, 0xe, 0x7b, 0x39, 0x29, 0xe4, 0x9a, 0xe6, 0xb1, 0xe9, 0x55, 0x69, 0x11, 0xf2, 0x58, 0x95, 0x5b, 0x6e, 0xc2, 0x25, 0x6f, 0x2d, 0xd1}; - uint8_t byteswillprops2[] = {0xb6, 0xeb, 0xb3, 0x86, 0x65, 0x67, 0xa5, 0x51, 0xf, 0x29, 0xdd, 0x7c, 0x1e, 0x7, 0x23, 0x34, 0xb0, 0xcf, 0x6d, 0x70, 0xc4, 0x7d, 0x8b, 0x46, 0xd0, 0x53, 0x3f, 0x61, 0xc1}; - uint8_t byteswillprops4[] = {0x3c, 0x65, 0x39, 0x76, 0x5f, 0xbc, 0xf0}; - uint8_t byteswillprops3[] = {0x83, 0x54, 0x9c, 0x19, 0x25, 0x73, 0x67, 0x5d, 0x12, 0x8d, 0xbd, 0x20, 0xfb, 0xa2, 0xfb, 0x68}; - uint8_t byteswillprops5[] = {0x60, 0x5b, 0xdc, 0xb4, 0x2, 0x1d, 0x57, 0x35, 0x95, 0xf1, 0x7c, 0x78, 0xf9, 0x4d, 0x3, 0xa3, 0xfc, 0xc4, 0x73, 0x24, 0x50, 0x88, 0x55, 0xa2, 0xee, 0xe7, 0x9d}; - + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x1b, 0xa9, 0x3e, 0x12, 0xb3, 0x60, 0xb2, 0x51, 0x10, 0x6, 0xb6, 0x5, 0xf8, 0x44, + 0x6f, 0xd6, 0x91, 0x6f, 0xe, 0x69, 0x37, 0x9b, 0xa4, 0xe8, 0x47, 0xef, 0x5, 0xd}; + uint8_t byteswillprops1[] = {0xda, 0xf6, 0x34, 0x9, 0xdc, 0x43, 0xc7, 0xc1, 0x3, 0x72, 0x74, 0x52, 0x6, + 0x8e, 0x2e, 0x15, 0x95, 0x8b, 0x9c, 0xc0, 0x85, 0xa3, 0x29, 0xce, 0x8e}; + uint8_t byteswillprops2[] = {0}; + uint8_t byteswillprops3[] = {0xe9, 0x16, 0xb4, 0xa0, 0xb2, 0x87, 0xa2, 0xc7, 0x52, 0x46, 0x49, 0xcc, + 0x26, 0x64, 0xef, 0xb8, 0xa8, 0xed, 0x65, 0x79, 0x3, 0xd6, 0x18}; + uint8_t byteswillprops4[] = {0}; + uint8_t byteswillprops5[] = {0x0, 0xd, 0xdf, 0x80, 0xa8, 0x5f, 0xf9, 0xd3, + 0xc0, 0x65, 0x7, 0xf6, 0xfb, 0xf, 0x49, 0x2f}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22700}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={16, (char*)&byteswillprops3}, .v={7, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4004}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24648}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2289}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 177}}, - }; - - lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3f, 0x77, 0x9b, 0x65, 0xdc, 0x2b, 0xd5, 0x3a, 0x23, 0x2e, 0xc4, 0x46, 0x3c, 0x4d, 0xf7}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa3, 0xe2, 0x3a, 0xf4, 0x16, 0x84, 0x95, 0x44, 0x5f, 0xef, 0x61, 0xf2, 0x78, 0xa7, 0x78, 0xd3, 0x2d, 0xd7, 0xdb, 0x90, 0x94, 0x67, 0xeb, 0x69, 0xef, 0xf6, 0x8f, 0xcc, 0x74, 0x4b}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 25316; - uint8_t client_id_bytes[] = {0x8}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; -opts.client_id = client_id; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5999}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23410}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27313}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25863}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31669}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2051}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 288}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11992}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&byteswillprops5}}}, + }; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1f, 0x6d}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 16105; + uint8_t client_id_bytes[] = {0xe9, 0x23, 0xa2, 0x34, 0xdd, 0x76, 0x31, 0x27, 0xc2, 0x6a, 0xb6, 0xb2, 0x4a, 0xe1, 0xf7, + 0x6e, 0x78, 0xa8, 0xa6, 0x94, 0x93, 0x4d, 0xc7, 0x9c, 0xe5, 0x43, 0x7a, 0x86, 0x4}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "\EM\145", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS1, _willTopic = "\251\200\&6\199\206\206\220pH\v\151\196\129A_\134\141\215\229\SO\189\198l\249=\202", +// _willMsg = "\179%l\240\143\191>o\222\152\ETXd\178q\161", _willProps = [PropContentType +// "M\n\153\155\EM\221s9|9B\131\223\&2&\201q\ty\DC3",PropServerReference +// "@\154\225\138\225\223\196",PropAuthenticationData +// "\214\243\166\172\205\134zvP\131p\161",PropAssignedClientIdentifier "{\255\229\189\130{h(\238\172",PropResponseTopic +// "\209 +// \198\a~\236z\253\DLE\134\226\&3\233\170\235\212\147\215\223\217\DC3\247\165\164\rc\177\156\181\240",PropUserProperty +// "k\191\216\&8E\249\f]\233\140f-\214Bf7t\147\150\168\243\196\184\222W\239\248N\STX\164" +// "\133\f\203\154u\221\&5V\231\US\EOT\229\168\SO\240;\213K\142"]}), _cleanSession = False, _keepAlive = 20495, _connID +// = "\199\170\&0\213\199\&6Tz4k\247\fs;\188l\241\227L\185\128\149\160\143\227\150c7\220", _properties = +// [PropSubscriptionIdentifier 14,PropSessionExpiryInterval 23537,PropAssignedClientIdentifier +// "\DC1\144\250j~\248\184\137,\DC4\168j_\f\172Ja\155\226\141\176Yr\ENQ\200?gl",PropResponseTopic +// "\241\138\194",PropSessionExpiryInterval 9638,PropSubscriptionIdentifierAvailable 169,PropRequestProblemInformation +// 253,PropUserProperty "\144\SI\216\EOT\138[A\144\r\143\172\161\171\171$\174\133\181^\184<:\149" +// "\186\&5\240\143\192\161",PropSubscriptionIdentifier 13,PropAssignedClientIdentifier +// "\220\218\211W-lS\206",PropCorrelationData "\179\DC4h\149\b\CAN#\176",PropUserProperty +// "\218\230\178s\191\NAK\143\&1\243f\174u" ")\229\150jQ\178\255",PropServerReference +// "\190\SUB<\198\SUBSy'\157",PropResponseInformation "$\250\&4^\240L\157\SUB",PropServerReference +// "\226\US\227\231{\166\&7"]} +TEST(Connect5QCTest, Encode7) { + uint8_t pkt[] = { + 0x10, 0x9a, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xac, 0x50, 0xf, 0xa8, 0x1, 0xb, 0xe, 0x11, 0x0, + 0x0, 0x5b, 0xf1, 0x12, 0x0, 0x1c, 0x11, 0x90, 0xfa, 0x6a, 0x7e, 0xf8, 0xb8, 0x89, 0x2c, 0x14, 0xa8, 0x6a, 0x5f, + 0xc, 0xac, 0x4a, 0x61, 0x9b, 0xe2, 0x8d, 0xb0, 0x59, 0x72, 0x5, 0xc8, 0x3f, 0x67, 0x6c, 0x8, 0x0, 0x3, 0xf1, + 0x8a, 0xc2, 0x11, 0x0, 0x0, 0x25, 0xa6, 0x29, 0xa9, 0x17, 0xfd, 0x26, 0x0, 0x17, 0x90, 0xf, 0xd8, 0x4, 0x8a, + 0x5b, 0x41, 0x90, 0xd, 0x8f, 0xac, 0xa1, 0xab, 0xab, 0x24, 0xae, 0x85, 0xb5, 0x5e, 0xb8, 0x3c, 0x3a, 0x95, 0x0, + 0x6, 0xba, 0x35, 0xf0, 0x8f, 0xc0, 0xa1, 0xb, 0xd, 0x12, 0x0, 0x8, 0xdc, 0xda, 0xd3, 0x57, 0x2d, 0x6c, 0x53, + 0xce, 0x9, 0x0, 0x8, 0xb3, 0x14, 0x68, 0x95, 0x8, 0x18, 0x23, 0xb0, 0x26, 0x0, 0xc, 0xda, 0xe6, 0xb2, 0x73, + 0xbf, 0x15, 0x8f, 0x31, 0xf3, 0x66, 0xae, 0x75, 0x0, 0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, 0x42, 0x66, 0x37, 0x74, 0x93, 0x96, 0xa8, 0xf3, 0xc4, 0xb8, 0xde, 0x57, 0xef, 0xf8, 0x4e, 0x2, + 0xa4, 0x0, 0x13, 0x85, 0xc, 0xcb, 0x9a, 0x75, 0xdd, 0x35, 0x56, 0xe7, 0x1f, 0x4, 0xe5, 0xa8, 0xe, 0xf0, 0x3b, + 0xd5, 0x4b, 0x8e, 0x0, 0x1a, 0xfb, 0xc8, 0x36, 0xc7, 0xce, 0xce, 0xdc, 0x70, 0x48, 0xb, 0x97, 0xc4, 0x81, 0x41, + 0x5f, 0x86, 0x8d, 0xd7, 0xe5, 0xe, 0xbd, 0xc6, 0x6c, 0xf9, 0x3d, 0xca, 0x0, 0xf, 0xb3, 0x25, 0x6c, 0xf0, 0x8f, + 0xbf, 0x3e, 0x6f, 0xde, 0x98, 0x3, 0x64, 0xb2, 0x71, 0xa1, 0x0, 0x2, 0x19, 0x91}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x11, 0x90, 0xfa, 0x6a, 0x7e, 0xf8, 0xb8, 0x89, 0x2c, 0x14, 0xa8, 0x6a, 0x5f, 0xc, + 0xac, 0x4a, 0x61, 0x9b, 0xe2, 0x8d, 0xb0, 0x59, 0x72, 0x5, 0xc8, 0x3f, 0x67, 0x6c}; + uint8_t bytesprops1[] = {0xf1, 0x8a, 0xc2}; + uint8_t bytesprops3[] = {0xba, 0x35, 0xf0, 0x8f, 0xc0, 0xa1}; + uint8_t bytesprops2[] = {0x90, 0xf, 0xd8, 0x4, 0x8a, 0x5b, 0x41, 0x90, 0xd, 0x8f, 0xac, 0xa1, + 0xab, 0xab, 0x24, 0xae, 0x85, 0xb5, 0x5e, 0xb8, 0x3c, 0x3a, 0x95}; + uint8_t bytesprops4[] = {0xdc, 0xda, 0xd3, 0x57, 0x2d, 0x6c, 0x53, 0xce}; + uint8_t bytesprops5[] = {0xb3, 0x14, 0x68, 0x95, 0x8, 0x18, 0x23, 0xb0}; + uint8_t bytesprops7[] = {0x29, 0xe5, 0x96, 0x6a, 0x51, 0xb2, 0xff}; + uint8_t bytesprops6[] = {0xda, 0xe6, 0xb2, 0x73, 0xbf, 0x15, 0x8f, 0x31, 0xf3, 0x66, 0xae, 0x75}; + uint8_t bytesprops8[] = {0xbe, 0x1a, 0x3c, 0xc6, 0x1a, 0x53, 0x79, 0x27, 0x9d}; + uint8_t bytesprops9[] = {0x24, 0xfa, 0x34, 0x5e, 0xf0, 0x4c, 0x9d, 0x1a}; + uint8_t bytesprops10[] = {0xe2, 0x1f, 0xe3, 0xe7, 0x7b, 0xa6, 0x37}; -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\231\215\CAN\203\225\ETX1\228\EM$\170", _willMsg = "v\245\158;\210\154\234\241O\186u[,<\NAK'r>", _willProps = [PropResponseTopic "\225\DC1\207l\SUB\197\&123\178\143\ESC\NUL|\246c\176s\171\220PO\188\245\NUL\181",PropRequestResponseInformation 85,PropAuthenticationData "\136\132@d]\167l\146\STX>\173\165\167\128\132\CANzm\138\r\159\&0'C",PropReceiveMaximum 9284,PropContentType "iQ,\140\SI\NAK\235\188\v\134Q\218\213\143\RS",PropSharedSubscriptionAvailable 12]}), _cleanSession = True, _keepAlive = 30216, _connID = "\ETBtE\131\"\233<\193T\DLE", _properties = [PropWildcardSubscriptionAvailable 162,PropSubscriptionIdentifierAvailable 89,PropSessionExpiryInterval 5666,PropWillDelayInterval 1242,PropSubscriptionIdentifierAvailable 81,PropSubscriptionIdentifier 8,PropMaximumQoS 148,PropResponseInformation "p\SOH\140\134$X\131!`X`\ETB\141\229\196k\148\NAK",PropRequestResponseInformation 46,PropSubscriptionIdentifierAvailable 132,PropAssignedClientIdentifier "\206\&7\199\224\173\140C_]\157\246\159",PropMessageExpiryInterval 24801,PropAuthenticationData "\158\230\a\254\249",PropCorrelationData "\174\158\250\154\197\159nC\129\164",PropReasonString "jzM`*j\192\&31\137\t\DLEl\161\US\148-U\EOT\213C\212\146\212\201g\243",PropMaximumPacketSize 31605,PropAuthenticationMethod "\182\140\&4o\131\FSp\209\145\200\187\175\136k\EM=\186I'L",PropWillDelayInterval 21259,PropMaximumQoS 69,PropMaximumPacketSize 27562,PropPayloadFormatIndicator 66,PropResponseTopic "\198]\248\STX\135\248",PropWillDelayInterval 26956]} -TEST(Connect5QCTest, Encode6) { -uint8_t pkt[] = {0x10, 0xb7, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x16, 0x76, 0x8, 0xac, 0x1, 0x28, 0xa2, 0x29, 0x59, 0x11, 0x0, 0x0, 0x16, 0x22, 0x18, 0x0, 0x0, 0x4, 0xda, 0x29, 0x51, 0xb, 0x8, 0x24, 0x94, 0x1a, 0x0, 0x12, 0x70, 0x1, 0x8c, 0x86, 0x24, 0x58, 0x83, 0x21, 0x60, 0x58, 0x60, 0x17, 0x8d, 0xe5, 0xc4, 0x6b, 0x94, 0x15, 0x19, 0x2e, 0x29, 0x84, 0x12, 0x0, 0xc, 0xce, 0x37, 0xc7, 0xe0, 0xad, 0x8c, 0x43, 0x5f, 0x5d, 0x9d, 0xf6, 0x9f, 0x2, 0x0, 0x0, 0x60, 0xe1, 0x16, 0x0, 0x5, 0x9e, 0xe6, 0x7, 0xfe, 0xf9, 0x9, 0x0, 0xa, 0xae, 0x9e, 0xfa, 0x9a, 0xc5, 0x9f, 0x6e, 0x43, 0x81, 0xa4, 0x1f, 0x0, 0x1b, 0x6a, 0x7a, 0x4d, 0x60, 0x2a, 0x6a, 0xc0, 0x33, 0x31, 0x89, 0x9, 0x10, 0x6c, 0xa1, 0x1f, 0x94, 0x2d, 0x55, 0x4, 0xd5, 0x43, 0xd4, 0x92, 0xd4, 0xc9, 0x67, 0xf3, 0x27, 0x0, 0x0, 0x7b, 0x75, 0x15, 0x0, 0x14, 0xb6, 0x8c, 0x34, 0x6f, 0x83, 0x1c, 0x70, 0xd1, 0x91,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6b, 0x94, 0x15}; - uint8_t bytesprops1[] = {0xce, 0x37, 0xc7, 0xe0, 0xad, 0x8c, 0x43, 0x5f, 0x5d, 0x9d, 0xf6, 0x9f}; - uint8_t bytesprops2[] = {0x9e, 0xe6, 0x7, 0xfe, 0xf9}; - uint8_t bytesprops3[] = {0xae, 0x9e, 0xfa, 0x9a, 0xc5, 0x9f, 0x6e, 0x43, 0x81, 0xa4}; - uint8_t bytesprops4[] = {0x6a, 0x7a, 0x4d, 0x60, 0x2a, 0x6a, 0xc0, 0x33, 0x31, 0x89, 0x9, 0x10, 0x6c, 0xa1, 0x1f, 0x94, 0x2d, 0x55, 0x4, 0xd5, 0x43, 0xd4, 0x92, 0xd4, 0xc9, 0x67, 0xf3}; - uint8_t bytesprops5[] = {0xb6, 0x8c, 0x34, 0x6f, 0x83, 0x1c, 0x70, 0xd1, 0x91, 0xc8, 0xbb, 0xaf, 0x88, 0x6b, 0x19, 0x3d, 0xba, 0x49, 0x27, 0x4c}; - uint8_t bytesprops6[] = {0xc6, 0x5d, 0xf8, 0x2, 0x87, 0xf8}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5666}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1242}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24801}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31605}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21259}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27562}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26956}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23537}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9638}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops2}, .v = {6, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops6}, .v = {7, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe1, 0x11, 0xcf, 0x6c, 0x1a, 0xc5, 0x31, 0x32, 0x33, 0xb2, 0x8f, 0x1b, 0x0, 0x7c, 0xf6, 0x63, 0xb0, 0x73, 0xab, 0xdc, 0x50, 0x4f, 0xbc, 0xf5, 0x0, 0xb5}; - uint8_t byteswillprops1[] = {0x88, 0x84, 0x40, 0x64, 0x5d, 0xa7, 0x6c, 0x92, 0x2, 0x3e, 0xad, 0xa5, 0xa7, 0x80, 0x84, 0x18, 0x7a, 0x6d, 0x8a, 0xd, 0x9f, 0x30, 0x27, 0x43}; - uint8_t byteswillprops2[] = {0x69, 0x51, 0x2c, 0x8c, 0xf, 0x15, 0xeb, 0xbc, 0xb, 0x86, 0x51, 0xda, 0xd5, 0x8f, 0x1e}; - + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x4d, 0xa, 0x99, 0x9b, 0x19, 0xdd, 0x73, 0x39, 0x7c, 0x39, + 0x42, 0x83, 0xdf, 0x32, 0x26, 0xc9, 0x71, 0x9, 0x79, 0x13}; + uint8_t byteswillprops1[] = {0x40, 0x9a, 0xe1, 0x8a, 0xe1, 0xdf, 0xc4}; + uint8_t byteswillprops2[] = {0xd6, 0xf3, 0xa6, 0xac, 0xcd, 0x86, 0x7a, 0x76, 0x50, 0x83, 0x70, 0xa1}; + uint8_t byteswillprops3[] = {0x7b, 0xff, 0xe5, 0xbd, 0x82, 0x7b, 0x68, 0x28, 0xee, 0xac}; + uint8_t byteswillprops4[] = {0xd1, 0x20, 0xc6, 0x7, 0x7e, 0xec, 0x7a, 0xfd, 0x10, 0x86, + 0xe2, 0x33, 0xe9, 0xaa, 0xeb, 0xd4, 0x93, 0xd7, 0xdf, 0xd9, + 0x13, 0xf7, 0xa5, 0xa4, 0xd, 0x63, 0xb1, 0x9c, 0xb5, 0xf0}; + uint8_t byteswillprops6[] = {0x85, 0xc, 0xcb, 0x9a, 0x75, 0xdd, 0x35, 0x56, 0xe7, 0x1f, + 0x4, 0xe5, 0xa8, 0xe, 0xf0, 0x3b, 0xd5, 0x4b, 0x8e}; + uint8_t byteswillprops5[] = {0x6b, 0xbf, 0xd8, 0x38, 0x45, 0xf9, 0xc, 0x5d, 0xe9, 0x8c, + 0x66, 0x2d, 0xd6, 0x42, 0x66, 0x37, 0x74, 0x93, 0x96, 0xa8, + 0xf3, 0xc4, 0xb8, 0xde, 0x57, 0xef, 0xf8, 0x4e, 0x2, 0xa4}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9284}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {30, (char*)&byteswillprops5}, .v = {19, (char*)&byteswillprops6}}}}, }; lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe7, 0xd7, 0x18, 0xcb, 0xe1, 0x3, 0x31, 0xe4, 0x19, 0x24, 0xaa}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x76, 0xf5, 0x9e, 0x3b, 0xd2, 0x9a, 0xea, 0xf1, 0x4f, 0xba, 0x75, 0x5b, 0x2c, 0x3c, 0x15, 0x27, 0x72, 0x3e}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 30216; - uint8_t client_id_bytes[] = {0x17, 0x74, 0x45, 0x83, 0x22, 0xe9, 0x3c, 0xc1, 0x54, 0x10}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; -opts.client_id = client_id; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - -} - - -// ConnectRequest {_username = Just "\184\RS2\175$\t.Y\176C6\139.\188\209\208\199", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "k_hun\216\209\212\219%\193\NAK[\175\250\232\STX\214\196)\SOH\135\SO\t", _willMsg = "\216\193J\242J\215\b\166\FS\181,u\246W&\128\245\STXbo\142d\186\234!\250\EM\219\136", _willProps = [PropReasonString "",PropMessageExpiryInterval 4624,PropResponseTopic "\213\DEL}kO\DEL\146",PropReasonString "\CAN-\226@y\"\CAN:\248\183[D\142\204\156\146UqcW\187\194y\166_",PropSubscriptionIdentifier 20,PropServerKeepAlive 2189,PropUserProperty "\215o\"\224" "r\232\167=4\234\&4KwD\234\165\rf\249\226d\ETX}\178\STX\250\220V\213\SYN",PropTopicAliasMaximum 16445,PropMessageExpiryInterval 10243,PropResponseTopic "g\163\135\157\132\136c\231",PropCorrelationData "",PropMaximumPacketSize 21568,PropMessageExpiryInterval 3075,PropRequestProblemInformation 212,PropContentType "\171\151S\147\US\171\134\150\200\CAN?J\142f\175\n\162O",PropSubscriptionIdentifier 12,PropWillDelayInterval 14729,PropSessionExpiryInterval 21067,PropSharedSubscriptionAvailable 108,PropAuthenticationMethod "\186%]\DC1\NUL\210c\248\SIgFOe\DC3\DC4\134a\DLE",PropResponseInformation "\130&\193\188k\150y\141\198~\196+",PropContentType "",PropServerReference "de\214OR\139\249",PropServerKeepAlive 2475,PropResponseInformation "jO",PropWillDelayInterval 6987,PropSubscriptionIdentifier 14,PropRequestProblemInformation 79,PropServerKeepAlive 7409]}), _cleanSession = True, _keepAlive = 12402, _connID = "\157\DC4\228=k\DLE5N\171\v+\185\227", _properties = [PropRetainAvailable 103,PropRetainAvailable 113,PropAssignedClientIdentifier "\154(\NAK\187\209\146y\252F\ACKo\143\157\229\217{\174\144\141{\224",PropAssignedClientIdentifier "\185/\163\236\252",PropPayloadFormatIndicator 77,PropPayloadFormatIndicator 49,PropReceiveMaximum 25543,PropMessageExpiryInterval 22717,PropWildcardSubscriptionAvailable 20,PropSubscriptionIdentifierAvailable 7,PropAuthenticationData "\129\245\EOT\240\STX\SO\138\133",PropRequestProblemInformation 10,PropResponseTopic "\178p\185P\147\147:L\r\153\152[\224\201~\187\ENQ",PropResponseInformation "\130\144\DC4\CAN\US\247\&0#$5\217\133\204\&7\155\141a9\DLE\vt4",PropServerKeepAlive 6182,PropTopicAliasMaximum 26231,PropSessionExpiryInterval 10906,PropSharedSubscriptionAvailable 79,PropSubscriptionIdentifierAvailable 173,PropSubscriptionIdentifier 32]} -TEST(Connect5QCTest, Encode7) { -uint8_t pkt[] = {0x10, 0xc7, 0x3, 0x0, 0x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, 0x75, 0x6e, 0xd8, 0xd1, 0xd4, 0xdb, 0x25, 0xc1, 0x15, 0x5b, 0xaf, 0xfa, 0xe8, 0x2, 0xd6, 0xc4, 0x29, 0x1, 0x87, 0xe, 0x9, 0x0, 0x1d, 0xd8, 0xc1, 0x4a, 0xf2, 0x4a, 0xd7, 0x8, 0xa6, 0x1c, 0xb5, 0x2c, 0x75, 0xf6, 0x57, 0x26, 0x80, 0xf5, 0x2, 0x62, 0x6f, 0x8e, 0x64, 0xba, 0xea, 0x21, 0xfa, 0x19, 0xdb, 0x88, 0x0, 0x11, 0xb8, 0x1e, 0x32, 0xaf, 0x24, 0x9, 0x2e, 0x59, 0xb0, 0x43, 0x36, 0x8b, 0x2e, 0xbc, 0xd1, 0xd0, 0xc7}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x9a, 0x28, 0x15, 0xbb, 0xd1, 0x92, 0x79, 0xfc, 0x46, 0x6, 0x6f, 0x8f, 0x9d, 0xe5, 0xd9, 0x7b, 0xae, 0x90, 0x8d, 0x7b, 0xe0}; - uint8_t bytesprops1[] = {0xb9, 0x2f, 0xa3, 0xec, 0xfc}; - uint8_t bytesprops2[] = {0x81, 0xf5, 0x4, 0xf0, 0x2, 0xe, 0x8a, 0x85}; - uint8_t bytesprops3[] = {0xb2, 0x70, 0xb9, 0x50, 0x93, 0x93, 0x3a, 0x4c, 0xd, 0x99, 0x98, 0x5b, 0xe0, 0xc9, 0x7e, 0xbb, 0x5}; - uint8_t bytesprops4[] = {0x82, 0x90, 0x14, 0x18, 0x1f, 0xf7, 0x30, 0x23, 0x24, 0x35, 0xd9, 0x85, 0xcc, 0x37, 0x9b, 0x8d, 0x61, 0x39, 0x10, 0xb, 0x74, 0x34}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25543}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22717}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6182}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26231}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10906}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 32}}, - }; - - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0}; - uint8_t byteswillprops1[] = {0xd5, 0x7f, 0x7d, 0x6b, 0x4f, 0x7f, 0x92}; - uint8_t byteswillprops2[] = {0x18, 0x2d, 0xe2, 0x40, 0x79, 0x22, 0x18, 0x3a, 0xf8, 0xb7, 0x5b, 0x44, 0x8e, 0xcc, 0x9c, 0x92, 0x55, 0x71, 0x63, 0x57, 0xbb, 0xc2, 0x79, 0xa6, 0x5f}; - uint8_t byteswillprops4[] = {0x72, 0xe8, 0xa7, 0x3d, 0x34, 0xea, 0x34, 0x4b, 0x77, 0x44, 0xea, 0xa5, 0xd, 0x66, 0xf9, 0xe2, 0x64, 0x3, 0x7d, 0xb2, 0x2, 0xfa, 0xdc, 0x56, 0xd5, 0x16}; - uint8_t byteswillprops3[] = {0xd7, 0x6f, 0x22, 0xe0}; - uint8_t byteswillprops5[] = {0x67, 0xa3, 0x87, 0x9d, 0x84, 0x88, 0x63, 0xe7}; - uint8_t byteswillprops6[] = {0}; - uint8_t byteswillprops7[] = {0xab, 0x97, 0x53, 0x93, 0x1f, 0xab, 0x86, 0x96, 0xc8, 0x18, 0x3f, 0x4a, 0x8e, 0x66, 0xaf, 0xa, 0xa2, 0x4f}; - uint8_t byteswillprops8[] = {0xba, 0x25, 0x5d, 0x11, 0x0, 0xd2, 0x63, 0xf8, 0xf, 0x67, 0x46, 0x4f, 0x65, 0x13, 0x14, 0x86, 0x61, 0x10}; - uint8_t byteswillprops9[] = {0x82, 0x26, 0xc1, 0xbc, 0x6b, 0x96, 0x79, 0x8d, 0xc6, 0x7e, 0xc4, 0x2b}; - uint8_t byteswillprops10[] = {0}; - uint8_t byteswillprops11[] = {0x64, 0x65, 0xd6, 0x4f, 0x52, 0x8b, 0xf9}; - uint8_t byteswillprops12[] = {0x6a, 0x4f}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4624}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2189}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={4, (char*)&byteswillprops3}, .v={26, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16445}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10243}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21568}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3075}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14729}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21067}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2475}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&byteswillprops12}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6987}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7409}}, - }; - - lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x6b, 0x5f, 0x68, 0x75, 0x6e, 0xd8, 0xd1, 0xd4, 0xdb, 0x25, 0xc1, 0x15, 0x5b, 0xaf, 0xfa, 0xe8, 0x2, 0xd6, 0xc4, 0x29, 0x1, 0x87, 0xe, 0x9}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd8, 0xc1, 0x4a, 0xf2, 0x4a, 0xd7, 0x8, 0xa6, 0x1c, 0xb5, 0x2c, 0x75, 0xf6, 0x57, 0x26, 0x80, 0xf5, 0x2, 0x62, 0x6f, 0x8e, 0x64, 0xba, 0xea, 0x21, 0xfa, 0x19, 0xdb, 0x88}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 12402; - uint8_t client_id_bytes[] = {0x9d, 0x14, 0xe4, 0x3d, 0x6b, 0x10, 0x35, 0x4e, 0xab, 0xb, 0x2b, 0xb9, 0xe3}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xb8, 0x1e, 0x32, 0xaf, 0x24, 0x9, 0x2e, 0x59, 0xb0, 0x43, 0x36, 0x8b, 0x2e, 0xbc, 0xd1, 0xd0, 0xc7}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; -opts.username = username; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + uint8_t will_topic_bytes[] = {0xfb, 0xc8, 0x36, 0xc7, 0xce, 0xce, 0xdc, 0x70, 0x48, 0xb, 0x97, 0xc4, 0x81, + 0x41, 0x5f, 0x86, 0x8d, 0xd7, 0xe5, 0xe, 0xbd, 0xc6, 0x6c, 0xf9, 0x3d, 0xca}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb3, 0x25, 0x6c, 0xf0, 0x8f, 0xbf, 0x3e, 0x6f, + 0xde, 0x98, 0x3, 0x64, 0xb2, 0x71, 0xa1}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 20495; + uint8_t client_id_bytes[] = {0xc7, 0xaa, 0x30, 0xd5, 0xc7, 0x36, 0x54, 0x7a, 0x34, 0x6b, 0xf7, 0xc, 0x73, 0x3b, 0xbc, + 0x6c, 0xf1, 0xe3, 0x4c, 0xb9, 0x80, 0x95, 0xa0, 0x8f, 0xe3, 0x96, 0x63, 0x37, 0xdc}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x19, 0x91}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Nothing, _password = Just "W\DC2v\185\154.x\154\183R\236\DC4\SI\179\251\231", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\230,\132\194wK\251\ENQ\NUL\154\229\223\206\215", _willMsg = "\149\250\&2EL\189\206", _willProps = [PropRequestProblemInformation 105,PropCorrelationData "F\246\131!\f\227\t^\158\DLE\242\248P\166\NAK\255\211!\146f\214\EOT",PropSubscriptionIdentifier 20,PropPayloadFormatIndicator 148,PropTopicAlias 25005,PropMaximumPacketSize 5254,PropTopicAliasMaximum 28863,PropReceiveMaximum 30544,PropResponseTopic "\142\168\205-\r\RS\"\147\202\191\"\NAK\155,\199b/^E\246",PropMaximumPacketSize 26937,PropWildcardSubscriptionAvailable 96,PropSubscriptionIdentifier 28,PropRetainAvailable 124,PropWildcardSubscriptionAvailable 54,PropReceiveMaximum 10276]}), _cleanSession = True, _keepAlive = 4527, _connID = "\140Kc\DC2\DC2\249`", _properties = [PropRetainAvailable 190,PropAuthenticationData "k\216\130 ^j\226\EM,lM\135\195l\194\176\242\158\221\200\136",PropWillDelayInterval 25782,PropRetainAvailable 150,PropTopicAliasMaximum 4604,PropSubscriptionIdentifierAvailable 176,PropPayloadFormatIndicator 130,PropReceiveMaximum 9491,PropRequestProblemInformation 146,PropMessageExpiryInterval 23140,PropServerReference "\f\186",PropWildcardSubscriptionAvailable 114]} +// ConnectRequest {_username = Nothing, _password = Just "\181\166\207", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "\140\199\a\SOH\ETX\168\245v\148k\214\201\144\139n\ENQ\170\252Z\142\205", _willMsg = +// ":*\192m\246\&0\144M\255\232<\210\138\STX\142h!j\205\162\158\"\140\190", _willProps = [PropServerKeepAlive +// 13448,PropMaximumQoS 150,PropAuthenticationData +// "&\239u#C\SOH2\160\177\198\133^8\GS\149jF,\192\228\227A\n\GST\140\247",PropReasonString +// "o",PropRequestProblemInformation 226,PropMaximumQoS 224,PropSubscriptionIdentifier 24,PropWillDelayInterval +// 2921,PropSubscriptionIdentifierAvailable 82,PropSessionExpiryInterval 24845,PropServerReference +// "\210)\GS\DLE\192O\242o\EM\186\196\208F",PropReasonString +// "\249\172a\232\229\230D\237\238\135\223\ETB%\aM\211Q\144O",PropSubscriptionIdentifier 29,PropSubscriptionIdentifier +// 5,PropMaximumQoS 213,PropAuthenticationMethod ".\143z\221\151\153\201:",PropRetainAvailable 49,PropMaximumPacketSize +// 30334]}), _cleanSession = False, _keepAlive = 19119, _connID = "\ETBB\213\133\216\235\t0\138\222\&2", _properties = +// [PropSubscriptionIdentifierAvailable 48,PropMessageExpiryInterval 25674,PropSessionExpiryInterval +// 5403,PropRequestResponseInformation 153,PropUserProperty "li\224\&3\162\fE\bD\230" +// "H#\DC1\239\218W\155\239m\198T\157eF\219\249<\251\152b",PropSessionExpiryInterval 15951,PropMessageExpiryInterval +// 16481,PropResponseTopic "\135N\252\207\135\158\250\158\185G\134:",PropSubscriptionIdentifier +// 24,PropSubscriptionIdentifier 7,PropSubscriptionIdentifier 10,PropSubscriptionIdentifierAvailable 206,PropTopicAlias +// 7630,PropWildcardSubscriptionAvailable 115,PropServerReference "4\185\SI",PropAuthenticationMethod +// "\206\ENQ\243k4Ow\153\222x\235]\203\195L\t\193y\205\155f8\ENQ\145\178\196\ENQ j",PropUserProperty +// "\135Mh\rJ\205\147\&5\191\DC3\169\208\CAN\234!\146R\ETB\214-" +// "\EOT\203M{\SOH\232=\254;\225kN2>\SOH\227",PropPayloadFormatIndicator 44,PropMessageExpiryInterval +// 3989,PropResponseTopic "d",PropContentType "M\184\DELvUAX\190\160\150\STXl\"\214\a:z\229\NUL\213"]} TEST(Connect5QCTest, Encode8) { -uint8_t pkt[] = {0x10, 0xcd, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x4e, 0x11, 0xaf, 0x39, 0x25, 0xbe, 0x16, 0x0, 0x15, 0x6b, 0xd8, 0x82, 0x20, 0x5e, 0x6a, 0xe2, 0x19, 0x2c, 0x6c, 0x4d, 0x87, 0xc3, 0x6c, 0xc2, 0xb0, 0xf2, 0x9e, 0xdd, 0xc8, 0x88, 0x18, 0x0, 0x0, 0x64, 0xb6, 0x25, 0x96, 0x22, 0x11, 0xfc, 0x29, 0xb0, 0x1, 0x82, 0x21, 0x25, 0x13, 0x17, 0x92, 0x2, 0x0, 0x0, 0x5a, 0x64, 0x1c, 0x0, 0x2, 0xc, 0xba, 0x28, 0x72, 0x0, 0x7, 0x8c, 0x4b, 0x63, 0x12, 0x12, 0xf9, 0x60, 0x54, 0x17, 0x69, 0x9, 0x0, 0x16, 0x46, 0xf6, 0x83, 0x21, 0xc, 0xe3, 0x9, 0x5e, 0x9e, 0x10, 0xf2, 0xf8, 0x50, 0xa6, 0x15, 0xff, 0xd3, 0x21, 0x92, 0x66, 0xd6, 0x4, 0xb, 0x14, 0x1, 0x94, 0x23, 0x61, 0xad, 0x27, 0x0, 0x0, 0x14, 0x86, 0x22, 0x70, 0xbf, 0x21, 0x77, 0x50, 0x8, 0x0, 0x14, 0x8e, 0xa8, 0xcd, 0x2d, 0xd, 0x1e, 0x22, 0x93, 0xca, 0xbf, 0x22, 0x15, 0x9b, 0x2c, 0xc7, 0x62, 0x2f, 0x5e, 0x45, 0xf6, 0x27, 0x0, 0x0, 0x69, 0x39, 0x28, 0x60, 0xb, 0x1c, 0x25, 0x7c, 0x28, 0x36, 0x21, 0x28, 0x24, 0x0, 0xe, 0xe6, 0x2c, 0x84, 0xc2, 0x77, 0x4b, 0xfb, 0x5, 0x0, 0x9a, 0xe5, 0xdf, 0xce, 0xd7, 0x0, 0x7, 0x95, 0xfa, 0x32, 0x45, 0x4c, 0xbd, 0xce, 0x0, 0x10, 0x57, 0x12, 0x76, 0xb9, 0x9a, 0x2e, 0x78, 0x9a, 0xb7, 0x52, 0xec, 0x14, 0xf, 0xb3, 0xfb, 0xe7}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x6b, 0xd8, 0x82, 0x20, 0x5e, 0x6a, 0xe2, 0x19, 0x2c, 0x6c, 0x4d, 0x87, 0xc3, 0x6c, 0xc2, 0xb0, 0xf2, 0x9e, 0xdd, 0xc8, 0x88}; - uint8_t bytesprops1[] = {0xc, 0xba}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25782}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4604}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9491}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23140}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 114}}, + uint8_t pkt[] = { + 0x10, 0x8f, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x74, 0x4a, 0xaf, 0xc8, 0x1, 0x29, 0x30, 0x2, 0x0, + 0x0, 0x64, 0x4a, 0x11, 0x0, 0x0, 0x15, 0x1b, 0x19, 0x99, 0x26, 0x0, 0xa, 0x6c, 0x69, 0xe0, 0x33, 0xa2, 0xc, + 0x45, 0x8, 0x44, 0xe6, 0x0, 0x14, 0x48, 0x23, 0x11, 0xef, 0xda, 0x57, 0x9b, 0xef, 0x6d, 0xc6, 0x54, 0x9d, 0x65, + 0x46, 0xdb, 0xf9, 0x3c, 0xfb, 0x98, 0x62, 0x11, 0x0, 0x0, 0x3e, 0x4f, 0x2, 0x0, 0x0, 0x40, 0x61, 0x8, 0x0, + 0xc, 0x87, 0x4e, 0xfc, 0xcf, 0x87, 0x9e, 0xfa, 0x9e, 0xb9, 0x47, 0x86, 0x3a, 0xb, 0x18, 0xb, 0x7, 0xb, 0xa, + 0x29, 0xce, 0x23, 0x1d, 0xce, 0x28, 0x73, 0x1c, 0x0, 0x3, 0x34, 0xb9, 0xf, 0x15, 0x0, 0x1d, 0xce, 0x5, 0xf3, + 0x6b, 0x34, 0x4f, 0x77, 0x99, 0xde, 0x78, 0xeb, 0x5d, 0xcb, 0xc3, 0x4c, 0x9, 0xc1, 0x79, 0xcd, 0x9b, 0x66, 0x38, + 0x5, 0x91, 0xb2, 0xc4, 0x5, 0x20, 0x6a, 0x26, 0x0, 0x14, 0x87, 0x4d, 0x68, 0xd, 0x4a, 0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0xdd, 0x97, 0x99, 0xc9, 0x3a, 0x25, + 0x31, 0x27, 0x0, 0x0, 0x76, 0x7e, 0x0, 0x15, 0x8c, 0xc7, 0x7, 0x1, 0x3, 0xa8, 0xf5, 0x76, 0x94, 0x6b, 0xd6, + 0xc9, 0x90, 0x8b, 0x6e, 0x5, 0xaa, 0xfc, 0x5a, 0x8e, 0xcd, 0x0, 0x18, 0x3a, 0x2a, 0xc0, 0x6d, 0xf6, 0x30, 0x90, + 0x4d, 0xff, 0xe8, 0x3c, 0xd2, 0x8a, 0x2, 0x8e, 0x68, 0x21, 0x6a, 0xcd, 0xa2, 0x9e, 0x22, 0x8c, 0xbe, 0x0, 0x3, + 0xb5, 0xa6, 0xcf}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x48, 0x23, 0x11, 0xef, 0xda, 0x57, 0x9b, 0xef, 0x6d, 0xc6, + 0x54, 0x9d, 0x65, 0x46, 0xdb, 0xf9, 0x3c, 0xfb, 0x98, 0x62}; + uint8_t bytesprops0[] = {0x6c, 0x69, 0xe0, 0x33, 0xa2, 0xc, 0x45, 0x8, 0x44, 0xe6}; + uint8_t bytesprops2[] = {0x87, 0x4e, 0xfc, 0xcf, 0x87, 0x9e, 0xfa, 0x9e, 0xb9, 0x47, 0x86, 0x3a}; + uint8_t bytesprops3[] = {0x34, 0xb9, 0xf}; + uint8_t bytesprops4[] = {0xce, 0x5, 0xf3, 0x6b, 0x34, 0x4f, 0x77, 0x99, 0xde, 0x78, 0xeb, 0x5d, 0xcb, 0xc3, 0x4c, + 0x9, 0xc1, 0x79, 0xcd, 0x9b, 0x66, 0x38, 0x5, 0x91, 0xb2, 0xc4, 0x5, 0x20, 0x6a}; + uint8_t bytesprops6[] = {0x4, 0xcb, 0x4d, 0x7b, 0x1, 0xe8, 0x3d, 0xfe, 0x3b, 0xe1, 0x6b, 0x4e, 0x32, 0x3e, 0x1, 0xe3}; + uint8_t bytesprops5[] = {0x87, 0x4d, 0x68, 0xd, 0x4a, 0xcd, 0x93, 0x35, 0xbf, 0x13, + 0xa9, 0xd0, 0x18, 0xea, 0x21, 0x92, 0x52, 0x17, 0xd6, 0x2d}; + uint8_t bytesprops7[] = {0x64}; + uint8_t bytesprops8[] = {0x4d, 0xb8, 0x7f, 0x76, 0x55, 0x41, 0x58, 0xbe, 0xa0, 0x96, + 0x2, 0x6c, 0x22, 0xd6, 0x7, 0x3a, 0x7a, 0xe5, 0x0, 0xd5}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25674}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5403}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15951}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16481}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7630}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops5}, .v = {16, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3989}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x46, 0xf6, 0x83, 0x21, 0xc, 0xe3, 0x9, 0x5e, 0x9e, 0x10, 0xf2, 0xf8, 0x50, 0xa6, 0x15, 0xff, 0xd3, 0x21, 0x92, 0x66, 0xd6, 0x4}; - uint8_t byteswillprops1[] = {0x8e, 0xa8, 0xcd, 0x2d, 0xd, 0x1e, 0x22, 0x93, 0xca, 0xbf, 0x22, 0x15, 0x9b, 0x2c, 0xc7, 0x62, 0x2f, 0x5e, 0x45, 0xf6}; - + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x26, 0xef, 0x75, 0x23, 0x43, 0x1, 0x32, 0xa0, 0xb1, 0xc6, 0x85, 0x5e, 0x38, 0x1d, + 0x95, 0x6a, 0x46, 0x2c, 0xc0, 0xe4, 0xe3, 0x41, 0xa, 0x1d, 0x54, 0x8c, 0xf7}; + uint8_t byteswillprops1[] = {0x6f}; + uint8_t byteswillprops2[] = {0xd2, 0x29, 0x1d, 0x10, 0xc0, 0x4f, 0xf2, 0x6f, 0x19, 0xba, 0xc4, 0xd0, 0x46}; + uint8_t byteswillprops3[] = {0xf9, 0xac, 0x61, 0xe8, 0xe5, 0xe6, 0x44, 0xed, 0xee, 0x87, + 0xdf, 0x17, 0x25, 0x7, 0x4d, 0xd3, 0x51, 0x90, 0x4f}; + uint8_t byteswillprops4[] = {0x2e, 0x8f, 0x7a, 0xdd, 0x97, 0x99, 0xc9, 0x3a}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25005}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5254}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28863}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30544}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26937}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10276}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13448}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2921}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24845}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30334}}, }; - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe6, 0x2c, 0x84, 0xc2, 0x77, 0x4b, 0xfb, 0x5, 0x0, 0x9a, 0xe5, 0xdf, 0xce, 0xd7}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x95, 0xfa, 0x32, 0x45, 0x4c, 0xbd, 0xce}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 4527; - uint8_t client_id_bytes[] = {0x8c, 0x4b, 0x63, 0x12, 0x12, 0xf9, 0x60}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x57, 0x12, 0x76, 0xb9, 0x9a, 0x2e, 0x78, 0x9a, 0xb7, 0x52, 0xec, 0x14, 0xf, 0xb3, 0xfb, 0xe7}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8c, 0xc7, 0x7, 0x1, 0x3, 0xa8, 0xf5, 0x76, 0x94, 0x6b, 0xd6, + 0xc9, 0x90, 0x8b, 0x6e, 0x5, 0xaa, 0xfc, 0x5a, 0x8e, 0xcd}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3a, 0x2a, 0xc0, 0x6d, 0xf6, 0x30, 0x90, 0x4d, 0xff, 0xe8, 0x3c, 0xd2, + 0x8a, 0x2, 0x8e, 0x68, 0x21, 0x6a, 0xcd, 0xa2, 0x9e, 0x22, 0x8c, 0xbe}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 19119; + uint8_t client_id_bytes[] = {0x17, 0x42, 0xd5, 0x85, 0xd8, 0xeb, 0x9, 0x30, 0x8a, 0xde, 0x32}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xb5, 0xa6, 0xcf}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Nothing, _password = Just "A\ESC'\139\188\167\DEL0\247\183\225\230dn1\207\&4a+\229#\149s\233\178Lz\188B", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "1\210\DC3\DC47O", _willMsg = "M\176\215\\\188\144\&2\213\199\175\GS", _willProps = [PropMessageExpiryInterval 361,PropSubscriptionIdentifier 6,PropSubscriptionIdentifier 2,PropMessageExpiryInterval 19895,PropAuthenticationData "\SI_\168\181n\245\154%L",PropTopicAliasMaximum 1020]}), _cleanSession = False, _keepAlive = 26060, _connID = "'M\238\158*c\NUL\197&]T\231\237\226\255e=\SUB]&\188\246", _properties = [PropWillDelayInterval 11494,PropAssignedClientIdentifier ",/\244\&5\ENQ\132\247\241\134\177w\SUBT\255p\SI!\t\212]\131U",PropMessageExpiryInterval 30996,PropAuthenticationData "m':\SI:\142$",PropRequestResponseInformation 238,PropSubscriptionIdentifier 30,PropRequestResponseInformation 236,PropTopicAliasMaximum 14621,PropSharedSubscriptionAvailable 236,PropMessageExpiryInterval 1407,PropMessageExpiryInterval 30953,PropSessionExpiryInterval 968,PropMaximumQoS 254,PropContentType "\237\159X!\201\EOT\r\130Ml#\a*e\249\148\227m\248\ENQ\250\188\242:d\235\181\243j",PropTopicAlias 28456,PropAuthenticationData "<",PropRequestResponseInformation 12,PropSessionExpiryInterval 13244,PropRequestResponseInformation 44,PropTopicAliasMaximum 10093,PropAuthenticationMethod "|\235\"\144\&5\180\201\&6ra\159r\199A(Gol.\GS",PropSessionExpiryInterval 31640,PropMaximumQoS 21,PropMaximumPacketSize 27543]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = +// 26405, _connID = "", _properties = [PropPayloadFormatIndicator 152,PropSessionExpiryInterval 23746]} TEST(Connect5QCTest, Encode9) { -uint8_t pkt[] = {0x10, 0x95, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x74, 0x65, 0xcc, 0x9f, 0x1, 0x18, 0x0, 0x0, 0x2c, 0xe6, 0x12, 0x0, 0x16, 0x2c, 0x2f, 0xf4, 0x35, 0x5, 0x84, 0xf7, 0xf1, 0x86, 0xb1, 0x77, 0x1a, 0x54, 0xff, 0x70, 0xf, 0x21, 0x9, 0xd4, 0x5d, 0x83, 0x55, 0x2, 0x0, 0x0, 0x79, 0x14, 0x16, 0x0, 0x7, 0x6d, 0x27, 0x3a, 0xf, 0x3a, 0x8e, 0x24, 0x19, 0xee, 0xb, 0x1e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0x27, 0x8b, 0xbc, 0xa7, 0x7f, 0x30, 0xf7, 0xb7, 0xe1, 0xe6, 0x64, 0x6e, 0x31, 0xcf, 0x34, 0x61, 0x2b, 0xe5, 0x23, 0x95, 0x73, 0xe9, 0xb2, 0x4c, 0x7a, 0xbc, 0x42}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x2c, 0x2f, 0xf4, 0x35, 0x5, 0x84, 0xf7, 0xf1, 0x86, 0xb1, 0x77, 0x1a, 0x54, 0xff, 0x70, 0xf, 0x21, 0x9, 0xd4, 0x5d, 0x83, 0x55}; - uint8_t bytesprops1[] = {0x6d, 0x27, 0x3a, 0xf, 0x3a, 0x8e, 0x24}; - uint8_t bytesprops2[] = {0xed, 0x9f, 0x58, 0x21, 0xc9, 0x4, 0xd, 0x82, 0x4d, 0x6c, 0x23, 0x7, 0x2a, 0x65, 0xf9, 0x94, 0xe3, 0x6d, 0xf8, 0x5, 0xfa, 0xbc, 0xf2, 0x3a, 0x64, 0xeb, 0xb5, 0xf3, 0x6a}; - uint8_t bytesprops3[] = {0x3c}; - uint8_t bytesprops4[] = {0x7c, 0xeb, 0x22, 0x90, 0x35, 0xb4, 0xc9, 0x36, 0x72, 0x61, 0x9f, 0x72, 0xc7, 0x41, 0x28, 0x47, 0x6f, 0x6c, 0x2e, 0x1d}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11494}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30996}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14621}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1407}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30953}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 968}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28456}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13244}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10093}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31640}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27543}}, - }; + uint8_t pkt[] = {0x10, 0x14, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2, 0x67, + 0x25, 0x7, 0x1, 0x98, 0x11, 0x0, 0x0, 0x5c, 0xc2, 0x0, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xf, 0x5f, 0xa8, 0xb5, 0x6e, 0xf5, 0x9a, 0x25, 0x4c}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 361}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19895}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1020}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23746}}, }; - lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x31, 0xd2, 0x13, 0x14, 0x37, 0x4f}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4d, 0xb0, 0xd7, 0x5c, 0xbc, 0x90, 0x32, 0xd5, 0xc7, 0xaf, 0x1d}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 26060; - uint8_t client_id_bytes[] = {0x27, 0x4d, 0xee, 0x9e, 0x2a, 0x63, 0x0, 0xc5, 0x26, 0x5d, 0x54, 0xe7, 0xed, 0xe2, 0xff, 0x65, 0x3d, 0x1a, 0x5d, 0x26, 0xbc, 0xf6}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x41, 0x1b, 0x27, 0x8b, 0xbc, 0xa7, 0x7f, 0x30, 0xf7, 0xb7, 0xe1, 0xe6, 0x64, 0x6e, 0x31, 0xcf, 0x34, 0x61, 0x2b, 0xe5, 0x23, 0x95, 0x73, 0xe9, 0xb2, 0x4c, 0x7a, 0xbc, 0x42}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 26405; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Just "\203\215'q\192;\253\158\131\"\185\255\168\f\227", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\DC3]\143\242\EOT8\146", _willMsg = "\230\207C'/^Ln\SOH\ACK\239\208\&6\227\162B~\222\142", _willProps = [PropWillDelayInterval 17500,PropRequestResponseInformation 248,PropRetainAvailable 9,PropWildcardSubscriptionAvailable 55,PropMessageExpiryInterval 31929,PropSubscriptionIdentifierAvailable 9,PropRequestProblemInformation 73,PropResponseInformation "J\176]\182\141\ng\175\165\170\191\DEL\179\177\208>IH\r\201\182z\132\150\142\228",PropRetainAvailable 202,PropReceiveMaximum 14731,PropTopicAlias 17969,PropRetainAvailable 131,PropReasonString "\178",PropTopicAlias 22210,PropAuthenticationData "\216\&88\168tf",PropSubscriptionIdentifierAvailable 158]}), _cleanSession = False, _keepAlive = 18009, _connID = "\223\157;e\ACKs*\NUL\134N\151K\212g\170", _properties = [PropReceiveMaximum 1627,PropReasonString "X\161\197!\DC2?\214FK \195W~\199'b",PropServerReference "\US\135\141Xj\ESC\NUL\169\155\161*\143\156\177)\158> \148\DC4\173N\139\197\189B\198\170T",PropMaximumPacketSize 23850,PropSharedSubscriptionAvailable 158,PropMaximumQoS 85,PropServerKeepAlive 3440,PropResponseTopic "\134]\241\ENQ\243\&1\180l+\137\132\220\FSQ\243tky\EOTD@\216m\134Z<`\255G\149",PropSubscriptionIdentifier 7,PropMessageExpiryInterval 9423,PropSubscriptionIdentifier 16,PropMaximumPacketSize 31638,PropWildcardSubscriptionAvailable 226,PropServerReference "\145\128\137\173h\DC1s\129\251\210\184",PropReceiveMaximum 29008,PropMaximumPacketSize 9586,PropTopicAlias 11288,PropSubscriptionIdentifier 25,PropTopicAliasMaximum 16372,PropAuthenticationMethod "A\187\EOT\132\169]\244\205",PropWildcardSubscriptionAvailable 83]} +// ConnectRequest {_username = Just "\244\160\221\&0\230\206m\172", _password = Just +// "\165\183%\251X.>\250\DC2jTpG*a)\199u\169\200c\ETB\200\246\180\&5\171\157S\185", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\189>\247Z\247\130\236\149k\150\218\181\\-Za%\"\153\153\249\154\229\155\174\154", _willMsg = +// "1\183yF.\202\190\&0\172\233\196\243\200;e\233\133N\232/T\223\157-)\ESC\144\SYN9", _willProps = +// [PropTopicAliasMaximum 21011,PropPayloadFormatIndicator 123,PropRequestProblemInformation +// 20,PropRequestProblemInformation 143,PropReasonString +// "\141#\208\DC2HkV<\234\254$3\170",PropRequestResponseInformation 83,PropRequestResponseInformation +// 118,PropUserProperty "4\199{\243" "d\176\165\FSn\GSU\190\172\207\167\223\EOT\198i\NAK\NAKu\SI\",",PropReceiveMaximum +// 20984,PropServerReference "qEm\240\141",PropMaximumPacketSize 19400,PropReasonString +// "\v\162\ACKi*\187\143\166l\ENQ&e\255\185C\DEL\169",PropSharedSubscriptionAvailable +// 161,PropAuthenticationData "\156\202~\SUB\159P\241\&2X\182\144\170\227{",PropSharedSubscriptionAvailable +// 175,PropTopicAliasMaximum 18891]}), _cleanSession = True, _keepAlive = 26688, _connID = +// "\246\249\133]\247\EOTD,\146\246\247\159\145\&1O\239Y\129\183+\237\ACK\b", _properties = [PropCorrelationData +// "\241s\SUB\SOH\185",PropRetainAvailable 188,PropSessionExpiryInterval 18205,PropResponseInformation +// "\236\DC2\207\159j\181\SIF\129\EMvRdc\241\240}_ e\199\252\133X\135",PropRequestResponseInformation +// 20,PropWildcardSubscriptionAvailable 141,PropRequestProblemInformation 245]} TEST(Connect5QCTest, Encode10) { -uint8_t pkt[] = {0x10, 0xb8, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xac, 0x46, 0x59, 0x9e, 0x1, 0x21, 0x6, 0x5b, 0x1f, 0x0, 0x10, 0x58, 0xa1, 0xc5, 0x21, 0x12, 0x3f, 0xd6, 0x46, 0x4b, 0x20, 0xc3, 0x57, 0x7e, 0xc7, 0x27, 0x62, 0x1c, 0x0, 0x1d, 0x1f, 0x87, 0x8d, 0x58, 0x6a, 0x1b, 0x0, 0xa9, 0x9b, 0xa1, 0x2a, 0x8f, 0x9c, 0xb1, 0x29, 0x9e, 0x3e, 0x20, 0x94, 0x14, 0xad, 0x4e, 0x8b, 0xc5, 0xbd, 0x42, 0xc6, 0xaa, 0x54, 0x27, 0x0, 0x0, 0x5d, 0x2a, 0x2a, 0x9e, 0x24, 0x55, 0x13, 0xd, 0x70, 0x8, 0x0, 0x1e, 0x86, 0x5d, 0xf1, 0x5, 0xf3, 0x31, 0xb4, 0x6c, 0x2b, 0x89, 0x84, 0xdc, 0x1c, 0x51, 0xf3, 0x74, 0x6b, 0x79, 0x4, 0x44, 0x40, 0xd8, 0x6d, 0x86, 0x5a, 0x3c, 0x60, 0xff, 0x47, 0x95, 0xb, 0x7, 0x2, 0x0, 0x0, 0x24, 0xcf, 0xb, 0x10, 0x27, 0x0, 0x0, 0x7b, 0x96, 0x28, 0xe2, 0x1c, 0x0, 0xb, 0x91, 0x80, 0x89, 0xad, 0x68, 0x11, 0x73, 0x81, 0xfb, 0xd2, 0xb8, 0x21, 0x71, 0x50, 0x27, 0x0, 0x0, 0x25, 0x72, 0x23, 0x2c, 0x18, 0xb, 0x19, 0x22,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58, 0x6a, 0x1b, 0x0, 0xa9, 0x9b, 0xa1, 0x2a, 0x8f, 0x9c, 0xb1, 0x29, 0x9e, 0x3e, 0x20, 0x94, 0x14, 0xad, 0x4e, 0x8b, 0xc5, 0xbd, 0x42, 0xc6, 0xaa, 0x54}; - uint8_t bytesprops2[] = {0x86, 0x5d, 0xf1, 0x5, 0xf3, 0x31, 0xb4, 0x6c, 0x2b, 0x89, 0x84, 0xdc, 0x1c, 0x51, 0xf3, 0x74, 0x6b, 0x79, 0x4, 0x44, 0x40, 0xd8, 0x6d, 0x86, 0x5a, 0x3c, 0x60, 0xff, 0x47, 0x95}; - uint8_t bytesprops3[] = {0x91, 0x80, 0x89, 0xad, 0x68, 0x11, 0x73, 0x81, 0xfb, 0xd2, 0xb8}; - uint8_t bytesprops4[] = {0x41, 0xbb, 0x4, 0x84, 0xa9, 0x5d, 0xf4, 0xcd}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1627}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23850}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3440}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9423}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31638}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29008}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9586}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11288}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16372}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 83}}, + uint8_t pkt[] = { + 0x10, 0xdc, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x68, 0x40, 0x31, 0x9, 0x0, 0x5, 0xf1, 0x73, + 0x1a, 0x1, 0xb9, 0x25, 0xbc, 0x11, 0x0, 0x0, 0x47, 0x1d, 0x1a, 0x0, 0x19, 0xec, 0x12, 0xcf, 0x9f, 0x6a, 0xb5, + 0xf, 0x46, 0x81, 0x19, 0x76, 0x52, 0x64, 0x63, 0xf1, 0xf0, 0x7d, 0x5f, 0x20, 0x65, 0xc7, 0xfc, 0x85, 0x58, 0x87, + 0x19, 0x14, 0x28, 0x8d, 0x17, 0xf5, 0x0, 0x17, 0xf6, 0xf9, 0x85, 0x5d, 0xf7, 0x4, 0x44, 0x2c, 0x92, 0xf6, 0xf7, + 0x9f, 0x91, 0x31, 0x4f, 0xef, 0x59, 0x81, 0xb7, 0x2b, 0xed, 0x6, 0x8, 0xa0, 0x1, 0x22, 0x52, 0x13, 0x1, 0x7b, + 0x17, 0x14, 0x17, 0x8f, 0x1f, 0x0, 0xd, 0x8d, 0x23, 0xd0, 0x12, 0x48, 0x6b, 0x56, 0x3c, 0xea, 0xfe, 0x24, 0x33, + 0xaa, 0x19, 0x53, 0x19, 0x76, 0x26, 0x0, 0x4, 0x34, 0xc7, 0x7b, 0xf3, 0x0, 0x15, 0x64, 0xb0, 0xa5, 0x1c, 0x6e, + 0x1d, 0x55, 0xbe, 0xac, 0xcf, 0xa7, 0xdf,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, 0x58, 0x2e, 0x3e, 0xfa, 0x12, 0x6a, 0x54, 0x70, 0x47, 0x2a, 0x61, 0x29, 0xc7, 0x75, 0xa9, 0xc8, 0x63, + 0x17, 0xc8, 0xf6, 0xb4, 0x35, 0xab, 0x9d, 0x53, 0xb9}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf1, 0x73, 0x1a, 0x1, 0xb9}; + uint8_t bytesprops1[] = {0xec, 0x12, 0xcf, 0x9f, 0x6a, 0xb5, 0xf, 0x46, 0x81, 0x19, 0x76, 0x52, 0x64, + 0x63, 0xf1, 0xf0, 0x7d, 0x5f, 0x20, 0x65, 0xc7, 0xfc, 0x85, 0x58, 0x87}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18205}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 245}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x4a, 0xb0, 0x5d, 0xb6, 0x8d, 0xa, 0x67, 0xaf, 0xa5, 0xaa, 0xbf, 0x7f, 0xb3, 0xb1, 0xd0, 0x3e, 0x49, 0x48, 0xd, 0xc9, 0xb6, 0x7a, 0x84, 0x96, 0x8e, 0xe4}; - uint8_t byteswillprops1[] = {0xb2}; - uint8_t byteswillprops2[] = {0xd8, 0x38, 0x38, 0xa8, 0x74, 0x66}; - + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x8d, 0x23, 0xd0, 0x12, 0x48, 0x6b, 0x56, 0x3c, 0xea, 0xfe, 0x24, 0x33, 0xaa}; + uint8_t byteswillprops2[] = {0x64, 0xb0, 0xa5, 0x1c, 0x6e, 0x1d, 0x55, 0xbe, 0xac, 0xcf, 0xa7, + 0xdf, 0x4, 0xc6, 0x69, 0x15, 0x15, 0x75, 0xf, 0x22, 0x2c}; + uint8_t byteswillprops1[] = {0x34, 0xc7, 0x7b, 0xf3}; + uint8_t byteswillprops3[] = {0x71, 0x45, 0x6d, 0xf0, 0x8d}; + uint8_t byteswillprops4[] = {0xb, 0xa2, 0x6, 0x69, 0x2a, 0xbb, 0x8f, 0x3c, 0x76, 0xc1, 0x49, 0x10, 0x93, + 0x79, 0x93, 0xf3, 0xd6, 0x23, 0x67, 0x72, 0x5d, 0x4c, 0xcb, 0x38, 0x67}; + uint8_t byteswillprops5[] = {0x80, 0x44, 0x21, 0x49, 0xdd, 0x15, 0x53, 0xa2, 0x9d, 0x94, 0xce, 0x58, 0x3a, + 0xd2, 0x3e, 0xa6, 0x6c, 0x5, 0x26, 0x65, 0xff, 0xb9, 0x43, 0x7f, 0xa9}; + uint8_t byteswillprops6[] = {0x9c, 0xca, 0x7e, 0x1a, 0x9f, 0x50, 0xf1, 0x32, 0x58, 0xb6, 0x90, 0xaa, 0xe3, 0x7b}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17500}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31929}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14731}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17969}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22210}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, - }; - - lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x13, 0x5d, 0x8f, 0xf2, 0x4, 0x38, 0x92}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe6, 0xcf, 0x43, 0x27, 0x2f, 0x5e, 0x4c, 0x6e, 0x1, 0x6, 0xef, 0xd0, 0x36, 0xe3, 0xa2, 0x42, 0x7e, 0xde, 0x8e}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 18009; - uint8_t client_id_bytes[] = {0xdf, 0x9d, 0x3b, 0x65, 0x6, 0x73, 0x2a, 0x0, 0x86, 0x4e, 0x97, 0x4b, 0xd4, 0x67, 0xaa}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xcb, 0xd7, 0x27, 0x71, 0xc0, 0x3b, 0xfd, 0x9e, 0x83, 0x22, 0xb9, 0xff, 0xa8, 0xc, 0xe3}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; -opts.username = username; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21011}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {4, (char*)&byteswillprops1}, .v = {21, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20984}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19400}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7054}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18891}}, + }; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xbd, 0x3e, 0xf7, 0x5a, 0xf7, 0x82, 0xec, 0x95, 0x6b, 0x96, 0xda, 0xb5, 0x5c, + 0x2d, 0x5a, 0x61, 0x25, 0x22, 0x99, 0x99, 0xf9, 0x9a, 0xe5, 0x9b, 0xae, 0x9a}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x31, 0xb7, 0x79, 0x46, 0x2e, 0xca, 0xbe, 0x30, 0xac, 0xe9, + 0xc4, 0xf3, 0xc8, 0x3b, 0x65, 0xe9, 0x85, 0x4e, 0xe8, 0x2f, + 0x54, 0xdf, 0x9d, 0x2d, 0x29, 0x1b, 0x90, 0x16, 0x39}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 26688; + uint8_t client_id_bytes[] = {0xf6, 0xf9, 0x85, 0x5d, 0xf7, 0x4, 0x44, 0x2c, 0x92, 0xf6, 0xf7, 0x9f, + 0x91, 0x31, 0x4f, 0xef, 0x59, 0x81, 0xb7, 0x2b, 0xed, 0x6, 0x8}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xf4, 0xa0, 0xdd, 0x30, 0xe6, 0xce, 0x6d, 0xac}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xa5, 0xb7, 0x25, 0xfb, 0x58, 0x2e, 0x3e, 0xfa, 0x12, 0x6a, 0x54, 0x70, 0x47, 0x2a, 0x61, + 0x29, 0xc7, 0x75, 0xa9, 0xc8, 0x63, 0x17, 0xc8, 0xf6, 0xb4, 0x35, 0xab, 0x9d, 0x53, 0xb9}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Nothing, _password = Just "\SOH\169\149X", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\185\164\201\218\t\RS\138w4\237\150O\188z}W", _willMsg = "<\195\167\FSW", _willProps = [PropPayloadFormatIndicator 255,PropUserProperty "\215" "\STX\189\169",PropServerKeepAlive 27782,PropMaximumPacketSize 28886,PropRetainAvailable 47,PropReceiveMaximum 31815,PropRequestProblemInformation 167,PropServerKeepAlive 25282,PropRequestProblemInformation 12,PropServerKeepAlive 19094,PropReasonString "u\155\199\&5U-Z\181\184\151q\224qP'\239\b\DLE\227\209\na\170\STXaF=",PropServerKeepAlive 5566,PropCorrelationData "+\226l\248\162A\250\166\143dtz",PropSubscriptionIdentifier 14]}), _cleanSession = True, _keepAlive = 29930, _connID = "\b7o\203\f\197", _properties = [PropContentType "wK\207_@",PropMessageExpiryInterval 23707,PropSubscriptionIdentifier 25,PropMessageExpiryInterval 32685,PropSubscriptionIdentifierAvailable 45,PropResponseInformation "\160>dD=fT\232\180|\252^\209\181W\141\149\GS-F4b\247\EM\n\228",PropMaximumPacketSize 16566,PropPayloadFormatIndicator 169,PropPayloadFormatIndicator 237,PropAuthenticationData "\205\ESC\182N\221g.\ACK\155\143\221!}XZW\222\219\249\158=\176F1",PropSubscriptionIdentifierAvailable 210,PropServerKeepAlive 7363,PropWillDelayInterval 406,PropServerReference "Gc\rt\190\198\rv\184\245\SI\145C\NUL\240\219\SOj\230",PropSessionExpiryInterval 26332,PropResponseTopic "\226z\145r\204\214K\173\216\234H06",PropAuthenticationData "x\210\209C\129\r`\132",PropServerKeepAlive 16373,PropMaximumQoS 223,PropMaximumQoS 215,PropMessageExpiryInterval 12607,PropRetainAvailable 161,PropRequestProblemInformation 185]} +// ConnectRequest {_username = Just "\169\&9\US\187\DC1", _password = Just +// "\184\193\180:Dky-1\229\177\RS\US\181{h{\187\237\157K\222kRL\242Z\NAK\214", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS1, _willTopic = "", _willMsg = +// "\251Q\218\169\218\207sq\185c\DC2s\f\\\246'R\RS%\242v\DEL\204f\195I\159`&", _willProps = [PropTopicAliasMaximum +// 15405,PropContentType "P\SYN\DC1\138#\160",PropContentType +// "\143\201\248\243\nw\199\239K\222\220\212*\214",PropRetainAvailable 216,PropCorrelationData +// "\191'y\249\165",PropRetainAvailable 244,PropRetainAvailable 188,PropRequestProblemInformation +// 147,PropAssignedClientIdentifier "\201\144\247\SUB\202\157\134\253"]}), _cleanSession = False, _keepAlive = 13305, +// _connID = "\207\241K\128\152Q\EMw\238\135PC\202L\142.\156)~\213\212\205", _properties = [PropResponseInformation +// "N=n$B",PropAuthenticationMethod "\148\253\&3\234lDj\215H\221%f\163",PropTopicAlias 28755,PropResponseInformation +// "\151A+\DC3l\128",PropSharedSubscriptionAvailable 222,PropTopicAliasMaximum 5186,PropTopicAliasMaximum +// 24871,PropTopicAliasMaximum 3490,PropPayloadFormatIndicator 220,PropCorrelationData +// "\166s\142\137\&4;\237\202J\213J\158\204\163\152\177!5\234}\143\SUB\DC4\142"]} TEST(Connect5QCTest, Encode11) { -uint8_t pkt[] = {0x10, 0xaf, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6e, 0x74, 0xea, 0xa7, 0x1, 0x3, 0x0, 0x5, 0x77, 0x4b, 0xcf, 0x5f, 0x40, 0x2, 0x0, 0x0, 0x5c, 0x9b, 0xb, 0x19, 0x2, 0x0, 0x0, 0x7f, 0xad, 0x29, 0x2d, 0x1a, 0x0, 0x1a, 0xa0, 0x3e, 0x64, 0x44, 0x3d, 0x66, 0x54, 0xe8, 0xb4, 0x7c, 0xfc, 0x5e, 0xd1, 0xb5, 0x57, 0x8d, 0x95, 0x1d, 0x2d, 0x46, 0x34, 0x62, 0xf7, 0x19, 0xa, 0xe4, 0x27, 0x0, 0x0, 0x40, 0xb6, 0x1, 0xa9, 0x1, 0xed, 0x16, 0x0, 0x18, 0xcd, 0x1b, 0xb6, 0x4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x74, 0x7a, 0xb, 0xe, 0x0, 0x10, 0xb9, 0xa4, 0xc9, 0xda, 0x9, 0x1e, 0x8a, 0x77, 0x34, 0xed, 0x96, 0x4f, 0xbc, 0x7a, 0x7d, 0x57, 0x0, 0x5, 0x3c, 0xc3, 0xa7, 0x1c, 0x57, 0x0, 0x4, 0x1, 0xa9, 0x95, 0x58}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x77, 0x4b, 0xcf, 0x5f, 0x40}; - uint8_t bytesprops1[] = {0xa0, 0x3e, 0x64, 0x44, 0x3d, 0x66, 0x54, 0xe8, 0xb4, 0x7c, 0xfc, 0x5e, 0xd1, 0xb5, 0x57, 0x8d, 0x95, 0x1d, 0x2d, 0x46, 0x34, 0x62, 0xf7, 0x19, 0xa, 0xe4}; - uint8_t bytesprops2[] = {0xcd, 0x1b, 0xb6, 0x4e, 0xdd, 0x67, 0x2e, 0x6, 0x9b, 0x8f, 0xdd, 0x21, 0x7d, 0x58, 0x5a, 0x57, 0xde, 0xdb, 0xf9, 0x9e, 0x3d, 0xb0, 0x46, 0x31}; - uint8_t bytesprops3[] = {0x47, 0x63, 0xd, 0x74, 0xbe, 0xc6, 0xd, 0x76, 0xb8, 0xf5, 0xf, 0x91, 0x43, 0x0, 0xf0, 0xdb, 0xe, 0x6a, 0xe6}; - uint8_t bytesprops4[] = {0xe2, 0x7a, 0x91, 0x72, 0xcc, 0xd6, 0x4b, 0xad, 0xd8, 0xea, 0x48, 0x30, 0x36}; - uint8_t bytesprops5[] = {0x78, 0xd2, 0xd1, 0x43, 0x81, 0xd, 0x60, 0x84}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23707}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32685}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16566}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7363}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 406}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26332}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16373}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12607}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 185}}, + uint8_t pkt[] = { + 0x10, 0xef, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x33, 0xf9, 0x4c, 0x1a, 0x0, 0x5, 0x4e, 0x3d, + 0x6e, 0x24, 0x42, 0x15, 0x0, 0xd, 0x94, 0xfd, 0x33, 0xea, 0x6c, 0x44, 0x6a, 0xd7, 0x48, 0xdd, 0x25, 0x66, 0xa3, + 0x23, 0x70, 0x53, 0x1a, 0x0, 0x6, 0x97, 0x41, 0x2b, 0x13, 0x6c, 0x80, 0x2a, 0xde, 0x22, 0x14, 0x42, 0x22, 0x61, + 0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uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x4e, 0x3d, 0x6e, 0x24, 0x42}; + uint8_t bytesprops1[] = {0x94, 0xfd, 0x33, 0xea, 0x6c, 0x44, 0x6a, 0xd7, 0x48, 0xdd, 0x25, 0x66, 0xa3}; + uint8_t bytesprops2[] = {0x97, 0x41, 0x2b, 0x13, 0x6c, 0x80}; + uint8_t bytesprops3[] = {0xa6, 0x73, 0x8e, 0x89, 0x34, 0x3b, 0xed, 0xca, 0x4a, 0xd5, 0x4a, 0x9e, + 0xcc, 0xa3, 0x98, 0xb1, 0x21, 0x35, 0xea, 0x7d, 0x8f, 0x1a, 0x14, 0x8e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28755}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5186}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24871}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3490}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x2, 0xbd, 0xa9}; - uint8_t byteswillprops0[] = {0xd7}; - uint8_t byteswillprops2[] = {0x75, 0x9b, 0xc7, 0x35, 0x55, 0x2d, 0x5a, 0xb5, 0xb8, 0x97, 0x71, 0xe0, 0x71, 0x50, 0x27, 0xef, 0x8, 0x10, 0xe3, 0xd1, 0xa, 0x61, 0xaa, 0x2, 0x61, 0x46, 0x3d}; - uint8_t byteswillprops3[] = {0x2b, 0xe2, 0x6c, 0xf8, 0xa2, 0x41, 0xfa, 0xa6, 0x8f, 0x64, 0x74, 0x7a}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={1, (char*)&byteswillprops0}, .v={3, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27782}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28886}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31815}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25282}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19094}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5566}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - }; - - lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb9, 0xa4, 0xc9, 0xda, 0x9, 0x1e, 0x8a, 0x77, 0x34, 0xed, 0x96, 0x4f, 0xbc, 0x7a, 0x7d, 0x57}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3c, 0xc3, 0xa7, 0x1c, 0x57}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 29930; - uint8_t client_id_bytes[] = {0x8, 0x37, 0x6f, 0xcb, 0xc, 0xc5}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x1, 0xa9, 0x95, 0x58}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x50, 0x16, 0x11, 0x8a, 0x23, 0xa0}; + uint8_t byteswillprops1[] = {0x8f, 0xc9, 0xf8, 0xf3, 0xa, 0x77, 0xc7, 0xef, 0x4b, 0xde, 0xdc, 0xd4, 0x2a, 0xd6}; + uint8_t byteswillprops2[] = {0xbf, 0x27, 0x79, 0xf9, 0xa5}; + uint8_t byteswillprops3[] = {0xc9, 0x90, 0xf7, 0x1a, 0xca, 0x9d, 0x86, 0xfd}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15405}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&byteswillprops3}}}, + }; + + lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfb, 0x51, 0xda, 0xa9, 0xda, 0xcf, 0x73, 0x71, 0xb9, 0x63, + 0x12, 0x73, 0xc, 0x5c, 0xf6, 0x27, 0x52, 0x1e, 0x25, 0xf2, + 0x76, 0x7f, 0xcc, 0x66, 0xc3, 0x49, 0x9f, 0x60, 0x26}; + lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 13305; + uint8_t client_id_bytes[] = {0xcf, 0xf1, 0x4b, 0x80, 0x98, 0x51, 0x19, 0x77, 0xee, 0x87, 0x50, + 0x43, 0xca, 0x4c, 0x8e, 0x2e, 0x9c, 0x29, 0x7e, 0xd5, 0xd4, 0xcd}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa9, 0x39, 0x1f, 0xbb, 0x11}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xb8, 0xc1, 0xb4, 0x3a, 0x44, 0x6b, 0x79, 0x2d, 0x31, 0xe5, 0xb1, 0x1e, 0x1f, 0xb5, 0x7b, + 0x68, 0x7b, 0xbb, 0xed, 0x9d, 0x4b, 0xde, 0x6b, 0x52, 0x4c, 0xf2, 0x5a, 0x15, 0xd6}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Just "xj\DC2d\147j\242\141\DC1\253\179o\188", _password = Just "\144\238/&m", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\191\197a\194u\133\135\244\211\170\162\129\161\&6\225\&2", _willMsg = "\218\f", _willProps = [PropPayloadFormatIndicator 192,PropTopicAliasMaximum 11735,PropWildcardSubscriptionAvailable 161,PropWillDelayInterval 8437,PropRequestResponseInformation 154,PropRequestResponseInformation 0,PropRequestProblemInformation 121,PropTopicAlias 5703,PropMessageExpiryInterval 30855,PropServerKeepAlive 21347,PropAssignedClientIdentifier "\232\&70\185N\179E\n]\254b/fTX\DC1C\167Au{\f\234\137",PropRequestProblemInformation 98,PropPayloadFormatIndicator 8]}), _cleanSession = False, _keepAlive = 15412, _connID = "\176\143\160_\\\166\148\213\226\224\CAN>\238\v\168\163", _properties = [PropAssignedClientIdentifier "\146\ETB<\248$\206\222\226\t\163_",PropMessageExpiryInterval 5227,PropTopicAlias 787,PropMaximumQoS 108,PropResponseInformation "K\161qr\DC4\207\217\225\185\142A)\188\&9^\175\244\130&}\225\204d\b\184\167\225\STX\b\151",PropContentType "\189 ",PropMessageExpiryInterval 19245,PropRequestProblemInformation 210,PropSessionExpiryInterval 32723,PropRequestResponseInformation 208,PropTopicAliasMaximum 32403,PropSessionExpiryInterval 11781,PropMaximumPacketSize 27425,PropMessageExpiryInterval 21128,PropRequestProblemInformation 119,PropAuthenticationData "\249\DLE\224\255\SOH\171l.`\165O\179\&9\NUL\246\180\148\&9\221\STX\r\159",PropServerReference "_\218\138\225p\ETX\STX\202\157X",PropResponseTopic "\150\135\239hji\149\DC26\153\190\201\253Y/\252\167\242.J=z\161\200\DC3",PropPayloadFormatIndicator 251]} +// ConnectRequest {_username = Just "\245\186\233\209\154JNY{\148\171\215\226hh\DELD\236\162\206", _password = Nothing, +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "J}|\FS", _willMsg = +// "\230\222{\SO\US\159a\182$\177", _willProps = [PropMessageExpiryInterval 4088,PropRequestProblemInformation +// 130,PropUserProperty "" +// "\206\181\146H\171\228*)\DC4_\149mx\186p\250\139\a\247\&5\211<@\158\201\173\237\189\NAK\211",PropServerReference +// "o\249\169C,\204\240I\226y7\171w\220\134\166\251\n\151\n\f\181\GS\USj\STXl",PropAuthenticationMethod +// "OgTi\139\173*|\228\227^\134F9j\DC3\144s",PropResponseTopic "\206",PropTopicAliasMaximum +// 21517,PropSessionExpiryInterval 25122,PropAuthenticationMethod "\176\176\160\155",PropCorrelationData +// "\ENQU=\165t",PropPayloadFormatIndicator 146,PropAuthenticationData "\176\192\DC4a\v!\176\171 +// \"(\150\151`\228\ENQ\246\193(",PropSessionExpiryInterval 9859,PropWillDelayInterval 11824,PropTopicAliasMaximum +// 7159,PropTopicAlias 15943,PropReasonString +// "k\253`-\141\224\153\SYN\215\158\&5\198{\170\USc)\STX\136\f\161\231,D\249)6\190F\233",PropTopicAliasMaximum +// 12331,PropContentType "^\DC2\182\242\220\248\138\173!\n&\251]8\146\226\214\129.\DC4hD",PropResponseInformation +// "\136(\136\165\189WO:P\143\191\248\&6.\143w\178",PropRequestResponseInformation 160,PropRetainAvailable +// 205,PropContentType "\243\150\&4\251\&2-\140\136\134VF\201\146\224\GS&\159",PropPayloadFormatIndicator +// 166,PropSessionExpiryInterval 31689,PropAuthenticationData +// "X\154\182\229\146\253;t\DC3\195~@\b<_",PropMessageExpiryInterval 32000,PropUserProperty "\US1\v8\225\204$" +// "\184\160\210\221\161\&6\205[\200\182V\232~\208\153M\201(\178b"]}), _cleanSession = False, _keepAlive = 17990, +// _connID = "\164\DC3\215\130\131\167\153>\200\244\244\GS\132\139\&8", _properties = [PropRequestResponseInformation +// 229,PropRetainAvailable 133,PropMessageExpiryInterval 27253,PropContentType +// "\179\241UJ\240\223\SI\168}\246:2u\134Vgh\236"]} TEST(Connect5QCT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c, 0xa6, 0x94, 0xd5, 0xe2, 0xe0, 0x18, 0x3e, 0xee, 0xb, 0xa8, 0xa3, 0x3c, 0x1, 0xc0, 0x22, 0x2d, 0xd7, 0x28, 0xa1, 0x18, 0x0, 0x0, 0x20, 0xf5, 0x19, 0x9a, 0x19, 0x0, 0x17, 0x79, 0x23, 0x16, 0x47, 0x2, 0x0, 0x0, 0x78, 0x87, 0x13, 0x53, 0x63, 0x12, 0x0, 0x18, 0xe8, 0x37, 0x30, 0xb9, 0x4e, 0xb3, 0x45, 0xa, 0x5d, 0xfe, 0x62, 0x2f, 0x66, 0x54, 0x58, 0x11, 0x43, 0xa7, 0x41, 0x75, 0x7b, 0xc, 0xea, 0x89, 0x17, 0x62, 0x1, 0x8, 0x0, 0x10, 0xbf, 0xc5, 0x61, 0xc2, 0x75, 0x85, 0x87, 0xf4, 0xd3, 0xaa, 0xa2, 0x81, 0xa1, 0x36, 0xe1, 0x32, 0x0, 0x2, 0xda, 0xc, 0x0, 0xd, 0x78, 0x6a, 0x12, 0x64, 0x93, 0x6a, 0xf2, 0x8d, 0x11, 0xfd, 0xb3, 0x6f, 0xbc, 0x0, 0x5, 0x90, 0xee, 0x2f, 0x26, 0x6d}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x92, 0x17, 0x3c, 0xf8, 0x24, 0xce, 0xde, 0xe2, 0x9, 0xa3, 0x5f}; - uint8_t bytesprops1[] = {0x4b, 0xa1, 0x71, 0x72, 0x14, 0xcf, 0xd9, 0xe1, 0xb9, 0x8e, 0x41, 0x29, 0xbc, 0x39, 0x5e, 0xaf, 0xf4, 0x82, 0x26, 0x7d, 0xe1, 0xcc, 0x64, 0x8, 0xb8, 0xa7, 0xe1, 0x2, 0x8, 0x97}; - uint8_t bytesprops2[] = {0xbd, 0x20}; - uint8_t bytesprops3[] = {0xf9, 0x10, 0xe0, 0xff, 0x1, 0xab, 0x6c, 0x2e, 0x60, 0xa5, 0x4f, 0xb3, 0x39, 0x0, 0xf6, 0xb4, 0x94, 0x39, 0xdd, 0x2, 0xd, 0x9f}; - uint8_t bytesprops4[] = {0x5f, 0xda, 0x8a, 0xe1, 0x70, 0x3, 0x2, 0xca, 0x9d, 0x58}; - uint8_t bytesprops5[] = {0x96, 0x87, 0xef, 0x68, 0x6a, 0x69, 0x95, 0x12, 0x36, 0x99, 0xbe, 0xc9, 0xfd, 0x59, 0x2f, 0xfc, 0xa7, 0xf2, 0x2e, 0x4a, 0x3d, 0x7a, 0xa1, 0xc8, 0x13}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5227}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 787}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19245}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32723}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32403}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11781}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27425}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21128}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte =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 0xd2, 0xdd, 0xa1, 0x36, 0xcd, 0x5b, 0xc8, 0xb6, + 0x56, 0xe8, 0x7e, 0xd0, 0x99, 0x4d, 0xc9, 0x28, 0xb2, 0x62, 0x0, 0x4, 0x4a, 0x7d, 0x7c, 0x1c, 0x0, 0xa, 0xe6, + 0xde, 0x7b, 0xe, 0x1f, 0x9f, 0x61, 0xb6, 0x24, 0xb1, 0x0, 0x14, 0xf5, 0xba, 0xe9, 0xd1, 0x9a, 0x4a, 0x4e, 0x59, + 0x7b, 0x94, 0xab, 0xd7, 0xe2, 0x68, 0x68, 0x7f, 0x44, 0xec, 0xa2, 0xce}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb3, 0xf1, 0x55, 0x4a, 0xf0, 0xdf, 0xf, 0xa8, 0x7d, + 0xf6, 0x3a, 0x32, 0x75, 0x86, 0x56, 0x67, 0x68, 0xec}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27253}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe8, 0x37, 0x30, 0xb9, 0x4e, 0xb3, 0x45, 0xa, 0x5d, 0xfe, 0x62, 0x2f, 0x66, 0x54, 0x58, 0x11, 0x43, 0xa7, 0x41, 0x75, 0x7b, 0xc, 0xea, 0x89}; - + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xce, 0xb5, 0x92, 0x48, 0xab, 0xe4, 0x2a, 0x29, 0x14, 0x5f, + 0x95, 0x6d, 0x78, 0xba, 0x70, 0xfa, 0x8b, 0x7, 0xf7, 0x35, + 0xd3, 0x3c, 0x40, 0x9e, 0xc9, 0xad, 0xed, 0xbd, 0x15, 0xd3}; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops2[] = {0x6f, 0xf9, 0xa9, 0x43, 0x2c, 0xcc, 0xf0, 0x49, 0xe2, 0x79, 0x37, 0xab, 0x77, 0xdc, + 0x86, 0xa6, 0xfb, 0xa, 0x97, 0xa, 0xc, 0xb5, 0x1d, 0x1f, 0x6a, 0x2, 0x6c}; + uint8_t byteswillprops3[] = {0x4f, 0x67, 0x54, 0x69, 0x8b, 0xad, 0x2a, 0x7c, 0xe4, + 0xe3, 0x5e, 0x86, 0x46, 0x39, 0x6a, 0x13, 0x90, 0x73}; + uint8_t byteswillprops4[] = {0xce}; + uint8_t byteswillprops5[] = {0xb0, 0xb0, 0xa0, 0x9b}; + uint8_t byteswillprops6[] = {0x5, 0x55, 0x3d, 0xa5, 0x74}; + uint8_t byteswillprops7[] = {0xb0, 0xc0, 0x14, 0x61, 0xb, 0x21, 0xb0, 0xab, 0x20, 0x22, + 0x28, 0x96, 0x97, 0x60, 0xe4, 0x5, 0xf6, 0xc1, 0x28}; + uint8_t byteswillprops8[] = {0x6b, 0xfd, 0x60, 0x2d, 0x8d, 0xe0, 0x99, 0x16, 0xd7, 0x9e, + 0x35, 0xc6, 0x7b, 0xaa, 0x1f, 0x63, 0x29, 0x2, 0x88, 0xc, + 0xa1, 0xe7, 0x2c, 0x44, 0xf9, 0x29, 0x36, 0xbe, 0x46, 0xe9}; + uint8_t byteswillprops9[] = {0x5e, 0x12, 0xb6, 0xf2, 0xdc, 0xf8, 0x8a, 0xad, 0x21, 0xa, 0x26, + 0xfb, 0x5d, 0x38, 0x92, 0xe2, 0xd6, 0x81, 0x2e, 0x14, 0x68, 0x44}; + uint8_t byteswillprops10[] = {0x88, 0x28, 0x88, 0xa5, 0xbd, 0x57, 0x4f, 0x3a, 0x50, + 0x8f, 0xbf, 0xf8, 0x36, 0x2e, 0x8f, 0x77, 0xb2}; + uint8_t byteswillprops11[] = {0xf3, 0x96, 0x34, 0xfb, 0x32, 0x2d, 0x8c, 0x88, 0x86, + 0x56, 0x46, 0xc9, 0x92, 0xe0, 0x1d, 0x26, 0x9f}; + uint8_t byteswillprops12[] = {0x58, 0x9a, 0xb6, 0xe5, 0x92, 0xfd, 0x3b, 0x74, + 0x13, 0xc3, 0x7e, 0x40, 0x8, 0x3c, 0x5f}; + uint8_t byteswillprops14[] = {0xb8, 0xa0, 0xd2, 0xdd, 0xa1, 0x36, 0xcd, 0x5b, 0xc8, 0xb6, + 0x56, 0xe8, 0x7e, 0xd0, 0x99, 0x4d, 0xc9, 0x28, 0xb2, 0x62}; + uint8_t byteswillprops13[] = {0x1f, 0x31, 0xb, 0x38, 0xe1, 0xcc, 0x24}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11735}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8437}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5703}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30855}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21347}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4088}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {0, (char*)&byteswillprops0}, .v = {30, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21517}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25122}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9859}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11824}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7159}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15943}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12331}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31689}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&byteswillprops12}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32000}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {7, (char*)&byteswillprops13}, .v = {20, (char*)&byteswillprops14}}}}, }; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbf, 0xc5, 0x61, 0xc2, 0x75, 0x85, 0x87, 0xf4, 0xd3, 0xaa, 0xa2, 0x81, 0xa1, 0x36, 0xe1, 0x32}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xda, 0xc}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS0; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 15412; - uint8_t client_id_bytes[] = {0xb0, 0x8f, 0xa0, 0x5f, 0x5c, 0xa6, 0x94, 0xd5, 0xe2, 0xe0, 0x18, 0x3e, 0xee, 0xb, 0xa8, 0xa3}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x78, 0x6a, 0x12, 0x64, 0x93, 0x6a, 0xf2, 0x8d, 0x11, 0xfd, 0xb3, 0x6f, 0xbc}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0x90, 0xee, 0x2f, 0x26, 0x6d}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x4a, 0x7d, 0x7c, 0x1c}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe6, 0xde, 0x7b, 0xe, 0x1f, 0x9f, 0x61, 0xb6, 0x24, 0xb1}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 17990; + uint8_t client_id_bytes[] = {0xa4, 0x13, 0xd7, 0x82, 0x83, 0xa7, 0x99, 0x3e, + 0xc8, 0xf4, 0xf4, 0x1d, 0x84, 0x8b, 0x38}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xf5, 0xba, 0xe9, 0xd1, 0x9a, 0x4a, 0x4e, 0x59, 0x7b, 0x94, + 0xab, 0xd7, 0xe2, 0x68, 0x68, 0x7f, 0x44, 0xec, 0xa2, 0xce}; + lwmqtt_string_t username = {20, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Nothing, _password = Just "\128p\220>r\201\195\&0\200", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\DC3l\244\169\203\EOT\129\173\&4\NUL\252\RS\184\133V\249z\191:P~GH\EM\193\SOH29\254e", _willMsg = "mvB", _willProps = [PropTopicAlias 32015,PropReceiveMaximum 20354,PropServerReference "a\230\147k\173c",PropRetainAvailable 141,PropContentType "\152\187&ci^\244\182{\166-\152\239\213 \216\242Z;nE~\235k\157\206",PropTopicAlias 4971,PropSharedSubscriptionAvailable 136,PropTopicAliasMaximum 21122,PropServerReference "\195%\SOo\170(\237",PropReceiveMaximum 30880,PropContentType " \237>Nx?\234\210\128\231\243\202\229\252r\191y\ETX9\214",PropTopicAliasMaximum 944,PropSessionExpiryInterval 4649,PropResponseTopic "0\DC4wb\235\170\196\188",PropSubscriptionIdentifier 5,PropPayloadFormatIndicator 92,PropSubscriptionIdentifier 23,PropMaximumQoS 170,PropCorrelationData "'",PropSubscriptionIdentifierAvailable 121,PropServerKeepAlive 11697,PropSessionExpiryInterval 32682,PropReceiveMaximum 10853,PropPayloadFormatIndicator 94,PropSubscriptionIdentifierAvailable 249]}), _cleanSession = True, _keepAlive = 30313, _connID = "\215\250VLG@\204B\"\166$HJ", _properties = [PropRequestResponseInformation 42,PropSubscriptionIdentifier 17,PropAuthenticationMethod "i\134\SO\230!|\133\173[O{6W&\161\175",PropReasonString "^@",PropMessageExpiryInterval 12544,PropServerReference "\SOH\168\246Bt\EOTQt,\158)\SYN\r=",PropAssignedClientIdentifier "a\212\EM\DC4H\239\196F\154QVS\157u\218\US\155\236\180\255_\196\229\207\241{\149P\212\233\157#\149u\132\157l",PropServerReference +// "(\148\200\145\173\166\157\243q",PropAuthenticationData "\SOI&\ng\141%",PropTopicAliasMaximum +// 1937,PropSessionExpiryInterval 16722,PropMaximumQoS 71,PropAssignedClientIdentifier +// "\196#\a{\234\157\ENQja\237\228d\234^c\193_~\180\170\209\145<",PropAssignedClientIdentifier +// "\234\GS\151\EOTY\222@j\128\195\ACKK;*\240\231\245\248R\130\159'uB\245\152\SI",PropSessionExpiryInterval 2313,PropSharedSubscriptionAvailable 135,PropMessageExpiryInterval 6040,PropMessageExpiryInterval 14534,PropAssignedClientIdentifier "\DC4*\231\182",PropResponseTopic "F\r#\DC1\203\&23\132\ETX4l\199",PropWildcardSubscriptionAvailable 202,PropResponseInformation "\231\&5\130,\230\162\SYNO\184\CAN!?LV\SUB\155\200e\174\214\238",PropCorrelationData "Y\202\227\r",PropSessionExpiryInterval 239]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\194\DC3\201\173i\234P)\159\241N\208l\133G", _willMsg = "\208\250\192\160", _willProps = +// [PropAuthenticationData "h\161K\EMw\NAK\r\DC4\188\158Z\ACK6", _properties = [PropSubscriptionIdentifier +// 30,PropAuthenticationMethod +// "}\188E\134\175\141h\217\DC40_Y[\NUL\212]\NUL\203\198\213}\DC2S\SO\214\&8\v\218",PropWillDelayInterval +// 13946,PropPayloadFormatIndicator 67,PropRequestProblemInformation 96,PropContentType +// "/\253C.d,,zl\167G\b",PropServerReference "{'sWS?'\201\183\220\EOT\STX",PropCorrelationData "\167\140Z\160,S\DC1\137 +// /\192\199\236V\220\150\156\219\193'\207\DLE\221\EM#",PropMaximumPacketSize 7792,PropSubscriptionIdentifierAvailable +// 74,PropUserProperty "@\134Y\217(\218hi\152\CAN\216\172\181" "*-\207cGd@?\232 +// \158\202Y\158\ACK\202$\249\139\129~[",PropAuthenticationMethod +// "\178(v\221\243R\r\246\195\226\ETX\EM\247\252\206\162\180F{\138"]} TEST(Connect5QCTest, Encode15) { -uint8_t pkt[] = {0x10, 0xfe, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf4, 0x12, 0x7d, 0x5b, 0x1, 0x92, 0x15, 0x0, 0x9, 0x1a, 0x96, 0x3e, 0x27, 0x75, 0x42, 0xf5, 0x98, 0xf, 0x11, 0x0, 0x0, 0x9, 0x9, 0x2a, 0x87, 0x2, 0x0, 0x0, 0x17, 0x98, 0x2, 0x0, 0x0, 0x38, 0xc6, 0x12, 0x0, 0x4, 0x14, 0x2a, 0xe7, 0xb6, 0x8, 0x0, 0xc, 0x46, 0xd, 0x23, 0x11, 0xcb, 0x32, 0x33, 0x84, 0x3, 0x34, 0x6c, 0xc7, 0x28, 0xca, 0x1a, 0x0, 0x15, 0xe7, 0x35, 0x82, 0x2c, 0xe6, 0xa2, 0x16, 0x4f, 0xb8, 0x18, 0x21, 0x3f, 0x4c, 0x56, 0x1a, 0x9b, 0xc8, 0x65, 0xae, 0xd6, 0xee, 0x9, 0x0, 0x4, 0x59, 0xca, 0xe3, 0xd, 0x11, 0x0, 0x0, 0x0, 0xef, 0x0, 0x18, 0xb, 0x3, 0x2c, 0xcc, 0x62, 0x8d, 0x88, 0x72, 0x21, 0x72, 0x13, 0x61, 0x2d, 0x8a, 0xf9, 0x4d, 0x37, 0x7, 0x66, 0x67, 0x4, 0x8b, 0xe4, 0x57, 0x39, 0x3, 0x0, 0x12, 0x3, 0xc3, 0x87, 0xd4, 0x63, 0xde, 0x46, 0xe0, 0xbc, 0xca, 0xef, 0xb9, 0x8f, 0xec, 0xb0, 0x5b, 0xf3, 0x34, 0x9, 0x0, 0x6, 0x68, 0x25, 0x6b, 0xa1, 0xc9, 0xbf, 0x1, 0xa6, 0x23, 0x59, 0x20, 0x19, 0x54, 0x18, 0x0, 0x0, 0x48, 0x2f, 0x19, 0x84, 0x29, 0xca, 0x1, 0xd2, 0xb, 0x13, 0x11, 0x0, 0x0, 0x9, 0xe6, 0x25, 0x81, 0x0, 0x8, 0xf1, 0x35, 0xb4, 0xeb, 0x85, 0x3d, 0x87, 0xe0, 0x0, 0x14, 0x2b, 0x72, 0x9c, 0xfa, 0x33, 0xa4, 0x8a, 0xa, 0x70, 0x6a, 0xf5, 0x3d, 0xee, 0xb6, 0x4e, 0x5e, 0xd, 0x61, 0x97, 0xa1, 0x0, 0x15, 0x41, 0x3b, 0xa8, 0xe0, 0xf0, 0xed, 0x11, 0x1f, 0x60, 0x6b, 0xe4, 0x44, 0xc9, 0x20, 0xd3, 0x76, 0x45, 0x2e, 0xcb, 0x2, 0x26, 0x0, 0xb, 0xe5, 0x16, 0xec, 0xfc, 0x6a, 0x72, 0x6a, 0xf6, 0x10, 0x3d, 0x78}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x1a, 0x96, 0x3e, 0x27, 0x75, 0x42, 0xf5, 0x98, 0xf}; - uint8_t bytesprops1[] = {0x14, 0x2a, 0xe7, 0xb6}; - uint8_t bytesprops2[] = {0x46, 0xd, 0x23, 0x11, 0xcb, 0x32, 0x33, 0x84, 0x3, 0x34, 0x6c, 0xc7}; - uint8_t bytesprops3[] = {0xe7, 0x35, 0x82, 0x2c, 0xe6, 0xa2, 0x16, 0x4f, 0xb8, 0x18, 0x21, 0x3f, 0x4c, 0x56, 0x1a, 0x9b, 0xc8, 0x65, 0xae, 0xd6, 0xee}; - uint8_t bytesprops4[] = {0x59, 0xca, 0xe3, 0xd}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2313}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6040}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14534}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 239}}, + uint8_t pkt[] = { + 0x10, 0x98, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x14, 0x2, 0xe1, 0xaa, 0x1, 0xb, 0x1e, 0x15, 0x0, + 0x1c, 0x7d, 0xbc, 0x45, 0x86, 0xaf, 0x8d, 0x68, 0xd9, 0x14, 0x30, 0x5f, 0x59, 0x5b, 0x0, 0xd4, 0x5d, 0x0, 0xcb, + 0xc6, 0xd5, 0x7d, 0x12, 0x53, 0xe, 0xd6, 0x38, 0xb, 0xda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xff, 0xa1, 0xe6, 0xae, 0x49, 0x2e, 0x89, 0x70, 0x56, 0x20, 0x5d, 0xa0, 0x4b, + 0x21, 0xb3, 0xa2, 0xb8, 0xe2, 0x88, 0x5f, 0x7a, 0x2b, 0x9a, 0xc9, 0x19, 0xac, 0x8, 0x0, 0x11, 0x57, 0xec, 0x4f, + 0x5b, 0x6b, 0xdb, 0x9d, 0xb5, 0x0, 0x3b, 0xde, 0x70, 0x89, 0xce, 0x80, 0x91, 0xfe, 0x13, 0x55, 0x48, 0x1a, 0x0, + 0x1e, 0x71, 0x8a, 0xd0, 0x99, 0x78, 0xd9, 0x58, 0x12, 0xd2, 0x9d, 0xbb, 0xed, 0xc5, 0xb, 0x75, 0xb4, 0x47, 0x47, + 0x3b, 0x58, 0x74, 0x61, 0xb7, 0x0, 0xce, 0xd8, 0x57, 0x5a, 0x71, 0x47, 0x26, 0x0, 0x1e, 0xaf, 0x28, 0x9f, 0x8d, + 0x31, 0xb6, 0x35, 0x79, 0xed, 0x4b, 0x61, 0x55, 0x68, 0xbb, 0xe2, 0x6b, 0x66, 0x4b, 0x34, 0x11, 0xc1, 0x49, 0x25, + 0x23, 0x6c, 0xb3, 0x1f, 0xc7, 0x36, 0x29, 0x0, 0x15, 0xc1, 0xb6, 0xf3, 0x19, 0xb5, 0x11, 0xe7, 0x3d, 0x52, 0xa3, + 0xc1, 0xc7, 0x37, 0xd9, 0x70, 0xf0, 0x4e, 0x6c, 0x7f, 0x5b, 0x43, 0x1c, 0x0, 0xd, 0xfc, 0x90, 0x96, 0x9a, 0x3, + 0xdd, 0xb8, 0xb4, 0x1e, 0xc3, 0xdc, 0x8, 0xd0, 0x0, 0xf, 0xc2, 0x13, 0xc9, 0xad, 0x69, 0xea, 0x50, 0x29, 0x9f, + 0xf1, 0x4e, 0xd0, 0x6c, 0x85, 0x47, 0x0, 0x4, 0xd0, 0xfa, 0xc0, 0xa0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7d, 0xbc, 0x45, 0x86, 0xaf, 0x8d, 0x68, 0xd9, 0x14, 0x30, 0x5f, 0x59, 0x5b, 0x0, + 0xd4, 0x5d, 0x0, 0xcb, 0xc6, 0xd5, 0x7d, 0x12, 0x53, 0xe, 0xd6, 0x38, 0xb, 0xda}; + uint8_t bytesprops1[] = {0x2f, 0xfd, 0x43, 0x2e, 0x64, 0x2c, 0x2c, 0x7a, 0x6c, 0xa7, 0x47, 0x8}; + uint8_t bytesprops2[] = {0x7b, 0x27, 0x73, 0x57, 0x53, 0x3f, 0x27, 0xc9, 0xb7, 0xdc, 0x4, 0x2}; + uint8_t bytesprops3[] = {0xa7, 0x8c, 0x5a, 0xa0, 0x2c, 0x53, 0x11, 0x89, 0x20, 0x2f, 0xc0, 0xc7, 0xec, + 0x56, 0xdc, 0x96, 0x9c, 0xdb, 0xc1, 0x27, 0xcf, 0x10, 0xdd, 0x19, 0x23}; + uint8_t bytesprops5[] = {0x2a, 0x2d, 0xcf, 0x63, 0x47, 0x64, 0x40, 0x3f, 0xe8, 0x20, 0x9e, + 0xca, 0x59, 0x9e, 0x6, 0xca, 0x24, 0xf9, 0x8b, 0x81, 0x7e, 0x5b}; + uint8_t bytesprops4[] = {0x40, 0x86, 0x59, 0xd9, 0x28, 0xda, 0x68, 0x69, 0x98, 0x18, 0xd8, 0xac, 0xb5}; + uint8_t bytesprops6[] = {0xb2, 0x28, 0x76, 0xdd, 0xf3, 0x52, 0xd, 0xf6, 0xc3, 0xe2, + 0x3, 0x19, 0xf7, 0xfc, 0xce, 0xa2, 0xb4, 0x46, 0x7b, 0x8a}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13946}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7792}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops4}, .v = {22, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops6}}}, }; lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x3, 0xc3, 0x87, 0xd4, 0x63, 0xde, 0x46, 0xe0, 0xbc, 0xca, 0xef, 0xb9, 0x8f, 0xec, 0xb0, 0x5b, 0xf3, 0x34}; - uint8_t byteswillprops1[] = {0x68, 0x25, 0x6b, 0xa1, 0xc9, 0xbf}; - + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x68, 0x3c, 0x79, 0x21, 0x3, 0x6a, 0x2e, 0x6b, 0x70, 0x1b, 0xe4, 0x99, 0x38, 0xa, 0x8c}; + uint8_t byteswillprops1[] = {0xb1, 0xd7, 0xfe, 0x1f, 0xaa, 0x9c, 0xff, 0xa1, 0xe6, 0xae, + 0x49, 0x2e, 0x89, 0x70, 0x56, 0x20, 0x5d, 0xa0, 0x4b, 0x21, + 0xb3, 0xa2, 0xb8, 0xe2, 0x88, 0x5f, 0x7a, 0x2b, 0x9a, 0xc9}; + uint8_t byteswillprops2[] = {0x57, 0xec, 0x4f, 0x5b, 0x6b, 0xdb, 0x9d, 0xb5, 0x0, + 0x3b, 0xde, 0x70, 0x89, 0xce, 0x80, 0x91, 0xfe}; + uint8_t byteswillprops3[] = {0x71, 0x8a, 0xd0, 0x99, 0x78, 0xd9, 0x58, 0x12, 0xd2, 0x9d, + 0xbb, 0xed, 0xc5, 0xb, 0x75, 0xb4, 0x47, 0x47, 0x3b, 0x58, + 0x74, 0x61, 0xb7, 0x0, 0xce, 0xd8, 0x57, 0x5a, 0x71, 0x47}; + uint8_t byteswillprops5[] = {0xc1, 0xb6, 0xf3, 0x19, 0xb5, 0x11, 0xe7, 0x3d, 0x52, 0xa3, 0xc1, + 0xc7, 0x37, 0xd9, 0x70, 0xf0, 0x4e, 0x6c, 0x7f, 0x5b, 0x43}; + uint8_t byteswillprops4[] = {0xaf, 0x28, 0x9f, 0x8d, 0x31, 0xb6, 0x35, 0x79, 0xed, 0x4b, + 0x61, 0x55, 0x68, 0xbb, 0xe2, 0x6b, 0x66, 0x4b, 0x34, 0x11, + 0xc1, 0x49, 0x25, 0x23, 0x6c, 0xb3, 0x1f, 0xc7, 0x36, 0x29}; + uint8_t byteswillprops6[] = {0xfc, 0x90, 0x96, 0x9a, 0x3, 0xdd, 0xb8, 0xb4, 0x1e, 0xc3, 0xdc, 0x8, 0xd0}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22816}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18479}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2534}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, - }; - - lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf1, 0x35, 0xb4, 0xeb, 0x85, 0x3d, 0x87, 0xe0}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x2b, 0x72, 0x9c, 0xfa, 0x33, 0xa4, 0x8a, 0xa, 0x70, 0x6a, 0xf5, 0x3d, 0xee, 0xb6, 0x4e, 0x5e, 0xd, 0x61, 0x97, 0xa1}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 4733; - uint8_t client_id_bytes[] = {0xb, 0x3, 0x2c, 0xcc, 0x62, 0x8d, 0x88, 0x72, 0x21, 0x72, 0x13, 0x61, 0x2d, 0x8a, 0xf9, 0x4d, 0x37, 0x7, 0x66, 0x67, 0x4, 0x8b, 0xe4, 0x57}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x41, 0x3b, 0xa8, 0xe0, 0xf0, 0xed, 0x11, 0x1f, 0x60, 0x6b, 0xe4, 0x44, 0xc9, 0x20, 0xd3, 0x76, 0x45, 0x2e, 0xcb, 0x2, 0x26}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0xe5, 0x16, 0xec, 0xfc, 0x6a, 0x72, 0x6a, 0xf6, 0x10, 0x3d, 0x78}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21832}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {30, (char*)&byteswillprops4}, .v = {21, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&byteswillprops6}}}, + }; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc2, 0x13, 0xc9, 0xad, 0x69, 0xea, 0x50, 0x29, + 0x9f, 0xf1, 0x4e, 0xd0, 0x6c, 0x85, 0x47}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd0, 0xfa, 0xc0, 0xa0}; + lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 737; + uint8_t client_id_bytes[] = {0xcc, 0x72, 0x8a, 0xd2, 0x99, 0x3e, 0xa1, 0x4b, 0x19, + 0x77, 0x15, 0xd, 0x14, 0xbc, 0x9e, 0x5a, 0x6, 0x36}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Just "\172\&0m\236P\216\191\220\208y\146\237\159\163\244Q\136\214\218\197\202\DC3(d\vm\142\GSO\DC3", _password = Just "\EM\a\ACKM\203i\200\227NY:", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\170\n\217\SO\CANI8\208\NAK", _willMsg = "", _willProps = [PropSharedSubscriptionAvailable 53,PropReasonString "\232\182\US_9\185\154\139\t\185\&9\187\225E*cC",PropResponseInformation "\206\DC4\SOH\251\&1M\232\134\129\145\251\t(",PropWildcardSubscriptionAvailable 94,PropSubscriptionIdentifier 11,PropWillDelayInterval 8513,PropSubscriptionIdentifierAvailable 166,PropRequestProblemInformation 92,PropMaximumQoS 16,PropSessionExpiryInterval 13745,PropServerReference "\182X\129:>\131\222\176vsk\255^\188\216\253\247X\142@\197\226u\164\NUL",PropServerKeepAlive 18267,PropResponseInformation "\132s\v\135\131\227\&9o;O\207,\129Al\241!u\222",PropTopicAlias 19785,PropUserProperty "\FS\177\SI-'\152\174\245\n\130\207\229\r\222 c4\188\196#" "\176o\253\216\DC4MT\140\NAK\129:\GS\146\\}`\n("]}), _cleanSession = True, _keepAlive = 25021, _connID = "h\216P$\178\190\228\190\138\FS", _properties = [PropMaximumQoS 85,PropReasonString "\205\229\152m\250\252hu\EOTu\135\230BP\199H\202)\220\RS\164\200\221\DC4",PropResponseTopic "<\212\221Um\DEL\133L8*\144\205\232\197w\231o\161\181\STX\208\232\SOH",PropSessionExpiryInterval 13715,PropMaximumQoS 51]} +// ConnectRequest {_username = Just "=\244\ESCz\EM\205Q\216 \211\&62\EM\238\244\239O D\136", _password = Just +// "\CANj\v\180\161\237\198h\184_NXO\223\DC1p$\175\183/*\178\186v2Z\USe\145", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS2, _willTopic = ":\229v?G\137\&4\DC4\206\151\169\DC2\SO\230\143RYg\149\228Q\SYN\220\176\201\157",PropTopicAliasMaximum +// 25134,PropSessionExpiryInterval 21348,PropSubscriptionIdentifierAvailable 19,PropPayloadFormatIndicator +// 250,PropMaximumPacketSize 28204,PropRetainAvailable 37,PropAssignedClientIdentifier +// "p\134\DC3\185\192\140\178&{1P\188\198",PropMessageExpiryInterval 15366,PropMaximumPacketSize +// 7017,PropWillDelayInterval 7756,PropRetainAvailable 121,PropSharedSubscriptionAvailable 51,PropUserProperty +// "\203\191\129(l\243[\173\210{=\185$\146\180\163\206\161\221\142\174\227\196\EM\237\214?y\156g" +// "\194S\132\191\191o\210\&5Sv\138\191M",PropWildcardSubscriptionAvailable 4,PropWillDelayInterval +// 9468,PropCorrelationData "\253\158\148A\245lZ\254\133\GS$\219H\181\226\208\238\EM",PropWildcardSubscriptionAvailable +// 142,PropServerKeepAlive 7563,PropAuthenticationMethod "3K\145\\",PropAssignedClientIdentifier +// "\167\169\248\n\239\183\251~+Z\186\158\232\ESCF\227,$",PropMaximumQoS 231,PropMessageExpiryInterval +// 2465,PropPayloadFormatIndicator 252,PropResponseTopic +// "\159\205I\251\142\aMs\191\136\ETX\STX\237\CANS9!U\GS\208\ENQrMR\CAN\bzD"]}), _cleanSession = True, _keepAlive = +// 13449, _connID = "\160\224\209~y/wD\182\&6\143\210\244\&6D\190", _properties = [PropAssignedClientIdentifier +// "R\RSI\189\206\210v",PropReasonString "\144\t\"\DEL\176\150\214\245_\203\190\176",PropAuthenticationData +// "\202\&4\n\171\157*\ETX\212{^\186\215x\EOT\229C\157\&2m_}:",PropReasonString +// "\203\&3W\227\217n\231q\a~\204\195M\237k\160.\248\SOH\207\171c\234\217Ad\241_f\203",PropCorrelationData +// "\ESC\216-\244\173\222\165\187\&8m\a~g*I\159\DC1z\141Gg\203w",PropAssignedClientIdentifier +// "",PropRequestResponseInformation 124,PropWildcardSubscriptionAvailable 213,PropReasonString +// "\165\240\217",PropResponseInformation "\155\NUL\246\217Nw\v!\215\ETX\159\163w\DLE\196",PropMessageExpiryInterval +// 26429,PropWildcardSubscriptionAvailable 28,PropServerReference +// "\165\185\&5\239k\DC1\198\213\164",PropRequestProblemInformation 160]} TEST(Connect5QCTest, Encode16) { -uint8_t pkt[] = {0x10, 0xae, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x61, 0xbd, 0x3e, 0x24, 0x55, 0x1f, 0x0, 0x18, 0xcd, 0xe5, 0x98, 0x6d, 0xfa, 0xfc, 0x68, 0x75, 0x4, 0x75, 0x87, 0xe6, 0x42, 0x50, 0xc7, 0x48, 0xca, 0x29, 0xdc, 0x1e, 0xa4, 0xc8, 0xdd, 0x14, 0x8, 0x0, 0x17, 0x3c, 0xd4, 0xdd, 0x55, 0x6d, 0x7f, 0x85, 0x4c, 0x38, 0x2a, 0x90, 0xcd, 0xe8, 0xc5, 0x77, 0xe7, 0x6f, 0xa1, 0xb5, 0x2, 0xd0, 0xe8, 0x1, 0x11, 0x0, 0x0, 0x35, 0x93, 0x24, 0x33, 0x0, 0xa, 0x68, 0xd8, 0x50, 0x24, 0xb2, 0xbe, 0xe4, 0xbe, 0x8a, 0x1c, 0x9d, 0x1, 0x2a, 0x35, 0x1f, 0x0, 0x11, 0xe8, 0xb6, 0x1f, 0x5f, 0x39, 0xb9, 0x9a, 0x8b, 0x9, 0xb9, 0x39, 0xbb, 0xe1, 0x45, 0x2a, 0x63, 0x43, 0x1a, 0x0, 0xd, 0xce, 0x14, 0x1, 0xfb, 0x31, 0x4d, 0xe8, 0x86, 0x81, 0x91, 0xfb, 0x9, 0x28, 0x28, 0x5e, 0xb, 0xb, 0x18, 0x0, 0x0, 0x21, 0x41, 0x29, 0xa6, 0x17, 0x5c, 0x24, 0x10, 0x11, 0x0, 0x0, 0x35, 0xb1, 0x1c, 0x0, 0x19, 0xb6, 0x58, 0x81, 0x3a, 0x3e, 0x83, 0xde, 0xb0, 0x76, 0x73, 0x6b, 0xff, 0x5e, 0xbc, 0xd8, 0xfd, 0xf7, 0x58, 0x8e, 0x40, 0xc5, 0xe2, 0x75, 0xa4, 0x0, 0x13, 0x47, 0x5b, 0x1a, 0x0, 0x13, 0x84, 0x73, 0xb, 0x87, 0x83, 0xe3, 0x39, 0x6f, 0x3b, 0x4f, 0xcf, 0x2c, 0x81, 0x41, 0x6c, 0xf1, 0x21, 0x75, 0xde, 0x23, 0x4d, 0x49, 0x26, 0x0, 0x14, 0x1c, 0xb1, 0xf, 0x2d, 0x27, 0x98, 0xae, 0xf5, 0xa, 0x82, 0xcf, 0xe5, 0xd, 0xde, 0x20, 0x63, 0x34, 0xbc, 0xc4, 0x23, 0x0, 0x12, 0xb0, 0x6f, 0xfd, 0xd8, 0x14, 0x4d, 0x54, 0x8c, 0x15, 0x81, 0x3a, 0x1d, 0x92, 0x5c, 0x7d, 0x60, 0xa, 0x28, 0x0, 0x9, 0xaa, 0xa, 0xd9, 0xe, 0x18, 0x49, 0x38, 0xd0, 0x15, 0x0, 0x0, 0x0, 0x1e, 0xac, 0x30, 0x6d, 0xec, 0x50, 0xd8, 0xbf, 0xdc, 0xd0, 0x79, 0x92, 0xed, 0x9f, 0xa3, 0xf4, 0x51, 0x88, 0xd6, 0xda, 0xc5, 0xca, 0x13, 0x28, 0x64, 0xb, 0x6d, 0x8e, 0x1d, 0x4f, 0x13, 0x0, 0xb, 0x19, 0x7, 0x6, 0x4d, 0xcb, 0x69, 0xc8, 0xe3, 0x4e, 0x59, 0x3a}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xcd, 0xe5, 0x98, 0x6d, 0xfa, 0xfc, 0x68, 0x75, 0x4, 0x75, 0x87, 0xe6, 0x42, 0x50, 0xc7, 0x48, 0xca, 0x29, 0xdc, 0x1e, 0xa4, 0xc8, 0xdd, 0x14}; - uint8_t bytesprops1[] = {0x3c, 0xd4, 0xdd, 0x55, 0x6d, 0x7f, 0x85, 0x4c, 0x38, 0x2a, 0x90, 0xcd, 0xe8, 0xc5, 0x77, 0xe7, 0x6f, 0xa1, 0xb5, 0x2, 0xd0, 0xe8, 0x1}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13715}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 51}}, - }; + uint8_t pkt[] = { + 0x10, 0x89, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x34, 0x89, 0xa1, 0x1, 0x12, 0x0, 0x7, 0x52, + 0x1e, 0x49, 0xbd, 0xce, 0xd2, 0x76, 0x1f, 0x0, 0xc, 0x90, 0x9, 0x22, 0x7f, 0xb0, 0x96, 0xd6, 0xf5, 0x5f, 0xcb, + 0xbe, 0xb0, 0x16, 0x0, 0x16, 0xca, 0x34, 0xa, 0xab, 0x9d, 0x2a, 0x3, 0xd4, 0x7b, 0x5e, 0xba, 0xd7, 0x78, 0x4, + 0xe5, 0x43, 0x9d, 0x32, 0x6d, 0x5f, 0x7d, 0x3a, 0x1f, 0x0, 0x1e, 0xcb, 0x33, 0x57, 0xe3, 0xd9, 0x6e, 0xe7, 0x71, + 0x7, 0x7e, 0xcc, 0xc3, 0x4d, 0xed, 0x6b, 0xa0, 0x2e, 0xf8, 0x1, 0xcf, 0xab, 0x63, 0xea, 0xd9, 0x41, 0x64, 0xf1, + 0x5f, 0x66, 0xcb, 0x9, 0x0, 0x17, 0x1b, 0xd8, 0x2d, 0xf4, 0xad, 0xde, 0xa5, 0xbb, 0x38, 0x6d, 0x7, 0x7e, 0x67, + 0x2a, 0x49, 0x9f, 0x11, 0x7a, 0x8d, 0x47, 0x67, 0xcb, 0x77, 0x12, 0x0, 0x0, 0x19, 0x7c, 0x28, 0xd5, 0x1f, 0x0, + 0x3, 0xa5, 0xf0, 0xd9, 0x1a, 0x0, 0x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, 0x24, 0xaf, + 0xb7, 0x2f, 0x2a, 0xb2, 0xba, 0x76, 0x32, 0x5a, 0x1f, 0x65, 0x91}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x52, 0x1e, 0x49, 0xbd, 0xce, 0xd2, 0x76}; + uint8_t bytesprops1[] = {0x90, 0x9, 0x22, 0x7f, 0xb0, 0x96, 0xd6, 0xf5, 0x5f, 0xcb, 0xbe, 0xb0}; + uint8_t bytesprops2[] = {0xca, 0x34, 0xa, 0xab, 0x9d, 0x2a, 0x3, 0xd4, 0x7b, 0x5e, 0xba, + 0xd7, 0x78, 0x4, 0xe5, 0x43, 0x9d, 0x32, 0x6d, 0x5f, 0x7d, 0x3a}; + uint8_t bytesprops3[] = {0xcb, 0x33, 0x57, 0xe3, 0xd9, 0x6e, 0xe7, 0x71, 0x7, 0x7e, 0xcc, 0xc3, 0x4d, 0xed, 0x6b, + 0xa0, 0x2e, 0xf8, 0x1, 0xcf, 0xab, 0x63, 0xea, 0xd9, 0x41, 0x64, 0xf1, 0x5f, 0x66, 0xcb}; + uint8_t bytesprops4[] = {0x1b, 0xd8, 0x2d, 0xf4, 0xad, 0xde, 0xa5, 0xbb, 0x38, 0x6d, 0x7, 0x7e, + 0x67, 0x2a, 0x49, 0x9f, 0x11, 0x7a, 0x8d, 0x47, 0x67, 0xcb, 0x77}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0xa5, 0xf0, 0xd9}; + uint8_t bytesprops7[] = {0x9b, 0x0, 0xf6, 0xd9, 0x4e, 0x77, 0xb, 0x21, 0xd7, 0x3, 0x9f, 0xa3, 0x77, 0x10, 0xc4}; + uint8_t bytesprops8[] = {0xa5, 0xb9, 0x35, 0xef, 0x6b, 0x11, 0xc6, 0xd5, 0xa4}; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe8, 0xb6, 0x1f, 0x5f, 0x39, 0xb9, 0x9a, 0x8b, 0x9, 0xb9, 0x39, 0xbb, 0xe1, 0x45, 0x2a, 0x63, 0x43}; - uint8_t byteswillprops1[] = {0xce, 0x14, 0x1, 0xfb, 0x31, 0x4d, 0xe8, 0x86, 0x81, 0x91, 0xfb, 0x9, 0x28}; - uint8_t byteswillprops2[] = {0xb6, 0x58, 0x81, 0x3a, 0x3e, 0x83, 0xde, 0xb0, 0x76, 0x73, 0x6b, 0xff, 0x5e, 0xbc, 0xd8, 0xfd, 0xf7, 0x58, 0x8e, 0x40, 0xc5, 0xe2, 0x75, 0xa4, 0x0}; - uint8_t byteswillprops3[] = {0x84, 0x73, 0xb, 0x87, 0x83, 0xe3, 0x39, 0x6f, 0x3b, 0x4f, 0xcf, 0x2c, 0x81, 0x41, 0x6c, 0xf1, 0x21, 0x75, 0xde}; - uint8_t byteswillprops5[] = {0xb0, 0x6f, 0xfd, 0xd8, 0x14, 0x4d, 0x54, 0x8c, 0x15, 0x81, 0x3a, 0x1d, 0x92, 0x5c, 0x7d, 0x60, 0xa, 0x28}; - uint8_t byteswillprops4[] = {0x1c, 0xb1, 0xf, 0x2d, 0x27, 0x98, 0xae, 0xf5, 0xa, 0x82, 0xcf, 0xe5, 0xd, 0xde, 0x20, 0x63, 0x34, 0xbc, 0xc4, 0x23}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8513}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13745}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18267}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19785}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={20, (char*)&byteswillprops4}, .v={18, (char*)&byteswillprops5}}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26429}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 160}}, }; - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xaa, 0xa, 0xd9, 0xe, 0x18, 0x49, 0x38, 0xd0, 0x15}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 25021; - uint8_t client_id_bytes[] = {0x68, 0xd8, 0x50, 0x24, 0xb2, 0xbe, 0xe4, 0xbe, 0x8a, 0x1c}; - lwmqtt_string_t client_id = {10, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xac, 0x30, 0x6d, 0xec, 0x50, 0xd8, 0xbf, 0xdc, 0xd0, 0x79, 0x92, 0xed, 0x9f, 0xa3, 0xf4, 0x51, 0x88, 0xd6, 0xda, 0xc5, 0xca, 0x13, 0x28, 0x64, 0xb, 0x6d, 0x8e, 0x1d, 0x4f, 0x13}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0x19, 0x7, 0x6, 0x4d, 0xcb, 0x69, 0xc8, 0xe3, 0x4e, 0x59, 0x3a}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - -} - - -// ConnectRequest {_username = Just "-\\\US\191>B\216\175\176\r\209#\187\163", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = ",R\166,\231d\190T\\4\f\152s\ENQ\214\188\159\242\200\STX\212yX\237", _willMsg = "G\242R!yU\157\129c\166", _willProps = [PropAuthenticationData "\EMK\SOH\DC3\202\&3\154\145\145^\221\f+\134-\174\249t\214",PropResponseInformation "\252\FS*,m\EM\159fX\226\175)",PropSessionExpiryInterval 99,PropTopicAlias 29786,PropResponseInformation "-$\190u\208\f\179\133+i+\172\213\227q\220\FS\157\217~\162\DC2\194U\238\&9\bl\174/",PropPayloadFormatIndicator 186,PropContentType "6V\EM\155.\151@,\150\172\218\CANpA\129\DEL",PropResponseInformation "\DC2j\193\r9\225\SUB\151\242\182\&6\211\158\237\194Q\142\&8r\194\255\167\166\RS\219\245XZg\215",PropAuthenticationMethod "x",PropMessageExpiryInterval 8608,PropResponseTopic "a\ACK\168\EM\218\\u\STXQ\226\SI,AO\158_!\ENQ\203",PropSubscriptionIdentifierAvailable 157,PropMaximumQoS 60,PropServerKeepAlive 20958,PropSharedSubscriptionAvailable 131,PropUserProperty "\215\&7\250\fS-\SI" "\227\249\215\206\205h\143\132\&0O5\247(\197\168\128{x",PropReceiveMaximum 19818,PropAuthenticationMethod "\v\184\&1\136R\164\245\208z\143\214\143#\252\159\129\221*I\189\150",PropTopicAlias 17514,PropAuthenticationData "\150\200\nX.\180yZV`\220\154",PropResponseInformation "\215"]}), _cleanSession = True, _keepAlive = 13547, _connID = "r\251\173\&4c\162{\179\188\SO\213\162/\US\158ej\186\DC43\174\157\&4(u\213\US\164E", _properties = [PropAuthenticationData "\DC4\195\a\137\252\139\139\170",PropTopicAliasMaximum 20467,PropServerReference "~\210v\151\253ca\DLEz>\173\193\244\237\189\150\a\224 \ACK",PropTopicAlias 7863,PropSubscriptionIdentifier 19,PropPayloadFormatIndicator 248,PropRequestResponseInformation 182,PropResponseTopic "\236\131T7\252\&7\DC4\r\219\153\DC4jD\246\vr\224\158\229\248\136L?\187wL\167",PropPayloadFormatIndicator 88,PropMaximumPacketSize 32441]} -TEST(Connect5QCTest, Encode17) { -uint8_t pkt[] = {0x10, 0xb0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb6, 0x34, 0xeb, 0x53, 0x16, 0x0, 0x8, 0x14, 0xc3, 0x7, 0x89, 0xfc, 0x8b, 0x8b, 0xaa, 0x22, 0x4f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2, 0xd4, 0x79, 0x58, 0xed, 0x0, 0xa, 0x47, 0xf2, 0x52, 0x21, 0x79, 0x55, 0x9d, 0x81, 0x63, 0xa6, 0x0, 0xe, 0x2d, 0x5c, 0x1f, 0xbf, 0x3e, 0x42, 0xd8, 0xaf, 0xb0, 0xd, 0xd1, 0x23, 0xbb, 0xa3}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x14, 0xc3, 0x7, 0x89, 0xfc, 0x8b, 0x8b, 0xaa}; - uint8_t bytesprops1[] = {0x7e, 0xd2, 0x76, 0x97, 0xfd, 0x63, 0x61, 0x10, 0x7a, 0x3e, 0xad, 0xc1, 0xf4, 0xed, 0xbd, 0x96, 0x7, 0xe0, 0x20, 0x6}; - uint8_t bytesprops2[] = {0xec, 0x83, 0x54, 0x37, 0xfc, 0x37, 0x14, 0xd, 0xdb, 0x99, 0x14, 0x6a, 0x44, 0xf6, 0xb, 0x72, 0xe0, 0x9e, 0xe5, 0xf8, 0x88, 0x4c, 0x3f, 0xbb, 0x77, 0x4c, 0xa7}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20467}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7863}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32441}}, - }; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xf0, 0x82, 0x4d, 0x2a, 0xfd, 0x76, 0x3e, 0x47, 0x89, 0x34, 0x14, 0xce, 0x97, 0xa9, 0x12, + 0xe, 0xe6, 0x8f, 0x52, 0x59, 0x67, 0x95, 0xe4, 0x51, 0x16, 0xdc, 0xb0, 0xc9, 0x9d}; + uint8_t byteswillprops1[] = {0x70, 0x86, 0x13, 0xb9, 0xc0, 0x8c, 0xb2, 0x26, 0x7b, 0x31, 0x50, 0xbc, 0xc6}; + uint8_t byteswillprops3[] = {0xc2, 0x53, 0x84, 0xbf, 0xbf, 0x6f, 0xd2, 0x35, 0x53, 0x76, 0x8a, 0xbf, 0x4d}; + uint8_t byteswillprops2[] = {0xcb, 0xbf, 0x81, 0x28, 0x6c, 0xf3, 0x5b, 0xad, 0xd2, 0x7b, + 0x3d, 0xb9, 0x24, 0x92, 0xb4, 0xa3, 0xce, 0xa1, 0xdd, 0x8e, + 0xae, 0xe3, 0xc4, 0x19, 0xed, 0xd6, 0x3f, 0x79, 0x9c, 0x67}; + uint8_t byteswillprops4[] = {0xfd, 0x9e, 0x94, 0x41, 0xf5, 0x6c, 0x5a, 0xfe, 0x85, + 0x1d, 0x24, 0xdb, 0x48, 0xb5, 0xe2, 0xd0, 0xee, 0x19}; + uint8_t byteswillprops5[] = {0x33, 0x4b, 0x91, 0x5c}; + uint8_t byteswillprops6[] = {0xa7, 0xa9, 0xf8, 0xa, 0xef, 0xb7, 0xfb, 0x7e, 0x2b, + 0x5a, 0xba, 0x9e, 0xe8, 0x1b, 0x46, 0xe3, 0x2c, 0x24}; + uint8_t byteswillprops7[] = {0x9f, 0xcd, 0x49, 0xfb, 0x8e, 0x7, 0x4d, 0x73, 0xbf, 0x88, 0x3, 0x2, 0xed, 0x18, + 0x53, 0x39, 0x21, 0x55, 0x1d, 0xd0, 0x5, 0x72, 0x4d, 0x52, 0x18, 0x8, 0x7a, 0x44}; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x19, 0x4b, 0x1, 0x13, 0xca, 0x33, 0x9a, 0x91, 0x91, 0x5e, 0xdd, 0xc, 0x2b, 0x86, 0x2d, 0xae, 0xf9, 0x74, 0xd6}; - uint8_t byteswillprops1[] = {0xfc, 0x1c, 0x2a, 0x2c, 0x6d, 0x19, 0x9f, 0x66, 0x58, 0xe2, 0xaf, 0x29}; - uint8_t byteswillprops2[] = {0x2d, 0x24, 0xbe, 0x75, 0xd0, 0xc, 0xb3, 0x85, 0x2b, 0x69, 0x2b, 0xac, 0xd5, 0xe3, 0x71, 0xdc, 0x1c, 0x9d, 0xd9, 0x7e, 0xa2, 0x12, 0xc2, 0x55, 0xee, 0x39, 0x8, 0x6c, 0xae, 0x2f}; - uint8_t byteswillprops3[] = {0x36, 0x56, 0x19, 0x9b, 0x2e, 0x97, 0x40, 0x2c, 0x96, 0xac, 0xda, 0x18, 0x70, 0x41, 0x81, 0x7f}; - uint8_t byteswillprops4[] = {0x12, 0x6a, 0xc1, 0xd, 0x39, 0xe1, 0x1a, 0x97, 0xf2, 0xb6, 0x36, 0xd3, 0x9e, 0xed, 0xc2, 0x51, 0x8e, 0x38, 0x72, 0xc2, 0xff, 0xa7, 0xa6, 0x1e, 0xdb, 0xf5, 0x58, 0x5a, 0x67, 0xd7}; - uint8_t byteswillprops5[] = {0x78}; - uint8_t byteswillprops6[] = {0x61, 0x6, 0xa8, 0x19, 0xda, 0x5c, 0x75, 0x2, 0x51, 0xe2, 0xf, 0x2c, 0x41, 0x4f, 0x9e, 0x5f, 0x21, 0x5, 0xcb}; - uint8_t byteswillprops8[] = {0xe3, 0xf9, 0xd7, 0xce, 0xcd, 0x68, 0x8f, 0x84, 0x30, 0x4f, 0x35, 0xf7, 0x28, 0xc5, 0xa8, 0x80, 0x7b, 0x78}; - uint8_t byteswillprops7[] = {0xd7, 0x37, 0xfa, 0xc, 0x53, 0x2d, 0xf}; - uint8_t byteswillprops9[] = {0xb, 0xb8, 0x31, 0x88, 0x52, 0xa4, 0xf5, 0xd0, 0x7a, 0x8f, 0xd6, 0x8f, 0x23, 0xfc, 0x9f, 0x81, 0xdd, 0x2a, 0x49, 0xbd, 0x96}; - uint8_t byteswillprops10[] = {0x96, 0xc8, 0xa, 0x58, 0x2e, 0xb4, 0x79, 0x5a, 0x56, 0x60, 0xdc, 0x9a}; - uint8_t byteswillprops11[] = {0xd7}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 99}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29786}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8608}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20958}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={7, (char*)&byteswillprops7}, .v={18, (char*)&byteswillprops8}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19818}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17514}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25134}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21348}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28204}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15366}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7017}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7756}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {30, (char*)&byteswillprops2}, .v = {13, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9468}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7563}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2465}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&byteswillprops7}}}, }; - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2c, 0x52, 0xa6, 0x2c, 0xe7, 0x64, 0xbe, 0x54, 0x5c, 0x34, 0xc, 0x98, 0x73, 0x5, 0xd6, 0xbc, 0x9f, 0xf2, 0xc8, 0x2, 0xd4, 0x79, 0x58, 0xed}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x47, 0xf2, 0x52, 0x21, 0x79, 0x55, 0x9d, 0x81, 0x63, 0xa6}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 13547; - uint8_t client_id_bytes[] = {0x72, 0xfb, 0xad, 0x34, 0x63, 0xa2, 0x7b, 0xb3, 0xbc, 0xe, 0xd5, 0xa2, 0x2f, 0x1f, 0x9e, 0x65, 0x6a, 0xba, 0x14, 0x33, 0xae, 0x9d, 0x34, 0x28, 0x75, 0xd5, 0x1f, 0xa4, 0x45}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x2d, 0x5c, 0x1f, 0xbf, 0x3e, 0x42, 0xd8, 0xaf, 0xb0, 0xd, 0xd1, 0x23, 0xbb, 0xa3}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; -opts.username = username; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x3a, 0xe5, 0x76, 0x3f, 0x3c, 0x66, 0x45, 0xc7, 0xf6, 0xb6, 0xae, 0x8d, 0x7e, + 0x11, 0x60, 0x79, 0xd7, 0xac, 0x4c, 0x25, 0x9e, 0xc, 0xd8, 0xc6, 0x3a}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf9, 0x2d, 0xb8, 0xea, 0x92, 0xa7, 0xee, 0xb1, 0xfb, 0xa7, 0x56}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 13449; + uint8_t client_id_bytes[] = {0xa0, 0xe0, 0xd1, 0x7e, 0x79, 0x2f, 0x77, 0x44, + 0xb6, 0x36, 0x8f, 0xd2, 0xf4, 0x36, 0x44, 0xbe}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x3d, 0xf4, 0x1b, 0x7a, 0x19, 0xcd, 0x51, 0xd8, 0x20, 0xd3, + 0x36, 0x32, 0x19, 0xee, 0xf4, 0xef, 0x4f, 0x20, 0x44, 0x88}; + lwmqtt_string_t username = {20, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x18, 0x6a, 0xb, 0xb4, 0xa1, 0xed, 0xc6, 0x68, 0xb8, 0x5f, 0x4e, 0x58, 0x4f, 0xdf, 0x11, + 0x70, 0x24, 0xaf, 0xb7, 0x2f, 0x2a, 0xb2, 0xba, 0x76, 0x32, 0x5a, 0x1f, 0x65, 0x91}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Nothing, _password = Just "\EM~\132\178\GS\169&\143*J\FS\223", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "@li\185SS", _willMsg = +// "\225\&9L\215\ENQ\CAN\158w\142P\EOT\219\157\227\160", _willProps = [PropTopicAlias 18028,PropRetainAvailable +// 185,PropSubscriptionIdentifier 20]}), _cleanSession = False, _keepAlive = 7971, _connID = +// "T\NAK\150\156\144\224\213\148P\161D\216\239ZE\171\185\169c\STX\173", _properties = [PropContentType +// "\DEL\223b\237\148\186\245",PropAuthenticationMethod +// "\158\DC3\214LI\160\253\195\164}t\182\ACK\192\191g",PropWillDelayInterval 25298,PropMessageExpiryInterval +// 27525,PropSubscriptionIdentifierAvailable 249,PropAuthenticationMethod +// "\247\178,+\SOH\236X\156\170\179F",PropMaximumQoS 90,PropResponseInformation +// "W!\154\169\DC2|\EM\158\DLE#5\157\246\&6\235\238\192'\f_\221\149\129\144\189\STX\144\242\141\DLE",PropResponseInformation +// "\165\DC1\136\239}' \131\184\&2\253I\217\142Ut|\225\&6/\178",PropTopicAlias 20976,PropMaximumQoS +// 135,PropMessageExpiryInterval 30112,PropAssignedClientIdentifier "{\133\251\144\SUB\252>\138,",PropContentType +// "\f\193\219\191! HJ\251\242\208",PropMaximumQoS 252,PropSessionExpiryInterval 9433,PropWillDelayInterval +// 7916,PropSubscriptionIdentifier 16,PropRequestResponseInformation 251,PropPayloadFormatIndicator 189,PropMaximumQoS +// 87,PropServerKeepAlive 28237,PropMaximumPacketSize 32319,PropTopicAlias 24039,PropRetainAvailable +// 214,PropAssignedClientIdentifier "\167\206\161K\DC4\134\DC4\165\146\\\221\ETX[\185\t\DC4N)\133\&1",PropMaximumQoS +// 195,PropAuthenticationData "\ETX"]} +TE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, 0xbd, 0x24, 0x57, 0x13, 0x6e, 0x4d, 0x27, 0x0, + 0x0, 0x7e, 0x3f, 0x23, 0x5d, 0xe7, 0x25, 0xd6, 0x12, 0x0, 0x14, 0xa7, 0xce, 0xa1, 0x4b, 0x14, 0x86, 0x14, 0xa5, + 0x92, 0x5c, 0xdd, 0x3, 0x5b, 0xb9, 0x9, 0x14, 0x4e, 0x29, 0x85, 0x31, 0x24, 0xc3, 0x16, 0x0, 0x1, 0x3, 0x0, + 0x15, 0x54, 0x15, 0x96, 0x9c, 0x90, 0xe0, 0xd5, 0x94, 0x50, 0xa1, 0x44, 0xd8, 0xef, 0x5a, 0x45, 0xab, 0xb9, 0xa9, + 0x63, 0x2, 0xad, 0x7, 0x23, 0x46, 0x6c, 0x25, 0xb9, 0xb, 0x14, 0x0, 0x6, 0x40, 0x6c, 0x69, 0xb9, 0x53, 0x53, + 0x0, 0xf, 0xe1, 0x39, 0x4c, 0xd7, 0x5, 0x18, 0x9e, 0x77, 0x8e, 0x50, 0x4, 0xdb, 0x9d, 0xe3, 0xa0, 0x0, 0xc, + 0x19, 0x7e, 0x84, 0xb2, 0x1d, 0xa9, 0x26, 0x8f, 0x2a, 0x4a, 0x1c, 0xdf}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7f, 0xdf, 0x62, 0xed, 0x94, 0xba, 0xf5}; + uint8_t bytesprops1[] = {0x9e, 0x13, 0xd6, 0x4c, 0x49, 0xa0, 0xfd, 0xc3, + 0xa4, 0x7d, 0x74, 0xb6, 0x6, 0xc0, 0xbf, 0x67}; + uint8_t bytesprops2[] = {0xf7, 0xb2, 0x2c, 0x2b, 0x1, 0xec, 0x58, 0x9c, 0xaa, 0xb3, 0x46}; + uint8_t bytesprops3[] = {0x57, 0x21, 0x9a, 0xa9, 0x12, 0x7c, 0x19, 0x9e, 0x10, 0x23, 0x35, 0x9d, 0xf6, 0x36, 0xeb, + 0xee, 0xc0, 0x27, 0xc, 0x5f, 0xdd, 0x95, 0x81, 0x90, 0xbd, 0x2, 0x90, 0xf2, 0x8d, 0x10}; + uint8_t bytesprops4[] = {0xa5, 0x11, 0x88, 0xef, 0x7d, 0x27, 0x20, 0x83, 0xb8, 0x32, 0xfd, + 0x49, 0xd9, 0x8e, 0x55, 0x74, 0x7c, 0xe1, 0x36, 0x2f, 0xb2}; + uint8_t bytesprops5[] = {0x7b, 0x85, 0xfb, 0x90, 0x1a, 0xfc, 0x3e, 0x8a, 0x2c}; + uint8_t bytesprops6[] = {0xc, 0xc1, 0xdb, 0xbf, 0x21, 0x20, 0x48, 0x4a, 0xfb, 0xf2, 0xd0}; + uint8_t bytesprops7[] = {0xa7, 0xce, 0xa1, 0x4b, 0x14, 0x86, 0x14, 0xa5, 0x92, 0x5c, + 0xdd, 0x3, 0x5b, 0xb9, 0x9, 0x14, 0x4e, 0x29, 0x85, 0x31}; + uint8_t bytesprops8[] = {0x3}; -// ConnectRequest {_username = Just "\232g\222\&1\254\EM\195}\FS\159h\255\DC4J\131:\250\139\243\245L\SYN\132\237\145\218l\149\147D", _password = Just "\216\SYN", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\RScg\195\250\136\246\225\255\166Lm\165\206\183\159", _willMsg = "\222\238\244.\139OJ", _willProps = [PropAuthenticationMethod "\226\222\ENQ\183\159\153{\172",PropMessageExpiryInterval 27045,PropServerReference "\EM\215\133",PropWillDelayInterval 27246,PropRequestResponseInformation 32,PropMaximumPacketSize 5739,PropContentType "\ETB\200\133}\199\192\185\154\215\189zH\208\200\148\DLEef",PropSubscriptionIdentifierAvailable 126,PropWillDelayInterval 27782,PropAssignedClientIdentifier "\SUB\200\204\249\153\NAK\208\160&\DC2|\t{I\220}\174",PropWillDelayInterval 2942,PropServerReference "|\137f\208\164Y"]}), _cleanSession = True, _keepAlive = 24226, _connID = "\171!\155o/ F\SO\201\168\DLE~\DC4*", _properties = [PropSharedSubscriptionAvailable 193,PropServerReference "|>\135\195Ne\DC4\rZ\195\149\\M+\222\229\233Z\205\250!\166\203\ENQ;H\163\237\160\193",PropReasonString "",PropServerKeepAlive 13435,PropResponseInformation "G^|\US,",PropRequestResponseInformation 100,PropMessageExpiryInterval 16479,PropMaximumQoS 141,PropSharedSubscriptionAvailable 7,PropResponseInformation "%",PropAssignedClientIdentifier "G\143e\243\ENQ\140v\130\184\GS\166ZP\165\167\ETX",PropMaximumPacketSize 4489,PropAssignedClientIdentifier "\SOH{8\SI\SOH\145\198\189\n",PropUserProperty "\FS\a(\221\vhE\SYN\171\203\&6w\130\RS<" "\ETX\205\187\187\219\&8\159$\153\DC20^\253u\198\149\176\DLE\203I&\241\250\197\171\176",PropReasonString "\223\227\225",PropSessionExpiryInterval 2978,PropUserProperty "\226\225\229\235\CANlF\139\194\129\218uo" "\SI\197t\226\173m^#\217*+\141\153\236\GS\185/\166\242&\167d\152,\216\a\245\231\&2",PropWillDelayInterval 21460,PropContentType "[h",PropMessageExpiryInterval 21321,PropWillDelayInterval 26395,PropPayloadFormatIndicator 242,PropContentType "\RS`"]} -TEST(Connect5QCTest, Encode18) { -uint8_t pkt[] = {0x10, 0xa3, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x5e, 0xa2, 0xe7, 0x1, 0x2a, 0xc1, 0x1c, 0x0, 0x1e, 0x7c, 0x3e, 0x87, 0xc3, 0x4e, 0x65, 0x14, 0xd, 0x5a, 0xc3, 0x95, 0x5c, 0x4d, 0x2b, 0xde, 0xe5, 0xe9, 0x5a, 0xcd, 0xfa, 0x21, 0xa6, 0xcb, 0x5, 0x3b, 0x48, 0xa3, 0xed, 0xa0, 0xc1, 0x1f, 0x0, 0x0, 0x13, 0x34, 0x7b, 0x1a, 0x0, 0x5, 0x47, 0x5e, 0x7c, 0x1f, 0x2c, 0x19, 0x64, 0x2, 0x0, 0x0, 0x40, 0x5f, 0x24, 0x8d, 0x2a, 0x7, 0x1a, 0x0, 0x1, 0x25, 0x12, 0x0, 0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xed, 0xa0, 0xc1}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x47, 0x5e, 0x7c, 0x1f, 0x2c}; - uint8_t bytesprops3[] = {0x25}; - uint8_t bytesprops4[] = {0x47, 0x8f, 0x65, 0xf3, 0x5, 0x8c, 0x76, 0x82, 0xb8, 0x1d, 0xa6, 0x5a, 0x50, 0xa5, 0xa7, 0x3}; - uint8_t bytesprops5[] = {0x1, 0x7b, 0x38, 0xf, 0x1, 0x91, 0xc6, 0xbd, 0xa}; - uint8_t bytesprops7[] = {0x3, 0xcd, 0xbb, 0xbb, 0xdb, 0x38, 0x9f, 0x24, 0x99, 0x12, 0x30, 0x5e, 0xfd, 0x75, 0xc6, 0x95, 0xb0, 0x10, 0xcb, 0x49, 0x26, 0xf1, 0xfa, 0xc5, 0xab, 0xb0}; - uint8_t bytesprops6[] = {0x1c, 0x7, 0x28, 0xdd, 0xb, 0x68, 0x45, 0x16, 0xab, 0xcb, 0x36, 0x77, 0x82, 0x1e, 0x3c}; - uint8_t bytesprops8[] = {0xdf, 0xe3, 0xe1}; - uint8_t bytesprops10[] = {0xf, 0xc5, 0x74, 0xe2, 0xad, 0x6d, 0x5e, 0x23, 0xd9, 0x2a, 0x2b, 0x8d, 0x99, 0xec, 0x1d, 0xb9, 0x2f, 0xa6, 0xf2, 0x26, 0xa7, 0x64, 0x98, 0x2c, 0xd8, 0x7, 0xf5, 0xe7, 0x32}; - uint8_t bytesprops9[] = {0xe2, 0xe1, 0xe5, 0xeb, 0x18, 0x6c, 0x46, 0x8b, 0xc2, 0x81, 0xda, 0x75, 0x6f}; - uint8_t bytesprops11[] = {0x5b, 0x68}; - uint8_t bytesprops12[] = {0x1e, 0x60}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13435}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16479}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4489}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={15, (char*)&bytesprops6}, .v={26, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2978}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={13, (char*)&bytesprops9}, .v={29, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21460}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21321}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26395}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops12}}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25298}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27525}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20976}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30112}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9433}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7916}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28237}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32319}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24039}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe2, 0xde, 0x5, 0xb7, 0x9f, 0x99, 0x7b, 0xac}; - uint8_t byteswillprops1[] = {0x19, 0xd7, 0x85}; - uint8_t byteswillprops2[] = {0x17, 0xc8, 0x85, 0x7d, 0xc7, 0xc0, 0xb9, 0x9a, 0xd7, 0xbd, 0x7a, 0x48, 0xd0, 0xc8, 0x94, 0x10, 0x65, 0x66}; - uint8_t byteswillprops3[] = {0x1a, 0xc8, 0xcc, 0xf9, 0x99, 0x15, 0xd0, 0xa0, 0x26, 0x12, 0x7c, 0x9, 0x7b, 0x49, 0xdc, 0x7d, 0xae}; - uint8_t byteswillprops4[] = {0x7c, 0x89, 0x66, 0xd0, 0xa4, 0x59}; - + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27045}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27246}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5739}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27782}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2942}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&byteswillprops4}}}, - }; - - lwmqtt_properties_t willprops = {12, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1e, 0x63, 0x67, 0xc3, 0xfa, 0x88, 0xf6, 0xe1, 0xff, 0xa6, 0x4c, 0x6d, 0xa5, 0xce, 0xb7, 0x9f}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xde, 0xee, 0xf4, 0x2e, 0x8b, 0x4f, 0x4a}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 24226; - uint8_t client_id_bytes[] = {0xab, 0x21, 0x9b, 0x6f, 0x2f, 0x20, 0x46, 0xe, 0xc9, 0xa8, 0x10, 0x7e, 0x14, 0x2a}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xe8, 0x67, 0xde, 0x31, 0xfe, 0x19, 0xc3, 0x7d, 0x1c, 0x9f, 0x68, 0xff, 0x14, 0x4a, 0x83, 0x3a, 0xfa, 0x8b, 0xf3, 0xf5, 0x4c, 0x16, 0x84, 0xed, 0x91, 0xda, 0x6c, 0x95, 0x93, 0x44}; - lwmqtt_string_t username = {30, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0xd8, 0x16}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18028}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + }; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x40, 0x6c, 0x69, 0xb9, 0x53, 0x53}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe1, 0x39, 0x4c, 0xd7, 0x5, 0x18, 0x9e, 0x77, + 0x8e, 0x50, 0x4, 0xdb, 0x9d, 0xe3, 0xa0}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 7971; + uint8_t client_id_bytes[] = {0x54, 0x15, 0x96, 0x9c, 0x90, 0xe0, 0xd5, 0x94, 0x50, 0xa1, 0x44, + 0xd8, 0xef, 0x5a, 0x45, 0xab, 0xb9, 0xa9, 0x63, 0x2, 0xad}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x19, 0x7e, 0x84, 0xb2, 0x1d, 0xa9, 0x26, 0x8f, 0x2a, 0x4a, 0x1c, 0xdf}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "\231\"\140\184\150\129\176\136", _password = Just "<", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\228\186\150\165\217\210\189", _willMsg = +// "\240\DC2\156\154E\165|\209S\189p\140", _willProps = [PropMaximumPacketSize 21557,PropTopicAlias +// 29303,PropUserProperty "`\DC2\163\247*\242>\239" +// "``(\241\182\199\228\185\150\184\231=\248A\NAK\179\a\151F\249",PropSubscriptionIdentifier 18]}), _cleanSession = +// True, _keepAlive = 14805, _connID = "\224\153\138 P\CAN\176\DLEz2\177\169\171\247\192rU\190\&9\189\196\149o?t", +// _properties = [PropMessageExpiryInterval 19004,PropSubscriptionIdentifierAvailable 55,PropTopicAliasMaximum +// 26303,PropTopicAlias 17188,PropResponseTopic "\ty}\232\212\t\DC2",PropSessionExpiryInterval +// 15240,PropResponseInformation +// "\157\NULA\206\252\149\US>:\220\132Yq\255\DC1\207\&8\243\SOH\EM\US\186\206\244R",PropServerKeepAlive +// 29200,PropMaximumQoS 169,PropTopicAlias 7816,PropMaximumPacketSize 17164,PropResponseInformation +// ":\SYN\208\206\EOT",PropPayloadFormatIndicator 5,PropMessageExpiryInterval 19457,PropReasonString +// "\SONXs\180Ob!\146\155\178~\137",PropCorrelationData "\EMjP\179,+,\144\241\161zl\244",PropTopicAliasMaximum +// 3531,PropRetainAvailable 31,PropWildcardSubscriptionAvailable 118,PropRetainAvailable 181,PropAuthenticationData +// "eSSMz\235J\186\NAKE8>;\241",PropResponseInformation +// "f[\201\SO\DLEvP\181\236\142\&5%\b\201\255^'\136q{",PropContentType "",PropReasonString +// "\ACK\150A\215\157\218\133",PropRequestResponseInformation 2,PropCorrelationData "=\184\178",PropServerKeepAlive +// 22022,PropPayloadFormatIndicator 214,PropAssignedClientIdentifier "5#\201\SUB"]} +TEST(Connect5QCTest, Encode18) { + uint8_t pkt[] = { + 0x10, 0xbd, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x39, 0xd5, 0xc6, 0x1, 0x2, 0x0, 0x0, 0x4a, + 0x3c, 0x29, 0x37, 0x22, 0x66, 0xbf, 0x23, 0x43, 0x24, 0x8, 0x0, 0x7, 0x9, 0x79, 0x7d, 0xe8, 0xd4, 0x9, 0x12, + 0x11, 0x0, 0x0, 0x3b, 0x88, 0x1a, 0x0, 0x19, 0x9d, 0x0, 0x41, 0xce, 0xfc, 0x95, 0x1f, 0x3e, 0x3a, 0xdc, 0x84, + 0x59, 0x71, 0xff, 0x11, 0xcf, 0x38, 0xf3, 0x1, 0x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 0xf7, 0x2a, 0xf2, 0x3e, 0xef, 0x0, 0x14, 0x60, 0x60, 0x28, 0xf1, + 0xb6, 0xc7, 0xe4, 0xb9, 0x96, 0xb8, 0xe7, 0x3d, 0xf8, 0x41, 0x15, 0xb3, 0x7, 0x97, 0x46, 0xf9, 0xb, 0x12, 0x0, + 0x7, 0xe4, 0xba, 0x96, 0xa5, 0xd9, 0xd2, 0xbd, 0x0, 0xc, 0xf0, 0x12, 0x9c, 0x9a, 0x45, 0xa5, 0x7c, 0xd1, 0x53, + 0xbd, 0x70, 0x8c, 0x0, 0x8, 0xe7, 0x22, 0x8c, 0xb8, 0x96, 0x81, 0xb0, 0x88, 0x0, 0x1, 0x3c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x9, 0x79, 0x7d, 0xe8, 0xd4, 0x9, 0x12}; + uint8_t bytesprops1[] = {0x9d, 0x0, 0x41, 0xce, 0xfc, 0x95, 0x1f, 0x3e, 0x3a, 0xdc, 0x84, 0x59, 0x71, + 0xff, 0x11, 0xcf, 0x38, 0xf3, 0x1, 0x19, 0x1f, 0xba, 0xce, 0xf4, 0x52}; + uint8_t bytesprops2[] = {0x3a, 0x16, 0xd0, 0xce, 0x4}; + uint8_t bytesprops3[] = {0xe, 0x4e, 0x58, 0x73, 0xb4, 0x4f, 0x62, 0x21, 0x92, 0x9b, 0xb2, 0x7e, 0x89}; + uint8_t bytesprops4[] = {0x19, 0x6a, 0x50, 0xb3, 0x2c, 0x2b, 0x2c, 0x90, 0xf1, 0xa1, 0x7a, 0x6c, 0xf4}; + uint8_t bytesprops5[] = {0x65, 0x53, 0x53, 0x4d, 0x7a, 0xeb, 0x4a, 0xba, 0x15, 0x45, 0x38, 0x3e, 0x3b, 0xf1}; + uint8_t bytesprops6[] = {0x66, 0x5b, 0xc9, 0xe, 0x10, 0x76, 0x50, 0xb5, 0xec, 0x8e, + 0x35, 0x25, 0x8, 0xc9, 0xff, 0x5e, 0x27, 0x88, 0x71, 0x7b}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops8[] = {0x6, 0x96, 0x41, 0xd7, 0x9d, 0xda, 0x85}; + uint8_t bytesprops9[] = {0x3d, 0xb8, 0xb2}; + uint8_t bytesprops10[] = {0x35, 0x23, 0xc9, 0x1a}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19004}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26303}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17188}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15240}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29200}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7816}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17164}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19457}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3531}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22022}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops10}}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x60, 0x60, 0x28, 0xf1, 0xb6, 0xc7, 0xe4, 0xb9, 0x96, 0xb8, + 0xe7, 0x3d, 0xf8, 0x41, 0x15, 0xb3, 0x7, 0x97, 0x46, 0xf9}; + uint8_t byteswillprops0[] = {0x60, 0x12, 0xa3, 0xf7, 0x2a, 0xf2, 0x3e, 0xef}; -// ConnectRequest {_username = Just "'\216\163|\221m\165\171\236!\179M84\232bZ\149\154\234\158", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\184\185\180\202\170\173g\tsp\221\170\169{\210\160\247\SOH\tG\158N5", _willMsg = "\\\RS/%&ik\DC2\234\228\US\198.*o\190$\DC1\234\187\154\212\129", _willProps = [PropMessageExpiryInterval 13124,PropSharedSubscriptionAvailable 96,PropServerKeepAlive 28528,PropRequestProblemInformation 20,PropTopicAliasMaximum 15600,PropRequestProblemInformation 130,PropRequestProblemInformation 69,PropAuthenticationData "QMO\210\152\135d\221Rk\200\241\164\230\252\179L\t%^\223\&0\240\201\n\180\209\ACK\196\191",PropMaximumQoS 38,PropWillDelayInterval 26473,PropServerKeepAlive 30083,PropResponseInformation "b\183\173\146\223d\203Gv\180\a\SI\254\SOHS",PropServerKeepAlive 29179,PropReasonString ",\173\232\203\190\DC4\138\244\162\&7\r\189\206",PropTopicAliasMaximum 17148,PropSubscriptionIdentifier 0,PropWildcardSubscriptionAvailable 52,PropSharedSubscriptionAvailable 9,PropContentType "Yk\252k\SOHn\142T\173l'\202s;fp0\153",PropSessionExpiryInterval 25517,PropPayloadFormatIndicator 54,PropSessionExpiryInterval 8919,PropRequestResponseInformation 201,PropAuthenticationMethod ")\DC2\239\174$\181\&3\246@`\187\229h\235&(S\152\215\a\188\177o",PropRequestResponseInformation 29,PropPayloadFormatIndicator 220,PropTopicAliasMaximum 28976]}), _cleanSession = False, _keepAlive = 10411, _connID = "V\EOTi\ETB\252n}!\239\188\234\&2;b\241\237$\230\184\167\154\163\NUL\206\175", _properties = [PropMessageExpiryInterval 4653,PropAuthenticationData "\ENQ\ESC}e\202\ACK\137J3$S\193J\212\226\SI5#\241",PropTopicAliasMaximum 6022,PropSharedSubscriptionAvailable 85,PropSubscriptionIdentifierAvailable 115,PropTopicAlias 6097,PropCorrelationData "#\205q\132\210k",PropReasonString "\ETX\183\132Ls\182\237\NULq\133\237\150\217\\\249",PropReasonString "\244~Qi\140\239\180\217PF\DC1%8u\159z\142\153\&9\186\202",PropUserProperty "a" "\227\166];6JQ]\225K\ETX\ACK\206\SUBv\250\171\238\169",PropMaximumPacketSize 12838,PropTopicAlias 30479,PropRequestResponseInformation 136,PropServerReference "\184\222\254\166\226M\154\133\134\RSKr\SOH\151\206jJ%p\SIz\188\211\222",PropPayloadFormatIndicator 93,PropRetainAvailable 101,PropMaximumQoS 51,PropAuthenticationMethod "z\US\215\164\243U\ESC\243\150\251\"\243-\196\245\DLE\203\SI\144\r",PropAssignedClientIdentifier "\170V\SO\242'\ETX2\GS\215\aN\133\184\ETXI\245\157\131\137\139\STX1\201\167\129\230\n\129",PropReasonString "#\v\167\201X=\229gs{",PropUserProperty "*]}\189\211\r",PropSharedSubscriptionAvailable 77,PropReasonString +// "\236c\164K\EOT.\172\212\ETB\SI=;\a\182\\\DC4S@[\DLE\249\199"]}), _cleanSession = False, _keepAlive = 487, _connID = +// "\r\196\187Nr\226\142\198\223\237\224\191", _properties = [PropWillDelayInterval 15241,PropResponseTopic +// "",PropRetainAvailable 19,PropRequestResponseInformation 209,PropMessageExpiryInterval +// 20291,PropRequestProblemInformation 234,PropAuthenticationData +// "h\194b\194/\EOTt\222\132:\184P\129(\n\ETB\204\153=\227\199",PropCorrelationData +// "\166&\246r\226\165W",PropRequestResponseInformation 23,PropSubscriptionIdentifierAvailable 8,PropReasonString +// "",PropSharedSubscriptionAvailable 201,PropContentType +// "qE^\SYNX\217\210\221V\213o\139B\GS\154'k\247\197\224P_&\249D\177[",PropTopicAlias 31279,PropRetainAvailable +// 96,PropAuthenticationMethod "m\189\149\&0\137\208",PropMessageExpiryInterval 587,PropUserProperty +// "7\248O\161+\b\132\138qy\134\163\190+\136\210\166\211\\)or\175\128/>)" +// "\158@\161\145\186\180\NAK\170\233X}\161}\r\DLE\232fW1\250t\170H",PropContentType "\141\179\ESC\210@\216<\220c[t +// \145m\178`T[Y\t\147+O\249\196\139\ESC\138",PropAuthenticationMethod "\249\253|\205H"]} +TEST(Connect5QCTest, Encode19) { + uint8_t pkt[] = { + 0x10, 0xe0, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x1, 0xe7, 0xcd, 0x1, 0x18, 0x0, 0x0, 0x3b, + 0x89, 0x8, 0x0, 0x0, 0x25, 0x13, 0x19, 0xd1, 0x2, 0x0, 0x0, 0x4f, 0x43, 0x17, 0xea, 0x16, 0x0, 0x15, 0x68, + 0xc2, 0x62, 0xc2, 0x2f, 0x4, 0x74, 0xde, 0x84, 0x3a, 0xb8, 0x50, 0x81, 0x28, 0xa, 0x17, 0xcc, 0x99, 0x3d, 0xe3, + 0xc7, 0x9, 0x0, 0x7, 0xa6, 0x26, 0xf6, 0x72, 0xe2, 0xa5, 0x57, 0x19, 0x17, 0x29, 0x8, 0x1f, 0x0, 0x0, 0x2a, + 0xc9, 0x3, 0x0, 0x1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x16, 0xec, 0x63, + 0xa4, 0x4b, 0x4, 0x2e, 0xac, 0xd4, 0x17, 0xf, 0x3d, 0x3b, 0x7, 0xb6, 0x5c, 0x14, 0x53, 0x40, 0x5b, 0x10, 0xf9, + 0xc7, 0x0, 0x1b, 0x47, 0x6e, 0xd, 0x20, 0x6b, 0xae, 0x5d, 0xd4, 0x21, 0x6e, 0x4e, 0xb0, 0xd9, 0xb9, 0x68, 0xd3, + 0x2a, 0xa6, 0x9, 0xa0, 0xa9, 0xb, 0xa8, 0x71, 0xae, 0x3e, 0x7a, 0x0, 0x2, 0x0, 0xf7, 0x0, 0xd, 0x49, 0x11, + 0x61, 0x4, 0xd9, 0x98, 0x35, 0xce, 0x91, 0x84, 0xe8, 0x7a, 0x9d, 0x0, 0x13, 0xd7, 0xeb, 0x95, 0x69, 0x8c, 0x75, + 0x1a, 0x7f, 0x70, 0x89, 0x8d, 0x71, 0x3f, 0xf6, 0x5b, 0x67, 0xc8, 0x95, 0x65}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x68, 0xc2, 0x62, 0xc2, 0x2f, 0x4, 0x74, 0xde, 0x84, 0x3a, 0xb8, + 0x50, 0x81, 0x28, 0xa, 0x17, 0xcc, 0x99, 0x3d, 0xe3, 0xc7}; + uint8_t bytesprops2[] = {0xa6, 0x26, 0xf6, 0x72, 0xe2, 0xa5, 0x57}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x71, 0x45, 0x5e, 0x16, 0x58, 0xd9, 0xd2, 0xdd, 0x56, 0xd5, 0x6f, 0x8b, 0x42, 0x1d, + 0x9a, 0x27, 0x6b, 0xf7, 0xc5, 0xe0, 0x50, 0x5f, 0x26, 0xf9, 0x44, 0xb1, 0x5b}; + uint8_t bytesprops5[] = {0x6d, 0xbd, 0x95, 0x30, 0x89, 0xd0}; + uint8_t bytesprops7[] = {0x9e, 0x40, 0xa1, 0x91, 0xba, 0xb4, 0x15, 0xaa, 0xe9, 0x58, 0x7d, 0xa1, + 0x7d, 0xd, 0x10, 0xe8, 0x66, 0x57, 0x31, 0xfa, 0x74, 0xaa, 0x48}; + uint8_t bytesprops6[] = {0x37, 0xf8, 0x4f, 0xa1, 0x2b, 0x8, 0x84, 0x8a, 0x71, 0x79, 0x86, 0xa3, 0xbe, 0x2b, + 0x88, 0xd2, 0xa6, 0xd3, 0x5c, 0x29, 0x6f, 0x72, 0xaf, 0x80, 0x2f, 0x3e, 0x29}; + uint8_t bytesprops8[] = {0x8d, 0xb3, 0x1b, 0xd2, 0x40, 0xd8, 0x3c, 0xdc, 0x63, 0x5b, 0x74, 0x20, 0x91, 0x6d, + 0xb2, 0x60, 0x54, 0x5b, 0x59, 0x9, 0x93, 0x2b, 0x4f, 0xf9, 0xc4, 0x8b, 0x1b, 0x8a}; + uint8_t bytesprops9[] = {0xf9, 0xfd, 0x7c, 0xcd, 0x48}; -// ConnectRequest {_username = Just "\238E\235\195\176i4\ETX\156\201\169\199m\192\SO\135|\184\247", _password = Just "\148!\GS\GS3\143\183\154J\SOF\207+\154$\189\201\133\152\220\230c\213i", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\176\187R!\190\252\137", _willMsg = "\CAN\202\249i\219", _willProps = [PropAuthenticationData "\a\167\247[w%\132",PropMaximumPacketSize 7772,PropRetainAvailable 12,PropUserProperty "W\184\249=-\141\255O\171\135" "\"sR\193",PropWildcardSubscriptionAvailable 189,PropSessionExpiryInterval 32113,PropRequestProblemInformation 100,PropContentType "*",PropPayloadFormatIndicator 34,PropSubscriptionIdentifier 23,PropMessageExpiryInterval 14823,PropSharedSubscriptionAvailable 28,PropPayloadFormatIndicator 105,PropWillDelayInterval 25676,PropSubscriptionIdentifierAvailable 19,PropSubscriptionIdentifierAvailable 139,PropServerReference "\168\226\184UW\a\247u\SOH\189\168\GS\208x\DELr\238\&2\131\136\252\DC1wb@\253\187\216",PropResponseTopic "\139\&3\222\139u\151\EOT\197\227\FS\229\RS&)\228\203.\146\134"]}), _cleanSession = True, _keepAlive = 11619, _connID = ")G\205}(\"\172\143lX\215\SYNQT\CAN7\194\138\RS\DELr3\144\SIn\185\210y", _properties = [PropWillDelayInterval 12505,PropTopicAlias 25947,PropSubscriptionIdentifier 27,PropAuthenticationMethod "\245\232\ENQ\165\ETX_\"M\202^\131\NAK",PropReasonString "5\248\&0`O)Yc\SUB\193%\213k&\194\222\228\162K\CAN\ENQ\rYU\175",PropResponseInformation "\202A\DC3\NUL\183R(\251\165",PropSubscriptionIdentifierAvailable 112,PropMessageExpiryInterval 32467,PropMaximumQoS 119,PropTopicAliasMaximum 1295,PropRequestResponseInformation 31,PropUserProperty "p~\202\210\160\r\232\207\139\190\185Q\\\184\216\EM\205b\206E[C\203U\231R$" "\203\253\162HA\ETB!",PropMessageExpiryInterval 14912,PropResponseTopic "\EOT^\DC4\187\166\157\NAK\SUB\168#\160\FS\192\f\164=\201b",PropReasonString "\RS\ACK\170W",PropSubscriptionIdentifierAvailable 181,PropAuthenticationMethod "p\b\FSb\rR\162\SO\241\212\&4\252\155\141\187\183m\182",PropCorrelationData "",PropReceiveMaximum 13177,PropResponseInformation "{\240\147\201uL\197\198\225\201\163\139\161&\197\SYN\NUL",PropReasonString "9)I7\165\177\139",PropAssignedClientIdentifier "\163Li\247\216\205=\219;\166\186\170\234\186\181\153",PropSubscriptionIdentifier 25,PropReceiveMaximum 31829,PropPayloadFormatIndicator 122,PropCorrelationData "\EM\168M`\160\142j",PropContentType "\194\217\DC4c\131\142\217\205",PropServerKeepAlive 7189,PropMessageExpiryInterval 22850,PropServerKeepAlive 32407]} -TEST(Connect5QCTest, Encode20) { -uint8_t pkt[] = {0x10, 0xf2, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x2d, 0x63, 0x8c, 0x2, 0x18, 0x0, 0x0, 0x30, 0xd9, 0x23, 0x65, 0x5b, 0xb, 0x1b, 0x15, 0x0, 0x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x32, 0x83, 0x88, 0xfc, 0x11, 0x77, 0x62, 0x40, 0xfd, 0xbb, 0xd8, 0x8, 0x0, 0x13, 0x8b, 0x33, 0xde, 0x8b, 0x75, 0x97, 0x4, 0xc5, 0xe3, 0x1c, 0xe5, 0x1e, 0x26, 0x29, 0xe4, 0xcb, 0x2e, 0x92, 0x86, 0x0, 0x7, 0xb0, 0xbb, 0x52, 0x21, 0xbe, 0xfc, 0x89, 0x0, 0x5, 0x18, 0xca, 0xf9, 0x69, 0xdb, 0x0, 0x13, 0xee, 0x45, 0xeb, 0xc3, 0xb0, 0x69, 0x34, 0x3, 0x9c, 0xc9, 0xa9, 0xc7, 0x6d, 0xc0, 0xe, 0x87, 0x7c, 0xb8, 0xf7, 0x0, 0x18, 0x94, 0x21, 0x1d, 0x1d, 0x33, 0x8f, 0xb7, 0x9a, 0x4a, 0xe, 0x46, 0xcf, 0x2b, 0x9a, 0x24, 0xbd, 0xc9, 0x85, 0x98, 0xdc, 0xe6, 0x63, 0xd5, 0x69}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xf5, 0xe8, 0x5, 0xa5, 0x3, 0x5f, 0x22, 0x4d, 0xca, 0x5e, 0x83, 0x15}; - uint8_t bytesprops1[] = {0x35, 0xf8, 0x30, 0x60, 0x4f, 0x29, 0x59, 0x63, 0x1a, 0xc1, 0x25, 0xd5, 0x6b, 0x26, 0xc2, 0xde, 0xe4, 0xa2, 0x4b, 0x18, 0x5, 0xd, 0x59, 0x55, 0xaf}; - uint8_t bytesprops2[] = {0xca, 0x41, 0x13, 0x0, 0xb7, 0x52, 0x28, 0xfb, 0xa5}; - uint8_t bytesprops4[] = {0xcb, 0xfd, 0xa2, 0x48, 0x41, 0x17, 0x21}; - uint8_t bytesprops3[] = {0x70, 0x7e, 0xca, 0xd2, 0xa0, 0xd, 0xe8, 0xcf, 0x8b, 0xbe, 0xb9, 0x51, 0x5c, 0xb8, 0xd8, 0x19, 0xcd, 0x62, 0xce, 0x45, 0x5b, 0x43, 0xcb, 0x55, 0xe7, 0x52, 0x24}; - uint8_t bytesprops5[] = {0x4, 0x5e, 0x14, 0xbb, 0xa6, 0x9d, 0x15, 0x1a, 0xa8, 0x23, 0xa0, 0x1c, 0xc0, 0xc, 0xa4, 0x3d, 0xc9, 0x62}; - uint8_t bytesprops6[] = {0x1e, 0x6, 0xaa, 0x57}; - uint8_t bytesprops7[] = {0x70, 0x8, 0x1c, 0x62, 0xd, 0x52, 0xa2, 0xe, 0xf1, 0xd4, 0x34, 0xfc, 0x9b, 0x8d, 0xbb, 0xb7, 0x6d, 0xb6}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops9[] = {0x7b, 0xf0, 0x93, 0xc9, 0x75, 0x4c, 0xc5, 0xc6, 0xe1, 0xc9, 0xa3, 0x8b, 0xa1, 0x26, 0xc5, 0x16, 0x0}; - uint8_t bytesprops10[] = {0x39, 0x29, 0x49, 0x37, 0xa5, 0xb1, 0x8b}; - uint8_t bytesprops11[] = {0xa3, 0x4c, 0x69, 0xf7, 0xd8, 0xcd, 0x3d, 0xdb, 0x3b, 0xa6, 0xba, 0xaa, 0xea, 0xba, 0xb5, 0x99}; - uint8_t bytesprops12[] = {0x19, 0xa8, 0x4d, 0x60, 0xa0, 0x8e, 0x6a}; - uint8_t bytesprops13[] = {0xc2, 0xd9, 0x14, 0x63, 0x83, 0x8e, 0xd9, 0xcd}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12505}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25947}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32467}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1295}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={27, (char*)&bytesprops3}, .v={7, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14912}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13177}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31829}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7189}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22850}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32407}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15241}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20291}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31279}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 587}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops6}, .v = {23, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x7, 0xa7, 0xf7, 0x5b, 0x77, 0x25, 0x84}; - uint8_t byteswillprops2[] = {0x22, 0x73, 0x52, 0xc1}; - uint8_t byteswillprops1[] = {0x57, 0xb8, 0xf9, 0x3d, 0x2d, 0x8d, 0xff, 0x4f, 0xab, 0x87}; - uint8_t byteswillprops3[] = {0x2a}; - uint8_t byteswillprops4[] = {0xa8, 0xe2, 0xb8, 0x55, 0x57, 0x7, 0xf7, 0x75, 0x1, 0xbd, 0xa8, 0x1d, 0xd0, 0x78, 0x7f, 0x72, 0xee, 0x32, 0x83, 0x88, 0xfc, 0x11, 0x77, 0x62, 0x40, 0xfd, 0xbb, 0xd8}; - uint8_t byteswillprops5[] = {0x8b, 0x33, 0xde, 0x8b, 0x75, 0x97, 0x4, 0xc5, 0xe3, 0x1c, 0xe5, 0x1e, 0x26, 0x29, 0xe4, 0xcb, 0x2e, 0x92, 0x86}; - + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xea, 0x2d, 0x6, 0x45, 0xae, 0x19, 0xf6, 0x32, 0x48, 0xf8, 0xf3, + 0x4d, 0xb8, 0xf6, 0x64, 0xb9, 0x6c, 0x48, 0xac, 0x3e, 0xd}; + uint8_t byteswillprops1[] = {0xec, 0x63, 0xa4, 0x4b, 0x4, 0x2e, 0xac, 0xd4, 0x17, 0xf, 0x3d, + 0x3b, 0x7, 0xb6, 0x5c, 0x14, 0x53, 0x40, 0x5b, 0x10, 0xf9, 0xc7}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7772}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={10, (char*)&byteswillprops1}, .v={4, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32113}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14823}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25676}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&byteswillprops1}}}, }; - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb0, 0xbb, 0x52, 0x21, 0xbe, 0xfc, 0x89}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x18, 0xca, 0xf9, 0x69, 0xdb}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 11619; - uint8_t client_id_bytes[] = {0x29, 0x47, 0xcd, 0x7d, 0x28, 0x22, 0xac, 0x8f, 0x6c, 0x58, 0xd7, 0x16, 0x51, 0x54, 0x18, 0x37, 0xc2, 0x8a, 0x1e, 0x7f, 0x72, 0x33, 0x90, 0xf, 0x6e, 0xb9, 0xd2, 0x79}; - lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xee, 0x45, 0xeb, 0xc3, 0xb0, 0x69, 0x34, 0x3, 0x9c, 0xc9, 0xa9, 0xc7, 0x6d, 0xc0, 0xe, 0x87, 0x7c, 0xb8, 0xf7}; - lwmqtt_string_t username = {19, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0x94, 0x21, 0x1d, 0x1d, 0x33, 0x8f, 0xb7, 0x9a, 0x4a, 0xe, 0x46, 0xcf, 0x2b, 0x9a, 0x24, 0xbd, 0xc9, 0x85, 0x98, 0xdc, 0xe6, 0x63, 0xd5, 0x69}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x47, 0x6e, 0xd, 0x20, 0x6b, 0xae, 0x5d, 0xd4, 0x21, 0x6e, 0x4e, 0xb0, 0xd9, 0xb9, + 0x68, 0xd3, 0x2a, 0xa6, 0x9, 0xa0, 0xa9, 0xb, 0xa8, 0x71, 0xae, 0x3e, 0x7a}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x0, 0xf7}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 487; + uint8_t client_id_bytes[] = {0xd, 0xc4, 0xbb, 0x4e, 0x72, 0xe2, 0x8e, 0xc6, 0xdf, 0xed, 0xe0, 0xbf}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x49, 0x11, 0x61, 0x4, 0xd9, 0x98, 0x35, 0xce, 0x91, 0x84, 0xe8, 0x7a, 0x9d}; + lwmqtt_string_t username = {13, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xd7, 0xeb, 0x95, 0x69, 0x8c, 0x75, 0x1a, 0x7f, 0x70, 0x89, + 0x8d, 0x71, 0x3f, 0xf6, 0x5b, 0x67, 0xc8, 0x95, 0x65}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "\167Vv", _password = Just "\USefMcY\245s", _lastWill = Just (LastWill {_willRetain +// = False, _willQoS = QoS2, _willTopic = +// "\134q\161\236\217\\\238\&3z\146\f\186\198\211u\250_\r\194\141t~\168w\225t\171\135i\229", _willMsg = +// "\164\252\EOT\203\197\166\171B\177\145\DC4\190\DC3\205\NAK\143\157\SUB\177\248\NAK\129\222\DEL>0H", _willProps = +// [PropServerReference "d\144,t\129\FS",PropSubscriptionIdentifierAvailable 129,PropAuthenticationMethod +// "\199\150\255u",PropMessageExpiryInterval 3290,PropRetainAvailable 208,PropUserProperty +// "\192\236\249h\132\EOTN\164\247\240Q\SOj\SYN{\\\220\&7f\176\246\ETX [^\149i" "_\208\140\255 EQ\153P"]}), +// _cleanSession = False, _keepAlive = 176, _connID = +// "\164\181\166\128r\129\SUB\184rUbzJ\177WIU+\158\DEL\SOH\NAK\164\169", _properties = [PropPayloadFormatIndicator +// 25,PropRequestProblemInformation 231,PropServerKeepAlive 16912,PropWillDelayInterval 27960,PropAuthenticationData +// "\187\206F\f\203\233\146\&1\ACK E\190\232$?\203$\176\206\148",PropAuthenticationData +// "s\128\138\228\251",PropCorrelationData "Bg\160\212q\248:uy\139+-\159{\252\251",PropServerReference +// "k\241\194cF\177\SI\222\EOT\233\241\134\138\142Ql\DC3\223\169\FS@\247\239\226\196\200\RSm",PropMaximumPacketSize +// 28292,PropSharedSubscriptionAvailable 111,PropWildcardSubscriptionAvailable 255,PropSubscriptionIdentifier +// 23,PropAuthenticationData "NH\"\134r\181{.\DC2\205\SI\SI\GS\v\t;\233\146\EM\180\193\DC4X\SI\NULg",PropTopicAlias +// 21077]} +TEST(Connect5QCTest, Encode20) { + uint8_t pkt[] = { + 0x10, 0xbd, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x0, 0xb0, 0x88, 0x1, 0x1, 0x19, 0x17, 0xe7, + 0x13, 0x42, 0x10, 0x18, 0x0, 0x0, 0x6d, 0x38, 0x16, 0x0, 0x14, 0xbb, 0xce, 0x46, 0xc, 0xcb, 0xe9, 0x92, 0x31, + 0x6, 0x20, 0x45, 0xbe, 0xe8, 0x24, 0x3f, 0xcb, 0x24, 0xb0, 0xce, 0x94, 0x16, 0x0, 0x5, 0x73, 0x80, 0x8a, 0xe4, + 0xfb, 0x9, 0x0, 0x10, 0x42, 0x67, 0xa0, 0xd4, 0x71, 0xf8, 0x3a, 0x75, 0x79, 0x8b, 0x2b, 0x2d, 0x9f, 0x7b, 0xfc, + 0xfb, 0x1c, 0x0, 0x1c, 0x6b, 0xf1, 0xc2, 0x63, 0x46, 0xb1, 0xf, 0xde, 0x4, 0xe9, 0xf1, 0x86, 0x8a, 0x8e, 0x51, + 0x6c, 0x13, 0xdf, 0xa9, 0x1c, 0x40, 0xf7, 0xef, 0xe2, 0xc4, 0xc8, 0x1e, 0x6d, 0x27, 0x0, 0x0, 0x6e, 0x84, 0x2a, + 0x6f, 0x28, 0xff, 0xb, 0x17, 0x16, 0x0, 0x1a, 0x4e, 0x48, 0x22, 0x86, 0x72, 0xb5, 0x7b, 0x2e, 0x12, 0xcd, 0xf, + 0xf, 0x1d, 0xb, 0x9, 0x3b, 0xe9, 0x92, 0x19, 0xb4, 0xc1, 0x14, 0x58, 0xf, 0x0, 0x67, 0x23, 0x52, 0x55, 0x0, + 0x18, 0xa4, 0xb5, 0xa6, 0x80, 0x72, 0x81, 0x1a, 0xb8, 0x72, 0x55, 0x62, 0x7a, 0x4a, 0xb1, 0x57, 0x49, 0x55, 0x2b, + 0x9e, 0x7f, 0x1, 0x15, 0xa4, 0xa9, 0x42, 0x1c, 0x0, 0x6, 0x64, 0x90, 0x2c, 0x74, 0x81, 0x1c, 0x29, 0x81, 0x15, + 0x0, 0x4, 0xc7, 0x96, 0xff, 0x75, 0x2, 0x0, 0x0, 0xc, 0xda, 0x25, 0xd0, 0x26, 0x0, 0x1b, 0xc0, 0xec, 0xf9, + 0x68, 0x84, 0x4, 0x4e, 0xa4, 0xf7, 0xf0, 0x51, 0xe, 0x6a, 0x16, 0x7b, 0x5c, 0xdc, 0x37, 0x66, 0xb0, 0xf6, 0x3, + 0x20, 0x5b, 0x5e, 0x95, 0x69, 0x0, 0x9, 0x5f, 0xd0, 0x8c, 0xff, 0x20, 0x45, 0x51, 0x99, 0x50, 0x0, 0x1e, 0x86, + 0x71, 0xa1, 0xec, 0xd9, 0x5c, 0xee, 0x33, 0x7a, 0x92, 0xc, 0xba, 0xc6, 0xd3, 0x75, 0xfa, 0x5f, 0xd, 0xc2, 0x8d, + 0x74, 0x7e, 0xa8, 0x77, 0xe1, 0x74, 0xab, 0x87, 0x69, 0xe5, 0x0, 0x1b, 0xa4, 0xfc, 0x4, 0xcb, 0xc5, 0xa6, 0xab, + 0x42, 0xb1, 0x91, 0x14, 0xbe, 0x13, 0xcd, 0x15, 0x8f, 0x9d, 0x1a, 0xb1, 0xf8, 0x15, 0x81, 0xde, 0x7f, 0x3e, 0x30, + 0x48, 0x0, 0x3, 0xa7, 0x56, 0x76, 0x0, 0x8, 0x1f, 0x65, 0x66, 0x4d, 0x63, 0x59, 0xf5, 0x73}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbb, 0xce, 0x46, 0xc, 0xcb, 0xe9, 0x92, 0x31, 0x6, 0x20, + 0x45, 0xbe, 0xe8, 0x24, 0x3f, 0xcb, 0x24, 0xb0, 0xce, 0x94}; + uint8_t bytesprops1[] = {0x73, 0x80, 0x8a, 0xe4, 0xfb}; + uint8_t bytesprops2[] = {0x42, 0x67, 0xa0, 0xd4, 0x71, 0xf8, 0x3a, 0x75, + 0x79, 0x8b, 0x2b, 0x2d, 0x9f, 0x7b, 0xfc, 0xfb}; + uint8_t bytesprops3[] = {0x6b, 0xf1, 0xc2, 0x63, 0x46, 0xb1, 0xf, 0xde, 0x4, 0xe9, 0xf1, 0x86, 0x8a, 0x8e, + 0x51, 0x6c, 0x13, 0xdf, 0xa9, 0x1c, 0x40, 0xf7, 0xef, 0xe2, 0xc4, 0xc8, 0x1e, 0x6d}; + uint8_t bytesprops4[] = {0x4e, 0x48, 0x22, 0x86, 0x72, 0xb5, 0x7b, 0x2e, 0x12, 0xcd, 0xf, 0xf, 0x1d, + 0xb, 0x9, 0x3b, 0xe9, 0x92, 0x19, 0xb4, 0xc1, 0x14, 0x58, 0xf, 0x0, 0x67}; -// ConnectRequest {_username = Just ";\196\214\158d\DC1\NAK\SUB\139)\218\190\184\241\CANP\STX3V\208&);\255\169\182\226\231`", _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 10023, _connID = "\158\&0\SO\215\199\&6&\NUL\172!u\226\224\240J\178nI", _properties = [PropWildcardSubscriptionAvailable 29,PropRequestProblemInformation 46,PropSharedSubscriptionAvailable 126,PropPayloadFormatIndicator 254,PropWillDelayInterval 20124,PropMessageExpiryInterval 27963]} -TEST(Connect5QCTest, Encode21) { -uint8_t pkt[] = {0x10, 0x50, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x80, 0x27, 0x27, 0x12, 0x28, 0x1d, 0x17, 0x2e, 0x2a, 0x7e, 0x1, 0xfe, 0x18, 0x0, 0x0, 0x4e, 0x9c, 0x2, 0x0, 0x0, 0x6d, 0x3b, 0x0, 0x12, 0x9e, 0x30, 0xe, 0xd7, 0xc7, 0x36, 0x26, 0x0, 0xac, 0x21, 0x75, 0xe2, 0xe0, 0xf0, 0x4a, 0xb2, 0x6e, 0x49, 0x0, 0x1d, 0x3b, 0xc4, 0xd6, 0x9e, 0x64, 0x11, 0x15, 0x1a, 0x8b, 0x29, 0xda, 0xbe, 0xb8, 0xf1, 0x18, 0x50, 0x2, 0x33, 0x56, 0xd0, 0x26, 0x29, 0x3b, 0xff, 0xa9, 0xb6, 0xe2, 0xe7, 0x60}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20124}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27963}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16912}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27960}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28292}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21077}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 10023; - uint8_t client_id_bytes[] = {0x9e, 0x30, 0xe, 0xd7, 0xc7, 0x36, 0x26, 0x0, 0xac, 0x21, 0x75, 0xe2, 0xe0, 0xf0, 0x4a, 0xb2, 0x6e, 0x49}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x3b, 0xc4, 0xd6, 0x9e, 0x64, 0x11, 0x15, 0x1a, 0x8b, 0x29, 0xda, 0xbe, 0xb8, 0xf1, 0x18, 0x50, 0x2, 0x33, 0x56, 0xd0, 0x26, 0x29, 0x3b, 0xff, 0xa9, 0xb6, 0xe2, 0xe7, 0x60}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; -opts.username = username; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x64, 0x90, 0x2c, 0x74, 0x81, 0x1c}; + uint8_t byteswillprops1[] = {0xc7, 0x96, 0xff, 0x75}; + uint8_t byteswillprops3[] = {0x5f, 0xd0, 0x8c, 0xff, 0x20, 0x45, 0x51, 0x99, 0x50}; + uint8_t byteswillprops2[] = {0xc0, 0xec, 0xf9, 0x68, 0x84, 0x4, 0x4e, 0xa4, 0xf7, 0xf0, 0x51, 0xe, 0x6a, 0x16, + 0x7b, 0x5c, 0xdc, 0x37, 0x66, 0xb0, 0xf6, 0x3, 0x20, 0x5b, 0x5e, 0x95, 0x69}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3290}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {27, (char*)&byteswillprops2}, .v = {9, (char*)&byteswillprops3}}}}, + }; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x86, 0x71, 0xa1, 0xec, 0xd9, 0x5c, 0xee, 0x33, 0x7a, 0x92, + 0xc, 0xba, 0xc6, 0xd3, 0x75, 0xfa, 0x5f, 0xd, 0xc2, 0x8d, + 0x74, 0x7e, 0xa8, 0x77, 0xe1, 0x74, 0xab, 0x87, 0x69, 0xe5}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa4, 0xfc, 0x4, 0xcb, 0xc5, 0xa6, 0xab, 0x42, 0xb1, 0x91, 0x14, 0xbe, 0x13, 0xcd, + 0x15, 0x8f, 0x9d, 0x1a, 0xb1, 0xf8, 0x15, 0x81, 0xde, 0x7f, 0x3e, 0x30, 0x48}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 176; + uint8_t client_id_bytes[] = {0xa4, 0xb5, 0xa6, 0x80, 0x72, 0x81, 0x1a, 0xb8, 0x72, 0x55, 0x62, 0x7a, + 0x4a, 0xb1, 0x57, 0x49, 0x55, 0x2b, 0x9e, 0x7f, 0x1, 0x15, 0xa4, 0xa9}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa7, 0x56, 0x76}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x1f, 0x65, 0x66, 0x4d, 0x63, 0x59, 0xf5, 0x73}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// ConnectRequest {_username = Just "g\164\GS\251\214\154t\217\140l\213\150&{\211\130", _password = Just +// "\187\ESC\201\164\156\195h\241\250v8\t\179\193\251[*\142", _lastWill = Nothing, _cleanSession = False, _keepAlive = +// 20540, _connID = "\255k\192]Rmr[\146o,\129", _properties = [PropRequestProblemInformation 43,PropServerReference +// "I\202\f=7\140\141\248\174\184G\141",PropTopicAliasMaximum 20363,PropUserProperty +// "c\182\241\t\ETXAs&\RS2\186\242\&3\STXQ\188\133/\a\138" "!\CAN\SUB\197h\176\168U",PropPayloadFormatIndicator +// 13,PropTopicAlias 10596,PropRetainAvailable 45,PropMessageExpiryInterval 2779,PropReceiveMaximum +// 32036,PropAuthenticationMethod "{",PropSessionExpiryInterval 22898,PropWillDelayInterval +// 3617,PropPayloadFormatIndicator 103]} +TEST(Connect5QCTest, Encode21) { + uint8_t pkt[] = {0x10, 0x93, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x50, 0x3c, 0x54, 0x17, 0x2b, 0x1c, + 0x0, 0xc, 0x49, 0xca, 0xc, 0x3d, 0x37, 0x8c, 0x8d, 0xf8, 0xae, 0xb8, 0x47, 0x8d, 0x22, 0x4f, 0x8b, + 0x26, 0x0, 0x14, 0x63, 0xb6, 0xf1, 0x9, 0x3, 0x41, 0x73, 0x26, 0x1e, 0x32, 0xba, 0xf2, 0x33, 0x2, + 0x51, 0xbc, 0x85, 0x2f, 0x7, 0x8a, 0x0, 0x8, 0x21, 0x18, 0x1a, 0xc5, 0x68, 0xb0, 0xa8, 0x55, 0x1, + 0xd, 0x23, 0x29, 0x64, 0x25, 0x2d, 0x2, 0x0, 0x0, 0xa, 0xdb, 0x21, 0x7d, 0x24, 0x15, 0x0, 0x1, + 0x7b, 0x11, 0x0, 0x0, 0x59, 0x72, 0x18, 0x0, 0x0, 0xe, 0x21, 0x1, 0x67, 0x0, 0xc, 0xff, 0x6b, + 0xc0, 0x5d, 0x52, 0x6d, 0x72, 0x5b, 0x92, 0x6f, 0x2c, 0x81, 0x0, 0x10, 0x67, 0xa4, 0x1d, 0xfb, 0xd6, + 0x9a, 0x74, 0xd9, 0x8c, 0x6c, 0xd5, 0x96, 0x26, 0x7b, 0xd3, 0x82, 0x0, 0x12, 0xbb, 0x1b, 0xc9, 0xa4, + 0x9c, 0xc3, 0x68, 0xf1, 0xfa, 0x76, 0x38, 0x9, 0xb3, 0xc1, 0xfb, 0x5b, 0x2a, 0x8e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x49, 0xca, 0xc, 0x3d, 0x37, 0x8c, 0x8d, 0xf8, 0xae, 0xb8, 0x47, 0x8d}; + uint8_t bytesprops2[] = {0x21, 0x18, 0x1a, 0xc5, 0x68, 0xb0, 0xa8, 0x55}; + uint8_t bytesprops1[] = {0x63, 0xb6, 0xf1, 0x9, 0x3, 0x41, 0x73, 0x26, 0x1e, 0x32, + 0xba, 0xf2, 0x33, 0x2, 0x51, 0xbc, 0x85, 0x2f, 0x7, 0x8a}; + uint8_t bytesprops3[] = {0x7b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20363}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10596}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2779}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32036}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22898}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3617}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 103}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 20540; + uint8_t client_id_bytes[] = {0xff, 0x6b, 0xc0, 0x5d, 0x52, 0x6d, 0x72, 0x5b, 0x92, 0x6f, 0x2c, 0x81}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x67, 0xa4, 0x1d, 0xfb, 0xd6, 0x9a, 0x74, 0xd9, + 0x8c, 0x6c, 0xd5, 0x96, 0x26, 0x7b, 0xd3, 0x82}; + lwmqtt_string_t username = {16, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xbb, 0x1b, 0xc9, 0xa4, 0x9c, 0xc3, 0x68, 0xf1, 0xfa, + 0x76, 0x38, 0x9, 0xb3, 0xc1, 0xfb, 0x5b, 0x2a, 0x8e}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} -// ConnectRequest {_username = Just "F\208\168\t~)z\vT8=\231\137\f\197\180\&5\169O\b\222\153\175\180H\193b\154%", _password = Just "\NAK^\RS\171Ce0\DLE\151\171\237L\167#", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\ESCn\STX\167<\196\189\197", _willMsg = "G\NAK\158\v\STX\173\140y\131", _willProps = [PropReasonString "\173)\174\184\DC1\238\&9!\155\158\137%F\172\\\170\226",PropTopicAlias 27587,PropResponseTopic "\204)\152\174\216\139SN\195\157o\176A\166n\165H\229x\225\213",PropContentType "\222\135\SUB\213]d\245\199\DC2\137\190\163\STX^{\152\232\199\&6\141\246\227\199\144",PropUserProperty "\145\US\168\139n0\243dF" "\178LO\128\199",PropSharedSubscriptionAvailable 81,PropResponseTopic "u\ACK\234#\136<\251Lj\200]\143\CAN\t\131\242zy\145\138r\196\\*e\171\b\145\239",PropAuthenticationMethod "m\167\219\175\t\219\175\254efh\210\211D\198F\130qH\206\209"]}), _cleanSession = True, _keepAlive = 17115, _connID = "\224\239\SYNj", _properties = [PropSubscriptionIdentifierAvailable 168,PropAssignedClientIdentifier "\154\245\&7\STXZ\tW",PropMessageExpiryInterval 9213,PropTopicAliasMaximum 20311,PropResponseInformation "\ENQ\246R\134\192\&5",PropMaximumQoS 232,PropSubscriptionIdentifier 22]} +// ConnectRequest {_username = Just "\130\153\246\DLEX\252\184\254\209\234/\229\190\&1k\ENQ\DC1\DEL\186", _password = +// Just "\152\245\222\230\235\f!z\243\&9\224P\250\231\236#\205V", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS1, _willTopic = "\199\149\CAND\190\238\210\161\204\&8C\192\168'\162\198\250\r\142\&0\250", _willMsg = +// "OUI", _willProps = [PropSessionExpiryInterval 8278,PropAssignedClientIdentifier +// "@\190",PropWildcardSubscriptionAvailable 168,PropContentType +// "W/\174\153\144}\206<\184}\ENQ\ETX\ESC@\226\141",PropMessageExpiryInterval 9621,PropMaximumQoS +// 66,PropPayloadFormatIndicator 142,PropReceiveMaximum 25445,PropReceiveMaximum 6056]}), _cleanSession = False, +// _keepAlive = 63, _connID = "\FS\196\a\216\236\229ts[;\209\141\182\141\154#\226\&7H.\199\195\f-\159\183\252c\235", +// _properties = [PropCorrelationData +// "\163\162\179\168\DC1\147\221t\164)z*+\155\135\217\199\STX\DLE\178=\\Q\227\252",PropReasonString +// "b\239\ESC\144",PropTopicAliasMaximum 10076,PropTopicAlias 11906,PropWillDelayInterval +// 20739,PropRequestResponseInformation 233,PropResponseTopic "E\210k\223\184\ETX\ESC",PropServerKeepAlive +// 22113,PropPayloadFormatIndicator 2,PropServerReference "\192`\251\133\252'C^N\f7%"]} TEST(Connect5QCTest, Encode22) { -uint8_t pkt[] = {0x10, 0x8f, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x42, 0xdb, 0x21, 0x29, 0xa8, 0x12, 0x0, 0x7, 0x9a, 0xf5, 0x37, 0x2, 0x5a, 0x9, 0x57, 0x2, 0x0, 0x0, 0x23, 0xfd, 0x22, 0x4f, 0x57, 0x1a, 0x0, 0x6, 0x5, 0xf6, 0x52, 0x86, 0xc0, 0x35, 0x24, 0xe8, 0xb, 0x16, 0x0, 0x4, 0xe0, 0xef, 0x16, 0x6a, 0x97, 0x1, 0x1f, 0x0, 0x11, 0xad, 0x29, 0xae, 0xb8, 0x11, 0xee, 0x39, 0x21, 0x9b, 0x9e, 0x89, 0x25, 0x46, 0xac, 0x5c, 0xaa, 0xe2, 0x23, 0x6b, 0xc3, 0x8, 0x0, 0x15, 0xcc, 0x29, 0x98, 0xae, 0xd8, 0x8b, 0x53, 0x4e, 0xc3, 0x9d, 0x6f, 0xb0, 0x41, 0xa6, 0x6e, 0xa5, 0x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, 0xc7, 0x95, 0x18, 0x44, 0xbe, 0xee, 0xd2, 0xa1, 0xcc, 0x38, 0x43, 0xc0, 0xa8, 0x27, 0xa2, 0xc6, 0xfa, 0xd, + 0x8e, 0x30, 0xfa, 0x0, 0x3, 0x4f, 0x55, 0x49, 0x0, 0x13, 0x82, 0x99, 0xf6, 0x10, 0x58, 0xfc, 0xb8, 0xfe, 0xd1, + 0xea, 0x2f, 0xe5, 0xbe, 0x31, 0x6b, 0x5, 0x11, 0x7f, 0xba, 0x0, 0x12, 0x98, 0xf5, 0xde, 0xe6, 0xeb, 0xc, 0x21, + 0x7a, 0xf3, 0x39, 0xe0, 0x50, 0xfa, 0xe7, 0xec, 0x23, 0xcd, 0x56}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa3, 0xa2, 0xb3, 0xa8, 0x11, 0x93, 0xdd, 0x74, 0xa4, 0x29, 0x7a, 0x2a, 0x2b, + 0x9b, 0x87, 0xd9, 0xc7, 0x2, 0x10, 0xb2, 0x3d, 0x5c, 0x51, 0xe3, 0xfc}; + uint8_t bytesprops1[] = {0x62, 0xef, 0x1b, 0x90}; + uint8_t bytesprops2[] = {0x45, 0xd2, 0x6b, 0xdf, 0xb8, 0x3, 0x1b}; + uint8_t bytesprops3[] = {0xc0, 0x60, 0xfb, 0x85, 0xfc, 0x27, 0x43, 0x5e, 0x4e, 0xc, 0x37, 0x25}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9213}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20311}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10076}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11906}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20739}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22113}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xad, 0x29, 0xae, 0xb8, 0x11, 0xee, 0x39, 0x21, 0x9b, 0x9e, 0x89, 0x25, 0x46, 0xac, 0x5c, 0xaa, 0xe2}; - uint8_t byteswillprops1[] = {0xcc, 0x29, 0x98, 0xae, 0xd8, 0x8b, 0x53, 0x4e, 0xc3, 0x9d, 0x6f, 0xb0, 0x41, 0xa6, 0x6e, 0xa5, 0x48, 0xe5, 0x78, 0xe1, 0xd5}; - uint8_t byteswillprops2[] = {0xde, 0x87, 0x1a, 0xd5, 0x5d, 0x64, 0xf5, 0xc7, 0x12, 0x89, 0xbe, 0xa3, 0x2, 0x5e, 0x7b, 0x98, 0xe8, 0xc7, 0x36, 0x8d, 0xf6, 0xe3, 0xc7, 0x90}; - uint8_t byteswillprops4[] = {0xb2, 0x4c, 0x4f, 0x80, 0xc7}; - uint8_t byteswillprops3[] = {0x91, 0x1f, 0xa8, 0x8b, 0x6e, 0x30, 0xf3, 0x64, 0x46}; - uint8_t byteswillprops5[] = {0x75, 0x6, 0xea, 0x23, 0x88, 0x3c, 0xfb, 0x4c, 0x6a, 0xc8, 0x5d, 0x8f, 0x18, 0x9, 0x83, 0xf2, 0x7a, 0x79, 0x91, 0x8a, 0x72, 0xc4, 0x5c, 0x2a, 0x65, 0xab, 0x8, 0x91, 0xef}; - uint8_t byteswillprops6[] = {0x6d, 0xa7, 0xdb, 0xaf, 0x9, 0xdb, 0xaf, 0xfe, 0x65, 0x66, 0x68, 0xd2, 0xd3, 0x44, 0xc6, 0x46, 0x82, 0x71, 0x48, 0xce, 0xd1}; - + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x40, 0xbe}; + uint8_t byteswillprops1[] = {0x57, 0x2f, 0xae, 0x99, 0x90, 0x7d, 0xce, 0x3c, + 0xb8, 0x7d, 0x5, 0x3, 0x1b, 0x40, 0xe2, 0x8d}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27587}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={9, (char*)&byteswillprops3}, .v={5, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&byteswillprops6}}}, - }; + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8278}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9621}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25445}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6056}}, + }; + + lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xc7, 0x95, 0x18, 0x44, 0xbe, 0xee, 0xd2, 0xa1, 0xcc, 0x38, 0x43, + 0xc0, 0xa8, 0x27, 0xa2, 0xc6, 0xfa, 0xd, 0x8e, 0x30, 0xfa}; + lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4f, 0x55, 0x49}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 63; + uint8_t client_id_bytes[] = {0x1c, 0xc4, 0x7, 0xd8, 0xec, 0xe5, 0x74, 0x73, 0x5b, 0x3b, 0xd1, 0x8d, 0xb6, 0x8d, 0x9a, + 0x23, 0xe2, 0x37, 0x48, 0x2e, 0xc7, 0xc3, 0xc, 0x2d, 0x9f, 0xb7, 0xfc, 0x63, 0xeb}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x82, 0x99, 0xf6, 0x10, 0x58, 0xfc, 0xb8, 0xfe, 0xd1, 0xea, + 0x2f, 0xe5, 0xbe, 0x31, 0x6b, 0x5, 0x11, 0x7f, 0xba}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x98, 0xf5, 0xde, 0xe6, 0xeb, 0xc, 0x21, 0x7a, 0xf3, + 0x39, 0xe0, 0x50, 0xfa, 0xe7, 0xec, 0x23, 0xcd, 0x56}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1b, 0x6e, 0x2, 0xa7, 0x3c, 0xc4, 0xbd, 0xc5}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x47, 0x15, 0x9e, 0xb, 0x2, 0xad, 0x8c, 0x79, 0x83}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 17115; - uint8_t client_id_bytes[] = {0xe0, 0xef, 0x16, 0x6a}; - lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x46, 0xd0, 0xa8, 0x9, 0x7e, 0x29, 0x7a, 0xb, 0x54, 0x38, 0x3d, 0xe7, 0x89, 0xc, 0xc5, 0xb4, 0x35, 0xa9, 0x4f, 0x8, 0xde, 0x99, 0xaf, 0xb4, 0x48, 0xc1, 0x62, 0x9a, 0x25}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0x15, 0x5e, 0x1e, 0xab, 0x43, 0x65, 0x30, 0x10, 0x97, 0xab, 0xed, 0x4c, 0xa7, 0x23}; - lwmqtt_string_t password = {14, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - -} - - -// ConnectRequest {_username = Nothing, _password = Just "_\181", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\130\CANG\157\a\138\188H\194", _willMsg = "\131;\DEL\244\175\170\170\225\172", _willProps = [PropAuthenticationMethod "\233\128E\an\188`"]}), _cleanSession = True, _keepAlive = 18273, _connID = "\DLEX\181cI5\156\142^\212\200\ETX\254\162\223\136\ETB\142\251p\163", _properties = [PropReasonString "i\231\190\203.\209#\225\135\199\205\137\FSfFpvw\163\250",PropSessionExpiryInterval 1250,PropWildcardSubscriptionAvailable 81,PropSessionExpiryInterval 5483,PropWillDelayInterval 888,PropAuthenticationData "e\t7\236\157\207\230",PropSharedSubscriptionAvailable 216,PropRequestProblemInformation 171,PropTopicAlias 15760,PropSubscriptionIdentifierAvailable 181,PropTopicAlias 7274,PropSubscriptionIdentifierAvailable 117,PropSubscriptionIdentifier 1,PropAssignedClientIdentifier "\129\219<\175\235\149\199Q\213\237\&5\172\232\159\"",PropRetainAvailable 42,PropTopicAliasMaximum 20244,PropTopicAliasMaximum 20476,PropTopicAlias 14196,PropMaximumQoS 225,PropRequestProblemInformation 103,PropPayloadFormatIndicator 124,PropAssignedClientIdentifier "\174\143\DLE\RS\251,\251\233BMg",PropReasonString ";IY\242s\198A\245\191\ETX",PropWillDelayInterval 7562,PropSessionExpiryInterval 24082,PropSubscriptionIdentifier 4,PropMessageExpiryInterval 30805,PropTopicAliasMaximum 20501,PropRetainAvailable 120]} + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just +// "\RS\167\162\&6\154\242\173\187\159\228M\149\143\133]\FS%\242\219\239\232\172\&7\STX\236\&3\229", _password = Just +// "\223\143\v\237\t/\227\FS\210\243\130\206\v\180\r", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, +// _willTopic = " \SI\153\ACK\213(Df\150\253\194\171\158r\205\203cW", _willMsg = +// "\221\140d\205\238w\156m\218w\195\&4\189\&2\208\177", _willProps = [PropWillDelayInterval 7312,PropReceiveMaximum +// 683,PropMessageExpiryInterval 21868,PropSubscriptionIdentifierAvailable 164,PropSubscriptionIdentifierAvailable +// 180,PropSessionExpiryInterval 19875,PropSessionExpiryInterval 327,PropSubscriptionIdentifierAvailable +// 94,PropAuthenticationData +// "\196\NAK\154z\173\129\&9\236\149\223\221<\245}\EOT\n\253\241u\207i2\219",PropReceiveMaximum +// 22731,PropPayloadFormatIndicator 106,PropResponseInformation "x\181\225\ETB\251\221\201",PropTopicAlias 29475]}), +// _cleanSession = False, _keepAlive = 32455, _connID = "\199f\232=\172\DEL\148R>\167\\X;\235 \DC1\189\173\203WE\245", +// _properties = [PropContentType "\SO8\239\215\140\202\DC2\140?\NUL\234HpZ\219\194l7.",PropUserProperty +// "\224\179\143\232\132\227\SUB\ACKh\ETX\253a" "\208\237\&1\193\209g\194L$\236s\250V",PropMaximumQoS +// 18,PropResponseInformation +// "\186M\202\135\&2\195\246\247\156\146\223E\137\160\200t\DLE+m\168\STX;\SI",PropSessionExpiryInterval +// 2421,PropSessionExpiryInterval 4930,PropSubscriptionIdentifier 3,PropResponseTopic "\STX",PropRetainAvailable +// 150,PropPayloadFormatIndicator 121,PropAssignedClientIdentifier +// "\206\&3\146\188\170\207\&2Z\f\148\193\SUB\236",PropRequestProblemInformation 183,PropReceiveMaximum +// 31082,PropContentType "\217\190\177\228\166\r%(c\137\165\&2u]\218\189 s_\132\a\GS",PropResponseInformation +// "s\153\167\SOAm\231\&1\128\234\SYN\246",PropReasonString "iC\\\EM6",PropMessageExpiryInterval +// 16797,PropMaximumPacketSize 28375,PropAuthenticationData +// "A\201\DC2\204q\197\SUBfA\219\211U\174\242\rX\254\218D\ETX\188\153\198\228\ETB",PropSubscriptionIdentifier +// 11,PropRequestResponseInformation 189,PropReasonString +// "~q\175\135\223\\A\251\248\172\174\&5Z\EOTa\r(\160\253\239\NAK\226\149vnr\141",PropRequestProblemInformation +// 139,PropSubscriptionIdentifierAvailable 124,PropSubscriptionIdentifierAvailable 38,PropMaximumPacketSize +// 30907,PropWillDelayInterval 3971,PropSubscriptionIdentifier 3,PropReasonString "\163\205"]} TEST(Connect5QCTest, Encode23) { -uint8_t pkt[] = {0x10, 0xde, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x46, 0x47, 0x61, 0x96, 0x1, 0x1f, 0x0, 0x14, 0x69, 0xe7, 0xbe, 0xcb, 0x2e, 0xd1, 0x23, 0xe1, 0x87, 0xc7, 0xcd, 0x89, 0x1c, 0x66, 0x46, 0x70, 0x76, 0x77, 0xa3, 0xfa, 0x11, 0x0, 0x0, 0x4, 0xe2, 0x28, 0x51, 0x11, 0x0, 0x0, 0x15, 0x6b, 0x18, 0x0, 0x0, 0x3, 0x78, 0x16, 0x0, 0x7, 0x65, 0x9, 0x37, 0xec, 0x9d, 0xcf, 0xe6, 0x2a, 0xd8, 0x17, 0xab, 0x23, 0x3d, 0x90, 0x29, 0xb5, 0x23, 0x1c, 0x6a, 0x29, 0x75, 0xb, 0x1, 0x12, 0x0, 0xf, 0x81, 0xdb, 0x3c, 0xaf, 0xeb, 0x95, 0xc7, 0x51, 0xd5, 0xed, 0x35, 0xac, 0xe8, 0x9f, 0x22, 0x25, 0x2a, 0x22, 0x4f, 0x14, 0x22, 0x4f, 0xfc, 0x23, 0x37, 0x74, 0x24, 0xe1, 0x17, 0x67, 0x1, 0x7c, 0x12, 0x0, 0xb, 0xae, 0x8f, 0x10, 0x1e, 0xfb, 0x2c, 0xfb, 0xe9, 0x42, 0x4d, 0x67, 0x1f, 0x0, 0xa, 0x3b, 0x49, 0x59, 0xf2, 0x73, 0xc6, 0x41, 0xf5, 0xbf, 0x3, 0x18, 0x0, 0x0, 0x1d, 0x8a, 0x11, 0x0, 0x0, 0x5e, 0x12, 0xb, 0x4, 0x2, 0x0, 0x0, 0x78, 0x55, 0x22, 0x50, 0x15, 0x25, 0x78, 0x0, 0x15, 0x10, 0x58, 0xb5, 0x63, 0x49, 0x35, 0x9c, 0x8e, 0x5e, 0xd4, 0xc8, 0x3, 0xfe, 0xa2, 0xdf, 0x88, 0x17, 0x8e, 0xfb, 0x70, 0xa3, 0xa, 0x15, 0x0, 0x7, 0xe9, 0x80, 0x45, 0x7, 0x6e, 0xbc, 0x60, 0x0, 0x9, 0x82, 0x18, 0x47, 0x9d, 0x7, 0x8a, 0xbc, 0x48, 0xc2, 0x0, 0x9, 0x83, 0x3b, 0x7f, 0xf4, 0xaf, 0xaa, 0xaa, 0xe1, 0xac, 0x0, 0x2, 0x5f, 0xb5}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x69, 0xe7, 0xbe, 0xcb, 0x2e, 0xd1, 0x23, 0xe1, 0x87, 0xc7, 0xcd, 0x89, 0x1c, 0x66, 0x46, 0x70, 0x76, 0x77, 0xa3, 0xfa}; - uint8_t bytesprops1[] = {0x65, 0x9, 0x37, 0xec, 0x9d, 0xcf, 0xe6}; - uint8_t bytesprops2[] = {0x81, 0xdb, 0x3c, 0xaf, 0xeb, 0x95, 0xc7, 0x51, 0xd5, 0xed, 0x35, 0xac, 0xe8, 0x9f, 0x22}; - uint8_t bytesprops3[] = {0xae, 0x8f, 0x10, 0x1e, 0xfb, 0x2c, 0xfb, 0xe9, 0x42, 0x4d, 0x67}; - uint8_t bytesprops4[] = {0x3b, 0x49, 0x59, 0xf2, 0x73, 0xc6, 0x41, 0xf5, 0xbf, 0x3}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1250}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5483}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 888}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15760}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7274}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20244}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20476}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14196}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7562}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24082}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30805}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20501}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 120}}, + uint8_t pkt[] = { + 0x10, 0xca, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x7e, 0xc7, 0x88, 0x2, 0x3, 0x0, 0x13, 0xe, + 0x38, 0xef, 0xd7, 0x8c, 0xca, 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, 0xcd, 0xee, 0x77, 0x9c, 0x6d, 0xda, 0x77, 0xc3, 0x34, 0xbd, 0x32, 0xd0, 0xb1, 0x0, 0x1b, 0x1e, + 0xa7, 0xa2, 0x36, 0x9a, 0xf2, 0xad, 0xbb, 0x9f, 0xe4, 0x4d, 0x95, 0x8f, 0x85, 0x5d, 0x1c, 0x25, 0xf2, 0xdb, 0xef, + 0xe8, 0xac, 0x37, 0x2, 0xec, 0x33, 0xe5, 0x0, 0xf, 0xdf, 0x8f, 0xb, 0xed, 0x9, 0x2f, 0xe3, 0x1c, 0xd2, 0xf3, + 0x82, 0xce, 0xb, 0xb4, 0xd}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe, 0x38, 0xef, 0xd7, 0x8c, 0xca, 0x12, 0x8c, 0x3f, 0x0, + 0xea, 0x48, 0x70, 0x5a, 0xdb, 0xc2, 0x6c, 0x37, 0x2e}; + uint8_t bytesprops2[] = {0xd0, 0xed, 0x31, 0xc1, 0xd1, 0x67, 0xc2, 0x4c, 0x24, 0xec, 0x73, 0xfa, 0x56}; + uint8_t bytesprops1[] = {0xe0, 0xb3, 0x8f, 0xe8, 0x84, 0xe3, 0x1a, 0x6, 0x68, 0x3, 0xfd, 0x61}; + uint8_t bytesprops3[] = {0xba, 0x4d, 0xca, 0x87, 0x32, 0xc3, 0xf6, 0xf7, 0x9c, 0x92, 0xdf, 0x45, + 0x89, 0xa0, 0xc8, 0x74, 0x10, 0x2b, 0x6d, 0xa8, 0x2, 0x3b, 0xf}; + uint8_t bytesprops4[] = {0x2}; + uint8_t bytesprops5[] = {0xce, 0x33, 0x92, 0xbc, 0xaa, 0xcf, 0x32, 0x5a, 0xc, 0x94, 0xc1, 0x1a, 0xec}; + uint8_t bytesprops6[] = {0xd9, 0xbe, 0xb1, 0xe4, 0xa6, 0xd, 0x25, 0x28, 0x63, 0x89, 0xa5, + 0x32, 0x75, 0x5d, 0xda, 0xbd, 0x20, 0x73, 0x5f, 0x84, 0x7, 0x1d}; + uint8_t bytesprops7[] = {0x73, 0x99, 0xa7, 0xe, 0x41, 0x6d, 0xe7, 0x31, 0x80, 0xea, 0x16, 0xf6}; + uint8_t bytesprops8[] = {0x69, 0x43, 0x5c, 0x19, 0x36}; + uint8_t bytesprops9[] = {0x41, 0xc9, 0x12, 0xcc, 0x71, 0xc5, 0x1a, 0x66, 0x41, 0xdb, 0xd3, 0x55, 0xae, + 0xf2, 0xd, 0x58, 0xfe, 0xda, 0x44, 0x3, 0xbc, 0x99, 0xc6, 0xe4, 0x17}; + uint8_t bytesprops10[] = {0x7e, 0x71, 0xaf, 0x87, 0xdf, 0x5c, 0x41, 0xfb, 0xf8, 0xac, 0xae, 0x35, 0x5a, 0x4, + 0x61, 0xd, 0x28, 0xa0, 0xfd, 0xef, 0x15, 0xe2, 0x95, 0x76, 0x6e, 0x72, 0x8d}; + uint8_t bytesprops11[] = {0xa3, 0xcd}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops1}, .v = {13, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2421}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4930}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31082}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16797}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28375}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30907}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3971}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops11}}}, }; lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe9, 0x80, 0x45, 0x7, 0x6e, 0xbc, 0x60}; - + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xc4, 0x15, 0x9a, 0x7a, 0xad, 0x81, 0x39, 0xec, 0x95, 0xdf, 0xdd, 0x3c, + 0xf5, 0x7d, 0x4, 0xa, 0xfd, 0xf1, 0x75, 0xcf, 0x69, 0x32, 0xdb}; + uint8_t byteswillprops1[] = {0x78, 0xb5, 0xe1, 0x17, 0xfb, 0xdd, 0xc9}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7312}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 683}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21868}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19875}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 327}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22731}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29475}}, }; - lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x82, 0x18, 0x47, 0x9d, 0x7, 0x8a, 0xbc, 0x48, 0xc2}; - lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x83, 0x3b, 0x7f, 0xf4, 0xaf, 0xaa, 0xaa, 0xe1, 0xac}; - lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS0; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 18273; - uint8_t client_id_bytes[] = {0x10, 0x58, 0xb5, 0x63, 0x49, 0x35, 0x9c, 0x8e, 0x5e, 0xd4, 0xc8, 0x3, 0xfe, 0xa2, 0xdf, 0x88, 0x17, 0x8e, 0xfb, 0x70, 0xa3}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x5f, 0xb5}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x20, 0xf, 0x99, 0x6, 0xd5, 0x28, 0x44, 0x66, 0x96, + 0xfd, 0xc2, 0xab, 0x9e, 0x72, 0xcd, 0xcb, 0x63, 0x57}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xdd, 0x8c, 0x64, 0xcd, 0xee, 0x77, 0x9c, 0x6d, + 0xda, 0x77, 0xc3, 0x34, 0xbd, 0x32, 0xd0, 0xb1}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 32455; + uint8_t client_id_bytes[] = {0xc7, 0x66, 0xe8, 0x3d, 0xac, 0x7f, 0x94, 0x52, 0x3e, 0xa7, 0x5c, + 0x58, 0x3b, 0xeb, 0x20, 0x11, 0xbd, 0xad, 0xcb, 0x57, 0x45, 0xf5}; + lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x1e, 0xa7, 0xa2, 0x36, 0x9a, 0xf2, 0xad, 0xbb, 0x9f, 0xe4, 0x4d, 0x95, 0x8f, 0x85, + 0x5d, 0x1c, 0x25, 0xf2, 0xdb, 0xef, 0xe8, 0xac, 0x37, 0x2, 0xec, 0x33, 0xe5}; + lwmqtt_string_t username = {27, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xdf, 0x8f, 0xb, 0xed, 0x9, 0x2f, 0xe3, 0x1c, 0xd2, 0xf3, 0x82, 0xce, 0xb, 0xb4, 0xd}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\212\138\190Q;W\148\195", _willMsg = "\213;", _willProps = [PropRequestResponseInformation 2,PropMessageExpiryInterval 22680,PropResponseTopic "\204\192\149\210\EOT)f\201\214\244\148\177Lv\196\128)\244D\ETX",PropCorrelationData "\EM\140\SUB\SI\168\CAN\144V1\t\US\223",PropTopicAlias 1847,PropResponseInformation "\252\165\241\SO~\228a\245?\160\199\172\216",PropSessionExpiryInterval 5571,PropWildcardSubscriptionAvailable 194,PropReasonString "&\189\DC4Rt\133\199\251\DC1\155h\240*\252%\167\\\229g\ETB\227\253\223\232\162\177",PropCorrelationData "a#\150\220D\147\v\221\140.|.\155\t#\140\&5\143P",PropTopicAliasMaximum 18078,PropSessionExpiryInterval 28214,PropWillDelayInterval 17859,PropPayloadFormatIndicator 221,PropAssignedClientIdentifier "\DC1\188H\ETX\196\187V\SYN{\155\FS`\190\185\236{\RS\247\197\234",PropCorrelationData "\153(\182\&6\248'\187\192pQ_\190",PropMessageExpiryInterval 10563,PropSharedSubscriptionAvailable 99,PropWildcardSubscriptionAvailable 171,PropMessageExpiryInterval 18957,PropWillDelayInterval 9477]}), _cleanSession = True, _keepAlive = 31629, _connID = "\157f\DC3.", _properties = [PropAuthenticationMethod "1\n\210\129\DLE\ETX\164\NUL",PropTopicAliasMaximum 10014,PropSessionExpiryInterval 18349,PropContentType "H\167\200\\\131\189\EOT#",PropReasonString "}\142\164:\156\189\239\194\222\139v\184\164\132\248|@\135\247\&3\201UU\200",PropAuthenticationData "\136\254\243X\ACK\DC2\f",PropUserProperty "\CAN\223T\156\133\157\136\SOH\213\133\199" "\253pj\128\188\230\179i\165C",PropAuthenticationData "\251\235\CAN\255,X\ESC\FS\v\150\ETBW7\ACK\214",PropAssignedClientIdentifier "\212\238\130\t\STXH\169e\176\&9\182\251\143r\147gcp\187\202\166\128",PropAssignedClientIdentifier "g\231\214\157\243\207_\129?\CANbF\199\DC1\131\229\252\157\US\135\adv\192w"]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = +// 14647, _connID = "\173\255n}\129\NAK", _properties = [PropContentType "V\175t\192N",PropResponseInformation +// "\136\188\243\EM:\173\236Y\t}%\212\229\138\SI9R\141I\206\192\139\217\249IC\150eo\170",PropServerReference +// "(\147\138\190\ESCb\239\183\\\252\&1\189bc\171\189\209",PropReceiveMaximum 3357,PropRequestProblemInformation +// 243,PropMessageExpiryInterval 5627,PropServerKeepAlive 22171,PropRetainAvailable 24,PropTopicAliasMaximum +// 18180,PropRequestResponseInformation 20,PropRetainAvailable 70,PropCorrelationData +// "8\131\255G\143\NAKhw3@t\EOT",PropResponseInformation +// "\135\ETX|\197\DEL\146f9L\197$t\SO0j\ENQ\137\138\178\138\245\210",PropSessionExpiryInterval +// 20657,PropSessionExpiryInterval 27920,PropRequestResponseInformation 8,PropUserProperty +// "\EOT\DC2p{\170.i\EOT\166\CANm" "r!\155\EOT6x\216s\SI\177\230Q\142\249\141\DLE\178\v\252\168",PropReceiveMaximum +// 8439,PropAuthenticationMethod "\221\DLE\133\205\&7\240\167\154",PropWillDelayInterval 9107]}), _cleanSession = False, +// _keepAlive = 17899, _connID = ".hc\n\135\206/\236\&0\221\216\155\236", _properties = [PropReceiveMaximum +// 26537,PropTopicAlias 10462,PropContentType +// "\133\DC4#\245\227&\ETX\217\r\DC1\216\210\234k\ACK\197\146\220\ACK\230\227\219/",PropReceiveMaximum +// 18891,PropWillDelayInterval 29782,PropSubscriptionIdentifier 7,PropWildcardSubscriptionAvailable 223,PropUserProperty +// "-\ETXU!\244N\169" "%9\254\194\US-\236\224\170;\244{u\180\198\243\&3\224\DC1\SO\203\t\193g",PropReceiveMaximum +// 29189]} TEST(Connect5QCTest, Encode25) { -uint8_t pkt[] = {0x10, 0x89, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x55, 0x17, 0x15, 0x18, 0x0, 0x0, 0x1f, 0xb5, 0x17, 0x4b, 0x15, 0x0, 0x9, 0xe1, 0x42, 0x9, 0x4c, 0x2d, 0x4c, 0xf7, 0xc9, 0x7e, 0x17, 0x4, 0x0, 0x1d, 0x35, 0x36, 0x15, 0x2c, 0x73, 0xa8, 0xa5, 0xf7, 0xeb, 0xe, 0x50, 0xef, 0xef, 0xc2, 0x9b, 0x15, 0xb5, 0x69, 0x42, 0x70, 0x1e, 0xef, 0x6, 0x83, 0x7, 0x9d, 0x1a, 0x96, 0x5d, 0x7a, 0x3, 0x0, 0xe, 0xe4, 0x3b, 0xfd, 0x67, 0x34, 0xba, 0x5e, 0xbe, 0x59, 0x84, 0x4c, 0x33, 0x45, 0x6c, 0x29, 0x24, 0x26, 0x0, 0x13, 0x3c, 0x3d, 0xa0, 0x92, 0xdf, 0xa4, 0xdb, 0xbf, 0xca, 0x5, 0x7f, 0x9a, 0x3d, 0x48, 0xd9, 0x6d, 0x89, 0xa0, 0xbb, 0x0, 0xf, 0xa2, 0xab, 0x3d, 0xa4, 0x3c, 0x42, 0xfc, 0xce, 0xd0, 0x36, 0xb6, 0xc6, 0xe6, 0xd, 0x83, 0x1, 0x89, 0x19, 0xdb, 0x29, 0x52, 0x21, 0x39, 0x36, 0x18, 0x0, 0x0, 0x6a, 0xc3, 0x28, 0x1d, 0x9, 0x0, 0x1a, 0x54, 0xf2, 0x8, 0x2c, 0x83, 0xc6, 0x37, 0x9c, 0xd3, 0x46, 0x50, 0x8c, 0xed, 0x5b, 0xd7, 0x69, 0xec, 0x50, 0xa8, 0x2c, 0xcf, 0x34, 0x4f, 0x3f, 0x89, 0x27, 0x12, 0x0, 0x10, 0xbd, 0xaf, 0xc5, 0x65, 0x97, 0xab, 0x20, 0x72, 0x82, 0xd2, 0xda, 0x30, 0x8f, 0xe0, 0x38, 0x6e, 0x0, 0xb, 0x35, 0x59, 0xa4, 0x31, 0x60, 0x75, 0xff, 0xfc, 0x38, 0xab, 0x26, 0x0, 0x1e, 0x6e, 0x2, 0x12, 0x7f, 0x5f, 0xab, 0x5, 0xab, 0x91, 0xaf, 0x1b, 0x36, 0x9e, 0x32, 0xf6, 0xc, 0x25, 0x68, 0xbe, 0xe9, 0x4f, 0xe8, 0xaf, 0xbe, 0x80, 0x2, 0xb2, 0xd2, 0xf5, 0x6c, 0x0, 0x11, 0xfc, 0xf5, 0x79, 0x3a, 0xc8, 0x8, 0xea, 0x36, 0xe1, 0x16, 0x9e, 0x7a, 0xee, 0x26, 0x18, 0xaf, 0x8a, 0x0, 0xd, 0x7c, 0xda, 0x2d, 0x76, 0x6c, 0x16, 0xde, 0x66, 0x9f, 0x56, 0x8a, 0xe8, 0xcb}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xe1, 0x42, 0x9, 0x4c, 0x2d, 0x4c, 0xf7, 0xc9, 0x7e}; - + uint8_t pkt[] = { + 0x10, 0x8a, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x45, 0xeb, 0x53, 0x21, 0x67, 0xa9, 0x23, 0x28, + 0xde, 0x3, 0x0, 0x17, 0x85, 0x14, 0x23, 0xf5, 0xe3, 0x26, 0x3, 0xd9, 0xd, 0x11, 0xd8, 0xd2, 0xea, 0x6b, 0x6, + 0xc5, 0x92, 0xdc, 0x6, 0xe6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 0x14, 0x25, 0x46, 0x9, 0x0, 0xc, 0x38, 0x83, 0xff, 0x47, 0x8f, 0x15, 0x68, 0x77, 0x33, 0x40, 0x74, + 0x4, 0x1a, 0x0, 0x16, 0x87, 0x3, 0x7c, 0xc5, 0x7f, 0x92, 0x66, 0x39, 0x4c, 0xc5, 0x24, 0x74, 0xe, 0x30, 0x6a, + 0x5, 0x89, 0x8a, 0xb2, 0x8a, 0xf5, 0xd2, 0x11, 0x0, 0x0, 0x50, 0xb1, 0x11, 0x0, 0x0, 0x6d, 0x10, 0x19, 0x8, + 0x26, 0x0, 0xb, 0x4, 0x12, 0x70, 0x7b, 0xaa, 0x2e, 0x69, 0x4, 0xa6, 0x18, 0x6d, 0x0, 0x14, 0x72, 0x21, 0x9b, + 0x4, 0x36, 0x78, 0xd8, 0x73, 0xf, 0xb1, 0xe6, 0x51, 0x8e, 0xf9, 0x8d, 0x10, 0xb2, 0xb, 0xfc, 0xa8, 0x21, 0x20, + 0xf7, 0x15, 0x0, 0x8, 0xdd, 0x10, 0x85, 0xcd, 0x37, 0xf0, 0xa7, 0x9a, 0x18, 0x0, 0x0, 0x23, 0x93, 0x0, 0x19, + 0xd1, 0x48, 0x6f, 0x82, 0xe9, 0x36, 0xcb, 0x45, 0xbd, 0x2, 0xcc, 0xca, 0x4c, 0x47, 0xa0, 0xbc, 0x43, 0x5b, 0x1d, + 0x26, 0xa9, 0x77, 0x0, 0xd0, 0xa1, 0x0, 0x1, 0x43, 0x0, 0x2, 0x2f, 0x26, 0x0, 0x15, 0x38, 0x1a, 0x8f, 0x9, + 0x1b, 0xdc, 0x25, 0xbb, 0x1b, 0x31, 0xa3, 0x39, 0xfd, 0xcf, 0xb9, 0x46, 0x9, 0xd5, 0x4e, 0x0, 0x22}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x85, 0x14, 0x23, 0xf5, 0xe3, 0x26, 0x3, 0xd9, 0xd, 0x11, 0xd8, 0xd2, + 0xea, 0x6b, 0x6, 0xc5, 0x92, 0xdc, 0x6, 0xe6, 0xe3, 0xdb, 0x2f}; + uint8_t bytesprops2[] = {0x25, 0x39, 0xfe, 0xc2, 0x1f, 0x2d, 0xec, 0xe0, 0xaa, 0x3b, 0xf4, 0x7b, + 0x75, 0xb4, 0xc6, 0xf3, 0x33, 0xe0, 0x11, 0xe, 0xcb, 0x9, 0xc1, 0x67}; + uint8_t bytesprops1[] = {0x2d, 0x3, 0x55, 0x21, 0xf4, 0x4e, 0xa9}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8117}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26537}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10462}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18891}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29782}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops1}, .v = {24, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29189}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe4, 0x3b, 0xfd, 0x67, 0x34, 0xba, 0x5e, 0xbe, 0x59, 0x84, 0x4c, 0x33, 0x45, 0x6c}; - uint8_t byteswillprops2[] = {0xa2, 0xab, 0x3d, 0xa4, 0x3c, 0x42, 0xfc, 0xce, 0xd0, 0x36, 0xb6, 0xc6, 0xe6, 0xd, 0x83}; - uint8_t byteswillprops1[] = {0x3c, 0x3d, 0xa0, 0x92, 0xdf, 0xa4, 0xdb, 0xbf, 0xca, 0x5, 0x7f, 0x9a, 0x3d, 0x48, 0xd9, 0x6d, 0x89, 0xa0, 0xbb}; - uint8_t byteswillprops3[] = {0x54, 0xf2, 0x8, 0x2c, 0x83, 0xc6, 0x37, 0x9c, 0xd3, 0x46, 0x50, 0x8c, 0xed, 0x5b, 0xd7, 0x69, 0xec, 0x50, 0xa8, 0x2c, 0xcf, 0x34, 0x4f, 0x3f, 0x89, 0x27}; - uint8_t byteswillprops4[] = {0xbd, 0xaf, 0xc5, 0x65, 0x97, 0xab, 0x20, 0x72, 0x82, 0xd2, 0xda, 0x30, 0x8f, 0xe0, 0x38, 0x6e}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={19, (char*)&byteswillprops1}, .v={15, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14646}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27331}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&byteswillprops4}}}, - }; - - lwmqtt_properties_t willprops = {11, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x35, 0x59, 0xa4, 0x31, 0x60, 0x75, 0xff, 0xfc, 0x38, 0xab, 0x26}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6e, 0x2, 0x12, 0x7f, 0x5f, 0xab, 0x5, 0xab, 0x91, 0xaf, 0x1b, 0x36, 0x9e, 0x32, 0xf6, 0xc, 0x25, 0x68, 0xbe, 0xe9, 0x4f, 0xe8, 0xaf, 0xbe, 0x80, 0x2, 0xb2, 0xd2, 0xf5, 0x6c}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 21783; - uint8_t client_id_bytes[] = {0x35, 0x36, 0x15, 0x2c, 0x73, 0xa8, 0xa5, 0xf7, 0xeb, 0xe, 0x50, 0xef, 0xef, 0xc2, 0x9b, 0x15, 0xb5, 0x69, 0x42, 0x70, 0x1e, 0xef, 0x6, 0x83, 0x7, 0x9d, 0x1a, 0x96, 0x5d}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xfc, 0xf5, 0x79, 0x3a, 0xc8, 0x8, 0xea, 0x36, 0xe1, 0x16, 0x9e, 0x7a, 0xee, 0x26, 0x18, 0xaf, 0x8a}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0x7c, 0xda, 0x2d, 0x76, 0x6c, 0x16, 0xde, 0x66, 0x9f, 0x56, 0x8a, 0xe8, 0xcb}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x6f, 0x87, 0x27, 0x54, 0x6e, 0x34, 0xc7, 0x1c, 0x20, 0xe, 0x2a, + 0x7c, 0x7, 0xae, 0xe, 0x3b, 0xe5, 0x9, 0xe1, 0x3e, 0xc0, 0x4e}; + uint8_t byteswillprops1[] = {0x88, 0xbc, 0xf3, 0x19, 0x3a, 0xad, 0xec, 0x59, 0x9, 0x7d, + 0x25, 0xd4, 0xe5, 0x8a, 0xf, 0x39, 0x52, 0x8d, 0x49, 0xce, + 0xc0, 0x8b, 0xd9, 0xf9, 0x49, 0x43, 0x96, 0x65, 0x6f, 0xaa}; + uint8_t byteswillprops2[] = {0x28, 0x93, 0x8a, 0xbe, 0x1b, 0x62, 0xef, 0xb7, 0x5c, + 0xfc, 0x31, 0xbd, 0x62, 0x63, 0xab, 0xbd, 0xd1}; + uint8_t byteswillprops3[] = {0x38, 0x83, 0xff, 0x47, 0x8f, 0x15, 0x68, 0x77, 0x33, 0x40, 0x74, 0x4}; + uint8_t byteswillprops4[] = {0x87, 0x3, 0x7c, 0xc5, 0x7f, 0x92, 0x66, 0x39, 0x4c, 0xc5, 0x24, + 0x74, 0xe, 0x30, 0x6a, 0x5, 0x89, 0x8a, 0xb2, 0x8a, 0xf5, 0xd2}; + uint8_t byteswillprops6[] = {0x72, 0x21, 0x9b, 0x4, 0x36, 0x78, 0xd8, 0x73, 0xf, 0xb1, + 0xe6, 0x51, 0x8e, 0xf9, 0x8d, 0x10, 0xb2, 0xb, 0xfc, 0xa8}; + uint8_t byteswillprops5[] = {0x4, 0x12, 0x70, 0x7b, 0xaa, 0x2e, 0x69, 0x4, 0xa6, 0x18, 0x6d}; + uint8_t byteswillprops7[] = {0xdd, 0x10, 0x85, 0xcd, 0x37, 0xf0, 0xa7, 0x9a}; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1870}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5518}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6427}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3357}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5627}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22171}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18180}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20657}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27920}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {11, (char*)&byteswillprops5}, .v = {20, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8439}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9107}}, + }; + + lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd1, 0x48, 0x6f, 0x82, 0xe9, 0x36, 0xcb, 0x45, 0xbd, 0x2, 0xcc, 0xca, 0x4c, + 0x47, 0xa0, 0xbc, 0x43, 0x5b, 0x1d, 0x26, 0xa9, 0x77, 0x0, 0xd0, 0xa1}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x43}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 17899; + uint8_t client_id_bytes[] = {0x2e, 0x68, 0x63, 0xa, 0x87, 0xce, 0x2f, 0xec, 0x30, 0xdd, 0xd8, 0x9b, 0xec}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x2f, 0x26}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x38, 0x1a, 0x8f, 0x9, 0x1b, 0xdc, 0x25, 0xbb, 0x1b, 0x31, 0xa3, + 0x39, 0xfd, 0xcf, 0xb9, 0x46, 0x9, 0xd5, 0x4e, 0x0, 0x22}; + lwmqtt_string_t password = {21, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Just "\223*\129F(\130\&4\142\220[3\138\202/U\241z\144\214\227\&9\162\164\149", _password = Just "k\177\238>\207X\198i\188\175\151\215\&4\250\DC2\133\DC3\208", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "", _willMsg = "O\f\163R\254G\172]\199\227#f/\147[\SI", _willProps = [PropSubscriptionIdentifier 22,PropMessageExpiryInterval 29484,PropSubscriptionIdentifierAvailable 190,PropMaximumPacketSize 24579,PropTopicAliasMaximum 5448,PropMaximumQoS 22,PropCorrelationData "\209\204\165\223\218\222\200N#\207",PropContentType "\227F\ACKS\147\240=\219\SUBa|\213w\227`",PropMaximumPacketSize 30812,PropMaximumPacketSize 12528,PropPayloadFormatIndicator 190,PropSubscriptionIdentifier 25,PropTopicAlias 30923,PropServerReference "\233W\US\136\152\174T\192\209C\253\158\226\161\146rp\172\DEL\205r\211wE\221\145\147",PropAuthenticationMethod "\n~\180\194v\180\181-\226\&3r\165\142.\229\229n\138\&0L\FS\205!;^",PropSharedSubscriptionAvailable 136,PropWildcardSubscriptionAvailable 41,PropSharedSubscriptionAvailable 117,PropTopicAlias 25089,PropMaximumQoS 67]}), _cleanSession = False, _keepAlive = 1168, _connID = "\t\208\CAN'\235Mek\SI\DC2;\237\GS\194~\SOH,", _properties = [PropAssignedClientIdentifier "\222d\SYN;4\DELQt~#2s\SO\171\146t'I\231\ACK\n\242\128\244\173\219s-\FS",PropRequestResponseInformation 138,PropReasonString "\186E\DEL\DC3\223o\251vX7\245\179\197\157",PropRetainAvailable 242,PropRequestProblemInformation 122,PropResponseInformation "\135b\EM\248\205\&9\197\134'\205\237Z\202\175\SUB,",PropReasonString "\252z\244n\166\153dEG*\221Yt\213\132",PropResponseInformation "\203\253\173]",PropServerReference ")\198\236\207\&8",PropSubscriptionIdentifier 28,PropMaximumQoS 187,PropMaximumPacketSize 31216,PropRetainAvailable 158,PropSessionExpiryInterval 28,PropResponseTopic "\142\239\FS\211\&8\151\240\n\156\205\146\137\253\v\130/\GS\131\234/\fit#\171\221\155\ETX\148}",PropRequestResponseInformation 182,PropResponseTopic "\139\255\158\207&\128\252A\DC3\180hl\149\b",PropSessionExpiryInterval 12368,PropMaximumPacketSize 2358,PropPayloadFormatIndicator 99,PropResponseTopic "\209\183\&1\168\EM\169\&4",PropWillDelayInterval 190,PropAssignedClientIdentifier "w\204\DC2\180\245\133\186\225L\DC1\182\248\GS\190\137V\223\189\246\254",PropMaximumQoS 123,PropMessageExpiryInterval 11858,PropWillDelayInterval 24601]} +// ConnectRequest {_username = Just "N\203\159\210\235ac\RS\168\231\220r'\253\200\162\192\166\149\231\221", _password = +// Just "\174,\168L\134y\NUL\129\t\237\152\134\184\222\US\168\208\"|\246\140=\236\196~\b\150\246\216\164", _lastWill = +// Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\218I\179[\161\209\ESC}h\205FPB@K\133", _willMsg +// = "2\215\135\225\197N", _willProps = [PropCorrelationData +// "@\153\210\152\129\138\129[k\165\228\205\201~\149\188",PropWildcardSubscriptionAvailable +// 161,PropWildcardSubscriptionAvailable 133,PropServerReference "\135Y\218\139.D/\173W\167j",PropAuthenticationMethod " +// \199/E\233\150;c/"]}), _cleanSession = False, _keepAlive = 30481, _connID = +// "\132\129b\222=>\197\164\SO\236\234\204O\202\240\150\&0\186\167", _properties = [PropSharedSubscriptionAvailable +// 2,PropPayloadFormatIndicator 142,PropMaximumPacketSize 7898,PropServerReference +// "\185\137\&6\172\245\241\241\246",PropRequestProblemInformation 20,PropUserProperty "[J\203\217\SO\&H\204\208M:\t" +// "%\NAK\208x\208$p\192x\247"]} TEST(Connect5QCTest, Encode26) { -uint8_t pkt[] = {0x10, 0xd8, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x4, 0x90, 0xed, 0x1, 0x12, 0x0, 0x1d, 0xde, 0x64, 0x16, 0x3b, 0x34, 0x7f, 0x51, 0x74, 0x7e, 0x23, 0x32, 0x73, 0xe, 0xab, 0x92, 0x74, 0x27, 0x49, 0xe7, 0x6, 0xa, 0xf2, 0x80, 0xf4, 0xad, 0xdb, 0x73, 0x2d, 0x1c, 0x19, 0x8a, 0x1f, 0x0, 0xe, 0xba, 0x45, 0x7f, 0x13, 0xdf, 0x6f, 0xfb, 0x76, 0x58,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, 0x5b, 0x33, 0x8a, 0xca, 0x2f, 0x55, 0xf1, 0x7a, 0x90, 0xd6, 0xe3, 0x39, 0xa2, 0xa4, 0x95, 0x0, 0x12, 0x6b, 0xb1, 0xee, 0x3e, 0xcf, 0x58, 0xc6, 0x69, 0xbc, 0xaf, 0x97, 0xd7, 0x34, 0xfa, 0x12, 0x85, 0x13, 0xd0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xde, 0x64, 0x16, 0x3b, 0x34, 0x7f, 0x51, 0x74, 0x7e, 0x23, 0x32, 0x73, 0xe, 0xab, 0x92, 0x74, 0x27, 0x49, 0xe7, 0x6, 0xa, 0xf2, 0x80, 0xf4, 0xad, 0xdb, 0x73, 0x2d, 0x1c}; - uint8_t bytesprops1[] = {0xba, 0x45, 0x7f, 0x13, 0xdf, 0x6f, 0xfb, 0x76, 0x58, 0x37, 0xf5, 0xb3, 0xc5, 0x9d}; - uint8_t bytesprops2[] = {0x87, 0x62, 0x19, 0xf8, 0xcd, 0x39, 0xc5, 0x86, 0x27, 0xcd, 0xed, 0x5a, 0xca, 0xaf, 0x1a, 0x2c}; - uint8_t bytesprops3[] = {0xfc, 0x7a, 0xf4, 0x6e, 0xa6, 0x99, 0x64, 0x45, 0x47, 0x2a, 0xdd, 0x59, 0x74, 0xd5, 0x84}; - uint8_t bytesprops4[] = {0xcb, 0xfd, 0xad, 0x5d}; - uint8_t bytesprops5[] = {0x29, 0xc6, 0xec, 0xcf, 0x38}; - uint8_t bytesprops6[] = {0x8e, 0xef, 0x1c, 0xd3, 0x38, 0x97, 0xf0, 0xa, 0x9c, 0xcd, 0x92, 0x89, 0xfd, 0xb, 0x82, 0x2f, 0x1d, 0x83, 0xea, 0x2f, 0xc, 0x69, 0x74, 0x23, 0xab, 0xdd, 0x9b, 0x3, 0x94, 0x7d}; - uint8_t bytesprops7[] = {0x8b, 0xff, 0x9e, 0xcf, 0x26, 0x80, 0xfc, 0x41, 0x13, 0xb4, 0x68, 0x6c, 0x95, 0x8}; - uint8_t bytesprops8[] = {0xd1, 0xb7, 0x31, 0xa8, 0x19, 0xa9, 0x34}; - uint8_t bytesprops9[] = {0x77, 0xcc, 0x12, 0xb4, 0xf5, 0x85, 0xba, 0xe1, 0x4c, 0x11, 0xb6, 0xf8, 0x1d, 0xbe, 0x89, 0x56, 0xdf, 0xbd, 0xf6, 0xfe}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31216}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12368}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2358}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 190}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11858}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24601}}, + uint8_t pkt[] = {0x10, 0xd3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc4, 0x77, 0x11, 0x30, 0x2a, 0x2, 0x1, + 0x8e, 0x27, 0x0, 0x0, 0x1e, 0xda, 0x1c, 0x0, 0x8, 0xb9, 0x89, 0x36, 0xac, 0xf5, 0xf1, 0xf1, 0xf6, + 0x17, 0x14, 0x26, 0x0, 0xb, 0x5b, 0x4a, 0xcb, 0xd9, 0xe, 0x48, 0xcc, 0xd0, 0x4d, 0x3a, 0x9, 0x0, + 0xa, 0x25, 0x15, 0xd0, 0x78, 0xd0, 0x24, 0x70, 0xc0, 0x78, 0xf7, 0x0, 0x13, 0x84, 0x81, 0x62, 0xde, + 0x3d, 0x3e, 0xc5, 0xa4, 0xe, 0xec, 0xea, 0xcc, 0x4f, 0xca, 0xf0, 0x96, 0x30, 0xba, 0xa7, 0x31, 0x9, + 0x0, 0x10, 0x40, 0x99, 0xd2, 0x98, 0x81, 0x8a, 0x81, 0x5b, 0x6b, 0xa5, 0xe4, 0xcd, 0xc9, 0x7e, 0x95, + 0xbc, 0x28, 0xa1, 0x28, 0x85, 0x1c, 0x0, 0xb, 0x87, 0x59, 0xda, 0x8b, 0x2e, 0x44, 0x2f, 0xad, 0x57, + 0xa7, 0x6a, 0x15, 0x0, 0x9, 0x20, 0xc7, 0x2f, 0x45, 0xe9, 0x96, 0x3b, 0x63, 0x2f, 0x0, 0x10, 0xda, + 0x49, 0xb3, 0x5b, 0xa1, 0xd1, 0x1b, 0x7d, 0x68, 0xcd, 0x46, 0x50, 0x42, 0x40, 0x4b, 0x85, 0x0, 0x6, + 0x32, 0xd7, 0x87, 0xe1, 0xc5, 0x4e, 0x0, 0x15, 0x4e, 0xcb, 0x9f, 0xd2, 0xeb, 0x61, 0x63, 0x1e, 0xa8, + 0xe7, 0xdc, 0x72, 0x27, 0xfd, 0xc8, 0xa2, 0xc0, 0xa6, 0x95, 0xe7, 0xdd, 0x0, 0x1e, 0xae, 0x2c, 0xa8, + 0x4c, 0x86, 0x79, 0x0, 0x81, 0x9, 0xed, 0x98, 0x86, 0xb8, 0xde, 0x1f, 0xa8, 0xd0, 0x22, 0x7c, 0xf6, + 0x8c, 0x3d, 0xec, 0xc4, 0x7e, 0x8, 0x96, 0xf6, 0xd8, 0xa4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb9, 0x89, 0x36, 0xac, 0xf5, 0xf1, 0xf1, 0xf6}; + uint8_t bytesprops2[] = {0x25, 0x15, 0xd0, 0x78, 0xd0, 0x24, 0x70, 0xc0, 0x78, 0xf7}; + uint8_t bytesprops1[] = {0x5b, 0x4a, 0xcb, 0xd9, 0xe, 0x48, 0xcc, 0xd0, 0x4d, 0x3a, 0x9}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7898}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {10, (char*)&bytesprops2}}}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd1, 0xcc, 0xa5, 0xdf, 0xda, 0xde, 0xc8, 0x4e, 0x23, 0xcf}; - uint8_t byteswillprops1[] = {0xe3, 0x46, 0x6, 0x53, 0x93, 0xf0, 0x3d, 0xdb, 0x1a, 0x61, 0x7c, 0xd5, 0x77, 0xe3, 0x60}; - uint8_t byteswillprops2[] = {0xe9, 0x57, 0x1f, 0x88, 0x98, 0xae, 0x54, 0xc0, 0xd1, 0x43, 0xfd, 0x9e, 0xe2, 0xa1, 0x92, 0x72, 0x70, 0xac, 0x7f, 0xcd, 0x72, 0xd3, 0x77, 0x45, 0xdd, 0x91, 0x93}; - uint8_t byteswillprops3[] = {0xa, 0x7e, 0xb4, 0xc2, 0x76, 0xb4, 0xb5, 0x2d, 0xe2, 0x33, 0x72, 0xa5, 0x8e, 0x2e, 0xe5, 0xe5, 0x6e, 0x8a, 0x30, 0x4c, 0x1c, 0xcd, 0x21, 0x3b, 0x5e}; - + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x40, 0x99, 0xd2, 0x98, 0x81, 0x8a, 0x81, 0x5b, + 0x6b, 0xa5, 0xe4, 0xcd, 0xc9, 0x7e, 0x95, 0xbc}; + uint8_t byteswillprops1[] = {0x87, 0x59, 0xda, 0x8b, 0x2e, 0x44, 0x2f, 0xad, 0x57, 0xa7, 0x6a}; + uint8_t byteswillprops2[] = {0x20, 0xc7, 0x2f, 0x45, 0xe9, 0x96, 0x3b, 0x63, 0x2f}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29484}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24579}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5448}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30812}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12528}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30923}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25089}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 67}}, - }; - - lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4f, 0xc, 0xa3, 0x52, 0xfe, 0x47, 0xac, 0x5d, 0xc7, 0xe3, 0x23, 0x66, 0x2f, 0x93, 0x5b, 0xf}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = false; -opts.keep_alive = 1168; - uint8_t client_id_bytes[] = {0x9, 0xd0, 0x18, 0x27, 0xeb, 0x4d, 0x65, 0x6b, 0xf, 0x12, 0x3b, 0xed, 0x1d, 0xc2, 0x7e, 0x1, 0x2c}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xdf, 0x2a, 0x81, 0x46, 0x28, 0x82, 0x34, 0x8e, 0xdc, 0x5b, 0x33, 0x8a, 0xca, 0x2f, 0x55, 0xf1, 0x7a, 0x90, 0xd6, 0xe3, 0x39, 0xa2, 0xa4, 0x95}; - lwmqtt_string_t username = {24, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0x6b, 0xb1, 0xee, 0x3e, 0xcf, 0x58, 0xc6, 0x69, 0xbc, 0xaf, 0x97, 0xd7, 0x34, 0xfa, 0x12, 0x85, 0x13, 0xd0}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&byteswillprops2}}}, + }; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xda, 0x49, 0xb3, 0x5b, 0xa1, 0xd1, 0x1b, 0x7d, + 0x68, 0xcd, 0x46, 0x50, 0x42, 0x40, 0x4b, 0x85}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x32, 0xd7, 0x87, 0xe1, 0xc5, 0x4e}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 30481; + uint8_t client_id_bytes[] = {0x84, 0x81, 0x62, 0xde, 0x3d, 0x3e, 0xc5, 0xa4, 0xe, 0xec, + 0xea, 0xcc, 0x4f, 0xca, 0xf0, 0x96, 0x30, 0xba, 0xa7}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x4e, 0xcb, 0x9f, 0xd2, 0xeb, 0x61, 0x63, 0x1e, 0xa8, 0xe7, 0xdc, + 0x72, 0x27, 0xfd, 0xc8, 0xa2, 0xc0, 0xa6, 0x95, 0xe7, 0xdd}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xae, 0x2c, 0xa8, 0x4c, 0x86, 0x79, 0x0, 0x81, 0x9, 0xed, 0x98, 0x86, 0xb8, 0xde, 0x1f, + 0xa8, 0xd0, 0x22, 0x7c, 0xf6, 0x8c, 0x3d, 0xec, 0xc4, 0x7e, 0x8, 0x96, 0xf6, 0xd8, 0xa4}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Just "\220\&2", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\174'\200lI", _willMsg = "\GS\ETXa\251\147I\r\201>\212r\195\DC1\164\SO!", _willProps = [PropCorrelationData "\213\240\188\235\211q\133\230\201c|\186#/c \216@\152\207\247qx\154",PropReasonString "",PropWildcardSubscriptionAvailable 115,PropRequestProblemInformation 42,PropPayloadFormatIndicator 100,PropResponseTopic "\ESC\202\134\192\EOT\136D\176\195Re\162\130\176H$\219T\GS\140\206\213\244\DC2.'s",PropPayloadFormatIndicator 234,PropCorrelationData "\220\RS-\147\218\a\201-\200",PropServerReference "\b\246H\240\NULVy\131\188\239\208\159J\242\EM\185\193v\166\&8\EOT\ENQ<\NUL#\209",PropServerKeepAlive 21725,PropPayloadFormatIndicator 67,PropReceiveMaximum 20662,PropWillDelayInterval 3391,PropResponseTopic "\187\235\SO\205\188\214u;}%2\171z\168\179\255\150\f\NAK\193_\192\174t",PropSubscriptionIdentifier 19,PropWildcardSubscriptionAvailable 231,PropMaximumPacketSize 10332,PropAuthenticationData "\CANt!K=c$\169\181\138\233Q\200#\156Q\210\153\EOT}5|\241\193v\t\149\214-",PropMaximumQoS 239,PropAssignedClientIdentifier "\249\&0=\193S\184\SI\225\139\141\152A(\204c\195y\ESCuR\177\145j\128\149",PropWildcardSubscriptionAvailable 226]}), _cleanSession = True, _keepAlive = 6357, _connID = "\200", _properties = [PropUserProperty "\193\162\129\r\170q\170\236\201\f\155\ETX\144:" "\159\158\STX)\141Q\217\237\236k\DLE",PropPayloadFormatIndicator 247,PropAssignedClientIdentifier "T(\218\253\246\215\f\205\ENQ\159\193\ETBX\DC1\215 \236\222gw\157\r \237\178",PropPayloadFormatIndicator 98,PropRequestResponseInformation 123,PropSubscriptionIdentifierAvailable 14,PropReceiveMaximum 3111,PropMaximumPacketSize 10786,PropRequestResponseInformation 127,PropSubscriptionIdentifierAvailable 109,PropRetainAvailable 43,PropMessageExpiryInterval 27459,PropWillDelayInterval 1445,PropWildcardSubscriptionAvailable 190,PropCorrelationData "9=\212a\137\DC3\SI~\225\208\241\214\157E\f\249\&3",PropMaximumQoS 232,PropMessageExpiryInterval 2828,PropTopicAliasMaximum 31253,PropAssignedClientIdentifier "y.\194\255G\SUB",PropAuthenticationData "\204K(\235\164\167 ?\165\STX=>P\143\246\239\164\197\&8\r\219\165\CAN\129Be",PropPayloadFormatIndicator 36,PropSessionExpiryInterval 30771,PropReasonString "g\201",PropRetainAvailable 233,PropResponseTopic "\246\200",PropAuthenticationMethod "\161\215{",PropMessageExpiryInterval 6761,PropSubscriptionIdentifier 13,PropSubscriptionIdentifierAvailable 86,PropSharedSubscriptionAvailable 210]} +// ConnectRequest {_username = Just "eBV0^b\231\GS\250\n\203\224", _password = Just +// "\240\177\187\244\250c\"\200Pw\189\163m|\131\&5*\177\169]", _lastWill = Just (LastWill {_willRetain = True, _willQoS +// = QoS1, _willTopic = "\b,([w\253\205\CAN\167\199\238\&0\171\SOHj\206\NUL\245\243\144\169\b\226\180\134\154}\214\194", +// _willMsg = "\181aO\128(\188\ETB", _willProps = [PropResponseTopic +// "\240\191\190;\151\150\128\232\230\189\223\208\149d_\241i\168",PropSubscriptionIdentifier 3,PropUserProperty +// "\255\n\170w\146\254\227\225>\147\136x\146\STX=@\192)_s3",PropTopicAliasMaximum +// 26779,PropWildcardSubscriptionAvailable 149,PropWillDelayInterval 6431,PropContentType +// "\208f\163\NAK~k\r\192%\199Mc\185\181\194 \193\ETB\169\"\255\144=\CAN\NAK\168$\t",PropRetainAvailable +// 106,PropUserProperty "\161]\219U\133\146\219\141_\197\NUL\ACKa\224\192L\196p" +// "Z\172\213\215\148\f#,",PropUserProperty "\245" +// "\227\199V\169\251\141\252r\148\167\134s\a\152\DC1\167\223\253^\213VV\128\193\ACKu\132\183\232r",PropTopicAlias +// 14287,PropTopicAliasMaximum 30203,PropRetainAvailable 218,PropResponseInformation +// "\142\&6\172J\DC4\v\v\239Q\139\203!&\180",PropServerReference "ML\165\210\154\253\&4\141hB"]}), _cleanSession = +// False, _keepAlive = 3521, _connID = "\205A\247\ACK\129\&6\196\202\192<\208z\234>\ETB\DC2\195\208\221\STX\DC1L\146s", +// _properties = [PropAuthenticationData "\130\248\ETX\197\202\166]\180\SI\154\188y\132",PropResponseTopic +// "\190\200l\241\&5\245p\171\183\255Qd\DC4\149\227",PropTopicAlias 17354,PropTopicAliasMaximum +// 205,PropAssignedClientIdentifier "Hz\157\DEL\150\144Bw\194=\203A&t\255\ENQH\184$\225\140",PropUserProperty +// "\DC2&\172\&5_<\146,\162\&3^\135\149:\b\191\170\250VJs\SUB\224f\186\236L" +// "$\141a/\214\195\229(\242\146\214",PropUserProperty "\250\&1\236D\152\145\137\&1\170" +// "SvF3\146TM\223\NAK\STX\191;\NUL\NUL#/\159\253\b\129\&0.\EM\209\247",PropMessageExpiryInterval +// 28259,PropPayloadFormatIndicator 81,PropSharedSubscriptionAvailable 202,PropUserProperty +// "@\253^\230\180\181$\245\219\245\162\224\NAK\204\231\244\175\212\174f\NUL\225\186\179kv\ETB" +// "\147R\167\155k",PropContentType "\200\171|\227\159\202\208\RSa\199",PropRequestProblemInformation +// 19,PropRequestProblemInformation 133,PropMaximumPacketSize 1040,PropSubscriptionIdentifier +// 18,PropAssignedClientIdentifier "\212*\158A\154\249\DEL\209<\191\r\n",PropTopicAliasMaximum 9595,PropReasonString +// "\SYN\191\223\SI_\234\241\163+\175W\187\184\&3\194\FS",PropUserProperty "V\238\150=fw\218\&9\200\EOT" +// "\229-",PropAuthenticationMethod "#m",PropResponseInformation +// "\r\174\170X\206g\186\255\153<\220\DC4kq\EOT\227W\129",PropAuthenticationMethod +// "\224\253^\184\248x\248\DC1\180\237\193_}\155 ?\212A\175",PropPayloadFormatIndicator 97,PropUserProperty +// "b\143\DC28\220a\148\198\145\145\&6\n\243\180\SOH `N\149\187\172\246\253\&9\139L:)" +// "\SUB\247V\243\153\ESCe\\\213>\219\SOH\EM\244X\154\251\172\254Y\238\&9R\243\SYN\DC3\206"]} TEST(Connect5QCTest, Encode27) { -uint8_t pkt[] = {0x10, 0xd0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb6, 0x18, 0xd5, 0xc4, 0x1, 0x26, 0x0, 0xe, 0xc1, 0xa2, 0x81, 0xd, 0xaa, 0x71, 0xaa, 0xec, 0xc9, 0xc, 0x9b, 0x3, 0x90, 0x3a, 0x0, 0xb, 0x9f, 0x9e, 0x2, 0x29, 0x8d, 0x51, 0xd9, 0xed, 0xec, 0x6b, 0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0xcc, 0x63, 0xc3, 0x79, 0x1b, 0x75, 0x52, 0xb1, 0x91, 0x6a, 0x80, 0x95, 0x28, 0xe2, 0x0, 0x5, 0xae, 0x27, 0xc8, 0x6c, 0x49, 0x0, 0x10, 0x1d, 0x3, 0x61, 0xfb, 0x93, 0x49, 0xd, 0xc9, 0x3e, 0xd4, 0x72, 0xc3, 0x11, 0xa4, 0xe, 0x21, 0x0, 0x2, 0xdc, 0x32}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops1[] = {0x9f, 0x9e, 0x2, 0x29, 0x8d, 0x51, 0xd9, 0xed, 0xec, 0x6b, 0x10}; - uint8_t bytesprops0[] = {0xc1, 0xa2, 0x81, 0xd, 0xaa, 0x71, 0xaa, 0xec, 0xc9, 0xc, 0x9b, 0x3, 0x90, 0x3a}; - uint8_t bytesprops2[] = {0x54, 0x28, 0xda, 0xfd, 0xf6, 0xd7, 0xc, 0xcd, 0x5, 0x9f, 0xc1, 0x17, 0x58, 0x11, 0xd7, 0x20, 0xec, 0xde, 0x67, 0x77, 0x9d, 0xd, 0x20, 0xed, 0xb2}; - uint8_t bytesprops3[] = {0x39, 0x3d, 0xd4, 0x61, 0x89, 0x13, 0xf, 0x7e, 0xe1, 0xd0, 0xf1, 0xd6, 0x9d, 0x45, 0xc, 0xf9, 0x33}; - uint8_t bytesprops4[] = {0x79, 0x2e, 0xc2, 0xff, 0x47, 0x1a}; - uint8_t bytesprops5[] = {0xcc, 0x4b, 0x28, 0xeb, 0xa4, 0xa7, 0x20, 0x3f, 0xa5, 0x2, 0x3d, 0x3e, 0x50, 0x8f, 0xf6, 0xef, 0xa4, 0xc5, 0x38, 0xd, 0xdb, 0xa5, 0x18, 0x81, 0x42, 0x65}; - uint8_t bytesprops6[] = {0x67, 0xc9}; - uint8_t bytesprops7[] = {0xf6, 0xc8}; - uint8_t bytesprops8[] = {0xa1, 0xd7, 0x7b}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={14, (char*)&bytesprops0}, .v={11, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3111}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10786}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27459}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1445}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2828}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31253}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30771}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6761}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, + uint8_t pkt[] = { + 0x10, 0xbb, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0xd, 0xc1, 0xfc, 0x2, 0x16, 0x0, 0xd, 0x82, + 0xf8, 0x3, 0xc5, 0xca, 0xa6, 0x5d, 0xb4, 0xf, 0x9a, 0xbc, 0x79, 0x84, 0x8, 0x0, 0xf, 0xbe, 0xc8, 0x6c, 0xf1, + 0x35, 0xf5, 0x70, 0xab, 0xb7, 0xff, 0x51, 0x64, 0x14, 0x95, 0xe3, 0x23, 0x43, 0xca, 0x22, 0x0, 0xcd, 0x12, 0x0, + 0x15, 0x48, 0x7a, 0x9d, 0x7f, 0x96, 0x90, 0x42, 0x77, 0xc2, 0x3d, 0xcb, 0x41, 0x26, 0x74, 0xff, 0x5, 0x48, 0xb8, + 0x24, 0xe1, 0x8c, 0x26, 0x0, 0x1b, 0x12, 0x26, 0xac, 0x35, 0x5f, 0x3c, 0x92, 0x2c, 0xa2, 0x33, 0x5e, 0x87, 0x95, + 0x3a, 0x8, 0xbf, 0xaa, 0xfa, 0x56, 0x4a, 0x73, 0x1a, 0xe0, 0x66, 0xba, 0xec, 0x4c, 0x0, 0xb, 0x24, 0x8d, 0x61, + 0x2f, 0xd6, 0xc3, 0xe5, 0x28, 0xf2, 0x92, 0xd6, 0x26, 0x0, 0x9, 0xfa, 0x31, 0xec, 0x44, 0x98, 0x91, 0x89, 0x31, + 0xaa, 0x0, 0x19, 0x53, 0x76, 0x46, 0x33, 0x92, 0x54, 0x4d, 0xdf, 0x15, 0x2, 0xbf, 0x3b, 0x0, 0x0, 0x23, 0x2f, + 0x9f, 0xfd, 0x8, 0x81, 0x30, 0x2e, 0x19, 0xd1, 0xf7, 0x2, 0x0, 0x0, 0x6e, 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84}; + uint8_t bytesprops1[] = {0xbe, 0xc8, 0x6c, 0xf1, 0x35, 0xf5, 0x70, 0xab, 0xb7, 0xff, 0x51, 0x64, 0x14, 0x95, 0xe3}; + uint8_t bytesprops2[] = {0x48, 0x7a, 0x9d, 0x7f, 0x96, 0x90, 0x42, 0x77, 0xc2, 0x3d, 0xcb, + 0x41, 0x26, 0x74, 0xff, 0x5, 0x48, 0xb8, 0x24, 0xe1, 0x8c}; + uint8_t bytesprops4[] = {0x24, 0x8d, 0x61, 0x2f, 0xd6, 0xc3, 0xe5, 0x28, 0xf2, 0x92, 0xd6}; + uint8_t bytesprops3[] = {0x12, 0x26, 0xac, 0x35, 0x5f, 0x3c, 0x92, 0x2c, 0xa2, 0x33, 0x5e, 0x87, 0x95, 0x3a, + 0x8, 0xbf, 0xaa, 0xfa, 0x56, 0x4a, 0x73, 0x1a, 0xe0, 0x66, 0xba, 0xec, 0x4c}; + uint8_t bytesprops6[] = {0x53, 0x76, 0x46, 0x33, 0x92, 0x54, 0x4d, 0xdf, 0x15, 0x2, 0xbf, 0x3b, 0x0, + 0x0, 0x23, 0x2f, 0x9f, 0xfd, 0x8, 0x81, 0x30, 0x2e, 0x19, 0xd1, 0xf7}; + uint8_t bytesprops5[] = {0xfa, 0x31, 0xec, 0x44, 0x98, 0x91, 0x89, 0x31, 0xaa}; + uint8_t bytesprops8[] = {0x93, 0x52, 0xa7, 0x9b, 0x6b}; + uint8_t bytesprops7[] = {0x40, 0xfd, 0x5e, 0xe6, 0xb4, 0xb5, 0x24, 0xf5, 0xdb, 0xf5, 0xa2, 0xe0, 0x15, 0xcc, + 0xe7, 0xf4, 0xaf, 0xd4, 0xae, 0x66, 0x0, 0xe1, 0xba, 0xb3, 0x6b, 0x76, 0x17}; + uint8_t bytesprops9[] = {0xc8, 0xab, 0x7c, 0xe3, 0x9f, 0xca, 0xd0, 0x1e, 0x61, 0xc7}; + uint8_t bytesprops10[] = {0xd4, 0x2a, 0x9e, 0x41, 0x9a, 0xf9, 0x7f, 0xd1, 0x3c, 0xbf, 0xd, 0xa}; + uint8_t bytesprops11[] = {0x16, 0xbf, 0xdf, 0xf, 0x5f, 0xea, 0xf1, 0xa3, + 0x2b, 0xaf, 0x57, 0xbb, 0xb8, 0x33, 0xc2, 0x1c}; + uint8_t bytesprops13[] = {0xe5, 0x2d}; + uint8_t bytesprops12[] = {0x56, 0xee, 0x96, 0x3d, 0x66, 0x77, 0xda, 0x39, 0xc8, 0x4}; + uint8_t bytesprops14[] = {0x23, 0x6d}; + uint8_t bytesprops15[] = {0xd, 0xae, 0xaa, 0x58, 0xce, 0x67, 0xba, 0xff, 0x99, + 0x3c, 0xdc, 0x14, 0x6b, 0x71, 0x4, 0xe3, 0x57, 0x81}; + uint8_t bytesprops16[] = {0xe0, 0xfd, 0x5e, 0xb8, 0xf8, 0x78, 0xf8, 0x11, 0xb4, 0xed, + 0xc1, 0x5f, 0x7d, 0x9b, 0x20, 0x3f, 0xd4, 0x41, 0xaf}; + uint8_t bytesprops18[] = {0x1a, 0xf7, 0x56, 0xf3, 0x99, 0x1b, 0x65, 0x5c, 0xd5, 0x3e, 0xdb, 0x1, 0x19, 0xf4, + 0x58, 0x9a, 0xfb, 0xac, 0xfe, 0x59, 0xee, 0x39, 0x52, 0xf3, 0x16, 0x13, 0xce}; + uint8_t bytesprops17[] = {0x62, 0x8f, 0x12, 0x38, 0xdc, 0x61, 0x94, 0xc6, 0x91, 0x91, 0x36, 0xa, 0xf3, 0xb4, + 0x1, 0x20, 0x60, 0x4e, 0x95, 0xbb, 0xac, 0xf6, 0xfd, 0x39, 0x8b, 0x4c, 0x3a, 0x29}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17354}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 205}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops3}, .v = {11, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops5}, .v = {25, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28259}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops7}, .v = {5, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1040}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9595}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops12}, .v = {2, (char*)&bytesprops13}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops16}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {28, (char*)&bytesprops17}, .v = {27, (char*)&bytesprops18}}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xd5, 0xf0, 0xbc, 0xeb, 0xd3, 0x71, 0x85, 0xe6, 0xc9, 0x63, 0x7c, 0xba, 0x23, 0x2f, 0x63, 0x20, 0xd8, 0x40, 0x98, 0xcf, 0xf7, 0x71, 0x78, 0x9a}; - uint8_t byteswillprops1[] = {0}; - uint8_t byteswillprops2[] = {0x1b, 0xca, 0x86, 0xc0, 0x4, 0x88, 0x44, 0xb0, 0xc3, 0x52, 0x65, 0xa2, 0x82, 0xb0, 0x48, 0x24, 0xdb, 0x54, 0x1d, 0x8c, 0xce, 0xd5, 0xf4, 0x12, 0x2e, 0x27, 0x73}; - uint8_t byteswillprops3[] = {0xdc, 0x1e, 0x2d, 0x93, 0xda, 0x7, 0xc9, 0x2d, 0xc8}; - uint8_t byteswillprops4[] = {0x8, 0xf6, 0x48, 0xf0, 0x0, 0x56, 0x79, 0x83, 0xbc, 0xef, 0xd0, 0x9f, 0x4a, 0xf2, 0x19, 0xb9, 0xc1, 0x76, 0xa6, 0x38, 0x4, 0x5, 0x3c, 0x0, 0x23, 0xd1}; - uint8_t byteswillprops5[] = {0xbb, 0xeb, 0xe, 0xcd, 0xbc, 0xd6, 0x75, 0x3b, 0x7d, 0x25, 0x32, 0xab, 0x7a, 0xa8, 0xb3, 0xff, 0x96, 0xc, 0x15, 0xc1, 0x5f, 0xc0, 0xae, 0x74}; - uint8_t byteswillprops6[] = {0x18, 0x74, 0x21, 0x4b, 0x3d, 0x63, 0x24, 0xa9, 0xb5, 0x8a, 0xe9, 0x51, 0xc8, 0x23, 0x9c, 0x51, 0xd2, 0x99, 0x4, 0x7d, 0x35, 0x7c, 0xf1, 0xc1, 0x76, 0x9, 0x95, 0xd6, 0x2d}; - uint8_t byteswillprops7[] = {0xf9, 0x30, 0x3d, 0xc1, 0x53, 0xb8, 0xf, 0xe1, 0x8b, 0x8d, 0x98, 0x41, 0x28, 0xcc, 0x63, 0xc3, 0x79, 0x1b, 0x75, 0x52, 0xb1, 0x91, 0x6a, 0x80, 0x95}; - + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xf0, 0xbf, 0xbe, 0x3b, 0x97, 0x96, 0x80, 0xe8, 0xe6, + 0xbd, 0xdf, 0xd0, 0x95, 0x64, 0x5f, 0xf1, 0x69, 0xa8}; + uint8_t byteswillprops2[] = {0x61, 0x76, 0xe7, 0x3e, 0xaa, 0x77, 0x92, 0xfe, 0xe3, 0xe1, 0x3e, 0x93, + 0x88, 0x78, 0x92, 0x2, 0x3d, 0x40, 0xc0, 0x29, 0x5f, 0x73, 0x33}; + uint8_t byteswillprops1[] = {0xff, 0xa, 0x3c, 0x3f}; + uint8_t byteswillprops3[] = {0xd0, 0x66, 0xa3, 0x15, 0x7e, 0x6b, 0xd, 0xc0, 0x25, 0xc7, 0x4d, 0x63, 0xb9, 0xb5, + 0xc2, 0x20, 0xc1, 0x17, 0xa9, 0x22, 0xff, 0x90, 0x3d, 0x18, 0x15, 0xa8, 0x24, 0x9}; + uint8_t byteswillprops5[] = {0x5a, 0xac, 0xd5, 0xd7, 0x94, 0xc, 0x23, 0x2c}; + uint8_t byteswillprops4[] = {0xa1, 0x5d, 0xdb, 0x55, 0x85, 0x92, 0xdb, 0x8d, 0x5f, + 0xc5, 0x0, 0x6, 0x61, 0xe0, 0xc0, 0x4c, 0xc4, 0x70}; + uint8_t byteswillprops7[] = {0xe3, 0xc7, 0x56, 0xa9, 0xfb, 0x8d, 0xfc, 0x72, 0x94, 0xa7, + 0x86, 0x73, 0x7, 0x98, 0x11, 0xa7, 0xdf, 0xfd, 0x5e, 0xd5, + 0x56, 0x56, 0x80, 0xc1, 0x6, 0x75, 0x84, 0xb7, 0xe8, 0x72}; + uint8_t byteswillprops6[] = {0xf5}; + uint8_t byteswillprops8[] = {0x8e, 0x36, 0xac, 0x4a, 0x14, 0xb, 0xb, 0xef, 0x51, 0x8b, 0xcb, 0x21, 0x26, 0xb4}; + uint8_t byteswillprops9[] = {0x4d, 0x4c, 0xa5, 0xd2, 0x9a, 0xfd, 0x34, 0x8d, 0x68, 0x42}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21725}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20662}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3391}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10332}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {4, (char*)&byteswillprops1}, .v = {23, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26779}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6431}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {18, (char*)&byteswillprops4}, .v = {8, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {1, (char*)&byteswillprops6}, .v = {30, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14287}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30203}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&byteswillprops9}}}, }; - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xae, 0x27, 0xc8, 0x6c, 0x49}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1d, 0x3, 0x61, 0xfb, 0x93, 0x49, 0xd, 0xc9, 0x3e, 0xd4, 0x72, 0xc3, 0x11, 0xa4, 0xe, 0x21}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 6357; - uint8_t client_id_bytes[] = {0xc8}; - lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0xdc, 0x32}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; -opts.username = username; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8, 0x2c, 0x28, 0x5b, 0x77, 0xfd, 0xcd, 0x18, 0xa7, 0xc7, 0xee, 0x30, 0xab, 0x1, 0x6a, + 0xce, 0x0, 0xf5, 0xf3, 0x90, 0xa9, 0x8, 0xe2, 0xb4, 0x86, 0x9a, 0x7d, 0xd6, 0xc2}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb5, 0x61, 0x4f, 0x80, 0x28, 0xbc, 0x17}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 3521; + uint8_t client_id_bytes[] = {0xcd, 0x41, 0xf7, 0x6, 0x81, 0x36, 0xc4, 0xca, 0xc0, 0x3c, 0xd0, 0x7a, + 0xea, 0x3e, 0x17, 0x12, 0xc3, 0xd0, 0xdd, 0x2, 0x11, 0x4c, 0x92, 0x73}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x65, 0x42, 0x56, 0x30, 0x5e, 0x62, 0xe7, 0x1d, 0xfa, 0xa, 0xcb, 0xe0}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf0, 0xb1, 0xbb, 0xf4, 0xfa, 0x63, 0x22, 0xc8, 0x50, 0x77, + 0xbd, 0xa3, 0x6d, 0x7c, 0x83, 0x35, 0x2a, 0xb1, 0xa9, 0x5d}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Nothing, _password = Just "\138P\246\r\139dV\214\134\172RuyQ\235d\SI&A\169\ETX\151\187swD", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "Q\190\197\213\216\168{>!\220\238\251Zm\n\219\233\RSM\158\210\250\228\168", _willMsg = "e\227;s\172;", _willProps = [PropWildcardSubscriptionAvailable 135,PropUserProperty "H;\237\136\172Z\223\243\194G\162\189\b\253\185\147\&6\191\178\220\144d" "\233\r\133\ENQ7|\219\241m/\133\166D\155\DC2?i\SI\168\NULH\248\247\196\176",PropMessageExpiryInterval 23691,PropUserProperty "\212\220\r\SYN=)!K\200\146\177\210+\146gE\EOT\r\204)}\n\128\253\152\EOT\SO" "\183o\129n\154\160\141\FS\253\221\&3",PropServerReference "\199\&3\160\228\158\159/:\214g\248o\190\154T\199l\SOH\SO\183\142'\158\aX",PropAssignedClientIdentifier "\225\138",PropMessageExpiryInterval 16206,PropTopicAliasMaximum 12753,PropRequestResponseInformation 221,PropMaximumQoS 41,PropMaximumQoS 48,PropSubscriptionIdentifierAvailable 187,PropAuthenticationData "S\132\252\128\234\206\190!\227\163U]\160 \144\150\252)\n_",PropWildcardSubscriptionAvailable 10,PropWildcardSubscriptionAvailable 178,PropRetainAvailable 10,PropMaximumPacketSize 28852,PropAuthenticationMethod "\156vp6\253\160\172\226\221K\219z\224\SUB",PropRetainAvailable 246,PropServerKeepAlive 21476]}), _cleanSession = True, _keepAlive = 10491, _connID = "", _properties = [PropRequestProblemInformation 88,PropTopicAliasMaximum 26258,PropResponseInformation "\SOH\210\EOTt\180>\196\184\r!\200\243\237\241!w\197\183\&6 \239\NAK$B~\158zh",PropResponseTopic "A\222y\r\177d\221\241\195\130\233@\163\150?\153\130\153.Y\136\233\253",PropCorrelationData "\229\243\255X\176\208uq<}\180\145\211\235#",PropAssignedClientIdentifier "\240\227\229\SI\129K\198L\US|\244\220-K\202e/\ESC\155",PropResponseInformation "\215\192r\218T^\204\155#\175\NUL\FS\133\184U\174\145\177\STX>{\205",PropSubscriptionIdentifierAvailable 56,PropWillDelayInterval 11136,PropPayloadFormatIndicator 30,PropWillDelayInterval 5641,PropAuthenticationMethod "\171",PropResponseInformation "\176\133\\Lqu\161\ESC\232\237",PropAuthenticationMethod "\204Y\132\SOH\DEL\153C\218\164I\214\140:IC",PropMessageExpiryInterval 6360,PropRequestResponseInformation 48,PropServerReference "\134\180\170\207\172\233\149\163\210\ENQe\205\164\226:\211\143\ENQ\195\232\159",PropRetainAvailable 248,PropSubscriptionIdentifier 14,PropReceiveMaximum 13659,PropSessionExpiryInterval 23673,PropSharedSubscriptionAvailable 205,PropServerKeepAlive 19558]} +// ConnectRequest {_username = Nothing, _password = Just +// "\v\169[\202\FS\206\145\142I\167&I\169k\b\160XudF\138\227\147V\252\193\134\197", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\223\&5$\DELC3\210\149\FS\188b\147\NUL\203\&8\177\&6\141S\"\236\215C", _willMsg = +// "\137Fydy\130\218\t\246Eu\206\188[\241P\186\235\236", _willProps = [PropMessageExpiryInterval +// 2990,PropResponseInformation +// "\140\ACK\209r\251\156}\215\214\175%\201\144D\131\SOs455\STX[S\214",PropAuthenticationData +// "\206L\217Y\245FH\186@DM\249\203,c"]}), _cleanSession = True, _keepAlive = 17383, _connID = +// "\146\157\196~\185Q\216\228Q\237\164K\154M\STX\226\133\244\158\188\177 \245\198\168", _properties = +// [PropSubscriptionIdentifierAvailable 68,PropServerReference "\152)\135'\252C@\162 +// Y\170ur\138\163C@:u\182r\234!\226j",PropTopicAlias 5481,PropAssignedClientIdentifier +// "\208\221\139\172\&9",PropSessionExpiryInterval 16158,PropReasonString +// "A\251\164\150K\ETB\138~\FSq[[\SI\188\252`\153\ESC{\189<",PropAuthenticationMethod +// "\168U\146\SO\224\ETB\EM\168\219\SUB\142dC\161?.\RS@\"h \\\130\179",PropMaximumQoS 213,PropServerKeepAlive +// 9294,PropTopicAlias 6235,PropContentType +// "\163\213Y\220\202@\186M\137\222\199\152\212\192wm\136\202Y\202\RS8\203p\185\aX\163\226m",PropSharedSubscriptionAvailable +// 140,PropCorrelationData "Q\182Q",PropReceiveMaximum 8023,PropSubscriptionIdentifier 4,PropRequestResponseInformation +// 133,PropRetainAvailable 18,PropResponseTopic "\191\169ND\b\142\194\215\160",PropRetainAvailable +// 116,PropServerKeepAlive 8260,PropSessionExpiryInterval 2573,PropSessionExpiryInterval 31411,PropMessageExpiryInterval +// 6846,PropReasonString "\174<\155\139\169\234r\239",PropReasonString +// "j\GS\SOH\234\252\176\160'd\137at\ACKX<\205_",PropUserProperty "\NULM\130\137Ic\162\176\141\135N:+\229\163" +// "\185Xv\184\247-\147\225\132x\171",PropContentType +// "\218\206\139C\144v\SO\248\CAN\DC1{\GSD\146\b\142\v,\235\202\210\&0\255\175:",PropAuthenticationData +// "BYW\198P\203\129&\b\186 )m\207z\189\131\ENQ\180\140\141\201\151\174\167\NAK\199",PropPayloadFormatIndicator +// 131,PropResponseTopic "O3\bd\236^\SUB\148\EOT\DC4\159b#\NAK\210"]} TEST(Connect5QCTest, Encode28) { -uint8_t pkt[] = {0x10, 0xfd, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x28, 0xfb, 0xe0, 0x1, 0x17, 0x58, 0x22, 0x66, 0x92, 0x1a, 0x0, 0x1c, 0x1,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 0xfc, 0x80, 0xea, 0xce, 0xbe, 0x21, 0xe3, 0xa3, 0x55, 0x5d, 0xa0, 0x20, 0x90, 0x96, 0xfc, 0x29, 0xa, 0x5f, 0x28, 0xa, 0x28, 0xb2, 0x25, 0xa, 0x27, 0x0, 0x0, 0x70, 0xb4, 0x15, 0x0, 0xe, 0x9c, 0x76, 0x70, 0x36, 0xfd, 0xa0, 0xac, 0xe2, 0xdd, 0x4b, 0xdb, 0x7a, 0xe0, 0x1a, 0x25, 0xf6, 0x13, 0x53, 0xe4, 0x0, 0x18, 0x51, 0xbe, 0xc5, 0xd5, 0xd8, 0xa8, 0x7b, 0x3e, 0x21, 0xdc, 0xee, 0xfb, 0x5a, 0x6d, 0xa, 0xdb, 0xe9, 0x1e, 0x4d, 0x9e, 0xd2, 0xfa, 0xe4, 0xa8, 0x0, 0x6, 0x65, 0xe3, 0x3b, 0x73, 0xac, 0x3b, 0x0, 0x1a, 0x8a, 0x50, 0xf6, 0xd, 0x8b, 0x64, 0x56, 0xd6, 0x86, 0xac, 0x52, 0x75, 0x79, 0x51, 0xeb, 0x64, 0xf, 0x26, 0x41, 0xa9, 0x3, 0x97, 0xbb, 0x73, 0x77, 0x44}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x1, 0xd2, 0x4, 0x74, 0xb4, 0x3e, 0xc4, 0xb8, 0xd, 0x21, 0xc8, 0xf3, 0xed, 0xf1, 0x21, 0x77, 0xc5, 0xb7, 0x36, 0x20, 0xef, 0x15, 0x24, 0x42, 0x7e, 0x9e, 0x7a, 0x68}; - uint8_t bytesprops1[] = {0x41, 0xde, 0x79, 0xd, 0xb1, 0x64, 0xdd, 0xf1, 0xc3, 0x82, 0xe9, 0x40, 0xa3, 0x96, 0x3f, 0x99, 0x82, 0x99, 0x2e, 0x59, 0x88, 0xe9, 0xfd}; - uint8_t bytesprops2[] = {0xe5, 0xf3, 0xff, 0x58, 0xb0, 0xd0, 0x75, 0x71, 0x3c, 0x7d, 0xb4, 0x91, 0xd3, 0xeb, 0x23}; - uint8_t bytesprops3[] = {0xf0, 0xe3, 0xe5, 0xf, 0x81, 0x4b, 0xc6, 0x4c, 0x1f, 0x7c, 0xf4, 0xdc, 0x2d, 0x4b, 0xca, 0x65, 0x2f, 0x1b, 0x9b}; - uint8_t bytesprops4[] = {0xd7, 0xc0, 0x72, 0xda, 0x54, 0x5e, 0xcc, 0x9b, 0x23, 0xaf, 0x0, 0x1c, 0x85, 0xb8, 0x55, 0xae, 0x91, 0xb1, 0x2, 0x3e, 0x7b, 0xcd}; - uint8_t bytesprops5[] = {0xab}; - uint8_t bytesprops6[] = {0xb0, 0x85, 0x5c, 0x4c, 0x71, 0x75, 0xa1, 0x1b, 0xe8, 0xed}; - uint8_t bytesprops7[] = {0xcc, 0x59, 0x84, 0x1, 0x7f, 0x99, 0x43, 0xda, 0xa4, 0x49, 0xd6, 0x8c, 0x3a, 0x49, 0x43}; - uint8_t bytesprops8[] = {0x86, 0xb4, 0xaa, 0xcf, 0xac, 0xe9, 0x95, 0xa3, 0xd2, 0x5, 0x65, 0xcd, 0xa4, 0xe2, 0x3a, 0xd3, 0x8f, 0x5, 0xc3, 0xe8, 0x9f}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26258}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11136}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5641}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6360}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13659}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23673}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19558}}, + uint8_t pkt[] = { + 0x10, 0xed, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6e, 0x43, 0xe7, 0xc7, 0x2, 0x29, 0x44, 0x1c, 0x0, + 0x19, 0x98, 0x29, 0x87, 0x27, 0xfc, 0x43, 0x40, 0xa2, 0x20, 0x59, 0xaa, 0x75, 0x72, 0x8a, 0xa3, 0x43, 0x40, 0x3a, + 0x75, 0xb6, 0x72, 0xea, 0x21, 0xe2, 0x6a, 0x23, 0x15, 0x69, 0x12, 0x0, 0x5, 0xd0, 0xdd, 0x8b, 0xac, 0x39, 0x11, + 0x0, 0x0, 0x3f, 0x1e, 0x1f, 0x0, 0x15, 0x41, 0xfb, 0xa4, 0x96, 0x4b, 0x17, 0x8a, 0x7e, 0x1c, 0x71, 0x5b, 0x5b, + 0xf, 0xbc, 0xfc, 0x60, 0x99, 0x1b, 0x7b, 0xbd, 0x3c, 0x15, 0x0, 0x18, 0xa8, 0x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 0xec, 0x0, 0x1c, 0xb, 0xa9, 0x5b, 0xca, 0x1c, 0xce, 0x91, + 0x8e, 0x49, 0xa7, 0x26, 0x49, 0xa9, 0x6b, 0x8, 0xa0, 0x58, 0x75, 0x64, 0x46, 0x8a, 0xe3, 0x93, 0x56, 0xfc, 0xc1, + 0x86, 0xc5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x98, 0x29, 0x87, 0x27, 0xfc, 0x43, 0x40, 0xa2, 0x20, 0x59, 0xaa, 0x75, 0x72, + 0x8a, 0xa3, 0x43, 0x40, 0x3a, 0x75, 0xb6, 0x72, 0xea, 0x21, 0xe2, 0x6a}; + uint8_t bytesprops1[] = {0xd0, 0xdd, 0x8b, 0xac, 0x39}; + uint8_t bytesprops2[] = {0x41, 0xfb, 0xa4, 0x96, 0x4b, 0x17, 0x8a, 0x7e, 0x1c, 0x71, 0x5b, + 0x5b, 0xf, 0xbc, 0xfc, 0x60, 0x99, 0x1b, 0x7b, 0xbd, 0x3c}; + uint8_t bytesprops3[] = {0xa8, 0x55, 0x92, 0xe, 0xe0, 0x17, 0x19, 0xa8, 0xdb, 0x1a, 0x8e, 0x64, + 0x43, 0xa1, 0x3f, 0x2e, 0x1e, 0x40, 0x22, 0x68, 0x20, 0x5c, 0x82, 0xb3}; + uint8_t bytesprops4[] = {0xa3, 0xd5, 0x59, 0xdc, 0xca, 0x40, 0xba, 0x4d, 0x89, 0xde, 0xc7, 0x98, 0xd4, 0xc0, 0x77, + 0x6d, 0x88, 0xca, 0x59, 0xca, 0x1e, 0x38, 0xcb, 0x70, 0xb9, 0x7, 0x58, 0xa3, 0xe2, 0x6d}; + uint8_t bytesprops5[] = {0x51, 0xb6, 0x51}; + uint8_t bytesprops6[] = {0xbf, 0xa9, 0x4e, 0x44, 0x8, 0x8e, 0xc2, 0xd7, 0xa0}; + uint8_t bytesprops7[] = {0xae, 0x3c, 0x9b, 0x8b, 0xa9, 0xea, 0x72, 0xef}; + uint8_t bytesprops8[] = {0x6a, 0x1d, 0x1, 0xea, 0xfc, 0xb0, 0xa0, 0x27, 0x64, + 0x89, 0x61, 0x74, 0x6, 0x58, 0x3c, 0xcd, 0x5f}; + uint8_t bytesprops10[] = {0xb9, 0x58, 0x76, 0xb8, 0xf7, 0x2d, 0x93, 0xe1, 0x84, 0x78, 0xab}; + uint8_t bytesprops9[] = {0x0, 0x4d, 0x82, 0x89, 0x49, 0x63, 0xa2, 0xb0, 0x8d, 0x87, 0x4e, 0x3a, 0x2b, 0xe5, 0xa3}; + uint8_t bytesprops11[] = {0xda, 0xce, 0x8b, 0x43, 0x90, 0x76, 0xe, 0xf8, 0x18, 0x11, 0x7b, 0x1d, 0x44, + 0x92, 0x8, 0x8e, 0xb, 0x2c, 0xeb, 0xca, 0xd2, 0x30, 0xff, 0xaf, 0x3a}; + uint8_t bytesprops12[] = {0x42, 0x59, 0x57, 0xc6, 0x50, 0xcb, 0x81, 0x26, 0x8, 0xba, 0x20, 0x29, 0x6d, 0xcf, + 0x7a, 0xbd, 0x83, 0x5, 0xb4, 0x8c, 0x8d, 0xc9, 0x97, 0xae, 0xa7, 0x15, 0xc7}; + uint8_t bytesprops13[] = {0x4f, 0x33, 0x8, 0x64, 0xec, 0x5e, 0x1a, 0x94, 0x4, 0x14, 0x9f, 0x62, 0x23, 0x15, 0xd2}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5481}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16158}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9294}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6235}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8023}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8260}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2573}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31411}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6846}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops9}, .v = {11, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops13}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xe9, 0xd, 0x85, 0x5, 0x37, 0x7c, 0xdb, 0xf1, 0x6d, 0x2f, 0x85, 0xa6, 0x44, 0x9b, 0x12, 0x3f, 0x69, 0xf, 0xa8, 0x0, 0x48, 0xf8, 0xf7, 0xc4, 0xb0}; - uint8_t byteswillprops0[] = {0x48, 0x3b, 0xed, 0x88, 0xac, 0x5a, 0xdf, 0xf3, 0xc2, 0x47, 0xa2, 0xbd, 0x8, 0xfd, 0xb9, 0x93, 0x36, 0xbf, 0xb2, 0xdc, 0x90, 0x64}; - uint8_t byteswillprops3[] = {0xb7, 0x6f, 0x81, 0x6e, 0x9a, 0xa0, 0x8d, 0x1c, 0xfd, 0xdd, 0x33}; - uint8_t byteswillprops2[] = {0xd4, 0xdc, 0xd, 0x16, 0x3d, 0x29, 0x21, 0x4b, 0xc8, 0x92, 0xb1, 0xd2, 0x2b, 0x92, 0x67, 0x45, 0x4, 0xd, 0xcc, 0x29, 0x7d, 0xa, 0x80, 0xfd, 0x98, 0x4, 0xe}; - uint8_t byteswillprops4[] = {0xc7, 0x33, 0xa0, 0xe4, 0x9e, 0x9f, 0x2f, 0x3a, 0xd6, 0x67, 0xf8, 0x6f, 0xbe, 0x9a, 0x54, 0xc7, 0x6c, 0x1, 0xe, 0xb7, 0x8e, 0x27, 0x9e, 0x7, 0x58}; - uint8_t byteswillprops5[] = {0xe1, 0x8a}; - uint8_t byteswillprops6[] = {0x53, 0x84, 0xfc, 0x80, 0xea, 0xce, 0xbe, 0x21, 0xe3, 0xa3, 0x55, 0x5d, 0xa0, 0x20, 0x90, 0x96, 0xfc, 0x29, 0xa, 0x5f}; - uint8_t byteswillprops7[] = {0x9c, 0x76, 0x70, 0x36, 0xfd, 0xa0, 0xac, 0xe2, 0xdd, 0x4b, 0xdb, 0x7a, 0xe0, 0x1a}; - + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x8c, 0x6, 0xd1, 0x72, 0xfb, 0x9c, 0x7d, 0xd7, 0xd6, 0xaf, 0x25, 0xc9, + 0x90, 0x44, 0x83, 0xe, 0x73, 0x34, 0x35, 0x35, 0x2, 0x5b, 0x53, 0xd6}; + uint8_t byteswillprops1[] = {0xce, 0x4c, 0xd9, 0x59, 0xf5, 0x46, 0x48, 0xba, + 0x40, 0x44, 0x4d, 0xf9, 0xcb, 0x2c, 0x63}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={22, (char*)&byteswillprops0}, .v={25, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23691}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={27, (char*)&byteswillprops2}, .v={11, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16206}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12753}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28852}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21476}}, - }; - - lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x51, 0xbe, 0xc5, 0xd5, 0xd8, 0xa8, 0x7b, 0x3e, 0x21, 0xdc, 0xee, 0xfb, 0x5a, 0x6d, 0xa, 0xdb, 0xe9, 0x1e, 0x4d, 0x9e, 0xd2, 0xfa, 0xe4, 0xa8}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x65, 0xe3, 0x3b, 0x73, 0xac, 0x3b}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS2; -will.retained = true; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 10491; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t password_bytes[] = {0x8a, 0x50, 0xf6, 0xd, 0x8b, 0x64, 0x56, 0xd6, 0x86, 0xac, 0x52, 0x75, 0x79, 0x51, 0xeb, 0x64, 0xf, 0x26, 0x41, 0xa9, 0x3, 0x97, 0xbb, 0x73, 0x77, 0x44}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2990}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&byteswillprops1}}}, + }; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xdf, 0x35, 0x24, 0x7f, 0x43, 0x33, 0xd2, 0x95, 0x1c, 0xbc, 0x62, 0x93, + 0x0, 0xcb, 0x38, 0xb1, 0x36, 0x8d, 0x53, 0x22, 0xec, 0xd7, 0x43}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x89, 0x46, 0x79, 0x64, 0x79, 0x82, 0xda, 0x9, 0xf6, 0x45, + 0x75, 0xce, 0xbc, 0x5b, 0xf1, 0x50, 0xba, 0xeb, 0xec}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 17383; + uint8_t client_id_bytes[] = {0x92, 0x9d, 0xc4, 0x7e, 0xb9, 0x51, 0xd8, 0xe4, 0x51, 0xed, 0xa4, 0x4b, 0x9a, + 0x4d, 0x2, 0xe2, 0x85, 0xf4, 0x9e, 0xbc, 0xb1, 0x20, 0xf5, 0xc6, 0xa8}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xb, 0xa9, 0x5b, 0xca, 0x1c, 0xce, 0x91, 0x8e, 0x49, 0xa7, 0x26, 0x49, 0xa9, 0x6b, + 0x8, 0xa0, 0x58, 0x75, 0x64, 0x46, 0x8a, 0xe3, 0x93, 0x56, 0xfc, 0xc1, 0x86, 0xc5}; + lwmqtt_string_t password = {28, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// ConnectRequest {_username = Just "\136\ETX\185\158{\133u\SUB]M\158\149j", _password = Just "\236\211\185\RS\166i\ENQ\145\208h\157\v\ESC!", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = "\224\ESC\"\DLEM\r\165\238\&9\230\141", _willMsg = "C\129\147\222\&7Q.1.", _willProps = [PropResponseTopic "\197\166\166lRU\205",PropServerKeepAlive 12229,PropSubscriptionIdentifier 12,PropContentType "\ax\186g!H\DC3\138\247Gs\228=z\162n\195$N\196&\182fj\181c\132y",PropTopicAlias 25969,PropUserProperty "ib\148\149.\202Z \ACK\140\136N\130L\199I\138" "\175\171\198\204\161P\222K\141\DC2%Bp\237\135O\rE\165\t",PropTopicAlias 29830,PropUserProperty "@l\248\ETX\221\SOH\169\192\ETB\192k\205>Z\207\186\&6c.\200\179+3\"$J\ACK\DC3c\DLE" "\158Ck5\ESC\173\175\\\130\v/\176\209\128K\NAK\n\156)\173",PropTopicAliasMaximum 30754,PropSubscriptionIdentifier 6,PropCorrelationData "\STXf\232\146\b\188\224\253\227M\236\&0v\ETB\135<\160\164\234\US%\202\DC1s",PropTopicAlias 21576,PropPayloadFormatIndicator 191,PropSubscriptionIdentifierAvailable 85,PropRequestProblemInformation 105,PropRetainAvailable 36,PropResponseInformation "2\254\146\215\ESCW,\142Wz\171\\#\vZ4\240\146\209&)\SYN\140N\169v",PropTopicAlias 19080,PropServerReference "\\\132\162(8\DC2\163\188\138A\244\243lJ[\DELu\160J",PropUserProperty "\DC4\186\217x\NULB\148\235UE v-" "\154T\166\235\DC2\NUL`\141\188\\\aeo\190\249"]}), _cleanSession = True, _keepAlive = 12875, _connID = "j", _properties = [PropServerReference "\164\DC4\181\229",PropWildcardSubscriptionAvailable 34,PropTopicAlias 25379,PropResponseInformation "\173X\157#Y\239Z\170\161\145D_\159r\227<\246%\252\237h\230G\EM\158\191\129\NUL\142V"]} +// ConnectRequest {_username = Just "\167\237\156Mq\176\&7F\133;p\STX\164\219,\196,U\NUL\171\ETB\144M", _password = Just +// "\150'c\159\ETX\DC2\144\212TY\230:\SOHvc'\218\154\US2#1\183\&7", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS2, _willTopic = "\STX\r\249A\250?#\SI\142\224\207\203C3\203\129\232\238\f>C\SUB\149\221\198\\1", +// _willMsg = "u}g.\134\182\153", _willProps = [PropMessageExpiryInterval 24813,PropTopicAlias +// 20635,PropWillDelayInterval 25175,PropAssignedClientIdentifier +// "U^\SOH\199\132\254\SYN\190\&9H\161\243\150/\206\176\205\148\187\186",PropAuthenticationData +// "\142\254Y]\DEL\217",PropRetainAvailable 125,PropRetainAvailable 237,PropServerReference +// "\aaL\251\227\&9\137\196A\133\&6`\132$ \247+\193\219z\164",PropResponseInformation +// "\136\&4\161",PropMaximumPacketSize 22005,PropRequestResponseInformation 98,PropAuthenticationData +// "@Q\v",PropServerReference "r\184\240\247\239='>\192\172-\b\v\195\227\160\130\178\191\252\DC4\140\138\179\a +// \181\145",PropSharedSubscriptionAvailable 24,PropAuthenticationMethod +// "q\244\237\162m\ESCa\221P\220\135\a*\232\205\226\207Z",PropAssignedClientIdentifier +// "H\177c\SYN\167\251\229S\245\EOTt\156\200\191\ENQ\a\t%\211}V\157\239@\DC4",PropSubscriptionIdentifier +// 26,PropRequestResponseInformation 104,PropRequestProblemInformation 220,PropSubscriptionIdentifierAvailable +// 19,PropAuthenticationData ">\179",PropAuthenticationMethod "\130\&3d\\\139c",PropSharedSubscriptionAvailable +// 91,PropReceiveMaximum 22548,PropRequestProblemInformation 26,PropReasonString +// "\216H\217k\DC4\183\191\180\143\165\224!\141\186\n\135e\155",PropAuthenticationData +// "\186\180\ACK\SOh\157\160\RSK\170p\132\197\&10n4>\189\GS\200\ESC",PropReceiveMaximum 12897,PropMaximumQoS +// 194,PropMessageExpiryInterval 18926]}), _cleanSession = False, _keepAlive = 2013, _connID = +// "\255\RST!?\165@\128+YC\181-\250\193\183\233\&7\RS\197x\SUB[?\f\227t", _properties = [PropServerReference +// "Ae\SO\241\196\223r\ETX\160%\209g\155\255'#\182\n\RS",PropReasonString +// "f\161\155\145Cx\173zb\DC1",PropMaximumPacketSize 29438,PropTopicAliasMaximum 27453,PropMaximumPacketSize 28785,PropTopicAlias 12980,PropCorrelationData "\154t?\190\192\210\&8\149[x\151\241d&O1\176\\\205\170*k\193~\DEL\144\201\252",PropMaximumQoS 20,PropSharedSubscriptionAvailable 167,PropSessionExpiryInterval 29157,PropAuthenticationMethod "\206C(\DC4",PropResponseTopic "\167\STX\176Aj\150\&4\NAK\197\212;\228m\225\v\217\189\248\STXS",PropMessageExpiryInterval 27021,PropContentType "\201\DC3}x[~S\163r,\204?\SI\173\221\&9*X+?\137",PropContentType "\\M",PropWillDelayInterval 5654,PropCorrelationData "\137V\239}\209\243n$\204\196\201\GS\211\218",PropWillDelayInterval 15136,PropSharedSubscriptionAvailable 79]}), _cleanSession = True, _keepAlive = 67, _connID = "\246Q\170N+\132\254\213*\162\243\n", _properties = [PropReceiveMaximum 28097,PropReceiveMaximum 3524,PropWillDelayInterval 14155,PropServerKeepAlive 22395,PropCorrelationData "\DC1M\188\&6\200O\161U",PropSharedSubscriptionAvailable 152,PropAuthenticationData "\176zC\EOT\fn\166\175\153\fo\182\196?\183\244\237\199\202\234\254\152",PropCorrelationData "@\238\194\STX\226\SO-",PropSessionExpiryInterval 15111,PropPayloadFormatIndicator 144,PropAuthenticationData "\173\209\193\158\222\186\192e\DC4\182\136\DC4=5 \171\239y\190\224`\150",PropPayloadFormatIndicator 83]} +// ConnectRequest {_username = Nothing, _password = Just "\182\240\189\t", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS2, _willTopic = "\187M\164\160l,v\190\218\204Q\220\172R\151\151>", _willMsg = +// "B\157i\190\132.u\233\158\DC3\242]\255\133\181\186\255Z\240\188\227", _willProps = [PropAuthenticationMethod +// "\EOT\171\240\148",PropServerKeepAlive 18994,PropRetainAvailable 198,PropServerReference +// ".:\205\237\187\NUL\129@\167\158F\223I\252\239\&9\155\STX\STXUQ",PropMaximumQoS 182,PropRequestProblemInformation +// 92,PropTopicAliasMaximum 7274,PropSubscriptionIdentifier 29,PropWillDelayInterval 752,PropReasonString +// "\146\135\&0.\224\t@",PropWillDelayInterval 5328,PropSharedSubscriptionAvailable 117,PropUserProperty +// "\232\232\166\143\226\176R\250w\176\ACKM\ETX\157\tQ" +// "\219O\163\EM\179\152\179'\182(\133\210\SOm\207E\150`\215\&0\245\189"]}), _cleanSession = False, _keepAlive = 1282, +// _connID = "(\191\136\201\182\228\133S\r\250\189X", _properties = [PropPayloadFormatIndicator +// 103,PropAssignedClientIdentifier "",PropSharedSubscriptionAvailable 126,PropMessageExpiryInterval +// 21203,PropWillDelayInterval 6069,PropTopicAlias 24514,PropSubscriptionIdentifierAvailable +// 165,PropSubscriptionIdentifier 15,PropResponseInformation +// "\CAN\212\SYNL\206\253\211\192\224f\242\249D:H;\228\221",PropMessageExpiryInterval 435,PropTopicAliasMaximum +// 85,PropSubscriptionIdentifier 10,PropSessionExpiryInterval 15646,PropMessageExpiryInterval +// 11202,PropSharedSubscriptionAvailable 62,PropCorrelationData +// "o\236:+\144R\r\154\NAK\\\138\219\145\192\&7\204\170\&4B\DC1\134o0CJ\ETB",PropResponseInformation +// "%w[\185\DLE\177\155\SOH0\130\STX)\211\153\SOH\131\213\US\181\DC1\144",PropRequestResponseInformation +// 138,PropAuthenticationMethod +// "@\194x\155\&0N\NULG0n\186\GS\161~@\240\209\159\142\\\b\142\r|9\152`:Iu",PropUserProperty +// "D\171\198\148\177/\164\167\203" +// "\216f\220\163\141\SYN\184\v\NAK\237\&9P^\129\135\SUBY.",PropWildcardSubscriptionAvailable 20]} TEST(Connect5QCTest, Encode30) { -uint8_t pkt[] = {0x10, 0x82, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x0, 0x43, 0x60, 0x21, 0x6d, 0xc1, 0x21, 0xd, 0xc4, 0x18, 0x0, 0x0, 0x37, 0x4b, 0x13, 0x57, 0x7b, 0x9, 0x0, 0x8, 0x11, 0x4d,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 0x43, 0x4, 0xc, 0x6e, 0xa6, 0xaf, 0x99, 0xc, 0x6f, 0xb6, 0xc4, 0x3f, 0xb7, 0xf4, 0xed, 0xc7, 0xca, 0xea, 0xfe, 0x98}; - uint8_t bytesprops2[] = {0x40, 0xee, 0xc2, 0x2, 0xe2, 0xe, 0x2d}; - uint8_t bytesprops3[] = {0xad, 0xd1, 0xc1, 0x9e, 0xde, 0xba, 0xc0, 0x65, 0x14, 0xb6, 0x88, 0x14, 0x3d, 0x35, 0x20, 0xab, 0xef, 0x79, 0xbe, 0xe0, 0x60, 0x96}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28097}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3524}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14155}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22395}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15111}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, + uint8_t pkt[] = { + 0x10, 0xf6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x54, 0x5, 0x2, 0xbd, 0x1, 0x1, 0x67, 0x12, 0x0, + 0x0, 0x2a, 0x7e, 0x2, 0x0, 0x0, 0x52, 0xd3, 0x18, 0x0, 0x0, 0x17, 0xb5, 0x23, 0x5f, 0xc2, 0x29, 0xa5, 0xb, + 0xf, 0x1a, 0x0, 0x12, 0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 0x25, 0xc6, 0x1c, 0x0, 0x15, 0x2e, 0x3a, 0xcd, 0xed, 0xbb, 0x0, 0x81, 0x40, 0xa7, 0x9e, 0x46, 0xdf, 0x49, + 0xfc, 0xef, 0x39, 0x9b, 0x2, 0x2, 0x55, 0x51, 0x24, 0xb6, 0x17, 0x5c, 0x22, 0x1c, 0x6a, 0xb, 0x1d, 0x18, 0x0, + 0x0, 0x2, 0xf0, 0x1f, 0x0, 0x7, 0x92, 0x87, 0x30, 0x2e, 0xe0, 0x9, 0x40, 0x18, 0x0, 0x0, 0x14, 0xd0, 0x2a, + 0x75, 0x26, 0x0, 0x10, 0xe8, 0xe8, 0xa6, 0x8f, 0xe2, 0xb0, 0x52, 0xfa, 0x77, 0xb0, 0x6, 0x4d, 0x3, 0x9d, 0x9, + 0x51, 0x0, 0x16, 0xdb, 0x4f, 0xa3, 0x19, 0xb3, 0x98, 0xb3, 0x27, 0xb6, 0x28, 0x85, 0xd2, 0xe, 0x6d, 0xcf, 0x45, + 0x96, 0x60, 0xd7, 0x30, 0xf5, 0xbd, 0x0, 0x11, 0xbb, 0x4d, 0xa4, 0xa0, 0x6c, 0x2c, 0x76, 0xbe, 0xda, 0xcc, 0x51, + 0xdc, 0xac, 0x52, 0x97, 0x97, 0x3e, 0x0, 0x15, 0x42, 0x9d, 0x69, 0xbe, 0x84, 0x2e, 0x75, 0xe9, 0x9e, 0x13, 0xf2, + 0x5d, 0xff, 0x85, 0xb5, 0xba, 0xff, 0x5a, 0xf0, 0xbc, 0xe3, 0x0, 0x4, 0xb6, 0xf0, 0xbd, 0x9}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x18, 0xd4, 0x16, 0x4c, 0xce, 0xfd, 0xd3, 0xc0, 0xe0, + 0x66, 0xf2, 0xf9, 0x44, 0x3a, 0x48, 0x3b, 0xe4, 0xdd}; + uint8_t bytesprops2[] = {0x6f, 0xec, 0x3a, 0x2b, 0x90, 0x52, 0xd, 0x9a, 0x15, 0x5c, 0x8a, 0xdb, 0x91, + 0xc0, 0x37, 0xcc, 0xaa, 0x34, 0x42, 0x11, 0x86, 0x6f, 0x30, 0x43, 0x4a, 0x17}; + uint8_t bytesprops3[] = {0x25, 0x77, 0x5b, 0xb9, 0x10, 0xb1, 0x9b, 0x1, 0x30, 0x82, 0x2, + 0x29, 0xd3, 0x99, 0x1, 0x83, 0xd5, 0x1f, 0xb5, 0x11, 0x90}; + uint8_t bytesprops4[] = {0x40, 0xc2, 0x78, 0x9b, 0x30, 0x4e, 0x0, 0x47, 0x30, 0x6e, 0xba, 0x1d, 0xa1, 0x7e, 0x40, + 0xf0, 0xd1, 0x9f, 0x8e, 0x5c, 0x8, 0x8e, 0xd, 0x7c, 0x39, 0x98, 0x60, 0x3a, 0x49, 0x75}; + uint8_t bytesprops6[] = {0xd8, 0x66, 0xdc, 0xa3, 0x8d, 0x16, 0xb8, 0xb, 0x15, + 0xed, 0x39, 0x50, 0x5e, 0x81, 0x87, 0x1a, 0x59, 0x2e}; + uint8_t bytesprops5[] = {0x44, 0xab, 0xc6, 0x94, 0xb1, 0x2f, 0xa4, 0xa7, 0xcb}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21203}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6069}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24514}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 435}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 85}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15646}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11202}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops5}, .v = {18, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; -lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xf4, 0x66, 0x37, 0x24, 0xca, 0x25, 0x42, 0xf3, 0x6, 0xa3, 0xea, 0x46}; - uint8_t byteswillprops1[] = {0x47, 0xb6, 0xf6, 0x54, 0xe1, 0xbb, 0x64, 0x18, 0x99, 0x50, 0xb9, 0x87, 0x9, 0xab}; - uint8_t byteswillprops2[] = {0x42, 0x17, 0x67, 0x2d, 0x6f, 0x4a, 0x4e, 0x2a, 0xc4, 0x7f, 0xf6, 0x3e, 0x43, 0x78, 0xad, 0x7a, 0x62, 0x11}; - uint8_t byteswillprops3[] = {0x9a, 0x74, 0x3f, 0xbe, 0xc0, 0xd2, 0x38, 0x95, 0x5b, 0x78, 0x97, 0xf1, 0x64, 0x26, 0x4f, 0x31, 0xb0, 0x5c, 0xcd, 0xaa, 0x2a, 0x6b, 0xc1, 0x7e, 0x7f, 0x90, 0xc9, 0xfc}; - uint8_t byteswillprops4[] = {0xce, 0x43, 0x28, 0x14}; - uint8_t byteswillprops5[] = {0xa7, 0x2, 0xb0, 0x41, 0x6a, 0x96, 0x34, 0x15, 0xc5, 0xd4, 0x3b, 0xe4, 0x6d, 0xe1, 0xb, 0xd9, 0xbd, 0xf8, 0x2, 0x53}; - uint8_t byteswillprops6[] = {0xc9, 0x13, 0x7d, 0x78, 0x5b, 0x7e, 0x53, 0xa3, 0x72, 0x2c, 0xcc, 0x3f, 0xf, 0xad, 0xdd, 0x39, 0x2a, 0x58, 0x2b, 0x3f, 0x89}; - uint8_t byteswillprops7[] = {0x5c, 0x4d}; - uint8_t byteswillprops8[] = {0x89, 0x56, 0xef, 0x7d, 0xd1, 0xf3, 0x6e, 0x24, 0xcc, 0xc4, 0xc9, 0x1d, 0xd3, 0xda}; - + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x4, 0xab, 0xf0, 0x94}; + uint8_t byteswillprops1[] = {0x2e, 0x3a, 0xcd, 0xed, 0xbb, 0x0, 0x81, 0x40, 0xa7, 0x9e, 0x46, + 0xdf, 0x49, 0xfc, 0xef, 0x39, 0x9b, 0x2, 0x2, 0x55, 0x51}; + uint8_t byteswillprops2[] = {0x92, 0x87, 0x30, 0x2e, 0xe0, 0x9, 0x40}; + uint8_t byteswillprops4[] = {0xdb, 0x4f, 0xa3, 0x19, 0xb3, 0x98, 0xb3, 0x27, 0xb6, 0x28, 0x85, + 0xd2, 0xe, 0x6d, 0xcf, 0x45, 0x96, 0x60, 0xd7, 0x30, 0xf5, 0xbd}; + uint8_t byteswillprops3[] = {0xe8, 0xe8, 0xa6, 0x8f, 0xe2, 0xb0, 0x52, 0xfa, + 0x77, 0xb0, 0x6, 0x4d, 0x3, 0x9d, 0x9, 0x51}; + lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4001}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25320}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29438}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27453}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28785}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12980}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29157}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27021}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5654}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15136}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, - }; - - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf6, 0xe3, 0xb0, 0xaf, 0x5f, 0x34, 0x4, 0x7b, 0x8f, 0xcc, 0x96}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd1, 0xbe, 0x55, 0xf6, 0xd2, 0x85, 0xcf, 0x91, 0x39, 0xe5}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; -will.topic = will_topic; -will.payload = will_payload; -will.qos = LWMQTT_QOS1; -will.retained = false; -will.properties = willprops; -lwmqtt_options_t opts = lwmqtt_default_options; -opts.properties = props; -opts.clean_session = true; -opts.keep_alive = 67; - uint8_t client_id_bytes[] = {0xf6, 0x51, 0xaa, 0x4e, 0x2b, 0x84, 0xfe, 0xd5, 0x2a, 0xa2, 0xf3, 0xa}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; -opts.client_id = client_id; - uint8_t username_bytes[] = {0x18, 0x60, 0x6c, 0xe5, 0xed, 0xff}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; -opts.username = username; - uint8_t password_bytes[] = {0xc0, 0x6f, 0xd5, 0xb3, 0xb6, 0xf5, 0xc6, 0x28, 0xec, 0x4, 0x15, 0x2f}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; -opts.password = password; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18994}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7274}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 752}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5328}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {16, (char*)&byteswillprops3}, .v = {22, (char*)&byteswillprops4}}}}, + }; -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xbb, 0x4d, 0xa4, 0xa0, 0x6c, 0x2c, 0x76, 0xbe, 0xda, + 0xcc, 0x51, 0xdc, 0xac, 0x52, 0x97, 0x97, 0x3e}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x42, 0x9d, 0x69, 0xbe, 0x84, 0x2e, 0x75, 0xe9, 0x9e, 0x13, 0xf2, + 0x5d, 0xff, 0x85, 0xb5, 0xba, 0xff, 0x5a, 0xf0, 0xbc, 0xe3}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 1282; + uint8_t client_id_bytes[] = {0x28, 0xbf, 0x88, 0xc9, 0xb6, 0xe4, 0x85, 0x53, 0xd, 0xfa, 0xbd, 0x58}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xb6, 0xf0, 0xbd, 0x9}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// SubscribeRequest 2235 [("\ETB\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 28306 [("^VR\US\DELZ\SYN\186#\147D\230\US:\188\210\186\165}\145tM\224\&4\158",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\146\&4\203\145\SUB\209\235\223`.\147\&8\250Q\187\223\244\210b\235p\RS",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\205\151*/E\ETXy",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("m\136\t\NUL\228\154\166\199TU&2\143",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode1) { -uint8_t pkt[] = {0x82, 0x7, 0x8, 0xbb, 0x0, 0x2, 0x17, 0xa6, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x17, 0xa6}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; -lwmqtt_sub_options_t sub_opts[1]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x51, 0x6e, 0x92, 0x0, 0x19, 0x5e, 0x56, 0x52, 0x1f, 0x7f, 0x5a, 0x16, 0xba, 0x23, 0x93, 0x44, + 0xe6, 0x1f, 0x3a, 0xbc, 0xd2, 0xba, 0xa5, 0x7d, 0x91, 0x74, 0x4d, 0xe0, 0x34, 0x9e, 0x2, 0x0, 0x16, + 0x92, 0x34, 0xcb, 0x91, 0x1a, 0xd1, 0xeb, 0xdf, 0x60, 0x2e, 0x93, 0x38, 0xfa, 0x51, 0xbb, 0xdf, 0xf4, + 0xd2, 0x62, 0xeb, 0x70, 0x1e, 0x0, 0x0, 0x7, 0xcd, 0x97, 0x2a, 0x2f, 0x45, 0x3, 0x79, 0x2, 0x0, + 0xd, 0x6d, 0x88, 0x9, 0x0, 0xe4, 0x9a, 0xa6, 0xc7, 0x54, 0x55, 0x26, 0x32, 0x8f, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x5e, 0x56, 0x52, 0x1f, 0x7f, 0x5a, 0x16, 0xba, 0x23, 0x93, 0x44, 0xe6, 0x1f, + 0x3a, 0xbc, 0xd2, 0xba, 0xa5, 0x7d, 0x91, 0x74, 0x4d, 0xe0, 0x34, 0x9e}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x92, 0x34, 0xcb, 0x91, 0x1a, 0xd1, 0xeb, 0xdf, 0x60, 0x2e, 0x93, + 0x38, 0xfa, 0x51, 0xbb, 0xdf, 0xf4, 0xd2, 0x62, 0xeb, 0x70, 0x1e}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xcd, 0x97, 0x2a, 0x2f, 0x45, 0x3, 0x79}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6d, 0x88, 0x9, 0x0, 0xe4, 0x9a, 0xa6, 0xc7, 0x54, 0x55, 0x26, 0x32, 0x8f}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2235, 1, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28306, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 29400 [("\212\DELo=\194\186\&8\213\&6\b,\218\ENQ\155\244\161a\159\ACK\242\223\233\ACK\SYN6",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\174~\129qh",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("]\227w\FS\n\152\156\253\203\254\v\GS\210(\226\v\EM3[\242\222\232\132Q\168",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\128\&1\237)\RS\197\ETX\206~I\228\227\&6\250\192",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\243\&8\184<\190N\253\&8W\223\234Fz\221`\148\176\134\&0",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\222\162\216\&7\t",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("9\EM\253\233\240M\232\ACK\223^|\r\141\205",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\147\255\160\143\132\225\&4\223\147\145\161\211\149\230\&4p\181",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\140\167\v\DLE\221\215\250;d}?\220\&0\"\DC2\178 \169,*\172\131HV\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\149\SI\158\RS\147\170\156\220\146",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 13416 [("\r\166\147\EM\SI{\SOH\234l\226\237]\132$!)Y%\182 \DC3\174-C\164D\FS\145@",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(",\156\&5\239\239:@",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("#\138\nSgRd\ACKU\180\186\145R\159\249/\EM\142 \146X\228I33\178#",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),(";\130\229\172!\203|",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("R\183\NUL\247G\201\192\NAKw\152.p\230\DEL\208\197!\243e\167\203",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False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c, 0x2a, 0xac, 0x83, 0x48, 0x56, 0xae, 0x0, 0x0, 0x9, 0x95, 0xf, 0x9e, 0x1e, 0x93, 0xaa, 0x9c, 0xdc, 0x92, 0x2}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xd4, 0x7f, 0x6f, 0x3d, 0xc2, 0xba, 0x38, 0xd5, 0x36, 0x8, 0x2c, 0xda, 0x5, 0x9b, 0xf4, 0xa1, 0x61, 0x9f, 0x6, 0xf2, 0xdf, 0xe9, 0x6, 0x16, 0x36}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xae, 0x7e, 0x81, 0x71, 0x68}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5d, 0xe3, 0x77, 0x1c, 0xa, 0x98, 0x9c, 0xfd, 0xcb, 0xfe, 0xb, 0x1d, 0xd2, 0x28, 0xe2, 0xb, 0x19, 0x33, 0x5b, 0xf2, 0xde, 0xe8, 0x84, 0x51, 0xa8}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x80, 0x31, 0xed, 0x29, 0x1e, 0xc5, 0x3, 0xce, 0x7e, 0x49, 0xe4, 0xe3, 0x36, 0xfa, 0xc0}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xf3, 0x38, 0xb8, 0x3c, 0xbe, 0x4e, 0xfd, 0x38, 0x57, 0xdf, 0xea, 0x46, 0x7a, 0xdd, 0x60, 0x94, 0xb0, 0x86, 0x30}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xde, 0xa2, 0xd8, 0x37, 0x9}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x39, 0x19, 0xfd, 0xe9, 0xf0, 0x4d, 0xe8, 0x6, 0xdf, 0x5e, 0x7c, 0xd, 0x8d, 0xcd}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0}; - lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x93, 0xff, 0xa0, 0x8f, 0x84, 0xe1, 0x34, 0xdf, 0x93, 0x91, 0xa1, 0xd3, 0x95, 0xe6, 0x34, 0x70, 0xb5}; - lwmqtt_string_t topic_filter_s8 = {17, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x8c, 0xa7, 0xb, 0x10, 0xdd, 0xd7, 0xfa, 0x3b, 0x64, 0x7d, 0x3f, 0xdc, 0x30, 0x22, 0x12, 0xb2, 0x20, 0xa9, 0x2c, 0x2a, 0xac, 0x83, 0x48, 0x56, 0xae}; - lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; -topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x95, 0xf, 0x9e, 0x1e, 0x93, 0xaa, 0x9c, 0xdc, 0x92}; - lwmqtt_string_t topic_filter_s10 = {9, (char*)&topic_filter_s10_bytes}; -topic_filters[10] = topic_filter_s10; -lwmqtt_sub_options_t sub_opts[11]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS0; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS1; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS0; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS2; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS2; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS1; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = false; -sub_opts[8].qos = LWMQTT_QOS0; -sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[8].retain_as_published = false; -sub_opts[8].no_local = false; -sub_opts[9].qos = LWMQTT_QOS0; -sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[9].retain_as_published = false; -sub_opts[9].no_local = false; -sub_opts[10].qos = LWMQTT_QOS2; -sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[10].retain_as_published = false; -sub_opts[10].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x6c, 0x34, 0x68, 0x0, 0x1d, 0xd, 0xa6, 0x93, 0x19, 0xf, 0x7b, 0x1, 0xea, 0x6c, 0xe2, + 0xed, 0x5d, 0x84, 0x24, 0x21, 0x29, 0x59, 0x25, 0xb6, 0x20, 0x13, 0xae, 0x2d, 0x43, 0xa4, 0x44, + 0x1c, 0x91, 0x40, 0x0, 0x0, 0x7, 0x2c, 0x9c, 0x35, 0xef, 0xef, 0x3a, 0x40, 0x2, 0x0, 0x1b, + 0x23, 0x8a, 0xa, 0x53, 0x67, 0x52, 0x64, 0x6, 0x55, 0xb4, 0xba, 0x91, 0x52, 0x9f, 0xf9, 0x2f, + 0x19, 0x8e, 0x20, 0x92, 0x58, 0xe4, 0x49, 0x33, 0x33, 0xb2, 0x23, 0x0, 0x0, 0x7, 0x3b, 0x82, + 0xe5, 0xac, 0x21, 0xcb, 0x7c, 0x2, 0x0, 0x15, 0x52, 0xb7, 0x0, 0xf7, 0x47, 0xc9, 0xc0, 0x15, + 0x77, 0x98, 0x2e, 0x70, 0xe6, 0x7f, 0xd0, 0xc5, 0x21, 0xf3, 0x65, 0xa7, 0xcb, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xd, 0xa6, 0x93, 0x19, 0xf, 0x7b, 0x1, 0xea, 0x6c, 0xe2, + 0xed, 0x5d, 0x84, 0x24, 0x21, 0x29, 0x59, 0x25, 0xb6, 0x20, + 0x13, 0xae, 0x2d, 0x43, 0xa4, 0x44, 0x1c, 0x91, 0x40}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2c, 0x9c, 0x35, 0xef, 0xef, 0x3a, 0x40}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x23, 0x8a, 0xa, 0x53, 0x67, 0x52, 0x64, 0x6, 0x55, 0xb4, 0xba, 0x91, 0x52, 0x9f, + 0xf9, 0x2f, 0x19, 0x8e, 0x20, 0x92, 0x58, 0xe4, 0x49, 0x33, 0x33, 0xb2, 0x23}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x3b, 0x82, 0xe5, 0xac, 0x21, 0xcb, 0x7c}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x52, 0xb7, 0x0, 0xf7, 0x47, 0xc9, 0xc0, 0x15, 0x77, 0x98, 0x2e, + 0x70, 0xe6, 0x7f, 0xd0, 0xc5, 0x21, 0xf3, 0x65, 0xa7, 0xcb}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29400, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13416, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 11000 [("\154\198\171-\233\SYNUL\216%\n\196\&6\192\157\&0\159\216\186k\249\227>K\DC3\236",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("w7jl\r\b\213",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\EOT\185\158\227\RSDU",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("6U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\141\150T,\250\229\217f\217\SO\239FB\251\CAN",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(")\254=\198'J\DC1\DC1$\210av\158m\162)\146\132\224\191\n\232\145",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("BK\228\209\196\156\140\244?2\144\USP3z2..\DC2`\129D",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SO\154",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 19505 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\193~\153\213\236\138\165\192;P\209\245\207",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\154\DC41*\134\182g\t'\129\&1\ETX\186_\STX\SYNks\SI\235P",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("1f,]@\243\146\195\138U\CAN\153B\215M8\229X?",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("k\241\"\130\130\f=\CANf\154\172\152E",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("W\235/\243\DLE",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("\168\164\163wJ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS2}),("\229\237\196\180\216\NAK\196\157'\221z\153\239-\EOT\202X\ENQK\177YOB+",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("RLl\155O\151\a\202]\163\201\221\153L+]\180\223\205\130\DC2h\NUL)\250\252\213\DC4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode3) { -uint8_t pkt[] = {0x82, 0x85, 0x1, 0x2a, 0xf8, 0x0, 0x1a, 0x9a, 0xc6, 0xab, 0x2d, 0xe9, 0x16, 0x55, 0x4c, 0xd8, 0x25, 0xa, 0xc4, 0x36, 0xc0, 0x9d, 0x30, 0x9f, 0xd8, 0xba, 0x6b, 0xf9, 0xe3, 0x3e, 0x4b, 0x13, 0xec, 0x0, 0x0, 0x7, 0x77, 0x37, 0x6a, 0x6c, 0xd, 0x8, 0xd5, 0x2, 0x0, 0x7, 0x4, 0xb9, 0x9e, 0xe3, 0x1e, 0x44, 0x55, 0x0, 0x0, 0x2, 0x36, 0x55, 0x1, 0x0, 0xf, 0x8d, 0x96, 0x54, 0x2c, 0xfa, 0xe5, 0xd9, 0x66, 0xd9, 0xe, 0xef, 0x46, 0x42, 0xfb, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0, 0x17, 0x29, 0xfe, 0x3d, 0xc6, 0x27, 0x4a, 0x11, 0x11, 0x24, 0xd2, 0x61, 0x76, 0x9e, 0x6d, 0xa2, 0x29, 0x92, 0x84, 0xe0, 0xbf, 0xa, 0xe8, 0x91, 0x0, 0x0, 0x16, 0x42, 0x4b, 0xe4, 0xd1, 0xc4, 0x9c, 0x8c, 0xf4, 0x3f, 0x32, 0x90, 0x1f, 0x50, 0x33, 0x7a, 0x32, 0x2e, 0x2e, 0x12, 0x60, 0x81, 0x44, 0x0, 0x0, 0x2, 0xe, 0x9a, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x9a, 0xc6, 0xab, 0x2d, 0xe9, 0x16, 0x55, 0x4c, 0xd8, 0x25, 0xa, 0xc4, 0x36, 0xc0, 0x9d, 0x30, 0x9f, 0xd8, 0xba, 0x6b, 0xf9, 0xe3, 0x3e, 0x4b, 0x13, 0xec}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x77, 0x37, 0x6a, 0x6c, 0xd, 0x8, 0xd5}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4, 0xb9, 0x9e, 0xe3, 0x1e, 0x44, 0x55}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x36, 0x55}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8d, 0x96, 0x54, 0x2c, 0xfa, 0xe5, 0xd9, 0x66, 0xd9, 0xe, 0xef, 0x46, 0x42, 0xfb, 0x18}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x29, 0xfe, 0x3d, 0xc6, 0x27, 0x4a, 0x11, 0x11, 0x24, 0xd2, 0x61, 0x76, 0x9e, 0x6d, 0xa2, 0x29, 0x92, 0x84, 0xe0, 0xbf, 0xa, 0xe8, 0x91}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x42, 0x4b, 0xe4, 0xd1, 0xc4, 0x9c, 0x8c, 0xf4, 0x3f, 0x32, 0x90, 0x1f, 0x50, 0x33, 0x7a, 0x32, 0x2e, 0x2e, 0x12, 0x60, 0x81, 0x44}; - lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe, 0x9a}; - lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; -lwmqtt_sub_options_t sub_opts[9]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS1; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS0; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS0; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS0; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = false; -sub_opts[8].qos = LWMQTT_QOS1; -sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[8].retain_as_published = false; -sub_opts[8].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x4c, 0x31, 0x0, 0x0, 0x0, 0x0, 0xd, 0xc1, 0x7e, 0x99, 0xd5, 0xec, 0x8a, + 0xa5, 0xc0, 0x3b, 0x50, 0xd1, 0xf5, 0xcf, 0x1, 0x0, 0x15, 0x9a, 0x14, 0x31, 0x2a, 0x86, 0xb6, + 0x67, 0x9, 0x27, 0x81, 0x31, 0x3, 0xba, 0x5f, 0x2, 0x16, 0x6b, 0x73, 0xf, 0xeb, 0x50, 0x0, + 0x0, 0x13, 0x31, 0x66, 0x2c, 0x5d, 0x40, 0xf3, 0x92, 0xc3, 0x8a, 0x55, 0x18, 0x99, 0x42, 0xd7, + 0x4d, 0x38, 0xe5, 0x58, 0x3f, 0x1, 0x0, 0xd, 0x6b, 0xf1, 0x22, 0x82, 0x82, 0xc, 0x3d, 0x18, + 0x66, 0x9a, 0xac, 0x98, 0x45, 0x0, 0x0, 0x5, 0x57, 0xeb, 0x2f, 0xf3, 0x10, 0x1, 0x0, 0x5, + 0xa8, 0xa4, 0xa3, 0x77, 0x4a, 0x2, 0x0, 0x18, 0xe5, 0xed, 0xc4, 0xb4, 0xd8, 0x15, 0xc4, 0x9d, + 0x27, 0xdd, 0x7a, 0x99, 0xef, 0x2d, 0x4, 0xca, 0x58, 0x5, 0x4b, 0xb1, 0x59, 0x4f, 0x42, 0x2b, + 0x1, 0x0, 0x1c, 0x52, 0x4c, 0x6c, 0x9b, 0x4f, 0x97, 0x7, 0xca, 0x5d, 0xa3, 0xc9, 0xdd, 0x99, + 0x4c, 0x2b, 0x5d, 0xb4, 0xdf, 0xcd, 0x82, 0x12, 0x68, 0x0, 0x29, 0xfa, 0xfc, 0xd5, 0x14, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc1, 0x7e, 0x99, 0xd5, 0xec, 0x8a, 0xa5, 0xc0, 0x3b, 0x50, 0xd1, 0xf5, 0xcf}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x9a, 0x14, 0x31, 0x2a, 0x86, 0xb6, 0x67, 0x9, 0x27, 0x81, 0x31, + 0x3, 0xba, 0x5f, 0x2, 0x16, 0x6b, 0x73, 0xf, 0xeb, 0x50}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x31, 0x66, 0x2c, 0x5d, 0x40, 0xf3, 0x92, 0xc3, 0x8a, 0x55, + 0x18, 0x99, 0x42, 0xd7, 0x4d, 0x38, 0xe5, 0x58, 0x3f}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x6b, 0xf1, 0x22, 0x82, 0x82, 0xc, 0x3d, 0x18, 0x66, 0x9a, 0xac, 0x98, 0x45}; + lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x57, 0xeb, 0x2f, 0xf3, 0x10}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa8, 0xa4, 0xa3, 0x77, 0x4a}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe5, 0xed, 0xc4, 0xb4, 0xd8, 0x15, 0xc4, 0x9d, 0x27, 0xdd, 0x7a, 0x99, + 0xef, 0x2d, 0x4, 0xca, 0x58, 0x5, 0x4b, 0xb1, 0x59, 0x4f, 0x42, 0x2b}; + lwmqtt_string_t topic_filter_s7 = {24, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x52, 0x4c, 0x6c, 0x9b, 0x4f, 0x97, 0x7, 0xca, 0x5d, 0xa3, + 0xc9, 0xdd, 0x99, 0x4c, 0x2b, 0x5d, 0xb4, 0xdf, 0xcd, 0x82, + 0x12, 0x68, 0x0, 0x29, 0xfa, 0xfc, 0xd5, 0x14}; + lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11000, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19505, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 21792 [("6\208Y0\251\199\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("GX\147{(\182\223\141\GSB;\164\153/\133\DC2s",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 22696 [("i\\\ETB]\223\172\230\167S\161\b\f\181\140\230\235\211\199\RS",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\167",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\167E\206\237eq!\244c\192\133\243\244",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\150\245e",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\156\133~]\132@\193",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\RS\145\206) +// \b\156\205\226\161RF\ETX\DC3\144q\211\212pm]%6\185\228\189p",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\188*F\240k\177\DEL\179Z\238a\160$\225\245*\135(\DC2q",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\197\168cf\214e\153\EM_T\211\151;\179\163\164 +// \135\158\193\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("C\133\193\&1\150FS\ESC\227S;\138I\ETX\SUB",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\148\241Hb\144[\206)\160\178w",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("HG\190\249\226\171Bd;n\226\240\138\157R\188\178\139",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode4) { -uint8_t pkt[] = {0x82, 0x20, 0x55, 0x20, 0x0, 0x7, 0x36, 0xd0, 0x59, 0x30, 0xfb, 0xc7, 0x19, 0x1, 0x0, 0x11, 0x47, 0x58, 0x93, 0x7b, 0x28, 0xb6, 0xdf, 0x8d, 0x1d, 0x42, 0x3b, 0xa4, 0x99, 0x2f, 0x85, 0x12, 0x73, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x36, 0xd0, 0x59, 0x30, 0xfb, 0xc7, 0x19}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x47, 0x58, 0x93, 0x7b, 0x28, 0xb6, 0xdf, 0x8d, 0x1d, 0x42, 0x3b, 0xa4, 0x99, 0x2f, 0x85, 0x12, 0x73}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; -lwmqtt_sub_options_t sub_opts[2]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8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f0, 0x8a, + 0x9d, 0x52, 0xbc, 0xb2, 0x8b, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x69, 0x5c, 0x17, 0x5d, 0xdf, 0xac, 0xe6, 0xa7, 0x53, 0xa1, + 0x8, 0xc, 0xb5, 0x8c, 0xe6, 0xeb, 0xd3, 0xc7, 0x1e}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa7}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa7, 0x45, 0xce, 0xed, 0x65, 0x71, 0x21, 0xf4, 0x63, 0xc0, 0x85, 0xf3, 0xf4}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x96, 0xf5, 0x65}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9c, 0x85, 0x7e, 0x5d, 0x84, 0x40, 0xc1}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1e, 0x91, 0xce, 0x29, 0x20, 0x8, 0x9c, 0xcd, 0xe2, 0xa1, 0x52, 0x46, 0x3, 0x13, + 0x90, 0x71, 0xd3, 0xd4, 0x70, 0x6d, 0x5d, 0x25, 0x36, 0xb9, 0xe4, 0xbd, 0x70}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xbc, 0x2a, 0x46, 0xf0, 0x6b, 0xb1, 0x7f, 0xb3, 0x5a, 0xee, + 0x61, 0xa0, 0x24, 0xe1, 0xf5, 0x2a, 0x87, 0x28, 0x12, 0x71}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xc5, 0xa8, 0x63, 0x66, 0xd6, 0x65, 0x99, 0x19, 0x5f, 0x54, 0xd3, + 0x97, 0x3b, 0xb3, 0xa3, 0xa4, 0x20, 0x87, 0x9e, 0xc1, 0x1}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x43, 0x85, 0xc1, 0x31, 0x96, 0x46, 0x53, 0x1b, + 0xe3, 0x53, 0x3b, 0x8a, 0x49, 0x3, 0x1a}; + lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x94, 0xf1, 0x48, 0x62, 0x90, 0x5b, 0xce, 0x29, 0xa0, 0xb2, 0x77}; + lwmqtt_string_t topic_filter_s9 = {11, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x48, 0x47, 0xbe, 0xf9, 0xe2, 0xab, 0x42, 0x64, 0x3b, + 0x6e, 0xe2, 0xf0, 0x8a, 0x9d, 0x52, 0xbc, 0xb2, 0x8b}; + lwmqtt_string_t topic_filter_s10 = {18, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21792, 2, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22696, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 20269 [("\220\133\254]\185%\213_\189\199t$[\170m\232m\SOf3c\226",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 14047 [("\r\253\211]\t\130|\206\&1\231\131\EOT\SI\129\229\140",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\245\193h\190\138\168\227j\SUB\DC2\232\129A\197",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\152>\249\ACK",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\184\209\128O=(Q\229",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("2E\213\230\200\236\143\235\&0\NUL\CAN\ESC#Y\224Bf\FS-z\133 \192'C",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\177\212\217\238\249\r\208\171n\214\145HAI\FSG\NUL>\198\212y\RS\217\148\225\CANQ",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("1\152:S",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("\180n\153T\208\214\157",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\168eem\240p\168\224\244\EOT\131/;\201\179\224",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),(")ZK[\221\236\"r\197\144\180\255,\159\143\229\160\189\242",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode5) { -uint8_t pkt[] = {0x82, 0x1b, 0x4f, 0x2d, 0x0, 0x16, 0xdc, 0x85, 0xfe, 0x5d, 0xb9, 0x25, 0xd5, 0x5f, 0xbd, 0xc7, 0x74, 0x24, 0x5b, 0xaa, 0x6d, 0xe8, 0x6d, 0xe, 0x66, 0x33, 0x63, 0xe2, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xdc, 0x85, 0xfe, 0x5d, 0xb9, 0x25, 0xd5, 0x5f, 0xbd, 0xc7, 0x74, 0x24, 0x5b, 0xaa, 0x6d, 0xe8, 0x6d, 0xe, 0x66, 0x33, 0x63, 0xe2}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; -lwmqtt_sub_options_t sub_opts[1]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0xac, 0x1, 0x36, 0xdf, 0x0, 0x10, 0xd, 0xfd, 0xd3, 0x5d, 0x9, 0x82, 0x7c, 0xce, 0x31, + 0xe7, 0x83, 0x4, 0xf, 0x81, 0xe5, 0x8c, 0x2, 0x0, 0xe, 0xf5, 0xc1, 0x68, 0xbe, 0x8a, 0xa8, + 0xe3, 0x6a, 0x1a, 0x12, 0xe8, 0x81, 0x41, 0xc5, 0x0, 0x0, 0x4, 0x98, 0x3e, 0xf9, 0x6, 0x0, + 0x0, 0x8, 0xb8, 0xd1, 0x80, 0x4f, 0x3d, 0x28, 0x51, 0xe5, 0x0, 0x0, 0x19, 0x32, 0x45, 0xd5, + 0xe6, 0xc8, 0xec, 0x8f, 0xeb, 0x30, 0x0, 0x18, 0x1b, 0x23, 0x59, 0xe0, 0x42, 0x66, 0x1c, 0x2d, + 0x7a, 0x85, 0x20, 0xc0, 0x27, 0x43, 0x2, 0x0, 0x1b, 0xb1, 0xd4, 0xd9, 0xee, 0xf9, 0xd, 0xd0, + 0xab, 0x6e, 0xd6, 0x91, 0x48, 0x41, 0x49, 0x1c, 0x47, 0x0, 0x3e, 0xc6, 0xd4, 0x79, 0x1e, 0xd9, + 0x94, 0xe1, 0x18, 0x51, 0x0, 0x0, 0x4, 0x31, 0x98, 0x3a, 0x53, 0x0, 0x0, 0x7, 0xb4, 0x6e, + 0x99, 0x54, 0xd0, 0xd6, 0x9d, 0x0, 0x0, 0x10, 0xa8, 0x65, 0x65, 0x6d, 0xf0, 0x70, 0xa8, 0xe0, + 0xf4, 0x4, 0x83, 0x2f, 0x3b, 0xc9, 0xb3, 0xe0, 0x2, 0x0, 0x13, 0x29, 0x5a, 0x4b, 0x5b, 0xdd, + 0xec, 0x22, 0x72, 0xc5, 0x90, 0xb4, 0xff, 0x2c, 0x9f, 0x8f, 0xe5, 0xa0, 0xbd, 0xf2, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd, 0xfd, 0xd3, 0x5d, 0x9, 0x82, 0x7c, 0xce, + 0x31, 0xe7, 0x83, 0x4, 0xf, 0x81, 0xe5, 0x8c}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf5, 0xc1, 0x68, 0xbe, 0x8a, 0xa8, 0xe3, + 0x6a, 0x1a, 0x12, 0xe8, 0x81, 0x41, 0xc5}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x98, 0x3e, 0xf9, 0x6}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb8, 0xd1, 0x80, 0x4f, 0x3d, 0x28, 0x51, 0xe5}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x32, 0x45, 0xd5, 0xe6, 0xc8, 0xec, 0x8f, 0xeb, 0x30, 0x0, 0x18, 0x1b, 0x23, + 0x59, 0xe0, 0x42, 0x66, 0x1c, 0x2d, 0x7a, 0x85, 0x20, 0xc0, 0x27, 0x43}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb1, 0xd4, 0xd9, 0xee, 0xf9, 0xd, 0xd0, 0xab, 0x6e, 0xd6, 0x91, 0x48, 0x41, 0x49, + 0x1c, 0x47, 0x0, 0x3e, 0xc6, 0xd4, 0x79, 0x1e, 0xd9, 0x94, 0xe1, 0x18, 0x51}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x31, 0x98, 0x3a, 0x53}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xb4, 0x6e, 0x99, 0x54, 0xd0, 0xd6, 0x9d}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa8, 0x65, 0x65, 0x6d, 0xf0, 0x70, 0xa8, 0xe0, + 0xf4, 0x4, 0x83, 0x2f, 0x3b, 0xc9, 0xb3, 0xe0}; + lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x29, 0x5a, 0x4b, 0x5b, 0xdd, 0xec, 0x22, 0x72, 0xc5, 0x90, + 0xb4, 0xff, 0x2c, 0x9f, 0x8f, 0xe5, 0xa0, 0xbd, 0xf2}; + lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20269, 1, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); - -} - + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14047, 10, topic_filters, sub_opts, props); -// SubscribeRequest 27793 [("\175\175\230\214\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(",\DEL[\SO\253\205\b\135j\ESC\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\224\206y\244\197V\182\157Q\232\248H\131\180\228B\FS\DC2\SO\159\243w",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\197\204\211\195h[\RSa&\150PL\SO\231\187\173\192P|q\240\r\139-\232\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\164\169|\199\van\145$\211<3\180)>\173Xgz:\225\DC4\163\212\141\177h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SUBl",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode6) { -uint8_t pkt[] = {0x82, 0x71, 0x6c, 0x91, 0x0, 0x5, 0xaf, 0xaf, 0xe6, 0xd6, 0x32, 0x1, 0x0, 0xb, 0x2c, 0x7f, 0x5b, 0xe, 0xfd, 0xcd, 0x8, 0x87, 0x6a, 0x1b, 0xd9, 0x0, 0x0, 0x16, 0xe0, 0xce, 0x79, 0xf4, 0xc5, 0x56, 0xb6, 0x9d, 0x51, 0xe8, 0xf8, 0x48, 0x83, 0xb4, 0xe4, 0x42, 0x1c, 0x12, 0xe, 0x9f, 0xf3, 0x77, 0x1, 0x0, 0x1a, 0xc5, 0xcc, 0xd3, 0xc3, 0x68, 0x5b, 0x1e, 0x61, 0x26, 0x96, 0x50, 0x4c, 0xe, 0xe7, 0xbb, 0xad, 0xc0, 0x50, 0x7c, 0x71, 0xf0, 0xd, 0x8b, 0x2d, 0xe8, 0xc5, 0x0, 0x0, 0x1b, 0xa4, 0xa9, 0x7c, 0xc7, 0xb, 0x61, 0x6e, 0x91, 0x24, 0xd3, 0x3c, 0x33, 0xb4, 0x29, 0x3e, 0xad, 0x58, 0x67, 0x7a, 0x3a, 0xe1, 0x14, 0xa3, 0xd4, 0x8d, 0xb1, 0x68, 0x1, 0x0, 0x2, 0x1a, 0x6c, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xaf, 0xaf, 0xe6, 0xd6, 0x32}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2c, 0x7f, 0x5b, 0xe, 0xfd, 0xcd, 0x8, 0x87, 0x6a, 0x1b, 0xd9}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe0, 0xce, 0x79, 0xf4, 0xc5, 0x56, 0xb6, 0x9d, 0x51, 0xe8, 0xf8, 0x48, 0x83, 0xb4, 0xe4, 0x42, 0x1c, 0x12, 0xe, 0x9f, 0xf3, 0x77}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc5, 0xcc, 0xd3, 0xc3, 0x68, 0x5b, 0x1e, 0x61, 0x26, 0x96, 0x50, 0x4c, 0xe, 0xe7, 0xbb, 0xad, 0xc0, 0x50, 0x7c, 0x71, 0xf0, 0xd, 0x8b, 0x2d, 0xe8, 0xc5}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa4, 0xa9, 0x7c, 0xc7, 0xb, 0x61, 0x6e, 0x91, 0x24, 0xd3, 0x3c, 0x33, 0xb4, 0x29, 0x3e, 0xad, 0x58, 0x67, 0x7a, 0x3a, 0xe1, 0x14, 0xa3, 0xd4, 0x8d, 0xb1, 0x68}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1a, 0x6c}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; -lwmqtt_sub_options_t sub_opts[6]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS0; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS0; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS1; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 502 [("\ESC\USm\212\ETB\238\&9\252\153\189\163S\234=+",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("{\221\\\229 +// :\162\183\177\157\208\253\FS\144bS\217\ETB\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("U,\243\&4\ETB\241\&1\142\221\ACK#\tm\137\153\131F\200\147\&1\153\242\176\192\241\132>\192\174",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\SI\SI\DC39\233\224\EMM\128L5\235\156\157o\239N7\172:d\247",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode6) { + uint8_t pkt[] = {0x82, 0x63, 0x1, 0xf6, 0x0, 0xf, 0x1b, 0x1f, 0x6d, 0xd4, 0x17, 0xee, 0x39, 0xfc, 0x99, 0xbd, 0xa3, + 0x53, 0xea, 0x3d, 0x2b, 0x2, 0x0, 0x13, 0x7b, 0xdd, 0x5c, 0xe5, 0x20, 0x3a, 0xa2, 0xb7, 0xb1, 0x9d, + 0xd0, 0xfd, 0x1c, 0x90, 0x62, 0x53, 0xd9, 0x17, 0xb4, 0x0, 0x0, 0x1d, 0x55, 0x2c, 0xf3, 0x34, 0x17, + 0xf1, 0x31, 0x8e, 0xdd, 0x6, 0x23, 0x9, 0x6d, 0x89, 0x99, 0x83, 0x46, 0xc8, 0x93, 0x31, 0x99, 0xf2, + 0xb0, 0xc0, 0xf1, 0x84, 0x3e, 0xc0, 0xae, 0x2, 0x0, 0x16, 0xf, 0xf, 0x13, 0x39, 0xe9, 0xe0, 0x19, + 0x4d, 0x80, 0x4c, 0x35, 0xeb, 0x9c, 0x9d, 0x6f, 0xef, 0x4e, 0x37, 0xac, 0x3a, 0x64, 0xf7, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x1b, 0x1f, 0x6d, 0xd4, 0x17, 0xee, 0x39, 0xfc, + 0x99, 0xbd, 0xa3, 0x53, 0xea, 0x3d, 0x2b}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7b, 0xdd, 0x5c, 0xe5, 0x20, 0x3a, 0xa2, 0xb7, 0xb1, 0x9d, + 0xd0, 0xfd, 0x1c, 0x90, 0x62, 0x53, 0xd9, 0x17, 0xb4}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x55, 0x2c, 0xf3, 0x34, 0x17, 0xf1, 0x31, 0x8e, 0xdd, 0x6, + 0x23, 0x9, 0x6d, 0x89, 0x99, 0x83, 0x46, 0xc8, 0x93, 0x31, + 0x99, 0xf2, 0xb0, 0xc0, 0xf1, 0x84, 0x3e, 0xc0, 0xae}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf, 0xf, 0x13, 0x39, 0xe9, 0xe0, 0x19, 0x4d, 0x80, 0x4c, 0x35, + 0xeb, 0x9c, 0x9d, 0x6f, 0xef, 0x4e, 0x37, 0xac, 0x3a, 0x64, 0xf7}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27793, 6, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 502, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 30311 [("a\220\187\230\175\184\177\131\&8n\180}\229Z",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\234\199\181\DC1N\b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 27247 +// [("\137\230\141\ACK\169\178P\242\SUB\143Ml]\220\&1<\251\195\206\187\139$\167\174\\zW",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("<\235\&2\233\188SY\DC2}N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\169\156\DC4\199\SUBt\235!\GS\198\SUB\142i\208\aj\\\NAKG\a",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("h\252u[I\131\&8\238i\235/\165{\147\159\226/G\208\207npWu\ACKc\150@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\132*T\ETB!\169\180\173\239t=",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\184\198;\ETX\221\STX\202\227[\197q;6\189\n\169",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("x30\199\163\193",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("s\226\229\185N]\173-\176\199\183\201\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("\228\134\195\198\239\232\245\153\ACKd.\130%$9D\237\231\158\SOH\160\242\151\170\\I",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode7) { -uint8_t pkt[] = {0x82, 0x1f, 0x76, 0x67, 0x0, 0xe, 0x61, 0xdc, 0xbb, 0xe6, 0xaf, 0xb8, 0xb1, 0x83, 0x38, 0x6e, 0xb4, 0x7d, 0xe5, 0x5a, 0x0, 0x0, 0x6, 0xea, 0xc7, 0xb5, 0x11, 0x4e, 0x8, 0x2, 0x0, 0x0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x61, 0xdc, 0xbb, 0xe6, 0xaf, 0xb8, 0xb1, 0x83, 0x38, 0x6e, 0xb4, 0x7d, 0xe5, 0x5a}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xea, 0xc7, 0xb5, 0x11, 0x4e, 0x8}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; -lwmqtt_sub_options_t sub_opts[3]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0xc0, 0x1, 0x6a, 0x6f, 0x0, 0x1b, 0x89, 0xe6, 0x8d, 0x6, 0xa9, 0xb2, 0x50, 0xf2, 0x1a, 0x8f, + 0x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ters[11]; + uint8_t topic_filter_s0_bytes[] = {0x89, 0xe6, 0x8d, 0x6, 0xa9, 0xb2, 0x50, 0xf2, 0x1a, 0x8f, 0x4d, 0x6c, 0x5d, 0xdc, + 0x31, 0x3c, 0xfb, 0xc3, 0xce, 0xbb, 0x8b, 0x24, 0xa7, 0xae, 0x5c, 0x7a, 0x57}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x3c, 0xeb, 0x32, 0xe9, 0xbc, 0x53, 0x59, 0x12, 0x7d, 0x4e}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa9, 0x9c, 0x14, 0xc7, 0x1a, 0x74, 0xeb, 0x21, 0x1d, 0xc6, + 0x1a, 0x8e, 0x69, 0xd0, 0x7, 0x6a, 0x5c, 0x15, 0x47, 0x7}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x68, 0xfc, 0x75, 0x5b, 0x49, 0x83, 0x38, 0xee, 0x69, 0xeb, + 0x2f, 0xa5, 0x7b, 0x93, 0x9f, 0xe2, 0x2f, 0x47, 0xd0, 0xcf, + 0x6e, 0x70, 0x57, 0x75, 0x6, 0x63, 0x96, 0x40}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x84, 0x2a, 0x54, 0x17, 0x21, 0xa9, 0xb4, 0xad, 0xef, 0x74, 0x3d}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xb8, 0xc6, 0x3b, 0x3, 0xdd, 0x2, 0xca, 0xe3, + 0x5b, 0xc5, 0x71, 0x3b, 0x36, 0xbd, 0xa, 0xa9}; + lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x78, 0x33, 0x30, 0xc7, 0xa3, 0xc1}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x73, 0xe2, 0xe5, 0xb9, 0x4e, 0x5d, 0xad, 0x2d, 0xb0, 0xc7, 0xb7, 0xc9, 0xdb}; + lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe4, 0x86, 0xc3, 0xc6, 0xef, 0xe8, 0xf5, 0x99, 0x6, 0x64, 0x2e, 0x82, 0x25, + 0x24, 0x39, 0x44, 0xed, 0xe7, 0x9e, 0x1, 0xa0, 0xf2, 0x97, 0xaa, 0x5c, 0x49}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30311, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27247, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 32651 [("\168U\NULn\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k\141i\169",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\ESC\250F\175_R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\187\219|!\193M\251\187\176h\ETB",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\155m$\224\202\136\212\255\150=\242\197\195P\SUB\211",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\193\143\128\SOH5\150K6\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 15611 [("\NUL\212p\201h\br'2ko\162\SYN\242U\173Sp\182\184",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode8) { -uint8_t pkt[] = {0x82, 0x47, 0x7f, 0x8b, 0x0, 0x5, 0xa8, 0x55, 0x0, 0x6e, 0x94, 0x0, 0x0, 0x4, 0x6b, 0x8d, 0x69, 0xa9, 0x1, 0x0, 0x6, 0x1b, 0xfa, 0x46, 0xaf, 0x5f, 0x52, 0x2, 0x0, 0xb, 0xbb, 0xdb, 0x7c, 0x21, 0xc1, 0x4d, 0xfb, 0xbb, 0xb0, 0x68, 0x17, 0x0, 0x0, 0x10, 0x9b, 0x6d, 0x24, 0xe0, 0xca, 0x88, 0xd4, 0xff, 0x96, 0x3d, 0xf2, 0xc5, 0xc3, 0x50, 0x1a, 0xd3, 0x2, 0x0, 0x9, 0xc1, 0x8f, 0x80, 0x1, 0x35, 0x96, 0x4b, 0x36, 0x2, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xa8, 0x55, 0x0, 0x6e, 0x94}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6b, 0x8d, 0x69, 0xa9}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1b, 0xfa, 0x46, 0xaf, 0x5f, 0x52}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xbb, 0xdb, 0x7c, 0x21, 0xc1, 0x4d, 0xfb, 0xbb, 0xb0, 0x68, 0x17}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9b, 0x6d, 0x24, 0xe0, 0xca, 0x88, 0xd4, 0xff, 0x96, 0x3d, 0xf2, 0xc5, 0xc3, 0x50, 0x1a, 0xd3}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc1, 0x8f, 0x80, 0x1, 0x35, 0x96, 0x4b, 0x36, 0x2}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; -lwmqtt_sub_options_t sub_opts[6]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS0; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x19, 0x3c, 0xfb, 0x0, 0x14, 0x0, 0xd4, 0x70, 0xc9, 0x68, 0x8, 0x72, 0x27, + 0x32, 0x6b, 0x6f, 0xa2, 0x16, 0xf2, 0x55, 0xad, 0x53, 0x70, 0xb6, 0xb8, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x0, 0xd4, 0x70, 0xc9, 0x68, 0x8, 0x72, 0x27, 0x32, 0x6b, + 0x6f, 0xa2, 0x16, 0xf2, 0x55, 0xad, 0x53, 0x70, 0xb6, 0xb8}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32651, 6, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15611, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 15465 [("\234y<\176R ]*\193\136",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\DC3v\b\SOH9",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("6'\ACK}p\CAN\144g\147~\200\182&\173\176\128%ev\142\SIT\254\138\&1h\US\169\210R",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 16791 [("\\\ACK\129B1\149Y/2\178vx\RSo",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\157\170\249\222\&8\248\181\190\212q\151\133\186\245\171\223g1)U\206\a\135",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("y\245\244\225K\177[\153B\179@\161\193",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\146\247\211\182H z\bK\191\RS\194V\134\&8$\221;8",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\167\159W\185-u;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("X\246\247\218G\162mZ(\DEL\EM\172",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\152X9\166\177\RS\226\222\212\128",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\236\NAK\169\245",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("@I\210\CAN\210\EM\200\RS\186\ETB\235\180$\182\167\155\138\135>'\246",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode9) { -uint8_t pkt[] = {0x82, 0x38, 0x3c, 0x69, 0x0, 0xa, 0xea, 0x79, 0x3c, 0xb0, 0x52, 0x20, 0x5d, 0x2a, 0xc1, 0x88, 0x1, 0x0, 0x5, 0x13, 0x76, 0x8, 0x1, 0x39, 0x1, 0x0, 0x1e, 0x36, 0x27, 0x6, 0x7d, 0x70, 0x18, 0x90, 0x67, 0x93, 0x7e, 0xc8, 0xb6, 0x26, 0xad, 0xb0, 0x80, 0x25, 0x65, 0x76, 0x8e, 0xf, 0x54, 0xfe, 0x8a, 0x31, 0x68, 0x1f, 0xa9, 0xd2, 0x52, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xea, 0x79, 0x3c, 0xb0, 0x52, 0x20, 0x5d, 0x2a, 0xc1, 0x88}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x13, 0x76, 0x8, 0x1, 0x39}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x36, 0x27, 0x6, 0x7d, 0x70, 0x18, 0x90, 0x67, 0x93, 0x7e, 0xc8, 0xb6, 0x26, 0xad, 0xb0, 0x80, 0x25, 0x65, 0x76, 0x8e, 0xf, 0x54, 0xfe, 0x8a, 0x31, 0x68, 0x1f, 0xa9, 0xd2, 0x52}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; -lwmqtt_sub_options_t sub_opts[3]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x98, 0x1, 0x41, 0x97, 0x0, 0xe, 0x5c, 0x6, 0x81, 0x42, 0x31, 0x95, 0x59, 0x2f, 0x32, + 0xb2, 0x76, 0x78, 0x1e, 0x6f, 0x2, 0x0, 0x17, 0x9d, 0xaa, 0xf9, 0xde, 0x38, 0xf8, 0xb5, 0xbe, + 0xd4, 0x71, 0x97, 0x85, 0xba, 0xf5, 0xab, 0xdf, 0x67, 0x31, 0x29, 0x55, 0xce, 0x7, 0x87, 0x2, + 0x0, 0xd, 0x79, 0xf5, 0xf4, 0xe1, 0x4b, 0xb1, 0x5b, 0x99, 0x42, 0xb3, 0x40, 0xa1, 0xc1, 0x2, + 0x0, 0x13, 0x92, 0xf7, 0xd3, 0xb6, 0x48, 0x20, 0x7a, 0x8, 0x4b, 0xbf, 0x1e, 0xc2, 0x56, 0x86, + 0x38, 0x24, 0xdd, 0x3b, 0x38, 0x2, 0x0, 0x7, 0xa7, 0x9f, 0x57, 0xb9, 0x2d, 0x75, 0x3b, 0x0, + 0x0, 0xc, 0x58, 0xf6, 0xf7, 0xda, 0x47, 0xa2, 0x6d, 0x5a, 0x28, 0x7f, 0x19, 0xac, 0x1, 0x0, + 0xa, 0x98, 0x58, 0x39, 0xa6, 0xb1, 0x1e, 0xe2, 0xde, 0xd4, 0x80, 0x2, 0x0, 0x4, 0xec, 0x15, + 0xa9, 0xf5, 0x0, 0x0, 0x15, 0x40, 0x49, 0xd2, 0x18, 0xd2, 0x19, 0xc8, 0x1e, 0xba, 0x17, 0xeb, + 0xb4, 0x24, 0xb6, 0xa7, 0x9b, 0x8a, 0x87, 0x3e, 0x27, 0xf6, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x5c, 0x6, 0x81, 0x42, 0x31, 0x95, 0x59, 0x2f, 0x32, 0xb2, 0x76, 0x78, 0x1e, 0x6f}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x9d, 0xaa, 0xf9, 0xde, 0x38, 0xf8, 0xb5, 0xbe, 0xd4, 0x71, 0x97, 0x85, + 0xba, 0xf5, 0xab, 0xdf, 0x67, 0x31, 0x29, 0x55, 0xce, 0x7, 0x87}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x79, 0xf5, 0xf4, 0xe1, 0x4b, 0xb1, 0x5b, 0x99, 0x42, 0xb3, 0x40, 0xa1, 0xc1}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x92, 0xf7, 0xd3, 0xb6, 0x48, 0x20, 0x7a, 0x8, 0x4b, 0xbf, + 0x1e, 0xc2, 0x56, 0x86, 0x38, 0x24, 0xdd, 0x3b, 0x38}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa7, 0x9f, 0x57, 0xb9, 0x2d, 0x75, 0x3b}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x58, 0xf6, 0xf7, 0xda, 0x47, 0xa2, 0x6d, 0x5a, 0x28, 0x7f, 0x19, 0xac}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x98, 0x58, 0x39, 0xa6, 0xb1, 0x1e, 0xe2, 0xde, 0xd4, 0x80}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xec, 0x15, 0xa9, 0xf5}; + lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x40, 0x49, 0xd2, 0x18, 0xd2, 0x19, 0xc8, 0x1e, 0xba, 0x17, 0xeb, + 0xb4, 0x24, 0xb6, 0xa7, 0x9b, 0x8a, 0x87, 0x3e, 0x27, 0xf6}; + lwmqtt_string_t topic_filter_s8 = {21, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15465, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16791, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 31381 [("\230\234.\186\229\249Tuf\222\188\DC4 \193J\t\DLE}\156<\255\150\156\146\136\132\a",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\143\&6\250ODD\155\192\210\157\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\240ni\SUB}\189/\167\&4\ACK\213\129o\150",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 26959 [("O\ESCB(\149\146o\177\249\238&\152\222\148\225\208k<",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\163\ACK\208\ETX}\235\ESC\230\193\202s",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\140>8\177\CAN\US\187w\173\n~\"",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("AdT[\254[\152\249\SUBhe%e\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\201\230\EM\GS4\DC4\233BO]\165",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\245\148@\246iy\SUB\129\206D\233\DEL\225\131B}\239\133\177\140\196\193j\DC1\237",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\152\130\187",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\143\DC1\220\180\147#-\155\181y",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\235.\t\SOH\DC2\EM/vM\205b",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode13) { -uint8_t pkt[] = {0x82, 0x43, 0x28, 0x24, 0x0, 0x1e, 0x16, 0x90, 0xda, 0xe6, 0x6c, 0x9a, 0xd9, 0xdb, 0xe1, 0x10, 0x96, 0x6d, 0x8d, 0xc3, 0xde, 0xb7, 0x23, 0x4e, 0x11, 0xdb, 0x29, 0xe2, 0x7, 0xce, 0x79, 0xcc, 0x96, 0x1e, 0xd6, 0xb2, 0x0, 0x0, 0x1d, 0x52, 0xe5, 0xc3, 0xd0, 0xa8, 0xc7, 0x91, 0xce, 0x96, 0xca, 0x7c, 0x6c, 0xfb, 0x8b, 0x60, 0x5b, 0xa5, 0x40, 0x47, 0x4c, 0xf, 0xe5, 0xbf, 0x21, 0xb7, 0x73, 0x9, 0xb8, 0x99, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x16, 0x90, 0xda, 0xe6, 0x6c, 0x9a, 0xd9, 0xdb, 0xe1, 0x10, 0x96, 0x6d, 0x8d, 0xc3, 0xde, 0xb7, 0x23, 0x4e, 0x11, 0xdb, 0x29, 0xe2, 0x7, 0xce, 0x79, 0xcc, 0x96, 0x1e, 0xd6, 0xb2}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x52, 0xe5, 0xc3, 0xd0, 0xa8, 0xc7, 0x91, 0xce, 0x96, 0xca, 0x7c, 0x6c, 0xfb, 0x8b, 0x60, 0x5b, 0xa5, 0x40, 0x47, 0x4c, 0xf, 0xe5, 0xbf, 0x21, 0xb7, 0x73, 0x9, 0xb8, 0x99}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; -lwmqtt_sub_options_t sub_opts[2]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS0; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x5a, 0x48, 0x73, 0x0, 0x19, 0xbd, 0x4a, 0x91, 0x13, 0x79, 0xb7, 0xd8, 0xa4, 0x96, 0x81, + 0xee, 0x6c, 0xa8, 0x3b, 0x51, 0xd3, 0x2f, 0xfd, 0xd3, 0x87, 0x25, 0x90, 0x99, 0x5c, 0xa0, 0x2, + 0x0, 0x18, 0x8, 0x40, 0xac, 0x66, 0x2c, 0x3e, 0x81, 0xce, 0x44, 0xe9, 0x7f, 0xe1, 0x83, 0x42, + 0x7d, 0xef, 0x85, 0xb1, 0x8c, 0xc4, 0xc1, 0x6a, 0x11, 0xed, 0x0, 0x0, 0x3, 0x98, 0x82, 0xbb, + 0x0, 0x0, 0xa, 0x8f, 0x11, 0xdc, 0xb4, 0x93, 0x23, 0x2d, 0x9b, 0xb5, 0x79, 0x2, 0x0, 0xb, + 0xeb, 0x2e, 0x9, 0x1, 0x12, 0x19, 0x2f, 0x76, 0x4d, 0xcd, 0x62, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xbd, 0x4a, 0x91, 0x13, 0x79, 0xb7, 0xd8, 0xa4, 0x96, 0x81, 0xee, 0x6c, 0xa8, + 0x3b, 0x51, 0xd3, 0x2f, 0xfd, 0xd3, 0x87, 0x25, 0x90, 0x99, 0x5c, 0xa0}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x8, 0x40, 0xac, 0x66, 0x2c, 0x3e, 0x81, 0xce, 0x44, 0xe9, 0x7f, 0xe1, + 0x83, 0x42, 0x7d, 0xef, 0x85, 0xb1, 0x8c, 0xc4, 0xc1, 0x6a, 0x11, 0xed}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x98, 0x82, 0xbb}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8f, 0x11, 0xdc, 0xb4, 0x93, 0x23, 0x2d, 0x9b, 0xb5, 0x79}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xeb, 0x2e, 0x9, 0x1, 0x12, 0x19, 0x2f, 0x76, 0x4d, 0xcd, 0x62}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10276, 2, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18547, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 7750 [("\191\131\229\247n\DC4\170]A\183\163\132",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\209U\"`\185\222\252RC|G\202#\161P\240\SYN\DLE;@\172\251\188dV",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\188t\246J\ETX\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\154<\139\";}\250\187\&0pG\224\173\148\216\238#R\187\168\142\190",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("}\146\176\ncE\212\185:\132-\DLE9\ETB[r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("m\DC3\169\GSX\164\&5\158\RS\153\235W8\CANp",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\151\209",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("$U\214\224\143\199M\166v\143\&6\241\STX\DC2U\245\144\153\135n\161\146\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\247\ACK\228'\209\245\RS\\\148\ACK\254\187\255gl\215",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\229rp:\145\167\ACK\191\188\195\US\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 10474 [(",+{\129\233\223\145\247o8\195\202\SIEVN\152\206m\181$\172\204\250HR\169",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\170[\206)\DC4\217gT\220\238",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\194y\219\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode14) { -uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x1e, 0x46, 0x0, 0xc, 0xbf, 0x83, 0xe5, 0xf7, 0x6e, 0x14, 0xaa, 0x5d, 0x41, 0xb7, 0xa3, 0x84, 0x2, 0x0, 0x19, 0xd1, 0x55, 0x22, 0x60, 0xb9, 0xde, 0xfc, 0x52, 0x43, 0x7c, 0x47, 0xca, 0x23, 0xa1, 0x50, 0xf0, 0x16, 0x10, 0x3b, 0x40, 0xac, 0xfb, 0xbc, 0x64, 0x56, 0x1, 0x0, 0x6, 0xbc, 0x74, 0xf6, 0x4a, 0x3, 0xae, 0x1, 0x0, 0x16, 0x9a, 0x3c, 0x8b, 0x22, 0x3b, 0x7d, 0xfa, 0xbb, 0x30, 0x70, 0x47, 0xe0, 0xad, 0x94, 0xd8, 0xee, 0x23, 0x52, 0xbb, 0xa8, 0x8e, 0xbe, 0x2, 0x0, 0x10, 0x7d, 0x92, 0xb0, 0xa, 0x63, 0x45, 0xd4, 0xb9, 0x3a, 0x84, 0x2d, 0x10, 0x39, 0x17, 0x5b, 0x72, 0x2, 0x0, 0xf, 0x6d, 0x13, 0xa9, 0x1d, 0x58, 0xa4, 0x35, 0x9e, 0x1e, 0x99, 0xeb, 0x57, 0x38, 0x18, 0x70, 0x0, 0x0, 0x2, 0x97, 0xd1, 0x0, 0x0, 0x17, 0x24, 0x55, 0xd6, 0xe0, 0x8f, 0xc7, 0x4d, 0xa6, 0x76, 0x8f, 0x36, 0xf1, 0x2, 0x12, 0x55, 0xf5, 0x90, 0x99, 0x87, 0x6e, 0xa1, 0x92, 0x1, 0x2, 0x0, 0x10, 0xf7, 0x6, 0xe4, 0x27, 0xd1, 0xf5, 0x1e, 0x5c, 0x94, 0x6, 0xfe, 0xbb, 0xff, 0x67, 0x6c, 0xd7, 0x1, 0x0, 0xc, 0xe5, 0x72, 0x70, 0x3a, 0x91, 0xa7, 0x6, 0xbf, 0xbc, 0xc3, 0x1f, 0x5c, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xbf, 0x83, 0xe5, 0xf7, 0x6e, 0x14, 0xaa, 0x5d, 0x41, 0xb7, 0xa3, 0x84}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd1, 0x55, 0x22, 0x60, 0xb9, 0xde, 0xfc, 0x52, 0x43, 0x7c, 0x47, 0xca, 0x23, 0xa1, 0x50, 0xf0, 0x16, 0x10, 0x3b, 0x40, 0xac, 0xfb, 0xbc, 0x64, 0x56}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xbc, 0x74, 0xf6, 0x4a, 0x3, 0xae}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9a, 0x3c, 0x8b, 0x22, 0x3b, 0x7d, 0xfa, 0xbb, 0x30, 0x70, 0x47, 0xe0, 0xad, 0x94, 0xd8, 0xee, 0x23, 0x52, 0xbb, 0xa8, 0x8e, 0xbe}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7d, 0x92, 0xb0, 0xa, 0x63, 0x45, 0xd4, 0xb9, 0x3a, 0x84, 0x2d, 0x10, 0x39, 0x17, 0x5b, 0x72}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6d, 0x13, 0xa9, 0x1d, 0x58, 0xa4, 0x35, 0x9e, 0x1e, 0x99, 0xeb, 0x57, 0x38, 0x18, 0x70}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x97, 0xd1}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x24, 0x55, 0xd6, 0xe0, 0x8f, 0xc7, 0x4d, 0xa6, 0x76, 0x8f, 0x36, 0xf1, 0x2, 0x12, 0x55, 0xf5, 0x90, 0x99, 0x87, 0x6e, 0xa1, 0x92, 0x1}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xf7, 0x6, 0xe4, 0x27, 0xd1, 0xf5, 0x1e, 0x5c, 0x94, 0x6, 0xfe, 0xbb, 0xff, 0x67, 0x6c, 0xd7}; - lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe5, 0x72, 0x70, 0x3a, 0x91, 0xa7, 0x6, 0xbf, 0xbc, 0xc3, 0x1f, 0x5c}; - lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; -topic_filters[9] = topic_filter_s9; -lwmqtt_sub_options_t sub_opts[10]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS0; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS2; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = false; -sub_opts[8].qos = LWMQTT_QOS1; -sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[8].retain_as_published = false; -sub_opts[8].no_local = false; -sub_opts[9].qos = LWMQTT_QOS1; -sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[9].retain_as_published = false; -sub_opts[9].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x34, 0x28, 0xea, 0x0, 0x1b, 0x2c, 0x2b, 0x7b, 0x81, 0xe9, 0xdf, 0x91, 0xf7, + 0x6f, 0x38, 0xc3, 0xca, 0xf, 0x45, 0x56, 0x4e, 0x98, 0xce, 0x6d, 0xb5, 0x24, 0xac, + 0xcc, 0xfa, 0x48, 0x52, 0xa9, 0x0, 0x0, 0xa, 0xaa, 0x5b, 0xce, 0x29, 0x14, 0xd9, + 0x67, 0x54, 0xdc, 0xee, 0x2, 0x0, 0x4, 0xc2, 0x79, 0xdb, 0xb4, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x2c, 0x2b, 0x7b, 0x81, 0xe9, 0xdf, 0x91, 0xf7, 0x6f, 0x38, 0xc3, 0xca, 0xf, 0x45, + 0x56, 0x4e, 0x98, 0xce, 0x6d, 0xb5, 0x24, 0xac, 0xcc, 0xfa, 0x48, 0x52, 0xa9}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xaa, 0x5b, 0xce, 0x29, 0x14, 0xd9, 0x67, 0x54, 0xdc, 0xee}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc2, 0x79, 0xdb, 0xb4}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7750, 10, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10474, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 6922 [("\176\131\178\223z\196\&7\244P\255\198\182\182Y\250e&\173\215\129\SOH\185\nQ7\NULK\SOH*",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("Xv\191Qn\146\ACK\CAN\159\&1\251U\202\233B\r\158\234\237",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\142\196\245\228Y{#1\n\227\151\215>O\213\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("l\232\254\201\210\146\&9\138\199\199?\n`~(#\223\NUL\152\142\194\&0\227\213>",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\183Gl\161\243g%\128",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 20401 [("\210n-\209\154iPp\201\217l\192\SOHlY\242\n$\144@t",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("@T\180Z\153\"\b\RS8\223%\224\&5z\DC2`\170\NAK\179\224!\SI\153}\149O\252\199\182",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("P\EM \252RA1y\233=Q +// \206U\161\SUB\NULSCcv\153\&1n\132\135T\138N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\233\&2\236\152@\229Z\RS\247\249\142\241\147\181\234\al}\228\167\157",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("G\193\ETB\152\&84H\fg2\215\f\DC26\209\t\216xr\172\225>\246Es/_\201",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\SUB\164q\168\180\218\223\190\207RU\153\250\238+E\247\244\183\231\225",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\221\149A\211\195",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode15) { -uint8_t pkt[] = {0x82, 0x72, 0x1b, 0xa, 0x0, 0x1d, 0xb0, 0x83, 0xb2, 0xdf, 0x7a, 0xc4, 0x37, 0xf4, 0x50, 0xff, 0xc6, 0xb6, 0xb6, 0x59, 0xfa, 0x65, 0x26, 0xad, 0xd7, 0x81, 0x1, 0xb9, 0xa, 0x51, 0x37, 0x0, 0x4b, 0x1, 0x2a, 0x1, 0x0, 0x13, 0x58, 0x76, 0xbf, 0x51, 0x6e, 0x92, 0x6, 0x18, 0x9f, 0x31, 0xfb, 0x55, 0xca, 0xe9, 0x42, 0xd, 0x9e, 0xea, 0xed, 0x1, 0x0, 0x10, 0x8e, 0xc4, 0xf5, 0xe4, 0x59, 0x7b, 0x23, 0x31, 0xa, 0xe3, 0x97, 0xd7, 0x3e, 0x4f, 0xd5, 0x83, 0x1, 0x0, 0x19, 0x6c, 0xe8, 0xfe, 0xc9, 0xd2, 0x92, 0x39, 0x8a, 0xc7, 0xc7, 0x3f, 0xa, 0x60, 0x7e, 0x28, 0x23, 0xdf, 0x0, 0x98, 0x8e, 0xc2, 0x30, 0xe3, 0xd5, 0x3e, 0x2, 0x0, 0x8, 0xb7, 0x47, 0x6c, 0xa1, 0xf3, 0x67, 0x25, 0x80, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xb0, 0x83, 0xb2, 0xdf, 0x7a, 0xc4, 0x37, 0xf4, 0x50, 0xff, 0xc6, 0xb6, 0xb6, 0x59, 0xfa, 0x65, 0x26, 0xad, 0xd7, 0x81, 0x1, 0xb9, 0xa, 0x51, 0x37, 0x0, 0x4b, 0x1, 0x2a}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x58, 0x76, 0xbf, 0x51, 0x6e, 0x92, 0x6, 0x18, 0x9f, 0x31, 0xfb, 0x55, 0xca, 0xe9, 0x42, 0xd, 0x9e, 0xea, 0xed}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8e, 0xc4, 0xf5, 0xe4, 0x59, 0x7b, 0x23, 0x31, 0xa, 0xe3, 0x97, 0xd7, 0x3e, 0x4f, 0xd5, 0x83}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6c, 0xe8, 0xfe, 0xc9, 0xd2, 0x92, 0x39, 0x8a, 0xc7, 0xc7, 0x3f, 0xa, 0x60, 0x7e, 0x28, 0x23, 0xdf, 0x0, 0x98, 0x8e, 0xc2, 0x30, 0xe3, 0xd5, 0x3e}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb7, 0x47, 0x6c, 0xa1, 0xf3, 0x67, 0x25, 0x80}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; -lwmqtt_sub_options_t sub_opts[5]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS1; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0xb1, 0x1, 0x4f, 0xb1, 0x0, 0x15, 0xd2, 0x6e, 0x2d, 0xd1, 0x9a, 0x69, 0x50, 0x70, 0xc9, 0xd9, + 0x6c, 0xc0, 0x1, 0x6c, 0x59, 0xf2, 0xa, 0x24, 0x90, 0x40, 0x74, 0x1, 0x0, 0x1d, 0x40, 0x54, 0xb4, + 0x5a, 0x99, 0x22, 0x8, 0x1e, 0x38, 0xdf, 0x25, 0xe0, 0x35, 0x7a, 0x12, 0x60, 0xaa, 0x15, 0xb3, 0xe0, + 0x21, 0xf, 0x99, 0x7d, 0x95, 0x4f, 0xfc, 0xc7, 0xb6, 0x1, 0x0, 0x1d, 0x50, 0x19, 0x20, 0xfc, 0x52, + 0x41, 0x31, 0x79, 0xe9, 0x3d, 0x51, 0x20, 0xce, 0x55, 0xa1, 0x1a, 0x0, 0x53, 0x43, 0x63, 0x76, 0x99, + 0x31, 0x6e, 0x84, 0x87, 0x54, 0x8a, 0x4e, 0x0, 0x0, 0x15, 0xe9, 0x32, 0xec, 0x98, 0x40, 0xe5, 0x5a, + 0x1e, 0xf7, 0xf9, 0x8e, 0xf1, 0x93, 0xb5, 0xea, 0x7, 0x6c, 0x7d, 0xe4, 0xa7, 0x9d, 0x0, 0x0, 0x1c, + 0x47, 0xc1, 0x17, 0x98, 0x38, 0x34, 0x48, 0xc, 0x67, 0x32, 0xd7, 0xc, 0x12, 0x36, 0xd1, 0x9, 0xd8, + 0x78, 0x72, 0xac, 0xe1, 0x3e, 0xf6, 0x45, 0x73, 0x2f, 0x5f, 0xc9, 0x0, 0x0, 0x15, 0x1a, 0xa4, 0x71, + 0xa8, 0xb4, 0xda, 0xdf, 0xbe, 0xcf, 0x52, 0x55, 0x99, 0xfa, 0xee, 0x2b, 0x45, 0xf7, 0xf4, 0xb7, 0xe7, + 0xe1, 0x2, 0x0, 0x5, 0xdd, 0x95, 0x41, 0xd3, 0xc3, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xd2, 0x6e, 0x2d, 0xd1, 0x9a, 0x69, 0x50, 0x70, 0xc9, 0xd9, 0x6c, + 0xc0, 0x1, 0x6c, 0x59, 0xf2, 0xa, 0x24, 0x90, 0x40, 0x74}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x40, 0x54, 0xb4, 0x5a, 0x99, 0x22, 0x8, 0x1e, 0x38, 0xdf, + 0x25, 0xe0, 0x35, 0x7a, 0x12, 0x60, 0xaa, 0x15, 0xb3, 0xe0, + 0x21, 0xf, 0x99, 0x7d, 0x95, 0x4f, 0xfc, 0xc7, 0xb6}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x50, 0x19, 0x20, 0xfc, 0x52, 0x41, 0x31, 0x79, 0xe9, 0x3d, + 0x51, 0x20, 0xce, 0x55, 0xa1, 0x1a, 0x0, 0x53, 0x43, 0x63, + 0x76, 0x99, 0x31, 0x6e, 0x84, 0x87, 0x54, 0x8a, 0x4e}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe9, 0x32, 0xec, 0x98, 0x40, 0xe5, 0x5a, 0x1e, 0xf7, 0xf9, 0x8e, + 0xf1, 0x93, 0xb5, 0xea, 0x7, 0x6c, 0x7d, 0xe4, 0xa7, 0x9d}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x47, 0xc1, 0x17, 0x98, 0x38, 0x34, 0x48, 0xc, 0x67, 0x32, + 0xd7, 0xc, 0x12, 0x36, 0xd1, 0x9, 0xd8, 0x78, 0x72, 0xac, + 0xe1, 0x3e, 0xf6, 0x45, 0x73, 0x2f, 0x5f, 0xc9}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1a, 0xa4, 0x71, 0xa8, 0xb4, 0xda, 0xdf, 0xbe, 0xcf, 0x52, 0x55, + 0x99, 0xfa, 0xee, 0x2b, 0x45, 0xf7, 0xf4, 0xb7, 0xe7, 0xe1}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xdd, 0x95, 0x41, 0xd3, 0xc3}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6922, 5, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20401, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 26316 [("\229\199\211Bm\186\243W\161\139O{A ^F\180,!5y\243\EOT\166\226opy\131\ESC",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Z\153\&6\215(\215\EM\137\140\252",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("U\\N\255a\146",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\174\\\247w\175\SYN\148o\191E\n[\197\SO\197a\175\227\236",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\DC2\180\170\148L1[`@[\253\159,\136`\ESC\229\DEL5\210\193\ESC@\131\152\212",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\141\&8\227\131\152p\224\162\146\228\175V \142\191QR\139g\188\165vf",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("N\240`q\204\255|\b\156A\227\238",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 8563 [("\143\195\RS\DEL-\129\b/n _",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\152K\195\r\158\128&X\SUB\FSI\163y\128\203\171\SO\227\231K\213\SI&Y\211\EM",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode16) { -uint8_t pkt[] = {0x82, 0x98, 0x1, 0x66, 0xcc, 0x0, 0x1e, 0xe5, 0xc7, 0xd3, 0x42, 0x6d, 0xba, 0xf3, 0x57, 0xa1, 0x8b, 0x4f, 0x7b, 0x41, 0x20, 0x5e, 0x46, 0xb4, 0x2c, 0x21, 0x35, 0x79, 0xf3, 0x4, 0xa6, 0xe2, 0x6f, 0x70, 0x79, 0x83, 0x1b, 0x2, 0x0, 0xa, 0x5a, 0x99, 0x36, 0xd7, 0x28, 0xd7, 0x19, 0x89, 0x8c, 0xfc, 0x2, 0x0, 0x6, 0x55, 0x5c, 0x4e, 0xff, 0x61, 0x92, 0x0, 0x0, 0x13, 0xae, 0x5c, 0xf7, 0x77, 0xaf, 0x16, 0x94, 0x6f, 0xbf, 0x45, 0xa, 0x5b, 0xc5, 0xe, 0xc5, 0x61, 0xaf, 0xe3, 0xec, 0x1, 0x0, 0x1a, 0x12, 0xb4, 0xaa, 0x94, 0x4c, 0x31, 0x5b, 0x60, 0x40, 0x5b, 0xfd, 0x9f, 0x2c, 0x88, 0x60, 0x1b, 0xe5, 0x7f, 0x35, 0xd2, 0xc1, 0x1b, 0x40, 0x83, 0x98, 0xd4, 0x2, 0x0, 0x0, 0x0, 0x0, 0x17, 0x8d, 0x38, 0xe3, 0x83, 0x98, 0x70, 0xe0, 0xa2, 0x92, 0xe4, 0xaf, 0x56, 0x20, 0x8e, 0xbf, 0x51, 0x52, 0x8b, 0x67, 0xbc, 0xa5, 0x76, 0x66, 0x2, 0x0, 0xc, 0x4e, 0xf0, 0x60, 0x71, 0xcc, 0xff, 0x7c, 0x8, 0x9c, 0x41, 0xe3, 0xee, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xe5, 0xc7, 0xd3, 0x42, 0x6d, 0xba, 0xf3, 0x57, 0xa1, 0x8b, 0x4f, 0x7b, 0x41, 0x20, 0x5e, 0x46, 0xb4, 0x2c, 0x21, 0x35, 0x79, 0xf3, 0x4, 0xa6, 0xe2, 0x6f, 0x70, 0x79, 0x83, 0x1b}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5a, 0x99, 0x36, 0xd7, 0x28, 0xd7, 0x19, 0x89, 0x8c, 0xfc}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x55, 0x5c, 0x4e, 0xff, 0x61, 0x92}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xae, 0x5c, 0xf7, 0x77, 0xaf, 0x16, 0x94, 0x6f, 0xbf, 0x45, 0xa, 0x5b, 0xc5, 0xe, 0xc5, 0x61, 0xaf, 0xe3, 0xec}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x12, 0xb4, 0xaa, 0x94, 0x4c, 0x31, 0x5b, 0x60, 0x40, 0x5b, 0xfd, 0x9f, 0x2c, 0x88, 0x60, 0x1b, 0xe5, 0x7f, 0x35, 0xd2, 0xc1, 0x1b, 0x40, 0x83, 0x98, 0xd4}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8d, 0x38, 0xe3, 0x83, 0x98, 0x70, 0xe0, 0xa2, 0x92, 0xe4, 0xaf, 0x56, 0x20, 0x8e, 0xbf, 0x51, 0x52, 0x8b, 0x67, 0xbc, 0xa5, 0x76, 0x66}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x4e, 0xf0, 0x60, 0x71, 0xcc, 0xff, 0x7c, 0x8, 0x9c, 0x41, 0xe3, 0xee}; - lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; -lwmqtt_sub_options_t sub_opts[8]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS1; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS2; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS0; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x2d, 0x21, 0x73, 0x0, 0xb, 0x8f, 0xc3, 0x1e, 0x7f, 0x2d, 0x81, 0x8, 0x2f, 0x6e, 0x20, + 0x5f, 0x1, 0x0, 0x1a, 0x98, 0x4b, 0xc3, 0xd, 0x9e, 0x80, 0x26, 0x58, 0x1a, 0x1c, 0x49, 0xa3, + 0x79, 0x80, 0xcb, 0xab, 0xe, 0xe3, 0xe7, 0x4b, 0xd5, 0xf, 0x26, 0x59, 0xd3, 0x19, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x8f, 0xc3, 0x1e, 0x7f, 0x2d, 0x81, 0x8, 0x2f, 0x6e, 0x20, 0x5f}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x98, 0x4b, 0xc3, 0xd, 0x9e, 0x80, 0x26, 0x58, 0x1a, 0x1c, 0x49, 0xa3, 0x79, + 0x80, 0xcb, 0xab, 0xe, 0xe3, 0xe7, 0x4b, 0xd5, 0xf, 0x26, 0x59, 0xd3, 0x19}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26316, 8, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8563, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 3621 [("7\186\177\153l\246\228+]4\237O$\165\135q\230\DC3b\180\SI\194\248\ACK\t",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("+\SO\164",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\152\172d3k\243}\216\210y\232\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\208'\165Pi\\8\EOT*/\191\202\180A\237\164",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Z\152\229",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\227a\230",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\178\254\234\\\139\236\222\v\188\159\236\DLE\215\254\SO.\128\250\160\128",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 7682 [("\RS `P\209\153\210\225\236\187\202\241L\148\241X",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\ENQM\221\168\223",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\138\SYN\nG\DC3\GS\189\169\136\188\248~1A\160\133\254\212)\197\\",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("X\218\142\219\222C\214\142\ETX\209]-\202k\ESC\146h\161m\207",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\165\153\b\146/\NUL\131\v\215\&9=O\238-\235\DLEg\161@\SYN\ENQ\bZ\163\223\185z",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\201'\162\130h\150\158/\184\FS\131\156\251",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode17) { -uint8_t pkt[] = {0x82, 0x69, 0xe, 0x25, 0x0, 0x19, 0x37, 0xba, 0xb1, 0x99, 0x6c, 0xf6, 0xe4, 0x2b, 0x5d, 0x34, 0xed, 0x4f, 0x24, 0xa5, 0x87, 0x71, 0xe6, 0x13, 0x62, 0xb4, 0xf, 0xc2, 0xf8, 0x6, 0x9, 0x2, 0x0, 0x3, 0x2b, 0xe, 0xa4, 0x2, 0x0, 0xc, 0x98, 0xac, 0x64, 0x33, 0x6b, 0xf3, 0x7d, 0xd8, 0xd2, 0x79, 0xe8, 0x98, 0x1, 0x0, 0x10, 0xd0, 0x27, 0xa5, 0x50, 0x69, 0x5c, 0x38, 0x4, 0x2a, 0x2f, 0xbf, 0xca, 0xb4, 0x41, 0xed, 0xa4, 0x2, 0x0, 0x3, 0x5a, 0x98, 0xe5, 0x1, 0x0, 0x3, 0xe3, 0x61, 0xe6, 0x2, 0x0, 0x14, 0xb2, 0xfe, 0xea, 0x5c, 0x8b, 0xec, 0xde, 0xb, 0xbc, 0x9f, 0xec, 0x10, 0xd7, 0xfe, 0xe, 0x2e, 0x80, 0xfa, 0xa0, 0x80, 0x2}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x37, 0xba, 0xb1, 0x99, 0x6c, 0xf6, 0xe4, 0x2b, 0x5d, 0x34, 0xed, 0x4f, 0x24, 0xa5, 0x87, 0x71, 0xe6, 0x13, 0x62, 0xb4, 0xf, 0xc2, 0xf8, 0x6, 0x9}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2b, 0xe, 0xa4}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x98, 0xac, 0x64, 0x33, 0x6b, 0xf3, 0x7d, 0xd8, 0xd2, 0x79, 0xe8, 0x98}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd0, 0x27, 0xa5, 0x50, 0x69, 0x5c, 0x38, 0x4, 0x2a, 0x2f, 0xbf, 0xca, 0xb4, 0x41, 0xed, 0xa4}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5a, 0x98, 0xe5}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe3, 0x61, 0xe6}; - lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb2, 0xfe, 0xea, 0x5c, 0x8b, 0xec, 0xde, 0xb, 0xbc, 0x9f, 0xec, 0x10, 0xd7, 0xfe, 0xe, 0x2e, 0x80, 0xfa, 0xa0, 0x80}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; -lwmqtt_sub_options_t sub_opts[7]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS1; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS2; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS2; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x7a, 0x1e, 0x2, 0x0, 0x10, 0x1e, 0x20, 0x60, 0x50, 0xd1, 0x99, 0xd2, 0xe1, 0xec, 0xbb, + 0xca, 0xf1, 0x4c, 0x94, 0xf1, 0x58, 0x2, 0x0, 0x5, 0x5, 0x4d, 0xdd, 0xa8, 0xdf, 0x0, 0x0, + 0x15, 0x8a, 0x16, 0xa, 0x47, 0x13, 0x1d, 0xbd, 0xa9, 0x88, 0xbc, 0xf8, 0x7e, 0x31, 0x41, 0xa0, + 0x85, 0xfe, 0xd4, 0x29, 0xc5, 0x5c, 0x0, 0x0, 0x14, 0x58, 0xda, 0x8e, 0xdb, 0xde, 0x43, 0xd6, + 0x8e, 0x3, 0xd1, 0x5d, 0x2d, 0xca, 0x6b, 0x1b, 0x92, 0x68, 0xa1, 0x6d, 0xcf, 0x2, 0x0, 0x1b, + 0xa5, 0x99, 0x8, 0x92, 0x2f, 0x0, 0x83, 0xb, 0xd7, 0x39, 0x3d, 0x4f, 0xee, 0x2d, 0xeb, 0x10, + 0x67, 0xa1, 0x40, 0x16, 0x5, 0x8, 0x5a, 0xa3, 0xdf, 0xb9, 0x7a, 0x0, 0x0, 0xd, 0xc9, 0x27, + 0xa2, 0x82, 0x68, 0x96, 0x9e, 0x2f, 0xb8, 0x1c, 0x83, 0x9c, 0xfb, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x1e, 0x20, 0x60, 0x50, 0xd1, 0x99, 0xd2, 0xe1, + 0xec, 0xbb, 0xca, 0xf1, 0x4c, 0x94, 0xf1, 0x58}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x5, 0x4d, 0xdd, 0xa8, 0xdf}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x8a, 0x16, 0xa, 0x47, 0x13, 0x1d, 0xbd, 0xa9, 0x88, 0xbc, 0xf8, + 0x7e, 0x31, 0x41, 0xa0, 0x85, 0xfe, 0xd4, 0x29, 0xc5, 0x5c}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x58, 0xda, 0x8e, 0xdb, 0xde, 0x43, 0xd6, 0x8e, 0x3, 0xd1, + 0x5d, 0x2d, 0xca, 0x6b, 0x1b, 0x92, 0x68, 0xa1, 0x6d, 0xcf}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa5, 0x99, 0x8, 0x92, 0x2f, 0x0, 0x83, 0xb, 0xd7, 0x39, 0x3d, 0x4f, 0xee, 0x2d, + 0xeb, 0x10, 0x67, 0xa1, 0x40, 0x16, 0x5, 0x8, 0x5a, 0xa3, 0xdf, 0xb9, 0x7a}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xc9, 0x27, 0xa2, 0x82, 0x68, 0x96, 0x9e, 0x2f, 0xb8, 0x1c, 0x83, 0x9c, 0xfb}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3621, 7, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7682, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 17519 [("\237*\219:\226s\140\&8K \188\244l\243f\DC2|\184\193/\SYN\148\187\SOH\137\228:\ACK",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\223\254xc\242\211\169\140",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("4\144\223\145\225\223\164[Kn\246\237}J,z\141\238",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 9224 [("\199\229\146\190\EOT\224",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = +// QoS0}),("\238\163\ETB\179[\253\146N.\169\223$\202\251\ENQ\183\191\183`\165\135\152f-qP\201\189\SUB",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("f\133\252\176\189\165",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("ai\ETX\141\131P\247\191\147\143",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode18) { -uint8_t pkt[] = {0x82, 0x41, 0x44, 0x6f, 0x0, 0x1c, 0xed, 0x2a, 0xdb, 0x3a, 0xe2, 0x73, 0x8c, 0x38, 0x4b, 0x20, 0xbc, 0xf4, 0x6c, 0xf3, 0x66, 0x12, 0x7c, 0xb8, 0xc1, 0x2f, 0x16, 0x94, 0xbb, 0x1, 0x89, 0xe4, 0x3a, 0x6, 0x1, 0x0, 0x8, 0xdf, 0xfe, 0x78, 0x63, 0xf2, 0xd3, 0xa9, 0x8c, 0x2, 0x0, 0x12, 0x34, 0x90, 0xdf, 0x91, 0xe1, 0xdf, 0xa4, 0x5b, 0x4b, 0x6e, 0xf6, 0xed, 0x7d, 0x4a, 0x2c, 0x7a, 0x8d, 0xee, 0x2}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x2a, 0xdb, 0x3a, 0xe2, 0x73, 0x8c, 0x38, 0x4b, 0x20, 0xbc, 0xf4, 0x6c, 0xf3, 0x66, 0x12, 0x7c, 0xb8, 0xc1, 0x2f, 0x16, 0x94, 0xbb, 0x1, 0x89, 0xe4, 0x3a, 0x6}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xdf, 0xfe, 0x78, 0x63, 0xf2, 0xd3, 0xa9, 0x8c}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x34, 0x90, 0xdf, 0x91, 0xe1, 0xdf, 0xa4, 0x5b, 0x4b, 0x6e, 0xf6, 0xed, 0x7d, 0x4a, 0x2c, 0x7a, 0x8d, 0xee}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; -lwmqtt_sub_options_t sub_opts[3]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x41, 0x24, 0x8, 0x0, 0x6, 0xc7, 0xe5, 0x92, 0xbe, 0x4, 0xe0, 0x0, 0x0, 0x1d, 0xee, 0xa3, + 0x17, 0xb3, 0x5b, 0xfd, 0x92, 0x4e, 0x2e, 0xa9, 0xdf, 0x24, 0xca, 0xfb, 0x5, 0xb7, 0xbf, 0xb7, 0x60, + 0xa5, 0x87, 0x98, 0x66, 0x2d, 0x71, 0x50, 0xc9, 0xbd, 0x1a, 0x1, 0x0, 0x6, 0x66, 0x85, 0xfc, 0xb0, + 0xbd, 0xa5, 0x0, 0x0, 0xa, 0x61, 0x69, 0x3, 0x8d, 0x83, 0x50, 0xf7, 0xbf, 0x93, 0x8f, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xc7, 0xe5, 0x92, 0xbe, 0x4, 0xe0}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xee, 0xa3, 0x17, 0xb3, 0x5b, 0xfd, 0x92, 0x4e, 0x2e, 0xa9, + 0xdf, 0x24, 0xca, 0xfb, 0x5, 0xb7, 0xbf, 0xb7, 0x60, 0xa5, + 0x87, 0x98, 0x66, 0x2d, 0x71, 0x50, 0xc9, 0xbd, 0x1a}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x66, 0x85, 0xfc, 0xb0, 0xbd, 0xa5}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x61, 0x69, 0x3, 0x8d, 0x83, 0x50, 0xf7, 0xbf, 0x93, 0x8f}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17519, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9224, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 3152 [("\221jG\162A\208>\210\170r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\198\138\161\233\v\180\STX\241\207\221\150\234\128)\130\nF\209\ETX\GSVdb",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\148y\243\207\167\176HiA\209\148mB\219\169\138\169c\r\173b\150Q\247\153}\221F",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\243\171\216\165!\EOT,g\235G\164 2\206\211-\b-D\218",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 14508 [("R\USc\174\228\248\201\SYN\DC3\248\&2\191\130\SUB\146'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(":\200\140\238\238\173\241A\v\155\186\&9#m$\204\SUBe?Qr\214<3Q9O\214",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(" \139\195\231G\f\SOHqD*F\221%F\SYN\142\&7\207\252",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("@\217Q\249+\DLE\152\DLE\237\v\180[",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\207\SI\195\138W\141H2\157b?\147N\147# a%\239\181G\236[m\NULx",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\226>An\226G\185\FS",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\131\189l\133\133\tg\128\139\&9<\151y<\197o\204\221\132\&6\151\253\213\196\&3\221i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 24389 [("\255L)[J\CAN\t\240\&1\138\n",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\230\203\206\212\216\253-\EOT\b\248<",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode20) { -uint8_t pkt[] = {0x82, 0xbe, 0x1, 0x42, 0xf6, 0x0, 0x1e, 0x65, 0x30, 0xd3, 0xa, 0x28, 0x31, 0x7, 0x5b, 0x6d, 0xc0, 0xfa, 0x86, 0xb3, 0x52, 0x9c, 0x3a, 0x7f, 0xd9, 0x33, 0x8f, 0x5a, 0xe4, 0xba, 0xe0, 0x1f, 0x80, 0xa4, 0xc2, 0xa7, 0xdf, 0x2, 0x0, 0xe, 0xec, 0x5e, 0x3a, 0x16, 0x57, 0xf9, 0xb6, 0x37, 0x3e, 0xbf, 0x82, 0x1a, 0x92, 0x27, 0x0, 0x0, 0x1c, 0x3a, 0xc8, 0x8c, 0xee, 0xee, 0xad, 0xf1, 0x41, 0xb, 0x9b, 0xba, 0x39, 0x23, 0x6d, 0x24, 0xcc, 0x1a, 0x65, 0x3f, 0x51, 0x72, 0xd6, 0x3c, 0x33, 0x51, 0x39, 0x4f, 0xd6, 0x2, 0x0, 0x13, 0x20, 0x8b, 0xc3, 0xe7, 0x47, 0xc, 0x1, 0x71, 0x44, 0x2a, 0x46, 0xdd, 0x25, 0x46, 0x16, 0x8e, 0x37, 0xcf, 0xfc, 0x0, 0x0, 0xc, 0x40, 0xd9, 0x51, 0xf9, 0x2b, 0x10, 0x98, 0x10, 0xed, 0xb, 0xb4, 0x5b, 0x1, 0x0, 0x1a, 0xcf, 0xf, 0xc3, 0x8a, 0x57, 0x8d, 0x48, 0x32, 0x9d, 0x62, 0x3f, 0x93, 0x4e, 0x93, 0x23, 0x20, 0x61, 0x25, 0xef, 0xb5, 0x47, 0xec, 0x5b, 0x6d, 0x0, 0x78, 0x1, 0x0, 0x8, 0xe2, 0x3e, 0x41, 0x6e, 0xe2, 0x47, 0xb9, 0x1c, 0x0, 0x0, 0x1b, 0x83, 0xbd, 0x6c, 0x85, 0x85, 0x9, 0x67, 0x80, 0x8b, 0x39, 0x3c, 0x97, 0x79, 0x3c, 0xc5, 0x6f, 0xcc, 0xdd, 0x84, 0x36, 0x97, 0xfd, 0xd5, 0xc4, 0x33, 0xdd, 0x69, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x65, 0x30, 0xd3, 0xa, 0x28, 0x31, 0x7, 0x5b, 0x6d, 0xc0, 0xfa, 0x86, 0xb3, 0x52, 0x9c, 0x3a, 0x7f, 0xd9, 0x33, 0x8f, 0x5a, 0xe4, 0xba, 0xe0, 0x1f, 0x80, 0xa4, 0xc2, 0xa7, 0xdf}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xec, 0x5e, 0x3a, 0x16, 0x57, 0xf9, 0xb6, 0x37, 0x3e, 0xbf, 0x82, 0x1a, 0x92, 0x27}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x3a, 0xc8, 0x8c, 0xee, 0xee, 0xad, 0xf1, 0x41, 0xb, 0x9b, 0xba, 0x39, 0x23, 0x6d, 0x24, 0xcc, 0x1a, 0x65, 0x3f, 0x51, 0x72, 0xd6, 0x3c, 0x33, 0x51, 0x39, 0x4f, 0xd6}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x20, 0x8b, 0xc3, 0xe7, 0x47, 0xc, 0x1, 0x71, 0x44, 0x2a, 0x46, 0xdd, 0x25, 0x46, 0x16, 0x8e, 0x37, 0xcf, 0xfc}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x40, 0xd9, 0x51, 0xf9, 0x2b, 0x10, 0x98, 0x10, 0xed, 0xb, 0xb4, 0x5b}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xcf, 0xf, 0xc3, 0x8a, 0x57, 0x8d, 0x48, 0x32, 0x9d, 0x62, 0x3f, 0x93, 0x4e, 0x93, 0x23, 0x20, 0x61, 0x25, 0xef, 0xb5, 0x47, 0xec, 0x5b, 0x6d, 0x0, 0x78}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xe2, 0x3e, 0x41, 0x6e, 0xe2, 0x47, 0xb9, 0x1c}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x83, 0xbd, 0x6c, 0x85, 0x85, 0x9, 0x67, 0x80, 0x8b, 0x39, 0x3c, 0x97, 0x79, 0x3c, 0xc5, 0x6f, 0xcc, 0xdd, 0x84, 0x36, 0x97, 0xfd, 0xd5, 0xc4, 0x33, 0xdd, 0x69}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; -lwmqtt_sub_options_t sub_opts[8]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS0; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS0; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS1; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS1; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS0; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS1; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x1e, 0x5f, 0x45, 0x0, 0xb, 0xff, 0x4c, 0x29, 0x5b, 0x4a, 0x18, 0x9, 0xf0, 0x31, 0x8a, + 0xa, 0x0, 0x0, 0xb, 0xe6, 0xcb, 0xce, 0xd4, 0xd8, 0xfd, 0x2d, 0x4, 0x8, 0xf8, 0x3c, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xff, 0x4c, 0x29, 0x5b, 0x4a, 0x18, 0x9, 0xf0, 0x31, 0x8a, 0xa}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xe6, 0xcb, 0xce, 0xd4, 0xd8, 0xfd, 0x2d, 0x4, 0x8, 0xf8, 0x3c}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17142, 8, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24389, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 12736 [("\145r:&\180\185\191_\191\EOT\159&\193$\205",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\188'\DEL\156\SOV\198\162e\166U0\163\197\181\t\230\&9z\213\135=I",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("fp bI\176\162\r\137\188\NUL\247\ETXy\143s\221q\232\153ff\RS\ESC",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\240\180\DC4+'\SOHP\138y\131!=Z\134\SO2+\169\ETB*",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\201-r-|\180\149qF\242?\234\163\191|m#q\150\CANB\189",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("a)(\167\186\SOH\206\180\ETB\151\150\136hl\212l\187t.\160\189n\165{",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\198\158\243\SYNL\SI\160e\196Y\225\249\234\200\237\136\225\255l\240\tH\250\170\235\223",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(",`6V\143_\180\169\246\186\185\141\138\NAK\ACKIq\130\173?",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\b4\247",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 10907 [("A\162\160\180\204w=\RSRuY\179\226\193\241M\SI_\205\144\150\163\229E\232\a\173",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("I?\215\128q+\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\156\203A\181",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = +// QoS1}),("f,u\248\196\253Ec\136\146a\182D\192\SO\206\128\EMS\198~\227\179\225\&5\190\200",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\160\250\NAK\133R\172\224\SUB*\176\204\145",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode21) { -uint8_t pkt[] = {0x82, 0xce, 0x1, 0x31, 0xc0, 0x0, 0xf, 0x91, 0x72, 0x3a, 0x26, 0xb4, 0xb9, 0xbf, 0x5f, 0xbf, 0x4, 0x9f, 0x26, 0xc1, 0x24, 0xcd, 0x2, 0x0, 0x17, 0xbc, 0x27, 0x7f, 0x9c, 0xe, 0x56, 0xc6, 0xa2, 0x65, 0xa6, 0x55, 0x30, 0xa3, 0xc5, 0xb5, 0x9, 0xe6, 0x39, 0x7a, 0xd5, 0x87, 0x3d, 0x49, 0x0, 0x0, 0x18, 0x66, 0x70, 0x20, 0x62, 0x49, 0xb0, 0xa2, 0xd, 0x89, 0xbc, 0x0, 0xf7, 0x3, 0x79, 0x8f, 0x73, 0xdd, 0x71, 0xe8, 0x99, 0x66, 0x66, 0x1e, 0x1b, 0x1, 0x0, 0x14, 0xf0, 0xb4, 0x14, 0x2b, 0x27, 0x1, 0x50, 0x8a, 0x79, 0x83, 0x21, 0x3d, 0x5a, 0x86, 0xe, 0x32, 0x2b, 0xa9, 0x17, 0x2a, 0x1, 0x0, 0x16, 0xc9, 0x2d, 0x72, 0x2d, 0x7c, 0xb4, 0x95, 0x71, 0x46, 0xf2, 0x3f, 0xea, 0xa3, 0xbf, 0x7c, 0x6d, 0x23, 0x71, 0x96, 0x18, 0x42, 0xbd, 0x1, 0x0, 0x18, 0x61, 0x29, 0x28, 0xa7, 0xba, 0x1, 0xce, 0xb4, 0x17, 0x97, 0x96, 0x88, 0x68, 0x6c, 0xd4, 0x6c, 0xbb, 0x74, 0x2e, 0xa0, 0xbd, 0x6e, 0xa5, 0x7b, 0x1, 0x0, 0x1a, 0xc6, 0x9e, 0xf3, 0x16, 0x4c, 0xf, 0xa0, 0x65, 0xc4, 0x59, 0xe1, 0xf9, 0xea, 0xc8, 0xed, 0x88, 0xe1, 0xff, 0x6c, 0xf0, 0x9, 0x48, 0xfa, 0xaa, 0xeb, 0xdf, 0x2, 0x0, 0x14, 0x2c, 0x60, 0x36, 0x56, 0x8f, 0x5f, 0xb4, 0xa9, 0xf6, 0xba, 0xb9, 0x8d, 0x8a, 0x15, 0x6, 0x49, 0x71, 0x82, 0xad, 0x3f, 0x2, 0x0, 0x3, 0x8, 0x34, 0xf7, 0x2}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x91, 0x72, 0x3a, 0x26, 0xb4, 0xb9, 0xbf, 0x5f, 0xbf, 0x4, 0x9f, 0x26, 0xc1, 0x24, 0xcd}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbc, 0x27, 0x7f, 0x9c, 0xe, 0x56, 0xc6, 0xa2, 0x65, 0xa6, 0x55, 0x30, 0xa3, 0xc5, 0xb5, 0x9, 0xe6, 0x39, 0x7a, 0xd5, 0x87, 0x3d, 0x49}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x66, 0x70, 0x20, 0x62, 0x49, 0xb0, 0xa2, 0xd, 0x89, 0xbc, 0x0, 0xf7, 0x3, 0x79, 0x8f, 0x73, 0xdd, 0x71, 0xe8, 0x99, 0x66, 0x66, 0x1e, 0x1b}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf0, 0xb4, 0x14, 0x2b, 0x27, 0x1, 0x50, 0x8a, 0x79, 0x83, 0x21, 0x3d, 0x5a, 0x86, 0xe, 0x32, 0x2b, 0xa9, 0x17, 0x2a}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc9, 0x2d, 0x72, 0x2d, 0x7c, 0xb4, 0x95, 0x71, 0x46, 0xf2, 0x3f, 0xea, 0xa3, 0xbf, 0x7c, 0x6d, 0x23, 0x71, 0x96, 0x18, 0x42, 0xbd}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x61, 0x29, 0x28, 0xa7, 0xba, 0x1, 0xce, 0xb4, 0x17, 0x97, 0x96, 0x88, 0x68, 0x6c, 0xd4, 0x6c, 0xbb, 0x74, 0x2e, 0xa0, 0xbd, 0x6e, 0xa5, 0x7b}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc6, 0x9e, 0xf3, 0x16, 0x4c, 0xf, 0xa0, 0x65, 0xc4, 0x59, 0xe1, 0xf9, 0xea, 0xc8, 0xed, 0x88, 0xe1, 0xff, 0x6c, 0xf0, 0x9, 0x48, 0xfa, 0xaa, 0xeb, 0xdf}; - lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x2c, 0x60, 0x36, 0x56, 0x8f, 0x5f, 0xb4, 0xa9, 0xf6, 0xba, 0xb9, 0x8d, 0x8a, 0x15, 0x6, 0x49, 0x71, 0x82, 0xad, 0x3f}; - lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x8, 0x34, 0xf7}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; -lwmqtt_sub_options_t sub_opts[9]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS0; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS1; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS1; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS1; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS2; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS2; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = false; -sub_opts[8].qos = LWMQTT_QOS2; -sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[8].retain_as_published = false; -sub_opts[8].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x5e, 0x2a, 0x9b, 0x0, 0x1b, 0x41, 0xa2, 0xa0, 0xb4, 0xcc, 0x77, 0x3d, 0x1e, 0x52, 0x75, + 0x59, 0xb3, 0xe2, 0xc1, 0xf1, 0x4d, 0xf, 0x5f, 0xcd, 0x90, 0x96, 0xa3, 0xe5, 0x45, 0xe8, 0x7, + 0xad, 0x2, 0x0, 0x7, 0x49, 0x3f, 0xd7, 0x80, 0x71, 0x2b, 0xd2, 0x1, 0x0, 0x4, 0x9c, 0xcb, + 0x41, 0xb5, 0x1, 0x0, 0x1b, 0x66, 0x2c, 0x75, 0xf8, 0xc4, 0xfd, 0x45, 0x63, 0x88, 0x92, 0x61, + 0xb6, 0x44, 0xc0, 0xe, 0xce, 0x80, 0x19, 0x53, 0xc6, 0x7e, 0xe3, 0xb3, 0xe1, 0x35, 0xbe, 0xc8, + 0x0, 0x0, 0xc, 0xa0, 0xfa, 0x15, 0x85, 0x52, 0xac, 0xe0, 0x1a, 0x2a, 0xb0, 0xcc, 0x91, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x41, 0xa2, 0xa0, 0xb4, 0xcc, 0x77, 0x3d, 0x1e, 0x52, 0x75, 0x59, 0xb3, 0xe2, 0xc1, + 0xf1, 0x4d, 0xf, 0x5f, 0xcd, 0x90, 0x96, 0xa3, 0xe5, 0x45, 0xe8, 0x7, 0xad}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x49, 0x3f, 0xd7, 0x80, 0x71, 0x2b, 0xd2}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x9c, 0xcb, 0x41, 0xb5}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x66, 0x2c, 0x75, 0xf8, 0xc4, 0xfd, 0x45, 0x63, 0x88, 0x92, 0x61, 0xb6, 0x44, 0xc0, + 0xe, 0xce, 0x80, 0x19, 0x53, 0xc6, 0x7e, 0xe3, 0xb3, 0xe1, 0x35, 0xbe, 0xc8}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa0, 0xfa, 0x15, 0x85, 0x52, 0xac, 0xe0, 0x1a, 0x2a, 0xb0, 0xcc, 0x91}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12736, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10907, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 26425 [("\145\NAK7\199",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\GSs0\DC1\171V\137\&9\159w\132\ESC\169\234\155\213",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\\\142Z\247\242sCn\US\191q!\148^!i\196\133\n\205\140Ar\136\133",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\235e\220\167>\DLE*\133\128\145\180\DC3t\129\&8",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\218\188\137$}\EOT4\238\239\232|~\185\169R\141\196\189R\151",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\173\US{0hp\194\172Up\210?\133\204\227\&0\160\137\183\158\212\217z\228\208\130\164\213\ACK\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\217\199\165J\206\133\254\160,k\ETB\144\186\EOT\ETXKN=\160\SYN\200K\f\208\155%\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\DEL\210\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\211\225\228\234\188g\203A\222\NUL!\191\194\&0\194\&0\144@(A\232\&8\176N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 19202 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\233$]\137\\\203f\234\199\ESC1+\152\242\NULM",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("1\194\146\170\EM\r|!\171\192\142\CAN\203<\165p\EMg\236\CAN\174x:\235\165\US\196,\129",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\170\170\208h\229\130\bc\245#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("0\218\159\251\186A\250w\ETX\DC4Ni\223Dpd\238-\139\t\134x\DC2\148v",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\180\201\201.\222",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode22) { -uint8_t pkt[] = {0x82, 0xc1, 0x1, 0x67, 0x39, 0x0, 0x4, 0x91, 0x15, 0x37, 0xc7, 0x1, 0x0, 0x10, 0x1d, 0x73, 0x30, 0x11, 0xab, 0x56, 0x89, 0x39, 0x9f, 0x77, 0x84, 0x1b, 0xa9, 0xea, 0x9b, 0xd5, 0x2, 0x0, 0x19, 0x5c, 0x8e, 0x5a, 0xf7, 0xf2, 0x73, 0x43, 0x6e, 0x1f, 0xbf, 0x71, 0x21, 0x94, 0x5e, 0x21, 0x69, 0xc4, 0x85, 0xa, 0xcd, 0x8c, 0x41, 0x72, 0x88, 0x85, 0x0, 0x0, 0xf, 0xeb, 0x65, 0xdc, 0xa7, 0x3e, 0x10, 0x2a, 0x85, 0x80, 0x91, 0xb4, 0x13, 0x74, 0x81, 0x38, 0x1, 0x0, 0x14, 0xda, 0xbc, 0x89, 0x24, 0x7d, 0x4, 0x34, 0xee, 0xef, 0xe8, 0x7c, 0x7e, 0xb9, 0xa9, 0x52, 0x8d, 0xc4, 0xbd, 0x52, 0x97, 0x0, 0x0, 0x1e, 0xad, 0x1f, 0x7b, 0x30, 0x68, 0x70, 0xc2, 0xac, 0x55, 0x70, 0xd2, 0x3f, 0x85, 0xcc, 0xe3, 0x30, 0xa0, 0x89, 0xb7, 0x9e, 0xd4, 0xd9, 0x7a, 0xe4, 0xd0, 0x82, 0xa4, 0xd5, 0x6, 0xd2, 0x0, 0x0, 0x1b, 0xd9, 0xc7, 0xa5, 0x4a, 0xce, 0x85, 0xfe, 0xa0, 0x2c, 0x6b, 0x17, 0x90, 0xba, 0x4, 0x3, 0x4b, 0x4e, 0x3d, 0xa0, 0x16, 0xc8, 0x4b, 0xc, 0xd0, 0x9b, 0x25, 0xb4, 0x1, 0x0, 0x3, 0x7f, 0xd2, 0xba, 0x2, 0x0, 0x18, 0xd3, 0xe1, 0xe4, 0xea, 0xbc, 0x67, 0xcb, 0x41, 0xde, 0x0, 0x21, 0xbf, 0xc2, 0x30, 0xc2, 0x30, 0x90, 0x40, 0x28, 0x41, 0xe8, 0x38, 0xb0, 0x4e, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x91, 0x15, 0x37, 0xc7}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1d, 0x73, 0x30, 0x11, 0xab, 0x56, 0x89, 0x39, 0x9f, 0x77, 0x84, 0x1b, 0xa9, 0xea, 0x9b, 0xd5}; + uint8_t pkt[] = {0x82, 0x69, 0x4b, 0x2, 0x0, 0x0, 0x1, 0x0, 0x10, 0xe9, 0x24, 0x5d, 0x89, 0x5c, 0xcb, 0x66, + 0xea, 0xc7, 0x1b, 0x31, 0x2b, 0x98, 0xf2, 0x0, 0x4d, 0x0, 0x0, 0x1d, 0x31, 0xc2, 0x92, 0xaa, + 0x19, 0xd, 0x7c, 0x21, 0xab, 0xc0, 0x8e, 0x18, 0xcb, 0x3c, 0xa5, 0x70, 0x19, 0x67, 0xec, 0x18, + 0xae, 0x78, 0x3a, 0xeb, 0xa5, 0x1f, 0xc4, 0x2c, 0x81, 0x0, 0x0, 0xa, 0xaa, 0xaa, 0xd0, 0x68, + 0xe5, 0x82, 0x8, 0x63, 0xf5, 0x23, 0x1, 0x0, 0x19, 0x30, 0xda, 0x9f, 0xfb, 0xba, 0x41, 0xfa, + 0x77, 0x3, 0x14, 0x4e, 0x69, 0xdf, 0x44, 0x70, 0x64, 0xee, 0x2d, 0x8b, 0x9, 0x86, 0x78, 0x12, + 0x94, 0x76, 0x1, 0x0, 0x5, 0xb4, 0xc9, 0xc9, 0x2e, 0xde, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xe9, 0x24, 0x5d, 0x89, 0x5c, 0xcb, 0x66, 0xea, + 0xc7, 0x1b, 0x31, 0x2b, 0x98, 0xf2, 0x0, 0x4d}; lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5c, 0x8e, 0x5a, 0xf7, 0xf2, 0x73, 0x43, 0x6e, 0x1f, 0xbf, 0x71, 0x21, 0x94, 0x5e, 0x21, 0x69, 0xc4, 0x85, 0xa, 0xcd, 0x8c, 0x41, 0x72, 0x88, 0x85}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xeb, 0x65, 0xdc, 0xa7, 0x3e, 0x10, 0x2a, 0x85, 0x80, 0x91, 0xb4, 0x13, 0x74, 0x81, 0x38}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xda, 0xbc, 0x89, 0x24, 0x7d, 0x4, 0x34, 0xee, 0xef, 0xe8, 0x7c, 0x7e, 0xb9, 0xa9, 0x52, 0x8d, 0xc4, 0xbd, 0x52, 0x97}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xad, 0x1f, 0x7b, 0x30, 0x68, 0x70, 0xc2, 0xac, 0x55, 0x70, 0xd2, 0x3f, 0x85, 0xcc, 0xe3, 0x30, 0xa0, 0x89, 0xb7, 0x9e, 0xd4, 0xd9, 0x7a, 0xe4, 0xd0, 0x82, 0xa4, 0xd5, 0x6, 0xd2}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xd9, 0xc7, 0xa5, 0x4a, 0xce, 0x85, 0xfe, 0xa0, 0x2c, 0x6b, 0x17, 0x90, 0xba, 0x4, 0x3, 0x4b, 0x4e, 0x3d, 0xa0, 0x16, 0xc8, 0x4b, 0xc, 0xd0, 0x9b, 0x25, 0xb4}; - lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7f, 0xd2, 0xba}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd3, 0xe1, 0xe4, 0xea, 0xbc, 0x67, 0xcb, 0x41, 0xde, 0x0, 0x21, 0xbf, 0xc2, 0x30, 0xc2, 0x30, 0x90, 0x40, 0x28, 0x41, 0xe8, 0x38, 0xb0, 0x4e}; - lwmqtt_string_t topic_filter_s8 = {24, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; -lwmqtt_sub_options_t sub_opts[9]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS1; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS0; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS1; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS2; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = false; -sub_opts[8].qos = LWMQTT_QOS1; -sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[8].retain_as_published = false; -sub_opts[8].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x31, 0xc2, 0x92, 0xaa, 0x19, 0xd, 0x7c, 0x21, 0xab, 0xc0, + 0x8e, 0x18, 0xcb, 0x3c, 0xa5, 0x70, 0x19, 0x67, 0xec, 0x18, + 0xae, 0x78, 0x3a, 0xeb, 0xa5, 0x1f, 0xc4, 0x2c, 0x81}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xaa, 0xaa, 0xd0, 0x68, 0xe5, 0x82, 0x8, 0x63, 0xf5, 0x23}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x30, 0xda, 0x9f, 0xfb, 0xba, 0x41, 0xfa, 0x77, 0x3, 0x14, 0x4e, 0x69, 0xdf, + 0x44, 0x70, 0x64, 0xee, 0x2d, 0x8b, 0x9, 0x86, 0x78, 0x12, 0x94, 0x76}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb4, 0xc9, 0xc9, 0x2e, 0xde}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26425, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19202, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 17320 [("\144\175\&0\194y\215$\SO\US",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\140\252\NAKZ\ENQ\201\234\204\151\235\251\198\234\190\DC2\NULi\211\201",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 4671 [("osy",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\210HT\163\DC2\139\243O\224\246\242h\152\192\152y\186",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\180Q\187",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("'\191s\156\EM\188\210\SOH\148\186\141\154{\206\STXwV\233\188+",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\149\r:\181V\203\NAK0\179\229",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("Re\176\RS\251\223S\255\200\190\180+\217!p",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("w\n\174\187\236vy\169\166\185\&1\149\SOH\250\131\152\204\US\128U\144\DC2\174",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\200\193\194\&8\241p\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode24) { -uint8_t pkt[] = {0x82, 0x99, 0x1, 0x24, 0x85, 0x0, 0x2, 0x44, 0xa1, 0x0, 0x0, 0x1a, 0x93, 0x1d, 0x8c, 0xdd, 0xc2, 0xf9, 0x32, 0x48, 0x24, 0xa0, 0x39, 0x5a, 0xf7, 0xc9, 0x37, 0xeb, 0x85, 0xd2, 0x4d, 0x7b, 0x72, 0x92, 0x75, 0x4a, 0x59, 0x1b, 0x1, 0x0, 0xd, 0xea, 0xd8, 0xc5, 0x92, 0x2d, 0x2e, 0x3a, 0x7c, 0x23, 0xba, 0x1a, 0x7d, 0x86, 0x2, 0x0, 0x0, 0x2, 0x0, 0xf, 0x5d, 0x2f, 0x2e, 0xd0, 0x4, 0xc3, 0xe0, 0x49, 0x67, 0xee, 0x78, 0xdb, 0xfe, 0x20, 0xb2, 0x2, 0x0, 0xc, 0xa8, 0xe8, 0x15, 0x89, 0xe7, 0xe6, 0x7d, 0x7e, 0xb2, 0x5d, 0x36, 0xf6, 0x2, 0x0, 0x12, 0x56, 0x81, 0x66, 0x29, 0xce, 0x59, 0x8, 0xd8, 0xde, 0xdf, 0x2a, 0x84, 0x6b, 0xc1, 0xa3, 0xd5, 0x32, 0x29, 0x0, 0x0, 0x13, 0xf9, 0xc9, 0x19, 0x78, 0xe9, 0xd0, 0xc5, 0x2a, 0xe4, 0x95, 0xb3, 0xd5, 0x9e, 0x2c, 0xa6, 0x71, 0xfd, 0x3e, 0x1f, 0x2, 0x0, 0x13, 0x8c, 0xfc, 0x15, 0x5a, 0x5, 0xc9, 0xea, 0xcc, 0x97, 0xeb, 0xfb, 0xc6, 0xea, 0xbe, 0x12, 0x0, 0x69, 0xd3, 0xc9, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x44, 0xa1}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x93, 0x1d, 0x8c, 0xdd, 0xc2, 0xf9, 0x32, 0x48, 0x24, 0xa0, 0x39, 0x5a, 0xf7, 0xc9, 0x37, 0xeb, 0x85, 0xd2, 0x4d, 0x7b, 0x72, 0x92, 0x75, 0x4a, 0x59, 0x1b}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xea, 0xd8, 0xc5, 0x92, 0x2d, 0x2e, 0x3a, 0x7c, 0x23, 0xba, 0x1a, 0x7d, 0x86}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; + uint8_t pkt[] = {0x82, 0x7f, 0x12, 0x3f, 0x0, 0x3, 0x6f, 0x73, 0x79, 0x2, 0x0, 0x11, 0xd2, 0x48, 0x54, 0xa3, 0x12, + 0x8b, 0xf3, 0x4f, 0xe0, 0xf6, 0xf2, 0x68, 0x98, 0xc0, 0x98, 0x79, 0xba, 0x1, 0x0, 0x3, 0xb4, 0x51, + 0xbb, 0x2, 0x0, 0x0, 0x2, 0x0, 0x14, 0x27, 0xbf, 0x73, 0x9c, 0x19, 0xbc, 0xd2, 0x1, 0x94, 0xba, + 0x8d, 0x9a, 0x7b, 0xce, 0x2, 0x77, 0x56, 0xe9, 0xbc, 0x2b, 0x0, 0x0, 0xa, 0x95, 0xd, 0x3a, 0xb5, + 0x56, 0xcb, 0x15, 0x30, 0xb3, 0xe5, 0x2, 0x0, 0xf, 0x52, 0x65, 0xb0, 0x1e, 0xfb, 0xdf, 0x53, 0xff, + 0xc8, 0xbe, 0xb4, 0x2b, 0xd9, 0x21, 0x70, 0x2, 0x0, 0x17, 0x77, 0xa, 0xae, 0xbb, 0xec, 0x76, 0x79, + 0xa9, 0xa6, 0xb9, 0x31, 0x95, 0x1, 0xfa, 0x83, 0x98, 0xcc, 0x1f, 0x80, 0x55, 0x90, 0x12, 0xae, 0x2, + 0x0, 0x7, 0xc8, 0xc1, 0xc2, 0x38, 0xf1, 0x70, 0xa6, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x6f, 0x73, 0x79}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd2, 0x48, 0x54, 0xa3, 0x12, 0x8b, 0xf3, 0x4f, 0xe0, + 0xf6, 0xf2, 0x68, 0x98, 0xc0, 0x98, 0x79, 0xba}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb4, 0x51, 0xbb}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; uint8_t topic_filter_s3_bytes[] = {0}; lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5d, 0x2f, 0x2e, 0xd0, 0x4, 0xc3, 0xe0, 0x49, 0x67, 0xee, 0x78, 0xdb, 0xfe, 0x20, 0xb2}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa8, 0xe8, 0x15, 0x89, 0xe7, 0xe6, 0x7d, 0x7e, 0xb2, 0x5d, 0x36, 0xf6}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x56, 0x81, 0x66, 0x29, 0xce, 0x59, 0x8, 0xd8, 0xde, 0xdf, 0x2a, 0x84, 0x6b, 0xc1, 0xa3, 0xd5, 0x32, 0x29}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf9, 0xc9, 0x19, 0x78, 0xe9, 0xd0, 0xc5, 0x2a, 0xe4, 0x95, 0xb3, 0xd5, 0x9e, 0x2c, 0xa6, 0x71, 0xfd, 0x3e, 0x1f}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x8c, 0xfc, 0x15, 0x5a, 0x5, 0xc9, 0xea, 0xcc, 0x97, 0xeb, 0xfb, 0xc6, 0xea, 0xbe, 0x12, 0x0, 0x69, 0xd3, 0xc9}; - lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; -lwmqtt_sub_options_t sub_opts[9]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS2; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS0; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS2; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = false; -sub_opts[8].qos = LWMQTT_QOS1; -sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[8].retain_as_published = false; -sub_opts[8].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x27, 0xbf, 0x73, 0x9c, 0x19, 0xbc, 0xd2, 0x1, 0x94, 0xba, + 0x8d, 0x9a, 0x7b, 0xce, 0x2, 0x77, 0x56, 0xe9, 0xbc, 0x2b}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x95, 0xd, 0x3a, 0xb5, 0x56, 0xcb, 0x15, 0x30, 0xb3, 0xe5}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x52, 0x65, 0xb0, 0x1e, 0xfb, 0xdf, 0x53, 0xff, + 0xc8, 0xbe, 0xb4, 0x2b, 0xd9, 0x21, 0x70}; + lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x77, 0xa, 0xae, 0xbb, 0xec, 0x76, 0x79, 0xa9, 0xa6, 0xb9, 0x31, 0x95, + 0x1, 0xfa, 0x83, 0x98, 0xcc, 0x1f, 0x80, 0x55, 0x90, 0x12, 0xae}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xc8, 0xc1, 0xc2, 0x38, 0xf1, 0x70, 0xa6}; + lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9349, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4671, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 26963 [("\222\194M\DEL\152\197,\190??\b\237\DELK\244.\212\133\159\247{\238\US7[\151\DC1",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\171\141\177\173\n\EM\129,\143\DC4\167\162\191<,",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("{\146\138\133s9`\172\155`\205#\CAN\160\193h\188\DC3K\205\253<\255g\DC4c\246",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("'\170\221]\SIq\189\192\ESCH\r5\163\154D",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 22250 [("\186\185\130\168\166",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\155\157\SYN\229\227\209\&4\SOH|\242\168\253\129xF\166\\\"BG\191\246\215",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\182\&7\250\251\141.\181\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\134&\251\172\216\150}\237\b\142\246",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\197\235",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("K\195})\202\&1'\218\169\SOH\200g\252\235R\225\201\b&@\v Y~\144x\232",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\163\249Y`\207\ETB\EOTf\n\159!l\SUB2hs\162\149\186\250?\a\220\237\200",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\177\128;f\163y\182\222\185\r\SYN\US-y#\168\SO\190Cu\SO\r\143~y\254\vi\163X",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\236Fm\234\247v&5\249\208\&0\FS",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("b",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode25) { -uint8_t pkt[] = {0x82, 0x66, 0x69, 0x53, 0x0, 0x1b, 0xde, 0xc2, 0x4d, 0x7f, 0x98, 0xc5, 0x2c, 0xbe, 0x3f, 0x3f, 0x8, 0xed, 0x7f, 0x4b, 0xf4, 0x2e, 0xd4, 0x85, 0x9f, 0xf7, 0x7b, 0xee, 0x1f, 0x37, 0x5b, 0x97, 0x11, 0x2, 0x0, 0xf, 0xab, 0x8d, 0xb1, 0xad, 0xa, 0x19, 0x81, 0x2c, 0x8f, 0x14, 0xa7, 0xa2, 0xbf, 0x3c, 0x2c, 0x2, 0x0, 0x1b, 0x7b, 0x92, 0x8a, 0x85, 0x73, 0x39, 0x60, 0xac, 0x9b, 0x60, 0xcd, 0x23, 0x18, 0xa0, 0xc1, 0x68, 0xbc, 0x13, 0x4b, 0xcd, 0xfd, 0x3c, 0xff, 0x67, 0x14, 0x63, 0xf6, 0x1, 0x0, 0xf, 0x27, 0xaa, 0xdd, 0x5d, 0xf, 0x71, 0xbd, 0xc0, 0x1b, 0x48, 0xd, 0x35, 0xa3, 0x9a, 0x44, 0x1, 0x0, 0x1, 0x69, 0x2}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xde, 0xc2, 0x4d, 0x7f, 0x98, 0xc5, 0x2c, 0xbe, 0x3f, 0x3f, 0x8, 0xed, 0x7f, 0x4b, 0xf4, 0x2e, 0xd4, 0x85, 0x9f, 0xf7, 0x7b, 0xee, 0x1f, 0x37, 0x5b, 0x97, 0x11}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xab, 0x8d, 0xb1, 0xad, 0xa, 0x19, 0x81, 0x2c, 0x8f, 0x14, 0xa7, 0xa2, 0xbf, 0x3c, 0x2c}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7b, 0x92, 0x8a, 0x85, 0x73, 0x39, 0x60, 0xac, 0x9b, 0x60, 0xcd, 0x23, 0x18, 0xa0, 0xc1, 0x68, 0xbc, 0x13, 0x4b, 0xcd, 0xfd, 0x3c, 0xff, 0x67, 0x14, 0x63, 0xf6}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x27, 0xaa, 0xdd, 0x5d, 0xf, 0x71, 0xbd, 0xc0, 0x1b, 0x48, 0xd, 0x35, 0xa3, 0x9a, 0x44}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x69}; - lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; -lwmqtt_sub_options_t sub_opts[5]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS1; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0xb3, 0x1, 0x56, 0xea, 0x0, 0x5, 0xba, 0xb9, 0x82, 0xa8, 0xa6, 0x1, 0x0, 0x17, 0x9b, 0x9d, + 0x16, 0xe5, 0xe3, 0xd1, 0x34, 0x1, 0x7c, 0xf2, 0xa8, 0xfd, 0x81, 0x78, 0x46, 0xa6, 0x5c, 0x22, 0x42, + 0x47, 0xbf, 0xf6, 0xd7, 0x0, 0x0, 0x8, 0xb6, 0x37, 0xfa, 0xfb, 0x8d, 0x2e, 0xb5, 0xb9, 0x2, 0x0, + 0x0, 0x0, 0x0, 0xb, 0x86, 0x26, 0xfb, 0xac, 0xd8, 0x96, 0x7d, 0xed, 0x8, 0x8e, 0xf6, 0x2, 0x0, + 0x2, 0xc5, 0xeb, 0x2, 0x0, 0x1b, 0x4b, 0xc3, 0x7d, 0x29, 0xca, 0x31, 0x27, 0xda, 0xa9, 0x1, 0xc8, + 0x67, 0xfc, 0xeb, 0x52, 0xe1, 0xc9, 0x8, 0x26, 0x40, 0xb, 0x20, 0x59, 0x7e, 0x90, 0x78, 0xe8, 0x2, + 0x0, 0x19, 0xa3, 0xf9, 0x59, 0x60, 0xcf, 0x17, 0x4, 0x66, 0xa, 0x9f, 0x21, 0x6c, 0x1a, 0x32, 0x68, + 0x73, 0xa2, 0x95, 0xba, 0xfa, 0x3f, 0x7, 0xdc, 0xed, 0xc8, 0x1, 0x0, 0x1e, 0xb1, 0x80, 0x3b, 0x66, + 0xa3, 0x79, 0xb6, 0xde, 0xb9, 0xd, 0x16, 0x1f, 0x2d, 0x79, 0x23, 0xa8, 0xe, 0xbe, 0x43, 0x75, 0xe, + 0xd, 0x8f, 0x7e, 0x79, 0xfe, 0xb, 0x69, 0xa3, 0x58, 0x2, 0x0, 0xc, 0xec, 0x46, 0x6d, 0xea, 0xf7, + 0x76, 0x26, 0x35, 0xf9, 0xd0, 0x30, 0x1c, 0x2, 0x0, 0x1, 0x62, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xba, 0xb9, 0x82, 0xa8, 0xa6}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x9b, 0x9d, 0x16, 0xe5, 0xe3, 0xd1, 0x34, 0x1, 0x7c, 0xf2, 0xa8, 0xfd, + 0x81, 0x78, 0x46, 0xa6, 0x5c, 0x22, 0x42, 0x47, 0xbf, 0xf6, 0xd7}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb6, 0x37, 0xfa, 0xfb, 0x8d, 0x2e, 0xb5, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x86, 0x26, 0xfb, 0xac, 0xd8, 0x96, 0x7d, 0xed, 0x8, 0x8e, 0xf6}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xc5, 0xeb}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x4b, 0xc3, 0x7d, 0x29, 0xca, 0x31, 0x27, 0xda, 0xa9, 0x1, 0xc8, 0x67, 0xfc, 0xeb, + 0x52, 0xe1, 0xc9, 0x8, 0x26, 0x40, 0xb, 0x20, 0x59, 0x7e, 0x90, 0x78, 0xe8}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xa3, 0xf9, 0x59, 0x60, 0xcf, 0x17, 0x4, 0x66, 0xa, 0x9f, 0x21, 0x6c, 0x1a, + 0x32, 0x68, 0x73, 0xa2, 0x95, 0xba, 0xfa, 0x3f, 0x7, 0xdc, 0xed, 0xc8}; + lwmqtt_string_t topic_filter_s7 = {25, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xb1, 0x80, 0x3b, 0x66, 0xa3, 0x79, 0xb6, 0xde, 0xb9, 0xd, + 0x16, 0x1f, 0x2d, 0x79, 0x23, 0xa8, 0xe, 0xbe, 0x43, 0x75, + 0xe, 0xd, 0x8f, 0x7e, 0x79, 0xfe, 0xb, 0x69, 0xa3, 0x58}; + lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xec, 0x46, 0x6d, 0xea, 0xf7, 0x76, 0x26, 0x35, 0xf9, 0xd0, 0x30, 0x1c}; + lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x62}; + lwmqtt_string_t topic_filter_s10 = {1, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26963, 5, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22250, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 21870 [("@\DC1\168\&4q^o\128\193 R\129Q\n\SO \156\223\234\178\252\158\217=",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\v\202\226\206G",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\159W\DC30=\CAN%",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\138O\209\212z\EOTK",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("3\240\148o\129\n\158\&8\NULd\193\134\132\129z\132z\219`{\235W\144_",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 22609 [("9\162A\164\214x2\135U|)\230\201t\GS\197\189",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\SYN!\148\165\145\182dN\241\238@\176\144\v\210`\247d!u\206\133\167\190\&8",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\SUB\209\216\248:\200\215\CAN\234\STX\238\216\159Q\183\221\SYN\173<\182\128\142\n,\f",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\129?\164a4\230\147\232\177\225\226\247\131\222\205\ENQ",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\DC2a\186H\140\172N<\153M\252\171\252Ji'\DC3\f36\GS\236\DC4t\200",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("{\204\244O\162>\CAN9\152\209\137,[\171\227\225\131%",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(")eM\218\&6\152 \202\231\152J\139",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\200[\DC1O\176\181\136",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS0}),("\209f\ENQ!\195\251$^7\130\148_\DC4\189\167\202s\172\210\149\254\181=",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("2a\216\&2\185\140i=\199\224\250\&3\230r\DC4\161\146\130G",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\136\ETX\176~\130\DC1\"\241\SIp\253\190\162\219\183`\234",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode26) { -uint8_t pkt[] = {0x82, 0x54, 0x55, 0x6e, 0x0, 0x18, 0x40, 0x11, 0xa8, 0x34, 0x71, 0x5e, 0x6f, 0x80, 0xc1, 0x20, 0x52, 0x81, 0x51, 0xa, 0xe, 0x20, 0x9c, 0xdf, 0xea, 0xb2, 0xfc, 0x9e, 0xd9, 0x3d, 0x2, 0x0, 0x5, 0xb, 0xca, 0xe2, 0xce, 0x47, 0x2, 0x0, 0x7, 0x9f, 0x57, 0x13, 0x30, 0x3d, 0x18, 0x25, 0x2, 0x0, 0x7, 0x8a, 0x4f, 0xd1, 0xd4, 0x7a, 0x4, 0x4b, 0x2, 0x0, 0x18, 0x33, 0xf0, 0x94, 0x6f, 0x81, 0xa, 0x9e, 0x38, 0x0, 0x64, 0xc1, 0x86, 0x84, 0x81, 0x7a, 0x84, 0x7a, 0xdb, 0x60, 0x7b, 0xeb, 0x57, 0x90, 0x5f, 0x2}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x40, 0x11, 0xa8, 0x34, 0x71, 0x5e, 0x6f, 0x80, 0xc1, 0x20, 0x52, 0x81, 0x51, 0xa, 0xe, 0x20, 0x9c, 0xdf, 0xea, 0xb2, 0xfc, 0x9e, 0xd9, 0x3d}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb, 0xca, 0xe2, 0xce, 0x47}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9f, 0x57, 0x13, 0x30, 0x3d, 0x18, 0x25}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8a, 0x4f, 0xd1, 0xd4, 0x7a, 0x4, 0x4b}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x33, 0xf0, 0x94, 0x6f, 0x81, 0xa, 0x9e, 0x38, 0x0, 0x64, 0xc1, 0x86, 0x84, 0x81, 0x7a, 0x84, 0x7a, 0xdb, 0x60, 0x7b, 0xeb, 0x57, 0x90, 0x5f}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; -lwmqtt_sub_options_t sub_opts[5]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = { + 0x82, 0xef, 0x1, 0x58, 0x51, 0x0, 0x11, 0x39, 0xa2, 0x41, 0xa4, 0xd6, 0x78, 0x32, 0x87, 0x55, 0x7c, 0x29, 0xe6, + 0xc9, 0x74, 0x1d, 0xc5, 0xbd, 0x0, 0x0, 0x19, 0x16, 0x21, 0x94, 0xa5, 0x91, 0xb6, 0x64, 0x4e, 0xf1, 0xee, 0x40, + 0xb0, 0x90, 0xb, 0xd2, 0x60, 0xf7, 0x64, 0x21, 0x75, 0xce, 0x85, 0xa7, 0xbe, 0x38, 0x0, 0x0, 0x19, 0x1a, 0xd1, + 0xd8, 0xf8, 0x3a, 0xc8, 0xd7, 0x18, 0xea, 0x2, 0xee, 0xd8, 0x9f, 0x51, 0xb7, 0xdd, 0x16, 0xad, 0x3c, 0xb6, 0x80, + 0x8e, 0xa, 0x2c, 0xc, 0x1, 0x0, 0x10, 0x81, 0x3f, 0xa4, 0x61, 0x34, 0xe6, 0x93, 0xe8, 0xb1, 0xe1, 0xe2, 0xf7, + 0x83, 0xde, 0xcd, 0x5, 0x1, 0x0, 0x19, 0x12, 0x61, 0xba, 0x48, 0x8c, 0xac, 0x4e, 0x3c, 0x99, 0x4d, 0xfc, 0xab, + 0xfc, 0x4a, 0x69, 0x27, 0x13, 0xc, 0x33, 0x36, 0x1d, 0xec, 0x14, 0x74, 0xc8, 0x2, 0x0, 0x12, 0x7b, 0xcc, 0xf4, + 0x4f, 0xa2, 0x3e, 0x18, 0x39, 0x98, 0xd1, 0x89, 0x2c, 0x5b, 0xab, 0xe3, 0xe1, 0x83, 0x25, 0x0, 0x0, 0xc, 0x29, + 0x65, 0x4d, 0xda, 0x36, 0x98, 0x20, 0xca, 0xe7, 0x98, 0x4a, 0x8b, 0x2, 0x0, 0x7, 0xc8, 0x5b, 0x11, 0x4f, 0xb0, + 0xb5, 0x88, 0x0, 0x0, 0x17, 0xd1, 0x66, 0x5, 0x21, 0xc3, 0xfb, 0x24, 0x5e, 0x37, 0x82, 0x94, 0x5f, 0x14, 0xbd, + 0xa7, 0xca, 0x73, 0xac, 0xd2, 0x95, 0xfe, 0xb5, 0x3d, 0x2, 0x0, 0x13, 0x32, 0x61, 0xd8, 0x32, 0xb9, 0x8c, 0x69, + 0x3d, 0xc7, 0xe0, 0xfa, 0x33, 0xe6, 0x72, 0x14, 0xa1, 0x92, 0x82, 0x47, 0x1, 0x0, 0x11, 0x88, 0x3, 0xb0, 0x7e, + 0x82, 0x11, 0x22, 0xf1, 0xf, 0x70, 0xfd, 0xbe, 0xa2, 0xdb, 0xb7, 0x60, 0xea, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x39, 0xa2, 0x41, 0xa4, 0xd6, 0x78, 0x32, 0x87, 0x55, + 0x7c, 0x29, 0xe6, 0xc9, 0x74, 0x1d, 0xc5, 0xbd}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x16, 0x21, 0x94, 0xa5, 0x91, 0xb6, 0x64, 0x4e, 0xf1, 0xee, 0x40, 0xb0, 0x90, + 0xb, 0xd2, 0x60, 0xf7, 0x64, 0x21, 0x75, 0xce, 0x85, 0xa7, 0xbe, 0x38}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1a, 0xd1, 0xd8, 0xf8, 0x3a, 0xc8, 0xd7, 0x18, 0xea, 0x2, 0xee, 0xd8, 0x9f, + 0x51, 0xb7, 0xdd, 0x16, 0xad, 0x3c, 0xb6, 0x80, 0x8e, 0xa, 0x2c, 0xc}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x81, 0x3f, 0xa4, 0x61, 0x34, 0xe6, 0x93, 0xe8, + 0xb1, 0xe1, 0xe2, 0xf7, 0x83, 0xde, 0xcd, 0x5}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x12, 0x61, 0xba, 0x48, 0x8c, 0xac, 0x4e, 0x3c, 0x99, 0x4d, 0xfc, 0xab, 0xfc, + 0x4a, 0x69, 0x27, 0x13, 0xc, 0x33, 0x36, 0x1d, 0xec, 0x14, 0x74, 0xc8}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x7b, 0xcc, 0xf4, 0x4f, 0xa2, 0x3e, 0x18, 0x39, 0x98, + 0xd1, 0x89, 0x2c, 0x5b, 0xab, 0xe3, 0xe1, 0x83, 0x25}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x29, 0x65, 0x4d, 0xda, 0x36, 0x98, 0x20, 0xca, 0xe7, 0x98, 0x4a, 0x8b}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xc8, 0x5b, 0x11, 0x4f, 0xb0, 0xb5, 0x88}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd1, 0x66, 0x5, 0x21, 0xc3, 0xfb, 0x24, 0x5e, 0x37, 0x82, 0x94, 0x5f, + 0x14, 0xbd, 0xa7, 0xca, 0x73, 0xac, 0xd2, 0x95, 0xfe, 0xb5, 0x3d}; + lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x32, 0x61, 0xd8, 0x32, 0xb9, 0x8c, 0x69, 0x3d, 0xc7, 0xe0, + 0xfa, 0x33, 0xe6, 0x72, 0x14, 0xa1, 0x92, 0x82, 0x47}; + lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x88, 0x3, 0xb0, 0x7e, 0x82, 0x11, 0x22, 0xf1, 0xf, + 0x70, 0xfd, 0xbe, 0xa2, 0xdb, 0xb7, 0x60, 0xea}; + lwmqtt_string_t topic_filter_s10 = {17, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21870, 5, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22609, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 6154 [("\DEL\244\227\193\248L\DC2\249\249h\217u_u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\146\226X\227zoKZ\172C$\DC1>",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\USpH\130\\\EOT\ESCo\r\205\249d\215\243\246\EM\243\\Oy\195\147\&9<\249A\230\&5\ETX.",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\186Uah\251?\236m\133\v\215",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\f\193y\211\&9\163\188\237\SYN8\198\DC34\130\218\203\&3~\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\255+\137v\184\215Pix\170R\252{l\130\254\212yQ\223@l\SI\130i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\137\236\&92",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("{\"\202\130",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\221u\223w",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\249\137\219n\139\f\238\208lT0\201\209\SI\135\237\182\212\185\190\244\220\177\180B\229",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\\([*\EOTn\145\175\236G\176\&8\240\STX\170\SUB[c",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 5459 [("\167\&9\128\201\254\251f\154)\222\SYN\n\182w",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\v\244",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\NULV?\231o\214\r\141\181\DC4\236\139\166f\RS?B_",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\134\198\224\203\182\223E\204\128l\208\172\156\"\246",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\170b\195j\211}D\139\ESC\192\ACK9!\244F\140&1\143W\DC1Qy\211",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("p\NULm,\228\200\DLE\134\191V\174\192\SOHm\145H\RS\US\177\SIt\\",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\SOH\251cC\207\239\246\&5\202\158\vi\196\&1",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode27) { -uint8_t pkt[] = {0x82, 0xcb, 0x1, 0x18, 0xa, 0x0, 0xe, 0x7f, 0xf4, 0xe3, 0xc1, 0xf8, 0x4c, 0x12, 0xf9, 0xf9, 0x68, 0xd9, 0x75, 0x5f, 0x75, 0x1, 0x0, 0xd, 0x92, 0xe2, 0x58, 0xe3, 0x7a, 0x6f, 0x4b, 0x5a, 0xac, 0x43, 0x24, 0x11, 0x3e, 0x2, 0x0, 0x1e, 0x1f, 0x70, 0x48, 0x82, 0x5c, 0x4, 0x1b, 0x6f, 0xd, 0xcd, 0xf9, 0x64, 0xd7, 0xf3, 0xf6, 0x19, 0xf3, 0x5c, 0x4f, 0x79, 0xc3, 0x93, 0x39, 0x3c, 0xf9, 0x41, 0xe6, 0x35, 0x3, 0x2e, 0x1, 0x0, 0xb, 0xba, 0x55, 0x61, 0x68, 0xfb, 0x3f, 0xec, 0x6d, 0x85, 0xb, 0xd7, 0x1, 0x0, 0x13, 0xc, 0xc1, 0x79, 0xd3, 0x39, 0xa3, 0xbc, 0xed, 0x16, 0x38, 0xc6, 0x13, 0x34, 0x82, 0xda, 0xcb, 0x33, 0x7e, 0x5c, 0x0, 0x0, 0x19, 0xff, 0x2b, 0x89, 0x76, 0xb8, 0xd7, 0x50, 0x69, 0x78, 0xaa, 0x52, 0xfc, 0x7b, 0x6c, 0x82, 0xfe, 0xd4, 0x79, 0x51, 0xdf, 0x40, 0x6c, 0xf, 0x82, 0x69, 0x0, 0x0, 0x4, 0x89, 0xec, 0x39, 0x32, 0x2, 0x0, 0x4, 0x7b, 0x22, 0xca, 0x82, 0x0, 0x0, 0x4, 0xdd, 0x75, 0xdf, 0x77, 0x1, 0x0, 0x1a, 0xf9, 0x89, 0xdb, 0x6e, 0x8b, 0xc, 0xee, 0xd0, 0x6c, 0x54, 0x30, 0xc9, 0xd1, 0xf, 0x87, 0xed, 0xb6, 0xd4, 0xb9, 0xbe, 0xf4, 0xdc, 0xb1, 0xb4, 0x42, 0xe5, 0x2, 0x0, 0x12, 0x5c, 0x28, 0x5b, 0x2a, 0x4, 0x6e, 0x91, 0xaf, 0xec, 0x47, 0xb0, 0x38, 0xf0, 0x2, 0xaa, 0x1a, 0x5b, 0x63, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x7f, 0xf4, 0xe3, 0xc1, 0xf8, 0x4c, 0x12, 0xf9, 0xf9, 0x68, 0xd9, 0x75, 0x5f, 0x75}; + uint8_t pkt[] = {0x82, 0x84, 0x1, 0x15, 0x53, 0x0, 0xe, 0xa7, 0x39, 0x80, 0xc9, 0xfe, 0xfb, 0x66, 0x9a, 0x29, 0xde, + 0x16, 0xa, 0xb6, 0x77, 0x2, 0x0, 0x2, 0xb, 0xf4, 0x0, 0x0, 0x12, 0x0, 0x56, 0x3f, 0xe7, 0x6f, + 0xd6, 0xd, 0x8d, 0xb5, 0x14, 0xec, 0x8b, 0xa6, 0x66, 0x1e, 0x3f, 0x42, 0x5f, 0x2, 0x0, 0xf, 0x86, + 0xc6, 0xe0, 0xcb, 0xb6, 0xdf, 0x45, 0xcc, 0x80, 0x6c, 0xd0, 0xac, 0x9c, 0x22, 0xf6, 0x0, 0x0, 0x18, + 0xaa, 0x62, 0xc3, 0x6a, 0xd3, 0x7d, 0x44, 0x8b, 0x1b, 0xc0, 0x6, 0x39, 0x21, 0xf4, 0x46, 0x8c, 0x26, + 0x31, 0x8f, 0x57, 0x11, 0x51, 0x79, 0xd3, 0x2, 0x0, 0x16, 0x70, 0x0, 0x6d, 0x2c, 0xe4, 0xc8, 0x10, + 0x86, 0xbf, 0x56, 0xae, 0xc0, 0x1, 0x6d, 0x91, 0x48, 0x1e, 0x1f, 0xb1, 0xf, 0x74, 0x5c, 0x1, 0x0, + 0xe, 0x1, 0xfb, 0x63, 0x43, 0xcf, 0xef, 0xf6, 0x35, 0xca, 0x9e, 0xb, 0x69, 0xc4, 0x31, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xa7, 0x39, 0x80, 0xc9, 0xfe, 0xfb, 0x66, 0x9a, 0x29, 0xde, 0x16, 0xa, 0xb6, 0x77}; lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x92, 0xe2, 0x58, 0xe3, 0x7a, 0x6f, 0x4b, 0x5a, 0xac, 0x43, 0x24, 0x11, 0x3e}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1f, 0x70, 0x48, 0x82, 0x5c, 0x4, 0x1b, 0x6f, 0xd, 0xcd, 0xf9, 0x64, 0xd7, 0xf3, 0xf6, 0x19, 0xf3, 0x5c, 0x4f, 0x79, 0xc3, 0x93, 0x39, 0x3c, 0xf9, 0x41, 0xe6, 0x35, 0x3, 0x2e}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xba, 0x55, 0x61, 0x68, 0xfb, 0x3f, 0xec, 0x6d, 0x85, 0xb, 0xd7}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc, 0xc1, 0x79, 0xd3, 0x39, 0xa3, 0xbc, 0xed, 0x16, 0x38, 0xc6, 0x13, 0x34, 0x82, 0xda, 0xcb, 0x33, 0x7e, 0x5c}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xff, 0x2b, 0x89, 0x76, 0xb8, 0xd7, 0x50, 0x69, 0x78, 0xaa, 0x52, 0xfc, 0x7b, 0x6c, 0x82, 0xfe, 0xd4, 0x79, 0x51, 0xdf, 0x40, 0x6c, 0xf, 0x82, 0x69}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x89, 0xec, 0x39, 0x32}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7b, 0x22, 0xca, 0x82}; - lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xdd, 0x75, 0xdf, 0x77}; - lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xf9, 0x89, 0xdb, 0x6e, 0x8b, 0xc, 0xee, 0xd0, 0x6c, 0x54, 0x30, 0xc9, 0xd1, 0xf, 0x87, 0xed, 0xb6, 0xd4, 0xb9, 0xbe, 0xf4, 0xdc, 0xb1, 0xb4, 0x42, 0xe5}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; -topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x5c, 0x28, 0x5b, 0x2a, 0x4, 0x6e, 0x91, 0xaf, 0xec, 0x47, 0xb0, 0x38, 0xf0, 0x2, 0xaa, 0x1a, 0x5b, 0x63}; - lwmqtt_string_t topic_filter_s10 = {18, (char*)&topic_filter_s10_bytes}; -topic_filters[10] = topic_filter_s10; -lwmqtt_sub_options_t sub_opts[11]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS1; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS0; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS2; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS0; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = false; -sub_opts[8].qos = LWMQTT_QOS1; -sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[8].retain_as_published = false; -sub_opts[8].no_local = false; -sub_opts[9].qos = LWMQTT_QOS2; -sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[9].retain_as_published = false; -sub_opts[9].no_local = false; -sub_opts[10].qos = LWMQTT_QOS1; -sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[10].retain_as_published = false; -sub_opts[10].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb, 0xf4}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x0, 0x56, 0x3f, 0xe7, 0x6f, 0xd6, 0xd, 0x8d, 0xb5, + 0x14, 0xec, 0x8b, 0xa6, 0x66, 0x1e, 0x3f, 0x42, 0x5f}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x86, 0xc6, 0xe0, 0xcb, 0xb6, 0xdf, 0x45, 0xcc, + 0x80, 0x6c, 0xd0, 0xac, 0x9c, 0x22, 0xf6}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xaa, 0x62, 0xc3, 0x6a, 0xd3, 0x7d, 0x44, 0x8b, 0x1b, 0xc0, 0x6, 0x39, + 0x21, 0xf4, 0x46, 0x8c, 0x26, 0x31, 0x8f, 0x57, 0x11, 0x51, 0x79, 0xd3}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x70, 0x0, 0x6d, 0x2c, 0xe4, 0xc8, 0x10, 0x86, 0xbf, 0x56, 0xae, + 0xc0, 0x1, 0x6d, 0x91, 0x48, 0x1e, 0x1f, 0xb1, 0xf, 0x74, 0x5c}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x1, 0xfb, 0x63, 0x43, 0xcf, 0xef, 0xf6, 0x35, 0xca, 0x9e, 0xb, 0x69, 0xc4, 0x31}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6154, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5459, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 7912 [("\182\167\151\163VQ\156;\242Q\187<\193\&4\145-\243Y\208\152E?\200&\SYN\US",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\FS?\153\174\206\185MuW\176b\183\172\134",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\223\224s\US\169\&0bC\ENQQ\200\221\248qE\235\255B\n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 21650 +// [("\144\143\250\181?\222c\242\195\194iT\235\216\230\207\176(\169\205\175g\RS\221}V\US\206\228\167",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("r\242Fl\STX\222\224\199\213\254?\253\b\n\241\ESC\137f\252\ETX",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\188\213\&9\219v$\165F\194\195\157\155\193\DC2y\EM",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("Yk\181r6Q\f\148l\155\151\149\206I\133\&8\SOH\SOH\148\SUBaQ",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("D\191",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode28) { -uint8_t pkt[] = {0x82, 0x46, 0x1e, 0xe8, 0x0, 0x1a, 0xb6, 0xa7, 0x97, 0xa3, 0x56, 0x51, 0x9c, 0x3b, 0xf2, 0x51, 0xbb, 0x3c, 0xc1, 0x34, 0x91, 0x2d, 0xf3, 0x59, 0xd0, 0x98, 0x45, 0x3f, 0xc8, 0x26, 0x16, 0x1f, 0x1, 0x0, 0xe, 0x1c, 0x3f, 0x99, 0xae, 0xce, 0xb9, 0x4d, 0x75, 0x57, 0xb0, 0x62, 0xb7, 0xac, 0x86, 0x0, 0x0, 0x13, 0xdf, 0xe0, 0x73, 0x1f, 0xa9, 0x30, 0x62, 0x43, 0x5, 0x51, 0xc8, 0xdd, 0xf8, 0x71, 0x45, 0xeb, 0xff, 0x42, 0xa, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xb6, 0xa7, 0x97, 0xa3, 0x56, 0x51, 0x9c, 0x3b, 0xf2, 0x51, 0xbb, 0x3c, 0xc1, 0x34, 0x91, 0x2d, 0xf3, 0x59, 0xd0, 0x98, 0x45, 0x3f, 0xc8, 0x26, 0x16, 0x1f}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1c, 0x3f, 0x99, 0xae, 0xce, 0xb9, 0x4d, 0x75, 0x57, 0xb0, 0x62, 0xb7, 0xac, 0x86}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdf, 0xe0, 0x73, 0x1f, 0xa9, 0x30, 0x62, 0x43, 0x5, 0x51, 0xc8, 0xdd, 0xf8, 0x71, 0x45, 0xeb, 0xff, 0x42, 0xa}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; -lwmqtt_sub_options_t sub_opts[3]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS0; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x6e, 0x54, 0x92, 0x0, 0x1e, 0x90, 0x8f, 0xfa, 0xb5, 0x3f, 0xde, 0x63, 0xf2, 0xc3, 0xc2, + 0x69, 0x54, 0xeb, 0xd8, 0xe6, 0xcf, 0xb0, 0x28, 0xa9, 0xcd, 0xaf, 0x67, 0x1e, 0xdd, 0x7d, 0x56, + 0x1f, 0xce, 0xe4, 0xa7, 0x2, 0x0, 0x14, 0x72, 0xf2, 0x46, 0x6c, 0x2, 0xde, 0xe0, 0xc7, 0xd5, + 0xfe, 0x3f, 0xfd, 0x8, 0xa, 0xf1, 0x1b, 0x89, 0x66, 0xfc, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x10, 0xbc, 0xd5, 0x39, 0xdb, 0x76, 0x24, 0xa5, 0x46, 0xc2, 0xc3, 0x9d, 0x9b, 0xc1, 0x12, 0x79, + 0x19, 0x1, 0x0, 0x16, 0x59, 0x6b, 0xb5, 0x72, 0x36, 0x51, 0xc, 0x94, 0x6c, 0x9b, 0x97, 0x95, + 0xce, 0x49, 0x85, 0x38, 0x1, 0x1, 0x94, 0x1a, 0x61, 0x51, 0x2, 0x0, 0x2, 0x44, 0xbf, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x90, 0x8f, 0xfa, 0xb5, 0x3f, 0xde, 0x63, 0xf2, 0xc3, 0xc2, + 0x69, 0x54, 0xeb, 0xd8, 0xe6, 0xcf, 0xb0, 0x28, 0xa9, 0xcd, + 0xaf, 0x67, 0x1e, 0xdd, 0x7d, 0x56, 0x1f, 0xce, 0xe4, 0xa7}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x72, 0xf2, 0x46, 0x6c, 0x2, 0xde, 0xe0, 0xc7, 0xd5, 0xfe, + 0x3f, 0xfd, 0x8, 0xa, 0xf1, 0x1b, 0x89, 0x66, 0xfc, 0x3}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xbc, 0xd5, 0x39, 0xdb, 0x76, 0x24, 0xa5, 0x46, + 0xc2, 0xc3, 0x9d, 0x9b, 0xc1, 0x12, 0x79, 0x19}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x59, 0x6b, 0xb5, 0x72, 0x36, 0x51, 0xc, 0x94, 0x6c, 0x9b, 0x97, + 0x95, 0xce, 0x49, 0x85, 0x38, 0x1, 0x1, 0x94, 0x1a, 0x61, 0x51}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x44, 0xbf}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7912, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21650, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 1410 [("\146)\134\170\232\238\169\149\192\144\173`=4\225}\DC2\181\176\234\SUB-\173\SI\204",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\157\225\208\231:\189\b\244\171\243J\204\GS\233\177\CAN\210v\FS\NUL\EM",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DC3\166\143e\196",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 15109 [("\175\231\162\204$\151/\218\&0m\229",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode29) { -uint8_t pkt[] = {0x82, 0x3e, 0x5, 0x82, 0x0, 0x19, 0x92, 0x29, 0x86, 0xaa, 0xe8, 0xee, 0xa9, 0x95, 0xc0, 0x90, 0xad, 0x60, 0x3d, 0x34, 0xe1, 0x7d, 0x12, 0xb5, 0xb0, 0xea, 0x1a, 0x2d, 0xad, 0xf, 0xcc, 0x0, 0x0, 0x15, 0x9d, 0xe1, 0xd0, 0xe7, 0x3a, 0xbd, 0x8, 0xf4, 0xab, 0xf3, 0x4a, 0xcc, 0x1d, 0xe9, 0xb1, 0x18, 0xd2, 0x76, 0x1c, 0x0, 0x19, 0x2, 0x0, 0x5, 0x13, 0xa6, 0x8f, 0x65, 0xc4, 0x1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x92, 0x29, 0x86, 0xaa, 0xe8, 0xee, 0xa9, 0x95, 0xc0, 0x90, 0xad, 0x60, 0x3d, 0x34, 0xe1, 0x7d, 0x12, 0xb5, 0xb0, 0xea, 0x1a, 0x2d, 0xad, 0xf, 0xcc}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9d, 0xe1, 0xd0, 0xe7, 0x3a, 0xbd, 0x8, 0xf4, 0xab, 0xf3, 0x4a, 0xcc, 0x1d, 0xe9, 0xb1, 0x18, 0xd2, 0x76, 0x1c, 0x0, 0x19}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x13, 0xa6, 0x8f, 0x65, 0xc4}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; -lwmqtt_sub_options_t sub_opts[3]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x10, 0x3b, 0x5, 0x0, 0xb, 0xaf, 0xe7, 0xa2, + 0xcc, 0x24, 0x97, 0x2f, 0xda, 0x30, 0x6d, 0xe5, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xaf, 0xe7, 0xa2, 0xcc, 0x24, 0x97, 0x2f, 0xda, 0x30, 0x6d, 0xe5}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1410, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15109, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 21007 [("K\148\168\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("r\233o\161\151.",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("a\216\169\218\&7\t\173\212\208C|\f\221",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\209\136\244\253\211\NAK\191-\a\196\188\224\129\178_\238\170[\218\131$jr\220U\162:",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 31149 [("(\255\220",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("nuB\184\220_5\217\196}\246\129",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\n?*\177\237",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\166\247\163\135\239\140E\178R\230-\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("z\250o\254y\a\a,\201+#\222\212\164\CAN\DC1\184\138\217",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\ESC\220\r4\ak\135",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode30) { -uint8_t pkt[] = {0x82, 0x40, 0x52, 0xf, 0x0, 0x4, 0x4b, 0x94, 0xa8, 0x1, 0x2, 0x0, 0x6, 0x72, 0xe9, 0x6f, 0xa1, 0x97, 0x2e, 0x2, 0x0, 0xd, 0x61, 0xd8, 0xa9, 0xda, 0x37, 0x9, 0xad, 0xd4, 0xd0, 0x43, 0x7c, 0xc, 0xdd, 0x0, 0x0, 0x1b, 0xd1, 0x88, 0xf4, 0xfd, 0xd3, 0x15, 0xbf, 0x2d, 0x7, 0xc4, 0xbc, 0xe0, 0x81, 0xb2, 0x5f, 0xee, 0xaa, 0x5b, 0xda, 0x83, 0x24, 0x6a, 0x72, 0xdc, 0x55, 0xa2, 0x3a, 0x2}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x4b, 0x94, 0xa8, 0x1}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x72, 0xe9, 0x6f, 0xa1, 0x97, 0x2e}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x61, 0xd8, 0xa9, 0xda, 0x37, 0x9, 0xad, 0xd4, 0xd0, 0x43, 0x7c, 0xc, 0xdd}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd1, 0x88, 0xf4, 0xfd, 0xd3, 0x15, 0xbf, 0x2d, 0x7, 0xc4, 0xbc, 0xe0, 0x81, 0xb2, 0x5f, 0xee, 0xaa, 0x5b, 0xda, 0x83, 0x24, 0x6a, 0x72, 0xdc, 0x55, 0xa2, 0x3a}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; -lwmqtt_sub_options_t sub_opts[4]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; - - lwmqtt_property_t propslist[] = { - }; + uint8_t pkt[] = {0x82, 0x4e, 0x79, 0xad, 0x0, 0x3, 0x28, 0xff, 0xdc, 0x0, 0x0, 0xc, 0x6e, 0x75, 0x42, 0xb8, + 0xdc, 0x5f, 0x35, 0xd9, 0xc4, 0x7d, 0xf6, 0x81, 0x0, 0x0, 0x5, 0xa, 0x3f, 0x2a, 0xb1, 0xed, + 0x1, 0x0, 0xc, 0xa6, 0xf7, 0xa3, 0x87, 0xef, 0x8c, 0x45, 0xb2, 0x52, 0xe6, 0x2d, 0x98, 0x1, + 0x0, 0x13, 0x7a, 0xfa, 0x6f, 0xfe, 0x79, 0x7, 0x7, 0x2c, 0xc9, 0x2b, 0x23, 0xde, 0xd4, 0xa4, + 0x18, 0x11, 0xb8, 0x8a, 0xd9, 0x2, 0x0, 0x7, 0x1b, 0xdc, 0xd, 0x34, 0x7, 0x6b, 0x87, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x28, 0xff, 0xdc}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6e, 0x75, 0x42, 0xb8, 0xdc, 0x5f, 0x35, 0xd9, 0xc4, 0x7d, 0xf6, 0x81}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa, 0x3f, 0x2a, 0xb1, 0xed}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa6, 0xf7, 0xa3, 0x87, 0xef, 0x8c, 0x45, 0xb2, 0x52, 0xe6, 0x2d, 0x98}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x7a, 0xfa, 0x6f, 0xfe, 0x79, 0x7, 0x7, 0x2c, 0xc9, 0x2b, + 0x23, 0xde, 0xd4, 0xa4, 0x18, 0x11, 0xb8, 0x8a, 0xd9}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1b, 0xdc, 0xd, 0x34, 0x7, 0x6b, 0x87}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + + lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21007, 4, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31149, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 2235 [("\ETB\166",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropResponseInformation "\212\ETB\233\246\147\144G\DEL",PropSessionExpiryInterval 21137,PropUserProperty "\SYN\191\240\CANC" "p[",PropServerKeepAlive 12069,PropAssignedClientIdentifier "\130E\SUB >\SI\216\230R\235\ACK\FS\133jfq7/\210\198\210\161ys#",PropResponseTopic "\152\r\178\143\233\ACK0Ke\148\190\169Q4.]\130n\180\138\128\238\184=",PropAuthenticationMethod "4\167\136t\196\ESC\236\GS,3\188\aV\132\&2\192^\NUL\182\154\NAK'\a\130",PropSessionExpiryInterval 25074,PropSharedSubscriptionAvailable 100,PropRequestResponseInformation 36,PropSubscriptionIdentifier 18,PropMessageExpiryInterval 9123,PropUserProperty "\228\250F\165=\137\176\213Z\248\154ho\187\ENQ\176\184\136m\f\DC2\224\130\149A|\215\186\185" "\210q\217@\219;%\aB\196",PropTopicAlias 27031,PropUserProperty "y\135\164\169\250\159" "\247A\SO\DC3\147\182\240C|\f\129R\129\156/\SYN\160\216\244\ETB2\160\134\245}\132",PropWillDelayInterval 2441,PropMaximumQoS 72,PropAssignedClientIdentifier "o\SUB\239\t\r\SOH\245\134gu\GS\131b\SOH\"\208\177\164\&0\192V"] +// SubscribeRequest 28306 [("^VR\US\DELZ\SYN\186#\147D\230\US:\188\210\186\165}\145tM\224\&4\158",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\146\&4\203\145\SUB\209\235\223`.\147\&8\250Q\187\223\244\210b\235p\RS",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\205\151*/E\ETXy",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("m\136\t\NUL\228\154\166\199TU&2\143",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = False, _subQoS = QoS2})] [PropAuthenticationMethod +// "\151\191.\146\237\136B\SO\187[\200s\174\240\131\247\245",PropTopicAliasMaximum 30483,PropReceiveMaximum +// 10665,PropTopicAliasMaximum 27539,PropWillDelayInterval 20866,PropRetainAvailable 17,PropRetainAvailable +// 110,PropAuthenticationMethod +// "\210\137\139/\245\193\179\&6\148\191\195\ETB\ACKy@L\218\STX\150\162\239\235",PropRequestProblemInformation +// 146,PropRequestResponseInformation 102,PropTopicAlias 2117,PropMaximumPacketSize 21081,PropSessionExpiryInterval +// 9240,PropUserProperty "\148\138\ETBU\242K\DC3\236",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("w7jl\r\b\213",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\EOT\185\158\227\RSDU",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("6U",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\141\150T,\250\229\217f\217\SO\239FB\251\CAN",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),(")\254=\198'J\DC1\DC1$\210av\158m\162)\146\132\224\191\n\232\145",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("BK\228\209\196\156\140\244?2\144\USP3z2..\DC2`\129D",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\SO\154",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropAssignedClientIdentifier "\185K\r\236v1\206\""] +// SubscribeRequest 19505 [("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = +// True, _subQoS = QoS0}),("\193~\153\213\236\138\165\192;P\209\245\207",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\154\DC41*\134\182g\t'\129\&1\ETX\186_\STX\SYNks\SI\235P",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("1f,]@\243\146\195\138U\CAN\153B\215M8\229X?",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("k\241\"\130\130\f=\CANf\154\172\152E",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("W\235/\243\DLE",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, +// _subQoS = QoS1}),("\168\164\163wJ",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS2}),("\229\237\196\180\216\NAK\196\157'\221z\153\239-\EOT\202X\ENQK\177YOB+",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("RLl\155O\151\a\202]\163\201\221\153L+]\180\223\205\130\DC2h\NUL)\250\252\213\DC4",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropReasonString "\157\164\163\DC1[\246\STXH",PropSharedSubscriptionAvailable 191,PropSubscriptionIdentifier +// 5,PropSubscriptionIdentifierAvailable 89,PropMessageExpiryInterval 26463,PropReasonString "W +// \202\173\&5\169\&3N\183*\240V|]\209\176$\DLE\208",PropMaximumQoS 117,PropSubscriptionIdentifierAvailable +// 215,PropWildcardSubscriptionAvailable 169,PropServerReference +// "\240<\249Kx1\210\149\226\172\191\CANy;",PropResponseTopic "\NUL&\172*\180\NUL",PropAuthenticationData +// "3\192G\bV\176",PropTopicAlias 29798,PropMaximumQoS 29,PropMaximumPacketSize 7661,PropUserProperty +// "\230\183\aKq\DC4K2" "c\195\168p\202\248\CAN\218\DEL\SUB\247p\174\162H\188U!",PropPayloadFormatIndicator +// 35,PropServerReference "+\250\DC4\242\222\182/",PropSessionExpiryInterval 30690,PropPayloadFormatIndicator +// 113,PropWillDelayInterval 31221,PropRequestProblemInformation 46] TEST(Subscribe5QCTest, Encode3) { -uint8_t pkt[] = {0x82, 0x91, 0x1, 0x2a, 0xf8, 0xb, 0x12, 0x0, 0x8, 0xb9, 0x4b, 0xd, 0xec, 0x76, 0x31, 0xce, 0x22, 0x0, 0x1a, 0x9a, 0xc6, 0xab, 0x2d, 0xe9, 0x16, 0x55, 0x4c, 0xd8, 0x25, 0xa, 0xc4, 0x36, 0xc0, 0x9d, 0x30, 0x9f, 0xd8, 0xba, 0x6b, 0xf9, 0xe3, 0x3e, 0x4b, 0x13, 0xec, 0x18, 0x0, 0x7, 0x77, 0x37, 0x6a, 0x6c, 0xd, 0x8, 0xd5, 0x22, 0x0, 0x7, 0x4, 0xb9, 0x9e, 0xe3, 0x1e, 0x44, 0x55, 0x0, 0x0, 0x2, 0x36, 0x55, 0x5, 0x0, 0xf, 0x8d, 0x96, 0x54, 0x2c, 0xfa, 0xe5, 0xd9, 0x66, 0xd9, 0xe, 0xef, 0x46, 0x42, 0xfb, 0x18, 0x18, 0x0, 0x0, 0x4, 0x0, 0x17, 0x29, 0xfe, 0x3d, 0xc6, 0x27, 0x4a, 0x11, 0x11, 0x24, 0xd2, 0x61, 0x76, 0x9e, 0x6d, 0xa2, 0x29, 0x92, 0x84, 0xe0, 0xbf, 0xa, 0xe8, 0x91, 0x4, 0x0, 0x16, 0x42, 0x4b, 0xe4, 0xd1, 0xc4, 0x9c, 0x8c, 0xf4, 0x3f, 0x32, 0x90, 0x1f, 0x50, 0x33, 0x7a, 0x32, 0x2e, 0x2e, 0x12, 0x60, 0x81, 0x44, 0x8, 0x0, 0x2, 0xe, 0x9a, 0x19}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x9a, 0xc6, 0xab, 0x2d, 0xe9, 0x16, 0x55, 0x4c, 0xd8, 0x25, 0xa, 0xc4, 0x36, 0xc0, 0x9d, 0x30, 0x9f, 0xd8, 0xba, 0x6b, 0xf9, 0xe3, 0x3e, 0x4b, 0x13, 0xec}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x77, 0x37, 0x6a, 0x6c, 0xd, 0x8, 0xd5}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4, 0xb9, 0x9e, 0xe3, 0x1e, 0x44, 0x55}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x36, 0x55}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8d, 0x96, 0x54, 0x2c, 0xfa, 0xe5, 0xd9, 0x66, 0xd9, 0xe, 0xef, 0x46, 0x42, 0xfb, 0x18}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x29, 0xfe, 0x3d, 0xc6, 0x27, 0x4a, 0x11, 0x11, 0x24, 0xd2, 0x61, 0x76, 0x9e, 0x6d, 0xa2, 0x29, 0x92, 0x84, 0xe0, 0xbf, 0xa, 0xe8, 0x91}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x42, 0x4b, 0xe4, 0xd1, 0xc4, 0x9c, 0x8c, 0xf4, 0x3f, 0x32, 0x90, 0x1f, 0x50, 0x33, 0x7a, 0x32, 0x2e, 0x2e, 0x12, 0x60, 0x81, 0x44}; - lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xe, 0x9a}; - lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; -lwmqtt_sub_options_t sub_opts[9]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[0].retain_as_published = true; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS1; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = true; -sub_opts[4].qos = LWMQTT_QOS0; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[4].retain_as_published = true; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = true; -sub_opts[6].qos = LWMQTT_QOS0; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = false; -sub_opts[6].no_local = true; -sub_opts[7].qos = LWMQTT_QOS0; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = true; -sub_opts[7].no_local = false; -sub_opts[8].qos = LWMQTT_QOS1; -sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[8].retain_as_published = true; -sub_opts[8].no_local = false; - uint8_t bytesprops0[] = {0xb9, 0x4b, 0xd, 0xec, 0x76, 0x31, 0xce, 0x22}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops0}}}, + uint8_t pkt[] = { + 0x82, 0xb7, 0x2, 0x4c, 0x31, 0x98, 0x1, 0x1f, 0x0, 0x8, 0x9d, 0xa4, 0xa3, 0x11, 0x5b, 0xf6, 0x2, 0x48, 0x2a, + 0xbf, 0xb, 0x5, 0x29, 0x59, 0x2, 0x0, 0x0, 0x67, 0x5f, 0x1f, 0x0, 0x13, 0x57, 0x20, 0xca, 0xad, 0x35, 0xa9, + 0x33, 0x4e, 0xb7, 0x2a, 0xf0, 0x56, 0x7c, 0x5d, 0xd1, 0xb0, 0x24, 0x10, 0xd0, 0x24, 0x75, 0x29, 0xd7, 0x28, 0xa9, + 0x1c, 0x0, 0xe, 0xf0, 0x3c, 0xf9, 0x4b, 0x78, 0x31, 0xd2, 0x95, 0xe2, 0xac, 0xbf, 0x18, 0x79, 0x3b, 0x8, 0x0, + 0x6, 0x0, 0x26, 0xac, 0x2a, 0xb4, 0x0, 0x16, 0x0, 0x6, 0x33, 0xc0, 0x47, 0x8, 0x56, 0xb0, 0x23, 0x74, 0x66, + 0x24, 0x1d, 0x27, 0x0, 0x0, 0x1d, 0xed, 0x26, 0x0, 0x8, 0xe6, 0xb7, 0x7, 0x4b, 0x71, 0x14, 0x4b, 0x32, 0x0, + 0x12, 0x63, 0xc3, 0xa8, 0x70, 0xca, 0xf8, 0x18, 0xda, 0x7f, 0x1a, 0xf7, 0x70, 0xae, 0xa2, 0x48, 0xbc, 0x55, 0x21, + 0x1, 0x23, 0x1c, 0x0, 0x7, 0x2b, 0xfa, 0x14, 0xf2, 0xde, 0xb6, 0x2f, 0x11, 0x0, 0x0, 0x77, 0xe2, 0x1, 0x71, + 0x18, 0x0, 0x0, 0x79, 0xf5, 0x17, 0x2e, 0x0, 0x0, 0x2c, 0x0, 0xd, 0xc1, 0x7e, 0x99, 0xd5, 0xec, 0x8a, 0xa5, + 0xc0, 0x3b, 0x50, 0xd1, 0xf5, 0xcf, 0x19, 0x0, 0x15, 0x9a, 0x14, 0x31, 0x2a, 0x86, 0xb6, 0x67, 0x9, 0x27, 0x81, + 0x31, 0x3, 0xba, 0x5f, 0x2, 0x16, 0x6b, 0x73, 0xf, 0xeb, 0x50, 0x2c, 0x0, 0x13, 0x31, 0x66, 0x2c, 0x5d, 0x40, + 0xf3, 0x92, 0xc3, 0x8a, 0x55, 0x18, 0x99, 0x42, 0xd7, 0x4d, 0x38, 0xe5, 0x58, 0x3f, 0x29, 0x0, 0xd, 0x6b, 0xf1, + 0x22, 0x82, 0x82, 0xc, 0x3d, 0x18, 0x66, 0x9a, 0xac, 0x98, 0x45, 0x8, 0x0, 0x5, 0x57, 0xeb, 0x2f, 0xf3, 0x10, + 0x9, 0x0, 0x5, 0xa8, 0xa4, 0xa3, 0x77, 0x4a, 0x16, 0x0, 0x18, 0xe5, 0xed, 0xc4, 0xb4, 0xd8, 0x15, 0xc4, 0x9d, + 0x27, 0xdd, 0x7a, 0x99, 0xef, 0x2d, 0x4, 0xca, 0x58, 0x5, 0x4b, 0xb1, 0x59, 0x4f, 0x42, 0x2b, 0x11, 0x0, 0x1c, + 0x52, 0x4c, 0x6c, 0x9b, 0x4f, 0x97, 0x7, 0xca, 0x5d, 0xa3, 0xc9, 0xdd, 0x99, 0x4c, 0x2b, 0x5d, 0xb4, 0xdf, 0xcd, + 0x82, 0x12, 0x68, 0x0, 0x29, 0xfa, 0xfc, 0xd5, 0x14, 0x10}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc1, 0x7e, 0x99, 0xd5, 0xec, 0x8a, 0xa5, 0xc0, 0x3b, 0x50, 0xd1, 0xf5, 0xcf}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x9a, 0x14, 0x31, 0x2a, 0x86, 0xb6, 0x67, 0x9, 0x27, 0x81, 0x31, + 0x3, 0xba, 0x5f, 0x2, 0x16, 0x6b, 0x73, 0xf, 0xeb, 0x50}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x31, 0x66, 0x2c, 0x5d, 0x40, 0xf3, 0x92, 0xc3, 0x8a, 0x55, + 0x18, 0x99, 0x42, 0xd7, 0x4d, 0x38, 0xe5, 0x58, 0x3f}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x6b, 0xf1, 0x22, 0x82, 0x82, 0xc, 0x3d, 0x18, 0x66, 0x9a, 0xac, 0x98, 0x45}; + lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x57, 0xeb, 0x2f, 0xf3, 0x10}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa8, 0xa4, 0xa3, 0x77, 0x4a}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe5, 0xed, 0xc4, 0xb4, 0xd8, 0x15, 0xc4, 0x9d, 0x27, 0xdd, 0x7a, 0x99, + 0xef, 0x2d, 0x4, 0xca, 0x58, 0x5, 0x4b, 0xb1, 0x59, 0x4f, 0x42, 0x2b}; + lwmqtt_string_t topic_filter_s7 = {24, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x52, 0x4c, 0x6c, 0x9b, 0x4f, 0x97, 0x7, 0xca, 0x5d, 0xa3, + 0xc9, 0xdd, 0x99, 0x4c, 0x2b, 0x5d, 0xb4, 0xdf, 0xcd, 0x82, + 0x12, 0x68, 0x0, 0x29, 0xfa, 0xfc, 0xd5, 0x14}; + lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + uint8_t bytesprops0[] = {0x9d, 0xa4, 0xa3, 0x11, 0x5b, 0xf6, 0x2, 0x48}; + uint8_t bytesprops1[] = {0x57, 0x20, 0xca, 0xad, 0x35, 0xa9, 0x33, 0x4e, 0xb7, 0x2a, + 0xf0, 0x56, 0x7c, 0x5d, 0xd1, 0xb0, 0x24, 0x10, 0xd0}; + uint8_t bytesprops2[] = {0xf0, 0x3c, 0xf9, 0x4b, 0x78, 0x31, 0xd2, 0x95, 0xe2, 0xac, 0xbf, 0x18, 0x79, 0x3b}; + uint8_t bytesprops3[] = {0x0, 0x26, 0xac, 0x2a, 0xb4, 0x0}; + uint8_t bytesprops4[] = {0x33, 0xc0, 0x47, 0x8, 0x56, 0xb0}; + uint8_t bytesprops6[] = {0x63, 0xc3, 0xa8, 0x70, 0xca, 0xf8, 0x18, 0xda, 0x7f, + 0x1a, 0xf7, 0x70, 0xae, 0xa2, 0x48, 0xbc, 0x55, 0x21}; + uint8_t bytesprops5[] = {0xe6, 0xb7, 0x7, 0x4b, 0x71, 0x14, 0x4b, 0x32}; + uint8_t bytesprops7[] = {0x2b, 0xfa, 0x14, 0xf2, 0xde, 0xb6, 0x2f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26463}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29798}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7661}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops5}, .v = {18, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30690}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31221}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11000, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19505, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 21792 [("6\208Y0\251\199\EM",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("GX\147{(\182\223\141\GSB;\164\153/\133\DC2s",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropSubscriptionIdentifier 6,PropTopicAliasMaximum 11050,PropAssignedClientIdentifier "\GS\236\&8\194\187\187\209\221\&2S\177J\231\&7\ESC\177s\CAN\134\158H\136\229\215\t\EM\RS\r\STX"] +// SubscribeRequest 22696 [("i\\\ETB]\223\172\230\167S\161\b\f\181\140\230\235\211\199\RS",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\167",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\167E\206\237eq!\244c\192\133\243\244",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS2}),("\150\245e",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\156\133~]\132@\193",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\RS\145\206) +// \b\156\205\226\161RF\ETX\DC3\144q\211\212pm]%6\185\228\189p",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\188*F\240k\177\DEL\179Z\238a\160$\225\245*\135(\DC2q",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\197\168cf\214e\153\EM_T\211\151;\179\163\164 +// \135\158\193\SOH",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("C\133\193\&1\150FS\ESC\227S;\138I\ETX\SUB",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\148\241Hb\144[\206)\160\178w",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("HG\190\249\226\171Bd;n\226\240\138\157R\188\178\139",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropUserProperty "=\254\ESC\143n\170~1" +// "\139\206\167\196S\180\252\205\128\213z\132Y\213\SYN\225\133\213\&8$",PropContentType +// "v\DEL\186\DC2J\156\210O",PropUserProperty "\ETX\206\SUB\ETX\162\249\b$\169\254/\DEL\215\ETX\214\202\179lr\ESC;Q" +// "y\197\DEL\202\&6*\237{\144(\206-\"\215\215\136\239\237\ETB\183\US",PropResponseTopic +// "\190%4!\141\131",PropSharedSubscriptionAvailable 243,PropTopicAliasMaximum 30973,PropCorrelationData +// "",PropServerReference "@3}\150J\188\251\170\142\DLE ",PropWildcardSubscriptionAvailable 73,PropAuthenticationData +// "1\134u8\DC2!\136\172",PropMaximumPacketSize 21435,PropAuthenticationData +// "~YJM\211\142\158&\227\153\185=(Ob\188.$1\232\204=N\217k",PropAssignedClientIdentifier "w\ETXh\244\160\&3\234\205\235Bq",PropMaximumPacketSize 15446,PropSessionExpiryInterval 5053,PropContentType "F\216GO\237\212\244#",PropAuthenticationMethod "",PropSubscriptionIdentifierAvailable 116,PropReceiveMaximum 19775,PropSubscriptionIdentifierAvailable 85,PropWildcardSubscriptionAvailable 61,PropResponseTopic "\t",PropRequestResponseInformation 152,PropServerKeepAlive 7792,PropAssignedClientIdentifier "\195\201\132",PropRequestResponseInformation 241,PropServerKeepAlive 9998,PropMaximumPacketSize 7241,PropSessionExpiryInterval 9777,PropSubscriptionIdentifierAvailable 184,PropResponseTopic "\142F\DC1\212\ESC\236j8",PropRequestResponseInformation 237,PropContentType "\DC2\US\RS\178\US\152\DC1\225\205\n\140\191\153\188q\159\152\174\&9\132\208\235\196\ESC\199\NUL",PropResponseInformation "$\211\243#\n:)L\169S",PropMaximumPacketSize 13967,PropRequestProblemInformation 31,PropAuthenticationData "\tgj\146\166\193\&9\212LhA{\b>",PropReceiveMaximum 17429,PropAuthenticationData "#\203>\CANSd\205+\CAN",PropSessionExpiryInterval 1396] +// SubscribeRequest 14047 [("\r\253\211]\t\130|\206\&1\231\131\EOT\SI\129\229\140",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\245\193h\190\138\168\227j\SUB\DC2\232\129A\197",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\152>\249\ACK",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\184\209\128O=(Q\229",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("2E\213\230\200\236\143\235\&0\NUL\CAN\ESC#Y\224Bf\FS-z\133 \192'C",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\177\212\217\238\249\r\208\171n\214\145HAI\FSG\NUL>\198\212y\RS\217\148\225\CANQ",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("1\152:S",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("\180n\153T\208\214\157",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// True, _noLocal = False, _subQoS = QoS0}),("\168eem\240p\168\224\244\EOT\131/;\201\179\224",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),(")ZK[\221\236\"r\197\144\180\255,\159\143\229\160\189\242",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval +// 9681,PropRequestResponseInformation 112,PropSubscriptionIdentifier 13,PropAssignedClientIdentifier +// "\168+\167\203\"\239\253K\240\150\231]\131\202\231\175\233\135\128K\132\227\217\&4\222$\182\&8\196\209",PropSubscriptionIdentifier +// 14,PropServerKeepAlive 27976,PropRetainAvailable 103,PropSessionExpiryInterval 15663,PropAssignedClientIdentifier +// "\229q\247_d}\143{\232Fi\153\248\228\ETXM6",PropContentType "\145t\166\134\205\232\203\129",PropSessionExpiryInterval +// 8709,PropSubscriptionIdentifierAvailable 52,PropServerKeepAlive 7895,PropServerReference +// "\175\213\152\183^x\fY\165,\154",PropResponseTopic "\250\ESCX\a\230B\239\249\137eFA",PropCorrelationData +// "\254;\t\222p\170\NAK",PropServerKeepAlive 21236,PropSubscriptionIdentifier 12,PropWillDelayInterval +// 21266,PropRequestResponseInformation 45] TEST(Subscribe5QCTest, Encode5) { -uint8_t pkt[] = {0x82, 0xee, 0x1, 0x4f, 0x2d, 0xd1, 0x1, 0x12, 0x0, 0x1c, 0xc2, 0x6e, 0xb7, 0xce, 0xb4, 0xed, 0x51, 0x76, 0x9b, 0x85, 0x15, 0x47, 0x45, 0x9e, 0x87, 0x22, 0x44, 0x6e, 0xc8, 0x1e, 0x65, 0xf6, 0xe0, 0x4e, 0x3e, 0x4e, 0xd9, 0x6b, 0x12, 0x0, 0xb, 0x77, 0x3, 0x68, 0xf4, 0xa0, 0x33, 0xea, 0xcd, 0xeb, 0x42, 0x71, 0x27, 0x0, 0x0, 0x3c, 0x56, 0x11, 0x0, 0x0, 0x13, 0xbd, 0x3, 0x0, 0x8, 0x46, 0xd8, 0x47, 0x4f, 0xed, 0xd4, 0xf4, 0x23, 0x15, 0x0, 0x0, 0x29, 0x74, 0x21, 0x4d, 0x3f, 0x29, 0x55, 0x28, 0x3d, 0x8, 0x0, 0x1, 0x9, 0x19, 0x98, 0x13, 0x1e, 0x70, 0x12, 0x0, 0x3, 0xc3, 0xc9, 0x84, 0x19, 0xf1, 0x13, 0x27, 0xe, 0x27, 0x0, 0x0, 0x1c, 0x49, 0x11, 0x0, 0x0, 0x26, 0x31, 0x29, 0xb8, 0x8, 0x0, 0x8, 0x8e, 0x46, 0x11, 0xd4, 0x1b, 0xec, 0x6a, 0x38, 0x19, 0xed, 0x3, 0x0, 0x1a, 0x12, 0x1f, 0x1e, 0xb2, 0x1f, 0x98, 0x11, 0xe1, 0xcd, 0xa, 0x8c, 0xbf, 0x99, 0xbc, 0x71, 0x9f, 0x98, 0xae, 0x39, 0x84, 0xd0, 0xeb, 0xc4, 0x1b, 0xc7, 0x0, 0x1a, 0x0, 0xa, 0x24, 0xd3, 0xf3, 0x23, 0xa, 0x3a, 0x29, 0x4c, 0xa9, 0x53, 0x27, 0x0, 0x0, 0x36, 0x8f, 0x17, 0x1f, 0x16, 0x0, 0xe, 0x9, 0x67, 0x6a, 0x92, 0xa6, 0xc1, 0x39, 0xd4, 0x4c, 0x68, 0x41, 0x7b, 0x8, 0x3e, 0x21, 0x44, 0x15, 0x16, 0x0, 0x9, 0x23, 0xcb, 0x3e, 0x18, 0x53, 0x64, 0xcd, 0x2b, 0x18, 0x11, 0x0, 0x0, 0x5, 0x74, 0x0, 0x16, 0xdc, 0x85, 0xfe, 0x5d, 0xb9, 0x25, 0xd5, 0x5f, 0xbd, 0xc7, 0x74, 0x24, 0x5b, 0xaa, 0x6d, 0xe8, 0x6d, 0xe, 0x66, 0x33, 0x63, 0xe2, 0x29}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xdc, 0x85, 0xfe, 0x5d, 0xb9, 0x25, 0xd5, 0x5f, 0xbd, 0xc7, 0x74, 0x24, 0x5b, 0xaa, 0x6d, 0xe8, 0x6d, 0xe, 0x66, 0x33, 0x63, 0xe2}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; -lwmqtt_sub_options_t sub_opts[1]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[0].retain_as_published = true; -sub_opts[0].no_local = false; - uint8_t bytesprops0[] = {0xc2, 0x6e, 0xb7, 0xce, 0xb4, 0xed, 0x51, 0x76, 0x9b, 0x85, 0x15, 0x47, 0x45, 0x9e, 0x87, 0x22, 0x44, 0x6e, 0xc8, 0x1e, 0x65, 0xf6, 0xe0, 0x4e, 0x3e, 0x4e, 0xd9, 0x6b}; - uint8_t bytesprops1[] = {0x77, 0x3, 0x68, 0xf4, 0xa0, 0x33, 0xea, 0xcd, 0xeb, 0x42, 0x71}; - uint8_t bytesprops2[] = {0x46, 0xd8, 0x47, 0x4f, 0xed, 0xd4, 0xf4, 0x23}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x9}; - uint8_t bytesprops5[] = {0xc3, 0xc9, 0x84}; - uint8_t bytesprops6[] = {0x8e, 0x46, 0x11, 0xd4, 0x1b, 0xec, 0x6a, 0x38}; - uint8_t bytesprops7[] = {0x12, 0x1f, 0x1e, 0xb2, 0x1f, 0x98, 0x11, 0xe1, 0xcd, 0xa, 0x8c, 0xbf, 0x99, 0xbc, 0x71, 0x9f, 0x98, 0xae, 0x39, 0x84, 0xd0, 0xeb, 0xc4, 0x1b, 0xc7, 0x0}; - uint8_t bytesprops8[] = {0x24, 0xd3, 0xf3, 0x23, 0xa, 0x3a, 0x29, 0x4c, 0xa9, 0x53}; - uint8_t bytesprops9[] = {0x9, 0x67, 0x6a, 0x92, 0xa6, 0xc1, 0x39, 0xd4, 0x4c, 0x68, 0x41, 0x7b, 0x8, 0x3e}; - uint8_t bytesprops10[] = {0x23, 0xcb, 0x3e, 0x18, 0x53, 0x64, 0xcd, 0x2b, 0x18}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15446}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5053}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19775}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7792}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9998}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7241}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9777}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13967}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17429}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1396}}, + uint8_t pkt[] = { + 0x82, 0xc0, 0x2, 0x36, 0xdf, 0x92, 0x1, 0x2, 0x0, 0x0, 0x25, 0xd1, 0x19, 0x70, 0xb, 0xd, 0x12, 0x0, 0x1e, + 0xa8, 0x2b, 0xa7, 0xcb, 0x22, 0xef, 0xfd, 0x4b, 0xf0, 0x96, 0xe7, 0x5d, 0x83, 0xca, 0xe7, 0xaf, 0xe9, 0x87, 0x80, + 0x4b, 0x84, 0xe3, 0xd9, 0x34, 0xde, 0x24, 0xb6, 0x38, 0xc4, 0xd1, 0xb, 0xe, 0x13, 0x6d, 0x48, 0x25, 0x67, 0x11, + 0x0, 0x0, 0x3d, 0x2f, 0x12, 0x0, 0x11, 0xe5, 0x71, 0xf7, 0x5f, 0x64, 0x7d, 0x8f, 0x7b, 0xe8, 0x46, 0x69, 0x99, + 0xf8, 0xe4, 0x3, 0x4d, 0x36, 0x3, 0x0, 0x8, 0x91, 0x74, 0xa6, 0x86, 0xcd, 0xe8, 0xcb, 0x81, 0x11, 0x0, 0x0, + 0x22, 0x5, 0x29, 0x34, 0x13, 0x1e, 0xd7, 0x1c, 0x0, 0xb, 0xaf, 0xd5, 0x98, 0xb7, 0x5e, 0x78, 0xc, 0x59, 0xa5, + 0x2c, 0x9a, 0x8, 0x0, 0xc, 0xfa, 0x1b, 0x58, 0x7, 0xe6, 0x42, 0xef, 0xf9, 0x89, 0x65, 0x46, 0x41, 0x9, 0x0, + 0x7, 0xfe, 0x3b, 0x9, 0xde, 0x70, 0xaa, 0x15, 0x13, 0x52, 0xf4, 0xb, 0xc, 0x18, 0x0, 0x0, 0x53, 0x12, 0x19, + 0x2d, 0x0, 0x10, 0xd, 0xfd, 0xd3, 0x5d, 0x9, 0x82, 0x7c, 0xce, 0x31, 0xe7, 0x83, 0x4, 0xf, 0x81, 0xe5, 0x8c, + 0x12, 0x0, 0xe, 0xf5, 0xc1, 0x68, 0xbe, 0x8a, 0xa8, 0xe3, 0x6a, 0x1a, 0x12, 0xe8, 0x81, 0x41, 0xc5, 0x2c, 0x0, + 0x4, 0x98, 0x3e, 0xf9, 0x6, 0xc, 0x0, 0x8, 0xb8, 0xd1, 0x80, 0x4f, 0x3d, 0x28, 0x51, 0xe5, 0x0, 0x0, 0x19, + 0x32, 0x45, 0xd5, 0xe6, 0xc8, 0xec, 0x8f, 0xeb, 0x30, 0x0, 0x18, 0x1b, 0x23, 0x59, 0xe0, 0x42, 0x66, 0x1c, 0x2d, + 0x7a, 0x85, 0x20, 0xc0, 0x27, 0x43, 0x12, 0x0, 0x1b, 0xb1, 0xd4, 0xd9, 0xee, 0xf9, 0xd, 0xd0, 0xab, 0x6e, 0xd6, + 0x91, 0x48, 0x41, 0x49, 0x1c, 0x47, 0x0, 0x3e, 0xc6, 0xd4, 0x79, 0x1e, 0xd9, 0x94, 0xe1, 0x18, 0x51, 0x10, 0x0, + 0x4, 0x31, 0x98, 0x3a, 0x53, 0x0, 0x0, 0x7, 0xb4, 0x6e, 0x99, 0x54, 0xd0, 0xd6, 0x9d, 0x18, 0x0, 0x10, 0xa8, + 0x65, 0x65, 0x6d, 0xf0, 0x70, 0xa8, 0xe0, 0xf4, 0x4, 0x83, 0x2f, 0x3b, 0xc9, 0xb3, 0xe0, 0x2, 0x0, 0x13, 0x29, + 0x5a, 0x4b, 0x5b, 0xdd, 0xec, 0x22, 0x72, 0xc5, 0x90, 0xb4, 0xff, 0x2c, 0x9f, 0x8f, 0xe5, 0xa0, 0xbd, 0xf2, 0x21}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd, 0xfd, 0xd3, 0x5d, 0x9, 0x82, 0x7c, 0xce, + 0x31, 0xe7, 0x83, 0x4, 0xf, 0x81, 0xe5, 0x8c}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf5, 0xc1, 0x68, 0xbe, 0x8a, 0xa8, 0xe3, + 0x6a, 0x1a, 0x12, 0xe8, 0x81, 0x41, 0xc5}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x98, 0x3e, 0xf9, 0x6}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb8, 0xd1, 0x80, 0x4f, 0x3d, 0x28, 0x51, 0xe5}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x32, 0x45, 0xd5, 0xe6, 0xc8, 0xec, 0x8f, 0xeb, 0x30, 0x0, 0x18, 0x1b, 0x23, + 0x59, 0xe0, 0x42, 0x66, 0x1c, 0x2d, 0x7a, 0x85, 0x20, 0xc0, 0x27, 0x43}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb1, 0xd4, 0xd9, 0xee, 0xf9, 0xd, 0xd0, 0xab, 0x6e, 0xd6, 0x91, 0x48, 0x41, 0x49, + 0x1c, 0x47, 0x0, 0x3e, 0xc6, 0xd4, 0x79, 0x1e, 0xd9, 0x94, 0xe1, 0x18, 0x51}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x31, 0x98, 0x3a, 0x53}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xb4, 0x6e, 0x99, 0x54, 0xd0, 0xd6, 0x9d}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa8, 0x65, 0x65, 0x6d, 0xf0, 0x70, 0xa8, 0xe0, + 0xf4, 0x4, 0x83, 0x2f, 0x3b, 0xc9, 0xb3, 0xe0}; + lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x29, 0x5a, 0x4b, 0x5b, 0xdd, 0xec, 0x22, 0x72, 0xc5, 0x90, + 0xb4, 0xff, 0x2c, 0x9f, 0x8f, 0xe5, 0xa0, 0xbd, 0xf2}; + lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + uint8_t bytesprops0[] = {0xa8, 0x2b, 0xa7, 0xcb, 0x22, 0xef, 0xfd, 0x4b, 0xf0, 0x96, 0xe7, 0x5d, 0x83, 0xca, 0xe7, + 0xaf, 0xe9, 0x87, 0x80, 0x4b, 0x84, 0xe3, 0xd9, 0x34, 0xde, 0x24, 0xb6, 0x38, 0xc4, 0xd1}; + uint8_t bytesprops1[] = {0xe5, 0x71, 0xf7, 0x5f, 0x64, 0x7d, 0x8f, 0x7b, 0xe8, + 0x46, 0x69, 0x99, 0xf8, 0xe4, 0x3, 0x4d, 0x36}; + uint8_t bytesprops2[] = {0x91, 0x74, 0xa6, 0x86, 0xcd, 0xe8, 0xcb, 0x81}; + uint8_t bytesprops3[] = {0xaf, 0xd5, 0x98, 0xb7, 0x5e, 0x78, 0xc, 0x59, 0xa5, 0x2c, 0x9a}; + uint8_t bytesprops4[] = {0xfa, 0x1b, 0x58, 0x7, 0xe6, 0x42, 0xef, 0xf9, 0x89, 0x65, 0x46, 0x41}; + uint8_t bytesprops5[] = {0xfe, 0x3b, 0x9, 0xde, 0x70, 0xaa, 0x15}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9681}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27976}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15663}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8709}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7895}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21236}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21266}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 45}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20269, 1, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14047, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 27793 [("\175\175\230\214\&2",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),(",\DEL[\SO\253\205\b\135j\ESC\217",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\224\206y\244\197V\182\157Q\232\248H\131\180\228B\FS\DC2\SO\159\243w",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\197\204\211\195h[\RSa&\150PL\SO\231\187\173\192P|q\240\r\139-\232\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\164\169|\199\van\145$\211<3\180)>\173Xgz:\225\DC4\163\212\141\177h",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\SUBl",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationMethod "\179\199:G\128yB\161hQ\USb",PropSubscriptionIdentifierAvailable 146,PropAssignedClientIdentifier "!\241\231\174Y\STX\178\245\"\182",PropServerReference "\243At\249\DC24\139\128\130\161\224\189\183Q\244<*R\142\134\129",PropReceiveMaximum 11764,PropTopicAlias 11978,PropServerReference "\144\ETX\210\153\r\v\163 \SI\247\234\208{2\160\&4\142\165K\"a\NAK",PropMessageExpiryInterval 7709,PropTopicAlias 11119,PropWillDelayInterval 11679,PropWildcardSubscriptionAvailable 21,PropTopicAliasMaximum 3192] +// SubscribeRequest 502 [("\ESC\USm\212\ETB\238\&9\252\153\189\163S\234=+",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("{\221\\\229 +// :\162\183\177\157\208\253\FS\144bS\217\ETB\180",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("U,\243\&4\ETB\241\&1\142\221\ACK#\tm\137\153\131F\200\147\&1\153\242\176\192\241\132>\192\174",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\SI\SI\DC39\233\224\EMM\128L5\235\156\157o\239N7\172:d\247",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropCorrelationData +// "\t\197[\224\236Y\206}\148\234\178P\237\222\147(\217\162\154\nL\201|\ACK\184\DLE\243\151\254",PropSubscriptionIdentifierAvailable +// 209,PropTopicAlias 23243,PropTopicAliasMaximum 24913,PropSubscriptionIdentifierAvailable 10,PropMaximumPacketSize +// 27215,PropPayloadFormatIndicator 37,PropContentType "\ESC\175*!\157\249'\t\158\\\204\DC4\158Bo|\140\RS.\202\128 +// 2\243\229\185\226",PropRetainAvailable 124,PropRetainAvailable 27,PropSubscriptionIdentifier 0,PropAuthenticationData +// "\DEL\ETX'\143\245\191\229\196\179$",PropPayloadFormatIndicator 43,PropAuthenticationData +// "\177",PropMessageExpiryInterval 1767,PropResponseInformation +// "E\NAKD3[\244*\254\248\246q\215\177\250\RSPU\148.\180^\DC4\ETB#q\218",PropContentType +// "\ENQ\v\221x0F\ACKe\ETB<\255ZS\DEL\169\233O>|0\SO\228\172\142\&7\224\&7",PropPayloadFormatIndicator +// 75,PropSubscriptionIdentifierAvailable 152,PropSharedSubscriptionAvailable 194,PropAuthenticationMethod +// "Ql\234\237c\224\v\151\bG\DEL\141\CAN",PropReceiveMaximum 26111,PropAssignedClientIdentifier +// "\154\162T\157\216\252\187~H\232X\ETX>\146\196\234/\219\239\194",PropReasonString +// "F8pG\158",PropSessionExpiryInterval 28561,PropMaximumPacketSize 13192,PropReasonString "~\191\216`\194}:\246"] TEST(Subscribe5QCTest, Encode6) { -uint8_t pkt[] = {0x82, 0xd9, 0x1, 0x6c, 0x91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0x61, 0x6e, 0x91, 0x24, 0xd3, 0x3c, 0x33, 0xb4, 0x29, 0x3e, 0xad, 0x58, 0x67, 0x7a, 0x3a, 0xe1, 0x14, 0xa3, 0xd4, 0x8d, 0xb1, 0x68, 0x1, 0x0, 0x2, 0x1a, 0x6c, 0x28}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xaf, 0xaf, 0xe6, 0xd6, 0x32}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2c, 0x7f, 0x5b, 0xe, 0xfd, 0xcd, 0x8, 0x87, 0x6a, 0x1b, 0xd9}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe0, 0xce, 0x79, 0xf4, 0xc5, 0x56, 0xb6, 0x9d, 0x51, 0xe8, 0xf8, 0x48, 0x83, 0xb4, 0xe4, 0x42, 0x1c, 0x12, 0xe, 0x9f, 0xf3, 0x77}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc5, 0xcc, 0xd3, 0xc3, 0x68, 0x5b, 0x1e, 0x61, 0x26, 0x96, 0x50, 0x4c, 0xe, 0xe7, 0xbb, 0xad, 0xc0, 0x50, 0x7c, 0x71, 0xf0, 0xd, 0x8b, 0x2d, 0xe8, 0xc5}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa4, 0xa9, 0x7c, 0xc7, 0xb, 0x61, 0x6e, 0x91, 0x24, 0xd3, 0x3c, 0x33, 0xb4, 0x29, 0x3e, 0xad, 0x58, 0x67, 0x7a, 0x3a, 0xe1, 0x14, 0xa3, 0xd4, 0x8d, 0xb1, 0x68}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1a, 0x6c}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; -lwmqtt_sub_options_t sub_opts[6]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = true; -sub_opts[0].no_local = true; -sub_opts[1].qos = LWMQTT_QOS0; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = true; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS0; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = true; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS1; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[5].retain_as_published = true; -sub_opts[5].no_local = false; - uint8_t bytesprops0[] = {0xb3, 0xc7, 0x3a, 0x47, 0x80, 0x79, 0x42, 0xa1, 0x68, 0x51, 0x1f, 0x62}; - uint8_t bytesprops1[] = {0x21, 0xf1, 0xe7, 0xae, 0x59, 0x2, 0xb2, 0xf5, 0x22, 0xb6}; - uint8_t bytesprops2[] = {0xf3, 0x41, 0x74, 0xf9, 0x12, 0x34, 0x8b, 0x80, 0x82, 0xa1, 0xe0, 0xbd, 0xb7, 0x51, 0xf4, 0x3c, 0x2a, 0x52, 0x8e, 0x86, 0x81}; - uint8_t bytesprops3[] = {0x90, 0x3, 0xd2, 0x99, 0xd, 0xb, 0xa3, 0x20, 0xf, 0xf7, 0xea, 0xd0, 0x7b, 0x32, 0xa0, 0x34, 0x8e, 0xa5, 0x4b, 0x22, 0x61, 0x15}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11764}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11978}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7709}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11119}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11679}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3192}}, + uint8_t pkt[] = { + 0x82, 0xda, 0x2, 0x1, 0xf6, 0xf5, 0x1, 0x9, 0x0, 0x1d, 0x9, 0xc5, 0x5b, 0xe0, 0xec, 0x59, 0xce, 0x7d, 0x94, + 0xea, 0xb2, 0x50, 0xed, 0xde, 0x93, 0x28, 0xd9, 0xa2, 0x9a, 0xa, 0x4c, 0xc9, 0x7c, 0x6, 0xb8, 0x10, 0xf3, 0x97, + 0xfe, 0x29, 0xd1, 0x23, 0x5a, 0xcb, 0x22, 0x61, 0x51, 0x29, 0xa, 0x27, 0x0, 0x0, 0x6a, 0x4f, 0x1, 0x25, 0x3, + 0x0, 0x1b, 0x1b, 0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8, + 0x60, 0xc2, 0x7d, 0x3a, 0xf6, 0x0, 0xf, 0x1b, 0x1f, 0x6d, 0xd4, 0x17, 0xee, 0x39, 0xfc, 0x99, 0xbd, 0xa3, 0x53, + 0xea, 0x3d, 0x2b, 0xa, 0x0, 0x13, 0x7b, 0xdd, 0x5c, 0xe5, 0x20, 0x3a, 0xa2, 0xb7, 0xb1, 0x9d, 0xd0, 0xfd, 0x1c, + 0x90, 0x62, 0x53, 0xd9, 0x17, 0xb4, 0x28, 0x0, 0x1d, 0x55, 0x2c, 0xf3, 0x34, 0x17, 0xf1, 0x31, 0x8e, 0xdd, 0x6, + 0x23, 0x9, 0x6d, 0x89, 0x99, 0x83, 0x46, 0xc8, 0x93, 0x31, 0x99, 0xf2, 0xb0, 0xc0, 0xf1, 0x84, 0x3e, 0xc0, 0xae, + 0x1a, 0x0, 0x16, 0xf, 0xf, 0x13, 0x39, 0xe9, 0xe0, 0x19, 0x4d, 0x80, 0x4c, 0x35, 0xeb, 0x9c, 0x9d, 0x6f, 0xef, + 0x4e, 0x37, 0xac, 0x3a, 0x64, 0xf7, 0x2a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x1b, 0x1f, 0x6d, 0xd4, 0x17, 0xee, 0x39, 0xfc, + 0x99, 0xbd, 0xa3, 0x53, 0xea, 0x3d, 0x2b}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7b, 0xdd, 0x5c, 0xe5, 0x20, 0x3a, 0xa2, 0xb7, 0xb1, 0x9d, + 0xd0, 0xfd, 0x1c, 0x90, 0x62, 0x53, 0xd9, 0x17, 0xb4}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x55, 0x2c, 0xf3, 0x34, 0x17, 0xf1, 0x31, 0x8e, 0xdd, 0x6, + 0x23, 0x9, 0x6d, 0x89, 0x99, 0x83, 0x46, 0xc8, 0x93, 0x31, + 0x99, 0xf2, 0xb0, 0xc0, 0xf1, 0x84, 0x3e, 0xc0, 0xae}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf, 0xf, 0x13, 0x39, 0xe9, 0xe0, 0x19, 0x4d, 0x80, 0x4c, 0x35, + 0xeb, 0x9c, 0x9d, 0x6f, 0xef, 0x4e, 0x37, 0xac, 0x3a, 0x64, 0xf7}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + uint8_t bytesprops0[] = {0x9, 0xc5, 0x5b, 0xe0, 0xec, 0x59, 0xce, 0x7d, 0x94, 0xea, 0xb2, 0x50, 0xed, 0xde, 0x93, + 0x28, 0xd9, 0xa2, 0x9a, 0xa, 0x4c, 0xc9, 0x7c, 0x6, 0xb8, 0x10, 0xf3, 0x97, 0xfe}; + uint8_t bytesprops1[] = {0x1b, 0xaf, 0x2a, 0x21, 0x9d, 0xf9, 0x27, 0x9, 0x9e, 0x5c, 0xcc, 0x14, 0x9e, 0x42, + 0x6f, 0x7c, 0x8c, 0x1e, 0x2e, 0xca, 0x80, 0x20, 0x32, 0xf3, 0xe5, 0xb9, 0xe2}; + uint8_t bytesprops2[] = {0x7f, 0x3, 0x27, 0x8f, 0xf5, 0xbf, 0xe5, 0xc4, 0xb3, 0x24}; + uint8_t bytesprops3[] = {0xb1}; + uint8_t bytesprops4[] = {0x45, 0x15, 0x44, 0x33, 0x5b, 0xf4, 0x2a, 0xfe, 0xf8, 0xf6, 0x71, 0xd7, 0xb1, + 0xfa, 0x1e, 0x50, 0x55, 0x94, 0x2e, 0xb4, 0x5e, 0x14, 0x17, 0x23, 0x71, 0xda}; + uint8_t bytesprops5[] = {0x5, 0xb, 0xdd, 0x78, 0x30, 0x46, 0x6, 0x65, 0x17, 0x3c, 0xff, 0x5a, 0x53, 0x7f, + 0xa9, 0xe9, 0x4f, 0x3e, 0x7c, 0x30, 0xe, 0xe4, 0xac, 0x8e, 0x37, 0xe0, 0x37}; + uint8_t bytesprops6[] = {0x51, 0x6c, 0xea, 0xed, 0x63, 0xe0, 0xb, 0x97, 0x8, 0x47, 0x7f, 0x8d, 0x18}; + uint8_t bytesprops7[] = {0x9a, 0xa2, 0x54, 0x9d, 0xd8, 0xfc, 0xbb, 0x7e, 0x48, 0xe8, + 0x58, 0x3, 0x3e, 0x92, 0xc4, 0xea, 0x2f, 0xdb, 0xef, 0xc2}; + uint8_t bytesprops8[] = {0x46, 0x38, 0x70, 0x47, 0x9e}; + uint8_t bytesprops9[] = {0x7e, 0xbf, 0xd8, 0x60, 0xc2, 0x7d, 0x3a, 0xf6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23243}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24913}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27215}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1767}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26111}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28561}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13192}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27793, 6, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 502, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 30311 [("a\220\187\230\175\184\177\131\&8n\180}\229Z",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\234\199\181\DC1N\b",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropMaximumQoS 66,PropMaximumPacketSize 1305,PropUserProperty "\DEL\DC4#\197Y\192k\218\246D\208\177\&2`\SYN\158\177\153\251\205/##Yq" "\187z\212\171\b]\146Q\190X\193\SOH\140\&1aw \219\200",PropReceiveMaximum 19885] +// SubscribeRequest 27247 +// [("\137\230\141\ACK\169\178P\242\SUB\143Ml]\220\&1<\251\195\206\187\139$\167\174\\zW",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("<\235\&2\233\188SY\DC2}N",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS0}),("\169\156\DC4\199\SUBt\235!\GS\198\SUB\142i\208\aj\\\NAKG\a",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("h\252u[I\131\&8\238i\235/\165{\147\159\226/G\208\207npWu\ACKc\150@",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\132*T\ETB!\169\180\173\239t=",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS2}),("\184\198;\ETX\221\STX\202\227[\197q;6\189\n\169",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("x30\199\163\193",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("s\226\229\185N]\173-\176\199\183\201\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = True, _subQoS = +// QoS0}),("\228\134\195\198\239\232\245\153\ACKd.\130%$9D\237\231\158\SOH\160\242\151\170\\I",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0})] [PropCorrelationData +// "\247\167\151\238U\DEL\SYN\142\241(\198\136U\175Z\155\227\188`*\"t\237\137\222",PropRequestResponseInformation +// 222,PropSubscriptionIdentifierAvailable 126,PropContentType +// "\NAK\164O=h\238$\166",PropSubscriptionIdentifierAvailable 108,PropMessageExpiryInterval +// 31722,PropMessageExpiryInterval 12051,PropRequestResponseInformation 74,PropRetainAvailable +// 231,PropSharedSubscriptionAvailable 188,PropTopicAlias 4372,PropContentType +// "\130\144\SUB\236o:W\f\135\RSQ}\165",PropServerReference +// "0Q\241\EOT\192'\150u\219\171\242c\190\236\234\204\&0",PropTopicAlias 19724,PropMaximumPacketSize +// 17874,PropRequestResponseInformation 116,PropRetainAvailable 20,PropMaximumQoS 24,PropMaximumPacketSize +// 16124,PropAuthenticationData "\189\212\SI\182",PropReasonString +// "\233h\SI\133\ACK\253\232\156\184\228\164\ESC\n\STX\241\155U",PropUserProperty +// "4:l\200P\SUB\n\164\NUL7\132\172w\201\209BOE8\224\251\DC2\228\SI\FS\197\154" "\184\245l\232\178\fy[\128"] TEST(Subscribe5QCTest, Encode7) { -uint8_t pkt[] = {0x82, 0x5b, 0x76, 0x67, 0x3b, 0x24, 0x42, 0x27, 0x0, 0x0, 0x5, 0x19, 0x26, 0x0, 0x19, 0x7f, 0x14, 0x23, 0xc5, 0x59, 0xc0, 0x6b, 0xda, 0xf6, 0x44, 0xd0, 0xb1, 0x32, 0x60, 0x16, 0x9e, 0xb1, 0x99, 0xfb, 0xcd, 0x2f, 0x23, 0x23, 0x59, 0x71, 0x0, 0x13, 0xbb, 0x7a, 0xd4, 0xab, 0x8, 0x5d, 0x92, 0x51, 0xbe, 0x58, 0xc1, 0x1, 0x8c, 0x31, 0x61, 0x77, 0x20, 0xdb, 0xc8, 0x21, 0x4d, 0xad, 0x0, 0xe, 0x61, 0xdc, 0xbb, 0xe6, 0xaf, 0xb8, 0xb1, 0x83, 0x38, 0x6e, 0xb4, 0x7d, 0xe5, 0x5a, 0x10, 0x0, 0x6, 0xea, 0xc7, 0xb5, 0x11, 0x4e, 0x8, 0x2a, 0x0, 0x0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x61, 0xdc, 0xbb, 0xe6, 0xaf, 0xb8, 0xb1, 0x83, 0x38, 0x6e, 0xb4, 0x7d, 0xe5, 0x5a}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xea, 0xc7, 0xb5, 0x11, 0x4e, 0x8}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; -lwmqtt_sub_options_t sub_opts[3]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[1].retain_as_published = true; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; - uint8_t bytesprops1[] = {0xbb, 0x7a, 0xd4, 0xab, 0x8, 0x5d, 0x92, 0x51, 0xbe, 0x58, 0xc1, 0x1, 0x8c, 0x31, 0x61, 0x77, 0x20, 0xdb, 0xc8}; - uint8_t bytesprops0[] = {0x7f, 0x14, 0x23, 0xc5, 0x59, 0xc0, 0x6b, 0xda, 0xf6, 0x44, 0xd0, 0xb1, 0x32, 0x60, 0x16, 0x9e, 0xb1, 0x99, 0xfb, 0xcd, 0x2f, 0x23, 0x23, 0x59, 0x71}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1305}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={25, (char*)&bytesprops0}, .v={19, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19885}}, + uint8_t pkt[] = { + 0x82, 0xfd, 0x2, 0x6a, 0x6f, 0xbb, 0x1, 0x9, 0x0, 0x19, 0xf7, 0xa7, 0x97, 0xee, 0x55, 0x7f, 0x16, 0x8e, 0xf1, + 0x28, 0xc6, 0x88, 0x55, 0xaf, 0x5a, 0x9b, 0xe3, 0xbc, 0x60, 0x2a, 0x22, 0x74, 0xed, 0x89, 0xde, 0x19, 0xde, 0x29, + 0x7e, 0x3, 0x0, 0x8, 0x15, 0xa4, 0x4f, 0x3d, 0x68, 0xee, 0x24, 0xa6, 0x29,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14, 0x0, 0x14, 0xa9, 0x9c, 0x14, 0xc7, 0x1a, 0x74, 0xeb, 0x21, + 0x1d, 0xc6, 0x1a, 0x8e, 0x69, 0xd0, 0x7, 0x6a, 0x5c, 0x15, 0x47, 0x7, 0x2a, 0x0, 0x1c, 0x68, 0xfc, 0x75, 0x5b, + 0x49, 0x83, 0x38, 0xee, 0x69, 0xeb, 0x2f, 0xa5, 0x7b, 0x93, 0x9f, 0xe2, 0x2f, 0x47, 0xd0, 0xcf, 0x6e, 0x70, 0x57, + 0x75, 0x6, 0x63, 0x96, 0x40, 0x18, 0x0, 0x0, 0x2, 0x0, 0xb, 0x84, 0x2a, 0x54, 0x17, 0x21, 0xa9, 0xb4, 0xad, + 0xef, 0x74, 0x3d, 0x16, 0x0, 0x10, 0xb8, 0xc6, 0x3b, 0x3, 0xdd, 0x2, 0xca, 0xe3, 0x5b, 0xc5, 0x71, 0x3b, 0x36, + 0xbd, 0xa, 0xa9, 0x18, 0x0, 0x6, 0x78, 0x33, 0x30, 0xc7, 0xa3, 0xc1, 0x2, 0x0, 0xd, 0x73, 0xe2, 0xe5, 0xb9, + 0x4e, 0x5d, 0xad, 0x2d, 0xb0, 0xc7, 0xb7, 0xc9, 0xdb, 0x4, 0x0, 0x1a, 0xe4, 0x86, 0xc3, 0xc6, 0xef, 0xe8, 0xf5, + 0x99, 0x6, 0x64, 0x2e, 0x82, 0x25, 0x24, 0x39, 0x44, 0xed, 0xe7, 0x9e, 0x1, 0xa0, 0xf2, 0x97, 0xaa, 0x5c, 0x49, + 0x21, 0x0, 0x0, 0x1c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x89, 0xe6, 0x8d, 0x6, 0xa9, 0xb2, 0x50, 0xf2, 0x1a, 0x8f, 0x4d, 0x6c, 0x5d, 0xdc, + 0x31, 0x3c, 0xfb, 0xc3, 0xce, 0xbb, 0x8b, 0x24, 0xa7, 0xae, 0x5c, 0x7a, 0x57}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x3c, 0xeb, 0x32, 0xe9, 0xbc, 0x53, 0x59, 0x12, 0x7d, 0x4e}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa9, 0x9c, 0x14, 0xc7, 0x1a, 0x74, 0xeb, 0x21, 0x1d, 0xc6, + 0x1a, 0x8e, 0x69, 0xd0, 0x7, 0x6a, 0x5c, 0x15, 0x47, 0x7}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x68, 0xfc, 0x75, 0x5b, 0x49, 0x83, 0x38, 0xee, 0x69, 0xeb, + 0x2f, 0xa5, 0x7b, 0x93, 0x9f, 0xe2, 0x2f, 0x47, 0xd0, 0xcf, + 0x6e, 0x70, 0x57, 0x75, 0x6, 0x63, 0x96, 0x40}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x84, 0x2a, 0x54, 0x17, 0x21, 0xa9, 0xb4, 0xad, 0xef, 0x74, 0x3d}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xb8, 0xc6, 0x3b, 0x3, 0xdd, 0x2, 0xca, 0xe3, + 0x5b, 0xc5, 0x71, 0x3b, 0x36, 0xbd, 0xa, 0xa9}; + lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x78, 0x33, 0x30, 0xc7, 0xa3, 0xc1}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x73, 0xe2, 0xe5, 0xb9, 0x4e, 0x5d, 0xad, 0x2d, 0xb0, 0xc7, 0xb7, 0xc9, 0xdb}; + lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xe4, 0x86, 0xc3, 0xc6, 0xef, 0xe8, 0xf5, 0x99, 0x6, 0x64, 0x2e, 0x82, 0x25, + 0x24, 0x39, 0x44, 0xed, 0xe7, 0x9e, 0x1, 0xa0, 0xf2, 0x97, 0xaa, 0x5c, 0x49}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = true; + uint8_t bytesprops0[] = {0xf7, 0xa7, 0x97, 0xee, 0x55, 0x7f, 0x16, 0x8e, 0xf1, 0x28, 0xc6, 0x88, 0x55, + 0xaf, 0x5a, 0x9b, 0xe3, 0xbc, 0x60, 0x2a, 0x22, 0x74, 0xed, 0x89, 0xde}; + uint8_t bytesprops1[] = {0x15, 0xa4, 0x4f, 0x3d, 0x68, 0xee, 0x24, 0xa6}; + uint8_t bytesprops2[] = {0x82, 0x90, 0x1a, 0xec, 0x6f, 0x3a, 0x57, 0xc, 0x87, 0x1e, 0x51, 0x7d, 0xa5}; + uint8_t bytesprops3[] = {0x30, 0x51, 0xf1, 0x4, 0xc0, 0x27, 0x96, 0x75, 0xdb, + 0xab, 0xf2, 0x63, 0xbe, 0xec, 0xea, 0xcc, 0x30}; + uint8_t bytesprops4[] = {0xbd, 0xd4, 0xf, 0xb6}; + uint8_t bytesprops5[] = {0xe9, 0x68, 0xf, 0x85, 0x6, 0xfd, 0xe8, 0x9c, 0xb8, + 0xe4, 0xa4, 0x1b, 0xa, 0x2, 0xf1, 0x9b, 0x55}; + uint8_t bytesprops7[] = {0xb8, 0xf5, 0x6c, 0xe8, 0xb2, 0xc, 0x79, 0x5b, 0x80}; + uint8_t bytesprops6[] = {0x34, 0x3a, 0x6c, 0xc8, 0x50, 0x1a, 0xa, 0xa4, 0x0, 0x37, 0x84, 0xac, 0x77, 0xc9, + 0xd1, 0x42, 0x4f, 0x45, 0x38, 0xe0, 0xfb, 0x12, 0xe4, 0xf, 0x1c, 0xc5, 0x9a}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31722}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12051}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4372}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19724}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17874}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16124}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops6}, .v = {9, (char*)&bytesprops7}}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30311, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27247, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 32651 [("\168U\NULn\148",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("k\141i\169",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\ESC\250F\175_R",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\187\219|!\193M\251\187\176h\ETB",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\155m$\224\202\136\212\255\150=\242\197\195P\SUB\211",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\193\143\128\SOH5\150K6\STX",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropReceiveMaximum 4662,PropServerReference "\185\147*\251\135\214-i\235X\131\150N\212\218WAt;f\178\154\151\134\196\201\ACK",PropRequestResponseInformation 121,PropSharedSubscriptionAvailable 183,PropTopicAliasMaximum 1031,PropWildcardSubscriptionAvailable 176,PropWillDelayInterval 19156,PropAuthenticationData "@\236w\239\151\215\165dQ\146\ETBlx\DELr\150\SIP/\ACK\182\DLEf\224\155/\DC3\SO\NAK",PropSubscriptionIdentifierAvailable 108,PropSessionExpiryInterval 24703,PropSessionExpiryInterval 14135,PropReasonString "\183b\177\178E\239?\243\EOT\166\160\215QXm\ETB",PropSessionExpiryInterval 448,PropPayloadFormatIndicator 126] +// SubscribeRequest 15611 [("\NUL\212p\201h\br'2ko\162\SYN\242U\173Sp\182\184",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropWillDelayInterval +// 16059,PropReceiveMaximum 18847,PropTopicAlias 31233,PropMessageExpiryInterval 17329,PropAuthenticationMethod +// "\228\166\137|\201X\211\ETX\ETBR\SO\247\fL\n\187\EOT\td\183\155u\146O\196\194\194j",PropPayloadFormatIndicator +// 20,PropWillDelayInterval 14778,PropServerReference "z\ETX\168\180\ETX-\244' \143",PropMessageExpiryInterval +// 23767,PropTopicAliasMaximum 583,PropMessageExpiryInterval 13968,PropRequestResponseInformation +// 60,PropSessionExpiryInterval 26412,PropTopicAliasMaximum 7853,PropSubscriptionIdentifierAvailable +// 16,PropTopicAliasMaximum 3303,PropPayloadFormatIndicator 55,PropMaximumQoS 160,PropUserProperty "K\SYNA\163\NUL\221U" +// "\183\v$r\161\250 f\167\ESC\215\136\160\175",PropTopicAlias 13301,PropRequestProblemInformation 216] TEST(Subscribe5QCTest, Encode8) { -uint8_t pkt[] = {0x82, 0xbd, 0x1, 0x7f, 0x8b, 0x75, 0x21, 0x12, 0x36, 0x1c, 0x0, 0x1b, 0xb9, 0x93, 0x2a, 0xfb, 0x87, 0xd6, 0x2d, 0x69, 0xeb, 0x58, 0x83, 0x96, 0x4e, 0xd4, 0xda, 0x57, 0x41, 0x74, 0x3b, 0x66, 0xb2, 0x9a, 0x97, 0x86, 0xc4, 0xc9, 0x6, 0x19, 0x79, 0x2a, 0xb7, 0x22, 0x4, 0x7, 0x28, 0xb0, 0x18, 0x0, 0x0, 0x4a, 0xd4, 0x16, 0x0, 0x1d, 0x40, 0xec, 0x77, 0xef, 0x97, 0xd7, 0xa5, 0x64, 0x51, 0x92, 0x17, 0x6c, 0x78, 0x7f, 0x72, 0x96, 0xf, 0x50, 0x2f, 0x6, 0xb6, 0x10, 0x66, 0xe0, 0x9b, 0x2f, 0x13, 0xe, 0x15, 0x29, 0x6c, 0x11, 0x0, 0x0, 0x60, 0x7f, 0x11, 0x0, 0x0, 0x37, 0x37, 0x1f, 0x0, 0x10, 0xb7, 0x62, 0xb1, 0xb2, 0x45, 0xef, 0x3f, 0xf3, 0x4, 0xa6, 0xa0, 0xd7, 0x51, 0x58, 0x6d, 0x17, 0x11, 0x0, 0x0, 0x1, 0xc0, 0x1, 0x7e, 0x0, 0x5, 0xa8, 0x55, 0x0, 0x6e, 0x94, 0x20, 0x0, 0x4, 0x6b, 0x8d, 0x69, 0xa9, 0x29, 0x0, 0x6, 0x1b, 0xfa, 0x46, 0xaf, 0x5f, 0x52, 0x22, 0x0, 0xb, 0xbb, 0xdb, 0x7c, 0x21, 0xc1, 0x4d, 0xfb, 0xbb, 0xb0, 0x68, 0x17, 0x24, 0x0, 0x10, 0x9b, 0x6d, 0x24, 0xe0, 0xca, 0x88, 0xd4, 0xff, 0x96, 0x3d, 0xf2, 0xc5, 0xc3, 0x50, 0x1a, 0xd3, 0x12, 0x0, 0x9, 0xc1, 0x8f, 0x80, 0x1, 0x35, 0x96, 0x4b, 0x36, 0x2, 0x8}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xa8, 0x55, 0x0, 0x6e, 0x94}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6b, 0x8d, 0x69, 0xa9}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1b, 0xfa, 0x46, 0xaf, 0x5f, 0x52}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xbb, 0xdb, 0x7c, 0x21, 0xc1, 0x4d, 0xfb, 0xbb, 0xb0, 0x68, 0x17}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9b, 0x6d, 0x24, 0xe0, 0xca, 0x88, 0xd4, 0xff, 0x96, 0x3d, 0xf2, 0xc5, 0xc3, 0x50, 0x1a, 0xd3}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc1, 0x8f, 0x80, 0x1, 0x35, 0x96, 0x4b, 0x36, 0x2}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; -lwmqtt_sub_options_t sub_opts[6]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[1].retain_as_published = true; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS0; -sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = true; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = true; -sub_opts[5].no_local = false; - uint8_t bytesprops0[] = {0xb9, 0x93, 0x2a, 0xfb, 0x87, 0xd6, 0x2d, 0x69, 0xeb, 0x58, 0x83, 0x96, 0x4e, 0xd4, 0xda, 0x57, 0x41, 0x74, 0x3b, 0x66, 0xb2, 0x9a, 0x97, 0x86, 0xc4, 0xc9, 0x6}; - uint8_t bytesprops1[] = {0x40, 0xec, 0x77, 0xef, 0x97, 0xd7, 0xa5, 0x64, 0x51, 0x92, 0x17, 0x6c, 0x78, 0x7f, 0x72, 0x96, 0xf, 0x50, 0x2f, 0x6, 0xb6, 0x10, 0x66, 0xe0, 0x9b, 0x2f, 0x13, 0xe, 0x15}; - uint8_t bytesprops2[] = {0xb7, 0x62, 0xb1, 0xb2, 0x45, 0xef, 0x3f, 0xf3, 0x4, 0xa6, 0xa0, 0xd7, 0x51, 0x58, 0x6d, 0x17}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4662}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1031}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19156}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24703}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14135}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 448}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 126}}, + uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x3c, 0xfb, 0x82, 0x1, 0x18, 0x0, 0x0, 0x3e, 0xbb, 0x21, 0x49, 0x9f, 0x23, + 0x7a, 0x1, 0x2, 0x0, 0x0, 0x43, 0xb1, 0x15, 0x0, 0x1c, 0xe4, 0xa6, 0x89, 0x7c, 0xc9, 0x58, + 0xd3, 0x3, 0x17, 0x52, 0xe, 0xf7, 0xc, 0x4c, 0xa, 0xbb, 0x4, 0x9, 0x64, 0xb7, 0x9b, 0x75, + 0x92, 0x4f, 0xc4, 0xc2, 0xc2, 0x6a, 0x1, 0x14, 0x18, 0x0, 0x0, 0x39, 0xba, 0x1c, 0x0, 0xa, + 0x7a, 0x3, 0xa8, 0xb4, 0x3, 0x2d, 0xf4, 0x27, 0x20, 0x8f, 0x2, 0x0, 0x0, 0x5c, 0xd7, 0x22, + 0x2, 0x47, 0x2, 0x0, 0x0, 0x36, 0x90, 0x19, 0x3c, 0x11, 0x0, 0x0, 0x67, 0x2c, 0x22, 0x1e, + 0xad, 0x29, 0x10, 0x22, 0xc, 0xe7, 0x1, 0x37, 0x24, 0xa0, 0x26, 0x0, 0x7, 0x4b, 0x16, 0x41, + 0xa3, 0x0, 0xdd, 0x55, 0x0, 0xe, 0xb7, 0xb, 0x24, 0x72, 0xa1, 0xfa, 0x20, 0x66, 0xa7, 0x1b, + 0xd7, 0x88, 0xa0, 0xaf, 0x23, 0x33, 0xf5, 0x17, 0xd8, 0x0, 0x14, 0x0, 0xd4, 0x70, 0xc9, 0x68, + 0x8, 0x72, 0x27, 0x32, 0x6b, 0x6f, 0xa2, 0x16, 0xf2, 0x55, 0xad, 0x53, 0x70, 0xb6, 0xb8, 0x4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x0, 0xd4, 0x70, 0xc9, 0x68, 0x8, 0x72, 0x27, 0x32, 0x6b, + 0x6f, 0xa2, 0x16, 0xf2, 0x55, 0xad, 0x53, 0x70, 0xb6, 0xb8}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + uint8_t bytesprops0[] = {0xe4, 0xa6, 0x89, 0x7c, 0xc9, 0x58, 0xd3, 0x3, 0x17, 0x52, 0xe, 0xf7, 0xc, 0x4c, + 0xa, 0xbb, 0x4, 0x9, 0x64, 0xb7, 0x9b, 0x75, 0x92, 0x4f, 0xc4, 0xc2, 0xc2, 0x6a}; + uint8_t bytesprops1[] = {0x7a, 0x3, 0xa8, 0xb4, 0x3, 0x2d, 0xf4, 0x27, 0x20, 0x8f}; + uint8_t bytesprops3[] = {0xb7, 0xb, 0x24, 0x72, 0xa1, 0xfa, 0x20, 0x66, 0xa7, 0x1b, 0xd7, 0x88, 0xa0, 0xaf}; + uint8_t bytesprops2[] = {0x4b, 0x16, 0x41, 0xa3, 0x0, 0xdd, 0x55}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16059}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18847}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31233}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17329}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14778}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23767}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 583}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13968}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26412}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7853}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3303}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops2}, .v = {14, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13301}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 216}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32651, 6, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15611, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 15465 [("\234y<\176R ]*\193\136",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\DC3v\b\SOH9",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("6'\ACK}p\CAN\144g\147~\200\182&\173\176\128%ev\142\SIT\254\138\&1h\US\169\210R",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropWillDelayInterval 2288,PropCorrelationData "\211\FS\ACK&\a\251\EOT\184RW\193l8K\249",PropAuthenticationMethod "\158N2 qL\156\209\141.\218{\137\206\234\159F(\187\195\215\246k2\139\177",PropCorrelationData "\251\\\SYN\244\&7\208\199\248\t\170\&5\146\155\172j\231\177\137\211\ETBK\136\SOH\133",PropPayloadFormatIndicator 176,PropMaximumPacketSize 8470,PropCorrelationData "^\243\179\128\DC4M.bt\r\186.",PropAuthenticationData "K\185\137\&9\155Sa\FS\199k\200R.\142y\158\158]\220\188\STX\r=\RS\185"] +// SubscribeRequest 16791 [("\\\ACK\129B1\149Y/2\178vx\RSo",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\157\170\249\222\&8\248\181\190\212q\151\133\186\245\171\223g1)U\206\a\135",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("y\245\244\225K\177[\153B\179@\161\193",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = True, _noLocal = True, _subQoS = QoS2}),("\146\247\211\182H z\bK\191\RS\194V\134\&8$\221;8",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\167\159W\185-u;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS0}),("X\246\247\218G\162mZ(\DEL\EM\172",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\152X9\166\177\RS\226\222\212\128",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\236\NAK\169\245",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("@I\210\CAN\210\EM\200\RS\186\ETB\235\180$\182\167\155\138\135>'\246",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] +// [PropSubscriptionIdentifier 30,PropTopicAliasMaximum 28275,PropSubscriptionIdentifierAvailable +// 70,PropSharedSubscriptionAvailable 178,PropTopicAlias 18035,PropMessageExpiryInterval 13889,PropMaximumPacketSize +// 19219,PropReceiveMaximum 11664,PropPayloadFormatIndicator 124,PropAuthenticationData +// "\226\129.\DC2R\ACK\238a\205\DEL\163\STX\182\SYNJK",PropUserProperty "{s\129m\228\218\210\192#zl" +// "\186\138\139r'\199\228\164$=\SYN",PropMaximumPacketSize 483,PropRequestProblemInformation 66] TEST(Subscribe5QCTest, Encode9) { -uint8_t pkt[] = {0x82, 0xbb, 0x1, 0x3c, 0x69, 0x81, 0x1, 0x18, 0x0, 0x0, 0x8, 0xf0, 0x9, 0x0, 0xf, 0xd3, 0x1c, 0x6, 0x26, 0x7, 0xfb, 0x4, 0xb8, 0x52, 0x57, 0xc1, 0x6c, 0x38, 0x4b, 0xf9, 0x15, 0x0, 0x1a, 0x9e, 0x4e, 0x32, 0x20, 0x71, 0x4c, 0x9c, 0xd1, 0x8d, 0x2e, 0xda, 0x7b, 0x89, 0xce, 0xea, 0x9f, 0x46, 0x28, 0xbb, 0xc3, 0xd7, 0xf6, 0x6b, 0x32, 0x8b, 0xb1, 0x9, 0x0, 0x18, 0xfb, 0x5c, 0x16, 0xf4, 0x37, 0xd0, 0xc7, 0xf8, 0x9, 0xaa, 0x35, 0x92, 0x9b, 0xac, 0x6a, 0xe7, 0xb1, 0x89, 0xd3, 0x17, 0x4b, 0x88, 0x1, 0x85, 0x1, 0xb0, 0x27, 0x0, 0x0, 0x21, 0x16, 0x9, 0x0, 0xc, 0x5e, 0xf3, 0xb3, 0x80, 0x14, 0x4d, 0x2e, 0x62, 0x74, 0xd, 0xba, 0x2e, 0x16, 0x0, 0x19, 0x4b, 0xb9, 0x89, 0x39, 0x9b, 0x53, 0x61, 0x1c, 0xc7, 0x6b, 0xc8, 0x52, 0x2e, 0x8e, 0x79, 0x9e, 0x9e, 0x5d, 0xdc, 0xbc, 0x2, 0xd, 0x3d, 0x1e, 0xb9, 0x0, 0xa, 0xea, 0x79, 0x3c, 0xb0, 0x52, 0x20, 0x5d, 0x2a, 0xc1, 0x88, 0x11, 0x0, 0x5, 0x13, 0x76, 0x8, 0x1, 0x39, 0x25, 0x0, 0x1e, 0x36, 0x27, 0x6, 0x7d, 0x70, 0x18, 0x90, 0x67, 0x93, 0x7e, 0xc8, 0xb6, 0x26, 0xad, 0xb0, 0x80, 0x25, 0x65, 0x76, 0x8e, 0xf, 0x54, 0xfe, 0x8a, 0x31, 0x68, 0x1f, 0xa9, 0xd2, 0x52, 0x1c}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xea, 0x79, 0x3c, 0xb0, 0x52, 0x20, 0x5d, 0x2a, 0xc1, 0x88}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x13, 0x76, 0x8, 0x1, 0x39}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x36, 0x27, 0x6, 0x7d, 0x70, 0x18, 0x90, 0x67, 0x93, 0x7e, 0xc8, 0xb6, 0x26, 0xad, 0xb0, 0x80, 0x25, 0x65, 0x76, 0x8e, 0xf, 0x54, 0xfe, 0x8a, 0x31, 0x68, 0x1f, 0xa9, 0xd2, 0x52}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; -lwmqtt_sub_options_t sub_opts[3]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = true; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[2].retain_as_published = true; -sub_opts[2].no_local = true; - uint8_t bytesprops0[] = {0xd3, 0x1c, 0x6, 0x26, 0x7, 0xfb, 0x4, 0xb8, 0x52, 0x57, 0xc1, 0x6c, 0x38, 0x4b, 0xf9}; - uint8_t bytesprops1[] = {0x9e, 0x4e, 0x32, 0x20, 0x71, 0x4c, 0x9c, 0xd1, 0x8d, 0x2e, 0xda, 0x7b, 0x89, 0xce, 0xea, 0x9f, 0x46, 0x28, 0xbb, 0xc3, 0xd7, 0xf6, 0x6b, 0x32, 0x8b, 0xb1}; - uint8_t bytesprops2[] = {0xfb, 0x5c, 0x16, 0xf4, 0x37, 0xd0, 0xc7, 0xf8, 0x9, 0xaa, 0x35, 0x92, 0x9b, 0xac, 0x6a, 0xe7, 0xb1, 0x89, 0xd3, 0x17, 0x4b, 0x88, 0x1, 0x85}; - uint8_t bytesprops3[] = {0x5e, 0xf3, 0xb3, 0x80, 0x14, 0x4d, 0x2e, 0x62, 0x74, 0xd, 0xba, 0x2e}; - uint8_t bytesprops4[] = {0x4b, 0xb9, 0x89, 0x39, 0x9b, 0x53, 0x61, 0x1c, 0xc7, 0x6b, 0xc8, 0x52, 0x2e, 0x8e, 0x79, 0x9e, 0x9e, 0x5d, 0xdc, 0xbc, 0x2, 0xd, 0x3d, 0x1e, 0xb9}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2288}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8470}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops4}}}, - }; + uint8_t pkt[] = {0x82, 0xe9, 0x1, 0x41, 0x97, 0x50, 0xb, 0x1e, 0x22, 0x6e, 0x73, 0x29, 0x46, 0x2a, 0xb2, 0x23, 0x46, + 0x73, 0x2, 0x0, 0x0, 0x36, 0x41, 0x27, 0x0, 0x0, 0x4b, 0x13, 0x21, 0x2d, 0x90, 0x1, 0x7c, 0x16, + 0x0, 0x10, 0xe2, 0x81, 0x2e, 0x12, 0x52, 0x6, 0xee, 0x61, 0xcd, 0x7f, 0xa3, 0x2, 0xb6, 0x16, 0x4a, + 0x4b, 0x26, 0x0, 0xb, 0x7b, 0x73, 0x81, 0x6d, 0xe4, 0xda, 0xd2, 0xc0, 0x23, 0x7a, 0x6c, 0x0, 0xb, + 0xba, 0x8a, 0x8b, 0x72, 0x27, 0xc7, 0xe4, 0xa4, 0x24, 0x3d, 0x16, 0x27, 0x0, 0x0, 0x1, 0xe3, 0x17, + 0x42, 0x0, 0xe, 0x5c, 0x6, 0x81, 0x42, 0x31, 0x95, 0x59, 0x2f, 0x32, 0xb2, 0x76, 0x78, 0x1e, 0x6f, + 0x16, 0x0, 0x17, 0x9d, 0xaa, 0xf9, 0xde, 0x38, 0xf8, 0xb5, 0xbe, 0xd4, 0x71, 0x97, 0x85, 0xba, 0xf5, + 0xab, 0xdf, 0x67, 0x31, 0x29, 0x55, 0xce, 0x7, 0x87, 0xe, 0x0, 0xd, 0x79, 0xf5, 0xf4, 0xe1, 0x4b, + 0xb1, 0x5b, 0x99, 0x42, 0xb3, 0x40, 0xa1, 0xc1, 0x1e, 0x0, 0x13, 0x92, 0xf7, 0xd3, 0xb6, 0x48, 0x20, + 0x7a, 0x8, 0x4b, 0xbf, 0x1e, 0xc2, 0x56, 0x86, 0x38, 0x24, 0xdd, 0x3b, 0x38, 0xa, 0x0, 0x7, 0xa7, + 0x9f, 0x57, 0xb9, 0x2d, 0x75, 0x3b, 0x8, 0x0, 0xc, 0x58, 0xf6, 0xf7, 0xda, 0x47, 0xa2, 0x6d, 0x5a, + 0x28, 0x7f, 0x19, 0xac, 0x5, 0x0, 0xa, 0x98, 0x58, 0x39, 0xa6, 0xb1, 0x1e, 0xe2, 0xde, 0xd4, 0x80, + 0x1e, 0x0, 0x4, 0xec, 0x15, 0xa9, 0xf5, 0x0, 0x0, 0x15, 0x40, 0x49, 0xd2, 0x18, 0xd2, 0x19, 0xc8, + 0x1e, 0xba, 0x17, 0xeb, 0xb4, 0x24, 0xb6, 0xa7, 0x9b, 0x8a, 0x87, 0x3e, 0x27, 0xf6, 0x24}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x5c, 0x6, 0x81, 0x42, 0x31, 0x95, 0x59, 0x2f, 0x32, 0xb2, 0x76, 0x78, 0x1e, 0x6f}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x9d, 0xaa, 0xf9, 0xde, 0x38, 0xf8, 0xb5, 0xbe, 0xd4, 0x71, 0x97, 0x85, + 0xba, 0xf5, 0xab, 0xdf, 0x67, 0x31, 0x29, 0x55, 0xce, 0x7, 0x87}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x79, 0xf5, 0xf4, 0xe1, 0x4b, 0xb1, 0x5b, 0x99, 0x42, 0xb3, 0x40, 0xa1, 0xc1}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x92, 0xf7, 0xd3, 0xb6, 0x48, 0x20, 0x7a, 0x8, 0x4b, 0xbf, + 0x1e, 0xc2, 0x56, 0x86, 0x38, 0x24, 0xdd, 0x3b, 0x38}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa7, 0x9f, 0x57, 0xb9, 0x2d, 0x75, 0x3b}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x58, 0xf6, 0xf7, 0xda, 0x47, 0xa2, 0x6d, 0x5a, 0x28, 0x7f, 0x19, 0xac}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x98, 0x58, 0x39, 0xa6, 0xb1, 0x1e, 0xe2, 0xde, 0xd4, 0x80}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xec, 0x15, 0xa9, 0xf5}; + lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x40, 0x49, 0xd2, 0x18, 0xd2, 0x19, 0xc8, 0x1e, 0xba, 0x17, 0xeb, + 0xb4, 0x24, 0xb6, 0xa7, 0x9b, 0x8a, 0x87, 0x3e, 0x27, 0xf6}; + lwmqtt_string_t topic_filter_s8 = {21, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; + uint8_t bytesprops0[] = {0xe2, 0x81, 0x2e, 0x12, 0x52, 0x6, 0xee, 0x61, + 0xcd, 0x7f, 0xa3, 0x2, 0xb6, 0x16, 0x4a, 0x4b}; + uint8_t bytesprops2[] = {0xba, 0x8a, 0x8b, 0x72, 0x27, 0xc7, 0xe4, 0xa4, 0x24, 0x3d, 0x16}; + uint8_t bytesprops1[] = {0x7b, 0x73, 0x81, 0x6d, 0xe4, 0xda, 0xd2, 0xc0, 0x23, 0x7a, 0x6c}; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28275}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18035}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13889}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19219}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11664}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 483}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 66}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15465, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16791, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 31381 [("\230\234.\186\229\249Tuf\222\188\DC4 \193J\t\DLE}\156<\255\150\156\146\136\132\a",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\143\&6\250ODD\155\192\210\157\152",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\240ni\SUB}\189/\167\&4\ACK\213\129o\150",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropWildcardSubscriptionAvailable 59] +// SubscribeRequest 26959 [("O\ESCB(\149\146o\177\249\238&\152\222\148\225\208k<",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\163\ACK\208\ETX}\235\ESC\230\193\202s",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\140>8\177\CAN\US\187w\173\n~\"",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("AdT[\254[\152\249\SUBhe%e\185",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS2}),("\201\230\EM\GS4\DC4\233BO]\165",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\245\148@\246iy\SUB}\r\199\224\149",PropMessageExpiryInterval 8464,PropRequestResponseInformation 192,PropAssignedClientIdentifier "\212\215\253#\214$\160\&0\163\237\128\134\US?\180\212\219"] +// SubscribeRequest 12270 [("7\235R8?\\\200\&7^jN\237\DC2\229\&6O7",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\154\223\186^\201\164\207\230\160\GSi\205\210\204=(\196\CAN\191H\169D`",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\254\248p\NUL5\\\140j\"\ETX\185\251\223\242+'\214\223z\229\247\219\225Y\ETB\FS\ESC\ESC\254",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\213\190 +// \178\176o\172\166\217\173E\167`)\b\EM\EM\249\204_\DLE\152`\179P",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("w\ESCURkJ\215\186\129\131\NAK\"\139d\\\246\228\ESC\SOHA\EM\218D\215\211*",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\186H[`\183\255",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\170+\DEL:4\218\131z(#\199^O}\a\193\&0\181\231\231\187\187P\239",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropRetainAvailable +// 149,PropReasonString +// "\219?!\ETX\138J(v\227\238\210\237\GSu\189\137\&5N^\217F;\242\&7\137\NULl\181\178",PropTopicAliasMaximum +// 13282,PropReasonString "'\r\164I7\148~-",PropAuthenticationMethod +// "\167_\229\162\&8\DC4~\SI\149\131\147s\147\245Y\SOH\RS\167\f\205\245\131\SIl\SUB\191",PropResponseTopic +// "\"\DEL\173Y\174\r\151\133iQ0\137M\208\171\DC2\225\137\238}",PropReasonString +// "E\176\150\&2\255#\224&{\219\242\215\149g\217TW",PropCorrelationData "\161Ss<\192\194ct\146Z\157\169\151\&9\141 +// x\173K\147\r|_}\157",PropSubscriptionIdentifier 7,PropReasonString "\EM-",PropMessageExpiryInterval +// 15513,PropSubscriptionIdentifier 22,PropRetainAvailable 40,PropSubscriptionIdentifierAvailable +// 175,PropServerReference "\EOT\182\NAK5\158\&8\DC4\131 U\198\DC3\EOT@p\219Ix\237m\203\161W",PropRetainAvailable +// 30,PropAuthenticationData "\133\136y\187Lb{\218",PropTopicAlias 30717,PropContentType +// "\161\161\171\NUL\152RI\CAN\146\241\194\171\&9\186\145\174\227@\174/Ht\ETBi\242",PropMessageExpiryInterval +// 26831,PropUserProperty "\236\193\150\254\ETB\203\209\179{!}Q\139\170IG\FS\ba\240&'" +// ">\210\&4",PropRequestProblemInformation 91] TEST(Subscribe5QCTest, Encode12) { -uint8_t pkt[] = {0x82, 0x49, 0x53, 0xa4, 0x39, 0x24, 0x99, 0x15, 0x0, 0x5, 0xcf, 0x30, 0x3a, 0xa5, 0x4f, 0x15, 0x0, 0x11, 0x61, 0xa, 0x29, 0x2b, 0x6f, 0x80, 0x4f, 0xdf, 0x3, 0xf3, 0x4, 0x3e, 0x7d, 0xd, 0xc7, 0xe0, 0x95, 0x2, 0x0, 0x0, 0x21, 0x10, 0x19, 0xc0, 0x12, 0x0, 0x11, 0xd4, 0xd7, 0xfd, 0x23, 0xd6, 0x24, 0xa0, 0x30, 0xa3, 0xed, 0x80, 0x86, 0x1f, 0x3f, 0xb4, 0xd4, 0xdb, 0x0, 0xa, 0x77, 0xda, 0x5d, 0x72, 0x1b, 0x8f, 0x3c, 0x71, 0xf2, 0x4c, 0x4}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x77, 0xda, 0x5d, 0x72, 0x1b, 0x8f, 0x3c, 0x71, 0xf2, 0x4c}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; -lwmqtt_sub_options_t sub_opts[1]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = true; - uint8_t bytesprops0[] = {0xcf, 0x30, 0x3a, 0xa5, 0x4f}; - uint8_t bytesprops1[] = {0x61, 0xa, 0x29, 0x2b, 0x6f, 0x80, 0x4f, 0xdf, 0x3, 0xf3, 0x4, 0x3e, 0x7d, 0xd, 0xc7, 0xe0, 0x95}; - uint8_t bytesprops2[] = {0xd4, 0xd7, 0xfd, 0x23, 0xd6, 0x24, 0xa0, 0x30, 0xa3, 0xed, 0x80, 0x86, 0x1f, 0x3f, 0xb4, 0xd4, 0xdb}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8464}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops2}}}, + uint8_t pkt[] = { + 0x82, 0xc0, 0x3, 0x2f, 0xee, 0x91, 0x2, 0x25, 0x95, 0x1f, 0x0, 0x1d, 0xdb, 0x3f, 0x21, 0x3, 0x8a, 0x4a, 0x28, + 0x76, 0xe3, 0xee, 0xd2, 0xed, 0x1d, 0x75, 0xbd, 0x89, 0x35, 0x4e, 0x5e, 0xd9, 0x46, 0x3b, 0xf2, 0x37, 0x89, 0x0, + 0x6c, 0xb5, 0xb2, 0x22, 0x33, 0xe2, 0x1f, 0x0, 0x8, 0x27, 0xd, 0xa4, 0x49, 0x37, 0x94, 0x7e, 0x2d, 0x15, 0x0, + 0x1a, 0xa7, 0x5f, 0xe5, 0xa2, 0x38, 0x14, 0x7e, 0xf, 0x95, 0x83, 0x93, 0x73, 0x93, 0xf5, 0x59, 0x1, 0x1e, 0xa7, + 0xc, 0xcd, 0xf5, 0x83, 0xf, 0x6c, 0x1a, 0xbf, 0x8, 0x0, 0x14, 0x22, 0x7f, 0xad, 0x59, 0xae, 0xd, 0x97, 0x85, + 0x69, 0x51, 0x30, 0x89, 0x4d, 0xd0, 0xab, 0x12, 0xe1, 0x89, 0xee, 0x7d, 0x1f, 0x0, 0x11, 0x45, 0xb0, 0x96, 0x32, + 0xff, 0x23, 0xe0, 0x26, 0x7b, 0xdb, 0xf2, 0xd7, 0x95, 0x67, 0xd9, 0x54, 0x57, 0x9, 0x0, 0x19, 0xa1, 0x53, 0x73, + 0x3c, 0xc0, 0xc2, 0x63, 0x74, 0x92, 0x5a, 0x9d, 0xa9, 0x97, 0x39, 0x8d, 0x20, 0x78, 0xad, 0x4b, 0x93, 0xd, 0x7c, + 0x5f, 0x7d, 0x9d, 0xb, 0x7, 0x1f, 0x0, 0x2, 0x19, 0x2d, 0x2, 0x0, 0x0, 0x3c, 0x99, 0xb, 0x16, 0x25, 0x28, + 0x29, 0xaf, 0x1c, 0x0, 0x17, 0x4, 0xb6, 0x15, 0x35, 0x9e, 0x38, 0x14, 0x83, 0x20, 0x55, 0xc6, 0x13, 0x4, 0x40, + 0x70, 0xdb, 0x49, 0x78, 0xed, 0x6d, 0xcb, 0xa1, 0x57, 0x25, 0x1e, 0x16, 0x0, 0x8, 0x85, 0x88, 0x79, 0xbb, 0x4c, + 0x62, 0x7b, 0xda, 0x23, 0x77, 0xfd, 0x3, 0x0, 0x19, 0xa1, 0xa1, 0xab, 0x0, 0x98, 0x52, 0x49, 0x18, 0x92, 0xf1, + 0xc2, 0xab, 0x39, 0xba, 0x91, 0xae, 0xe3, 0x40, 0xae, 0x2f, 0x48, 0x74, 0x17, 0x69, 0xf2, 0x2, 0x0, 0x0, 0x68, + 0xcf, 0x26, 0x0, 0x16, 0xec, 0xc1, 0x96, 0xfe, 0x17, 0xcb, 0xd1, 0xb3, 0x7b, 0x21, 0x7d, 0x51, 0x8b, 0xaa, 0x49, + 0x47, 0x1c, 0x8, 0x61, 0xf0, 0x26, 0x27, 0x0, 0x3, 0x3e, 0xd2, 0x34, 0x17, 0x5b, 0x0, 0x11, 0x37, 0xeb, 0x52, + 0x38, 0x3f, 0x5c, 0xc8, 0x37, 0x5e, 0x6a, 0x4e, 0xed, 0x12, 0xe5, 0x36, 0x4f, 0x37, 0x6, 0x0, 0x17, 0x9a, 0xdf, + 0xba, 0x5e, 0xc9, 0xa4, 0xcf, 0xe6, 0xa0, 0x1d, 0x69, 0xcd, 0xd2, 0xcc, 0x3d, 0x28, 0xc4, 0x18, 0xbf, 0x48, 0xa9, + 0x44, 0x60, 0x10, 0x0, 0x1d, 0xfe, 0xf8, 0x70, 0x0, 0x35, 0x5c, 0x8c, 0x6a, 0x22, 0x3, 0xb9, 0xfb, 0xdf, 0xf2, + 0x2b, 0x27, 0xd6, 0xdf, 0x7a, 0xe5, 0xf7, 0xdb, 0xe1, 0x59, 0x17, 0x1c, 0x1b, 0x1b, 0xfe, 0x2, 0x0, 0x19, 0xd5, + 0xbe, 0x20, 0xb2, 0xb0, 0x6f, 0xac, 0xa6, 0xd9, 0xad, 0x45, 0xa7, 0x60, 0x29, 0x8, 0x19, 0x19, 0xf9, 0xcc, 0x5f, + 0x10, 0x98, 0x60, 0xb3, 0x50, 0xd, 0x0, 0x1a, 0x77, 0x1b, 0x55, 0x52, 0x6b, 0x4a, 0xd7, 0xba, 0x81, 0x83, 0x15, + 0x22, 0x8b, 0x64, 0x5c, 0xf6, 0xe4, 0x1b, 0x1, 0x41, 0x19, 0xda, 0x44, 0xd7, 0xd3, 0x2a, 0x6, 0x0, 0x6, 0xba, + 0x48, 0x5b, 0x60, 0xb7, 0xff, 0x9, 0x0, 0x18, 0xaa, 0x2b, 0x7f, 0x3a, 0x34, 0xda, 0x83, 0x7a, 0x28, 0x23, 0xc7, + 0x5e, 0x4f, 0x7d, 0x7, 0xc1, 0x30, 0xb5, 0xe7, 0xe7, 0xbb, 0xbb, 0x50, 0xef, 0x1d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x37, 0xeb, 0x52, 0x38, 0x3f, 0x5c, 0xc8, 0x37, 0x5e, + 0x6a, 0x4e, 0xed, 0x12, 0xe5, 0x36, 0x4f, 0x37}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x9a, 0xdf, 0xba, 0x5e, 0xc9, 0xa4, 0xcf, 0xe6, 0xa0, 0x1d, 0x69, 0xcd, + 0xd2, 0xcc, 0x3d, 0x28, 0xc4, 0x18, 0xbf, 0x48, 0xa9, 0x44, 0x60}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xfe, 0xf8, 0x70, 0x0, 0x35, 0x5c, 0x8c, 0x6a, 0x22, 0x3, + 0xb9, 0xfb, 0xdf, 0xf2, 0x2b, 0x27, 0xd6, 0xdf, 0x7a, 0xe5, + 0xf7, 0xdb, 0xe1, 0x59, 0x17, 0x1c, 0x1b, 0x1b, 0xfe}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd5, 0xbe, 0x20, 0xb2, 0xb0, 0x6f, 0xac, 0xa6, 0xd9, 0xad, 0x45, 0xa7, 0x60, + 0x29, 0x8, 0x19, 0x19, 0xf9, 0xcc, 0x5f, 0x10, 0x98, 0x60, 0xb3, 0x50}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x77, 0x1b, 0x55, 0x52, 0x6b, 0x4a, 0xd7, 0xba, 0x81, 0x83, 0x15, 0x22, 0x8b, + 0x64, 0x5c, 0xf6, 0xe4, 0x1b, 0x1, 0x41, 0x19, 0xda, 0x44, 0xd7, 0xd3, 0x2a}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xba, 0x48, 0x5b, 0x60, 0xb7, 0xff}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xaa, 0x2b, 0x7f, 0x3a, 0x34, 0xda, 0x83, 0x7a, 0x28, 0x23, 0xc7, 0x5e, + 0x4f, 0x7d, 0x7, 0xc1, 0x30, 0xb5, 0xe7, 0xe7, 0xbb, 0xbb, 0x50, 0xef}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + uint8_t bytesprops0[] = {0xdb, 0x3f, 0x21, 0x3, 0x8a, 0x4a, 0x28, 0x76, 0xe3, 0xee, 0xd2, 0xed, 0x1d, 0x75, 0xbd, + 0x89, 0x35, 0x4e, 0x5e, 0xd9, 0x46, 0x3b, 0xf2, 0x37, 0x89, 0x0, 0x6c, 0xb5, 0xb2}; + uint8_t bytesprops1[] = {0x27, 0xd, 0xa4, 0x49, 0x37, 0x94, 0x7e, 0x2d}; + uint8_t bytesprops2[] = {0xa7, 0x5f, 0xe5, 0xa2, 0x38, 0x14, 0x7e, 0xf, 0x95, 0x83, 0x93, 0x73, 0x93, + 0xf5, 0x59, 0x1, 0x1e, 0xa7, 0xc, 0xcd, 0xf5, 0x83, 0xf, 0x6c, 0x1a, 0xbf}; + uint8_t bytesprops3[] = {0x22, 0x7f, 0xad, 0x59, 0xae, 0xd, 0x97, 0x85, 0x69, 0x51, + 0x30, 0x89, 0x4d, 0xd0, 0xab, 0x12, 0xe1, 0x89, 0xee, 0x7d}; + uint8_t bytesprops4[] = {0x45, 0xb0, 0x96, 0x32, 0xff, 0x23, 0xe0, 0x26, 0x7b, + 0xdb, 0xf2, 0xd7, 0x95, 0x67, 0xd9, 0x54, 0x57}; + uint8_t bytesprops5[] = {0xa1, 0x53, 0x73, 0x3c, 0xc0, 0xc2, 0x63, 0x74, 0x92, 0x5a, 0x9d, 0xa9, 0x97, + 0x39, 0x8d, 0x20, 0x78, 0xad, 0x4b, 0x93, 0xd, 0x7c, 0x5f, 0x7d, 0x9d}; + uint8_t bytesprops6[] = {0x19, 0x2d}; + uint8_t bytesprops7[] = {0x4, 0xb6, 0x15, 0x35, 0x9e, 0x38, 0x14, 0x83, 0x20, 0x55, 0xc6, 0x13, + 0x4, 0x40, 0x70, 0xdb, 0x49, 0x78, 0xed, 0x6d, 0xcb, 0xa1, 0x57}; + uint8_t bytesprops8[] = {0x85, 0x88, 0x79, 0xbb, 0x4c, 0x62, 0x7b, 0xda}; + uint8_t bytesprops9[] = {0xa1, 0xa1, 0xab, 0x0, 0x98, 0x52, 0x49, 0x18, 0x92, 0xf1, 0xc2, 0xab, 0x39, + 0xba, 0x91, 0xae, 0xe3, 0x40, 0xae, 0x2f, 0x48, 0x74, 0x17, 0x69, 0xf2}; + uint8_t bytesprops11[] = {0x3e, 0xd2, 0x34}; + uint8_t bytesprops10[] = {0xec, 0xc1, 0x96, 0xfe, 0x17, 0xcb, 0xd1, 0xb3, 0x7b, 0x21, 0x7d, + 0x51, 0x8b, 0xaa, 0x49, 0x47, 0x1c, 0x8, 0x61, 0xf0, 0x26, 0x27}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13282}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15513}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30717}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26831}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops10}, .v = {3, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 91}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21412, 1, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12270, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 10276 [("\SYN\144\218\230l\154\217\219\225\DLE\150m\141\195\222\183#N\DC1\219)\226\a\206y\204\150\RS\214\178",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("R\229\195\208\168\199\145\206\150\202|l\251\139`[\165@GL\SI\229\191!\183s\t\184\153",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationMethod "\\\238\220\219NN_\DELm(\138\183\164O\215q\195n\231#\208\182\DC3\RSJ",PropAuthenticationMethod "\DC3\156",PropTopicAlias 26024,PropResponseTopic "2\n0\139\212\176\255\&8\243b)\a\222n\233N\222\149\208]s\154\147",PropRequestResponseInformation 121,PropAuthenticationData "\162\140\203\163\170\250\194\153\144O4\162;\137\215\168\129\216S\244v\251\&0V\ACKL6",PropMaximumPacketSize 9941,PropResponseInformation "\235\208g\251\DLEO\192\&1\201\STX\ESC\238\183",PropPayloadFormatIndicator 104,PropSessionExpiryInterval 25608,PropAuthenticationMethod "\239",PropWildcardSubscriptionAvailable 163,PropTopicAliasMaximum 2138,PropAuthenticationMethod "+\189\240\243\152G-\185\254\v\152\161\146\&6",PropAuthenticationMethod "7\\)",PropMessageExpiryInterval 9959,PropWillDelayInterval 14260,PropMaximumQoS 41,PropServerReference "4",PropReasonString "\200\215\155\212\DC4\144\239\244\247q",PropWildcardSubscriptionAvailable 249,PropMaximumPacketSize 13691,PropTopicAlias 25895,PropReceiveMaximum 13454] +// SubscribeRequest 18547 [("\189J\145\DC3y\183\216\164\150\129\238l\168;Q\211/\253\211\135%\144\153\\\160",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\b@\172f,>\129\206D\233\DEL\225\131B}\239\133\177\140\196\193j\DC1\237",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\152\130\187",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\143\DC1\220\180\147#-\155\181y",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// True, _noLocal = True, _subQoS = QoS2}),("\235.\t\SOH\DC2\EM/vM\205b",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropContentType +// "\218\224\222?",PropMessageExpiryInterval 29289,PropAuthenticationData "\191n\EOTS",PropSharedSubscriptionAvailable +// 84,PropMessageExpiryInterval 3727,PropMessageExpiryInterval 29049,PropTopicAlias 21920,PropServerReference +// "\231\246\219\229B\169&\a\187\b\167\&3\191u\176!+\243\249T\223{",PropMessageExpiryInterval 11550,PropResponseTopic +// "\218\DEL\237,\213}\NUL\229\138,\ESCD\243P\187\223\187\144WT\EOTU\160da",PropMessageExpiryInterval +// 5728,PropCorrelationData "~\182T\189"] TEST(Subscribe5QCTest, Encode13) { -uint8_t pkt[] = {0x82, 0x89, 0x2, 0x28, 0x24, 0xc4, 0x1, 0x15, 0x0, 0x19, 0x5c, 0xee, 0xdc, 0xdb, 0x4e, 0x4e, 0x5f, 0x7f, 0x6d, 0x28, 0x8a, 0xb7, 0xa4, 0x4f, 0xd7, 0x71, 0xc3, 0x6e, 0xe7, 0x23, 0xd0, 0xb6, 0x13, 0x1e, 0x4a, 0x15, 0x0, 0x2, 0x13, 0x9c, 0x23, 0x65, 0xa8, 0x8, 0x0, 0x17, 0x32, 0xa, 0x30, 0x8b, 0xd4, 0xb0, 0xff, 0x38, 0xf3, 0x62, 0x29, 0x7, 0xde, 0x6e, 0xe9, 0x4e, 0xde, 0x95, 0xd0, 0x5d, 0x73, 0x9a, 0x93, 0x19, 0x79, 0x16, 0x0, 0x1b, 0xa2, 0x8c, 0xcb, 0xa3, 0xaa, 0xfa, 0xc2, 0x99, 0x90, 0x4f, 0x34, 0xa2, 0x3b, 0x89, 0xd7, 0xa8, 0x81, 0xd8, 0x53, 0xf4, 0x76, 0xfb, 0x30, 0x56, 0x6, 0x4c, 0x36, 0x27, 0x0, 0x0, 0x26, 0xd5, 0x1a, 0x0, 0xd, 0xeb, 0xd0, 0x67, 0xfb, 0x10, 0x4f, 0xc0, 0x31, 0xc9, 0x2, 0x1b, 0xee, 0xb7, 0x1, 0x68, 0x11, 0x0, 0x0, 0x64, 0x8, 0x15, 0x0, 0x1, 0xef, 0x28, 0xa3, 0x22, 0x8, 0x5a, 0x15, 0x0, 0xe, 0x2b, 0xbd, 0xf0, 0xf3, 0x98, 0x47, 0x2d, 0xb9, 0xfe, 0xb, 0x98, 0xa1, 0x92, 0x36, 0x15, 0x0, 0x3, 0x37, 0x5c, 0x29, 0x2, 0x0, 0x0, 0x26, 0xe7, 0x18, 0x0, 0x0, 0x37, 0xb4, 0x24, 0x29, 0x1c, 0x0, 0x1, 0x34, 0x1f, 0x0, 0xa, 0xc8, 0xd7, 0x9b, 0xd4, 0x14, 0x90, 0xef, 0xf4, 0xf7, 0x71, 0x28, 0xf9, 0x27, 0x0, 0x0, 0x35, 0x7b, 0x23, 0x65, 0x27, 0x21, 0x34, 0x8e, 0x0, 0x1e, 0x16, 0x90, 0xda, 0xe6, 0x6c, 0x9a, 0xd9, 0xdb, 0xe1, 0x10, 0x96, 0x6d, 0x8d, 0xc3, 0xde, 0xb7, 0x23, 0x4e, 0x11, 0xdb, 0x29, 0xe2, 0x7, 0xce, 0x79, 0xcc, 0x96, 0x1e, 0xd6, 0xb2, 0x10, 0x0, 0x1d, 0x52, 0xe5, 0xc3, 0xd0, 0xa8, 0xc7, 0x91, 0xce, 0x96, 0xca, 0x7c, 0x6c, 0xfb, 0x8b, 0x60, 0x5b, 0xa5, 0x40, 0x47, 0x4c, 0xf, 0xe5, 0xbf, 0x21, 0xb7, 0x73, 0x9, 0xb8, 0x99, 0x10}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x16, 0x90, 0xda, 0xe6, 0x6c, 0x9a, 0xd9, 0xdb, 0xe1, 0x10, 0x96, 0x6d, 0x8d, 0xc3, 0xde, 0xb7, 0x23, 0x4e, 0x11, 0xdb, 0x29, 0xe2, 0x7, 0xce, 0x79, 0xcc, 0x96, 0x1e, 0xd6, 0xb2}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x52, 0xe5, 0xc3, 0xd0, 0xa8, 0xc7, 0x91, 0xce, 0x96, 0xca, 0x7c, 0x6c, 0xfb, 0x8b, 0x60, 0x5b, 0xa5, 0x40, 0x47, 0x4c, 0xf, 0xe5, 0xbf, 0x21, 0xb7, 0x73, 0x9, 0xb8, 0x99}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; -lwmqtt_sub_options_t sub_opts[2]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS0; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; - uint8_t bytesprops0[] = {0x5c, 0xee, 0xdc, 0xdb, 0x4e, 0x4e, 0x5f, 0x7f, 0x6d, 0x28, 0x8a, 0xb7, 0xa4, 0x4f, 0xd7, 0x71, 0xc3, 0x6e, 0xe7, 0x23, 0xd0, 0xb6, 0x13, 0x1e, 0x4a}; - uint8_t bytesprops1[] = {0x13, 0x9c}; - uint8_t bytesprops2[] = {0x32, 0xa, 0x30, 0x8b, 0xd4, 0xb0, 0xff, 0x38, 0xf3, 0x62, 0x29, 0x7, 0xde, 0x6e, 0xe9, 0x4e, 0xde, 0x95, 0xd0, 0x5d, 0x73, 0x9a, 0x93}; - uint8_t bytesprops3[] = {0xa2, 0x8c, 0xcb, 0xa3, 0xaa, 0xfa, 0xc2, 0x99, 0x90, 0x4f, 0x34, 0xa2, 0x3b, 0x89, 0xd7, 0xa8, 0x81, 0xd8, 0x53, 0xf4, 0x76, 0xfb, 0x30, 0x56, 0x6, 0x4c, 0x36}; - uint8_t bytesprops4[] = {0xeb, 0xd0, 0x67, 0xfb, 0x10, 0x4f, 0xc0, 0x31, 0xc9, 0x2, 0x1b, 0xee, 0xb7}; - uint8_t bytesprops5[] = {0xef}; - uint8_t bytesprops6[] = {0x2b, 0xbd, 0xf0, 0xf3, 0x98, 0x47, 0x2d, 0xb9, 0xfe, 0xb, 0x98, 0xa1, 0x92, 0x36}; - uint8_t bytesprops7[] = {0x37, 0x5c, 0x29}; - uint8_t bytesprops8[] = {0x34}; - uint8_t bytesprops9[] = {0xc8, 0xd7, 0x9b, 0xd4, 0x14, 0x90, 0xef, 0xf4, 0xf7, 0x71}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26024}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9941}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25608}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2138}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9959}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14260}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13691}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25895}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13454}}, + uint8_t pkt[] = {0x82, 0xc3,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1, 0x12, 0x19, 0x2f, 0x76, 0x4d, 0xcd, 0x62, 0x24}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xbd, 0x4a, 0x91, 0x13, 0x79, 0xb7, 0xd8, 0xa4, 0x96, 0x81, 0xee, 0x6c, 0xa8, + 0x3b, 0x51, 0xd3, 0x2f, 0xfd, 0xd3, 0x87, 0x25, 0x90, 0x99, 0x5c, 0xa0}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x8, 0x40, 0xac, 0x66, 0x2c, 0x3e, 0x81, 0xce, 0x44, 0xe9, 0x7f, 0xe1, + 0x83, 0x42, 0x7d, 0xef, 0x85, 0xb1, 0x8c, 0xc4, 0xc1, 0x6a, 0x11, 0xed}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x98, 0x82, 0xbb}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8f, 0x11, 0xdc, 0xb4, 0x93, 0x23, 0x2d, 0x9b, 0xb5, 0x79}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xeb, 0x2e, 0x9, 0x1, 0x12, 0x19, 0x2f, 0x76, 0x4d, 0xcd, 0x62}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + uint8_t bytesprops0[] = {0xda, 0xe0, 0xde, 0x3f}; + uint8_t bytesprops1[] = {0xbf, 0x6e, 0x4, 0x53}; + uint8_t bytesprops2[] = {0xe7, 0xf6, 0xdb, 0xe5, 0x42, 0xa9, 0x26, 0x7, 0xbb, 0x8, 0xa7, + 0x33, 0xbf, 0x75, 0xb0, 0x21, 0x2b, 0xf3, 0xf9, 0x54, 0xdf, 0x7b}; + uint8_t bytesprops3[] = {0xda, 0x7f, 0xed, 0x2c, 0xd5, 0x7d, 0x0, 0xe5, 0x8a, 0x2c, 0x1b, 0x44, 0xf3, + 0x50, 0xbb, 0xdf, 0xbb, 0x90, 0x57, 0x54, 0x4, 0x55, 0xa0, 0x64, 0x61}; + uint8_t bytesprops4[] = {0x7e, 0xb6, 0x54, 0xbd}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29289}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3727}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29049}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21920}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11550}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5728}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10276, 2, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18547, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 7750 [("\191\131\229\247n\DC4\170]A\183\163\132",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\209U\"`\185\222\252RC|G\202#\161P\240\SYN\DLE;@\172\251\188dV",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\188t\246J\ETX\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\154<\139\";}\250\187\&0pG\224\173\148\216\238#R\187\168\142\190",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("}\146\176\ncE\212\185:\132-\DLE9\ETB[r",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("m\DC3\169\GSX\164\&5\158\RS\153\235W8\CANp",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\151\209",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("$U\214\224\143\199M\166v\143\&6\241\STX\DC2U\245\144\153\135n\161\146\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\247\ACK\228'\209\245\RS\\\148\ACK\254\187\255gl\215",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\229rp:\145\167\ACK\191\188\195\US\\",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropWillDelayInterval 882,PropReasonString "1\ENQ\r\238\181 \ACK\ag\200\196j\157{c\173",PropWillDelayInterval 16738,PropAuthenticationData "\CAN\231",PropReasonString ".\161\&5g\NUL\183\147\197#k\157\GSz1)",PropMaximumQoS 208,PropRequestProblemInformation 104,PropUserProperty "\\\188t\\+Vg\177\139\206 \211\236=AU\161;\199f}\153-z\DC3\156\177\159\132\248" ":\138\203\NAKa\NUL\178\130\160(\SYN^\223\226:U\DC3\215\155\129\160\ETB",PropAssignedClientIdentifier "\225",PropRetainAvailable 233,PropAssignedClientIdentifier "\161S\232K\203",PropRequestProblemInformation 70,PropContentType "\192M\"greI\199\177}Z])",PropTopicAliasMaximum 692,PropMaximumQoS 117,PropRequestResponseInformation 183,PropTopicAliasMaximum 2828,PropReceiveMaximum 13055,PropReceiveMaximum 14438,PropWildcardSubscriptionAvailable 164,PropPayloadFormatIndicator 120,PropResponseInformation "\SYN\DEL%\222\178u\248\132\247\212\229u\155Iu\217\182@I\ETB\"X",PropTopicAlias 26576] +// SubscribeRequest 10474 [(",+{\129\233\223\145\247o8\195\202\SIEVN\152\206m\181$\172\204\250HR\169",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\170[\206)\DC4\217gT\220\238",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS2}),("\194y\219\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1})] [PropPayloadFormatIndicator 44,PropAssignedClientIdentifier +// "\220\218\250V\193A\242\142\153\ESCH\210",PropAssignedClientIdentifier +// "\165CG\207\253\204\237\177\192\143",PropWillDelayInterval 27765,PropMaximumQoS 133,PropAssignedClientIdentifier +// "\210\CANo\193>",PropTopicAliasMaximum 12560,PropServerReference +// "\164\&2\212\vUW\147WU\226\228\245\212L\166!\225\239\240J",PropResponseInformation +// "_\170&\132\206\&5\153w\167\228\153\203=\ACK\167\ENQ?8\162\&4\SYN/\243\177zCO=",PropMessageExpiryInterval +// 29666,PropUserProperty "\228\&41\ENQG\171\241?F/\199\226\154 @\153\ACK!\ENQ\216\173\ETX\228\253\226\NUL^d.\201" +// "\165\169o\208\SOH\185\193\184\202\r\215\150\226L\138\&9\222+\224@l\240\167\187\129",PropMessageExpiryInterval +// 14224,PropResponseInformation "\168\208\251F\232\179\&4\NAKvO\140\ETX9Ae\160(",PropResponseTopic +// "\196\ACK\197\199\163m\NUL\168~/B\244\198\204\226\NUL\219\&6H\183\203\249\191\188\197\238\167\196\168",PropRequestResponseInformation +// 155,PropSubscriptionIdentifierAvailable 59,PropUserProperty "\SOH" +// ",\254\234u\166\231\205\211\133\169cu`\199\DC4V\234\251)",PropTopicAliasMaximum 8917,PropSessionExpiryInterval +// 28790,PropServerReference "\173\203h\175U\GS\250T"] TEST(Subscribe5QCTest, Encode14) { -uint8_t pkt[] = {0x82, 0xf8, 0x2, 0x1e, 0x46, 0xc1, 0x1, 0x18, 0x0, 0x0, 0x3, 0x72, 0x1f, 0x0, 0x10, 0x31, 0x5, 0xd, 0xee, 0xb5, 0x20, 0x6, 0x7, 0x67,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a3, 0x84, 0x22, 0x0, 0x19, 0xd1, 0x55, 0x22, 0x60, 0xb9, 0xde, 0xfc, 0x52, 0x43, 0x7c, 0x47, 0xca, 0x23, 0xa1, 0x50, 0xf0, 0x16, 0x10, 0x3b, 0x40, 0xac, 0xfb, 0xbc, 0x64, 0x56, 0x11, 0x0, 0x6, 0xbc, 0x74, 0xf6, 0x4a, 0x3, 0xae, 0x9, 0x0, 0x16, 0x9a, 0x3c, 0x8b, 0x22, 0x3b, 0x7d, 0xfa, 0xbb, 0x30, 0x70, 0x47, 0xe0, 0xad, 0x94, 0xd8, 0xee, 0x23, 0x52, 0xbb, 0xa8, 0x8e, 0xbe, 0x12, 0x0, 0x10, 0x7d, 0x92, 0xb0, 0xa, 0x63, 0x45, 0xd4, 0xb9, 0x3a, 0x84, 0x2d, 0x10, 0x39, 0x17, 0x5b, 0x72, 0x2e, 0x0, 0xf, 0x6d, 0x13, 0xa9, 0x1d, 0x58, 0xa4, 0x35, 0x9e, 0x1e, 0x99, 0xeb, 0x57, 0x38, 0x18, 0x70, 0x1c, 0x0, 0x2, 0x97, 0xd1, 0xc, 0x0, 0x17, 0x24, 0x55, 0xd6, 0xe0, 0x8f, 0xc7, 0x4d, 0xa6, 0x76, 0x8f, 0x36, 0xf1, 0x2, 0x12, 0x55, 0xf5, 0x90, 0x99, 0x87, 0x6e, 0xa1, 0x92, 0x1, 0x6, 0x0, 0x10, 0xf7, 0x6, 0xe4, 0x27, 0xd1, 0xf5, 0x1e, 0x5c, 0x94, 0x6, 0xfe, 0xbb, 0xff, 0x67, 0x6c, 0xd7, 0x29, 0x0, 0xc, 0xe5, 0x72, 0x70, 0x3a, 0x91, 0xa7, 0x6, 0xbf, 0xbc, 0xc3, 0x1f, 0x5c, 0x1d}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xbf, 0x83, 0xe5, 0xf7, 0x6e, 0x14, 0xaa, 0x5d, 0x41, 0xb7, 0xa3, 0x84}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd1, 0x55, 0x22, 0x60, 0xb9, 0xde, 0xfc, 0x52, 0x43, 0x7c, 0x47, 0xca, 0x23, 0xa1, 0x50, 0xf0, 0x16, 0x10, 0x3b, 0x40, 0xac, 0xfb, 0xbc, 0x64, 0x56}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xbc, 0x74, 0xf6, 0x4a, 0x3, 0xae}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9a, 0x3c, 0x8b, 0x22, 0x3b, 0x7d, 0xfa, 0xbb, 0x30, 0x70, 0x47, 0xe0, 0xad, 0x94, 0xd8, 0xee, 0x23, 0x52, 0xbb, 0xa8, 0x8e, 0xbe}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7d, 0x92, 0xb0, 0xa, 0x63, 0x45, 0xd4, 0xb9, 0x3a, 0x84, 0x2d, 0x10, 0x39, 0x17, 0x5b, 0x72}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6d, 0x13, 0xa9, 0x1d, 0x58, 0xa4, 0x35, 0x9e, 0x1e, 0x99, 0xeb, 0x57, 0x38, 0x18, 0x70}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x97, 0xd1}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x24, 0x55, 0xd6, 0xe0, 0x8f, 0xc7, 0x4d, 0xa6, 0x76, 0x8f, 0x36, 0xf1, 0x2, 0x12, 0x55, 0xf5, 0x90, 0x99, 0x87, 0x6e, 0xa1, 0x92, 0x1}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xf7, 0x6, 0xe4, 0x27, 0xd1, 0xf5, 0x1e, 0x5c, 0x94, 0x6, 0xfe, 0xbb, 0xff, 0x67, 0x6c, 0xd7}; - lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe5, 0x72, 0x70, 0x3a, 0x91, 0xa7, 0x6, 0xbf, 0xbc, 0xc3, 0x1f, 0x5c}; - lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; -topic_filters[9] = topic_filter_s9; -lwmqtt_sub_options_t sub_opts[10]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = true; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[4].retain_as_published = true; -sub_opts[4].no_local = true; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[5].retain_as_published = true; -sub_opts[5].no_local = true; -sub_opts[6].qos = LWMQTT_QOS0; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[6].retain_as_published = true; -sub_opts[6].no_local = true; -sub_opts[7].qos = LWMQTT_QOS2; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = true; -sub_opts[8].qos = LWMQTT_QOS1; -sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[8].retain_as_published = true; -sub_opts[8].no_local = false; -sub_opts[9].qos = LWMQTT_QOS1; -sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[9].retain_as_published = true; -sub_opts[9].no_local = true; - uint8_t bytesprops0[] = {0x31, 0x5, 0xd, 0xee, 0xb5, 0x20, 0x6, 0x7, 0x67, 0xc8, 0xc4, 0x6a, 0x9d, 0x7b, 0x63, 0xad}; - uint8_t bytesprops1[] = {0x18, 0xe7}; - uint8_t bytesprops2[] = {0x2e, 0xa1, 0x35, 0x67, 0x0, 0xb7, 0x93, 0xc5, 0x23, 0x6b, 0x9d, 0x1d, 0x7a, 0x31, 0x29}; - uint8_t bytesprops4[] = {0x3a, 0x8a, 0xcb, 0x15, 0x61, 0x0, 0xb2, 0x82, 0xa0, 0x28, 0x16, 0x5e, 0xdf, 0xe2, 0x3a, 0x55, 0x13, 0xd7, 0x9b, 0x81, 0xa0, 0x17}; - uint8_t bytesprops3[] = {0x5c, 0xbc, 0x74, 0x5c, 0x2b, 0x56, 0x67, 0xb1, 0x8b, 0xce, 0x20, 0xd3, 0xec, 0x3d, 0x41, 0x55, 0xa1, 0x3b, 0xc7, 0x66, 0x7d, 0x99, 0x2d, 0x7a, 0x13, 0x9c, 0xb1, 0x9f, 0x84, 0xf8}; - uint8_t bytesprops5[] = {0xe1}; - uint8_t bytesprops6[] = {0xa1, 0x53, 0xe8, 0x4b, 0xcb}; - uint8_t bytesprops7[] = {0xc0, 0x4d, 0x22, 0x67, 0x72, 0x65, 0x49, 0xc7, 0xb1, 0x7d, 0x5a, 0x5d, 0x29}; - uint8_t bytesprops8[] = {0x16, 0x7f, 0x25, 0xde, 0xb2, 0x75, 0xf8, 0x84, 0xf7, 0xd4, 0xe5, 0x75, 0x9b, 0x49, 0x75, 0xd9, 0xb6, 0x40, 0x49, 0x17, 0x22, 0x58}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 882}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16738}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={30, (char*)&bytesprops3}, .v={22, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 692}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2828}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13055}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14438}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26576}}, + uint8_t pkt[] = { + 0x82, 0xc6, 0x2, 0x28, 0xea, 0x90, 0x2, 0x1, 0x2c, 0x12, 0x0, 0xc, 0xdc, 0xda, 0xfa, 0x56, 0xc1, 0x41, 0xf2, + 0x8e, 0x99, 0x1b, 0x48, 0xd2, 0x12, 0x0, 0xa, 0xa5, 0x43, 0x47, 0xcf, 0xfd, 0xcc, 0xed, 0xb1, 0xc0, 0x8f, 0x18, + 0x0, 0x0, 0x6c, 0x75, 0x24, 0x85, 0x12, 0x0, 0x5, 0xd2, 0x18, 0x6f, 0xc1, 0x3e, 0x22, 0x31, 0x10, 0x1c, 0x0, + 0x14, 0xa4, 0x32, 0xd4, 0xb, 0x55, 0x57, 0x93, 0x57, 0x55, 0xe2, 0xe4, 0xf5, 0xd4, 0x4c, 0xa6, 0x21, 0xe1, 0xef, + 0xf0, 0x4a, 0x1a, 0x0, 0x1c, 0x5f, 0xaa, 0x26, 0x84, 0xce, 0x35, 0x99, 0x77, 0xa7, 0xe4, 0x99, 0xcb, 0x3d, 0x6, + 0xa7, 0x5, 0x3f, 0x38, 0xa2, 0x34, 0x16, 0x2f, 0xf3, 0xb1, 0x7a, 0x43, 0x4f, 0x3d, 0x2, 0x0, 0x0, 0x73, 0xe2, + 0x26, 0x0, 0x1e, 0xe4, 0x34, 0x31, 0x5, 0x47, 0xab, 0xf1, 0x3f, 0x46, 0x2f, 0xc7, 0xe2, 0x9a, 0x20, 0x40, 0x99, + 0x6, 0x21, 0x5, 0xd8, 0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0x0, + 0x4, 0xc2, 0x79, 0xdb, 0xb4, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x2c, 0x2b, 0x7b, 0x81, 0xe9, 0xdf, 0x91, 0xf7, 0x6f, 0x38, 0xc3, 0xca, 0xf, 0x45, + 0x56, 0x4e, 0x98, 0xce, 0x6d, 0xb5, 0x24, 0xac, 0xcc, 0xfa, 0x48, 0x52, 0xa9}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xaa, 0x5b, 0xce, 0x29, 0x14, 0xd9, 0x67, 0x54, 0xdc, 0xee}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc2, 0x79, 0xdb, 0xb4}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + uint8_t bytesprops0[] = {0xdc, 0xda, 0xfa, 0x56, 0xc1, 0x41, 0xf2, 0x8e, 0x99, 0x1b, 0x48, 0xd2}; + uint8_t bytesprops1[] = {0xa5, 0x43, 0x47, 0xcf, 0xfd, 0xcc, 0xed, 0xb1, 0xc0, 0x8f}; + uint8_t bytesprops2[] = {0xd2, 0x18, 0x6f, 0xc1, 0x3e}; + uint8_t bytesprops3[] = {0xa4, 0x32, 0xd4, 0xb, 0x55, 0x57, 0x93, 0x57, 0x55, 0xe2, + 0xe4, 0xf5, 0xd4, 0x4c, 0xa6, 0x21, 0xe1, 0xef, 0xf0, 0x4a}; + uint8_t bytesprops4[] = {0x5f, 0xaa, 0x26, 0x84, 0xce, 0x35, 0x99, 0x77, 0xa7, 0xe4, 0x99, 0xcb, 0x3d, 0x6, + 0xa7, 0x5, 0x3f, 0x38, 0xa2, 0x34, 0x16, 0x2f, 0xf3, 0xb1, 0x7a, 0x43, 0x4f, 0x3d}; + uint8_t bytesprops6[] = {0xa5, 0xa9, 0x6f, 0xd0, 0x1, 0xb9, 0xc1, 0xb8, 0xca, 0xd, 0xd7, 0x96, 0xe2, + 0x4c, 0x8a, 0x39, 0xde, 0x2b, 0xe0, 0x40, 0x6c, 0xf0, 0xa7, 0xbb, 0x81}; + uint8_t bytesprops5[] = {0xe4, 0x34, 0x31, 0x5, 0x47, 0xab, 0xf1, 0x3f, 0x46, 0x2f, 0xc7, 0xe2, 0x9a, 0x20, 0x40, + 0x99, 0x6, 0x21, 0x5, 0xd8, 0xad, 0x3, 0xe4, 0xfd, 0xe2, 0x0, 0x5e, 0x64, 0x2e, 0xc9}; + uint8_t bytesprops7[] = {0xa8, 0xd0, 0xfb, 0x46, 0xe8, 0xb3, 0x34, 0x15, 0x76, + 0x4f, 0x8c, 0x3, 0x39, 0x41, 0x65, 0xa0, 0x28}; + uint8_t bytesprops8[] = {0xc4, 0x6, 0xc5, 0xc7, 0xa3, 0x6d, 0x0, 0xa8, 0x7e, 0x2f, 0x42, 0xf4, 0xc6, 0xcc, 0xe2, + 0x0, 0xdb, 0x36, 0x48, 0xb7, 0xcb, 0xf9, 0xbf, 0xbc, 0xc5, 0xee, 0xa7, 0xc4, 0xa8}; + uint8_t bytesprops10[] = {0x2c, 0xfe, 0xea, 0x75, 0xa6, 0xe7, 0xcd, 0xd3, 0x85, 0xa9, + 0x63, 0x75, 0x60, 0xc7, 0x14, 0x56, 0xea, 0xfb, 0x29}; + uint8_t bytesprops9[] = {0x1}; + uint8_t bytesprops11[] = {0xad, 0xcb, 0x68, 0xaf, 0x55, 0x1d, 0xfa, 0x54}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27765}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12560}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29666}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops5}, .v = {25, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14224}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops9}, .v = {19, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8917}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28790}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7750, 10, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10474, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 6922 [("\176\131\178\223z\196\&7\244P\255\198\182\182Y\250e&\173\215\129\SOH\185\nQ7\NULK\SOH*",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("Xv\191Qn\146\ACK\CAN\159\&1\251U\202\233B\r\158\234\237",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\142\196\245\228Y{#1\n\227\151\215>O\213\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("l\232\254\201\210\146\&9\138\199\199?\n`~(#\223\NUL\152\142\194\&0\227\213>",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\183Gl\161\243g%\128",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropResponseInformation "\175iA^\225\203\ACK\FSE\175e\DLE\NAK\189\253\249\194J\181^\134\158\ETBQ\ESC\EOT",PropTopicAlias 2462,PropAssignedClientIdentifier "\251\171*\164\251Q\158\154q\214\194\144\239v\217\200\220\CAN\201\SI\a\192\255\FS",PropReceiveMaximum 11788,PropWillDelayInterval 4283,PropAuthenticationData "=B\238\177b\179\162\DC3\246\254\228s",PropSubscriptionIdentifierAvailable 66,PropTopicAlias 11878,PropMessageExpiryInterval 17512,PropServerKeepAlive 19493,PropAuthenticationMethod "\149\217\196\177z\245\161\240[\169\FSZ1z\SUBH\EOT\166\250\193\197\218",PropTopicAliasMaximum 16410,PropMessageExpiryInterval 8324,PropCorrelationData "\206\247\&5\148\231\220z\179\&6\169l7\235\237\161\241\t\208\152 \158\&9\179\240\136\188h"] +// SubscribeRequest 20401 [("\210n-\209\154iPp\201\217l\192\SOHlY\242\n$\144@t",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("@T\180Z\153\"\b\RS8\223%\224\&5z\DC2`\170\NAK\179\224!\SI\153}\149O\252\199\182",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("P\EM \252RA1y\233=Q +// \206U\161\SUB\NULSCcv\153\&1n\132\135T\138N",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// True, _noLocal = True, _subQoS = +// QoS0}),("\233\&2\236\152@\229Z\RS\247\249\142\241\147\181\234\al}\228\167\157",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("G\193\ETB\152\&84H\fg2\215\f\DC26\209\t\216xr\172\225>\246Es/_\201",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\SUB\164q\168\180\218\223\190\207RU\153\250\238+E\247\244\183\231\225",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\221\149A\211\195",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] +// [PropMessageExpiryInterval 18748,PropRetainAvailable 227,PropSessionExpiryInterval +// 7310,PropSubscriptionIdentifierAvailable 59,PropAssignedClientIdentifier +// ".\157P^\128\&1\188\198c2\205\&3s&\138\226\ACK\US\129\155\232~\183",PropMessageExpiryInterval 18830,PropMaximumQoS +// 7,PropMessageExpiryInterval 10723,PropContentType +// "\SUBA>\231\STX\174\247\239NVE\151\215\146\SOH\175\171V",PropRetainAvailable 168,PropReceiveMaximum +// 20286,PropAuthenticationData "\STX\134E\208\156\n\223,Q\166\161\FS\141\192\195\197\&6\EM0^",PropTopicAliasMaximum +// 25662,PropServerKeepAlive 1905,PropResponseTopic "\175\DC3\202",PropPayloadFormatIndicator 117,PropRetainAvailable +// 101,PropReceiveMaximum 17048,PropWildcardSubscriptionAvailable 212,PropWildcardSubscriptionAvailable 20] TEST(Subscribe5QCTest, Encode15) { -uint8_t pkt[] = {0x82, 0x92, 0x2, 0x1b, 0xa, 0x9e, 0x1, 0x1a, 0x0, 0x1a, 0xaf, 0x69, 0x41, 0x5e, 0xe1, 0xcb, 0x6, 0x1c, 0x45, 0xaf, 0x65, 0x10, 0x15, 0xbd, 0xfd, 0xf9, 0xc2, 0x4a, 0xb5, 0x5e, 0x86, 0x9e, 0x17, 0x51, 0x1b, 0x4, 0x23, 0x9, 0x9e, 0x12, 0x0, 0x18, 0xfb, 0xab, 0x2a, 0xa4, 0xfb, 0x51, 0x9e, 0x9a, 0x71, 0xd6, 0xc2, 0x90, 0xef, 0x76, 0xd9, 0xc8, 0xdc, 0x18, 0xc9, 0xf, 0x7, 0xc0, 0xff, 0x1c, 0x21, 0x2e, 0xc, 0x18, 0x0, 0x0, 0x10, 0xbb, 0x16, 0x0, 0xc, 0x3d, 0x42, 0xee, 0xb1, 0x62, 0xb3, 0xa2, 0x13, 0xf6, 0xfe, 0xe4, 0x73, 0x29, 0x42, 0x23, 0x2e, 0x66, 0x2, 0x0, 0x0, 0x44, 0x68, 0x13, 0x4c, 0x25, 0x15, 0x0, 0x16, 0x95, 0xd9, 0xc4, 0xb1, 0x7a, 0xf5, 0xa1, 0xf0, 0x5b, 0xa9, 0x1c, 0x5a, 0x31, 0x7a, 0x1a, 0x48, 0x4, 0xa6, 0xfa, 0xc1, 0xc5, 0xda, 0x22, 0x40, 0x1a, 0x2, 0x0, 0x0, 0x20, 0x84, 0x9, 0x0, 0x1b, 0xce, 0xf7, 0x35, 0x94, 0xe7, 0xdc, 0x7a, 0xb3, 0x36, 0xa9, 0x6c, 0x37, 0xeb, 0xed, 0xa1, 0xf1, 0x9, 0xd0, 0x98, 0x20, 0x9e, 0x39, 0xb3, 0xf0, 0x88, 0xbc, 0x68, 0x0, 0x1d, 0xb0, 0x83, 0xb2, 0xdf, 0x7a, 0xc4, 0x37, 0xf4, 0x50, 0xff, 0xc6, 0xb6, 0xb6, 0x59, 0xfa, 0x65, 0x26, 0xad, 0xd7, 0x81, 0x1, 0xb9, 0xa, 0x51, 0x37, 0x0, 0x4b, 0x1, 0x2a, 0x15, 0x0, 0x13, 0x58, 0x76, 0xbf, 0x51, 0x6e, 0x92, 0x6, 0x18, 0x9f, 0x31, 0xfb, 0x55, 0xca, 0xe9, 0x42, 0xd, 0x9e, 0xea, 0xed, 0x5, 0x0, 0x10, 0x8e, 0xc4, 0xf5, 0xe4, 0x59, 0x7b, 0x23, 0x31, 0xa, 0xe3, 0x97, 0xd7, 0x3e, 0x4f, 0xd5, 0x83, 0xd, 0x0, 0x19, 0x6c, 0xe8, 0xfe, 0xc9, 0xd2, 0x92, 0x39, 0x8a, 0xc7, 0xc7, 0x3f, 0xa, 0x60, 0x7e, 0x28, 0x23, 0xdf, 0x0, 0x98, 0x8e, 0xc2, 0x30, 0xe3, 0xd5, 0x3e, 0x26, 0x0, 0x8, 0xb7, 0x47, 0x6c, 0xa1, 0xf3, 0x67, 0x25, 0x80, 0xd}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xb0, 0x83, 0xb2, 0xdf, 0x7a, 0xc4, 0x37, 0xf4, 0x50, 0xff, 0xc6, 0xb6, 0xb6, 0x59, 0xfa, 0x65, 0x26, 0xad, 0xd7, 0x81, 0x1, 0xb9, 0xa, 0x51, 0x37, 0x0, 0x4b, 0x1, 0x2a}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x58, 0x76, 0xbf, 0x51, 0x6e, 0x92, 0x6, 0x18, 0x9f, 0x31, 0xfb, 0x55, 0xca, 0xe9, 0x42, 0xd, 0x9e, 0xea, 0xed}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8e, 0xc4, 0xf5, 0xe4, 0x59, 0x7b, 0x23, 0x31, 0xa, 0xe3, 0x97, 0xd7, 0x3e, 0x4f, 0xd5, 0x83}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6c, 0xe8, 0xfe, 0xc9, 0xd2, 0x92, 0x39, 0x8a, 0xc7, 0xc7, 0x3f, 0xa, 0x60, 0x7e, 0x28, 0x23, 0xdf, 0x0, 0x98, 0x8e, 0xc2, 0x30, 0xe3, 0xd5, 0x3e}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb7, 0x47, 0x6c, 0xa1, 0xf3, 0x67, 0x25, 0x80}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; -lwmqtt_sub_options_t sub_opts[5]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = true; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = true; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = true; -sub_opts[2].no_local = true; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = true; -sub_opts[4].qos = LWMQTT_QOS1; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = true; -sub_opts[4].no_local = true; - uint8_t bytesprops0[] = {0xaf, 0x69, 0x41, 0x5e, 0xe1, 0xcb, 0x6, 0x1c, 0x45, 0xaf, 0x65, 0x10, 0x15, 0xbd, 0xfd, 0xf9, 0xc2, 0x4a, 0xb5, 0x5e, 0x86, 0x9e, 0x17, 0x51, 0x1b, 0x4}; - uint8_t bytesprops1[] = {0xfb, 0xab, 0x2a, 0xa4, 0xfb, 0x51, 0x9e, 0x9a, 0x71, 0xd6, 0xc2, 0x90, 0xef, 0x76, 0xd9, 0xc8, 0xdc, 0x18, 0xc9, 0xf, 0x7, 0xc0, 0xff, 0x1c}; - uint8_t bytesprops2[] = {0x3d, 0x42, 0xee, 0xb1, 0x62, 0xb3, 0xa2, 0x13, 0xf6, 0xfe, 0xe4, 0x73}; - uint8_t bytesprops3[] = {0x95, 0xd9, 0xc4, 0xb1, 0x7a, 0xf5, 0xa1, 0xf0, 0x5b, 0xa9, 0x1c, 0x5a, 0x31, 0x7a, 0x1a, 0x48, 0x4, 0xa6, 0xfa, 0xc1, 0xc5, 0xda}; - uint8_t bytesprops4[] = {0xce, 0xf7, 0x35, 0x94, 0xe7, 0xdc, 0x7a, 0xb3, 0x36, 0xa9, 0x6c, 0x37, 0xeb, 0xed, 0xa1, 0xf1, 0x9, 0xd0, 0x98, 0x20, 0x9e, 0x39, 0xb3, 0xf0, 0x88, 0xbc, 0x68}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2462}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11788}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4283}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11878}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17512}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19493}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16410}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8324}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops4}}}, + uint8_t pkt[] = {0x82, 0xae, 0x2, 0x4f, 0xb1, 0x7c, 0x2, 0x0, 0x0, 0x49, 0x3c, 0x25, 0xe3, 0x11, 0x0, 0x0, 0x1c, + 0x8e, 0x29, 0x3b, 0x12, 0x0, 0x17, 0x2e, 0x9d, 0x50, 0x5e, 0x80, 0x31, 0xbc, 0xc6, 0x63, 0x32, 0xcd, + 0x33, 0x73, 0x26, 0x8a, 0xe2, 0x6, 0x1f, 0x81, 0x9b, 0xe8, 0x7e, 0xb7, 0x2, 0x0, 0x0, 0x49, 0x8e, + 0x24, 0x7, 0x2, 0x0, 0x0, 0x29, 0xe3, 0x3, 0x0, 0x12, 0x1a, 0x41, 0x3e, 0xe7, 0x2, 0xae, 0xf7, + 0xef, 0x4e, 0x56, 0x45, 0x97, 0xd7, 0x92, 0x1, 0xaf, 0xab, 0x56, 0x25, 0xa8, 0x21, 0x4f, 0x3e, 0x16, + 0x0, 0x14, 0x2, 0x86, 0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a4, 0x71, 0xa8, 0xb4, 0xda, 0xdf, 0xbe, 0xcf, 0x52, 0x55, 0x99, 0xfa, 0xee, + 0x2b, 0x45, 0xf7, 0xf4, 0xb7, 0xe7, 0xe1, 0x6, 0x0, 0x5, 0xdd, 0x95, 0x41, 0xd3, 0xc3, 0x14}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xd2, 0x6e, 0x2d, 0xd1, 0x9a, 0x69, 0x50, 0x70, 0xc9, 0xd9, 0x6c, + 0xc0, 0x1, 0x6c, 0x59, 0xf2, 0xa, 0x24, 0x90, 0x40, 0x74}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x40, 0x54, 0xb4, 0x5a, 0x99, 0x22, 0x8, 0x1e, 0x38, 0xdf, + 0x25, 0xe0, 0x35, 0x7a, 0x12, 0x60, 0xaa, 0x15, 0xb3, 0xe0, + 0x21, 0xf, 0x99, 0x7d, 0x95, 0x4f, 0xfc, 0xc7, 0xb6}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x50, 0x19, 0x20, 0xfc, 0x52, 0x41, 0x31, 0x79, 0xe9, 0x3d, + 0x51, 0x20, 0xce, 0x55, 0xa1, 0x1a, 0x0, 0x53, 0x43, 0x63, + 0x76, 0x99, 0x31, 0x6e, 0x84, 0x87, 0x54, 0x8a, 0x4e}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe9, 0x32, 0xec, 0x98, 0x40, 0xe5, 0x5a, 0x1e, 0xf7, 0xf9, 0x8e, + 0xf1, 0x93, 0xb5, 0xea, 0x7, 0x6c, 0x7d, 0xe4, 0xa7, 0x9d}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x47, 0xc1, 0x17, 0x98, 0x38, 0x34, 0x48, 0xc, 0x67, 0x32, + 0xd7, 0xc, 0x12, 0x36, 0xd1, 0x9, 0xd8, 0x78, 0x72, 0xac, + 0xe1, 0x3e, 0xf6, 0x45, 0x73, 0x2f, 0x5f, 0xc9}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1a, 0xa4, 0x71, 0xa8, 0xb4, 0xda, 0xdf, 0xbe, 0xcf, 0x52, 0x55, + 0x99, 0xfa, 0xee, 0x2b, 0x45, 0xf7, 0xf4, 0xb7, 0xe7, 0xe1}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xdd, 0x95, 0x41, 0xd3, 0xc3}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; + uint8_t bytesprops0[] = {0x2e, 0x9d, 0x50, 0x5e, 0x80, 0x31, 0xbc, 0xc6, 0x63, 0x32, 0xcd, 0x33, + 0x73, 0x26, 0x8a, 0xe2, 0x6, 0x1f, 0x81, 0x9b, 0xe8, 0x7e, 0xb7}; + uint8_t bytesprops1[] = {0x1a, 0x41, 0x3e, 0xe7, 0x2, 0xae, 0xf7, 0xef, 0x4e, + 0x56, 0x45, 0x97, 0xd7, 0x92, 0x1, 0xaf, 0xab, 0x56}; + uint8_t bytesprops2[] = {0x2, 0x86, 0x45, 0xd0, 0x9c, 0xa, 0xdf, 0x2c, 0x51, 0xa6, + 0xa1, 0x1c, 0x8d, 0xc0, 0xc3, 0xc5, 0x36, 0x19, 0x30, 0x5e}; + uint8_t bytesprops3[] = {0xaf, 0x13, 0xca}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18748}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7310}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18830}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10723}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20286}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25662}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1905}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17048}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6922, 5, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20401, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 26316 [("\229\199\211Bm\186\243W\161\139O{A ^F\180,!5y\243\EOT\166\226opy\131\ESC",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Z\153\&6\215(\215\EM\137\140\252",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("U\\N\255a\146",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\174\\\247w\175\SYN\148o\191E\n[\197\SO\197a\175\227\236",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\DC2\180\170\148L1[`@[\253\159,\136`\ESC\229\DEL5\210\193\ESC@\131\152\212",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\141\&8\227\131\152p\224\162\146\228\175V \142\191QR\139g\188\165vf",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("N\240`q\204\255|\b\156A\227\238",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropMaximumPacketSize 17342,PropPayloadFormatIndicator 202,PropRequestProblemInformation 206,PropTopicAlias 20086,PropWildcardSubscriptionAvailable 171,PropMaximumQoS 190,PropMaximumQoS 87,PropMessageExpiryInterval 29692,PropUserProperty "m\165\210)cD" "\158c\252?'\245\170R*\146\200\208\FS\202p\ENQ",PropServerReference "\201\220\231\219\214\200\231T1\229c\171\238\143\133n\228gd(@\213\SUB",PropMessageExpiryInterval 6551,PropAssignedClientIdentifier "ki\218\160DW=\241\172\244\207\198\STX\130Zm'",PropAssignedClientIdentifier "\212\173\r\148\SOH`\169\241\138\214%\176\239\190\158\&1\160\128\&6Z\SO#\145T\145A]\224\v",PropSessionExpiryInterval 20280,PropPayloadFormatIndicator 72,PropMessageExpiryInterval 21059,PropContentType "\155\221\158",PropTopicAlias 14,PropContentType "W\149`w,f\206\ETXx\184~\142\201\214O\FS",PropSubscriptionIdentifier 0,PropTopicAliasMaximum 15849,PropRetainAvailable 48,PropMessageExpiryInterval 25313] +// SubscribeRequest 8563 [("\143\195\RS\DEL-\129\b/n _",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\152K\195\r\158\128&X\SUB\FSI\163y\128\203\171\SO\227\231K\213\SI&Y\211\EM",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropContentType +// "\159\206p\152)",PropRequestResponseInformation 253,PropServerKeepAlive 32043,PropResponseInformation +// "[\187&\US\146r\201_\142\185\170\136?.\178,\199\SI^=\EM\178\249AC\245\189",PropResponseTopic +// "%\128\CAN\241",PropServerReference +// "K\165\197\SYN\189\NULX\213\224\230`\146\147\b\129\237\SYN\170\190<\206<)\210\US`\236j",PropMessageExpiryInterval +// 632,PropWillDelayInterval 8614,PropMessageExpiryInterval 1653,PropSessionExpiryInterval 2016,PropRetainAvailable +// 232,PropReasonString "\176\&3\159\243N\167\162V\167 \189\158GE\ETBl\149\189",PropSessionExpiryInterval 21353] TEST(Subscribe5QCTest, Encode16) { -uint8_t pkt[] = {0x82, 0xd3, 0x2, 0x66, 0xcc, 0xb9, 0x1, 0x27, 0x0, 0x0, 0x43, 0xbe, 0x1, 0xca, 0x17, 0xce, 0x23, 0x4e, 0x76, 0x28, 0xab, 0x24, 0xbe, 0x24, 0x57, 0x2, 0x0, 0x0, 0x73, 0xfc, 0x26, 0x0, 0x6, 0x6d, 0xa5, 0xd2, 0x29, 0x63, 0x44, 0x0, 0x10, 0x9e, 0x63, 0xfc, 0x3f, 0x27, 0xf5, 0xaa, 0x52, 0x2a, 0x92, 0xc8, 0xd0, 0x1c, 0xca, 0x70, 0x5, 0x1c, 0x0, 0x17, 0xc9, 0xdc, 0xe7, 0xdb, 0xd6, 0xc8, 0xe7, 0x54, 0x31, 0xe5, 0x63, 0xab, 0xee, 0x8f, 0x85, 0x6e, 0xe4, 0x67, 0x64, 0x28, 0x40, 0xd5, 0x1a, 0x2, 0x0, 0x0, 0x19, 0x97, 0x12, 0x0, 0x11, 0x6b, 0x69, 0xda, 0xa0, 0x44, 0x57, 0x3d, 0xf1, 0xac, 0xf4, 0xcf, 0xc6, 0x2,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b, 0x40, 0x83, 0x98, 0xd4, 0x22, 0x0, 0x0, 0x0, 0x0, 0x17, 0x8d, 0x38, 0xe3, 0x83, 0x98, 0x70, 0xe0, 0xa2, 0x92, 0xe4, 0xaf, 0x56, 0x20, 0x8e, 0xbf, 0x51, 0x52, 0x8b, 0x67, 0xbc, 0xa5, 0x76, 0x66, 0x1e, 0x0, 0xc, 0x4e, 0xf0, 0x60, 0x71, 0xcc, 0xff, 0x7c, 0x8, 0x9c, 0x41, 0xe3, 0xee, 0x28}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xe5, 0xc7, 0xd3, 0x42, 0x6d, 0xba, 0xf3, 0x57, 0xa1, 0x8b, 0x4f, 0x7b, 0x41, 0x20, 0x5e, 0x46, 0xb4, 0x2c, 0x21, 0x35, 0x79, 0xf3, 0x4, 0xa6, 0xe2, 0x6f, 0x70, 0x79, 0x83, 0x1b}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5a, 0x99, 0x36, 0xd7, 0x28, 0xd7, 0x19, 0x89, 0x8c, 0xfc}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x55, 0x5c, 0x4e, 0xff, 0x61, 0x92}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xae, 0x5c, 0xf7, 0x77, 0xaf, 0x16, 0x94, 0x6f, 0xbf, 0x45, 0xa, 0x5b, 0xc5, 0xe, 0xc5, 0x61, 0xaf, 0xe3, 0xec}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x12, 0xb4, 0xaa, 0x94, 0x4c, 0x31, 0x5b, 0x60, 0x40, 0x5b, 0xfd, 0x9f, 0x2c, 0x88, 0x60, 0x1b, 0xe5, 0x7f, 0x35, 0xd2, 0xc1, 0x1b, 0x40, 0x83, 0x98, 0xd4}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8d, 0x38, 0xe3, 0x83, 0x98, 0x70, 0xe0, 0xa2, 0x92, 0xe4, 0xaf, 0x56, 0x20, 0x8e, 0xbf, 0x51, 0x52, 0x8b, 0x67, 0xbc, 0xa5, 0x76, 0x66}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x4e, 0xf0, 0x60, 0x71, 0xcc, 0xff, 0x7c, 0x8, 0x9c, 0x41, 0xe3, 0xee}; - lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; -lwmqtt_sub_options_t sub_opts[8]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = true; -sub_opts[1].no_local = true; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = true; -sub_opts[3].qos = LWMQTT_QOS1; -sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[3].retain_as_published = true; -sub_opts[3].no_local = true; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS2; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[6].retain_as_published = true; -sub_opts[6].no_local = true; -sub_opts[7].qos = LWMQTT_QOS0; -sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[7].retain_as_published = true; -sub_opts[7].no_local = false; - uint8_t bytesprops1[] = {0x9e, 0x63, 0xfc, 0x3f, 0x27, 0xf5, 0xaa, 0x52, 0x2a, 0x92, 0xc8, 0xd0, 0x1c, 0xca, 0x70, 0x5}; - uint8_t bytesprops0[] = {0x6d, 0xa5, 0xd2, 0x29, 0x63, 0x44}; - uint8_t bytesprops2[] = {0xc9, 0xdc, 0xe7, 0xdb, 0xd6, 0xc8, 0xe7, 0x54, 0x31, 0xe5, 0x63, 0xab, 0xee, 0x8f, 0x85, 0x6e, 0xe4, 0x67, 0x64, 0x28, 0x40, 0xd5, 0x1a}; - uint8_t bytesprops3[] = {0x6b, 0x69, 0xda, 0xa0, 0x44, 0x57, 0x3d, 0xf1, 0xac, 0xf4, 0xcf, 0xc6, 0x2, 0x82, 0x5a, 0x6d, 0x27}; - uint8_t bytesprops4[] = {0xd4, 0xad, 0xd, 0x94, 0x1, 0x60, 0xa9, 0xf1, 0x8a, 0xd6, 0x25, 0xb0, 0xef, 0xbe, 0x9e, 0x31, 0xa0, 0x80, 0x36, 0x5a, 0xe, 0x23, 0x91, 0x54, 0x91, 0x41, 0x5d, 0xe0, 0xb}; - uint8_t bytesprops5[] = {0x9b, 0xdd, 0x9e}; - uint8_t bytesprops6[] = {0x57, 0x95, 0x60, 0x77, 0x2c, 0x66, 0xce, 0x3, 0x78, 0xb8, 0x7e, 0x8e, 0xc9, 0xd6, 0x4f, 0x1c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17342}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20086}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29692}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={6, (char*)&bytesprops0}, .v={16, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6551}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20280}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21059}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15849}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)2, .value = {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of(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x8f, 0xc3, 0x1e, 0x7f, 0x2d, 0x81, 0x8, 0x2f, 0x6e, 0x20, 0x5f}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x98, 0x4b, 0xc3, 0xd, 0x9e, 0x80, 0x26, 0x58, 0x1a, 0x1c, 0x49, 0xa3, 0x79, + 0x80, 0xcb, 0xab, 0xe, 0xe3, 0xe7, 0x4b, 0xd5, 0xf, 0x26, 0x59, 0xd3, 0x19}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + uint8_t bytesprops0[] = {0x9f, 0xce, 0x70, 0x98, 0x29}; + uint8_t bytesprops1[] = {0x5b, 0xbb, 0x26, 0x1f, 0x92, 0x72, 0xc9, 0x5f, 0x8e, 0xb9, 0xaa, 0x88, 0x3f, 0x2e, + 0xb2, 0x2c, 0xc7, 0xf, 0x5e, 0x3d, 0x19, 0xb2, 0xf9, 0x41, 0x43, 0xf5, 0xbd}; + uint8_t bytesprops2[] = {0x25, 0x80, 0x18, 0xf1}; + uint8_t bytesprops3[] = {0x4b, 0xa5, 0xc5, 0x16, 0xbd, 0x0, 0x58, 0xd5, 0xe0, 0xe6, 0x60, 0x92, 0x93, 0x8, + 0x81, 0xed, 0x16, 0xaa, 0xbe, 0x3c, 0xce, 0x3c, 0x29, 0xd2, 0x1f, 0x60, 0xec, 0x6a}; + uint8_t bytesprops4[] = {0xb0, 0x33, 0x9f, 0xf3, 0x4e, 0xa7, 0xa2, 0x56, 0xa7, + 0x20, 0xbd, 0x9e, 0x47, 0x45, 0x17, 0x6c, 0x95, 0xbd}; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32043}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 632}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8614}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1653}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2016}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21353}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26316, 8, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8563, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 3621 [("7\186\177\153l\246\228+]4\237O$\165\135q\230\DC3b\180\SI\194\248\ACK\t",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("+\SO\164",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\152\172d3k\243}\216\210y\232\152",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\208'\165Pi\\8\EOT*/\191\202\180A\237\164",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("Z\152\229",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\227a\230",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\178\254\234\\\139\236\222\v\188\159\236\DLE\215\254\SO.\128\250\160\128",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropRequestResponseInformation 86,PropTopicAliasMaximum 24273,PropTopicAliasMaximum 7199] +// SubscribeRequest 7682 [("\RS `P\209\153\210\225\236\187\202\241L\148\241X",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\ENQM\221\168\223",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\138\SYN\nG\DC3\GS\189\169\136\188\248~1A\160\133\254\212)\197\\",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("X\218\142\219\222C\214\142\ETX\209]-\202k\ESC\146h\161m\207",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\165\153\b\146/\NUL\131\v\215\&9=O\238-\235\DLEg\161@\SYN\ENQ\bZ\163\223\185z",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\201'\162\130h\150\158/\184\FS\131\156\251",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropPayloadFormatIndicator +// 188,PropAuthenticationMethod "\215\201\189\244\208",PropMessageExpiryInterval 7937,PropSubscriptionIdentifier +// 15,PropAuthenticationMethod +// "\200\US\253\244\NAK\155\243r\188\246\211\FS\179\NUL\179U\216]\179\144\EM\237\181MO\218\213\255K\205",PropWillDelayInterval +// 28417,PropServerKeepAlive 21564,PropServerReference "\249\248\176S\225\188\133\136\255\157\176",PropMaximumQoS +// 201,PropSubscriptionIdentifierAvailable 153,PropTopicAliasMaximum 29985] TEST(Subscribe5QCTest, Encode17) { -uint8_t pkt[] = {0x82, 0x72, 0xe, 0x25, 0x8, 0x19, 0x56, 0x22, 0x5e, 0xd1, 0x22, 0x1c, 0x1f, 0x0, 0x19, 0x37, 0xba, 0xb1, 0x99, 0x6c, 0xf6, 0xe4, 0x2b, 0x5d, 0x34, 0xed, 0x4f, 0x24, 0xa5, 0x87, 0x71, 0xe6, 0x13, 0x62, 0xb4, 0xf, 0xc2, 0xf8, 0x6, 0x9, 0x2a, 0x0, 0x3, 0x2b, 0xe, 0xa4, 0x1e, 0x0, 0xc, 0x98, 0xac, 0x64, 0x33, 0x6b, 0xf3, 0x7d, 0xd8, 0xd2, 0x79, 0xe8, 0x98, 0x25, 0x0, 0x10, 0xd0, 0x27, 0xa5, 0x50, 0x69, 0x5c, 0x38, 0x4, 0x2a, 0x2f, 0xbf, 0xca, 0xb4, 0x41, 0xed, 0xa4, 0xa, 0x0, 0x3, 0x5a, 0x98, 0xe5, 0x29, 0x0, 0x3, 0xe3, 0x61, 0xe6, 0x6, 0x0, 0x14, 0xb2, 0xfe, 0xea, 0x5c, 0x8b, 0xec, 0xde, 0xb, 0xbc, 0x9f, 0xec, 0x10, 0xd7, 0xfe, 0xe, 0x2e, 0x80, 0xfa, 0xa0, 0x80, 0x1e}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x37, 0xba, 0xb1, 0x99, 0x6c, 0xf6, 0xe4, 0x2b, 0x5d, 0x34, 0xed, 0x4f, 0x24, 0xa5, 0x87, 0x71, 0xe6, 0x13, 0x62, 0xb4, 0xf, 0xc2, 0xf8, 0x6, 0x9}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2b, 0xe, 0xa4}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x98, 0xac, 0x64, 0x33, 0x6b, 0xf3, 0x7d, 0xd8, 0xd2, 0x79, 0xe8, 0x98}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd0, 0x27, 0xa5, 0x50, 0x69, 0x5c, 0x38, 0x4, 0x2a, 0x2f, 0xbf, 0xca, 0xb4, 0x41, 0xed, 0xa4}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5a, 0x98, 0xe5}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xe3, 0x61, 0xe6}; - lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb2, 0xfe, 0xea, 0x5c, 0x8b, 0xec, 0xde, 0xb, 0xbc, 0x9f, 0xec, 0x10, 0xd7, 0xfe, 0xe, 0x2e, 0x80, 0xfa, 0xa0, 0x80}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; -lwmqtt_sub_options_t sub_opts[7]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[0].retain_as_published = true; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[1].retain_as_published = true; -sub_opts[1].no_local = true; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = true; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = true; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS1; -sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[4].retain_as_published = true; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS2; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = true; -sub_opts[6].qos = LWMQTT_QOS2; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[6].retain_as_published = true; -sub_opts[6].no_local = true; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24273}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7199}}, - }; + uint8_t pkt[] = { + 0x82, 0xca, 0x1, 0x1e, 0x2, 0x4f, 0x1, 0xbc, 0x15, 0x0, 0x5, 0xd7, 0xc9, 0xbd, 0xf4, 0xd0, 0x2, 0x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0x9c, 0xfb, 0x18}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x1e, 0x20, 0x60, 0x50, 0xd1, 0x99, 0xd2, 0xe1, + 0xec, 0xbb, 0xca, 0xf1, 0x4c, 0x94, 0xf1, 0x58}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x5, 0x4d, 0xdd, 0xa8, 0xdf}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x8a, 0x16, 0xa, 0x47, 0x13, 0x1d, 0xbd, 0xa9, 0x88, 0xbc, 0xf8, + 0x7e, 0x31, 0x41, 0xa0, 0x85, 0xfe, 0xd4, 0x29, 0xc5, 0x5c}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x58, 0xda, 0x8e, 0xdb, 0xde, 0x43, 0xd6, 0x8e, 0x3, 0xd1, + 0x5d, 0x2d, 0xca, 0x6b, 0x1b, 0x92, 0x68, 0xa1, 0x6d, 0xcf}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa5, 0x99, 0x8, 0x92, 0x2f, 0x0, 0x83, 0xb, 0xd7, 0x39, 0x3d, 0x4f, 0xee, 0x2d, + 0xeb, 0x10, 0x67, 0xa1, 0x40, 0x16, 0x5, 0x8, 0x5a, 0xa3, 0xdf, 0xb9, 0x7a}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xc9, 0x27, 0xa2, 0x82, 0x68, 0x96, 0x9e, 0x2f, 0xb8, 0x1c, 0x83, 0x9c, 0xfb}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + uint8_t bytesprops0[] = {0xd7, 0xc9, 0xbd, 0xf4, 0xd0}; + uint8_t bytesprops1[] = {0xc8, 0x1f, 0xfd, 0xf4, 0x15, 0x9b, 0xf3, 0x72, 0xbc, 0xf6, 0xd3, 0x1c, 0xb3, 0x0, 0xb3, + 0x55, 0xd8, 0x5d, 0xb3, 0x90, 0x19, 0xed, 0xb5, 0x4d, 0x4f, 0xda, 0xd5, 0xff, 0x4b, 0xcd}; + uint8_t bytesprops2[] = {0xf9, 0xf8, 0xb0, 0x53, 0xe1, 0xbc, 0x85, 0x88, 0xff, 0x9d, 0xb0}; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7937}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28417}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21564}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29985}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3621, 7, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7682, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 17519 [("\237*\219:\226s\140\&8K \188\244l\243f\DC2|\184\193/\SYN\148\187\SOH\137\228:\ACK",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\223\254xc\242\211\169\140",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("4\144\223\145\225\223\164[Kn\246\237}J,z\141\238",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropMaximumQoS 197,PropMaximumPacketSize 3676,PropCorrelationData "\146\181\224\ACK\186\202\DC4v$\195\148bT\SUB\181\239t\205\182\161\&0\154\RSw'\ACKn",PropRequestProblemInformation 117,PropSharedSubscriptionAvailable 47,PropWillDelayInterval 12249,PropSubscriptionIdentifier 2,PropRequestResponseInformation 90,PropMessageExpiryInterval 4001,PropRetainAvailable 182,PropCorrelationData "\223\NUL\227\&8\140\DEL",PropRequestResponseInformation 223,PropReasonString "w\146\NAK\STX\245\161\148\159\193\152\201A,:\181\230\DC3\158L\164",PropMaximumPacketSize 4942,PropMessageExpiryInterval 29241,PropCorrelationData "\216*\128",PropContentType "\ETB\140e6\165\192U.\250\161\133f\214\173\198\135\128\204u\\\f\186S\148\129-5\STX\188:",PropAssignedClientIdentifier "hq+\134'\245\132bx\199\255\143\142\223{\241 \169\227\199\FS\178\NAK\150\208",PropSubscriptionIdentifier 25,PropTopicAlias 3143,PropMessageExpiryInterval 30304,PropWillDelayInterval 25711,PropWillDelayInterval 5752,PropSharedSubscriptionAvailable 68,PropPayloadFormatIndicator 153,PropResponseTopic "J\234<\228\191\206\247CD\213G\167",PropSubscriptionIdentifierAvailable 118,PropResponseTopic "w\222=\175_\DLE"] +// SubscribeRequest 9224 [("\199\229\146\190\EOT\224",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\238\163\ETB\179[\253\146N.\169\223$\202\251\ENQ\183\191\183`\165\135\152f-qP\201\189\SUB",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("f\133\252\176\189\165",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS0}),("ai\ETX\141\131P\247\191\147\143",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropMaximumQoS 210,PropWillDelayInterval +// 8103,PropUserProperty "\159\161:\170\151\205" +// "\ETB\139\222\ENQ\141\251\198\192\152nA\DC4\237\199x\240\&7\234Oz",PropMaximumPacketSize 25020,PropContentType +// "\199e\202`\233\172\"\155\187\253\220md}Z\225\\\135",PropContentType +// "V\187\154$EZ\243\208=\203\150\223A\153\223\209\131\235\SUB\n\208",PropCorrelationData "\219",PropMaximumQoS +// 103,PropRequestProblemInformation 63,PropMessageExpiryInterval 13825,PropResponseInformation "\190\207s +// #\164\DC4\239\145\252\183\195\206\165G\249\131\215\157\173",PropAssignedClientIdentifier +// "A\ENQ\174>\187i\165\ENQ\164\179F\DEL\166N;L\242\&1\229\196A\173\142\162k\142\&2\rB6",PropRequestResponseInformation +// 84,PropServerReference "L\167\&3k\206GU4)",PropPayloadFormatIndicator 37,PropMessageExpiryInterval +// 31778,PropRequestProblemInformation 119,PropWildcardSubscriptionAvailable 150,PropUserProperty +// "\132\218\239\163T;j\181\143\179`" "\255(UW\194\194\187\251W"] TEST(Subscribe5QCTest, Encode18) { -uint8_t pkt[] = {0x82, 0x9d, 0x2, 0x44, 0x6f, 0xda, 0x1, 0x24, 0xc5, 0x27, 0x0, 0x0, 0xe, 0x5c, 0x9, 0x0, 0x1b, 0x92, 0xb5, 0xe0, 0x6, 0xba, 0xca, 0x14, 0x76, 0x24, 0xc3, 0x94, 0x62, 0x54, 0x1a, 0xb5, 0xef, 0x74, 0xcd, 0xb6, 0xa1, 0x30, 0x9a, 0x1e, 0x77, 0x27, 0x6, 0x6e, 0x17, 0x75, 0x2a, 0x2f, 0x18, 0x0, 0x0, 0x2f, 0xd9, 0xb, 0x2, 0x19, 0x5a, 0x2, 0x0, 0x0, 0xf, 0xa1, 0x25, 0xb6, 0x9, 0x0, 0x6, 0xdf, 0x0, 0xe3, 0x38, 0x8c, 0x7f, 0x19, 0xdf, 0x1f, 0x0, 0x14, 0x77, 0x92, 0x15, 0x2, 0xf5, 0xa1, 0x94, 0x9f, 0xc1, 0x98, 0xc9, 0x41, 0x2c, 0x3a, 0x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0x7d, 0x4a, 0x2c, 0x7a, 0x8d, 0xee, 0x6}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x2a, 0xdb, 0x3a, 0xe2, 0x73, 0x8c, 0x38, 0x4b, 0x20, 0xbc, 0xf4, 0x6c, 0xf3, 0x66, 0x12, 0x7c, 0xb8, 0xc1, 0x2f, 0x16, 0x94, 0xbb, 0x1, 0x89, 0xe4, 0x3a, 0x6}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xdf, 0xfe, 0x78, 0x63, 0xf2, 0xd3, 0xa9, 0x8c}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x34, 0x90, 0xdf, 0x91, 0xe1, 0xdf, 0xa4, 0x5b, 0x4b, 0x6e, 0xf6, 0xed, 0x7d, 0x4a, 0x2c, 0x7a, 0x8d, 0xee}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; -lwmqtt_sub_options_t sub_opts[3]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[0].retain_as_published = true; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[1].retain_as_published = true; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = true; - uint8_t bytesprops0[] = {0x92, 0xb5, 0xe0, 0x6, 0xba, 0xca, 0x14, 0x76, 0x24, 0xc3, 0x94, 0x62, 0x54, 0x1a, 0xb5, 0xef, 0x74, 0xcd, 0xb6, 0xa1, 0x30, 0x9a, 0x1e, 0x77, 0x27, 0x6, 0x6e}; - uint8_t bytesprops1[] = {0xdf, 0x0, 0xe3, 0x38, 0x8c, 0x7f}; - uint8_t bytesprops2[] = {0x77, 0x92, 0x15, 0x2, 0xf5, 0xa1, 0x94, 0x9f, 0xc1, 0x98, 0xc9, 0x41, 0x2c, 0x3a, 0xb5, 0xe6, 0x13, 0x9e, 0x4c, 0xa4}; - uint8_t bytesprops3[] = {0xd8, 0x2a, 0x80}; - uint8_t bytesprops4[] = {0x17, 0x8c, 0x65, 0x36, 0xa5, 0xc0, 0x55, 0x2e, 0xfa, 0xa1, 0x85, 0x66, 0xd6, 0xad, 0xc6, 0x87, 0x80, 0xcc, 0x75, 0x5c, 0xc, 0xba, 0x53, 0x94, 0x81, 0x2d, 0x35, 0x2, 0xbc, 0x3a}; - uint8_t bytesprops5[] = {0x68, 0x71, 0x2b, 0x86, 0x27, 0xf5, 0x84, 0x62, 0x78, 0xc7, 0xff, 0x8f, 0x8e, 0xdf, 0x7b, 0xf1, 0x20, 0xa9, 0xe3, 0xc7, 0x1c, 0xb2, 0x15, 0x96, 0xd0}; - uint8_t bytesprops6[] = {0x4a, 0xea, 0x3c, 0xe4, 0xbf, 0xce, 0xf7, 0x43, 0x44, 0xd5, 0x47, 0xa7}; - uint8_t bytesprops7[] = {0x77, 0xde, 0x3d, 0xaf, 0x5f, 0x10}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3676}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12249}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4001}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4942}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29241}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3143}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30304}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25711}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5752}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops7}}}, + uint8_t pkt[] = { + 0x82, 0x92, 0x2, 0x24, 0x8, 0xcf, 0x1, 0x24, 0xd2, 0x18, 0x0, 0x0, 0x1f, 0xa7, 0x26, 0x0, 0x6, 0x9f, 0xa1, + 0x3a, 0xaa, 0x97, 0xcd, 0x0, 0x14, 0x17, 0x8b, 0xde, 0x5, 0x8d, 0xfb, 0xc6, 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0xbe, 0x4, 0xe0, 0x1c, 0x0, 0x1d, 0xee, 0xa3, 0x17, + 0xb3, 0x5b, 0xfd, 0x92, 0x4e, 0x2e, 0xa9, 0xdf, 0x24, 0xca, 0xfb, 0x5, 0xb7, 0xbf, 0xb7, 0x60, 0xa5, 0x87, 0x98, + 0x66, 0x2d, 0x71, 0x50, 0xc9, 0xbd, 0x1a, 0x5, 0x0, 0x6, 0x66, 0x85, 0xfc, 0xb0, 0xbd, 0xa5, 0x24, 0x0, 0xa, + 0x61, 0x69, 0x3, 0x8d, 0x83, 0x50, 0xf7, 0xbf, 0x93, 0x8f, 0x4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xc7, 0xe5, 0x92, 0xbe, 0x4, 0xe0}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xee, 0xa3, 0x17, 0xb3, 0x5b, 0xfd, 0x92, 0x4e, 0x2e, 0xa9, + 0xdf, 0x24, 0xca, 0xfb, 0x5, 0xb7, 0xbf, 0xb7, 0x60, 0xa5, + 0x87, 0x98, 0x66, 0x2d, 0x71, 0x50, 0xc9, 0xbd, 0x1a}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x66, 0x85, 0xfc, 0xb0, 0xbd, 0xa5}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x61, 0x69, 0x3, 0x8d, 0x83, 0x50, 0xf7, 0xbf, 0x93, 0x8f}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + uint8_t bytesprops1[] = {0x17, 0x8b, 0xde, 0x5, 0x8d, 0xfb, 0xc6, 0xc0, 0x98, 0x6e, + 0x41, 0x14, 0xed, 0xc7, 0x78, 0xf0, 0x37, 0xea, 0x4f, 0x7a}; + uint8_t bytesprops0[] = {0x9f, 0xa1, 0x3a, 0xaa, 0x97, 0xcd}; + uint8_t bytesprops2[] = {0xc7, 0x65, 0xca, 0x60, 0xe9, 0xac, 0x22, 0x9b, 0xbb, + 0xfd, 0xdc, 0x6d, 0x64, 0x7d, 0x5a, 0xe1, 0x5c, 0x87}; + uint8_t bytesprops3[] = {0x56, 0xbb, 0x9a, 0x24, 0x45, 0x5a, 0xf3, 0xd0, 0x3d, 0xcb, 0x96, + 0xdf, 0x41, 0x99, 0xdf, 0xd1, 0x83, 0xeb, 0x1a, 0xa, 0xd0}; + uint8_t bytesprops4[] = {0xdb}; + uint8_t bytesprops5[] = {0xbe, 0xcf, 0x73, 0x20, 0x23, 0xa4, 0x14, 0xef, 0x91, 0xfc, + 0xb7, 0xc3, 0xce, 0xa5, 0x47, 0xf9, 0x83, 0xd7, 0x9d, 0xad}; + uint8_t bytesprops6[] = {0x41, 0x5, 0xae, 0x3e, 0xbb, 0x69, 0xa5, 0x5, 0xa4, 0xb3, 0x46, 0x7f, 0xa6, 0x4e, 0x3b, + 0x4c, 0xf2, 0x31, 0xe5, 0xc4, 0x41, 0xad, 0x8e, 0xa2, 0x6b, 0x8e, 0x32, 0xd, 0x42, 0x36}; + uint8_t bytesprops7[] = {0x4c, 0xa7, 0x33, 0x6b, 0xce, 0x47, 0x55, 0x34, 0x29}; + uint8_t bytesprops9[] = {0xff, 0x28, 0x55, 0x57, 0xc2, 0xc2, 0xbb, 0xfb, 0x57}; + uint8_t bytesprops8[] = {0x84, 0xda, 0xef, 0xa3, 0x54, 0x3b, 0x6a, 0xb5, 0x8f, 0xb3, 0x60}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8103}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25020}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13825}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31778}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops8}, .v = {9, (char*)&bytesprops9}}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17519, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9224, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 3152 [("\221jG\162A\208>\210\170r",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\198\138\161\233\v\180\STX\241\207\221\150\234\128)\130\nF\209\ETX\GSVdb",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\148y\243\207\167\176HiA\209\148mB\219\169\138\169c\r\173b\150Q\247\153}\221F",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\243\171\216\165!\EOT,g\235G\164 2\206\211-\b-D\218",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropPayloadFormatIndicator 48,PropTopicAlias 5835,PropMessageExpiryInterval 29048,PropResponseInformation "\188\164\EM\205@\235\tL6\213\238\233A\EM\194\\\229\247 \ESC&\211(\ETB",PropSubscriptionIdentifierAvailable 228,PropContentType "S\171\ETX\b\139\191Y\219\234\&3j]\193\195u2\215\153",PropResponseTopic "\167\225N{\142\r\163\214\133\155\188\EOT\231\151<\DLE\SUB",PropMaximumPacketSize 13133,PropRequestResponseInformation 229,PropRequestProblemInformation 75] +// SubscribeRequest 14508 [("R\USc\174\228\248\201\SYN\DC3\248\&2\191\130\SUB\146'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(":\200\140\238\238\173\241A\v\155\186\&9#m$\204\SUBe?Qr\214<3Q9O\214",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),(" \139\195\231G\f\SOHqD*F\221%F\SYN\142\&7\207\252",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("@\217Q\249+\DLE\152\DLE\237\v\180[",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\207\SI\195\138W\141H2\157b?\147N\147# a%\239\181G\236[m\NULx",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\226>An\226G\185\FS",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\131\189l\133\133\tg\128\139\&9<\151y<\197o\204\221\132\&6\151\253\213\196\&3\221i",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropResponseTopic "=\250i{\136y\SUB\224.\228\&8GLxb\151\171>N\NAK\243",PropCorrelationData "=v2\173n\EOT\FS\170s\182",PropTopicAliasMaximum 26880,PropTopicAlias 15262,PropMaximumQoS 40,PropSubscriptionIdentifierAvailable 189,PropServerReference "V\ETX\203\218\214\138\&14n7\172oZ\135\234\210\237\143\SO",PropRequestProblemInformation 46,PropTopicAlias 24607,PropSubscriptionIdentifier 7,PropServerKeepAlive 27192,PropSessionExpiryInterval 623,PropReceiveMaximum 27376,PropReasonString "B!\188\137'\FSL\213",PropSubscriptionIdentifierAvailable 49,PropAuthenticationMethod "\249Jo\182\210\182\168p>\ENQ&S\155\189P\DEL\179\239\&5\160\163iaGi\218<\159\240v",PropMessageExpiryInterval 2499,PropTopicAliasMaximum 12723] +// SubscribeRequest 24389 [("\255L)[J\CAN\t\240\&1\138\n",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\230\203\206\212\216\253-\EOT\b\248<",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropServerKeepAlive 20334,PropRequestProblemInformation 235,PropSubscriptionIdentifier 27,PropRetainAvailable +// 7,PropPayloadFormatIndicator 25,PropAuthenticationData "`\155",PropResponseTopic "J\132^$",PropSubscriptionIdentifier +// 12,PropCorrelationData +// "\155@\152\SOHV;\SYN\155\&8m\"\213\154N\207+\254\179P\128\213\ENQ\209?\232P1\187\187",PropTopicAlias +// 9652,PropPayloadFormatIndicator 245,PropResponseInformation "",PropPayloadFormatIndicator 152,PropTopicAlias +// 23632,PropWildcardSubscriptionAvailable 49,PropRequestProblemInformation 208,PropCorrelationData +// "|\EM\186mXWwA\178\169\SYN\205\NUL\180\252G\251\157+\STX\186",PropMaximumQoS 114,PropServerKeepAlive +// 3725,PropWildcardSubscriptionAvailable 127,PropAuthenticationMethod +// "^\177\129\138\159\129]\NUL\129\215\181\EOT2\253\ACK\241\&3\179\195\"GKO+>\128\ENQ5",PropServerKeepAlive +// 17385,PropSubscriptionIdentifierAvailable 202,PropUserProperty +// "\251\CAN\177\245\143~JIPS<\205\148\212\199\249\223\133\151_\\>\245\215" "+",PropCorrelationData +// "\ACK\SO\222A\ACK\197#\215?\128\157\226L1",PropReceiveMaximum 8463,PropSubscriptionIdentifierAvailable 254] TEST(Subscribe5QCTest, Encode20) { -uint8_t pkt[] = {0x82, 0xcd, 0x2, 0x42, 0xf6, 0x8d, 0x1, 0x8, 0x0, 0x15, 0x3d, 0xfa, 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, 0x3a, 0xc8, 0x8c, 0xee, 0xee, 0xad, 0xf1, 0x41, 0xb, 0x9b, 0xba, 0x39, 0x23, 0x6d, 0x24, 0xcc, 0x1a, 0x65, 0x3f, 0x51, 0x72, 0xd6, 0x3c, 0x33, 0x51, 0x39, 0x4f, 0xd6, 0xa, 0x0, 0x13, 0x20, 0x8b, 0xc3, 0xe7, 0x47, 0xc, 0x1, 0x71, 0x44, 0x2a, 0x46, 0xdd, 0x25, 0x46, 0x16, 0x8e, 0x37, 0xcf, 0xfc, 0x14, 0x0, 0xc, 0x40, 0xd9, 0x51, 0xf9, 0x2b, 0x10, 0x98, 0x10, 0xed, 0xb, 0xb4, 0x5b, 0x2d, 0x0, 0x1a, 0xcf, 0xf, 0xc3, 0x8a, 0x57, 0x8d, 0x48, 0x32, 0x9d, 0x62, 0x3f, 0x93, 0x4e, 0x93, 0x23, 0x20, 0x61, 0x25, 0xef, 0xb5, 0x47, 0xec, 0x5b, 0x6d, 0x0, 0x78, 0x5, 0x0, 0x8, 0xe2, 0x3e, 0x41, 0x6e, 0xe2, 0x47, 0xb9, 0x1c, 0x2c, 0x0, 0x1b, 0x83, 0xbd, 0x6c, 0x85, 0x85, 0x9, 0x67, 0x80, 0x8b, 0x39, 0x3c, 0x97, 0x79, 0x3c, 0xc5, 0x6f, 0xcc, 0xdd, 0x84, 0x36, 0x97, 0xfd, 0xd5, 0xc4, 0x33, 0xdd, 0x69, 0x21}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x65, 0x30, 0xd3, 0xa, 0x28, 0x31, 0x7, 0x5b, 0x6d, 0xc0, 0xfa, 0x86, 0xb3, 0x52, 0x9c, 0x3a, 0x7f, 0xd9, 0x33, 0x8f, 0x5a, 0xe4, 0xba, 0xe0, 0x1f, 0x80, 0xa4, 0xc2, 0xa7, 0xdf}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xec, 0x5e, 0x3a, 0x16, 0x57, 0xf9, 0xb6, 0x37, 0x3e, 0xbf, 0x82, 0x1a, 0x92, 0x27}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x3a, 0xc8, 0x8c, 0xee, 0xee, 0xad, 0xf1, 0x41, 0xb, 0x9b, 0xba, 0x39, 0x23, 0x6d, 0x24, 0xcc, 0x1a, 0x65, 0x3f, 0x51, 0x72, 0xd6, 0x3c, 0x33, 0x51, 0x39, 0x4f, 0xd6}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x20, 0x8b, 0xc3, 0xe7, 0x47, 0xc, 0x1, 0x71, 0x44, 0x2a, 0x46, 0xdd, 0x25, 0x46, 0x16, 0x8e, 0x37, 0xcf, 0xfc}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x40, 0xd9, 0x51, 0xf9, 0x2b, 0x10, 0x98, 0x10, 0xed, 0xb, 0xb4, 0x5b}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xcf, 0xf, 0xc3, 0x8a, 0x57, 0x8d, 0x48, 0x32, 0x9d, 0x62, 0x3f, 0x93, 0x4e, 0x93, 0x23, 0x20, 0x61, 0x25, 0xef, 0xb5, 0x47, 0xec, 0x5b, 0x6d, 0x0, 0x78}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xe2, 0x3e, 0x41, 0x6e, 0xe2, 0x47, 0xb9, 0x1c}; - lwmqtt_string_t topic_filter_s6 = {8, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x83, 0xbd, 0x6c, 0x85, 0x85, 0x9, 0x67, 0x80, 0x8b, 0x39, 0x3c, 0x97, 0x79, 0x3c, 0xc5, 0x6f, 0xcc, 0xdd, 0x84, 0x36, 0x97, 0xfd, 0xd5, 0xc4, 0x33, 0xdd, 0x69}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; -lwmqtt_sub_options_t sub_opts[8]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[0].retain_as_published = true; -sub_opts[0].no_local = true; -sub_opts[1].qos = LWMQTT_QOS0; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = true; -sub_opts[2].no_local = false; -sub_opts[3].qos = LWMQTT_QOS0; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = true; -sub_opts[4].qos = LWMQTT_QOS1; -sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[4].retain_as_published = true; -sub_opts[4].no_local = true; -sub_opts[5].qos = LWMQTT_QOS1; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = true; -sub_opts[6].qos = LWMQTT_QOS0; -sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[6].retain_as_published = true; -sub_opts[6].no_local = true; -sub_opts[7].qos = LWMQTT_QOS1; -sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[7].retain_as_published = false; -sub_opts[7].no_local = false; - uint8_t bytesprops0[] = {0x3d, 0xfa, 0x69, 0x7b, 0x88, 0x79, 0x1a, 0xe0, 0x2e, 0xe4, 0x38, 0x47, 0x4c, 0x78, 0x62, 0x97, 0xab, 0x3e, 0x4e, 0x15, 0xf3}; - uint8_t bytesprops1[] = {0x3d, 0x76, 0x32, 0xad, 0x6e, 0x4, 0x1c, 0xaa, 0x73, 0xb6}; - uint8_t bytesprops2[] = {0x56, 0x3, 0xcb, 0xda, 0xd6, 0x8a, 0x31, 0x34, 0x6e, 0x37, 0xac, 0x6f, 0x5a, 0x87, 0xea, 0xd2, 0xed, 0x8f, 0xe}; - uint8_t bytesprops3[] = {0x42, 0x21, 0xbc, 0x89, 0x27, 0x1c, 0x4c, 0xd5}; - uint8_t bytesprops4[] = {0xf9, 0x4a, 0x6f, 0xb6, 0xd2, 0xb6, 0xa8, 0x70, 0x3e, 0x5, 0x26, 0x53, 0x9b, 0xbd, 0x50, 0x7f, 0xb3, 0xef, 0x35, 0xa0, 0xa3, 0x69, 0x61, 0x47, 0x69, 0xda, 0x3c, 0x9f, 0xf0, 0x76}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26880}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15262}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24607}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27192}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 623}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27376}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2499}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12723}}, + uint8_t pkt[] = { + 0x82, 0xe1, 0x1, 0x5f, 0x45, 0xc1, 0x1, 0x13, 0x4f, 0x6e, 0x17, 0xeb, 0xb, 0x1b, 0x25, 0x7, 0x1, 0x19, 0x16, + 0x0, 0x2, 0x60, 0x9b, 0x8, 0x0, 0x4, 0x4a, 0x84, 0x5e, 0x24, 0xb, 0xc, 0x9, 0x0, 0x1d, 0x9b, 0x40, 0x98, + 0x1, 0x56, 0x3b, 0x16, 0x9b, 0x38, 0x6d, 0x22, 0xd5, 0x9a, 0x4e, 0xcf, 0x2b, 0xfe, 0xb3, 0x50, 0x80, 0xd5, 0x5, + 0xd1, 0x3f, 0xe8, 0x50, 0x31, 0xbb, 0xbb, 0x23, 0x25, 0xb4, 0x1, 0xf5, 0x1a, 0x0, 0x0, 0x1, 0x98, 0x23, 0x5c, + 0x50, 0x28, 0x31, 0x17, 0xd0, 0x9, 0x0, 0x15, 0x7c, 0x19, 0xba, 0x6d, 0x58, 0x57, 0x77, 0x41, 0xb2, 0xa9, 0x16, + 0xcd, 0x0, 0xb4, 0xfc, 0x47, 0xfb, 0x9d, 0x2b, 0x2, 0xba, 0x24, 0x72, 0x13, 0xe, 0x8d, 0x28, 0x7f, 0x15, 0x0, + 0x1c, 0x5e, 0xb1, 0x81, 0x8a, 0x9f, 0x81, 0x5d, 0x0, 0x81, 0xd7, 0xb5, 0x4, 0x32, 0xfd, 0x6, 0xf1, 0x33, 0xb3, + 0xc3, 0x22, 0x47, 0x4b, 0x4f, 0x2b, 0x3e, 0x80, 0x5, 0x35, 0x13, 0x43, 0xe9, 0x29, 0xca, 0x26, 0x0, 0x18, 0xfb, + 0x18, 0xb1, 0xf5, 0x8f, 0x7e, 0x4a, 0x49, 0x50, 0x53, 0x3c, 0xcd, 0x94, 0xd4, 0xc7, 0xf9, 0xdf, 0x85, 0x97, 0x5f, + 0x5c, 0x3e, 0xf5, 0xd7, 0x0, 0x1, 0x2b, 0x9, 0x0, 0xe, 0x6, 0xe, 0xde, 0x41, 0x6, 0xc5, 0x23, 0xd7, 0x3f, + 0x80, 0x9d, 0xe2, 0x4c, 0x31, 0x21, 0x21, 0xf, 0x29, 0xfe, 0x0, 0xb, 0xff, 0x4c, 0x29, 0x5b, 0x4a, 0x18, 0x9, + 0xf0, 0x31, 0x8a, 0xa, 0x4, 0x0, 0xb, 0xe6, 0xcb, 0xce, 0xd4, 0xd8, 0xfd, 0x2d, 0x4, 0x8, 0xf8, 0x3c, 0x20}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xff, 0x4c, 0x29, 0x5b, 0x4a, 0x18, 0x9, 0xf0, 0x31, 0x8a, 0xa}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xe6, 0xcb, 0xce, 0xd4, 0xd8, 0xfd, 0x2d, 0x4, 0x8, 0xf8, 0x3c}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + uint8_t bytesprops0[] = {0x60, 0x9b}; + uint8_t bytesprops1[] = {0x4a, 0x84, 0x5e, 0x24}; + uint8_t bytesprops2[] = {0x9b, 0x40, 0x98, 0x1, 0x56, 0x3b, 0x16, 0x9b, 0x38, 0x6d, 0x22, 0xd5, 0x9a, 0x4e, 0xcf, + 0x2b, 0xfe, 0xb3, 0x50, 0x80, 0xd5, 0x5, 0xd1, 0x3f, 0xe8, 0x50, 0x31, 0xbb, 0xbb}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x7c, 0x19, 0xba, 0x6d, 0x58, 0x57, 0x77, 0x41, 0xb2, 0xa9, 0x16, + 0xcd, 0x0, 0xb4, 0xfc, 0x47, 0xfb, 0x9d, 0x2b, 0x2, 0xba}; + uint8_t bytesprops5[] = {0x5e, 0xb1, 0x81, 0x8a, 0x9f, 0x81, 0x5d, 0x0, 0x81, 0xd7, 0xb5, 0x4, 0x32, 0xfd, + 0x6, 0xf1, 0x33, 0xb3, 0xc3, 0x22, 0x47, 0x4b, 0x4f, 0x2b, 0x3e, 0x80, 0x5, 0x35}; + uint8_t bytesprops7[] = {0x2b}; + uint8_t bytesprops6[] = {0xfb, 0x18, 0xb1, 0xf5, 0x8f, 0x7e, 0x4a, 0x49, 0x50, 0x53, 0x3c, 0xcd, + 0x94, 0xd4, 0xc7, 0xf9, 0xdf, 0x85, 0x97, 0x5f, 0x5c, 0x3e, 0xf5, 0xd7}; + uint8_t bytesprops8[] = {0x6, 0xe, 0xde, 0x41, 0x6, 0xc5, 0x23, 0xd7, 0x3f, 0x80, 0x9d, 0xe2, 0x4c, 0x31}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20334}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9652}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23632}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3725}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17385}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops6}, .v = {1, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8463}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 254}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17142, 8, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24389, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 12736 [("\145r:&\180\185\191_\191\EOT\159&\193$\205",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\188'\DEL\156\SOV\198\162e\166U0\163\197\181\t\230\&9z\213\135=I",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("fp bI\176\162\r\137\188\NUL\247\ETXy\143s\221q\232\153ff\RS\ESC",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\240\180\DC4+'\SOHP\138y\131!=Z\134\SO2+\169\ETB*",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\201-r-|\180\149qF\242?\234\163\191|m#q\150\CANB\189",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("a)(\167\186\SOH\206\180\ETB\151\150\136hl\212l\187t.\160\189n\165{",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\198\158\243\SYNL\SI\160e\196Y\225\249\234\200\237\136\225\255l\240\tH\250\170\235\223",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(",`6V\143_\180\169\246\186\185\141\138\NAK\ACKIq\130\173?",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\b4\247",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropMaximumPacketSize 32469,PropTopicAlias 714,PropTopicAliasMaximum 31220,PropAuthenticationData "\225\"\r",PropContentType "\DC4\DC4\255$\176\216\174\152K\197f\192\165RN\ACKS\219\n\DLE*\133\128\145\180\DC3t\129\&8",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\218\188\137$}\EOT4\238\239\232|~\185\169R\141\196\189R\151",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\173\US{0hp\194\172Up\210?\133\204\227\&0\160\137\183\158\212\217z\228\208\130\164\213\ACK\210",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\217\199\165J\206\133\254\160,k\ETB\144\186\EOT\ETXKN=\160\SYN\200K\f\208\155%\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\DEL\210\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\211\225\228\234\188g\203A\222\NUL!\191\194\&0\194\&0\144@(A\232\&8\176N",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropReasonString "\163\196\DC1\US\DC4\186sL\238L",PropTopicAlias 7143,PropWildcardSubscriptionAvailable 82,PropMessageExpiryInterval 15875,PropSharedSubscriptionAvailable 168,PropSubscriptionIdentifier 4,PropCorrelationData "r\174\213\240w\SYN\252\\'",PropReasonString "@\181\143\177\163\176\192\169\183\215\231z\170O\DLEy\246\176\223W?\156\rx\DC3\154\201\140",PropAuthenticationData "`1p\163\252\SI\202\233\247\130]7\ENQ\f\RSW+dp\233]3\fr\197\233\SO\130\ENQ",PropRequestProblemInformation 2,PropCorrelationData "[\172\179=",PropSessionExpiryInterval 20694,PropSessionExpiryInterval 19861,PropRequestProblemInformation 17,PropMessageExpiryInterval 26061,PropRequestResponseInformation 228,PropWildcardSubscriptionAvailable 202,PropPayloadFormatIndicator 193,PropWildcardSubscriptionAvailable 120,PropRetainAvailable 37,PropMessageExpiryInterval 28337,PropRetainAvailable 100,PropTopicAlias 2850] +// SubscribeRequest 19202 [("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\233$]\137\\\203f\234\199\ESC1+\152\242\NULM",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("1\194\146\170\EM\r|!\171\192\142\CAN\203<\165p\EMg\236\CAN\174x:\235\165\US\196,\129",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\170\170\208h\229\130\bc\245#",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS1}),("0\218\159\251\186A\250w\ETX\DC4Ni\223Dpd\238-\139\t\134x\DC2\148v",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\180\201\201.\222",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS0})] [PropAuthenticationMethod +// "\158\244s\159\RS\183\175]\142)GW\ENQF\129C^\143uq\245\237\146",PropWillDelayInterval 2853,PropWillDelayInterval +// 12750,PropTopicAliasMaximum 22867,PropRequestResponseInformation 101,PropWillDelayInterval 23997,PropReceiveMaximum +// 21762,PropUserProperty "-K\US\139\251\235" "\154\NUL\242bE\240\&9\167\165H\243\244l9Z3\DC4.",PropResponseInformation +// "\149e\154\236\&97\NULG3@\211\&1#\219\DC4\252\183\&7 \215h\189\214\146\144\ACKI",PropSubscriptionIdentifier +// 6,PropRequestProblemInformation 70,PropTopicAlias 24035,PropReasonString +// "\250\241\240\232\185\178\168\EOTt]\207\174uF\242\214&$\201\149",PropUserProperty "PS\147\163\145" +// "\187`[/\SO^\152x\152A\134n\182x\\\216(\207\&0M\172",PropWildcardSubscriptionAvailable 20,PropRetainAvailable +// 2,PropWildcardSubscriptionAvailable 250,PropServerReference "\208\175\184\STX\166",PropRequestResponseInformation 238,PropPayloadFormatIndicator 55,PropAuthenticationData +// "\248V\155\DC1\175\156\&1^\159\&5\161\165$",PropMessageExpiryInterval 5961,PropServerReference +// "\FS\252\&7^\"\181$\231Jw\"\187r\169]=\US",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\140\252\NAKZ\ENQ\201\234\204\151\235\251\198\234\190\DC2\NULi\211\201",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropReceiveMaximum 28279,PropMaximumQoS 210,PropMaximumQoS 185,PropWildcardSubscriptionAvailable 25] +// SubscribeRequest 4671 [("osy",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS2}),("\210HT\163\DC2\139\243O\224\246\242h\152\192\152y\186",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\180Q\187",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("'\191s\156\EM\188\210\SOH\148\186\141\154{\206\STXwV\233\188+",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\149\r:\181V\203\NAK0\179\229",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// True, _noLocal = True, _subQoS = QoS2}),("Re\176\RS\251\223S\255\200\190\180+\217!p",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("w\n\174\187\236vy\169\166\185\&1\149\SOH\250\131\152\204\US\128U\144\DC2\174",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\200\193\194\&8\241p\166",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropUserProperty +// "\214l\NAK)\RSnV\145\153\186\ESC@\184\161\235v\218\191\138\209yb\135Fu~`\146y" "r\234\195\151",PropContentType +// "\196\\$#\243\DC4``\158[a\FS\195P\184D\ETX\ENQv",PropUserProperty +// "\230\165\SOH\255\176h\169\152\224U\226_1\CAN\168\151\218\212\247\USbr\SUBl\147Z" +// "z\128\219N\149#e7",PropSubscriptionIdentifierAvailable 43,PropMaximumQoS 18,PropRequestResponseInformation +// 171,PropTopicAlias 23677,PropMessageExpiryInterval 13734,PropUserProperty "\186v\141\137C\189\&9\138Vt\DLEq\154" +// "\222<\190$\SI%\178\RS\218\187c0",PropResponseInformation +// "\SO\ETX\173Z\235\253\239\182>\214\&8\142\"\188s\144fH\199K\ETXr\USX\194r\199fL\151",PropReasonString +// "\227ec\214\143j\141\&5T\193\139\245",PropAuthenticationMethod +// "z\176\194\219\219<\184\t\140\186\168\240\133\179'Q%\185\170",PropWildcardSubscriptionAvailable 107,PropTopicAlias +// 26361] TEST(Subscribe5QCTest, Encode24) { -uint8_t pkt[] = {0x82, 0xa3, 0x1, 0x24, 0x85, 0x9, 0x21, 0x6e, 0x77, 0x24, 0xd2, 0x24, 0xb9, 0x28, 0x19, 0x0, 0x2, 0x44, 0xa1, 0x2c, 0x0, 0x1a, 0x93, 0x1d, 0x8c, 0xdd, 0xc2, 0xf9, 0x32, 0x48, 0x24, 0xa0, 0x39, 0x5a, 0xf7, 0xc9, 0x37, 0xeb, 0x85, 0xd2, 0x4d, 0x7b, 0x72, 0x92, 0x75, 0x4a, 0x59, 0x1b, 0x1, 0x0, 0xd, 0xea, 0xd8, 0xc5, 0x92, 0x2d, 0x2e, 0x3a, 0x7c, 0x23, 0xba, 0x1a, 0x7d, 0x86, 0x16, 0x0, 0x0, 0x22, 0x0, 0xf, 0x5d, 0x2f, 0x2e, 0xd0, 0x4, 0xc3, 0xe0, 0x49, 0x67, 0xee, 0x78, 0xdb, 0xfe, 0x20, 0xb2, 0x1a, 0x0, 0xc, 0xa8, 0xe8, 0x15, 0x89, 0xe7, 0xe6, 0x7d, 0x7e, 0xb2, 0x5d, 0x36, 0xf6, 0x22, 0x0, 0x12, 0x56, 0x81, 0x66, 0x29, 0xce, 0x59, 0x8, 0xd8, 0xde, 0xdf, 0x2a, 0x84, 0x6b, 0xc1, 0xa3, 0xd5, 0x32, 0x29, 0x18, 0x0, 0x13, 0xf9, 0xc9, 0x19, 0x78, 0xe9, 0xd0, 0xc5, 0x2a, 0xe4, 0x95, 0xb3, 0xd5, 0x9e, 0x2c, 0xa6, 0x71, 0xfd, 0x3e, 0x1f, 0x2e, 0x0, 0x13, 0x8c, 0xfc, 0x15, 0x5a, 0x5, 0xc9, 0xea, 0xcc, 0x97, 0xeb, 0xfb, 0xc6, 0xea, 0xbe, 0x12, 0x0, 0x69, 0xd3, 0xc9, 0x21}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x44, 0xa1}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x93, 0x1d, 0x8c, 0xdd, 0xc2, 0xf9, 0x32, 0x48, 0x24, 0xa0, 0x39, 0x5a, 0xf7, 0xc9, 0x37, 0xeb, 0x85, 0xd2, 0x4d, 0x7b, 0x72, 0x92, 0x75, 0x4a, 0x59, 0x1b}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xea, 0xd8, 0xc5, 0x92, 0x2d, 0x2e, 0x3a, 0x7c, 0x23, 0xba, 0x1a, 0x7d, 0x86}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; + uint8_t pkt[] = { + 0x82, 0xdb, 0x2, 0x12, 0x3f, 0xda, 0x1, 0x26, 0x0, 0x1d, 0xd6, 0x6c, 0x15, 0x29, 0x1e, 0x6e, 0x56, 0x91, 0x99, + 0xba, 0x1b, 0x40, 0xb8, 0xa1, 0xeb, 0x76, 0xda, 0xbf, 0x8a, 0xd1, 0x79, 0x62, 0x87, 0x46, 0x75, 0x7e, 0x60, 0x92, + 0x79, 0x0, 0x4, 0x72, 0xea, 0xc3, 0x97, 0x3, 0x0, 0x13, 0xc4, 0x5c, 0x24, 0x23, 0xf3, 0x14, 0x60, 0x60, 0x9e, + 0x5b, 0x61, 0x1c, 0xc3, 0x50, 0xb8, 0x44, 0x3, 0x5, 0x76, 0x26, 0x0, 0x1a, 0xe6, 0xa5, 0x1, 0xff, 0xb0, 0x68, + 0xa9, 0x98, 0xe0, 0x55, 0xe2, 0x5f, 0x31, 0x18, 0xa8, 0x97, 0xda, 0xd4, 0xf7, 0x1f, 0x62, 0x72, 0x1a, 0x6c, 0x93, + 0x5a, 0x0, 0x8, 0x7a, 0x80, 0xdb, 0x4e, 0x95, 0x23, 0x65, 0x37, 0x29, 0x2b, 0x24, 0x12, 0x19, 0xab, 0x23, 0x5c, + 0x7d, 0x2, 0x0, 0x0, 0x35, 0xa6, 0x26, 0x0, 0xd, 0xba, 0x76, 0x8d, 0x89, 0x43, 0xbd, 0x39, 0x8a, 0x56, 0x74, + 0x10, 0x71, 0x9a, 0x0, 0xc, 0xde, 0x3c, 0xbe, 0x24, 0xf, 0x25, 0xb2, 0x1e, 0xda, 0xbb, 0x63, 0x30, 0x1a, 0x0, + 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0xae, 0x6, 0x0, 0x7, + 0xc8, 0xc1, 0xc2, 0x38, 0xf1, 0x70, 0xa6, 0xc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x6f, 0x73, 0x79}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd2, 0x48, 0x54, 0xa3, 0x12, 0x8b, 0xf3, 0x4f, 0xe0, + 0xf6, 0xf2, 0x68, 0x98, 0xc0, 0x98, 0x79, 0xba}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb4, 0x51, 0xbb}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; uint8_t topic_filter_s3_bytes[] = {0}; lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5d, 0x2f, 0x2e, 0xd0, 0x4, 0xc3, 0xe0, 0x49, 0x67, 0xee, 0x78, 0xdb, 0xfe, 0x20, 0xb2}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa8, 0xe8, 0x15, 0x89, 0xe7, 0xe6, 0x7d, 0x7e, 0xb2, 0x5d, 0x36, 0xf6}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x56, 0x81, 0x66, 0x29, 0xce, 0x59, 0x8, 0xd8, 0xde, 0xdf, 0x2a, 0x84, 0x6b, 0xc1, 0xa3, 0xd5, 0x32, 0x29}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf9, 0xc9, 0x19, 0x78, 0xe9, 0xd0, 0xc5, 0x2a, 0xe4, 0x95, 0xb3, 0xd5, 0x9e, 0x2c, 0xa6, 0x71, 0xfd, 0x3e, 0x1f}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x8c, 0xfc, 0x15, 0x5a, 0x5, 0xc9, 0xea, 0xcc, 0x97, 0xeb, 0xfb, 0xc6, 0xea, 0xbe, 0x12, 0x0, 0x69, 0xd3, 0xc9}; - lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; -lwmqtt_sub_options_t sub_opts[9]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[0].retain_as_published = true; -sub_opts[0].no_local = true; -sub_opts[1].qos = LWMQTT_QOS1; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = true; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = false; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[4].retain_as_published = true; -sub_opts[4].no_local = false; -sub_opts[5].qos = LWMQTT_QOS2; -sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = false; -sub_opts[6].qos = LWMQTT_QOS0; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[6].retain_as_published = true; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS2; -sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[7].retain_as_published = true; -sub_opts[7].no_local = true; -sub_opts[8].qos = LWMQTT_QOS1; -sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[8].retain_as_published = false; -sub_opts[8].no_local = false; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28279}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x27, 0xbf, 0x73, 0x9c, 0x19, 0xbc, 0xd2, 0x1, 0x94, 0xba, + 0x8d, 0x9a, 0x7b, 0xce, 0x2, 0x77, 0x56, 0xe9, 0xbc, 0x2b}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x95, 0xd, 0x3a, 0xb5, 0x56, 0xcb, 0x15, 0x30, 0xb3, 0xe5}; + lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x52, 0x65, 0xb0, 0x1e, 0xfb, 0xdf, 0x53, 0xff, + 0xc8, 0xbe, 0xb4, 0x2b, 0xd9, 0x21, 0x70}; + lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x77, 0xa, 0xae, 0xbb, 0xec, 0x76, 0x79, 0xa9, 0xa6, 0xb9, 0x31, 0x95, + 0x1, 0xfa, 0x83, 0x98, 0xcc, 0x1f, 0x80, 0x55, 0x90, 0x12, 0xae}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xc8, 0xc1, 0xc2, 0x38, 0xf1, 0x70, 0xa6}; + lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + uint8_t bytesprops1[] = {0x72, 0xea, 0xc3, 0x97}; + uint8_t bytesprops0[] = {0xd6, 0x6c, 0x15, 0x29, 0x1e, 0x6e, 0x56, 0x91, 0x99, 0xba, 0x1b, 0x40, 0xb8, 0xa1, 0xeb, + 0x76, 0xda, 0xbf, 0x8a, 0xd1, 0x79, 0x62, 0x87, 0x46, 0x75, 0x7e, 0x60, 0x92, 0x79}; + uint8_t bytesprops2[] = {0xc4, 0x5c, 0x24, 0x23, 0xf3, 0x14, 0x60, 0x60, 0x9e, 0x5b, + 0x61, 0x1c, 0xc3, 0x50, 0xb8, 0x44, 0x3, 0x5, 0x76}; + uint8_t bytesprops4[] = {0x7a, 0x80, 0xdb, 0x4e, 0x95, 0x23, 0x65, 0x37}; + uint8_t bytesprops3[] = {0xe6, 0xa5, 0x1, 0xff, 0xb0, 0x68, 0xa9, 0x98, 0xe0, 0x55, 0xe2, 0x5f, 0x31, + 0x18, 0xa8, 0x97, 0xda, 0xd4, 0xf7, 0x1f, 0x62, 0x72, 0x1a, 0x6c, 0x93, 0x5a}; + uint8_t bytesprops6[] = {0xde, 0x3c, 0xbe, 0x24, 0xf, 0x25, 0xb2, 0x1e, 0xda, 0xbb, 0x63, 0x30}; + uint8_t bytesprops5[] = {0xba, 0x76, 0x8d, 0x89, 0x43, 0xbd, 0x39, 0x8a, 0x56, 0x74, 0x10, 0x71, 0x9a}; + uint8_t bytesprops7[] = {0xe, 0x3, 0xad, 0x5a, 0xeb, 0xfd, 0xef, 0xb6, 0x3e, 0xd6, 0x38, 0x8e, 0x22, 0xbc, 0x73, + 0x90, 0x66, 0x48, 0xc7, 0x4b, 0x3, 0x72, 0x1f, 0x58, 0xc2, 0x72, 0xc7, 0x66, 0x4c, 0x97}; + uint8_t bytesprops8[] = {0xe3, 0x65, 0x63, 0xd6, 0x8f, 0x6a, 0x8d, 0x35, 0x54, 0xc1, 0x8b, 0xf5}; + uint8_t bytesprops9[] = {0x7a, 0xb0, 0xc2, 0xdb, 0xdb, 0x3c, 0xb8, 0x9, 0x8c, 0xba, + 0xa8, 0xf0, 0x85, 0xb3, 0x27, 0x51, 0x25, 0xb9, 0xaa}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops0}, .v = {4, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops3}, .v = {8, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23677}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13734}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops5}, .v = {12, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26361}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9349, 9, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4671, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 26963 [("\222\194M\DEL\152\197,\190??\b\237\DELK\244.\212\133\159\247{\238\US7[\151\DC1",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\171\141\177\173\n\EM\129,\143\DC4\167\162\191<,",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("{\146\138\133s9`\172\155`\205#\CAN\160\193h\188\DC3K\205\253<\255g\DC4c\246",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("'\170\221]\SIq\189\192\ESCH\r5\163\154D",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("i",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropResponseTopic "\206P'i\t\136\192:l&Zd\184\154#\231\219Y^\253\238\173\181\133\210\247",PropReasonString "\245vtLJE\244CgT\155cZH\190\ETB\254Y\144\EM;Y",PropTopicAlias 31490,PropRetainAvailable 238,PropServerReference "\155\170W",PropAssignedClientIdentifier "\208\208\234\STX|\165",PropTopicAliasMaximum 6467,PropSubscriptionIdentifierAvailable 0,PropSubscriptionIdentifier 20,PropReceiveMaximum 26960,PropUserProperty "\129n\150" "Eh\215\&8\219\fl6\133\170}\248\237\189\228\&6\175\144u",PropResponseInformation "",PropWildcardSubscriptionAvailable 215,PropWildcardSubscriptionAvailable 129,PropSessionExpiryInterval 26931,PropWillDelayInterval 21110,PropResponseTopic "9Y\156\204\202\242\DC1*\161\234\175\178i\SOHT\213\DC3\NAK\217?p\US\160p\143\151\142\167",PropCorrelationData "\SUBV\204\247\&7q\222\220\217\244\129\&9o\DC1\175=\255\128\GS5\DC2d",PropReceiveMaximum 30889,PropMaximumPacketSize 6880,PropServerKeepAlive 4124,PropServerReference "\204\CANI3Ql\168\181\218\DEL",PropMessageExpiryInterval 3510,PropPayloadFormatIndicator 8,PropSubscriptionIdentifierAvailable 139,PropMaximumQoS 173,PropAuthenticationData "\128\173}\DLE\165\&8\227c\EOT$\157\235z\DC2\171"] +// SubscribeRequest 22250 [("\186\185\130\168\166",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\155\157\SYN\229\227\209\&4\SOH|\242\168\253\129xF\166\\\"BG\191\246\215",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\182\&7\250\251\141.\181\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS0}),("\134&\251\172\216\150}\237\b\142\246",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\197\235",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("K\195})\202\&1'\218\169\SOH\200g\252\235R\225\201\b&@\v Y~\144x\232",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\163\249Y`\207\ETB\EOTf\n\159!l\SUB2hs\162\149\186\250?\a\220\237\200",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\177\128;f\163y\182\222\185\r\SYN\US-y#\168\SO\190Cu\SO\r\143~y\254\vi\163X",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\236Fm\234\247v&5\249\208\&0\FS",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// True, _noLocal = False, _subQoS = QoS2}),("b",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0})] [PropRetainAvailable 236,PropSharedSubscriptionAvailable +// 11,PropRequestProblemInformation 28,PropMessageExpiryInterval 4198,PropTopicAlias +// 7386,PropSubscriptionIdentifierAvailable 14,PropWildcardSubscriptionAvailable 157,PropWillDelayInterval +// 20454,PropTopicAlias 8171,PropServerReference "\138\155\254%\185\185nS",PropPayloadFormatIndicator +// 213,PropServerReference "\169K\DLEu\204",PropResponseInformation +// "\ESC\185\142-\151\152\135C\183`\147/\215\235\223\234\138\fLBL\249\131@\CAN9\152\209\137,[\171\227\225\131%",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),(")eM\218\&6\152 \202\231\152J\139",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\200[\DC1O\176\181\136",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\209f\ENQ!\195\251$^7\130\148_\DC4\189\167\202s\172\210\149\254\181=",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("2a\216\&2\185\140i=\199\224\250\&3\230r\DC4\161\146\130G",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\136\ETX\176~\130\DC1\"\241\SIp\253\190\162\219\183`\234",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropMaximumPacketSize +// 5697,PropSharedSubscriptionAvailable 120,PropSubscriptionIdentifierAvailable 40,PropWildcardSubscriptionAvailable +// 52,PropServerKeepAlive 24790,PropPayloadFormatIndicator 26,PropUserProperty +// "\a\173:\189{4\DLE\177\231d\231\139\214\254\160\153" "",PropAssignedClientIdentifier +// "`.'\202\203\231\229?\DLE\167\157\134\204\182\180\227\210\192\&9V\143\213Y\133v=",PropCorrelationData +// "h\SI\228\160b\EM\150\151Z\132n\209nb&\FS\129\239|4\211\&36\ENQ\172\135K\SUBz",PropResponseTopic +// "#:+\228\235Y\183\250!x\197\a)\SO\154\254",PropUserProperty +// "p\238\184,\236\ESC\201\&3\199\254\132\246y\187\170\210}!\f\169\247T\184\&0Fw\142" +// "\b\NAKOj\148\136\227\201\221'\195nj7\ETB\254\188\145uD\131\&3\188\&7",PropAuthenticationMethod +// "\169\&4&tp8\151\179\185",PropTopicAlias 13893,PropMessageExpiryInterval 30246,PropMaximumQoS +// 68,PropMaximumPacketSize 19007,PropServerReference "\FS\SOt\223\229R\255",PropMaximumPacketSize +// 24216,PropSubscriptionIdentifierAvailable 104,PropRequestResponseInformation 139,PropSessionExpiryInterval +// 11251,PropTopicAliasMaximum 30523,PropServerKeepAlive 26783,PropMaximumQoS 129,PropRequestProblemInformation 174] TEST(Subscribe5QCTest, Encode26) { -uint8_t pkt[] = {0x82, 0x7c, 0x55, 0x6e, 0x27, 0x21, 0x48, 0xa4, 0x27, 0x0, 0x0, 0x51, 0xf4, 0x2, 0x0, 0x0, 0x16, 0xfc, 0x1f, 0x0, 0x12, 0x48, 0xf3, 0x4a, 0x6f, 0x7b, 0x2, 0xe8, 0xf2, 0xab, 0x4, 0x32, 0x96, 0x92, 0x90, 0x63, 0x4, 0xac, 0x70, 0x27, 0x0, 0x0, 0xf, 0xf3, 0x0, 0x18, 0x40, 0x11, 0xa8, 0x34, 0x71, 0x5e, 0x6f, 0x80, 0xc1, 0x20, 0x52, 0x81, 0x51, 0xa, 0xe, 0x20, 0x9c, 0xdf, 0xea, 0xb2, 0xfc, 0x9e, 0xd9, 0x3d, 0x2e, 0x0, 0x5, 0xb, 0xca, 0xe2, 0xce, 0x47, 0x1e, 0x0, 0x7, 0x9f, 0x57, 0x13, 0x30, 0x3d, 0x18, 0x25, 0x2e, 0x0, 0x7, 0x8a, 0x4f, 0xd1, 0xd4, 0x7a, 0x4, 0x4b, 0xe, 0x0, 0x18, 0x33, 0xf0, 0x94, 0x6f, 0x81, 0xa, 0x9e, 0x38, 0x0, 0x64, 0xc1, 0x86, 0x84, 0x81, 0x7a, 0x84, 0x7a, 0xdb, 0x60, 0x7b, 0xeb, 0x57, 0x90, 0x5f, 0xe}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x40, 0x11, 0xa8, 0x34, 0x71, 0x5e, 0x6f, 0x80, 0xc1, 0x20, 0x52, 0x81, 0x51, 0xa, 0xe, 0x20, 0x9c, 0xdf, 0xea, 0xb2, 0xfc, 0x9e, 0xd9, 0x3d}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb, 0xca, 0xe2, 0xce, 0x47}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9f, 0x57, 0x13, 0x30, 0x3d, 0x18, 0x25}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8a, 0x4f, 0xd1, 0xd4, 0x7a, 0x4, 0x4b}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x33, 0xf0, 0x94, 0x6f, 0x81, 0xa, 0x9e, 0x38, 0x0, 0x64, 0xc1, 0x86, 0x84, 0x81, 0x7a, 0x84, 0x7a, 0xdb, 0x60, 0x7b, 0xeb, 0x57, 0x90, 0x5f}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; -lwmqtt_sub_options_t sub_opts[5]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[0].retain_as_published = true; -sub_opts[0].no_local = true; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[1].retain_as_published = true; -sub_opts[1].no_local = true; -sub_opts[2].qos = LWMQTT_QOS2; -sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[2].retain_as_published = true; -sub_opts[2].no_local = true; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[3].retain_as_published = true; -sub_opts[3].no_local = true; -sub_opts[4].qos = LWMQTT_QOS2; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = true; -sub_opts[4].no_local = true; - uint8_t bytesprops0[] = {0x48, 0xf3, 0x4a, 0x6f, 0x7b, 0x2, 0xe8, 0xf2, 0xab, 0x4, 0x32, 0x96, 0x92, 0x90, 0x63, 0x4, 0xac, 0x70}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18596}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20980}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5884}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4083}}, + uint8_t pkt[] = { + 0x82, 0xdb, 0x3, 0x58, 0x51, 0xea, 0x1, 0x27, 0x0, 0x0, 0x16, 0x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, 0xc, 0x29, 0x65, 0x4d, 0xda, 0x36, 0x98, 0x20, 0xca, 0xe7, 0x98, 0x4a, 0x8b, + 0x2a, 0x0, 0x7, 0xc8, 0x5b, 0x11, 0x4f, 0xb0, 0xb5, 0x88, 0x20, 0x0, 0x17, 0xd1, 0x66, 0x5, 0x21, 0xc3, 0xfb, + 0x24, 0x5e, 0x37, 0x82, 0x94, 0x5f, 0x14, 0xbd, 0xa7, 0xca, 0x73, 0xac, 0xd2, 0x95, 0xfe, 0xb5, 0x3d, 0xa, 0x0, + 0x13, 0x32, 0x61, 0xd8, 0x32, 0xb9, 0x8c, 0x69, 0x3d, 0xc7, 0xe0, 0xfa, 0x33, 0xe6, 0x72, 0x14, 0xa1, 0x92, 0x82, + 0x47, 0x1d, 0x0, 0x11, 0x88, 0x3, 0xb0, 0x7e, 0x82, 0x11, 0x22, 0xf1, 0xf, 0x70, 0xfd, 0xbe, 0xa2, 0xdb, 0xb7, + 0x60, 0xea, 0x12}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x39, 0xa2, 0x41, 0xa4, 0xd6, 0x78, 0x32, 0x87, 0x55, + 0x7c, 0x29, 0xe6, 0xc9, 0x74, 0x1d, 0xc5, 0xbd}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x16, 0x21, 0x94, 0xa5, 0x91, 0xb6, 0x64, 0x4e, 0xf1, 0xee, 0x40, 0xb0, 0x90, + 0xb, 0xd2, 0x60, 0xf7, 0x64, 0x21, 0x75, 0xce, 0x85, 0xa7, 0xbe, 0x38}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1a, 0xd1, 0xd8, 0xf8, 0x3a, 0xc8, 0xd7, 0x18, 0xea, 0x2, 0xee, 0xd8, 0x9f, + 0x51, 0xb7, 0xdd, 0x16, 0xad, 0x3c, 0xb6, 0x80, 0x8e, 0xa, 0x2c, 0xc}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x81, 0x3f, 0xa4, 0x61, 0x34, 0xe6, 0x93, 0xe8, + 0xb1, 0xe1, 0xe2, 0xf7, 0x83, 0xde, 0xcd, 0x5}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x12, 0x61, 0xba, 0x48, 0x8c, 0xac, 0x4e, 0x3c, 0x99, 0x4d, 0xfc, 0xab, 0xfc, + 0x4a, 0x69, 0x27, 0x13, 0xc, 0x33, 0x36, 0x1d, 0xec, 0x14, 0x74, 0xc8}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x7b, 0xcc, 0xf4, 0x4f, 0xa2, 0x3e, 0x18, 0x39, 0x98, + 0xd1, 0x89, 0x2c, 0x5b, 0xab, 0xe3, 0xe1, 0x83, 0x25}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x29, 0x65, 0x4d, 0xda, 0x36, 0x98, 0x20, 0xca, 0xe7, 0x98, 0x4a, 0x8b}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xc8, 0x5b, 0x11, 0x4f, 0xb0, 0xb5, 0x88}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd1, 0x66, 0x5, 0x21, 0xc3, 0xfb, 0x24, 0x5e, 0x37, 0x82, 0x94, 0x5f, + 0x14, 0xbd, 0xa7, 0xca, 0x73, 0xac, 0xd2, 0x95, 0xfe, 0xb5, 0x3d}; + lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x32, 0x61, 0xd8, 0x32, 0xb9, 0x8c, 0x69, 0x3d, 0xc7, 0xe0, + 0xfa, 0x33, 0xe6, 0x72, 0x14, 0xa1, 0x92, 0x82, 0x47}; + lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x88, 0x3, 0xb0, 0x7e, 0x82, 0x11, 0x22, 0xf1, 0xf, + 0x70, 0xfd, 0xbe, 0xa2, 0xdb, 0xb7, 0x60, 0xea}; + lwmqtt_string_t topic_filter_s10 = {17, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = true; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops0[] = {0x7, 0xad, 0x3a, 0xbd, 0x7b, 0x34, 0x10, 0xb1, + 0xe7, 0x64, 0xe7, 0x8b, 0xd6, 0xfe, 0xa0, 0x99}; + uint8_t bytesprops2[] = {0x60, 0x2e, 0x27, 0xca, 0xcb, 0xe7, 0xe5, 0x3f, 0x10, 0xa7, 0x9d, 0x86, 0xcc, + 0xb6, 0xb4, 0xe3, 0xd2, 0xc0, 0x39, 0x56, 0x8f, 0xd5, 0x59, 0x85, 0x76, 0x3d}; + uint8_t bytesprops3[] = {0x68, 0xf, 0xe4, 0xa0, 0x62, 0x19, 0x96, 0x97, 0x5a, 0x84, 0x6e, 0xd1, 0x6e, 0x62, 0x26, + 0x1c, 0x81, 0xef, 0x7c, 0x34, 0xd3, 0x33, 0x36, 0x5, 0xac, 0x87, 0x4b, 0x1a, 0x7a}; + uint8_t bytesprops4[] = {0x23, 0x3a, 0x2b, 0xe4, 0xeb, 0x59, 0xb7, 0xfa, + 0x21, 0x78, 0xc5, 0x7, 0x29, 0xe, 0x9a, 0xfe}; + uint8_t bytesprops6[] = {0x8, 0x15, 0x4f, 0x6a, 0x94, 0x88, 0xe3, 0xc9, 0xdd, 0x27, 0xc3, 0x6e, + 0x6a, 0x37, 0x17, 0xfe, 0xbc, 0x91, 0x75, 0x44, 0x83, 0x33, 0xbc, 0x37}; + uint8_t bytesprops5[] = {0x70, 0xee, 0xb8, 0x2c, 0xec, 0x1b, 0xc9, 0x33, 0xc7, 0xfe, 0x84, 0xf6, 0x79, 0xbb, + 0xaa, 0xd2, 0x7d, 0x21, 0xc, 0xa9, 0xf7, 0x54, 0xb8, 0x30, 0x46, 0x77, 0x8e}; + uint8_t bytesprops7[] = {0xa9, 0x34, 0x26, 0x74, 0x70, 0x38, 0x97, 0xb3, 0xb9}; + uint8_t bytesprops8[] = {0x1c, 0xe, 0x74, 0xdf, 0xe5, 0x52, 0xff}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5697}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24790}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops5}, .v = {24, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13893}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30246}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19007}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24216}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11251}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30523}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26783}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 174}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21870, 5, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22609, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 6154 [("\DEL\244\227\193\248L\DC2\249\249h\217u_u",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\146\226X\227zoKZ\172C$\DC1>",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\USpH\130\\\EOT\ESCo\r\205\249d\215\243\246\EM\243\\Oy\195\147\&9<\249A\230\&5\ETX.",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\186Uah\251?\236m\133\v\215",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\f\193y\211\&9\163\188\237\SYN8\198\DC34\130\218\203\&3~\\",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\255+\137v\184\215Pix\170R\252{l\130\254\212yQ\223@l\SI\130i",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\137\236\&92",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("{\"\202\130",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\221u\223w",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\249\137\219n\139\f\238\208lT0\201\209\SI\135\237\182\212\185\190\244\220\177\180B\229",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\\([*\EOTn\145\175\236G\176\&8\240\STX\170\SUB[c",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropWillDelayInterval 18072,PropRequestProblemInformation 247,PropWildcardSubscriptionAvailable 13,PropAssignedClientIdentifier "pq\141\159\215]}S\235!qs",PropRequestResponseInformation 251,PropReasonString "\219\251S\148",PropUserProperty "\US\228\156\DC1\240`p%\137\140\230\164\\R\196\224" "\SO\250{\SUB\159\191\213\185",PropRequestResponseInformation 24,PropAuthenticationMethod "",PropServerReference "\SOH\176\197K\191\185\142>\244\DC13e9\201\253\183\DEL\249&\187\191\222\150D",PropTopicAlias 32300,PropPayloadFormatIndicator 3,PropWildcardSubscriptionAvailable 185,PropAuthenticationData "/",PropMaximumQoS 220,PropServerKeepAlive 4339,PropTopicAliasMaximum 14185,PropSessionExpiryInterval 886,PropUserProperty "<\245\DELf\142\168\168\154\243\184\DC1\189\CAN\146\197k\226\235?rc\170E:" "p\214\176\DC2\129",PropRequestResponseInformation 207,PropCorrelationData "@\212\214d\236`\143q\DELW\DC1\t\\p+\a\179\DC2\240]IW\GS\"",PropResponseTopic "",PropContentType "\176\181c\ETX)\179w?$a\248\250$\247=\n\159\151\156\135",PropUserProperty "O\132" "u\232\177\ACK;\191\&2\164\144.\158\135\194ho\251\153:\n\240\200\FSu",PropWildcardSubscriptionAvailable 59,PropMessageExpiryInterval 6310,PropServerReference "z\v\DLE\239h\129\&3\204%\254\NULF!\228bS>",PropRequestResponseInformation 10,PropTopicAliasMaximum 8987,PropUserProperty "R\GS9>f" "^\ETX\174\173K\197c\221\132L\249CY\179\208\207\154-\223"] +// SubscribeRequest 5459 [("\167\&9\128\201\254\251f\154)\222\SYN\n\182w",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\v\244",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\NULV?\231o\214\r\141\181\DC4\236\139\166f\RS?B_",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\134\198\224\203\182\223E\204\128l\208\172\156\"\246",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\170b\195j\211}D\139\ESC\192\ACK9!\244F\140&1\143W\DC1Qy\211",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("p\NULm,\228\200\DLE\134\191V\174\192\SOHm\145H\RS\US\177\SIt\\",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\SOH\251cC\207\239\246\&5\202\158\vi\196\&1",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropTopicAlias 16179,PropSessionExpiryInterval +// 23734,PropMessageExpiryInterval 31667,PropServerReference "x-\231",PropRequestResponseInformation 128,PropContentType +// "\nR\215\219\165\142\208*\130\ACKh\ETX\202\179\141\150\165\252\173m\223p\139M^n\199>"] TEST(Subscribe5QCTest, Encode27) { -uint8_t pkt[] = {0x82, 0xf7, 0x3, 0x18, 0xa, 0xaa, 0x2, 0x18, 0x0, 0x0, 0x46, 0x98, 0x17, 0xf7, 0x28, 0xd, 0x12, 0x0, 0xc, 0x70, 0x71, 0x8d, 0x9f, 0xd7, 0x5d, 0x7d, 0x53, 0xeb, 0x21, 0x71, 0x73, 0x19, 0xfb, 0x1f, 0x0, 0x4, 0xdb, 0xfb, 0x53, 0x94, 0x26, 0x0, 0x10, 0x1f, 0xe4, 0x9c, 0x11, 0xf0, 0x60, 0x70, 0x25, 0x89, 0x8c, 0xe6, 0xa4, 0x5c, 0x52, 0xc4, 0xe0, 0x0, 0x8, 0xe, 0xfa, 0x7b, 0x1a, 0x9f, 0xbf, 0xd5, 0xb9, 0x19, 0x18, 0x15, 0x0, 0x0, 0x1c, 0x0, 0x18, 0x1, 0xb0, 0xc5, 0x4b, 0xbf, 0xb9, 0x8e, 0x3e, 0xf4, 0x11, 0x33, 0x65, 0x39, 0xc9, 0xfd, 0xb7, 0x7f, 0xf9, 0x26, 0xbb, 0xbf, 0xde, 0x96, 0x44, 0x23, 0x7e, 0x2c, 0x1, 0x3, 0x28, 0xb9, 0x16, 0x0, 0x1, 0x2f, 0x24, 0xdc, 0x13, 0x10, 0xf3, 0x22, 0x37, 0x69, 0x11, 0x0, 0x0, 0x3, 0x76, 0x26,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xaa, 0x1a, 0x5b, 0x63, 0xd}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x7f, 0xf4, 0xe3, 0xc1, 0xf8, 0x4c, 0x12, 0xf9, 0xf9, 0x68, 0xd9, 0x75, 0x5f, 0x75}; + uint8_t pkt[] = { + 0x82, 0xb9, 0x1, 0x15, 0x53, 0x34, 0x23, 0x3f, 0x33, 0x11, 0x0, 0x0, 0x5c, 0xb6, 0x2, 0x0, 0x0, 0x7b, 0xb3, + 0x1c, 0x0, 0x3, 0x78, 0x2d, 0xe7, 0x19, 0x80, 0x3, 0x0, 0x1c, 0xa, 0x52, 0xd7, 0xdb, 0xa5, 0x8e, 0xd0, 0x2a, + 0x82, 0x6, 0x68, 0x3, 0xca, 0xb3, 0x8d, 0x96, 0xa5, 0xfc, 0xad, 0x6d, 0xdf, 0x70, 0x8b, 0x4d, 0x5e, 0x6e, 0xc7, + 0x3e, 0x0, 0xe, 0xa7, 0x39, 0x80, 0xc9, 0xfe, 0xfb, 0x66, 0x9a, 0x29, 0xde, 0x16, 0xa, 0xb6, 0x77, 0xe, 0x0, + 0x2, 0xb, 0xf4, 0x24, 0x0, 0x12, 0x0, 0x56, 0x3f, 0xe7, 0x6f, 0xd6, 0xd, 0x8d, 0xb5, 0x14, 0xec, 0x8b, 0xa6, + 0x66, 0x1e, 0x3f, 0x42, 0x5f, 0x16, 0x0, 0xf, 0x86, 0xc6, 0xe0, 0xcb, 0xb6, 0xdf, 0x45, 0xcc, 0x80, 0x6c, 0xd0, + 0xac, 0x9c, 0x22, 0xf6, 0x4, 0x0, 0x18, 0xaa, 0x62, 0xc3, 0x6a, 0xd3, 0x7d, 0x44, 0x8b, 0x1b, 0xc0, 0x6, 0x39, + 0x21, 0xf4, 0x46, 0x8c, 0x26, 0x31, 0x8f, 0x57, 0x11, 0x51, 0x79, 0xd3, 0x6, 0x0, 0x16, 0x70, 0x0, 0x6d, 0x2c, + 0xe4, 0xc8, 0x10, 0x86, 0xbf, 0x56, 0xae, 0xc0, 0x1, 0x6d, 0x91, 0x48, 0x1e, 0x1f, 0xb1, 0xf, 0x74, 0x5c, 0x1d, + 0x0, 0xe, 0x1, 0xfb, 0x63, 0x43, 0xcf, 0xef, 0xf6, 0x35, 0xca, 0x9e, 0xb, 0x69, 0xc4, 0x31, 0x2e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xa7, 0x39, 0x80, 0xc9, 0xfe, 0xfb, 0x66, 0x9a, 0x29, 0xde, 0x16, 0xa, 0xb6, 0x77}; lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x92, 0xe2, 0x58, 0xe3, 0x7a, 0x6f, 0x4b, 0x5a, 0xac, 0x43, 0x24, 0x11, 0x3e}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1f, 0x70, 0x48, 0x82, 0x5c, 0x4, 0x1b, 0x6f, 0xd, 0xcd, 0xf9, 0x64, 0xd7, 0xf3, 0xf6, 0x19, 0xf3, 0x5c, 0x4f, 0x79, 0xc3, 0x93, 0x39, 0x3c, 0xf9, 0x41, 0xe6, 0x35, 0x3, 0x2e}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xba, 0x55, 0x61, 0x68, 0xfb, 0x3f, 0xec, 0x6d, 0x85, 0xb, 0xd7}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc, 0xc1, 0x79, 0xd3, 0x39, 0xa3, 0xbc, 0xed, 0x16, 0x38, 0xc6, 0x13, 0x34, 0x82, 0xda, 0xcb, 0x33, 0x7e, 0x5c}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; -topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xff, 0x2b, 0x89, 0x76, 0xb8, 0xd7, 0x50, 0x69, 0x78, 0xaa, 0x52, 0xfc, 0x7b, 0x6c, 0x82, 0xfe, 0xd4, 0x79, 0x51, 0xdf, 0x40, 0x6c, 0xf, 0x82, 0x69}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; -topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x89, 0xec, 0x39, 0x32}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; -topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7b, 0x22, 0xca, 0x82}; - lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; -topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xdd, 0x75, 0xdf, 0x77}; - lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; -topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xf9, 0x89, 0xdb, 0x6e, 0x8b, 0xc, 0xee, 0xd0, 0x6c, 0x54, 0x30, 0xc9, 0xd1, 0xf, 0x87, 0xed, 0xb6, 0xd4, 0xb9, 0xbe, 0xf4, 0xdc, 0xb1, 0xb4, 0x42, 0xe5}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; -topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x5c, 0x28, 0x5b, 0x2a, 0x4, 0x6e, 0x91, 0xaf, 0xec, 0x47, 0xb0, 0x38, 0xf0, 0x2, 0xaa, 0x1a, 0x5b, 0x63}; - lwmqtt_string_t topic_filter_s10 = {18, (char*)&topic_filter_s10_bytes}; -topic_filters[10] = topic_filter_s10; -lwmqtt_sub_options_t sub_opts[11]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[0].retain_as_published = true; -sub_opts[0].no_local = true; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[1].retain_as_published = true; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[2].retain_as_published = true; -sub_opts[2].no_local = true; -sub_opts[3].qos = LWMQTT_QOS1; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[3].retain_as_published = true; -sub_opts[3].no_local = true; -sub_opts[4].qos = LWMQTT_QOS0; -sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[4].retain_as_published = false; -sub_opts[4].no_local = true; -sub_opts[5].qos = LWMQTT_QOS0; -sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[5].retain_as_published = false; -sub_opts[5].no_local = true; -sub_opts[6].qos = LWMQTT_QOS2; -sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[6].retain_as_published = true; -sub_opts[6].no_local = false; -sub_opts[7].qos = LWMQTT_QOS0; -sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[7].retain_as_published = true; -sub_opts[7].no_local = true; -sub_opts[8].qos = LWMQTT_QOS1; -sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[8].retain_as_published = true; -sub_opts[8].no_local = true; -sub_opts[9].qos = LWMQTT_QOS2; -sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[9].retain_as_published = false; -sub_opts[9].no_local = true; -sub_opts[10].qos = LWMQTT_QOS1; -sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[10].retain_as_published = true; -sub_opts[10].no_local = true; - uint8_t bytesprops0[] = {0x70, 0x71, 0x8d, 0x9f, 0xd7, 0x5d, 0x7d, 0x53, 0xeb, 0x21, 0x71, 0x73}; - uint8_t bytesprops1[] = {0xdb, 0xfb, 0x53, 0x94}; - uint8_t bytesprops3[] = {0xe, 0xfa, 0x7b, 0x1a, 0x9f, 0xbf, 0xd5, 0xb9}; - uint8_t bytesprops2[] = {0x1f, 0xe4, 0x9c, 0x11, 0xf0, 0x60, 0x70, 0x25, 0x89, 0x8c, 0xe6, 0xa4, 0x5c, 0x52, 0xc4, 0xe0}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0x1, 0xb0, 0xc5, 0x4b, 0xbf, 0xb9, 0x8e, 0x3e, 0xf4, 0x11, 0x33, 0x65, 0x39, 0xc9, 0xfd, 0xb7, 0x7f, 0xf9, 0x26, 0xbb, 0xbf, 0xde, 0x96, 0x44}; - uint8_t bytesprops6[] = {0x2f}; - uint8_t bytesprops8[] = {0x70, 0xd6, 0xb0, 0x12, 0x81}; - uint8_t bytesprops7[] = {0x3c, 0xf5, 0x7f, 0x66, 0x8e, 0xa8, 0xa8, 0x9a, 0xf3, 0xb8, 0x11, 0xbd, 0x18, 0x92, 0xc5, 0x6b, 0xe2, 0xeb, 0x3f, 0x72, 0x63, 0xaa, 0x45, 0x3a}; - uint8_t bytesprops9[] = {0x40, 0xd4, 0xd6, 0x64, 0xec, 0x60, 0x8f, 0x71, 0x7f, 0x57, 0x11, 0x9, 0x5c, 0x70, 0x2b, 0x7, 0xb3, 0x12, 0xf0, 0x5d, 0x49, 0x57, 0x1d, 0x22}; - uint8_t bytesprops10[] = {0}; - uint8_t bytesprops11[] = {0xb0, 0xb5, 0x63, 0x3, 0x29, 0xb3, 0x77, 0x3f, 0x24, 0x61, 0xf8, 0xfa, 0x24, 0xf7, 0x3d, 0xa, 0x9f, 0x97, 0x9c, 0x87}; - uint8_t bytesprops13[] = {0x75, 0xe8, 0xb1, 0x6, 0x3b, 0xbf, 0x32, 0xa4, 0x90, 0x2e, 0x9e, 0x87, 0xc2, 0x68, 0x6f, 0xfb, 0x99, 0x3a, 0xa, 0xf0, 0xc8, 0x1c, 0x75}; - uint8_t bytesprops12[] = {0x4f, 0x84}; - uint8_t bytesprops14[] = {0x7a, 0xb, 0x10, 0xef, 0x68, 0x81, 0x33, 0xcc, 0x25, 0xfe, 0x0, 0x46, 0x21, 0xe4, 0x62, 0x53, 0x3e}; - uint8_t bytesprops16[] = {0x5e, 0x3, 0xae, 0xad, 0x4b, 0xc5, 0x63, 0xdd, 0x84, 0x4c, 0xf9, 0x43, 0x59, 0xb3, 0xd0, 0xcf, 0x9a, 0x2d, 0xdf}; - uint8_t bytesprops15[] = {0x52, 0x1d, 0x39, 0x3e, 0x66}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18072}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={16, (char*)&bytesprops2}, .v={8, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32300}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4339}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14185}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 886}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={24, (char*)&bytesprops7}, .v={5, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={2, (char*)&bytesprops12}, .v={23, (char*)&bytesprops13}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6310}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8987}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={5, (char*)&bytesprops15}, .v={19, (char*)&bytesprops16}}}}, + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb, 0xf4}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x0, 0x56, 0x3f, 0xe7, 0x6f, 0xd6, 0xd, 0x8d, 0xb5, + 0x14, 0xec, 0x8b, 0xa6, 0x66, 0x1e, 0x3f, 0x42, 0x5f}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x86, 0xc6, 0xe0, 0xcb, 0xb6, 0xdf, 0x45, 0xcc, + 0x80, 0x6c, 0xd0, 0xac, 0x9c, 0x22, 0xf6}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xaa, 0x62, 0xc3, 0x6a, 0xd3, 0x7d, 0x44, 0x8b, 0x1b, 0xc0, 0x6, 0x39, + 0x21, 0xf4, 0x46, 0x8c, 0x26, 0x31, 0x8f, 0x57, 0x11, 0x51, 0x79, 0xd3}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x70, 0x0, 0x6d, 0x2c, 0xe4, 0xc8, 0x10, 0x86, 0xbf, 0x56, 0xae, + 0xc0, 0x1, 0x6d, 0x91, 0x48, 0x1e, 0x1f, 0xb1, 0xf, 0x74, 0x5c}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x1, 0xfb, 0x63, 0x43, 0xcf, 0xef, 0xf6, 0x35, 0xca, 0x9e, 0xb, 0x69, 0xc4, 0x31}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + uint8_t bytesprops0[] = {0x78, 0x2d, 0xe7}; + uint8_t bytesprops1[] = {0xa, 0x52, 0xd7, 0xdb, 0xa5, 0x8e, 0xd0, 0x2a, 0x82, 0x6, 0x68, 0x3, 0xca, 0xb3, + 0x8d, 0x96, 0xa5, 0xfc, 0xad, 0x6d, 0xdf, 0x70, 0x8b, 0x4d, 0x5e, 0x6e, 0xc7, 0x3e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16179}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23734}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31667}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6154, 11, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5459, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 7912 [("\182\167\151\163VQ\156;\242Q\187<\193\&4\145-\243Y\208\152E?\200&\SYN\US",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\FS?\153\174\206\185MuW\176b\183\172\134",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\223\224s\US\169\&0bC\ENQQ\200\221\248qE\235\255B\n",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropServerReference "\152\224[5B",PropTopicAlias 477,PropUserProperty "\130\CANs\f4-\245\227" "46\200\238\DLEf\176\GS\192j#\183r\CAN\234\ENQ\133\249",PropResponseTopic "\GS\200\&9\209\216\182\137<\185\170\147\234\&2\132\171\181rh\137",PropReceiveMaximum 30574,PropRequestProblemInformation 32] +// SubscribeRequest 21650 +// [("\144\143\250\181?\222c\242\195\194iT\235\216\230\207\176(\169\205\175g\RS\221}V\US\206\228\167",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("r\242Fl\STX\222\224\199\213\254?\253\b\n\241\ESC\137f\252\ETX",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\188\213\&9\219v$\165F\194\195\157\155\193\DC2y\EM",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("Yk\181r6Q\f\148l\155\151\149\206I\133\&8\SOH\SOH\148\SUBaQ",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("D\191",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropReasonString "\137Iy\133 +// {*\EOT\v5\226\234\221\165\f",PropReasonString +// "\173\224=Tg\214o\ETXDLb\156t]t\ESCs\254]\DLE.",PropMessageExpiryInterval 4602,PropSessionExpiryInterval +// 17637,PropUserProperty "\207\190\248z6" +// "a\176\146]+\EOT\192h\NUL\165\248\229\249\183\200FI\157`\255\170\200\DC3\151\135\ENQ",PropAuthenticationData +// "\174A\SUB\182]\191\215,\167\DC2\US\227\ESC\182cJq\235!Y\158\v&\164\175\225O\233\210\157",PropRequestProblemInformation +// 120,PropWillDelayInterval 1152,PropMaximumPacketSize 13603,PropPayloadFormatIndicator 70,PropMaximumPacketSize +// 17285,PropContentType "2>D\246\r\139;A\182D s\254\207",PropResponseInformation "\185",PropAssignedClientIdentifier +// "\234!~]\191H\214"] TEST(Subscribe5QCTest, Encode28) { -uint8_t pkt[] = {0x82, 0x8c, 0x1, 0x1e, 0xe8, 0x45, 0x1c, 0x0, 0x5, 0x98, 0xe0, 0x5b, 0x35, 0x42, 0x23, 0x1, 0xdd, 0x26, 0x0, 0x8, 0x82, 0x18, 0x73, 0xc, 0x34, 0x2d, 0xf5, 0xe3, 0x0, 0x12, 0x34, 0x36, 0xc8, 0xee, 0x10, 0x66, 0xb0, 0x1d, 0xc0, 0x6a, 0x23, 0xb7, 0x72, 0x18, 0xea, 0x5, 0x85, 0xf9, 0x8, 0x0, 0x13, 0x1d, 0xc8, 0x39, 0xd1, 0xd8, 0xb6, 0x89, 0x3c, 0xb9, 0xaa, 0x93, 0xea, 0x32, 0x84, 0xab, 0xb5, 0x72, 0x68, 0x89, 0x21, 0x77, 0x6e, 0x17, 0x20, 0x0, 0x1a, 0xb6, 0xa7, 0x97, 0xa3, 0x56, 0x51, 0x9c, 0x3b, 0xf2, 0x51, 0xbb, 0x3c, 0xc1, 0x34, 0x91, 0x2d, 0xf3, 0x59, 0xd0, 0x98, 0x45, 0x3f, 0xc8, 0x26, 0x16, 0x1f, 0x15, 0x0, 0xe, 0x1c, 0x3f, 0x99, 0xae, 0xce, 0xb9, 0x4d, 0x75, 0x57, 0xb0, 0x62, 0xb7, 0xac, 0x86, 0x24, 0x0, 0x13, 0xdf, 0xe0, 0x73, 0x1f, 0xa9, 0x30, 0x62, 0x43, 0x5, 0x51, 0xc8, 0xdd, 0xf8, 0x71, 0x45, 0xeb, 0xff, 0x42, 0xa, 0x21}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xb6, 0xa7, 0x97, 0xa3, 0x56, 0x51, 0x9c, 0x3b, 0xf2, 0x51, 0xbb, 0x3c, 0xc1, 0x34, 0x91, 0x2d, 0xf3, 0x59, 0xd0, 0x98, 0x45, 0x3f, 0xc8, 0x26, 0x16, 0x1f}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1c, 0x3f, 0x99, 0xae, 0xce, 0xb9, 0x4d, 0x75, 0x57, 0xb0, 0x62, 0xb7, 0xac, 0x86}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdf, 0xe0, 0x73, 0x1f, 0xa9, 0x30, 0x62, 0x43, 0x5, 0x51, 0xc8, 0xdd, 0xf8, 0x71, 0x45, 0xeb, 0xff, 0x42, 0xa}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; -lwmqtt_sub_options_t sub_opts[3]; -sub_opts[0].qos = LWMQTT_QOS1; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = true; -sub_opts[1].qos = LWMQTT_QOS0; -sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = true; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = false; - uint8_t bytesprops0[] = {0x98, 0xe0, 0x5b, 0x35, 0x42}; - uint8_t bytesprops2[] = {0x34, 0x36, 0xc8, 0xee, 0x10, 0x66, 0xb0, 0x1d, 0xc0, 0x6a, 0x23, 0xb7, 0x72, 0x18, 0xea, 0x5, 0x85, 0xf9}; - uint8_t bytesprops1[] = {0x82, 0x18, 0x73, 0xc, 0x34, 0x2d, 0xf5, 0xe3}; - uint8_t bytesprops3[] = {0x1d, 0xc8, 0x39, 0xd1, 0xd8, 0xb6, 0x89, 0x3c, 0xb9, 0xaa, 0x93, 0xea, 0x32, 0x84, 0xab, 0xb5, 0x72, 0x68, 0x89}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 477}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={8, (char*)&bytesprops1}, .v={18, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30574}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 32}}, + uint8_t pkt[] = {0x82, 0x9b, 0x2, 0x54, 0x92, 0xab, 0x1, 0x1f, 0x0, 0xf, 0x89, 0x49, 0x79, 0x85, 0x20, 0x7b, 0x2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 0x1e, 0xdd, + 0x7d, 0x56, 0x1f, 0xce, 0xe4, 0xa7, 0x2e, 0x0, 0x14, 0x72, 0xf2, 0x46, 0x6c, 0x2, 0xde, 0xe0, 0xc7, + 0xd5, 0xfe, 0x3f, 0xfd, 0x8, 0xa, 0xf1, 0x1b, 0x89, 0x66, 0xfc, 0x3, 0x28, 0x0, 0x0, 0x24, 0x0, + 0x10, 0xbc, 0xd5, 0x39, 0xdb, 0x76, 0x24, 0xa5, 0x46, 0xc2, 0xc3, 0x9d, 0x9b, 0xc1, 0x12, 0x79, 0x19, + 0x1d, 0x0, 0x16, 0x59, 0x6b, 0xb5, 0x72, 0x36, 0x51, 0xc, 0x94, 0x6c, 0x9b, 0x97, 0x95, 0xce, 0x49, + 0x85, 0x38, 0x1, 0x1, 0x94, 0x1a, 0x61, 0x51, 0xa, 0x0, 0x2, 0x44, 0xbf, 0x1e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x90, 0x8f, 0xfa, 0xb5, 0x3f, 0xde, 0x63, 0xf2, 0xc3, 0xc2, + 0x69, 0x54, 0xeb, 0xd8, 0xe6, 0xcf, 0xb0, 0x28, 0xa9, 0xcd, + 0xaf, 0x67, 0x1e, 0xdd, 0x7d, 0x56, 0x1f, 0xce, 0xe4, 0xa7}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x72, 0xf2, 0x46, 0x6c, 0x2, 0xde, 0xe0, 0xc7, 0xd5, 0xfe, + 0x3f, 0xfd, 0x8, 0xa, 0xf1, 0x1b, 0x89, 0x66, 0xfc, 0x3}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xbc, 0xd5, 0x39, 0xdb, 0x76, 0x24, 0xa5, 0x46, + 0xc2, 0xc3, 0x9d, 0x9b, 0xc1, 0x12, 0x79, 0x19}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x59, 0x6b, 0xb5, 0x72, 0x36, 0x51, 0xc, 0x94, 0x6c, 0x9b, 0x97, + 0x95, 0xce, 0x49, 0x85, 0x38, 0x1, 0x1, 0x94, 0x1a, 0x61, 0x51}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x44, 0xbf}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + uint8_t bytesprops0[] = {0x89, 0x49, 0x79, 0x85, 0x20, 0x7b, 0x2a, 0x4, 0xb, 0x35, 0xe2, 0xea, 0xdd, 0xa5, 0xc}; + uint8_t bytesprops1[] = {0xad, 0xe0, 0x3d, 0x54, 0x67, 0xd6, 0x6f, 0x3, 0x44, 0x4c, 0x62, + 0x9c, 0x74, 0x5d, 0x74, 0x1b, 0x73, 0xfe, 0x5d, 0x10, 0x2e}; + uint8_t bytesprops3[] = {0x61, 0xb0, 0x92, 0x5d, 0x2b, 0x4, 0xc0, 0x68, 0x0, 0xa5, 0xf8, 0xe5, 0xf9, + 0xb7, 0xc8, 0x46, 0x49, 0x9d, 0x60, 0xff, 0xaa, 0xc8, 0x13, 0x97, 0x87, 0x5}; + uint8_t bytesprops2[] = {0xcf, 0xbe, 0xf8, 0x7a, 0x36}; + uint8_t bytesprops4[] = {0xae, 0x41, 0x1a, 0xb6, 0x5d, 0xbf, 0xd7, 0x2c, 0xa7, 0x12, 0x1f, 0xe3, 0x1b, 0xb6, 0x63, + 0x4a, 0x71, 0xeb, 0x21, 0x59, 0x9e, 0xb, 0x26, 0xa4, 0xaf, 0xe1, 0x4f, 0xe9, 0xd2, 0x9d}; + uint8_t bytesprops5[] = {0x32, 0x3e, 0x44, 0xf6, 0xd, 0x8b, 0x3b, 0x41, 0xb6, 0x44, 0x20, 0x73, 0xfe, 0xcf}; + uint8_t bytesprops6[] = {0xb9}; + uint8_t bytesprops7[] = {0xea, 0x21, 0x7e, 0x5d, 0xbf, 0x48, 0xd6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4602}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17637}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops2}, .v = {26, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1152}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13603}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17285}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7912, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21650, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 1410 [("\146)\134\170\232\238\169\149\192\144\173`=4\225}\DC2\181\176\234\SUB-\173\SI\204",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\157\225\208\231:\189\b\244\171\243J\204\GS\233\177\CAN\210v\FS\NUL\EM",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\DC3\166\143e\196",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropRequestProblemInformation 29,PropTopicAlias 657,PropSessionExpiryInterval 1894,PropResponseTopic "$S",PropRequestResponseInformation 124,PropTopicAlias 1690,PropUserProperty "N\136xM3\136\222ru\f\176\175\DC1\230\NAK=\v\166\163\DELN\145X\210\215~\STXJz" "\220_x\128;I\ENQ\219\229\217\&7\198+\175\169\196\&7\233E^\210\198\146\ETB.]\RS\"q",PropPayloadFormatIndicator 229,PropRequestResponseInformation 121,PropRequestProblemInformation 171,PropPayloadFormatIndicator 152,PropMessageExpiryInterval 13952,PropServerReference "Q\225\246\218\234\194\NAKbVF^\f\214",PropAuthenticationData ")\254\245\174&:r!\160\SUB\218Y",PropUserProperty "\243\255y" "I",PropServerKeepAlive 9699,PropTopicAlias 857,PropServerKeepAlive 16613,PropServerKeepAlive 21324,PropMaximumQoS 131,PropRequestResponseInformation 48] +// SubscribeRequest 15109 [("\175\231\162\204$\151/\218\&0m\229",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropMaximumQoS 184,PropRequestProblemInformation +// 57,PropReasonString "[l3g\145n\246s",PropAuthenticationData "\NUL}\192\220",PropRetainAvailable 171,PropReasonString +// "8\130\150\188\246\243\SO\177\172\150\235,\255EsB\181\134+}",PropWillDelayInterval 4975] TEST(Subscribe5QCTest, Encode29) { -uint8_t pkt[] = {0x82, 0xd8, 0x1, 0x5, 0x82, 0x98, 0x1, 0x17, 0x1d, 0x23, 0x2, 0x91, 0x11, 0x0, 0x0, 0x7, 0x66, 0x8, 0x0, 0x2, 0x24, 0x53, 0x19, 0x7c, 0x23, 0x6, 0x9a, 0x26, 0x0, 0x1d, 0x4e, 0x88, 0x78, 0x4d, 0x33, 0x88, 0xde, 0x72, 0x75, 0xc, 0xb0, 0xaf, 0x11, 0xe6, 0x15, 0x3d, 0xb, 0xa6, 0xa3, 0x7f, 0x4e, 0x91, 0x58, 0xd2, 0xd7, 0x7e, 0x2, 0x4a, 0x7a, 0x0, 0x1d, 0xdc, 0x5f, 0x78, 0x80, 0x3b, 0x49, 0x5, 0xdb, 0xe5, 0xd9, 0x37, 0xc6, 0x2b, 0xaf, 0xa9, 0xc4, 0x37, 0xe9, 0x45, 0x5e, 0xd2, 0xc6, 0x92, 0x17, 0x2e, 0x5d, 0x1e, 0x22, 0x71, 0x1, 0xe5, 0x19, 0x79, 0x17, 0xab, 0x1, 0x98, 0x2, 0x0, 0x0, 0x36, 0x80, 0x1c, 0x0, 0xd, 0x51, 0xe1, 0xf6, 0xda, 0xea, 0xc2, 0x15, 0x62, 0x56, 0x46, 0x5e, 0xc, 0xd6, 0x16, 0x0, 0xc, 0x29, 0xfe, 0xf5, 0xae, 0x26, 0x3a, 0x72, 0x21, 0xa0, 0x1a, 0xda, 0x59, 0x26, 0x0, 0x3, 0xf3, 0xff, 0x79, 0x0, 0x1, 0x49, 0x13, 0x25, 0xe3, 0x23, 0x3, 0x59, 0x13, 0x40, 0xe5, 0x13, 0x53, 0x4c, 0x24, 0x83, 0x19, 0x30, 0x0, 0x19, 0x92, 0x29, 0x86, 0xaa, 0xe8, 0xee, 0xa9, 0x95, 0xc0, 0x90, 0xad, 0x60, 0x3d, 0x34, 0xe1, 0x7d, 0x12, 0xb5, 0xb0, 0xea, 0x1a, 0x2d, 0xad, 0xf, 0xcc, 0x14, 0x0, 0x15, 0x9d, 0xe1, 0xd0, 0xe7, 0x3a, 0xbd, 0x8, 0xf4, 0xab, 0xf3, 0x4a, 0xcc, 0x1d, 0xe9, 0xb1, 0x18, 0xd2, 0x76, 0x1c, 0x0, 0x19, 0x22, 0x0, 0x5, 0x13, 0xa6, 0x8f, 0x65, 0xc4, 0x9}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x92, 0x29, 0x86, 0xaa, 0xe8, 0xee, 0xa9, 0x95, 0xc0, 0x90, 0xad, 0x60, 0x3d, 0x34, 0xe1, 0x7d, 0x12, 0xb5, 0xb0, 0xea, 0x1a, 0x2d, 0xad, 0xf, 0xcc}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9d, 0xe1, 0xd0, 0xe7, 0x3a, 0xbd, 0x8, 0xf4, 0xab, 0xf3, 0x4a, 0xcc, 0x1d, 0xe9, 0xb1, 0x18, 0xd2, 0x76, 0x1c, 0x0, 0x19}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x13, 0xa6, 0x8f, 0x65, 0xc4}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; -lwmqtt_sub_options_t sub_opts[3]; -sub_opts[0].qos = LWMQTT_QOS0; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = true; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[1].retain_as_published = false; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS1; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = true; -sub_opts[2].no_local = false; - uint8_t bytesprops0[] = {0x24, 0x53}; - uint8_t bytesprops2[] = {0xdc, 0x5f, 0x78, 0x80, 0x3b, 0x49, 0x5, 0xdb, 0xe5, 0xd9, 0x37, 0xc6, 0x2b, 0xaf, 0xa9, 0xc4, 0x37, 0xe9, 0x45, 0x5e, 0xd2, 0xc6, 0x92, 0x17, 0x2e, 0x5d, 0x1e, 0x22, 0x71}; - uint8_t bytesprops1[] = {0x4e, 0x88, 0x78, 0x4d, 0x33, 0x88, 0xde, 0x72, 0x75, 0xc, 0xb0, 0xaf, 0x11, 0xe6, 0x15, 0x3d, 0xb, 0xa6, 0xa3, 0x7f, 0x4e, 0x91, 0x58, 0xd2, 0xd7, 0x7e, 0x2, 0x4a, 0x7a}; - uint8_t bytesprops3[] = {0x51, 0xe1, 0xf6, 0xda, 0xea, 0xc2, 0x15, 0x62, 0x56, 0x46, 0x5e, 0xc, 0xd6}; - uint8_t bytesprops4[] = {0x29, 0xfe, 0xf5, 0xae, 0x26, 0x3a, 0x72, 0x21, 0xa0, 0x1a, 0xda, 0x59}; - uint8_t bytesprops6[] = {0x49}; - uint8_t bytesprops5[] = {0xf3, 0xff, 0x79}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 657}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1894}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1690}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={29, (char*)&bytesprops1}, .v={29, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13952}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={3, (char*)&bytesprops5}, .v={1, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9699}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 857}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16613}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21324}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, + uint8_t pkt[] = {0x82, 0x45, 0x3b, 0x5, 0x34, 0x24, 0xb8, 0x17, 0x39, 0x1f, 0x0, 0x8, 0x5b, 0x6c, 0x33, + 0x67, 0x91, 0x6e, 0xf6, 0x73, 0x16, 0x0, 0x4, 0x0, 0x7d, 0xc0, 0xdc, 0x25, 0xab, 0x1f, + 0x0, 0x14, 0x38, 0x82, 0x96, 0xbc, 0xf6, 0xf3, 0xe, 0xb1, 0xac, 0x96, 0xeb, 0x2c, 0xff, + 0x45, 0x73, 0x42, 0xb5, 0x86, 0x2b, 0x7d, 0x18, 0x0, 0x0, 0x13, 0x6f, 0x0, 0xb, 0xaf, + 0xe7, 0xa2, 0xcc, 0x24, 0x97, 0x2f, 0xda, 0x30, 0x6d, 0xe5, 0xc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xaf, 0xe7, 0xa2, 0xcc, 0x24, 0x97, 0x2f, 0xda, 0x30, 0x6d, 0xe5}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + uint8_t bytesprops0[] = {0x5b, 0x6c, 0x33, 0x67, 0x91, 0x6e, 0xf6, 0x73}; + uint8_t bytesprops1[] = {0x0, 0x7d, 0xc0, 0xdc}; + uint8_t bytesprops2[] = {0x38, 0x82, 0x96, 0xbc, 0xf6, 0xf3, 0xe, 0xb1, 0xac, 0x96, + 0xeb, 0x2c, 0xff, 0x45, 0x73, 0x42, 0xb5, 0x86, 0x2b, 0x7d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4975}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1410, 3, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15109, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeRequest 21007 [("K\148\168\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("r\233o\161\151.",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("a\216\169\218\&7\t\173\212\208C|\f\221",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\209\136\244\253\211\NAK\191-\a\196\188\224\129\178_\238\170[\218\131$jr\220U\162:",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropAssignedClientIdentifier ")\152\165PL!\SOH\237s\235"] +// SubscribeRequest 31149 [("(\255\220",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS0}),("nuB\184\220_5\217\196}\246\129",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\n?*\177\237",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\166\247\163\135\239\140E\178R\230-\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS1}),("z\250o\254y\a\a,\201+#\222\212\164\CAN\DC1\184\138\217",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\ESC\220\r4\ak\135",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal +// = True, _subQoS = QoS2})] [PropPayloadFormatIndicator 79,PropSessionExpiryInterval +// 9736,PropSubscriptionIdentifierAvailable 116,PropPayloadFormatIndicator 214,PropRequestProblemInformation +// 5,PropServerReference "ri",PropCorrelationData "\214\216\SO\234M&\242\140\206\t\230",PropMessageExpiryInterval +// 17300,PropWillDelayInterval 32083,PropMaximumQoS 189] TEST(Subscribe5QCTest, Encode30) { -uint8_t pkt[] = {0x82, 0x4e, 0x52, 0xf, 0xd, 0x12, 0x0, 0xa, 0x29, 0x98, 0xa5, 0x50, 0x4c, 0x21, 0x1, 0xed, 0x73, 0xeb, 0x0, 0x4, 0x4b, 0x94, 0xa8, 0x1, 0x2, 0x0, 0x6, 0x72, 0xe9, 0x6f, 0xa1, 0x97, 0x2e, 0x2a, 0x0, 0xd, 0x61, 0xd8, 0xa9, 0xda, 0x37, 0x9, 0xad, 0xd4, 0xd0, 0x43, 0x7c, 0xc, 0xdd, 0x4, 0x0, 0x1b, 0xd1, 0x88, 0xf4, 0xfd, 0xd3, 0x15, 0xbf, 0x2d, 0x7, 0xc4, 0xbc, 0xe0, 0x81, 0xb2, 0x5f, 0xee, 0xaa, 0x5b, 0xda, 0x83, 0x24, 0x6a, 0x72, 0xdc, 0x55, 0xa2, 0x3a, 0x16}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; -lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x4b, 0x94, 0xa8, 0x1}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; -topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x72, 0xe9, 0x6f, 0xa1, 0x97, 0x2e}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; -topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x61, 0xd8, 0xa9, 0xda, 0x37, 0x9, 0xad, 0xd4, 0xd0, 0x43, 0x7c, 0xc, 0xdd}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; -topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd1, 0x88, 0xf4, 0xfd, 0xd3, 0x15, 0xbf, 0x2d, 0x7, 0xc4, 0xbc, 0xe0, 0x81, 0xb2, 0x5f, 0xee, 0xaa, 0x5b, 0xda, 0x83, 0x24, 0x6a, 0x72, 0xdc, 0x55, 0xa2, 0x3a}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; -topic_filters[3] = topic_filter_s3; -lwmqtt_sub_options_t sub_opts[4]; -sub_opts[0].qos = LWMQTT_QOS2; -sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[0].retain_as_published = false; -sub_opts[0].no_local = false; -sub_opts[1].qos = LWMQTT_QOS2; -sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; -sub_opts[1].retain_as_published = true; -sub_opts[1].no_local = false; -sub_opts[2].qos = LWMQTT_QOS0; -sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; -sub_opts[2].retain_as_published = false; -sub_opts[2].no_local = true; -sub_opts[3].qos = LWMQTT_QOS2; -sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; -sub_opts[3].retain_as_published = false; -sub_opts[3].no_local = true; - uint8_t bytesprops0[] = {0x29, 0x98, 0xa5, 0x50, 0x4c, 0x21, 0x1, 0xed, 0x73, 0xeb}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, + uint8_t pkt[] = {0x82, 0x7b, 0x79, 0xad, 0x2c, 0x1, 0x4f, 0x11, 0x0, 0x0, 0x26, 0x8, 0x29, 0x74, 0x1, 0xd6, + 0x17, 0x5, 0x1c, 0x0, 0x2, 0x72, 0x69, 0x9, 0x0, 0xb, 0xd6, 0xd8, 0xe, 0xea, 0x4d, 0x26, + 0xf2, 0x8c, 0xce, 0x9, 0xe6, 0x2, 0x0, 0x0, 0x43, 0x94, 0x18, 0x0, 0x0, 0x7d, 0x53, 0x24, + 0xbd, 0x0, 0x3, 0x28, 0xff, 0xdc, 0x18, 0x0, 0xc, 0x6e, 0x75, 0x42, 0xb8, 0xdc, 0x5f, 0x35, + 0xd9, 0xc4, 0x7d, 0xf6, 0x81, 0x20, 0x0, 0x5, 0xa, 0x3f, 0x2a, 0xb1, 0xed, 0x2d, 0x0, 0xc, + 0xa6, 0xf7, 0xa3, 0x87, 0xef, 0x8c, 0x45, 0xb2, 0x52, 0xe6, 0x2d, 0x98, 0x5, 0x0, 0x13, 0x7a, + 0xfa, 0x6f, 0xfe, 0x79, 0x7, 0x7, 0x2c, 0xc9, 0x2b, 0x23, 0xde, 0xd4, 0xa4, 0x18, 0x11, 0xb8, + 0x8a, 0xd9, 0x2, 0x0, 0x7, 0x1b, 0xdc, 0xd, 0x34, 0x7, 0x6b, 0x87, 0x2e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x28, 0xff, 0xdc}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x6e, 0x75, 0x42, 0xb8, 0xdc, 0x5f, 0x35, 0xd9, 0xc4, 0x7d, 0xf6, 0x81}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa, 0x3f, 0x2a, 0xb1, 0xed}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa6, 0xf7, 0xa3, 0x87, 0xef, 0x8c, 0x45, 0xb2, 0x52, 0xe6, 0x2d, 0x98}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x7a, 0xfa, 0x6f, 0xfe, 0x79, 0x7, 0x7, 0x2c, 0xc9, 0x2b, + 0x23, 0xde, 0xd4, 0xa4, 0x18, 0x11, 0xb8, 0x8a, 0xd9}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1b, 0xdc, 0xd, 0x34, 0x7, 0x6b, 0x87}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + uint8_t bytesprops0[] = {0x72, 0x69}; + uint8_t bytesprops1[] = {0xd6, 0xd8, 0xe, 0xea, 0x4d, 0x26, 0xf2, 0x8c, 0xce, 0x9, 0xe6}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9736}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17300}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32083}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21007, 4, topic_filters, sub_opts, props); + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31149, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); - } - -// SubscribeResponse 6377 [Right QoS0,Right QoS0,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0] [] +// SubscribeResponse 13080 [Right QoS1,Right QoS0,Left SubErrNotAuthorized,Left SubErrNotAuthorized,Right QoS1,Right +// QoS1,Left SubErrPacketIdentifierInUse,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS0] [] TEST(SubACK311QCTest, Decode1) { -uint8_t pkt[] = {0x90, 0x7, 0x18, 0xe9, 0x0, 0x0, 0x1, 0xa1, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 6377); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[3], 0x80); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - -} - - -// SubscribeResponse 22342 [Left SubErrQuotaExceeded,Right QoS2,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS1,Right QoS0] [] + uint8_t pkt[] = {0x90, 0xd, 0x33, 0x18, 0x1, 0x0, 0x87, 0x87, 0x1, 0x1, 0x91, 0x2, 0x2, 0x8f, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 13080); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); +} + +// SubscribeResponse 32460 [Left SubErrImplementationSpecificError,Right QoS2,Right QoS0,Left +// SubErrUnspecifiedError,Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrUnspecifiedError,Left +// SubErrUnspecifiedError,Right QoS2,Right QoS1,Right QoS2] [] TEST(SubACK311QCTest, Decode2) { -uint8_t pkt[] = {0x90, 0xd, 0x57, 0x46, 0x97, 0x2, 0xa1, 0x9e, 0x1, 0x8f, 0x0, 0x91, 0x0, 0x1, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[11]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 11, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 22342); -EXPECT_EQ(count, 11); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], 0x80); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[5], 0x80); -EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[7], 0x80); -EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); - -} - - -// SubscribeResponse 20403 [Left SubErrImplementationSpecificError,Left SubErrNotAuthorized,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [] + uint8_t pkt[] = {0x90, 0xd, 0x7e, 0xcc, 0x83, 0x2, 0x0, 0x80, 0x2, 0x91, 0x80, 0x80, 0x2, 0x1, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 32460); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); +} + +// SubscribeResponse 7819 [Right QoS2,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode3) { -uint8_t pkt[] = {0x90, 0x6, 0x4f, 0xb3, 0x83, 0x87, 0xa1, 0x1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[4]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 4, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 20403); -EXPECT_EQ(count, 4); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], 0x80); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - + uint8_t pkt[] = {0x90, 0x5, 0x1e, 0x8b, 0x2, 0x1, 0xa2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7819); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); } - -// SubscribeResponse 8789 [Left SubErrUnspecifiedError,Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] [] +// SubscribeResponse 17369 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode4) { -uint8_t pkt[] = {0x90, 0x7, 0x22, 0x55, 0x80, 0x9e, 0x97, 0x1, 0xa2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 8789); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], 0x80); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[4], 0x80); - + uint8_t pkt[] = {0x90, 0x5, 0x43, 0xd9, 0x2, 0x9e, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 17369); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); } - -// SubscribeResponse 2708 [Right QoS1,Right QoS2,Right QoS0,Right QoS0,Left SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS1,Right QoS0,Right QoS1] [] +// SubscribeResponse 14645 [Right QoS0,Left SubErrTopicFilterInvalid,Right QoS1,Left SubErrTopicFilterInvalid,Right +// QoS1,Right QoS2,Right QoS0] [] TEST(SubACK311QCTest, Decode5) { -uint8_t pkt[] = {0x90, 0xd, 0xa, 0x94, 0x1, 0x2, 0x0, 0x0, 0x8f, 0xa2, 0x2, 0x1, 0x1, 0x0, 0x1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[11]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 11, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 2708); -EXPECT_EQ(count, 11); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[4], 0x80); -EXPECT_EQ(granted_qos_levels[5], 0x80); -EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS1); - -} - - -// SubscribeResponse 12793 [Left SubErrTopicFilterInvalid,Right QoS0,Right QoS0,Right QoS2,Left SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [] + uint8_t pkt[] = {0x90, 0x9, 0x39, 0x35, 0x0, 0x8f, 0x1, 0x8f, 0x1, 0x2, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 14645); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); +} + +// SubscribeResponse 12295 [Left SubErrPacketIdentifierInUse,Right QoS0,Left SubErrTopicFilterInvalid,Right QoS2] [] TEST(SubACK311QCTest, Decode6) { -uint8_t pkt[] = {0x90, 0xa, 0x31, 0xf9, 0x8f, 0x0, 0x0, 0x2, 0x8f, 0xa2, 0x1, 0xa1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[8]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 8, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 12793); -EXPECT_EQ(count, 8); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[4], 0x80); -EXPECT_EQ(granted_qos_levels[5], 0x80); -EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[7], 0x80); - -} - - -// SubscribeResponse 16851 [Left SubErrNotAuthorized] [] -TEST(SubACK311QCTest, Decode7) { -uint8_t pkt[] = {0x90, 0x3, 0x41, 0xd3, 0x87}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 16851); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], 0x80); - + uint8_t pkt[] = {0x90, 0x6, 0x30, 0x7, 0x91, 0x0, 0x8f, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 12295); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); } - -// SubscribeResponse 23680 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Left SubErrUnspecifiedError,Right QoS2,Right QoS2,Right QoS2,Right QoS1,Right QoS0,Right QoS0,Left SubErrImplementationSpecificError,Left SubErrTopicFilterInvalid] [] +// SubscribeResponse 10100 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Right QoS0,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS2,Right QoS2,Left +// SubErrPacketIdentifierInUse,Right QoS2,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError] [] +TEST(SubACK311QCTest, Decode7) { + uint8_t pkt[] = {0x90, 0xd, 0x27, 0x74, 0xa1, 0x0, 0x0, 0xa2, 0x80, 0x2, 0x2, 0x91, 0x2, 0x97, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 10100); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[10], 0x80); +} + +// SubscribeResponse 19212 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Left +// SubErrImplementationSpecificError,Right QoS0,Right QoS2,Right QoS0,Left SubErrPacketIdentifierInUse] [] TEST(SubACK311QCTest, Decode8) { -uint8_t pkt[] = {0x90, 0xd, 0x5c, 0x80, 0xa1, 0x8f, 0x80, 0x2, 0x2, 0x2, 0x1, 0x0, 0x0, 0x83, 0x8f}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[11]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 11, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 23680); -EXPECT_EQ(count, 11); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], 0x80); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[9], 0x80); -EXPECT_EQ(granted_qos_levels[10], 0x80); - -} - - -// SubscribeResponse 7955 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrImplementationSpecificError,Right QoS2,Right QoS2,Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError,Left SubErrNotAuthorized] [] + uint8_t pkt[] = {0x90, 0x9, 0x4b, 0xc, 0xa1, 0x1, 0x83, 0x0, 0x2, 0x0, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 19212); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x80); +} + +// SubscribeResponse 31570 [Left SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode9) { -uint8_t pkt[] = {0x90, 0xa, 0x1f, 0x13, 0x1, 0xa1, 0x83, 0x2, 0x2, 0x97, 0x83, 0x87}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[8]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 8, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 7955); -EXPECT_EQ(count, 8); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[1], 0x80); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[5], 0x80); -EXPECT_EQ(granted_qos_levels[6], 0x80); -EXPECT_EQ(granted_qos_levels[7], 0x80); - -} - - -// SubscribeResponse 29704 [Right QoS2,Right QoS0,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS2] [] + uint8_t pkt[] = {0x90, 0x3, 0x7b, 0x52, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 31570); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], 0x80); +} + +// SubscribeResponse 15416 [Right QoS1,Left SubErrQuotaExceeded,Left SubErrTopicFilterInvalid,Right QoS1,Left +// SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode10) { -uint8_t pkt[] = {0x90, 0xb, 0x74, 0x8, 0x2, 0x0, 0x1, 0x9e, 0xa1, 0x0, 0x9e, 0x0, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[9]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 9, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 29704); -EXPECT_EQ(count, 9); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[3], 0x80); -EXPECT_EQ(granted_qos_levels[4], 0x80); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[6], 0x80); -EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - -} - - -// SubscribeResponse 251 [Left SubErrNotAuthorized,Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded,Right QoS2,Right QoS2] [] + uint8_t pkt[] = {0x90, 0x7, 0x3c, 0x38, 0x1, 0x97, 0x8f, 0x1, 0xa2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 15416); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x80); +} + +// SubscribeResponse 24411 [Right QoS2,Left SubErrImplementationSpecificError,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse] +// [] TEST(SubACK311QCTest, Decode11) { -uint8_t pkt[] = {0x90, 0x9, 0x0, 0xfb, 0x87, 0x87, 0x80, 0x91, 0x97, 0x2, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[7]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 7, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 251); -EXPECT_EQ(count, 7); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], 0x80); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], 0x80); -EXPECT_EQ(granted_qos_levels[4], 0x80); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - -} - - -// SubscribeResponse 4144 [Right QoS2] [] + uint8_t pkt[] = {0x90, 0x7, 0x5f, 0x5b, 0x2, 0x83, 0x9e, 0xa2, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 24411); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); +} + +// SubscribeResponse 16797 [Right QoS0,Right QoS0,Right QoS1,Right QoS2,Left SubErrUnspecifiedError,Right QoS0,Right +// QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrNotAuthorized,Left +// SubErrSubscriptionIdentifiersNotSupported] [] TEST(SubACK311QCTest, Decode12) { -uint8_t pkt[] = {0x90, 0x3, 0x10, 0x30, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 4144); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - -} - - -// SubscribeResponse 22442 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS0] [] + uint8_t pkt[] = {0x90, 0xc, 0x41, 0x9d, 0x0, 0x0, 0x1, 0x2, 0x80, 0x0, 0x0, 0x9e, 0x87, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 16797); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], 0x80); +} + +// SubscribeResponse 8011 [Right QoS0,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Left +// SubErrTopicFilterInvalid,Right QoS2] [] TEST(SubACK311QCTest, Decode13) { -uint8_t pkt[] = {0x90, 0x4, 0x57, 0xaa, 0xa2, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[2]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 2, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 22442); -EXPECT_EQ(count, 2); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - -} - - -// SubscribeResponse 5149 [Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS2,Right QoS2,Left SubErrImplementationSpecificError] [] + uint8_t pkt[] = {0x90, 0x8, 0x1f, 0x4b, 0x0, 0x2, 0x2, 0x8f, 0x8f, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8011); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); +} + +// SubscribeResponse 32745 [Right QoS0,Right QoS2,Right QoS1,Left SubErrNotAuthorized,Right QoS0,Right QoS2,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS2] [] TEST(SubACK311QCTest, Decode14) { -uint8_t pkt[] = {0x90, 0x8, 0x14, 0x1d, 0x91, 0x0, 0x2, 0x2, 0x2, 0x83}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 5149); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[5], 0x80); - -} - - -// SubscribeResponse 27317 [Left SubErrPacketIdentifierInUse,Left SubErrTopicFilterInvalid,Right QoS2,Right QoS0,Right QoS0,Right QoS2] [] + uint8_t pkt[] = {0x90, 0xa, 0x7f, 0xe9, 0x0, 0x2, 0x1, 0x87, 0x0, 0x2, 0xa2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 32745); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); +} + +// SubscribeResponse 8548 [Right QoS1,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS0] [] TEST(SubACK311QCTest, Decode15) { -uint8_t pkt[] = {0x90, 0x8, 0x6a, 0xb5, 0x91, 0x8f, 0x2, 0x0, 0x0, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 27317); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], 0x80); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - + uint8_t pkt[] = {0x90, 0x7, 0x21, 0x64, 0x1, 0x2, 0xa2, 0xa2, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8548); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); } - -// SubscribeResponse 30611 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS0,Right QoS2,Right QoS1] [] +// SubscribeResponse 12279 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left +// SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode16) { -uint8_t pkt[] = {0x90, 0x7, 0x77, 0x93, 0xa1, 0x2, 0x0, 0x2, 0x1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 30611); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - + uint8_t pkt[] = {0x90, 0x6, 0x2f, 0xf7, 0x2, 0x9e, 0x1, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 12279); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); } - -// SubscribeResponse 14554 [Right QoS0,Right QoS2,Left SubErrUnspecifiedError,Right QoS0] [] +// SubscribeResponse 8001 [Right QoS2,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS2,Left +// SubErrNotAuthorized,Left SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode17) { -uint8_t pkt[] = {0x90, 0x6, 0x38, 0xda, 0x0, 0x2, 0x80, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[4]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 4, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 14554); -EXPECT_EQ(count, 4); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - -} - - -// SubscribeResponse 22626 [Right QoS2,Right QoS1,Left SubErrImplementationSpecificError,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported] [] + uint8_t pkt[] = {0x90, 0x9, 0x1f, 0x41, 0x2, 0x0, 0xa2, 0x2, 0x2, 0x87, 0xa2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8001); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); +} + +// SubscribeResponse 4988 [Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrNotAuthorized,Left +// SubErrImplementationSpecificError,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS2] [] TEST(SubACK311QCTest, Decode18) { -uint8_t pkt[] = {0x90, 0x8, 0x58, 0x62, 0x2, 0x1, 0x83, 0x2, 0x2, 0x9e}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 22626); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[5], 0x80); - + uint8_t pkt[] = {0x90, 0xd, 0x13, 0x7c, 0x8f, 0x0, 0x87, 0x83, 0xa2, 0x9e, 0x0, 0xa1, 0x9e, 0x1, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4988); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); +} + +// SubscribeResponse 6982 [Right QoS0,Left SubErrTopicFilterInvalid,Left SubErrQuotaExceeded,Left +// SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS2,Right QoS0,Right QoS1,Left SubErrTopicFilterInvalid,Left +// SubErrTopicFilterInvalid,Right QoS0] [] +TEST(SubACK311QCTest, Decode19) { + uint8_t pkt[] = {0x90, 0xd, 0x1b, 0x46, 0x0, 0x8f, 0x97, 0x80, 0x87, 0x2, 0x0, 0x1, 0x8f, 0x8f, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 6982); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); +} + +// SubscribeResponse 25134 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrImplementationSpecificError,Right +// QoS2,Left SubErrNotAuthorized,Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrQuotaExceeded] [] +TEST(SubACK311QCTest, Decode20) { + uint8_t pkt[] = {0x90, 0xa, 0x62, 0x2e, 0xa1, 0x83, 0x2, 0x87, 0x0, 0x2, 0xa2, 0x97}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 25134); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); +} + +// SubscribeResponse 25090 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrQuotaExceeded,Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Right QoS1,Left +// SubErrPacketIdentifierInUse] [] +TEST(SubACK311QCTest, Decode21) { + uint8_t pkt[] = {0x90, 0x9, 0x62, 0x2, 0x80, 0xa2, 0x97, 0x8f, 0x83, 0x1, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 25090); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); +} + +// SubscribeResponse 270 [Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS0,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrUnspecifiedError] [] +TEST(SubACK311QCTest, Decode22) { + uint8_t pkt[] = {0x90, 0xc, 0x1, 0xe, 0x91, 0x0, 0x0, 0xa2, 0x1, 0xa1, 0xa1, 0x0, 0xa1, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 270); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], 0x80); +} + +// SubscribeResponse 28717 [Right QoS0,Left SubErrQuotaExceeded,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrPacketIdentifierInUse,Right QoS2,Right QoS1,Right QoS2,Right QoS2] [] +TEST(SubACK311QCTest, Decode23) { + uint8_t pkt[] = {0x90, 0xa, 0x70, 0x2d, 0x0, 0x97, 0xa2, 0x91, 0x2, 0x1, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 28717); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); +} + +// SubscribeResponse 8736 [Right QoS1,Right QoS2,Left SubErrImplementationSpecificError,Right QoS2,Right QoS0,Right +// QoS1] [] +TEST(SubACK311QCTest, Decode24) { + uint8_t pkt[] = {0x90, 0x8, 0x22, 0x20, 0x1, 0x2, 0x83, 0x2, 0x0, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8736); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); +} + +// SubscribeResponse 27132 [Left SubErrWildcardSubscriptionsNotSupported,Left SubErrImplementationSpecificError,Right +// QoS0] [] +TEST(SubACK311QCTest, Decode25) { + uint8_t pkt[] = {0x90, 0x5, 0x69, 0xfc, 0xa2, 0x83, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 27132); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); } +// SubscribeResponse 20260 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS1,Right QoS1] [] +TEST(SubACK311QCTest, Decode26) { + uint8_t pkt[] = {0x90, 0x8, 0x4f, 0x24, 0x2, 0x91, 0x0, 0x2, 0x1, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 20260); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); +} + +// SubscribeResponse 471 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS0,Left +// SubErrNotAuthorized,Right QoS2,Left SubErrImplementationSpecificError,Right QoS1,Right QoS1] [] +TEST(SubACK311QCTest, Decode27) { + uint8_t pkt[] = {0x90, 0xa, 0x1, 0xd7, 0x9e, 0x0, 0x0, 0x87, 0x2, 0x83, 0x1, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 471); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); +} + +// SubscribeResponse 21021 [Right QoS1,Right QoS2,Right QoS2,Right QoS2] [] +TEST(SubACK311QCTest, Decode28) { + uint8_t pkt[] = {0x90, 0x6, 0x52, 0x1d, 0x1, 0x2, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 21021); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +} -// SubscribeResponse 22779 [Right QoS0] [] -TEST(SubACK311QCTest, Decode19) { -uint8_t pkt[] = {0x90, 0x3, 0x58, 0xfb, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 22779); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - +// SubscribeResponse 3050 [Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrUnspecifiedError,Left +// SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left SubErrSharedSubscriptionsNotSupported,Right QoS0] [] +TEST(SubACK311QCTest, Decode29) { + uint8_t pkt[] = {0x90, 0x9, 0xb, 0xea, 0x2, 0x91, 0x80, 0x80, 0x91, 0x9e, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 3050); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); +} + +// SubscribeResponse 9426 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrTopicFilterInvalid,Right QoS0,Right QoS2] [] +TEST(SubACK311QCTest, Decode30) { + uint8_t pkt[] = {0x90, 0xd, 0x24, 0xd2, 0x80, 0xa2, 0xa2, 0x1, 0x1, 0x83, 0xa2, 0x9e, 0x8f, 0x0, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 9426); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); +} + +// SubscribeResponse 13080 [Right QoS1,Right QoS0,Left SubErrNotAuthorized,Left SubErrNotAuthorized,Right QoS1,Right +// QoS1,Left SubErrPacketIdentifierInUse,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS0] +// [PropCorrelationData "\242'L\238\DC3t{\175QVr\STX+\r\195\172\187h\202_\"\142\b\170i{\234\221F\212",PropContentType +// "|]w\253\nFy\252]Vf\254\239?j\197\193\237\vj\174\137\&3L",PropWillDelayInterval 11256,PropMaximumPacketSize +// 14054,PropMaximumPacketSize 28209,PropReasonString "3\159\r",PropWildcardSubscriptionAvailable +// 206,PropSessionExpiryInterval 11090,PropAssignedClientIdentifier "\182V@\252\178\185\166#(\145\&0SP\176\188\EM +// w-\r\230oG\ACK",PropCorrelationData +// "\132\142GK\176\169\216\139\ENQ\145\221Y\249.\186\&1i\142\151\195\244\201\218\&6\176\215\STX",PropSharedSubscriptionAvailable +// 213,PropMessageExpiryInterval 1156,PropMaximumPacketSize 5568,PropSubscriptionIdentifier +// 0,PropRequestResponseInformation 243,PropMessageExpiryInterval 28104] +TEST(SubACK5QCTest, Decode1) { + uint8_t pkt[] = {0x90, 0xb5, 0x1, 0x33, 0x18, 0xa6, 0x1, 0x9, 0x0, 0x1e, 0xf2, 0x27, 0x4c, 0xee, 0x13, 0x74, 0x7b, + 0xaf, 0x51, 0x56, 0x72, 0x2, 0x2b, 0xd, 0xc3, 0xac, 0xbb, 0x68, 0xca, 0x5f, 0x22, 0x8e, 0x8, 0xaa, + 0x69, 0x7b, 0xea, 0xdd, 0x46, 0xd4, 0x3, 0x0, 0x18, 0x7c, 0x5d, 0x77, 0xfd, 0xa, 0x46, 0x79, 0xfc, + 0x5d, 0x56, 0x66, 0xfe, 0xef, 0x3f, 0x6a, 0xc5, 0xc1, 0xed, 0xb, 0x6a, 0xae, 0x89, 0x33, 0x4c, 0x18, + 0x0, 0x0, 0x2b, 0xf8, 0x27, 0x0, 0x0, 0x36, 0xe6, 0x27, 0x0, 0x0, 0x6e, 0x31, 0x1f, 0x0, 0x3, + 0x33, 0x9f, 0xd, 0x28, 0xce, 0x11, 0x0, 0x0, 0x2b, 0x52, 0x12, 0x0, 0x18, 0xb6, 0x56, 0x40, 0xfc, + 0xb2, 0xb9, 0xa6, 0x23, 0x28, 0x91, 0x30, 0x53, 0x50, 0xb0, 0xbc, 0x19, 0x20, 0x77, 0x2d, 0xd, 0xe6, + 0x6f, 0x47, 0x6, 0x9, 0x0, 0x1b, 0x84, 0x8e, 0x47, 0x4b, 0xb0, 0xa9, 0xd8, 0x8b, 0x5, 0x91, 0xdd, + 0x59, 0xf9, 0x2e, 0xba, 0x31, 0x69, 0x8e, 0x97, 0xc3, 0xf4, 0xc9, 0xda, 0x36, 0xb0, 0xd7, 0x2, 0x2a, + 0xd5, 0x2, 0x0, 0x0, 0x4, 0x84, 0x27, 0x0, 0x0, 0x15, 0xc0, 0xb, 0x0, 0x19, 0xf3, 0x2, 0x0, + 0x0, 0x6d, 0xc8, 0x1, 0x0, 0x87, 0x87, 0x1, 0x1, 0x91, 0x2, 0x2, 0x8f, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 13080); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x87); + EXPECT_EQ(granted_qos_levels[3], 0x87); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x91); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], 0x8F); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); +} + +// SubscribeResponse 32460 [Left SubErrImplementationSpecificError,Right QoS2,Right QoS0,Left +// SubErrUnspecifiedError,Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrUnspecifiedError,Left +// SubErrUnspecifiedError,Right QoS2,Right QoS1,Right QoS2] [PropMaximumQoS 184,PropWildcardSubscriptionAvailable +// 136,PropTopicAliasMaximum 16792,PropWildcardSubscriptionAvailable 177,PropSubscriptionIdentifier 21,PropReasonString +// "\216\246$\243\ESC\190(\179\180\220\135QI\131\160,\SO\198\168\DLE{\151",PropReasonString +// "\140[F\192\171\&9\CAN\DC1\DC4\225\DELQ\156#",PropUserProperty +// "\242\181k\SO\206\166S\157\246\231e\136\202\187\180\151\r\204x9(\202\129\b\194\b\EOT" +// "\160\161\254z\252\150\169\170,)\141\EM\207\147\158\169\137\133\SOH\210\220)\137P\SOHR\229\&1",PropMaximumPacketSize +// 30976,PropPayloadFormatIndicator 118,PropServerKeepAlive 29125,PropReceiveMaximum 14366,PropPayloadFormatIndicator +// 42,PropResponseInformation "\135f+\177j\SO\RS\191T\129g\195\214!\222",PropAssignedClientIdentifier +// "&+\142o\220\&6\FS\202;\151\204\USq\SI\241/\167\164\GS\\gOS\225\a",PropSharedSubscriptionAvailable 67,PropTopicAlias +// 504,PropMessageExpiryInterval 13989,PropAssignedClientIdentifier +// ",\197/\196\SYN\220/\208\160\229\&9e\170Zt\156\139\185",PropResponseTopic "[\tY",PropReasonString +// "h\172\STXi\153y\139@\128u\FS9\138%\230\158$6p\128\163\&5\228P\132h|Po\DC1",PropAuthenticationMethod +// "\251G\217\188\154\GS",PropWillDelayInterval 23086] +TEST(SubACK5QCTest, Decode2) { + uint8_t pkt[] = { + 0x90, 0x91, 0x2, 0x7e, 0xcc, 0x82, 0x2, 0x24, 0xb8, 0x28, 0x88, 0x22, 0x41, 0x98, 0x28, 0xb1, 0xb, 0x15, 0x1f, + 0x0, 0x16, 0xd8, 0xf6, 0x24, 0xf3, 0x1b, 0xbe, 0x28, 0xb3, 0xb4, 0xdc, 0x87, 0x51, 0x49, 0x83, 0xa0, 0x2c, 0xe, + 0xc6, 0xa8, 0x10, 0x7b, 0x97, 0x1f, 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75, 0x1c, 0x39, 0x8a, 0x25, 0xe6, 0x9e, 0x24, 0x36, 0x70, 0x80, 0xa3, 0x35, 0xe4, 0x50, 0x84, 0x68, + 0x7c, 0x50, 0x6f, 0x11, 0x15, 0x0, 0x6, 0xfb, 0x47, 0xd9, 0xbc, 0x9a, 0x1d, 0x18, 0x0, 0x0, 0x5a, 0x2e, 0x83, + 0x2, 0x0, 0x80, 0x2, 0x91, 0x80, 0x80, 0x2, 0x1, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 32460); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x83); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x91); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); +} + +// SubscribeResponse 7819 [Right QoS2,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] +// [PropSharedSubscriptionAvailable 150,PropSubscriptionIdentifierAvailable 160,PropServerKeepAlive +// 19557,PropRequestResponseInformation 138,PropAuthenticationMethod +// "\236\145\214\235\210\190\189S1l\166\246\225\173'\f\224\161\191\166\201[\STX\210^",PropTopicAlias +// 24707,PropMaximumPacketSize 20799,PropContentType +// "\207\aE\227\201(\194\NUL\226\a_w\245\&9\129\254$\221\233\231\&9\253\&8h\240\GS\135.\247\150",PropMaximumQoS +// 31,PropRequestResponseInformation 6,PropCorrelationData +// "\SI\td\SYN\131\190\187\\\198\140\222\214\169\253+\f\t\192\DC2(\SOH\186\146\214\ETX%\218",PropReceiveMaximum 29138] +TEST(SubACK5QCTest, Decode3) { + uint8_t pkt[] = {0x90, 0x79, 0x1e, 0x8b, 0x73, 0x2a, 0x96, 0x29, 0xa0, 0x13, 0x4c, 0x65, 0x19, 0x8a, 0x15, 0x0, + 0x19, 0xec, 0x91, 0xd6, 0xeb, 0xd2, 0xbe, 0xbd, 0x53, 0x31, 0x6c, 0xa6, 0xf6, 0xe1, 0xad, 0x27, + 0xc, 0xe0, 0xa1, 0xbf, 0xa6, 0xc9, 0x5b, 0x2, 0xd2, 0x5e, 0x23, 0x60, 0x83, 0x27, 0x0, 0x0, + 0x51, 0x3f, 0x3, 0x0, 0x1e, 0xcf, 0x7, 0x45, 0xe3, 0xc9, 0x28, 0xc2, 0x0, 0xe2, 0x7, 0x5f, + 0x77, 0xf5, 0x39, 0x81, 0xfe, 0x24, 0xdd, 0xe9, 0xe7, 0x39, 0xfd, 0x38, 0x68, 0xf0, 0x1d, 0x87, + 0x2e, 0xf7, 0x96, 0x24, 0x1f, 0x19, 0x6, 0x9, 0x0, 0x1b, 0xf, 0x9, 0x64, 0x16, 0x83, 0xbe, + 0xbb, 0x5c, 0xc6, 0x8c, 0xde, 0xd6, 0xa9, 0xfd, 0x2b, 0xc, 0x9, 0xc0, 0x12, 0x28, 0x1, 0xba, + 0x92, 0xd6, 0x3, 0x25, 0xda, 0x21, 0x71, 0xd2, 0x2, 0x1, 0xa2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7819); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0xA2); +} + +// SubscribeResponse 17369 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left SubErrTopicFilterInvalid] +// [PropCorrelationData "\152!\DC2\241\205co\n\153l\STX\GS\158\DC1pO\217",PropRequestProblemInformation +// 23,PropRetainAvailable 158,PropSharedSubscriptionAvailable 40,PropRetainAvailable +// 138,PropWildcardSubscriptionAvailable 241,PropSessionExpiryInterval 14344,PropReceiveMaximum +// 20784,PropServerKeepAlive 559,PropServerReference ">\252\161\243\143O\DLE\165\147|\215\DC2+",PropContentType +// "\203\248\228\192\212|\EM\213\234%\165\DEL\211\237\224\211\GS{`PV\128\185`\165\EOT",PropSubscriptionIdentifierAvailable +// 49,PropResponseInformation "dsHa\206\179>\216\217\222\190O\247\DC3\DC3",PropResponseTopic +// "L\234Q\188\186\224\132\151:X\EOTj\227 \176\242\175C\ACKSp\215",PropTopicAlias 22362,PropTopicAlias +// 11639,PropWillDelayInterval 30787,PropSubscriptionIdentifierAvailable 2,PropResponseTopic +// "\187\222\&2\ACKh`\243P\ACK*\STX\225\r",PropSubscriptionIdentifierAvailable 171,PropServerReference "\137@\220"] +TEST(SubACK5QCTest, Decode4) { + uint8_t pkt[] = {0x90, 0xaf, 0x1, 0x43, 0xd9, 0xa8, 0x1, 0x9, 0x0, 0x11, 0x98, 0x21, 0x12, 0xf1, 0xcd, 0x63, 0x6f, + 0xa, 0x99, 0x6c, 0x2, 0x1d, 0x9e, 0x11, 0x70, 0x4f, 0xd9, 0x17, 0x17, 0x25, 0x9e, 0x2a, 0x28, 0x25, + 0x8a, 0x28, 0xf1, 0x11, 0x0, 0x0, 0x38, 0x8, 0x21, 0x51, 0x30, 0x13, 0x2, 0x2f, 0x1c, 0x0, 0xd, + 0x3e, 0xfc, 0xa1, 0xf3, 0x8f, 0x4f, 0x10, 0xa5, 0x93, 0x7c, 0xd7, 0x12, 0x2b, 0x3, 0x0, 0x1a, 0xcb, + 0xf8, 0xe4, 0xc0, 0xd4, 0x7c, 0x19, 0xd5, 0xea, 0x25, 0xa5, 0x7f, 0xd3, 0xed, 0xe0, 0xd3, 0x1d, 0x7b, + 0x60, 0x50, 0x56, 0x80, 0xb9, 0x60, 0xa5, 0x4, 0x29, 0x31, 0x1a, 0x0, 0xf, 0x64, 0x73, 0x48, 0x61, + 0xce, 0xb3, 0x3e, 0xd8, 0xd9, 0xde, 0xbe, 0x4f, 0xf7, 0x13, 0x13, 0x8, 0x0, 0x16, 0x4c, 0xea, 0x51, + 0xbc, 0xba, 0xe0, 0x84, 0x97, 0x3a, 0x58, 0x4, 0x6a, 0xe3, 0x20, 0xb0, 0xf2, 0xaf, 0x43, 0x6, 0x53, + 0x70, 0xd7, 0x23, 0x57, 0x5a, 0x23, 0x2d, 0x77, 0x18, 0x0, 0x0, 0x78, 0x43, 0x29, 0x2, 0x8, 0x0, + 0xd, 0xbb, 0xde, 0x32, 0x6, 0x68, 0x60, 0xf3, 0x50, 0x6, 0x2a, 0x2, 0xe1, 0xd, 0x29, 0xab, 0x1c, + 0x0, 0x3, 0x89, 0x40, 0xdc, 0x2, 0x9e, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 17369); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x9E); + EXPECT_EQ(granted_qos_levels[2], 0x8F); +} + +// SubscribeResponse 14645 [Right QoS0,Left SubErrTopicFilterInvalid,Right QoS1,Left SubErrTopicFilterInvalid,Right +// QoS1,Right QoS2,Right QoS0] [PropCorrelationData +// "\179\182\172\210\RS\221\243\a\147\169u\145Jt\218\133:",PropContentType +// "=u\246\161B\229\166\244,%\133\\\222\187\r\225",PropSessionExpiryInterval 20784] +TEST(SubACK5QCTest, Decode10) { + uint8_t pkt[] = {0x90, 0x99, 0x1, 0x3c, 0x38, 0x90, 0x1, 0x1f, 0x0, 0xd, 0x55, 0x52, 0xe0, 0x76, 0x98, 0x2b, + 0x2, 0x2c, 0xd6, 0x13, 0x6e, 0x7, 0x7c, 0x1c, 0x0, 0x8, 0x28, 0x8a, 0xdf, 0x9d, 0x1, 0xcc, + 0x54, 0x0, 0x28, 0xd5, 0x19, 0x57, 0x16, 0x0, 0x1, 0x6a, 0x1f, 0x0, 0x19, 0x23, 0xdc, 0x6f, + 0xe6, 0x6, 0xd5, 0x17, 0x80, 0x36, 0xd2, 0xcb, 0x38, 0x6b, 0xf6, 0x99, 0x72, 0xdc, 0xdd, 0xe5, + 0x33, 0xcc, 0x24, 0x65, 0x3c, 0xe5, 0x18, 0x0, 0x0, 0xe, 0x9d, 0x25, 0x37, 0x1f, 0x0, 0x11, + 0x15, 0x53, 0x30, 0xa8, 0xcd, 0xda, 0xbc, 0x5d, 0x85, 0xc5, 0xb, 0xb0, 0x10, 0xa7, 0x3a, 0xe8, + 0x3d, 0x1a, 0x0, 0x1b, 0x77, 0xb4, 0xad, 0x46, 0x45, 0x74, 0x92, 0x24, 0xb2, 0x7c, 0x60, 0xf8, + 0x97, 0x52, 0xfc, 0x71, 0x3e, 0x7, 0x93, 0xa9, 0x75, 0x91, 0x4a, 0x74, 0xda, 0x85, 0x3a, 0x3, + 0x0, 0x10, 0x3d, 0x75, 0xf6, 0xa1, 0x42, 0xe5, 0xa6, 0xf4, 0x2c, 0x25, 0x85, 0x5c, 0xde, 0xbb, + 0xd, 0xe1, 0x11, 0x0, 0x0, 0x51, 0x30, 0x1, 0x97, 0x8f, 0x1, 0xa2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 15416); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x97); + EXPECT_EQ(granted_qos_levels[2], 0x8F); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0xA2); +} + +// SubscribeResponse 24411 [Right QoS2,Left SubErrImplementationSpecificError,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse] +// [PropSessionExpiryInterval 1993] +TEST(SubACK5QCTest, Decode11) { + uint8_t pkt[] = {0x90, 0xd, 0x5f, 0x5b, 0x5, 0x11, 0x0, 0x0, 0x7, 0xc9, 0x2, 0x83, 0x9e, 0xa2, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 24411); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], 0x9E); + EXPECT_EQ(granted_qos_levels[3], 0xA2); + EXPECT_EQ(granted_qos_levels[4], 0x91); +} + +// SubscribeResponse 16797 [Right QoS0,Right QoS0,Right QoS1,Right QoS2,Left SubErrUnspecifiedError,Right QoS0,Right +// QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrNotAuthorized,Left +// SubErrSubscriptionIdentifiersNotSupported] [PropSubscriptionIdentifier 28,PropAssignedClientIdentifier +// "\157\160\131\&3o4[\141\&6`\138#\232\b\185\147\220A",PropRequestProblemInformation 41,PropResponseTopic +// "\191\&4\176\SO\193\176(\134L\195Y\236\240\172\154xUkI",PropResponseTopic +// "]\196\DLE{\172\245{u\166O\224T`\210\208zi\250",PropMaximumQoS 110,PropContentType +// "*2\191\163\148\SUB\182\231t\141\145\210\235\169\212:\\4\129Vl\RS\146<\155Sw\199\DC1",PropMessageExpiryInterval +// 20196,PropServerReference +// "e80\133\163\185\239\222\US\131\250c\ACK\131\184+E\193Q\196\NAK\166",PropSessionExpiryInterval +// 192,PropWildcardSubscriptionAvailable 89,PropRetainAvailable 70,PropServerKeepAlive 27803,PropReceiveMaximum +// 26170,PropPayloadFormatIndicator 240,PropSubscriptionIdentifier 7,PropReceiveMaximum 3282,PropServerKeepAlive +// 17130,PropMessageExpiryInterval 15690,PropReceiveMaximum 22602,PropMaximumPacketSize 28367,PropTopicAlias +// 20614,PropWillDelayInterval 4977,PropAuthenticationMethod +// "adv56\218\248\ETB\168\168\172\190m\189\SI\b\134;",PropResponseInformation +// "\\\201\144\152\218&\225Gz\145\135\131\145\190\152'\230"] +TEST(SubACK5QCTest, Decode12) { + uint8_t pkt[] = {0x90, 0xe9, 0x1, 0x41, 0x9d, 0xdb, 0x1, 0xb, 0x1c, 0x12, 0x0, 0x12, 0x9d, 0xa0, 0x83, 0x33, 0x6f, + 0x34, 0x5b, 0x8d, 0x36, 0x60, 0x8a, 0x23, 0xe8, 0x8, 0xb9, 0x93, 0xdc, 0x41, 0x17, 0x29, 0x8, 0x0, + 0x13, 0xbf, 0x34, 0xb0, 0xe, 0xc1, 0xb0, 0x28, 0x86, 0x4c, 0xc3, 0x59, 0xec, 0xf0, 0xac, 0x9a, 0x78, + 0x55, 0x6b, 0x49, 0x8, 0x0, 0x12, 0x5d, 0xc4, 0x10, 0x7b, 0xac, 0xf5, 0x7b, 0x75, 0xa6, 0x4f, 0xe0, + 0x54, 0x60, 0xd2, 0xd0, 0x7a, 0x69, 0xfa, 0x24, 0x6e, 0x3, 0x0, 0x1d, 0x2a, 0x32, 0xbf, 0xa3, 0x94, + 0x1a, 0xb6, 0xe7, 0x74, 0x8d, 0x91, 0xd2, 0xeb, 0xa9, 0xd4, 0x3a, 0x5c, 0x34, 0x81, 0x56, 0x6c, 0x1e, + 0x92, 0x3c, 0x9b, 0x53, 0x77, 0xc7, 0x11, 0x2, 0x0, 0x0, 0x4e, 0xe4, 0x1c, 0x0, 0x16, 0x65, 0x38, + 0x30, 0x85, 0xa3, 0xb9, 0xef, 0xde, 0x1f, 0x83, 0xfa, 0x63, 0x6, 0x83, 0xb8, 0x2b, 0x45, 0xc1, 0x51, + 0xc4, 0x15, 0xa6, 0x11, 0x0, 0x0, 0x0, 0xc0, 0x28, 0x59, 0x25, 0x46, 0x13, 0x6c, 0x9b, 0x21, 0x66, + 0x3a, 0x1, 0xf0, 0xb, 0x7, 0x21, 0xc, 0xd2, 0x13, 0x42, 0xea, 0x2, 0x0, 0x0, 0x3d, 0x4a, 0x21, + 0x58, 0x4a, 0x27, 0x0, 0x0, 0x6e, 0xcf, 0x23, 0x50, 0x86, 0x18, 0x0, 0x0, 0x13, 0x71, 0x15, 0x0, + 0x12, 0x61, 0x64, 0x76, 0x35, 0x36, 0xda, 0xf8, 0x17, 0xa8, 0xa8, 0xac, 0xbe, 0x6d, 0xbd, 0xf, 0x8, + 0x86, 0x3b, 0x1a, 0x0, 0x11, 0x5c, 0xc9, 0x90, 0x98, 0xda, 0x26, 0xe1, 0x47, 0x7a, 0x91, 0x87, 0x83, + 0x91, 0xbe, 0x98, 0x27, 0xe6, 0x0, 0x0, 0x1, 0x2, 0x80, 0x0, 0x0, 0x9e, 0x87, 0xa1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 16797); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x9E); + EXPECT_EQ(granted_qos_levels[8], 0x87); + EXPECT_EQ(granted_qos_levels[9], 0xA1); +} + +// SubscribeResponse 8011 [Right QoS0,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Left +// SubErrTopicFilterInvalid,Right QoS2] [PropWildcardSubscriptionAvailable 104,PropServerKeepAlive +// 27826,PropResponseTopic "\152\138\201\137\152\144\228\aI\CAN\193\146&2sX\a#\\L",PropMessageExpiryInterval +// 4121,PropTopicAliasMaximum 25788,PropSharedSubscriptionAvailable 229,PropTopicAliasMaximum 11111,PropUserProperty +// "\EM\170\205\SUB\162\&4\175u\231\174%}P+\ETB\190\&6m\200\GSK\161/@\255\&7" +// "\254\188D\186\GS\193z\241R\201\139@\200!\SOH\184\&5\191\228",PropAuthenticationData +// "\131oJHx6\173\DC1\180\US\146n2\220\237`\227\157r<\202\b\b\187\219F\172=\177",PropRequestResponseInformation 60] +TEST(SubACK5QCTest, Decode13) { + uint8_t pkt[] = {0x90, 0x86, 0x1, 0x1f, 0x4b, 0x7d, 0x28, 0x68, 0x13, 0x6c, 0xb2, 0x8, 0x0, 0x14, 0x98, 0x8a, + 0xc9, 0x89, 0x98, 0x90, 0xe4, 0x7, 0x49, 0x18, 0xc1, 0x92, 0x26, 0x32, 0x73, 0x58, 0x7, 0x23, + 0x5c, 0x4c, 0x2, 0x0, 0x0, 0x10, 0x19, 0x22, 0x64, 0xbc, 0x2a, 0xe5, 0x22, 0x2b, 0x67, 0x26, + 0x0, 0x1a, 0x19, 0xaa, 0xcd, 0x1a, 0xa2, 0x34, 0xaf, 0x75, 0xe7, 0xae, 0x25, 0x7d, 0x50, 0x2b, + 0x17, 0xbe, 0x36, 0x6d, 0xc8, 0x1d, 0x4b, 0xa1, 0x2f, 0x40, 0xff, 0x37, 0x0, 0x13, 0xfe, 0xbc, + 0x44, 0xba, 0x1d, 0xc1, 0x7a, 0xf1, 0x52, 0xc9, 0x8b, 0x40, 0xc8, 0x21, 0x1, 0xb8, 0x35, 0xbf, + 0xe4, 0x16, 0x0, 0x1d, 0x83, 0x6f, 0x4a, 0x48, 0x78, 0x36, 0xad, 0x11, 0xb4, 0x1f, 0x92, 0x6e, + 0x32, 0xdc, 0xed, 0x60, 0xe3, 0x9d, 0x72, 0x3c, 0xca, 0x8, 0x8, 0xbb, 0xdb, 0x46, 0xac, 0x3d, + 0xb1, 0x19, 0x3c, 0x0, 0x2, 0x2, 0x8f, 0x8f, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8011); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x8F); + EXPECT_EQ(granted_qos_levels[4], 0x8F); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); +} + +// SubscribeResponse 32745 [Right QoS0,Right QoS2,Right QoS1,Left SubErrNotAuthorized,Right QoS0,Right QoS2,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS2] [PropReceiveMaximum 16091,PropServerKeepAlive +// 6465,PropContentType "\192\215\&9m\STXl",PropPayloadFormatIndicator 155,PropCorrelationData +// "qr\253vwH\"T\138Pz*a\133\rJx\RS\183l\236\SO\187\210",PropMessageExpiryInterval 7888,PropResponseInformation +// "\SO\255\133",PropMaximumQoS 64,PropRequestProblemInformation 112,PropMaximumQoS 105,PropResponseInformation +// "\156My%\245\218|R\DC3y\132)\177y\208\230*\221S\201\214\SUB\182\153\156\215",PropWildcardSubscriptionAvailable +// 185,PropServerKeepAlive 28165,PropTopicAlias 32215,PropPayloadFormatIndicator 122,PropSubscriptionIdentifierAvailable +// 114,PropReasonString +// "\204t/\180D\188H(\225\194\162\tK\183\226\252\234\177\155\216\182\192\193t\236uY\209\EMl",PropMessageExpiryInterval +// 28202,PropRequestResponseInformation 201,PropWillDelayInterval 32683,PropUserProperty +// "\189a\159\209i\181\135AI\142\SI\192\DC3\RS" +// "\160\232I0\177\153\175\131\194\150\156\144\138\184\"&m\187",PropAuthenticationData +// "\142'\164\181\151\201T\199M\225",PropAssignedClientIdentifier +// "z\135u.9\ESC\236\152\230\SIla\135*5\DLEt\142\237\131>\140\214\a,\186}",PropServerKeepAlive +// 8604,PropMessageExpiryInterval 6304,PropSessionExpiryInterval 18034,PropResponseTopic +// "\225#\206\SYN6\168?s\142\196\129\176\194\238\206>\247\164."] +TEST(SubACK5QCTest, Decode14) { + uint8_t pkt[] = { + 0x90, 0x92, 0x2, 0x7f, 0xe9, 0x86, 0x2, 0x21, 0x3e, 0xdb, 0x13, 0x19, 0x41, 0x3, 0x0, 0x6, 0xc0, 0xd7, 0x39, + 0x6d, 0x2, 0x6c, 0x1, 0x9b, 0x9, 0x0, 0x18, 0x71, 0x72, 0xfd, 0x76, 0x77, 0x48, 0x22, 0x54, 0x8a, 0x50, 0x7a, + 0x2a, 0x61, 0x85, 0xd, 0x4a, 0x78, 0x1e, 0xb7, 0x6c, 0xec, 0xe, 0xbb, 0xd2, 0x2, 0x0, 0x0, 0x1e, 0xd0, 0x1a, + 0x0, 0x3, 0xe, 0xff, 0x85, 0x24, 0x40, 0x17, 0x70, 0x24, 0x69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0x16, 0x36, 0xa8, 0x3f, 0x73, 0x8e, 0xc4, 0x81, 0xb0, 0xc2, 0xee, 0xce, 0x3e, + 0xf7, 0xa4, 0x2e, 0x0, 0x2, 0x1, 0x87, 0x0, 0x2, 0xa2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 32745); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x87); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0xA2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); +} + +// SubscribeResponse 8548 [Right QoS1,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS0] [PropTopicAlias 17510,PropReasonString +// "\SUBz\136\SOH\175\232\242.\SOH?H\147\DEL\194\173r(",PropReceiveMaximum 13803,PropServerKeepAlive 3961,PropTopicAlias +// 14018,PropWillDelayInterval 26965,PropAuthenticationMethod +// "\212\203\150]\213w\NULg\128\STXx\255\180\158P\129Z\233",PropSharedSubscriptionAvailable +// 106,PropSharedSubscriptionAvailable 110,PropSubscriptionIdentifier 3,PropSessionExpiryInterval 26894,PropReasonString +// "=/\188D,L\242t\169c\175\197\228\SYN\153\233\208\217",PropAuthenticationData +// "}\NUL$\158\EM\169\183h2f\230\222\159\234\149Mw\221y\240",PropResponseTopic +// "\172\195E\187D\136f4W*\252\244'4\DC2",PropWildcardSubscriptionAvailable 241,PropSubscriptionIdentifierAvailable +// 71,PropMaximumPacketSize 22821] +TEST(SubACK5QCTest, Decode15) { + uint8_t pkt[] = {0x90, 0x95, 0x1, 0x21, 0x64, 0x8c, 0x1, 0x23, 0x44, 0x66, 0x1f, 0x0, 0x11, 0x1a, 0x7a, 0x88, 0x1, + 0xaf, 0xe8, 0xf2, 0x2e, 0x1, 0x3f, 0x48, 0x93, 0x7f, 0xc2, 0xad, 0x72, 0x28, 0x21, 0x35, 0xeb, 0x13, + 0xf, 0x79, 0x23, 0x36, 0xc2, 0x18, 0x0, 0x0, 0x69, 0x55, 0x15, 0x0, 0x12, 0xd4, 0xcb, 0x96, 0x5d, + 0xd5, 0x77, 0x0, 0x67, 0x80, 0x2, 0x78, 0xff, 0xb4, 0x9e, 0x50, 0x81, 0x5a, 0xe9, 0x2a, 0x6a, 0x2a, + 0x6e, 0xb, 0x3, 0x11, 0x0, 0x0, 0x69, 0xe, 0x1f, 0x0, 0x12, 0x3d, 0x2f, 0xbc, 0x44, 0x2c, 0x4c, + 0xf2, 0x74, 0xa9, 0x63, 0xaf, 0xc5, 0xe4, 0x16, 0x99, 0xe9, 0xd0, 0xd9, 0x16, 0x0, 0x14, 0x7d, 0x0, + 0x24, 0x9e, 0x19, 0xa9, 0xb7, 0x68, 0x32, 0x66, 0xe6, 0xde, 0x9f, 0xea, 0x95, 0x4d, 0x77, 0xdd, 0x79, + 0xf0, 0x8, 0x0, 0xf, 0xac, 0xc3, 0x45, 0xbb, 0x44, 0x88, 0x66, 0x34, 0x57, 0x2a, 0xfc, 0xf4, 0x27, + 0x34, 0x12, 0x28, 0xf1, 0x29, 0x47, 0x27, 0x0, 0x0, 0x59, 0x25, 0x1, 0x2, 0xa2, 0xa2, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8548); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0xA2); + EXPECT_EQ(granted_qos_levels[3], 0xA2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); +} + +// SubscribeResponse 12279 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left +// SubErrTopicFilterInvalid] [PropServerKeepAlive 32670,PropServerReference +// "\248|\170\178I\184\247*\DLE|\226\136\232?b\240",PropRetainAvailable 121] +TEST(SubACK5QCTest, Decode16) { + uint8_t pkt[] = {0x90, 0x1f, 0x2f, 0xf7, 0x18, 0x13, 0x7f, 0x9e, 0x1c, 0x0, 0x10, 0xf8, 0x7c, 0xaa, 0xb2, 0x49, 0xb8, + 0xf7, 0x2a, 0x10, 0x7c, 0xe2, 0x88, 0xe8, 0x3f, 0x62, 0xf0, 0x25, 0x79, 0x2, 0x9e, 0x1, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 12279); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x9E); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x8F); +} -// SubscribeResponse 12719 [Left SubErrNotAuthorized,Right QoS0] [] -TEST(SubACK311QCTest, Decode20) { -uint8_t pkt[] = {0x90, 0x4, 0x31, 0xaf, 0x87, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[2]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 2, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 12719); -EXPECT_EQ(count, 2); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); +// SubscribeResponse 8001 [Right QoS2,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS2,Left +// SubErrNotAuthorized,Left SubErrWildcardSubscriptionsNotSupported] [PropTopicAliasMaximum 3486,PropRetainAvailable +// 25,PropMessageExpiryInterval 11544] +TEST(SubACK5QCTest, Decode17) { + uint8_t pkt[] = {0x90, 0x14, 0x1f, 0x41, 0xa, 0x22, 0xd, 0x9e, 0x25, 0x19, 0x2, + 0x0, 0x0, 0x2d, 0x18, 0x2, 0x0, 0xa2, 0x2, 0x2, 0x87, 0xa2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8001); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0xA2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x87); + EXPECT_EQ(granted_qos_levels[6], 0xA2); +} + +// SubscribeResponse 4988 [Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrNotAuthorized,Left +// SubErrImplementationSpecificError,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS2] [PropRequestProblemInformation +// 33,PropRequestProblemInformation 126,PropMessageExpiryInterval 30345,PropMaximumPacketSize +// 17191,PropPayloadFormatIndicator 186,PropWillDelayInterval 18701,PropTopicAliasMaximum +// 21991,PropMessageExpiryInterval 10612,PropRequestResponseInformation 157,PropAuthenticationData +// "$\223u\CANl\200\208M\SO8C&\131\DEL\250\209\136\136\155Y\165\232\225",PropMessageExpiryInterval +// 6146,PropSubscriptionIdentifier 5,PropMessageExpiryInterval 4255,PropPayloadFormatIndicator 169,PropWillDelayInterval +// 3779,PropSubscriptionIdentifierAvailable 17,PropRequestProblemInformation 73,PropAuthenticationData +// "\240s\172C\193\204P\197\208\224\149p!\241\245\210f\148@",PropServerKeepAlive +// 30539,PropSubscriptionIdentifierAvailable 126,PropResponseInformation +// "\222\132B\SOH(\DC2\EM\251L\187b7|\177\232mv\136\136\&2\202\254"] +TEST(SubACK5QCTest, Decode18) { + uint8_t pkt[] = {0x90, 0x93, 0x1, 0x13, 0x7c, 0x84, 0x1, 0x17, 0x21, 0x17, 0x7e, 0x2, 0x0, 0x0, 0x76, 0x89, 0x27, + 0x0, 0x0, 0x43, 0x27, 0x1, 0xba, 0x18, 0x0, 0x0, 0x49, 0xd, 0x22, 0x55, 0xe7, 0x2, 0x0, 0x0, + 0x29, 0x74, 0x19, 0x9d, 0x16, 0x0, 0x17, 0x24, 0xdf, 0x75, 0x18, 0x6c, 0xc8, 0xd0, 0x4d, 0xe, 0x38, + 0x43, 0x26, 0x83, 0x7f, 0xfa, 0xd1, 0x88, 0x88, 0x9b, 0x59, 0xa5, 0xe8, 0xe1, 0x2, 0x0, 0x0, 0x18, + 0x2, 0xb, 0x5, 0x2, 0x0, 0x0, 0x10, 0x9f, 0x1, 0xa9, 0x18, 0x0, 0x0, 0xe, 0xc3, 0x29, 0x11, + 0x17, 0x49, 0x16, 0x0, 0x13, 0xf0, 0x73, 0xac, 0x43, 0xc1, 0xcc, 0x50, 0xc5, 0xd0, 0xe0, 0x95, 0x70, + 0x21, 0xf1, 0xf5, 0xd2, 0x66, 0x94, 0x40, 0x13, 0x77, 0x4b, 0x29, 0x7e, 0x1a, 0x0, 0x16, 0xde, 0x84, + 0x42, 0x1, 0x28, 0x12, 0x19, 0xfb, 0x4c, 0xbb, 0x62, 0x37, 0x7c, 0xb1, 0xe8, 0x6d, 0x76, 0x88, 0x88, + 0x32, 0xca, 0xfe, 0x8f, 0x0, 0x87, 0x83, 0xa2, 0x9e, 0x0, 0xa1, 0x9e, 0x1, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4988); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x8F); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x87); + EXPECT_EQ(granted_qos_levels[3], 0x83); + EXPECT_EQ(granted_qos_levels[4], 0xA2); + EXPECT_EQ(granted_qos_levels[5], 0x9E); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0xA1); + EXPECT_EQ(granted_qos_levels[8], 0x9E); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); +} + +// SubscribeResponse 6982 [Right QoS0,Left SubErrTopicFilterInvalid,Left SubErrQuotaExceeded,Left +// SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS2,Right QoS0,Right QoS1,Left SubErrTopicFilterInvalid,Left +// SubErrTopicFilterInvalid,Right QoS0] [PropReceiveMaximum 16887,PropUserProperty +// "\169\DC3\148_\DC3\191\137e\175\"\132\134n!q\210z\157\165y\214\217f\252D" +// "\233\212\209L\198A+\137\246\ETX",PropRequestResponseInformation 92,PropSubscriptionIdentifierAvailable +// 37,PropContentType "\238rR\162\236\b\202+\248\164\SUB`\246W\USD]QZ~\b\155L^r\200\253u-",PropMessageExpiryInterval +// 25037,PropTopicAlias 16205,PropMessageExpiryInterval 24486,PropServerKeepAlive 17359,PropAssignedClientIdentifier +// "\176\222\SI\248\250\"d~v\212\ETB\215",PropTopicAlias 9629,PropCorrelationData +// "6QV>\254\184\233P\DC2\199i\135\162?\160\CAN[,R/\158\ESC\187|Y\145`\fx",PropRetainAvailable 137] +TEST(SubACK5QCTest, Decode19) { + uint8_t pkt[] = {0x90, 0xa2, 0x1, 0x1b, 0x46, 0x93, 0x1, 0x21, 0x41, 0xf7, 0x26, 0x0, 0x19, 0xa9, 0x13, 0x94, 0x5f, + 0x13, 0xbf, 0x89, 0x65, 0xaf, 0x22, 0x84, 0x86, 0x6e, 0x21, 0x71, 0xd2, 0x7a, 0x9d, 0xa5, 0x79, 0xd6, + 0xd9, 0x66, 0xfc, 0x44, 0x0, 0xa, 0xe9, 0xd4, 0xd1, 0x4c, 0xc6, 0x41, 0x2b, 0x89, 0xf6, 0x3, 0x19, + 0x5c, 0x29, 0x25, 0x3, 0x0, 0x1d, 0xee, 0x72, 0x52, 0xa2, 0xec, 0x8, 0xca, 0x2b, 0xf8, 0xa4, 0x1a, + 0x60, 0xf6, 0x57, 0x1f, 0x44, 0x5d, 0x51, 0x5a, 0x7e, 0x8, 0x9b, 0x4c, 0x5e, 0x72, 0xc8, 0xfd, 0x75, + 0x2d, 0x2, 0x0, 0x0, 0x61, 0xcd, 0x23, 0x3f, 0x4d, 0x2, 0x0, 0x0, 0x5f, 0xa6, 0x13, 0x43, 0xcf, + 0x12, 0x0, 0xc, 0xb0, 0xde, 0xf, 0xf8, 0xfa, 0x22, 0x64, 0x7e, 0x76, 0xd4, 0x17, 0xd7, 0x23, 0x25, + 0x9d, 0x9, 0x0, 0x1d, 0x36, 0x51, 0x56, 0x3e, 0xfe, 0xb8, 0xe9, 0x50, 0x12, 0xc7, 0x69, 0x87, 0xa2, + 0x3f, 0xa0, 0x18, 0x5b, 0x2c, 0x52, 0x2f, 0x9e, 0x1b, 0xbb, 0x7c, 0x59, 0x91, 0x60, 0xc, 0x78, 0x25, + 0x89, 0x0, 0x8f, 0x97, 0x80, 0x87, 0x2, 0x0, 0x1, 0x8f, 0x8f, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 6982); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x8F); + EXPECT_EQ(granted_qos_levels[2], 0x97); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x87); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], 0x8F); + EXPECT_EQ(granted_qos_levels[9], 0x8F); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); +} + +// SubscribeResponse 25134 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrImplementationSpecificError,Right +// QoS2,Left SubErrNotAuthorized,Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrQuotaExceeded] [PropResponseInformation "!\ENQ\EM\212\211",PropSharedSubscriptionAvailable +// 125,PropSessionExpiryInterval 15656,PropRequestProblemInformation 3,PropRequestResponseInformation +// 24,PropRequestResponseInformation 18,PropWildcardSubscriptionAvailable 148,PropAuthenticationData +// "=\234\&7_\217\238V{\162\&8\186\"\221\201u",PropReasonString +// "\197\161\SI\DC1\143w\149\152\252UR\242(",PropSharedSubscriptionAvailable 137,PropReceiveMaximum +// 13195,PropUserProperty "\197\131\&0(" "\232\181\SYN\215*}\223gi'5I\179",PropSharedSubscriptionAvailable +// 238,PropTopicAlias 27840,PropAssignedClientIdentifier +// "\NULs\vk\NUL\167J\131\133\249\237wq\216b\149\218~\220\139&\203",PropAuthenticationData +// "\"'V0\133\\\247\245\240\196}\245\&9\DLEw\143\184",PropAuthenticationData "& \222\239xv\ESC",PropResponseTopic +// "\205\DEL\233\155Fs\145n\180\219=\196'G\175\SYN\237\214\237\149\163Z \221\176\174U\DC1Z",PropSessionExpiryInterval +// 23440,PropServerKeepAlive 21999,PropCorrelationData +// "\248S\212\178_\170\r\161\141\129Q\203\155S\205\161\189\146\154\185\151|\178\ACK\161\226\US\143\247",PropAuthenticationMethod +// "\145\174\162\172\151!0\243\201\193\168_",PropAuthenticationMethod "",PropSessionExpiryInterval +// 15746,PropMaximumPacketSize 19299,PropRequestProblemInformation 58,PropAuthenticationMethod "N{\229\254%\243r\130"] +TEST(SubACK5QCTest, Decode20) { + uint8_t pkt[] = { + 0x90, 0x8d, 0x2, 0x62, 0x2e, 0x81, 0x2, 0x1a, 0x0, 0x5, 0x21, 0x5, 0x19, 0xd4, 0xd3, 0x2a, 0x7d, 0x11, 0x0, + 0x0, 0x3d, 0x28, 0x17, 0x3, 0x19, 0x18, 0x19, 0x12, 0x28, 0x94, 0x16, 0x0, 0xf, 0x3d, 0xea, 0x37, 0x5f, 0xd9, + 0xee, 0x56, 0x7b, 0xa2, 0x38, 0xba, 0x22, 0xdd, 0xc9, 0x75, 0x1f, 0x0, 0xd, 0xc5, 0xa1, 0xf, 0x11, 0x8f, 0x77, + 0x95, 0x98, 0xfc, 0x55, 0x52, 0xf2, 0x28, 0x2a, 0x89, 0x21, 0x33, 0x8b, 0x26, 0x0, 0x4, 0xc5, 0x83, 0x30, 0x28, + 0x0, 0xd, 0xe8,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x83, + 0x2, 0x87, 0x0, 0x2, 0xa2, 0x97}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 25134); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x87); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0xA2); + EXPECT_EQ(granted_qos_levels[7], 0x97); +} + +// SubscribeResponse 25090 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrQuotaExceeded,Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Right QoS1,Left +// SubErrPacketIdentifierInUse] [PropSubscriptionIdentifier 11,PropContentType "\250xC",PropServerKeepAlive +// 21843,PropPayloadFormatIndicator 10,PropRetainAvailable 165,PropTopicAliasMaximum 1014,PropResponseTopic +// "\160\180-\251\252m\233,\254\229\203\253\160\157H\214\SUB$\SO\ESC\146\223+\v",PropReasonString +// "3\171;\133\ENQ\234,\176o\206\NULc\226\247\224\DC4\"\164r\189\212\229C\238M",PropResponseTopic +// "`\225\ESC'\137\184\184Voz\146\&8\201\ESC\237\167\209\177T;o",PropWildcardSubscriptionAvailable +// 255,PropReceiveMaximum 32182] +TEST(SubACK5QCTest, Decode21) { + uint8_t pkt[] = {0x90, 0x70, 0x62, 0x2, 0x66, 0xb, 0xb, 0x3, 0x0, 0x3, 0xfa, 0x78, 0x43, 0x13, 0x55, 0x53, 0x1, + 0xa, 0x25, 0xa5, 0x22, 0x3, 0xf6, 0x8, 0x0, 0x18, 0xa0, 0xb4, 0x2d, 0xfb, 0xfc, 0x6d, 0xe9, 0x2c, + 0xfe, 0xe5, 0xcb, 0xfd, 0xa0, 0x9d, 0x48, 0xd6, 0x1a, 0x24, 0xe, 0x1b, 0x92, 0xdf, 0x2b, 0xb, 0x1f, + 0x0, 0x19, 0x33, 0xab, 0x3b, 0x85, 0x5, 0xea, 0x2c, 0xb0, 0x6f, 0xce, 0x0, 0x63, 0xe2, 0xf7, 0xe0, + 0x14, 0x22, 0xa4, 0x72, 0xbd, 0xd4, 0xe5, 0x43, 0xee, 0x4d, 0x8, 0x0, 0x15, 0x60, 0xe1, 0x1b, 0x27, + 0x89, 0xb8, 0xb8, 0x56, 0x6f, 0x7a, 0x92, 0x38, 0xc9, 0x1b, 0xed, 0xa7, 0xd1, 0xb1, 0x54, 0x3b, 0x6f, + 0x28, 0xff, 0x21, 0x7d, 0xb6, 0x80, 0xa2, 0x97, 0x8f, 0x83, 0x1, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 25090); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(granted_qos_levels[2], 0x97); + EXPECT_EQ(granted_qos_levels[3], 0x8F); + EXPECT_EQ(granted_qos_levels[4], 0x83); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x91); +} + +// SubscribeResponse 270 [Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS0,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrUnspecifiedError] [PropResponseTopic +// "\v=\ENQlq\tV\148o\211h\ETBs\254\213e\224\STXU\f8\134\r\201\248\255\245\218\241",PropAuthenticationData +// "\162\153Q56\EOT+]KH\133Q\219\198\166`",PropAssignedClientIdentifier +// "=\141\218It\145\226W5\180\CAN\230\191\139!\184;\164p\174\236)",PropTopicAlias 11631,PropUserProperty +// "W\234O\236\DC21(|\143\145\201\NAKy\191+\159n\DC1\246\199\150\NAK\156\157\160eX" +// "\RS\"\STX\EM#\169\178",PropMaximumPacketSize 12863,PropMaximumPacketSize 17273,PropMessageExpiryInterval +// 13702,PropCorrelationData +// "\\\165\176o\176.\248\149\208\137\156[\DC2\148\GSR\255\237\187\n\138\254\182\133\242\"\FS\ETXP/",PropSubscriptionIdentifierAvailable +// 79,PropResponseTopic +// "Y\EM\215\231\193\236\\),b\202{\217>\137\186\162\166|\EOT\166!1O\175\SO\233q",PropRetainAvailable +// 207,PropMessageExpiryInterval 15018,PropAssignedClientIdentifier "S\171b\220|\217\146A",PropWillDelayInterval +// 18618,PropSubscriptionIdentifier 13] +TEST(SubACK5QCTest, Decode22) { + uint8_t pkt[] = { + 0x90, 0xee, 0x1, 0x1, 0xe, 0xe0, 0x1, 0x8, 0x0, 0x1d, 0xb, 0x3d, 0x5, 0x6c, 0x71, 0x9, 0x56, 0x94, 0x6f, + 0xd3, 0x68, 0x17, 0x73, 0xfe, 0xd5, 0x65, 0xe0, 0x2, 0x55, 0xc, 0x38, 0x86, 0xd, 0xc9, 0xf8, 0xff, 0xf5, 0xda, + 0xf1, 0x16, 0x0, 0x10, 0xa2, 0x99, 0x51, 0x35, 0x36, 0x4, 0x2b, 0x5d, 0x4b, 0x48, 0x85, 0x51, 0xdb, 0xc6, 0xa6, + 0x60, 0x12, 0x0, 0x16, 0x3d, 0x8d, 0xda, 0x49, 0x74, 0x91, 0xe2, 0x57, 0x35, 0xb4, 0x18, 0xe6, 0xbf, 0x8b, 0x21, + 0xb8, 0x3b, 0xa4, 0x70, 0xae, 0xec, 0x29, 0x23, 0x2d, 0x6f, 0x26, 0x0, 0x1b, 0x57, 0xea, 0x4f, 0xec, 0x12, 0x31, + 0x28, 0x7c, 0x8f, 0x91, 0xc9, 0x15, 0x79, 0xbf, 0x2b, 0x9f, 0x6e, 0x11, 0xf6, 0xc7, 0x96, 0x15, 0x9c, 0x9d, 0xa0, + 0x65, 0x58, 0x0, 0x7, 0x1e, 0x22, 0x2, 0x19, 0x23, 0xa9, 0xb2, 0x27, 0x0, 0x0, 0x32, 0x3f, 0x27, 0x0, 0x0, + 0x43, 0x79, 0x2, 0x0, 0x0, 0x35, 0x86, 0x9, 0x0, 0x1e, 0x5c, 0xa5, 0xb0, 0x6f, 0xb0, 0x2e, 0xf8, 0x95, 0xd0, + 0x89, 0x9c, 0x5b, 0x12, 0x94, 0x1d, 0x52, 0xff, 0xed, 0xbb, 0xa, 0x8a, 0xfe, 0xb6, 0x85, 0xf2, 0x22, 0x1c, 0x3, + 0x50, 0x2f, 0x29, 0x4f, 0x8, 0x0, 0x1c, 0x59, 0x19, 0xd7, 0xe7, 0xc1, 0xec, 0x5c, 0x29, 0x2c, 0x62, 0xca, 0x7b, + 0xd9, 0x3e, 0x89, 0xba, 0xa2, 0xa6, 0x7c, 0x4, 0xa6, 0x21, 0x31, 0x4f, 0xaf, 0xe, 0xe9, 0x71, 0x25, 0xcf, 0x2, + 0x0, 0x0, 0x3a, 0xaa, 0x12, 0x0, 0x8, 0x53, 0xab, 0x62, 0xdc, 0x7c, 0xd9, 0x92, 0x41, 0x18, 0x0, 0x0, 0x48, + 0xba, 0xb, 0xd, 0x91, 0x0, 0x0, 0xa2, 0x1, 0xa1, 0xa1, 0x0, 0xa1, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 270); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0xA2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0xA1); + EXPECT_EQ(granted_qos_levels[6], 0xA1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], 0xA1); + EXPECT_EQ(granted_qos_levels[9], 0x80); +} + +// SubscribeResponse 28717 [Right QoS0,Left SubErrQuotaExceeded,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrPacketIdentifierInUse,Right QoS2,Right QoS1,Right QoS2,Right QoS2] [PropCorrelationData +// "\195\&8A}\215\188\&14\EML\193/6C\202\200\147\SOH\155\238\156\175\164\128\180v",PropTopicAlias +// 3259,PropMessageExpiryInterval 12278,PropAuthenticationMethod "\198\DC1V",PropReceiveMaximum +// 20488,PropSubscriptionIdentifier 23,PropUserProperty "" +// "\ESC{.\227\245\\\207d\US\170!\132J\t\EM%\252\226\DC2\240\f\ENQ\r\193\177\205",PropServerKeepAlive +// 22539,PropSubscriptionIdentifier 21,PropSessionExpiryInterval 15138,PropAuthenticationMethod +// "=\133\&8",PropWildcardSubscriptionAvailable 111,PropMaximumQoS 85,PropUserProperty +// "\214S\221\179B\ACK\196J&^'7\180\199$t2" "",PropRequestProblemInformation 145,PropWillDelayInterval +// 3910,PropMaximumPacketSize 12153,PropReasonString "\165\230\187\169\207d +// \222\141\242_\SI|\v\178\GS^\147\b[\ESC\ETX\142\139)\176\170\176d",PropSubscriptionIdentifier 30,PropServerKeepAlive +// 5908,PropReasonString "z\137\181O\231\207\167",PropUserProperty "\225\160\198\252]\145\184\CAN\139\&6\188\161\&0\f" +// ";\221\250B\163Uqv\n?\211\233d1\224\247\170s=",PropMaximumPacketSize 2390] +TEST(SubACK5QCTest, Decode23) { + uint8_t pkt[] = {0x90, 0xeb, 0x1, 0x70, 0x2d, 0xdf, 0x1, 0x9, 0x0, 0x1a, 0xc3, 0x38, 0x41, 0x7d, 0xd7, 0xbc, 0x31, + 0x34, 0x19, 0x4c, 0xc1, 0x2f, 0x36, 0x43, 0xca, 0xc8, 0x93, 0x1, 0x9b, 0xee, 0x9c, 0xaf, 0xa4, 0x80, + 0xb4, 0x76, 0x23, 0xc, 0xbb, 0x2, 0x0, 0x0, 0x2f, 0xf6, 0x15, 0x0, 0x3, 0xc6, 0x11, 0x56, 0x21, + 0x50, 0x8, 0xb, 0x17, 0x26, 0x0, 0x0, 0x0, 0x1a, 0x1b, 0x7b, 0x2e, 0xe3, 0xf5, 0x5c, 0xcf, 0x64, + 0x1f, 0xaa, 0x21, 0x84, 0x4a, 0x9, 0x19, 0x25, 0xfc, 0xe2, 0x12, 0xf0, 0xc, 0x5, 0xd, 0xc1, 0xb1, + 0xcd, 0x13, 0x58, 0xb, 0xb, 0x15, 0x11, 0x0, 0x0, 0x3b, 0x22, 0x15, 0x0, 0x3, 0x3d, 0x85, 0x38, + 0x28, 0x6f, 0x24, 0x55, 0x26, 0x0, 0x11, 0xd6, 0x53, 0xdd, 0xb3, 0x42, 0x6, 0xc4, 0x4a, 0x26, 0x5e, + 0x27, 0x37, 0xb4, 0xc7, 0x24, 0x74, 0x32, 0x0, 0x0, 0x17, 0x91, 0x18, 0x0, 0x0, 0xf, 0x46, 0x27, + 0x0, 0x0, 0x2f, 0x79, 0x1f, 0x0, 0x1d, 0xa5, 0xe6, 0xbb, 0xa9, 0xcf, 0x64, 0x20, 0xde, 0x8d, 0xf2, + 0x5f, 0xf, 0x7c, 0xb, 0xb2, 0x1d, 0x5e, 0x93, 0x8, 0x5b, 0x1b, 0x3, 0x8e, 0x8b, 0x29, 0xb0, 0xaa, + 0xb0, 0x64, 0xb, 0x1e, 0x13, 0x17, 0x14, 0x1f, 0x0, 0x7, 0x7a, 0x89, 0xb5, 0x4f, 0xe7, 0xcf, 0xa7, + 0x26, 0x0, 0xe, 0xe1, 0xa0, 0xc6, 0xfc, 0x5d, 0x91, 0xb8, 0x18, 0x8b, 0x36, 0xbc, 0xa1, 0x30, 0xc, + 0x0, 0x13, 0x3b, 0xdd, 0xfa, 0x42, 0xa3, 0x55, 0x71, 0x76, 0xa, 0x3f, 0xd3, 0xe9, 0x64, 0x31, 0xe0, + 0xf7, 0xaa, 0x73, 0x3d, 0x27, 0x0, 0x0, 0x9, 0x56, 0x0, 0x97, 0xa2, 0x91, 0x2, 0x1, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 28717); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x97); + EXPECT_EQ(granted_qos_levels[2], 0xA2); + EXPECT_EQ(granted_qos_levels[3], 0x91); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); +} + +// SubscribeResponse 8736 [Right QoS1,Right QoS2,Left SubErrImplementationSpecificError,Right QoS2,Right QoS0,Right +// QoS1] [PropSharedSubscriptionAvailable 21,PropUserProperty "\192$&\227\ACKH\231o\186\200'vm\173" +// "\207?\228=\184\v\213\228\245T\163\194\FSG\162\192\202\180X\DLEg\138c\ACK\147\237\196\216\227",PropTopicAliasMaximum +// 12826] +TEST(SubACK5QCTest, Decode24) { + uint8_t pkt[] = {0x90, 0x3e, 0x22, 0x20, 0x35, 0x2a, 0x15, 0x26, 0x0, 0xe, 0xc0, 0x24, 0x26, 0xe3, 0x6, 0x48, + 0xe7, 0x6f, 0xba, 0xc8, 0x27, 0x76, 0x6d, 0xad, 0x0, 0x1d, 0xcf, 0x3f, 0xe4, 0x3d, 0xb8, 0xb, + 0xd5, 0xe4, 0xf5, 0x54, 0xa3, 0xc2, 0x1c, 0x47, 0xa2, 0xc0, 0xca, 0xb4, 0x58, 0x10, 0x67, 0x8a, + 0x63, 0x6, 0x93, 0xed, 0xc4, 0xd8, 0xe3, 0x22, 0x32, 0x1a, 0x1, 0x2, 0x83, 0x2, 0x0, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8736); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x83); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); +} + +// SubscribeResponse 27132 [Left SubErrWildcardSubscriptionsNotSupported,Left SubErrImplementationSpecificError,Right +// QoS0] [PropSessionExpiryInterval 29768,PropContentType "\DC3",PropRetainAvailable 129,PropWillDelayInterval +// 3417,PropSessionExpiryInterval 11868,PropSessionExpiryInterval 9277,PropRequestResponseInformation +// 147,PropServerKeepAlive 6086,PropAuthenticationData "l\215\STX\207\138\153\197\133T\STX\232\229{ +// \141\147",PropAuthenticationMethod "i\203\193$\146\&0T\129uH\204",PropAuthenticationData +// "&E@\143wF\199\136\NULNS\185\175\225\149\155{\203W\241;\192\134\a",PropAssignedClientIdentifier +// "\185\139\185\139\246\242\153\196PJD\"\231\ESC\165A\250\176t\r\154J\213\239\"\195",PropServerKeepAlive +// 10472,PropReasonString "\186\182\239R\141\163/\EOT\163\196\173",PropRequestResponseInformation 159] +TEST(SubACK5QCTest, Decode25) { + uint8_t pkt[] = {0x90, 0x92, 0x1, 0x69, 0xfc, 0x8b, 0x1, 0x11, 0x0, 0x0, 0x74, 0x48, 0x3, 0x0, 0x1, 0x13, 0x25, + 0x81, 0x18, 0x0, 0x0, 0xd, 0x59, 0x11, 0x0, 0x0, 0x2e, 0x5c, 0x11, 0x0, 0x0, 0x24, 0x3d, 0x19, + 0x93, 0x13, 0x17, 0xc6, 0x16, 0x0, 0x10, 0x6c, 0xd7, 0x2, 0xcf, 0x8a, 0x99, 0xc5, 0x85, 0x54, 0x2, + 0xe8, 0xe5, 0x7b, 0x20, 0x8d, 0x93, 0x15, 0x0, 0xb, 0x69, 0xcb, 0xc1, 0x24, 0x92, 0x30, 0x54, 0x81, + 0x75, 0x48, 0xcc, 0x16, 0x0, 0x18, 0x26, 0x45, 0x40, 0x8f, 0x77, 0x46, 0xc7, 0x88, 0x0, 0x4e, 0x53, + 0xb9, 0xaf, 0xe1, 0x95, 0x9b, 0x7b, 0xcb, 0x57, 0xf1, 0x3b, 0xc0, 0x86, 0x7, 0x12, 0x0, 0x1a, 0xb9, + 0x8b, 0xb9, 0x8b, 0xf6, 0xf2, 0x99, 0xc4, 0x50, 0x4a, 0x44, 0x22, 0xe7, 0x1b, 0xa5, 0x41, 0xfa, 0xb0, + 0x74, 0xd, 0x9a, 0x4a, 0xd5, 0xef, 0x22, 0xc3, 0x13, 0x28, 0xe8, 0x1f, 0x0, 0xb, 0xba, 0xb6, 0xef, + 0x52, 0x8d, 0xa3, 0x2f, 0x4, 0xa3, 0xc4, 0xad, 0x19, 0x9f, 0xa2, 0x83, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 27132); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0xA2); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); +} + +// SubscribeResponse 20260 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS1,Right QoS1] +// [PropReceiveMaximum 25039,PropReasonString "6\174\ETX\RSBM\175\b\181\DC2+\246s",PropReceiveMaximum +// 32590,PropServerReference "\138z\187#\202\153\152",PropMaximumQoS 67,PropUserProperty +// "\160e\GS\161\144l\147g\r\174S\183\170\156\149tCm\203\248,\FS\232d\146" +// "\176\203EE\224\239\158j\166\SOHz\215MF\157\ETB\138DI\137\ACK\150\215\&0\141",PropAuthenticationData +// "$\192eZb\135Z$\161",PropSubscriptionIdentifier 7,PropPayloadFormatIndicator 117,PropReceiveMaximum +// 9335,PropSubscriptionIdentifierAvailable 163,PropSharedSubscriptionAvailable 107,PropSharedSubscriptionAvailable +// 141,PropTopicAlias 4296,PropMessageExpiryInterval 13428,PropMaximumPacketSize 15215,PropRetainAvailable +// 197,PropMessageExpiryInterval 12485,PropReceiveMaximum 11017,PropContentType +// "j\180\182\200\188Ul",PropCorrelationData "\\UP\243\172\NUL\f/z\186X\134\236\227R\192",PropUserProperty +// "\213\v\152\ESCBm\133\218C\r\130\194!{" +// "\129$F\179s0y\201\&2\180\143K\197|c\151\160F",PropWildcardSubscriptionAvailable 114,PropSharedSubscriptionAvailable +// 218,PropWillDelayInterval 4879,PropRequestResponseInformation 147,PropTopicAliasMaximum +// 13826,PropSubscriptionIdentifierAvailable 180,PropMessageExpiryInterval 18818,PropMaximumPacketSize 4173] +TEST(SubACK5QCTest, Decode26) { + uint8_t pkt[] = { + 0x90, 0xef, 0x1,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 0x12, 0x81, 0x24, 0x46, 0xb3, 0x73, 0x30, 0x79, 0xc9, 0x32, 0xb4, 0x8f, 0x4b, 0xc5, 0x7c, 0x63, 0x97, 0xa0, + 0x46, 0x28, 0x72, 0x2a, 0xda, 0x18, 0x0, 0x0, 0x13, 0xf, 0x19, 0x93, 0x22, 0x36, 0x2, 0x29, 0xb4, 0x2, 0x0, + 0x0, 0x49, 0x82, 0x27, 0x0, 0x0, 0x10, 0x4d, 0x2, 0x91, 0x0, 0x2, 0x1, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 20260); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x91); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); +} + +// SubscribeResponse 471 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS0,Left +// SubErrNotAuthorized,Right QoS2,Left SubErrImplementationSpecificError,Right QoS1,Right QoS1] +// [PropMessageExpiryInterval 13269,PropMaximumPacketSize 22041,PropRetainAvailable +// 121,PropSubscriptionIdentifierAvailable 209] +TEST(SubACK5QCTest, Decode27) { + uint8_t pkt[] = {0x90, 0x19, 0x1, 0xd7, 0xe, 0x2, 0x0, 0x0, 0x33, 0xd5, 0x27, 0x0, 0x0, 0x56, + 0x19, 0x25, 0x79, 0x29, 0xd1, 0x9e, 0x0, 0x0, 0x87, 0x2, 0x83, 0x1, 0x1}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 471); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x87); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x83); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); +} + +// SubscribeResponse 21021 [Right QoS1,Right QoS2,Right QoS2,Right QoS2] [PropResponseInformation +// "\143\239n\n\SI\203\220\154\130\175\181}\226\144\150\159\&3\142",PropMessageExpiryInterval +// 25828,PropSubscriptionIdentifierAvailable 184,PropCorrelationData +// "~\NUL\236\190|6\221",PropWildcardSubscriptionAvailable 212,PropMessageExpiryInterval 21937,PropSessionExpiryInterval +// 22211,PropSubscriptionIdentifierAvailable 173,PropMessageExpiryInterval 16452,PropSharedSubscriptionAvailable 169] +TEST(SubACK5QCTest, Decode28) { + uint8_t pkt[] = {0x90, 0x42, 0x52, 0x1d, 0x3b, 0x1a, 0x0, 0x12, 0x8f, 0xef, 0x6e, 0xa, 0xf, 0xcb, 0xdc, 0x9a, 0x82, + 0xaf, 0xb5, 0x7d, 0xe2, 0x90, 0x96, 0x9f, 0x33, 0x8e, 0x2, 0x0, 0x0, 0x64, 0xe4, 0x29, 0xb8, 0x9, + 0x0, 0x7, 0x7e, 0x0, 0xec, 0xbe, 0x7c, 0x36, 0xdd, 0x28, 0xd4, 0x2, 0x0, 0x0, 0x55, 0xb1, 0x11, + 0x0, 0x0, 0x56, 0xc3, 0x29, 0xad, 0x2, 0x0, 0x0, 0x40, 0x44, 0x2a, 0xa9, 0x1, 0x2, 0x2, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 21021); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +} + +// SubscribeResponse 3050 [Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrUnspecifiedError,Left +// SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left SubErrSharedSubscriptionsNotSupported,Right QoS0] +// [PropAuthenticationMethod "\248nv\143\249\166Q\244",PropAuthenticationMethod +// "\218\144)X\160\204Y;\135\SOH\244\200Y\229\245\237;O\210]!\163\139\145\164\222`=j",PropServerReference +// "\165\235\NAK\235\158\192\176\219\145\145\162\SIr\201\131\DEL\131\135\233\148\v\208VG\185\154b\178",PropMessageExpiryInterval +// 16134,PropMaximumQoS 206,PropTopicAliasMaximum 20322,PropReasonString " +// g\129\182B\173\177\254\r\ACK\186\&6\245\210\165\FS,\248]|",PropAuthenticationData +// ".\158\179\181\DC4.A\210O\128g\219i\196\v)\152",PropMaximumQoS 50,PropResponseInformation +// "p\210\143?0\144\DEL\SOH\131\178!\252\&5Z\ACK7\DC4=,\141B\v\181\243$\177K>\DC1\193",PropRequestProblemInformation +// 217,PropAssignedClientIdentifier "\DC3\178\140\230y\196\235:-\173\157l\173\188",PropMaximumPacketSize +// 8704,PropWildcardSubscriptionAvailable 198,PropResponseTopic +// "\EOTOk\147\211\SOH\203\162#\159)\178\209q\"\137",PropPayloadFormatIndicator 29,PropServerReference +// "\169\247",PropServerKeepAlive 7468,PropTopicAlias 13534,PropSharedSubscriptionAvailable +// 117,PropSubscriptionIdentifier 30,PropCorrelationData "nNt\203\206Q\178\r\185\EOT",PropMaximumQoS +// 95,PropWildcardSubscriptionAvailable 131,PropRetainAvailable 113,PropUserProperty "\145<\n\SUB\137\242\&5Z\204" +// "\SUB2\217j\136\175\145\128\230\202\ACK\134\255\144\v\224\159\193~\192\204i\150=;!s\255",PropTopicAliasMaximum 4299] +TEST(SubACK5QCTest, Decode29) { + uint8_t pkt[] = { + 0x90, 0xab, 0x2, 0xb, 0xea, 0xa0, 0x2, 0x15, 0x0, 0x8, 0xf8, 0x6e, 0x76, 0x8f, 0xf9, 0xa6, 0x51, 0xf4, 0x15, + 0x0, 0x1d, 0xda, 0x90, 0x29, 0x58, 0xa0, 0xcc, 0x59, 0x3b, 0x87, 0x1, 0xf4, 0xc8, 0x59, 0xe5, 0xf5, 0xed, 0x3b, + 0x4f, 0xd2, 0x5d, 0x21, 0xa3, 0x8b, 0x91, 0xa4, 0xde, 0x60, 0x3d, 0x6a, 0x1c, 0x0, 0x1c, 0xa5, 0xeb, 0x15, 0xeb, + 0x9e, 0xc0, 0xb0, 0xdb, 0x91, 0x91, 0xa2, 0xf, 0x72, 0xc9, 0x83, 0x7f, 0x83, 0x87, 0xe9, 0x94, 0xb, 0xd0, 0x56, + 0x47, 0xb9, 0x9a, 0x62, 0xb2, 0x2, 0x0, 0x0, 0x3f, 0x6, 0x24, 0xce, 0x22, 0x4f, 0x62, 0x1f, 0x0, 0x14, 0x20, + 0x67, 0x81, 0xb6, 0x42, 0xad, 0xb1, 0xfe, 0xd, 0x6, 0xba, 0x36, 0xf5, 0xd2, 0xa5, 0x1c, 0x2c, 0xf8, 0x5d, 0x7c, + 0x16, 0x0, 0x11, 0x2e, 0x9e, 0xb3, 0xb5, 0x14, 0x2e, 0x41, 0xd2, 0x4f, 0x80, 0x67, 0xdb, 0x69, 0xc4, 0xb, 0x29, + 0x98, 0x24, 0x32, 0x1a, 0x0, 0x1e, 0x70, 0xd2, 0x8f, 0x3f, 0x30, 0x90, 0x7f, 0x1, 0x83, 0xb2, 0x21, 0xfc, 0x35, + 0x5a, 0x6, 0x37, 0x14, 0x3d, 0x2c, 0x8d, 0x42, 0xb, 0xb5, 0xf3, 0x24, 0xb1, 0x4b, 0x3e, 0x11, 0xc1, 0x17, 0xd9, + 0x12, 0x0, 0xe, 0x13, 0xb2, 0x8c, 0xe6, 0x79, 0xc4, 0xeb, 0x3a, 0x2d, 0xad, 0x9d, 0x6c, 0xad, 0xbc, 0x27, 0x0, + 0x0, 0x22, 0x0, 0x28, 0xc6, 0x8, 0x0, 0x10, 0x4, 0x4f, 0x6b, 0x93, 0xd3, 0x1, 0xcb, 0xa2, 0x23, 0x9f, 0x29, + 0xb2, 0xd1, 0x71, 0x22, 0x89, 0x1, 0x1d, 0x1c, 0x0, 0x2, 0xa9, 0xf7, 0x13, 0x1d, 0x2c, 0x23, 0x34, 0xde, 0x2a, + 0x75, 0xb, 0x1e, 0x9, 0x0, 0xa, 0x6e, 0x4e, 0x74, 0xcb, 0xce, 0x51, 0xb2, 0xd, 0xb9, 0x4, 0x24, 0x5f, 0x28, + 0x83, 0x25, 0x71, 0x26, 0x0, 0x9, 0x91, 0x3c, 0xa, 0x1a, 0x89, 0xf2, 0x35, 0x5a, 0xcc, 0x0, 0x1c, 0x1a, 0x32, + 0xd9, 0x6a, 0x88, 0xaf, 0x91, 0x80, 0xe6, 0xca, 0x6, 0x86, 0xff, 0x90, 0xb, 0xe0, 0x9f, 0xc1, 0x7e, 0xc0, 0xcc, + 0x69, 0x96, 0x3d, 0x3b, 0x21, 0x73, 0xff, 0x22, 0x10, 0xcb, 0x2, 0x91, 0x80, 0x80, 0x91, 0x9e, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 3050); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x91); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x91); + EXPECT_EQ(granted_qos_levels[5], 0x9E); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); +} + +// SubscribeResponse 9426 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrTopicFilterInvalid,Right QoS0,Right QoS2] [PropSubscriptionIdentifierAvailable 177,PropContentType +// "\253'\175\175\255\138\n\233w\GS\179\DLE\RS,\fOUS\143\226\178K\184%/(",PropSharedSubscriptionAvailable +// 16,PropRequestProblemInformation 63,PropPayloadFormatIndicator 39,PropWildcardSubscriptionAvailable +// 52,PropAuthenticationMethod "\136\176",PropResponseInformation +// "\155A\235\220\214\129\250\203Q\199\245\228\187\220\132\222]-\171XQ",PropSubscriptionIdentifier +// 20,PropPayloadFormatIndicator 214,PropMessageExpiryInterval 31640,PropSubscriptionIdentifierAvailable +// 186,PropRequestResponseInformation 66,PropAuthenticationMethod "}\fV\211\231x\132",PropContentType +// ",\161\201I\197\180\SI$\252k\254P2\185U\180\212\204\196\138\DC2\152\183\206\194\145\193\255P",PropWillDelayInterval +// 6080,PropServerReference "x\132\SOH\215Z\156\160,#\DC3z\174q\198z\239-\220\155"] +TEST(SubACK5QCTest, Decode30) { + uint8_t pkt[] = {0x90, 0xa5, 0x1, 0x24, 0xd2, 0x96, 0x1, 0x29, 0xb1, 0x3, 0x0, 0x1a, 0xfd, 0x27, 0xaf, 0xaf, 0xff, + 0x8a, 0xa, 0xe9, 0x77, 0x1d, 0xb3, 0x10, 0x1e, 0x2c, 0xc, 0x4f, 0x55, 0x53, 0x8f, 0xe2, 0xb2, 0x4b, + 0xb8, 0x25, 0x2f, 0x28, 0x2a, 0x10, 0x17, 0x3f, 0x1, 0x27, 0x28, 0x34, 0x15, 0x0, 0x2, 0x88, 0xb0, + 0x1a, 0x0, 0x15, 0x9b, 0x41, 0xeb, 0xdc, 0xd6, 0x81, 0xfa, 0xcb, 0x51, 0xc7, 0xf5, 0xe4, 0xbb, 0xdc, + 0x84, 0xde, 0x5d, 0x2d, 0xab, 0x58, 0x51, 0xb, 0x14, 0x1, 0xd6, 0x2, 0x0, 0x0, 0x7b, 0x98, 0x29, + 0xba, 0x19, 0x42, 0x15, 0x0, 0x7, 0x7d, 0xc, 0x56, 0xd3, 0xe7, 0x78, 0x84, 0x3, 0x0, 0x1d, 0x2c, + 0xa1, 0xc9, 0x49, 0xc5, 0xb4, 0xf, 0x24, 0xfc, 0x6b, 0xfe, 0x50, 0x32, 0xb9, 0x55, 0xb4, 0xd4, 0xcc, + 0xc4, 0x8a, 0x12, 0x98, 0xb7, 0xce, 0xc2, 0x91, 0xc1, 0xff, 0x50, 0x18, 0x0, 0x0, 0x17, 0xc0, 0x1c, + 0x0, 0x13, 0x78, 0x84, 0x1, 0xd7, 0x5a, 0x9c, 0xa0, 0x2c, 0x23, 0x13, 0x7a, 0xae, 0x71, 0xc6, 0x7a, + 0xef, 0x2d, 0xdc, 0x9b, 0x80, 0xa2, 0xa2, 0x1, 0x1, 0x83, 0xa2, 0x9e, 0x8f, 0x0, 0x2}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 9426); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(granted_qos_levels[2], 0xA2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x83); + EXPECT_EQ(granted_qos_levels[6], 0xA2); + EXPECT_EQ(granted_qos_levels[7], 0x9E); + EXPECT_EQ(granted_qos_levels[8], 0x8F); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); +} + +// UnsubscribeRequest 17193 +// ["\201\232\214-\249\178\243\205$\220\150\232<\145\247","\167\SOH\185\173{\128\&73b\161rO\230\187\148\214\163\169\130\195\177\233\159l\249","K\ENQ\f\ACK\152\223","\169\DC1\140\210\EMO\172%;\SI\DLE\128\170U\SI\180\&7g\221\229 +// ","\255/n\"\EOT\\P\199\f\DEL\254\EMgh\179\206\243>"] [] +TEST(Unsubscribe311QCTest, Encode1) { + uint8_t pkt[] = {0xa2, 0x61, 0x43, 0x29, 0x0, 0xf, 0xc9, 0xe8, 0xd6, 0x2d, 0xf9, 0xb2, 0xf3, 0xcd, 0x24, 0xdc, 0x96, + 0xe8, 0x3c, 0x91, 0xf7, 0x0, 0x19, 0xa7, 0x1, 0xb9, 0xad, 0x7b, 0x80, 0x37, 0x33, 0x62, 0xa1, 0x72, + 0x4f, 0xe6, 0xbb, 0x94, 0xd6, 0xa3, 0xa9, 0x82, 0xc3, 0xb1, 0xe9, 0x9f, 0x6c, 0xf9, 0x0, 0x6, 0x4b, + 0x5, 0xc, 0x6, 0x98, 0xdf, 0x0, 0x15, 0xa9, 0x11, 0x8c, 0xd2, 0x19, 0x4f, 0xac, 0x25, 0x3b, 0xf, + 0x10, 0x80, 0xaa, 0x55, 0xf, 0xb4, 0x37, 0x67, 0xdd, 0xe5, 0x20, 0x0, 0x12, 0xff, 0x2f, 0x6e, 0x22, + 0x4, 0x5c, 0x50, 0xc7, 0xc, 0x7f, 0xfe, 0x19, 0x67, 0x68, 0xb3, 0xce, 0xf3, 0x3e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xc9, 0xe8, 0xd6, 0x2d, 0xf9, 0xb2, 0xf3, 0xcd, + 0x24, 0xdc, 0x96, 0xe8, 0x3c, 0x91, 0xf7}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa7, 0x1, 0xb9, 0xad, 0x7b, 0x80, 0x37, 0x33, 0x62, 0xa1, 0x72, 0x4f, 0xe6, + 0xbb, 0x94, 0xd6, 0xa3, 0xa9, 0x82, 0xc3, 0xb1, 0xe9, 0x9f, 0x6c, 0xf9}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4b, 0x5, 0xc, 0x6, 0x98, 0xdf}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa9, 0x11, 0x8c, 0xd2, 0x19, 0x4f, 0xac, 0x25, 0x3b, 0xf, 0x10, + 0x80, 0xaa, 0x55, 0xf, 0xb4, 0x37, 0x67, 0xdd, 0xe5, 0x20}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xff, 0x2f, 0x6e, 0x22, 0x4, 0x5c, 0x50, 0xc7, 0xc, + 0x7f, 0xfe, 0x19, 0x67, 0x68, 0xb3, 0xce, 0xf3, 0x3e}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17193, 5, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 26830 +// ["\218+\CAN,\224\168w\RSA\238#\r\212'\236M7g\185\213H9V\247)","-\222\193hv\157\140\193\135\212\152\212","\DEL\rs\210\"\178\STX\ENQ\226\231\ETX\247)\157c\218\174","\243eC +// v|F\170\188e\246w\177:\197J\219\212\184i\139\EOT\207\187\177\228\192\150?\134","\159\157\FS\135\152\130u\DC4\194","\151O\204\&1\251\ACK","46\222nn\188#\191\208{\DC4\208\217\195"] +// [] +TEST(Unsubscribe311QCTest, Encode2) { + uint8_t pkt[] = {0xa2, 0x81, 0x1, 0x68, 0xce, 0x0, 0x19, 0xda, 0x2b, 0x18, 0x2c, 0xe0, 0xa8, 0x77, 0x1e, 0x41, 0xee, + 0x23, 0xd, 0xd4, 0x27, 0xec, 0x4d, 0x37, 0x67, 0xb9, 0xd5, 0x48, 0x39, 0x56, 0xf7, 0x29, 0x0, 0xc, + 0x2d, 0xde, 0xc1, 0x68, 0x76, 0x9d, 0x8c, 0xc1, 0x87, 0xd4, 0x98, 0xd4, 0x0, 0x11, 0x7f, 0xd, 0x73, + 0xd2, 0x22, 0xb2, 0x2, 0x5, 0xe2, 0xe7, 0x3, 0xf7, 0x29, 0x9d, 0x63, 0xda, 0xae, 0x0, 0x1e, 0xf3, + 0x65, 0x43, 0x20, 0x76, 0x7c, 0x46, 0xaa, 0xbc, 0x65, 0xf6, 0x77, 0xb1, 0x3a, 0xc5, 0x4a, 0xdb, 0xd4, + 0xb8, 0x69, 0x8b, 0x4, 0xcf, 0xbb, 0xb1, 0xe4, 0xc0, 0x96, 0x3f, 0x86, 0x0, 0x9, 0x9f, 0x9d, 0x1c, + 0x87, 0x98, 0x82, 0x75, 0x14, 0xc2, 0x0, 0x6, 0x97, 0x4f, 0xcc, 0x31, 0xfb, 0x6, 0x0, 0xe, 0x34, + 0x36, 0xde, 0x6e, 0x6e, 0xbc, 0x23, 0xbf, 0xd0, 0x7b, 0x14, 0xd0, 0xd9, 0xc3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 18524 [Right QoS2] [] -TEST(SubACK311QCTest, Decode21) { -uint8_t pkt[] = {0x90, 0x3, 0x48, 0x5c, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 18524); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xda, 0x2b, 0x18, 0x2c, 0xe0, 0xa8, 0x77, 0x1e, 0x41, 0xee, 0x23, 0xd, 0xd4, + 0x27, 0xec, 0x4d, 0x37, 0x67, 0xb9, 0xd5, 0x48, 0x39, 0x56, 0xf7, 0x29}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2d, 0xde, 0xc1, 0x68, 0x76, 0x9d, 0x8c, 0xc1, 0x87, 0xd4, 0x98, 0xd4}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x7f, 0xd, 0x73, 0xd2, 0x22, 0xb2, 0x2, 0x5, 0xe2, + 0xe7, 0x3, 0xf7, 0x29, 0x9d, 0x63, 0xda, 0xae}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf3, 0x65, 0x43, 0x20, 0x76, 0x7c, 0x46, 0xaa, 0xbc, 0x65, + 0xf6, 0x77, 0xb1, 0x3a, 0xc5, 0x4a, 0xdb, 0xd4, 0xb8, 0x69, + 0x8b, 0x4, 0xcf, 0xbb, 0xb1, 0xe4, 0xc0, 0x96, 0x3f, 0x86}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9f, 0x9d, 0x1c, 0x87, 0x98, 0x82, 0x75, 0x14, 0xc2}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x97, 0x4f, 0xcc, 0x31, 0xfb, 0x6}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x34, 0x36, 0xde, 0x6e, 0x6e, 0xbc, 0x23, + 0xbf, 0xd0, 0x7b, 0x14, 0xd0, 0xd9, 0xc3}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26830, 7, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 23824 ["\226W\ETX\192;\167?\SO \145"] [] +TEST(Unsubscribe311QCTest, Encode3) { + uint8_t pkt[] = {0xa2, 0xe, 0x5d, 0x10, 0x0, 0xa, 0xe2, 0x57, 0x3, 0xc0, 0x3b, 0xa7, 0x3f, 0xe, 0x20, 0x91}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 12697 [Left SubErrPacketIdentifierInUse,Left SubErrPacketIdentifierInUse,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrNotAuthorized] [] -TEST(SubACK311QCTest, Decode22) { -uint8_t pkt[] = {0x90, 0x8, 0x31, 0x99, 0x91, 0x91, 0xa2, 0x9e, 0xa1, 0x87}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 12697); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], 0x80); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], 0x80); -EXPECT_EQ(granted_qos_levels[4], 0x80); -EXPECT_EQ(granted_qos_levels[5], 0x80); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xe2, 0x57, 0x3, 0xc0, 0x3b, 0xa7, 0x3f, 0xe, 0x20, 0x91}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23824, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 20314 +// ["\247$\SOcz\155#\129\206\189\129\151\230\250[\179\254\214=v\GS\230\237\227\174\157\ETB\ESC\189"] [] +TEST(Unsubscribe311QCTest, Encode4) { + uint8_t pkt[] = {0xa2, 0x21, 0x4f, 0x5a, 0x0, 0x1d, 0xf7, 0x24, 0xe, 0x63, 0x7a, 0x9b, + 0x23, 0x81, 0xce, 0xbd, 0x81, 0x97, 0xe6, 0xfa, 0x5b, 0xb3, 0xfe, 0xd6, + 0x3d, 0x76, 0x1d, 0xe6, 0xed, 0xe3, 0xae, 0x9d, 0x17, 0x1b, 0xbd}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 1694 [Left SubErrSubscriptionIdentifiersNotSupported] [] -TEST(SubACK311QCTest, Decode23) { -uint8_t pkt[] = {0x90, 0x3, 0x6, 0x9e, 0xa1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 1694); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], 0x80); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xf7, 0x24, 0xe, 0x63, 0x7a, 0x9b, 0x23, 0x81, 0xce, 0xbd, + 0x81, 0x97, 0xe6, 0xfa, 0x5b, 0xb3, 0xfe, 0xd6, 0x3d, 0x76, + 0x1d, 0xe6, 0xed, 0xe3, 0xae, 0x9d, 0x17, 0x1b, 0xbd}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20314, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 29664 +// ["\214i\176\156X)\134(\251ux\210\240\DC1\SUB\200\219\EM\219l\213\170B","=\197\235\163\&1\EM\ENQ\255\181\143\201\171vu_o","6\134~W\204","7\223'\b\224\232u","\166v\184[x","z\n\135.Z\170\&9\208\249\231|\132",":1\229C\168\137","7\181\161\220\150\219:\219\171i\226u\150\195`\169","\223\233\205\n\174\ETB\193\ETB\v\255\&0\137u\158\136D\201\&1","\EMX\246C\131J +// \242>:\SOH\164"] [] +TEST(Unsubscribe311QCTest, Encode5) { + uint8_t pkt[] = {0xa2, 0x8e, 0x1, 0x73, 0xe0, 0x0, 0x17, 0xd6, 0x69, 0xb0, 0x9c, 0x58, 0x29, 0x86, 0x28, 0xfb, 0x75, + 0x78, 0xd2, 0xf0, 0x11, 0x1a, 0xc8, 0xdb, 0x19, 0xdb, 0x6c, 0xd5, 0xaa, 0x42, 0x0, 0x10, 0x3d, 0xc5, + 0xeb, 0xa3, 0x31, 0x19, 0x5, 0xff, 0xb5, 0x8f, 0xc9, 0xab, 0x76, 0x75, 0x5f, 0x6f, 0x0, 0x5, 0x36, + 0x86, 0x7e, 0x57, 0xcc, 0x0, 0x7, 0x37, 0xdf, 0x27, 0x8, 0xe0, 0xe8, 0x75, 0x0, 0x5, 0xa6, 0x76, + 0xb8, 0x5b, 0x78, 0x0, 0xc, 0x7a, 0xa, 0x87, 0x2e, 0x5a, 0xaa, 0x39, 0xd0, 0xf9, 0xe7, 0x7c, 0x84, + 0x0, 0x6, 0x3a, 0x31, 0xe5, 0x43, 0xa8, 0x89, 0x0, 0x10, 0x37, 0xb5, 0xa1, 0xdc, 0x96, 0xdb, 0x3a, + 0xdb, 0xab, 0x69, 0xe2, 0x75, 0x96, 0xc3, 0x60, 0xa9, 0x0, 0x12, 0xdf, 0xe9, 0xcd, 0xa, 0xae, 0x17, + 0xc1, 0x17, 0xb, 0xff, 0x30, 0x89, 0x75, 0x9e, 0x88, 0x44, 0xc9, 0x31, 0x0, 0xc, 0x19, 0x58, 0xf6, + 0x43, 0x83, 0x4a, 0x20, 0xf2, 0x3e, 0x3a, 0x1, 0xa4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 30899 [Right QoS1] [] -TEST(SubACK311QCTest, Decode24) { -uint8_t pkt[] = {0x90, 0x3, 0x78, 0xb3, 0x1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 30899); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd6, 0x69, 0xb0, 0x9c, 0x58, 0x29, 0x86, 0x28, 0xfb, 0x75, 0x78, 0xd2, + 0xf0, 0x11, 0x1a, 0xc8, 0xdb, 0x19, 0xdb, 0x6c, 0xd5, 0xaa, 0x42}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x3d, 0xc5, 0xeb, 0xa3, 0x31, 0x19, 0x5, 0xff, + 0xb5, 0x8f, 0xc9, 0xab, 0x76, 0x75, 0x5f, 0x6f}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x36, 0x86, 0x7e, 0x57, 0xcc}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x37, 0xdf, 0x27, 0x8, 0xe0, 0xe8, 0x75}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa6, 0x76, 0xb8, 0x5b, 0x78}; + lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x7a, 0xa, 0x87, 0x2e, 0x5a, 0xaa, 0x39, 0xd0, 0xf9, 0xe7, 0x7c, 0x84}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3a, 0x31, 0xe5, 0x43, 0xa8, 0x89}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x37, 0xb5, 0xa1, 0xdc, 0x96, 0xdb, 0x3a, 0xdb, + 0xab, 0x69, 0xe2, 0x75, 0x96, 0xc3, 0x60, 0xa9}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xdf, 0xe9, 0xcd, 0xa, 0xae, 0x17, 0xc1, 0x17, 0xb, + 0xff, 0x30, 0x89, 0x75, 0x9e, 0x88, 0x44, 0xc9, 0x31}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x19, 0x58, 0xf6, 0x43, 0x83, 0x4a, 0x20, 0xf2, 0x3e, 0x3a, 0x1, 0xa4}; + lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29664, 10, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 28866 ["\ACK"] [] +TEST(Unsubscribe311QCTest, Encode6) { + uint8_t pkt[] = {0xa2, 0x5, 0x70, 0xc2, 0x0, 0x1, 0x6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 15 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS2] [] -TEST(SubACK311QCTest, Decode25) { -uint8_t pkt[] = {0x90, 0x8, 0x0, 0xf, 0xa1, 0x2, 0x2, 0x9e, 0x0, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 15); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[3], 0x80); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x6}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28866, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 22023 ["f\155\163\EOT\DLE\ETX\209\SO","d\219\136\ENQC\167\239$\224","e{[\245\153\203\211*~\193"] +// [] +TEST(Unsubscribe311QCTest, Encode7) { + uint8_t pkt[] = {0xa2, 0x23, 0x56, 0x7, 0x0, 0x8, 0x66, 0x9b, 0xa3, 0x4, 0x10, 0x3, 0xd1, + 0xe, 0x0, 0x9, 0x64, 0xdb, 0x88, 0x5, 0x43, 0xa7, 0xef, 0x24, 0xe0, 0x0, + 0xa, 0x65, 0x7b, 0x5b, 0xf5, 0x99, 0xcb, 0xd3, 0x2a, 0x7e, 0xc1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 13923 [Right QoS2,Left SubErrNotAuthorized,Right QoS1,Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded] [] -TEST(SubACK311QCTest, Decode26) { -uint8_t pkt[] = {0x90, 0x7, 0x36, 0x63, 0x2, 0x87, 0x1, 0x91, 0x97}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 13923); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[1], 0x80); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[3], 0x80); -EXPECT_EQ(granted_qos_levels[4], 0x80); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x66, 0x9b, 0xa3, 0x4, 0x10, 0x3, 0xd1, 0xe}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x64, 0xdb, 0x88, 0x5, 0x43, 0xa7, 0xef, 0x24, 0xe0}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x65, 0x7b, 0x5b, 0xf5, 0x99, 0xcb, 0xd3, 0x2a, 0x7e, 0xc1}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22023, 3, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 28799 +// ["\n\DC3\242\212\169e\178\133","\175\193&\241\184C\SO\NAK\147\164[_\NAKK\180\249\202\fq\246\RS"] [] +TEST(Unsubscribe311QCTest, Encode8) { + uint8_t pkt[] = {0xa2, 0x23, 0x70, 0x7f, 0x0, 0x8, 0xa, 0x13, 0xf2, 0xd4, 0xa9, 0x65, 0xb2, + 0x85, 0x0, 0x15, 0xaf, 0xc1, 0x26, 0xf1, 0xb8, 0x43, 0xe, 0x15, 0x93, 0xa4, + 0x5b, 0x5f, 0x15, 0x4b, 0xb4, 0xf9, 0xca, 0xc, 0x71, 0xf6, 0x1e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 6677 [Right QoS0,Right QoS1,Left SubErrImplementationSpecificError,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError] [] -TEST(SubACK311QCTest, Decode27) { -uint8_t pkt[] = {0x90, 0xd, 0x1a, 0x15, 0x0, 0x1, 0x83, 0x1, 0x91, 0x0, 0x2, 0x2, 0x9e, 0x1, 0x83}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[11]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 11, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 6677); -EXPECT_EQ(count, 11); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[4], 0x80); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[8], 0x80); -EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[10], 0x80); - -} - - -// SubscribeResponse 12919 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported] [] -TEST(SubACK311QCTest, Decode28) { -uint8_t pkt[] = {0x90, 0x7, 0x32, 0x77, 0x2, 0x91, 0x1, 0x0, 0xa1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT311, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 12919); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[1], 0x80); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[4], 0x80); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xa, 0x13, 0xf2, 0xd4, 0xa9, 0x65, 0xb2, 0x85}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xaf, 0xc1, 0x26, 0xf1, 0xb8, 0x43, 0xe, 0x15, 0x93, 0xa4, 0x5b, + 0x5f, 0x15, 0x4b, 0xb4, 0xf9, 0xca, 0xc, 0x71, 0xf6, 0x1e}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28799, 2, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 20344 +// ["\132&\189So\207\US\218VGo\190\255u\223\192\228\&7]\EOTM\164\206\171IIN[W","\234\252\195\214\201.\223\160\FSx\204\229\237{-Yj\DC2\239\167\132\159{","\221\ESCwC\170\ESC3\SYN\247\206"] +// [] +TEST(Unsubscribe311QCTest, Encode11) { + uint8_t pkt[] = {0xa2, 0x2f, 0x44, 0x4e, 0x0, 0x2, 0x61, 0x3, 0x0, 0x1b, 0x81, 0xe6, 0x5e, 0x9b, 0xea, 0x37, 0x73, + 0xea, 0x23, 0x43, 0xeb, 0x5b, 0xd9, 0xb8, 0xda, 0xc1, 0x97, 0x7d, 0x3e, 0x59, 0x6a, 0x12, 0xef, 0xa7, + 0x84, 0x9f, 0x7b, 0x0, 0xa, 0xdd, 0x1b, 0x77, 0x43, 0xaa, 0x1b, 0x33, 0x16, 0xf7, 0xce}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 6377 [Right QoS0,Right QoS0,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0] [PropWillDelayInterval 21552,PropWildcardSubscriptionAvailable 199,PropSubscriptionIdentifier 16,PropReasonString "~\139kfO\DLE\184\199\&5\177\154\234\203\188\163\206",PropServerReference "\ETBh\139\164\232\250",PropRequestResponseInformation 83,PropWildcardSubscriptionAvailable 103,PropServerReference "\159Y\158\204\&7\ESC\236\228\151\187",PropTopicAlias 32755,PropTopicAlias 18713,PropServerKeepAlive 19773,PropContentType "\255\FSX9Vv\192\v#\v\245\226\219\162\254~\144$@\168?\214rb\222\DC3\155G\246!",PropRequestProblemInformation 125,PropAuthenticationData "z\190G`?\204\173\184\237\209\162y,\242\ESC\141\EMU\144\243\211\222\243@",PropCorrelationData "\249\164B\149\210H\177D\179\170\219\174\254\171\249\193>\235S1L",PropServerKeepAlive 25850,PropRequestProblemInformation 60,PropAuthenticationMethod "\230\241\255QY-\t\214\EOTR#CsI\246\140\158T\140\235\186\DC4\CAN\n<\ACK",PropResponseInformation "n\223/\ETX({\SO\v\203\"\189\234Bi1\239\STX",PropMessageExpiryInterval 13351,PropReasonString "\181\239D\145%\195.n\163P)\199\142\205\206\246P\STX\204B\246\222\169\219",PropWillDelayInterval 28861,PropReasonString "(\SI\239\225\129\231>\136r\214.\190",PropSubscriptionIdentifierAvailable 235,PropMessageExpiryInterval 16397,PropResponseTopic "\US\NAK\163\143",PropAuthenticationMethod "yx6%\165|\156\129\215\DLE\FSe\208|\128\146C\198",PropMaximumQoS 172] -TEST(SubACK5QCTest, Decode1) { -uint8_t pkt[] = {0x90, 0xad, 0x2, 0x18, 0xe9, 0xa4, 0x2, 0x18, 0x0, 0x0, 0x54, 0x30, 0x28, 0xc7, 0xb, 0x10, 0x1f, 0x0, 0x10, 0x7e, 0x8b, 0x6b, 0x66, 0x4f, 0x10, 0xb8, 0xc7, 0x35, 0xb1, 0x9a, 0xea, 0xcb, 0xbc, 0xa3, 0xce, 0x1c, 0x0, 0x6, 0x17, 0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50, 0x29, 0xc7, 0x8e, 0xcd, 0xce, 0xf6, 0x50, 0x2, 0xcc, 0x42, 0xf6, 0xde, 0xa9, 0xdb, 0x18, 0x0, 0x0, 0x70, 0xbd, 0x1f, 0x0, 0xc, 0x28, 0xf, 0xef, 0xe1, 0x81, 0xe7, 0x3e, 0x88, 0x72, 0xd6, 0x2e, 0xbe, 0x29, 0xeb, 0x2, 0x0, 0x0, 0x40, 0xd, 0x8, 0x0, 0x4, 0x1f, 0x15, 0xa3, 0x8f, 0x15, 0x0, 0x12, 0x79, 0x78, 0x36, 0x25, 0xa5, 0x7c, 0x9c, 0x81, 0xd7, 0x10, 0x1c, 0x65, 0xd0, 0x7c, 0x80, 0x92, 0x43, 0xc6, 0x24, 0xac, 0x0, 0x0, 0x1, 0xa1, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 6377); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[3], 0xA1); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x61, 0x3}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x81, 0xe6, 0x5e, 0x9b, 0xea, 0x37, 0x73, 0xea, 0x23, 0x43, 0xeb, 0x5b, 0xd9, 0xb8, + 0xda, 0xc1, 0x97, 0x7d, 0x3e, 0x59, 0x6a, 0x12, 0xef, 0xa7, 0x84, 0x9f, 0x7b}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xdd, 0x1b, 0x77, 0x43, 0xaa, 0x1b, 0x33, 0x16, 0xf7, 0xce}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17486, 3, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 7754 ["\211\172/9\239\190\154\155:\145\238\225c\242\144\159\183"] [] +TEST(Unsubscribe311QCTest, Encode12) { + uint8_t pkt[] = {0xa2, 0x15, 0x1e, 0x4a, 0x0, 0x11, 0xd3, 0xac, 0x2f, 0x39, 0xef, 0xbe, + 0x9a, 0x9b, 0x3a, 0x91, 0xee, 0xe1, 0x63, 0xf2, 0x90, 0x9f, 0xb7}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 22342 [Left SubErrQuotaExceeded,Right QoS2,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS1,Right QoS0] [PropRetainAvailable 40,PropMessageExpiryInterval 30950,PropServerKeepAlive 31863,PropResponseTopic "\222x\188\&6!\172\253\138\155%\239(l8\147#\175\&4\195*\155l\240",PropAssignedClientIdentifier "\164w\200(\168Z\134\186\138\&1\254>\236\234\212E\151\215\144\142",PropPayloadFormatIndicator 49,PropUserProperty "f\250\132\NUL\229q\185\172 \132" "$\US",PropReasonString "*!\201\223\197s\135\213k\156\190\186H\SUB\164o\242\&2\ACK\221\SOH[U}\183\179\232\239\172",PropSessionExpiryInterval 12524,PropResponseInformation "\224\155\178\155\234f",PropTopicAlias 25820,PropMessageExpiryInterval 11088,PropUserProperty "\173!\US\234\f#j32" "\GSJ+I\189]\206\240\160\156D"] -TEST(SubACK5QCTest, Decode2) { -uint8_t pkt[] = {0x90, 0xac, 0x1, 0x57, 0x46, 0x9d, 0x1, 0x25, 0x28, 0x2, 0x0, 0x0, 0x78, 0xe6, 0x13, 0x7c, 0x77, 0x8, 0x0, 0x17, 0xde, 0x78, 0xbc, 0x36, 0x21, 0xac, 0xfd, 0x8a, 0x9b, 0x25, 0xef, 0x28, 0x6c, 0x38, 0x93, 0x23, 0xaf, 0x34, 0xc3, 0x2a, 0x9b, 0x6c, 0xf0, 0x12, 0x0, 0x14, 0xa4, 0x77, 0xc8, 0x28, 0xa8, 0x5a, 0x86, 0xba, 0x8a, 0x31, 0xfe, 0x3e, 0xec, 0xea, 0xd4, 0x45, 0x97, 0xd7, 0x90, 0x8e, 0x1, 0x31, 0x26, 0x0, 0xa, 0x66, 0xfa, 0x84, 0x0, 0xe5, 0x71, 0xb9, 0xac, 0x20, 0x84, 0x0, 0x2, 0x24, 0x1f, 0x1f, 0x0, 0x1d, 0x2a, 0x21, 0xc9, 0xdf, 0xc5, 0x73, 0x87, 0xd5, 0x6b, 0x9c, 0xbe, 0xba, 0x48, 0x1a, 0xa4, 0x6f, 0xf2, 0x32, 0x6, 0xdd, 0x1, 0x5b, 0x55, 0x7d, 0xb7, 0xb3, 0xe8, 0xef, 0xac, 0x11, 0x0, 0x0, 0x30, 0xec, 0x1a, 0x0, 0x6, 0xe0, 0x9b, 0xb2, 0x9b, 0xea, 0x66, 0x23, 0x64, 0xdc, 0x2, 0x0, 0x0, 0x2b, 0x50, 0x26, 0x0, 0x9, 0xad, 0x21, 0x1f, 0xea, 0xc, 0x23, 0x6a, 0x33, 0x32, 0x0, 0xb, 0x1d, 0x4a, 0x2b, 0x49, 0xbd, 0x5d, 0xce, 0xf0, 0xa0, 0x9c, 0x44, 0x97, 0x2, 0xa1, 0x9e, 0x1, 0x8f, 0x0, 0x91, 0x0, 0x1, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[11]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 11, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 22342); -EXPECT_EQ(count, 11); -EXPECT_EQ(granted_qos_levels[0], 0x97); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[2], 0xA1); -EXPECT_EQ(granted_qos_levels[3], 0x9E); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[5], 0x8F); -EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[7], 0x91); -EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); - -} - - -// SubscribeResponse 20403 [Left SubErrImplementationSpecificError,Left SubErrNotAuthorized,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [PropSharedSubscriptionAvailable 232,PropRequestProblemInformation 75,PropResponseInformation "\201\208\FS0\215\215~\DC1\141\142^\214s\202z\245rb\246\240//",PropReceiveMaximum 32008,PropSubscriptionIdentifierAvailable 248,PropReasonString "]\205Ugu\148\255i\230\195C\240",PropCorrelationData "\132'\nD\vRv\141\&1\224\220\233;\145\&1eJI\164\225\144\148\230\131\231\&7",PropUserProperty "\160\213\RS-S\171\171W\241\206\239\137\ENQ\b\229\&8\229r\182\ESC+\157\\\148m5\227@g\142" "\STX?nttV\255C<%\SUB\135\225\237",PropAuthenticationMethod "\SUB\223\177\189x\208\194\164\&1f_\ETB3\168VOx\157\172",PropReceiveMaximum 9817,PropSubscriptionIdentifierAvailable 127,PropAuthenticationMethod "\253e\EMx+\147K+u\RSQU\173\194\145x7d+(\241\152\CANmk\NUL\179",PropMaximumQoS 70,PropSessionExpiryInterval 14477,PropAssignedClientIdentifier "Y\141\ENQ\251\160\244f\154\&8yv\174\177\DEL/\202\"\189\143\185J",PropPayloadFormatIndicator 111,PropMessageExpiryInterval 21491,PropRequestProblemInformation 109,PropSessionExpiryInterval 24691,PropCorrelationData "",PropMaximumPacketSize 10757,PropContentType "",PropWildcardSubscriptionAvailable 136] -TEST(SubACK5QCTest, Decode3) { -uint8_t pkt[] = {0x90, 0xfa, 0x1, 0x4f, 0xb3, 0xf2, 0x1, 0x2a, 0xe8, 0x17, 0x4b, 0x1a, 0x0, 0x16, 0xc9, 0xd0, 0x1c, 0x30, 0xd7, 0xd7, 0x7e, 0x11, 0x8d, 0x8e, 0x5e, 0xd6, 0x73, 0xca, 0x7a, 0xf5, 0x72, 0x62, 0xf6, 0xf0, 0x2f, 0x2f, 0x21, 0x7d, 0x8, 0x29, 0xf8, 0x1f, 0x0, 0xc, 0x5d, 0xcd, 0x55, 0x67, 0x75, 0x94, 0xff, 0x69, 0xe6, 0xc3, 0x43, 0xf0, 0x9, 0x0, 0x1a, 0x84, 0x27, 0xa, 0x44, 0xb, 0x52, 0x76, 0x8d, 0x31, 0xe0, 0xdc, 0xe9, 0x3b, 0x91, 0x31, 0x65, 0x4a, 0x49, 0xa4, 0xe1, 0x90, 0x94, 0xe6, 0x83, 0xe7, 0x37, 0x26, 0x0, 0x1e, 0xa0, 0xd5, 0x1e, 0x2d, 0x53, 0xab, 0xab, 0x57, 0xf1, 0xce, 0xef, 0x89, 0x5, 0x8, 0xe5, 0x38, 0xe5, 0x72, 0xb6, 0x1b, 0x2b, 0x9d, 0x5c, 0x94, 0x6d, 0x35, 0xe3, 0x40, 0x67, 0x8e, 0x0, 0xe, 0x2, 0x3f, 0x6e, 0x74, 0x74, 0x56, 0xff, 0x43, 0x3c, 0x25, 0x1a, 0x87, 0xe1, 0xed, 0x15, 0x0, 0x13, 0x1a, 0xdf, 0xb1, 0xbd, 0x78, 0xd0, 0xc2, 0xa4, 0x31, 0x66, 0x5f, 0x17, 0x33, 0xa8, 0x56, 0x4f, 0x78, 0x9d, 0xac, 0x21, 0x26, 0x59, 0x29, 0x7f, 0x15, 0x0, 0x1b, 0xfd, 0x65, 0x19, 0x78, 0x2b, 0x93, 0x4b, 0x2b, 0x75, 0x1e, 0x51, 0x55, 0xad, 0xc2, 0x91, 0x78, 0x37, 0x64, 0x2b, 0x28, 0xf1, 0x98, 0x18, 0x6d, 0x6b, 0x0, 0xb3, 0x24, 0x46, 0x11, 0x0, 0x0, 0x38, 0x8d, 0x12, 0x0, 0x15, 0x59, 0x8d, 0x5, 0xfb, 0xa0, 0xf4, 0x66, 0x9a, 0x38, 0x79, 0x76, 0xae, 0xb1, 0x7f, 0x2f, 0xca, 0x22, 0xbd, 0x8f, 0xb9, 0x4a, 0x1, 0x6f, 0x2, 0x0, 0x0, 0x53, 0xf3, 0x17, 0x6d, 0x11, 0x0, 0x0, 0x60, 0x73, 0x9, 0x0, 0x0, 0x27, 0x0, 0x0, 0x2a, 0x5, 0x3, 0x0, 0x0, 0x28, 0x88, 0x83, 0x87, 0xa1, 0x1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[4]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 4, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 20403); -EXPECT_EQ(count, 4); -EXPECT_EQ(granted_qos_levels[0], 0x83); -EXPECT_EQ(granted_qos_levels[1], 0x87); -EXPECT_EQ(granted_qos_levels[2], 0xA1); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xd3, 0xac, 0x2f, 0x39, 0xef, 0xbe, 0x9a, 0x9b, 0x3a, + 0x91, 0xee, 0xe1, 0x63, 0xf2, 0x90, 0x9f, 0xb7}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7754, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 949 ["\139xV\142E\139\&7\179T\130\212\250G\195F\193\252\250\202{\196z\228\164\STX\US\219"] [] +TEST(Unsubscribe311QCTest, Encode13) { + uint8_t pkt[] = {0xa2, 0x1f, 0x3, 0xb5, 0x0, 0x1b, 0x8b, 0x78, 0x56, 0x8e, 0x45, 0x8b, 0x37, 0xb3, 0x54, 0x82, 0xd4, + 0xfa, 0x47, 0xc3, 0x46, 0xc1, 0xfc, 0xfa, 0xca, 0x7b, 0xc4, 0x7a, 0xe4, 0xa4, 0x2, 0x1f, 0xdb}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 8789 [Left SubErrUnspecifiedError,Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] [PropPayloadFormatIndicator 151,PropAssignedClientIdentifier "I\177\215\239\226q",PropServerReference "\RS\SYNE/\157m\NUL\133/l\ETB\138\168Spf\129,\133",PropAuthenticationData "\192\219\tc;\217,r\245V Z\190)\239\232\185\160w\SO\170\n\189\217\214sk\SUB\ETB?",PropSharedSubscriptionAvailable 245,PropResponseInformation "~R9\"\244fY\203\182\137:\194\183\&3`\ACK\170\245\226\164",PropMaximumPacketSize 26769,PropReasonString "R\206\163\GS,\DC4\170\247\249\139\174\188\138\147I\180\&5\t\b\143\250\134\132\255b\180\223c\211\238",PropContentType "\\\215\138\196\229hF%=\246\152\168e\138\a'P}\227rA#\211n\156",PropUserProperty "|f\176\f\162\196\168s\148\182+\171\183\208\142\224\157x+ z\217\US\128\159\215u\NAK",PropRequestProblemInformation 184,PropMessageExpiryInterval 21818,PropReasonString "\"\245\214\SI\147\180nJUX\205O\231\144\155\CAN)\184\205c\157P\US\234\246\n\203\235bn",PropAuthenticationMethod "A^o\DEL/6\180\163(\248\242\153y\218\STXp\201-\n",PropRequestProblemInformation 184,PropResponseInformation ""] -TEST(SubACK5QCTest, Decode4) { -uint8_t pkt[] = {0x90, 0xa5, 0x2, 0x22, 0x55, 0x9c, 0x2, 0x1, 0x97, 0x12, 0x0, 0x6, 0x49, 0xb1, 0xd7, 0xef, 0xe2, 0x71, 0x1c, 0x0, 0x13, 0x1e, 0x16, 0x45, 0x2f, 0x9d, 0x6d, 0x0, 0x85, 0x2f, 0x6c, 0x17, 0x8a, 0xa8, 0x53, 0x70, 0x66, 0x81, 0x2c, 0x85, 0x16, 0x0, 0x1e, 0xc0, 0xdb, 0x9, 0x63, 0x3b, 0xd9, 0x2c, 0x72, 0xf5, 0x56, 0x20, 0x5a, 0xbe, 0x29, 0xef, 0xe8, 0xb9, 0xa0, 0x77, 0xe, 0xaa, 0xa, 0xbd, 0xd9, 0xd6, 0x73, 0x6b, 0x1a, 0x17, 0x3f, 0x2a, 0xf5, 0x1a, 0x0, 0x14, 0x7e, 0x52, 0x39, 0x22, 0xf4, 0x66, 0x59, 0xcb, 0xb6, 0x89, 0x3a, 0xc2, 0xb7, 0x33, 0x60, 0x6, 0xaa, 0xf5, 0xe2, 0xa4, 0x27, 0x0, 0x0, 0x68, 0x91, 0x1f, 0x0, 0x1e, 0x52, 0xce, 0xa3, 0x1d, 0x2c, 0x14, 0xaa, 0xf7, 0xf9, 0x8b, 0xae, 0xbc, 0x8a, 0x93, 0x49, 0xb4, 0x35, 0x9, 0x8, 0x8f, 0xfa, 0x86, 0x84, 0xff, 0x62, 0xb4, 0xdf, 0x63, 0xd3, 0xee, 0x3, 0x0, 0x19, 0x5c, 0xd7, 0x8a, 0xc4, 0xe5, 0x68, 0x46, 0x25, 0x3d, 0xf6, 0x98, 0xa8, 0x65, 0x8a, 0x7, 0x27, 0x50, 0x7d, 0xe3, 0x72, 0x41, 0x23, 0xd3, 0x6e, 0x9c, 0x26, 0x0, 0x1e, 0x7c, 0x66, 0xb0, 0xc, 0xa2, 0xc4, 0xa8, 0x73, 0x94, 0xb6, 0x2b, 0xab, 0x3c, 0x43, 0xf5, 0x1a, 0x18, 0x97, 0x8, 0x2e, 0xb1, 0x27, 0x9d, 0x2c, 0xef, 0xf4, 0x57, 0xbc, 0x55, 0xe3, 0x0, 0x19, 0x3b, 0x79, 0x4b, 0xea, 0x27, 0xfe, 0x36, 0x9a, 0x3e, 0xb7, 0xd0, 0x8e, 0xe0, 0x9d, 0x78, 0x2b, 0x20, 0x7a, 0xd9, 0x1f, 0x80, 0x9f, 0xd7, 0x75, 0x15, 0x17, 0xb8, 0x2, 0x0, 0x0, 0x55, 0x3a, 0x1f, 0x0, 0x1e, 0x22, 0xf5, 0xd6, 0xf, 0x93, 0xb4, 0x6e, 0x4a, 0x55, 0x58, 0xcd, 0x4f, 0xe7, 0x90, 0x9b, 0x18, 0x29, 0xb8, 0xcd, 0x63, 0x9d, 0x50, 0x1f, 0xea, 0xf6, 0xa, 0xcb, 0xeb, 0x62, 0x6e, 0x15, 0x0, 0x13, 0x41, 0x5e, 0x6f, 0x7f, 0x2f, 0x36, 0xb4, 0xa3, 0x28, 0xf8, 0xf2, 0x99, 0x79, 0xda, 0x2, 0x70, 0xc9, 0x2d, 0xa, 0x17, 0xb8, 0x1a, 0x0, 0x0, 0x80, 0x9e, 0x97, 0x1, 0xa2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 8789); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], 0x80); -EXPECT_EQ(granted_qos_levels[1], 0x9E); -EXPECT_EQ(granted_qos_levels[2], 0x97); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[4], 0xA2); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x8b, 0x78, 0x56, 0x8e, 0x45, 0x8b, 0x37, 0xb3, 0x54, 0x82, 0xd4, 0xfa, 0x47, 0xc3, + 0x46, 0xc1, 0xfc, 0xfa, 0xca, 0x7b, 0xc4, 0x7a, 0xe4, 0xa4, 0x2, 0x1f, 0xdb}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 949, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 5184 +// ["\160\156\&1\155\217\US\192\233A\170\&6f\208I","\ENQ\r\NAK\179\221\CAN\215\212\191\237F\250\ESC'\255a\132\132W>\231","\169\255\rPZLI'\SO\SYN\158\226\192\203\CAN[\136\168\185","\227Jq\248\&3\215\SYN=\200\169(\221\NAKe0>\147\156pZ\131e\165\ETB\252\152d\245\133\174","\192\144\SI\216f\194_\160\160'\US}\195VY\222\235\217\186%\198T]\247","\239Z\211\232","J\184i\172\147\218PR\190~\at/\158\152T\135\"\144\RS3\139","\167\176.\244x\254S\EOT!N\202z\154T\210\DC3G\DLE\130","\194","\165\208\135\190\165G"] +// [] +TEST(Unsubscribe311QCTest, Encode14) { + uint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0x47}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; -// SubscribeResponse 2708 [Right QoS1,Right QoS2,Right QoS0,Right QoS0,Left SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS1,Right QoS0,Right QoS1] [PropAuthenticationData "\137&t\240\241\CAN\201\212\173\255t\tyG\245\189\157!@\193Y\ENQ%a\237\133",PropMaximumPacketSize 1523] -TEST(SubACK5QCTest, Decode5) { -uint8_t pkt[] = {0x90, 0x30, 0xa, 0x94, 0x22, 0x16, 0x0, 0x1a, 0x89, 0x26, 0x74, 0xf0, 0xf1, 0x18, 0xc9, 0xd4, 0xad, 0xff, 0x74, 0x9, 0x79, 0x47, 0xf5, 0xbd, 0x9d, 0x21, 0x40, 0xc1, 0x59, 0x5, 0x25, 0x61, 0xed, 0x85, 0x27, 0x0, 0x0, 0x5, 0xf3, 0x1, 0x2, 0x0, 0x0, 0x8f, 0xa2, 0x2, 0x1, 0x1, 0x0, 0x1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[11]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 11, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 2708); -EXPECT_EQ(count, 11); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[4], 0x8F); -EXPECT_EQ(granted_qos_levels[5], 0xA2); -EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS1); - -} - - -// SubscribeResponse 12793 [Left SubErrTopicFilterInvalid,Right QoS0,Right QoS0,Right QoS2,Left SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported] [PropUserProperty "\SO3\200y\203\r\DC2\208\DLE9v\r\152Q-\167\&8\187}\ACK\NUL" "\129\&5",PropCorrelationData "\139f\SOH\245\STX\169\238^r\229hV\206\180",PropWillDelayInterval 16972,PropSubscriptionIdentifier 27,PropRequestProblemInformation 54,PropAuthenticationMethod "J\175\145\EOT\225L\241f`GZ\US\CANnj\129s\139+\238\245R",PropUserProperty "\146\226\170\198\238\ETX\216\191M\203\236l\131\217x7J\150\226" "|\244\ETBe#\CAN\206\173\168\250\245\SO\221J\SI\248b\248\232\177;\242\155",PropRequestResponseInformation 193,PropResponseTopic "`\132\189\196\203\224\128\252\SO\166\252`f\GS\172\SOQ\DC2\216\220\SO\182\255\SYN",PropServerKeepAlive 19627,PropMaximumPacketSize 8916,PropSubscriptionIdentifier 21,PropAssignedClientIdentifier "\158\t\SYN)H\153\&0\230?\NAK\DC4",PropPayloadFormatIndicator 209,PropAssignedClientIdentifier "\185\162+\152JG\200(\162&",PropServerReference "\164\195\DC2\249J\NUL\191\136\138_\137r\241\\\211\236'\n8\200\160Wb\147\172\196\SYN\221",PropSessionExpiryInterval 28997,PropMessageExpiryInterval 8313,PropUserProperty "\200\189\192\FS\240\DC29\138\249\238\NULX\165" "\SYN\STX\233I\245s\183\232xW\207\&5\254\139\228O\SOH\CAN>\138&\244\vy\226\155#\DC1\165",PropTopicAliasMaximum 24813,PropRequestProblemInformation 181,PropResponseTopic "\DC28\202\175\242\US\226\166\244\142\DEL\144\234}",PropSessionExpiryInterval 19284,PropMaximumQoS 251,PropResponseInformation "q\242\NUL -\210?@lk",PropUserProperty "\STX\211\252\225\139\&7\159\198\fl7i\132\254:$\249\153\237^\221L\194Sq\"\t\DC1" "\129`m\145\225\252-",PropWillDelayInterval 11295,PropMaximumQoS 2] -TEST(SubACK5QCTest, Decode10) { -uint8_t pkt[] = {0x90, 0xf7, 0x1, 0x74, 0x8, 0xea, 0x1, 0x1, 0x57, 0x8, 0x0, 0xd, 0x4e, 0x40, 0xef, 0x0, 0xc2, 0xb2, 0x96, 0x1a, 0xc8, 0x3e, 0xb6, 0xff, 0x16, 0x13, 0x4c, 0xab, 0x27, 0x0, 0x0, 0x22, 0xd4, 0xb, 0x15, 0x12, 0x0, 0xb, 0x9e, 0x9, 0x16, 0x29, 0x48, 0x99, 0x30, 0xe6, 0x3f, 0x15, 0x14, 0x1, 0xd1, 0x12, 0x0, 0xa, 0xb9, 0xa2, 0x2b, 0x98, 0x4a, 0x47, 0xc8, 0x28, 0xa2, 0x26, 0x1c, 0x0, 0x1c, 0xa4, 0xc3, 0x12, 0xf9, 0x4a, 0x0, 0xbf, 0x88, 0x8a, 0x5f, 0x89, 0x72, 0xf1, 0x5c, 0xd3, 0xec, 0x27, 0xa, 0x38, 0xc8, 0xa0, 0x57, 0x62, 0x93, 0xac, 0xc4, 0x16, 0xdd, 0x11, 0x0, 0x0, 0x71, 0x45, 0x2, 0x0, 0x0, 0x20, 0x79, 0x26, 0x0, 0xd, 0xc8, 0xbd, 0xc0, 0x1c, 0xf0, 0x12, 0x39, 0x8a, 0xf9, 0xee, 0x0, 0x58, 0xa5, 0x0, 0x1d, 0x16, 0x2, 0xe9, 0x49, 0xf5, 0x73, 0xb7, 0xe8, 0x78, 0x57, 0xcf, 0x35, 0xfe, 0x8b, 0xe4, 0x4f, 0x1, 0x18, 0x3e, 0x8a, 0x26, 0xf4, 0xb, 0x79, 0xe2, 0x9b, 0x23, 0x11, 0xa5, 0x22, 0x60, 0xed, 0x17, 0xb5, 0x8, 0x0, 0xe, 0x12, 0x38, 0xca, 0xaf, 0xf2, 0x1f, 0xe2, 0xa6, 0xf4, 0x8e, 0x7f, 0x90, 0xea, 0x7d, 0x11, 0x0, 0x0, 0x4b, 0x54, 0x24, 0xfb, 0x1a, 0x0, 0xa, 0x71, 0xf2, 0x0, 0x20, 0x2d, 0xd2, 0x3f, 0x40, 0x6c, 0x6b, 0x26, 0x0, 0x1c, 0x2, 0xd3, 0xfc, 0xe1, 0x8b, 0x37, 0x9f, 0xc6, 0xc, 0x6c, 0x37, 0x69, 0x84, 0xfe, 0x3a, 0x24, 0xf9, 0x99, 0xed, 0x5e, 0xdd, 0x4c, 0xc2, 0x53, 0x71, 0x22, 0x9, 0x11, 0x0, 0x7, 0x81, 0x60, 0x6d, 0x91, 0xe1, 0xfc, 0x2d, 0x18, 0x0, 0x0, 0x2c, 0x1f, 0x24, 0x2, 0x2, 0x0, 0x1, 0x9e, 0xa1, 0x0, 0x9e, 0x0, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[9]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 9, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 29704); -EXPECT_EQ(count, 9); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[3], 0x9E); -EXPECT_EQ(granted_qos_levels[4], 0xA1); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[6], 0x9E); -EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - -} - - -// SubscribeResponse 251 [Left SubErrNotAuthorized,Left SubErrNotAuthorized,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded,Right QoS2,Right QoS2] [PropTopicAliasMaximum 26597,PropAuthenticationData ";&f\172H\211\249W\230\186.\239\NUL\196X\133\&4vN\184cd\DEL\SIy\164\ETX",PropPayloadFormatIndicator 65] -TEST(SubACK5QCTest, Decode11) { -uint8_t pkt[] = {0x90, 0x2d, 0x0, 0xfb, 0x23, 0x22, 0x67, 0xe5, 0x16, 0x0, 0x1b, 0x3b, 0x26, 0x66, 0xac, 0x48, 0xd3, 0xf9, 0x57, 0xe6, 0xba, 0x2e, 0xef, 0x0, 0xc4, 0x58, 0x85, 0x34, 0x76, 0x4e, 0xb8, 0x63, 0x64, 0x7f, 0xf, 0x79, 0xa4, 0x3, 0x1, 0x41, 0x87, 0x87, 0x80, 0x91, 0x97, 0x2, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[7]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 7, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 251); -EXPECT_EQ(count, 7); -EXPECT_EQ(granted_qos_levels[0], 0x87); -EXPECT_EQ(granted_qos_levels[1], 0x87); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], 0x91); -EXPECT_EQ(granted_qos_levels[4], 0x97); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - -} - - -// SubscribeResponse 4144 [Right QoS2] [PropSharedSubscriptionAvailable 170,PropSubscriptionIdentifierAvailable 172,PropContentType "\ACK\248zEH\223lpU\198\180",PropWildcardSubscriptionAvailable 74,PropUserProperty ":`'\245\164a'\178N\SI\227r,+KX\203\179\142\242\219\140\144Rv\145\170" "G\245\152\&6\143G\157",PropRequestResponseInformation 116,PropSubscriptionIdentifier 29,PropSubscriptionIdentifier 19,PropResponseTopic "\130{Fz\SI\215\227\STX",PropWillDelayInterval 28450,PropSubscriptionIdentifierAvailable 70,PropWildcardSubscriptionAvailable 18] -TEST(SubACK5QCTest, Decode12) { -uint8_t pkt[] = {0x90, 0x59, 0x10, 0x30, 0x55, 0x2a, 0xaa, 0x29, 0xac, 0x3, 0x0, 0xb, 0x6, 0xf8, 0x7a, 0x45, 0x48, 0xdf, 0x6c, 0x70, 0x55, 0xc6, 0xb4, 0x28, 0x4a, 0x26, 0x0, 0x1b, 0x3a, 0x60, 0x27, 0xf5, 0xa4, 0x61, 0x27, 0xb2, 0x4e, 0xf, 0xe3, 0x72, 0x2c, 0x2b, 0x4b, 0x58, 0xcb, 0xb3, 0x8e, 0xf2, 0xdb, 0x8c, 0x90, 0x52, 0x76, 0x91, 0xaa, 0x0, 0x7, 0x47, 0xf5, 0x98, 0x36, 0x8f, 0x47, 0x9d, 0x19, 0x74, 0xb, 0x1d, 0xb, 0x13, 0x8, 0x0, 0x8, 0x82, 0x7b, 0x46, 0x7a, 0xf, 0xd7, 0xe3, 0x2, 0x18, 0x0, 0x0, 0x6f, 0x22, 0x29, 0x46, 0x28, 0x12, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 4144); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x67, 0x1a, 0xad, 0x5a, 0x35, 0x87, 0xf5, 0x0, 0x8a, 0xf3, 0x82, 0xa5, 0xaa, 0x4d, + 0xb8, 0x2f, 0x4f, 0x3, 0xd6, 0x24, 0xf1, 0x13, 0x93, 0x38, 0x57, 0x5a, 0x27}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf3, 0xfd, 0xca, 0xa7, 0xd2, 0x6, 0xfd, 0x77, 0xef, 0xf8, 0x80, 0x1f, 0xb8, + 0x99, 0xf2, 0x45, 0xf2, 0x84, 0xdb, 0x6e, 0x4f, 0x6b, 0xfa, 0xf2, 0x71, 0x52}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x22}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x55, 0x8a, 0xc1, 0xf6, 0xa2, 0x54, 0x5f, 0x1a, 0xce, 0x34}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9a, 0x30, 0x54, 0x61, 0x76, 0xff, 0xd5, 0x31, 0x12, 0x59}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xfc, 0x3d, 0x90, 0x4f, 0x22, 0x45, 0x54, 0x44, 0x63, 0xdd, 0x82, 0xe4, 0x45, + 0x5f, 0x34, 0x61, 0x12, 0xfd, 0x66, 0x6e, 0xd1, 0xbb, 0x8a, 0x23, 0x33}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x46, 0x39, 0x7, 0xe0, 0x85, 0xc9, 0xfc, 0xff, 0x97, 0xfd, + 0xdc, 0x4, 0x0, 0x17, 0x33, 0x6d, 0x8c, 0x6f, 0x87, 0xd7, + 0x6c, 0x53, 0x69, 0x8c, 0x9b, 0xf0, 0x32, 0x1, 0xd3, 0x80}; + lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21743, 7, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 11426 ["\138\251 +// \SOH\190x\170(\EOT(\NUL\229\US\232\ETX\tH","\212\252_\137\222\158gd\rm\194;&w\RS\242\199\DLE\ETB\253\145\151","xD\194\160"] +// [] +TEST(Unsubscribe311QCTest, Encode16) { + uint8_t pkt[] = {0xa2, 0x33, 0x2c, 0xa2, 0x0, 0x11, 0x8a, 0xfb, 0x20, 0x1, 0xbe, 0x78, 0xaa, 0x28, + 0x4, 0x28, 0x0, 0xe5, 0x1f, 0xe8, 0x3, 0x9, 0x48, 0x0, 0x16, 0xd4, 0xfc, 0x5f, + 0x89, 0xde, 0x9e, 0x67, 0x64, 0xd, 0x6d, 0xc2, 0x3b, 0x26, 0x77, 0x1e, 0xf2, 0xc7, + 0x10, 0x17, 0xfd, 0x91, 0x97, 0x0, 0x4, 0x78, 0x44, 0xc2, 0xa0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 22442 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS0] [PropSessionExpiryInterval 17170,PropWildcardSubscriptionAvailable 171,PropMessageExpiryInterval 26968,PropMaximumPacketSize 20851,PropMessageExpiryInterval 9049,PropReceiveMaximum 3743,PropSubscriptionIdentifier 9,PropServerReference "\139@D\SO\248\243",PropServerKeepAlive 24258,PropMessageExpiryInterval 23855,PropWildcardSubscriptionAvailable 9,PropWildcardSubscriptionAvailable 233,PropMaximumQoS 77,PropWillDelayInterval 4264,PropMaximumPacketSize 18411,PropSessionExpiryInterval 13140,PropServerKeepAlive 20787] -TEST(SubACK5QCTest, Decode13) { -uint8_t pkt[] = {0x90, 0x49, 0x57, 0xaa, 0x44, 0x11, 0x0, 0x0, 0x43, 0x12, 0x28, 0xab, 0x2, 0x0, 0x0, 0x69, 0x58, 0x27, 0x0, 0x0, 0x51, 0x73, 0x2, 0x0, 0x0, 0x23, 0x59, 0x21, 0xe, 0x9f, 0xb, 0x9, 0x1c, 0x0, 0x6, 0x8b, 0x40, 0x44, 0xe, 0xf8, 0xf3, 0x13, 0x5e, 0xc2, 0x2, 0x0, 0x0, 0x5d, 0x2f, 0x28, 0x9, 0x28, 0xe9, 0x24, 0x4d, 0x18, 0x0, 0x0, 0x10, 0xa8, 0x27, 0x0, 0x0, 0x47, 0xeb, 0x11, 0x0, 0x0, 0x33, 0x54, 0x13, 0x51, 0x33, 0xa2, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[2]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 2, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 22442); -EXPECT_EQ(count, 2); -EXPECT_EQ(granted_qos_levels[0], 0xA2); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x8a, 0xfb, 0x20, 0x1, 0xbe, 0x78, 0xaa, 0x28, 0x4, + 0x28, 0x0, 0xe5, 0x1f, 0xe8, 0x3, 0x9, 0x48}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd4, 0xfc, 0x5f, 0x89, 0xde, 0x9e, 0x67, 0x64, 0xd, 0x6d, 0xc2, + 0x3b, 0x26, 0x77, 0x1e, 0xf2, 0xc7, 0x10, 0x17, 0xfd, 0x91, 0x97}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x78, 0x44, 0xc2, 0xa0}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11426, 3, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 5841 ["yh\251\169","\178\SI\146G\210\133v\153\f\143T\188\187c\SI\227\n\n\NAK*fTRl\205M\224c!"," +// \161\vU\242\SYN:\224","\182o_\213\131\253HkX>\245{\190qc\163\162EH\NUL\a\ENQh","`\198\220\GSG6\209Q\236\251;","\139Hp\135\199d\160+"] +// [] +TEST(Unsubscribe311QCTest, Encode17) { + uint8_t pkt[] = {0xa2, 0x61, 0x16, 0xd1, 0x0, 0x4, 0x79, 0x68, 0xfb, 0xa9, 0x0, 0x1d, 0xb2, 0xf, 0x92, 0x47, 0xd2, + 0x85, 0x76, 0x99, 0xc, 0x8f, 0x54, 0xbc, 0xbb, 0x63, 0xf, 0xe3, 0xa, 0xa, 0x15, 0x2a, 0x66, 0x54, + 0x52, 0x6c, 0xcd, 0x4d, 0xe0, 0x63, 0x21, 0x0, 0x8, 0x20, 0xa1, 0xb, 0x55, 0xf2, 0x16, 0x3a, 0xe0, + 0x0, 0x17, 0xb6, 0x6f, 0x5f, 0xd5, 0x83, 0xfd, 0x48, 0x6b, 0x58, 0x3e, 0xf5, 0x7b, 0xbe, 0x71, 0x63, + 0xa3, 0xa2, 0x45, 0x48, 0x0, 0x7, 0x5, 0x68, 0x0, 0xb, 0x60, 0xc6, 0xdc, 0x1d, 0x47, 0x36, 0xd1, + 0x51, 0xec, 0xfb, 0x3b, 0x0, 0x8, 0x8b, 0x48, 0x70, 0x87, 0xc7, 0x64, 0xa0, 0x2b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 5149 [Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS2,Right QoS2,Left SubErrImplementationSpecificError] [PropMessageExpiryInterval 8080,PropSubscriptionIdentifier 23,PropAuthenticationData "",PropResponseInformation "\SOH\STX\216\178>\219n\233\158-\165\148\166O\168\226\EMk\206\NUL\229",PropRequestProblemInformation 124] -TEST(SubACK5QCTest, Decode14) { -uint8_t pkt[] = {0x90, 0x2d, 0x14, 0x1d, 0x24, 0x2, 0x0, 0x0, 0x1f, 0x90, 0xb, 0x17, 0x16, 0x0, 0x0, 0x1a, 0x0, 0x15, 0x1, 0x2, 0xd8, 0xb2, 0x3e, 0xdb, 0x6e, 0xe9, 0x9e, 0x2d, 0xa5, 0x94, 0xa6, 0x4f, 0xa8, 0xe2, 0x19, 0x6b, 0xce, 0x0, 0xe5, 0x17, 0x7c, 0x91, 0x0, 0x2, 0x2, 0x2, 0x83}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 5149); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], 0x91); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[5], 0x83); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x79, 0x68, 0xfb, 0xa9}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb2, 0xf, 0x92, 0x47, 0xd2, 0x85, 0x76, 0x99, 0xc, 0x8f, + 0x54, 0xbc, 0xbb, 0x63, 0xf, 0xe3, 0xa, 0xa, 0x15, 0x2a, + 0x66, 0x54, 0x52, 0x6c, 0xcd, 0x4d, 0xe0, 0x63, 0x21}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x20, 0xa1, 0xb, 0x55, 0xf2, 0x16, 0x3a, 0xe0}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb6, 0x6f, 0x5f, 0xd5, 0x83, 0xfd, 0x48, 0x6b, 0x58, 0x3e, 0xf5, 0x7b, + 0xbe, 0x71, 0x63, 0xa3, 0xa2, 0x45, 0x48, 0x0, 0x7, 0x5, 0x68}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x60, 0xc6, 0xdc, 0x1d, 0x47, 0x36, 0xd1, 0x51, 0xec, 0xfb, 0x3b}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8b, 0x48, 0x70, 0x87, 0xc7, 0x64, 0xa0, 0x2b}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5841, 6, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 26803 +// ["h\b\248\219\SI\197\167\148#\226\147\153}","f\166\188I8\138","o\166\FS\210\138\156\166\234\SUB:%\155N\154\226\132\233E"] +// [] +TEST(Unsubscribe311QCTest, Encode18) { + uint8_t pkt[] = {0xa2, 0x2d, 0x68, 0xb3, 0x0, 0xd, 0x68, 0x8, 0xf8, 0xdb, 0xf, 0xc5, 0xa7, 0x94, 0x23, 0xe2, + 0x93, 0x99, 0x7d, 0x0, 0x6, 0x66, 0xa6, 0xbc, 0x49, 0x38, 0x8a, 0x0, 0x12, 0x6f, 0xa6, 0x1c, + 0xd2, 0x8a, 0x9c, 0xa6, 0xea, 0x1a, 0x3a, 0x25, 0x9b, 0x4e, 0x9a, 0xe2, 0x84, 0xe9, 0x45}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 27317 [Left SubErrPacketIdentifierInUse,Left SubErrTopicFilterInvalid,Right QoS2,Right QoS0,Right QoS0,Right QoS2] [PropContentType "?\DC4\SI\172~\166\149dp\182\170F\165\163i\150\ENQ\no",PropPayloadFormatIndicator 192,PropSessionExpiryInterval 26985,PropUserProperty "\246)\SI\242c" "?\US\166\SOH\187\250\&3\183\&1O\247\&7Hq",PropTopicAlias 26253,PropWillDelayInterval 23496,PropAuthenticationMethod "\245\189\184\180$D\170\208\v\206\168\SUB\145f\212",PropContentType "qS+",PropTopicAliasMaximum 12139,PropTopicAlias 28751,PropContentType "W\219\180\DC3\144\230"] -TEST(SubACK5QCTest, Decode15) { -uint8_t pkt[] = {0x90, 0x6d, 0x6a, 0xb5, 0x64, 0x3, 0x0, 0x13, 0x3f, 0x14, 0xf, 0xac, 0x7e, 0xa6, 0x95, 0x64, 0x70, 0xb6, 0xaa, 0x46, 0xa5, 0xa3, 0x69, 0x96, 0x5, 0xa, 0x6f, 0x1, 0xc0, 0x11, 0x0, 0x0, 0x69, 0x69, 0x26, 0x0, 0x5, 0xf6, 0x29, 0xf, 0xf2, 0x63, 0x0, 0xe, 0x3f, 0x1f, 0xa6, 0x1, 0xbb, 0xfa, 0x33, 0xb7, 0x31, 0x4f, 0xf7, 0x37, 0x48, 0x71, 0x23, 0x66, 0x8d, 0x18, 0x0, 0x0, 0x5b, 0xc8, 0x15, 0x0, 0xf, 0xf5, 0xbd, 0xb8, 0xb4, 0x24, 0x44, 0xaa, 0xd0, 0xb, 0xce, 0xa8, 0x1a, 0x91, 0x66, 0xd4, 0x3, 0x0, 0x3, 0x71, 0x53, 0x2b, 0x22, 0x2f, 0x6b, 0x23, 0x70, 0x4f, 0x3, 0x0, 0x6, 0x57, 0xdb, 0xb4, 0x13, 0x90, 0xe6, 0x91, 0x8f, 0x2, 0x0, 0x0, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 27317); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], 0x91); -EXPECT_EQ(granted_qos_levels[1], 0x8F); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x68, 0x8, 0xf8, 0xdb, 0xf, 0xc5, 0xa7, 0x94, 0x23, 0xe2, 0x93, 0x99, 0x7d}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x66, 0xa6, 0xbc, 0x49, 0x38, 0x8a}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x6f, 0xa6, 0x1c, 0xd2, 0x8a, 0x9c, 0xa6, 0xea, 0x1a, + 0x3a, 0x25, 0x9b, 0x4e, 0x9a, 0xe2, 0x84, 0xe9, 0x45}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26803, 3, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 22595 ["","r3\FS\a(<\131w\CAN\204\229"] [] +TEST(Unsubscribe311QCTest, Encode19) { + uint8_t pkt[] = {0xa2, 0x11, 0x58, 0x43, 0x0, 0x0, 0x0, 0xb, 0x72, 0x33, + 0x1c, 0x7, 0x28, 0x3c, 0x83, 0x77, 0x18, 0xcc, 0xe5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 30611 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS0,Right QoS2,Right QoS1] [PropMessageExpiryInterval 27493,PropSharedSubscriptionAvailable 220,PropAssignedClientIdentifier "\236\DEL\\\204\242k0\152N\206\215\132@\148\155\177\133'\167"] -TEST(SubACK5QCTest, Decode16) { -uint8_t pkt[] = {0x90, 0x25, 0x77, 0x93, 0x1d, 0x2, 0x0, 0x0, 0x6b, 0x65, 0x2a, 0xdc, 0x12, 0x0, 0x13, 0xec, 0x7f, 0x5c, 0xcc, 0xf2, 0x6b, 0x30, 0x98, 0x4e, 0xce, 0xd7, 0x84, 0x40, 0x94, 0x9b, 0xb1, 0x85, 0x27, 0xa7, 0xa1, 0x2, 0x0, 0x2, 0x1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 30611); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], 0xA1); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x72, 0x33, 0x1c, 0x7, 0x28, 0x3c, 0x83, 0x77, 0x18, 0xcc, 0xe5}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22595, 2, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 907 +// ["\141\FS\ETX\162\204'\133\DLE7\237\140\\w>\252:\aS\161s\SI\179:\248\150E","*,\176\143\254R\241\242\DLE\173a.\225\151\159I:\161","\\X$\251\237\251W\215P\a\133A\163\145\225D\SYN^\163\bf\237\174\STX\141\230\189w\161\162","\217\182-\169\169\173\191Hx@\206Qi\188\231\210D\165\NUL\165\ENQ\220\232\224\226>"] +// [] +TEST(Unsubscribe311QCTest, Encode20) { + uint8_t pkt[] = {0xa2, 0x6e, 0x3, 0x8b, 0x0, 0x1a, 0x8d, 0x1c, 0x3, 0xa2, 0xcc, 0x27, 0x85, 0x10, 0x37, 0xed, + 0x8c, 0x5c, 0x77, 0x3e, 0xfc, 0x3a, 0x7, 0x53, 0xa1, 0x73, 0xf, 0xb3, 0x3a, 0xf8, 0x96, 0x45, + 0x0, 0x12, 0x2a, 0x2c, 0xb0, 0x8f, 0xfe, 0x52, 0xf1, 0xf2, 0x10, 0xad, 0x61, 0x2e, 0xe1, 0x97, + 0x9f, 0x49, 0x3a, 0xa1, 0x0, 0x1e, 0x5c, 0x58, 0x24, 0xfb, 0xed, 0xfb, 0x57, 0xd7, 0x50, 0x7, + 0x85, 0x41, 0xa3, 0x91, 0xe1, 0x44, 0x16, 0x5e, 0xa3, 0x8, 0x66, 0xed, 0xae, 0x2, 0x8d, 0xe6, + 0xbd, 0x77, 0xa1, 0xa2, 0x0, 0x1a, 0xd9, 0xb6, 0x2d, 0xa9, 0xa9, 0xad, 0xbf, 0x48, 0x78, 0x40, + 0xce, 0x51, 0x69, 0xbc, 0xe7, 0xd2, 0x44, 0xa5, 0x0, 0xa5, 0x5, 0xdc, 0xe8, 0xe0, 0xe2, 0x3e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 14554 [Right QoS0,Right QoS2,Left SubErrUnspecifiedError,Right QoS0] [PropTopicAlias 11229,PropMessageExpiryInterval 32396,PropResponseInformation "\183\153$\145\176\192ng\231nM\b\160\147\253U\243\ACKA-\165#\EOT\159\DC1\US",PropAuthenticationData "'n\159d\176?3\204k\217&%\197",PropRetainAvailable 250,PropMessageExpiryInterval 5575,PropAuthenticationData "\136\177\162\173\241\152\"\173\204\DELO\DLE",PropTopicAliasMaximum 27880,PropWillDelayInterval 235,PropSubscriptionIdentifierAvailable 3,PropMaximumQoS 55,PropSharedSubscriptionAvailable 5,PropRequestProblemInformation 163,PropSubscriptionIdentifier 8,PropSubscriptionIdentifier 22,PropUserProperty "\\I.D<\143\213\195\147\157)\CANK\149\138\255/a\226\196\184<\169\201\227\\\132\188b_" "\DC1\SYN\217z\203}\ETX\187;\\",PropWillDelayInterval 11365,PropPayloadFormatIndicator 116,PropServerReference "\211\237\176\193\SYN",PropResponseInformation "\\v\SUBGzm\185\162\157)\200@!\235#\243I\237\146\NUL\132X",PropCorrelationData "\251\174.\203c\245c\ACKT\CAN\154\174)\224{\138\214#\251p:\210c\161",PropTopicAliasMaximum 23726,PropRetainAvailable 113,PropRequestResponseInformation 121,PropAuthenticationData "5\248\&1\239td\129\183\143\\",PropSessionExpiryInterval 15701,PropRequestResponseInformation 200,PropTopicAliasMaximum 14994,PropServerReference "y\166\163i\EMq|\DC1",PropAuthenticationData ")\213\253\152q\243FH\211\ENQm\135\188\&9\232\146\176\189H\CAN\227"] -TEST(SubACK5QCTest, Decode17) { -uint8_t pkt[] = {0x90, 0x98, 0x2, 0x38, 0xda, 0x90, 0x2, 0x23, 0x2b, 0xdd, 0x2, 0x0, 0x0, 0x7e, 0x8c, 0x1a, 0x0, 0x1a, 0xb7, 0x99, 0x24, 0x91, 0xb0, 0xc0, 0x6e, 0x67, 0xe7, 0x6e, 0x4d, 0x8, 0xa0, 0x93, 0xfd, 0x55, 0xf3, 0x6, 0x41, 0x2d, 0xa5, 0x23, 0x4, 0x9f, 0x11, 0x1f, 0x16, 0x0, 0xd, 0x27, 0x6e, 0x9f, 0x64, 0xb0, 0x3f, 0x33, 0xcc, 0x6b, 0xd9, 0x26, 0x25, 0xc5, 0x25, 0xfa, 0x2, 0x0, 0x0, 0x15, 0xc7, 0x16, 0x0, 0xc, 0x88, 0xb1, 0xa2, 0xad, 0xf1, 0x98, 0x22, 0xad, 0xcc, 0x7f, 0x4f, 0x10, 0x22, 0x6c, 0xe8, 0x18, 0x0, 0x0, 0x0, 0xeb, 0x29, 0x3, 0x24, 0x37, 0x2a, 0x5, 0x17, 0xa3, 0xb, 0x8, 0xb, 0x16, 0x26, 0x0, 0x1e, 0x5c, 0x49, 0x2e, 0x44, 0x3c, 0x8f, 0xd5, 0xc3, 0x93, 0x9d, 0x29, 0x18, 0x4b, 0x95, 0x8a, 0xff, 0x2f, 0x61, 0xe2, 0xc4, 0xb8, 0x3c, 0xa9, 0xc9, 0xe3, 0x5c, 0x84, 0xbc, 0x62, 0x5f, 0x0, 0xa, 0x11, 0x16, 0xd9, 0x7a, 0xcb, 0x7d, 0x3, 0xbb, 0x3b, 0x5c, 0x18, 0x0, 0x0, 0x2c, 0x65, 0x1, 0x74, 0x1c, 0x0, 0x5, 0xd3, 0xed, 0xb0, 0xc1, 0x16, 0x1a, 0x0, 0x16, 0x5c, 0x76, 0x1a, 0x47, 0x7a, 0x6d, 0xb9, 0xa2, 0x9d, 0x29, 0xc8, 0x40, 0x21, 0xeb, 0x23, 0xf3, 0x49, 0xed, 0x92, 0x0, 0x84, 0x58, 0x9, 0x0, 0x18, 0xfb, 0xae, 0x2e, 0xcb, 0x63, 0xf5, 0x63, 0x6, 0x54, 0x18, 0x9a, 0xae, 0x29, 0xe0, 0x7b, 0x8a, 0xd6, 0x23, 0xfb, 0x70, 0x3a, 0xd2, 0x63, 0xa1, 0x22, 0x5c, 0xae, 0x25, 0x71, 0x19, 0x79, 0x16, 0x0, 0xa, 0x35, 0xf8, 0x31, 0xef, 0x74, 0x64, 0x81, 0xb7, 0x8f, 0x5c, 0x11, 0x0, 0x0, 0x3d, 0x55, 0x19, 0xc8, 0x22, 0x3a, 0x92, 0x1c, 0x0, 0x8, 0x79, 0xa6, 0xa3, 0x69, 0x19, 0x71, 0x7c, 0x11, 0x16, 0x0, 0x15, 0x29, 0xd5, 0xfd, 0x98, 0x71, 0xf3, 0x46, 0x48, 0xd3, 0x5, 0x6d, 0x87, 0xbc, 0x39, 0xe8, 0x92, 0xb0, 0xbd, 0x48, 0x18, 0xe3, 0x0, 0x2, 0x80, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[4]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 4, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 14554); -EXPECT_EQ(count, 4); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[2], 0x80); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x8d, 0x1c, 0x3, 0xa2, 0xcc, 0x27, 0x85, 0x10, 0x37, 0xed, 0x8c, 0x5c, 0x77, + 0x3e, 0xfc, 0x3a, 0x7, 0x53, 0xa1, 0x73, 0xf, 0xb3, 0x3a, 0xf8, 0x96, 0x45}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2a, 0x2c, 0xb0, 0x8f, 0xfe, 0x52, 0xf1, 0xf2, 0x10, + 0xad, 0x61, 0x2e, 0xe1, 0x97, 0x9f, 0x49, 0x3a, 0xa1}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5c, 0x58, 0x24, 0xfb, 0xed, 0xfb, 0x57, 0xd7, 0x50, 0x7, + 0x85, 0x41, 0xa3, 0x91, 0xe1, 0x44, 0x16, 0x5e, 0xa3, 0x8, + 0x66, 0xed, 0xae, 0x2, 0x8d, 0xe6, 0xbd, 0x77, 0xa1, 0xa2}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd9, 0xb6, 0x2d, 0xa9, 0xa9, 0xad, 0xbf, 0x48, 0x78, 0x40, 0xce, 0x51, 0x69, + 0xbc, 0xe7, 0xd2, 0x44, 0xa5, 0x0, 0xa5, 0x5, 0xdc, 0xe8, 0xe0, 0xe2, 0x3e}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 907, 4, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 24572 +// ["\209r2\129\173f\255\143\237!\188m\134\&4#\167\156\211[@D\181\SO\161\210\n\235\&4","\133\164\149\&5\205\251\223","Bf.\183r\147H\252","/\130V\141\130\200\131\248\b\162Eb\DC2\EM\202r\182\251\FSKJ\186"] +// [] +TEST(Unsubscribe311QCTest, Encode21) { + uint8_t pkt[] = {0xa2, 0x4b, 0x5f, 0xfc, 0x0, 0x1c, 0xd1, 0x72, 0x32, 0x81, 0xad, 0x66, 0xff, 0x8f, 0xed, 0x21, + 0xbc, 0x6d, 0x86, 0x34, 0x23, 0xa7, 0x9c, 0xd3, 0x5b, 0x40, 0x44, 0xb5, 0xe, 0xa1, 0xd2, 0xa, + 0xeb, 0x34, 0x0, 0x7, 0x85, 0xa4, 0x95, 0x35, 0xcd, 0xfb, 0xdf, 0x0, 0x8, 0x42, 0x66, 0x2e, + 0xb7, 0x72, 0x93, 0x48, 0xfc, 0x0, 0x16, 0x2f, 0x82, 0x56, 0x8d, 0x82, 0xc8, 0x83, 0xf8, 0x8, + 0xa2, 0x45, 0x62, 0x12, 0x19, 0xca, 0x72, 0xb6, 0xfb, 0x1c, 0x4b, 0x4a, 0xba}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 22626 [Right QoS2,Right QoS1,Left SubErrImplementationSpecificError,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported] [PropContentType "\NAKQs\155\134\195\&7\191\171",PropResponseTopic "z\151",PropWildcardSubscriptionAvailable 95,PropCorrelationData "Y\180\142\DC2\249\235\141\137\v_\b\166\197\176\n\174k/\237\175\181{\190",PropServerReference "Xd\225\NUL\190jz\r\187\247\ETX[;\221\210\168\241l*\216\ACK\GS",PropWildcardSubscriptionAvailable 46,PropSharedSubscriptionAvailable 119,PropContentType "\247\173\146D\186\166s\171\EMs\171\233\140aE\188z.bQ\DEL\140\226",PropWildcardSubscriptionAvailable 21,PropContentType "\ETB\187\202\162\212q\DC2\214^\176\131\128X$}\185F",PropMaximumPacketSize 16829,PropReasonString "j\146z\153",PropSharedSubscriptionAvailable 43,PropRequestResponseInformation 33,PropMessageExpiryInterval 11523,PropAuthenticationMethod "\213\SO\191\202",PropContentType "\GS\131\DC3\233\213pd\242\131A@\146E\199",PropResponseInformation "\150\241\SI\SYN[\196",PropReasonString "\206Ck\149\215\221",PropReasonString "\223\DC45\167\185\177jw)\164\221:\252\199\147\245\239\147\SOH\v",PropServerKeepAlive 2942] -TEST(SubACK5QCTest, Decode18) { -uint8_t pkt[] = {0x90, 0xdd, 0x1, 0x58, 0x62, 0xd3, 0x1, 0x3, 0x0, 0x9, 0x15, 0x51, 0x73, 0x9b, 0x86, 0xc3, 0x37, 0xbf, 0xab, 0x8, 0x0, 0x2, 0x7a, 0x97, 0x28, 0x5f, 0x9, 0x0, 0x17, 0x59, 0xb4, 0x8e, 0x12, 0xf9, 0xeb, 0x8d, 0x89, 0xb, 0x5f, 0x8, 0xa6, 0xc5, 0xb0, 0xa, 0xae, 0x6b, 0x2f, 0xed, 0xaf, 0xb5, 0x7b, 0xbe, 0x1c, 0x0, 0x16, 0x58, 0x64, 0xe1, 0x0, 0xbe, 0x6a, 0x7a, 0xd, 0xbb, 0xf7, 0x3, 0x5b, 0x3b, 0xdd, 0xd2, 0xa8, 0xf1, 0x6c, 0x2a, 0xd8, 0x6, 0x1d, 0x28, 0x2e, 0x2a, 0x77, 0x3, 0x0, 0x17, 0xf7, 0xad, 0x92, 0x44, 0xba, 0xa6, 0x73, 0xab, 0x19, 0x73, 0xab, 0xe9, 0x8c, 0x61, 0x45, 0xbc, 0x7a, 0x2e, 0x62, 0x51, 0x7f, 0x8c, 0xe2, 0x28, 0x15, 0x3, 0x0, 0x11, 0x17, 0xbb, 0xca, 0xa2, 0xd4, 0x71, 0x12, 0xd6, 0x5e, 0xb0, 0x83, 0x80, 0x58, 0x24, 0x7d, 0xb9, 0x46, 0x27, 0x0, 0x0, 0x41, 0xbd, 0x1f, 0x0, 0x4, 0x6a, 0x92, 0x7a, 0x99, 0x2a, 0x2b, 0x19, 0x21, 0x2, 0x0, 0x0, 0x2d, 0x3, 0x15, 0x0, 0x4, 0xd5, 0xe, 0xbf, 0xca, 0x3, 0x0, 0xe, 0x1d, 0x83, 0x13, 0xe9, 0xd5, 0x70, 0x64, 0xf2, 0x83, 0x41, 0x40, 0x92, 0x45, 0xc7, 0x1a, 0x0, 0x6, 0x96, 0xf1, 0xf, 0x16, 0x5b, 0xc4, 0x1f, 0x0, 0x6, 0xce, 0x43, 0x6b, 0x95, 0xd7, 0xdd, 0x1f, 0x0, 0x14, 0xdf, 0x14, 0x35, 0xa7, 0xb9, 0xb1, 0x6a, 0x77, 0x29, 0xa4, 0xdd, 0x3a, 0xfc, 0xc7, 0x93, 0xf5, 0xef, 0x93, 0x1, 0xb, 0x13, 0xb, 0x7e, 0x2, 0x1, 0x83, 0x2, 0x2, 0x9e}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 22626); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[2], 0x83); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[5], 0x9E); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xd1, 0x72, 0x32, 0x81, 0xad, 0x66, 0xff, 0x8f, 0xed, 0x21, + 0xbc, 0x6d, 0x86, 0x34, 0x23, 0xa7, 0x9c, 0xd3, 0x5b, 0x40, + 0x44, 0xb5, 0xe, 0xa1, 0xd2, 0xa, 0xeb, 0x34}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x85, 0xa4, 0x95, 0x35, 0xcd, 0xfb, 0xdf}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x42, 0x66, 0x2e, 0xb7, 0x72, 0x93, 0x48, 0xfc}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x2f, 0x82, 0x56, 0x8d, 0x82, 0xc8, 0x83, 0xf8, 0x8, 0xa2, 0x45, + 0x62, 0x12, 0x19, 0xca, 0x72, 0xb6, 0xfb, 0x1c, 0x4b, 0x4a, 0xba}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24572, 4, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 22215 +// ["tkb\217BA\193-\r\243\141\144\131?#\SO\181p\150,\n\DEL)!","`\148\&8\EOT\EM\209\DLEI\193\218\148\180?\184X`,","\177V]\a8>\139\248\US\158\&4Pz\232|\147S\229\149\145\150\170\185\240'","\242M!M\182ds\247I\DEL\233\&0X),\206\155\200\232\182","s\SOH\149\210\176E\148\180\164\142\v\225gk\198\168\139/\161\240\249T\155)\140*","\165\EM\192\148-\241\213\188\182w\155\ESC*\NUL\RS*)\177h","\244\148-\DC3A\174,d\225\215d\170x"] +// [] +TEST(Unsubscribe311QCTest, Encode22) { + uint8_t pkt[] = {0xa2, 0xa0, 0x1, 0x56, 0xc7, 0x0, 0x18, 0x74, 0x6b, 0x62, 0xd9, 0x42, 0x41, 0xc1, 0x2d, 0xd, 0xf3, + 0x8d, 0x90, 0x83, 0x3f, 0x23, 0xe, 0xb5, 0x70, 0x96, 0x2c, 0xa, 0x7f, 0x29, 0x21, 0x0, 0x11, 0x60, + 0x94, 0x38, 0x4, 0x19, 0xd1, 0x10, 0x49, 0xc1, 0xda, 0x94, 0xb4, 0x3f, 0xb8, 0x58, 0x60, 0x2c, 0x0, + 0x19, 0xb1, 0x56, 0x5d, 0x7, 0x38, 0x3e, 0x8b, 0xf8, 0x1f, 0x9e, 0x34, 0x50, 0x7a, 0xe8, 0x7c, 0x93, + 0x53, 0xe5, 0x95, 0x91, 0x96, 0xaa, 0xb9, 0xf0, 0x27, 0x0, 0x14, 0xf2, 0x4d, 0x21, 0x4d, 0xb6, 0x64, + 0x73, 0xf7, 0x49, 0x7f, 0xe9, 0x30, 0x58, 0x29, 0x2c, 0xce, 0x9b, 0xc8, 0xe8, 0xb6, 0x0, 0x1a, 0x73, + 0x1, 0x95, 0xd2, 0xb0, 0x45, 0x94, 0xb4, 0xa4, 0x8e, 0xb, 0xe1, 0x67, 0x6b, 0xc6, 0xa8, 0x8b, 0x2f, + 0xa1, 0xf0, 0xf9, 0x54, 0x9b, 0x29, 0x8c, 0x2a, 0x0, 0x13, 0xa5, 0x19, 0xc0, 0x94, 0x2d, 0xf1, 0xd5, + 0xbc, 0xb6, 0x77, 0x9b, 0x1b, 0x2a, 0x0, 0x1e, 0x2a, 0x29, 0xb1, 0x68, 0x0, 0xd, 0xf4, 0x94, 0x2d, + 0x13, 0x41, 0xae, 0x2c, 0x64, 0xe1, 0xd7, 0x64, 0xaa, 0x78}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; -// SubscribeResponse 22779 [Right QoS0] [PropReceiveMaximum 29958,PropUserProperty "V\171\199J\148\167\152\DC2Y\DEL(\168\222F\189u>y\159(:\230\213(\203\162m\DELs1" "\DLE\230\222\163\163Bhd",PropRequestProblemInformation 33,PropTopicAliasMaximum 13111,PropRequestProblemInformation 159,PropSessionExpiryInterval 24873,PropRequestProblemInformation 74,PropSubscriptionIdentifier 7,PropSessionExpiryInterval 694,PropWillDelayInterval 1746,PropAuthenticationMethod "\ETB\tp9\166\DC3\183",PropMaximumPacketSize 32621,PropServerReference "\151\202^\135\235\227\DLEGFc]\236\142\184\128\248\156]\136\186C",PropPayloadFormatIndicator 120,PropMaximumQoS 100,PropMessageExpiryInterval 11802] -TEST(SubACK5QCTest, Decode19) { -uint8_t pkt[] = {0x90, 0x7c, 0x58, 0xfb, 0x78, 0x21, 0x75, 0x6, 0x26, 0x0, 0x1e, 0x56, 0xab, 0xc7, 0x4a, 0x94, 0xa7, 0x98, 0x12, 0x59, 0x7f, 0x28, 0xa8, 0xde, 0x46, 0xbd, 0x75, 0x3e, 0x79, 0x9f, 0x28, 0x3a, 0xe6, 0xd5, 0x28, 0xcb, 0xa2, 0x6d, 0x7f, 0x73, 0x31, 0x0, 0x8, 0x10, 0xe6, 0xde, 0xa3, 0xa3, 0x42, 0x68, 0x64, 0x17, 0x21, 0x22, 0x33, 0x37, 0x17, 0x9f, 0x11, 0x0, 0x0, 0x61, 0x29, 0x17, 0x4a, 0xb, 0x7, 0x11, 0x0, 0x0, 0x2, 0xb6, 0x18, 0x0, 0x0, 0x6, 0xd2, 0x15, 0x0, 0x7, 0x17, 0x9, 0x70, 0x39, 0xa6, 0x13, 0xb7, 0x27, 0x0, 0x0, 0x7f, 0x6d, 0x1c, 0x0, 0x15, 0x97, 0xca, 0x5e, 0x87, 0xeb, 0xe3, 0x10, 0x47, 0x46, 0x63, 0x5d, 0xec, 0x8e, 0xb8, 0x80, 0xf8, 0x9c, 0x5d, 0x88, 0xba, 0x43, 0x1, 0x78, 0x24, 0x64, 0x2, 0x0, 0x0, 0x2e, 0x1a, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 22779); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x74, 0x6b, 0x62, 0xd9, 0x42, 0x41, 0xc1, 0x2d, 0xd, 0xf3, 0x8d, 0x90, + 0x83, 0x3f, 0x23, 0xe, 0xb5, 0x70, 0x96, 0x2c, 0xa, 0x7f, 0x29, 0x21}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x60, 0x94, 0x38, 0x4, 0x19, 0xd1, 0x10, 0x49, 0xc1, + 0xda, 0x94, 0xb4, 0x3f, 0xb8, 0x58, 0x60, 0x2c}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb1, 0x56, 0x5d, 0x7, 0x38, 0x3e, 0x8b, 0xf8, 0x1f, 0x9e, 0x34, 0x50, 0x7a, + 0xe8, 0x7c, 0x93, 0x53, 0xe5, 0x95, 0x91, 0x96, 0xaa, 0xb9, 0xf0, 0x27}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf2, 0x4d, 0x21, 0x4d, 0xb6, 0x64, 0x73, 0xf7, 0x49, 0x7f, + 0xe9, 0x30, 0x58, 0x29, 0x2c, 0xce, 0x9b, 0xc8, 0xe8, 0xb6}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x73, 0x1, 0x95, 0xd2, 0xb0, 0x45, 0x94, 0xb4, 0xa4, 0x8e, 0xb, 0xe1, 0x67, + 0x6b, 0xc6, 0xa8, 0x8b, 0x2f, 0xa1, 0xf0, 0xf9, 0x54, 0x9b, 0x29, 0x8c, 0x2a}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa5, 0x19, 0xc0, 0x94, 0x2d, 0xf1, 0xd5, 0xbc, 0xb6, 0x77, + 0x9b, 0x1b, 0x2a, 0x0, 0x1e, 0x2a, 0x29, 0xb1, 0x68}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xf4, 0x94, 0x2d, 0x13, 0x41, 0xae, 0x2c, 0x64, 0xe1, 0xd7, 0x64, 0xaa, 0x78}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22215, 7, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 6585 +// ["\230\183q\150\255f\RS\133,\EM\151s\DC4","\160\239\214T\CANS\255\134\169\182\167ri\233\201","B\149Ms7\DC2\234x\185t\233\239\247\EOT\150\\\225\NUL\DC4\SO$\tP\190\DC3","\231\130\&50\142?\232\228\STX\183\182\159h\211\140\218N\ESC\ENQL\161=\158\251\166","\218\230\&2\130\163\DLE","\130q\162\EOT:\240\"\206`\134|\162","l\185N\132\177\203*","SB\DC1\\\186\191\167iq\187\204\a\NAK\137\214u\155\n"] +// [] +TEST(Unsubscribe311QCTest, Encode23) { + uint8_t pkt[] = {0xa2, 0x8b, 0x1, 0x19, 0xb9, 0x0, 0xd, 0xe6, 0xb7, 0x71, 0x96, 0xff, 0x66, 0x1e, 0x85, 0x2c, + 0x19, 0x97, 0x73, 0x14, 0x0, 0xf, 0xa0, 0xef, 0xd6, 0x54, 0x18, 0x53, 0xff, 0x86, 0xa9, 0xb6, + 0xa7, 0x72, 0x69, 0xe9, 0xc9, 0x0, 0x19, 0x42, 0x95, 0x4d, 0x73, 0x37, 0x12, 0xea, 0x78, 0xb9, + 0x74, 0xe9, 0xef, 0xf7, 0x4, 0x96, 0x5c, 0xe1, 0x0, 0x14, 0xe, 0x24, 0x9, 0x50, 0xbe, 0x13, + 0x0, 0x19, 0xe7, 0x82, 0x35, 0x30, 0x8e, 0x3f, 0xe8, 0xe4, 0x2, 0xb7, 0xb6, 0x9f, 0x68, 0xd3, + 0x8c, 0xda, 0x4e, 0x1b, 0x5, 0x4c, 0xa1, 0x3d, 0x9e, 0xfb, 0xa6, 0x0, 0x6, 0xda, 0xe6, 0x32, + 0x82, 0xa3, 0x10, 0x0, 0xc, 0x82, 0x71, 0xa2, 0x4, 0x3a, 0xf0, 0x22, 0xce, 0x60, 0x86, 0x7c, + 0xa2, 0x0, 0x7, 0x6c, 0xb9, 0x4e, 0x84, 0xb1, 0xcb, 0x2a, 0x0, 0x12, 0x53, 0x42, 0x11, 0x5c, + 0xba, 0xbf, 0xa7, 0x69, 0x71, 0xbb, 0xcc, 0x7, 0x15, 0x89, 0xd6, 0x75, 0x9b, 0xa}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 12719 [Left SubErrNotAuthorized,Right QoS0] [PropServerReference "On\212\204\ACK\209\154\SYN\211\240\142\200\150e\196\205\231\182k#zX\243\133\134\252\185",PropMessageExpiryInterval 8103,PropRetainAvailable 64,PropRequestProblemInformation 145,PropWillDelayInterval 29614,PropRequestProblemInformation 189,PropAssignedClientIdentifier "\SUB\170",PropTopicAlias 12053,PropServerReference "",PropServerKeepAlive 16570,PropAuthenticationData "a\255\197g\177(\228\\\145\SYN\208&l",PropContentType "\201\&1\255\&5\140L\239J^'\200I\158\199,$\164\214\213",PropMaximumQoS 168,PropAuthenticationMethod "\161\202\242?\244\&9\149\181\177\169v \217",PropResponseTopic "\207T\201-\208\160\192\248\vWR\179\132",PropReasonString "\146i\153\200\b\\b\232\157a--_\155e\192",PropRetainAvailable 3,PropCorrelationData "\141",PropSharedSubscriptionAvailable 187,PropResponseTopic "\CAN\133\226qc\NUL\150\134\154\SUB5&\225Y1&\a}\173\255\133\148z@\207",PropCorrelationData "M,\EM7\137\200\US\159{",PropTopicAlias 24670,PropMaximumPacketSize 19132,PropAssignedClientIdentifier "8\160AH\SI\RS\ng\200\&9P\217\240\&0\236\168\164f&\t",PropRetainAvailable 254,PropAuthenticationMethod "\254\154'i\SUB\DC2\"K\179><\r\188\CAN9\252>\195\DC3\ETX\147g\188\&5\132l"] -TEST(SubACK5QCTest, Decode20) { -uint8_t pkt[] = {0x90, 0x8b, 0x2, 0x31, 0xaf, 0x85, 0x2, 0x1c, 0x0, 0x1b, 0x4f, 0x6e, 0xd4, 0xcc, 0x6, 0xd1, 0x9a, 0x16, 0xd3, 0xf0, 0x8e, 0xc8, 0x96, 0x65, 0xc4, 0xcd, 0xe7, 0xb6, 0x6b, 0x23, 0x7a, 0x58, 0xf3, 0x85, 0x86, 0xfc,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, 0x39, 0x50, 0xd9, 0xf0, 0x30, 0xec, 0xa8, 0xa4, 0x66, 0x26, 0x9, 0x25, 0xfe, 0x15, 0x0, 0x1a, 0xfe, 0x9a, 0x27, 0x69, 0x1a, 0x12, 0x22, 0x4b, 0xb3, 0x3e, 0x3c, 0xd, 0xbc, 0x18, 0x39, 0xfc, 0x3e, 0xc3, 0x13, 0x3, 0x93, 0x67, 0xbc, 0x35, 0x84, 0x6c, 0x87, 0x0}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[2]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 2, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 12719); -EXPECT_EQ(count, 2); -EXPECT_EQ(granted_qos_levels[0], 0x87); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xe6, 0xb7, 0x71, 0x96, 0xff, 0x66, 0x1e, 0x85, 0x2c, 0x19, 0x97, 0x73, 0x14}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa0, 0xef, 0xd6, 0x54, 0x18, 0x53, 0xff, 0x86, + 0xa9, 0xb6, 0xa7, 0x72, 0x69, 0xe9, 0xc9}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x42, 0x95, 0x4d, 0x73, 0x37, 0x12, 0xea, 0x78, 0xb9, 0x74, 0xe9, 0xef, 0xf7, + 0x4, 0x96, 0x5c, 0xe1, 0x0, 0x14, 0xe, 0x24, 0x9, 0x50, 0xbe, 0x13}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe7, 0x82, 0x35, 0x30, 0x8e, 0x3f, 0xe8, 0xe4, 0x2, 0xb7, 0xb6, 0x9f, 0x68, + 0xd3, 0x8c, 0xda, 0x4e, 0x1b, 0x5, 0x4c, 0xa1, 0x3d, 0x9e, 0xfb, 0xa6}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xda, 0xe6, 0x32, 0x82, 0xa3, 0x10}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x82, 0x71, 0xa2, 0x4, 0x3a, 0xf0, 0x22, 0xce, 0x60, 0x86, 0x7c, 0xa2}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x6c, 0xb9, 0x4e, 0x84, 0xb1, 0xcb, 0x2a}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x53, 0x42, 0x11, 0x5c, 0xba, 0xbf, 0xa7, 0x69, 0x71, + 0xbb, 0xcc, 0x7, 0x15, 0x89, 0xd6, 0x75, 0x9b, 0xa}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6585, 8, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 22838 +// ["@w%\186\210\164\154\ACKl\193]J?uN\fM\186","\206\247\DEL\254\199\EM\205\216\151KC\ETX\219\180etQ\135\188\195\197_\249\b","m\CAN\222\175|\164\198\ETBF","\186\147\228\156\151$\239K@\USJ\248\193`z\220\222\224M[\182","\154\n$qM4\nL\ETXb\ETX\241","K\154?\178\227p\162\200R\194\196","+\245t\230#}Ja\SOH\214x\220)\ESC\138\t\134\215J\222\131$dD\222","\169\191\191\193[\224tV&\218rG\196\SYNQ\224n\157\&7\215\165\207\153+\a\234\235","(\185\142\190\225\&7\FSf\147Obz\203\136||\198\&5\DC1\239\161\202","_>\198mEZ\153\&1\149\250r\146zt\ESC\239g\176\148\197\210\NUL\231-\212\138"] +// [] +TEST(Unsubscribe311QCTest, Encode24) { + uint8_t pkt[] = {0xa2, 0xd9, 0x1, 0x59, 0x36, 0x0, 0x12, 0x40, 0x77, 0x25, 0xba, 0xd2, 0xa4, 0x9a, 0x6, 0x6c, 0xc1, + 0x5d, 0x4a, 0x3f, 0x75, 0x4e, 0xc, 0x4d, 0xba, 0x0, 0x18, 0xce, 0xf7, 0x7f, 0xfe, 0xc7, 0x19, 0xcd, + 0xd8, 0x97, 0x4b, 0x43, 0x3, 0xdb, 0xb4, 0x65, 0x74, 0x51, 0x87, 0xbc, 0xc3, 0xc5, 0x5f, 0xf9, 0x8, + 0x0, 0x9, 0x6d, 0x18, 0xde, 0xaf, 0x7c, 0xa4, 0xc6, 0x17, 0x46, 0x0, 0x15, 0xba, 0x93, 0xe4, 0x9c, + 0x97, 0x24, 0xef, 0x4b, 0x40, 0x1f, 0x4a, 0xf8, 0xc1, 0x60, 0x7a, 0xdc, 0xde, 0xe0, 0x4d, 0x5b, 0xb6, + 0x0, 0xc, 0x9a, 0xa, 0x24, 0x71, 0x4d, 0x34, 0xa, 0x4c, 0x3, 0x62, 0x3, 0xf1, 0x0, 0xb, 0x4b, + 0x9a, 0x3f, 0xb2, 0xe3, 0x70, 0xa2, 0xc8, 0x52, 0xc2, 0xc4, 0x0, 0x19, 0x2b, 0xf5, 0x74, 0xe6, 0x23, + 0x7d, 0x4a, 0x61, 0x1, 0xd6, 0x78, 0xdc, 0x29, 0x1b, 0x8a, 0x9, 0x86, 0xd7, 0x4a, 0xde, 0x83, 0x24, + 0x64, 0x44, 0xde, 0x0, 0x1b, 0xa9, 0xbf, 0xbf, 0xc1, 0x5b, 0xe0, 0x74, 0x56, 0x26, 0xda, 0x72, 0x47, + 0xc4, 0x16, 0x51, 0xe0, 0x6e, 0x9d, 0x37, 0xd7, 0xa5, 0xcf, 0x99, 0x2b, 0x7, 0xea, 0xeb, 0x0, 0x16, + 0x28, 0xb9, 0x8e, 0xbe, 0xe1, 0x37, 0x1c, 0x66, 0x93, 0x4f, 0x62, 0x7a, 0xcb, 0x88, 0x7c, 0x7c, 0xc6, + 0x35, 0x11, 0xef, 0xa1, 0xca, 0x0, 0x1a, 0x5f, 0x3e, 0xc6, 0x6d, 0x45, 0x5a, 0x99, 0x31, 0x95, 0xfa, + 0x72, 0x92, 0x7a, 0x74, 0x1b, 0xef, 0x67, 0xb0, 0x94, 0xc5, 0xd2, 0x0, 0xe7, 0x2d, 0xd4, 0x8a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; -// SubscribeResponse 18524 [Right QoS2] [PropMaximumPacketSize 20730,PropWillDelayInterval 25373,PropSubscriptionIdentifierAvailable 57,PropWillDelayInterval 24371,PropRetainAvailable 14,PropRequestResponseInformation 160,PropAssignedClientIdentifier "4aG\n\131\189t\148\217b\209\209k\251\DC3\205\&5\186\173\133G.\147\145",PropTopicAliasMaximum 30097,PropPayloadFormatIndicator 113,PropWildcardSubscriptionAvailable 52,PropReasonString "q\SOHAL\FS\164vC\145\154\250\244\"\167\246\ESC",PropRequestResponseInformation 19] -TEST(SubACK5QCTest, Decode21) { -uint8_t pkt[] = {0x90, 0x50, 0x48, 0x5c, 0x4c, 0x27, 0x0, 0x0, 0x50, 0xfa, 0x18, 0x0, 0x0, 0x63, 0x1d, 0x29, 0x39, 0x18, 0x0, 0x0, 0x5f, 0x33, 0x25, 0xe, 0x19, 0xa0, 0x12, 0x0, 0x18, 0x34, 0x61, 0x47, 0xa, 0x83, 0xbd, 0x74, 0x94, 0xd9, 0x62, 0xd1, 0xd1, 0x6b, 0xfb, 0x13, 0xcd, 0x35, 0xba, 0xad, 0x85, 0x47, 0x2e, 0x93, 0x91, 0x22, 0x75, 0x91, 0x1, 0x71, 0x28, 0x34, 0x1f, 0x0, 0x10, 0x71, 0x1, 0x41, 0x4c, 0x1c, 0xa4, 0x76, 0x43, 0x91, 0x9a, 0xfa, 0xf4, 0x22, 0xa7, 0xf6, 0x1b, 0x19, 0x13, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 18524); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x40, 0x77, 0x25, 0xba, 0xd2, 0xa4, 0x9a, 0x6, 0x6c, + 0xc1, 0x5d, 0x4a, 0x3f, 0x75, 0x4e, 0xc, 0x4d, 0xba}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xce, 0xf7, 0x7f, 0xfe, 0xc7, 0x19, 0xcd, 0xd8, 0x97, 0x4b, 0x43, 0x3, + 0xdb, 0xb4, 0x65, 0x74, 0x51, 0x87, 0xbc, 0xc3, 0xc5, 0x5f, 0xf9, 0x8}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x6d, 0x18, 0xde, 0xaf, 0x7c, 0xa4, 0xc6, 0x17, 0x46}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xba, 0x93, 0xe4, 0x9c, 0x97, 0x24, 0xef, 0x4b, 0x40, 0x1f, 0x4a, + 0xf8, 0xc1, 0x60, 0x7a, 0xdc, 0xde, 0xe0, 0x4d, 0x5b, 0xb6}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9a, 0xa, 0x24, 0x71, 0x4d, 0x34, 0xa, 0x4c, 0x3, 0x62, 0x3, 0xf1}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x4b, 0x9a, 0x3f, 0xb2, 0xe3, 0x70, 0xa2, 0xc8, 0x52, 0xc2, 0xc4}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x2b, 0xf5, 0x74, 0xe6, 0x23, 0x7d, 0x4a, 0x61, 0x1, 0xd6, 0x78, 0xdc, 0x29, + 0x1b, 0x8a, 0x9, 0x86, 0xd7, 0x4a, 0xde, 0x83, 0x24, 0x64, 0x44, 0xde}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xa9, 0xbf, 0xbf, 0xc1, 0x5b, 0xe0, 0x74, 0x56, 0x26, 0xda, 0x72, 0x47, 0xc4, 0x16, + 0x51, 0xe0, 0x6e, 0x9d, 0x37, 0xd7, 0xa5, 0xcf, 0x99, 0x2b, 0x7, 0xea, 0xeb}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x28, 0xb9, 0x8e, 0xbe, 0xe1, 0x37, 0x1c, 0x66, 0x93, 0x4f, 0x62, + 0x7a, 0xcb, 0x88, 0x7c, 0x7c, 0xc6, 0x35, 0x11, 0xef, 0xa1, 0xca}; + lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x5f, 0x3e, 0xc6, 0x6d, 0x45, 0x5a, 0x99, 0x31, 0x95, 0xfa, 0x72, 0x92, 0x7a, + 0x74, 0x1b, 0xef, 0x67, 0xb0, 0x94, 0xc5, 0xd2, 0x0, 0xe7, 0x2d, 0xd4, 0x8a}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22838, 10, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 14034 ["1\217\143\SOH~W~\ETX +// \191\NUL\173|\218L\CAN\229\ESC\249\241\169\130","T\140qo","\128k\172\167\180\235\144\222\r\129\254?,\152\187+\228\178F\194\225","\244\CAN\230/\246X\247\&1,\208\222\235(\219%\246\172\225\254\191\189|\218'\253","\ENQ\133\178\EOT\241\135\222\201\220\164\&3\179\157\222T\189\253","\ETB\DC4\159\210\ETB0\218\213;\180\EM\227\244Lr\245\EOTn\NULh","\173.N\n~\219o\214\205\167\190\139\196\185\246\174\&3\STX\215\235\135a","\172g\bAu\187r\au-\DC4!!Vw +// |x","\211\&6\175\180c\153\187s\NUL\v\140Em\215\144\244\&3|\246\ESC&\239tD\243\239","]\US\226A\165\\|\206U6\249d\144\241On-\153"] +// [] +TEST(Unsubscribe311QCTest, Encode25) { + uint8_t pkt[] = {0xa2, 0xd7, 0x1, 0x36, 0xd2, 0x0, 0x16, 0x31, 0xd9, 0x8f, 0x1, 0x7e, 0x57, 0x7e, 0x3, 0x20, 0xbf, + 0x0, 0xad, 0x7c, 0xda, 0x4c, 0x18, 0xe5, 0x1b, 0xf9, 0xf1, 0xa9, 0x82, 0x0, 0x4, 0x54, 0x8c, 0x71, + 0x6f, 0x0, 0x15, 0x80, 0x6b, 0xac, 0xa7, 0xb4, 0xeb, 0x90, 0xde, 0xd, 0x81, 0xfe, 0x3f, 0x2c, 0x98, + 0xbb, 0x2b, 0xe4, 0xb2, 0x46, 0xc2, 0xe1, 0x0, 0x19, 0xf4, 0x18, 0xe6, 0x2f, 0xf6, 0x58, 0xf7, 0x31, + 0x2c, 0xd0, 0xde, 0xeb, 0x28, 0xdb, 0x25, 0xf6, 0xac, 0xe1, 0xfe, 0xbf, 0xbd, 0x7c, 0xda, 0x27, 0xfd, + 0x0, 0x11, 0x5, 0x85, 0xb2, 0x4, 0xf1, 0x87, 0xde, 0xc9, 0xdc, 0xa4, 0x33, 0xb3, 0x9d, 0xde, 0x54, + 0xbd, 0xfd, 0x0, 0x14, 0x17, 0x14, 0x9f, 0xd2, 0x17, 0x30, 0xda, 0xd5, 0x3b, 0xb4, 0x19, 0xe3, 0xf4, + 0x4c, 0x72, 0xf5, 0x4, 0x6e, 0x0, 0x68, 0x0, 0x16, 0xad, 0x2e, 0x4e, 0xa, 0x7e, 0xdb, 0x6f, 0xd6, + 0xcd, 0xa7, 0xbe, 0x8b, 0xc4, 0xb9, 0xf6, 0xae, 0x33, 0x2, 0xd7, 0xeb, 0x87, 0x61, 0x0, 0x12, 0xac, + 0x67, 0x8, 0x41, 0x75, 0xbb, 0x72, 0x7, 0x75, 0x2d, 0x14, 0x21, 0x21, 0x56, 0x77, 0x20, 0x7c, 0x78, + 0x0, 0x1a, 0xd3, 0x36, 0xaf, 0xb4, 0x63, 0x99, 0xbb, 0x73, 0x0, 0xb, 0x8c, 0x45, 0x6d, 0xd7, 0x90, + 0xf4, 0x33, 0x7c, 0xf6, 0x1b, 0x26, 0xef, 0x74, 0x44, 0xf3, 0xef, 0x0, 0x12, 0x5d, 0x1f, 0xe2, 0x41, + 0xa5, 0x5c, 0x7c, 0xce, 0x55, 0x36, 0xf9, 0x64, 0x90, 0xf1, 0x4f, 0x6e, 0x2d, 0x99}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; -// SubscribeResponse 12697 [Left SubErrPacketIdentifierInUse,Left SubErrPacketIdentifierInUse,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrNotAuthorized] [PropRequestResponseInformation 65,PropSubscriptionIdentifierAvailable 150,PropReasonString ")\b\223\213\173)\GS",PropUserProperty "" "\160)\146\f\167\DC4i\\\146",PropMessageExpiryInterval 27739,PropRequestResponseInformation 87,PropAuthenticationData "_\129[0]\150",PropRequestResponseInformation 81,PropMaximumQoS 234,PropMessageExpiryInterval 685] -TEST(SubACK5QCTest, Decode22) { -uint8_t pkt[] = {0x90, 0x3e, 0x31, 0x99, 0x35, 0x19, 0x41, 0x29, 0x96, 0x1f, 0x0, 0x7, 0x29, 0x8, 0xdf, 0xd5, 0xad, 0x29, 0x1d, 0x26, 0x0, 0x0, 0x0, 0x9, 0xa0, 0x29, 0x92, 0xc, 0xa7, 0x14, 0x69, 0x5c, 0x92, 0x2, 0x0, 0x0, 0x6c, 0x5b, 0x19, 0x57, 0x16, 0x0, 0x6, 0x5f, 0x81, 0x5b, 0x30, 0x5d, 0x96, 0x19, 0x51, 0x24, 0xea, 0x2, 0x0, 0x0, 0x2, 0xad, 0x91, 0x91, 0xa2, 0x9e, 0xa1, 0x87}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 12697); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], 0x91); -EXPECT_EQ(granted_qos_levels[1], 0x91); -EXPECT_EQ(granted_qos_levels[2], 0xA2); -EXPECT_EQ(granted_qos_levels[3], 0x9E); -EXPECT_EQ(granted_qos_levels[4], 0xA1); -EXPECT_EQ(granted_qos_levels[5], 0x87); - + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x31, 0xd9, 0x8f, 0x1, 0x7e, 0x57, 0x7e, 0x3, 0x20, 0xbf, 0x0, + 0xad, 0x7c, 0xda, 0x4c, 0x18, 0xe5, 0x1b, 0xf9, 0xf1, 0xa9, 0x82}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x54, 0x8c, 0x71, 0x6f}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x80, 0x6b, 0xac, 0xa7, 0xb4, 0xeb, 0x90, 0xde, 0xd, 0x81, 0xfe, + 0x3f, 0x2c, 0x98, 0xbb, 0x2b, 0xe4, 0xb2, 0x46, 0xc2, 0xe1}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf4, 0x18, 0xe6, 0x2f, 0xf6, 0x58, 0xf7, 0x31, 0x2c, 0xd0, 0xde, 0xeb, 0x28, + 0xdb, 0x25, 0xf6, 0xac, 0xe1, 0xfe, 0xbf, 0xbd, 0x7c, 0xda, 0x27, 0xfd}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x5, 0x85, 0xb2, 0x4, 0xf1, 0x87, 0xde, 0xc9, 0xdc, + 0xa4, 0x33, 0xb3, 0x9d, 0xde, 0x54, 0xbd, 0xfd}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x17, 0x14, 0x9f, 0xd2, 0x17, 0x30, 0xda, 0xd5, 0x3b, 0xb4, + 0x19, 0xe3, 0xf4, 0x4c, 0x72, 0xf5, 0x4, 0x6e, 0x0, 0x68}; + lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xad, 0x2e, 0x4e, 0xa, 0x7e, 0xdb, 0x6f, 0xd6, 0xcd, 0xa7, 0xbe, + 0x8b, 0xc4, 0xb9, 0xf6, 0xae, 0x33, 0x2, 0xd7, 0xeb, 0x87, 0x61}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xac, 0x67, 0x8, 0x41, 0x75, 0xbb, 0x72, 0x7, 0x75, + 0x2d, 0x14, 0x21, 0x21, 0x56, 0x77, 0x20, 0x7c, 0x78}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd3, 0x36, 0xaf, 0xb4, 0x63, 0x99, 0xbb, 0x73, 0x0, 0xb, 0x8c, 0x45, 0x6d, + 0xd7, 0x90, 0xf4, 0x33, 0x7c, 0xf6, 0x1b, 0x26, 0xef, 0x74, 0x44, 0xf3, 0xef}; + lwmqtt_string_t topic_filter_s8 = {26, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x5d, 0x1f, 0xe2, 0x41, 0xa5, 0x5c, 0x7c, 0xce, 0x55, + 0x36, 0xf9, 0x64, 0x90, 0xf1, 0x4f, 0x6e, 0x2d, 0x99}; + lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14034, 10, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 22538 ["O\215\150\139h\178\159\233Bf\234x\tp\206\198\147s\142\236\132\SYN\221f\DELN\NAK\228\133"] +// [] +TEST(Unsubscribe311QCTest, Encode26) { + uint8_t pkt[] = {0xa2, 0x21, 0x58, 0xa, 0x0, 0x1d, 0x4f, 0xd7, 0x96, 0x8b, 0x68, 0xb2, + 0x9f, 0xe9, 0x42, 0x66, 0xea, 0x78, 0x9, 0x70, 0xce, 0xc6, 0x93, 0x73, + 0x8e, 0xec, 0x84, 0x16, 0xdd, 0x66, 0x7f, 0x4e, 0x15, 0xe4, 0x85}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 1694 [Left SubErrSubscriptionIdentifiersNotSupported] [PropSubscriptionIdentifier 29,PropRequestResponseInformation 43,PropMaximumPacketSize 2393,PropServerReference "`\253ve\"\180\148jD\DLEh\181?\225\205\ETB|\150)\DC2B\237|\155\191\EMi\ETX",PropWillDelayInterval 2584,PropServerReference "\152\129\248\ETB=\210\"\132",PropResponseTopic "\164I4uR\"\CAN/\218\252",PropRequestResponseInformation 236,PropWillDelayInterval 10307,PropMaximumPacketSize 21415,PropMessageExpiryInterval 11498,PropAssignedClientIdentifier "VB\b\171vn\237D\128\145\189\DEL\135\FS\235\185\238\SO\128\140\STX",PropReasonString "\204\188\153\162\248\a\SO\187\162Z\224R\252h?\\M \207W\238F\DC2p$\241K\234\171\240",PropReasonString "\198\194\180\NUL",PropResponseTopic "]",PropAuthenticationMethod "\187\196\SO\248\161\215T\166\252\237\248\ETX\177\241\ETB\169\SO\175\&6\151\&4H"] -TEST(SubACK5QCTest, Decode23) { -uint8_t pkt[] = {0x90, 0xb8, 0x1, 0x6, 0x9e, 0xb3, 0x1, 0xb, 0x1d, 0x19, 0x2b, 0x27, 0x0, 0x0, 0x9, 0x59, 0x1c, 0x0, 0x1c, 0x60, 0xfd, 0x76, 0x65, 0x22, 0xb4, 0x94, 0x6a, 0x44, 0x10, 0x68, 0xb5, 0x3f, 0xe1, 0xcd, 0x17, 0x7c, 0x96, 0x29, 0x12, 0x42, 0xed, 0x7c, 0x9b, 0xbf, 0x19, 0x69, 0x3, 0x18, 0x0, 0x0, 0xa, 0x18, 0x1c, 0x0, 0x8, 0x98, 0x81, 0xf8, 0x17, 0x3d, 0xd2, 0x22, 0x84, 0x8, 0x0, 0xa, 0xa4, 0x49, 0x34, 0x75, 0x52, 0x22, 0x18, 0x2f, 0xda, 0xfc, 0x19, 0xec, 0x18, 0x0, 0x0, 0x28, 0x43, 0x27, 0x0, 0x0, 0x53, 0xa7, 0x2, 0x0, 0x0, 0x2c, 0xea, 0x12, 0x0, 0x15, 0x56, 0x42, 0x8, 0xab, 0x76, 0x6e, 0xed, 0x44, 0x80, 0x91, 0xbd, 0x7f, 0x87, 0x1c, 0xeb, 0xb9, 0xee, 0xe, 0x80, 0x8c, 0x2, 0x1f, 0x0, 0x1e, 0xcc, 0xbc, 0x99, 0xa2, 0xf8, 0x7, 0xe, 0xbb, 0xa2, 0x5a, 0xe0, 0x52, 0xfc, 0x68, 0x3f, 0x5c, 0x4d, 0x20, 0xcf, 0x57, 0xee, 0x46, 0x12, 0x70, 0x24, 0xf1, 0x4b, 0xea, 0xab, 0xf0, 0x1f, 0x0, 0x4, 0xc6, 0xc2, 0xb4, 0x0, 0x8, 0x0, 0x1, 0x5d, 0x15, 0x0, 0x16, 0xbb, 0xc4, 0xe, 0xf8, 0xa1, 0xd7, 0x54, 0xa6, 0xfc, 0xed, 0xf8, 0x3, 0xb1, 0xf1, 0x17, 0xa9, 0xe, 0xaf, 0x36, 0x97, 0x34, 0x48, 0xa1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 1694); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], 0xA1); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x4f, 0xd7, 0x96, 0x8b, 0x68, 0xb2, 0x9f, 0xe9, 0x42, 0x66, + 0xea, 0x78, 0x9, 0x70, 0xce, 0xc6, 0x93, 0x73, 0x8e, 0xec, + 0x84, 0x16, 0xdd, 0x66, 0x7f, 0x4e, 0x15, 0xe4, 0x85}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22538, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 30444 +// ["GX)\EOT\193\GS\201A\196\169\SYN\180","\192\194c\139X\215\204<\ba\143\240^\173\198\169V\USFt\229\141;\n\223\215t","\228&\240","","R\164}j.u4\218\129\170\245j\245\192)\196","i\183\181;\182\142C","0|?r?\191\EOT==o\244\243@\198\NAK\218\155\158\NUL\151\184z","v\202.j\238\248\163T\167\148\158dl\249T\228Iv"] +// [] +TEST(Unsubscribe311QCTest, Encode27) { + uint8_t pkt[] = {0xa2, 0x7b, 0x76, 0xec, 0x0, 0xc, 0x47, 0x58, 0x29, 0x4, 0xc1, 0x1d, 0xc9, 0x41, 0xc4, 0xa9, + 0x16, 0xb4, 0x0, 0x1b, 0xc0, 0xc2, 0x63, 0x8b, 0x58, 0xd7, 0xcc, 0x3c, 0x8, 0x61, 0x8f, 0xf0, + 0x5e, 0xad, 0xc6, 0xa9, 0x56, 0x1f, 0x46, 0x74, 0xe5, 0x8d, 0x3b, 0xa, 0xdf, 0xd7, 0x74, 0x0, + 0x3, 0xe4, 0x26, 0xf0, 0x0, 0x0, 0x0, 0x10, 0x52, 0xa4, 0x7d, 0x6a, 0x2e, 0x75, 0x34, 0xda, + 0x81, 0xaa, 0xf5, 0x6a, 0xf5, 0xc0, 0x29, 0xc4, 0x0, 0x7, 0x69, 0xb7, 0xb5, 0x3b, 0xb6, 0x8e, + 0x43, 0x0, 0x16, 0x30, 0x7c, 0x3f, 0x72, 0x3f, 0xbf, 0x4, 0x3d, 0x3d, 0x6f, 0xf4, 0xf3, 0x40, + 0xc6, 0x15, 0xda, 0x9b, 0x9e, 0x0, 0x97, 0xb8, 0x7a, 0x0, 0x12, 0x76, 0xca, 0x2e, 0x6a, 0xee, + 0xf8, 0xa3, 0x54, 0xa7, 0x94, 0x9e, 0x64, 0x6c, 0xf9, 0x54, 0xe4, 0x49, 0x76}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 30899 [Right QoS1] [PropReceiveMaximum 27644,PropReceiveMaximum 8426,PropAuthenticationMethod "\245\194\219\EOT\156",PropTopicAlias 5286,PropMessageExpiryInterval 19925,PropMaximumQoS 126,PropWillDelayInterval 3267,PropMessageExpiryInterval 21796,PropReasonString "\174a\208\rg\222\233Z\129\163\150\&6\185\248,O\128\237",PropAuthenticationData "",PropReasonString "\EOT\t\173\&9\255\216LP\138'\EM\170x\198\235\a\CAN\196\217E!\EM\239\DC2",PropServerReference "29\139D\215\128\151\198\190\247\205)r\DC4\DC4Y\178\DC1\131",PropSubscriptionIdentifier 3,PropRequestResponseInformation 129,PropReasonString "\133\&5\EM\RS<\DEL\228\157|\215\244|\143\231\219\173Ol~V\166\162x\235E}\193\ENQ\218V",PropRequestResponseInformation 21,PropRequestResponseInformation 29,PropResponseInformation "R\151fy\168\191\234\146\"\CAN_\181\&4\"\223m\243A\NAK",PropResponseInformation "W\207v\217\244D!y\242\ACK",PropMessageExpiryInterval 9026,PropResponseInformation "\ESCvURy\155\138\133\253\143\ESC\254",PropContentType "\225\135\187\173\171\v.\243R\133\252\253\STX",PropContentType "]\206\US\t\139",PropAuthenticationData "\182\184\223D\211\ETX\243 )\139\156\251\&1\227\248"] -TEST(SubACK5QCTest, Decode24) { -uint8_t pkt[] = {0x90, 0xfa, 0x1, 0x78, 0xb3, 0xf5, 0x1, 0x21, 0x6b, 0xfc, 0x21, 0x20, 0xea, 0x15, 0x0, 0x5, 0xf5, 0xc2, 0xdb, 0x4, 0x9c, 0x23, 0x14, 0xa6, 0x2, 0x0, 0x0, 0x4d, 0xd5, 0x24, 0x7e, 0x18, 0x0, 0x0, 0xc, 0xc3, 0x2, 0x0, 0x0, 0x55, 0x24, 0x1f, 0x0, 0x12, 0xae, 0x61, 0xd0, 0xd, 0x67, 0xde, 0xe9, 0x5a, 0x81, 0xa3, 0x96, 0x36, 0xb9, 0xf8, 0x2c, 0x4f, 0x80, 0xed, 0x16, 0x0, 0x0, 0x1f, 0x0, 0x18, 0x4, 0x9, 0xad, 0x39, 0xff, 0xd8, 0x4c, 0x50, 0x8a, 0x27, 0x19, 0xaa, 0x78, 0xc6, 0xeb, 0x7, 0x18, 0xc4, 0xd9, 0x45, 0x21, 0x19, 0xef, 0x12, 0x1c, 0x0, 0x13, 0x32, 0x39, 0x8b, 0x44, 0xd7, 0x80, 0x97, 0xc6, 0xbe, 0xf7, 0xcd, 0x29, 0x72, 0x14, 0x14, 0x59, 0xb2, 0x11, 0x83, 0xb, 0x3, 0x19, 0x81, 0x1f, 0x0, 0x1e, 0x85, 0x35, 0x19, 0x1e, 0x3c, 0x7f, 0xe4, 0x9d, 0x7c, 0xd7, 0xf4, 0x7c, 0x8f, 0xe7, 0xdb, 0xad, 0x4f, 0x6c, 0x7e, 0x56, 0xa6, 0xa2, 0x78, 0xeb, 0x45, 0x7d, 0xc1, 0x5, 0xda, 0x56, 0x19, 0x15, 0x19, 0x1d, 0x1a, 0x0, 0x13, 0x52, 0x97, 0x66, 0x79, 0xa8, 0xbf, 0xea, 0x92, 0x22, 0x18, 0x5f, 0xb5, 0x34, 0x22, 0xdf, 0x6d, 0xf3, 0x41, 0x15, 0x1a, 0x0, 0xa, 0x57, 0xcf, 0x76, 0xd9, 0xf4, 0x44, 0x21, 0x79, 0xf2, 0x6, 0x2, 0x0, 0x0, 0x23, 0x42, 0x1a, 0x0, 0xc, 0x1b, 0x76, 0x55, 0x52, 0x79, 0x9b, 0x8a, 0x85, 0xfd, 0x8f, 0x1b, 0xfe, 0x3, 0x0, 0xd, 0xe1, 0x87, 0xbb, 0xad, 0xab, 0xb, 0x2e, 0xf3, 0x52, 0x85, 0xfc, 0xfd, 0x2, 0x3, 0x0, 0x5, 0x5d, 0xce, 0x1f, 0x9, 0x8b, 0x16, 0x0, 0xf, 0xb6, 0xb8, 0xdf, 0x44, 0xd3, 0x3, 0xf3, 0x20, 0x29, 0x8b, 0x9c, 0xfb, 0x31, 0xe3, 0xf8, 0x1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[1]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 1, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 30899); -EXPECT_EQ(count, 1); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x47, 0x58, 0x29, 0x4, 0xc1, 0x1d, 0xc9, 0x41, 0xc4, 0xa9, 0x16, 0xb4}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc0, 0xc2, 0x63, 0x8b, 0x58, 0xd7, 0xcc, 0x3c, 0x8, 0x61, 0x8f, 0xf0, 0x5e, 0xad, + 0xc6, 0xa9, 0x56, 0x1f, 0x46, 0x74, 0xe5, 0x8d, 0x3b, 0xa, 0xdf, 0xd7, 0x74}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe4, 0x26, 0xf0}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x52, 0xa4, 0x7d, 0x6a, 0x2e, 0x75, 0x34, 0xda, + 0x81, 0xaa, 0xf5, 0x6a, 0xf5, 0xc0, 0x29, 0xc4}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x69, 0xb7, 0xb5, 0x3b, 0xb6, 0x8e, 0x43}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x30, 0x7c, 0x3f, 0x72, 0x3f, 0xbf, 0x4, 0x3d, 0x3d, 0x6f, 0xf4, + 0xf3, 0x40, 0xc6, 0x15, 0xda, 0x9b, 0x9e, 0x0, 0x97, 0xb8, 0x7a}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x76, 0xca, 0x2e, 0x6a, 0xee, 0xf8, 0xa3, 0x54, 0xa7, + 0x94, 0x9e, 0x64, 0x6c, 0xf9, 0x54, 0xe4, 0x49, 0x76}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30444, 8, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 10904 +// ["\158\151(tQ&M3?\234\162qjZ\ENQ\146wd\180\249\&0","\148\148\181'\255Q\247\ETB\218\ESC\136\SYN\a\213\151t\229az1\208\253","z\245\157\159\151\241\225%\SOH^\129`\166\168\252\172\135}","|\SOq\189\SO","\ENQi\226\n}\143\149O\235\&1\SOHN\241\252\183GG\136\142"] +// [] +TEST(Unsubscribe311QCTest, Encode28) { + uint8_t pkt[] = {0xa2, 0x61, 0x2a, 0x98, 0x0, 0x15, 0x9e, 0x97, 0x28, 0x74, 0x51, 0x26, 0x4d, 0x33, 0x3f, 0xea, 0xa2, + 0x71, 0x6a, 0x5a, 0x5, 0x92, 0x77, 0x64, 0xb4, 0xf9, 0x30, 0x0, 0x16, 0x94, 0x94, 0xb5, 0x27, 0xff, + 0x51, 0xf7, 0x17, 0xda, 0x1b, 0x88, 0x16, 0x7, 0xd5, 0x97, 0x74, 0xe5, 0x61, 0x7a, 0x31, 0xd0, 0xfd, + 0x0, 0x12, 0x7a, 0xf5, 0x9d, 0x9f, 0x97, 0xf1, 0xe1, 0x25, 0x1, 0x5e, 0x81, 0x60, 0xa6, 0xa8, 0xfc, + 0xac, 0x87, 0x7d, 0x0, 0x5, 0x7c, 0xe, 0x71, 0xbd, 0xe, 0x0, 0x13, 0x5, 0x69, 0xe2, 0xa, 0x7d, + 0x8f, 0x95, 0x4f, 0xeb, 0x31, 0x1, 0x4e, 0xf1, 0xfc, 0xb7, 0x47, 0x47, 0x88, 0x8e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 15 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS2] [PropMaximumQoS 216,PropServerReference "A1\"\208\250\203&",PropWildcardSubscriptionAvailable 128,PropMaximumPacketSize 15978,PropUserProperty "W\146\r$\SI\aP&\149|v\208\222\US\128C\217\&4\159\209\128Z@Z" "\CAN+2\131\218!ZZz\192\142",PropResponseTopic ".\216\246&\RSF\130\136k\159\&3\197_[\138\v\145",PropSessionExpiryInterval 29247,PropServerKeepAlive 20272,PropCorrelationData "~N\219\182!\f^\247\172\ACK\148\254\153\159\221\208\129\FS\141\CAN\177\213C\219\135rU",PropResponseTopic "HU\222\186tp\236\RS(\174w\249\GS\220\NAK3t\156\160\147a\145w",PropMessageExpiryInterval 23404,PropMaximumQoS 41] -TEST(SubACK5QCTest, Decode25) { -uint8_t pkt[] = {0x90, 0xa0, 0x1, 0x0, 0xf, 0x96, 0x1, 0x24, 0xd8, 0x1c, 0x0, 0x7, 0x41, 0x31, 0x22, 0xd0, 0xfa, 0xcb, 0x26, 0x28, 0x80, 0x27, 0x0, 0x0, 0x3e, 0x6a, 0x26, 0x0, 0x18, 0x57, 0x92, 0xd, 0x24, 0xf, 0x7, 0x50, 0x26, 0x95, 0x7c, 0x76, 0xd0, 0xde, 0x1f, 0x80, 0x43, 0xd9, 0x34, 0x9f, 0xd1, 0x80, 0x5a, 0x40, 0x5a, 0x0, 0xb, 0x18, 0x2b, 0x32, 0x83, 0xda, 0x21, 0x5a, 0x5a, 0x7a, 0xc0, 0x8e, 0x8, 0x0, 0x11, 0x2e, 0xd8, 0xf6, 0x26, 0x1e, 0x46, 0x82, 0x88, 0x6b, 0x9f, 0x33, 0xc5, 0x5f, 0x5b, 0x8a, 0xb, 0x91, 0x11, 0x0, 0x0, 0x72, 0x3f, 0x13, 0x4f, 0x30, 0x9, 0x0, 0x1b, 0x7e, 0x4e, 0xdb, 0xb6, 0x21, 0xc, 0x5e, 0xf7, 0xac, 0x6, 0x94, 0xfe, 0x99, 0x9f, 0xdd, 0xd0, 0x81, 0x1c, 0x8d, 0x18, 0xb1, 0xd5, 0x43, 0xdb, 0x87, 0x72, 0x55, 0x8, 0x0, 0x17, 0x48, 0x55, 0xde, 0xba, 0x74, 0x70, 0xec, 0x1e, 0x28, 0xae, 0x77, 0xf9, 0x1d, 0xdc, 0x15, 0x33, 0x74, 0x9c, 0xa0, 0x93, 0x61, 0x91, 0x77, 0x2, 0x0, 0x0, 0x5b, 0x6c, 0x24, 0x29, 0xa1, 0x2, 0x2, 0x9e, 0x0, 0x2}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 15); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], 0xA1); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[3], 0x9E); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x9e, 0x97, 0x28, 0x74, 0x51, 0x26, 0x4d, 0x33, 0x3f, 0xea, 0xa2, + 0x71, 0x6a, 0x5a, 0x5, 0x92, 0x77, 0x64, 0xb4, 0xf9, 0x30}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x94, 0x94, 0xb5, 0x27, 0xff, 0x51, 0xf7, 0x17, 0xda, 0x1b, 0x88, + 0x16, 0x7, 0xd5, 0x97, 0x74, 0xe5, 0x61, 0x7a, 0x31, 0xd0, 0xfd}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x7a, 0xf5, 0x9d, 0x9f, 0x97, 0xf1, 0xe1, 0x25, 0x1, + 0x5e, 0x81, 0x60, 0xa6, 0xa8, 0xfc, 0xac, 0x87, 0x7d}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x7c, 0xe, 0x71, 0xbd, 0xe}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x5, 0x69, 0xe2, 0xa, 0x7d, 0x8f, 0x95, 0x4f, 0xeb, 0x31, + 0x1, 0x4e, 0xf1, 0xfc, 0xb7, 0x47, 0x47, 0x88, 0x8e}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10904, 5, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 5483 +// ["","\RSY|\167.\233=\245U,\193\250.\241\&8]Z\239\EOTi\DC2\193\235\212","\233\251\197\179\CAN\205\158\160\250\133\254\220\DC3\236\149k\249,w\223yf\239\240\193\&2\SO","1;\224awQA\b\129m\211-\177#y\130L;%\227\202'","\129\143;\208\166\210!h@\133","\212\213jo\156\238\193\DC2\188o\254\NUL\219\202","(\182Q\ENQ\158\220\233\233\228\196\226\218\163"] +// [] +TEST(Unsubscribe311QCTest, Encode29) { + uint8_t pkt[] = {0xa2, 0x7e, 0x15, 0x6b, 0x0, 0x0, 0x0, 0x18, 0x1e, 0x59, 0x7c, 0xa7, 0x2e, 0xe9, 0x3d, 0xf5, + 0x55, 0x2c, 0xc1, 0xfa, 0x2e, 0xf1, 0x38, 0x5d, 0x5a, 0xef, 0x4, 0x69, 0x12, 0xc1, 0xeb, 0xd4, + 0x0, 0x1b, 0xe9, 0xfb, 0xc5, 0xb3, 0x18, 0xcd, 0x9e, 0xa0, 0xfa, 0x85, 0xfe, 0xdc, 0x13, 0xec, + 0x95, 0x6b, 0xf9, 0x2c, 0x77, 0xdf, 0x79, 0x66, 0xef, 0xf0, 0xc1, 0x32, 0xe, 0x0, 0x16, 0x31, + 0x3b, 0xe0, 0x61, 0x77, 0x51, 0x41, 0x8, 0x81, 0x6d, 0xd3, 0x2d, 0xb1, 0x23, 0x79, 0x82, 0x4c, + 0x3b, 0x25, 0xe3, 0xca, 0x27, 0x0, 0xa, 0x81, 0x8f, 0x3b, 0xd0, 0xa6, 0xd2, 0x21, 0x68, 0x40, + 0x85, 0x0, 0xe, 0xd4, 0xd5, 0x6a, 0x6f, 0x9c, 0xee, 0xc1, 0x12, 0xbc, 0x6f, 0xfe, 0x0, 0xdb, + 0xca, 0x0, 0xd, 0x28, 0xb6, 0x51, 0x5, 0x9e, 0xdc, 0xe9, 0xe9, 0xe4, 0xc4, 0xe2, 0xda, 0xa3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 13923 [Right QoS2,Left SubErrNotAuthorized,Right QoS1,Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded] [PropContentType "\DC3\SUB@,\185k\226",PropSubscriptionIdentifier 12,PropMessageExpiryInterval 9419,PropReceiveMaximum 31538,PropServerReference "\154\168\128c",PropTopicAliasMaximum 16842,PropServerReference "aXA\247\138<\132:\161\198v",PropMaximumQoS 114,PropMessageExpiryInterval 15881,PropReceiveMaximum 9017,PropSharedSubscriptionAvailable 191,PropUserProperty "" "\NAK\193Ab\228\&4_\150\DEL\rd\128{\208I\163)/\SI\188\255\&1\132",PropUserProperty "\203\173\DC41\139\160\252" "\DC2r\208",PropUserProperty "\145s\208\152\243q\CAN\SYNbG\154J\144\193\157&\SOH\131k\250" "]L\172\152",PropMessageExpiryInterval 2098,PropServerReference "\154\203\&6\ETX\n\EOT\136P\186\208w6\215\143:_\EOT\254R\213L*^#\193E\142i",PropSubscriptionIdentifierAvailable 127,PropMaximumQoS 12,PropMaximumQoS 156] -TEST(SubACK5QCTest, Decode26) { -uint8_t pkt[] = {0x90, 0xb3, 0x1, 0x36, 0x63, 0xaa, 0x1, 0x3, 0x0, 0x7, 0x13, 0x1a, 0x40, 0x2c, 0xb9, 0x6b, 0xe2, 0xb, 0xc, 0x2, 0x0, 0x0, 0x24, 0xcb, 0x21, 0x7b, 0x32, 0x1c, 0x0, 0x4, 0x9a, 0xa8, 0x80, 0x63, 0x22, 0x41, 0xca, 0x1c, 0x0, 0xb, 0x61, 0x58, 0x41, 0xf7, 0x8a, 0x3c, 0x84, 0x3a, 0xa1, 0xc6, 0x76, 0x24, 0x72, 0x2, 0x0, 0x0, 0x3e, 0x9, 0x21, 0x23, 0x39, 0x2a, 0xbf, 0x26, 0x0, 0x0, 0x0, 0x17, 0x15, 0xc1, 0x41, 0x62, 0xe4, 0x34, 0x5f, 0x96, 0x7f, 0xd, 0x64, 0x80, 0x7b, 0xd0, 0x49, 0xa3, 0x29, 0x2f, 0xf, 0xbc, 0xff, 0x31, 0x84, 0x26, 0x0, 0x7, 0xcb, 0xad, 0x14, 0x31, 0x8b, 0xa0, 0xfc, 0x0, 0x3, 0x12, 0x72, 0xd0, 0x26, 0x0, 0x14, 0x91, 0x73, 0xd0, 0x98, 0xf3, 0x71, 0x18, 0x16, 0x62, 0x47, 0x9a, 0x4a, 0x90, 0xc1, 0x9d, 0x26, 0x1, 0x83, 0x6b, 0xfa, 0x0, 0x4, 0x5d, 0x4c, 0xac, 0x98, 0x2, 0x0, 0x0, 0x8, 0x32, 0x1c, 0x0, 0x1c, 0x9a, 0xcb, 0x36, 0x3, 0xa, 0x4, 0x88, 0x50, 0xba, 0xd0, 0x77, 0x36, 0xd7, 0x8f, 0x3a, 0x5f, 0x4, 0xfe, 0x52, 0xd5, 0x4c, 0x2a, 0x5e, 0x23, 0xc1, 0x45, 0x8e, 0x69, 0x29, 0x7f, 0x24, 0xc, 0x24, 0x9c, 0x2, 0x87, 0x1, 0x91, 0x97}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 13923); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[1], 0x87); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[3], 0x91); -EXPECT_EQ(granted_qos_levels[4], 0x97); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0x59, 0x7c, 0xa7, 0x2e, 0xe9, 0x3d, 0xf5, 0x55, 0x2c, 0xc1, 0xfa, + 0x2e, 0xf1, 0x38, 0x5d, 0x5a, 0xef, 0x4, 0x69, 0x12, 0xc1, 0xeb, 0xd4}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe9, 0xfb, 0xc5, 0xb3, 0x18, 0xcd, 0x9e, 0xa0, 0xfa, 0x85, 0xfe, 0xdc, 0x13, 0xec, + 0x95, 0x6b, 0xf9, 0x2c, 0x77, 0xdf, 0x79, 0x66, 0xef, 0xf0, 0xc1, 0x32, 0xe}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x31, 0x3b, 0xe0, 0x61, 0x77, 0x51, 0x41, 0x8, 0x81, 0x6d, 0xd3, + 0x2d, 0xb1, 0x23, 0x79, 0x82, 0x4c, 0x3b, 0x25, 0xe3, 0xca, 0x27}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x81, 0x8f, 0x3b, 0xd0, 0xa6, 0xd2, 0x21, 0x68, 0x40, 0x85}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xd4, 0xd5, 0x6a, 0x6f, 0x9c, 0xee, 0xc1, 0x12, 0xbc, 0x6f, 0xfe, 0x0, 0xdb, 0xca}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x28, 0xb6, 0x51, 0x5, 0x9e, 0xdc, 0xe9, 0xe9, 0xe4, 0xc4, 0xe2, 0xda, 0xa3}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5483, 7, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 27410 +// ["\142,\253\251\228\164\&6>\237\ETX\150\202\228\225\236\SUB\130}\144\142\196:\EOT","7$&\216\162\FSEn\RSsy\244]","\200\209D","\154,\164<","\211c\153","\DLE\221\175\212*","Pk)\217\129'\201\236\161\181o\176D\191L\241\158\153\EOT\228","#\231\205E\220\217&S\242","\211\145\204"] +// [] +TEST(Unsubscribe311QCTest, Encode30) { + uint8_t pkt[] = {0xa2, 0x67, 0x6b, 0x12, 0x0, 0x17, 0x8e, 0x2c, 0xfd, 0xfb, 0xe4, 0xa4, 0x36, 0x3e, 0xed, + 0x3, 0x96, 0xca, 0xe4, 0xe1, 0xec, 0x1a, 0x82, 0x7d, 0x90, 0x8e, 0xc4, 0x3a, 0x4, 0x0, + 0xd, 0x37, 0x24, 0x26, 0xd8, 0xa2, 0x1c, 0x45, 0x6e, 0x1e, 0x73, 0x79, 0xf4, 0x5d, 0x0, + 0x3, 0xc8, 0xd1, 0x44, 0x0, 0x4, 0x9a, 0x2c, 0xa4, 0x3c, 0x0, 0x3, 0xd3, 0x63, 0x99, + 0x0, 0x5, 0x10, 0xdd, 0xaf, 0xd4, 0x2a, 0x0, 0x14, 0x50, 0x6b, 0x29, 0xd9, 0x81, 0x27, + 0xc9, 0xec, 0xa1, 0xb5, 0x6f, 0xb0, 0x44, 0xbf, 0x4c, 0xf1, 0x9e, 0x99, 0x4, 0xe4, 0x0, + 0x9, 0x23, 0xe7, 0xcd, 0x45, 0xdc, 0xd9, 0x26, 0x53, 0xf2, 0x0, 0x3, 0xd3, 0x91, 0xcc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 6677 [Right QoS0,Right QoS1,Left SubErrImplementationSpecificError,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError] [PropSessionExpiryInterval 14683,PropSessionExpiryInterval 21434,PropAuthenticationData "D#\252\208F\157P\215J \205\186\251\251\139",PropAuthenticationData "\179\247",PropPayloadFormatIndicator 176,PropResponseTopic "\201\244\179\185o\NAK\177\\H\192\ETB\229\170\164\242T\136\149w",PropSubscriptionIdentifierAvailable 152,PropSharedSubscriptionAvailable 60,PropRetainAvailable 141,PropReceiveMaximum 27371,PropSubscriptionIdentifierAvailable 227,PropSubscriptionIdentifierAvailable 154,PropRetainAvailable 162,PropWillDelayInterval 19822,PropAssignedClientIdentifier "c",PropServerKeepAlive 6408,PropResponseInformation "\bF\129f\199\228\201\255\255\176\156\&1\238",PropReceiveMaximum 16984,PropSubscriptionIdentifier 28,PropAuthenticationData "\r\129\228\233\202R\160\164\240w\173\SUB\NULB?\245\204O\210\150\&5\226\141W\239\130\160G",PropMessageExpiryInterval 15050,PropAuthenticationMethod "\SOH\168\SYN!\224\166\237\228_\181\202\136\141\156\217\&9\252-\213\138>",PropResponseTopic "\250\217\206t\"\223\DC2Y\131\FS\139+\DEL\209h~\162\197YV>\DEL",PropServerKeepAlive 11130,PropSharedSubscriptionAvailable 136] -TEST(SubACK5QCTest, Decode27) { -uint8_t pkt[] = {0x90, 0xd2, 0x1, 0x1a, 0x15, 0xc3, 0x1, 0x11, 0x0, 0x0, 0x39, 0x5b, 0x11, 0x0, 0x0, 0x53, 0xba, 0x16, 0x0, 0xf, 0x44, 0x23, 0xfc, 0xd0, 0x46, 0x9d, 0x50, 0xd7, 0x4a, 0x20, 0xcd, 0xba, 0xfb, 0xfb, 0x8b, 0x16, 0x0, 0x2, 0xb3, 0xf7, 0x1, 0xb0, 0x8, 0x0, 0x13, 0xc9, 0xf4, 0xb3, 0xb9, 0x6f, 0x15, 0xb1, 0x5c, 0x48, 0xc0, 0x17, 0xe5, 0xaa, 0xa4, 0xf2, 0x54, 0x88, 0x95, 0x77, 0x29, 0x98, 0x2a, 0x3c, 0x25, 0x8d, 0x21, 0x6a, 0xeb, 0x29, 0xe3, 0x29, 0x9a, 0x25, 0xa2, 0x18, 0x0, 0x0, 0x4d, 0x6e, 0x12, 0x0, 0x1, 0x63, 0x13, 0x19, 0x8, 0x1a, 0x0, 0xd, 0x8, 0x46, 0x81, 0x66, 0xc7, 0xe4, 0xc9, 0xff, 0xff, 0xb0, 0x9c, 0x31, 0xee, 0x21, 0x42, 0x58, 0xb, 0x1c, 0x16, 0x0, 0x1c, 0xd, 0x81, 0xe4, 0xe9, 0xca, 0x52, 0xa0, 0xa4, 0xf0, 0x77, 0xad, 0x1a, 0x0, 0x42, 0x3f, 0xf5, 0xcc, 0x4f, 0xd2, 0x96, 0x35, 0xe2, 0x8d, 0x57, 0xef, 0x82, 0xa0, 0x47, 0x2, 0x0, 0x0, 0x3a, 0xca, 0x15, 0x0, 0x15, 0x1, 0xa8, 0x16, 0x21, 0xe0, 0xa6, 0xed, 0xe4, 0x5f, 0xb5, 0xca, 0x88, 0x8d, 0x9c, 0xd9, 0x39, 0xfc, 0x2d, 0xd5, 0x8a, 0x3e, 0x8, 0x0, 0x16, 0xfa, 0xd9, 0xce, 0x74, 0x22, 0xdf, 0x12, 0x59, 0x83, 0x1c, 0x8b, 0x2b, 0x7f, 0xd1, 0x68, 0x7e, 0xa2, 0xc5, 0x59, 0x56, 0x3e, 0x7f, 0x13, 0x2b, 0x7a, 0x2a, 0x88, 0x0, 0x1, 0x83, 0x1, 0x91, 0x0, 0x2, 0x2, 0x9e, 0x1, 0x83}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[11]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 11, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 6677); -EXPECT_EQ(count, 11); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[2], 0x83); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[4], 0x91); -EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[8], 0x9E); -EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[10], 0x83); - -} - - -// SubscribeResponse 12919 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported] [PropAuthenticationData "f\224~\151\161Ar\218B\165\171\200\130\128\253C\CAN\154\n\153$\ENQ\194\180\148\DC4\223",PropUserProperty "\DC2:#\184q]" "\NAK!_k\236\\m\170\201\173u\149\ETXD:\178\129\164\&6i",PropSubscriptionIdentifier 14,PropRequestResponseInformation 152,PropMessageExpiryInterval 30660,PropSubscriptionIdentifier 5,PropMessageExpiryInterval 24332,PropReceiveMaximum 32249,PropContentType "\178\174=\US~0v\136\187\229\252\f",PropRetainAvailable 253,PropSubscriptionIdentifierAvailable 1,PropServerKeepAlive 19906,PropSubscriptionIdentifierAvailable 54,PropAssignedClientIdentifier "\174o\138z\186\200\184@",PropSubscriptionIdentifier 19,PropWillDelayInterval 7801,PropResponseInformation "\160\SYN#s",PropCorrelationData "\145\SOH\144\133\ETBtn\172w\195j\164\161\205\151\229o\231\168%@UK",PropRequestResponseInformation 101,PropMaximumQoS 213,PropServerReference "u\RS\228\212T:Oz>\154\176\231La-\164,\166",PropCorrelationData "\169\SOH \\\197\209x:\b\176\t\226\\\222\GS\178IV\RSE\190\ETB\252",PropPayloadFormatIndicator 140,PropRequestResponseInformation 93,PropWildcardSubscriptionAvailable 15,PropMaximumPacketSize 21743,PropSubscriptionIdentifierAvailable 12,PropResponseInformation "iv\SI\219)\164\b\253\223\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c, 0x61, 0x2d, 0xa4, 0x2c, 0xa6, 0x9, 0x0, 0x17, 0xa9, 0x1, 0x20, 0x5c, 0xc5, 0xd1, 0x78, 0x3a, 0x8, 0xb0, 0x9, 0xe2, 0x5c, 0xde, 0x1d, 0xb2, 0x49, 0x56, 0x1e, 0x45, 0xbe, 0x17, 0xfc, 0x1, 0x8c, 0x19, 0x5d, 0x28, 0xf, 0x27, 0x0, 0x0, 0x54, 0xef, 0x29, 0xc, 0x1a, 0x0, 0xe, 0x69, 0x76, 0xf, 0xdb, 0x29, 0xa4, 0x8, 0xfd, 0xdf, 0xa, 0x9, 0xeb, 0x15, 0xdb, 0x2, 0x91, 0x1, 0x0, 0xa1}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 12919); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); -EXPECT_EQ(granted_qos_levels[1], 0x91); -EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[4], 0xA1); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x8e, 0x2c, 0xfd, 0xfb, 0xe4, 0xa4, 0x36, 0x3e, 0xed, 0x3, 0x96, 0xca, + 0xe4, 0xe1, 0xec, 0x1a, 0x82, 0x7d, 0x90, 0x8e, 0xc4, 0x3a, 0x4}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x37, 0x24, 0x26, 0xd8, 0xa2, 0x1c, 0x45, 0x6e, 0x1e, 0x73, 0x79, 0xf4, 0x5d}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc8, 0xd1, 0x44}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x9a, 0x2c, 0xa4, 0x3c}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd3, 0x63, 0x99}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x10, 0xdd, 0xaf, 0xd4, 0x2a}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x50, 0x6b, 0x29, 0xd9, 0x81, 0x27, 0xc9, 0xec, 0xa1, 0xb5, + 0x6f, 0xb0, 0x44, 0xbf, 0x4c, 0xf1, 0x9e, 0x99, 0x4, 0xe4}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x23, 0xe7, 0xcd, 0x45, 0xdc, 0xd9, 0x26, 0x53, 0xf2}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd3, 0x91, 0xcc}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27410, 9, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 17193 +// ["\201\232\214-\249\178\243\205$\220\150\232<\145\247","\167\SOH\185\173{\128\&73b\161rO\230\187\148\214\163\169\130\195\177\233\159l\249","K\ENQ\f\ACK\152\223","\169\DC1\140\210\EMO\172%;\SI\DLE\128\170U\SI\180\&7g\221\229 +// ","\255/n\"\EOT\\P\199\f\DEL\254\EMgh\179\206\243>"] [] +TEST(Unsubscribe5QCTest, Encode1) { + uint8_t pkt[] = {0xa2, 0x62, 0x43, 0x29, 0x0, 0x0, 0xf, 0xc9, 0xe8, 0xd6, 0x2d, 0xf9, 0xb2, 0xf3, 0xcd, 0x24, 0xdc, + 0x96, 0xe8, 0x3c, 0x91, 0xf7, 0x0, 0x19, 0xa7, 0x1, 0xb9, 0xad, 0x7b, 0x80, 0x37, 0x33, 0x62, 0xa1, + 0x72, 0x4f, 0xe6, 0xbb, 0x94, 0xd6, 0xa3, 0xa9, 0x82, 0xc3, 0xb1, 0xe9, 0x9f, 0x6c, 0xf9, 0x0, 0x6, + 0x4b, 0x5, 0xc, 0x6, 0x98, 0xdf, 0x0, 0x15, 0xa9, 0x11, 0x8c, 0xd2, 0x19, 0x4f, 0xac, 0x25, 0x3b, + 0xf, 0x10, 0x80, 0xaa, 0x55, 0xf, 0xb4, 0x37, 0x67, 0xdd, 0xe5, 0x20, 0x0, 0x12, 0xff, 0x2f, 0x6e, + 0x22, 0x4, 0x5c, 0x50, 0xc7, 0xc, 0x7f, 0xfe, 0x19, 0x67, 0x68, 0xb3, 0xce, 0xf3, 0x3e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// SubscribeResponse 20520 [Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right QoS0,Left SubErrImplementationSpecificError] [PropSubscriptionIdentifierAvailable 144,PropTopicAliasMaximum 10170,PropMaximumPacketSize 22999,PropRequestProblemInformation 220,PropAuthenticationData "X\238{\218f),",PropSessionExpiryInterval 21080,PropRequestProblemInformation 67,PropAuthenticationData "\SYN\189\&4\180\225\156\&8\246\DEL\151bX\148n\196@\247\214\132\&4\177\245h\179S\\\215EF",PropAuthenticationMethod "\249,\163\207\134\ESC\176?GbZ<4\218\164\207{",PropSharedSubscriptionAvailable 247,PropRequestResponseInformation 63,PropServerKeepAlive 12124,PropServerReference "_\\\235\181\236)\227\219\190\194\&9#|\233\204\200",PropMessageExpiryInterval 10858,PropRequestResponseInformation 207,PropSessionExpiryInterval 24059,PropReasonString "\NUL\EOT\228\DC3",PropContentType "\177N6\250\204j~\172\199cO\176\130\180 \225ba\206\US",PropAuthenticationData "K\RS\133c\ENQ\143\199\n7s\240IJ\187",PropMessageExpiryInterval 27212,PropSubscriptionIdentifier 10,PropRequestResponseInformation 203,PropTopicAlias 16606,PropAuthenticationMethod "9V\188\255\225\218\&5\DC1\247\NUL",PropWildcardSubscriptionAvailable 206,PropMaximumQoS 9,PropRetainAvailable 230,PropSharedSubscriptionAvailable 159,PropMaximumPacketSize 1549] -TEST(SubACK5QCTest, Decode29) { -uint8_t pkt[] = {0x90, 0xd5, 0x1, 0x50, 0x28, 0xcc, 0x1, 0x29, 0x90, 0x22, 0x27, 0xba, 0x27, 0x0, 0x0, 0x59, 0xd7, 0x17, 0xdc, 0x16, 0x0, 0x7, 0x58, 0xee, 0x7b, 0xda, 0x66, 0x29, 0x2c, 0x11, 0x0, 0x0, 0x52, 0x58, 0x17, 0x43, 0x16, 0x0, 0x1d, 0x16, 0xbd, 0x34, 0xb4, 0xe1, 0x9c, 0x38, 0xf6, 0x7f, 0x97, 0x62, 0x58, 0x94, 0x6e, 0xc4, 0x40, 0xf7, 0xd6, 0x84, 0x34, 0xb1, 0xf5, 0x68, 0xb3, 0x53, 0x5c, 0xd7, 0x45, 0x46, 0x15, 0x0, 0x11, 0xf9, 0x2c, 0xa3, 0xcf, 0x86, 0x1b, 0xb0, 0x3f, 0x47, 0x62, 0x5a, 0x3c, 0x34, 0xda, 0xa4, 0xcf, 0x7b, 0x2a, 0xf7, 0x19, 0x3f, 0x13, 0x2f, 0x5c, 0x1c, 0x0, 0x10, 0x5f, 0x5c, 0xeb, 0xb5, 0xec, 0x29, 0xe3, 0xdb, 0xbe, 0xc2, 0x39, 0x23, 0x7c, 0xe9, 0xcc, 0xc8, 0x2, 0x0, 0x0, 0x2a, 0x6a, 0x19, 0xcf, 0x11, 0x0, 0x0, 0x5d, 0xfb, 0x1f, 0x0, 0x4, 0x0, 0x4, 0xe4, 0x13, 0x3, 0x0, 0x14, 0xb1, 0x4e, 0x36, 0xfa, 0xcc, 0x6a, 0x7e, 0xac, 0xc7, 0x63, 0x4f, 0xb0, 0x82, 0xb4, 0x20, 0xe1, 0x62, 0x61, 0xce, 0x1f, 0x16, 0x0, 0xe, 0x4b, 0x1e, 0x85, 0x63, 0x5, 0x8f, 0xc7, 0xa, 0x37, 0x73, 0xf0, 0x49, 0x4a, 0xbb, 0x2, 0x0, 0x0, 0x6a, 0x4c, 0xb, 0xa, 0x19, 0xcb, 0x23, 0x40, 0xde, 0x15, 0x0, 0xa, 0x39, 0x56, 0xbc, 0xff, 0xe1, 0xda, 0x35, 0x11, 0xf7, 0x0, 0x28, 0xce, 0x24, 0x9, 0x25, 0xe6, 0x2a, 0x9f, 0x27, 0x0, 0x0, 0x6, 0xd, 0x1, 0x0, 0x87, 0x0, 0x83}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[5]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 5, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 20520); -EXPECT_EQ(count, 5); -EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[2], 0x87); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[4], 0x83); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xc9, 0xe8, 0xd6, 0x2d, 0xf9, 0xb2, 0xf3, 0xcd, + 0x24, 0xdc, 0x96, 0xe8, 0x3c, 0x91, 0xf7}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa7, 0x1, 0xb9, 0xad, 0x7b, 0x80, 0x37, 0x33, 0x62, 0xa1, 0x72, 0x4f, 0xe6, + 0xbb, 0x94, 0xd6, 0xa3, 0xa9, 0x82, 0xc3, 0xb1, 0xe9, 0x9f, 0x6c, 0xf9}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4b, 0x5, 0xc, 0x6, 0x98, 0xdf}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa9, 0x11, 0x8c, 0xd2, 0x19, 0x4f, 0xac, 0x25, 0x3b, 0xf, 0x10, + 0x80, 0xaa, 0x55, 0xf, 0xb4, 0x37, 0x67, 0xdd, 0xe5, 0x20}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xff, 0x2f, 0x6e, 0x22, 0x4, 0x5c, 0x50, 0xc7, 0xc, + 0x7f, 0xfe, 0x19, 0x67, 0x68, 0xb3, 0xce, 0xf3, 0x3e}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17193, 5, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 26830 +// ["\218+\CAN,\224\168w\RSA\238#\r\212'\236M7g\185\213H9V\247)","-\222\193hv\157\140\193\135\212\152\212","\DEL\rs\210\"\178\STX\ENQ\226\231\ETX\247)\157c\218\174","\243eC +// v|F\170\188e\246w\177:\197J\219\212\184i\139\EOT\207\187\177\228\192\150?\134","\159\157\FS\135\152\130u\DC4\194","\151O\204\&1\251\ACK","46\222nn\188#\191\208{\DC4\208\217\195"] +// [PropAssignedClientIdentifier "\128\221\179\247\163 \237\230B\150",PropAuthenticationMethod +// "h\177\&6\139\ETXu\143l^\246\155v\198H4\137\DC3\167\234\228\163\148\236\US\149\209\135q\130",PropPayloadFormatIndicator +// 50,PropResponseInformation "\ETXq\241%\238\151",PropSharedSubscriptionAvailable 148,PropWillDelayInterval +// 25509,PropTopicAlias 4710,PropContentType "\173\218T\210\215W~>XI\156/\250\152H",PropAuthenticationData +// "\240A1*\138\219\168\216'v\187\&0\153\CAN\202A\231o\DLE\202\251\210]\231\200",PropSessionExpiryInterval +// 22202,PropResponseInformation "\181\228\230",PropRetainAvailable 241,PropResponseInformation +// "\136\247\141o\191",PropServerReference "\249\246\v\DC2\183I\160\183z9"] +TEST(Unsubscribe5QCTest, Encode2) { + uint8_t pkt[] = { + 0xa2, 0x95, 0x2, 0x68, 0xce, 0x92, 0x1, 0x12, 0x0, 0xa, 0x80, 0xdd, 0xb3, 0xf7, 0xa3, 0x20, 0xed, 0xe6, 0x42, + 0x96, 0x15, 0x0, 0x1d, 0x68, 0xb1, 0x36, 0x8b, 0x3, 0x75, 0x8f, 0x6c, 0x5e, 0xf6, 0x9b, 0x76, 0xc6, 0x48, 0x34, + 0x89, 0x13, 0xa7, 0xea, 0xe4, 0xa3, 0x94, 0xec, 0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0xb8, 0x69, 0x8b, 0x4, 0xcf, 0xbb, 0xb1, 0xe4, 0xc0, 0x96, 0x3f, 0x86, 0x0, 0x9, + 0x9f, 0x9d, 0x1c, 0x87, 0x98, 0x82, 0x75, 0x14, 0xc2, 0x0, 0x6, 0x97, 0x4f, 0xcc, 0x31, 0xfb, 0x6, 0x0, 0xe, + 0x34, 0x36, 0xde, 0x6e, 0x6e, 0xbc, 0x23, 0xbf, 0xd0, 0x7b, 0x14, 0xd0, 0xd9, 0xc3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x80, 0xdd, 0xb3, 0xf7, 0xa3, 0x20, 0xed, 0xe6, 0x42, 0x96}; + uint8_t bytesprops1[] = {0x68, 0xb1, 0x36, 0x8b, 0x3, 0x75, 0x8f, 0x6c, 0x5e, 0xf6, 0x9b, 0x76, 0xc6, 0x48, 0x34, + 0x89, 0x13, 0xa7, 0xea, 0xe4, 0xa3, 0x94, 0xec, 0x1f, 0x95, 0xd1, 0x87, 0x71, 0x82}; + uint8_t bytesprops2[] = {0x3, 0x71, 0xf1, 0x25, 0xee, 0x97}; + uint8_t bytesprops3[] = {0xad, 0xda, 0x54, 0xd2, 0xd7, 0x57, 0x7e, 0x3e, 0x58, 0x49, 0x9c, 0x2f, 0xfa, 0x98, 0x48}; + uint8_t bytesprops4[] = {0xf0, 0x41, 0x31, 0x2a, 0x8a, 0xdb, 0xa8, 0xd8, 0x27, 0x76, 0xbb, 0x30, 0x99, + 0x18, 0xca, 0x41, 0xe7, 0x6f, 0x10, 0xca, 0xfb, 0xd2, 0x5d, 0xe7, 0xc8}; + uint8_t bytesprops5[] = {0xb5, 0xe4, 0xe6}; + uint8_t bytesprops6[] = {0x88, 0xf7, 0x8d, 0x6f, 0xbf}; + uint8_t bytesprops7[] = {0xf9, 0xf6, 0xb, 0x12, 0xb7, 0x49, 0xa0, 0xb7, 0x7a, 0x39}; -// SubscribeResponse 2699 [Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded,Left SubErrQuotaExceeded,Right QoS1,Right QoS0,Left SubErrQuotaExceeded] [PropResponseTopic "",PropSessionExpiryInterval 8424] -TEST(SubACK5QCTest, Decode30) { -uint8_t pkt[] = {0x90, 0x11, 0xa, 0x8b, 0x8, 0x8, 0x0, 0x0, 0x11, 0x0, 0x0, 0x20, 0xe8, 0x91, 0x97, 0x97, 0x1, 0x0, 0x97}; -uint16_t packet_id; -int count; -lwmqtt_qos_t granted_qos_levels[6]; -lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id,LWMQTT_MQTT5, 6, &count, granted_qos_levels); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(packet_id, 2699); -EXPECT_EQ(count, 6); -EXPECT_EQ(granted_qos_levels[0], 0x91); -EXPECT_EQ(granted_qos_levels[1], 0x97); -EXPECT_EQ(granted_qos_levels[2], 0x97); -EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); -EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); -EXPECT_EQ(granted_qos_levels[5], 0x97); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25509}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4710}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22202}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops7}}}, + }; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xda, 0x2b, 0x18, 0x2c, 0xe0, 0xa8, 0x77, 0x1e, 0x41, 0xee, 0x23, 0xd, 0xd4, + 0x27, 0xec, 0x4d, 0x37, 0x67, 0xb9, 0xd5, 0x48, 0x39, 0x56, 0xf7, 0x29}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2d, 0xde, 0xc1, 0x68, 0x76, 0x9d, 0x8c, 0xc1, 0x87, 0xd4, 0x98, 0xd4}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x7f, 0xd, 0x73, 0xd2, 0x22, 0xb2, 0x2, 0x5, 0xe2, + 0xe7, 0x3, 0xf7, 0x29, 0x9d, 0x63, 0xda, 0xae}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf3, 0x65, 0x43, 0x20, 0x76, 0x7c, 0x46, 0xaa, 0xbc, 0x65, + 0xf6, 0x77, 0xb1, 0x3a, 0xc5, 0x4a, 0xdb, 0xd4, 0xb8, 0x69, + 0x8b, 0x4, 0xcf, 0xbb, 0xb1, 0xe4, 0xc0, 0x96, 0x3f, 0x86}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9f, 0x9d, 0x1c, 0x87, 0x98, 0x82, 0x75, 0x14, 0xc2}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x97, 0x4f, 0xcc, 0x31, 0xfb, 0x6}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x34, 0x36, 0xde, 0x6e, 0x6e, 0xbc, 0x23, + 0xbf, 0xd0, 0x7b, 0x14, 0xd0, 0xd9, 0xc3}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26830, 7, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 23824 ["\226W\ETX\192;\167?\SO \145"] [PropRequestResponseInformation 87,PropReceiveMaximum +// 20388,PropReceiveMaximum 27543,PropMessageExpiryInterval 17456,PropTopicAliasMaximum 32748,PropMaximumQoS +// 145,PropMessageExpiryInterval 31600,PropRequestProblemInformation 63,PropAuthenticationMethod +// "\DLEQ\232F\162\143\&6\SO\242\200%\136\251z[|\ACK\129\213\147",PropServerKeepAlive +// 8194,PropRequestResponseInformation 19,PropRequestResponseInformation 205,PropContentType +// "\203oD\202*\181,%\248\240\SUBo\228wJ\168\130\NAK\243\253",PropMessageExpiryInterval 11962,PropSessionExpiryInterval +// 14539,PropUserProperty "" +// "\ACKt\206BH\250\221\238\232\ENQ\172\207\137\STX\195\172k\GS\CAN\154\203-\ETX\204\229\&2!<",PropTopicAlias +// 2154,PropContentType "\236\211\136>U\199L\168\162",PropCorrelationData +// "Fd\229\ACKS\206\180c\143y\153d\210\180\149+\165\207\179\NUL;\135\146v:\182\218\151\207\155",PropSharedSubscriptionAvailable +// 135,PropAuthenticationMethod "\225c\237 \183ve\FS\186",PropTopicAliasMaximum 30866,PropServerKeepAlive +// 32352,PropUserProperty "" "",PropUserProperty "\nY\DLE\150T\227W\160c\228" +// "\208\227\139\ENQ\t\RS\201\v\227\183y\243\215\183\f",PropAssignedClientIdentifier +// "X\SO\176\234\&0\195\253\204\ENQ\143\208y\f\SOH<\ACK",PropMessageExpiryInterval 30461,PropCorrelationData +// "\223A\205\193($\DEL\131\153zj6f@O\145c\243\RS\155\&0\130\143"] +TEST(Unsubscribe5QCTest, Encode3) { + uint8_t pkt[] = { + 0xa2, 0xa2, 0x2, 0x5d, 0x10, 0x92, 0x2, 0x19, 0x57, 0x21, 0x4f, 0xa4, 0x21, 0x6b, 0x97, 0x2, 0x0, 0x0, 0x44, + 0x30, 0x22, 0x7f, 0xec, 0x24, 0x91, 0x2, 0x0, 0x0, 0x7b, 0x70, 0x17, 0x3f, 0x15, 0x0, 0x14, 0x10, 0x51, 0xe8, + 0x46, 0xa2, 0x8f, 0x36, 0xe, 0xf2, 0xc8, 0x25, 0x88, 0xfb, 0x7a, 0x5b, 0x7c, 0x6, 0x81, 0xd5, 0x93, 0x13, 0x20, + 0x2, 0x19, 0x13, 0x19, 0xcd, 0x3, 0x0, 0x14, 0xcb, 0x6f, 0x44, 0xca, 0x2a, 0xb5, 0x2c, 0x25, 0xf8, 0xf0, 0x1a, + 0x6f, 0xe4, 0x77, 0x4a, 0xa8, 0x82, 0x15, 0xf3, 0xfd, 0x2, 0x0, 0x0, 0x2e, 0xba, 0x11, 0x0, 0x0, 0x38, 0xcb, + 0x26, 0x0, 0x0, 0x0, 0x1c, 0x6, 0x74, 0xce, 0x42, 0x48, 0xfa, 0xdd, 0xee, 0xe8, 0x5, 0xac, 0xcf, 0x89, 0x2, + 0xc3, 0xac, 0x6b, 0x1d, 0x18, 0x9a, 0xcb, 0x2d, 0x3, 0xcc, 0xe5, 0x32, 0x21, 0x3c, 0x23, 0x8, 0x6a, 0x3, 0x0, + 0x9, 0xec, 0xd3, 0x88, 0x3e, 0x55, 0xc7, 0x4c, 0xa8, 0xa2, 0x9, 0x0, 0x1e, 0x46, 0x64, 0xe5, 0x6, 0x53, 0xce, + 0xb4, 0x63, 0x8f, 0x79, 0x99, 0x64, 0xd2, 0xb4, 0x95, 0x2b, 0xa5, 0xcf, 0xb3, 0x0, 0x3b, 0x87, 0x92, 0x76, 0x3a, + 0xb6, 0xda, 0x97, 0xcf, 0x9b, 0x2a, 0x87, 0x15, 0x0, 0x9, 0xe1, 0x63, 0xed, 0x20, 0xb7, 0x76, 0x65, 0x1c, 0xba, + 0x22, 0x78, 0x92, 0x13, 0x7e, 0x60, 0x26, 0x0, 0x0, 0x0, 0x0, 0x26, 0x0, 0xa, 0xa, 0x59, 0x10, 0x96, 0x54, + 0xe3, 0x57, 0xa0, 0x63, 0xe4, 0x0, 0xf, 0xd0, 0xe3, 0x8b, 0x5, 0x9, 0x1e, 0xc9, 0xb, 0xe3, 0xb7, 0x79, 0xf3, + 0xd7, 0xb7, 0xc, 0x12, 0x0, 0x10, 0x58, 0xe, 0xb0, 0xea, 0x30, 0xc3, 0xfd, 0xcc, 0x5, 0x8f, 0xd0, 0x79, 0xc, + 0x1, 0x3c, 0x6, 0x2, 0x0, 0x0, 0x76, 0xfd, 0x9, 0x0, 0x17, 0xdf, 0x41, 0xcd, 0xc1, 0x28, 0x24, 0x7f, 0x83, + 0x99, 0x7a, 0x6a, 0x36, 0x66, 0x40, 0x4f, 0x91, 0x63, 0xf3, 0x1e, 0x9b, 0x30, 0x82, 0x8f, 0x0, 0xa, 0xe2, 0x57, + 0x3, 0xc0, 0x3b, 0xa7, 0x3f, 0xe, 0x20, 0x91}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x10, 0x51, 0xe8, 0x46, 0xa2, 0x8f, 0x36, 0xe, 0xf2, 0xc8, + 0x25, 0x88, 0xfb, 0x7a, 0x5b, 0x7c, 0x6, 0x81, 0xd5, 0x93}; + uint8_t bytesprops1[] = {0xcb, 0x6f, 0x44, 0xca, 0x2a, 0xb5, 0x2c, 0x25, 0xf8, 0xf0, + 0x1a, 0x6f, 0xe4, 0x77, 0x4a, 0xa8, 0x82, 0x15, 0xf3, 0xfd}; + uint8_t bytesprops3[] = {0x6, 0x74, 0xce, 0x42, 0x48, 0xfa, 0xdd, 0xee, 0xe8, 0x5, 0xac, 0xcf, 0x89, 0x2, + 0xc3, 0xac, 0x6b, 0x1d, 0x18, 0x9a, 0xcb, 0x2d, 0x3, 0xcc, 0xe5, 0x32, 0x21, 0x3c}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops4[] = {0xec, 0xd3, 0x88, 0x3e, 0x55, 0xc7, 0x4c, 0xa8, 0xa2}; + uint8_t bytesprops5[] = {0x46, 0x64, 0xe5, 0x6, 0x53, 0xce, 0xb4, 0x63, 0x8f, 0x79, 0x99, 0x64, 0xd2, 0xb4, 0x95, + 0x2b, 0xa5, 0xcf, 0xb3, 0x0, 0x3b, 0x87, 0x92, 0x76, 0x3a, 0xb6, 0xda, 0x97, 0xcf, 0x9b}; + uint8_t bytesprops6[] = {0xe1, 0x63, 0xed, 0x20, 0xb7, 0x76, 0x65, 0x1c, 0xba}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops10[] = {0xd0, 0xe3, 0x8b, 0x5, 0x9, 0x1e, 0xc9, 0xb, 0xe3, 0xb7, 0x79, 0xf3, 0xd7, 0xb7, 0xc}; + uint8_t bytesprops9[] = {0xa, 0x59, 0x10, 0x96, 0x54, 0xe3, 0x57, 0xa0, 0x63, 0xe4}; + uint8_t bytesprops11[] = {0x58, 0xe, 0xb0, 0xea, 0x30, 0xc3, 0xfd, 0xcc, 0x5, 0x8f, 0xd0, 0x79, 0xc, 0x1, 0x3c, 0x6}; + uint8_t bytesprops12[] = {0xdf, 0x41, 0xcd, 0xc1, 0x28, 0x24, 0x7f, 0x83, 0x99, 0x7a, 0x6a, 0x36, + 0x66, 0x40, 0x4f, 0x91, 0x63, 0xf3, 0x1e, 0x9b, 0x30, 0x82, 0x8f}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode1) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20388}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27543}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17456}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32748}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31600}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8194}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11962}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14539}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops2}, .v = {28, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2154}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30866}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32352}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops7}, .v = {0, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops9}, .v = {15, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30461}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops12}}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xe2, 0x57, 0x3, 0xc0, 0x3b, 0xa7, 0x3f, 0xe, 0x20, 0x91}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23824, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 20314 +// ["\247$\SOcz\155#\129\206\189\129\151\230\250[\179\254\214=v\GS\230\237\227\174\157\ETB\ESC\189"] +// [PropAssignedClientIdentifier "]\222#\222G\232n\197\ACK\170f\139\157\154\183\a\167",PropUserProperty +// "\221\DLE\146)\186\136\&7\232" "\220\218,\136\219#4d\143\250\253\251\218\FS\ACK",PropAuthenticationMethod +// "\161\EM_\DEL\198\159i\164e\173\161#\SI\252\216\STX%\198\178Ij8~\162",PropTopicAliasMaximum 5392,PropServerReference +// "\132\255\141\149#\249\ESC;\SO\187\154*y\ETB\191\232Db\219\DLEIJtr\131Qk\247\DLE\169",PropServerKeepAlive +// 6076,PropTopicAliasMaximum 30910,PropSubscriptionIdentifierAvailable 160,PropMaximumQoS +// 92,PropRequestProblemInformation 171,PropServerKeepAlive 12856,PropTopicAlias 32229,PropMessageExpiryInterval +// 11092,PropRetainAvailable 106,PropUserProperty "\161\160>I\250f\174\SO\205\b\ESCD@\STXb\216{v\fT\248 +// $E\196\178\203\&4<" "",PropSubscriptionIdentifierAvailable 15,PropUserProperty +// ">\170\FS\193\205GS\209\211\247h\EM\DLEW\226\157" +// "\197/&4\163aHw\250S\145\&5)\SOH\204\240\182\209\SOH\145\169",PropResponseTopic +// "\147\147Y\243\232\&91fj;\184\243\135\&3\149&_\174L\ESC\203n49\206\198\147'w\197",PropMessageExpiryInterval +// 13776,PropAuthenticationData "\162\251,\206\178\249tR\180}\232\178\&3b0u\199\ENQC\GS)\169\198"] +TEST(Unsubscribe5QCTest, Encode4) { + uint8_t pkt[] = { + 0xa2, 0xb9, 0x2, 0x4f, 0x5a, 0x96, 0x2, 0x12, 0x0, 0x11, 0x5d, 0xde, 0x23, 0xde, 0x47, 0xe8, 0x6e, 0xc5, 0x6, + 0xaa, 0x66, 0x8b, 0x9d, 0x9a, 0xb7, 0x7, 0xa7, 0x26, 0x0, 0x8, 0xdd, 0x10, 0x92, 0x29, 0xba, 0x88, 0x37, 0xe8, + 0x0, 0xf, 0xdc, 0xda, 0x2c, 0x88, 0xdb, 0x23, 0x34, 0x64, 0x8f, 0xfa, 0xfd, 0xfb, 0xda, 0x1c, 0x6, 0x15, 0x0, + 0x18, 0xa1, 0x19, 0x5f, 0x7f, 0xc6, 0x9f, 0x69, 0xa4, 0x65, 0xad, 0xa1,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0x0, 0x35, 0xd0, 0x16, 0x0, 0x17, 0xa2, 0xfb, 0x2c, 0xce, + 0xb2, 0xf9, 0x74, 0x52, 0xb4, 0x7d, 0xe8, 0xb2, 0x33, 0x62, 0x30, 0x75, 0xc7, 0x5, 0x43, 0x1d, 0x29, 0xa9, 0xc6, + 0x0, 0x1d, 0xf7, 0x24, 0xe, 0x63, 0x7a, 0x9b, 0x23, 0x81, 0xce, 0xbd, 0x81, 0x97, 0xe6, 0xfa, 0x5b, 0xb3, 0xfe, + 0xd6, 0x3d, 0x76, 0x1d, 0xe6, 0xed, 0xe3, 0xae, 0x9d, 0x17, 0x1b, 0xbd}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x5d, 0xde, 0x23, 0xde, 0x47, 0xe8, 0x6e, 0xc5, 0x6, + 0xaa, 0x66, 0x8b, 0x9d, 0x9a, 0xb7, 0x7, 0xa7}; + uint8_t bytesprops2[] = {0xdc, 0xda, 0x2c, 0x88, 0xdb, 0x23, 0x34, 0x64, 0x8f, 0xfa, 0xfd, 0xfb, 0xda, 0x1c, 0x6}; + uint8_t bytesprops1[] = {0xdd, 0x10, 0x92, 0x29, 0xba, 0x88, 0x37, 0xe8}; + uint8_t bytesprops3[] = {0xa1, 0x19, 0x5f, 0x7f, 0xc6, 0x9f, 0x69, 0xa4, 0x65, 0xad, 0xa1, 0x23, + 0xf, 0xfc, 0xd8, 0x2, 0x25, 0xc6, 0xb2, 0x49, 0x6a, 0x38, 0x7e, 0xa2}; + uint8_t bytesprops4[] = {0x84, 0xff, 0x8d, 0x95, 0x23, 0xf9, 0x1b, 0x3b, 0xe, 0xbb, 0x9a, 0x2a, 0x79, 0x17, 0xbf, + 0xe8, 0x44, 0x62, 0xdb, 0x10, 0x49, 0x4a, 0x74, 0x72, 0x83, 0x51, 0x6b, 0xf7, 0x10, 0xa9}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops5[] = {0xa1, 0xa0, 0x3e, 0x49, 0xfa, 0x66, 0xae, 0xe, 0xcd, 0x8, 0x1b, 0x44, 0x40, 0x2, 0x62, + 0xd8, 0x7b, 0x76, 0xc, 0x54, 0xf8, 0x20, 0x24, 0x45, 0xc4, 0xb2, 0xcb, 0x34, 0x3c}; + uint8_t bytesprops8[] = {0xc5, 0x2f, 0x26, 0x34, 0xa3, 0x61, 0x48, 0x77, 0xfa, 0x53, 0x91, + 0x35, 0x29, 0x1, 0xcc, 0xf0, 0xb6, 0xd1, 0x1, 0x91, 0xa9}; + uint8_t bytesprops7[] = {0x3e, 0xaa, 0x1c, 0xc1, 0xcd, 0x47, 0x53, 0xd1, + 0xd3, 0xf7, 0x68, 0x19, 0x10, 0x57, 0xe2, 0x9d}; + uint8_t bytesprops9[] = {0x93, 0x93, 0x59, 0xf3, 0xe8, 0x39, 0x31, 0x66, 0x6a, 0x3b, 0xb8, 0xf3, 0x87, 0x33, 0x95, + 0x26, 0x5f, 0xae, 0x4c, 0x1b, 0xcb, 0x6e, 0x34, 0x39, 0xce, 0xc6, 0x93, 0x27, 0x77, 0xc5}; + uint8_t bytesprops10[] = {0xa2, 0xfb, 0x2c, 0xce, 0xb2, 0xf9, 0x74, 0x52, 0xb4, 0x7d, 0xe8, 0xb2, + 0x33, 0x62, 0x30, 0x75, 0xc7, 0x5, 0x43, 0x1d, 0x29, 0xa9, 0xc6}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode2) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops1}, .v = {15, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5392}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6076}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30910}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12856}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32229}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11092}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops5}, .v = {0, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops7}, .v = {21, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13776}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xf7, 0x24, 0xe, 0x63, 0x7a, 0x9b, 0x23, 0x81, 0xce, 0xbd, + 0x81, 0x97, 0xe6, 0xfa, 0x5b, 0xb3, 0xfe, 0xd6, 0x3d, 0x76, + 0x1d, 0xe6, 0xed, 0xe3, 0xae, 0x9d, 0x17, 0x1b, 0xbd}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20314, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 29664 +// ["\214i\176\156X)\134(\251ux\210\240\DC1\SUB\200\219\EM\219l\213\170B","=\197\235\163\&1\EM\ENQ\255\181\143\201\171vu_o","6\134~W\204","7\223'\b\224\232u","\166v\184[x","z\n\135.Z\170\&9\208\249\231|\132",":1\229C\168\137","7\181\161\220\150\219:\219\171i\226u\150\195`\169","\223\233\205\n\174\ETB\193\ETB\v\255\&0\137u\158\136D\201\&1","\EMX\246C\131J +// \242>:\SOH\164"] [PropWillDelayInterval 13866,PropSharedSubscriptionAvailable 154,PropSubscriptionIdentifier +// 27,PropSessionExpiryInterval 26200,PropAuthenticationMethod +// "\136f\214T5\GSH\SI\148\188\205\247u\ETX\171\ESC\STX\245N\SOH5Ib(\222",PropRequestResponseInformation +// 65,PropReceiveMaximum 24317] +TEST(Unsubscribe5QCTest, Encode5) { + uint8_t pkt[] = {0xa2, 0xbe, 0x1, 0x73, 0xe0, 0x2f, 0x18, 0x0, 0x0, 0x36, 0x2a, 0x2a, 0x9a, 0xb, 0x1b, 0x11, 0x0, + 0x0, 0x66, 0x58, 0x15, 0x0, 0x19, 0x88, 0x66, 0xd6, 0x54, 0x35, 0x1d, 0x48, 0xf, 0x94, 0xbc, 0xcd, + 0xf7, 0x75, 0x3, 0xab, 0x1b, 0x2, 0xf5, 0x4e, 0x1, 0x35, 0x49, 0x62, 0x28, 0xde, 0x19, 0x41, 0x21, + 0x5e, 0xfd, 0x0, 0x17, 0xd6, 0x69, 0xb0, 0x9c, 0x58, 0x29, 0x86, 0x28, 0xfb, 0x75, 0x78, 0xd2, 0xf0, + 0x11, 0x1a, 0xc8, 0xdb, 0x19, 0xdb, 0x6c, 0xd5, 0xaa, 0x42, 0x0, 0x10, 0x3d, 0xc5, 0xeb, 0xa3, 0x31, + 0x19, 0x5, 0xff, 0xb5, 0x8f, 0xc9, 0xab, 0x76, 0x75, 0x5f, 0x6f, 0x0, 0x5, 0x36, 0x86, 0x7e, 0x57, + 0xcc, 0x0, 0x7, 0x37, 0xdf, 0x27, 0x8, 0xe0, 0xe8, 0x75, 0x0, 0x5, 0xa6, 0x76, 0xb8, 0x5b, 0x78, + 0x0, 0xc, 0x7a, 0xa, 0x87, 0x2e, 0x5a, 0xaa, 0x39, 0xd0, 0xf9, 0xe7, 0x7c, 0x84, 0x0, 0x6, 0x3a, + 0x31, 0xe5, 0x43, 0xa8, 0x89, 0x0, 0x10, 0x37, 0xb5, 0xa1, 0xdc, 0x96, 0xdb, 0x3a, 0xdb, 0xab, 0x69, + 0xe2, 0x75, 0x96, 0xc3, 0x60, 0xa9, 0x0, 0x12, 0xdf, 0xe9, 0xcd, 0xa, 0xae, 0x17, 0xc1, 0x17, 0xb, + 0xff, 0x30, 0x89, 0x75, 0x9e, 0x88, 0x44, 0xc9, 0x31, 0x0, 0xc, 0x19, 0x58, 0xf6, 0x43, 0x83, 0x4a, + 0x20, 0xf2, 0x3e, 0x3a, 0x1, 0xa4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x88, 0x66, 0xd6, 0x54, 0x35, 0x1d, 0x48, 0xf, 0x94, 0xbc, 0xcd, 0xf7, 0x75, + 0x3, 0xab, 0x1b, 0x2, 0xf5, 0x4e, 0x1, 0x35, 0x49, 0x62, 0x28, 0xde}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode3) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13866}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26200}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24317}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd6, 0x69, 0xb0, 0x9c, 0x58, 0x29, 0x86, 0x28, 0xfb, 0x75, 0x78, 0xd2, + 0xf0, 0x11, 0x1a, 0xc8, 0xdb, 0x19, 0xdb, 0x6c, 0xd5, 0xaa, 0x42}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x3d, 0xc5, 0xeb, 0xa3, 0x31, 0x19, 0x5, 0xff, + 0xb5, 0x8f, 0xc9, 0xab, 0x76, 0x75, 0x5f, 0x6f}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x36, 0x86, 0x7e, 0x57, 0xcc}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x37, 0xdf, 0x27, 0x8, 0xe0, 0xe8, 0x75}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa6, 0x76, 0xb8, 0x5b, 0x78}; + lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x7a, 0xa, 0x87, 0x2e, 0x5a, 0xaa, 0x39, 0xd0, 0xf9, 0xe7, 0x7c, 0x84}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3a, 0x31, 0xe5, 0x43, 0xa8, 0x89}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x37, 0xb5, 0xa1, 0xdc, 0x96, 0xdb, 0x3a, 0xdb, + 0xab, 0x69, 0xe2, 0x75, 0x96, 0xc3, 0x60, 0xa9}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xdf, 0xe9, 0xcd, 0xa, 0xae, 0x17, 0xc1, 0x17, 0xb, + 0xff, 0x30, 0x89, 0x75, 0x9e, 0x88, 0x44, 0xc9, 0x31}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x19, 0x58, 0xf6, 0x43, 0x83, 0x4a, 0x20, 0xf2, 0x3e, 0x3a, 0x1, 0xa4}; + lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29664, 10, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 28866 ["\ACK"] [PropAuthenticationData "\SI",PropMessageExpiryInterval +// 6437,PropPayloadFormatIndicator 115,PropSharedSubscriptionAvailable 176,PropMaximumQoS 86,PropUserProperty +// "F\148\DC1\254\194\179\208dX\243\151\t\b_\243X\165:\182\231~`\RSxh" "\164\135\153}\DC2.\162*",PropResponseInformation +// "X\220L\204@\140E\ACKo\235?\250\r\194\178h\230",PropServerReference "\220\194\f\146;",PropAssignedClientIdentifier +// "\230\"\CANp}\224\&4\132V\US\NUL+\133\168\193",PropTopicAlias 19678,PropMaximumQoS +// 88,PropSubscriptionIdentifierAvailable 19,PropSharedSubscriptionAvailable 13,PropRetainAvailable +// 199,PropResponseTopic "M\199m\129\254\222;3gjYj\DC2\239\167\132\159{","\221\ESCwC\170\ESC3\SYN\247\206"] +// [PropWildcardSubscriptionAvailable 205,PropResponseTopic +// "}\229\DC2Y[\239;\231\254\133v\EM\138O\226No",PropCorrelationData +// "\170Hr\170\199\SO\161\149Dy\229\248`\190\146\180\178w\178\DC4\222\226\ETXJ\253\144\DLE\163\DC2",PropMaximumQoS +// 231,PropUserProperty "\CAN\RS-\219\177\240\179d}\232\136\154\137\183\222nT}U\210\194" +// "\173\DC11\196j\167\156\255\a\DEL\140\245\243",PropSubscriptionIdentifier 28,PropMessageExpiryInterval +// 9872,PropUserProperty +// "\130\157\174\180\156\221\SOH\228\247Gl\SUB\194\133g\134P\NAK\223-\239[\199\138\128\224\NUL\178\\" +// "Z\213\219y\228\SOH\255",PropRequestProblemInformation 96,PropWillDelayInterval 30997,PropUserProperty +// "\139\240O\202\STX\238\217**\ESC" "\136r\228\199\191\162M.\191\133\160\246g:P\190\168 +// 8\137\155",PropAuthenticationData "w",PropSharedSubscriptionAvailable 215,PropSessionExpiryInterval +// 31240,PropRequestProblemInformation 153,PropMessageExpiryInterval 10229,PropCorrelationData +// "f\245EK7\247\194\171\143\163\v3P\169Q\178\212\254&\244^\204\NAK",PropAssignedClientIdentifier +// "V\170\209\&8b\190\165Rs\EM",PropServerKeepAlive 16887,PropResponseInformation +// "e\242\128\146\CAN",PropServerReference "\a\240\202\202\230|",PropTopicAlias 8989,PropRequestResponseInformation +// 49,PropSessionExpiryInterval 18001,PropResponseTopic "\129\242C\192\149\151<\197\194\180\187\SUBD\210",PropTopicAlias +// 854,PropSharedSubscriptionAvailable 130,PropRetainAvailable 248,PropMaximumQoS 251] +TEST(Unsubscribe5QCTest, Encode13) { + uint8_t pkt[] = { + 0xa2, 0xb8, 0x1, 0x3, 0xb5, 0x97, 0x1, 0x26, 0x0, 0xc, 0x9e, 0xb8, 0x23, 0xff, 0xf4, 0x3e, 0x2, 0xee, 0xd9, + 0x2a, 0x2a, 0x1b, 0x0, 0x15, 0x88, 0x72, 0xe4, 0xc7, 0xbf, 0xa2, 0x4d, 0x2e, 0xbf, 0x85, 0xa0, 0xf6, 0x67, 0x3a, + 0x50, 0xbe, 0xa8, 0x20, 0x38, 0x89, 0x9b, 0x16, 0x0, 0x1, 0x77, 0x2a, 0xd7, 0x11, 0x0, 0x0, 0x7a, 0x8, 0x17, + 0x99, 0x2, 0x0, 0x0, 0x27, 0xf5, 0x9, 0x0, 0x17, 0x66, 0xf5, 0x45, 0x4b, 0x37, 0xf7, 0xc2, 0xab, 0x8f, 0xa3, + 0xb, 0x33, 0x50, 0xa9, 0x51, 0xb2, 0xd4, 0xfe, 0x26, 0xf4, 0x5e, 0xcc, 0x15, 0x12, 0x0, 0xa, 0x56, 0xaa, 0xd1, + 0x38, 0x62, 0xbe, 0xa5, 0x52, 0x73, 0x19, 0x13, 0x41, 0xf7, 0x1a, 0x0, 0x5, 0x65, 0xf2, 0x80, 0x92, 0x18, 0x1c, + 0x0, 0x6, 0x7, 0xf0, 0xca, 0xca, 0xe6, 0x7c, 0x23, 0x23, 0x1d, 0x19, 0x31, 0x11, 0x0, 0x0, 0x46, 0x51, 0x8, + 0x0, 0xe, 0x81, 0xf2, 0x43, 0xc0, 0x95, 0x97, 0x3c, 0xc5, 0xc2, 0xb4, 0xbb, 0x1a, 0x44, 0xd2, 0x23, 0x3, 0x56, + 0x2a, 0x82, 0x25, 0xf8, 0x24, 0xfb, 0x0, 0x1b, 0x8b, 0x78, 0x56, 0x8e, 0x45, 0x8b, 0x37, 0xb3, 0x54, 0x82, 0xd4, + 0xfa, 0x47, 0xc3, 0x46, 0xc1, 0xfc, 0xfa, 0xca, 0x7b, 0xc4, 0x7a, 0xe4, 0xa4, 0x2, 0x1f, 0xdb}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x88, 0x72, 0xe4, 0xc7, 0xbf, 0xa2, 0x4d, 0x2e, 0xbf, 0x85, 0xa0, + 0xf6, 0x67, 0x3a, 0x50, 0xbe, 0xa8, 0x20, 0x38, 0x89, 0x9b}; + uint8_t bytesprops0[] = {0x9e, 0xb8, 0x23, 0xff, 0xf4, 0x3e, 0x2, 0xee, 0xd9, 0x2a, 0x2a, 0x1b}; + uint8_t bytesprops2[] = {0x77}; + uint8_t bytesprops3[] = {0x66, 0xf5, 0x45, 0x4b, 0x37, 0xf7, 0xc2, 0xab, 0x8f, 0xa3, 0xb, 0x33, + 0x50, 0xa9, 0x51, 0xb2, 0xd4, 0xfe, 0x26, 0xf4, 0x5e, 0xcc, 0x15}; + uint8_t bytesprops4[] = {0x56, 0xaa, 0xd1, 0x38, 0x62, 0xbe, 0xa5, 0x52, 0x73, 0x19}; + uint8_t bytesprops5[] = {0x65, 0xf2, 0x80, 0x92, 0x18}; + uint8_t bytesprops6[] = {0x7, 0xf0, 0xca, 0xca, 0xe6, 0x7c}; + uint8_t bytesprops7[] = {0x81, 0xf2, 0x43, 0xc0, 0x95, 0x97, 0x3c, 0xc5, 0xc2, 0xb4, 0xbb, 0x1a, 0x44, 0xd2}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode11) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops0}, .v = {21, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31240}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10229}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16887}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8989}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18001}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 854}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 251}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x8b, 0x78, 0x56, 0x8e, 0x45, 0x8b, 0x37, 0xb3, 0x54, 0x82, 0xd4, 0xfa, 0x47, 0xc3, + 0x46, 0xc1, 0xfc, 0xfa, 0xca, 0x7b, 0xc4, 0x7a, 0xe4, 0xa4, 0x2, 0x1f, 0xdb}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 949, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 5184 +// ["\160\156\&1\155\217\US\192\233A\170\&6f\208I","\ENQ\r\NAK\179\221\CAN\215\212\191\237F\250\ESC'\255a\132\132W>\231","\169\255\rPZLI'\SO\SYN\158\226\192\203\CAN[\136\168\185","\227Jq\248\&3\215\SYN=\200\169(\221\NAKe0>\147\156pZ\131e\165\ETB\252\152d\245\133\174","\192\144\SI\216f\194_\160\160'\US}\195VY\222\235\217\186%\198T]\247","\239Z\211\232","J\184i\172\147\218PR\190~\at/\158\152T\135\"\144\RS3\139","\167\176.\244x\254S\EOT!N\202z\154T\210\DC3G\DLE\130","\194","\165\208\135\190\165G"] +// [PropRequestResponseInformation 213,PropRequestResponseInformation 171,PropWillDelayInterval +// 6198,PropSubscriptionIdentifier 3] +TEST(Unsubscribe5QCTest, Encode14) { + uint8_t pkt[] = {0xa2, 0xc2, 0x1, 0x14, 0x40, 0xb, 0x19, 0xd5, 0x19, 0xab, 0x18, 0x0, 0x0, 0x18, 0x36, 0xb, 0x3, + 0x0, 0xe, 0xa0, 0x9c, 0x31, 0x9b, 0xd9, 0x1f, 0xc0, 0xe9, 0x41, 0xaa, 0x36, 0x66, 0xd0, 0x49, 0x0, + 0x15, 0x5, 0xd, 0x15, 0xb3, 0xdd, 0x18, 0xd7, 0xd4, 0xbf, 0xed, 0x46, 0xfa, 0x1b, 0x27, 0xff, 0x61, + 0x84, 0x84, 0x57, 0x3e, 0xe7, 0x0, 0x13, 0xa9, 0xff, 0xd, 0x50, 0x5a, 0x4c, 0x49, 0x27, 0xe, 0x16, + 0x9e, 0xe2, 0xc0, 0xcb, 0x18, 0x5b, 0x88, 0xa8, 0xb9, 0x0, 0x1e, 0xe3, 0x4a, 0x71, 0xf8, 0x33, 0xd7, + 0x16, 0x3d, 0xc8, 0xa9, 0x28, 0xdd, 0x15, 0x65, 0x30, 0x3e, 0x93, 0x9c, 0x70, 0x5a, 0x83, 0x65, 0xa5, + 0x17, 0xfc, 0x98, 0x64, 0xf5, 0x85, 0xae, 0x0, 0x18, 0xc0, 0x90, 0xf, 0xd8, 0x66, 0xc2, 0x5f, 0xa0, + 0xa0, 0x27, 0x1f, 0x7d, 0xc3, 0x56, 0x59, 0xde, 0xeb, 0xd9, 0xba, 0x25, 0xc6, 0x54, 0x5d, 0xf7, 0x0, + 0x4, 0xef, 0x5a, 0xd3, 0xe8, 0x0, 0x16, 0x4a, 0xb8, 0x69, 0xac, 0x93, 0xda, 0x50, 0x52, 0xbe, 0x7e, + 0x7, 0x74, 0x2f, 0x9e, 0x98, 0x54, 0x87, 0x22, 0x90, 0x1e, 0x33, 0x8b, 0x0, 0x13, 0xa7, 0xb0, 0x2e, + 0xf4, 0x78, 0xfe, 0x53, 0x4, 0x21, 0x4e, 0xca, 0x7a, 0x9a, 0x54, 0xd2, 0x13, 0x47, 0x10, 0x82, 0x0, + 0x1, 0xc2, 0x0, 0x6, 0xa5, 0xd0, 0x87, 0xbe, 0xa5, 0x47}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode12) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6198}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xa0, 0x9c, 0x31, 0x9b, 0xd9, 0x1f, 0xc0, + 0xe9, 0x41, 0xaa, 0x36, 0x66, 0xd0, 0x49}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x5, 0xd, 0x15, 0xb3, 0xdd, 0x18, 0xd7, 0xd4, 0xbf, 0xed, 0x46, + 0xfa, 0x1b, 0x27, 0xff, 0x61, 0x84, 0x84, 0x57, 0x3e, 0xe7}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa9, 0xff, 0xd, 0x50, 0x5a, 0x4c, 0x49, 0x27, 0xe, 0x16, + 0x9e, 0xe2, 0xc0, 0xcb, 0x18, 0x5b, 0x88, 0xa8, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe3, 0x4a, 0x71, 0xf8, 0x33, 0xd7, 0x16, 0x3d, 0xc8, 0xa9, + 0x28, 0xdd, 0x15, 0x65, 0x30, 0x3e, 0x93, 0x9c, 0x70, 0x5a, + 0x83, 0x65, 0xa5, 0x17, 0xfc, 0x98, 0x64, 0xf5, 0x85, 0xae}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xc0, 0x90, 0xf, 0xd8, 0x66, 0xc2, 0x5f, 0xa0, 0xa0, 0x27, 0x1f, 0x7d, + 0xc3, 0x56, 0x59, 0xde, 0xeb, 0xd9, 0xba, 0x25, 0xc6, 0x54, 0x5d, 0xf7}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xef, 0x5a, 0xd3, 0xe8}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x4a, 0xb8, 0x69, 0xac, 0x93, 0xda, 0x50, 0x52, 0xbe, 0x7e, 0x7, + 0x74, 0x2f, 0x9e, 0x98, 0x54, 0x87, 0x22, 0x90, 0x1e, 0x33, 0x8b}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xa7, 0xb0, 0x2e, 0xf4, 0x78, 0xfe, 0x53, 0x4, 0x21, 0x4e, + 0xca, 0x7a, 0x9a, 0x54, 0xd2, 0x13, 0x47, 0x10, 0x82}; + lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xc2}; + lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa5, 0xd0, 0x87, 0xbe, 0xa5, 0x47}; + lwmqtt_string_t topic_filter_s9 = {6, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5184, 10, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 21743 +// ["g\SUB\173Z5\135\245\NUL\138\243\130\165\170M\184/O\ETX\214$\241\DC3\147\&8WZ'","\243\253\202\167\210\ACK\253w\239\248\128\US\184\153\242E\242\132\219nOk\250\242qR","\"","U\138\193\246\162T_\SUB\206\&4","\154\&0Tav\255\213\&1\DC2Y","\252=\144O\"ETDc\221\130\228E_4a\DC2\253fn\209\187\138#3","F9\a\224\133\201\252\255\151\253\220\EOT\NUL\ETB3m\140o\135\215lSi\140\155\240\&2\SOH\211\128"] +// [PropSharedSubscriptionAvailable 98] +TEST(Unsubscribe5QCTest, Encode15) { + uint8_t pkt[] = {0xa2, 0x94, 0x1, 0x54, 0xef, 0x2, 0x2a, 0x62, 0x0, 0x1b, 0x67, 0x1a, 0xad, 0x5a, 0x35, 0x87, 0xf5, + 0x0, 0x8a, 0xf3, 0x82, 0xa5, 0xaa, 0x4d, 0xb8, 0x2f, 0x4f, 0x3, 0xd6, 0x24, 0xf1, 0x13, 0x93, 0x38, + 0x57, 0x5a, 0x27, 0x0, 0x1a, 0xf3, 0xfd, 0xca, 0xa7, 0xd2, 0x6, 0xfd, 0x77, 0xef, 0xf8, 0x80, 0x1f, + 0xb8, 0x99, 0xf2, 0x45, 0xf2, 0x84, 0xdb, 0x6e, 0x4f, 0x6b, 0xfa, 0xf2, 0x71, 0x52, 0x0, 0x1, 0x22, + 0x0, 0xa, 0x55, 0x8a, 0xc1, 0xf6, 0xa2, 0x54, 0x5f, 0x1a, 0xce, 0x34, 0x0, 0xa, 0x9a, 0x30, 0x54, + 0x61, 0x76, 0xff, 0xd5, 0x31, 0x12, 0x59, 0x0, 0x19, 0xfc, 0x3d, 0x90, 0x4f, 0x22, 0x45, 0x54, 0x44, + 0x63, 0xdd, 0x82, 0xe4, 0x45, 0x5f, 0x34, 0x61, 0x12, 0xfd, 0x66, 0x6e, 0xd1, 0xbb, 0x8a, 0x23, 0x33, + 0x0, 0x1e, 0x46, 0x39, 0x7, 0xe0, 0x85, 0xc9, 0xfc, 0xff, 0x97, 0xfd, 0xdc, 0x4, 0x0, 0x17, 0x33, + 0x6d, 0x8c, 0x6f, 0x87, 0xd7, 0x6c, 0x53, 0x69, 0x8c, 0x9b, 0xf0, 0x32, 0x1, 0xd3, 0x80}; + uint8_t buf[sizeof(pkt) + 10] = {0}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode13) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 98}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x67, 0x1a, 0xad, 0x5a, 0x35, 0x87, 0xf5, 0x0, 0x8a, 0xf3, 0x82, 0xa5, 0xaa, 0x4d, + 0xb8, 0x2f, 0x4f, 0x3, 0xd6, 0x24, 0xf1, 0x13, 0x93, 0x38, 0x57, 0x5a, 0x27}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf3, 0xfd, 0xca, 0xa7, 0xd2, 0x6, 0xfd, 0x77, 0xef, 0xf8, 0x80, 0x1f, 0xb8, + 0x99, 0xf2, 0x45, 0xf2, 0x84, 0xdb, 0x6e, 0x4f, 0x6b, 0xfa, 0xf2, 0x71, 0x52}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x22}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x55, 0x8a, 0xc1, 0xf6, 0xa2, 0x54, 0x5f, 0x1a, 0xce, 0x34}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9a, 0x30, 0x54, 0x61, 0x76, 0xff, 0xd5, 0x31, 0x12, 0x59}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xfc, 0x3d, 0x90, 0x4f, 0x22, 0x45, 0x54, 0x44, 0x63, 0xdd, 0x82, 0xe4, 0x45, + 0x5f, 0x34, 0x61, 0x12, 0xfd, 0x66, 0x6e, 0xd1, 0xbb, 0x8a, 0x23, 0x33}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x46, 0x39, 0x7, 0xe0, 0x85, 0xc9, 0xfc, 0xff, 0x97, 0xfd, + 0xdc, 0x4, 0x0, 0x17, 0x33, 0x6d, 0x8c, 0x6f, 0x87, 0xd7, + 0x6c, 0x53, 0x69, 0x8c, 0x9b, 0xf0, 0x32, 0x1, 0xd3, 0x80}; + lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21743, 7, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 11426 ["\138\251 +// \SOH\190x\170(\EOT(\NUL\229\US\232\ETX\tH","\212\252_\137\222\158gd\rm\194;&w\RS\242\199\DLE\ETB\253\145\151","xD\194\160"] +// [PropTopicAliasMaximum 5217,PropCorrelationData "*\169\DC1t",PropResponseInformation +// "\ACK0\224\&8\215\163\192\132\255\DC4\226\129\\\179A+o\157~\155\SO",PropUserProperty +// "\207\166@]\175\136\DC3'\r\184\130\159\147=\249\159\211a\186\207V\CANeL\196\&4\144wj" +// "C\a~\200\&4&\133\178\237\SI\237E\NUL",PropRequestProblemInformation 9,PropResponseInformation +// "N\190\&9i\SUBs.D\233$#]\DLE\136\149\170\228\224\SI\ACK\199\140\237\160\DC4Iz",PropReasonString "\NULB\195\248 +// 8\235\247z\b",PropAuthenticationData +// "\170\239G\224\203\229\161\152\160\232@oj6\152V\192>\176:^\CAN\160\SOH9\t\135\EOT",PropReasonString +// "\213\250\233\253\148\163\227\EME\ETX\245{\190qc\163\162EH\NUL\a\ENQh","`\198\220\GSG6\209Q\236\251;","\139Hp\135\199d\160+"] +// [PropResponseInformation +// "@t\NAK\239I\255T\NUL\234u$\b\162Xh\204\159\214:M\231\v\230\189\165$#",PropRequestResponseInformation +// 103,PropAuthenticationData "",PropResponseInformation "\DC4@UB\147\206\239\156`\231\137\bx",PropResponseTopic +// "\204n\229\a\ENQ\177]\226`\EM\209\&8\219u",PropAuthenticationMethod +// "0\232\179\185F\201\b\DLE\180\224z>\157L\226\141\226:h)\216\245\201\235\241|d1",PropResponseTopic +// "\220\223\128\&4\223\222^\193:_W\143G\140\154\SUBD\163",PropContentType +// "9\158\RS\202\251\FS)\132K]\217T\182a\131\217\CAN\185x",PropAuthenticationMethod +// "\220\132\182k\146\240\191\250R\149\168/$\157\216\&4;P\138\250",PropSessionExpiryInterval 17187,PropCorrelationData +// "\131\141\235\238\130w\236\ACKcQ5\166\135\134\160",PropContentType "p\155\&8\149\SO\181",PropUserProperty "Z8\b\234" +// "\161\249\241-\v\156\ESC",PropSubscriptionIdentifier 29,PropReceiveMaximum 23266,PropMaximumPacketSize +// 3356,PropTopicAliasMaximum 7145,PropResponseTopic "\221\244\SUB\SIC\210\165A\DC1\217\143(hW",PropServerKeepAlive +// 502,PropServerKeepAlive 3960,PropWillDelayInterval 1206,PropUserProperty "" +// "x\172\ESCf#\252\234\251\&3\185\211\f\130\244\247",PropAssignedClientIdentifier "",PropSessionExpiryInterval +// 29118,PropResponseInformation +// "\ETBq\221\176v\b\252\146\181\210\171\197\170\242W\247\188\181\SO\180\241\221\ETX",PropRetainAvailable +// 134,PropRequestProblemInformation 51,PropSharedSubscriptionAvailable 51,PropRetainAvailable 129,PropResponseTopic +// "\216\SI\236\&1\204\139\168T\138_\141 l\236\183f\250\135\248!ua\DC2\EM\245"] +TEST(Unsubscribe5QCTest, Encode17) { + uint8_t pkt[] = { + 0xa2, 0xbb, 0x3, 0x16, 0xd1, 0xd8, 0x2, 0x1a, 0x0, 0x1b, 0x40, 0x74, 0x15, 0xef, 0x49, 0xff, 0x54, 0x0, 0xea, + 0x75, 0x24, 0x8, 0xa2, 0x58, 0x68, 0xcc, 0x9f, 0xd6, 0x3a, 0x4d, 0xe7, 0xb, 0xe6, 0xbd, 0xa5, 0x24, 0x23, 0x19, + 0x67, 0x16, 0x0, 0x0, 0x1a, 0x0, 0xd, 0x14, 0x40, 0x55, 0x42, 0x93, 0xce, 0xef, 0x9c, 0x60, 0xe7, 0x89, 0x8, + 0x78, 0x8, 0x0, 0xe, 0xcc, 0x6e, 0xe5, 0x7, 0x5, 0xb1, 0x5d, 0xe2, 0x60, 0x19, 0xd1, 0x38, 0xdb, 0x75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eof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x40, 0x74, 0x15, 0xef, 0x49, 0xff, 0x54, 0x0, 0xea, 0x75, 0x24, 0x8, 0xa2, 0x58, + 0x68, 0xcc, 0x9f, 0xd6, 0x3a, 0x4d, 0xe7, 0xb, 0xe6, 0xbd, 0xa5, 0x24, 0x23}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x14, 0x40, 0x55, 0x42, 0x93, 0xce, 0xef, 0x9c, 0x60, 0xe7, 0x89, 0x8, 0x78}; + uint8_t bytesprops3[] = {0xcc, 0x6e, 0xe5, 0x7, 0x5, 0xb1, 0x5d, 0xe2, 0x60, 0x19, 0xd1, 0x38, 0xdb, 0x75}; + uint8_t bytesprops4[] = {0x30, 0xe8, 0xb3, 0xb9, 0x46, 0xc9, 0x8, 0x10, 0xb4, 0xe0, 0x7a, 0x3e, 0x9d, 0x4c, + 0xe2, 0x8d, 0xe2, 0x3a, 0x68, 0x29, 0xd8, 0xf5, 0xc9, 0xeb, 0xf1, 0x7c, 0x64, 0x31}; + uint8_t bytesprops5[] = {0xdc, 0xdf, 0x80, 0x34, 0xdf, 0xde, 0x5e, 0xc1, 0x3a, + 0x5f, 0x57, 0x8f, 0x47, 0x8c, 0x9a, 0x1a, 0x44, 0xa3}; + uint8_t bytesprops6[] = {0x39, 0x9e, 0x1e, 0xca, 0xfb, 0x1c, 0x29, 0x84, 0x4b, 0x5d, + 0xd9, 0x54, 0xb6, 0x61, 0x83, 0xd9, 0x18, 0xb9, 0x78}; + uint8_t bytesprops7[] = {0xdc, 0x84, 0xb6, 0x6b, 0x92, 0xf0, 0xbf, 0xfa, 0x52, 0x95, + 0xa8, 0x2f, 0x24, 0x9d, 0xd8, 0x34, 0x3b, 0x50, 0x8a, 0xfa}; + uint8_t bytesprops8[] = {0x83, 0x8d, 0xeb, 0xee, 0x82, 0x77, 0xec, 0x6, 0x63, 0x51, 0x35, 0xa6, 0x87, 0x86, 0xa0}; + uint8_t bytesprops9[] = {0x70, 0x9b, 0x38, 0x95, 0xe, 0xb5}; + uint8_t bytesprops11[] = {0xa1, 0xf9, 0xf1, 0x2d, 0xb, 0x9c, 0x1b}; + uint8_t bytesprops10[] = {0x5a, 0x38, 0x8, 0xea}; + uint8_t bytesprops12[] = {0xdd, 0xf4, 0x1a, 0xf, 0x43, 0xd2, 0xa5, 0x41, 0x11, 0xd9, 0x8f, 0x28, 0x68, 0x57}; + uint8_t bytesprops14[] = {0x78, 0xac, 0x1b, 0x66, 0x23, 0xfc, 0xea, 0xfb, 0x33, 0xb9, 0xd3, 0xc, 0x82, 0xf4, 0xf7}; + uint8_t bytesprops13[] = {0}; + uint8_t bytesprops15[] = {0}; + uint8_t bytesprops16[] = {0x17, 0x71, 0xdd, 0xb0, 0x76, 0x8, 0xfc, 0x92, 0xb5, 0xd2, 0xab, 0xc5, + 0xaa, 0xf2, 0x57, 0xf7, 0xbc, 0xb5, 0xe, 0xb4, 0xf1, 0xdd, 0x3}; + uint8_t bytesprops17[] = {0xd8, 0xf, 0xec, 0x31, 0xcc, 0x8b, 0xa8, 0x54, 0x8a, 0x5f, 0x8d, 0x20, 0x6c, + 0xec, 0xb7, 0x66, 0xfa, 0x87, 0xf8, 0x21, 0x75, 0x61, 0x12, 0x19, 0xf5}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode15) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17187}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops10}, .v = {7, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23266}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3356}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7145}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 502}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3960}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1206}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops13}, .v = {15, (char*)&bytesprops14}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29118}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops16}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops17}}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x79, 0x68, 0xfb, 0xa9}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xb2, 0xf, 0x92, 0x47, 0xd2, 0x85, 0x76, 0x99, 0xc, 0x8f, + 0x54, 0xbc, 0xbb, 0x63, 0xf, 0xe3, 0xa, 0xa, 0x15, 0x2a, + 0x66, 0x54, 0x52, 0x6c, 0xcd, 0x4d, 0xe0, 0x63, 0x21}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x20, 0xa1, 0xb, 0x55, 0xf2, 0x16, 0x3a, 0xe0}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb6, 0x6f, 0x5f, 0xd5, 0x83, 0xfd, 0x48, 0x6b, 0x58, 0x3e, 0xf5, 0x7b, + 0xbe, 0x71, 0x63, 0xa3, 0xa2, 0x45, 0x48, 0x0, 0x7, 0x5, 0x68}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x60, 0xc6, 0xdc, 0x1d, 0x47, 0x36, 0xd1, 0x51, 0xec, 0xfb, 0x3b}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8b, 0x48, 0x70, 0x87, 0xc7, 0x64, 0xa0, 0x2b}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5841, 6, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 26803 +// ["h\b\248\219\SI\197\167\148#\226\147\153}","f\166\188I8\138","o\166\FS\210\138\156\166\234\SUB:%\155N\154\226\132\233E"] +// [PropResponseInformation "\USvE\182\163\248k\DC3 +// \221\254\232\167\186\181Y\155\173X\209\242\132t",PropMessageExpiryInterval 20360,PropMaximumPacketSize +// 13975,PropAuthenticationData +// "q\RS\SOH'\SYN\132j1\245\141\&4r\173\&9k\251f\DC2\233\238*\222\130o\194\203\EOTb",PropContentType +// "e)\148BfT6\DEL\181a\DC2\SYN\145",PropPayloadFormatIndicator 174,PropReasonString "\DLE\223\169\189\162Q\128\ENQ\154 +// |\226qCj\186\253`\222@\128\a \236",PropMaximumQoS 65,PropSubscriptionIdentifierAvailable +// 221,PropPayloadFormatIndicator 174,PropMaximumQoS 100,PropRequestResponseInformation 162,PropUserProperty +// "(\167\172\a\NAK\209\206\166\225nR{\130\177\146ZP\252l\SYN\a\251\164\146" "\241\US\"",PropSharedSubscriptionAvailable +// 34,PropRetainAvailable 89] +TEST(Unsubscribe5QCTest, Encode18) { + uint8_t pkt[] = { + 0xa2, 0xcd, 0x1, 0x68, 0xb3, 0x9e, 0x1, 0x1a, 0x0, 0x17, 0x1f, 0x76, 0x45, 0xb6, 0xa3, 0xf8, 0x6b, 0x13, 0x20, + 0xdd, 0xfe, 0xe8, 0xa7, 0xba, 0xb5, 0x59, 0x9b, 0xad, 0x58, 0xd1, 0xf2, 0x84, 0x74, 0x2, 0x0, 0x0, 0x4f, 0x88, + 0x27, 0x0, 0x0, 0x36, 0x97, 0x16, 0x0, 0x1c, 0x71, 0x1e, 0x1, 0x27, 0x16, 0x84, 0x6a, 0x31, 0xf5, 0x8d, 0x34, + 0x72, 0xad, 0x39, 0x6b, 0xfb, 0x66, 0x12, 0xe9, 0xee, 0x2a, 0xde, 0x82, 0x6f, 0xc2, 0xcb, 0x4, 0x62, 0x3, 0x0, + 0xd, 0x65, 0x29, 0x94, 0x42, 0x66, 0x54, 0x36, 0x7f, 0xb5, 0x61, 0x12, 0x16, 0x91, 0x1, 0xae, 0x1f, 0x0, 0x18, + 0x10, 0xdf, 0xa9, 0xbd, 0xa2, 0x51, 0x80, 0x5, 0x9a, 0x20, 0x7c, 0xe2, 0x71, 0x43, 0x6a, 0xba, 0xfd, 0x60, 0xde, + 0x40, 0x80, 0x7, 0x20, 0xec, 0x24, 0x41, 0x29, 0xdd, 0x1, 0xae, 0x24, 0x64, 0x19, 0xa2, 0x26, 0x0, 0x18, 0x28, + 0xa7, 0xac, 0x7, 0x15, 0xd1, 0xce, 0xa6, 0xe1, 0x6e, 0x52, 0x7b, 0x82, 0xb1, 0x92, 0x5a, 0x50, 0xfc, 0x6c, 0x16, + 0x7, 0xfb, 0xa4, 0x92, 0x0, 0x3, 0xf1, 0x1f, 0x22, 0x2a, 0x22, 0x25, 0x59, 0x0, 0xd, 0x68, 0x8, 0xf8, 0xdb, + 0xf, 0xc5, 0xa7, 0x94, 0x23, 0xe2, 0x93, 0x99, 0x7d, 0x0, 0x6, 0x66, 0xa6, 0xbc, 0x49, 0x38, 0x8a, 0x0, 0x12, + 0x6f, 0xa6, 0x1c, 0xd2, 0x8a, 0x9c, 0xa6, 0xea, 0x1a, 0x3a, 0x25, 0x9b, 0x4e, 0x9a, 0xe2, 0x84, 0xe9, 0x45}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1f, 0x76, 0x45, 0xb6, 0xa3, 0xf8, 0x6b, 0x13, 0x20, 0xdd, 0xfe, 0xe8, + 0xa7, 0xba, 0xb5, 0x59, 0x9b, 0xad, 0x58, 0xd1, 0xf2, 0x84, 0x74}; + uint8_t bytesprops1[] = {0x71, 0x1e, 0x1, 0x27, 0x16, 0x84, 0x6a, 0x31, 0xf5, 0x8d, 0x34, 0x72, 0xad, 0x39, + 0x6b, 0xfb, 0x66, 0x12, 0xe9, 0xee, 0x2a, 0xde, 0x82, 0x6f, 0xc2, 0xcb, 0x4, 0x62}; + uint8_t bytesprops2[] = {0x65, 0x29, 0x94, 0x42, 0x66, 0x54, 0x36, 0x7f, 0xb5, 0x61, 0x12, 0x16, 0x91}; + uint8_t bytesprops3[] = {0x10, 0xdf, 0xa9, 0xbd, 0xa2, 0x51, 0x80, 0x5, 0x9a, 0x20, 0x7c, 0xe2, + 0x71, 0x43, 0x6a, 0xba, 0xfd, 0x60, 0xde, 0x40, 0x80, 0x7, 0x20, 0xec}; + uint8_t bytesprops5[] = {0xf1, 0x1f, 0x22}; + uint8_t bytesprops4[] = {0x28, 0xa7, 0xac, 0x7, 0x15, 0xd1, 0xce, 0xa6, 0xe1, 0x6e, 0x52, 0x7b, + 0x82, 0xb1, 0x92, 0x5a, 0x50, 0xfc, 0x6c, 0x16, 0x7, 0xfb, 0xa4, 0x92}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode16) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20360}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13975}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops4}, .v = {3, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 89}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x68, 0x8, 0xf8, 0xdb, 0xf, 0xc5, 0xa7, 0x94, 0x23, 0xe2, 0x93, 0x99, 0x7d}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x66, 0xa6, 0xbc, 0x49, 0x38, 0x8a}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x6f, 0xa6, 0x1c, 0xd2, 0x8a, 0x9c, 0xa6, 0xea, 0x1a, + 0x3a, 0x25, 0x9b, 0x4e, 0x9a, 0xe2, 0x84, 0xe9, 0x45}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26803, 3, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 22595 ["","r3\FS\a(<\131w\CAN\204\229"] [PropMessageExpiryInterval 9208,PropMaximumQoS +// 227,PropTopicAliasMaximum 25061,PropTopicAliasMaximum 9521,PropWillDelayInterval +// 19511,PropSharedSubscriptionAvailable 152,PropServerReference +// "\233u\f\131\237\DC2\DC4\128\\\185\187R\218_\155t\ENQ\STX\140",PropMaximumPacketSize 4920,PropPayloadFormatIndicator +// 17,PropResponseInformation "\US\186a",PropTopicAlias 2483,PropMaximumPacketSize 139,PropCorrelationData +// "\t\FS\222\252",PropTopicAliasMaximum 602,PropSubscriptionIdentifierAvailable 119,PropWillDelayInterval +// 22699,PropRetainAvailable 215] +TEST(Unsubscribe5QCTest, Encode19) { + uint8_t pkt[] = {0xa2, 0x64, 0x58, 0x43, 0x52, 0x2, 0x0, 0x0, 0x23, 0xf8, 0x24, 0xe3, 0x22, 0x61, 0xe5, + 0x22, 0x25, 0x31, 0x18, 0x0, 0x0, 0x4c, 0x37, 0x2a, 0x98, 0x1c, 0x0, 0x13, 0xe9, 0x75, + 0xc, 0x83, 0xed, 0x12, 0x14, 0x80, 0x5c, 0xb9, 0xbb, 0x52, 0xda, 0x5f, 0x9b, 0x74, 0x5, + 0x2, 0x8c, 0x27, 0x0, 0x0, 0x13, 0x38, 0x1, 0x11, 0x1a, 0x0, 0x3, 0x1f, 0xba, 0x61, + 0x23, 0x9, 0xb3, 0x27, 0x0, 0x0, 0x0, 0x8b, 0x9, 0x0, 0x4, 0x9, 0x1c, 0xde, 0xfc, + 0x22, 0x2, 0x5a, 0x29, 0x77, 0x18, 0x0, 0x0, 0x58, 0xab, 0x25, 0xd7, 0x0, 0x0, 0x0, + 0xb, 0x72, 0x33, 0x1c, 0x7, 0x28, 0x3c, 0x83, 0x77, 0x18, 0xcc, 0xe5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe9, 0x75, 0xc, 0x83, 0xed, 0x12, 0x14, 0x80, 0x5c, 0xb9, + 0xbb, 0x52, 0xda, 0x5f, 0x9b, 0x74, 0x5, 0x2, 0x8c}; + uint8_t bytesprops1[] = {0x1f, 0xba, 0x61}; + uint8_t bytesprops2[] = {0x9, 0x1c, 0xde, 0xfc}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode17) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9208}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25061}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9521}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19511}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4920}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2483}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 139}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 602}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22699}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x72, 0x33, 0x1c, 0x7, 0x28, 0x3c, 0x83, 0x77, 0x18, 0xcc, 0xe5}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22595, 2, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 907 +// ["\141\FS\ETX\162\204'\133\DLE7\237\140\\w>\252:\aS\161s\SI\179:\248\150E","*,\176\143\254R\241\242\DLE\173a.\225\151\159I:\161","\\X$\251\237\251W\215P\a\133A\163\145\225D\SYN^\163\bf\237\174\STX\141\230\189w\161\162","\217\182-\169\169\173\191Hx@\206Qi\188\231\210D\165\NUL\165\ENQ\220\232\224\226>"] +// [PropCorrelationData "\DC2D\234\t\n\241\140\244[^/\203\222\202^SSp\220\226\158(",PropMessageExpiryInterval +// 2595,PropRetainAvailable 14,PropMaximumPacketSize 149,PropServerKeepAlive 19177,PropReceiveMaximum +// 32247,PropWillDelayInterval 22627,PropUserProperty "" +// "\200\226\240\205\DEL\190{\DC2\132(s\ETB",PropMessageExpiryInterval 1055] +TEST(Unsubscribe5QCTest, Encode20) { + uint8_t pkt[] = {0xa2, 0xb5, 0x1, 0x3, 0x8b, 0x46, 0x9, 0x0, 0x16, 0x12, 0x44, 0xea, 0x9, 0xa, 0xf1, 0x8c, 0xf4, + 0x5b, 0x5e, 0x2f, 0xcb, 0xde, 0xca, 0x5e, 0x53, 0x53, 0x70, 0xdc, 0xe2, 0x9e, 0x28, 0x2, 0x0, 0x0, + 0xa, 0x23, 0x25, 0xe, 0x27, 0x0, 0x0, 0x0, 0x95, 0x13, 0x4a, 0xe9, 0x21, 0x7d, 0xf7, 0x18, 0x0, + 0x0, 0x58, 0x63, 0x26, 0x0, 0x0, 0x0, 0xc, 0xc8, 0xe2, 0xf0, 0xcd, 0x7f, 0xbe, 0x7b, 0x12, 0x84, + 0x28, 0x73, 0x17, 0x2, 0x0, 0x0, 0x4, 0x1f, 0x0, 0x1a, 0x8d, 0x1c, 0x3, 0xa2, 0xcc, 0x27, 0x85, + 0x10, 0x37, 0xed, 0x8c, 0x5c, 0x77, 0x3e, 0xfc, 0x3a, 0x7, 0x53, 0xa1, 0x73, 0xf, 0xb3, 0x3a, 0xf8, + 0x96, 0x45, 0x0, 0x12, 0x2a, 0x2c, 0xb0, 0x8f, 0xfe, 0x52, 0xf1, 0xf2, 0x10, 0xad, 0x61, 0x2e, 0xe1, + 0x97, 0x9f, 0x49, 0x3a, 0xa1, 0x0, 0x1e, 0x5c, 0x58, 0x24, 0xfb, 0xed, 0xfb, 0x57, 0xd7, 0x50, 0x7, + 0x85, 0x41, 0xa3, 0x91, 0xe1, 0x44, 0x16, 0x5e, 0xa3, 0x8, 0x66, 0xed, 0xae, 0x2, 0x8d, 0xe6, 0xbd, + 0x77, 0xa1, 0xa2, 0x0, 0x1a, 0xd9, 0xb6, 0x2d, 0xa9, 0xa9, 0xad, 0xbf, 0x48, 0x78, 0x40, 0xce, 0x51, + 0x69, 0xbc, 0xe7, 0xd2, 0x44, 0xa5, 0x0, 0xa5, 0x5, 0xdc, 0xe8, 0xe0, 0xe2, 0x3e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x12, 0x44, 0xea, 0x9, 0xa, 0xf1, 0x8c, 0xf4, 0x5b, 0x5e, 0x2f, + 0xcb, 0xde, 0xca, 0x5e, 0x53, 0x53, 0x70, 0xdc, 0xe2, 0x9e, 0x28}; + uint8_t bytesprops2[] = {0xc8, 0xe2, 0xf0, 0xcd, 0x7f, 0xbe, 0x7b, 0x12, 0x84, 0x28, 0x73, 0x17}; + uint8_t bytesprops1[] = {0}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode18) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2595}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 149}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19177}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32247}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22627}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops1}, .v = {12, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1055}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x8d, 0x1c, 0x3, 0xa2, 0xcc, 0x27, 0x85, 0x10, 0x37, 0xed, 0x8c, 0x5c, 0x77, + 0x3e, 0xfc, 0x3a, 0x7, 0x53, 0xa1, 0x73, 0xf, 0xb3, 0x3a, 0xf8, 0x96, 0x45}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2a, 0x2c, 0xb0, 0x8f, 0xfe, 0x52, 0xf1, 0xf2, 0x10, + 0xad, 0x61, 0x2e, 0xe1, 0x97, 0x9f, 0x49, 0x3a, 0xa1}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x5c, 0x58, 0x24, 0xfb, 0xed, 0xfb, 0x57, 0xd7, 0x50, 0x7, + 0x85, 0x41, 0xa3, 0x91, 0xe1, 0x44, 0x16, 0x5e, 0xa3, 0x8, + 0x66, 0xed, 0xae, 0x2, 0x8d, 0xe6, 0xbd, 0x77, 0xa1, 0xa2}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd9, 0xb6, 0x2d, 0xa9, 0xa9, 0xad, 0xbf, 0x48, 0x78, 0x40, 0xce, 0x51, 0x69, + 0xbc, 0xe7, 0xd2, 0x44, 0xa5, 0x0, 0xa5, 0x5, 0xdc, 0xe8, 0xe0, 0xe2, 0x3e}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 907, 4, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 24572 +// ["\209r2\129\173f\255\143\237!\188m\134\&4#\167\156\211[@D\181\SO\161\210\n\235\&4","\133\164\149\&5\205\251\223","Bf.\183r\147H\252","/\130V\141\130\200\131\248\b\162Eb\DC2\EM\202r\182\251\FSKJ\186"] +// [PropCorrelationData +// "\205^\EM\241I\ACKH\152ni\249\224\&1\DC1\157\142>\149\218\&2\226\242\166\DLEL\141\217\158k?",PropCorrelationData +// "\"O\248\226\189\164\192",PropSessionExpiryInterval 43,PropServerReference "z\214\130",PropReasonString +// "b~3\ETX!Z\252\198\128\181#\243\202",PropMessageExpiryInterval 6944,PropRetainAvailable +// 127,PropSharedSubscriptionAvailable 183,PropAuthenticationMethod "\232\t\139\253!",PropContentType +// "\176\184#\GStZ$>\185Bk\175\183\RSb\DC3\235\204",PropPayloadFormatIndicator 239,PropSubscriptionIdentifier +// 3,PropRequestResponseInformation 209,PropServerReference "",PropSubscriptionIdentifier 17,PropSubscriptionIdentifier +// 4,PropServerKeepAlive 29028,PropRequestResponseInformation 90,PropMessageExpiryInterval 28968,PropRetainAvailable +// 43,PropResponseTopic "\141Mv\160\SOH\197|\226\136\&9Om)\176:\205\v]",PropAuthenticationData +// "\n\237\EOTp\SYN\195\158\155\171\230\t\226>\245N\249\191F\ETX\252\203Y\224C\229S",PropAuthenticationMethod +// "\135\166\CAN0\128\159\188\244\DC4-\130\191\173\188\225y\225\141\129S0\a\201D\231\159\222",PropTopicAlias +// 21823,PropWildcardSubscriptionAvailable 248,PropUserProperty "t\193\234\184\SYNi\DEL\147\ACK" "z\212#\175\144~\n"] +TEST(Unsubscribe5QCTest, Encode21) { + uint8_t pkt[] = { + 0xa2, 0xbc, 0x2, 0x5f, 0xfc, 0xef, 0x1, 0x9, 0x0, 0x1e, 0xcd, 0x5e, 0x19, 0xf1, 0x49, 0x6, 0x48, 0x98, 0x6e, + 0x69, 0xf9, 0xe0, 0x31, 0x11, 0x9d, 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x8d, 0x81, 0x53, 0x30, 0x7, 0xc9, 0x44, 0xe7, 0x9f, 0xde, 0x23, 0x55, 0x3f, 0x28, 0xf8, 0x26, 0x0, 0x9, + 0x74, 0xc1, 0xea, 0xb8, 0x16, 0x69, 0x7f, 0x93, 0x6, 0x0, 0x7, 0x7a, 0xd4, 0x23, 0xaf, 0x90, 0x7e, 0xa, 0x0, + 0x1c, 0xd1, 0x72, 0x32, 0x81, 0xad, 0x66, 0xff, 0x8f, 0xed, 0x21, 0xbc, 0x6d, 0x86, 0x34, 0x23, 0xa7, 0x9c, 0xd3, + 0x5b, 0x40, 0x44, 0xb5, 0xe, 0xa1, 0xd2, 0xa, 0xeb, 0x34, 0x0, 0x7, 0x85, 0xa4, 0x95, 0x35, 0xcd, 0xfb, 0xdf, + 0x0, 0x8, 0x42, 0x66, 0x2e, 0xb7, 0x72, 0x93, 0x48, 0xfc, 0x0, 0x16, 0x2f, 0x82, 0x56, 0x8d, 0x82, 0xc8, 0x83, + 0xf8, 0x8, 0xa2, 0x45, 0x62, 0x12, 0x19, 0xca, 0x72, 0xb6, 0xfb, 0x1c, 0x4b, 0x4a, 0xba}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xcd, 0x5e, 0x19, 0xf1, 0x49, 0x6, 0x48, 0x98, 0x6e, 0x69, 0xf9, 0xe0, 0x31, 0x11, 0x9d, + 0x8e, 0x3e, 0x95, 0xda, 0x32, 0xe2, 0xf2, 0xa6, 0x10, 0x4c, 0x8d, 0xd9, 0x9e, 0x6b, 0x3f}; + uint8_t bytesprops1[] = {0x22, 0x4f, 0xf8, 0xe2, 0xbd, 0xa4, 0xc0}; + uint8_t bytesprops2[] = {0x7a, 0xd6, 0x82}; + uint8_t bytesprops3[] = {0x62, 0x7e, 0x33, 0x3, 0x21, 0x5a, 0xfc, 0xc6, 0x80, 0xb5, 0x23, 0xf3, 0xca}; + uint8_t bytesprops4[] = {0xe8, 0x9, 0x8b, 0xfd, 0x21}; + uint8_t bytesprops5[] = {0xb0, 0xb8, 0x23, 0x1d, 0x74, 0x5a, 0x24, 0x3e, 0xb9, + 0x42, 0x6b, 0xaf, 0xb7, 0x1e, 0x62, 0x13, 0xeb, 0xcc}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops7[] = {0x8d, 0x4d, 0x76, 0xa0, 0x1, 0xc5, 0x7c, 0xe2, 0x88, + 0x39, 0x4f, 0x6d, 0x29, 0xb0, 0x3a, 0xcd, 0xb, 0x5d}; + uint8_t bytesprops8[] = {0xa, 0xed, 0x4, 0x70, 0x16, 0xc3, 0x9e, 0x9b, 0xab, 0xe6, 0x9, 0xe2, 0x3e, + 0xf5, 0x4e, 0xf9, 0xbf, 0x46, 0x3, 0xfc, 0xcb, 0x59, 0xe0, 0x43, 0xe5, 0x53}; + uint8_t bytesprops9[] = {0x87, 0xa6, 0x18, 0x30, 0x80, 0x9f, 0xbc, 0xf4, 0x14, 0x2d, 0x82, 0xbf, 0xad, 0xbc, + 0xe1, 0x79, 0xe1, 0x8d, 0x81, 0x53, 0x30, 0x7, 0xc9, 0x44, 0xe7, 0x9f, 0xde}; + uint8_t bytesprops11[] = {0x7a, 0xd4, 0x23, 0xaf, 0x90, 0x7e, 0xa}; + uint8_t bytesprops10[] = {0x74, 0xc1, 0xea, 0xb8, 0x16, 0x69, 0x7f, 0x93, 0x6}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode19) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 43}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6944}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29028}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28968}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21823}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops10}, .v = {7, (char*)&bytesprops11}}}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xd1, 0x72, 0x32, 0x81, 0xad, 0x66, 0xff, 0x8f, 0xed, 0x21, + 0xbc, 0x6d, 0x86, 0x34, 0x23, 0xa7, 0x9c, 0xd3, 0x5b, 0x40, + 0x44, 0xb5, 0xe, 0xa1, 0xd2, 0xa, 0xeb, 0x34}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x85, 0xa4, 0x95, 0x35, 0xcd, 0xfb, 0xdf}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x42, 0x66, 0x2e, 0xb7, 0x72, 0x93, 0x48, 0xfc}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x2f, 0x82, 0x56, 0x8d, 0x82, 0xc8, 0x83, 0xf8, 0x8, 0xa2, 0x45, + 0x62, 0x12, 0x19, 0xca, 0x72, 0xb6, 0xfb, 0x1c, 0x4b, 0x4a, 0xba}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24572, 4, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 22215 +// ["tkb\217BA\193-\r\243\141\144\131?#\SO\181p\150,\n\DEL)!","`\148\&8\EOT\EM\209\DLEI\193\218\148\180?\184X`,","\177V]\a8>\139\248\US\158\&4Pz\232|\147S\229\149\145\150\170\185\240'","\242M!M\182ds\247I\DEL\233\&0X),\206\155\200\232\182","s\SOH\149\210\176E\148\180\164\142\v\225gk\198\168\139/\161\240\249T\155)\140*","\165\EM\192\148-\241\213\188\182w\155\ESC*\NUL\RS*)\177h","\244\148-\DC3A\174,d\225\215d\170x"] +// [PropTopicAliasMaximum 31672,PropWildcardSubscriptionAvailable 140,PropTopicAlias 31200,PropResponseInformation +// "\t\192\t",PropRequestProblemInformation 247,PropSharedSubscriptionAvailable 136,PropReceiveMaximum +// 3232,PropRequestResponseInformation 225,PropReceiveMaximum 12340] +TEST(Unsubscribe5QCTest, Encode22) { + uint8_t pkt[] = { + 0xa2, 0xbb, 0x1, 0x56, 0xc7, 0x1a, 0x22, 0x7b, 0xb8, 0x28, 0x8c, 0x23, 0x79, 0xe0, 0x1a, 0x0, 0x3, 0x9, 0xc0, + 0x9, 0x17, 0xf7, 0x2a, 0x88, 0x21, 0xc, 0xa0, 0x19, 0xe1, 0x21, 0x30, 0x34, 0x0, 0x18, 0x74, 0x6b, 0x62, 0xd9, + 0x42, 0x41, 0xc1, 0x2d, 0xd, 0xf3, 0x8d, 0x90, 0x83, 0x3f, 0x23, 0xe, 0xb5, 0x70, 0x96, 0x2c, 0xa, 0x7f, 0x29, + 0x21, 0x0, 0x11, 0x60, 0x94, 0x38, 0x4, 0x19, 0xd1, 0x10, 0x49, 0xc1, 0xda, 0x94, 0xb4, 0x3f, 0xb8, 0x58, 0x60, + 0x2c, 0x0, 0x19, 0xb1, 0x56, 0x5d, 0x7, 0x38, 0x3e, 0x8b, 0xf8, 0x1f, 0x9e, 0x34, 0x50, 0x7a, 0xe8, 0x7c, 0x93, + 0x53, 0xe5, 0x95, 0x91, 0x96, 0xaa, 0xb9, 0xf0, 0x27, 0x0, 0x14, 0xf2, 0x4d, 0x21, 0x4d, 0xb6, 0x64, 0x73, 0xf7, + 0x49, 0x7f, 0xe9, 0x30, 0x58, 0x29, 0x2c, 0xce, 0x9b, 0xc8, 0xe8, 0xb6, 0x0, 0x1a, 0x73, 0x1, 0x95, 0xd2, 0xb0, + 0x45, 0x94, 0xb4, 0xa4, 0x8e, 0xb, 0xe1, 0x67, 0x6b, 0xc6, 0xa8, 0x8b, 0x2f, 0xa1, 0xf0, 0xf9, 0x54, 0x9b, 0x29, + 0x8c, 0x2a, 0x0, 0x13, 0xa5, 0x19, 0xc0, 0x94, 0x2d, 0xf1, 0xd5, 0xbc, 0xb6, 0x77, 0x9b, 0x1b, 0x2a, 0x0, 0x1e, + 0x2a, 0x29, 0xb1, 0x68, 0x0, 0xd, 0xf4, 0x94, 0x2d, 0x13, 0x41, 0xae, 0x2c, 0x64, 0xe1, 0xd7, 0x64, 0xaa, 0x78}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x9, 0xc0, 0x9}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode20) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31672}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31200}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3232}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12340}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x74, 0x6b, 0x62, 0xd9, 0x42, 0x41, 0xc1, 0x2d, 0xd, 0xf3, 0x8d, 0x90, + 0x83, 0x3f, 0x23, 0xe, 0xb5, 0x70, 0x96, 0x2c, 0xa, 0x7f, 0x29, 0x21}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x60, 0x94, 0x38, 0x4, 0x19, 0xd1, 0x10, 0x49, 0xc1, + 0xda, 0x94, 0xb4, 0x3f, 0xb8, 0x58, 0x60, 0x2c}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb1, 0x56, 0x5d, 0x7, 0x38, 0x3e, 0x8b, 0xf8, 0x1f, 0x9e, 0x34, 0x50, 0x7a, + 0xe8, 0x7c, 0x93, 0x53, 0xe5, 0x95, 0x91, 0x96, 0xaa, 0xb9, 0xf0, 0x27}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf2, 0x4d, 0x21, 0x4d, 0xb6, 0x64, 0x73, 0xf7, 0x49, 0x7f, + 0xe9, 0x30, 0x58, 0x29, 0x2c, 0xce, 0x9b, 0xc8, 0xe8, 0xb6}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x73, 0x1, 0x95, 0xd2, 0xb0, 0x45, 0x94, 0xb4, 0xa4, 0x8e, 0xb, 0xe1, 0x67, + 0x6b, 0xc6, 0xa8, 0x8b, 0x2f, 0xa1, 0xf0, 0xf9, 0x54, 0x9b, 0x29, 0x8c, 0x2a}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa5, 0x19, 0xc0, 0x94, 0x2d, 0xf1, 0xd5, 0xbc, 0xb6, 0x77, + 0x9b, 0x1b, 0x2a, 0x0, 0x1e, 0x2a, 0x29, 0xb1, 0x68}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xf4, 0x94, 0x2d, 0x13, 0x41, 0xae, 0x2c, 0x64, 0xe1, 0xd7, 0x64, 0xaa, 0x78}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22215, 7, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 6585 +// ["\230\183q\150\255f\RS\133,\EM\151s\DC4","\160\239\214T\CANS\255\134\169\182\167ri\233\201","B\149Ms7\DC2\234x\185t\233\239\247\EOT\150\\\225\NUL\DC4\SO$\tP\190\DC3","\231\130\&50\142?\232\228\STX\183\182\159h\211\140\218N\ESC\ENQL\161=\158\251\166","\218\230\&2\130\163\DLE","\130q\162\EOT:\240\"\206`\134|\162","l\185N\132\177\203*","SB\DC1\\\186\191\167iq\187\204\a\NAK\137\214u\155\n"] +// [PropWildcardSubscriptionAvailable 25,PropWildcardSubscriptionAvailable 71,PropResponseInformation +// "\159\253\198f\154\DC1\143e\153\a|W\208\140f\210\DC4H\227\144\183",PropSubscriptionIdentifier 27,PropResponseTopic +// "\128\176XG\181\NUL\r\228\220\237\DC3O\173\ETB\239vD2\ENQ\156\180",PropTopicAlias 23925,PropReasonString +// "{=@F\SO\159\238\207w\145\136\243j\172L\200\246\192U*\212\131@\215A\239el*\187",PropMaximumQoS +// 225,PropWillDelayInterval 32196,PropSubscriptionIdentifierAvailable 174,PropServerReference +// "\238\186y\159\214\137j<\153\195\202\\\160W\"\204!\214C",PropMessageExpiryInterval 14388,PropPayloadFormatIndicator +// 179,PropServerReference "\"\GS\132\146\241\184\t\157\128",PropMessageExpiryInterval 25165,PropWillDelayInterval +// 5332,PropRequestProblemInformation 55,PropWillDelayInterval 1710,PropContentType +// "8\217\136\SYN\241\SI",PropMaximumPacketSize 11435,PropUserProperty "<\254\STX\227\&7\240D" +// "TswK\\L/\217\138A\195\230\158\227VT\r\178",PropMessageExpiryInterval 12725,PropTopicAliasMaximum +// 29756,PropResponseTopic "\253\&6w\174\223\r\bO\178#\156/\243\140:N\132U\155\244^",PropTopicAliasMaximum +// 30499,PropContentType "\138o4K\192\228\ETXR\165\172T\227GE3",PropServerReference +// "\158u\167{7\198\aC\160x[\199\128\144\213\140+s\226\128\191\146\221N\241Y",PropSubscriptionIdentifier 4] +TEST(Unsubscribe5QCTest, Encode23) { + uint8_t pkt[] = { + 0xa2, 0xaa, 0x3, 0x19, 0xb9, 0x9d, 0x2, 0x28, 0x19, 0x28, 0x47, 0x1a, 0x0, 0x15, 0x9f, 0xfd, 0xc6, 0x66, 0x9a, + 0x11, 0x8f, 0x65, 0x99, 0x7, 0x7c, 0x57, 0xd0, 0x8c, 0x66, 0xd2, 0x14, 0x48, 0xe3, 0x90, 0xb7, 0xb, 0x1b, 0x8, + 0x0, 0x15, 0x80, 0xb0, 0x58, 0x47, 0xb5, 0x0, 0xd, 0xe4, 0xdc, 0xed, 0x13, 0x4f, 0xad, 0x17, 0xef, 0x76, 0x44, + 0x32, 0x5, 0x9c, 0xb4, 0x23, 0x5d, 0x75, 0x1f, 0x0, 0x1e, 0x7b, 0x3d, 0x40, 0x46, 0xe, 0x9f, 0xee, 0xcf, 0x77, + 0x91, 0x88, 0xf3, 0x6a,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b, 0x37, 0xc6, 0x7, 0x43, 0xa0, 0x78, 0x5b, 0xc7, 0x80, 0x90, 0xd5, 0x8c, 0x2b, 0x73, 0xe2, 0x80, 0xbf, + 0x92, 0xdd, 0x4e, 0xf1, 0x59, 0xb, 0x4, 0x0, 0xd, 0xe6, 0xb7, 0x71, 0x96, 0xff, 0x66, 0x1e, 0x85, 0x2c, 0x19, + 0x97, 0x73, 0x14, 0x0, 0xf, 0xa0, 0xef, 0xd6, 0x54, 0x18, 0x53, 0xff, 0x86, 0xa9, 0xb6, 0xa7, 0x72, 0x69, 0xe9, + 0xc9, 0x0, 0x19, 0x42, 0x95, 0x4d, 0x73, 0x37, 0x12, 0xea, 0x78, 0xb9, 0x74, 0xe9, 0xef, 0xf7, 0x4, 0x96, 0x5c, + 0xe1, 0x0, 0x14, 0xe, 0x24, 0x9, 0x50, 0xbe, 0x13, 0x0, 0x19, 0xe7, 0x82, 0x35, 0x30, 0x8e, 0x3f, 0xe8, 0xe4, + 0x2, 0xb7, 0xb6, 0x9f, 0x68, 0xd3, 0x8c, 0xda, 0x4e, 0x1b, 0x5, 0x4c, 0xa1, 0x3d, 0x9e, 0xfb, 0xa6, 0x0, 0x6, + 0xda, 0xe6, 0x32, 0x82, 0xa3, 0x10, 0x0, 0xc, 0x82, 0x71, 0xa2, 0x4, 0x3a, 0xf0, 0x22, 0xce, 0x60, 0x86, 0x7c, + 0xa2, 0x0, 0x7, 0x6c, 0xb9, 0x4e, 0x84, 0xb1, 0xcb, 0x2a, 0x0, 0x12, 0x53, 0x42, 0x11, 0x5c, 0xba, 0xbf, 0xa7, + 0x69, 0x71, 0xbb, 0xcc, 0x7, 0x15, 0x89, 0xd6, 0x75, 0x9b, 0xa}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x9f, 0xfd, 0xc6, 0x66, 0x9a, 0x11, 0x8f, 0x65, 0x99, 0x7, 0x7c, + 0x57, 0xd0, 0x8c, 0x66, 0xd2, 0x14, 0x48, 0xe3, 0x90, 0xb7}; + uint8_t bytesprops1[] = {0x80, 0xb0, 0x58, 0x47, 0xb5, 0x0, 0xd, 0xe4, 0xdc, 0xed, 0x13, + 0x4f, 0xad, 0x17, 0xef, 0x76, 0x44, 0x32, 0x5, 0x9c, 0xb4}; + uint8_t bytesprops2[] = {0x7b, 0x3d, 0x40, 0x46, 0xe, 0x9f, 0xee, 0xcf, 0x77, 0x91, 0x88, 0xf3, 0x6a, 0xac, 0x4c, + 0xc8, 0xf6, 0xc0, 0x55, 0x2a, 0xd4, 0x83, 0x40, 0xd7, 0x41, 0xef, 0x65, 0x6c, 0x2a, 0xbb}; + uint8_t bytesprops3[] = {0xee, 0xba, 0x79, 0x9f, 0xd6, 0x89, 0x6a, 0x3c, 0x99, 0xc3, + 0xca, 0x5c, 0xa0, 0x57, 0x22, 0xcc, 0x21, 0xd6, 0x43}; + uint8_t bytesprops4[] = {0x22, 0x1d, 0x84, 0x92, 0xf1, 0xb8, 0x9, 0x9d, 0x80}; + uint8_t bytesprops5[] = {0x38, 0xd9, 0x88, 0x16, 0xf1, 0xf}; + uint8_t bytesprops7[] = {0x54, 0x73, 0x77, 0x4b, 0x5c, 0x4c, 0x2f, 0xd9, 0x8a, + 0x41, 0xc3, 0xe6, 0x9e, 0xe3, 0x56, 0x54, 0xd, 0xb2}; + uint8_t bytesprops6[] = {0x3c, 0xfe, 0x2, 0xe3, 0x37, 0xf0, 0x44}; + uint8_t bytesprops8[] = {0xfd, 0x36, 0x77, 0xae, 0xdf, 0xd, 0x8, 0x4f, 0xb2, 0x23, 0x9c, + 0x2f, 0xf3, 0x8c, 0x3a, 0x4e, 0x84, 0x55, 0x9b, 0xf4, 0x5e}; + uint8_t bytesprops9[] = {0x8a, 0x6f, 0x34, 0x4b, 0xc0, 0xe4, 0x3, 0x52, 0xa5, 0xac, 0x54, 0xe3, 0x47, 0x45, 0x33}; + uint8_t bytesprops10[] = {0x9e, 0x75, 0xa7, 0x7b, 0x37, 0xc6, 0x7, 0x43, 0xa0, 0x78, 0x5b, 0xc7, 0x80, + 0x90, 0xd5, 0x8c, 0x2b, 0x73, 0xe2, 0x80, 0xbf, 0x92, 0xdd, 0x4e, 0xf1, 0x59}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode21) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23925}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32196}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14388}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25165}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5332}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1710}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11435}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops6}, .v = {18, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12725}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29756}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30499}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xe6, 0xb7, 0x71, 0x96, 0xff, 0x66, 0x1e, 0x85, 0x2c, 0x19, 0x97, 0x73, 0x14}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa0, 0xef, 0xd6, 0x54, 0x18, 0x53, 0xff, 0x86, + 0xa9, 0xb6, 0xa7, 0x72, 0x69, 0xe9, 0xc9}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x42, 0x95, 0x4d, 0x73, 0x37, 0x12, 0xea, 0x78, 0xb9, 0x74, 0xe9, 0xef, 0xf7, + 0x4, 0x96, 0x5c, 0xe1, 0x0, 0x14, 0xe, 0x24, 0x9, 0x50, 0xbe, 0x13}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe7, 0x82, 0x35, 0x30, 0x8e, 0x3f, 0xe8, 0xe4, 0x2, 0xb7, 0xb6, 0x9f, 0x68, + 0xd3, 0x8c, 0xda, 0x4e, 0x1b, 0x5, 0x4c, 0xa1, 0x3d, 0x9e, 0xfb, 0xa6}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xda, 0xe6, 0x32, 0x82, 0xa3, 0x10}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x82, 0x71, 0xa2, 0x4, 0x3a, 0xf0, 0x22, 0xce, 0x60, 0x86, 0x7c, 0xa2}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x6c, 0xb9, 0x4e, 0x84, 0xb1, 0xcb, 0x2a}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x53, 0x42, 0x11, 0x5c, 0xba, 0xbf, 0xa7, 0x69, 0x71, + 0xbb, 0xcc, 0x7, 0x15, 0x89, 0xd6, 0x75, 0x9b, 0xa}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6585, 8, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 22838 +// ["@w%\186\210\164\154\ACKl\193]J?uN\fM\186","\206\247\DEL\254\199\EM\205\216\151KC\ETX\219\180etQ\135\188\195\197_\249\b","m\CAN\222\175|\164\198\ETBF","\186\147\228\156\151$\239K@\USJ\248\193`z\220\222\224M[\182","\154\n$qM4\nL\ETXb\ETX\241","K\154?\178\227p\162\200R\194\196","+\245t\230#}Ja\SOH\214x\220)\ESC\138\t\134\215J\222\131$dD\222","\169\191\191\193[\224tV&\218rG\196\SYNQ\224n\157\&7\215\165\207\153+\a\234\235","(\185\142\190\225\&7\FSf\147Obz\203\136||\198\&5\DC1\239\161\202","_>\198mEZ\153\&1\149\250r\146zt\ESC\239g\176\148\197\210\NUL\231-\212\138"] +// [PropRetainAvailable 107,PropContentType "\248\135;\215w4\172\183\223\SOH\DEL\172\157\151!Z",PropReasonString +// "\173\227\&7\237\199)V \155\175\DEL\NUL\USd\ACK\161\138\150\207\255Vg\135mwS{j",PropAssignedClientIdentifier +// "?\209\182\SO"] +TEST(Unsubscribe5QCTest, Encode24) { + uint8_t pkt[] = { + 0xa2, 0x95, 0x2, 0x59, 0x36, 0x3b, 0x25, 0x6b, 0x3, 0x0, 0x10, 0xf8, 0x87, 0x3b, 0xd7, 0x77, 0x34, 0xac, 0xb7, + 0xdf, 0x1, 0x7f, 0xac, 0x9d, 0x97, 0x21, 0x5a, 0x1f, 0x0, 0x1c, 0xad, 0xe3, 0x37, 0xed, 0xc7, 0x29, 0x56, 0x20, + 0x9b, 0xaf, 0x7f, 0x0, 0x1f, 0x64, 0x6, 0xa1, 0x8a, 0x96, 0xcf, 0xff, 0x56, 0x67, 0x87, 0x6d, 0x77, 0x53, 0x7b, + 0x6a, 0x12, 0x0, 0x4, 0x3f, 0xd1, 0xb6, 0xe, 0x0, 0x12, 0x40, 0x77, 0x25, 0xba, 0xd2, 0xa4, 0x9a, 0x6, 0x6c, + 0xc1, 0x5d, 0x4a, 0x3f, 0x75, 0x4e, 0xc, 0x4d, 0xba, 0x0, 0x18, 0xce, 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0x94, 0xc5, 0xd2, 0x0, 0xe7, 0x2d, 0xd4, 0x8a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf8, 0x87, 0x3b, 0xd7, 0x77, 0x34, 0xac, 0xb7, + 0xdf, 0x1, 0x7f, 0xac, 0x9d, 0x97, 0x21, 0x5a}; + uint8_t bytesprops1[] = {0xad, 0xe3, 0x37, 0xed, 0xc7, 0x29, 0x56, 0x20, 0x9b, 0xaf, 0x7f, 0x0, 0x1f, 0x64, + 0x6, 0xa1, 0x8a, 0x96, 0xcf, 0xff, 0x56, 0x67, 0x87, 0x6d, 0x77, 0x53, 0x7b, 0x6a}; + uint8_t bytesprops2[] = {0x3f, 0xd1, 0xb6, 0xe}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode22) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x40, 0x77, 0x25, 0xba, 0xd2, 0xa4, 0x9a, 0x6, 0x6c, + 0xc1, 0x5d, 0x4a, 0x3f, 0x75, 0x4e, 0xc, 0x4d, 0xba}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xce, 0xf7, 0x7f, 0xfe, 0xc7, 0x19, 0xcd, 0xd8, 0x97, 0x4b, 0x43, 0x3, + 0xdb, 0xb4, 0x65, 0x74, 0x51, 0x87, 0xbc, 0xc3, 0xc5, 0x5f, 0xf9, 0x8}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x6d, 0x18, 0xde, 0xaf, 0x7c, 0xa4, 0xc6, 0x17, 0x46}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xba, 0x93, 0xe4, 0x9c, 0x97, 0x24, 0xef, 0x4b, 0x40, 0x1f, 0x4a, + 0xf8, 0xc1, 0x60, 0x7a, 0xdc, 0xde, 0xe0, 0x4d, 0x5b, 0xb6}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9a, 0xa, 0x24, 0x71, 0x4d, 0x34, 0xa, 0x4c, 0x3, 0x62, 0x3, 0xf1}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x4b, 0x9a, 0x3f, 0xb2, 0xe3, 0x70, 0xa2, 0xc8, 0x52, 0xc2, 0xc4}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x2b, 0xf5, 0x74, 0xe6, 0x23, 0x7d, 0x4a, 0x61, 0x1, 0xd6, 0x78, 0xdc, 0x29, + 0x1b, 0x8a, 0x9, 0x86, 0xd7, 0x4a, 0xde, 0x83, 0x24, 0x64, 0x44, 0xde}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xa9, 0xbf, 0xbf, 0xc1, 0x5b, 0xe0, 0x74, 0x56, 0x26, 0xda, 0x72, 0x47, 0xc4, 0x16, + 0x51, 0xe0, 0x6e, 0x9d, 0x37, 0xd7, 0xa5, 0xcf, 0x99, 0x2b, 0x7, 0xea, 0xeb}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x28, 0xb9, 0x8e, 0xbe, 0xe1, 0x37, 0x1c, 0x66, 0x93, 0x4f, 0x62, + 0x7a, 0xcb, 0x88, 0x7c, 0x7c, 0xc6, 0x35, 0x11, 0xef, 0xa1, 0xca}; + lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x5f, 0x3e, 0xc6, 0x6d, 0x45, 0x5a, 0x99, 0x31, 0x95, 0xfa, 0x72, 0x92, 0x7a, + 0x74, 0x1b, 0xef, 0x67, 0xb0, 0x94, 0xc5, 0xd2, 0x0, 0xe7, 0x2d, 0xd4, 0x8a}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22838, 10, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 14034 ["1\217\143\SOH~W~\ETX +// \191\NUL\173|\218L\CAN\229\ESC\249\241\169\130","T\140qo","\128k\172\167\180\235\144\222\r\129\254?,\152\187+\228\178F\194\225","\244\CAN\230/\246X\247\&1,\208\222\235(\219%\246\172\225\254\191\189|\218'\253","\ENQ\133\178\EOT\241\135\222\201\220\164\&3\179\157\222T\189\253","\ETB\DC4\159\210\ETB0\218\213;\180\EM\227\244Lr\245\EOTn\NULh","\173.N\n~\219o\214\205\167\190\139\196\185\246\174\&3\STX\215\235\135a","\172g\bAu\187r\au-\DC4!!Vw +// |x","\211\&6\175\180c\153\187s\NUL\v\140Em\215\144\244\&3|\246\ESC&\239tD\243\239","]\US\226A\165\\|\206U6\249d\144\241On-\153"] +// [PropMessageExpiryInterval 5120,PropTopicAliasMaximum 18895,PropSharedSubscriptionAvailable 79,PropServerKeepAlive +// 26825,PropRequestResponseInformation 31,PropMaximumQoS 209,PropMaximumQoS 168,PropAuthenticationData +// "R\143\140\ETB\229\&0\193\246~Z\131\166C)\151\226\&7",PropMessageExpiryInterval 11526,PropResponseInformation +// "\169\CAN\170\DEL\206\197",PropRequestProblemInformation 239,PropResponseInformation +// "\188\221\162\177\CAN\246\r\252\&2\198\211o\CAN\FS\ESC\136\&5\"\240`E\ETB",PropSubscriptionIdentifier +// 23,PropMaximumQoS 102,PropRequestResponseInformation 187,PropMessageExpiryInterval +// 20661,PropRequestProblemInformation 73,PropMaximumQoS 39] +TEST(Unsubscribe5QCTest, Encode25) { + uint8_t pkt[] = { + 0xa2, 0xb7, 0x2, 0x36, 0xd2, 0x5f, 0x2, 0x0, 0x0, 0x14, 0x0, 0x22, 0x49, 0xcf, 0x2a, 0x4f, 0x13, 0x68, 0xc9, + 0x19, 0x1f, 0x24, 0xd1, 0x24, 0xa8, 0x16, 0x0, 0x11, 0x52, 0x8f, 0x8c, 0x17, 0xe5, 0x30, 0xc1, 0xf6, 0x7e, 0x5a, + 0x83, 0xa6, 0x43, 0x29, 0x97, 0xe2, 0x37, 0x2, 0x0, 0x0, 0x2d, 0x6, 0x1a, 0x0, 0x6, 0xa9, 0x18, 0xaa, 0x7f, + 0xce, 0xc5, 0x17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x87, 0x61, 0x0, + 0x12, 0xac, 0x67, 0x8, 0x41, 0x75, 0xbb, 0x72, 0x7, 0x75, 0x2d, 0x14, 0x21, 0x21, 0x56, 0x77, 0x20, 0x7c, 0x78, + 0x0, 0x1a, 0xd3, 0x36, 0xaf, 0xb4, 0x63, 0x99, 0xbb, 0x73, 0x0, 0xb, 0x8c, 0x45, 0x6d, 0xd7, 0x90, 0xf4, 0x33, + 0x7c, 0xf6, 0x1b, 0x26, 0xef, 0x74, 0x44, 0xf3, 0xef, 0x0, 0x12, 0x5d, 0x1f, 0xe2, 0x41, 0xa5, 0x5c, 0x7c, 0xce, + 0x55, 0x36, 0xf9, 0x64, 0x90, 0xf1, 0x4f, 0x6e, 0x2d, 0x99}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x52, 0x8f, 0x8c, 0x17, 0xe5, 0x30, 0xc1, 0xf6, 0x7e, + 0x5a, 0x83, 0xa6, 0x43, 0x29, 0x97, 0xe2, 0x37}; + uint8_t bytesprops1[] = {0xa9, 0x18, 0xaa, 0x7f, 0xce, 0xc5}; + uint8_t bytesprops2[] = {0xbc, 0xdd, 0xa2, 0xb1, 0x18, 0xf6, 0xd, 0xfc, 0x32, 0xc6, 0xd3, + 0x6f, 0x18, 0x1c, 0x1b, 0x88, 0x35, 0x22, 0xf0, 0x60, 0x45, 0x17}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode23) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5120}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18895}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26825}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11526}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20661}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 39}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x31, 0xd9, 0x8f, 0x1, 0x7e, 0x57, 0x7e, 0x3, 0x20, 0xbf, 0x0, + 0xad, 0x7c, 0xda, 0x4c, 0x18, 0xe5, 0x1b, 0xf9, 0xf1, 0xa9, 0x82}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x54, 0x8c, 0x71, 0x6f}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x80, 0x6b, 0xac, 0xa7, 0xb4, 0xeb, 0x90, 0xde, 0xd, 0x81, 0xfe, + 0x3f, 0x2c, 0x98, 0xbb, 0x2b, 0xe4, 0xb2, 0x46, 0xc2, 0xe1}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf4, 0x18, 0xe6, 0x2f, 0xf6, 0x58, 0xf7, 0x31, 0x2c, 0xd0, 0xde, 0xeb, 0x28, + 0xdb, 0x25, 0xf6, 0xac, 0xe1, 0xfe, 0xbf, 0xbd, 0x7c, 0xda, 0x27, 0xfd}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x5, 0x85, 0xb2, 0x4, 0xf1, 0x87, 0xde, 0xc9, 0xdc, + 0xa4, 0x33, 0xb3, 0x9d, 0xde, 0x54, 0xbd, 0xfd}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x17, 0x14, 0x9f, 0xd2, 0x17, 0x30, 0xda, 0xd5, 0x3b, 0xb4, + 0x19, 0xe3, 0xf4, 0x4c, 0x72, 0xf5, 0x4, 0x6e, 0x0, 0x68}; + lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xad, 0x2e, 0x4e, 0xa, 0x7e, 0xdb, 0x6f, 0xd6, 0xcd, 0xa7, 0xbe, + 0x8b, 0xc4, 0xb9, 0xf6, 0xae, 0x33, 0x2, 0xd7, 0xeb, 0x87, 0x61}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xac, 0x67, 0x8, 0x41, 0x75, 0xbb, 0x72, 0x7, 0x75, + 0x2d, 0x14, 0x21, 0x21, 0x56, 0x77, 0x20, 0x7c, 0x78}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd3, 0x36, 0xaf, 0xb4, 0x63, 0x99, 0xbb, 0x73, 0x0, 0xb, 0x8c, 0x45, 0x6d, + 0xd7, 0x90, 0xf4, 0x33, 0x7c, 0xf6, 0x1b, 0x26, 0xef, 0x74, 0x44, 0xf3, 0xef}; + lwmqtt_string_t topic_filter_s8 = {26, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x5d, 0x1f, 0xe2, 0x41, 0xa5, 0x5c, 0x7c, 0xce, 0x55, + 0x36, 0xf9, 0x64, 0x90, 0xf1, 0x4f, 0x6e, 0x2d, 0x99}; + lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14034, 10, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 22538 ["O\215\150\139h\178\159\233Bf\234x\tp\206\198\147s\142\236\132\SYN\221f\DELN\NAK\228\133"] +// [PropWillDelayInterval 17254,PropWildcardSubscriptionAvailable 120,PropSharedSubscriptionAvailable +// 61,PropUserProperty "\147\245\158\ENQ\220\244\DC1V\240\NUL\186W" +// "&\154\236~;t\US[\FS\211\184K\153u\233[\238n\182[\134G",PropResponseInformation "*\EM)5D6\136",PropMaximumQoS +// 78,PropReceiveMaximum 25530] +TEST(Unsubscribe5QCTest, Encode26) { + uint8_t pkt[] = {0xa2, 0x61, 0x58, 0xa, 0x3f, 0x18, 0x0, 0x0, 0x43, 0x66, 0x28, 0x78, 0x2a, 0x3d, 0x26, 0x0, 0xc, + 0x93, 0xf5, 0x9e, 0x5, 0xdc, 0xf4, 0x11, 0x56, 0xf0, 0x0, 0xba, 0x57, 0x0, 0x16, 0x26, 0x9a, 0xec, + 0x7e, 0x3b, 0x74, 0x1f, 0x5b, 0x1c, 0xd3, 0xb8, 0x4b, 0x99, 0x75, 0xe9, 0x5b, 0xee, 0x6e, 0xb6, 0x5b, + 0x86, 0x47, 0x1a, 0x0, 0x7, 0x2a, 0x19, 0x29, 0x35, 0x44, 0x36, 0x88, 0x24, 0x4e, 0x21, 0x63, 0xba, + 0x0, 0x1d, 0x4f, 0xd7, 0x96, 0x8b, 0x68, 0xb2, 0x9f, 0xe9, 0x42, 0x66, 0xea, 0x78, 0x9, 0x70, 0xce, + 0xc6, 0x93, 0x73, 0x8e, 0xec, 0x84, 0x16, 0xdd, 0x66, 0x7f, 0x4e, 0x15, 0xe4, 0x85}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x26, 0x9a, 0xec, 0x7e, 0x3b, 0x74, 0x1f, 0x5b, 0x1c, 0xd3, 0xb8, + 0x4b, 0x99, 0x75, 0xe9, 0x5b, 0xee, 0x6e, 0xb6, 0x5b, 0x86, 0x47}; + uint8_t bytesprops0[] = {0x93, 0xf5, 0x9e, 0x5, 0xdc, 0xf4, 0x11, 0x56, 0xf0, 0x0, 0xba, 0x57}; + uint8_t bytesprops2[] = {0x2a, 0x19, 0x29, 0x35, 0x44, 0x36, 0x88}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode24) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17254}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops0}, .v = {22, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25530}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x4f, 0xd7, 0x96, 0x8b, 0x68, 0xb2, 0x9f, 0xe9, 0x42, 0x66, + 0xea, 0x78, 0x9, 0x70, 0xce, 0xc6, 0x93, 0x73, 0x8e, 0xec, + 0x84, 0x16, 0xdd, 0x66, 0x7f, 0x4e, 0x15, 0xe4, 0x85}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22538, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 30444 +// ["GX)\EOT\193\GS\201A\196\169\SYN\180","\192\194c\139X\215\204<\ba\143\240^\173\198\169V\USFt\229\141;\n\223\215t","\228&\240","","R\164}j.u4\218\129\170\245j\245\192)\196","i\183\181;\182\142C","0|?r?\191\EOT==o\244\243@\198\NAK\218\155\158\NUL\151\184z","v\202.j\238\248\163T\167\148\158dl\249T\228Iv"] +// [PropWillDelayInterval 11257,PropTopicAliasMaximum 19369,PropResponseInformation +// "\vH\153\209\&5I\213\179\159\197\155%"] +TEST(Unsubscribe5QCTest, Encode27) { + uint8_t pkt[] = {0xa2, 0x93, 0x1, 0x76, 0xec, 0x17, 0x18, 0x0, 0x0, 0x2b, 0xf9, 0x22, 0x4b, 0xa9, 0x1a, 0x0, 0xc, + 0xb, 0x48, 0x99, 0xd1, 0x35, 0x49, 0xd5, 0xb3, 0x9f, 0xc5, 0x9b, 0x25, 0x0, 0xc, 0x47, 0x58, 0x29, + 0x4, 0xc1, 0x1d, 0xc9, 0x41, 0xc4, 0xa9, 0x16, 0xb4, 0x0, 0x1b, 0xc0, 0xc2, 0x63, 0x8b, 0x58, 0xd7, + 0xcc, 0x3c, 0x8, 0x61, 0x8f, 0xf0, 0x5e, 0xad, 0xc6, 0xa9, 0x56, 0x1f, 0x46, 0x74, 0xe5, 0x8d, 0x3b, + 0xa, 0xdf, 0xd7, 0x74, 0x0, 0x3, 0xe4, 0x26, 0xf0, 0x0, 0x0, 0x0, 0x10, 0x52, 0xa4, 0x7d, 0x6a, + 0x2e, 0x75, 0x34, 0xda, 0x81, 0xaa, 0xf5, 0x6a, 0xf5, 0xc0, 0x29, 0xc4, 0x0, 0x7, 0x69, 0xb7, 0xb5, + 0x3b, 0xb6, 0x8e, 0x43, 0x0, 0x16, 0x30, 0x7c, 0x3f, 0x72, 0x3f, 0xbf, 0x4, 0x3d, 0x3d, 0x6f, 0xf4, + 0xf3, 0x40, 0xc6, 0x15, 0xda, 0x9b, 0x9e, 0x0, 0x97, 0xb8, 0x7a, 0x0, 0x12, 0x76, 0xca, 0x2e, 0x6a, + 0xee, 0xf8, 0xa3, 0x54, 0xa7, 0x94, 0x9e, 0x64, 0x6c, 0xf9, 0x54, 0xe4, 0x49, 0x76}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb, 0x48, 0x99, 0xd1, 0x35, 0x49, 0xd5, 0xb3, 0x9f, 0xc5, 0x9b, 0x25}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode25) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11257}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19369}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x47, 0x58, 0x29, 0x4, 0xc1, 0x1d, 0xc9, 0x41, 0xc4, 0xa9, 0x16, 0xb4}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc0, 0xc2, 0x63, 0x8b, 0x58, 0xd7, 0xcc, 0x3c, 0x8, 0x61, 0x8f, 0xf0, 0x5e, 0xad, + 0xc6, 0xa9, 0x56, 0x1f, 0x46, 0x74, 0xe5, 0x8d, 0x3b, 0xa, 0xdf, 0xd7, 0x74}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe4, 0x26, 0xf0}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x52, 0xa4, 0x7d, 0x6a, 0x2e, 0x75, 0x34, 0xda, + 0x81, 0xaa, 0xf5, 0x6a, 0xf5, 0xc0, 0x29, 0xc4}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x69, 0xb7, 0xb5, 0x3b, 0xb6, 0x8e, 0x43}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x30, 0x7c, 0x3f, 0x72, 0x3f, 0xbf, 0x4, 0x3d, 0x3d, 0x6f, 0xf4, + 0xf3, 0x40, 0xc6, 0x15, 0xda, 0x9b, 0x9e, 0x0, 0x97, 0xb8, 0x7a}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x76, 0xca, 0x2e, 0x6a, 0xee, 0xf8, 0xa3, 0x54, 0xa7, + 0x94, 0x9e, 0x64, 0x6c, 0xf9, 0x54, 0xe4, 0x49, 0x76}; + lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30444, 8, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 10904 +// ["\158\151(tQ&M3?\234\162qjZ\ENQ\146wd\180\249\&0","\148\148\181'\255Q\247\ETB\218\ESC\136\SYN\a\213\151t\229az1\208\253","z\245\157\159\151\241\225%\SOH^\129`\166\168\252\172\135}","|\SOq\189\SO","\ENQi\226\n}\143\149O\235\&1\SOHN\241\252\183GG\136\142"] +// [PropSubscriptionIdentifier 3,PropSharedSubscriptionAvailable 112,PropAssignedClientIdentifier +// "\235nn\FS\208o\211\167We\172\224",PropResponseTopic +// "\233\173\232\r\185\218\161\200#\179\SOH\SO\DLE\SUB3\171\&4)@\137\198\"\182\EM-\238]\162",PropMessageExpiryInterval +// 25344,PropRequestProblemInformation 184,PropPayloadFormatIndicator 144,PropReceiveMaximum +// 8063,PropWildcardSubscriptionAvailable 56,PropTopicAlias 15484,PropReceiveMaximum 6258,PropTopicAliasMaximum +// 12379,PropMessageExpiryInterval 28859] +TEST(Unsubscribe5QCTest, Encode28) { + uint8_t pkt[] = {0xa2, 0xb0, 0x1, 0x2a, 0x98, 0x4e, 0xb, 0x3, 0x2a, 0x70, 0x12, 0x0, 0xc, 0xeb, 0x6e, 0x6e, 0x1c, + 0xd0, 0x6f, 0xd3, 0xa7, 0x57, 0x65, 0xac, 0xe0, 0x8, 0x0, 0x1c, 0xe9, 0xad, 0xe8, 0xd, 0xb9, 0xda, + 0xa1, 0xc8, 0x23, 0xb3, 0x1, 0xe, 0x10, 0x1a, 0x33, 0xab, 0x34, 0x29, 0x40, 0x89, 0xc6, 0x22, 0xb6, + 0x19, 0x2d, 0xee, 0x5d, 0xa2, 0x2, 0x0, 0x0, 0x63, 0x0, 0x17, 0xb8, 0x1, 0x90, 0x21, 0x1f, 0x7f, + 0x28, 0x38, 0x23, 0x3c, 0x7c, 0x21, 0x18, 0x72, 0x22, 0x30, 0x5b, 0x2, 0x0, 0x0, 0x70, 0xbb, 0x0, + 0x15, 0x9e, 0x97, 0x28, 0x74, 0x51, 0x26, 0x4d, 0x33, 0x3f, 0xea, 0xa2, 0x71, 0x6a, 0x5a, 0x5, 0x92, + 0x77, 0x64, 0xb4, 0xf9, 0x30, 0x0, 0x16, 0x94, 0x94, 0xb5, 0x27, 0xff, 0x51, 0xf7, 0x17, 0xda, 0x1b, + 0x88, 0x16, 0x7, 0xd5, 0x97, 0x74, 0xe5, 0x61, 0x7a, 0x31, 0xd0, 0xfd, 0x0, 0x12, 0x7a, 0xf5, 0x9d, + 0x9f, 0x97, 0xf1, 0xe1, 0x25, 0x1, 0x5e, 0x81, 0x60, 0xa6, 0xa8, 0xfc, 0xac, 0x87, 0x7d, 0x0, 0x5, + 0x7c, 0xe, 0x71, 0xbd, 0xe, 0x0, 0x13, 0x5, 0x69, 0xe2, 0xa, 0x7d, 0x8f, 0x95, 0x4f, 0xeb, 0x31, + 0x1, 0x4e, 0xf1, 0xfc, 0xb7, 0x47, 0x47, 0x88, 0x8e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xeb, 0x6e, 0x6e, 0x1c, 0xd0, 0x6f, 0xd3, 0xa7, 0x57, 0x65, 0xac, 0xe0}; + uint8_t bytesprops1[] = {0xe9, 0xad, 0xe8, 0xd, 0xb9, 0xda, 0xa1, 0xc8, 0x23, 0xb3, 0x1, 0xe, 0x10, 0x1a, + 0x33, 0xab, 0x34, 0x29, 0x40, 0x89, 0xc6, 0x22, 0xb6, 0x19, 0x2d, 0xee, 0x5d, 0xa2}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode26) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { - }; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25344}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8063}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15484}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6258}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12379}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28859}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x9e, 0x97, 0x28, 0x74, 0x51, 0x26, 0x4d, 0x33, 0x3f, 0xea, 0xa2, + 0x71, 0x6a, 0x5a, 0x5, 0x92, 0x77, 0x64, 0xb4, 0xf9, 0x30}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x94, 0x94, 0xb5, 0x27, 0xff, 0x51, 0xf7, 0x17, 0xda, 0x1b, 0x88, + 0x16, 0x7, 0xd5, 0x97, 0x74, 0xe5, 0x61, 0x7a, 0x31, 0xd0, 0xfd}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x7a, 0xf5, 0x9d, 0x9f, 0x97, 0xf1, 0xe1, 0x25, 0x1, + 0x5e, 0x81, 0x60, 0xa6, 0xa8, 0xfc, 0xac, 0x87, 0x7d}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x7c, 0xe, 0x71, 0xbd, 0xe}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x5, 0x69, 0xe2, 0xa, 0x7d, 0x8f, 0x95, 0x4f, 0xeb, 0x31, + 0x1, 0x4e, 0xf1, 0xfc, 0xb7, 0x47, 0x47, 0x88, 0x8e}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10904, 5, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 5483 +// ["","\RSY|\167.\233=\245U,\193\250.\241\&8]Z\239\EOTi\DC2\193\235\212","\233\251\197\179\CAN\205\158\160\250\133\254\220\DC3\236\149k\249,w\223yf\239\240\193\&2\SO","1;\224awQA\b\129m\211-\177#y\130L;%\227\202'","\129\143;\208\166\210!h@\133","\212\213jo\156\238\193\DC2\188o\254\NUL\219\202","(\182Q\ENQ\158\220\233\233\228\196\226\218\163"] +// [PropUserProperty "h\205\&2\188\249uu\225" +// "K\190\140\234t\134\NAKX\141\201\185\188\230\&8\211\SUB\170e\194Q\b\235/\161\140y",PropReceiveMaximum +// 28222,PropTopicAliasMaximum 18691,PropAuthenticationData +// "&\148\172\ACKQI)\203\DC3\193\212\176\ACKP",PropAuthenticationData +// "S\ax0\188=\236\&1C\DC2\156^\RSM",PropAuthenticationMethod "\fs\231\144\RS\233K\EMZ",PropAuthenticationData +// "\142\US\198\245A\180",PropReceiveMaximum 5487,PropWildcardSubscriptionAvailable 78,PropResponseInformation +// "\189\160\198",PropCorrelationData "R\170\137\155\151%=\SYN\EOT",PropMessageExpiryInterval +// 17502,PropMaximumPacketSize 31330,PropMaximumPacketSize 6043,PropResponseInformation +// "J~\249\234U,h0\141Kd\133L\151{C$\170C\136w\SUB\182\229",PropTopicAlias 30866,PropSharedSubscriptionAvailable +// 90,PropContentType "\137\164)\SOHa;\237\212\252\191Q\140B\nJ\"\EOT}\253\187\167",PropSharedSubscriptionAvailable +// 165,PropServerReference "Z\134v\144L\180\249]_\202%\222f7~U\DC1\198b\213\ACK\154\ACK@g",PropServerKeepAlive +// 21230,PropRequestProblemInformation 106,PropSubscriptionIdentifierAvailable 104,PropServerReference +// "\184*kb\NAKsf\138\145\225\240w\v\DEL]\227\212's\226\&2\169xF",PropAuthenticationMethod +// "\\\ESC\154wl\225F\142\146\201\217?`\235\201HT\136\US\t\254",PropMaximumPacketSize 11165,PropServerReference +// "\219\153\175\221\237\238m\216\200g",PropMaximumPacketSize 11614,PropPayloadFormatIndicator 95,PropTopicAliasMaximum +// 19880] +TEST(Unsubscribe5QCTest, Encode29) { + uint8_t pkt[] = { + 0xa2, 0xb6, 0x3, 0x15, 0x6b, 0xb6, 0x2, 0x26, 0x0, 0x8, 0x68, 0xcd, 0x32, 0xbc, 0xf9, 0x75, 0x75, 0xe1, 0x0, + 0x1a, 0x4b, 0xbe, 0x8c, 0xea, 0x74, 0x86, 0x15, 0x58, 0x8d, 0xc9, 0xb9, 0xbc, 0xe6, 0x38, 0xd3, 0x1a, 0xaa, 0x65, + 0xc2, 0x51, 0x8, 0xeb, 0x2f, 0xa1, 0x8c, 0x79, 0x21, 0x6e, 0x3e, 0x22, 0x49, 0x3, 0x16, 0x0, 0xe, 0x26, 0x94, + 0xac, 0x6, 0x51, 0x49, 0x29, 0xcb, 0x13, 0xc1, 0xd4, 0xb0, 0x6, 0x50, 0x16, 0x0, 0xe, 0x53, 0x7, 0x78, 0x30, + 0xbc, 0x3d, 0xec, 0x31, 0x43, 0x12, 0x9c, 0x5e, 0x1e, 0x4d, 0x15, 0x0, 0x9, 0xc, 0x73, 0xe7, 0x90, 0x1e, 0xe9, + 0x4b, 0x19, 0x5a, 0x16, 0x0, 0x6, 0x8e, 0x1f, 0xc6, 0x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x79}; + uint8_t bytesprops0[] = {0x68, 0xcd, 0x32, 0xbc, 0xf9, 0x75, 0x75, 0xe1}; + uint8_t bytesprops2[] = {0x26, 0x94, 0xac, 0x6, 0x51, 0x49, 0x29, 0xcb, 0x13, 0xc1, 0xd4, 0xb0, 0x6, 0x50}; + uint8_t bytesprops3[] = {0x53, 0x7, 0x78, 0x30, 0xbc, 0x3d, 0xec, 0x31, 0x43, 0x12, 0x9c, 0x5e, 0x1e, 0x4d}; + uint8_t bytesprops4[] = {0xc, 0x73, 0xe7, 0x90, 0x1e, 0xe9, 0x4b, 0x19, 0x5a}; + uint8_t bytesprops5[] = {0x8e, 0x1f, 0xc6, 0xf5, 0x41, 0xb4}; + uint8_t bytesprops6[] = {0xbd, 0xa0, 0xc6}; + uint8_t bytesprops7[] = {0x52, 0xaa, 0x89, 0x9b, 0x97, 0x25, 0x3d, 0x16, 0x4}; + uint8_t bytesprops8[] = {0x4a, 0x7e, 0xf9, 0xea, 0x55, 0x2c, 0x68, 0x30, 0x8d, 0x4b, 0x64, 0x85, + 0x4c, 0x97, 0x7b, 0x43, 0x24, 0xaa, 0x43, 0x88, 0x77, 0x1a, 0xb6, 0xe5}; + uint8_t bytesprops9[] = {0x89, 0xa4, 0x29, 0x1, 0x61, 0x3b, 0xed, 0xd4, 0xfc, 0xbf, 0x51, + 0x8c, 0x42, 0xa, 0x4a, 0x22, 0x4, 0x7d, 0xfd, 0xbb, 0xa7}; + uint8_t bytesprops10[] = {0x5a, 0x86, 0x76, 0x90, 0x4c, 0xb4, 0xf9, 0x5d, 0x5f, 0xca, 0x25, 0xde, 0x66, + 0x37, 0x7e, 0x55, 0x11, 0xc6, 0x62, 0xd5, 0x6, 0x9a, 0x6, 0x40, 0x67}; + uint8_t bytesprops11[] = {0xb8, 0x2a, 0x6b, 0x62, 0x15, 0x73, 0x66, 0x8a, 0x91, 0xe1, 0xf0, 0x77, + 0xb, 0x7f, 0x5d, 0xe3, 0xd4, 0x27, 0x73, 0xe2, 0x32, 0xa9, 0x78, 0x46}; + uint8_t bytesprops12[] = {0x5c, 0x1b, 0x9a, 0x77, 0x6c, 0xe1, 0x46, 0x8e, 0x92, 0xc9, 0xd9, + 0x3f, 0x60, 0xeb, 0xc9, 0x48, 0x54, 0x88, 0x1f, 0x9, 0xfe}; + uint8_t bytesprops13[] = {0xdb, 0x99, 0xaf, 0xdd, 0xed, 0xee, 0x6d, 0xd8, 0xc8, 0x67}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode27) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {26, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28222}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18691}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5487}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17502}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31330}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6043}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30866}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21230}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11165}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11614}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19880}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0x59, 0x7c, 0xa7, 0x2e, 0xe9, 0x3d, 0xf5, 0x55, 0x2c, 0xc1, 0xfa, + 0x2e, 0xf1, 0x38, 0x5d, 0x5a, 0xef, 0x4, 0x69, 0x12, 0xc1, 0xeb, 0xd4}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe9, 0xfb, 0xc5, 0xb3, 0x18, 0xcd, 0x9e, 0xa0, 0xfa, 0x85, 0xfe, 0xdc, 0x13, 0xec, + 0x95, 0x6b, 0xf9, 0x2c, 0x77, 0xdf, 0x79, 0x66, 0xef, 0xf0, 0xc1, 0x32, 0xe}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x31, 0x3b, 0xe0, 0x61, 0x77, 0x51, 0x41, 0x8, 0x81, 0x6d, 0xd3, + 0x2d, 0xb1, 0x23, 0x79, 0x82, 0x4c, 0x3b, 0x25, 0xe3, 0xca, 0x27}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x81, 0x8f, 0x3b, 0xd0, 0xa6, 0xd2, 0x21, 0x68, 0x40, 0x85}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xd4, 0xd5, 0x6a, 0x6f, 0x9c, 0xee, 0xc1, 0x12, 0xbc, 0x6f, 0xfe, 0x0, 0xdb, 0xca}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x28, 0xb6, 0x51, 0x5, 0x9e, 0xdc, 0xe9, 0xe9, 0xe4, 0xc4, 0xe2, 0xda, 0xa3}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5483, 7, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } +// UnsubscribeRequest 27410 +// ["\142,\253\251\228\164\&6>\237\ETX\150\202\228\225\236\SUB\130}\144\142\196:\EOT","7$&\216\162\FSEn\RSsy\244]","\200\209D","\154,\164<","\211c\153","\DLE\221\175\212*","Pk)\217\129'\201\236\161\181o\176D\191L\241\158\153\EOT\228","#\231\205E\220\217&S\242","\211\145\204"] +// [PropMaximumPacketSize 25355,PropRetainAvailable 125,PropRetainAvailable 176,PropWillDelayInterval +// 6837,PropResponseInformation "\137\128\237q5K\SOE}{",PropCorrelationData +// "\224b#\254\157\&5`\ENQ]\128\GS\227@p\239",PropResponseInformation "\188",PropReasonString +// "\131o\165>A\196\165\n\139D \142\ACKjg",PropCorrelationData +// "P\STX{\US\ACKe\167\187/;\ah\134\160'\253\204",PropAuthenticationMethod +// "\224W\DLE$\223\242\a\FSU\245&\254\&1\251\SYN\t\218\222\&0XF\221;",PropSessionExpiryInterval +// 9119,PropSessionExpiryInterval 16118,PropServerKeepAlive 16036,PropMessageExpiryInterval +// 31819,PropAuthenticationMethod +// "\US\137DB7;\140\213\235\NUL&\NUL\162{\170\254C\192\207S\178;t\ENQ",PropMessageExpiryInterval +// 30475,PropServerReference +// "EK\\)\178\NUL\138\&4U\189]<>\163\232\147\244\204\&5;\n\241\169\193\SYN\211\245\DC2\211\180"] +TEST(Unsubscribe5QCTest, Encode30) { + uint8_t pkt[] = { + 0xa2, 0xad, 0x2, 0x6b, 0x12, 0xc4, 0x1, 0x27, 0x0, 0x0, 0x63, 0xb, 0x25, 0x7d, 0x25, 0xb0, 0x18, 0x0, 0x0, + 0x1a, 0xb5, 0x1a, 0x0, 0xa, 0x89, 0x80, 0xed, 0x71, 0x35, 0x4b, 0xe, 0x45, 0x7d, 0x7b, 0x9, 0x0, 0xf, 0xe0, + 0x62, 0x23, 0xfe, 0x9d, 0x35, 0x60, 0x5, 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x37, 0x24, 0x26, 0xd8, 0xa2, 0x1c, 0x45, 0x6e, 0x1e, 0x73, 0x79, 0xf4, 0x5d, 0x0, 0x3, 0xc8, 0xd1, + 0x44, 0x0, 0x4, 0x9a, 0x2c, 0xa4, 0x3c, 0x0, 0x3, 0xd3, 0x63, 0x99, 0x0, 0x5, 0x10, 0xdd, 0xaf, 0xd4, 0x2a, + 0x0, 0x14, 0x50, 0x6b, 0x29, 0xd9, 0x81, 0x27, 0xc9, 0xec, 0xa1, 0xb5, 0x6f, 0xb0, 0x44, 0xbf, 0x4c, 0xf1, 0x9e, + 0x99, 0x4, 0xe4, 0x0, 0x9, 0x23, 0xe7, 0xcd, 0x45, 0xdc, 0xd9, 0x26, 0x53, 0xf2, 0x0, 0x3, 0xd3, 0x91, 0xcc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x89, 0x80, 0xed, 0x71, 0x35, 0x4b, 0xe, 0x45, 0x7d, 0x7b}; + uint8_t bytesprops1[] = {0xe0, 0x62, 0x23, 0xfe, 0x9d, 0x35, 0x60, 0x5, 0x5d, 0x80, 0x1d, 0xe3, 0x40, 0x70, 0xef}; + uint8_t bytesprops2[] = {0xbc}; + uint8_t bytesprops3[] = {0x83, 0x6f, 0xa5, 0x3e, 0x41, 0xc4, 0xa5, 0xa, 0x8b, 0x44, 0x20, 0x8e, 0x6, 0x6a, 0x67}; + uint8_t bytesprops4[] = {0x50, 0x2, 0x7b, 0x1f, 0x6, 0x65, 0xa7, 0xbb, 0x2f, + 0x3b, 0x7, 0x68, 0x86, 0xa0, 0x27, 0xfd, 0xcc}; + uint8_t bytesprops5[] = {0xe0, 0x57, 0x10, 0x24, 0xdf, 0xf2, 0x7, 0x1c, 0x55, 0xf5, 0x26, 0xfe, + 0x31, 0xfb, 0x16, 0x9, 0xda, 0xde, 0x30, 0x58, 0x46, 0xdd, 0x3b}; + uint8_t bytesprops6[] = {0x1f, 0x89, 0x44, 0x42, 0x37, 0x3b, 0x8c, 0xd5, 0xeb, 0x0, 0x26, 0x0, + 0xa2, 0x7b, 0xaa, 0xfe, 0x43, 0xc0, 0xcf, 0x53, 0xb2, 0x3b, 0x74, 0x5}; + uint8_t bytesprops7[] = {0x45, 0x4b, 0x5c, 0x29, 0xb2, 0x0, 0x8a, 0x34, 0x55, 0xbd, 0x5d, 0x3c, 0x3e, 0xa3, 0xe8, + 0x93, 0xf4, 0xcc, 0x35, 0x3b, 0xa, 0xf1, 0xa9, 0xc1, 0x16, 0xd3, 0xf5, 0x12, 0xd3, 0xb4}; -// DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode28) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25355}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6837}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9119}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16118}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16036}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31819}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30475}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x8e, 0x2c, 0xfd, 0xfb, 0xe4, 0xa4, 0x36, 0x3e, 0xed, 0x3, 0x96, 0xca, + 0xe4, 0xe1, 0xec, 0x1a, 0x82, 0x7d, 0x90, 0x8e, 0xc4, 0x3a, 0x4}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x37, 0x24, 0x26, 0xd8, 0xa2, 0x1c, 0x45, 0x6e, 0x1e, 0x73, 0x79, 0xf4, 0x5d}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc8, 0xd1, 0x44}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x9a, 0x2c, 0xa4, 0x3c}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd3, 0x63, 0x99}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x10, 0xdd, 0xaf, 0xd4, 0x2a}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x50, 0x6b, 0x29, 0xd9, 0x81, 0x27, 0xc9, 0xec, 0xa1, 0xb5, + 0x6f, 0xb0, 0x44, 0xbf, 0x4c, 0xf1, 0x9e, 0x99, 0x4, 0xe4}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x23, 0xe7, 0xcd, 0x45, 0xdc, 0xd9, 0x26, 0x53, 0xf2}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xd3, 0x91, 0xcc}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27410, 9, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); } - // DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode29) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; +TEST(Disco311QCTest, Encode1) { + uint8_t pkt[] = {0xe0, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - // DisconnectRequest DiscoNormalDisconnection [] -TEST(Disco311QCTest, Encode30) { -uint8_t pkt[] = {0xe0, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - - lwmqtt_property_t propslist[] = { - }; +TEST(Disco311QCTest, Encode2) { + uint8_t pkt[] = {0xe0, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT311, 0, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoMessageRateTooHigh [PropReasonString "\225\ENQ<\232\197\144\236\DLESJ\182g~~\230\252\ETX\231",PropContentType "\205\232\136\DC3Z~\156x\FS\223\228\203",PropWillDelayInterval 26618,PropCorrelationData "\228\r\236\237\t\188\136\EOTo\204tPm\DEL\232{'\153\209\196",PropTopicAlias 6948,PropSubscriptionIdentifier 23,PropAssignedClientIdentifier "\238\214\184\137D\251",PropMessageExpiryInterval 6626,PropAssignedClientIdentifier "\151e\219\254\131\134\177\f`\155\194\&3\SUB]\147\ESC\151",PropSharedSubscriptionAvailable 191,PropPayloadFormatIndicator 226,PropAssignedClientIdentifier "S\DC3%x\146\184\210\242\ENQf\228@S-\ETX\231\\\t\173^]\254\231B#S%6",PropTopicAliasMaximum 13418,PropResponseTopic "\bo\208~\176vG\EM\171=",PropWillDelayInterval 5695,PropCorrelationData "t\207\138\SOHXL\139R\201\200\220\145m",PropMessageExpiryInterval 4237,PropReceiveMaximum 27811,PropSubscriptionIdentifierAvailable 116,PropResponseTopic "",PropMessageExpiryInterval 25556,PropMaximumQoS 160,PropResponseTopic "O8\t\226\169\146\ENQ\159s\181\te\226\137\154\"",PropCorrelationData "\144\\X[\203\148\246D>\141 \233S\143",PropRequestProblemInformation 170,PropServerKeepAlive 12755] +// DisconnectRequest DiscoServerMoved [PropAssignedClientIdentifier +// "\136h8s\245\148b\RS\211\129\135\138\SI\212\142\187\155\217:\220.\149f\FS\159[/\147\136\t",PropServerReference +// "\245\214\DC2q\254\171\SO\195\152\EOT\208\224z\236\SI\212lK^\253\211\208\170",PropReasonString +// "95Z\190\237\166\190Xy\187\196\170",PropServerReference +// "\133\177\221n\140\&1\239\157\ACK\148\ACK\136^\SOH\142C",PropResponseTopic +// "2&\ETX\151\DC1'\234\210Jve\168!z\181\\<\a\158\&8\SO",PropReceiveMaximum 20949,PropRetainAvailable +// 231,PropCorrelationData +// "y\GS\142\249\DC48P.\n\164'\138\DC1D.'\210{\STX\158\251KM\243\234\165",PropSubscriptionIdentifierAvailable +// 187,PropMessageExpiryInterval 19805,PropTopicAlias 27535,PropMessageExpiryInterval 23453,PropMessageExpiryInterval +// 9517,PropServerReference "\148$`\177",PropContentType "\214A",PropReasonString "\184H\169",PropPayloadFormatIndicator +// 104,PropMessageExpiryInterval 14956,PropSessionExpiryInterval 15208,PropWildcardSubscriptionAvailable +// 53,PropMaximumQoS 237,PropTopicAlias 7810,PropSessionExpiryInterval 3612,PropMaximumPacketSize +// 28521,PropResponseInformation "\188C|\137W\183\t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, 0xdc, 0x91, 0x6d, 0x2, 0x0, 0x0, 0x10, 0x8d, 0x21, 0x6c, 0xa3, 0x29, 0x74, 0x8, 0x0, 0x0, 0x2, 0x0, 0x0, 0x63, 0xd4, 0x24, 0xa0, 0x8, 0x0, 0x10, 0x4f, 0x38, 0x9, 0xe2, 0xa9, 0x92, 0x5, 0x9f, 0x73, 0xb5, 0x9, 0x65, 0xe2, 0x89, 0x9a, 0x22, 0x9, 0x0, 0xe, 0x90, 0x5c, 0x58, 0x5b, 0xcb, 0x94, 0xf6, 0x44, 0x3e, 0x8d, 0x20, 0xe9, 0x53, 0x8f, 0x17, 0xaa, 0x13, 0x31, 0xd3}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xe1, 0x5, 0x3c, 0xe8, 0xc5, 0x90, 0xec, 0x10, 0x53, 0x4a, 0xb6, 0x67, 0x7e, 0x7e, 0xe6, 0xfc, 0x3, 0xe7}; - uint8_t bytesprops1[] = {0xcd, 0xe8, 0x88, 0x13, 0x5a, 0x7e, 0x9c, 0x78, 0x1c, 0xdf, 0xe4, 0xcb}; - uint8_t bytesprops2[] = {0xe4, 0xd, 0xec, 0xed, 0x9, 0xbc, 0x88, 0x4, 0x6f, 0xcc, 0x74, 0x50, 0x6d, 0x7f, 0xe8, 0x7b, 0x27, 0x99, 0xd1, 0xc4}; - uint8_t bytesprops3[] = {0xee, 0xd6, 0xb8, 0x89, 0x44, 0xfb}; - uint8_t bytesprops4[] = {0x97, 0x65, 0xdb, 0xfe, 0x83, 0x86, 0xb1, 0xc, 0x60, 0x9b, 0xc2, 0x33, 0x1a, 0x5d, 0x93, 0x1b, 0x97}; - uint8_t bytesprops5[] = {0x53, 0x13, 0x25, 0x78, 0x92, 0xb8, 0xd2, 0xf2, 0x5, 0x66, 0xe4, 0x40, 0x53, 0x2d, 0x3, 0xe7, 0x5c, 0x9, 0xad, 0x5e, 0x5d, 0xfe, 0xe7, 0x42, 0x23, 0x53, 0x25, 0x36}; - uint8_t bytesprops6[] = {0x8, 0x6f, 0xd0, 0x7e, 0xb0, 0x76, 0x47, 0x19, 0xab, 0x3d}; - uint8_t bytesprops7[] = {0x74, 0xcf, 0x8a, 0x1, 0x58, 0x4c, 0x8b, 0x52, 0xc9, 0xc8, 0xdc, 0x91, 0x6d}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops9[] = {0x4f, 0x38, 0x9, 0xe2, 0xa9, 0x92, 0x5, 0x9f, 0x73, 0xb5, 0x9, 0x65, 0xe2, 0x89, 0x9a, 0x22}; - uint8_t bytesprops10[] = {0x90, 0x5c, 0x58, 0x5b, 0xcb, 0x94, 0xf6, 0x44, 0x3e, 0x8d, 0x20, 0xe9, 0x53, 0x8f}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26618}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6948}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6626}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13418}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5695}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4237}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27811}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25556}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12755}}, - }; + uint8_t pkt[] = { + 0xe0, 0xf4, 0x1, 0x9d, 0xf1, 0x1, 0x12, 0x0, 0x1e, 0x88, 0x68, 0x38, 0x73, 0xf5, 0x94, 0x62, 0x1e, 0xd3, 0x81, + 0x87, 0x8a, 0xf, 0xd4, 0x8e, 0xbb, 0x9b, 0xd9, 0x3a, 0xdc, 0x2e, 0x95, 0x66, 0x1c, 0x9f, 0x5b, 0x2f, 0x93, 0x88, + 0x9, 0x1c, 0x0, 0x17, 0xf5, 0xd6, 0x12, 0x71, 0xfe, 0xab, 0xe, 0xc3, 0x98, 0x4, 0xd0, 0xe0, 0x7a, 0xec, 0xf, + 0xd4, 0x6c, 0x4b, 0x5e, 0xfd, 0xd3, 0xd0, 0xaa, 0x1f, 0x0, 0xc, 0x39, 0x35, 0x5a, 0xbe, 0xed, 0xa6, 0xbe, 0x58, + 0x79, 0xbb, 0xc4, 0xaa, 0x1c, 0x0, 0x10, 0x85, 0xb1, 0xdd, 0x6e, 0x8c, 0x31, 0xef, 0x9d, 0x6, 0x94, 0x6, 0x88, + 0x5e, 0x1, 0x8e, 0x43, 0x8, 0x0, 0x15, 0x32, 0x26, 0x3, 0x97, 0x11, 0x27, 0xea, 0xd2, 0x4a, 0x76, 0x65, 0xa8, + 0x21, 0x7a, 0xb5, 0x5c, 0x3c, 0x7, 0x9e, 0x38, 0xe, 0x21, 0x51, 0xd5, 0x25, 0xe7, 0x9, 0x0, 0x1a, 0x79, 0x1d, + 0x8e, 0xf9, 0x14, 0x38, 0x50, 0x2e, 0xa, 0xa4, 0x27, 0x8a, 0x11, 0x44, 0x2e, 0x27, 0xd2, 0x7b, 0x2, 0x9e, 0xfb, + 0x4b, 0x4d, 0xf3, 0xea, 0xa5, 0x29, 0xbb, 0x2, 0x0, 0x0, 0x4d, 0x5d, 0x23, 0x6b, 0x8f, 0x2, 0x0, 0x0, 0x5b, + 0x9d, 0x2, 0x0, 0x0, 0x25, 0x2d, 0x1c, 0x0, 0x4, 0x94, 0x24, 0x60, 0xb1, 0x3, 0x0, 0x2, 0xd6, 0x41, 0x1f, + 0x0, 0x3, 0xb8, 0x48, 0xa9, 0x1, 0x68, 0x2, 0x0, 0x0, 0x3a, 0x6c, 0x11, 0x0, 0x0, 0x3b, 0x68, 0x28, 0x35, + 0x24, 0xed, 0x23, 0x1e, 0x82, 0x11, 0x0, 0x0, 0xe, 0x1c, 0x27, 0x0, 0x0, 0x6f, 0x69, 0x1a, 0x0, 0x14, 0xbc, + 0x43, 0x7c, 0x89, 0x57, 0xb7, 0x9, 0x5, 0x9b, 0x38, 0x31, 0xac, 0x5e, 0x62, 0x1a, 0xa5, 0x9b, 0x26, 0xe, 0xe3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x88, 0x68, 0x38, 0x73, 0xf5, 0x94, 0x62, 0x1e, 0xd3, 0x81, 0x87, 0x8a, 0xf, 0xd4, 0x8e, + 0xbb, 0x9b, 0xd9, 0x3a, 0xdc, 0x2e, 0x95, 0x66, 0x1c, 0x9f, 0x5b, 0x2f, 0x93, 0x88, 0x9}; + uint8_t bytesprops1[] = {0xf5, 0xd6, 0x12, 0x71, 0xfe, 0xab, 0xe, 0xc3, 0x98, 0x4, 0xd0, 0xe0, + 0x7a, 0xec, 0xf, 0xd4, 0x6c, 0x4b, 0x5e, 0xfd, 0xd3, 0xd0, 0xaa}; + uint8_t bytesprops2[] = {0x39, 0x35, 0x5a, 0xbe, 0xed, 0xa6, 0xbe, 0x58, 0x79, 0xbb, 0xc4, 0xaa}; + uint8_t bytesprops3[] = {0x85, 0xb1, 0xdd, 0x6e, 0x8c, 0x31, 0xef, 0x9d, 0x6, 0x94, 0x6, 0x88, 0x5e, 0x1, 0x8e, 0x43}; + uint8_t bytesprops4[] = {0x32, 0x26, 0x3, 0x97, 0x11, 0x27, 0xea, 0xd2, 0x4a, 0x76, 0x65, + 0xa8, 0x21, 0x7a, 0xb5, 0x5c, 0x3c, 0x7, 0x9e, 0x38, 0xe}; + uint8_t bytesprops5[] = {0x79, 0x1d, 0x8e, 0xf9, 0x14, 0x38, 0x50, 0x2e, 0xa, 0xa4, 0x27, 0x8a, 0x11, + 0x44, 0x2e, 0x27, 0xd2, 0x7b, 0x2, 0x9e, 0xfb, 0x4b, 0x4d, 0xf3, 0xea, 0xa5}; + uint8_t bytesprops6[] = {0x94, 0x24, 0x60, 0xb1}; + uint8_t bytesprops7[] = {0xd6, 0x41}; + uint8_t bytesprops8[] = {0xb8, 0x48, 0xa9}; + uint8_t bytesprops9[] = {0xbc, 0x43, 0x7c, 0x89, 0x57, 0xb7, 0x9, 0x5, 0x9b, 0x38, + 0x31, 0xac, 0x5e, 0x62, 0x1a, 0xa5, 0x9b, 0x26, 0xe, 0xe3}; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 150, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20949}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19805}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27535}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23453}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9517}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14956}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15208}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7810}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3612}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28521}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops9}}}, + }; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 157, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoKeepAliveTimeout [PropSubscriptionIdentifier 16,PropReasonString "\DLEC\171",PropAuthenticationMethod "z\161_a\195\160\230m",PropResponseInformation "c.\DC3f\238\255-\174\148\222\152\231BA\SYN\252",PropReasonString "\186]H\146bz\\\228PE)?\155 \SUB\255{",PropReceiveMaximum 18866,PropAuthenticationData "kz\227\GS\219\205",PropWillDelayInterval 29972,PropUserProperty "\233\137\rD\208_\149\227\254\ETB\216\203\243a\147\"\USJ\242\182\143W\231k\162\243\rIb\252" "JT\231\143S\v\166^q\134;\EOT\149PX\145\148\STX\168\&8\169j\245\237",PropContentType "\143\195AB\161\151\234\SOv\243",PropRetainAvailable 162,PropSharedSubscriptionAvailable 171,PropWildcardSubscriptionAvailable 64,PropAuthenticationData "\226(\221",PropSessionExpiryInterval 15912,PropSubscriptionIdentifierAvailable 56,PropMaximumPacketSize 11188,PropRequestResponseInformation 77,PropServerReference "zc,\221?\r\255\250\DLE\222h\130K\247\169\176K\135\198\244JZ\159\192\215",PropMaximumPacketSize 19726,PropRequestResponseInformation 136,PropResponseTopic "\203\192\185)#\SOH\a\219\206<\b\FS\219\\",PropResponseTopic "WzS\142r\209\176\231\213\203!2\NUL!^\205\199\147\155\216\SI\200|2",PropMessageExpiryInterval 31378,PropRetainAvailable 155,PropServerKeepAlive 12042] +// DisconnectRequest DiscoNotAuthorized [PropReceiveMaximum 2365,PropAuthenticationMethod +// "9\185\198@\189q\ESC\180\156Z\147\151y\248\231\152\139k7\131\182\219\210#\130\252\ENQ"] TEST(Disco5QCTest, Encode2) { -uint8_t pkt[] = {0xe0, 0x89, 0x2, 0x8d, 0x86, 0x2, 0xb, 0x10, 0x1f, 0x0, 0x3, 0x10, 0x43, 0xab, 0x15, 0x0, 0x8,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, 0xc0, 0xd7, 0x27, 0x0, 0x0, 0x4d, 0xe, 0x19, 0x88, 0x8, 0x0, 0xe, 0xcb, 0xc0, 0xb9, 0x29, 0x23, 0x1, 0x7, 0xdb, 0xce, 0x3c, 0x8, 0x1c, 0xdb, 0x5c, 0x8, 0x0, 0x18, 0x57, 0x7a, 0x53, 0x8e, 0x72, 0xd1, 0xb0, 0xe7, 0xd5, 0xcb, 0x21, 0x32, 0x0, 0x21, 0x5e, 0xcd, 0xc7, 0x93, 0x9b, 0xd8, 0xf, 0xc8, 0x7c, 0x32, 0x2, 0x0, 0x0, 0x7a, 0x92, 0x25, 0x9b, 0x13, 0x2f, 0xa}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x10, 0x43, 0xab}; - uint8_t bytesprops1[] = {0x7a, 0xa1, 0x5f, 0x61, 0xc3, 0xa0, 0xe6, 0x6d}; - uint8_t bytesprops2[] = {0x63, 0x2e, 0x13, 0x66, 0xee, 0xff, 0x2d, 0xae, 0x94, 0xde, 0x98, 0xe7, 0x42, 0x41, 0x16, 0xfc}; - uint8_t bytesprops3[] = {0xba, 0x5d, 0x48, 0x92, 0x62, 0x7a, 0x5c, 0xe4, 0x50, 0x45, 0x29, 0x3f, 0x9b, 0x20, 0x1a, 0xff, 0x7b}; - uint8_t bytesprops4[] = {0x6b, 0x7a, 0xe3, 0x1d, 0xdb, 0xcd}; - uint8_t bytesprops6[] = {0x4a, 0x54, 0xe7, 0x8f, 0x53, 0xb, 0xa6, 0x5e, 0x71, 0x86, 0x3b, 0x4, 0x95, 0x50, 0x58, 0x91, 0x94, 0x2, 0xa8, 0x38, 0xa9, 0x6a, 0xf5, 0xed}; - uint8_t bytesprops5[] = {0xe9, 0x89, 0xd, 0x44, 0xd0, 0x5f, 0x95, 0xe3, 0xfe, 0x17, 0xd8, 0xcb, 0xf3, 0x61, 0x93, 0x22, 0x1f, 0x4a, 0xf2, 0xb6, 0x8f, 0x57, 0xe7, 0x6b, 0xa2, 0xf3, 0xd, 0x49, 0x62, 0xfc}; - uint8_t bytesprops7[] = {0x8f, 0xc3, 0x41, 0x42, 0xa1, 0x97, 0xea, 0xe, 0x76, 0xf3}; - uint8_t bytesprops8[] = {0xe2, 0x28, 0xdd}; - uint8_t bytesprops9[] = {0x7a, 0x63, 0x2c, 0xdd, 0x3f, 0xd, 0xff, 0xfa, 0x10, 0xde, 0x68, 0x82, 0x4b, 0xf7, 0xa9, 0xb0, 0x4b, 0x87, 0xc6, 0xf4, 0x4a, 0x5a, 0x9f, 0xc0, 0xd7}; - uint8_t bytesprops10[] = {0xcb, 0xc0, 0xb9, 0x29, 0x23, 0x1, 0x7, 0xdb, 0xce, 0x3c, 0x8, 0x1c, 0xdb, 0x5c}; - uint8_t bytesprops11[] = {0x57, 0x7a, 0x53, 0x8e, 0x72, 0xd1, 0xb0, 0xe7, 0xd5, 0xcb, 0x21, 0x32, 0x0, 0x21, 0x5e, 0xcd, 0xc7, 0x93, 0x9b, 0xd8, 0xf, 0xc8, 0x7c, 0x32}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18866}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29972}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={30, (char*)&bytesprops5}, .v={24, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15912}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11188}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19726}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31378}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12042}}, + uint8_t pkt[] = {0xe0, 0x23, 0x87, 0x21, 0x21, 0x9, 0x3d, 0x15, 0x0, 0x1b, 0x39, 0xb9, 0xc6, + 0x40, 0xbd, 0x71, 0x1b, 0xb4, 0x9c, 0x5a, 0x93, 0x97, 0x79, 0xf8, 0xe7, 0x98, + 0x8b, 0x6b, 0x37, 0x83, 0xb6, 0xdb, 0xd2, 0x23, 0x82, 0xfc, 0x5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x39, 0xb9, 0xc6, 0x40, 0xbd, 0x71, 0x1b, 0xb4, 0x9c, 0x5a, 0x93, 0x97, 0x79, 0xf8, + 0xe7, 0x98, 0x8b, 0x6b, 0x37, 0x83, 0xb6, 0xdb, 0xd2, 0x23, 0x82, 0xfc, 0x5}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2365}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 141, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 135, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoTopicNameInvalid [PropSubscriptionIdentifier 29,PropServerKeepAlive 7482,PropAuthenticationData "\STX\FS7\ENQ",PropMessageExpiryInterval 19184,PropSubscriptionIdentifierAvailable 165,PropResponseInformation "\DC1\201<\140\241N\169px\233\166_Z\196\185\131:\246\240S\205",PropSubscriptionIdentifierAvailable 196,PropSubscriptionIdentifier 21,PropSubscriptionIdentifierAvailable 193] +// DisconnectRequest DiscoQuotaExceeded [PropTopicAliasMaximum 15799,PropTopicAlias 2831,PropResponseInformation +// "\STX\163Q\131",PropSubscriptionIdentifierAvailable 184,PropAuthenticationMethod +// "\168\170\247\154\EM\145;\SO;\EM\166G\190`\149s\224\240\DELh\203@H\US-b\150",PropReasonString +// "\250\137;4\193\169\tvr_Q8\EOT\253\&4\214\189/\153!\DLE\DC4\135\207Fa\205b",PropPayloadFormatIndicator +// 155,PropWillDelayInterval 27802,PropMessageExpiryInterval 31388,PropResponseTopic +// "\128\165\224V<\"4-\133\a\161\253!\156\134X&\DC4,I.\180",PropAuthenticationData "Lp\145\249m{|\216\132Z\190\SOH\156"] TEST(Disco5QCTest, Encode3) { -uint8_t pkt[] = {0xe0, 0x33, 0x90, 0x31, 0xb, 0x1d, 0x13, 0x1d, 0x3a, 0x16, 0x0, 0x4, 0x2, 0x1c, 0x37, 0x5, 0x2, 0x0, 0x0, 0x4a, 0xf0, 0x29, 0xa5, 0x1a, 0x0, 0x15, 0x11, 0xc9, 0x3c, 0x8c, 0xf1, 0x4e, 0xa9, 0x70, 0x78, 0xe9, 0xa6, 0x5f, 0x5a, 0xc4, 0xb9, 0x83, 0x3a, 0xf6, 0xf0, 0x53, 0xcd, 0x29, 0xc4, 0xb, 0x15, 0x29, 0xc1}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x2, 0x1c, 0x37, 0x5}; - uint8_t bytesprops1[] = {0x11, 0xc9, 0x3c, 0x8c, 0xf1, 0x4e, 0xa9, 0x70, 0x78, 0xe9, 0xa6, 0x5f, 0x5a, 0xc4, 0xb9, 0x83, 0x3a, 0xf6, 0xf0, 0x53, 0xcd}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7482}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19184}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 193}}, - }; - - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + uint8_t pkt[] = {0xe0, 0x84, 0x1, 0x97, 0x81, 0x1, 0x22, 0x3d, 0xb7, 0x23, 0xb, 0xf, 0x1a, 0x0, 0x4, 0x2, 0xa3, + 0x51, 0x83, 0x29, 0xb8, 0x15, 0x0, 0x1b, 0xa8, 0xaa, 0xf7, 0x9a, 0x19, 0x91, 0x3b, 0xe, 0x3b, 0x19, + 0xa6, 0x47, 0xbe, 0x60, 0x95, 0x73, 0xe0, 0xf0, 0x7f, 0x68, 0xcb, 0x40, 0x48, 0x1f, 0x2d, 0x62, 0x96, + 0x1f, 0x0, 0x1c, 0xfa, 0x89, 0x3b, 0x34, 0xc1, 0xa9, 0x9, 0x76, 0x72, 0x5f, 0x51, 0x38, 0x4, 0xfd, + 0x34, 0xd6, 0xbd, 0x2f, 0x99, 0x21, 0x10, 0x14, 0x87, 0xcf, 0x46, 0x61, 0xcd, 0x62, 0x1, 0x9b, 0x18, + 0x0, 0x0, 0x6c, 0x9a, 0x2, 0x0, 0x0, 0x7a, 0x9c, 0x8, 0x0, 0x16, 0x80, 0xa5, 0xe0, 0x56, 0x3c, + 0x22, 0x34, 0x2d, 0x85, 0x7, 0xa1, 0xfd, 0x21, 0x9c, 0x86, 0x58, 0x26, 0x14, 0x2c, 0x49, 0x2e, 0xb4, + 0x16, 0x0, 0xd, 0x4c, 0x70, 0x91, 0xf9, 0x6d, 0x7b, 0x7c, 0xd8, 0x84, 0x5a, 0xbe, 0x1, 0x9c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x2, 0xa3, 0x51, 0x83}; + uint8_t bytesprops1[] = {0xa8, 0xaa, 0xf7, 0x9a, 0x19, 0x91, 0x3b, 0xe, 0x3b, 0x19, 0xa6, 0x47, 0xbe, 0x60, + 0x95, 0x73, 0xe0, 0xf0, 0x7f, 0x68, 0xcb, 0x40, 0x48, 0x1f, 0x2d, 0x62, 0x96}; + uint8_t bytesprops2[] = {0xfa, 0x89, 0x3b, 0x34, 0xc1, 0xa9, 0x9, 0x76, 0x72, 0x5f, 0x51, 0x38, 0x4, 0xfd, + 0x34, 0xd6, 0xbd, 0x2f, 0x99, 0x21, 0x10, 0x14, 0x87, 0xcf, 0x46, 0x61, 0xcd, 0x62}; + uint8_t bytesprops3[] = {0x80, 0xa5, 0xe0, 0x56, 0x3c, 0x22, 0x34, 0x2d, 0x85, 0x7, 0xa1, + 0xfd, 0x21, 0x9c, 0x86, 0x58, 0x26, 0x14, 0x2c, 0x49, 0x2e, 0xb4}; + uint8_t bytesprops4[] = {0x4c, 0x70, 0x91, 0xf9, 0x6d, 0x7b, 0x7c, 0xd8, 0x84, 0x5a, 0xbe, 0x1, 0x9c}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15799}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2831}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27802}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31388}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops4}}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 151, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoKeepAliveTimeout [PropContentType "j\214j",PropSubscriptionIdentifier 5,PropMessageExpiryInterval 16922,PropResponseInformation "\203\148\158\DELn\245\199\n\v\141",PropCorrelationData "\166T-\f\139\137M=A\192\230\ETB\129",PropCorrelationData "j\145\225=W\215\169\GS\255_T\205\148"] +// DisconnectRequest DiscoPayloadFormatInvalid [PropSubscriptionIdentifierAvailable 154,PropMaximumQoS +// 22,PropRetainAvailable 184,PropAuthenticationData +// "\182\209\149tT\EOTd%+Zf\152yw\206Y(m\160\147\\\FS\161\156",PropMessageExpiryInterval +// 16874,PropPayloadFormatIndicator 48,PropPayloadFormatIndicator 43,PropMaximumPacketSize +// 19500,PropMessageExpiryInterval 10936,PropResponseTopic "T\230\162",PropSessionExpiryInterval +// 7727,PropSharedSubscriptionAvailable 157,PropMaximumQoS 103,PropMaximumQoS 148,PropSubscriptionIdentifier +// 20,PropResponseInformation "\f\n\128",PropPayloadFormatIndicator 150,PropContentType +// "",PropRequestResponseInformation 67,PropResponseInformation "\162ECV\b%\FS\170\159\191M\140\151"] TEST(Disco5QCTest, Encode4) { -uint8_t pkt[] = {0xe0, 0x3c, 0x8d, 0x3a, 0x3, 0x0, 0x3, 0x6a, 0xd6, 0x6a, 0xb, 0x5, 0x2, 0x0, 0x0, 0x42, 0x1a, 0x1a, 0x0, 0xa, 0xcb, 0x94, 0x9e, 0x7f, 0x6e, 0xf5, 0xc7, 0xa, 0xb, 0x8d, 0x9, 0x0, 0xd, 0xa6, 0x54, 0x2d, 0xc, 0x8b, 0x89, 0x4d, 0x3d, 0x41, 0xc0, 0xe6, 0x17, 0x81, 0x9, 0x0, 0xd, 0x6a, 0x91, 0xe1, 0x3d, 0x57, 0xd7, 0xa9, 0x1d, 0xff, 0x5f, 0x54, 0xcd, 0x94}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x6a, 0xd6, 0x6a}; - uint8_t bytesprops1[] = {0xcb, 0x94, 0x9e, 0x7f, 0x6e, 0xf5, 0xc7, 0xa, 0xb, 0x8d}; - uint8_t bytesprops2[] = {0xa6, 0x54, 0x2d, 0xc, 0x8b, 0x89, 0x4d, 0x3d, 0x41, 0xc0, 0xe6, 0x17, 0x81}; - uint8_t bytesprops3[] = {0x6a, 0x91, 0xe1, 0x3d, 0x57, 0xd7, 0xa9, 0x1d, 0xff, 0x5f, 0x54, 0xcd, 0x94}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16922}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops3}}}, - }; + uint8_t pkt[] = {0xe0, 0x66, 0x99, 0x64, 0x29, 0x9a, 0x24, 0x16, 0x25, 0xb8, 0x16, 0x0, 0x18, 0xb6, 0xd1, + 0x95, 0x74, 0x54, 0x4, 0x64, 0x25, 0x2b, 0x5a, 0x66, 0x98, 0x79, 0x77, 0xce, 0x59, 0x28, + 0x6d, 0xa0, 0x93, 0x5c, 0x1c, 0xa1, 0x9c, 0x2, 0x0, 0x0, 0x41, 0xea, 0x1, 0x30, 0x1, + 0x2b, 0x27, 0x0, 0x0, 0x4c, 0x2c, 0x2, 0x0, 0x0, 0x2a, 0xb8, 0x8, 0x0, 0x3, 0x54, + 0xe6, 0xa2, 0x11, 0x0, 0x0, 0x1e, 0x2f, 0x2a, 0x9d, 0x24, 0x67, 0x24, 0x94, 0xb, 0x14, + 0x1a, 0x0, 0x3, 0xc, 0xa, 0x80, 0x1, 0x96, 0x3, 0x0, 0x0, 0x19, 0x43, 0x1a, 0x0, + 0xd, 0xa2, 0x45, 0x43, 0x56, 0x8, 0x25, 0x1c, 0xaa, 0x9f, 0xbf, 0x4d, 0x8c, 0x97}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb6, 0xd1, 0x95, 0x74, 0x54, 0x4, 0x64, 0x25, 0x2b, 0x5a, 0x66, 0x98, + 0x79, 0x77, 0xce, 0x59, 0x28, 0x6d, 0xa0, 0x93, 0x5c, 0x1c, 0xa1, 0x9c}; + uint8_t bytesprops1[] = {0x54, 0xe6, 0xa2}; + uint8_t bytesprops2[] = {0xc, 0xa, 0x80}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0xa2, 0x45, 0x43, 0x56, 0x8, 0x25, 0x1c, 0xaa, 0x9f, 0xbf, 0x4d, 0x8c, 0x97}; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 141, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16874}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19500}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10936}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7727}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops4}}}, + }; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 153, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoQoSNotSupported [PropTopicAlias 24397,PropReceiveMaximum 21691,PropContentType "\180n\NAK\249M\179\130\189:\158\145",PropSharedSubscriptionAvailable 27,PropContentType "\241=\180G\NAK\142",PropAssignedClientIdentifier "+\254P\217D\137\218r`\160\248|\142\&5\179\DC3C4G~",PropSharedSubscriptionAvailable 87,PropMaximumPacketSize 10553,PropTopicAlias 30553,PropSubscriptionIdentifier 15,PropTopicAlias 22925,PropResponseTopic "\NULR\ETX}\248$\164\207z\173.Z\136\249o\185\196\140\166",PropSubscriptionIdentifier 6,PropSharedSubscriptionAvailable 64,PropPayloadFormatIndicator 146,PropMaximumQoS 24,PropRetainAvailable 210,PropServerKeepAlive 23235,PropTopicAlias 14682,PropReasonString "-N\188\"\GS}I\158t\132W",PropMessageExpiryInterval 4570,PropSubscriptionIdentifierAvailable 144,PropAuthenticationData "<"] +// DisconnectRequest DiscoQoSNotSupported [PropContentType +// "\189\217\225N\157\189=\248iC\v\DLE\236e2\DC1\SI",PropAssignedClientIdentifier +// "rK\219\190\184\174\DC3g\142\US\130\243\225\&4\199\215\FSph\210\133Q\147\223r\r",PropServerKeepAlive +// 1413,PropWildcardSubscriptionAvailable 27,PropResponseInformation "\195",PropWildcardSubscriptionAvailable +// 41,PropPayloadFormatIndicator 101,PropSessionExpiryInterval 29285,PropCorrelationData +// "0/\218\191\179\132lT\US",PropSubscriptionIdentifierAvailable 135,PropRequestProblemInformation 194] TEST(Disco5QCTest, Encode5) { -uint8_t pkt[] = {0xe0, 0x87, 0x1, 0x9b, 0x84, 0x1, 0x23, 0x5f, 0x4d, 0x21, 0x54, 0xbb, 0x3, 0x0, 0xb, 0xb4, 0x6e, 0x15, 0xf9, 0x4d, 0xb3, 0x82, 0xbd, 0x3a, 0x9e, 0x91, 0x2a, 0x1b, 0x3, 0x0, 0x6, 0xf1, 0x3d, 0xb4, 0x47, 0x15, 0x8e, 0x12, 0x0, 0x14, 0x2b, 0xfe, 0x50, 0xd9, 0x44, 0x89, 0xda, 0x72, 0x60, 0xa0, 0xf8, 0x7c, 0x8e, 0x35, 0xb3, 0x13, 0x43, 0x34, 0x47, 0x7e, 0x2a, 0x57, 0x27, 0x0, 0x0, 0x29, 0x39, 0x23, 0x77, 0x59, 0xb, 0xf, 0x23, 0x59, 0x8d, 0x8, 0x0, 0x13, 0x0, 0x52, 0x3, 0x7d, 0xf8, 0x24, 0xa4, 0xcf, 0x7a, 0xad, 0x2e, 0x5a, 0x88, 0xf9, 0x6f, 0xb9, 0xc4, 0x8c, 0xa6, 0xb, 0x6, 0x2a, 0x40, 0x1, 0x92, 0x24, 0x18, 0x25, 0xd2, 0x13, 0x5a, 0xc3, 0x23, 0x39, 0x5a, 0x1f, 0x0, 0xb, 0x2d, 0x4e, 0xbc, 0x22, 0x1d, 0x7d, 0x49, 0x9e, 0x74, 0x84, 0x57, 0x2, 0x0, 0x0, 0x11, 0xda, 0x29, 0x90, 0x16, 0x0, 0x1, 0x3c}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xb4, 0x6e, 0x15, 0xf9, 0x4d, 0xb3, 0x82, 0xbd, 0x3a, 0x9e, 0x91}; - uint8_t bytesprops1[] = {0xf1, 0x3d, 0xb4, 0x47, 0x15, 0x8e}; - uint8_t bytesprops2[] = {0x2b, 0xfe, 0x50, 0xd9, 0x44, 0x89, 0xda, 0x72, 0x60, 0xa0, 0xf8, 0x7c, 0x8e, 0x35, 0xb3, 0x13, 0x43, 0x34, 0x47, 0x7e}; - uint8_t bytesprops3[] = {0x0, 0x52, 0x3, 0x7d, 0xf8, 0x24, 0xa4, 0xcf, 0x7a, 0xad, 0x2e, 0x5a, 0x88, 0xf9, 0x6f, 0xb9, 0xc4, 0x8c, 0xa6}; - uint8_t bytesprops4[] = {0x2d, 0x4e, 0xbc, 0x22, 0x1d, 0x7d, 0x49, 0x9e, 0x74, 0x84, 0x57}; - uint8_t bytesprops5[] = {0x3c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24397}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21691}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10553}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30553}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22925}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23235}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14682}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4570}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops5}}}, - }; - - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + uint8_t pkt[] = {0xe0, 0x55, 0x9b, 0x53, 0x3, 0x0, 0x11, 0xbd, 0xd9, 0xe1, 0x4e, 0x9d, 0xbd, 0x3d, 0xf8, + 0x69, 0x43, 0xb, 0x10, 0xec, 0x65, 0x32, 0x11, 0xf, 0x12, 0x0, 0x1a, 0x72, 0x4b, 0xdb, + 0xbe, 0xb8, 0xae, 0x13, 0x67, 0x8e, 0x1f, 0x82, 0xf3, 0xe1, 0x34, 0xc7, 0xd7, 0x1c, 0x70, + 0x68, 0xd2, 0x85, 0x51, 0x93, 0xdf, 0x72, 0xd, 0x13, 0x5, 0x85, 0x28, 0x1b, 0x1a, 0x0, + 0x1, 0xc3, 0x28, 0x29, 0x1, 0x65, 0x11, 0x0, 0x0, 0x72, 0x65, 0x9, 0x0, 0x9, 0x30, + 0x2f, 0xda, 0xbf, 0xb3, 0x84, 0x6c, 0x54, 0x1f, 0x29, 0x87, 0x17, 0xc2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbd, 0xd9, 0xe1, 0x4e, 0x9d, 0xbd, 0x3d, 0xf8, 0x69, + 0x43, 0xb, 0x10, 0xec, 0x65, 0x32, 0x11, 0xf}; + uint8_t bytesprops1[] = {0x72, 0x4b, 0xdb, 0xbe, 0xb8, 0xae, 0x13, 0x67, 0x8e, 0x1f, 0x82, 0xf3, 0xe1, + 0x34, 0xc7, 0xd7, 0x1c, 0x70, 0x68, 0xd2, 0x85, 0x51, 0x93, 0xdf, 0x72, 0xd}; + uint8_t bytesprops2[] = {0xc3}; + uint8_t bytesprops3[] = {0x30, 0x2f, 0xda, 0xbf, 0xb3, 0x84, 0x6c, 0x54, 0x1f}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1413}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29285}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoConnectionRateExceeded [PropUserProperty "\150\ACKW\r_\178\224\254\203\251y\190m\185\142\am\160x\DC4\181\209\162]" "\227\133U\226\&4\213\186\167\NUL\233I\174]\144\144\v\173=\194\DC2\166H\220\236\243",PropWildcardSubscriptionAvailable 112,PropAuthenticationMethod "\147\140\SO$\189.\247h\152\&5\160\181\183^\231\172\182",PropPayloadFormatIndicator 194,PropRetainAvailable 213] +// DisconnectRequest DiscoQoSNotSupported [PropResponseInformation "\228(\210io\200N\191p_\175",PropUserProperty +// "C\177+\b_\DC1\246G\141~\203 \156+\162\203\209v:\DC2\215\211" +// "\NAK\171\190\205\186\225L\184\191\ACK\204\133\&5-\236R{",PropWildcardSubscriptionAvailable 55,PropMaximumPacketSize +// 21821,PropMessageExpiryInterval 13767,PropTopicAlias 13552,PropAssignedClientIdentifier +// "\139\SI\bF\SYN\\o\213\133\&55",PropRequestProblemInformation 230,PropResponseInformation +// "NJ\182\163]\143\168\247\133\STX\207\v\149\146\166\RS\206kR0\EOT\236\160\SOH4\208\\\232\162",PropServerReference +// "\128c\v\215z\SUB\ESC\190\165@\150.\179 \241\153\&18\242g\201\EOT",PropSessionExpiryInterval 16675,PropResponseTopic +// "\177\EM\206\165\ETXy\247?\161\b\183\197\135\186\ACK\207",PropTopicAliasMaximum 12720,PropContentType +// "8\SO\198B\137a\209\210\170VE\n\169J\184"] TEST(Disco5QCTest, Encode6) { -uint8_t pkt[] = {0xe0, 0x52, 0x9f, 0x50, 0x26, 0x0, 0x18, 0x96, 0x6, 0x57, 0xd, 0x5f, 0xb2, 0xe0, 0xfe, 0xcb, 0xfb, 0x79, 0xbe, 0x6d, 0xb9, 0x8e, 0x7, 0x6d, 0xa0, 0x78, 0x14, 0xb5, 0xd1, 0xa2, 0x5d, 0x0, 0x19, 0xe3, 0x85, 0x55, 0xe2, 0x34, 0xd5, 0xba, 0xa7, 0x0, 0xe9, 0x49, 0xae, 0x5d, 0x90, 0x90, 0xb, 0xad, 0x3d, 0xc2, 0x12, 0xa6, 0x48, 0xdc, 0xec, 0xf3, 0x28, 0x70, 0x15, 0x0, 0x11, 0x93, 0x8c, 0xe, 0x24, 0xbd, 0x2e, 0xf7, 0x68, 0x98, 0x35, 0xa0, 0xb5, 0xb7, 0x5e, 0xe7, 0xac, 0xb6, 0x1, 0xc2, 0x25, 0xd5}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops1[] = {0xe3, 0x85, 0x55, 0xe2, 0x34, 0xd5, 0xba, 0xa7, 0x0, 0xe9, 0x49, 0xae, 0x5d, 0x90, 0x90, 0xb, 0xad, 0x3d, 0xc2, 0x12, 0xa6, 0x48, 0xdc, 0xec, 0xf3}; - uint8_t bytesprops0[] = {0x96, 0x6, 0x57, 0xd, 0x5f, 0xb2, 0xe0, 0xfe, 0xcb, 0xfb, 0x79, 0xbe, 0x6d, 0xb9, 0x8e, 0x7, 0x6d, 0xa0, 0x78, 0x14, 0xb5, 0xd1, 0xa2, 0x5d}; - uint8_t bytesprops2[] = {0x93, 0x8c, 0xe, 0x24, 0xbd, 0x2e, 0xf7, 0x68, 0x98, 0x35, 0xa0, 0xb5, 0xb7, 0x5e, 0xe7, 0xac, 0xb6}; - + uint8_t pkt[] = {0xe0, 0xc2, 0x1, 0x9b, 0xbf, 0x1, 0x1a, 0x0, 0xb, 0xe4, 0x28, 0xd2, 0x69, 0x6f, 0xc8, 0x4e, 0xbf, + 0x70, 0x5f, 0xaf, 0x26, 0x0, 0x16, 0x43, 0xb1, 0x2b, 0x8, 0x5f, 0x11, 0xf6, 0x47, 0x8d, 0x7e, 0xcb, + 0x20, 0x9c, 0x2b, 0xa2, 0xcb, 0xd1, 0x76, 0x3a, 0x12, 0xd7, 0xd3, 0x0, 0x11, 0x15, 0xab, 0xbe, 0xcd, + 0xba, 0xe1, 0x4c, 0xb8, 0xbf, 0x6, 0xcc, 0x85, 0x35, 0x2d, 0xec, 0x52, 0x7b, 0x28, 0x37, 0x27, 0x0, + 0x0, 0x55, 0x3d, 0x2, 0x0, 0x0, 0x35, 0xc7, 0x23, 0x34, 0xf0, 0x12, 0x0, 0xb, 0x8b, 0xf, 0x8, + 0x46, 0x16, 0x5c, 0x6f, 0xd5, 0x85, 0x35, 0x35, 0x17, 0xe6, 0x1a, 0x0, 0x1d, 0x4e, 0x4a, 0xb6, 0xa3, + 0x5d, 0x8f, 0xa8, 0xf7, 0x85, 0x2, 0xcf, 0xb, 0x95, 0x92, 0xa6, 0x1e, 0xce, 0x6b, 0x52, 0x30, 0x4, + 0xec, 0xa0, 0x1, 0x34, 0xd0, 0x5c, 0xe8, 0xa2, 0x1c, 0x0, 0x16, 0x80, 0x63, 0xb, 0xd7, 0x7a, 0x1a, + 0x1b, 0xbe, 0xa5, 0x40, 0x96, 0x2e, 0xb3, 0x20, 0xf1, 0x99, 0x31, 0x38, 0xf2, 0x67, 0xc9, 0x4, 0x11, + 0x0, 0x0, 0x41, 0x23, 0x8, 0x0, 0x10, 0xb1, 0x19, 0xce, 0xa5, 0x3, 0x79, 0xf7, 0x3f, 0xa1, 0x8, + 0xb7, 0xc5, 0x87, 0xba, 0x6, 0xcf, 0x22, 0x31, 0xb0, 0x3, 0x0, 0xf, 0x38, 0xe, 0xc6, 0x42, 0x89, + 0x61, 0xd1, 0xd2, 0xaa, 0x56, 0x45, 0xa, 0xa9, 0x4a, 0xb8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe4, 0x28, 0xd2, 0x69, 0x6f, 0xc8, 0x4e, 0xbf, 0x70, 0x5f, 0xaf}; + uint8_t bytesprops2[] = {0x15, 0xab, 0xbe, 0xcd, 0xba, 0xe1, 0x4c, 0xb8, 0xbf, + 0x6, 0xcc, 0x85, 0x35, 0x2d, 0xec, 0x52, 0x7b}; + uint8_t bytesprops1[] = {0x43, 0xb1, 0x2b, 0x8, 0x5f, 0x11, 0xf6, 0x47, 0x8d, 0x7e, 0xcb, + 0x20, 0x9c, 0x2b, 0xa2, 0xcb, 0xd1, 0x76, 0x3a, 0x12, 0xd7, 0xd3}; + uint8_t bytesprops3[] = {0x8b, 0xf, 0x8, 0x46, 0x16, 0x5c, 0x6f, 0xd5, 0x85, 0x35, 0x35}; + uint8_t bytesprops4[] = {0x4e, 0x4a, 0xb6, 0xa3, 0x5d, 0x8f, 0xa8, 0xf7, 0x85, 0x2, 0xcf, 0xb, 0x95, 0x92, 0xa6, + 0x1e, 0xce, 0x6b, 0x52, 0x30, 0x4, 0xec, 0xa0, 0x1, 0x34, 0xd0, 0x5c, 0xe8, 0xa2}; + uint8_t bytesprops5[] = {0x80, 0x63, 0xb, 0xd7, 0x7a, 0x1a, 0x1b, 0xbe, 0xa5, 0x40, 0x96, + 0x2e, 0xb3, 0x20, 0xf1, 0x99, 0x31, 0x38, 0xf2, 0x67, 0xc9, 0x4}; + uint8_t bytesprops6[] = {0xb1, 0x19, 0xce, 0xa5, 0x3, 0x79, 0xf7, 0x3f, 0xa1, 0x8, 0xb7, 0xc5, 0x87, 0xba, 0x6, 0xcf}; + uint8_t bytesprops7[] = {0x38, 0xe, 0xc6, 0x42, 0x89, 0x61, 0xd1, 0xd2, 0xaa, 0x56, 0x45, 0xa, 0xa9, 0x4a, 0xb8}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={24, (char*)&bytesprops0}, .v={25, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops1}, .v = {17, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21821}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13767}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13552}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16675}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12720}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoTopicFilterInvalid [PropTopicAliasMaximum 7050,PropRequestProblemInformation 59,PropMaximumPacketSize 14933,PropContentType "a\187\241l\134&\203N\CAN\194\&25,\172\ETX\239\189L\ETXOc\187",PropResponseInformation "\227;\195#r\237\150\245we\176|\207\ENQ\237\SI|\144\194\202@\181\217LH\amK",PropAuthenticationMethod "|_\202\226\237\225u\ETB\248\EM\178}\162v\177&\"\228^H",PropRequestResponseInformation 147] +// DisconnectRequest DiscoSharedSubscriptionsNotSupported [PropMessageExpiryInterval 11490,PropPayloadFormatIndicator +// 13,PropServerKeepAlive 27670,PropSessionExpiryInterval 16138,PropTopicAlias 7546,PropUserProperty +// "\190\DC2z\155\239\207\177\rw\205\STX\156\139\131" "u\SUB.<\214\181\221P\237lI\239\246",PropSessionExpiryInterval +// 3968,PropUserProperty "\138\&5\250\&3\"r\144\179\248yH9\253\237S\CAN\157\EM\200x\SI\166K\156\183" +// "\244\f\224\208E^\b}\137x\193\232\177\196\209aP\223\&0\ESC",PropAssignedClientIdentifier +// "\176:s\251\174\192\NULz\137G\208$\137p\131\DC3\130\bX\US0\188\250\233\SO\f\ESCL",PropMaximumQoS 110,PropMaximumQoS +// 180,PropAuthenticationMethod "k\r\217\ru,\nB\235\213m\"]\247Sk\240\211\135zD)\183\240\245",PropTopicAliasMaximum +// 18518,PropServerReference "X\252\DC1\218oX\200\156h\172E-\224\132]\170\&3\175c",PropAssignedClientIdentifier +// "e\154\&4l",PropResponseInformation "}8e\161\183\RSI\229\202\US\144\220\r_\190\141\SUB}",PropSessionExpiryInterval +// 18101,PropCorrelationData "\\2\129O\159\195W}\150\DC1\137\&5\233\140S\DC3\EM\185'\SUB\192\159v\204r",PropContentType +// "\207P\v\RSj",PropRetainAvailable 235,PropContentType +// "w\200\234h{\222@\149\210\225\133\v\248\243\246(\US\128\&3&\136\201t\200\DC4\206\227",PropSubscriptionIdentifier 14] TEST(Disco5QCTest, Encode7) { -uint8_t pkt[] = {0xe0, 0x5d, 0x8f, 0x5b, 0x22, 0x1b, 0x8a, 0x17, 0x3b, 0x27, 0x0, 0x0, 0x3a, 0x55, 0x3, 0x0, 0x16, 0x61, 0xbb, 0xf1, 0x6c, 0x86, 0x26, 0xcb, 0x4e, 0x18, 0xc2, 0x32, 0x35, 0x2c, 0xac, 0x3, 0xef, 0xbd, 0x4c, 0x3, 0x4f, 0x63, 0xbb, 0x1a, 0x0, 0x1c, 0xe3, 0x3b, 0xc3, 0x23, 0x72, 0xed, 0x96, 0xf5, 0x77, 0x65, 0xb0, 0x7c, 0xcf, 0x5, 0xed, 0xf, 0x7c, 0x90, 0xc2, 0xca, 0x40, 0xb5, 0xd9, 0x4c, 0x48, 0x7, 0x6d, 0x4b, 0x15, 0x0, 0x14, 0x7c, 0x5f, 0xca, 0xe2, 0xed, 0xe1, 0x75, 0x17, 0xf8, 0x19, 0xb2, 0x7d, 0xa2, 0x76, 0xb1, 0x26, 0x22, 0xe4, 0x5e, 0x48, 0x19, 0x93}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x61, 0xbb, 0xf1, 0x6c, 0x86, 0x26, 0xcb, 0x4e, 0x18, 0xc2, 0x32, 0x35, 0x2c, 0xac, 0x3, 0xef, 0xbd, 0x4c, 0x3, 0x4f, 0x63, 0xbb}; - uint8_t bytesprops1[] = {0xe3, 0x3b, 0xc3, 0x23, 0x72, 0xed, 0x96, 0xf5, 0x77, 0x65, 0xb0, 0x7c, 0xcf, 0x5, 0xed, 0xf, 0x7c, 0x90, 0xc2, 0xca, 0x40, 0xb5, 0xd9, 0x4c, 0x48, 0x7, 0x6d, 0x4b}; - uint8_t bytesprops2[] = {0x7c, 0x5f, 0xca, 0xe2, 0xed, 0xe1, 0x75, 0x17, 0xf8, 0x19, 0xb2, 0x7d, 0xa2, 0x76, 0xb1, 0x26, 0x22, 0xe4, 0x5e, 0x48}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7050}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14933}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value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fc, 0x11, 0xda, 0x6f, 0x58, 0xc8, 0x9c, 0x68, 0xac, + 0x45, 0x2d, 0xe0, 0x84, 0x5d, 0xaa, 0x33, 0xaf, 0x63, 0x12, 0x0, 0x4, 0x65, 0x9a, 0x34, 0x6c, 0x1a, 0x0, 0x12, + 0x7d, 0x38, 0x65, 0xa1, 0xb7, 0x1e, 0x49, 0xe5, 0xca, 0x1f, 0x90, 0xdc, 0xd, 0x5f, 0xbe, 0x8d, 0x1a, 0x7d, 0x11, + 0x0, 0x0, 0x46, 0xb5, 0x9, 0x0, 0x19, 0x5c, 0x32, 0x81, 0x4f, 0x9f, 0xc3, 0x57, 0x7d, 0x96, 0x11, 0x89, 0x35, + 0xe9, 0x8c, 0x53, 0x13, 0x19, 0xb9, 0x27, 0x1a, 0xc0, 0x9f, 0x76, 0xcc, 0x72, 0x3, 0x0, 0x5, 0xcf, 0x50, 0xb, + 0x1e, 0x6a, 0x25, 0xeb, 0x3, 0x0, 0x1b, 0x77, 0xc8, 0xea, 0x68, 0x7b, 0xde, 0x40, 0x95, 0xd2, 0xe1, 0x85, 0xb, + 0xf8, 0xf3, 0xf6, 0x28, 0x1f, 0x80, 0x33, 0x26, 0x88, 0xc9, 0x74, 0xc8, 0x14, 0xce, 0xe3, 0xb, 0xe}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x75, 0x1a, 0x2e, 0x3c, 0xd6, 0xb5, 0xdd, 0x50, 0xed, 0x6c, 0x49, 0xef, 0xf6}; + uint8_t bytesprops0[] = {0xbe, 0x12, 0x7a, 0x9b, 0xef, 0xcf, 0xb1, 0xd, 0x77, 0xcd, 0x2, 0x9c, 0x8b, 0x83}; + uint8_t bytesprops3[] = {0xf4, 0xc, 0xe0, 0xd0, 0x45, 0x5e, 0x8, 0x7d, 0x89, 0x78, + 0xc1, 0xe8, 0xb1, 0xc4, 0xd1, 0x61, 0x50, 0xdf, 0x30, 0x1b}; + uint8_t bytesprops2[] = {0x8a, 0x35, 0xfa, 0x33, 0x22, 0x72, 0x90, 0xb3, 0xf8, 0x79, 0x48, 0x39, 0xfd, + 0xed, 0x53, 0x18, 0x9d, 0x19, 0xc8, 0x78, 0xf, 0xa6, 0x4b, 0x9c, 0xb7}; + uint8_t bytesprops4[] = {0xb0, 0x3a, 0x73, 0xfb, 0xae, 0xc0, 0x0, 0x7a, 0x89, 0x47, 0xd0, 0x24, 0x89, 0x70, + 0x83, 0x13, 0x82, 0x8, 0x58, 0x1f, 0x30, 0xbc, 0xfa, 0xe9, 0xe, 0xc, 0x1b, 0x4c}; + uint8_t bytesprops5[] = {0x6b, 0xd, 0xd9, 0xd, 0x75, 0x2c, 0xa, 0x42, 0xeb, 0xd5, 0x6d, 0x22, 0x5d, + 0xf7, 0x53, 0x6b, 0xf0, 0xd3, 0x87, 0x7a, 0x44, 0x29, 0xb7, 0xf0, 0xf5}; + uint8_t bytesprops6[] = {0x58, 0xfc, 0x11, 0xda, 0x6f, 0x58, 0xc8, 0x9c, 0x68, 0xac, + 0x45, 0x2d, 0xe0, 0x84, 0x5d, 0xaa, 0x33, 0xaf, 0x63}; + uint8_t bytesprops7[] = {0x65, 0x9a, 0x34, 0x6c}; + uint8_t bytesprops8[] = {0x7d, 0x38, 0x65, 0xa1, 0xb7, 0x1e, 0x49, 0xe5, 0xca, + 0x1f, 0x90, 0xdc, 0xd, 0x5f, 0xbe, 0x8d, 0x1a, 0x7d}; + uint8_t bytesprops9[] = {0x5c, 0x32, 0x81, 0x4f, 0x9f, 0xc3, 0x57, 0x7d, 0x96, 0x11, 0x89, 0x35, 0xe9, + 0x8c, 0x53, 0x13, 0x19, 0xb9, 0x27, 0x1a, 0xc0, 0x9f, 0x76, 0xcc, 0x72}; + uint8_t bytesprops10[] = {0xcf, 0x50, 0xb, 0x1e, 0x6a}; + uint8_t bytesprops11[] = {0x77, 0xc8, 0xea, 0x68, 0x7b, 0xde, 0x40, 0x95, 0xd2, 0xe1, 0x85, 0xb, 0xf8, 0xf3, + 0xf6, 0x28, 0x1f, 0x80, 0x33, 0x26, 0x88, 0xc9, 0x74, 0xc8, 0x14, 0xce, 0xe3}; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 143, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11490}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27670}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16138}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7546}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3968}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops2}, .v = {20, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18518}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18101}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + }; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 158, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoServerMoved [PropAuthenticationData "\133\aV\218f{\DEL+0Z\254\160\142\DC2{*`\bb^d\ACK\183\174nO\174",PropRetainAvailable 100,PropUserProperty "\130\226" "f+\145\172\214a%\153\151\186",PropRetainAvailable 2,PropServerKeepAlive 19057,PropAssignedClientIdentifier "#X\b\242~:\246X\SUBo\155v~\ESC\189\185\159i\203",PropCorrelationData "\199z\242Bv\210\&0\187\240\144\198\247",PropAuthenticationData ">L^\162\189L\b\166\v\FS\139Q&\EM4\232\156\231\212H\174\244\t\188\202\154",PropSharedSubscriptionAvailable 88,PropMaximumPacketSize 12821,PropAssignedClientIdentifier "R\179\151\210~Yl5\218\208k\180\159K\176\138",PropAuthenticationMethod "\v\188k\163W\SOH",PropReasonString "\162\SOH\180HL\222\245H\v\DC3",PropReceiveMaximum 20007,PropWillDelayInterval 23538,PropMessageExpiryInterval 21495,PropResponseInformation "\149\241\223\&2\EM\NAK\249G",PropMessageExpiryInterval 13410,PropResponseInformation "\166\235k0\187Z\202\248\195\173\STX\232O\131\217\n\165\197}\201\137\148\152\242-\202",PropMessageExpiryInterval 22642,PropRequestProblemInformation 120,PropResponseInformation "n\NAK3\174T\146\196\SI\170\147\&2p\129\255um6\194\DC3\ETB+[\147\&6\146\202\"(",PropRetainAvailable 42,PropRequestProblemInformation 109,PropMaximumPacketSize 25224] +// DisconnectRequest DiscoMaximumConnectTime [PropWildcardSubscriptionAvailable 9,PropResponseInformation +// "\242\"\144\253\155A\a\224\157\&0\250\167\202UU\DC3i\SO\216\ESCE\t\200e\236",PropAuthenticationData +// "\224q~\185\ACK\169\192g\DC2\146\&11iM\128\204\a\176\DC40M",PropRequestProblemInformation 236,PropCorrelationData +// "\164Z\140\175\231\192N\164\SOH{P\ETB\194\200\154\178\193",PropRequestResponseInformation +// 247,PropSubscriptionIdentifierAvailable 58,PropRequestResponseInformation 250,PropMessageExpiryInterval 31479] TEST(Disco5QCTest, Encode8) { -uint8_t pkt[] = {0xe0, 0x94, 0x2, 0x9d, 0x91, 0x2, 0x16, 0x0, 0x1b, 0x85, 0x7, 0x56, 0xda, 0x66, 0x7b, 0x7f, 0x2b, 0x30, 0x5a, 0xfe, 0xa0, 0x8e, 0x12, 0x7b, 0x2a, 0x60, 0x8, 0x62, 0x5e, 0x64, 0x6, 0xb7, 0xae, 0x6e, 0x4f, 0xae, 0x25, 0x64, 0x26, 0x0, 0x2, 0x82, 0xe2, 0x0, 0xa, 0x66, 0x2b, 0x91, 0xac, 0xd6, 0x61, 0x25, 0x99, 0x97, 0xba, 0x25, 0x2, 0x13, 0x4a, 0x71, 0x12, 0x0, 0x13, 0x23, 0x58, 0x8, 0xf2, 0x7e, 0x3a, 0xf6, 0x58, 0x1a, 0x6f, 0x9b, 0x76, 0x7e, 0x1b, 0xbd, 0xb9, 0x9f, 0x69, 0xcb, 0x9, 0x0, 0xc, 0xc7, 0x7a, 0xf2, 0x42, 0x76, 0xd2, 0x30, 0xbb, 0xf0, 0x90, 0xc6, 0xf7, 0x16, 0x0, 0x1a, 0x3e, 0x4c, 0x5e, 0xa2, 0xbd, 0x4c, 0x8, 0xa6, 0xb, 0x1c, 0x8b, 0x51, 0x26, 0x19, 0x34, 0xe8, 0x9c, 0xe7, 0xd4, 0x48, 0xae, 0xf4, 0x9, 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, 0xae}; - uint8_t bytesprops2[] = {0x66, 0x2b, 0x91, 0xac, 0xd6, 0x61, 0x25, 0x99, 0x97, 0xba}; - uint8_t bytesprops1[] = {0x82, 0xe2}; - uint8_t bytesprops3[] = {0x23, 0x58, 0x8, 0xf2, 0x7e, 0x3a, 0xf6, 0x58, 0x1a, 0x6f, 0x9b, 0x76, 0x7e, 0x1b, 0xbd, 0xb9, 0x9f, 0x69, 0xcb}; - uint8_t bytesprops4[] = {0xc7, 0x7a, 0xf2, 0x42, 0x76, 0xd2, 0x30, 0xbb, 0xf0, 0x90, 0xc6, 0xf7}; - uint8_t bytesprops5[] = {0x3e, 0x4c, 0x5e, 0xa2, 0xbd, 0x4c, 0x8, 0xa6, 0xb, 0x1c, 0x8b, 0x51, 0x26, 0x19, 0x34, 0xe8, 0x9c, 0xe7, 0xd4, 0x48, 0xae, 0xf4, 0x9, 0xbc, 0xca, 0x9a}; - uint8_t bytesprops6[] = {0x52, 0xb3, 0x97, 0xd2, 0x7e, 0x59, 0x6c, 0x35, 0xda, 0xd0, 0x6b, 0xb4, 0x9f, 0x4b, 0xb0, 0x8a}; - uint8_t bytesprops7[] = {0xb, 0xbc, 0x6b, 0xa3, 0x57, 0x1}; - uint8_t bytesprops8[] = {0xa2, 0x1, 0xb4, 0x48, 0x4c, 0xde, 0xf5, 0x48, 0xb, 0x13}; - uint8_t bytesprops9[] = {0x95, 0xf1, 0xdf, 0x32, 0x19, 0x15, 0xf9, 0x47}; - uint8_t bytesprops10[] = {0xa6, 0xeb, 0x6b, 0x30, 0xbb, 0x5a, 0xca, 0xf8, 0xc3, 0xad, 0x2, 0xe8, 0x4f, 0x83, 0xd9, 0xa, 0xa5, 0xc5, 0x7d, 0xc9, 0x89, 0x94, 0x98, 0xf2, 0x2d, 0xca}; - uint8_t bytesprops11[] = {0x6e, 0x15, 0x33, 0xae, 0x54, 0x92, 0xc4, 0xf, 0xaa, 0x93, 0x32, 0x70, 0x81, 0xff, 0x75, 0x6d, 0x36, 0xc2, 0x13, 0x17, 0x2b, 0x5b, 0x93, 0x36, 0x92, 0xca, 0x22, 0x28}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={2, (char*)&bytesprops1}, .v={10, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19057}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12821}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20007}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23538}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21495}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13410}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22642}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25224}}, - }; + uint8_t pkt[] = {0xe0, 0x59, 0xa0, 0x57, 0x28, 0x9, 0x1a, 0x0, 0x19, 0xf2, 0x22, 0x90, 0xfd, 0x9b, 0x41, 0x7, + 0xe0, 0x9d, 0x30, 0xfa, 0xa7, 0xca, 0x55, 0x55, 0x13, 0x69, 0xe, 0xd8, 0x1b, 0x45, 0x9, 0xc8, + 0x65, 0xec, 0x16, 0x0, 0x15, 0xe0, 0x71, 0x7e, 0xb9, 0x6, 0xa9, 0xc0, 0x67, 0x12, 0x92, 0x31, + 0x31, 0x69, 0x4d, 0x80, 0xcc, 0x7, 0xb0, 0x14, 0x30, 0x4d, 0x17, 0xec, 0x9, 0x0, 0x11, 0xa4, + 0x5a, 0x8c, 0xaf, 0xe7, 0xc0, 0x4e, 0xa4, 0x1, 0x7b, 0x50, 0x17, 0xc2, 0xc8, 0x9a, 0xb2, 0xc1, + 0x19, 0xf7, 0x29, 0x3a, 0x19, 0xfa, 0x2, 0x0, 0x0, 0x7a, 0xf7}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf2, 0x22, 0x90, 0xfd, 0x9b, 0x41, 0x7, 0xe0, 0x9d, 0x30, 0xfa, 0xa7, 0xca, + 0x55, 0x55, 0x13, 0x69, 0xe, 0xd8, 0x1b, 0x45, 0x9, 0xc8, 0x65, 0xec}; + uint8_t bytesprops1[] = {0xe0, 0x71, 0x7e, 0xb9, 0x6, 0xa9, 0xc0, 0x67, 0x12, 0x92, 0x31, + 0x31, 0x69, 0x4d, 0x80, 0xcc, 0x7, 0xb0, 0x14, 0x30, 0x4d}; + uint8_t bytesprops2[] = {0xa4, 0x5a, 0x8c, 0xaf, 0xe7, 0xc0, 0x4e, 0xa4, 0x1, + 0x7b, 0x50, 0x17, 0xc2, 0xc8, 0x9a, 0xb2, 0xc1}; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 157, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31479}}, + }; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 160, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoReceiveMaximumExceeded [PropServerKeepAlive 16952,PropMessageExpiryInterval 27410,PropResponseInformation "\135\SOHA\239\&0yy\227f\189\169\\\155\&6\233\164Ly\180\183",PropServerKeepAlive 29488,PropUserProperty "\197A\138t#\164\247\192" "\176\139K9\227M+ GBHp[,\205\&0\155`1\214QY1\220\187\217\255",PropUserProperty "oZJ\246\&1\200C\251\164\148\ENQ\200/\223\187+\228\FS\CANOM" "Z\154x6\247\138\163",PropSessionExpiryInterval 14049,PropMaximumPacketSize +// 6508,PropResponseTopic "\ETXCT(\\{\RS\DEL\206\EOT\183\141O",PropReasonString +// "\150AFn\165\146\189\&2\253\145-\SUB\US\162G\151\245\201\&4x\DLE\155\129\238",PropResponseInformation +// "\184\153\r\175\180\t\250\197/\DC1\190\210\208\186\187l\EM\216",PropWildcardSubscriptionAvailable +// 165,PropAuthenticationData "\US\USf\180\206\t/\248\167\ETB\246\DC2\213\SUBH\239+A\ENQ"] TEST(Disco5QCTest, Encode11) { -uint8_t pkt[] = {0xe0, 0x5c, 0x0, 0x5a, 0x9, 0x0, 0xb, 0xa0, 0xd9, 0x3f, 0xdd, 0xbb, 0x99, 0xf2, 0x39, 0xd8, 0xd1, 0xc4, 0xb, 0x1, 0x2a, 0x3e, 0x16, 0x0, 0x1c, 0xdc, 0x12, 0x77, 0x9b, 0xff, 0xdb, 0x93, 0x15, 0xba, 0x5d, 0xf, 0x3f, 0x2d, 0xf2, 0x39, 0x9b, 0x49, 0x59, 0x71, 0x6c, 0xb4, 0xa4, 0x71, 0x96, 0x7, 0x0, 0xab, 0x1d, 0x1f, 0x0, 0x14, 0xf2, 0x2f, 0x81, 0x91, 0xf, 0x94, 0xb6, 0x34, 0x54, 0xb6, 0x52, 0x8b, 0x5e, 0xef, 0x3b, 0x42, 0xf6, 0xc1, 0x6a, 0x55, 0x17, 0xa2, 0x1a, 0x0, 0xa, 0x4e, 0xd0, 0x75, 0xd7, 0x50, 0xa1, 0x68, 0x4, 0x28, 0xf3, 0x21, 0x9, 0x6c}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xa0, 0xd9, 0x3f, 0xdd, 0xbb, 0x99, 0xf2, 0x39, 0xd8, 0xd1, 0xc4}; - uint8_t bytesprops1[] = {0xdc, 0x12, 0x77, 0x9b, 0xff, 0xdb, 0x93, 0x15, 0xba, 0x5d, 0xf, 0x3f, 0x2d, 0xf2, 0x39, 0x9b, 0x49, 0x59, 0x71, 0x6c, 0xb4, 0xa4, 0x71, 0x96, 0x7, 0x0, 0xab, 0x1d}; - uint8_t bytesprops2[] = {0xf2, 0x2f, 0x81, 0x91, 0xf, 0x94, 0xb6, 0x34, 0x54, 0xb6, 0x52, 0x8b, 0x5e, 0xef, 0x3b, 0x42, 0xf6, 0xc1, 0x6a, 0x55}; - uint8_t bytesprops3[] = {0x4e, 0xd0, 0x75, 0xd7, 0x50, 0xa1, 0x68, 0x4, 0x28, 0xf3}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2412}}, - }; + uint8_t pkt[] = {0xe0, 0x84, 0x1, 0x9d, 0x81, 0x1, 0x24, 0x1f, 0x17, 0x91, 0x21, 0x30, 0x33, 0x2, 0x0, 0x0, 0x6, + 0x13, 0x19, 0x80, 0x23, 0x51, 0x2d, 0x23, 0x1a, 0x3d, 0x2, 0x0, 0x0, 0x36, 0x5f, 0x8, 0x0, 0x3, + 0x2d, 0x3e, 0xa3, 0x11, 0x0, 0x0, 0x36, 0xe1, 0x27, 0x0, 0x0, 0x19, 0x6c, 0x8, 0x0, 0xd, 0x3, + 0x43, 0x54, 0x28, 0x5c, 0x7b, 0x1e, 0x7f, 0xce, 0x4, 0xb7, 0x8d, 0x4f, 0x1f, 0x0, 0x18, 0x96, 0x41, + 0x46, 0x6e, 0xa5, 0x92, 0xbd, 0x32, 0xfd, 0x91, 0x2d, 0x1a, 0x1f, 0xa2, 0x47, 0x97, 0xf5, 0xc9, 0x34, + 0x78, 0x10, 0x9b, 0x81, 0xee, 0x1a, 0x0, 0x12, 0xb8, 0x99, 0xd, 0xaf, 0xb4, 0x9, 0xfa, 0xc5, 0x2f, + 0x11, 0xbe, 0xd2, 0xd0, 0xba, 0xbb, 0x6c, 0x19, 0xd8, 0x28, 0xa5, 0x16, 0x0, 0x13, 0x1f, 0x1f, 0x66, + 0xb4, 0xce, 0x9, 0x2f, 0xf8, 0xa7, 0x17, 0xf6, 0x12, 0xd5, 0x1a, 0x48, 0xef, 0x2b, 0x41, 0x5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x2d, 0x3e, 0xa3}; + uint8_t bytesprops1[] = {0x3, 0x43, 0x54, 0x28, 0x5c, 0x7b, 0x1e, 0x7f, 0xce, 0x4, 0xb7, 0x8d, 0x4f}; + uint8_t bytesprops2[] = {0x96, 0x41, 0x46, 0x6e, 0xa5, 0x92, 0xbd, 0x32, 0xfd, 0x91, 0x2d, 0x1a, + 0x1f, 0xa2, 0x47, 0x97, 0xf5, 0xc9, 0x34, 0x78, 0x10, 0x9b, 0x81, 0xee}; + uint8_t bytesprops3[] = {0xb8, 0x99, 0xd, 0xaf, 0xb4, 0x9, 0xfa, 0xc5, 0x2f, + 0x11, 0xbe, 0xd2, 0xd0, 0xba, 0xbb, 0x6c, 0x19, 0xd8}; + uint8_t bytesprops4[] = {0x1f, 0x1f, 0x66, 0xb4, 0xce, 0x9, 0x2f, 0xf8, 0xa7, 0x17, + 0xf6, 0x12, 0xd5, 0x1a, 0x48, 0xef, 0x2b, 0x41, 0x5}; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12339}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1555}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20781}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6717}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13919}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14049}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6508}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops4}}}, + }; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 157, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoPacketTooLarge [PropTopicAliasMaximum 2818,PropMessageExpiryInterval 28513,PropRequestProblemInformation 93,PropMessageExpiryInterval 9700,PropReasonString "0\244'&\nU\SUB\162\136e\ACKlu\243^\168@\DEL\b EP4\188\&2\131=Y\155",PropMaximumPacketSize 16244,PropMessageExpiryInterval 28664,PropPayloadFormatIndicator 101,PropMaximumQoS 157,PropServerReference "J\191\EOT\218\EM\175p\GSh \131\170\178v8SA\140o(\231\245\199r}O\SUB\191a\246",PropRequestResponseInformation 232,PropSessionExpiryInterval 5258,PropServerReference "\254I\189\215\&4l\STX\201l/\190$\243\DC4\174k\191\146>oFY\RS^\237",PropReasonString "\168\141\189f\166",PropSessionExpiryInterval 7969] +// DisconnectRequest DiscoPayloadFormatInvalid [PropMessageExpiryInterval 6984,PropSubscriptionIdentifier +// 17,PropServerReference "k+\223\218\228\255\174\248\209D\140\181\164\SUB\136\175K\185",PropAssignedClientIdentifier +// "\150\224\191\129T\a\185[\172\158\DLE\208\186\ETB\238\168\222(L1\247\221",PropResponseTopic +// "\217\&4\155\216.\218\128\DC4\221B\143\SI\247\&1",PropSubscriptionIdentifierAvailable 6,PropAssignedClientIdentifier +// "",PropWildcardSubscriptionAvailable 87,PropTopicAliasMaximum 1948,PropResponseTopic +// "\192\176\194A\221y\194\187\207\201\"\128\NUL!?\169\EOT\DLE",PropContentType "\203",PropSessionExpiryInterval +// 20851,PropSubscriptionIdentifier 17,PropMessageExpiryInterval 30485,PropServerKeepAlive +// 8118,PropRequestProblemInformation 194,PropReceiveMaximum 31011,PropAuthenticationData +// "\201{H\210?\241\NAK\205",PropRequestResponseInformation 61] TEST(Disco5QCTest, Encode12) { -uint8_t pkt[] = {0xe0, 0x91, 0x1, 0x95, 0x8e, 0x1, 0x22, 0xb, 0x2, 0x2, 0x0, 0x0, 0x6f, 0x61, 0x17, 0x5d, 0x2, 0x0, 0x0, 0x25, 0xe4, 0x1f, 0x0, 0x1d, 0x30, 0xf4, 0x27, 0x26, 0xa, 0x55, 0x1a, 0xa2, 0x88, 0x65, 0x6, 0x6c, 0x75, 0xf3, 0x5e, 0xa8, 0x40, 0x7f, 0x8, 0x20, 0x45, 0x50, 0x34, 0xbc, 0x32, 0x83, 0x3d, 0x59, 0x9b, 0x27, 0x0, 0x0, 0x3f, 0x74, 0x2, 0x0, 0x0, 0x6f, 0xf8, 0x1, 0x65, 0x24, 0x9d, 0x1c, 0x0, 0x1e, 0x4a, 0xbf, 0x4, 0xda, 0x19, 0xaf, 0x70, 0x1d, 0x68, 0x20, 0x83, 0xaa, 0xb2, 0x76, 0x38, 0x53, 0x41, 0x8c, 0x6f, 0x28, 0xe7, 0xf5, 0xc7, 0x72, 0x7d, 0x4f, 0x1a, 0xbf, 0x61, 0xf6, 0x19, 0xe8, 0x11, 0x0, 0x0, 0x14, 0x8a, 0x1c, 0x0, 0x19, 0xfe, 0x49, 0xbd, 0xd7, 0x34, 0x6c, 0x2, 0xc9, 0x6c, 0x2f, 0xbe, 0x24, 0xf3, 0x14, 0xae, 0x6b, 0xbf, 0x92, 0x3e, 0x6f, 0x46, 0x59, 0x1e, 0x5e, 0xed, 0x1f, 0x0, 0x5, 0xa8, 0x8d, 0xbd, 0x66, 0xa6, 0x11, 0x0, 0x0, 0x1f, 0x21}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x30, 0xf4, 0x27, 0x26, 0xa, 0x55, 0x1a, 0xa2, 0x88, 0x65, 0x6, 0x6c, 0x75, 0xf3, 0x5e, 0xa8, 0x40, 0x7f, 0x8, 0x20, 0x45, 0x50, 0x34, 0xbc, 0x32, 0x83, 0x3d, 0x59, 0x9b}; - uint8_t bytesprops1[] = {0x4a, 0xbf, 0x4, 0xda, 0x19, 0xaf, 0x70, 0x1d, 0x68, 0x20, 0x83, 0xaa, 0xb2, 0x76, 0x38, 0x53, 0x41, 0x8c, 0x6f, 0x28, 0xe7, 0xf5, 0xc7, 0x72, 0x7d, 0x4f, 0x1a, 0xbf, 0x61, 0xf6}; - uint8_t bytesprops2[] = {0xfe, 0x49, 0xbd, 0xd7, 0x34, 0x6c, 0x2, 0xc9, 0x6c, 0x2f, 0xbe, 0x24, 0xf3, 0x14, 0xae, 0x6b, 0xbf, 0x92, 0x3e, 0x6f, 0x46, 0x59, 0x1e, 0x5e, 0xed}; - uint8_t bytesprops3[] = {0xa8, 0x8d, 0xbd, 0x66, 0xa6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2818}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28513}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9700}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16244}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28664}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5258}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7969}}, - }; + uint8_t pkt[] = {0xe0, 0x8d, 0x1, 0x99, 0x8a, 0x1, 0x2, 0x0, 0x0, 0x1b, 0x48, 0xb, 0x11, 0x1c, 0x0, 0x12, + 0x6b, 0x2b, 0xdf, 0xda, 0xe4, 0xff, 0xae, 0xf8, 0xd1, 0x44, 0x8c, 0xb5, 0xa4, 0x1a, 0x88, 0xaf, + 0x4b, 0xb9, 0x12, 0x0, 0x16, 0x96, 0xe0, 0xbf, 0x81, 0x54, 0x7, 0xb9, 0x5b, 0xac, 0x9e, 0x10, + 0xd0, 0xba, 0x17, 0xee, 0xa8, 0xde, 0x28, 0x4c, 0x31, 0xf7, 0xdd, 0x8, 0x0, 0xe, 0xd9, 0x34, + 0x9b, 0xd8, 0x2e, 0xda, 0x80, 0x14, 0xdd, 0x42, 0x8f, 0xf, 0xf7, 0x31, 0x29, 0x6, 0x12, 0x0, + 0x0, 0x28, 0x57, 0x22, 0x7, 0x9c, 0x8, 0x0, 0x12, 0xc0, 0xb0, 0xc2, 0x41, 0xdd, 0x79, 0xc2, + 0xbb, 0xcf, 0xc9, 0x22, 0x80, 0x0, 0x21, 0x3f, 0xa9, 0x4, 0x10, 0x3, 0x0, 0x1, 0xcb, 0x11, + 0x0, 0x0, 0x51, 0x73, 0xb, 0x11, 0x2, 0x0, 0x0, 0x77, 0x15, 0x13, 0x1f, 0xb6, 0x17, 0xc2, + 0x21, 0x79, 0x23, 0x16, 0x0, 0x8, 0xc9, 0x7b, 0x48, 0xd2, 0x3f, 0xf1, 0x15, 0xcd, 0x19, 0x3d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x6b, 0x2b, 0xdf, 0xda, 0xe4, 0xff, 0xae, 0xf8, 0xd1, + 0x44, 0x8c, 0xb5, 0xa4, 0x1a, 0x88, 0xaf, 0x4b, 0xb9}; + uint8_t bytesprops1[] = {0x96, 0xe0, 0xbf, 0x81, 0x54, 0x7, 0xb9, 0x5b, 0xac, 0x9e, 0x10, + 0xd0, 0xba, 0x17, 0xee, 0xa8, 0xde, 0x28, 0x4c, 0x31, 0xf7, 0xdd}; + uint8_t bytesprops2[] = {0xd9, 0x34, 0x9b, 0xd8, 0x2e, 0xda, 0x80, 0x14, 0xdd, 0x42, 0x8f, 0xf, 0xf7, 0x31}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0xc0, 0xb0, 0xc2, 0x41, 0xdd, 0x79, 0xc2, 0xbb, 0xcf, + 0xc9, 0x22, 0x80, 0x0, 0x21, 0x3f, 0xa9, 0x4, 0x10}; + uint8_t bytesprops5[] = {0xcb}; + uint8_t bytesprops6[] = {0xc9, 0x7b, 0x48, 0xd2, 0x3f, 0xf1, 0x15, 0xcd}; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 149, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6984}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1948}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20851}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30485}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8118}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31011}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 61}}, + }; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 153, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoSubscriptionIdentifiersNotSupported [] +// DisconnectRequest DiscoConnectionRateExceeded [PropContentType +// "C\240\216I\207~(\SOH\214\251\236X\186\&1\167j2&r\v\\\183HX",PropPayloadFormatIndicator 3,PropResponseInformation +// "\153\ESC\187Ce\169J\SOH\175",PropRequestProblemInformation 237,PropReasonString +// "\198i\156\243\DC3\176t\231\251\210?\138oA\226\174\143\SUB\207\174\\",PropServerKeepAlive +// 14943,PropAuthenticationData +// "7\141\216\204\&0\222\151\131\211B\215\208g\245-\214\145\133\132\&5\205;\159s,*G\185",PropReceiveMaximum +// 24237,PropRequestResponseInformation 147,PropServerReference "\236\216u\221CD\140x\211",PropAssignedClientIdentifier +// "\190\171t/\STX",PropRequestResponseInformation 147,PropReceiveMaximum 10434,PropMessageExpiryInterval +// 26344,PropSubscriptionIdentifier 25,PropResponseInformation "5\166\USnWv\163\v^\204\169!",PropReceiveMaximum +// 18516,PropUserProperty "\b\141T\173\209\191\206h+.\194\227\174" "\199Z\ACK\""] TEST(Disco5QCTest, Encode13) { -uint8_t pkt[] = {0xe0, 0x2, 0xa1, 0x0}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - + uint8_t pkt[] = {0xe0, 0xb5, 0x1, 0x9f, 0xb2, 0x1, 0x3, 0x0, 0x18, 0x43, 0xf0, 0xd8, 0x49, 0xcf, 0x7e, 0x28, 0x1, + 0xd6, 0xfb, 0xec, 0x58, 0xba, 0x31, 0xa7, 0x6a, 0x32, 0x26, 0x72, 0xb, 0x5c, 0xb7, 0x48, 0x58, 0x1, + 0x3, 0x1a, 0x0, 0x9, 0x99, 0x1b, 0xbb, 0x43, 0x65, 0xa9, 0x4a, 0x1, 0xaf, 0x17, 0xed, 0x1f, 0x0, + 0x15, 0xc6, 0x69, 0x9c, 0xf3, 0x13, 0xb0, 0x74, 0xe7, 0xfb, 0xd2, 0x3f, 0x8a, 0x6f, 0x41, 0xe2, 0xae, + 0x8f, 0x1a, 0xcf, 0xae, 0x5c, 0x13, 0x3a, 0x5f, 0x16, 0x0, 0x1c, 0x37, 0x8d, 0xd8, 0xcc, 0x30, 0xde, + 0x97, 0x83, 0xd3, 0x42, 0xd7, 0xd0, 0x67, 0xf5, 0x2d, 0xd6, 0x91, 0x85, 0x84, 0x35, 0xcd, 0x3b, 0x9f, + 0x73, 0x2c, 0x2a, 0x47, 0xb9, 0x21, 0x5e, 0xad, 0x19, 0x93, 0x1c, 0x0, 0x9, 0xec, 0xd8, 0x75, 0xdd, + 0x43, 0x44, 0x8c, 0x78, 0xd3, 0x12, 0x0, 0x5, 0xbe, 0xab, 0x74, 0x2f, 0x2, 0x19, 0x93, 0x21, 0x28, + 0xc2, 0x2, 0x0, 0x0, 0x66, 0xe8, 0xb, 0x19, 0x1a, 0x0, 0xc, 0x35, 0xa6, 0x1f, 0x6e, 0x57, 0x76, + 0xa3, 0xb, 0x5e, 0xcc, 0xa9, 0x21, 0x21, 0x48, 0x54, 0x26, 0x0, 0xd, 0x8, 0x8d, 0x54, 0xad, 0xd1, + 0xbf, 0xce, 0x68, 0x2b, 0x2e, 0xc2, 0xe3, 0xae, 0x0, 0x4, 0xc7, 0x5a, 0x6, 0x22}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x43, 0xf0, 0xd8, 0x49, 0xcf, 0x7e, 0x28, 0x1, 0xd6, 0xfb, 0xec, 0x58, + 0xba, 0x31, 0xa7, 0x6a, 0x32, 0x26, 0x72, 0xb, 0x5c, 0xb7, 0x48, 0x58}; + uint8_t bytesprops1[] = {0x99, 0x1b, 0xbb, 0x43, 0x65, 0xa9, 0x4a, 0x1, 0xaf}; + uint8_t bytesprops2[] = {0xc6, 0x69, 0x9c, 0xf3, 0x13, 0xb0, 0x74, 0xe7, 0xfb, 0xd2, 0x3f, + 0x8a, 0x6f, 0x41, 0xe2, 0xae, 0x8f, 0x1a, 0xcf, 0xae, 0x5c}; + uint8_t bytesprops3[] = {0x37, 0x8d, 0xd8, 0xcc, 0x30, 0xde, 0x97, 0x83, 0xd3, 0x42, 0xd7, 0xd0, 0x67, 0xf5, + 0x2d, 0xd6, 0x91, 0x85, 0x84, 0x35, 0xcd, 0x3b, 0x9f, 0x73, 0x2c, 0x2a, 0x47, 0xb9}; + uint8_t bytesprops4[] = {0xec, 0xd8, 0x75, 0xdd, 0x43, 0x44, 0x8c, 0x78, 0xd3}; + uint8_t bytesprops5[] = {0xbe, 0xab, 0x74, 0x2f, 0x2}; + uint8_t bytesprops6[] = {0x35, 0xa6, 0x1f, 0x6e, 0x57, 0x76, 0xa3, 0xb, 0x5e, 0xcc, 0xa9, 0x21}; + uint8_t bytesprops8[] = {0xc7, 0x5a, 0x6, 0x22}; + uint8_t bytesprops7[] = {0x8, 0x8d, 0x54, 0xad, 0xd1, 0xbf, 0xce, 0x68, 0x2b, 0x2e, 0xc2, 0xe3, 0xae}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14943}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24237}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10434}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26344}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18516}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops7}, .v = {4, (char*)&bytesprops8}}}}, }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 161, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoTopicNameInvalid [] +// DisconnectRequest DiscoServerBusy [PropCorrelationData +// "\156c\234v\230\166\189^6\192\212\247\DELU\146",PropAuthenticationMethod "\128",PropSubscriptionIdentifierAvailable +// 136,PropRequestProblemInformation 9,PropContentType +// "ST6;|\147\194\r\152",PropCorrelationData +// "XQ\141\183i\193\CAN\220\187c\NUL",PropSubscriptionIdentifierAvailable 101,PropResponseInformation +// "&\173-H\175'\176YE\DC1\149\189\243\245%f \141a",PropMaximumQoS 8,PropRetainAvailable +// 83,PropReceiveMaximum 14438,PropSubscriptionIdentifier 7,PropRequestResponseInformation 70,PropMessageExpiryInterval +// 4714,PropSubscriptionIdentifier 16,PropSubscriptionIdentifier 21,PropAuthenticationData +// "csx/\172\f`\190\DC2\ACK\DLE\201\&6\169\168O\188",PropServerKeepAlive 15824,PropMessageExpiryInterval +// 8359,PropWillDelayInterval 26294,PropReceiveMaximum 15657,PropWillDelayInterval 3552,PropTopicAliasMaximum +// 19709,PropMessageExpiryInterval 31451,PropSubscriptionIdentifierAvailable 206,PropMessageExpiryInterval +// 30405,PropUserProperty "L&\216\DC33\DLE!Xa\236\SOQ\243\206G\USV21\179\ETB\246\ETX+w\239zm\SO" +// "\192\136",PropRetainAvailable 59,PropMessageExpiryInterval 26129] TEST(Disco5QCTest, Encode15) { -uint8_t pkt[] = {0xe0, 0x30, 0x83, 0x2e, 0x3, 0x0, 0x8, 0x31, 0xb2, 0x46, 0xad, 0xc4, 0xd, 0x84, 0x41, 0x18, 0x0, 0x0, 0x1a, 0xb5, 0x1c, 0x0, 0xa, 0x3c, 0x7c, 0x76, 0xe4, 0x43, 0x4c, 0xa9, 0x69, 0xed, 0xac, 0x23, 0x2c, 0xe5, 0x13, 0x4c, 0xb4, 0x12, 0x0, 0x5, 0x81, 0xb, 0x9d, 0xcd, 0xa3, 0x23, 0x9, 0xd4}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x31, 0xb2, 0x46, 0xad, 0xc4, 0xd, 0x84, 0x41}; - uint8_t bytesprops1[] = {0x3c, 0x7c, 0x76, 0xe4, 0x43, 0x4c, 0xa9, 0x69, 0xed, 0xac}; - uint8_t bytesprops2[] = {0x81, 0xb, 0x9d, 0xcd, 0xa3}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6837}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11493}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19636}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2516}}, - }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7a, + 0x6d, 0xe, 0x0, 0x2, 0xc0, 0x88, 0x25, 0x3b, 0x2, 0x0, 0x0, 0x66, 0x11}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb2, 0xfa, 0xc5, 0xd5, 0x3f, 0xf5, 0x59, 0x19, 0xe3, 0xa3, 0x8, 0xa, 0xc6, + 0x5b, 0xdf, 0x10, 0x71, 0xbd, 0xa6, 0x3e, 0x7c, 0x93, 0xc2, 0xd, 0x98}; + uint8_t bytesprops1[] = {0x58, 0x51, 0x8d, 0xb7, 0x69, 0xc1, 0x18, 0xdc, 0xbb, 0x63, 0x0}; + uint8_t bytesprops2[] = {0x26, 0xad, 0x2d, 0x48, 0x3c, 0x4a, 0x3b, 0xee, 0xf1, 0xa6, 0x3e, 0xaf, 0x27, + 0xb0, 0x59, 0x45, 0x11, 0x95, 0xbd, 0xf3, 0xf5, 0x25, 0x66, 0x20, 0x8d, 0x61}; + uint8_t bytesprops3[] = {0x63, 0x73, 0x78, 0x2f, 0xac, 0xc, 0x60, 0xbe, 0x12, + 0x6, 0x10, 0xc9, 0x36, 0xa9, 0xa8, 0x4f, 0xbc}; + uint8_t bytesprops5[] = {0xc0, 0x88}; + uint8_t bytesprops4[] = {0x4c, 0x26, 0xd8, 0x13, 0x33, 0x10, 0x21, 0x58, 0x61, 0xec, 0xe, 0x51, 0xf3, 0xce, 0x47, + 0x1f, 0x56, 0x32, 0x31, 0xb3, 0x17, 0xf6, 0x3, 0x2b, 0x77, 0xef, 0x7a, 0x6d, 0xe}; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 131, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14438}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4714}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15824}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8359}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26294}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15657}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3552}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19709}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31451}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30405}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26129}}, + }; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 139, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoDisconnectWithWill [PropUserProperty ",AK}%a\ESC1c\200\143\134\ESCnN\213\&3" "3\ETXcK\228\241\226\185\248g;\230\CANa\233\189KJ",PropRequestResponseInformation 51,PropCorrelationData "\213\175\164\189\170|",PropContentType "p\CANg\128",PropUserProperty "\171\217.\157`Tc\211\152c\207SmoTlG5Y" "\247p\221\SI\219",PropAuthenticationData "w\ETB\220]zk\212\157{\244\SO:Q-\222U'\218\250\197",PropMessageExpiryInterval 6020,PropSharedSubscriptionAvailable 8,PropContentType ")\250\234\RS\137\154",PropSharedSubscriptionAvailable 51,PropWildcardSubscriptionAvailable 176,PropAuthenticationData "Ot\EOT\222\223\&6\252\139\175\172j\131t`\139\NAK",PropResponseInformation "\"\246\152\142LU\142vr{\171\SUB\138{S\200\ENQ\144q\241 \vG\186",PropUserProperty "\128\ACK\152V\179\163\228x\ESC\160\230\EOT\195\&5\206.yXJf\226=85,lc" "\SO\131\DEL\215\SYN\213\166\183\248L.@7m\245\133\128r\197",PropContentType "\220\199|\NUL/\208.",PropCorrelationData "\f\235\245\219\201\129\152\204\145\148\US7\173\225f\207\r>\201q Q\238\213\247\195\DLE\213\"",PropTopicAliasMaximum 2107,PropCorrelationData "Q\171\138\205N\132\224\212\223\USF\DC2\177C\231\ETB\DLEF\163",PropSubscriptionIdentifier 1,PropServerKeepAlive 24248,PropRequestProblemInformation 138,PropAssignedClientIdentifier "\221\200\223\136\181\179X&i|\251\210\223)$x\US",PropContentType "\150\EM\130",PropRequestResponseInformation 41,PropMessageExpiryInterval 21178,PropContentType "\181\240}\139'\f"] +// DisconnectRequest DiscoConnectionRateExceeded [PropMaximumPacketSize 26235,PropWillDelayInterval +// 14753,PropServerKeepAlive 23091,PropCorrelationData "\221\220\197\146\147m\224l\189\137",PropServerKeepAlive +// 18977,PropRetainAvailable 40,PropAuthenticationData +// "\132H\t7\146\228\130\133\156\233\208\238\DC33\218\166T\250\193\185\225\217J\229\252q8\184",PropSubscriptionIdentifierAvailable +// 128,PropSharedSubscriptionAvailable 68,PropPayloadFormatIndicator 198,PropMessageExpiryInterval +// 30085,PropRequestProblemInformation 26,PropTopicAlias 9348,PropCorrelationData +// "k\189\172;\148\130:\194\253D8N'\225I",PropMaximumPacketSize 24904,PropSubscriptionIdentifierAvailable +// 201,PropContentType +// "\129\&2\182\229\200\SOHg]\161dbh\198\133\129/\202]\245\DC20\241\r\188>]",PropRequestResponseInformation +// 151,PropReasonString "\162\249\189\188",PropMessageExpiryInterval 16347,PropServerReference +// "\DC2\208\ESCC$,!|+\v\161\&9\221>\169\191\174\169Re\234\239\194\249 \162VSc\128",PropMaximumPacketSize +// 25464,PropAuthenticationMethod "?\198\243",PropSubscriptionIdentifierAvailable 147,PropServerReference +// "\233\DC3\237\143\167\190r\170o\230\SYN\241\251\ba",PropSessionExpiryInterval 20982,PropReceiveMaximum +// 21095,PropServerReference "\255E^kM:\238\148\US\SI\211\231\&9dM +// \227\244s\167\GS\146n\153\137\209\249",PropContentType "I\160\252\203f",PropAssignedClientIdentifier +// "\"'i\184f\v\194\157bJ\181\SOH"] TEST(Disco5QCTest, Encode16) { -uint8_t pkt[] = {0xe0, 0xda, 0x2, 0x4, 0xd7, 0x2, 0x26, 0x0, 0x11, 0x2c, 0x41, 0x4b, 0x7d, 0x25, 0x61, 0x1b, 0x31, 0x63, 0xc8, 0x8f, 0x86, 0x1b, 0x6e, 0x4e, 0xd5, 0x33, 0x0, 0x12, 0x33, 0x3, 0x63, 0x4b, 0xe4, 0xf1, 0xe2, 0xb9, 0xf8, 0x67, 0x3b, 0xe6, 0x18, 0x61, 0xe9, 0xbd, 0x4b, 0x4a, 0x19, 0x33, 0x9, 0x0, 0x6, 0xd5, 0xaf, 0xa4, 0xbd,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, 0x0, 0x1d, 0xc, 0xeb, 0xf5, 0xdb, 0xc9, 0x81, 0x98, 0xcc, 0x91, 0x94, 0x1f, 0x37, 0xad, 0xe1, 0x66, 0xcf, 0xd, 0x3e, 0xc9, 0x71, 0x20, 0x51, 0xee, 0xd5, 0xf7, 0xc3, 0x10, 0xd5, 0x22, 0x22, 0x8, 0x3b, 0x9, 0x0, 0x13, 0x51, 0xab, 0x8a, 0xcd, 0x4e, 0x84, 0xe0, 0xd4, 0xdf, 0x1f, 0x46, 0x12, 0xb1, 0x43, 0xe7, 0x17, 0x10, 0x46, 0xa3, 0xb, 0x1, 0x13, 0x5e, 0xb8, 0x17, 0x8a, 0x12, 0x0, 0x11, 0xdd, 0xc8, 0xdf, 0x88, 0xb5, 0xb3, 0x58, 0x26, 0x69, 0x7c, 0xfb, 0xd2, 0xdf, 0x29, 0x24, 0x78, 0x1f, 0x3, 0x0, 0x3, 0x96, 0x19, 0x82, 0x19, 0x29, 0x2, 0x0, 0x0, 0x52, 0xba, 0x3, 0x0, 0x6, 0xb5, 0xf0, 0x7d, 0x8b, 0x27, 0xc}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops1[] = {0x33, 0x3, 0x63, 0x4b, 0xe4, 0xf1, 0xe2, 0xb9, 0xf8, 0x67, 0x3b, 0xe6, 0x18, 0x61, 0xe9, 0xbd, 0x4b, 0x4a}; - uint8_t bytesprops0[] = {0x2c, 0x41, 0x4b, 0x7d, 0x25, 0x61, 0x1b, 0x31, 0x63, 0xc8, 0x8f, 0x86, 0x1b, 0x6e, 0x4e, 0xd5, 0x33}; - uint8_t bytesprops2[] = {0xd5, 0xaf, 0xa4, 0xbd, 0xaa, 0x7c}; - uint8_t bytesprops3[] = {0x70, 0x18, 0x67, 0x80}; - uint8_t bytesprops5[] = {0xf7, 0x70, 0xdd, 0xf, 0xdb}; - uint8_t bytesprops4[] = {0xab, 0xd9, 0x2e, 0x9d, 0x60, 0x54, 0x63, 0xd3, 0x98, 0x63, 0xcf, 0x53, 0x6d, 0x6f, 0x54, 0x6c, 0x47, 0x35, 0x59}; - uint8_t bytesprops6[] = {0x77, 0x17, 0xdc, 0x5d, 0x7a, 0x6b, 0xd4, 0x9d, 0x7b, 0xf4, 0xe, 0x3a, 0x51, 0x2d, 0xde, 0x55, 0x27, 0xda, 0xfa, 0xc5}; - uint8_t bytesprops7[] = {0x29, 0xfa, 0xea, 0x1e, 0x89, 0x9a}; - uint8_t bytesprops8[] = {0x4f, 0x74, 0x4, 0xde, 0xdf, 0x36, 0xfc, 0x8b, 0xaf, 0xac, 0x6a, 0x83, 0x74, 0x60, 0x8b, 0x15}; - uint8_t bytesprops9[] = {0x22, 0xf6, 0x98, 0x8e, 0x4c, 0x55, 0x8e, 0x76, 0x72, 0x7b, 0xab, 0x1a, 0x8a, 0x7b, 0x53, 0xc8, 0x5, 0x90, 0x71, 0xf1, 0x20, 0xb, 0x47, 0xba}; - uint8_t bytesprops11[] = {0xe, 0x83, 0x7f, 0xd7, 0x16, 0xd5, 0xa6, 0xb7, 0xf8, 0x4c, 0x2e, 0x40, 0x37, 0x6d, 0xf5, 0x85, 0x80, 0x72, 0xc5}; - uint8_t bytesprops10[] = {0x80, 0x6, 0x98, 0x56, 0xb3, 0xa3, 0xe4, 0x78, 0x1b, 0xa0, 0xe6, 0x4, 0xc3, 0x35, 0xce, 0x2e, 0x79, 0x58, 0x4a, 0x66, 0xe2, 0x3d, 0x38, 0x35, 0x2c, 0x6c, 0x63}; - uint8_t bytesprops12[] = {0xdc, 0xc7, 0x7c, 0x0, 0x2f, 0xd0, 0x2e}; - uint8_t bytesprops13[] = {0xc, 0xeb, 0xf5, 0xdb, 0xc9, 0x81, 0x98, 0xcc, 0x91, 0x94, 0x1f, 0x37, 0xad, 0xe1, 0x66, 0xcf, 0xd, 0x3e, 0xc9, 0x71, 0x20, 0x51, 0xee, 0xd5, 0xf7, 0xc3, 0x10, 0xd5, 0x22}; - uint8_t bytesprops14[] = {0x51, 0xab, 0x8a, 0xcd, 0x4e, 0x84, 0xe0, 0xd4, 0xdf, 0x1f, 0x46, 0x12, 0xb1, 0x43, 0xe7, 0x17, 0x10, 0x46, 0xa3}; - uint8_t bytesprops15[] = {0xdd, 0xc8, 0xdf, 0x88, 0xb5, 0xb3, 0x58, 0x26, 0x69, 0x7c, 0xfb, 0xd2, 0xdf, 0x29, 0x24, 0x78, 0x1f}; - uint8_t bytesprops16[] = {0x96, 0x19, 0x82}; - uint8_t bytesprops17[] = {0xb5, 0xf0, 0x7d, 0x8b, 0x27, 0xc}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={17, (char*)&bytesprops0}, .v={18, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={19, (char*)&bytesprops4}, .v={5, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6020}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={27, (char*)&bytesprops10}, .v={19, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2107}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24248}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops15}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops16}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21178}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops17}}}, - }; + uint8_t pkt[] = { + 0xe0, 0x92, 0x2, 0x9f, 0x8f, 0x2, 0x27, 0x0, 0x0, 0x66, 0x7b, 0x18, 0x0, 0x0, 0x39, 0xa1, 0x13, 0x5a, 0x33, + 0x9, 0x0, 0xa, 0xdd, 0xdc, 0xc5, 0x92, 0x93, 0x6d, 0xe0, 0x6c, 0xbd, 0x89, 0x13, 0x4a, 0x21, 0x25, 0x28, 0x16, + 0x0, 0x1c, 0x84, 0x48, 0x9, 0x37, 0x92, 0xe4, 0x82, 0x85, 0x9c, 0xe9, 0xd0, 0xee, 0x13, 0x33, 0xda, 0xa6, 0x54, + 0xfa, 0xc1, 0xb9, 0xe1, 0xd9, 0x4a, 0xe5, 0xfc, 0x71, 0x38, 0xb8, 0x29, 0x80, 0x2a, 0x44, 0x1, 0xc6, 0x2, 0x0, + 0x0, 0x75, 0x85, 0x17, 0x1a, 0x23, 0x24, 0x84, 0x9, 0x0, 0xf, 0x6b, 0xbd, 0xac, 0x3b, 0x94, 0x82, 0x3a, 0xc2, + 0xfd, 0x44, 0x38, 0x4e, 0x27, 0xe1, 0x49, 0x27, 0x0, 0x0, 0x61, 0x48, 0x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xbd, 0x89}; + uint8_t bytesprops1[] = {0x84, 0x48, 0x9, 0x37, 0x92, 0xe4, 0x82, 0x85, 0x9c, 0xe9, 0xd0, 0xee, 0x13, 0x33, + 0xda, 0xa6, 0x54, 0xfa, 0xc1, 0xb9, 0xe1, 0xd9, 0x4a, 0xe5, 0xfc, 0x71, 0x38, 0xb8}; + uint8_t bytesprops2[] = {0x6b, 0xbd, 0xac, 0x3b, 0x94, 0x82, 0x3a, 0xc2, 0xfd, 0x44, 0x38, 0x4e, 0x27, 0xe1, 0x49}; + uint8_t bytesprops3[] = {0x81, 0x32, 0xb6, 0xe5, 0xc8, 0x1, 0x67, 0x5d, 0xa1, 0x64, 0x62, 0x68, 0xc6, + 0x85, 0x81, 0x2f, 0xca, 0x5d, 0xf5, 0x12, 0x30, 0xf1, 0xd, 0xbc, 0x3e, 0x5d}; + uint8_t bytesprops4[] = {0xa2, 0xf9, 0xbd, 0xbc}; + uint8_t bytesprops5[] = {0x12, 0xd0, 0x1b, 0x43, 0x24, 0x2c, 0x21, 0x7c, 0x2b, 0xb, 0xa1, 0x39, 0xdd, 0x3e, 0xa9, + 0xbf, 0xae, 0xa9, 0x52, 0x65, 0xea, 0xef, 0xc2, 0xf9, 0x20, 0xa2, 0x56, 0x53, 0x63, 0x80}; + uint8_t bytesprops6[] = {0x3f, 0xc6, 0xf3}; + uint8_t bytesprops7[] = {0xe9, 0x13, 0xed, 0x8f, 0xa7, 0xbe, 0x72, 0xaa, 0x6f, 0xe6, 0x16, 0xf1, 0xfb, 0x8, 0x61}; + uint8_t bytesprops8[] = {0xff, 0x45, 0x5e, 0x6b, 0x4d, 0x3a, 0xee, 0x94, 0x1f, 0xf, 0xd3, 0xe7, 0x39, 0x64, + 0x4d, 0x20, 0xe3, 0xf4, 0x73, 0xa7, 0x1d, 0x92, 0x6e, 0x99, 0x89, 0xd1, 0xf9}; + uint8_t bytesprops9[] = {0x49, 0xa0, 0xfc, 0xcb, 0x66}; + uint8_t bytesprops10[] = {0x22, 0x27, 0x69, 0xb8, 0x66, 0xb, 0xc2, 0x9d, 0x62, 0x4a, 0xb5, 0x1}; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26235}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14753}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23091}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18977}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30085}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9348}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24904}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16347}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25464}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20982}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21095}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops10}}}, + }; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoKeepAliveTimeout [PropSubscriptionIdentifier 12,PropMaximumPacketSize 27576,PropAuthenticationMethod "r\213\205@*(~\169\246\157(\204a\FSu\232\181",PropAuthenticationMethod "\232\150\a",PropResponseTopic "<921^\207",PropWillDelayInterval 8261,PropWillDelayInterval 20923,PropContentType " \CAN\162\SYN\SOH\NUL\214<\216\218b\NUL#\NUL\STXV\237\EOT",PropMessageExpiryInterval 9198,PropTopicAliasMaximum 5712,PropMessageExpiryInterval 4543,PropResponseInformation "\143\232\CAN\187\155\210gD?",PropMaximumPacketSize 20356,PropRequestResponseInformation 250,PropMaximumQoS 33,PropSessionExpiryInterval 26369,PropUserProperty "3n\227\245\163|\199R\SI\232\199\165\239\161S\141CGR\US\"\170\204\187" "h\238]\187/\157\179",PropAuthenticationMethod "\203\DC4\136\144\202\ETXV\241y\190\DC3Ug5\170\205W\255\151U;\155R",PropAuthenticationData "1\164\129\147Y\183\&0O\146\169\STX\185X\188\219=b\237\249=\129\253",PropPayloadFormatIndicator 54,PropResponseInformation "Y\226\153.\192+\129y\234\CAN\226\188\246\230",PropServerKeepAlive 27270] +// DisconnectRequest DiscoConnectionRateExceeded [PropAssignedClientIdentifier "",PropRequestProblemInformation +// 58,PropWillDelayInterval 26540,PropSessionExpiryInterval 10965,PropUserProperty +// "\243\&2QIy!8\EOT\f\ETX\204g\241}@\133\134o\US\FS\231_kx\248" "d\EOT\"0T\238\236",PropContentType +// "\ETX\211\NUL\181\DC47\131}",PropMessageExpiryInterval 24904,PropPayloadFormatIndicator 169,PropMessageExpiryInterval +// 23817,PropAssignedClientIdentifier "\176\ENQ\222VC\188,\164\NAK\DEL\169Gq\182",PropResponseTopic +// "\165\NAK\DC1y_53\211\t\254c\175\213M\NUL&y\b\236V^\246\225\141g\ESC>\173\130",PropPayloadFormatIndicator +// 183,PropSharedSubscriptionAvailable 115,PropWillDelayInterval 25597,PropServerKeepAlive +// 17658,PropSubscriptionIdentifier 2,PropMessageExpiryInterval 14628,PropSessionExpiryInterval 26147] TEST(Disco5QCTest, Encode17) { -uint8_t pkt[] = {0xe0, 0xe0, 0x1, 0x8d, 0xdd, 0x1, 0xb, 0xc, 0x27, 0x0, 0x0, 0x6b, 0xb8, 0x15, 0x0, 0x11, 0x72, 0xd5, 0xcd, 0x40, 0x2a, 0x28, 0x7e, 0xa9, 0xf6, 0x9d, 0x28, 0xcc, 0x61, 0x1c, 0x75, 0xe8, 0xb5, 0x15, 0x0, 0x3, 0xe8, 0x96, 0x7, 0x8, 0x0, 0x6, 0x3c, 0x39, 0x32, 0x31, 0x5e, 0xcf, 0x18, 0x0, 0x0, 0x20, 0x45, 0x18, 0x0, 0x0, 0x51, 0xbb, 0x3, 0x0, 0x12, 0x20, 0x18, 0xa2, 0x16, 0x1, 0x0, 0xd6, 0x3c, 0xd8, 0xda, 0x62, 0x0, 0x23, 0x0, 0x2, 0x56, 0xed, 0x4, 0x2, 0x0, 0x0, 0x23, 0xee, 0x22, 0x16, 0x50, 0x2, 0x0, 0x0, 0x11, 0xbf, 0x1a, 0x0, 0x9, 0x8f, 0xe8, 0x18, 0xbb, 0x9b, 0xd2, 0x67, 0x44, 0x3f, 0x27, 0x0, 0x0, 0x4f, 0x84, 0x19, 0xfa, 0x24, 0x21, 0x11, 0x0, 0x0, 0x67, 0x1, 0x26, 0x0, 0x18, 0x33, 0x6e, 0xe3, 0xf5, 0xa3, 0x7c, 0xc7, 0x52, 0xf, 0xe8, 0xc7, 0xa5, 0xef, 0xa1, 0x53, 0x8d, 0x43, 0x47, 0x52, 0x1f, 0x22, 0xaa, 0xcc, 0xbb, 0x0, 0x7, 0x68, 0xee, 0x5d, 0xbb, 0x2f, 0x9d, 0xb3, 0x15, 0x0, 0x17, 0xcb, 0x14, 0x88, 0x90, 0xca, 0x3, 0x56, 0xf1, 0x79, 0xbe, 0x13, 0x55, 0x67, 0x35, 0xaa, 0xcd, 0x57, 0xff, 0x97, 0x55, 0x3b, 0x9b, 0x52, 0x16, 0x0, 0x16, 0x31, 0xa4, 0x81, 0x93, 0x59, 0xb7, 0x30, 0x4f, 0x92, 0xa9, 0x2, 0xb9, 0x58, 0xbc, 0xdb, 0x3d, 0x62, 0xed, 0xf9, 0x3d, 0x81, 0xfd, 0x1, 0x36, 0x1a, 0x0, 0xe, 0x59, 0xe2, 0x99, 0x2e, 0xc0, 0x2b, 0x81, 0x79, 0xea, 0x18, 0xe2, 0xbc, 0xf6, 0xe6, 0x13, 0x6a, 0x86}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x72, 0xd5, 0xcd, 0x40, 0x2a, 0x28, 0x7e, 0xa9, 0xf6, 0x9d, 0x28, 0xcc, 0x61, 0x1c, 0x75, 0xe8, 0xb5}; - uint8_t bytesprops1[] = {0xe8, 0x96, 0x7}; - uint8_t bytesprops2[] = {0x3c, 0x39, 0x32, 0x31, 0x5e, 0xcf}; - uint8_t bytesprops3[] = {0x20, 0x18, 0xa2, 0x16, 0x1, 0x0, 0xd6, 0x3c, 0xd8, 0xda, 0x62, 0x0, 0x23, 0x0, 0x2, 0x56, 0xed, 0x4}; - uint8_t bytesprops4[] = {0x8f, 0xe8, 0x18, 0xbb, 0x9b, 0xd2, 0x67, 0x44, 0x3f}; - uint8_t bytesprops6[] = {0x68, 0xee, 0x5d, 0xbb, 0x2f, 0x9d, 0xb3}; - uint8_t bytesprops5[] = {0x33, 0x6e, 0xe3, 0xf5, 0xa3, 0x7c, 0xc7, 0x52, 0xf, 0xe8, 0xc7, 0xa5, 0xef, 0xa1, 0x53, 0x8d, 0x43, 0x47, 0x52, 0x1f, 0x22, 0xaa, 0xcc, 0xbb}; - uint8_t bytesprops7[] = {0xcb, 0x14, 0x88, 0x90, 0xca, 0x3, 0x56, 0xf1, 0x79, 0xbe, 0x13, 0x55, 0x67, 0x35, 0xaa, 0xcd, 0x57, 0xff, 0x97, 0x55, 0x3b, 0x9b, 0x52}; - uint8_t bytesprops8[] = {0x31, 0xa4, 0x81, 0x93, 0x59, 0xb7, 0x30, 0x4f, 0x92, 0xa9, 0x2, 0xb9, 0x58, 0xbc, 0xdb, 0x3d, 0x62, 0xed, 0xf9, 0x3d, 0x81, 0xfd}; - uint8_t bytesprops9[] = {0x59, 0xe2, 0x99, 0x2e, 0xc0, 0x2b, 0x81, 0x79, 0xea, 0x18, 0xe2, 0xbc, 0xf6, 0xe6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27576}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8261}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20923}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9198}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5712}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4543}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20356}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26369}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={24, (char*)&bytesprops5}, .v={7, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27270}}, - }; + uint8_t pkt[] = {0xe0, 0x97, 0x1, 0x9f, 0x94, 0x1, 0x12, 0x0, 0x0, 0x17, 0x3a, 0x18, 0x0, 0x0, 0x67, 0xac, + 0x11, 0x0, 0x0, 0x2a, 0xd5, 0x26, 0x0, 0x19, 0xf3, 0x32, 0x51, 0x49, 0x79, 0x21, 0x38, 0x4, + 0xc, 0x3, 0xcc, 0x67, 0xf1, 0x7d, 0x40, 0x85, 0x86, 0x6f, 0x1f, 0x1c, 0xe7, 0x5f, 0x6b, 0x78, + 0xf8, 0x0, 0x7, 0x64, 0x4, 0x22, 0x30, 0x54, 0xee, 0xec, 0x3, 0x0, 0x8, 0x3, 0xd3, 0x0, + 0xb5, 0x14, 0x37, 0x83, 0x7d, 0x2, 0x0, 0x0, 0x61, 0x48, 0x1, 0xa9, 0x2, 0x0, 0x0, 0x5d, + 0x9, 0x12, 0x0, 0xe, 0xb0, 0x5, 0xde, 0x56, 0x43, 0xbc, 0x2c, 0xa4, 0x15, 0x7f, 0xa9, 0x47, + 0x71, 0xb6, 0x8, 0x0, 0x1d, 0xa5, 0x15, 0x11, 0x79, 0x5f, 0x35, 0x33, 0xd3, 0x9, 0xfe, 0x63, + 0xaf, 0xd5, 0x4d, 0x0, 0x26, 0x79, 0x8, 0xec, 0x56, 0x5e, 0xf6, 0xe1, 0x8d, 0x67, 0x1b, 0x3e, + 0xad, 0x82, 0x1, 0xb7, 0x2a, 0x73, 0x18, 0x0, 0x0, 0x63, 0xfd, 0x13, 0x44, 0xfa, 0xb, 0x2, + 0x2, 0x0, 0x0, 0x39, 0x24, 0x11, 0x0, 0x0, 0x66, 0x23}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops2[] = {0x64, 0x4, 0x22, 0x30, 0x54, 0xee, 0xec}; + uint8_t bytesprops1[] = {0xf3, 0x32, 0x51, 0x49, 0x79, 0x21, 0x38, 0x4, 0xc, 0x3, 0xcc, 0x67, 0xf1, + 0x7d, 0x40, 0x85, 0x86, 0x6f, 0x1f, 0x1c, 0xe7, 0x5f, 0x6b, 0x78, 0xf8}; + uint8_t bytesprops3[] = {0x3, 0xd3, 0x0, 0xb5, 0x14, 0x37, 0x83, 0x7d}; + uint8_t bytesprops4[] = {0xb0, 0x5, 0xde, 0x56, 0x43, 0xbc, 0x2c, 0xa4, 0x15, 0x7f, 0xa9, 0x47, 0x71, 0xb6}; + uint8_t bytesprops5[] = {0xa5, 0x15, 0x11, 0x79, 0x5f, 0x35, 0x33, 0xd3, 0x9, 0xfe, 0x63, 0xaf, 0xd5, 0x4d, 0x0, + 0x26, 0x79, 0x8, 0xec, 0x56, 0x5e, 0xf6, 0xe1, 0x8d, 0x67, 0x1b, 0x3e, 0xad, 0x82}; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 141, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26540}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10965}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops1}, .v = {7, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24904}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23817}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25597}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17658}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14628}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26147}}, + }; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoPayloadFormatInvalid [PropServerReference "\175\212N\225\&9\US0\230\184\130c'\236",PropReceiveMaximum 29122,PropSharedSubscriptionAvailable 74,PropPayloadFormatIndicator 231,PropMessageExpiryInterval 10411] +// DisconnectRequest DiscoReceiveMaximumExceeded [PropTopicAliasMaximum 7621,PropSubscriptionIdentifierAvailable +// 53,PropReceiveMaximum 8235,PropServerReference "\208-:Qp\231\239N\134\171/qe",PropReasonString +// "<\ENQ\164^k\164\DLEMH\237]3Z\196\158\177\201\ETX$\130\171g\204",PropWillDelayInterval +// 19719,PropSharedSubscriptionAvailable 115,PropAssignedClientIdentifier +// "\169{(\NAK\225\219\r-\157\169\240Xa\144\145\229\217",PropMaximumQoS 235,PropRetainAvailable +// 74,PropAuthenticationData "\152K",PropResponseInformation +// "w\149\151\221\147\238X\v\NUL\142<\DEL\178\t\130\nz\134\227N5",PropAuthenticationData +// "\180\199\128\217c\144\&8\227\&3\136\180\ENQ\FSFG\236\135\143p\139\SOH\128",PropSubscriptionIdentifier +// 24,PropTopicAliasMaximum 3541,PropPayloadFormatIndicator 8,PropSessionExpiryInterval 26303,PropAuthenticationMethod +// ",\230=\151\248\199z\191-$\223\239\154\154\193\196\177\157\153\181I\209\230\132<",PropSessionExpiryInterval +// 2383,PropSessionExpiryInterval 30622,PropRetainAvailable 28,PropSessionExpiryInterval 73,PropCorrelationData +// "\171\218\201\177ZS 5\133\STX\207\181d\\Cx\249\169\183\NAK}h\198\FSpH",PropMaximumQoS +// 135,PropAssignedClientIdentifier "\204~{",PropAuthenticationMethod "Yb",PropAuthenticationMethod +// "E\165\228\205\244\208h\210\129F\128\209\162\157c\219\US\153\149\237\255\137}\170\162t,"] TEST(Disco5QCTest, Encode18) { -uint8_t pkt[] = {0xe0, 0x1e, 0x99, 0x1c, 0x1c, 0x0, 0xd, 0xaf, 0xd4, 0x4e, 0xe1, 0x39, 0x1f, 0x30, 0xe6, 0xb8, 0x82, 0x63, 0x27, 0xec, 0x21, 0x71, 0xc2, 0x2a, 0x4a, 0x1, 0xe7, 0x2, 0x0, 0x0, 0x28, 0xab}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xaf, 0xd4, 0x4e, 0xe1, 0x39, 0x1f, 0x30, 0xe6, 0xb8, 0x82, 0x63, 0x27, 0xec}; - + uint8_t pkt[] = {0xe0, 0x8b, 0x2, 0x93, 0x88, 0x2, 0x22, 0x1d, 0xc5, 0x29, 0x35, 0x21, 0x20, 0x2b, 0x1c, 0x0, 0xd, + 0xd0, 0x2d, 0x3a, 0x51, 0x70, 0xe7, 0xef, 0x4e, 0x86, 0xab, 0x2f, 0x71, 0x65, 0x1f, 0x0, 0x17, 0x3c, + 0x5, 0xa4, 0x5e, 0x6b, 0xa4, 0x10, 0x4d, 0x48, 0xed, 0x5d, 0x33, 0x5a, 0xc4, 0x9e, 0xb1, 0xc9, 0x3, + 0x24, 0x82, 0xab, 0x67, 0xcc, 0x18, 0x0, 0x0, 0x4d, 0x7, 0x2a, 0x73, 0x12, 0x0, 0x11, 0xa9, 0x7b, + 0x28, 0x15, 0xe1, 0xdb, 0xd, 0x2d, 0x9d, 0xa9, 0xf0, 0x58, 0x61, 0x90, 0x91, 0xe5, 0xd9, 0x24, 0xeb, + 0x25, 0x4a, 0x16, 0x0, 0x2, 0x98, 0x4b, 0x1a, 0x0, 0x15, 0x77, 0x95, 0x97, 0xdd, 0x93, 0xee, 0x58, + 0xb, 0x0, 0x8e, 0x3c, 0x7f, 0xb2, 0x9, 0x82, 0xa, 0x7a, 0x86, 0xe3, 0x4e, 0x35, 0x16, 0x0, 0x16, + 0xb4, 0xc7, 0x80, 0xd9, 0x63, 0x90, 0x38, 0xe3, 0x33, 0x88, 0xb4, 0x5, 0x1c, 0x46, 0x47, 0xec, 0x87, + 0x8f, 0x70, 0x8b, 0x1, 0x80, 0xb, 0x18, 0x22, 0xd, 0xd5, 0x1, 0x8, 0x11, 0x0, 0x0, 0x66, 0xbf, + 0x15, 0x0, 0x19, 0x2c, 0xe6, 0x3d, 0x97, 0xf8, 0xc7, 0x7a, 0xbf, 0x2d, 0x24, 0xdf, 0xef, 0x9a, 0x9a, + 0xc1, 0xc4, 0xb1, 0x9d, 0x99, 0xb5, 0x49, 0xd1, 0xe6, 0x84, 0x3c, 0x11, 0x0, 0x0, 0x9, 0x4f, 0x11, + 0x0, 0x0, 0x77, 0x9e, 0x25, 0x1c, 0x11, 0x0, 0x0, 0x0, 0x49, 0x9, 0x0, 0x1a, 0xab, 0xda, 0xc9, + 0xb1, 0x5a, 0x53, 0x20, 0x35, 0x85, 0x2, 0xcf, 0xb5, 0x64, 0x5c, 0x43, 0x78, 0xf9, 0xa9, 0xb7, 0x15, + 0x7d, 0x68, 0xc6, 0x1c, 0x70, 0x48, 0x24, 0x87, 0x12, 0x0, 0x3, 0xcc, 0x7e, 0x7b, 0x15, 0x0, 0x2, + 0x59, 0x62, 0x15, 0x0, 0x1b, 0x45, 0xa5, 0xe4, 0xcd, 0xf4, 0xd0, 0x68, 0xd2, 0x81, 0x46, 0x80, 0xd1, + 0xa2, 0x9d, 0x63, 0xdb, 0x1f, 0x99, 0x95, 0xed, 0xff, 0x89, 0x7d, 0xaa, 0xa2, 0x74, 0x2c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xd0, 0x2d, 0x3a, 0x51, 0x70, 0xe7, 0xef, 0x4e, 0x86, 0xab, 0x2f, 0x71, 0x65}; + uint8_t bytesprops1[] = {0x3c, 0x5, 0xa4, 0x5e, 0x6b, 0xa4, 0x10, 0x4d, 0x48, 0xed, 0x5d, 0x33, + 0x5a, 0xc4, 0x9e, 0xb1, 0xc9, 0x3, 0x24, 0x82, 0xab, 0x67, 0xcc}; + uint8_t bytesprops2[] = {0xa9, 0x7b, 0x28, 0x15, 0xe1, 0xdb, 0xd, 0x2d, 0x9d, + 0xa9, 0xf0, 0x58, 0x61, 0x90, 0x91, 0xe5, 0xd9}; + uint8_t bytesprops3[] = {0x98, 0x4b}; + uint8_t bytesprops4[] = {0x77, 0x95, 0x97, 0xdd, 0x93, 0xee, 0x58, 0xb, 0x0, 0x8e, 0x3c, + 0x7f, 0xb2, 0x9, 0x82, 0xa, 0x7a, 0x86, 0xe3, 0x4e, 0x35}; + uint8_t bytesprops5[] = {0xb4, 0xc7, 0x80, 0xd9, 0x63, 0x90, 0x38, 0xe3, 0x33, 0x88, 0xb4, + 0x5, 0x1c, 0x46, 0x47, 0xec, 0x87, 0x8f, 0x70, 0x8b, 0x1, 0x80}; + uint8_t bytesprops6[] = {0x2c, 0xe6, 0x3d, 0x97, 0xf8, 0xc7, 0x7a, 0xbf, 0x2d, 0x24, 0xdf, 0xef, 0x9a, + 0x9a, 0xc1, 0xc4, 0xb1, 0x9d, 0x99, 0xb5, 0x49, 0xd1, 0xe6, 0x84, 0x3c}; + uint8_t bytesprops7[] = {0xab, 0xda, 0xc9, 0xb1, 0x5a, 0x53, 0x20, 0x35, 0x85, 0x2, 0xcf, 0xb5, 0x64, + 0x5c, 0x43, 0x78, 0xf9, 0xa9, 0xb7, 0x15, 0x7d, 0x68, 0xc6, 0x1c, 0x70, 0x48}; + uint8_t bytesprops8[] = {0xcc, 0x7e, 0x7b}; + uint8_t bytesprops9[] = {0x59, 0x62}; + uint8_t bytesprops10[] = {0x45, 0xa5, 0xe4, 0xcd, 0xf4, 0xd0, 0x68, 0xd2, 0x81, 0x46, 0x80, 0xd1, 0xa2, 0x9d, + 0x63, 0xdb, 0x1f, 0x99, 0x95, 0xed, 0xff, 0x89, 0x7d, 0xaa, 0xa2, 0x74, 0x2c}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29122}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10411}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7621}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8235}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19719}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3541}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26303}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2383}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30622}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 73}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 153, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 147, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoWildcardSubscriptionsNotSupported [PropRequestProblemInformation 181,PropAuthenticationData "@\ESC\171\213\ENQ\246\&2V\162\238",PropResponseInformation "\129\224i\141\250\208\177",PropWillDelayInterval 13537,PropResponseTopic "\240,\217\SOr\139\147T\a\\\166\135\248\128xe\DC1_\vc\239\165C[\207\246\&6\225\230",PropMaximumQoS 197,PropRequestResponseInformation 14,PropAssignedClientIdentifier ")'\r\233\252\DC4\172\253\232\216\156\188e\NAK/\DC1\152\\\192W.",PropServerReference "\DC4y\207KL",PropMessageExpiryInterval 21283] +// DisconnectRequest DiscoDisconnectWithWill [PropAuthenticationData +// "@\ACK\248%\233\FSHv\216",PropAssignedClientIdentifier +// "$\SUB\226\129\156hO\148j\179\180w\159\161\230Mw6\156S\198\f",PropContentType +// "|\b\136#\SYN\131\179\168\&8\167\201\157]\179\142%-\a\150\132\132",PropResponseTopic +// "%\253",PropRequestProblemInformation 226,PropSubscriptionIdentifier 10,PropRetainAvailable 101,PropServerKeepAlive +// 4043,PropRequestProblemInformation 24,PropRetainAvailable 35,PropContentType +// "\DC3\159\128\255\v'\194\225\152\ESC",PropRetainAvailable 166] TEST(Disco5QCTest, Encode19) { -uint8_t pkt[] = {0xe0, 0x69, 0xa2, 0x67, 0x17, 0xb5, 0x16, 0x0, 0xa, 0x40, 0x1b, 0xab, 0xd5, 0x5, 0xf6, 0x32, 0x56, 0xa2, 0xee, 0x1a, 0x0, 0x7, 0x81, 0xe0, 0x69, 0x8d, 0xfa, 0xd0, 0xb1, 0x18, 0x0, 0x0, 0x34, 0xe1, 0x8, 0x0, 0x1d, 0xf0, 0x2c, 0xd9, 0xe, 0x72, 0x8b, 0x93, 0x54, 0x7, 0x5c, 0xa6, 0x87, 0xf8, 0x80, 0x78, 0x65, 0x11, 0x5f, 0xb, 0x63, 0xef, 0xa5, 0x43, 0x5b, 0xcf, 0xf6, 0x36, 0xe1, 0xe6, 0x24, 0xc5, 0x19, 0xe, 0x12, 0x0, 0x15, 0x29, 0x27, 0xd, 0xe9, 0xfc, 0x14, 0xac, 0xfd, 0xe8, 0xd8, 0x9c, 0xbc, 0x65, 0x15, 0x2f, 0x11, 0x98, 0x5c, 0xc0, 0x57, 0x2e, 0x1c, 0x0, 0x5, 0x14, 0x79, 0xcf, 0x4b, 0x4c, 0x2, 0x0, 0x0, 0x53, 0x23}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x40, 0x1b, 0xab, 0xd5, 0x5, 0xf6, 0x32, 0x56, 0xa2, 0xee}; - uint8_t bytesprops1[] = {0x81, 0xe0, 0x69, 0x8d, 0xfa, 0xd0, 0xb1}; - uint8_t bytesprops2[] = {0xf0, 0x2c, 0xd9, 0xe, 0x72, 0x8b, 0x93, 0x54, 0x7, 0x5c, 0xa6, 0x87, 0xf8, 0x80, 0x78, 0x65, 0x11, 0x5f, 0xb, 0x63, 0xef, 0xa5, 0x43, 0x5b, 0xcf, 0xf6, 0x36, 0xe1, 0xe6}; - uint8_t bytesprops3[] = {0x29, 0x27, 0xd, 0xe9, 0xfc, 0x14, 0xac, 0xfd, 0xe8, 0xd8, 0x9c, 0xbc, 0x65, 0x15, 0x2f, 0x11, 0x98, 0x5c, 0xc0, 0x57, 0x2e}; - uint8_t bytesprops4[] = {0x14, 0x79, 0xcf, 0x4b, 0x4c}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13537}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21283}}, - }; + uint8_t pkt[] = {0xe0, 0x60, 0x4, 0x5e, 0x16, 0x0, 0x9, 0x40, 0x6, 0xf8, 0x25, 0xe9, 0x1c, 0x48, 0x76, 0xd8, 0x12, + 0x0, 0x16, 0x24, 0x1a, 0xe2, 0x81, 0x9c, 0x68, 0x4f, 0x94, 0x6a, 0xb3, 0xb4, 0x77, 0x9f, 0xa1, 0xe6, + 0x4d, 0x77, 0x36, 0x9c, 0x53, 0xc6, 0xc, 0x3, 0x0, 0x15, 0x7c, 0x8, 0x88, 0x23, 0x16, 0x83, 0xb3, + 0xa8, 0x38, 0xa7, 0xc9, 0x9d, 0x5d, 0xb3, 0x8e, 0x25, 0x2d, 0x7, 0x96, 0x84, 0x84, 0x8, 0x0, 0x2, + 0x25, 0xfd, 0x17, 0xe2, 0xb, 0xa, 0x25, 0x65, 0x13, 0xf, 0xcb, 0x17, 0x18, 0x25, 0x23, 0x3, 0x0, + 0xa, 0x13, 0x9f, 0x80, 0xff, 0xb, 0x27, 0xc2, 0xe1, 0x98, 0x1b, 0x25, 0xa6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x40, 0x6, 0xf8, 0x25, 0xe9, 0x1c, 0x48, 0x76, 0xd8}; + uint8_t bytesprops1[] = {0x24, 0x1a, 0xe2, 0x81, 0x9c, 0x68, 0x4f, 0x94, 0x6a, 0xb3, 0xb4, + 0x77, 0x9f, 0xa1, 0xe6, 0x4d, 0x77, 0x36, 0x9c, 0x53, 0xc6, 0xc}; + uint8_t bytesprops2[] = {0x7c, 0x8, 0x88, 0x23, 0x16, 0x83, 0xb3, 0xa8, 0x38, 0xa7, 0xc9, + 0x9d, 0x5d, 0xb3, 0x8e, 0x25, 0x2d, 0x7, 0x96, 0x84, 0x84}; + uint8_t bytesprops3[] = {0x25, 0xfd}; + uint8_t bytesprops4[] = {0x13, 0x9f, 0x80, 0xff, 0xb, 0x27, 0xc2, 0xe1, 0x98, 0x1b}; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 162, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4043}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 166}}, + }; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoRetainNotSupported [PropRequestResponseInformation 43,PropMaximumPacketSize 26732,PropSessionExpiryInterval 11092,PropAuthenticationData ". 6\253\225\231\250\150F\177n"] +// DisconnectRequest DiscoMaximumConnectTime [PropPayloadFormatIndicator 64,PropRetainAvailable 191,PropTopicAlias +// 20889,PropServerReference "6Kc4;*}\238\DC3\179\ETXT",PropServerKeepAlive 29920,PropReceiveMaximum +// 10201,PropWillDelayInterval 658,PropWillDelayInterval 28824,PropUserProperty "\230\132\149.\219" +// "\n\204\n\154\&3\GS\132\ENQ6",PropServerKeepAlive 7761,PropTopicAliasMaximum 13346,PropSubscriptionIdentifier +// 14,PropRequestProblemInformation 179,PropTopicAliasMaximum 26363,PropSessionExpiryInterval 12423,PropReasonString +// "pT6D\r@\153\162\184\138w+\233\&6\172\206\DC4]\129\&5\164\GS\208\179\187P\207\231"] TEST(Disco5QCTest, Encode20) { -uint8_t pkt[] = {0xe0, 0x1c, 0x9a, 0x1a, 0x19, 0x2b, 0x27, 0x0, 0x0, 0x68, 0x6c, 0x11, 0x0, 0x0, 0x2b, 0x54, 0x16, 0x0, 0xb, 0x2e, 0x20, 0x36, 0xfd, 0xe1, 0xe7, 0xfa, 0x96, 0x46, 0xb1, 0x6e}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x2e, 0x20, 0x36, 0xfd, 0xe1, 0xe7, 0xfa, 0x96, 0x46, 0xb1, 0x6e}; - + uint8_t pkt[] = {0xe0, 0x6c, 0xa0, 0x6a, 0x1, 0x40, 0x25, 0xbf, 0x23, 0x51, 0x99, 0x1c, 0x0, 0xc, 0x36, 0x4b, + 0x63, 0x34, 0x3b, 0x2a, 0x7d, 0xee, 0x13, 0xb3, 0x3, 0x54, 0x13, 0x74, 0xe0, 0x21, 0x27, 0xd9, + 0x18, 0x0, 0x0, 0x2, 0x92, 0x18, 0x0, 0x0, 0x70, 0x98, 0x26, 0x0, 0x5, 0xe6, 0x84, 0x95, + 0x2e, 0xdb, 0x0, 0x9, 0xa, 0xcc, 0xa, 0x9a, 0x33, 0x1d, 0x84, 0x5, 0x36, 0x13, 0x1e, 0x51, + 0x22, 0x34, 0x22, 0xb, 0xe, 0x17, 0xb3, 0x22, 0x66, 0xfb, 0x11, 0x0, 0x0, 0x30, 0x87, 0x1f, + 0x0, 0x1c, 0x70, 0x54, 0x36, 0x44, 0xd, 0x40, 0x99, 0xa2, 0xb8, 0x8a, 0x77, 0x2b, 0xe9, 0x36, + 0xac, 0xce, 0x14, 0x5d, 0x81, 0x35, 0xa4, 0x1d, 0xd0, 0xb3, 0xbb, 0x50, 0xcf, 0xe7}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x36, 0x4b, 0x63, 0x34, 0x3b, 0x2a, 0x7d, 0xee, 0x13, 0xb3, 0x3, 0x54}; + uint8_t bytesprops2[] = {0xa, 0xcc, 0xa, 0x9a, 0x33, 0x1d, 0x84, 0x5, 0x36}; + uint8_t bytesprops1[] = {0xe6, 0x84, 0x95, 0x2e, 0xdb}; + uint8_t bytesprops3[] = {0x70, 0x54, 0x36, 0x44, 0xd, 0x40, 0x99, 0xa2, 0xb8, 0x8a, 0x77, 0x2b, 0xe9, 0x36, + 0xac, 0xce, 0x14, 0x5d, 0x81, 0x35, 0xa4, 0x1d, 0xd0, 0xb3, 0xbb, 0x50, 0xcf, 0xe7}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26732}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11092}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20889}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29920}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10201}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 658}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28824}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops1}, .v = {9, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7761}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13346}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26363}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12423}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 154, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 160, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoDisconnectWithWill [PropServerReference "\166G\177\198e\DC2\DLEr|\231=k\"\217\170\180\164\237\230\214\SYNd\218W\DC2\208",PropRequestProblemInformation 143,PropSubscriptionIdentifier 22,PropMaximumQoS 108] +// DisconnectRequest DiscoNotAuthorized [PropServerReference +// "\143\194@H\238\228\a\135\194>\200;\143\128\144M\ETX",PropReceiveMaximum 9209,PropServerReference +// "\254\155pu\225",PropMaximumQoS 188,PropServerReference "j\ENQ",PropSharedSubscriptionAvailable +// 103,PropSharedSubscriptionAvailable 206,PropTopicAlias 31456,PropResponseTopic +// "\205\&7b\203kH\224g\RSi\183\"\178\250\188\t",PropContentType "\186\&8\131\210d\"\163\196\133\162l\178p\131 +// \249\&7\n3\187\248\138\233\199\"\CAN\233\204\146",PropContentType "}\216",PropAuthenticationMethod +// "\191\SO",PropMessageExpiryInterval 25961,PropRetainAvailable 53] TEST(Disco5QCTest, Encode21) { -uint8_t pkt[] = {0xe0, 0x25, 0x4, 0x23, 0x1c, 0x0, 0x1a, 0xa6, 0x47, 0xb1, 0xc6, 0x65, 0x12, 0x10, 0x72, 0x7c, 0xe7, 0x3d, 0x6b, 0x22, 0xd9, 0xaa, 0xb4, 0xa4, 0xed, 0xe6, 0xd6, 0x16, 0x64, 0xda, 0x57, 0x12, 0xd0, 0x17, 0x8f, 0xb, 0x16, 0x24, 0x6c}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xa6, 0x47, 0xb1, 0xc6, 0x65, 0x12, 0x10, 0x72, 0x7c, 0xe7, 0x3d, 0x6b, 0x22, 0xd9, 0xaa, 0xb4, 0xa4, 0xed, 0xe6, 0xd6, 0x16, 0x64, 0xda, 0x57, 0x12, 0xd0}; - + uint8_t pkt[] = {0xe0, 0x73, 0x87, 0x71, 0x1c, 0x0, 0x11, 0x8f, 0xc2, 0x40, 0x48, 0xee, 0xe4, 0x7, 0x87, 0xc2, 0x3e, + 0xc8, 0x3b, 0x8f, 0x80, 0x90, 0x4d, 0x3, 0x21, 0x23, 0xf9, 0x1c, 0x0, 0x5, 0xfe, 0x9b, 0x70, 0x75, + 0xe1, 0x24, 0xbc, 0x1c, 0x0, 0x2, 0x6a, 0x5, 0x2a, 0x67, 0x2a, 0xce, 0x23, 0x7a, 0xe0, 0x8, 0x0, + 0x10, 0xcd, 0x37, 0x62, 0xcb, 0x6b, 0x48, 0xe0, 0x67, 0x1e, 0x69, 0xb7, 0x22, 0xb2, 0xfa, 0xbc, 0x9, + 0x3, 0x0, 0x1d, 0xba, 0x38, 0x83, 0xd2, 0x64, 0x22, 0xa3, 0xc4, 0x85, 0xa2, 0x6c, 0xb2, 0x70, 0x83, + 0x20, 0xf9, 0x37, 0xa, 0x33, 0xbb, 0xf8, 0x8a, 0xe9, 0xc7, 0x22, 0x18, 0xe9, 0xcc, 0x92, 0x3, 0x0, + 0x2, 0x7d, 0xd8, 0x15, 0x0, 0x2, 0xbf, 0xe, 0x2, 0x0, 0x0, 0x65, 0x69, 0x25, 0x35}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x8f, 0xc2, 0x40, 0x48, 0xee, 0xe4, 0x7, 0x87, 0xc2, + 0x3e, 0xc8, 0x3b, 0x8f, 0x80, 0x90, 0x4d, 0x3}; + uint8_t bytesprops1[] = {0xfe, 0x9b, 0x70, 0x75, 0xe1}; + uint8_t bytesprops2[] = {0x6a, 0x5}; + uint8_t bytesprops3[] = {0xcd, 0x37, 0x62, 0xcb, 0x6b, 0x48, 0xe0, 0x67, + 0x1e, 0x69, 0xb7, 0x22, 0xb2, 0xfa, 0xbc, 0x9}; + uint8_t bytesprops4[] = {0xba, 0x38, 0x83, 0xd2, 0x64, 0x22, 0xa3, 0xc4, 0x85, 0xa2, 0x6c, 0xb2, 0x70, 0x83, 0x20, + 0xf9, 0x37, 0xa, 0x33, 0xbb, 0xf8, 0x8a, 0xe9, 0xc7, 0x22, 0x18, 0xe9, 0xcc, 0x92}; + uint8_t bytesprops5[] = {0x7d, 0xd8}; + uint8_t bytesprops6[] = {0xbf, 0xe}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9209}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31456}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25961}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 53}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 135, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoTopicNameInvalid [PropCorrelationData "9\GSX\227\194\168\FS\191\201\219\133\236g",PropUserProperty "\243" "]\238hX\198\183\132\224?\167/\181=yZ{z\178",PropAuthenticationMethod "/\142\aU1\\\186}>V\189`Ap^W%\229[",PropWildcardSubscriptionAvailable 160,PropResponseTopic "(\188\130#",PropReasonString "\150_Z0ef",PropSubscriptionIdentifierAvailable 53,PropReceiveMaximum 12034,PropServerKeepAlive 2916,PropSessionExpiryInterval 10487,PropWillDelayInterval 13840,PropSubscriptionIdentifier 3,PropWildcardSubscriptionAvailable 35,PropReasonString ";H\170\254e=\164\v\213\165\148\134,\226\179uB",PropResponseTopic "5.\184\ETX\194\211\&3\DC3F\133\200\184\222\153\166\207J",PropServerKeepAlive 27368,PropSessionExpiryInterval 10893,PropTopicAliasMaximum 6988] +// DisconnectRequest DiscoImplementationSpecificError [PropAuthenticationMethod +// "cr,\ACK\bC/\227\NAK\152\228\176\144\192t\v\"\246\130`_",PropMaximumPacketSize 14029,PropSessionExpiryInterval +// 12586,PropRequestResponseInformation 115,PropMaximumPacketSize 6061,PropServerReference +// "$\ACK\138\&0\208\247l\180\253~u\132\ESC\STX\ETBD\r\ETBc\DC3\180\149\140\164\129\183\134\140",PropResponseInformation +// "t",PropSubscriptionIdentifier 17,PropServerKeepAlive 20492,PropTopicAliasMaximum 14027,PropCorrelationData +// "\169\&8\135\SOH\aKzAK~E}\182\236\RS\161\208J8\155Y\202\136\v\196\230\240\ETB",PropServerReference +// "\163\229\183,\196\208\244\188q\166U\ETXh\EM",PropCorrelationData +// "\158\DC4\187\223\140\135oV\t7F\SOH/G\202\177\146\216iMA\ENQ\230\148"] TEST(Disco5QCTest, Encode22) { -uint8_t pkt[] = {0xe0, 0x9c, 0x1, 0x90, 0x99, 0x1, 0x9, 0x0, 0xd, 0x39, 0x1d, 0x58, 0xe3, 0xc2, 0xa8, 0x1c, 0xbf, 0xc9, 0xdb, 0x85, 0xec, 0x67, 0x26, 0x0, 0x1, 0xf3, 0x0, 0x12, 0x5d, 0xee, 0x68, 0x58, 0xc6, 0xb7, 0x84, 0xe0, 0x3f, 0xa7, 0x2f, 0xb5, 0x3d, 0x79, 0x5a, 0x7b, 0x7a, 0xb2, 0x15, 0x0, 0x13, 0x2f, 0x8e, 0x7, 0x55, 0x31, 0x5c, 0xba, 0x7d, 0x3e, 0x56, 0xbd, 0x60, 0x41, 0x70, 0x5e, 0x57, 0x25, 0xe5, 0x5b, 0x28, 0xa0, 0x8, 0x0, 0x4, 0x28, 0xbc, 0x82, 0x23, 0x1f, 0x0, 0x6, 0x96, 0x5f, 0x5a, 0x30, 0x65, 0x66, 0x29, 0x35, 0x21, 0x2f, 0x2, 0x13, 0xb, 0x64, 0x11, 0x0, 0x0, 0x28, 0xf7, 0x18, 0x0, 0x0, 0x36, 0x10, 0xb, 0x3, 0x28, 0x23, 0x1f, 0x0, 0x11, 0x3b, 0x48, 0xaa, 0xfe, 0x65, 0x3d, 0xa4, 0xb, 0xd5, 0xa5, 0x94, 0x86, 0x2c, 0xe2, 0xb3, 0x75, 0x42, 0x8, 0x0, 0x11, 0x35, 0x2e, 0xb8, 0x3, 0xc2, 0xd3, 0x33, 0x13, 0x46, 0x85, 0xc8, 0xb8, 0xde, 0x99, 0xa6, 0xcf, 0x4a, 0x13, 0x6a, 0xe8, 0x11, 0x0, 0x0, 0x2a, 0x8d, 0x22, 0x1b, 0x4c}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x39, 0x1d, 0x58, 0xe3, 0xc2, 0xa8, 0x1c, 0xbf, 0xc9, 0xdb, 0x85, 0xec, 0x67}; - uint8_t bytesprops2[] = {0x5d, 0xee, 0x68, 0x58, 0xc6, 0xb7, 0x84, 0xe0, 0x3f, 0xa7, 0x2f, 0xb5, 0x3d, 0x79, 0x5a, 0x7b, 0x7a, 0xb2}; - uint8_t bytesprops1[] = {0xf3}; - uint8_t bytesprops3[] = {0x2f, 0x8e, 0x7, 0x55, 0x31, 0x5c, 0xba, 0x7d, 0x3e, 0x56, 0xbd, 0x60, 0x41, 0x70, 0x5e, 0x57, 0x25, 0xe5, 0x5b}; - uint8_t bytesprops4[] = {0x28, 0xbc, 0x82, 0x23}; - uint8_t bytesprops5[] = {0x96, 0x5f, 0x5a, 0x30, 0x65, 0x66}; - uint8_t bytesprops6[] = {0x3b, 0x48, 0xaa, 0xfe, 0x65, 0x3d, 0xa4, 0xb, 0xd5, 0xa5, 0x94, 0x86, 0x2c, 0xe2, 0xb3, 0x75, 0x42}; - uint8_t bytesprops7[] = {0x35, 0x2e, 0xb8, 0x3, 0xc2, 0xd3, 0x33, 0x13, 0x46, 0x85, 0xc8, 0xb8, 0xde, 0x99, 0xa6, 0xcf, 0x4a}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={1, (char*)&bytesprops1}, .v={18, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12034}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2916}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10487}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13840}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27368}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10893}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6988}}, - }; - - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + uint8_t pkt[] = {0xe0, 0xa2, 0x1, 0x83, 0x9f, 0x1, 0x15, 0x0, 0x15, 0x63, 0x72, 0x2c, 0x6, 0x8, 0x43, 0x2f, 0xe3, + 0x15, 0x98, 0xe4, 0xb0, 0x90, 0xc0, 0x74, 0xb, 0x22, 0xf6, 0x82, 0x60, 0x5f, 0x27, 0x0, 0x0, 0x36, + 0xcd, 0x11, 0x0, 0x0, 0x31, 0x2a, 0x19, 0x73, 0x27, 0x0, 0x0, 0x17, 0xad, 0x1c, 0x0, 0x1c, 0x24, + 0x6, 0x8a, 0x30, 0xd0, 0xf7, 0x6c, 0xb4, 0xfd, 0x7e, 0x75, 0x84, 0x1b, 0x2, 0x17, 0x44, 0xd, 0x17, + 0x63, 0x13, 0xb4, 0x95, 0x8c, 0xa4, 0x81, 0xb7, 0x86, 0x8c, 0x1a, 0x0, 0x1, 0x74, 0xb, 0x11, 0x13, + 0x50, 0xc, 0x22, 0x36, 0xcb, 0x9, 0x0, 0x1c, 0xa9, 0x38, 0x87, 0x1, 0x7, 0x4b, 0x7a, 0x41, 0x4b, + 0x7e, 0x45, 0x7d, 0xb6, 0xec, 0x1e, 0xa1, 0xd0, 0x4a, 0x38, 0x9b, 0x59, 0xca, 0x88, 0xb, 0xc4, 0xe6, + 0xf0, 0x17, 0x1c, 0x0, 0xe, 0xa3, 0xe5, 0xb7, 0x2c, 0xc4, 0xd0, 0xf4, 0xbc, 0x71, 0xa6, 0x55, 0x3, + 0x68, 0x19, 0x9, 0x0, 0x18, 0x9e, 0x14, 0xbb, 0xdf, 0x8c, 0x87, 0x6f, 0x56, 0x9, 0x37, 0x46, 0x1, + 0x2f, 0x47, 0xca, 0xb1, 0x92, 0xd8, 0x69, 0x4d, 0x41, 0x5, 0xe6, 0x94}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x63, 0x72, 0x2c, 0x6, 0x8, 0x43, 0x2f, 0xe3, 0x15, 0x98, 0xe4, + 0xb0, 0x90, 0xc0, 0x74, 0xb, 0x22, 0xf6, 0x82, 0x60, 0x5f}; + uint8_t bytesprops1[] = {0x24, 0x6, 0x8a, 0x30, 0xd0, 0xf7, 0x6c, 0xb4, 0xfd, 0x7e, 0x75, 0x84, 0x1b, 0x2, + 0x17, 0x44, 0xd, 0x17, 0x63, 0x13, 0xb4, 0x95, 0x8c, 0xa4, 0x81, 0xb7, 0x86, 0x8c}; + uint8_t bytesprops2[] = {0x74}; + uint8_t bytesprops3[] = {0xa9, 0x38, 0x87, 0x1, 0x7, 0x4b, 0x7a, 0x41, 0x4b, 0x7e, 0x45, 0x7d, 0xb6, 0xec, + 0x1e, 0xa1, 0xd0, 0x4a, 0x38, 0x9b, 0x59, 0xca, 0x88, 0xb, 0xc4, 0xe6, 0xf0, 0x17}; + uint8_t bytesprops4[] = {0xa3, 0xe5, 0xb7, 0x2c, 0xc4, 0xd0, 0xf4, 0xbc, 0x71, 0xa6, 0x55, 0x3, 0x68, 0x19}; + uint8_t bytesprops5[] = {0x9e, 0x14, 0xbb, 0xdf, 0x8c, 0x87, 0x6f, 0x56, 0x9, 0x37, 0x46, 0x1, + 0x2f, 0x47, 0xca, 0xb1, 0x92, 0xd8, 0x69, 0x4d, 0x41, 0x5, 0xe6, 0x94}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14029}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12586}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6061}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20492}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14027}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops5}}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 131, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoDisconnectWithWill [PropMessageExpiryInterval 31906,PropServerKeepAlive 11688,PropAuthenticationData "\219\215\SI\228Z\ETX\158&\241Om\234)\US\230{=e\189M",PropMaximumQoS 32,PropUserProperty "3\ENQ*\175\DC1c\251\DLE\210f\197\206\199\CAN\237\ACKFx\215" "]\137\&4\EM\232[\243}N^\253S\142\239\238\t8\213-!\129",PropAuthenticationMethod "\204\169\222\&4C\229\EOT\177\143\241\196Od\176,At\199\167\134\206\254\253o\147\143N\232"] +// DisconnectRequest DiscoTopicNameInvalid [PropTopicAliasMaximum 26497,PropRetainAvailable 72,PropReceiveMaximum +// 481,PropServerReference "",PropReceiveMaximum 1240,PropSubscriptionIdentifierAvailable 54,PropTopicAliasMaximum +// 14770,PropMessageExpiryInterval 24223,PropUserProperty "Y\244\136I\175\250\238\"u\223a\155" +// "\SOF\134\STX\181\&2\174\243\244\&3\192m\149\215F\144[\214\SYN\NAK\253\151\167\140\225-\DEL\rG\149",PropResponseTopic +// "\180U\fQ\144\&2\254\142\179\DC42N\128m\ESC\206\157=@\213%\253#",PropSubscriptionIdentifier 20,PropReasonString +// "^\215\146\207!2r\GS\156[M\236\247G<-)5C\150",PropReasonString "\129%z",PropRetainAvailable 39,PropTopicAliasMaximum +// 7771] TEST(Disco5QCTest, Encode23) { -uint8_t pkt[] = {0xe0, 0x6f, 0x4, 0x6d, 0x2, 0x0, 0x0, 0x7c, 0xa2, 0x13, 0x2d, 0xa8, 0x16, 0x0, 0x14, 0xdb, 0xd7, 0xf, 0xe4, 0x5a, 0x3, 0x9e, 0x26, 0xf1, 0x4f, 0x6d, 0xea, 0x29, 0x1f, 0xe6, 0x7b, 0x3d, 0x65, 0xbd, 0x4d, 0x24, 0x20, 0x26, 0x0, 0x13, 0x33, 0x5, 0x2a, 0xaf, 0x11, 0x63, 0xfb, 0x10, 0xd2, 0x66, 0xc5, 0xce, 0xc7, 0x18, 0xed, 0x6, 0x46, 0x78, 0xd7, 0x0, 0x15, 0x5d, 0x89, 0x34, 0x19, 0xe8, 0x5b, 0xf3, 0x7d, 0x4e, 0x5e, 0xfd, 0x53, 0x8e, 0xef, 0xee, 0x9, 0x38, 0xd5, 0x2d, 0x21, 0x81, 0x15, 0x0, 0x1c, 0xcc, 0xa9, 0xde, 0x34, 0x43, 0xe5, 0x4, 0xb1, 0x8f, 0xf1, 0xc4, 0x4f, 0x64, 0xb0, 0x2c, 0x41, 0x74, 0xc7, 0xa7, 0x86, 0xce, 0xfe, 0xfd, 0x6f, 0x93, 0x8f, 0x4e, 0xe8}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0xdb, 0xd7, 0xf, 0xe4, 0x5a, 0x3, 0x9e, 0x26, 0xf1, 0x4f, 0x6d, 0xea, 0x29, 0x1f, 0xe6, 0x7b, 0x3d, 0x65, 0xbd, 0x4d}; - uint8_t bytesprops2[] = {0x5d, 0x89, 0x34, 0x19, 0xe8, 0x5b, 0xf3, 0x7d, 0x4e, 0x5e, 0xfd, 0x53, 0x8e, 0xef, 0xee, 0x9, 0x38, 0xd5, 0x2d, 0x21, 0x81}; - uint8_t bytesprops1[] = {0x33, 0x5, 0x2a, 0xaf, 0x11, 0x63, 0xfb, 0x10, 0xd2, 0x66, 0xc5, 0xce, 0xc7, 0x18, 0xed, 0x6, 0x46, 0x78, 0xd7}; - uint8_t bytesprops3[] = {0xcc, 0xa9, 0xde, 0x34, 0x43, 0xe5, 0x4, 0xb1, 0x8f, 0xf1, 0xc4, 0x4f, 0x64, 0xb0, 0x2c, 0x41, 0x74, 0xc7, 0xa7, 0x86, 0xce, 0xfe, 0xfd, 0x6f, 0x93, 0x8f, 0x4e, 0xe8}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31906}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11688}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={19, (char*)&bytesprops1}, .v={21, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops3}}}, - }; + uint8_t pkt[] = {0xe0, 0x88, 0x1, 0x90, 0x85, 0x1, 0x22, 0x67, 0x81, 0x25, 0x48, 0x21, 0x1, 0xe1, 0x1c, 0x0, + 0x0, 0x21, 0x4, 0xd8, 0x29, 0x36, 0x22, 0x39, 0xb2, 0x2, 0x0, 0x0, 0x5e, 0x9f, 0x26, 0x0, + 0xc, 0x59, 0xf4, 0x88, 0x49, 0xaf, 0xfa, 0xee, 0x22, 0x75, 0xdf, 0x61, 0x9b, 0x0, 0x1e, 0xe, + 0x46, 0x86, 0x2, 0xb5, 0x32, 0xae, 0xf3, 0xf4, 0x33, 0xc0, 0x6d, 0x95, 0xd7, 0x46, 0x90, 0x5b, + 0xd6, 0x16, 0x15, 0xfd, 0x97, 0xa7, 0x8c, 0xe1, 0x2d, 0x7f, 0xd, 0x47, 0x95, 0x8, 0x0, 0x17, + 0xb4, 0x55, 0xc, 0x51, 0x90, 0x32, 0xfe, 0x8e, 0xb3, 0x14, 0x32, 0x4e, 0x80, 0x6d, 0x1b, 0xce, + 0x9d, 0x3d, 0x40, 0xd5, 0x25, 0xfd, 0x23, 0xb, 0x14, 0x1f, 0x0, 0x14, 0x5e, 0xd7, 0x92, 0xcf, + 0x21, 0x32, 0x72, 0x1d, 0x9c, 0x5b, 0x4d, 0xec, 0xf7, 0x47, 0x3c, 0x2d, 0x29, 0x35, 0x43, 0x96, + 0x1f, 0x0, 0x3, 0x81, 0x25, 0x7a, 0x25, 0x27, 0x22, 0x1e, 0x5b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops2[] = {0xe, 0x46, 0x86, 0x2, 0xb5, 0x32, 0xae, 0xf3, 0xf4, 0x33, 0xc0, 0x6d, 0x95, 0xd7, 0x46, + 0x90, 0x5b, 0xd6, 0x16, 0x15, 0xfd, 0x97, 0xa7, 0x8c, 0xe1, 0x2d, 0x7f, 0xd, 0x47, 0x95}; + uint8_t bytesprops1[] = {0x59, 0xf4, 0x88, 0x49, 0xaf, 0xfa, 0xee, 0x22, 0x75, 0xdf, 0x61, 0x9b}; + uint8_t bytesprops3[] = {0xb4, 0x55, 0xc, 0x51, 0x90, 0x32, 0xfe, 0x8e, 0xb3, 0x14, 0x32, 0x4e, + 0x80, 0x6d, 0x1b, 0xce, 0x9d, 0x3d, 0x40, 0xd5, 0x25, 0xfd, 0x23}; + uint8_t bytesprops4[] = {0x5e, 0xd7, 0x92, 0xcf, 0x21, 0x32, 0x72, 0x1d, 0x9c, 0x5b, + 0x4d, 0xec, 0xf7, 0x47, 0x3c, 0x2d, 0x29, 0x35, 0x43, 0x96}; + uint8_t bytesprops5[] = {0x81, 0x25, 0x7a}; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26497}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 481}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1240}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14770}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24223}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7771}}, + }; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoWildcardSubscriptionsNotSupported [PropResponseInformation "H\162?|+\SUB}\US\t\180k=\208",PropTopicAlias 30601,PropSubscriptionIdentifier 13,PropUserProperty "\205\129\SYN\199k^\192F\234\153L\136\193\131@d\FS\247^\132" "\131\NUL\135\233\133\212\237\230h",PropAssignedClientIdentifier "\253\235\248\160W\232\204\201\EM\NAK\170\200\205Kd\b\160\224\244E\204\t@a\225\217\ESC\157\186|",PropMessageExpiryInterval 9535,PropContentType "\r\252\178\GS\ESC\164/\191m\150d\255Q",PropRequestResponseInformation 253,PropTopicAlias 1395,PropMaximumPacketSize 9375,PropContentType "\231\"\181&<",PropTopicAliasMaximum 17101,PropRetainAvailable 52,PropRetainAvailable 122,PropMaximumQoS 55,PropRequestResponseInformation 156,PropWildcardSubscriptionAvailable 248,PropMessageExpiryInterval 25630,PropSessionExpiryInterval 676,PropAuthenticationMethod "`\226",PropSubscriptionIdentifierAvailable 77,PropWildcardSubscriptionAvailable 115,PropAuthenticationData "\182\143\250\253vR\150F\226\137J\150\191\198\EM\248\216\NUL?>"] +// DisconnectRequest DiscoMessageRateTooHigh [PropServerKeepAlive 1529,PropMaximumPacketSize 22315,PropResponseTopic +// "\183L~\163\132\149#\132\245\b@\SOH\t&\180R\171b]\GSB1",PropResponseTopic +// "\250\153\199\236|\176(|\208\143Re\NAK\246*\129#\231g\225t\187\169\236U",PropRequestProblemInformation +// 142,PropAssignedClientIdentifier "i\250\194l0+\144Z\SI\ETX\175\251W\177\149\218-\155\162x.\222\171\146W.X/\250"] TEST(Disco5QCTest, Encode24) { -uint8_t pkt[] = {0xe0, 0xb9, 0x1, 0xa2, 0xb6, 0x1, 0x1a, 0x0, 0xd, 0x48, 0xa2, 0x3f, 0x7c, 0x2b, 0x1a, 0x7d, 0x1f, 0x9, 0xb4, 0x6b, 0x3d, 0xd0, 0x23, 0x77, 0x89, 0xb, 0xd, 0x26, 0x0, 0x14, 0xcd, 0x81, 0x16, 0xc7, 0x6b, 0x5e, 0xc0, 0x46, 0xea, 0x99, 0x4c, 0x88, 0xc1, 0x83, 0x40, 0x64, 0x1c, 0xf7, 0x5e, 0x84, 0x0, 0x9, 0x83, 0x0, 0x87, 0xe9, 0x85, 0xd4, 0xed, 0xe6, 0x68, 0x12, 0x0, 0x1e, 0xfd, 0xeb, 0xf8, 0xa0, 0x57, 0xe8, 0xcc, 0xc9, 0x19, 0x15, 0xaa, 0xc8, 0xcd, 0x4b, 0x64, 0x8, 0xa0, 0xe0, 0xf4, 0x45, 0xcc, 0x9, 0x40, 0x61, 0xe1, 0xd9, 0x1b, 0x9d, 0xba, 0x7c, 0x2, 0x0, 0x0, 0x25, 0x3f, 0x3, 0x0, 0xd, 0xd, 0xfc, 0xb2, 0x1d, 0x1b, 0xa4, 0x2f, 0xbf, 0x6d, 0x96, 0x64, 0xff, 0x51, 0x19, 0xfd, 0x23, 0x5, 0x73, 0x27, 0x0, 0x0, 0x24, 0x9f, 0x3, 0x0, 0x5, 0xe7, 0x22, 0xb5, 0x26, 0x3c, 0x22, 0x42, 0xcd, 0x25, 0x34, 0x25, 0x7a, 0x24, 0x37, 0x19, 0x9c, 0x28, 0xf8, 0x2, 0x0, 0x0, 0x64, 0x1e, 0x11, 0x0, 0x0, 0x2, 0xa4, 0x15, 0x0, 0x2, 0x60, 0xe2, 0x29, 0x4d, 0x28, 0x73, 0x16, 0x0, 0x14, 0xb6, 0x8f, 0xfa, 0xfd, 0x76, 0x52, 0x96, 0x46, 0xe2, 0x89, 0x4a, 0x96, 0xbf, 0xc6, 0x19, 0xf8, 0xd8, 0x0, 0x3f, 0x3e}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x48, 0xa2, 0x3f, 0x7c, 0x2b, 0x1a, 0x7d, 0x1f, 0x9, 0xb4, 0x6b, 0x3d, 0xd0}; - uint8_t bytesprops2[] = {0x83, 0x0, 0x87, 0xe9, 0x85, 0xd4, 0xed, 0xe6, 0x68}; - uint8_t bytesprops1[] = {0xcd, 0x81, 0x16, 0xc7, 0x6b, 0x5e, 0xc0, 0x46, 0xea, 0x99, 0x4c, 0x88, 0xc1, 0x83, 0x40, 0x64, 0x1c, 0xf7, 0x5e, 0x84}; - uint8_t bytesprops3[] = {0xfd, 0xeb, 0xf8, 0xa0, 0x57, 0xe8, 0xcc, 0xc9, 0x19, 0x15, 0xaa, 0xc8, 0xcd, 0x4b, 0x64, 0x8, 0xa0, 0xe0, 0xf4, 0x45, 0xcc, 0x9, 0x40, 0x61, 0xe1, 0xd9, 0x1b, 0x9d, 0xba, 0x7c}; - uint8_t bytesprops4[] = {0xd, 0xfc, 0xb2, 0x1d, 0x1b, 0xa4, 0x2f, 0xbf, 0x6d, 0x96, 0x64, 0xff, 0x51}; - uint8_t bytesprops5[] = {0xe7, 0x22, 0xb5, 0x26, 0x3c}; - uint8_t bytesprops6[] = {0x60, 0xe2}; - uint8_t bytesprops7[] = {0xb6, 0x8f, 0xfa, 0xfd, 0x76, 0x52, 0x96, 0x46, 0xe2, 0x89, 0x4a, 0x96, 0xbf, 0xc6, 0x19, 0xf8, 0xd8, 0x0, 0x3f, 0x3e}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30601}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={20, (char*)&bytesprops1}, .v={9, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9535}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1395}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9375}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17101}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25630}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 676}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops7}}}, - }; + uint8_t pkt[] = {0xe0, 0x61, 0x96, 0x5f, 0x13, 0x5, 0xf9, 0x27, 0x0, 0x0, 0x57, 0x2b, 0x8, 0x0, 0x16, 0xb7, 0x4c, + 0x7e, 0xa3, 0x84, 0x95, 0x23, 0x84, 0xf5, 0x8, 0x40, 0x1, 0x9, 0x26, 0xb4, 0x52, 0xab, 0x62, 0x5d, + 0x1d, 0x42, 0x31, 0x8, 0x0, 0x19, 0xfa, 0x99, 0xc7, 0xec, 0x7c, 0xb0, 0x28, 0x7c, 0xd0, 0x8f, 0x52, + 0x65, 0x15, 0xf6, 0x2a, 0x81, 0x23, 0xe7, 0x67, 0xe1, 0x74, 0xbb, 0xa9, 0xec, 0x55, 0x17, 0x8e, 0x12, + 0x0, 0x1d, 0x69, 0xfa, 0xc2, 0x6c, 0x30, 0x2b, 0x90, 0x5a, 0xf, 0x3, 0xaf, 0xfb, 0x57, 0xb1, 0x95, + 0xda, 0x2d, 0x9b, 0xa2, 0x78, 0x2e, 0xde, 0xab, 0x92, 0x57, 0x2e, 0x58, 0x2f, 0xfa}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb7, 0x4c, 0x7e, 0xa3, 0x84, 0x95, 0x23, 0x84, 0xf5, 0x8, 0x40, + 0x1, 0x9, 0x26, 0xb4, 0x52, 0xab, 0x62, 0x5d, 0x1d, 0x42, 0x31}; + uint8_t bytesprops1[] = {0xfa, 0x99, 0xc7, 0xec, 0x7c, 0xb0, 0x28, 0x7c, 0xd0, 0x8f, 0x52, 0x65, 0x15, + 0xf6, 0x2a, 0x81, 0x23, 0xe7, 0x67, 0xe1, 0x74, 0xbb, 0xa9, 0xec, 0x55}; + uint8_t bytesprops2[] = {0x69, 0xfa, 0xc2, 0x6c, 0x30, 0x2b, 0x90, 0x5a, 0xf, 0x3, 0xaf, 0xfb, 0x57, 0xb1, 0x95, + 0xda, 0x2d, 0x9b, 0xa2, 0x78, 0x2e, 0xde, 0xab, 0x92, 0x57, 0x2e, 0x58, 0x2f, 0xfa}; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 162, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1529}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22315}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops2}}}, + }; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 150, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoSessiontakenOver [PropRequestProblemInformation 147,PropMessageExpiryInterval 9332,PropRequestResponseInformation 40,PropResponseInformation "p@d\ESCG.\GS\ENQYk\146",PropSubscriptionIdentifierAvailable 113,PropMessageExpiryInterval 27708,PropServerKeepAlive 21312,PropAuthenticationMethod "\135][)\217\DC4\240\v@\146\210\SO|\ETB\196\148\SI\v&eot\168\173\149\230\247",PropSessionExpiryInterval 18569,PropRequestResponseInformation 98,PropResponseTopic "D\157\149n\nd@\206\195_ZW\162\186\SUB\205\ETX\228\DC1\225\r-\214",PropRequestProblemInformation 73,PropWildcardSubscriptionAvailable 141,PropAssignedClientIdentifier "\194d?Y\181\ESC\194u\DEL\149\215\&3g&Q\SI\v\134\189\167b\134\DLE\214",PropReceiveMaximum 12656,PropRequestProblemInformation 62,PropResponseInformation "\170\232\143G\220\241",PropTopicAlias 28685] +// DisconnectRequest DiscoKeepAliveTimeout [PropMaximumQoS 246,PropServerKeepAlive +// 5558,PropSubscriptionIdentifierAvailable 253,PropAssignedClientIdentifier "V\SO\r\UScP\148\162"] TEST(Disco5QCTest, Encode25) { -uint8_t pkt[] = {0xe0, 0x93, 0x1, 0x8e, 0x90, 0x1, 0x17, 0x93, 0x2, 0x0, 0x0, 0x24, 0x74, 0x19, 0x28, 0x1a, 0x0, 0xb, 0x70, 0x40, 0x64, 0x1b, 0x47, 0x2e, 0x1d, 0x5, 0x59, 0x6b, 0x92, 0x29, 0x71, 0x2, 0x0, 0x0, 0x6c, 0x3c, 0x13, 0x53, 0x40, 0x15, 0x0, 0x1b, 0x87, 0x5d, 0x5b, 0x29, 0xd9, 0x14, 0xf0, 0xb, 0x40, 0x92, 0xd2, 0xe, 0x7c, 0x17, 0xc4, 0x94, 0xf, 0xb, 0x26, 0x65, 0x6f, 0x74, 0xa8, 0xad, 0x95, 0xe6, 0xf7, 0x11, 0x0, 0x0, 0x48, 0x89, 0x19, 0x62, 0x8, 0x0, 0x17, 0x44, 0x9d, 0x95, 0x6e, 0xa, 0x64, 0x40, 0xce, 0xc3, 0x5f, 0x5a, 0x57, 0xa2, 0xba, 0x1a, 0xcd, 0x3, 0xe4, 0x11, 0xe1, 0xd, 0x2d, 0xd6, 0x17, 0x49, 0x28, 0x8d, 0x12, 0x0, 0x18, 0xc2, 0x64, 0x3f, 0x59, 0xb5, 0x1b, 0xc2, 0x75, 0x7f, 0x95, 0xd7, 0x33, 0x67, 0x26, 0x51, 0xf, 0xb, 0x86, 0xbd, 0xa7, 0x62, 0x86, 0x10, 0xd6, 0x21, 0x31, 0x70, 0x17, 0x3e, 0x1a, 0x0, 0x6, 0xaa, 0xe8, 0x8f, 0x47, 0xdc, 0xf1, 0x23, 0x70, 0xd}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x70, 0x40, 0x64, 0x1b, 0x47, 0x2e, 0x1d, 0x5, 0x59, 0x6b, 0x92}; - uint8_t bytesprops1[] = {0x87, 0x5d, 0x5b, 0x29, 0xd9, 0x14, 0xf0, 0xb, 0x40, 0x92, 0xd2, 0xe, 0x7c, 0x17, 0xc4, 0x94, 0xf, 0xb, 0x26, 0x65, 0x6f, 0x74, 0xa8, 0xad, 0x95, 0xe6, 0xf7}; - uint8_t bytesprops2[] = {0x44, 0x9d, 0x95, 0x6e, 0xa, 0x64, 0x40, 0xce, 0xc3, 0x5f, 0x5a, 0x57, 0xa2, 0xba, 0x1a, 0xcd, 0x3, 0xe4, 0x11, 0xe1, 0xd, 0x2d, 0xd6}; - uint8_t bytesprops3[] = {0xc2, 0x64, 0x3f, 0x59, 0xb5, 0x1b, 0xc2, 0x75, 0x7f, 0x95, 0xd7, 0x33, 0x67, 0x26, 0x51, 0xf, 0xb, 0x86, 0xbd, 0xa7, 0x62, 0x86, 0x10, 0xd6}; - uint8_t bytesprops4[] = {0xaa, 0xe8, 0x8f, 0x47, 0xdc, 0xf1}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9332}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27708}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21312}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18569}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12656}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28685}}, - }; + uint8_t pkt[] = {0xe0, 0x14, 0x8d, 0x12, 0x24, 0xf6, 0x13, 0x15, 0xb6, 0x29, 0xfd, + 0x12, 0x0, 0x8, 0x56, 0xe, 0xd, 0x1f, 0x63, 0x50, 0x94, 0xa2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x56, 0xe, 0xd, 0x1f, 0x63, 0x50, 0x94, 0xa2}; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 142, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5558}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops0}}}, + }; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 141, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoDisconnectWithWill [PropRetainAvailable 130,PropAuthenticationMethod "\NUL\175\222#\241w\211H\140/4\249\v\GS\209\138/\SI~\209",PropAuthenticationMethod "\\\200\SYN\152\131\144<\133\204*\249\180=\185\254G\156\223>)\226[^\237K\ESC3",PropMaximumPacketSize 8572,PropSubscriptionIdentifier 9,PropRetainAvailable 54,PropTopicAlias 1970,PropServerKeepAlive 23614,PropServerKeepAlive 10526,PropRetainAvailable 214,PropSharedSubscriptionAvailable 41,PropResponseTopic "\DEL\EM|\231\226S",PropSharedSubscriptionAvailable 109,PropResponseInformation "",PropWillDelayInterval 281,PropTopicAlias 7326,PropMaximumPacketSize 26693,PropContentType "S\141l\161\207\&3\249\&9\209D\207\&9\197G\134\176c\136<\US\EOTVH\147\231\138\136\186\201\SYN",PropUserProperty "\132\254\170S\168\SOH$\201\199>\151\EM\233.\129y\214" ">G)",PropTopicAlias 32372] +// DisconnectRequest DiscoProtocolError [PropResponseInformation +// "@;\216x\241\148\ACK\161Q\225\226\135\147c~\233\229$\231\DC2K\205\ESC\186\171,\131)",PropSubscriptionIdentifierAvailable +// 218,PropAssignedClientIdentifier "oW\128\254y(\243y\ESC%",PropWildcardSubscriptionAvailable 23,PropServerKeepAlive +// 22478,PropSubscriptionIdentifier 10,PropSubscriptionIdentifierAvailable 225,PropSharedSubscriptionAvailable +// 7,PropMaximumQoS 39,PropRequestProblemInformation 241] TEST(Disco5QCTest, Encode27) { -uint8_t pkt[] = {0xe0, 0xdf, 0x1, 0x93, 0xdc, 0x1, 0x29, 0xc3, 0x29, 0x76, 0x28, 0x39, 0x2a, 0x97, 0x29, 0xdf, 0x28, 0x7f, 0x1, 0x10, 0x12, 0x0, 0x1, 0x88, 0x15, 0x0, 0x1c, 0x21, 0xcf, 0x4c, 0x7f, 0xda, 0x1, 0xf8, 0x9a, 0x88, 0x0, 0x91, 0xb2, 0x90, 0xb3, 0x73, 0x43, 0x80, 0xdb, 0x82, 0xc0, 0x98, 0xab, 0xeb, 0x3f, 0x1f, 0xe9, 0x72,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0x7f, 0xda, 0x1, 0xf8, 0x9a, 0x88, 0x0, 0x91, 0xb2, 0x90, 0xb3, 0x73, 0x43, 0x80, 0xdb, 0x82, 0xc0, 0x98, 0xab, 0xeb, 0x3f, 0x1f, 0xe9, 0x72, 0x2b}; - uint8_t bytesprops2[] = {0xfe, 0x6c, 0xba, 0xc5, 0xb1, 0x1e, 0xa4, 0xe9, 0x57, 0xd3, 0x2b, 0x58, 0xc9, 0xe1, 0x5b, 0x24, 0xe9, 0xc4, 0xa6, 0x3e, 0xf, 0x7e, 0xd1}; - uint8_t bytesprops3[] = {0x5c, 0xc8, 0x16, 0x98, 0x83, 0x90, 0x3c, 0x85, 0xcc, 0x2a, 0xf9, 0xb4, 0x3d, 0xb9, 0xfe, 0x47, 0x9c, 0xdf, 0x3e, 0x29, 0xe2, 0x5b, 0x5e, 0xed, 0x4b, 0x1b, 0x33}; - uint8_t bytesprops4[] = {0x7f, 0x19, 0x7c, 0xe7, 0xe2, 0x53}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0x53, 0x8d, 0x6c, 0xa1, 0xcf, 0x33, 0xf9, 0x39, 0xd1, 0x44, 0xcf, 0x39, 0xc5, 0x47, 0x86, 0xb0, 0x63, 0x88, 0x3c, 0x1f, 0x4, 0x56, 0x48, 0x93, 0xe7, 0x8a, 0x88, 0xba, 0xc9, 0x16}; - uint8_t bytesprops8[] = {0x3e, 0x47, 0x29}; - uint8_t bytesprops7[] = {0x84, 0xfe, 0xaa, 0x53, 0xa8, 0x1, 0x24, 0xc9, 0xc7, 0x3e, 0x97, 0x19, 0xe9, 0x2e, 0x81, 0x79, 0xd6}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2710}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8572}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1970}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23614}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10526}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 281}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7326}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26693}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={17, (char*)&bytesprops7}, .v={3, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32372}}, - }; + uint8_t pkt[] = {0xe0, 0x3f, 0x82, 0x3d, 0x1a, 0x0, 0x1c, 0x40, 0x3b, 0xd8, 0x78, 0xf1, 0x94, 0x6, 0xa1, 0x51, 0xe1, + 0xe2, 0x87, 0x93, 0x63, 0x7e, 0xe9, 0xe5, 0x24, 0xe7, 0x12, 0x4b, 0xcd, 0x1b, 0xba, 0xab, 0x2c, 0x83, + 0x29, 0x29, 0xda, 0x12, 0x0, 0xa, 0x6f, 0x57, 0x80, 0xfe, 0x79, 0x28, 0xf3, 0x79, 0x1b, 0x25, 0x28, + 0x17, 0x13, 0x57, 0xce, 0xb, 0xa, 0x29, 0xe1, 0x2a, 0x7, 0x24, 0x27, 0x17, 0xf1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x40, 0x3b, 0xd8, 0x78, 0xf1, 0x94, 0x6, 0xa1, 0x51, 0xe1, 0xe2, 0x87, 0x93, 0x63, + 0x7e, 0xe9, 0xe5, 0x24, 0xe7, 0x12, 0x4b, 0xcd, 0x1b, 0xba, 0xab, 0x2c, 0x83, 0x29}; + uint8_t bytesprops1[] = {0x6f, 0x57, 0x80, 0xfe, 0x79, 0x28, 0xf3, 0x79, 0x1b, 0x25}; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 147, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22478}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 241}}, + }; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 130, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoQuotaExceeded [PropServerReference "e\227\135\rV\154\ESC\NAK\SI!9s\164]\166(xw\210\239",PropCorrelationData "\v\201\204i\228\149\223\235\226\197\164u\146\221",PropResponseInformation +// "Y\147\235\NUL\144#Mw\145[\135\DELb\193)",PropSubscriptionIdentifier 29,PropCorrelationData "a\173\f\212\153u +// &\FS\173 e\ENQOVsAr\183\194\171\198/c5",PropWillDelayInterval 2734,PropMessageExpiryInterval +// 6794,PropRequestProblemInformation 128,PropAssignedClientIdentifier +// "y\136\237\SO1'\134y\179x\189\184K\138B\148^\133\226\170\&7\FS\NAK",PropResponseInformation +// "\203\n\155\233\133a\170V\222\&2i\CAN\170\&5\249\203\166'",PropRequestResponseInformation 136,PropMaximumQoS +// 237,PropMessageExpiryInterval 30501,PropResponseInformation +// "e\171Q+\159e\GS\222\ETX\187",PropRequestResponseInformation 137,PropResponseInformation +// "\ACK!\142\187\226W\n,I\196",PropSubscriptionIdentifier 26,PropPayloadFormatIndicator 131,PropReasonString +// "\198",PropAuthenticationData +// "\129\144\n\n#\SYNXD\136\DLE\225\200\175\129MVO\167B\233\152\130\GS\NUL\130e\208U\196",PropAuthenticationData +// "\171\253\221\227o\148\160E\185\198\232[dA\190\228\232\167\RS~\239\tb\236",PropMessageExpiryInterval +// 28849,PropCorrelationData "6R\144X7\204r~6\137\184\208\209`\207\192n\n%\146",PropTopicAliasM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4, 0x3b, 0xad, 0xa8, 0xa9, 0xe8, 0x9, 0xc7, 0xf4, 0xbf, 0x6e, 0x91, 0xd5, 0x85, 0x5b, 0xa1, 0x1d, 0x25, 0x1a, 0x12, 0x0, 0x1d, 0x19, 0x42, 0xfa, 0x29, 0x1b, 0x7, 0x34, 0x2e, 0xef, 0x5f, 0x55, 0x29, 0xe, 0xb9, 0x24, 0xee, 0x57, 0xaa, 0xa4, 0x3f, 0x25, 0xa0, 0x33, 0x93, 0x10, 0xfe, 0x6f, 0x75, 0xad, 0x19, 0xfd, 0x21, 0x57, 0xbf, 0x1, 0xb9}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x65, 0xe3, 0x87, 0xd, 0x56, 0x9a, 0x1b, 0x15, 0xf, 0x21, 0x39, 0x73, 0xa4, 0x5d, 0xa6, 0x28, 0x78, 0x77, 0xd2, 0xef}; - uint8_t bytesprops1[] = {0xb, 0xc9, 0xcc, 0x69, 0xe4, 0x95, 0xdf, 0xeb, 0xe2, 0xc5, 0xa4, 0x3c, 0x58, 0x4a, 0xd5, 0xe6, 0xa6, 0x9d, 0x9e, 0x17, 0x92, 0xc9, 0xdd, 0x45}; - uint8_t bytesprops2[] = {0x74, 0x90, 0x4c, 0x41, 0xea, 0x1, 0xfc, 0x98, 0x89, 0x88, 0x59, 0x8c, 0xe4, 0xea, 0xcf, 0x8e, 0xf, 0xd, 0x3c, 0x9, 0xce, 0xea}; - uint8_t bytesprops3[] = {0xfa, 0x90, 0xf9, 0x8c, 0x51, 0xdf}; - uint8_t bytesprops4[] = {0x98, 0xfb, 0xf7, 0x29, 0x86, 0x44, 0xbb, 0xda, 0xc, 0xb8, 0x74, 0x5d, 0xc3, 0x94, 0x7d, 0x9f, 0x5a, 0x2e, 0x4a, 0x40, 0xfd, 0xb0, 0x8e, 0xfe, 0x51, 0xcc}; - uint8_t bytesprops5[] = {0xf2, 0x19, 0x78, 0x9e, 0x90, 0x73, 0x5d, 0x3d, 0x24, 0x43, 0x7d, 0x46, 0xe7, 0x79, 0x32, 0xfb, 0x52, 0x52, 0xf9, 0x50, 0x4e, 0x9e, 0x75}; - uint8_t bytesprops6[] = {0xd4, 0xfb, 0xa9, 0x4d, 0xc2, 0xf4, 0x3b, 0xad, 0xa8, 0xa9, 0xe8, 0x9, 0xc7, 0xf4, 0xbf, 0x6e, 0x91, 0xd5, 0x85, 0x5b, 0xa1, 0x1d}; - uint8_t bytesprops7[] = {0x19, 0x42, 0xfa, 0x29, 0x1b, 0x7, 0x34, 0x2e, 0xef, 0x5f, 0x55, 0x29, 0xe, 0xb9, 0x24, 0xee, 0x57, 0xaa, 0xa4, 0x3f, 0x25, 0xa0, 0x33, 0x93, 0x10, 0xfe, 0x6f, 0x75, 0xad}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 31}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29062}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32108}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11255}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22463}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 185}}, - }; + uint8_t pkt[] = { + 0xe0, 0x93, 0x2, 0x96, 0x90, 0x2, 0x9, 0x0, 0x1b, 0x83, 0x82, 0xd2, 0x84, 0xe0, 0x7c, 0x56, 0xe6, 0x3, 0x53, + 0x47, 0x77, 0x9d, 0xf1, 0xfa, 0xb3, 0xc1, 0x67, 0x8d, 0xdc, 0x62, 0x6f, 0xc5, 0x3e, 0x75, 0x92, 0xdd, 0x1a, 0x0, + 0xf, 0x59, 0x93, 0xeb, 0x0, 0x90, 0x23, 0x4d, 0x77, 0x91, 0x5b, 0x87, 0x7f, 0x62, 0xc1, 0x29, 0xb, 0x1d, 0x9, + 0x0, 0x19, 0x61, 0xad, 0xc, 0xd4, 0x99, 0x75, 0x20, 0x26, 0x1c, 0xad, 0x20, 0x65, 0x5, 0x4f, 0x56, 0x73, 0x41, + 0x72, 0xb7, 0xc2, 0xab, 0xc6, 0x2f, 0x63, 0x35, 0x18, 0x0, 0x0, 0xa, 0xae, 0x2, 0x0, 0x0, 0x1a, 0x8a, 0x17, + 0x80, 0x12, 0x0, 0x17, 0x79, 0x88, 0xed, 0xe, 0x31, 0x27, 0x86, 0x79, 0xb3, 0x78, 0xbd, 0xb8, 0x4b, 0x8a, 0x42, + 0x94, 0x5e, 0x85, 0xe2, 0xaa, 0x37, 0x1c, 0x15, 0x1a, 0x0, 0x12, 0xcb, 0xa, 0x9b, 0xe9, 0x85, 0x61, 0xaa, 0x56, + 0xde, 0x32, 0x69, 0x18, 0xaa, 0x35, 0xf9, 0xcb, 0xa6, 0x27, 0x19, 0x88, 0x24, 0xed, 0x2, 0x0, 0x0, 0x77, 0x25, + 0x1a, 0x0, 0xa, 0x65, 0xab, 0x51, 0x2b, 0x9f, 0x65, 0x1d, 0xde, 0x3, 0xbb, 0x19, 0x89, 0x1a, 0x0, 0xa, 0x6, + 0x21, 0x8e, 0xbb, 0xe2, 0x57, 0xa, 0x2c, 0x49, 0xc4, 0xb, 0x1a, 0x1, 0x83, 0x1f, 0x0, 0x1, 0xc6, 0x16, 0x0, + 0x1d, 0x81, 0x90, 0xa, 0xa, 0x23, 0x16, 0x58, 0x44, 0x88, 0x10, 0xe1, 0xc8, 0xaf, 0x81, 0x4d, 0x56, 0x4f, 0xa7, + 0x42, 0xe9, 0x98, 0x82, 0x1d, 0x0, 0x82, 0x65, 0xd0, 0x55, 0xc4, 0x16, 0x0, 0x18, 0xab, 0xfd, 0xdd, 0xe3, 0x6f, + 0x94, 0xa0, 0x45, 0xb9, 0xc6, 0xe8, 0x5b, 0x64, 0x41, 0xbe, 0xe4, 0xe8, 0xa7, 0x1e, 0x7e, 0xef, 0x9, 0x62, 0xec, + 0x2, 0x0, 0x0, 0x70, 0xb1, 0x9, 0x0, 0x14, 0x36, 0x52, 0x90, 0x58, 0x37, 0xcc, 0x72, 0x7e, 0x36, 0x89, 0xb8, + 0xd0, 0xd1, 0x60, 0xcf, 0xc0, 0x6e, 0xa, 0x25, 0x92, 0x22, 0xa, 0xbb}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x83, 0x82, 0xd2, 0x84, 0xe0, 0x7c, 0x56, 0xe6, 0x3, 0x53, 0x47, 0x77, 0x9d, 0xf1, + 0xfa, 0xb3, 0xc1, 0x67, 0x8d, 0xdc, 0x62, 0x6f, 0xc5, 0x3e, 0x75, 0x92, 0xdd}; + uint8_t bytesprops1[] = {0x59, 0x93, 0xeb, 0x0, 0x90, 0x23, 0x4d, 0x77, 0x91, 0x5b, 0x87, 0x7f, 0x62, 0xc1, 0x29}; + uint8_t bytesprops2[] = {0x61, 0xad, 0xc, 0xd4, 0x99, 0x75, 0x20, 0x26, 0x1c, 0xad, 0x20, 0x65, 0x5, + 0x4f, 0x56, 0x73, 0x41, 0x72, 0xb7, 0xc2, 0xab, 0xc6, 0x2f, 0x63, 0x35}; + uint8_t bytesprops3[] = {0x79, 0x88, 0xed, 0xe, 0x31, 0x27, 0x86, 0x79, 0xb3, 0x78, 0xbd, 0xb8, + 0x4b, 0x8a, 0x42, 0x94, 0x5e, 0x85, 0xe2, 0xaa, 0x37, 0x1c, 0x15}; + uint8_t bytesprops4[] = {0xcb, 0xa, 0x9b, 0xe9, 0x85, 0x61, 0xaa, 0x56, 0xde, + 0x32, 0x69, 0x18, 0xaa, 0x35, 0xf9, 0xcb, 0xa6, 0x27}; + uint8_t bytesprops5[] = {0x65, 0xab, 0x51, 0x2b, 0x9f, 0x65, 0x1d, 0xde, 0x3, 0xbb}; + uint8_t bytesprops6[] = {0x6, 0x21, 0x8e, 0xbb, 0xe2, 0x57, 0xa, 0x2c, 0x49, 0xc4}; + uint8_t bytesprops7[] = {0xc6}; + uint8_t bytesprops8[] = {0x81, 0x90, 0xa, 0xa, 0x23, 0x16, 0x58, 0x44, 0x88, 0x10, 0xe1, 0xc8, 0xaf, 0x81, 0x4d, + 0x56, 0x4f, 0xa7, 0x42, 0xe9, 0x98, 0x82, 0x1d, 0x0, 0x82, 0x65, 0xd0, 0x55, 0xc4}; + uint8_t bytesprops9[] = {0xab, 0xfd, 0xdd, 0xe3, 0x6f, 0x94, 0xa0, 0x45, 0xb9, 0xc6, 0xe8, 0x5b, + 0x64, 0x41, 0xbe, 0xe4, 0xe8, 0xa7, 0x1e, 0x7e, 0xef, 0x9, 0x62, 0xec}; + uint8_t bytesprops10[] = {0x36, 0x52, 0x90, 0x58, 0x37, 0xcc, 0x72, 0x7e, 0x36, 0x89, + 0xb8, 0xd0, 0xd1, 0x60, 0xcf, 0xc0, 0x6e, 0xa, 0x25, 0x92}; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 151, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2734}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6794}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30501}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28849}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2747}}, + }; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 150, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoQoSNotSupported [PropSharedSubscriptionAvailable 255,PropReceiveMaximum 3693,PropWillDelayInterval 1598,PropAssignedClientIdentifier "N\ETX7\158\t"] +// DisconnectRequest DiscoTopicNameInvalid [PropSubscriptionIdentifier 11,PropWillDelayInterval +// 21991,PropAssignedClientIdentifier ",\226\141u\SUB,O\211\188E\239\162\149\174\SOh\249\176[\227\143",PropContentType +// "B\a\160\171\STX!\SO5`\198\SI\177\213\197\n:\\\144",PropResponseTopic +// "\169UZ\203\162\SI\242\235\232=\206\233I\162\224\199",PropReasonString +// "\ETB\251U\131_\203i\253#\202\237\130",PropReceiveMaximum 26751,PropResponseInformation +// "\SYNm\232/R\180h;2t\241\216\&4\243\167\209\174\&1\178:\248uZ\CAN\174\130`"] TEST(Disco5QCTest, Encode29) { -uint8_t pkt[] = {0xe0, 0x14, 0x9b, 0x12, 0x2a, 0xff, 0x21, 0xe, 0x6d, 0x18, 0x0, 0x0, 0x6, 0x3e, 0x12, 0x0, 0x5, 0x4e, 0x3, 0x37, 0x9e, 0x9}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops0[] = {0x4e, 0x3, 0x37, 0x9e, 0x9}; - + uint8_t pkt[] = {0xe0, 0x79, 0x90, 0x77, 0xb, 0xb, 0x18, 0x0, 0x0, 0x55, 0xe7, 0x12, 0x0, 0x15, 0x2c, 0xe2, + 0x8d, 0x75, 0x1a, 0x2c, 0x4f, 0xd3, 0xbc, 0x45, 0xef, 0xa2, 0x95, 0xae, 0xe, 0x68, 0xf9, 0xb0, + 0x5b, 0xe3, 0x8f, 0x3, 0x0, 0x12, 0x42, 0x7, 0xa0, 0xab, 0x2, 0x21, 0xe, 0x35, 0x60, 0xc6, + 0xf, 0xb1, 0xd5, 0xc5, 0xa, 0x3a, 0x5c, 0x90, 0x8, 0x0, 0x10, 0xa9, 0x55, 0x5a, 0xcb, 0xa2, + 0xf, 0xf2, 0xeb, 0xe8, 0x3d, 0xce, 0xe9, 0x49, 0xa2, 0xe0, 0xc7, 0x1f, 0x0, 0xc, 0x17, 0xfb, + 0x55, 0x83, 0x5f, 0xcb, 0x69, 0xfd, 0x23, 0xca, 0xed, 0x82, 0x21, 0x68, 0x7f, 0x1a, 0x0, 0x1b, + 0x16, 0x6d, 0xe8, 0x2f, 0x52, 0xb4, 0x68, 0x3b, 0x32, 0x74, 0xf1, 0xd8, 0x34, 0xf3, 0xa7, 0xd1, + 0xae, 0x31, 0xb2, 0x3a, 0xf8, 0x75, 0x5a, 0x18, 0xae, 0x82, 0x60}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x2c, 0xe2, 0x8d, 0x75, 0x1a, 0x2c, 0x4f, 0xd3, 0xbc, 0x45, 0xef, + 0xa2, 0x95, 0xae, 0xe, 0x68, 0xf9, 0xb0, 0x5b, 0xe3, 0x8f}; + uint8_t bytesprops1[] = {0x42, 0x7, 0xa0, 0xab, 0x2, 0x21, 0xe, 0x35, 0x60, + 0xc6, 0xf, 0xb1, 0xd5, 0xc5, 0xa, 0x3a, 0x5c, 0x90}; + uint8_t bytesprops2[] = {0xa9, 0x55, 0x5a, 0xcb, 0xa2, 0xf, 0xf2, 0xeb, + 0xe8, 0x3d, 0xce, 0xe9, 0x49, 0xa2, 0xe0, 0xc7}; + uint8_t bytesprops3[] = {0x17, 0xfb, 0x55, 0x83, 0x5f, 0xcb, 0x69, 0xfd, 0x23, 0xca, 0xed, 0x82}; + uint8_t bytesprops4[] = {0x16, 0x6d, 0xe8, 0x2f, 0x52, 0xb4, 0x68, 0x3b, 0x32, 0x74, 0xf1, 0xd8, 0x34, 0xf3, + 0xa7, 0xd1, 0xae, 0x31, 0xb2, 0x3a, 0xf8, 0x75, 0x5a, 0x18, 0xae, 0x82, 0x60}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3693}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1598}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21991}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26751}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); - + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - -// DisconnectRequest DiscoTopicNameInvalid [PropRequestResponseInformation 14,PropMaximumQoS 14,PropUserProperty "\CANt\DC3\215A\171%\171\&8\226\245\DC4\229\215\162\CAN\130\210\225\144\202\DC1^\157\&3\251\&8" "\EOT\135\132t-\251\FS",PropSubscriptionIdentifier 8,PropResponseInformation "\bk\\\249\RS-\196\GSE\164e\SO6\rR",PropAuthenticationMethod "\176\188\226\128U\183\r `\241",PropMaximumPacketSize 23171,PropMaximumQoS 139,PropRequestResponseInformation 198,PropSharedSubscriptionAvailable 220,PropSharedSubscriptionAvailable 63,PropWildcardSubscriptionAvailable 234,PropServerReference "",PropContentType "\ETB&&\253\179\166GJ",PropServerReference "\NUL\191\225s\226",PropServerKeepAlive 19145] +// DisconnectRequest DiscoImplementationSpecificError [PropTopicAlias 14784,PropServerReference +// "\137jMZ",PropResponseTopic "zW\135\188\248\164yl\192+a\207miV\SOH\220\193\&8(\229/mh7\167\t",PropMaximumPacketSize +// 8003,PropUserProperty "\202\f\ACK*\229\EOT\134\241\DC4v\204\161A" +// "X'\187\165\147\137\207nO\n\233\148\138\138\248\DC4\157\219\155T\139",PropAuthenticationData +// "?\ETB\144p\130gQuI\184,\f\141C3",PropServerKeepAlive 21004,PropMessageExpiryInterval 18390,PropContentType +// "\200'\215P\181a\187\208H\152\210L",PropTopicAlias 18937,PropCorrelationData +// "\128\152\208\147\231\\\141y\138\191\145\167$\223\NAK\DC4 I\199\163\222",PropMessageExpiryInterval +// 4343,PropReceiveMaximum 10269,PropRequestResponseInformation 105,PropSubscriptionIdentifier 7,PropResponseInformation +// "\248&d\EM2#\204\203\219\163\161\177Q\159\147",PropAuthenticationMethod +// "\242\177\\\186\SUBO\240E\"\222\170\242rX\239\181AH\235\139\213\198|u",PropWildcardSubscriptionAvailable +// 44,PropMaximumPacketSize 3490,PropAssignedClientIdentifier "\GS\201\a\185{C",PropAuthenticationData +// "\182\"\FS\182h1l\195\148\a-\189\RSS\197l",PropPayloadFormatIndicator 218] TEST(Disco5QCTest, Encode30) { -uint8_t pkt[] = {0xe0, 0x76, 0x90, 0x74, 0x19, 0xe, 0x24, 0xe, 0x26, 0x0, 0x1b, 0x18, 0x74, 0x13, 0xd7, 0x41, 0xab, 0x25, 0xab, 0x38, 0xe2, 0xf5, 0x14, 0xe5, 0xd7, 0xa2, 0x18, 0x82, 0xd2, 0xe1, 0x90, 0xca, 0x11, 0x5e, 0x9d, 0x33, 0xfb, 0x38, 0x0, 0x7, 0x4, 0x87, 0x84, 0x74, 0x2d, 0xfb, 0x1c, 0xb, 0x8, 0x1a, 0x0, 0xf, 0x8, 0x6b, 0x5c, 0xf9, 0x1e, 0x2d, 0xc4, 0x1d, 0x45, 0xa4, 0x65, 0xe, 0x36, 0xd, 0x52, 0x15, 0x0, 0xa, 0xb0, 0xbc, 0xe2, 0x80, 0x55, 0xb7, 0xd, 0x20, 0x60, 0xf1, 0x27, 0x0, 0x0, 0x5a, 0x83, 0x24, 0x8b, 0x19, 0xc6, 0x2a, 0xdc, 0x2a, 0x3f, 0x28, 0xea, 0x1c, 0x0, 0x0, 0x3, 0x0, 0x8, 0x17, 0x26, 0x26, 0xfd, 0xb3, 0xa6, 0x47, 0x4a, 0x1c, 0x0, 0x5, 0x0, 0xbf, 0xe1, 0x73, 0xe2, 0x13, 0x4a, 0xc9}; -uint8_t buf[sizeof(pkt)+10] = { 0 }; - uint8_t bytesprops1[] = {0x4, 0x87, 0x84, 0x74, 0x2d, 0xfb, 0x1c}; - uint8_t bytesprops0[] = {0x18, 0x74, 0x13, 0xd7, 0x41, 0xab, 0x25, 0xab, 0x38, 0xe2, 0xf5, 0x14, 0xe5, 0xd7, 0xa2, 0x18, 0x82, 0xd2, 0xe1, 0x90, 0xca, 0x11, 0x5e, 0x9d, 0x33, 0xfb, 0x38}; - uint8_t bytesprops2[] = {0x8, 0x6b, 0x5c, 0xf9, 0x1e, 0x2d, 0xc4, 0x1d, 0x45, 0xa4, 0x65, 0xe, 0x36, 0xd, 0x52}; - uint8_t bytesprops3[] = {0xb0, 0xbc, 0xe2, 0x80, 0x55, 0xb7, 0xd, 0x20, 0x60, 0xf1}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0x17, 0x26, 0x26, 0xfd, 0xb3, 0xa6, 0x47, 0x4a}; - uint8_t bytesprops6[] = {0x0, 0xbf, 0xe1, 0x73, 0xe2}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k={27, (char*)&bytesprops0}, .v={7, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23171}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19145}}, - }; + uint8_t pkt[] = {0xe0, 0xf9, 0x1, 0x83, 0xf6, 0x1, 0x23, 0x39, 0xc0, 0x1c, 0x0, 0x4, 0x89, 0x6a, 0x4d, 0x5a, 0x8, + 0x0, 0x1b, 0x7a, 0x57, 0x87, 0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b, 0x8b, 0xd5, 0xc6, 0x7c, 0x75, 0x28, 0x2c, 0x27, 0x0, 0x0, 0xd, + 0xa2, 0x12, 0x0, 0x6, 0x1d, 0xc9, 0x7, 0xb9, 0x7b, 0x43, 0x16, 0x0, 0x10, 0xb6, 0x22, 0x1c, 0xb6, + 0x68, 0x31, 0x6c, 0xc3, 0x94, 0x7, 0x2d, 0xbd, 0x1e, 0x53, 0xc5, 0x6c, 0x1, 0xda}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x89, 0x6a, 0x4d, 0x5a}; + uint8_t bytesprops1[] = {0x7a, 0x57, 0x87, 0xbc, 0xf8, 0xa4, 0x79, 0x6c, 0xc0, 0x2b, 0x61, 0xcf, 0x6d, 0x69, + 0x56, 0x1, 0xdc, 0xc1, 0x38, 0x28, 0xe5, 0x2f, 0x6d, 0x68, 0x37, 0xa7, 0x9}; + uint8_t bytesprops3[] = {0x58, 0x27, 0xbb, 0xa5, 0x93, 0x89, 0xcf, 0x6e, 0x4f, 0xa, 0xe9, + 0x94, 0x8a, 0x8a, 0xf8, 0x14, 0x9d, 0xdb, 0x9b, 0x54, 0x8b}; + uint8_t bytesprops2[] = {0xca, 0xc, 0x6, 0x2a, 0xe5, 0x4, 0x86, 0xf1, 0x14, 0x76, 0xcc, 0xa1, 0x41}; + uint8_t bytesprops4[] = {0x3f, 0x17, 0x90, 0x70, 0x82, 0x67, 0x51, 0x75, 0x49, 0xb8, 0x2c, 0xc, 0x8d, 0x43, 0x33}; + uint8_t bytesprops5[] = {0xc8, 0x27, 0xd7, 0x50, 0xb5, 0x61, 0xbb, 0xd0, 0x48, 0x98, 0xd2, 0x4c}; + uint8_t bytesprops6[] = {0x80, 0x98, 0xd0, 0x93, 0xe7, 0x5c, 0x8d, 0x79, 0x8a, 0xbf, 0x91, + 0xa7, 0x24, 0xdf, 0x15, 0x14, 0x20, 0x49, 0xc7, 0xa3, 0xde}; + uint8_t bytesprops7[] = {0xf8, 0x26, 0x64, 0x19, 0x32, 0x23, 0xcc, 0xcb, 0xdb, 0xa3, 0xa1, 0xb1, 0x51, 0x9f, 0x93}; + uint8_t bytesprops8[] = {0xf2, 0xb1, 0x5c, 0xba, 0x1a, 0x4f, 0xf0, 0x45, 0x22, 0xde, 0xaa, 0xf2, + 0x72, 0x58, 0xef, 0xb5, 0x41, 0x48, 0xeb, 0x8b, 0xd5, 0xc6, 0x7c, 0x75}; + uint8_t bytesprops9[] = {0x1d, 0xc9, 0x7, 0xb9, 0x7b, 0x43}; + uint8_t bytesprops10[] = {0xb6, 0x22, 0x1c, 0xb6, 0x68, 0x31, 0x6c, 0xc3, + 0x94, 0x7, 0x2d, 0xbd, 0x1e, 0x53, 0xc5, 0x6c}; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; -size_t len = 0; -lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); -EXPECT_EQ(err, LWMQTT_SUCCESS); -EXPECT_EQ(len, sizeof(pkt)); -EXPECT_ARRAY_EQ(pkt, buf, len); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14784}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8003}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops2}, .v = {21, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21004}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18390}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18937}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4343}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10269}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3490}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, + }; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 131, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); } - - diff --git a/tests/packet.cpp b/tests/packet.cpp index 18c0dea..0f46ee3 100644 --- a/tests/packet.cpp +++ b/tests/packet.cpp @@ -761,7 +761,7 @@ TEST(UnsubscribeTest, Encode1) { topic_filters[2] = lwmqtt_string("/a/b/#/cdd"); size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, 38, &len, 7, 3, topic_filters); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, 38, &len, LWMQTT_MQTT311, 7, 3, topic_filters, empty_props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); @@ -774,7 +774,7 @@ TEST(UnsubscribeTest, EncodeError1) { topic_filters[0] = lwmqtt_string("surgemq"); size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, 2, &len, 7, 1, topic_filters); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, 2, &len, LWMQTT_MQTT311, 7, 1, topic_filters, empty_props); EXPECT_EQ(err, LWMQTT_BUFFER_TOO_SHORT); } From 75592a7c599afd850ff540bfcecba50c9c419ea9 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Sat, 21 Sep 2019 11:26:49 -0700 Subject: [PATCH 22/26] Properly parsing unsub acks. --- gentests/app/Main.hs | 41 +- include/lwmqtt.h | 11 + src/client.c | 14 +- src/packet.c | 65 + src/packet.h | 3 + tests/generated.cpp | 35081 +++++++++++++++++++++-------------------- 6 files changed, 18177 insertions(+), 17038 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 5e98e65..0f6f165 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -46,8 +46,11 @@ v311SubReq p50 = let (SubscribePkt p) = v311mask (SubscribePkt p50) in p v311UnsubReq :: UnsubscribeRequest -> UnsubscribeRequest v311UnsubReq p50 = let (UnsubscribePkt p) = v311mask (UnsubscribePkt p50) in p -v311SubACKReq :: SubscribeResponse -> SubscribeResponse -v311SubACKReq p50 = let (SubACKPkt p) = v311mask (SubACKPkt p50) in p +v311SubACK :: SubscribeResponse -> SubscribeResponse +v311SubACK p50 = let (SubACKPkt p) = v311mask (SubACKPkt p50) in p + +v311UnsubACK :: UnsubscribeResponse -> UnsubscribeResponse +v311UnsubACK p50 = let (UnsubACKPkt p) = v311mask (UnsubACKPkt p50) in p v311ConnReq :: ConnectRequest -> ConnectRequest v311ConnReq p50 = let (ConnPkt p) = v311mask (ConnPkt p50) in p @@ -342,6 +345,34 @@ genSubACKTest prot i p@(SubscribeResponse pid res _props) = do q5 SubErrSubscriptionIdentifiersNotSupported = "0xA1" q5 SubErrWildcardSubscriptionsNotSupported = "0xA2" +genUnsubACKTest :: ProtocolLevel -> Int -> UnsubscribeResponse -> String +genUnsubACKTest prot i p@(UnsubscribeResponse pid _props res) = do + let ll = show (length res) + genTestFunc "UnsubACK" "Decode" prot i p $ mconcat [ + "uint16_t packet_id;\n", + "int count;\n", + "lwmqtt_unsubscribe_status_t statuses[", ll, "];\n", + "lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id,", + protlvl prot, ", ", ll, ", &count, statuses);\n", + "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + "EXPECT_EQ(packet_id, ", show pid, ");\n", + "EXPECT_EQ(count, ", ll, ");\n", + concatMap checkStatus (zip [0..] res) + ] + + where + checkStatus :: (Int,UnsubStatus) -> String + checkStatus (qi,q) = "EXPECT_EQ(statuses[" <> show qi <> "], " <> b q <> ");\n" + + b UnsubSuccess = "LWMQTT_UNSUB_SUCCESS" + b UnsubNoSubscriptionExisted = "LWMQTT_UNSUB_NO_SUB_EXISTED" + b UnsubUnspecifiedError = "LWMQTT_UNSUB_UNSPECIFIED_ERROR" + b UnsubImplementationSpecificError = "LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR" + b UnsubNotAuthorized = "LWMQTT_UNSUB_NOT_AUTHORIZED" + b UnsubTopicFilterInvalid = "LWMQTT_UNSUB_TOPIC_FILTER_INVALID" + b UnsubPacketIdentifierInUse = "LWMQTT_UNSUB_PACKET_ID_IN_USE" + + genDiscoTest :: ProtocolLevel -> Int -> DisconnectRequest -> String genDiscoTest prot i p@(DisconnectRequest rsn props) = do genTestFunc "Disco" "Encode" prot i p $ mconcat [ @@ -425,13 +456,17 @@ extern "C" { f genSubTest Protocol50 subs subax <- replicateM numTests $ generate arbitrary - f genSubACKTest Protocol311 (v311SubACKReq <$> subax) + f genSubACKTest Protocol311 (v311SubACK <$> subax) f genSubACKTest Protocol50 subax unsubs <- replicateM numTests $ generate arbitrary f genUnsubTest Protocol311 (v311UnsubReq <$> unsubs) f genUnsubTest Protocol50 unsubs + unsubax <- replicateM numTests $ generate arbitrary + f genUnsubACKTest Protocol311 (v311UnsubACK <$> unsubax) + f genUnsubACKTest Protocol50 unsubax + discos <- replicateM numTests $ generate arbitrary f genDiscoTest Protocol311 (take 2 $ v311DiscoClean <$> discos) -- these are all the same f genDiscoTest Protocol50 discos diff --git a/include/lwmqtt.h b/include/lwmqtt.h index e34c34b..af7ad8d 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -29,6 +29,7 @@ typedef enum { LWMQTT_FAILED_SUBSCRIPTION = -11, LWMQTT_SUBACK_ARRAY_OVERFLOW = -12, LWMQTT_PONG_TIMEOUT = -13, + LWMQTT_FAILED_UNSUBSCRIPTION = -14, } lwmqtt_err_t; /** @@ -414,6 +415,16 @@ lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_ lwmqtt_err_t lwmqtt_subscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, lwmqtt_sub_options_t opts, uint32_t timeout); +typedef enum { + LWMQTT_UNSUB_SUCCESS = 0, + LWMQTT_UNSUB_NO_SUB_EXISTED = 0x11, + LWMQTT_UNSUB_UNSPECIFIED_ERROR = 0x80, + LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR = 0x83, + LWMQTT_UNSUB_NOT_AUTHORIZED = 0x87, + LWMQTT_UNSUB_TOPIC_FILTER_INVALID = 0x8f, + LWMQTT_UNSUB_PACKET_ID_IN_USE = 0x91, +} lwmqtt_unsubscribe_status_t; + /** * Will send an unsubscribe packet with multiple topic filters and wait for the unsuback to complete. * diff --git a/src/client.c b/src/client.c index c19f6a8..85b3ce4 100644 --- a/src/client.c +++ b/src/client.c @@ -513,6 +513,7 @@ lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_ // check suback codes for (int i = 0; i < suback_count; i++) { + // TODO: Reverse this and just consider successes. if (granted_qos[i] == LWMQTT_QOS_FAILURE) { return LWMQTT_FAILED_SUBSCRIPTION; } @@ -555,13 +556,22 @@ lwmqtt_err_t lwmqtt_unsubscribe(lwmqtt_client_t *client, int count, lwmqtt_strin } // decode unsuback packet - bool dup; uint16_t packet_id; - err = lwmqtt_decode_ack(client->read_buf, client->read_buf_size, LWMQTT_UNSUBACK_PACKET, &dup, &packet_id); + int ret_count; + lwmqtt_unsubscribe_status_t statuses[count]; + err = lwmqtt_decode_unsuback(client->read_buf, client->read_buf_size, &packet_id, client->protocol, count, &ret_count, + statuses); if (err != LWMQTT_SUCCESS) { return err; } + for (int i = 0; i < ret_count; i++) { + if (statuses[i] != LWMQTT_UNSUB_SUCCESS) { + // TODO: It might be nice to bubble this up (or the properties?) + return LWMQTT_FAILED_UNSUBSCRIPTION; + } + } + return LWMQTT_SUCCESS; } diff --git a/src/packet.c b/src/packet.c index 3ce2901..923d270 100644 --- a/src/packet.c +++ b/src/packet.c @@ -739,6 +739,71 @@ lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet return LWMQTT_SUCCESS; } +lwmqtt_err_t lwmqtt_decode_unsuback(uint8_t *buf, size_t buf_len, uint16_t *packet_id, lwmqtt_protocol_t protocol, + int max_count, int *count, lwmqtt_unsubscribe_status_t *statuses) { + // prepare pointer + uint8_t *buf_ptr = buf; + uint8_t *buf_end = buf + buf_len; + + // read header + uint8_t header; + lwmqtt_err_t err = lwmqtt_read_byte(&buf_ptr, buf_end, &header); + if (err != LWMQTT_SUCCESS) { + return err; + } + + // check packet type + if (lwmqtt_read_bits(header, 4, 4) != LWMQTT_UNSUBACK_PACKET) { + return LWMQTT_MISSING_OR_WRONG_PACKET; + } + + // read remaining length + uint32_t rem_len; + err = lwmqtt_read_varnum(&buf_ptr, buf_end, &rem_len); + if (err != LWMQTT_SUCCESS) { + return err; + } + uint8_t *end = buf_ptr + rem_len; + + // read packet id + err = lwmqtt_read_num(&buf_ptr, buf_end, packet_id); + if (err != LWMQTT_SUCCESS) { + return err; + } + + if (protocol == LWMQTT_MQTT311) { + for (int i = 0; i < max_count; i++) { + statuses[i] = LWMQTT_UNSUB_SUCCESS; + } + *count = max_count; + return LWMQTT_SUCCESS; + } + + lwmqtt_serialized_properties_t props = {0, 0}; + err = decode_props(&buf_ptr, buf_end, protocol, &props); + if (err != LWMQTT_SUCCESS) { + return err; + } + + // read all suback codes + for (*count = 0; buf_ptr < end; (*count)++) { + // check max count + if (*count > max_count) { + return LWMQTT_SUBACK_ARRAY_OVERFLOW; + } + + // read qos level + uint8_t st; + err = lwmqtt_read_byte(&buf_ptr, buf_end, &st); + if (err != LWMQTT_SUCCESS) { + return err; + } + statuses[*count] = (lwmqtt_unsubscribe_status_t)st; + } + + return LWMQTT_SUCCESS; +} + lwmqtt_err_t lwmqtt_encode_unsubscribe(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, uint16_t packet_id, int count, lwmqtt_string_t *topic_filters, lwmqtt_properties_t props) { diff --git a/src/packet.h b/src/packet.h index 13b54ff..a2f1fda 100644 --- a/src/packet.h +++ b/src/packet.h @@ -176,6 +176,9 @@ lwmqtt_err_t lwmqtt_encode_subscribe(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_err_t lwmqtt_decode_suback(uint8_t *buf, size_t buf_len, uint16_t *packet_id, lwmqtt_protocol_t protocol, int max_count, int *count, lwmqtt_qos_t *granted_qos_levels); +lwmqtt_err_t lwmqtt_decode_unsuback(uint8_t *buf, size_t buf_len, uint16_t *packet_id, lwmqtt_protocol_t protocol, + int max_count, int *count, lwmqtt_unsubscribe_status_t *statuses); + /** * Encodes the supplied unsubscribe data into the supplied buffer, ready for sending * diff --git a/tests/generated.cpp b/tests/generated.cpp index f062ca8..4c2d66f 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,39 +21,42 @@ extern "C" { } \ } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\137\189\213\133\214H\EM\161\170\241\136", _pubPktID = 0, _pubBody = "\217\146\229\195\163\175\196\174y0d\141b\146", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "L\255\GS\208o\194\236\140\156\225\135\244\SO\154#", _pubPktID = 6184, _pubBody = +// "_\160\218auw5\192\154w\154\194:T\135\200\157", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x31, 0x1b, 0x0, 0xb, 0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88, - 0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; - uint8_t topic_bytes[] = {0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x24, 0x0, 0xf, 0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, + 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23, 0x18, 0x28, 0x5f, 0xa0, 0xda, 0x61, 0x75, + 0x77, 0x35, 0xc0, 0x9a, 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; + uint8_t topic_bytes[] = {0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, 0x9a, + 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6184, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\137\189\213\133\214H\EM\161\170\241\136", _pubPktID = 0, _pubBody = "\217\146\229\195\163\175\196\174y0d\141b\146", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "L\255\GS\208o\194\236\140\156\225\135\244\SO\154#", _pubPktID = 6184, _pubBody = +// "_\160\218auw5\192\154w\154\194:T\135\200\157", _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x31, 0x1b, 0x0, 0xb, 0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88, - 0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + uint8_t pkt[] = {0x3c, 0x24, 0x0, 0xf, 0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, + 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23, 0x18, 0x28, 0x5f, 0xa0, 0xda, 0x61, 0x75, + 0x77, 0x35, 0xc0, 0x9a, 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -62,55 +65,53 @@ TEST(Publish311QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + uint8_t exp_topic_bytes[] = {0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, 0x9a, + 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 6184); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\183\249", _pubPktID = 0, _pubBody -// = "M\EOTga\US?`w\167\&6\152\SI\NAKC\168>\173<\149\213m,5\235\133\r\180\190\195", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\198\DC1L:\231)\185\220\223D\v\EOT\217<", _pubPktID = 6873, _pubBody = "\ESC\"[|\180", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x30, 0x21, 0x0, 0x2, 0xb7, 0xf9, 0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, - 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, 0x3e, 0xad, 0x3c, - 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; - uint8_t topic_bytes[] = {0xb7, 0xf9}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x17, 0x0, 0xe, 0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, + 0x44, 0xb, 0x4, 0xd9, 0x3c, 0x1a, 0xd9, 0x1b, 0x22, 0x5b, 0x7c, 0xb4}; + uint8_t topic_bytes[] = {0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, - 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x1b, 0x22, 0x5b, 0x7c, 0xb4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 5; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 6873, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\183\249", _pubPktID = 0, _pubBody -// = "M\EOTga\US?`w\167\&6\152\SI\NAKC\168>\173<\149\213m,5\235\133\r\180\190\195", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\198\DC1L:\231)\185\220\223D\v\EOT\217<", _pubPktID = 6873, _pubBody = "\ESC\"[|\180", _pubProps = []} TEST(Publish311QCTest, Decode2) { - uint8_t pkt[] = {0x30, 0x21, 0x0, 0x2, 0xb7, 0xf9, 0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, - 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, 0x3e, 0xad, 0x3c, - 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + uint8_t pkt[] = {0x35, 0x17, 0x0, 0xe, 0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, + 0x44, 0xb, 0x4, 0xd9, 0x3c, 0x1a, 0xd9, 0x1b, 0x22, 0x5b, 0x7c, 0xb4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -119,58 +120,57 @@ TEST(Publish311QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb7, 0xf9}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, - 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1b, 0x22, 0x5b, 0x7c, 0xb4}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 6873); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } // PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\DC1\157\ns\ETX0?\130,\153\&5(\EM\NAK\235tg/\223cz\215\188l", _pubPktID = 23951, _pubBody = "\252\STX\212\139", -// _pubProps = []} +// "^W\131\160\253B\156\130SrVB\238=\158m_\253\242\178N", _pubPktID = 12282, _pubBody = +// "\169\159cc\RSh\239_U\ETB\NAK\223f", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x3a, 0x20, 0x0, 0x18, 0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, - 0x2c, 0x99, 0x35, 0x28, 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, - 0x7a, 0xd7, 0xbc, 0x6c, 0x5d, 0x8f, 0xfc, 0x2, 0xd4, 0x8b}; - uint8_t topic_bytes[] = {0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, - 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xbc, 0x6c}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x26, 0x0, 0x15, 0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, + 0x56, 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e, 0x2f, 0xfa, 0xa9, + 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; + uint8_t topic_bytes[] = {0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, 0x56, + 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xfc, 0x2, 0xd4, 0x8b}; + uint8_t msg_bytes[] = {0xa9, 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 13; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 23951, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 12282, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } // PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\DC1\157\ns\ETX0?\130,\153\&5(\EM\NAK\235tg/\223cz\215\188l", _pubPktID = 23951, _pubBody = "\252\STX\212\139", -// _pubProps = []} +// "^W\131\160\253B\156\130SrVB\238=\158m_\253\242\178N", _pubPktID = 12282, _pubBody = +// "\169\159cc\RSh\239_U\ETB\NAK\223f", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x3a, 0x20, 0x0, 0x18, 0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, - 0x2c, 0x99, 0x35, 0x28, 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, - 0x7a, 0xd7, 0xbc, 0x6c, 0x5d, 0x8f, 0xfc, 0x2, 0xd4, 0x8b}; + uint8_t pkt[] = {0x3a, 0x26, 0x0, 0x15, 0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, + 0x56, 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e, 0x2f, 0xfa, 0xa9, + 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -179,54 +179,58 @@ TEST(Publish311QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, - 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xbc, 0x6c}; - lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfc, 0x2, 0xd4, 0x8b}; - lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, 0x56, + 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa9, 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 23951); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); - EXPECT_EQ(msg.payload_len, 4); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + EXPECT_EQ(packet_id, 12282); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "2]\237\233\224\238", _pubPktID = -// 32430, _pubBody = "\\7\a}d\f\191)\250N\n\r\240\169\178\184]", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\223~\247S\221_\137\253\202\t\SO<\197\171X=\DC1'\196\ACK", _pubPktID = 7369, _pubBody = +// "\218\SI\242\t\138\r\SO\ESC[\224\207", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x35, 0x1b, 0x0, 0x6, 0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee, 0x7e, 0xae, 0x5c, 0x37, 0x7, - 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; - uint8_t topic_bytes[] = {0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x23, 0x0, 0x14, 0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, + 0x9, 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6, 0x1c, 0xc9, + 0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; + uint8_t topic_bytes[] = {0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, + 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x5c, 0x37, 0x7, 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, - 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; + msg.retained = false; + uint8_t msg_bytes[] = {0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 11; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32430, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7369, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "2]\237\233\224\238", _pubPktID = -// 32430, _pubBody = "\\7\a}d\f\191)\250N\n\r\240\169\178\184]", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\223~\247S\221_\137\253\202\t\SO<\197\171X=\DC1'\196\ACK", _pubPktID = 7369, _pubBody = +// "\218\SI\242\t\138\r\SO\ESC[\224\207", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x35, 0x1b, 0x0, 0x6, 0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee, 0x7e, 0xae, 0x5c, 0x37, 0x7, - 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; + uint8_t pkt[] = {0x34, 0x23, 0x0, 0x14, 0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, + 0x9, 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6, 0x1c, 0xc9, + 0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -235,54 +239,53 @@ TEST(Publish311QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5c, 0x37, 0x7, 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, - 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, + 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 32430); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7369); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "V\156\142\176", _pubPktID = 29213, -// _pubBody = "\EM\FSK\190t\254o\168\200\&9\131(\254Z\138g\243jL|\137\220", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\250\191\190jan\209", _pubPktID = +// 6761, _pubBody = "z-\195\235\243\220Q", _pubProps = []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x35, 0x1e, 0x0, 0x4, 0x56, 0x9c, 0x8e, 0xb0, 0x72, 0x1d, 0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, - 0x6f, 0xa8, 0xc8, 0x39, 0x83, 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; - uint8_t topic_bytes[] = {0x56, 0x9c, 0x8e, 0xb0}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x12, 0x0, 0x7, 0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, + 0xd1, 0x1a, 0x69, 0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; + uint8_t topic_bytes[] = {0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, 0x6f, 0xa8, 0xc8, 0x39, 0x83, - 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + msg.retained = false; + uint8_t msg_bytes[] = {0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 7; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29213, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6761, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "V\156\142\176", _pubPktID = 29213, -// _pubBody = "\EM\FSK\190t\254o\168\200\&9\131(\254Z\138g\243jL|\137\220", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\250\191\190jan\209", _pubPktID = +// 6761, _pubBody = "z-\195\235\243\220Q", _pubProps = []} TEST(Publish311QCTest, Decode5) { - uint8_t pkt[] = {0x35, 0x1e, 0x0, 0x4, 0x56, 0x9c, 0x8e, 0xb0, 0x72, 0x1d, 0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, - 0x6f, 0xa8, 0xc8, 0x39, 0x83, 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + uint8_t pkt[] = {0x3c, 0x12, 0x0, 0x7, 0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, + 0xd1, 0x1a, 0x69, 0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -291,53 +294,57 @@ TEST(Publish311QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x56, 0x9c, 0x8e, 0xb0}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, 0x6f, 0xa8, 0xc8, 0x39, 0x83, - 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29213); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 6761); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "j-w\135im\135", _pubPktID = 15185, -// _pubBody = "\178\183W\163D\179", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\229Y\156\186GOd\EOT\247\ETB\224\251-\228h{^Q!\246\b\DEL\225\NUL{/Q ", _pubPktID = 0, _pubBody = "<@\201Iv", +// _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x35, 0x11, 0x0, 0x7, 0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, - 0x87, 0x3b, 0x51, 0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; - uint8_t topic_bytes[] = {0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x23, 0x0, 0x1c, 0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, + 0x17, 0xe0, 0xfb, 0x2d, 0xe4, 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, + 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20, 0x3c, 0x40, 0xc9, 0x49, 0x76}; + uint8_t topic_bytes[] = {0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, 0x2d, 0xe4, + 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + uint8_t msg_bytes[] = {0x3c, 0x40, 0xc9, 0x49, 0x76}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 5; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15185, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "j-w\135im\135", _pubPktID = 15185, -// _pubBody = "\178\183W\163D\179", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\229Y\156\186GOd\EOT\247\ETB\224\251-\228h{^Q!\246\b\DEL\225\NUL{/Q ", _pubPktID = 0, _pubBody = "<@\201Iv", +// _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x35, 0x11, 0x0, 0x7, 0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, - 0x87, 0x3b, 0x51, 0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + uint8_t pkt[] = {0x39, 0x23, 0x0, 0x1c, 0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, + 0x17, 0xe0, 0xfb, 0x2d, 0xe4, 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, + 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20, 0x3c, 0x40, 0xc9, 0x49, 0x76}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -346,53 +353,58 @@ TEST(Publish311QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; - lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, 0x2d, 0xe4, + 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x3c, 0x40, 0xc9, 0x49, 0x76}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 15185); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 6); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129\166\ACK\241", _pubPktID = 26446, -// _pubBody = "h'uL\n\225\221gp\182{\140\DC4\136\151c\170\191\r|\214\197\&7", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\242\EM\182T\137\181\\_\NUL\137\135\&0\211", _pubPktID = 31937, _pubBody = +// "\242\196\240\145t\150mj\CANV\251\200\142o\192\150G", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x3d, 0x1f, 0x0, 0x4, 0x81, 0xa6, 0x6, 0xf1, 0x67, 0x4e, 0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, - 0x67, 0x70, 0xb6, 0x7b, 0x8c, 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; - uint8_t topic_bytes[] = {0x81, 0xa6, 0x6, 0xf1}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x22, 0x0, 0xd, 0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, + 0x0, 0x89, 0x87, 0x30, 0xd3, 0x7c, 0xc1, 0xf2, 0xc4, 0xf0, 0x91, 0x74, + 0x96, 0x6d, 0x6a, 0x18, 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; + uint8_t topic_bytes[] = {0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, 0x67, 0x70, 0xb6, 0x7b, 0x8c, - 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + uint8_t msg_bytes[] = {0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, + 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 26446, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31937, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129\166\ACK\241", _pubPktID = 26446, -// _pubBody = "h'uL\n\225\221gp\182{\140\DC4\136\151c\170\191\r|\214\197\&7", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\242\EM\182T\137\181\\_\NUL\137\135\&0\211", _pubPktID = 31937, _pubBody = +// "\242\196\240\145t\150mj\CANV\251\200\142o\192\150G", _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x3d, 0x1f, 0x0, 0x4, 0x81, 0xa6, 0x6, 0xf1, 0x67, 0x4e, 0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, - 0x67, 0x70, 0xb6, 0x7b, 0x8c, 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + uint8_t pkt[] = {0x35, 0x22, 0x0, 0xd, 0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, + 0x0, 0x89, 0x87, 0x30, 0xd3, 0x7c, 0xc1, 0xf2, 0xc4, 0xf0, 0x91, 0x74, + 0x96, 0x6d, 0x6a, 0x18, 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -401,55 +413,51 @@ TEST(Publish311QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x81, 0xa6, 0x6, 0xf1}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, 0x67, 0x70, 0xb6, 0x7b, 0x8c, - 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, + 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 26446); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 23); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); + EXPECT_EQ(packet_id, 31937); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "}\250\132\234S\200EV\164\175\218\237D", _pubPktID = 25658, _pubBody = -// "\DLE\DC3\242\235C\134\216h\196\ETB\255\169\164\222", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q", _pubPktID = 31364, _pubBody = +// "J\NAK\203\196\226\"\223\GS\200a", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x3d, 0x1f, 0x0, 0xd, 0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44, - 0x64, 0x3a, 0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; - uint8_t topic_bytes[] = {0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0xf, 0x0, 0x1, 0x71, 0x7a, 0x84, 0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; + uint8_t topic_bytes[] = {0x71}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + uint8_t msg_bytes[] = {0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 10; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25658, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31364, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "}\250\132\234S\200EV\164\175\218\237D", _pubPktID = 25658, _pubBody = -// "\DLE\DC3\242\235C\134\216h\196\ETB\255\169\164\222", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q", _pubPktID = 31364, _pubBody = +// "J\NAK\203\196\226\"\223\GS\200a", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x3d, 0x1f, 0x0, 0xd, 0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44, - 0x64, 0x3a, 0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + uint8_t pkt[] = {0x33, 0xf, 0x0, 0x1, 0x71, 0x7a, 0x84, 0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -458,57 +466,57 @@ TEST(Publish311QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0x71}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 25658); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_EQ(packet_id, 31364); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\ETB\EM\FSn\\^\219_\249\191\CAN\146\196\142\252x\187\173 \r\244[B\136h\210\180", _pubPktID = 12697, _pubBody = -// "\208\EOT\241", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\144\171\130\USB\155\212\163\136\212\154", _pubPktID = 8173, _pubBody = +// "\142\178\132u\236\130\153F\CANno\142\151\241\209\208\162\246\156\249\199", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x1b, 0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, - 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, - 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4, 0x31, 0x99, 0xd0, 0x4, 0xf1}; - uint8_t topic_bytes[] = {0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, - 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x24, 0x0, 0xb, 0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, + 0xd4, 0x9a, 0x1f, 0xed, 0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, + 0x6e, 0x6f, 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; + uint8_t topic_bytes[] = {0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xd0, 0x4, 0xf1}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, + 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 12697, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8173, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\ETB\EM\FSn\\^\219_\249\191\CAN\146\196\142\252x\187\173 \r\244[B\136h\210\180", _pubPktID = 12697, _pubBody = -// "\208\EOT\241", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\144\171\130\USB\155\212\163\136\212\154", _pubPktID = 8173, _pubBody = +// "\142\178\132u\236\130\153F\CANno\142\151\241\209\208\162\246\156\249\199", _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x3c, 0x22, 0x0, 0x1b, 0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, - 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, - 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4, 0x31, 0x99, 0xd0, 0x4, 0xf1}; + uint8_t pkt[] = {0x33, 0x24, 0x0, 0xb, 0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, + 0xd4, 0x9a, 0x1f, 0xed, 0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, + 0x6e, 0x6f, 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -517,56 +525,54 @@ TEST(Publish311QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, - 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd0, 0x4, 0xf1}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 12697); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + uint8_t exp_topic_bytes[] = {0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, + 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 8173); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\207\219\241(topic.data), 8); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + uint8_t exp_topic_bytes[] = {0x40, 0xb3, 0xa0}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2b, 0x3e, 0xf, 0x1b, 0x82, 0x5e, 0xd5, 0xad, 0x93, 0xa7, 0x44, 0x1c, + 0xfe, 0x99, 0xda, 0x63, 0xed, 0x85, 0xdc, 0x9c, 0x5a, 0x6b, 0xd3, 0xcf}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 5779); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\218\230\US\223|\136nz\184\f)s\246ht", _pubPktID = 0, _pubBody = "\209", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "P\177\NAK.\190\171\224\139\&2\248]=\179n\DC4k\146\152\175\210\205`3|\135\&8i\209", _pubPktID = 19270, _pubBody = +// "\134\ENQKL\159E.\211+^\240\187\146\NAK7dRg\129.m\133\DLE\152C\ESCJ\160\203", _pubProps = []} TEST(Publish311QCTest, Encode11) { - uint8_t pkt[] = {0x39, 0x12, 0x0, 0xf, 0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, - 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74, 0xd1}; - uint8_t topic_bytes[] = {0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x3d, 0x0, 0x1c, 0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, + 0xb3, 0x6e, 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1, + 0x4b, 0x46, 0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, + 0x37, 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; + uint8_t topic_bytes[] = {0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, 0xb3, 0x6e, + 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xd1}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, + 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 29; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19270, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\218\230\US\223|\136nz\184\f)s\246ht", _pubPktID = 0, _pubBody = "\209", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "P\177\NAK.\190\171\224\139\&2\248]=\179n\DC4k\146\152\175\210\205`3|\135\&8i\209", _pubPktID = 19270, _pubBody = +// "\134\ENQKL\159E.\211+^\240\187\146\NAK7dRg\129.m\133\DLE\152C\ESCJ\160\203", _pubProps = []} TEST(Publish311QCTest, Decode11) { - uint8_t pkt[] = {0x39, 0x12, 0x0, 0xf, 0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, - 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74, 0xd1}; + uint8_t pkt[] = {0x32, 0x3d, 0x0, 0x1c, 0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, + 0xb3, 0x6e, 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1, + 0x4b, 0x46, 0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, + 0x37, 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -630,58 +644,57 @@ TEST(Publish311QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd1}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + uint8_t exp_topic_bytes[] = {0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, 0xb3, 0x6e, + 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, + 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 19270); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\185\207+s\131Y\252\238R\EOT\183\224\v\195'\154V\SUB\214", _pubPktID = 0, _pubBody = -// "n\190=U\SI\224\255\fT\157I\150?Z\SI\215\177\163\143\SUB", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DLE", _pubPktID = 0, _pubBody = +// "\DC4s\199\ACKg\249\133\ENQ\157\223\145\&2NM^T\137xH3\226=j,\r\239U\ACK\153\210", _pubProps = []} TEST(Publish311QCTest, Encode12) { - uint8_t pkt[] = {0x31, 0x29, 0x0, 0x13, 0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, 0xb7, - 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6, 0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, - 0xc, 0x54, 0x9d, 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; - uint8_t topic_bytes[] = {0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, - 0xb7, 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x21, 0x0, 0x1, 0x10, 0x14, 0x73, 0xc7, 0x6, 0x67, 0xf9, 0x85, + 0x5, 0x9d, 0xdf, 0x91, 0x32, 0x4e, 0x4d, 0x5e, 0x54, 0x89, 0x78, 0x48, + 0x33, 0xe2, 0x3d, 0x6a, 0x2c, 0xd, 0xef, 0x55, 0x6, 0x99, 0xd2}; + uint8_t topic_bytes[] = {0x10}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, - 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + uint8_t msg_bytes[] = {0x14, 0x73, 0xc7, 0x6, 0x67, 0xf9, 0x85, 0x5, 0x9d, 0xdf, 0x91, 0x32, 0x4e, 0x4d, 0x5e, + 0x54, 0x89, 0x78, 0x48, 0x33, 0xe2, 0x3d, 0x6a, 0x2c, 0xd, 0xef, 0x55, 0x6, 0x99, 0xd2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 30; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\185\207+s\131Y\252\238R\EOT\183\224\v\195'\154V\SUB\214", _pubPktID = 0, _pubBody = -// "n\190=U\SI\224\255\fT\157I\150?Z\SI\215\177\163\143\SUB", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DLE", _pubPktID = 0, _pubBody = +// "\DC4s\199\ACKg\249\133\ENQ\157\223\145\&2NM^T\137xH3\226=j,\r\239U\ACK\153\210", _pubProps = []} TEST(Publish311QCTest, Decode12) { - uint8_t pkt[] = {0x31, 0x29, 0x0, 0x13, 0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, 0xb7, - 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6, 0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, - 0xc, 0x54, 0x9d, 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + uint8_t pkt[] = {0x39, 0x21, 0x0, 0x1, 0x10, 0x14, 0x73, 0xc7, 0x6, 0x67, 0xf9, 0x85, + 0x5, 0x9d, 0xdf, 0x91, 0x32, 0x4e, 0x4d, 0x5e, 0x54, 0x89, 0x78, 0x48, + 0x33, 0xe2, 0x3d, 0x6a, 0x2c, 0xd, 0xef, 0x55, 0x6, 0x99, 0xd2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -690,62 +703,58 @@ TEST(Publish311QCTest, Decode12) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, - 0xb7, 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6}; - lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, - 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x10}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x14, 0x73, 0xc7, 0x6, 0x67, 0xf9, 0x85, 0x5, 0x9d, 0xdf, 0x91, 0x32, 0x4e, 0x4d, 0x5e, + 0x54, 0x89, 0x78, 0x48, 0x33, 0xe2, 0x3d, 0x6a, 0x2c, 0xd, 0xef, 0x55, 0x6, 0x99, 0xd2}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "-\224\164\222\163\DLE\224\218\229\CAN!n\rZ\193Y\DC3r\129\219T\172\139\252\&2~", _pubPktID = 8532, _pubBody = -// "\145b$\DEL\237\176\245E\250\186\STX\US|\163\f\221\190&\238\vu\US", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\171b\DC1\233\"[\161x\tR2\b\143\ap\176)0\156/\230\155\ETBx\154h*|", _pubPktID = 3357, _pubBody = "\139", _pubProps = +// []} TEST(Publish311QCTest, Encode13) { - uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x1a, 0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, - 0x21, 0x6e, 0xd, 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, - 0x32, 0x7e, 0x21, 0x54, 0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, - 0x2, 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; - uint8_t topic_bytes[] = {0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, 0x21, 0x6e, 0xd, - 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, 0x32, 0x7e}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x21, 0x0, 0x1c, 0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, + 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, + 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c, 0xd, 0x1d, 0x8b}; + uint8_t topic_bytes[] = {0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, + 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, 0x2, - 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; + msg.retained = false; + uint8_t msg_bytes[] = {0x8b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 1; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 8532, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 3357, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "-\224\164\222\163\DLE\224\218\229\CAN!n\rZ\193Y\DC3r\129\219T\172\139\252\&2~", _pubPktID = 8532, _pubBody = -// "\145b$\DEL\237\176\245E\250\186\STX\US|\163\f\221\190&\238\vu\US", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\171b\DC1\233\"[\161x\tR2\b\143\ap\176)0\156/\230\155\ETBx\154h*|", _pubPktID = 3357, _pubBody = "\139", _pubProps = +// []} TEST(Publish311QCTest, Decode13) { - uint8_t pkt[] = {0x3d, 0x34, 0x0, 0x1a, 0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, - 0x21, 0x6e, 0xd, 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, - 0x32, 0x7e, 0x21, 0x54, 0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, - 0x2, 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; + uint8_t pkt[] = {0x3c, 0x21, 0x0, 0x1c, 0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, + 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, + 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c, 0xd, 0x1d, 0x8b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -754,54 +763,61 @@ TEST(Publish311QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, 0x21, 0x6e, 0xd, - 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, 0x32, 0x7e}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, 0x2, - 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, + 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8b}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 8532); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 3357); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "8(\GS\144\187\237\&8\196sz", -// _pubPktID = 0, _pubBody = "0zBlyt\159", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\243\197\208\135\165\n\174^Z4\184\231\152+\166\ETX\175`\187\229\171:\143\196\rO\140G", _pubPktID = 31669, _pubBody = +// "\165yk,.\240\234\134]\245eA\SI\171\146\201\234a.\165", _pubProps = []} TEST(Publish311QCTest, Encode14) { - uint8_t pkt[] = {0x39, 0x13, 0x0, 0xa, 0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, - 0xc4, 0x73, 0x7a, 0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; - uint8_t topic_bytes[] = {0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x34, 0x0, 0x1c, 0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, + 0xb8, 0xe7, 0x98, 0x2b, 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, + 0xd, 0x4f, 0x8c, 0x47, 0x7b, 0xb5, 0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, + 0x5d, 0xf5, 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; + uint8_t topic_bytes[] = {0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, 0x2b, + 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, 0x5d, 0xf5, + 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 20; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31669, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "8(\GS\144\187\237\&8\196sz", -// _pubPktID = 0, _pubBody = "0zBlyt\159", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\243\197\208\135\165\n\174^Z4\184\231\152+\166\ETX\175`\187\229\171:\143\196\rO\140G", _pubPktID = 31669, _pubBody = +// "\165yk,.\240\234\134]\245eA\SI\171\146\201\234a.\165", _pubProps = []} TEST(Publish311QCTest, Decode14) { - uint8_t pkt[] = {0x39, 0x13, 0x0, 0xa, 0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, - 0xc4, 0x73, 0x7a, 0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + uint8_t pkt[] = {0x34, 0x34, 0x0, 0x1c, 0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, + 0xb8, 0xe7, 0x98, 0x2b, 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, + 0xd, 0x4f, 0x8c, 0x47, 0x7b, 0xb5, 0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, + 0x5d, 0xf5, 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -810,58 +826,59 @@ TEST(Publish311QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + uint8_t exp_topic_bytes[] = {0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, 0x2b, + 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, 0x5d, 0xf5, + 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 31669); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ")F\t\CAN\159&z\212\EOT\210y\239\190\EOT\131b\161\153I\235\162", _pubPktID = 2063, _pubBody = -// "\SUB\236\&0\ENQ\ACK1\246q@\SUB\224\&3{\175\RS\142k\"", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\v\172h\241z\159Z'\153h\STXiS.\STX&a\166|\147~\ETBbP\194\242$`q", _pubPktID = 29118, _pubBody = +// "\155\GS\134h\241\DC2\174", _pubProps = []} TEST(Publish311QCTest, Encode15) { - uint8_t pkt[] = {0x34, 0x2b, 0x0, 0x15, 0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, - 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2, 0x8, 0xf, 0x1a, 0xec, 0x30, - 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; - uint8_t topic_bytes[] = {0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, - 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x28, 0x0, 0x1d, 0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, + 0x2, 0x69, 0x53, 0x2e, 0x2, 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, + 0xc2, 0xf2, 0x24, 0x60, 0x71, 0x71, 0xbe, 0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; + uint8_t topic_bytes[] = {0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, 0x53, 0x2e, 0x2, + 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x1a, 0xec, 0x30, 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, - 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 7; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 2063, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29118, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ")F\t\CAN\159&z\212\EOT\210y\239\190\EOT\131b\161\153I\235\162", _pubPktID = 2063, _pubBody = -// "\SUB\236\&0\ENQ\ACK1\246q@\SUB\224\&3{\175\RS\142k\"", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\v\172h\241z\159Z'\153h\STXiS.\STX&a\166|\147~\ETBbP\194\242$`q", _pubPktID = 29118, _pubBody = +// "\155\GS\134h\241\DC2\174", _pubProps = []} TEST(Publish311QCTest, Decode15) { - uint8_t pkt[] = {0x34, 0x2b, 0x0, 0x15, 0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, - 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2, 0x8, 0xf, 0x1a, 0xec, 0x30, - 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + uint8_t pkt[] = {0x33, 0x28, 0x0, 0x1d, 0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, + 0x2, 0x69, 0x53, 0x2e, 0x2, 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, + 0xc2, 0xf2, 0x24, 0x60, 0x71, 0x71, 0xbe, 0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -870,57 +887,61 @@ TEST(Publish311QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, - 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1a, 0xec, 0x30, 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, - 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, 0x53, 0x2e, 0x2, + 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2063); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 29118); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\\Z\DLE\\x\DC3\192\DLE", _pubPktID = -// 15081, _pubBody = "\213\141\182\137f\134\150z.K\232\224o\177\FS\156\198\158\CAN\ESC", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "q+J\205\r\197\201+\DLE\216\DC4\207\206\SI\242\241\137\SUB\213\246\&1\NUL%\242b\204", _pubPktID = 0, _pubBody = +// "\137[\151L+\\\238\187\158\137/}8}\vL\159\208\134\DC4\192", _pubProps = []} TEST(Publish311QCTest, Encode16) { - uint8_t pkt[] = {0x35, 0x20, 0x0, 0x8, 0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10, - 0x3a, 0xe9, 0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, - 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; - uint8_t topic_bytes[] = {0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x31, 0x0, 0x1a, 0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, + 0xd8, 0x14, 0xcf, 0xce, 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, + 0x25, 0xf2, 0x62, 0xcc, 0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, + 0x89, 0x2f, 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; + uint8_t topic_bytes[] = {0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, 0xd8, 0x14, 0xcf, 0xce, + 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, 0x25, 0xf2, 0x62, 0xcc}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, - 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + uint8_t msg_bytes[] = {0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, 0x89, 0x2f, + 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 15081, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\\Z\DLE\\x\DC3\192\DLE", _pubPktID = -// 15081, _pubBody = "\213\141\182\137f\134\150z.K\232\224o\177\FS\156\198\158\CAN\ESC", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "q+J\205\r\197\201+\DLE\216\DC4\207\206\SI\242\241\137\SUB\213\246\&1\NUL%\242b\204", _pubPktID = 0, _pubBody = +// "\137[\151L+\\\238\187\158\137/}8}\vL\159\208\134\DC4\192", _pubProps = []} TEST(Publish311QCTest, Decode16) { - uint8_t pkt[] = {0x35, 0x20, 0x0, 0x8, 0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10, - 0x3a, 0xe9, 0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, - 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + uint8_t pkt[] = {0x39, 0x31, 0x0, 0x1a, 0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, + 0xd8, 0x14, 0xcf, 0xce, 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, + 0x25, 0xf2, 0x62, 0xcc, 0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, + 0x89, 0x2f, 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -929,53 +950,52 @@ TEST(Publish311QCTest, Decode16) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, - 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, 0xd8, 0x14, 0xcf, 0xce, + 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, 0x25, 0xf2, 0x62, 0xcc}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, 0x89, 0x2f, + 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 15081); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "~2\242\136\211*\DEL", _pubPktID = -// 30428, _pubBody = "\253ET\175\214\175\205\211w\196\ETX\f-\214\144\194", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "6", _pubPktID = 0, _pubBody = "b", +// _pubProps = []} TEST(Publish311QCTest, Encode17) { - uint8_t pkt[] = {0x3b, 0x1b, 0x0, 0x7, 0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f, 0x76, 0xdc, 0xfd, 0x45, - 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; - uint8_t topic_bytes[] = {0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x4, 0x0, 0x1, 0x36, 0x62}; + uint8_t topic_bytes[] = {0x36}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xfd, 0x45, 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + uint8_t msg_bytes[] = {0x62}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 1; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30428, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "~2\242\136\211*\DEL", _pubPktID = -// 30428, _pubBody = "\253ET\175\214\175\205\211w\196\ETX\f-\214\144\194", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "6", _pubPktID = 0, _pubBody = "b", +// _pubProps = []} TEST(Publish311QCTest, Decode17) { - uint8_t pkt[] = {0x3b, 0x1b, 0x0, 0x7, 0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f, 0x76, 0xdc, 0xfd, 0x45, - 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + uint8_t pkt[] = {0x31, 0x4, 0x0, 0x1, 0x36, 0x62}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -984,58 +1004,52 @@ TEST(Publish311QCTest, Decode17) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfd, 0x45, 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, - 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x36}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x62}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 30428); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "dG\194+K1e\237n\253\EM\US\222\156\216K\173\158+\228\&9E\185\CAN\147`\203un\n", _pubPktID = 16078, _pubBody = "", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\184\EOT\177\237[w\205\DC4E\GS@", +// _pubPktID = 11334, _pubBody = "\247ax\ESCb", _pubProps = []} TEST(Publish311QCTest, Encode18) { - uint8_t pkt[] = {0x32, 0x22, 0x0, 0x1e, 0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, - 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, 0x4b, 0xad, 0x9e, 0x2b, 0xe4, - 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa, 0x3e, 0xce}; - uint8_t topic_bytes[] = {0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, - 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x15, 0x0, 0xc, 0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, + 0x14, 0x45, 0x1d, 0x40, 0x2c, 0x46, 0xf7, 0x61, 0x78, 0x1b, 0x62}; + uint8_t topic_bytes[] = {0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, 0x14, 0x45, 0x1d, 0x40}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0}; + msg.retained = true; + uint8_t msg_bytes[] = {0xf7, 0x61, 0x78, 0x1b, 0x62}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 5; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 16078, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 11334, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "dG\194+K1e\237n\253\EM\US\222\156\216K\173\158+\228\&9E\185\CAN\147`\203un\n", _pubPktID = 16078, _pubBody = "", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\184\EOT\177\237[w\205\DC4E\GS@", +// _pubPktID = 11334, _pubBody = "\247ax\ESCb", _pubProps = []} TEST(Publish311QCTest, Decode18) { - uint8_t pkt[] = {0x32, 0x22, 0x0, 0x1e, 0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, - 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, 0x4b, 0xad, 0x9e, 0x2b, 0xe4, - 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa, 0x3e, 0xce}; + uint8_t pkt[] = {0x3b, 0x15, 0x0, 0xc, 0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, + 0x14, 0x45, 0x1d, 0x40, 0x2c, 0x46, 0xf7, 0x61, 0x78, 0x1b, 0x62}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1044,42 +1058,39 @@ TEST(Publish311QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, - 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa}; - lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, 0x14, 0x45, 0x1d, 0x40}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf7, 0x61, 0x78, 0x1b, 0x62}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 16078); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 11334); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "?\DC1;Y\196\211\145n\198\234\233\176_,\224\194\182X\250J\NUL_\198\186\&5\173\224W", _pubPktID = 0, _pubBody = -// "\189?\ag\226\204+\195v\STX4\147\165\167h\131}n\149j\208", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\tm5\139\DC1\DC18\255>\b\a\EM\145\213XbT\218|", _pubPktID = 0, _pubBody = "\DC4\GS+\EM\ESC\132B\172\232|\215", +// _pubProps = []} TEST(Publish311QCTest, Encode19) { - uint8_t pkt[] = {0x30, 0x33, 0x0, 0x1c, 0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, - 0xe9, 0xb0, 0x5f, 0x2c, 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, - 0x35, 0xad, 0xe0, 0x57, 0xbd, 0x3f, 0x7, 0x67, 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, - 0x34, 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; - uint8_t topic_bytes[] = {0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, 0xe9, 0xb0, 0x5f, 0x2c, - 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, 0x35, 0xad, 0xe0, 0x57}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x20, 0x0, 0x13, 0x9, 0x6d, 0x35, 0x8b, 0x11, 0x11, 0x38, 0xff, + 0x3e, 0x8, 0x7, 0x19, 0x91, 0xd5, 0x58, 0x62, 0x54, 0xda, 0x7c, 0x14, + 0x1d, 0x2b, 0x19, 0x1b, 0x84, 0x42, 0xac, 0xe8, 0x7c, 0xd7}; + uint8_t topic_bytes[] = {0x9, 0x6d, 0x35, 0x8b, 0x11, 0x11, 0x38, 0xff, 0x3e, 0x8, + 0x7, 0x19, 0x91, 0xd5, 0x58, 0x62, 0x54, 0xda, 0x7c}; + lwmqtt_string_t topic = {19, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xbd, 0x3f, 0x7, 0x67, 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, 0x34, - 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; + msg.retained = true; + uint8_t msg_bytes[] = {0x14, 0x1d, 0x2b, 0x19, 0x1b, 0x84, 0x42, 0xac, 0xe8, 0x7c, 0xd7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 11; lwmqtt_property_t propslist[] = {}; @@ -1091,14 +1102,13 @@ TEST(Publish311QCTest, Encode19) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "?\DC1;Y\196\211\145n\198\234\233\176_,\224\194\182X\250J\NUL_\198\186\&5\173\224W", _pubPktID = 0, _pubBody = -// "\189?\ag\226\204+\195v\STX4\147\165\167h\131}n\149j\208", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\tm5\139\DC1\DC18\255>\b\a\EM\145\213XbT\218|", _pubPktID = 0, _pubBody = "\DC4\GS+\EM\ESC\132B\172\232|\215", +// _pubProps = []} TEST(Publish311QCTest, Decode19) { - uint8_t pkt[] = {0x30, 0x33, 0x0, 0x1c, 0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, - 0xe9, 0xb0, 0x5f, 0x2c, 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, - 0x35, 0xad, 0xe0, 0x57, 0xbd, 0x3f, 0x7, 0x67, 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, - 0x34, 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; + uint8_t pkt[] = {0x31, 0x20, 0x0, 0x13, 0x9, 0x6d, 0x35, 0x8b, 0x11, 0x11, 0x38, 0xff, + 0x3e, 0x8, 0x7, 0x19, 0x91, 0xd5, 0x58, 0x62, 0x54, 0xda, 0x7c, 0x14, + 0x1d, 0x2b, 0x19, 0x1b, 0x84, 0x42, 0xac, 0xe8, 0x7c, 0xd7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1107,59 +1117,58 @@ TEST(Publish311QCTest, Decode19) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3f, 0x11, 0x3b, 0x59, 0xc4, 0xd3, 0x91, 0x6e, 0xc6, 0xea, 0xe9, 0xb0, 0x5f, 0x2c, - 0xe0, 0xc2, 0xb6, 0x58, 0xfa, 0x4a, 0x0, 0x5f, 0xc6, 0xba, 0x35, 0xad, 0xe0, 0x57}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbd, 0x3f, 0x7, 0x67, 0xe2, 0xcc, 0x2b, 0xc3, 0x76, 0x2, 0x34, - 0x93, 0xa5, 0xa7, 0x68, 0x83, 0x7d, 0x6e, 0x95, 0x6a, 0xd0}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x9, 0x6d, 0x35, 0x8b, 0x11, 0x11, 0x38, 0xff, 0x3e, 0x8, + 0x7, 0x19, 0x91, 0xd5, 0x58, 0x62, 0x54, 0xda, 0x7c}; + lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x14, 0x1d, 0x2b, 0x19, 0x1b, 0x84, 0x42, 0xac, 0xe8, 0x7c, 0xd7}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "D\SUBc\224\DC3\202\&3\187\&84T\240", _pubPktID = 22665, _pubBody = -// "EV\174.\183\&1Q\DC1\216V\203p>q=x\132\163(\239\143\135b\236\137\&6", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\211Q\204\149\142\&8\217\174\213\221\133\214\221\166\207E\151\t\221y\192>\ETBqK[", _pubPktID = 0, _pubBody = +// "\189\221\169\130\f\211\DC1\DC2\252", _pubProps = []} TEST(Publish311QCTest, Encode20) { - uint8_t pkt[] = {0x32, 0x2a, 0x0, 0xc, 0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, - 0xf0, 0x58, 0x89, 0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, - 0x3e, 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; - uint8_t topic_bytes[] = {0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, 0xf0}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x25, 0x0, 0x1a, 0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, + 0xdd, 0x85, 0xd6, 0xdd, 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, + 0x17, 0x71, 0x4b, 0x5b, 0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; + uint8_t topic_bytes[] = {0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, 0xdd, + 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, 0x3e, - 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + uint8_t msg_bytes[] = {0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 9; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 22665, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "D\SUBc\224\DC3\202\&3\187\&84T\240", _pubPktID = 22665, _pubBody = -// "EV\174.\183\&1Q\DC1\216V\203p>q=x\132\163(\239\143\135b\236\137\&6", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\211Q\204\149\142\&8\217\174\213\221\133\214\221\166\207E\151\t\221y\192>\ETBqK[", _pubPktID = 0, _pubBody = +// "\189\221\169\130\f\211\DC1\DC2\252", _pubProps = []} TEST(Publish311QCTest, Decode20) { - uint8_t pkt[] = {0x32, 0x2a, 0x0, 0xc, 0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, - 0xf0, 0x58, 0x89, 0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, - 0x3e, 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + uint8_t pkt[] = {0x30, 0x25, 0x0, 0x1a, 0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, + 0xdd, 0x85, 0xd6, 0xdd, 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, + 0x17, 0x71, 0x4b, 0x5b, 0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1168,40 +1177,40 @@ TEST(Publish311QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, 0xf0}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, 0x3e, - 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, 0xdd, + 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 22665); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\230\f\162\233\EOT\DC3\171\130\175!\217\131n\254\197\128m$;\254w\217O\ETX0\241c\223", _pubPktID = 0, _pubBody = -// ";]t:N\225`\ETX\239\239R\FS\135\144", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "p\211K\218>w\SOHst%h%\249P\an\SYNF\157q=]", _pubPktID = 0, _pubBody = "\135 \184\208\200\r\GSu\205w\SOHst%h%\249P\an\SYNF\157q=]", _pubPktID = 0, _pubBody = "\135 \184\208\200\r\GSu\205(topic.data), 28); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\DEL\ETX\153\229\248dS\153`\SOH\167\230\142f\DC1\233\135#<\250\245dX!\172\177\&9,\148", _pubPktID = 23552, _pubBody -// = "\165\207\195k*4\RS", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\249", _pubPktID = 7383, _pubBody = +// "\166\v\241D\ESCtx4\151\196\206=\239 r\RS\159\195\249NT_", _pubProps = []} TEST(Publish311QCTest, Encode22) { - uint8_t pkt[] = {0x3d, 0x28, 0x0, 0x1d, 0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, - 0xa7, 0xe6, 0x8e, 0x66, 0x11, 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, - 0xac, 0xb1, 0x39, 0x2c, 0x94, 0x5c, 0x0, 0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; - uint8_t topic_bytes[] = {0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, 0x8e, 0x66, 0x11, - 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, 0x94}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x1b, 0x0, 0x1, 0xf9, 0x1c, 0xd7, 0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, 0x34, + 0x97, 0xc4, 0xce, 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; + uint8_t topic_bytes[] = {0xf9}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, 0x34, 0x97, 0xc4, 0xce, + 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 23552, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7383, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\DEL\ETX\153\229\248dS\153`\SOH\167\230\142f\DC1\233\135#<\250\245dX!\172\177\&9,\148", _pubPktID = 23552, _pubBody -// = "\165\207\195k*4\RS", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\249", _pubPktID = 7383, _pubBody = +// "\166\v\241D\ESCtx4\151\196\206=\239 r\RS\159\195\249NT_", _pubProps = []} TEST(Publish311QCTest, Decode22) { - uint8_t pkt[] = {0x3d, 0x28, 0x0, 0x1d, 0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, - 0xa7, 0xe6, 0x8e, 0x66, 0x11, 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, - 0xac, 0xb1, 0x39, 0x2c, 0x94, 0x5c, 0x0, 0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + uint8_t pkt[] = {0x32, 0x1b, 0x0, 0x1, 0xf9, 0x1c, 0xd7, 0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, 0x34, + 0x97, 0xc4, 0xce, 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1288,51 +1293,61 @@ TEST(Publish311QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, 0x8e, 0x66, 0x11, - 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, 0x94}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 23552); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + uint8_t exp_topic_bytes[] = {0xf9}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, 0x34, 0x97, 0xc4, 0xce, + 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7383); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163\132d\157\149", _pubPktID = -// 24502, _pubBody = "\224h\ACK", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\156\249\196\168\224\205\FS\219\244\128\231\SYN\252\239j\NAK\164\171G]\133\229\147Q\199(\f\249y", _pubPktID = 11390, +// _pubBody = "s\226]\184\NUL\176A\242\&3\195\ETBC\RSN\254\t\t\\\203\255=\180B\201k\163", _pubProps = []} TEST(Publish311QCTest, Encode23) { - uint8_t pkt[] = {0x34, 0xc, 0x0, 0x5, 0xa3, 0x84, 0x64, 0x9d, 0x95, 0x5f, 0xb6, 0xe0, 0x68, 0x6}; - uint8_t topic_bytes[] = {0xa3, 0x84, 0x64, 0x9d, 0x95}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x3b, 0x0, 0x1d, 0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, + 0xfc, 0xef, 0x6a, 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, + 0x79, 0x2c, 0x7e, 0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, + 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; + uint8_t topic_bytes[] = {0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, 0x6a, + 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, 0x79}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xe0, 0x68, 0x6}; + uint8_t msg_bytes[] = {0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, + 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 26; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 24502, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 11390, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163\132d\157\149", _pubPktID = -// 24502, _pubBody = "\224h\ACK", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\156\249\196\168\224\205\FS\219\244\128\231\SYN\252\239j\NAK\164\171G]\133\229\147Q\199(\f\249y", _pubPktID = 11390, +// _pubBody = "s\226]\184\NUL\176A\242\&3\195\ETBC\RSN\254\t\t\\\203\255=\180B\201k\163", _pubProps = []} TEST(Publish311QCTest, Decode23) { - uint8_t pkt[] = {0x34, 0xc, 0x0, 0x5, 0xa3, 0x84, 0x64, 0x9d, 0x95, 0x5f, 0xb6, 0xe0, 0x68, 0x6}; + uint8_t pkt[] = {0x3a, 0x3b, 0x0, 0x1d, 0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, + 0xfc, 0xef, 0x6a, 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, + 0x79, 0x2c, 0x7e, 0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, + 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1341,55 +1356,60 @@ TEST(Publish311QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa3, 0x84, 0x64, 0x9d, 0x95}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xe0, 0x68, 0x6}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, 0x6a, + 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, 0x79}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, + 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 24502); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(packet_id, 11390); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\153\164\218\195=\160\170\223\157 -// b%X\222\199hG0\198K3y\207\128J\188\176\225", _pubPktID = 0, _pubBody = "\SOH\191\156", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\247\&51\173<\172\250\229U\SOH\214a\211n>\225\&2^", _pubPktID = 0, _pubBody = +// "\r\136\219Jg\197\169\234\190\251\255K\212\139c\186,\229", _pubProps = []} TEST(Publish311QCTest, Encode24) { - uint8_t pkt[] = {0x38, 0x21, 0x0, 0x1c, 0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, - 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, - 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1, 0x1, 0xbf, 0x9c}; - uint8_t topic_bytes[] = {0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, - 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x26, 0x0, 0x12, 0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, 0x1, + 0xd6, 0x61, 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e, 0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, + 0xa9, 0xea, 0xbe, 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; + uint8_t topic_bytes[] = {0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, + 0x1, 0xd6, 0x61, 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x1, 0xbf, 0x9c}; + uint8_t msg_bytes[] = {0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, 0xa9, 0xea, 0xbe, + 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 18; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\153\164\218\195=\160\170\223\157 -// b%X\222\199hG0\198K3y\207\128J\188\176\225", _pubPktID = 0, _pubBody = "\SOH\191\156", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\247\&51\173<\172\250\229U\SOH\214a\211n>\225\&2^", _pubPktID = 0, _pubBody = +// "\r\136\219Jg\197\169\234\190\251\255K\212\139c\186,\229", _pubProps = []} TEST(Publish311QCTest, Decode24) { - uint8_t pkt[] = {0x38, 0x21, 0x0, 0x1c, 0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, - 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, - 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1, 0x1, 0xbf, 0x9c}; + uint8_t pkt[] = {0x30, 0x26, 0x0, 0x12, 0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, 0x1, + 0xd6, 0x61, 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e, 0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, + 0xa9, 0xea, 0xbe, 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1398,58 +1418,59 @@ TEST(Publish311QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, - 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1, 0xbf, 0x9c}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, + 0x1, 0xd6, 0x61, 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, 0xa9, 0xea, 0xbe, + 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "Z\162]m\132\183R\SUBWRu", _pubPktID -// = 13838, _pubBody = -// "{&\208\GS\139\141\&9\162*\207\153\136\148\172\STX\190\162e\RS\\\163\194\141\DC1\SYN\156\204\236", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\DC3 +// \244\212\ETX\143\186\222G-\212", _pubPktID = 0, _pubBody = "cndv<\250\182\170?\140\SYN\204\158n'\161tLKL\DC4\131", +// _pubProps = []} TEST(Publish311QCTest, Encode25) { - uint8_t pkt[] = {0x3a, 0x2b, 0x0, 0xb, 0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75, - 0x36, 0xe, 0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, - 0xac, 0x2, 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; - uint8_t topic_bytes[] = {0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75}; + uint8_t pkt[] = {0x30, 0x23, 0x0, 0xb, 0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, + 0x2d, 0xd4, 0x63, 0x6e, 0x64, 0x76, 0x3c, 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, + 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; + uint8_t topic_bytes[] = {0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, 0x2d, 0xd4}; lwmqtt_string_t topic = {11, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, 0xac, - 0x2, 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; + uint8_t msg_bytes[] = {0x63, 0x6e, 0x64, 0x76, 0x3c, 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, + 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 13838, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "Z\162]m\132\183R\SUBWRu", _pubPktID -// = 13838, _pubBody = -// "{&\208\GS\139\141\&9\162*\207\153\136\148\172\STX\190\162e\RS\\\163\194\141\DC1\SYN\156\204\236", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\DC3 +// \244\212\ETX\143\186\222G-\212", _pubPktID = 0, _pubBody = "cndv<\250\182\170?\140\SYN\204\158n'\161tLKL\DC4\131", +// _pubProps = []} TEST(Publish311QCTest, Decode25) { - uint8_t pkt[] = {0x3a, 0x2b, 0x0, 0xb, 0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75, - 0x36, 0xe, 0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, - 0xac, 0x2, 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; + uint8_t pkt[] = {0x30, 0x23, 0x0, 0xb, 0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, + 0x2d, 0xd4, 0x63, 0x6e, 0x64, 0x76, 0x3c, 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, + 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1458,58 +1479,58 @@ TEST(Publish311QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5a, 0xa2, 0x5d, 0x6d, 0x84, 0xb7, 0x52, 0x1a, 0x57, 0x52, 0x75}; + uint8_t exp_topic_bytes[] = {0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, 0x2d, 0xd4}; lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7b, 0x26, 0xd0, 0x1d, 0x8b, 0x8d, 0x39, 0xa2, 0x2a, 0xcf, 0x99, 0x88, 0x94, 0xac, - 0x2, 0xbe, 0xa2, 0x65, 0x1e, 0x5c, 0xa3, 0xc2, 0x8d, 0x11, 0x16, 0x9c, 0xcc, 0xec}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_body_bytes[] = {0x63, 0x6e, 0x64, 0x76, 0x3c, 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, + 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 13838); + EXPECT_EQ(packet_id, 0); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\245\STX\252\CAN\215\187\FS^!\141\191\250|\190\164I\153\169,U`", _pubPktID = 10215, _pubBody = -// "\199r\153\234\&0UY.\201J\198\SO", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "o#L\177\210\EOT\140\230w\252ir\220-\217\230\154\182\a0(\169\225\232uo", _pubPktID = 0, _pubBody = +// "2\137\n\NUL\201\149\252e\191]\CAN#`\250", _pubProps = []} TEST(Publish311QCTest, Encode26) { - uint8_t pkt[] = {0x33, 0x25, 0x0, 0x15, 0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, - 0x8d, 0xbf, 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60, 0x27, - 0xe7, 0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; - uint8_t topic_bytes[] = {0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, - 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x2a, 0x0, 0x1a, 0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, + 0x72, 0xdc, 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f, + 0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; + uint8_t topic_bytes[] = {0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, + 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + uint8_t msg_bytes[] = {0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 14; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10215, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\245\STX\252\CAN\215\187\FS^!\141\191\250|\190\164I\153\169,U`", _pubPktID = 10215, _pubBody = -// "\199r\153\234\&0UY.\201J\198\SO", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "o#L\177\210\EOT\140\230w\252ir\220-\217\230\154\182\a0(\169\225\232uo", _pubPktID = 0, _pubBody = +// "2\137\n\NUL\201\149\252e\191]\CAN#`\250", _pubProps = []} TEST(Publish311QCTest, Decode26) { - uint8_t pkt[] = {0x33, 0x25, 0x0, 0x15, 0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, - 0x8d, 0xbf, 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60, 0x27, - 0xe7, 0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + uint8_t pkt[] = {0x31, 0x2a, 0x0, 0x1a, 0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, + 0x72, 0xdc, 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f, + 0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1518,36 +1539,35 @@ TEST(Publish311QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, - 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, + 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 10215); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\187\192\216\&6]J\244\v\252\&6\149\EOT\128\ETX", _pubPktID = 11476, _pubBody = -// "\254&\138\150\179\238u\252\176\246'\140\196", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O\216\186", _pubPktID = 31863, +// _pubBody = "\206\US\183\184\207\198X\216\SOn\202 \214", _pubProps = []} TEST(Publish311QCTest, Encode27) { - uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0xe, 0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, - 0x3, 0x2c, 0xd4, 0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; - uint8_t topic_bytes[] = {0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, 0x3}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x14, 0x0, 0x3, 0x4f, 0xd8, 0xba, 0x7c, 0x77, 0xce, 0x1f, + 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; + uint8_t topic_bytes[] = {0x4f, 0xd8, 0xba}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xce, 0x1f, 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 13; @@ -1555,18 +1575,17 @@ TEST(Publish311QCTest, Encode27) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 11476, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 31863, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\187\192\216\&6]J\244\v\252\&6\149\EOT\128\ETX", _pubPktID = 11476, _pubBody = -// "\254&\138\150\179\238u\252\176\246'\140\196", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O\216\186", _pubPktID = 31863, +// _pubBody = "\206\US\183\184\207\198X\216\SOn\202 \214", _pubProps = []} TEST(Publish311QCTest, Decode27) { - uint8_t pkt[] = {0x3a, 0x1f, 0x0, 0xe, 0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, - 0x3, 0x2c, 0xd4, 0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + uint8_t pkt[] = {0x3d, 0x14, 0x0, 0x3, 0x4f, 0xd8, 0xba, 0x7c, 0x77, 0xce, 0x1f, + 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1575,55 +1594,57 @@ TEST(Publish311QCTest, Decode27) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, 0x3}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + uint8_t exp_topic_bytes[] = {0x4f, 0xd8, 0xba}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xce, 0x1f, 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 11476); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 31863); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); EXPECT_EQ(msg.payload_len, 13); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "/\USs\188\193\156\202\143\244\215\159fj\184\STX\DC3\217", _pubPktID = 0, _pubBody = "\213T\157\156*`\174Ad\219\206", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "r8* +// \EM\150\251uUH\DEL\151\232\SOH\RS\240\192\167=\255\246\193\250*<", _pubPktID = 26145, _pubBody = +// "\165\DC2\SOH6&\169\226\233\172\134`\205\149\221__", _pubProps = []} TEST(Publish311QCTest, Encode28) { - uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x11, 0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, 0xd7, 0x9f, 0x66, - 0x6a, 0xb8, 0x2, 0x13, 0xd9, 0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; - uint8_t topic_bytes[] = {0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, - 0xd7, 0x9f, 0x66, 0x6a, 0xb8, 0x2, 0x13, 0xd9}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x2d, 0x0, 0x19, 0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, + 0xe8, 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c, 0x66, 0x21, 0xa5, + 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; + uint8_t topic_bytes[] = {0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, 0xe8, + 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 16; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 26145, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "/\USs\188\193\156\202\143\244\215\159fj\184\STX\DC3\217", _pubPktID = 0, _pubBody = "\213T\157\156*`\174Ad\219\206", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "r8* +// \EM\150\251uUH\DEL\151\232\SOH\RS\240\192\167=\255\246\193\250*<", _pubPktID = 26145, _pubBody = +// "\165\DC2\SOH6&\169\226\233\172\134`\205\149\221__", _pubProps = []} TEST(Publish311QCTest, Decode28) { - uint8_t pkt[] = {0x31, 0x1e, 0x0, 0x11, 0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, 0xd7, 0x9f, 0x66, - 0x6a, 0xb8, 0x2, 0x13, 0xd9, 0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + uint8_t pkt[] = {0x32, 0x2d, 0x0, 0x19, 0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, + 0xe8, 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c, 0x66, 0x21, 0xa5, + 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1632,58 +1653,52 @@ TEST(Publish311QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, - 0xd7, 0x9f, 0x66, 0x6a, 0xb8, 0x2, 0x13, 0xd9}; - lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, 0xe8, + 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, + 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 26145); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\ETXJ\240r\220\200\DLE=\219m\152\EM\205\US\144", _pubPktID = 32504, _pubBody = -// "C\158&\185\DLE\NUL\239\237\184+\SO<\134\"R\EM\232\230\222\ENQ", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 7976, _pubBody = +// "\ENQP\a\164\163\166{\250{", _pubProps = []} TEST(Publish311QCTest, Encode29) { - uint8_t pkt[] = {0x35, 0x27, 0x0, 0xf, 0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, - 0x98, 0x19, 0xcd, 0x1f, 0x90, 0x7e, 0xf8, 0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, - 0xed, 0xb8, 0x2b, 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; - uint8_t topic_bytes[] = {0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, 0xcd, 0x1f, 0x90}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0xd, 0x0, 0x0, 0x1f, 0x28, 0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, - 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + uint8_t msg_bytes[] = {0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 9; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32504, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7976, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\ETXJ\240r\220\200\DLE=\219m\152\EM\205\US\144", _pubPktID = 32504, _pubBody = -// "C\158&\185\DLE\NUL\239\237\184+\SO<\134\"R\EM\232\230\222\ENQ", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 7976, _pubBody = +// "\ENQP\a\164\163\166{\250{", _pubProps = []} TEST(Publish311QCTest, Decode29) { - uint8_t pkt[] = {0x35, 0x27, 0x0, 0xf, 0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, - 0x98, 0x19, 0xcd, 0x1f, 0x90, 0x7e, 0xf8, 0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, - 0xed, 0xb8, 0x2b, 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + uint8_t pkt[] = {0x3b, 0xd, 0x0, 0x0, 0x1f, 0x28, 0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1692,51 +1707,60 @@ TEST(Publish311QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, 0xcd, 0x1f, 0x90}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, - 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 32504); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_EQ(packet_id, 7976); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CAN\n\131L\223F1\229", _pubPktID = -// 0, _pubBody = "\138\228\212\203", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\197\a\164\SUB\DC1\195\RS`\FS\155?\206\154I\134\181\139\252Vc\161i`\DC3\245", _pubPktID = 3213, _pubBody = +// "\249a\NAK\209f+\v\251'\141\199\&6\195s\160^:v\251\&5\174\FS\240\191k\205\"\201\222=", _pubProps = []} TEST(Publish311QCTest, Encode30) { - uint8_t pkt[] = {0x30, 0xe, 0x0, 0x8, 0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5, 0x8a, 0xe4, 0xd4, 0xcb}; - uint8_t topic_bytes[] = {0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x3b, 0x0, 0x19, 0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, + 0x9a, 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5, 0xc, 0x8d, 0xf9, + 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, 0x5e, 0x3a, + 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; + uint8_t topic_bytes[] = {0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, 0x9a, + 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x8a, 0xe4, 0xd4, 0xcb}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xf9, 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, + 0x5e, 0x3a, 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 30; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3213, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CAN\n\131L\223F1\229", _pubPktID = -// 0, _pubBody = "\138\228\212\203", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\197\a\164\SUB\DC1\195\RS`\FS\155?\206\154I\134\181\139\252Vc\161i`\DC3\245", _pubPktID = 3213, _pubBody = +// "\249a\NAK\209f+\v\251'\141\199\&6\195s\160^:v\251\&5\174\FS\240\191k\205\"\201\222=", _pubProps = []} TEST(Publish311QCTest, Decode30) { - uint8_t pkt[] = {0x30, 0xe, 0x0, 0x8, 0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5, 0x8a, 0xe4, 0xd4, 0xcb}; + uint8_t pkt[] = {0x35, 0x3b, 0x0, 0x19, 0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, + 0x9a, 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5, 0xc, 0x8d, 0xf9, + 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, 0x5e, 0x3a, + 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1745,99 +1769,153 @@ TEST(Publish311QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8a, 0xe4, 0xd4, 0xcb}; - lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, 0x9a, + 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf9, 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, + 0x5e, 0x3a, 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 4); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 3213); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\137\189\213\133\214H\EM\161\170\241\136", _pubPktID = 0, _pubBody = "\217\146\229\195\163\175\196\174y0d\141b\146", -// _pubProps = [PropWildcardSubscriptionAvailable 153,PropTopicAliasMaximum 3171,PropContentType -// "\EOT6\189\bp\217'\191\164\GS:\157\177o\254",PropAuthenticationData -// "E]\238\185\207#\n\145\&2\233\253\140\&0",PropTopicAliasMaximum 14538,PropSubscriptionIdentifierAvailable -// 92,PropSubscriptionIdentifier 5,PropRetainAvailable 55,PropReasonString -// "{\167_\GS\209\244\179\245",PropMessageExpiryInterval 27769,PropReasonString -// "\188l\201\168\179\&5\231\253\230\157\226\161\149{\173\DLE\177\222!\146\b.@",PropMaximumQoS 165,PropServerKeepAlive -// 1411,PropMessageExpiryInterval 19809]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "L\255\GS\208o\194\236\140\156\225\135\244\SO\154#", _pubPktID = 6184, _pubBody = +// "_\160\218auw5\192\154w\154\194:T\135\200\157", _pubProps = [PropTopicAliasMaximum +// 15521,PropRequestResponseInformation 202,PropServerReference "",PropServerKeepAlive 27747,PropUserProperty +// "1\250^n\DELx\208e/~\246we" "8,\249\179r\DC2",PropSubscriptionIdentifierAvailable 146,PropSharedSubscriptionAvailable +// 249,PropRetainAvailable 178,PropCorrelationData "\ENQ\231",PropServerReference "F",PropWildcardSubscriptionAvailable +// 173,PropMaximumPacketSize 23566,PropSubscriptionIdentifier 22,PropSubscriptionIdentifierAvailable 53,PropTopicAlias +// 15812,PropServerKeepAlive 31656,PropContentType +// "_\240\vO\162;\136g\247\135\144ae\182;\154\237X\DELCf2\EOT*\171h",PropReasonString +// "\146\r]\239\153\&5r`1#\251",PropResponseTopic +// "G\164\230\178G\CAN\234\254p\DEL\156\250KR\r\219x@\247t\164\141\&9",PropAuthenticationData +// "B]0.\181\174\177\221T\128`D\210\253@\137[\DC2\174\160\245\227\170u\SI{^\241",PropWillDelayInterval +// 30420,PropAuthenticationData "\NUL\245\ETX\229[\STX\140\179V\227\226\220t\DC20\164R",PropReceiveMaximum +// 12547,PropTopicAlias 18835,PropMaximumQoS 44,PropMaximumPacketSize 5027,PropSharedSubscriptionAvailable +// 105,PropTopicAlias 9204,PropServerKeepAlive 4590,PropRequestProblemInformation 67]} TEST(Publish5QCTest, Encode1) { - uint8_t pkt[] = {0x31, 0x80, 0x1, 0x0, 0xb, 0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88, 0x64, - 0x28, 0x99, 0x22, 0xc, 0x63, 0x3, 0x0, 0xf, 0x4, 0x36, 0xbd, 0x8, 0x70, 0xd9, 0x27, 0xbf, 0xa4, - 0x1d, 0x3a, 0x9d, 0xb1, 0x6f, 0xfe, 0x16, 0x0, 0xd, 0x45, 0x5d, 0xee, 0xb9, 0xcf, 0x23, 0xa, 0x91, - 0x32, 0xe9, 0xfd, 0x8c, 0x30, 0x22, 0x38, 0xca, 0x29, 0x5c, 0xb, 0x5, 0x25, 0x37, 0x1f, 0x0, 0x8, - 0x7b, 0xa7, 0x5f, 0x1d, 0xd1, 0xf4, 0xb3, 0xf5, 0x2, 0x0, 0x0, 0x6c, 0x79, 0x1f, 0x0, 0x17, 0xbc, - 0x6c, 0xc9, 0xa8, 0xb3, 0x35, 0xe7, 0xfd, 0xe6, 0x9d, 0xe2, 0xa1, 0x95, 0x7b, 0xad, 0x10, 0xb1, 0xde, - 0x21, 0x92, 0x8, 0x2e, 0x40, 0x24, 0xa5, 0x13, 0x5, 0x83, 0x2, 0x0, 0x0, 0x4d, 0x61, 0xd9, 0x92, - 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; - uint8_t topic_bytes[] = {0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x3c, 0xfd, 0x1, 0x0, 0xf, 0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, + 0x23, 0x18, 0x28, 0xd7, 0x1, 0x22, 0x3c, 0xa1, 0x19, 0xca, 0x1c, 0x0, 0x0, 0x13, 0x6c, 0x63, 0x26, 0x0, 0xd, + 0x31, 0xfa, 0x5e, 0x6e, 0x7f, 0x78, 0xd0, 0x65, 0x2f, 0x7e, 0xf6, 0x77, 0x65, 0x0, 0x6, 0x38, 0x2c, 0xf9, 0xb3, + 0x72, 0x12, 0x29, 0x92, 0x2a, 0xf9, 0x25, 0xb2, 0x9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xc8, 0x9d}; + uint8_t topic_bytes[] = {0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, 0x9a, + 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 17; - uint8_t bytesprops0[] = {0x4, 0x36, 0xbd, 0x8, 0x70, 0xd9, 0x27, 0xbf, 0xa4, 0x1d, 0x3a, 0x9d, 0xb1, 0x6f, 0xfe}; - uint8_t bytesprops1[] = {0x45, 0x5d, 0xee, 0xb9, 0xcf, 0x23, 0xa, 0x91, 0x32, 0xe9, 0xfd, 0x8c, 0x30}; - uint8_t bytesprops2[] = {0x7b, 0xa7, 0x5f, 0x1d, 0xd1, 0xf4, 0xb3, 0xf5}; - uint8_t bytesprops3[] = {0xbc, 0x6c, 0xc9, 0xa8, 0xb3, 0x35, 0xe7, 0xfd, 0xe6, 0x9d, 0xe2, 0xa1, - 0x95, 0x7b, 0xad, 0x10, 0xb1, 0xde, 0x21, 0x92, 0x8, 0x2e, 0x40}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops2[] = {0x38, 0x2c, 0xf9, 0xb3, 0x72, 0x12}; + uint8_t bytesprops1[] = {0x31, 0xfa, 0x5e, 0x6e, 0x7f, 0x78, 0xd0, 0x65, 0x2f, 0x7e, 0xf6, 0x77, 0x65}; + uint8_t bytesprops3[] = {0x5, 0xe7}; + uint8_t bytesprops4[] = {0x46}; + uint8_t bytesprops5[] = {0x5f, 0xf0, 0xb, 0x4f, 0xa2, 0x3b, 0x88, 0x67, 0xf7, 0x87, 0x90, 0x61, 0x65, + 0xb6, 0x3b, 0x9a, 0xed, 0x58, 0x7f, 0x43, 0x66, 0x32, 0x4, 0x2a, 0xab, 0x68}; + uint8_t bytesprops6[] = {0x92, 0xd, 0x5d, 0xef, 0x99, 0x35, 0x72, 0x60, 0x31, 0x23, 0xfb}; + uint8_t bytesprops7[] = {0x47, 0xa4, 0xe6, 0xb2, 0x47, 0x18, 0xea, 0xfe, 0x70, 0x7f, 0x9c, 0xfa, + 0x4b, 0x52, 0xd, 0xdb, 0x78, 0x40, 0xf7, 0x74, 0xa4, 0x8d, 0x39}; + uint8_t bytesprops8[] = {0x42, 0x5d, 0x30, 0x2e, 0xb5, 0xae, 0xb1, 0xdd, 0x54, 0x80, 0x60, 0x44, 0xd2, 0xfd, + 0x40, 0x89, 0x5b, 0x12, 0xae, 0xa0, 0xf5, 0xe3, 0xaa, 0x75, 0xf, 0x7b, 0x5e, 0xf1}; + uint8_t bytesprops9[] = {0x0, 0xf5, 0x3, 0xe5, 0x5b, 0x2, 0x8c, 0xb3, 0x56, + 0xe3, 0xe2, 0xdc, 0x74, 0x12, 0x30, 0xa4, 0x52}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3171}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14538}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27769}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1411}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19809}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15521}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27747}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23566}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15812}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31656}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30420}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12547}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18835}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5027}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9204}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4590}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 67}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6184, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\137\189\213\133\214H\EM\161\170\241\136", _pubPktID = 0, _pubBody = "\217\146\229\195\163\175\196\174y0d\141b\146", -// _pubProps = [PropWildcardSubscriptionAvailable 153,PropTopicAliasMaximum 3171,PropContentType -// "\EOT6\189\bp\217'\191\164\GS:\157\177o\254",PropAuthenticationData -// "E]\238\185\207#\n\145\&2\233\253\140\&0",PropTopicAliasMaximum 14538,PropSubscriptionIdentifierAvailable -// 92,PropSubscriptionIdentifier 5,PropRetainAvailable 55,PropReasonString -// "{\167_\GS\209\244\179\245",PropMessageExpiryInterval 27769,PropReasonString -// "\188l\201\168\179\&5\231\253\230\157\226\161\149{\173\DLE\177\222!\146\b.@",PropMaximumQoS 165,PropServerKeepAlive -// 1411,PropMessageExpiryInterval 19809]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "L\255\GS\208o\194\236\140\156\225\135\244\SO\154#", _pubPktID = 6184, _pubBody = +// "_\160\218auw5\192\154w\154\194:T\135\200\157", _pubProps = [PropTopicAliasMaximum +// 15521,PropRequestResponseInformation 202,PropServerReference "",PropServerKeepAlive 27747,PropUserProperty +// "1\250^n\DELx\208e/~\246we" "8,\249\179r\DC2",PropSubscriptionIdentifierAvailable 146,PropSharedSubscriptionAvailable +// 249,PropRetainAvailable 178,PropCorrelationData "\ENQ\231",PropServerReference "F",PropWildcardSubscriptionAvailable +// 173,PropMaximumPacketSize 23566,PropSubscriptionIdentifier 22,PropSubscriptionIdentifierAvailable 53,PropTopicAlias +// 15812,PropServerKeepAlive 31656,PropContentType +// "_\240\vO\162;\136g\247\135\144ae\182;\154\237X\DELCf2\EOT*\171h",PropReasonString +// "\146\r]\239\153\&5r`1#\251",PropResponseTopic +// "G\164\230\178G\CAN\234\254p\DEL\156\250KR\r\219x@\247t\164\141\&9",PropAuthenticationData +// "B]0.\181\174\177\221T\128`D\210\253@\137[\DC2\174\160\245\227\170u\SI{^\241",PropWillDelayInterval +// 30420,PropAuthenticationData "\NUL\245\ETX\229[\STX\140\179V\227\226\220t\DC20\164R",PropReceiveMaximum +// 12547,PropTopicAlias 18835,PropMaximumQoS 44,PropMaximumPacketSize 5027,PropSharedSubscriptionAvailable +// 105,PropTopicAlias 9204,PropServerKeepAlive 4590,PropRequestProblemInformation 67]} TEST(Publish5QCTest, Decode1) { - uint8_t pkt[] = {0x31, 0x80, 0x1, 0x0, 0xb, 0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88, 0x64, - 0x28, 0x99, 0x22, 0xc, 0x63, 0x3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 0xad, + 0x27, 0x0, 0x0, 0x5c, 0xe, 0xb, 0x16, 0x29, 0x35, 0x23, 0x3d, 0xc4, 0x13, 0x7b, 0xa8, 0x3, 0x0, 0x1a, 0x5f, + 0xf0, 0xb, 0x4f, 0xa2, 0x3b, 0x88, 0x67, 0xf7, 0x87, 0x90, 0x61, 0x65, 0xb6, 0x3b, 0x9a, 0xed, 0x58, 0x7f, 0x43, + 0x66, 0x32, 0x4, 0x2a, 0xab, 0x68, 0x1f, 0x0, 0xb, 0x92, 0xd, 0x5d, 0xef, 0x99, 0x35, 0x72, 0x60, 0x31, 0x23, + 0xfb, 0x8, 0x0, 0x17, 0x47, 0xa4, 0xe6, 0xb2, 0x47, 0x18, 0xea, 0xfe, 0x70, 0x7f, 0x9c, 0xfa, 0x4b, 0x52, 0xd, + 0xdb, 0x78, 0x40, 0xf7, 0x74, 0xa4, 0x8d, 0x39, 0x16, 0x0, 0x1c, 0x42, 0x5d, 0x30, 0x2e, 0xb5, 0xae, 0xb1, 0xdd, + 0x54, 0x80, 0x60, 0x44, 0xd2, 0xfd, 0x40, 0x89, 0x5b, 0x12, 0xae, 0xa0, 0xf5, 0xe3, 0xaa, 0x75, 0xf, 0x7b, 0x5e, + 0xf1, 0x18, 0x0, 0x0, 0x76, 0xd4, 0x16, 0x0, 0x11, 0x0, 0xf5, 0x3, 0xe5, 0x5b, 0x2, 0x8c, 0xb3, 0x56, 0xe3, + 0xe2, 0xdc, 0x74, 0x12, 0x30, 0xa4, 0x52, 0x21, 0x31, 0x3, 0x23, 0x49, 0x93, 0x24, 0x2c, 0x27, 0x0, 0x0, 0x13, + 0xa3, 0x2a, 0x69, 0x23, 0x23, 0xf4, 0x13, 0x11, 0xee, 0x17, 0x43, 0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, + 0x9a, 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1846,171 +1924,132 @@ TEST(Publish5QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x89, 0xbd, 0xd5, 0x85, 0xd6, 0x48, 0x19, 0xa1, 0xaa, 0xf1, 0x88}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd9, 0x92, 0xe5, 0xc3, 0xa3, 0xaf, 0xc4, 0xae, 0x79, 0x30, 0x64, 0x8d, 0x62, 0x92}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + uint8_t exp_topic_bytes[] = {0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, 0x9a, + 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 6184); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\183\249", _pubPktID = 0, _pubBody -// = "M\EOTga\US?`w\167\&6\152\SI\NAKC\168>\173<\149\213m,5\235\133\r\180\190\195", _pubProps = -// [PropMessageExpiryInterval 32152,PropCorrelationData "};Zy2w\196\SO\158\155\212\US\145[\216\208&",PropResponseTopic -// "P\154\n\168\222q\EM\191\&7\247\208",PropResponseTopic -// "r\164\175\171\SUB=\160D'v\154\167",PropSharedSubscriptionAvailable 114,PropAssignedClientIdentifier -// "\179\247$\SYN\214\231\223\235+=SuY\244g\138\&4\198\158o\155\209\187\159v\153\230\203",PropMessageExpiryInterval -// 7971,PropReasonString "\167\SI\144j\r\230\207Q\139\&7\ETX\248[\154",PropMessageExpiryInterval -// 10952,PropRequestResponseInformation 148,PropReasonString "\139[\171\224!~\164\210",PropAssignedClientIdentifier -// "\138\169\SIV\231",PropAuthenticationData "\188\155\136o\243O\194",PropResponseInformation -// "[<\225\130\225\223\&4\134\CAN{0\188\209Bt\128\152A\133\a\n",PropSessionExpiryInterval -// 24494,PropSharedSubscriptionAvailable 202,PropResponseInformation -// "B\173n\FSD1\197\a\211v\144\152\184\188B",PropAuthenticationData -// "C2\202\128H\DC3\136\188\194v3\235\231\198\149\251zc",PropMaximumPacketSize 32261,PropRequestProblemInformation -// 61,PropSubscriptionIdentifierAvailable 184,PropResponseTopic -// "L\EM\147\234\201\193\t\EM\245*p\205\138\182O",PropUserProperty "o\US\ESC\155\160\221f\176\141\NAK\159" -// "\ETX\222o\DC4\169\130O\132\SYN\141\DC3",PropContentType -// "\DC1\195\185v\167\r\175N.\207\128\USM\147?*\nA\248\161\133\244\186{\251+\STX",PropContentType -// "\138n[`C$",PropRetainAvailable 205]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\198\DC1L:\231)\185\220\223D\v\EOT\217<", _pubPktID = 6873, _pubBody = "\ESC\"[|\180", _pubProps = +// [PropSubscriptionIdentifier 26,PropSubscriptionIdentifier 20,PropSubscriptionIdentifierAvailable +// 97,PropSessionExpiryInterval 1270,PropMaximumQoS 17,PropTopicAliasMaximum 10662,PropServerReference +// "1\200T%r\131\SOHr\212\191\242\CAN\247#\238v\nH\DC4\201Z\164\245\223\FS]",PropWillDelayInterval 643,PropMaximumQoS +// 77,PropPayloadFormatIndicator 204,PropAuthenticationData "\191 +// \136a\144\SUB\218\233\142\192\141\188\130\200\&2\140\234\168.\182\244`\169",PropRequestResponseInformation +// 99,PropRequestProblemInformation 98,PropSessionExpiryInterval 4736,PropSessionExpiryInterval 22872,PropResponseTopic +// "\143(Q\146\&7\171ew}S^\134\238QZ\DC3E \182\230'\234`",PropAuthenticationData +// "\207\179g\145M\145\246\226Ij\173\US\145\ETX\155\251\132^E\219\179\185\SO\136",PropServerReference +// "\250|\135#h",PropRetainAvailable 1,PropServerReference +// "1\GS\178\129~-{+\US\SUBBe\DEL\SI\174q\210\241Zq\201_mb\129@\210E\208",PropSubscriptionIdentifier +// 14,PropMessageExpiryInterval 1239]} TEST(Publish5QCTest, Encode2) { uint8_t pkt[] = { - 0x30, 0xd9, 0x2, 0x0, 0x2, 0xb7, 0xf9, 0xb6, 0x2, 0x2, 0x0, 0x0, 0x7d, 0x98, 0x9, 0x0, 0x11, 0x7d, 0x3b, - 0x5a, 0x79, 0x32, 0x77, 0xc4, 0xe, 0x9e, 0x9b, 0xd4, 0x1f, 0x91, 0x5b, 0xd8, 0xd0, 0x26, 0x8, 0x0, 0xb, 0x50, - 0x9a, 0xa, 0xa8, 0xde, 0x71, 0x19, 0xbf, 0x37, 0xf7, 0xd0, 0x8, 0x0, 0xc, 0x72, 0xa4, 0xaf, 0xab, 0x1a, 0x3d, - 0xa0, 0x44, 0x27, 0x76, 0x9a, 0xa7, 0x2a, 0x72, 0x12, 0x0, 0x1c, 0xb3, 0xf7, 0x24, 0x16, 0xd6, 0xe7, 0xdf, 0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0xb0, 0x8d, 0x15, 0x9f, 0x0, - 0xb, 0x3, 0xde, 0x6f, 0x14, 0xa9, 0x82, 0x4f, 0x84, 0x16, 0x8d, 0x13, 0x3, 0x0, 0x1b, 0x11, 0xc3, 0xb9, 0x76, - 0xa7, 0xd, 0xaf, 0x4e, 0x2e, 0xcf, 0x80, 0x1f, 0x4d, 0x93, 0x3f, 0x2a, 0xa, 0x41, 0xf8, 0xa1, 0x85, 0xf4, 0xba, - 0x7b, 0xfb, 0x2b, 0x2, 0x3, 0x0, 0x6, 0x8a, 0x6e, 0x5b, 0x60, 0x43, 0x24, 0x25, 0xcd, 0x4d, 0x4, 0x67, 0x61, - 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, - 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; - uint8_t topic_bytes[] = {0xb7, 0xf9}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + 0x35, 0xdd, 0x1, 0x0, 0xe, 0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c, + 0x1a, 0xd9, 0xc4, 0x1, 0xb, 0x1a, 0xb, 0x14, 0x29, 0x61, 0x11, 0x0, 0x0, 0x4, 0xf6, 0x24, 0x11, 0x22, 0x29, + 0xa6, 0x1c, 0x0, 0x1a, 0x31, 0xc8, 0x54, 0x25, 0x72, 0x83, 0x1, 0x72, 0xd4, 0xbf, 0xf2, 0x18, 0xf7, 0x23, 0xee, + 0x76, 0xa, 0x48, 0x14, 0xc9, 0x5a, 0xa4, 0xf5, 0xdf, 0x1c, 0x5d, 0x18, 0x0, 0x0, 0x2, 0x83, 0x24, 0x4d, 0x1, + 0xcc, 0x16, 0x0, 0x17, 0xbf, 0x20, 0x88, 0x61, 0x90, 0x1a, 0xda, 0xe9, 0x8e, 0xc0, 0x8d, 0xbc, 0x82, 0xc8, 0x32, + 0x8c, 0xea, 0xa8, 0x2e, 0xb6, 0xf4, 0x60, 0xa9, 0x19, 0x63, 0x17, 0x62, 0x11, 0x0, 0x0, 0x12, 0x80, 0x11, 0x0, + 0x0, 0x59, 0x58, 0x8, 0x0, 0x17, 0x8f, 0x28, 0x51, 0x92, 0x37, 0xab, 0x65, 0x77, 0x7d, 0x53, 0x5e, 0x86, 0xee, + 0x51, 0x5a, 0x13, 0x45, 0x20, 0xb6, 0xe6, 0x27, 0xea, 0x60, 0x16, 0x0, 0x18, 0xcf, 0xb3, 0x67, 0x91, 0x4d, 0x91, + 0xf6, 0xe2, 0x49, 0x6a, 0xad, 0x1f, 0x91, 0x3, 0x9b, 0xfb, 0x84, 0x5e, 0x45, 0xdb, 0xb3, 0xb9, 0xe, 0x88, 0x1c, + 0x0, 0x5, 0xfa, 0x7c, 0x87, 0x23, 0x68, 0x25, 0x1, 0x1c, 0x0, 0x1d, 0x31, 0x1d, 0xb2, 0x81, 0x7e, 0x2d, 0x7b, + 0x2b, 0x1f, 0x1a, 0x42, 0x65, 0x7f, 0xf, 0xae, 0x71, 0xd2, 0xf1, 0x5a, 0x71, 0xc9, 0x5f, 0x6d, 0x62, 0x81, 0x40, + 0xd2, 0x45, 0xd0, 0xb, 0xe, 0x2, 0x0, 0x0, 0x4, 0xd7, 0x1b, 0x22, 0x5b, 0x7c, 0xb4}; + uint8_t topic_bytes[] = {0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, - 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0x1b, 0x22, 0x5b, 0x7c, 0xb4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; - - uint8_t bytesprops0[] = {0x7d, 0x3b, 0x5a, 0x79, 0x32, 0x77, 0xc4, 0xe, 0x9e, - 0x9b, 0xd4, 0x1f, 0x91, 0x5b, 0xd8, 0xd0, 0x26}; - uint8_t bytesprops1[] = {0x50, 0x9a, 0xa, 0xa8, 0xde, 0x71, 0x19, 0xbf, 0x37, 0xf7, 0xd0}; - uint8_t bytesprops2[] = {0x72, 0xa4, 0xaf, 0xab, 0x1a, 0x3d, 0xa0, 0x44, 0x27, 0x76, 0x9a, 0xa7}; - uint8_t bytesprops3[] = {0xb3, 0xf7, 0x24, 0x16, 0xd6, 0xe7, 0xdf, 0xeb, 0x2b, 0x3d, 0x53, 0x75, 0x59, 0xf4, - 0x67, 0x8a, 0x34, 0xc6, 0x9e, 0x6f, 0x9b, 0xd1, 0xbb, 0x9f, 0x76, 0x99, 0xe6, 0xcb}; - uint8_t bytesprops4[] = {0xa7, 0xf, 0x90, 0x6a, 0xd, 0xe6, 0xcf, 0x51, 0x8b, 0x37, 0x3, 0xf8, 0x5b, 0x9a}; - uint8_t bytesprops5[] = {0x8b, 0x5b, 0xab, 0xe0, 0x21, 0x7e, 0xa4, 0xd2}; - uint8_t bytesprops6[] = {0x8a, 0xa9, 0xf, 0x56, 0xe7}; - uint8_t bytesprops7[] = {0xbc, 0x9b, 0x88, 0x6f, 0xf3, 0x4f, 0xc2}; - uint8_t bytesprops8[] = {0x5b, 0x3c, 0xe1, 0x82, 0xe1, 0xdf, 0x34, 0x86, 0x18, 0x7b, 0x30, - 0xbc, 0xd1, 0x42, 0x74, 0x80, 0x98, 0x41, 0x85, 0x7, 0xa}; - uint8_t bytesprops9[] = {0x42, 0xad, 0x6e, 0x1c, 0x44, 0x31, 0xc5, 0x7, 0xd3, 0x76, 0x90, 0x98, 0xb8, 0xbc, 0x42}; - uint8_t bytesprops10[] = {0x43, 0x32, 0xca, 0x80, 0x48, 0x13, 0x88, 0xbc, 0xc2, - 0x76, 0x33, 0xeb, 0xe7, 0xc6, 0x95, 0xfb, 0x7a, 0x63}; - uint8_t bytesprops11[] = {0x4c, 0x19, 0x93, 0xea, 0xc9, 0xc1, 0x9, 0x19, 0xf5, 0x2a, 0x70, 0xcd, 0x8a, 0xb6, 0x4f}; - uint8_t bytesprops13[] = {0x3, 0xde, 0x6f, 0x14, 0xa9, 0x82, 0x4f, 0x84, 0x16, 0x8d, 0x13}; - uint8_t bytesprops12[] = {0x6f, 0x1f, 0x1b, 0x9b, 0xa0, 0xdd, 0x66, 0xb0, 0x8d, 0x15, 0x9f}; - uint8_t bytesprops14[] = {0x11, 0xc3, 0xb9, 0x76, 0xa7, 0xd, 0xaf, 0x4e, 0x2e, 0xcf, 0x80, 0x1f, 0x4d, 0x93, - 0x3f, 0x2a, 0xa, 0x41, 0xf8, 0xa1, 0x85, 0xf4, 0xba, 0x7b, 0xfb, 0x2b, 0x2}; - uint8_t bytesprops15[] = {0x8a, 0x6e, 0x5b, 0x60, 0x43, 0x24}; + msg.payload_len = 5; + + uint8_t bytesprops0[] = {0x31, 0xc8, 0x54, 0x25, 0x72, 0x83, 0x1, 0x72, 0xd4, 0xbf, 0xf2, 0x18, 0xf7, + 0x23, 0xee, 0x76, 0xa, 0x48, 0x14, 0xc9, 0x5a, 0xa4, 0xf5, 0xdf, 0x1c, 0x5d}; + uint8_t bytesprops1[] = {0xbf, 0x20, 0x88, 0x61, 0x90, 0x1a, 0xda, 0xe9, 0x8e, 0xc0, 0x8d, 0xbc, + 0x82, 0xc8, 0x32, 0x8c, 0xea, 0xa8, 0x2e, 0xb6, 0xf4, 0x60, 0xa9}; + uint8_t bytesprops2[] = {0x8f, 0x28, 0x51, 0x92, 0x37, 0xab, 0x65, 0x77, 0x7d, 0x53, 0x5e, 0x86, + 0xee, 0x51, 0x5a, 0x13, 0x45, 0x20, 0xb6, 0xe6, 0x27, 0xea, 0x60}; + uint8_t bytesprops3[] = {0xcf, 0xb3, 0x67, 0x91, 0x4d, 0x91, 0xf6, 0xe2, 0x49, 0x6a, 0xad, 0x1f, + 0x91, 0x3, 0x9b, 0xfb, 0x84, 0x5e, 0x45, 0xdb, 0xb3, 0xb9, 0xe, 0x88}; + uint8_t bytesprops4[] = {0xfa, 0x7c, 0x87, 0x23, 0x68}; + uint8_t bytesprops5[] = {0x31, 0x1d, 0xb2, 0x81, 0x7e, 0x2d, 0x7b, 0x2b, 0x1f, 0x1a, 0x42, 0x65, 0x7f, 0xf, 0xae, + 0x71, 0xd2, 0xf1, 0x5a, 0x71, 0xc9, 0x5f, 0x6d, 0x62, 0x81, 0x40, 0xd2, 0x45, 0xd0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32152}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7971}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10952}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24494}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32261}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {11, (char*)&bytesprops12}, .v = {11, (char*)&bytesprops13}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops15}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1270}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10662}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 643}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4736}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22872}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1239}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 6873, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\183\249", _pubPktID = 0, _pubBody -// = "M\EOTga\US?`w\167\&6\152\SI\NAKC\168>\173<\149\213m,5\235\133\r\180\190\195", _pubProps = -// [PropMessageExpiryInterval 32152,PropCorrelationData "};Zy2w\196\SO\158\155\212\US\145[\216\208&",PropResponseTopic -// "P\154\n\168\222q\EM\191\&7\247\208",PropResponseTopic -// "r\164\175\171\SUB=\160D'v\154\167",PropSharedSubscriptionAvailable 114,PropAssignedClientIdentifier -// "\179\247$\SYN\214\231\223\235+=SuY\244g\138\&4\198\158o\155\209\187\159v\153\230\203",PropMessageExpiryInterval -// 7971,PropReasonString "\167\SI\144j\r\230\207Q\139\&7\ETX\248[\154",PropMessageExpiryInterval -// 10952,PropRequestResponseInformation 148,PropReasonString "\139[\171\224!~\164\210",PropAssignedClientIdentifier -// "\138\169\SIV\231",PropAuthenticationData "\188\155\136o\243O\194",PropResponseInformation -// "[<\225\130\225\223\&4\134\CAN{0\188\209Bt\128\152A\133\a\n",PropSessionExpiryInterval -// 24494,PropSharedSubscriptionAvailable 202,PropResponseInformation -// "B\173n\FSD1\197\a\211v\144\152\184\188B",PropAuthenticationData -// "C2\202\128H\DC3\136\188\194v3\235\231\198\149\251zc",PropMaximumPacketSize 32261,PropRequestProblemInformation -// 61,PropSubscriptionIdentifierAvailable 184,PropResponseTopic -// "L\EM\147\234\201\193\t\EM\245*p\205\138\182O",PropUserProperty "o\US\ESC\155\160\221f\176\141\NAK\159" -// "\ETX\222o\DC4\169\130O\132\SYN\141\DC3",PropContentType -// "\DC1\195\185v\167\r\175N.\207\128\USM\147?*\nA\248\161\133\244\186{\251+\STX",PropContentType -// "\138n[`C$",PropRetainAvailable 205]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\198\DC1L:\231)\185\220\223D\v\EOT\217<", _pubPktID = 6873, _pubBody = "\ESC\"[|\180", _pubProps = +// [PropSubscriptionIdentifier 26,PropSubscriptionIdentifier 20,PropSubscriptionIdentifierAvailable +// 97,PropSessionExpiryInterval 1270,PropMaximumQoS 17,PropTopicAliasMaximum 10662,PropServerReference +// "1\200T%r\131\SOHr\212\191\242\CAN\247#\238v\nH\DC4\201Z\164\245\223\FS]",PropWillDelayInterval 643,PropMaximumQoS +// 77,PropPayloadFormatIndicator 204,PropAuthenticationData "\191 +// \136a\144\SUB\218\233\142\192\141\188\130\200\&2\140\234\168.\182\244`\169",PropRequestResponseInformation +// 99,PropRequestProblemInformation 98,PropSessionExpiryInterval 4736,PropSessionExpiryInterval 22872,PropResponseTopic +// "\143(Q\146\&7\171ew}S^\134\238QZ\DC3E \182\230'\234`",PropAuthenticationData +// "\207\179g\145M\145\246\226Ij\173\US\145\ETX\155\251\132^E\219\179\185\SO\136",PropServerReference +// "\250|\135#h",PropRetainAvailable 1,PropServerReference +// "1\GS\178\129~-{+\US\SUBBe\DEL\SI\174q\210\241Zq\201_mb\129@\210E\208",PropSubscriptionIdentifier +// 14,PropMessageExpiryInterval 1239]} TEST(Publish5QCTest, Decode2) { uint8_t pkt[] = { - 0x30, 0xd9, 0x2, 0x0, 0x2, 0xb7, 0xf9, 0xb6, 0x2, 0x2, 0x0, 0x0, 0x7d, 0x98, 0x9, 0x0, 0x11, 0x7d, 0x3b, - 0x5a, 0x79, 0x32, 0x77, 0xc4, 0xe, 0x9e, 0x9b, 0xd4, 0x1f, 0x91, 0x5b, 0xd8, 0xd0, 0x26, 0x8, 0x0, 0xb, 0x50, - 0x9a, 0xa, 0xa8, 0xde, 0x71, 0x19, 0xbf, 0x37, 0xf7, 0xd0, 0x8, 0x0, 0xc, 0x72, 0xa4, 0xaf, 0xab, 0x1a, 0x3d, - 0xa0, 0x44, 0x27, 0x76, 0x9a, 0xa7, 0x2a, 0x72, 0x12, 0x0, 0x1c, 0xb3, 0xf7, 0x24, 0x16, 0xd6, 0xe7, 0xdf, 0xeb, - 0x2b, 0x3d, 0x53, 0x75, 0x59, 0xf4, 0x67, 0x8a, 0x34, 0xc6, 0x9e, 0x6f, 0x9b, 0xd1, 0xbb, 0x9f, 0x76, 0x99, 0xe6, - 0xcb, 0x2, 0x0, 0x0, 0x1f, 0x23, 0x1f, 0x0, 0xe, 0xa7, 0xf, 0x90, 0x6a, 0xd, 0xe6, 0xcf, 0x51, 0x8b, 0x37, - 0x3, 0xf8, 0x5b, 0x9a, 0x2, 0x0, 0x0, 0x2a, 0xc8, 0x19, 0x94, 0x1f, 0x0, 0x8, 0x8b, 0x5b, 0xab, 0xe0, 0x21, - 0x7e, 0xa4, 0xd2, 0x12, 0x0, 0x5, 0x8a, 0xa9, 0xf, 0x56, 0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0x88, 0x1c, + 0x0, 0x5, 0xfa, 0x7c, 0x87, 0x23, 0x68, 0x25, 0x1, 0x1c, 0x0, 0x1d, 0x31, 0x1d, 0xb2, 0x81, 0x7e, 0x2d, 0x7b, + 0x2b, 0x1f, 0x1a, 0x42, 0x65, 0x7f, 0xf, 0xae, 0x71, 0xd2, 0xf1, 0x5a, 0x71, 0xc9, 0x5f, 0x6d, 0x62, 0x81, 0x40, + 0xd2, 0x45, 0xd0, 0xb, 0xe, 0x2, 0x0, 0x0, 0x4, 0xd7, 0x1b, 0x22, 0x5b, 0x7c, 0xb4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2019,166 +2058,67 @@ TEST(Publish5QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb7, 0xf9}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4d, 0x4, 0x67, 0x61, 0x1f, 0x3f, 0x60, 0x77, 0xa7, 0x36, 0x98, 0xf, 0x15, 0x43, 0xa8, - 0x3e, 0xad, 0x3c, 0x95, 0xd5, 0x6d, 0x2c, 0x35, 0xeb, 0x85, 0xd, 0xb4, 0xbe, 0xc3}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x1b, 0x22, 0x5b, 0x7c, 0xb4}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 6873); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } // PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\DC1\157\ns\ETX0?\130,\153\&5(\EM\NAK\235tg/\223cz\215\188l", _pubPktID = 23951, _pubBody = "\252\STX\212\139", -// _pubProps = [PropReceiveMaximum 2885,PropSubscriptionIdentifierAvailable 134,PropCorrelationData -// "4\178\DEL\235\196_\225<\219\177\197\GS\ENQ\167I\213\168N\155\163",PropMessageExpiryInterval -// 30572,PropSubscriptionIdentifierAvailable 249,PropTopicAliasMaximum 2600,PropRetainAvailable -// 111,PropResponseInformation "\235\188\191\218\&7\232t\203P\218%\190\184\209s\173\NAK\rY",PropMaximumPacketSize -// 27511,PropAuthenticationMethod -// "d$6\228\131\179\242\218\235\EM8\169\141HK\146\177\167)\253\133\137\172",PropMaximumPacketSize -// 13586,PropServerReference "\249X\232\RS\228\225\207(3\vn\153\170\200Ds\157\201\ENQ1\234W\167",PropServerReference -// "uMy\144F\248<\231\215\221\184z\132Wm}\ETX",PropTopicAlias 14062,PropResponseTopic -// "\195\172\153\209|\153\DC2K\138\230y\250\NUL\189\ACKV\NAKn!",PropAuthenticationData -// "Q5\182q\140\DLEu\153\164a\149\157?>]D\195\142\DC1",PropResponseInformation -// "9\139\232\228\EM",PropAssignedClientIdentifier "3\189w=\ESC",PropSubscriptionIdentifierAvailable -// 19,PropAuthenticationMethod -// "\174\235B\200\147\145\192\156B\SOHV\228`\182\245\217\233\165\138c\190\GS\DC1u\157K\187\234\207",PropSessionExpiryInterval -// 16713,PropResponseInformation "M\194\151d\163\182\EOT.\208\ACK\183\&9\159]3:\187",PropSharedSubscriptionAvailable -// 144,PropTopicAliasMaximum 11118,PropAuthenticationData "\f\EM\DEL\155\167\236;-J^~n_\162"]} +// "^W\131\160\253B\156\130SrVB\238=\158m_\253\242\178N", _pubPktID = 12282, _pubBody = +// "\169\159cc\RSh\239_U\ETB\NAK\223f", _pubProps = [PropMessageExpiryInterval 2866,PropServerReference +// "\216\SOH\NAKu\157\159\n\164\172",PropRequestProblemInformation 154]} TEST(Publish5QCTest, Encode3) { - uint8_t pkt[] = { - 0x3a, 0xc2, 0x2, 0x0, 0x18, 0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, 0x19, 0x15, - 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xbc, 0x6c, 0x5d, 0x8f, 0xa0, 0x2, 0x21, 0xb, 0x45, 0x29, 0x86, - 0x9, 0x0, 0x14, 0x34, 0xb2, 0x7f, 0xeb, 0xc4, 0x5f, 0xe1, 0x3c, 0xdb, 0xb1, 0xc5, 0x1d, 0x5, 0xa7, 0x49, 0xd5, - 0xa8, 0x4e, 0x9b, 0xa3, 0x2, 0x0, 0x0, 0x77, 0x6c, 0x29, 0xf9, 0x22, 0xa, 0x28, 0x25, 0x6f, 0x1a, 0x0, 0x13, - 0xeb, 0xbc, 0xbf, 0xda, 0x37, 0xe8, 0x74, 0xcb, 0x50, 0xda, 0x25, 0xbe, 0xb8, 0xd1, 0x73, 0xad, 0x15, 0xd, 0x59, - 0x27, 0x0, 0x0, 0x6b, 0x77, 0x15, 0x0, 0x17, 0x64, 0x24, 0x36, 0xe4, 0x83, 0xb3, 0xf2, 0xda, 0xeb, 0x19, 0x38, - 0xa9, 0x8d, 0x48, 0x4b, 0x92, 0x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x0, 0xe, 0xc, 0x19, 0x7f, 0x9b, 0xa7, 0xec, 0x3b, 0x2d, 0x4a, 0x5e, 0x7e, 0x6e, 0x5f, 0xa2, 0xfc, 0x2, - 0xd4, 0x8b}; - uint8_t topic_bytes[] = {0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, - 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xbc, 0x6c}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x3a, 0x0, 0x15, 0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, 0x56, + 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e, 0x2f, 0xfa, 0x13, 0x2, 0x0, + 0x0, 0xb, 0x32, 0x1c, 0x0, 0x9, 0xd8, 0x1, 0x15, 0x75, 0x9d, 0x9f, 0xa, 0xa4, 0xac, + 0x17, 0x9a, 0xa9, 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; + uint8_t topic_bytes[] = {0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, 0x56, + 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xfc, 0x2, 0xd4, 0x8b}; + uint8_t msg_bytes[] = {0xa9, 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; - - uint8_t bytesprops0[] = {0x34, 0xb2, 0x7f, 0xeb, 0xc4, 0x5f, 0xe1, 0x3c, 0xdb, 0xb1, - 0xc5, 0x1d, 0x5, 0xa7, 0x49, 0xd5, 0xa8, 0x4e, 0x9b, 0xa3}; - uint8_t bytesprops1[] = {0xeb, 0xbc, 0xbf, 0xda, 0x37, 0xe8, 0x74, 0xcb, 0x50, 0xda, - 0x25, 0xbe, 0xb8, 0xd1, 0x73, 0xad, 0x15, 0xd, 0x59}; - uint8_t bytesprops2[] = {0x64, 0x24, 0x36, 0xe4, 0x83, 0xb3, 0xf2, 0xda, 0xeb, 0x19, 0x38, 0xa9, - 0x8d, 0x48, 0x4b, 0x92, 0xb1, 0xa7, 0x29, 0xfd, 0x85, 0x89, 0xac}; - uint8_t bytesprops3[] = {0xf9, 0x58, 0xe8, 0x1e, 0xe4, 0xe1, 0xcf, 0x28, 0x33, 0xb, 0x6e, 0x99, - 0xaa, 0xc8, 0x44, 0x73, 0x9d, 0xc9, 0x5, 0x31, 0xea, 0x57, 0xa7}; - uint8_t bytesprops4[] = {0x75, 0x4d, 0x79, 0x90, 0x46, 0xf8, 0x3c, 0xe7, 0xd7, - 0xdd, 0xb8, 0x7a, 0x84, 0x57, 0x6d, 0x7d, 0x3}; - uint8_t bytesprops5[] = {0xc3, 0xac, 0x99, 0xd1, 0x7c, 0x99, 0x12, 0x4b, 0x8a, 0xe6, - 0x79, 0xfa, 0x0, 0xbd, 0x6, 0x56, 0x15, 0x6e, 0x21}; - uint8_t bytesprops6[] = {0x51, 0x35, 0xb6, 0x71, 0x8c, 0x10, 0x75, 0x99, 0xa4, 0x61, - 0x95, 0x9d, 0x3f, 0x3e, 0x5d, 0x44, 0xc3, 0x8e, 0x11}; - uint8_t bytesprops7[] = {0x39, 0x8b, 0xe8, 0xe4, 0x19}; - uint8_t bytesprops8[] = {0x33, 0xbd, 0x77, 0x3d, 0x1b}; - uint8_t bytesprops9[] = {0xae, 0xeb, 0x42, 0xc8, 0x93, 0x91, 0xc0, 0x9c, 0x42, 0x1, 0x56, 0xe4, 0x60, 0xb6, 0xf5, - 0xd9, 0xe9, 0xa5, 0x8a, 0x63, 0xbe, 0x1d, 0x11, 0x75, 0x9d, 0x4b, 0xbb, 0xea, 0xcf}; - uint8_t bytesprops10[] = {0x4d, 0xc2, 0x97, 0x64, 0xa3, 0xb6, 0x4, 0x2e, 0xd0, - 0x6, 0xb7, 0x39, 0x9f, 0x5d, 0x33, 0x3a, 0xbb}; - uint8_t bytesprops11[] = {0xc, 0x19, 0x7f, 0x9b, 0xa7, 0xec, 0x3b, 0x2d, 0x4a, 0x5e, 0x7e, 0x6e, 0x5f, 0xa2}; + msg.payload_len = 13; + + uint8_t bytesprops0[] = {0xd8, 0x1, 0x15, 0x75, 0x9d, 0x9f, 0xa, 0xa4, 0xac}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2885}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30572}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2600}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27511}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13586}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14062}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16713}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11118}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2866}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 154}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 23951, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 12282, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } // PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\DC1\157\ns\ETX0?\130,\153\&5(\EM\NAK\235tg/\223cz\215\188l", _pubPktID = 23951, _pubBody = "\252\STX\212\139", -// _pubProps = [PropReceiveMaximum 2885,PropSubscriptionIdentifierAvailable 134,PropCorrelationData -// "4\178\DEL\235\196_\225<\219\177\197\GS\ENQ\167I\213\168N\155\163",PropMessageExpiryInterval -// 30572,PropSubscriptionIdentifierAvailable 249,PropTopicAliasMaximum 2600,PropRetainAvailable -// 111,PropResponseInformation "\235\188\191\218\&7\232t\203P\218%\190\184\209s\173\NAK\rY",PropMaximumPacketSize -// 27511,PropAuthenticationMethod -// "d$6\228\131\179\242\218\235\EM8\169\141HK\146\177\167)\253\133\137\172",PropMaximumPacketSize -// 13586,PropServerReference "\249X\232\RS\228\225\207(3\vn\153\170\200Ds\157\201\ENQ1\234W\167",PropServerReference -// "uMy\144F\248<\231\215\221\184z\132Wm}\ETX",PropTopicAlias 14062,PropResponseTopic -// "\195\172\153\209|\153\DC2K\138\230y\250\NUL\189\ACKV\NAKn!",PropAuthenticationData -// "Q5\182q\140\DLEu\153\164a\149\157?>]D\195\142\DC1",PropResponseInformation -// "9\139\232\228\EM",PropAssignedClientIdentifier "3\189w=\ESC",PropSubscriptionIdentifierAvailable -// 19,PropAuthenticationMethod -// "\174\235B\200\147\145\192\156B\SOHV\228`\182\245\217\233\165\138c\190\GS\DC1u\157K\187\234\207",PropSessionExpiryInterval -// 16713,PropResponseInformation "M\194\151d\163\182\EOT.\208\ACK\183\&9\159]3:\187",PropSharedSubscriptionAvailable -// 144,PropTopicAliasMaximum 11118,PropAuthenticationData "\f\EM\DEL\155\167\236;-J^~n_\162"]} +// "^W\131\160\253B\156\130SrVB\238=\158m_\253\242\178N", _pubPktID = 12282, _pubBody = +// "\169\159cc\RSh\239_U\ETB\NAK\223f", _pubProps = [PropMessageExpiryInterval 2866,PropServerReference +// "\216\SOH\NAKu\157\159\n\164\172",PropRequestProblemInformation 154]} TEST(Publish5QCTest, Decode3) { - uint8_t pkt[] = { - 0x3a, 0xc2, 0x2, 0x0, 0x18, 0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, 0x19, 0x15, - 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xb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x61, 0x95, 0x9d, 0x3f, 0x3e, 0x5d, 0x44, 0xc3, 0x8e, 0x11, 0x1a, 0x0, 0x5, 0x39, - 0x8b, 0xe8, 0xe4, 0x19, 0x12, 0x0, 0x5, 0x33, 0xbd, 0x77, 0x3d, 0x1b, 0x29, 0x13, 0x15, 0x0, 0x1d, 0xae, 0xeb, - 0x42, 0xc8, 0x93, 0x91, 0xc0, 0x9c, 0x42, 0x1, 0x56, 0xe4, 0x60, 0xb6, 0xf5, 0xd9, 0xe9, 0xa5, 0x8a, 0x63, 0xbe, - 0x1d, 0x11, 0x75, 0x9d, 0x4b, 0xbb, 0xea, 0xcf, 0x11, 0x0, 0x0, 0x41, 0x49, 0x1a, 0x0, 0x11, 0x4d, 0xc2, 0x97, - 0x64, 0xa3, 0xb6, 0x4, 0x2e, 0xd0, 0x6, 0xb7, 0x39, 0x9f, 0x5d, 0x33, 0x3a, 0xbb, 0x2a, 0x90, 0x22, 0x2b, 0x6e, - 0x16, 0x0, 0xe, 0xc, 0x19, 0x7f, 0x9b, 0xa7, 0xec, 0x3b, 0x2d, 0x4a, 0x5e, 0x7e, 0x6e, 0x5f, 0xa2, 0xfc, 0x2, - 0xd4, 0x8b}; + uint8_t pkt[] = {0x3a, 0x3a, 0x0, 0x15, 0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, 0x56, + 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e, 0x2f, 0xfa, 0x13, 0x2, 0x0, + 0x0, 0xb, 0x32, 0x1c, 0x0, 0x9, 0xd8, 0x1, 0x15, 0x75, 0x9d, 0x9f, 0xa, 0xa4, 0xac, + 0x17, 0x9a, 0xa9, 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2187,139 +2127,112 @@ TEST(Publish5QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x11, 0x9d, 0xa, 0x73, 0x3, 0x30, 0x3f, 0x82, 0x2c, 0x99, 0x35, 0x28, - 0x19, 0x15, 0xeb, 0x74, 0x67, 0x2f, 0xdf, 0x63, 0x7a, 0xd7, 0xbc, 0x6c}; - lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfc, 0x2, 0xd4, 0x8b}; - lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, 0x56, + 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa9, 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 23951); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); - EXPECT_EQ(msg.payload_len, 4); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + EXPECT_EQ(packet_id, 12282); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "2]\237\233\224\238", _pubPktID = -// 32430, _pubBody = "\\7\a}d\f\191)\250N\n\r\240\169\178\184]", _pubProps = [PropResponseInformation -// "",PropMessageExpiryInterval 21151,PropMessageExpiryInterval 151,PropReasonString -// "\230\215Z\157U\190\241f\174\150{\183\NAK\239\204\n\150\183\128AV\144\n",PropMaximumPacketSize -// 11185,PropMaximumPacketSize 25334,PropSubscriptionIdentifierAvailable 124,PropReceiveMaximum -// 12433,PropCorrelationData "G\192\206\131\145\SOH\255>\211&\136\161$!`^G",PropServerKeepAlive -// 19132,PropServerReference "q\RS\RSB\\\204\182\165",PropRetainAvailable 93,PropServerKeepAlive 1218,PropMaximumQoS -// 66,PropPayloadFormatIndicator 228,PropResponseInformation -// "\138[\247\246\166\GS\CANx\RS\188",PropAssignedClientIdentifier -// "\229\203\GS\146I\202t\182\230%\238O\DC1\237\222\219\175\213VT\186\154\DC3d\251\138A\SI",PropMaximumQoS -// 44,PropMessageExpiryInterval 8113,PropMaximumQoS 61,PropRequestResponseInformation -// 120,PropSubscriptionIdentifierAvailable 168,PropReceiveMaximum 6126,PropResponseInformation -// "?g%\180\ETB0\226\191W\198!K\175\f\240\159\186W\210\166L\188\SYN\136\EM\199\229\&9",PropPayloadFormatIndicator -// 19,PropMaximumQoS 97]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\223~\247S\221_\137\253\202\t\SO<\197\171X=\DC1'\196\ACK", _pubPktID = 7369, _pubBody = +// "\218\SI\242\t\138\r\SO\ESC[\224\207", _pubProps = [PropMaximumPacketSize 12936,PropServerKeepAlive +// 29399,PropRetainAvailable 124,PropTopicAliasMaximum 20663,PropReasonString +// "\189\DC2u}o&\218G\239\DC4\202;\143\b",PropCorrelationData +// "\129=\183\174f\210\184\204h\195\223\\\138\141",PropMessageExpiryInterval 17593,PropMaximumPacketSize +// 27303,PropServerReference "d\146\185<\255\151\&8\ETB\"\163[\176|\214g/w\210N\250s",PropRequestResponseInformation +// 140,PropResponseTopic "\172\144\DC2\140\130\\\EM\rj\243\135\&6",PropRequestResponseInformation 24,PropReceiveMaximum +// 24602,PropRetainAvailable 197,PropWillDelayInterval 7751,PropRequestProblemInformation +// 36,PropRequestResponseInformation 76,PropSubscriptionIdentifier 7,PropRequestResponseInformation 2]} TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = { - 0x35, 0xdd, 0x1, 0x0, 0x6, 0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee, 0x7e, 0xae, 0xc0, 0x1, 0x1a, 0x0, 0x0, 0x2, - 0x0, 0x0, 0x52, 0x9f, 0x2, 0x0, 0x0, 0x0, 0x97, 0x1f, 0x0, 0x17, 0xe6, 0xd7, 0x5a, 0x9d, 0x55, 0xbe, 0xf1, - 0x66, 0xae, 0x96, 0x7b, 0xb7, 0x15, 0xef, 0xcc, 0xa, 0x96, 0xb7, 0x80, 0x41, 0x56, 0x90, 0xa, 0x27, 0x0, 0x0, - 0x2b, 0xb1, 0x27, 0x0, 0x0, 0x62, 0xf6, 0x29, 0x7c, 0x21, 0x30, 0x91, 0x9, 0x0, 0x11, 0x47, 0xc0, 0xce, 0x83, - 0x91, 0x1, 0xff, 0x3e, 0xd3, 0x26, 0x88, 0xa1, 0x24, 0x21, 0x60, 0x5e, 0x47, 0x13, 0x4a, 0xbc, 0x1c, 0x0, 0x8, - 0x71, 0x1e, 0x1e, 0x42, 0x5c, 0xcc, 0xb6, 0xa5, 0x25, 0x5d, 0x13, 0x4, 0xc2, 0x24, 0x42, 0x1, 0xe4, 0x1a, 0x0, - 0xa, 0x8a, 0x5b, 0xf7, 0xf6, 0xa6, 0x1d, 0x18, 0x78, 0x1e, 0xbc, 0x12, 0x0, 0x1c, 0xe5, 0xcb, 0x1d, 0x92, 0x49, - 0xca, 0x74, 0xb6, 0xe6, 0x25, 0xee, 0x4f, 0x11, 0xed, 0xde, 0xdb, 0xaf, 0xd5, 0x56, 0x54, 0xba, 0x9a, 0x13, 0x64, - 0xfb, 0x8a, 0x41, 0xf, 0x24, 0x2c, 0x2, 0x0, 0x0, 0x1f, 0xb1, 0x24, 0x3d, 0x19, 0x78, 0x29, 0xa8, 0x21, 0x17, - 0xee, 0x1a, 0x0, 0x1c, 0x3f, 0x67, 0x25, 0xb4, 0x17, 0x30, 0xe2, 0xbf, 0x57, 0xc6, 0x21, 0x4b, 0xaf, 0xc, 0xf0, - 0x9f, 0xba, 0x57, 0xd2, 0xa6, 0x4c, 0xbc, 0x16, 0x88, 0x19, 0xc7, 0xe5, 0x39, 0x1, 0x13, 0x24, 0x61, 0x5c, 0x37, - 0x7, 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; - uint8_t topic_bytes[] = {0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee}; - lwmqtt_string_t topic = {6, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x9a, 0x1, 0x0, 0x14, 0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, 0xe, + 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6, 0x1c, 0xc9, 0x76, 0x27, 0x0, 0x0, 0x32, + 0x88, 0x13, 0x72, 0xd7, 0x25, 0x7c, 0x22, 0x50, 0xb7, 0x1f, 0x0, 0xe, 0xbd, 0x12, 0x75, 0x7d, + 0x6f, 0x26, 0xda, 0x47, 0xef, 0x14, 0xca, 0x3b, 0x8f, 0x8, 0x9, 0x0, 0xe, 0x81, 0x3d, 0xb7, + 0xae, 0x66, 0xd2, 0xb8, 0xcc, 0x68, 0xc3, 0xdf, 0x5c, 0x8a, 0x8d, 0x2, 0x0, 0x0, 0x44, 0xb9, + 0x27, 0x0, 0x0, 0x6a, 0xa7, 0x1c, 0x0, 0x15, 0x64, 0x92, 0xb9, 0x3c, 0xff, 0x97, 0x38, 0x17, + 0x22, 0xa3, 0x5b, 0xb0, 0x7c, 0xd6, 0x67, 0x2f, 0x77, 0xd2, 0x4e, 0xfa, 0x73, 0x19, 0x8c, 0x8, + 0x0, 0xc, 0xac, 0x90, 0x12, 0x8c, 0x82, 0x5c, 0x19, 0xd, 0x6a, 0xf3, 0x87, 0x36, 0x19, 0x18, + 0x21, 0x60, 0x1a, 0x25, 0xc5, 0x18, 0x0, 0x0, 0x1e, 0x47, 0x17, 0x24, 0x19, 0x4c, 0xb, 0x7, + 0x19, 0x2, 0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; + uint8_t topic_bytes[] = {0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, + 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x5c, 0x37, 0x7, 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, - 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; + msg.retained = false; + uint8_t msg_bytes[] = {0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 11; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xe6, 0xd7, 0x5a, 0x9d, 0x55, 0xbe, 0xf1, 0x66, 0xae, 0x96, 0x7b, 0xb7, - 0x15, 0xef, 0xcc, 0xa, 0x96, 0xb7, 0x80, 0x41, 0x56, 0x90, 0xa}; - uint8_t bytesprops2[] = {0x47, 0xc0, 0xce, 0x83, 0x91, 0x1, 0xff, 0x3e, 0xd3, - 0x26, 0x88, 0xa1, 0x24, 0x21, 0x60, 0x5e, 0x47}; - uint8_t bytesprops3[] = {0x71, 0x1e, 0x1e, 0x42, 0x5c, 0xcc, 0xb6, 0xa5}; - uint8_t bytesprops4[] = {0x8a, 0x5b, 0xf7, 0xf6, 0xa6, 0x1d, 0x18, 0x78, 0x1e, 0xbc}; - uint8_t bytesprops5[] = {0xe5, 0xcb, 0x1d, 0x92, 0x49, 0xca, 0x74, 0xb6, 0xe6, 0x25, 0xee, 0x4f, 0x11, 0xed, - 0xde, 0xdb, 0xaf, 0xd5, 0x56, 0x54, 0xba, 0x9a, 0x13, 0x64, 0xfb, 0x8a, 0x41, 0xf}; - uint8_t bytesprops6[] = {0x3f, 0x67, 0x25, 0xb4, 0x17, 0x30, 0xe2, 0xbf, 0x57, 0xc6, 0x21, 0x4b, 0xaf, 0xc, - 0xf0, 0x9f, 0xba, 0x57, 0xd2, 0xa6, 0x4c, 0xbc, 0x16, 0x88, 0x19, 0xc7, 0xe5, 0x39}; + uint8_t bytesprops0[] = {0xbd, 0x12, 0x75, 0x7d, 0x6f, 0x26, 0xda, 0x47, 0xef, 0x14, 0xca, 0x3b, 0x8f, 0x8}; + uint8_t bytesprops1[] = {0x81, 0x3d, 0xb7, 0xae, 0x66, 0xd2, 0xb8, 0xcc, 0x68, 0xc3, 0xdf, 0x5c, 0x8a, 0x8d}; + uint8_t bytesprops2[] = {0x64, 0x92, 0xb9, 0x3c, 0xff, 0x97, 0x38, 0x17, 0x22, 0xa3, 0x5b, + 0xb0, 0x7c, 0xd6, 0x67, 0x2f, 0x77, 0xd2, 0x4e, 0xfa, 0x73}; + uint8_t bytesprops3[] = {0xac, 0x90, 0x12, 0x8c, 0x82, 0x5c, 0x19, 0xd, 0x6a, 0xf3, 0x87, 0x36}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21151}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 151}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11185}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25334}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12433}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19132}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1218}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8113}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6126}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12936}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29399}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20663}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17593}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27303}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24602}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7751}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 2}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32430, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7369, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "2]\237\233\224\238", _pubPktID = -// 32430, _pubBody = "\\7\a}d\f\191)\250N\n\r\240\169\178\184]", _pubProps = [PropResponseInformation -// "",PropMessageExpiryInterval 21151,PropMessageExpiryInterval 151,PropReasonString -// "\230\215Z\157U\190\241f\174\150{\183\NAK\239\204\n\150\183\128AV\144\n",PropMaximumPacketSize -// 11185,PropMaximumPacketSize 25334,PropSubscriptionIdentifierAvailable 124,PropReceiveMaximum -// 12433,PropCorrelationData "G\192\206\131\145\SOH\255>\211&\136\161$!`^G",PropServerKeepAlive -// 19132,PropServerReference "q\RS\RSB\\\204\182\165",PropRetainAvailable 93,PropServerKeepAlive 1218,PropMaximumQoS -// 66,PropPayloadFormatIndicator 228,PropResponseInformation -// "\138[\247\246\166\GS\CANx\RS\188",PropAssignedClientIdentifier -// "\229\203\GS\146I\202t\182\230%\238O\DC1\237\222\219\175\213VT\186\154\DC3d\251\138A\SI",PropMaximumQoS -// 44,PropMessageExpiryInterval 8113,PropMaximumQoS 61,PropRequestResponseInformation -// 120,PropSubscriptionIdentifierAvailable 168,PropReceiveMaximum 6126,PropResponseInformation -// "?g%\180\ETB0\226\191W\198!K\175\f\240\159\186W\210\166L\188\SYN\136\EM\199\229\&9",PropPayloadFormatIndicator -// 19,PropMaximumQoS 97]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\223~\247S\221_\137\253\202\t\SO<\197\171X=\DC1'\196\ACK", _pubPktID = 7369, _pubBody = +// "\218\SI\242\t\138\r\SO\ESC[\224\207", _pubProps = [PropMaximumPacketSize 12936,PropServerKeepAlive +// 29399,PropRetainAvailable 124,PropTopicAliasMaximum 20663,PropReasonString +// "\189\DC2u}o&\218G\239\DC4\202;\143\b",PropCorrelationData +// "\129=\183\174f\210\184\204h\195\223\\\138\141",PropMessageExpiryInterval 17593,PropMaximumPacketSize +// 27303,PropServerReference "d\146\185<\255\151\&8\ETB\"\163[\176|\214g/w\210N\250s",PropRequestResponseInformation +// 140,PropResponseTopic "\172\144\DC2\140\130\\\EM\rj\243\135\&6",PropRequestResponseInformation 24,PropReceiveMaximum +// 24602,PropRetainAvailable 197,PropWillDelayInterval 7751,PropRequestProblemInformation +// 36,PropRequestResponseInformation 76,PropSubscriptionIdentifier 7,PropRequestResponseInformation 2]} TEST(Publish5QCTest, Decode4) { - uint8_t pkt[] = { - 0x35, 0xdd, 0x1, 0x0, 0x6, 0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee, 0x7e, 0xae, 0xc0, 0x1, 0x1a, 0x0, 0x0, 0x2, - 0x0, 0x0, 0x52, 0x9f, 0x2, 0x0, 0x0, 0x0, 0x97, 0x1f, 0x0, 0x17, 0xe6, 0xd7, 0x5a, 0x9d, 0x55, 0xbe, 0xf1, - 0x66, 0xae, 0x96, 0x7b, 0xb7, 0x15, 0xef, 0xcc, 0xa, 0x96, 0xb7, 0x80, 0x41, 0x56, 0x90, 0xa, 0x27, 0x0, 0x0, - 0x2b, 0xb1, 0x27, 0x0, 0x0, 0x62, 0xf6, 0x29, 0x7c, 0x21, 0x30, 0x91, 0x9, 0x0, 0x11, 0x47, 0xc0, 0xce, 0x83, - 0x91, 0x1, 0xff, 0x3e, 0xd3, 0x26, 0x88, 0xa1, 0x24, 0x21, 0x60, 0x5e, 0x47, 0x13, 0x4a, 0xbc, 0x1c, 0x0, 0x8, - 0x71, 0x1e, 0x1e, 0x42, 0x5c, 0xcc, 0xb6, 0xa5, 0x25, 0x5d, 0x13, 0x4, 0xc2, 0x24, 0x42, 0x1, 0xe4, 0x1a, 0x0, - 0xa, 0x8a, 0x5b, 0xf7, 0xf6, 0xa6, 0x1d, 0x18, 0x78, 0x1e, 0xbc, 0x12, 0x0, 0x1c, 0xe5, 0xcb, 0x1d, 0x92, 0x49, - 0xca, 0x74, 0xb6, 0xe6, 0x25, 0xee, 0x4f, 0x11, 0xed, 0xde, 0xdb, 0xaf, 0xd5, 0x56, 0x54, 0xba, 0x9a, 0x13, 0x64, - 0xfb, 0x8a, 0x41, 0xf, 0x24, 0x2c, 0x2, 0x0, 0x0, 0x1f, 0xb1, 0x24, 0x3d, 0x19, 0x78, 0x29, 0xa8, 0x21, 0x17, - 0xee, 0x1a, 0x0, 0x1c, 0x3f, 0x67, 0x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 0x17, 0x24, 0x19, 0x4c, 0xb, 0x7, + 0x19, 0x2, 0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2328,133 +2241,72 @@ TEST(Publish5QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x32, 0x5d, 0xed, 0xe9, 0xe0, 0xee}; - lwmqtt_string_t exp_topic = {6, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5c, 0x37, 0x7, 0x7d, 0x64, 0xc, 0xbf, 0x29, 0xfa, - 0x4e, 0xa, 0xd, 0xf0, 0xa9, 0xb2, 0xb8, 0x5d}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, + 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 32430); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 6); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7369); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "V\156\142\176", _pubPktID = 29213, -// _pubBody = "\EM\FSK\190t\254o\168\200\&9\131(\254Z\138g\243jL|\137\220", _pubProps = [PropMaximumPacketSize -// 3871,PropMaximumQoS 160,PropMessageExpiryInterval 10386,PropRequestResponseInformation -// 71,PropRequestProblemInformation 55,PropRetainAvailable 35,PropReceiveMaximum 27736,PropMessageExpiryInterval -// 15681,PropMaximumQoS 67,PropAuthenticationData "{jG\fFZ\241\EM\239G\254",PropResponseInformation -// "TW\FS{r\"\SI\182\168\b\182X\154\207@\195\192\248\&92\185>\DC3`\243\SYN",PropReasonString -// "\139\171\245\232",PropMessageExpiryInterval 15064,PropPayloadFormatIndicator 3,PropRequestProblemInformation -// 14,PropSubscriptionIdentifierAvailable 35,PropWillDelayInterval 5426,PropRequestProblemInformation -// 178,PropContentType "\136\206\198#c\DEL\219",PropResponseInformation "3\n",PropRetainAvailable 192,PropTopicAlias -// 19843,PropMaximumPacketSize 12373,PropRetainAvailable 239,PropContentType -// "!\164\212\179e\SO$\195nqq\153a\252\246\234\194\245\188",PropResponseTopic "\152",PropWillDelayInterval -// 22627,PropRequestResponseInformation 4]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\250\191\190jan\209", _pubPktID = +// 6761, _pubBody = "z-\195\235\243\220Q", _pubProps = [PropMaximumQoS 51,PropWildcardSubscriptionAvailable +// 241,PropWillDelayInterval 30710,PropAuthenticationData "m\144\196p",PropRetainAvailable 66,PropMaximumPacketSize +// 28886,PropWillDelayInterval 10121,PropSharedSubscriptionAvailable 136]} TEST(Publish5QCTest, Encode5) { - uint8_t pkt[] = {0x35, 0xbc, 0x1, 0x0, 0x4, 0x56, 0x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9c, 0x8e, 0xb0}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x31, 0x0, 0x7, 0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1, 0x1a, 0x69, + 0x1e, 0x24, 0x33, 0x28, 0xf1, 0x18, 0x0, 0x0, 0x77, 0xf6, 0x16, 0x0, 0x4, + 0x6d, 0x90, 0xc4, 0x70, 0x25, 0x42, 0x27, 0x0, 0x0, 0x70, 0xd6, 0x18, 0x0, + 0x0, 0x27, 0x89, 0x2a, 0x88, 0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; + uint8_t topic_bytes[] = {0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, 0x6f, 0xa8, 0xc8, 0x39, 0x83, - 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; + msg.retained = false; + uint8_t msg_bytes[] = {0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 7; - uint8_t bytesprops0[] = {0x7b, 0x6a, 0x47, 0xc, 0x46, 0x5a, 0xf1, 0x19, 0xef, 0x47, 0xfe}; - uint8_t bytesprops1[] = {0x54, 0x57, 0x1c, 0x7b, 0x72, 0x22, 0xf, 0xb6, 0xa8, 0x8, 0xb6, 0x58, 0x9a, - 0xcf, 0x40, 0xc3, 0xc0, 0xf8, 0x39, 0x32, 0xb9, 0x3e, 0x13, 0x60, 0xf3, 0x16}; - uint8_t bytesprops2[] = {0x8b, 0xab, 0xf5, 0xe8}; - uint8_t bytesprops3[] = {0x88, 0xce, 0xc6, 0x23, 0x63, 0x7f, 0xdb}; - uint8_t bytesprops4[] = {0x33, 0xa}; - uint8_t bytesprops5[] = {0x21, 0xa4, 0xd4, 0xb3, 0x65, 0xe, 0x24, 0xc3, 0x6e, 0x71, - 0x71, 0x99, 0x61, 0xfc, 0xf6, 0xea, 0xc2, 0xf5, 0xbc}; - uint8_t bytesprops6[] = {0x98}; + uint8_t bytesprops0[] = {0x6d, 0x90, 0xc4, 0x70}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3871}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10386}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27736}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15681}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15064}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5426}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19843}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12373}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22627}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30710}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28886}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10121}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 136}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29213, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6761, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "V\156\142\176", _pubPktID = 29213, -// _pubBody = "\EM\FSK\190t\254o\168\200\&9\131(\254Z\138g\243jL|\137\220", _pubProps = [PropMaximumPacketSize -// 3871,PropMaximumQoS 160,PropMessageExpiryInterval 10386,PropRequestResponseInformation -// 71,PropRequestProblemInformation 55,PropRetainAvailable 35,PropReceiveMaximum 27736,PropMessageExpiryInterval -// 15681,PropMaximumQoS 67,PropAuthenticationData "{jG\fFZ\241\EM\239G\254",PropResponseInformation -// "TW\FS{r\"\SI\182\168\b\182X\154\207@\195\192\248\&92\185>\DC3`\243\SYN",PropReasonString -// "\139\171\245\232",PropMessageExpiryInterval 15064,PropPayloadFormatIndicator 3,PropRequestProblemInformation -// 14,PropSubscriptionIdentifierAvailable 35,PropWillDelayInterval 5426,PropRequestProblemInformation -// 178,PropContentType "\136\206\198#c\DEL\219",PropResponseInformation "3\n",PropRetainAvailable 192,PropTopicAlias -// 19843,PropMaximumPacketSize 12373,PropRetainAvailable 239,PropContentType -// "!\164\212\179e\SO$\195nqq\153a\252\246\234\194\245\188",PropResponseTopic "\152",PropWillDelayInterval -// 22627,PropRequestResponseInformation 4]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\250\191\190jan\209", _pubPktID = +// 6761, _pubBody = "z-\195\235\243\220Q", _pubProps = [PropMaximumQoS 51,PropWildcardSubscriptionAvailable +// 241,PropWillDelayInterval 30710,PropAuthenticationData "m\144\196p",PropRetainAvailable 66,PropMaximumPacketSize +// 28886,PropWillDelayInterval 10121,PropSharedSubscriptionAvailable 136]} TEST(Publish5QCTest, Decode5) { - uint8_t pkt[] = {0x35, 0xbc, 0x1, 0x0, 0x4, 0x56, 0x9c, 0x8e, 0xb0, 0x72, 0x1d, 0x9c, 0x1, 0x27, 0x0, 0x0, - 0xf, 0x1f, 0x24, 0xa0, 0x2, 0x0, 0x0, 0x28, 0x92, 0x19, 0x47, 0x17, 0x37, 0x25, 0x23, 0x21, - 0x6c, 0x58, 0x2, 0x0, 0x0, 0x3d, 0x41, 0x24, 0x43, 0x16, 0x0, 0xb, 0x7b, 0x6a, 0x47, 0xc, - 0x46, 0x5a, 0xf1, 0x19, 0xef, 0x47, 0xfe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0xdc, 0x51}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2463,80 +2315,109 @@ TEST(Publish5QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x56, 0x9c, 0x8e, 0xb0}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x19, 0x1c, 0x4b, 0xbe, 0x74, 0xfe, 0x6f, 0xa8, 0xc8, 0x39, 0x83, - 0x28, 0xfe, 0x5a, 0x8a, 0x67, 0xf3, 0x6a, 0x4c, 0x7c, 0x89, 0xdc}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29213); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 6761); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "j-w\135im\135", _pubPktID = 15185, -// _pubBody = "\178\183W\163D\179", _pubProps = [PropResponseTopic -// "\FS\n\NULY#r\132\&4\DEL%\206{/7V=\ETB\195W\192,\229\135\162\ETB\250\175\194\170",PropServerKeepAlive -// 4458,PropSharedSubscriptionAvailable 33,PropSessionExpiryInterval 14022,PropSubscriptionIdentifierAvailable -// 239,PropServerReference "\164\228\204[\165\224\229)\SYN66\195{\211\227u\EM\249",PropMessageExpiryInterval 808]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\229Y\156\186GOd\EOT\247\ETB\224\251-\228h{^Q!\246\b\DEL\225\NUL{/Q ", _pubPktID = 0, _pubBody = "<@\201Iv", +// _pubProps = [PropWildcardSubscriptionAvailable 30,PropRequestProblemInformation 173,PropSharedSubscriptionAvailable +// 114,PropRequestProblemInformation 48,PropSharedSubscriptionAvailable 63,PropWildcardSubscriptionAvailable +// 80,PropAssignedClientIdentifier "j",PropReceiveMaximum 7010,PropTopicAliasMaximum 29063,PropResponseInformation +// "\150\206\240\187U\152#\224]2=,\t\189\138\205\255\254`\175{}",PropServerKeepAlive 31184,PropReasonString +// "\ETXA",PropRequestProblemInformation 225,PropRetainAvailable 107,PropResponseTopic +// "\153\228\225A$\189h\217",PropAuthenticationMethod ";\180\240#\146Z \140_\212$\176\156Nt| +// \r",PropAuthenticationMethod "\175V\149+\250\164\254\205\181\234v`\233\247j\161\146\174"]} TEST(Publish5QCTest, Encode6) { - uint8_t pkt[] = {0x35, 0x58, 0x0, 0x7, 0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87, 0x3b, 0x51, 0x46, 0x8, - 0x0, 0x1d, 0x1c, 0xa, 0x0, 0x59, 0x23, 0x72, 0x84, 0x34, 0x7f, 0x25, 0xce, 0x7b, 0x2f, - 0x37, 0x56, 0x3d, 0x17, 0xc3, 0x57, 0xc0, 0x2c, 0xe5, 0x87, 0xa2, 0x17, 0xfa, 0xaf, 0xc2, - 0xaa, 0x13, 0x11, 0x6a, 0x2a, 0x21, 0x11, 0x0, 0x0, 0x36, 0xc6, 0x29, 0xef, 0x1c, 0x0, - 0x12, 0xa4, 0xe4, 0xcc, 0x5b, 0xa5, 0xe0, 0xe5, 0x29, 0x16, 0x36, 0x36, 0xc3, 0x7b, 0xd3, - 0xe3, 0x75, 0x19, 0xf9, 0x2, 0x0, 0x0, 0x3, 0x28, 0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; - uint8_t topic_bytes[] = {0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x94, 0x1, 0x0, 0x1c, 0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, + 0x2d, 0xe4, 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20, 0x70, + 0x28, 0x1e, 0x17, 0xad, 0x2a, 0x72, 0x17, 0x30, 0x2a, 0x3f, 0x28, 0x50, 0x12, 0x0, 0x1, 0x6a, 0x21, + 0x1b, 0x62, 0x22, 0x71, 0x87, 0x1a, 0x0, 0x16, 0x96, 0xce, 0xf0, 0xbb, 0x55, 0x98, 0x23, 0xe0, 0x5d, + 0x32, 0x3d, 0x2c, 0x9, 0xbd, 0x8a, 0xcd, 0xff, 0xfe, 0x60, 0xaf, 0x7b, 0x7d, 0x13, 0x79, 0xd0, 0x1f, + 0x0, 0x2, 0x3, 0x41, 0x17, 0xe1, 0x25, 0x6b, 0x8, 0x0, 0x8, 0x99, 0xe4, 0xe1, 0x41, 0x24, 0xbd, + 0x68, 0xd9, 0x15, 0x0, 0x12, 0x3b, 0xb4, 0xf0, 0x23, 0x92, 0x5a, 0x20, 0x8c, 0x5f, 0xd4, 0x24, 0xb0, + 0x9c, 0x4e, 0x74, 0x7c, 0x20, 0xd, 0x15, 0x0, 0x12, 0xaf, 0x56, 0x95, 0x2b, 0xfa, 0xa4, 0xfe, 0xcd, + 0xb5, 0xea, 0x76, 0x60, 0xe9, 0xf7, 0x6a, 0xa1, 0x92, 0xae, 0x3c, 0x40, 0xc9, 0x49, 0x76}; + uint8_t topic_bytes[] = {0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, 0x2d, 0xe4, + 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + uint8_t msg_bytes[] = {0x3c, 0x40, 0xc9, 0x49, 0x76}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; - - uint8_t bytesprops0[] = {0x1c, 0xa, 0x0, 0x59, 0x23, 0x72, 0x84, 0x34, 0x7f, 0x25, 0xce, 0x7b, 0x2f, 0x37, 0x56, - 0x3d, 0x17, 0xc3, 0x57, 0xc0, 0x2c, 0xe5, 0x87, 0xa2, 0x17, 0xfa, 0xaf, 0xc2, 0xaa}; - uint8_t bytesprops1[] = {0xa4, 0xe4, 0xcc, 0x5b, 0xa5, 0xe0, 0xe5, 0x29, 0x16, - 0x36, 0x36, 0xc3, 0x7b, 0xd3, 0xe3, 0x75, 0x19, 0xf9}; + msg.payload_len = 5; + + uint8_t bytesprops0[] = {0x6a}; + uint8_t bytesprops1[] = {0x96, 0xce, 0xf0, 0xbb, 0x55, 0x98, 0x23, 0xe0, 0x5d, 0x32, 0x3d, + 0x2c, 0x9, 0xbd, 0x8a, 0xcd, 0xff, 0xfe, 0x60, 0xaf, 0x7b, 0x7d}; + uint8_t bytesprops2[] = {0x3, 0x41}; + uint8_t bytesprops3[] = {0x99, 0xe4, 0xe1, 0x41, 0x24, 0xbd, 0x68, 0xd9}; + uint8_t bytesprops4[] = {0x3b, 0xb4, 0xf0, 0x23, 0x92, 0x5a, 0x20, 0x8c, 0x5f, + 0xd4, 0x24, 0xb0, 0x9c, 0x4e, 0x74, 0x7c, 0x20, 0xd}; + uint8_t bytesprops5[] = {0xaf, 0x56, 0x95, 0x2b, 0xfa, 0xa4, 0xfe, 0xcd, 0xb5, + 0xea, 0x76, 0x60, 0xe9, 0xf7, 0x6a, 0xa1, 0x92, 0xae}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4458}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14022}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 808}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7010}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29063}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31184}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15185, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "j-w\135im\135", _pubPktID = 15185, -// _pubBody = "\178\183W\163D\179", _pubProps = [PropResponseTopic -// "\FS\n\NULY#r\132\&4\DEL%\206{/7V=\ETB\195W\192,\229\135\162\ETB\250\175\194\170",PropServerKeepAlive -// 4458,PropSharedSubscriptionAvailable 33,PropSessionExpiryInterval 14022,PropSubscriptionIdentifierAvailable -// 239,PropServerReference "\164\228\204[\165\224\229)\SYN66\195{\211\227u\EM\249",PropMessageExpiryInterval 808]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\229Y\156\186GOd\EOT\247\ETB\224\251-\228h{^Q!\246\b\DEL\225\NUL{/Q ", _pubPktID = 0, _pubBody = "<@\201Iv", +// _pubProps = [PropWildcardSubscriptionAvailable 30,PropRequestProblemInformation 173,PropSharedSubscriptionAvailable +// 114,PropRequestProblemInformation 48,PropSharedSubscriptionAvailable 63,PropWildcardSubscriptionAvailable +// 80,PropAssignedClientIdentifier "j",PropReceiveMaximum 7010,PropTopicAliasMaximum 29063,PropResponseInformation +// "\150\206\240\187U\152#\224]2=,\t\189\138\205\255\254`\175{}",PropServerKeepAlive 31184,PropReasonString +// "\ETXA",PropRequestProblemInformation 225,PropRetainAvailable 107,PropResponseTopic +// "\153\228\225A$\189h\217",PropAuthenticationMethod ";\180\240#\146Z \140_\212$\176\156Nt| +// \r",PropAuthenticationMethod "\175V\149+\250\164\254\205\181\234v`\233\247j\161\146\174"]} TEST(Publish5QCTest, Decode6) { - uint8_t pkt[] = {0x35, 0x58, 0x0, 0x7, 0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87, 0x3b, 0x51, 0x46, 0x8, - 0x0, 0x1d, 0x1c, 0xa, 0x0, 0x59, 0x23, 0x72, 0x84, 0x34, 0x7f, 0x25, 0xce, 0x7b, 0x2f, - 0x37, 0x56, 0x3d, 0x17, 0xc3, 0x57, 0xc0, 0x2c, 0xe5, 0x87, 0xa2, 0x17, 0xfa, 0xaf, 0xc2, - 0xaa, 0x13, 0x11, 0x6a, 0x2a, 0x21, 0x11, 0x0, 0x0, 0x36, 0xc6, 0x29, 0xef, 0x1c, 0x0, - 0x12, 0xa4, 0xe4, 0xcc, 0x5b, 0xa5, 0xe0, 0xe5, 0x29, 0x16, 0x36, 0x36, 0xc3, 0x7b, 0xd3, - 0xe3, 0x75, 0x19, 0xf9, 0x2, 0x0, 0x0, 0x3, 0x28, 0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; + uint8_t pkt[] = {0x39, 0x94, 0x1, 0x0, 0x1c, 0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, + 0x2d, 0xe4, 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20, 0x70, + 0x28, 0x1e, 0x17, 0xad, 0x2a, 0x72, 0x17, 0x30, 0x2a, 0x3f, 0x28, 0x50, 0x12, 0x0, 0x1, 0x6a, 0x21, + 0x1b, 0x62, 0x22, 0x71, 0x87, 0x1a, 0x0, 0x16, 0x96, 0xce, 0xf0, 0xbb, 0x55, 0x98, 0x23, 0xe0, 0x5d, + 0x32, 0x3d, 0x2c, 0x9, 0xbd, 0x8a, 0xcd, 0xff, 0xfe, 0x60, 0xaf, 0x7b, 0x7d, 0x13, 0x79, 0xd0, 0x1f, + 0x0, 0x2, 0x3, 0x41, 0x17, 0xe1, 0x25, 0x6b, 0x8, 0x0, 0x8, 0x99, 0xe4, 0xe1, 0x41, 0x24, 0xbd, + 0x68, 0xd9, 0x15, 0x0, 0x12, 0x3b, 0xb4, 0xf0, 0x23, 0x92, 0x5a, 0x20, 0x8c, 0x5f, 0xd4, 0x24, 0xb0, + 0x9c, 0x4e, 0x74, 0x7c, 0x20, 0xd, 0x15, 0x0, 0x12, 0xaf, 0x56, 0x95, 0x2b, 0xfa, 0xa4, 0xfe, 0xcd, + 0xb5, 0xea, 0x76, 0x60, 0xe9, 0xf7, 0x6a, 0xa1, 0x92, 0xae, 0x3c, 0x40, 0xc9, 0x49, 0x76}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2545,70 +2426,119 @@ TEST(Publish5QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x6a, 0x2d, 0x77, 0x87, 0x69, 0x6d, 0x87}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb2, 0xb7, 0x57, 0xa3, 0x44, 0xb3}; - lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, 0x2d, 0xe4, + 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x3c, 0x40, 0xc9, 0x49, 0x76}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 15185); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 6); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129\166\ACK\241", _pubPktID = 26446, -// _pubBody = "h'uL\n\225\221gp\182{\140\DC4\136\151c\170\191\r|\214\197\&7", _pubProps = [PropPayloadFormatIndicator -// 170,PropCorrelationData "&Gz\228\136\t\SUBx!V_@\228",PropAuthenticationMethod "\161e",PropRetainAvailable -// 105,PropMessageExpiryInterval 22688]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\242\EM\182T\137\181\\_\NUL\137\135\&0\211", _pubPktID = 31937, _pubBody = +// "\242\196\240\145t\150mj\CANV\251\200\142o\192\150G", _pubProps = [PropRetainAvailable 122,PropSubscriptionIdentifier +// 19,PropReasonString +// "\140l=\142\212\166k\196\222\153\204\166\224!-\SOt\135\152\221\fy\192k!\FS\221\f",PropSharedSubscriptionAvailable +// 194,PropSessionExpiryInterval 2254,PropResponseInformation "\222\199\193\131a@\249",PropWillDelayInterval +// 14313,PropSessionExpiryInterval 29233,PropResponseInformation "\184\154\187\142\"?\231\147",PropResponseInformation +// "\"\US\156\n^\143\tH\US\133\160$g\171\241\173\FS",PropRequestResponseInformation 58,PropResponseInformation +// "Rdn\237\230",PropMessageExpiryInterval 25080,PropReceiveMaximum 25894,PropServerKeepAlive 22192,PropServerReference +// "\166",PropAssignedClientIdentifier +// "\164\233=z\206\223\177<\187\250A\226z.\158;:\ENQ\177J\206\t\v\249\181U\221\240\135"]} TEST(Publish5QCTest, Encode7) { - uint8_t pkt[] = {0x3d, 0x3e, 0x0, 0x4, 0x81, 0xa6, 0x6, 0xf1, 0x67, 0x4e, 0x1e, 0x1, 0xaa, 0x9, 0x0, 0xd, - 0x26, 0x47, 0x7a, 0xe4, 0x88, 0x9, 0x1a, 0x78, 0x21, 0x56, 0x5f, 0x40, 0xe4, 0x15, 0x0, 0x2, - 0xa1, 0x65, 0x25, 0x69, 0x2, 0x0, 0x0, 0x58, 0xa0, 0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, - 0x67, 0x70, 0xb6, 0x7b, 0x8c, 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; - uint8_t topic_bytes[] = {0x81, 0xa6, 0x6, 0xf1}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x35, 0xba, 0x1, 0x0, 0xd, 0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3, 0x7c, + 0xc1, 0x96, 0x1, 0x25, 0x7a, 0xb, 0x13, 0x1f, 0x0, 0x1c, 0x8c, 0x6c, 0x3d, 0x8e, 0xd4, 0xa6, 0x6b, 0xc4, 0xde, + 0x99, 0xcc, 0xa6, 0xe0, 0x21, 0x2d, 0xe, 0x74, 0x87, 0x98, 0xdd, 0xc, 0x79, 0xc0, 0x6b, 0x21, 0x1c, 0xdd, 0xc, + 0x2a, 0xc2, 0x11, 0x0, 0x0, 0x8, 0xce, 0x1a, 0x0, 0x7, 0xde, 0xc7, 0xc1, 0x83, 0x61, 0x40, 0xf9, 0x18, 0x0, + 0x0, 0x37, 0xe9, 0x11, 0x0, 0x0, 0x72, 0x31, 0x1a, 0x0, 0x8, 0xb8, 0x9a, 0xbb, 0x8e, 0x22, 0x3f, 0xe7, 0x93, + 0x1a, 0x0, 0x11, 0x22, 0x1f, 0x9c, 0xa, 0x5e, 0x8f, 0x9, 0x48, 0x1f, 0x85, 0xa0, 0x24, 0x67, 0xab, 0xf1, 0xad, + 0x1c, 0x19, 0x3a, 0x1a, 0x0, 0x5, 0x52, 0x64, 0x6e, 0xed, 0xe6, 0x2, 0x0, 0x0, 0x61, 0xf8, 0x21, 0x65, 0x26, + 0x13, 0x56, 0xb0, 0x1c, 0x0, 0x1, 0xa6, 0x12, 0x0, 0x1d, 0xa4, 0xe9, 0x3d, 0x7a, 0xce, 0xdf, 0xb1, 0x3c, 0xbb, + 0xfa, 0x41, 0xe2, 0x7a, 0x2e, 0x9e, 0x3b, 0x3a, 0x5, 0xb1, 0x4a, 0xce, 0x9, 0xb, 0xf9, 0xb5, 0x55, 0xdd, 0xf0, + 0x87, 0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; + uint8_t topic_bytes[] = {0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; msg.retained = true; - uint8_t msg_bytes[] = {0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, 0x67, 0x70, 0xb6, 0x7b, 0x8c, - 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; + uint8_t msg_bytes[] = {0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, + 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 17; - uint8_t bytesprops0[] = {0x26, 0x47, 0x7a, 0xe4, 0x88, 0x9, 0x1a, 0x78, 0x21, 0x56, 0x5f, 0x40, 0xe4}; - uint8_t bytesprops1[] = {0xa1, 0x65}; + uint8_t bytesprops0[] = {0x8c, 0x6c, 0x3d, 0x8e, 0xd4, 0xa6, 0x6b, 0xc4, 0xde, 0x99, 0xcc, 0xa6, 0xe0, 0x21, + 0x2d, 0xe, 0x74, 0x87, 0x98, 0xdd, 0xc, 0x79, 0xc0, 0x6b, 0x21, 0x1c, 0xdd, 0xc}; + uint8_t bytesprops1[] = {0xde, 0xc7, 0xc1, 0x83, 0x61, 0x40, 0xf9}; + uint8_t bytesprops2[] = {0xb8, 0x9a, 0xbb, 0x8e, 0x22, 0x3f, 0xe7, 0x93}; + uint8_t bytesprops3[] = {0x22, 0x1f, 0x9c, 0xa, 0x5e, 0x8f, 0x9, 0x48, 0x1f, + 0x85, 0xa0, 0x24, 0x67, 0xab, 0xf1, 0xad, 0x1c}; + uint8_t bytesprops4[] = {0x52, 0x64, 0x6e, 0xed, 0xe6}; + uint8_t bytesprops5[] = {0xa6}; + uint8_t bytesprops6[] = {0xa4, 0xe9, 0x3d, 0x7a, 0xce, 0xdf, 0xb1, 0x3c, 0xbb, 0xfa, 0x41, 0xe2, 0x7a, 0x2e, 0x9e, + 0x3b, 0x3a, 0x5, 0xb1, 0x4a, 0xce, 0x9, 0xb, 0xf9, 0xb5, 0x55, 0xdd, 0xf0, 0x87}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22688}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2254}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14313}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29233}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25080}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25894}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22192}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 26446, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 31937, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\129\166\ACK\241", _pubPktID = 26446, -// _pubBody = "h'uL\n\225\221gp\182{\140\DC4\136\151c\170\191\r|\214\197\&7", _pubProps = [PropPayloadFormatIndicator -// 170,PropCorrelationData "&Gz\228\136\t\SUBx!V_@\228",PropAuthenticationMethod "\161e",PropRetainAvailable -// 105,PropMessageExpiryInterval 22688]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\242\EM\182T\137\181\\_\NUL\137\135\&0\211", _pubPktID = 31937, _pubBody = +// "\242\196\240\145t\150mj\CANV\251\200\142o\192\150G", _pubProps = [PropRetainAvailable 122,PropSubscriptionIdentifier +// 19,PropReasonString +// "\140l=\142\212\166k\196\222\153\204\166\224!-\SOt\135\152\221\fy\192k!\FS\221\f",PropSharedSubscriptionAvailable +// 194,PropSessionExpiryInterval 2254,PropResponseInformation "\222\199\193\131a@\249",PropWillDelayInterval +// 14313,PropSessionExpiryInterval 29233,PropResponseInformation "\184\154\187\142\"?\231\147",PropResponseInformation +// "\"\US\156\n^\143\tH\US\133\160$g\171\241\173\FS",PropRequestResponseInformation 58,PropResponseInformation +// "Rdn\237\230",PropMessageExpiryInterval 25080,PropReceiveMaximum 25894,PropServerKeepAlive 22192,PropServerReference +// "\166",PropAssignedClientIdentifier +// "\164\233=z\206\223\177<\187\250A\226z.\158;:\ENQ\177J\206\t\v\249\181U\221\240\135"]} TEST(Publish5QCTest, Decode7) { - uint8_t pkt[] = {0x3d, 0x3e, 0x0, 0x4, 0x81, 0xa6, 0x6, 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, 0x61, 0xf8, 0x21, 0x65, 0x26, + 0x13, 0x56, 0xb0, 0x1c, 0x0, 0x1, 0xa6, 0x12, 0x0, 0x1d, 0xa4, 0xe9, 0x3d, 0x7a, 0xce, 0xdf, 0xb1, 0x3c, 0xbb, + 0xfa, 0x41, 0xe2, 0x7a, 0x2e, 0x9e, 0x3b, 0x3a, 0x5, 0xb1, 0x4a, 0xce, 0x9, 0xb, 0xf9, 0xb5, 0x55, 0xdd, 0xf0, + 0x87, 0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2617,133 +2547,164 @@ TEST(Publish5QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x81, 0xa6, 0x6, 0xf1}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x68, 0x27, 0x75, 0x4c, 0xa, 0xe1, 0xdd, 0x67, 0x70, 0xb6, 0x7b, 0x8c, - 0x14, 0x88, 0x97, 0x63, 0xaa, 0xbf, 0xd, 0x7c, 0xd6, 0xc5, 0x37}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, + 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 26446); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 23); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); + EXPECT_EQ(packet_id, 31937); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "}\250\132\234S\200EV\164\175\218\237D", _pubPktID = 25658, _pubBody = -// "\DLE\DC3\242\235C\134\216h\196\ETB\255\169\164\222", _pubProps = [PropResponseTopic -// "\164\ETX\255\SYN\169a\EM\237\135\219?\183(\DLE2i\254\191?s\217\SI\229\243&\130",PropMessageExpiryInterval -// 16431,PropReasonString "\218\232\&8_\216\202'@\227\ACK|\252\NUL\ACK\235",PropRetainAvailable -// 227,PropSessionExpiryInterval 1125,PropCorrelationData -// "\188\180-\146\252\250Y\134|\255\169\224\228\226\&8\169\195\229o",PropServerKeepAlive 31922,PropReceiveMaximum -// 13953,PropResponseTopic "*}",PropReceiveMaximum 10205,PropRequestProblemInformation -// 46,PropWildcardSubscriptionAvailable 199,PropServerKeepAlive 17597,PropMaximumQoS 236,PropServerReference -// "\ENQI\177\187%LN\EM,\168d\215\245\220\170\203\247\DC2~E\SI\139\ACK\RS\189d\183;9",PropRetainAvailable -// 170,PropPayloadFormatIndicator 164,PropServerKeepAlive 13334,PropServerKeepAlive 20469,PropRequestResponseInformation -// 170,PropServerKeepAlive 964,PropSharedSubscriptionAvailable 117,PropAssignedClientIdentifier -// "\244=\"\141i\204\DC1\ENQ\r\DLE\ESC\rqV\251\DC1\188\213i\148q",PropTopicAliasMaximum 28761]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q", _pubPktID = 31364, _pubBody = +// "J\NAK\203\196\226\"\223\GS\200a", _pubProps = [PropResponseTopic +// "s\189\254=\155q+\137\192=\248J\fp\152\162<",PropTopicAliasMaximum 24003,PropServerKeepAlive +// 19136,PropAssignedClientIdentifier "v\160!%L>\161\232\190&]U\199'&Z\224z\249",PropResponseTopic +// "\229\161+\255\128u?\DC1",PropAuthenticationMethod +// "\ACK2\135\209F\135\136\253x\RS\141\227\165",PropSubscriptionIdentifier 9,PropAuthenticationData +// "i\EM\192\253\161f;MIF\130B\159\160\212\183Y\192\237}\136\224",PropReasonString +// "~O\167\ESC\194\253\147K\217\193\222\219",PropAuthenticationMethod "",PropAuthenticationMethod +// "\225\164\b\DLE\SI\246\ETBE\187\220\&7kW\NAKC\206\205\239\227\&9\147\173uTz\139\176",PropServerKeepAlive +// 10976,PropReasonString "\160",PropCorrelationData "L\251\158X\237\135\138\ETB\SYN\208",PropMessageExpiryInterval +// 13532,PropSubscriptionIdentifier 18,PropMaximumQoS 0,PropServerKeepAlive 1892,PropContentType +// "r",PropSubscriptionIdentifierAvailable 72,PropSharedSubscriptionAvailable 67,PropReceiveMaximum +// 5584,PropRequestResponseInformation 193,PropUserProperty +// "0o\232\US\216\196(\156w\234\"\SIz\217\137\135\vw\232\178\160y\144\224\f\NUL7\224" +// "#\DC2'\206[\156\194\217\172\194\b{0\146",PropWildcardSubscriptionAvailable 155,PropRequestProblemInformation +// 110,PropAuthenticationMethod "*\195\218\FS4L\130^!\230:\227RH\US\150\241\175\198\245\134",PropMessageExpiryInterval +// 11523]} TEST(Publish5QCTest, Encode8) { - uint8_t pkt[] = {0x3d, 0xd5, 0x1, 0x0, 0xd, 0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, - 0x44, 0x64, 0x3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, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; - uint8_t topic_bytes[] = {0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x33, 0xa4, 0x2, 0x0, 0x1, 0x71, 0x7a, 0x84, 0x93, 0x2, 0x8, 0x0, 0x11, 0x73, 0xbd, 0xfe, 0x3d, 0x9b, 0x71, + 0x2b, 0x89, 0xc0, 0x3d, 0xf8, 0x4a, 0xc, 0x70, 0x98, 0xa2, 0x3c, 0x22, 0x5d, 0xc3, 0x13, 0x4a, 0xc0, 0x12, 0x0, + 0x13, 0x76, 0xa0, 0x21, 0x25, 0x4c, 0x3e, 0xa1, 0xe8, 0xbe, 0x26, 0x5d, 0x55, 0xc7, 0x27, 0x26, 0x5a, 0xe0, 0x7a, + 0xf9, 0x8, 0x0, 0x8, 0xe5, 0xa1, 0x2b, 0xff, 0x80, 0x75, 0x3f, 0x11, 0x15, 0x0, 0xd, 0x6, 0x32, 0x87, 0xd1, + 0x46, 0x87, 0x88, 0xfd, 0x78, 0x1e, 0x8d, 0xe3, 0xa5, 0xb, 0x9, 0x16, 0x0, 0x16, 0x69, 0x19, 0xc0, 0xfd, 0xa1, + 0x66, 0x3b, 0x4d, 0x49, 0x46, 0x82, 0x42, 0x9f, 0xa0, 0xd4, 0xb7, 0x59, 0xc0, 0xed, 0x7d, 0x88, 0xe0, 0x1f, 0x0, + 0xc, 0x7e, 0x4f, 0xa7, 0x1b, 0xc2, 0xfd, 0x93, 0x4b, 0xd9, 0xc1, 0xde, 0xdb, 0x15, 0x0, 0x0, 0x15, 0x0, 0x1b, + 0xe1, 0xa4, 0x8, 0x10, 0xf, 0xf6, 0x17, 0x45, 0xbb, 0xdc, 0x37, 0x6b, 0x57, 0x15, 0x43, 0xce, 0xcd, 0xef, 0xe3, + 0x39, 0x93, 0xad, 0x75, 0x54, 0x7a, 0x8b, 0xb0, 0x13, 0x2a, 0xe0, 0x1f, 0x0, 0x1, 0xa0, 0x9, 0x0, 0xa, 0x4c, + 0xfb, 0x9e, 0x58, 0xed, 0x87, 0x8a, 0x17, 0x16, 0xd0, 0x2, 0x0, 0x0, 0x34, 0xdc, 0xb, 0x12, 0x24, 0x0, 0x13, + 0x7, 0x64, 0x3, 0x0, 0x1, 0x72, 0x29, 0x48, 0x2a, 0x43, 0x21, 0x15, 0xd0, 0x19, 0xc1, 0x26, 0x0, 0x1c, 0x30, + 0x6f, 0xe8, 0x1f, 0xd8, 0xc4, 0x28, 0x9c, 0x77, 0xea, 0x22, 0xf, 0x7a, 0xd9, 0x89, 0x87, 0xb, 0x77, 0xe8, 0xb2, + 0xa0, 0x79, 0x90, 0xe0, 0xc, 0x0, 0x37, 0xe0, 0x0, 0xe, 0x23, 0x12, 0x27, 0xce, 0x5b, 0x9c, 0xc2, 0xd9, 0xac, + 0xc2, 0x8, 0x7b, 0x30, 0x92, 0x28, 0x9b, 0x17, 0x6e, 0x15, 0x0, 0x15, 0x2a, 0xc3, 0xda, 0x1c, 0x34, 0x4c, 0x82, + 0x5e, 0x21, 0xe6, 0x3a, 0xe3, 0x52, 0x48, 0x1f, 0x96, 0xf1, 0xaf, 0xc6, 0xf5, 0x86, 0x2, 0x0, 0x0, 0x2d, 0x3, + 0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; + uint8_t topic_bytes[] = {0x71}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; + uint8_t msg_bytes[] = {0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; - - uint8_t bytesprops0[] = {0xa4, 0x3, 0xff, 0x16, 0xa9, 0x61, 0x19, 0xed, 0x87, 0xdb, 0x3f, 0xb7, 0x28, - 0x10, 0x32, 0x69, 0xfe, 0xbf, 0x3f, 0x73, 0xd9, 0xf, 0xe5, 0xf3, 0x26, 0x82}; - uint8_t bytesprops1[] = {0xda, 0xe8, 0x38, 0x5f, 0xd8, 0xca, 0x27, 0x40, 0xe3, 0x6, 0x7c, 0xfc, 0x0, 0x6, 0xeb}; - uint8_t bytesprops2[] = {0xbc, 0xb4, 0x2d, 0x92, 0xfc, 0xfa, 0x59, 0x86, 0x7c, 0xff, - 0xa9, 0xe0, 0xe4, 0xe2, 0x38, 0xa9, 0xc3, 0xe5, 0x6f}; - uint8_t bytesprops3[] = {0x2a, 0x7d}; - uint8_t bytesprops4[] = {0x5, 0x49, 0xb1, 0xbb, 0x25, 0x4c, 0x4e, 0x19, 0x2c, 0xa8, 0x64, 0xd7, 0xf5, 0xdc, 0xaa, - 0xcb, 0xf7, 0x12, 0x7e, 0x45, 0xf, 0x8b, 0x6, 0x1e, 0xbd, 0x64, 0xb7, 0x3b, 0x39}; - uint8_t bytesprops5[] = {0xf4, 0x3d, 0x22, 0x8d, 0x69, 0xcc, 0x11, 0x5, 0xd, 0x10, 0x1b, - 0xd, 0x71, 0x56, 0xfb, 0x11, 0xbc, 0xd5, 0x69, 0x94, 0x71}; + msg.payload_len = 10; + + uint8_t bytesprops0[] = {0x73, 0xbd, 0xfe, 0x3d, 0x9b, 0x71, 0x2b, 0x89, 0xc0, + 0x3d, 0xf8, 0x4a, 0xc, 0x70, 0x98, 0xa2, 0x3c}; + uint8_t bytesprops1[] = {0x76, 0xa0, 0x21, 0x25, 0x4c, 0x3e, 0xa1, 0xe8, 0xbe, 0x26, + 0x5d, 0x55, 0xc7, 0x27, 0x26, 0x5a, 0xe0, 0x7a, 0xf9}; + uint8_t bytesprops2[] = {0xe5, 0xa1, 0x2b, 0xff, 0x80, 0x75, 0x3f, 0x11}; + uint8_t bytesprops3[] = {0x6, 0x32, 0x87, 0xd1, 0x46, 0x87, 0x88, 0xfd, 0x78, 0x1e, 0x8d, 0xe3, 0xa5}; + uint8_t bytesprops4[] = {0x69, 0x19, 0xc0, 0xfd, 0xa1, 0x66, 0x3b, 0x4d, 0x49, 0x46, 0x82, + 0x42, 0x9f, 0xa0, 0xd4, 0xb7, 0x59, 0xc0, 0xed, 0x7d, 0x88, 0xe0}; + uint8_t bytesprops5[] = {0x7e, 0x4f, 0xa7, 0x1b, 0xc2, 0xfd, 0x93, 0x4b, 0xd9, 0xc1, 0xde, 0xdb}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops7[] = {0xe1, 0xa4, 0x8, 0x10, 0xf, 0xf6, 0x17, 0x45, 0xbb, 0xdc, 0x37, 0x6b, 0x57, 0x15, + 0x43, 0xce, 0xcd, 0xef, 0xe3, 0x39, 0x93, 0xad, 0x75, 0x54, 0x7a, 0x8b, 0xb0}; + uint8_t bytesprops8[] = {0xa0}; + uint8_t bytesprops9[] = {0x4c, 0xfb, 0x9e, 0x58, 0xed, 0x87, 0x8a, 0x17, 0x16, 0xd0}; + uint8_t bytesprops10[] = {0x72}; + uint8_t bytesprops12[] = {0x23, 0x12, 0x27, 0xce, 0x5b, 0x9c, 0xc2, 0xd9, 0xac, 0xc2, 0x8, 0x7b, 0x30, 0x92}; + uint8_t bytesprops11[] = {0x30, 0x6f, 0xe8, 0x1f, 0xd8, 0xc4, 0x28, 0x9c, 0x77, 0xea, 0x22, 0xf, 0x7a, 0xd9, + 0x89, 0x87, 0xb, 0x77, 0xe8, 0xb2, 0xa0, 0x79, 0x90, 0xe0, 0xc, 0x0, 0x37, 0xe0}; + uint8_t bytesprops13[] = {0x2a, 0xc3, 0xda, 0x1c, 0x34, 0x4c, 0x82, 0x5e, 0x21, 0xe6, 0x3a, + 0xe3, 0x52, 0x48, 0x1f, 0x96, 0xf1, 0xaf, 0xc6, 0xf5, 0x86}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16431}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1125}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31922}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13953}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10205}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17597}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13334}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20469}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 964}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28761}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24003}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19136}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10976}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13532}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1892}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5584}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {28, (char*)&bytesprops11}, .v = {14, (char*)&bytesprops12}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11523}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25658, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 31364, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "}\250\132\234S\200EV\164\175\218\237D", _pubPktID = 25658, _pubBody = -// "\DLE\DC3\242\235C\134\216h\196\ETB\255\169\164\222", _pubProps = [PropResponseTopic -// "\164\ETX\255\SYN\169a\EM\237\135\219?\183(\DLE2i\254\191?s\217\SI\229\243&\130",PropMessageExpiryInterval -// 16431,PropReasonString "\218\232\&8_\216\202'@\227\ACK|\252\NUL\ACK\235",PropRetainAvailable -// 227,PropSessionExpiryInterval 1125,PropCorrelationData -// "\188\180-\146\252\250Y\134|\255\169\224\228\226\&8\169\195\229o",PropServerKeepAlive 31922,PropReceiveMaximum -// 13953,PropResponseTopic "*}",PropReceiveMaximum 10205,PropRequestProblemInformation -// 46,PropWildcardSubscriptionAvailable 199,PropServerKeepAlive 17597,PropMaximumQoS 236,PropServerReference -// "\ENQI\177\187%LN\EM,\168d\215\245\220\170\203\247\DC2~E\SI\139\ACK\RS\189d\183;9",PropRetainAvailable -// 170,PropPayloadFormatIndicator 164,PropServerKeepAlive 13334,PropServerKeepAlive 20469,PropRequestResponseInformation -// 170,PropServerKeepAlive 964,PropSharedSubscriptionAvailable 117,PropAssignedClientIdentifier -// "\244=\"\141i\204\DC1\ENQ\r\DLE\ESC\rqV\251\DC1\188\213i\148q",PropTopicAliasMaximum 28761]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q", _pubPktID = 31364, _pubBody = +// "J\NAK\203\196\226\"\223\GS\200a", _pubProps = [PropResponseTopic +// "s\189\254=\155q+\137\192=\248J\fp\152\162<",PropTopicAliasMaximum 24003,PropServerKeepAlive +// 19136,PropAssignedClientIdentifier "v\160!%L>\161\232\190&]U\199'&Z\224z\249",PropResponseTopic +// "\229\161+\255\128u?\DC1",PropAuthenticationMethod +// "\ACK2\135\209F\135\136\253x\RS\141\227\165",PropSubscriptionIdentifier 9,PropAuthenticationData +// "i\EM\192\253\161f;MIF\130B\159\160\212\183Y\192\237}\136\224",PropReasonString +// "~O\167\ESC\194\253\147K\217\193\222\219",PropAuthenticationMethod "",PropAuthenticationMethod +// "\225\164\b\DLE\SI\246\ETBE\187\220\&7kW\NAKC\206\205\239\227\&9\147\173uTz\139\176",PropServerKeepAlive +// 10976,PropReasonString "\160",PropCorrelationData "L\251\158X\237\135\138\ETB\SYN\208",PropMessageExpiryInterval +// 13532,PropSubscriptionIdentifier 18,PropMaximumQoS 0,PropServerKeepAlive 1892,PropContentType +// "r",PropSubscriptionIdentifierAvailable 72,PropSharedSubscriptionAvailable 67,PropReceiveMaximum +// 5584,PropRequestResponseInformation 193,PropUserProperty +// "0o\232\US\216\196(\156w\234\"\SIz\217\137\135\vw\232\178\160y\144\224\f\NUL7\224" +// "#\DC2'\206[\156\194\217\172\194\b{0\146",PropWildcardSubscriptionAvailable 155,PropRequestProblemInformation +// 110,PropAuthenticationMethod "*\195\218\FS4L\130^!\230:\227RH\US\150\241\175\198\245\134",PropMessageExpiryInterval +// 11523]} TEST(Publish5QCTest, Decode8) { - uint8_t pkt[] = {0x3d, 0xd5, 0x1, 0x0, 0xd, 0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf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x0, 0xa, 0x4c, + 0xfb, 0x9e, 0x58, 0xed, 0x87, 0x8a, 0x17, 0x16, 0xd0, 0x2, 0x0, 0x0, 0x34, 0xdc, 0xb, 0x12, 0x24, 0x0, 0x13, + 0x7, 0x64, 0x3, 0x0, 0x1, 0x72, 0x29, 0x48, 0x2a, 0x43, 0x21, 0x15, 0xd0, 0x19, 0xc1, 0x26, 0x0, 0x1c, 0x30, + 0x6f, 0xe8, 0x1f, 0xd8, 0xc4, 0x28, 0x9c, 0x77, 0xea, 0x22, 0xf, 0x7a, 0xd9, 0x89, 0x87, 0xb, 0x77, 0xe8, 0xb2, + 0xa0, 0x79, 0x90, 0xe0, 0xc, 0x0, 0x37, 0xe0, 0x0, 0xe, 0x23, 0x12, 0x27, 0xce, 0x5b, 0x9c, 0xc2, 0xd9, 0xac, + 0xc2, 0x8, 0x7b, 0x30, 0x92, 0x28, 0x9b, 0x17, 0x6e, 0x15, 0x0, 0x15, 0x2a, 0xc3, 0xda, 0x1c, 0x34, 0x4c, 0x82, + 0x5e, 0x21, 0xe6, 0x3a, 0xe3, 0x52, 0x48, 0x1f, 0x96, 0xf1, 0xaf, 0xc6, 0xf5, 0x86, 0x2, 0x0, 0x0, 0x2d, 0x3, + 0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2752,135 +2713,92 @@ TEST(Publish5QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7d, 0xfa, 0x84, 0xea, 0x53, 0xc8, 0x45, 0x56, 0xa4, 0xaf, 0xda, 0xed, 0x44}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x10, 0x13, 0xf2, 0xeb, 0x43, 0x86, 0xd8, 0x68, 0xc4, 0x17, 0xff, 0xa9, 0xa4, 0xde}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0x71}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 25658); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_EQ(packet_id, 31364); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\ETB\EM\FSn\\^\219_\249\191\CAN\146\196\142\252x\187\173 \r\244[B\136h\210\180", _pubPktID = 12697, _pubBody = -// "\208\EOT\241", _pubProps = [PropResponseTopic "\195\162",PropResponseInformation "\184\204f\153",PropTopicAlias -// 10643,PropMaximumQoS 120,PropMessageExpiryInterval 15357,PropMessageExpiryInterval 24217,PropSubscriptionIdentifier -// 4,PropServerKeepAlive 10759,PropResponseTopic "N\153\&4\249$\156\145\144\176\&1}\r\254\202\227",PropRetainAvailable -// 246,PropAuthenticationData "\179w\r\235\190+",PropMessageExpiryInterval 27852,PropTopicAliasMaximum -// 11775,PropRetainAvailable 87,PropAssignedClientIdentifier "\233\211e6\244",PropSharedSubscriptionAvailable -// 174,PropResponseInformation "\140\216\225W\195\218\136;\SYN\CANX?\DC3\192",PropSessionExpiryInterval -// 27739,PropServerReference "\134\235\135P\n0d0\223^\163\253",PropSubscriptionIdentifierAvailable -// 158,PropServerReference "\251C",PropSessionExpiryInterval 4686,PropTopicAlias 31565,PropServerReference -// "l\133\fk\169\243\159",PropServerReference -// "u6\224\199\176\250\&3\US\213\215#\\K?\226A\249\&54\160",PropWillDelayInterval 196,PropTopicAlias 23560]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\144\171\130\USB\155\212\163\136\212\154", _pubPktID = 8173, _pubBody = +// "\142\178\132u\236\130\153F\CANno\142\151\241\209\208\162\246\156\249\199", _pubProps = +// [PropRequestResponseInformation 100,PropAssignedClientIdentifier +// "u\235\b'?\200\200\222\209\170\244\a\163",PropAuthenticationMethod +// "\130\170\149\228\NAK\DC3(\236\185\239\206\199Ie\136X",PropPayloadFormatIndicator 109,PropReceiveMaximum +// 17095,PropContentType "\132X\255\250z3T;\180\219\144,gS\137BB\144\DC3w\170\248\173a\245\211\246",PropCorrelationData +// "\RSN\167\184\187bki4\152\197F=H\168"]} TEST(Publish5QCTest, Encode9) { - uint8_t pkt[] = {0x3c, 0xd2, 0x1, 0x0, 0x1b, 0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, - 0xc4, 0x8e, 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4, 0x31, 0x99, - 0xae, 0x1, 0x8, 0x0, 0x2, 0xc3, 0xa2, 0x1a, 0x0, 0x4, 0xb8, 0xcc, 0x66, 0x99, 0x23, 0x29, 0x93, - 0x24, 0x78, 0x2, 0x0, 0x0, 0x3b, 0xfd, 0x2, 0x0, 0x0, 0x5e, 0x99, 0xb, 0x4, 0x13, 0x2a, 0x7, - 0x8, 0x0, 0xf, 0x4e, 0x99, 0x34, 0xf9, 0x24, 0x9c, 0x91, 0x90, 0xb0, 0x31, 0x7d, 0xd, 0xfe, 0xca, - 0xe3, 0x25, 0xf6, 0x16, 0x0, 0x6, 0xb3, 0x77, 0xd, 0xeb, 0xbe, 0x2b, 0x2, 0x0, 0x0, 0x6c, 0xcc, - 0x22, 0x2d, 0xff, 0x25, 0x57, 0x12, 0x0, 0x5, 0xe9, 0xd3, 0x65, 0x36, 0xf4, 0x2a, 0xae, 0x1a, 0x0, - 0xe, 0x8c, 0xd8, 0xe1, 0x57, 0xc3, 0xda, 0x88, 0x3b, 0x16, 0x18, 0x58, 0x3f, 0x13, 0xc0, 0x11, 0x0, - 0x0, 0x6c, 0x5b, 0x1c, 0x0, 0xc, 0x86, 0xeb, 0x87, 0x50, 0xa, 0x30, 0x64, 0x30, 0xdf, 0x5e, 0xa3, - 0xfd, 0x29, 0x9e, 0x1c, 0x0, 0x2, 0xfb, 0x43, 0x11, 0x0, 0x0, 0x12, 0x4e, 0x23, 0x7b, 0x4d, 0x1c, - 0x0, 0x7, 0x6c, 0x85, 0xc, 0x6b, 0xa9, 0xf3, 0x9f, 0x1c, 0x0, 0x14, 0x75, 0x36, 0xe0, 0xc7, 0xb0, - 0xfa, 0x33, 0x1f, 0xd5, 0xd7, 0x23, 0x5c, 0x4b, 0x3f, 0xe2, 0x41, 0xf9, 0x35, 0x34, 0xa0, 0x18, 0x0, - 0x0, 0x0, 0xc4, 0x23, 0x5c, 0x8, 0xd0, 0x4, 0xf1}; - uint8_t topic_bytes[] = {0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, - 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x7f, 0x0, 0xb, 0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a, 0x1f, 0xed, + 0x5a, 0x19, 0x64, 0x12, 0x0, 0xd, 0x75, 0xeb, 0x8, 0x27, 0x3f, 0xc8, 0xc8, 0xde, 0xd1, 0xaa, 0xf4, + 0x7, 0xa3, 0x15, 0x0, 0x10, 0x82, 0xaa, 0x95, 0xe4, 0x15, 0x13, 0x28, 0xec, 0xb9, 0xef, 0xce, 0xc7, + 0x49, 0x65, 0x88, 0x58, 0x1, 0x6d, 0x21, 0x42, 0xc7, 0x3, 0x0, 0x1b, 0x84, 0x58, 0xff, 0xfa, 0x7a, + 0x33, 0x54, 0x3b, 0xb4, 0xdb, 0x90, 0x2c, 0x67, 0x53, 0x89, 0x42, 0x42, 0x90, 0x13, 0x77, 0xaa, 0xf8, + 0xad, 0x61, 0xf5, 0xd3, 0xf6, 0x9, 0x0, 0xf, 0x1e, 0x4e, 0xa7, 0xb8, 0xbb, 0x62, 0x6b, 0x69, 0x34, + 0x98, 0xc5, 0x46, 0x3d, 0x48, 0xa8, 0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, + 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; + uint8_t topic_bytes[] = {0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a}; + lwmqtt_string_t topic = {11, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xd0, 0x4, 0xf1}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, + 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; - - uint8_t bytesprops0[] = {0xc3, 0xa2}; - uint8_t bytesprops1[] = {0xb8, 0xcc, 0x66, 0x99}; - uint8_t bytesprops2[] = {0x4e, 0x99, 0x34, 0xf9, 0x24, 0x9c, 0x91, 0x90, 0xb0, 0x31, 0x7d, 0xd, 0xfe, 0xca, 0xe3}; - uint8_t bytesprops3[] = {0xb3, 0x77, 0xd, 0xeb, 0xbe, 0x2b}; - uint8_t bytesprops4[] = {0xe9, 0xd3, 0x65, 0x36, 0xf4}; - uint8_t bytesprops5[] = {0x8c, 0xd8, 0xe1, 0x57, 0xc3, 0xda, 0x88, 0x3b, 0x16, 0x18, 0x58, 0x3f, 0x13, 0xc0}; - uint8_t bytesprops6[] = {0x86, 0xeb, 0x87, 0x50, 0xa, 0x30, 0x64, 0x30, 0xdf, 0x5e, 0xa3, 0xfd}; - uint8_t bytesprops7[] = {0xfb, 0x43}; - uint8_t bytesprops8[] = {0x6c, 0x85, 0xc, 0x6b, 0xa9, 0xf3, 0x9f}; - uint8_t bytesprops9[] = {0x75, 0x36, 0xe0, 0xc7, 0xb0, 0xfa, 0x33, 0x1f, 0xd5, 0xd7, - 0x23, 0x5c, 0x4b, 0x3f, 0xe2, 0x41, 0xf9, 0x35, 0x34, 0xa0}; + msg.payload_len = 21; + + uint8_t bytesprops0[] = {0x75, 0xeb, 0x8, 0x27, 0x3f, 0xc8, 0xc8, 0xde, 0xd1, 0xaa, 0xf4, 0x7, 0xa3}; + uint8_t bytesprops1[] = {0x82, 0xaa, 0x95, 0xe4, 0x15, 0x13, 0x28, 0xec, + 0xb9, 0xef, 0xce, 0xc7, 0x49, 0x65, 0x88, 0x58}; + uint8_t bytesprops2[] = {0x84, 0x58, 0xff, 0xfa, 0x7a, 0x33, 0x54, 0x3b, 0xb4, 0xdb, 0x90, 0x2c, 0x67, 0x53, + 0x89, 0x42, 0x42, 0x90, 0x13, 0x77, 0xaa, 0xf8, 0xad, 0x61, 0xf5, 0xd3, 0xf6}; + uint8_t bytesprops3[] = {0x1e, 0x4e, 0xa7, 0xb8, 0xbb, 0x62, 0x6b, 0x69, 0x34, 0x98, 0xc5, 0x46, 0x3d, 0x48, 0xa8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10643}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15357}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24217}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10759}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27852}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11775}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27739}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4686}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31565}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 196}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23560}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17095}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 12697, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 8173, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\ETB\EM\FSn\\^\219_\249\191\CAN\146\196\142\252x\187\173 \r\244[B\136h\210\180", _pubPktID = 12697, _pubBody = -// "\208\EOT\241", _pubProps = [PropResponseTopic "\195\162",PropResponseInformation "\184\204f\153",PropTopicAlias -// 10643,PropMaximumQoS 120,PropMessageExpiryInterval 15357,PropMessageExpiryInterval 24217,PropSubscriptionIdentifier -// 4,PropServerKeepAlive 10759,PropResponseTopic "N\153\&4\249$\156\145\144\176\&1}\r\254\202\227",PropRetainAvailable -// 246,PropAuthenticationData "\179w\r\235\190+",PropMessageExpiryInterval 27852,PropTopicAliasMaximum -// 11775,PropRetainAvailable 87,PropAssignedClientIdentifier "\233\211e6\244",PropSharedSubscriptionAvailable -// 174,PropResponseInformation "\140\216\225W\195\218\136;\SYN\CANX?\DC3\192",PropSessionExpiryInterval -// 27739,PropServerReference "\134\235\135P\n0d0\223^\163\253",PropSubscriptionIdentifierAvailable -// 158,PropServerReference "\251C",PropSessionExpiryInterval 4686,PropTopicAlias 31565,PropServerReference -// "l\133\fk\169\243\159",PropServerReference -// "u6\224\199\176\250\&3\US\213\215#\\K?\226A\249\&54\160",PropWillDelayInterval 196,PropTopicAlias 23560]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\144\171\130\USB\155\212\163\136\212\154", _pubPktID = 8173, _pubBody = +// "\142\178\132u\236\130\153F\CANno\142\151\241\209\208\162\246\156\249\199", _pubProps = +// [PropRequestResponseInformation 100,PropAssignedClientIdentifier +// "u\235\b'?\200\200\222\209\170\244\a\163",PropAuthenticationMethod +// "\130\170\149\228\NAK\DC3(\236\185\239\206\199Ie\136X",PropPayloadFormatIndicator 109,PropReceiveMaximum +// 17095,PropContentType "\132X\255\250z3T;\180\219\144,gS\137BB\144\DC3w\170\248\173a\245\211\246",PropCorrelationData +// "\RSN\167\184\187bki4\152\197F=H\168"]} TEST(Publish5QCTest, Decode9) { - uint8_t pkt[] = {0x3c, 0xd2, 0x1, 0x0, 0x1b, 0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, - 0xc4, 0x8e, 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4, 0x31, 0x99, - 0xae, 0x1, 0x8, 0x0, 0x2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d4, 0xa3, 0x88, 0xd4, 0x9a, 0x1f, 0xed, + 0x5a, 0x19, 0x64, 0x12, 0x0, 0xd, 0x75, 0xeb, 0x8, 0x27, 0x3f, 0xc8, 0xc8, 0xde, 0xd1, 0xaa, 0xf4, + 0x7, 0xa3, 0x15, 0x0, 0x10, 0x82, 0xaa, 0x95, 0xe4, 0x15, 0x13, 0x28, 0xec, 0xb9, 0xef, 0xce, 0xc7, + 0x49, 0x65, 0x88, 0x58, 0x1, 0x6d, 0x21, 0x42, 0xc7, 0x3, 0x0, 0x1b, 0x84, 0x58, 0xff, 0xfa, 0x7a, + 0x33, 0x54, 0x3b, 0xb4, 0xdb, 0x90, 0x2c, 0x67, 0x53, 0x89, 0x42, 0x42, 0x90, 0x13, 0x77, 0xaa, 0xf8, + 0xad, 0x61, 0xf5, 0xd3, 0xf6, 0x9, 0x0, 0xf, 0x1e, 0x4e, 0xa7, 0xb8, 0xbb, 0x62, 0x6b, 0x69, 0x34, + 0x98, 0xc5, 0x46, 0x3d, 0x48, 0xa8, 0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, + 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2889,109 +2807,56 @@ TEST(Publish5QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x17, 0x19, 0x1c, 0x6e, 0x5c, 0x5e, 0xdb, 0x5f, 0xf9, 0xbf, 0x18, 0x92, 0xc4, 0x8e, - 0xfc, 0x78, 0xbb, 0xad, 0x20, 0xd, 0xf4, 0x5b, 0x42, 0x88, 0x68, 0xd2, 0xb4}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd0, 0x4, 0xf1}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 12697); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + uint8_t exp_topic_bytes[] = {0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a}; + lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, + 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 8173); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\207\219\241(topic.data), 8); - EXPECT_EQ(msg.payload_len, 25); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); + uint8_t exp_topic_bytes[] = {0x40, 0xb3, 0xa0}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2b, 0x3e, 0xf, 0x1b, 0x82, 0x5e, 0xd5, 0xad, 0x93, 0xa7, 0x44, 0x1c, + 0xfe, 0x99, 0xda, 0x63, 0xed, 0x85, 0xdc, 0x9c, 0x5a, 0x6b, 0xd3, 0xcf}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 5779); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\218\230\US\223|\136nz\184\f)s\246ht", _pubPktID = 0, _pubBody = "\209", _pubProps = [PropRequestResponseInformation -// 63,PropTopicAliasMaximum 25586,PropWildcardSubscriptionAvailable 35,PropSubscriptionIdentifier -// 0,PropPayloadFormatIndicator 212,PropMaximumPacketSize 7906,PropMessageExpiryInterval 15199,PropResponseInformation -// "{\254\252\147e\184hx-\250\171\SYN\158\133\252\194\176\219\140:m",PropUserProperty -// "\166i\GS\b\231\ENQ\190\NUL\229\174\182\"" -// "V\193g\167\200\186\&5\246P\159d\225\&5\209\219sS",PropSubscriptionIdentifierAvailable 136,PropWillDelayInterval -// 32300,PropMaximumPacketSize 22829,PropAuthenticationData -// "\184\221\227|\240\152\182\167\DC1\DELY\143x-",PropRequestProblemInformation 233,PropAuthenticationMethod -// "x\139\214\b\199\&3\175j\245W\160M\200\220\194\212\148:\184",PropRequestProblemInformation -// 146,PropSubscriptionIdentifier 28,PropSubscriptionIdentifierAvailable 116,PropServerReference -// "g\140\&0%\146(\175\165\141`\254\204\170\132",PropTopicAliasMaximum 25801]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "P\177\NAK.\190\171\224\139\&2\248]=\179n\DC4k\146\152\175\210\205`3|\135\&8i\209", _pubPktID = 19270, _pubBody = +// "\134\ENQKL\159E.\211+^\240\187\146\NAK7dRg\129.m\133\DLE\152C\ESCJ\160\203", _pubProps = [PropAuthenticationData +// "\249\128\218!m\186\b\174\&6\228q\130iQ\252O2\t\134\f\159\211n\150K\164\213\196?\149",PropResponseInformation +// "\244\162%",PropAuthenticationData "\156\195]t",PropContentType +// "7o\211\198\220\230\ETB",PropSubscriptionIdentifierAvailable 49,PropContentType +// "\161\192\204\175\207\205\182\229\236.\247C\EMZf/\223\243\205",PropWillDelayInterval 20097]} TEST(Publish5QCTest, Encode11) { - uint8_t pkt[] = {0x39, 0xb2, 0x1, 0x0, 0xf, 0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, - 0xf6, 0x68, 0x74, 0x9e, 0x1, 0x19, 0x3f, 0x22, 0x63, 0xf2, 0x28, 0x23, 0xb, 0x0, 0x1, 0xd4, 0x27, - 0x0, 0x0, 0x1e, 0xe2, 0x2, 0x0, 0x0, 0x3b, 0x5f, 0x1a, 0x0, 0x15, 0x7b, 0xfe, 0xfc, 0x93, 0x65, - 0xb8, 0x68, 0x78, 0x2d, 0xfa, 0xab, 0x16, 0x9e, 0x85, 0xfc, 0xc2, 0xb0, 0xdb, 0x8c, 0x3a, 0x6d, 0x26, - 0x0, 0xc, 0xa6, 0x69, 0x1d, 0x8, 0xe7, 0x5, 0xbe, 0x0, 0xe5, 0xae, 0xb6, 0x22, 0x0, 0x11, 0x56, - 0xc1, 0x67, 0xa7, 0xc8, 0xba, 0x35, 0xf6, 0x50, 0x9f, 0x64, 0xe1, 0x35, 0xd1, 0xdb, 0x73, 0x53, 0x29, - 0x88, 0x18, 0x0, 0x0, 0x7e, 0x2c, 0x27, 0x0, 0x0, 0x59, 0x2d, 0x16, 0x0, 0xe, 0xb8, 0xdd, 0xe3, - 0x7c, 0xf0, 0x98, 0xb6, 0xa7, 0x11, 0x7f, 0x59, 0x8f, 0x78, 0x2d, 0x17, 0xe9, 0x15, 0x0, 0x13, 0x78, - 0x8b, 0xd6, 0x8, 0xc7, 0x33, 0xaf, 0x6a, 0xf5, 0x57, 0xa0, 0x4d, 0xc8, 0xdc, 0xc2, 0xd4, 0x94, 0x3a, - 0xb8, 0x17, 0x92, 0xb, 0x1c, 0x29, 0x74, 0x1c, 0x0, 0xe, 0x67, 0x8c, 0x30, 0x25, 0x92, 0x28, 0xaf, - 0xa5, 0x8d, 0x60, 0xfe, 0xcc, 0xaa, 0x84, 0x22, 0x64, 0xc9, 0xd1}; - uint8_t topic_bytes[] = {0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x93, 0x1, 0x0, 0x1c, 0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, + 0xb3, 0x6e, 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1, 0x4b, + 0x46, 0x55, 0x16, 0x0, 0x1e, 0xf9, 0x80, 0xda, 0x21, 0x6d, 0xba, 0x8, 0xae, 0x36, 0xe4, 0x71, 0x82, + 0x69, 0x51, 0xfc, 0x4f, 0x32, 0x9, 0x86, 0xc, 0x9f, 0xd3, 0x6e, 0x96, 0x4b, 0xa4, 0xd5, 0xc4, 0x3f, + 0x95, 0x1a, 0x0, 0x3, 0xf4, 0xa2, 0x25, 0x16, 0x0, 0x4, 0x9c, 0xc3, 0x5d, 0x74, 0x3, 0x0, 0x7, + 0x37, 0x6f, 0xd3, 0xc6, 0xdc, 0xe6, 0x17, 0x29, 0x31, 0x3, 0x0, 0x13, 0xa1, 0xc0, 0xcc, 0xaf, 0xcf, + 0xcd, 0xb6, 0xe5, 0xec, 0x2e, 0xf7, 0x43, 0x19, 0x5a, 0x66, 0x2f, 0xdf, 0xf3, 0xcd, 0x18, 0x0, 0x0, + 0x4e, 0x81, 0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, + 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; + uint8_t topic_bytes[] = {0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, 0xb3, 0x6e, + 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xd1}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, + 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 29; - uint8_t bytesprops0[] = {0x7b, 0xfe, 0xfc, 0x93, 0x65, 0xb8, 0x68, 0x78, 0x2d, 0xfa, 0xab, - 0x16, 0x9e, 0x85, 0xfc, 0xc2, 0xb0, 0xdb, 0x8c, 0x3a, 0x6d}; - uint8_t bytesprops2[] = {0x56, 0xc1, 0x67, 0xa7, 0xc8, 0xba, 0x35, 0xf6, 0x50, - 0x9f, 0x64, 0xe1, 0x35, 0xd1, 0xdb, 0x73, 0x53}; - uint8_t bytesprops1[] = {0xa6, 0x69, 0x1d, 0x8, 0xe7, 0x5, 0xbe, 0x0, 0xe5, 0xae, 0xb6, 0x22}; - uint8_t bytesprops3[] = {0xb8, 0xdd, 0xe3, 0x7c, 0xf0, 0x98, 0xb6, 0xa7, 0x11, 0x7f, 0x59, 0x8f, 0x78, 0x2d}; - uint8_t bytesprops4[] = {0x78, 0x8b, 0xd6, 0x8, 0xc7, 0x33, 0xaf, 0x6a, 0xf5, 0x57, - 0xa0, 0x4d, 0xc8, 0xdc, 0xc2, 0xd4, 0x94, 0x3a, 0xb8}; - uint8_t bytesprops5[] = {0x67, 0x8c, 0x30, 0x25, 0x92, 0x28, 0xaf, 0xa5, 0x8d, 0x60, 0xfe, 0xcc, 0xaa, 0x84}; + uint8_t bytesprops0[] = {0xf9, 0x80, 0xda, 0x21, 0x6d, 0xba, 0x8, 0xae, 0x36, 0xe4, 0x71, 0x82, 0x69, 0x51, 0xfc, + 0x4f, 0x32, 0x9, 0x86, 0xc, 0x9f, 0xd3, 0x6e, 0x96, 0x4b, 0xa4, 0xd5, 0xc4, 0x3f, 0x95}; + uint8_t bytesprops1[] = {0xf4, 0xa2, 0x25}; + uint8_t bytesprops2[] = {0x9c, 0xc3, 0x5d, 0x74}; + uint8_t bytesprops3[] = {0x37, 0x6f, 0xd3, 0xc6, 0xdc, 0xe6, 0x17}; + uint8_t bytesprops4[] = {0xa1, 0xc0, 0xcc, 0xaf, 0xcf, 0xcd, 0xb6, 0xe5, 0xec, 0x2e, + 0xf7, 0x43, 0x19, 0x5a, 0x66, 0x2f, 0xdf, 0xf3, 0xcd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25586}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7906}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15199}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops1}, .v = {17, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32300}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22829}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25801}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20097}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19270, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\218\230\US\223|\136nz\184\f)s\246ht", _pubPktID = 0, _pubBody = "\209", _pubProps = [PropRequestResponseInformation -// 63,PropTopicAliasMaximum 25586,PropWildcardSubscriptionAvailable 35,PropSubscriptionIdentifier -// 0,PropPayloadFormatIndicator 212,PropMaximumPacketSize 7906,PropMessageExpiryInterval 15199,PropResponseInformation -// "{\254\252\147e\184hx-\250\171\SYN\158\133\252\194\176\219\140:m",PropUserProperty -// "\166i\GS\b\231\ENQ\190\NUL\229\174\182\"" -// "V\193g\167\200\186\&5\246P\159d\225\&5\209\219sS",PropSubscriptionIdentifierAvailable 136,PropWillDelayInterval -// 32300,PropMaximumPacketSize 22829,PropAuthenticationData -// "\184\221\227|\240\152\182\167\DC1\DELY\143x-",PropRequestProblemInformation 233,PropAuthenticationMethod -// "x\139\214\b\199\&3\175j\245W\160M\200\220\194\212\148:\184",PropRequestProblemInformation -// 146,PropSubscriptionIdentifier 28,PropSubscriptionIdentifierAvailable 116,PropServerReference -// "g\140\&0%\146(\175\165\141`\254\204\170\132",PropTopicAliasMaximum 25801]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "P\177\NAK.\190\171\224\139\&2\248]=\179n\DC4k\146\152\175\210\205`3|\135\&8i\209", _pubPktID = 19270, _pubBody = +// "\134\ENQKL\159E.\211+^\240\187\146\NAK7dRg\129.m\133\DLE\152C\ESCJ\160\203", _pubProps = [PropAuthenticationData +// "\249\128\218!m\186\b\174\&6\228q\130iQ\252O2\t\134\f\159\211n\150K\164\213\196?\149",PropResponseInformation +// "\244\162%",PropAuthenticationData "\156\195]t",PropContentType +// "7o\211\198\220\230\ETB",PropSubscriptionIdentifierAvailable 49,PropContentType +// "\161\192\204\175\207\205\182\229\236.\247C\EMZf/\223\243\205",PropWillDelayInterval 20097]} TEST(Publish5QCTest, Decode11) { - uint8_t pkt[] = {0x39, 0xb2, 0x1, 0x0, 0xf, 0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, - 0xf6, 0x68, 0x74, 0x9e, 0x1, 0x19, 0x3f, 0x22, 0x63, 0xf2, 0x28, 0x23, 0xb, 0x0, 0x1, 0xd4, 0x27, - 0x0, 0x0, 0x1e, 0xe2, 0x2, 0x0, 0x0, 0x3b, 0x5f, 0x1a, 0x0, 0x15, 0x7b, 0xfe, 0xfc, 0x93, 0x65, - 0xb8, 0x68, 0x78, 0x2d, 0xfa, 0xab, 0x16, 0x9e, 0x85, 0xfc, 0xc2, 0xb0, 0xdb, 0x8c, 0x3a, 0x6d, 0x26, - 0x0, 0xc, 0xa6, 0x69, 0x1d, 0x8, 0xe7, 0x5, 0xbe, 0x0, 0xe5, 0xae, 0xb6, 0x22, 0x0, 0x11, 0x56, - 0xc1, 0x67, 0xa7, 0xc8, 0xba, 0x35, 0xf6, 0x50, 0x9f, 0x64, 0xe1, 0x35, 0xd1, 0xdb, 0x73, 0x53, 0x29, - 0x88, 0x18, 0x0, 0x0, 0x7e, 0x2c, 0x27, 0x0, 0x0, 0x59, 0x2d, 0x16, 0x0, 0xe, 0xb8, 0xdd, 0xe3, - 0x7c, 0xf0, 0x98, 0xb6, 0xa7, 0x11, 0x7f, 0x59, 0x8f, 0x78, 0x2d, 0x17, 0xe9, 0x15, 0x0, 0x13, 0x78, - 0x8b, 0xd6, 0x8, 0xc7, 0x33, 0xaf, 0x6a, 0xf5, 0x57, 0xa0, 0x4d, 0xc8, 0xdc, 0xc2, 0xd4, 0x94, 0x3a, - 0xb8, 0x17, 0x92, 0xb, 0x1c, 0x29, 0x74, 0x1c, 0x0, 0xe, 0x67, 0x8c, 0x30, 0x25, 0x92, 0x28, 0xaf, - 0xa5, 0x8d, 0x60, 0xfe, 0xcc, 0xaa, 0x84, 0x22, 0x64, 0xc9, 0xd1}; + uint8_t pkt[] = {0x32, 0x93, 0x1, 0x0, 0x1c, 0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, + 0xb3, 0x6e, 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1, 0x4b, + 0x46, 0x55, 0x16, 0x0, 0x1e, 0xf9, 0x80, 0xda, 0x21, 0x6d, 0xba, 0x8, 0xae, 0x36, 0xe4, 0x71, 0x82, + 0x69, 0x51, 0xfc, 0x4f, 0x32, 0x9, 0x86, 0xc, 0x9f, 0xd3, 0x6e, 0x96, 0x4b, 0xa4, 0xd5, 0xc4, 0x3f, + 0x95, 0x1a, 0x0, 0x3, 0xf4, 0xa2, 0x25, 0x16, 0x0, 0x4, 0x9c, 0xc3, 0x5d, 0x74, 0x3, 0x0, 0x7, + 0x37, 0x6f, 0xd3, 0xc6, 0xdc, 0xe6, 0x17, 0x29, 0x31, 0x3, 0x0, 0x13, 0xa1, 0xc0, 0xcc, 0xaf, 0xcf, + 0xcd, 0xb6, 0xe5, 0xec, 0x2e, 0xf7, 0x43, 0x19, 0x5a, 0x66, 0x2f, 0xdf, 0xf3, 0xcd, 0x18, 0x0, 0x0, + 0x4e, 0x81, 0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, + 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3124,73 +2962,109 @@ TEST(Publish5QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xda, 0xe6, 0x1f, 0xdf, 0x7c, 0x88, 0x6e, 0x7a, 0xb8, 0xc, 0x29, 0x73, 0xf6, 0x68, 0x74}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd1}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + uint8_t exp_topic_bytes[] = {0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, 0xb3, 0x6e, + 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, + 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 19270); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\185\207+s\131Y\252\238R\EOT\183\224\v\195'\154V\SUB\214", _pubPktID = 0, _pubBody = -// "n\190=U\SI\224\255\fT\157I\150?Z\SI\215\177\163\143\SUB", _pubProps = [PropUserProperty -// "\144.\193YAI\228\215\n(3\DEL\226\244y\234V\196" -// "\194\246d\nv\220\222\238\190\CAN\198vx\170\137",PropSharedSubscriptionAvailable 143]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DLE", _pubPktID = 0, _pubBody = +// "\DC4s\199\ACKg\249\133\ENQ\157\223\145\&2NM^T\137xH3\226=j,\r\239U\ACK\153\210", _pubProps = [PropWillDelayInterval +// 13975,PropAuthenticationMethod "\178y~\133\229\US\134f",PropSubscriptionIdentifier 24,PropPayloadFormatIndicator +// 112,PropAuthenticationData "\226\221\243\164*\209\&1_F\NAKcK\194",PropServerReference +// "\RSW\194s\202\203\172/\207R",PropServerReference "\248\244\133\DC4",PropTopicAlias 12118,PropAuthenticationData +// "\181\221\RS{\134\247\SUB\195\SO",PropServerReference +// "\225\232\152\176yO\DEL{\233x\170^\b\193g\ETXd\v\\\252wc\175\149eU\a\DC4",PropResponseTopic +// "Z\FSr\DC3\220{\RS\206V\168\197\&0\210\203\ENQ\160\&5\176W\213\&64\vu",PropCorrelationData "Jh"]} TEST(Publish5QCTest, Encode12) { - uint8_t pkt[] = {0x31, 0x52, 0x0, 0x13, 0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, 0xb7, 0xe0, 0xb, - 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6, 0x28, 0x26, 0x0, 0x12, 0x90, 0x2e, 0xc1, 0x59, 0x41, 0x49, 0xe4, - 0xd7, 0xa, 0x28, 0x33, 0x7f, 0xe2, 0xf4, 0x79, 0xea, 0x56, 0xc4, 0x0, 0xf, 0xc2, 0xf6, 0x64, 0xa, - 0x76, 0xdc, 0xde, 0xee, 0xbe, 0x18, 0xc6, 0x76, 0x78, 0xaa, 0x89, 0x2a, 0x8f, 0x6e, 0xbe, 0x3d, 0x55, - 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; - uint8_t topic_bytes[] = {0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, - 0xb7, 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0xa9, 0x1, 0x0, 0x1, 0x10, 0x86, 0x1, 0x18, 0x0, 0x0, 0x36, 0x97, 0x15, 0x0, 0x8, + 0xb2, 0x79, 0x7e, 0x85, 0xe5, 0x1f, 0x86, 0x66, 0xb, 0x18, 0x1, 0x70, 0x16, 0x0, 0xd, 0xe2, + 0xdd, 0xf3, 0xa4, 0x2a, 0xd1, 0x31, 0x5f, 0x46, 0x15, 0x63, 0x4b, 0xc2, 0x1c, 0x0, 0xa, 0x1e, + 0x57, 0xc2, 0x73, 0xca, 0xcb, 0xac, 0x2f, 0xcf, 0x52, 0x1c, 0x0, 0x4, 0xf8, 0xf4, 0x85, 0x14, + 0x23, 0x2f, 0x56, 0x16, 0x0, 0x9, 0xb5, 0xdd, 0x1e, 0x7b, 0x86, 0xf7, 0x1a, 0xc3, 0xe, 0x1c, + 0x0, 0x1c, 0xe1, 0xe8, 0x98, 0xb0, 0x79, 0x4f, 0x7f, 0x7b, 0xe9, 0x78, 0xaa, 0x5e, 0x8, 0xc1, + 0x67, 0x3, 0x64, 0xb, 0x5c, 0xfc, 0x77, 0x63, 0xaf, 0x95, 0x65, 0x55, 0x7, 0x14, 0x8, 0x0, + 0x18, 0x5a, 0x1c, 0x72, 0x13, 0xdc, 0x7b, 0x1e, 0xce, 0x56, 0xa8, 0xc5, 0x30, 0xd2, 0xcb, 0x5, + 0xa0, 0x35, 0xb0, 0x57, 0xd5, 0x36, 0x34, 0xb, 0x75, 0x9, 0x0, 0x2, 0x4a, 0x68, 0x14, 0x73, + 0xc7, 0x6, 0x67, 0xf9, 0x85, 0x5, 0x9d, 0xdf, 0x91, 0x32, 0x4e, 0x4d, 0x5e, 0x54, 0x89, 0x78, + 0x48, 0x33, 0xe2, 0x3d, 0x6a, 0x2c, 0xd, 0xef, 0x55, 0x6, 0x99, 0xd2}; + uint8_t topic_bytes[] = {0x10}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, - 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + uint8_t msg_bytes[] = {0x14, 0x73, 0xc7, 0x6, 0x67, 0xf9, 0x85, 0x5, 0x9d, 0xdf, 0x91, 0x32, 0x4e, 0x4d, 0x5e, + 0x54, 0x89, 0x78, 0x48, 0x33, 0xe2, 0x3d, 0x6a, 0x2c, 0xd, 0xef, 0x55, 0x6, 0x99, 0xd2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; - - uint8_t bytesprops1[] = {0xc2, 0xf6, 0x64, 0xa, 0x76, 0xdc, 0xde, 0xee, 0xbe, 0x18, 0xc6, 0x76, 0x78, 0xaa, 0x89}; - uint8_t bytesprops0[] = {0x90, 0x2e, 0xc1, 0x59, 0x41, 0x49, 0xe4, 0xd7, 0xa, - 0x28, 0x33, 0x7f, 0xe2, 0xf4, 0x79, 0xea, 0x56, 0xc4}; + msg.payload_len = 30; + + uint8_t bytesprops0[] = {0xb2, 0x79, 0x7e, 0x85, 0xe5, 0x1f, 0x86, 0x66}; + uint8_t bytesprops1[] = {0xe2, 0xdd, 0xf3, 0xa4, 0x2a, 0xd1, 0x31, 0x5f, 0x46, 0x15, 0x63, 0x4b, 0xc2}; + uint8_t bytesprops2[] = {0x1e, 0x57, 0xc2, 0x73, 0xca, 0xcb, 0xac, 0x2f, 0xcf, 0x52}; + uint8_t bytesprops3[] = {0xf8, 0xf4, 0x85, 0x14}; + uint8_t bytesprops4[] = {0xb5, 0xdd, 0x1e, 0x7b, 0x86, 0xf7, 0x1a, 0xc3, 0xe}; + uint8_t bytesprops5[] = {0xe1, 0xe8, 0x98, 0xb0, 0x79, 0x4f, 0x7f, 0x7b, 0xe9, 0x78, 0xaa, 0x5e, 0x8, 0xc1, + 0x67, 0x3, 0x64, 0xb, 0x5c, 0xfc, 0x77, 0x63, 0xaf, 0x95, 0x65, 0x55, 0x7, 0x14}; + uint8_t bytesprops6[] = {0x5a, 0x1c, 0x72, 0x13, 0xdc, 0x7b, 0x1e, 0xce, 0x56, 0xa8, 0xc5, 0x30, + 0xd2, 0xcb, 0x5, 0xa0, 0x35, 0xb0, 0x57, 0xd5, 0x36, 0x34, 0xb, 0x75}; + uint8_t bytesprops7[] = {0x4a, 0x68}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops0}, .v = {15, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13975}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12118}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\185\207+s\131Y\252\238R\EOT\183\224\v\195'\154V\SUB\214", _pubPktID = 0, _pubBody = -// "n\190=U\SI\224\255\fT\157I\150?Z\SI\215\177\163\143\SUB", _pubProps = [PropUserProperty -// "\144.\193YAI\228\215\n(3\DEL\226\244y\234V\196" -// "\194\246d\nv\220\222\238\190\CAN\198vx\170\137",PropSharedSubscriptionAvailable 143]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DLE", _pubPktID = 0, _pubBody = +// "\DC4s\199\ACKg\249\133\ENQ\157\223\145\&2NM^T\137xH3\226=j,\r\239U\ACK\153\210", _pubProps = [PropWillDelayInterval +// 13975,PropAuthenticationMethod "\178y~\133\229\US\134f",PropSubscriptionIdentifier 24,PropPayloadFormatIndicator +// 112,PropAuthenticationData "\226\221\243\164*\209\&1_F\NAKcK\194",PropServerReference +// "\RSW\194s\202\203\172/\207R",PropServerReference "\248\244\133\DC4",PropTopicAlias 12118,PropAuthenticationData +// "\181\221\RS{\134\247\SUB\195\SO",PropServerReference +// "\225\232\152\176yO\DEL{\233x\170^\b\193g\ETXd\v\\\252wc\175\149eU\a\DC4",PropResponseTopic +// "Z\FSr\DC3\220{\RS\206V\168\197\&0\210\203\ENQ\160\&5\176W\213\&64\vu",PropCorrelationData "Jh"]} TEST(Publish5QCTest, Decode12) { - uint8_t pkt[] = {0x31, 0x52, 0x0, 0x13, 0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, 0xb7, 0xe0, 0xb, - 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6, 0x28, 0x26, 0x0, 0x12, 0x90, 0x2e, 0xc1, 0x59, 0x41, 0x49, 0xe4, - 0xd7, 0xa, 0x28, 0x33, 0x7f, 0xe2, 0xf4, 0x79, 0xea, 0x56, 0xc4, 0x0, 0xf, 0xc2, 0xf6, 0x64, 0xa, - 0x76, 0xdc, 0xde, 0xee, 0xbe, 0x18, 0xc6, 0x76, 0x78, 0xaa, 0x89, 0x2a, 0x8f, 0x6e, 0xbe, 0x3d, 0x55, - 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; + uint8_t pkt[] = {0x39, 0xa9, 0x1, 0x0, 0x1, 0x10, 0x86, 0x1, 0x18, 0x0, 0x0, 0x36, 0x97, 0x15, 0x0, 0x8, + 0xb2, 0x79, 0x7e, 0x85, 0xe5, 0x1f, 0x86, 0x66, 0xb, 0x18, 0x1, 0x70, 0x16, 0x0, 0xd, 0xe2, + 0xdd, 0xf3, 0xa4, 0x2a, 0xd1, 0x31, 0x5f, 0x46, 0x15, 0x63, 0x4b, 0xc2, 0x1c, 0x0, 0xa, 0x1e, + 0x57, 0xc2, 0x73, 0xca, 0xcb, 0xac, 0x2f, 0xcf, 0x52, 0x1c, 0x0, 0x4, 0xf8, 0xf4, 0x85, 0x14, + 0x23, 0x2f, 0x56, 0x16, 0x0, 0x9, 0xb5, 0xdd, 0x1e, 0x7b, 0x86, 0xf7, 0x1a, 0xc3, 0xe, 0x1c, + 0x0, 0x1c, 0xe1, 0xe8, 0x98, 0xb0, 0x79, 0x4f, 0x7f, 0x7b, 0xe9, 0x78, 0xaa, 0x5e, 0x8, 0xc1, + 0x67, 0x3, 0x64, 0xb, 0x5c, 0xfc, 0x77, 0x63, 0xaf, 0x95, 0x65, 0x55, 0x7, 0x14, 0x8, 0x0, + 0x18, 0x5a, 0x1c, 0x72, 0x13, 0xdc, 0x7b, 0x1e, 0xce, 0x56, 0xa8, 0xc5, 0x30, 0xd2, 0xcb, 0x5, + 0xa0, 0x35, 0xb0, 0x57, 0xd5, 0x36, 0x34, 0xb, 0x75, 0x9, 0x0, 0x2, 0x4a, 0x68, 0x14, 0x73, + 0xc7, 0x6, 0x67, 0xf9, 0x85, 0x5, 0x9d, 0xdf, 0x91, 0x32, 0x4e, 0x4d, 0x5e, 0x54, 0x89, 0x78, + 0x48, 0x33, 0xe2, 0x3d, 0x6a, 0x2c, 0xd, 0xef, 0x55, 0x6, 0x99, 0xd2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3199,144 +3073,106 @@ TEST(Publish5QCTest, Decode12) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb9, 0xcf, 0x2b, 0x73, 0x83, 0x59, 0xfc, 0xee, 0x52, 0x4, - 0xb7, 0xe0, 0xb, 0xc3, 0x27, 0x9a, 0x56, 0x1a, 0xd6}; - lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x6e, 0xbe, 0x3d, 0x55, 0xf, 0xe0, 0xff, 0xc, 0x54, 0x9d, - 0x49, 0x96, 0x3f, 0x5a, 0xf, 0xd7, 0xb1, 0xa3, 0x8f, 0x1a}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x10}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x14, 0x73, 0xc7, 0x6, 0x67, 0xf9, 0x85, 0x5, 0x9d, 0xdf, 0x91, 0x32, 0x4e, 0x4d, 0x5e, + 0x54, 0x89, 0x78, 0x48, 0x33, 0xe2, 0x3d, 0x6a, 0x2c, 0xd, 0xef, 0x55, 0x6, 0x99, 0xd2}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "-\224\164\222\163\DLE\224\218\229\CAN!n\rZ\193Y\DC3r\129\219T\172\139\252\&2~", _pubPktID = 8532, _pubBody = -// "\145b$\DEL\237\176\245E\250\186\STX\US|\163\f\221\190&\238\vu\US", _pubProps = [PropSubscriptionIdentifierAvailable -// 34,PropMessageExpiryInterval 11891,PropResponseInformation -// "-\225]\247aFq\176\244g[\SYN\129\131\161\164\154-\f\129\147*\154M\225\242\169\237\ENQZ",PropSubscriptionIdentifierAvailable -// 249,PropContentType -// "\164KI\192\b\GSW\"\143O\137\197\ETBhML8\223\145\RS\US\181\129\STXHc<\243\165\225",PropAuthenticationMethod -// "\136\&0\244\233\166=Bk%69\245\211|",PropResponseInformation "J\233\157\144<",PropWildcardSubscriptionAvailable -// 58,PropMessageExpiryInterval 16260,PropRetainAvailable 130,PropAuthenticationMethod -// "\"\187\183\218\237\174\186\161K\CAN\236V\153\227",PropMaximumQoS 17,PropAuthenticationData -// "\190\140\f",PropPayloadFormatIndicator 52,PropRequestProblemInformation 200,PropSessionExpiryInterval -// 11292,PropPayloadFormatIndicator 217,PropAssignedClientIdentifier -// "\153\159m+\233\f/,qrA\217\151%<@\253\170\134>I\137",PropMaximumQoS 157,PropServerKeepAlive -// 21812,PropRequestProblemInformation 111,PropResponseInformation "hw\171",PropAuthenticationData -// "\214",PropReceiveMaximum 30617]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\171b\DC1\233\"[\161x\tR2\b\143\ap\176)0\156/\230\155\ETBx\154h*|", _pubPktID = 3357, _pubBody = "\139", _pubProps = +// [PropTopicAlias 26188,PropRetainAvailable 55,PropReasonString +// "w\181\DC2\242\168\ACK\248@\224\ACK\SOH\135",PropMaximumPacketSize 1661,PropWillDelayInterval +// 877,PropRequestResponseInformation 164,PropWillDelayInterval 28432,PropSessionExpiryInterval +// 27592,PropMessageExpiryInterval 19299,PropTopicAliasMaximum 32078,PropAuthenticationMethod "\154 +// 0o}R\229`h\198\&0\STX0D\221\218\242\&3e\162\164\225\248\183\SIZ\209\251\226\251",PropMessageExpiryInterval +// 7477,PropSubscriptionIdentifier 1,PropReasonString +// "YS\ETB\STX\157\204_\155\&2\244\201\"\143X\142&\241\US\131\&0\ETB\177",PropTopicAlias 10274]} TEST(Publish5QCTest, Encode13) { - uint8_t pkt[] = { - 0x3d, 0xf4, 0x1, 0x0, 0x1a, 0x2d, 0xe0, 0xa4, 0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d9, 0x97, 0x25, 0x3c, 0x40, 0xfd, 0xaa, 0x86, 0x3e, 0x49, 0x89, 0x24, 0x9d, 0x13, 0x55, - 0x34, 0x17, 0x6f, 0x1a, 0x0, 0x3, 0x68, 0x77, 0xab, 0x16, 0x0, 0x1, 0xd6, 0x21, 0x77, 0x99, 0x91, 0x62, 0x24, - 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, 0x2, 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; - uint8_t topic_bytes[] = {0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, 0x21, 0x6e, 0xd, - 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, 0x32, 0x7e}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x98, 0x1, 0x0, 0x1c, 0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, + 0x8, 0x8f, 0x7, 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, + 0x7c, 0xd, 0x1d, 0x76, 0x23, 0x66, 0x4c, 0x25, 0x37, 0x1f, 0x0, 0xc, 0x77, 0xb5, 0x12, 0xf2, + 0xa8, 0x6, 0xf8, 0x40, 0xe0, 0x6, 0x1, 0x87, 0x27, 0x0, 0x0, 0x6, 0x7d, 0x18, 0x0, 0x0, + 0x3, 0x6d, 0x19, 0xa4, 0x18, 0x0, 0x0, 0x6f, 0x10, 0x11, 0x0, 0x0, 0x6b, 0xc8, 0x2, 0x0, + 0x0, 0x4b, 0x63, 0x22, 0x7d, 0x4e, 0x15, 0x0, 0x1e, 0x9a, 0x20, 0x30, 0x6f, 0x7d, 0x52, 0xe5, + 0x60, 0x68, 0xc6, 0x30, 0x2, 0x30, 0x44, 0xdd, 0xda, 0xf2, 0x33, 0x65, 0xa2, 0xa4, 0xe1, 0xf8, + 0xb7, 0xf, 0x5a, 0xd1, 0xfb, 0xe2, 0xfb, 0x2, 0x0, 0x0, 0x1d, 0x35, 0xb, 0x1, 0x1f, 0x0, + 0x16, 0x59, 0x53, 0x17, 0x2, 0x9d, 0xcc, 0x5f, 0x9b, 0x32, 0xf4, 0xc9, 0x22, 0x8f, 0x58, 0x8e, + 0x26, 0xf1, 0x1f, 0x83, 0x30, 0x17, 0xb1, 0x23, 0x28, 0x22, 0x8b}; + uint8_t topic_bytes[] = {0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, + 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, 0x2, - 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; + msg.retained = false; + uint8_t msg_bytes[] = {0x8b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 1; - uint8_t bytesprops0[] = {0x2d, 0xe1, 0x5d, 0xf7, 0x61, 0x46, 0x71, 0xb0, 0xf4, 0x67, 0x5b, 0x16, 0x81, 0x83, 0xa1, - 0xa4, 0x9a, 0x2d, 0xc, 0x81, 0x93, 0x2a, 0x9a, 0x4d, 0xe1, 0xf2, 0xa9, 0xed, 0x5, 0x5a}; - uint8_t bytesprops1[] = {0xa4, 0x4b, 0x49, 0xc0, 0x8, 0x1d, 0x57, 0x22, 0x8f, 0x4f, 0x89, 0xc5, 0x17, 0x68, 0x4d, - 0x4c, 0x38, 0xdf, 0x91, 0x1e, 0x1f, 0xb5, 0x81, 0x2, 0x48, 0x63, 0x3c, 0xf3, 0xa5, 0xe1}; - uint8_t bytesprops2[] = {0x88, 0x30, 0xf4, 0xe9, 0xa6, 0x3d, 0x42, 0x6b, 0x25, 0x36, 0x39, 0xf5, 0xd3, 0x7c}; - uint8_t bytesprops3[] = {0x4a, 0xe9, 0x9d, 0x90, 0x3c}; - uint8_t bytesprops4[] = {0x22, 0xbb, 0xb7, 0xda, 0xed, 0xae, 0xba, 0xa1, 0x4b, 0x18, 0xec, 0x56, 0x99, 0xe3}; - uint8_t bytesprops5[] = {0xbe, 0x8c, 0xc}; - uint8_t bytesprops6[] = {0x99, 0x9f, 0x6d, 0x2b, 0xe9, 0xc, 0x2f, 0x2c, 0x71, 0x72, 0x41, - 0xd9, 0x97, 0x25, 0x3c, 0x40, 0xfd, 0xaa, 0x86, 0x3e, 0x49, 0x89}; - uint8_t bytesprops7[] = {0x68, 0x77, 0xab}; - uint8_t bytesprops8[] = {0xd6}; + uint8_t bytesprops0[] = {0x77, 0xb5, 0x12, 0xf2, 0xa8, 0x6, 0xf8, 0x40, 0xe0, 0x6, 0x1, 0x87}; + uint8_t bytesprops1[] = {0x9a, 0x20, 0x30, 0x6f, 0x7d, 0x52, 0xe5, 0x60, 0x68, 0xc6, 0x30, 0x2, 0x30, 0x44, 0xdd, + 0xda, 0xf2, 0x33, 0x65, 0xa2, 0xa4, 0xe1, 0xf8, 0xb7, 0xf, 0x5a, 0xd1, 0xfb, 0xe2, 0xfb}; + uint8_t bytesprops2[] = {0x59, 0x53, 0x17, 0x2, 0x9d, 0xcc, 0x5f, 0x9b, 0x32, 0xf4, 0xc9, + 0x22, 0x8f, 0x58, 0x8e, 0x26, 0xf1, 0x1f, 0x83, 0x30, 0x17, 0xb1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11891}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16260}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11292}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21812}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30617}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26188}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1661}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 877}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28432}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27592}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19299}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32078}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7477}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10274}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 8532, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 3357, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "-\224\164\222\163\DLE\224\218\229\CAN!n\rZ\193Y\DC3r\129\219T\172\139\252\&2~", _pubPktID = 8532, _pubBody = -// "\145b$\DEL\237\176\245E\250\186\STX\US|\163\f\221\190&\238\vu\US", _pubProps = [PropSubscriptionIdentifierAvailable -// 34,PropMessageExpiryInterval 11891,PropResponseInformation -// "-\225]\247aFq\176\244g[\SYN\129\131\161\164\154-\f\129\147*\154M\225\242\169\237\ENQZ",PropSubscriptionIdentifierAvailable -// 249,PropContentType -// "\164KI\192\b\GSW\"\143O\137\197\ETBhML8\223\145\RS\US\181\129\STXHc<\243\165\225",PropAuthenticationMethod -// "\136\&0\244\233\166=Bk%69\245\211|",PropResponseInformation "J\233\157\144<",PropWildcardSubscriptionAvailable -// 58,PropMessageExpiryInterval 16260,PropRetainAvailable 130,PropAuthenticationMethod -// "\"\187\183\218\237\174\186\161K\CAN\236V\153\227",PropMaximumQoS 17,PropAuthenticationData -// "\190\140\f",PropPayloadFormatIndicator 52,PropRequestProblemInformation 200,PropSessionExpiryInterval -// 11292,PropPayloadFormatIndicator 217,PropAssignedClientIdentifier -// "\153\159m+\233\f/,qrA\217\151%<@\253\170\134>I\137",PropMaximumQoS 157,PropServerKeepAlive -// 21812,PropRequestProblemInformation 111,PropResponseInformation "hw\171",PropAuthenticationData -// "\214",PropReceiveMaximum 30617]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\171b\DC1\233\"[\161x\tR2\b\143\ap\176)0\156/\230\155\ETBx\154h*|", _pubPktID = 3357, _pubBody = "\139", _pubProps = +// [PropTopicAlias 26188,PropRetainAvailable 55,PropReasonString +// "w\181\DC2\242\168\ACK\248@\224\ACK\SOH\135",PropMaximumPacketSize 1661,PropWillDelayInterval +// 877,PropRequestResponseInformation 164,PropWillDelayInterval 28432,PropSessionExpiryInterval +// 27592,PropMessageExpiryInterval 19299,PropTopicAliasMaximum 32078,PropAuthenticationMethod "\154 +// 0o}R\229`h\198\&0\STX0D\221\218\242\&3e\162\164\225\248\183\SIZ\209\251\226\251",PropMessageExpiryInterval +// 7477,PropSubscriptionIdentifier 1,PropReasonString +// "YS\ETB\STX\157\204_\155\&2\244\201\"\143X\142&\241\US\131\&0\ETB\177",PropTopicAlias 10274]} TEST(Publish5QCTest, Decode13) { - uint8_t pkt[] = { - 0x3d, 0xf4, 0x1, 0x0, 0x1a, 0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0x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32, 0xf4, 0xc9, 0x22, 0x8f, 0x58, 0x8e, + 0x26, 0xf1, 0x1f, 0x83, 0x30, 0x17, 0xb1, 0x23, 0x28, 0x22, 0x8b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3345,124 +3181,65 @@ TEST(Publish5QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x2d, 0xe0, 0xa4, 0xde, 0xa3, 0x10, 0xe0, 0xda, 0xe5, 0x18, 0x21, 0x6e, 0xd, - 0x5a, 0xc1, 0x59, 0x13, 0x72, 0x81, 0xdb, 0x54, 0xac, 0x8b, 0xfc, 0x32, 0x7e}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x91, 0x62, 0x24, 0x7f, 0xed, 0xb0, 0xf5, 0x45, 0xfa, 0xba, 0x2, - 0x1f, 0x7c, 0xa3, 0xc, 0xdd, 0xbe, 0x26, 0xee, 0xb, 0x75, 0x1f}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, + 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8b}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 8532); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 3357); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "8(\GS\144\187\237\&8\196sz", -// _pubPktID = 0, _pubBody = "0zBlyt\159", _pubProps = [PropPayloadFormatIndicator 91,PropRequestProblemInformation -// 77,PropContentType -// "\DC24\251\ETB\ETXn\ENQ\ACK\193\242\131\218\t5\168\152\182\138\170\fJ",PropRequestProblemInformation -// 91,PropMaximumQoS 160,PropTopicAliasMaximum 30380,PropServerReference "",PropReceiveMaximum 26494,PropReceiveMaximum -// 31778,PropResponseInformation "\154\139\156\128?",PropSubscriptionIdentifier 28,PropRetainAvailable -// 93,PropAuthenticationData "\173?",PropReceiveMaximum 10352,PropTopicAlias 27723,PropMessageExpiryInterval -// 1735,PropMessageExpiryInterval 5242,PropTopicAliasMaximum 13186,PropCorrelationData -// "5\217\230;g)\247\203)\151",PropAuthenticationData -// "\144\144c\202x(\237O\236\177\201\166?\230\233\&3\152\146x\144\184",PropSharedSubscriptionAvailable -// 48,PropRetainAvailable 107,PropUserProperty "\ACK<\227\130\129%\141" "1\203\190\US",PropRetainAvailable 90]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\243\197\208\135\165\n\174^Z4\184\231\152+\166\ETX\175`\187\229\171:\143\196\rO\140G", _pubPktID = 31669, _pubBody = +// "\165yk,.\240\234\134]\245eA\SI\171\146\201\234a.\165", _pubProps = [PropCorrelationData "w2\170x\169\&4\199\\"]} TEST(Publish5QCTest, Encode14) { - uint8_t pkt[] = {0x39, 0xa0, 0x1, 0x0, 0xa, 0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a, 0x8b, 0x1, - 0x1, 0x5b, 0x17, 0x4d, 0x3, 0x0, 0x15, 0x12, 0x34, 0xfb, 0x17, 0x3, 0x6e, 0x5, 0x6, 0xc1, 0xf2, - 0x83, 0xda, 0x9, 0x35, 0xa8, 0x98, 0xb6, 0x8a, 0xaa, 0xc, 0x4a, 0x17, 0x5b, 0x24, 0xa0, 0x22, 0x76, - 0xac, 0x1c, 0x0, 0x0, 0x21, 0x67, 0x7e, 0x21, 0x7c, 0x22, 0x1a, 0x0, 0x5, 0x9a, 0x8b, 0x9c, 0x80, - 0x3f, 0xb, 0x1c, 0x25, 0x5d, 0x16, 0x0, 0x2, 0xad, 0x3f, 0x21, 0x28, 0x70, 0x23, 0x6c, 0x4b, 0x2, - 0x0, 0x0, 0x6, 0xc7, 0x2, 0x0, 0x0, 0x14, 0x7a, 0x22, 0x33, 0x82, 0x9, 0x0, 0xa, 0x35, 0xd9, - 0xe6, 0x3b, 0x67, 0x29, 0xf7, 0xcb, 0x29, 0x97, 0x16, 0x0, 0x15, 0x90, 0x90, 0x63, 0xca, 0x78, 0x28, - 0xed, 0x4f, 0xec, 0xb1, 0xc9, 0xa6, 0x3f, 0xe6, 0xe9, 0x33, 0x98, 0x92, 0x78, 0x90, 0xb8, 0x2a, 0x30, - 0x25, 0x6b, 0x26, 0x0, 0x7, 0x6, 0x3c, 0xe3, 0x82, 0x81, 0x25, 0x8d, 0x0, 0x4, 0x31, 0xcb, 0xbe, - 0x1f, 0x25, 0x5a, 0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; - uint8_t topic_bytes[] = {0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x40, 0x0, 0x1c, 0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, + 0x2b, 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47, 0x7b, 0xb5, + 0xb, 0x9, 0x0, 0x8, 0x77, 0x32, 0xaa, 0x78, 0xa9, 0x34, 0xc7, 0x5c, 0xa5, 0x79, 0x6b, 0x2c, 0x2e, + 0xf0, 0xea, 0x86, 0x5d, 0xf5, 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; + uint8_t topic_bytes[] = {0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, 0x2b, + 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47}; + lwmqtt_string_t topic = {28, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, 0x5d, 0xf5, + 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 20; - uint8_t bytesprops0[] = {0x12, 0x34, 0xfb, 0x17, 0x3, 0x6e, 0x5, 0x6, 0xc1, 0xf2, 0x83, - 0xda, 0x9, 0x35, 0xa8, 0x98, 0xb6, 0x8a, 0xaa, 0xc, 0x4a}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x9a, 0x8b, 0x9c, 0x80, 0x3f}; - uint8_t bytesprops3[] = {0xad, 0x3f}; - uint8_t bytesprops4[] = {0x35, 0xd9, 0xe6, 0x3b, 0x67, 0x29, 0xf7, 0xcb, 0x29, 0x97}; - uint8_t bytesprops5[] = {0x90, 0x90, 0x63, 0xca, 0x78, 0x28, 0xed, 0x4f, 0xec, 0xb1, 0xc9, - 0xa6, 0x3f, 0xe6, 0xe9, 0x33, 0x98, 0x92, 0x78, 0x90, 0xb8}; - uint8_t bytesprops7[] = {0x31, 0xcb, 0xbe, 0x1f}; - uint8_t bytesprops6[] = {0x6, 0x3c, 0xe3, 0x82, 0x81, 0x25, 0x8d}; + uint8_t bytesprops0[] = {0x77, 0x32, 0xaa, 0x78, 0xa9, 0x34, 0xc7, 0x5c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30380}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26494}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31778}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10352}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27723}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1735}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5242}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13186}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops6}, .v = {4, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 31669, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "8(\GS\144\187\237\&8\196sz", -// _pubPktID = 0, _pubBody = "0zBlyt\159", _pubProps = [PropPayloadFormatIndicator 91,PropRequestProblemInformation -// 77,PropContentType -// "\DC24\251\ETB\ETXn\ENQ\ACK\193\242\131\218\t5\168\152\182\138\170\fJ",PropRequestProblemInformation -// 91,PropMaximumQoS 160,PropTopicAliasMaximum 30380,PropServerReference "",PropReceiveMaximum 26494,PropReceiveMaximum -// 31778,PropResponseInformation "\154\139\156\128?",PropSubscriptionIdentifier 28,PropRetainAvailable -// 93,PropAuthenticationData "\173?",PropReceiveMaximum 10352,PropTopicAlias 27723,PropMessageExpiryInterval -// 1735,PropMessageExpiryInterval 5242,PropTopicAliasMaximum 13186,PropCorrelationData -// "5\217\230;g)\247\203)\151",PropAuthenticationData -// "\144\144c\202x(\237O\236\177\201\166?\230\233\&3\152\146x\144\184",PropSharedSubscriptionAvailable -// 48,PropRetainAvailable 107,PropUserProperty "\ACK<\227\130\129%\141" "1\203\190\US",PropRetainAvailable 90]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\243\197\208\135\165\n\174^Z4\184\231\152+\166\ETX\175`\187\229\171:\143\196\rO\140G", _pubPktID = 31669, _pubBody = +// "\165yk,.\240\234\134]\245eA\SI\171\146\201\234a.\165", _pubProps = [PropCorrelationData "w2\170x\169\&4\199\\"]} TEST(Publish5QCTest, Decode14) { - uint8_t pkt[] = {0x39, 0xa0, 0x1, 0x0, 0xa, 0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a, 0x8b, 0x1, - 0x1, 0x5b, 0x17, 0x4d, 0x3, 0x0, 0x15, 0x12, 0x34, 0xfb, 0x17, 0x3, 0x6e, 0x5, 0x6, 0xc1, 0xf2, - 0x83, 0xda, 0x9, 0x35, 0xa8, 0x98, 0xb6, 0x8a, 0xaa, 0xc, 0x4a, 0x17, 0x5b, 0x24, 0xa0, 0x22, 0x76, - 0xac, 0x1c, 0x0, 0x0, 0x21, 0x67, 0x7e, 0x21, 0x7c, 0x22, 0x1a, 0x0, 0x5, 0x9a, 0x8b, 0x9c, 0x80, - 0x3f, 0xb, 0x1c, 0x25, 0x5d, 0x16, 0x0, 0x2, 0xad, 0x3f, 0x21, 0x28, 0x70, 0x23, 0x6c, 0x4b, 0x2, - 0x0, 0x0, 0x6, 0xc7, 0x2, 0x0, 0x0, 0x14, 0x7a, 0x22, 0x33, 0x82, 0x9, 0x0, 0xa, 0x35, 0xd9, - 0xe6, 0x3b, 0x67, 0x29, 0xf7, 0xcb, 0x29, 0x97, 0x16, 0x0, 0x15, 0x90, 0x90, 0x63, 0xca, 0x78, 0x28, - 0xed, 0x4f, 0xec, 0xb1, 0xc9, 0xa6, 0x3f, 0xe6, 0xe9, 0x33, 0x98, 0x92, 0x78, 0x90, 0xb8, 0x2a, 0x30, - 0x25, 0x6b, 0x26, 0x0, 0x7, 0x6, 0x3c, 0xe3, 0x82, 0x81, 0x25, 0x8d, 0x0, 0x4, 0x31, 0xcb, 0xbe, - 0x1f, 0x25, 0x5a, 0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; + uint8_t pkt[] = {0x34, 0x40, 0x0, 0x1c, 0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, + 0x2b, 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47, 0x7b, 0xb5, + 0xb, 0x9, 0x0, 0x8, 0x77, 0x32, 0xaa, 0x78, 0xa9, 0x34, 0xc7, 0x5c, 0xa5, 0x79, 0x6b, 0x2c, 0x2e, + 0xf0, 0xea, 0x86, 0x5d, 0xf5, 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3471,78 +3248,120 @@ TEST(Publish5QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x38, 0x28, 0x1d, 0x90, 0xbb, 0xed, 0x38, 0xc4, 0x73, 0x7a}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x30, 0x7a, 0x42, 0x6c, 0x79, 0x74, 0x9f}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + uint8_t exp_topic_bytes[] = {0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, 0x2b, + 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, 0x5d, 0xf5, + 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 31669); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ")F\t\CAN\159&z\212\EOT\210y\239\190\EOT\131b\161\153I\235\162", _pubPktID = 2063, _pubBody = -// "\SUB\236\&0\ENQ\ACK1\246q@\SUB\224\&3{\175\RS\142k\"", _pubProps = [PropServerReference -// "\179\230jv\218d=N\245\220i\172\188\168mEau\252\DC1E\192\159\253?\150\167w",PropResponseTopic -// "^mt\fM\ESC\224\240\251c\240",PropTopicAliasMaximum 4110,PropAssignedClientIdentifier "\vP"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\v\172h\241z\159Z'\153h\STXiS.\STX&a\166|\147~\ETBbP\194\242$`q", _pubPktID = 29118, _pubBody = +// "\155\GS\134h\241\DC2\174", _pubProps = [PropRequestProblemInformation 58,PropSubscriptionIdentifierAvailable +// 41,PropSubscriptionIdentifier 30,PropMessageExpiryInterval 13507,PropPayloadFormatIndicator +// 213,PropWildcardSubscriptionAvailable 147,PropSubscriptionIdentifierAvailable 57,PropReceiveMaximum +// 3682,PropServerReference "5C\CAN$\STXi\214\131o\r\205\&8X\143",PropWildcardSubscriptionAvailable +// 131,PropRequestResponseInformation 174,PropWildcardSubscriptionAvailable 121,PropSharedSubscriptionAvailable +// 106,PropMaximumPacketSize 6087,PropMessageExpiryInterval 1138,PropMaximumQoS 166,PropResponseTopic +// "e:\SYN\202\158\161\132\161\SOH\139\ETBr\ACK\ESC7\160+\183}\221#\201",PropRequestResponseInformation +// 40,PropAuthenticationData "\203\213\NUL#\207\DC4?5Y\249n\"\174\140\150\216\"3sz",PropWildcardSubscriptionAvailable +// 42,PropSubscriptionIdentifier 19,PropMaximumPacketSize 27196,PropCorrelationData "\b\223\191e\227"]} TEST(Publish5QCTest, Encode15) { - uint8_t pkt[] = {0x34, 0x61, 0x0, 0x15, 0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, 0xef, 0xbe, - 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2, 0x8, 0xf, 0x35, 0x1c, 0x0, 0x1c, 0xb3, 0xe6, 0x6a, - 0x76, 0xda, 0x64, 0x3d, 0x4e, 0xf5, 0xdc, 0x69, 0xac, 0xbc, 0xa8, 0x6d, 0x45, 0x61, 0x75, 0xfc, 0x11, - 0x45, 0xc0, 0x9f, 0xfd, 0x3f, 0x96, 0xa7, 0x77, 0x8, 0x0, 0xb, 0x5e, 0x6d, 0x74, 0xc, 0x4d, 0x1b, - 0xe0, 0xf0, 0xfb, 0x63, 0xf0, 0x22, 0x10, 0xe, 0x12, 0x0, 0x2, 0xb, 0x50, 0x1a, 0xec, 0x30, 0x5, - 0x6, 0x31, 0xf6, 0x71, 0x40, 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; - uint8_t topic_bytes[] = {0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, - 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0xa5, 0x1, 0x0, 0x1d, 0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, + 0x53, 0x2e, 0x2, 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71, + 0x71, 0xbe, 0x7c, 0x17, 0x3a, 0x29, 0x29, 0xb, 0x1e, 0x2, 0x0, 0x0, 0x34, 0xc3, 0x1, 0xd5, 0x28, + 0x93, 0x29, 0x39, 0x21, 0xe, 0x62, 0x1c, 0x0, 0xe, 0x35, 0x43, 0x18, 0x24, 0x2, 0x69, 0xd6, 0x83, + 0x6f, 0xd, 0xcd, 0x38, 0x58, 0x8f, 0x28, 0x83, 0x19, 0xae, 0x28, 0x79, 0x2a, 0x6a, 0x27, 0x0, 0x0, + 0x17, 0xc7, 0x2, 0x0, 0x0, 0x4, 0x72, 0x24, 0xa6, 0x8, 0x0, 0x16, 0x65, 0x3a, 0x16, 0xca, 0x9e, + 0xa1, 0x84, 0xa1, 0x1, 0x8b, 0x17, 0x72, 0x6, 0x1b, 0x37, 0xa0, 0x2b, 0xb7, 0x7d, 0xdd, 0x23, 0xc9, + 0x19, 0x28, 0x16, 0x0, 0x14, 0xcb, 0xd5, 0x0, 0x23, 0xcf, 0x14, 0x3f, 0x35, 0x59, 0xf9, 0x6e, 0x22, + 0xae, 0x8c, 0x96, 0xd8, 0x22, 0x33, 0x73, 0x7a, 0x28, 0x2a, 0xb, 0x13, 0x27, 0x0, 0x0, 0x6a, 0x3c, + 0x9, 0x0, 0x5, 0x8, 0xdf, 0xbf, 0x65, 0xe3, 0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; + uint8_t topic_bytes[] = {0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, 0x53, 0x2e, 0x2, + 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x1a, 0xec, 0x30, 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, - 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 7; - uint8_t bytesprops0[] = {0xb3, 0xe6, 0x6a, 0x76, 0xda, 0x64, 0x3d, 0x4e, 0xf5, 0xdc, 0x69, 0xac, 0xbc, 0xa8, - 0x6d, 0x45, 0x61, 0x75, 0xfc, 0x11, 0x45, 0xc0, 0x9f, 0xfd, 0x3f, 0x96, 0xa7, 0x77}; - uint8_t bytesprops1[] = {0x5e, 0x6d, 0x74, 0xc, 0x4d, 0x1b, 0xe0, 0xf0, 0xfb, 0x63, 0xf0}; - uint8_t bytesprops2[] = {0xb, 0x50}; + uint8_t bytesprops0[] = {0x35, 0x43, 0x18, 0x24, 0x2, 0x69, 0xd6, 0x83, 0x6f, 0xd, 0xcd, 0x38, 0x58, 0x8f}; + uint8_t bytesprops1[] = {0x65, 0x3a, 0x16, 0xca, 0x9e, 0xa1, 0x84, 0xa1, 0x1, 0x8b, 0x17, + 0x72, 0x6, 0x1b, 0x37, 0xa0, 0x2b, 0xb7, 0x7d, 0xdd, 0x23, 0xc9}; + uint8_t bytesprops2[] = {0xcb, 0xd5, 0x0, 0x23, 0xcf, 0x14, 0x3f, 0x35, 0x59, 0xf9, + 0x6e, 0x22, 0xae, 0x8c, 0x96, 0xd8, 0x22, 0x33, 0x73, 0x7a}; + uint8_t bytesprops3[] = {0x8, 0xdf, 0xbf, 0x65, 0xe3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4110}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13507}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3682}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6087}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1138}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27196}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 2063, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29118, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// ")F\t\CAN\159&z\212\EOT\210y\239\190\EOT\131b\161\153I\235\162", _pubPktID = 2063, _pubBody = -// "\SUB\236\&0\ENQ\ACK1\246q@\SUB\224\&3{\175\RS\142k\"", _pubProps = [PropServerReference -// "\179\230jv\218d=N\245\220i\172\188\168mEau\252\DC1E\192\159\253?\150\167w",PropResponseTopic -// "^mt\fM\ESC\224\240\251c\240",PropTopicAliasMaximum 4110,PropAssignedClientIdentifier "\vP"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\v\172h\241z\159Z'\153h\STXiS.\STX&a\166|\147~\ETBbP\194\242$`q", _pubPktID = 29118, _pubBody = +// "\155\GS\134h\241\DC2\174", _pubProps = [PropRequestProblemInformation 58,PropSubscriptionIdentifierAvailable +// 41,PropSubscriptionIdentifier 30,PropMessageExpiryInterval 13507,PropPayloadFormatIndicator +// 213,PropWildcardSubscriptionAvailable 147,PropSubscriptionIdentifierAvailable 57,PropReceiveMaximum +// 3682,PropServerReference "5C\CAN$\STXi\214\131o\r\205\&8X\143",PropWildcardSubscriptionAvailable +// 131,PropRequestResponseInformation 174,PropWildcardSubscriptionAvailable 121,PropSharedSubscriptionAvailable +// 106,PropMaximumPacketSize 6087,PropMessageExpiryInterval 1138,PropMaximumQoS 166,PropResponseTopic +// "e:\SYN\202\158\161\132\161\SOH\139\ETBr\ACK\ESC7\160+\183}\221#\201",PropRequestResponseInformation +// 40,PropAuthenticationData "\203\213\NUL#\207\DC4?5Y\249n\"\174\140\150\216\"3sz",PropWildcardSubscriptionAvailable +// 42,PropSubscriptionIdentifier 19,PropMaximumPacketSize 27196,PropCorrelationData "\b\223\191e\227"]} TEST(Publish5QCTest, Decode15) { - uint8_t pkt[] = {0x34, 0x61, 0x0, 0x15, 0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, 0xef, 0xbe, - 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2, 0x8, 0xf, 0x35, 0x1c, 0x0, 0x1c, 0xb3, 0xe6, 0x6a, - 0x76, 0xda, 0x64, 0x3d, 0x4e, 0xf5, 0xdc, 0x69, 0xac, 0xbc, 0xa8, 0x6d, 0x45, 0x61, 0x75, 0xfc, 0x11, - 0x45, 0xc0, 0x9f, 0xfd, 0x3f, 0x96, 0xa7, 0x77, 0x8, 0x0, 0xb, 0x5e, 0x6d, 0x74, 0xc, 0x4d, 0x1b, - 0xe0, 0xf0, 0xfb, 0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 0xe3, 0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3551,104 +3370,61 @@ TEST(Publish5QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x29, 0x46, 0x9, 0x18, 0x9f, 0x26, 0x7a, 0xd4, 0x4, 0xd2, 0x79, - 0xef, 0xbe, 0x4, 0x83, 0x62, 0xa1, 0x99, 0x49, 0xeb, 0xa2}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1a, 0xec, 0x30, 0x5, 0x6, 0x31, 0xf6, 0x71, 0x40, - 0x1a, 0xe0, 0x33, 0x7b, 0xaf, 0x1e, 0x8e, 0x6b, 0x22}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, 0x53, 0x2e, 0x2, + 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; + lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 2063); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 29118); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 7); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\\Z\DLE\\x\DC3\192\DLE", _pubPktID = -// 15081, _pubBody = "\213\141\182\137f\134\150z.K\232\224o\177\FS\156\198\158\CAN\ESC", _pubProps = [PropReceiveMaximum -// 14518,PropRequestResponseInformation 171,PropReceiveMaximum 527,PropAssignedClientIdentifier "\RSn",PropMaximumQoS -// 222,PropPayloadFormatIndicator 176,PropAuthenticationData "-\214\204Mp)\167\137 -// \168\158\STX\STX\214\SO*\241\SOH\190",PropSessionExpiryInterval 10088,PropMessageExpiryInterval -// 28009,PropPayloadFormatIndicator 206,PropTopicAlias 15441,PropWillDelayInterval 23877,PropContentType -// "\251\US\200b",PropSharedSubscriptionAvailable 0,PropSubscriptionIdentifier 12,PropCorrelationData -// "r\132n\170X\196\194\207U\167\ENQ\249\161\t\128\253\204",PropSharedSubscriptionAvailable 71]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "q+J\205\r\197\201+\DLE\216\DC4\207\206\SI\242\241\137\SUB\213\246\&1\NUL%\242b\204", _pubPktID = 0, _pubBody = +// "\137[\151L+\\\238\187\158\137/}8}\vL\159\208\134\DC4\192", _pubProps = []} TEST(Publish5QCTest, Encode16) { - uint8_t pkt[] = {0x35, 0x7d, 0x0, 0x8, 0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10, 0x3a, 0xe9, 0x5c, 0x21, - 0x38, 0xb6, 0x19, 0xab, 0x21, 0x2, 0xf, 0x12, 0x0, 0x2, 0x1e, 0x6e, 0x24, 0xde, 0x1, 0xb0, - 0x16, 0x0, 0x13, 0x2d, 0xd6, 0xcc, 0x4d, 0x70, 0x29, 0xa7, 0x89, 0x20, 0xa8, 0x9e, 0x2, 0x2, - 0xd6, 0xe, 0x2a, 0xf1, 0x1, 0xbe, 0x11, 0x0, 0x0, 0x27, 0x68, 0x2, 0x0, 0x0, 0x6d, 0x69, - 0x1, 0xce, 0x23, 0x3c, 0x51, 0x18, 0x0, 0x0, 0x5d, 0x45, 0x3, 0x0, 0x4, 0xfb, 0x1f, 0xc8, - 0x62, 0x2a, 0x0, 0xb, 0xc, 0x9, 0x0, 0x11, 0x72, 0x84, 0x6e, 0xaa, 0x58, 0xc4, 0xc2, 0xcf, - 0x55, 0xa7, 0x5, 0xf9, 0xa1, 0x9, 0x80, 0xfd, 0xcc, 0x2a, 0x47, 0xd5, 0x8d, 0xb6, 0x89, 0x66, - 0x86, 0x96, 0x7a, 0x2e, 0x4b, 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; - uint8_t topic_bytes[] = {0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x32, 0x0, 0x1a, 0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, + 0xd8, 0x14, 0xcf, 0xce, 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, + 0x25, 0xf2, 0x62, 0xcc, 0x0, 0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, + 0x9e, 0x89, 0x2f, 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; + uint8_t topic_bytes[] = {0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, 0xd8, 0x14, 0xcf, 0xce, + 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, 0x25, 0xf2, 0x62, 0xcc}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, - 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + uint8_t msg_bytes[] = {0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, 0x89, 0x2f, + 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; - - uint8_t bytesprops0[] = {0x1e, 0x6e}; - uint8_t bytesprops1[] = {0x2d, 0xd6, 0xcc, 0x4d, 0x70, 0x29, 0xa7, 0x89, 0x20, 0xa8, - 0x9e, 0x2, 0x2, 0xd6, 0xe, 0x2a, 0xf1, 0x1, 0xbe}; - uint8_t bytesprops2[] = {0xfb, 0x1f, 0xc8, 0x62}; - uint8_t bytesprops3[] = {0x72, 0x84, 0x6e, 0xaa, 0x58, 0xc4, 0xc2, 0xcf, 0x55, - 0xa7, 0x5, 0xf9, 0xa1, 0x9, 0x80, 0xfd, 0xcc}; + msg.payload_len = 21; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14518}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 527}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10088}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28009}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15441}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23877}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 71}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 15081, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\\Z\DLE\\x\DC3\192\DLE", _pubPktID = -// 15081, _pubBody = "\213\141\182\137f\134\150z.K\232\224o\177\FS\156\198\158\CAN\ESC", _pubProps = [PropReceiveMaximum -// 14518,PropRequestResponseInformation 171,PropReceiveMaximum 527,PropAssignedClientIdentifier "\RSn",PropMaximumQoS -// 222,PropPayloadFormatIndicator 176,PropAuthenticationData "-\214\204Mp)\167\137 -// \168\158\STX\STX\214\SO*\241\SOH\190",PropSessionExpiryInterval 10088,PropMessageExpiryInterval -// 28009,PropPayloadFormatIndicator 206,PropTopicAlias 15441,PropWillDelayInterval 23877,PropContentType -// "\251\US\200b",PropSharedSubscriptionAvailable 0,PropSubscriptionIdentifier 12,PropCorrelationData -// "r\132n\170X\196\194\207U\167\ENQ\249\161\t\128\253\204",PropSharedSubscriptionAvailable 71]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "q+J\205\r\197\201+\DLE\216\DC4\207\206\SI\242\241\137\SUB\213\246\&1\NUL%\242b\204", _pubPktID = 0, _pubBody = +// "\137[\151L+\\\238\187\158\137/}8}\vL\159\208\134\DC4\192", _pubProps = []} TEST(Publish5QCTest, Decode16) { - uint8_t pkt[] = {0x35, 0x7d, 0x0, 0x8, 0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10, 0x3a, 0xe9, 0x5c, 0x21, - 0x38, 0xb6, 0x19, 0xab, 0x21, 0x2, 0xf, 0x12, 0x0, 0x2, 0x1e, 0x6e, 0x24, 0xde, 0x1, 0xb0, - 0x16, 0x0, 0x13, 0x2d, 0xd6, 0xcc, 0x4d, 0x70, 0x29, 0xa7, 0x89, 0x20, 0xa8, 0x9e, 0x2, 0x2, - 0xd6, 0xe, 0x2a, 0xf1, 0x1, 0xbe, 0x11, 0x0, 0x0, 0x27, 0x68, 0x2, 0x0, 0x0, 0x6d, 0x69, - 0x1, 0xce, 0x23, 0x3c, 0x51, 0x18, 0x0, 0x0, 0x5d, 0x45, 0x3, 0x0, 0x4, 0xfb, 0x1f, 0xc8, - 0x62, 0x2a, 0x0, 0xb, 0xc, 0x9, 0x0, 0x11, 0x72, 0x84, 0x6e, 0xaa, 0x58, 0xc4, 0xc2, 0xcf, - 0x55, 0xa7, 0x5, 0xf9, 0xa1, 0x9, 0x80, 0xfd, 0xcc, 0x2a, 0x47, 0xd5, 0x8d, 0xb6, 0x89, 0x66, - 0x86, 0x96, 0x7a, 0x2e, 0x4b, 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; + uint8_t pkt[] = {0x39, 0x32, 0x0, 0x1a, 0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, + 0xd8, 0x14, 0xcf, 0xce, 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, + 0x25, 0xf2, 0x62, 0xcc, 0x0, 0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, + 0x9e, 0x89, 0x2f, 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3657,61 +3433,150 @@ TEST(Publish5QCTest, Decode16) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5c, 0x5a, 0x10, 0x5c, 0x78, 0x13, 0xc0, 0x10}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd5, 0x8d, 0xb6, 0x89, 0x66, 0x86, 0x96, 0x7a, 0x2e, 0x4b, - 0xe8, 0xe0, 0x6f, 0xb1, 0x1c, 0x9c, 0xc6, 0x9e, 0x18, 0x1b}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, 0xd8, 0x14, 0xcf, 0xce, + 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, 0x25, 0xf2, 0x62, 0xcc}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, 0x89, 0x2f, + 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 15081); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "~2\242\136\211*\DEL", _pubPktID = -// 30428, _pubBody = "\253ET\175\214\175\205\211w\196\ETX\f-\214\144\194", _pubProps = [PropServerKeepAlive -// 4003,PropMessageExpiryInterval 15782,PropRetainAvailable 134]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "6", _pubPktID = 0, _pubBody = "b", +// _pubProps = [PropResponseTopic "l\135\EM",PropSessionExpiryInterval 27254,PropSubscriptionIdentifierAvailable +// 134,PropMaximumPacketSize 4947,PropRequestResponseInformation 129,PropServerReference +// "\152$\STX\215\220\243\246\202@\129_V%\158\176",PropServerReference "\246bNa\175@;\160\187\144o\232 +// ",PropServerReference "\246} \172\ETB?\252U\254\a\237Q\226WE\173\162b\163\217\246",PropMaximumPacketSize +// 23596,PropReasonString "]\CAN!\SUB\191~\131}S\202$f\141\155\&0~\189\ENQ^\228\203\206",PropContentType +// "@/\238{\253\142\158t\206&\143\160\&2\225\244\162x\195\r\235\DELx",PropReceiveMaximum 15263,PropCorrelationData +// "\241\234\181\&8\220^\161\239SU",PropAuthenticationData +// "\212\211G%\134\NUL&\185\242\159+\139J\177\177",PropResponseTopic +// "\230\238s\143\164\133-\212\SOV++\249\138",PropServerReference +// "PV\128\209\&0$\172M\231l\153\129\199\184\&84\244\152F\170C\225\179\208\b\137",PropMessageExpiryInterval +// 26834,PropServerKeepAlive 26744,PropRequestResponseInformation 214,PropTopicAlias 21354,PropServerReference +// "\164\244\229\233\151\187k}v\237",PropRetainAvailable 118,PropAuthenticationMethod +// "IX\131\171r\178\196u",PropTopicAliasMaximum 8893,PropCorrelationData "`\146\151\209}\EOT\177\230\236S"]} TEST(Publish5QCTest, Encode17) { - uint8_t pkt[] = {0x3b, 0x26, 0x0, 0x7, 0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f, 0x76, 0xdc, 0xa, - 0x13, 0xf, 0xa3, 0x2, 0x0, 0x0, 0x3d, 0xa6, 0x25, 0x86, 0xfd, 0x45, 0x54, 0xaf, - 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; - uint8_t topic_bytes[] = {0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x31, 0x92, 0x2, 0x0, 0x1, 0x36, 0x8c, 0x2, 0x8, 0x0, 0x3, 0x6c, 0x87, 0x19, 0x11, 0x0, 0x0, 0x6a, 0x76, + 0x29, 0x86, 0x27, 0x0, 0x0, 0x13, 0x53, 0x19, 0x81, 0x1c, 0x0, 0xf, 0x98, 0x24, 0x2, 0xd7, 0xdc, 0xf3, 0xf6, + 0xca, 0x40, 0x81, 0x5f, 0x56, 0x25, 0x9e, 0xb0, 0x1c, 0x0, 0xd, 0xf6, 0x62, 0x4e, 0x61, 0xaf, 0x40, 0x3b, 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 0x97, 0xbb, 0x6b, 0x7d, 0x76, 0xed, + 0x25, 0x76, 0x15, 0x0, 0x8, 0x49, 0x58, 0x83, 0xab, 0x72, 0xb2, 0xc4, 0x75, 0x22, 0x22, 0xbd, 0x9, 0x0, 0xa, + 0x60, 0x92, 0x97, 0xd1, 0x7d, 0x4, 0xb1, 0xe6, 0xec, 0x53, 0x62}; + uint8_t topic_bytes[] = {0x36}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xfd, 0x45, 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; + uint8_t msg_bytes[] = {0x62}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 1; + + uint8_t bytesprops0[] = {0x6c, 0x87, 0x19}; + uint8_t bytesprops1[] = {0x98, 0x24, 0x2, 0xd7, 0xdc, 0xf3, 0xf6, 0xca, 0x40, 0x81, 0x5f, 0x56, 0x25, 0x9e, 0xb0}; + uint8_t bytesprops2[] = {0xf6, 0x62, 0x4e, 0x61, 0xaf, 0x40, 0x3b, 0xa0, 0xbb, 0x90, 0x6f, 0xe8, 0x20}; + uint8_t bytesprops3[] = {0xf6, 0x7d, 0x20, 0xac, 0x17, 0x3f, 0xfc, 0x55, 0xfe, 0x7, 0xed, + 0x51, 0xe2, 0x57, 0x45, 0xad, 0xa2, 0x62, 0xa3, 0xd9, 0xf6}; + uint8_t bytesprops4[] = {0x5d, 0x18, 0x21, 0x1a, 0xbf, 0x7e, 0x83, 0x7d, 0x53, 0xca, 0x24, + 0x66, 0x8d, 0x9b, 0x30, 0x7e, 0xbd, 0x5, 0x5e, 0xe4, 0xcb, 0xce}; + uint8_t bytesprops5[] = {0x40, 0x2f, 0xee, 0x7b, 0xfd, 0x8e, 0x9e, 0x74, 0xce, 0x26, 0x8f, + 0xa0, 0x32, 0xe1, 0xf4, 0xa2, 0x78, 0xc3, 0xd, 0xeb, 0x7f, 0x78}; + uint8_t bytesprops6[] = {0xf1, 0xea, 0xb5, 0x38, 0xdc, 0x5e, 0xa1, 0xef, 0x53, 0x55}; + uint8_t bytesprops7[] = {0xd4, 0xd3, 0x47, 0x25, 0x86, 0x0, 0x26, 0xb9, 0xf2, 0x9f, 0x2b, 0x8b, 0x4a, 0xb1, 0xb1}; + uint8_t bytesprops8[] = {0xe6, 0xee, 0x73, 0x8f, 0xa4, 0x85, 0x2d, 0xd4, 0xe, 0x56, 0x2b, 0x2b, 0xf9, 0x8a}; + uint8_t bytesprops9[] = {0x50, 0x56, 0x80, 0xd1, 0x30, 0x24, 0xac, 0x4d, 0xe7, 0x6c, 0x99, 0x81, 0xc7, + 0xb8, 0x38, 0x34, 0xf4, 0x98, 0x46, 0xaa, 0x43, 0xe1, 0xb3, 0xd0, 0x8, 0x89}; + uint8_t bytesprops10[] = {0xa4, 0xf4, 0xe5, 0xe9, 0x97, 0xbb, 0x6b, 0x7d, 0x76, 0xed}; + uint8_t bytesprops11[] = {0x49, 0x58, 0x83, 0xab, 0x72, 0xb2, 0xc4, 0x75}; + uint8_t bytesprops12[] = {0x60, 0x92, 0x97, 0xd1, 0x7d, 0x4, 0xb1, 0xe6, 0xec, 0x53}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4003}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15782}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27254}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4947}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23596}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15263}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26834}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26744}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21354}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8893}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops12}}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 30428, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "~2\242\136\211*\DEL", _pubPktID = -// 30428, _pubBody = "\253ET\175\214\175\205\211w\196\ETX\f-\214\144\194", _pubProps = [PropServerKeepAlive -// 4003,PropMessageExpiryInterval 15782,PropRetainAvailable 134]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "6", _pubPktID = 0, _pubBody = "b", +// _pubProps = [PropResponseTopic "l\135\EM",PropSessionExpiryInterval 27254,PropSubscriptionIdentifierAvailable +// 134,PropMaximumPacketSize 4947,PropRequestResponseInformation 129,PropServerReference +// "\152$\STX\215\220\243\246\202@\129_V%\158\176",PropServerReference "\246bNa\175@;\160\187\144o\232 +// ",PropServerReference "\246} \172\ETB?\252U\254\a\237Q\226WE\173\162b\163\217\246",PropMaximumPacketSize +// 23596,PropReasonString "]\CAN!\SUB\191~\131}S\202$f\141\155\&0~\189\ENQ^\228\203\206",PropContentType +// "@/\238{\253\142\158t\206&\143\160\&2\225\244\162x\195\r\235\DELx",PropReceiveMaximum 15263,PropCorrelationData +// "\241\234\181\&8\220^\161\239SU",PropAuthenticationData +// "\212\211G%\134\NUL&\185\242\159+\139J\177\177",PropResponseTopic +// "\230\238s\143\164\133-\212\SOV++\249\138",PropServerReference +// "PV\128\209\&0$\172M\231l\153\129\199\184\&84\244\152F\170C\225\179\208\b\137",PropMessageExpiryInterval +// 26834,PropServerKeepAlive 26744,PropRequestResponseInformation 214,PropTopicAlias 21354,PropServerReference +// "\164\244\229\233\151\187k}v\237",PropRetainAvailable 118,PropAuthenticationMethod +// "IX\131\171r\178\196u",PropTopicAliasMaximum 8893,PropCorrelationData "`\146\151\209}\EOT\177\230\236S"]} TEST(Publish5QCTest, Decode17) { - u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0x3b, 0x9f, 0x9, 0x0, 0xa, 0xf1, 0xea, 0xb5, 0x38, 0xdc, + 0x5e, 0xa1, 0xef, 0x53, 0x55, 0x16, 0x0, 0xf, 0xd4, 0xd3, 0x47, 0x25, 0x86, 0x0, 0x26, 0xb9, 0xf2, 0x9f, 0x2b, + 0x8b, 0x4a, 0xb1, 0xb1, 0x8, 0x0, 0xe, 0xe6, 0xee, 0x73, 0x8f, 0xa4, 0x85, 0x2d, 0xd4, 0xe, 0x56, 0x2b, 0x2b, + 0xf9, 0x8a, 0x1c, 0x0, 0x1a, 0x50, 0x56, 0x80, 0xd1, 0x30, 0x24, 0xac, 0x4d, 0xe7, 0x6c, 0x99, 0x81, 0xc7, 0xb8, + 0x38, 0x34, 0xf4, 0x98, 0x46, 0xaa, 0x43, 0xe1, 0xb3, 0xd0, 0x8, 0x89, 0x2, 0x0, 0x0, 0x68, 0xd2, 0x13, 0x68, + 0x78, 0x19, 0xd6, 0x23, 0x53, 0x6a, 0x1c, 0x0, 0xa, 0xa4, 0xf4, 0xe5, 0xe9, 0x97, 0xbb, 0x6b, 0x7d, 0x76, 0xed, + 0x25, 0x76, 0x15, 0x0, 0x8, 0x49, 0x58, 0x83, 0xab, 0x72, 0xb2, 0xc4, 0x75, 0x22, 0x22, 0xbd, 0x9, 0x0, 0xa, + 0x60, 0x92, 0x97, 0xd1, 0x7d, 0x4, 0xb1, 0xe6, 0xec, 0x53, 0x62}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3720,87 +3585,52 @@ TEST(Publish5QCTest, Decode17) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7e, 0x32, 0xf2, 0x88, 0xd3, 0x2a, 0x7f}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfd, 0x45, 0x54, 0xaf, 0xd6, 0xaf, 0xcd, 0xd3, - 0x77, 0xc4, 0x3, 0xc, 0x2d, 0xd6, 0x90, 0xc2}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0x36}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x62}; + lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 30428); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 1); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "dG\194+K1e\237n\253\EM\US\222\156\216K\173\158+\228\&9E\185\CAN\147`\203un\n", _pubPktID = 16078, _pubBody = "", -// _pubProps = [PropResponseTopic -// "\166\242\248\192\207\220\249z\141t\a`\222\EM\183Op(5\226QK'\245\150\nI\SOHR3",PropTopicAliasMaximum -// 26890,PropMaximumQoS 179,PropMessageExpiryInterval 8868,PropSubscriptionIdentifierAvailable 112,PropReasonString -// "\229\ENQ\190m\206\t\130\134\b\131\134\235+\166bi\138\163\172\186\NAKJ\a\SYN\138C\184K",PropRequestResponseInformation -// 172]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\184\EOT\177\237[w\205\DC4E\GS@", +// _pubPktID = 11334, _pubBody = "\247ax\ESCb", _pubProps = []} TEST(Publish5QCTest, Encode18) { - uint8_t pkt[] = {0x32, 0x71, 0x0, 0x1e, 0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, - 0x9c, 0xd8, 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa, - 0x3e, 0xce, 0x4e, 0x8, 0x0, 0x1e, 0xa6, 0xf2, 0xf8, 0xc0, 0xcf, 0xdc, 0xf9, 0x7a, 0x8d, 0x74, 0x7, - 0x60, 0xde, 0x19, 0xb7, 0x4f, 0x70, 0x28, 0x35, 0xe2, 0x51, 0x4b, 0x27, 0xf5, 0x96, 0xa, 0x49, 0x1, - 0x52, 0x33, 0x22, 0x69, 0xa, 0x24, 0xb3, 0x2, 0x0, 0x0, 0x22, 0xa4, 0x29, 0x70, 0x1f, 0x0, 0x1c, - 0xe5, 0x5, 0xbe, 0x6d, 0xce, 0x9, 0x82, 0x86, 0x8, 0x83, 0x86, 0xeb, 0x2b, 0xa6, 0x62, 0x69, 0x8a, - 0xa3, 0xac, 0xba, 0x15, 0x4a, 0x7, 0x16, 0x8a, 0x43, 0xb8, 0x4b, 0x19, 0xac}; - uint8_t topic_bytes[] = {0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, - 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa}; - lwmqtt_string_t topic = {30, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x16, 0x0, 0xc, 0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, + 0x14, 0x45, 0x1d, 0x40, 0x2c, 0x46, 0x0, 0xf7, 0x61, 0x78, 0x1b, 0x62}; + uint8_t topic_bytes[] = {0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, 0x14, 0x45, 0x1d, 0x40}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0}; + msg.retained = true; + uint8_t msg_bytes[] = {0xf7, 0x61, 0x78, 0x1b, 0x62}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 0; + msg.payload_len = 5; - uint8_t bytesprops0[] = {0xa6, 0xf2, 0xf8, 0xc0, 0xcf, 0xdc, 0xf9, 0x7a, 0x8d, 0x74, 0x7, 0x60, 0xde, 0x19, 0xb7, - 0x4f, 0x70, 0x28, 0x35, 0xe2, 0x51, 0x4b, 0x27, 0xf5, 0x96, 0xa, 0x49, 0x1, 0x52, 0x33}; - uint8_t bytesprops1[] = {0xe5, 0x5, 0xbe, 0x6d, 0xce, 0x9, 0x82, 0x86, 0x8, 0x83, 0x86, 0xeb, 0x2b, 0xa6, - 0x62, 0x69, 0x8a, 0xa3, 0xac, 0xba, 0x15, 0x4a, 0x7, 0x16, 0x8a, 0x43, 0xb8, 0x4b}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26890}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8868}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 16078, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 11334, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "dG\194+K1e\237n\253\EM\US\222\156\216K\173\158+\228\&9E\185\CAN\147`\203un\n", _pubPktID = 16078, _pubBody = "", -// _pubProps = [PropResponseTopic -// "\166\242\248\192\207\220\249z\141t\a`\222\EM\183Op(5\226QK'\245\150\nI\SOHR3",PropTopicAliasMaximum -// 26890,PropMaximumQoS 179,PropMessageExpiryInterval 8868,PropSubscriptionIdentifierAvailable 112,PropReasonString -// "\229\ENQ\190m\206\t\130\134\b\131\134\235+\166bi\138\163\172\186\NAKJ\a\SYN\138C\184K",PropRequestResponseInformation -// 172]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\184\EOT\177\237[w\205\DC4E\GS@", +// _pubPktID = 11334, _pubBody = "\247ax\ESCb", _pubProps = []} TEST(Publish5QCTest, Decode18) { - uint8_t pkt[] = {0x32, 0x71, 0x0, 0x1e, 0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, - 0x9c, 0xd8, 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa, - 0x3e, 0xce, 0x4e, 0x8, 0x0, 0x1e, 0xa6, 0xf2, 0xf8, 0xc0, 0xcf, 0xdc, 0xf9, 0x7a, 0x8d, 0x74, 0x7, - 0x60, 0xde, 0x19, 0xb7, 0x4f, 0x70, 0x28, 0x35, 0xe2, 0x51, 0x4b, 0x27, 0xf5, 0x96, 0xa, 0x49, 0x1, - 0x52, 0x33, 0x22, 0x69, 0xa, 0x24, 0xb3, 0x2, 0x0, 0x0, 0x22, 0xa4, 0x29, 0x70, 0x1f, 0x0, 0x1c, - 0xe5, 0x5, 0xbe, 0x6d, 0xce, 0x9, 0x82, 0x86, 0x8, 0x83, 0x86, 0xeb, 0x2b, 0xa6, 0x62, 0x69, 0x8a, - 0xa3, 0xac, 0xba, 0x15, 0x4a, 0x7, 0x16, 0x8a, 0x43, 0xb8, 0x4b, 0x19, 0xac}; + uint8_t pkt[] = {0x3b, 0x16, 0x0, 0xc, 0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, + 0x14, 0x45, 0x1d, 0x40, 0x2c, 0x46, 0x0, 0xf7, 0x61, 0x78, 0x1b, 0x62}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3809,128 +3639,93 @@ TEST(Publish5QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x64, 0x47, 0xc2, 0x2b, 0x4b, 0x31, 0x65, 0xed, 0x6e, 0xfd, 0x19, 0x1f, 0xde, 0x9c, 0xd8, - 0x4b, 0xad, 0x9e, 0x2b, 0xe4, 0x39, 0x45, 0xb9, 0x18, 0x93, 0x60, 0xcb, 0x75, 0x6e, 0xa}; - lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0}; - lwmqtt_string_t exp_body = {0, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, 0x14, 0x45, 0x1d, 0x40}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf7, 0x61, 0x78, 0x1b, 0x62}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 16078); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); - EXPECT_EQ(msg.payload_len, 0); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 11334); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "?\DC1;Y\196\211\145n\198\234\233\176_,\224\194\182X\250J\NUL_\198\186\&5\173\224W", _pubPktID = 0, _pubBody = -// "\189?\ag\226\204+\195v\STX4\147\165\167h\131}n\149j\208", _pubProps = [PropWildcardSubscriptionAvailable -// 0,PropCorrelationData -// "\192\253\172\134\180\240\188A\202\151\153^\148\&0\153\251|\227\151\207))\207U`",PropRetainAvailable -// 202,PropUserProperty "\151\180#\EOT1\US\252.\STX\224\214\210\\\192\242\213^\193\SUB\149\175\165\193!V" -// "\145\&0\189\&0\253\&5\165\SUB\140\140g`c\SOH",PropSubscriptionIdentifier 3,PropSubscriptionIdentifierAvailable -// 175,PropContentType "",PropServerKeepAlive 10995,PropWillDelayInterval 29838,PropTopicAliasMaximum -// 12765,PropUserProperty "\249\223\142_B\DELAQ\NAKr\155]\254'h\178Q\140\212\ETX\230\240\151td\213g" -// "E",PropAssignedClientIdentifier "\SOH\EMJd|\185_6\232",PropMaximumQoS 36,PropSubscriptionIdentifierAvailable -// 226,PropResponseInformation "\250?\140\DC1\211\RS\238rpe\EM\253[8\147y",PropReasonString -// "\221\166\174\SI",PropResponseInformation "t4\SYNQ\140W'_i\v6",PropServerReference -// "\210\245\151\236",PropTopicAliasMaximum 8057,PropAssignedClientIdentifier "\159RG\156",PropCorrelationData -// "~\249\195\160\166Y2\154L\150i \ACKr\242\181\DLE8d\221\175\215\176\202\248\216\163",PropReceiveMaximum -// 3286,PropSubscriptionIdentifierAvailable 245,PropTopicAliasMaximum 5386,PropReceiveMaximum -// 8489,PropRequestResponseInformation 31,PropPayloadFormatIndicator 106,PropWillDelayInterval -// 8799,PropResponseInformation -// "Z\216\187\SOH\169\207\180vs\177\&8\216\150\v\174\195\245\187\250vq(X\SYN\197Z",PropMessageExpiryInterval 22785]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\tm5\139\DC1\DC18\255>\b\a\EM\145\213XbT\218|", _pubPktID = 0, _pubBody = "\DC4\GS+\EM\ESC\132B\172\232|\215", +// _pubProps = [PropTopicAliasMaximum 14496,PropServerReference +// "\176\251s\234\234\&2\201O&\DLE",PropSharedSubscriptionAvailable 24,PropUserProperty +// "\249Z\DC3\EOT\145\166\&4\182U\162t}\DC2\139\128]1\211@L\DC22&M\157\&7" +// "\254\223\&7\220BMq\175Un",PropMaximumPacketSize 6785,PropServerKeepAlive 10085,PropPayloadFormatIndicator +// 74,PropAuthenticationData "\213\150\137\148W\231\160",PropTopicAliasMaximum 7081,PropContentType +// "\155A\166\188\NAK,\180\206\154\226j\f!\160",PropWillDelayInterval 17165,PropMaximumPacketSize +// 15345,PropAuthenticationData +// "\206@\151\167\b\a\EM\145\213XbT\218|", _pubPktID = 0, _pubBody = "\DC4\GS+\EM\ESC\132B\172\232|\215", +// _pubProps = [PropTopicAliasMaximum 14496,PropServerReference +// "\176\251s\234\234\&2\201O&\DLE",PropSharedSubscriptionAvailable 24,PropUserProperty +// "\249Z\DC3\EOT\145\166\&4\182U\162t}\DC2\139\128]1\211@L\DC22&M\157\&7" +// "\254\223\&7\220BMq\175Un",PropMaximumPacketSize 6785,PropServerKeepAlive 10085,PropPayloadFormatIndicator +// 74,PropAuthenticationData "\213\150\137\148W\231\160",PropTopicAliasMaximum 7081,PropContentType +// "\155A\166\188\NAK,\180\206\154\226j\f!\160",PropWillDelayInterval 17165,PropMaximumPacketSize +// 15345,PropAuthenticationData +// "\206@\151\167(topic.data), 28); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "D\SUBc\224\DC3\202\&3\187\&84T\240", _pubPktID = 22665, _pubBody = -// "EV\174.\183\&1Q\DC1\216V\203p>q=x\132\163(\239\143\135b\236\137\&6", _pubProps = [PropTopicAlias -// 1081,PropContentType "3\205\199\242_=",PropWildcardSubscriptionAvailable 83,PropUserProperty "F\217%]\244\163G\239" -// "\156\129",PropPayloadFormatIndicator 159,PropServerReference -// "\226\"\247\195\163\GSS%\184\r\215t\186\211",PropResponseInformation -// "\174\249z\CAN\248\219\SI\138}\152",PropAssignedClientIdentifier -// "!j\154E\128o\220\EOT\251=\135\221i\180\RS",PropMaximumPacketSize 30968,PropReasonString -// "\157\&3U\GS\139\&1-\250\SOH\177\245\128\STX",PropCorrelationData -// "\EOT\189\NULoWjA\177\237\168\215-\225",PropWildcardSubscriptionAvailable 11]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\211Q\204\149\142\&8\217\174\213\221\133\214\221\166\207E\151\t\221y\192>\ETBqK[", _pubPktID = 0, _pubBody = +// "\189\221\169\130\f\211\DC1\DC2\252", _pubProps = [PropWildcardSubscriptionAvailable 130,PropRetainAvailable +// 210,PropPayloadFormatIndicator 124,PropReasonString "\SIO\248m?>tR\149\216l\CANUVY\236",PropMessageExpiryInterval +// 13933,PropRequestResponseInformation 138,PropSharedSubscriptionAvailable 224,PropWildcardSubscriptionAvailable 148]} TEST(Publish5QCTest, Encode20) { - uint8_t pkt[] = {0x32, 0xa1, 0x1, 0x0, 0xc, 0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, 0xf0, - 0x58, 0x89, 0x76, 0x23, 0x4, 0x39, 0x3, 0x0, 0x6, 0x33, 0xcd, 0xc7, 0xf2, 0x5f, 0x3d, 0x28, 0x53, - 0x26, 0x0, 0x8, 0x46, 0xd9, 0x25, 0x5d, 0xf4, 0xa3, 0x47, 0xef, 0x0, 0x2, 0x9c, 0x81, 0x1, 0x9f, - 0x1c, 0x0, 0xe, 0xe2, 0x22, 0xf7, 0xc3, 0xa3, 0x1d, 0x53, 0x25, 0xb8, 0xd, 0xd7, 0x74, 0xba, 0xd3, - 0x1a, 0x0, 0xa, 0xae, 0xf9, 0x7a, 0x18, 0xf8, 0xdb, 0xf, 0x8a, 0x7d, 0x98, 0x12, 0x0, 0xf, 0x21, - 0x6a, 0x9a, 0x45, 0x80, 0x6f, 0xdc, 0x4, 0xfb, 0x3d, 0x87, 0xdd, 0x69, 0xb4, 0x1e, 0x27, 0x0, 0x0, - 0x78, 0xf8, 0x1f, 0x0, 0xd, 0x9d, 0x33, 0x55, 0x1d, 0x8b, 0x31, 0x2d, 0xfa, 0x1, 0xb1, 0xf5, 0x80, - 0x2, 0x9, 0x0, 0xd, 0x4, 0xbd, 0x0, 0x6f, 0x57, 0x6a, 0x41, 0xb1, 0xed, 0xa8, 0xd7, 0x2d, 0xe1, - 0x28, 0xb, 0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, 0x3e, 0x71, 0x3d, - 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; - uint8_t topic_bytes[] = {0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, 0xf0}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x4a, 0x0, 0x1a, 0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, + 0xdd, 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b, 0x24, 0x28, + 0x82, 0x25, 0xd2, 0x1, 0x7c, 0x1f, 0x0, 0x10, 0xf, 0x4f, 0xf8, 0x6d, 0x3f, 0x3e, 0x74, 0x52, + 0x95, 0xd8, 0x6c, 0x18, 0x55, 0x56, 0x59, 0xec, 0x2, 0x0, 0x0, 0x36, 0x6d, 0x19, 0x8a, 0x2a, + 0xe0, 0x28, 0x94, 0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; + uint8_t topic_bytes[] = {0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, 0xdd, + 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, 0x3e, - 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + uint8_t msg_bytes[] = {0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 9; - uint8_t bytesprops0[] = {0x33, 0xcd, 0xc7, 0xf2, 0x5f, 0x3d}; - uint8_t bytesprops2[] = {0x9c, 0x81}; - uint8_t bytesprops1[] = {0x46, 0xd9, 0x25, 0x5d, 0xf4, 0xa3, 0x47, 0xef}; - uint8_t bytesprops3[] = {0xe2, 0x22, 0xf7, 0xc3, 0xa3, 0x1d, 0x53, 0x25, 0xb8, 0xd, 0xd7, 0x74, 0xba, 0xd3}; - uint8_t bytesprops4[] = {0xae, 0xf9, 0x7a, 0x18, 0xf8, 0xdb, 0xf, 0x8a, 0x7d, 0x98}; - uint8_t bytesprops5[] = {0x21, 0x6a, 0x9a, 0x45, 0x80, 0x6f, 0xdc, 0x4, 0xfb, 0x3d, 0x87, 0xdd, 0x69, 0xb4, 0x1e}; - uint8_t bytesprops6[] = {0x9d, 0x33, 0x55, 0x1d, 0x8b, 0x31, 0x2d, 0xfa, 0x1, 0xb1, 0xf5, 0x80, 0x2}; - uint8_t bytesprops7[] = {0x4, 0xbd, 0x0, 0x6f, 0x57, 0x6a, 0x41, 0xb1, 0xed, 0xa8, 0xd7, 0x2d, 0xe1}; + uint8_t bytesprops0[] = {0xf, 0x4f, 0xf8, 0x6d, 0x3f, 0x3e, 0x74, 0x52, + 0x95, 0xd8, 0x6c, 0x18, 0x55, 0x56, 0x59, 0xec}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1081}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops1}, .v = {2, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30968}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13933}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 148}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 22665, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "D\SUBc\224\DC3\202\&3\187\&84T\240", _pubPktID = 22665, _pubBody = -// "EV\174.\183\&1Q\DC1\216V\203p>q=x\132\163(\239\143\135b\236\137\&6", _pubProps = [PropTopicAlias -// 1081,PropContentType "3\205\199\242_=",PropWildcardSubscriptionAvailable 83,PropUserProperty "F\217%]\244\163G\239" -// "\156\129",PropPayloadFormatIndicator 159,PropServerReference -// "\226\"\247\195\163\GSS%\184\r\215t\186\211",PropResponseInformation -// "\174\249z\CAN\248\219\SI\138}\152",PropAssignedClientIdentifier -// "!j\154E\128o\220\EOT\251=\135\221i\180\RS",PropMaximumPacketSize 30968,PropReasonString -// "\157\&3U\GS\139\&1-\250\SOH\177\245\128\STX",PropCorrelationData -// "\EOT\189\NULoWjA\177\237\168\215-\225",PropWildcardSubscriptionAvailable 11]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\211Q\204\149\142\&8\217\174\213\221\133\214\221\166\207E\151\t\221y\192>\ETBqK[", _pubPktID = 0, _pubBody = +// "\189\221\169\130\f\211\DC1\DC2\252", _pubProps = [PropWildcardSubscriptionAvailable 130,PropRetainAvailable +// 210,PropPayloadFormatIndicator 124,PropReasonString "\SIO\248m?>tR\149\216l\CANUVY\236",PropMessageExpiryInterval +// 13933,PropRequestResponseInformation 138,PropSharedSubscriptionAvailable 224,PropWildcardSubscriptionAvailable 148]} TEST(Publish5QCTest, Decode20) { - uint8_t pkt[] = {0x32, 0xa1, 0x1, 0x0, 0xc, 0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, 0xf0, - 0x58, 0x89, 0x76, 0x23, 0x4, 0x39, 0x3, 0x0, 0x6, 0x33, 0xcd, 0xc7, 0xf2, 0x5f, 0x3d, 0x28, 0x53, - 0x26, 0x0, 0x8, 0x46, 0xd9, 0x25, 0x5d, 0xf4, 0xa3, 0x47, 0xef, 0x0, 0x2, 0x9c, 0x81, 0x1, 0x9f, - 0x1c, 0x0, 0xe, 0xe2, 0x22, 0xf7, 0xc3, 0xa3, 0x1d, 0x53, 0x25, 0xb8, 0xd, 0xd7, 0x74, 0xba, 0xd3, - 0x1a, 0x0, 0xa, 0xae, 0xf9, 0x7a, 0x18, 0xf8, 0xdb, 0xf, 0x8a, 0x7d, 0x98, 0x12, 0x0, 0xf, 0x21, - 0x6a, 0x9a, 0x45, 0x80, 0x6f, 0xdc, 0x4, 0xfb, 0x3d, 0x87, 0xdd, 0x69, 0xb4, 0x1e, 0x27, 0x0, 0x0, - 0x78, 0xf8, 0x1f, 0x0, 0xd, 0x9d, 0x33, 0x55, 0x1d, 0x8b, 0x31, 0x2d, 0xfa, 0x1, 0xb1, 0xf5, 0x80, - 0x2, 0x9, 0x0, 0xd, 0x4, 0xbd, 0x0, 0x6f, 0x57, 0x6a, 0x41, 0xb1, 0xed, 0xa8, 0xd7, 0x2d, 0xe1, - 0x28, 0xb, 0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, 0x3e, 0x71, 0x3d, - 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; + uint8_t pkt[] = {0x30, 0x4a, 0x0, 0x1a, 0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, + 0xdd, 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b, 0x24, 0x28, + 0x82, 0x25, 0xd2, 0x1, 0x7c, 0x1f, 0x0, 0x10, 0xf, 0x4f, 0xf8, 0x6d, 0x3f, 0x3e, 0x74, 0x52, + 0x95, 0xd8, 0x6c, 0x18, 0x55, 0x56, 0x59, 0xec, 0x2, 0x0, 0x0, 0x36, 0x6d, 0x19, 0x8a, 0x2a, + 0xe0, 0x28, 0x94, 0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4095,77 +3847,84 @@ TEST(Publish5QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x44, 0x1a, 0x63, 0xe0, 0x13, 0xca, 0x33, 0xbb, 0x38, 0x34, 0x54, 0xf0}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x45, 0x56, 0xae, 0x2e, 0xb7, 0x31, 0x51, 0x11, 0xd8, 0x56, 0xcb, 0x70, 0x3e, - 0x71, 0x3d, 0x78, 0x84, 0xa3, 0x28, 0xef, 0x8f, 0x87, 0x62, 0xec, 0x89, 0x36}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, 0xdd, + 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 22665); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\230\f\162\233\EOT\DC3\171\130\175!\217\131n\254\197\128m$;\254w\217O\ETX0\241c\223", _pubPktID = 0, _pubBody = -// ";]t:N\225`\ETX\239\239R\FS\135\144", _pubProps = [PropRequestProblemInformation -// 94,PropSubscriptionIdentifierAvailable 215,PropUserProperty "\229" -// "\246\173\&5\184\&1\a)\174\169p\228Rz\241\n}9j\215\&1\220~\187\SYN\168\149\DELe(\215",PropSubscriptionIdentifier -// 28,PropResponseTopic "Y\213\SOHf;a\135\217",PropContentType -// "\v\135\236su\221\217\202\247\152\&1?\227ycg",PropUserProperty "\DEL\200L\174_\175\242\200" "\199",PropMaximumQoS -// 242,PropReceiveMaximum 3177,PropAuthenticationMethod "\135\238",PropMessageExpiryInterval 25546]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "p\211K\218>w\SOHst%h%\249P\an\SYNF\157q=]", _pubPktID = 0, _pubBody = "\135 \184\208\200\r\GSu\205w\SOHst%h%\249P\an\SYNF\157q=]", _pubPktID = 0, _pubBody = "\135 \184\208\200\r\GSu\205(topic.data), 28); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\DEL\ETX\153\229\248dS\153`\SOH\167\230\142f\DC1\233\135#<\250\245dX!\172\177\&9,\148", _pubPktID = 23552, _pubBody -// = "\165\207\195k*4\RS", _pubProps = [PropTopicAliasMaximum 20288,PropMaximumQoS 217]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\249", _pubPktID = 7383, _pubBody = +// "\166\v\241D\ESCtx4\151\196\206=\239 r\RS\159\195\249NT_", _pubProps = [PropPayloadFormatIndicator +// 118,PropWillDelayInterval 17649,PropServerKeepAlive 8042,PropSessionExpiryInterval 18970]} TEST(Publish5QCTest, Encode22) { - uint8_t pkt[] = {0x3d, 0x2e, 0x0, 0x1d, 0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, - 0x8e, 0x66, 0x11, 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, - 0x94, 0x5c, 0x0, 0x5, 0x22, 0x4f, 0x40, 0x24, 0xd9, 0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; - uint8_t topic_bytes[] = {0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, 0x8e, 0x66, 0x11, - 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, 0x94}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x2b, 0x0, 0x1, 0xf9, 0x1c, 0xd7, 0xf, 0x1, 0x76, 0x18, 0x0, 0x0, 0x44, 0xf1, + 0x13, 0x1f, 0x6a, 0x11, 0x0, 0x0, 0x4a, 0x1a, 0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, + 0x34, 0x97, 0xc4, 0xce, 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; + uint8_t topic_bytes[] = {0xf9}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, 0x34, 0x97, 0xc4, 0xce, + 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 22; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20288}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17649}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8042}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18970}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 23552, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7383, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\DEL\ETX\153\229\248dS\153`\SOH\167\230\142f\DC1\233\135#<\250\245dX!\172\177\&9,\148", _pubPktID = 23552, _pubBody -// = "\165\207\195k*4\RS", _pubProps = [PropTopicAliasMaximum 20288,PropMaximumQoS 217]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\249", _pubPktID = 7383, _pubBody = +// "\166\v\241D\ESCtx4\151\196\206=\239 r\RS\159\195\249NT_", _pubProps = [PropPayloadFormatIndicator +// 118,PropWillDelayInterval 17649,PropServerKeepAlive 8042,PropSessionExpiryInterval 18970]} TEST(Publish5QCTest, Decode22) { - uint8_t pkt[] = {0x3d, 0x2e, 0x0, 0x1d, 0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, - 0x8e, 0x66, 0x11, 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, - 0x94, 0x5c, 0x0, 0x5, 0x22, 0x4f, 0x40, 0x24, 0xd9, 0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; + uint8_t pkt[] = {0x32, 0x2b, 0x0, 0x1, 0xf9, 0x1c, 0xd7, 0xf, 0x1, 0x76, 0x18, 0x0, 0x0, 0x44, 0xf1, + 0x13, 0x1f, 0x6a, 0x11, 0x0, 0x0, 0x4a, 0x1a, 0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, + 0x34, 0x97, 0xc4, 0xce, 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4262,149 +4027,150 @@ TEST(Publish5QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x7f, 0x3, 0x99, 0xe5, 0xf8, 0x64, 0x53, 0x99, 0x60, 0x1, 0xa7, 0xe6, 0x8e, 0x66, 0x11, - 0xe9, 0x87, 0x23, 0x3c, 0xfa, 0xf5, 0x64, 0x58, 0x21, 0xac, 0xb1, 0x39, 0x2c, 0x94}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa5, 0xcf, 0xc3, 0x6b, 0x2a, 0x34, 0x1e}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 23552); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + uint8_t exp_topic_bytes[] = {0xf9}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, 0x34, 0x97, 0xc4, 0xce, + 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7383); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163\132d\157\149", _pubPktID = -// 24502, _pubBody = "\224h\ACK", _pubProps = [PropPayloadFormatIndicator 187,PropResponseInformation -// ".*R\129t\184\132\SUB\242\DLE2\NAK,\143\210\228c\205\161\215\190\237\179?\132\234[y",PropSubscriptionIdentifierAvailable -// 240,PropAssignedClientIdentifier "o",PropWillDelayInterval 26051,PropMaximumQoS 161,PropResponseInformation -// "\190\DC3\DC2|G\249q\226\RS\234\&7\157\ETX",PropAuthenticationMethod "z\249i\131&\198\228K",PropMessageExpiryInterval -// 6283,PropResponseTopic -// "\NAK\134\DEL\151qC\134\ESC;\247\184Dviu=\191\170\145\140\248\DC1\130\191F(z\SUB",PropAuthenticationMethod "Y\\N- -// \156\253\226\133}\147",PropSubscriptionIdentifierAvailable 116,PropAuthenticationData -// "\219n\154\210\157J\152\FSy\147`\CANN\245\197#C\190\128z\239\197",PropServerKeepAlive 1560,PropPayloadFormatIndicator -// 234,PropSharedSubscriptionAvailable 60,PropUserProperty -// "\224\184V\SYN\204\172\&4p\194\161\179,\220\&2$Y\129\DC2\233X\136\&3\233" -// "\253L\236\\\187Y\242FO-7d\145",PropPayloadFormatIndicator 5,PropServerReference -// "\250\DC1MA,\252\243\147\209^[\252\249\r",PropAuthenticationData -// "{V\255|\170\183%i\135\166a\254w\169\185xh$",PropMaximumQoS 99,PropServerReference -// "\137_\191\221\195;\207.",PropReceiveMaximum 1647]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\156\249\196\168\224\205\FS\219\244\128\231\SYN\252\239j\NAK\164\171G]\133\229\147Q\199(\f\249y", _pubPktID = 11390, +// _pubBody = "s\226]\184\NUL\176A\242\&3\195\ETBC\RSN\254\t\t\\\203\255=\180B\201k\163", _pubProps = [PropResponseTopic +// "\FS,J\229`\170\204\255\133\133G\208(]+j\132\230x\244\CAN\148\143\227\151H",PropMessageExpiryInterval +// 23325,PropUserProperty "\224\150\SUB\154\&6d:y\142\239\232\RS_\181CY\184\150\254\242\226\a\"\132\159#\158Fk" +// "\ESC\180|3&\134",PropAuthenticationMethod "\230\198",PropAuthenticationData +// "\255\246\195f\b,.\176\150\222",PropResponseTopic "\182\CANu\SOH\SO\151\224@N +// \200\220\199\168S\NAKD\NAK'\DC3\fA\243\135\195\147^",PropRetainAvailable 157,PropServerReference +// "V?\225\174\237\154y9\175\195oX\212d\182\214\157\vb\239\157-p\US\155>\ACK\242",PropRequestResponseInformation +// 114,PropSubscriptionIdentifier 23,PropAssignedClientIdentifier +// "\221\200\143\NUL\229\132\232H`2O\213\DC1\SOHL\142\bz\241\138\167A",PropTopicAliasMaximum 14201,PropServerReference +// "c\146\NAK\140cS\135G\172?j\144\244\232\141g\239F\DC4\ETB#\255\r\207\&7\129N\183\143",PropAuthenticationMethod +// "R\141\240\142\180Ky",PropMaximumPacketSize 27523,PropSessionExpiryInterval 9563,PropAssignedClientIdentifier +// "V\229\STX\153\n\153\DC2\204=\DC4\147B\b\153\169\175\191CW"]} TEST(Publish5QCTest, Encode23) { - uint8_t pkt[] = {0x34, 0x8c, 0x2, 0x0, 0x5, 0xa3, 0x84, 0x64, 0x9d, 0x95, 0x5f, 0xb6, 0xfe, 0x1, 0x1, 0xbb, 0x1a, - 0x0, 0x1c, 0x2e, 0x2a, 0x52, 0x81, 0x74, 0xb8, 0x84, 0x1a, 0xf2, 0x10, 0x32, 0x15, 0x2c, 0x8f, 0xd2, - 0xe4, 0x63, 0xcd, 0xa1, 0xd7, 0xbe, 0xed, 0xb3, 0x3f, 0x84, 0xea, 0x5b, 0x79, 0x29, 0xf0, 0x12, 0x0, - 0x1, 0x6f, 0x18, 0x0, 0x0, 0x65, 0xc3, 0x24, 0xa1, 0x1a, 0x0, 0xd, 0xbe, 0x13, 0x12, 0x7c, 0x47, - 0xf9, 0x71, 0xe2, 0x1e, 0xea, 0x37, 0x9d, 0x3, 0x15, 0x0, 0x8, 0x7a, 0xf9, 0x69, 0x83, 0x26, 0xc6, - 0xe4, 0x4b, 0x2, 0x0, 0x0, 0x18, 0x8b, 0x8, 0x0, 0x1c, 0x15, 0x86, 0x7f, 0x97, 0x71, 0x43, 0x86, - 0x1b, 0x3b, 0xf7, 0xb8, 0x44, 0x76, 0x69, 0x75, 0x3d, 0xbf, 0xaa, 0x91, 0x8c, 0xf8, 0x11, 0x82, 0xbf, - 0x46, 0x28, 0x7a, 0x1a, 0x15, 0x0, 0xb, 0x59, 0x5c, 0x4e, 0x2d, 0x20, 0x9c, 0xfd, 0xe2, 0x85, 0x7d, - 0x93, 0x29, 0x74, 0x16, 0x0, 0x16, 0xdb, 0x6e, 0x9a, 0xd2, 0x9d, 0x4a, 0x98, 0x1c, 0x79, 0x93, 0x60, - 0x18, 0x4e, 0xf5, 0xc5, 0x23, 0x43, 0xbe, 0x80, 0x7a, 0xef, 0xc5, 0x13, 0x6, 0x18, 0x1, 0xea, 0x2a, - 0x3c, 0x26, 0x0, 0x17, 0xe0, 0xb8, 0x56, 0x16, 0xcc, 0xac, 0x34, 0x70, 0xc2, 0xa1, 0xb3, 0x2c, 0xdc, - 0x32, 0x24, 0x59, 0x81, 0x12, 0xe9, 0x58, 0x88, 0x33, 0xe9, 0x0, 0xd, 0xfd, 0x4c, 0xec, 0x5c, 0xbb, - 0x59, 0xf2, 0x46, 0x4f, 0x2d, 0x37, 0x64, 0x91, 0x1, 0x5, 0x1c, 0x0, 0xe, 0xfa, 0x11, 0x4d, 0x41, - 0x2c, 0xfc, 0xf3, 0x93, 0xd1, 0x5e, 0x5b, 0xfc, 0xf9, 0xd, 0x16, 0x0, 0x12, 0x7b, 0x56, 0xff, 0x7c, - 0xaa, 0xb7, 0x25, 0x69, 0x87, 0xa6, 0x61, 0xfe, 0x77, 0xa9, 0xb9, 0x78, 0x68, 0x24, 0x24, 0x63, 0x1c, - 0x0, 0x8, 0x89, 0x5f, 0xbf, 0xdd, 0xc3, 0x3b, 0xcf, 0x2e, 0x21, 0x6, 0x6f, 0xe0, 0x68, 0x6}; - uint8_t topic_bytes[] = {0xa3, 0x84, 0x64, 0x9d, 0x95}; - lwmqtt_string_t topic = {5, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x3a, 0xc2, 0x2, 0x0, 0x1d, 0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, + 0x6a, 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 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, 0x7a, 0xf1, 0x8a, 0xa7, 0x41, 0x22, 0x37, 0x79, 0x1c, 0x0, 0x1d, + 0x63, 0x92, 0x15, 0x8c, 0x63, 0x53, 0x87, 0x47, 0xac, 0x3f, 0x6a, 0x90, 0xf4, 0xe8, 0x8d, 0x67, 0xef, 0x46, 0x14, + 0x17, 0x23, 0xff, 0xd, 0xcf, 0x37, 0x81, 0x4e, 0xb7, 0x8f, 0x15, 0x0, 0x7, 0x52, 0x8d, 0xf0, 0x8e, 0xb4, 0x4b, + 0x79, 0x27, 0x0, 0x0, 0x6b, 0x83, 0x11, 0x0, 0x0, 0x25, 0x5b, 0x12, 0x0, 0x13, 0x56, 0xe5, 0x2, 0x99, 0xa, + 0x99, 0x12, 0xcc, 0x3d, 0x14, 0x93, 0x42, 0x8, 0x99, 0xa9, 0xaf, 0xbf, 0x43, 0x57, 0x73, 0xe2, 0x5d, 0xb8, 0x0, + 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, + 0x6b, 0xa3}; + uint8_t topic_bytes[] = {0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, 0x6a, + 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, 0x79}; + lwmqtt_string_t topic = {29, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xe0, 0x68, 0x6}; + uint8_t msg_bytes[] = {0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, + 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; - - uint8_t bytesprops0[] = {0x2e, 0x2a, 0x52, 0x81, 0x74, 0xb8, 0x84, 0x1a, 0xf2, 0x10, 0x32, 0x15, 0x2c, 0x8f, - 0xd2, 0xe4, 0x63, 0xcd, 0xa1, 0xd7, 0xbe, 0xed, 0xb3, 0x3f, 0x84, 0xea, 0x5b, 0x79}; - uint8_t bytesprops1[] = {0x6f}; - uint8_t bytesprops2[] = {0xbe, 0x13, 0x12, 0x7c, 0x47, 0xf9, 0x71, 0xe2, 0x1e, 0xea, 0x37, 0x9d, 0x3}; - uint8_t bytesprops3[] = {0x7a, 0xf9, 0x69, 0x83, 0x26, 0xc6, 0xe4, 0x4b}; - uint8_t bytesprops4[] = {0x15, 0x86, 0x7f, 0x97, 0x71, 0x43, 0x86, 0x1b, 0x3b, 0xf7, 0xb8, 0x44, 0x76, 0x69, - 0x75, 0x3d, 0xbf, 0xaa, 0x91, 0x8c, 0xf8, 0x11, 0x82, 0xbf, 0x46, 0x28, 0x7a, 0x1a}; - uint8_t bytesprops5[] = {0x59, 0x5c, 0x4e, 0x2d, 0x20, 0x9c, 0xfd, 0xe2, 0x85, 0x7d, 0x93}; - uint8_t bytesprops6[] = {0xdb, 0x6e, 0x9a, 0xd2, 0x9d, 0x4a, 0x98, 0x1c, 0x79, 0x93, 0x60, - 0x18, 0x4e, 0xf5, 0xc5, 0x23, 0x43, 0xbe, 0x80, 0x7a, 0xef, 0xc5}; - uint8_t bytesprops8[] = {0xfd, 0x4c, 0xec, 0x5c, 0xbb, 0x59, 0xf2, 0x46, 0x4f, 0x2d, 0x37, 0x64, 0x91}; - uint8_t bytesprops7[] = {0xe0, 0xb8, 0x56, 0x16, 0xcc, 0xac, 0x34, 0x70, 0xc2, 0xa1, 0xb3, 0x2c, - 0xdc, 0x32, 0x24, 0x59, 0x81, 0x12, 0xe9, 0x58, 0x88, 0x33, 0xe9}; - uint8_t bytesprops9[] = {0xfa, 0x11, 0x4d, 0x41, 0x2c, 0xfc, 0xf3, 0x93, 0xd1, 0x5e, 0x5b, 0xfc, 0xf9, 0xd}; - uint8_t bytesprops10[] = {0x7b, 0x56, 0xff, 0x7c, 0xaa, 0xb7, 0x25, 0x69, 0x87, - 0xa6, 0x61, 0xfe, 0x77, 0xa9, 0xb9, 0x78, 0x68, 0x24}; - uint8_t bytesprops11[] = {0x89, 0x5f, 0xbf, 0xdd, 0xc3, 0x3b, 0xcf, 0x2e}; + msg.payload_len = 26; + + uint8_t bytesprops0[] = {0x1c, 0x2c, 0x4a, 0xe5, 0x60, 0xaa, 0xcc, 0xff, 0x85, 0x85, 0x47, 0xd0, 0x28, + 0x5d, 0x2b, 0x6a, 0x84, 0xe6, 0x78, 0xf4, 0x18, 0x94, 0x8f, 0xe3, 0x97, 0x48}; + uint8_t bytesprops2[] = {0x1b, 0xb4, 0x7c, 0x33, 0x26, 0x86}; + uint8_t bytesprops1[] = {0xe0, 0x96, 0x1a, 0x9a, 0x36, 0x64, 0x3a, 0x79, 0x8e, 0xef, 0xe8, 0x1e, 0x5f, 0xb5, 0x43, + 0x59, 0xb8, 0x96, 0xfe, 0xf2, 0xe2, 0x7, 0x22, 0x84, 0x9f, 0x23, 0x9e, 0x46, 0x6b}; + uint8_t bytesprops3[] = {0xe6, 0xc6}; + uint8_t bytesprops4[] = {0xff, 0xf6, 0xc3, 0x66, 0x8, 0x2c, 0x2e, 0xb0, 0x96, 0xde}; + uint8_t bytesprops5[] = {0xb6, 0x18, 0x75, 0x1, 0xe, 0x97, 0xe0, 0x40, 0x4e, 0x20, 0xc8, 0xdc, 0xc7, 0xa8, + 0x53, 0x15, 0x44, 0x15, 0x27, 0x13, 0xc, 0x41, 0xf3, 0x87, 0xc3, 0x93, 0x5e}; + uint8_t bytesprops6[] = {0x56, 0x3f, 0xe1, 0xae, 0xed, 0x9a, 0x79, 0x39, 0xaf, 0xc3, 0x6f, 0x58, 0xd4, 0x64, + 0xb6, 0xd6, 0x9d, 0xb, 0x62, 0xef, 0x9d, 0x2d, 0x70, 0x1f, 0x9b, 0x3e, 0x6, 0xf2}; + uint8_t bytesprops7[] = {0xdd, 0xc8, 0x8f, 0x0, 0xe5, 0x84, 0xe8, 0x48, 0x60, 0x32, 0x4f, + 0xd5, 0x11, 0x1, 0x4c, 0x8e, 0x8, 0x7a, 0xf1, 0x8a, 0xa7, 0x41}; + uint8_t bytesprops8[] = {0x63, 0x92, 0x15, 0x8c, 0x63, 0x53, 0x87, 0x47, 0xac, 0x3f, 0x6a, 0x90, 0xf4, 0xe8, 0x8d, + 0x67, 0xef, 0x46, 0x14, 0x17, 0x23, 0xff, 0xd, 0xcf, 0x37, 0x81, 0x4e, 0xb7, 0x8f}; + uint8_t bytesprops9[] = {0x52, 0x8d, 0xf0, 0x8e, 0xb4, 0x4b, 0x79}; + uint8_t bytesprops10[] = {0x56, 0xe5, 0x2, 0x99, 0xa, 0x99, 0x12, 0xcc, 0x3d, 0x14, + 0x93, 0x42, 0x8, 0x99, 0xa9, 0xaf, 0xbf, 0x43, 0x57}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26051}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6283}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1560}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops7}, .v = {13, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1647}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23325}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14201}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27523}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9563}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 24502, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 11390, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\163\132d\157\149", _pubPktID = -// 24502, _pubBody = "\224h\ACK", _pubProps = [PropPayloadFormatIndicator 187,PropResponseInformation -// ".*R\129t\184\132\SUB\242\DLE2\NAK,\143\210\228c\205\161\215\190\237\179?\132\234[y",PropSubscriptionIdentifierAvailable -// 240,PropAssignedClientIdentifier "o",PropWillDelayInterval 26051,PropMaximumQoS 161,PropResponseInformation -// "\190\DC3\DC2|G\249q\226\RS\234\&7\157\ETX",PropAuthenticationMethod "z\249i\131&\198\228K",PropMessageExpiryInterval -// 6283,PropResponseTopic -// "\NAK\134\DEL\151qC\134\ESC;\247\184Dviu=\191\170\145\140\248\DC1\130\191F(z\SUB",PropAuthenticationMethod "Y\\N- -// \156\253\226\133}\147",PropSubscriptionIdentifierAvailable 116,PropAuthenticationData -// "\219n\154\210\157J\152\FSy\147`\CANN\245\197#C\190\128z\239\197",PropServerKeepAlive 1560,PropPayloadFormatIndicator -// 234,PropSharedSubscriptionAvailable 60,PropUserProperty -// "\224\184V\SYN\204\172\&4p\194\161\179,\220\&2$Y\129\DC2\233X\136\&3\233" -// "\253L\236\\\187Y\242FO-7d\145",PropPayloadFormatIndicator 5,PropServerReference -// "\250\DC1MA,\252\243\147\209^[\252\249\r",PropAuthenticationData -// "{V\255|\170\183%i\135\166a\254w\169\185xh$",PropMaximumQoS 99,PropServerReference -// "\137_\191\221\195;\207.",PropReceiveMaximum 1647]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\156\249\196\168\224\205\FS\219\244\128\231\SYN\252\239j\NAK\164\171G]\133\229\147Q\199(\f\249y", _pubPktID = 11390, +// _pubBody = "s\226]\184\NUL\176A\242\&3\195\ETBC\RSN\254\t\t\\\203\255=\180B\201k\163", _pubProps = [PropResponseTopic +// "\FS,J\229`\170\204\255\133\133G\208(]+j\132\230x\244\CAN\148\143\227\151H",PropMessageExpiryInterval +// 23325,PropUserProperty "\224\150\SUB\154\&6d:y\142\239\232\RS_\181CY\184\150\254\242\226\a\"\132\159#\158Fk" +// "\ESC\180|3&\134",PropAuthenticationMethod "\230\198",PropAuthenticationData +// "\255\246\195f\b,.\176\150\222",PropResponseTopic "\182\CANu\SOH\SO\151\224@N +// \200\220\199\168S\NAKD\NAK'\DC3\fA\243\135\195\147^",PropRetainAvailable 157,PropServerReference +// "V?\225\174\237\154y9\175\195oX\212d\182\214\157\vb\239\157-p\US\155>\ACK\242",PropRequestResponseInformation +// 114,PropSubscriptionIdentifier 23,PropAssignedClientIdentifier +// "\221\200\143\NUL\229\132\232H`2O\213\DC1\SOHL\142\bz\241\138\167A",PropTopicAliasMaximum 14201,PropServerReference +// "c\146\NAK\140cS\135G\172?j\144\244\232\141g\239F\DC4\ETB#\255\r\207\&7\129N\183\143",PropAuthenticationMethod +// "R\141\240\142\180Ky",PropMaximumPacketSize 27523,PropSessionExpiryInterval 9563,PropAssignedClientIdentifier +// "V\229\STX\153\n\153\DC2\204=\DC4\147B\b\153\169\175\191CW"]} TEST(Publish5QCTest, Decode23) { - uint8_t pkt[] = {0x34, 0x8c, 0x2, 0x0, 0x5, 0xa3, 0x84, 0x64, 0x9d, 0x95, 0x5f, 0xb6, 0xfe, 0x1, 0x1, 0xbb, 0x1a, - 0x0, 0x1c, 0x2e, 0x2a, 0x52, 0x81, 0x74, 0xb8, 0x84, 0x1a, 0xf2, 0x10, 0x32, 0x15, 0x2c, 0x8f, 0xd2, - 0xe4, 0x63, 0xcd, 0xa1, 0xd7, 0xbe, 0xed, 0xb3, 0x3f, 0x84, 0xea, 0x5b, 0x79, 0x29, 0xf0, 0x12, 0x0, - 0x1, 0x6f, 0x18, 0x0, 0x0, 0x65, 0xc3, 0x24, 0xa1, 0x1a, 0x0, 0xd, 0xbe, 0x13, 0x12, 0x7c, 0x47, - 0xf9, 0x71, 0xe2, 0x1e, 0xea, 0x37, 0x9d, 0x3, 0x15, 0x0, 0x8, 0x7a, 0xf9, 0x69, 0x83, 0x26, 0xc6, - 0xe4, 0x4b, 0x2, 0x0, 0x0, 0x18, 0x8b, 0x8, 0x0, 0x1c, 0x15, 0x86, 0x7f, 0x97, 0x71, 0x43, 0x86, - 0x1b, 0x3b, 0xf7, 0xb8, 0x44, 0x76, 0x69, 0x75, 0x3d, 0xbf, 0xaa, 0x91, 0x8c, 0xf8, 0x11, 0x82, 0xbf, - 0x46, 0x28, 0x7a, 0x1a, 0x15, 0x0, 0xb, 0x59, 0x5c, 0x4e, 0x2d, 0x20, 0x9c, 0xfd, 0xe2, 0x85, 0x7d, - 0x93, 0x29, 0x74, 0x16, 0x0, 0x16, 0xdb, 0x6e, 0x9a, 0xd2, 0x9d, 0x4a, 0x98, 0x1c, 0x79, 0x93, 0x60, - 0x18, 0x4e, 0xf5, 0xc5, 0x23, 0x43, 0xbe, 0x80, 0x7a, 0xef, 0xc5, 0x13, 0x6, 0x18, 0x1, 0xea, 0x2a, - 0x3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 0x0, 0x0, 0x6b, 0x83, 0x11, 0x0, 0x0, 0x25, 0x5b, 0x12, 0x0, 0x13, 0x56, 0xe5, 0x2, 0x99, 0xa, + 0x99, 0x12, 0xcc, 0x3d, 0x14, 0x93, 0x42, 0x8, 0x99, 0xa9, 0xaf, 0xbf, 0x43, 0x57, 0x73, 0xe2, 0x5d, 0xb8, 0x0, + 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, + 0x6b, 0xa3}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4413,67 +4179,94 @@ TEST(Publish5QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa3, 0x84, 0x64, 0x9d, 0x95}; - lwmqtt_string_t exp_topic = {5, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xe0, 0x68, 0x6}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, 0x6a, + 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, 0x79}; + lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, + 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 24502); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 5); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_EQ(packet_id, 11390); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\153\164\218\195=\160\170\223\157 -// b%X\222\199hG0\198K3y\207\128J\188\176\225", _pubPktID = 0, _pubBody = "\SOH\191\156", _pubProps = -// [PropServerKeepAlive 29860,PropAuthenticationMethod -// "\246\EOT\240\184\137\197\234\173b<\139\208",PropSubscriptionIdentifierAvailable 117]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\247\&51\173<\172\250\229U\SOH\214a\211n>\225\&2^", _pubPktID = 0, _pubBody = +// "\r\136\219Jg\197\169\234\190\251\255K\212\139c\186,\229", _pubProps = [PropAuthenticationMethod +// "\160\209\234jK\216\216:)\166\146\205\&8\249\CAN\191E\188\ESC",PropWillDelayInterval 18526,PropMaximumQoS +// 140,PropAssignedClientIdentifier "\GSd\199\233",PropServerReference +// "\249\DC2e^I\139\STX\232\195\NUL\ACK\233Z\214\206\STX\180\191&\t\DC1\249\154\158\\\NUL\EM",PropWillDelayInterval +// 6427,PropServerReference "b\SI_\254",PropRequestProblemInformation 249]} TEST(Publish5QCTest, Encode24) { - uint8_t pkt[] = {0x38, 0x36, 0x0, 0x1c, 0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, - 0x62, 0x25, 0x58, 0xde, 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, - 0x4a, 0xbc, 0xb0, 0xe1, 0x14, 0x13, 0x74, 0xa4, 0x15, 0x0, 0xc, 0xf6, 0x4, 0xf0, - 0xb8, 0x89, 0xc5, 0xea, 0xad, 0x62, 0x3c, 0x8b, 0xd0, 0x29, 0x75, 0x1, 0xbf, 0x9c}; - uint8_t topic_bytes[] = {0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, - 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x77, 0x0, 0x12, 0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, 0x1, 0xd6, 0x61, + 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e, 0x50, 0x15, 0x0, 0x13, 0xa0, 0xd1, 0xea, 0x6a, 0x4b, 0xd8, + 0xd8, 0x3a, 0x29, 0xa6, 0x92, 0xcd, 0x38, 0xf9, 0x18, 0xbf, 0x45, 0xbc, 0x1b, 0x18, 0x0, 0x0, + 0x48, 0x5e, 0x24, 0x8c, 0x12, 0x0, 0x4, 0x1d, 0x64, 0xc7, 0xe9, 0x1c, 0x0, 0x1b, 0xf9, 0x12, + 0x65, 0x5e, 0x49, 0x8b, 0x2, 0xe8, 0xc3, 0x0, 0x6, 0xe9, 0x5a, 0xd6, 0xce, 0x2, 0xb4, 0xbf, + 0x26, 0x9, 0x11, 0xf9, 0x9a, 0x9e, 0x5c, 0x0, 0x19, 0x18, 0x0, 0x0, 0x19, 0x1b, 0x1c, 0x0, + 0x4, 0x62, 0xf, 0x5f, 0xfe, 0x17, 0xf9, 0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, 0xa9, 0xea, 0xbe, + 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; + uint8_t topic_bytes[] = {0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, + 0x1, 0xd6, 0x61, 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; msg.retained = false; - uint8_t msg_bytes[] = {0x1, 0xbf, 0x9c}; + uint8_t msg_bytes[] = {0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, 0xa9, 0xea, 0xbe, + 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 18; - uint8_t bytesprops0[] = {0xf6, 0x4, 0xf0, 0xb8, 0x89, 0xc5, 0xea, 0xad, 0x62, 0x3c, 0x8b, 0xd0}; + uint8_t bytesprops0[] = {0xa0, 0xd1, 0xea, 0x6a, 0x4b, 0xd8, 0xd8, 0x3a, 0x29, 0xa6, + 0x92, 0xcd, 0x38, 0xf9, 0x18, 0xbf, 0x45, 0xbc, 0x1b}; + uint8_t bytesprops1[] = {0x1d, 0x64, 0xc7, 0xe9}; + uint8_t bytesprops2[] = {0xf9, 0x12, 0x65, 0x5e, 0x49, 0x8b, 0x2, 0xe8, 0xc3, 0x0, 0x6, 0xe9, 0x5a, 0xd6, + 0xce, 0x2, 0xb4, 0xbf, 0x26, 0x9, 0x11, 0xf9, 0x9a, 0x9e, 0x5c, 0x0, 0x19}; + uint8_t bytesprops3[] = {0x62, 0xf, 0x5f, 0xfe}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29860}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18526}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6427}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 249}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\153\164\218\195=\160\170\223\157 -// b%X\222\199hG0\198K3y\207\128J\188\176\225", _pubPktID = 0, _pubBody = "\SOH\191\156", _pubProps = -// [PropServerKeepAlive 29860,PropAuthenticationMethod -// "\246\EOT\240\184\137\197\234\173b<\139\208",PropSubscriptionIdentifierAvailable 117]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\247\&51\173<\172\250\229U\SOH\214a\211n>\225\&2^", _pubPktID = 0, _pubBody = +// "\r\136\219Jg\197\169\234\190\251\255K\212\139c\186,\229", _pubProps = [PropAuthenticationMethod +// "\160\209\234jK\216\216:)\166\146\205\&8\249\CAN\191E\188\ESC",PropWillDelayInterval 18526,PropMaximumQoS +// 140,PropAssignedClientIdentifier "\GSd\199\233",PropServerReference +// "\249\DC2e^I\139\STX\232\195\NUL\ACK\233Z\214\206\STX\180\191&\t\DC1\249\154\158\\\NUL\EM",PropWillDelayInterval +// 6427,PropServerReference "b\SI_\254",PropRequestProblemInformation 249]} TEST(Publish5QCTest, Decode24) { - uint8_t pkt[] = {0x38, 0x36, 0x0, 0x1c, 0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, - 0x62, 0x25, 0x58, 0xde, 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, - 0x4a, 0xbc, 0xb0, 0xe1, 0x14, 0x13, 0x74, 0xa4, 0x15, 0x0, 0xc, 0xf6, 0x4, 0xf0, - 0xb8, 0x89, 0xc5, 0xea, 0xad, 0x62, 0x3c, 0x8b, 0xd0, 0x29, 0x75, 0x1, 0xbf, 0x9c}; + uint8_t pkt[] = {0x30, 0x77, 0x0, 0x12, 0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, 0x1, 0xd6, 0x61, + 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e, 0x50, 0x15, 0x0, 0x13, 0xa0, 0xd1, 0xea, 0x6a, 0x4b, 0xd8, + 0xd8, 0x3a, 0x29, 0xa6, 0x92, 0xcd, 0x38, 0xf9, 0x18, 0xbf, 0x45, 0xbc, 0x1b, 0x18, 0x0, 0x0, + 0x48, 0x5e, 0x24, 0x8c, 0x12, 0x0, 0x4, 0x1d, 0x64, 0xc7, 0xe9, 0x1c, 0x0, 0x1b, 0xf9, 0x12, + 0x65, 0x5e, 0x49, 0x8b, 0x2, 0xe8, 0xc3, 0x0, 0x6, 0xe9, 0x5a, 0xd6, 0xce, 0x2, 0xb4, 0xbf, + 0x26, 0x9, 0x11, 0xf9, 0x9a, 0x9e, 0x5c, 0x0, 0x19, 0x18, 0x0, 0x0, 0x19, 0x1b, 0x1c, 0x0, + 0x4, 0x62, 0xf, 0x5f, 0xfe, 0x17, 0xf9, 0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, 0xa9, 0xea, 0xbe, + 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4482,89 +4275,132 @@ TEST(Publish5QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x99, 0xa4, 0xda, 0xc3, 0x3d, 0xa0, 0xaa, 0xdf, 0x9d, 0x20, 0x62, 0x25, 0x58, 0xde, - 0xc7, 0x68, 0x47, 0x30, 0xc6, 0x4b, 0x33, 0x79, 0xcf, 0x80, 0x4a, 0xbc, 0xb0, 0xe1}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1, 0xbf, 0x9c}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, + 0x1, 0xd6, 0x61, 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, 0xa9, 0xea, 0xbe, + 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "Z\162]m\132\183R\SUBWRu", _pubPktID -// = 13838, _pubBody = -// "{&\208\GS\139\141\&9\162*\207\153\136\148\172\STX\190\162e\RS\\\163\194\141\DC1\SYN\156\204\236", _pubProps = -// [PropMaximumQoS 172,PropCorrelationData "(",PropMessageExpiryInterval 4898,PropPayloadFormatIndicator -// 242,PropSubscriptionIdentifierAvailable 76,PropResponseInformation -// "S\154\150\166\EOT\224\208\&9\NUL\190\210]6\179\219\166\173x*",PropAuthenticationData -// "\146X\192<|\200\215\DC1\204\206\a\205,\164\ETB\SI\226;c\ETB4",PropWildcardSubscriptionAvailable 121]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\DC3 +// \244\212\ETX\143\186\222G-\212", _pubPktID = 0, _pubBody = "cndv<\250\182\170?\140\SYN\204\158n'\161tLKL\DC4\131", +// _pubProps = [PropPayloadFormatIndicator 90,PropMessageExpiryInterval 11159,PropSessionExpiryInterval +// 2113,PropAuthenticationMethod "\128\249OaH;\232",PropTopicAliasMaximum 15946,PropAuthenticationData +// "\168\187\142\SO\157\223\&5\t\242g\246\141\t\FS\237\217\EM\DLE\203L\134\175\189<(#\DC2",PropMessageExpiryInterval +// 27559,PropWildcardSubscriptionAvailable 13,PropSubscriptionIdentifierAvailable 37,PropResponseTopic +// "\147\215\NAK\\\NUL\181\ETBQ\254\200\135\US\250\229\EOTI\149(topic.data), 11); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\245\STX\252\CAN\215\187\FS^!\141\191\250|\190\164I\153\169,U`", _pubPktID = 10215, _pubBody = -// "\199r\153\234\&0UY.\201J\198\SO", _pubProps = [PropWildcardSubscriptionAvailable 107,PropMaximumPacketSize -// 1844,PropContentType "\US\202C\131\167o",PropResponseTopic "",PropSubscriptionIdentifierAvailable -// 105,PropSubscriptionIdentifierAvailable 186,PropReasonString "Ry\SUB\\",PropTopicAlias 32557,PropMaximumQoS -// 23,PropRequestProblemInformation 72,PropSessionExpiryInterval 30830,PropTopicAlias 29267,PropTopicAlias -// 1624,PropReceiveMaximum 23007,PropRetainAvailable 148]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "o#L\177\210\EOT\140\230w\252ir\220-\217\230\154\182\a0(\169\225\232uo", _pubPktID = 0, _pubBody = +// "2\137\n\NUL\201\149\252e\191]\CAN#`\250", _pubProps = [PropSubscriptionIdentifierAvailable +// 236,PropAssignedClientIdentifier "\152\SOHt\252\165",PropTopicAliasMaximum 13490,PropWillDelayInterval +// 22209,PropPayloadFormatIndicator 60,PropTopicAlias 16841,PropRetainAvailable 107,PropResponseTopic +// "ah\ETB\139iQ\b\n\164\233Q\132g\GSU\160\212\b\191K\211\157\200\165",PropMessageExpiryInterval +// 1549,PropAuthenticationMethod "\229\224\206\vA\237\182\FS![1=U\218,V>\ETX\210p3",PropSharedSubscriptionAvailable +// 99,PropAuthenticationData "o\213\198\161'A?P\ENQ'\144\235qY\144\192\210\156\214\200*M",PropRetainAvailable +// 220,PropServerKeepAlive 26426,PropAuthenticationData +// "\212O\226\198\214\236\150D_\DC2\135",PropRequestProblemInformation 170,PropTopicAliasMaximum +// 10106,PropResponseInformation +// "\ESCu\152M\180V\202\DLE\220&`\244\RS\234\&5X\137\237\DC1\230\210\208u\RS\180\ETB",PropContentType +// "",PropAuthenticationData +// "R\178\230b\169\192\188\232\161\168\230K\SOMj>|s@b\140\243\197\246\t\156\b^",PropSubscriptionIdentifier +// 12,PropSessionExpiryInterval 28419,PropSharedSubscriptionAvailable 28,PropMaximumPacketSize 19043,PropServerKeepAlive +// 19008,PropRetainAvailable 208,PropUserProperty "\195\DEL\252}\STX.\234\130\189\255:)\SO\136x\143\133\129" +// "\159\161:z\170\255\DC3\230\249\ETBZ\204}\178T\190\222\198\DEL\181\150\245\253\f\255#\218\t*M"]} TEST(Publish5QCTest, Encode26) { - uint8_t pkt[] = {0x33, 0x5b, 0x0, 0x15, 0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, 0xfa, - 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60, 0x27, 0xe7, 0x35, 0x28, 0x6b, 0x27, 0x0, - 0x0, 0x7, 0x34, 0x3, 0x0, 0x6, 0x1f, 0xca, 0x43, 0x83, 0xa7, 0x6f, 0x8, 0x0, 0x0, 0x29, - 0x69, 0x29, 0xba, 0x1f, 0x0, 0x4, 0x52, 0x79, 0x1a, 0x5c, 0x23, 0x7f, 0x2d, 0x24, 0x17, 0x17, - 0x48, 0x11, 0x0, 0x0, 0x78, 0x6e, 0x23, 0x72, 0x53, 0x23, 0x6, 0x58, 0x21, 0x59, 0xdf, 0x25, - 0x94, 0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; - uint8_t topic_bytes[] = {0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, - 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x31, 0xb7, 0x2, 0x0, 0x1a, 0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, 0x2d, + 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f, 0x8b, 0x2, 0x29, 0xec, 0x12, 0x0, 0x5, + 0x98, 0x1, 0x74, 0xfc, 0xa5, 0x22, 0x34, 0xb2, 0x18, 0x0, 0x0, 0x56, 0xc1, 0x1, 0x3c, 0x23, 0x41, 0xc9, 0x25, + 0x6b, 0x8, 0x0, 0x18, 0x61, 0x68, 0x17, 0x8b, 0x69, 0x51, 0x8, 0xa, 0xa4, 0xe9, 0x51, 0x84, 0x67, 0x1d, 0x55, + 0xa0, 0xd4, 0x8, 0xbf, 0x4b, 0xd3, 0x9d, 0xc8, 0xa5, 0x2, 0x0, 0x0, 0x6, 0xd, 0x15, 0x0, 0x15, 0xe5, 0xe0, + 0xce, 0xb, 0x41, 0xed, 0xb6, 0x1c, 0x21, 0x5b, 0x31, 0x3d, 0x55, 0xda, 0x2c, 0x56, 0x3e, 0x3, 0xd2, 0x70, 0x33, + 0x2a, 0x63, 0x16, 0x0, 0x16, 0x6f, 0xd5, 0xc6, 0xa1, 0x27, 0x41, 0x3f, 0x50, 0x5, 0x27, 0x90, 0xeb, 0x71, 0x59, + 0x90, 0xc0, 0xd2, 0x9c, 0xd6, 0xc8, 0x2a, 0x4d, 0x25, 0xdc, 0x13, 0x67, 0x3a, 0x16, 0x0, 0xb, 0xd4, 0x4f, 0xe2, + 0xc6, 0xd6, 0xec, 0x96, 0x44, 0x5f, 0x12, 0x87, 0x17, 0xaa, 0x22, 0x27, 0x7a, 0x1a, 0x0, 0x1a, 0x1b, 0x75, 0x98, + 0x4d, 0xb4, 0x56, 0xca, 0x10, 0xdc, 0x26, 0x60, 0xf4, 0x1e, 0xea, 0x35, 0x58, 0x89, 0xed, 0x11, 0xe6, 0xd2, 0xd0, + 0x75, 0x1e, 0xb4, 0x17, 0x3, 0x0, 0x0, 0x16, 0x0, 0x1c, 0x52, 0xb2, 0xe6, 0x62, 0xa9, 0xc0, 0xbc, 0xe8, 0xa1, + 0xa8, 0xe6, 0x4b, 0xe, 0x4d, 0x6a, 0x3e, 0x7c, 0x73, 0x40, 0x62, 0x8c, 0xf3, 0xc5, 0xf6, 0x9, 0x9c, 0x8, 0x5e, + 0xb, 0xc, 0x11, 0x0, 0x0, 0x6f, 0x3, 0x2a, 0x1c, 0x27, 0x0, 0x0, 0x4a, 0x63, 0x13, 0x4a, 0x40, 0x25, 0xd0, + 0x26, 0x0, 0x12, 0xc3, 0x7f, 0xfc, 0x7d, 0x2, 0x2e, 0xea, 0x82, 0xbd, 0xff, 0x3a, 0x29, 0xe, 0x88, 0x78, 0x8f, + 0x85, 0x81, 0x0, 0x1e, 0x9f, 0xa1, 0x3a, 0x7a, 0xaa, 0xff, 0x13, 0xe6, 0xf9, 0x17, 0x5a, 0xcc, 0x7d, 0xb2, 0x54, + 0xbe, 0xde, 0xc6, 0x7f, 0xb5, 0x96, 0xf5, 0xfd, 0xc, 0xff, 0x23, 0xda, 0x9, 0x2a, 0x4d, 0x32, 0x89, 0xa, 0x0, + 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; + uint8_t topic_bytes[] = {0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, + 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f}; + lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; + uint8_t msg_bytes[] = {0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 14; - uint8_t bytesprops0[] = {0x1f, 0xca, 0x43, 0x83, 0xa7, 0x6f}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x52, 0x79, 0x1a, 0x5c}; + uint8_t bytesprops0[] = {0x98, 0x1, 0x74, 0xfc, 0xa5}; + uint8_t bytesprops1[] = {0x61, 0x68, 0x17, 0x8b, 0x69, 0x51, 0x8, 0xa, 0xa4, 0xe9, 0x51, 0x84, + 0x67, 0x1d, 0x55, 0xa0, 0xd4, 0x8, 0xbf, 0x4b, 0xd3, 0x9d, 0xc8, 0xa5}; + uint8_t bytesprops2[] = {0xe5, 0xe0, 0xce, 0xb, 0x41, 0xed, 0xb6, 0x1c, 0x21, 0x5b, 0x31, + 0x3d, 0x55, 0xda, 0x2c, 0x56, 0x3e, 0x3, 0xd2, 0x70, 0x33}; + uint8_t bytesprops3[] = {0x6f, 0xd5, 0xc6, 0xa1, 0x27, 0x41, 0x3f, 0x50, 0x5, 0x27, 0x90, + 0xeb, 0x71, 0x59, 0x90, 0xc0, 0xd2, 0x9c, 0xd6, 0xc8, 0x2a, 0x4d}; + uint8_t bytesprops4[] = {0xd4, 0x4f, 0xe2, 0xc6, 0xd6, 0xec, 0x96, 0x44, 0x5f, 0x12, 0x87}; + uint8_t bytesprops5[] = {0x1b, 0x75, 0x98, 0x4d, 0xb4, 0x56, 0xca, 0x10, 0xdc, 0x26, 0x60, 0xf4, 0x1e, + 0xea, 0x35, 0x58, 0x89, 0xed, 0x11, 0xe6, 0xd2, 0xd0, 0x75, 0x1e, 0xb4, 0x17}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops7[] = {0x52, 0xb2, 0xe6, 0x62, 0xa9, 0xc0, 0xbc, 0xe8, 0xa1, 0xa8, 0xe6, 0x4b, 0xe, 0x4d, + 0x6a, 0x3e, 0x7c, 0x73, 0x40, 0x62, 0x8c, 0xf3, 0xc5, 0xf6, 0x9, 0x9c, 0x8, 0x5e}; + uint8_t bytesprops9[] = {0x9f, 0xa1, 0x3a, 0x7a, 0xaa, 0xff, 0x13, 0xe6, 0xf9, 0x17, 0x5a, 0xcc, 0x7d, 0xb2, 0x54, + 0xbe, 0xde, 0xc6, 0x7f, 0xb5, 0x96, 0xf5, 0xfd, 0xc, 0xff, 0x23, 0xda, 0x9, 0x2a, 0x4d}; + uint8_t bytesprops8[] = {0xc3, 0x7f, 0xfc, 0x7d, 0x2, 0x2e, 0xea, 0x82, 0xbd, + 0xff, 0x3a, 0x29, 0xe, 0x88, 0x78, 0x8f, 0x85, 0x81}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1844}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32557}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30830}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29267}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1624}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23007}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13490}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22209}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16841}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1549}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26426}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10106}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28419}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19043}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19008}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops8}, .v = {30, (char*)&bytesprops9}}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10215, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\245\STX\252\CAN\215\187\FS^!\141\191\250|\190\164I\153\169,U`", _pubPktID = 10215, _pubBody = -// "\199r\153\234\&0UY.\201J\198\SO", _pubProps = [PropWildcardSubscriptionAvailable 107,PropMaximumPacketSize -// 1844,PropContentType "\US\202C\131\167o",PropResponseTopic "",PropSubscriptionIdentifierAvailable -// 105,PropSubscriptionIdentifierAvailable 186,PropReasonString "Ry\SUB\\",PropTopicAlias 32557,PropMaximumQoS -// 23,PropRequestProblemInformation 72,PropSessionExpiryInterval 30830,PropTopicAlias 29267,PropTopicAlias -// 1624,PropReceiveMaximum 23007,PropRetainAvailable 148]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "o#L\177\210\EOT\140\230w\252ir\220-\217\230\154\182\a0(\169\225\232uo", _pubPktID = 0, _pubBody = +// "2\137\n\NUL\201\149\252e\191]\CAN#`\250", _pubProps = [PropSubscriptionIdentifierAvailable +// 236,PropAssignedClientIdentifier "\152\SOHt\252\165",PropTopicAliasMaximum 13490,PropWillDelayInterval +// 22209,PropPayloadFormatIndicator 60,PropTopicAlias 16841,PropRetainAvailable 107,PropResponseTopic +// "ah\ETB\139iQ\b\n\164\233Q\132g\GSU\160\212\b\191K\211\157\200\165",PropMessageExpiryInterval +// 1549,PropAuthenticationMethod "\229\224\206\vA\237\182\FS![1=U\218,V>\ETX\210p3",PropSharedSubscriptionAvailable +// 99,PropAuthenticationData "o\213\198\161'A?P\ENQ'\144\235qY\144\192\210\156\214\200*M",PropRetainAvailable +// 220,PropServerKeepAlive 26426,PropAuthenticationData +// "\212O\226\198\214\236\150D_\DC2\135",PropRequestProblemInformation 170,PropTopicAliasMaximum +// 10106,PropResponseInformation +// "\ESCu\152M\180V\202\DLE\220&`\244\RS\234\&5X\137\237\DC1\230\210\208u\RS\180\ETB",PropContentType +// "",PropAuthenticationData +// "R\178\230b\169\192\188\232\161\168\230K\SOMj>|s@b\140\243\197\246\t\156\b^",PropSubscriptionIdentifier +// 12,PropSessionExpiryInterval 28419,PropSharedSubscriptionAvailable 28,PropMaximumPacketSize 19043,PropServerKeepAlive +// 19008,PropRetainAvailable 208,PropUserProperty "\195\DEL\252}\STX.\234\130\189\255:)\SO\136x\143\133\129" +// "\159\161:z\170\255\DC3\230\249\ETBZ\204}\178T\190\222\198\DEL\181\150\245\253\f\255#\218\t*M"]} TEST(Publish5QCTest, Decode26) { - uint8_t pkt[] = {0x33, 0x5b, 0x0, 0x15, 0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, 0xfa, - 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60, 0x27, 0xe7, 0x35, 0x28, 0x6b, 0x27, 0x0, - 0x0, 0x7, 0x34, 0x3, 0x0, 0x6, 0x1f, 0xca, 0x43, 0x83, 0xa7, 0x6f, 0x8, 0x0, 0x0, 0x29, - 0x69, 0x29, 0xba, 0x1f, 0x0, 0x4, 0x52, 0x79, 0x1a, 0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d4, 0x4f, 0xe2, + 0xc6, 0xd6, 0xec, 0x96, 0x44, 0x5f, 0x12, 0x87, 0x17, 0xaa, 0x22, 0x27, 0x7a, 0x1a, 0x0, 0x1a, 0x1b, 0x75, 0x98, + 0x4d, 0xb4, 0x56, 0xca, 0x10, 0xdc, 0x26, 0x60, 0xf4, 0x1e, 0xea, 0x35, 0x58, 0x89, 0xed, 0x11, 0xe6, 0xd2, 0xd0, + 0x75, 0x1e, 0xb4, 0x17, 0x3, 0x0, 0x0, 0x16, 0x0, 0x1c, 0x52, 0xb2, 0xe6, 0x62, 0xa9, 0xc0, 0xbc, 0xe8, 0xa1, + 0xa8, 0xe6, 0x4b, 0xe, 0x4d, 0x6a, 0x3e, 0x7c, 0x73, 0x40, 0x62, 0x8c, 0xf3, 0xc5, 0xf6, 0x9, 0x9c, 0x8, 0x5e, + 0xb, 0xc, 0x11, 0x0, 0x0, 0x6f, 0x3, 0x2a, 0x1c, 0x27, 0x0, 0x0, 0x4a, 0x63, 0x13, 0x4a, 0x40, 0x25, 0xd0, + 0x26, 0x0, 0x12, 0xc3, 0x7f, 0xfc, 0x7d, 0x2, 0x2e, 0xea, 0x82, 0xbd, 0xff, 0x3a, 0x29, 0xe, 0x88, 0x78, 0x8f, + 0x85, 0x81, 0x0, 0x1e, 0x9f, 0xa1, 0x3a, 0x7a, 0xaa, 0xff, 0x13, 0xe6, 0xf9, 0x17, 0x5a, 0xcc, 0x7d, 0xb2, 0x54, + 0xbe, 0xde, 0xc6, 0x7f, 0xb5, 0x96, 0xf5, 0xfd, 0xc, 0xff, 0x23, 0xda, 0x9, 0x2a, 0x4d, 0x32, 0x89, 0xa, 0x0, + 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4667,66 +4573,104 @@ TEST(Publish5QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf5, 0x2, 0xfc, 0x18, 0xd7, 0xbb, 0x1c, 0x5e, 0x21, 0x8d, 0xbf, - 0xfa, 0x7c, 0xbe, 0xa4, 0x49, 0x99, 0xa9, 0x2c, 0x55, 0x60}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xc7, 0x72, 0x99, 0xea, 0x30, 0x55, 0x59, 0x2e, 0xc9, 0x4a, 0xc6, 0xe}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, + 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f}; + lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; + lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 10215); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); + EXPECT_EQ(msg.payload_len, 14); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\187\192\216\&6]J\244\v\252\&6\149\EOT\128\ETX", _pubPktID = 11476, _pubBody = -// "\254&\138\150\179\238u\252\176\246'\140\196", _pubProps = [PropServerReference -// "\158s\136m\193\205\148G\247g\SI\GS\NAK\188\135\r"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O\216\186", _pubPktID = 31863, +// _pubBody = "\206\US\183\184\207\198X\216\SOn\202 \214", _pubProps = [PropServerKeepAlive +// 3457,PropAssignedClientIdentifier "y",PropCorrelationData "\RS\202\193",PropMaximumQoS 253,PropUserProperty +// "n\150\v\139\139\166K\163lr$-#\CANEK\243(;\253" "\164N\244\218LO#\214\vfMF\176\136\FS\138",PropPayloadFormatIndicator +// 113,PropMessageExpiryInterval 28096,PropServerReference +// "d\172q\231\174\232v\SYN\ACK\213\189,=\132\DC2\144\235z\t%\DEL\227\230\147\&9\198;",PropWildcardSubscriptionAvailable +// 100,PropRequestProblemInformation 159,PropTopicAlias 29659,PropResponseTopic "\ENQt\165[",PropReceiveMaximum +// 23882,PropWildcardSubscriptionAvailable 19]} TEST(Publish5QCTest, Encode27) { - uint8_t pkt[] = {0x3a, 0x33, 0x0, 0xe, 0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, - 0x95, 0x4, 0x80, 0x3, 0x2c, 0xd4, 0x13, 0x1c, 0x0, 0x10, 0x9e, 0x73, 0x88, 0x6d, - 0xc1, 0xcd, 0x94, 0x47, 0xf7, 0x67, 0xf, 0x1d, 0x15, 0xbc, 0x87, 0xd, 0xfe, 0x26, - 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; - uint8_t topic_bytes[] = {0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, 0x3}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x85, 0x1, 0x0, 0x3, 0x4f, 0xd8, 0xba, 0x7c, 0x77, 0x70, 0x13, 0xd, 0x81, 0x12, 0x0, + 0x1, 0x79, 0x9, 0x0, 0x3, 0x1e, 0xca, 0xc1, 0x24, 0xfd, 0x26, 0x0, 0x14, 0x6e, 0x96, 0xb, + 0x8b, 0x8b, 0xa6, 0x4b, 0xa3, 0x6c, 0x72, 0x24, 0x2d, 0x23, 0x18, 0x45, 0x4b, 0xf3, 0x28, 0x3b, + 0xfd, 0x0, 0x10, 0xa4, 0x4e, 0xf4, 0xda, 0x4c, 0x4f, 0x23, 0xd6, 0xb, 0x66, 0x4d, 0x46, 0xb0, + 0x88, 0x1c, 0x8a, 0x1, 0x71, 0x2, 0x0, 0x0, 0x6d, 0xc0, 0x1c, 0x0, 0x1b, 0x64, 0xac, 0x71, + 0xe7, 0xae, 0xe8, 0x76, 0x16, 0x6, 0xd5, 0xbd, 0x2c, 0x3d, 0x84, 0x12, 0x90, 0xeb, 0x7a, 0x9, + 0x25, 0x7f, 0xe3, 0xe6, 0x93, 0x39, 0xc6, 0x3b, 0x28, 0x64, 0x17, 0x9f, 0x23, 0x73, 0xdb, 0x8, + 0x0, 0x4, 0x5, 0x74, 0xa5, 0x5b, 0x21, 0x5d, 0x4a, 0x28, 0x13, 0xce, 0x1f, 0xb7, 0xb8, 0xcf, + 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; + uint8_t topic_bytes[] = {0x4f, 0xd8, 0xba}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xce, 0x1f, 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 13; - uint8_t bytesprops0[] = {0x9e, 0x73, 0x88, 0x6d, 0xc1, 0xcd, 0x94, 0x47, - 0xf7, 0x67, 0xf, 0x1d, 0x15, 0xbc, 0x87, 0xd}; + uint8_t bytesprops0[] = {0x79}; + uint8_t bytesprops1[] = {0x1e, 0xca, 0xc1}; + uint8_t bytesprops3[] = {0xa4, 0x4e, 0xf4, 0xda, 0x4c, 0x4f, 0x23, 0xd6, + 0xb, 0x66, 0x4d, 0x46, 0xb0, 0x88, 0x1c, 0x8a}; + uint8_t bytesprops2[] = {0x6e, 0x96, 0xb, 0x8b, 0x8b, 0xa6, 0x4b, 0xa3, 0x6c, 0x72, + 0x24, 0x2d, 0x23, 0x18, 0x45, 0x4b, 0xf3, 0x28, 0x3b, 0xfd}; + uint8_t bytesprops4[] = {0x64, 0xac, 0x71, 0xe7, 0xae, 0xe8, 0x76, 0x16, 0x6, 0xd5, 0xbd, 0x2c, 0x3d, 0x84, + 0x12, 0x90, 0xeb, 0x7a, 0x9, 0x25, 0x7f, 0xe3, 0xe6, 0x93, 0x39, 0xc6, 0x3b}; + uint8_t bytesprops5[] = {0x5, 0x74, 0xa5, 0x5b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3457}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops2}, .v = {16, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28096}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29659}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23882}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 19}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 11476, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 31863, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\187\192\216\&6]J\244\v\252\&6\149\EOT\128\ETX", _pubPktID = 11476, _pubBody = -// "\254&\138\150\179\238u\252\176\246'\140\196", _pubProps = [PropServerReference -// "\158s\136m\193\205\148G\247g\SI\GS\NAK\188\135\r"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O\216\186", _pubPktID = 31863, +// _pubBody = "\206\US\183\184\207\198X\216\SOn\202 \214", _pubProps = [PropServerKeepAlive +// 3457,PropAssignedClientIdentifier "y",PropCorrelationData "\RS\202\193",PropMaximumQoS 253,PropUserProperty +// "n\150\v\139\139\166K\163lr$-#\CANEK\243(;\253" "\164N\244\218LO#\214\vfMF\176\136\FS\138",PropPayloadFormatIndicator +// 113,PropMessageExpiryInterval 28096,PropServerReference +// "d\172q\231\174\232v\SYN\ACK\213\189,=\132\DC2\144\235z\t%\DEL\227\230\147\&9\198;",PropWildcardSubscriptionAvailable +// 100,PropRequestProblemInformation 159,PropTopicAlias 29659,PropResponseTopic "\ENQt\165[",PropReceiveMaximum +// 23882,PropWildcardSubscriptionAvailable 19]} TEST(Publish5QCTest, Decode27) { - uint8_t pkt[] = {0x3a, 0x33, 0x0, 0xe, 0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, - 0x95, 0x4, 0x80, 0x3, 0x2c, 0xd4, 0x13, 0x1c, 0x0, 0x10, 0x9e, 0x73, 0x88, 0x6d, - 0xc1, 0xcd, 0x94, 0x47, 0xf7, 0x67, 0xf, 0x1d, 0x15, 0xbc, 0x87, 0xd, 0xfe, 0x26, - 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + uint8_t pkt[] = {0x3d, 0x85, 0x1, 0x0, 0x3, 0x4f, 0xd8, 0xba, 0x7c, 0x77, 0x70, 0x13, 0xd, 0x81, 0x12, 0x0, + 0x1, 0x79, 0x9, 0x0, 0x3, 0x1e, 0xca, 0xc1, 0x24, 0xfd, 0x26, 0x0, 0x14, 0x6e, 0x96, 0xb, + 0x8b, 0x8b, 0xa6, 0x4b, 0xa3, 0x6c, 0x72, 0x24, 0x2d, 0x23, 0x18, 0x45, 0x4b, 0xf3, 0x28, 0x3b, + 0xfd, 0x0, 0x10, 0xa4, 0x4e, 0xf4, 0xda, 0x4c, 0x4f, 0x23, 0xd6, 0xb, 0x66, 0x4d, 0x46, 0xb0, + 0x88, 0x1c, 0x8a, 0x1, 0x71, 0x2, 0x0, 0x0, 0x6d, 0xc0, 0x1c, 0x0, 0x1b, 0x64, 0xac, 0x71, + 0xe7, 0xae, 0xe8, 0x76, 0x16, 0x6, 0xd5, 0xbd, 0x2c, 0x3d, 0x84, 0x12, 0x90, 0xeb, 0x7a, 0x9, + 0x25, 0x7f, 0xe3, 0xe6, 0x93, 0x39, 0xc6, 0x3b, 0x28, 0x64, 0x17, 0x9f, 0x23, 0x73, 0xdb, 0x8, + 0x0, 0x4, 0x5, 0x74, 0xa5, 0x5b, 0x21, 0x5d, 0x4a, 0x28, 0x13, 0xce, 0x1f, 0xb7, 0xb8, 0xcf, + 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4735,148 +4679,134 @@ TEST(Publish5QCTest, Decode27) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xbb, 0xc0, 0xd8, 0x36, 0x5d, 0x4a, 0xf4, 0xb, 0xfc, 0x36, 0x95, 0x4, 0x80, 0x3}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfe, 0x26, 0x8a, 0x96, 0xb3, 0xee, 0x75, 0xfc, 0xb0, 0xf6, 0x27, 0x8c, 0xc4}; + uint8_t exp_topic_bytes[] = {0x4f, 0xd8, 0xba}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xce, 0x1f, 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 11476); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 31863); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); EXPECT_EQ(msg.payload_len, 13); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "/\USs\188\193\156\202\143\244\215\159fj\184\STX\DC3\217", _pubPktID = 0, _pubBody = "\213T\157\156*`\174Ad\219\206", -// _pubProps = [PropServerKeepAlive 4269,PropRequestProblemInformation 153,PropServerKeepAlive -// 27842,PropMessageExpiryInterval 1195,PropMaximumQoS 247,PropMessageExpiryInterval 16305,PropReasonString -// "\223\146\n\193=EP\214\252+\245",PropTopicAliasMaximum 5510,PropServerReference -// "i\250S\ETB\179\t4Af$\255\173\188\204\STX\236\165",PropServerKeepAlive 9985,PropResponseTopic -// ":\219f\210",PropServerKeepAlive 3868,PropMaximumPacketSize 7322,PropContentType -// "\213\128\229\164F$\188\238L\161\STX\143",PropSubscriptionIdentifierAvailable 38,PropUserProperty -// "\198\NAK\NAKY<\165\a\220\161\US\207\SYN\227\&3\194\179\137lp ww,\FS\ETB\ETB\DC2\132\195" -// "D\181\230\136\&8@\STX\212\EM/3R\186\167\&4\157\145\187\227\ENQ\250\151\&0\225\174",PropSharedSubscriptionAvailable -// 204,PropRetainAvailable 215,PropWillDelayInterval 7511,PropServerKeepAlive 30724,PropWildcardSubscriptionAvailable -// 219,PropMaximumQoS 149,PropMessageExpiryInterval 21863,PropUserProperty "" -// "\218\186\SO\DC2\143\139\242\136_\129P\EM\144\243up\144\231\DC2",PropMaximumQoS 53,PropServerReference -// "\DLEG\146=}|\NUL\131\228#Y0\EM\129~\139$\136T\STX\225\194\158]\DC4\"",PropMaximumPacketSize 3760]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "r8* +// \EM\150\251uUH\DEL\151\232\SOH\RS\240\192\167=\255\246\193\250*<", _pubPktID = 26145, _pubBody = +// "\165\DC2\SOH6&\169\226\233\172\134`\205\149\221__", _pubProps = [PropRequestProblemInformation 48,PropReceiveMaximum +// 6809,PropMessageExpiryInterval 14400,PropUserProperty "\212\RSv!\211" +// "\156h\\\138^\159\139P\172\217\153\"\130|\137}\SOH\249\187\141\215\172",PropMessageExpiryInterval +// 29289,PropAuthenticationData +// "\DC4\DEL\172\&5\147\250\NUL\154M\t\146@\234\176\244\226q\218i\252\147\170NpB\213\248\134w!",PropSessionExpiryInterval +// 14509,PropReceiveMaximum 27484,PropContentType +// "H\228\SYN\255;x\209\150\154\165\179!\200\159O)E\189\128*\132\SI\154\235\ENQ{\180\154h",PropSubscriptionIdentifierAvailable +// 195,PropTopicAliasMaximum 24651,PropContentType +// "\140\196p2\EM\213p\178\139`o&\139\215CP\210\198\170\227A\221\195\205",PropWillDelayInterval +// 31842,PropServerKeepAlive 227,PropRequestResponseInformation 96,PropSubscriptionIdentifierAvailable +// 234,PropTopicAlias 30778,PropSubscriptionIdentifierAvailable 201,PropRequestResponseInformation +// 153,PropSubscriptionIdentifier 8,PropWildcardSubscriptionAvailable 6,PropMessageExpiryInterval 27590]} TEST(Publish5QCTest, Encode28) { - uint8_t pkt[] = {0x31, 0x88, 0x2, 0x0, 0x11, 0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, 0xd7, 0x9f, 0x66, - 0x6a, 0xb8, 0x2, 0x13, 0xd9, 0xe8, 0x1, 0x13, 0x10, 0xad, 0x17, 0x99, 0x13, 0x6c, 0xc2, 0x2, 0x0, - 0x0, 0x4, 0xab, 0x24, 0xf7, 0x2, 0x0, 0x0, 0x3f, 0xb1, 0x1f, 0x0, 0xb, 0xdf, 0x92, 0xa, 0xc1, - 0x3d, 0x45, 0x50, 0xd6, 0xfc, 0x2b, 0xf5, 0x22, 0x15, 0x86, 0x1c, 0x0, 0x11, 0x69, 0xfa, 0x53, 0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d5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; - uint8_t topic_bytes[] = {0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, - 0xd7, 0x9f, 0x66, 0x6a, 0xb8, 0x2, 0x13, 0xd9}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0xe3, 0x1, 0x0, 0x19, 0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, + 0xe8, 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c, 0x66, 0x21, 0xb4, 0x1, + 0x17, 0x30, 0x21, 0x1a, 0x99, 0x2, 0x0, 0x0, 0x38, 0x40, 0x26, 0x0, 0x5, 0xd4, 0x1e, 0x76, 0x21, + 0xd3, 0x0, 0x16, 0x9c, 0x68, 0x5c, 0x8a, 0x5e, 0x9f, 0x8b, 0x50, 0xac, 0xd9, 0x99, 0x22, 0x82, 0x7c, + 0x89, 0x7d, 0x1, 0xf9, 0xbb, 0x8d, 0xd7, 0xac, 0x2, 0x0, 0x0, 0x72, 0x69, 0x16, 0x0, 0x1e, 0x14, + 0x7f, 0xac, 0x35, 0x93, 0xfa, 0x0, 0x9a, 0x4d, 0x9, 0x92, 0x40, 0xea, 0xb0, 0xf4, 0xe2, 0x71, 0xda, + 0x69, 0xfc, 0x93, 0xaa, 0x4e, 0x70, 0x42, 0xd5, 0xf8, 0x86, 0x77, 0x21, 0x11, 0x0, 0x0, 0x38, 0xad, + 0x21, 0x6b, 0x5c, 0x3, 0x0, 0x1d, 0x48, 0xe4, 0x16, 0xff, 0x3b, 0x78, 0xd1, 0x96, 0x9a, 0xa5, 0xb3, + 0x21, 0xc8, 0x9f, 0x4f, 0x29, 0x45, 0xbd, 0x80, 0x2a, 0x84, 0xf, 0x9a, 0xeb, 0x5, 0x7b, 0xb4, 0x9a, + 0x68, 0x29, 0xc3, 0x22, 0x60, 0x4b, 0x3, 0x0, 0x18, 0x8c, 0xc4, 0x70, 0x32, 0x19, 0xd5, 0x70, 0xb2, + 0x8b, 0x60, 0x6f, 0x26, 0x8b, 0xd7, 0x43, 0x50, 0xd2, 0xc6, 0xaa, 0xe3, 0x41, 0xdd, 0xc3, 0xcd, 0x18, + 0x0, 0x0, 0x7c, 0x62, 0x13, 0x0, 0xe3, 0x19, 0x60, 0x29, 0xea, 0x23, 0x78, 0x3a, 0x29, 0xc9, 0x19, + 0x99, 0xb, 0x8, 0x28, 0x6, 0x2, 0x0, 0x0, 0x6b, 0xc6, 0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, + 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; + uint8_t topic_bytes[] = {0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, 0xe8, + 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 16; - uint8_t bytesprops0[] = {0xdf, 0x92, 0xa, 0xc1, 0x3d, 0x45, 0x50, 0xd6, 0xfc, 0x2b, 0xf5}; - uint8_t bytesprops1[] = {0x69, 0xfa, 0x53, 0x17, 0xb3, 0x9, 0x34, 0x41, 0x66, - 0x24, 0xff, 0xad, 0xbc, 0xcc, 0x2, 0xec, 0xa5}; - uint8_t bytesprops2[] = {0x3a, 0xdb, 0x66, 0xd2}; - uint8_t bytesprops3[] = {0xd5, 0x80, 0xe5, 0xa4, 0x46, 0x24, 0xbc, 0xee, 0x4c, 0xa1, 0x2, 0x8f}; - uint8_t bytesprops5[] = {0x44, 0xb5, 0xe6, 0x88, 0x38, 0x40, 0x2, 0xd4, 0x19, 0x2f, 0x33, 0x52, 0xba, - 0xa7, 0x34, 0x9d, 0x91, 0xbb, 0xe3, 0x5, 0xfa, 0x97, 0x30, 0xe1, 0xae}; - uint8_t bytesprops4[] = {0xc6, 0x15, 0x15, 0x59, 0x3c, 0xa5, 0x7, 0xdc, 0xa1, 0x1f, 0xcf, 0x16, 0xe3, 0x33, 0xc2, - 0xb3, 0x89, 0x6c, 0x70, 0x20, 0x77, 0x77, 0x2c, 0x1c, 0x17, 0x17, 0x12, 0x84, 0xc3}; - uint8_t bytesprops7[] = {0xda, 0xba, 0xe, 0x12, 0x8f, 0x8b, 0xf2, 0x88, 0x5f, 0x81, - 0x50, 0x19, 0x90, 0xf3, 0x75, 0x70, 0x90, 0xe7, 0x12}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops8[] = {0x10, 0x47, 0x92, 0x3d, 0x7d, 0x7c, 0x0, 0x83, 0xe4, 0x23, 0x59, 0x30, 0x19, - 0x81, 0x7e, 0x8b, 0x24, 0x88, 0x54, 0x2, 0xe1, 0xc2, 0x9e, 0x5d, 0x14, 0x22}; + uint8_t bytesprops1[] = {0x9c, 0x68, 0x5c, 0x8a, 0x5e, 0x9f, 0x8b, 0x50, 0xac, 0xd9, 0x99, + 0x22, 0x82, 0x7c, 0x89, 0x7d, 0x1, 0xf9, 0xbb, 0x8d, 0xd7, 0xac}; + uint8_t bytesprops0[] = {0xd4, 0x1e, 0x76, 0x21, 0xd3}; + uint8_t bytesprops2[] = {0x14, 0x7f, 0xac, 0x35, 0x93, 0xfa, 0x0, 0x9a, 0x4d, 0x9, 0x92, 0x40, 0xea, 0xb0, 0xf4, + 0xe2, 0x71, 0xda, 0x69, 0xfc, 0x93, 0xaa, 0x4e, 0x70, 0x42, 0xd5, 0xf8, 0x86, 0x77, 0x21}; + uint8_t bytesprops3[] = {0x48, 0xe4, 0x16, 0xff, 0x3b, 0x78, 0xd1, 0x96, 0x9a, 0xa5, 0xb3, 0x21, 0xc8, 0x9f, 0x4f, + 0x29, 0x45, 0xbd, 0x80, 0x2a, 0x84, 0xf, 0x9a, 0xeb, 0x5, 0x7b, 0xb4, 0x9a, 0x68}; + uint8_t bytesprops4[] = {0x8c, 0xc4, 0x70, 0x32, 0x19, 0xd5, 0x70, 0xb2, 0x8b, 0x60, 0x6f, 0x26, + 0x8b, 0xd7, 0x43, 0x50, 0xd2, 0xc6, 0xaa, 0xe3, 0x41, 0xdd, 0xc3, 0xcd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4269}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27842}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1195}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16305}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5510}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9985}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3868}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7322}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {25, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7511}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30724}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21863}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops6}, .v = {19, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3760}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6809}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14400}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops0}, .v = {22, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29289}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14509}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27484}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24651}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31842}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 227}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30778}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27590}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 26145, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "/\USs\188\193\156\202\143\244\215\159fj\184\STX\DC3\217", _pubPktID = 0, _pubBody = "\213T\157\156*`\174Ad\219\206", -// _pubProps = [PropServerKeepAlive 4269,PropRequestProblemInformation 153,PropServerKeepAlive -// 27842,PropMessageExpiryInterval 1195,PropMaximumQoS 247,PropMessageExpiryInterval 16305,PropReasonString -// "\223\146\n\193=EP\214\252+\245",PropTopicAliasMaximum 5510,PropServerReference -// "i\250S\ETB\179\t4Af$\255\173\188\204\STX\236\165",PropServerKeepAlive 9985,PropResponseTopic -// ":\219f\210",PropServerKeepAlive 3868,PropMaximumPacketSize 7322,PropContentType -// "\213\128\229\164F$\188\238L\161\STX\143",PropSubscriptionIdentifierAvailable 38,PropUserProperty -// "\198\NAK\NAKY<\165\a\220\161\US\207\SYN\227\&3\194\179\137lp ww,\FS\ETB\ETB\DC2\132\195" -// "D\181\230\136\&8@\STX\212\EM/3R\186\167\&4\157\145\187\227\ENQ\250\151\&0\225\174",PropSharedSubscriptionAvailable -// 204,PropRetainAvailable 215,PropWillDelayInterval 7511,PropServerKeepAlive 30724,PropWildcardSubscriptionAvailable -// 219,PropMaximumQoS 149,PropMessageExpiryInterval 21863,PropUserProperty "" -// "\218\186\SO\DC2\143\139\242\136_\129P\EM\144\243up\144\231\DC2",PropMaximumQoS 53,PropServerReference -// "\DLEG\146=}|\NUL\131\228#Y0\EM\129~\139$\136T\STX\225\194\158]\DC4\"",PropMaximumPacketSize 3760]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "r8* +// \EM\150\251uUH\DEL\151\232\SOH\RS\240\192\167=\255\246\193\250*<", _pubPktID = 26145, _pubBody = +// "\165\DC2\SOH6&\169\226\233\172\134`\205\149\221__", _pubProps = [PropRequestProblemInformation 48,PropReceiveMaximum +// 6809,PropMessageExpiryInterval 14400,PropUserProperty "\212\RSv!\211" +// "\156h\\\138^\159\139P\172\217\153\"\130|\137}\SOH\249\187\141\215\172",PropMessageExpiryInterval +// 29289,PropAuthenticationData +// "\DC4\DEL\172\&5\147\250\NUL\154M\t\146@\234\176\244\226q\218i\252\147\170NpB\213\248\134w!",PropSessionExpiryInterval +// 14509,PropReceiveMaximum 27484,PropContentType +// "H\228\SYN\255;x\209\150\154\165\179!\200\159O)E\189\128*\132\SI\154\235\ENQ{\180\154h",PropSubscriptionIdentifierAvailable +// 195,PropTopicAliasMaximum 24651,PropContentType +// "\140\196p2\EM\213p\178\139`o&\139\215CP\210\198\170\227A\221\195\205",PropWillDelayInterval +// 31842,PropServerKeepAlive 227,PropRequestResponseInformation 96,PropSubscriptionIdentifierAvailable +// 234,PropTopicAlias 30778,PropSubscriptionIdentifierAvailable 201,PropRequestResponseInformation +// 153,PropSubscriptionIdentifier 8,PropWildcardSubscriptionAvailable 6,PropMessageExpiryInterval 27590]} TEST(Publish5QCTest, Decode28) { - uint8_t pkt[] = {0x31, 0x88, 0x2, 0x0, 0x11, 0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, 0xd7, 0x9f, 0x66, - 0x6a, 0xb8, 0x2, 0x13, 0xd9, 0xe8, 0x1, 0x13, 0x10, 0xad, 0x17, 0x99, 0x13, 0x6c, 0xc2, 0x2, 0x0, - 0x0, 0x4, 0xab, 0x24, 0xf7, 0x2, 0x0, 0x0, 0x3f, 0xb1, 0x1f, 0x0, 0xb, 0xdf, 0x92, 0xa, 0xc1, - 0x3d, 0x45, 0x50, 0xd6, 0xfc, 0x2b, 0xf5, 0x22, 0x15, 0x86, 0x1c, 0x0, 0x11, 0x69, 0xfa, 0x53, 0x17, - 0xb3, 0x9, 0x34, 0x41, 0x66, 0x24, 0xff, 0xad, 0xbc, 0xcc, 0x2, 0xec, 0xa5, 0x13, 0x27, 0x1, 0x8, - 0x0, 0x4, 0x3a, 0xdb, 0x66, 0xd2, 0x13, 0xf, 0x1c, 0x27, 0x0, 0x0, 0x1c, 0x9a, 0x3, 0x0, 0xc, - 0xd5, 0x80, 0xe5, 0xa4, 0x46, 0x24, 0xbc, 0xee, 0x4c, 0xa1, 0x2, 0x8f, 0x29, 0x26, 0x26, 0x0, 0x1d, - 0xc6, 0x15, 0x15, 0x59, 0x3c, 0xa5, 0x7, 0xdc, 0xa1, 0x1f, 0xcf, 0x16, 0xe3, 0x33, 0xc2, 0xb3, 0x89, - 0x6c, 0x70, 0x20, 0x77, 0x77, 0x2c, 0x1c, 0x17, 0x17, 0x12, 0x84, 0xc3, 0x0, 0x19, 0x44, 0xb5, 0xe6, - 0x88, 0x38, 0x40, 0x2, 0xd4, 0x19, 0x2f, 0x33, 0x52, 0xba, 0xa7, 0x34, 0x9d, 0x91, 0xbb, 0xe3, 0x5, - 0xfa, 0x97, 0x30, 0xe1, 0xae, 0x2a, 0xcc, 0x25, 0xd7, 0x18, 0x0, 0x0, 0x1d, 0x57, 0x13, 0x78, 0x4, - 0x28, 0xdb, 0x24, 0x95, 0x2, 0x0, 0x0, 0x55, 0x67, 0x26, 0x0, 0x0, 0x0, 0x13, 0xda, 0xba, 0xe, - 0x12, 0x8f, 0x8b, 0xf2, 0x88, 0x5f, 0x81, 0x50, 0x19, 0x90, 0xf3, 0x75, 0x70, 0x90, 0xe7, 0x12, 0x24, - 0x35, 0x1c, 0x0, 0x1a, 0x10, 0x47, 0x92, 0x3d, 0x7d, 0x7c, 0x0, 0x83, 0xe4, 0x23, 0x59, 0x30, 0x19, - 0x81, 0x7e, 0x8b, 0x24, 0x88, 0x54, 0x2, 0xe1, 0xc2, 0x9e, 0x5d, 0x14, 0x22, 0x27, 0x0, 0x0, 0xe, - 0xb0, 0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; + uint8_t pkt[] = {0x32, 0xe3, 0x1, 0x0, 0x19, 0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, + 0xe8, 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c, 0x66, 0x21, 0xb4, 0x1, + 0x17, 0x30, 0x21, 0x1a, 0x99, 0x2, 0x0, 0x0, 0x38, 0x40, 0x26, 0x0, 0x5, 0xd4, 0x1e, 0x76, 0x21, + 0xd3, 0x0, 0x16, 0x9c, 0x68, 0x5c, 0x8a, 0x5e, 0x9f, 0x8b, 0x50, 0xac, 0xd9, 0x99, 0x22, 0x82, 0x7c, + 0x89, 0x7d, 0x1, 0xf9, 0xbb, 0x8d, 0xd7, 0xac, 0x2, 0x0, 0x0, 0x72, 0x69, 0x16, 0x0, 0x1e, 0x14, + 0x7f, 0xac, 0x35, 0x93, 0xfa, 0x0, 0x9a, 0x4d, 0x9, 0x92, 0x40, 0xea, 0xb0, 0xf4, 0xe2, 0x71, 0xda, + 0x69, 0xfc, 0x93, 0xaa, 0x4e, 0x70, 0x42, 0xd5, 0xf8, 0x86, 0x77, 0x21, 0x11, 0x0, 0x0, 0x38, 0xad, + 0x21, 0x6b, 0x5c, 0x3, 0x0, 0x1d, 0x48, 0xe4, 0x16, 0xff, 0x3b, 0x78, 0xd1, 0x96, 0x9a, 0xa5, 0xb3, + 0x21, 0xc8, 0x9f, 0x4f, 0x29, 0x45, 0xbd, 0x80, 0x2a, 0x84, 0xf, 0x9a, 0xeb, 0x5, 0x7b, 0xb4, 0x9a, + 0x68, 0x29, 0xc3, 0x22, 0x60, 0x4b, 0x3, 0x0, 0x18, 0x8c, 0xc4, 0x70, 0x32, 0x19, 0xd5, 0x70, 0xb2, + 0x8b, 0x60, 0x6f, 0x26, 0x8b, 0xd7, 0x43, 0x50, 0xd2, 0xc6, 0xaa, 0xe3, 0x41, 0xdd, 0xc3, 0xcd, 0x18, + 0x0, 0x0, 0x7c, 0x62, 0x13, 0x0, 0xe3, 0x19, 0x60, 0x29, 0xea, 0x23, 0x78, 0x3a, 0x29, 0xc9, 0x19, + 0x99, 0xb, 0x8, 0x28, 0x6, 0x2, 0x0, 0x0, 0x6b, 0xc6, 0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, + 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4885,131 +4815,66 @@ TEST(Publish5QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x2f, 0x1f, 0x73, 0xbc, 0xc1, 0x9c, 0xca, 0x8f, 0xf4, - 0xd7, 0x9f, 0x66, 0x6a, 0xb8, 0x2, 0x13, 0xd9}; - lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd5, 0x54, 0x9d, 0x9c, 0x2a, 0x60, 0xae, 0x41, 0x64, 0xdb, 0xce}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, 0xe8, + 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, + 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 26145); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\ETXJ\240r\220\200\DLE=\219m\152\EM\205\US\144", _pubPktID = 32504, _pubBody = -// "C\158&\185\DLE\NUL\239\237\184+\SO<\134\"R\EM\232\230\222\ENQ", _pubProps = [PropTopicAliasMaximum -// 16938,PropReasonString "j\226\ESC\188$J\155(i\223\251\150#\b\151\SOH",PropPayloadFormatIndicator -// 58,PropWildcardSubscriptionAvailable 104,PropAssignedClientIdentifier "`e",PropAssignedClientIdentifier -// "#[\181+\157\182\245\229\145\255\205zB\245x\140o\205\197P\143s\168f\146\154\221\224\221}",PropContentType -// "\132\162)q\NUL\239\140\&2\SOH\165W\174\162\203\246\159\230f\DELF%",PropRetainAvailable 62,PropContentType -// "/*%Z@",PropReasonString -// "\219\239\161\255rX\129\250qmI\184\159v5\199\238\147<\252xx\\\164\&09\253",PropRequestProblemInformation -// 30,PropSharedSubscriptionAvailable 155,PropMessageExpiryInterval 14356,PropWildcardSubscriptionAvailable -// 212,PropContentType "\202\182",PropResponseTopic -// "\180mv\t-\239\239\142\252_\214!\129\192%\218\230\147\&7\211L\ENQ\153\180",PropServerKeepAlive -// 26081,PropRetainAvailable 68]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 7976, _pubBody = +// "\ENQP\a\164\163\166{\250{", _pubProps = [PropWillDelayInterval 3340,PropSubscriptionIdentifierAvailable +// 115,PropAuthenticationMethod "0\192j1e\ACK",PropReasonString "\r\173"]} TEST(Publish5QCTest, Encode29) { - uint8_t pkt[] = {0x35, 0xd9, 0x1, 0x0, 0xf, 0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, - 0xcd, 0x1f, 0x90, 0x7e, 0xf8, 0xb0, 0x1, 0x22, 0x42, 0x2a, 0x1f, 0x0, 0x10, 0x6a, 0xe2, 0x1b, 0xbc, - 0x24, 0x4a, 0x9b, 0x28, 0x69, 0xdf, 0xfb, 0x96, 0x23, 0x8, 0x97, 0x1, 0x1, 0x3a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0x19, 0xcd, 0x1f, 0x90}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x23, 0x0, 0x0, 0x1f, 0x28, 0x15, 0x18, 0x0, 0x0, 0xd, 0xc, 0x29, + 0x73, 0x15, 0x0, 0x6, 0x30, 0xc0, 0x6a, 0x31, 0x65, 0x6, 0x1f, 0x0, 0x2, + 0xd, 0xad, 0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, - 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + uint8_t msg_bytes[] = {0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 9; - uint8_t bytesprops0[] = {0x6a, 0xe2, 0x1b, 0xbc, 0x24, 0x4a, 0x9b, 0x28, - 0x69, 0xdf, 0xfb, 0x96, 0x23, 0x8, 0x97, 0x1}; - uint8_t bytesprops1[] = {0x60, 0x65}; - uint8_t bytesprops2[] = {0x23, 0x5b, 0xb5, 0x2b, 0x9d, 0xb6, 0xf5, 0xe5, 0x91, 0xff, 0xcd, 0x7a, 0x42, 0xf5, 0x78, - 0x8c, 0x6f, 0xcd, 0xc5, 0x50, 0x8f, 0x73, 0xa8, 0x66, 0x92, 0x9a, 0xdd, 0xe0, 0xdd, 0x7d}; - uint8_t bytesprops3[] = {0x84, 0xa2, 0x29, 0x71, 0x0, 0xef, 0x8c, 0x32, 0x1, 0xa5, 0x57, - 0xae, 0xa2, 0xcb, 0xf6, 0x9f, 0xe6, 0x66, 0x7f, 0x46, 0x25}; - uint8_t bytesprops4[] = {0x2f, 0x2a, 0x25, 0x5a, 0x40}; - uint8_t bytesprops5[] = {0xdb, 0xef, 0xa1, 0xff, 0x72, 0x58, 0x81, 0xfa, 0x71, 0x6d, 0x49, 0xb8, 0x9f, 0x76, - 0x35, 0xc7, 0xee, 0x93, 0x3c, 0xfc, 0x78, 0x78, 0x5c, 0xa4, 0x30, 0x39, 0xfd}; - uint8_t bytesprops6[] = {0xca, 0xb6}; - uint8_t bytesprops7[] = {0xb4, 0x6d, 0x76, 0x9, 0x2d, 0xef, 0xef, 0x8e, 0xfc, 0x5f, 0xd6, 0x21, - 0x81, 0xc0, 0x25, 0xda, 0xe6, 0x93, 0x37, 0xd3, 0x4c, 0x5, 0x99, 0xb4}; + uint8_t bytesprops0[] = {0x30, 0xc0, 0x6a, 0x31, 0x65, 0x6}; + uint8_t bytesprops1[] = {0xd, 0xad}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16938}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14356}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26081}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3340}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32504, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7976, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\ETXJ\240r\220\200\DLE=\219m\152\EM\205\US\144", _pubPktID = 32504, _pubBody = -// "C\158&\185\DLE\NUL\239\237\184+\SO<\134\"R\EM\232\230\222\ENQ", _pubProps = [PropTopicAliasMaximum -// 16938,PropReasonString "j\226\ESC\188$J\155(i\223\251\150#\b\151\SOH",PropPayloadFormatIndicator -// 58,PropWildcardSubscriptionAvailable 104,PropAssignedClientIdentifier "`e",PropAssignedClientIdentifier -// "#[\181+\157\182\245\229\145\255\205zB\245x\140o\205\197P\143s\168f\146\154\221\224\221}",PropContentType -// "\132\162)q\NUL\239\140\&2\SOH\165W\174\162\203\246\159\230f\DELF%",PropRetainAvailable 62,PropContentType -// "/*%Z@",PropReasonString -// "\219\239\161\255rX\129\250qmI\184\159v5\199\238\147<\252xx\\\164\&09\253",PropRequestProblemInformation -// 30,PropSharedSubscriptionAvailable 155,PropMessageExpiryInterval 14356,PropWildcardSubscriptionAvailable -// 212,PropContentType "\202\182",PropResponseTopic -// "\180mv\t-\239\239\142\252_\214!\129\192%\218\230\147\&7\211L\ENQ\153\180",PropServerKeepAlive -// 26081,PropRetainAvailable 68]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 7976, _pubBody = +// "\ENQP\a\164\163\166{\250{", _pubProps = [PropWillDelayInterval 3340,PropSubscriptionIdentifierAvailable +// 115,PropAuthenticationMethod "0\192j1e\ACK",PropReasonString "\r\173"]} TEST(Publish5QCTest, Decode29) { - uint8_t pkt[] = {0x35, 0xd9, 0x1, 0x0, 0xf, 0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, - 0xcd, 0x1f, 0x90, 0x7e, 0xf8, 0xb0, 0x1, 0x22, 0x42, 0x2a, 0x1f, 0x0, 0x10, 0x6a, 0xe2, 0x1b, 0xbc, - 0x24, 0x4a, 0x9b, 0x28, 0x69, 0xdf, 0xfb, 0x96, 0x23, 0x8, 0x97, 0x1, 0x1, 0x3a, 0x28, 0x68, 0x12, - 0x0, 0x2, 0x60, 0x65, 0x12, 0x0, 0x1e, 0x23, 0x5b, 0xb5, 0x2b, 0x9d, 0xb6, 0xf5, 0xe5, 0x91, 0xff, - 0xcd, 0x7a, 0x42, 0xf5, 0x78, 0x8c, 0x6f, 0xcd, 0xc5, 0x50, 0x8f, 0x73, 0xa8, 0x66, 0x92, 0x9a, 0xdd, - 0xe0, 0xdd, 0x7d, 0x3, 0x0, 0x15, 0x84, 0xa2, 0x29, 0x71, 0x0, 0xef, 0x8c, 0x32, 0x1, 0xa5, 0x57, - 0xae, 0xa2, 0xcb, 0xf6, 0x9f, 0xe6, 0x66, 0x7f, 0x46, 0x25, 0x25, 0x3e, 0x3, 0x0, 0x5, 0x2f, 0x2a, - 0x25, 0x5a, 0x40, 0x1f, 0x0, 0x1b, 0xdb, 0xef, 0xa1, 0xff, 0x72, 0x58, 0x81, 0xfa, 0x71, 0x6d, 0x49, - 0xb8, 0x9f, 0x76, 0x35, 0xc7, 0xee, 0x93, 0x3c, 0xfc, 0x78, 0x78, 0x5c, 0xa4, 0x30, 0x39, 0xfd, 0x17, - 0x1e, 0x2a, 0x9b, 0x2, 0x0, 0x0, 0x38, 0x14, 0x28, 0xd4, 0x3, 0x0, 0x2, 0xca, 0xb6, 0x8, 0x0, - 0x18, 0xb4, 0x6d, 0x76, 0x9, 0x2d, 0xef, 0xef, 0x8e, 0xfc, 0x5f, 0xd6, 0x21, 0x81, 0xc0, 0x25, 0xda, - 0xe6, 0x93, 0x37, 0xd3, 0x4c, 0x5, 0x99, 0xb4, 0x13, 0x65, 0xe1, 0x25, 0x44, 0x43, 0x9e, 0x26, 0xb9, - 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; + uint8_t pkt[] = {0x3b, 0x23, 0x0, 0x0, 0x1f, 0x28, 0x15, 0x18, 0x0, 0x0, 0xd, 0xc, 0x29, + 0x73, 0x15, 0x0, 0x6, 0x30, 0xc0, 0x6a, 0x31, 0x65, 0x6, 0x1f, 0x0, 0x2, + 0xd, 0xad, 0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -5018,60 +4883,100 @@ TEST(Publish5QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3, 0x4a, 0xf0, 0x72, 0xdc, 0xc8, 0x10, 0x3d, 0xdb, 0x6d, 0x98, 0x19, 0xcd, 0x1f, 0x90}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x43, 0x9e, 0x26, 0xb9, 0x10, 0x0, 0xef, 0xed, 0xb8, 0x2b, - 0xe, 0x3c, 0x86, 0x22, 0x52, 0x19, 0xe8, 0xe6, 0xde, 0x5}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; + lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 32504); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_EQ(packet_id, 7976); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 9); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CAN\n\131L\223F1\229", _pubPktID = -// 0, _pubBody = "\138\228\212\203", _pubProps = [PropWildcardSubscriptionAvailable 206,PropReasonString -// "\149N\204\172\138N\250[\183\171"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\197\a\164\SUB\DC1\195\RS`\FS\155?\206\154I\134\181\139\252Vc\161i`\DC3\245", _pubPktID = 3213, _pubBody = +// "\249a\NAK\209f+\v\251'\141\199\&6\195s\160^:v\251\&5\174\FS\240\191k\205\"\201\222=", _pubProps = [PropResponseTopic +// "\227\163\184+",PropAssignedClientIdentifier "\231\&6\243\150\NAK\194\191\142e",PropPayloadFormatIndicator +// 184,PropRequestProblemInformation 163,PropResponseInformation +// "\213^\232,F\184\\p\DC3L?\221\DC1\DC1\153#\DC3UYf\242\192\234\142LV",PropMaximumQoS 81,PropCorrelationData +// "\131\229\227oU\136O\"zQ\191\211$\214\&79",PropAuthenticationData "\213\215\v\179~l\190c +// \165wh.\181\208u\128\133\t\243\161\232\SOHB"]} TEST(Publish5QCTest, Encode30) { - uint8_t pkt[] = {0x30, 0x1e, 0x0, 0x8, 0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5, 0xf, 0x28, 0xce, 0x1f, - 0x0, 0xa, 0x95, 0x4e, 0xcc, 0xac, 0x8a, 0x4e, 0xfa, 0x5b, 0xb7, 0xab, 0x8a, 0xe4, 0xd4, 0xcb}; - uint8_t topic_bytes[] = {0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0xa0, 0x1, 0x0, 0x19, 0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, + 0x9a, 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5, 0xc, 0x8d, 0x64, 0x8, + 0x0, 0x4, 0xe3, 0xa3, 0xb8, 0x2b, 0x12, 0x0, 0x9, 0xe7, 0x36, 0xf3, 0x96, 0x15, 0xc2, 0xbf, 0x8e, + 0x65, 0x1, 0xb8, 0x17, 0xa3, 0x1a, 0x0, 0x1a, 0xd5, 0x5e, 0xe8, 0x2c, 0x46, 0xb8, 0x5c, 0x70, 0x13, + 0x4c, 0x3f, 0xdd, 0x11, 0x11, 0x99, 0x23, 0x13, 0x55, 0x59, 0x66, 0xf2, 0xc0, 0xea, 0x8e, 0x4c, 0x56, + 0x24, 0x51, 0x9, 0x0, 0x10, 0x83, 0xe5, 0xe3, 0x6f, 0x55, 0x88, 0x4f, 0x22, 0x7a, 0x51, 0xbf, 0xd3, + 0x24, 0xd6, 0x37, 0x39, 0x16, 0x0, 0x18, 0xd5, 0xd7, 0xb, 0xb3, 0x7e, 0x6c, 0xbe, 0x63, 0x20, 0xa5, + 0x77, 0x68, 0x2e, 0xb5, 0xd0, 0x75, 0x80, 0x85, 0x9, 0xf3, 0xa1, 0xe8, 0x1, 0x42, 0xf9, 0x61, 0x15, + 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, 0x5e, 0x3a, 0x76, 0xfb, 0x35, + 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; + uint8_t topic_bytes[] = {0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, 0x9a, + 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0x8a, 0xe4, 0xd4, 0xcb}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xf9, 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, + 0x5e, 0x3a, 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 30; - uint8_t bytesprops0[] = {0x95, 0x4e, 0xcc, 0xac, 0x8a, 0x4e, 0xfa, 0x5b, 0xb7, 0xab}; + uint8_t bytesprops0[] = {0xe3, 0xa3, 0xb8, 0x2b}; + uint8_t bytesprops1[] = {0xe7, 0x36, 0xf3, 0x96, 0x15, 0xc2, 0xbf, 0x8e, 0x65}; + uint8_t bytesprops2[] = {0xd5, 0x5e, 0xe8, 0x2c, 0x46, 0xb8, 0x5c, 0x70, 0x13, 0x4c, 0x3f, 0xdd, 0x11, + 0x11, 0x99, 0x23, 0x13, 0x55, 0x59, 0x66, 0xf2, 0xc0, 0xea, 0x8e, 0x4c, 0x56}; + uint8_t bytesprops3[] = {0x83, 0xe5, 0xe3, 0x6f, 0x55, 0x88, 0x4f, 0x22, + 0x7a, 0x51, 0xbf, 0xd3, 0x24, 0xd6, 0x37, 0x39}; + uint8_t bytesprops4[] = {0xd5, 0xd7, 0xb, 0xb3, 0x7e, 0x6c, 0xbe, 0x63, 0x20, 0xa5, 0x77, 0x68, + 0x2e, 0xb5, 0xd0, 0x75, 0x80, 0x85, 0x9, 0xf3, 0xa1, 0xe8, 0x1, 0x42}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 3213, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\CAN\n\131L\223F1\229", _pubPktID = -// 0, _pubBody = "\138\228\212\203", _pubProps = [PropWildcardSubscriptionAvailable 206,PropReasonString -// "\149N\204\172\138N\250[\183\171"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// "\197\a\164\SUB\DC1\195\RS`\FS\155?\206\154I\134\181\139\252Vc\161i`\DC3\245", _pubPktID = 3213, _pubBody = +// "\249a\NAK\209f+\v\251'\141\199\&6\195s\160^:v\251\&5\174\FS\240\191k\205\"\201\222=", _pubProps = [PropResponseTopic +// "\227\163\184+",PropAssignedClientIdentifier "\231\&6\243\150\NAK\194\191\142e",PropPayloadFormatIndicator +// 184,PropRequestProblemInformation 163,PropResponseInformation +// "\213^\232,F\184\\p\DC3L?\221\DC1\DC1\153#\DC3UYf\242\192\234\142LV",PropMaximumQoS 81,PropCorrelationData +// "\131\229\227oU\136O\"zQ\191\211$\214\&79",PropAuthenticationData "\213\215\v\179~l\190c +// \165wh.\181\208u\128\133\t\243\161\232\SOHB"]} TEST(Publish5QCTest, Decode30) { - uint8_t pkt[] = {0x30, 0x1e, 0x0, 0x8,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x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -5080,83 +4985,69 @@ TEST(Publish5QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x18, 0xa, 0x83, 0x4c, 0xdf, 0x46, 0x31, 0xe5}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8a, 0xe4, 0xd4, 0xcb}; - lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, 0x9a, + 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf9, 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, + 0x5e, 0x3a, 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; + lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 4); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 3213); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 30); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); lwmqtt_string_t x = exp_topic; x = exp_body; } -// ConnectRequest {_username = Just "su\219", _password = Just "\245\218", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS2, _willTopic = "\200\218\ENQ\194\150u=", _willMsg = "18\181\155\177B\144\135#\186\ESC", -// _willProps = []}), _cleanSession = True, _keepAlive = 23341, _connID = "\167\130W\226#\FSJ:\239#\154)\178i", -// _properties = []} +// ConnectRequest {_username = Just "\160\151\149a\211\ACK*?\149\202\211vrIu\153\DC2\173\173!\ACK", _password = Just +// "\212\133\STX\STX\240\131p", _lastWill = Nothing, _cleanSession = False, _keepAlive = 1099, _connID = +// "1\a\221\162V\235\244\238\188\&2v1%G\151H4@{\224\180\180\184\194\165\&2\138\141\204", _properties = []} TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x5b, 0x2d, 0x0, 0xe, 0xa7, - 0x82, 0x57, 0xe2, 0x23, 0x1c, 0x4a, 0x3a, 0xef, 0x23, 0x9a, 0x29, 0xb2, 0x69, 0x0, 0x7, - 0xc8, 0xda, 0x5, 0xc2, 0x96, 0x75, 0x3d, 0x0, 0xb, 0x31, 0x38, 0xb5, 0x9b, 0xb1, 0x42, - 0x90, 0x87, 0x23, 0xba, 0x1b, 0x0, 0x3, 0x73, 0x75, 0xdb, 0x0, 0x2, 0xf5, 0xda}; + uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x4, 0x4b, 0x0, 0x1d, 0x31, + 0x7, 0xdd, 0xa2, 0x56, 0xeb, 0xf4, 0xee, 0xbc, 0x32, 0x76, 0x31, 0x25, 0x47, 0x97, 0x48, + 0x34, 0x40, 0x7b, 0xe0, 0xb4, 0xb4, 0xb8, 0xc2, 0xa5, 0x32, 0x8a, 0x8d, 0xcc, 0x0, 0x15, + 0xa0, 0x97, 0x95, 0x61, 0xd3, 0x6, 0x2a, 0x3f, 0x95, 0xca, 0xd3, 0x76, 0x72, 0x49, 0x75, + 0x99, 0x12, 0xad, 0xad, 0x21, 0x6, 0x0, 0x7, 0xd4, 0x85, 0x2, 0x2, 0xf0, 0x83, 0x70}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc8, 0xda, 0x5, 0xc2, 0x96, 0x75, 0x3d}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x31, 0x38, 0xb5, 0x9b, 0xb1, 0x42, 0x90, 0x87, 0x23, 0xba, 0x1b}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 23341; - uint8_t client_id_bytes[] = {0xa7, 0x82, 0x57, 0xe2, 0x23, 0x1c, 0x4a, 0x3a, 0xef, 0x23, 0x9a, 0x29, 0xb2, 0x69}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 1099; + uint8_t client_id_bytes[] = {0x31, 0x7, 0xdd, 0xa2, 0x56, 0xeb, 0xf4, 0xee, 0xbc, 0x32, 0x76, 0x31, 0x25, 0x47, 0x97, + 0x48, 0x34, 0x40, 0x7b, 0xe0, 0xb4, 0xb4, 0xb8, 0xc2, 0xa5, 0x32, 0x8a, 0x8d, 0xcc}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x73, 0x75, 0xdb}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa0, 0x97, 0x95, 0x61, 0xd3, 0x6, 0x2a, 0x3f, 0x95, 0xca, 0xd3, + 0x76, 0x72, 0x49, 0x75, 0x99, 0x12, 0xad, 0xad, 0x21, 0x6}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xf5, 0xda}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xd4, 0x85, 0x2, 0x2, 0xf0, 0x83, 0x70}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "P\166UwM\219C\247)G\246N\221{\180_\252\165e\v\208q\130c\RS\211C<", _password = Just -// "\130\CAN3\224\145\232]\239\145\186\165\178v\169N=\a+\t -", _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS0, _willTopic = "\\\179", _willMsg = "\165\154\226\EOTH\244,\148\217\b|", _willProps = []}), _cleanSession = -// False, _keepAlive = 18048, _connID = -// "J\190\236\SO\209A\240R\155\STX:\190\166-\217C\169\EM\134\160\170\226\251I\v\238\&6\208\149", _properties = []} +// ConnectRequest {_username = Just "\245\FSg\131", _password = Just "\SO\141\210", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "\152\255\131ME_\ENQ\227\fVV\141\172", _willMsg = +// "\152\v\143\189\254\149a\FS7i\f_\220\240\209\232", _willProps = []}), _cleanSession = True, _keepAlive = 4861, +// _connID = "=\b:\142\144", _properties = []} TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x6f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x46, 0x80, 0x0, 0x1d, 0x4a, 0xbe, 0xec, - 0xe, 0xd1, 0x41, 0xf0, 0x52, 0x9b, 0x2, 0x3a, 0xbe, 0xa6, 0x2d, 0xd9, 0x43, 0xa9, 0x19, 0x86, 0xa0, - 0xaa, 0xe2, 0xfb, 0x49, 0xb, 0xee, 0x36, 0xd0, 0x95, 0x0, 0x2, 0x5c, 0xb3, 0x0, 0xb, 0xa5, 0x9a, - 0xe2, 0x4, 0x48, 0xf4, 0x2c, 0x94, 0xd9, 0x8, 0x7c, 0x0, 0x1c, 0x50, 0xa6, 0x55, 0x77, 0x4d, 0xdb, - 0x43, 0xf7, 0x29, 0x47, 0xf6, 0x4e, 0xdd, 0x7b, 0xb4, 0x5f, 0xfc, 0xa5, 0x65, 0xb, 0xd0, 0x71, 0x82, - 0x63, 0x1e, 0xd3, 0x43, 0x3c, 0x0, 0x15, 0x82, 0x18, 0x33, 0xe0, 0x91, 0xe8, 0x5d, 0xef, 0x91, 0xba, - 0xa5, 0xb2, 0x76, 0xa9, 0x4e, 0x3d, 0x7, 0x2b, 0x9, 0x20, 0x2d}; + uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x12, 0xfd, 0x0, 0x5, 0x3d, 0x8, + 0x3a, 0x8e, 0x90, 0x0, 0xd, 0x98, 0xff, 0x83, 0x4d, 0x45, 0x5f, 0x5, 0xe3, 0xc, 0x56, 0x56, + 0x8d, 0xac, 0x0, 0x10, 0x98, 0xb, 0x8f, 0xbd, 0xfe, 0x95, 0x61, 0x1c, 0x37, 0x69, 0xc, 0x5f, + 0xdc, 0xf0, 0xd1, 0xe8, 0x0, 0x4, 0xf5, 0x1c, 0x67, 0x83, 0x0, 0x3, 0xe, 0x8d, 0xd2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5167,30 +5058,28 @@ TEST(Connect311QCTest, Encode2) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5c, 0xb3}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa5, 0x9a, 0xe2, 0x4, 0x48, 0xf4, 0x2c, 0x94, 0xd9, 0x8, 0x7c}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x98, 0xff, 0x83, 0x4d, 0x45, 0x5f, 0x5, 0xe3, 0xc, 0x56, 0x56, 0x8d, 0xac}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x98, 0xb, 0x8f, 0xbd, 0xfe, 0x95, 0x61, 0x1c, + 0x37, 0x69, 0xc, 0x5f, 0xdc, 0xf0, 0xd1, 0xe8}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 18048; - uint8_t client_id_bytes[] = {0x4a, 0xbe, 0xec, 0xe, 0xd1, 0x41, 0xf0, 0x52, 0x9b, 0x2, 0x3a, 0xbe, 0xa6, 0x2d, 0xd9, - 0x43, 0xa9, 0x19, 0x86, 0xa0, 0xaa, 0xe2, 0xfb, 0x49, 0xb, 0xee, 0x36, 0xd0, 0x95}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 4861; + uint8_t client_id_bytes[] = {0x3d, 0x8, 0x3a, 0x8e, 0x90}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x50, 0xa6, 0x55, 0x77, 0x4d, 0xdb, 0x43, 0xf7, 0x29, 0x47, 0xf6, 0x4e, 0xdd, 0x7b, - 0xb4, 0x5f, 0xfc, 0xa5, 0x65, 0xb, 0xd0, 0x71, 0x82, 0x63, 0x1e, 0xd3, 0x43, 0x3c}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf5, 0x1c, 0x67, 0x83}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x82, 0x18, 0x33, 0xe0, 0x91, 0xe8, 0x5d, 0xef, 0x91, 0xba, 0xa5, - 0xb2, 0x76, 0xa9, 0x4e, 0x3d, 0x7, 0x2b, 0x9, 0x20, 0x2d}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe, 0x8d, 0xd2}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5200,71 +5089,45 @@ TEST(Connect311QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "2\SYN9\139\255u\201\DEL\234\DEL\164@W\249\SUB\225B\154\170*\\H\246:b\164", -// _password = Just "+ZTUH\240]\158$\252\179\130\182\154hK", _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "\248\227\198;\219P\186\DC1\SO\130\166<\193j\180\&3\199\231BD@\235", _willMsg = "\231", _willProps -// = []}), _cleanSession = True, _keepAlive = 16330, _connID = "\v\176\184\NULR", _properties = []} +// ConnectRequest {_username = Just "\190~\232\224\v\218x\135\ESC\193\243\132\192\&1\150\134+\245\EOT9\235j\175", +// _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 11488, _connID = "", _properties = []} TEST(Connect311QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x3f, 0xca, 0x0, 0x5, 0xb, 0xb0, - 0xb8, 0x0, 0x52, 0x0, 0x16, 0xf8, 0xe3, 0xc6, 0x3b, 0xdb, 0x50, 0xba, 0x11, 0xe, 0x82, 0xa6, - 0x3c, 0xc1, 0x6a, 0xb4, 0x33, 0xc7, 0xe7, 0x42, 0x44, 0x40, 0xeb, 0x0, 0x1, 0xe7, 0x0, 0x1a, - 0x32, 0x16, 0x39, 0x8b, 0xff, 0x75, 0xc9, 0x7f, 0xea, 0x7f, 0xa4, 0x40, 0x57, 0xf9, 0x1a, 0xe1, - 0x42, 0x9a, 0xaa, 0x2a, 0x5c, 0x48, 0xf6, 0x3a, 0x62, 0xa4, 0x0, 0x10, 0x2b, 0x5a, 0x54, 0x55, - 0x48, 0xf0, 0x5d, 0x9e, 0x24, 0xfc, 0xb3, 0x82, 0xb6, 0x9a, 0x68, 0x4b}; + uint8_t pkt[] = {0x10, 0x25, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x2c, 0xe0, 0x0, + 0x0, 0x0, 0x17, 0xbe, 0x7e, 0xe8, 0xe0, 0xb, 0xda, 0x78, 0x87, 0x1b, 0xc1, + 0xf3, 0x84, 0xc0, 0x31, 0x96, 0x86, 0x2b, 0xf5, 0x4, 0x39, 0xeb, 0x6a, 0xaf}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf8, 0xe3, 0xc6, 0x3b, 0xdb, 0x50, 0xba, 0x11, 0xe, 0x82, 0xa6, - 0x3c, 0xc1, 0x6a, 0xb4, 0x33, 0xc7, 0xe7, 0x42, 0x44, 0x40, 0xeb}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe7}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 16330; - uint8_t client_id_bytes[] = {0xb, 0xb0, 0xb8, 0x0, 0x52}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 11488; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x32, 0x16, 0x39, 0x8b, 0xff, 0x75, 0xc9, 0x7f, 0xea, 0x7f, 0xa4, 0x40, 0x57, - 0xf9, 0x1a, 0xe1, 0x42, 0x9a, 0xaa, 0x2a, 0x5c, 0x48, 0xf6, 0x3a, 0x62, 0xa4}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xbe, 0x7e, 0xe8, 0xe0, 0xb, 0xda, 0x78, 0x87, 0x1b, 0xc1, 0xf3, 0x84, + 0xc0, 0x31, 0x96, 0x86, 0x2b, 0xf5, 0x4, 0x39, 0xeb, 0x6a, 0xaf}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x2b, 0x5a, 0x54, 0x55, 0x48, 0xf0, 0x5d, 0x9e, - 0x24, 0xfc, 0xb3, 0x82, 0xb6, 0x9a, 0x68, 0x4b}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\SOH\222\148y4W7\221\234\219\249G\176i\153\&7C\174\DC3\201\168", _password = -// Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\182\DC2\202\175'\175", -// _willMsg = "FT\180\227 ,\DLEhU\147g\249\210sn\150=>P\234h4\234\150\&6T\137\149\192\216", _willProps = []}), -// _cleanSession = True, _keepAlive = 30046, _connID = "A'\216\131\251\208\218\DC4\152\230\198\239\a", _properties = []} +// ConnectRequest {_username = Just "_\DLE\201\254`\162\246\240I", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = "\248J", _willMsg = +// "\RSG\205\252\RSP\173\SO\195\CAN\209PX\DC1c:\218\166G\158\ACK", _willProps = []}), _cleanSession = True, _keepAlive = +// 31889, _connID = "I.j%\170?\194\183h\143.\150\255", _properties = []} TEST(Connect311QCTest, Encode4) { - uint8_t pkt[] = {0x10, 0x58, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa6, 0x75, 0x5e, 0x0, 0xd, 0x41, - 0x27, 0xd8, 0x83, 0xfb, 0xd0, 0xda, 0x14, 0x98, 0xe6, 0xc6, 0xef, 0x7, 0x0, 0x6, 0xb6, - 0x12, 0xca, 0xaf, 0x27, 0xaf, 0x0, 0x1e, 0x46, 0x54, 0xb4, 0xe3, 0x20, 0x2c, 0x10, 0x68, - 0x55, 0x93, 0x67, 0xf9, 0xd2, 0x73, 0x6e, 0x96, 0x3d, 0x3e, 0x50, 0xea, 0x68, 0x34, 0xea, - 0x96, 0x36, 0x54, 0x89, 0x95, 0xc0, 0xd8, 0x0, 0x15, 0x1, 0xde, 0x94, 0x79, 0x34, 0x57, - 0x37, 0xdd, 0xea, 0xdb, 0xf9, 0x47, 0xb0, 0x69, 0x99, 0x37, 0x43, 0xae, 0x13, 0xc9, 0xa8}; + uint8_t pkt[] = {0x10, 0x3f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xae, 0x7c, 0x91, 0x0, 0xd, 0x49, 0x2e, 0x6a, + 0x25, 0xaa, 0x3f, 0xc2, 0xb7, 0x68, 0x8f, 0x2e, 0x96, 0xff, 0x0, 0x2, 0xf8, 0x4a, 0x0, 0x15, 0x1e, + 0x47, 0xcd, 0xfc, 0x1e, 0x50, 0xad, 0xe, 0xc3, 0x18, 0xd1, 0x50, 0x58, 0x11, 0x63, 0x3a, 0xda, 0xa6, + 0x47, 0x9e, 0x6, 0x0, 0x9, 0x5f, 0x10, 0xc9, 0xfe, 0x60, 0xa2, 0xf6, 0xf0, 0x49}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5275,27 +5138,25 @@ TEST(Connect311QCTest, Encode4) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb6, 0x12, 0xca, 0xaf, 0x27, 0xaf}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x46, 0x54, 0xb4, 0xe3, 0x20, 0x2c, 0x10, 0x68, 0x55, 0x93, - 0x67, 0xf9, 0xd2, 0x73, 0x6e, 0x96, 0x3d, 0x3e, 0x50, 0xea, - 0x68, 0x34, 0xea, 0x96, 0x36, 0x54, 0x89, 0x95, 0xc0, 0xd8}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xf8, 0x4a}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1e, 0x47, 0xcd, 0xfc, 0x1e, 0x50, 0xad, 0xe, 0xc3, 0x18, 0xd1, + 0x50, 0x58, 0x11, 0x63, 0x3a, 0xda, 0xa6, 0x47, 0x9e, 0x6}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS1; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 30046; - uint8_t client_id_bytes[] = {0x41, 0x27, 0xd8, 0x83, 0xfb, 0xd0, 0xda, 0x14, 0x98, 0xe6, 0xc6, 0xef, 0x7}; + opts.keep_alive = 31889; + uint8_t client_id_bytes[] = {0x49, 0x2e, 0x6a, 0x25, 0xaa, 0x3f, 0xc2, 0xb7, 0x68, 0x8f, 0x2e, 0x96, 0xff}; lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x1, 0xde, 0x94, 0x79, 0x34, 0x57, 0x37, 0xdd, 0xea, 0xdb, 0xf9, - 0x47, 0xb0, 0x69, 0x99, 0x37, 0x43, 0xae, 0x13, 0xc9, 0xa8}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x5f, 0x10, 0xc9, 0xfe, 0x60, 0xa2, 0xf6, 0xf0, 0x49}; + lwmqtt_string_t username = {9, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5305,50 +5166,57 @@ TEST(Connect311QCTest, Encode4) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "~\247\167\ACK\232\156\SYN\185\229`S\252", _password = Just -// "\f\149\174\193\181\&4\229ys\252zT\227\DC2\247\&2\216\183\132)\183\"#-\226\142", _lastWill = Nothing, _cleanSession = -// True, _keepAlive = 2932, _connID = "\199h5Ao\222\152\ETXd\178q\161", _willProps = []}), _cleanSession = False, _keepAlive = -// 20495, _connID = "\199\170\&0\213\199\&6Tz4k\247\fs;\188l\241\227L\185\128\149\160\143\227\150c7\220", _properties = -// []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "c_\DC1\222(\232\&7", _willMsg = +// "\213z\217-\215\&3\195\ETB\188G\198\140\251+\139\183\183\222\232\204M\187\145\252\EOT\n\192\129", _willProps = []}), +// _cleanSession = True, _keepAlive = 7652, _connID = "m\186 \189\208z", _properties = []} TEST(Connect311QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0x50, 0xf, 0x0, 0x1d, 0xc7, 0xaa, - 0x30, 0xd5, 0xc7, 0x36, 0x54, 0x7a, 0x34, 0x6b, 0xf7, 0xc, 0x73, 0x3b, 0xbc, 0x6c, 0xf1, 0xe3, - 0x4c, 0xb9, 0x80, 0x95, 0xa0, 0x8f, 0xe3, 0x96, 0x63, 0x37, 0xdc, 0x0, 0x1a, 0xfb, 0xc8, 0x36, - 0xc7, 0xce, 0xce, 0xdc, 0x70, 0x48, 0xb, 0x97, 0xc4, 0x81, 0x41, 0x5f, 0x86, 0x8d, 0xd7, 0xe5, - 0xe, 0xbd, 0xc6, 0x6c, 0xf9, 0x3d, 0xca, 0x0, 0xf, 0xb3, 0x25, 0x6c, 0xf0, 0x8f, 0xbf, 0x3e, - 0x6f, 0xde, 0x98, 0x3, 0x64, 0xb2, 0x71, 0xa1, 0x0, 0x2, 0x19, 0x91}; + uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x1d, 0xe4, 0x0, 0x6, 0x6d, + 0xba, 0x20, 0xbd, 0xd0, 0x7a, 0x0, 0x7, 0x63, 0x5f, 0x11, 0xde, 0x28, 0xe8, 0x37, 0x0, + 0x1c, 0xd5, 0x7a, 0xd9, 0x2d, 0xd7, 0x33, 0xc3, 0x17, 0xbc, 0x47, 0xc6, 0x8c, 0xfb, 0x2b, + 0x8b, 0xb7, 0xb7, 0xde, 0xe8, 0xcc, 0x4d, 0xbb, 0x91, 0xfc, 0x4, 0xa, 0xc0, 0x81}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5406,28 +5275,23 @@ TEST(Connect311QCTest, Encode7) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xfb, 0xc8, 0x36, 0xc7, 0xce, 0xce, 0xdc, 0x70, 0x48, 0xb, 0x97, 0xc4, 0x81, - 0x41, 0x5f, 0x86, 0x8d, 0xd7, 0xe5, 0xe, 0xbd, 0xc6, 0x6c, 0xf9, 0x3d, 0xca}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb3, 0x25, 0x6c, 0xf0, 0x8f, 0xbf, 0x3e, 0x6f, - 0xde, 0x98, 0x3, 0x64, 0xb2, 0x71, 0xa1}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x63, 0x5f, 0x11, 0xde, 0x28, 0xe8, 0x37}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd5, 0x7a, 0xd9, 0x2d, 0xd7, 0x33, 0xc3, 0x17, 0xbc, 0x47, 0xc6, 0x8c, 0xfb, 0x2b, + 0x8b, 0xb7, 0xb7, 0xde, 0xe8, 0xcc, 0x4d, 0xbb, 0x91, 0xfc, 0x4, 0xa, 0xc0, 0x81}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 20495; - uint8_t client_id_bytes[] = {0xc7, 0xaa, 0x30, 0xd5, 0xc7, 0x36, 0x54, 0x7a, 0x34, 0x6b, 0xf7, 0xc, 0x73, 0x3b, 0xbc, - 0x6c, 0xf1, 0xe3, 0x4c, 0xb9, 0x80, 0x95, 0xa0, 0x8f, 0xe3, 0x96, 0x63, 0x37, 0xdc}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 7652; + uint8_t client_id_bytes[] = {0x6d, 0xba, 0x20, 0xbd, 0xd0, 0x7a}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x19, 0x91}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5436,16 +5300,15 @@ TEST(Connect311QCTest, Encode7) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\181\166\207", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "\140\199\a\SOH\ETX\168\245v\148k\214\201\144\139n\ENQ\170\252Z\142\205", _willMsg = -// ":*\192m\246\&0\144M\255\232<\210\138\STX\142h!j\205\162\158\"\140\190", _willProps = []}), _cleanSession = False, -// _keepAlive = 19119, _connID = "\ETBB\213\133\216\235\t0\138\222\&2", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS2, _willTopic = "\167\186,\225\231\n\229RS\158n\EOT\157pX\SI\134\254\187\&5\178[\235\215\141", _willMsg = "\183~", +// _willProps = []}), _cleanSession = True, _keepAlive = 4897, _connID = "\215ES)\213\"\RS\149\165\167\252\216_\166", +// _properties = []} TEST(Connect311QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x48, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x4a, 0xaf, 0x0, 0xb, 0x17, - 0x42, 0xd5, 0x85, 0xd8, 0xeb, 0x9, 0x30, 0x8a, 0xde, 0x32, 0x0, 0x15, 0x8c, 0xc7, 0x7, - 0x1, 0x3, 0xa8, 0xf5, 0x76, 0x94, 0x6b, 0xd6, 0xc9, 0x90, 0x8b, 0x6e, 0x5, 0xaa, 0xfc, - 0x5a, 0x8e, 0xcd, 0x0, 0x18, 0x3a, 0x2a, 0xc0, 0x6d, 0xf6, 0x30, 0x90, 0x4d, 0xff, 0xe8, - 0x3c, 0xd2, 0x8a, 0x2, 0x8e, 0x68, 0x21, 0x6a, 0xcd, 0xa2, 0x9e, 0x22, 0x8c, 0xbe}; + uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x13, 0x21, 0x0, 0xe, 0xd7, + 0x45, 0x53, 0x29, 0xd5, 0x22, 0x1e, 0x95, 0xa5, 0xa7, 0xfc, 0xd8, 0x5f, 0xa6, 0x0, 0x19, + 0xa7, 0xba, 0x2c, 0xe1, 0xe7, 0xa, 0xe5, 0x52, 0x53, 0x9e, 0x6e, 0x4, 0x9d, 0x70, 0x58, + 0xf, 0x86, 0xfe, 0xbb, 0x35, 0xb2, 0x5b, 0xeb, 0xd7, 0x8d, 0x0, 0x2, 0xb7, 0x7e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5456,12 +5319,11 @@ TEST(Connect311QCTest, Encode8) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8c, 0xc7, 0x7, 0x1, 0x3, 0xa8, 0xf5, 0x76, 0x94, 0x6b, 0xd6, - 0xc9, 0x90, 0x8b, 0x6e, 0x5, 0xaa, 0xfc, 0x5a, 0x8e, 0xcd}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3a, 0x2a, 0xc0, 0x6d, 0xf6, 0x30, 0x90, 0x4d, 0xff, 0xe8, 0x3c, 0xd2, - 0x8a, 0x2, 0x8e, 0x68, 0x21, 0x6a, 0xcd, 0xa2, 0x9e, 0x22, 0x8c, 0xbe}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xa7, 0xba, 0x2c, 0xe1, 0xe7, 0xa, 0xe5, 0x52, 0x53, 0x9e, 0x6e, 0x4, 0x9d, + 0x70, 0x58, 0xf, 0x86, 0xfe, 0xbb, 0x35, 0xb2, 0x5b, 0xeb, 0xd7, 0x8d}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb7, 0x7e}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; @@ -5469,14 +5331,11 @@ TEST(Connect311QCTest, Encode8) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19119; - uint8_t client_id_bytes[] = {0x17, 0x42, 0xd5, 0x85, 0xd8, 0xeb, 0x9, 0x30, 0x8a, 0xde, 0x32}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 4897; + uint8_t client_id_bytes[] = {0xd7, 0x45, 0x53, 0x29, 0xd5, 0x22, 0x1e, 0x95, 0xa5, 0xa7, 0xfc, 0xd8, 0x5f, 0xa6}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xb5, 0xa6, 0xcf}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5485,47 +5344,66 @@ TEST(Connect311QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = -// 26405, _connID = "", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\179\171\192\219e27\202\244Y\238\&9\151", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\221\239\USQ\"", _willMsg = "", _willProps = []}), +// _cleanSession = False, _keepAlive = 28246, _connID = +// "6S\138\205\221\220lm\242_x6\230\192\DC4\219\134u\DC40\191tP^\212\247", _properties = []} TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0xc, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x67, 0x25, 0x0, 0x0}; + uint8_t pkt[] = {0x10, 0x2f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x14, 0x6e, 0x56, 0x0, 0x1a, 0x36, 0x53, 0x8a, + 0xcd, 0xdd, 0xdc, 0x6c, 0x6d, 0xf2, 0x5f, 0x78, 0x36, 0xe6, 0xc0, 0x14, 0xdb, 0x86, 0x75, 0x14, 0x30, + 0xbf, 0x74, 0x50, 0x5e, 0xd4, 0xf7, 0x0, 0x5, 0xdd, 0xef, 0x1f, 0x51, 0x22, 0x0, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xdd, 0xef, 0x1f, 0x51, 0x22}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 26405; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 28246; + uint8_t client_id_bytes[] = {0x36, 0x53, 0x8a, 0xcd, 0xdd, 0xdc, 0x6c, 0x6d, 0xf2, 0x5f, 0x78, 0x36, 0xe6, + 0xc0, 0x14, 0xdb, 0x86, 0x75, 0x14, 0x30, 0xbf, 0x74, 0x50, 0x5e, 0xd4, 0xf7}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t password_bytes[] = {0xb3, 0xab, 0xc0, 0xdb, 0x65, 0x32, 0x37, 0xca, 0xf4, 0x59, 0xee, 0x39, 0x97}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\244\160\221\&0\230\206m\172", _password = Just -// "\165\183%\251X.>\250\DC2jTpG*a)\199u\169\200c\ETB\200\246\180\&5\171\157S\185", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = -// "\189>\247Z\247\130\236\149k\150\218\181\\-Za%\"\153\153\249\154\229\155\174\154", _willMsg = -// "1\183yF.\202\190\&0\172\233\196\243\200;e\233\133N\232/T\223\157-)\ESC\144\SYN9", _willProps = []}), _cleanSession = -// True, _keepAlive = 26688, _connID = "\246\249\133]\247\EOTD,\146\246\247\159\145\&1O\239Y\129\183+\237\ACK\b", -// _properties = []} +// ConnectRequest {_username = Just "a\240\130l{", _password = Just +// "\139\168iv\184\216p\167\249\142\150\188G^'\235a\GS", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = +// "\DC4\144\178\229\CAN\160\DC2\233\SI\160\DC1G\219\173\175\r\161\&3\250\246\200\250\r\199J\154\165\195\221\237", +// _willMsg = " \207(\FS?\175Cq\NUL\154(\203(\186\197\156`\189O\255\195\169\153\RS\226\b`h", _willProps = []}), +// _cleanSession = True, _keepAlive = 13826, _connID = "", _properties = []} TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x88, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x68, 0x40, 0x0, 0x17, 0xf6, - 0xf9, 0x85, 0x5d, 0xf7, 0x4, 0x44, 0x2c, 0x92, 0xf6, 0xf7, 0x9f, 0x91, 0x31, 0x4f, 0xef, 0x59, - 0x81, 0xb7, 0x2b, 0xed, 0x6, 0x8, 0x0, 0x1a, 0xbd, 0x3e, 0xf7, 0x5a, 0xf7, 0x82, 0xec, 0x95, - 0x6b, 0x96, 0xda, 0xb5, 0x5c, 0x2d, 0x5a, 0x61, 0x25, 0x22, 0x99, 0x99, 0xf9, 0x9a, 0xe5, 0x9b, - 0xae, 0x9a, 0x0, 0x1d, 0x31, 0xb7, 0x79, 0x46, 0x2e, 0xca, 0xbe, 0x30, 0xac, 0xe9, 0xc4, 0xf3, - 0xc8, 0x3b, 0x65, 0xe9, 0x85, 0x4e, 0xe8, 0x2f, 0x54, 0xdf, 0x9d, 0x2d, 0x29, 0x1b, 0x90, 0x16, - 0x39, 0x0, 0x8, 0xf4, 0xa0, 0xdd, 0x30, 0xe6, 0xce, 0x6d, 0xac, 0x0, 0x1e, 0xa5, 0xb7, 0x25, - 0xfb, 0x58, 0x2e, 0x3e, 0xfa, 0x12, 0x6a, 0x54, 0x70, 0x47, 0x2a, 0x61, 0x29, 0xc7, 0x75, 0xa9, - 0xc8, 0x63, 0x17, 0xc8, 0xf6, 0xb4, 0x35, 0xab, 0x9d, 0x53, 0xb9}; + uint8_t pkt[] = {0x10, 0x65, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe6, 0x36, 0x2, 0x0, 0x0, 0x0, + 0x1e, 0x14, 0x90, 0xb2, 0xe5, 0x18, 0xa0, 0x12, 0xe9, 0xf, 0xa0, 0x11, 0x47, 0xdb, 0xad, + 0xaf, 0xd, 0xa1, 0x33, 0xfa, 0xf6, 0xc8, 0xfa, 0xd, 0xc7, 0x4a, 0x9a, 0xa5, 0xc3, 0xdd, + 0xed, 0x0, 0x1c, 0x20, 0xcf, 0x28, 0x1c, 0x3f, 0xaf, 0x43, 0x71, 0x0, 0x9a, 0x28, 0xcb, + 0x28, 0xba, 0xc5, 0x9c, 0x60, 0xbd, 0x4f, 0xff, 0xc3, 0xa9, 0x99, 0x1e, 0xe2, 0x8, 0x60, + 0x68, 0x0, 0x5, 0x61, 0xf0, 0x82, 0x6c, 0x7b, 0x0, 0x12, 0x8b, 0xa8, 0x69, 0x76, 0xb8, + 0xd8, 0x70, 0xa7, 0xf9, 0x8e, 0x96, 0xbc, 0x47, 0x5e, 0x27, 0xeb, 0x61, 0x1d}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5536,32 +5414,31 @@ TEST(Connect311QCTest, Encode10) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbd, 0x3e, 0xf7, 0x5a, 0xf7, 0x82, 0xec, 0x95, 0x6b, 0x96, 0xda, 0xb5, 0x5c, - 0x2d, 0x5a, 0x61, 0x25, 0x22, 0x99, 0x99, 0xf9, 0x9a, 0xe5, 0x9b, 0xae, 0x9a}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x31, 0xb7, 0x79, 0x46, 0x2e, 0xca, 0xbe, 0x30, 0xac, 0xe9, - 0xc4, 0xf3, 0xc8, 0x3b, 0x65, 0xe9, 0x85, 0x4e, 0xe8, 0x2f, - 0x54, 0xdf, 0x9d, 0x2d, 0x29, 0x1b, 0x90, 0x16, 0x39}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x14, 0x90, 0xb2, 0xe5, 0x18, 0xa0, 0x12, 0xe9, 0xf, 0xa0, + 0x11, 0x47, 0xdb, 0xad, 0xaf, 0xd, 0xa1, 0x33, 0xfa, 0xf6, + 0xc8, 0xfa, 0xd, 0xc7, 0x4a, 0x9a, 0xa5, 0xc3, 0xdd, 0xed}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x20, 0xcf, 0x28, 0x1c, 0x3f, 0xaf, 0x43, 0x71, 0x0, 0x9a, 0x28, 0xcb, 0x28, 0xba, + 0xc5, 0x9c, 0x60, 0xbd, 0x4f, 0xff, 0xc3, 0xa9, 0x99, 0x1e, 0xe2, 0x8, 0x60, 0x68}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 26688; - uint8_t client_id_bytes[] = {0xf6, 0xf9, 0x85, 0x5d, 0xf7, 0x4, 0x44, 0x2c, 0x92, 0xf6, 0xf7, 0x9f, - 0x91, 0x31, 0x4f, 0xef, 0x59, 0x81, 0xb7, 0x2b, 0xed, 0x6, 0x8}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 13826; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf4, 0xa0, 0xdd, 0x30, 0xe6, 0xce, 0x6d, 0xac}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x61, 0xf0, 0x82, 0x6c, 0x7b}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xa5, 0xb7, 0x25, 0xfb, 0x58, 0x2e, 0x3e, 0xfa, 0x12, 0x6a, 0x54, 0x70, 0x47, 0x2a, 0x61, - 0x29, 0xc7, 0x75, 0xa9, 0xc8, 0x63, 0x17, 0xc8, 0xf6, 0xb4, 0x35, 0xab, 0x9d, 0x53, 0xb9}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x8b, 0xa8, 0x69, 0x76, 0xb8, 0xd8, 0x70, 0xa7, 0xf9, + 0x8e, 0x96, 0xbc, 0x47, 0x5e, 0x27, 0xeb, 0x61, 0x1d}; + lwmqtt_string_t password = {18, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5571,19 +5448,16 @@ TEST(Connect311QCTest, Encode10) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\169\&9\US\187\DC1", _password = Just -// "\184\193\180:Dky-1\229\177\RS\US\181{h{\187\237\157K\222kRL\242Z\NAK\214", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS1, _willTopic = "", _willMsg = -// "\251Q\218\169\218\207sq\185c\DC2s\f\\\246'R\RS%\242v\DEL\204f\195I\159`&", _willProps = []}), _cleanSession = False, -// _keepAlive = 13305, _connID = "\207\241K\128\152Q\EMw\238\135PC\202L\142.\156)~\213\212\205", _properties = []} +// ConnectRequest {_username = Just "\212\GS\145\247\v\161", _password = Just "{!\212\236\201\231Q", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "", _willMsg = +// "]9\230\162rqS\215\197\SI\129\173\160\"j\ACK\181\v\226\253X\189\&4\146\169\138%\143$", _willProps = []}), +// _cleanSession = True, _keepAlive = 10261, _connID = "\137\n\r\250!\209\SO\245\&0\146@>\253V:\197D", _properties = []} TEST(Connect311QCTest, Encode11) { - uint8_t pkt[] = {0x10, 0x69, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x33, 0xf9, 0x0, 0x16, 0xcf, 0xf1, - 0x4b, 0x80, 0x98, 0x51, 0x19, 0x77, 0xee, 0x87, 0x50, 0x43, 0xca, 0x4c, 0x8e, 0x2e, 0x9c, 0x29, - 0x7e, 0xd5, 0xd4, 0xcd, 0x0, 0x0, 0x0, 0x1d, 0xfb, 0x51, 0xda, 0xa9, 0xda, 0xcf, 0x73, 0x71, - 0xb9, 0x63, 0x12, 0x73, 0xc, 0x5c, 0xf6, 0x27, 0x52, 0x1e, 0x25, 0xf2, 0x76, 0x7f, 0xcc, 0x66, - 0xc3, 0x49, 0x9f, 0x60, 0x26, 0x0, 0x5, 0xa9, 0x39, 0x1f, 0xbb, 0x11, 0x0, 0x1d, 0xb8, 0xc1, - 0xb4, 0x3a, 0x44, 0x6b, 0x79, 0x2d, 0x31, 0xe5, 0xb1, 0x1e, 0x1f, 0xb5, 0x7b, 0x68, 0x7b, 0xbb, - 0xed, 0x9d, 0x4b, 0xde, 0x6b, 0x52, 0x4c, 0xf2, 0x5a, 0x15, 0xd6}; + uint8_t pkt[] = {0x10, 0x4f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x28, 0x15, 0x0, 0x11, 0x89, 0xa, 0xd, + 0xfa, 0x21, 0xd1, 0xe, 0xf5, 0x30, 0x92, 0x40, 0x3e, 0xfd, 0x56, 0x3a, 0xc5, 0x44, 0x0, 0x0, 0x0, + 0x1d, 0x5d, 0x39, 0xe6, 0xa2, 0x72, 0x71, 0x53, 0xd7, 0xc5, 0xf, 0x81, 0xad, 0xa0, 0x22, 0x6a, 0x6, + 0xb5, 0xb, 0xe2, 0xfd, 0x58, 0xbd, 0x34, 0x92, 0xa9, 0x8a, 0x25, 0x8f, 0x24, 0x0, 0x6, 0xd4, 0x1d, + 0x91, 0xf7, 0xb, 0xa1, 0x0, 0x7, 0x7b, 0x21, 0xd4, 0xec, 0xc9, 0xe7, 0x51}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5596,9 +5470,9 @@ TEST(Connect311QCTest, Encode11) { lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; uint8_t will_topic_bytes[] = {0}; lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfb, 0x51, 0xda, 0xa9, 0xda, 0xcf, 0x73, 0x71, 0xb9, 0x63, - 0x12, 0x73, 0xc, 0x5c, 0xf6, 0x27, 0x52, 0x1e, 0x25, 0xf2, - 0x76, 0x7f, 0xcc, 0x66, 0xc3, 0x49, 0x9f, 0x60, 0x26}; + uint8_t will_payload_bytes[] = {0x5d, 0x39, 0xe6, 0xa2, 0x72, 0x71, 0x53, 0xd7, 0xc5, 0xf, + 0x81, 0xad, 0xa0, 0x22, 0x6a, 0x6, 0xb5, 0xb, 0xe2, 0xfd, + 0x58, 0xbd, 0x34, 0x92, 0xa9, 0x8a, 0x25, 0x8f, 0x24}; lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; @@ -5607,18 +5481,17 @@ TEST(Connect311QCTest, Encode11) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 13305; - uint8_t client_id_bytes[] = {0xcf, 0xf1, 0x4b, 0x80, 0x98, 0x51, 0x19, 0x77, 0xee, 0x87, 0x50, - 0x43, 0xca, 0x4c, 0x8e, 0x2e, 0x9c, 0x29, 0x7e, 0xd5, 0xd4, 0xcd}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 10261; + uint8_t client_id_bytes[] = {0x89, 0xa, 0xd, 0xfa, 0x21, 0xd1, 0xe, 0xf5, 0x30, + 0x92, 0x40, 0x3e, 0xfd, 0x56, 0x3a, 0xc5, 0x44}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa9, 0x39, 0x1f, 0xbb, 0x11}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xd4, 0x1d, 0x91, 0xf7, 0xb, 0xa1}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xb8, 0xc1, 0xb4, 0x3a, 0x44, 0x6b, 0x79, 0x2d, 0x31, 0xe5, 0xb1, 0x1e, 0x1f, 0xb5, 0x7b, - 0x68, 0x7b, 0xbb, 0xed, 0x9d, 0x4b, 0xde, 0x6b, 0x52, 0x4c, 0xf2, 0x5a, 0x15, 0xd6}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x7b, 0x21, 0xd4, 0xec, 0xc9, 0xe7, 0x51}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5628,16 +5501,19 @@ TEST(Connect311QCTest, Encode11) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\245\186\233\209\154JNY{\148\171\215\226hh\DELD\236\162\206", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "J}|\FS", _willMsg = -// "\230\222{\SO\US\159a\182$\177", _willProps = []}), _cleanSession = False, _keepAlive = 17990, _connID = -// "\164\DC3\215\130\131\167\153>\200\244\244\GS\132\139\&8", _properties = []} +// ConnectRequest {_username = Just "\221\242}\231\174B\GS\239\159Y\168\135+?h\249\&9`9<\191\211!\157\134\174", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\181\SUB\128:,a\250\247V)\184\235rKQORD!\154\244M\a", _willMsg = +// "\160\135:w_\160cdu\218\207\198\170\214\131\252w*0\v\204\191\186\ACK\224v", _willProps = []}), _cleanSession = False, +// _keepAlive = 27848, _connID = "|c\",E\248\&4\129\STX\254\128^\SYNv\175", _properties = []} TEST(Connect311QCTest, Encode12) { - uint8_t pkt[] = {0x10, 0x43, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0x46, 0x46, 0x0, 0xf, - 0xa4, 0x13, 0xd7, 0x82, 0x83, 0xa7, 0x99, 0x3e, 0xc8, 0xf4, 0xf4, 0x1d, 0x84, 0x8b, - 0x38, 0x0, 0x4, 0x4a, 0x7d, 0x7c, 0x1c, 0x0, 0xa, 0xe6, 0xde, 0x7b, 0xe, 0x1f, - 0x9f, 0x61, 0xb6, 0x24, 0xb1, 0x0, 0x14, 0xf5, 0xba, 0xe9, 0xd1, 0x9a, 0x4a, 0x4e, - 0x59, 0x7b, 0x94, 0xab, 0xd7, 0xe2, 0x68, 0x68, 0x7f, 0x44, 0xec, 0xa2, 0xce}; + uint8_t pkt[] = {0x10, 0x6c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0x6c, 0xc8, 0x0, 0xf, 0x7c, 0x63, + 0x22, 0x2c, 0x45, 0xf8, 0x34, 0x81, 0x2, 0xfe, 0x80, 0x5e, 0x16, 0x76, 0xaf, 0x0, 0x17, 0xb5, + 0x1a, 0x80, 0x3a, 0x2c, 0x61, 0xfa, 0xf7, 0x56, 0x29, 0xb8, 0xeb, 0x72, 0x4b, 0x51, 0x4f, 0x52, + 0x44, 0x21, 0x9a, 0xf4, 0x4d, 0x7, 0x0, 0x1a, 0xa0, 0x87, 0x3a, 0x77, 0x5f, 0xa0, 0x63, 0x64, + 0x75, 0xda, 0xcf, 0xc6, 0xaa, 0xd6, 0x83, 0xfc, 0x77, 0x2a, 0x30, 0xb, 0xcc, 0xbf, 0xba, 0x6, + 0xe0, 0x76, 0x0, 0x1a, 0xdd, 0xf2, 0x7d, 0xe7, 0xae, 0x42, 0x1d, 0xef, 0x9f, 0x59, 0xa8, 0x87, + 0x2b, 0x3f, 0x68, 0xf9, 0x39, 0x60, 0x39, 0x3c, 0xbf, 0xd3, 0x21, 0x9d, 0x86, 0xae}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -5648,10 +5524,12 @@ TEST(Connect311QCTest, Encode12) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x4a, 0x7d, 0x7c, 0x1c}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe6, 0xde, 0x7b, 0xe, 0x1f, 0x9f, 0x61, 0xb6, 0x24, 0xb1}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xb5, 0x1a, 0x80, 0x3a, 0x2c, 0x61, 0xfa, 0xf7, 0x56, 0x29, 0xb8, 0xeb, + 0x72, 0x4b, 0x51, 0x4f, 0x52, 0x44, 0x21, 0x9a, 0xf4, 0x4d, 0x7}; + lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa0, 0x87, 0x3a, 0x77, 0x5f, 0xa0, 0x63, 0x64, 0x75, 0xda, 0xcf, 0xc6, 0xaa, + 0xd6, 0x83, 0xfc, 0x77, 0x2a, 0x30, 0xb, 0xcc, 0xbf, 0xba, 0x6, 0xe0, 0x76}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -5660,14 +5538,13 @@ TEST(Connect311QCTest, Encode12) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 17990; - uint8_t client_id_bytes[] = {0xa4, 0x13, 0xd7, 0x82, 0x83, 0xa7, 0x99, 0x3e, - 0xc8, 0xf4, 0xf4, 0x1d, 0x84, 0x8b, 0x38}; + opts.keep_alive = 27848; + uint8_t client_id_bytes[] = {0x7c, 0x63, 0x22, 0x2c, 0x45, 0xf8, 0x34, 0x81, 0x2, 0xfe, 0x80, 0x5e, 0x16, 0x76, 0xaf}; lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xf5, 0xba, 0xe9, 0xd1, 0x9a, 0x4a, 0x4e, 0x59, 0x7b, 0x94, - 0xab, 0xd7, 0xe2, 0x68, 0x68, 0x7f, 0x44, 0xec, 0xa2, 0xce}; - lwmqtt_string_t username = {20, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xdd, 0xf2, 0x7d, 0xe7, 0xae, 0x42, 0x1d, 0xef, 0x9f, 0x59, 0xa8, 0x87, 0x2b, + 0x3f, 0x68, 0xf9, 0x39, 0x60, 0x39, 0x3c, 0xbf, 0xd3, 0x21, 0x9d, 0x86, 0xae}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -5677,15 +5554,17 @@ TEST(Connect311QCTest, Encode12) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\250\200\162\134OF\FS\CAN\131=\SI\ESC", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\205\193\146C\176\DC1{T\189hD\173\188\SOH\198h\2520H", _willProps = -// []}), _cleanSession = False, _keepAlive = 176, _connID = -// "\164\181\166\128r\129\SUB\184rUbzJ\177WIU+\158\DEL\SOH\NAK\164\169", _properties = []} +// ConnectRequest {_username = Just "\238", _password = Just "\224\167\178Vb~\222\DLE\192\146\197\133L", _lastWill = +// Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\STX", _willMsg = +// "6D\137\167,4\131\&6\166\145\201\149|\221\&2i\192", _willProps = []}), _cleanSession = False, _keepAlive = 19508, +// _connID = "|\238>", _properties = []} TEST(Connect311QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0x70, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x0, 0xb0, 0x0, 0x18, 0xa4, 0xb5, 0xa6, - 0x80, 0x72, 0x81, 0x1a, 0xb8, 0x72, 0x55, 0x62, 0x7a, 0x4a, 0xb1, 0x57, 0x49, 0x55, 0x2b, 0x9e, 0x7f, - 0x1, 0x15, 0xa4, 0xa9, 0x0, 0x1e, 0x86, 0x71, 0xa1, 0xec, 0xd9, 0x5c, 0xee, 0x33, 0x7a, 0x92, 0xc, - 0xba, 0xc6, 0xd3, 0x75, 0xfa, 0x5f, 0xd, 0xc2, 0x8d, 0x74, 0x7e, 0xa8, 0x77, 0xe1, 0x74, 0xab, 0x87, - 0x69, 0xe5, 0x0, 0x1b, 0xa4, 0xfc, 0x4, 0xcb, 0xc5, 0xa6, 0xab, 0x42, 0xb1, 0x91, 0x14, 0xbe, 0x13, - 0xcd, 0x15, 0x8f, 0x9d, 0x1a, 0xb1, 0xf8, 0x15, 0x81, 0xde, 0x7f, 0x3e, 0x30, 0x48, 0x0, 0x3, 0xa7, - 0x56, 0x76, 0x0, 0x8, 0x1f, 0x65, 0x66, 0x4d, 0x63, 0x59, 0xf5, 0x73}; + uint8_t pkt[] = {0x10, 0x37, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x4c, 0x34, 0x0, 0x3, 0x7c, + 0xee, 0x3e, 0x0, 0x1, 0x2, 0x0, 0x11, 0x36, 0x44, 0x89, 0xa7, 0x2c, 0x34, 0x83, 0x36, + 0xa6, 0x91, 0xc9, 0x95, 0x7c, 0xdd, 0x32, 0x69, 0xc0, 0x0, 0x1, 0xee, 0x0, 0xd, 0xe0, + 0xa7, 0xb2, 0x56, 0x62, 0x7e, 0xde, 0x10, 0xc0, 0x92, 0xc5, 0x85, 0x4c}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6052,31 +5915,28 @@ TEST(Connect311QCTest, Encode20) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x86, 0x71, 0xa1, 0xec, 0xd9, 0x5c, 0xee, 0x33, 0x7a, 0x92, - 0xc, 0xba, 0xc6, 0xd3, 0x75, 0xfa, 0x5f, 0xd, 0xc2, 0x8d, - 0x74, 0x7e, 0xa8, 0x77, 0xe1, 0x74, 0xab, 0x87, 0x69, 0xe5}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa4, 0xfc, 0x4, 0xcb, 0xc5, 0xa6, 0xab, 0x42, 0xb1, 0x91, 0x14, 0xbe, 0x13, 0xcd, - 0x15, 0x8f, 0x9d, 0x1a, 0xb1, 0xf8, 0x15, 0x81, 0xde, 0x7f, 0x3e, 0x30, 0x48}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x2}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x36, 0x44, 0x89, 0xa7, 0x2c, 0x34, 0x83, 0x36, 0xa6, + 0x91, 0xc9, 0x95, 0x7c, 0xdd, 0x32, 0x69, 0xc0}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 176; - uint8_t client_id_bytes[] = {0xa4, 0xb5, 0xa6, 0x80, 0x72, 0x81, 0x1a, 0xb8, 0x72, 0x55, 0x62, 0x7a, - 0x4a, 0xb1, 0x57, 0x49, 0x55, 0x2b, 0x9e, 0x7f, 0x1, 0x15, 0xa4, 0xa9}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.keep_alive = 19508; + uint8_t client_id_bytes[] = {0x7c, 0xee, 0x3e}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa7, 0x56, 0x76}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xee}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x1f, 0x65, 0x66, 0x4d, 0x63, 0x59, 0xf5, 0x73}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe0, 0xa7, 0xb2, 0x56, 0x62, 0x7e, 0xde, 0x10, 0xc0, 0x92, 0xc5, 0x85, 0x4c}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6086,55 +5946,65 @@ TEST(Connect311QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "g\164\GS\251\214\154t\217\140l\213\150&{\211\130", _password = Just -// "\187\ESC\201\164\156\195h\241\250v8\t\179\193\251[*\142", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 20540, _connID = "\255k\192]Rmr[\146o,\129", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS0, _willTopic = "e\178\176 \SO\167T!\SOH\NAK;b\193\247\SUB\136\189\199\232", _willMsg = +// "\221}\161\196zS\178P*\152}\254\220\196\216\136\161\220\"\NAK", _willProps = []}), _cleanSession = True, _keepAlive = +// 9446, _connID = "\146\132J\ENQ\144\192\ty\167>\184:C\152\133o\\1C\128\253\189]VH\210", _properties = []} TEST(Connect311QCTest, Encode21) { - uint8_t pkt[] = {0x10, 0x3e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x50, 0x3c, 0x0, 0xc, 0xff, 0x6b, - 0xc0, 0x5d, 0x52, 0x6d, 0x72, 0x5b, 0x92, 0x6f, 0x2c, 0x81, 0x0, 0x10, 0x67, 0xa4, 0x1d, 0xfb, - 0xd6, 0x9a, 0x74, 0xd9, 0x8c, 0x6c, 0xd5, 0x96, 0x26, 0x7b, 0xd3, 0x82, 0x0, 0x12, 0xbb, 0x1b, - 0xc9, 0xa4, 0x9c, 0xc3, 0x68, 0xf1, 0xfa, 0x76, 0x38, 0x9, 0xb3, 0xc1, 0xfb, 0x5b, 0x2a, 0x8e}; + uint8_t pkt[] = {0x10, 0x51, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x24, 0xe6, 0x0, 0x1a, 0x92, 0x84, 0x4a, + 0x5, 0x90, 0xc0, 0x9, 0x79, 0xa7, 0x3e, 0xb8, 0x3a, 0x43, 0x98, 0x85, 0x6f, 0x5c, 0x31, 0x43, 0x80, + 0xfd, 0xbd, 0x5d, 0x56, 0x48, 0xd2, 0x0, 0x13, 0x65, 0xb2, 0xb0, 0x20, 0xe, 0xa7, 0x54, 0x21, 0x1, + 0x15, 0x3b, 0x62, 0xc1, 0xf7, 0x1a, 0x88, 0xbd, 0xc7, 0xe8, 0x0, 0x14, 0xdd, 0x7d, 0xa1, 0xc4, 0x7a, + 0x53, 0xb2, 0x50, 0x2a, 0x98, 0x7d, 0xfe, 0xdc, 0xc4, 0xd8, 0x88, 0xa1, 0xdc, 0x22, 0x15}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x65, 0xb2, 0xb0, 0x20, 0xe, 0xa7, 0x54, 0x21, 0x1, 0x15, + 0x3b, 0x62, 0xc1, 0xf7, 0x1a, 0x88, 0xbd, 0xc7, 0xe8}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xdd, 0x7d, 0xa1, 0xc4, 0x7a, 0x53, 0xb2, 0x50, 0x2a, 0x98, + 0x7d, 0xfe, 0xdc, 0xc4, 0xd8, 0x88, 0xa1, 0xdc, 0x22, 0x15}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 20540; - uint8_t client_id_bytes[] = {0xff, 0x6b, 0xc0, 0x5d, 0x52, 0x6d, 0x72, 0x5b, 0x92, 0x6f, 0x2c, 0x81}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 9446; + uint8_t client_id_bytes[] = {0x92, 0x84, 0x4a, 0x5, 0x90, 0xc0, 0x9, 0x79, 0xa7, 0x3e, 0xb8, 0x3a, 0x43, + 0x98, 0x85, 0x6f, 0x5c, 0x31, 0x43, 0x80, 0xfd, 0xbd, 0x5d, 0x56, 0x48, 0xd2}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x67, 0xa4, 0x1d, 0xfb, 0xd6, 0x9a, 0x74, 0xd9, - 0x8c, 0x6c, 0xd5, 0x96, 0x26, 0x7b, 0xd3, 0x82}; - lwmqtt_string_t username = {16, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xbb, 0x1b, 0xc9, 0xa4, 0x9c, 0xc3, 0x68, 0xf1, 0xfa, - 0x76, 0x38, 0x9, 0xb3, 0xc1, 0xfb, 0x5b, 0x2a, 0x8e}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\130\153\246\DLEX\252\184\254\209\234/\229\190\&1k\ENQ\DC1\DEL\186", _password = -// Just "\152\245\222\230\235\f!z\243\&9\224P\250\231\236#\205V", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS1, _willTopic = "\199\149\CAND\190\238\210\161\204\&8C\192\168'\162\198\250\r\142\&0\250", _willMsg = -// "OUI", _willProps = []}), _cleanSession = False, _keepAlive = 63, _connID = -// "\FS\196\a\216\236\229ts[;\209\141\182\141\154#\226\&7H.\199\195\f-\159\183\252c\235", _properties = []} +// ConnectRequest {_username = Just "0\219\168\207u\209FQb\194\255\SYN:\216` ", _password = Just +// "\224\206\238\173\&1\157LS\135\STX\RSL\213\178A\184\&6\185\133\180r1\191O\169\153m\246O", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = "\210\254({", _willMsg = "Z\128\204\SOH\NUL\v%", _willProps = +// []}), _cleanSession = False, _keepAlive = 10802, _connID = "\229U\154\147\141\141XPP\181I\226\208\SYN", _properties = +// []} TEST(Connect311QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0x6e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x0, 0x3f, 0x0, 0x1d, 0x1c, 0xc4, - 0x7, 0xd8, 0xec,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 0xf6, 0x4f}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6145,31 +6015,29 @@ TEST(Connect311QCTest, Encode22) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc7, 0x95, 0x18, 0x44, 0xbe, 0xee, 0xd2, 0xa1, 0xcc, 0x38, 0x43, - 0xc0, 0xa8, 0x27, 0xa2, 0xc6, 0xfa, 0xd, 0x8e, 0x30, 0xfa}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4f, 0x55, 0x49}; - lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xd2, 0xfe, 0x28, 0x7b}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5a, 0x80, 0xcc, 0x1, 0x0, 0xb, 0x25}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 63; - uint8_t client_id_bytes[] = {0x1c, 0xc4, 0x7, 0xd8, 0xec, 0xe5, 0x74, 0x73, 0x5b, 0x3b, 0xd1, 0x8d, 0xb6, 0x8d, 0x9a, - 0x23, 0xe2, 0x37, 0x48, 0x2e, 0xc7, 0xc3, 0xc, 0x2d, 0x9f, 0xb7, 0xfc, 0x63, 0xeb}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.keep_alive = 10802; + uint8_t client_id_bytes[] = {0xe5, 0x55, 0x9a, 0x93, 0x8d, 0x8d, 0x58, 0x50, 0x50, 0xb5, 0x49, 0xe2, 0xd0, 0x16}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x82, 0x99, 0xf6, 0x10, 0x58, 0xfc, 0xb8, 0xfe, 0xd1, 0xea, - 0x2f, 0xe5, 0xbe, 0x31, 0x6b, 0x5, 0x11, 0x7f, 0xba}; - lwmqtt_string_t username = {19, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x30, 0xdb, 0xa8, 0xcf, 0x75, 0xd1, 0x46, 0x51, + 0x62, 0xc2, 0xff, 0x16, 0x3a, 0xd8, 0x60, 0x20}; + lwmqtt_string_t username = {16, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x98, 0xf5, 0xde, 0xe6, 0xeb, 0xc, 0x21, 0x7a, 0xf3, - 0x39, 0xe0, 0x50, 0xfa, 0xe7, 0xec, 0x23, 0xcd, 0x56}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe0, 0xce, 0xee, 0xad, 0x31, 0x9d, 0x4c, 0x53, 0x87, 0x2, 0x1e, 0x4c, 0xd5, 0xb2, 0x41, + 0xb8, 0x36, 0xb9, 0x85, 0xb4, 0x72, 0x31, 0xbf, 0x4f, 0xa9, 0x99, 0x6d, 0xf6, 0x4f}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6179,21 +6047,13 @@ TEST(Connect311QCTest, Encode22) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "\RS\167\162\&6\154\242\173\187\159\228M\149\143\133]\FS%\242\219\239\232\172\&7\STX\236\&3\229", _password = Just -// "\223\143\v\237\t/\227\FS\210\243\130\206\v\180\r", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, -// _willTopic = " \SI\153\ACK\213(Df\150\253\194\171\158r\205\203cW", _willMsg = -// "\221\140d\205\238w\156m\218w\195\&4\189\&2\208\177", _willProps = []}), _cleanSession = False, _keepAlive = 32455, -// _connID = "\199f\232=\172\DEL\148R>\167\\X;\235 \DC1\189\173\203WE\245", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\159V\EOT\ENQR\a\169J\EOT", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\SI\SO", _willMsg = "\SUB{\SO\EM\190", _willProps = []}), +// _cleanSession = True, _keepAlive = 3695, _connID = "V\159\161\231\237\200\154\134\206X\143", _properties = []} TEST(Connect311QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0x76, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x7e, 0xc7, 0x0, 0x16, 0xc7, - 0x66, 0xe8, 0x3d, 0xac, 0x7f, 0x94, 0x52, 0x3e, 0xa7, 0x5c, 0x58, 0x3b, 0xeb, 0x20, 0x11, - 0xbd, 0xad, 0xcb, 0x57, 0x45, 0xf5, 0x0, 0x12, 0x20, 0xf, 0x99, 0x6, 0xd5, 0x28, 0x44, - 0x66, 0x96, 0xfd, 0xc2, 0xab, 0x9e, 0x72, 0xcd, 0xcb, 0x63, 0x57, 0x0, 0x10, 0xdd, 0x8c, - 0x64, 0xcd, 0xee, 0x77, 0x9c, 0x6d, 0xda, 0x77, 0xc3, 0x34, 0xbd, 0x32, 0xd0, 0xb1, 0x0, - 0x1b, 0x1e, 0xa7, 0xa2, 0x36, 0x9a, 0xf2, 0xad, 0xbb, 0x9f, 0xe4, 0x4d, 0x95, 0x8f, 0x85, - 0x5d, 0x1c, 0x25, 0xf2, 0xdb, 0xef, 0xe8, 0xac, 0x37, 0x2, 0xec, 0x33, 0xe5, 0x0, 0xf, - 0xdf, 0x8f, 0xb, 0xed, 0x9, 0x2f, 0xe3, 0x1c, 0xd2, 0xf3, 0x82, 0xce, 0xb, 0xb4, 0xd}; + uint8_t pkt[] = {0x10, 0x22, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0xe, 0x6f, + 0x0, 0xb, 0x56, 0x9f, 0xa1, 0xe7, 0xed, 0xc8, 0x9a, 0x86, 0xce, 0x58, + 0x8f, 0x0, 0x2, 0xf, 0xe, 0x0, 0x5, 0x1a, 0x7b, 0xe, 0x19, 0xbe}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6204,31 +6064,24 @@ TEST(Connect311QCTest, Encode23) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x20, 0xf, 0x99, 0x6, 0xd5, 0x28, 0x44, 0x66, 0x96, - 0xfd, 0xc2, 0xab, 0x9e, 0x72, 0xcd, 0xcb, 0x63, 0x57}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xdd, 0x8c, 0x64, 0xcd, 0xee, 0x77, 0x9c, 0x6d, - 0xda, 0x77, 0xc3, 0x34, 0xbd, 0x32, 0xd0, 0xb1}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xf, 0xe}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1a, 0x7b, 0xe, 0x19, 0xbe}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32455; - uint8_t client_id_bytes[] = {0xc7, 0x66, 0xe8, 0x3d, 0xac, 0x7f, 0x94, 0x52, 0x3e, 0xa7, 0x5c, - 0x58, 0x3b, 0xeb, 0x20, 0x11, 0xbd, 0xad, 0xcb, 0x57, 0x45, 0xf5}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 3695; + uint8_t client_id_bytes[] = {0x56, 0x9f, 0xa1, 0xe7, 0xed, 0xc8, 0x9a, 0x86, 0xce, 0x58, 0x8f}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x1e, 0xa7, 0xa2, 0x36, 0x9a, 0xf2, 0xad, 0xbb, 0x9f, 0xe4, 0x4d, 0x95, 0x8f, 0x85, - 0x5d, 0x1c, 0x25, 0xf2, 0xdb, 0xef, 0xe8, 0xac, 0x37, 0x2, 0xec, 0x33, 0xe5}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xdf, 0x8f, 0xb, 0xed, 0x9, 0x2f, 0xe3, 0x1c, 0xd2, 0xf3, 0x82, 0xce, 0xb, 0xb4, 0xd}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x9f, 0x56, 0x4, 0x5, 0x52, 0x7, 0xa9, 0x4a, 0x4}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6238,42 +6091,71 @@ TEST(Connect311QCTest, Encode23) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = -// 14647, _connID = "\173\255n}\129\NAK", _properties = []} +// ConnectRequest {_username = Just "\US\184\177\250\165\178m\202\177\229\250+d\229", _password = Just "4#", _lastWill = +// Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\DLE\157\231\207\176$D\205\246cj\139\212\151\237\181\225\198\182>C\FS", _willMsg = +// "\242\166\\\SYN\191\r\DC2d8\129\239\138\135\230\214]\CAN#K\206\USb%R\215\254\242\255\GS\139", _willProps = []}), +// _cleanSession = True, _keepAlive = 21935, _connID = "", _properties = []} TEST(Connect311QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x12, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, - 0x39, 0x37, 0x0, 0x6, 0xad, 0xff, 0x6e, 0x7d, 0x81, 0x15}; + uint8_t pkt[] = {0x10, 0x58, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x55, 0xaf, 0x0, 0x0, 0x0, + 0x16, 0x10, 0x9d, 0xe7, 0xcf, 0xb0, 0x24, 0x44, 0xcd, 0xf6, 0x63, 0x6a, 0x8b, 0xd4, 0x97, + 0xed, 0xb5, 0xe1, 0xc6, 0xb6, 0x3e, 0x43, 0x1c, 0x0, 0x1e, 0xf2, 0xa6, 0x5c, 0x16, 0xbf, + 0xd, 0x12, 0x64, 0x38, 0x81, 0xef, 0x8a, 0x87, 0xe6, 0xd6, 0x5d, 0x18, 0x23, 0x4b, 0xce, + 0x1f, 0x62, 0x25, 0x52, 0xd7, 0xfe, 0xf2, 0xff, 0x1d, 0x8b, 0x0, 0xe, 0x1f, 0xb8, 0xb1, + 0xfa, 0xa5, 0xb2, 0x6d, 0xca, 0xb1, 0xe5, 0xfa, 0x2b, 0x64, 0xe5, 0x0, 0x2, 0x34, 0x23}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x10, 0x9d, 0xe7, 0xcf, 0xb0, 0x24, 0x44, 0xcd, 0xf6, 0x63, 0x6a, + 0x8b, 0xd4, 0x97, 0xed, 0xb5, 0xe1, 0xc6, 0xb6, 0x3e, 0x43, 0x1c}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf2, 0xa6, 0x5c, 0x16, 0xbf, 0xd, 0x12, 0x64, 0x38, 0x81, + 0xef, 0x8a, 0x87, 0xe6, 0xd6, 0x5d, 0x18, 0x23, 0x4b, 0xce, + 0x1f, 0x62, 0x25, 0x52, 0xd7, 0xfe, 0xf2, 0xff, 0x1d, 0x8b}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 14647; - uint8_t client_id_bytes[] = {0xad, 0xff, 0x6e, 0x7d, 0x81, 0x15}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.keep_alive = 21935; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t username_bytes[] = {0x1f, 0xb8, 0xb1, 0xfa, 0xa5, 0xb2, 0x6d, 0xca, 0xb1, 0xe5, 0xfa, 0x2b, 0x64, 0xe5}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x34, 0x23}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "/&", _password = Just -// "8\SUB\143\t\ESC\220%\187\ESC1\163\&9\253\207\185F\t\213N\NUL\"", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS0, _willTopic = "\209Ho\130\233\&6\203E\189\STX\204\202LG\160\188C[\GS&\169w\NUL\208\161", _willMsg = -// "C", _willProps = []}), _cleanSession = False, _keepAlive = 17899, _connID = ".hc\n\135\206/\236\&0\221\216\155\236", -// _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\223\FS\149\212{Q\139+/s\191U\174l\n\173", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "AbQ~\153\211\195\255aR\240\202u\223", _willMsg = +// "\254\139\131\221\&7y\167\ETX\187I\188O~e\199", _willProps = []}), _cleanSession = False, _keepAlive = 5033, _connID +// = "\168\223\181\140\b\149\&4\184\157\178\201.\ETX\169Tm\178;\228b\\\246\DLE", _properties = []} TEST(Connect311QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0x52, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x45, 0xeb, 0x0, 0xd, 0x2e, 0x68, 0x63, - 0xa, 0x87, 0xce, 0x2f, 0xec, 0x30, 0xdd, 0xd8, 0x9b, 0xec, 0x0, 0x19, 0xd1, 0x48, 0x6f, 0x82, 0xe9, - 0x36, 0xcb, 0x45, 0xbd, 0x2, 0xcc, 0xca, 0x4c, 0x47, 0xa0, 0xbc, 0x43, 0x5b, 0x1d, 0x26, 0xa9, 0x77, - 0x0, 0xd0, 0xa1, 0x0, 0x1, 0x43, 0x0, 0x2, 0x2f, 0x26, 0x0, 0x15, 0x38, 0x1a, 0x8f, 0x9, 0x1b, - 0xdc, 0x25, 0xbb, 0x1b, 0x31, 0xa3, 0x39, 0xfd, 0xcf, 0xb9, 0x46, 0x9, 0xd5, 0x4e, 0x0, 0x22}; + uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x13, 0xa9, 0x0, 0x17, + 0xa8, 0xdf, 0xb5, 0x8c, 0x8, 0x95, 0x34, 0xb8, 0x9d, 0xb2, 0xc9, 0x2e, 0x3, 0xa9, + 0x54, 0x6d, 0xb2, 0x3b, 0xe4, 0x62, 0x5c, 0xf6, 0x10, 0x0, 0xe, 0x41, 0x62, 0x51, + 0x7e, 0x99, 0xd3, 0xc3, 0xff, 0x61, 0x52, 0xf0, 0xca, 0x75, 0xdf, 0x0, 0xf, 0xfe, + 0x8b, 0x83, 0xdd, 0x37, 0x79, 0xa7, 0x3, 0xbb, 0x49, 0xbc, 0x4f, 0x7e, 0x65, 0xc7}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6284,29 +6166,27 @@ TEST(Connect311QCTest, Encode25) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd1, 0x48, 0x6f, 0x82, 0xe9, 0x36, 0xcb, 0x45, 0xbd, 0x2, 0xcc, 0xca, 0x4c, - 0x47, 0xa0, 0xbc, 0x43, 0x5b, 0x1d, 0x26, 0xa9, 0x77, 0x0, 0xd0, 0xa1}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x43}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x41, 0x62, 0x51, 0x7e, 0x99, 0xd3, 0xc3, 0xff, 0x61, 0x52, 0xf0, 0xca, 0x75, 0xdf}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfe, 0x8b, 0x83, 0xdd, 0x37, 0x79, 0xa7, 0x3, + 0xbb, 0x49, 0xbc, 0x4f, 0x7e, 0x65, 0xc7}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 17899; - uint8_t client_id_bytes[] = {0x2e, 0x68, 0x63, 0xa, 0x87, 0xce, 0x2f, 0xec, 0x30, 0xdd, 0xd8, 0x9b, 0xec}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.keep_alive = 5033; + uint8_t client_id_bytes[] = {0xa8, 0xdf, 0xb5, 0x8c, 0x8, 0x95, 0x34, 0xb8, 0x9d, 0xb2, 0xc9, 0x2e, + 0x3, 0xa9, 0x54, 0x6d, 0xb2, 0x3b, 0xe4, 0x62, 0x5c, 0xf6, 0x10}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2f, 0x26}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x38, 0x1a, 0x8f, 0x9, 0x1b, 0xdc, 0x25, 0xbb, 0x1b, 0x31, 0xa3, - 0x39, 0xfd, 0xcf, 0xb9, 0x46, 0x9, 0xd5, 0x4e, 0x0, 0x22}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xdf, 0x1c, 0x95, 0xd4, 0x7b, 0x51, 0x8b, 0x2b, + 0x2f, 0x73, 0xbf, 0x55, 0xae, 0x6c, 0xa, 0xad}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6316,19 +6196,17 @@ TEST(Connect311QCTest, Encode25) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "N\203\159\210\235ac\RS\168\231\220r'\253\200\162\192\166\149\231\221", _password = -// Just "\174,\168L\134y\NUL\129\t\237\152\134\184\222\US\168\208\"|\246\140=\236\196~\b\150\246\216\164", _lastWill = -// Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\218I\179[\161\209\ESC}h\205FPB@K\133", _willMsg -// = "2\215\135\225\197N", _willProps = []}), _cleanSession = False, _keepAlive = 30481, _connID = -// "\132\129b\222=>\197\164\SO\236\234\204O\202\240\150\&0\186\167", _properties = []} +// ConnectRequest {_username = Just "Q\ESC&\174\247\148\240\DEL]\244\244\245", _password = Just "*\202 ;\132", _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\130\&6pS\DC2\ACK(Y\152Y\FS\150\ETBy\207\136\204", _willMsg = +// "\164w\254._0\196?\182\141eY\201\165\141n\163\251|\199\160", _willProps = []}), _cleanSession = False, _keepAlive = +// 6835, _connID = "=7\240F\243\217", _properties = []} TEST(Connect311QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0x70, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc4, 0x77, 0x11, 0x0, 0x13, 0x84, 0x81, 0x62, - 0xde, 0x3d, 0x3e, 0xc5, 0xa4, 0xe, 0xec, 0xea, 0xcc, 0x4f, 0xca, 0xf0, 0x96, 0x30, 0xba, 0xa7, 0x0, - 0x10, 0xda, 0x49, 0xb3, 0x5b, 0xa1, 0xd1, 0x1b, 0x7d, 0x68, 0xcd, 0x46, 0x50, 0x42, 0x40, 0x4b, 0x85, - 0x0, 0x6, 0x32, 0xd7, 0x87, 0xe1, 0xc5, 0x4e, 0x0, 0x15, 0x4e, 0xcb, 0x9f, 0xd2, 0xeb, 0x61, 0x63, - 0x1e, 0xa8, 0xe7, 0xdc, 0x72, 0x27, 0xfd, 0xc8, 0xa2, 0xc0, 0xa6, 0x95, 0xe7, 0xdd, 0x0, 0x1e, 0xae, - 0x2c, 0xa8, 0x4c, 0x86, 0x79, 0x0, 0x81, 0x9, 0xed, 0x98, 0x86, 0xb8, 0xde, 0x1f, 0xa8, 0xd0, 0x22, - 0x7c, 0xf6, 0x8c, 0x3d, 0xec, 0xc4, 0x7e, 0x8, 0x96, 0xf6, 0xd8, 0xa4}; + uint8_t pkt[] = {0x10, 0x51, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x1a, 0xb3, 0x0, 0x6, 0x3d, 0x37, 0xf0, + 0x46, 0xf3, 0xd9, 0x0, 0x11, 0x82, 0x36, 0x70, 0x53, 0x12, 0x6, 0x28, 0x59, 0x98, 0x59, 0x1c, 0x96, + 0x17, 0x79, 0xcf, 0x88, 0xcc, 0x0, 0x15, 0xa4, 0x77, 0xfe, 0x2e, 0x5f, 0x30, 0xc4, 0x3f, 0xb6, 0x8d, + 0x65, 0x59, 0xc9, 0xa5, 0x8d, 0x6e, 0xa3, 0xfb, 0x7c, 0xc7, 0xa0, 0x0, 0xc, 0x51, 0x1b, 0x26, 0xae, + 0xf7, 0x94, 0xf0, 0x7f, 0x5d, 0xf4, 0xf4, 0xf5, 0x0, 0x5, 0x2a, 0xca, 0x20, 0x3b, 0x84}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6339,31 +6217,29 @@ TEST(Connect311QCTest, Encode26) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xda, 0x49, 0xb3, 0x5b, 0xa1, 0xd1, 0x1b, 0x7d, - 0x68, 0xcd, 0x46, 0x50, 0x42, 0x40, 0x4b, 0x85}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x32, 0xd7, 0x87, 0xe1, 0xc5, 0x4e}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x82, 0x36, 0x70, 0x53, 0x12, 0x6, 0x28, 0x59, 0x98, + 0x59, 0x1c, 0x96, 0x17, 0x79, 0xcf, 0x88, 0xcc}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa4, 0x77, 0xfe, 0x2e, 0x5f, 0x30, 0xc4, 0x3f, 0xb6, 0x8d, 0x65, + 0x59, 0xc9, 0xa5, 0x8d, 0x6e, 0xa3, 0xfb, 0x7c, 0xc7, 0xa0}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 30481; - uint8_t client_id_bytes[] = {0x84, 0x81, 0x62, 0xde, 0x3d, 0x3e, 0xc5, 0xa4, 0xe, 0xec, - 0xea, 0xcc, 0x4f, 0xca, 0xf0, 0x96, 0x30, 0xba, 0xa7}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.keep_alive = 6835; + uint8_t client_id_bytes[] = {0x3d, 0x37, 0xf0, 0x46, 0xf3, 0xd9}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x4e, 0xcb, 0x9f, 0xd2, 0xeb, 0x61, 0x63, 0x1e, 0xa8, 0xe7, 0xdc, - 0x72, 0x27, 0xfd, 0xc8, 0xa2, 0xc0, 0xa6, 0x95, 0xe7, 0xdd}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x51, 0x1b, 0x26, 0xae, 0xf7, 0x94, 0xf0, 0x7f, 0x5d, 0xf4, 0xf4, 0xf5}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xae, 0x2c, 0xa8, 0x4c, 0x86, 0x79, 0x0, 0x81, 0x9, 0xed, 0x98, 0x86, 0xb8, 0xde, 0x1f, - 0xa8, 0xd0, 0x22, 0x7c, 0xf6, 0x8c, 0x3d, 0xec, 0xc4, 0x7e, 0x8, 0x96, 0xf6, 0xd8, 0xa4}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x2a, 0xca, 0x20, 0x3b, 0x84}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6373,19 +6249,19 @@ TEST(Connect311QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "eBV0^b\231\GS\250\n\203\224", _password = Just -// "\240\177\187\244\250c\"\200Pw\189\163m|\131\&5*\177\169]", _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS1, _willTopic = "\b,([w\253\205\CAN\167\199\238\&0\171\SOHj\206\NUL\245\243\144\169\b\226\180\134\154}\214\194", -// _willMsg = "\181aO\128(\188\ETB", _willProps = []}), _cleanSession = False, _keepAlive = 3521, _connID = -// "\205A\247\ACK\129\&6\196\202\192<\208z\234>\ETB\DC2\195\208\221\STX\DC1L\146s", _properties = []} +// ConnectRequest {_username = Just ">\GSG\161K\206,\183\NAKu{\239\227y\214\238\251\157?\147!,XQ\180\vF\251P", _password +// = Just "\f\192\209\&7\135\205f\134\181\170)xCW.\190E", _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\236\202:\200\SO\EMYd\145y6:\171-\DC4 \194", _willMsg = +// "\241\156\177\145\136\DC3h\r\128\187P\182\239\173#\153y0o'\158G\149", _willProps = []}), _cleanSession = True, +// _keepAlive = 12883, _connID = "\191\194\&3\136\GS\t\240", _properties = []} TEST(Connect311QCTest, Encode27) { - uint8_t pkt[] = {0x10, 0x70, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0xd, 0xc1, 0x0, 0x18, 0xcd, 0x41, 0xf7, - 0x6, 0x81, 0x36, 0xc4, 0xca, 0xc0, 0x3c, 0xd0, 0x7a, 0xea, 0x3e, 0x17, 0x12, 0xc3, 0xd0, 0xdd, 0x2, - 0x11, 0x4c, 0x92, 0x73, 0x0, 0x1d, 0x8, 0x2c, 0x28, 0x5b, 0x77, 0xfd, 0xcd, 0x18, 0xa7, 0xc7, 0xee, - 0x30, 0xab, 0x1, 0x6a, 0xce, 0x0, 0xf5, 0xf3, 0x90, 0xa9, 0x8, 0xe2, 0xb4, 0x86, 0x9a, 0x7d, 0xd6, - 0xc2, 0x0, 0x7, 0xb5, 0x61, 0x4f, 0x80, 0x28, 0xbc, 0x17, 0x0, 0xc, 0x65, 0x42, 0x56, 0x30, 0x5e, - 0x62, 0xe7, 0x1d, 0xfa, 0xa, 0xcb, 0xe0, 0x0, 0x14, 0xf0, 0xb1, 0xbb, 0xf4, 0xfa, 0x63, 0x22, 0xc8, - 0x50, 0x77, 0xbd, 0xa3, 0x6d, 0x7c, 0x83, 0x35, 0x2a, 0xb1, 0xa9, 0x5d}; + uint8_t pkt[] = {0x10, 0x71, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x32, 0x53, 0x0, 0x7, 0xbf, 0xc2, 0x33, + 0x88, 0x1d, 0x9, 0xf0, 0x0, 0x11, 0xec, 0xca, 0x3a, 0xc8, 0xe, 0x19, 0x59, 0x64, 0x91, 0x79, 0x36, + 0x3a, 0xab, 0x2d, 0x14, 0x20, 0xc2, 0x0, 0x17, 0xf1, 0x9c, 0xb1, 0x91, 0x88, 0x13, 0x68, 0xd, 0x80, + 0xbb, 0x50, 0xb6, 0xef, 0xad, 0x23, 0x99, 0x79, 0x30, 0x6f, 0x27, 0x9e, 0x47, 0x95, 0x0, 0x1d, 0x3e, + 0x1d, 0x47, 0xa1, 0x4b, 0xce, 0x2c, 0xb7, 0x15, 0x75, 0x7b, 0xef, 0xe3, 0x79, 0xd6, 0xee, 0xfb, 0x9d, + 0x3f, 0x93, 0x21, 0x2c, 0x58, 0x51, 0xb4, 0xb, 0x46, 0xfb, 0x50, 0x0, 0x11, 0xc, 0xc0, 0xd1, 0x37, + 0x87, 0xcd, 0x66, 0x86, 0xb5, 0xaa, 0x29, 0x78, 0x43, 0x57, 0x2e, 0xbe, 0x45}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6396,30 +6272,31 @@ TEST(Connect311QCTest, Encode27) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8, 0x2c, 0x28, 0x5b, 0x77, 0xfd, 0xcd, 0x18, 0xa7, 0xc7, 0xee, 0x30, 0xab, 0x1, 0x6a, - 0xce, 0x0, 0xf5, 0xf3, 0x90, 0xa9, 0x8, 0xe2, 0xb4, 0x86, 0x9a, 0x7d, 0xd6, 0xc2}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb5, 0x61, 0x4f, 0x80, 0x28, 0xbc, 0x17}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xec, 0xca, 0x3a, 0xc8, 0xe, 0x19, 0x59, 0x64, 0x91, + 0x79, 0x36, 0x3a, 0xab, 0x2d, 0x14, 0x20, 0xc2}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf1, 0x9c, 0xb1, 0x91, 0x88, 0x13, 0x68, 0xd, 0x80, 0xbb, 0x50, 0xb6, + 0xef, 0xad, 0x23, 0x99, 0x79, 0x30, 0x6f, 0x27, 0x9e, 0x47, 0x95}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3521; - uint8_t client_id_bytes[] = {0xcd, 0x41, 0xf7, 0x6, 0x81, 0x36, 0xc4, 0xca, 0xc0, 0x3c, 0xd0, 0x7a, - 0xea, 0x3e, 0x17, 0x12, 0xc3, 0xd0, 0xdd, 0x2, 0x11, 0x4c, 0x92, 0x73}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 12883; + uint8_t client_id_bytes[] = {0xbf, 0xc2, 0x33, 0x88, 0x1d, 0x9, 0xf0}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x65, 0x42, 0x56, 0x30, 0x5e, 0x62, 0xe7, 0x1d, 0xfa, 0xa, 0xcb, 0xe0}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x3e, 0x1d, 0x47, 0xa1, 0x4b, 0xce, 0x2c, 0xb7, 0x15, 0x75, 0x7b, 0xef, 0xe3, 0x79, 0xd6, + 0xee, 0xfb, 0x9d, 0x3f, 0x93, 0x21, 0x2c, 0x58, 0x51, 0xb4, 0xb, 0x46, 0xfb, 0x50}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xf0, 0xb1, 0xbb, 0xf4, 0xfa, 0x63, 0x22, 0xc8, 0x50, 0x77, - 0xbd, 0xa3, 0x6d, 0x7c, 0x83, 0x35, 0x2a, 0xb1, 0xa9, 0x5d}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xc, 0xc0, 0xd1, 0x37, 0x87, 0xcd, 0x66, 0x86, 0xb5, + 0xaa, 0x29, 0x78, 0x43, 0x57, 0x2e, 0xbe, 0x45}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6429,19 +6306,15 @@ TEST(Connect311QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "\v\169[\202\FS\206\145\142I\167&I\169k\b\160XudF\138\227\147V\252\193\134\197", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\223\&5$\DELC3\210\149\FS\188b\147\NUL\203\&8\177\&6\141S\"\236\215C", _willMsg = -// "\137Fydy\130\218\t\246Eu\206\188[\241P\186\235\236", _willProps = []}), _cleanSession = True, _keepAlive = 17383, -// _connID = "\146\157\196~\185Q\216\228Q\237\164K\154M\STX\226\133\244\158\188\177 \245\198\168", _properties = []} +// ConnectRequest {_username = Just "\148o\200m\186<\174\187@H*\199\199k\241N\207z\181$\235z\253j\134{", _password = +// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "", _willMsg = +// "U\STX\188\199\130;", _willProps = []}), _cleanSession = True, _keepAlive = 3904, _connID = +// "\197#\190r4\236\133\t\SIY\198\226\213\244\145", _properties = []} TEST(Connect311QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2e, 0x43, 0xe7, 0x0, 0x19, 0x92, - 0x9d, 0xc4, 0x7e, 0xb9, 0x51, 0xd8, 0xe4, 0x51, 0xed, 0xa4, 0x4b, 0x9a, 0x4d, 0x2, 0xe2, - 0x85, 0xf4, 0x9e, 0xbc, 0xb1, 0x20, 0xf5, 0xc6, 0xa8, 0x0, 0x17, 0xdf, 0x35, 0x24, 0x7f, - 0x43, 0x33, 0xd2, 0x95, 0x1c, 0xbc, 0x62, 0x93, 0x0, 0xcb, 0x38, 0xb1, 0x36, 0x8d, 0x53, - 0x22, 0xec, 0xd7, 0x43, 0x0, 0x13, 0x89, 0x46, 0x79, 0x64, 0x79, 0x82, 0xda, 0x9, 0xf6, - 0x45, 0x75, 0xce, 0xbc, 0x5b, 0xf1, 0x50, 0xba, 0xeb, 0xec}; + uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0xf, 0x40, 0x0, 0xf, 0xc5, 0x23, 0xbe, + 0x72, 0x34, 0xec, 0x85, 0x9, 0xf, 0x59, 0xc6, 0xe2, 0xd5, 0xf4, 0x91, 0x0, 0x0, 0x0, 0x6, 0x55, + 0x2, 0xbc, 0xc7, 0x82, 0x3b, 0x0, 0x1a, 0x94, 0x6f, 0xc8, 0x6d, 0xba, 0x3c, 0xae, 0xbb, 0x40, 0x48, + 0x2a, 0xc7, 0xc7, 0x6b, 0xf1, 0x4e, 0xcf, 0x7a, 0xb5, 0x24, 0xeb, 0x7a, 0xfd, 0x6a, 0x86, 0x7b}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6452,29 +6325,26 @@ TEST(Connect311QCTest, Encode28) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xdf, 0x35, 0x24, 0x7f, 0x43, 0x33, 0xd2, 0x95, 0x1c, 0xbc, 0x62, 0x93, - 0x0, 0xcb, 0x38, 0xb1, 0x36, 0x8d, 0x53, 0x22, 0xec, 0xd7, 0x43}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x89, 0x46, 0x79, 0x64, 0x79, 0x82, 0xda, 0x9, 0xf6, 0x45, - 0x75, 0xce, 0xbc, 0x5b, 0xf1, 0x50, 0xba, 0xeb, 0xec}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x55, 0x2, 0xbc, 0xc7, 0x82, 0x3b}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 17383; - uint8_t client_id_bytes[] = {0x92, 0x9d, 0xc4, 0x7e, 0xb9, 0x51, 0xd8, 0xe4, 0x51, 0xed, 0xa4, 0x4b, 0x9a, - 0x4d, 0x2, 0xe2, 0x85, 0xf4, 0x9e, 0xbc, 0xb1, 0x20, 0xf5, 0xc6, 0xa8}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.keep_alive = 3904; + uint8_t client_id_bytes[] = {0xc5, 0x23, 0xbe, 0x72, 0x34, 0xec, 0x85, 0x9, 0xf, 0x59, 0xc6, 0xe2, 0xd5, 0xf4, 0x91}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xb, 0xa9, 0x5b, 0xca, 0x1c, 0xce, 0x91, 0x8e, 0x49, 0xa7, 0x26, 0x49, 0xa9, 0x6b, - 0x8, 0xa0, 0x58, 0x75, 0x64, 0x46, 0x8a, 0xe3, 0x93, 0x56, 0xfc, 0xc1, 0x86, 0xc5}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; - opts.password = password; + uint8_t username_bytes[] = {0x94, 0x6f, 0xc8, 0x6d, 0xba, 0x3c, 0xae, 0xbb, 0x40, 0x48, 0x2a, 0xc7, 0xc7, + 0x6b, 0xf1, 0x4e, 0xcf, 0x7a, 0xb5, 0x24, 0xeb, 0x7a, 0xfd, 0x6a, 0x86, 0x7b}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; + opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6483,20 +6353,15 @@ TEST(Connect311QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\167\237\156Mq\176\&7F\133;p\STX\164\219,\196,U\NUL\171\ETB\144M", _password = Just -// "\150'c\159\ETX\DC2\144\212TY\230:\SOHvc'\218\154\US2#1\183\&7", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS2, _willTopic = "\STX\r\249A\250?#\SI\142\224\207\203C3\203\129\232\238\f>C\SUB\149\221\198\\1", -// _willMsg = "u}g.\134\182\153", _willProps = []}), _cleanSession = False, _keepAlive = 2013, _connID = -// "\255\RST!?\165@\128+YC\181-\250\193\183\233\&7\RS\197x\SUB[?\f\227t", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "\166@\DEL\142", _willMsg = "\DC3x\226\245Jp\148\STX%\DC1\141\240\169\253\ETXfd\193t^", _willProps +// = []}), _cleanSession = True, _keepAlive = 24545, _connID = "\183#J\202\157\184-\233Zr\211\247l\185=\182\150\193", +// _properties = []} TEST(Connect311QCTest, Encode29) { - uint8_t pkt[] = {0x10, 0x80, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x7, 0xdd, 0x0, 0x1b, 0xff, 0x1e, - 0x54, 0x21, 0x3f, 0xa5, 0x40, 0x80, 0x2b, 0x59, 0x43, 0xb5, 0x2d, 0xfa, 0xc1, 0xb7, 0xe9, 0x37, 0x1e, - 0xc5, 0x78, 0x1a, 0x5b, 0x3f, 0xc, 0xe3, 0x74, 0x0, 0x1b, 0x2, 0xd, 0xf9, 0x41, 0xfa, 0x3f, 0x23, - 0xf, 0x8e, 0xe0, 0xcf, 0xcb, 0x43, 0x33, 0xcb, 0x81, 0xe8, 0xee, 0xc, 0x3e, 0x43, 0x1a, 0x95, 0xdd, - 0xc6, 0x5c, 0x31, 0x0, 0x7, 0x75, 0x7d, 0x67, 0x2e, 0x86, 0xb6, 0x99, 0x0, 0x17, 0xa7, 0xed, 0x9c, - 0x4d, 0x71, 0xb0, 0x37, 0x46, 0x85, 0x3b, 0x70, 0x2, 0xa4, 0xdb, 0x2c, 0xc4, 0x2c, 0x55, 0x0, 0xab, - 0x17, 0x90, 0x4d, 0x0, 0x18, 0x96, 0x27, 0x63, 0x9f, 0x3, 0x12, 0x90, 0xd4, 0x54, 0x59, 0xe6, 0x3a, - 0x1, 0x76, 0x63, 0x27, 0xda, 0x9a, 0x1f, 0x32, 0x23, 0x31, 0xb7, 0x37}; + uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x5f, 0xe1, 0x0, 0x12, 0xb7, + 0x23, 0x4a, 0xca, 0x9d, 0xb8, 0x2d, 0xe9, 0x5a, 0x72, 0xd3, 0xf7, 0x6c, 0xb9, 0x3d, 0xb6, + 0x96, 0xc1, 0x0, 0x4, 0xa6, 0x40, 0x7f, 0x8e, 0x0, 0x14, 0x13, 0x78, 0xe2, 0xf5, 0x4a, + 0x70, 0x94, 0x2, 0x25, 0x11, 0x8d, 0xf0, 0xa9, 0xfd, 0x3, 0x66, 0x64, 0xc1, 0x74, 0x5e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6507,32 +6372,24 @@ TEST(Connect311QCTest, Encode29) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2, 0xd, 0xf9, 0x41, 0xfa, 0x3f, 0x23, 0xf, 0x8e, 0xe0, 0xcf, 0xcb, 0x43, 0x33, - 0xcb, 0x81, 0xe8, 0xee, 0xc, 0x3e, 0x43, 0x1a, 0x95, 0xdd, 0xc6, 0x5c, 0x31}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x75, 0x7d, 0x67, 0x2e, 0x86, 0xb6, 0x99}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xa6, 0x40, 0x7f, 0x8e}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x13, 0x78, 0xe2, 0xf5, 0x4a, 0x70, 0x94, 0x2, 0x25, 0x11, + 0x8d, 0xf0, 0xa9, 0xfd, 0x3, 0x66, 0x64, 0xc1, 0x74, 0x5e}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 2013; - uint8_t client_id_bytes[] = {0xff, 0x1e, 0x54, 0x21, 0x3f, 0xa5, 0x40, 0x80, 0x2b, 0x59, 0x43, 0xb5, 0x2d, 0xfa, - 0xc1, 0xb7, 0xe9, 0x37, 0x1e, 0xc5, 0x78, 0x1a, 0x5b, 0x3f, 0xc, 0xe3, 0x74}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 24545; + uint8_t client_id_bytes[] = {0xb7, 0x23, 0x4a, 0xca, 0x9d, 0xb8, 0x2d, 0xe9, 0x5a, + 0x72, 0xd3, 0xf7, 0x6c, 0xb9, 0x3d, 0xb6, 0x96, 0xc1}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa7, 0xed, 0x9c, 0x4d, 0x71, 0xb0, 0x37, 0x46, 0x85, 0x3b, 0x70, 0x2, - 0xa4, 0xdb, 0x2c, 0xc4, 0x2c, 0x55, 0x0, 0xab, 0x17, 0x90, 0x4d}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x96, 0x27, 0x63, 0x9f, 0x3, 0x12, 0x90, 0xd4, 0x54, 0x59, 0xe6, 0x3a, - 0x1, 0x76, 0x63, 0x27, 0xda, 0x9a, 0x1f, 0x32, 0x23, 0x31, 0xb7, 0x37}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6541,16 +6398,15 @@ TEST(Connect311QCTest, Encode29) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\182\240\189\t", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = "\187M\164\160l,v\190\218\204Q\220\172R\151\151>", _willMsg = -// "B\157i\190\132.u\233\158\DC3\242]\255\133\181\186\255Z\240\188\227", _willProps = []}), _cleanSession = False, -// _keepAlive = 1282, _connID = "(\191\136\201\182\228\133S\r\250\189X", _properties = []} +// ConnectRequest {_username = Just "\\\143\216", _password = Just "\151\&6\134W]\238P\207\167\&0Z", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "9", _willMsg = +// "]v\243\130\NULm\134'\201\ESCs\176\166\a;\239\EM", _willProps = []}), _cleanSession = True, _keepAlive = 17718, +// _connID = "\225qY\140\214\227+/\167\SI7\177", _properties = []} TEST(Connect311QCTest, Encode30) { - uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x14, 0x5, 0x2, 0x0, 0xc, - 0x28, 0xbf, 0x88, 0xc9, 0xb6, 0xe4, 0x85, 0x53, 0xd, 0xfa, 0xbd, 0x58, 0x0, 0x11, - 0xbb, 0x4d, 0xa4, 0xa0, 0x6c, 0x2c, 0x76, 0xbe, 0xda, 0xcc, 0x51, 0xdc, 0xac, 0x52, - 0x97, 0x97, 0x3e, 0x0, 0x15, 0x42, 0x9d, 0x69, 0xbe, 0x84, 0x2e, 0x75, 0xe9, 0x9e, - 0x13, 0xf2, 0x5d, 0xff, 0x85, 0xb5, 0xba, 0xff, 0x5a, 0xf0, 0xbc, 0xe3}; + uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x45, 0x36, 0x0, 0xc, 0xe1, 0x71, 0x59, + 0x8c, 0xd6, 0xe3, 0x2b, 0x2f, 0xa7, 0xf, 0x37, 0xb1, 0x0, 0x1, 0x39, 0x0, 0x11, 0x5d, 0x76, 0xf3, + 0x82, 0x0, 0x6d, 0x86, 0x27, 0xc9, 0x1b, 0x73, 0xb0, 0xa6, 0x7, 0x3b, 0xef, 0x19, 0x0, 0x3, 0x5c, + 0x8f, 0xd8, 0x0, 0xb, 0x97, 0x36, 0x86, 0x57, 0x5d, 0xee, 0x50, 0xcf, 0xa7, 0x30, 0x5a}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -6561,26 +6417,28 @@ TEST(Connect311QCTest, Encode30) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbb, 0x4d, 0xa4, 0xa0, 0x6c, 0x2c, 0x76, 0xbe, 0xda, - 0xcc, 0x51, 0xdc, 0xac, 0x52, 0x97, 0x97, 0x3e}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x42, 0x9d, 0x69, 0xbe, 0x84, 0x2e, 0x75, 0xe9, 0x9e, 0x13, 0xf2, - 0x5d, 0xff, 0x85, 0xb5, 0xba, 0xff, 0x5a, 0xf0, 0xbc, 0xe3}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x39}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5d, 0x76, 0xf3, 0x82, 0x0, 0x6d, 0x86, 0x27, 0xc9, + 0x1b, 0x73, 0xb0, 0xa6, 0x7, 0x3b, 0xef, 0x19}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 1282; - uint8_t client_id_bytes[] = {0x28, 0xbf, 0x88, 0xc9, 0xb6, 0xe4, 0x85, 0x53, 0xd, 0xfa, 0xbd, 0x58}; + opts.clean_session = true; + opts.keep_alive = 17718; + uint8_t client_id_bytes[] = {0xe1, 0x71, 0x59, 0x8c, 0xd6, 0xe3, 0x2b, 0x2f, 0xa7, 0xf, 0x37, 0xb1}; lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xb6, 0xf0, 0xbd, 0x9}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x5c, 0x8f, 0xd8}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x97, 0x36, 0x86, 0x57, 0x5d, 0xee, 0x50, 0xcf, 0xa7, 0x30, 0x5a}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -6590,245 +6448,291 @@ TEST(Connect311QCTest, Encode30) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "su\219", _password = Just "\245\218", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS2, _willTopic = "\200\218\ENQ\194\150u=", _willMsg = "18\181\155\177B\144\135#\186\ESC", -// _willProps = [PropSessionExpiryInterval 16907,PropAssignedClientIdentifier -// "\164\251\183\146\189\248\f",PropUserProperty "\\\139\180" "\167",PropMessageExpiryInterval -// 20439,PropSharedSubscriptionAvailable 246,PropUserProperty -// "\DC1\128\246\210l\192\248BjzSY\197\NUL\157Hg^\156\132\139" "&H\FSo \156'\216!",PropResponseInformation -// "\165\203\195\162I\140\153\179\147\&3\DC2\242\178L9\177UI\130U\147\RS\234%\231",PropPayloadFormatIndicator -// 212,PropUserProperty "GM\163\t\158T\226\SYN\243\160\235a\176" "`",PropContentType -// "\134\160\vZT\ACK\149\220`",PropSessionExpiryInterval 4579,PropTopicAliasMaximum 22244,PropServerKeepAlive -// 14992,PropMaximumQoS 181,PropServerReference -// "\247\231\181\b\148\177\DEL\240\196\157v?e\f\243\STX\DC2\173\205\205D\152P\239\135 0o",PropAuthenticationMethod -// "3\ETB\218\156/y\239S\RS8\232@m\221|)\200\&7\SI\">:6\185z^\174\220\237n",PropSubscriptionIdentifier -// 27,PropSubscriptionIdentifierAvailable 58,PropMessageExpiryInterval 15968,PropSubscriptionIdentifierAvailable -// 192,PropRetainAvailable 143]}), _cleanSession = True, _keepAlive = 23341, _connID = -// "\167\130W\226#\FSJ:\239#\154)\178i", _properties = [PropAuthenticationData -// "\157\176%_\142\166jk\138\199\158\226\b\197\181J\142\196\218",PropSubscriptionIdentifierAvailable -// 241,PropTopicAliasMaximum 30873,PropSessionExpiryInterval 8383,PropServerKeepAlive 20280,PropResponseTopic -// "\164\FSf?\227\250d\224",PropAuthenticationData -// "\222\STX\SI\169\158\193\143\207\141",PropSubscriptionIdentifierAvailable 189,PropAssignedClientIdentifier -// "",PropCorrelationData "6\140\253\228\176L\DC4K\181M1\179^\"\157do\250",PropTopicAlias 2954,PropTopicAlias -// 9070,PropWildcardSubscriptionAvailable 163,PropRequestProblemInformation 192,PropReasonString -// "KN\219Q\US\SOH\202h\213\NUL\a\166JF\231\ESC\250\249\136\203\SYN\a\249\DLE\242",PropMessageExpiryInterval -// 5860,PropRequestResponseInformation 76,PropSharedSubscriptionAvailable 184]} +// ConnectRequest {_username = Just "\160\151\149a\211\ACK*?\149\202\211vrIu\153\DC2\173\173!\ACK", _password = Just +// "\212\133\STX\STX\240\131p", _lastWill = Nothing, _cleanSession = False, _keepAlive = 1099, _connID = +// "1\a\221\162V\235\244\238\188\&2v1%G\151H4@{\224\180\180\184\194\165\&2\138\141\204", _properties = +// [PropTopicAliasMaximum 31313,PropCorrelationData +// "\EM\156`\194\144Q\221Y\128T\245\213e\134x\b\178\&6\139\210O\142\150\175\244:K\DLE\130",PropResponseTopic +// "\139\&65\223zD[\226\128\144#\142\&5/\237\&0]h\231\145\228\212\253\248p\222k",PropWillDelayInterval +// 16733,PropMessageExpiryInterval 18158,PropSessionExpiryInterval 27136,PropTopicAliasMaximum +// 4386,PropAssignedClientIdentifier +// "VC\234\151/a\191E\ETB\203On\215\244's]\STXPT\204\171\205\ESC/l6\"w!",PropRetainAvailable 236,PropServerReference +// "v\221\208?g\141\SO\&H\174\215\209\DC2\212\DC3*\159\140\231\201\231V\DEL\158\206R\NUL" "f\229\a\160"]} +// ConnectRequest {_username = Just "\245\FSg\131", _password = Just "\SO\141\210", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "\152\255\131ME_\ENQ\227\fVV\141\172", _willMsg = +// "\152\v\143\189\254\149a\FS7i\f_\220\240\209\232", _willProps = [PropTopicAlias 11626,PropMessageExpiryInterval +// 920,PropRetainAvailable 101,PropReceiveMaximum 25442,PropReceiveMaximum 28647,PropReceiveMaximum +// 4995,PropCorrelationData "9\214\188g\235\151#\SOH\254\140/\134@\203",PropServerReference +// "Os\152\233\190\EOT\230/|f\179\219\206\225r\164\196\237D8\185\135,\US\SIu",PropRequestProblemInformation +// 223,PropReceiveMaximum 2060,PropRequestProblemInformation 235,PropMaximumPacketSize 24384,PropSubscriptionIdentifier +// 18,PropServerReference "\150\218w\205\136\136SRq\SI\160a\253\ETB\242\151\SYN\ACK;:)q\174\220",PropResponseTopic +// "r\135\221\128(\174\f\223\NAK\153 \247\168\244R\130t\232\162-\144\189",PropContentType +// "\160\246\188P/(j+(",PropSubscriptionIdentifierAvailable 69,PropAssignedClientIdentifier +// "\212\212\148t\237yC)\\x\DEL\231*a@\154\217>\n",PropSubscriptionIdentifierAvailable 144,PropMaximumPacketSize +// 25477,PropWillDelayInterval 18212,PropContentType "lo\137\203\SO\DC2\143hj\SYNVTE\243\197P",PropAuthenticationMethod +// "",PropResponseTopic "$\220+\241\ACK\255\154\161\\[\196C\230@\183\151\DC1\218\&8",PropMessageExpiryInterval +// 22702,PropCorrelationData "",PropMaximumPacketSize 15828,PropReasonString "\129\177\229",PropResponseInformation +// "\213\128\226\159X>\243\ETX\135}\133\&58\220x\213y\252\v(C=C\205\157\205",PropWillDelayInterval 26379]}), +// _cleanSession = True, _keepAlive = 4861, _connID = "=\b:\142\144", _properties = [PropUserProperty +// "\159\246\235\237\139\128\212\129\\\220\222\223\196\232\172\r)\132\&2" +// "c\CAN\ESC'\DC2\DEL/N\204W-\182\226\228\189k\CAN\241'B\186/\ETX\133\"\193J\137N",PropWildcardSubscriptionAvailable +// 95,PropRetainAvailable 190,PropSubscriptionIdentifierAvailable 194,PropCorrelationData +// "0\ETXL\136\181",PropWildcardSubscriptionAvailable 128,PropRetainAvailable 219,PropUserProperty "s" +// "\139|\244\136\ETB\253\223\191\EOT\DC2I\225G\218\218\190nE\217DR",PropSharedSubscriptionAvailable +// 220,PropRetainAvailable 8,PropRequestProblemInformation 64,PropMessageExpiryInterval 6339,PropMaximumQoS +// 142,PropRequestResponseInformation 171,PropTopicAliasMaximum 27261,PropRequestProblemInformation +// 243,PropReceiveMaximum 26619,PropAuthenticationData "j.\254",PropResponseTopic +// "\189\181JM'!\255\213;d\175\182G~j",PropRetainAvailable 249,PropWillDelayInterval 4276,PropSessionExpiryInterval +// 15218,PropSessionExpiryInterval 26486,PropMessageExpiryInterval 22520,PropSubscriptionIdentifier +// 13,PropResponseInformation "N\b\236\146\171\225\169\acTL{\245/\129[q",PropMaximumQoS 191]} TEST(Connect5QCTest, Encode2) { uint8_t pkt[] = { - 0x10, 0x90, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x46, 0x80, 0x8e, 0x1, 0x8, 0x0, 0x1c, 0x63, - 0xff, 0x5e, 0x58, 0x52, 0xf8, 0x39, 0x20, 0xb7, 0xd5, 0xfb, 0x38, 0x57, 0x1c, 0x72, 0x5c, 0x66, 0x4a, 0xba, 0x91, - 0x71, 0x5d, 0x7f, 0xd3, 0x73, 0x4b, 0xc4, 0x2, 0x2, 0x0, 0x0, 0x17, 0x1e, 0x25, 0x9f, 0x26, 0x0, 0x9, 0x13, - 0xd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 0xa5, 0x65, 0xb, 0xd0, 0x71, 0x82, - 0x63, 0x1e, 0xd3, 0x43, 0x3c, 0x0, 0x15, 0x82, 0x18, 0x33, 0xe0, 0x91, 0xe8, 0x5d, 0xef, 0x91, 0xba, 0xa5, 0xb2, - 0x76, 0xa9, 0x4e, 0x3d, 0x7, 0x2b, 0x9, 0x20, 0x2d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x63, 0xff, 0x5e, 0x58, 0x52, 0xf8, 0x39, 0x20, 0xb7, 0xd5, 0xfb, 0x38, 0x57, 0x1c, - 0x72, 0x5c, 0x66, 0x4a, 0xba, 0x91, 0x71, 0x5d, 0x7f, 0xd3, 0x73, 0x4b, 0xc4, 0x2}; - uint8_t bytesprops2[] = {0x1d, 0xbc, 0x39, 0x97, 0xbf, 0x4d, 0xec, 0x7c, 0xa2}; - uint8_t bytesprops1[] = {0x13, 0xdb, 0xe8, 0x8a, 0xb2, 0xf5, 0xb2, 0xa9, 0x13}; - uint8_t bytesprops3[] = {0xc7, 0x2c, 0x73, 0xcd, 0xb9, 0x79, 0x4e, 0x38, 0xaa, 0x84, 0x90, 0x8a}; - uint8_t bytesprops4[] = {0x76, 0x5f, 0x8a, 0x34, 0x46, 0x20, 0x45, 0xdb, 0xe, 0xd2, 0x64, - 0xd5, 0x8a, 0xa6, 0x6f, 0x85, 0x74, 0x3c, 0xb3, 0x99, 0x9e}; - uint8_t bytesprops6[] = {0x66, 0xe5, 0x7, 0xa0}; - uint8_t bytesprops5[] = {0x18, 0xc2, 0x18, 0xbf, 0xab, 0x66, 0x3b, 0x7, 0xee, 0xde, 0x7d, 0xd3, 0x85, 0xaa, 0x3e, - 0x12, 0xd4, 0x13, 0x2a, 0x9f, 0x8c, 0xe7, 0xc9, 0xe7, 0x56, 0x7f, 0x9e, 0xce, 0x52, 0x0}; + 0x10, 0x94, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x12, 0xf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x18, 0x0, 0x0, 0x47, 0x24, 0x3, 0x0, 0x10, 0x6c, 0x6f, + 0x89, 0xcb, 0xe, 0x12, 0x8f, 0x68, 0x6a, 0x16, 0x56, 0x54, 0x45, 0xf3, 0xc5, 0x50, 0x15, 0x0, 0x0, 0x8, 0x0, + 0x13, 0x24, 0xdc, 0x2b, 0xf1, 0x6, 0xff, 0x9a, 0xa1, 0x5c, 0x5b, 0xc4, 0x43, 0xe6, 0x40, 0xb7, 0x97, 0x11, 0xda, + 0x38, 0x2, 0x0, 0x0, 0x58, 0xae, 0x9, 0x0, 0x0, 0x27, 0x0, 0x0, 0x3d, 0xd4, 0x1f, 0x0, 0x3, 0x81, 0xb1, + 0xe5, 0x1a, 0x0, 0x1a, 0xd5, 0x80, 0xe2, 0x9f, 0x58, 0x3e, 0xf3, 0x3, 0x87, 0x7d, 0x85, 0x35, 0x38, 0xdc, 0x78, + 0xd5, 0x79, 0xfc, 0xb, 0x28, 0x43, 0x3d, 0x43, 0xcd, 0x9d, 0xcd, 0x18, 0x0, 0x0, 0x67, 0xb, 0x0, 0xd, 0x98, + 0xff, 0x83, 0x4d, 0x45, 0x5f, 0x5, 0xe3, 0xc, 0x56, 0x56, 0x8d, 0xac, 0x0, 0x10, 0x98, 0xb, 0x8f, 0xbd, 0xfe, + 0x95, 0x61, 0x1c, 0x37, 0x69, 0xc, 0x5f, 0xdc, 0xf0, 0xd1, 0xe8, 0x0, 0x4, 0xf5, 0x1c, 0x67, 0x83, 0x0, 0x3, + 0xe, 0x8d, 0xd2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x63, 0x18, 0x1b, 0x27, 0x12, 0x7f, 0x2f, 0x4e, 0xcc, 0x57, 0x2d, 0xb6, 0xe2, 0xe4, 0xbd, + 0x6b, 0x18, 0xf1, 0x27, 0x42, 0xba, 0x2f, 0x3, 0x85, 0x22, 0xc1, 0x4a, 0x89, 0x4e}; + uint8_t bytesprops0[] = {0x9f, 0xf6, 0xeb, 0xed, 0x8b, 0x80, 0xd4, 0x81, 0x5c, 0xdc, + 0xde, 0xdf, 0xc4, 0xe8, 0xac, 0xd, 0x29, 0x84, 0x32}; + uint8_t bytesprops2[] = {0x30, 0x3, 0x4c, 0x88, 0xb5}; + uint8_t bytesprops4[] = {0x8b, 0x7c, 0xf4, 0x88, 0x17, 0xfd, 0xdf, 0xbf, 0x4, 0x12, 0x49, + 0xe1, 0x47, 0xda, 0xda, 0xbe, 0x6e, 0x45, 0xd9, 0x44, 0x52}; + uint8_t bytesprops3[] = {0x73}; + uint8_t bytesprops5[] = {0x6a, 0x2e, 0xfe}; + uint8_t bytesprops6[] = {0xbd, 0xb5, 0x4a, 0x4d, 0x27, 0x21, 0xff, 0xd5, 0x3b, 0x64, 0xaf, 0xb6, 0x47, 0x7e, 0x6a}; + uint8_t bytesprops7[] = {0x4e, 0x8, 0xec, 0x92, 0xab, 0xe1, 0xa9, 0x7, 0x63, + 0x54, 0x4c, 0x7b, 0xf5, 0x2f, 0x81, 0x5b, 0x71}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5918}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops1}, .v = {9, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23323}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops5}, .v = {4, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops0}, .v = {29, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops3}, .v = {21, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6339}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27261}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26619}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4276}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15218}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26486}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22520}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 191}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xcd, 0x50, 0x33, 0x72, 0xa6, 0x3c, 0x93, 0xa7, 0x0, 0x6e, 0xa5, 0xfb, 0x88}; + uint8_t byteswillprops0[] = {0x39, 0xd6, 0xbc, 0x67, 0xeb, 0x97, 0x23, 0x1, 0xfe, 0x8c, 0x2f, 0x86, 0x40, 0xcb}; + uint8_t byteswillprops1[] = {0x4f, 0x73, 0x98, 0xe9, 0xbe, 0x4, 0xe6, 0x2f, 0x7c, 0x66, 0xb3, 0xdb, 0xce, + 0xe1, 0x72, 0xa4, 0xc4, 0xed, 0x44, 0x38, 0xb9, 0x87, 0x2c, 0x1f, 0xf, 0x75}; + uint8_t byteswillprops2[] = {0x96, 0xda, 0x77, 0xcd, 0x88, 0x88, 0x53, 0x52, 0x71, 0xf, 0xa0, 0x61, + 0xfd, 0x17, 0xf2, 0x97, 0x16, 0x6, 0x3b, 0x3a, 0x29, 0x71, 0xae, 0xdc}; + uint8_t byteswillprops3[] = {0x72, 0x87, 0xdd, 0x80, 0x28, 0xae, 0xc, 0xdf, 0x15, 0x99, 0x20, + 0xf7, 0xa8, 0xf4, 0x52, 0x82, 0x74, 0xe8, 0xa2, 0x2d, 0x90, 0xbd}; + uint8_t byteswillprops4[] = {0xa0, 0xf6, 0xbc, 0x50, 0x2f, 0x28, 0x6a, 0x2b, 0x28}; + uint8_t byteswillprops5[] = {0xd4, 0xd4, 0x94, 0x74, 0xed, 0x79, 0x43, 0x29, 0x5c, 0x78, + 0x7f, 0xe7, 0x2a, 0x61, 0x40, 0x9a, 0xd9, 0x3e, 0xa}; + uint8_t byteswillprops6[] = {0x6c, 0x6f, 0x89, 0xcb, 0xe, 0x12, 0x8f, 0x68, + 0x6a, 0x16, 0x56, 0x54, 0x45, 0xf3, 0xc5, 0x50}; + uint8_t byteswillprops7[] = {0}; + uint8_t byteswillprops8[] = {0x24, 0xdc, 0x2b, 0xf1, 0x6, 0xff, 0x9a, 0xa1, 0x5c, 0x5b, + 0xc4, 0x43, 0xe6, 0x40, 0xb7, 0x97, 0x11, 0xda, 0x38}; + uint8_t byteswillprops9[] = {0}; + uint8_t byteswillprops10[] = {0x81, 0xb1, 0xe5}; + uint8_t byteswillprops11[] = {0xd5, 0x80, 0xe2, 0x9f, 0x58, 0x3e, 0xf3, 0x3, 0x87, 0x7d, 0x85, 0x35, 0x38, + 0xdc, 0x78, 0xd5, 0x79, 0xfc, 0xb, 0x28, 0x43, 0x3d, 0x43, 0xcd, 0x9d, 0xcd}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11626}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 920}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25442}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28647}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4995}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2060}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24384}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25477}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18212}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22702}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15828}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26379}}, }; - lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x5c, 0xb3}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa5, 0x9a, 0xe2, 0x4, 0x48, 0xf4, 0x2c, 0x94, 0xd9, 0x8, 0x7c}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x98, 0xff, 0x83, 0x4d, 0x45, 0x5f, 0x5, 0xe3, 0xc, 0x56, 0x56, 0x8d, 0xac}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x98, 0xb, 0x8f, 0xbd, 0xfe, 0x95, 0x61, 0x1c, + 0x37, 0x69, 0xc, 0x5f, 0xdc, 0xf0, 0xd1, 0xe8}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 18048; - uint8_t client_id_bytes[] = {0x4a, 0xbe, 0xec, 0xe, 0xd1, 0x41, 0xf0, 0x52, 0x9b, 0x2, 0x3a, 0xbe, 0xa6, 0x2d, 0xd9, - 0x43, 0xa9, 0x19, 0x86, 0xa0, 0xaa, 0xe2, 0xfb, 0x49, 0xb, 0xee, 0x36, 0xd0, 0x95}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 4861; + uint8_t client_id_bytes[] = {0x3d, 0x8, 0x3a, 0x8e, 0x90}; + lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x50, 0xa6, 0x55, 0x77, 0x4d, 0xdb, 0x43, 0xf7, 0x29, 0x47, 0xf6, 0x4e, 0xdd, 0x7b, - 0xb4, 0x5f, 0xfc, 0xa5, 0x65, 0xb, 0xd0, 0x71, 0x82, 0x63, 0x1e, 0xd3, 0x43, 0x3c}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf5, 0x1c, 0x67, 0x83}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x82, 0x18, 0x33, 0xe0, 0x91, 0xe8, 0x5d, 0xef, 0x91, 0xba, 0xa5, - 0xb2, 0x76, 0xa9, 0x4e, 0x3d, 0x7, 0x2b, 0x9, 0x20, 0x2d}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe, 0x8d, 0xd2}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -6838,243 +6742,217 @@ TEST(Connect5QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "2\SYN9\139\255u\201\DEL\234\DEL\164@W\249\SUB\225B\154\170*\\H\246:b\164", -// _password = Just "+ZTUH\240]\158$\252\179\130\182\154hK", _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "\248\227\198;\219P\186\DC1\SO\130\166<\193j\180\&3\199\231BD@\235", _willMsg = "\231", _willProps -// = [PropResponseInformation "\188",PropMaximumQoS 180,PropPayloadFormatIndicator 242,PropRequestResponseInformation -// 85,PropUserProperty "p\151\153Fo\162\&4\DC2\140\236\179\186\248Q\247\200\228F?\135Z" -// "\DEL\134\&2\190]\200A(6B",PropAssignedClientIdentifier -// "i0\232\188\215\215Q\168\f\184\146\208\147M\165`\223\254\183\245\ESC=\135\151\228\SOH\173",PropSubscriptionIdentifierAvailable -// 175,PropMessageExpiryInterval 31995,PropSubscriptionIdentifier 4,PropSharedSubscriptionAvailable 43]}), _cleanSession -// = True, _keepAlive = 16330, _connID = "\v\176\184\NULR", _properties = [PropSubscriptionIdentifier -// 8,PropRetainAvailable 107,PropSubscriptionIdentifierAvailable 148,PropResponseInformation -// ")\ESC\231\233\US\140\254\254Q[\180\DC3\STX[\136\191O]\161\208=\207\222Ar\NUL\235w",PropRetainAvailable -// 4,PropMessageExpiryInterval 7551,PropReasonString "Q\177\223\156\161%\220",PropRetainAvailable 208]} +// ConnectRequest {_username = Just "\190~\232\224\v\218x\135\ESC\193\243\132\192\&1\150\134+\245\EOT9\235j\175", +// _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 11488, _connID = "", _properties = +// [PropMaximumQoS 223,PropWildcardSubscriptionAvailable 149,PropAuthenticationData +// "-_/y\147\ENQa\135\188\238\227\231M\225F\161\STX",PropResponseTopic "",PropSharedSubscriptionAvailable +// 166,PropReasonString "\136-W\248Fp\FS\128P\"",PropMaximumPacketSize 25315,PropRetainAvailable +// 63,PropMaximumPacketSize 6919,PropMaximumQoS 71,PropReasonString +// "\137\233\ENQ\ETB\207#\ETB\133s\205\209\247\ENQ\135\166u\232\252",PropRequestProblemInformation +// 115,PropServerReference "\219\229\161t|\255&\195!\" \169\248\&0\157\242j\233\228A\195",PropContentType +// "",PropWillDelayInterval 7778,PropRequestProblemInformation 53,PropAuthenticationData +// "\DLE\152\177\194\aV1\129\129\209c\241\249\201\CANb\162*k\194\246.\193q\190\213\145",PropResponseTopic +// "\178\216\236\130\131\234\173\165\&3\222\STX|C\237\197\191}\193\166z\227\160\186\205\176\219\tPW\NAK",PropAuthenticationMethod +// "\202j\240\220\140\STX\182\SI\DC3\SI\200\147\NUL\SYN\fp\n\132)\188\CANp\163\&1\US",PropCorrelationData +// "n;\254\190E\166\160A",PropSubscriptionIdentifier 15,PropSharedSubscriptionAvailable 228,PropPayloadFormatIndicator +// 39,PropServerKeepAlive 29814]} TEST(Connect5QCTest, Encode3) { uint8_t pkt[] = { - 0x10, 0xeb, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x3f, 0xca, 0x38, 0xb, 0x8, 0x25, 0x6b, 0x29, - 0x94, 0x1a, 0x0, 0x1c, 0x29, 0x1b, 0xe7, 0xe9, 0x1f, 0x8c, 0xfe, 0xfe, 0x51, 0x5b, 0xb4, 0x13, 0x2, 0x5b, 0x88, - 0xbf, 0x4f, 0x5d, 0xa1, 0xd0, 0x3d, 0xcf, 0xde, 0x41, 0x72, 0x0, 0xeb, 0x77, 0x25, 0x4, 0x2, 0x0, 0x0, 0x1d, - 0x7f, 0x1f, 0x0, 0x7, 0x51, 0xb1, 0xdf, 0x9c, 0xa1, 0x25, 0xdc, 0x25, 0xd0, 0x0, 0x5, 0xb, 0xb0, 0xb8, 0x0, - 0x52, 0x57, 0x1a, 0x0, 0x1, 0xbc, 0x24, 0xb4, 0x1, 0xf2, 0x19, 0x55, 0x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, 0xbf, 0x7d, 0xc1, 0xa6, 0x7a, 0xe3, 0xa0, 0xba, 0xcd, 0xb0, 0xdb, 0x9, 0x50, 0x57, + 0x15, 0x15, 0x0, 0x19, 0xca, 0x6a, 0xf0, 0xdc, 0x8c, 0x2, 0xb6, 0xf, 0x13, 0xf, 0xc8, 0x93, 0x0, 0x16, 0xc, + 0x70, 0xa, 0x84, 0x29, 0xbc, 0x18, 0x70, 0xa3, 0x31, 0x1f, 0x9, 0x0, 0x8, 0x6e, 0x3b, 0xfe, 0xbe, 0x45, 0xa6, + 0xa0, 0x41, 0xb, 0xf, 0x2a, 0xe4, 0x1, 0x27, 0x13, 0x74, 0x76, 0x0, 0x0, 0x0, 0x17, 0xbe, 0x7e, 0xe8, 0xe0, + 0xb, 0xda, 0x78, 0x87, 0x1b, 0xc1, 0xf3, 0x84, 0xc0, 0x31, 0x96, 0x86, 0x2b, 0xf5, 0x4, 0x39, 0xeb, 0x6a, 0xaf}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x2d, 0x5f, 0x2f, 0x79, 0x93, 0x5, 0x61, 0x87, 0xbc, + 0xee, 0xe3, 0xe7, 0x4d, 0xe1, 0x46, 0xa1, 0x2}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x88, 0x2d, 0x57, 0xf8, 0x46, 0x70, 0x1c, 0x80, 0x50, 0x22}; + uint8_t bytesprops3[] = {0x89, 0xe9, 0x5, 0x17, 0xcf, 0x23, 0x17, 0x85, 0x73, + 0xcd, 0xd1, 0xf7, 0x5, 0x87, 0xa6, 0x75, 0xe8, 0xfc}; + uint8_t bytesprops4[] = {0xdb, 0xe5, 0xa1, 0x74, 0x7c, 0xff, 0x26, 0xc3, 0x21, 0x22, 0x20, + 0xa9, 0xf8, 0x30, 0x9d, 0xf2, 0x6a, 0xe9, 0xe4, 0x41, 0xc3}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0x10, 0x98, 0xb1, 0xc2, 0x7, 0x56, 0x31, 0x81, 0x81, 0xd1, 0x63, 0xf1, 0xf9, 0xc9, + 0x18, 0x62, 0xa2, 0x2a, 0x6b, 0xc2, 0xf6, 0x2e, 0xc1, 0x71, 0xbe, 0xd5, 0x91}; + uint8_t bytesprops7[] = {0xb2, 0xd8, 0xec, 0x82, 0x83, 0xea, 0xad, 0xa5, 0x33, 0xde, 0x2, 0x7c, 0x43, 0xed, 0xc5, + 0xbf, 0x7d, 0xc1, 0xa6, 0x7a, 0xe3, 0xa0, 0xba, 0xcd, 0xb0, 0xdb, 0x9, 0x50, 0x57, 0x15}; + uint8_t bytesprops8[] = {0xca, 0x6a, 0xf0, 0xdc, 0x8c, 0x2, 0xb6, 0xf, 0x13, 0xf, 0xc8, 0x93, 0x0, + 0x16, 0xc, 0x70, 0xa, 0x84, 0x29, 0xbc, 0x18, 0x70, 0xa3, 0x31, 0x1f}; + uint8_t bytesprops9[] = {0x6e, 0x3b, 0xfe, 0xbe, 0x45, 0xa6, 0xa0, 0x41}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7551}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25315}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6919}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7778}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29814}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xbc}; - uint8_t byteswillprops2[] = {0x7f, 0x86, 0x32, 0xbe, 0x5d, 0xc8, 0x41, 0x28, 0x36, 0x42}; - uint8_t byteswillprops1[] = {0x70, 0x97, 0x99, 0x46, 0x6f, 0xa2, 0x34, 0x12, 0x8c, 0xec, 0xb3, - 0xba, 0xf8, 0x51, 0xf7, 0xc8, 0xe4, 0x46, 0x3f, 0x87, 0x5a}; - uint8_t byteswillprops3[] = {0x69, 0x30, 0xe8, 0xbc, 0xd7, 0xd7, 0x51, 0xa8, 0xc, 0xb8, 0x92, 0xd0, 0x93, 0x4d, - 0xa5, 0x60, 0xdf, 0xfe, 0xb7, 0xf5, 0x1b, 0x3d, 0x87, 0x97, 0xe4, 0x1, 0xad}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {21, (char*)&byteswillprops1}, .v = {10, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31995}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 43}}, - }; - - lwmqtt_properties_t willprops = {10, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf8, 0xe3, 0xc6, 0x3b, 0xdb, 0x50, 0xba, 0x11, 0xe, 0x82, 0xa6, - 0x3c, 0xc1, 0x6a, 0xb4, 0x33, 0xc7, 0xe7, 0x42, 0x44, 0x40, 0xeb}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe7}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 16330; - uint8_t client_id_bytes[] = {0xb, 0xb0, 0xb8, 0x0, 0x52}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 11488; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x32, 0x16, 0x39, 0x8b, 0xff, 0x75, 0xc9, 0x7f, 0xea, 0x7f, 0xa4, 0x40, 0x57, - 0xf9, 0x1a, 0xe1, 0x42, 0x9a, 0xaa, 0x2a, 0x5c, 0x48, 0xf6, 0x3a, 0x62, 0xa4}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xbe, 0x7e, 0xe8, 0xe0, 0xb, 0xda, 0x78, 0x87, 0x1b, 0xc1, 0xf3, 0x84, + 0xc0, 0x31, 0x96, 0x86, 0x2b, 0xf5, 0x4, 0x39, 0xeb, 0x6a, 0xaf}; + lwmqtt_string_t username = {23, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x2b, 0x5a, 0x54, 0x55, 0x48, 0xf0, 0x5d, 0x9e, - 0x24, 0xfc, 0xb3, 0x82, 0xb6, 0x9a, 0x68, 0x4b}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\SOH\222\148y4W7\221\234\219\249G\176i\153\&7C\174\DC3\201\168", _password = -// Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "\182\DC2\202\175'\175", -// _willMsg = "FT\180\227 ,\DLEhU\147g\249\210sn\150=>P\234h4\234\150\&6T\137\149\192\216", _willProps = -// [PropWildcardSubscriptionAvailable 106,PropRetainAvailable 244,PropRequestProblemInformation -// 51,PropSharedSubscriptionAvailable 219,PropMaximumQoS 11,PropSubscriptionIdentifier 16,PropSubscriptionIdentifier -// 26,PropCorrelationData "\r\243~\154\NUL\248\252y)\252\144\214\SOH\249\186\&1",PropSubscriptionIdentifierAvailable -// 202,PropMaximumPacketSize 19589,PropResponseInformation -// "\173\208\ACK\n\200\251\198<=\DC2\246b\207\211\216\165.",PropServerReference "\ENQ",PropWillDelayInterval -// 25985,PropSharedSubscriptionAvailable 114,PropResponseInformation "7\246\&2",PropMessageExpiryInterval -// 909,PropServerKeepAlive 24831,PropSubscriptionIdentifier 8,PropUserProperty "G\130\229" -// "\241z\186g\224\158R\130C\246\140\ENQ^s/\236\199\ENQU\GSl\US\r`\246",PropPayloadFormatIndicator -// 231,PropWillDelayInterval 29690,PropRequestResponseInformation 152,PropAssignedClientIdentifier -// "Y\253\201\&1\226\&0\250Ql\188\153\224C\231\DC4\225\229\238I>\141]\184e\236\201\165",PropTopicAlias -// 132,PropReceiveMaximum 7672,PropReasonString "#\nH\t\192\223\223>R\179q\144\ETB",PropSharedSubscriptionAvailable -// 4,PropMaximumPacketSize 4671,PropTopicAlias 22943,PropMessageExpiryInterval 29025]}), _cleanSession = True, -// _keepAlive = 30046, _connID = "A'\216\131\251\208\218\DC4\152\230\198\239\a", _properties = -// [PropMessageExpiryInterval 23903,PropSubscriptionIdentifier 0,PropUserProperty "v\235" -// "\b4\NAK\ACK,\141\US\230T\228[\EOT0vu\ENQ?",PropServerReference -// "\216TZ\165/>\146\146\160\237)\208o\EOT\234",PropServerReference ";\173U1|\DLE\197M\147\241\178Y -// Q[\STX\243R\233\150o\172zb\130",PropPayloadFormatIndicator 196,PropCorrelationData -// "\234\DC1\243\ESC\233\vH\202",PropRequestResponseInformation 37,PropContentType ""]} +// ConnectRequest {_username = Just "_\DLE\201\254`\162\246\240I", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = "\248J", _willMsg = +// "\RSG\205\252\RSP\173\SO\195\CAN\209PX\DC1c:\218\166G\158\ACK", _willProps = [PropReceiveMaximum +// 2303,PropRetainAvailable 55,PropMessageExpiryInterval 30752,PropRetainAvailable 95,PropResponseTopic +// "\vKr\227\129\189d",PropContentType "#\SOz\SOH\223\DC2;\ESC;\NULc8\199",PropSharedSubscriptionAvailable +// 83,PropWillDelayInterval 19746]}), _cleanSession = True, _keepAlive = 31889, _connID = +// "I.j%\170?\194\183h\143.\150\255", _properties = [PropAssignedClientIdentifier +// "\234P\ETB(T\179\STX\247\STXs\207SoA\133(=\STXG\191\201{\ENQ\225\DC2",PropAssignedClientIdentifier +// "\141^o",PropPayloadFormatIndicator 172,PropWillDelayInterval 32628,PropServerReference +// "\135V\185W\131B^\149\189\&8\216\232K\244",PropUserProperty "q2F\169" +// "\191Vo,\205a\218\174\USbTj\162G\243\177_>1\158$\232",PropMaximumQoS 203,PropTopicAliasMaximum +// 6794,PropAuthenticationMethod +// "\225)Q$>\220E\215\169\243$r\247{\241\&6\DC2\179`\178Q\DLE\ACK\182\ENQ\248Do\214\145o\SOi7\155\164\232G\239\ENQ\r",PropTopicAliasMaximum -// 23410,PropMessageExpiryInterval 27313,PropSessionExpiryInterval 25863,PropAuthenticationMethod -// "\218\246\&4\t\220C\199\193\ETXrtR\ACK\142.\NAK\149\139\156\192\133\163)\206\142",PropTopicAliasMaximum -// 31669,PropMessageExpiryInterval 2051,PropResponseInformation "",PropTopicAlias 288,PropPayloadFormatIndicator -// 69,PropServerKeepAlive 11992,PropAssignedClientIdentifier -// "\233\SYN\180\160\178\135\162\199RFI\204&d\239\184\168\237ey\ETX\214\CAN",PropPayloadFormatIndicator -// 209,PropAuthenticationData "",PropPayloadFormatIndicator 240,PropAssignedClientIdentifier -// "\NUL\r\223\128\168_\249\211\192e\a\246\251\SII/"]}), _cleanSession = False, _keepAlive = 16105, _connID = -// "\233#\162\&4\221v1'\194j\182\178J\225\247nx\168\166\148\147M\199\156\229Cz\134\EOT", _properties = [PropTopicAlias -// 27063,PropRequestResponseInformation 177,PropReasonString "",PropSharedSubscriptionAvailable -// 46,PropSubscriptionIdentifier 15,PropServerReference ":\216\237",PropMessageExpiryInterval 11345,PropServerKeepAlive -// 24364,PropResponseTopic "\168\199\129\177\157\193N/*8~W:",PropAuthenticationMethod -// "\162i\210\r\205\225\139\195\SYN\129\163\164\160Zc\173",PropSharedSubscriptionAvailable 93,PropServerKeepAlive -// 19517,PropWildcardSubscriptionAvailable 52,PropWillDelayInterval 7303,PropRequestProblemInformation -// 7,PropRequestProblemInformation 233,PropTopicAlias 3877,PropMessageExpiryInterval 11804,PropWillDelayInterval -// 5288,PropSessionExpiryInterval 19779,PropResponseTopic "\\Z\225\n\212'\202#\250",PropTopicAliasMaximum -// 5401,PropTopicAlias 7665,PropSubscriptionIdentifier 20,PropMaximumQoS 18,PropSubscriptionIdentifier 5]} +// ConnectRequest {_username = Nothing, _password = Just +// "\174g-~\US\254\174\RS5\r\148\251\190\141\147ed,\178\FS\148'\DELb\174\216", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS1, _willTopic = "\SI%\202\210^\187\&7\227\165\SI\236\b\199,\159\238\169", _willMsg = +// "\167\235\ACK\211F\n\211\\@!Wh\n", _willProps = [PropMaximumPacketSize 31865,PropWillDelayInterval +// 5958,PropRequestResponseInformation 226,PropTopicAliasMaximum 20550,PropServerReference +// "\251\243\149\253{\186\171\197\172\164\193\GS\210GA1",PropAssignedClientIdentifier +// "\187\r\205\fTG\138\218\133\DLE\128\244\ETX\198\192\212\224\&8'\212\131\162\238uY\128Ur\222",PropRequestProblemInformation +// 93,PropRequestProblemInformation 71,PropServerKeepAlive 1297,PropContentType +// "\211q\DEL\249u",PropWildcardSubscriptionAvailable 19,PropReasonString +// "K\231\207\&1u\206Lr\143u\177\240\DC4\187c\ACK\168'\234\226\205`m\128\194\192,V",PropMessageExpiryInterval +// 4777,PropUserProperty "\160\152\tN\DC2h0\252\173\SOHX/\RS\GS.\216\184\DC1#s" "\246\183h\156",PropTopicAlias +// 1527,PropTopicAliasMaximum 10288,PropMaximumQoS 218,PropSharedSubscriptionAvailable 223,PropCorrelationData +// "\139\SI\142\182F\208\229\156\214",PropReceiveMaximum 11822,PropTopicAliasMaximum 18800,PropReceiveMaximum +// 25564,PropSubscriptionIdentifierAvailable 144,PropMaximumQoS 54,PropCorrelationData +// "m\239O\DC4",PropWildcardSubscriptionAvailable 255,PropTopicAliasMaximum 1795,PropSubscriptionIdentifierAvailable +// 216,PropWillDelayInterval 10052,PropSubscriptionIdentifierAvailable 47]}), _cleanSession = True, _keepAlive = 4901, +// _connID = "bDc", _properties = [PropServerKeepAlive 6085,PropMaximumQoS 244,PropPayloadFormatIndicator +// 209,PropWillDelayInterval 32239,PropMaximumQoS 201,PropSubscriptionIdentifier 15,PropSessionExpiryInterval +// 26513,PropWildcardSubscriptionAvailable 151,PropSharedSubscriptionAvailable 224,PropTopicAliasMaximum +// 27052,PropTopicAlias 13374,PropAuthenticationData "\177\182x*\204\EOT\213\180\ESC\207",PropServerKeepAlive +// 14469,PropRequestResponseInformation 157,PropAuthenticationMethod "\139L",PropWillDelayInterval +// 15730,PropCorrelationData "\143|q\214\&0\146\214Q\EMz\v2\255\GS\222.\FSFSUc\DC2x\136\148u",PropSessionExpiryInterval +// 20899,PropServerReference "X\216\153I\242j",PropSessionExpiryInterval 3724,PropTopicAliasMaximum +// 4163,PropTopicAliasMaximum 13157,PropServerReference "\255\142\198\NUL\245t\ty\246\234\aF\187\209"]} TEST(Connect5QCTest, Encode6) { uint8_t pkt[] = { - 0x10, 0xbd, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc, 0x3e, 0xe9, 0x77, 0x23, 0x69, 0xb7, 0x19, 0xb1, - 0x1f, 0x0, 0x0, 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a, - 0xb1, 0x11, 0x0, 0x0, 0x65, 0x7, 0x15, 0x0, 0x19, 0xda, 0xf6, 0x34, 0x9, 0xdc, 0x43, 0xc7, 0xc1, 0x3, 0x72, - 0x74, 0x52, 0x6, 0x8e, 0x2e, 0x15, 0x95, 0x8b, 0x9c, 0xc0, 0x85, 0xa3, 0x29, 0xce, 0x8e, 0x22, 0x7b, 0xb5, 0x2, - 0x0, 0x0, 0x8, 0x3, 0x1a, 0x0, 0x0, 0x23, 0x1, 0x20, 0x1, 0x45, 0x13, 0x2e, 0xd8, 0x12, 0x0, 0x17, 0xe9, - 0x16, 0xb4, 0xa0, 0xb2, 0x87, 0xa2, 0xc7, 0x52, 0x46, 0x49, 0xcc, 0x26, 0x64, 0xef, 0xb8, 0xa8, 0xed, 0x65, 0x79, - 0x3, 0xd6, 0x18, 0x1, 0xd1, 0x16, 0x0, 0x0, 0x1, 0xf0, 0x12, 0x0, 0x10, 0x0, 0xd, 0xdf, 0x80, 0xa8, 0x5f, - 0xf9, 0xd3, 0xc0, 0x65, 0x7, 0xf6, 0xfb, 0xf, 0x49, 0x2f, 0x0, 0x0, 0x0, 0x2, 0x1f, 0x6d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x3a, 0xd8, 0xed}; - uint8_t bytesprops2[] = {0xa8, 0xc7, 0x81, 0xb1, 0x9d, 0xc1, 0x4e, 0x2f, 0x2a, 0x38, 0x7e, 0x57, 0x3a}; - uint8_t bytesprops3[] = {0xa2, 0x69, 0xd2, 0xd, 0xcd, 0xe1, 0x8b, 0xc3, - 0x16, 0x81, 0xa3, 0xa4, 0xa0, 0x5a, 0x63, 0xad}; - uint8_t bytesprops4[] = {0x5c, 0x5a, 0xe1, 0xa, 0xd4, 0x27, 0xca, 0x23, 0xfa}; + 0x10, 0x9f, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x4e, 0x13, 0x25, 0x82, 0x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, 0x2d, 0x7e, 0x1f, 0xfe, 0xae, + 0x1e, 0x35, 0xd, 0x94, 0xfb, 0xbe, 0x8d, 0x93, 0x65, 0x64, 0x2c, 0xb2, 0x1c, 0x94, 0x27, 0x7f, 0x62, 0xae, 0xd8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb1, 0xb6, 0x78, 0x2a, 0xcc, 0x4, 0xd5, 0xb4, 0x1b, 0xcf}; + uint8_t bytesprops1[] = {0x8b, 0x4c}; + uint8_t bytesprops2[] = {0x8f, 0x7c, 0x71, 0xd6, 0x30, 0x92, 0xd6, 0x51, 0x19, 0x7a, 0xb, 0x32, 0xff, + 0x1d, 0xde, 0x2e, 0x1c, 0x46, 0x53, 0x55, 0x63, 0x12, 0x78, 0x88, 0x94, 0x75}; + uint8_t bytesprops3[] = {0x58, 0xd8, 0x99, 0x49, 0xf2, 0x6a}; + uint8_t bytesprops4[] = {0xff, 0x8e, 0xc6, 0x0, 0xf5, 0x74, 0x9, 0x79, 0xf6, 0xea, 0x7, 0x46, 0xbb, 0xd1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27063}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6085}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32239}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 201}}, {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11345}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24364}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19517}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7303}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3877}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11804}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5288}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19779}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5401}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7665}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26513}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27052}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13374}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14469}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15730}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20899}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3724}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4163}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13157}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x1b, 0xa9, 0x3e, 0x12, 0xb3, 0x60, 0xb2, 0x51, 0x10, 0x6, 0xb6, 0x5, 0xf8, 0x44, - 0x6f, 0xd6, 0x91, 0x6f, 0xe, 0x69, 0x37, 0x9b, 0xa4, 0xe8, 0x47, 0xef, 0x5, 0xd}; - uint8_t byteswillprops1[] = {0xda, 0xf6, 0x34, 0x9, 0xdc, 0x43, 0xc7, 0xc1, 0x3, 0x72, 0x74, 0x52, 0x6, - 0x8e, 0x2e, 0x15, 0x95, 0x8b, 0x9c, 0xc0, 0x85, 0xa3, 0x29, 0xce, 0x8e}; - uint8_t byteswillprops2[] = {0}; - uint8_t byteswillprops3[] = {0xe9, 0x16, 0xb4, 0xa0, 0xb2, 0x87, 0xa2, 0xc7, 0x52, 0x46, 0x49, 0xcc, - 0x26, 0x64, 0xef, 0xb8, 0xa8, 0xed, 0x65, 0x79, 0x3, 0xd6, 0x18}; - uint8_t byteswillprops4[] = {0}; - uint8_t byteswillprops5[] = {0x0, 0xd, 0xdf, 0x80, 0xa8, 0x5f, 0xf9, 0xd3, - 0xc0, 0x65, 0x7, 0xf6, 0xfb, 0xf, 0x49, 0x2f}; + uint8_t byteswillprops0[] = {0xfb, 0xf3, 0x95, 0xfd, 0x7b, 0xba, 0xab, 0xc5, + 0xac, 0xa4, 0xc1, 0x1d, 0xd2, 0x47, 0x41, 0x31}; + uint8_t byteswillprops1[] = {0xbb, 0xd, 0xcd, 0xc, 0x54, 0x47, 0x8a, 0xda, 0x85, 0x10, 0x80, 0xf4, 0x3, 0xc6, 0xc0, + 0xd4, 0xe0, 0x38, 0x27, 0xd4, 0x83, 0xa2, 0xee, 0x75, 0x59, 0x80, 0x55, 0x72, 0xde}; + uint8_t byteswillprops2[] = {0xd3, 0x71, 0x7f, 0xf9, 0x75}; + uint8_t byteswillprops3[] = {0x4b, 0xe7, 0xcf, 0x31, 0x75, 0xce, 0x4c, 0x72, 0x8f, 0x75, 0xb1, 0xf0, 0x14, 0xbb, + 0x63, 0x6, 0xa8, 0x27, 0xea, 0xe2, 0xcd, 0x60, 0x6d, 0x80, 0xc2, 0xc0, 0x2c, 0x56}; + uint8_t byteswillprops5[] = {0xf6, 0xb7, 0x68, 0x9c}; + uint8_t byteswillprops4[] = {0xa0, 0x98, 0x9, 0x4e, 0x12, 0x68, 0x30, 0xfc, 0xad, 0x1, + 0x58, 0x2f, 0x1e, 0x1d, 0x2e, 0xd8, 0xb8, 0x11, 0x23, 0x73}; + uint8_t byteswillprops6[] = {0x8b, 0xf, 0x8e, 0xb6, 0x46, 0xd0, 0xe5, 0x9c, 0xd6}; + uint8_t byteswillprops7[] = {0x6d, 0xef, 0x4f, 0x14}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5999}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23410}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27313}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25863}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31669}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2051}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 288}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11992}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31865}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5958}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20550}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1297}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4777}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {20, (char*)&byteswillprops4}, .v = {4, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1527}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10288}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11822}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18800}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25564}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1795}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10052}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 47}}, }; - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1f, 0x6d}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf, 0x25, 0xca, 0xd2, 0x5e, 0xbb, 0x37, 0xe3, 0xa5, + 0xf, 0xec, 0x8, 0xc7, 0x2c, 0x9f, 0xee, 0xa9}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa7, 0xeb, 0x6, 0xd3, 0x46, 0xa, 0xd3, 0x5c, 0x40, 0x21, 0x57, 0x68, 0xa}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -7250,12 +7170,15 @@ TEST(Connect5QCTest, Encode6) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 16105; - uint8_t client_id_bytes[] = {0xe9, 0x23, 0xa2, 0x34, 0xdd, 0x76, 0x31, 0x27, 0xc2, 0x6a, 0xb6, 0xb2, 0x4a, 0xe1, 0xf7, - 0x6e, 0x78, 0xa8, 0xa6, 0x94, 0x93, 0x4d, 0xc7, 0x9c, 0xe5, 0x43, 0x7a, 0x86, 0x4}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 4901; + uint8_t client_id_bytes[] = {0x62, 0x44, 0x63}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t password_bytes[] = {0xae, 0x67, 0x2d, 0x7e, 0x1f, 0xfe, 0xae, 0x1e, 0x35, 0xd, 0x94, 0xfb, 0xbe, + 0x8d, 0x93, 0x65, 0x64, 0x2c, 0xb2, 0x1c, 0x94, 0x27, 0x7f, 0x62, 0xae, 0xd8}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7264,132 +7187,164 @@ TEST(Connect5QCTest, Encode6) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\EM\145", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS1, _willTopic = "\251\200\&6\199\206\206\220pH\v\151\196\129A_\134\141\215\229\SO\189\198l\249=\202", -// _willMsg = "\179%l\240\143\191>o\222\152\ETXd\178q\161", _willProps = [PropContentType -// "M\n\153\155\EM\221s9|9B\131\223\&2&\201q\ty\DC3",PropServerReference -// "@\154\225\138\225\223\196",PropAuthenticationData -// "\214\243\166\172\205\134zvP\131p\161",PropAssignedClientIdentifier "{\255\229\189\130{h(\238\172",PropResponseTopic -// "\209 -// \198\a~\236z\253\DLE\134\226\&3\233\170\235\212\147\215\223\217\DC3\247\165\164\rc\177\156\181\240",PropUserProperty -// "k\191\216\&8E\249\f]\233\140f-\214Bf7t\147\150\168\243\196\184\222W\239\248N\STX\164" -// "\133\f\203\154u\221\&5V\231\US\EOT\229\168\SO\240;\213K\142"]}), _cleanSession = False, _keepAlive = 20495, _connID -// = "\199\170\&0\213\199\&6Tz4k\247\fs;\188l\241\227L\185\128\149\160\143\227\150c7\220", _properties = -// [PropSubscriptionIdentifier 14,PropSessionExpiryInterval 23537,PropAssignedClientIdentifier -// "\DC1\144\250j~\248\184\137,\DC4\168j_\f\172Ja\155\226\141\176Yr\ENQ\200?gl",PropResponseTopic -// "\241\138\194",PropSessionExpiryInterval 9638,PropSubscriptionIdentifierAvailable 169,PropRequestProblemInformation -// 253,PropUserProperty "\144\SI\216\EOT\138[A\144\r\143\172\161\171\171$\174\133\181^\184<:\149" -// "\186\&5\240\143\192\161",PropSubscriptionIdentifier 13,PropAssignedClientIdentifier -// "\220\218\211W-lS\206",PropCorrelationData "\179\DC4h\149\b\CAN#\176",PropUserProperty -// "\218\230\178s\191\NAK\143\&1\243f\174u" ")\229\150jQ\178\255",PropServerReference -// "\190\SUB<\198\SUBSy'\157",PropResponseInformation "$\250\&4^\240L\157\SUB",PropServerReference -// "\226\US\227\231{\166\&7"]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "c_\DC1\222(\232\&7", _willMsg = +// "\213z\217-\215\&3\195\ETB\188G\198\140\251+\139\183\183\222\232\204M\187\145\252\EOT\n\192\129", _willProps = +// [PropResponseInformation "u",PropAuthenticationData +// "\NAK9\201\234S\189\240C\251\ETB\182\187\t\187\144]\"|\139",PropRequestProblemInformation 231,PropMaximumPacketSize +// 25564,PropReceiveMaximum 26307,PropSessionExpiryInterval 3535,PropSubscriptionIdentifierAvailable 156,PropContentType +// "1\235\244~\199I\"\180\SYN\ACK\176\153P\148\255c\237\161[\USL\191\a\f&\232\137\151>)",PropAuthenticationMethod +// "Z#\f",PropSubscriptionIdentifier 5,PropSubscriptionIdentifier 19,PropServerReference +// "\212b4\143\148\223\232\250\163\228\138.\135\237`\195\SO&\130\RS\168\CAN\149\a\150\226\221\247?",PropSubscriptionIdentifier +// 7,PropContentType "\186\190?\ETXv;Q\GS\179\141\215\t2\179\233",PropReasonString +// "B/\ESC\165\176\135\235\200=\ETX\225<\150\224\149\197\200\NAK-I\214P\144\161\fJ/",PropAuthenticationData +// "\229\180M\232i\215~\143\DC3",PropReceiveMaximum 3850,PropMaximumPacketSize 19044,PropSubscriptionIdentifierAvailable +// 27,PropWillDelayInterval 8865,PropResponseTopic "u\"\DC3\246 +// \187\191\176`\146\GS\247\NAKQ~E\152i\196",PropRequestProblemInformation 35,PropMaximumQoS +// 212,PropRequestResponseInformation 160,PropResponseInformation +// "\237\190\209K-\180\155\253\153s\210\235p\221S\153\206\142\165%\DC28?",PropSubscriptionIdentifier 18]}), +// _cleanSession = True, _keepAlive = 7652, _connID = "m\186 \189\208z", _properties = [PropTopicAliasMaximum +// 7752,PropWildcardSubscriptionAvailable 167,PropSubscriptionIdentifier 19,PropUserProperty "\153\230" +// "\145m5q\238U\ETB\136*",PropSessionExpiryInterval 19199,PropServerKeepAlive 11861,PropSubscriptionIdentifierAvailable +// 196,PropMaximumPacketSize 19471,PropTopicAlias 18512,PropContentType +// "-oGT\128\163\EOTR\171\195\143\248\153.",PropReceiveMaximum 12290,PropReceiveMaximum 23080,PropMessageExpiryInterval +// 8200,PropUserProperty "\198\b^\159\210i_*\238\241\tFl\224\239RJ+\167\CAN\232u\185\DC4\183\249" +// "\140k\231\194\181\213^o \211\\\244\214\145\130\174\190\158=\255\143 \146\195n\151\145\202",PropServerReference +// "t\a\166xR$\213W\142\241\RS\203",PropRequestResponseInformation 132,PropRequestResponseInformation +// 227,PropSubscriptionIdentifierAvailable 22,PropResponseInformation "\US\160\170\180",PropPayloadFormatIndicator +// 131,PropRetainAvailable 204,PropResponseInformation "\214\DLE\218\190fG"]} TEST(Connect5QCTest, Encode7) { uint8_t pkt[] = { - 0x10, 0x9a, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xac, 0x50, 0xf, 0xa8, 0x1, 0xb, 0xe, 0x11, 0x0, - 0x0, 0x5b, 0xf1, 0x12, 0x0, 0x1c, 0x11, 0x90, 0xfa, 0x6a, 0x7e, 0xf8, 0xb8, 0x89, 0x2c, 0x14, 0xa8, 0x6a, 0x5f, - 0xc, 0xac, 0x4a, 0x61, 0x9b, 0xe2, 0x8d, 0xb0, 0x59, 0x72, 0x5, 0xc8, 0x3f, 0x67, 0x6c, 0x8, 0x0, 0x3, 0xf1, - 0x8a, 0xc2, 0x11, 0x0, 0x0, 0x25, 0xa6, 0x29, 0xa9, 0x17, 0xfd, 0x26, 0x0, 0x17, 0x90, 0xf, 0xd8, 0x4, 0x8a, - 0x5b, 0x41, 0x90, 0xd, 0x8f, 0xac, 0xa1, 0xab, 0xab, 0x24, 0xae, 0x85, 0xb5, 0x5e, 0xb8, 0x3c, 0x3a, 0x95, 0x0, - 0x6, 0xba, 0x35, 0xf0, 0x8f, 0xc0, 0xa1, 0xb, 0xd, 0x12, 0x0, 0x8, 0xdc, 0xda, 0xd3, 0x57, 0x2d, 0x6c, 0x53, - 0xce, 0x9, 0x0, 0x8, 0xb3, 0x14, 0x68, 0x95, 0x8, 0x18, 0x23, 0xb0, 0x26, 0x0, 0xc, 0xda, 0xe6, 0xb2, 0x73, - 0xbf, 0x15, 0x8f, 0x31, 0xf3, 0x66, 0xae, 0x75, 0x0, 0x7, 0x29, 0xe5, 0x96, 0x6a, 0x51, 0xb2, 0x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xf3, 0xc4, 0xb8, 0xde, 0x57, 0xef, 0xf8, 0x4e, 0x2, - 0xa4, 0x0, 0x13, 0x85, 0xc, 0xcb, 0x9a, 0x75, 0xdd, 0x35, 0x56, 0xe7, 0x1f, 0x4, 0xe5, 0xa8, 0xe, 0xf0, 0x3b, - 0xd5, 0x4b, 0x8e, 0x0, 0x1a, 0xfb, 0xc8, 0x36, 0xc7, 0xce, 0xce, 0xdc, 0x70, 0x48, 0xb, 0x97, 0xc4, 0x81, 0x41, - 0x5f, 0x86, 0x8d, 0xd7, 0xe5, 0xe, 0xbd, 0xc6, 0x6c, 0xf9, 0x3d, 0xca, 0x0, 0xf, 0xb3, 0x25, 0x6c, 0xf0, 0x8f, - 0xbf, 0x3e, 0x6f, 0xde, 0x98, 0x3, 0x64, 0xb2, 0x71, 0xa1, 0x0, 0x2, 0x19, 0x91}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x11, 0x90, 0xfa, 0x6a, 0x7e, 0xf8, 0xb8, 0x89, 0x2c, 0x14, 0xa8, 0x6a, 0x5f, 0xc, - 0xac, 0x4a, 0x61, 0x9b, 0xe2, 0x8d, 0xb0, 0x59, 0x72, 0x5, 0xc8, 0x3f, 0x67, 0x6c}; - uint8_t bytesprops1[] = {0xf1, 0x8a, 0xc2}; - uint8_t bytesprops3[] = {0xba, 0x35, 0xf0, 0x8f, 0xc0, 0xa1}; - uint8_t bytesprops2[] = {0x90, 0xf, 0xd8, 0x4, 0x8a, 0x5b, 0x41, 0x90, 0xd, 0x8f, 0xac, 0xa1, - 0xab, 0xab, 0x24, 0xae, 0x85, 0xb5, 0x5e, 0xb8, 0x3c, 0x3a, 0x95}; - uint8_t bytesprops4[] = {0xdc, 0xda, 0xd3, 0x57, 0x2d, 0x6c, 0x53, 0xce}; - uint8_t bytesprops5[] = {0xb3, 0x14, 0x68, 0x95, 0x8, 0x18, 0x23, 0xb0}; - uint8_t bytesprops7[] = {0x29, 0xe5, 0x96, 0x6a, 0x51, 0xb2, 0xff}; - uint8_t bytesprops6[] = {0xda, 0xe6, 0xb2, 0x73, 0xbf, 0x15, 0x8f, 0x31, 0xf3, 0x66, 0xae, 0x75}; - uint8_t bytesprops8[] = {0xbe, 0x1a, 0x3c, 0xc6, 0x1a, 0x53, 0x79, 0x27, 0x9d}; - uint8_t bytesprops9[] = {0x24, 0xfa, 0x34, 0x5e, 0xf0, 0x4c, 0x9d, 0x1a}; - uint8_t bytesprops10[] = {0xe2, 0x1f, 0xe3, 0xe7, 0x7b, 0xa6, 0x37}; + 0x10, 0xe1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe, 0x1d, 0xe4, 0xa9, 0x1, 0x22, 0x1e, 0x48, 0x28, + 0xa7, 0xb, 0x13, 0x26, 0x0, 0x2, 0x99, 0xe6, 0x0, 0x9, 0x91, 0x6d, 0x35, 0x71, 0xee, 0x55, 0x17, 0x88, 0x2a, + 0x11, 0x0, 0x0, 0x4a, 0xff, 0x13, 0x2e, 0x55, 0x29, 0xc4, 0x27, 0x0, 0x0, 0x4c, 0xf, 0x23, 0x48, 0x50, 0x3, + 0x0, 0xe, 0x2d, 0x6f, 0x47, 0x54, 0x80, 0xa3, 0x4, 0x52, 0xab, 0xc3, 0x8f, 0xf8, 0x99, 0x2e, 0x21, 0x30, 0x2, + 0x21, 0x5a, 0x28, 0x2, 0x0, 0x0, 0x20, 0x8, 0x26, 0x0, 0x1a, 0xc6, 0x8, 0x5e, 0x9f, 0xd2, 0x69, 0x5f, 0x2a, + 0xee, 0xf1, 0x9, 0x46, 0x6c, 0xe0, 0xef, 0x52, 0x4a, 0x2b, 0xa7, 0x18, 0xe8, 0x75, 0xb9, 0x14, 0xb7, 0xf9, 0x0, + 0x1c, 0x8c, 0x6b, 0xe7, 0xc2, 0xb5, 0xd5, 0x5e, 0x6f, 0x20, 0xd3, 0x5c, 0xf4, 0xd6, 0x91, 0x82, 0xae, 0xbe, 0x9e, + 0x3d, 0xff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3b, + 0x51, 0x1d, 0xb3, 0x8d, 0xd7, 0x9, 0x32, 0xb3, 0xe9, 0x1f, 0x0, 0x1b, 0x42, 0x2f, 0x1b, 0xa5, 0xb0, 0x87, 0xeb, + 0xc8, 0x3d, 0x3, 0xe1, 0x3c, 0x96, 0xe0, 0x95, 0xc5, 0xc8, 0x15, 0x2d, 0x49, 0xd6, 0x50, 0x90, 0xa1, 0xc, 0x4a, + 0x2f, 0x16, 0x0, 0x9, 0xe5, 0xb4, 0x4d, 0xe8, 0x69, 0xd7, 0x7e, 0x8f, 0x13, 0x21, 0xf, 0xa, 0x27, 0x0, 0x0, + 0x4a, 0x64, 0x29, 0x1b, 0x18, 0x0, 0x0, 0x22, 0xa1, 0x8, 0x0, 0x13, 0x75, 0x22, 0x13, 0xf6, 0x20, 0xbb, 0xbf, + 0xb0, 0x60, 0x92, 0x1d, 0xf7, 0x15, 0x51, 0x7e, 0x45, 0x98, 0x69, 0xc4, 0x17, 0x23, 0x24, 0xd4, 0x19, 0xa0, 0x1a, + 0x0, 0x17, 0xed, 0xbe, 0xd1, 0x4b, 0x2d, 0xb4, 0x9b, 0xfd, 0x99, 0x73, 0xd2, 0xeb, 0x70, 0xdd, 0x53, 0x99, 0xce, + 0x8e, 0xa5, 0x25, 0x12, 0x38, 0x3f, 0xb, 0x12, 0x0, 0x7, 0x63, 0x5f, 0x11, 0xde, 0x28, 0xe8, 0x37, 0x0, 0x1c, + 0xd5, 0x7a, 0xd9, 0x2d, 0xd7, 0x33, 0xc3, 0x17, 0xbc, 0x47, 0xc6, 0x8c, 0xfb, 0x2b, 0x8b, 0xb7, 0xb7, 0xde, 0xe8, + 0xcc, 0x4d, 0xbb, 0x91, 0xfc, 0x4, 0xa, 0xc0, 0x81}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x91, 0x6d, 0x35, 0x71, 0xee, 0x55, 0x17, 0x88, 0x2a}; + uint8_t bytesprops0[] = {0x99, 0xe6}; + uint8_t bytesprops2[] = {0x2d, 0x6f, 0x47, 0x54, 0x80, 0xa3, 0x4, 0x52, 0xab, 0xc3, 0x8f, 0xf8, 0x99, 0x2e}; + uint8_t bytesprops4[] = {0x8c, 0x6b, 0xe7, 0xc2, 0xb5, 0xd5, 0x5e, 0x6f, 0x20, 0xd3, 0x5c, 0xf4, 0xd6, 0x91, + 0x82, 0xae, 0xbe, 0x9e, 0x3d, 0xff, 0x8f, 0x20, 0x92, 0xc3, 0x6e, 0x97, 0x91, 0xca}; + uint8_t bytesprops3[] = {0xc6, 0x8, 0x5e, 0x9f, 0xd2, 0x69, 0x5f, 0x2a, 0xee, 0xf1, 0x9, 0x46, 0x6c, + 0xe0, 0xef, 0x52, 0x4a, 0x2b, 0xa7, 0x18, 0xe8, 0x75, 0xb9, 0x14, 0xb7, 0xf9}; + uint8_t bytesprops5[] = {0x74, 0x7, 0xa6, 0x78, 0x52, 0x24, 0xd5, 0x57, 0x8e, 0xf1, 0x1e, 0xcb}; + uint8_t bytesprops6[] = {0x1f, 0xa0, 0xaa, 0xb4}; + uint8_t bytesprops7[] = {0xd6, 0x10, 0xda, 0xbe, 0x66, 0x47}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23537}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9638}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops2}, .v = {6, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops6}, .v = {7, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7752}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops0}, .v = {9, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19199}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11861}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19471}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18512}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12290}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23080}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8200}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x4d, 0xa, 0x99, 0x9b, 0x19, 0xdd, 0x73, 0x39, 0x7c, 0x39, - 0x42, 0x83, 0xdf, 0x32, 0x26, 0xc9, 0x71, 0x9, 0x79, 0x13}; - uint8_t byteswillprops1[] = {0x40, 0x9a, 0xe1, 0x8a, 0xe1, 0xdf, 0xc4}; - uint8_t byteswillprops2[] = {0xd6, 0xf3, 0xa6, 0xac, 0xcd, 0x86, 0x7a, 0x76, 0x50, 0x83, 0x70, 0xa1}; - uint8_t byteswillprops3[] = {0x7b, 0xff, 0xe5, 0xbd, 0x82, 0x7b, 0x68, 0x28, 0xee, 0xac}; - uint8_t byteswillprops4[] = {0xd1, 0x20, 0xc6, 0x7, 0x7e, 0xec, 0x7a, 0xfd, 0x10, 0x86, - 0xe2, 0x33, 0xe9, 0xaa, 0xeb, 0xd4, 0x93, 0xd7, 0xdf, 0xd9, - 0x13, 0xf7, 0xa5, 0xa4, 0xd, 0x63, 0xb1, 0x9c, 0xb5, 0xf0}; - uint8_t byteswillprops6[] = {0x85, 0xc, 0xcb, 0x9a, 0x75, 0xdd, 0x35, 0x56, 0xe7, 0x1f, - 0x4, 0xe5, 0xa8, 0xe, 0xf0, 0x3b, 0xd5, 0x4b, 0x8e}; - uint8_t byteswillprops5[] = {0x6b, 0xbf, 0xd8, 0x38, 0x45, 0xf9, 0xc, 0x5d, 0xe9, 0x8c, - 0x66, 0x2d, 0xd6, 0x42, 0x66, 0x37, 0x74, 0x93, 0x96, 0xa8, - 0xf3, 0xc4, 0xb8, 0xde, 0x57, 0xef, 0xf8, 0x4e, 0x2, 0xa4}; + uint8_t byteswillprops0[] = {0x75}; + uint8_t byteswillprops1[] = {0x15, 0x39, 0xc9, 0xea, 0x53, 0xbd, 0xf0, 0x43, 0xfb, 0x17, + 0xb6, 0xbb, 0x9, 0xbb, 0x90, 0x5d, 0x22, 0x7c, 0x8b}; + uint8_t byteswillprops2[] = {0x31, 0xeb, 0xf4, 0x7e, 0xc7, 0x49, 0x22, 0xb4, 0x16, 0x6, + 0xb0, 0x99, 0x50, 0x94, 0xff, 0x63, 0xed, 0xa1, 0x5b, 0x1f, + 0x4c, 0xbf, 0x7, 0xc, 0x26, 0xe8, 0x89, 0x97, 0x3e, 0x29}; + uint8_t byteswillprops3[] = {0x5a, 0x23, 0xc}; + uint8_t byteswillprops4[] = {0xd4, 0x62, 0x34, 0x8f, 0x94, 0xdf, 0xe8, 0xfa, 0xa3, 0xe4, 0x8a, 0x2e, 0x87, 0xed, 0x60, + 0xc3, 0xe, 0x26, 0x82, 0x1e, 0xa8, 0x18, 0x95, 0x7, 0x96, 0xe2, 0xdd, 0xf7, 0x3f}; + uint8_t byteswillprops5[] = {0xba, 0xbe, 0x3f, 0x3, 0x76, 0x3b, 0x51, 0x1d, 0xb3, 0x8d, 0xd7, 0x9, 0x32, 0xb3, 0xe9}; + uint8_t byteswillprops6[] = {0x42, 0x2f, 0x1b, 0xa5, 0xb0, 0x87, 0xeb, 0xc8, 0x3d, 0x3, 0xe1, 0x3c, 0x96, 0xe0, + 0x95, 0xc5, 0xc8, 0x15, 0x2d, 0x49, 0xd6, 0x50, 0x90, 0xa1, 0xc, 0x4a, 0x2f}; + uint8_t byteswillprops7[] = {0xe5, 0xb4, 0x4d, 0xe8, 0x69, 0xd7, 0x7e, 0x8f, 0x13}; + uint8_t byteswillprops8[] = {0x75, 0x22, 0x13, 0xf6, 0x20, 0xbb, 0xbf, 0xb0, 0x60, 0x92, + 0x1d, 0xf7, 0x15, 0x51, 0x7e, 0x45, 0x98, 0x69, 0xc4}; + uint8_t byteswillprops9[] = {0xed, 0xbe, 0xd1, 0x4b, 0x2d, 0xb4, 0x9b, 0xfd, 0x99, 0x73, 0xd2, 0xeb, + 0x70, 0xdd, 0x53, 0x99, 0xce, 0x8e, 0xa5, 0x25, 0x12, 0x38, 0x3f}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {30, (char*)&byteswillprops5}, .v = {19, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25564}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26307}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3535}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3850}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19044}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8865}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, }; - lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xfb, 0xc8, 0x36, 0xc7, 0xce, 0xce, 0xdc, 0x70, 0x48, 0xb, 0x97, 0xc4, 0x81, - 0x41, 0x5f, 0x86, 0x8d, 0xd7, 0xe5, 0xe, 0xbd, 0xc6, 0x6c, 0xf9, 0x3d, 0xca}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb3, 0x25, 0x6c, 0xf0, 0x8f, 0xbf, 0x3e, 0x6f, - 0xde, 0x98, 0x3, 0x64, 0xb2, 0x71, 0xa1}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x63, 0x5f, 0x11, 0xde, 0x28, 0xe8, 0x37}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd5, 0x7a, 0xd9, 0x2d, 0xd7, 0x33, 0xc3, 0x17, 0xbc, 0x47, 0xc6, 0x8c, 0xfb, 0x2b, + 0x8b, 0xb7, 0xb7, 0xde, 0xe8, 0xcc, 0x4d, 0xbb, 0x91, 0xfc, 0x4, 0xa, 0xc0, 0x81}; + lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 20495; - uint8_t client_id_bytes[] = {0xc7, 0xaa, 0x30, 0xd5, 0xc7, 0x36, 0x54, 0x7a, 0x34, 0x6b, 0xf7, 0xc, 0x73, 0x3b, 0xbc, - 0x6c, 0xf1, 0xe3, 0x4c, 0xb9, 0x80, 0x95, 0xa0, 0x8f, 0xe3, 0x96, 0x63, 0x37, 0xdc}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 7652; + uint8_t client_id_bytes[] = {0x6d, 0xba, 0x20, 0xbd, 0xd0, 0x7a}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x19, 0x91}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7398,128 +7353,40 @@ TEST(Connect5QCTest, Encode7) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\181\166\207", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "\140\199\a\SOH\ETX\168\245v\148k\214\201\144\139n\ENQ\170\252Z\142\205", _willMsg = -// ":*\192m\246\&0\144M\255\232<\210\138\STX\142h!j\205\162\158\"\140\190", _willProps = [PropServerKeepAlive -// 13448,PropMaximumQoS 150,PropAuthenticationData -// "&\239u#C\SOH2\160\177\198\133^8\GS\149jF,\192\228\227A\n\GST\140\247",PropReasonString -// "o",PropRequestProblemInformation 226,PropMaximumQoS 224,PropSubscriptionIdentifier 24,PropWillDelayInterval -// 2921,PropSubscriptionIdentifierAvailable 82,PropSessionExpiryInterval 24845,PropServerReference -// "\210)\GS\DLE\192O\242o\EM\186\196\208F",PropReasonString -// "\249\172a\232\229\230D\237\238\135\223\ETB%\aM\211Q\144O",PropSubscriptionIdentifier 29,PropSubscriptionIdentifier -// 5,PropMaximumQoS 213,PropAuthenticationMethod ".\143z\221\151\153\201:",PropRetainAvailable 49,PropMaximumPacketSize -// 30334]}), _cleanSession = False, _keepAlive = 19119, _connID = "\ETBB\213\133\216\235\t0\138\222\&2", _properties = -// [PropSubscriptionIdentifierAvailable 48,PropMessageExpiryInterval 25674,PropSessionExpiryInterval -// 5403,PropRequestResponseInformation 153,PropUserProperty "li\224\&3\162\fE\bD\230" -// "H#\DC1\239\218W\155\239m\198T\157eF\219\249<\251\152b",PropSessionExpiryInterval 15951,PropMessageExpiryInterval -// 16481,PropResponseTopic "\135N\252\207\135\158\250\158\185G\134:",PropSubscriptionIdentifier -// 24,PropSubscriptionIdentifier 7,PropSubscriptionIdentifier 10,PropSubscriptionIdentifierAvailable 206,PropTopicAlias -// 7630,PropWildcardSubscriptionAvailable 115,PropServerReference "4\185\SI",PropAuthenticationMethod -// "\206\ENQ\243k4Ow\153\222x\235]\203\195L\t\193y\205\155f8\ENQ\145\178\196\ENQ j",PropUserProperty -// "\135Mh\rJ\205\147\&5\191\DC3\169\208\CAN\234!\146R\ETB\214-" -// "\EOT\203M{\SOH\232=\254;\225kN2>\SOH\227",PropPayloadFormatIndicator 44,PropMessageExpiryInterval -// 3989,PropResponseTopic "d",PropContentType "M\184\DELvUAX\190\160\150\STXl\"\214\a:z\229\NUL\213"]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS2, _willTopic = "\167\186,\225\231\n\229RS\158n\EOT\157pX\SI\134\254\187\&5\178[\235\215\141", _willMsg = "\183~", +// _willProps = [PropReasonString "\131\239}\233\220"]}), _cleanSession = True, _keepAlive = 4897, _connID = +// "\215ES)\213\"\RS\149\165\167\252\216_\166", _properties = [PropAssignedClientIdentifier +// "\128\128D\184\170\196U\255\162\EOT8}6\229b\DLE\170n\214\186\201"]} TEST(Connect5QCTest, Encode8) { - uint8_t pkt[] = { - 0x10, 0x8f, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x74, 0x4a, 0xaf, 0xc8, 0x1, 0x29, 0x30, 0x2, 0x0, - 0x0, 0x64, 0x4a, 0x11, 0x0, 0x0, 0x15, 0x1b, 0x19, 0x99, 0x26, 0x0, 0xa, 0x6c, 0x69, 0xe0, 0x33, 0xa2, 0xc, - 0x45, 0x8, 0x44, 0xe6, 0x0, 0x14, 0x48, 0x23, 0x11, 0xef, 0xda, 0x57, 0x9b, 0xef, 0x6d, 0xc6, 0x54, 0x9d, 0x65, - 0x46, 0xdb, 0xf9, 0x3c, 0xfb, 0x98, 0x62, 0x11, 0x0, 0x0, 0x3e, 0x4f, 0x2, 0x0, 0x0, 0x40, 0x61, 0x8, 0x0, - 0xc, 0x87, 0x4e, 0xfc, 0xcf, 0x87, 0x9e, 0xfa, 0x9e, 0xb9, 0x47, 0x86, 0x3a, 0xb, 0x18, 0xb, 0x7, 0xb, 0xa, - 0x29, 0xce, 0x23, 0x1d, 0xce, 0x28, 0x73, 0x1c, 0x0, 0x3, 0x34, 0xb9, 0xf, 0x15, 0x0, 0x1d, 0xce, 0x5, 0xf3, - 0x6b, 0x34, 0x4f, 0x77, 0x99, 0xde, 0x78, 0xeb, 0x5d, 0xcb, 0xc3, 0x4c, 0x9, 0xc1, 0x79, 0xcd, 0x9b, 0x66, 0x38, - 0x5, 0x91, 0xb2, 0xc4, 0x5, 0x20, 0x6a, 0x26, 0x0, 0x14, 0x87, 0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x8, 0x2e, 0x8f, 0x7a, 0xdd, 0x97, 0x99, 0xc9, 0x3a, 0x25, - 0x31, 0x27, 0x0, 0x0, 0x76, 0x7e, 0x0, 0x15, 0x8c, 0xc7, 0x7, 0x1, 0x3, 0xa8, 0xf5, 0x76, 0x94, 0x6b, 0xd6, - 0xc9, 0x90, 0x8b, 0x6e, 0x5, 0xaa, 0xfc, 0x5a, 0x8e, 0xcd, 0x0, 0x18, 0x3a, 0x2a, 0xc0, 0x6d, 0xf6, 0x30, 0x90, - 0x4d, 0xff, 0xe8, 0x3c, 0xd2, 0x8a, 0x2, 0x8e, 0x68, 0x21, 0x6a, 0xcd, 0xa2, 0x9e, 0x22, 0x8c, 0xbe, 0x0, 0x3, - 0xb5, 0xa6, 0xcf}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x48, 0x23, 0x11, 0xef, 0xda, 0x57, 0x9b, 0xef, 0x6d, 0xc6, - 0x54, 0x9d, 0x65, 0x46, 0xdb, 0xf9, 0x3c, 0xfb, 0x98, 0x62}; - uint8_t bytesprops0[] = {0x6c, 0x69, 0xe0, 0x33, 0xa2, 0xc, 0x45, 0x8, 0x44, 0xe6}; - uint8_t bytesprops2[] = {0x87, 0x4e, 0xfc, 0xcf, 0x87, 0x9e, 0xfa, 0x9e, 0xb9, 0x47, 0x86, 0x3a}; - uint8_t bytesprops3[] = {0x34, 0xb9, 0xf}; - uint8_t bytesprops4[] = {0xce, 0x5, 0xf3, 0x6b, 0x34, 0x4f, 0x77, 0x99, 0xde, 0x78, 0xeb, 0x5d, 0xcb, 0xc3, 0x4c, - 0x9, 0xc1, 0x79, 0xcd, 0x9b, 0x66, 0x38, 0x5, 0x91, 0xb2, 0xc4, 0x5, 0x20, 0x6a}; - uint8_t bytesprops6[] = {0x4, 0xcb, 0x4d, 0x7b, 0x1, 0xe8, 0x3d, 0xfe, 0x3b, 0xe1, 0x6b, 0x4e, 0x32, 0x3e, 0x1, 0xe3}; - uint8_t bytesprops5[] = {0x87, 0x4d, 0x68, 0xd, 0x4a, 0xcd, 0x93, 0x35, 0xbf, 0x13, - 0xa9, 0xd0, 0x18, 0xea, 0x21, 0x92, 0x52, 0x17, 0xd6, 0x2d}; - uint8_t bytesprops7[] = {0x64}; - uint8_t bytesprops8[] = {0x4d, 0xb8, 0x7f, 0x76, 0x55, 0x41, 0x58, 0xbe, 0xa0, 0x96, - 0x2, 0x6c, 0x22, 0xd6, 0x7, 0x3a, 0x7a, 0xe5, 0x0, 0xd5}; + uint8_t pkt[] = {0x10, 0x5b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x36, 0x13, 0x21, 0x18, 0x12, 0x0, 0x15, + 0x80, 0x80, 0x44, 0xb8, 0xaa, 0xc4, 0x55, 0xff, 0xa2, 0x4, 0x38, 0x7d, 0x36, 0xe5, 0x62, 0x10, + 0xaa, 0x6e, 0xd6, 0xba, 0xc9, 0x0, 0xe, 0xd7, 0x45, 0x53, 0x29, 0xd5, 0x22, 0x1e, 0x95, 0xa5, + 0xa7, 0xfc, 0xd8, 0x5f, 0xa6, 0x8, 0x1f, 0x0, 0x5, 0x83, 0xef, 0x7d, 0xe9, 0xdc, 0x0, 0x19, + 0xa7, 0xba, 0x2c, 0xe1, 0xe7, 0xa, 0xe5, 0x52, 0x53, 0x9e, 0x6e, 0x4, 0x9d, 0x70, 0x58, 0xf, + 0x86, 0xfe, 0xbb, 0x35, 0xb2, 0x5b, 0xeb, 0xd7, 0x8d, 0x0, 0x2, 0xb7, 0x7e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x80, 0x80, 0x44, 0xb8, 0xaa, 0xc4, 0x55, 0xff, 0xa2, 0x4, 0x38, + 0x7d, 0x36, 0xe5, 0x62, 0x10, 0xaa, 0x6e, 0xd6, 0xba, 0xc9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25674}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5403}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15951}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16481}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7630}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops5}, .v = {16, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3989}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x26, 0xef, 0x75, 0x23, 0x43, 0x1, 0x32, 0xa0, 0xb1, 0xc6, 0x85, 0x5e, 0x38, 0x1d, - 0x95, 0x6a, 0x46, 0x2c, 0xc0, 0xe4, 0xe3, 0x41, 0xa, 0x1d, 0x54, 0x8c, 0xf7}; - uint8_t byteswillprops1[] = {0x6f}; - uint8_t byteswillprops2[] = {0xd2, 0x29, 0x1d, 0x10, 0xc0, 0x4f, 0xf2, 0x6f, 0x19, 0xba, 0xc4, 0xd0, 0x46}; - uint8_t byteswillprops3[] = {0xf9, 0xac, 0x61, 0xe8, 0xe5, 0xe6, 0x44, 0xed, 0xee, 0x87, - 0xdf, 0x17, 0x25, 0x7, 0x4d, 0xd3, 0x51, 0x90, 0x4f}; - uint8_t byteswillprops4[] = {0x2e, 0x8f, 0x7a, 0xdd, 0x97, 0x99, 0xc9, 0x3a}; + uint8_t byteswillprops0[] = {0x83, 0xef, 0x7d, 0xe9, 0xdc}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13448}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2921}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24845}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30334}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops0}}}, }; - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8c, 0xc7, 0x7, 0x1, 0x3, 0xa8, 0xf5, 0x76, 0x94, 0x6b, 0xd6, - 0xc9, 0x90, 0x8b, 0x6e, 0x5, 0xaa, 0xfc, 0x5a, 0x8e, 0xcd}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3a, 0x2a, 0xc0, 0x6d, 0xf6, 0x30, 0x90, 0x4d, 0xff, 0xe8, 0x3c, 0xd2, - 0x8a, 0x2, 0x8e, 0x68, 0x21, 0x6a, 0xcd, 0xa2, 0x9e, 0x22, 0x8c, 0xbe}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa7, 0xba, 0x2c, 0xe1, 0xe7, 0xa, 0xe5, 0x52, 0x53, 0x9e, 0x6e, 0x4, 0x9d, + 0x70, 0x58, 0xf, 0x86, 0xfe, 0xbb, 0x35, 0xb2, 0x5b, 0xeb, 0xd7, 0x8d}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xb7, 0x7e}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; @@ -7527,14 +7394,11 @@ TEST(Connect5QCTest, Encode8) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19119; - uint8_t client_id_bytes[] = {0x17, 0x42, 0xd5, 0x85, 0xd8, 0xeb, 0x9, 0x30, 0x8a, 0xde, 0x32}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 4897; + uint8_t client_id_bytes[] = {0xd7, 0x45, 0x53, 0x29, 0xd5, 0x22, 0x1e, 0x95, 0xa5, 0xa7, 0xfc, 0xd8, 0x5f, 0xa6}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xb5, 0xa6, 0xcf}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -7543,150 +7407,306 @@ TEST(Connect5QCTest, Encode8) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = -// 26405, _connID = "", _properties = [PropPayloadFormatIndicator 152,PropSessionExpiryInterval 23746]} +// ConnectRequest {_username = Nothing, _password = Just "\179\171\192\219e27\202\244Y\238\&9\151", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\221\239\USQ\"", _willMsg = "", _willProps = +// [PropResponseInformation "",PropMessageExpiryInterval 22718,PropMessageExpiryInterval 30489,PropServerReference +// "\SOH9\SI\231n\192\&0\131\174(K\137G\157..\".)\r\200",PropAuthenticationData +// "\SI\153\128\245\140\187\fq\157\195\155\ETX",PropContentType +// "\232\163\189\148d\GS\190\DC2\223\245\164\a\153",PropSubscriptionIdentifier 26,PropWildcardSubscriptionAvailable +// 103,PropAssignedClientIdentifier "\161v\133c",PropWildcardSubscriptionAvailable 179,PropTopicAlias +// 28960,PropSessionExpiryInterval 4948,PropReasonString +// "(\ETX\234\205Th\243\249\210\244\148\&2\DC3\204^\236S\222\245\EM2W",PropReasonString +// "\EMO\240\STX;\DC2\n\214\158!\216\156d\236G\226",PropMaximumQoS 112,PropMaximumQoS 191,PropRetainAvailable +// 33,PropUserProperty "\SO}\GSW\RS,\137t\152\DC2\249wQ" +// "\148\209\242\207\218\&2\128?\DLEa\184\191\141L\225.\183f\155U\DC4\135(",PropMessageExpiryInterval +// 31362,PropWillDelayInterval 19268,PropResponseInformation +// "\179\230\206\&9\227n#!\178@\v\200oj\192\155LU\170\141\161c\202k",PropMaximumQoS 128]} TEST(Connect5QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x14, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2, 0x67, - 0x25, 0x7, 0x1, 0x98, 0x11, 0x0, 0x0, 0x5c, 0xc2, 0x0, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t pkt[] = { + 0x10, 0xbb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x54, 0x6e, 0x56, 0x9d, 0x1, 0x1a, 0x0, 0x2, 0x69, + 0xa0, 0x8, 0x0, 0x15, 0x59, 0xfe, 0xc3, 0x6a, 0xf3, 0xa2, 0x2a, 0xf0, 0x8d, 0xe5, 0x40, 0xa8, 0xd2, 0xbd, 0xbf, + 0x79, 0xa0, 0xe4, 0xaa, 0xdd, 0xd5, 0x11, 0x0, 0x0, 0xa, 0xdd, 0x16, 0x0, 0x1c, 0xf, 0x5e, 0x7e, 0x20, 0xf9, + 0x85, 0xed, 0x63, 0xc5, 0xdf, 0x87, 0xaa, 0xb6, 0xc5, 0x7a, 0x73, 0x8e, 0x42, 0x57, 0xcb, 0x42, 0xf4, 0x83, 0x8c, + 0x4, 0xde, 0x6d, 0x47, 0x2a, 0x45, 0x1f, 0x0, 0xc, 0x8, 0xa, 0x53, 0x90, 0x9, 0x93, 0xa2, 0x79, 0xf5, 0x7b, + 0x87, 0x53, 0x25, 0xda, 0x2, 0x0, 0x0, 0xe, 0xf2, 0x22, 0x51, 0x98, 0x15, 0x0, 0xd, 0xcb, 0x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 0xf3, 0xf9, 0xd2, 0xf4, + 0x94, 0x32, 0x13, 0xcc, 0x5e, 0xec, 0x53, 0xde, 0xf5, 0x19, 0x32, 0x57, 0x1f, 0x0, 0x10, 0x19, 0x4f, 0xf0, 0x2, + 0x3b, 0x12, 0xa, 0xd6, 0x9e, 0x21, 0xd8, 0x9c, 0x64, 0xec, 0x47, 0xe2, 0x24, 0x70, 0x24, 0xbf, 0x25, 0x21, 0x26, + 0x0, 0xd, 0xe, 0x7d, 0x1d, 0x57, 0x1e, 0x2c, 0x89, 0x74, 0x98, 0x12, 0xf9, 0x77, 0x51, 0x0, 0x17, 0x94, 0xd1, + 0xf2, 0xcf, 0xda, 0x32, 0x80, 0x3f, 0x10, 0x61, 0xb8, 0xbf, 0x8d, 0x4c, 0xe1, 0x2e, 0xb7, 0x66, 0x9b, 0x55, 0x14, + 0x87, 0x28, 0x2, 0x0, 0x0, 0x7a, 0x82, 0x18, 0x0, 0x0, 0x4b, 0x44, 0x1a, 0x0, 0x1b, 0xb3, 0xe6, 0xce, 0x39, + 0xe3, 0x6e, 0x23, 0x21, 0xb2, 0x40, 0xb, 0xc8, 0x6f, 0x6a, 0xc0, 0x9b, 0x4c, 0x55, 0xaa, 0x8d, 0xa1, 0x63, 0xca, + 0x3c, 0x75, 0x82, 0xf5, 0x0, 0x5, 0xdd, 0xef, 0x1f, 0x51, 0x22, 0x0, 0x0, 0x0, 0xd, 0xb3, 0xab, 0xc0, 0xdb, + 0x65, 0x32, 0x37, 0xca, 0xf4, 0x59, 0xee, 0x39, 0x97}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x69, 0xa0}; + uint8_t bytesprops1[] = {0x59, 0xfe, 0xc3, 0x6a, 0xf3, 0xa2, 0x2a, 0xf0, 0x8d, 0xe5, 0x40, + 0xa8, 0xd2, 0xbd, 0xbf, 0x79, 0xa0, 0xe4, 0xaa, 0xdd, 0xd5}; + uint8_t bytesprops2[] = {0xf, 0x5e, 0x7e, 0x20, 0xf9, 0x85, 0xed, 0x63, 0xc5, 0xdf, 0x87, 0xaa, 0xb6, 0xc5, + 0x7a, 0x73, 0x8e, 0x42, 0x57, 0xcb, 0x42, 0xf4, 0x83, 0x8c, 0x4, 0xde, 0x6d, 0x47}; + uint8_t bytesprops3[] = {0x8, 0xa, 0x53, 0x90, 0x9, 0x93, 0xa2, 0x79, 0xf5, 0x7b, 0x87, 0x53}; + uint8_t bytesprops4[] = {0xcb, 0xdc, 0xc5, 0x15, 0x46, 0x77, 0xcc, 0x61, 0x92, 0x1c, 0x9e, 0x49, 0x3a}; + uint8_t bytesprops6[] = {0x71, 0xa1, 0x55, 0x53, 0xf, 0x78, 0x57, 0xdd, 0xa3, 0x98, 0x2d, 0x68, 0x77, 0x94}; + uint8_t bytesprops5[] = {0xa2, 0x4a, 0xf7, 0x34, 0x30, 0x70, 0xaf}; + uint8_t bytesprops7[] = {0xa9, 0x8b, 0x67, 0xae, 0x7c, 0x90, 0x5e, 0x23, 0xd5, 0xf2, 0x50, 0x3e, 0x6b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23746}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2781}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3826}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20888}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24341}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops5}, .v = {14, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops1[] = {0x1, 0x39, 0xf, 0xe7, 0x6e, 0xc0, 0x30, 0x83, 0xae, 0x28, 0x4b, + 0x89, 0x47, 0x9d, 0x2e, 0x2e, 0x22, 0x2e, 0x29, 0xd, 0xc8}; + uint8_t byteswillprops2[] = {0xf, 0x99, 0x80, 0xf5, 0x8c, 0xbb, 0xc, 0x71, 0x9d, 0xc3, 0x9b, 0x3}; + uint8_t byteswillprops3[] = {0xe8, 0xa3, 0xbd, 0x94, 0x64, 0x1d, 0xbe, 0x12, 0xdf, 0xf5, 0xa4, 0x7, 0x99}; + uint8_t byteswillprops4[] = {0xa1, 0x76, 0x85, 0x63}; + uint8_t byteswillprops5[] = {0x28, 0x3, 0xea, 0xcd, 0x54, 0x68, 0xf3, 0xf9, 0xd2, 0xf4, 0x94, + 0x32, 0x13, 0xcc, 0x5e, 0xec, 0x53, 0xde, 0xf5, 0x19, 0x32, 0x57}; + uint8_t byteswillprops6[] = {0x19, 0x4f, 0xf0, 0x2, 0x3b, 0x12, 0xa, 0xd6, + 0x9e, 0x21, 0xd8, 0x9c, 0x64, 0xec, 0x47, 0xe2}; + uint8_t byteswillprops8[] = {0x94, 0xd1, 0xf2, 0xcf, 0xda, 0x32, 0x80, 0x3f, 0x10, 0x61, 0xb8, 0xbf, + 0x8d, 0x4c, 0xe1, 0x2e, 0xb7, 0x66, 0x9b, 0x55, 0x14, 0x87, 0x28}; + uint8_t byteswillprops7[] = {0xe, 0x7d, 0x1d, 0x57, 0x1e, 0x2c, 0x89, 0x74, 0x98, 0x12, 0xf9, 0x77, 0x51}; + uint8_t byteswillprops9[] = {0xb3, 0xe6, 0xce, 0x39, 0xe3, 0x6e, 0x23, 0x21, 0xb2, 0x40, 0xb, 0xc8, 0x6f, 0x6a, + 0xc0, 0x9b, 0x4c, 0x55, 0xaa, 0x8d, 0xa1, 0x63, 0xca, 0x3c, 0x75, 0x82, 0xf5}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22718}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30489}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28960}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4948}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {13, (char*)&byteswillprops7}, .v = {23, (char*)&byteswillprops8}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31362}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19268}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops9}}}, + }; + + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xdd, 0xef, 0x1f, 0x51, 0x22}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 26405; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 28246; + uint8_t client_id_bytes[] = {0x36, 0x53, 0x8a, 0xcd, 0xdd, 0xdc, 0x6c, 0x6d, 0xf2, 0x5f, 0x78, 0x36, 0xe6, + 0xc0, 0x14, 0xdb, 0x86, 0x75, 0x14, 0x30, 0xbf, 0x74, 0x50, 0x5e, 0xd4, 0xf7}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t password_bytes[] = {0xb3, 0xab, 0xc0, 0xdb, 0x65, 0x32, 0x37, 0xca, 0xf4, 0x59, 0xee, 0x39, 0x97}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\244\160\221\&0\230\206m\172", _password = Just -// "\165\183%\251X.>\250\DC2jTpG*a)\199u\169\200c\ETB\200\246\180\&5\171\157S\185", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = -// "\189>\247Z\247\130\236\149k\150\218\181\\-Za%\"\153\153\249\154\229\155\174\154", _willMsg = -// "1\183yF.\202\190\&0\172\233\196\243\200;e\233\133N\232/T\223\157-)\ESC\144\SYN9", _willProps = -// [PropTopicAliasMaximum 21011,PropPayloadFormatIndicator 123,PropRequestProblemInformation -// 20,PropRequestProblemInformation 143,PropReasonString -// "\141#\208\DC2HkV<\234\254$3\170",PropRequestResponseInformation 83,PropRequestResponseInformation -// 118,PropUserProperty "4\199{\243" "d\176\165\FSn\GSU\190\172\207\167\223\EOT\198i\NAK\NAKu\SI\",",PropReceiveMaximum -// 20984,PropServerReference "qEm\240\141",PropMaximumPacketSize 19400,PropReasonString -// "\v\162\ACKi*\187\143\166l\ENQ&e\255\185C\DEL\169",PropSharedSubscriptionAvailable -// 161,PropAuthenticationData "\156\202~\SUB\159P\241\&2X\182\144\170\227{",PropSharedSubscriptionAvailable -// 175,PropTopicAliasMaximum 18891]}), _cleanSession = True, _keepAlive = 26688, _connID = -// "\246\249\133]\247\EOTD,\146\246\247\159\145\&1O\239Y\129\183+\237\ACK\b", _properties = [PropCorrelationData -// "\241s\SUB\SOH\185",PropRetainAvailable 188,PropSessionExpiryInterval 18205,PropResponseInformation -// "\236\DC2\207\159j\181\SIF\129\EMvRdc\241\240}_ e\199\252\133X\135",PropRequestResponseInformation -// 20,PropWildcardSubscriptionAvailable 141,PropRequestProblemInformation 245]} +// ConnectRequest {_username = Just "a\240\130l{", _password = Just +// "\139\168iv\184\216p\167\249\142\150\188G^'\235a\GS", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = +// "\DC4\144\178\229\CAN\160\DC2\233\SI\160\DC1G\219\173\175\r\161\&3\250\246\200\250\r\199J\154\165\195\221\237", +// _willMsg = " \207(\FS?\175Cq\NUL\154(\203(\186\197\156`\189O\255\195\169\153\RS\226\b`h", _willProps = +// [PropCorrelationData +// "\236\178\197~\STX\NULy\189\224\b*\v\238\151\152\203\DC4H~\189\189J\168\202\234\223\132\168",PropReceiveMaximum +// 30115,PropTopicAlias 12374,PropResponseTopic "o\232",PropWillDelayInterval 27982,PropServerKeepAlive +// 23541,PropRetainAvailable 187,PropMessageExpiryInterval 22446,PropServerReference +// "\177\183\219\223\162E\151EIW\226/\154\128s)\187\242"]}), _cleanSession = True, _keepAlive = 13826, _connID = "", +// _properties = [PropRequestResponseInformation 160,PropMaximumPacketSize 26751,PropAuthenticationMethod +// "Z\t",PropPayloadFormatIndicator 71,PropContentType "\RSC\154\FS;\DC2",PropRequestResponseInformation +// 197,PropRequestProblemInformation 183,PropSubscriptionIdentifierAvailable 243,PropMessageExpiryInterval +// 18872,PropRetainAvailable 244,PropMaximumPacketSize 13684,PropCorrelationData +// "\204\STX\236q,\211'\138P\161S\136+\163\SI\240x\DC2\131\129\210",PropResponseTopic +// "$\142\152\245\&6\ENQ\163\238\179\"O\162\215*\251\177\&3\ACK\231\149",PropRequestProblemInformation +// 163,PropWillDelayInterval 24681,PropSessionExpiryInterval 31574,PropReasonString +// "\ETB\216*p\rd\248*dIe\154(\166\194\222\205\206\222\215",PropContentType +// ",#\227\179\151+{",PropSharedSubscriptionAvailable 219,PropAuthenticationMethod +// "\139N\EM\180\186x\145\131`l2h)\201\155\152\177\144\FSC\223\238\154\237\&6dRu4\170",PropUserProperty +// "\237_\195\211\163\204P2f\162\DLE\177\236\180\255_\196\229\207\241{\149P\212\233\157#\149u\132\157l",PropServerReference -// "(\148\200\145\173\166\157\243q",PropAuthenticationData "\SOI&\ng\141%",PropTopicAliasMaximum -// 1937,PropSessionExpiryInterval 16722,PropMaximumQoS 71,PropAssignedClientIdentifier -// "\196#\a{\234\157\ENQja\237\228d\234^c\193_~\180\170\209\145<",PropAssignedClientIdentifier -// "\234\GS\151\EOTY\222@j\128\195\ACKK;*\240\231\245\248R\130\159a\DC2\US\n\131`\196\203a\214\169\DC2\164k",PropAssignedClientIdentifier +// "\241?\174A\148\194\220\207\b\232o'\191f\196g\202&\241\181]\NUL8\139X\180\229\167\&6\212",PropSubscriptionIdentifier +// 0]}), _cleanSession = True, _keepAlive = 7077, _connID = "\166\&2\183R\234\EM*\227 \nz\SYN\ENQ", _properties = +// [PropSubscriptionIdentifierAvailable 184,PropSessionExpiryInterval 30559,PropSubscriptionIdentifier +// 25,PropUserProperty "\v\DC3T\175R\161\245\244" "",PropMessageExpiryInterval 9738,PropPayloadFormatIndicator +// 210,PropSharedSubscriptionAvailable 42,PropSharedSubscriptionAvailable 253,PropTopicAlias 4943,PropResponseTopic +// "gY\132",PropTopicAlias 8971,PropAuthenticationMethod +// "\161a\230q\SYN\ACK\204\168P\EOT\165\USz\203\228\227\240\DC3\141n\211Vu{\243\201,\NULE\161",PropTopicAlias +// 11926,PropAssignedClientIdentifier "\NAK\223",PropAuthenticationMethod +// "\158\171\141\228\145\225(\133d\194\&9\186\209\ENQ",PropSharedSubscriptionAvailable 39,PropMaximumQoS +// 223,PropUserProperty "\227\178\161\167\232\149\174>\STX\233\SO\156\ACKD\190&Iq\168\191" +// "\160\151\239|Fq\216\129\&8\250N\130T\152\167\ETB\246\b\178\130\RS[W\132",PropMaximumPacketSize +// 12119,PropMessageExpiryInterval 11980,PropReasonString +// "\187\156\155\226\ENQ(ym\234\DLE1i\234\SO\171c\207p",PropTopicAlias 15565,PropSessionExpiryInterval +// 19627,PropSubscriptionIdentifierAvailable 9,PropMaximumPacketSize 1238]} TEST(Connect5QCTest, Encode13) { uint8_t pkt[] = { - 0x10, 0xd8, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x4c, 0x67, 0xa7, 0xa7, 0x1, 0x27, 0x0, 0x0, 0x62, - 0xe3, 0x1a, 0x0, 0xf, 0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6e, 0xf8, 0xa, 0x7b, 0xa5, 0x38, - 0x0, 0xc, 0xfa, 0xc8, 0xa2, 0x86, 0x4f, 0x46, 0x1c, 0x18, 0x83, 0x3d, 0xf, 0x1b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe9, 0x5c, 0xfa, 0x1a, 0x15, 0x6b, 0x4b, 0x84, 0xe1, 0xcb, 0x4a, 0x8f, 0x2b, 0xb8, 0xa5}; - uint8_t bytesprops1[] = {0x80, 0x66, 0x5b, 0xcd, 0x63, 0xfe, 0xa5, 0x44, 0xf5, 0xdb, 0xd8, 0x64, - 0xf8, 0x2e, 0xb7, 0xc2, 0x38, 0x55, 0x7c, 0x2e, 0xf, 0x75, 0xa7}; - uint8_t bytesprops2[] = {0x19, 0x5, 0xbe, 0x72, 0xf7, 0x3b, 0x83, 0x49, - 0xb0, 0xda, 0x69, 0x5e, 0x1a, 0xff, 0x63, 0x8f}; - uint8_t bytesprops3[] = {0x7, 0xd, 0x43, 0xb9, 0x45, 0x6f, 0x1a, 0x17, 0x54, 0x8b, 0xd4, 0x3, 0x81, 0x64, - 0x79, 0x20, 0x4f, 0xdf, 0x9e, 0x63, 0xc, 0x61, 0x5d, 0xd6, 0x8b, 0x16, 0xdd}; - uint8_t bytesprops4[] = {0xcf, 0xc7, 0xb9}; - uint8_t bytesprops5[] = {0xb0, 0x4b, 0x70, 0xf4, 0xb1, 0x47, 0x87, 0x61, 0x7}; - uint8_t bytesprops6[] = {0}; + 0x10, 0x89, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x1b, 0xa5, 0xca, 0x1, 0x29, 0xb8, 0x11, 0x0, + 0x0, 0x77, 0x5f, 0xb, 0x19, 0x26, 0x0, 0x8, 0xb, 0x13, 0x54, 0xaf, 0x52, 0xa1, 0xf5, 0xf4, 0x0, 0x0, 0x2, + 0x0, 0x0, 0x26, 0xa, 0x1, 0xd2, 0x2a, 0x2a, 0x2a,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x22, 0x33, 0x33, 0x18, 0x0, 0x0, 0x30, 0xa4, 0x12, 0x0, 0x12, 0xf0, + 0xa6, 0xf7, 0xdf, 0x7c, 0x23, 0xc1, 0xc1, 0xb2, 0xc1, 0x61, 0x8a, 0xb7, 0xe4, 0x7c, 0xa2, 0x3d, 0x80, 0x2, 0x0, + 0x0, 0x76, 0x78, 0x2a, 0xd, 0x21, 0x53, 0xd6, 0x19, 0xda, 0x8, 0x0, 0x11, 0xf4, 0xf2, 0x3e, 0x61, 0x12, 0x1f, + 0xa, 0x83, 0x60, 0xc4, 0xcb, 0x61, 0xd6, 0xa9, 0x12, 0xa4, 0x6b, 0x12, 0x0, 0x1e, 0xf1, 0x3f, 0xae, 0x41, 0x94, + 0xc2, 0xdc, 0xcf, 0x8, 0xe8, 0x6f, 0x27, 0xbf, 0x66, 0xc4, 0x67, 0xca, 0x26, 0xf1, 0xb5, 0x5d, 0x0, 0x38, 0x8b, + 0x58, 0xb4, 0xe5, 0xa7, 0x36, 0xd4, 0xb, 0x0, 0x0, 0x1, 0x8d, 0x0, 0xa, 0xfb, 0x9a, 0xca, 0xfc, 0x35, 0x31, + 0x69, 0x28, 0xe, 0x4b, 0x0, 0x19, 0xeb, 0x77, 0x84, 0x6d, 0x5d, 0xf8, 0x24, 0x34, 0xe8, 0x30, 0xf9, 0x56, 0xd6, + 0x7f, 0xb6, 0xaa, 0x4, 0x10, 0x11, 0xd4, 0x58, 0x93, 0x2d, 0xcf, 0x30, 0x0, 0x15, 0x42, 0xf5, 0xec, 0x80, 0xc4, + 0x22, 0xb, 0xa6, 0x5b, 0x18, 0xa0, 0x75, 0x92, 0x26, 0x5, 0x2a, 0x11, 0x74, 0x4e, 0x3f, 0x68}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops0[] = {0xb, 0x13, 0x54, 0xaf, 0x52, 0xa1, 0xf5, 0xf4}; + uint8_t bytesprops2[] = {0x67, 0x59, 0x84}; + uint8_t bytesprops3[] = {0xa1, 0x61, 0xe6, 0x71, 0x16, 0x6, 0xcc, 0xa8, 0x50, 0x4, 0xa5, 0x1f, 0x7a, 0xcb, 0xe4, + 0xe3, 0xf0, 0x13, 0x8d, 0x6e, 0xd3, 0x56, 0x75, 0x7b, 0xf3, 0xc9, 0x2c, 0x0, 0x45, 0xa1}; + uint8_t bytesprops4[] = {0x15, 0xdf}; + uint8_t bytesprops5[] = {0x9e, 0xab, 0x8d, 0xe4, 0x91, 0xe1, 0x28, 0x85, 0x64, 0xc2, 0x39, 0xba, 0xd1, 0x5}; + uint8_t bytesprops7[] = {0xa0, 0x97, 0xef, 0x7c, 0x46, 0x71, 0xd8, 0x81, 0x38, 0xfa, 0x4e, 0x82, + 0x54, 0x98, 0xa7, 0x17, 0xf6, 0x8, 0xb2, 0x82, 0x1e, 0x5b, 0x57, 0x84}; + uint8_t bytesprops6[] = {0xe3, 0xb2, 0xa1, 0xa7, 0xe8, 0x95, 0xae, 0x3e, 0x2, 0xe9, + 0xe, 0x9c, 0x6, 0x44, 0xbe, 0x26, 0x49, 0x71, 0xa8, 0xbf}; + uint8_t bytesprops8[] = {0xbb, 0x9c, 0x9b, 0xe2, 0x5, 0x28, 0x79, 0x6d, 0xea, + 0x10, 0x31, 0x69, 0xea, 0xe, 0xab, 0x63, 0xcf, 0x70}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25315}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10460}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30945}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17366}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19287}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22133}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28666}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30559}}, {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9738}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4943}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8971}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11926}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops6}, .v = {24, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12119}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11980}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15565}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19627}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1238}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x73, 0x8c, 0xca, 0x8b, 0x3a, 0x58, 0xb2, 0xf1, 0xe8, 0xba, 0xfc, - 0x7d, 0xdc, 0x48, 0xc8, 0x92, 0x56, 0xca, 0xb2, 0xb, 0xa5, 0xb6}; - uint8_t byteswillprops1[] = {0xc, 0x57, 0x15, 0x62, 0x6c, 0xa6, 0xc5, 0xc1, - 0x7a, 0xa5, 0x5c, 0x56, 0xfb, 0xba, 0x7d, 0x70}; - uint8_t byteswillprops2[] = {0x58, 0xaf, 0x5f, 0xd0, 0xb1, 0xc9, 0x1c, 0x88, 0x1a, 0x8, 0xf1, 0x62, 0x1f, 0x55, - 0x29, 0x80, 0xb2, 0x8, 0x7, 0x8, 0x19, 0x55, 0x43, 0x2a, 0x8f, 0x23, 0x34}; - uint8_t byteswillprops3[] = {0xbd, 0x1f, 0x1e, 0x1c, 0xf5, 0xc8, 0xa6, 0xed, 0x7a, 0xb6, 0xa5, 0x61, - 0x26, 0xd7, 0x16, 0x71, 0x37, 0xfc, 0xf6, 0x13, 0x3b, 0xd0, 0xea, 0x2f}; - uint8_t byteswillprops5[] = {0x42, 0x7d, 0x98, 0x99, 0x61, 0xdc, 0x6, 0x2b, 0x65, 0x49, 0xbc, 0xa6, 0x7f, - 0x41, 0xe8, 0x32, 0x86, 0x69, 0x43, 0x6f, 0x7b, 0xb9, 0xe5, 0xb3, 0xa8}; - uint8_t byteswillprops4[] = {0xdb, 0x12, 0x32, 0x9b, 0x65, 0x68, 0xbb, 0xaf, 0x21, 0xdc, 0xa, - 0x64, 0xb, 0x53, 0xa3, 0xc3, 0xf3, 0x33, 0x51, 0x9b, 0x94}; - uint8_t byteswillprops6[] = {0xf1, 0x24, 0x7d, 0xba, 0xcc}; - uint8_t byteswillprops8[] = {0x72, 0x4c, 0x84, 0x5a, 0x7b, 0x6b}; - uint8_t byteswillprops7[] = {0x28, 0xb4, 0x30, 0xa2, 0x4e, 0x35, 0xc7, 0xae, 0x81, 0x9e, 0xdb, 0x4, 0x87, - 0xfe, 0x13, 0x6a, 0xe6, 0x22, 0xcf, 0xc1, 0x8f, 0x4a, 0x15, 0xb6, 0xb1}; - uint8_t byteswillprops9[] = {0x42, 0x3c, 0x10, 0xfa, 0x5d, 0xce, 0x9a, 0x3e, 0xec, 0xb4, 0xff, 0x5f, 0xc4, 0xe5, - 0xcf, 0xf1, 0x7b, 0x95, 0x50, 0xd4, 0xe9, 0x9d, 0x23, 0x95, 0x75, 0x84, 0x9d, 0x6c}; - uint8_t byteswillprops10[] = {0x28, 0x94, 0xc8, 0x91, 0xad, 0xa6, 0x9d, 0xf3, 0x71}; - uint8_t byteswillprops11[] = {0xe, 0x49, 0x26, 0xa, 0x67, 0x8d, 0x25}; - uint8_t byteswillprops12[] = {0xc4, 0x23, 0x7, 0x7b, 0xea, 0x9d, 0x5, 0x6a, 0x61, 0xed, 0xe4, 0x64, - 0xea, 0x5e, 0x63, 0xc1, 0x5f, 0x7e, 0xb4, 0xaa, 0xd1, 0x91, 0x3c}; - uint8_t byteswillprops13[] = {0xea, 0x1d, 0x97, 0x4, 0x59, 0xde, 0x40, 0x6a, 0x80, 0xc3, 0x6, 0x4b, 0x3b, - 0x2a, 0xf0, 0xe7, 0xf5, 0xf8, 0x52, 0x82, 0x9f, 0x3c, 0x67, 0x70, 0x58, 0xdf}; - uint8_t byteswillprops14[] = {0xae, 0x57}; + uint8_t byteswillprops0[] = {0xf0, 0xa6, 0xf7, 0xdf, 0x7c, 0x23, 0xc1, 0xc1, 0xb2, + 0xc1, 0x61, 0x8a, 0xb7, 0xe4, 0x7c, 0xa2, 0x3d, 0x80}; + uint8_t byteswillprops1[] = {0xf4, 0xf2, 0x3e, 0x61, 0x12, 0x1f, 0xa, 0x83, 0x60, + 0xc4, 0xcb, 0x61, 0xd6, 0xa9, 0x12, 0xa4, 0x6b}; + uint8_t byteswillprops2[] = {0xf1, 0x3f, 0xae, 0x41, 0x94, 0xc2, 0xdc, 0xcf, 0x8, 0xe8, + 0x6f, 0x27, 0xbf, 0x66, 0xc4, 0x67, 0xca, 0x26, 0xf1, 0xb5, + 0x5d, 0x0, 0x38, 0x8b, 0x58, 0xb4, 0xe5, 0xa7, 0x36, 0xd4}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25536}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {21, (char*)&byteswillprops4}, .v = {25, (char*)&byteswillprops5}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14073}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {25, (char*)&byteswillprops7}, .v = {6, (char*)&byteswillprops8}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23398}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4588}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1937}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16722}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops12}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&byteswillprops13}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&byteswillprops14}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13107}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12452}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30328}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21462}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, }; - lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xcd, 0xc1, 0x92, 0x43, 0xb0, 0x11, 0x7b, 0x54, 0xbd, 0x68, - 0x44, 0xad, 0xbc, 0x1, 0xc6, 0x68, 0xfc, 0x3c, 0x52}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xee, 0xb5, 0x1b, 0x5, 0x10, 0x9f, 0xba, 0xaa, - 0x73, 0x4, 0x6e, 0xf8, 0xa, 0x7b, 0xa5, 0x38}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {11, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x8d}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfb, 0x9a, 0xca, 0xfc, 0x35, 0x31, 0x69, 0x28, 0xe, 0x4b}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -8121,13 +8095,18 @@ TEST(Connect5QCTest, Encode13) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 26535; - uint8_t client_id_bytes[] = {0xbf, 0x7c, 0xc5, 0xab, 0x7a, 0xf0, 0x36, 0x61, 0x5c, 0x99, 0xde, 0xd8, 0x4c}; + opts.clean_session = true; + opts.keep_alive = 7077; + uint8_t client_id_bytes[] = {0xa6, 0x32, 0xb7, 0x52, 0xea, 0x19, 0x2a, 0xe3, 0x20, 0xa, 0x7a, 0x16, 0x5}; lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xfa, 0xc8, 0xa2, 0x86, 0x4f, 0x46, 0x1c, 0x18, 0x83, 0x3d, 0xf, 0x1b}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xeb, 0x77, 0x84, 0x6d, 0x5d, 0xf8, 0x24, 0x34, 0xe8, 0x30, 0xf9, 0x56, 0xd6, + 0x7f, 0xb6, 0xaa, 0x4, 0x10, 0x11, 0xd4, 0x58, 0x93, 0x2d, 0xcf, 0x30}; + lwmqtt_string_t username = {25, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x42, 0xf5, 0xec, 0x80, 0xc4, 0x22, 0xb, 0xa6, 0x5b, 0x18, 0xa0, + 0x75, 0x92, 0x26, 0x5, 0x2a, 0x11, 0x74, 0x4e, 0x3f, 0x68}; + lwmqtt_string_t password = {21, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8137,78 +8116,92 @@ TEST(Connect5QCTest, Encode13) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\166\249\a\219\249u\EOTu\143\251", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "\NAK\217-e}|k\a\212M<2\SOH\135", _willMsg = -// "\234\243\SI\181\224\fx\DC2j?\196[\150@\140:\DEL#\USkOE", _willProps = [PropMaximumPacketSize -// 22163,PropCorrelationData "\STXC\SUB3\RSl\231\n",PropWillDelayInterval 2212,PropTopicAlias -// 3721,PropSessionExpiryInterval 22751,PropAuthenticationMethod -// "=\n\235\129|\201\151\232\191\147\DC3\222\129z\199l\SO\147\175\232r\217\171"]}), _cleanSession = True, _keepAlive = -// 25650, _connID = "\US\179p\223Y8\251\250}|\146\DC10", _properties = [PropSubscriptionIdentifier -// 26,PropRequestResponseInformation 101,PropMaximumPacketSize 26563,PropContentType -// "\ACK\RS2`\130\&4\148G\222\158-K\ESC\213\DC2\130\129I$\SOH\210",PropUserProperty "5\222\192h" -// "\130\225tF\192\211\182\GS"]} +// ConnectRequest {_username = Just " \173\&3f\DC4", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS1, _willTopic = "\SUB\224\241\aY%\155\222\143G\155T\163lx\218+", _willMsg = +// "m\130Tq\186R\196\157\v\245\FS\140\202\ETB\143\v\188\159\199\242\237\249A\DEL", _willProps = [PropTopicAlias +// 12587,PropTopicAlias 20812,PropRequestProblemInformation 63,PropServerKeepAlive 6655,PropTopicAliasMaximum +// 24552,PropContentType "\229\251\&4R\180\208\DC4/\147\141\196\EOT\211\149",PropMaximumQoS 199,PropCorrelationData +// "\252\240\SYN\147\221\204V\169\&2j\SOY\156\EOT\140\248\211|u\b\ACK\231\&6\223a\227"]}), _cleanSession = True, +// _keepAlive = 16885, _connID = "", _properties = [PropServerReference "\SOHRM\GS\154",PropResponseTopic +// ":g6\165\129\139|h\f2\210}\n2*M\186\142\149\157\129e\161\164M\157\199j:",PropPayloadFormatIndicator +// 74,PropMessageExpiryInterval 7166,PropSharedSubscriptionAvailable 99,PropReasonString +// "Fw3ry\206`s\DC4%I\ETB\226W\137\176\217k\130-\237\"*D\134\232\207\176W",PropServerKeepAlive 31247,PropUserProperty +// "\199P\237\222`\FS\153\STX\213m\217\254\156\218\ESC\ENQ0" "\173i\138\vj\231\246\199`"]} TEST(Connect5QCTest, Encode14) { uint8_t pkt[] = { - 0x10, 0xb8, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6e, 0x64, 0x32, 0x32, 0xb, 0x1a, 0x19, 0x65, 0x27, - 0x0, 0x0, 0x67, 0xc3, 0x3, 0x0, 0x15, 0x6, 0x1e, 0x32, 0x60, 0x82, 0x34, 0x94, 0x47, 0xde, 0x9e, 0x2d, 0x4b, - 0x1b, 0xd5, 0x12, 0x82, 0x81, 0x49, 0x24, 0x1, 0xd2, 0x26, 0x0, 0x4, 0x35, 0xde, 0xc0, 0x68, 0x0, 0x8, 0x82, - 0xe1, 0x74, 0x46, 0xc0, 0xd3, 0xb6, 0x1d, 0x0, 0xd, 0x1f, 0xb3, 0x70, 0xdf, 0x59, 0x38, 0xfb, 0xfa, 0x7d, 0x7c, - 0x92, 0x11, 0x30, 0x37, 0x27, 0x0, 0x0, 0x56, 0x93, 0x9, 0x0, 0x8, 0x2, 0x43, 0x1a, 0x33, 0x1e, 0x6c, 0xe7, - 0xa, 0x18, 0x0, 0x0, 0x8, 0xa4, 0x23, 0xe, 0x89, 0x11, 0x0, 0x0, 0x58, 0xdf, 0x15, 0x0, 0x17, 0x3d, 0xa, - 0xeb, 0x81, 0x7c, 0xc9, 0x97, 0xe8, 0xbf, 0x93, 0x13, 0xde, 0x81, 0x7a, 0xc7, 0x6c, 0xe, 0x93, 0xaf, 0xe8, 0x72, - 0xd9, 0xab, 0x0, 0xe, 0x15, 0xd9, 0x2d, 0x65, 0x7d, 0x7c, 0x6b, 0x7, 0xd4, 0x4d, 0x3c, 0x32, 0x1, 0x87, 0x0, - 0x16, 0xea, 0xf3, 0xf, 0xb5, 0xe0, 0xc, 0x78, 0x12, 0x6a, 0x3f, 0xc4, 0x5b, 0x96, 0x40, 0x8c, 0x3a, 0x7f, 0x23, - 0x1f, 0x6b, 0x4f, 0x45, 0x0, 0xa, 0xa6, 0xf9, 0x7, 0xdb, 0xf9, 0x75, 0x4, 0x75, 0x8f, 0xfb}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x6, 0x1e, 0x32, 0x60, 0x82, 0x34, 0x94, 0x47, 0xde, 0x9e, 0x2d, - 0x4b, 0x1b, 0xd5, 0x12, 0x82, 0x81, 0x49, 0x24, 0x1, 0xd2}; - uint8_t bytesprops2[] = {0x82, 0xe1, 0x74, 0x46, 0xc0, 0xd3, 0xb6, 0x1d}; - uint8_t bytesprops1[] = {0x35, 0xde, 0xc0, 0x68}; + 0x10, 0xf3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0x41, 0xf5, 0x73, 0x1c, 0x0, 0x5, 0x1, 0x52, + 0x4d, 0x1d, 0x9a, 0x8, 0x0, 0x1d, 0x3a, 0x67, 0x36, 0xa5, 0x81, 0x8b, 0x7c, 0x68, 0xc, 0x32, 0xd2, 0x7d, 0xa, + 0x32, 0x2a, 0x4d, 0xba, 0x8e, 0x95, 0x9d, 0x81, 0x65, 0xa1, 0xa4, 0x4d, 0x9d, 0xc7, 0x6a, 0x3a, 0x1, 0x4a, 0x2, + 0x0, 0x0, 0x1b, 0xfe, 0x2a, 0x63, 0x1f, 0x0, 0x1d, 0x46, 0x77, 0x33, 0x72, 0x79, 0xce, 0x60, 0x73, 0x14, 0x25, + 0x49, 0x17, 0xe2, 0x57, 0x89, 0xb0, 0xd9, 0x6b, 0x82, 0x2d, 0xed, 0x22, 0x2a, 0x44, 0x86, 0xe8, 0xcf, 0xb0, 0x57, + 0x13, 0x7a, 0xf, 0x26, 0x0, 0x11, 0xc7, 0x50, 0xed, 0xde, 0x60, 0x1c, 0x99, 0x2, 0xd5, 0x6d, 0xd9, 0xfe, 0x9c, + 0xda, 0x1b, 0x5, 0x30, 0x0, 0x9, 0xad, 0x69, 0x8a, 0xb, 0x6a, 0xe7, 0xf6, 0xc7, 0x60, 0x0, 0x0, 0x3e, 0x23, + 0x31, 0x2b, 0x23, 0x51, 0x4c, 0x17, 0x3f, 0x13, 0x19, 0xff, 0x22, 0x5f, 0xe8, 0x3, 0x0, 0xe, 0xe5, 0xfb, 0x34, + 0x52, 0xb4, 0xd0, 0x14, 0x2f, 0x93, 0x8d, 0xc4, 0x4, 0xd3, 0x95, 0x24, 0xc7, 0x9, 0x0, 0x1a, 0xfc, 0xf0, 0x16, + 0x93, 0xdd, 0xcc, 0x56, 0xa9, 0x32, 0x6a, 0xe, 0x59, 0x9c, 0x4, 0x8c, 0xf8, 0xd3, 0x7c, 0x75, 0x8, 0x6, 0xe7, + 0x36, 0xdf, 0x61, 0xe3, 0x0, 0x11, 0x1a, 0xe0, 0xf1, 0x7, 0x59, 0x25, 0x9b, 0xde, 0x8f, 0x47, 0x9b, 0x54, 0xa3, + 0x6c, 0x78, 0xda, 0x2b, 0x0, 0x18, 0x6d, 0x82, 0x54, 0x71, 0xba, 0x52, 0xc4, 0x9d, 0xb, 0xf5, 0x1c, 0x8c, 0xca, + 0x17, 0x8f, 0xb, 0xbc, 0x9f, 0xc7, 0xf2, 0xed, 0xf9, 0x41, 0x7f, 0x0, 0x5, 0x20, 0xad, 0x33, 0x66, 0x14}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1, 0x52, 0x4d, 0x1d, 0x9a}; + uint8_t bytesprops1[] = {0x3a, 0x67, 0x36, 0xa5, 0x81, 0x8b, 0x7c, 0x68, 0xc, 0x32, 0xd2, 0x7d, 0xa, 0x32, 0x2a, + 0x4d, 0xba, 0x8e, 0x95, 0x9d, 0x81, 0x65, 0xa1, 0xa4, 0x4d, 0x9d, 0xc7, 0x6a, 0x3a}; + uint8_t bytesprops2[] = {0x46, 0x77, 0x33, 0x72, 0x79, 0xce, 0x60, 0x73, 0x14, 0x25, 0x49, 0x17, 0xe2, 0x57, 0x89, + 0xb0, 0xd9, 0x6b, 0x82, 0x2d, 0xed, 0x22, 0x2a, 0x44, 0x86, 0xe8, 0xcf, 0xb0, 0x57}; + uint8_t bytesprops4[] = {0xad, 0x69, 0x8a, 0xb, 0x6a, 0xe7, 0xf6, 0xc7, 0x60}; + uint8_t bytesprops3[] = {0xc7, 0x50, 0xed, 0xde, 0x60, 0x1c, 0x99, 0x2, 0xd5, + 0x6d, 0xd9, 0xfe, 0x9c, 0xda, 0x1b, 0x5, 0x30}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26563}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7166}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31247}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops3}, .v = {9, (char*)&bytesprops4}}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x2, 0x43, 0x1a, 0x33, 0x1e, 0x6c, 0xe7, 0xa}; - uint8_t byteswillprops1[] = {0x3d, 0xa, 0xeb, 0x81, 0x7c, 0xc9, 0x97, 0xe8, 0xbf, 0x93, 0x13, 0xde, - 0x81, 0x7a, 0xc7, 0x6c, 0xe, 0x93, 0xaf, 0xe8, 0x72, 0xd9, 0xab}; + uint8_t byteswillprops0[] = {0xe5, 0xfb, 0x34, 0x52, 0xb4, 0xd0, 0x14, 0x2f, 0x93, 0x8d, 0xc4, 0x4, 0xd3, 0x95}; + uint8_t byteswillprops1[] = {0xfc, 0xf0, 0x16, 0x93, 0xdd, 0xcc, 0x56, 0xa9, 0x32, 0x6a, 0xe, 0x59, 0x9c, + 0x4, 0x8c, 0xf8, 0xd3, 0x7c, 0x75, 0x8, 0x6, 0xe7, 0x36, 0xdf, 0x61, 0xe3}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22163}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2212}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3721}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22751}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12587}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20812}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6655}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24552}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&byteswillprops1}}}, }; - lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x15, 0xd9, 0x2d, 0x65, 0x7d, 0x7c, 0x6b, 0x7, 0xd4, 0x4d, 0x3c, 0x32, 0x1, 0x87}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xea, 0xf3, 0xf, 0xb5, 0xe0, 0xc, 0x78, 0x12, 0x6a, 0x3f, 0xc4, - 0x5b, 0x96, 0x40, 0x8c, 0x3a, 0x7f, 0x23, 0x1f, 0x6b, 0x4f, 0x45}; - lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1a, 0xe0, 0xf1, 0x7, 0x59, 0x25, 0x9b, 0xde, 0x8f, + 0x47, 0x9b, 0x54, 0xa3, 0x6c, 0x78, 0xda, 0x2b}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6d, 0x82, 0x54, 0x71, 0xba, 0x52, 0xc4, 0x9d, 0xb, 0xf5, 0x1c, 0x8c, + 0xca, 0x17, 0x8f, 0xb, 0xbc, 0x9f, 0xc7, 0xf2, 0xed, 0xf9, 0x41, 0x7f}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 25650; - uint8_t client_id_bytes[] = {0x1f, 0xb3, 0x70, 0xdf, 0x59, 0x38, 0xfb, 0xfa, 0x7d, 0x7c, 0x92, 0x11, 0x30}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.keep_alive = 16885; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xa6, 0xf9, 0x7, 0xdb, 0xf9, 0x75, 0x4, 0x75, 0x8f, 0xfb}; - lwmqtt_string_t password = {10, (char*)&password_bytes}; - opts.password = password; + uint8_t username_bytes[] = {0x20, 0xad, 0x33, 0x66, 0x14}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; + opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8217,126 +8210,177 @@ TEST(Connect5QCTest, Encode14) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "\194\DC3\201\173i\234P)\159\241N\208l\133G", _willMsg = "\208\250\192\160", _willProps = -// [PropAuthenticationData "h\161K\EMw\NAK\r\DC4\188\158Z\ACK6", _properties = [PropSubscriptionIdentifier -// 30,PropAuthenticationMethod -// "}\188E\134\175\141h\217\DC40_Y[\NUL\212]\NUL\203\198\213}\DC2S\SO\214\&8\v\218",PropWillDelayInterval -// 13946,PropPayloadFormatIndicator 67,PropRequestProblemInformation 96,PropContentType -// "/\253C.d,,zl\167G\b",PropServerReference "{'sWS?'\201\183\220\EOT\STX",PropCorrelationData "\167\140Z\160,S\DC1\137 -// /\192\199\236V\220\150\156\219\193'\207\DLE\221\EM#",PropMaximumPacketSize 7792,PropSubscriptionIdentifierAvailable -// 74,PropUserProperty "@\134Y\217(\218hi\152\CAN\216\172\181" "*-\207cGd@?\232 -// \158\202Y\158\ACK\202$\249\139\129~[",PropAuthenticationMethod -// "\178(v\221\243R\r\246\195\226\ETX\EM\247\252\206\162\180F{\138"]} +// ConnectRequest {_username = Just "\162\146\138\141K)\DEL\142\&8zW\163\DC2M#\138\ENQ\NUL\134\235\203", _password = +// Just "\133\n\206/_y\134\132\146/\225s 4O\210\144\130\GS\148b", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS1, _willTopic = "\251\220\159\161T\129^\175\210\212\RS0Yh\NAK\141{5\207lv\193\253\209", _willMsg = +// "\202{q\255\165\RS", _willProps = [PropReasonString "\168\154\234\&83o\192\NAK\202",PropRequestProblemInformation +// 231,PropRetainAvailable 97,PropUserProperty "q\142\NUL,\255\238\211\245\224\DC4\DC2\235\RS\145" +// ">\US\141r\136\162\CAN\254\209\139\160\178\162n\220RI",PropContentType "\142\247DZ^\180e]\n",PropContentType +// "5(NH>\143x",PropTopicAlias 27268,PropReasonString +// "'\227w\244\183\240\230\146+\SI\186C_C\172y$",PropRequestProblemInformation 87,PropWillDelayInterval +// 31902,PropRequestResponseInformation 176,PropMessageExpiryInterval 30405,PropUserProperty +// "\SI\204Vp}Z\199]\ETX\160\179u\247~y\194" "6bN\162\245\&3%\158\243\214\vo\239\151",PropCorrelationData +// "\204\&9\DC2\US\170=\209"]}), +// _cleanSession = False, _keepAlive = 28167, _connID = +// "v\243\203T}\236\142\226\SI\204\157\191\223\138y\DC4\252\163\134", _properties = [PropResponseTopic +// "/3\SOHI\158%/\137v\174\&1\233Qf\168Mm*\189~\ETX\150\232A\244\129",PropSubscriptionIdentifier 24,PropServerReference +// ".-8Qz\239le",PropTopicAliasMaximum 3736,PropWillDelayInterval 24917,PropMessageExpiryInterval +// 20599,PropAuthenticationMethod "\144b\171\CAN\130\235R\162",PropMaximumQoS 223,PropWillDelayInterval +// 24968,PropCorrelationData "\199\GS\128N\212\&6}U\131(\200",PropResponseInformation +// "\192\231e\176Q5P\183\175>\183I\NAK`\253\235\132\168\148\238\ESCy2\SI\140\241\161\EOT",PropResponseTopic +// "\159\238F\145\170>\183_\142\t\184\&4OB\185\190:\175\f\175'\RS\"/\158\155}==\191",PropContentType +// "\243\234(\159\206\202\222\143#\192\ACKj\217\b\t\175`\"\139\r8\198b\SUBZ`\172/\GS2",PropResponseTopic +// "O\250w\212w+\ENQ\NUL\194'\148\177\136",PropSubscriptionIdentifierAvailable 242,PropRequestProblemInformation +// 255,PropWildcardSubscriptionAvailable 72,PropTopicAlias 11275]} TEST(Connect5QCTest, Encode15) { uint8_t pkt[] = { - 0x10, 0x98, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x14, 0x2, 0xe1, 0xaa, 0x1, 0xb, 0x1e, 0x15, 0x0, - 0x1c, 0x7d, 0xbc, 0x45, 0x86, 0xaf, 0x8d, 0x68, 0xd9, 0x14, 0x30, 0x5f, 0x59, 0x5b, 0x0, 0xd4, 0x5d, 0x0, 0xcb, - 0xc6, 0xd5, 0x7d, 0x12, 0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kt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7d, 0xbc, 0x45, 0x86, 0xaf, 0x8d, 0x68, 0xd9, 0x14, 0x30, 0x5f, 0x59, 0x5b, 0x0, - 0xd4, 0x5d, 0x0, 0xcb, 0xc6, 0xd5, 0x7d, 0x12, 0x53, 0xe, 0xd6, 0x38, 0xb, 0xda}; - uint8_t bytesprops1[] = {0x2f, 0xfd, 0x43, 0x2e, 0x64, 0x2c, 0x2c, 0x7a, 0x6c, 0xa7, 0x47, 0x8}; - uint8_t bytesprops2[] = {0x7b, 0x27, 0x73, 0x57, 0x53, 0x3f, 0x27, 0xc9, 0xb7, 0xdc, 0x4, 0x2}; - uint8_t bytesprops3[] = {0xa7, 0x8c, 0x5a, 0xa0, 0x2c, 0x53, 0x11, 0x89, 0x20, 0x2f, 0xc0, 0xc7, 0xec, - 0x56, 0xdc, 0x96, 0x9c, 0xdb, 0xc1, 0x27, 0xcf, 0x10, 0xdd, 0x19, 0x23}; - uint8_t bytesprops5[] = {0x2a, 0x2d, 0xcf, 0x63, 0x47, 0x64, 0x40, 0x3f, 0xe8, 0x20, 0x9e, - 0xca, 0x59, 0x9e, 0x6, 0xca, 0x24, 0xf9, 0x8b, 0x81, 0x7e, 0x5b}; - uint8_t bytesprops4[] = {0x40, 0x86, 0x59, 0xd9, 0x28, 0xda, 0x68, 0x69, 0x98, 0x18, 0xd8, 0xac, 0xb5}; - uint8_t bytesprops6[] = {0xb2, 0x28, 0x76, 0xdd, 0xf3, 0x52, 0xd, 0xf6, 0xc3, 0xe2, - 0x3, 0x19, 0xf7, 0xfc, 0xce, 0xa2, 0xb4, 0x46, 0x7b, 0x8a}; + 0x10, 0xbf, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x6e, 0x7, 0xd1, 0x1, 0x8, 0x0, 0x1a, 0x2f, + 0x33, 0x1, 0x49, 0x9e, 0x25, 0x2f, 0x89, 0x76, 0xae, 0x31, 0xe9, 0x51, 0x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x7c, 0x5a, 0xa4, 0x27, 0x0, 0x0, 0xd, 0xb, 0x2, 0x0, 0x0, 0x72, 0xc9, 0xb, + 0x1b, 0x2, 0x0, 0x0, 0x2, 0xbb, 0x2a, 0x26, 0x21, 0x43, 0x15, 0x26, 0x0, 0xd, 0xed, 0xef, 0x91, 0x5c, 0xfa, + 0x6b, 0xd9, 0x3c, 0x6, 0xcf, 0xba, 0x61, 0x78, 0x0, 0xd, 0xa1, 0xb5, 0x46, 0x38, 0x44, 0x25, 0xa7, 0x54, 0x2d, + 0x2e, 0x72, 0x96, 0xba, 0x2a, 0x19, 0x23, 0x4a, 0x8b, 0x15, 0x0, 0x1e, 0xbb, 0x7d, 0xec, 0x26, 0xb0, 0x34, 0x58, + 0x2e, 0x16, 0xda, 0x17, 0x21, 0x9a, 0xee, 0xe3, 0xd8, 0x85, 0xb8, 0xc, 0xa4, 0x1, 0xeb, 0x5, 0x98, 0x5, 0xa0, + 0xb9, 0xb5, 0x3e, 0xd1, 0x0, 0x18, 0xfb, 0xdc, 0x9f, 0xa1, 0x54, 0x81, 0x5e, 0xaf, 0xd2, 0xd4, 0x1e, 0x30, 0x59, + 0x68, 0x15, 0x8d, 0x7b, 0x35, 0xcf, 0x6c, 0x76, 0xc1, 0xfd, 0xd1, 0x0, 0x6, 0xca, 0x7b, 0x71, 0xff, 0xa5, 0x1e, + 0x0, 0x15, 0xa2, 0x92, 0x8a, 0x8d, 0x4b, 0x29, 0x7f, 0x8e, 0x38, 0x7a, 0x57, 0xa3, 0x12, 0x4d, 0x23, 0x8a, 0x5, + 0x0, 0x86, 0xeb, 0xcb, 0x0, 0x15, 0x85, 0xa, 0xce, 0x2f, 0x5f, 0x79, 0x86, 0x84, 0x92, 0x2f, 0xe1, 0x73, 0x20, + 0x34, 0x4f, 0xd2, 0x90, 0x82, 0x1d, 0x94, 0x62}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x2f, 0x33, 0x1, 0x49, 0x9e, 0x25, 0x2f, 0x89, 0x76, 0xae, 0x31, 0xe9, 0x51, + 0x66, 0xa8, 0x4d, 0x6d, 0x2a, 0xbd, 0x7e, 0x3, 0x96, 0xe8, 0x41, 0xf4, 0x81}; + uint8_t bytesprops1[] = {0x2e, 0x2d, 0x38, 0x51, 0x7a, 0xef, 0x6c, 0x65}; + uint8_t bytesprops2[] = {0x90, 0x62, 0xab, 0x18, 0x82, 0xeb, 0x52, 0xa2}; + uint8_t bytesprops3[] = {0xc7, 0x1d, 0x80, 0x4e, 0xd4, 0x36, 0x7d, 0x55, 0x83, 0x28, 0xc8}; + uint8_t bytesprops4[] = {0xc0, 0xe7, 0x65, 0xb0, 0x51, 0x35, 0x50, 0xb7, 0xaf, 0x3e, 0xb7, 0x49, 0x15, 0x60, + 0xfd, 0xeb, 0x84, 0xa8, 0x94, 0xee, 0x1b, 0x79, 0x32, 0xf, 0x8c, 0xf1, 0xa1, 0x4}; + uint8_t bytesprops5[] = {0x9f, 0xee, 0x46, 0x91, 0xaa, 0x3e, 0xb7, 0x5f, 0x8e, 0x9, 0xb8, 0x34, 0x4f, 0x42, 0xb9, + 0xbe, 0x3a, 0xaf, 0xc, 0xaf, 0x27, 0x1e, 0x22, 0x2f, 0x9e, 0x9b, 0x7d, 0x3d, 0x3d, 0xbf}; + uint8_t bytesprops6[] = {0xf3, 0xea, 0x28, 0x9f, 0xce, 0xca, 0xde, 0x8f, 0x23, 0xc0, 0x6, 0x6a, 0xd9, 0x8, 0x9, + 0xaf, 0x60, 0x22, 0x8b, 0xd, 0x38, 0xc6, 0x62, 0x1a, 0x5a, 0x60, 0xac, 0x2f, 0x1d, 0x32}; + uint8_t bytesprops7[] = {0x4f, 0xfa, 0x77, 0xd4, 0x77, 0x2b, 0x5, 0x0, 0xc2, 0x27, 0x94, 0xb1, 0x88}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13946}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7792}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops4}, .v = {22, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3736}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24917}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20599}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24968}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11275}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x68, 0x3c, 0x79, 0x21, 0x3, 0x6a, 0x2e, 0x6b, 0x70, 0x1b, 0xe4, 0x99, 0x38, 0xa, 0x8c}; - uint8_t byteswillprops1[] = {0xb1, 0xd7, 0xfe, 0x1f, 0xaa, 0x9c, 0xff, 0xa1, 0xe6, 0xae, - 0x49, 0x2e, 0x89, 0x70, 0x56, 0x20, 0x5d, 0xa0, 0x4b, 0x21, - 0xb3, 0xa2, 0xb8, 0xe2, 0x88, 0x5f, 0x7a, 0x2b, 0x9a, 0xc9}; - uint8_t byteswillprops2[] = {0x57, 0xec, 0x4f, 0x5b, 0x6b, 0xdb, 0x9d, 0xb5, 0x0, - 0x3b, 0xde, 0x70, 0x89, 0xce, 0x80, 0x91, 0xfe}; - uint8_t byteswillprops3[] = {0x71, 0x8a, 0xd0, 0x99, 0x78, 0xd9, 0x58, 0x12, 0xd2, 0x9d, - 0xbb, 0xed, 0xc5, 0xb, 0x75, 0xb4, 0x47, 0x47, 0x3b, 0x58, - 0x74, 0x61, 0xb7, 0x0, 0xce, 0xd8, 0x57, 0x5a, 0x71, 0x47}; - uint8_t byteswillprops5[] = {0xc1, 0xb6, 0xf3, 0x19, 0xb5, 0x11, 0xe7, 0x3d, 0x52, 0xa3, 0xc1, - 0xc7, 0x37, 0xd9, 0x70, 0xf0, 0x4e, 0x6c, 0x7f, 0x5b, 0x43}; - uint8_t byteswillprops4[] = {0xaf, 0x28, 0x9f, 0x8d, 0x31, 0xb6, 0x35, 0x79, 0xed, 0x4b, - 0x61, 0x55, 0x68, 0xbb, 0xe2, 0x6b, 0x66, 0x4b, 0x34, 0x11, - 0xc1, 0x49, 0x25, 0x23, 0x6c, 0xb3, 0x1f, 0xc7, 0x36, 0x29}; - uint8_t byteswillprops6[] = {0xfc, 0x90, 0x96, 0x9a, 0x3, 0xdd, 0xb8, 0xb4, 0x1e, 0xc3, 0xdc, 0x8, 0xd0}; + uint8_t byteswillprops0[] = {0xa8, 0x9a, 0xea, 0x38, 0x33, 0x6f, 0xc0, 0x15, 0xca}; + uint8_t byteswillprops2[] = {0x3e, 0x1f, 0x8d, 0x72, 0x88, 0xa2, 0x18, 0xfe, 0xd1, + 0x8b, 0xa0, 0xb2, 0xa2, 0x6e, 0xdc, 0x52, 0x49}; + uint8_t byteswillprops1[] = {0x71, 0x8e, 0x0, 0x2c, 0xff, 0xee, 0xd3, 0xf5, 0xe0, 0x14, 0x12, 0xeb, 0x1e, 0x91}; + uint8_t byteswillprops3[] = {0x8e, 0xf7, 0x44, 0x5a, 0x5e, 0xb4, 0x65, 0x5d, 0xa}; + uint8_t byteswillprops4[] = {0x35, 0x28, 0x4e, 0x48, 0x3e, 0x8f, 0x78}; + uint8_t byteswillprops5[] = {0x27, 0xe3, 0x77, 0xf4, 0xb7, 0xf0, 0xe6, 0x92, 0x2b, + 0xf, 0xba, 0x43, 0x5f, 0x43, 0xac, 0x79, 0x24}; + uint8_t byteswillprops7[] = {0x36, 0x62, 0x4e, 0xa2, 0xf5, 0x33, 0x25, 0x9e, 0xf3, 0xd6, 0xb, 0x6f, 0xef, 0x97}; + uint8_t byteswillprops6[] = {0xf, 0xcc, 0x56, 0x70, 0x7d, 0x5a, 0xc7, 0x5d, + 0x3, 0xa0, 0xb3, 0x75, 0xf7, 0x7e, 0x79, 0xc2}; + uint8_t byteswillprops8[] = {0xcc, 0x39, 0x12, 0x1f, 0xaa, 0x3d, 0x3c, 0x58, 0x7c, 0x5a, 0xa4}; + uint8_t byteswillprops10[] = {0xa1, 0xb5, 0x46, 0x38, 0x44, 0x25, 0xa7, 0x54, 0x2d, 0x2e, 0x72, 0x96, 0xba}; + uint8_t byteswillprops9[] = {0xed, 0xef, 0x91, 0x5c, 0xfa, 0x6b, 0xd9, 0x3c, 0x6, 0xcf, 0xba, 0x61, 0x78}; + uint8_t byteswillprops11[] = {0xbb, 0x7d, 0xec, 0x26, 0xb0, 0x34, 0x58, 0x2e, 0x16, 0xda, + 0x17, 0x21, 0x9a, 0xee, 0xe3, 0xd8, 0x85, 0xb8, 0xc, 0xa4, + 0x1, 0xeb, 0x5, 0x98, 0x5, 0xa0, 0xb9, 0xb5, 0x3e, 0xd1}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21832}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {14, (char*)&byteswillprops1}, .v = {17, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27268}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31902}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30405}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {16, (char*)&byteswillprops6}, .v = {14, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3339}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29385}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 699}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17173}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {30, (char*)&byteswillprops4}, .v = {21, (char*)&byteswillprops5}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&byteswillprops6}}}, + .value = {.pair = {.k = {13, (char*)&byteswillprops9}, .v = {13, (char*)&byteswillprops10}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19083}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops11}}}, }; - lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc2, 0x13, 0xc9, 0xad, 0x69, 0xea, 0x50, 0x29, - 0x9f, 0xf1, 0x4e, 0xd0, 0x6c, 0x85, 0x47}; - lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd0, 0xfa, 0xc0, 0xa0}; - lwmqtt_string_t will_payload = {4, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xfb, 0xdc, 0x9f, 0xa1, 0x54, 0x81, 0x5e, 0xaf, 0xd2, 0xd4, 0x1e, 0x30, + 0x59, 0x68, 0x15, 0x8d, 0x7b, 0x35, 0xcf, 0x6c, 0x76, 0xc1, 0xfd, 0xd1}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xca, 0x7b, 0x71, 0xff, 0xa5, 0x1e}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS1; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 737; - uint8_t client_id_bytes[] = {0xcc, 0x72, 0x8a, 0xd2, 0x99, 0x3e, 0xa1, 0x4b, 0x19, - 0x77, 0x15, 0xd, 0x14, 0xbc, 0x9e, 0x5a, 0x6, 0x36}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.keep_alive = 28167; + uint8_t client_id_bytes[] = {0x76, 0xf3, 0xcb, 0x54, 0x7d, 0xec, 0x8e, 0xe2, 0xf, 0xcc, + 0x9d, 0xbf, 0xdf, 0x8a, 0x79, 0x14, 0xfc, 0xa3, 0x86}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t username_bytes[] = {0xa2, 0x92, 0x8a, 0x8d, 0x4b, 0x29, 0x7f, 0x8e, 0x38, 0x7a, 0x57, + 0xa3, 0x12, 0x4d, 0x23, 0x8a, 0x5, 0x0, 0x86, 0xeb, 0xcb}; + lwmqtt_string_t username = {21, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x85, 0xa, 0xce, 0x2f, 0x5f, 0x79, 0x86, 0x84, 0x92, 0x2f, 0xe1, + 0x73, 0x20, 0x34, 0x4f, 0xd2, 0x90, 0x82, 0x1d, 0x94, 0x62}; + lwmqtt_string_t password = {21, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8345,165 +8389,131 @@ TEST(Connect5QCTest, Encode15) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "=\244\ESCz\EM\205Q\216 \211\&62\EM\238\244\239O D\136", _password = Just -// "\CANj\v\180\161\237\198h\184_NXO\223\DC1p$\175\183/*\178\186v2Z\USe\145", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = ":\229v?G\137\&4\DC4\206\151\169\DC2\SO\230\143RYg\149\228Q\SYN\220\176\201\157",PropTopicAliasMaximum -// 25134,PropSessionExpiryInterval 21348,PropSubscriptionIdentifierAvailable 19,PropPayloadFormatIndicator -// 250,PropMaximumPacketSize 28204,PropRetainAvailable 37,PropAssignedClientIdentifier -// "p\134\DC3\185\192\140\178&{1P\188\198",PropMessageExpiryInterval 15366,PropMaximumPacketSize -// 7017,PropWillDelayInterval 7756,PropRetainAvailable 121,PropSharedSubscriptionAvailable 51,PropUserProperty -// "\203\191\129(l\243[\173\210{=\185$\146\180\163\206\161\221\142\174\227\196\EM\237\214?y\156g" -// "\194S\132\191\191o\210\&5Sv\138\191M",PropWildcardSubscriptionAvailable 4,PropWillDelayInterval -// 9468,PropCorrelationData "\253\158\148A\245lZ\254\133\GS$\219H\181\226\208\238\EM",PropWildcardSubscriptionAvailable -// 142,PropServerKeepAlive 7563,PropAuthenticationMethod "3K\145\\",PropAssignedClientIdentifier -// "\167\169\248\n\239\183\251~+Z\186\158\232\ESCF\227,$",PropMaximumQoS 231,PropMessageExpiryInterval -// 2465,PropPayloadFormatIndicator 252,PropResponseTopic -// "\159\205I\251\142\aMs\191\136\ETX\STX\237\CANS9!U\GS\208\ENQrMR\CAN\bzD"]}), _cleanSession = True, _keepAlive = -// 13449, _connID = "\160\224\209~y/wD\182\&6\143\210\244\&6D\190", _properties = [PropAssignedClientIdentifier -// "R\RSI\189\206\210v",PropReasonString "\144\t\"\DEL\176\150\214\245_\203\190\176",PropAuthenticationData -// "\202\&4\n\171\157*\ETX\212{^\186\215x\EOT\229C\157\&2m_}:",PropReasonString -// "\203\&3W\227\217n\231q\a~\204\195M\237k\160.\248\SOH\207\171c\234\217Ad\241_f\203",PropCorrelationData -// "\ESC\216-\244\173\222\165\187\&8m\a~g*I\159\DC1z\141Gg\203w",PropAssignedClientIdentifier -// "",PropRequestResponseInformation 124,PropWildcardSubscriptionAvailable 213,PropReasonString -// "\165\240\217",PropResponseInformation "\155\NUL\246\217Nw\v!\215\ETX\159\163w\DLE\196",PropMessageExpiryInterval -// 26429,PropWildcardSubscriptionAvailable 28,PropServerReference -// "\165\185\&5\239k\DC1\198\213\164",PropRequestProblemInformation 160]} +// ConnectRequest {_username = Just "Ub", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS +// = QoS2, _willTopic = "\EM\162\218\226Q\179}\211\ETB\242\188\157(\150\&7-", _willMsg = "\146#K\CAN-7w\161\228\157", +// _willProps = [PropContentType "'\193\181\DC3zy\170p\GS\r\191\129\&7\"\141\162\128-\249i\138 +// KIN\222\198J",PropWildcardSubscriptionAvailable 118,PropMaximumQoS 163,PropTopicAlias 27085,PropMessageExpiryInterval +// 28560,PropTopicAliasMaximum 5360,PropSubscriptionIdentifierAvailable 70,PropTopicAlias 7674,PropServerKeepAlive +// 24177,PropMessageExpiryInterval 7765,PropWillDelayInterval 31134,PropServerKeepAlive 25331,PropServerKeepAlive +// 13361]}), _cleanSession = False, _keepAlive = 618, _connID = "\193\150\ENQ", _properties = [PropContentType +// "\RS\163\209\\Kg\ESC\139%\192",PropContentType "\172_\167\130\t\159\152\a",PropMessageExpiryInterval +// 29459,PropPayloadFormatIndicator 84,PropTopicAlias 10884,PropServerReference +// "\245{\232\189\&0PI\DC3\160\254\NUL\235*\230\157\182x\146",PropReasonString +// "&b\EOTAb\217\ax\bD\vz\222\234x\196\212\&5fEI\thW\241",PropTopicAliasMaximum 6153,PropResponseTopic +// "e-l.d\\d\184\ETB\ENQ\197\179\143\245\186\EMD!",PropServerKeepAlive 25494,PropMaximumPacketSize +// 12721,PropReceiveMaximum 3532,PropSubscriptionIdentifier 23,PropAssignedClientIdentifier +// "#\237\144\214\228NA\185p\166\DC3E\ETB",PropWillDelayInterval 19226,PropTopicAliasMaximum 16287,PropWillDelayInterval +// 26966,PropReceiveMaximum 22426,PropRetainAvailable 175,PropPayloadFormatIndicator 116,PropSubscriptionIdentifier +// 4,PropCorrelationData "i\252\ETX\226",PropSubscriptionIdentifierAvailable 152,PropSubscriptionIdentifierAvailable +// 66,PropMessageExpiryInterval 8075,PropContentType +// "\SYN\250\NAK\GS\154N\EMC3P\DC3\DC1d%\SO\177\140\239@\182\171\142\"\146\190ub\SO\DC2\135",PropMessageExpiryInterval +// 29700]} TEST(Connect5QCTest, Encode16) { uint8_t pkt[] = { - 0x10, 0x89, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x34, 0x89, 0xa1, 0x1, 0x12, 0x0, 0x7, 0x52, - 0x1e, 0x49, 0xbd, 0xce, 0xd2, 0x76, 0x1f, 0x0, 0xc, 0x90, 0x9, 0x22, 0x7f, 0xb0, 0x96, 0xd6, 0xf5, 0x5f, 0xcb, - 0xbe, 0xb0, 0x16, 0x0, 0x16, 0xca, 0x34, 0xa, 0xab, 0x9d, 0x2a, 0x3, 0xd4, 0x7b, 0x5e, 0xba, 0xd7, 0x78, 0x4, - 0xe5, 0x43, 0x9d, 0x32, 0x6d, 0x5f, 0x7d, 0x3a, 0x1f, 0x0, 0x1e, 0xcb, 0x33, 0x57, 0xe3, 0xd9, 0x6e, 0xe7, 0x71, - 0x7, 0x7e, 0xcc, 0xc3, 0x4d, 0xed, 0x6b, 0xa0, 0x2e, 0xf8, 0x1, 0xcf, 0xab, 0x63, 0xea, 0xd9, 0x41, 0x64, 0xf1, - 0x5f, 0x66, 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xfb, 0xa7, 0x56, 0x0, 0x14, 0x3d, 0xf4, - 0x1b, 0x7a, 0x19, 0xcd, 0x51, 0xd8, 0x20, 0xd3, 0x36, 0x32, 0x19, 0xee, 0xf4, 0xef, 0x4f, 0x20, 0x44, 0x88, 0x0, - 0x1d, 0x18, 0x6a, 0xb, 0xb4, 0xa1, 0xed, 0xc6, 0x68, 0xb8, 0x5f, 0x4e, 0x58, 0x4f, 0xdf, 0x11, 0x70, 0x24, 0xaf, - 0xb7, 0x2f, 0x2a, 0xb2, 0xba, 0x76, 0x32, 0x5a, 0x1f, 0x65, 0x91}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x52, 0x1e, 0x49, 0xbd, 0xce, 0xd2, 0x76}; - uint8_t bytesprops1[] = {0x90, 0x9, 0x22, 0x7f, 0xb0, 0x96, 0xd6, 0xf5, 0x5f, 0xcb, 0xbe, 0xb0}; - uint8_t bytesprops2[] = {0xca, 0x34, 0xa, 0xab, 0x9d, 0x2a, 0x3, 0xd4, 0x7b, 0x5e, 0xba, - 0xd7, 0x78, 0x4, 0xe5, 0x43, 0x9d, 0x32, 0x6d, 0x5f, 0x7d, 0x3a}; - uint8_t bytesprops3[] = {0xcb, 0x33, 0x57, 0xe3, 0xd9, 0x6e, 0xe7, 0x71, 0x7, 0x7e, 0xcc, 0xc3, 0x4d, 0xed, 0x6b, - 0xa0, 0x2e, 0xf8, 0x1, 0xcf, 0xab, 0x63, 0xea, 0xd9, 0x41, 0x64, 0xf1, 0x5f, 0x66, 0xcb}; - uint8_t bytesprops4[] = {0x1b, 0xd8, 0x2d, 0xf4, 0xad, 0xde, 0xa5, 0xbb, 0x38, 0x6d, 0x7, 0x7e, - 0x67, 0x2a, 0x49, 0x9f, 0x11, 0x7a, 0x8d, 0x47, 0x67, 0xcb, 0x77}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0xa5, 0xf0, 0xd9}; - uint8_t bytesprops7[] = {0x9b, 0x0, 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x21, 0x57, 0x9a, 0x25, 0xaf, 0x1, 0x74, + 0xb, 0x4, 0x9, 0x0, 0x4, 0x69, 0xfc, 0x3, 0xe2, 0x29, 0x98, 0x29, 0x42, 0x2, 0x0, 0x0, 0x1f, 0x8b, 0x3, + 0x0, 0x1e, 0x16, 0xfa, 0x15, 0x1d, 0x9a, 0x4e, 0x19, 0x43, 0x33, 0x50, 0x13, 0x11, 0x64, 0x25, 0xe, 0xb1, 0x8c, + 0xef, 0x40, 0xb6, 0xab, 0x8e, 0x22, 0x92, 0xbe, 0x75, 0x62, 0xe, 0x12, 0x87, 0x2, 0x0, 0x0, 0x74, 0x4, 0x0, + 0x3, 0xc1, 0x96, 0x5, 0x46, 0x3, 0x0, 0x1c, 0x27, 0xc1, 0xb5, 0x13, 0x7a, 0x79, 0xaa, 0x70, 0x1d, 0xd, 0xbf, + 0x81, 0x37, 0x22, 0x8d, 0xa2, 0x80, 0x2d, 0xf9, 0x69, 0x8a, 0x20, 0x4b, 0x49, 0x4e, 0xde, 0xc6, 0x4a, 0x28, 0x76, + 0x24, 0xa3, 0x23, 0x69, 0xcd, 0x2, 0x0, 0x0, 0x6f, 0x90, 0x22, 0x14, 0xf0, 0x29, 0x46, 0x23, 0x1d, 0xfa, 0x13, + 0x5e, 0x71, 0x2, 0x0, 0x0, 0x1e, 0x55, 0x18, 0x0, 0x0, 0x79, 0x9e, 0x13, 0x62, 0xf3, 0x13, 0x34, 0x31, 0x0, + 0x10, 0x19, 0xa2, 0xda, 0xe2, 0x51, 0xb3, 0x7d, 0xd3, 0x17, 0xf2, 0xbc, 0x9d, 0x28, 0x96, 0x37, 0x2d, 0x0, 0xa, + 0x92, 0x23, 0x4b, 0x18, 0x2d, 0x37, 0x77, 0xa1, 0xe4, 0x9d, 0x0, 0x2, 0x55, 0x62}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1e, 0xa3, 0xd1, 0x5c, 0x4b, 0x67, 0x1b, 0x8b, 0x25, 0xc0}; + uint8_t bytesprops1[] = {0xac, 0x5f, 0xa7, 0x82, 0x9, 0x9f, 0x98, 0x7}; + uint8_t bytesprops2[] = {0xf5, 0x7b, 0xe8, 0xbd, 0x30, 0x50, 0x49, 0x13, 0xa0, + 0xfe, 0x0, 0xeb, 0x2a, 0xe6, 0x9d, 0xb6, 0x78, 0x92}; + uint8_t bytesprops3[] = {0x26, 0x62, 0x4, 0x41, 0x62, 0xd9, 0x7, 0x78, 0x8, 0x44, 0xb, 0x7a, 0xde, + 0xea, 0x78, 0xc4, 0xd4, 0x35, 0x66, 0x45, 0x49, 0x9, 0x68, 0x57, 0xf1}; + uint8_t bytesprops4[] = {0x65, 0x2d, 0x6c, 0x2e, 0x64, 0x5c, 0x64, 0xb8, 0x17, + 0x5, 0xc5, 0xb3, 0x8f, 0xf5, 0xba, 0x19, 0x44, 0x21}; + uint8_t bytesprops5[] = {0x23, 0xed, 0x90, 0xd6, 0xe4, 0x4e, 0x41, 0xb9, 0x70, 0xa6, 0x13, 0x45, 0x17}; + uint8_t bytesprops6[] = {0x69, 0xfc, 0x3, 0xe2}; + uint8_t bytesprops7[] = {0x16, 0xfa, 0x15, 0x1d, 0x9a, 0x4e, 0x19, 0x43, 0x33, 0x50, 0x13, 0x11, 0x64, 0x25, 0xe, + 0xb1, 0x8c, 0xef, 0x40, 0xb6, 0xab, 0x8e, 0x22, 0x92, 0xbe, 0x75, 0x62, 0xe, 0x12, 0x87}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26429}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29459}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10884}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6153}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25494}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12721}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3532}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19226}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16287}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26966}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22426}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8075}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29700}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xf0, 0x82, 0x4d, 0x2a, 0xfd, 0x76, 0x3e, 0x47, 0x89, 0x34, 0x14, 0xce, 0x97, 0xa9, 0x12, - 0xe, 0xe6, 0x8f, 0x52, 0x59, 0x67, 0x95, 0xe4, 0x51, 0x16, 0xdc, 0xb0, 0xc9, 0x9d}; - uint8_t byteswillprops1[] = {0x70, 0x86, 0x13, 0xb9, 0xc0, 0x8c, 0xb2, 0x26, 0x7b, 0x31, 0x50, 0xbc, 0xc6}; - uint8_t byteswillprops3[] = {0xc2, 0x53, 0x84, 0xbf, 0xbf, 0x6f, 0xd2, 0x35, 0x53, 0x76, 0x8a, 0xbf, 0x4d}; - uint8_t byteswillprops2[] = {0xcb, 0xbf, 0x81, 0x28, 0x6c, 0xf3, 0x5b, 0xad, 0xd2, 0x7b, - 0x3d, 0xb9, 0x24, 0x92, 0xb4, 0xa3, 0xce, 0xa1, 0xdd, 0x8e, - 0xae, 0xe3, 0xc4, 0x19, 0xed, 0xd6, 0x3f, 0x79, 0x9c, 0x67}; - uint8_t byteswillprops4[] = {0xfd, 0x9e, 0x94, 0x41, 0xf5, 0x6c, 0x5a, 0xfe, 0x85, - 0x1d, 0x24, 0xdb, 0x48, 0xb5, 0xe2, 0xd0, 0xee, 0x19}; - uint8_t byteswillprops5[] = {0x33, 0x4b, 0x91, 0x5c}; - uint8_t byteswillprops6[] = {0xa7, 0xa9, 0xf8, 0xa, 0xef, 0xb7, 0xfb, 0x7e, 0x2b, - 0x5a, 0xba, 0x9e, 0xe8, 0x1b, 0x46, 0xe3, 0x2c, 0x24}; - uint8_t byteswillprops7[] = {0x9f, 0xcd, 0x49, 0xfb, 0x8e, 0x7, 0x4d, 0x73, 0xbf, 0x88, 0x3, 0x2, 0xed, 0x18, - 0x53, 0x39, 0x21, 0x55, 0x1d, 0xd0, 0x5, 0x72, 0x4d, 0x52, 0x18, 0x8, 0x7a, 0x44}; + uint8_t byteswillprops0[] = {0x27, 0xc1, 0xb5, 0x13, 0x7a, 0x79, 0xaa, 0x70, 0x1d, 0xd, 0xbf, 0x81, 0x37, 0x22, + 0x8d, 0xa2, 0x80, 0x2d, 0xf9, 0x69, 0x8a, 0x20, 0x4b, 0x49, 0x4e, 0xde, 0xc6, 0x4a}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25134}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21348}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28204}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15366}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7017}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7756}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {30, (char*)&byteswillprops2}, .v = {13, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9468}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7563}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2465}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27085}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28560}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5360}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7674}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24177}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7765}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31134}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25331}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13361}}, }; - lwmqtt_properties_t willprops = {25, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x3a, 0xe5, 0x76, 0x3f, 0x3c, 0x66, 0x45, 0xc7, 0xf6, 0xb6, 0xae, 0x8d, 0x7e, - 0x11, 0x60, 0x79, 0xd7, 0xac, 0x4c, 0x25, 0x9e, 0xc, 0xd8, 0xc6, 0x3a}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf9, 0x2d, 0xb8, 0xea, 0x92, 0xa7, 0xee, 0xb1, 0xfb, 0xa7, 0x56}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x19, 0xa2, 0xda, 0xe2, 0x51, 0xb3, 0x7d, 0xd3, + 0x17, 0xf2, 0xbc, 0x9d, 0x28, 0x96, 0x37, 0x2d}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x92, 0x23, 0x4b, 0x18, 0x2d, 0x37, 0x77, 0xa1, 0xe4, 0x9d}; + lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 13449; - uint8_t client_id_bytes[] = {0xa0, 0xe0, 0xd1, 0x7e, 0x79, 0x2f, 0x77, 0x44, - 0xb6, 0x36, 0x8f, 0xd2, 0xf4, 0x36, 0x44, 0xbe}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 618; + uint8_t client_id_bytes[] = {0xc1, 0x96, 0x5}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x3d, 0xf4, 0x1b, 0x7a, 0x19, 0xcd, 0x51, 0xd8, 0x20, 0xd3, - 0x36, 0x32, 0x19, 0xee, 0xf4, 0xef, 0x4f, 0x20, 0x44, 0x88}; - lwmqtt_string_t username = {20, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x55, 0x62}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x18, 0x6a, 0xb, 0xb4, 0xa1, 0xed, 0xc6, 0x68, 0xb8, 0x5f, 0x4e, 0x58, 0x4f, 0xdf, 0x11, - 0x70, 0x24, 0xaf, 0xb7, 0x2f, 0x2a, 0xb2, 0xba, 0x76, 0x32, 0x5a, 0x1f, 0x65, 0x91}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8512,118 +8522,121 @@ TEST(Connect5QCTest, Encode16) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\EM~\132\178\GS\169&\143*J\FS\223", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS0, _willTopic = "@li\185SS", _willMsg = -// "\225\&9L\215\ENQ\CAN\158w\142P\EOT\219\157\227\160", _willProps = [PropTopicAlias 18028,PropRetainAvailable -// 185,PropSubscriptionIdentifier 20]}), _cleanSession = False, _keepAlive = 7971, _connID = -// "T\NAK\150\156\144\224\213\148P\161D\216\239ZE\171\185\169c\STX\173", _properties = [PropContentType -// "\DEL\223b\237\148\186\245",PropAuthenticationMethod -// "\158\DC3\214LI\160\253\195\164}t\182\ACK\192\191g",PropWillDelayInterval 25298,PropMessageExpiryInterval -// 27525,PropSubscriptionIdentifierAvailable 249,PropAuthenticationMethod -// "\247\178,+\SOH\236X\156\170\179F",PropMaximumQoS 90,PropResponseInformation -// "W!\154\169\DC2|\EM\158\DLE#5\157\246\&6\235\238\192'\f_\221\149\129\144\189\STX\144\242\141\DLE",PropResponseInformation -// "\165\DC1\136\239}' \131\184\&2\253I\217\142Ut|\225\&6/\178",PropTopicAlias 20976,PropMaximumQoS -// 135,PropMessageExpiryInterval 30112,PropAssignedClientIdentifier "{\133\251\144\SUB\252>\138,",PropContentType -// "\f\193\219\191! HJ\251\242\208",PropMaximumQoS 252,PropSessionExpiryInterval 9433,PropWillDelayInterval -// 7916,PropSubscriptionIdentifier 16,PropRequestResponseInformation 251,PropPayloadFormatIndicator 189,PropMaximumQoS -// 87,PropServerKeepAlive 28237,PropMaximumPacketSize 32319,PropTopicAlias 24039,PropRetainAvailable -// 214,PropAssignedClientIdentifier "\167\206\161K\DC4\134\DC4\165\146\\\221\ETX[\185\t\DC4N)\133\&1",PropMaximumQoS -// 195,PropAuthenticationData "\ETX"]} +// ConnectRequest {_username = Just +// "\212\178\194\175\",\DC4\189\220\226\206U\131Q\182\202p\244\242D;\212\175m*\194WT\207", _password = Nothing, +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\DC24\133\225%k\SOHa\149\232\DC3}q\224", _willMsg = "\226\225\232\214\198L7\156\&6H\247\231\176X'm", _willProps = +// [PropRequestResponseInformation 60,PropMaximumQoS 151,PropServerReference "\175K\156",PropResponseTopic +// "P3\246S\222\&3\172\246\179\&4\DC3\r\220\&0\147\200|\204\174I\GS\203 \216\199d$",PropResponseInformation +// "\220\196\163\176\SYNy6\"\154\214\244\160\233\&9u\163\251\185",PropReasonString +// "6\214\n\182\231\180\&3x\176g\142r?F\218\&4&P T\214\188\238\141\171\229,\160",PropRetainAvailable +// 170,PropUserProperty "p\231\183\DC2\181\143\217\224\158\159snl\204\SO\151" +// "\219\148\139l\211x\221\143\240\187",PropWildcardSubscriptionAvailable 5]}), _cleanSession = True, _keepAlive = 5852, +// _connID = "|\199", _properties = [PropMaximumQoS 226,PropContentType " +// ,\ETB\189c\a^\181\200{\NUL\163\DLE\NAK\215g\"6\156'\169\215h\199\249\179\210\130+\144",PropServerReference +// "K\183T\166\151L\234\143\193\234C:\134\GS\220\138\206\179",PropSharedSubscriptionAvailable 218,PropMaximumQoS +// 115,PropContentType "MkR\DLEx\252\148j\174C\187\182\220\161\250",PropTopicAliasMaximum 18250,PropRetainAvailable +// 97,PropMessageExpiryInterval 18382,PropMaximumQoS 171,PropSubscriptionIdentifierAvailable +// 58,PropRequestResponseInformation 98,PropAssignedClientIdentifier +// "\168}\160\147\NAK\128V\DC1\214\177\v<\DC44\218\179",PropReasonString +// "\STX2\227.PW\187\161z\148\170\217\174\\\227<|\204\&4\204N\245\SI&z\173v=\233"]} TEST(Connect5QCTest, Encode17) { uint8_t pkt[] = { - 0x10, 0xa6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x44, 0x1f, 0x23, 0xd4, 0x1, 0x3, 0x0, 0x7, 0x7f, - 0xdf, 0x62, 0xed, 0x94, 0xba, 0xf5, 0x15, 0x0, 0x10, 0x9e, 0x13, 0xd6, 0x4c, 0x49, 0xa0, 0xfd, 0xc3, 0xa4, 0x7d, - 0x74, 0xb6, 0x6, 0xc0, 0xbf, 0x67, 0x18, 0x0, 0x0, 0x62, 0xd2, 0x2, 0x0, 0x0, 0x6b, 0x85, 0x29, 0xf9, 0x15, - 0x0, 0xb, 0xf7, 0xb2, 0x2c, 0x2b, 0x1, 0xec, 0x58, 0x9c, 0xaa, 0xb3, 0x46, 0x24, 0x5a, 0x1a, 0x0, 0x1e, 0x57, - 0x21, 0x9a, 0xa9, 0x12, 0x7c, 0x19, 0x9e, 0x10, 0x23, 0x35, 0x9d, 0xf6, 0x36, 0xeb, 0xee, 0xc0, 0x27, 0xc, 0x5f, - 0xdd, 0x95, 0x81, 0x90, 0xbd, 0x2, 0x90, 0xf2, 0x8d, 0x10, 0x1a, 0x0, 0x15, 0xa5, 0x11, 0x88, 0xef, 0x7d, 0x27, - 0x20, 0x83, 0xb8, 0x32, 0xfd, 0x49, 0xd9, 0x8e, 0x55, 0x74, 0x7c, 0xe1, 0x36, 0x2f, 0xb2, 0x23, 0x51, 0xf0, 0x24, - 0x87, 0x2, 0x0, 0x0, 0x75, 0xa0, 0x12, 0x0, 0x9, 0x7b, 0x85, 0xfb, 0x90, 0x1a, 0xfc, 0x3e, 0x8a, 0x2c, 0x3, - 0x0, 0xb, 0xc, 0xc1, 0xdb, 0xbf, 0x21, 0x20, 0x48, 0x4a, 0xfb, 0xf2, 0xd0, 0x24, 0xfc, 0x11, 0x0, 0x0, 0x24, - 0xd9, 0x18, 0x0, 0x0, 0x1e, 0xec, 0xb, 0x10, 0x19, 0xfb, 0x1, 0xbd, 0x24, 0x57, 0x13, 0x6e, 0x4d, 0x27, 0x0, - 0x0, 0x7e, 0x3f, 0x23, 0x5d, 0xe7, 0x25, 0xd6, 0x12, 0x0, 0x14, 0xa7, 0xce, 0xa1, 0x4b, 0x14, 0x86, 0x14, 0xa5, - 0x92, 0x5c, 0xdd, 0x3, 0x5b, 0xb9, 0x9, 0x14, 0x4e, 0x29, 0x85, 0x31, 0x24, 0xc3, 0x16, 0x0, 0x1, 0x3, 0x0, - 0x15, 0x54, 0x15, 0x96, 0x9c, 0x90, 0xe0, 0xd5, 0x94, 0x50, 0xa1, 0x44, 0xd8, 0xef, 0x5a, 0x45, 0xab, 0xb9, 0xa9, - 0x63, 0x2, 0xad, 0x7, 0x23, 0x46, 0x6c, 0x25, 0xb9, 0xb, 0x14, 0x0, 0x6, 0x40, 0x6c, 0x69, 0xb9, 0x53, 0x53, - 0x0, 0xf, 0xe1, 0x39, 0x4c, 0xd7, 0x5, 0x18, 0x9e, 0x77, 0x8e, 0x50, 0x4, 0xdb, 0x9d, 0xe3, 0xa0, 0x0, 0xc, - 0x19, 0x7e, 0x84, 0xb2, 0x1d, 0xa9, 0x26, 0x8f, 0x2a, 0x4a, 0x1c, 0xdf}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7f, 0xdf, 0x62, 0xed, 0x94, 0xba, 0xf5}; - uint8_t bytesprops1[] = {0x9e, 0x13, 0xd6, 0x4c, 0x49, 0xa0, 0xfd, 0xc3, - 0xa4, 0x7d, 0x74, 0xb6, 0x6, 0xc0, 0xbf, 0x67}; - uint8_t bytesprops2[] = {0xf7, 0xb2, 0x2c, 0x2b, 0x1, 0xec, 0x58, 0x9c, 0xaa, 0xb3, 0x46}; - uint8_t bytesprops3[] = {0x57, 0x21, 0x9a, 0xa9, 0x12, 0x7c, 0x19, 0x9e, 0x10, 0x23, 0x35, 0x9d, 0xf6, 0x36, 0xeb, - 0xee, 0xc0, 0x27, 0xc, 0x5f, 0xdd, 0x95, 0x81, 0x90, 0xbd, 0x2, 0x90, 0xf2, 0x8d, 0x10}; - uint8_t bytesprops4[] = {0xa5, 0x11, 0x88, 0xef, 0x7d, 0x27, 0x20, 0x83, 0xb8, 0x32, 0xfd, - 0x49, 0xd9, 0x8e, 0x55, 0x74, 0x7c, 0xe1, 0x36, 0x2f, 0xb2}; - uint8_t bytesprops5[] = {0x7b, 0x85, 0xfb, 0x90, 0x1a, 0xfc, 0x3e, 0x8a, 0x2c}; - uint8_t bytesprops6[] = {0xc, 0xc1, 0xdb, 0xbf, 0x21, 0x20, 0x48, 0x4a, 0xfb, 0xf2, 0xd0}; - uint8_t bytesprops7[] = {0xa7, 0xce, 0xa1, 0x4b, 0x14, 0x86, 0x14, 0xa5, 0x92, 0x5c, - 0xdd, 0x3, 0x5b, 0xb9, 0x9, 0x14, 0x4e, 0x29, 0x85, 0x31}; - uint8_t bytesprops8[] = {0x3}; + 0x10, 0xe2, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xae, 0x16, 0xdc, 0x91, 0x1, 0x24, 0xe2, 0x3, 0x0, + 0x1e, 0x20, 0x2c, 0x17, 0xbd, 0x63, 0x7, 0x5e, 0xb5, 0xc8, 0x7b, 0x0, 0xa3, 0x10, 0x15, 0xd7, 0x67, 0x22, 0x36, + 0x9c, 0x27, 0xa9, 0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x1f, 0x0, + 0x1c, 0x36, 0xd6, 0xa, 0xb6, 0xe7, 0xb4, 0x33, 0x78, 0xb0, 0x67, 0x8e, 0x72, 0x3f, 0x46, 0xda, 0x34, 0x26, 0x50, + 0x20, 0x54, 0xd6, 0xbc, 0xee, 0x8d, 0xab, 0xe5, 0x2c, 0xa0, 0x25, 0xaa, 0x26, 0x0, 0x10, 0x70, 0xe7, 0xb7, 0x12, + 0xb5, 0x8f, 0xd9, 0xe0, 0x9e, 0x9f, 0x73, 0x6e, 0x6c, 0xcc, 0xe, 0x97, 0x0, 0xa, 0xdb, 0x94, 0x8b, 0x6c, 0xd3, + 0x78, 0xdd, 0x8f, 0xf0, 0xbb, 0x28, 0x5, 0x0, 0xe, 0x12, 0x34, 0x85, 0xe1, 0x25, 0x6b, 0x1, 0x61, 0x95, 0xe8, + 0x13, 0x7d, 0x71, 0xe0, 0x0, 0x10, 0xe2, 0xe1, 0xe8, 0xd6, 0xc6, 0x4c, 0x37, 0x9c, 0x36, 0x48, 0xf7, 0xe7, 0xb0, + 0x58, 0x27, 0x6d, 0x0, 0x1d, 0xd4, 0xb2, 0xc2, 0xaf, 0x22, 0x2c, 0x14, 0xbd, 0xdc, 0xe2, 0xce, 0x55, 0x83, 0x51, + 0xb6, 0xca, 0x70, 0xf4, 0xf2, 0x44, 0x3b, 0xd4, 0xaf, 0x6d, 0x2a, 0xc2, 0x57, 0x54, 0xcf}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x20, 0x2c, 0x17, 0xbd, 0x63, 0x7, 0x5e, 0xb5, 0xc8, 0x7b, 0x0, 0xa3, 0x10, 0x15, 0xd7, + 0x67, 0x22, 0x36, 0x9c, 0x27, 0xa9, 0xd7, 0x68, 0xc7, 0xf9, 0xb3, 0xd2, 0x82, 0x2b, 0x90}; + uint8_t bytesprops1[] = {0x4b, 0xb7, 0x54, 0xa6, 0x97, 0x4c, 0xea, 0x8f, 0xc1, + 0xea, 0x43, 0x3a, 0x86, 0x1d, 0xdc, 0x8a, 0xce, 0xb3}; + uint8_t bytesprops2[] = {0x4d, 0x6b, 0x52, 0x10, 0x78, 0xfc, 0x94, 0x6a, 0xae, 0x43, 0xbb, 0xb6, 0xdc, 0xa1, 0xfa}; + uint8_t bytesprops3[] = {0xa8, 0x7d, 0xa0, 0x93, 0x15, 0x80, 0x56, 0x11, + 0xd6, 0xb1, 0xb, 0x3c, 0x14, 0x34, 0xda, 0xb3}; + uint8_t bytesprops4[] = {0x2, 0x32, 0xe3, 0x2e, 0x50, 0x57, 0xbb, 0xa1, 0x7a, 0x94, 0xaa, 0xd9, 0xae, 0x5c, 0xe3, + 0x3c, 0x7c, 0xcc, 0x34, 0xcc, 0x4e, 0xf5, 0xf, 0x26, 0x7a, 0xad, 0x76, 0x3d, 0xe9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25298}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27525}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20976}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30112}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9433}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7916}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28237}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32319}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24039}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18250}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18382}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xaf, 0x4b, 0x9c}; + uint8_t byteswillprops1[] = {0x50, 0x33, 0xf6, 0x53, 0xde, 0x33, 0xac, 0xf6, 0xb3, 0x34, 0x13, 0xd, 0xdc, 0x30, + 0x93, 0xc8, 0x7c, 0xcc, 0xae, 0x49, 0x1d, 0xcb, 0x20, 0xd8, 0xc7, 0x64, 0x24}; + uint8_t byteswillprops2[] = {0xdc, 0xc4, 0xa3, 0xb0, 0x16, 0x79, 0x36, 0x22, 0x9a, + 0xd6, 0xf4, 0xa0, 0xe9, 0x39, 0x75, 0xa3, 0xfb, 0xb9}; + uint8_t byteswillprops3[] = {0x36, 0xd6, 0xa, 0xb6, 0xe7, 0xb4, 0x33, 0x78, 0xb0, 0x67, 0x8e, 0x72, 0x3f, 0x46, + 0xda, 0x34, 0x26, 0x50, 0x20, 0x54, 0xd6, 0xbc, 0xee, 0x8d, 0xab, 0xe5, 0x2c, 0xa0}; + uint8_t byteswillprops5[] = {0xdb, 0x94, 0x8b, 0x6c, 0xd3, 0x78, 0xdd, 0x8f, 0xf0, 0xbb}; + uint8_t byteswillprops4[] = {0x70, 0xe7, 0xb7, 0x12, 0xb5, 0x8f, 0xd9, 0xe0, + 0x9e, 0x9f, 0x73, 0x6e, 0x6c, 0xcc, 0xe, 0x97}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18028}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {16, (char*)&byteswillprops4}, .v = {10, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 5}}, }; - lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x40, 0x6c, 0x69, 0xb9, 0x53, 0x53}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe1, 0x39, 0x4c, 0xd7, 0x5, 0x18, 0x9e, 0x77, - 0x8e, 0x50, 0x4, 0xdb, 0x9d, 0xe3, 0xa0}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x12, 0x34, 0x85, 0xe1, 0x25, 0x6b, 0x1, 0x61, 0x95, 0xe8, 0x13, 0x7d, 0x71, 0xe0}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe2, 0xe1, 0xe8, 0xd6, 0xc6, 0x4c, 0x37, 0x9c, + 0x36, 0x48, 0xf7, 0xe7, 0xb0, 0x58, 0x27, 0x6d}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; + will.qos = LWMQTT_QOS1; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 7971; - uint8_t client_id_bytes[] = {0x54, 0x15, 0x96, 0x9c, 0x90, 0xe0, 0xd5, 0x94, 0x50, 0xa1, 0x44, - 0xd8, 0xef, 0x5a, 0x45, 0xab, 0xb9, 0xa9, 0x63, 0x2, 0xad}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 5852; + uint8_t client_id_bytes[] = {0x7c, 0xc7}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x19, 0x7e, 0x84, 0xb2, 0x1d, 0xa9, 0x26, 0x8f, 0x2a, 0x4a, 0x1c, 0xdf}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; - opts.password = password; + uint8_t username_bytes[] = {0xd4, 0xb2, 0xc2, 0xaf, 0x22, 0x2c, 0x14, 0xbd, 0xdc, 0xe2, 0xce, 0x55, 0x83, 0x51, 0xb6, + 0xca, 0x70, 0xf4, 0xf2, 0x44, 0x3b, 0xd4, 0xaf, 0x6d, 0x2a, 0xc2, 0x57, 0x54, 0xcf}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; + opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8632,127 +8645,125 @@ TEST(Connect5QCTest, Encode17) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\231\"\140\184\150\129\176\136", _password = Just "<", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\228\186\150\165\217\210\189", _willMsg = -// "\240\DC2\156\154E\165|\209S\189p\140", _willProps = [PropMaximumPacketSize 21557,PropTopicAlias -// 29303,PropUserProperty "`\DC2\163\247*\242>\239" -// "``(\241\182\199\228\185\150\184\231=\248A\NAK\179\a\151F\249",PropSubscriptionIdentifier 18]}), _cleanSession = -// True, _keepAlive = 14805, _connID = "\224\153\138 P\CAN\176\DLEz2\177\169\171\247\192rU\190\&9\189\196\149o?t", -// _properties = [PropMessageExpiryInterval 19004,PropSubscriptionIdentifierAvailable 55,PropTopicAliasMaximum -// 26303,PropTopicAlias 17188,PropResponseTopic "\ty}\232\212\t\DC2",PropSessionExpiryInterval -// 15240,PropResponseInformation -// "\157\NULA\206\252\149\US>:\220\132Yq\255\DC1\207\&8\243\SOH\EM\US\186\206\244R",PropServerKeepAlive -// 29200,PropMaximumQoS 169,PropTopicAlias 7816,PropMaximumPacketSize 17164,PropResponseInformation -// ":\SYN\208\206\EOT",PropPayloadFormatIndicator 5,PropMessageExpiryInterval 19457,PropReasonString -// "\SONXs\180Ob!\146\155\178~\137",PropCorrelationData "\EMjP\179,+,\144\241\161zl\244",PropTopicAliasMaximum -// 3531,PropRetainAvailable 31,PropWildcardSubscriptionAvailable 118,PropRetainAvailable 181,PropAuthenticationData -// "eSSMz\235J\186\NAKE8>;\241",PropResponseInformation -// "f[\201\SO\DLEvP\181\236\142\&5%\b\201\255^'\136q{",PropContentType "",PropReasonString -// "\ACK\150A\215\157\218\133",PropRequestResponseInformation 2,PropCorrelationData "=\184\178",PropServerKeepAlive -// 22022,PropPayloadFormatIndicator 214,PropAssignedClientIdentifier "5#\201\SUB"]} +// ConnectRequest {_username = Just "2\DC1\197\140\172\STX\245\224", _password = Just +// "C\232\160\f\216\162\204\154\165\248\249\194\&5g\172\177\236\DC2\EOT\245\214\156", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = +// "$\RSC_\156\STX\165$\246x_\195(]^\f\a%\232O\vf\"\180\174\135\223!8`", _willMsg = +// "\190'c\128\&6\169\239\f\a\GS\246\152}\153\215\ACK\SOH9\248\193A\224\237\179", _willProps = +// [PropSessionExpiryInterval 28866,PropMessageExpiryInterval 5544,PropAuthenticationData +// "\170\250\133s\NAK\140\167\t\209",PropTopicAliasMaximum 28843,PropMessageExpiryInterval +// 11044,PropAssignedClientIdentifier "\180T8\237}\182\204\RSr",PropAuthenticationMethod "\138\179 +// ?",PropSessionExpiryInterval 27762,PropMaximumPacketSize 16384,PropResponseTopic +// "W\235\149U",PropMessageExpiryInterval 14766,PropWillDelayInterval 26866,PropWillDelayInterval +// 8680,PropMaximumPacketSize 16961,PropMessageExpiryInterval 6312,PropMaximumPacketSize 28045,PropRetainAvailable +// 220,PropSessionExpiryInterval 31091,PropSharedSubscriptionAvailable 27,PropWildcardSubscriptionAvailable +// 139,PropReceiveMaximum 19162,PropAuthenticationMethod +// "\188\170\148Z\CAN\211L\SUB\175\158#\192\236B\193V\162",PropWildcardSubscriptionAvailable +// 142,PropSharedSubscriptionAvailable 27]}), _cleanSession = True, _keepAlive = 12387, _connID = +// "\ETX\SYN\DC2\a\ETB\224\158xuW\n\236S\134\138\198\CAN\SI\bp", _properties = [PropContentType +// "\194\251\188\239\FS\176\180!\193\141\210 \251%e\203!\254\182k\SI",PropWildcardSubscriptionAvailable +// 207,PropMaximumPacketSize 3626,PropWillDelayInterval 12740,PropAuthenticationMethod +// "\DC4\STXj\145\185k\160\SYN\181\SUBlW\171\142\207j\177\v\192",PropMessageExpiryInterval 13928,PropServerKeepAlive +// 13861]} TEST(Connect5QCTest, Encode18) { uint8_t pkt[] = { - 0x10, 0xbd, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x39, 0xd5, 0xc6, 0x1, 0x2, 0x0, 0x0, 0x4a, - 0x3c, 0x29, 0x37, 0x22, 0x66, 0xbf, 0x23, 0x43, 0x24, 0x8, 0x0, 0x7, 0x9, 0x79, 0x7d, 0xe8, 0xd4, 0x9, 0x12, - 0x11, 0x0, 0x0, 0x3b, 0x88, 0x1a, 0x0, 0x19, 0x9d, 0x0, 0x41, 0xce, 0xfc, 0x95, 0x1f, 0x3e, 0x3a, 0xdc, 0x84, - 0x59, 0x71, 0xff, 0x11, 0xcf, 0x38, 0xf3, 0x1, 0x19, 0x1f, 0xba, 0xce, 0xf4, 0x52, 0x13, 0x72, 0x10, 0x24, 0xa9, - 0x23, 0x1e, 0x88, 0x27, 0x0, 0x0, 0x43, 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b8, 0xe7, 0x3d, 0xf8, 0x41, 0x15, 0xb3, 0x7, 0x97, 0x46, 0xf9, 0xb, 0x12, 0x0, - 0x7, 0xe4, 0xba, 0x96, 0xa5, 0xd9, 0xd2, 0xbd, 0x0, 0xc, 0xf0, 0x12, 0x9c, 0x9a, 0x45, 0xa5, 0x7c, 0xd1, 0x53, - 0xbd, 0x70, 0x8c, 0x0, 0x8, 0xe7, 0x22, 0x8c, 0xb8, 0x96, 0x81, 0xb0, 0x88, 0x0, 0x1, 0x3c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x9, 0x79, 0x7d, 0xe8, 0xd4, 0x9, 0x12}; - uint8_t bytesprops1[] = {0x9d, 0x0, 0x41, 0xce, 0xfc, 0x95, 0x1f, 0x3e, 0x3a, 0xdc, 0x84, 0x59, 0x71, - 0xff, 0x11, 0xcf, 0x38, 0xf3, 0x1, 0x19, 0x1f, 0xba, 0xce, 0xf4, 0x52}; - uint8_t bytesprops2[] = {0x3a, 0x16, 0xd0, 0xce, 0x4}; - uint8_t bytesprops3[] = {0xe, 0x4e, 0x58, 0x73, 0xb4, 0x4f, 0x62, 0x21, 0x92, 0x9b, 0xb2, 0x7e, 0x89}; - uint8_t bytesprops4[] = {0x19, 0x6a, 0x50, 0xb3, 0x2c, 0x2b, 0x2c, 0x90, 0xf1, 0xa1, 0x7a, 0x6c, 0xf4}; - uint8_t bytesprops5[] = {0x65, 0x53, 0x53, 0x4d, 0x7a, 0xeb, 0x4a, 0xba, 0x15, 0x45, 0x38, 0x3e, 0x3b, 0xf1}; - uint8_t bytesprops6[] = {0x66, 0x5b, 0xc9, 0xe, 0x10, 0x76, 0x50, 0xb5, 0xec, 0x8e, - 0x35, 0x25, 0x8, 0xc9, 0xff, 0x5e, 0x27, 0x88, 0x71, 0x7b}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops8[] = {0x6, 0x96, 0x41, 0xd7, 0x9d, 0xda, 0x85}; - uint8_t bytesprops9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 0x18, 0x0, 0x0, 0x21, 0xe8, 0x27, 0x0, 0x0, 0x42, 0x41, + 0x2, 0x0, 0x0, 0x18, 0xa8, 0x27, 0x0, 0x0, 0x6d, 0x8d, 0x25, 0xdc, 0x11, 0x0, 0x0, 0x79, 0x73, 0x2a, 0x1b, + 0x28, 0x8b, 0x21, 0x4a, 0xda, 0x15, 0x0, 0x11, 0xbc, 0xaa, 0x94, 0x5a, 0x18, 0xd3, 0x4c, 0x1a, 0xaf, 0x9e, 0x23, + 0xc0, 0xec, 0x42, 0xc1, 0x56, 0xa2, 0x28, 0x8e, 0x2a, 0x1b, 0x0, 0x1e, 0x24, 0x1e, 0x43, 0x5f, 0x9c, 0x2, 0xa5, + 0x24, 0xf6, 0x78, 0x5f, 0xc3, 0x28, 0x5d, 0x5e, 0xc, 0x7, 0x25, 0xe8, 0x4f, 0xb, 0x66, 0x22, 0xb4, 0xae, 0x87, + 0xdf, 0x21, 0x38, 0x60, 0x0, 0x18, 0xbe, 0x27, 0x63, 0x80, 0x36, 0xa9, 0xef, 0xc, 0x7, 0x1d, 0xf6, 0x98, 0x7d, + 0x99, 0xd7, 0x6, 0x1, 0x39, 0xf8, 0xc1, 0x41, 0xe0, 0xed, 0xb3, 0x0, 0x8, 0x32, 0x11, 0xc5, 0x8c, 0xac, 0x2, + 0xf5, 0xe0, 0x0, 0x16, 0x43, 0xe8, 0xa0, 0xc, 0xd8, 0xa2, 0xcc, 0x9a, 0xa5, 0xf8, 0xf9, 0xc2, 0x35, 0x67, 0xac, + 0xb1, 0xec, 0x12, 0x4, 0xf5, 0xd6, 0x9c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc2, 0xfb, 0xbc, 0xef, 0x1c, 0xb0, 0xb4, 0x21, 0xc1, 0x8d, 0xd2, + 0x20, 0xfb, 0x25, 0x65, 0xcb, 0x21, 0xfe, 0xb6, 0x6b, 0xf}; + uint8_t bytesprops1[] = {0x14, 0x2, 0x6a, 0x91, 0xb9, 0x6b, 0xa0, 0x16, 0xb5, 0x1a, + 0x6c, 0x57, 0xab, 0x8e, 0xcf, 0x6a, 0xb1, 0xb, 0xc0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19004}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26303}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17188}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15240}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29200}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7816}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17164}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19457}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3531}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22022}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3626}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12740}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13928}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13861}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x60, 0x60, 0x28, 0xf1, 0xb6, 0xc7, 0xe4, 0xb9, 0x96, 0xb8, - 0xe7, 0x3d, 0xf8, 0x41, 0x15, 0xb3, 0x7, 0x97, 0x46, 0xf9}; - uint8_t byteswillprops0[] = {0x60, 0x12, 0xa3, 0xf7, 0x2a, 0xf2, 0x3e, 0xef}; + uint8_t byteswillprops0[] = {0xaa, 0xfa, 0x85, 0x73, 0x15, 0x8c, 0xa7, 0x9, 0xd1}; + uint8_t byteswillprops1[] = {0xb4, 0x54, 0x38, 0xed, 0x7d, 0xb6, 0xcc, 0x1e, 0x72}; + uint8_t byteswillprops2[] = {0x8a, 0xb3, 0x20, 0x3f}; + uint8_t byteswillprops3[] = {0x57, 0xeb, 0x95, 0x55}; + uint8_t byteswillprops4[] = {0xbc, 0xaa, 0x94, 0x5a, 0x18, 0xd3, 0x4c, 0x1a, 0xaf, + 0x9e, 0x23, 0xc0, 0xec, 0x42, 0xc1, 0x56, 0xa2}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21557}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29303}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {8, (char*)&byteswillprops0}, .v = {20, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28866}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5544}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28843}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11044}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27762}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16384}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14766}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26866}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8680}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16961}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6312}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28045}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31091}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19162}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 27}}, }; - lwmqtt_properties_t willprops = {4, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xe4, 0xba, 0x96, 0xa5, 0xd9, 0xd2, 0xbd}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf0, 0x12, 0x9c, 0x9a, 0x45, 0xa5, 0x7c, 0xd1, 0x53, 0xbd, 0x70, 0x8c}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x24, 0x1e, 0x43, 0x5f, 0x9c, 0x2, 0xa5, 0x24, 0xf6, 0x78, + 0x5f, 0xc3, 0x28, 0x5d, 0x5e, 0xc, 0x7, 0x25, 0xe8, 0x4f, + 0xb, 0x66, 0x22, 0xb4, 0xae, 0x87, 0xdf, 0x21, 0x38, 0x60}; + lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xbe, 0x27, 0x63, 0x80, 0x36, 0xa9, 0xef, 0xc, 0x7, 0x1d, 0xf6, 0x98, + 0x7d, 0x99, 0xd7, 0x6, 0x1, 0x39, 0xf8, 0xc1, 0x41, 0xe0, 0xed, 0xb3}; + lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 14805; - uint8_t client_id_bytes[] = {0xe0, 0x99, 0x8a, 0x20, 0x50, 0x18, 0xb0, 0x10, 0x7a, 0x32, 0xb1, 0xa9, 0xab, - 0xf7, 0xc0, 0x72, 0x55, 0xbe, 0x39, 0xbd, 0xc4, 0x95, 0x6f, 0x3f, 0x74}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.keep_alive = 12387; + uint8_t client_id_bytes[] = {0x3, 0x16, 0x12, 0x7, 0x17, 0xe0, 0x9e, 0x78, 0x75, 0x57, + 0xa, 0xec, 0x53, 0x86, 0x8a, 0xc6, 0x18, 0xf, 0x8, 0x70}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xe7, 0x22, 0x8c, 0xb8, 0x96, 0x81, 0xb0, 0x88}; + uint8_t username_bytes[] = {0x32, 0x11, 0xc5, 0x8c, 0xac, 0x2, 0xf5, 0xe0}; lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x3c}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x43, 0xe8, 0xa0, 0xc, 0xd8, 0xa2, 0xcc, 0x9a, 0xa5, 0xf8, 0xf9, + 0xc2, 0x35, 0x67, 0xac, 0xb1, 0xec, 0x12, 0x4, 0xf5, 0xd6, 0x9c}; + lwmqtt_string_t password = {22, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -8762,237 +8773,201 @@ TEST(Connect5QCTest, Encode18) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "I\DC1a\EOT\217\152\&5\206\145\132\232z\157", _password = Just -// "\215\235\149i\140u\SUB\DELp\137\141q?\246[g\200\149e", _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "Gn\r k\174]\212!nN\176\217\185h\211*\166\t\160\169\v\168q\174>z", _willMsg = "\NUL\247", -// _willProps = [PropAuthenticationData -// "\234-\ACKE\174\EM\246\&2H\248\243M\184\246d\185lH\172>\r",PropSharedSubscriptionAvailable 77,PropReasonString -// "\236c\164K\EOT.\172\212\ETB\SI=;\a\182\\\DC4S@[\DLE\249\199"]}), _cleanSession = False, _keepAlive = 487, _connID = -// "\r\196\187Nr\226\142\198\223\237\224\191", _properties = [PropWillDelayInterval 15241,PropResponseTopic -// "",PropRetainAvailable 19,PropRequestResponseInformation 209,PropMessageExpiryInterval -// 20291,PropRequestProblemInformation 234,PropAuthenticationData -// "h\194b\194/\EOTt\222\132:\184P\129(\n\ETB\204\153=\227\199",PropCorrelationData -// "\166&\246r\226\165W",PropRequestResponseInformation 23,PropSubscriptionIdentifierAvailable 8,PropReasonString -// "",PropSharedSubscriptionAvailable 201,PropContentType -// "qE^\SYNX\217\210\221V\213o\139B\GS\154'k\247\197\224P_&\249D\177[",PropTopicAlias 31279,PropRetainAvailable -// 96,PropAuthenticationMethod "m\189\149\&0\137\208",PropMessageExpiryInterval 587,PropUserProperty -// "7\248O\161+\b\132\138qy\134\163\190+\136\210\166\211\\)or\175\128/>)" -// "\158@\161\145\186\180\NAK\170\233X}\161}\r\DLE\232fW1\250t\170H",PropContentType "\141\179\ESC\210@\216<\220c[t -// \145m\178`T[Y\t\147+O\249\196\139\ESC\138",PropAuthenticationMethod "\249\253|\205H"]} +// ConnectRequest {_username = Nothing, _password = Just "m\224J\233E\DC3\ETB\NUL`\145\194\ETXi", _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 8004, _connID = "\152\175\205\ESC\239\142|}6k\238\178", _properties = +// [PropWildcardSubscriptionAvailable 80,PropRetainAvailable 187,PropReceiveMaximum 22643,PropResponseInformation +// "\187\173\&8\139\232!=",PropTopicAliasMaximum 32061,PropSharedSubscriptionAvailable 144,PropMessageExpiryInterval +// 21234,PropServerKeepAlive 17963,PropPayloadFormatIndicator 196,PropServerReference +// "\196\&4dF+]\206jD]\217\206\168^\138\248U\253\141\SOH\STX\222\186\184",PropMessageExpiryInterval +// 7126,PropWildcardSubscriptionAvailable 228,PropPayloadFormatIndicator 253,PropSessionExpiryInterval +// 14518,PropResponseInformation +// "\219\249\154\SYN/\139\177\142v\188\153\189\148\216XtX\139\237c\219B",PropRetainAvailable +// 4,PropRequestResponseInformation 105,PropSubscriptionIdentifierAvailable 243,PropMessageExpiryInterval +// 15556,PropTopicAliasMaximum 20230,PropServerReference +// "G\225\nh\248\NUL%\254\193S\131\227,b\137l\ACK\DC2.\STX0\222l\143\142\228\128\135",PropReceiveMaximum +// 20167,PropMessageExpiryInterval 26552,PropTopicAliasMaximum 18024]} TEST(Connect5QCTest, Encode19) { - uint8_t pkt[] = { - 0x10, 0xe0, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x1, 0xe7, 0xcd, 0x1, 0x18, 0x0, 0x0, 0x3b, - 0x89, 0x8, 0x0, 0x0, 0x25, 0x13, 0x19, 0xd1, 0x2, 0x0, 0x0, 0x4f, 0x43, 0x17, 0xea, 0x16, 0x0, 0x15, 0x68, - 0xc2, 0x62, 0xc2, 0x2f, 0x4, 0x74, 0xde, 0x84, 0x3a, 0xb8, 0x50, 0x81, 0x28, 0xa, 0x17, 0xcc, 0x99, 0x3d, 0xe3, - 0xc7, 0x9, 0x0, 0x7, 0xa6, 0x26, 0xf6, 0x72, 0xe2, 0xa5, 0x57, 0x19, 0x17, 0x29, 0x8, 0x1f, 0x0, 0x0, 0x2a, - 0xc9, 0x3, 0x0, 0x1b, 0x71, 0x45, 0x5e, 0x16, 0x58, 0xd9, 0xd2, 0xdd, 0x56, 0xd5, 0x6f, 0x8b, 0x42, 0x1d, 0x9a, - 0x27, 0x6b, 0xf7, 0xc5, 0xe0, 0x50, 0x5f, 0x26, 0xf9, 0x44, 0xb1, 0x5b, 0x23, 0x7a, 0x2f, 0x25, 0x60, 0x15, 0x0, - 0x6, 0x6d, 0xbd, 0x95, 0x30, 0x89, 0xd0, 0x2, 0x0, 0x0, 0x2, 0x4b,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 0xb, 0xa8, 0x71, 0xae, 0x3e, 0x7a, 0x0, 0x2, 0x0, 0xf7, 0x0, 0xd, 0x49, 0x11, - 0x61, 0x4, 0xd9, 0x98, 0x35, 0xce, 0x91, 0x84, 0xe8, 0x7a, 0x9d, 0x0, 0x13, 0xd7, 0xeb, 0x95, 0x69, 0x8c, 0x75, - 0x1a, 0x7f, 0x70, 0x89, 0x8d, 0x71, 0x3f, 0xf6, 0x5b, 0x67, 0xc8, 0x95, 0x65}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x68, 0xc2, 0x62, 0xc2, 0x2f, 0x4, 0x74, 0xde, 0x84, 0x3a, 0xb8, - 0x50, 0x81, 0x28, 0xa, 0x17, 0xcc, 0x99, 0x3d, 0xe3, 0xc7}; - uint8_t bytesprops2[] = {0xa6, 0x26, 0xf6, 0x72, 0xe2, 0xa5, 0x57}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x71, 0x45, 0x5e, 0x16, 0x58, 0xd9, 0xd2, 0xdd, 0x56, 0xd5, 0x6f, 0x8b, 0x42, 0x1d, - 0x9a, 0x27, 0x6b, 0xf7, 0xc5, 0xe0, 0x50, 0x5f, 0x26, 0xf9, 0x44, 0xb1, 0x5b}; - uint8_t bytesprops5[] = {0x6d, 0xbd, 0x95, 0x30, 0x89, 0xd0}; - uint8_t bytesprops7[] = {0x9e, 0x40, 0xa1, 0x91, 0xba, 0xb4, 0x15, 0xaa, 0xe9, 0x58, 0x7d, 0xa1, - 0x7d, 0xd, 0x10, 0xe8, 0x66, 0x57, 0x31, 0xfa, 0x74, 0xaa, 0x48}; - uint8_t bytesprops6[] = {0x37, 0xf8, 0x4f, 0xa1, 0x2b, 0x8, 0x84, 0x8a, 0x71, 0x79, 0x86, 0xa3, 0xbe, 0x2b, - 0x88, 0xd2, 0xa6, 0xd3, 0x5c, 0x29, 0x6f, 0x72, 0xaf, 0x80, 0x2f, 0x3e, 0x29}; - uint8_t bytesprops8[] = {0x8d, 0xb3, 0x1b, 0xd2, 0x40, 0xd8, 0x3c, 0xdc, 0x63, 0x5b, 0x74, 0x20, 0x91, 0x6d, - 0xb2, 0x60, 0x54, 0x5b, 0x59, 0x9, 0x93, 0x2b, 0x4f, 0xf9, 0xc4, 0x8b, 0x1b, 0x8a}; - uint8_t bytesprops9[] = {0xf9, 0xfd, 0x7c, 0xcd, 0x48}; + uint8_t pkt[] = {0x10, 0xc3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x42, 0x1f, 0x44, 0x9a, 0x1, 0x28, 0x50, + 0x25, 0xbb, 0x21, 0x58, 0x73, 0x1a, 0x0, 0x7, 0xbb, 0xad, 0x38, 0x8b, 0xe8, 0x21, 0x3d, 0x22, 0x7d, + 0x3d, 0x2a, 0x90, 0x2, 0x0, 0x0, 0x52, 0xf2, 0x13, 0x46, 0x2b, 0x1, 0xc4, 0x1c, 0x0, 0x18, 0xc4, + 0x34, 0x64, 0x46, 0x2b, 0x5d, 0xce, 0x6a, 0x44, 0x5d, 0xd9, 0xce, 0xa8, 0x5e, 0x8a, 0xf8, 0x55, 0xfd, + 0x8d, 0x1, 0x2, 0xde, 0xba, 0xb8, 0x2, 0x0, 0x0, 0x1b, 0xd6, 0x28, 0xe4, 0x1, 0xfd, 0x11, 0x0, + 0x0, 0x38, 0xb6, 0x1a, 0x0, 0x16, 0xdb, 0xf9, 0x9a, 0x16, 0x2f, 0x8b, 0xb1, 0x8e, 0x76, 0xbc, 0x99, + 0xbd, 0x94, 0xd8, 0x58, 0x74, 0x58, 0x8b, 0xed, 0x63, 0xdb, 0x42, 0x25, 0x4, 0x19, 0x69, 0x29, 0xf3, + 0x2, 0x0, 0x0, 0x3c, 0xc4, 0x22, 0x4f, 0x6, 0x1c, 0x0, 0x1c, 0x47, 0xe1, 0xa, 0x68, 0xf8, 0x0, + 0x25, 0xfe, 0xc1, 0x53, 0x83, 0xe3, 0x2c, 0x62, 0x89, 0x6c, 0x6, 0x12, 0x2e, 0x2, 0x30, 0xde, 0x6c, + 0x8f, 0x8e, 0xe4, 0x80, 0x87, 0x21, 0x4e, 0xc7, 0x2, 0x0, 0x0, 0x67, 0xb8, 0x22, 0x46, 0x68, 0x0, + 0xc, 0x98, 0xaf, 0xcd, 0x1b, 0xef, 0x8e, 0x7c, 0x7d, 0x36, 0x6b, 0xee, 0xb2, 0x0, 0xd, 0x6d, 0xe0, + 0x4a, 0xe9, 0x45, 0x13, 0x17, 0x0, 0x60, 0x91, 0xc2, 0x3, 0x69}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbb, 0xad, 0x38, 0x8b, 0xe8, 0x21, 0x3d}; + uint8_t bytesprops1[] = {0xc4, 0x34, 0x64, 0x46, 0x2b, 0x5d, 0xce, 0x6a, 0x44, 0x5d, 0xd9, 0xce, + 0xa8, 0x5e, 0x8a, 0xf8, 0x55, 0xfd, 0x8d, 0x1, 0x2, 0xde, 0xba, 0xb8}; + uint8_t bytesprops2[] = {0xdb, 0xf9, 0x9a, 0x16, 0x2f, 0x8b, 0xb1, 0x8e, 0x76, 0xbc, 0x99, + 0xbd, 0x94, 0xd8, 0x58, 0x74, 0x58, 0x8b, 0xed, 0x63, 0xdb, 0x42}; + uint8_t bytesprops3[] = {0x47, 0xe1, 0xa, 0x68, 0xf8, 0x0, 0x25, 0xfe, 0xc1, 0x53, 0x83, 0xe3, 0x2c, 0x62, + 0x89, 0x6c, 0x6, 0x12, 0x2e, 0x2, 0x30, 0xde, 0x6c, 0x8f, 0x8e, 0xe4, 0x80, 0x87}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15241}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20291}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31279}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 587}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops6}, .v = {23, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops9}}}, - }; - - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xea, 0x2d, 0x6, 0x45, 0xae, 0x19, 0xf6, 0x32, 0x48, 0xf8, 0xf3, - 0x4d, 0xb8, 0xf6, 0x64, 0xb9, 0x6c, 0x48, 0xac, 0x3e, 0xd}; - uint8_t byteswillprops1[] = {0xec, 0x63, 0xa4, 0x4b, 0x4, 0x2e, 0xac, 0xd4, 0x17, 0xf, 0x3d, - 0x3b, 0x7, 0xb6, 0x5c, 0x14, 0x53, 0x40, 0x5b, 0x10, 0xf9, 0xc7}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22643}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32061}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21234}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17963}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7126}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14518}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15556}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20230}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20167}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26552}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18024}}, }; - lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x47, 0x6e, 0xd, 0x20, 0x6b, 0xae, 0x5d, 0xd4, 0x21, 0x6e, 0x4e, 0xb0, 0xd9, 0xb9, - 0x68, 0xd3, 0x2a, 0xa6, 0x9, 0xa0, 0xa9, 0xb, 0xa8, 0x71, 0xae, 0x3e, 0x7a}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x0, 0xf7}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 487; - uint8_t client_id_bytes[] = {0xd, 0xc4, 0xbb, 0x4e, 0x72, 0xe2, 0x8e, 0xc6, 0xdf, 0xed, 0xe0, 0xbf}; + opts.clean_session = true; + opts.keep_alive = 8004; + uint8_t client_id_bytes[] = {0x98, 0xaf, 0xcd, 0x1b, 0xef, 0x8e, 0x7c, 0x7d, 0x36, 0x6b, 0xee, 0xb2}; lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x49, 0x11, 0x61, 0x4, 0xd9, 0x98, 0x35, 0xce, 0x91, 0x84, 0xe8, 0x7a, 0x9d}; - lwmqtt_string_t username = {13, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd7, 0xeb, 0x95, 0x69, 0x8c, 0x75, 0x1a, 0x7f, 0x70, 0x89, - 0x8d, 0x71, 0x3f, 0xf6, 0x5b, 0x67, 0xc8, 0x95, 0x65}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x6d, 0xe0, 0x4a, 0xe9, 0x45, 0x13, 0x17, 0x0, 0x60, 0x91, 0xc2, 0x3, 0x69}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\167Vv", _password = Just "\USefMcY\245s", _lastWill = Just (LastWill {_willRetain -// = False, _willQoS = QoS2, _willTopic = -// "\134q\161\236\217\\\238\&3z\146\f\186\198\211u\250_\r\194\141t~\168w\225t\171\135i\229", _willMsg = -// "\164\252\EOT\203\197\166\171B\177\145\DC4\190\DC3\205\NAK\143\157\SUB\177\248\NAK\129\222\DEL>0H", _willProps = -// [PropServerReference "d\144,t\129\FS",PropSubscriptionIdentifierAvailable 129,PropAuthenticationMethod -// "\199\150\255u",PropMessageExpiryInterval 3290,PropRetainAvailable 208,PropUserProperty -// "\192\236\249h\132\EOTN\164\247\240Q\SOj\SYN{\\\220\&7f\176\246\ETX [^\149i" "_\208\140\255 EQ\153P"]}), -// _cleanSession = False, _keepAlive = 176, _connID = -// "\164\181\166\128r\129\SUB\184rUbzJ\177WIU+\158\DEL\SOH\NAK\164\169", _properties = [PropPayloadFormatIndicator -// 25,PropRequestProblemInformation 231,PropServerKeepAlive 16912,PropWillDelayInterval 27960,PropAuthenticationData -// "\187\206F\f\203\233\146\&1\ACK E\190\232$?\203$\176\206\148",PropAuthenticationData -// "s\128\138\228\251",PropCorrelationData "Bg\160\212q\248:uy\139+-\159{\252\251",PropServerReference -// "k\241\194cF\177\SI\222\EOT\233\241\134\138\142Ql\DC3\223\169\FS@\247\239\226\196\200\RSm",PropMaximumPacketSize -// 28292,PropSharedSubscriptionAvailable 111,PropWildcardSubscriptionAvailable 255,PropSubscriptionIdentifier -// 23,PropAuthenticationData "NH\"\134r\181{.\DC2\205\SI\SI\GS\v\t;\233\146\EM\180\193\DC4X\SI\NULg",PropTopicAlias -// 21077]} +// ConnectRequest {_username = Just "\238", _password = Just "\224\167\178Vb~\222\DLE\192\146\197\133L", _lastWill = +// Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\STX", _willMsg = +// "6D\137\167,4\131\&6\166\145\201\149|\221\&2i\192", _willProps = [PropResponseInformation +// "\DC1\210\228c-H\171\231\183MU\SYN\236*\248",PropUserProperty +// "\195\a\251E=/\214g\222\249\221\174\229$wSn\217\STX\229f\147\229lr" +// "\ETXL\202*l\201?p\247\250\173\210\161#\"R\STX\210",PropSubscriptionIdentifierAvailable 96,PropServerKeepAlive +// 3571,PropAssignedClientIdentifier "+)\152\164\177\&9v\245\NAK\153",PropRequestResponseInformation +// 45,PropMessageExpiryInterval 10940,PropMaximumPacketSize 12523]}), _cleanSession = False, _keepAlive = 19508, _connID +// = "|\238>", _properties = [PropReceiveMaximum 6419,PropUserProperty "\STX\194\196\164\209@\152\NUL\248\149a\ENQL" +// "}\167h6tf0h!\200L\STX\SIv\190\183\165\225\DC3\217\237$\173\&4\tK\FS\149\221\GS",PropAuthenticationData +// "\182",PropRequestProblemInformation 122,PropAssignedClientIdentifier "",PropMessageExpiryInterval +// 23247,PropRequestProblemInformation 18,PropMaximumPacketSize 25523,PropWildcardSubscriptionAvailable +// 88,PropMaximumPacketSize 27103,PropSubscriptionIdentifier 30,PropSubscriptionIdentifierAvailable +// 145,PropTopicAliasMaximum 11597,PropResponseTopic +// "\178M\160PH\183\241\149\DLE\144\150y\233\ENQ\253\233\148\SO\DC4\212\222\b\246\182\DC4\vG",PropServerReference +// "L\224",PropMessageExpiryInterval 31337,PropResponseTopic +// "\ACK\130S\DC3\159>\232\132\&3\175\184\149\191\255x\SOH\NAK",PropMaximumQoS 247]} TEST(Connect5QCTest, Encode20) { - uint8_t pkt[] = { - 0x10, 0xbd, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54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0x75, 0x2, 0x0, 0x0, 0xc, 0xda, 0x25, 0xd0, 0x26, 0x0, 0x1b, 0xc0, 0xec, 0xf9, - 0x68, 0x84, 0x4, 0x4e, 0xa4, 0xf7, 0xf0, 0x51, 0xe, 0x6a, 0x16, 0x7b, 0x5c, 0xdc, 0x37, 0x66, 0xb0, 0xf6, 0x3, - 0x20, 0x5b, 0x5e, 0x95, 0x69, 0x0, 0x9, 0x5f, 0xd0, 0x8c, 0xff, 0x20, 0x45, 0x51, 0x99, 0x50, 0x0, 0x1e, 0x86, - 0x71, 0xa1, 0xec, 0xd9, 0x5c, 0xee, 0x33, 0x7a, 0x92, 0xc, 0xba, 0xc6, 0xd3, 0x75, 0xfa, 0x5f, 0xd, 0xc2, 0x8d, - 0x74, 0x7e, 0xa8, 0x77, 0xe1, 0x74, 0xab, 0x87, 0x69, 0xe5, 0x0, 0x1b, 0xa4, 0xfc, 0x4, 0xcb, 0xc5, 0xa6, 0xab, - 0x42, 0xb1, 0x91, 0x14, 0xbe, 0x13, 0xcd, 0x15, 0x8f, 0x9d, 0x1a, 0xb1, 0xf8, 0x15, 0x81, 0xde, 0x7f, 0x3e, 0x30, - 0x48, 0x0, 0x3, 0xa7, 0x56, 0x76, 0x0, 0x8, 0x1f, 0x65, 0x66, 0x4d, 0x63, 0x59, 0xf5, 0x73}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xbb, 0xce, 0x46, 0xc, 0xcb, 0xe9, 0x92, 0x31, 0x6, 0x20, - 0x45, 0xbe, 0xe8, 0x24, 0x3f, 0xcb, 0x24, 0xb0, 0xce, 0x94}; - uint8_t bytesprops1[] = {0x73, 0x80, 0x8a, 0xe4, 0xfb}; - uint8_t bytesprops2[] = {0x42, 0x67, 0xa0, 0xd4, 0x71, 0xf8, 0x3a, 0x75, - 0x79, 0x8b, 0x2b, 0x2d, 0x9f, 0x7b, 0xfc, 0xfb}; - uint8_t bytesprops3[] = {0x6b, 0xf1, 0xc2, 0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0, 0x2, 0x4c, 0xe0, + 0x2, 0x0, 0x0, 0x7a, 0x69, 0x8, 0x0, 0x11, 0x6, 0x82, 0x53, 0x13, 0x9f, 0x3e, 0xe8, 0x84, 0x33, + 0xaf, 0xb8, 0x95, 0xbf, 0xff, 0x78, 0x1, 0x15, 0x24, 0xf7, 0x0, 0x3, 0x7c, 0xee, 0x3e, 0x60, 0x1a, + 0x0, 0xf, 0x11, 0xd2, 0xe4, 0x63, 0x2d, 0x48, 0xab, 0xe7, 0xb7, 0x4d, 0x55, 0x16, 0xec, 0x2a, 0xf8, + 0x26, 0x0, 0x19, 0xc3, 0x7, 0xfb, 0x45, 0x3d, 0x2f, 0xd6, 0x67, 0xde, 0xf9, 0xdd, 0xae, 0xe5, 0x24, + 0x77, 0x53, 0x6e, 0xd9, 0x2, 0xe5, 0x66, 0x93, 0xe5, 0x6c, 0x72, 0x0, 0x12, 0x3, 0x4c, 0xca, 0x2a, + 0x6c, 0xc9, 0x3f, 0x70, 0xf7, 0xfa, 0xad, 0xd2, 0xa1, 0x23, 0x22, 0x52, 0x2, 0xd2, 0x29, 0x60, 0x13, + 0xd, 0xf3, 0x12, 0x0, 0xa, 0x2b, 0x29, 0x98, 0xa4, 0xb1, 0x39, 0x76, 0xf5, 0x15, 0x99, 0x19, 0x2d, + 0x2, 0x0, 0x0, 0x2a, 0xbc, 0x27, 0x0, 0x0, 0x30, 0xeb, 0x0, 0x1, 0x2, 0x0, 0x11, 0x36, 0x44, + 0x89, 0xa7, 0x2c, 0x34, 0x83, 0x36, 0xa6, 0x91, 0xc9, 0x95, 0x7c, 0xdd, 0x32, 0x69, 0xc0, 0x0, 0x1, + 0xee, 0x0, 0xd, 0xe0, 0xa7, 0xb2, 0x56, 0x62, 0x7e, 0xde, 0x10, 0xc0, 0x92, 0xc5, 0x85, 0x4c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x7d, 0xa7, 0x68, 0x36, 0x74, 0x66, 0x30, 0x68, 0x21, 0xc8, 0x4c, 0x2, 0xf, 0x76, 0xbe, + 0xb7, 0xa5, 0xe1, 0x13, 0xd9, 0xed, 0x24, 0xad, 0x34, 0x9, 0x4b, 0x1c, 0x95, 0xdd, 0x1d}; + uint8_t bytesprops0[] = {0x2, 0xc2, 0xc4, 0xa4, 0xd1, 0x40, 0x98, 0x0, 0xf8, 0x95, 0x61, 0x5, 0x4c}; + uint8_t bytesprops2[] = {0xb6}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0xb2, 0x4d, 0xa0, 0x50, 0x48, 0xb7, 0xf1, 0x95, 0x10, 0x90, 0x96, 0x79, 0xe9, 0x5, + 0xfd, 0xe9, 0x94, 0xe, 0x14, 0xd4, 0xde, 0x8, 0xf6, 0xb6, 0x14, 0xb, 0x47}; + uint8_t bytesprops5[] = {0x4c, 0xe0}; + uint8_t bytesprops6[] = {0x6, 0x82, 0x53, 0x13, 0x9f, 0x3e, 0xe8, 0x84, 0x33, + 0xaf, 0xb8, 0x95, 0xbf, 0xff, 0x78, 0x1, 0x15}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16912}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27960}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28292}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21077}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6419}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops0}, .v = {30, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23247}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25523}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27103}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11597}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31337}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 247}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x64, 0x90, 0x2c, 0x74, 0x81, 0x1c}; - uint8_t byteswillprops1[] = {0xc7, 0x96, 0xff, 0x75}; - uint8_t byteswillprops3[] = {0x5f, 0xd0, 0x8c, 0xff, 0x20, 0x45, 0x51, 0x99, 0x50}; - uint8_t byteswillprops2[] = {0xc0, 0xec, 0xf9, 0x68, 0x84, 0x4, 0x4e, 0xa4, 0xf7, 0xf0, 0x51, 0xe, 0x6a, 0x16, - 0x7b, 0x5c, 0xdc, 0x37, 0x66, 0xb0, 0xf6, 0x3, 0x20, 0x5b, 0x5e, 0x95, 0x69}; + uint8_t byteswillprops0[] = {0x11, 0xd2, 0xe4, 0x63, 0x2d, 0x48, 0xab, 0xe7, + 0xb7, 0x4d, 0x55, 0x16, 0xec, 0x2a, 0xf8}; + uint8_t byteswillprops2[] = {0x3, 0x4c, 0xca, 0x2a, 0x6c, 0xc9, 0x3f, 0x70, 0xf7, + 0xfa, 0xad, 0xd2, 0xa1, 0x23, 0x22, 0x52, 0x2, 0xd2}; + uint8_t byteswillprops1[] = {0xc3, 0x7, 0xfb, 0x45, 0x3d, 0x2f, 0xd6, 0x67, 0xde, 0xf9, 0xdd, 0xae, 0xe5, + 0x24, 0x77, 0x53, 0x6e, 0xd9, 0x2, 0xe5, 0x66, 0x93, 0xe5, 0x6c, 0x72}; + uint8_t byteswillprops3[] = {0x2b, 0x29, 0x98, 0xa4, 0xb1, 0x39, 0x76, 0xf5, 0x15, 0x99}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3290}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&byteswillprops0}}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {27, (char*)&byteswillprops2}, .v = {9, (char*)&byteswillprops3}}}}, + .value = {.pair = {.k = {25, (char*)&byteswillprops1}, .v = {18, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3571}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10940}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12523}}, }; - lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x86, 0x71, 0xa1, 0xec, 0xd9, 0x5c, 0xee, 0x33, 0x7a, 0x92, - 0xc, 0xba, 0xc6, 0xd3, 0x75, 0xfa, 0x5f, 0xd, 0xc2, 0x8d, - 0x74, 0x7e, 0xa8, 0x77, 0xe1, 0x74, 0xab, 0x87, 0x69, 0xe5}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa4, 0xfc, 0x4, 0xcb, 0xc5, 0xa6, 0xab, 0x42, 0xb1, 0x91, 0x14, 0xbe, 0x13, 0xcd, - 0x15, 0x8f, 0x9d, 0x1a, 0xb1, 0xf8, 0x15, 0x81, 0xde, 0x7f, 0x3e, 0x30, 0x48}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x36, 0x44, 0x89, 0xa7, 0x2c, 0x34, 0x83, 0x36, 0xa6, + 0x91, 0xc9, 0x95, 0x7c, 0xdd, 0x32, 0x69, 0xc0}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 176; - uint8_t client_id_bytes[] = {0xa4, 0xb5, 0xa6, 0x80, 0x72, 0x81, 0x1a, 0xb8, 0x72, 0x55, 0x62, 0x7a, - 0x4a, 0xb1, 0x57, 0x49, 0x55, 0x2b, 0x9e, 0x7f, 0x1, 0x15, 0xa4, 0xa9}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.keep_alive = 19508; + uint8_t client_id_bytes[] = {0x7c, 0xee, 0x3e}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa7, 0x56, 0x76}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xee}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x1f, 0x65, 0x66, 0x4d, 0x63, 0x59, 0xf5, 0x73}; - lwmqtt_string_t password = {8, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe0, 0xa7, 0xb2, 0x56, 0x62, 0x7e, 0xde, 0x10, 0xc0, 0x92, 0xc5, 0x85, 0x4c}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9002,163 +8977,263 @@ TEST(Connect5QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "g\164\GS\251\214\154t\217\140l\213\150&{\211\130", _password = Just -// "\187\ESC\201\164\156\195h\241\250v8\t\179\193\251[*\142", _lastWill = Nothing, _cleanSession = False, _keepAlive = -// 20540, _connID = "\255k\192]Rmr[\146o,\129", _properties = [PropRequestProblemInformation 43,PropServerReference -// "I\202\f=7\140\141\248\174\184G\141",PropTopicAliasMaximum 20363,PropUserProperty -// "c\182\241\t\ETXAs&\RS2\186\242\&3\STXQ\188\133/\a\138" "!\CAN\SUB\197h\176\168U",PropPayloadFormatIndicator -// 13,PropTopicAlias 10596,PropRetainAvailable 45,PropMessageExpiryInterval 2779,PropReceiveMaximum -// 32036,PropAuthenticationMethod "{",PropSessionExpiryInterval 22898,PropWillDelayInterval -// 3617,PropPayloadFormatIndicator 103]} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS0, _willTopic = "e\178\176 \SO\167T!\SOH\NAK;b\193\247\SUB\136\189\199\232", _willMsg = +// "\221}\161\196zS\178P*\152}\254\220\196\216\136\161\220\"\NAK", _willProps = [PropTopicAlias +// 16380,PropServerKeepAlive 6209,PropTopicAliasMaximum 29194,PropMessageExpiryInterval +// 2368,PropSharedSubscriptionAvailable 195,PropUserProperty "kQPG\NUL\228\229\249\156W\217\246\204;d\163\\" +// "n\DLE\225\169\DELI\STX>\SUB\211\248M\169l/p\172m\"",PropSubscriptionIdentifier 4,PropServerReference +// "\NULV\211\225\152A%",PropSubscriptionIdentifier 18,PropMessageExpiryInterval 14776,PropAssignedClientIdentifier +// "\NUL\255\152\137\144\229\186}{\213\173\227\152\131\249\219%!>\DC3\234kn",PropReceiveMaximum +// 26829,PropResponseInformation +// "H\"\255\170l\158\193\141\\\199\168n\STXg\252\197q\133\174W\203ov\131\174k\192\196\GS\167",PropResponseTopic +// "lEe\202\150\130%\146xf\212\255\f\233\&5U@\178\208\212\149\ACK\145@\202_b\241\ACK",PropSubscriptionIdentifier +// 22,PropSessionExpiryInterval 20393,PropAuthenticationMethod +// "\\\242k\155\215\150b\233Q+\217\196\165\166\138\ETX$\248",PropReasonString "nr~\SO\v\242*\199\193 \180"]}), +// _cleanSession = True, _keepAlive = 9446, _connID = +// "\146\132J\ENQ\144\192\ty\167>\184:C\152\133o\\1C\128\253\189]VH\210", _properties = [PropServerKeepAlive +// 15281,PropMessageExpiryInterval 321,PropAuthenticationData +// "\190!H7\224\152\SYNg4\164d2\208\255gR\134",PropRetainAvailable 111,PropServerKeepAlive +// 26493,PropRequestResponseInformation 29,PropAuthenticationMethod +// "\147\NUL>\US\145\&3\139\&8tE\CANV\232F\158\209\149\181\191\130\185\255\196c",PropMaximumQoS +// 44,PropSubscriptionIdentifier 11,PropContentType +// "P\EM\232\185\128:Rju\139a+\171\249hU\221W\DEL&[\178\164\238Cw\ETBn\157_",PropWildcardSubscriptionAvailable +// 71,PropWildcardSubscriptionAvailable 2,PropWillDelayInterval 5770,PropMaximumPacketSize 12405,PropAuthenticationData +// "\183\EOT\SO_\249\f\SO\148\\C\ACK\158\148\251\US\203\171Bu",PropAuthenticationData +// "$hlnO\140Pg\219k\FSPX,\234\DC3\128\166\253h\225\197\SUB\"\243\239\NUL\160",PropRetainAvailable +// 195,PropSessionExpiryInterval 28432,PropAuthenticationData +// "\ENQn\243\212\SOH>k!\151t\212\189\175\165\SYNV\233\ENQ\250\ETB\201\247\&3",PropMaximumQoS +// 223,PropSessionExpiryInterval 1570,PropTopicAliasMaximum 17694,PropSubscriptionIdentifierAvailable +// 230,PropWillDelayInterval 3740,PropSubscriptionIdentifierAvailable 101,PropServerReference +// "3\157\"Cg\215\196r",PropPayloadFormatIndicator 21,PropSubscriptionIdentifier 30,PropAuthenticationData +// "1\196D",PropMaximumPacketSize 9841]} TEST(Connect5QCTest, Encode21) { - uint8_t pkt[] = {0x10, 0x93, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x50, 0x3c, 0x54, 0x17, 0x2b, 0x1c, - 0x0, 0xc, 0x49, 0xca, 0xc, 0x3d, 0x37, 0x8c, 0x8d, 0xf8, 0xae, 0xb8, 0x47, 0x8d, 0x22, 0x4f, 0x8b, - 0x26, 0x0, 0x14, 0x63, 0xb6, 0xf1, 0x9, 0x3, 0x41, 0x73, 0x26, 0x1e, 0x32, 0xba, 0xf2, 0x33, 0x2, - 0x51, 0xbc, 0x85, 0x2f, 0x7, 0x8a, 0x0, 0x8, 0x21, 0x18, 0x1a, 0xc5, 0x68, 0xb0, 0xa8, 0x55, 0x1, - 0xd, 0x23, 0x29, 0x64, 0x25, 0x2d, 0x2, 0x0, 0x0, 0xa, 0xdb, 0x21, 0x7d, 0x24, 0x15, 0x0, 0x1, - 0x7b, 0x11, 0x0, 0x0, 0x59, 0x72, 0x18, 0x0, 0x0, 0xe, 0x21, 0x1, 0x67, 0x0, 0xc, 0xff, 0x6b, - 0xc0, 0x5d, 0x52, 0x6d, 0x72, 0x5b, 0x92, 0x6f, 0x2c, 0x81, 0x0, 0x10, 0x67, 0xa4, 0x1d, 0xfb, 0xd6, - 0x9a, 0x74, 0xd9, 0x8c, 0x6c, 0xd5, 0x96, 0x26, 0x7b, 0xd3, 0x82, 0x0, 0x12, 0xbb, 0x1b, 0xc9, 0xa4, - 0x9c, 0xc3, 0x68, 0xf1, 0xfa, 0x76, 0x38, 0x9, 0xb3, 0xc1, 0xfb, 0x5b, 0x2a, 0x8e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x49, 0xca, 0xc, 0x3d, 0x37, 0x8c, 0x8d, 0xf8, 0xae, 0xb8, 0x47, 0x8d}; - uint8_t bytesprops2[] = {0x21, 0x18, 0x1a, 0xc5, 0x68, 0xb0, 0xa8, 0x55}; - uint8_t bytesprops1[] = {0x63, 0xb6, 0xf1, 0x9, 0x3, 0x41, 0x73, 0x26, 0x1e, 0x32, - 0xba, 0xf2, 0x33, 0x2, 0x51, 0xbc, 0x85, 0x2f, 0x7, 0x8a}; - uint8_t bytesprops3[] = {0x7b}; + uint8_t pkt[] = { + 0x10, 0x9d, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6, 0x24, 0xe6, 0xf4, 0x1, 0x13, 0x3b, 0xb1, 0x2, + 0x0, 0x0, 0x1, 0x41, 0x16, 0x0, 0x11, 0xbe, 0x21, 0x48, 0x37, 0xe0, 0x98, 0x16, 0x67, 0x34, 0xa4, 0x64, 0x32, + 0xd0, 0xff,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, 0x57, 0xcb, + 0x6f, 0x76, 0x83, 0xae, 0x6b, 0xc0, 0xc4, 0x1d, 0xa7, 0x8, 0x0, 0x1d, 0x6c, 0x45, 0x65, 0xca, 0x96, 0x82, 0x25, + 0x92, 0x78, 0x66, 0xd4, 0xff, 0xc, 0xe9, 0x35, 0x55, 0x40, 0xb2, 0xd0, 0xd4, 0x95, 0x6, 0x91, 0x40, 0xca, 0x5f, + 0x62, 0xf1, 0x6, 0xb, 0x16, 0x11, 0x0, 0x0, 0x4f, 0xa9, 0x15, 0x0, 0x12, 0x5c, 0xf2, 0x6b, 0x9b, 0xd7, 0x96, + 0x62, 0xe9, 0x51, 0x2b, 0xd9, 0xc4, 0xa5, 0xa6, 0x8a, 0x3, 0x24, 0xf8, 0x1f, 0x0, 0xb, 0x6e, 0x72, 0x7e, 0xe, + 0xb, 0xf2, 0x2a, 0xc7, 0xc1, 0x20, 0xb4, 0x0, 0x13, 0x65, 0xb2, 0xb0, 0x20, 0xe, 0xa7, 0x54, 0x21, 0x1, 0x15, + 0x3b, 0x62, 0xc1, 0xf7, 0x1a, 0x88, 0xbd, 0xc7, 0xe8, 0x0, 0x14, 0xdd, 0x7d, 0xa1, 0xc4, 0x7a, 0x53, 0xb2, 0x50, + 0x2a, 0x98, 0x7d, 0xfe, 0xdc, 0xc4, 0xd8, 0x88, 0xa1, 0xdc, 0x22, 0x15}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbe, 0x21, 0x48, 0x37, 0xe0, 0x98, 0x16, 0x67, 0x34, + 0xa4, 0x64, 0x32, 0xd0, 0xff, 0x67, 0x52, 0x86}; + uint8_t bytesprops1[] = {0x93, 0x0, 0x3e, 0x1f, 0x91, 0x33, 0x8b, 0x38, 0x74, 0x45, 0x18, 0x56, + 0xe8, 0x46, 0x9e, 0xd1, 0x95, 0xb5, 0xbf, 0x82, 0xb9, 0xff, 0xc4, 0x63}; + uint8_t bytesprops2[] = {0x50, 0x19, 0xe8, 0xb9, 0x80, 0x3a, 0x52, 0x6a, 0x75, 0x8b, 0x61, 0x2b, 0xab, 0xf9, 0x68, + 0x55, 0xdd, 0x57, 0x7f, 0x26, 0x5b, 0xb2, 0xa4, 0xee, 0x43, 0x77, 0x17, 0x6e, 0x9d, 0x5f}; + uint8_t bytesprops3[] = {0xb7, 0x4, 0xe, 0x5f, 0xf9, 0xc, 0xe, 0x94, 0x5c, 0x43, + 0x6, 0x9e, 0x94, 0xfb, 0x1f, 0xcb, 0xab, 0x42, 0x75}; + uint8_t bytesprops4[] = {0x24, 0x68, 0x6c, 0x6e, 0x4f, 0x8c, 0x50, 0x67, 0xdb, 0x6b, 0x1c, 0x50, 0x58, 0x2c, + 0xea, 0x13, 0x80, 0xa6, 0xfd, 0x68, 0xe1, 0xc5, 0x1a, 0x22, 0xf3, 0xef, 0x0, 0xa0}; + uint8_t bytesprops5[] = {0x5, 0x6e, 0xf3, 0xd4, 0x1, 0x3e, 0x6b, 0x21, 0x97, 0x74, 0xd4, 0xbd, + 0xaf, 0xa5, 0x16, 0x56, 0xe9, 0x5, 0xfa, 0x17, 0xc9, 0xf7, 0x33}; + uint8_t bytesprops6[] = {0x33, 0x9d, 0x22, 0x43, 0x67, 0xd7, 0xc4, 0x72}; + uint8_t bytesprops7[] = {0x31, 0xc4, 0x44}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20363}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops1}, .v = {8, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10596}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2779}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32036}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22898}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3617}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15281}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 321}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26493}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5770}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12405}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28432}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1570}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17694}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3740}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9841}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x6e, 0x10, 0xe1, 0xa9, 0x7f, 0x49, 0x2, 0x3e, 0x1a, 0xd3, + 0xf8, 0x4d, 0xa9, 0x6c, 0x2f, 0x70, 0xac, 0x6d, 0x22}; + uint8_t byteswillprops0[] = {0x6b, 0x51, 0x50, 0x47, 0x0, 0xe4, 0xe5, 0xf9, 0x9c, + 0x57, 0xd9, 0xf6, 0xcc, 0x3b, 0x64, 0xa3, 0x5c}; + uint8_t byteswillprops2[] = {0x0, 0x56, 0xd3, 0xe1, 0x98, 0x41, 0x25}; + uint8_t byteswillprops3[] = {0x0, 0xff, 0x98, 0x89, 0x90, 0xe5, 0xba, 0x7d, 0x7b, 0xd5, 0xad, 0xe3, + 0x98, 0x83, 0xf9, 0xdb, 0x25, 0x21, 0x3e, 0x13, 0xea, 0x6b, 0x6e}; + uint8_t byteswillprops4[] = {0x48, 0x22, 0xff, 0xaa, 0x6c, 0x9e, 0xc1, 0x8d, 0x5c, 0xc7, + 0xa8, 0x6e, 0x2, 0x67, 0xfc, 0xc5, 0x71, 0x85, 0xae, 0x57, + 0xcb, 0x6f, 0x76, 0x83, 0xae, 0x6b, 0xc0, 0xc4, 0x1d, 0xa7}; + uint8_t byteswillprops5[] = {0x6c, 0x45, 0x65, 0xca, 0x96, 0x82, 0x25, 0x92, 0x78, 0x66, 0xd4, 0xff, 0xc, 0xe9, 0x35, + 0x55, 0x40, 0xb2, 0xd0, 0xd4, 0x95, 0x6, 0x91, 0x40, 0xca, 0x5f, 0x62, 0xf1, 0x6}; + uint8_t byteswillprops6[] = {0x5c, 0xf2, 0x6b, 0x9b, 0xd7, 0x96, 0x62, 0xe9, 0x51, + 0x2b, 0xd9, 0xc4, 0xa5, 0xa6, 0x8a, 0x3, 0x24, 0xf8}; + uint8_t byteswillprops7[] = {0x6e, 0x72, 0x7e, 0xe, 0xb, 0xf2, 0x2a, 0xc7, 0xc1, 0x20, 0xb4}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16380}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6209}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29194}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2368}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {17, (char*)&byteswillprops0}, .v = {19, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14776}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26829}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20393}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops7}}}, + }; + + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x65, 0xb2, 0xb0, 0x20, 0xe, 0xa7, 0x54, 0x21, 0x1, 0x15, + 0x3b, 0x62, 0xc1, 0xf7, 0x1a, 0x88, 0xbd, 0xc7, 0xe8}; + lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xdd, 0x7d, 0xa1, 0xc4, 0x7a, 0x53, 0xb2, 0x50, 0x2a, 0x98, + 0x7d, 0xfe, 0xdc, 0xc4, 0xd8, 0x88, 0xa1, 0xdc, 0x22, 0x15}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 20540; - uint8_t client_id_bytes[] = {0xff, 0x6b, 0xc0, 0x5d, 0x52, 0x6d, 0x72, 0x5b, 0x92, 0x6f, 0x2c, 0x81}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 9446; + uint8_t client_id_bytes[] = {0x92, 0x84, 0x4a, 0x5, 0x90, 0xc0, 0x9, 0x79, 0xa7, 0x3e, 0xb8, 0x3a, 0x43, + 0x98, 0x85, 0x6f, 0x5c, 0x31, 0x43, 0x80, 0xfd, 0xbd, 0x5d, 0x56, 0x48, 0xd2}; + lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x67, 0xa4, 0x1d, 0xfb, 0xd6, 0x9a, 0x74, 0xd9, - 0x8c, 0x6c, 0xd5, 0x96, 0x26, 0x7b, 0xd3, 0x82}; - lwmqtt_string_t username = {16, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xbb, 0x1b, 0xc9, 0xa4, 0x9c, 0xc3, 0x68, 0xf1, 0xfa, - 0x76, 0x38, 0x9, 0xb3, 0xc1, 0xfb, 0x5b, 0x2a, 0x8e}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; - opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\130\153\246\DLEX\252\184\254\209\234/\229\190\&1k\ENQ\DC1\DEL\186", _password = -// Just "\152\245\222\230\235\f!z\243\&9\224P\250\231\236#\205V", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS1, _willTopic = "\199\149\CAND\190\238\210\161\204\&8C\192\168'\162\198\250\r\142\&0\250", _willMsg = -// "OUI", _willProps = [PropSessionExpiryInterval 8278,PropAssignedClientIdentifier -// "@\190",PropWildcardSubscriptionAvailable 168,PropContentType -// "W/\174\153\144}\206<\184}\ENQ\ETX\ESC@\226\141",PropMessageExpiryInterval 9621,PropMaximumQoS -// 66,PropPayloadFormatIndicator 142,PropReceiveMaximum 25445,PropReceiveMaximum 6056]}), _cleanSession = False, -// _keepAlive = 63, _connID = "\FS\196\a\216\236\229ts[;\209\141\182\141\154#\226\&7H.\199\195\f-\159\183\252c\235", -// _properties = [PropCorrelationData -// "\163\162\179\168\DC1\147\221t\164)z*+\155\135\217\199\STX\DLE\178=\\Q\227\252",PropReasonString -// "b\239\ESC\144",PropTopicAliasMaximum 10076,PropTopicAlias 11906,PropWillDelayInterval -// 20739,PropRequestResponseInformation 233,PropResponseTopic "E\210k\223\184\ETX\ESC",PropServerKeepAlive -// 22113,PropPayloadFormatIndicator 2,PropServerReference "\192`\251\133\252'C^N\f7%"]} +// ConnectRequest {_username = Just "0\219\168\207u\209FQb\194\255\SYN:\216` ", _password = Just +// "\224\206\238\173\&1\157LS\135\STX\RSL\213\178A\184\&6\185\133\180r1\191O\169\153m\246O", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = "\210\254({", _willMsg = "Z\128\204\SOH\NUL\v%", _willProps = +// [PropResponseInformation "\152\&8\173\FSM*G\129w\204\184\247\224\STX\CANn\168\STX\173\227/u",PropReasonString +// "\233\146Y\178,\161\&2\ETB\179\220\200\243\162\SI[",PropTopicAliasMaximum 2888,PropTopicAliasMaximum +// 31004,PropSessionExpiryInterval 32704,PropReasonString " +// \250\210\140\217\149>\216\255\232\209I\171\180\US\239",PropMessageExpiryInterval 2234]}), _cleanSession = False, +// _keepAlive = 10802, _connID = "\229U\154\147\141\141XPP\181I\226\208\SYN", _properties = +// [PropRequestProblemInformation 180,PropAuthenticationData "w\144",PropRetainAvailable +// 254,PropSubscriptionIdentifierAvailable 147,PropAuthenticationData "\214\130\181",PropWildcardSubscriptionAvailable +// 225]} TEST(Connect5QCTest, Encode22) { - uint8_t pkt[] = { - 0x10, 0xec, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x0, 0x3f, 0x4e, 0x9, 0x0, 0x19, 0xa3, 0xa2, - 0xb3, 0xa8, 0x11, 0x93, 0xdd, 0x74, 0xa4, 0x29, 0x7a, 0x2a, 0x2b, 0x9b, 0x87, 0xd9, 0xc7, 0x2, 0x10, 0xb2, 0x3d, - 0x5c, 0x51, 0xe3, 0xfc, 0x1f, 0x0, 0x4, 0x62, 0xef, 0x1b, 0x90, 0x22, 0x27, 0x5c, 0x23, 0x2e, 0x82, 0x18, 0x0, - 0x0, 0x51, 0x3, 0x19, 0xe9, 0x8, 0x0, 0x7, 0x45, 0xd2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0xdd, 0x74, 0xa4, 0x29, 0x7a, 0x2a, 0x2b, - 0x9b, 0x87, 0xd9, 0xc7, 0x2, 0x10, 0xb2, 0x3d, 0x5c, 0x51, 0xe3, 0xfc}; - uint8_t bytesprops1[] = {0x62, 0xef, 0x1b, 0x90}; - uint8_t bytesprops2[] = {0x45, 0xd2, 0x6b, 0xdf, 0xb8, 0x3, 0x1b}; - uint8_t bytesprops3[] = {0xc0, 0x60, 0xfb, 0x85, 0xfc, 0x27, 0x43, 0x5e, 0x4e, 0xc, 0x37, 0x25}; + uint8_t pkt[] = {0x10, 0xbd, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x2a, 0x32, 0x13, 0x17, 0xb4, + 0x16, 0x0, 0x2, 0x77, 0x90, 0x25, 0xfe, 0x29, 0x93, 0x16, 0x0, 0x3, 0xd6, 0x82, 0xb5, 0x28, + 0xe1, 0x0, 0xe, 0xe5, 0x55, 0x9a, 0x93, 0x8d, 0x8d, 0x58, 0x50, 0x50, 0xb5, 0x49, 0xe2, 0xd0, + 0x16, 0x4e, 0x1a, 0x0, 0x16, 0x98, 0x38, 0xad, 0x1c, 0x4d, 0x2a, 0x47, 0x81, 0x77, 0xcc, 0xb8, + 0xf7, 0xe0, 0x2, 0x18, 0x6e, 0xa8, 0x2, 0xad, 0xe3, 0x2f, 0x75, 0x1f, 0x0, 0xf, 0xe9, 0x92, + 0x59, 0xb2, 0x2c, 0xa1, 0x32, 0x17, 0xb3, 0xdc, 0xc8, 0xf3, 0xa2, 0xf, 0x5b, 0x22, 0xb, 0x48, + 0x22, 0x79, 0x1c, 0x11, 0x0, 0x0, 0x7f, 0xc0, 0x1f, 0x0, 0x10, 0x20, 0xfa, 0xd2, 0x8c, 0xd9, + 0x95, 0x3e, 0xd8, 0xff, 0xe8, 0xd1, 0x49, 0xab, 0xb4, 0x1f, 0xef, 0x2, 0x0, 0x0, 0x8, 0xba, + 0x0, 0x4, 0xd2, 0xfe, 0x28, 0x7b, 0x0, 0x7, 0x5a, 0x80, 0xcc, 0x1, 0x0, 0xb, 0x25, 0x0, + 0x10, 0x30, 0xdb, 0xa8, 0xcf, 0x75, 0xd1, 0x46, 0x51, 0x62, 0xc2, 0xff, 0x16, 0x3a, 0xd8, 0x60, + 0x20, 0x0, 0x1d, 0xe0, 0xce, 0xee, 0xad, 0x31, 0x9d, 0x4c, 0x53, 0x87, 0x2, 0x1e, 0x4c, 0xd5, + 0xb2, 0x41, 0xb8, 0x36, 0xb9, 0x85, 0xb4, 0x72, 0x31, 0xbf, 0x4f, 0xa9, 0x99, 0x6d, 0xf6, 0x4f}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x77, 0x90}; + uint8_t bytesprops1[] = {0xd6, 0x82, 0xb5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10076}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11906}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20739}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22113}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 225}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x40, 0xbe}; - uint8_t byteswillprops1[] = {0x57, 0x2f, 0xae, 0x99, 0x90, 0x7d, 0xce, 0x3c, - 0xb8, 0x7d, 0x5, 0x3, 0x1b, 0x40, 0xe2, 0x8d}; + uint8_t byteswillprops0[] = {0x98, 0x38, 0xad, 0x1c, 0x4d, 0x2a, 0x47, 0x81, 0x77, 0xcc, 0xb8, + 0xf7, 0xe0, 0x2, 0x18, 0x6e, 0xa8, 0x2, 0xad, 0xe3, 0x2f, 0x75}; + uint8_t byteswillprops1[] = {0xe9, 0x92, 0x59, 0xb2, 0x2c, 0xa1, 0x32, 0x17, 0xb3, 0xdc, 0xc8, 0xf3, 0xa2, 0xf, 0x5b}; + uint8_t byteswillprops2[] = {0x20, 0xfa, 0xd2, 0x8c, 0xd9, 0x95, 0x3e, 0xd8, + 0xff, 0xe8, 0xd1, 0x49, 0xab, 0xb4, 0x1f, 0xef}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8278}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9621}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25445}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6056}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2888}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31004}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32704}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2234}}, }; - lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xc7, 0x95, 0x18, 0x44, 0xbe, 0xee, 0xd2, 0xa1, 0xcc, 0x38, 0x43, - 0xc0, 0xa8, 0x27, 0xa2, 0xc6, 0xfa, 0xd, 0x8e, 0x30, 0xfa}; - lwmqtt_string_t will_topic = {21, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4f, 0x55, 0x49}; - lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd2, 0xfe, 0x28, 0x7b}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5a, 0x80, 0xcc, 0x1, 0x0, 0xb, 0x25}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 63; - uint8_t client_id_bytes[] = {0x1c, 0xc4, 0x7, 0xd8, 0xec, 0xe5, 0x74, 0x73, 0x5b, 0x3b, 0xd1, 0x8d, 0xb6, 0x8d, 0x9a, - 0x23, 0xe2, 0x37, 0x48, 0x2e, 0xc7, 0xc3, 0xc, 0x2d, 0x9f, 0xb7, 0xfc, 0x63, 0xeb}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.keep_alive = 10802; + uint8_t client_id_bytes[] = {0xe5, 0x55, 0x9a, 0x93, 0x8d, 0x8d, 0x58, 0x50, 0x50, 0xb5, 0x49, 0xe2, 0xd0, 0x16}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x82, 0x99, 0xf6, 0x10, 0x58, 0xfc, 0xb8, 0xfe, 0xd1, 0xea, - 0x2f, 0xe5, 0xbe, 0x31, 0x6b, 0x5, 0x11, 0x7f, 0xba}; - lwmqtt_string_t username = {19, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x30, 0xdb, 0xa8, 0xcf, 0x75, 0xd1, 0x46, 0x51, + 0x62, 0xc2, 0xff, 0x16, 0x3a, 0xd8, 0x60, 0x20}; + lwmqtt_string_t username = {16, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x98, 0xf5, 0xde, 0xe6, 0xeb, 0xc, 0x21, 0x7a, 0xf3, - 0x39, 0xe0, 0x50, 0xfa, 0xe7, 0xec, 0x23, 0xcd, 0x56}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xe0, 0xce, 0xee, 0xad, 0x31, 0x9d, 0x4c, 0x53, 0x87, 0x2, 0x1e, 0x4c, 0xd5, 0xb2, 0x41, + 0xb8, 0x36, 0xb9, 0x85, 0xb4, 0x72, 0x31, 0xbf, 0x4f, 0xa9, 0x99, 0x6d, 0xf6, 0x4f}; + lwmqtt_string_t password = {29, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9168,158 +9243,190 @@ TEST(Connect5QCTest, Encode22) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "\RS\167\162\&6\154\242\173\187\159\228M\149\143\133]\FS%\242\219\239\232\172\&7\STX\236\&3\229", _password = Just -// "\223\143\v\237\t/\227\FS\210\243\130\206\v\180\r", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, -// _willTopic = " \SI\153\ACK\213(Df\150\253\194\171\158r\205\203cW", _willMsg = -// "\221\140d\205\238w\156m\218w\195\&4\189\&2\208\177", _willProps = [PropWillDelayInterval 7312,PropReceiveMaximum -// 683,PropMessageExpiryInterval 21868,PropSubscriptionIdentifierAvailable 164,PropSubscriptionIdentifierAvailable -// 180,PropSessionExpiryInterval 19875,PropSessionExpiryInterval 327,PropSubscriptionIdentifierAvailable -// 94,PropAuthenticationData -// "\196\NAK\154z\173\129\&9\236\149\223\221<\245}\EOT\n\253\241u\207i2\219",PropReceiveMaximum -// 22731,PropPayloadFormatIndicator 106,PropResponseInformation "x\181\225\ETB\251\221\201",PropTopicAlias 29475]}), -// _cleanSession = False, _keepAlive = 32455, _connID = "\199f\232=\172\DEL\148R>\167\\X;\235 \DC1\189\173\203WE\245", -// _properties = [PropContentType "\SO8\239\215\140\202\DC2\140?\NUL\234HpZ\219\194l7.",PropUserProperty -// "\224\179\143\232\132\227\SUB\ACKh\ETX\253a" "\208\237\&1\193\209g\194L$\236s\250V",PropMaximumQoS -// 18,PropResponseInformation -// "\186M\202\135\&2\195\246\247\156\146\223E\137\160\200t\DLE+m\168\STX;\SI",PropSessionExpiryInterval -// 2421,PropSessionExpiryInterval 4930,PropSubscriptionIdentifier 3,PropResponseTopic "\STX",PropRetainAvailable -// 150,PropPayloadFormatIndicator 121,PropAssignedClientIdentifier -// "\206\&3\146\188\170\207\&2Z\f\148\193\SUB\236",PropRequestProblemInformation 183,PropReceiveMaximum -// 31082,PropContentType "\217\190\177\228\166\r%(c\137\165\&2u]\218\189 s_\132\a\GS",PropResponseInformation -// "s\153\167\SOAm\231\&1\128\234\SYN\246",PropReasonString "iC\\\EM6",PropMessageExpiryInterval -// 16797,PropMaximumPacketSize 28375,PropAuthenticationData -// "A\201\DC2\204q\197\SUBfA\219\211U\174\242\rX\254\218D\ETX\188\153\198\228\ETB",PropSubscriptionIdentifier -// 11,PropRequestResponseInformation 189,PropReasonString -// "~q\175\135\223\\A\251\248\172\174\&5Z\EOTa\r(\160\253\239\NAK\226\149vnr\141",PropRequestProblemInformation -// 139,PropSubscriptionIdentifierAvailable 124,PropSubscriptionIdentifierAvailable 38,PropMaximumPacketSize -// 30907,PropWillDelayInterval 3971,PropSubscriptionIdentifier 3,PropReasonString "\163\205"]} +// ConnectRequest {_username = Nothing, _password = Just "\159V\EOT\ENQR\a\169J\EOT", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\SI\SO", _willMsg = "\SUB{\SO\EM\190", _willProps = +// [PropWillDelayInterval 5775,PropResponseTopic +// "\140\225i)\252N\183\&5\199\SOH\140\234\131\v;\SOH?\DEL\174k\252Ec\US&\EOT|y\178\r",PropTopicAlias +// 30510,PropReceiveMaximum 21817,PropAuthenticationMethod +// "\203\131\189\214\DC37\DEL\212cm,\254\173\168\RS\185",PropRequestResponseInformation 44,PropServerReference +// "\200\225-\175\171\&7\v\ENQ\226\209\&5\195CL:\163)g\ENQ\181\135\CANqM",PropTopicAlias 24660,PropAuthenticationData +// "rR\237\185\200\186\207\EOT\166f\184\193d\v\GS\\\US#;\238N\172\142\175\198\240",PropMessageExpiryInterval +// 20356,PropSubscriptionIdentifier 18,PropSessionExpiryInterval 11181,PropReceiveMaximum +// 3137,PropRequestResponseInformation 79,PropSessionExpiryInterval 6595,PropAuthenticationData +// ")n\183vS\DC2m\248\ACK`]\251J2\180\175\132,X",PropWildcardSubscriptionAvailable 98,PropWillDelayInterval +// 5996,PropMaximumQoS 190,PropRetainAvailable 40,PropAuthenticationData "",PropAuthenticationData +// "\ESC\STX{\vt\142u\254\161\141Cii\t\217\171`\212\&0\230G",PropSubscriptionIdentifier 4,PropMessageExpiryInterval +// 23967,PropPayloadFormatIndicator 96,PropSubscriptionIdentifier 26,PropServerReference +// "Q$Z\ACK\179\240\155\200\192\204\246x\140\139\ESC",PropRetainAvailable 57,PropMaximumPacketSize 32201]}), +// _cleanSession = True, _keepAlive = 3695, _connID = "V\159\161\231\237\200\154\134\206X\143", _properties = +// [PropAuthenticationMethod "c\143pZf\163]\251gI9S5-O\128l]\v}\249\174o",PropServerKeepAlive +// 9332,PropSubscriptionIdentifier 11,PropMessageExpiryInterval 1769,PropRequestResponseInformation 244,PropUserProperty +// "`\183z(\192\160\144Y=>w8{\136,\183\248\181,\233\247w\252+\ESC\250\203\t\139" +// "\138\218\139z\246@\n\161\244\SOHJ\232\235\DC1\220xX\\?\213\166\DLE\140r\150p",PropResponseInformation +// "\220\147tPcV\NAK\212\f\158\157s\156(\128",PropSessionExpiryInterval 28700,PropSubscriptionIdentifier +// 17,PropCorrelationData "\SICy",PropResponseInformation +// "\NUL\230\136@\146\247\150P*\172\153/\254\174\STX\191",PropReasonString +// "2\163\DC3\220Q\217\133Kg&\163\DC4\254\155;?;\168M[\b-\237z.\FS\249\DC3\202\SI",PropRequestProblemInformation +// 181,PropServerKeepAlive 3262,PropAuthenticationData "$\b\235\EM",PropCorrelationData +// "\184\131\245e\n:\DC3\238",PropTopicAlias 25579,PropUserProperty "\ETX\EOT\167\US\248\139\fB\173" +// "\183\186\&1l\FS\195;\167",PropAssignedClientIdentifier +// "\DC48#GK=,\"\234\253\128\205\177\222\255\195e\173",PropCorrelationData +// "G\173\255m\161\184\247\171T\"a\132",PropTopicAlias 31936,PropUserProperty +// "|\211\196|\176\192\&2\247\156!!L\RS\250\SO" "",PropMessageExpiryInterval 12658,PropRetainAvailable +// 205,PropPayloadFormatIndicator 53]} TEST(Connect5QCTest, Encode23) { uint8_t pkt[] = { - 0x10, 0xca, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x7e, 0xc7, 0x88, 0x2, 0x3, 0x0, 0x13, 0xe, - 0x38, 0xef, 0xd7, 0x8c, 0xca, 0x12, 0x8c, 0x3f, 0x0, 0xea, 0x48, 0x70, 0x5a, 0xdb,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34, 0xbd, 0x32, 0xd0, 0xb1, 0x0, 0x1b, 0x1e, - 0xa7, 0xa2, 0x36, 0x9a, 0xf2, 0xad, 0xbb, 0x9f, 0xe4, 0x4d, 0x95, 0x8f, 0x85, 0x5d, 0x1c, 0x25, 0xf2, 0xdb, 0xef, - 0xe8, 0xac, 0x37, 0x2, 0xec, 0x33, 0xe5, 0x0, 0xf, 0xdf, 0x8f, 0xb, 0xed, 0x9, 0x2f, 0xe3, 0x1c, 0xd2, 0xf3, - 0x82, 0xce, 0xb, 0xb4, 0xd}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe, 0x38, 0xef, 0xd7, 0x8c, 0xca, 0x12, 0x8c, 0x3f, 0x0, - 0xea, 0x48, 0x70, 0x5a, 0xdb, 0xc2, 0x6c, 0x37, 0x2e}; - uint8_t bytesprops2[] = {0xd0, 0xed, 0x31, 0xc1, 0xd1, 0x67, 0xc2, 0x4c, 0x24, 0xec, 0x73, 0xfa, 0x56}; - uint8_t bytesprops1[] = {0xe0, 0xb3, 0x8f, 0xe8, 0x84, 0xe3, 0x1a, 0x6, 0x68, 0x3, 0xfd, 0x61}; - uint8_t bytesprops3[] = {0xba, 0x4d, 0xca, 0x87, 0x32, 0xc3, 0xf6, 0xf7, 0x9c, 0x92, 0xdf, 0x45, - 0x89, 0xa0, 0xc8, 0x74, 0x10, 0x2b, 0x6d, 0xa8, 0x2, 0x3b, 0xf}; - uint8_t bytesprops4[] = {0x2}; - uint8_t bytesprops5[] = {0xce, 0x33, 0x92, 0xbc, 0xaa, 0xcf, 0x32, 0x5a, 0xc, 0x94, 0xc1, 0x1a, 0xec}; - uint8_t bytesprops6[] = {0xd9, 0xbe, 0xb1, 0xe4, 0xa6, 0xd, 0x25, 0x28, 0x63, 0x89, 0xa5, - 0x32, 0x75, 0x5d, 0xda, 0xbd, 0x20, 0x73, 0x5f, 0x84, 0x7, 0x1d}; - uint8_t bytesprops7[] = {0x73, 0x99, 0xa7, 0xe, 0x41, 0x6d, 0xe7, 0x31, 0x80, 0xea, 0x16, 0xf6}; - uint8_t bytesprops8[] = {0x69, 0x43, 0x5c, 0x19, 0x36}; - uint8_t bytesprops9[] = {0x41, 0xc9, 0x12, 0xcc, 0x71, 0xc5, 0x1a, 0x66, 0x41, 0xdb, 0xd3, 0x55, 0xae, - 0xf2, 0xd, 0x58, 0xfe, 0xda, 0x44, 0x3, 0xbc, 0x99, 0xc6, 0xe4, 0x17}; - uint8_t bytesprops10[] = {0x7e, 0x71, 0xaf, 0x87, 0xdf, 0x5c, 0x41, 0xfb, 0xf8, 0xac, 0xae, 0x35, 0x5a, 0x4, - 0x61, 0xd, 0x28, 0xa0, 0xfd, 0xef, 0x15, 0xe2, 0x95, 0x76, 0x6e, 0x72, 0x8d}; - uint8_t bytesprops11[] = {0xa3, 0xcd}; + 0x10, 0xcc, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x4e, 0xe, 0x6f, 0xa9, 0x2, 0x15, 0x0, 0x17, 0x63, + 0x8f, 0x70, 0x5a, 0x66, 0xa3, 0x5d, 0xfb, 0x67, 0x49, 0x39, 0x53, 0x35, 0x2d, 0x4f, 0x80, 0x6c, 0x5d, 0xb, 0x7d, + 0xf9, 0xae, 0x6f, 0x13, 0x24, 0x74, 0xb, 0xb, 0x2, 0x0, 0x0, 0x6, 0xe9, 0x19, 0xf4, 0x26, 0x0, 0x1d, 0x60, + 0xb7, 0x7a, 0x28, 0xc0, 0xa0, 0x90, 0x59, 0x3d, 0x3e, 0x77, 0x38, 0x7b, 0x88, 0x2c, 0xb7, 0xf8, 0xb5, 0x2c, 0xe9, + 0xf7, 0x77, 0xfc, 0x2b, 0x1b, 0xfa, 0xcb, 0x9, 0x8b, 0x0, 0x1a, 0x8a, 0xda, 0x8b, 0x7a, 0xf6, 0x40, 0xa, 0xa1, + 0xf4, 0x1, 0x4a, 0xe8, 0xeb, 0x11, 0xdc, 0x78, 0x58, 0x5c, 0x3f, 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12, 0x6d, 0xf8, 0x6, 0x60, 0x5d, 0xfb, 0x4a, 0x32, 0xb4, 0xaf, 0x84, 0x2c, + 0x58, 0x28, 0x62, 0x18, 0x0, 0x0, 0x17, 0x6c, 0x24, 0xbe, 0x25, 0x28, 0x16, 0x0, 0x0, 0x16, 0x0, 0x15, 0x1b, + 0x2, 0x7b, 0xb, 0x74, 0x8e, 0x75, 0xfe, 0xa1, 0x8d, 0x43, 0x69, 0x69, 0x9, 0xd9, 0xab, 0x60, 0xd4, 0x30, 0xe6, + 0x47, 0xb, 0x4, 0x2, 0x0, 0x0, 0x5d, 0x9f, 0x1, 0x60, 0xb, 0x1a, 0x1c, 0x0, 0xf, 0x51, 0x24, 0x5a, 0x6, + 0xb3, 0xf0, 0x9b, 0xc8, 0xc0, 0xcc, 0xf6, 0x78, 0x8c, 0x8b, 0x1b, 0x25, 0x39, 0x27, 0x0, 0x0, 0x7d, 0xc9, 0x0, + 0x2, 0xf, 0xe, 0x0, 0x5, 0x1a, 0x7b, 0xe, 0x19, 0xbe, 0x0, 0x9, 0x9f, 0x56, 0x4, 0x5, 0x52, 0x7, 0xa9, + 0x4a, 0x4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x63, 0x8f, 0x70, 0x5a, 0x66, 0xa3, 0x5d, 0xfb, 0x67, 0x49, 0x39, 0x53, + 0x35, 0x2d, 0x4f, 0x80, 0x6c, 0x5d, 0xb, 0x7d, 0xf9, 0xae, 0x6f}; + uint8_t bytesprops2[] = {0x8a, 0xda, 0x8b, 0x7a, 0xf6, 0x40, 0xa, 0xa1, 0xf4, 0x1, 0x4a, 0xe8, 0xeb, + 0x11, 0xdc, 0x78, 0x58, 0x5c, 0x3f, 0xd5, 0xa6, 0x10, 0x8c, 0x72, 0x96, 0x70}; + uint8_t bytesprops1[] = {0x60, 0xb7, 0x7a, 0x28, 0xc0, 0xa0, 0x90, 0x59, 0x3d, 0x3e, 0x77, 0x38, 0x7b, 0x88, 0x2c, + 0xb7, 0xf8, 0xb5, 0x2c, 0xe9, 0xf7, 0x77, 0xfc, 0x2b, 0x1b, 0xfa, 0xcb, 0x9, 0x8b}; + uint8_t bytesprops3[] = {0xdc, 0x93, 0x74, 0x50, 0x63, 0x56, 0x15, 0xd4, 0xc, 0x9e, 0x9d, 0x73, 0x9c, 0x28, 0x80}; + uint8_t bytesprops4[] = {0xf, 0x43, 0x79}; + uint8_t bytesprops5[] = {0x0, 0xe6, 0x88, 0x40, 0x92, 0xf7, 0x96, 0x50, + 0x2a, 0xac, 0x99, 0x2f, 0xfe, 0xae, 0x2, 0xbf}; + uint8_t bytesprops6[] = {0x32, 0xa3, 0x13, 0xdc, 0x51, 0xd9, 0x85, 0x4b, 0x67, 0x26, 0xa3, 0x14, 0xfe, 0x9b, 0x3b, + 0x3f, 0x3b, 0xa8, 0x4d, 0x5b, 0x8, 0x2d, 0xed, 0x7a, 0x2e, 0x1c, 0xf9, 0x13, 0xca, 0xf}; + uint8_t bytesprops7[] = {0x24, 0x8, 0xeb, 0x19}; + uint8_t bytesprops8[] = {0xb8, 0x83, 0xf5, 0x65, 0xa, 0x3a, 0x13, 0xee}; + uint8_t bytesprops10[] = {0xb7, 0xba, 0x31, 0x6c, 0x1c, 0xc3, 0x3b, 0xa7}; + uint8_t bytesprops9[] = {0x3, 0x4, 0xa7, 0x1f, 0xf8, 0x8b, 0xc, 0x42, 0xad}; + uint8_t bytesprops11[] = {0x14, 0x38, 0x23, 0x47, 0x4b, 0x3d, 0x2c, 0x22, 0xea, + 0xfd, 0x80, 0xcd, 0xb1, 0xde, 0xff, 0xc3, 0x65, 0xad}; + uint8_t bytesprops12[] = {0x47, 0xad, 0xff, 0x6d, 0xa1, 0xb8, 0xf7, 0xab, 0x54, 0x22, 0x61, 0x84}; + uint8_t bytesprops14[] = {0}; + uint8_t bytesprops13[] = {0x7c, 0xd3, 0xc4, 0x7c, 0xb0, 0xc0, 0x32, 0xf7, 0x9c, 0x21, 0x21, 0x4c, 0x1e, 0xfa, 0xe}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops1}, .v = {13, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2421}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4930}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31082}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16797}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28375}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9332}}, {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30907}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3971}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1769}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {26, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28700}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3262}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25579}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops9}, .v = {8, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31936}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops13}, .v = {0, (char*)&bytesprops14}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12658}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 53}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc4, 0x15, 0x9a, 0x7a, 0xad, 0x81, 0x39, 0xec, 0x95, 0xdf, 0xdd, 0x3c, - 0xf5, 0x7d, 0x4, 0xa, 0xfd, 0xf1, 0x75, 0xcf, 0x69, 0x32, 0xdb}; - uint8_t byteswillprops1[] = {0x78, 0xb5, 0xe1, 0x17, 0xfb, 0xdd, 0xc9}; + uint8_t byteswillprops0[] = {0x8c, 0xe1, 0x69, 0x29, 0xfc, 0x4e, 0xb7, 0x35, 0xc7, 0x1, 0x8c, 0xea, 0x83, 0xb, 0x3b, + 0x1, 0x3f, 0x7f, 0xae, 0x6b, 0xfc, 0x45, 0x63, 0x1f, 0x26, 0x4, 0x7c, 0x79, 0xb2, 0xd}; + uint8_t byteswillprops1[] = {0xcb, 0x83, 0xbd, 0xd6, 0x13, 0x37, 0x7f, 0xd4, + 0x63, 0x6d, 0x2c, 0xfe, 0xad, 0xa8, 0x1e, 0xb9}; + uint8_t byteswillprops2[] = {0xc8, 0xe1, 0x2d, 0xaf, 0xab, 0x37, 0xb, 0x5, 0xe2, 0xd1, 0x35, 0xc3, + 0x43, 0x4c, 0x3a, 0xa3, 0x29, 0x67, 0x5, 0xb5, 0x87, 0x18, 0x71, 0x4d}; + uint8_t byteswillprops3[] = {0x72, 0x52, 0xed, 0xb9, 0xc8, 0xba, 0xcf, 0x4, 0xa6, 0x66, 0xb8, 0xc1, 0x64, + 0xb, 0x1d, 0x5c, 0x1f, 0x23, 0x3b, 0xee, 0x4e, 0xac, 0x8e, 0xaf, 0xc6, 0xf0}; + uint8_t byteswillprops4[] = {0x29, 0x6e, 0xb7, 0x76, 0x53, 0x12, 0x6d, 0xf8, 0x6, 0x60, + 0x5d, 0xfb, 0x4a, 0x32, 0xb4, 0xaf, 0x84, 0x2c, 0x58}; + uint8_t byteswillprops5[] = {0}; + uint8_t byteswillprops6[] = {0x1b, 0x2, 0x7b, 0xb, 0x74, 0x8e, 0x75, 0xfe, 0xa1, 0x8d, 0x43, + 0x69, 0x69, 0x9, 0xd9, 0xab, 0x60, 0xd4, 0x30, 0xe6, 0x47}; + uint8_t byteswillprops7[] = {0x51, 0x24, 0x5a, 0x6, 0xb3, 0xf0, 0x9b, 0xc8, 0xc0, 0xcc, 0xf6, 0x78, 0x8c, 0x8b, 0x1b}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7312}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 683}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21868}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19875}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 327}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22731}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29475}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5775}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30510}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21817}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24660}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20356}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11181}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3137}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6595}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5996}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23967}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32201}}, }; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x20, 0xf, 0x99, 0x6, 0xd5, 0x28, 0x44, 0x66, 0x96, - 0xfd, 0xc2, 0xab, 0x9e, 0x72, 0xcd, 0xcb, 0x63, 0x57}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xdd, 0x8c, 0x64, 0xcd, 0xee, 0x77, 0x9c, 0x6d, - 0xda, 0x77, 0xc3, 0x34, 0xbd, 0x32, 0xd0, 0xb1}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xf, 0xe}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x1a, 0x7b, 0xe, 0x19, 0xbe}; + lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 32455; - uint8_t client_id_bytes[] = {0xc7, 0x66, 0xe8, 0x3d, 0xac, 0x7f, 0x94, 0x52, 0x3e, 0xa7, 0x5c, - 0x58, 0x3b, 0xeb, 0x20, 0x11, 0xbd, 0xad, 0xcb, 0x57, 0x45, 0xf5}; - lwmqtt_string_t client_id = {22, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 3695; + uint8_t client_id_bytes[] = {0x56, 0x9f, 0xa1, 0xe7, 0xed, 0xc8, 0x9a, 0x86, 0xce, 0x58, 0x8f}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x1e, 0xa7, 0xa2, 0x36, 0x9a, 0xf2, 0xad, 0xbb, 0x9f, 0xe4, 0x4d, 0x95, 0x8f, 0x85, - 0x5d, 0x1c, 0x25, 0xf2, 0xdb, 0xef, 0xe8, 0xac, 0x37, 0x2, 0xec, 0x33, 0xe5}; - lwmqtt_string_t username = {27, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xdf, 0x8f, 0xb, 0xed, 0x9, 0x2f, 0xe3, 0x1c, 0xd2, 0xf3, 0x82, 0xce, 0xb, 0xb4, 0xd}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x9f, 0x56, 0x4, 0x5, 0x52, 0x7, 0xa9, 0x4a, 0x4}; + lwmqtt_string_t password = {9, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9329,231 +9436,191 @@ TEST(Connect5QCTest, Encode23) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = -// 14647, _connID = "\173\255n}\129\NAK", _properties = [PropContentType "V\175tC\FS", _willMsg = +// "\242\166\\\SYN\191\r\DC2d8\129\239\138\135\230\214]\CAN#K\206\USb%R\215\254\242\255\GS\139", _willProps = +// [PropMessageExpiryInterval 10172,PropServerKeepAlive 6438,PropWildcardSubscriptionAvailable 190,PropResponseTopic +// "",PropMessageExpiryInterval 30408,PropMessageExpiryInterval 16984,PropRetainAvailable +// 240,PropSubscriptionIdentifierAvailable 176,PropAssignedClientIdentifier "[\228\138d\USq\v\FS\172",PropReceiveMaximum +// 14049,PropMaximumQoS 252,PropContentType "\252",PropServerKeepAlive 31013]}), _cleanSession = True, _keepAlive = +// 21935, _connID = "", _properties = [PropUserProperty "\169\176\198\202\133\GS\188\USq\SYN\194\135\249\187J" +// "\211\224S;\229\176ID\210\168\US\185Mo\241\137\144\153\143\203\250\ETXW\251",PropTopicAliasMaximum +// 23665,PropServerReference "\SUB\DC1\253\168\&7\NAK'&\186\137\215\158O\229b9",PropSessionExpiryInterval 15033]} TEST(Connect5QCTest, Encode24) { - uint8_t pkt[] = { - 0x10, 0xf1, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2, 0x39, 0x37, 0xdd, 0x1, 0x3, 0x0, 0x9, 0x56, - 0xaf, 0x74, 0x3c, 0x59, 0xfb, 0xba, 0xd8, 0x93, 0x1c, 0x0, 0x4, 0x26, 0x43, 0xc1, 0x33, 0x1, 0xbe, 0x22, 0x25, - 0x28, 0x9, 0x0, 0x15, 0xa5, 0x72, 0xe5, 0x6e, 0x17, 0xae, 0x8e, 0x80, 0x14, 0x2b, 0xff, 0x5f, 0xd0, 0xc7, 0x39, - 0xf3, 0x62, 0xbb, 0xe2, 0x56, 0x79, 0x2a, 0x49, 0x3, 0x0, 0x4, 0x9c, 0x9c, 0xa2, 0x78, 0x26, 0x0, 0x9, 0x94, - 0xd5, 0xf7, 0x8c, 0x88, 0x8b, 0xb6, 0xf1, 0xb1, 0x0, 0x14, 0x8e, 0x45, 0xd8, 0x63, 0x5, 0x45, 0xcb, 0xa6, 0x77, - 0x74, 0x26, 0xb9, 0x6, 0x56, 0xae, 0x2d, 0xee, 0xbd, 0x69, 0xe2, 0x1a, 0x0, 0x14, 0xf8, 0x59, 0x1d, 0x13, 0xbe, - 0x2, 0x85, 0x3, 0xf3, 0x70, 0x84, 0xcc, 0xf7, 0xe5, 0xf3, 0xdf, 0x41, 0xda, 0x23, 0x36, 0x16, 0x0, 0x6, 0x6a, - 0x5a, 0xd9, 0xf9, 0x16, 0xc6, 0x22, 0x1a, 0xf9, 0x3, 0x0, 0x15, 0x5c, 0xa5, 0xe5, 0xe, 0x8a, 0x14, 0x73, 0x2, - 0xe8, 0xa, 0xda, 0xd9, 0xff, 0x60, 0x2d, 0xe1, 0x34, 0xc7, 0x77, 0xdb, 0x29, 0x23, 0x26, 0x7d, 0x17, 0x91, 0x25, - 0x9a, 0x2, 0x0, 0x0, 0x7d, 0x9e, 0x16, 0x0, 0x0, 0x26, 0x0, 0x6, 0x2a, 0x9e, 0x8f, 0xc0, 0x62, 0x63, 0x0, - 0x7, 0x4a, 0x52, 0xb8, 0x3a, 0x5, 0x11, 0xc3, 0x12, 0x0, 0x13, 0x26, 0x55, 0x23, 0xed, 0x52, 0x9c, 0x64, 0x57, - 0x48, 0x33, 0x17, 0x95, 0x51, 0x7b, 0xc0, 0x9d, 0x41, 0x9f, 0x9c, 0x1, 0x6a, 0x21, 0x18, 0x44, 0x13, 0x59, 0xf4, - 0x16, 0x0, 0x5, 0xc3, 0x8a, 0xd8, 0xf0, 0x62, 0x0, 0x6, 0xad, 0xff, 0x6e, 0x7d, 0x81, 0x15}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x56, 0xaf, 0x74, 0x3c, 0x59, 0xfb, 0xba, 0xd8, 0x93}; - uint8_t bytesprops1[] = {0x26, 0x43, 0xc1, 0x33}; - uint8_t bytesprops2[] = {0xa5, 0x72, 0xe5, 0x6e, 0x17, 0xae, 0x8e, 0x80, 0x14, 0x2b, 0xff, - 0x5f, 0xd0, 0xc7, 0x39, 0xf3, 0x62, 0xbb, 0xe2, 0x56, 0x79}; - uint8_t bytesprops3[] = {0x9c, 0x9c, 0xa2, 0x78}; - uint8_t bytesprops5[] = {0x8e, 0x45, 0xd8, 0x63, 0x5, 0x45, 0xcb, 0xa6, 0x77, 0x74, - 0x26, 0xb9, 0x6, 0x56, 0xae, 0x2d, 0xee, 0xbd, 0x69, 0xe2}; - uint8_t bytesprops4[] = {0x94, 0xd5, 0xf7, 0x8c, 0x88, 0x8b, 0xb6, 0xf1, 0xb1}; - uint8_t bytesprops6[] = {0xf8, 0x59, 0x1d, 0x13, 0xbe, 0x2, 0x85, 0x3, 0xf3, 0x70, - 0x84, 0xcc, 0xf7, 0xe5, 0xf3, 0xdf, 0x41, 0xda, 0x23, 0x36}; - uint8_t bytesprops7[] = {0x6a, 0x5a, 0xd9, 0xf9, 0x16, 0xc6}; - uint8_t bytesprops8[] = {0x5c, 0xa5, 0xe5, 0xe, 0x8a, 0x14, 0x73, 0x2, 0xe8, 0xa, 0xda, - 0xd9, 0xff, 0x60, 0x2d, 0xe1, 0x34, 0xc7, 0x77, 0xdb, 0x29}; - uint8_t bytesprops9[] = {0}; - uint8_t bytesprops11[] = {0x4a, 0x52, 0xb8, 0x3a, 0x5, 0x11, 0xc3}; - uint8_t bytesprops10[] = {0x2a, 0x9e, 0x8f, 0xc0, 0x62, 0x63}; - uint8_t bytesprops12[] = {0x26, 0x55, 0x23, 0xed, 0x52, 0x9c, 0x64, 0x57, 0x48, 0x33, - 0x17, 0x95, 0x51, 0x7b, 0xc0, 0x9d, 0x41, 0x9f, 0x9c}; - uint8_t bytesprops13[] = {0xc3, 0x8a, 0xd8, 0xf0, 0x62}; + uint8_t pkt[] = {0x10, 0xd4, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x55, 0xaf, 0x47, 0x26, 0x0, 0xf, + 0xa9, 0xb0, 0xc6, 0xca, 0x85, 0x1d, 0xbc, 0x1f, 0x71, 0x16, 0xc2, 0x87, 0xf9, 0xbb, 0x4a, 0x0, 0x18, + 0xd3, 0xe0, 0x53, 0x3b, 0xe5, 0xb0, 0x49, 0x44, 0xd2, 0xa8, 0x1f, 0xb9, 0x4d, 0x6f, 0xf1, 0x89, 0x90, + 0x99, 0x8f, 0xcb, 0xfa, 0x3, 0x57, 0xfb, 0x22, 0x5c, 0x71, 0x1c, 0x0, 0x10, 0x1a, 0x11, 0xfd, 0xa8, + 0x37, 0x15, 0x27, 0x26, 0xba, 0x89, 0xd7, 0x9e, 0x4f, 0xe5, 0x62, 0x39, 0x11, 0x0, 0x0, 0x3a, 0xb9, + 0x0, 0x0, 0x33, 0x2, 0x0, 0x0, 0x27, 0xbc, 0x13, 0x19, 0x26, 0x28, 0xbe, 0x8, 0x0, 0x0, 0x2, + 0x0, 0x0, 0x76, 0xc8, 0x2, 0x0, 0x0, 0x42, 0x58, 0x25, 0xf0, 0x29, 0xb0, 0x12, 0x0, 0x9, 0x5b, + 0xe4, 0x8a, 0x64, 0x1f, 0x71, 0xb, 0x1c, 0xac, 0x21, 0x36, 0xe1, 0x24, 0xfc, 0x3, 0x0, 0x1, 0xfc, + 0x13, 0x79, 0x25, 0x0, 0x16, 0x10, 0x9d, 0xe7, 0xcf, 0xb0, 0x24, 0x44, 0xcd, 0xf6, 0x63, 0x6a, 0x8b, + 0xd4, 0x97, 0xed, 0xb5, 0xe1, 0xc6, 0xb6, 0x3e, 0x43, 0x1c, 0x0, 0x1e, 0xf2, 0xa6, 0x5c, 0x16, 0xbf, + 0xd, 0x12, 0x64, 0x38, 0x81, 0xef, 0x8a, 0x87, 0xe6, 0xd6, 0x5d, 0x18, 0x23, 0x4b, 0xce, 0x1f, 0x62, + 0x25, 0x52, 0xd7, 0xfe, 0xf2, 0xff, 0x1d, 0x8b, 0x0, 0xe, 0x1f, 0xb8, 0xb1, 0xfa, 0xa5, 0xb2, 0x6d, + 0xca, 0xb1, 0xe5, 0xfa, 0x2b, 0x64, 0xe5, 0x0, 0x2, 0x34, 0x23}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0xd3, 0xe0, 0x53, 0x3b, 0xe5, 0xb0, 0x49, 0x44, 0xd2, 0xa8, 0x1f, 0xb9, + 0x4d, 0x6f, 0xf1, 0x89, 0x90, 0x99, 0x8f, 0xcb, 0xfa, 0x3, 0x57, 0xfb}; + uint8_t bytesprops0[] = {0xa9, 0xb0, 0xc6, 0xca, 0x85, 0x1d, 0xbc, 0x1f, 0x71, 0x16, 0xc2, 0x87, 0xf9, 0xbb, 0x4a}; + uint8_t bytesprops2[] = {0x1a, 0x11, 0xfd, 0xa8, 0x37, 0x15, 0x27, 0x26, + 0xba, 0x89, 0xd7, 0x9e, 0x4f, 0xe5, 0x62, 0x39}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9512}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops4}, .v = {20, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6905}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9853}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32158}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops10}, .v = {7, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6212}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23028}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23665}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15033}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops1[] = {0x5b, 0xe4, 0x8a, 0x64, 0x1f, 0x71, 0xb, 0x1c, 0xac}; + uint8_t byteswillprops2[] = {0xfc}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10172}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6438}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30408}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16984}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14049}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31013}}, + }; + + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x10, 0x9d, 0xe7, 0xcf, 0xb0, 0x24, 0x44, 0xcd, 0xf6, 0x63, 0x6a, + 0x8b, 0xd4, 0x97, 0xed, 0xb5, 0xe1, 0xc6, 0xb6, 0x3e, 0x43, 0x1c}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf2, 0xa6, 0x5c, 0x16, 0xbf, 0xd, 0x12, 0x64, 0x38, 0x81, + 0xef, 0x8a, 0x87, 0xe6, 0xd6, 0x5d, 0x18, 0x23, 0x4b, 0xce, + 0x1f, 0x62, 0x25, 0x52, 0xd7, 0xfe, 0xf2, 0xff, 0x1d, 0x8b}; + lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 14647; - uint8_t client_id_bytes[] = {0xad, 0xff, 0x6e, 0x7d, 0x81, 0x15}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; + opts.keep_alive = 21935; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t username_bytes[] = {0x1f, 0xb8, 0xb1, 0xfa, 0xa5, 0xb2, 0x6d, 0xca, 0xb1, 0xe5, 0xfa, 0x2b, 0x64, 0xe5}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x34, 0x23}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "/&", _password = Just -// "8\SUB\143\t\ESC\220%\187\ESC1\163\&9\253\207\185F\t\213N\NUL\"", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS0, _willTopic = "\209Ho\130\233\&6\203E\189\STX\204\202LG\160\188C[\GS&\169w\NUL\208\161", _willMsg = -// "C", _willProps = [PropSessionExpiryInterval 1870,PropSharedSubscriptionAvailable 232,PropMessageExpiryInterval -// 5518,PropTopicAlias 6427,PropSubscriptionIdentifierAvailable 131,PropSubscriptionIdentifier 25,PropReasonString -// "o\135'Tn4\199\FS \SO*|\a\174\SO;\229\t\225>\192N",PropResponseInformation -// "\136\188\243\EM:\173\236Y\t}%\212\229\138\SI9R\141I\206\192\139\217\249IC\150eo\170",PropServerReference -// "(\147\138\190\ESCb\239\183\\\252\&1\189bc\171\189\209",PropReceiveMaximum 3357,PropRequestProblemInformation -// 243,PropMessageExpiryInterval 5627,PropServerKeepAlive 22171,PropRetainAvailable 24,PropTopicAliasMaximum -// 18180,PropRequestResponseInformation 20,PropRetainAvailable 70,PropCorrelationData -// "8\131\255G\143\NAKhw3@t\EOT",PropResponseInformation -// "\135\ETX|\197\DEL\146f9L\197$t\SO0j\ENQ\137\138\178\138\245\210",PropSessionExpiryInterval -// 20657,PropSessionExpiryInterval 27920,PropRequestResponseInformation 8,PropUserProperty -// "\EOT\DC2p{\170.i\EOT\166\CANm" "r!\155\EOT6x\216s\SI\177\230Q\142\249\141\DLE\178\v\252\168",PropReceiveMaximum -// 8439,PropAuthenticationMethod "\221\DLE\133\205\&7\240\167\154",PropWillDelayInterval 9107]}), _cleanSession = False, -// _keepAlive = 17899, _connID = ".hc\n\135\206/\236\&0\221\216\155\236", _properties = [PropReceiveMaximum -// 26537,PropTopicAlias 10462,PropContentType -// "\133\DC4#\245\227&\ETX\217\r\DC1\216\210\234k\ACK\197\146\220\ACK\230\227\219/",PropReceiveMaximum -// 18891,PropWillDelayInterval 29782,PropSubscriptionIdentifier 7,PropWildcardSubscriptionAvailable 223,PropUserProperty -// "-\ETXU!\244N\169" "%9\254\194\US-\236\224\170;\244{u\180\198\243\&3\224\DC1\SO\203\t\193g",PropReceiveMaximum -// 29189]} +// ConnectRequest {_username = Nothing, _password = Just "\223\FS\149\212{Q\139+/s\191U\174l\n\173", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "AbQ~\153\211\195\255aR\240\202u\223", _willMsg = +// "\254\139\131\221\&7y\167\ETX\187I\188O~e\199", _willProps = [PropContentType +// "'\161^\GS\NAK*\DC4\158A\141\229\135",PropResponseTopic "\222\229\&7\167\192\177",PropReasonString +// "jJL\n7\250\173\NULx\ENQ\245",PropContentType +// "\SOH\253\f&\217\230\253,\164\246\162\227ms,\172\161\218\b\168\178w3",PropMessageExpiryInterval 15070]}), +// _cleanSession = False, _keepAlive = 5033, _connID = +// "\168\223\181\140\b\149\&4\184\157\178\201.\ETX\169Tm\178;\228b\\\246\DLE", _properties = [PropResponseInformation +// "\212\SYN\137\165Fi\152\ETB%\128\216\254\142C\150:\r\254\203S\RS\229\149\188&yS\137\239\GS",PropWildcardSubscriptionAvailable +// 197,PropWildcardSubscriptionAvailable 24,PropServerKeepAlive 21035,PropMessageExpiryInterval 969,PropRetainAvailable +// 9,PropServerReference +// "\147\ETX\233\SI^\128\n\152VB\254\142\252\174\252\160K\219\229\254n\234\&3\SYNbK\186",PropMaximumQoS +// 116,PropMaximumPacketSize 7900,PropReasonString "&\248\165w\200\ENQ\223\213J",PropMaximumQoS +// 31,PropSharedSubscriptionAvailable 112]} TEST(Connect5QCTest, Encode25) { uint8_t pkt[] = { - 0x10, 0x8a, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x45, 0xeb, 0x53, 0x21, 0x67, 0xa9, 0x23, 0x28, - 0xde, 0x3, 0x0, 0x17, 0x85, 0x14, 0x23, 0xf5, 0xe3, 0x26, 0x3, 0xd9, 0xd, 0x11, 0xd8, 0xd2, 0xea, 0x6b, 0x6, - 0xc5, 0x92, 0xdc, 0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x4, 0x19, 0x14, 0x25, 0x46, 0x9, 0x0, 0xc, 0x38, 0x83, 0xff, 0x47, 0x8f, 0x15, 0x68, 0x77, 0x33, 0x40, 0x74, - 0x4, 0x1a, 0x0, 0x16, 0x87, 0x3, 0x7c, 0xc5, 0x7f, 0x92, 0x66, 0x39, 0x4c, 0xc5, 0x24, 0x74, 0xe, 0x30, 0x6a, - 0x5, 0x89, 0x8a, 0xb2, 0x8a, 0xf5, 0xd2, 0x11, 0x0, 0x0, 0x50, 0xb1, 0x11, 0x0, 0x0, 0x6d, 0x10, 0x19, 0x8, - 0x26, 0x0, 0xb, 0x4, 0x12, 0x70, 0x7b, 0xaa, 0x2e, 0x69, 0x4, 0xa6, 0x18, 0x6d, 0x0, 0x14, 0x72, 0x21, 0x9b, - 0x4, 0x36, 0x78, 0xd8, 0x73, 0xf, 0xb1, 0xe6, 0x51, 0x8e, 0xf9, 0x8d, 0x10, 0xb2, 0xb, 0xfc, 0xa8, 0x21, 0x20, - 0xf7, 0x15, 0x0, 0x8, 0xdd, 0x10, 0x85, 0xcd, 0x37, 0xf0, 0xa7, 0x9a, 0x18, 0x0, 0x0, 0x23, 0x93, 0x0, 0x19, - 0xd1, 0x48, 0x6f, 0x82, 0xe9, 0x36, 0xcb, 0x45, 0xbd, 0x2, 0xcc, 0xca, 0x4c, 0x47, 0xa0, 0xbc, 0x43, 0x5b, 0x1d, - 0x26, 0xa9, 0x77, 0x0, 0xd0, 0xa1, 0x0, 0x1, 0x43, 0x0, 0x2, 0x2f, 0x26, 0x0, 0x15, 0x38, 0x1a, 0x8f, 0x9, - 0x1b, 0xdc, 0x25, 0xbb, 0x1b, 0x31, 0xa3, 0x39, 0xfd, 0xcf, 0xb9, 0x46, 0x9, 0xd5, 0x4e, 0x0, 0x22}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x85, 0x14, 0x23, 0xf5, 0xe3, 0x26, 0x3, 0xd9, 0xd, 0x11, 0xd8, 0xd2, - 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0xf6, 0x10, 0x45, 0x3, 0x0, 0xc, 0x27, 0xa1, 0x5e, 0x1d, 0x15, 0x2a, 0x14, 0x9e, 0x41, + 0x8d, 0xe5, 0x87, 0x8, 0x0, 0x6, 0xde, 0xe5, 0x37, 0xa7, 0xc0, 0xb1, 0x1f, 0x0, 0xb, 0x6a, 0x4a, 0x4c, 0xa, + 0x37, 0xfa, 0xad, 0x0, 0x78, 0x5, 0xf5, 0x3, 0x0, 0x17, 0x1, 0xfd, 0xc, 0x26, 0xd9, 0xe6, 0xfd, 0x2c, 0xa4, + 0xf6, 0xa2, 0xe3, 0x6d, 0x73, 0x2c, 0xac, 0xa1, 0xda, 0x8, 0xa8, 0xb2, 0x77, 0x33, 0x2, 0x0, 0x0, 0x3a, 0xde, + 0x0, 0xe, 0x41, 0x62, 0x51, 0x7e, 0x99, 0xd3, 0xc3, 0xff, 0x61, 0x52, 0xf0, 0xca, 0x75, 0xdf, 0x0, 0xf, 0xfe, + 0x8b, 0x83, 0xdd, 0x37, 0x79, 0xa7, 0x3, 0xbb, 0x49, 0xbc, 0x4f, 0x7e, 0x65, 0xc7, 0x0, 0x10, 0xdf, 0x1c, 0x95, + 0xd4, 0x7b, 0x51, 0x8b, 0x2b, 0x2f, 0x73, 0xbf, 0x55, 0xae, 0x6c, 0xa, 0xad}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xd4, 0x16, 0x89, 0xa5, 0x46, 0x69, 0x98, 0x17, 0x25, 0x80, 0xd8, 0xfe, 0x8e, 0x43, 0x96, + 0x3a, 0xd, 0xfe, 0xcb, 0x53, 0x1e, 0xe5, 0x95, 0xbc, 0x26, 0x79, 0x53, 0x89, 0xef, 0x1d}; + uint8_t bytesprops1[] = {0x93, 0x3, 0xe9, 0xf, 0x5e, 0x80, 0xa, 0x98, 0x56, 0x42, 0xfe, 0x8e, 0xfc, 0xae, + 0xfc, 0xa0, 0x4b, 0xdb, 0xe5, 0xfe, 0x6e, 0xea, 0x33, 0x16, 0x62, 0x4b, 0xba}; + uint8_t bytesprops2[] = {0x26, 0xf8, 0xa5, 0x77, 0xc8, 0x5, 0xdf, 0xd5, 0x4a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26537}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10462}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18891}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29782}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops1}, .v = {24, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29189}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21035}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 969}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7900}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 112}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x6f, 0x87, 0x27, 0x54, 0x6e, 0x34, 0xc7, 0x1c, 0x20, 0xe, 0x2a, - 0x7c, 0x7, 0xae, 0xe, 0x3b, 0xe5, 0x9, 0xe1, 0x3e, 0xc0, 0x4e}; - uint8_t byteswillprops1[] = {0x88, 0xbc, 0xf3, 0x19, 0x3a, 0xad, 0xec, 0x59, 0x9, 0x7d, - 0x25, 0xd4, 0xe5, 0x8a, 0xf, 0x39, 0x52, 0x8d, 0x49, 0xce, - 0xc0, 0x8b, 0xd9, 0xf9, 0x49, 0x43, 0x96, 0x65, 0x6f, 0xaa}; - uint8_t byteswillprops2[] = {0x28, 0x93, 0x8a, 0xbe, 0x1b, 0x62, 0xef, 0xb7, 0x5c, - 0xfc, 0x31, 0xbd, 0x62, 0x63, 0xab, 0xbd, 0xd1}; - uint8_t byteswillprops3[] = {0x38, 0x83, 0xff, 0x47, 0x8f, 0x15, 0x68, 0x77, 0x33, 0x40, 0x74, 0x4}; - uint8_t byteswillprops4[] = {0x87, 0x3, 0x7c, 0xc5, 0x7f, 0x92, 0x66, 0x39, 0x4c, 0xc5, 0x24, - 0x74, 0xe, 0x30, 0x6a, 0x5, 0x89, 0x8a, 0xb2, 0x8a, 0xf5, 0xd2}; - uint8_t byteswillprops6[] = {0x72, 0x21, 0x9b, 0x4, 0x36, 0x78, 0xd8, 0x73, 0xf, 0xb1, - 0xe6, 0x51, 0x8e, 0xf9, 0x8d, 0x10, 0xb2, 0xb, 0xfc, 0xa8}; - uint8_t byteswillprops5[] = {0x4, 0x12, 0x70, 0x7b, 0xaa, 0x2e, 0x69, 0x4, 0xa6, 0x18, 0x6d}; - uint8_t byteswillprops7[] = {0xdd, 0x10, 0x85, 0xcd, 0x37, 0xf0, 0xa7, 0x9a}; + uint8_t byteswillprops0[] = {0x27, 0xa1, 0x5e, 0x1d, 0x15, 0x2a, 0x14, 0x9e, 0x41, 0x8d, 0xe5, 0x87}; + uint8_t byteswillprops1[] = {0xde, 0xe5, 0x37, 0xa7, 0xc0, 0xb1}; + uint8_t byteswillprops2[] = {0x6a, 0x4a, 0x4c, 0xa, 0x37, 0xfa, 0xad, 0x0, 0x78, 0x5, 0xf5}; + uint8_t byteswillprops3[] = {0x1, 0xfd, 0xc, 0x26, 0xd9, 0xe6, 0xfd, 0x2c, 0xa4, 0xf6, 0xa2, 0xe3, + 0x6d, 0x73, 0x2c, 0xac, 0xa1, 0xda, 0x8, 0xa8, 0xb2, 0x77, 0x33}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1870}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5518}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6427}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3357}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5627}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22171}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18180}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20657}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27920}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {11, (char*)&byteswillprops5}, .v = {20, (char*)&byteswillprops6}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8439}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9107}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15070}}, }; - lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd1, 0x48, 0x6f, 0x82, 0xe9, 0x36, 0xcb, 0x45, 0xbd, 0x2, 0xcc, 0xca, 0x4c, - 0x47, 0xa0, 0xbc, 0x43, 0x5b, 0x1d, 0x26, 0xa9, 0x77, 0x0, 0xd0, 0xa1}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x43}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x41, 0x62, 0x51, 0x7e, 0x99, 0xd3, 0xc3, 0xff, 0x61, 0x52, 0xf0, 0xca, 0x75, 0xdf}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfe, 0x8b, 0x83, 0xdd, 0x37, 0x79, 0xa7, 0x3, + 0xbb, 0x49, 0xbc, 0x4f, 0x7e, 0x65, 0xc7}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS1; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 17899; - uint8_t client_id_bytes[] = {0x2e, 0x68, 0x63, 0xa, 0x87, 0xce, 0x2f, 0xec, 0x30, 0xdd, 0xd8, 0x9b, 0xec}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.keep_alive = 5033; + uint8_t client_id_bytes[] = {0xa8, 0xdf, 0xb5, 0x8c, 0x8, 0x95, 0x34, 0xb8, 0x9d, 0xb2, 0xc9, 0x2e, + 0x3, 0xa9, 0x54, 0x6d, 0xb2, 0x3b, 0xe4, 0x62, 0x5c, 0xf6, 0x10}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2f, 0x26}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x38, 0x1a, 0x8f, 0x9, 0x1b, 0xdc, 0x25, 0xbb, 0x1b, 0x31, 0xa3, - 0x39, 0xfd, 0xcf, 0xb9, 0x46, 0x9, 0xd5, 0x4e, 0x0, 0x22}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xdf, 0x1c, 0x95, 0xd4, 0x7b, 0x51, 0x8b, 0x2b, + 0x2f, 0x73, 0xbf, 0x55, 0xae, 0x6c, 0xa, 0xad}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9563,86 +9630,190 @@ TEST(Connect5QCTest, Encode25) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "N\203\159\210\235ac\RS\168\231\220r'\253\200\162\192\166\149\231\221", _password = -// Just "\174,\168L\134y\NUL\129\t\237\152\134\184\222\US\168\208\"|\246\140=\236\196~\b\150\246\216\164", _lastWill = -// Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\218I\179[\161\209\ESC}h\205FPB@K\133", _willMsg -// = "2\215\135\225\197N", _willProps = [PropCorrelationData -// "@\153\210\152\129\138\129[k\165\228\205\201~\149\188",PropWildcardSubscriptionAvailable -// 161,PropWildcardSubscriptionAvailable 133,PropServerReference "\135Y\218\139.D/\173W\167j",PropAuthenticationMethod " -// \199/E\233\150;c/"]}), _cleanSession = False, _keepAlive = 30481, _connID = -// "\132\129b\222=>\197\164\SO\236\234\204O\202\240\150\&0\186\167", _properties = [PropSharedSubscriptionAvailable -// 2,PropPayloadFormatIndicator 142,PropMaximumPacketSize 7898,PropServerReference -// "\185\137\&6\172\245\241\241\246",PropRequestProblemInformation 20,PropUserProperty "[J\203\217\SO\&H\204\208M:\t" -// "%\NAK\208x\208$p\192x\247"]} +// ConnectRequest {_username = Just "Q\ESC&\174\247\148\240\DEL]\244\244\245", _password = Just "*\202 ;\132", _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "\130\&6pS\DC2\ACK(Y\152Y\FS\150\ETBy\207\136\204", _willMsg = +// "\164w\254._0\196?\182\141eY\201\165\141n\163\251|\199\160", _willProps = [PropContentType +// "\154\206-*'Q(\236D@xx\151\148\167T\239xC\195+\142\v\186SA\174\138\166s",PropResponseTopic +// "A\191\DC2E$(\239%vB^\212\181\152?7\150\164f\DEL\220Zp\158\SYNvF\226\151",PropPayloadFormatIndicator +// 101,PropCorrelationData ",2\176$",PropServerKeepAlive 11601,PropMaximumQoS 120,PropServerReference +// "s\230h.\SUB5p9\178\248\227\DC3\n\STXf*\ACKN\242+\225",PropReceiveMaximum 10666,PropMessageExpiryInterval +// 5491,PropRequestProblemInformation 111,PropRequestResponseInformation 47,PropCorrelationData +// "T\200\254\157[x\210\185\228+\186\190P\155*[z\r\188",PropTopicAlias 26651,PropAssignedClientIdentifier +// "",PropSubscriptionIdentifierAvailable 199,PropSessionExpiryInterval 12887,PropContentType +// "J\199fS-_\250\180\160\129K\171\151\155y\220-1"]}), _cleanSession = False, _keepAlive = 6835, _connID = +// "=7\240F\243\217", _properties = [PropSharedSubscriptionAvailable 204,PropResponseInformation +// "e",PropSharedSubscriptionAvailable 192,PropRequestProblemInformation 201,PropSessionExpiryInterval +// 19992,PropAssignedClientIdentifier "\186\&2\ETB\169\190\129o\ETXN\160I",PropUserProperty +// "a?\166r\172\240\159\250\128\187" "kX{\140\215\235/\248\SO\152L\239\229\175~O\199",PropUserProperty "\131\173" +// "\189c\135\&4\t\DEL\130[\176\171\241O\192\189q\149\&3\255\&0\ETBq",PropServerKeepAlive 15269,PropResponseInformation +// "\214\161\150\SOH\136\247cV\158\&2\ENQ\154\249\DC2!\141p:-C%\250q1",PropAssignedClientIdentifier +// "\211<5\229Y$",PropRequestProblemInformation 252,PropServerReference +// "\SOoo\f\156\CAN\157\249S\170\218o\SYN\153\142\207\236\133\176XN6\219iZ",PropTopicAlias +// 27820,PropSubscriptionIdentifierAvailable 228,PropSubscriptionIdentifier 3,PropServerKeepAlive 30256,PropMaximumQoS +// 231]} TEST(Connect5QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0xd3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc4, 0x77, 0x11, 0x30, 0x2a, 0x2, 0x1, - 0x8e, 0x27, 0x0, 0x0, 0x1e, 0xda, 0x1c, 0x0, 0x8, 0xb9, 0x89, 0x36, 0xac, 0xf5, 0xf1, 0xf1, 0xf6, - 0x17, 0x14, 0x26, 0x0, 0xb, 0x5b, 0x4a, 0xcb, 0xd9, 0xe, 0x48, 0xcc, 0xd0, 0x4d, 0x3a, 0x9, 0x0, - 0xa, 0x25, 0x15, 0xd0, 0x78, 0xd0, 0x24, 0x70, 0xc0, 0x78, 0xf7, 0x0, 0x13, 0x84, 0x81, 0x62, 0xde, - 0x3d, 0x3e, 0xc5, 0xa4, 0xe, 0xec, 0xea, 0xcc, 0x4f, 0xca, 0xf0, 0x96, 0x30, 0xba, 0xa7, 0x31, 0x9, - 0x0, 0x10, 0x40, 0x99, 0xd2, 0x98, 0x81, 0x8a, 0x81, 0x5b, 0x6b, 0xa5, 0xe4, 0xcd, 0xc9, 0x7e, 0x95, - 0xbc, 0x28, 0xa1, 0x28, 0x85, 0x1c, 0x0, 0xb, 0x87, 0x59, 0xda, 0x8b, 0x2e, 0x44, 0x2f, 0xad, 0x57, - 0xa7, 0x6a, 0x15, 0x0, 0x9, 0x20, 0xc7, 0x2f, 0x45, 0xe9, 0x96, 0x3b, 0x63, 0x2f, 0x0, 0x10, 0xda, - 0x49, 0xb3, 0x5b, 0xa1, 0xd1, 0x1b, 0x7d, 0x68, 0xcd, 0x46, 0x50, 0x42, 0x40, 0x4b, 0x85, 0x0, 0x6, - 0x32, 0xd7, 0x87, 0xe1, 0xc5, 0x4e, 0x0, 0x15, 0x4e, 0xcb, 0x9f, 0xd2, 0xeb, 0x61, 0x63, 0x1e, 0xa8, - 0xe7, 0xdc, 0x72, 0x27, 0xfd, 0xc8, 0xa2, 0xc0, 0xa6, 0x95, 0xe7, 0xdd, 0x0, 0x1e, 0xae, 0x2c, 0xa8, - 0x4c, 0x86, 0x79, 0x0, 0x81, 0x9, 0xed, 0x98, 0x86, 0xb8, 0xde, 0x1f, 0xa8, 0xd0, 0x22, 0x7c, 0xf6, - 0x8c, 0x3d, 0xec, 0xc4, 0x7e, 0x8, 0x96, 0xf6, 0xd8, 0xa4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb9, 0x89, 0x36, 0xac, 0xf5, 0xf1, 0xf1, 0xf6}; - uint8_t bytesprops2[] = {0x25, 0x15, 0xd0, 0x78, 0xd0, 0x24, 0x70, 0xc0, 0x78, 0xf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 0x6, 0x28, 0x59, 0x98, 0x59, 0x1c, + 0x96, 0x17, 0x79, 0xcf, 0x88, 0xcc, 0x0, 0x15, 0xa4, 0x77, 0xfe, 0x2e, 0x5f, 0x30, 0xc4, 0x3f, 0xb6, 0x8d, 0x65, + 0x59, 0xc9, 0xa5, 0x8d, 0x6e, 0xa3, 0xfb, 0x7c, 0xc7, 0xa0, 0x0, 0xc, 0x51, 0x1b, 0x26, 0xae, 0xf7, 0x94, 0xf0, + 0x7f, 0x5d, 0xf4, 0xf4, 0xf5, 0x0, 0x5, 0x2a, 0xca, 0x20, 0x3b, 0x84}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x65}; + uint8_t bytesprops1[] = {0xba, 0x32, 0x17, 0xa9, 0xbe, 0x81, 0x6f, 0x3, 0x4e, 0xa0, 0x49}; + uint8_t bytesprops3[] = {0x6b, 0x58, 0x7b, 0x8c, 0xd7, 0xeb, 0x2f, 0xf8, 0xe, + 0x98, 0x4c, 0xef, 0xe5, 0xaf, 0x7e, 0x4f, 0xc7}; + uint8_t bytesprops2[] = {0x61, 0x3f, 0xa6, 0x72, 0xac, 0xf0, 0x9f, 0xfa, 0x80, 0xbb}; + uint8_t bytesprops5[] = {0xbd, 0x63, 0x87, 0x34, 0x9, 0x7f, 0x82, 0x5b, 0xb0, 0xab, 0xf1, + 0x4f, 0xc0, 0xbd, 0x71, 0x95, 0x33, 0xff, 0x30, 0x17, 0x71}; + uint8_t bytesprops4[] = {0x83, 0xad}; + uint8_t bytesprops6[] = {0xd6, 0xa1, 0x96, 0x1, 0x88, 0xf7, 0x63, 0x56, 0x9e, 0x32, 0x3c, + 0x2f, 0x86, 0x3c, 0xbb, 0x87, 0x8b, 0x42, 0xcb, 0x5, 0x17, 0x22}; + uint8_t bytesprops7[] = {0xf6, 0x61, 0x72, 0xcf, 0xe0, 0x94, 0xf9, 0x15, 0x4, + 0x78, 0x11, 0x44, 0xb7, 0xfb, 0x36, 0x90, 0xca}; + uint8_t bytesprops8[] = {0x57, 0xea, 0x4e, 0xf5, 0xe, 0x1f, 0x63, 0x96, 0x72, 0x5c, 0x14}; + uint8_t bytesprops9[] = {0x4e, 0x0, 0xef, 0x91, 0x51, 0x69, 0xd0, 0xde, 0xa2, 0x57, 0x5f, 0x4f, 0x9c, 0x12, 0x30, + 0x9d, 0x82, 0x8f, 0x94, 0x67, 0x28, 0xee, 0xb5, 0xa3, 0xa1, 0x6b, 0xf6, 0xe9, 0x99}; + uint8_t bytesprops10[] = {0x5a, 0xb6, 0x8b, 0xc2, 0x92, 0x8, 0x79, 0x5b, 0x6d, 0x4, 0xfd, + 0xba, 0x19, 0xf1, 0x62, 0xe9, 0x74, 0x9e, 0xad, 0x5e, 0x89, 0x74}; + uint8_t bytesprops11[] = {0xe4, 0x55, 0x4, 0x8f, 0x39, 0xc7, 0x73, 0x73, 0xae, 0xf3, + 0x5e, 0x5f, 0x37, 0xd5, 0x4, 0x9c, 0x5d, 0x4d, 0x24}; + uint8_t bytesprops12[] = {0xbc, 0x8b, 0x5d, 0xd7, 0x34, 0xc2, 0xab, 0x4, 0x3b, 0x78, 0xc9, + 0x4d, 0xfc, 0x8a, 0x1e, 0x8a, 0x13, 0xc7, 0xec, 0x90, 0x55, 0x80}; + uint8_t bytesprops13[] = {0x2d, 0xc0, 0x5c, 0x2, 0x1d, 0x5, 0x6, 0x96, 0x6f, 0x3e, 0x5, 0x9a, + 0xf9, 0x12, 0x21, 0x8d, 0x70, 0x3a, 0x2d, 0x43, 0x25, 0xfa, 0x71, 0x31}; + uint8_t bytesprops14[] = {0xd3, 0x3c, 0x35, 0xe5, 0x59, 0x24}; + uint8_t bytesprops15[] = {0xe, 0x6f, 0x6f, 0xc, 0x9c, 0x18, 0x9d, 0xf9, 0x53, 0xaa, 0xda, 0x6f, 0x16, + 0x99, 0x8e, 0xcf, 0xec, 0x85, 0xb0, 0x58, 0x4e, 0x36, 0xdb, 0x69, 0x5a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7898}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {10, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19992}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {17, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops4}, .v = {21, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15269}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28984}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27820}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30256}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x40, 0x99, 0xd2, 0x98, 0x81, 0x8a, 0x81, 0x5b, - 0x6b, 0xa5, 0xe4, 0xcd, 0xc9, 0x7e, 0x95, 0xbc}; - uint8_t byteswillprops1[] = {0x87, 0x59, 0xda, 0x8b, 0x2e, 0x44, 0x2f, 0xad, 0x57, 0xa7, 0x6a}; - uint8_t byteswillprops2[] = {0x20, 0xc7, 0x2f, 0x45, 0xe9, 0x96, 0x3b, 0x63, 0x2f}; + uint8_t byteswillprops0[] = {0x9a, 0xce, 0x2d, 0x2a, 0x27, 0x51, 0x28, 0xec, 0x44, 0x40, + 0x78, 0x78, 0x97, 0x94, 0xa7, 0x54, 0xef, 0x78, 0x43, 0xc3, + 0x2b, 0x8e, 0xb, 0xba, 0x53, 0x41, 0xae, 0x8a, 0xa6, 0x73}; + uint8_t byteswillprops1[] = {0x41, 0xbf, 0x12, 0x45, 0x24, 0x28, 0xef, 0x25, 0x76, 0x42, 0x5e, 0xd4, 0xb5, 0x98, 0x3f, + 0x37, 0x96, 0xa4, 0x66, 0x7f, 0xdc, 0x5a, 0x70, 0x9e, 0x16, 0x76, 0x46, 0xe2, 0x97}; + uint8_t byteswillprops2[] = {0x2c, 0x32, 0xb0, 0x24}; + uint8_t byteswillprops3[] = {0x73, 0xe6, 0x68, 0x2e, 0x1a, 0x35, 0x70, 0x39, 0xb2, 0xf8, 0xe3, + 0x13, 0xa, 0x2, 0x66, 0x2a, 0x6, 0x4e, 0xf2, 0x2b, 0xe1}; + uint8_t byteswillprops4[] = {0x54, 0xc8, 0xfe, 0x9d, 0x5b, 0x78, 0xd2, 0xb9, 0xe4, 0x2b, + 0xba, 0xbe, 0x50, 0x9b, 0x2a, 0x5b, 0x7a, 0xd, 0xbc}; + uint8_t byteswillprops5[] = {0}; + uint8_t byteswillprops6[] = {0x4a, 0xc7, 0x66, 0x53, 0x2d, 0x5f, 0xfa, 0xb4, 0xa0, + 0x81, 0x4b, 0xab, 0x97, 0x9b, 0x79, 0xdc, 0x2d, 0x31}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11601}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10666}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5491}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26651}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12887}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops6}}}, }; - lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xda, 0x49, 0xb3, 0x5b, 0xa1, 0xd1, 0x1b, 0x7d, - 0x68, 0xcd, 0x46, 0x50, 0x42, 0x40, 0x4b, 0x85}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x32, 0xd7, 0x87, 0xe1, 0xc5, 0x4e}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x82, 0x36, 0x70, 0x53, 0x12, 0x6, 0x28, 0x59, 0x98, + 0x59, 0x1c, 0x96, 0x17, 0x79, 0xcf, 0x88, 0xcc}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa4, 0x77, 0xfe, 0x2e, 0x5f, 0x30, 0xc4, 0x3f, 0xb6, 0x8d, 0x65, + 0x59, 0xc9, 0xa5, 0x8d, 0x6e, 0xa3, 0xfb, 0x7c, 0xc7, 0xa0}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 30481; - uint8_t client_id_bytes[] = {0x84, 0x81, 0x62, 0xde, 0x3d, 0x3e, 0xc5, 0xa4, 0xe, 0xec, - 0xea, 0xcc, 0x4f, 0xca, 0xf0, 0x96, 0x30, 0xba, 0xa7}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; + opts.keep_alive = 6835; + uint8_t client_id_bytes[] = {0x3d, 0x37, 0xf0, 0x46, 0xf3, 0xd9}; + lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x4e, 0xcb, 0x9f, 0xd2, 0xeb, 0x61, 0x63, 0x1e, 0xa8, 0xe7, 0xdc, - 0x72, 0x27, 0xfd, 0xc8, 0xa2, 0xc0, 0xa6, 0x95, 0xe7, 0xdd}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x51, 0x1b, 0x26, 0xae, 0xf7, 0x94, 0xf0, 0x7f, 0x5d, 0xf4, 0xf4, 0xf5}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xae, 0x2c, 0xa8, 0x4c, 0x86, 0x79, 0x0, 0x81, 0x9, 0xed, 0x98, 0x86, 0xb8, 0xde, 0x1f, - 0xa8, 0xd0, 0x22, 0x7c, 0xf6, 0x8c, 0x3d, 0xec, 0xc4, 0x7e, 0x8, 0x96, 0xf6, 0xd8, 0xa4}; - lwmqtt_string_t password = {30, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x2a, 0xca, 0x20, 0x3b, 0x84}; + lwmqtt_string_t password = {5, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9652,200 +9823,206 @@ TEST(Connect5QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "eBV0^b\231\GS\250\n\203\224", _password = Just -// "\240\177\187\244\250c\"\200Pw\189\163m|\131\&5*\177\169]", _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS1, _willTopic = "\b,([w\253\205\CAN\167\199\238\&0\171\SOHj\206\NUL\245\243\144\169\b\226\180\134\154}\214\194", -// _willMsg = "\181aO\128(\188\ETB", _willProps = [PropResponseTopic -// "\240\191\190;\151\150\128\232\230\189\223\208\149d_\241i\168",PropSubscriptionIdentifier 3,PropUserProperty -// "\255\n\170w\146\254\227\225>\147\136x\146\STX=@\192)_s3",PropTopicAliasMaximum -// 26779,PropWildcardSubscriptionAvailable 149,PropWillDelayInterval 6431,PropContentType -// "\208f\163\NAK~k\r\192%\199Mc\185\181\194 \193\ETB\169\"\255\144=\CAN\NAK\168$\t",PropRetainAvailable -// 106,PropUserProperty "\161]\219U\133\146\219\141_\197\NUL\ACKa\224\192L\196p" -// "Z\172\213\215\148\f#,",PropUserProperty "\245" -// "\227\199V\169\251\141\252r\148\167\134s\a\152\DC1\167\223\253^\213VV\128\193\ACKu\132\183\232r",PropTopicAlias -// 14287,PropTopicAliasMaximum 30203,PropRetainAvailable 218,PropResponseInformation -// "\142\&6\172J\DC4\v\v\239Q\139\203!&\180",PropServerReference "ML\165\210\154\253\&4\141hB"]}), _cleanSession = -// False, _keepAlive = 3521, _connID = "\205A\247\ACK\129\&6\196\202\192<\208z\234>\ETB\DC2\195\208\221\STX\DC1L\146s", -// _properties = [PropAuthenticationData "\130\248\ETX\197\202\166]\180\SI\154\188y\132",PropResponseTopic -// "\190\200l\241\&5\245p\171\183\255Qd\DC4\149\227",PropTopicAlias 17354,PropTopicAliasMaximum -// 205,PropAssignedClientIdentifier "Hz\157\DEL\150\144Bw\194=\203A&t\255\ENQH\184$\225\140",PropUserProperty -// "\DC2&\172\&5_<\146,\162\&3^\135\149:\b\191\170\250VJs\SUB\224f\186\236L" -// "$\141a/\214\195\229(\242\146\214",PropUserProperty "\250\&1\236D\152\145\137\&1\170" -// "SvF3\146TM\223\NAK\STX\191;\NUL\NUL#/\159\253\b\129\&0.\EM\209\247",PropMessageExpiryInterval -// 28259,PropPayloadFormatIndicator 81,PropSharedSubscriptionAvailable 202,PropUserProperty -// "@\253^\230\180\181$\245\219\245\162\224\NAK\204\231\244\175\212\174f\NUL\225\186\179kv\ETB" -// "\147R\167\155k",PropContentType "\200\171|\227\159\202\208\RSa\199",PropRequestProblemInformation -// 19,PropRequestProblemInformation 133,PropMaximumPacketSize 1040,PropSubscriptionIdentifier -// 18,PropAssignedClientIdentifier "\212*\158A\154\249\DEL\209<\191\r\n",PropTopicAliasMaximum 9595,PropReasonString -// "\SYN\191\223\SI_\234\241\163+\175W\187\184\&3\194\FS",PropUserProperty "V\238\150=fw\218\&9\200\EOT" -// "\229-",PropAuthenticationMethod "#m",PropResponseInformation -// "\r\174\170X\206g\186\255\153<\220\DC4kq\EOT\227W\129",PropAuthenticationMethod -// "\224\253^\184\248x\248\DC1\180\237\193_}\155 ?\212A\175",PropPayloadFormatIndicator 97,PropUserProperty -// "b\143\DC28\220a\148\198\145\145\&6\n\243\180\SOH `N\149\187\172\246\253\&9\139L:)" -// "\SUB\247V\243\153\ESCe\\\213>\219\SOH\EM\244X\154\251\172\254Y\238\&9R\243\SYN\DC3\206"]} +// ConnectRequest {_username = Just ">\GSG\161K\206,\183\NAKu{\239\227y\214\238\251\157?\147!,XQ\180\vF\251P", _password +// = Just "\f\192\209\&7\135\205f\134\181\170)xCW.\190E", _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS2, _willTopic = "\236\202:\200\SO\EMYd\145y6:\171-\DC4 \194", _willMsg = +// "\241\156\177\145\136\DC3h\r\128\187P\182\239\173#\153y0o'\158G\149", _willProps = [PropTopicAlias +// 21,PropWildcardSubscriptionAvailable 157,PropRetainAvailable 182,PropAuthenticationData +// "\194\245\254~wi#\142\214\131\248O\248\196\175Mck3",PropServerKeepAlive 22229,PropAuthenticationData +// "\236\171D\173C]U\192",PropWildcardSubscriptionAvailable 147,PropContentType +// "\220\246\153\DLE\162&\216K\232xv\174;\254\165\135\190\EOT\180J\134~O\195mm\SI\197\b\EM",PropRetainAvailable +// 220,PropUserProperty "\167\194\244p\245=\238\DC1\201" "\238D#5S\160B\242",PropWillDelayInterval +// 10510,PropRequestProblemInformation 144,PropServerReference "e\221\133\147A\NAK\v\139\\\157\131t\208C_I\239\FS +// \232\168]\183Q",PropUserProperty "\216\t\198\192" +// "\136\143\229\225U\194lb%\141\200\&1R`\254\225\192\136;z`\216CgR",PropCorrelationData +// "\180\207\178x\STX\142",PropAuthenticationData +// "\240\DC1\254\162\155\&0\180\243s\195\223\STX\179\168\149F\174\150v\NAK\188\136\DC3\213\226(\137R",PropServerKeepAlive +// 11277,PropWildcardSubscriptionAvailable 162,PropSharedSubscriptionAvailable 16,PropMessageExpiryInterval +// 30939,PropAuthenticationMethod ".\203\&4\150\r\ETB\214\146\&4\225\253\133\215\223",PropTopicAlias +// 4379,PropWillDelayInterval 22271,PropSubscriptionIdentifierAvailable 53,PropAuthenticationData +// "\236;\228$\176\133yZg\ETX\DC1\188\230=\255jI'S\197",PropRequestProblemInformation 132,PropReceiveMaximum 16913]}), +// _cleanSession = True, _keepAlive = 12883, _connID = "\191\194\&3\136\GS\t\240", _properties = +// [PropSubscriptionIdentifier 22,PropUserProperty "\RSP\240{\242\140\r" "e",PropWildcardSubscriptionAvailable +// 74,PropSubscriptionIdentifierAvailable 79,PropMessageExpiryInterval 5364,PropServerReference +// "\222\145\154\252\ESC\163\147\152\203",PropMessageExpiryInterval 22212,PropReasonString +// "\168",PropPayloadFormatIndicator 212,PropRetainAvailable 246,PropUserProperty +// "\237\&4\146}\DC3\252G=^,\SIuu\132\196\143\233\240\SYN" +// ":\198\183\192\218al[\DELNr\206\245\152\236\196\198l\151\SUB\195\188_",PropSharedSubscriptionAvailable +// 192,PropServerKeepAlive 9518,PropCorrelationData "\156>\SO?\216^g\197\146",PropAuthenticationData +// "|>\136\187\214w2",PropMessageExpiryInterval 5171,PropWillDelayInterval 30792,PropAssignedClientIdentifier +// "",PropMaximumQoS 160,PropSharedSubscriptionAvailable 59,PropContentType +// "\238U\161av\178!p\175\197Zz<\ACKC\162\208\177\US\RS\ETBqg1",PropMessageExpiryInterval 2410,PropServerKeepAlive +// 21813,PropRequestProblemInformation 2,PropContentType "\EM\DC1\v\ACK\DC1\177\185\f+",PropMessageExpiryInterval +// 30176,PropUserProperty "a\180U" "\163\156\183\NAK\195\193\a]/|\253\171\US\190[ 4\227\195\214\ETX",PropUserProperty +// "\240\151\205\238\\H" "@\194\234\209`\132\NUL\144T"]} TEST(Connect5QCTest, Encode27) { uint8_t pkt[] = { - 0x10, 0xbb, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0xd, 0xc1, 0xfc, 0x2, 0x16, 0x0, 0xd, 0x82, - 0xf8, 0x3, 0xc5, 0xca, 0xa6, 0x5d, 0xb4, 0xf, 0x9a, 0xbc, 0x79, 0x84, 0x8, 0x0, 0xf, 0xbe, 0xc8, 0x6c, 0xf1, - 0x35, 0xf5, 0x70, 0xab, 0xb7, 0xff, 0x51, 0x64, 0x14, 0x95, 0xe3, 0x23, 0x43, 0xca, 0x22, 0x0, 0xcd, 0x12, 0x0, - 0x15, 0x48, 0x7a, 0x9d, 0x7f, 0x96, 0x90, 0x42, 0x77, 0xc2, 0x3d, 0xcb, 0x41, 0x26, 0x74, 0xff, 0x5, 0x48, 0xb8, - 0x24, 0xe1, 0x8c, 0x26, 0x0, 0x1b, 0x12, 0x26, 0xac, 0x35, 0x5f, 0x3c, 0x92, 0x2c, 0xa2, 0x33, 0x5e, 0x87, 0x95, - 0x3a, 0x8, 0xbf, 0xaa, 0xfa, 0x56,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, 0x61, 0x4f, 0x80, 0x28, 0xbc, - 0x17, 0x0, 0xc, 0x65, 0x42, 0x56, 0x30, 0x5e, 0x62, 0xe7, 0x1d, 0xfa, 0xa, 0xcb, 0xe0, 0x0, 0x14, 0xf0, 0xb1, - 0xbb, 0xf4, 0xfa, 0x63, 0x22, 0xc8, 0x50, 0x77, 0xbd, 0xa3, 0x6d, 0x7c, 0x83, 0x35, 0x2a, 0xb1, 0xa9, 0x5d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x82, 0xf8, 0x3, 0xc5, 0xca, 0xa6, 0x5d, 0xb4, 0xf, 0x9a, 0xbc, 0x79, 0x84}; - uint8_t bytesprops1[] = {0xbe, 0xc8, 0x6c, 0xf1, 0x35, 0xf5, 0x70, 0xab, 0xb7, 0xff, 0x51, 0x64, 0x14, 0x95, 0xe3}; - uint8_t bytesprops2[] = {0x48, 0x7a, 0x9d, 0x7f, 0x96, 0x90, 0x42, 0x77, 0xc2, 0x3d, 0xcb, - 0x41, 0x26, 0x74, 0xff, 0x5, 0x48, 0xb8, 0x24, 0xe1, 0x8c}; - uint8_t bytesprops4[] = {0x24, 0x8d, 0x61, 0x2f, 0xd6, 0xc3, 0xe5, 0x28, 0xf2, 0x92, 0xd6}; - uint8_t bytesprops3[] = {0x12, 0x26, 0xac, 0x35, 0x5f, 0x3c, 0x92, 0x2c, 0xa2, 0x33, 0x5e, 0x87, 0x95, 0x3a, - 0x8, 0xbf, 0xaa, 0xfa, 0x56, 0x4a, 0x73, 0x1a, 0xe0, 0x66, 0xba, 0xec, 0x4c}; - uint8_t bytesprops6[] = {0x53, 0x76, 0x46, 0x33, 0x92, 0x54, 0x4d, 0xdf, 0x15, 0x2, 0xbf, 0x3b, 0x0, - 0x0, 0x23, 0x2f, 0x9f, 0xfd, 0x8, 0x81, 0x30, 0x2e, 0x19, 0xd1, 0xf7}; - uint8_t bytesprops5[] = {0xfa, 0x31, 0xec, 0x44, 0x98, 0x91, 0x89, 0x31, 0xaa}; - uint8_t bytesprops8[] = {0x93, 0x52, 0xa7, 0x9b, 0x6b}; - uint8_t bytesprops7[] = {0x40, 0xfd, 0x5e, 0xe6, 0xb4, 0xb5, 0x24, 0xf5, 0xdb, 0xf5, 0xa2, 0xe0, 0x15, 0xcc, - 0xe7, 0xf4, 0xaf, 0xd4, 0xae, 0x66, 0x0, 0xe1, 0xba, 0xb3, 0x6b, 0x76, 0x17}; - uint8_t bytesprops9[] = {0xc8, 0xab, 0x7c, 0xe3, 0x9f, 0xca, 0xd0, 0x1e, 0x61, 0xc7}; - uint8_t bytesprops10[] = {0xd4, 0x2a, 0x9e, 0x41, 0x9a, 0xf9, 0x7f, 0xd1, 0x3c, 0xbf, 0xd, 0xa}; - uint8_t bytesprops11[] = {0x16, 0xbf, 0xdf, 0xf, 0x5f, 0xea, 0xf1, 0xa3, - 0x2b, 0xaf, 0x57, 0xbb, 0xb8, 0x33, 0xc2, 0x1c}; - uint8_t bytesprops13[] = {0xe5, 0x2d}; - uint8_t bytesprops12[] = {0x56, 0xee, 0x96, 0x3d, 0x66, 0x77, 0xda, 0x39, 0xc8, 0x4}; - uint8_t bytesprops14[] = {0x23, 0x6d}; - uint8_t bytesprops15[] = {0xd, 0xae, 0xaa, 0x58, 0xce, 0x67, 0xba, 0xff, 0x99, - 0x3c, 0xdc, 0x14, 0x6b, 0x71, 0x4, 0xe3, 0x57, 0x81}; - uint8_t bytesprops16[] = {0xe0, 0xfd, 0x5e, 0xb8, 0xf8, 0x78, 0xf8, 0x11, 0xb4, 0xed, - 0xc1, 0x5f, 0x7d, 0x9b, 0x20, 0x3f, 0xd4, 0x41, 0xaf}; - uint8_t bytesprops18[] = {0x1a, 0xf7, 0x56, 0xf3, 0x99, 0x1b, 0x65, 0x5c, 0xd5, 0x3e, 0xdb, 0x1, 0x19, 0xf4, - 0x58, 0x9a, 0xfb, 0xac, 0xfe, 0x59, 0xee, 0x39, 0x52, 0xf3, 0x16, 0x13, 0xce}; - uint8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c, 0xe6, 0x3d, 0xff, 0x6a, 0x49, 0x27, 0x53, 0xc5, 0x17, 0x84, 0x21, 0x42, 0x11, 0x0, 0x11, 0xec, 0xca, 0x3a, + 0xc8, 0xe, 0x19, 0x59, 0x64, 0x91, 0x79, 0x36, 0x3a, 0xab, 0x2d, 0x14, 0x20, 0xc2, 0x0, 0x17, 0xf1, 0x9c, 0xb1, + 0x91, 0x88, 0x13, 0x68, 0xd, 0x80, 0xbb, 0x50, 0xb6, 0xef, 0xad, 0x23, 0x99, 0x79, 0x30, 0x6f, 0x27, 0x9e, 0x47, + 0x95, 0x0, 0x1d, 0x3e, 0x1d, 0x47, 0xa1, 0x4b, 0xce, 0x2c, 0xb7, 0x15, 0x75, 0x7b, 0xef, 0xe3, 0x79, 0xd6, 0xee, + 0xfb, 0x9d, 0x3f, 0x93, 0x21, 0x2c, 0x58, 0x51, 0xb4, 0xb, 0x46, 0xfb, 0x50, 0x0, 0x11, 0xc, 0xc0, 0xd1, 0x37, + 0x87, 0xcd, 0x66, 0x86, 0xb5, 0xaa, 0x29, 0x78, 0x43, 0x57, 0x2e, 0xbe, 0x45}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x65}; + uint8_t bytesprops0[] = {0x1e, 0x50, 0xf0, 0x7b, 0xf2, 0x8c, 0xd}; + uint8_t bytesprops2[] = {0xde, 0x91, 0x9a, 0xfc, 0x1b, 0xa3, 0x93, 0x98, 0xcb}; + uint8_t bytesprops3[] = {0xa8}; + uint8_t bytesprops5[] = {0x3a, 0xc6, 0xb7, 0xc0, 0xda, 0x61, 0x6c, 0x5b, 0x7f, 0x4e, 0x72, 0xce, + 0xf5, 0x98, 0xec, 0xc4, 0xc6, 0x6c, 0x97, 0x1a, 0xc3, 0xbc, 0x5f}; + uint8_t bytesprops4[] = {0xed, 0x34, 0x92, 0x7d, 0x13, 0xfc, 0x47, 0x3d, 0x5e, 0x2c, + 0xf, 0x75, 0x75, 0x84, 0xc4, 0x8f, 0xe9, 0xf0, 0x16}; + uint8_t bytesprops6[] = {0x9c, 0x3e, 0xe, 0x3f, 0xd8, 0x5e, 0x67, 0xc5, 0x92}; + uint8_t bytesprops7[] = {0x7c, 0x3e, 0x88, 0xbb, 0xd6, 0x77, 0x32}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0xee, 0x55, 0xa1, 0x61, 0x76, 0xb2, 0x21, 0x70, 0xaf, 0xc5, 0x5a, 0x7a, + 0x3c, 0x6, 0x43, 0xa2, 0xd0, 0xb1, 0x1f, 0x1e, 0x17, 0x71, 0x67, 0x31}; + uint8_t bytesprops10[] = {0x19, 0x11, 0xb, 0x6, 0x11, 0xb1, 0xb9, 0xc, 0x2b}; + uint8_t bytesprops12[] = {0xa3, 0x9c, 0xb7, 0x15, 0xc3, 0xc1, 0x7, 0x5d, 0x2f, 0x7c, 0xfd, + 0xab, 0x1f, 0xbe, 0x5b, 0x20, 0x34, 0xe3, 0xc3, 0xd6, 0x3}; + uint8_t bytesprops11[] = {0x61, 0xb4, 0x55}; + uint8_t bytesprops14[] = {0x40, 0xc2, 0xea, 0xd1, 0x60, 0x84, 0x0, 0x90, 0x54}; + uint8_t bytesprops13[] = {0xf0, 0x97, 0xcd, 0xee, 0x5c, 0x48}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17354}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 205}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops3}, .v = {11, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops5}, .v = {25, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28259}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops7}, .v = {5, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1040}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9595}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops12}, .v = {2, (char*)&bytesprops13}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops15}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops16}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {28, (char*)&bytesprops17}, .v = {27, (char*)&bytesprops18}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops0}, .v = {1, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5364}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22212}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops4}, .v = {23, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9518}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5171}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30792}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2410}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21813}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30176}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops11}, .v = {21, (char*)&bytesprops12}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops13}, .v = {9, (char*)&bytesprops14}}}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xf0, 0xbf, 0xbe, 0x3b, 0x97, 0x96, 0x80, 0xe8, 0xe6, - 0xbd, 0xdf, 0xd0, 0x95, 0x64, 0x5f, 0xf1, 0x69, 0xa8}; - uint8_t byteswillprops2[] = {0x61, 0x76, 0xe7, 0x3e, 0xaa, 0x77, 0x92, 0xfe, 0xe3, 0xe1, 0x3e, 0x93, - 0x88, 0x78, 0x92, 0x2, 0x3d, 0x40, 0xc0, 0x29, 0x5f, 0x73, 0x33}; - uint8_t byteswillprops1[] = {0xff, 0xa, 0x3c, 0x3f}; - uint8_t byteswillprops3[] = {0xd0, 0x66, 0xa3, 0x15, 0x7e, 0x6b, 0xd, 0xc0, 0x25, 0xc7, 0x4d, 0x63, 0xb9, 0xb5, - 0xc2, 0x20, 0xc1, 0x17, 0xa9, 0x22, 0xff, 0x90, 0x3d, 0x18, 0x15, 0xa8, 0x24, 0x9}; - uint8_t byteswillprops5[] = {0x5a, 0xac, 0xd5, 0xd7, 0x94, 0xc, 0x23, 0x2c}; - uint8_t byteswillprops4[] = {0xa1, 0x5d, 0xdb, 0x55, 0x85, 0x92, 0xdb, 0x8d, 0x5f, - 0xc5, 0x0, 0x6, 0x61, 0xe0, 0xc0, 0x4c, 0xc4, 0x70}; - uint8_t byteswillprops7[] = {0xe3, 0xc7, 0x56, 0xa9, 0xfb, 0x8d, 0xfc, 0x72, 0x94, 0xa7, - 0x86, 0x73, 0x7, 0x98, 0x11, 0xa7, 0xdf, 0xfd, 0x5e, 0xd5, - 0x56, 0x56, 0x80, 0xc1, 0x6, 0x75, 0x84, 0xb7, 0xe8, 0x72}; - uint8_t byteswillprops6[] = {0xf5}; - uint8_t byteswillprops8[] = {0x8e, 0x36, 0xac, 0x4a, 0x14, 0xb, 0xb, 0xef, 0x51, 0x8b, 0xcb, 0x21, 0x26, 0xb4}; - uint8_t byteswillprops9[] = {0x4d, 0x4c, 0xa5, 0xd2, 0x9a, 0xfd, 0x34, 0x8d, 0x68, 0x42}; + uint8_t byteswillprops0[] = {0xc2, 0xf5, 0xfe, 0x7e, 0x77, 0x69, 0x23, 0x8e, 0xd6, 0x83, + 0xf8, 0x4f, 0xf8, 0xc4, 0xaf, 0x4d, 0x63, 0x6b, 0x33}; + uint8_t byteswillprops1[] = {0xec, 0xab, 0x44, 0xad, 0x43, 0x5d, 0x55, 0xc0}; + uint8_t byteswillprops2[] = {0xdc, 0xf6, 0x99, 0x10, 0xa2, 0x26, 0xd8, 0x4b, 0xe8, 0x78, + 0x76, 0xae, 0x3b, 0xfe, 0xa5, 0x87, 0xbe, 0x4, 0xb4, 0x4a, + 0x86, 0x7e, 0x4f, 0xc3, 0x6d, 0x6d, 0xf, 0xc5, 0x8, 0x19}; + uint8_t byteswillprops4[] = {0xee, 0x44, 0x23, 0x35, 0x53, 0xa0, 0x42, 0xf2}; + uint8_t byteswillprops3[] = {0xa7, 0xc2, 0xf4, 0x70, 0xf5, 0x3d, 0xee, 0x11, 0xc9}; + uint8_t byteswillprops5[] = {0x65, 0xdd, 0x85, 0x93, 0x41, 0x15, 0xb, 0x8b, 0x5c, 0x9d, 0x83, 0x74, + 0xd0, 0x43, 0x5f, 0x49, 0xef, 0x1c, 0x20, 0xe8, 0xa8, 0x5d, 0xb7, 0x51}; + uint8_t byteswillprops7[] = {0x88, 0x8f, 0xe5, 0xe1, 0x55, 0xc2, 0x6c, 0x62, 0x25, 0x8d, 0xc8, 0x31, 0x52, + 0x60, 0xfe, 0xe1, 0xc0, 0x88, 0x3b, 0x7a, 0x60, 0xd8, 0x43, 0x67, 0x52}; + uint8_t byteswillprops6[] = {0xd8, 0x9, 0xc6, 0xc0}; + uint8_t byteswillprops8[] = {0xb4, 0xcf, 0xb2, 0x78, 0x2, 0x8e}; + uint8_t byteswillprops9[] = {0xf0, 0x11, 0xfe, 0xa2, 0x9b, 0x30, 0xb4, 0xf3, 0x73, 0xc3, 0xdf, 0x2, 0xb3, 0xa8, + 0x95, 0x46, 0xae, 0x96, 0x76, 0x15, 0xbc, 0x88, 0x13, 0xd5, 0xe2, 0x28, 0x89, 0x52}; + uint8_t byteswillprops10[] = {0x2e, 0xcb, 0x34, 0x96, 0xd, 0x17, 0xd6, 0x92, 0x34, 0xe1, 0xfd, 0x85, 0xd7, 0xdf}; + uint8_t byteswillprops11[] = {0xec, 0x3b, 0xe4, 0x24, 0xb0, 0x85, 0x79, 0x5a, 0x67, 0x3, + 0x11, 0xbc, 0xe6, 0x3d, 0xff, 0x6a, 0x49, 0x27, 0x53, 0xc5}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {4, (char*)&byteswillprops1}, .v = {23, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26779}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6431}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22229}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 220}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {18, (char*)&byteswillprops4}, .v = {8, (char*)&byteswillprops5}}}}, + .value = {.pair = {.k = {9, (char*)&byteswillprops3}, .v = {8, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10510}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops5}}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {1, (char*)&byteswillprops6}, .v = {30, (char*)&byteswillprops7}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14287}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30203}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&byteswillprops9}}}, + .value = {.pair = {.k = {4, (char*)&byteswillprops6}, .v = {25, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11277}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30939}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4379}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22271}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&byteswillprops11}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16913}}, }; - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8, 0x2c, 0x28, 0x5b, 0x77, 0xfd, 0xcd, 0x18, 0xa7, 0xc7, 0xee, 0x30, 0xab, 0x1, 0x6a, - 0xce, 0x0, 0xf5, 0xf3, 0x90, 0xa9, 0x8, 0xe2, 0xb4, 0x86, 0x9a, 0x7d, 0xd6, 0xc2}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb5, 0x61, 0x4f, 0x80, 0x28, 0xbc, 0x17}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xec, 0xca, 0x3a, 0xc8, 0xe, 0x19, 0x59, 0x64, 0x91, + 0x79, 0x36, 0x3a, 0xab, 0x2d, 0x14, 0x20, 0xc2}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xf1, 0x9c, 0xb1, 0x91, 0x88, 0x13, 0x68, 0xd, 0x80, 0xbb, 0x50, 0xb6, + 0xef, 0xad, 0x23, 0x99, 0x79, 0x30, 0x6f, 0x27, 0x9e, 0x47, 0x95}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 3521; - uint8_t client_id_bytes[] = {0xcd, 0x41, 0xf7, 0x6, 0x81, 0x36, 0xc4, 0xca, 0xc0, 0x3c, 0xd0, 0x7a, - 0xea, 0x3e, 0x17, 0x12, 0xc3, 0xd0, 0xdd, 0x2, 0x11, 0x4c, 0x92, 0x73}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 12883; + uint8_t client_id_bytes[] = {0xbf, 0xc2, 0x33, 0x88, 0x1d, 0x9, 0xf0}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x65, 0x42, 0x56, 0x30, 0x5e, 0x62, 0xe7, 0x1d, 0xfa, 0xa, 0xcb, 0xe0}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x3e, 0x1d, 0x47, 0xa1, 0x4b, 0xce, 0x2c, 0xb7, 0x15, 0x75, 0x7b, 0xef, 0xe3, 0x79, 0xd6, + 0xee, 0xfb, 0x9d, 0x3f, 0x93, 0x21, 0x2c, 0x58, 0x51, 0xb4, 0xb, 0x46, 0xfb, 0x50}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xf0, 0xb1, 0xbb, 0xf4, 0xfa, 0x63, 0x22, 0xc8, 0x50, 0x77, - 0xbd, 0xa3, 0x6d, 0x7c, 0x83, 0x35, 0x2a, 0xb1, 0xa9, 0x5d}; - lwmqtt_string_t password = {20, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xc, 0xc0, 0xd1, 0x37, 0x87, 0xcd, 0x66, 0x86, 0xb5, + 0xaa, 0x29, 0x78, 0x43, 0x57, 0x2e, 0xbe, 0x45}; + lwmqtt_string_t password = {17, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -9855,153 +10032,153 @@ TEST(Connect5QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "\v\169[\202\FS\206\145\142I\167&I\169k\b\160XudF\138\227\147V\252\193\134\197", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\223\&5$\DELC3\210\149\FS\188b\147\NUL\203\&8\177\&6\141S\"\236\215C", _willMsg = -// "\137Fydy\130\218\t\246Eu\206\188[\241P\186\235\236", _willProps = [PropMessageExpiryInterval -// 2990,PropResponseInformation -// "\140\ACK\209r\251\156}\215\214\175%\201\144D\131\SOs455\STX[S\214",PropAuthenticationData -// "\206L\217Y\245FH\186@DM\249\203,c"]}), _cleanSession = True, _keepAlive = 17383, _connID = -// "\146\157\196~\185Q\216\228Q\237\164K\154M\STX\226\133\244\158\188\177 \245\198\168", _properties = -// [PropSubscriptionIdentifierAvailable 68,PropServerReference "\152)\135'\252C@\162 -// Y\170ur\138\163C@:u\182r\234!\226j",PropTopicAlias 5481,PropAssignedClientIdentifier -// "\208\221\139\172\&9",PropSessionExpiryInterval 16158,PropReasonString -// "A\251\164\150K\ETB\138~\FSq[[\SI\188\252`\153\ESC{\189<",PropAuthenticationMethod -// "\168U\146\SO\224\ETB\EM\168\219\SUB\142dC\161?.\RS@\"h \\\130\179",PropMaximumQoS 213,PropServerKeepAlive -// 9294,PropTopicAlias 6235,PropContentType -// "\163\213Y\220\202@\186M\137\222\199\152\212\192wm\136\202Y\202\RS8\203p\185\aX\163\226m",PropSharedSubscriptionAvailable -// 140,PropCorrelationData "Q\182Q",PropReceiveMaximum 8023,PropSubscriptionIdentifier 4,PropRequestResponseInformation -// 133,PropRetainAvailable 18,PropResponseTopic "\191\169ND\b\142\194\215\160",PropRetainAvailable -// 116,PropServerKeepAlive 8260,PropSessionExpiryInterval 2573,PropSessionExpiryInterval 31411,PropMessageExpiryInterval -// 6846,PropReasonString "\174<\155\139\169\234r\239",PropReasonString -// "j\GS\SOH\234\252\176\160'd\137at\ACKX<\205_",PropUserProperty "\NULM\130\137Ic\162\176\141\135N:+\229\163" -// "\185Xv\184\247-\147\225\132x\171",PropContentType -// "\218\206\139C\144v\SO\248\CAN\DC1{\GSD\146\b\142\v,\235\202\210\&0\255\175:",PropAuthenticationData -// "BYW\198P\203\129&\b\186 )m\207z\189\131\ENQ\180\140\141\201\151\174\167\NAK\199",PropPayloadFormatIndicator -// 131,PropResponseTopic "O3\bd\236^\SUB\148\EOT\DC4\159b#\NAK\210"]} +// ConnectRequest {_username = Just "\148o\200m\186<\174\187@H*\199\199k\241N\207z\181$\235z\253j\134{", _password = +// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "", _willMsg = +// "U\STX\188\199\130;", _willProps = [PropPayloadFormatIndicator 132,PropServerReference +// "\170\132t\195V",PropPayloadFormatIndicator 178,PropRequestResponseInformation 96,PropServerKeepAlive +// 9172,PropAssignedClientIdentifier "i\192",PropRequestResponseInformation 37,PropMessageExpiryInterval +// 19524,PropSharedSubscriptionAvailable 118,PropWillDelayInterval 17746,PropSubscriptionIdentifierAvailable +// 127,PropSessionExpiryInterval 472,PropResponseInformation +// "\141\250qW\223\253\SUB\252\&4D\170\137\DC3n\b\183\208=\153\236\159\201\159",PropSharedSubscriptionAvailable +// 150,PropWildcardSubscriptionAvailable 221,PropSubscriptionIdentifierAvailable 233,PropResponseTopic +// "",PropSubscriptionIdentifier 13,PropAssignedClientIdentifier +// "FI\195a\235\207\ETBV\146e\ESC\140\DLE\203G\248\175\219\226\&3\238\245\183\249\169\145\DC3",PropRetainAvailable +// 121,PropServerReference "<\174D\171p#\215\&0\252{Hz\218\f5f\185\189\SOH\246?",PropMessageExpiryInterval +// 15394,PropServerKeepAlive 17437,PropAssignedClientIdentifier "q\129\t\232g\vx\DC3\247V2,\240",PropAuthenticationData +// "[\215\255\168\194\203\r\DC39T\145e\207\223\n\154\152",PropContentType +// "7>\218\155\&7\EOT\194?4\219\&9\147^[\208\SI\DC2\ETB\128\a",PropAuthenticationData "\232\244r\172\150\172\202\r"]}), +// _cleanSession = True, _keepAlive = 3904, _connID = "\197#\190r4\236\133\t\SIY\198\226\213\244\145", _properties = +// [PropAssignedClientIdentifier +// "\232\255\&0\209\230;\163\SOH\DC1W\195\245\151\152.k4\199\184\160\SOHK5\253\bs\227\243",PropRetainAvailable +// 233,PropTopicAliasMaximum 12059,PropServerKeepAlive 30416,PropServerReference +// "\STX\233(\186\n\178\236",PropWildcardSubscriptionAvailable 183,PropWillDelayInterval +// 3122,PropRequestProblemInformation 134,PropResponseInformation "\210\191B\190\229\138\&0",PropContentType +// "F|\179y\166H\200>!\175\227\154\151\139\206Z\151\179S\EM\251",PropRequestProblemInformation +// 132,PropResponseInformation "L_\172\207_lX\164\STX4J\236\211!\245\STX[\128\&23\163] ",PropUserProperty "\168" +// "\183T\242\131\181\r\229\191\200\212\252\154\175\\Q\167\\\182\232T\188\n\EOT\130"]} TEST(Connect5QCTest, Encode28) { uint8_t pkt[] = { - 0x10, 0xed, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6e, 0x43, 0xe7, 0xc7, 0x2, 0x29, 0x44, 0x1c, 0x0, - 0x19, 0x98, 0x29, 0x87, 0x27, 0xfc, 0x43, 0x40, 0xa2, 0x20, 0x59, 0xaa, 0x75, 0x72, 0x8a, 0xa3, 0x43, 0x40, 0x3a, - 0x75, 0xb6, 0x72, 0xea, 0x21, 0xe2, 0x6a, 0x23, 0x15, 0x69, 0x12, 0x0, 0x5, 0xd0, 0xdd, 0x8b, 0xac, 0x39, 0x11, - 0x0, 0x0, 0x3f, 0x1e, 0x1f, 0x0, 0x15, 0x41, 0xfb, 0xa4, 0x96, 0x4b, 0x17, 0x8a, 0x7e, 0x1c, 0x71, 0x5b, 0x5b, - 0xf, 0xbc, 0xfc, 0x60, 0x99, 0x1b, 0x7b, 0xbd, 0x3c, 0x15, 0x0, 0x18, 0xa8, 0x55, 0x92, 0xe, 0xe0, 0x17, 0x19, - 0xa8, 0xdb, 0x1a, 0x8e, 0x64, 0x43, 0xa1, 0x3f, 0x2e, 0x1e, 0x40, 0x22, 0x68, 0x20, 0x5c, 0x82, 0xb3, 0x24, 0xd5, - 0x13, 0x24, 0x4e, 0x23, 0x18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0x86, 0xc5}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x98, 0x29, 0x87, 0x27, 0xfc, 0x43, 0x40, 0xa2, 0x20, 0x59, 0xaa, 0x75, 0x72, - 0x8a, 0xa3, 0x43, 0x40, 0x3a, 0x75, 0xb6, 0x72, 0xea, 0x21, 0xe2, 0x6a}; - uint8_t bytesprops1[] = {0xd0, 0xdd, 0x8b, 0xac, 0x39}; - uint8_t bytesprops2[] = {0x41, 0xfb, 0xa4, 0x96, 0x4b, 0x17, 0x8a, 0x7e, 0x1c, 0x71, 0x5b, - 0x5b, 0xf, 0xbc, 0xfc, 0x60, 0x99, 0x1b, 0x7b, 0xbd, 0x3c}; - uint8_t bytesprops3[] = {0xa8, 0x55, 0x92, 0xe, 0xe0, 0x17, 0x19, 0xa8, 0xdb, 0x1a, 0x8e, 0x64, - 0x43, 0xa1, 0x3f, 0x2e, 0x1e, 0x40, 0x22, 0x68, 0x20, 0x5c, 0x82, 0xb3}; - uint8_t bytesprops4[] = {0xa3, 0xd5, 0x59, 0xdc, 0xca, 0x40, 0xba, 0x4d, 0x89, 0xde, 0xc7, 0x98, 0xd4, 0xc0, 0x77, - 0x6d, 0x88, 0xca, 0x59, 0xca, 0x1e, 0x38, 0xcb, 0x70, 0xb9, 0x7, 0x58, 0xa3, 0xe2, 0x6d}; - uint8_t bytesprops5[] = {0x51, 0xb6, 0x51}; - uint8_t bytesprops6[] = {0xbf, 0xa9, 0x4e, 0x44, 0x8, 0x8e, 0xc2, 0xd7, 0xa0}; - uint8_t bytesprops7[] = {0xae, 0x3c, 0x9b, 0x8b, 0xa9, 0xea, 0x72, 0xef}; - uint8_t bytesprops8[] = {0x6a, 0x1d, 0x1, 0xea, 0xfc, 0xb0, 0xa0, 0x27, 0x64, - 0x89, 0x61, 0x74, 0x6, 0x58, 0x3c, 0xcd, 0x5f}; - uint8_t bytesprops10[] = {0xb9, 0x58, 0x76, 0xb8, 0xf7, 0x2d, 0x93, 0xe1, 0x84, 0x78, 0xab}; - uint8_t bytesprops9[] = {0x0, 0x4d, 0x82, 0x89, 0x49, 0x63, 0xa2, 0xb0, 0x8d, 0x87, 0x4e, 0x3a, 0x2b, 0xe5, 0xa3}; - uint8_t bytesprops11[] = {0xda, 0xce, 0x8b, 0x43, 0x90, 0x76, 0xe, 0xf8, 0x18, 0x11, 0x7b, 0x1d, 0x44, - 0x92, 0x8, 0x8e, 0xb, 0x2c, 0xeb, 0xca, 0xd2, 0x30, 0xff, 0xaf, 0x3a}; - uint8_t bytesprops12[] = {0x42, 0x59, 0x57, 0xc6, 0x50, 0xcb, 0x81, 0x26, 0x8, 0xba, 0x20, 0x29, 0x6d, 0xcf, - 0x7a, 0xbd, 0x83, 0x5, 0xb4, 0x8c, 0x8d, 0xc9, 0x97, 0xae, 0xa7, 0x15, 0xc7}; - uint8_t bytesprops13[] = {0x4f, 0x33, 0x8, 0x64, 0xec, 0x5e, 0x1a, 0x94, 0x4, 0x14, 0x9f, 0x62, 0x23, 0x15, 0xd2}; + 0x10, 0xb1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0xf, 0x40, 0x96, 0x1, 0x12, 0x0, 0x1c, 0xe8, + 0xff, 0x30, 0xd1, 0xe6, 0x3b, 0xa3, 0x1, 0x11, 0x57, 0xc3, 0xf5, 0x97, 0x98, 0x2e, 0x6b, 0x34, 0xc7, 0xb8, 0xa0, + 0x1, 0x4b, 0x35, 0xfd, 0x8, 0x73, 0xe3, 0xf3, 0x25, 0xe9, 0x22, 0x2f, 0x1b, 0x13, 0x76, 0xd0, 0x1c, 0x0, 0x7, + 0x2, 0xe9, 0x28, 0xba, 0xa, 0xb2, 0xec, 0x28, 0xb7, 0x18, 0x0, 0x0, 0xc, 0x32, 0x17, 0x86, 0x1a, 0x0, 0x7, + 0xd2, 0xbf, 0x42, 0xbe, 0xe5, 0x8a, 0x30, 0x3, 0x0, 0x15, 0x46, 0x7c, 0xb3, 0x79,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 0x1b, 0x8c, 0x10, 0xcb, 0x47, 0xf8, 0xaf, 0xdb, + 0xe2, 0x33, 0xee, 0xf5, 0xb7, 0xf9, 0xa9, 0x91, 0x13, 0x25, 0x79, 0x1c, 0x0, 0x15, 0x3c, 0xae, 0x44, 0xab, 0x70, + 0x23, 0xd7, 0x30, 0xfc, 0x7b, 0x48, 0x7a, 0xda, 0xc, 0x35, 0x66, 0xb9, 0xbd, 0x1, 0xf6, 0x3f, 0x2, 0x0, 0x0, + 0x3c, 0x22, 0x13, 0x44, 0x1d, 0x12, 0x0, 0xd, 0x71, 0x81, 0x9, 0xe8, 0x67, 0xb, 0x78, 0x13, 0xf7, 0x56, 0x32, + 0x2c, 0xf0, 0x16, 0x0, 0x11, 0x5b, 0xd7, 0xff, 0xa8, 0xc2, 0xcb, 0xd, 0x13, 0x39, 0x54, 0x91, 0x65, 0xcf, 0xdf, + 0xa, 0x9a, 0x98, 0x3, 0x0, 0x14, 0x37, 0x3e, 0xda, 0x9b, 0x37, 0x4, 0xc2, 0x3f, 0x34, 0xdb, 0x39, 0x93, 0x5e, + 0x5b, 0xd0, 0xf, 0x12, 0x17, 0x80, 0x7, 0x16, 0x0, 0x8, 0xe8, 0xf4, 0x72, 0xac, 0x96, 0xac, 0xca, 0xd, 0x0, + 0x0, 0x0, 0x6, 0x55, 0x2, 0xbc, 0xc7, 0x82, 0x3b, 0x0, 0x1a, 0x94, 0x6f, 0xc8, 0x6d, 0xba, 0x3c, 0xae, 0xbb, + 0x40, 0x48, 0x2a, 0xc7, 0xc7, 0x6b, 0xf1, 0x4e, 0xcf, 0x7a, 0xb5, 0x24, 0xeb, 0x7a, 0xfd, 0x6a, 0x86, 0x7b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe8, 0xff, 0x30, 0xd1, 0xe6, 0x3b, 0xa3, 0x1, 0x11, 0x57, 0xc3, 0xf5, 0x97, 0x98, + 0x2e, 0x6b, 0x34, 0xc7, 0xb8, 0xa0, 0x1, 0x4b, 0x35, 0xfd, 0x8, 0x73, 0xe3, 0xf3}; + uint8_t bytesprops1[] = {0x2, 0xe9, 0x28, 0xba, 0xa, 0xb2, 0xec}; + uint8_t bytesprops2[] = {0xd2, 0xbf, 0x42, 0xbe, 0xe5, 0x8a, 0x30}; + uint8_t bytesprops3[] = {0x46, 0x7c, 0xb3, 0x79, 0xa6, 0x48, 0xc8, 0x3e, 0x21, 0xaf, 0xe3, + 0x9a, 0x97, 0x8b, 0xce, 0x5a, 0x97, 0xb3, 0x53, 0x19, 0xfb}; + uint8_t bytesprops4[] = {0x4c, 0x5f, 0xac, 0xcf, 0x5f, 0x6c, 0x58, 0xa4, 0x2, 0x34, 0x4a, 0xec, + 0xd3, 0x21, 0xf5, 0x2, 0x5b, 0x80, 0x32, 0x33, 0xa3, 0x5d, 0x20}; + uint8_t bytesprops6[] = {0xb7, 0x54, 0xf2, 0x83, 0xb5, 0xd, 0xe5, 0xbf, 0xc8, 0xd4, 0xfc, 0x9a, + 0xaf, 0x5c, 0x51, 0xa7, 0x5c, 0xb6, 0xe8, 0x54, 0xbc, 0xa, 0x4, 0x82}; + uint8_t bytesprops5[] = {0xa8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5481}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16158}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9294}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6235}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8023}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8260}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2573}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31411}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6846}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops9}, .v = {11, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12059}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30416}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3122}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops5}, .v = {24, (char*)&bytesprops6}}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x8c, 0x6, 0xd1, 0x72, 0xfb, 0x9c, 0x7d, 0xd7, 0xd6, 0xaf, 0x25, 0xc9, - 0x90, 0x44, 0x83, 0xe, 0x73, 0x34, 0x35, 0x35, 0x2, 0x5b, 0x53, 0xd6}; - uint8_t byteswillprops1[] = {0xce, 0x4c, 0xd9, 0x59, 0xf5, 0x46, 0x48, 0xba, - 0x40, 0x44, 0x4d, 0xf9, 0xcb, 0x2c, 0x63}; + uint8_t byteswillprops0[] = {0xaa, 0x84, 0x74, 0xc3, 0x56}; + uint8_t byteswillprops1[] = {0x69, 0xc0}; + uint8_t byteswillprops2[] = {0x8d, 0xfa, 0x71, 0x57, 0xdf, 0xfd, 0x1a, 0xfc, 0x34, 0x44, 0xaa, 0x89, + 0x13, 0x6e, 0x8, 0xb7, 0xd0, 0x3d, 0x99, 0xec, 0x9f, 0xc9, 0x9f}; + uint8_t byteswillprops3[] = {0}; + uint8_t byteswillprops4[] = {0x46, 0x49, 0xc3, 0x61, 0xeb, 0xcf, 0x17, 0x56, 0x92, 0x65, 0x1b, 0x8c, 0x10, 0xcb, + 0x47, 0xf8, 0xaf, 0xdb, 0xe2, 0x33, 0xee, 0xf5, 0xb7, 0xf9, 0xa9, 0x91, 0x13}; + uint8_t byteswillprops5[] = {0x3c, 0xae, 0x44, 0xab, 0x70, 0x23, 0xd7, 0x30, 0xfc, 0x7b, 0x48, + 0x7a, 0xda, 0xc, 0x35, 0x66, 0xb9, 0xbd, 0x1, 0xf6, 0x3f}; + uint8_t byteswillprops6[] = {0x71, 0x81, 0x9, 0xe8, 0x67, 0xb, 0x78, 0x13, 0xf7, 0x56, 0x32, 0x2c, 0xf0}; + uint8_t byteswillprops7[] = {0x5b, 0xd7, 0xff, 0xa8, 0xc2, 0xcb, 0xd, 0x13, 0x39, + 0x54, 0x91, 0x65, 0xcf, 0xdf, 0xa, 0x9a, 0x98}; + uint8_t byteswillprops8[] = {0x37, 0x3e, 0xda, 0x9b, 0x37, 0x4, 0xc2, 0x3f, 0x34, 0xdb, + 0x39, 0x93, 0x5e, 0x5b, 0xd0, 0xf, 0x12, 0x17, 0x80, 0x7}; + uint8_t byteswillprops9[] = {0xe8, 0xf4, 0x72, 0xac, 0x96, 0xac, 0xca, 0xd}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2990}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9172}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19524}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17746}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 472}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15394}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17437}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&byteswillprops9}}}, }; - lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xdf, 0x35, 0x24, 0x7f, 0x43, 0x33, 0xd2, 0x95, 0x1c, 0xbc, 0x62, 0x93, - 0x0, 0xcb, 0x38, 0xb1, 0x36, 0x8d, 0x53, 0x22, 0xec, 0xd7, 0x43}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x89, 0x46, 0x79, 0x64, 0x79, 0x82, 0xda, 0x9, 0xf6, 0x45, - 0x75, 0xce, 0xbc, 0x5b, 0xf1, 0x50, 0xba, 0xeb, 0xec}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0}; + lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x55, 0x2, 0xbc, 0xc7, 0x82, 0x3b}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 17383; - uint8_t client_id_bytes[] = {0x92, 0x9d, 0xc4, 0x7e, 0xb9, 0x51, 0xd8, 0xe4, 0x51, 0xed, 0xa4, 0x4b, 0x9a, - 0x4d, 0x2, 0xe2, 0x85, 0xf4, 0x9e, 0xbc, 0xb1, 0x20, 0xf5, 0xc6, 0xa8}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.keep_alive = 3904; + uint8_t client_id_bytes[] = {0xc5, 0x23, 0xbe, 0x72, 0x34, 0xec, 0x85, 0x9, 0xf, 0x59, 0xc6, 0xe2, 0xd5, 0xf4, 0x91}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xb, 0xa9, 0x5b, 0xca, 0x1c, 0xce, 0x91, 0x8e, 0x49, 0xa7, 0x26, 0x49, 0xa9, 0x6b, - 0x8, 0xa0, 0x58, 0x75, 0x64, 0x46, 0x8a, 0xe3, 0x93, 0x56, 0xfc, 0xc1, 0x86, 0xc5}; - lwmqtt_string_t password = {28, (char*)&password_bytes}; - opts.password = password; + uint8_t username_bytes[] = {0x94, 0x6f, 0xc8, 0x6d, 0xba, 0x3c, 0xae, 0xbb, 0x40, 0x48, 0x2a, 0xc7, 0xc7, + 0x6b, 0xf1, 0x4e, 0xcf, 0x7a, 0xb5, 0x24, 0xeb, 0x7a, 0xfd, 0x6a, 0x86, 0x7b}; + lwmqtt_string_t username = {26, (char*)&username_bytes}; + opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10010,157 +10187,165 @@ TEST(Connect5QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\167\237\156Mq\176\&7F\133;p\STX\164\219,\196,U\NUL\171\ETB\144M", _password = Just -// "\150'c\159\ETX\DC2\144\212TY\230:\SOHvc'\218\154\US2#1\183\&7", _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS2, _willTopic = "\STX\r\249A\250?#\SI\142\224\207\203C3\203\129\232\238\f>C\SUB\149\221\198\\1", -// _willMsg = "u}g.\134\182\153", _willProps = [PropMessageExpiryInterval 24813,PropTopicAlias -// 20635,PropWillDelayInterval 25175,PropAssignedClientIdentifier -// "U^\SOH\199\132\254\SYN\190\&9H\161\243\150/\206\176\205\148\187\186",PropAuthenticationData -// "\142\254Y]\DEL\217",PropRetainAvailable 125,PropRetainAvailable 237,PropServerReference -// "\aaL\251\227\&9\137\196A\133\&6`\132$ \247+\193\219z\164",PropResponseInformation -// "\136\&4\161",PropMaximumPacketSize 22005,PropRequestResponseInformation 98,PropAuthenticationData -// "@Q\v",PropServerReference "r\184\240\247\239='>\192\172-\b\v\195\227\160\130\178\191\252\DC4\140\138\179\a -// \181\145",PropSharedSubscriptionAvailable 24,PropAuthenticationMethod -// "q\244\237\162m\ESCa\221P\220\135\a*\232\205\226\207Z",PropAssignedClientIdentifier -// "H\177c\SYN\167\251\229S\245\EOTt\156\200\191\ENQ\a\t%\211}V\157\239@\DC4",PropSubscriptionIdentifier -// 26,PropRequestResponseInformation 104,PropRequestProblemInformation 220,PropSubscriptionIdentifierAvailable -// 19,PropAuthenticationData ">\179",PropAuthenticationMethod "\130\&3d\\\139c",PropSharedSubscriptionAvailable -// 91,PropReceiveMaximum 22548,PropRequestProblemInformation 26,PropReasonString -// "\216H\217k\DC4\183\191\180\143\165\224!\141\186\n\135e\155",PropAuthenticationData -// "\186\180\ACK\SOh\157\160\RSK\170p\132\197\&10n4>\189\GS\200\ESC",PropReceiveMaximum 12897,PropMaximumQoS -// 194,PropMessageExpiryInterval 18926]}), _cleanSession = False, _keepAlive = 2013, _connID = -// "\255\RST!?\165@\128+YC\181-\250\193\183\233\&7\RS\197x\SUB[?\f\227t", _properties = [PropServerReference -// "Ae\SO\241\196\223r\ETX\160%\209g\155\255'#\182\n\RS",PropReasonString -// "f\161\155\145p\179\208\SYN,\216M\235\161\DEL",PropSubscriptionIdentifier +// 17,PropReasonString +// "\ETB\179\226_(\215m\183\134\210\160\214\245)n\194j]I\205T\170o&h\192\157,",PropSubscriptionIdentifierAvailable +// 205,PropServerKeepAlive 439,PropResponseTopic +// "\155\204\228y\SUB\224\f\200(\165\189\241\\b9\141\205\239'\ETBV\SUB\DC1\229-\EOT'",PropTopicAlias +// 6588,PropServerKeepAlive 28469,PropReasonString "\220\131\238\SOHh\247\186\184\192%n\ACK",PropWillDelayInterval +// 6420,PropResponseTopic ";",PropReasonString +// "\213]\DC1\215\239B\DC3\139\161\NAK\147\135\ETX\DELL\148\&6#?\144\225\145j\231",PropAuthenticationData +// "I\v\fz$\216\249@\204 -\231\EM",PropMessageExpiryInterval 30414,PropSubscriptionIdentifierAvailable +// 228,PropSharedSubscriptionAvailable 117,PropPayloadFormatIndicator 40]} TEST(Connect5QCTest, Encode29) { uint8_t pkt[] = { - 0x10, 0xcf, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x7, 0xdd, 0x49, 0x1c, 0x0, 0x13, 0x41, 0x65, - 0xe, 0xf1, 0xc4, 0xdf, 0x72, 0x3, 0xa0, 0x25, 0xd1, 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x95, 0xdd, 0xc6, 0x5c, 0x31, 0x0, 0x7, 0x75, 0x7d, 0x67, 0x2e, 0x86, 0xb6, 0x99, 0x0, 0x17, 0xa7, - 0xed, 0x9c, 0x4d, 0x71, 0xb0, 0x37, 0x46, 0x85, 0x3b, 0x70, 0x2, 0xa4, 0xdb, 0x2c, 0xc4, 0x2c, 0x55, 0x0, 0xab, - 0x17, 0x90, 0x4d, 0x0, 0x18, 0x96, 0x27, 0x63, 0x9f, 0x3, 0x12, 0x90, 0xd4, 0x54, 0x59, 0xe6, 0x3a, 0x1, 0x76, - 0x63, 0x27, 0xda, 0x9a, 0x1f, 0x32, 0x23, 0x31, 0xb7, 0x37}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x41, 0x65, 0xe, 0xf1, 0xc4, 0xdf, 0x72, 0x3, 0xa0, 0x25, - 0xd1, 0x67, 0x9b, 0xff, 0x27, 0x23, 0xb6, 0xa, 0x1e}; - uint8_t bytesprops1[] = {0x66, 0xa1, 0x9b, 0x91, 0x3c, 0x61, 0x3, 0xa2, 0x3b, 0x30, - 0x5, 0xf6, 0xa1, 0xfb, 0x9d, 0x86, 0xe4, 0xac, 0x72}; - uint8_t bytesprops2[] = {0x39, 0x4e, 0x2c, 0x33, 0xd3}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0xd7, 0xd3, 0xd0, 0xa8, 0x66, 0x36, 0xab, 0x82}; + 0x10, 0xdb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x5f, 0xe1, 0xbb, 0x2, 0x2, 0x0, 0x0, 0x7b, + 0x8f, 0x12, 0x0, 0x16, 0xf9, 0xe1, 0x7, 0x15, 0xf, 0xd0, 0x83, 0x86, 0xd6, 0xa0, 0xb7, 0xf5, 0xef, 0x2a, 0x27, + 0xd3, 0x65, 0x57, 0xe6, 0x32, 0x66, 0xc4, 0x24, 0x12, 0x12, 0x0, 0x12, 0xfc, 0x43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 0x0, 0x19, 0xb2, 0x23, 0x2f, 0x92, 0x29, 0x3c, 0x13, 0xd, 0x12, 0x17, 0x15, 0x19, 0x79, + 0x21, 0x2f, 0xb6, 0x3, 0x0, 0x7, 0x50, 0x18, 0x3b, 0xb, 0xb9, 0xee, 0x49, 0x0, 0x4, 0xa6, 0x40, 0x7f, 0x8e, + 0x0, 0x14, 0x13, 0x78, 0xe2, 0xf5, 0x4a, 0x70, 0x94, 0x2, 0x25, 0x11, 0x8d, 0xf0, 0xa9, 0xfd, 0x3, 0x66, 0x64, + 0xc1, 0x74, 0x5e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf9, 0xe1, 0x7, 0x15, 0xf, 0xd0, 0x83, 0x86, 0xd6, 0xa0, 0xb7, + 0xf5, 0xef, 0x2a, 0x27, 0xd3, 0x65, 0x57, 0xe6, 0x32, 0x66, 0xc4}; + uint8_t bytesprops1[] = {0xfc, 0x43, 0xff, 0xe8, 0x9b, 0x22, 0xce, 0xf2, 0xae, + 0xfa, 0xc2, 0x69, 0xb8, 0xb8, 0x8e, 0x2d, 0x24, 0x2e}; + uint8_t bytesprops2[] = {0x6e, 0x2e, 0x9a, 0x2f, 0x7, 0xde, 0x6d, 0x7d, 0xa1, 0xa5, 0x1b, 0xb7, 0x5b, 0x9a, 0xc1}; + uint8_t bytesprops3[] = {0xc7, 0x24, 0x1d, 0x18, 0x5, 0x29, 0x4a, 0xad, 0xaf, 0x30, 0xb, 0x78, 0x27, 0x9a}; + uint8_t bytesprops4[] = {0xb8, 0xe4, 0x47, 0xf1, 0xa1, 0xe6, 0xd, 0x2b, 0x18, 0x84, 0x9c}; + uint8_t bytesprops6[] = {0x51, 0x64, 0x64, 0xfc, 0xf5, 0x8d, 0xcb}; + uint8_t bytesprops5[] = {0xbe, 0xf2, 0xa1, 0x4d, 0xb9, 0xe1, 0x8f, 0x2d, 0xe8}; + uint8_t bytesprops7[] = {0x28, 0x43, 0xa4, 0x84, 0x53, 0xa0, 0x41, 0x55, 0x33, 0xd0, 0x3e, + 0x70, 0xb3, 0xd0, 0x16, 0x2c, 0xd8, 0x4d, 0xeb, 0xa1, 0x7f}; + uint8_t bytesprops8[] = {0x17, 0xb3, 0xe2, 0x5f, 0x28, 0xd7, 0x6d, 0xb7, 0x86, 0xd2, 0xa0, 0xd6, 0xf5, 0x29, + 0x6e, 0xc2, 0x6a, 0x5d, 0x49, 0xcd, 0x54, 0xaa, 0x6f, 0x26, 0x68, 0xc0, 0x9d, 0x2c}; + uint8_t bytesprops9[] = {0x9b, 0xcc, 0xe4, 0x79, 0x1a, 0xe0, 0xc, 0xc8, 0x28, 0xa5, 0xbd, 0xf1, 0x5c, 0x62, + 0x39, 0x8d, 0xcd, 0xef, 0x27, 0x17, 0x56, 0x1a, 0x11, 0xe5, 0x2d, 0x4, 0x27}; + uint8_t bytesprops10[] = {0xdc, 0x83, 0xee, 0x1, 0x68, 0xf7, 0xba, 0xb8, 0xc0, 0x25, 0x6e, 0x6}; + uint8_t bytesprops11[] = {0x3b}; + uint8_t bytesprops12[] = {0xd5, 0x5d, 0x11, 0xd7, 0xef, 0x42, 0x13, 0x8b, 0xa1, 0x15, 0x93, 0x87, + 0x3, 0x7f, 0x4c, 0x94, 0x36, 0x23, 0x3f, 0x90, 0xe1, 0x91, 0x6a, 0xe7}; + uint8_t bytesprops13[] = {0x49, 0xb, 0xc, 0x7a, 0x24, 0xd8, 0xf9, 0x40, 0xcc, 0x20, 0x2d, 0xe7, 0x19}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10790}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31631}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21182}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops5}, .v = {7, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9172}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 439}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6588}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28469}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6420}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30414}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 40}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x55, 0x5e, 0x1, 0xc7, 0x84, 0xfe, 0x16, 0xbe, 0x39, 0x48, - 0xa1, 0xf3, 0x96, 0x2f, 0xce, 0xb0, 0xcd, 0x94, 0xbb, 0xba}; - uint8_t byteswillprops1[] = {0x8e, 0xfe, 0x59, 0x5d, 0x7f, 0xd9}; - uint8_t byteswillprops2[] = {0x7, 0x61, 0x4c, 0xfb, 0xe3, 0x39, 0x89, 0xc4, 0x41, 0x85, 0x36, - 0x60, 0x84, 0x24, 0x20, 0xf7, 0x2b, 0xc1, 0xdb, 0x7a, 0xa4}; - uint8_t byteswillprops3[] = {0x88, 0x34, 0xa1}; - uint8_t byteswillprops4[] = {0x40, 0x51, 0xb}; - uint8_t byteswillprops5[] = {0x72, 0xb8, 0xf0, 0xf7, 0xef, 0x3d, 0x27, 0x3e, 0xc0, 0xac, 0x2d, 0x8, 0xb, 0xc3, - 0xe3, 0xa0, 0x82, 0xb2, 0xbf, 0xfc, 0x14, 0x8c, 0x8a, 0xb3, 0x7, 0x20, 0xb5, 0x91}; - uint8_t byteswillprops6[] = {0x71, 0xf4, 0xed, 0xa2, 0x6d, 0x1b, 0x61, 0xdd, 0x50, - 0xdc, 0x87, 0x7, 0x2a, 0xe8, 0xcd, 0xe2, 0xcf, 0x5a}; - uint8_t byteswillprops7[] = {0x48, 0xb1, 0x63, 0x16, 0xa7, 0xfb, 0xe5, 0x53, 0xf5, 0x4, 0x74, 0x9c, 0xc8, - 0xbf, 0x5, 0x7, 0x9, 0x25, 0xd3, 0x7d, 0x56, 0x9d, 0xef, 0x40, 0x14}; - uint8_t byteswillprops8[] = {0x3e, 0xb3}; - uint8_t byteswillprops9[] = {0x82, 0x33, 0x64, 0x5c, 0x8b, 0x63}; - uint8_t byteswillprops10[] = {0xd8, 0x48, 0xd9, 0x6b, 0x14, 0xb7, 0xbf, 0xb4, 0x8f, - 0xa5, 0xe0, 0x21, 0x8d, 0xba, 0xa, 0x87, 0x65, 0x9b}; - uint8_t byteswillprops11[] = {0xba, 0xb4, 0x6, 0xe, 0x68, 0x9d, 0xa0, 0x1e, 0x4b, 0xaa, 0x70, - 0x84, 0xc5, 0x31, 0x30, 0x6e, 0x34, 0x3e, 0xbd, 0x1d, 0xc8, 0x1b}; + uint8_t byteswillprops1[] = {0x69, 0xf0, 0xda, 0xc9, 0x30, 0x7a, 0xfe, 0xfd, 0x1, 0x4a, + 0xf2, 0xa3, 0x79, 0xb3, 0x26, 0xb, 0x55, 0x99, 0x59, 0x2, + 0x26, 0x9a, 0xa2, 0x70, 0xc5, 0x29, 0x62, 0xbe, 0xac, 0xa4}; + uint8_t byteswillprops0[] = {0xe0, 0x64, 0xe2, 0x3b, 0x6b, 0xa8, 0xab, 0x11}; + uint8_t byteswillprops3[] = {0}; + uint8_t byteswillprops2[] = {0x36, 0xee, 0xb0, 0x7e, 0x37, 0x71, 0xee, 0xf6, 0xf4}; + uint8_t byteswillprops4[] = {0x50, 0x18, 0x3b, 0xb, 0xb9, 0xee, 0x49}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24813}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20635}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25175}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22005}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22548}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12897}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18926}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7530}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31785}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21418}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {8, (char*)&byteswillprops0}, .v = {30, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {9, (char*)&byteswillprops2}, .v = {0, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12178}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3346}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12214}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&byteswillprops4}}}, }; - lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2, 0xd, 0xf9, 0x41, 0xfa, 0x3f, 0x23, 0xf, 0x8e, 0xe0, 0xcf, 0xcb, 0x43, 0x33, - 0xcb, 0x81, 0xe8, 0xee, 0xc, 0x3e, 0x43, 0x1a, 0x95, 0xdd, 0xc6, 0x5c, 0x31}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x75, 0x7d, 0x67, 0x2e, 0x86, 0xb6, 0x99}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa6, 0x40, 0x7f, 0x8e}; + lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x13, 0x78, 0xe2, 0xf5, 0x4a, 0x70, 0x94, 0x2, 0x25, 0x11, + 0x8d, 0xf0, 0xa9, 0xfd, 0x3, 0x66, 0x64, 0xc1, 0x74, 0x5e}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 2013; - uint8_t client_id_bytes[] = {0xff, 0x1e, 0x54, 0x21, 0x3f, 0xa5, 0x40, 0x80, 0x2b, 0x59, 0x43, 0xb5, 0x2d, 0xfa, - 0xc1, 0xb7, 0xe9, 0x37, 0x1e, 0xc5, 0x78, 0x1a, 0x5b, 0x3f, 0xc, 0xe3, 0x74}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 24545; + uint8_t client_id_bytes[] = {0xb7, 0x23, 0x4a, 0xca, 0x9d, 0xb8, 0x2d, 0xe9, 0x5a, + 0x72, 0xd3, 0xf7, 0x6c, 0xb9, 0x3d, 0xb6, 0x96, 0xc1}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xa7, 0xed, 0x9c, 0x4d, 0x71, 0xb0, 0x37, 0x46, 0x85, 0x3b, 0x70, 0x2, - 0xa4, 0xdb, 0x2c, 0xc4, 0x2c, 0x55, 0x0, 0xab, 0x17, 0x90, 0x4d}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x96, 0x27, 0x63, 0x9f, 0x3, 0x12, 0x90, 0xd4, 0x54, 0x59, 0xe6, 0x3a, - 0x1, 0x76, 0x63, 0x27, 0xda, 0x9a, 0x1f, 0x32, 0x23, 0x31, 0xb7, 0x37}; - lwmqtt_string_t password = {24, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10169,137 +10354,93 @@ TEST(Connect5QCTest, Encode29) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\182\240\189\t", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = "\187M\164\160l,v\190\218\204Q\220\172R\151\151>", _willMsg = -// "B\157i\190\132.u\233\158\DC3\242]\255\133\181\186\255Z\240\188\227", _willProps = [PropAuthenticationMethod -// "\EOT\171\240\148",PropServerKeepAlive 18994,PropRetainAvailable 198,PropServerReference -// ".:\205\237\187\NUL\129@\167\158F\223I\252\239\&9\155\STX\STXUQ",PropMaximumQoS 182,PropRequestProblemInformation -// 92,PropTopicAliasMaximum 7274,PropSubscriptionIdentifier 29,PropWillDelayInterval 752,PropReasonString -// "\146\135\&0.\224\t@",PropWillDelayInterval 5328,PropSharedSubscriptionAvailable 117,PropUserProperty -// "\232\232\166\143\226\176R\250w\176\ACKM\ETX\157\tQ" -// "\219O\163\EM\179\152\179'\182(\133\210\SOm\207E\150`\215\&0\245\189"]}), _cleanSession = False, _keepAlive = 1282, -// _connID = "(\191\136\201\182\228\133S\r\250\189X", _properties = [PropPayloadFormatIndicator -// 103,PropAssignedClientIdentifier "",PropSharedSubscriptionAvailable 126,PropMessageExpiryInterval -// 21203,PropWillDelayInterval 6069,PropTopicAlias 24514,PropSubscriptionIdentifierAvailable -// 165,PropSubscriptionIdentifier 15,PropResponseInformation -// "\CAN\212\SYNL\206\253\211\192\224f\242\249D:H;\228\221",PropMessageExpiryInterval 435,PropTopicAliasMaximum -// 85,PropSubscriptionIdentifier 10,PropSessionExpiryInterval 15646,PropMessageExpiryInterval -// 11202,PropSharedSubscriptionAvailable 62,PropCorrelationData -// "o\236:+\144R\r\154\NAK\\\138\219\145\192\&7\204\170\&4B\DC1\134o0CJ\ETB",PropResponseInformation -// "%w[\185\DLE\177\155\SOH0\130\STX)\211\153\SOH\131\213\US\181\DC1\144",PropRequestResponseInformation -// 138,PropAuthenticationMethod -// "@\194x\155\&0N\NULG0n\186\GS\161~@\240\209\159\142\\\b\142\r|9\152`:Iu",PropUserProperty -// "D\171\198\148\177/\164\167\203" -// "\216f\220\163\141\SYN\184\v\NAK\237\&9P^\129\135\SUBY.",PropWildcardSubscriptionAvailable 20]} +// ConnectRequest {_username = Just "\\\143\216", _password = Just "\151\&6\134W]\238P\207\167\&0Z", _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "9", _willMsg = +// "]v\243\130\NULm\134'\201\ESCs\176\166\a;\239\EM", _willProps = [PropSharedSubscriptionAvailable 43,PropMaximumQoS +// 74,PropMessageExpiryInterval 14419,PropAssignedClientIdentifier +// "\134\183\136\208\159\DC1M\141\142\DC3\FS\237\155$",PropRetainAvailable 128,PropResponseTopic +// "\206\129\SIY>CI\193\192n\236\&4\226\185#\168@u\CAN\ETB\212\212\225\251\207",PropSessionExpiryInterval +// 24313,PropMaximumQoS 77,PropAssignedClientIdentifier "\206\237\&9\246\213\tt\GS\186H\198k\ETB[",PropMaximumQoS +// 145,PropMessageExpiryInterval 9405,PropSubscriptionIdentifierAvailable 222,PropMaximumPacketSize 705,PropTopicAlias +// 16865]}), _cleanSession = True, _keepAlive = 17718, _connID = "\225qY\140\214\227+/\167\SI7\177", _properties = +// [PropContentType "\229\150\211\156\128\237\250J=\219\181",PropSessionExpiryInterval 21507,PropCorrelationData +// "\215\234ZT\219\251a\DC2lHJ\250\133\243z\132\145T?%\241Y[",PropReceiveMaximum 25812,PropTopicAlias +// 9975,PropPayloadFormatIndicator 188]} TEST(Connect5QCTest, Encode30) { - uint8_t pkt[] = { - 0x10, 0xf6, 0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0x9}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x18, 0xd4, 0x16, 0x4c, 0xce, 0xfd, 0xd3, 0xc0, 0xe0, - 0x66, 0xf2, 0xf9, 0x44, 0x3a, 0x48, 0x3b, 0xe4, 0xdd}; - uint8_t bytesprops2[] = {0x6f, 0xec, 0x3a, 0x2b, 0x90, 0x52, 0xd, 0x9a, 0x15, 0x5c, 0x8a, 0xdb, 0x91, - 0xc0, 0x37, 0xcc, 0xaa, 0x34, 0x42, 0x11, 0x86, 0x6f, 0x30, 0x43, 0x4a, 0x17}; - uint8_t bytesprops3[] = {0x25, 0x77, 0x5b, 0xb9, 0x10, 0xb1, 0x9b, 0x1, 0x30, 0x82, 0x2, - 0x29, 0xd3, 0x99, 0x1, 0x83, 0xd5, 0x1f, 0xb5, 0x11, 0x90}; - uint8_t bytesprops4[] = {0x40, 0xc2, 0x78, 0x9b, 0x30, 0x4e, 0x0, 0x47, 0x30, 0x6e, 0xba, 0x1d, 0xa1, 0x7e, 0x40, - 0xf0, 0xd1, 0x9f, 0x8e, 0x5c, 0x8, 0x8e, 0xd, 0x7c, 0x39, 0x98, 0x60, 0x3a, 0x49, 0x75}; - uint8_t bytesprops6[] = {0xd8, 0x66, 0xdc, 0xa3, 0x8d, 0x16, 0xb8, 0xb, 0x15, - 0xed, 0x39, 0x50, 0x5e, 0x81, 0x87, 0x1a, 0x59, 0x2e}; - uint8_t bytesprops5[] = {0x44, 0xab, 0xc6, 0x94, 0xb1, 0x2f, 0xa4, 0xa7, 0xcb}; + uint8_t pkt[] = {0x10, 0xd8, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x45, 0x36, 0x35, 0x3, 0x0, 0xb, + 0xe5, 0x96, 0xd3, 0x9c, 0x80, 0xed, 0xfa, 0x4a, 0x3d, 0xdb, 0xb5, 0x11, 0x0, 0x0, 0x54, 0x3, 0x9, + 0x0, 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] = {0}; + uint8_t bytesprops0[] = {0xe5, 0x96, 0xd3, 0x9c, 0x80, 0xed, 0xfa, 0x4a, 0x3d, 0xdb, 0xb5}; + uint8_t bytesprops1[] = {0xd7, 0xea, 0x5a, 0x54, 0xdb, 0xfb, 0x61, 0x12, 0x6c, 0x48, 0x4a, 0xfa, + 0x85, 0xf3, 0x7a, 0x84, 0x91, 0x54, 0x3f, 0x25, 0xf1, 0x59, 0x5b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21203}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6069}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24514}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 435}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 85}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15646}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11202}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops5}, .v = {18, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21507}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25812}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9975}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 188}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x4, 0xab, 0xf0, 0x94}; - uint8_t byteswillprops1[] = {0x2e, 0x3a, 0xcd, 0xed, 0xbb, 0x0, 0x81, 0x40, 0xa7, 0x9e, 0x46, - 0xdf, 0x49, 0xfc, 0xef, 0x39, 0x9b, 0x2, 0x2, 0x55, 0x51}; - uint8_t byteswillprops2[] = {0x92, 0x87, 0x30, 0x2e, 0xe0, 0x9, 0x40}; - uint8_t byteswillprops4[] = {0xdb, 0x4f, 0xa3, 0x19, 0xb3, 0x98, 0xb3, 0x27, 0xb6, 0x28, 0x85, - 0xd2, 0xe, 0x6d, 0xcf, 0x45, 0x96, 0x60, 0xd7, 0x30, 0xf5, 0xbd}; - uint8_t byteswillprops3[] = {0xe8, 0xe8, 0xa6, 0x8f, 0xe2, 0xb0, 0x52, 0xfa, - 0x77, 0xb0, 0x6, 0x4d, 0x3, 0x9d, 0x9, 0x51}; + uint8_t byteswillprops0[] = {0x86, 0xb7, 0x88, 0xd0, 0x9f, 0x11, 0x4d, 0x8d, 0x8e, 0x13, 0x1c, 0xed, 0x9b, 0x24}; + uint8_t byteswillprops1[] = {0xce, 0x81, 0xf, 0x59, 0x3e, 0x43, 0x49, 0xc1, 0xc0, 0x6e, 0xec, 0x34, 0xe2, + 0xb9, 0x23, 0xa8, 0x40, 0x75, 0x18, 0x17, 0xd4, 0xd4, 0xe1, 0xfb, 0xcf}; + uint8_t byteswillprops2[] = {0xce, 0xed, 0x39, 0xf6, 0xd5, 0x9, 0x74, 0x1d, 0xba, 0x48, 0xc6, 0x6b, 0x17, 0x5b}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18994}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7274}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 752}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5328}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {16, (char*)&byteswillprops3}, .v = {22, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14419}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24313}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9405}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 705}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16865}}, }; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xbb, 0x4d, 0xa4, 0xa0, 0x6c, 0x2c, 0x76, 0xbe, 0xda, - 0xcc, 0x51, 0xdc, 0xac, 0x52, 0x97, 0x97, 0x3e}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x42, 0x9d, 0x69, 0xbe, 0x84, 0x2e, 0x75, 0xe9, 0x9e, 0x13, 0xf2, - 0x5d, 0xff, 0x85, 0xb5, 0xba, 0xff, 0x5a, 0xf0, 0xbc, 0xe3}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x39}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5d, 0x76, 0xf3, 0x82, 0x0, 0x6d, 0x86, 0x27, 0xc9, + 0x1b, 0x73, 0xb0, 0xa6, 0x7, 0x3b, 0xef, 0x19}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 1282; - uint8_t client_id_bytes[] = {0x28, 0xbf, 0x88, 0xc9, 0xb6, 0xe4, 0x85, 0x53, 0xd, 0xfa, 0xbd, 0x58}; + opts.clean_session = true; + opts.keep_alive = 17718; + uint8_t client_id_bytes[] = {0xe1, 0x71, 0x59, 0x8c, 0xd6, 0xe3, 0x2b, 0x2f, 0xa7, 0xf, 0x37, 0xb1}; lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xb6, 0xf0, 0xbd, 0x9}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x5c, 0x8f, 0xd8}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x97, 0x36, 0x86, 0x57, 0x5d, 0xee, 0x50, 0xcf, 0xa7, 0x30, 0x5a}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10309,37 +10450,71 @@ TEST(Connect5QCTest, Encode30) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28306 [("^VR\US\DELZ\SYN\186#\147D\230\US:\188\210\186\165}\145tM\224\&4\158",SubOptions +// SubscribeRequest 18112 [("\217\163\ETBT\231\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\199}\169\229\237\168.,U\215W4W\211\197\172\&1&\235\203\213",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\146\&4\203\145\SUB\209\235\223`.\147\&8\250Q\187\223\244\210b\235p\RS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\205\151*/E\ETXy",SubOptions +// QoS0}),("\225\200[H\253e\NUL\230l[hR\220\215\242\223\175\133\169\231}",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("X",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("D\ACK\181\185\&4\239\235M\227\131\252\255M\176\r\219\180\ETB\217\167\232\190\223\236",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("m\136\t\NUL\228\154\166\199TU&2\143",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] +// QoS1}),("B)`\234\&1'\221\218\171\ETBd\196\&4\229\170Y\SYN\164y\164b\174E\240",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\165\213\SYN\240\249\ETX\f\225\171\188j\164(\170\190\189\248\223\202",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\182\208\135BB\223",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("7",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x51, 0x6e, 0x92, 0x0, 0x19, 0x5e, 0x56, 0x52, 0x1f, 0x7f, 0x5a, 0x16, 0xba, 0x23, 0x93, 0x44, - 0xe6, 0x1f, 0x3a, 0xbc, 0xd2, 0xba, 0xa5, 0x7d, 0x91, 0x74, 0x4d, 0xe0, 0x34, 0x9e, 0x2, 0x0, 0x16, - 0x92, 0x34, 0xcb, 0x91, 0x1a, 0xd1, 0xeb, 0xdf, 0x60, 0x2e, 0x93, 0x38, 0xfa, 0x51, 0xbb, 0xdf, 0xf4, - 0xd2, 0x62, 0xeb, 0x70, 0x1e, 0x0, 0x0, 0x7, 0xcd, 0x97, 0x2a, 0x2f, 0x45, 0x3, 0x79, 0x2, 0x0, - 0xd, 0x6d, 0x88, 0x9, 0x0, 0xe4, 0x9a, 0xa6, 0xc7, 0x54, 0x55, 0x26, 0x32, 0x8f, 0x2}; + uint8_t pkt[] = {0x82, 0x9b, 0x1, 0x46, 0xc0, 0x0, 0x6, 0xd9, 0xa3, 0x17, 0x54, 0xe7, 0xd9, 0x0, 0x0, 0x15, + 0xc7, 0x7d, 0xa9, 0xe5, 0xed, 0xa8, 0x2e, 0x2c, 0x55, 0xd7, 0x57, 0x34, 0x57, 0xd3, 0xc5, 0xac, + 0x31, 0x26, 0xeb, 0xcb, 0xd5, 0x0, 0x0, 0x15, 0xe1, 0xc8, 0x5b, 0x48, 0xfd, 0x65, 0x0, 0xe6, + 0x6c, 0x5b, 0x68, 0x52, 0xdc, 0xd7, 0xf2, 0xdf, 0xaf, 0x85, 0xa9, 0xe7, 0x7d, 0x0, 0x0, 0x1, + 0x58, 0x1, 0x0, 0x18, 0x44, 0x6, 0xb5, 0xb9, 0x34, 0xef, 0xeb, 0x4d, 0xe3, 0x83, 0xfc, 0xff, + 0x4d, 0xb0, 0xd, 0xdb, 0xb4, 0x17, 0xd9, 0xa7, 0xe8, 0xbe, 0xdf, 0xec, 0x1, 0x0, 0x18, 0x42, + 0x29, 0x60, 0xea, 0x31, 0x27, 0xdd, 0xda, 0xab, 0x17, 0x64, 0xc4, 0x34, 0xe5, 0xaa, 0x59, 0x16, + 0xa4, 0x79, 0xa4, 0x62, 0xae, 0x45, 0xf0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x13, 0xa5, 0xd5, 0x16, + 0xf0, 0xf9, 0x3, 0xc, 0xe1, 0xab, 0xbc, 0x6a, 0xa4, 0x28, 0xaa, 0xbe, 0xbd, 0xf8, 0xdf, 0xca, + 0x0, 0x0, 0x6, 0xb6, 0xd0, 0x87, 0x42, 0x42, 0xdf, 0x2, 0x0, 0x1, 0x37, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x5e, 0x56, 0x52, 0x1f, 0x7f, 0x5a, 0x16, 0xba, 0x23, 0x93, 0x44, 0xe6, 0x1f, - 0x3a, 0xbc, 0xd2, 0xba, 0xa5, 0x7d, 0x91, 0x74, 0x4d, 0xe0, 0x34, 0x9e}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd9, 0xa3, 0x17, 0x54, 0xe7, 0xd9}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x92, 0x34, 0xcb, 0x91, 0x1a, 0xd1, 0xeb, 0xdf, 0x60, 0x2e, 0x93, - 0x38, 0xfa, 0x51, 0xbb, 0xdf, 0xf4, 0xd2, 0x62, 0xeb, 0x70, 0x1e}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc7, 0x7d, 0xa9, 0xe5, 0xed, 0xa8, 0x2e, 0x2c, 0x55, 0xd7, 0x57, + 0x34, 0x57, 0xd3, 0xc5, 0xac, 0x31, 0x26, 0xeb, 0xcb, 0xd5}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xcd, 0x97, 0x2a, 0x2f, 0x45, 0x3, 0x79}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe1, 0xc8, 0x5b, 0x48, 0xfd, 0x65, 0x0, 0xe6, 0x6c, 0x5b, 0x68, + 0x52, 0xdc, 0xd7, 0xf2, 0xdf, 0xaf, 0x85, 0xa9, 0xe7, 0x7d}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6d, 0x88, 0x9, 0x0, 0xe4, 0x9a, 0xa6, 0xc7, 0x54, 0x55, 0x26, 0x32, 0x8f}; - lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x58}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s4_bytes[] = {0x44, 0x6, 0xb5, 0xb9, 0x34, 0xef, 0xeb, 0x4d, 0xe3, 0x83, 0xfc, 0xff, + 0x4d, 0xb0, 0xd, 0xdb, 0xb4, 0x17, 0xd9, 0xa7, 0xe8, 0xbe, 0xdf, 0xec}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x42, 0x29, 0x60, 0xea, 0x31, 0x27, 0xdd, 0xda, 0xab, 0x17, 0x64, 0xc4, + 0x34, 0xe5, 0xaa, 0x59, 0x16, 0xa4, 0x79, 0xa4, 0x62, 0xae, 0x45, 0xf0}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xa5, 0xd5, 0x16, 0xf0, 0xf9, 0x3, 0xc, 0xe1, 0xab, 0xbc, + 0x6a, 0xa4, 0x28, 0xaa, 0xbe, 0xbd, 0xf8, 0xdf, 0xca}; + lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xb6, 0xd0, 0x87, 0x42, 0x42, 0xdf}; + lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x37}; + lwmqtt_string_t topic_filter_s9 = {1, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -10347,65 +10522,68 @@ TEST(Subscribe311QCTest, Encode1) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28306, 4, topic_filters, sub_opts, props); - + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18112, 10, topic_filters, sub_opts, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 13416 [("\r\166\147\EM\SI{\SOH\234l\226\237]\132$!)Y%\182 \DC3\174-C\164D\FS\145@",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(",\156\&5\239\239:@",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("#\138\nSgRd\ACKU\180\186\145R\159\249/\EM\142 \146X\228I33\178#",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(";\130\229\172!\203|",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("R\183\NUL\247G\201\192\NAKw\152.p\230\DEL\208\197!\243e\167\203",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 8048 [("=\136\230h\216\226(\250c\195\226\174/9",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\216k\253Z\203\ETX\218\SYN&\169m",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0x6c, 0x34, 0x68, 0x0, 0x1d, 0xd, 0xa6, 0x93, 0x19, 0xf, 0x7b, 0x1, 0xea, 0x6c, 0xe2, - 0xed, 0x5d, 0x84, 0x24, 0x21, 0x29, 0x59, 0x25, 0xb6, 0x20, 0x13, 0xae, 0x2d, 0x43, 0xa4, 0x44, - 0x1c, 0x91, 0x40, 0x0, 0x0, 0x7, 0x2c, 0x9c, 0x35, 0xef, 0xef, 0x3a, 0x40, 0x2, 0x0, 0x1b, - 0x23, 0x8a, 0xa, 0x53, 0x67, 0x52, 0x64, 0x6, 0x55, 0xb4, 0xba, 0x91, 0x52, 0x9f, 0xf9, 0x2f, - 0x19, 0x8e, 0x20, 0x92, 0x58, 0xe4, 0x49, 0x33, 0x33, 0xb2, 0x23, 0x0, 0x0, 0x7, 0x3b, 0x82, - 0xe5, 0xac, 0x21, 0xcb, 0x7c, 0x2, 0x0, 0x15, 0x52, 0xb7, 0x0, 0xf7, 0x47, 0xc9, 0xc0, 0x15, - 0x77, 0x98, 0x2e, 0x70, 0xe6, 0x7f, 0xd0, 0xc5, 0x21, 0xf3, 0x65, 0xa7, 0xcb, 0x1}; + uint8_t pkt[] = {0x82, 0x21, 0x1f, 0x70, 0x0, 0xe, 0x3d, 0x88, 0xe6, 0x68, 0xd8, 0xe2, + 0x28, 0xfa, 0x63, 0xc3, 0xe2, 0xae, 0x2f, 0x39, 0x2, 0x0, 0xb, 0xd8, + 0x6b, 0xfd, 0x5a, 0xcb, 0x3, 0xda, 0x16, 0x26, 0xa9, 0x6d, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xd, 0xa6, 0x93, 0x19, 0xf, 0x7b, 0x1, 0xea, 0x6c, 0xe2, - 0xed, 0x5d, 0x84, 0x24, 0x21, 0x29, 0x59, 0x25, 0xb6, 0x20, - 0x13, 0xae, 0x2d, 0x43, 0xa4, 0x44, 0x1c, 0x91, 0x40}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x3d, 0x88, 0xe6, 0x68, 0xd8, 0xe2, 0x28, + 0xfa, 0x63, 0xc3, 0xe2, 0xae, 0x2f, 0x39}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2c, 0x9c, 0x35, 0xef, 0xef, 0x3a, 0x40}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd8, 0x6b, 0xfd, 0x5a, 0xcb, 0x3, 0xda, 0x16, 0x26, 0xa9, 0x6d}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x23, 0x8a, 0xa, 0x53, 0x67, 0x52, 0x64, 0x6, 0x55, 0xb4, 0xba, 0x91, 0x52, 0x9f, - 0xf9, 0x2f, 0x19, 0x8e, 0x20, 0x92, 0x58, 0xe4, 0x49, 0x33, 0x33, 0xb2, 0x23}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3b, 0x82, 0xe5, 0xac, 0x21, 0xcb, 0x7c}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x52, 0xb7, 0x0, 0xf7, 0x47, 0xc9, 0xc0, 0x15, 0x77, 0x98, 0x2e, - 0x70, 0xe6, 0x7f, 0xd0, 0xc5, 0x21, 0xf3, 0x65, 0xa7, 0xcb}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -10413,96 +10591,75 @@ TEST(Subscribe311QCTest, Encode2) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13416, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8048, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19505 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\193~\153\213\236\138\165\192;P\209\245\207",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 21602 [("\218I\151?\251\157\177r\DC2$\167\179\239",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\154\DC41*\134\182g\t'\129\&1\ETX\186_\STX\SYNks\SI\235P",SubOptions {_retainHandling = SendOnSubscribe, +// QoS1}),("\DELM\163P3T\138\133=\251\243C\218\218\133`\166",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("1f,]@\243\146\195\138U\CAN\153B\215M8\229X?",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("k\241\"\130\130\f=\CANf\154\172\152E",SubOptions +// QoS2}),("\SYN\189'\252\223\241\r\ENQ?\146.\216n\235jI",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("K$\SYNda\EOT\253\217\190\241p\RS\f\191\f.\252\152\244\DEL\215\RSn\195\EOTyZ\150",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\167",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("c7\142\243",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("W\235/\243\DLE",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("\168\164\163wJ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\229\237\196\180\216\NAK\196\157'\221z\153\239-\EOT\202X\ENQK\177YOB+",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("RLl\155O\151\a\202]\163\201\221\153L+]\180\223\205\130\DC2h\NUL)\250\252\213\DC4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS1}),("\155\184\145gf\215\SYN|%",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x4c, 0x31, 0x0, 0x0, 0x0, 0x0, 0xd, 0xc1, 0x7e, 0x99, 0xd5, 0xec, 0x8a, - 0xa5, 0xc0, 0x3b, 0x50, 0xd1, 0xf5, 0xcf, 0x1, 0x0, 0x15, 0x9a, 0x14, 0x31, 0x2a, 0x86, 0xb6, - 0x67, 0x9, 0x27, 0x81, 0x31, 0x3, 0xba, 0x5f, 0x2, 0x16, 0x6b, 0x73, 0xf, 0xeb, 0x50, 0x0, - 0x0, 0x13, 0x31, 0x66, 0x2c, 0x5d, 0x40, 0xf3, 0x92, 0xc3, 0x8a, 0x55, 0x18, 0x99, 0x42, 0xd7, - 0x4d, 0x38, 0xe5, 0x58, 0x3f, 0x1, 0x0, 0xd, 0x6b, 0xf1, 0x22, 0x82, 0x82, 0xc, 0x3d, 0x18, - 0x66, 0x9a, 0xac, 0x98, 0x45, 0x0, 0x0, 0x5, 0x57, 0xeb, 0x2f, 0xf3, 0x10, 0x1, 0x0, 0x5, - 0xa8, 0xa4, 0xa3, 0x77, 0x4a, 0x2, 0x0, 0x18, 0xe5, 0xed, 0xc4, 0xb4, 0xd8, 0x15, 0xc4, 0x9d, - 0x27, 0xdd, 0x7a, 0x99, 0xef, 0x2d, 0x4, 0xca, 0x58, 0x5, 0x4b, 0xb1, 0x59, 0x4f, 0x42, 0x2b, - 0x1, 0x0, 0x1c, 0x52, 0x4c, 0x6c, 0x9b, 0x4f, 0x97, 0x7, 0xca, 0x5d, 0xa3, 0xc9, 0xdd, 0x99, - 0x4c, 0x2b, 0x5d, 0xb4, 0xdf, 0xcd, 0x82, 0x12, 0x68, 0x0, 0x29, 0xfa, 0xfc, 0xd5, 0x14, 0x0}; + uint8_t pkt[] = {0x82, 0x72, 0x54, 0x62, 0x0, 0xd, 0xda, 0x49, 0x97, 0x3f, 0xfb, 0x9d, 0xb1, 0x72, 0x12, 0x24, 0xa7, + 0xb3, 0xef, 0x1, 0x0, 0x11, 0x7f, 0x4d, 0xa3, 0x50, 0x33, 0x54, 0x8a, 0x85, 0x3d, 0xfb, 0xf3, 0x43, + 0xda, 0xda, 0x85, 0x60, 0xa6, 0x2, 0x0, 0x10, 0x16, 0xbd, 0x27, 0xfc, 0xdf, 0xf1, 0xd, 0x5, 0x3f, + 0x92, 0x2e, 0xd8, 0x6e, 0xeb, 0x6a, 0x49, 0x0, 0x0, 0x1c, 0x4b, 0x24, 0x16, 0x64, 0x61, 0x4, 0xfd, + 0xd9, 0xbe, 0xf1, 0x70, 0x1e, 0xc, 0xbf, 0xc, 0x2e, 0xfc, 0x98, 0xf4, 0x7f, 0xd7, 0x1e, 0x6e, 0xc3, + 0x4, 0x79, 0x5a, 0x96, 0x0, 0x0, 0x1, 0xa7, 0x2, 0x0, 0x0, 0x0, 0x0, 0x4, 0x63, 0x37, 0x8e, + 0xf3, 0x1, 0x0, 0x9, 0x9b, 0xb8, 0x91, 0x67, 0x66, 0xd7, 0x16, 0x7c, 0x25, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xda, 0x49, 0x97, 0x3f, 0xfb, 0x9d, 0xb1, 0x72, 0x12, 0x24, 0xa7, 0xb3, 0xef}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc1, 0x7e, 0x99, 0xd5, 0xec, 0x8a, 0xa5, 0xc0, 0x3b, 0x50, 0xd1, 0xf5, 0xcf}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7f, 0x4d, 0xa3, 0x50, 0x33, 0x54, 0x8a, 0x85, 0x3d, + 0xfb, 0xf3, 0x43, 0xda, 0xda, 0x85, 0x60, 0xa6}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9a, 0x14, 0x31, 0x2a, 0x86, 0xb6, 0x67, 0x9, 0x27, 0x81, 0x31, - 0x3, 0xba, 0x5f, 0x2, 0x16, 0x6b, 0x73, 0xf, 0xeb, 0x50}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x16, 0xbd, 0x27, 0xfc, 0xdf, 0xf1, 0xd, 0x5, + 0x3f, 0x92, 0x2e, 0xd8, 0x6e, 0xeb, 0x6a, 0x49}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x31, 0x66, 0x2c, 0x5d, 0x40, 0xf3, 0x92, 0xc3, 0x8a, 0x55, - 0x18, 0x99, 0x42, 0xd7, 0x4d, 0x38, 0xe5, 0x58, 0x3f}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x4b, 0x24, 0x16, 0x64, 0x61, 0x4, 0xfd, 0xd9, 0xbe, 0xf1, + 0x70, 0x1e, 0xc, 0xbf, 0xc, 0x2e, 0xfc, 0x98, 0xf4, 0x7f, + 0xd7, 0x1e, 0x6e, 0xc3, 0x4, 0x79, 0x5a, 0x96}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x6b, 0xf1, 0x22, 0x82, 0x82, 0xc, 0x3d, 0x18, 0x66, 0x9a, 0xac, 0x98, 0x45}; - lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa7}; + lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x57, 0xeb, 0x2f, 0xf3, 0x10}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa8, 0xa4, 0xa3, 0x77, 0x4a}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x63, 0x37, 0x8e, 0xf3}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe5, 0xed, 0xc4, 0xb4, 0xd8, 0x15, 0xc4, 0x9d, 0x27, 0xdd, 0x7a, 0x99, - 0xef, 0x2d, 0x4, 0xca, 0x58, 0x5, 0x4b, 0xb1, 0x59, 0x4f, 0x42, 0x2b}; - lwmqtt_string_t topic_filter_s7 = {24, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x9b, 0xb8, 0x91, 0x67, 0x66, 0xd7, 0x16, 0x7c, 0x25}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x52, 0x4c, 0x6c, 0x9b, 0x4f, 0x97, 0x7, 0xca, 0x5d, 0xa3, - 0xc9, 0xdd, 0x99, 0x4c, 0x2b, 0x5d, 0xb4, 0xdf, 0xcd, 0x82, - 0x12, 0x68, 0x0, 0x29, 0xfa, 0xfc, 0xd5, 0x14}; - lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -10510,123 +10667,92 @@ TEST(Subscribe311QCTest, Encode3) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19505, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21602, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22696 [("i\\\ETB]\223\172\230\167S\161\b\f\181\140\230\235\211\199\RS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\167",SubOptions {_retainHandling = +// SubscribeRequest 20894 [("\237B-\128DW\251-\ENQ\236~\v\231",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\235\144\244p\b",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\167E\206\237eq!\244c\192\133\243\244",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\150\245e",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\156\133~]\132@\193",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\RS\145\206) -// \b\156\205\226\161RF\ETX\DC3\144q\211\212pm]%6\185\228\189p",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\188*F\240k\177\DEL\179Z\238a\160$\225\245*\135(\DC2q",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\197\168cf\214e\153\EM_T\211\151;\179\163\164 -// \135\158\193\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("C\133\193\&1\150FS\ESC\227S;\138I\ETX\SUB",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\148\241Hb\144[\206)\160\178w",SubOptions +// QoS1}),("\162\EM\147\205\188{m\242\133S\193\173\220\173H\227m\DC3\251\217\SUB\DC4\184\DC4~\255\a",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("HG\190\249\226\171Bd;n\226\240\138\157R\188\178\139",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS2}),("\237M\170\&2IG\163",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("N\168\164\212\213\140\SO|b\223\242P\195\226\192\139\128\NUL\SYN8 C",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\ETB\a\246\155\191\141\202\183\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0xbe, 0x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0xbc, 0xb2, 0x8b, 0x1}; + uint8_t pkt[] = {0x82, 0x6a, 0x51, 0x9e, 0x0, 0xd, 0xed, 0x42, 0x2d, 0x80, 0x44, 0x57, 0xfb, 0x2d, 0x5, 0xec, + 0x7e, 0xb, 0xe7, 0x0, 0x0, 0x5, 0xeb, 0x90, 0xf4, 0x70, 0x8, 0x1, 0x0, 0x1b, 0xa2, 0x19, + 0x93, 0xcd, 0xbc, 0x7b, 0x6d, 0xf2, 0x85, 0x53, 0xc1, 0xad, 0xdc, 0xad, 0x48, 0xe3, 0x6d, 0x13, + 0xfb, 0xd9, 0x1a, 0x14, 0xb8, 0x14, 0x7e, 0xff, 0x7, 0x1, 0x0, 0x0, 0x2, 0x0, 0x7, 0xed, + 0x4d, 0xaa, 0x32, 0x49, 0x47, 0xa3, 0x2, 0x0, 0x16, 0x4e, 0xa8, 0xa4, 0xd4, 0xd5, 0x8c, 0xe, + 0x7c, 0x62, 0xdf, 0xf2, 0x50, 0xc3, 0xe2, 0xc0, 0x8b, 0x80, 0x0, 0x16, 0x38, 0x20, 0x43, 0x1, + 0x0, 0x9, 0x17, 0x7, 0xf6, 0x9b, 0xbf, 0x8d, 0xca, 0xb7, 0x98, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x69, 0x5c, 0x17, 0x5d, 0xdf, 0xac, 0xe6, 0xa7, 0x53, 0xa1, - 0x8, 0xc, 0xb5, 0x8c, 0xe6, 0xeb, 0xd3, 0xc7, 0x1e}; - lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xed, 0x42, 0x2d, 0x80, 0x44, 0x57, 0xfb, 0x2d, 0x5, 0xec, 0x7e, 0xb, 0xe7}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa7}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xeb, 0x90, 0xf4, 0x70, 0x8}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa7, 0x45, 0xce, 0xed, 0x65, 0x71, 0x21, 0xf4, 0x63, 0xc0, 0x85, 0xf3, 0xf4}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa2, 0x19, 0x93, 0xcd, 0xbc, 0x7b, 0x6d, 0xf2, 0x85, 0x53, 0xc1, 0xad, 0xdc, 0xad, + 0x48, 0xe3, 0x6d, 0x13, 0xfb, 0xd9, 0x1a, 0x14, 0xb8, 0x14, 0x7e, 0xff, 0x7}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x96, 0xf5, 0x65}; - lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9c, 0x85, 0x7e, 0x5d, 0x84, 0x40, 0xc1}; + uint8_t topic_filter_s4_bytes[] = {0xed, 0x4d, 0xaa, 0x32, 0x49, 0x47, 0xa3}; lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1e, 0x91, 0xce, 0x29, 0x20, 0x8, 0x9c, 0xcd, 0xe2, 0xa1, 0x52, 0x46, 0x3, 0x13, - 0x90, 0x71, 0xd3, 0xd4, 0x70, 0x6d, 0x5d, 0x25, 0x36, 0xb9, 0xe4, 0xbd, 0x70}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x4e, 0xa8, 0xa4, 0xd4, 0xd5, 0x8c, 0xe, 0x7c, 0x62, 0xdf, 0xf2, + 0x50, 0xc3, 0xe2, 0xc0, 0x8b, 0x80, 0x0, 0x16, 0x38, 0x20, 0x43}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbc, 0x2a, 0x46, 0xf0, 0x6b, 0xb1, 0x7f, 0xb3, 0x5a, 0xee, - 0x61, 0xa0, 0x24, 0xe1, 0xf5, 0x2a, 0x87, 0x28, 0x12, 0x71}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x17, 0x7, 0xf6, 0x9b, 0xbf, 0x8d, 0xca, 0xb7, 0x98}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xc5, 0xa8, 0x63, 0x66, 0xd6, 0x65, 0x99, 0x19, 0x5f, 0x54, 0xd3, - 0x97, 0x3b, 0xb3, 0xa3, 0xa4, 0x20, 0x87, 0x9e, 0xc1, 0x1}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x43, 0x85, 0xc1, 0x31, 0x96, 0x46, 0x53, 0x1b, - 0xe3, 0x53, 0x3b, 0x8a, 0x49, 0x3, 0x1a}; - lwmqtt_string_t topic_filter_s8 = {15, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x94, 0xf1, 0x48, 0x62, 0x90, 0x5b, 0xce, 0x29, 0xa0, 0xb2, 0x77}; - lwmqtt_string_t topic_filter_s9 = {11, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x48, 0x47, 0xbe, 0xf9, 0xe2, 0xab, 0x42, 0x64, 0x3b, - 0x6e, 0xe2, 0xf0, 0x8a, 0x9d, 0x52, 0xbc, 0xb2, 0x8b}; - lwmqtt_string_t topic_filter_s10 = {18, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -10638,201 +10764,91 @@ TEST(Subscribe311QCTest, Encode4) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS1; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22696, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20894, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14047 [("\r\253\211]\t\130|\206\&1\231\131\EOT\SI\129\229\140",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\245\193h\190\138\168\227j\SUB\DC2\232\129A\197",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\152>\249\ACK",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\184\209\128O=(Q\229",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("2E\213\230\200\236\143\235\&0\NUL\CAN\ESC#Y\224Bf\FS-z\133 \192'C",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\177\212\217\238\249\r\208\171n\214\145HAI\FSG\NUL>\198\212y\RS\217\148\225\CANQ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("1\152:S",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("\180n\153T\208\214\157",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\168eem\240p\168\224\244\EOT\131/;\201\179\224",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(")ZK[\221\236\"r\197\144\180\255,\159\143\229\160\189\242",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 15574 +// [("]\129\160\v\144]\DC3^\204\220\DEL\ETX2_\SI\"\197\208\215\196\b\176^\158\233\177\180\164\255",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0xac, 0x1, 0x36, 0xdf, 0x0, 0x10, 0xd, 0xfd, 0xd3, 0x5d, 0x9, 0x82, 0x7c, 0xce, 0x31, - 0xe7, 0x83, 0x4, 0xf, 0x81, 0xe5, 0x8c, 0x2, 0x0, 0xe, 0xf5, 0xc1, 0x68, 0xbe, 0x8a, 0xa8, - 0xe3, 0x6a, 0x1a, 0x12, 0xe8, 0x81, 0x41, 0xc5, 0x0, 0x0, 0x4, 0x98, 0x3e, 0xf9, 0x6, 0x0, - 0x0, 0x8, 0xb8, 0xd1, 0x80, 0x4f, 0x3d, 0x28, 0x51, 0xe5, 0x0, 0x0, 0x19, 0x32, 0x45, 0xd5, - 0xe6, 0xc8, 0xec, 0x8f, 0xeb, 0x30, 0x0, 0x18, 0x1b, 0x23, 0x59, 0xe0, 0x42, 0x66, 0x1c, 0x2d, - 0x7a, 0x85, 0x20, 0xc0, 0x27, 0x43, 0x2, 0x0, 0x1b, 0xb1, 0xd4, 0xd9, 0xee, 0xf9, 0xd, 0xd0, - 0xab, 0x6e, 0xd6, 0x91, 0x48, 0x41, 0x49, 0x1c, 0x47, 0x0, 0x3e, 0xc6, 0xd4, 0x79, 0x1e, 0xd9, - 0x94, 0xe1, 0x18, 0x51, 0x0, 0x0, 0x4, 0x31, 0x98, 0x3a, 0x53, 0x0, 0x0, 0x7, 0xb4, 0x6e, - 0x99, 0x54, 0xd0, 0xd6, 0x9d, 0x0, 0x0, 0x10, 0xa8, 0x65, 0x65, 0x6d, 0xf0, 0x70, 0xa8, 0xe0, - 0xf4, 0x4, 0x83, 0x2f, 0x3b, 0xc9, 0xb3, 0xe0, 0x2, 0x0, 0x13, 0x29, 0x5a, 0x4b, 0x5b, 0xdd, - 0xec, 0x22, 0x72, 0xc5, 0x90, 0xb4, 0xff, 0x2c, 0x9f, 0x8f, 0xe5, 0xa0, 0xbd, 0xf2, 0x1}; + uint8_t pkt[] = {0x82, 0x22, 0x3c, 0xd6, 0x0, 0x1d, 0x5d, 0x81, 0xa0, 0xb, 0x90, 0x5d, + 0x13, 0x5e, 0xcc, 0xdc, 0x7f, 0x3, 0x32, 0x5f, 0xf, 0x22, 0xc5, 0xd0, + 0xd7, 0xc4, 0x8, 0xb0, 0x5e, 0x9e, 0xe9, 0xb1, 0xb4, 0xa4, 0xff, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd, 0xfd, 0xd3, 0x5d, 0x9, 0x82, 0x7c, 0xce, - 0x31, 0xe7, 0x83, 0x4, 0xf, 0x81, 0xe5, 0x8c}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x5d, 0x81, 0xa0, 0xb, 0x90, 0x5d, 0x13, 0x5e, 0xcc, 0xdc, + 0x7f, 0x3, 0x32, 0x5f, 0xf, 0x22, 0xc5, 0xd0, 0xd7, 0xc4, + 0x8, 0xb0, 0x5e, 0x9e, 0xe9, 0xb1, 0xb4, 0xa4, 0xff}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf5, 0xc1, 0x68, 0xbe, 0x8a, 0xa8, 0xe3, - 0x6a, 0x1a, 0x12, 0xe8, 0x81, 0x41, 0xc5}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x98, 0x3e, 0xf9, 0x6}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb8, 0xd1, 0x80, 0x4f, 0x3d, 0x28, 0x51, 0xe5}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x32, 0x45, 0xd5, 0xe6, 0xc8, 0xec, 0x8f, 0xeb, 0x30, 0x0, 0x18, 0x1b, 0x23, - 0x59, 0xe0, 0x42, 0x66, 0x1c, 0x2d, 0x7a, 0x85, 0x20, 0xc0, 0x27, 0x43}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb1, 0xd4, 0xd9, 0xee, 0xf9, 0xd, 0xd0, 0xab, 0x6e, 0xd6, 0x91, 0x48, 0x41, 0x49, - 0x1c, 0x47, 0x0, 0x3e, 0xc6, 0xd4, 0x79, 0x1e, 0xd9, 0x94, 0xe1, 0x18, 0x51}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x31, 0x98, 0x3a, 0x53}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb4, 0x6e, 0x99, 0x54, 0xd0, 0xd6, 0x9d}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa8, 0x65, 0x65, 0x6d, 0xf0, 0x70, 0xa8, 0xe0, - 0xf4, 0x4, 0x83, 0x2f, 0x3b, 0xc9, 0xb3, 0xe0}; - lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x29, 0x5a, 0x4b, 0x5b, 0xdd, 0xec, 0x22, 0x72, 0xc5, 0x90, - 0xb4, 0xff, 0x2c, 0x9f, 0x8f, 0xe5, 0xa0, 0xbd, 0xf2}; - lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14047, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15574, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 502 [("\ESC\USm\212\ETB\238\&9\252\153\189\163S\234=+",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("{\221\\\229 -// :\162\183\177\157\208\253\FS\144bS\217\ETB\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("U,\243\&4\ETB\241\&1\142\221\ACK#\tm\137\153\131F\200\147\&1\153\242\176\192\241\132>\192\174",SubOptions +// SubscribeRequest 17105 [("\251AO\229\203\204a\247\204\191\DC4\162\204\146JU\160\SUB\157\195",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\SI\SI\DC39\233\224\EMM\128L5\235\156\157o\239N7\172:d\247",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// QoS1}),("\155\216\r\EOT\169\SO\224\155n\235\FS\nu\159\142g;\149\246\147E\179]b\231\&8\US/<\FS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("{,\159\154j\185o\n\143m\178\242\207>=R\NAK\247nHl\242\STX\213&oY",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0x63, 0x1, 0xf6, 0x0, 0xf, 0x1b, 0x1f, 0x6d, 0xd4, 0x17, 0xee, 0x39, 0xfc, 0x99, 0xbd, 0xa3, - 0x53, 0xea, 0x3d, 0x2b, 0x2, 0x0, 0x13, 0x7b, 0xdd, 0x5c, 0xe5, 0x20, 0x3a, 0xa2, 0xb7, 0xb1, 0x9d, - 0xd0, 0xfd, 0x1c, 0x90, 0x62, 0x53, 0xd9, 0x17, 0xb4, 0x0, 0x0, 0x1d, 0x55, 0x2c, 0xf3, 0x34, 0x17, - 0xf1, 0x31, 0x8e, 0xdd, 0x6, 0x23, 0x9, 0x6d, 0x89, 0x99, 0x83, 0x46, 0xc8, 0x93, 0x31, 0x99, 0xf2, - 0xb0, 0xc0, 0xf1, 0x84, 0x3e, 0xc0, 0xae, 0x2, 0x0, 0x16, 0xf, 0xf, 0x13, 0x39, 0xe9, 0xe0, 0x19, - 0x4d, 0x80, 0x4c, 0x35, 0xeb, 0x9c, 0x9d, 0x6f, 0xef, 0x4e, 0x37, 0xac, 0x3a, 0x64, 0xf7, 0x2}; + uint8_t pkt[] = {0x82, 0x58, 0x42, 0xd1, 0x0, 0x14, 0xfb, 0x41, 0x4f, 0xe5, 0xcb, 0xcc, 0x61, 0xf7, 0xcc, + 0xbf, 0x14, 0xa2, 0xcc, 0x92, 0x4a, 0x55, 0xa0, 0x1a, 0x9d, 0xc3, 0x1, 0x0, 0x1e, 0x9b, + 0xd8, 0xd, 0x4, 0xa9, 0xe, 0xe0, 0x9b, 0x6e, 0xeb, 0x1c, 0xa, 0x75, 0x9f, 0x8e, 0x67, + 0x3b, 0x95, 0xf6, 0x93, 0x45, 0xb3, 0x5d, 0x62, 0xe7, 0x38, 0x1f, 0x2f, 0x3c, 0x1c, 0x2, + 0x0, 0x1b, 0x7b, 0x2c, 0x9f, 0x9a, 0x6a, 0xb9, 0x6f, 0xa, 0x8f, 0x6d, 0xb2, 0xf2, 0xcf, + 0x3e, 0x3d, 0x52, 0x15, 0xf7, 0x6e, 0x48, 0x6c, 0xf2, 0x2, 0xd5, 0x26, 0x6f, 0x59, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x1b, 0x1f, 0x6d, 0xd4, 0x17, 0xee, 0x39, 0xfc, - 0x99, 0xbd, 0xa3, 0x53, 0xea, 0x3d, 0x2b}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xfb, 0x41, 0x4f, 0xe5, 0xcb, 0xcc, 0x61, 0xf7, 0xcc, 0xbf, + 0x14, 0xa2, 0xcc, 0x92, 0x4a, 0x55, 0xa0, 0x1a, 0x9d, 0xc3}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7b, 0xdd, 0x5c, 0xe5, 0x20, 0x3a, 0xa2, 0xb7, 0xb1, 0x9d, - 0xd0, 0xfd, 0x1c, 0x90, 0x62, 0x53, 0xd9, 0x17, 0xb4}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9b, 0xd8, 0xd, 0x4, 0xa9, 0xe, 0xe0, 0x9b, 0x6e, 0xeb, + 0x1c, 0xa, 0x75, 0x9f, 0x8e, 0x67, 0x3b, 0x95, 0xf6, 0x93, + 0x45, 0xb3, 0x5d, 0x62, 0xe7, 0x38, 0x1f, 0x2f, 0x3c, 0x1c}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x55, 0x2c, 0xf3, 0x34, 0x17, 0xf1, 0x31, 0x8e, 0xdd, 0x6, - 0x23, 0x9, 0x6d, 0x89, 0x99, 0x83, 0x46, 0xc8, 0x93, 0x31, - 0x99, 0xf2, 0xb0, 0xc0, 0xf1, 0x84, 0x3e, 0xc0, 0xae}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7b, 0x2c, 0x9f, 0x9a, 0x6a, 0xb9, 0x6f, 0xa, 0x8f, 0x6d, 0xb2, 0xf2, 0xcf, 0x3e, + 0x3d, 0x52, 0x15, 0xf7, 0x6e, 0x48, 0x6c, 0xf2, 0x2, 0xd5, 0x26, 0x6f, 0x59}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf, 0xf, 0x13, 0x39, 0xe9, 0xe0, 0x19, 0x4d, 0x80, 0x4c, 0x35, - 0xeb, 0x9c, 0x9d, 0x6f, 0xef, 0x4e, 0x37, 0xac, 0x3a, 0x64, 0xf7}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -10840,96 +10856,55 @@ TEST(Subscribe311QCTest, Encode6) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 502, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17105, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27247 -// [("\137\230\141\ACK\169\178P\242\SUB\143Ml]\220\&1<\251\195\206\187\139$\167\174\\zW",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("<\235\&2\233\188SY\DC2}N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\169\156\DC4\199\SUBt\235!\GS\198\SUB\142i\208\aj\\\NAKG\a",SubOptions +// SubscribeRequest 26860 [("\\\141\254\CAN\217\DC4\240\244\DELx;\238\SO\168\&6A\223v\163\128",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("h\252u[I\131\&8\238i\235/\165{\147\159\226/G\208\207npWu\ACKc\150@",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// QoS1}),("t\181>5/\245\f\155\161\184\211",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\STX=\b\150d\219\200\177\178\226D\153\252A\229",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\132*T\ETB!\169\180\173\239t=",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\184\198;\ETX\221\STX\202\227[\197q;6\189\n\169",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("x30\199\163\193",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("s\226\229\185N]\173-\176\199\183\201\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS0}),("\228\134\195\198\239\232\245\153\ACKd.\130%$9D\237\231\158\SOH\160\242\151\170\\I",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions +// QoS1}),("\245\138\fl\228\159\224Bny",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\194t\244\206\158\155>\128\183y\199\173\195\199~F\150;\142\178d",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0xc0, 0x1, 0x6a, 0x6f, 0x0, 0x1b, 0x89, 0xe6, 0x8d, 0x6, 0xa9, 0xb2, 0x50, 0xf2, 0x1a, 0x8f, - 0x4d, 0x6c, 0x5d, 0xdc, 0x31, 0x3c, 0xfb, 0xc3, 0xce, 0xbb, 0x8b, 0x24, 0xa7, 0xae, 0x5c, 0x7a, 0x57, - 0x2, 0x0, 0xa, 0x3c, 0xeb, 0x32, 0xe9, 0xbc, 0x53, 0x59, 0x12, 0x7d, 0x4e, 0x0, 0x0, 0x14, 0xa9, - 0x9c, 0x14, 0xc7, 0x1a, 0x74, 0xeb, 0x21, 0x1d, 0xc6, 0x1a, 0x8e, 0x69, 0xd0, 0x7, 0x6a, 0x5c, 0x15, - 0x47, 0x7, 0x2, 0x0, 0x1c, 0x68, 0xfc, 0x75, 0x5b, 0x49, 0x83, 0x38, 0xee, 0x69, 0xeb, 0x2f, 0xa5, - 0x7b, 0x93, 0x9f, 0xe2, 0x2f, 0x47, 0xd0, 0xcf, 0x6e, 0x70, 0x57, 0x75, 0x6, 0x63, 0x96, 0x40, 0x0, - 0x0, 0x0, 0x2, 0x0, 0xb, 0x84, 0x2a, 0x54, 0x17, 0x21, 0xa9, 0xb4, 0xad, 0xef, 0x74, 0x3d, 0x2, - 0x0, 0x10, 0xb8, 0xc6, 0x3b, 0x3, 0xdd, 0x2, 0xca, 0xe3, 0x5b, 0xc5, 0x71, 0x3b, 0x36, 0xbd, 0xa, - 0xa9, 0x0, 0x0, 0x6, 0x78, 0x33, 0x30, 0xc7, 0xa3, 0xc1, 0x2, 0x0, 0xd, 0x73, 0xe2, 0xe5, 0xb9, - 0x4e, 0x5d, 0xad, 0x2d, 0xb0, 0xc7, 0xb7, 0xc9, 0xdb, 0x0, 0x0, 0x1a, 0xe4, 0x86, 0xc3, 0xc6, 0xef, - 0xe8, 0xf5, 0x99, 0x6, 0x64, 0x2e, 0x82, 0x25, 0x24, 0x39, 0x44, 0xed, 0xe7, 0x9e, 0x1, 0xa0, 0xf2, - 0x97, 0xaa, 0x5c, 0x49, 0x1, 0x0, 0x0, 0x0}; + uint8_t pkt[] = {0x82, 0x5e, 0x68, 0xec, 0x0, 0x14, 0x5c, 0x8d, 0xfe, 0x18, 0xd9, 0x14, 0xf0, 0xf4, 0x7f, 0x78, + 0x3b, 0xee, 0xe, 0xa8, 0x36, 0x41, 0xdf, 0x76, 0xa3, 0x80, 0x1, 0x0, 0xb, 0x74, 0xb5, 0x3e, + 0x35, 0x2f, 0xf5, 0xc, 0x9b, 0xa1, 0xb8, 0xd3, 0x0, 0x0, 0xf, 0x2, 0x3d, 0x8, 0x96, 0x64, + 0xdb, 0xc8, 0xb1, 0xb2, 0xe2, 0x44, 0x99, 0xfc, 0x41, 0xe5, 0x1, 0x0, 0xa, 0xf5, 0x8a, 0xc, + 0x6c, 0xe4, 0x9f, 0xe0, 0x42, 0x6e, 0x79, 0x0, 0x0, 0x15, 0xc2, 0x74, 0xf4, 0xce, 0x9e, 0x9b, + 0x3e, 0x80, 0xb7, 0x79, 0xc7, 0xad, 0xc3, 0xc7, 0x7e, 0x46, 0x96, 0x3b, 0x8e, 0xb2, 0x64, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x89, 0xe6, 0x8d, 0x6, 0xa9, 0xb2, 0x50, 0xf2, 0x1a, 0x8f, 0x4d, 0x6c, 0x5d, 0xdc, - 0x31, 0x3c, 0xfb, 0xc3, 0xce, 0xbb, 0x8b, 0x24, 0xa7, 0xae, 0x5c, 0x7a, 0x57}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x5c, 0x8d, 0xfe, 0x18, 0xd9, 0x14, 0xf0, 0xf4, 0x7f, 0x78, + 0x3b, 0xee, 0xe, 0xa8, 0x36, 0x41, 0xdf, 0x76, 0xa3, 0x80}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3c, 0xeb, 0x32, 0xe9, 0xbc, 0x53, 0x59, 0x12, 0x7d, 0x4e}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x74, 0xb5, 0x3e, 0x35, 0x2f, 0xf5, 0xc, 0x9b, 0xa1, 0xb8, 0xd3}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa9, 0x9c, 0x14, 0xc7, 0x1a, 0x74, 0xeb, 0x21, 0x1d, 0xc6, - 0x1a, 0x8e, 0x69, 0xd0, 0x7, 0x6a, 0x5c, 0x15, 0x47, 0x7}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2, 0x3d, 0x8, 0x96, 0x64, 0xdb, 0xc8, 0xb1, + 0xb2, 0xe2, 0x44, 0x99, 0xfc, 0x41, 0xe5}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x68, 0xfc, 0x75, 0x5b, 0x49, 0x83, 0x38, 0xee, 0x69, 0xeb, - 0x2f, 0xa5, 0x7b, 0x93, 0x9f, 0xe2, 0x2f, 0x47, 0xd0, 0xcf, - 0x6e, 0x70, 0x57, 0x75, 0x6, 0x63, 0x96, 0x40}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf5, 0x8a, 0xc, 0x6c, 0xe4, 0x9f, 0xe0, 0x42, 0x6e, 0x79}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc2, 0x74, 0xf4, 0xce, 0x9e, 0x9b, 0x3e, 0x80, 0xb7, 0x79, 0xc7, + 0xad, 0xc3, 0xc7, 0x7e, 0x46, 0x96, 0x3b, 0x8e, 0xb2, 0x64}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x84, 0x2a, 0x54, 0x17, 0x21, 0xa9, 0xb4, 0xad, 0xef, 0x74, 0x3d}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb8, 0xc6, 0x3b, 0x3, 0xdd, 0x2, 0xca, 0xe3, - 0x5b, 0xc5, 0x71, 0x3b, 0x36, 0xbd, 0xa, 0xa9}; - lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x78, 0x33, 0x30, 0xc7, 0xa3, 0xc1}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x73, 0xe2, 0xe5, 0xb9, 0x4e, 0x5d, 0xad, 0x2d, 0xb0, 0xc7, 0xb7, 0xc9, 0xdb}; - lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe4, 0x86, 0xc3, 0xc6, 0xef, 0xe8, 0xf5, 0x99, 0x6, 0x64, 0x2e, 0x82, 0x25, - 0x24, 0x39, 0x44, 0xed, 0xe7, 0x9e, 0x1, 0xa0, 0xf2, 0x97, 0xaa, 0x5c, 0x49}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0}; - lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -10937,7 +10912,7 @@ TEST(Subscribe311QCTest, Encode7) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -10945,141 +10920,155 @@ TEST(Subscribe311QCTest, Encode7) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27247, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26860, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15611 [("\NUL\212p\201h\br'2ko\162\SYN\242U\173Sp\182\184",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 11675 [("n\192\248\255\205<\240\238\SO!\140\179\201",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("o",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\232\ETXX\162\232\228\251b8Y\146c\244\143\247\RS\135",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x19, 0x3c, 0xfb, 0x0, 0x14, 0x0, 0xd4, 0x70, 0xc9, 0x68, 0x8, 0x72, 0x27, - 0x32, 0x6b, 0x6f, 0xa2, 0x16, 0xf2, 0x55, 0xad, 0x53, 0x70, 0xb6, 0xb8, 0x0}; + uint8_t pkt[] = {0x82, 0x2a, 0x2d, 0x9b, 0x0, 0xd, 0x6e, 0xc0, 0xf8, 0xff, 0xcd, 0x3c, 0xf0, 0xee, 0xe, + 0x21, 0x8c, 0xb3, 0xc9, 0x1, 0x0, 0x1, 0x6f, 0x0, 0x0, 0x11, 0xe8, 0x3, 0x58, 0xa2, + 0xe8, 0xe4, 0xfb, 0x62, 0x38, 0x59, 0x92, 0x63, 0xf4, 0x8f, 0xf7, 0x1e, 0x87, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x0, 0xd4, 0x70, 0xc9, 0x68, 0x8, 0x72, 0x27, 0x32, 0x6b, - 0x6f, 0xa2, 0x16, 0xf2, 0x55, 0xad, 0x53, 0x70, 0xb6, 0xb8}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x6e, 0xc0, 0xf8, 0xff, 0xcd, 0x3c, 0xf0, 0xee, 0xe, 0x21, 0x8c, 0xb3, 0xc9}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s1_bytes[] = {0x6f}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xe8, 0x3, 0x58, 0xa2, 0xe8, 0xe4, 0xfb, 0x62, 0x38, + 0x59, 0x92, 0x63, 0xf4, 0x8f, 0xf7, 0x1e, 0x87}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15611, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11675, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 16791 [("\\\ACK\129B1\149Y/2\178vx\RSo",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 3007 [("<\ESCJ\DC2V\230\n\158\168\250G%\212R\210V\227\229\134j\165\&3)\146\165\&95",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("_\234\180~!\246(\231}4\200\221\168\191\149\197$0\202\223\&0\150\vE\169\217\189",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\GS\195\202\227\242t}K9k\EMD\149|\186\ESC~tO\216\200\234",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\157\170\249\222\&8\248\181\190\212q\151\133\186\245\171\223g1)U\206\a\135",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("y\245\244\225K\177[\153B\179@\161\193",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\146\247\211\182H z\bK\191\RS\194V\134\&8$\221;8",SubOptions +// QoS2}),("Nz\DC2\155\&2\182\ETB>)\DC2&?\246\193i`\151\NAK_\US4\DC1\252\234\DC2Z\NUL\a\153",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("@\194TRT +// \178\157\251\225q\SO\181(\194\220\217p",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\206\DLE\241X5E\154\204\CAN\229~hlj{`f1\155y\181\DEL\217;",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\167\159W\185-u;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("X\246\247\218G\162mZ(\DEL\EM\172",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\152X9\166\177\RS\226\222\212\128",SubOptions +// QoS0}),("\201{}\179\NAK",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("f\t\SYN\165=\225\132\NUL\207\161F\250\237\SOH\195\142\"\148",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\186\ETX[",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\236\NAK\169\245",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("@I\210\CAN\210\EM\200\RS\186\ETB\235\180$\182\167\155\138\135>'\246",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS1}),("\234\250\254\182(\DEL\154mqQ\135K\160MA\174\234\211\145}\187\DC2hn/_",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0x98, 0x1, 0x41, 0x97, 0x0, 0xe, 0x5c, 0x6, 0x81, 0x42, 0x31, 0x95, 0x59, 0x2f, 0x32, - 0xb2, 0x76, 0x78, 0x1e, 0x6f, 0x2, 0x0, 0x17, 0x9d, 0xaa, 0xf9, 0xde, 0x38, 0xf8, 0xb5, 0xbe, - 0xd4, 0x71, 0x97, 0x85, 0xba, 0xf5, 0xab, 0xdf, 0x67, 0x31, 0x29, 0x55, 0xce, 0x7, 0x87, 0x2, - 0x0, 0xd, 0x79, 0xf5, 0xf4, 0xe1, 0x4b, 0xb1, 0x5b, 0x99, 0x42, 0xb3, 0x40, 0xa1, 0xc1, 0x2, - 0x0, 0x13, 0x92, 0xf7, 0xd3, 0xb6, 0x48, 0x20, 0x7a, 0x8, 0x4b, 0xbf, 0x1e, 0xc2, 0x56, 0x86, - 0x38, 0x24, 0xdd, 0x3b, 0x38, 0x2, 0x0, 0x7, 0xa7, 0x9f, 0x57, 0xb9, 0x2d, 0x75, 0x3b, 0x0, - 0x0, 0xc, 0x58, 0xf6, 0xf7, 0xda, 0x47, 0xa2, 0x6d, 0x5a, 0x28, 0x7f, 0x19, 0xac, 0x1, 0x0, - 0xa, 0x98, 0x58, 0x39, 0xa6, 0xb1, 0x1e, 0xe2, 0xde, 0xd4, 0x80, 0x2, 0x0, 0x4, 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a, 0xcc, 0x18, 0xe5, 0x7e, 0x68, 0x6c, 0x6a, 0x7b, 0x60, 0x66, 0x31, 0x9b, 0x79, 0xb5, 0x7f, + 0xd9, 0x3b, 0x0, 0x0, 0x5, 0xc9, 0x7b, 0x7d, 0xb3, 0x15, 0x0, 0x0, 0x12, 0x66, 0x9, 0x16, 0xa5, + 0x3d, 0xe1, 0x84, 0x0, 0xcf, 0xa1, 0x46, 0xfa, 0xed, 0x1, 0xc3, 0x8e, 0x22, 0x94, 0x0, 0x0, 0x3, + 0xba, 0x3, 0x5b, 0x1, 0x0, 0x1a, 0xea, 0xfa, 0xfe, 0xb6, 0x28, 0x7f, 0x9a, 0x6d, 0x71, 0x51, 0x87, + 0x4b, 0xa0, 0x4d, 0x41, 0xae, 0xea, 0xd3, 0x91, 0x7d, 0xbb, 0x12, 0x68, 0x6e, 0x2f, 0x5f, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x5c, 0x6, 0x81, 0x42, 0x31, 0x95, 0x59, 0x2f, 0x32, 0xb2, 0x76, 0x78, 0x1e, 0x6f}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x3c, 0x1b, 0x4a, 0x12, 0x56, 0xe6, 0xa, 0x9e, 0xa8, 0xfa, 0x47, 0x25, 0xd4, 0x52, + 0xd2, 0x56, 0xe3, 0xe5, 0x86, 0x6a, 0xa5, 0x33, 0x29, 0x92, 0xa5, 0x39, 0x35}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9d, 0xaa, 0xf9, 0xde, 0x38, 0xf8, 0xb5, 0xbe, 0xd4, 0x71, 0x97, 0x85, - 0xba, 0xf5, 0xab, 0xdf, 0x67, 0x31, 0x29, 0x55, 0xce, 0x7, 0x87}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5f, 0xea, 0xb4, 0x7e, 0x21, 0xf6, 0x28, 0xe7, 0x7d, 0x34, 0xc8, 0xdd, 0xa8, 0xbf, + 0x95, 0xc5, 0x24, 0x30, 0xca, 0xdf, 0x30, 0x96, 0xb, 0x45, 0xa9, 0xd9, 0xbd}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x79, 0xf5, 0xf4, 0xe1, 0x4b, 0xb1, 0x5b, 0x99, 0x42, 0xb3, 0x40, 0xa1, 0xc1}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1d, 0xc3, 0xca, 0xe3, 0xf2, 0x74, 0x7d, 0x4b, 0x39, 0x6b, 0x19, + 0x44, 0x95, 0x7c, 0xba, 0x1b, 0x7e, 0x74, 0x4f, 0xd8, 0xc8, 0xea}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x92, 0xf7, 0xd3, 0xb6, 0x48, 0x20, 0x7a, 0x8, 0x4b, 0xbf, - 0x1e, 0xc2, 0x56, 0x86, 0x38, 0x24, 0xdd, 0x3b, 0x38}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa7, 0x9f, 0x57, 0xb9, 0x2d, 0x75, 0x3b}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x4e, 0x7a, 0x12, 0x9b, 0x32, 0xb6, 0x17, 0x3e, 0x29, 0x12, + 0x26, 0x3f, 0xf6, 0xc1, 0x69, 0x60, 0x97, 0x15, 0x5f, 0x1f, + 0x34, 0x11, 0xfc, 0xea, 0x12, 0x5a, 0x0, 0x7, 0x99}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x58, 0xf6, 0xf7, 0xda, 0x47, 0xa2, 0x6d, 0x5a, 0x28, 0x7f, 0x19, 0xac}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x40, 0xc2, 0x54, 0x52, 0x54, 0x20, 0xb2, 0x9d, 0xfb, + 0xe1, 0x71, 0xe, 0xb5, 0x28, 0xc2, 0xdc, 0xd9, 0x70}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x98, 0x58, 0x39, 0xa6, 0xb1, 0x1e, 0xe2, 0xde, 0xd4, 0x80}; - lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xce, 0x10, 0xf1, 0x58, 0x35, 0x45, 0x9a, 0xcc, 0x18, 0xe5, 0x7e, 0x68, + 0x6c, 0x6a, 0x7b, 0x60, 0x66, 0x31, 0x9b, 0x79, 0xb5, 0x7f, 0xd9, 0x3b}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xec, 0x15, 0xa9, 0xf5}; - lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xc9, 0x7b, 0x7d, 0xb3, 0x15}; + lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x40, 0x49, 0xd2, 0x18, 0xd2, 0x19, 0xc8, 0x1e, 0xba, 0x17, 0xeb, - 0xb4, 0x24, 0xb6, 0xa7, 0x9b, 0x8a, 0x87, 0x3e, 0x27, 0xf6}; - lwmqtt_string_t topic_filter_s8 = {21, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x66, 0x9, 0x16, 0xa5, 0x3d, 0xe1, 0x84, 0x0, 0xcf, + 0xa1, 0x46, 0xfa, 0xed, 0x1, 0xc3, 0x8e, 0x22, 0x94}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s9_bytes[] = {0xba, 0x3, 0x5b}; + lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xea, 0xfa, 0xfe, 0xb6, 0x28, 0x7f, 0x9a, 0x6d, 0x71, 0x51, 0x87, 0x4b, 0xa0, + 0x4d, 0x41, 0xae, 0xea, 0xd3, 0x91, 0x7d, 0xbb, 0x12, 0x68, 0x6e, 0x2f, 0x5f}; + lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -11087,7 +11076,7 @@ TEST(Subscribe311QCTest, Encode9) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -11095,7 +11084,7 @@ TEST(Subscribe311QCTest, Encode9) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; @@ -11107,57 +11096,65 @@ TEST(Subscribe311QCTest, Encode9) { sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16791, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3007, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26959 [("O\ESCB(\149\146o\177\249\238&\152\222\148\225\208k<",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\163\ACK\208\ETX}\235\ESC\230\193\202s",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\140>8\177\CAN\US\187w\173\n~\"",SubOptions {_retainHandling = +// SubscribeRequest 30616 [("b\GS\215\182QH\USjKr\230\129\142?Q\129UE\243\147n\229\160)\137",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\164\EMyC\254\225\STX33_\EOTAsM\"\DEL\236\&3jy",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("}\159dgE^\200\218v",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("AdT[\254[\152\249\SUBhe%e\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\201\230\EM\GS4\DC4\233BO]\165",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\245\148@\246iy\SUB\212",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(".6V",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\254\248p\NUL5\\\140j\"\ETX\185\251\223\242+'\214\223z\229\247\219\225Y\ETB\FS\ESC\ESC\254",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\213\190 -// \178\176o\172\166\217\173E\167`)\b\EM\EM\249\204_\DLE\152`\179P",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("N\199\249\DC2\184\STX\149\167\166je\254\207\152\130\210\151\ETB\144\RS\162\130\128\207I\DLE~\162\244<",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\162\199}\255V\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("\215\SOM\234!\158\&7\167\225\183\250\173",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("w\ESCURkJ\215\186\129\131\NAK\"\139d\\\246\228\ESC\SOHA\EM\218D\215\211*",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\186H[`\183\255",SubOptions +// QoS2}),("&\v\205\128\233\230\187\129\181\128S\NUL\222\253\185$*\180i\183",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\135z\215D\NAK\225\197",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\170+\DEL:4\218\131z(#\199^O}\a\193\&0\181\231\231\187\187P\239",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS0}),("v\236\188\199\GS\206N.\208J\187\188q~\n\173.\199\154\SIQ\215\&7",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("d\128\&5B\227\&7\DC3\221\200",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode12) { - uint8_t pkt[] = {0x82, 0xad, 0x1, 0x2f, 0xee, 0x0, 0x11, 0x37, 0xeb, 0x52, 0x38, 0x3f, 0x5c, 0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, 0x0, 0x3c, 0x3e, 0xd4, 0x0, 0x0, 0x3, 0x2e, 0x36, 0x56, 0x2, 0x0, 0x1e, + 0x4e, 0xc7, 0xf9, 0x12, 0xb8, 0x2, 0x95, 0xa7, 0xa6, 0x6a, 0x65, 0xfe, 0xcf, 0x98, 0x82, 0xd2, + 0x97, 0x17, 0x90, 0x1e, 0xa2, 0x82, 0x80, 0xcf, 0x49, 0x10, 0x7e, 0xa2, 0xf4, 0x3c, 0x0, 0x0, + 0x6, 0xa2, 0xc7, 0x7d, 0xff, 0x56, 0x83, 0x1, 0x0, 0xc, 0xd7, 0xe, 0x4d, 0xea, 0x21, 0x9e, + 0x37, 0xa7, 0xe1, 0xb7, 0xfa, 0xad, 0x2, 0x0, 0x14, 0x26, 0xb, 0xcd, 0x80, 0xe9, 0xe6, 0xbb, + 0x81, 0xb5, 0x80, 0x53, 0x0, 0xde, 0xfd, 0xb9, 0x24, 0x2a, 0xb4, 0x69, 0xb7, 0x0, 0x0, 0x7, + 0x87, 0x7a, 0xd7, 0x44, 0x15, 0xe1, 0xc5, 0x0, 0x0, 0x17, 0x76, 0xec, 0xbc, 0xc7, 0x1d, 0xce, + 0x4e, 0x2e, 0xd0, 0x4a, 0xbb, 0xbc, 0x71, 0x7e, 0xa, 0xad, 0x2e, 0xc7, 0x9a, 0xf, 0x51, 0xd7, + 0x37, 0x2, 0x0, 0x9, 0x64, 0x80, 0x35, 0x42, 0xe3, 0x37, 0x13, 0xdd, 0xc8, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x37, 0xeb, 0x52, 0x38, 0x3f, 0x5c, 0xc8, 0x37, 0x5e, - 0x6a, 0x4e, 0xed, 0x12, 0xe5, 0x36, 0x4f, 0x37}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xf1, 0xb6, 0xdd, 0x18, 0xa, 0x6e, 0x38, 0xa, + 0x90, 0x97, 0x39, 0xc6, 0x0, 0x3c, 0x3e, 0xd4}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9a, 0xdf, 0xba, 0x5e, 0xc9, 0xa4, 0xcf, 0xe6, 0xa0, 0x1d, 0x69, 0xcd, - 0xd2, 0xcc, 0x3d, 0x28, 0xc4, 0x18, 0xbf, 0x48, 0xa9, 0x44, 0x60}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2e, 0x36, 0x56}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfe, 0xf8, 0x70, 0x0, 0x35, 0x5c, 0x8c, 0x6a, 0x22, 0x3, - 0xb9, 0xfb, 0xdf, 0xf2, 0x2b, 0x27, 0xd6, 0xdf, 0x7a, 0xe5, - 0xf7, 0xdb, 0xe1, 0x59, 0x17, 0x1c, 0x1b, 0x1b, 0xfe}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4e, 0xc7, 0xf9, 0x12, 0xb8, 0x2, 0x95, 0xa7, 0xa6, 0x6a, + 0x65, 0xfe, 0xcf, 0x98, 0x82, 0xd2, 0x97, 0x17, 0x90, 0x1e, + 0xa2, 0x82, 0x80, 0xcf, 0x49, 0x10, 0x7e, 0xa2, 0xf4, 0x3c}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd5, 0xbe, 0x20, 0xb2, 0xb0, 0x6f, 0xac, 0xa6, 0xd9, 0xad, 0x45, 0xa7, 0x60, - 0x29, 0x8, 0x19, 0x19, 0xf9, 0xcc, 0x5f, 0x10, 0x98, 0x60, 0xb3, 0x50}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa2, 0xc7, 0x7d, 0xff, 0x56, 0x83}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x77, 0x1b, 0x55, 0x52, 0x6b, 0x4a, 0xd7, 0xba, 0x81, 0x83, 0x15, 0x22, 0x8b, - 0x64, 0x5c, 0xf6, 0xe4, 0x1b, 0x1, 0x41, 0x19, 0xda, 0x44, 0xd7, 0xd3, 0x2a}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd7, 0xe, 0x4d, 0xea, 0x21, 0x9e, 0x37, 0xa7, 0xe1, 0xb7, 0xfa, 0xad}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xba, 0x48, 0x5b, 0x60, 0xb7, 0xff}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x26, 0xb, 0xcd, 0x80, 0xe9, 0xe6, 0xbb, 0x81, 0xb5, 0x80, + 0x53, 0x0, 0xde, 0xfd, 0xb9, 0x24, 0x2a, 0xb4, 0x69, 0xb7}; + lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xaa, 0x2b, 0x7f, 0x3a, 0x34, 0xda, 0x83, 0x7a, 0x28, 0x23, 0xc7, 0x5e, - 0x4f, 0x7d, 0x7, 0xc1, 0x30, 0xb5, 0xe7, 0xe7, 0xbb, 0xbb, 0x50, 0xef}; - lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x87, 0x7a, 0xd7, 0x44, 0x15, 0xe1, 0xc5}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s7_bytes[] = {0x76, 0xec, 0xbc, 0xc7, 0x1d, 0xce, 0x4e, 0x2e, 0xd0, 0x4a, 0xbb, 0xbc, + 0x71, 0x7e, 0xa, 0xad, 0x2e, 0xc7, 0x9a, 0xf, 0x51, 0xd7, 0x37}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x64, 0x80, 0x35, 0x42, 0xe3, 0x37, 0x13, 0xdd, 0xc8}; + lwmqtt_string_t topic_filter_s8 = {9, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -11375,207 +11337,277 @@ TEST(Subscribe311QCTest, Encode12) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12270, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31365, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18547 [("\189J\145\DC3y\183\216\164\150\129\238l\168;Q\211/\253\211\135%\144\153\\\160",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\b@\172f,>\129\206D\233\DEL\225\131B}\239\133\177\140\196\193j\DC1\237",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\152\130\187",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\143\DC1\220\180\147#-\155\181y",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\235.\t\SOH\DC2\EM/vM\205b",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 3963 [("&\249+\165\255",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0x5a, 0x48, 0x73, 0x0, 0x19, 0xbd, 0x4a, 0x91, 0x13, 0x79, 0xb7, 0xd8, 0xa4, 0x96, 0x81, - 0xee, 0x6c, 0xa8, 0x3b, 0x51, 0xd3, 0x2f, 0xfd, 0xd3, 0x87, 0x25, 0x90, 0x99, 0x5c, 0xa0, 0x2, - 0x0, 0x18, 0x8, 0x40, 0xac, 0x66, 0x2c, 0x3e, 0x81, 0xce, 0x44, 0xe9, 0x7f, 0xe1, 0x83, 0x42, - 0x7d, 0xef, 0x85, 0xb1, 0x8c, 0xc4, 0xc1, 0x6a, 0x11, 0xed, 0x0, 0x0, 0x3, 0x98, 0x82, 0xbb, - 0x0, 0x0, 0xa, 0x8f, 0x11, 0xdc, 0xb4, 0x93, 0x23, 0x2d, 0x9b, 0xb5, 0x79, 0x2, 0x0, 0xb, - 0xeb, 0x2e, 0x9, 0x1, 0x12, 0x19, 0x2f, 0x76, 0x4d, 0xcd, 0x62, 0x0}; + uint8_t pkt[] = {0x82, 0xa, 0xf, 0x7b, 0x0, 0x5, 0x26, 0xf9, 0x2b, 0xa5, 0xff, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xbd, 0x4a, 0x91, 0x13, 0x79, 0xb7, 0xd8, 0xa4, 0x96, 0x81, 0xee, 0x6c, 0xa8, - 0x3b, 0x51, 0xd3, 0x2f, 0xfd, 0xd3, 0x87, 0x25, 0x90, 0x99, 0x5c, 0xa0}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x26, 0xf9, 0x2b, 0xa5, 0xff}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8, 0x40, 0xac, 0x66, 0x2c, 0x3e, 0x81, 0xce, 0x44, 0xe9, 0x7f, 0xe1, - 0x83, 0x42, 0x7d, 0xef, 0x85, 0xb1, 0x8c, 0xc4, 0xc1, 0x6a, 0x11, 0xed}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x98, 0x82, 0xbb}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8f, 0x11, 0xdc, 0xb4, 0x93, 0x23, 0x2d, 0x9b, 0xb5, 0x79}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xeb, 0x2e, 0x9, 0x1, 0x12, 0x19, 0x2f, 0x76, 0x4d, 0xcd, 0x62}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; + lwmqtt_sub_options_t sub_opts[1]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18547, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3963, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 10474 [(",+{\129\233\223\145\247o8\195\202\SIEVN\152\206m\181$\172\204\250HR\169",SubOptions +// SubscribeRequest 27481 [("\173\187\212\&85\132\164-<\f",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("j\187\191\158GB4 +// \150\146\235\244\140\&1\188\t\220\225\SI+O\165\163\DLE'\SI\226\221\181\254",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\210\&5",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("a\169{+\204\189x\GS{`\\\195",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("Q\\\225\194\n\180\179d|\208<\202R,\183\137\RSh",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\170[\206)\DC4\217gT\220\238",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\194y\219\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS2}),("^\135\131R\219\\\129W@5`^\130\225?\243\200\157",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Z\177\195\252s\ESCh\253 \b\f6\DC4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\166\138\DC3\154:7\189]-\201p\160\223*R,\224",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("6\EM\165\136\194\149\NULb\236I\138\FS\207\&5qi\206\228\169i\r\252\132R\237",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0x34, 0x28, 0xea, 0x0, 0x1b, 0x2c, 0x2b, 0x7b, 0x81, 0xe9, 0xdf, 0x91, 0xf7, - 0x6f, 0x38, 0xc3, 0xca, 0xf, 0x45, 0x56, 0x4e, 0x98, 0xce, 0x6d, 0xb5, 0x24, 0xac, - 0xcc, 0xfa, 0x48, 0x52, 0xa9, 0x0, 0x0, 0xa, 0xaa, 0x5b, 0xce, 0x29, 0x14, 0xd9, - 0x67, 0x54, 0xdc, 0xee, 0x2, 0x0, 0x4, 0xc2, 0x79, 0xdb, 0xb4, 0x1}; + uint8_t pkt[] = {0x82, 0xb4, 0x1, 0x6b, 0x59, 0x0, 0xa, 0xad, 0xbb, 0xd4, 0x38, 0x35, 0x84, 0xa4, 0x2d, 0x3c, 0xc, + 0x1, 0x0, 0x1e, 0x6a, 0xbb, 0xbf, 0x9e, 0x47, 0x42, 0x34, 0x20, 0x96, 0x92, 0xeb, 0xf4, 0x8c, 0x31, + 0xbc, 0x9, 0xdc, 0xe1, 0xf, 0x2b, 0x4f, 0xa5, 0xa3, 0x10, 0x27, 0xf, 0xe2, 0xdd, 0xb5, 0xfe, 0x2, + 0x0, 0x2, 0xd2, 0x35, 0x2, 0x0, 0xc, 0x61, 0xa9, 0x7b, 0x2b, 0xcc, 0xbd, 0x78, 0x1d, 0x7b, 0x60, + 0x5c, 0xc3, 0x0, 0x0, 0x18, 0x51, 0x5c, 0xe1, 0x3c, 0x54, 0x70, 0xcc, 0x3c, 0x3e, 0xc2, 0xa, 0xb4, + 0xb3, 0x64, 0x7c, 0xd0, 0x3c, 0xca, 0x52, 0x2c, 0xb7, 0x89, 0x1e, 0x68, 0x2, 0x0, 0x12, 0x5e, 0x87, + 0x83, 0x52, 0xdb, 0x5c, 0x81, 0x57, 0x40, 0x35, 0x60, 0x5e, 0x82, 0xe1, 0x3f, 0xf3, 0xc8, 0x9d, 0x2, + 0x0, 0xd, 0x5a, 0xb1, 0xc3, 0xfc, 0x73, 0x1b, 0x68, 0xfd, 0x20, 0x8, 0xc, 0x36, 0x14, 0x2, 0x0, + 0x11, 0xa6, 0x8a, 0x13, 0x9a, 0x3a, 0x37, 0xbd, 0x5d, 0x2d, 0xc9, 0x70, 0xa0, 0xdf, 0x2a, 0x52, 0x2c, + 0xe0, 0x2, 0x0, 0x19, 0x36, 0x19, 0xa5, 0x88, 0xc2, 0x95, 0x0, 0x62, 0xec, 0x49, 0x8a, 0x1c, 0xcf, + 0x35, 0x71, 0x69, 0xce, 0xe4, 0xa9, 0x69, 0xd, 0xfc, 0x84, 0x52, 0xed, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x2c, 0x2b, 0x7b, 0x81, 0xe9, 0xdf, 0x91, 0xf7, 0x6f, 0x38, 0xc3, 0xca, 0xf, 0x45, - 0x56, 0x4e, 0x98, 0xce, 0x6d, 0xb5, 0x24, 0xac, 0xcc, 0xfa, 0x48, 0x52, 0xa9}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xad, 0xbb, 0xd4, 0x38, 0x35, 0x84, 0xa4, 0x2d, 0x3c, 0xc}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xaa, 0x5b, 0xce, 0x29, 0x14, 0xd9, 0x67, 0x54, 0xdc, 0xee}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6a, 0xbb, 0xbf, 0x9e, 0x47, 0x42, 0x34, 0x20, 0x96, 0x92, + 0xeb, 0xf4, 0x8c, 0x31, 0xbc, 0x9, 0xdc, 0xe1, 0xf, 0x2b, + 0x4f, 0xa5, 0xa3, 0x10, 0x27, 0xf, 0xe2, 0xdd, 0xb5, 0xfe}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc2, 0x79, 0xdb, 0xb4}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd2, 0x35}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + uint8_t topic_filter_s3_bytes[] = {0x61, 0xa9, 0x7b, 0x2b, 0xcc, 0xbd, 0x78, 0x1d, 0x7b, 0x60, 0x5c, 0xc3}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x51, 0x5c, 0xe1, 0x3c, 0x54, 0x70, 0xcc, 0x3c, 0x3e, 0xc2, 0xa, 0xb4, + 0xb3, 0x64, 0x7c, 0xd0, 0x3c, 0xca, 0x52, 0x2c, 0xb7, 0x89, 0x1e, 0x68}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x5e, 0x87, 0x83, 0x52, 0xdb, 0x5c, 0x81, 0x57, 0x40, + 0x35, 0x60, 0x5e, 0x82, 0xe1, 0x3f, 0xf3, 0xc8, 0x9d}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x5a, 0xb1, 0xc3, 0xfc, 0x73, 0x1b, 0x68, 0xfd, 0x20, 0x8, 0xc, 0x36, 0x14}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xa6, 0x8a, 0x13, 0x9a, 0x3a, 0x37, 0xbd, 0x5d, 0x2d, + 0xc9, 0x70, 0xa0, 0xdf, 0x2a, 0x52, 0x2c, 0xe0}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x36, 0x19, 0xa5, 0x88, 0xc2, 0x95, 0x0, 0x62, 0xec, 0x49, 0x8a, 0x1c, 0xcf, + 0x35, 0x71, 0x69, 0xce, 0xe4, 0xa9, 0x69, 0xd, 0xfc, 0x84, 0x52, 0xed}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10474, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27481, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20401 [("\210n-\209\154iPp\201\217l\192\SOHlY\242\n$\144@t",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("@T\180Z\153\"\b\RS8\223%\224\&5z\DC2`\170\NAK\179\224!\SI\153}\149O\252\199\182",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("P\EM \252RA1y\233=Q -// \206U\161\SUB\NULSCcv\153\&1n\132\135T\138N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\233\&2\236\152@\229Z\RS\247\249\142\241\147\181\234\al}\228\167\157",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("G\193\ETB\152\&84H\fg2\215\f\DC26\209\t\216xr\172\225>\246Es/_\201",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\SUB\164q\168\180\218\223\190\207RU\153\250\238+E\247\244\183\231\225",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\221\149A\211\195",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 32387 +// [("\205Yv\244\133\240o\244\240\227\&6\170r\201\GS\177\160\165\236\219\187K\FS\205\151\152",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\164\170z",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode15) { - uint8_t pkt[] = {0x82, 0xb1, 0x1, 0x4f, 0xb1, 0x0, 0x15, 0xd2, 0x6e, 0x2d, 0xd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f0, 0xe3, 0x36, 0xaa, 0x72, 0xc9, 0x1d, 0xb1, 0xa0, 0xa5, 0xec, 0xdb, + 0xbb, 0x4b, 0x1c, 0xcd, 0x97, 0x98, 0x0, 0x0, 0x3, 0xa4, 0xaa, 0x7a, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xd2, 0x6e, 0x2d, 0xd1, 0x9a, 0x69, 0x50, 0x70, 0xc9, 0xd9, 0x6c, - 0xc0, 0x1, 0x6c, 0x59, 0xf2, 0xa, 0x24, 0x90, 0x40, 0x74}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xcd, 0x59, 0x76, 0xf4, 0x85, 0xf0, 0x6f, 0xf4, 0xf0, 0xe3, 0x36, 0xaa, 0x72, + 0xc9, 0x1d, 0xb1, 0xa0, 0xa5, 0xec, 0xdb, 0xbb, 0x4b, 0x1c, 0xcd, 0x97, 0x98}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x40, 0x54, 0xb4, 0x5a, 0x99, 0x22, 0x8, 0x1e, 0x38, 0xdf, - 0x25, 0xe0, 0x35, 0x7a, 0x12, 0x60, 0xaa, 0x15, 0xb3, 0xe0, - 0x21, 0xf, 0x99, 0x7d, 0x95, 0x4f, 0xfc, 0xc7, 0xb6}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa4, 0xaa, 0x7a}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x50, 0x19, 0x20, 0xfc, 0x52, 0x41, 0x31, 0x79, 0xe9, 0x3d, - 0x51, 0x20, 0xce, 0x55, 0xa1, 0x1a, 0x0, 0x53, 0x43, 0x63, - 0x76, 0x99, 0x31, 0x6e, 0x84, 0x87, 0x54, 0x8a, 0x4e}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32387, 2, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 27695 [("\244savN\237\&9\ETB\SUB\239C\CAN\184a\157b\NUL\151u\142\230\r",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("D\153\DC2\SOH",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\SYN\139\192\ETB\205fr\136\n\229V\162C\DC3\130\ENQ\DC1\228\179\196C\192\RS\DEL",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\149\140\bL\128\SI\252T",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = +// QoS0}),("\164\138\235VW\242\242\a\134\243\168\215tQK\DLE\179\202\207\250A\EM\226\174]\a",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("!W\178\139't\202\166K\r\223\151",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\180\239\139\STX\NULd",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\133\235X3\227\134\248\236\248\231",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\170\153\226",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode16) { + uint8_t pkt[] = {0x82, 0x90, 0x1, 0x6c, 0x2f, 0x0, 0x16, 0xf4, 0x73, 0x61, 0x76, 0x4e, 0xed, 0x39, 0x17, 0x1a, 0xef, + 0x43, 0x18, 0xb8, 0x61, 0x9d, 0x62, 0x0, 0x97, 0x75, 0x8e, 0xe6, 0xd, 0x1, 0x0, 0x4, 0x44, 0x99, + 0x12, 0x1, 0x0, 0x0, 0x18, 0x16, 0x8b, 0xc0, 0x17, 0xcd, 0x66, 0x72, 0x88, 0xa, 0xe5, 0x56, 0xa2, + 0x43, 0x13, 0x82, 0x5, 0x11, 0xe4, 0xb3, 0xc4, 0x43, 0xc0, 0x1e, 0x7f, 0x1, 0x0, 0x8, 0x95, 0x8c, + 0x8, 0x4c, 0x80, 0xf, 0xfc, 0x54, 0x0, 0x0, 0x1a, 0xa4, 0x8a, 0xeb, 0x56, 0x57, 0xf2, 0xf2, 0x7, + 0x86, 0xf3, 0xa8, 0xd7, 0x74, 0x51, 0x4b, 0x10, 0xb3, 0xca, 0xcf, 0xfa, 0x41, 0x19, 0xe2, 0xae, 0x5d, + 0x7, 0x2, 0x0, 0xc, 0x21, 0x57, 0xb2, 0x8b, 0x27, 0x74, 0xca, 0xa6, 0x4b, 0xd, 0xdf, 0x97, 0x2, + 0x0, 0x6, 0xb4, 0xef, 0x8b, 0x2, 0x0, 0x64, 0x1, 0x0, 0xa, 0x85, 0xeb, 0x58, 0x33, 0xe3, 0x86, + 0xf8, 0xec, 0xf8, 0xe7, 0x0, 0x0, 0x3, 0xaa, 0x99, 0xe2, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xf4, 0x73, 0x61, 0x76, 0x4e, 0xed, 0x39, 0x17, 0x1a, 0xef, 0x43, + 0x18, 0xb8, 0x61, 0x9d, 0x62, 0x0, 0x97, 0x75, 0x8e, 0xe6, 0xd}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x44, 0x99, 0x12, 0x1}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x16, 0x8b, 0xc0, 0x17, 0xcd, 0x66, 0x72, 0x88, 0xa, 0xe5, 0x56, 0xa2, + 0x43, 0x13, 0x82, 0x5, 0x11, 0xe4, 0xb3, 0xc4, 0x43, 0xc0, 0x1e, 0x7f}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe9, 0x32, 0xec, 0x98, 0x40, 0xe5, 0x5a, 0x1e, 0xf7, 0xf9, 0x8e, - 0xf1, 0x93, 0xb5, 0xea, 0x7, 0x6c, 0x7d, 0xe4, 0xa7, 0x9d}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x95, 0x8c, 0x8, 0x4c, 0x80, 0xf, 0xfc, 0x54}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x47, 0xc1, 0x17, 0x98, 0x38, 0x34, 0x48, 0xc, 0x67, 0x32, - 0xd7, 0xc, 0x12, 0x36, 0xd1, 0x9, 0xd8, 0x78, 0x72, 0xac, - 0xe1, 0x3e, 0xf6, 0x45, 0x73, 0x2f, 0x5f, 0xc9}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa4, 0x8a, 0xeb, 0x56, 0x57, 0xf2, 0xf2, 0x7, 0x86, 0xf3, 0xa8, 0xd7, 0x74, + 0x51, 0x4b, 0x10, 0xb3, 0xca, 0xcf, 0xfa, 0x41, 0x19, 0xe2, 0xae, 0x5d, 0x7}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1a, 0xa4, 0x71, 0xa8, 0xb4, 0xda, 0xdf, 0xbe, 0xcf, 0x52, 0x55, - 0x99, 0xfa, 0xee, 0x2b, 0x45, 0xf7, 0xf4, 0xb7, 0xe7, 0xe1}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x21, 0x57, 0xb2, 0x8b, 0x27, 0x74, 0xca, 0xa6, 0x4b, 0xd, 0xdf, 0x97}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xdd, 0x95, 0x41, 0xd3, 0xc3}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb4, 0xef, 0x8b, 0x2, 0x0, 0x64}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; + uint8_t topic_filter_s7_bytes[] = {0x85, 0xeb, 0x58, 0x33, 0xe3, 0x86, 0xf8, 0xec, 0xf8, 0xe7}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xaa, 0x99, 0xe2}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -11583,7 +11615,7 @@ TEST(Subscribe311QCTest, Encode15) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -11591,41 +11623,57 @@ TEST(Subscribe311QCTest, Encode15) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20401, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27695, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8563 [("\143\195\RS\DEL-\129\b/n _",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\152K\195\r\158\128&X\SUB\FSI\163y\128\203\171\SO\227\231K\213\SI&Y\211\EM",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0x2d, 0x21, 0x73, 0x0, 0xb, 0x8f, 0xc3, 0x1e, 0x7f, 0x2d, 0x81, 0x8, 0x2f, 0x6e, 0x20, - 0x5f, 0x1, 0x0, 0x1a, 0x98, 0x4b, 0xc3, 0xd, 0x9e, 0x80, 0x26, 0x58, 0x1a, 0x1c, 0x49, 0xa3, - 0x79, 0x80, 0xcb, 0xab, 0xe, 0xe3, 0xe7, 0x4b, 0xd5, 0xf, 0x26, 0x59, 0xd3, 0x19, 0x2}; +// SubscribeRequest 29411 [(")\137\189d\189&\250#\214n1\GS\218A\245\158\136\t;\247\175:A\180\233",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\209\DLEs\183`\203\204*\136K\202\223k",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("\214?\172zE\154=\DLE\186u!\132\140a\183\249\&3\189\186)\139\SUB",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode17) { + uint8_t pkt[] = {0x82, 0x47, 0x72, 0xe3, 0x0, 0x19, 0x29, 0x89, 0xbd, 0x64, 0xbd, 0x26, 0xfa, 0x23, 0xd6, + 0x6e, 0x31, 0x1d, 0xda, 0x41, 0xf5, 0x9e, 0x88, 0x9, 0x3b, 0xf7, 0xaf, 0x3a, 0x41, 0xb4, + 0xe9, 0x2, 0x0, 0xd, 0xd1, 0x10, 0x73, 0xb7, 0x60, 0xcb, 0xcc, 0x2a, 0x88, 0x4b, 0xca, + 0xdf, 0x6b, 0x2, 0x0, 0x16, 0xd6, 0x3f, 0xac, 0x7a, 0x45, 0x9a, 0x3d, 0x10, 0xba, 0x75, + 0x21, 0x84, 0x8c, 0x61, 0xb7, 0xf9, 0x33, 0xbd, 0xba, 0x29, 0x8b, 0x1a, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x8f, 0xc3, 0x1e, 0x7f, 0x2d, 0x81, 0x8, 0x2f, 0x6e, 0x20, 0x5f}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x29, 0x89, 0xbd, 0x64, 0xbd, 0x26, 0xfa, 0x23, 0xd6, 0x6e, 0x31, 0x1d, 0xda, + 0x41, 0xf5, 0x9e, 0x88, 0x9, 0x3b, 0xf7, 0xaf, 0x3a, 0x41, 0xb4, 0xe9}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x98, 0x4b, 0xc3, 0xd, 0x9e, 0x80, 0x26, 0x58, 0x1a, 0x1c, 0x49, 0xa3, 0x79, - 0x80, 0xcb, 0xab, 0xe, 0xe3, 0xe7, 0x4b, 0xd5, 0xf, 0x26, 0x59, 0xd3, 0x19}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd1, 0x10, 0x73, 0xb7, 0x60, 0xcb, 0xcc, 0x2a, 0x88, 0x4b, 0xca, 0xdf, 0x6b}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s2_bytes[] = {0xd6, 0x3f, 0xac, 0x7a, 0x45, 0x9a, 0x3d, 0x10, 0xba, 0x75, 0x21, + 0x84, 0x8c, 0x61, 0xb7, 0xf9, 0x33, 0xbd, 0xba, 0x29, 0x8b, 0x1a}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11633,80 +11681,111 @@ TEST(Subscribe311QCTest, Encode16) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8563, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29411, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7682 [("\RS `P\209\153\210\225\236\187\202\241L\148\241X",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\ENQM\221\168\223",SubOptions +// SubscribeRequest 22557 [("#\164A\r\139\STX;\197\SIwh\SYN\201\230\252\196\208K",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\137\185l\EOT\205\r\219\t.\239j\181j,*k\255\SO}L",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("d\196T\247\DC4\198\165\SUB1\a\181\255",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\138\SYN\nG\DC3\GS\189\169\136\188\248~1A\160\133\254\212)\197\\",SubOptions {_retainHandling = +// QoS2}),("\ACK\155R\SYN\217\207\&3\145V\215ws\192\177\184S",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("#\161\214\195\f@H\130\av\155\169\241\157\251\196\231\233\135V\142",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("X\218\142\219\222C\214\142\ETX\209]-\202k\ESC\146h\161m\207",SubOptions {_retainHandling = SendOnSubscribe, +// QoS1}),("/\172\STX\DC2\"`\224+\179{\129\239\180\165\221\248\189\133",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\165\153\b\146/\NUL\131\v\215\&9=O\238-\235\DLEg\161@\SYN\ENQ\bZ\163\223\185z",SubOptions {_retainHandling = +// QoS0}),("\169\228LZ\199^-&\NAKA\f\129\251\EOT]\FS\185h\190Zn6\252\DLE\187\153\170d\148",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\201'\162\130h\150\158/\184\FS\131\156\251",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode17) { - uint8_t pkt[] = {0x82, 0x7a, 0x1e, 0x2, 0x0, 0x10, 0x1e, 0x20, 0x60, 0x50, 0xd1, 0x99, 0xd2, 0xe1, 0xec, 0xbb, - 0xca, 0xf1, 0x4c, 0x94, 0xf1, 0x58, 0x2, 0x0, 0x5, 0x5, 0x4d, 0xdd, 0xa8, 0xdf, 0x0, 0x0, - 0x15, 0x8a, 0x16, 0xa, 0x47, 0x13, 0x1d, 0xbd, 0xa9, 0x88, 0xbc, 0xf8, 0x7e, 0x31, 0x41, 0xa0, - 0x85, 0xfe, 0xd4, 0x29, 0xc5, 0x5c, 0x0, 0x0, 0x14, 0x58, 0xda, 0x8e, 0xdb, 0xde, 0x43, 0xd6, - 0x8e, 0x3, 0xd1, 0x5d, 0x2d, 0xca, 0x6b, 0x1b, 0x92, 0x68, 0xa1, 0x6d, 0xcf, 0x2, 0x0, 0x1b, - 0xa5, 0x99, 0x8, 0x92, 0x2f, 0x0, 0x83, 0xb, 0xd7, 0x39, 0x3d, 0x4f, 0xee, 0x2d, 0xeb, 0x10, - 0x67, 0xa1, 0x40, 0x16, 0x5, 0x8, 0x5a, 0xa3, 0xdf, 0xb9, 0x7a, 0x0, 0x0, 0xd, 0xc9, 0x27, - 0xa2, 0x82, 0x68, 0x96, 0x9e, 0x2f, 0xb8, 0x1c, 0x83, 0x9c, 0xfb, 0x0}; +// QoS2}),("\251\166\176\214=\STX\232\&4\248\r\254\\\184(\142\213\SO\140L\217\DC4\221y\202\169\138\206\145\182\192",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\170*\229'\207\130\193\237\139\159>\223\200\200\153\SOH\132\208\190\DC2\153\190\213O\190\DLE.\\y",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode18) { + uint8_t pkt[] = { + 0x82, 0xde, 0x1, 0x58, 0x1d, 0x0, 0x12, 0x23, 0xa4, 0x41, 0xd, 0x8b, 0x2, 0x3b, 0xc5, 0xf, 0x77, 0x68, 0x16, + 0xc9, 0xe6, 0xfc, 0xc4, 0xd0, 0x4b, 0x0, 0x0, 0x14, 0x89, 0xb9, 0x6c, 0x4, 0xcd, 0xd, 0xdb, 0x9, 0x2e, 0xef, + 0x6a, 0xb5, 0x6a, 0x2c, 0x2a, 0x6b, 0xff, 0xe, 0x7d, 0x4c, 0x1, 0x0, 0xc, 0x64, 0xc4, 0x54, 0xf7, 0x14, 0xc6, + 0xa5, 0x1a, 0x31, 0x7, 0xb5, 0xff, 0x2, 0x0, 0x10, 0x6, 0x9b, 0x52, 0x16, 0xd9, 0xcf, 0x33, 0x91, 0x56, 0xd7, + 0x77, 0x73, 0xc0, 0xb1, 0xb8, 0x53, 0x0, 0x0, 0x15, 0x23, 0xa1, 0xd6, 0xc3, 0xc, 0x40, 0x48, 0x82, 0x7, 0x76, + 0x9b, 0xa9, 0xf1, 0x9d, 0xfb, 0xc4, 0xe7, 0xe9, 0x87, 0x56, 0x8e, 0x1, 0x0, 0x12, 0x2f, 0xac, 0x2, 0x12, 0x22, + 0x60, 0xe0, 0x2b, 0xb3, 0x7b, 0x81, 0xef, 0xb4, 0xa5, 0xdd, 0xf8, 0xbd, 0x85, 0x0, 0x0, 0x1d, 0xa9, 0xe4, 0x4c, + 0x5a, 0xc7, 0x5e, 0x2d, 0x26, 0x15, 0x41, 0xc, 0x81, 0xfb, 0x4, 0x5d, 0x1c, 0xb9, 0x68, 0xbe, 0x5a, 0x6e, 0x36, + 0xfc, 0x10, 0xbb, 0x99, 0xaa, 0x64, 0x94, 0x2, 0x0, 0x1e, 0xfb, 0xa6, 0xb0, 0xd6, 0x3d, 0x2, 0xe8, 0x34, 0xf8, + 0xd, 0xfe, 0x5c, 0xb8, 0x28, 0x8e, 0xd5, 0xe, 0x8c, 0x4c, 0xd9, 0x14, 0xdd, 0x79, 0xca, 0xa9, 0x8a, 0xce, 0x91, + 0xb6, 0xc0, 0x2, 0x0, 0x1d, 0xaa, 0x2a, 0xe5, 0x27, 0xcf, 0x82, 0xc1, 0xed, 0x8b, 0x9f, 0x3e, 0xdf, 0xc8, 0xc8, + 0x99, 0x1, 0x84, 0xd0, 0xbe, 0x12, 0x99, 0xbe, 0xd5, 0x4f, 0xbe, 0x10, 0x2e, 0x5c, 0x79, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x1e, 0x20, 0x60, 0x50, 0xd1, 0x99, 0xd2, 0xe1, - 0xec, 0xbb, 0xca, 0xf1, 0x4c, 0x94, 0xf1, 0x58}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x23, 0xa4, 0x41, 0xd, 0x8b, 0x2, 0x3b, 0xc5, 0xf, + 0x77, 0x68, 0x16, 0xc9, 0xe6, 0xfc, 0xc4, 0xd0, 0x4b}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5, 0x4d, 0xdd, 0xa8, 0xdf}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x89, 0xb9, 0x6c, 0x4, 0xcd, 0xd, 0xdb, 0x9, 0x2e, 0xef, + 0x6a, 0xb5, 0x6a, 0x2c, 0x2a, 0x6b, 0xff, 0xe, 0x7d, 0x4c}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8a, 0x16, 0xa, 0x47, 0x13, 0x1d, 0xbd, 0xa9, 0x88, 0xbc, 0xf8, - 0x7e, 0x31, 0x41, 0xa0, 0x85, 0xfe, 0xd4, 0x29, 0xc5, 0x5c}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x64, 0xc4, 0x54, 0xf7, 0x14, 0xc6, 0xa5, 0x1a, 0x31, 0x7, 0xb5, 0xff}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x58, 0xda, 0x8e, 0xdb, 0xde, 0x43, 0xd6, 0x8e, 0x3, 0xd1, - 0x5d, 0x2d, 0xca, 0x6b, 0x1b, 0x92, 0x68, 0xa1, 0x6d, 0xcf}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6, 0x9b, 0x52, 0x16, 0xd9, 0xcf, 0x33, 0x91, + 0x56, 0xd7, 0x77, 0x73, 0xc0, 0xb1, 0xb8, 0x53}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa5, 0x99, 0x8, 0x92, 0x2f, 0x0, 0x83, 0xb, 0xd7, 0x39, 0x3d, 0x4f, 0xee, 0x2d, - 0xeb, 0x10, 0x67, 0xa1, 0x40, 0x16, 0x5, 0x8, 0x5a, 0xa3, 0xdf, 0xb9, 0x7a}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x23, 0xa1, 0xd6, 0xc3, 0xc, 0x40, 0x48, 0x82, 0x7, 0x76, 0x9b, + 0xa9, 0xf1, 0x9d, 0xfb, 0xc4, 0xe7, 0xe9, 0x87, 0x56, 0x8e}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc9, 0x27, 0xa2, 0x82, 0x68, 0x96, 0x9e, 0x2f, 0xb8, 0x1c, 0x83, 0x9c, 0xfb}; - lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x2f, 0xac, 0x2, 0x12, 0x22, 0x60, 0xe0, 0x2b, 0xb3, + 0x7b, 0x81, 0xef, 0xb4, 0xa5, 0xdd, 0xf8, 0xbd, 0x85}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s6_bytes[] = {0xa9, 0xe4, 0x4c, 0x5a, 0xc7, 0x5e, 0x2d, 0x26, 0x15, 0x41, + 0xc, 0x81, 0xfb, 0x4, 0x5d, 0x1c, 0xb9, 0x68, 0xbe, 0x5a, + 0x6e, 0x36, 0xfc, 0x10, 0xbb, 0x99, 0xaa, 0x64, 0x94}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xfb, 0xa6, 0xb0, 0xd6, 0x3d, 0x2, 0xe8, 0x34, 0xf8, 0xd, + 0xfe, 0x5c, 0xb8, 0x28, 0x8e, 0xd5, 0xe, 0x8c, 0x4c, 0xd9, + 0x14, 0xdd, 0x79, 0xca, 0xa9, 0x8a, 0xce, 0x91, 0xb6, 0xc0}; + lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xaa, 0x2a, 0xe5, 0x27, 0xcf, 0x82, 0xc1, 0xed, 0x8b, 0x9f, + 0x3e, 0xdf, 0xc8, 0xc8, 0x99, 0x1, 0x84, 0xd0, 0xbe, 0x12, + 0x99, 0xbe, 0xd5, 0x4f, 0xbe, 0x10, 0x2e, 0x5c, 0x79}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -11714,52 +11793,96 @@ TEST(Subscribe311QCTest, Encode17) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7682, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22557, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9224 [("\199\229\146\190\EOT\224",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = -// QoS0}),("\238\163\ETB\179[\253\146N.\169\223$\202\251\ENQ\183\191\183`\165\135\152f-qP\201\189\SUB",SubOptions +// SubscribeRequest 10879 [("k\CAN\STX\230?\231\199\145\130\DLE\182\233W\233\&5F\250\153Hoip\242W\164",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\t\253\178\254a\b\217\143\162\FS\221\238PG\177\229\208*\DEL$k\160O\DLEs`\132\DC2\NAKV",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("f\133\252\176\189\165",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("ai\ETX\141\131P\247\191\147\143",SubOptions {_retainHandling = SendOnSubscribe, +// QoS0}),("\216/\149I\232hE\247*RW\244\251\134\204",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\FS9Yu\225\234\246\SOHB>\199#\188\"i\162<\168\185?\219`\237\163\NUL%",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\201\177D\132y\246}ad\135\228\US\t",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\132lyi].N\135g\164se\160\235!n\158\239MqZ",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode18) { - uint8_t pkt[] = {0x82, 0x41, 0x24, 0x8, 0x0, 0x6, 0xc7, 0xe5, 0x92, 0xbe, 0x4, 0xe0, 0x0, 0x0, 0x1d, 0xee, 0xa3, - 0x17, 0xb3, 0x5b, 0xfd, 0x92, 0x4e, 0x2e, 0xa9, 0xdf, 0x24, 0xca, 0xfb, 0x5, 0xb7, 0xbf, 0xb7, 0x60, - 0xa5, 0x87, 0x98, 0x66, 0x2d, 0x71, 0x50, 0xc9, 0xbd, 0x1a, 0x1, 0x0, 0x6, 0x66, 0x85, 0xfc, 0xb0, - 0xbd, 0xa5, 0x0, 0x0, 0xa, 0x61, 0x69, 0x3, 0x8d, 0x83, 0x50, 0xf7, 0xbf, 0x93, 0x8f, 0x0}; +TEST(Subscribe311QCTest, Encode19) { + uint8_t pkt[] = { + 0x82, 0xba, 0x1, 0x2a, 0x7f, 0x0, 0x19, 0x6b, 0x18, 0x2, 0xe6, 0x3f, 0xe7, 0xc7, 0x91, 0x82, 0x10, 0xb6, 0xe9, + 0x57, 0xe9, 0x35, 0x46, 0xfa, 0x99, 0x48, 0x6f, 0x69, 0x70, 0xf2, 0x57, 0xa4, 0x1, 0x0, 0x1e, 0x9, 0xfd, 0xb2, + 0xfe, 0x61, 0x8, 0xd9, 0x8f, 0xa2, 0x1c, 0xdd, 0xee, 0x50, 0x47, 0xb1, 0xe5, 0xd0, 0x2a, 0x7f, 0x24, 0x6b, 0xa0, + 0x4f, 0x10, 0x73, 0x60, 0x84, 0x12, 0x15, 0x56, 0x0, 0x0, 0xf, 0xd8, 0x2f, 0x95, 0x49, 0xe8, 0x68, 0x45, 0xf7, + 0x2a, 0x52, 0x57, 0xf4, 0xfb, 0x86, 0xcc, 0x0, 0x0, 0x1a, 0x1c, 0x39, 0x59, 0x75, 0xe1, 0xea, 0xf6, 0x1, 0x42, + 0x3e, 0xc7, 0x23, 0xbc, 0x22, 0x69, 0xa2, 0x3c, 0xa8, 0xb9, 0x3f, 0xdb, 0x60, 0xed, 0xa3, 0x0, 0x25, 0x2, 0x0, + 0x17, 0xc9, 0xb1, 0x44, 0x84, 0x79, 0xf6, 0x7d, 0x61, 0x64, 0x87, 0xe4, 0x1f, 0x3c, 0x48, 0x32, 0x5d, 0x56, 0xff, + 0x9e, 0x65, 0xdf, 0xff, 0xfa, 0x1, 0x0, 0x4, 0x3d, 0xcd, 0x6f, 0x15, 0x2, 0x0, 0x10, 0x83, 0xcf, 0x36, 0x57, + 0xc3, 0x20, 0x67, 0x4c, 0xb2, 0xda, 0x82, 0x98, 0x75, 0xd1, 0x3e, 0x9, 0x0, 0x0, 0x15, 0x84, 0x6c, 0x79, 0x69, + 0x5d, 0x2e, 0x4e, 0x87, 0x67, 0xa4, 0x73, 0x65, 0xa0, 0xeb, 0x21, 0x6e, 0x9e, 0xef, 0x4d, 0x71, 0x5a, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xc7, 0xe5, 0x92, 0xbe, 0x4, 0xe0}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x6b, 0x18, 0x2, 0xe6, 0x3f, 0xe7, 0xc7, 0x91, 0x82, 0x10, 0xb6, 0xe9, 0x57, + 0xe9, 0x35, 0x46, 0xfa, 0x99, 0x48, 0x6f, 0x69, 0x70, 0xf2, 0x57, 0xa4}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xee, 0xa3, 0x17, 0xb3, 0x5b, 0xfd, 0x92, 0x4e, 0x2e, 0xa9, - 0xdf, 0x24, 0xca, 0xfb, 0x5, 0xb7, 0xbf, 0xb7, 0x60, 0xa5, - 0x87, 0x98, 0x66, 0x2d, 0x71, 0x50, 0xc9, 0xbd, 0x1a}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9, 0xfd, 0xb2, 0xfe, 0x61, 0x8, 0xd9, 0x8f, 0xa2, 0x1c, + 0xdd, 0xee, 0x50, 0x47, 0xb1, 0xe5, 0xd0, 0x2a, 0x7f, 0x24, + 0x6b, 0xa0, 0x4f, 0x10, 0x73, 0x60, 0x84, 0x12, 0x15, 0x56}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x66, 0x85, 0xfc, 0xb0, 0xbd, 0xa5}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd8, 0x2f, 0x95, 0x49, 0xe8, 0x68, 0x45, 0xf7, + 0x2a, 0x52, 0x57, 0xf4, 0xfb, 0x86, 0xcc}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x61, 0x69, 0x3, 0x8d, 0x83, 0x50, 0xf7, 0xbf, 0x93, 0x8f}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1c, 0x39, 0x59, 0x75, 0xe1, 0xea, 0xf6, 0x1, 0x42, 0x3e, 0xc7, 0x23, 0xbc, + 0x22, 0x69, 0xa2, 0x3c, 0xa8, 0xb9, 0x3f, 0xdb, 0x60, 0xed, 0xa3, 0x0, 0x25}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s4_bytes[] = {0xc9, 0xb1, 0x44, 0x84, 0x79, 0xf6, 0x7d, 0x61, 0x64, 0x87, 0xe4, 0x1f, + 0x3c, 0x48, 0x32, 0x5d, 0x56, 0xff, 0x9e, 0x65, 0xdf, 0xff, 0xfa}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x3d, 0xcd, 0x6f, 0x15}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x83, 0xcf, 0x36, 0x57, 0xc3, 0x20, 0x67, 0x4c, + 0xb2, 0xda, 0x82, 0x98, 0x75, 0xd1, 0x3e, 0x9}; + lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x84, 0x6c, 0x79, 0x69, 0x5d, 0x2e, 0x4e, 0x87, 0x67, 0xa4, 0x73, + 0x65, 0xa0, 0xeb, 0x21, 0x6e, 0x9e, 0xef, 0x4d, 0x71, 0x5a}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -11767,63 +11890,85 @@ TEST(Subscribe311QCTest, Encode18) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9224, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10879, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14508 [("R\USc\174\228\248\201\SYN\DC3\248\&2\CAN9\152\209\137,[\171\227\225\131%",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(")eM\218\&6\152 \202\231\152J\139",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\200[\DC1O\176\181\136",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS0}),("\209f\ENQ!\195\251$^7\130\148_\DC4\189\167\202s\172\210\149\254\181=",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("2a\216\&2\185\140i=\199\224\250\&3\230r\DC4\161\146\130G",SubOptions {_retainHandling = SendOnSubscribe, +// QoS0}),("\136\159\161\ETB\151\211$\128E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("v\ay\rA\210\DC2\243",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("e\174q\139U\145\139 +// \140\238i\152?\244\239\ACKBN\248\218\188\238\DELu\EOT\ENQ/",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\136\ETX\176~\130\DC1\"\241\SIp\253\190\162\219\183`\234",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode26) { - uint8_t pkt[] = { - 0x82, 0xef, 0x1, 0x58, 0x51, 0x0, 0x11, 0x39, 0xa2, 0x41, 0xa4, 0xd6, 0x78, 0x32, 0x87, 0x55, 0x7c, 0x29, 0xe6, - 0xc9, 0x74, 0x1d, 0xc5, 0xbd, 0x0, 0x0, 0x19, 0x16, 0x21, 0x94, 0xa5, 0x91, 0xb6, 0x64, 0x4e, 0xf1, 0xee, 0x40, -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x3, 0xb0, 0x7e, - 0x82, 0x11, 0x22, 0xf1, 0xf, 0x70, 0xfd, 0xbe, 0xa2, 0xdb, 0xb7, 0x60, 0xea, 0x2}; +// QoS0}),(",\196\144\&6$\US\DC3\212\195n\RS\149\140\204}\235\149\DC2\234\254\f",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("[\241\133m#\240#\175",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode30) { + uint8_t pkt[] = {0x82, 0x97, 0x1, 0x64, 0x93, 0x0, 0x19, 0x3a, 0xa3, 0x69, 0xbe, 0x8d, 0xbc, 0x64, 0xd0, 0x34, + 0x2, 0x8, 0x19, 0x6e, 0x17, 0x2e, 0x79, 0xc0, 0xe6, 0x6b, 0x4f, 0xb1, 0xcc, 0x27, 0x9c, 0xce, + 0x1, 0x0, 0x1b, 0xb8, 0xc8, 0x90, 0x73, 0x49, 0x67, 0xf8, 0xd, 0xb5, 0x3c, 0xbb, 0x0, 0xcf, + 0xa0, 0x59, 0x89, 0x49, 0xe0, 0x97, 0x5d, 0x55, 0x27, 0x67, 0x5b, 0xb, 0x6, 0x72, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x9, 0x88, 0x9f, 0xa1, 0x17, 0x97, 0xd3, 0x24, 0x80, 0x45, 0x0, 0x0, 0x8, + 0x76, 0x7, 0x79, 0xd, 0x41, 0xd2, 0x12, 0xf3, 0x1, 0x0, 0x1b, 0x65, 0xae, 0x71, 0x8b, 0x55, + 0x91, 0x8b, 0x20, 0x8c, 0xee, 0x69, 0x98, 0x3f, 0xf4, 0xef, 0x6, 0x42, 0x4e, 0xf8, 0xda, 0xbc, + 0xee, 0x7f, 0x75, 0x4, 0x5, 0x2f, 0x0, 0x0, 0x15, 0x2c, 0xc4, 0x90, 0x36, 0x24, 0x1f, 0x13, + 0xd4, 0xc3, 0x6e, 0x1e, 0x95, 0x8c, 0xcc, 0x7d, 0xeb, 0x95, 0x12, 0xea, 0xfe, 0xc, 0x0, 0x0, + 0x8, 0x5b, 0xf1, 0x85, 0x6d, 0x23, 0xf0, 0x23, 0xaf, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x39, 0xa2, 0x41, 0xa4, 0xd6, 0x78, 0x32, 0x87, 0x55, - 0x7c, 0x29, 0xe6, 0xc9, 0x74, 0x1d, 0xc5, 0xbd}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x3a, 0xa3, 0x69, 0xbe, 0x8d, 0xbc, 0x64, 0xd0, 0x34, 0x2, 0x8, 0x19, 0x6e, + 0x17, 0x2e, 0x79, 0xc0, 0xe6, 0x6b, 0x4f, 0xb1, 0xcc, 0x27, 0x9c, 0xce}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x16, 0x21, 0x94, 0xa5, 0x91, 0xb6, 0x64, 0x4e, 0xf1, 0xee, 0x40, 0xb0, 0x90, - 0xb, 0xd2, 0x60, 0xf7, 0x64, 0x21, 0x75, 0xce, 0x85, 0xa7, 0xbe, 0x38}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb8, 0xc8, 0x90, 0x73, 0x49, 0x67, 0xf8, 0xd, 0xb5, 0x3c, 0xbb, 0x0, 0xcf, 0xa0, + 0x59, 0x89, 0x49, 0xe0, 0x97, 0x5d, 0x55, 0x27, 0x67, 0x5b, 0xb, 0x6, 0x72}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1a, 0xd1, 0xd8, 0xf8, 0x3a, 0xc8, 0xd7, 0x18, 0xea, 0x2, 0xee, 0xd8, 0x9f, - 0x51, 0xb7, 0xdd, 0x16, 0xad, 0x3c, 0xb6, 0x80, 0x8e, 0xa, 0x2c, 0xc}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x81, 0x3f, 0xa4, 0x61, 0x34, 0xe6, 0x93, 0xe8, - 0xb1, 0xe1, 0xe2, 0xf7, 0x83, 0xde, 0xcd, 0x5}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x88, 0x9f, 0xa1, 0x17, 0x97, 0xd3, 0x24, 0x80, 0x45}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x12, 0x61, 0xba, 0x48, 0x8c, 0xac, 0x4e, 0x3c, 0x99, 0x4d, 0xfc, 0xab, 0xfc, - 0x4a, 0x69, 0x27, 0x13, 0xc, 0x33, 0x36, 0x1d, 0xec, 0x14, 0x74, 0xc8}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x76, 0x7, 0x79, 0xd, 0x41, 0xd2, 0x12, 0xf3}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7b, 0xcc, 0xf4, 0x4f, 0xa2, 0x3e, 0x18, 0x39, 0x98, - 0xd1, 0x89, 0x2c, 0x5b, 0xab, 0xe3, 0xe1, 0x83, 0x25}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x65, 0xae, 0x71, 0x8b, 0x55, 0x91, 0x8b, 0x20, 0x8c, 0xee, 0x69, 0x98, 0x3f, 0xf4, + 0xef, 0x6, 0x42, 0x4e, 0xf8, 0xda, 0xbc, 0xee, 0x7f, 0x75, 0x4, 0x5, 0x2f}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x29, 0x65, 0x4d, 0xda, 0x36, 0x98, 0x20, 0xca, 0xe7, 0x98, 0x4a, 0x8b}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x2c, 0xc4, 0x90, 0x36, 0x24, 0x1f, 0x13, 0xd4, 0xc3, 0x6e, 0x1e, + 0x95, 0x8c, 0xcc, 0x7d, 0xeb, 0x95, 0x12, 0xea, 0xfe, 0xc}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xc8, 0x5b, 0x11, 0x4f, 0xb0, 0xb5, 0x88}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x5b, 0xf1, 0x85, 0x6d, 0x23, 0xf0, 0x23, 0xaf}; + lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd1, 0x66, 0x5, 0x21, 0xc3, 0xfb, 0x24, 0x5e, 0x37, 0x82, 0x94, 0x5f, - 0x14, 0xbd, 0xa7, 0xca, 0x73, 0xac, 0xd2, 0x95, 0xfe, 0xb5, 0x3d}; - lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x32, 0x61, 0xd8, 0x32, 0xb9, 0x8c, 0x69, 0x3d, 0xc7, 0xe0, - 0xfa, 0x33, 0xe6, 0x72, 0x14, 0xa1, 0x92, 0x82, 0x47}; - lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x88, 0x3, 0xb0, 0x7e, 0x82, 0x11, 0x22, 0xf1, 0xf, - 0x70, 0xfd, 0xbe, 0xa2, 0xdb, 0xb7, 0x60, 0xea}; - lwmqtt_string_t topic_filter_s10 = {17, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -12406,15 +12495,15 @@ TEST(Subscribe311QCTest, Encode26) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -12422,9402 +12511,10418 @@ TEST(Subscribe311QCTest, Encode26) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22609, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25747, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 5459 [("\167\&9\128\201\254\251f\154)\222\SYN\n\182w",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\v\244",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\NULV?\231o\214\r\141\181\DC4\236\139\166f\RS?B_",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\134\198\224\203\182\223E\204\128l\208\172\156\"\246",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\170b\195j\211}D\139\ESC\192\ACK9!\244F\140&1\143W\DC1Qy\211",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("p\NULm,\228\200\DLE\134\191V\174\192\SOHm\145H\RS\US\177\SIt\\",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\SOH\251cC\207\239\246\&5\202\158\vi\196\&1",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0x84, 0x1, 0x15, 0x53, 0x0, 0xe, 0xa7, 0x39, 0x80, 0xc9, 0xfe, 0xfb, 0x66, 0x9a, 0x29, 0xde, - 0x16, 0xa, 0xb6, 0x77, 0x2, 0x0, 0x2, 0xb, 0xf4, 0x0, 0x0, 0x12, 0x0, 0x56, 0x3f, 0xe7, 0x6f, - 0xd6, 0xd, 0x8d, 0xb5, 0x14, 0xec, 0x8b, 0xa6, 0x66, 0x1e, 0x3f, 0x42, 0x5f, 0x2, 0x0, 0xf, 0x86, - 0xc6, 0xe0, 0xcb, 0xb6, 0xdf, 0x45, 0xcc, 0x80, 0x6c, 0xd0, 0xac, 0x9c, 0x22, 0xf6, 0x0, 0x0, 0x18, - 0xaa, 0x62, 0xc3, 0x6a, 0xd3, 0x7d, 0x44, 0x8b, 0x1b, 0xc0, 0x6, 0x39, 0x21, 0xf4, 0x46, 0x8c, 0x26, - 0x31, 0x8f, 0x57, 0x11, 0x51, 0x79, 0xd3, 0x2, 0x0, 0x16, 0x70, 0x0, 0x6d, 0x2c, 0xe4, 0xc8, 0x10, - 0x86, 0xbf, 0x56, 0xae, 0xc0, 0x1, 0x6d, 0x91, 0x48, 0x1e, 0x1f, 0xb1, 0xf, 0x74, 0x5c, 0x1, 0x0, - 0xe, 0x1, 0xfb, 0x63, 0x43, 0xcf, 0xef, 0xf6, 0x35, 0xca, 0x9e, 0xb, 0x69, 0xc4, 0x31, 0x2}; +// SubscribeRequest 18112 [("\217\163\ETBT\231\217",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = True, _noLocal = False, _subQoS = QoS0}),("\199}\169\229\237\168.,U\215W4W\211\197\172\&1&\235\203\213",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\225\200[H\253e\NUL\230l[hR\220\215\242\223\175\133\169\231}",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("X",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("D\ACK\181\185\&4\239\235M\227\131\252\255M\176\r\219\180\ETB\217\167\232\190\223\236",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("B)`\234\&1'\221\218\171\ETBd\196\&4\229\170Y\SYN\164y\164b\174E\240",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\165\213\SYN\240\249\ETX\f\225\171\188j\164(\170\190\189\248\223\202",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\182\208\135BB\223",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("7",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0})] [PropResponseTopic "\185\135'\a\a7w\240)%\STX\159&m\206\&0\166\244\143l\211\NAK.&H",PropContentType +// "%J\151\213\176\av\128\232\176\217\185\193\172\144\128\243\SI\241(FXa\187\232\155{",PropAuthenticationData +// "o\RS\157\ENQ7\219M>\246W\239\223&\183|yIe\202\130",PropAuthenticationMethod "\RS0[",PropMessageExpiryInterval +// 28857,PropMaximumQoS 254,PropWildcardSubscriptionAvailable 30,PropRetainAvailable 142,PropResponseInformation +// "`\229\&7\140\135\136\158\155\167",PropTopicAliasMaximum 26525,PropWildcardSubscriptionAvailable +// 230,PropRetainAvailable 219,PropResponseInformation "\162\SOH\231\175#k\213x\144\r",PropTopicAlias +// 21056,PropWillDelayInterval 27038,PropSessionExpiryInterval 11270,PropSharedSubscriptionAvailable +// 235,PropMessageExpiryInterval 22008,PropResponseInformation "3\193\168\DLE\137\220\135",PropRequestProblemInformation +// 36,PropResponseTopic "\158$\182g5\191\210\129^u\139\168\240KN\194n\NUL?]_\SUBQE\189p\240%\218",PropMaximumQoS +// 194,PropMaximumPacketSize 20583,PropSessionExpiryInterval 24442,PropWillDelayInterval +// 23910,PropWildcardSubscriptionAvailable 159,PropServerReference +// "\211\189#27\227\ETB4-,0\153$\190\200\216\ETX\173q\ETB\203v=",PropSharedSubscriptionAvailable +// 104,PropMaximumPacketSize 10426,PropReasonString +// "=\172N\203;\246v\211\130Y\182\162d\228\254\&5\b\216\133\179\153\223"] +TEST(Subscribe5QCTest, Encode1) { + uint8_t pkt[] = { + 0x82, 0xac, 0x3, 0x46, 0xc0, 0x8f, 0x2, 0x8, 0x0, 0x19, 0xb9, 0x87, 0x27, 0x7, 0x7, 0x37, 0x77, 0xf0, 0x29, + 0x25, 0x2, 0x9f, 0x26, 0x6d, 0xce, 0x30, 0xa6, 0xf4, 0x8f, 0x6c, 0xd3, 0x15, 0x2e, 0x26, 0x48, 0x3, 0x0, 0x1b, + 0x25, 0x4a, 0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be, 0xbd, 0xf8, 0xdf, 0xca, 0x4, + 0x0, 0x6, 0xb6, 0xd0, 0x87, 0x42, 0x42, 0xdf, 0x26, 0x0, 0x1, 0x37, 0x14}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xa7, 0x39, 0x80, 0xc9, 0xfe, 0xfb, 0x66, 0x9a, 0x29, 0xde, 0x16, 0xa, 0xb6, 0x77}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd9, 0xa3, 0x17, 0x54, 0xe7, 0xd9}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb, 0xf4}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc7, 0x7d, 0xa9, 0xe5, 0xed, 0xa8, 0x2e, 0x2c, 0x55, 0xd7, 0x57, + 0x34, 0x57, 0xd3, 0xc5, 0xac, 0x31, 0x26, 0xeb, 0xcb, 0xd5}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x0, 0x56, 0x3f, 0xe7, 0x6f, 0xd6, 0xd, 0x8d, 0xb5, - 0x14, 0xec, 0x8b, 0xa6, 0x66, 0x1e, 0x3f, 0x42, 0x5f}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe1, 0xc8, 0x5b, 0x48, 0xfd, 0x65, 0x0, 0xe6, 0x6c, 0x5b, 0x68, + 0x52, 0xdc, 0xd7, 0xf2, 0xdf, 0xaf, 0x85, 0xa9, 0xe7, 0x7d}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x86, 0xc6, 0xe0, 0xcb, 0xb6, 0xdf, 0x45, 0xcc, - 0x80, 0x6c, 0xd0, 0xac, 0x9c, 0x22, 0xf6}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x58}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xaa, 0x62, 0xc3, 0x6a, 0xd3, 0x7d, 0x44, 0x8b, 0x1b, 0xc0, 0x6, 0x39, - 0x21, 0xf4, 0x46, 0x8c, 0x26, 0x31, 0x8f, 0x57, 0x11, 0x51, 0x79, 0xd3}; + uint8_t topic_filter_s4_bytes[] = {0x44, 0x6, 0xb5, 0xb9, 0x34, 0xef, 0xeb, 0x4d, 0xe3, 0x83, 0xfc, 0xff, + 0x4d, 0xb0, 0xd, 0xdb, 0xb4, 0x17, 0xd9, 0xa7, 0xe8, 0xbe, 0xdf, 0xec}; lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x70, 0x0, 0x6d, 0x2c, 0xe4, 0xc8, 0x10, 0x86, 0xbf, 0x56, 0xae, - 0xc0, 0x1, 0x6d, 0x91, 0x48, 0x1e, 0x1f, 0xb1, 0xf, 0x74, 0x5c}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x42, 0x29, 0x60, 0xea, 0x31, 0x27, 0xdd, 0xda, 0xab, 0x17, 0x64, 0xc4, + 0x34, 0xe5, 0xaa, 0x59, 0x16, 0xa4, 0x79, 0xa4, 0x62, 0xae, 0x45, 0xf0}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x1, 0xfb, 0x63, 0x43, 0xcf, 0xef, 0xf6, 0x35, 0xca, 0x9e, 0xb, 0x69, 0xc4, 0x31}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + uint8_t topic_filter_s7_bytes[] = {0xa5, 0xd5, 0x16, 0xf0, 0xf9, 0x3, 0xc, 0xe1, 0xab, 0xbc, + 0x6a, 0xa4, 0x28, 0xaa, 0xbe, 0xbd, 0xf8, 0xdf, 0xca}; + lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xb6, 0xd0, 0x87, 0x42, 0x42, 0xdf}; + lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x37}; + lwmqtt_string_t topic_filter_s9 = {1, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; + sub_opts[4].no_local = true; sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = true; + uint8_t bytesprops0[] = {0xb9, 0x87, 0x27, 0x7, 0x7, 0x37, 0x77, 0xf0, 0x29, 0x25, 0x2, 0x9f, 0x26, + 0x6d, 0xce, 0x30, 0xa6, 0xf4, 0x8f, 0x6c, 0xd3, 0x15, 0x2e, 0x26, 0x48}; + uint8_t bytesprops1[] = {0x25, 0x4a, 0x97, 0xd5, 0xb0, 0x7, 0x76, 0x80, 0xe8, 0xb0, 0xd9, 0xb9, 0xc1, 0xac, + 0x90, 0x80, 0xf3, 0xf, 0xf1, 0x28, 0x46, 0x58, 0x61, 0xbb, 0xe8, 0x9b, 0x7b}; + uint8_t bytesprops2[] = {0x6f, 0x1e, 0x9d, 0x5, 0x37, 0xdb, 0x4d, 0x3e, 0xf6, 0x57, + 0xef, 0xdf, 0x26, 0xb7, 0x7c, 0x79, 0x49, 0x65, 0xca, 0x82}; + uint8_t bytesprops3[] = {0x1e, 0x30, 0x5b}; + uint8_t bytesprops4[] = {0x60, 0xe5, 0x37, 0x8c, 0x87, 0x88, 0x9e, 0x9b, 0xa7}; + uint8_t bytesprops5[] = {0xa2, 0x1, 0xe7, 0xaf, 0x23, 0x6b, 0xd5, 0x78, 0x90, 0xd}; + uint8_t bytesprops6[] = {0x33, 0xc1, 0xa8, 0x10, 0x89, 0xdc, 0x87}; + uint8_t bytesprops7[] = {0x9e, 0x24, 0xb6, 0x67, 0x35, 0xbf, 0xd2, 0x81, 0x5e, 0x75, 0x8b, 0xa8, 0xf0, 0x4b, 0x4e, + 0xc2, 0x6e, 0x0, 0x3f, 0x5d, 0x5f, 0x1a, 0x51, 0x45, 0xbd, 0x70, 0xf0, 0x25, 0xda}; + uint8_t bytesprops8[] = {0xd3, 0xbd, 0x23, 0x32, 0x37, 0xe3, 0x17, 0x34, 0x2d, 0x2c, 0x30, 0x99, + 0x24, 0xbe, 0xc8, 0xd8, 0x3, 0xad, 0x71, 0x17, 0xcb, 0x76, 0x3d}; + uint8_t bytesprops9[] = {0x3d, 0xac, 0x4e, 0xcb, 0x3b, 0xf6, 0x76, 0xd3, 0x82, 0x59, 0xb6, + 0xa2, 0x64, 0xe4, 0xfe, 0x35, 0x8, 0xd8, 0x85, 0xb3, 0x99, 0xdf}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28857}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26525}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21056}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27038}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11270}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22008}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20583}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24442}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23910}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10426}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops9}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5459, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18112, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21650 -// [("\144\143\250\181?\222c\242\195\194iT\235\216\230\207\176(\169\205\175g\RS\221}V\US\206\228\167",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("r\242Fl\STX\222\224\199\213\254?\253\b\n\241\ESC\137f\252\ETX",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\188\213\&9\219v$\165F\194\195\157\155\193\DC2y\EM",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("Yk\181r6Q\f\148l\155\151\149\206I\133\&8\SOH\SOH\148\SUBaQ",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("D\191",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0x6e, 0x54, 0x92, 0x0, 0x1e, 0x90, 0x8f, 0xfa, 0xb5, 0x3f, 0xde, 0x63, 0xf2, 0xc3, 0xc2, - 0x69, 0x54, 0xeb, 0xd8, 0xe6, 0xcf, 0xb0, 0x28, 0xa9, 0xcd, 0xaf, 0x67, 0x1e, 0xdd, 0x7d, 0x56, - 0x1f, 0xce, 0xe4, 0xa7, 0x2, 0x0, 0x14, 0x72, 0xf2, 0x46, 0x6c, 0x2, 0xde, 0xe0, 0xc7, 0xd5, - 0xfe, 0x3f, 0xfd, 0x8, 0xa, 0xf1, 0x1b, 0x89, 0x66, 0xfc, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x10, 0xbc, 0xd5, 0x39, 0xdb, 0x76, 0x24, 0xa5, 0x46, 0xc2, 0xc3, 0x9d, 0x9b, 0xc1, 0x12, 0x79, - 0x19, 0x1, 0x0, 0x16, 0x59, 0x6b, 0xb5, 0x72, 0x36, 0x51, 0xc, 0x94, 0x6c, 0x9b, 0x97, 0x95, - 0xce, 0x49, 0x85, 0x38, 0x1, 0x1, 0x94, 0x1a, 0x61, 0x51, 0x2, 0x0, 0x2, 0x44, 0xbf, 0x2}; +// SubscribeRequest 8048 [("=\136\230h\216\226(\250c\195\226\174/9",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\216k\253Z\203\ETX\218\SYN&\169m",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] +// [PropSharedSubscriptionAvailable 45,PropMaximumPacketSize 3495,PropRetainAvailable 129,PropTopicAliasMaximum +// 16323,PropSubscriptionIdentifierAvailable 118,PropContentType "\EMr\219\211\237\200A\140oe",PropTopicAlias 12732] +TEST(Subscribe5QCTest, Encode2) { + uint8_t pkt[] = {0x82, 0x40, 0x1f, 0x70, 0x1e, 0x2a, 0x2d, 0x27, 0x0, 0x0, 0xd, 0xa7, 0x25, 0x81, 0x22, 0x3f, 0xc3, + 0x29, 0x76, 0x3, 0x0, 0xa, 0x19, 0x72, 0xdb, 0xd3, 0xed, 0xc8, 0x41, 0x8c, 0x6f, 0x65, 0x23, 0x31, + 0xbc, 0x0, 0xe, 0x3d, 0x88, 0xe6, 0x68, 0xd8, 0xe2, 0x28, 0xfa, 0x63, 0xc3, 0xe2, 0xae, 0x2f, 0x39, + 0x22, 0x0, 0xb, 0xd8, 0x6b, 0xfd, 0x5a, 0xcb, 0x3, 0xda, 0x16, 0x26, 0xa9, 0x6d, 0x2e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x90, 0x8f, 0xfa, 0xb5, 0x3f, 0xde, 0x63, 0xf2, 0xc3, 0xc2, - 0x69, 0x54, 0xeb, 0xd8, 0xe6, 0xcf, 0xb0, 0x28, 0xa9, 0xcd, - 0xaf, 0x67, 0x1e, 0xdd, 0x7d, 0x56, 0x1f, 0xce, 0xe4, 0xa7}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x3d, 0x88, 0xe6, 0x68, 0xd8, 0xe2, 0x28, + 0xfa, 0x63, 0xc3, 0xe2, 0xae, 0x2f, 0x39}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x72, 0xf2, 0x46, 0x6c, 0x2, 0xde, 0xe0, 0xc7, 0xd5, 0xfe, - 0x3f, 0xfd, 0x8, 0xa, 0xf1, 0x1b, 0x89, 0x66, 0xfc, 0x3}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd8, 0x6b, 0xfd, 0x5a, 0xcb, 0x3, 0xda, 0x16, 0x26, 0xa9, 0x6d}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xbc, 0xd5, 0x39, 0xdb, 0x76, 0x24, 0xa5, 0x46, - 0xc2, 0xc3, 0x9d, 0x9b, 0xc1, 0x12, 0x79, 0x19}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x59, 0x6b, 0xb5, 0x72, 0x36, 0x51, 0xc, 0x94, 0x6c, 0x9b, 0x97, - 0x95, 0xce, 0x49, 0x85, 0x38, 0x1, 0x1, 0x94, 0x1a, 0x61, 0x51}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x44, 0xbf}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + lwmqtt_sub_options_t sub_opts[2]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + uint8_t bytesprops0[] = {0x19, 0x72, 0xdb, 0xd3, 0xed, 0xc8, 0x41, 0x8c, 0x6f, 0x65}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3495}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16323}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12732}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21650, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8048, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15109 [("\175\231\162\204$\151/\218\&0m\229",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0x10, 0x3b, 0x5, 0x0, 0xb, 0xaf, 0xe7, 0xa2, - 0xcc, 0x24, 0x97, 0x2f, 0xda, 0x30, 0x6d, 0xe5, 0x0}; +// SubscribeRequest 21602 [("\218I\151?\251\157\177r\DC2$\167\179\239",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\DELM\163P3T\138\133=\251\243C\218\218\133`\166",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\SYN\189'\252\223\241\r\ENQ?\146.\216n\235jI",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("K$\SYNda\EOT\253\217\190\241p\RS\f\191\f.\252\152\244\DEL\215\RSn\195\EOTyZ\150",SubOptions {_retainHandling +// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\167",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("c7\142\243",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, +// _subQoS = QoS1}),("\155\184\145gf\215\SYN|%",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe5QCTest, Encode3) { + uint8_t pkt[] = {0x82, 0x73, 0x54, 0x62, 0x0, 0x0, 0xd, 0xda, 0x49, 0x97, 0x3f, 0xfb, 0x9d, 0xb1, 0x72, 0x12, 0x24, + 0xa7, 0xb3, 0xef, 0x25, 0x0, 0x11, 0x7f, 0x4d, 0xa3, 0x50, 0x33, 0x54, 0x8a, 0x85, 0x3d, 0xfb, 0xf3, + 0x43, 0xda, 0xda, 0x85, 0x60, 0xa6, 0x22, 0x0, 0x10, 0x16, 0xbd, 0x27, 0xfc, 0xdf, 0xf1, 0xd, 0x5, + 0x3f, 0x92, 0x2e, 0xd8, 0x6e, 0xeb, 0x6a, 0x49, 0x18, 0x0, 0x1c, 0x4b, 0x24, 0x16, 0x64, 0x61, 0x4, + 0xfd, 0xd9, 0xbe, 0xf1, 0x70, 0x1e, 0xc, 0xbf, 0xc, 0x2e, 0xfc, 0x98, 0xf4, 0x7f, 0xd7, 0x1e, 0x6e, + 0xc3, 0x4, 0x79, 0x5a, 0x96, 0x1c, 0x0, 0x1, 0xa7, 0x16, 0x0, 0x0, 0x8, 0x0, 0x4, 0x63, 0x37, + 0x8e, 0xf3, 0xd, 0x0, 0x9, 0x9b, 0xb8, 0x91, 0x67, 0x66, 0xd7, 0x16, 0x7c, 0x25, 0x22}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xaf, 0xe7, 0xa2, 0xcc, 0x24, 0x97, 0x2f, 0xda, 0x30, 0x6d, 0xe5}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xda, 0x49, 0x97, 0x3f, 0xfb, 0x9d, 0xb1, 0x72, 0x12, 0x24, 0xa7, 0xb3, 0xef}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15109, 1, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 31149 [("(\255\220",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("nuB\184\220_5\217\196}\246\129",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\n?*\177\237",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\166\247\163\135\239\140E\178R\230-\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("z\250o\254y\a\a,\201+#\222\212\164\CAN\DC1\184\138\217",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ESC\220\r4\ak\135",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x4e, 0x79, 0xad, 0x0, 0x3, 0x28, 0xff, 0xdc, 0x0, 0x0, 0xc, 0x6e, 0x75, 0x42, 0xb8, - 0xdc, 0x5f, 0x35, 0xd9, 0xc4, 0x7d, 0xf6, 0x81, 0x0, 0x0, 0x5, 0xa, 0x3f, 0x2a, 0xb1, 0xed, - 0x1, 0x0, 0xc, 0xa6, 0xf7, 0xa3, 0x87, 0xef, 0x8c, 0x45, 0xb2, 0x52, 0xe6, 0x2d, 0x98, 0x1, - 0x0, 0x13, 0x7a, 0xfa, 0x6f, 0xfe, 0x79, 0x7, 0x7, 0x2c, 0xc9, 0x2b, 0x23, 0xde, 0xd4, 0xa4, - 0x18, 0x11, 0xb8, 0x8a, 0xd9, 0x2, 0x0, 0x7, 0x1b, 0xdc, 0xd, 0x34, 0x7, 0x6b, 0x87, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x28, 0xff, 0xdc}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6e, 0x75, 0x42, 0xb8, 0xdc, 0x5f, 0x35, 0xd9, 0xc4, 0x7d, 0xf6, 0x81}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7f, 0x4d, 0xa3, 0x50, 0x33, 0x54, 0x8a, 0x85, 0x3d, + 0xfb, 0xf3, 0x43, 0xda, 0xda, 0x85, 0x60, 0xa6}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa, 0x3f, 0x2a, 0xb1, 0xed}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x16, 0xbd, 0x27, 0xfc, 0xdf, 0xf1, 0xd, 0x5, + 0x3f, 0x92, 0x2e, 0xd8, 0x6e, 0xeb, 0x6a, 0x49}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa6, 0xf7, 0xa3, 0x87, 0xef, 0x8c, 0x45, 0xb2, 0x52, 0xe6, 0x2d, 0x98}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x4b, 0x24, 0x16, 0x64, 0x61, 0x4, 0xfd, 0xd9, 0xbe, 0xf1, + 0x70, 0x1e, 0xc, 0xbf, 0xc, 0x2e, 0xfc, 0x98, 0xf4, 0x7f, + 0xd7, 0x1e, 0x6e, 0xc3, 0x4, 0x79, 0x5a, 0x96}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7a, 0xfa, 0x6f, 0xfe, 0x79, 0x7, 0x7, 0x2c, 0xc9, 0x2b, - 0x23, 0xde, 0xd4, 0xa4, 0x18, 0x11, 0xb8, 0x8a, 0xd9}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa7}; + lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1b, 0xdc, 0xd, 0x34, 0x7, 0x6b, 0x87}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + uint8_t topic_filter_s6_bytes[] = {0x63, 0x37, 0x8e, 0xf3}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x9b, 0xb8, 0x91, 0x67, 0x66, 0xd7, 0x16, 0x7c, 0x25}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31149, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21602, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28306 [("^VR\US\DELZ\SYN\186#\147D\230\US:\188\210\186\165}\145tM\224\&4\158",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\146\&4\203\145\SUB\209\235\223`.\147\&8\250Q\187\223\244\210b\235p\RS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\205\151*/E\ETXy",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("m\136\t\NUL\228\154\166\199TU&2\143",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = True, _noLocal = False, _subQoS = QoS2})] [PropAuthenticationMethod -// "\151\191.\146\237\136B\SO\187[\200s\174\240\131\247\245",PropTopicAliasMaximum 30483,PropReceiveMaximum -// 10665,PropTopicAliasMaximum 27539,PropWillDelayInterval 20866,PropRetainAvailable 17,PropRetainAvailable -// 110,PropAuthenticationMethod -// "\210\137\139/\245\193\179\&6\148\191\195\ETB\ACKy@L\218\STX\150\162\239\235",PropRequestProblemInformation -// 146,PropRequestResponseInformation 102,PropTopicAlias 2117,PropMaximumPacketSize 21081,PropSessionExpiryInterval -// 9240,PropUserProperty "\148\138\ETBU\242\228\190i\148\139{\SI\DC3R\ACK\198\170K\SUB\185\189\164\129\190",PropReasonString +// "\192\145SO\207*\186\227\223",PropSubscriptionIdentifierAvailable 133,PropPayloadFormatIndicator +// 58,PropMessageExpiryInterval 5405,PropServerReference "\150\140\151\180\226Xe\b",PropTopicAliasMaximum +// 27080,PropResponseInformation +// "\184\254\&9Tn#Q\192\SYN\244\193\240/\180\DLE~\206\FS*\207\187\152\"\DC2",PropUserProperty +// "\252\&4=R\NAK\247nHl\242\STX\213&oY",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropReasonString "\223b +// @\167?\143\&7L\163\146\216\197;\DC2\213\228\234\208",PropMessageExpiryInterval 31326,PropTopicAlias +// 16320,PropReceiveMaximum 6351,PropWildcardSubscriptionAvailable 31,PropMessageExpiryInterval +// 8699,PropMaximumPacketSize 25430,PropPayloadFormatIndicator 87,PropReasonString +// "az\138\221\181\197\191\NAK{=\137)\243\181\184\209W4\231\253\229\153\163\170\156",PropSubscriptionIdentifier +// 9,PropMessageExpiryInterval 26330,PropTopicAlias 22270,PropMessageExpiryInterval 27322,PropCorrelationData +// "\131\145H\141\152\159\218H\153*\192\&7\186\154\231",PropMaximumQoS 32,PropMaximumQoS 233,PropWillDelayInterval +// 24371,PropRequestResponseInformation 149,PropSharedSubscriptionAvailable 31,PropSharedSubscriptionAvailable +// 199,PropRetainAvailable 125] +TEST(Subscribe5QCTest, Encode6) { + uint8_t pkt[] = {0x82, 0xd6, 0x1, 0x42, 0xd1, 0x7d, 0x1f, 0x0, 0x13, 0xdf, 0x62, 0x20, 0x40, 0xa7, 0x3f, 0x8f, 0x37, + 0x4c, 0xa3, 0x92, 0xd8, 0xc5, 0x3b, 0x12, 0xd5, 0xe4, 0xea, 0xd0, 0x2, 0x0, 0x0, 0x7a, 0x5e, 0x23, + 0x3f, 0xc0, 0x21, 0x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0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xd, 0xa6, 0x93, 0x19, 0xf, 0x7b, 0x1, 0xea, 0x6c, 0xe2, - 0xed, 0x5d, 0x84, 0x24, 0x21, 0x29, 0x59, 0x25, 0xb6, 0x20, - 0x13, 0xae, 0x2d, 0x43, 0xa4, 0x44, 0x1c, 0x91, 0x40}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xfb, 0x41, 0x4f, 0xe5, 0xcb, 0xcc, 0x61, 0xf7, 0xcc, 0xbf, + 0x14, 0xa2, 0xcc, 0x92, 0x4a, 0x55, 0xa0, 0x1a, 0x9d, 0xc3}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2c, 0x9c, 0x35, 0xef, 0xef, 0x3a, 0x40}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9b, 0xd8, 0xd, 0x4, 0xa9, 0xe, 0xe0, 0x9b, 0x6e, 0xeb, + 0x1c, 0xa, 0x75, 0x9f, 0x8e, 0x67, 0x3b, 0x95, 0xf6, 0x93, + 0x45, 0xb3, 0x5d, 0x62, 0xe7, 0x38, 0x1f, 0x2f, 0x3c, 0x1c}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x23, 0x8a, 0xa, 0x53, 0x67, 0x52, 0x64, 0x6, 0x55, 0xb4, 0xba, 0x91, 0x52, 0x9f, - 0xf9, 0x2f, 0x19, 0x8e, 0x20, 0x92, 0x58, 0xe4, 0x49, 0x33, 0x33, 0xb2, 0x23}; + uint8_t topic_filter_s2_bytes[] = {0x7b, 0x2c, 0x9f, 0x9a, 0x6a, 0xb9, 0x6f, 0xa, 0x8f, 0x6d, 0xb2, 0xf2, 0xcf, 0x3e, + 0x3d, 0x52, 0x15, 0xf7, 0x6e, 0x48, 0x6c, 0xf2, 0x2, 0xd5, 0x26, 0x6f, 0x59}; lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3b, 0x82, 0xe5, 0xac, 0x21, 0xcb, 0x7c}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x52, 0xb7, 0x0, 0xf7, 0x47, 0xc9, 0xc0, 0x15, 0x77, 0x98, 0x2e, - 0x70, 0xe6, 0x7f, 0xd0, 0xc5, 0x21, 0xf3, 0x65, 0xa7, 0xcb}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; + uint8_t bytesprops0[] = {0xdf, 0x62, 0x20, 0x40, 0xa7, 0x3f, 0x8f, 0x37, 0x4c, 0xa3, + 0x92, 0xd8, 0xc5, 0x3b, 0x12, 0xd5, 0xe4, 0xea, 0xd0}; + uint8_t bytesprops1[] = {0x61, 0x7a, 0x8a, 0xdd, 0xb5, 0xc5, 0xbf, 0x15, 0x7b, 0x3d, 0x89, 0x29, 0xf3, + 0xb5, 0xb8, 0xd1, 0x57, 0x34, 0xe7, 0xfd, 0xe5, 0x99, 0xa3, 0xaa, 0x9c}; + uint8_t bytesprops2[] = {0x83, 0x91, 0x48, 0x8d, 0x98, 0x9f, 0xda, 0x48, 0x99, 0x2a, 0xc0, 0x37, 0xba, 0x9a, 0xe7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30374}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 130}}, {.prop = (lwmqtt_prop_t)41, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12495}}, {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27761}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31326}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16320}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6351}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8699}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25430}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26330}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22270}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27322}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24371}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13416, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17105, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19505 [("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = -// True, _subQoS = QoS0}),("\193~\153\213\236\138\165\192;P\209\245\207",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\154\DC41*\134\182g\t'\129\&1\ETX\186_\STX\SYNks\SI\235P",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("1f,]@\243\146\195\138U\CAN\153B\215M8\229X?",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("k\241\"\130\130\f=\CANf\154\172\152E",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("W\235/\243\DLE",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, -// _subQoS = QoS1}),("\168\164\163wJ",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS2}),("\229\237\196\180\216\NAK\196\157'\221z\153\239-\EOT\202X\ENQK\177YOB+",SubOptions +// SubscribeRequest 26860 [("\\\141\254\CAN\217\DC4\240\244\DELx;\238\SO\168\&6A\223v\163\128",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("t\181>5/\245\f\155\161\184\211",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// True, _noLocal = False, _subQoS = QoS0}),("\STX=\b\150d\219\200\177\178\226D\153\252A\229",SubOptions // {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("RLl\155O\151\a\202]\163\201\221\153L+]\180\223\205\130\DC2h\NUL)\250\252\213\DC4",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropReasonString "\157\164\163\DC1[\246\STXH",PropSharedSubscriptionAvailable 191,PropSubscriptionIdentifier -// 5,PropSubscriptionIdentifierAvailable 89,PropMessageExpiryInterval 26463,PropReasonString "W -// \202\173\&5\169\&3N\183*\240V|]\209\176$\DLE\208",PropMaximumQoS 117,PropSubscriptionIdentifierAvailable -// 215,PropWildcardSubscriptionAvailable 169,PropServerReference -// "\240<\249Kx1\210\149\226\172\191\CANy;",PropResponseTopic "\NUL&\172*\180\NUL",PropAuthenticationData -// "3\192G\bV\176",PropTopicAlias 29798,PropMaximumQoS 29,PropMaximumPacketSize 7661,PropUserProperty -// "\230\183\aKq\DC4K2" "c\195\168p\202\248\CAN\218\DEL\SUB\247p\174\162H\188U!",PropPayloadFormatIndicator -// 35,PropServerReference "+\250\DC4\242\222\182/",PropSessionExpiryInterval 30690,PropPayloadFormatIndicator -// 113,PropWillDelayInterval 31221,PropRequestProblemInformation 46] -TEST(Subscribe5QCTest, Encode3) { - uint8_t pkt[] = { - 0x82, 0xb7, 0x2, 0x4c, 0x31, 0x98, 0x1, 0x1f, 0x0, 0x8, 0x9d, 0xa4, 0xa3, 0x11, 0x5b, 0xf6, 0x2, 0x48, 0x2a, - 0xbf, 0xb, 0x5, 0x29, 0x59, 0x2, 0x0, 0x0, 0x67, 0x5f, 0x1f, 0x0, 0x13, 0x57, 0x20, 0xca, 0xad, 0x35, 0xa9, - 0x33, 0x4e, 0xb7, 0x2a, 0xf0, 0x56, 0x7c, 0x5d, 0xd1, 0xb0, 0x24, 0x10, 0xd0, 0x24, 0x75, 0x29, 0xd7, 0x28, 0xa9, - 0x1c, 0x0, 0xe, 0xf0, 0x3c, 0xf9, 0x4b, 0x78, 0x31, 0xd2, 0x95, 0xe2, 0xac, 0xbf, 0x18, 0x79, 0x3b, 0x8, 0x0, - 0x6, 0x0, 0x26, 0xac, 0x2a, 0xb4, 0x0, 0x16, 0x0, 0x6, 0x33, 0xc0, 0x47, 0x8, 0x56, 0xb0, 0x23, 0x74, 0x66, - 0x24, 0x1d, 0x27, 0x0, 0x0, 0x1d, 0xed, 0x26, 0x0, 0x8, 0xe6, 0xb7, 0x7, 0x4b, 0x71, 0x14, 0x4b, 0x32, 0x0, - 0x12, 0x63, 0xc3, 0xa8, 0x70, 0xca, 0xf8, 0x18, 0xda, 0x7f, 0x1a, 0xf7, 0x70, 0xae, 0xa2, 0x48, 0xbc, 0x55, 0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ubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS0}),("\194t\244\206\158\155>\128\183y\199\173\195\199~F\150;\142\178d",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] +// [PropRetainAvailable 154,PropSubscriptionIdentifierAvailable 188,PropMaximumPacketSize +// 17727,PropRequestResponseInformation 216,PropResponseTopic "Y\168\178\200/\208",PropReceiveMaximum +// 30281,PropTopicAliasMaximum 7251,PropSessionExpiryInterval 20135,PropSessionExpiryInterval 569,PropTopicAliasMaximum +// 7009,PropTopicAlias 16877,PropCorrelationData "\154\229V\235\EOT\190b\152",PropReceiveMaximum 12069,PropMaximumQoS +// 161,PropMessageExpiryInterval 426,PropSubscriptionIdentifierAvailable 154] +TEST(Subscribe5QCTest, Encode7) { + uint8_t pkt[] = {0x82, 0xa0, 0x1, 0x68, 0xec, 0x41, 0x25, 0x9a, 0x29, 0xbc, 0x27, 0x0, 0x0, 0x45, 0x3f, 0x19, 0xd8, + 0x8, 0x0, 0x6, 0x59, 0xa8, 0xb2, 0xc8, 0x2f, 0xd0, 0x21, 0x76, 0x49, 0x22, 0x1c, 0x53, 0x11, 0x0, + 0x0, 0x4e, 0xa7, 0x11, 0x0, 0x0, 0x2, 0x39, 0x22, 0x1b, 0x61, 0x23, 0x41, 0xed, 0x9, 0x0, 0x8, + 0x9a, 0xe5, 0x56, 0xeb, 0x4, 0xbe, 0x62, 0x98, 0x21, 0x2f, 0x25, 0x24, 0xa1, 0x2, 0x0, 0x0, 0x1, + 0xaa, 0x29, 0x9a, 0x0, 0x14, 0x5c, 0x8d, 0xfe, 0x18, 0xd9, 0x14, 0xf0, 0xf4, 0x7f, 0x78, 0x3b, 0xee, + 0xe, 0xa8, 0x36, 0x41, 0xdf, 0x76, 0xa3, 0x80, 0x1d, 0x0, 0xb, 0x74, 0xb5, 0x3e, 0x35, 0x2f, 0xf5, + 0xc, 0x9b, 0xa1, 0xb8, 0xd3, 0x28, 0x0, 0xf, 0x2, 0x3d, 0x8, 0x96, 0x64, 0xdb, 0xc8, 0xb1, 0xb2, + 0xe2, 0x44, 0x99, 0xfc, 0x41, 0xe5, 0x11, 0x0, 0xa, 0xf5, 0x8a, 0xc, 0x6c, 0xe4, 0x9f, 0xe0, 0x42, + 0x6e, 0x79, 0x8, 0x0, 0x15, 0xc2, 0x74, 0xf4, 0xce, 0x9e, 0x9b, 0x3e, 0x80, 0xb7, 0x79, 0xc7, 0xad, + 0xc3, 0xc7, 0x7e, 0x46, 0x96, 0x3b, 0x8e, 0xb2, 0x64, 0x1c}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x5c, 0x8d, 0xfe, 0x18, 0xd9, 0x14, 0xf0, 0xf4, 0x7f, 0x78, + 0x3b, 0xee, 0xe, 0xa8, 0x36, 0x41, 0xdf, 0x76, 0xa3, 0x80}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc1, 0x7e, 0x99, 0xd5, 0xec, 0x8a, 0xa5, 0xc0, 0x3b, 0x50, 0xd1, 0xf5, 0xcf}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x74, 0xb5, 0x3e, 0x35, 0x2f, 0xf5, 0xc, 0x9b, 0xa1, 0xb8, 0xd3}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9a, 0x14, 0x31, 0x2a, 0x86, 0xb6, 0x67, 0x9, 0x27, 0x81, 0x31, - 0x3, 0xba, 0x5f, 0x2, 0x16, 0x6b, 0x73, 0xf, 0xeb, 0x50}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2, 0x3d, 0x8, 0x96, 0x64, 0xdb, 0xc8, 0xb1, + 0xb2, 0xe2, 0x44, 0x99, 0xfc, 0x41, 0xe5}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x31, 0x66, 0x2c, 0x5d, 0x40, 0xf3, 0x92, 0xc3, 0x8a, 0x55, - 0x18, 0x99, 0x42, 0xd7, 0x4d, 0x38, 0xe5, 0x58, 0x3f}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf5, 0x8a, 0xc, 0x6c, 0xe4, 0x9f, 0xe0, 0x42, 0x6e, 0x79}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x6b, 0xf1, 0x22, 0x82, 0x82, 0xc, 0x3d, 0x18, 0x66, 0x9a, 0xac, 0x98, 0x45}; - lwmqtt_string_t topic_filter_s4 = {13, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc2, 0x74, 0xf4, 0xce, 0x9e, 0x9b, 0x3e, 0x80, 0xb7, 0x79, 0xc7, + 0xad, 0xc3, 0xc7, 0x7e, 0x46, 0x96, 0x3b, 0x8e, 0xb2, 0x64}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x57, 0xeb, 0x2f, 0xf3, 0x10}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa8, 0xa4, 0xa3, 0x77, 0x4a}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe5, 0xed, 0xc4, 0xb4, 0xd8, 0x15, 0xc4, 0x9d, 0x27, 0xdd, 0x7a, 0x99, - 0xef, 0x2d, 0x4, 0xca, 0x58, 0x5, 0x4b, 0xb1, 0x59, 0x4f, 0x42, 0x2b}; - lwmqtt_string_t topic_filter_s7 = {24, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x52, 0x4c, 0x6c, 0x9b, 0x4f, 0x97, 0x7, 0xca, 0x5d, 0xa3, - 0xc9, 0xdd, 0x99, 0x4c, 0x2b, 0x5d, 0xb4, 0xdf, 0xcd, 0x82, - 0x12, 0x68, 0x0, 0x29, 0xfa, 0xfc, 0xd5, 0x14}; - lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - uint8_t bytesprops0[] = {0x9d, 0xa4, 0xa3, 0x11, 0x5b, 0xf6, 0x2, 0x48}; - uint8_t bytesprops1[] = {0x57, 0x20, 0xca, 0xad, 0x35, 0xa9, 0x33, 0x4e, 0xb7, 0x2a, - 0xf0, 0x56, 0x7c, 0x5d, 0xd1, 0xb0, 0x24, 0x10, 0xd0}; - uint8_t bytesprops2[] = {0xf0, 0x3c, 0xf9, 0x4b, 0x78, 0x31, 0xd2, 0x95, 0xe2, 0xac, 0xbf, 0x18, 0x79, 0x3b}; - uint8_t bytesprops3[] = {0x0, 0x26, 0xac, 0x2a, 0xb4, 0x0}; - uint8_t bytesprops4[] = {0x33, 0xc0, 0x47, 0x8, 0x56, 0xb0}; - uint8_t bytesprops6[] = {0x63, 0xc3, 0xa8, 0x70, 0xca, 0xf8, 0x18, 0xda, 0x7f, - 0x1a, 0xf7, 0x70, 0xae, 0xa2, 0x48, 0xbc, 0x55, 0x21}; - uint8_t bytesprops5[] = {0xe6, 0xb7, 0x7, 0x4b, 0x71, 0x14, 0x4b, 0x32}; - uint8_t bytesprops7[] = {0x2b, 0xfa, 0x14, 0xf2, 0xde, 0xb6, 0x2f}; + sub_opts[4].no_local = true; + uint8_t bytesprops0[] = {0x59, 0xa8, 0xb2, 0xc8, 0x2f, 0xd0}; + uint8_t bytesprops1[] = {0x9a, 0xe5, 0x56, 0xeb, 0x4, 0xbe, 0x62, 0x98}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26463}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29798}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7661}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops5}, .v = {18, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30690}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31221}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17727}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30281}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7251}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20135}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 569}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7009}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16877}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12069}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 426}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 154}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19505, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26860, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22696 [("i\\\ETB]\223\172\230\167S\161\b\f\181\140\230\235\211\199\RS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\167",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\167E\206\237eq!\244c\192\133\243\244",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS2}),("\150\245e",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\156\133~]\132@\193",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\RS\145\206) -// \b\156\205\226\161RF\ETX\DC3\144q\211\212pm]%6\185\228\189p",SubOptions {_retainHandling = SendOnSubscribeNew, +// SubscribeRequest 11675 [("n\192\248\255\205<\240\238\SO!\140\179\201",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("o",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\188*F\240k\177\DEL\179Z\238a\160$\225\245*\135(\DC2q",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\197\168cf\214e\153\EM_T\211\151;\179\163\164 -// \135\158\193\SOH",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("C\133\193\&1\150FS\ESC\227S;\138I\ETX\SUB",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\148\241Hb\144[\206)\160\178w",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("HG\190\249\226\171Bd;n\226\240\138\157R\188\178\139",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropUserProperty "=\254\ESC\143n\170~1" -// "\139\206\167\196S\180\252\205\128\213z\132Y\213\SYN\225\133\213\&8$",PropContentType -// "v\DEL\186\DC2J\156\210O",PropUserProperty "\ETX\206\SUB\ETX\162\249\b$\169\254/\DEL\215\ETX\214\202\179lr\ESC;Q" -// "y\197\DEL\202\&6*\237{\144(\206-\"\215\215\136\239\237\ETB\183\US",PropResponseTopic -// "\190%4!\141\131",PropSharedSubscriptionAvailable 243,PropTopicAliasMaximum 30973,PropCorrelationData -// "",PropServerReference "@3}\150J\188\251\170\142\DLE ",PropWildcardSubscriptionAvailable 73,PropAuthenticationData -// "1\134u8\DC2!\136\172",PropMaximumPacketSize 21435,PropAuthenticationData -// "~YJM\211\142\158&\227\153\185=(Ob\188.$1\232\204=\249\ACK",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\184\209\128O=(Q\229",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("2E\213\230\200\236\143\235\&0\NUL\CAN\ESC#Y\224Bf\FS-z\133 \192'C",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\177\212\217\238\249\r\208\171n\214\145HAI\FSG\NUL>\198\212y\RS\217\148\225\CANQ",SubOptions +// SubscribeRequest 3007 [("<\ESCJ\DC2V\230\n\158\168\250G%\212R\210V\227\229\134j\165\&3)\146\165\&95",SubOptions // {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("1\152:S",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("\180n\153T\208\214\157",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// True, _noLocal = False, _subQoS = QoS0}),("\168eem\240p\168\224\244\EOT\131/;\201\179\224",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(")ZK[\221\236\"r\197\144\180\255,\159\143\229\160\189\242",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval -// 9681,PropRequestResponseInformation 112,PropSubscriptionIdentifier 13,PropAssignedClientIdentifier -// "\168+\167\203\"\239\253K\240\150\231]\131\202\231\175\233\135\128K\132\227\217\&4\222$\182\&8\196\209",PropSubscriptionIdentifier -// 14,PropServerKeepAlive 27976,PropRetainAvailable 103,PropSessionExpiryInterval 15663,PropAssignedClientIdentifier -// "\229q\247_d}\143{\232Fi\153\248\228\ETXM6",PropContentType "\145t\166\134\205\232\203\129",PropSessionExpiryInterval -// 8709,PropSubscriptionIdentifierAvailable 52,PropServerKeepAlive 7895,PropServerReference -// "\175\213\152\183^x\fY\165,\154",PropResponseTopic "\250\ESCX\a\230B\239\249\137eFA",PropCorrelationData -// "\254;\t\222p\170\NAK",PropServerKeepAlive 21236,PropSubscriptionIdentifier 12,PropWillDelayInterval -// 21266,PropRequestResponseInformation 45] -TEST(Subscribe5QCTest, Encode5) { +// QoS0}),("_\234\180~!\246(\231}4\200\221\168\191\149\197$0\202\223\&0\150\vE\169\217\189",SubOptions {_retainHandling +// = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\GS\195\202\227\242t}K9k\EMD\149|\186\ESC~tO\216\200\234",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("Nz\DC2\155\&2\182\ETB>)\DC2&?\246\193i`\151\NAK_\US4\DC1\252\234\DC2Z\NUL\a\153",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("@\194TRT +// \178\157\251\225q\SO\181(\194\220\217p",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\206\DLE\241X5E\154\204\CAN\229~hlj{`f1\155y\181\DEL\217;",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\201{}\179\NAK",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = +// True, _subQoS = QoS0}),("f\t\SYN\165=\225\132\NUL\207\161F\250\237\SOH\195\142\"\148",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\186\ETX[",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\234\250\254\182(\DEL\154mqQ\135K\160MA\174\234\211\145}\187\DC2hn/_",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropReasonString +// "",PropServerKeepAlive 8062] +TEST(Subscribe5QCTest, Encode9) { uint8_t pkt[] = { - 0x82, 0xc0, 0x2, 0x36, 0xdf, 0x92, 0x1, 0x2, 0x0, 0x0, 0x25, 0xd1, 0x19, 0x70, 0xb, 0xd, 0x12, 0x0, 0x1e, - 0xa8, 0x2b, 0xa7, 0xcb, 0x22, 0xef, 0xfd, 0x4b, 0xf0, 0x96, 0xe7, 0x5d, 0x83, 0xca, 0xe7, 0xaf, 0xe9, 0x87, 0x80, - 0x4b, 0x84, 0x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, 0x7e, 0x74, 0x4f, 0xd8, 0xc8, + 0xea, 0x4, 0x0, 0x0, 0x2a, 0x0, 0x1d, 0x4e, 0x7a, 0x12, 0x9b, 0x32, 0xb6, 0x17, 0x3e, 0x29, 0x12, 0x26, 0x3f, + 0xf6, 0xc1, 0x69, 0x60, 0x97, 0x15, 0x5f, 0x1f, 0x34, 0x11, 0xfc, 0xea, 0x12, 0x5a, 0x0, 0x7, 0x99, 0xd, 0x0, + 0x12, 0x40, 0xc2, 0x54, 0x52, 0x54, 0x20, 0xb2, 0x9d, 0xfb, 0xe1, 0x71, 0xe, 0xb5, 0x28, 0xc2, 0xdc, 0xd9, 0x70, + 0x11, 0x0, 0x18, 0xce, 0x10, 0xf1, 0x58, 0x35, 0x45, 0x9a, 0xcc, 0x18, 0xe5, 0x7e, 0x68, 0x6c, 0x6a, 0x7b, 0x60, + 0x66, 0x31, 0x9b, 0x79, 0xb5, 0x7f, 0xd9, 0x3b, 0x14, 0x0, 0x5, 0xc9, 0x7b, 0x7d, 0xb3, 0x15, 0x14, 0x0, 0x12, + 0x66, 0x9, 0x16, 0xa5, 0x3d, 0xe1, 0x84, 0x0, 0xcf, 0xa1, 0x46, 0xfa, 0xed, 0x1, 0xc3, 0x8e, 0x22, 0x94, 0x8, + 0x0, 0x3, 0xba, 0x3, 0x5b, 0x5, 0x0, 0x1a, 0xea, 0xfa, 0xfe, 0xb6, 0x28, 0x7f, 0x9a, 0x6d, 0x71, 0x51, 0x87, + 0x4b, 0xa0, 0x4d, 0x41, 0xae, 0xea, 0xd3, 0x91, 0x7d, 0xbb, 0x12, 0x68, 0x6e, 0x2f, 0x5f, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd, 0xfd, 0xd3, 0x5d, 0x9, 0x82, 0x7c, 0xce, - 0x31, 0xe7, 0x83, 0x4, 0xf, 0x81, 0xe5, 0x8c}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x3c, 0x1b, 0x4a, 0x12, 0x56, 0xe6, 0xa, 0x9e, 0xa8, 0xfa, 0x47, 0x25, 0xd4, 0x52, + 0xd2, 0x56, 0xe3, 0xe5, 0x86, 0x6a, 0xa5, 0x33, 0x29, 0x92, 0xa5, 0x39, 0x35}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf5, 0xc1, 0x68, 0xbe, 0x8a, 0xa8, 0xe3, - 0x6a, 0x1a, 0x12, 0xe8, 0x81, 0x41, 0xc5}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5f, 0xea, 0xb4, 0x7e, 0x21, 0xf6, 0x28, 0xe7, 0x7d, 0x34, 0xc8, 0xdd, 0xa8, 0xbf, + 0x95, 0xc5, 0x24, 0x30, 0xca, 0xdf, 0x30, 0x96, 0xb, 0x45, 0xa9, 0xd9, 0xbd}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x98, 0x3e, 0xf9, 0x6}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1d, 0xc3, 0xca, 0xe3, 0xf2, 0x74, 0x7d, 0x4b, 0x39, 0x6b, 0x19, + 0x44, 0x95, 0x7c, 0xba, 0x1b, 0x7e, 0x74, 0x4f, 0xd8, 0xc8, 0xea}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb8, 0xd1, 0x80, 0x4f, 0x3d, 0x28, 0x51, 0xe5}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x32, 0x45, 0xd5, 0xe6, 0xc8, 0xec, 0x8f, 0xeb, 0x30, 0x0, 0x18, 0x1b, 0x23, - 0x59, 0xe0, 0x42, 0x66, 0x1c, 0x2d, 0x7a, 0x85, 0x20, 0xc0, 0x27, 0x43}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x4e, 0x7a, 0x12, 0x9b, 0x32, 0xb6, 0x17, 0x3e, 0x29, 0x12, + 0x26, 0x3f, 0xf6, 0xc1, 0x69, 0x60, 0x97, 0x15, 0x5f, 0x1f, + 0x34, 0x11, 0xfc, 0xea, 0x12, 0x5a, 0x0, 0x7, 0x99}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb1, 0xd4, 0xd9, 0xee, 0xf9, 0xd, 0xd0, 0xab, 0x6e, 0xd6, 0x91, 0x48, 0x41, 0x49, - 0x1c, 0x47, 0x0, 0x3e, 0xc6, 0xd4, 0x79, 0x1e, 0xd9, 0x94, 0xe1, 0x18, 0x51}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x40, 0xc2, 0x54, 0x52, 0x54, 0x20, 0xb2, 0x9d, 0xfb, + 0xe1, 0x71, 0xe, 0xb5, 0x28, 0xc2, 0xdc, 0xd9, 0x70}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x31, 0x98, 0x3a, 0x53}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xce, 0x10, 0xf1, 0x58, 0x35, 0x45, 0x9a, 0xcc, 0x18, 0xe5, 0x7e, 0x68, + 0x6c, 0x6a, 0x7b, 0x60, 0x66, 0x31, 0x9b, 0x79, 0xb5, 0x7f, 0xd9, 0x3b}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb4, 0x6e, 0x99, 0x54, 0xd0, 0xd6, 0x9d}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xc9, 0x7b, 0x7d, 0xb3, 0x15}; + lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa8, 0x65, 0x65, 0x6d, 0xf0, 0x70, 0xa8, 0xe0, - 0xf4, 0x4, 0x83, 0x2f, 0x3b, 0xc9, 0xb3, 0xe0}; - lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x66, 0x9, 0x16, 0xa5, 0x3d, 0xe1, 0x84, 0x0, 0xcf, + 0xa1, 0x46, 0xfa, 0xed, 0x1, 0xc3, 0x8e, 0x22, 0x94}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x29, 0x5a, 0x4b, 0x5b, 0xdd, 0xec, 0x22, 0x72, 0xc5, 0x90, - 0xb4, 0xff, 0x2c, 0x9f, 0x8f, 0xe5, 0xa0, 0xbd, 0xf2}; - lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0xba, 0x3, 0x5b}; + lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s10_bytes[] = {0xea, 0xfa, 0xfe, 0xb6, 0x28, 0x7f, 0x9a, 0x6d, 0x71, 0x51, 0x87, 0x4b, 0xa0, + 0x4d, 0x41, 0xae, 0xea, 0xd3, 0x91, 0x7d, 0xbb, 0x12, 0x68, 0x6e, 0x2f, 0x5f}; + lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; + sub_opts[6].no_local = true; sub_opts[7].qos = LWMQTT_QOS0; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; + sub_opts[8].retain_as_published = true; sub_opts[8].no_local = false; sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - uint8_t bytesprops0[] = {0xa8, 0x2b, 0xa7, 0xcb, 0x22, 0xef, 0xfd, 0x4b, 0xf0, 0x96, 0xe7, 0x5d, 0x83, 0xca, 0xe7, - 0xaf, 0xe9, 0x87, 0x80, 0x4b, 0x84, 0xe3, 0xd9, 0x34, 0xde, 0x24, 0xb6, 0x38, 0xc4, 0xd1}; - uint8_t bytesprops1[] = {0xe5, 0x71, 0xf7, 0x5f, 0x64, 0x7d, 0x8f, 0x7b, 0xe8, - 0x46, 0x69, 0x99, 0xf8, 0xe4, 0x3, 0x4d, 0x36}; - uint8_t bytesprops2[] = {0x91, 0x74, 0xa6, 0x86, 0xcd, 0xe8, 0xcb, 0x81}; - uint8_t bytesprops3[] = {0xaf, 0xd5, 0x98, 0xb7, 0x5e, 0x78, 0xc, 0x59, 0xa5, 0x2c, 0x9a}; - uint8_t bytesprops4[] = {0xfa, 0x1b, 0x58, 0x7, 0xe6, 0x42, 0xef, 0xf9, 0x89, 0x65, 0x46, 0x41}; - uint8_t bytesprops5[] = {0xfe, 0x3b, 0x9, 0xde, 0x70, 0xaa, 0x15}; + sub_opts[9].no_local = true; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; + uint8_t bytesprops0[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9681}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27976}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15663}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8709}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7895}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21236}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21266}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8062}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14047, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3007, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 502 [("\ESC\USm\212\ETB\238\&9\252\153\189\163S\234=+",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("{\221\\\229 -// :\162\183\177\157\208\253\FS\144bS\217\ETB\180",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("U,\243\&4\ETB\241\&1\142\221\ACK#\tm\137\153\131F\200\147\&1\153\242\176\192\241\132>\192\174",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\SI\SI\DC39\233\224\EMM\128L5\235\156\157o\239N7\172:d\247",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropCorrelationData -// "\t\197[\224\236Y\206}\148\234\178P\237\222\147(\217\162\154\nL\201|\ACK\184\DLE\243\151\254",PropSubscriptionIdentifierAvailable -// 209,PropTopicAlias 23243,PropTopicAliasMaximum 24913,PropSubscriptionIdentifierAvailable 10,PropMaximumPacketSize -// 27215,PropPayloadFormatIndicator 37,PropContentType "\ESC\175*!\157\249'\t\158\\\204\DC4\158Bo|\140\RS.\202\128 -// 2\243\229\185\226",PropRetainAvailable 124,PropRetainAvailable 27,PropSubscriptionIdentifier 0,PropAuthenticationData -// "\DEL\ETX'\143\245\191\229\196\179$",PropPayloadFormatIndicator 43,PropAuthenticationData -// "\177",PropMessageExpiryInterval 1767,PropResponseInformation -// "E\NAKD3[\244*\254\248\246q\215\177\250\RSPU\148.\180^\DC4\ETB#q\218",PropContentType -// "\ENQ\v\221x0F\ACKe\ETB<\255ZS\DEL\169\233O>|0\SO\228\172\142\&7\224\&7",PropPayloadFormatIndicator -// 75,PropSubscriptionIdentifierAvailable 152,PropSharedSubscriptionAvailable 194,PropAuthenticationMethod -// "Ql\234\237c\224\v\151\bG\DEL\141\CAN",PropReceiveMaximum 26111,PropAssignedClientIdentifier -// "\154\162T\157\216\252\187~H\232X\ETX>\146\196\234/\219\239\194",PropReasonString -// "F8pG\158",PropSessionExpiryInterval 28561,PropMaximumPacketSize 13192,PropReasonString "~\191\216`\194}:\246"] -TEST(Subscribe5QCTest, Encode6) { +// SubscribeRequest 30616 [("b\GS\215\182QH\USjKr\230\129\142?Q\129UE\243\147n\229\160)\137",SubOptions {_retainHandling +// = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\164\EMyC\254\225\STX33_\EOTAsM\"\DEL\236\&3jy",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("}\159dgE^\200\218v",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\DC2\249\217\184\DEL\147\151g\128\169}\221\168\236~l",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\227\172\EM\147eL\199B +// \USLxP\210\a4as\191\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, +// _subQoS = QoS1})] [PropRequestResponseInformation 255,PropAssignedClientIdentifier +// "\190\DLE\FS\134c\141\255\181\"\248z\206N\t@\160{\200]\SYN\140\f\198\232\176>\252\243\t\203",PropReceiveMaximum +// 29184,PropTopicAliasMaximum 29191,PropRetainAvailable 168,PropServerKeepAlive 31897,PropServerKeepAlive +// 26301,PropUserProperty "\230I\187\DC3X\225\190\156\156E\249\132\DC2\244\&3v\158\144\182F" +// "\131\238\138\225\SI\204r\200#\SYN?\234&\ESCg4\176\213\&3\227;\146\228\209k\246",PropAuthenticationData +// "\254\172\138\226\"bfv\179\220\166",PropAuthenticationMethod +// "TlTU\SUBqZU\187\b\156\160\&8\224\244\252\CAN\190\152",PropResponseInformation +// "\246\164\160zZ",PropWildcardSubscriptionAvailable 0,PropContentType "",PropReceiveMaximum 29467,PropUserProperty +// "\253\RSI\129\158\223IT\156\186\DC2~\161\161\194/\130\179\168\213VX\247QY" "d5",PropUserProperty +// "q\207\173\188\221\183\194\223\155\181\193/c\247a" +// "\236d\219pJ%\DC3gf1\189\196\166\227\224\NAKx\243$\ETB\194\163\147",PropMessageExpiryInterval 9079,PropMaximumQoS +// 74,PropRequestProblemInformation 57] +TEST(Subscribe5QCTest, Encode10) { uint8_t pkt[] = { - 0x82, 0xda, 0x2, 0x1, 0xf6, 0xf5, 0x1, 0x9, 0x0, 0x1d, 0x9, 0xc5, 0x5b, 0xe0, 0xec, 0x59, 0xce, 0x7d, 0x94, - 0xea, 0xb2, 0x50, 0xed, 0xde, 0x93, 0x28, 0xd9, 0xa2, 0x9a, 0xa, 0x4c, 0xc9, 0x7c, 0x6, 0xb8, 0x10, 0xf3, 0x97, - 0xfe, 0x29, 0xd1, 0x23, 0x5a, 0xcb, 0x22, 0x61, 0x51, 0x29, 0xa, 0x27, 0x0, 0x0, 0x6a, 0x4f, 0x1, 0x25, 0x3, - 0x0, 0x1b, 0x1b, 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0, 0x29, 0x89, 0x2e, 0x0, 0x14, 0xa4, 0x19, 0x79, 0x43, 0xfe, 0xe1, 0x2, 0x33, 0x33, 0x5f, 0x4, 0x41, + 0x73, 0x4d, 0x22, 0x7f, 0xec, 0x33, 0x6a, 0x79, 0x22, 0x0, 0x9, 0x7d, 0x9f, 0x64, 0x67, 0x45, 0x5e, 0xc8, 0xda, + 0x76, 0x16, 0x0, 0x10, 0x12, 0xf9, 0xd9, 0xb8, 0x7f, 0x93, 0x97, 0x67, 0x80, 0xa9, 0x7d, 0xdd, 0xa8, 0xec, 0x7e, + 0x6c, 0x15, 0x0, 0x14, 0xe3, 0xac, 0x19, 0x93, 0x65, 0x4c, 0xc7, 0x42, 0x20, 0x1f, 0x4c, 0x78, 0x50, 0xd2, 0x7, + 0x34, 0x61, 0x73, 0xbf, 0xe8, 0xd}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x1b, 0x1f, 0x6d, 0xd4, 0x17, 0xee, 0x39, 0xfc, - 0x99, 0xbd, 0xa3, 0x53, 0xea, 0x3d, 0x2b}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x62, 0x1d, 0xd7, 0xb6, 0x51, 0x48, 0x1f, 0x6a, 0x4b, 0x72, 0xe6, 0x81, 0x8e, + 0x3f, 0x51, 0x81, 0x55, 0x45, 0xf3, 0x93, 0x6e, 0xe5, 0xa0, 0x29, 0x89}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7b, 0xdd, 0x5c, 0xe5, 0x20, 0x3a, 0xa2, 0xb7, 0xb1, 0x9d, - 0xd0, 0xfd, 0x1c, 0x90, 0x62, 0x53, 0xd9, 0x17, 0xb4}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa4, 0x19, 0x79, 0x43, 0xfe, 0xe1, 0x2, 0x33, 0x33, 0x5f, + 0x4, 0x41, 0x73, 0x4d, 0x22, 0x7f, 0xec, 0x33, 0x6a, 0x79}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x55, 0x2c, 0xf3, 0x34, 0x17, 0xf1, 0x31, 0x8e, 0xdd, 0x6, - 0x23, 0x9, 0x6d, 0x89, 0x99, 0x83, 0x46, 0xc8, 0x93, 0x31, - 0x99, 0xf2, 0xb0, 0xc0, 0xf1, 0x84, 0x3e, 0xc0, 0xae}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7d, 0x9f, 0x64, 0x67, 0x45, 0x5e, 0xc8, 0xda, 0x76}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf, 0xf, 0x13, 0x39, 0xe9, 0xe0, 0x19, 0x4d, 0x80, 0x4c, 0x35, - 0xeb, 0x9c, 0x9d, 0x6f, 0xef, 0x4e, 0x37, 0xac, 0x3a, 0x64, 0xf7}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x12, 0xf9, 0xd9, 0xb8, 0x7f, 0x93, 0x97, 0x67, + 0x80, 0xa9, 0x7d, 0xdd, 0xa8, 0xec, 0x7e, 0x6c}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + uint8_t topic_filter_s4_bytes[] = {0xe3, 0xac, 0x19, 0x93, 0x65, 0x4c, 0xc7, 0x42, 0x20, 0x1f, + 0x4c, 0x78, 0x50, 0xd2, 0x7, 0x34, 0x61, 0x73, 0xbf, 0xe8}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - uint8_t bytesprops0[] = {0x9, 0xc5, 0x5b, 0xe0, 0xec, 0x59, 0xce, 0x7d, 0x94, 0xea, 0xb2, 0x50, 0xed, 0xde, 0x93, - 0x28, 0xd9, 0xa2, 0x9a, 0xa, 0x4c, 0xc9, 0x7c, 0x6, 0xb8, 0x10, 0xf3, 0x97, 0xfe}; - uint8_t bytesprops1[] = {0x1b, 0xaf, 0x2a, 0x21, 0x9d, 0xf9, 0x27, 0x9, 0x9e, 0x5c, 0xcc, 0x14, 0x9e, 0x42, - 0x6f, 0x7c, 0x8c, 0x1e, 0x2e, 0xca, 0x80, 0x20, 0x32, 0xf3, 0xe5, 0xb9, 0xe2}; - uint8_t bytesprops2[] = {0x7f, 0x3, 0x27, 0x8f, 0xf5, 0xbf, 0xe5, 0xc4, 0xb3, 0x24}; - uint8_t bytesprops3[] = {0xb1}; - uint8_t bytesprops4[] = {0x45, 0x15, 0x44, 0x33, 0x5b, 0xf4, 0x2a, 0xfe, 0xf8, 0xf6, 0x71, 0xd7, 0xb1, - 0xfa, 0x1e, 0x50, 0x55, 0x94, 0x2e, 0xb4, 0x5e, 0x14, 0x17, 0x23, 0x71, 0xda}; - uint8_t bytesprops5[] = {0x5, 0xb, 0xdd, 0x78, 0x30, 0x46, 0x6, 0x65, 0x17, 0x3c, 0xff, 0x5a, 0x53, 0x7f, - 0xa9, 0xe9, 0x4f, 0x3e, 0x7c, 0x30, 0xe, 0xe4, 0xac, 0x8e, 0x37, 0xe0, 0x37}; - uint8_t bytesprops6[] = {0x51, 0x6c, 0xea, 0xed, 0x63, 0xe0, 0xb, 0x97, 0x8, 0x47, 0x7f, 0x8d, 0x18}; - uint8_t bytesprops7[] = {0x9a, 0xa2, 0x54, 0x9d, 0xd8, 0xfc, 0xbb, 0x7e, 0x48, 0xe8, - 0x58, 0x3, 0x3e, 0x92, 0xc4, 0xea, 0x2f, 0xdb, 0xef, 0xc2}; - uint8_t bytesprops8[] = {0x46, 0x38, 0x70, 0x47, 0x9e}; - uint8_t bytesprops9[] = {0x7e, 0xbf, 0xd8, 0x60, 0xc2, 0x7d, 0x3a, 0xf6}; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + uint8_t bytesprops0[] = {0xbe, 0x10, 0x1c, 0x86, 0x63, 0x8d, 0xff, 0xb5, 0x22, 0xf8, 0x7a, 0xce, 0x4e, 0x9, 0x40, + 0xa0, 0x7b, 0xc8, 0x5d, 0x16, 0x8c, 0xc, 0xc6, 0xe8, 0xb0, 0x3e, 0xfc, 0xf3, 0x9, 0xcb}; + uint8_t bytesprops2[] = {0x83, 0xee, 0x8a, 0xe1, 0xf, 0xcc, 0x72, 0xc8, 0x23, 0x16, 0x3f, 0xea, 0x26, + 0x1b, 0x67, 0x34, 0xb0, 0xd5, 0x33, 0xe3, 0x3b, 0x92, 0xe4, 0xd1, 0x6b, 0xf6}; + uint8_t bytesprops1[] = {0xe6, 0x49, 0xbb, 0x13, 0x58, 0xe1, 0xbe, 0x9c, 0x9c, 0x45, + 0xf9, 0x84, 0x12, 0xf4, 0x33, 0x76, 0x9e, 0x90, 0xb6, 0x46}; + uint8_t bytesprops3[] = {0xfe, 0xac, 0x8a, 0xe2, 0x22, 0x62, 0x66, 0x76, 0xb3, 0xdc, 0xa6}; + uint8_t bytesprops4[] = {0x54, 0x6c, 0x54, 0x55, 0x1a, 0x71, 0x5a, 0x55, 0xbb, 0x8, + 0x9c, 0xa0, 0x38, 0xe0, 0xf4, 0xfc, 0x18, 0xbe, 0x98}; + uint8_t bytesprops5[] = {0xf6, 0xa4, 0xa0, 0x7a, 0x5a}; + uint8_t bytesprops6[] = {0}; + uint8_t bytesprops8[] = {0x64, 0x35}; + uint8_t bytesprops7[] = {0xfd, 0x1e, 0x49, 0x81, 0x9e, 0xdf, 0x49, 0x54, 0x9c, 0xba, 0x12, 0x7e, 0xa1, + 0xa1, 0xc2, 0x2f, 0x82, 0xb3, 0xa8, 0xd5, 0x56, 0x58, 0xf7, 0x51, 0x59}; + uint8_t bytesprops10[] = {0xec, 0x64, 0xdb, 0x70, 0x4a, 0x25, 0x13, 0x67, 0x66, 0x31, 0xbd, 0xc4, + 0xa6, 0xe3, 0xe0, 0x15, 0x78, 0xf3, 0x24, 0x17, 0xc2, 0xa3, 0x93}; + uint8_t bytesprops9[] = {0x71, 0xcf, 0xad, 0xbc, 0xdd, 0xb7, 0xc2, 0xdf, 0x9b, 0xb5, 0xc1, 0x2f, 0x63, 0xf7, 0x61}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23243}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24913}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27215}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1767}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26111}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28561}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13192}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29184}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29191}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31897}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26301}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops1}, .v = {26, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29467}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops7}, .v = {2, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops9}, .v = {23, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9079}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 57}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 502, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30616, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27247 -// [("\137\230\141\ACK\169\178P\242\SUB\143Ml]\220\&1<\251\195\206\187\139$\167\174\\zW",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("<\235\&2\233\188SY\DC2}N",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS0}),("\169\156\DC4\199\SUBt\235!\GS\198\SUB\142i\208\aj\\\NAKG\a",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("h\252u[I\131\&8\238i\235/\165{\147\159\226/G\208\207npWu\ACKc\150@",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\132*T\ETB!\169\180\173\239t=",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS2}),("\184\198;\ETX\221\STX\202\227[\197q;6\189\n\169",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("x30\199\163\193",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("s\226\229\185N]\173-\176\199\183\201\219",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = True, _subQoS = -// QoS0}),("\228\134\195\198\239\232\245\153\ACKd.\130%$9D\237\231\158\SOH\160\242\151\170\\I",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0})] [PropCorrelationData -// "\247\167\151\238U\DEL\SYN\142\241(\198\136U\175Z\155\227\188`*\"t\237\137\222",PropRequestResponseInformation -// 222,PropSubscriptionIdentifierAvailable 126,PropContentType -// "\NAK\164O=h\238$\166",PropSubscriptionIdentifierAvailable 108,PropMessageExpiryInterval -// 31722,PropMessageExpiryInterval 12051,PropRequestResponseInformation 74,PropRetainAvailable -// 231,PropSharedSubscriptionAvailable 188,PropTopicAlias 4372,PropContentType -// "\130\144\SUB\236o:W\f\135\RSQ}\165",PropServerReference -// "0Q\241\EOT\192'\150u\219\171\242c\190\236\234\204\&0",PropTopicAlias 19724,PropMaximumPacketSize -// 17874,PropRequestResponseInformation 116,PropRetainAvailable 20,PropMaximumQoS 24,PropMaximumPacketSize -// 16124,PropAuthenticationData "\189\212\SI\182",PropReasonString -// "\233h\SI\133\ACK\253\232\156\184\228\164\ESC\n\STX\241\155U",PropUserProperty -// "4:l\200P\SUB\n\164\NUL7\132\172w\201\209BOE8\224\251\DC2\228\SI\FS\197\154" "\184\245l\232\178\fy[\128"] -TEST(Subscribe5QCTest, Encode7) { +// SubscribeRequest 27910 [("\146\183",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS2}),("\190\186\217w\248\160\225))",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\178\157\206\191\161S\255!{\198\145\131E2\133W2",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\181\210p\180\241\184\&6\233r\192\145\128\159Q1\210\199",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\DLE5#\237\150\213-\170\158\FS\165\166\EOTJ\249\144T\SOH\158`N\200\168B\EM",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropTopicAlias +// 16384,PropRequestResponseInformation 139,PropTopicAliasMaximum 1928,PropTopicAlias 30103,PropMaximumPacketSize +// 20035,PropAssignedClientIdentifier "l\ETB!k",PropReasonString "",PropSubscriptionIdentifierAvailable +// 81,PropSubscriptionIdentifier 19,PropMessageExpiryInterval 6072,PropSubscriptionIdentifierAvailable +// 15,PropAuthenticationMethod +// "\205\240\131\NAK@\225a\134\146\191\128\DC4\165\228\161'\157\130C\USb\NAKl\174\US",PropAssignedClientIdentifier +// "*O9\212p$\STX\219\129!^\130\168\173\136",PropContentType "1\186\178 +// &\163s\188^K\173\184\229\174\184K\172\US\246+2\192\151\133R\210\182\DC1",PropReasonString +// "\145E[\218\131\&3",PropResponseInformation +// "#2\198b\246Q\149x\178\149\US\216~\178\147\193\168\150n+\a\137\234",PropRetainAvailable 219] +TEST(Subscribe5QCTest, Encode11) { uint8_t pkt[] = { - 0x82, 0xfd, 0x2, 0x6a, 0x6f, 0xbb, 0x1, 0x9, 0x0, 0x19, 0xf7, 0xa7, 0x97, 0xee, 0x55, 0x7f, 0x16, 0x8e, 0xf1, - 0x28, 0xc6, 0x88, 0x55, 0xaf, 0x5a, 0x9b, 0xe3, 0xbc, 0x60, 0x2a, 0x22, 0x74, 0xed, 0x89, 0xde, 0x19, 0xde, 0x29, - 0x7e, 0x3, 0x0, 0x8, 0x15, 0xa4, 0x4f, 0x3d, 0x68, 0xee, 0x24, 0xa6, 0x29, 0x6c, 0x2, 0x0, 0x0, 0x7b, 0xea, - 0x2, 0x0, 0x0, 0x2f, 0x13, 0x19, 0x4a, 0x25, 0xe7, 0x2a, 0xbc, 0x23, 0x11, 0x14, 0x3, 0x0, 0xd, 0x82, 0x90, - 0x1a, 0xec, 0x6f, 0x3a, 0x57, 0xc, 0x87, 0x1e, 0x51, 0x7d, 0xa5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+ 0x4f, 0x39, 0xd4, 0x70, 0x24, 0x2, 0xdb, 0x81, 0x21, 0x5e, 0x82, 0xa8, 0xad, 0x88, 0x3, 0x0, 0x1c, 0x31, 0xba, + 0xb2, 0x20, 0x26, 0xa3, 0x73, 0xbc, 0x5e, 0x4b, 0xad, 0xb8, 0xe5, 0xae, 0xb8, 0x4b, 0xac, 0x1f, 0xf6, 0x2b, 0x32, + 0xc0, 0x97, 0x85, 0x52, 0xd2, 0xb6, 0x11, 0x1f, 0x0, 0x6, 0x91, 0x45, 0x5b, 0xda, 0x83, 0x33, 0x1a, 0x0, 0x17, + 0x23, 0x32, 0xc6, 0x62, 0xf6, 0x51, 0x95, 0x78, 0xb2, 0x95, 0x1f, 0xd8, 0x7e, 0xb2, 0x93, 0xc1, 0xa8, 0x96, 0x6e, + 0x2b, 0x7, 0x89, 0xea, 0x25, 0xdb, 0x0, 0x2, 0x92, 0xb7, 0x2a, 0x0, 0x9, 0xbe, 0xba, 0xd9, 0x77, 0xf8, 0xa0, + 0xe1, 0x29, 0x29, 0x16, 0x0, 0x11, 0xb2, 0x9d, 0xce, 0xbf, 0xa1, 0x53, 0xff, 0x21, 0x7b, 0xc6, 0x91, 0x83, 0x45, + 0x32, 0x85, 0x57, 0x32, 0x6, 0x0, 0x11, 0xb5, 0xd2, 0x70, 0xb4, 0xf1, 0xb8, 0x36, 0xe9, 0x72, 0xc0, 0x91, 0x80, + 0x9f, 0x51, 0x31, 0xd2, 0xc7, 0xe, 0x0, 0x19, 0x10, 0x35, 0x23, 0xed, 0x96, 0xd5, 0x2d, 0xaa, 0x9e, 0x1c, 0xa5, + 0xa6, 0x4, 0x4a, 0xf9, 0x90, 0x54, 0x1, 0x9e, 0x60, 0x4e, 0xc8, 0xa8, 0x42, 0x19, 0x1d}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x89, 0xe6, 0x8d, 0x6, 0xa9, 0xb2, 0x50, 0xf2, 0x1a, 0x8f, 0x4d, 0x6c, 0x5d, 0xdc, - 0x31, 0x3c, 0xfb, 0xc3, 0xce, 0xbb, 0x8b, 0x24, 0xa7, 0xae, 0x5c, 0x7a, 0x57}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x92, 0xb7}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3c, 0xeb, 0x32, 0xe9, 0xbc, 0x53, 0x59, 0x12, 0x7d, 0x4e}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbe, 0xba, 0xd9, 0x77, 0xf8, 0xa0, 0xe1, 0x29, 0x29}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa9, 0x9c, 0x14, 0xc7, 0x1a, 0x74, 0xeb, 0x21, 0x1d, 0xc6, - 0x1a, 0x8e, 0x69, 0xd0, 0x7, 0x6a, 0x5c, 0x15, 0x47, 0x7}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb2, 0x9d, 0xce, 0xbf, 0xa1, 0x53, 0xff, 0x21, 0x7b, + 0xc6, 0x91, 0x83, 0x45, 0x32, 0x85, 0x57, 0x32}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x68, 0xfc, 0x75, 0x5b, 0x49, 0x83, 0x38, 0xee, 0x69, 0xeb, - 0x2f, 0xa5, 0x7b, 0x93, 0x9f, 0xe2, 0x2f, 0x47, 0xd0, 0xcf, - 0x6e, 0x70, 0x57, 0x75, 0x6, 0x63, 0x96, 0x40}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xb5, 0xd2, 0x70, 0xb4, 0xf1, 0xb8, 0x36, 0xe9, 0x72, + 0xc0, 0x91, 0x80, 0x9f, 0x51, 0x31, 0xd2, 0xc7}; + lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x10, 0x35, 0x23, 0xed, 0x96, 0xd5, 0x2d, 0xaa, 0x9e, 0x1c, 0xa5, 0xa6, 0x4, + 0x4a, 0xf9, 0x90, 0x54, 0x1, 0x9e, 0x60, 0x4e, 0xc8, 0xa8, 0x42, 0x19}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x84, 0x2a, 0x54, 0x17, 0x21, 0xa9, 0xb4, 0xad, 0xef, 0x74, 0x3d}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb8, 0xc6, 0x3b, 0x3, 0xdd, 0x2, 0xca, 0xe3, - 0x5b, 0xc5, 0x71, 0x3b, 0x36, 0xbd, 0xa, 0xa9}; - lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x78, 0x33, 0x30, 0xc7, 0xa3, 0xc1}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x73, 0xe2, 0xe5, 0xb9, 0x4e, 0x5d, 0xad, 0x2d, 0xb0, 0xc7, 0xb7, 0xc9, 0xdb}; - lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe4, 0x86, 0xc3, 0xc6, 0xef, 0xe8, 0xf5, 0x99, 0x6, 0x64, 0x2e, 0x82, 0x25, - 0x24, 0x39, 0x44, 0xed, 0xe7, 0x9e, 0x1, 0xa0, 0xf2, 0x97, 0xaa, 0x5c, 0x49}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0}; - lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; + lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + uint8_t bytesprops0[] = {0x6c, 0x17, 0x21, 0x6b}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0xcd, 0xf0, 0x83, 0x15, 0x40, 0xe1, 0x61, 0x86, 0x92, 0xbf, 0x80, 0x14, 0xa5, + 0xe4, 0xa1, 0x27, 0x9d, 0x82, 0x43, 0x1f, 0x62, 0x15, 0x6c, 0xae, 0x1f}; + uint8_t bytesprops3[] = {0x2a, 0x4f, 0x39, 0xd4, 0x70, 0x24, 0x2, 0xdb, 0x81, 0x21, 0x5e, 0x82, 0xa8, 0xad, 0x88}; + uint8_t bytesprops4[] = {0x31, 0xba, 0xb2, 0x20, 0x26, 0xa3, 0x73, 0xbc, 0x5e, 0x4b, 0xad, 0xb8, 0xe5, 0xae, + 0xb8, 0x4b, 0xac, 0x1f, 0xf6, 0x2b, 0x32, 0xc0, 0x97, 0x85, 0x52, 0xd2, 0xb6, 0x11}; + uint8_t bytesprops5[] = {0x91, 0x45, 0x5b, 0xda, 0x83, 0x33}; + uint8_t bytesprops6[] = {0x23, 0x32, 0xc6, 0x62, 0xf6, 0x51, 0x95, 0x78, 0xb2, 0x95, 0x1f, 0xd8, + 0x7e, 0xb2, 0x93, 0xc1, 0xa8, 0x96, 0x6e, 0x2b, 0x7, 0x89, 0xea}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16384}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1928}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30103}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20035}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6072}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, + }; + + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27910, 5, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 31365 [("\241\182\221\CAN\nn8\n\144\151\&9\198\NUL<>\212",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),(".6V",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("N\199\249\DC2\184\STX\149\167\166je\254\207\152\130\210\151\ETB\144\RS\162\130\128\207I\DLE~\162\244<",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\162\199}\255V\131",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = +// True, _subQoS = QoS1}),("\215\SOM\234!\158\&7\167\225\183\250\173",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("&\v\205\128\233\230\187\129\181\128S\NUL\222\253\185$*\180i\183",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\135z\215D\NAK\225\197",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("v\236\188\199\GS\206N.\208J\187\188q~\n\173.\199\154\SIQ\215\&7",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("d\128\&5B\227\&7\DC3\221\200",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS0})] [PropResponseInformation "\150\142\";\245\DC4",PropAuthenticationMethod +// "\142\197%iY\t\156\255V\203\167\DLEA\SYN5\159Rb.`L|\SO%\GS\157=\SYN",PropReasonString +// "}\253\139\EM\150\229\RS",PropResponseTopic "=`\216\230\156\148\240\148\223\188bA\161z\144\196\143",PropResponseTopic +// "5\229\214\SOt\234)\r\129\181\200\r\229\209\DLE\213\238\146\ETX\177\131",PropCorrelationData "",PropTopicAliasMaximum +// 20281,PropAuthenticationMethod "\203\204k\"\168\132M\194\133\157\b@\155\&9"] +TEST(Subscribe5QCTest, Encode12) { + uint8_t pkt[] = { + 0x82, 0x91, 0x2, 0x7a, 0x85, 0x75, 0x1a, 0x0, 0x6, 0x96, 0x8e, 0x22, 0x3b, 0xf5, 0x14, 0x15, 0x0, 0x1c, 0x8e, + 0xc5, 0x25, 0x69, 0x59, 0x9, 0x9c, 0xff, 0x56, 0xcb, 0xa7, 0x10, 0x41, 0x16, 0x35, 0x9f, 0x52, 0x62, 0x2e, 0x60, + 0x4c, 0x7c, 0xe, 0x25, 0x1d, 0x9d, 0x3d, 0x16, 0x1f, 0x0, 0x7, 0x7d, 0xfd, 0x8b, 0x19, 0x96, 0xe5, 0x1e, 0x8, + 0x0, 0x11, 0x3d, 0x60, 0xd8, 0xe6, 0x9c, 0x94, 0xf0, 0x94, 0xdf, 0xbc, 0x62, 0x41, 0xa1, 0x7a, 0x90, 0xc4, 0x8f, + 0x8, 0x0, 0x15, 0x35, 0xe5, 0xd6, 0xe, 0x74, 0xea, 0x29, 0xd, 0x81, 0xb5, 0xc8, 0xd, 0xe5, 0xd1, 0x10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= {0}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xf1, 0xb6, 0xdd, 0x18, 0xa, 0x6e, 0x38, 0xa, + 0x90, 0x97, 0x39, 0xc6, 0x0, 0x3c, 0x3e, 0xd4}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2e, 0x36, 0x56}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4e, 0xc7, 0xf9, 0x12, 0xb8, 0x2, 0x95, 0xa7, 0xa6, 0x6a, + 0x65, 0xfe, 0xcf, 0x98, 0x82, 0xd2, 0x97, 0x17, 0x90, 0x1e, + 0xa2, 0x82, 0x80, 0xcf, 0x49, 0x10, 0x7e, 0xa2, 0xf4, 0x3c}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa2, 0xc7, 0x7d, 0xff, 0x56, 0x83}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd7, 0xe, 0x4d, 0xea, 0x21, 0x9e, 0x37, 0xa7, 0xe1, 0xb7, 0xfa, 0xad}; + lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x26, 0xb, 0xcd, 0x80, 0xe9, 0xe6, 0xbb, 0x81, 0xb5, 0x80, + 0x53, 0x0, 0xde, 0xfd, 0xb9, 0x24, 0x2a, 0xb4, 0x69, 0xb7}; + lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x87, 0x7a, 0xd7, 0x44, 0x15, 0xe1, 0xc5}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x76, 0xec, 0xbc, 0xc7, 0x1d, 0xce, 0x4e, 0x2e, 0xd0, 0x4a, 0xbb, 0xbc, + 0x71, 0x7e, 0xa, 0xad, 0x2e, 0xc7, 0x9a, 0xf, 0x51, 0xd7, 0x37}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x64, 0x80, 0x35, 0x42, 0xe3, 0x37, 0x13, 0xdd, 0xc8}; + lwmqtt_string_t topic_filter_s8 = {9, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; + sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; + sub_opts[7].no_local = true; sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; + sub_opts[8].retain_as_published = true; sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[10].retain_as_published = true; - sub_opts[10].no_local = true; - uint8_t bytesprops0[] = {0xf7, 0xa7, 0x97, 0xee, 0x55, 0x7f, 0x16, 0x8e, 0xf1, 0x28, 0xc6, 0x88, 0x55, - 0xaf, 0x5a, 0x9b, 0xe3, 0xbc, 0x60, 0x2a, 0x22, 0x74, 0xed, 0x89, 0xde}; - uint8_t bytesprops1[] = {0x15, 0xa4, 0x4f, 0x3d, 0x68, 0xee, 0x24, 0xa6}; - uint8_t bytesprops2[] = {0x82, 0x90, 0x1a, 0xec, 0x6f, 0x3a, 0x57, 0xc, 0x87, 0x1e, 0x51, 0x7d, 0xa5}; - uint8_t bytesprops3[] = {0x30, 0x51, 0xf1, 0x4, 0xc0, 0x27, 0x96, 0x75, 0xdb, - 0xab, 0xf2, 0x63, 0xbe, 0xec, 0xea, 0xcc, 0x30}; - uint8_t bytesprops4[] = {0xbd, 0xd4, 0xf, 0xb6}; - uint8_t bytesprops5[] = {0xe9, 0x68, 0xf, 0x85, 0x6, 0xfd, 0xe8, 0x9c, 0xb8, - 0xe4, 0xa4, 0x1b, 0xa, 0x2, 0xf1, 0x9b, 0x55}; - uint8_t bytesprops7[] = {0xb8, 0xf5, 0x6c, 0xe8, 0xb2, 0xc, 0x79, 0x5b, 0x80}; - uint8_t bytesprops6[] = {0x34, 0x3a, 0x6c, 0xc8, 0x50, 0x1a, 0xa, 0xa4, 0x0, 0x37, 0x84, 0xac, 0x77, 0xc9, - 0xd1, 0x42, 0x4f, 0x45, 0x38, 0xe0, 0xfb, 0x12, 0xe4, 0xf, 0x1c, 0xc5, 0x9a}; + uint8_t bytesprops0[] = {0x96, 0x8e, 0x22, 0x3b, 0xf5, 0x14}; + uint8_t bytesprops1[] = {0x8e, 0xc5, 0x25, 0x69, 0x59, 0x9, 0x9c, 0xff, 0x56, 0xcb, 0xa7, 0x10, 0x41, 0x16, + 0x35, 0x9f, 0x52, 0x62, 0x2e, 0x60, 0x4c, 0x7c, 0xe, 0x25, 0x1d, 0x9d, 0x3d, 0x16}; + uint8_t bytesprops2[] = {0x7d, 0xfd, 0x8b, 0x19, 0x96, 0xe5, 0x1e}; + uint8_t bytesprops3[] = {0x3d, 0x60, 0xd8, 0xe6, 0x9c, 0x94, 0xf0, 0x94, 0xdf, + 0xbc, 0x62, 0x41, 0xa1, 0x7a, 0x90, 0xc4, 0x8f}; + uint8_t bytesprops4[] = {0x35, 0xe5, 0xd6, 0xe, 0x74, 0xea, 0x29, 0xd, 0x81, 0xb5, 0xc8, + 0xd, 0xe5, 0xd1, 0x10, 0xd5, 0xee, 0x92, 0x3, 0xb1, 0x83}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0xcb, 0xcc, 0x6b, 0x22, 0xa8, 0x84, 0x4d, 0xc2, 0x85, 0x9d, 0x8, 0x40, 0x9b, 0x39}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31722}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12051}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4372}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19724}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17874}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16124}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops6}, .v = {9, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20281}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27247, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31365, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15611 [("\NUL\212p\201h\br'2ko\162\SYN\242U\173Sp\182\184",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropWillDelayInterval -// 16059,PropReceiveMaximum 18847,PropTopicAlias 31233,PropMessageExpiryInterval 17329,PropAuthenticationMethod -// "\228\166\137|\201X\211\ETX\ETBR\SO\247\fL\n\187\EOT\td\183\155u\146O\196\194\194j",PropPayloadFormatIndicator -// 20,PropWillDelayInterval 14778,PropServerReference "z\ETX\168\180\ETX-\244' \143",PropMessageExpiryInterval -// 23767,PropTopicAliasMaximum 583,PropMessageExpiryInterval 13968,PropRequestResponseInformation -// 60,PropSessionExpiryInterval 26412,PropTopicAliasMaximum 7853,PropSubscriptionIdentifierAvailable -// 16,PropTopicAliasMaximum 3303,PropPayloadFormatIndicator 55,PropMaximumQoS 160,PropUserProperty "K\SYNA\163\NUL\221U" -// "\183\v$r\161\250 f\167\ESC\215\136\160\175",PropTopicAlias 13301,PropRequestProblemInformation 216] -TEST(Subscribe5QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x9d, 0x1, 0x3c, 0xfb, 0x82, 0x1, 0x18, 0x0, 0x0, 0x3e, 0xbb, 0x21, 0x49, 0x9f, 0x23, - 0x7a, 0x1, 0x2, 0x0, 0x0, 0x43, 0xb1, 0x15, 0x0, 0x1c, 0xe4, 0xa6, 0x89, 0x7c, 0xc9, 0x58, - 0xd3, 0x3, 0x17, 0x52, 0xe, 0xf7, 0xc, 0x4c, 0xa, 0xbb, 0x4, 0x9, 0x64, 0xb7, 0x9b, 0x75, - 0x92, 0x4f, 0xc4, 0xc2, 0xc2, 0x6a, 0x1, 0x14, 0x18, 0x0, 0x0, 0x39, 0xba, 0x1c, 0x0, 0xa, - 0x7a, 0x3, 0xa8, 0xb4, 0x3, 0x2d, 0xf4, 0x27, 0x20, 0x8f, 0x2, 0x0, 0x0, 0x5c, 0xd7, 0x22, - 0x2, 0x47, 0x2, 0x0, 0x0, 0x36, 0x90, 0x19, 0x3c, 0x11, 0x0, 0x0, 0x67, 0x2c, 0x22, 0x1e, - 0xad, 0x29, 0x10, 0x22, 0xc, 0xe7, 0x1, 0x37, 0x24, 0xa0, 0x26, 0x0, 0x7, 0x4b, 0x16, 0x41, - 0xa3, 0x0, 0xdd, 0x55, 0x0, 0xe, 0xb7, 0xb, 0x24, 0x72, 0xa1, 0xfa, 0x20, 0x66, 0xa7, 0x1b, - 0xd7, 0x88, 0xa0, 0xaf, 0x23, 0x33, 0xf5, 0x17, 0xd8, 0x0, 0x14, 0x0, 0xd4, 0x70, 0xc9, 0x68, - 0x8, 0x72, 0x27, 0x32, 0x6b, 0x6f, 0xa2, 0x16, 0xf2, 0x55, 0xad, 0x53, 0x70, 0xb6, 0xb8, 0x4}; +// SubscribeRequest 3963 [("&\249+\165\255",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS2})] [PropTopicAliasMaximum 15126,PropMessageExpiryInterval 4277,PropTopicAlias +// 4146,PropRequestProblemInformation 97,PropMaximumPacketSize 4331,PropSharedSubscriptionAvailable +// 226,PropRetainAvailable 242,PropWillDelayInterval 30502,PropServerReference "\132\189p\225q\153rV\203\130%"] +TEST(Subscribe5QCTest, Encode13) { + uint8_t pkt[] = {0x82, 0x34, 0xf, 0x7b, 0x29, 0x22, 0x3b, 0x16, 0x2, 0x0, 0x0, 0x10, 0xb5, 0x23, + 0x10, 0x32, 0x17, 0x61, 0x27, 0x0, 0x0, 0x10, 0xeb, 0x2a, 0xe2, 0x25, 0xf2, 0x18, + 0x0, 0x0, 0x77, 0x26, 0x1c, 0x0, 0xb, 0x84, 0xbd, 0x70, 0xe1, 0x71, 0x99, 0x72, + 0x56, 0xcb, 0x82, 0x25, 0x0, 0x5, 0x26, 0xf9, 0x2b, 0xa5, 0xff, 0x16}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x0, 0xd4, 0x70, 0xc9, 0x68, 0x8, 0x72, 0x27, 0x32, 0x6b, - 0x6f, 0xa2, 0x16, 0xf2, 0x55, 0xad, 0x53, 0x70, 0xb6, 0xb8}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x26, 0xf9, 0x2b, 0xa5, 0xff}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - uint8_t bytesprops0[] = {0xe4, 0xa6, 0x89, 0x7c, 0xc9, 0x58, 0xd3, 0x3, 0x17, 0x52, 0xe, 0xf7, 0xc, 0x4c, - 0xa, 0xbb, 0x4, 0x9, 0x64, 0xb7, 0x9b, 0x75, 0x92, 0x4f, 0xc4, 0xc2, 0xc2, 0x6a}; - uint8_t bytesprops1[] = {0x7a, 0x3, 0xa8, 0xb4, 0x3, 0x2d, 0xf4, 0x27, 0x20, 0x8f}; - uint8_t bytesprops3[] = {0xb7, 0xb, 0x24, 0x72, 0xa1, 0xfa, 0x20, 0x66, 0xa7, 0x1b, 0xd7, 0x88, 0xa0, 0xaf}; - uint8_t bytesprops2[] = {0x4b, 0x16, 0x41, 0xa3, 0x0, 0xdd, 0x55}; + uint8_t bytesprops0[] = {0x84, 0xbd, 0x70, 0xe1, 0x71, 0x99, 0x72, 0x56, 0xcb, 0x82, 0x25}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16059}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18847}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31233}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17329}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14778}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23767}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 583}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13968}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26412}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7853}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3303}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops2}, .v = {14, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13301}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15126}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4277}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4146}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4331}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30502}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15611, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3963, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 16791 [("\\\ACK\129B1\149Y/2\178vx\RSo",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\157\170\249\222\&8\248\181\190\212q\151\133\186\245\171\223g1)U\206\a\135",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("y\245\244\225K\177[\153B\179@\161\193",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished -// = True, _noLocal = True, _subQoS = QoS2}),("\146\247\211\182H z\bK\191\RS\194V\134\&8$\221;8",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\167\159W\185-u;",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = -// False, _subQoS = QoS0}),("X\246\247\218G\162mZ(\DEL\EM\172",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\152X9\166\177\RS\226\222\212\128",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\236\NAK\169\245",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("@I\210\CAN\210\EM\200\RS\186\ETB\235\180$\182\167\155\138\135>'\246",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] -// [PropSubscriptionIdentifier 30,PropTopicAliasMaximum 28275,PropSubscriptionIdentifierAvailable -// 70,PropSharedSubscriptionAvailable 178,PropTopicAlias 18035,PropMessageExpiryInterval 13889,PropMaximumPacketSize -// 19219,PropReceiveMaximum 11664,PropPayloadFormatIndicator 124,PropAuthenticationData -// "\226\129.\DC2R\ACK\238a\205\DEL\163\STX\182\SYNJK",PropUserProperty "{s\129m\228\218\210\192#zl" -// "\186\138\139r'\199\228\164$=\SYN",PropMaximumPacketSize 483,PropRequestProblemInformation 66] -TEST(Subscribe5QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0xe9, 0x1, 0x41, 0x97, 0x50, 0xb, 0x1e, 0x22, 0x6e, 0x73, 0x29, 0x46, 0x2a, 0xb2,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4, 0x80, - 0x1e, 0x0, 0x4, 0xec, 0x15, 0xa9, 0xf5, 0x0, 0x0, 0x15, 0x40, 0x49, 0xd2, 0x18, 0xd2, 0x19, 0xc8, - 0x1e, 0xba, 0x17, 0xeb, 0xb4, 0x24, 0xb6, 0xa7, 0x9b, 0x8a, 0x87, 0x3e, 0x27, 0xf6, 0x24}; +// SubscribeRequest 27481 [("\173\187\212\&85\132\164-<\f",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("j\187\191\158GB4 +// \150\146\235\244\140\&1\188\t\220\225\SI+O\165\163\DLE'\SI\226\221\181\254",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\210\&5",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("a\169{+\204\189x\GS{`\\\195",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("Q\\\225\194\n\180\179d|\208<\202R,\183\137\RSh",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("^\135\131R\219\\\129W@5`^\130\225?\243\200\157",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("Z\177\195\252s\ESCh\253 \b\f6\DC4",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\166\138\DC3\154:7\189]-\201p\160\223*R,\224",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("6\EM\165\136\194\149\NULb\236I\138\FS\207\&5qi\206\228\169i\r\252\132R\237",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe5QCTest, Enc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, 0xed, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x5c, 0x6, 0x81, 0x42, 0x31, 0x95, 0x59, 0x2f, 0x32, 0xb2, 0x76, 0x78, 0x1e, 0x6f}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xad, 0xbb, 0xd4, 0x38, 0x35, 0x84, 0xa4, 0x2d, 0x3c, 0xc}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9d, 0xaa, 0xf9, 0xde, 0x38, 0xf8, 0xb5, 0xbe, 0xd4, 0x71, 0x97, 0x85, - 0xba, 0xf5, 0xab, 0xdf, 0x67, 0x31, 0x29, 0x55, 0xce, 0x7, 0x87}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6a, 0xbb, 0xbf, 0x9e, 0x47, 0x42, 0x34, 0x20, 0x96, 0x92, + 0xeb, 0xf4, 0x8c, 0x31, 0xbc, 0x9, 0xdc, 0xe1, 0xf, 0x2b, + 0x4f, 0xa5, 0xa3, 0x10, 0x27, 0xf, 0xe2, 0xdd, 0xb5, 0xfe}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x79, 0xf5, 0xf4, 0xe1, 0x4b, 0xb1, 0x5b, 0x99, 0x42, 0xb3, 0x40, 0xa1, 0xc1}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd2, 0x35}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x92, 0xf7, 0xd3, 0xb6, 0x48, 0x20, 0x7a, 0x8, 0x4b, 0xbf, - 0x1e, 0xc2, 0x56, 0x86, 0x38, 0x24, 0xdd, 0x3b, 0x38}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x61, 0xa9, 0x7b, 0x2b, 0xcc, 0xbd, 0x78, 0x1d, 0x7b, 0x60, 0x5c, 0xc3}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa7, 0x9f, 0x57, 0xb9, 0x2d, 0x75, 0x3b}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x51, 0x5c, 0xe1, 0x3c, 0x54, 0x70, 0xcc, 0x3c, 0x3e, 0xc2, 0xa, 0xb4, + 0xb3, 0x64, 0x7c, 0xd0, 0x3c, 0xca, 0x52, 0x2c, 0xb7, 0x89, 0x1e, 0x68}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x58, 0xf6, 0xf7, 0xda, 0x47, 0xa2, 0x6d, 0x5a, 0x28, 0x7f, 0x19, 0xac}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x5e, 0x87, 0x83, 0x52, 0xdb, 0x5c, 0x81, 0x57, 0x40, + 0x35, 0x60, 0x5e, 0x82, 0xe1, 0x3f, 0xf3, 0xc8, 0x9d}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x98, 0x58, 0x39, 0xa6, 0xb1, 0x1e, 0xe2, 0xde, 0xd4, 0x80}; - lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x5a, 0xb1, 0xc3, 0xfc, 0x73, 0x1b, 0x68, 0xfd, 0x20, 0x8, 0xc, 0x36, 0x14}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xec, 0x15, 0xa9, 0xf5}; - lwmqtt_string_t topic_filter_s7 = {4, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xa6, 0x8a, 0x13, 0x9a, 0x3a, 0x37, 0xbd, 0x5d, 0x2d, + 0xc9, 0x70, 0xa0, 0xdf, 0x2a, 0x52, 0x2c, 0xe0}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x40, 0x49, 0xd2, 0x18, 0xd2, 0x19, 0xc8, 0x1e, 0xba, 0x17, 0xeb, - 0xb4, 0x24, 0xb6, 0xa7, 0x9b, 0x8a, 0x87, 0x3e, 0x27, 0xf6}; - lwmqtt_string_t topic_filter_s8 = {21, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x36, 0x19, 0xa5, 0x88, 0xc2, 0x95, 0x0, 0x62, 0xec, 0x49, 0x8a, 0x1c, 0xcf, + 0x35, 0x71, 0x69, 0xce, 0xe4, 0xa9, 0x69, 0xd, 0xfc, 0x84, 0x52, 0xed}; + lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = true; sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; + sub_opts[7].retain_as_published = true; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; - uint8_t bytesprops0[] = {0xe2, 0x81, 0x2e, 0x12, 0x52, 0x6, 0xee, 0x61, - 0xcd, 0x7f, 0xa3, 0x2, 0xb6, 0x16, 0x4a, 0x4b}; - uint8_t bytesprops2[] = {0xba, 0x8a, 0x8b, 0x72, 0x27, 0xc7, 0xe4, 0xa4, 0x24, 0x3d, 0x16}; - uint8_t bytesprops1[] = {0x7b, 0x73, 0x81, 0x6d, 0xe4, 0xda, 0xd2, 0xc0, 0x23, 0x7a, 0x6c}; + sub_opts[8].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27481, 9, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 32387 +// [("\205Yv\244\133\240o\244\240\227\&6\170r\201\GS\177\160\165\236\219\187K\FS\205\151\152",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\164\170z",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, +// _subQoS = QoS1})] [PropContentType +// "\180\152w\228\156\212\184=\145}\222\233e\NAK\147\246\178;\EOT\v>ADt\176\130\244\151g\166",PropRequestResponseInformation +// 80,PropSharedSubscriptionAvailable 77,PropMessageExpiryInterval 13371,PropTopicAliasMaximum +// 31269,PropResponseInformation "\\\248\"\136|\205\SOH\199\t\EM,\f\130\150\145\NUL\209\197[Or",PropServerKeepAlive +// 27813,PropMessageExpiryInterval 4055,PropResponseInformation "\206\154\235\a",PropMaximumPacketSize +// 22528,PropAuthenticationData "\249\178\159\175\&8W\220ZP\135\135\145\ESC\154\180qm\215",PropRequestProblemInformation +// 145,PropAuthenticationData "",PropWildcardSubscriptionAvailable 69,PropSubscriptionIdentifier +// 16,PropResponseInformation "\187\139\137",PropContentType "\DEL\240\137",PropAssignedClientIdentifier +// "\246;O\145\161\200\SOY6\186\246\155\v\US0\229Z&\131\202\220\175v\142\132c\ESC\220\167&",PropSessionExpiryInterval +// 27386,PropWildcardSubscriptionAvailable 84,PropReceiveMaximum 20115,PropMaximumPacketSize +// 27201,PropWildcardSubscriptionAvailable 252,PropSessionExpiryInterval 21491,PropRetainAvailable +// 238,PropMessageExpiryInterval 11536,PropWildcardSubscriptionAvailable 92,PropRequestResponseInformation +// 103,PropAuthenticationData +// "\198\183\ACKLl\180H\200\194\209\200)\252\149!\195\199\156\226\191x\218{\250\SOH\235\254\226\158"] +TEST(Subscribe5QCTest, Encode15) { + uint8_t pkt[] = {0x82, 0x8c, 0x2, 0x7e, 0x83, 0xe5, 0x1, 0x3, 0x0, 0x1e, 0xb4, 0x98, 0x77, 0xe4, 0x9c, 0xd4, 0xb8, + 0x3d, 0x91, 0x7d, 0xde, 0xe9, 0x65, 0x15, 0x93, 0xf6, 0xb2, 0x3b, 0x4, 0xb, 0x3e, 0x41, 0x44, 0x74, + 0xb0, 0x82, 0xf4, 0x97, 0x67, 0xa6, 0x19, 0x50, 0x2a, 0x4d, 0x2, 0x0, 0x0, 0x34, 0x3b, 0x22, 0x7a, + 0x25, 0x1a, 0x0, 0x15, 0x5c, 0xf8, 0x22, 0x88, 0x7c, 0xcd, 0x1, 0xc7, 0x9, 0x19, 0x2c, 0xc, 0x82, + 0x96, 0x91, 0x0, 0xd1, 0xc5, 0x5b, 0x4f, 0x72, 0x13, 0x6c, 0xa5, 0x2, 0x0, 0x0, 0xf, 0xd7, 0x1a, + 0x0, 0x4, 0xce, 0x9a, 0xeb, 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0}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xcd, 0x59, 0x76, 0xf4, 0x85, 0xf0, 0x6f, 0xf4, 0xf0, 0xe3, 0x36, 0xaa, 0x72, + 0xc9, 0x1d, 0xb1, 0xa0, 0xa5, 0xec, 0xdb, 0xbb, 0x4b, 0x1c, 0xcd, 0x97, 0x98}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa4, 0xaa, 0x7a}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + uint8_t bytesprops0[] = {0xb4, 0x98, 0x77, 0xe4, 0x9c, 0xd4, 0xb8, 0x3d, 0x91, 0x7d, 0xde, 0xe9, 0x65, 0x15, 0x93, + 0xf6, 0xb2, 0x3b, 0x4, 0xb, 0x3e, 0x41, 0x44, 0x74, 0xb0, 0x82, 0xf4, 0x97, 0x67, 0xa6}; + uint8_t bytesprops1[] = {0x5c, 0xf8, 0x22, 0x88, 0x7c, 0xcd, 0x1, 0xc7, 0x9, 0x19, 0x2c, + 0xc, 0x82, 0x96, 0x91, 0x0, 0xd1, 0xc5, 0x5b, 0x4f, 0x72}; + uint8_t bytesprops2[] = {0xce, 0x9a, 0xeb, 0x7}; + uint8_t bytesprops3[] = {0xf9, 0xb2, 0x9f, 0xaf, 0x38, 0x57, 0xdc, 0x5a, 0x50, + 0x87, 0x87, 0x91, 0x1b, 0x9a, 0xb4, 0x71, 0x6d, 0xd7}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0xbb, 0x8b, 0x89}; + uint8_t bytesprops6[] = {0x7f, 0xf0, 0x89}; + uint8_t bytesprops7[] = {0xf6, 0x3b, 0x4f, 0x91, 0xa1, 0xc8, 0xe, 0x59, 0x36, 0xba, 0xf6, 0x9b, 0xb, 0x1f, 0x30, + 0xe5, 0x5a, 0x26, 0x83, 0xca, 0xdc, 0xaf, 0x76, 0x8e, 0x84, 0x63, 0x1b, 0xdc, 0xa7, 0x26}; + uint8_t bytesprops8[] = {0xc6, 0xb7, 0x6, 0x4c, 0x6c, 0xb4, 0x48, 0xc8, 0xc2, 0xd1, 0xc8, 0x29, 0xfc, 0x95, 0x21, + 0xc3, 0xc7, 0x9c, 0xe2, 0xbf, 0x78, 0xda, 0x7b, 0xfa, 0x1, 0xeb, 0xfe, 0xe2, 0x9e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28275}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18035}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13889}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19219}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11664}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 483}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13371}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31269}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27813}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4055}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22528}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27386}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20115}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27201}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21491}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11536}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16791, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32387, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26959 [("O\ESCB(\149\146o\177\249\238&\152\222\148\225\208k<",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\163\ACK\208\ETX}\235\ESC\230\193\202s",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\140>8\177\CAN\US\187w\173\n~\"",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("AdT[\254[\152\249\SUBhe%e\185",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS2}),("\201\230\EM\GS4\DC4\233BO]\165",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\245\148@\246iy\SUB"] +TEST(Subscribe5QCTest, Encode16) { uint8_t pkt[] = { - 0x82, 0xb4, 0x2, 0x69, 0x4f, 0xcf, 0x1, 0x2, 0x0, 0x0, 0x54, 0x11, 0x27, 0x0, 0x0, 0x4f, 0x8, 0x29, 0xc8, - 0x2, 0x0, 0x0, 0xb, 0xd3, 0x15, 0x0, 0x14, 0x85, 0x5f, 0xe1, 0x9e, 0xc5, 0x80, 0x43, 0xc5, 0x15, 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0xa4, 0x8a, 0xeb, 0x56, 0x57, 0xf2, 0xf2, 0x7, 0x86, 0xf3, 0xa8, 0xd7, 0x74, 0x51, 0x4b, 0x10, 0xb3, 0xca, 0xcf, + 0xfa, 0x41, 0x19, 0xe2, 0xae, 0x5d, 0x7, 0x12, 0x0, 0xc, 0x21, 0x57, 0xb2, 0x8b, 0x27, 0x74, 0xca, 0xa6, 0x4b, + 0xd, 0xdf, 0x97, 0x2a, 0x0, 0x6, 0xb4, 0xef, 0x8b, 0x2, 0x0, 0x64, 0x29, 0x0, 0xa, 0x85, 0xeb, 0x58, 0x33, + 0xe3, 0x86, 0xf8, 0xec, 0xf8, 0xe7, 0xc, 0x0, 0x3, 0xaa, 0x99, 0xe2, 0x25}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x4f, 0x1b, 0x42, 0x28, 0x95, 0x92, 0x6f, 0xb1, 0xf9, - 0xee, 0x26, 0x98, 0xde, 0x94, 0xe1, 0xd0, 0x6b, 0x3c}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xf4, 0x73, 0x61, 0x76, 0x4e, 0xed, 0x39, 0x17, 0x1a, 0xef, 0x43, + 0x18, 0xb8, 0x61, 0x9d, 0x62, 0x0, 0x97, 0x75, 0x8e, 0xe6, 0xd}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa3, 0x6, 0xd0, 0x3, 0x7d, 0xeb, 0x1b, 0xe6, 0xc1, 0xca, 0x73}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x44, 0x99, 0x12, 0x1}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8c, 0x3e, 0x38, 0xb1, 0x18, 0x1f, 0xbb, 0x77, 0xad, 0xa, 0x7e, 0x22}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x16, 0x8b, 0xc0, 0x17, 0xcd, 0x66, 0x72, 0x88, 0xa, 0xe5, 0x56, 0xa2, + 0x43, 0x13, 0x82, 0x5, 0x11, 0xe4, 0xb3, 0xc4, 0x43, 0xc0, 0x1e, 0x7f}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x41, 0x64, 0x54, 0x5b, 0xfe, 0x5b, 0x98, - 0xf9, 0x1a, 0x68, 0x65, 0x25, 0x65, 0xb9}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x95, 0x8c, 0x8, 0x4c, 0x80, 0xf, 0xfc, 0x54}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc9, 0xe6, 0x19, 0x1d, 0x34, 0x14, 0xe9, 0x42, 0x4f, 0x5d, 0xa5}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa4, 0x8a, 0xeb, 0x56, 0x57, 0xf2, 0xf2, 0x7, 0x86, 0xf3, 0xa8, 0xd7, 0x74, + 0x51, 0x4b, 0x10, 0xb3, 0xca, 0xcf, 0xfa, 0x41, 0x19, 0xe2, 0xae, 0x5d, 0x7}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf5, 0x94, 0x40, 0xf6, 0x69, 0x79, 0x1a, 0x3c, 0x45, 0xbf, 0xe, 0x62, 0x72}; - lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x21, 0x57, 0xb2, 0x8b, 0x27, 0x74, 0xca, 0xa6, 0x4b, 0xd, 0xdf, 0x97}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + uint8_t topic_filter_s6_bytes[] = {0xb4, 0xef, 0x8b, 0x2, 0x0, 0x64}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x85, 0xeb, 0x58, 0x33, 0xe3, 0x86, 0xf8, 0xec, 0xf8, 0xe7}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xaa, 0x99, 0xe2}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; + sub_opts[3].no_local = false; sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - uint8_t bytesprops0[] = {0x85, 0x5f, 0xe1, 0x9e, 0xc5, 0x80, 0x43, 0xc5, 0x15, 0x3d, - 0xc2, 0x42, 0x2b, 0xa1, 0xd5, 0xf0, 0x59, 0xde, 0xb5, 0x80}; - uint8_t bytesprops1[] = {0xd4, 0xc6, 0x7, 0xdc, 0x58, 0x92, 0x6e, 0x50, 0x85, 0x63, 0x60, 0x2b, 0x17, 0x34, - 0x2, 0x19, 0x5c, 0x25, 0xea, 0xf, 0x80, 0x20, 0x4d, 0x4e, 0xb0, 0xda, 0x97, 0x58}; - uint8_t bytesprops2[] = {0xbe, 0xef, 0x26, 0x7e, 0xb4, 0x41, 0x69, 0xf3, 0xf, 0x82, 0xa0, - 0xed, 0x3c, 0x2c, 0x14, 0xbf, 0xa4, 0xd4, 0x53, 0x63, 0x31, 0xf1}; - uint8_t bytesprops3[] = {0x1c, 0x2, 0x37, 0x3d, 0xeb, 0x6c, 0x3d, 0xf2, 0xb5, - 0x42, 0x1f, 0xe2, 0x45, 0xc6, 0x69, 0x87, 0x6c, 0x85}; - uint8_t bytesprops4[] = {0xb0, 0x5e, 0xa9, 0xcd, 0x65, 0xca, 0xaa, 0xae, 0xd6}; - uint8_t bytesprops5[] = {0x46}; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; + uint8_t bytesprops0[] = {0xac, 0xd2, 0x12, 0x56, 0xc0, 0xb5, 0xd, 0xf6, 0x20, 0x86, 0xdc, + 0xdf, 0x9e, 0x67, 0x1b, 0xfd, 0x5b, 0xb1, 0x41, 0x9f, 0x3b}; + uint8_t bytesprops1[] = {0x49, 0xb3, 0xcc, 0x7a, 0x5d, 0x19, 0x49, 0x81, 0x7d, 0x54, 0x3c, 0xc6}; + uint8_t bytesprops2[] = {0xe3, 0xe4, 0xe5, 0xe8, 0xc3, 0xc0, 0x29, 0xfc, 0x6f, 0x3b, 0xa6, + 0x75, 0xa0, 0x9b, 0x1d, 0xc7, 0x2a, 0xb8, 0x5a, 0x5, 0x97, 0x78}; + uint8_t bytesprops3[] = {0xb8, 0xcb, 0xd1, 0xd3, 0xfc, 0xaf, 0x5c, 0xc6, 0xa5, 0xea, 0x8, + 0x83, 0x15, 0x29, 0xd0, 0x7a, 0x32, 0xd6, 0x4d, 0x5d, 0x84}; + uint8_t bytesprops4[] = {0x6f, 0xf4, 0x24, 0x63, 0x10, 0x54, 0x5, 0xbe, 0xbc, 0x6e, 0xe8, 0xde, 0x14, 0xb5, + 0xbd, 0x79, 0xd3, 0xd0, 0x20, 0xd3, 0xa3, 0x82, 0xc1, 0xd4, 0x56, 0xb2, 0x8b, 0x73}; + uint8_t bytesprops6[] = {0x6f, 0x38, 0x99, 0x9, 0x75, 0x6a, 0x73, 0x53, 0x23, 0xa2, 0x7e}; + uint8_t bytesprops5[] = {0x80, 0x9c, 0x54, 0xa0, 0x92, 0xf4, 0x3b, 0x9a, 0x7, 0x7e, + 0x87, 0xc9, 0x4b, 0x80, 0xfd, 0xa9, 0x7b, 0x65, 0xaf, 0x6}; + uint8_t bytesprops8[] = {0xaa, 0xd7, 0x60, 0xe2, 0xba, 0x5, 0x9c, 0x22, 0x7a, 0xbe, + 0x4f, 0x25, 0xb6, 0x37, 0x7b, 0x39, 0x7a, 0xda, 0x3e}; + uint8_t bytesprops7[] = {0x79, 0xbc, 0x96, 0xe1, 0xa0, 0x51, 0xd6, 0xe4, 0xbd, 0x2c, 0x43}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21521}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20232}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3027}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7035}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6999}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19768}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20153}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23593}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17398}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9346}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20036}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6666}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23069}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3647}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32244}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14285}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19610}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13043}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8811}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops5}, .v = {11, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops7}, .v = {19, (char*)&bytesprops8}}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26959, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27695, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 24469 [("\ESC#\199)\130R\223\244K\131C[",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\251\177\205",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\SIM7\199/\GSb\150\n\210 -// m\147\134\136B$\140[\181G",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS2}),("x\229\129*\DC4h3\238\156\215|k\147=\203I\207t\230\131\199E\154\&6-\159\254B\b_",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\GS\179I\154\174\202\188f\228\141\231\152\165U\184H\238\&5a",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("e\242xX?l\240\&0p[V\STX\221%\132\152\STX\NAK7\204\231\202\SI\167\182\137bd\170\224",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("Au\237\142}\ENQ/1\187\&3fw@\229\243\188\SYN;\189\186\t\159\222\SI\r",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("@ -// \v5\RS\192\164\205\192\128\149\176Yt\SUB\229K\216\195\"\251",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropRetainAvailable 97,PropContentType -// "F\DLE\248\141\235\CANR\140-\155\252\182}@8nP\161\NAK\135<\203+\223r\244\170\b\STX\233",PropTopicAliasMaximum -// 20763,PropSubscriptionIdentifierAvailable 225,PropCorrelationData -// "BW\138\b\190y\187\130g\198\148\171\186\159\225\131\CAN\239\&6\136z\EM\228\246\224\&0",PropRequestProblemInformation -// 126,PropReceiveMaximum 7455,PropMaximumPacketSize 10474,PropReasonString -// "o\132\224\163",PropSharedSubscriptionAvailable 144,PropServerKeepAlive 24000,PropSessionExpiryInterval -// 11449,PropUserProperty "\203D;\ETX\219[\138\DEL\172\176\"&{" "\EMW-\148Q%\188\225\233[",PropMaximumPacketSize -// 4103,PropMaximumQoS 46] -TEST(Subscribe5QCTest, Encode11) { +// SubscribeRequest 29411 [(")\137\189d\189&\250#\214n1\GS\218A\245\158\136\t;\247\175:A\180\233",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\209\DLEs\183`\203\204*\136K\202\223k",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = True, _noLocal = True, _subQoS = +// QoS2}),("\214?\172zE\154=\DLE\186u!\132\140a\183\249\&3\189\186)\139\SUB",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropSharedSubscriptionAvailable +// 165,PropRequestResponseInformation 235,PropAuthenticationMethod +// "\DC2\t\188\157&$\245\GSX\196zgV\211\138q\208\196>\DLE\232\198f\166\224\223",PropAssignedClientIdentifier +// "EH",PropRetainAvailable 186,PropMessageExpiryInterval 4196,PropMessageExpiryInterval +// 5834,PropRequestResponseInformation 226,PropRequestProblemInformation 73,PropContentType "<",PropRetainAvailable +// 62,PropCorrelationData "2\ESC\245\&0",PropWildcardSubscriptionAvailable 39,PropRetainAvailable +// 243,PropCorrelationData ":\150\175\195\204\EOT\133\245\202\NUL\160\240_\NUL\219\251<\228",PropAuthenticationData +// "\245\EM\159B\215\228\255\166@4B?*'|G\143"] +TEST(Subscribe5QCTest, Encode17) { uint8_t pkt[] = { - 0x82, 0xc0, 0x2, 0x5f, 0x95, 0x83, 0x1, 0x25, 0x61, 0x3, 0x0, 0x1e, 0x46, 0x10, 0xf8, 0x8d, 0xeb, 0x18, 0x52, - 0x8c, 0x2d, 0x9b, 0xfc, 0xb6, 0x7d, 0x40, 0x38, 0x6e, 0x50, 0xa1, 0x15, 0x87, 0x3c, 0xcb, 0x2b, 0xdf, 0x72, 0xf4, - 0xaa, 0x8, 0x2, 0xe9, 0x22, 0x51, 0x1b, 0x29, 0xe1, 0x9, 0x0, 0x1a, 0x42, 0x57, 0x8a, 0x8, 0xbe, 0x79, 0xbb, - 0x82, 0x67, 0xc6, 0x94, 0xab, 0xba, 0x9f, 0xe1, 0x83, 0x18, 0xef, 0x36, 0x88, 0x7a, 0x19, 0xe4, 0xf6, 0xe0, 0x30, - 0x17, 0x7e, 0x21, 0x1d, 0x1f, 0x27, 0x0, 0x0, 0x28, 0xea, 0x1f, 0x0, 0x4, 0x6f, 0x84, 0xe0, 0xa3, 0x2a, 0x90, - 0x13, 0x5d, 0xc0, 0x11, 0x0, 0x0, 0x2c, 0xb9, 0x26, 0x0, 0xd, 0xcb, 0x44, 0x3b, 0x3, 0xdb, 0x5b, 0x8a, 0x7f, - 0xac, 0xb0, 0x22, 0x26, 0x7b, 0x0, 0xa, 0x19, 0x57, 0x2d, 0x94, 0x51, 0x25, 0xbc, 0xe1, 0xe9, 0x5b, 0x27, 0x0, - 0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x29, 0x8b, 0x1a, 0x1d}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x1b, 0x23, 0xc7, 0x29, 0x82, 0x52, 0xdf, 0xf4, 0x4b, 0x83, 0x43, 0x5b}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x29, 0x89, 0xbd, 0x64, 0xbd, 0x26, 0xfa, 0x23, 0xd6, 0x6e, 0x31, 0x1d, 0xda, + 0x41, 0xf5, 0x9e, 0x88, 0x9, 0x3b, 0xf7, 0xaf, 0x3a, 0x41, 0xb4, 0xe9}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfb, 0xb1, 0xcd}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd1, 0x10, 0x73, 0xb7, 0x60, 0xcb, 0xcc, 0x2a, 0x88, 0x4b, 0xca, 0xdf, 0x6b}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf, 0x4d, 0x37, 0xc7, 0x2f, 0x1d, 0x62, 0x96, 0xa, 0xd2, 0x20, - 0x6d, 0x93, 0x86, 0x88, 0x42, 0x24, 0x8c, 0x5b, 0xb5, 0x47}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd6, 0x3f, 0xac, 0x7a, 0x45, 0x9a, 0x3d, 0x10, 0xba, 0x75, 0x21, + 0x84, 0x8c, 0x61, 0xb7, 0xf9, 0x33, 0xbd, 0xba, 0x29, 0x8b, 0x1a}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x78, 0xe5, 0x81, 0x2a, 0x14, 0x68, 0x33, 0xee, 0x9c, 0xd7, - 0x7c, 0x6b, 0x93, 0x3d, 0xcb, 0x49, 0xcf, 0x74, 0xe6, 0x83, - 0xc7, 0x45, 0x9a, 0x36, 0x2d, 0x9f, 0xfe, 0x42, 0x8, 0x5f}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x1d, 0xb3, 0x49, 0x9a, 0xae, 0xca, 0xbc, 0x66, 0xe4, 0x8d, - 0xe7, 0x98, 0xa5, 0x55, 0xb8, 0x48, 0xee, 0x35, 0x61}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x65, 0xf2, 0x78, 0x58, 0x3f, 0x6c, 0xf0, 0x30, 0x70, 0x5b, - 0x56, 0x2, 0xdd, 0x25, 0x84, 0x98, 0x2, 0x15, 0x37, 0xcc, - 0xe7, 0xca, 0xf, 0xa7, 0xb6, 0x89, 0x62, 0x64, 0xaa, 0xe0}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x41, 0x75, 0xed, 0x8e, 0x7d, 0x5, 0x2f, 0x31, 0xbb, 0x33, 0x66, 0x77, 0x40, - 0xe5, 0xf3, 0xbc, 0x16, 0x3b, 0xbd, 0xba, 0x9, 0x9f, 0xde, 0xf, 0xd}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x40, 0x20, 0xb, 0x35, 0x1e, 0xc0, 0xa4, 0xcd, 0xc0, 0x80, 0x95, - 0xb0, 0x59, 0x74, 0x1a, 0xe5, 0x4b, 0xd8, 0xc3, 0x22, 0xfb}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - uint8_t bytesprops0[] = {0x46, 0x10, 0xf8, 0x8d, 0xeb, 0x18, 0x52, 0x8c, 0x2d, 0x9b, 0xfc, 0xb6, 0x7d, 0x40, 0x38, - 0x6e, 0x50, 0xa1, 0x15, 0x87, 0x3c, 0xcb, 0x2b, 0xdf, 0x72, 0xf4, 0xaa, 0x8, 0x2, 0xe9}; - uint8_t bytesprops1[] = {0x42, 0x57, 0x8a, 0x8, 0xbe, 0x79, 0xbb, 0x82, 0x67, 0xc6, 0x94, 0xab, 0xba, - 0x9f, 0xe1, 0x83, 0x18, 0xef, 0x36, 0x88, 0x7a, 0x19, 0xe4, 0xf6, 0xe0, 0x30}; - uint8_t bytesprops2[] = {0x6f, 0x84, 0xe0, 0xa3}; - uint8_t bytesprops4[] = {0x19, 0x57, 0x2d, 0x94, 0x51, 0x25, 0xbc, 0xe1, 0xe9, 0x5b}; - uint8_t bytesprops3[] = {0xcb, 0x44, 0x3b, 0x3, 0xdb, 0x5b, 0x8a, 0x7f, 0xac, 0xb0, 0x22, 0x26, 0x7b}; + uint8_t bytesprops0[] = {0x12, 0x9, 0xbc, 0x9d, 0x26, 0x24, 0xf5, 0x1d, 0x58, 0xc4, 0x7a, 0x67, 0x56, + 0xd3, 0x8a, 0x71, 0xd0, 0xc4, 0x3e, 0x10, 0xe8, 0xc6, 0x66, 0xa6, 0xe0, 0xdf}; + uint8_t bytesprops1[] = {0x45, 0x48}; + uint8_t bytesprops2[] = {0x3c}; + uint8_t bytesprops3[] = {0x32, 0x1b, 0xf5, 0x30}; + uint8_t bytesprops4[] = {0x3a, 0x96, 0xaf, 0xc3, 0xcc, 0x4, 0x85, 0xf5, 0xca, + 0x0, 0xa0, 0xf0, 0x5f, 0x0, 0xdb, 0xfb, 0x3c, 0xe4}; + uint8_t bytesprops5[] = {0xf5, 0x19, 0x9f, 0x42, 0xd7, 0xe4, 0xff, 0xa6, 0x40, + 0x34, 0x42, 0x3f, 0x2a, 0x27, 0x7c, 0x47, 0x8f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20763}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7455}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10474}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24000}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11449}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops3}, .v = {10, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4103}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4196}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5834}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24469, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29411, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12270 [("7\235R8?\\\200\&7^jN\237\DC2\229\&6O7",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\154\223\186^\201\164\207\230\160\GSi\205\210\204=(\196\CAN\191H\169D`",SubOptions {_retainHandling = +// SubscribeRequest 22557 [("#\164A\r\139\STX;\197\SIwh\SYN\201\230\252\196\208K",SubOptions {_retainHandling = // SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\254\248p\NUL5\\\140j\"\ETX\185\251\223\242+'\214\223z\229\247\219\225Y\ETB\FS\ESC\ESC\254",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\213\190 -// \178\176o\172\166\217\173E\167`)\b\EM\EM\249\204_\DLE\152`\179P",SubOptions {_retainHandling = SendOnSubscribe, +// QoS0}),("\137\185l\EOT\205\r\219\t.\239j\181j,*k\255\SO}L",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("d\196T\247\DC4\198\165\SUB1\a\181\255",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\ACK\155R\SYN\217\207\&3\145V\215ws\192\177\184S",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("#\161\214\195\f@H\130\av\155\169\241\157\251\196\231\233\135V\142",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("/\172\STX\DC2\"`\224+\179{\129\239\180\165\221\248\189\133",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("w\ESCURkJ\215\186\129\131\NAK\"\139d\\\246\228\ESC\SOHA\EM\218D\215\211*",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\186H[`\183\255",SubOptions +// QoS0}),("\169\228LZ\199^-&\NAKA\f\129\251\EOT]\FS\185h\190Zn6\252\DLE\187\153\170d\148",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\251\166\176\214=\STX\232\&4\248\r\254\\\184(\142\213\SO\140L\217\DC4\221y\202\169\138\206\145\182\192",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\170+\DEL:4\218\131z(#\199^O}\a\193\&0\181\231\231\187\187P\239",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropRetainAvailable -// 149,PropReasonString -// "\219?!\ETX\138J(v\227\238\210\237\GSu\189\137\&5N^\217F;\242\&7\137\NULl\181\178",PropTopicAliasMaximum -// 13282,PropReasonString "'\r\164I7\148~-",PropAuthenticationMethod -// "\167_\229\162\&8\DC4~\SI\149\131\147s\147\245Y\SOH\RS\167\f\205\245\131\SIl\SUB\191",PropResponseTopic -// "\"\DEL\173Y\174\r\151\133iQ0\137M\208\171\DC2\225\137\238}",PropReasonString -// "E\176\150\&2\255#\224&{\219\242\215\149g\217TW",PropCorrelationData "\161Ss<\192\194ct\146Z\157\169\151\&9\141 -// x\173K\147\r|_}\157",PropSubscriptionIdentifier 7,PropReasonString "\EM-",PropMessageExpiryInterval -// 15513,PropSubscriptionIdentifier 22,PropRetainAvailable 40,PropSubscriptionIdentifierAvailable -// 175,PropServerReference "\EOT\182\NAK5\158\&8\DC4\131 U\198\DC3\EOT@p\219Ix\237m\203\161W",PropRetainAvailable -// 30,PropAuthenticationData "\133\136y\187Lb{\218",PropTopicAlias 30717,PropContentType -// "\161\161\171\NUL\152RI\CAN\146\241\194\171\&9\186\145\174\227@\174/Ht\ETBi\242",PropMessageExpiryInterval -// 26831,PropUserProperty "\236\193\150\254\ETB\203\209\179{!}Q\139\170IG\FS\ba\240&'" -// ">\210\&4",PropRequestProblemInformation 91] -TEST(Subscribe5QCTest, Encode12) { +// QoS2}),("\170*\229'\207\130\193\237\139\159>\223\200\200\153\SOH\132\208\190\DC2\153\190\213O\190\DLE.\\y",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] +// [PropCorrelationData "\219\232\\\149f\b\DLE\248\250\168O\137Z\145\179\NULo\131\221",PropMaximumQoS +// 52,PropReasonString "n\SUB\132\189\253\138\247t",PropTopicAlias 31150,PropServerReference +// "\149w\214w\141\f\DC3\216\f\163\133\198^g\164\255\207\r\188a\201",PropReceiveMaximum 12814,PropServerReference +// ")\241C38s\146\152\ESCu\195\201\FS",PropAssignedClientIdentifier "\225",PropReceiveMaximum 26923,PropServerKeepAlive +// 21509,PropAuthenticationData +// "\\\228>xr[\227\207\154\DC3z\ETX\SYN\FSnw\163\195\139\240+&\168k\180\128",PropSharedSubscriptionAvailable +// 181,PropSharedSubscriptionAvailable 46,PropAssignedClientIdentifier +// "\DC3\218\251\245a\157\158\192\250\193?/\143\183P\180\189\ACK\146\250_",PropAuthenticationData +// "\172-jq\222\188^4\250\241\161\EM\133\189\245\142\228\148\216\238Q\179\SO\134&6?\ETB]\244",PropRetainAvailable +// 16,PropSharedSubscriptionAvailable 13,PropReceiveMaximum 25304,PropMessageExpiryInterval 30495,PropServerReference +// "yH\210U\184\&6\GS\a\131\148\&1",PropReceiveMaximum 2552,PropSessionExpiryInterval 29036,PropSessionExpiryInterval +// 17544,PropSubscriptionIdentifier 28,PropAuthenticationMethod +// "?\187\128M\206f\225\177G\175AJ0\156\185\219h\219\231\&5\138on\248\157"] +TEST(Subscribe5QCTest, Encode18) { uint8_t pkt[] = { - 0x82, 0xc0, 0x3, 0x2f, 0xee, 0x91, 0x2, 0x25, 0x95, 0x1f, 0x0, 0x1d, 0xdb, 0x3f, 0x21, 0x3, 0x8a, 0x4a, 0x28, - 0x76, 0xe3, 0xee, 0xd2, 0xed, 0x1d, 0x75, 0xbd, 0x89, 0x35, 0x4e, 0x5e, 0xd9, 0x46, 0x3b, 0xf2, 0x37, 0x89, 0x0, - 0x6c, 0xb5, 0xb2, 0x22, 0x33, 0xe2, 0x1f, 0x0, 0x8, 0x27, 0xd, 0xa4, 0x49, 0x37, 0x94, 0x7e, 0x2d, 0x15, 0x0, - 0x1a, 0xa7, 0x5f, 0xe5, 0xa2, 0x38, 0x14, 0x7e, 0xf, 0x95, 0x83, 0x93, 0x73, 0x93, 0xf5, 0x59, 0x1, 0x1e, 0xa7, - 0xc, 0xcd, 0xf5, 0x83, 0xf, 0x6c, 0x1a, 0xbf, 0x8, 0x0, 0x14, 0x22, 0x7f, 0xad, 0x59, 0xae, 0xd, 0x97, 0x85, - 0x69, 0x51, 0x30, 0x89, 0x4d, 0xd0, 0xab, 0x12, 0xe1, 0x89, 0xee, 0x7d, 0x1f, 0x0, 0x11, 0x45, 0xb0, 0x96, 0x32, - 0xff, 0x23, 0xe0, 0x26, 0x7b, 0xdb, 0xf2, 0xd7, 0x95, 0x67, 0xd9, 0x54, 0x57, 0x9, 0x0, 0x19, 0xa1, 0x53, 0x73, - 0x3c, 0xc0, 0xc2, 0x63, 0x74, 0x92, 0x5a, 0x9d, 0xa9, 0x97, 0x39, 0x8d, 0x20, 0x78, 0xad, 0x4b, 0x93, 0xd, 0x7c, - 0x5f, 0x7d, 0x9d, 0xb, 0x7, 0x1f, 0x0, 0x2, 0x19, 0x2d, 0x2, 0x0, 0x0, 0x3c, 0x99, 0xb, 0x16, 0x25, 0x28, - 0x29, 0xaf, 0x1c, 0x0, 0x17, 0x4, 0xb6, 0x15, 0x35, 0x9e, 0x38, 0x14, 0x83, 0x20, 0x55, 0xc6, 0x13, 0x4, 0x40, - 0x70, 0xdb, 0x49, 0x78, 0xed, 0x6d, 0xcb, 0xa1, 0x57, 0x25, 0x1e, 0x16, 0x0, 0x8, 0x85, 0x88, 0x79, 0xbb, 0x4c, - 0x62, 0x7b, 0xda, 0x23, 0x77, 0xfd, 0x3, 0x0, 0x19, 0xa1, 0xa1, 0xab, 0x0, 0x98, 0x52, 0x49, 0x18, 0x92, 0xf1, - 0xc2, 0xab, 0x39, 0xba, 0x91, 0xae, 0xe3, 0x40, 0xae, 0x2f, 0x48, 0x74, 0x17, 0x69, 0xf2, 0x2, 0x0, 0x0, 0x68, - 0xcf, 0x26, 0x0, 0x16, 0xec, 0xc1, 0x96, 0xfe, 0x17, 0xcb, 0xd1, 0xb3, 0x7b, 0x21, 0x7d, 0x51, 0x8b, 0xaa, 0x49, - 0x47, 0x1c, 0x8, 0x61, 0xf0, 0x26, 0x27, 0x0, 0x3, 0x3e, 0xd2, 0x34, 0x17, 0x5b, 0x0, 0x11, 0x37, 0xeb, 0x52, - 0x38, 0x3f, 0x5c, 0xc8, 0x37, 0x5e, 0x6a, 0x4e, 0xed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d, 0x1c, 0xb9, + 0x68, 0xbe, 0x5a, 0x6e, 0x36, 0xfc, 0x10, 0xbb, 0x99, 0xaa, 0x64, 0x94, 0x16, 0x0, 0x1e, 0xfb, 0xa6, 0xb0, 0xd6, + 0x3d, 0x2, 0xe8, 0x34, 0xf8, 0xd, 0xfe, 0x5c, 0xb8, 0x28, 0x8e, 0xd5, 0xe, 0x8c, 0x4c, 0xd9, 0x14, 0xdd, 0x79, + 0xca, 0xa9, 0x8a, 0xce, 0x91, 0xb6, 0xc0, 0xa, 0x0, 0x1d, 0xaa, 0x2a, 0xe5, 0x27, 0xcf, 0x82, 0xc1, 0xed, 0x8b, + 0x9f, 0x3e, 0xdf, 0xc8, 0xc8, 0x99, 0x1, 0x84, 0xd0, 0xbe, 0x12, 0x99, 0xbe, 0xd5, 0x4f, 0xbe, 0x10, 0x2e, 0x5c, + 0x79, 0xc}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x37, 0xeb, 0x52, 0x38, 0x3f, 0x5c, 0xc8, 0x37, 0x5e, - 0x6a, 0x4e, 0xed, 0x12, 0xe5, 0x36, 0x4f, 0x37}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x23, 0xa4, 0x41, 0xd, 0x8b, 0x2, 0x3b, 0xc5, 0xf, + 0x77, 0x68, 0x16, 0xc9, 0xe6, 0xfc, 0xc4, 0xd0, 0x4b}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9a, 0xdf, 0xba, 0x5e, 0xc9, 0xa4, 0xcf, 0xe6, 0xa0, 0x1d, 0x69, 0xcd, - 0xd2, 0xcc, 0x3d, 0x28, 0xc4, 0x18, 0xbf, 0x48, 0xa9, 0x44, 0x60}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x89, 0xb9, 0x6c, 0x4, 0xcd, 0xd, 0xdb, 0x9, 0x2e, 0xef, + 0x6a, 0xb5, 0x6a, 0x2c, 0x2a, 0x6b, 0xff, 0xe, 0x7d, 0x4c}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfe, 0xf8, 0x70, 0x0, 0x35, 0x5c, 0x8c, 0x6a, 0x22, 0x3, - 0xb9, 0xfb, 0xdf, 0xf2, 0x2b, 0x27, 0xd6, 0xdf, 0x7a, 0xe5, - 0xf7, 0xdb, 0xe1, 0x59, 0x17, 0x1c, 0x1b, 0x1b, 0xfe}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x64, 0xc4, 0x54, 0xf7, 0x14, 0xc6, 0xa5, 0x1a, 0x31, 0x7, 0xb5, 0xff}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd5, 0xbe, 0x20, 0xb2, 0xb0, 0x6f, 0xac, 0xa6, 0xd9, 0xad, 0x45, 0xa7, 0x60, - 0x29, 0x8, 0x19, 0x19, 0xf9, 0xcc, 0x5f, 0x10, 0x98, 0x60, 0xb3, 0x50}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6, 0x9b, 0x52, 0x16, 0xd9, 0xcf, 0x33, 0x91, + 0x56, 0xd7, 0x77, 0x73, 0xc0, 0xb1, 0xb8, 0x53}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x77, 0x1b, 0x55, 0x52, 0x6b, 0x4a, 0xd7, 0xba, 0x81, 0x83, 0x15, 0x22, 0x8b, - 0x64, 0x5c, 0xf6, 0xe4, 0x1b, 0x1, 0x41, 0x19, 0xda, 0x44, 0xd7, 0xd3, 0x2a}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x23, 0xa1, 0xd6, 0xc3, 0xc, 0x40, 0x48, 0x82, 0x7, 0x76, 0x9b, + 0xa9, 0xf1, 0x9d, 0xfb, 0xc4, 0xe7, 0xe9, 0x87, 0x56, 0x8e}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xba, 0x48, 0x5b, 0x60, 0xb7, 0xff}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x2f, 0xac, 0x2, 0x12, 0x22, 0x60, 0xe0, 0x2b, 0xb3, + 0x7b, 0x81, 0xef, 0xb4, 0xa5, 0xdd, 0xf8, 0xbd, 0x85}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xaa, 0x2b, 0x7f, 0x3a, 0x34, 0xda, 0x83, 0x7a, 0x28, 0x23, 0xc7, 0x5e, - 0x4f, 0x7d, 0x7, 0xc1, 0x30, 0xb5, 0xe7, 0xe7, 0xbb, 0xbb, 0x50, 0xef}; - lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xa9, 0xe4, 0x4c, 0x5a, 0xc7, 0x5e, 0x2d, 0x26, 0x15, 0x41, + 0xc, 0x81, 0xfb, 0x4, 0x5d, 0x1c, 0xb9, 0x68, 0xbe, 0x5a, + 0x6e, 0x36, 0xfc, 0x10, 0xbb, 0x99, 0xaa, 0x64, 0x94}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + uint8_t topic_filter_s7_bytes[] = {0xfb, 0xa6, 0xb0, 0xd6, 0x3d, 0x2, 0xe8, 0x34, 0xf8, 0xd, + 0xfe, 0x5c, 0xb8, 0x28, 0x8e, 0xd5, 0xe, 0x8c, 0x4c, 0xd9, + 0x14, 0xdd, 0x79, 0xca, 0xa9, 0x8a, 0xce, 0x91, 0xb6, 0xc0}; + lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xaa, 0x2a, 0xe5, 0x27, 0xcf, 0x82, 0xc1, 0xed, 0x8b, 0x9f, + 0x3e, 0xdf, 0xc8, 0xc8, 0x99, 0x1, 0x84, 0xd0, 0xbe, 0x12, + 0x99, 0xbe, 0xd5, 0x4f, 0xbe, 0x10, 0x2e, 0x5c, 0x79}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; + sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; + sub_opts[6].retain_as_published = false; sub_opts[6].no_local = true; - uint8_t bytesprops0[] = {0xdb, 0x3f, 0x21, 0x3, 0x8a, 0x4a, 0x28, 0x76, 0xe3, 0xee, 0xd2, 0xed, 0x1d, 0x75, 0xbd, - 0x89, 0x35, 0x4e, 0x5e, 0xd9, 0x46, 0x3b, 0xf2, 0x37, 0x89, 0x0, 0x6c, 0xb5, 0xb2}; - uint8_t bytesprops1[] = {0x27, 0xd, 0xa4, 0x49, 0x37, 0x94, 0x7e, 0x2d}; - uint8_t bytesprops2[] = {0xa7, 0x5f, 0xe5, 0xa2, 0x38, 0x14, 0x7e, 0xf, 0x95, 0x83, 0x93, 0x73, 0x93, - 0xf5, 0x59, 0x1, 0x1e, 0xa7, 0xc, 0xcd, 0xf5, 0x83, 0xf, 0x6c, 0x1a, 0xbf}; - uint8_t bytesprops3[] = {0x22, 0x7f, 0xad, 0x59, 0xae, 0xd, 0x97, 0x85, 0x69, 0x51, - 0x30, 0x89, 0x4d, 0xd0, 0xab, 0x12, 0xe1, 0x89, 0xee, 0x7d}; - uint8_t bytesprops4[] = {0x45, 0xb0, 0x96, 0x32, 0xff, 0x23, 0xe0, 0x26, 0x7b, - 0xdb, 0xf2, 0xd7, 0x95, 0x67, 0xd9, 0x54, 0x57}; - uint8_t bytesprops5[] = {0xa1, 0x53, 0x73, 0x3c, 0xc0, 0xc2, 0x63, 0x74, 0x92, 0x5a, 0x9d, 0xa9, 0x97, - 0x39, 0x8d, 0x20, 0x78, 0xad, 0x4b, 0x93, 0xd, 0x7c, 0x5f, 0x7d, 0x9d}; - uint8_t bytesprops6[] = {0x19, 0x2d}; - uint8_t bytesprops7[] = {0x4, 0xb6, 0x15, 0x35, 0x9e, 0x38, 0x14, 0x83, 0x20, 0x55, 0xc6, 0x13, - 0x4, 0x40, 0x70, 0xdb, 0x49, 0x78, 0xed, 0x6d, 0xcb, 0xa1, 0x57}; - uint8_t bytesprops8[] = {0x85, 0x88, 0x79, 0xbb, 0x4c, 0x62, 0x7b, 0xda}; - uint8_t bytesprops9[] = {0xa1, 0xa1, 0xab, 0x0, 0x98, 0x52, 0x49, 0x18, 0x92, 0xf1, 0xc2, 0xab, 0x39, - 0xba, 0x91, 0xae, 0xe3, 0x40, 0xae, 0x2f, 0x48, 0x74, 0x17, 0x69, 0xf2}; - uint8_t bytesprops11[] = {0x3e, 0xd2, 0x34}; - uint8_t bytesprops10[] = {0xec, 0xc1, 0x96, 0xfe, 0x17, 0xcb, 0xd1, 0xb3, 0x7b, 0x21, 0x7d, - 0x51, 0x8b, 0xaa, 0x49, 0x47, 0x1c, 0x8, 0x61, 0xf0, 0x26, 0x27}; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + uint8_t bytesprops0[] = {0xdb, 0xe8, 0x5c, 0x95, 0x66, 0x8, 0x10, 0xf8, 0xfa, 0xa8, + 0x4f, 0x89, 0x5a, 0x91, 0xb3, 0x0, 0x6f, 0x83, 0xdd}; + uint8_t bytesprops1[] = {0x6e, 0x1a, 0x84, 0xbd, 0xfd, 0x8a, 0xf7, 0x74}; + uint8_t bytesprops2[] = {0x95, 0x77, 0xd6, 0x77, 0x8d, 0xc, 0x13, 0xd8, 0xc, 0xa3, 0x85, + 0xc6, 0x5e, 0x67, 0xa4, 0xff, 0xcf, 0xd, 0xbc, 0x61, 0xc9}; + uint8_t bytesprops3[] = {0x29, 0xf1, 0x43, 0x33, 0x38, 0x73, 0x92, 0x98, 0x1b, 0x75, 0xc3, 0xc9, 0x1c}; + uint8_t bytesprops4[] = {0xe1}; + uint8_t bytesprops5[] = {0x5c, 0xe4, 0x3e, 0x78, 0x72, 0x5b, 0xe3, 0xcf, 0x9a, 0x13, 0x7a, 0x3, 0x16, + 0x1c, 0x6e, 0x77, 0xa3, 0xc3, 0x8b, 0xf0, 0x2b, 0x26, 0xa8, 0x6b, 0xb4, 0x80}; + uint8_t bytesprops6[] = {0x13, 0xda, 0xfb, 0xf5, 0x61, 0x9d, 0x9e, 0xc0, 0xfa, 0xc1, 0x3f, + 0x2f, 0x8f, 0xb7, 0x50, 0xb4, 0xbd, 0x6, 0x92, 0xfa, 0x5f}; + uint8_t bytesprops7[] = {0xac, 0x2d, 0x6a, 0x71, 0xde, 0xbc, 0x5e, 0x34, 0xfa, 0xf1, 0xa1, 0x19, 0x85, 0xbd, 0xf5, + 0x8e, 0xe4, 0x94, 0xd8, 0xee, 0x51, 0xb3, 0xe, 0x86, 0x26, 0x36, 0x3f, 0x17, 0x5d, 0xf4}; + uint8_t bytesprops8[] = {0x79, 0x48, 0xd2, 0x55, 0xb8, 0x36, 0x1d, 0x7, 0x83, 0x94, 0x31}; + uint8_t bytesprops9[] = {0x3f, 0xbb, 0x80, 0x4d, 0xce, 0x66, 0xe1, 0xb1, 0x47, 0xaf, 0x41, 0x4a, 0x30, + 0x9c, 0xb9, 0xdb, 0x68, 0xdb, 0xe7, 0x35, 0x8a, 0x6f, 0x6e, 0xf8, 0x9d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13282}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 52}}, {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15513}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30717}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26831}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops10}, .v = {3, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31150}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12814}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26923}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21509}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25304}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30495}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2552}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29036}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17544}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12270, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22557, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18547 [("\189J\145\DC3y\183\216\164\150\129\238l\168;Q\211/\253\211\135%\144\153\\\160",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\b@\172f,>\129\206D\233\DEL\225\131B}\239\133\177\140\196\193j\DC1\237",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\152\130\187",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\143\DC1\220\180\147#-\155\181y",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// True, _noLocal = True, _subQoS = QoS2}),("\235.\t\SOH\DC2\EM/vM\205b",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropContentType -// "\218\224\222?",PropMessageExpiryInterval 29289,PropAuthenticationData "\191n\EOTS",PropSharedSubscriptionAvailable -// 84,PropMessageExpiryInterval 3727,PropMessageExpiryInterval 29049,PropTopicAlias 21920,PropServerReference -// "\231\246\219\229B\169&\a\187\b\167\&3\191u\176!+\243\249T\223{",PropMessageExpiryInterval 11550,PropResponseTopic -// "\218\DEL\237,\213}\NUL\229\138,\ESCD\243P\187\223\187\144WT\EOTU\160da",PropMessageExpiryInterval -// 5728,PropCorrelationData "~\182T\189"] -TEST(Subscribe5QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0xc3, 0x1, 0x48, 0x73, 0x68, 0x3, 0x0, 0x4, 0xda, 0xe0, 0xde, 0x3f, 0x2, 0x0, 0x0, 0x72, - 0x69, 0x16, 0x0, 0x4, 0xbf, 0x6e, 0x4, 0x53, 0x2a, 0x54, 0x2, 0x0, 0x0, 0xe, 0x8f, 0x2, 0x0, - 0x0, 0x71, 0x79, 0x23, 0x55, 0xa0, 0x1c, 0x0, 0x16, 0xe7, 0xf6, 0xdb, 0xe5, 0x42, 0xa9, 0x26, 0x7, - 0xbb, 0x8, 0xa7, 0x33, 0xbf, 0x75, 0xb0, 0x21, 0x2b, 0xf3, 0xf9, 0x54, 0xdf, 0x7b, 0x2, 0x0, 0x0, - 0x2d, 0x1e, 0x8, 0x0, 0x19, 0xda, 0x7f, 0xed, 0x2c, 0xd5, 0x7d, 0x0, 0xe5, 0x8a, 0x2c, 0x1b, 0x44, - 0xf3, 0x50, 0xbb, 0xdf, 0xbb, 0x90, 0x57, 0x54, 0x4, 0x55, 0xa0, 0x64, 0x61, 0x2, 0x0, 0x0, 0x16, - 0x60, 0x9, 0x0, 0x4, 0x7e, 0xb6, 0x54, 0xbd, 0x0, 0x19, 0xbd, 0x4a, 0x91, 0x13, 0x79, 0xb7, 0xd8, - 0xa4, 0x96, 0x81, 0xee, 0x6c, 0xa8, 0x3b, 0x51, 0xd3, 0x2f, 0xfd, 0xd3, 0x87, 0x25, 0x90, 0x99, 0x5c, - 0xa0, 0x2, 0x0, 0x18, 0x8, 0x40, 0xac, 0x66, 0x2c, 0x3e, 0x81, 0xce, 0x44, 0xe9, 0x7f, 0xe1, 0x83, - 0x42, 0x7d, 0xef, 0x85, 0xb1, 0x8c, 0xc4, 0xc1, 0x6a, 0x11, 0xed, 0xc, 0x0, 0x3, 0x98, 0x82, 0xbb, - 0x4, 0x0, 0xa, 0x8f, 0x11, 0xdc, 0xb4, 0x93, 0x23, 0x2d, 0x9b, 0xb5, 0x79, 0x1e, 0x0, 0xb, 0xeb, - 0x2e, 0x9, 0x1, 0x12, 0x19, 0x2f, 0x76, 0x4d, 0xcd, 0x62, 0x24}; +// SubscribeRequest 10879 [("k\CAN\STX\230?\231\199\145\130\DLE\182\233W\233\&5F\250\153Hoip\242W\164",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\t\253\178\254a\b\217\143\162\FS\221\238PG\177\229\208*\DEL$k\160O\DLEs`\132\DC2\NAKV",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\216/\149I\232hE\247*RW\244\251\134\204",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\FS9Yu\225\234\246\SOHB>\199#\188\"i\162<\168\185?\219`\237\163\NUL%",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\201\177D\132y\246}ad\135\228\US\t",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS0}),("\132lyi].N\135g\164se\160\235!n\158\239MqZ",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropMaximumPacketSize +// 5146,PropSessionExpiryInterval 25344,PropSubscriptionIdentifier 9,PropMessageExpiryInterval +// 11213,PropWillDelayInterval 9631,PropRequestResponseInformation 142,PropResponseTopic +// "\170\224\174/\170\135\131\ENQ\235\194\247h",PropUserProperty ";T\ETX]^\235;F|\153Z\157/h\242'c|\147\178M!" +// "7\238KB\173\223%4\178a\RS\US\174~\157k\145\158\141\EM\184\242_\221<\170\&9\214",PropRetainAvailable +// 235,PropWillDelayInterval 23966,PropMessageExpiryInterval 27117,PropContentType "W\166",PropMessageExpiryInterval +// 2184,PropAssignedClientIdentifier "\181\&1\145;\250\248p1\144\145z\DC1\236",PropContentType +// "\238\168G\197\219\136\142i\243\&8I\220eyc\163\254e\f\193\f)SB\205\246\188B",PropWildcardSubscriptionAvailable +// 5,PropMessageExpiryInterval 2521,PropMaximumQoS 243,PropSubscriptionIdentifier 8,PropRequestResponseInformation +// 226,PropSharedSubscriptionAvailable 105,PropPayloadFormatIndicator 50,PropWildcardSubscriptionAvailable +// 13,PropAssignedClientIdentifier "0wW[P\155;\165A",PropMessageExpiryInterval 8553,PropTopicAliasMaximum +// 21395,PropSubscriptionIdentifier 18,PropMaximumQoS 178,PropContentType +// "\r`\209\159\254\ACK\148\236\161+\185\&6%\201~\198MC",PropReasonString "\170\215y\147\243U\216\222UI"] +TEST(Subscribe5QCTest, Encode19) { + uint8_t pkt[] = { + 0x82, 0xac, 0x3, 0x2a, 0x7f, 0xf0, 0x1, 0x27, 0x0, 0x0, 0x14, 0x1a, 0x11, 0x0, 0x0, 0x63, 0x0, 0xb, 0x9, + 0x2, 0x0, 0x0, 0x2b, 0xcd, 0x18, 0x0, 0x0, 0x25, 0x9f, 0x19, 0x8e, 0x8, 0x0, 0xc, 0xaa, 0xe0, 0xae, 0x2f, + 0xaa, 0x87, 0x83, 0x5, 0xeb, 0xc2, 0xf7, 0x68, 0x26, 0x0, 0x16, 0x3b, 0x54, 0x3, 0x5d, 0x5e, 0xeb, 0x3b, 0x46, + 0x7c, 0x99, 0x5a, 0x9d, 0x2f, 0x68, 0xf2, 0x27, 0x63, 0x7c, 0x93, 0xb2, 0x4d, 0x21, 0x0, 0x1c, 0x37, 0xee, 0x4b, + 0x42, 0xad, 0xdf, 0x25, 0x34, 0xb2, 0x61, 0x1e, 0x1f, 0xae, 0x7e, 0x9d, 0x6b, 0x91, 0x9e, 0x8d, 0x19, 0xb8, 0xf2, + 0x5f, 0xdd, 0x3c, 0xaa, 0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xee, 0x50, 0x47, 0xb1, 0xe5, 0xd0, 0x2a, 0x7f, 0x24, 0x6b, 0xa0, 0x4f, 0x10, 0x73, 0x60, 0x84, + 0x12, 0x15, 0x56, 0x8, 0x0, 0xf, 0xd8, 0x2f, 0x95, 0x49, 0xe8, 0x68, 0x45, 0xf7, 0x2a, 0x52, 0x57, 0xf4, 0xfb, + 0x86, 0xcc, 0x20, 0x0, 0x1a, 0x1c, 0x39, 0x59, 0x75, 0xe1, 0xea, 0xf6, 0x1, 0x42, 0x3e, 0xc7, 0x23, 0xbc, 0x22, + 0x69, 0xa2, 0x3c, 0xa8, 0xb9, 0x3f, 0xdb, 0x60, 0xed, 0xa3, 0x0, 0x25, 0x2e, 0x0, 0x17, 0xc9, 0xb1, 0x44, 0x84, + 0x79, 0xf6, 0x7d, 0x61, 0x64, 0x87, 0xe4, 0x1f, 0x3c, 0x48, 0x32, 0x5d, 0x56, 0xff, 0x9e, 0x65, 0xdf, 0xff, 0xfa, + 0x5, 0x0, 0x4, 0x3d, 0xcd, 0x6f, 0x15, 0x2a, 0x0, 0x10, 0x83, 0xcf, 0x36, 0x57, 0xc3, 0x20, 0x67, 0x4c, 0xb2, + 0xda, 0x82, 0x98, 0x75, 0xd1, 0x3e, 0x9, 0x20, 0x0, 0x15, 0x84, 0x6c, 0x79, 0x69, 0x5d, 0x2e, 0x4e, 0x87, 0x67, + 0xa4, 0x73, 0x65, 0xa0, 0xeb, 0x21, 0x6e, 0x9e, 0xef, 0x4d, 0x71, 0x5a, 0x18}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xbd, 0x4a, 0x91, 0x13, 0x79, 0xb7, 0xd8, 0xa4, 0x96, 0x81, 0xee, 0x6c, 0xa8, - 0x3b, 0x51, 0xd3, 0x2f, 0xfd, 0xd3, 0x87, 0x25, 0x90, 0x99, 0x5c, 0xa0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x6b, 0x18, 0x2, 0xe6, 0x3f, 0xe7, 0xc7, 0x91, 0x82, 0x10, 0xb6, 0xe9, 0x57, + 0xe9, 0x35, 0x46, 0xfa, 0x99, 0x48, 0x6f, 0x69, 0x70, 0xf2, 0x57, 0xa4}; lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8, 0x40, 0xac, 0x66, 0x2c, 0x3e, 0x81, 0xce, 0x44, 0xe9, 0x7f, 0xe1, - 0x83, 0x42, 0x7d, 0xef, 0x85, 0xb1, 0x8c, 0xc4, 0xc1, 0x6a, 0x11, 0xed}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9, 0xfd, 0xb2, 0xfe, 0x61, 0x8, 0xd9, 0x8f, 0xa2, 0x1c, + 0xdd, 0xee, 0x50, 0x47, 0xb1, 0xe5, 0xd0, 0x2a, 0x7f, 0x24, + 0x6b, 0xa0, 0x4f, 0x10, 0x73, 0x60, 0x84, 0x12, 0x15, 0x56}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x98, 0x82, 0xbb}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd8, 0x2f, 0x95, 0x49, 0xe8, 0x68, 0x45, 0xf7, + 0x2a, 0x52, 0x57, 0xf4, 0xfb, 0x86, 0xcc}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8f, 0x11, 0xdc, 0xb4, 0x93, 0x23, 0x2d, 0x9b, 0xb5, 0x79}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1c, 0x39, 0x59, 0x75, 0xe1, 0xea, 0xf6, 0x1, 0x42, 0x3e, 0xc7, 0x23, 0xbc, + 0x22, 0x69, 0xa2, 0x3c, 0xa8, 0xb9, 0x3f, 0xdb, 0x60, 0xed, 0xa3, 0x0, 0x25}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xeb, 0x2e, 0x9, 0x1, 0x12, 0x19, 0x2f, 0x76, 0x4d, 0xcd, 0x62}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc9, 0xb1, 0x44, 0x84, 0x79, 0xf6, 0x7d, 0x61, 0x64, 0x87, 0xe4, 0x1f, + 0x3c, 0x48, 0x32, 0x5d, 0x56, 0xff, 0x9e, 0x65, 0xdf, 0xff, 0xfa}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; + uint8_t topic_filter_s5_bytes[] = {0x3d, 0xcd, 0x6f, 0x15}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x83, 0xcf, 0x36, 0x57, 0xc3, 0x20, 0x67, 0x4c, + 0xb2, 0xda, 0x82, 0x98, 0x75, 0xd1, 0x3e, 0x9}; + lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x84, 0x6c, 0x79, 0x69, 0x5d, 0x2e, 0x4e, 0x87, 0x67, 0xa4, 0x73, + 0x65, 0xa0, 0xeb, 0x21, 0x6e, 0x9e, 0xef, 0x4d, 0x71, 0x5a}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; + sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; + sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = true; - uint8_t bytesprops0[] = {0xda, 0xe0, 0xde, 0x3f}; - uint8_t bytesprops1[] = {0xbf, 0x6e, 0x4, 0x53}; - uint8_t bytesprops2[] = {0xe7, 0xf6, 0xdb, 0xe5, 0x42, 0xa9, 0x26, 0x7, 0xbb, 0x8, 0xa7, - 0x33, 0xbf, 0x75, 0xb0, 0x21, 0x2b, 0xf3, 0xf9, 0x54, 0xdf, 0x7b}; - uint8_t bytesprops3[] = {0xda, 0x7f, 0xed, 0x2c, 0xd5, 0x7d, 0x0, 0xe5, 0x8a, 0x2c, 0x1b, 0x44, 0xf3, - 0x50, 0xbb, 0xdf, 0xbb, 0x90, 0x57, 0x54, 0x4, 0x55, 0xa0, 0x64, 0x61}; - uint8_t bytesprops4[] = {0x7e, 0xb6, 0x54, 0xbd}; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + uint8_t bytesprops0[] = {0xaa, 0xe0, 0xae, 0x2f, 0xaa, 0x87, 0x83, 0x5, 0xeb, 0xc2, 0xf7, 0x68}; + uint8_t bytesprops2[] = {0x37, 0xee, 0x4b, 0x42, 0xad, 0xdf, 0x25, 0x34, 0xb2, 0x61, 0x1e, 0x1f, 0xae, 0x7e, + 0x9d, 0x6b, 0x91, 0x9e, 0x8d, 0x19, 0xb8, 0xf2, 0x5f, 0xdd, 0x3c, 0xaa, 0x39, 0xd6}; + uint8_t bytesprops1[] = {0x3b, 0x54, 0x3, 0x5d, 0x5e, 0xeb, 0x3b, 0x46, 0x7c, 0x99, 0x5a, + 0x9d, 0x2f, 0x68, 0xf2, 0x27, 0x63, 0x7c, 0x93, 0xb2, 0x4d, 0x21}; + uint8_t bytesprops3[] = {0x57, 0xa6}; + uint8_t bytesprops4[] = {0xb5, 0x31, 0x91, 0x3b, 0xfa, 0xf8, 0x70, 0x31, 0x90, 0x91, 0x7a, 0x11, 0xec}; + uint8_t bytesprops5[] = {0xee, 0xa8, 0x47, 0xc5, 0xdb, 0x88, 0x8e, 0x69, 0xf3, 0x38, 0x49, 0xdc, 0x65, 0x79, + 0x63, 0xa3, 0xfe, 0x65, 0xc, 0xc1, 0xc, 0x29, 0x53, 0x42, 0xcd, 0xf6, 0xbc, 0x42}; + uint8_t bytesprops6[] = {0x30, 0x77, 0x57, 0x5b, 0x50, 0x9b, 0x3b, 0xa5, 0x41}; + uint8_t bytesprops7[] = {0xd, 0x60, 0xd1, 0x9f, 0xfe, 0x6, 0x94, 0xec, 0xa1, + 0x2b, 0xb9, 0x36, 0x25, 0xc9, 0x7e, 0xc6, 0x4d, 0x43}; + uint8_t bytesprops8[] = {0xaa, 0xd7, 0x79, 0x93, 0xf3, 0x55, 0xd8, 0xde, 0x55, 0x49}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29289}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3727}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29049}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21920}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11550}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5728}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5146}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25344}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11213}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9631}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops1}, .v = {28, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23966}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27117}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2184}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2521}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8553}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21395}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18547, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10879, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 10474 [(",+{\129\233\223\145\247o8\195\202\SIEVN\152\206m\181$\172\204\250HR\169",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\170[\206)\DC4\217gT\220\238",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS2}),("\194y\219\180",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1})] [PropPayloadFormatIndicator 44,PropAssignedClientIdentifier -// "\220\218\250V\193A\242\142\153\ESCH\210",PropAssignedClientIdentifier -// "\165CG\207\253\204\237\177\192\143",PropWillDelayInterval 27765,PropMaximumQoS 133,PropAssignedClientIdentifier -// "\210\CANo\193>",PropTopicAliasMaximum 12560,PropServerReference -// "\164\&2\212\vUW\147WU\226\228\245\212L\166!\225\239\240J",PropResponseInformation -// "_\170&\132\206\&5\153w\167\228\153\203=\ACK\167\ENQ?8\162\&4\SYN/\243\177zCO=",PropMessageExpiryInterval -// 29666,PropUserProperty "\228\&41\ENQG\171\241?F/\199\226\154 @\153\ACK!\ENQ\216\173\ETX\228\253\226\NUL^d.\201" -// "\165\169o\208\SOH\185\193\184\202\r\215\150\226L\138\&9\222+\224@l\240\167\187\129",PropMessageExpiryInterval -// 14224,PropResponseInformation "\168\208\251F\232\179\&4\NAKvO\140\ETX9Ae\160(",PropResponseTopic -// "\196\ACK\197\199\163m\NUL\168~/B\244\198\204\226\NUL\219\&6H\183\203\249\191\188\197\238\167\196\168",PropRequestResponseInformation -// 155,PropSubscriptionIdentifierAvailable 59,PropUserProperty "\SOH" -// ",\254\234u\166\231\205\211\133\169cu`\199\DC4V\234\251)",PropTopicAliasMaximum 8917,PropSessionExpiryInterval -// 28790,PropServerReference "\173\203h\175U\GS\250T"] -TEST(Subscribe5QCTest, Encode14) { - uint8_t pkt[] = { - 0x82, 0xc6, 0x2, 0x28, 0xea, 0x90, 0x2, 0x1, 0x2c, 0x12, 0x0, 0xc, 0xdc, 0xda, 0xfa, 0x56, 0xc1, 0x41, 0xf2, - 0x8e, 0x99, 0x1b, 0x48, 0xd2, 0x12, 0x0, 0xa, 0xa5, 0x43, 0x47, 0xcf, 0xfd, 0xcc, 0xed, 0xb1, 0xc0, 0x8f, 0x18, - 0x0, 0x0, 0x6c, 0x75, 0x24, 0x85, 0x12, 0x0, 0x5, 0xd2, 0x18, 0x6f, 0xc1, 0x3e, 0x22, 0x31, 0x10, 0x1c, 0x0, - 0x14, 0xa4, 0x32, 0xd4, 0xb, 0x55, 0x57, 0x93, 0x57, 0x55, 0xe2, 0xe4, 0xf5, 0xd4, 0x4c, 0xa6, 0x21, 0xe1, 0xef, - 0xf0, 0x4a, 0x1a, 0x0, 0x1c, 0x5f, 0xaa, 0x26, 0x84, 0xce, 0x35, 0x99, 0x77, 0xa7, 0xe4, 0x99, 0xcb, 0x3d, 0x6, - 0xa7, 0x5, 0x3f, 0x38, 0xa2, 0x34, 0x16, 0x2f, 0xf3, 0xb1, 0x7a, 0x43, 0x4f, 0x3d, 0x2, 0x0, 0x0, 0x73, 0xe2, - 0x26, 0x0, 0x1e, 0xe4, 0x34, 0x31, 0x5, 0x47, 0xab, 0xf1, 0x3f, 0x46, 0x2f, 0xc7, 0xe2, 0x9a, 0x20, 0x40, 0x99, - 0x6, 0x21, 0x5, 0xd8, 0xad, 0x3, 0xe4, 0xfd, 0xe2, 0x0, 0x5e, 0x64,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ubscribeRequest 26713 [("i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = +// True, _subQoS = QoS2}),("0\150\163\DC3)S\193\165K\135\211\DC43\159\\/\250+\200MF\149sGs{t\158",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\180+?\143\187\GS",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS0}),("s\t\186\187\183\237\241gr\201",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\SYN\179\228\226\252EZ\t\240$\ENQ\239JJq",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("D",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropResponseTopic +// "\223\150\233R;\FS\196o:\236\230\&7U\196\135\157\241\193",PropResponseInformation +// "\136\SUB\197qd\255\131\226\DC1\\J\\\206\172\197\NAK\253\189^",PropSessionExpiryInterval 19197,PropContentType +// "p",PropMessageExpiryInterval 25930,PropServerKeepAlive 24518,PropCorrelationData +// "\ENQ:e\DC2\145\ESC\195q\191\143\t\132\bX\154\SYN\210\230\196_`\"\201G",PropSharedSubscriptionAvailable +// 124,PropRequestResponseInformation 109,PropWildcardSubscriptionAvailable 99,PropMessageExpiryInterval +// 3866,PropReasonString "\162\132`\154\166\235\173\155G\215\236T\202!$z\ENQL"] +TEST(Subscribe5QCTest, Encode20) { + uint8_t pkt[] = {0x82, 0xc9, 0x1, 0x68, 0x59, 0x77, 0x8, 0x0, 0x12, 0xdf, 0x96, 0xe9, 0x52, 0x3b, 0x1c, 0xc4, 0x6f, + 0x3a, 0xec, 0xe6, 0x37, 0x55, 0xc4, 0x87, 0x9d, 0xf1, 0xc1, 0x1a, 0x0, 0x13, 0x88, 0x1a, 0xc5, 0x71, + 0x64, 0xff, 0x83, 0xe2, 0x11, 0x5c, 0x4a, 0x5c, 0xce, 0xac, 0xc5, 0x15, 0xfd, 0xbd, 0x5e, 0x11, 0x0, + 0x0, 0x4a, 0xfd, 0x3, 0x0, 0x1, 0x70, 0x2, 0x0, 0x0, 0x65, 0x4a, 0x13, 0x5f, 0xc6, 0x9, 0x0, + 0x18, 0x5, 0x3a, 0x65, 0x12, 0x91, 0x1b, 0xc3, 0x71, 0xbf, 0x8f, 0x9, 0x84, 0x8, 0x58, 0x9a, 0x16, + 0xd2, 0xe6, 0xc4, 0x5f, 0x60, 0x22, 0xc9, 0x47, 0x2a, 0x7c, 0x19, 0x6d, 0x28, 0x63, 0x2, 0x0, 0x0, + 0xf, 0x1a, 0x1f, 0x0, 0x12, 0xa2, 0x84, 0x60, 0x9a, 0xa6, 0xeb, 0xad, 0x9b, 0x47, 0xd7, 0xec, 0x54, + 0xca, 0x21, 0x24, 0x7a, 0x5, 0x4c, 0x0, 0x1, 0x69, 0xe, 0x0, 0x1c, 0x30, 0x96, 0xa3, 0x13, 0x29, + 0x53, 0xc1, 0xa5, 0x4b, 0x87, 0xd3, 0x14, 0x33, 0x9f, 0x5c, 0x2f, 0xfa, 0x2b, 0xc8, 0x4d, 0x46, 0x95, + 0x73, 0x47, 0x73, 0x7b, 0x74, 0x9e, 0xd, 0x0, 0x6, 0xb4, 0x2b, 0x3f, 0x8f, 0xbb, 0x1d, 0x18, 0x0, + 0xa, 0x73, 0x9, 0xba, 0xbb, 0xb7, 0xed, 0xf1, 0x67, 0x72, 0xc9, 0x14, 0x0, 0xf, 0x16, 0xb3, 0xe4, + 0xe2, 0xfc, 0x45, 0x5a, 0x9, 0xf0, 0x24, 0x5, 0xef, 0x4a, 0x4a, 0x71, 0x11, 0x0, 0x1, 0x44, 0xd}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x2c, 0x2b, 0x7b, 0x81, 0xe9, 0xdf, 0x91, 0xf7, 0x6f, 0x38, 0xc3, 0xca, 0xf, 0x45, - 0x56, 0x4e, 0x98, 0xce, 0x6d, 0xb5, 0x24, 0xac, 0xcc, 0xfa, 0x48, 0x52, 0xa9}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x69}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xaa, 0x5b, 0xce, 0x29, 0x14, 0xd9, 0x67, 0x54, 0xdc, 0xee}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x30, 0x96, 0xa3, 0x13, 0x29, 0x53, 0xc1, 0xa5, 0x4b, 0x87, + 0xd3, 0x14, 0x33, 0x9f, 0x5c, 0x2f, 0xfa, 0x2b, 0xc8, 0x4d, + 0x46, 0x95, 0x73, 0x47, 0x73, 0x7b, 0x74, 0x9e}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc2, 0x79, 0xdb, 0xb4}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb4, 0x2b, 0x3f, 0x8f, 0xbb, 0x1d}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s3_bytes[] = {0x73, 0x9, 0xba, 0xbb, 0xb7, 0xed, 0xf1, 0x67, 0x72, 0xc9}; + lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x16, 0xb3, 0xe4, 0xe2, 0xfc, 0x45, 0x5a, 0x9, + 0xf0, 0x24, 0x5, 0xef, 0x4a, 0x4a, 0x71}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x44}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - uint8_t bytesprops0[] = {0xdc, 0xda, 0xfa, 0x56, 0xc1, 0x41, 0xf2, 0x8e, 0x99, 0x1b, 0x48, 0xd2}; - uint8_t bytesprops1[] = {0xa5, 0x43, 0x47, 0xcf, 0xfd, 0xcc, 0xed, 0xb1, 0xc0, 0x8f}; - uint8_t bytesprops2[] = {0xd2, 0x18, 0x6f, 0xc1, 0x3e}; - uint8_t bytesprops3[] = {0xa4, 0x32, 0xd4, 0xb, 0x55, 0x57, 0x93, 0x57, 0x55, 0xe2, - 0xe4, 0xf5, 0xd4, 0x4c, 0xa6, 0x21, 0xe1, 0xef, 0xf0, 0x4a}; - uint8_t bytesprops4[] = {0x5f, 0xaa, 0x26, 0x84, 0xce, 0x35, 0x99, 0x77, 0xa7, 0xe4, 0x99, 0xcb, 0x3d, 0x6, - 0xa7, 0x5, 0x3f, 0x38, 0xa2, 0x34, 0x16, 0x2f, 0xf3, 0xb1, 0x7a, 0x43, 0x4f, 0x3d}; - uint8_t bytesprops6[] = {0xa5, 0xa9, 0x6f, 0xd0, 0x1, 0xb9, 0xc1, 0xb8, 0xca, 0xd, 0xd7, 0x96, 0xe2, - 0x4c, 0x8a, 0x39, 0xde, 0x2b, 0xe0, 0x40, 0x6c, 0xf0, 0xa7, 0xbb, 0x81}; - uint8_t bytesprops5[] = {0xe4, 0x34, 0x31, 0x5, 0x47, 0xab, 0xf1, 0x3f, 0x46, 0x2f, 0xc7, 0xe2, 0x9a, 0x20, 0x40, - 0x99, 0x6, 0x21, 0x5, 0xd8, 0xad, 0x3, 0xe4, 0xfd, 0xe2, 0x0, 0x5e, 0x64, 0x2e, 0xc9}; - uint8_t bytesprops7[] = {0xa8, 0xd0, 0xfb, 0x46, 0xe8, 0xb3, 0x34, 0x15, 0x76, - 0x4f, 0x8c, 0x3, 0x39, 0x41, 0x65, 0xa0, 0x28}; - uint8_t bytesprops8[] = {0xc4, 0x6, 0xc5, 0xc7, 0xa3, 0x6d, 0x0, 0xa8, 0x7e, 0x2f, 0x42, 0xf4, 0xc6, 0xcc, 0xe2, - 0x0, 0xdb, 0x36, 0x48, 0xb7, 0xcb, 0xf9, 0xbf, 0xbc, 0xc5, 0xee, 0xa7, 0xc4, 0xa8}; - uint8_t bytesprops10[] = {0x2c, 0xfe, 0xea, 0x75, 0xa6, 0xe7, 0xcd, 0xd3, 0x85, 0xa9, - 0x63, 0x75, 0x60, 0xc7, 0x14, 0x56, 0xea, 0xfb, 0x29}; - uint8_t bytesprops9[] = {0x1}; - uint8_t bytesprops11[] = {0xad, 0xcb, 0x68, 0xaf, 0x55, 0x1d, 0xfa, 0x54}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27765}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12560}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29666}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops5}, .v = {25, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14224}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops9}, .v = {19, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8917}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28790}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops11}}}, - }; - - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10474, 3, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 20401 [("\210n-\209\154iPp\201\217l\192\SOHlY\242\n$\144@t",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("@T\180Z\153\"\b\RS8\223%\224\&5z\DC2`\170\NAK\179\224!\SI\153}\149O\252\199\182",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("P\EM \252RA1y\233=Q -// \206U\161\SUB\NULSCcv\153\&1n\132\135T\138N",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// True, _noLocal = True, _subQoS = -// QoS0}),("\233\&2\236\152@\229Z\RS\247\249\142\241\147\181\234\al}\228\167\157",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("G\193\ETB\152\&84H\fg2\215\f\DC26\209\t\216xr\172\225>\246Es/_\201",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\SUB\164q\168\180\218\223\190\207RU\153\250\238+E\247\244\183\231\225",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\221\149A\211\195",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] -// [PropMessageExpiryInterval 18748,PropRetainAvailable 227,PropSessionExpiryInterval -// 7310,PropSubscriptionIdentifierAvailable 59,PropAssignedClientIdentifier -// ".\157P^\128\&1\188\198c2\205\&3s&\138\226\ACK\US\129\155\232~\183",PropMessageExpiryInterval 18830,PropMaximumQoS -// 7,PropMessageExpiryInterval 10723,PropContentType -// "\SUBA>\231\STX\174\247\239NVE\151\215\146\SOH\175\171V",PropRetainAvailable 168,PropReceiveMaximum -// 20286,PropAuthenticationData "\STX\134E\208\156\n\223,Q\166\161\FS\141\192\195\197\&6\EM0^",PropTopicAliasMaximum -// 25662,PropServerKeepAlive 1905,PropResponseTopic "\175\DC3\202",PropPayloadFormatIndicator 117,PropRetainAvailable -// 101,PropReceiveMaximum 17048,PropWildcardSubscriptionAvailable 212,PropWildcardSubscriptionAvailable 20] -TEST(Subscribe5QCTest, Encode15) { - uint8_t pkt[] = {0x82, 0xae, 0x2, 0x4f, 0xb1, 0x7c, 0x2, 0x0, 0x0, 0x49, 0x3c, 0x25, 0xe3, 0x11, 0x0, 0x0, 0x1c, - 0x8e, 0x29, 0x3b, 0x12, 0x0, 0x17, 0x2e, 0x9d, 0x50, 0x5e, 0x80, 0x31, 0xbc, 0xc6, 0x63, 0x32, 0xcd, - 0x33, 0x73, 0x26, 0x8a, 0xe2, 0x6, 0x1f, 0x81, 0x9b, 0xe8, 0x7e, 0xb7, 0x2, 0x0, 0x0, 0x49, 0x8e, - 0x24, 0x7, 0x2, 0x0, 0x0, 0x29, 0xe3, 0x3, 0x0, 0x12, 0x1a, 0x41, 0x3e, 0xe7, 0x2, 0xae, 0xf7, - 0xef, 0x4e, 0x56, 0x45, 0x97, 0xd7, 0x92, 0x1, 0xaf, 0xab, 0x56, 0x25, 0xa8, 0x21, 0x4f, 0x3e, 0x16, - 0x0, 0x14, 0x2, 0x86, 0x45, 0xd0, 0x9c, 0xa, 0xdf, 0x2c, 0x51, 0xa6, 0xa1, 0x1c, 0x8d, 0xc0, 0xc3, - 0xc5, 0x36, 0x19, 0x30, 0x5e, 0x22, 0x64, 0x3e, 0x13, 0x7, 0x71, 0x8, 0x0, 0x3, 0xaf, 0x13, 0xca, - 0x1, 0x75, 0x25, 0x65, 0x21, 0x42, 0x98, 0x28, 0xd4, 0x28, 0x14, 0x0, 0x15, 0xd2, 0x6e, 0x2d, 0xd1, - 0x9a, 0x69, 0x50, 0x70, 0xc9, 0xd9, 0x6c, 0xc0, 0x1, 0x6c, 0x59, 0xf2, 0xa, 0x24, 0x90, 0x40, 0x74, - 0xd, 0x0, 0x1d, 0x40, 0x54, 0xb4, 0x5a, 0x99, 0x22, 0x8, 0x1e, 0x38, 0xdf, 0x25, 0xe0, 0x35, 0x7a, - 0x12, 0x60, 0xaa, 0x15, 0xb3, 0xe0, 0x21, 0xf, 0x99, 0x7d, 0x95, 0x4f, 0xfc, 0xc7, 0xb6, 0xd, 0x0, - 0x1d, 0x50, 0x19, 0x20, 0xfc, 0x52, 0x41, 0x31, 0x79, 0xe9, 0x3d, 0x51, 0x20, 0xce, 0x55, 0xa1, 0x1a, - 0x0, 0x53, 0x43, 0x63, 0x76, 0x99, 0x31, 0x6e, 0x84, 0x87, 0x54, 0x8a, 0x4e, 0x2c, 0x0, 0x15, 0xe9, - 0x32, 0xec, 0x98, 0x40, 0xe5, 0x5a, 0x1e, 0xf7, 0xf9, 0x8e, 0xf1, 0x93, 0xb5, 0xea, 0x7, 0x6c, 0x7d, - 0xe4, 0xa7, 0x9d, 0x14, 0x0, 0x1c, 0x47, 0xc1, 0x17, 0x98, 0x38, 0x34, 0x48, 0xc, 0x67, 0x32, 0xd7, - 0xc, 0x12, 0x36, 0xd1, 0x9, 0xd8, 0x78, 0x72, 0xac, 0xe1, 0x3e, 0xf6, 0x45, 0x73, 0x2f, 0x5f, 0xc9, - 0xc, 0x0, 0x15, 0x1a, 0xa4, 0x71, 0xa8, 0xb4, 0xda, 0xdf, 0xbe, 0xcf, 0x52, 0x55, 0x99, 0xfa, 0xee, - 0x2b, 0x45, 0xf7, 0xf4, 0xb7, 0xe7, 0xe1, 0x6, 0x0, 0x5, 0xdd, 0x95, 0x41, 0xd3, 0xc3, 0x14}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xd2, 0x6e, 0x2d, 0xd1, 0x9a, 0x69, 0x50, 0x70, 0xc9, 0xd9, 0x6c, - 0xc0, 0x1, 0x6c, 0x59, 0xf2, 0xa, 0x24, 0x90, 0x40, 0x74}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x40, 0x54, 0xb4, 0x5a, 0x99, 0x22, 0x8, 0x1e, 0x38, 0xdf, - 0x25, 0xe0, 0x35, 0x7a, 0x12, 0x60, 0xaa, 0x15, 0xb3, 0xe0, - 0x21, 0xf, 0x99, 0x7d, 0x95, 0x4f, 0xfc, 0xc7, 0xb6}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x50, 0x19, 0x20, 0xfc, 0x52, 0x41, 0x31, 0x79, 0xe9, 0x3d, - 0x51, 0x20, 0xce, 0x55, 0xa1, 0x1a, 0x0, 0x53, 0x43, 0x63, - 0x76, 0x99, 0x31, 0x6e, 0x84, 0x87, 0x54, 0x8a, 0x4e}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe9, 0x32, 0xec, 0x98, 0x40, 0xe5, 0x5a, 0x1e, 0xf7, 0xf9, 0x8e, - 0xf1, 0x93, 0xb5, 0xea, 0x7, 0x6c, 0x7d, 0xe4, 0xa7, 0x9d}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x47, 0xc1, 0x17, 0x98, 0x38, 0x34, 0x48, 0xc, 0x67, 0x32, - 0xd7, 0xc, 0x12, 0x36, 0xd1, 0x9, 0xd8, 0x78, 0x72, 0xac, - 0xe1, 0x3e, 0xf6, 0x45, 0x73, 0x2f, 0x5f, 0xc9}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1a, 0xa4, 0x71, 0xa8, 0xb4, 0xda, 0xdf, 0xbe, 0xcf, 0x52, 0x55, - 0x99, 0xfa, 0xee, 0x2b, 0x45, 0xf7, 0xf4, 0xb7, 0xe7, 0xe1}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xdd, 0x95, 0x41, 0xd3, 0xc3}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; + sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - uint8_t bytesprops0[] = {0x2e, 0x9d, 0x50, 0x5e, 0x80, 0x31, 0xbc, 0xc6, 0x63, 0x32, 0xcd, 0x33, - 0x73, 0x26, 0x8a, 0xe2, 0x6, 0x1f, 0x81, 0x9b, 0xe8, 0x7e, 0xb7}; - uint8_t bytesprops1[] = {0x1a, 0x41, 0x3e, 0xe7, 0x2, 0xae, 0xf7, 0xef, 0x4e, - 0x56, 0x45, 0x97, 0xd7, 0x92, 0x1, 0xaf, 0xab, 0x56}; - uint8_t bytesprops2[] = {0x2, 0x86, 0x45, 0xd0, 0x9c, 0xa, 0xdf, 0x2c, 0x51, 0xa6, - 0xa1, 0x1c, 0x8d, 0xc0, 0xc3, 0xc5, 0x36, 0x19, 0x30, 0x5e}; - uint8_t bytesprops3[] = {0xaf, 0x13, 0xca}; + uint8_t bytesprops0[] = {0xdf, 0x96, 0xe9, 0x52, 0x3b, 0x1c, 0xc4, 0x6f, 0x3a, + 0xec, 0xe6, 0x37, 0x55, 0xc4, 0x87, 0x9d, 0xf1, 0xc1}; + uint8_t bytesprops1[] = {0x88, 0x1a, 0xc5, 0x71, 0x64, 0xff, 0x83, 0xe2, 0x11, 0x5c, + 0x4a, 0x5c, 0xce, 0xac, 0xc5, 0x15, 0xfd, 0xbd, 0x5e}; + uint8_t bytesprops2[] = {0x70}; + uint8_t bytesprops3[] = {0x5, 0x3a, 0x65, 0x12, 0x91, 0x1b, 0xc3, 0x71, 0xbf, 0x8f, 0x9, 0x84, + 0x8, 0x58, 0x9a, 0x16, 0xd2, 0xe6, 0xc4, 0x5f, 0x60, 0x22, 0xc9, 0x47}; + uint8_t bytesprops4[] = {0xa2, 0x84, 0x60, 0x9a, 0xa6, 0xeb, 0xad, 0x9b, 0x47, + 0xd7, 0xec, 0x54, 0xca, 0x21, 0x24, 0x7a, 0x5, 0x4c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18748}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7310}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18830}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10723}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20286}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25662}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1905}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17048}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19197}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25930}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24518}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3866}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20401, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26713, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8563 [("\143\195\RS\DEL-\129\b/n _",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\152K\195\r\158\128&X\SUB\FSI\163y\128\203\171\SO\227\231K\213\SI&Y\211\EM",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropContentType -// "\159\206p\152)",PropRequestResponseInformation 253,PropServerKeepAlive 32043,PropResponseInformation -// "[\187&\US\146r\201_\142\185\170\136?.\178,\199\SI^=\EM\178\249AC\245\189",PropResponseTopic -// "%\128\CAN\241",PropServerReference -// "K\165\197\SYN\189\NULX\213\224\230`\146\147\b\129\237\SYN\170\190<\206<)\210\US`\236j",PropMessageExpiryInterval -// 632,PropWillDelayInterval 8614,PropMessageExpiryInterval 1653,PropSessionExpiryInterval 2016,PropRetainAvailable -// 232,PropReasonString "\176\&3\159\243N\167\162V\167 \189\158GE\ETBl\149\189",PropSessionExpiryInterval 21353] -TEST(Subscribe5QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0xb0, 0x1, 0x21, 0x73, 0x81, 0x1, 0x3, 0x0, 0x5, 0x9f, 0xce, 0x70, 0x98, 0x29, 0x19, 0xfd, - 0x13, 0x7d, 0x2b, 0x1a, 0x0, 0x1b, 0x5b, 0xbb, 0x26, 0x1f, 0x92, 0x72, 0xc9, 0x5f, 0x8e, 0xb9, 0xaa, - 0x88, 0x3f, 0x2e, 0xb2, 0x2c, 0xc7, 0xf, 0x5e, 0x3d, 0x19, 0xb2, 0xf9, 0x41, 0x43, 0xf5, 0xbd, 0x8, - 0x0, 0x4, 0x25, 0x80, 0x18, 0xf1, 0x1c, 0x0, 0x1c, 0x4b, 0xa5, 0xc5, 0x16, 0xbd, 0x0, 0x58, 0xd5, - 0xe0, 0xe6, 0x60, 0x92, 0x93, 0x8, 0x81, 0xed, 0x16, 0xaa, 0xbe, 0x3c, 0xce, 0x3c, 0x29, 0xd2, 0x1f, - 0x60, 0xec, 0x6a, 0x2, 0x0, 0x0, 0x2, 0x78, 0x18, 0x0, 0x0, 0x21, 0xa6, 0x2, 0x0, 0x0, 0x6, - 0x75, 0x11, 0x0, 0x0, 0x7, 0xe0, 0x25, 0xe8, 0x1f, 0x0, 0x12, 0xb0, 0x33, 0x9f, 0xf3, 0x4e, 0xa7, - 0xa2, 0x56, 0xa7, 0x20, 0xbd, 0x9e, 0x47, 0x45, 0x17, 0x6c, 0x95, 0xbd, 0x11, 0x0, 0x0, 0x53, 0x69, - 0x0, 0xb, 0x8f, 0xc3, 0x1e, 0x7f, 0x2d, 0x81, 0x8, 0x2f, 0x6e, 0x20, 0x5f, 0x29, 0x0, 0x1a, 0x98, - 0x4b, 0xc3, 0xd, 0x9e, 0x80, 0x26, 0x58, 0x1a, 0x1c, 0x49, 0xa3, 0x79, 0x80, 0xcb, 0xab, 0xe, 0xe3, - 0xe7, 0x4b, 0xd5, 0xf, 0x26, 0x59, 0xd3, 0x19, 0x1a}; +// SubscribeRequest 25908 [("\158\154$vc\165\145gf\234i\231\148\155\181",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\RS\209\233$}",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] +// [PropMaximumPacketSize 30821,PropAuthenticationData +// "*\169G\209g~n26\184@\177\173{e\US\178L\188\167\165\130l",PropTopicAliasMaximum 29506,PropSessionExpiryInterval +// 19470,PropReasonString "o\EOT\159\170J5\136M\STX\189\189",PropSharedSubscriptionAvailable 133,PropResponseTopic +// "\218\SUB%\182\174\&2\178Sv\151\SYN@\155B\193B(#\161~\135",PropServerReference +// "\145H\203T%\196\244\219,\209K\246q0\171\167\EMxG\b\206\189\241\197\149X",PropServerReference +// ")\237+\191\222?\136\139\177#\166",PropSessionExpiryInterval 19900,PropServerReference +// ")\189v3\142G",PropSessionExpiryInterval 9354,PropPayloadFormatIndicator 193,PropMessageExpiryInterval +// 24898,PropWildcardSubscriptionAvailable 103,PropRequestResponseInformation 94,PropMessageExpiryInterval +// 3135,PropResponseInformation "\208S",PropReceiveMaximum 3314,PropSubscriptionIdentifierAvailable 172] +TEST(Subscribe5QCTest, Encode21) { + uint8_t pkt[] = {0x82, 0xc5, 0x1, 0x65, 0x34, 0xa7, 0x1, 0x27, 0x0, 0x0, 0x78, 0x65, 0x16, 0x0, 0x17, 0x2a, 0xa9, + 0x47, 0xd1, 0x67, 0x7e, 0x6e, 0x32, 0x36, 0xb8, 0x40, 0xb1, 0xad, 0x7b, 0x65, 0x1f, 0xb2, 0x4c, 0xbc, + 0xa7, 0xa5, 0x82, 0x6c, 0x22, 0x73, 0x42, 0x11, 0x0, 0x0, 0x4c, 0xe, 0x1f, 0x0, 0xb, 0x6f, 0x4, + 0x9f, 0xaa, 0x4a, 0x35, 0x88, 0x4d, 0x2, 0xbd, 0xbd, 0x2a, 0x85, 0x8, 0x0, 0x15, 0xda, 0x1a, 0x25, + 0xb6, 0xae, 0x32, 0xb2, 0x53, 0x76, 0x97, 0x16, 0x40, 0x9b, 0x42, 0xc1, 0x42, 0x28, 0x23, 0xa1, 0x7e, + 0x87, 0x1c, 0x0, 0x1a, 0x91, 0x48, 0xcb, 0x54, 0x25, 0xc4, 0xf4, 0xdb, 0x2c, 0xd1, 0x4b, 0xf6, 0x71, + 0x30, 0xab, 0xa7, 0x19, 0x78, 0x47, 0x8, 0xce, 0xbd, 0xf1, 0xc5, 0x95, 0x58, 0x1c, 0x0, 0xb, 0x29, + 0xed, 0x2b, 0xbf, 0xde, 0x3f, 0x88, 0x8b, 0xb1, 0x23, 0xa6, 0x11, 0x0, 0x0, 0x4d, 0xbc, 0x1c, 0x0, + 0x6, 0x29, 0xbd, 0x76, 0x33, 0x8e, 0x47, 0x11, 0x0, 0x0, 0x24, 0x8a, 0x1, 0xc1, 0x2, 0x0, 0x0, + 0x61, 0x42, 0x28, 0x67, 0x19, 0x5e, 0x2, 0x0, 0x0, 0xc, 0x3f, 0x1a, 0x0, 0x2, 0xd0, 0x53, 0x21, + 0xc, 0xf2, 0x29, 0xac, 0x0, 0xf, 0x9e, 0x9a, 0x24, 0x76, 0x63, 0xa5, 0x91, 0x67, 0x66, 0xea, 0x69, + 0xe7, 0x94, 0x9b, 0xb5, 0x1a, 0x0, 0x5, 0x1e, 0xd1, 0xe9, 0x24, 0x7d, 0x18}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x8f, 0xc3, 0x1e, 0x7f, 0x2d, 0x81, 0x8, 0x2f, 0x6e, 0x20, 0x5f}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x9e, 0x9a, 0x24, 0x76, 0x63, 0xa5, 0x91, 0x67, + 0x66, 0xea, 0x69, 0xe7, 0x94, 0x9b, 0xb5}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x98, 0x4b, 0xc3, 0xd, 0x9e, 0x80, 0x26, 0x58, 0x1a, 0x1c, 0x49, 0xa3, 0x79, - 0x80, 0xcb, 0xab, 0xe, 0xe3, 0xe7, 0x4b, 0xd5, 0xf, 0x26, 0x59, 0xd3, 0x19}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0xd1, 0xe9, 0x24, 0x7d}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - uint8_t bytesprops0[] = {0x9f, 0xce, 0x70, 0x98, 0x29}; - uint8_t bytesprops1[] = {0x5b, 0xbb, 0x26, 0x1f, 0x92, 0x72, 0xc9, 0x5f, 0x8e, 0xb9, 0xaa, 0x88, 0x3f, 0x2e, - 0xb2, 0x2c, 0xc7, 0xf, 0x5e, 0x3d, 0x19, 0xb2, 0xf9, 0x41, 0x43, 0xf5, 0xbd}; - uint8_t bytesprops2[] = {0x25, 0x80, 0x18, 0xf1}; - uint8_t bytesprops3[] = {0x4b, 0xa5, 0xc5, 0x16, 0xbd, 0x0, 0x58, 0xd5, 0xe0, 0xe6, 0x60, 0x92, 0x93, 0x8, - 0x81, 0xed, 0x16, 0xaa, 0xbe, 0x3c, 0xce, 0x3c, 0x29, 0xd2, 0x1f, 0x60, 0xec, 0x6a}; - uint8_t bytesprops4[] = {0xb0, 0x33, 0x9f, 0xf3, 0x4e, 0xa7, 0xa2, 0x56, 0xa7, - 0x20, 0xbd, 0x9e, 0x47, 0x45, 0x17, 0x6c, 0x95, 0xbd}; + uint8_t bytesprops0[] = {0x2a, 0xa9, 0x47, 0xd1, 0x67, 0x7e, 0x6e, 0x32, 0x36, 0xb8, 0x40, 0xb1, + 0xad, 0x7b, 0x65, 0x1f, 0xb2, 0x4c, 0xbc, 0xa7, 0xa5, 0x82, 0x6c}; + uint8_t bytesprops1[] = {0x6f, 0x4, 0x9f, 0xaa, 0x4a, 0x35, 0x88, 0x4d, 0x2, 0xbd, 0xbd}; + uint8_t bytesprops2[] = {0xda, 0x1a, 0x25, 0xb6, 0xae, 0x32, 0xb2, 0x53, 0x76, 0x97, 0x16, + 0x40, 0x9b, 0x42, 0xc1, 0x42, 0x28, 0x23, 0xa1, 0x7e, 0x87}; + uint8_t bytesprops3[] = {0x91, 0x48, 0xcb, 0x54, 0x25, 0xc4, 0xf4, 0xdb, 0x2c, 0xd1, 0x4b, 0xf6, 0x71, + 0x30, 0xab, 0xa7, 0x19, 0x78, 0x47, 0x8, 0xce, 0xbd, 0xf1, 0xc5, 0x95, 0x58}; + uint8_t bytesprops4[] = {0x29, 0xed, 0x2b, 0xbf, 0xde, 0x3f, 0x88, 0x8b, 0xb1, 0x23, 0xa6}; + uint8_t bytesprops5[] = {0x29, 0xbd, 0x76, 0x33, 0x8e, 0x47}; + uint8_t bytesprops6[] = {0xd0, 0x53}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32043}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 632}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8614}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1653}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2016}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21353}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30821}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29506}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19470}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19900}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9354}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24898}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3135}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3314}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 172}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8563, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25908, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 7682 [("\RS `P\209\153\210\225\236\187\202\241L\148\241X",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\ENQM\221\168\223",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\138\SYN\nG\DC3\GS\189\169\136\188\248~1A\160\133\254\212)\197\\",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("X\218\142\219\222C\214\142\ETX\209]-\202k\ESC\146h\161m\207",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\165\153\b\146/\NUL\131\v\215\&9=O\238-\235\DLEg\161@\SYN\ENQ\bZ\163\223\185z",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\201'\162\130h\150\158/\184\FS\131\156\251",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropPayloadFormatIndicator -// 188,PropAuthenticationMethod "\215\201\189\244\208",PropMessageExpiryInterval 7937,PropSubscriptionIdentifier -// 15,PropAuthenticationMethod -// "\200\US\253\244\NAK\155\243r\188\246\211\FS\179\NUL\179U\216]\179\144\EM\237\181MO\218\213\255K\205",PropWillDelayInterval -// 28417,PropServerKeepAlive 21564,PropServerReference "\249\248\176S\225\188\133\136\255\157\176",PropMaximumQoS -// 201,PropSubscriptionIdentifierAvailable 153,PropTopicAliasMaximum 29985] -TEST(Subscribe5QCTest, Encode17) { - uint8_t pkt[] = { - 0x82, 0xca, 0x1, 0x1e, 0x2, 0x4f, 0x1, 0xbc, 0x15, 0x0, 0x5, 0xd7, 0xc9, 0xbd, 0xf4, 0xd0, 0x2, 0x0, 0x0, - 0x1f, 0x1, 0xb, 0xf, 0x15, 0x0, 0x1e, 0xc8, 0x1f, 0xfd, 0xf4, 0x15, 0x9b, 0xf3, 0x72, 0xbc, 0xf6, 0xd3, 0x1c, - 0xb3, 0x0, 0xb3, 0x55, 0xd8, 0x5d, 0xb3, 0x90, 0x19, 0xed, 0xb5, 0x4d, 0x4f, 0xda, 0xd5, 0xff, 0x4b, 0xcd, 0x18, - 0x0, 0x0, 0x6f, 0x1, 0x13, 0x54, 0x3c, 0x1c, 0x0, 0xb, 0xf9, 0xf8, 0xb0, 0x53, 0xe1, 0xbc, 0x85, 0x88, 0xff, - 0x9d, 0xb0, 0x24, 0xc9, 0x29, 0x99, 0x22, 0x75, 0x21, 0x0, 0x10, 0x1e, 0x20, 0x60, 0x50, 0xd1, 0x99, 0xd2, 0xe1, - 0xec, 0xbb, 0xca, 0xf1, 0x4c, 0x94, 0xf1, 0x58, 0x16, 0x0, 0x5, 0x5, 0x4d, 0xdd, 0xa8, 0xdf, 0x24, 0x0, 0x15, - 0x8a, 0x16, 0xa, 0x47, 0x13, 0x1d, 0xbd, 0xa9, 0x88, 0xbc, 0xf8, 0x7e, 0x31, 0x41, 0xa0, 0x85, 0xfe, 0xd4, 0x29, - 0xc5, 0x5c, 0x20, 0x0, 0x14, 0x58, 0xda, 0x8e, 0xdb, 0xde, 0x43, 0xd6, 0x8e, 0x3, 0xd1, 0x5d, 0x2d, 0xca, 0x6b, - 0x1b, 0x92, 0x68, 0xa1, 0x6d, 0xcf, 0x6, 0x0, 0x1b, 0xa5, 0x99, 0x8, 0x92, 0x2f, 0x0, 0x83, 0xb, 0xd7, 0x39, - 0x3d, 0x4f, 0xee, 0x2d, 0xeb, 0x10, 0x67, 0xa1, 0x40, 0x16, 0x5, 0x8, 0x5a, 0xa3, 0xdf, 0xb9, 0x7a, 0x2c, 0x0, - 0xd, 0xc9, 0x27, 0xa2, 0x82, 0x68, 0x96, 0x9e, 0x2f, 0xb8, 0x1c, 0x83, 0x9c, 0xfb, 0x18}; +// SubscribeRequest 20578 [("\224\194C\240\225\DC1\DEL\202~\187o\222v\157/\164<\CAN\230;\141",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("m\173}5\SUB\254\SI\157\231",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\r$\DLE9\US*E\226",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAuthenticationData +// "\240\203\GS\191\198\140g\225~d\237\136\231oHF\167o\SI_\129\207\DEL\131\239\243C\173R",PropSharedSubscriptionAvailable +// 31,PropRetainAvailable 143,PropUserProperty "\254\199.t\235\132\145\197\fY^\250\255\185\187\211" +// "i\129\190\202\142\134\177%\237\180K\142\n\DC4/\236\188\169\160\135K",PropWildcardSubscriptionAvailable +// 165,PropSubscriptionIdentifier 0,PropWillDelayInterval 11724,PropTopicAliasMaximum 2174,PropResponseInformation +// "z\156\158\150Q\177U\168",PropCorrelationData +// "\202\184\170/\229\145\&7\"\255:]\237\215\DC3\228\158/N\DC4_\233b~\196\250iy\162\202",PropRequestResponseInformation +// 248,PropWildcardSubscriptionAvailable 99,PropReceiveMaximum 29354,PropContentType "\166",PropRetainAvailable +// 99,PropSubscriptionIdentifierAvailable 214,PropMaximumPacketSize 12704,PropServerReference +// "k\184{\254\DC2u\DC4,\213\DC1\ESC@\201\227\225=\141\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 0xe1, 0x3d, 0x8d, 0x1b, 0x1f, 0x95, 0x0, 0x15, 0xe0, 0xc2, + 0x43, 0xf0, 0xe1, 0x11, 0x7f, 0xca, 0x7e, 0xbb, 0x6f, 0xde, 0x76, 0x9d, 0x2f, 0xa4, 0x3c, 0x18, 0xe6, + 0x3b, 0x8d, 0xd, 0x0, 0x9, 0x6d, 0xad, 0x7d, 0x35, 0x1a, 0xfe, 0xf, 0x9d, 0xe7, 0x2, 0x0, 0x8, + 0xd, 0x24, 0x10, 0x39, 0x1f, 0x2a, 0x45, 0xe2, 0x11}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x1e, 0x20, 0x60, 0x50, 0xd1, 0x99, 0xd2, 0xe1, - 0xec, 0xbb, 0xca, 0xf1, 0x4c, 0x94, 0xf1, 0x58}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xe0, 0xc2, 0x43, 0xf0, 0xe1, 0x11, 0x7f, 0xca, 0x7e, 0xbb, 0x6f, + 0xde, 0x76, 0x9d, 0x2f, 0xa4, 0x3c, 0x18, 0xe6, 0x3b, 0x8d}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5, 0x4d, 0xdd, 0xa8, 0xdf}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6d, 0xad, 0x7d, 0x35, 0x1a, 0xfe, 0xf, 0x9d, 0xe7}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8a, 0x16, 0xa, 0x47, 0x13, 0x1d, 0xbd, 0xa9, 0x88, 0xbc, 0xf8, - 0x7e, 0x31, 0x41, 0xa0, 0x85, 0xfe, 0xd4, 0x29, 0xc5, 0x5c}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd, 0x24, 0x10, 0x39, 0x1f, 0x2a, 0x45, 0xe2}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x58, 0xda, 0x8e, 0xdb, 0xde, 0x43, 0xd6, 0x8e, 0x3, 0xd1, - 0x5d, 0x2d, 0xca, 0x6b, 0x1b, 0x92, 0x68, 0xa1, 0x6d, 0xcf}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa5, 0x99, 0x8, 0x92, 0x2f, 0x0, 0x83, 0xb, 0xd7, 0x39, 0x3d, 0x4f, 0xee, 0x2d, - 0xeb, 0x10, 0x67, 0xa1, 0x40, 0x16, 0x5, 0x8, 0x5a, 0xa3, 0xdf, 0xb9, 0x7a}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc9, 0x27, 0xa2, 0x82, 0x68, 0x96, 0x9e, 0x2f, 0xb8, 0x1c, 0x83, 0x9c, 0xfb}; - lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - uint8_t bytesprops0[] = {0xd7, 0xc9, 0xbd, 0xf4, 0xd0}; - uint8_t bytesprops1[] = {0xc8, 0x1f, 0xfd, 0xf4, 0x15, 0x9b, 0xf3, 0x72, 0xbc, 0xf6, 0xd3, 0x1c, 0xb3, 0x0, 0xb3, - 0x55, 0xd8, 0x5d, 0xb3, 0x90, 0x19, 0xed, 0xb5, 0x4d, 0x4f, 0xda, 0xd5, 0xff, 0x4b, 0xcd}; - uint8_t bytesprops2[] = {0xf9, 0xf8, 0xb0, 0x53, 0xe1, 0xbc, 0x85, 0x88, 0xff, 0x9d, 0xb0}; + uint8_t bytesprops0[] = {0xf0, 0xcb, 0x1d, 0xbf, 0xc6, 0x8c, 0x67, 0xe1, 0x7e, 0x64, 0xed, 0x88, 0xe7, 0x6f, 0x48, + 0x46, 0xa7, 0x6f, 0xf, 0x5f, 0x81, 0xcf, 0x7f, 0x83, 0xef, 0xf3, 0x43, 0xad, 0x52}; + uint8_t bytesprops2[] = {0x69, 0x81, 0xbe, 0xca, 0x8e, 0x86, 0xb1, 0x25, 0xed, 0xb4, 0x4b, + 0x8e, 0xa, 0x14, 0x2f, 0xec, 0xbc, 0xa9, 0xa0, 0x87, 0x4b}; + uint8_t bytesprops1[] = {0xfe, 0xc7, 0x2e, 0x74, 0xeb, 0x84, 0x91, 0xc5, + 0xc, 0x59, 0x5e, 0xfa, 0xff, 0xb9, 0xbb, 0xd3}; + uint8_t bytesprops3[] = {0x7a, 0x9c, 0x9e, 0x96, 0x51, 0xb1, 0x55, 0xa8}; + uint8_t bytesprops4[] = {0xca, 0xb8, 0xaa, 0x2f, 0xe5, 0x91, 0x37, 0x22, 0xff, 0x3a, 0x5d, 0xed, 0xd7, 0x13, 0xe4, + 0x9e, 0x2f, 0x4e, 0x14, 0x5f, 0xe9, 0x62, 0x7e, 0xc4, 0xfa, 0x69, 0x79, 0xa2, 0xca}; + uint8_t bytesprops5[] = {0xa6}; + uint8_t bytesprops6[] = {0x6b, 0xb8, 0x7b, 0xfe, 0x12, 0x75, 0x14, 0x2c, 0xd5, 0x11, + 0x1b, 0x40, 0xc9, 0xe3, 0xe1, 0x3d, 0x8d, 0x1b, 0x1f, 0x95}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7937}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28417}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21564}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29985}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {21, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11724}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2174}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29354}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12704}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7682, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20578, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9224 [("\199\229\146\190\EOT\224",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\238\163\ETB\179[\253\146N.\169\223$\202\251\ENQ\183\191\183`\165\135\152f-qP\201\189\SUB",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("f\133\252\176\189\165",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS0}),("ai\ETX\141\131P\247\191\147\143",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropMaximumQoS 210,PropWillDelayInterval -// 8103,PropUserProperty "\159\161:\170\151\205" -// "\ETB\139\222\ENQ\141\251\198\192\152nA\DC4\237\199x\240\&7\234Oz",PropMaximumPacketSize 25020,PropContentType -// "\199e\202`\233\172\"\155\187\253\220md}Z\225\\\135",PropContentType -// "V\187\154$EZ\243\208=\203\150\223A\153\223\209\131\235\SUB\n\208",PropCorrelationData "\219",PropMaximumQoS -// 103,PropRequestProblemInformation 63,PropMessageExpiryInterval 13825,PropResponseInformation "\190\207s -// #\164\DC4\239\145\252\183\195\206\165G\249\131\215\157\173",PropAssignedClientIdentifier -// "A\ENQ\174>\187i\165\ENQ\164\179F\DEL\166N;L\242\&1\229\196A\173\142\162k\142\&2\rB6",PropRequestResponseInformation -// 84,PropServerReference "L\167\&3k\206GU4)",PropPayloadFormatIndicator 37,PropMessageExpiryInterval -// 31778,PropRequestProblemInformation 119,PropWildcardSubscriptionAvailable 150,PropUserProperty -// "\132\218\239\163T;j\181\143\179`" "\255(UW\194\194\187\251W"] -TEST(Subscribe5QCTest,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x7c, 0x22, 0x17, 0x77, 0x28, 0x96, 0x26, - 0x0, 0xb, 0x84, 0xda, 0xef, 0xa3, 0x54, 0x3b, 0x6a, 0xb5, 0x8f, 0xb3, 0x60, 0x0, 0x9, 0xff, 0x28, 0x55, 0x57, - 0xc2, 0xc2, 0xbb, 0xfb, 0x57, 0x0, 0x6, 0xc7, 0xe5, 0x92, 0xbe, 0x4, 0xe0, 0x1c, 0x0, 0x1d, 0xee, 0xa3, 0x17, - 0xb3, 0x5b, 0xfd, 0x92, 0x4e, 0x2e, 0xa9, 0xdf, 0x24, 0xca, 0xfb, 0x5, 0xb7, 0xbf, 0xb7, 0x60, 0xa5, 0x87, 0x98, - 0x66, 0x2d, 0x71, 0x50, 0xc9, 0xbd, 0x1a, 0x5, 0x0, 0x6, 0x66, 0x85, 0xfc, 0xb0, 0xbd, 0xa5, 0x24, 0x0, 0xa, - 0x61, 0x69, 0x3, 0x8d, 0x83, 0x50, 0xf7, 0xbf, 0x93, 0x8f, 0x4}; +// SubscribeRequest 13418 [("\EM\171z\153z\136\168{\150\208\134\ENQ\134\225\231\CAN}",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropResponseInformation +// "B\187\220L\DLE",PropAuthenticationMethod "\130\196\&9~\195\ACK\152\&1\170\nI",PropSubscriptionIdentifierAvailable +// 123,PropMaximumQoS 103,PropSharedSubscriptionAvailable 60,PropTopicAlias 26601,PropTopicAlias +// 29510,PropReceiveMaximum 8856,PropSubscriptionIdentifierAvailable 204,PropUserProperty +// "\149y\130\172\239\250\154X>P\193\175u\132\221\236\228 }\192\FS\166on\"4\DC2\146" "e",PropSessionExpiryInterval +// 5464,PropWillDelayInterval 6090,PropReasonString "\249\188\SO\197\&7",PropAuthenticationMethod +// "_4;\253\209\216f\167\&5;\235\177\201\EOT\255\226\192\174\FSC5\SUB\230\ETX",PropSessionExpiryInterval +// 7464,PropServerReference "\245\169\255T\239\199jO\214\238\147\175\246N\a\181+\DC3",PropResponseTopic +// "\190\DLE\239",PropMaximumQoS 137,PropReceiveMaximum 27863,PropSharedSubscriptionAvailable 120,PropReceiveMaximum +// 3606,PropServerKeepAlive 27761,PropReasonString +// "\184\203\DC2\252[)\133\220-\US$\178V'\146\EOT\149\DC1\161\160d\142*\229\224",PropAuthenticationData +// "`^\v\ACK\206\225\130_\199w0 \rU"] +TEST(Subscribe5QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0xe8, 0x1, 0x34, 0x6a, 0xd0, 0x1, 0x1a, 0x0, 0x5, 0x42, 0xbb, 0xdc, 0x4c, 0x10, 0x15, 0x0, + 0xb, 0x82, 0xc4, 0x39, 0x7e, 0xc3, 0x6, 0x98, 0x31, 0xaa, 0xa, 0x49, 0x29, 0x7b, 0x24, 0x67, 0x2a, + 0x3c, 0x23, 0x67, 0xe9, 0x23, 0x73, 0x46, 0x21, 0x22, 0x98, 0x29, 0xcc, 0x26, 0x0, 0x1c, 0x95, 0x79, + 0x82, 0xac, 0xef, 0xfa, 0x9a, 0x58, 0x3e, 0x50, 0xc1, 0xaf, 0x75, 0x84, 0xdd, 0xec, 0xe4, 0x20, 0x7d, + 0xc0, 0x1c, 0xa6, 0x6f, 0x6e, 0x22, 0x34, 0x12, 0x92, 0x0, 0x1, 0x65, 0x11, 0x0, 0x0, 0x15, 0x58, + 0x18, 0x0, 0x0, 0x17, 0xca, 0x1f, 0x0, 0x5, 0xf9, 0xbc, 0xe, 0xc5, 0x37, 0x15, 0x0, 0x18, 0x5f, + 0x34, 0x3b, 0xfd, 0xd1, 0xd8, 0x66, 0xa7, 0x35, 0x3b, 0xeb, 0xb1, 0xc9, 0x4, 0xff, 0xe2, 0xc0, 0xae, + 0x1c, 0x43, 0x35, 0x1a, 0xe6, 0x3, 0x11, 0x0, 0x0, 0x1d, 0x28, 0x1c, 0x0, 0x12, 0xf5, 0xa9, 0xff, + 0x54, 0xef, 0xc7, 0x6a, 0x4f, 0xd6, 0xee, 0x93, 0xaf, 0xf6, 0x4e, 0x7, 0xb5, 0x2b, 0x13, 0x8, 0x0, + 0x3, 0xbe, 0x10, 0xef, 0x24, 0x89, 0x21, 0x6c, 0xd7, 0x2a, 0x78, 0x21, 0xe, 0x16, 0x13, 0x6c, 0x71, + 0x1f, 0x0, 0x19, 0xb8, 0xcb, 0x12, 0xfc, 0x5b, 0x29, 0x85, 0xdc, 0x2d, 0x1f, 0x24, 0xb2, 0x56, 0x27, + 0x92, 0x4, 0x95, 0x11, 0xa1, 0xa0, 0x64, 0x8e, 0x2a, 0xe5, 0xe0, 0x16, 0x0, 0xe, 0x60, 0x5e, 0xb, + 0x6, 0xce, 0xe1, 0x82, 0x5f, 0xc7, 0x77, 0x30, 0x20, 0xd, 0x55, 0x0, 0x11, 0x19, 0xab, 0x7a, 0x99, + 0x7a, 0x88, 0xa8, 0x7b, 0x96, 0xd0, 0x86, 0x5, 0x86, 0xe1, 0xe7, 0x18, 0x7d, 0x10}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xc7, 0xe5, 0x92, 0xbe, 0x4, 0xe0}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x19, 0xab, 0x7a, 0x99, 0x7a, 0x88, 0xa8, 0x7b, 0x96, + 0xd0, 0x86, 0x5, 0x86, 0xe1, 0xe7, 0x18, 0x7d}; + lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xee, 0xa3, 0x17, 0xb3, 0x5b, 0xfd, 0x92, 0x4e, 0x2e, 0xa9, - 0xdf, 0x24, 0xca, 0xfb, 0x5, 0xb7, 0xbf, 0xb7, 0x60, 0xa5, - 0x87, 0x98, 0x66, 0x2d, 0x71, 0x50, 0xc9, 0xbd, 0x1a}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x66, 0x85, 0xfc, 0xb0, 0xbd, 0xa5}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x61, 0x69, 0x3, 0x8d, 0x83, 0x50, 0xf7, 0xbf, 0x93, 0x8f}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + lwmqtt_sub_options_t sub_opts[1]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - uint8_t bytesprops1[] = {0x17, 0x8b, 0xde, 0x5, 0x8d, 0xfb, 0xc6, 0xc0, 0x98, 0x6e, - 0x41, 0x14, 0xed, 0xc7, 0x78, 0xf0, 0x37, 0xea, 0x4f, 0x7a}; - uint8_t bytesprops0[] = {0x9f, 0xa1, 0x3a, 0xaa, 0x97, 0xcd}; - uint8_t bytesprops2[] = {0xc7, 0x65, 0xca, 0x60, 0xe9, 0xac, 0x22, 0x9b, 0xbb, - 0xfd, 0xdc, 0x6d, 0x64, 0x7d, 0x5a, 0xe1, 0x5c, 0x87}; - uint8_t bytesprops3[] = {0x56, 0xbb, 0x9a, 0x24, 0x45, 0x5a, 0xf3, 0xd0, 0x3d, 0xcb, 0x96, - 0xdf, 0x41, 0x99, 0xdf, 0xd1, 0x83, 0xeb, 0x1a, 0xa, 0xd0}; - uint8_t bytesprops4[] = {0xdb}; - uint8_t bytesprops5[] = {0xbe, 0xcf, 0x73, 0x20, 0x23, 0xa4, 0x14, 0xef, 0x91, 0xfc, - 0xb7, 0xc3, 0xce, 0xa5, 0x47, 0xf9, 0x83, 0xd7, 0x9d, 0xad}; - uint8_t bytesprops6[] = {0x41, 0x5, 0xae, 0x3e, 0xbb, 0x69, 0xa5, 0x5, 0xa4, 0xb3, 0x46, 0x7f, 0xa6, 0x4e, 0x3b, - 0x4c, 0xf2, 0x31, 0xe5, 0xc4, 0x41, 0xad, 0x8e, 0xa2, 0x6b, 0x8e, 0x32, 0xd, 0x42, 0x36}; - uint8_t bytesprops7[] = {0x4c, 0xa7, 0x33, 0x6b, 0xce, 0x47, 0x55, 0x34, 0x29}; - uint8_t bytesprops9[] = {0xff, 0x28, 0x55, 0x57, 0xc2, 0xc2, 0xbb, 0xfb, 0x57}; - uint8_t bytesprops8[] = {0x84, 0xda, 0xef, 0xa3, 0x54, 0x3b, 0x6a, 0xb5, 0x8f, 0xb3, 0x60}; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0x42, 0xbb, 0xdc, 0x4c, 0x10}; + uint8_t bytesprops1[] = {0x82, 0xc4, 0x39, 0x7e, 0xc3, 0x6, 0x98, 0x31, 0xaa, 0xa, 0x49}; + uint8_t bytesprops3[] = {0x65}; + uint8_t bytesprops2[] = {0x95, 0x79, 0x82, 0xac, 0xef, 0xfa, 0x9a, 0x58, 0x3e, 0x50, 0xc1, 0xaf, 0x75, 0x84, + 0xdd, 0xec, 0xe4, 0x20, 0x7d, 0xc0, 0x1c, 0xa6, 0x6f, 0x6e, 0x22, 0x34, 0x12, 0x92}; + uint8_t bytesprops4[] = {0xf9, 0xbc, 0xe, 0xc5, 0x37}; + uint8_t bytesprops5[] = {0x5f, 0x34, 0x3b, 0xfd, 0xd1, 0xd8, 0x66, 0xa7, 0x35, 0x3b, 0xeb, 0xb1, + 0xc9, 0x4, 0xff, 0xe2, 0xc0, 0xae, 0x1c, 0x43, 0x35, 0x1a, 0xe6, 0x3}; + uint8_t bytesprops6[] = {0xf5, 0xa9, 0xff, 0x54, 0xef, 0xc7, 0x6a, 0x4f, 0xd6, + 0xee, 0x93, 0xaf, 0xf6, 0x4e, 0x7, 0xb5, 0x2b, 0x13}; + uint8_t bytesprops7[] = {0xbe, 0x10, 0xef}; + uint8_t bytesprops8[] = {0xb8, 0xcb, 0x12, 0xfc, 0x5b, 0x29, 0x85, 0xdc, 0x2d, 0x1f, 0x24, 0xb2, 0x56, + 0x27, 0x92, 0x4, 0x95, 0x11, 0xa1, 0xa0, 0x64, 0x8e, 0x2a, 0xe5, 0xe0}; + uint8_t bytesprops9[] = {0x60, 0x5e, 0xb, 0x6, 0xce, 0xe1, 0x82, 0x5f, 0xc7, 0x77, 0x30, 0x20, 0xd, 0x55}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8103}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {20, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25020}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 123}}, {.prop = (lwmqtt_prop_t)36, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13825}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31778}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops8}, .v = {9, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26601}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29510}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8856}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops2}, .v = {1, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5464}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6090}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7464}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27863}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3606}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27761}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9224, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13418, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14508 [("R\USc\174\228\248\201\SYN\DC3\248\&2\128\ENQ5",PropServerKeepAlive -// 17385,PropSubscriptionIdentifierAvailable 202,PropUserProperty -// "\251\CAN\177\245\143~JIPS<\205\148\212\199\249\223\133\151_\\>\245\215" "+",PropCorrelationData -// "\ACK\SO\222A\ACK\197#\215?\128\157\226L1",PropReceiveMaximum 8463,PropSubscriptionIdentifierAvailable 254] -TEST(Subscribe5QCTest, Encode20) { - uint8_t pkt[] = { - 0x82, 0xe1, 0x1, 0x5f, 0x45, 0xc1, 0x1, 0x13, 0x4f, 0x6e, 0x17, 0xeb, 0xb, 0x1b, 0x25, 0x7, 0x1, 0x19, 0x16, - 0x0, 0x2, 0x60, 0x9b, 0x8, 0x0, 0x4, 0x4a, 0x84, 0x5e, 0x24, 0xb, 0xc, 0x9, 0x0, 0x1d, 0x9b, 0x40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2d, 0x4, 0x8, 0xf8, 0x3c, 0x20}; +// SubscribeRequest 17738 [("\217\130'@BS\183\201\137\SOH\DC4\225o",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropAuthenticationData "",PropMaximumPacketSize +// 13226,PropTopicAlias 25122,PropPayloadFormatIndicator 92,PropAuthenticationData +// "\214\133\STX\246\DC1",PropTopicAliasMaximum 28878,PropTopicAlias 25882,PropRequestResponseInformation +// 230,PropUserProperty "\187\SUB_8\FS\170G\173i" "\178\148\207",PropMessageExpiryInterval 17596,PropTopicAlias +// 24979,PropSessionExpiryInterval 25290,PropPayloadFormatIndicator 23,PropServerKeepAlive +// 29088,PropAssignedClientIdentifier "\240\139A\a",PropSubscriptionIdentifierAvailable 237] +TEST(Subscribe5QCTest, Encode25) { + uint8_t pkt[] = {0x82, 0x5c, 0x45, 0x4a, 0x49, 0x16, 0x0, 0x0, 0x27, 0x0, 0x0, 0x33, 0xaa, 0x23, 0x62, 0x22, + 0x1, 0x5c, 0x16, 0x0, 0x5, 0xd6, 0x85, 0x2, 0xf6, 0x11, 0x22, 0x70, 0xce, 0x23, 0x65, 0x1a, + 0x19, 0xe6, 0x26, 0x0, 0x9, 0xbb, 0x1a, 0x5f, 0x38, 0x1c, 0xaa, 0x47, 0xad, 0x69, 0x0, 0x3, + 0xb2, 0x94, 0xcf, 0x2, 0x0, 0x0, 0x44, 0xbc, 0x23, 0x61, 0x93, 0x11, 0x0, 0x0, 0x62, 0xca, + 0x1, 0x17, 0x13, 0x71, 0xa0, 0x12, 0x0, 0x4, 0xf0, 0x8b, 0x41, 0x7, 0x29, 0xed, 0x0, 0xd, + 0xd9, 0x82, 0x27, 0x40, 0x42, 0x53, 0xb7, 0xc9, 0x89, 0x1, 0x14, 0xe1, 0x6f, 0x1e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xff, 0x4c, 0x29, 0x5b, 0x4a, 0x18, 0x9, 0xf0, 0x31, 0x8a, 0xa}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xd9, 0x82, 0x27, 0x40, 0x42, 0x53, 0xb7, 0xc9, 0x89, 0x1, 0x14, 0xe1, 0x6f}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe6, 0xcb, 0xce, 0xd4, 0xd8, 0xfd, 0x2d, 0x4, 0x8, 0xf8, 0x3c}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - uint8_t bytesprops0[] = {0x60, 0x9b}; - uint8_t bytesprops1[] = {0x4a, 0x84, 0x5e, 0x24}; - uint8_t bytesprops2[] = {0x9b, 0x40, 0x98, 0x1, 0x56, 0x3b, 0x16, 0x9b, 0x38, 0x6d, 0x22, 0xd5, 0x9a, 0x4e, 0xcf, - 0x2b, 0xfe, 0xb3, 0x50, 0x80, 0xd5, 0x5, 0xd1, 0x3f, 0xe8, 0x50, 0x31, 0xbb, 0xbb}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x7c, 0x19, 0xba, 0x6d, 0x58, 0x57, 0x77, 0x41, 0xb2, 0xa9, 0x16, - 0xcd, 0x0, 0xb4, 0xfc, 0x47, 0xfb, 0x9d, 0x2b, 0x2, 0xba}; - uint8_t bytesprops5[] = {0x5e, 0xb1, 0x81, 0x8a, 0x9f, 0x81, 0x5d, 0x0, 0x81, 0xd7, 0xb5, 0x4, 0x32, 0xfd, - 0x6, 0xf1, 0x33, 0xb3, 0xc3, 0x22, 0x47, 0x4b, 0x4f, 0x2b, 0x3e, 0x80, 0x5, 0x35}; - uint8_t bytesprops7[] = {0x2b}; - uint8_t bytesprops6[] = {0xfb, 0x18, 0xb1, 0xf5, 0x8f, 0x7e, 0x4a, 0x49, 0x50, 0x53, 0x3c, 0xcd, - 0x94, 0xd4, 0xc7, 0xf9, 0xdf, 0x85, 0x97, 0x5f, 0x5c, 0x3e, 0xf5, 0xd7}; - uint8_t bytesprops8[] = {0x6, 0xe, 0xde, 0x41, 0x6, 0xc5, 0x23, 0xd7, 0x3f, 0x80, 0x9d, 0xe2, 0x4c, 0x31}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0xd6, 0x85, 0x2, 0xf6, 0x11}; + uint8_t bytesprops3[] = {0xb2, 0x94, 0xcf}; + uint8_t bytesprops2[] = {0xbb, 0x1a, 0x5f, 0x38, 0x1c, 0xaa, 0x47, 0xad, 0x69}; + uint8_t bytesprops4[] = {0xf0, 0x8b, 0x41, 0x7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20334}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9652}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23632}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3725}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17385}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops6}, .v = {1, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8463}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13226}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25122}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28878}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25882}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops2}, .v = {3, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17596}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24979}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25290}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29088}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 237}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24389, 2, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 10907 [("A\162\160\180\204w=\RSRuY\179\226\193\241M\SI_\205\144\150\163\229E\232\a\173",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("I?\215\128q+\210",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS1}),("\156\203A\181",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// True, _noLocal = False, _subQoS = -// QoS1}),("f,u\248\196\253Ec\136\146a\182D\192\SO\206\128\EMS\198~\227\179\225\&5\190\200",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\160\250\NAK\133R\172\224\SUB*\176\204\145",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropReasonString -// "\"\132\239\185\EM=GD\248",PropCorrelationData "\NAK\184\206`\149$r;\241\138[ @\154\212n\SUB",PropTopicAlias -// 8966,PropWildcardSubscriptionAvailable 182,PropServerKeepAlive 9665,PropReceiveMaximum 23172,PropReasonString -// "\218,\176x\185\221\ESCd\241tN\131C\DC1\243\236\NULZo\183\243\184\238 \135\213SU\188",PropPayloadFormatIndicator -// 37,PropSubscriptionIdentifier 29,PropReceiveMaximum 17073,PropSessionExpiryInterval -// 6868,PropRequestProblemInformation 43,PropResponseTopic -// "\134g\196\DC1\187=D\nV\173\217\NAK\CAN\245\156\207E<\197\141t\140",PropCorrelationData -// "\144|\146\138o<\145UT\249",PropUserProperty "\162A\184\253\&4\245\225\165\NUL\238\a0\212\163\190W\230" -// "\183\154\155e\ETX\178\v\DC1:\247\230N\237 4B\fu\254\170v\138\240\229B",PropWillDelayInterval 8733,PropContentType -// "\222Dx\"\239\203@\163k/\192qs\149@\226c\DC46\252\175",PropMessageExpiryInterval 25434,PropMessageExpiryInterval -// 9677,PropTopicAlias 7911,PropMaximumPacketSize 7439,PropSubscriptionIdentifier 21,PropContentType -// "\172\191",PropAuthenticationData "\206\229\163T\203",PropMaximumPacketSize 29860,PropUserProperty -// "\195\b\STX\166",PropRequestResponseInformation 238,PropPayloadFormatIndicator 55,PropAuthenticationData -// "\248V\155\DC1\175\156\&1^\159\&5\161\165$",PropMessageExpiryInterval 5961,PropServerReference -// "\FS\252\&7^\"\181$\231Jw\"\187r\169]=\214\&8\142\"\188s\144fH\199K\ETXr\USX\194r\199fL\151",PropReasonString -// "\227ec\214\143j\141\&5T\193\139\245",PropAuthenticationMethod -// "z\176\194\219\219<\184\t\140\186\168\240\133\179'Q%\185\170",PropWildcardSubscriptionAvailable 107,PropTopicAlias -// 26361] -TEST(Subscribe5QCTest, Encode24) { - uint8_t pkt[] = { - 0x82, 0xdb, 0x2, 0x12, 0x3f, 0xda, 0x1, 0x26, 0x0, 0x1d, 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5, 0x15, 0x0, 0x13, 0x7a, 0xb0, 0xc2, 0xdb, 0xdb, 0x3c, 0xb8, 0x9, - 0x8c, 0xba, 0xa8, 0xf0, 0x85, 0xb3, 0x27, 0x51, 0x25, 0xb9, 0xaa, 0x28, 0x6b, 0x23, 0x66, 0xf9, 0x0, 0x3, 0x6f, - 0x73, 0x79, 0x1a, 0x0, 0x11, 0xd2, 0x48, 0x54, 0xa3, 0x12, 0x8b, 0xf3, 0x4f, 0xe0, 0xf6, 0xf2, 0x68, 0x98, 0xc0, - 0x98, 0x79, 0xba, 0x5, 0x0, 0x3, 0xb4, 0x51, 0xbb, 0x1e, 0x0, 0x0, 0xe, 0x0, 0x14, 0x27, 0xbf, 0x73, 0x9c, - 0x19, 0xbc, 0xd2, 0x1, 0x94, 0xba, 0x8d, 0x9a, 0x7b, 0xce, 0x2, 0x77, 0x56, 0xe9, 0xbc, 0x2b, 0x28, 0x0, 0xa, - 0x95, 0xd, 0x3a, 0xb5, 0x56, 0xcb, 0x15, 0x30, 0xb3, 0xe5, 0x2e, 0x0, 0xf, 0x52, 0x65, 0xb0, 0x1e, 0xfb, 0xdf, - 0x53, 0xff, 0xc8, 0xbe, 0xb4, 0x2b, 0xd9, 0x21, 0x70, 0xa, 0x0, 0x17, 0x77, 0xa, 0xae, 0xbb, 0xec, 0x76, 0x79, - 0xa9, 0xa6, 0xb9, 0x31, 0x95, 0x1, 0xfa, 0x83, 0x98, 0xcc, 0x1f, 0x80, 0x55, 0x90, 0x12, 0xae, 0x6, 0x0, 0x7, - 0xc8, 0xc1, 0xc2, 0x38, 0xf1, 0x70, 0xa6, 0xc}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x6f, 0x73, 0x79}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd2, 0x48, 0x54, 0xa3, 0x12, 0x8b, 0xf3, 0x4f, 0xe0, - 0xf6, 0xf2, 0x68, 0x98, 0xc0, 0x98, 0x79, 0xba}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb4, 0x51, 0xbb}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x27, 0xbf, 0x73, 0x9c, 0x19, 0xbc, 0xd2, 0x1, 0x94, 0xba, - 0x8d, 0x9a, 0x7b, 0xce, 0x2, 0x77, 0x56, 0xe9, 0xbc, 0x2b}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x95, 0xd, 0x3a, 0xb5, 0x56, 0xcb, 0x15, 0x30, 0xb3, 0xe5}; - lwmqtt_string_t topic_filter_s5 = {10, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x52, 0x65, 0xb0, 0x1e, 0xfb, 0xdf, 0x53, 0xff, - 0xc8, 0xbe, 0xb4, 0x2b, 0xd9, 0x21, 0x70}; - lwmqtt_string_t topic_filter_s6 = {15, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x77, 0xa, 0xae, 0xbb, 0xec, 0x76, 0x79, 0xa9, 0xa6, 0xb9, 0x31, 0x95, - 0x1, 0xfa, 0x83, 0x98, 0xcc, 0x1f, 0x80, 0x55, 0x90, 0x12, 0xae}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc8, 0xc1, 0xc2, 0x38, 0xf1, 0x70, 0xa6}; - lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = true; - uint8_t bytesprops1[] = {0x72, 0xea, 0xc3, 0x97}; - uint8_t bytesprops0[] = {0xd6, 0x6c, 0x15, 0x29, 0x1e, 0x6e, 0x56, 0x91, 0x99, 0xba, 0x1b, 0x40, 0xb8, 0xa1, 0xeb, - 0x76, 0xda, 0xbf, 0x8a, 0xd1, 0x79, 0x62, 0x87, 0x46, 0x75, 0x7e, 0x60, 0x92, 0x79}; - uint8_t bytesprops2[] = {0xc4, 0x5c, 0x24, 0x23, 0xf3, 0x14, 0x60, 0x60, 0x9e, 0x5b, - 0x61, 0x1c, 0xc3, 0x50, 0xb8, 0x44, 0x3, 0x5, 0x76}; - uint8_t bytesprops4[] = {0x7a, 0x80, 0xdb, 0x4e, 0x95, 0x23, 0x65, 0x37}; - uint8_t bytesprops3[] = {0xe6, 0xa5, 0x1, 0xff, 0xb0, 0x68, 0xa9, 0x98, 0xe0, 0x55, 0xe2, 0x5f, 0x31, - 0x18, 0xa8, 0x97, 0xda, 0xd4, 0xf7, 0x1f, 0x62, 0x72, 0x1a, 0x6c, 0x93, 0x5a}; - uint8_t bytesprops6[] = {0xde, 0x3c, 0xbe, 0x24, 0xf, 0x25, 0xb2, 0x1e, 0xda, 0xbb, 0x63, 0x30}; - uint8_t bytesprops5[] = {0xba, 0x76, 0x8d, 0x89, 0x43, 0xbd, 0x39, 0x8a, 0x56, 0x74, 0x10, 0x71, 0x9a}; - uint8_t bytesprops7[] = {0xe, 0x3, 0xad, 0x5a, 0xeb, 0xfd, 0xef, 0xb6, 0x3e, 0xd6, 0x38, 0x8e, 0x22, 0xbc, 0x73, - 0x90, 0x66, 0x48, 0xc7, 0x4b, 0x3, 0x72, 0x1f, 0x58, 0xc2, 0x72, 0xc7, 0x66, 0x4c, 0x97}; - uint8_t bytesprops8[] = {0xe3, 0x65, 0x63, 0xd6, 0x8f, 0x6a, 0x8d, 0x35, 0x54, 0xc1, 0x8b, 0xf5}; - uint8_t bytesprops9[] = {0x7a, 0xb0, 0xc2, 0xdb, 0xdb, 0x3c, 0xb8, 0x9, 0x8c, 0xba, - 0xa8, 0xf0, 0x85, 0xb3, 0x27, 0x51, 0x25, 0xb9, 0xaa}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops0}, .v = {4, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops3}, .v = {8, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23677}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13734}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops5}, .v = {12, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26361}}, - }; - - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4671, 9, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 22250 [("\186\185\130\168\166",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\155\157\SYN\229\227\209\&4\SOH|\242\168\253\129xF\166\\\"BG\191\246\215",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\182\&7\250\251\141.\181\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS0}),("\134&\251\172\216\150}\237\b\142\246",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\197\235",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("K\195})\202\&1'\218\169\SOH\200g\252\235R\225\201\b&@\v Y~\144x\232",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\163\249Y`\207\ETB\EOTf\n\159!l\SUB2hs\162\149\186\250?\a\220\237\200",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\177\128;f\163y\182\222\185\r\SYN\US-y#\168\SO\190Cu\SO\r\143~y\254\vi\163X",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\236Fm\234\247v&5\249\208\&0\FS",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// True, _noLocal = False, _subQoS = QoS2}),("b",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS0})] [PropRetainAvailable 236,PropSharedSubscriptionAvailable -// 11,PropRequestProblemInformation 28,PropMessageExpiryInterval 4198,PropTopicAlias -// 7386,PropSubscriptionIdentifierAvailable 14,PropWildcardSubscriptionAvailable 157,PropWillDelayInterval -// 20454,PropTopicAlias 8171,PropServerReference "\138\155\254%\185\185nS",PropPayloadFormatIndicator -// 213,PropServerReference "\169K\DLEu\204",PropResponseInformation -// "\ESC\185\142-\151\152\135C\183`\147/\215\235\223\234\138\fLBL\249\131@\CAN9\152\209\137,[\171\227\225\131%",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),(")eM\218\&6\152 \202\231\152J\139",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\200[\DC1O\176\181\136",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\209f\ENQ!\195\251$^7\130\148_\DC4\189\167\202s\172\210\149\254\181=",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("2a\216\&2\185\140i=\199\224\250\&3\230r\DC4\161\146\130G",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\136\ETX\176~\130\DC1\"\241\SIp\253\190\162\219\183`\234",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropMaximumPacketSize -// 5697,PropSharedSubscriptionAvailable 120,PropSubscriptionIdentifierAvailable 40,PropWildcardSubscriptionAvailable -// 52,PropServerKeepAlive 24790,PropPayloadFormatIndicator 26,PropUserProperty -// "\a\173:\189{4\DLE\177\231d\231\139\214\254\160\153" "",PropAssignedClientIdentifier -// "`.'\202\203\231\229?\DLE\167\157\134\204\182\180\227\210\192\&9V\143\213Y\133v=",PropCorrelationData -// "h\SI\228\160b\EM\150\151Z\132n\209nb&\FS\129\239|4\211\&36\ENQ\172\135K\SUBz",PropResponseTopic -// "#:+\228\235Y\183\250!x\197\a)\SO\154\254",PropUserProperty -// "p\238\184,\236\ESC\201\&3\199\254\132\246y\187\170\210}!\f\169\247T\184\&0Fw\142" -// "\b\NAKOj\148\136\227\201\221'\195nj7\ETB\254\188\145uD\131\&3\188\&7",PropAuthenticationMethod -// "\169\&4&tp8\151\179\185",PropTopicAlias 13893,PropMessageExpiryInterval 30246,PropMaximumQoS -// 68,PropMaximumPacketSize 19007,PropServerReference "\FS\SOt\223\229R\255",PropMaximumPacketSize -// 24216,PropSubscriptionIdentifierAvailable 104,PropRequestResponseInformation 139,PropSessionExpiryInterval -// 11251,PropTopicAliasMaximum 30523,PropServerKeepAlive 26783,PropMaximumQoS 129,PropRequestProblemInformation 174] -TEST(Subscribe5QCTest, Encode26) { - uint8_t pkt[] = { - 0x82, 0xdb, 0x3, 0x58, 0x51, 0xea, 0x1, 0x27, 0x0, 0x0, 0x16, 0x41, 0x2a, 0x78, 0x29, 0x28, 0x28, 0x34, 0x13, - 0x60, 0xd6, 0x1, 0x1a, 0x26, 0x0, 0x10, 0x7, 0xad, 0x3a, 0xbd, 0x7b, 0x34, 0x10, 0xb1, 0xe7, 0x64, 0xe7, 0x8b, - 0xd6, 0xfe, 0xa0, 0x99, 0x0, 0x0, 0x12, 0x0, 0x1a, 0x60, 0x2e, 0x27, 0xca, 0xcb, 0xe7, 0xe5, 0x3f, 0x10, 0xa7, - 0x9d, 0x86, 0xcc, 0xb6, 0xb4, 0xe3, 0xd2, 0xc0, 0x39, 0x56, 0x8f, 0xd5, 0x59, 0x85, 0x76, 0x3d, 0x9, 0x0, 0x1d, - 0x68, 0xf, 0xe4, 0xa0, 0x62, 0x19, 0x96, 0x97, 0x5a, 0x84, 0x6e, 0xd1, 0x6e, 0x62, 0x26, 0x1c, 0x81, 0xef, 0x7c, - 0x34, 0xd3, 0x33, 0x36, 0x5, 0xac, 0x87, 0x4b, 0x1a, 0x7a, 0x8, 0x0, 0x10, 0x23, 0x3a, 0x2b, 0xe4, 0xeb, 0x59, - 0xb7, 0xfa, 0x21, 0x78, 0xc5, 0x7, 0x29, 0xe, 0x9a, 0xfe, 0x26, 0x0, 0x1b, 0x70, 0xee, 0xb8, 0x2c, 0xec,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x3f, 0xa4, 0x61, - 0x34, 0xe6, 0x93, 0xe8, 0xb1, 0xe1, 0xe2, 0xf7, 0x83, 0xde, 0xcd, 0x5, 0x5, 0x0, 0x19, 0x12, 0x61, 0xba, 0x48, - 0x8c, 0xac, 0x4e, 0x3c, 0x99, 0x4d, 0xfc, 0xab, 0xfc, 0x4a, 0x69, 0x27, 0x13, 0xc, 0x33, 0x36, 0x1d, 0xec, 0x14, - 0x74, 0xc8, 0xa, 0x0, 0x12, 0x7b, 0xcc, 0xf4, 0x4f, 0xa2, 0x3e, 0x18, 0x39, 0x98, 0xd1, 0x89, 0x2c, 0x5b, 0xab, - 0xe3, 0xe1, 0x83, 0x25, 0x2c, 0x0, 0xc, 0x29, 0x65, 0x4d, 0xda, 0x36, 0x98, 0x20, 0xca, 0xe7, 0x98, 0x4a, 0x8b, - 0x2a, 0x0, 0x7, 0xc8, 0x5b, 0x11, 0x4f, 0xb0, 0xb5, 0x88, 0x20, 0x0, 0x17, 0xd1, 0x66, 0x5, 0x21, 0xc3, 0xfb, - 0x24, 0x5e, 0x37, 0x82, 0x94, 0x5f, 0x14, 0xbd, 0xa7, 0xca, 0x73, 0xac, 0xd2, 0x95, 0xfe, 0xb5, 0x3d, 0xa, 0x0, - 0x13, 0x32, 0x61, 0xd8, 0x32, 0xb9, 0x8c, 0x69, 0x3d, 0xc7, 0xe0, 0xfa, 0x33, 0xe6, 0x72, 0x14, 0xa1, 0x92, 0x82, - 0x47, 0x1d, 0x0, 0x11, 0x88, 0x3, 0xb0, 0x7e, 0x82, 0x11, 0x22, 0xf1, 0xf, 0x70, 0xfd, 0xbe, 0xa2, 0xdb, 0xb7, - 0x60, 0xea, 0x12}; +// SubscribeRequest 19375 [("\225\165Uj\\\240\190*Vv\135:f)\169i/up&",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\203N\154\STXXt\245\221\238\134 ?=",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\SUB\205",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, +// _subQoS = QoS0})] [PropAuthenticationData "\179\140vn5\142'\154\215l\129\171I\175\188\CANs\172/",PropMaximumQoS +// 49,PropMaximumPacketSize 29237,PropTopicAliasMaximum 8231,PropRequestResponseInformation 182,PropMaximumPacketSize +// 18717,PropResponseInformation "\178\129\246W",PropServerReference "*IE\245\240\167<\DC2 +// \247-\STX\241\218\184n\225yl\145\179\161\190\145",PropResponseInformation +// "\165|\136\145Z\150\245F\USI\STX\154\232\224\158\168\SUB_\169\DC3\204\169v",PropServerReference +// "\NAK\143$\235",PropWildcardSubscriptionAvailable 222,PropTopicAliasMaximum 1110,PropSubscriptionIdentifierAvailable +// 115,PropMessageExpiryInterval 23125,PropContentType "m\SUB",PropSubscriptionIdentifier 12,PropMaximumPacketSize +// 8589,PropRetainAvailable 108,PropRetainAvailable 35,PropTopicAlias 7606,PropSessionExpiryInterval 28011] +TEST(Subscribe5QCTest, Encode27) { + uint8_t pkt[] = {0x82, 0xbe, 0x1, 0x4b, 0xaf, 0x8e, 0x1, 0x16, 0x0, 0x13, 0xb3, 0x8c, 0x76, 0x6e, 0x35, 0x8e, 0x27, + 0x9a, 0xd7, 0x6c, 0x81, 0xab, 0x49, 0xaf, 0xbc, 0x18, 0x73, 0xac, 0x2f, 0x24, 0x31, 0x27, 0x0, 0x0, + 0x72, 0x35, 0x22, 0x20, 0x27, 0x19, 0xb6, 0x27, 0x0, 0x0, 0x49, 0x1d, 0x1a, 0x0, 0x4, 0xb2, 0x81, + 0xf6, 0x57, 0x1c, 0x0, 0x18, 0x2a, 0x49, 0x45, 0xf5, 0xf0, 0xa7, 0x3c, 0x12, 0x20, 0xf7, 0x2d, 0x2, + 0xf1, 0xda, 0xb8, 0x6e, 0xe1, 0x79, 0x6c, 0x91, 0xb3, 0xa1, 0xbe, 0x91, 0x1a, 0x0, 0x17, 0xa5, 0x7c, + 0x88, 0x91, 0x5a, 0x96, 0xf5, 0x46, 0x1f, 0x49, 0x2, 0x9a, 0xe8, 0xe0, 0x9e, 0xa8, 0x1a, 0x5f, 0xa9, + 0x13, 0xcc, 0xa9, 0x76, 0x1c, 0x0, 0x4, 0x15, 0x8f, 0x24, 0xeb, 0x28, 0xde, 0x22, 0x4, 0x56, 0x29, + 0x73, 0x2, 0x0, 0x0, 0x5a, 0x55, 0x3, 0x0, 0x2, 0x6d, 0x1a, 0xb, 0xc, 0x27, 0x0, 0x0, 0x21, + 0x8d, 0x25, 0x6c, 0x25, 0x23, 0x23, 0x1d, 0xb6, 0x11, 0x0, 0x0, 0x6d, 0x6b, 0x0, 0x14, 0xe1, 0xa5, + 0x55, 0x6a, 0x5c, 0xf0, 0xbe, 0x2a, 0x56, 0x76, 0x87, 0x3a, 0x66, 0x29, 0xa9, 0x69, 0x2f, 0x75, 0x70, + 0x26, 0x0, 0x0, 0xd, 0xcb, 0x4e, 0x9a, 0x2, 0x58, 0x74, 0xf5, 0xdd, 0xee, 0x86, 0x20, 0x3f, 0x3d, + 0x2e, 0x0, 0x2, 0x1a, 0xcd, 0x18}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x39, 0xa2, 0x41, 0xa4, 0xd6, 0x78, 0x32, 0x87, 0x55, - 0x7c, 0x29, 0xe6, 0xc9, 0x74, 0x1d, 0xc5, 0xbd}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xe1, 0xa5, 0x55, 0x6a, 0x5c, 0xf0, 0xbe, 0x2a, 0x56, 0x76, + 0x87, 0x3a, 0x66, 0x29, 0xa9, 0x69, 0x2f, 0x75, 0x70, 0x26}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x16, 0x21, 0x94, 0xa5, 0x91, 0xb6, 0x64, 0x4e, 0xf1, 0xee, 0x40, 0xb0, 0x90, - 0xb, 0xd2, 0x60, 0xf7, 0x64, 0x21, 0x75, 0xce, 0x85, 0xa7, 0xbe, 0x38}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xcb, 0x4e, 0x9a, 0x2, 0x58, 0x74, 0xf5, 0xdd, 0xee, 0x86, 0x20, 0x3f, 0x3d}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1a, 0xd1, 0xd8, 0xf8, 0x3a, 0xc8, 0xd7, 0x18, 0xea, 0x2, 0xee, 0xd8, 0x9f, - 0x51, 0xb7, 0xdd, 0x16, 0xad, 0x3c, 0xb6, 0x80, 0x8e, 0xa, 0x2c, 0xc}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1a, 0xcd}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x81, 0x3f, 0xa4, 0x61, 0x34, 0xe6, 0x93, 0xe8, - 0xb1, 0xe1, 0xe2, 0xf7, 0x83, 0xde, 0xcd, 0x5}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x12, 0x61, 0xba, 0x48, 0x8c, 0xac, 0x4e, 0x3c, 0x99, 0x4d, 0xfc, 0xab, 0xfc, - 0x4a, 0x69, 0x27, 0x13, 0xc, 0x33, 0x36, 0x1d, 0xec, 0x14, 0x74, 0xc8}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7b, 0xcc, 0xf4, 0x4f, 0xa2, 0x3e, 0x18, 0x39, 0x98, - 0xd1, 0x89, 0x2c, 0x5b, 0xab, 0xe3, 0xe1, 0x83, 0x25}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x29, 0x65, 0x4d, 0xda, 0x36, 0x98, 0x20, 0xca, 0xe7, 0x98, 0x4a, 0x8b}; - lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xc8, 0x5b, 0x11, 0x4f, 0xb0, 0xb5, 0x88}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd1, 0x66, 0x5, 0x21, 0xc3, 0xfb, 0x24, 0x5e, 0x37, 0x82, 0x94, 0x5f, - 0x14, 0xbd, 0xa7, 0xca, 0x73, 0xac, 0xd2, 0x95, 0xfe, 0xb5, 0x3d}; - lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x32, 0x61, 0xd8, 0x32, 0xb9, 0x8c, 0x69, 0x3d, 0xc7, 0xe0, - 0xfa, 0x33, 0xe6, 0x72, 0x14, 0xa1, 0x92, 0x82, 0x47}; - lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x88, 0x3, 0xb0, 0x7e, 0x82, 0x11, 0x22, 0xf1, 0xf, - 0x70, 0xfd, 0xbe, 0xa2, 0xdb, 0xb7, 0x60, 0xea}; - lwmqtt_string_t topic_filter_s10 = {17, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; + lwmqtt_sub_options_t sub_opts[3]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = true; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops0[] = {0x7, 0xad, 0x3a, 0xbd, 0x7b, 0x34, 0x10, 0xb1, - 0xe7, 0x64, 0xe7, 0x8b, 0xd6, 0xfe, 0xa0, 0x99}; - uint8_t bytesprops2[] = {0x60, 0x2e, 0x27, 0xca, 0xcb, 0xe7, 0xe5, 0x3f, 0x10, 0xa7, 0x9d, 0x86, 0xcc, - 0xb6, 0xb4, 0xe3, 0xd2, 0xc0, 0x39, 0x56, 0x8f, 0xd5, 0x59, 0x85, 0x76, 0x3d}; - uint8_t bytesprops3[] = {0x68, 0xf, 0xe4, 0xa0, 0x62, 0x19, 0x96, 0x97, 0x5a, 0x84, 0x6e, 0xd1, 0x6e, 0x62, 0x26, - 0x1c, 0x81, 0xef, 0x7c, 0x34, 0xd3, 0x33, 0x36, 0x5, 0xac, 0x87, 0x4b, 0x1a, 0x7a}; - uint8_t bytesprops4[] = {0x23, 0x3a, 0x2b, 0xe4, 0xeb, 0x59, 0xb7, 0xfa, - 0x21, 0x78, 0xc5, 0x7, 0x29, 0xe, 0x9a, 0xfe}; - uint8_t bytesprops6[] = {0x8, 0x15, 0x4f, 0x6a, 0x94, 0x88, 0xe3, 0xc9, 0xdd, 0x27, 0xc3, 0x6e, - 0x6a, 0x37, 0x17, 0xfe, 0xbc, 0x91, 0x75, 0x44, 0x83, 0x33, 0xbc, 0x37}; - uint8_t bytesprops5[] = {0x70, 0xee, 0xb8, 0x2c, 0xec, 0x1b, 0xc9, 0x33, 0xc7, 0xfe, 0x84, 0xf6, 0x79, 0xbb, - 0xaa, 0xd2, 0x7d, 0x21, 0xc, 0xa9, 0xf7, 0x54, 0xb8, 0x30, 0x46, 0x77, 0x8e}; - uint8_t bytesprops7[] = {0xa9, 0x34, 0x26, 0x74, 0x70, 0x38, 0x97, 0xb3, 0xb9}; - uint8_t bytesprops8[] = {0x1c, 0xe, 0x74, 0xdf, 0xe5, 0x52, 0xff}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5697}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24790}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops5}, .v = {24, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13893}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30246}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19007}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24216}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11251}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30523}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26783}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 174}}, - }; - - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22609, 11, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 5459 [("\167\&9\128\201\254\251f\154)\222\SYN\n\182w",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\v\244",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\NULV?\231o\214\r\141\181\DC4\236\139\166f\RS?B_",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\134\198\224\203\182\223E\204\128l\208\172\156\"\246",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\170b\195j\211}D\139\ESC\192\ACK9!\244F\140&1\143W\DC1Qy\211",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("p\NULm,\228\200\DLE\134\191V\174\192\SOHm\145H\RS\US\177\SIt\\",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\SOH\251cC\207\239\246\&5\202\158\vi\196\&1",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropTopicAlias 16179,PropSessionExpiryInterval -// 23734,PropMessageExpiryInterval 31667,PropServerReference "x-\231",PropRequestResponseInformation 128,PropContentType -// "\nR\215\219\165\142\208*\130\ACKh\ETX\202\179\141\150\165\252\173m\223p\139M^n\199>"] -TEST(Subscribe5QCTest, Encode27) { - uint8_t pkt[] = { - 0x82, 0xb9, 0x1, 0x15, 0x53, 0x34, 0x23, 0x3f, 0x33, 0x11, 0x0, 0x0, 0x5c, 0xb6, 0x2, 0x0, 0x0, 0x7b, 0xb3, - 0x1c, 0x0, 0x3, 0x78, 0x2d, 0xe7, 0x19, 0x80, 0x3, 0x0, 0x1c, 0xa, 0x52, 0xd7, 0xdb, 0xa5, 0x8e, 0xd0, 0x2a, - 0x82, 0x6, 0x68, 0x3, 0xca, 0xb3, 0x8d, 0x96, 0xa5, 0xfc, 0xad, 0x6d, 0xdf, 0x70, 0x8b, 0x4d, 0x5e, 0x6e, 0xc7, - 0x3e, 0x0, 0xe, 0xa7, 0x39, 0x80, 0xc9, 0xfe, 0xfb, 0x66, 0x9a, 0x29, 0xde, 0x16, 0xa, 0xb6, 0x77, 0xe, 0x0, - 0x2, 0xb, 0xf4, 0x24, 0x0, 0x12, 0x0, 0x56, 0x3f, 0xe7, 0x6f, 0xd6, 0xd, 0x8d, 0xb5, 0x14, 0xec, 0x8b, 0xa6, - 0x66, 0x1e, 0x3f, 0x42, 0x5f, 0x16, 0x0, 0xf, 0x86, 0xc6, 0xe0, 0xcb, 0xb6, 0xdf, 0x45, 0xcc, 0x80, 0x6c, 0xd0, - 0xac, 0x9c, 0x22, 0xf6, 0x4, 0x0, 0x18, 0xaa, 0x62, 0xc3, 0x6a, 0xd3, 0x7d, 0x44, 0x8b, 0x1b, 0xc0, 0x6, 0x39, - 0x21, 0xf4, 0x46, 0x8c, 0x26, 0x31, 0x8f, 0x57, 0x11, 0x51, 0x79, 0xd3, 0x6, 0x0, 0x16, 0x70, 0x0, 0x6d, 0x2c, - 0xe4, 0xc8, 0x10, 0x86, 0xbf, 0x56, 0xae, 0xc0, 0x1, 0x6d, 0x91, 0x48, 0x1e, 0x1f, 0xb1, 0xf, 0x74, 0x5c, 0x1d, - 0x0, 0xe, 0x1, 0xfb, 0x63, 0x43, 0xcf, 0xef, 0xf6, 0x35, 0xca, 0x9e, 0xb, 0x69, 0xc4, 0x31, 0x2e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xa7, 0x39, 0x80, 0xc9, 0xfe, 0xfb, 0x66, 0x9a, 0x29, 0xde, 0x16, 0xa, 0xb6, 0x77}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb, 0xf4}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x0, 0x56, 0x3f, 0xe7, 0x6f, 0xd6, 0xd, 0x8d, 0xb5, - 0x14, 0xec, 0x8b, 0xa6, 0x66, 0x1e, 0x3f, 0x42, 0x5f}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x86, 0xc6, 0xe0, 0xcb, 0xb6, 0xdf, 0x45, 0xcc, - 0x80, 0x6c, 0xd0, 0xac, 0x9c, 0x22, 0xf6}; - lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xaa, 0x62, 0xc3, 0x6a, 0xd3, 0x7d, 0x44, 0x8b, 0x1b, 0xc0, 0x6, 0x39, - 0x21, 0xf4, 0x46, 0x8c, 0x26, 0x31, 0x8f, 0x57, 0x11, 0x51, 0x79, 0xd3}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x70, 0x0, 0x6d, 0x2c, 0xe4, 0xc8, 0x10, 0x86, 0xbf, 0x56, 0xae, - 0xc0, 0x1, 0x6d, 0x91, 0x48, 0x1e, 0x1f, 0xb1, 0xf, 0x74, 0x5c}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x1, 0xfb, 0x63, 0x43, 0xcf, 0xef, 0xf6, 0x35, 0xca, 0x9e, 0xb, 0x69, 0xc4, 0x31}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; - uint8_t bytesprops0[] = {0x78, 0x2d, 0xe7}; - uint8_t bytesprops1[] = {0xa, 0x52, 0xd7, 0xdb, 0xa5, 0x8e, 0xd0, 0x2a, 0x82, 0x6, 0x68, 0x3, 0xca, 0xb3, - 0x8d, 0x96, 0xa5, 0xfc, 0xad, 0x6d, 0xdf, 0x70, 0x8b, 0x4d, 0x5e, 0x6e, 0xc7, 0x3e}; + uint8_t bytesprops0[] = {0xb3, 0x8c, 0x76, 0x6e, 0x35, 0x8e, 0x27, 0x9a, 0xd7, 0x6c, + 0x81, 0xab, 0x49, 0xaf, 0xbc, 0x18, 0x73, 0xac, 0x2f}; + uint8_t bytesprops1[] = {0xb2, 0x81, 0xf6, 0x57}; + uint8_t bytesprops2[] = {0x2a, 0x49, 0x45, 0xf5, 0xf0, 0xa7, 0x3c, 0x12, 0x20, 0xf7, 0x2d, 0x2, + 0xf1, 0xda, 0xb8, 0x6e, 0xe1, 0x79, 0x6c, 0x91, 0xb3, 0xa1, 0xbe, 0x91}; + uint8_t bytesprops3[] = {0xa5, 0x7c, 0x88, 0x91, 0x5a, 0x96, 0xf5, 0x46, 0x1f, 0x49, 0x2, 0x9a, + 0xe8, 0xe0, 0x9e, 0xa8, 0x1a, 0x5f, 0xa9, 0x13, 0xcc, 0xa9, 0x76}; + uint8_t bytesprops4[] = {0x15, 0x8f, 0x24, 0xeb}; + uint8_t bytesprops5[] = {0x6d, 0x1a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16179}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23734}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31667}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29237}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8231}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18717}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1110}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23125}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8589}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7606}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28011}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5459, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19375, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21650 -// [("\144\143\250\181?\222c\242\195\194iT\235\216\230\207\176(\169\205\175g\RS\221}V\US\206\228\167",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("r\242Fl\STX\222\224\199\213\254?\253\b\n\241\ESC\137f\252\ETX",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\188\213\&9\219v$\165F\194\195\157\155\193\DC2y\EM",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("Yk\181r6Q\f\148l\155\151\149\206I\133\&8\SOH\SOH\148\SUBaQ",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("D\191",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropReasonString "\137Iy\133 -// {*\EOT\v5\226\234\221\165\f",PropReasonString -// "\173\224=Tg\214o\ETXDLb\156t]t\ESCs\254]\DLE.",PropMessageExpiryInterval 4602,PropSessionExpiryInterval -// 17637,PropUserProperty "\207\190\248z6" -// "a\176\146]+\EOT\192h\NUL\165\248\229\249\183\200FI\157`\255\170\200\DC3\151\135\ENQ",PropAuthenticationData -// "\174A\SUB\182]\191\215,\167\DC2\US\227\ESC\182cJq\235!Y\158\v&\164\175\225O\233\210\157",PropRequestProblemInformation -// 120,PropWillDelayInterval 1152,PropMaximumPacketSize 13603,PropPayloadFormatIndicator 70,PropMaximumPacketSize -// 17285,PropContentType "2>D\246\r\139;A\182D s\254\207",PropResponseInformation "\185",PropAssignedClientIdentifier -// "\234!~]\191H\214"] +// SubscribeRequest 28027 [("\"g&\184\164\188M\DC4'tW=\211iw\223\142\177\135\221\193\212\ETX\235",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Ef\203H",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, +// _subQoS = QoS2}),("\174\&6\157\194{p\223\202\255Fi\201O\EM}\223\234$\EOTq\SYN\201\182\219\164:\136|x",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("m\t\200\200|++\177\DLE\DC4,\198\195:SP44\161-",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("cW\193\160\232\166\&8@\244 +// \"\SI\171\&5Ky\215;\131\US\243c\144\128\214\138",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\174\&7\208h4ML@\STX\167Mp\vQ\232\148\r\254\b\189\132\219}\235\155\131\\,\255",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\219\233",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\139\228'\CAN\224\233y\170z\235\168\b'\237\"\171\177",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropTopicAlias 17001,PropResponseInformation +// "\128\244\176\190\199\NAK-\183\186\184\225r\242\202c\237\DC2\251\233>f\220\DC2\146H\160\233\166q",PropRequestResponseInformation +// 123,PropAuthenticationMethod "\143\252\247S\189\RSE\165\190B\173Ab^\r \217\170\DLE\214\142]@V\165\&9\185L"] TEST(Subscribe5QCTest, Encode28) { - uint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, 0x4d, 0x14, 0x27, + 0x74, 0x57, 0x3d, 0xd3, 0x69, 0x77, 0xdf, 0x8e, 0xb1, 0x87, 0xdd, 0xc1, 0xd4, 0x3, 0xeb, 0x22, 0x0, + 0x4, 0x45, 0x66, 0xcb, 0x48, 0x2e, 0x0, 0x1d, 0xae, 0x36, 0x9d, 0xc2, 0x7b, 0x70, 0xdf, 0xca, 0xff, + 0x46, 0x69, 0xc9, 0x4f, 0x19, 0x7d, 0xdf, 0xea, 0x24, 0x4, 0x71, 0x16, 0xc9, 0xb6, 0xdb, 0xa4, 0x3a, + 0x88, 0x7c, 0x78, 0x12, 0x0, 0x14, 0x6d, 0x9, 0xc8, 0xc8, 0x7c, 0x2b, 0x2b, 0xb1, 0x10, 0x14, 0x2c, + 0xc6, 0xc3, 0x3a, 0x53, 0x50, 0x34, 0x34, 0xa1, 0x2d, 0x9, 0x0, 0x1a, 0x63, 0x57, 0xc1, 0xa0, 0xe8, + 0xa6, 0x38, 0x40, 0xf4, 0x20, 0x22, 0xf, 0xab, 0x35, 0x4b, 0x79, 0xd7, 0x3b, 0x83, 0x1f, 0xf3, 0x63, + 0x90, 0x80, 0xd6, 0x8a, 0x28, 0x0, 0x1d, 0xae, 0x37, 0xd0, 0x68, 0x34, 0x4d, 0x4c, 0x40, 0x2, 0xa7, + 0x4d, 0x70, 0xb, 0x51, 0xe8, 0x94, 0xd, 0xfe, 0x8, 0xbd, 0x84, 0xdb, 0x7d, 0xeb, 0x9b, 0x83, 0x5c, + 0x2c, 0xff, 0x1c, 0x0, 0x2, 0xdb, 0xe9, 0x9, 0x0, 0x11, 0x8b, 0xe4, 0x27, 0x18, 0xe0, 0xe9, 0x79, + 0xaa, 0x7a, 0xeb, 0xa8, 0x8, 0x27, 0xed, 0x22, 0xab, 0xb1, 0x19}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x90, 0x8f, 0xfa, 0xb5, 0x3f, 0xde, 0x63, 0xf2, 0xc3, 0xc2, - 0x69, 0x54, 0xeb, 0xd8, 0xe6, 0xcf, 0xb0, 0x28, 0xa9, 0xcd, - 0xaf, 0x67, 0x1e, 0xdd, 0x7d, 0x56, 0x1f, 0xce, 0xe4, 0xa7}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x22, 0x67, 0x26, 0xb8, 0xa4, 0xbc, 0x4d, 0x14, 0x27, 0x74, 0x57, 0x3d, + 0xd3, 0x69, 0x77, 0xdf, 0x8e, 0xb1, 0x87, 0xdd, 0xc1, 0xd4, 0x3, 0xeb}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x72, 0xf2, 0x46, 0x6c, 0x2, 0xde, 0xe0, 0xc7, 0xd5, 0xfe, - 0x3f, 0xfd, 0x8, 0xa, 0xf1, 0x1b, 0x89, 0x66, 0xfc, 0x3}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x45, 0x66, 0xcb, 0x48}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xae, 0x36, 0x9d, 0xc2, 0x7b, 0x70, 0xdf, 0xca, 0xff, 0x46, + 0x69, 0xc9, 0x4f, 0x19, 0x7d, 0xdf, 0xea, 0x24, 0x4, 0x71, + 0x16, 0xc9, 0xb6, 0xdb, 0xa4, 0x3a, 0x88, 0x7c, 0x78}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xbc, 0xd5, 0x39, 0xdb, 0x76, 0x24, 0xa5, 0x46, - 0xc2, 0xc3, 0x9d, 0x9b, 0xc1, 0x12, 0x79, 0x19}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6d, 0x9, 0xc8, 0xc8, 0x7c, 0x2b, 0x2b, 0xb1, 0x10, 0x14, + 0x2c, 0xc6, 0xc3, 0x3a, 0x53, 0x50, 0x34, 0x34, 0xa1, 0x2d}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x59, 0x6b, 0xb5, 0x72, 0x36, 0x51, 0xc, 0x94, 0x6c, 0x9b, 0x97, - 0x95, 0xce, 0x49, 0x85, 0x38, 0x1, 0x1, 0x94, 0x1a, 0x61, 0x51}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x63, 0x57, 0xc1, 0xa0, 0xe8, 0xa6, 0x38, 0x40, 0xf4, 0x20, 0x22, 0xf, 0xab, + 0x35, 0x4b, 0x79, 0xd7, 0x3b, 0x83, 0x1f, 0xf3, 0x63, 0x90, 0x80, 0xd6, 0x8a}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x44, 0xbf}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xae, 0x37, 0xd0, 0x68, 0x34, 0x4d, 0x4c, 0x40, 0x2, 0xa7, + 0x4d, 0x70, 0xb, 0x51, 0xe8, 0x94, 0xd, 0xfe, 0x8, 0xbd, + 0x84, 0xdb, 0x7d, 0xeb, 0x9b, 0x83, 0x5c, 0x2c, 0xff}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0xdb, 0xe9}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x8b, 0xe4, 0x27, 0x18, 0xe0, 0xe9, 0x79, 0xaa, 0x7a, + 0xeb, 0xa8, 0x8, 0x27, 0xed, 0x22, 0xab, 0xb1}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; + sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = true; sub_opts[5].no_local = true; - uint8_t bytesprops0[] = {0x89, 0x49, 0x79, 0x85, 0x20, 0x7b, 0x2a, 0x4, 0xb, 0x35, 0xe2, 0xea, 0xdd, 0xa5, 0xc}; - uint8_t bytesprops1[] = {0xad, 0xe0, 0x3d, 0x54, 0x67, 0xd6, 0x6f, 0x3, 0x44, 0x4c, 0x62, - 0x9c, 0x74, 0x5d, 0x74, 0x1b, 0x73, 0xfe, 0x5d, 0x10, 0x2e}; - uint8_t bytesprops3[] = {0x61, 0xb0, 0x92, 0x5d, 0x2b, 0x4, 0xc0, 0x68, 0x0, 0xa5, 0xf8, 0xe5, 0xf9, - 0xb7, 0xc8, 0x46, 0x49, 0x9d, 0x60, 0xff, 0xaa, 0xc8, 0x13, 0x97, 0x87, 0x5}; - uint8_t bytesprops2[] = {0xcf, 0xbe, 0xf8, 0x7a, 0x36}; - uint8_t bytesprops4[] = {0xae, 0x41, 0x1a, 0xb6, 0x5d, 0xbf, 0xd7, 0x2c, 0xa7, 0x12, 0x1f, 0xe3, 0x1b, 0xb6, 0x63, - 0x4a, 0x71, 0xeb, 0x21, 0x59, 0x9e, 0xb, 0x26, 0xa4, 0xaf, 0xe1, 0x4f, 0xe9, 0xd2, 0x9d}; - uint8_t bytesprops5[] = {0x32, 0x3e, 0x44, 0xf6, 0xd, 0x8b, 0x3b, 0x41, 0xb6, 0x44, 0x20, 0x73, 0xfe, 0xcf}; - uint8_t bytesprops6[] = {0xb9}; - uint8_t bytesprops7[] = {0xea, 0x21, 0x7e, 0x5d, 0xbf, 0x48, 0xd6}; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + uint8_t bytesprops0[] = {0x80, 0xf4, 0xb0, 0xbe, 0xc7, 0x15, 0x2d, 0xb7, 0xba, 0xb8, 0xe1, 0x72, 0xf2, 0xca, 0x63, + 0xed, 0x12, 0xfb, 0xe9, 0x3e, 0x66, 0xdc, 0x12, 0x92, 0x48, 0xa0, 0xe9, 0xa6, 0x71}; + uint8_t bytesprops1[] = {0x8f, 0xfc, 0xf7, 0x53, 0xbd, 0x1e, 0x45, 0xa5, 0xbe, 0x42, 0xad, 0x41, 0x62, 0x5e, + 0xd, 0x20, 0xd9, 0xaa, 0x10, 0xd6, 0x8e, 0x5d, 0x40, 0x56, 0xa5, 0x39, 0xb9, 0x4c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4602}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17637}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops2}, .v = {26, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1152}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13603}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17285}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17001}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21650, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28027, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15109 [("\175\231\162\204$\151/\218\&0m\229",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] [PropMaximumQoS 184,PropRequestProblemInformation -// 57,PropReasonString "[l3g\145n\246s",PropAuthenticationData "\NUL}\192\220",PropRetainAvailable 171,PropReasonString -// "8\130\150\188\246\243\SO\177\172\150\235,\255EsB\181\134+}",PropWillDelayInterval 4975] +// SubscribeRequest 16403 [("36\t\GS\147",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS1}),("\219(\232\129\147/\NAKI\148\189\191\241l\207\134M; +// \146\255\164\SI\129\251\252g\253\DLE=",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("\178]k\204\209\202\239\157m\227\SI\182M\tft\NUL?\184]}\128\149%\202\234",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),(",\249N\129\196\212+ft,\180\v\166\t\164j\DEL\ETB\SYNC\244GIO\203\176\180|\148",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropRequestProblemInformation +// 104,PropMessageExpiryInterval 8176,PropServerReference +// "$;3O@\155\252;\218*\227\DC2\171A\142~\169\&4\154i\ETX\FS\134\216\215\200\FS.",PropTopicAlias 3118,PropMaximumQoS +// 36,PropAuthenticationData "\146\t",PropResponseTopic +// "\153\138\ETBB\224C\196\174\224\ESC\EOT\249\vHT\163/\208e\192\215\&1\238\213\179O\224",PropTopicAlias +// 3095,PropReasonString +// "\212U\142\147\208\216\242\NAK\212\160\153\198\149\205\216\n\154\171\SUB\146\135:`:\186\SO\178B\GS\192",PropSharedSubscriptionAvailable +// 17,PropSubscriptionIdentifier 16,PropMessageExpiryInterval 4489,PropReceiveMaximum 32086,PropTopicAliasMaximum +// 29734,PropWillDelayInterval 24777,PropMaximumQoS 102,PropServerReference +// "\189\DLE\136lf\172\162ON",PropSubscriptionIdentifierAvailable 80,PropRequestProblemInformation +// 86,PropRetainAvailable 104,PropSharedSubscriptionAvailable 21,PropMaximumQoS 169,PropServerReference +// "\ETX9\150\170\210\235",PropAuthenticationData +// "\165`\DC1\240\DEL\STX\FS\EMH\CAN\179\197\147\249\215\209.\223\DC1\t\162o\164",PropRetainAvailable +// 155,PropUserProperty "\\\194\166?\"\207\143&hS\150\&2\193\180\162W\v" +// "\167\144AL,\160\184\231\185\231\ESC\209\&3\132\208\STXO\DLE\158b",PropSubscriptionIdentifier +// 28,PropMessageExpiryInterval 25290,PropServerReference "\159\235\tf +// ~\148\239\212\243e4iyG\177\198,\177o\218\228fb\182y\141\205P",PropAssignedClientIdentifier +// "\189\ESC!O\GS\248\FS\224^X\ETB}\142\DC4\DC1|T\243\226\218\145d\232\191\153[\129\253\ACK\ETX"] TEST(Subscribe5QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0x45, 0x3b, 0x5, 0x34, 0x24, 0xb8, 0x17, 0x39, 0x1f, 0x0, 0x8, 0x5b, 0x6c, 0x33, - 0x67, 0x91, 0x6e, 0xf6, 0x73, 0x16, 0x0, 0x4, 0x0, 0x7d, 0xc0, 0xdc, 0x25, 0xab, 0x1f, - 0x0, 0x14, 0x38, 0x82, 0x96, 0xbc, 0xf6, 0xf3, 0xe, 0xb1, 0xac, 0x96, 0xeb, 0x2c, 0xff, - 0x45, 0x73, 0x42, 0xb5, 0x86, 0x2b, 0x7d, 0x18, 0x0, 0x0, 0x13, 0x6f, 0x0, 0xb, 0xaf, - 0xe7, 0xa2, 0xcc, 0x24, 0x97, 0x2f, 0xda, 0x30, 0x6d, 0xe5, 0xc}; + uint8_t pkt[] = { + 0x82, 0x9e, 0x3, 0x40, 0x13, 0xb5, 0x2, 0x17, 0x68, 0x2, 0x0, 0x0, 0x1f, 0xf0, 0x1c, 0x0, 0x1c, 0x24, 0x3b, + 0x33, 0x4f, 0x40, 0x9b, 0xfc, 0x3b, 0xda, 0x2a, 0xe3, 0x12, 0xab, 0x41, 0x8e, 0x7e, 0xa9, 0x34, 0x9a, 0x69, 0x3, + 0x1c, 0x86, 0xd8, 0xd7, 0xc8, 0x1c, 0x2e, 0x23, 0xc, 0x2e, 0x24, 0x24, 0x16, 0x0, 0x2, 0x92, 0x9, 0x8, 0x0, + 0x1b, 0x99, 0x8a, 0x17, 0x42, 0xe0, 0x43, 0xc4, 0xae, 0xe0, 0x1b, 0x4, 0xf9, 0xb, 0x48, 0x54, 0xa3, 0x2f, 0xd0, + 0x65, 0xc0, 0xd7, 0x31, 0xee, 0xd5, 0xb3, 0x4f, 0xe0, 0x23, 0xc, 0x17, 0x1f, 0x0, 0x1e, 0xd4, 0x55, 0x8e, 0x93, + 0xd0, 0xd8, 0xf2, 0x15, 0xd4, 0xa0, 0x99, 0xc6, 0x95, 0xcd, 0xd8,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x1c, 0xe0, 0x5e, 0x58, 0x17, 0x7d, 0x8e, 0x14, 0x11, 0x7c, 0x54, 0xf3, + 0xe2, 0xda, 0x91, 0x64, 0xe8, 0xbf, 0x99, 0x5b, 0x81, 0xfd, 0x6, 0x3, 0x0, 0x5, 0x33, 0x36, 0x9, 0x1d, 0x93, + 0x19, 0x0, 0x1d, 0xdb, 0x28, 0xe8, 0x81, 0x93, 0x2f, 0x15, 0x49, 0x94, 0xbd, 0xbf, 0xf1, 0x6c, 0xcf, 0x86, 0x4d, + 0x3b, 0x20, 0x92, 0xff, 0xa4, 0xf, 0x81, 0xfb, 0xfc, 0x67, 0xfd, 0x10, 0x3d, 0x22, 0x0, 0x1a, 0xb2, 0x5d, 0x6b, + 0xcc, 0xd1, 0xca, 0xef, 0x9d, 0x6d, 0xe3, 0xf, 0xb6, 0x4d, 0x9, 0x66, 0x74, 0x0, 0x3f, 0xb8, 0x5d, 0x7d, 0x80, + 0x95, 0x25, 0xca, 0xea, 0x2, 0x0, 0x1d, 0x2c, 0xf9, 0x4e, 0x81, 0xc4, 0xd4, 0x2b, 0x66, 0x74, 0x2c, 0xb4, 0xb, + 0xa6, 0x9, 0xa4, 0x6a, 0x7f, 0x17, 0x16, 0x43, 0xf4, 0x47, 0x49, 0x4f, 0xcb, 0xb0, 0xb4, 0x7c, 0x94, 0x20}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xaf, 0xe7, 0xa2, 0xcc, 0x24, 0x97, 0x2f, 0xda, 0x30, 0x6d, 0xe5}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x33, 0x36, 0x9, 0x1d, 0x93}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + uint8_t topic_filter_s1_bytes[] = {0xdb, 0x28, 0xe8, 0x81, 0x93, 0x2f, 0x15, 0x49, 0x94, 0xbd, + 0xbf, 0xf1, 0x6c, 0xcf, 0x86, 0x4d, 0x3b, 0x20, 0x92, 0xff, + 0xa4, 0xf, 0x81, 0xfb, 0xfc, 0x67, 0xfd, 0x10, 0x3d}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xb2, 0x5d, 0x6b, 0xcc, 0xd1, 0xca, 0xef, 0x9d, 0x6d, 0xe3, 0xf, 0xb6, 0x4d, + 0x9, 0x66, 0x74, 0x0, 0x3f, 0xb8, 0x5d, 0x7d, 0x80, 0x95, 0x25, 0xca, 0xea}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x2c, 0xf9, 0x4e, 0x81, 0xc4, 0xd4, 0x2b, 0x66, 0x74, 0x2c, + 0xb4, 0xb, 0xa6, 0x9, 0xa4, 0x6a, 0x7f, 0x17, 0x16, 0x43, + 0xf4, 0x47, 0x49, 0x4f, 0xcb, 0xb0, 0xb4, 0x7c, 0x94}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - uint8_t bytesprops0[] = {0x5b, 0x6c, 0x33, 0x67, 0x91, 0x6e, 0xf6, 0x73}; - uint8_t bytesprops1[] = {0x0, 0x7d, 0xc0, 0xdc}; - uint8_t bytesprops2[] = {0x38, 0x82, 0x96, 0xbc, 0xf6, 0xf3, 0xe, 0xb1, 0xac, 0x96, - 0xeb, 0x2c, 0xff, 0x45, 0x73, 0x42, 0xb5, 0x86, 0x2b, 0x7d}; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + uint8_t bytesprops0[] = {0x24, 0x3b, 0x33, 0x4f, 0x40, 0x9b, 0xfc, 0x3b, 0xda, 0x2a, 0xe3, 0x12, 0xab, 0x41, + 0x8e, 0x7e, 0xa9, 0x34, 0x9a, 0x69, 0x3, 0x1c, 0x86, 0xd8, 0xd7, 0xc8, 0x1c, 0x2e}; + uint8_t bytesprops1[] = {0x92, 0x9}; + uint8_t bytesprops2[] = {0x99, 0x8a, 0x17, 0x42, 0xe0, 0x43, 0xc4, 0xae, 0xe0, 0x1b, 0x4, 0xf9, 0xb, 0x48, + 0x54, 0xa3, 0x2f, 0xd0, 0x65, 0xc0, 0xd7, 0x31, 0xee, 0xd5, 0xb3, 0x4f, 0xe0}; + uint8_t bytesprops3[] = {0xd4, 0x55, 0x8e, 0x93, 0xd0, 0xd8, 0xf2, 0x15, 0xd4, 0xa0, 0x99, 0xc6, 0x95, 0xcd, 0xd8, + 0xa, 0x9a, 0xab, 0x1a, 0x92, 0x87, 0x3a, 0x60, 0x3a, 0xba, 0xe, 0xb2, 0x42, 0x1d, 0xc0}; + uint8_t bytesprops4[] = {0xbd, 0x10, 0x88, 0x6c, 0x66, 0xac, 0xa2, 0x4f, 0x4e}; + uint8_t bytesprops5[] = {0x3, 0x39, 0x96, 0xaa, 0xd2, 0xeb}; + uint8_t bytesprops6[] = {0xa5, 0x60, 0x11, 0xf0, 0x7f, 0x2, 0x1c, 0x19, 0x48, 0x18, 0xb3, 0xc5, + 0x93, 0xf9, 0xd7, 0xd1, 0x2e, 0xdf, 0x11, 0x9, 0xa2, 0x6f, 0xa4}; + uint8_t bytesprops8[] = {0xa7, 0x90, 0x41, 0x4c, 0x2c, 0xa0, 0xb8, 0xe7, 0xb9, 0xe7, + 0x1b, 0xd1, 0x33, 0x84, 0xd0, 0x2, 0x4f, 0x10, 0x9e, 0x62}; + uint8_t bytesprops7[] = {0x5c, 0xc2, 0xa6, 0x3f, 0x22, 0xcf, 0x8f, 0x26, 0x68, + 0x53, 0x96, 0x32, 0xc1, 0xb4, 0xa2, 0x57, 0xb}; + uint8_t bytesprops9[] = {0x9f, 0xeb, 0x9, 0x66, 0x20, 0x7e, 0x94, 0xef, 0xd4, 0xf3, 0x65, 0x34, 0x69, 0x79, 0x47, + 0xb1, 0xc6, 0x2c, 0xb1, 0x6f, 0xda, 0xe4, 0x66, 0x62, 0xb6, 0x79, 0x8d, 0xcd, 0x50}; + uint8_t bytesprops10[] = {0xbd, 0x1b, 0x21, 0x4f, 0x1d, 0xf8, 0x1c, 0xe0, 0x5e, 0x58, 0x17, 0x7d, 0x8e, 0x14, 0x11, + 0x7c, 0x54, 0xf3, 0xe2, 0xda, 0x91, 0x64, 0xe8, 0xbf, 0x99, 0x5b, 0x81, 0xfd, 0x6, 0x3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4975}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8176}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3118}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3095}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4489}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32086}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29734}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24777}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops7}, .v = {20, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25290}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15109, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16403, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 31149 [("(\255\220",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS0}),("nuB\184\220_5\217\196}\246\129",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\n?*\177\237",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\166\247\163\135\239\140E\178R\230-\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS1}),("z\250o\254y\a\a,\201+#\222\212\164\CAN\DC1\184\138\217",SubOptions +// SubscribeRequest 25747 [(":\163i\190\141\188d\208\&4\STX\b\EMn\ETB.y\192\230kO\177\204'\156\206",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ESC\220\r4\ak\135",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal -// = True, _subQoS = QoS2})] [PropPayloadFormatIndicator 79,PropSessionExpiryInterval -// 9736,PropSubscriptionIdentifierAvailable 116,PropPayloadFormatIndicator 214,PropRequestProblemInformation -// 5,PropServerReference "ri",PropCorrelationData "\214\216\SO\234M&\242\140\206\t\230",PropMessageExpiryInterval -// 17300,PropWillDelayInterval 32083,PropMaximumQoS 189] +// QoS1}),("\184\200\144sIg\248\r\181<\187\NUL\207\160Y\137I\224\151]U'g[\v\ACKr",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\136\159\161\ETB\151\211$\128E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("v\ay\rA\210\DC2\243",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("e\174q\139U\145\139 +// \140\238i\152?\244\239\ACKBN\248\218\188\238\DELu\EOT\ENQ/",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),(",\196\144\&6$\US\DC3\212\195n\RS\149\140\204}\235\149\DC2\234\254\f",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("[\241\133m#\240#\175",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropTopicAlias +// 9871,PropWildcardSubscriptionAvailable 245,PropSubscriptionIdentifierAvailable 153,PropReasonString +// "\189\225K\201\t>\DC3{\215\199\185K\EOTM\172Q\128\150\208[\128\164\149",PropUserProperty ",bEZ\239\ESC\SOH\148_\ETXo" +// "A:I\242\215o\237\194\183\224\133",PropUserProperty "\129\183 \220\212\DC4']\180\247\ACK" +// "\140W\224.P\SYNpR\a\236$~\254\137\204\150",PropReceiveMaximum 32665,PropServerKeepAlive 9559,PropRetainAvailable +// 138] TEST(Subscribe5QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x7b, 0x79, 0xad, 0x2c, 0x1, 0x4f, 0x11, 0x0, 0x0, 0x26, 0x8, 0x29, 0x74, 0x1, 0xd6, - 0x17, 0x5, 0x1c, 0x0, 0x2, 0x72, 0x69, 0x9, 0x0, 0xb, 0xd6, 0xd8, 0xe, 0xea, 0x4d, 0x26, - 0xf2, 0x8c, 0xce, 0x9, 0xe6, 0x2, 0x0, 0x0, 0x43, 0x94, 0x18, 0x0, 0x0, 0x7d, 0x53, 0x24, - 0xbd, 0x0, 0x3, 0x28, 0xff, 0xdc, 0x18, 0x0, 0xc, 0x6e, 0x75, 0x42, 0xb8, 0xdc, 0x5f, 0x35, - 0xd9, 0xc4, 0x7d, 0xf6, 0x81, 0x20, 0x0, 0x5, 0xa, 0x3f, 0x2a, 0xb1, 0xed, 0x2d, 0x0, 0xc, - 0xa6, 0xf7, 0xa3, 0x87, 0xef, 0x8c, 0x45, 0xb2, 0x52, 0xe6, 0x2d, 0x98, 0x5, 0x0, 0x13, 0x7a, - 0xfa, 0x6f, 0xfe, 0x79, 0x7, 0x7, 0x2c, 0xc9, 0x2b, 0x23, 0xde, 0xd4, 0xa4, 0x18, 0x11, 0xb8, - 0x8a, 0xd9, 0x2, 0x0, 0x7, 0x1b, 0xdc, 0xd, 0x34, 0x7, 0x6b, 0x87, 0x2e}; + uint8_t pkt[] = {0x82, 0xfc, 0x1, 0x64, 0x93, 0x64, 0x23, 0x26, 0x8f, 0x28, 0xf5, 0x29, 0x99, 0x1f, 0x0, 0x17, 0xbd, + 0xe1, 0x4b, 0xc9, 0x9, 0x3e, 0x13, 0x7b, 0xd7, 0xc7, 0xb9, 0x4b, 0x4, 0x4d, 0xac, 0x51, 0x80, 0x96, + 0xd0, 0x5b, 0x80, 0xa4, 0x95, 0x26, 0x0, 0xb, 0x2c, 0x62, 0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 0x1e, 0x95, 0x8c, 0xcc, 0x7d, 0xeb, + 0x95, 0x12, 0xea, 0xfe, 0xc, 0x1c, 0x0, 0x8, 0x5b, 0xf1, 0x85, 0x6d, 0x23, 0xf0, 0x23, 0xaf, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x28, 0xff, 0xdc}; - lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x3a, 0xa3, 0x69, 0xbe, 0x8d, 0xbc, 0x64, 0xd0, 0x34, 0x2, 0x8, 0x19, 0x6e, + 0x17, 0x2e, 0x79, 0xc0, 0xe6, 0x6b, 0x4f, 0xb1, 0xcc, 0x27, 0x9c, 0xce}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6e, 0x75, 0x42, 0xb8, 0xdc, 0x5f, 0x35, 0xd9, 0xc4, 0x7d, 0xf6, 0x81}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb8, 0xc8, 0x90, 0x73, 0x49, 0x67, 0xf8, 0xd, 0xb5, 0x3c, 0xbb, 0x0, 0xcf, 0xa0, + 0x59, 0x89, 0x49, 0xe0, 0x97, 0x5d, 0x55, 0x27, 0x67, 0x5b, 0xb, 0x6, 0x72}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa, 0x3f, 0x2a, 0xb1, 0xed}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa6, 0xf7, 0xa3, 0x87, 0xef, 0x8c, 0x45, 0xb2, 0x52, 0xe6, 0x2d, 0x98}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x88, 0x9f, 0xa1, 0x17, 0x97, 0xd3, 0x24, 0x80, 0x45}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7a, 0xfa, 0x6f, 0xfe, 0x79, 0x7, 0x7, 0x2c, 0xc9, 0x2b, - 0x23, 0xde, 0xd4, 0xa4, 0x18, 0x11, 0xb8, 0x8a, 0xd9}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x76, 0x7, 0x79, 0xd, 0x41, 0xd2, 0x12, 0xf3}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1b, 0xdc, 0xd, 0x34, 0x7, 0x6b, 0x87}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x65, 0xae, 0x71, 0x8b, 0x55, 0x91, 0x8b, 0x20, 0x8c, 0xee, 0x69, 0x98, 0x3f, 0xf4, + 0xef, 0x6, 0x42, 0x4e, 0xf8, 0xda, 0xbc, 0xee, 0x7f, 0x75, 0x4, 0x5, 0x2f}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; + uint8_t topic_filter_s6_bytes[] = {0x2c, 0xc4, 0x90, 0x36, 0x24, 0x1f, 0x13, 0xd4, 0xc3, 0x6e, 0x1e, + 0x95, 0x8c, 0xcc, 0x7d, 0xeb, 0x95, 0x12, 0xea, 0xfe, 0xc}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x5b, 0xf1, 0x85, 0x6d, 0x23, 0xf0, 0x23, 0xaf}; + lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[5].retain_as_published = true; sub_opts[5].no_local = true; - uint8_t bytesprops0[] = {0x72, 0x69}; - uint8_t bytesprops1[] = {0xd6, 0xd8, 0xe, 0xea, 0x4d, 0x26, 0xf2, 0x8c, 0xce, 0x9, 0xe6}; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + uint8_t bytesprops0[] = {0xbd, 0xe1, 0x4b, 0xc9, 0x9, 0x3e, 0x13, 0x7b, 0xd7, 0xc7, 0xb9, 0x4b, + 0x4, 0x4d, 0xac, 0x51, 0x80, 0x96, 0xd0, 0x5b, 0x80, 0xa4, 0x95}; + uint8_t bytesprops2[] = {0x41, 0x3a, 0x49, 0xf2, 0xd7, 0x6f, 0xed, 0xc2, 0xb7, 0xe0, 0x85}; + uint8_t bytesprops1[] = {0x2c, 0x62, 0x45, 0x5a, 0xef, 0x1b, 0x1, 0x94, 0x5f, 0x3, 0x6f}; + uint8_t bytesprops4[] = {0x8c, 0x57, 0xe0, 0x2e, 0x50, 0x16, 0x70, 0x52, + 0x7, 0xec, 0x24, 0x7e, 0xfe, 0x89, 0xcc, 0x96}; + uint8_t bytesprops3[] = {0x81, 0xb7, 0x20, 0xdc, 0xd4, 0x14, 0x27, 0x5d, 0xb4, 0xf7, 0x6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9736}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17300}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32083}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9871}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops3}, .v = {16, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32665}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9559}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 138}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31149, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25747, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeResponse 13080 [Right QoS1,Right QoS0,Left SubErrNotAuthorized,Left SubErrNotAuthorized,Right QoS1,Right -// QoS1,Left SubErrPacketIdentifierInUse,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS0] [] +// SubscribeResponse 8450 [Right QoS0] [] TEST(SubACK311QCTest, Decode1) { - uint8_t pkt[] = {0x90, 0xd, 0x33, 0x18, 0x1, 0x0, 0x87, 0x87, 0x1, 0x1, 0x91, 0x2, 0x2, 0x8f, 0x0}; + uint8_t pkt[] = {0x90, 0x3, 0x21, 0x2, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13080); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], 0x80); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 8450); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); } -// SubscribeResponse 32460 [Left SubErrImplementationSpecificError,Right QoS2,Right QoS0,Left -// SubErrUnspecifiedError,Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrUnspecifiedError,Left -// SubErrUnspecifiedError,Right QoS2,Right QoS1,Right QoS2] [] +// SubscribeResponse 20275 [Right QoS2,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Right QoS2,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Right QoS2] [] TEST(SubACK311QCTest, Decode2) { - uint8_t pkt[] = {0x90, 0xd, 0x7e, 0xcc, 0x83, 0x2, 0x0, 0x80, 0x2, 0x91, 0x80, 0x80, 0x2, 0x1, 0x2}; + uint8_t pkt[] = {0x90, 0xb, 0x4f, 0x33, 0x2, 0x0, 0x97, 0x0, 0x2, 0x9e, 0x97, 0x80, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32460); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(packet_id, 20275); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[5], 0x80); EXPECT_EQ(granted_qos_levels[6], 0x80); EXPECT_EQ(granted_qos_levels[7], 0x80); EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); } -// SubscribeResponse 7819 [Right QoS2,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] [] +// SubscribeResponse 3848 [Right QoS0,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Right QoS2,Left +// SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError,Right QoS1,Right QoS0] [] TEST(SubACK311QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0x5, 0x1e, 0x8b, 0x2, 0x1, 0xa2}; + uint8_t pkt[] = {0x90, 0xb, 0xf, 0x8, 0x0, 0x97, 0x80, 0x2, 0x91, 0x87, 0x83, 0x1, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7819); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 3848); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); } -// SubscribeResponse 17369 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left SubErrTopicFilterInvalid] [] +// SubscribeResponse 21048 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrUnspecifiedError,Right QoS1,Left SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0x5, 0x43, 0xd9, 0x2, 0x9e, 0x8f}; + uint8_t pkt[] = {0x90, 0x8, 0x52, 0x38, 0xa2, 0x2, 0xa1, 0x80, 0x1, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17369); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(packet_id, 21048); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); } -// SubscribeResponse 14645 [Right QoS0,Left SubErrTopicFilterInvalid,Right QoS1,Left SubErrTopicFilterInvalid,Right -// QoS1,Right QoS2,Right QoS0] [] +// SubscribeResponse 24181 [Right QoS0,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS0] [] TEST(SubACK311QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0x9, 0x39, 0x35, 0x0, 0x8f, 0x1, 0x8f, 0x1, 0x2, 0x0}; + uint8_t pkt[] = {0x90, 0x6, 0x5e, 0x75, 0x0, 0x80, 0x87, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14645); - EXPECT_EQ(count, 7); + EXPECT_EQ(packet_id, 24181); + EXPECT_EQ(count, 4); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); } -// SubscribeResponse 12295 [Left SubErrPacketIdentifierInUse,Right QoS0,Left SubErrTopicFilterInvalid,Right QoS2] [] +// SubscribeResponse 29704 [Right QoS2,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS0,Right +// QoS1] [] TEST(SubACK311QCTest, Decode6) { - uint8_t pkt[] = {0x90, 0x6, 0x30, 0x7, 0x91, 0x0, 0x8f, 0x2}; + uint8_t pkt[] = {0x90, 0x8, 0x74, 0x8, 0x2, 0x1, 0x9e, 0x0, 0x0, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12295); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 29704); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 10100 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Right QoS0,Left -// SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS2,Right QoS2,Left -// SubErrPacketIdentifierInUse,Right QoS2,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError] [] +// SubscribeResponse 8 [Right QoS2] [] TEST(SubACK311QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0xd, 0x27, 0x74, 0xa1, 0x0, 0x0, 0xa2, 0x80, 0x2, 0x2, 0x91, 0x2, 0x97, 0x80}; + uint8_t pkt[] = {0x90, 0x3, 0x0, 0x8, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10100); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], 0x80); - EXPECT_EQ(granted_qos_levels[10], 0x80); + EXPECT_EQ(packet_id, 8); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); } -// SubscribeResponse 19212 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Left -// SubErrImplementationSpecificError,Right QoS0,Right QoS2,Right QoS0,Left SubErrPacketIdentifierInUse] [] +// SubscribeResponse 24329 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Right QoS2,Right QoS0,Right QoS0,Right +// QoS1,Right QoS2] [] TEST(SubACK311QCTest, Decode8) { - uint8_t pkt[] = {0x90, 0x9, 0x4b, 0xc, 0xa1, 0x1, 0x83, 0x0, 0x2, 0x0, 0x91}; + uint8_t pkt[] = {0x90, 0xc, 0x5f, 0x9, 0x2, 0x9e, 0xa2, 0x80, 0x0, 0x2, 0x0, 0x0, 0x1, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19212); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 24329); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); } -// SubscribeResponse 31570 [Left SubErrTopicFilterInvalid] [] +// SubscribeResponse 10189 [Left SubErrImplementationSpecificError,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS2,Left SubErrUnspecifiedError,Right QoS1,Left +// SubErrImplementationSpecificError,Right QoS2,Left SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left +// SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode9) { - uint8_t pkt[] = {0x90, 0x3, 0x7b, 0x52, 0x8f}; + uint8_t pkt[] = {0x90, 0xd, 0x27, 0xcd, 0x83, 0x0, 0x9e, 0x2, 0x80, 0x1, 0x83, 0x2, 0x83, 0x97, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 31570); - EXPECT_EQ(count, 1); + EXPECT_EQ(packet_id, 10189); + EXPECT_EQ(count, 11); EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 15416 [Right QoS1,Left SubErrQuotaExceeded,Left SubErrTopicFilterInvalid,Right QoS1,Left -// SubErrWildcardSubscriptionsNotSupported] [] +// SubscribeResponse 11213 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right QoS0,Right +// QoS0,Right QoS0,Right QoS2,Left SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0x7, 0x3c, 0x38, 0x1, 0x97, 0x8f, 0x1, 0xa2}; + uint8_t pkt[] = {0x90, 0x9, 0x2b, 0xcd, 0x9e, 0x97, 0x0, 0x0, 0x0, 0x2, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15416); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 11213); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); } -// SubscribeResponse 24411 [Right QoS2,Left SubErrImplementationSpecificError,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse] -// [] +// SubscribeResponse 16288 [Right QoS0,Right QoS1,Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Left +// SubErrNotAuthorized,Right QoS1,Right QoS1,Right QoS2,Left SubErrNotAuthorized] [] TEST(SubACK311QCTest, Decode11) { - uint8_t pkt[] = {0x90, 0x7, 0x5f, 0x5b, 0x2, 0x83, 0x9e, 0xa2, 0x91}; + uint8_t pkt[] = {0x90, 0xb, 0x3f, 0xa0, 0x0, 0x1, 0x80, 0x80, 0x87, 0x1, 0x1, 0x2, 0x87}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24411); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(packet_id, 16288); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], 0x80); } -// SubscribeResponse 16797 [Right QoS0,Right QoS0,Right QoS1,Right QoS2,Left SubErrUnspecifiedError,Right QoS0,Right -// QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrNotAuthorized,Left -// SubErrSubscriptionIdentifiersNotSupported] [] +// SubscribeResponse 12823 [Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode12) { - uint8_t pkt[] = {0x90, 0xc, 0x41, 0x9d, 0x0, 0x0, 0x1, 0x2, 0x80, 0x0, 0x0, 0x9e, 0x87, 0xa1}; + uint8_t pkt[] = {0x90, 0x6, 0x32, 0x17, 0x8f, 0xa1, 0x0, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 16797); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(packet_id, 12823); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x80); } -// SubscribeResponse 8011 [Right QoS0,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Left -// SubErrTopicFilterInvalid,Right QoS2] [] +// SubscribeResponse 27996 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS2,Left +// SubErrImplementationSpecificError,Right QoS1,Right QoS2,Left SubErrUnspecifiedError,Left +// SubErrTopicFilterInvalid,Left SubErrPacketIdentifierInUse,Left SubErrSharedSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode13) { - uint8_t pkt[] = {0x90, 0x8, 0x1f, 0x4b, 0x0, 0x2, 0x2, 0x8f, 0x8f, 0x2}; + uint8_t pkt[] = {0x90, 0xc, 0x6d, 0x5c, 0x9e, 0x2, 0x2, 0x83, 0x1, 0x2, 0x80, 0x8f, 0x91, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8011); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 27996); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], 0x80); } -// SubscribeResponse 32745 [Right QoS0,Right QoS2,Right QoS1,Left SubErrNotAuthorized,Right QoS0,Right QoS2,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS2] [] +// SubscribeResponse 30878 [Left SubErrUnspecifiedError,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left +// SubErrTopicFilterInvalid,Right QoS0] [] TEST(SubACK311QCTest, Decode14) { - uint8_t pkt[] = {0x90, 0xa, 0x7f, 0xe9, 0x0, 0x2, 0x1, 0x87, 0x0, 0x2, 0xa2, 0x2}; + uint8_t pkt[] = {0x90, 0xa, 0x78, 0x9e, 0x80, 0x1, 0xa2, 0x80, 0xa2, 0x80, 0x8f, 0x0}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[8]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32745); + EXPECT_EQ(packet_id, 30878); EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); } -// SubscribeResponse 8548 [Right QoS1,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS0] [] +// SubscribeResponse 7754 [Right QoS0,Right QoS2,Right QoS1,Right QoS1,Right QoS1,Right QoS2,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS0,Right QoS1,Left +// SubErrSubscriptionIdentifiersNotSupported] [] TEST(SubACK311QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0x7, 0x21, 0x64, 0x1, 0x2, 0xa2, 0xa2, 0x0}; + uint8_t pkt[] = {0x90, 0xd, 0x1e, 0x4a, 0x0, 0x2, 0x1, 0x1, 0x1, 0x2, 0x9e, 0x1, 0x0, 0x1, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8548); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 7754); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 12279 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left -// SubErrTopicFilterInvalid] [] +// SubscribeResponse 29991 [Left SubErrPacketIdentifierInUse,Right QoS1,Right QoS0,Left +// SubErrPacketIdentifierInUse,Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS0] [] TEST(SubACK311QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0x6, 0x2f, 0xf7, 0x2, 0x9e, 0x1, 0x8f}; + uint8_t pkt[] = {0x90, 0xb, 0x75, 0x27, 0x91, 0x1, 0x0, 0x91, 0x1, 0x1, 0x83, 0xa1, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12279); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 29991); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); } -// SubscribeResponse 8001 [Right QoS2,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS2,Left -// SubErrNotAuthorized,Left SubErrWildcardSubscriptionsNotSupported] [] +// SubscribeResponse 6273 [Right QoS1,Right QoS0] [] TEST(SubACK311QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0x9, 0x1f, 0x41, 0x2, 0x0, 0xa2, 0x2, 0x2, 0x87, 0xa2}; + uint8_t pkt[] = {0x90, 0x4, 0x18, 0x81, 0x1, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8001); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 6273); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); } -// SubscribeResponse 4988 [Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrNotAuthorized,Left -// SubErrImplementationSpecificError,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS2] [] +// SubscribeResponse 10407 [Left SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode18) { - uint8_t pkt[] = {0x90, 0xd, 0x13, 0x7c, 0x8f, 0x0, 0x87, 0x83, 0xa2, 0x9e, 0x0, 0xa1, 0x9e, 0x1, 0x2}; + uint8_t pkt[] = {0x90, 0x3, 0x28, 0xa7, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4988); - EXPECT_EQ(count, 11); + EXPECT_EQ(packet_id, 10407); + EXPECT_EQ(count, 1); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); } -// SubscribeResponse 6982 [Right QoS0,Left SubErrTopicFilterInvalid,Left SubErrQuotaExceeded,Left -// SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS2,Right QoS0,Right QoS1,Left SubErrTopicFilterInvalid,Left -// SubErrTopicFilterInvalid,Right QoS0] [] +// SubscribeResponse 13436 [Left SubErrPacketIdentifierInUse,Left SubErrImplementationSpecificError,Left +// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left SubErrNotAuthorized,Right QoS0,Right QoS1,Left +// SubErrQuotaExceeded,Right QoS0,Right QoS0] [] TEST(SubACK311QCTest, Decode19) { - uint8_t pkt[] = {0x90, 0xd, 0x1b, 0x46, 0x0, 0x8f, 0x97, 0x80, 0x87, 0x2, 0x0, 0x1, 0x8f, 0x8f, 0x0}; + uint8_t pkt[] = {0x90, 0xc, 0x34, 0x7c, 0x91, 0x83, 0x83, 0x97, 0x87, 0x0, 0x1, 0x97, 0x0, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6982); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 13436); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], 0x80); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); } -// SubscribeResponse 25134 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrImplementationSpecificError,Right -// QoS2,Left SubErrNotAuthorized,Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrQuotaExceeded] [] +// SubscribeResponse 634 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left +// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported] +// [] TEST(SubACK311QCTest, Decode20) { - uint8_t pkt[] = {0x90, 0xa, 0x62, 0x2e, 0xa1, 0x83, 0x2, 0x87, 0x0, 0x2, 0xa2, 0x97}; + uint8_t pkt[] = {0x90, 0x9, 0x2, 0x7a, 0x2, 0x91, 0x1, 0x83, 0x97, 0x0, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25134); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(packet_id, 634); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); } -// SubscribeResponse 25090 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrQuotaExceeded,Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Right QoS1,Left -// SubErrPacketIdentifierInUse] [] +// SubscribeResponse 742 [Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrPacketIdentifierInUse,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Right QoS1,Left SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0x9, 0x62, 0x2, 0x80, 0xa2, 0x97, 0x8f, 0x83, 0x1, 0x91}; + uint8_t pkt[] = {0x90, 0xb, 0x2, 0xe6, 0x0, 0xa1, 0x91, 0x2, 0x9e, 0x83, 0x97, 0x1, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25090); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(packet_id, 742); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], 0x80); } -// SubscribeResponse 270 [Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS0,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrUnspecifiedError] [] +// SubscribeResponse 14677 [Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode22) { - uint8_t pkt[] = {0x90, 0xc, 0x1, 0xe, 0x91, 0x0, 0x0, 0xa2, 0x1, 0xa1, 0xa1, 0x0, 0xa1, 0x80}; + uint8_t pkt[] = {0x90, 0x5, 0x39, 0x55, 0x8f, 0x0, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 270); - EXPECT_EQ(count, 10); + EXPECT_EQ(packet_id, 14677); + EXPECT_EQ(count, 3); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); } -// SubscribeResponse 28717 [Right QoS0,Left SubErrQuotaExceeded,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrPacketIdentifierInUse,Right QoS2,Right QoS1,Right QoS2,Right QoS2] [] +// SubscribeResponse 22954 [Right QoS1,Left SubErrTopicFilterInvalid,Left SubErrQuotaExceeded,Right QoS0,Left +// SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0xa, 0x70, 0x2d, 0x0, 0x97, 0xa2, 0x91, 0x2, 0x1, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0x7, 0x59, 0xaa, 0x1, 0x8f, 0x97, 0x0, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 28717); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 22954); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); } -// SubscribeResponse 8736 [Right QoS1,Right QoS2,Left SubErrImplementationSpecificError,Right QoS2,Right QoS0,Right -// QoS1] [] +// SubscribeResponse 18733 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrPacketIdentifierInUse,Right QoS2,Right QoS1,Right QoS1] [] TEST(SubACK311QCTest, Decode24) { - uint8_t pkt[] = {0x90, 0x8, 0x22, 0x20, 0x1, 0x2, 0x83, 0x2, 0x0, 0x1}; + uint8_t pkt[] = {0x90, 0x8, 0x49, 0x2d, 0x2, 0xa2, 0x91, 0x2, 0x1, 0x1}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[6]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8736); + EXPECT_EQ(packet_id, 18733); EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 27132 [Left SubErrWildcardSubscriptionsNotSupported,Left SubErrImplementationSpecificError,Right -// QoS0] [] +// SubscribeResponse 22455 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left +// SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded,Right QoS0,Left +// SubErrTopicFilterInvalid,Right QoS1,Right QoS1] [] TEST(SubACK311QCTest, Decode25) { - uint8_t pkt[] = {0x90, 0x5, 0x69, 0xfc, 0xa2, 0x83, 0x0}; + uint8_t pkt[] = {0x90, 0xb, 0x57, 0xb7, 0x9e, 0x97, 0x8f, 0xa1, 0x97, 0x0, 0x8f, 0x1, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27132); - EXPECT_EQ(count, 3); + EXPECT_EQ(packet_id, 22455); + EXPECT_EQ(count, 9); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); } -// SubscribeResponse 20260 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS1,Right QoS1] [] +// SubscribeResponse 556 [Right QoS1,Left SubErrImplementationSpecificError,Right QoS1] [] TEST(SubACK311QCTest, Decode26) { - uint8_t pkt[] = {0x90, 0x8, 0x4f, 0x24, 0x2, 0x91, 0x0, 0x2, 0x1, 0x1}; + uint8_t pkt[] = {0x90, 0x5, 0x2, 0x2c, 0x1, 0x83, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 20260); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 556); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); } -// SubscribeResponse 471 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS0,Left -// SubErrNotAuthorized,Right QoS2,Left SubErrImplementationSpecificError,Right QoS1,Right QoS1] [] +// SubscribeResponse 15417 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left SubErrNotAuthorized] +// [] TEST(SubACK311QCTest, Decode27) { - uint8_t pkt[] = {0x90, 0xa, 0x1, 0xd7, 0x9e, 0x0, 0x0, 0x87, 0x2, 0x83, 0x1, 0x1}; + uint8_t pkt[] = {0x90, 0x6, 0x3c, 0x39, 0x2, 0xa2, 0x0, 0x87}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 471); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 15417); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); } -// SubscribeResponse 21021 [Right QoS1,Right QoS2,Right QoS2,Right QoS2] [] +// SubscribeResponse 26950 [Left SubErrImplementationSpecificError,Right QoS2,Right QoS2,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [] TEST(SubACK311QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0x6, 0x52, 0x1d, 0x1, 0x2, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0x7, 0x69, 0x46, 0x83, 0x2, 0x2, 0xa1, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21021); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 26950); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); } -// SubscribeResponse 3050 [Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrUnspecifiedError,Left -// SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left SubErrSharedSubscriptionsNotSupported,Right QoS0] [] +// SubscribeResponse 24196 [Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Left +// SubErrImplementationSpecificError,Right QoS0,Right QoS0,Left SubErrTopicFilterInvalid,Left +// SubErrPacketIdentifierInUse,Right QoS2] [] TEST(SubACK311QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0x9, 0xb, 0xea, 0x2, 0x91, 0x80, 0x80, 0x91, 0x9e, 0x0}; + uint8_t pkt[] = {0x90, 0xb, 0x5e, 0x84, 0x9e, 0x1, 0x8f, 0x83, 0x0, 0x0, 0x8f, 0x91, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3050); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(packet_id, 24196); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); } -// SubscribeResponse 9426 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Left -// SubErrWildcardSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrTopicFilterInvalid,Right QoS0,Right QoS2] [] +// SubscribeResponse 19551 [Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrUnspecifiedError,Right QoS1,Right +// QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrQuotaExceeded,Right QoS0] [] TEST(SubACK311QCTest, Decode30) { - uint8_t pkt[] = {0x90, 0xd, 0x24, 0xd2, 0x80, 0xa2, 0xa2, 0x1, 0x1, 0x83, 0xa2, 0x9e, 0x8f, 0x0, 0x2}; + uint8_t pkt[] = {0x90, 0xc, 0x4c, 0x5f, 0x91, 0x2, 0x80, 0x1, 0x2, 0x91, 0x1, 0x9e, 0x97, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9426); - EXPECT_EQ(count, 11); + EXPECT_EQ(packet_id, 19551); + EXPECT_EQ(count, 10); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[7], 0x80); EXPECT_EQ(granted_qos_levels[8], 0x80); EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); -} - -// SubscribeResponse 13080 [Right QoS1,Right QoS0,Left SubErrNotAuthorized,Left SubErrNotAuthorized,Right QoS1,Right -// QoS1,Left SubErrPacketIdentifierInUse,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Right QoS0] -// [PropCorrelationData "\242'L\238\DC3t{\175QVr\STX+\r\195\172\187h\202_\"\142\b\170i{\234\221F\212",PropContentType -// "|]w\253\nFy\252]Vf\254\239?j\197\193\237\vj\174\137\&3L",PropWillDelayInterval 11256,PropMaximumPacketSize -// 14054,PropMaximumPacketSize 28209,PropReasonString "3\159\r",PropWildcardSubscriptionAvailable -// 206,PropSessionExpiryInterval 11090,PropAssignedClientIdentifier "\182V@\252\178\185\166#(\145\&0SP\176\188\EM -// w-\r\230oG\ACK",PropCorrelationData -// "\132\142GK\176\169\216\139\ENQ\145\221Y\249.\186\&1i\142\151\195\244\201\218\&6\176\215\STX",PropSharedSubscriptionAvailable -// 213,PropMessageExpiryInterval 1156,PropMaximumPacketSize 5568,PropSubscriptionIdentifier -// 0,PropRequestResponseInformation 243,PropMessageExpiryInterval 28104] +} + +// SubscribeResponse 8450 [Right QoS0] [PropResponseInformation "\253u\180K`\159\150\fE\153}H",PropReceiveMaximum +// 24891,PropMaximumPacketSize 28088] TEST(SubACK5QCTest, Decode1) { - uint8_t pkt[] = {0x90, 0xb5, 0x1, 0x33, 0x18, 0xa6, 0x1, 0x9, 0x0, 0x1e, 0xf2, 0x27, 0x4c, 0xee, 0x13, 0x74, 0x7b, - 0xaf, 0x51, 0x56, 0x72, 0x2, 0x2b, 0xd, 0xc3, 0xac, 0xbb, 0x68, 0xca, 0x5f, 0x22, 0x8e, 0x8, 0xaa, - 0x69, 0x7b, 0xea, 0xdd, 0x46, 0xd4, 0x3, 0x0, 0x18, 0x7c, 0x5d, 0x77, 0xfd, 0xa, 0x46, 0x79, 0xfc, - 0x5d, 0x56, 0x66, 0xfe, 0xef, 0x3f, 0x6a, 0xc5, 0xc1, 0xed, 0xb, 0x6a, 0xae, 0x89, 0x33, 0x4c, 0x18, - 0x0, 0x0, 0x2b, 0xf8, 0x27, 0x0, 0x0, 0x36, 0xe6, 0x27, 0x0, 0x0, 0x6e, 0x31, 0x1f, 0x0, 0x3, - 0x33, 0x9f, 0xd, 0x28, 0xce, 0x11, 0x0, 0x0, 0x2b, 0x52, 0x12, 0x0, 0x18, 0xb6, 0x56, 0x40, 0xfc, - 0xb2, 0xb9, 0xa6, 0x23, 0x28, 0x91, 0x30, 0x53, 0x50, 0xb0, 0xbc, 0x19, 0x20, 0x77, 0x2d, 0xd, 0xe6, - 0x6f, 0x47, 0x6, 0x9, 0x0, 0x1b, 0x84, 0x8e, 0x47, 0x4b, 0xb0, 0xa9, 0xd8, 0x8b, 0x5, 0x91, 0xdd, - 0x59, 0xf9, 0x2e, 0xba, 0x31, 0x69, 0x8e, 0x97, 0xc3, 0xf4, 0xc9, 0xda, 0x36, 0xb0, 0xd7, 0x2, 0x2a, - 0xd5, 0x2, 0x0, 0x0, 0x4, 0x84, 0x27, 0x0, 0x0, 0x15, 0xc0, 0xb, 0x0, 0x19, 0xf3, 0x2, 0x0, - 0x0, 0x6d, 0xc8, 0x1, 0x0, 0x87, 0x87, 0x1, 0x1, 0x91, 0x2, 0x2, 0x8f, 0x0}; + uint8_t pkt[] = {0x90, 0x1b, 0x21, 0x2, 0x17, 0x1a, 0x0, 0xc, 0xfd, 0x75, 0xb4, 0x4b, 0x60, 0x9f, 0x96, + 0xc, 0x45, 0x99, 0x7d, 0x48, 0x21, 0x61, 0x3b, 0x27, 0x0, 0x0, 0x6d, 0xb8, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13080); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x87); - EXPECT_EQ(granted_qos_levels[3], 0x87); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x91); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], 0x8F); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); -} - -// SubscribeResponse 32460 [Left SubErrImplementationSpecificError,Right QoS2,Right QoS0,Left -// SubErrUnspecifiedError,Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrUnspecifiedError,Left -// SubErrUnspecifiedError,Right QoS2,Right QoS1,Right QoS2] [PropMaximumQoS 184,PropWildcardSubscriptionAvailable -// 136,PropTopicAliasMaximum 16792,PropWildcardSubscriptionAvailable 177,PropSubscriptionIdentifier 21,PropReasonString -// "\216\246$\243\ESC\190(\179\180\220\135QI\131\160,\SO\198\168\DLE{\151",PropReasonString -// "\140[F\192\171\&9\CAN\DC1\DC4\225\DELQ\156#",PropUserProperty -// "\242\181k\SO\206\166S\157\246\231e\136\202\187\180\151\r\204x9(\202\129\b\194\b\EOT" -// "\160\161\254z\252\150\169\170,)\141\EM\207\147\158\169\137\133\SOH\210\220)\137P\SOHR\229\&1",PropMaximumPacketSize -// 30976,PropPayloadFormatIndicator 118,PropServerKeepAlive 29125,PropReceiveMaximum 14366,PropPayloadFormatIndicator -// 42,PropResponseInformation "\135f+\177j\SO\RS\191T\129g\195\214!\222",PropAssignedClientIdentifier -// "&+\142o\220\&6\FS\202;\151\204\USq\SI\241/\167\164\GS\\gOS\225\a",PropSharedSubscriptionAvailable 67,PropTopicAlias -// 504,PropMessageExpiryInterval 13989,PropAssignedClientIdentifier -// ",\197/\196\SYN\220/\208\160\229\&9e\170Zt\156\139\185",PropResponseTopic "[\tY",PropReasonString -// "h\172\STXi\153y\139@\128u\FS9\138%\230\158$6p\128\163\&5\228P\132h|Po\DC1",PropAuthenticationMethod -// "\251G\217\188\154\GS",PropWillDelayInterval 23086] + EXPECT_EQ(packet_id, 8450); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); +} + +// SubscribeResponse 20275 [Right QoS2,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Right QoS2,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Right QoS2] +// [PropAuthenticationData "\143\227\202\173[{\229$\148j<\161\220\DLE\204\194B",PropReasonString +// "rQ\202\231\161\&9\180\219\188\237\213U\157\233jKkC=\194\159\184T\187%\248\DC3j\156",PropSubscriptionIdentifierAvailable +// 97,PropWillDelayInterval 25789,PropTopicAliasMaximum 20234,PropServerKeepAlive 26883,PropPayloadFormatIndicator +// 65,PropWillDelayInterval 21939,PropServerReference +// "-\ETB\173\v\224\231Q\NAKr\b\196\158a\238\EM\185\244\&8h\152\UShJ\146",PropMaximumPacketSize +// 10688,PropWildcardSubscriptionAvailable 25,PropResponseInformation +// "\216\152\200\230\208o\208\DLE",PropAssignedClientIdentifier "\n",PropSessionExpiryInterval 20612,PropCorrelationData +// "\188{\132\187\247\ACK"] TEST(SubACK5QCTest, Decode2) { - uint8_t pkt[] = { - 0x90, 0x91, 0x2, 0x7e, 0xcc, 0x82, 0x2, 0x24, 0xb8, 0x28, 0x88, 0x22, 0x41, 0x98, 0x28, 0xb1, 0xb, 0x15, 0x1f, - 0x0, 0x16, 0xd8, 0xf6, 0x24, 0xf3, 0x1b, 0xbe, 0x28, 0xb3, 0xb4, 0xdc, 0x87, 0x51, 0x49, 0x83, 0xa0, 0x2c, 0xe, - 0xc6, 0xa8, 0x10, 0x7b, 0x97, 0x1f, 0x0, 0xe, 0x8c, 0x5b, 0x46, 0xc0, 0xab, 0x39, 0x18, 0x11, 0x14, 0xe1, 0x7f, - 0x51, 0x9c, 0x23, 0x26, 0x0, 0x1b, 0xf2, 0xb5, 0x6b, 0xe, 0xce, 0xa6, 0x53, 0x9d, 0xf6, 0xe7, 0x65, 0x88, 0xca, - 0xbb, 0xb4, 0x97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83, - 0x2, 0x0, 0x80, 0x2, 0x91, 0x80, 0x80, 0x2, 0x1, 0x2}; + uint8_t pkt[] = {0x90, 0x94, 0x1, 0x4f, 0x33, 0x87, 0x1, 0x16, 0x0, 0x11, 0x8f, 0xe3, 0xca, 0xad, 0x5b, 0x7b, 0xe5, + 0x24, 0x94, 0x6a, 0x3c, 0xa1, 0xdc, 0x10, 0xcc, 0xc2, 0x42, 0x1f, 0x0, 0x1d, 0x72, 0x51, 0xca, 0xe7, + 0xa1, 0x39, 0xb4, 0xdb, 0xbc, 0xed, 0xd5, 0x55, 0x9d, 0xe9, 0x6a, 0x4b, 0x6b, 0x43, 0x3d, 0xc2, 0x9f, + 0xb8, 0x54, 0xbb, 0x25, 0xf8, 0x13, 0x6a, 0x9c, 0x29, 0x61, 0x18, 0x0, 0x0, 0x64, 0xbd, 0x22, 0x4f, + 0xa, 0x13, 0x69, 0x3, 0x1, 0x41, 0x18, 0x0, 0x0, 0x55, 0xb3, 0x1c, 0x0, 0x18, 0x2d, 0x17, 0xad, + 0xb, 0xe0, 0xe7, 0x51, 0x15, 0x72, 0x8, 0xc4, 0x9e, 0x61, 0xee, 0x19, 0xb9, 0xf4, 0x38, 0x68, 0x98, + 0x1f, 0x68, 0x4a, 0x92, 0x27, 0x0, 0x0, 0x29, 0xc0, 0x28, 0x19, 0x1a, 0x0, 0x8, 0xd8, 0x98, 0xc8, + 0xe6, 0xd0, 0x6f, 0xd0, 0x10, 0x12, 0x0, 0x1, 0xa, 0x11, 0x0, 0x0, 0x50, 0x84, 0x9, 0x0, 0x6, + 0xbc, 0x7b, 0x84, 0xbb, 0xf7, 0x6, 0x2, 0x0, 0x97, 0x0, 0x2, 0x9e, 0x97, 0x80, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32460); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x83); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(packet_id, 20275); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x97); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x91); - EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x9E); + EXPECT_EQ(granted_qos_levels[6], 0x97); EXPECT_EQ(granted_qos_levels[7], 0x80); EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); } -// SubscribeResponse 7819 [Right QoS2,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported] -// [PropSharedSubscriptionAvailable 150,PropSubscriptionIdentifierAvailable 160,PropServerKeepAlive -// 19557,PropRequestResponseInformation 138,PropAuthenticationMethod -// "\236\145\214\235\210\190\189S1l\166\246\225\173'\f\224\161\191\166\201[\STX\210^",PropTopicAlias -// 24707,PropMaximumPacketSize 20799,PropContentType -// "\207\aE\227\201(\194\NUL\226\a_w\245\&9\129\254$\221\233\231\&9\253\&8h\240\GS\135.\247\150",PropMaximumQoS -// 31,PropRequestResponseInformation 6,PropCorrelationData -// "\SI\td\SYN\131\190\187\\\198\140\222\214\169\253+\f\t\192\DC2(\SOH\186\146\214\ETX%\218",PropReceiveMaximum 29138] +// SubscribeResponse 3848 [Right QoS0,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Right QoS2,Left +// SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError,Right QoS1,Right QoS0] +// [PropTopicAliasMaximum 10554,PropSubscriptionIdentifierAvailable 81,PropTopicAlias 14436,PropReceiveMaximum +// 20441,PropCorrelationData "\148\162\129Gq\a\SYN\CAN\194\&4",PropResponseInformation +// "\231\CAN\128\ETXI\154\GS\249Jp\a.",PropSubscriptionIdentifierAvailable 23,PropContentType +// "\172\162&\f\194\135\128\154\DC32\179\222\&1\252\a\ACK\SIs!\DC4\185\131n;*",PropRetainAvailable +// 236,PropWillDelayInterval 13881,PropAuthenticationMethod +// "\228\216\192\DC3{W\USs\205\148F\192\&6a\204\152\242\&4\237?\169\174\216;\211\204\223\f",PropCorrelationData +// "\FS\SYN9\208\&2\146y\254\144\202g\234\161%\GSS\EOT0\226\162\SOH\137U",PropServerKeepAlive 25204] TEST(SubACK5QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0x79, 0x1e, 0x8b, 0x73, 0x2a, 0x96, 0x29, 0xa0, 0x13, 0x4c, 0x65, 0x19, 0x8a, 0x15, 0x0, - 0x19, 0xec, 0x91, 0xd6, 0xeb, 0xd2, 0xbe, 0xbd, 0x53, 0x31, 0x6c, 0xa6, 0xf6, 0xe1, 0xad, 0x27, - 0xc, 0xe0, 0xa1, 0xbf, 0xa6, 0xc9, 0x5b, 0x2, 0xd2, 0x5e, 0x23, 0x60, 0x83, 0x27, 0x0, 0x0, - 0x51, 0x3f, 0x3, 0x0, 0x1e, 0xcf, 0x7, 0x45, 0xe3, 0xc9, 0x28, 0xc2, 0x0, 0xe2, 0x7, 0x5f, - 0x77, 0xf5, 0x39, 0x81, 0xfe, 0x24, 0xdd, 0xe9, 0xe7, 0x39, 0xfd, 0x38, 0x68, 0xf0, 0x1d, 0x87, - 0x2e, 0xf7, 0x96, 0x24, 0x1f, 0x19, 0x6, 0x9, 0x0, 0x1b, 0xf, 0x9, 0x64, 0x16, 0x83, 0xbe, - 0xbb, 0x5c, 0xc6, 0x8c, 0xde, 0xd6, 0xa9, 0xfd, 0x2b, 0xc, 0x9, 0xc0, 0x12, 0x28, 0x1, 0xba, - 0x92, 0xd6, 0x3, 0x25, 0xda, 0x21, 0x71, 0xd2, 0x2, 0x1, 0xa2}; + uint8_t pkt[] = {0x90, 0x95, 0x1, 0xf, 0x8, 0x88, 0x1, 0x22, 0x29, 0x3a, 0x29, 0x51, 0x23, 0x38, 0x64, 0x21, 0x4f, + 0xd9, 0x9, 0x0, 0xa, 0x94, 0xa2, 0x81, 0x47, 0x71, 0x7, 0x16, 0x18, 0xc2, 0x34, 0x1a, 0x0, 0xc, + 0xe7, 0x18, 0x80, 0x3, 0x49, 0x9a, 0x1d, 0xf9, 0x4a, 0x70, 0x7, 0x2e, 0x29, 0x17, 0x3, 0x0, 0x19, + 0xac, 0xa2, 0x26, 0xc, 0xc2, 0x87, 0x80, 0x9a, 0x13, 0x32, 0xb3, 0xde, 0x31, 0xfc, 0x7, 0x6, 0xf, + 0x73, 0x21, 0x14, 0xb9, 0x83, 0x6e, 0x3b, 0x2a, 0x25, 0xec, 0x18, 0x0, 0x0, 0x36, 0x39, 0x15, 0x0, + 0x1c, 0xe4, 0xd8, 0xc0, 0x13, 0x7b, 0x57, 0x1f, 0x73, 0xcd, 0x94, 0x46, 0xc0, 0x36, 0x61, 0xcc, 0x98, + 0xf2, 0x34, 0xed, 0x3f, 0xa9, 0xae, 0xd8, 0x3b, 0xd3, 0xcc, 0xdf, 0xc, 0x9, 0x0, 0x17, 0x1c, 0x16, + 0x39, 0xd0, 0x32, 0x92, 0x79, 0xfe, 0x90, 0xca, 0x67, 0xea, 0xa1, 0x25, 0x1d, 0x53, 0x4, 0x30, 0xe2, + 0xa2, 0x1, 0x89, 0x55, 0x13, 0x62, 0x74, 0x0, 0x97, 0x80, 0x2, 0x91, 0x87, 0x83, 0x1, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7819); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0xA2); -} - -// SubscribeResponse 17369 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left SubErrTopicFilterInvalid] -// [PropCorrelationData "\152!\DC2\241\205co\n\153l\STX\GS\158\DC1pO\217",PropRequestProblemInformation -// 23,PropRetainAvailable 158,PropSharedSubscriptionAvailable 40,PropRetainAvailable -// 138,PropWildcardSubscriptionAvailable 241,PropSessionExpiryInterval 14344,PropReceiveMaximum -// 20784,PropServerKeepAlive 559,PropServerReference ">\252\161\243\143O\DLE\165\147|\215\DC2+",PropContentType -// "\203\248\228\192\212|\EM\213\234%\165\DEL\211\237\224\211\GS{`PV\128\185`\165\EOT",PropSubscriptionIdentifierAvailable -// 49,PropResponseInformation "dsHa\206\179>\216\217\222\190O\247\DC3\DC3",PropResponseTopic -// "L\234Q\188\186\224\132\151:X\EOTj\227 \176\242\175C\ACKSp\215",PropTopicAlias 22362,PropTopicAlias -// 11639,PropWillDelayInterval 30787,PropSubscriptionIdentifierAvailable 2,PropResponseTopic -// "\187\222\&2\ACKh`\243P\ACK*\STX\225\r",PropSubscriptionIdentifierAvailable 171,PropServerReference "\137@\220"] + EXPECT_EQ(packet_id, 3848); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x97); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x91); + EXPECT_EQ(granted_qos_levels[5], 0x87); + EXPECT_EQ(granted_qos_levels[6], 0x83); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); +} + +// SubscribeResponse 21048 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrUnspecifiedError,Right QoS1,Left SubErrUnspecifiedError] +// [PropReasonString "o\143\223\139\170\249\182\142\220\FS\DC4\214\173\NUL\234+p\177Zd\247\&1*V\140",PropContentType +// "\RS*\SUB\ESC\NAK\nB\224\173\214\212\163z/\225",PropRetainAvailable 255,PropResponseTopic +// "\191\STX\221\172j\247\210\208",PropPayloadFormatIndicator 92,PropPayloadFormatIndicator 61,PropWillDelayInterval +// 3196,PropMaximumQoS 45,PropSessionExpiryInterval 11712,PropSessionExpiryInterval 21681,PropSessionExpiryInterval +// 10572,PropWildcardSubscriptionAvailable 93,PropAuthenticationData "\196\236\231",PropMessageExpiryInterval +// 11997,PropReasonString "v\RS(+hC\194B",PropSubscriptionIdentifierAvailable 77,PropTopicAlias +// 14811,PropRetainAvailable 155,PropResponseTopic "\217\178q\229|\154[1\a\CAN\138 \166",PropReceiveMaximum +// 86,PropReceiveMaximum 17084,PropWildcardSubscriptionAvailable 136,PropReceiveMaximum 8446,PropContentType +// "\193\168\176\&6X\185\203\232\SOH\219\194\176\f;J\191\155\237\"\206\n\225\DC1",PropMessageExpiryInterval 7662] TEST(SubACK5QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0xaf, 0x1, 0x43, 0xd9, 0xa8, 0x1, 0x9, 0x0, 0x11, 0x98, 0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8e, 0xdc, + 0x1c, 0x14, 0xd6, 0xad, 0x0, 0xea, 0x2b, 0x70, 0xb1, 0x5a, 0x64, 0xf7, 0x31, 0x2a, 0x56, 0x8c, 0x3, 0x0, 0xf, + 0x1e, 0x2a, 0x1a, 0x1b, 0x15, 0xa, 0x42, 0xe0, 0xad, 0xd6, 0xd4, 0xa3, 0x7a, 0x2f, 0xe1, 0x25, 0xff, 0x8, 0x0, + 0x8, 0xbf, 0x2, 0xdd, 0xac, 0x6a, 0xf7, 0xd2, 0xd0, 0x1, 0x5c, 0x1, 0x3d, 0x18, 0x0, 0x0, 0xc, 0x7c, 0x24, + 0x2d, 0x11, 0x0, 0x0, 0x2d, 0xc0, 0x11, 0x0, 0x0, 0x54, 0xb1, 0x11, 0x0, 0x0, 0x29, 0x4c, 0x28, 0x5d, 0x16, + 0x0, 0x3, 0xc4, 0xec, 0xe7, 0x2, 0x0, 0x0, 0x2e, 0xdd, 0x1f, 0x0, 0x8, 0x76, 0x1e, 0x28, 0x2b, 0x68, 0x43, + 0xc2, 0x42, 0x29, 0x4d, 0x23, 0x39, 0xdb, 0x25, 0x9b, 0x8, 0x0, 0xd, 0xd9, 0xb2, 0x71, 0xe5, 0x7c, 0x9a, 0x5b, + 0x31, 0x7, 0x18, 0x8a, 0x20, 0xa6, 0x21, 0x0, 0x56, 0x21, 0x42, 0xbc, 0x28, 0x88, 0x21, 0x20, 0xfe, 0x3, 0x0, + 0x17, 0xc1, 0xa8, 0xb0, 0x36, 0x58, 0xb9, 0xcb, 0xe8, 0x1, 0xdb, 0xc2, 0xb0, 0xc, 0x3b, 0x4a, 0xbf, 0x9b, 0xed, + 0x22, 0xce, 0xa, 0xe1, 0x11, 0x2, 0x0, 0x0, 0x1d, 0xee, 0xa2, 0x2, 0xa1, 0x80, 0x1, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17369); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x9E); - EXPECT_EQ(granted_qos_levels[2], 0x8F); + EXPECT_EQ(packet_id, 21048); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0xA2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0xA1); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); } -// SubscribeResponse 14645 [Right QoS0,Left SubErrTopicFilterInvalid,Right QoS1,Left SubErrTopicFilterInvalid,Right -// QoS1,Right QoS2,Right QoS0] [PropCorrelationData -// "\179\182\172\210\RS\221\243\151",PropCorrelationData +// "o\133c\153\191\&4\215%",PropTopicAlias 26118,PropSharedSubscriptionAvailable 115,PropCorrelationData +// "0{\216v\211ti\200\&3\"\177\173\143\210A\183\202\&3\145\176L\129\USJl\253",PropSessionExpiryInterval +// 18085,PropSharedSubscriptionAvailable 204,PropRequestResponseInformation 162,PropSubscriptionIdentifier +// 18,PropTopicAlias 29222,PropReceiveMaximum 26778,PropSessionExpiryInterval 21467,PropMessageExpiryInterval +// 25987,PropMaximumQoS 167,PropContentType +// "\252\143\173\221\235\141\145\138\NUL\254\NAK\175\201\234\193\255\218\150\182"] TEST(SubACK5QCTest, Decode6) { - uint8_t pkt[] = {0x90, 0x18, 0x30, 0x7, 0x11, 0x16, 0x0, 0xc, 0x5c, 0x8c, 0x40, 0x9d, 0xfd, - 0xf4, 0xbd, 0x1a, 0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0x4a, 0x6c, 0xfd, 0x11, 0x0, 0x0, 0x46, 0xa5, 0x2a, 0xcc, 0x19, 0xa2, + 0xb, 0x12, 0x23, 0x72, 0x26, 0x21, 0x68, 0x9a, 0x11, 0x0, 0x0, 0x53, 0xdb, 0x2, 0x0, 0x0, 0x65, + 0x83, 0x24, 0xa7, 0x3, 0x0, 0x13, 0xfc, 0x8f, 0xad, 0xdd, 0xeb, 0x8d, 0x91, 0x8a, 0x0, 0xfe, 0x15, + 0xaf, 0xc9, 0xea, 0xc1, 0xff, 0xda, 0x96, 0xb6, 0x2, 0x1, 0x9e, 0x0, 0x0, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12295); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], 0x91); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x8F); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 29704); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x9E); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 10100 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Right QoS0,Left -// SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS2,Right QoS2,Left -// SubErrPacketIdentifierInUse,Right QoS2,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError] [] +// SubscribeResponse 8 [Right QoS2] [PropAuthenticationMethod +// "\219\DC3\203\236\192<\167-\168*Q\133\138\ETX",PropSubscriptionIdentifierAvailable 27,PropAuthenticationData +// "\ESC\245r\158!\172\\u\184\USu\253f\164",PropSubscriptionIdentifier 30,PropMessageExpiryInterval +// 18702,PropPayloadFormatIndicator 181,PropReceiveMaximum 15038,PropWildcardSubscriptionAvailable +// 106,PropReceiveMaximum 24360,PropServerReference +// ">\133%\129\139\179\174\207\189\141l\ENQ\180\149\SYN'p\178\229\174\202",PropAuthenticationData +// "{\200\n\210\234]\233\130\204w \239\151:\228\&4\132+\234rY\176\SYN\249\&7\145\NAK\nd",PropResponseInformation +// "\215\251\159\227\154\130\234$\226\ACK\174\f\224#N\EM\254\205\151\141\192]s"] TEST(SubACK5QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0xe, 0x27, 0x74, 0x0, 0xa1, 0x0, 0x0, 0xa2, 0x80, 0x2, 0x2, 0x91, 0x2, 0x97, 0x80}; + uint8_t pkt[] = {0x90, 0x8c, 0x1, 0x0, 0x8, 0x87, 0x1, 0x15, 0x0, 0xe, 0xdb, 0x13, 0xcb, 0xec, 0xc0, 0x3c, + 0xa7, 0x2d, 0xa8, 0x2a, 0x51, 0x85, 0x8a, 0x3, 0x29, 0x1b, 0x16, 0x0, 0xe, 0x1b, 0xf5, 0x72, + 0x9e, 0x21, 0xac, 0x5c, 0x75, 0xb8, 0x1f, 0x75, 0xfd, 0x66, 0xa4, 0xb, 0x1e, 0x2, 0x0, 0x0, + 0x49, 0xe, 0x1, 0xb5, 0x21, 0x3a, 0xbe, 0x28, 0x6a, 0x21, 0x5f, 0x28, 0x1c, 0x0, 0x15, 0x3e, + 0x85, 0x25, 0x81, 0x8b, 0xb3, 0xae, 0xcf, 0xbd, 0x8d, 0x6c, 0x5, 0xb4, 0x95, 0x16, 0x27, 0x70, + 0xb2, 0xe5, 0xae, 0xca, 0x16, 0x0, 0x1d, 0x7b, 0xc8, 0xa, 0xd2, 0xea, 0x5d, 0xe9, 0x82, 0xcc, + 0x77, 0x20, 0xef, 0x97, 0x3a, 0xe4, 0x34, 0x84, 0x2b, 0xea, 0x72, 0x59, 0xb0, 0x16, 0xf9, 0x37, + 0x91, 0x15, 0xa, 0x64, 0x1a, 0x0, 0x17, 0xd7, 0xfb, 0x9f, 0xe3, 0x9a, 0x82, 0xea, 0x24, 0xe2, + 0x6, 0xae, 0xc, 0xe0, 0x23, 0x4e, 0x19, 0xfe, 0xcd, 0x97, 0x8d, 0xc0, 0x5d, 0x73, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10100); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0xA1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0xA2); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], 0x91); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[9], 0x97); - EXPECT_EQ(granted_qos_levels[10], 0x80); + EXPECT_EQ(packet_id, 8); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); } -// SubscribeResponse 19212 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Left -// SubErrImplementationSpecificError,Right QoS0,Right QoS2,Right QoS0,Left SubErrPacketIdentifierInUse] -// [PropServerReference "\240r\148\243\&4\175\187\144\188.5",PropMaximumQoS 211,PropAuthenticationMethod -// "\193\212\SI\177zP\US9f\ESCW",PropRetainAvailable 194,PropContentType -// "\a\164#\131\207\221T;N\ENQ\SO\216\t",PropResponseTopic "\r\195\&6A\222\b&+\197N\195\174S\157M\174 -// A\225\132B\220\144\186\172\192",PropContentType "w\202\240\180\SUBSZ\226\DC3r\SOH\181%)W",PropMessageExpiryInterval -// 25838,PropCorrelationData "\136\&7\205\162\165\SYNL\232;\247\230",PropResponseInformation -// "\152\SIa\208J\SO\173M\132\ETB\DC2\GS\SOH",PropRequestProblemInformation 222,PropResponseTopic -// "\171\173w\174",PropTopicAliasMaximum 28507,PropMaximumQoS 239,PropAssignedClientIdentifier -// "\178\165",PropRequestResponseInformation 229,PropRequestResponseInformation 25,PropPayloadFormatIndicator -// 24,PropResponseInformation "\DEL6\138MW",PropWillDelayInterval 31867,PropAssignedClientIdentifier -// "\185\193\n\137-\211\183MkHj@\SOHr\248\218\203\186\189@",PropWildcardSubscriptionAvailable -// 93,PropSessionExpiryInterval 30900,PropRetainAvailable 80,PropServerKeepAlive 31885,PropSubscriptionIdentifier 11] +// SubscribeResponse 24329 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Right QoS2,Right QoS0,Right QoS0,Right +// QoS1,Right QoS2] [PropSessionExpiryInterval 3602,PropResponseTopic +// "/5x\ETBj\ACK0\DC3q\176\252\191\150\234\214\236\193\249\167\&5\225\&2\215\195i\132",PropCorrelationData +// "\198ww\135\192\229\234",PropReceiveMaximum 21158,PropResponseTopic +// "\255\a\ACKU\RSN\NAK5=\185,j\162",PropUserProperty "p1\CAN\188\144\DC4\146\207Q" +// "\NUL+\214\149G\195xo\177>\ACK\SYN\167\&2\220 \183\156\247\142#\196\STX\ETX{N0\220\230\243",PropTopicAlias +// 32590,PropRetainAvailable 229,PropServerKeepAlive 13344,PropSharedSubscriptionAvailable 121,PropUserProperty +// "@2K?\\\231\252\221\212S.\190\140\227\189\FSL\185\137\179\&7!\132\130\SUB\t\163\149\211" +// "\132#{\178\\\172\250\219\US\STX\ETB",PropSessionExpiryInterval 16041,PropReasonString +// "\249\165\157\CANk!\166\237\DC1\228\228O\187\STX\SYNT\170e\ETB>\167\151m\200\253r1r\GS\SOH",PropRequestProblemInformation +// 224,PropReasonString "B\244\133n{\179\DC1\129yE",PropResponseTopic +// "\177\171\SOm\243\192\vy=\182\133",PropReceiveMaximum 10480,PropAuthenticationData +// "\DC4q\131\160\239\241}^e\192m\252\187D\169\azt\239\DC1\EOT\RS",PropTopicAliasMaximum 11512,PropMessageExpiryInterval +// 6187,PropSubscriptionIdentifierAvailable 243,PropServerReference "\\\227\180",PropMessageExpiryInterval +// 6636,PropUserProperty "\241\243\139\207Fh\EM\GSo:\ESC" "\173\229{>\233\247-\SOHp",PropServerReference +// "",PropSubscriptionIdentifier 23] TEST(SubACK5QCTest, Decode8) { - uint8_t pkt[] = {0x90, 0xd8, 0x1, 0x4b, 0xc, 0xcd, 0x1, 0x1c, 0x0, 0xb, 0xf0, 0x72, 0x94, 0xf3, 0x34, 0xaf, 0xbb, - 0x90, 0xbc, 0x2e, 0x35, 0x24, 0xd3, 0x15, 0x0, 0xb, 0xc1, 0xd4, 0xf, 0xb1, 0x7a, 0x50, 0x1f, 0x39, - 0x66, 0x1b, 0x57, 0x25, 0xc2, 0x3, 0x0, 0xd, 0x7, 0xa4, 0x23, 0x83, 0xcf, 0xdd, 0x54, 0x3b, 0x4e, - 0x5, 0xe, 0xd8, 0x9, 0x8, 0x0, 0x1a, 0xd, 0xc3, 0x36, 0x41, 0xde, 0x8, 0x26, 0x2b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, 0x11, 0x81, 0x79, 0x45, 0x8, 0x0, 0xb, 0xb1, 0xab, 0xe, + 0x6d, 0xf3, 0xc0, 0xb, 0x79, 0x3d, 0xb6, 0x85, 0x21, 0x28, 0xf0, 0x16, 0x0, 0x16, 0x14, 0x71, 0x83, 0xa0, 0xef, + 0xf1, 0x7d, 0x5e, 0x65, 0xc0, 0x6d, 0xfc, 0xbb, 0x44, 0xa9, 0x7, 0x7a, 0x74, 0xef, 0x11, 0x4, 0x1e, 0x22, 0x2c, + 0xf8, 0x2, 0x0, 0x0, 0x18, 0x2b, 0x29, 0xf3, 0x1c, 0x0, 0x3, 0x5c, 0xe3, 0xb4, 0x2, 0x0, 0x0, 0x19, 0xec, + 0x26, 0x0, 0xb, 0xf1, 0xf3, 0x8b, 0xcf, 0x46, 0x68, 0x19, 0x1d, 0x6f, 0x3a, 0x1b, 0x0, 0x9, 0xad, 0xe5, 0x7b, + 0x3e, 0xe9, 0xf7, 0x2d, 0x1, 0x70, 0x1c, 0x0, 0x0, 0xb, 0x17, 0x2, 0x9e, 0xa2, 0x80, 0x0, 0x2, 0x0, 0x0, + 0x1, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19212); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0xA1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x83); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x91); -} - -// SubscribeResponse 31570 [Left SubErrTopicFilterInvalid] [PropRetainAvailable 54,PropMaximumPacketSize -// 11455,PropRequestProblemInformation 175,PropTopicAlias 15662,PropSubscriptionIdentifierAvailable 140,PropMaximumQoS -// 246,PropMessageExpiryInterval 24290] + EXPECT_EQ(packet_id, 24329); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x9E); + EXPECT_EQ(granted_qos_levels[2], 0xA2); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); +} + +// SubscribeResponse 10189 [Left SubErrImplementationSpecificError,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS2,Left SubErrUnspecifiedError,Right QoS1,Left +// SubErrImplementationSpecificError,Right QoS2,Left SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left +// SubErrWildcardSubscriptionsNotSupported] [PropAssignedClientIdentifier +// "\ETX\142\176\SI\135\229\156\165\&6TU\141\EOTR\196\ETBn&I~qx\220\SOD\ETB\183",PropSessionExpiryInterval +// 23384,PropUserProperty "\229\&7_'\206\145\128_\222C\153" ")*",PropAuthenticationData "=",PropPayloadFormatIndicator +// 144,PropMessageExpiryInterval 32480,PropCorrelationData +// "\SI\162JG\DC1\244\150\234\151\&2r\207\133\158\a\199&I\225\139\246E\v",PropMaximumQoS +// 76,PropSharedSubscriptionAvailable 193,PropReasonString "\177",PropRequestProblemInformation +// 85,PropAssignedClientIdentifier "T\179\"",PropAssignedClientIdentifier +// "AC}\ETX@\152H\238\150\154\185\ESC",PropResponseInformation "tM\128\192\157\173A",PropRetainAvailable +// 52,PropUserProperty "Z\153\222\f\RS\128t` 4\177\150\&5n\DC1\CANZx\207\DLE\\\GS\250\DC13\194\v" +// "_\245\182K\158",PropWillDelayInterval 30645,PropWildcardSubscriptionAvailable 207] TEST(SubACK5QCTest, Decode9) { - uint8_t pkt[] = {0x90, 0x19, 0x7b, 0x52, 0x15, 0x25, 0x36, 0x27, 0x0, 0x0, 0x2c, 0xbf, 0x17, 0xaf, - 0x23, 0x3d, 0x2e, 0x29, 0x8c, 0x24, 0xf6, 0x2, 0x0, 0x0, 0x5e, 0xe2, 0x8f}; + uint8_t pkt[] = {0x90, 0xc0, 0x1, 0x27, 0xcd, 0xb1, 0x1, 0x12, 0x0, 0x1b, 0x3, 0x8e, 0xb0, 0xf, 0x87, 0xe5, 0x9c, + 0xa5, 0x36, 0x54, 0x55, 0x8d, 0x4, 0x52, 0xc4, 0x17, 0x6e, 0x26, 0x49, 0x7e, 0x71, 0x78, 0xdc, 0xe, + 0x44, 0x17, 0xb7, 0x11, 0x0, 0x0, 0x5b, 0x58, 0x26, 0x0, 0xb, 0xe5, 0x37, 0x5f, 0x27, 0xce, 0x91, + 0x80, 0x5f, 0xde, 0x43, 0x99, 0x0, 0x2, 0x29, 0x2a, 0x16, 0x0, 0x1, 0x3d, 0x1, 0x90, 0x2, 0x0, + 0x0, 0x7e, 0xe0, 0x9, 0x0, 0x17, 0xf, 0xa2, 0x4a, 0x47, 0x11, 0xf4, 0x96, 0xea, 0x97, 0x32, 0x72, + 0xcf, 0x85, 0x9e, 0x7, 0xc7, 0x26, 0x49, 0xe1, 0x8b, 0xf6, 0x45, 0xb, 0x24, 0x4c, 0x2a, 0xc1, 0x1f, + 0x0, 0x1, 0xb1, 0x17, 0x55, 0x12, 0x0, 0x3, 0x54, 0xb3, 0x22, 0x12, 0x0, 0xc, 0x41, 0x43, 0x7d, + 0x3, 0x40, 0x98, 0x48, 0xee, 0x96, 0x9a, 0xb9, 0x1b, 0x1a, 0x0, 0x7, 0x74, 0x4d, 0x80, 0xc0, 0x9d, + 0xad, 0x41, 0x25, 0x34, 0x26, 0x0, 0x1b, 0x5a, 0x99, 0xde, 0xc, 0x1e, 0x80, 0x74, 0x60, 0x20, 0x34, + 0xb1, 0x96, 0x35, 0x6e, 0x11, 0x18, 0x5a, 0x78, 0xcf, 0x10, 0x5c, 0x1d, 0xfa, 0x11, 0x33, 0xc2, 0xb, + 0x0, 0x5, 0x5f, 0xf5, 0xb6, 0x4b, 0x9e, 0x18, 0x0, 0x0, 0x77, 0xb5, 0x28, 0xcf, 0x83, 0x0, 0x9e, + 0x2, 0x80, 0x1, 0x83, 0x2, 0x83, 0x97, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 31570); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], 0x8F); + EXPECT_EQ(packet_id, 10189); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x83); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x9E); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x83); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], 0x83); + EXPECT_EQ(granted_qos_levels[9], 0x97); + EXPECT_EQ(granted_qos_levels[10], 0xA2); } -// SubscribeResponse 15416 [Right QoS1,Left SubErrQuotaExceeded,Left SubErrTopicFilterInvalid,Right QoS1,Left -// SubErrWildcardSubscriptionsNotSupported] [PropReasonString "UR\224v\152+\STX,\214\DC3n\a|",PropServerReference -// "(\138\223\157\SOH\204T\NUL",PropWildcardSubscriptionAvailable 213,PropRequestResponseInformation -// 87,PropAuthenticationData "j",PropReasonString -// "#\220o\230\ACK\213\ETB\128\&6\210\203\&8k\246\153r\220\221\229\&3\204$e<\229",PropWillDelayInterval -// 3741,PropRetainAvailable 55,PropReasonString -// "\NAKS0\168\205\218\188]\133\197\v\176\DLE\167:\232=",PropResponseInformation -// "w\180\173FEt\146$\178|`\248\151R\252q>\a\147\169u\145Jt\218\133:",PropContentType -// "=u\246\161B\229\166\244,%\133\\\222\187\r\225",PropSessionExpiryInterval 20784] +// SubscribeResponse 11213 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right QoS0,Right +// QoS0,Right QoS0,Right QoS2,Left SubErrTopicFilterInvalid] [] TEST(SubACK5QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0x99, 0x1, 0x3c, 0x38, 0x90, 0x1, 0x1f, 0x0, 0xd, 0x55, 0x52, 0xe0, 0x76, 0x98, 0x2b, - 0x2, 0x2c, 0xd6, 0x13, 0x6e, 0x7, 0x7c, 0x1c, 0x0, 0x8, 0x28, 0x8a, 0xdf, 0x9d, 0x1, 0xcc, - 0x54, 0x0, 0x28, 0xd5, 0x19, 0x57, 0x16, 0x0, 0x1, 0x6a, 0x1f, 0x0, 0x19, 0x23, 0xdc, 0x6f, - 0xe6, 0x6, 0xd5, 0x17, 0x80, 0x36, 0xd2, 0xcb, 0x38, 0x6b, 0xf6, 0x99, 0x72, 0xdc, 0xdd, 0xe5, - 0x33, 0xcc, 0x24, 0x65, 0x3c, 0xe5, 0x18, 0x0, 0x0, 0xe, 0x9d, 0x25, 0x37, 0x1f, 0x0, 0x11, - 0x15, 0x53, 0x30, 0xa8, 0xcd, 0xda, 0xbc, 0x5d, 0x85, 0xc5, 0xb, 0xb0, 0x10, 0xa7, 0x3a, 0xe8, - 0x3d, 0x1a, 0x0, 0x1b, 0x77, 0xb4, 0xad, 0x46, 0x45, 0x74, 0x92, 0x24, 0xb2, 0x7c, 0x60, 0xf8, - 0x97, 0x52, 0xfc, 0x71, 0x3e, 0x7, 0x93, 0xa9, 0x75, 0x91, 0x4a, 0x74, 0xda, 0x85, 0x3a, 0x3, - 0x0, 0x10, 0x3d, 0x75, 0xf6, 0xa1, 0x42, 0xe5, 0xa6, 0xf4, 0x2c, 0x25, 0x85, 0x5c, 0xde, 0xbb, - 0xd, 0xe1, 0x11, 0x0, 0x0, 0x51, 0x30, 0x1, 0x97, 0x8f, 0x1, 0xa2}; + uint8_t pkt[] = {0x90, 0xa, 0x2b, 0xcd, 0x0, 0x9e, 0x97, 0x0, 0x0, 0x0, 0x2, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15416); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 11213); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], 0x9E); EXPECT_EQ(granted_qos_levels[1], 0x97); - EXPECT_EQ(granted_qos_levels[2], 0x8F); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], 0xA2); -} - -// SubscribeResponse 24411 [Right QoS2,Left SubErrImplementationSpecificError,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse] -// [PropSessionExpiryInterval 1993] + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x8F); +} + +// SubscribeResponse 16288 [Right QoS0,Right QoS1,Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Left +// SubErrNotAuthorized,Right QoS1,Right QoS1,Right QoS2,Left SubErrNotAuthorized] [PropTopicAliasMaximum +// 30519,PropAssignedClientIdentifier "\233\239U\129J\243",PropMessageExpiryInterval 32558,PropUserProperty +// "\140\191\189\162\129\153\128\203\DLEp\205" "\172\213\&7\228\140\170",PropSharedSubscriptionAvailable +// 227,PropCorrelationData +// "\159\199\&7X\\\t\169\209V\180C\206\158\198x,c\n|X\GS\214\165?%\128\199\131\131",PropSharedSubscriptionAvailable +// 133,PropRequestResponseInformation 128,PropServerReference "\230\155\144#\146\251\DELPI",PropSessionExpiryInterval +// 4721,PropContentType "\177d\239L\196",PropServerKeepAlive 26462,PropResponseTopic +// "\223\197\139",PropRequestProblemInformation 137,PropWillDelayInterval 16506,PropMessageExpiryInterval +// 3229,PropMaximumPacketSize 30608,PropServerKeepAlive 5792,PropSessionExpiryInterval 5438,PropServerReference "\201"] TEST(SubACK5QCTest, Decode11) { - uint8_t pkt[] = {0x90, 0xd, 0x5f, 0x5b, 0x5, 0x11, 0x0, 0x0, 0x7, 0xc9, 0x2, 0x83, 0x9e, 0xa2, 0x91}; + uint8_t pkt[] = {0x90, 0x99, 0x1, 0x3f, 0xa0, 0x8c, 0x1, 0x22, 0x77, 0x37, 0x12, 0x0, 0x6, 0xe9, 0xef, 0x55, + 0x81, 0x4a, 0xf3, 0x2, 0x0, 0x0, 0x7f, 0x2e, 0x26, 0x0, 0xb, 0x8c, 0xbf, 0xbd, 0xa2, 0x81, + 0x99, 0x80, 0xcb, 0x10, 0x70, 0xcd, 0x0, 0x6, 0xac, 0xd5, 0x37, 0xe4, 0x8c, 0xaa, 0x2a, 0xe3, + 0x9, 0x0, 0x1d, 0x9f, 0xc7, 0x37, 0x58, 0x5c, 0x9, 0xa9, 0xd1, 0x56, 0xb4, 0x43, 0xce, 0x9e, + 0xc6, 0x78, 0x2c, 0x63, 0xa, 0x7c, 0x58, 0x1d, 0xd6, 0xa5, 0x3f, 0x25, 0x80, 0xc7, 0x83, 0x83, + 0x2a, 0x85, 0x19, 0x80, 0x1c, 0x0, 0x9, 0xe6, 0x9b, 0x90, 0x23, 0x92, 0xfb, 0x7f, 0x50, 0x49, + 0x11, 0x0, 0x0, 0x12, 0x71, 0x3, 0x0, 0x5, 0xb1, 0x64, 0xef, 0x4c, 0xc4, 0x13, 0x67, 0x5e, + 0x8, 0x0, 0x3, 0xdf, 0xc5, 0x8b, 0x17, 0x89, 0x18, 0x0, 0x0, 0x40, 0x7a, 0x2, 0x0, 0x0, + 0xc, 0x9d, 0x27, 0x0, 0x0, 0x77, 0x90, 0x13, 0x16, 0xa0, 0x11, 0x0, 0x0, 0x15, 0x3e, 0x1c, + 0x0, 0x1, 0xc9, 0x0, 0x1, 0x80, 0x80, 0x87, 0x1, 0x1, 0x2, 0x87}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24411); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x83); - EXPECT_EQ(granted_qos_levels[2], 0x9E); - EXPECT_EQ(granted_qos_levels[3], 0xA2); - EXPECT_EQ(granted_qos_levels[4], 0x91); -} - -// SubscribeResponse 16797 [Right QoS0,Right QoS0,Right QoS1,Right QoS2,Left SubErrUnspecifiedError,Right QoS0,Right -// QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrNotAuthorized,Left -// SubErrSubscriptionIdentifiersNotSupported] [PropSubscriptionIdentifier 28,PropAssignedClientIdentifier -// "\157\160\131\&3o4[\141\&6`\138#\232\b\185\147\220A",PropRequestProblemInformation 41,PropResponseTopic -// "\191\&4\176\SO\193\176(\134L\195Y\236\240\172\154xUkI",PropResponseTopic -// "]\196\DLE{\172\245{u\166O\224T`\210\208zi\250",PropMaximumQoS 110,PropContentType -// "*2\191\163\148\SUB\182\231t\141\145\210\235\169\212:\\4\129Vl\RS\146<\155Sw\199\DC1",PropMessageExpiryInterval -// 20196,PropServerReference -// "e80\133\163\185\239\222\US\131\250c\ACK\131\184+E\193Q\196\NAK\166",PropSessionExpiryInterval -// 192,PropWildcardSubscriptionAvailable 89,PropRetainAvailable 70,PropServerKeepAlive 27803,PropReceiveMaximum -// 26170,PropPayloadFormatIndicator 240,PropSubscriptionIdentifier 7,PropReceiveMaximum 3282,PropServerKeepAlive -// 17130,PropMessageExpiryInterval 15690,PropReceiveMaximum 22602,PropMaximumPacketSize 28367,PropTopicAlias -// 20614,PropWillDelayInterval 4977,PropAuthenticationMethod -// "adv56\218\248\ETB\168\168\172\190m\189\SI\b\134;",PropResponseInformation -// "\\\201\144\152\218&\225Gz\145\135\131\145\190\152'\230"] -TEST(SubACK5QCTest, Decode12) { - uint8_t pkt[] = {0x90, 0xe9, 0x1, 0x41, 0x9d, 0xdb, 0x1, 0xb, 0x1c, 0x12, 0x0, 0x12, 0x9d, 0xa0, 0x83, 0x33, 0x6f, - 0x34, 0x5b, 0x8d, 0x36, 0x60, 0x8a, 0x23, 0xe8, 0x8, 0xb9, 0x93, 0xdc, 0x41, 0x17, 0x29, 0x8, 0x0, - 0x13, 0xbf, 0x34, 0xb0, 0x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 0x0, 0x0, 0x1, 0x2, 0x80, 0x0, 0x0, 0x9e, 0x87, 0xa1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 16797); - EXPECT_EQ(count, 10); + EXPECT_EQ(packet_id, 16288); + EXPECT_EQ(count, 9); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x9E); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x87); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[8], 0x87); - EXPECT_EQ(granted_qos_levels[9], 0xA1); } -// SubscribeResponse 8011 [Right QoS0,Right QoS2,Right QoS2,Left SubErrTopicFilterInvalid,Left -// SubErrTopicFilterInvalid,Right QoS2] [PropWildcardSubscriptionAvailable 104,PropServerKeepAlive -// 27826,PropResponseTopic "\152\138\201\137\152\144\228\aI\CAN\193\146&2sX\a#\\L",PropMessageExpiryInterval -// 4121,PropTopicAliasMaximum 25788,PropSharedSubscriptionAvailable 229,PropTopicAliasMaximum 11111,PropUserProperty -// "\EM\170\205\SUB\162\&4\175u\231\174%}P+\ETB\190\&6m\200\GSK\161/@\255\&7" -// "\254\188D\186\GS\193z\241R\201\139@\200!\SOH\184\&5\191\228",PropAuthenticationData -// "\131oJHx6\173\DC1\180\US\146n2\220\237`\227\157r<\202\b\b\187\219F\172=\177",PropRequestResponseInformation 60] +// SubscribeResponse 12823 [Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported] [PropCorrelationData "\181\216w _\250\170I\a",PropUserProperty +// "\174\196\238\142\&6N\212\r+\GS\b\231\192IT\198l\129\217c\163nq\185" "p\154\162\140`",PropPayloadFormatIndicator +// 64,PropMessageExpiryInterval 2937,PropMaximumQoS 140,PropContentType "\FS\227!",PropContentType +// "/~*\155\194\159]\161Z\192\184\238\SOH\244\131\188\188e\198]\165\244\130",PropRequestProblemInformation +// 85,PropRequestProblemInformation 65,PropSubscriptionIdentifier 18,PropTopicAlias 24580,PropReceiveMaximum +// 215,PropSharedSubscriptionAvailable 136,PropRetainAvailable 236,PropSessionExpiryInterval 15801,PropTopicAliasMaximum +// 8932,PropPayloadFormatIndicator 162,PropReceiveMaximum 27309,PropWillDelayInterval +// 22879,PropRequestProblemInformation 244,PropUserProperty "\186r" +// "B\242|$\ENQd\137\247B\200\&0\252\153\DC1\189\251\EOT)X",PropResponseTopic +// "\196\133\188\245\r\183",PropAuthenticationData +// "u@\182\ETX\192{\196\STX\175\135\196LR\166\209\&7E)N\138\159\204B\204\SUB",PropContentType +// "$\v\152'L\184\242",PropServerReference "\178 \186\207\147>\158u\NAKh\215\EOT\ACK\191\181",PropWillDelayInterval +// 5469,PropMessageExpiryInterval 27203] +TEST(SubACK5QCTest, Decode12) { + uint8_t pkt[] = {0x90, 0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f, 0xcc, 0x42, 0xcc, 0x1a, 0x3, 0x0, 0x7, 0x24, 0xb, 0x98, 0x27, 0x4c, 0xb8, 0xf2, 0x1c, + 0x0, 0xf, 0xb2, 0x20, 0xba, 0xcf, 0x93, 0x3e, 0x9e, 0x75, 0x15, 0x68, 0xd7, 0x4, 0x6, 0xbf, 0xb5, + 0x18, 0x0, 0x0, 0x15, 0x5d, 0x2, 0x0, 0x0, 0x6a, 0x43, 0x8f, 0xa1, 0x0, 0x9e}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 12823); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x8F); + EXPECT_EQ(granted_qos_levels[1], 0xA1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x9E); +} + +// SubscribeResponse 27996 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS2,Left +// SubErrImplementationSpecificError,Right QoS1,Right QoS2,Left SubErrUnspecifiedError,Left +// SubErrTopicFilterInvalid,Left SubErrPacketIdentifierInUse,Left SubErrSharedSubscriptionsNotSupported] +// [PropRequestProblemInformation 225,PropReceiveMaximum 12966,PropMaximumPacketSize 9315,PropSubscriptionIdentifier +// 22,PropContentType "\242\143",PropReasonString "y",PropContentType "\221\186\187\DLE!\219F",PropTopicAlias +// 31775,PropSharedSubscriptionAvailable 225,PropPayloadFormatIndicator 94,PropRequestResponseInformation 212] TEST(SubACK5QCTest, Decode13) { - uint8_t pkt[] = {0x90, 0x86, 0x1, 0x1f, 0x4b, 0x7d, 0x28, 0x68, 0x13, 0x6c, 0xb2, 0x8, 0x0, 0x14, 0x98, 0x8a, - 0xc9, 0x89, 0x98, 0x90, 0xe4, 0x7, 0x49, 0x18, 0xc1, 0x92, 0x26, 0x32, 0x73, 0x58, 0x7, 0x23, - 0x5c, 0x4c, 0x2, 0x0, 0x0, 0x10, 0x19, 0x22, 0x64, 0xbc, 0x2a, 0xe5, 0x22, 0x2b, 0x67, 0x26, - 0x0, 0x1a, 0x19, 0xaa, 0xcd, 0x1a, 0xa2, 0x34, 0xaf, 0x75, 0xe7, 0xae, 0x25, 0x7d, 0x50, 0x2b, - 0x17, 0xbe, 0x36, 0x6d, 0xc8, 0x1d, 0x4b, 0xa1, 0x2f, 0x40, 0xff, 0x37, 0x0, 0x13, 0xfe, 0xbc, - 0x44, 0xba, 0x1d, 0xc1, 0x7a, 0xf1, 0x52, 0xc9, 0x8b, 0x40, 0xc8, 0x21, 0x1, 0xb8, 0x35, 0xbf, - 0xe4, 0x16, 0x0, 0x1d, 0x83, 0x6f, 0x4a, 0x48, 0x78, 0x36, 0xad, 0x11, 0xb4, 0x1f, 0x92, 0x6e, - 0x32, 0xdc, 0xed, 0x60, 0xe3, 0x9d, 0x72, 0x3c, 0xca, 0x8, 0x8, 0xbb, 0xdb, 0x46, 0xac, 0x3d, - 0xb1, 0x19, 0x3c, 0x0, 0x2, 0x2, 0x8f, 0x8f, 0x2}; + uint8_t pkt[] = {0x90, 0x35, 0x6d, 0x5c, 0x28, 0x17, 0xe1, 0x21, 0x32, 0xa6, 0x27, 0x0, 0x0, 0x24, + 0x63, 0xb, 0x16, 0x3, 0x0, 0x2, 0xf2, 0x8f, 0x1f, 0x0, 0x1, 0x79, 0x3, 0x0, + 0x7, 0xdd, 0xba, 0xbb, 0x10, 0x21, 0xdb, 0x46, 0x23, 0x7c, 0x1f, 0x2a, 0xe1, 0x1, + 0x5e, 0x19, 0xd4, 0x9e, 0x2, 0x2, 0x83, 0x1, 0x2, 0x80, 0x8f, 0x91, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8011); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 27996); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x9E); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x8F); - EXPECT_EQ(granted_qos_levels[4], 0x8F); + EXPECT_EQ(granted_qos_levels[3], 0x83); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x8F); + EXPECT_EQ(granted_qos_levels[8], 0x91); + EXPECT_EQ(granted_qos_levels[9], 0x9E); } -// SubscribeResponse 32745 [Right QoS0,Right QoS2,Right QoS1,Left SubErrNotAuthorized,Right QoS0,Right QoS2,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS2] [PropReceiveMaximum 16091,PropServerKeepAlive -// 6465,PropContentType "\192\215\&9m\STXl",PropPayloadFormatIndicator 155,PropCorrelationData -// "qr\253vwH\"T\138Pz*a\133\rJx\RS\183l\236\SO\187\210",PropMessageExpiryInterval 7888,PropResponseInformation -// "\SO\255\133",PropMaximumQoS 64,PropRequestProblemInformation 112,PropMaximumQoS 105,PropResponseInformation -// "\156My%\245\218|R\DC3y\132)\177y\208\230*\221S\201\214\SUB\182\153\156\215",PropWildcardSubscriptionAvailable -// 185,PropServerKeepAlive 28165,PropTopicAlias 32215,PropPayloadFormatIndicator 122,PropSubscriptionIdentifierAvailable -// 114,PropReasonString -// "\204t/\180D\188H(\225\194\162\tK\183\226\252\234\177\155\216\182\192\193t\236uY\209\EMl",PropMessageExpiryInterval -// 28202,PropRequestResponseInformation 201,PropWillDelayInterval 32683,PropUserProperty -// "\189a\159\209i\181\135AI\142\SI\192\DC3\RS" -// "\160\232I0\177\153\175\131\194\150\156\144\138\184\"&m\187",PropAuthenticationData -// "\142'\164\181\151\201T\199M\225",PropAssignedClientIdentifier -// "z\135u.9\ESC\236\152\230\SIla\135*5\DLEt\142\237\131>\140\214\a,\186}",PropServerKeepAlive -// 8604,PropMessageExpiryInterval 6304,PropSessionExpiryInterval 18034,PropResponseTopic -// "\225#\206\SYN6\168?s\142\196\129\176\194\238\206>\247\164."] +// SubscribeResponse 30878 [Left SubErrUnspecifiedError,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left +// SubErrTopicFilterInvalid,Right QoS0] [PropWildcardSubscriptionAvailable 185] TEST(SubACK5QCTest, Decode14) { - uint8_t pkt[] = { - 0x90, 0x92, 0x2, 0x7f, 0xe9, 0x86, 0x2, 0x21, 0x3e, 0xdb, 0x13, 0x19, 0x41, 0x3, 0x0, 0x6, 0xc0, 0xd7, 0x39, - 0x6d, 0x2, 0x6c, 0x1, 0x9b, 0x9, 0x0, 0x18, 0x71, 0x72, 0xfd, 0x76, 0x77, 0x48, 0x22, 0x54, 0x8a, 0x50, 0x7a, - 0x2a, 0x61, 0x85, 0xd, 0x4a, 0x78, 0x1e, 0xb7, 0x6c, 0xec, 0xe, 0xbb, 0xd2, 0x2, 0x0, 0x0, 0x1e, 0xd0, 0x1a, - 0x0, 0x3, 0xe, 0xff, 0x85, 0x24, 0x40, 0x17, 0x70, 0x24, 0x69, 0x1a, 0x0, 0x1a, 0x9c, 0x4d, 0x79, 0x25, 0xf5, - 0xda, 0x7c, 0x52, 0x13, 0x79, 0x84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, 0xa4, 0x2e, 0x0, 0x2, 0x1, 0x87, 0x0, 0x2, 0xa2, 0x2}; + uint8_t pkt[] = {0x90, 0xd, 0x78, 0x9e, 0x2, 0x28, 0xb9, 0x80, 0x1, 0xa2, 0x80, 0xa2, 0x80, 0x8f, 0x0}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[8]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32745); + EXPECT_EQ(packet_id, 30878); EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x87); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0xA2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0xA2); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0xA2); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x8F); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); } -// SubscribeResponse 8548 [Right QoS1,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS0] [PropTopicAlias 17510,PropReasonString -// "\SUBz\136\SOH\175\232\242.\SOH?H\147\DEL\194\173r(",PropReceiveMaximum 13803,PropServerKeepAlive 3961,PropTopicAlias -// 14018,PropWillDelayInterval 26965,PropAuthenticationMethod -// "\212\203\150]\213w\NULg\128\STXx\255\180\158P\129Z\233",PropSharedSubscriptionAvailable -// 106,PropSharedSubscriptionAvailable 110,PropSubscriptionIdentifier 3,PropSessionExpiryInterval 26894,PropReasonString -// "=/\188D,L\242t\169c\175\197\228\SYN\153\233\208\217",PropAuthenticationData -// "}\NUL$\158\EM\169\183h2f\230\222\159\234\149Mw\221y\240",PropResponseTopic -// "\172\195E\187D\136f4W*\252\244'4\DC2",PropWildcardSubscriptionAvailable 241,PropSubscriptionIdentifierAvailable -// 71,PropMaximumPacketSize 22821] +// SubscribeResponse 7754 [Right QoS0,Right QoS2,Right QoS1,Right QoS1,Right QoS1,Right QoS2,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS0,Right QoS1,Left +// SubErrSubscriptionIdentifiersNotSupported] [PropAuthenticationMethod +// "\139\254\DC4\195\152n\197k\139\CAN\241/",PropSubscriptionIdentifier 10,PropReasonString +// "p\148(\243\SO\251\216$5\205\163\DEL\148\245\f",PropResponseInformation +// "\165\n\DC4\SYN\178\185\135\214\SO\150`\218!\t-\159\fv\248\STX,\193\159 Y"] TEST(SubACK5QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0x95, 0x1, 0x21, 0x64, 0x8c, 0x1, 0x23, 0x44, 0x66, 0x1f, 0x0, 0x11, 0x1a, 0x7a, 0x88, 0x1, - 0xaf, 0xe8, 0xf2, 0x2e, 0x1, 0x3f, 0x48, 0x93, 0x7f, 0xc2, 0xad, 0x72, 0x28, 0x21, 0x35, 0xeb, 0x13, - 0xf, 0x79, 0x23, 0x36, 0xc2, 0x18, 0x0, 0x0, 0x69, 0x55, 0x15, 0x0, 0x12, 0xd4, 0xcb, 0x96, 0x5d, - 0xd5, 0x77, 0x0, 0x67, 0x80, 0x2, 0x78, 0xff, 0xb4, 0x9e, 0x50, 0x81, 0x5a, 0xe9, 0x2a, 0x6a, 0x2a, - 0x6e, 0xb, 0x3, 0x11, 0x0, 0x0, 0x69, 0xe, 0x1f, 0x0, 0x12, 0x3d, 0x2f, 0xbc, 0x44, 0x2c, 0x4c, - 0xf2, 0x74, 0xa9, 0x63, 0xaf, 0xc5, 0xe4, 0x16, 0x99, 0xe9, 0xd0, 0xd9, 0x16, 0x0, 0x14, 0x7d, 0x0, - 0x24, 0x9e, 0x19, 0xa9, 0xb7, 0x68, 0x32, 0x66, 0xe6, 0xde, 0x9f, 0xea, 0x95, 0x4d, 0x77, 0xdd, 0x79, - 0xf0, 0x8, 0x0, 0xf, 0xac, 0xc3, 0x45, 0xbb, 0x44, 0x88, 0x66, 0x34, 0x57, 0x2a, 0xfc, 0xf4, 0x27, - 0x34, 0x12, 0x28, 0xf1, 0x29, 0x47, 0x27, 0x0, 0x0, 0x59, 0x25, 0x1, 0x2, 0xa2, 0xa2, 0x0}; + uint8_t pkt[] = {0x90, 0x4d, 0x1e, 0x4a, 0x3f, 0x15, 0x0, 0xc, 0x8b, 0xfe, 0x14, 0xc3, 0x98, 0x6e, 0xc5, 0x6b, + 0x8b, 0x18, 0xf1, 0x2f, 0xb, 0xa, 0x1f, 0x0, 0xf, 0x70, 0x94, 0x28, 0xf3, 0xe, 0xfb, 0xd8, + 0x24, 0x35, 0xcd, 0xa3, 0x7f, 0x94, 0xf5, 0xc, 0x1a, 0x0, 0x19, 0xa5, 0xa, 0x14, 0x16, 0xb2, + 0xb9, 0x87, 0xd6, 0xe, 0x96, 0x60, 0xda, 0x21, 0x9, 0x2d, 0x9f, 0xc, 0x76, 0xf8, 0x2, 0x2c, + 0xc1, 0x9f, 0x20, 0x59, 0x0, 0x2, 0x1, 0x1, 0x1, 0x2, 0x9e, 0x1, 0x0, 0x1, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8548); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 7754); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0xA2); - EXPECT_EQ(granted_qos_levels[3], 0xA2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x9E); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[10], 0xA1); } -// SubscribeResponse 12279 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left -// SubErrTopicFilterInvalid] [PropServerKeepAlive 32670,PropServerReference -// "\248|\170\178I\184\247*\DLE|\226\136\232?b\240",PropRetainAvailable 121] +// SubscribeResponse 29991 [Left SubErrPacketIdentifierInUse,Right QoS1,Right QoS0,Left +// SubErrPacketIdentifierInUse,Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS0] [PropTopicAliasMaximum 3368,PropWildcardSubscriptionAvailable +// 46,PropServerReference "wF\202\DEL\134\171H\239\153J\ETX\DLE\DLE/H\190un",PropReasonString +// "$\130\250\&1~1\173\158_\196\130\241\&2\141)\138h\EOT-Z\n",PropPayloadFormatIndicator 204,PropTopicAlias +// 21439,PropAssignedClientIdentifier "\227\STX\228>K\187",PropRequestProblemInformation 245,PropPayloadFormatIndicator +// 235,PropSubscriptionIdentifier 13,PropServerReference "\237\249\f\243\191\254\129\ACK\226%\232",PropTopicAliasMaximum +// 15309,PropReceiveMaximum 23314] TEST(SubACK5QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0x1f, 0x2f, 0xf7, 0x18, 0x13, 0x7f, 0x9e, 0x1c, 0x0, 0x10, 0xf8, 0x7c, 0xaa, 0xb2, 0x49, 0xb8, - 0xf7, 0x2a, 0x10, 0x7c, 0xe2, 0x88, 0xe8, 0x3f, 0x62, 0xf0, 0x25, 0x79, 0x2, 0x9e, 0x1, 0x8f}; + uint8_t pkt[] = {0x90, 0x66, 0x75, 0x27, 0x5a, 0x22, 0xd, 0x28, 0x28, 0x2e, 0x1c, 0x0, 0x12, 0x77, 0x46, + 0xca, 0x7f, 0x86, 0xab, 0x48, 0xef, 0x99, 0x4a, 0x3, 0x10, 0x10, 0x2f, 0x48, 0xbe, 0x75, + 0x6e, 0x1f, 0x0, 0x15, 0x24, 0x82, 0xfa, 0x31, 0x7e, 0x31, 0xad, 0x9e, 0x5f, 0xc4, 0x82, + 0xf1, 0x32, 0x8d, 0x29, 0x8a, 0x68, 0x4, 0x2d, 0x5a, 0xa, 0x1, 0xcc, 0x23, 0x53, 0xbf, + 0x12, 0x0, 0x6, 0xe3, 0x2, 0xe4, 0x3e, 0x4b, 0xbb, 0x17, 0xf5, 0x1, 0xeb, 0xb, 0xd, + 0x1c, 0x0, 0xb, 0xed, 0xf9, 0xc, 0xf3, 0xbf, 0xfe, 0x81, 0x6, 0xe2, 0x25, 0xe8, 0x22, + 0x3b, 0xcd, 0x21, 0x5b, 0x12, 0x91, 0x1, 0x0, 0x91, 0x1, 0x1, 0x83, 0xa1, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12279); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x9E); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x8F); + EXPECT_EQ(packet_id, 29991); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x91); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x83); + EXPECT_EQ(granted_qos_levels[7], 0xA1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); } -// SubscribeResponse 8001 [Right QoS2,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS2,Left -// SubErrNotAuthorized,Left SubErrWildcardSubscriptionsNotSupported] [PropTopicAliasMaximum 3486,PropRetainAvailable -// 25,PropMessageExpiryInterval 11544] +// SubscribeResponse 6273 [Right QoS1,Right QoS0] [PropWildcardSubscriptionAvailable 63,PropAssignedClientIdentifier +// "*\165!\210&D\246\SO\ENQ\162{\ACKv\DELm\SUB\142"] TEST(SubACK5QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0x14, 0x1f, 0x41, 0xa, 0x22, 0xd, 0x9e, 0x25, 0x19, 0x2, - 0x0, 0x0, 0x2d, 0x18, 0x2, 0x0, 0xa2, 0x2, 0x2, 0x87, 0xa2}; + uint8_t pkt[] = {0x90, 0x1b, 0x18, 0x81, 0x16, 0x28, 0x3f, 0x12, 0x0, 0x11, 0x2a, 0xa5, 0x21, 0xd2, 0x26, + 0x44, 0xf6, 0xe, 0x5, 0xa2, 0x7b, 0x6, 0x76, 0x7f, 0x6d, 0x1a, 0x8e, 0x1, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8001); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 6273); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0xA2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x87); - EXPECT_EQ(granted_qos_levels[6], 0xA2); } -// SubscribeResponse 4988 [Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrNotAuthorized,Left -// SubErrImplementationSpecificError,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS2] [PropRequestProblemInformation -// 33,PropRequestProblemInformation 126,PropMessageExpiryInterval 30345,PropMaximumPacketSize -// 17191,PropPayloadFormatIndicator 186,PropWillDelayInterval 18701,PropTopicAliasMaximum -// 21991,PropMessageExpiryInterval 10612,PropRequestResponseInformation 157,PropAuthenticationData -// "$\223u\CANl\200\208M\SO8C&\131\DEL\250\209\136\136\155Y\165\232\225",PropMessageExpiryInterval -// 6146,PropSubscriptionIdentifier 5,PropMessageExpiryInterval 4255,PropPayloadFormatIndicator 169,PropWillDelayInterval -// 3779,PropSubscriptionIdentifierAvailable 17,PropRequestProblemInformation 73,PropAuthenticationData -// "\240s\172C\193\204P\197\208\224\149p!\241\245\210f\148@",PropServerKeepAlive -// 30539,PropSubscriptionIdentifierAvailable 126,PropResponseInformation -// "\222\132B\SOH(\DC2\EM\251L\187b7|\177\232mv\136\136\&2\202\254"] +// SubscribeResponse 10407 [Left SubErrUnspecifiedError] [PropRequestProblemInformation +// 215,PropWildcardSubscriptionAvailable 161,PropRetainAvailable 44,PropMaximumQoS 1,PropMessageExpiryInterval +// 21069,PropAuthenticationData "~\EOTwE'\249\129\197\212\195\201\167&\208\240",PropMaximumQoS +// 34,PropSubscriptionIdentifier 17,PropAssignedClientIdentifier "\154\193\171B\f\171G",PropAuthenticationData +// "",PropResponseTopic +// "C\DC2\141\138W\234\235\136\177h\226\255\134\137b\148'ig\SOHZc]X\244\199\176+",PropWillDelayInterval +// 26669,PropReceiveMaximum 7925,PropAssignedClientIdentifier +// "0\147\&6\EM\231p\235\254Rk+\131\141",PropMaximumPacketSize 3698,PropAssignedClientIdentifier +// "\ACKJ\SOH\254Mb\131\138\192B\140\156\191\239\217\245;7\139\&1/u\215\139\&1\222\186\183",PropResponseInformation +// "\250e\DC1E\212\204?7y\236n0C\r",PropMaximumPacketSize 6648,PropReceiveMaximum +// 24409,PropSubscriptionIdentifierAvailable 230,PropWillDelayInterval 7378,PropServerKeepAlive +// 31324,PropSubscriptionIdentifier 6,PropSharedSubscriptionAvailable 10,PropAuthenticationData +// "\167\179MJ\ETX\174\185\166;\175\157nX\146",PropMessageExpiryInterval 8462,PropCorrelationData +// "\198f%h\140\253\213g#\163\251X\DC4\194\&4N\247\129\168\148\143\248Xc\138\215",PropUserProperty +// "\140\194m$C\226\235\183Gt\176\210\135\169H\133\144\213\156Z" "\176p9\ETB2y\251o<\145%\173\ENQ\244AX\r\204\167\238"] TEST(SubACK5QCTest, Decode18) { - uint8_t pkt[] = {0x90, 0x93, 0x1, 0x13, 0x7c, 0x84, 0x1, 0x17, 0x21, 0x17, 0x7e, 0x2, 0x0, 0x0, 0x76, 0x89, 0x27, - 0x0, 0x0, 0x43, 0x27, 0x1, 0xba, 0x18, 0x0, 0x0, 0x49, 0xd, 0x22, 0x55, 0xe7, 0x2, 0x0, 0x0, - 0x29, 0x74, 0x19, 0x9d, 0x16, 0x0, 0x17, 0x24, 0xdf, 0x75, 0x18, 0x6c, 0xc8, 0xd0, 0x4d, 0xe, 0x38, - 0x43, 0x26, 0x83, 0x7f, 0xfa, 0xd1, 0x88, 0x88, 0x9b, 0x59, 0xa5, 0xe8, 0xe1, 0x2, 0x0, 0x0, 0x18, - 0x2, 0xb, 0x5, 0x2, 0x0, 0x0, 0x10, 0x9f, 0x1, 0xa9, 0x18, 0x0, 0x0, 0xe, 0xc3, 0x29, 0x11, - 0x17, 0x49, 0x16, 0x0, 0x13, 0xf0, 0x73, 0xac, 0x43, 0xc1, 0xcc, 0x50, 0xc5, 0xd0, 0xe0, 0x95, 0x70, - 0x21, 0xf1, 0xf5, 0xd2, 0x66, 0x94, 0x40, 0x13, 0x77, 0x4b, 0x29, 0x7e, 0x1a, 0x0, 0x16, 0xde, 0x84, - 0x42, 0x1, 0x28, 0x12, 0x19, 0xfb, 0x4c, 0xbb, 0x62, 0x37, 0x7c, 0xb1, 0xe8, 0x6d, 0x76, 0x88, 0x88, - 0x32, 0xca, 0xfe, 0x8f, 0x0, 0x87, 0x83, 0xa2, 0x9e, 0x0, 0xa1, 0x9e, 0x1, 0x2}; + uint8_t pkt[] = { + 0x90, 0x97, 0x2, 0x28, 0xa7, 0x92, 0x2, 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a6, 0x3b, 0xaf, 0x9d, 0x6e, 0x58, 0x92, 0x2, 0x0, 0x0, 0x21, 0xe, 0x9, 0x0, + 0x1a, 0xc6, 0x66, 0x25, 0x68, 0x8c, 0xfd, 0xd5, 0x67, 0x23, 0xa3, 0xfb, 0x58, 0x14, 0xc2, 0x34, 0x4e, 0xf7, 0x81, + 0xa8, 0x94, 0x8f, 0xf8, 0x58, 0x63, 0x8a, 0xd7, 0x26, 0x0, 0x14, 0x8c, 0xc2, 0x6d, 0x24, 0x43, 0xe2, 0xeb, 0xb7, + 0x47, 0x74, 0xb0, 0xd2, 0x87, 0xa9, 0x48, 0x85, 0x90, 0xd5, 0x9c, 0x5a, 0x0, 0x14, 0xb0, 0x70, 0x39, 0x17, 0x32, + 0x79, 0xfb, 0x6f, 0x3c, 0x91, 0x25, 0xad, 0x5, 0xf4, 0x41, 0x58, 0xd, 0xcc, 0xa7, 0xee, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4988); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x8F); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x87); - EXPECT_EQ(granted_qos_levels[3], 0x83); - EXPECT_EQ(granted_qos_levels[4], 0xA2); - EXPECT_EQ(granted_qos_levels[5], 0x9E); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0xA1); - EXPECT_EQ(granted_qos_levels[8], 0x9E); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS2); -} - -// SubscribeResponse 6982 [Right QoS0,Left SubErrTopicFilterInvalid,Left SubErrQuotaExceeded,Left -// SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS2,Right QoS0,Right QoS1,Left SubErrTopicFilterInvalid,Left -// SubErrTopicFilterInvalid,Right QoS0] [PropReceiveMaximum 16887,PropUserProperty -// "\169\DC3\148_\DC3\191\137e\175\"\132\134n!q\210z\157\165y\214\217f\252D" -// "\233\212\209L\198A+\137\246\ETX",PropRequestResponseInformation 92,PropSubscriptionIdentifierAvailable -// 37,PropContentType "\238rR\162\236\b\202+\248\164\SUB`\246W\USD]QZ~\b\155L^r\200\253u-",PropMessageExpiryInterval -// 25037,PropTopicAlias 16205,PropMessageExpiryInterval 24486,PropServerKeepAlive 17359,PropAssignedClientIdentifier -// "\176\222\SI\248\250\"d~v\212\ETB\215",PropTopicAlias 9629,PropCorrelationData -// "6QV>\254\184\233P\DC2\199i\135\162?\160\CAN[,R/\158\ESC\187|Y\145`\fx",PropRetainAvailable 137] + EXPECT_EQ(packet_id, 10407); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], 0x80); +} + +// SubscribeResponse 13436 [Left SubErrPacketIdentifierInUse,Left SubErrImplementationSpecificError,Left +// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left SubErrNotAuthorized,Right QoS0,Right QoS1,Left +// SubErrQuotaExceeded,Right QoS0,Right QoS0] [PropServerKeepAlive 21556,PropReceiveMaximum 13390,PropUserProperty +// "P\129" "\198\207\160",PropTopicAliasMaximum 22735,PropTopicAliasMaximum 13713,PropCorrelationData +// "\219\137\CAN\153\223\\\198\164\161\190,\255e\253\219\211",PropSessionExpiryInterval 27448,PropMaximumPacketSize +// 13892,PropReasonString "\149\204[\147\151\198\145\131\EM~\250\&3\174\161\136\254\148n",PropReceiveMaximum +// 27195,PropTopicAlias 857,PropAuthenticationMethod +// "\ESC\233\211\237\133\246\177\198\212\136\213\160\154\143\202\143z\ETB\ESCW",PropSubscriptionIdentifier +// 20,PropSubscriptionIdentifierAvailable 95] TEST(SubACK5QCTest, Decode19) { - uint8_t pkt[] = {0x90, 0xa2, 0x1, 0x1b, 0x46, 0x93, 0x1, 0x21, 0x41, 0xf7, 0x26, 0x0, 0x19, 0xa9, 0x13, 0x94, 0x5f, - 0x13, 0xbf, 0x89, 0x65, 0xaf, 0x22, 0x84, 0x86, 0x6e, 0x21, 0x71, 0xd2, 0x7a, 0x9d, 0xa5, 0x79, 0xd6, - 0xd9, 0x66, 0xfc, 0x44, 0x0, 0xa, 0xe9, 0xd4, 0xd1, 0x4c, 0xc6, 0x41, 0x2b, 0x89, 0xf6, 0x3, 0x19, - 0x5c, 0x29, 0x25, 0x3, 0x0, 0x1d, 0xee, 0x72, 0x52, 0xa2, 0xec, 0x8, 0xca, 0x2b, 0xf8, 0xa4, 0x1a, - 0x60, 0xf6, 0x57, 0x1f, 0x44, 0x5d, 0x51, 0x5a, 0x7e, 0x8, 0x9b, 0x4c, 0x5e, 0x72, 0xc8, 0xfd, 0x75, - 0x2d, 0x2, 0x0, 0x0, 0x61, 0xcd, 0x23, 0x3f, 0x4d, 0x2, 0x0, 0x0, 0x5f, 0xa6, 0x13, 0x43, 0xcf, - 0x12, 0x0, 0xc, 0xb0, 0xde, 0xf, 0xf8, 0xfa, 0x22, 0x64, 0x7e, 0x76, 0xd4, 0x17, 0xd7, 0x23, 0x25, - 0x9d, 0x9, 0x0, 0x1d, 0x36, 0x51, 0x56, 0x3e, 0xfe, 0xb8, 0xe9, 0x50, 0x12, 0xc7, 0x69, 0x87, 0xa2, - 0x3f, 0xa0, 0x18, 0x5b, 0x2c, 0x52, 0x2f, 0x9e, 0x1b, 0xbb, 0x7c, 0x59, 0x91, 0x60, 0xc, 0x78, 0x25, - 0x89, 0x0, 0x8f, 0x97, 0x80, 0x87, 0x2, 0x0, 0x1, 0x8f, 0x8f, 0x0}; + uint8_t pkt[] = {0x90, 0x76, 0x34, 0x7c, 0x69, 0x13, 0x54, 0x34, 0x21, 0x34, 0x4e, 0x26, 0x0, 0x2, 0x50, + 0x81, 0x0, 0x3, 0xc6, 0xcf, 0xa0, 0x22, 0x58, 0xcf, 0x22, 0x35, 0x91, 0x9, 0x0, 0x10, + 0xdb, 0x89, 0x18, 0x99, 0xdf, 0x5c, 0xc6, 0xa4, 0xa1, 0xbe, 0x2c, 0xff, 0x65, 0xfd, 0xdb, + 0xd3, 0x11, 0x0, 0x0, 0x6b, 0x38, 0x27, 0x0, 0x0, 0x36, 0x44, 0x1f, 0x0, 0x12, 0x95, + 0xcc, 0x5b, 0x93, 0x97, 0xc6, 0x91, 0x83, 0x19, 0x7e, 0xfa, 0x33, 0xae, 0xa1, 0x88, 0xfe, + 0x94, 0x6e, 0x21, 0x6a, 0x3b, 0x23, 0x3, 0x59, 0x15, 0x0, 0x14, 0x1b, 0xe9, 0xd3, 0xed, + 0x85, 0xf6, 0xb1, 0xc6, 0xd4, 0x88, 0xd5, 0xa0, 0x9a, 0x8f, 0xca, 0x8f, 0x7a, 0x17, 0x1b, + 0x57, 0xb, 0x14, 0x29, 0x5f, 0x91, 0x83, 0x83, 0x97, 0x87, 0x0, 0x1, 0x97, 0x0, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6982); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x8F); - EXPECT_EQ(granted_qos_levels[2], 0x97); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(packet_id, 13436); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], 0x83); + EXPECT_EQ(granted_qos_levels[3], 0x97); EXPECT_EQ(granted_qos_levels[4], 0x87); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0x8F); - EXPECT_EQ(granted_qos_levels[9], 0x8F); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); -} - -// SubscribeResponse 25134 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrImplementationSpecificError,Right -// QoS2,Left SubErrNotAuthorized,Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrQuotaExceeded] [PropResponseInformation "!\ENQ\EM\212\211",PropSharedSubscriptionAvailable -// 125,PropSessionExpiryInterval 15656,PropRequestProblemInformation 3,PropRequestResponseInformation -// 24,PropRequestResponseInformation 18,PropWildcardSubscriptionAvailable 148,PropAuthenticationData -// "=\234\&7_\217\238V{\162\&8\186\"\221\201u",PropReasonString -// "\197\161\SI\DC1\143w\149\152\252UR\242(",PropSharedSubscriptionAvailable 137,PropReceiveMaximum -// 13195,PropUserProperty "\197\131\&0(" "\232\181\SYN\215*}\223gi'5I\179",PropSharedSubscriptionAvailable -// 238,PropTopicAlias 27840,PropAssignedClientIdentifier -// "\NULs\vk\NUL\167J\131\133\249\237wq\216b\149\218~\220\139&\203",PropAuthenticationData -// "\"'V0\133\\\247\245\240\196}\245\&9\DLEw\143\184",PropAuthenticationData "& \222\239xv\ESC",PropResponseTopic -// "\205\DEL\233\155Fs\145n\180\219=\196'G\175\SYN\237\214\237\149\163Z \221\176\174U\DC1Z",PropSessionExpiryInterval -// 23440,PropServerKeepAlive 21999,PropCorrelationData -// "\248S\212\178_\170\r\161\141\129Q\203\155S\205\161\189\146\154\185\151|\178\ACK\161\226\US\143\247",PropAuthenticationMethod -// "\145\174\162\172\151!0\243\201\193\168_",PropAuthenticationMethod "",PropSessionExpiryInterval -// 15746,PropMaximumPacketSize 19299,PropRequestProblemInformation 58,PropAuthenticationMethod "N{\229\254%\243r\130"] + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], 0x97); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); +} + +// SubscribeResponse 634 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left +// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported] +// [PropUserProperty "\239\&6\vvf\231\184Wm!\159" "\138\241\203Z\171*\189~\151^\tw&@",PropRetainAvailable +// 131,PropSubscriptionIdentifierAvailable 177,PropReceiveMaximum 32035,PropContentType +// "\185\176z#\225\150h6\171\145^",PropMaximumPacketSize 18026,PropPayloadFormatIndicator 233,PropAuthenticationData +// "\ETB\243\GS\DC3",PropServerReference +// "\161\183\130\246\207,\129\254\244\242\141Lr\161\DC1\192\&2",PropTopicAliasMaximum 23013,PropMaximumPacketSize +// 10661,PropServerKeepAlive 13847,PropSharedSubscriptionAvailable 98,PropWillDelayInterval 31057] TEST(SubACK5QCTest, Decode20) { - uint8_t pkt[] = { - 0x90, 0x8d, 0x2, 0x62, 0x2e, 0x81, 0x2, 0x1a, 0x0, 0x5, 0x21, 0x5, 0x19, 0xd4, 0xd3, 0x2a, 0x7d, 0x11, 0x0, - 0x0, 0x3d, 0x28, 0x17, 0x3, 0x19, 0x18, 0x19, 0x12, 0x28, 0x94, 0x16, 0x0, 0xf, 0x3d, 0xea, 0x37, 0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f7, 0x15, 0x0, 0xc, 0x91, 0xae, - 0xa2, 0xac, 0x97, 0x21, 0x30, 0xf3, 0xc9, 0xc1, 0xa8, 0x5f, 0x15, 0x0, 0x0, 0x11, 0x0, 0x0, 0x3d, 0x82, 0x27, - 0x0, 0x0, 0x4b, 0x63, 0x17, 0x3a, 0x15, 0x0, 0x8, 0x4e, 0x7b, 0xe5, 0xfe, 0x25, 0xf3, 0x72, 0x82, 0xa1, 0x83, - 0x2, 0x87, 0x0, 0x2, 0xa2, 0x97}; + uint8_t pkt[] = {0x90, 0x71, 0x2, 0x7a, 0x67, 0x26, 0x0, 0xb, 0xef, 0x36, 0xb, 0x76, 0x66, 0xe7, 0xb8, 0x57, 0x6d, + 0x21, 0x9f, 0x0, 0xe, 0x8a, 0xf1, 0xcb, 0x5a, 0xab, 0x2a, 0xbd, 0x7e, 0x97, 0x5e, 0x9, 0x77, 0x26, + 0x40, 0x25, 0x83, 0x29, 0xb1, 0x21, 0x7d, 0x23, 0x3, 0x0, 0xb, 0xb9, 0xb0, 0x7a, 0x23, 0xe1, 0x96, + 0x68, 0x36, 0xab, 0x91, 0x5e, 0x27, 0x0, 0x0, 0x46, 0x6a, 0x1, 0xe9, 0x16, 0x0, 0x4, 0x17, 0xf3, + 0x1d, 0x13, 0x1c, 0x0, 0x11, 0xa1, 0xb7, 0x82, 0xf6, 0xcf, 0x2c, 0x81, 0xfe, 0xf4, 0xf2, 0x8d, 0x4c, + 0x72, 0xa1, 0x11, 0xc0, 0x32, 0x22, 0x59, 0xe5, 0x27, 0x0, 0x0, 0x29, 0xa5, 0x13, 0x36, 0x17, 0x2a, + 0x62, 0x18, 0x0, 0x0, 0x79, 0x51, 0x2, 0x91, 0x1, 0x83, 0x97, 0x0, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25134); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], 0xA1); - EXPECT_EQ(granted_qos_levels[1], 0x83); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x87); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 634); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x91); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x83); + EXPECT_EQ(granted_qos_levels[4], 0x97); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[6], 0xA2); - EXPECT_EQ(granted_qos_levels[7], 0x97); } -// SubscribeResponse 25090 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrQuotaExceeded,Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Right QoS1,Left -// SubErrPacketIdentifierInUse] [PropSubscriptionIdentifier 11,PropContentType "\250xC",PropServerKeepAlive -// 21843,PropPayloadFormatIndicator 10,PropRetainAvailable 165,PropTopicAliasMaximum 1014,PropResponseTopic -// "\160\180-\251\252m\233,\254\229\203\253\160\157H\214\SUB$\SO\ESC\146\223+\v",PropReasonString -// "3\171;\133\ENQ\234,\176o\206\NULc\226\247\224\DC4\"\164r\189\212\229C\238M",PropResponseTopic -// "`\225\ESC'\137\184\184Voz\146\&8\201\ESC\237\167\209\177T;o",PropWildcardSubscriptionAvailable -// 255,PropReceiveMaximum 32182] +// SubscribeResponse 742 [Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrPacketIdentifierInUse,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Right QoS1,Left SubErrTopicFilterInvalid] +// [PropReceiveMaximum 9630,PropMessageExpiryInterval 1477,PropAuthenticationMethod +// "\SYNe\DC2\234\203\229\STX\ENQ\240\167\NAK\146\130*\ESC$\SYN\236\148\195\137\179\183|\182\173\134",PropContentType +// "\242\253",PropMessageExpiryInterval 13288,PropWillDelayInterval 13555,PropReasonString +// "\213E\175+TG\142$t\EOT:aO\SO\228Iq\180\221\200'Z\244q]f",PropSubscriptionIdentifier 21,PropSessionExpiryInterval +// 2187,PropReasonString "\CAN-\219\198\DC4\128L=zQ\242\244",PropCorrelationData +// "\SO|\250M\EM\DC3\207e\213;\153\202",PropSubscriptionIdentifierAvailable 108] TEST(SubACK5QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0x70, 0x62, 0x2, 0x66, 0xb, 0xb, 0x3, 0x0, 0x3, 0xfa, 0x78, 0x43, 0x13, 0x55, 0x53, 0x1, - 0xa, 0x25, 0xa5, 0x22, 0x3, 0xf6, 0x8, 0x0, 0x18, 0xa0, 0xb4, 0x2d, 0xfb, 0xfc, 0x6d, 0xe9, 0x2c, - 0xfe, 0xe5, 0xcb, 0xfd, 0xa0, 0x9d, 0x48, 0xd6, 0x1a, 0x24, 0xe, 0x1b, 0x92, 0xdf, 0x2b, 0xb, 0x1f, - 0x0, 0x19, 0x33, 0xab, 0x3b, 0x85, 0x5, 0xea, 0x2c, 0xb0, 0x6f, 0xce, 0x0, 0x63, 0xe2, 0xf7, 0xe0, - 0x14, 0x22, 0xa4, 0x72, 0xbd, 0xd4, 0xe5, 0x43, 0xee, 0x4d, 0x8, 0x0, 0x15, 0x60, 0xe1, 0x1b, 0x27, - 0x89, 0xb8, 0xb8, 0x56, 0x6f, 0x7a, 0x92, 0x38, 0xc9, 0x1b, 0xed, 0xa7, 0xd1, 0xb1, 0x54, 0x3b, 0x6f, - 0x28, 0xff, 0x21, 0x7d, 0xb6, 0x80, 0xa2, 0x97, 0x8f, 0x83, 0x1, 0x91}; + uint8_t pkt[] = {0x90, 0x85, 0x1, 0x2, 0xe6, 0x79, 0x21, 0x25, 0x9e, 0x2, 0x0, 0x0, 0x5, 0xc5, 0x15, 0x0, + 0x1b, 0x16, 0x65, 0x12, 0xea, 0xcb, 0xe5, 0x2, 0x5, 0xf0, 0xa7, 0x15, 0x92, 0x82, 0x2a, 0x1b, + 0x24, 0x16, 0xec, 0x94, 0xc3, 0x89, 0xb3, 0xb7, 0x7c, 0xb6, 0xad, 0x86, 0x3, 0x0, 0x2, 0xf2, + 0xfd, 0x2, 0x0, 0x0, 0x33, 0xe8, 0x18, 0x0, 0x0, 0x34, 0xf3, 0x1f, 0x0, 0x1a, 0xd5, 0x45, + 0xaf, 0x2b, 0x54, 0x47, 0x8e, 0x24, 0x74, 0x4, 0x3a, 0x61, 0x4f, 0xe, 0xe4, 0x49, 0x71, 0xb4, + 0xdd, 0xc8, 0x27, 0x5a, 0xf4, 0x71, 0x5d, 0x66, 0xb, 0x15, 0x11, 0x0, 0x0, 0x8, 0x8b, 0x1f, + 0x0, 0xc, 0x18, 0x2d, 0xdb, 0xc6, 0x14, 0x80, 0x4c, 0x3d, 0x7a, 0x51, 0xf2, 0xf4, 0x9, 0x0, + 0xc, 0xe, 0x7c, 0xfa, 0x4d, 0x19, 0x13, 0xcf, 0x65, 0xd5, 0x3b, 0x99, 0xca, 0x29, 0x6c, 0x0, + 0xa1, 0x91, 0x2, 0x9e, 0x83, 0x97, 0x1, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25090); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0xA2); - EXPECT_EQ(granted_qos_levels[2], 0x97); - EXPECT_EQ(granted_qos_levels[3], 0x8F); - EXPECT_EQ(granted_qos_levels[4], 0x83); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x91); -} - -// SubscribeResponse 270 [Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS0,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrUnspecifiedError] [PropResponseTopic -// "\v=\ENQlq\tV\148o\211h\ETBs\254\213e\224\STXU\f8\134\r\201\248\255\245\218\241",PropAuthenticationData -// "\162\153Q56\EOT+]KH\133Q\219\198\166`",PropAssignedClientIdentifier -// "=\141\218It\145\226W5\180\CAN\230\191\139!\184;\164p\174\236)",PropTopicAlias 11631,PropUserProperty -// "W\234O\236\DC21(|\143\145\201\NAKy\191+\159n\DC1\246\199\150\NAK\156\157\160eX" -// "\RS\"\STX\EM#\169\178",PropMaximumPacketSize 12863,PropMaximumPacketSize 17273,PropMessageExpiryInterval -// 13702,PropCorrelationData -// "\\\165\176o\176.\248\149\208\137\156[\DC2\148\GSR\255\237\187\n\138\254\182\133\242\"\FS\ETXP/",PropSubscriptionIdentifierAvailable -// 79,PropResponseTopic -// "Y\EM\215\231\193\236\\),b\202{\217>\137\186\162\166|\EOT\166!1O\175\SO\233q",PropRetainAvailable -// 207,PropMessageExpiryInterval 15018,PropAssignedClientIdentifier "S\171b\220|\217\146A",PropWillDelayInterval -// 18618,PropSubscriptionIdentifier 13] + EXPECT_EQ(packet_id, 742); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0xA1); + EXPECT_EQ(granted_qos_levels[2], 0x91); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x9E); + EXPECT_EQ(granted_qos_levels[5], 0x83); + EXPECT_EQ(granted_qos_levels[6], 0x97); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], 0x8F); +} + +// SubscribeResponse 14677 [Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrTopicFilterInvalid] +// [PropAuthenticationData "",PropMaximumQoS 183,PropWildcardSubscriptionAvailable 152,PropTopicAlias +// 10631,PropRequestResponseInformation 108,PropServerKeepAlive 7360,PropMessageExpiryInterval +// 29434,PropSubscriptionIdentifierAvailable 168,PropMaximumPacketSize 23853,PropMaximumQoS 108,PropReceiveMaximum +// 11783] TEST(SubACK5QCTest, Decode22) { - uint8_t pkt[] = { - 0x90, 0xee, 0x1, 0x1, 0xe, 0xe0, 0x1, 0x8, 0x0, 0x1d, 0xb, 0x3d, 0x5, 0x6c, 0x71, 0x9, 0x56, 0x94, 0x6f, - 0xd3, 0x68, 0x17, 0x73, 0xfe, 0xd5, 0x65, 0xe0, 0x2, 0x55, 0xc, 0x38, 0x86, 0xd, 0xc9, 0xf8, 0xff, 0xf5, 0xda, - 0xf1, 0x16, 0x0, 0x10, 0xa2, 0x99, 0x51, 0x35, 0x36, 0x4, 0x2b, 0x5d, 0x4b, 0x48, 0x85, 0x51, 0xdb, 0xc6, 0xa6, - 0x60, 0x12, 0x0, 0x16, 0x3d, 0x8d, 0xda, 0x49, 0x74, 0x91, 0xe2, 0x57, 0x35, 0xb4, 0x18, 0xe6, 0xbf, 0x8b, 0x21, - 0xb8, 0x3b, 0xa4, 0x70, 0xae, 0xec, 0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x27, + 0x0, 0x0, 0x5d, 0x2d, 0x24, 0x6c, 0x21, 0x2e, 0x7, 0x8f, 0x0, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 270); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(packet_id, 14677); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0x8F); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0xA2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0xA1); - EXPECT_EQ(granted_qos_levels[6], 0xA1); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], 0xA1); - EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x8F); } -// SubscribeResponse 28717 [Right QoS0,Left SubErrQuotaExceeded,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrPacketIdentifierInUse,Right QoS2,Right QoS1,Right QoS2,Right QoS2] [PropCorrelationData -// "\195\&8A}\215\188\&14\EML\193/6C\202\200\147\SOH\155\238\156\175\164\128\180v",PropTopicAlias -// 3259,PropMessageExpiryInterval 12278,PropAuthenticationMethod "\198\DC1V",PropReceiveMaximum -// 20488,PropSubscriptionIdentifier 23,PropUserProperty "" -// "\ESC{.\227\245\\\207d\US\170!\132J\t\EM%\252\226\DC2\240\f\ENQ\r\193\177\205",PropServerKeepAlive -// 22539,PropSubscriptionIdentifier 21,PropSessionExpiryInterval 15138,PropAuthenticationMethod -// "=\133\&8",PropWildcardSubscriptionAvailable 111,PropMaximumQoS 85,PropUserProperty -// "\214S\221\179B\ACK\196J&^'7\180\199$t2" "",PropRequestProblemInformation 145,PropWillDelayInterval -// 3910,PropMaximumPacketSize 12153,PropReasonString "\165\230\187\169\207d -// \222\141\242_\SI|\v\178\GS^\147\b[\ESC\ETX\142\139)\176\170\176d",PropSubscriptionIdentifier 30,PropServerKeepAlive -// 5908,PropReasonString "z\137\181O\231\207\167",PropUserProperty "\225\160\198\252]\145\184\CAN\139\&6\188\161\&0\f" -// ";\221\250B\163Uqv\n?\211\233d1\224\247\170s=",PropMaximumPacketSize 2390] +// SubscribeResponse 22954 [Right QoS1,Left SubErrTopicFilterInvalid,Left SubErrQuotaExceeded,Right QoS0,Left +// SubErrUnspecifiedError] [PropRequestProblemInformation 173,PropContentType +// "\NAK\139j\215\189\191\162Iq\237\240q}\143\176\131\232\228\176#",PropTopicAliasMaximum +// 15589,PropSubscriptionIdentifierAvailable 54,PropServerKeepAlive 18613,PropSessionExpiryInterval +// 19845,PropSessionExpiryInterval 20838,PropReasonString +// "\168\164\252\190\143\164\141\198\NUL\176\138\235\CAN\187K\193*\US\147\SUB\254+\202y\150}\212{",PropContentType +// "",PropPayloadFormatIndicator 225,PropMaximumPacketSize 12913,PropTopicAliasMaximum 20068,PropCorrelationData +// "@\181I0\140\182\FS"] TEST(SubACK5QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0xeb, 0x1, 0x70, 0x2d, 0xdf, 0x1, 0x9, 0x0, 0x1a, 0xc3, 0x38, 0x41, 0x7d, 0xd7, 0xbc, 0x31, - 0x34, 0x19, 0x4c, 0xc1, 0x2f, 0x36, 0x43, 0xca, 0xc8, 0x93, 0x1, 0x9b, 0xee, 0x9c, 0xaf, 0xa4, 0x80, - 0xb4, 0x76, 0x23, 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73, 0x3d, 0x27, 0x0, 0x0, 0x9, 0x56, 0x0, 0x97, 0xa2, 0x91, 0x2, 0x1, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0x69, 0x59, 0xaa, 0x61, 0x17, 0xad, 0x3, 0x0, 0x14, 0x15, 0x8b, 0x6a, 0xd7, 0xbd, 0xbf, + 0xa2, 0x49, 0x71, 0xed, 0xf0, 0x71, 0x7d, 0x8f, 0xb0, 0x83, 0xe8, 0xe4, 0xb0, 0x23, 0x22, 0x3c, + 0xe5, 0x29, 0x36, 0x13, 0x48, 0xb5, 0x11, 0x0, 0x0, 0x4d, 0x85, 0x11, 0x0, 0x0, 0x51, 0x66, + 0x1f, 0x0, 0x1c, 0xa8, 0xa4, 0xfc, 0xbe, 0x8f, 0xa4, 0x8d, 0xc6, 0x0, 0xb0, 0x8a, 0xeb, 0x18, + 0xbb, 0x4b, 0xc1, 0x2a, 0x1f, 0x93, 0x1a, 0xfe, 0x2b, 0xca, 0x79, 0x96, 0x7d, 0xd4, 0x7b, 0x3, + 0x0, 0x0, 0x1, 0xe1, 0x27, 0x0, 0x0, 0x32, 0x71, 0x22, 0x4e, 0x64, 0x9, 0x0, 0x7, 0x40, + 0xb5, 0x49, 0x30, 0x8c, 0xb6, 0x1c, 0x1, 0x8f, 0x97, 0x0, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 28717); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x97); - EXPECT_EQ(granted_qos_levels[2], 0xA2); - EXPECT_EQ(granted_qos_levels[3], 0x91); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 22954); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x8F); + EXPECT_EQ(granted_qos_levels[2], 0x97); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); } -// SubscribeResponse 8736 [Right QoS1,Right QoS2,Left SubErrImplementationSpecificError,Right QoS2,Right QoS0,Right -// QoS1] [PropSharedSubscriptionAvailable 21,PropUserProperty "\192$&\227\ACKH\231o\186\200'vm\173" -// "\207?\228=\184\v\213\228\245T\163\194\FSG\162\192\202\180X\DLEg\138c\ACK\147\237\196\216\227",PropTopicAliasMaximum -// 12826] +// SubscribeResponse 18733 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrPacketIdentifierInUse,Right QoS2,Right QoS1,Right QoS1] [PropPayloadFormatIndicator +// 98,PropSharedSubscriptionAvailable 87,PropRequestResponseInformation 52,PropCorrelationData +// "\134>?J\255\142\&8PT\238<\NUL\198.\165\206\229\a\216\211\239-X\218jL\249"] TEST(SubACK5QCTest, Decode24) { - uint8_t pkt[] = {0x90, 0x3e, 0x22, 0x20, 0x35, 0x2a, 0x15, 0x26, 0x0, 0xe, 0xc0, 0x24, 0x26, 0xe3, 0x6, 0x48, - 0xe7, 0x6f, 0xba, 0xc8, 0x27, 0x76, 0x6d, 0xad, 0x0, 0x1d, 0xcf, 0x3f, 0xe4, 0x3d, 0xb8, 0xb, - 0xd5, 0xe4, 0xf5, 0x54, 0xa3, 0xc2, 0x1c, 0x47, 0xa2, 0xc0, 0xca, 0xb4, 0x58, 0x10, 0x67, 0x8a, - 0x63, 0x6, 0x93, 0xed, 0xc4, 0xd8, 0xe3, 0x22, 0x32, 0x1a, 0x1, 0x2, 0x83, 0x2, 0x0, 0x1}; + uint8_t pkt[] = {0x90, 0x2d, 0x49, 0x2d, 0x24, 0x1, 0x62, 0x2a, 0x57, 0x19, 0x34, 0x9, 0x0, 0x1b, 0x86, 0x3e, + 0x3f, 0x4a, 0xff, 0x8e, 0x38, 0x50, 0x54, 0xee, 0x3c, 0x0, 0xc6, 0x2e, 0xa5, 0xce, 0xe5, 0x7, + 0xd8, 0xd3, 0xef, 0x2d, 0x58, 0xda, 0x6a, 0x4c, 0xf9, 0x2, 0xa2, 0x91, 0x2, 0x1, 0x1}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[6]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8736); + EXPECT_EQ(packet_id, 18733); EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x83); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(granted_qos_levels[2], 0x91); EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 27132 [Left SubErrWildcardSubscriptionsNotSupported,Left SubErrImplementationSpecificError,Right -// QoS0] [PropSessionExpiryInterval 29768,PropContentType "\DC3",PropRetainAvailable 129,PropWillDelayInterval -// 3417,PropSessionExpiryInterval 11868,PropSessionExpiryInterval 9277,PropRequestResponseInformation -// 147,PropServerKeepAlive 6086,PropAuthenticationData "l\215\STX\207\138\153\197\133T\STX\232\229{ -// \141\147",PropAuthenticationMethod "i\203\193$\146\&0T\129uH\204",PropAuthenticationData -// "&E@\143wF\199\136\NULNS\185\175\225\149\155{\203W\241;\192\134\a",PropAssignedClientIdentifier -// "\185\139\185\139\246\242\153\196PJD\"\231\ESC\165A\250\176t\r\154J\213\239\"\195",PropServerKeepAlive -// 10472,PropReasonString "\186\182\239R\141\163/\EOT\163\196\173",PropRequestResponseInformation 159] +// SubscribeResponse 22455 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left +// SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded,Right QoS0,Left +// SubErrTopicFilterInvalid,Right QoS1,Right QoS1] [PropMaximumQoS 125,PropCorrelationData +// "\US\144ST\228\202\ETX\225\EOT\163-\199\201 \191\180\235sf\n\186\158",PropReasonString +// "\NUL\FS\235\&6k\143v\171\SO\166\189\190x\254\162\243\182\255\157\222*d\219\178\187D",PropUserProperty +// "\231\144\n,\152\201\147\232\FSX\141B\158WY\182\166\242\244\ACK\230\165\233<)\165" +// "h\r9f\203\&8\202\146\DC4x\SI0\188\176\168\157\FSGj\157{FV\239\182Y",PropAuthenticationMethod +// "\231\&7\204\DELr\210\NUL\t7\162\245\&6H\136q\190\201\139v",PropTopicAliasMaximum +// 24385,PropSubscriptionIdentifierAvailable 37,PropAssignedClientIdentifier +// "q\149\212\165\220\240\146\&4b\167\164\244\180\165\254\191l\183\199@R",PropMessageExpiryInterval +// 23,PropSessionExpiryInterval 16436,PropAuthenticationMethod "",PropReceiveMaximum 8596,PropSessionExpiryInterval +// 14740,PropCorrelationData "\196A\NUL5\213\197J<@\180\STX\134W",PropAuthenticationData +// "\EOT\217`\180x\206\206!\187\204\172\236\&2B\189\235\167jap\161\196\&3wxl\131",PropPayloadFormatIndicator +// 140,PropContentType "\144\224\155\219\&5C\178\EM>\ESC./I\GS\242yx}\146\227=v\250DM\157",PropRequestProblemInformation +// 132,PropResponseTopic "b\RS\208r(#\a'\EOT\CAN\236h\187\213\tc\189`\243p\184q_\157\&4",PropReceiveMaximum +// 27370,PropMaximumPacketSize 23288,PropSubscriptionIdentifier 29,PropReasonString +// "[\169\145/\185f$\ESC\222\179'\226\134\ACK\129\218=A\DLE",PropServerReference +// "\187\US\179]\140\&4f\238",PropResponseInformation "\213\ENQ +// N\ACK\198v\STX6\231-\161\&0\132v\128\249",PropTopicAliasMaximum 27985,PropSharedSubscriptionAvailable +// 107,PropSubscriptionIdentifierAvailable 62] TEST(SubACK5QCTest, Decode25) { - uint8_t pkt[] = {0x90, 0x92, 0x1, 0x69, 0xfc, 0x8b, 0x1, 0x11, 0x0, 0x0, 0x74, 0x48, 0x3, 0x0, 0x1, 0x13, 0x25, - 0x81, 0x18, 0x0, 0x0, 0xd, 0x59, 0x11, 0x0, 0x0, 0x2e, 0x5c, 0x11, 0x0, 0x0, 0x24, 0x3d, 0x19, - 0x93, 0x13, 0x17, 0xc6, 0x16, 0x0, 0x10, 0x6c, 0xd7, 0x2, 0xcf, 0x8a, 0x99, 0xc5, 0x85, 0x54, 0x2, - 0xe8, 0xe5, 0x7b, 0x20, 0x8d, 0x93, 0x15, 0x0, 0xb, 0x69, 0xcb, 0xc1, 0x24, 0x92, 0x30, 0x54, 0x81, - 0x75, 0x48, 0xcc, 0x16, 0x0, 0x18, 0x26, 0x45, 0x40, 0x8f, 0x77, 0x46, 0xc7, 0x88, 0x0, 0x4e, 0x53, - 0xb9, 0xaf, 0xe1, 0x95, 0x9b, 0x7b, 0xcb, 0x57, 0xf1, 0x3b, 0xc0, 0x86, 0x7, 0x12, 0x0, 0x1a, 0xb9, - 0x8b, 0xb9, 0x8b, 0xf6, 0xf2, 0x99, 0xc4, 0x50, 0x4a, 0x44, 0x22, 0xe7, 0x1b, 0xa5, 0x41, 0xfa, 0xb0, - 0x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0xee, + 0x1a, 0x0, 0x11, 0xd5, 0x5, 0x20, 0x4e, 0x6, 0xc6, 0x76, 0x2, 0x36, 0xe7, 0x2d, 0xa1, 0x30, 0x84, 0x76, 0x80, + 0xf9, 0x22, 0x6d, 0x51, 0x2a, 0x6b, 0x29, 0x3e, 0x9e, 0x97, 0x8f, 0xa1, 0x97, 0x0, 0x8f, 0x1, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27132); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0xA2); - EXPECT_EQ(granted_qos_levels[1], 0x83); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); -} - -// SubscribeResponse 20260 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS0,Right QoS2,Right QoS1,Right QoS1] -// [PropReceiveMaximum 25039,PropReasonString "6\174\ETX\RSBM\175\b\181\DC2+\246s",PropReceiveMaximum -// 32590,PropServerReference "\138z\187#\202\153\152",PropMaximumQoS 67,PropUserProperty -// "\160e\GS\161\144l\147g\r\174S\183\170\156\149tCm\203\248,\FS\232d\146" -// "\176\203EE\224\239\158j\166\SOHz\215MF\157\ETB\138DI\137\ACK\150\215\&0\141",PropAuthenticationData -// "$\192eZb\135Z$\161",PropSubscriptionIdentifier 7,PropPayloadFormatIndicator 117,PropReceiveMaximum -// 9335,PropSubscriptionIdentifierAvailable 163,PropSharedSubscriptionAvailable 107,PropSharedSubscriptionAvailable -// 141,PropTopicAlias 4296,PropMessageExpiryInterval 13428,PropMaximumPacketSize 15215,PropRetainAvailable -// 197,PropMessageExpiryInterval 12485,PropReceiveMaximum 11017,PropContentType -// "j\180\182\200\188Ul",PropCorrelationData "\\UP\243\172\NUL\f/z\186X\134\236\227R\192",PropUserProperty -// "\213\v\152\ESCBm\133\218C\r\130\194!{" -// "\129$F\179s0y\201\&2\180\143K\197|c\151\160F",PropWildcardSubscriptionAvailable 114,PropSharedSubscriptionAvailable -// 218,PropWillDelayInterval 4879,PropRequestResponseInformation 147,PropTopicAliasMaximum -// 13826,PropSubscriptionIdentifierAvailable 180,PropMessageExpiryInterval 18818,PropMaximumPacketSize 4173] + EXPECT_EQ(packet_id, 22455); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], 0x97); + EXPECT_EQ(granted_qos_levels[2], 0x8F); + EXPECT_EQ(granted_qos_levels[3], 0xA1); + EXPECT_EQ(granted_qos_levels[4], 0x97); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x8F); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); +} + +// SubscribeResponse 556 [Right QoS1,Left SubErrImplementationSpecificError,Right QoS1] [PropCorrelationData +// "\r\176\163\148\188\204\158}\243\207\214Z\b\a\208\157",PropRequestProblemInformation +// 75,PropSubscriptionIdentifierAvailable 129,PropAssignedClientIdentifier +// "\EOTx=`\208\142\153\149\224\224\161)@\166\SYN\EOT\224\162*\129*.;~\254\&1\193\252p8",PropMaximumQoS +// 38,PropAuthenticationMethod "Hb)\a{V[\252j\206^\222\&3\221V\192G\255o",PropRequestProblemInformation +// 31,PropWillDelayInterval 5553,PropMessageExpiryInterval 2889,PropWillDelayInterval 21169,PropAssignedClientIdentifier +// "\176m\159`Q\ETBF\196\DC4+\vv",PropResponseInformation +// "Tp7\179\236\EM\179kwZ\212g\143$\128\208\150*(\208q\255*\236\128\EM;",PropReasonString +// "\135\189\172\247\130\153\174\240\246\207\161,\201",PropMaximumQoS 212,PropRequestResponseInformation +// 227,PropCorrelationData "^\\k#\DC3\159\240\ENQ\208{\167[ml\253\173\b\163\134\157\185",PropWillDelayInterval +// 20829,PropServerKeepAlive 21836,PropReceiveMaximum 9146,PropWillDelayInterval 6516,PropResponseInformation +// "\227\203\253\152\aj"] TEST(SubACK5QCTest, Decode26) { - uint8_t pkt[] = { - 0x90, 0xef, 0x1, 0x4f, 0x24, 0xe5, 0x1, 0x21, 0x61, 0xcf, 0x1f, 0x0, 0xd, 0x36, 0xae, 0x3, 0x1e, 0x42, 0x4d, - 0xaf, 0x8, 0xb5, 0x12, 0x2b, 0xf6, 0x73, 0x21, 0x7f, 0x4e, 0x1c, 0x0, 0x7, 0x8a, 0x7a, 0xbb, 0x23, 0xca, 0x99, - 0x98, 0x24, 0x43, 0x26, 0x0, 0x19, 0xa0, 0x65, 0x1d, 0xa1, 0x90, 0x6c, 0x93, 0x67, 0xd, 0xae, 0x53, 0xb7, 0xaa, - 0x9c, 0x95, 0x74, 0x43, 0x6d, 0xcb, 0xf8, 0x2c, 0x1c, 0xe8, 0x64, 0x92, 0x0, 0x19, 0xb0, 0xcb, 0x45, 0x45, 0xe0, - 0xef, 0x9e, 0x6a, 0xa6, 0x1, 0x7a, 0xd7, 0x4d, 0x46, 0x9d, 0x17, 0x8a, 0x44, 0x49, 0x89, 0x6, 0x96, 0xd7, 0x30, - 0x8d, 0x16, 0x0, 0x9, 0x24, 0xc0, 0x65, 0x5a, 0x62, 0x87, 0x5a, 0x24, 0xa1, 0xb, 0x7, 0x1, 0x75, 0x21, 0x24, - 0x77, 0x29, 0xa3, 0x2a, 0x6b, 0x2a, 0x8d, 0x23, 0x10, 0xc8, 0x2, 0x0, 0x0, 0x34, 0x74, 0x27, 0x0, 0x0, 0x3b, - 0x6f, 0x25, 0xc5, 0x2, 0x0, 0x0, 0x30, 0xc5, 0x21, 0x2b, 0x9, 0x3, 0x0, 0x7, 0x6a, 0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, 0xb1, 0x2, 0x0, 0x0, 0xb, 0x49, 0x18, 0x0, 0x0, + 0x52, 0xb1, 0x12, 0x0, 0xc, 0xb0, 0x6d, 0x9f, 0x60, 0x51, 0x17, 0x46, 0xc4, 0x14, 0x2b, 0xb, 0x76, + 0x1a, 0x0, 0x1b, 0x54, 0x70, 0x37, 0xb3, 0xec, 0x19, 0xb3, 0x6b, 0x77, 0x5a, 0xd4, 0x67, 0x8f, 0x24, + 0x80, 0xd0, 0x96, 0x2a, 0x28, 0xd0, 0x71, 0xff, 0x2a, 0xec, 0x80, 0x19, 0x3b, 0x1f, 0x0, 0xd, 0x87, + 0xbd, 0xac, 0xf7, 0x82, 0x99, 0xae, 0xf0, 0xf6, 0xcf, 0xa1, 0x2c, 0xc9, 0x24, 0xd4, 0x19, 0xe3, 0x9, + 0x0, 0x15, 0x5e, 0x5c, 0x6b, 0x23, 0x13, 0x9f, 0xf0, 0x5, 0xd0, 0x7b, 0xa7, 0x5b, 0x6d, 0x6c, 0xfd, + 0xad, 0x8, 0xa3, 0x86, 0x9d, 0xb9, 0x18, 0x0, 0x0, 0x51, 0x5d, 0x13, 0x55, 0x4c, 0x21, 0x23, 0xba, + 0x18, 0x0, 0x0, 0x19, 0x74, 0x1a, 0x0, 0x6, 0xe3, 0xcb, 0xfd, 0x98, 0x7, 0x6a, 0x1, 0x83, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 20260); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x91); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 556); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); } -// SubscribeResponse 471 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS0,Left -// SubErrNotAuthorized,Right QoS2,Left SubErrImplementationSpecificError,Right QoS1,Right QoS1] -// [PropMessageExpiryInterval 13269,PropMaximumPacketSize 22041,PropRetainAvailable -// 121,PropSubscriptionIdentifierAvailable 209] +// SubscribeResponse 15417 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left SubErrNotAuthorized] +// [PropMessageExpiryInterval 3342,PropAuthenticationMethod +// "\197\130\195\190\223w\173\235\225\ESC\GS\DC4\210\137m\159\ETBo\250",PropAuthenticationData +// "\179\131\211\146n]\SO\rus3\229\v'\158T\134\128\254\186\&1\DELe\217*\171\156-D",PropPayloadFormatIndicator +// 54,PropReasonString +// "\f\141\249u|R\191`S\153\251\&6+C\160\DC1\240>\241'\238\236\f\EM,\237",PropRequestProblemInformation +// 62,PropSharedSubscriptionAvailable 29,PropWildcardSubscriptionAvailable 131,PropRequestResponseInformation +// 224,PropTopicAlias 32256,PropRequestProblemInformation 194,PropSharedSubscriptionAvailable 79,PropRetainAvailable +// 34,PropRetainAvailable 19,PropSharedSubscriptionAvailable 92,PropContentType +// "\150\160\236\SYNp}\f",PropSubscriptionIdentifierAvailable 213,PropServerKeepAlive 8068] TEST(SubACK5QCTest, Decode27) { - uint8_t pkt[] = {0x90, 0x19, 0x1, 0xd7, 0xe, 0x2, 0x0, 0x0, 0x33, 0xd5, 0x27, 0x0, 0x0, 0x56, - 0x19, 0x25, 0x79, 0x29, 0xd1, 0x9e, 0x0, 0x0, 0x87, 0x2, 0x83, 0x1, 0x1}; + uint8_t pkt[] = {0x90, 0x85, 0x1, 0x3c, 0x39, 0x7e, 0x2, 0x0, 0x0, 0xd, 0xe, 0x15, 0x0, 0x13, 0xc5, 0x82, + 0xc3, 0xbe, 0xdf, 0x77, 0xad, 0xeb, 0xe1, 0x1b, 0x1d, 0x14, 0xd2, 0x89, 0x6d, 0x9f, 0x17, 0x6f, + 0xfa, 0x16, 0x0, 0x1d, 0xb3, 0x83, 0xd3, 0x92, 0x6e, 0x5d, 0xe, 0xd, 0x75, 0x73, 0x33, 0xe5, + 0xb, 0x27, 0x9e, 0x54, 0x86, 0x80, 0xfe, 0xba, 0x31, 0x7f, 0x65, 0xd9, 0x2a, 0xab, 0x9c, 0x2d, + 0x44, 0x1, 0x36, 0x1f, 0x0, 0x1a, 0xc, 0x8d, 0xf9, 0x75, 0x7c, 0x52, 0xbf, 0x60, 0x53, 0x99, + 0xfb, 0x36, 0x2b, 0x43, 0xa0, 0x11, 0xf0, 0x3e, 0xf1, 0x27, 0xee, 0xec, 0xc, 0x19, 0x2c, 0xed, + 0x17, 0x3e, 0x2a, 0x1d, 0x28, 0x83, 0x19, 0xe0, 0x23, 0x7e, 0x0, 0x17, 0xc2, 0x2a, 0x4f, 0x25, + 0x22, 0x25, 0x13, 0x2a, 0x5c, 0x3, 0x0, 0x7, 0x96, 0xa0, 0xec, 0x16, 0x70, 0x7d, 0xc, 0x29, + 0xd5, 0x13, 0x1f, 0x84, 0x2, 0xa2, 0x0, 0x87}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 471); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 15417); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0xA2); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[3], 0x87); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x83); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); } -// SubscribeResponse 21021 [Right QoS1,Right QoS2,Right QoS2,Right QoS2] [PropResponseInformation -// "\143\239n\n\SI\203\220\154\130\175\181}\226\144\150\159\&3\142",PropMessageExpiryInterval -// 25828,PropSubscriptionIdentifierAvailable 184,PropCorrelationData -// "~\NUL\236\190|6\221",PropWildcardSubscriptionAvailable 212,PropMessageExpiryInterval 21937,PropSessionExpiryInterval -// 22211,PropSubscriptionIdentifierAvailable 173,PropMessageExpiryInterval 16452,PropSharedSubscriptionAvailable 169] +// SubscribeResponse 26950 [Left SubErrImplementationSpecificError,Right QoS2,Right QoS2,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [PropSubscriptionIdentifierAvailable +// 90,PropAssignedClientIdentifier "\245\DC3x\171w\SOx\129\DC3\a\249\239\252\188Y<\149>",PropReasonString +// "\194\253\ENQE\169\153\t8A?1S\200\249",PropServerReference "\211'\b\129:\147a\191",PropAuthenticationData +// "\162",PropMaximumPacketSize 9056,PropSubscriptionIdentifierAvailable 35,PropSessionExpiryInterval +// 8594,PropAuthenticationMethod "\238\150\215\189\233\132\SO\192\167^\SYN",PropCorrelationData "\155Si;8'7 +// nh\232\209+Q6\FS",PropSharedSubscriptionAvailable 107,PropSessionExpiryInterval 16867,PropResponseInformation +// "\185\ESCf"] TEST(SubACK5QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0x42, 0x52, 0x1d, 0x3b, 0x1a, 0x0, 0x12, 0x8f, 0xef, 0x6e, 0xa, 0xf, 0xcb, 0xdc, 0x9a, 0x82, - 0xaf, 0xb5, 0x7d, 0xe2, 0x90, 0x96, 0x9f, 0x33, 0x8e, 0x2, 0x0, 0x0, 0x64, 0xe4, 0x29, 0xb8, 0x9, - 0x0, 0x7, 0x7e, 0x0, 0xec, 0xbe, 0x7c, 0x36, 0xdd, 0x28, 0xd4, 0x2, 0x0, 0x0, 0x55, 0xb1, 0x11, - 0x0, 0x0, 0x56, 0xc3, 0x29, 0xad, 0x2, 0x0, 0x0, 0x40, 0x44, 0x2a, 0xa9, 0x1, 0x2, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0x79, 0x69, 0x46, 0x71, 0x29, 0x5a, 0x12, 0x0, 0x12, 0xf5, 0x13, 0x78, 0xab, 0x77, 0xe, + 0x78, 0x81, 0x13, 0x7, 0xf9, 0xef, 0xfc, 0xbc, 0x59, 0x3c, 0x95, 0x3e, 0x1f, 0x0, 0xe, 0xc2, + 0xfd, 0x5, 0x45, 0xa9, 0x99, 0x9, 0x38, 0x41, 0x3f, 0x31, 0x53, 0xc8, 0xf9, 0x1c, 0x0, 0x8, + 0xd3, 0x27, 0x8, 0x81, 0x3a, 0x93, 0x61, 0xbf, 0x16, 0x0, 0x1, 0xa2, 0x27, 0x0, 0x0, 0x23, + 0x60, 0x29, 0x23, 0x11, 0x0, 0x0, 0x21, 0x92, 0x15, 0x0, 0xb, 0xee, 0x96, 0xd7, 0xbd, 0xe9, + 0x84, 0xe, 0xc0, 0xa7, 0x5e, 0x16, 0x9, 0x0, 0x10, 0x9b, 0x53, 0x69, 0x3b, 0x38, 0x27, 0x37, + 0x20, 0x6e, 0x68, 0xe8, 0xd1, 0x2b, 0x51, 0x36, 0x1c, 0x2a, 0x6b, 0x11, 0x0, 0x0, 0x41, 0xe3, + 0x1a, 0x0, 0x3, 0xb9, 0x1b, 0x66, 0x83, 0x2, 0x2, 0xa1, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21021); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 26950); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x83); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0xA1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); } -// SubscribeResponse 3050 [Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrUnspecifiedError,Left -// SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left SubErrSharedSubscriptionsNotSupported,Right QoS0] -// [PropAuthenticationMethod "\248nv\143\249\166Q\244",PropAuthenticationMethod -// "\218\144)X\160\204Y;\135\SOH\244\200Y\229\245\237;O\210]!\163\139\145\164\222`=j",PropServerReference -// "\165\235\NAK\235\158\192\176\219\145\145\162\SIr\201\131\DEL\131\135\233\148\v\208VG\185\154b\178",PropMessageExpiryInterval -// 16134,PropMaximumQoS 206,PropTopicAliasMaximum 20322,PropReasonString " -// g\129\182B\173\177\254\r\ACK\186\&6\245\210\165\FS,\248]|",PropAuthenticationData -// ".\158\179\181\DC4.A\210O\128g\219i\196\v)\152",PropMaximumQoS 50,PropResponseInformation -// "p\210\143?0\144\DEL\SOH\131\178!\252\&5Z\ACK7\DC4=,\141B\v\181\243$\177K>\DC1\193",PropRequestProblemInformation -// 217,PropAssignedClientIdentifier "\DC3\178\140\230y\196\235:-\173\157l\173\188",PropMaximumPacketSize -// 8704,PropWildcardSubscriptionAvailable 198,PropResponseTopic -// "\EOTOk\147\211\SOH\203\162#\159)\178\209q\"\137",PropPayloadFormatIndicator 29,PropServerReference -// "\169\247",PropServerKeepAlive 7468,PropTopicAlias 13534,PropSharedSubscriptionAvailable -// 117,PropSubscriptionIdentifier 30,PropCorrelationData "nNt\203\206Q\178\r\185\EOT",PropMaximumQoS -// 95,PropWildcardSubscriptionAvailable 131,PropRetainAvailable 113,PropUserProperty "\145<\n\SUB\137\242\&5Z\204" -// "\SUB2\217j\136\175\145\128\230\202\ACK\134\255\144\v\224\159\193~\192\204i\150=;!s\255",PropTopicAliasMaximum 4299] +// SubscribeResponse 24196 [Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Left +// SubErrImplementationSpecificError,Right QoS0,Right QoS0,Left SubErrTopicFilterInvalid,Left +// SubErrPacketIdentifierInUse,Right QoS2] [PropSessionExpiryInterval 3870,PropSubscriptionIdentifierAvailable +// 240,PropAuthenticationMethod +// "\177\&3\SOH\212\US\176\160\237z\230\255\173\236[}u\135\240\137\187\159\140\191]",PropSubscriptionIdentifier +// 29,PropMaximumQoS 47,PropReasonString "\233*\a\152l~OR\188\184o\139",PropServerKeepAlive 12968,PropTopicAliasMaximum +// 5292,PropResponseInformation "1A\219XL\n\212\n\220\137\213",PropResponseTopic +// "\DC3\164q\212X\ACK\201D\164\128\&9\182\&8D6&",PropMaximumPacketSize 2747] TEST(SubACK5QCTest, Decode29) { - uint8_t pkt[] = { - 0x90, 0xab, 0x2, 0xb, 0xea, 0xa0, 0x2, 0x15, 0x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xdc, 0x89, 0xd5, 0x8, 0x0, + 0x10, 0x13, 0xa4, 0x71, 0xd4, 0x58, 0x6, 0xc9, 0x44, 0xa4, 0x80, 0x39, 0xb6, 0x38, 0x44, 0x36, + 0x26, 0x27, 0x0, 0x0, 0xa, 0xbb, 0x9e, 0x1, 0x8f, 0x83, 0x0, 0x0, 0x8f, 0x91, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3050); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x91); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x91); - EXPECT_EQ(granted_qos_levels[5], 0x9E); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 24196); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x8F); + EXPECT_EQ(granted_qos_levels[3], 0x83); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x8F); + EXPECT_EQ(granted_qos_levels[7], 0x91); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); } -// SubscribeResponse 9426 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Left -// SubErrWildcardSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrTopicFilterInvalid,Right QoS0,Right QoS2] [PropSubscriptionIdentifierAvailable 177,PropContentType -// "\253'\175\175\255\138\n\233w\GS\179\DLE\RS,\fOUS\143\226\178K\184%/(",PropSharedSubscriptionAvailable -// 16,PropRequestProblemInformation 63,PropPayloadFormatIndicator 39,PropWildcardSubscriptionAvailable -// 52,PropAuthenticationMethod "\136\176",PropResponseInformation -// "\155A\235\220\214\129\250\203Q\199\245\228\187\220\132\222]-\171XQ",PropSubscriptionIdentifier -// 20,PropPayloadFormatIndicator 214,PropMessageExpiryInterval 31640,PropSubscriptionIdentifierAvailable -// 186,PropRequestResponseInformation 66,PropAuthenticationMethod "}\fV\211\231x\132",PropContentType -// ",\161\201I\197\180\SI$\252k\254P2\185U\180\212\204\196\138\DC2\152\183\206\194\145\193\255P",PropWillDelayInterval -// 6080,PropServerReference "x\132\SOH\215Z\156\160,#\DC3z\174q\198z\239-\220\155"] +// SubscribeResponse 19551 [Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrUnspecifiedError,Right QoS1,Right +// QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrQuotaExceeded,Right QoS0] [PropResponseTopic "\251!"] [] +// UnsubscribeRequest 21005 +// ["\162U\229Q\203:\151\212\213\175Q\163\a\240\194\211\147\&1\196\251\US\142\159>\129\227\142\140","\191\&2\206V\211\208jL\223\162M\237i\241\128\DC1R\160UJ\195\175\194R\213","\213?\174\187\RS\DEL\245 +// \199\246\204","6\147z\129\248e\186\239\143\190\200\231\233\244\170(\225[\f\254\202\159-VJ\255Pp!","H\191\171\135\157){d~\181\190","\FSe\146\150\222","\DLE\228\196{\157hG\135~RV^\EOT5","\243\212\198\a\157\193\174\231\196\129N\182\137\243w"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xcc, 0x0, 0x1d, 0x36, 0x93, 0x7a, + 0x81, 0xf8, 0x65, 0xba, 0xef, 0x8f, 0xbe, 0xc8, 0xe7, 0xe9, 0xf4, 0xaa, 0x28, 0xe1, 0x5b, 0xc, + 0xfe, 0xca, 0x9f, 0x2d, 0x56, 0x4a, 0xff, 0x50, 0x70, 0x21, 0x0, 0xb, 0x48, 0xbf, 0xab, 0x87, + 0x9d, 0x29, 0x7b, 0x64, 0x7e, 0xb5, 0xbe, 0x0, 0x5, 0x1c, 0x65, 0x92, 0x96, 0xde, 0x0, 0xe, + 0x10, 0xe4, 0xc4, 0x7b, 0x9d, 0x68, 0x47, 0x87, 0x7e, 0x52, 0x56, 0x5e, 0x4, 0x35, 0x0, 0xf, + 0xf3, 0xd4, 0xc6, 0x7, 0x9d, 0xc1, 0xae, 0xe7, 0xc4, 0x81, 0x4e, 0xb6, 0x89, 0xf3, 0x77}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xc9, 0xe8, 0xd6, 0x2d, 0xf9, 0xb2, 0xf3, 0xcd, - 0x24, 0xdc, 0x96, 0xe8, 0x3c, 0x91, 0xf7}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xa2, 0x55, 0xe5, 0x51, 0xcb, 0x3a, 0x97, 0xd4, 0xd5, 0xaf, + 0x51, 0xa3, 0x7, 0xf0, 0xc2, 0xd3, 0x93, 0x31, 0xc4, 0xfb, + 0x1f, 0x8e, 0x9f, 0x3e, 0x81, 0xe3, 0x8e, 0x8c}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa7, 0x1, 0xb9, 0xad, 0x7b, 0x80, 0x37, 0x33, 0x62, 0xa1, 0x72, 0x4f, 0xe6, - 0xbb, 0x94, 0xd6, 0xa3, 0xa9, 0x82, 0xc3, 0xb1, 0xe9, 0x9f, 0x6c, 0xf9}; + uint8_t topic_filter_s1_bytes[] = {0xbf, 0x32, 0xce, 0x56, 0xd3, 0xd0, 0x6a, 0x4c, 0xdf, 0xa2, 0x4d, 0xed, 0x69, + 0xf1, 0x80, 0x11, 0x52, 0xa0, 0x55, 0x4a, 0xc3, 0xaf, 0xc2, 0x52, 0xd5}; lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4b, 0x5, 0xc, 0x6, 0x98, 0xdf}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd5, 0x3f, 0xae, 0xbb, 0x1e, 0x7f, 0xf5, 0x20, 0xc7, 0xf6, 0xcc}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa9, 0x11, 0x8c, 0xd2, 0x19, 0x4f, 0xac, 0x25, 0x3b, 0xf, 0x10, - 0x80, 0xaa, 0x55, 0xf, 0xb4, 0x37, 0x67, 0xdd, 0xe5, 0x20}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x36, 0x93, 0x7a, 0x81, 0xf8, 0x65, 0xba, 0xef, 0x8f, 0xbe, + 0xc8, 0xe7, 0xe9, 0xf4, 0xaa, 0x28, 0xe1, 0x5b, 0xc, 0xfe, + 0xca, 0x9f, 0x2d, 0x56, 0x4a, 0xff, 0x50, 0x70, 0x21}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xff, 0x2f, 0x6e, 0x22, 0x4, 0x5c, 0x50, 0xc7, 0xc, - 0x7f, 0xfe, 0x19, 0x67, 0x68, 0xb3, 0xce, 0xf3, 0x3e}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x48, 0xbf, 0xab, 0x87, 0x9d, 0x29, 0x7b, 0x64, 0x7e, 0xb5, 0xbe}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1c, 0x65, 0x92, 0x96, 0xde}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x10, 0xe4, 0xc4, 0x7b, 0x9d, 0x68, 0x47, 0x87, 0x7e, 0x52, 0x56, 0x5e, 0x4, 0x35}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf3, 0xd4, 0xc6, 0x7, 0x9d, 0xc1, 0xae, 0xe7, + 0xc4, 0x81, 0x4e, 0xb6, 0x89, 0xf3, 0x77}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17193, 5, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21005, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 26830 -// ["\218+\CAN,\224\168w\RSA\238#\r\212'\236M7g\185\213H9V\247)","-\222\193hv\157\140\193\135\212\152\212","\DEL\rs\210\"\178\STX\ENQ\226\231\ETX\247)\157c\218\174","\243eC -// v|F\170\188e\246w\177:\197J\219\212\184i\139\EOT\207\187\177\228\192\150?\134","\159\157\FS\135\152\130u\DC4\194","\151O\204\&1\251\ACK","46\222nn\188#\191\208{\DC4\208\217\195"] +// UnsubscribeRequest 17284 +// ["\219\&6\208\245\251\252\ESC\222\a\175]6\SUB\EM\187\163\135\251R\141\188\250_~#\250\154\253'6","\209\"I\SOW",":/\181!v\193\177A\DC4\ACK\181\218\218*\183\248\233","^}\ETB\204n1\129\156\159\193Y\160\v","\222}^v\153\247\244\185\129\n\220Cy\SUB\ETX","\247\184r"] // [] TEST(Unsubscribe311QCTest, Encode2) { - uint8_t pkt[] = {0xa2, 0x81, 0x1, 0x68, 0xce, 0x0, 0x19, 0xda, 0x2b, 0x18, 0x2c, 0xe0, 0xa8, 0x77, 0x1e, 0x41, 0xee, - 0x23, 0xd, 0xd4, 0x27, 0xec, 0x4d, 0x37, 0x67, 0xb9, 0xd5, 0x48, 0x39, 0x56, 0xf7, 0x29, 0x0, 0xc, - 0x2d, 0xde, 0xc1, 0x68, 0x76, 0x9d, 0x8c, 0xc1, 0x87, 0xd4, 0x98, 0xd4, 0x0, 0x11, 0x7f, 0xd, 0x73, - 0xd2, 0x22, 0xb2, 0x2, 0x5, 0xe2, 0xe7, 0x3, 0xf7, 0x29, 0x9d, 0x63, 0xda, 0xae, 0x0, 0x1e, 0xf3, - 0x65, 0x43, 0x20, 0x76, 0x7c, 0x46, 0xaa, 0xbc, 0x65, 0xf6, 0x77, 0xb1, 0x3a, 0xc5, 0x4a, 0xdb, 0xd4, - 0xb8, 0x69, 0x8b, 0x4, 0xcf, 0xbb, 0xb1, 0xe4, 0xc0, 0x96, 0x3f, 0x86, 0x0, 0x9, 0x9f, 0x9d, 0x1c, - 0x87, 0x98, 0x82, 0x75, 0x14, 0xc2, 0x0, 0x6, 0x97, 0x4f, 0xcc, 0x31, 0xfb, 0x6, 0x0, 0xe, 0x34, - 0x36, 0xde, 0x6e, 0x6e, 0xbc, 0x23, 0xbf, 0xd0, 0x7b, 0x14, 0xd0, 0xd9, 0xc3}; + uint8_t pkt[] = {0xa2, 0x61, 0x43, 0x84, 0x0, 0x1e, 0xdb, 0x36, 0xd0, 0xf5, 0xfb, 0xfc, 0x1b, 0xde, 0x7, 0xaf, 0x5d, + 0x36, 0x1a, 0x19, 0xbb, 0xa3, 0x87, 0xfb, 0x52, 0x8d, 0xbc, 0xfa, 0x5f, 0x7e, 0x23, 0xfa, 0x9a, 0xfd, + 0x27, 0x36, 0x0, 0x5, 0xd1, 0x22, 0x49, 0xe, 0x57, 0x0, 0x11, 0x3a, 0x2f, 0xb5, 0x21, 0x76, 0xc1, + 0xb1, 0x41, 0x14, 0x6, 0xb5, 0xda, 0xda, 0x2a, 0xb7, 0xf8, 0xe9, 0x0, 0xd, 0x5e, 0x7d, 0x17, 0xcc, + 0x6e, 0x31, 0x81, 0x9c, 0x9f, 0xc1, 0x59, 0xa0, 0xb, 0x0, 0xf, 0xde, 0x7d, 0x5e, 0x76, 0x99, 0xf7, + 0xf4, 0xb9, 0x81, 0xa, 0xdc, 0x43, 0x79, 0x1a, 0x3, 0x0, 0x3, 0xf7, 0xb8, 0x72}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xda, 0x2b, 0x18, 0x2c, 0xe0, 0xa8, 0x77, 0x1e, 0x41, 0xee, 0x23, 0xd, 0xd4, - 0x27, 0xec, 0x4d, 0x37, 0x67, 0xb9, 0xd5, 0x48, 0x39, 0x56, 0xf7, 0x29}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xdb, 0x36, 0xd0, 0xf5, 0xfb, 0xfc, 0x1b, 0xde, 0x7, 0xaf, + 0x5d, 0x36, 0x1a, 0x19, 0xbb, 0xa3, 0x87, 0xfb, 0x52, 0x8d, + 0xbc, 0xfa, 0x5f, 0x7e, 0x23, 0xfa, 0x9a, 0xfd, 0x27, 0x36}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2d, 0xde, 0xc1, 0x68, 0x76, 0x9d, 0x8c, 0xc1, 0x87, 0xd4, 0x98, 0xd4}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd1, 0x22, 0x49, 0xe, 0x57}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7f, 0xd, 0x73, 0xd2, 0x22, 0xb2, 0x2, 0x5, 0xe2, - 0xe7, 0x3, 0xf7, 0x29, 0x9d, 0x63, 0xda, 0xae}; + uint8_t topic_filter_s2_bytes[] = {0x3a, 0x2f, 0xb5, 0x21, 0x76, 0xc1, 0xb1, 0x41, 0x14, + 0x6, 0xb5, 0xda, 0xda, 0x2a, 0xb7, 0xf8, 0xe9}; lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf3, 0x65, 0x43, 0x20, 0x76, 0x7c, 0x46, 0xaa, 0xbc, 0x65, - 0xf6, 0x77, 0xb1, 0x3a, 0xc5, 0x4a, 0xdb, 0xd4, 0xb8, 0x69, - 0x8b, 0x4, 0xcf, 0xbb, 0xb1, 0xe4, 0xc0, 0x96, 0x3f, 0x86}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x5e, 0x7d, 0x17, 0xcc, 0x6e, 0x31, 0x81, 0x9c, 0x9f, 0xc1, 0x59, 0xa0, 0xb}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9f, 0x9d, 0x1c, 0x87, 0x98, 0x82, 0x75, 0x14, 0xc2}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xde, 0x7d, 0x5e, 0x76, 0x99, 0xf7, 0xf4, 0xb9, + 0x81, 0xa, 0xdc, 0x43, 0x79, 0x1a, 0x3}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x97, 0x4f, 0xcc, 0x31, 0xfb, 0x6}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf7, 0xb8, 0x72}; + lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x34, 0x36, 0xde, 0x6e, 0x6e, 0xbc, 0x23, - 0xbf, 0xd0, 0x7b, 0x14, 0xd0, 0xd9, 0xc3}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26830, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17284, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 23824 ["\226W\ETX\192;\167?\SO \145"] [] +// UnsubscribeRequest 26289 +// ["\140B\199\151L3\231\157\171K\204\197\224\217\DC2\144l\223\SYNH\185kEa\195","\170\250s\163&\SUB\DC3?I\176","*\244","\169\175\132P&\bp\128\&0B\ETB*\162u\148\&3p\fE\STX\ENQ\NAK)M{\199","\212j\250\SYN\247\NUL\139#9\128\SYN\141\DC1\198\182\221\128\146\130\239`3\STX\r","\179sq\146\SI\SYN\SUB\229\SUBT\SIeFJd\172\am\222\178|\234T\138\137\144"] +// [] TEST(Unsubscribe311QCTest, Encode3) { - uint8_t pkt[] = {0xa2, 0xe, 0x5d, 0x10, 0x0, 0xa, 0xe2, 0x57, 0x3, 0xc0, 0x3b, 0xa7, 0x3f, 0xe, 0x20, 0x91}; + uint8_t pkt[] = {0xa2, 0x7f, 0x66, 0xb1, 0x0, 0x19, 0x8c, 0x42, 0xc7, 0x97, 0x4c, 0x33, 0xe7, 0x9d, 0xab, 0x4b, 0xcc, + 0xc5, 0xe0, 0xd9, 0x12, 0x90, 0x6c, 0xdf, 0x16, 0x48, 0xb9, 0x6b, 0x45, 0x61, 0xc3, 0x0, 0xa, 0xaa, + 0xfa, 0x73, 0xa3, 0x26, 0x1a, 0x13, 0x3f, 0x49, 0xb0, 0x0, 0x2, 0x2a, 0xf4, 0x0, 0x1a, 0xa9, 0xaf, + 0x84, 0x50, 0x26, 0x8, 0x70, 0x80, 0x30, 0x42, 0x17, 0x2a, 0xa2, 0x75, 0x94, 0x33, 0x70, 0xc, 0x45, + 0x2, 0x5, 0x15, 0x29, 0x4d, 0x7b, 0xc7, 0x0, 0x18, 0xd4, 0x6a, 0xfa, 0x16, 0xf7, 0x0, 0x8b, 0x23, + 0x39, 0x80, 0x16, 0x8d, 0x11, 0xc6, 0xb6, 0xdd, 0x80, 0x92, 0x82, 0xef, 0x60, 0x33, 0x2, 0xd, 0x0, + 0x1a, 0xb3, 0x73, 0x71, 0x92, 0xf, 0x16, 0x1a, 0xe5, 0x1a, 0x54, 0xf, 0x65, 0x46, 0x4a, 0x64, 0xac, + 0x7, 0x6d, 0xde, 0xb2, 0x7c, 0xea, 0x54, 0x8a, 0x89, 0x90}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xe2, 0x57, 0x3, 0xc0, 0x3b, 0xa7, 0x3f, 0xe, 0x20, 0x91}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x8c, 0x42, 0xc7, 0x97, 0x4c, 0x33, 0xe7, 0x9d, 0xab, 0x4b, 0xcc, 0xc5, 0xe0, + 0xd9, 0x12, 0x90, 0x6c, 0xdf, 0x16, 0x48, 0xb9, 0x6b, 0x45, 0x61, 0xc3}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xaa, 0xfa, 0x73, 0xa3, 0x26, 0x1a, 0x13, 0x3f, 0x49, 0xb0}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x2a, 0xf4}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa9, 0xaf, 0x84, 0x50, 0x26, 0x8, 0x70, 0x80, 0x30, 0x42, 0x17, 0x2a, 0xa2, + 0x75, 0x94, 0x33, 0x70, 0xc, 0x45, 0x2, 0x5, 0x15, 0x29, 0x4d, 0x7b, 0xc7}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd4, 0x6a, 0xfa, 0x16, 0xf7, 0x0, 0x8b, 0x23, 0x39, 0x80, 0x16, 0x8d, + 0x11, 0xc6, 0xb6, 0xdd, 0x80, 0x92, 0x82, 0xef, 0x60, 0x33, 0x2, 0xd}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb3, 0x73, 0x71, 0x92, 0xf, 0x16, 0x1a, 0xe5, 0x1a, 0x54, 0xf, 0x65, 0x46, + 0x4a, 0x64, 0xac, 0x7, 0x6d, 0xde, 0xb2, 0x7c, 0xea, 0x54, 0x8a, 0x89, 0x90}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23824, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26289, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 20314 -// ["\247$\SOcz\155#\129\206\189\129\151\230\250[\179\254\214=v\GS\230\237\227\174\157\ETB\ESC\189"] [] +// UnsubscribeRequest 9896 ["\tB\174\175\ETB\143 +// \v","\ENQm\"j\248","WK\250\223\NULU\203\244\200\172*\132","\RS\242\186\199b\226\200OR\vY\184#n\183\221\242\148bb\SUB\180"] +// [] TEST(Unsubscribe311QCTest, Encode4) { - uint8_t pkt[] = {0xa2, 0x21, 0x4f, 0x5a, 0x0, 0x1d, 0xf7, 0x24, 0xe, 0x63, 0x7a, 0x9b, - 0x23, 0x81, 0xce, 0xbd, 0x81, 0x97, 0xe6, 0xfa, 0x5b, 0xb3, 0xfe, 0xd6, - 0x3d, 0x76, 0x1d, 0xe6, 0xed, 0xe3, 0xae, 0x9d, 0x17, 0x1b, 0xbd}; + uint8_t pkt[] = {0xa2, 0x39, 0x26, 0xa8, 0x0, 0x8, 0x9, 0x42, 0xae, 0xaf, 0x17, 0x8f, 0x20, 0xb, 0x0, + 0x5, 0x5, 0x6d, 0x22, 0x6a, 0xf8, 0x0, 0xc, 0x57, 0x4b, 0xfa, 0xdf, 0x0, 0x55, 0xcb, + 0xf4, 0xc8, 0xac, 0x2a, 0x84, 0x0, 0x16, 0x1e, 0xf2, 0xba, 0xc7, 0x62, 0xe2, 0xc8, 0x4f, + 0x52, 0xb, 0x59, 0xb8, 0x23, 0x6e, 0xb7, 0xdd, 0xf2, 0x94, 0x62, 0x62, 0x1a, 0xb4}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xf7, 0x24, 0xe, 0x63, 0x7a, 0x9b, 0x23, 0x81, 0xce, 0xbd, - 0x81, 0x97, 0xe6, 0xfa, 0x5b, 0xb3, 0xfe, 0xd6, 0x3d, 0x76, - 0x1d, 0xe6, 0xed, 0xe3, 0xae, 0x9d, 0x17, 0x1b, 0xbd}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x9, 0x42, 0xae, 0xaf, 0x17, 0x8f, 0x20, 0xb}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x5, 0x6d, 0x22, 0x6a, 0xf8}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x57, 0x4b, 0xfa, 0xdf, 0x0, 0x55, 0xcb, 0xf4, 0xc8, 0xac, 0x2a, 0x84}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x1e, 0xf2, 0xba, 0xc7, 0x62, 0xe2, 0xc8, 0x4f, 0x52, 0xb, 0x59, + 0xb8, 0x23, 0x6e, 0xb7, 0xdd, 0xf2, 0x94, 0x62, 0x62, 0x1a, 0xb4}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20314, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9896, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 29664 -// ["\214i\176\156X)\134(\251ux\210\240\DC1\SUB\200\219\EM\219l\213\170B","=\197\235\163\&1\EM\ENQ\255\181\143\201\171vu_o","6\134~W\204","7\223'\b\224\232u","\166v\184[x","z\n\135.Z\170\&9\208\249\231|\132",":1\229C\168\137","7\181\161\220\150\219:\219\171i\226u\150\195`\169","\223\233\205\n\174\ETB\193\ETB\v\255\&0\137u\158\136D\201\&1","\EMX\246C\131J -// \242>:\SOH\164"] [] +// UnsubscribeRequest 9659 +// ["\253","\160\188","\246\207o\213\149\183l\132M\244\133\167\244B[\202","\DC4\197.\n\245\152<\170X\185\RS?8\177\237\152\ENQ\173\173\191\249\&8x\ESC\215\145\250","\158F\EOT.\ESC\EMp\SUB\218\&9P\172LJ\198"] +// [] TEST(Unsubscribe311QCTest, Encode5) { - uint8_t pkt[] = {0xa2, 0x8e, 0x1, 0x73, 0xe0, 0x0, 0x17, 0xd6, 0x69, 0xb0, 0x9c, 0x58, 0x29, 0x86, 0x28, 0xfb, 0x75, - 0x78, 0xd2, 0xf0, 0x11, 0x1a, 0xc8, 0xdb, 0x19, 0xdb, 0x6c, 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0x19, 0x70, 0x1a, 0xda, 0x39, 0x50, 0xac, 0x4c, 0x4a, 0xc6}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd6, 0x69, 0xb0, 0x9c, 0x58, 0x29, 0x86, 0x28, 0xfb, 0x75, 0x78, 0xd2, - 0xf0, 0x11, 0x1a, 0xc8, 0xdb, 0x19, 0xdb, 0x6c, 0xd5, 0xaa, 0x42}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xfd}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3d, 0xc5, 0xeb, 0xa3, 0x31, 0x19, 0x5, 0xff, - 0xb5, 0x8f, 0xc9, 0xab, 0x76, 0x75, 0x5f, 0x6f}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa0, 0xbc}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x36, 0x86, 0x7e, 0x57, 0xcc}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf6, 0xcf, 0x6f, 0xd5, 0x95, 0xb7, 0x6c, 0x84, + 0x4d, 0xf4, 0x85, 0xa7, 0xf4, 0x42, 0x5b, 0xca}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x37, 0xdf, 0x27, 0x8, 0xe0, 0xe8, 0x75}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x14, 0xc5, 0x2e, 0xa, 0xf5, 0x98, 0x3c, 0xaa, 0x58, 0xb9, 0x1e, 0x3f, 0x38, 0xb1, + 0xed, 0x98, 0x5, 0xad, 0xad, 0xbf, 0xf9, 0x38, 0x78, 0x1b, 0xd7, 0x91, 0xfa}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa6, 0x76, 0xb8, 0x5b, 0x78}; - lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x9e, 0x46, 0x4, 0x2e, 0x1b, 0x19, 0x70, 0x1a, + 0xda, 0x39, 0x50, 0xac, 0x4c, 0x4a, 0xc6}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7a, 0xa, 0x87, 0x2e, 0x5a, 0xaa, 0x39, 0xd0, 0xf9, 0xe7, 0x7c, 0x84}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3a, 0x31, 0xe5, 0x43, 0xa8, 0x89}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x37, 0xb5, 0xa1, 0xdc, 0x96, 0xdb, 0x3a, 0xdb, - 0xab, 0x69, 0xe2, 0x75, 0x96, 0xc3, 0x60, 0xa9}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xdf, 0xe9, 0xcd, 0xa, 0xae, 0x17, 0xc1, 0x17, 0xb, - 0xff, 0x30, 0x89, 0x75, 0x9e, 0x88, 0x44, 0xc9, 0x31}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x19, 0x58, 0xf6, 0x43, 0x83, 0x4a, 0x20, 0xf2, 0x3e, 0x3a, 0x1, 0xa4}; - lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29664, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9659, 5, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 28866 ["\ACK"] [] +// UnsubscribeRequest 5752 +// ["\a\tr\STXO4\140\DC2\166\&9\DC2\n\233","G\196\155\t.\170\213Y\229_\218\226k\NAKIi\229\145\SI\234","M!\NUL\223\224\185\128\215\200\186\241f\221vD\173\tW\162\EOT\200\&4!\n\160","Wu\227\181\230\224\215}\250\227\167\RS\140QIPk\192\135\b\STX\180\186\147\135U\174\155"] +// [] TEST(Unsubscribe311QCTest, Encode6) { - uint8_t pkt[] = {0xa2, 0x5, 0x70, 0xc2, 0x0, 0x1, 0x6}; + uint8_t pkt[] = {0xa2, 0x60, 0x16, 0x78, 0x0, 0xd, 0x7, 0x9, 0x72, 0x2, 0x4f, 0x34, 0x8c, 0x12, 0xa6, 0x39, 0x12, + 0xa, 0xe9, 0x0, 0x14, 0x47, 0xc4, 0x9b, 0x9, 0x2e, 0xaa, 0xd5, 0x59, 0xe5, 0x5f, 0xda, 0xe2, 0x6b, + 0x15, 0x49, 0x69, 0xe5, 0x91, 0xf, 0xea, 0x0, 0x19, 0x4d, 0x21, 0x0, 0xdf, 0xe0, 0xb9, 0x80, 0xd7, + 0xc8, 0xba, 0xf1, 0x66, 0xdd, 0x76, 0x44, 0xad, 0x9, 0x57, 0xa2, 0x4, 0xc8, 0x34, 0x21, 0xa, 0xa0, + 0x0, 0x1c, 0x57, 0x75, 0xe3, 0xb5, 0xe6, 0xe0, 0xd7, 0x7d, 0xfa, 0xe3, 0xa7, 0x1e, 0x8c, 0x51, 0x49, + 0x50, 0x6b, 0xc0, 0x87, 0x8, 0x2, 0xb4, 0xba, 0x93, 0x87, 0x55, 0xae, 0x9b}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x6}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x7, 0x9, 0x72, 0x2, 0x4f, 0x34, 0x8c, 0x12, 0xa6, 0x39, 0x12, 0xa, 0xe9}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x47, 0xc4, 0x9b, 0x9, 0x2e, 0xaa, 0xd5, 0x59, 0xe5, 0x5f, + 0xda, 0xe2, 0x6b, 0x15, 0x49, 0x69, 0xe5, 0x91, 0xf, 0xea}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4d, 0x21, 0x0, 0xdf, 0xe0, 0xb9, 0x80, 0xd7, 0xc8, 0xba, 0xf1, 0x66, 0xdd, + 0x76, 0x44, 0xad, 0x9, 0x57, 0xa2, 0x4, 0xc8, 0x34, 0x21, 0xa, 0xa0}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x57, 0x75, 0xe3, 0xb5, 0xe6, 0xe0, 0xd7, 0x7d, 0xfa, 0xe3, + 0xa7, 0x1e, 0x8c, 0x51, 0x49, 0x50, 0x6b, 0xc0, 0x87, 0x8, + 0x2, 0xb4, 0xba, 0x93, 0x87, 0x55, 0xae, 0x9b}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28866, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5752, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22023 ["f\155\163\EOT\DLE\ETX\209\SO","d\219\136\ENQC\167\239$\224","e{[\245\153\203\211*~\193"] +// UnsubscribeRequest 26590 +// ["\"\128\&3`Z\154EIF","\191\216\128<6\157\128\f\207\159&h\207O\235|\169g\r\DC4\137\DC3\175\176\&3\201EN\NAK","\130{\210H\187 +// \219q\251wl\247&\nJ$\185\DLE\158\179","\167\NUL\ETX\172\207gd3\251C\170\SIM\239\157O\233\224-\251e-\224\148\188","\184\NAK\198\&2\137\SI:\164\DC3\SYN(#\174\242\179\138<\206\157\US","\222\SO=\194\210\132u\185\192\r5\181","O\231\246\135\209\137","B>\250\193\SOL\212\170\245\168)\237\134\187\204\232*+\218\EM7\r\142\EOTb\221\152l\148"] // [] TEST(Unsubscribe311QCTest, Encode7) { - uint8_t pkt[] = {0xa2, 0x23, 0x56, 0x7, 0x0, 0x8, 0x66, 0x9b, 0xa3, 0x4, 0x10, 0x3, 0xd1, - 0xe, 0x0, 0x9, 0x64, 0xdb, 0x88, 0x5, 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0x4, 0x62, 0xdd, 0x98, 0x6c, 0x94}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x66, 0x9b, 0xa3, 0x4, 0x10, 0x3, 0xd1, 0xe}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x22, 0x80, 0x33, 0x60, 0x5a, 0x9a, 0x45, 0x49, 0x46}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x64, 0xdb, 0x88, 0x5, 0x43, 0xa7, 0xef, 0x24, 0xe0}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbf, 0xd8, 0x80, 0x3c, 0x36, 0x9d, 0x80, 0xc, 0xcf, 0x9f, + 0x26, 0x68, 0xcf, 0x4f, 0xeb, 0x7c, 0xa9, 0x67, 0xd, 0x14, + 0x89, 0x13, 0xaf, 0xb0, 0x33, 0xc9, 0x45, 0x4e, 0x15}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x65, 0x7b, 0x5b, 0xf5, 0x99, 0xcb, 0xd3, 0x2a, 0x7e, 0xc1}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x82, 0x7b, 0xd2, 0x48, 0xbb, 0x20, 0xdb, 0x71, 0xfb, 0x77, + 0x6c, 0xf7, 0x26, 0xa, 0x4a, 0x24, 0xb9, 0x10, 0x9e, 0xb3}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xa7, 0x0, 0x3, 0xac, 0xcf, 0x67, 0x64, 0x33, 0xfb, 0x43, 0xaa, 0xf, 0x4d, + 0xef, 0x9d, 0x4f, 0xe9, 0xe0, 0x2d, 0xfb, 0x65, 0x2d, 0xe0, 0x94, 0xbc}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xb8, 0x15, 0xc6, 0x32, 0x89, 0xf, 0x3a, 0xa4, 0x13, 0x16, + 0x28, 0x23, 0xae, 0xf2, 0xb3, 0x8a, 0x3c, 0xce, 0x9d, 0x1f}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xde, 0xe, 0x3d, 0xc2, 0xd2, 0x84, 0x75, 0xb9, 0xc0, 0xd, 0x35, 0xb5}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x4f, 0xe7, 0xf6, 0x87, 0xd1, 0x89}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x42, 0x3e, 0xfa, 0xc1, 0xe, 0x4c, 0xd4, 0xaa, 0xf5, 0xa8, + 0x29, 0xed, 0x86, 0xbb, 0xcc, 0xe8, 0x2a, 0x2b, 0xda, 0x19, + 0x37, 0xd, 0x8e, 0x4, 0x62, 0xdd, 0x98, 0x6c, 0x94}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22023, 3, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26590, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 28799 -// ["\n\DC3\242\212\169e\178\133","\175\193&\241\184C\SO\NAK\147\164[_\NAKK\180\249\202\fq\246\RS"] [] +// UnsubscribeRequest 28467 ["\188j71/\157\SUBlO\ESC","N\195\136\SUB[L\203?\219","\USk\146!\197w\FSR\152\254\&3\216 +// \DEL\184\"\147\247\GS\137\168","\147\161\247W\NAKc\172\214*\254 17\201\164\177)\167e\233\179\198\197Wf\a\153x"] [] TEST(Unsubscribe311QCTest, Encode8) { - uint8_t pkt[] = {0xa2, 0x23, 0x70, 0x7f, 0x0, 0x8, 0xa, 0x13, 0xf2, 0xd4, 0xa9, 0x65, 0xb2, - 0x85, 0x0, 0x15, 0xaf, 0xc1, 0x26, 0xf1, 0xb8, 0x43, 0xe, 0x15, 0x93, 0xa4, - 0x5b, 0x5f, 0x15, 0x4b, 0xb4, 0xf9, 0xca, 0xc, 0x71, 0xf6, 0x1e}; + uint8_t pkt[] = {0xa2, 0x4e, 0x6f, 0x33, 0x0, 0xa, 0xbc, 0x6a, 0x37, 0x31, 0x2f, 0x9d, 0x1a, 0x6c, 0x4f, 0x1b, + 0x0, 0x9, 0x4e, 0xc3, 0x88, 0x1a, 0x5b, 0x4c, 0xcb, 0x3f, 0xdb, 0x0, 0x15, 0x1f, 0x6b, 0x92, + 0x21, 0xc5, 0x77, 0x1c, 0x52, 0x98, 0xfe, 0x33, 0xd8, 0x20, 0x7f, 0xb8, 0x22, 0x93, 0xf7, 0x1d, + 0x89, 0xa8, 0x0, 0x1c, 0x93, 0xa1, 0xf7, 0x57, 0x15, 0x63, 0xac, 0xd6, 0x2a, 0xfe, 0x20, 0x31, + 0x37, 0xc9, 0xa4, 0xb1, 0x29, 0xa7, 0x65, 0xe9, 0xb3, 0xc6, 0xc5, 0x57, 0x66, 0x7, 0x99, 0x78}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xa, 0x13, 0xf2, 0xd4, 0xa9, 0x65, 0xb2, 0x85}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xbc, 0x6a, 0x37, 0x31, 0x2f, 0x9d, 0x1a, 0x6c, 0x4f, 0x1b}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xaf, 0xc1, 0x26, 0xf1, 0xb8, 0x43, 0xe, 0x15, 0x93, 0xa4, 0x5b, - 0x5f, 0x15, 0x4b, 0xb4, 0xf9, 0xca, 0xc, 0x71, 0xf6, 0x1e}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4e, 0xc3, 0x88, 0x1a, 0x5b, 0x4c, 0xcb, 0x3f, 0xdb}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1f, 0x6b, 0x92, 0x21, 0xc5, 0x77, 0x1c, 0x52, 0x98, 0xfe, 0x33, + 0xd8, 0x20, 0x7f, 0xb8, 0x22, 0x93, 0xf7, 0x1d, 0x89, 0xa8}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x93, 0xa1, 0xf7, 0x57, 0x15, 0x63, 0xac, 0xd6, 0x2a, 0xfe, + 0x20, 0x31, 0x37, 0xc9, 0xa4, 0xb1, 0x29, 0xa7, 0x65, 0xe9, + 0xb3, 0xc6, 0xc5, 0x57, 0x66, 0x7, 0x99, 0x78}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28799, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28467, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 20344 -// ["\132&\189So\207\US\218VGo\190\255u\223\192\228\&7]\EOTM\164\206\171IIN[W","\234\252\195\214\201.\223\160\FSx\204\229\237{-\213\ESC_d\SUB\DC1N"] [] +TEST(Unsubscribe311QCTest, Encode12) { + uint8_t pkt[] = {0xa2, 0x10, 0x45, 0x69, 0x0, 0xc, 0xc0, 0x64, 0xde, + 0x32, 0x3e, 0xd5, 0x1b, 0x5f, 0x64, 0x1a, 0x11, 0x4e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xc0, 0x64, 0xde, 0x32, 0x3e, 0xd5, 0x1b, 0x5f, 0x64, 0x1a, 0x11, 0x4e}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17769, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 17486 -// ["a\ETX","\129\230^\155\234\&7s\234#C\235[\217\184\218\193\151}>Yj\DC2\239\167\132\159{","\221\ESCwC\170\ESC3\SYN\247\206"] +// UnsubscribeRequest 21908 +// ["$","\GSI\141^\185\188\DC2|\159M\189\209\DC4\211\&1","L\t}\130~\220\&8\211\235","\210\USg\203\179@\DC2\174l\v\193\DC2)Q\233\STX#\177C\164\ENQ&@;=\238\138\217\158"] // [] -TEST(Unsubscribe311QCTest, Encode11) { - uint8_t pkt[] = {0xa2, 0x2f, 0x44, 0x4e, 0x0, 0x2, 0x61, 0x3, 0x0, 0x1b, 0x81, 0xe6, 0x5e, 0x9b, 0xea, 0x37, 0x73, - 0xea, 0x23, 0x43, 0xeb, 0x5b, 0xd9, 0xb8, 0xda, 0xc1, 0x97, 0x7d, 0x3e, 0x59, 0x6a, 0x12, 0xef, 0xa7, - 0x84, 0x9f, 0x7b, 0x0, 0xa, 0xdd, 0x1b, 0x77, 0x43, 0xaa, 0x1b, 0x33, 0x16, 0xf7, 0xce}; +TEST(Unsubscribe311QCTest, Encode13) { + uint8_t pkt[] = {0xa2, 0x40, 0x55, 0x94, 0x0, 0x1, 0x24, 0x0, 0xf, 0x1d, 0x49, 0x8d, 0x5e, 0xb9, 0xbc, 0x12, 0x7c, + 0x9f, 0x4d, 0xbd, 0xd1, 0x14, 0xd3, 0x31, 0x0, 0x9, 0x4c, 0x9, 0x7d, 0x82, 0x7e, 0xdc, 0x38, 0xd3, + 0xeb, 0x0, 0x1d, 0xd2, 0x1f, 0x67, 0xcb, 0xb3, 0x40, 0x12, 0xae, 0x6c, 0xb, 0xc1, 0x12, 0x29, 0x51, + 0xe9, 0x2, 0x23, 0xb1, 0x43, 0xa4, 0x5, 0x26, 0x40, 0x3b, 0x3d, 0xee, 0x8a, 0xd9, 0x9e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x61, 0x3}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x24}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x81, 0xe6, 0x5e, 0x9b, 0xea, 0x37, 0x73, 0xea, 0x23, 0x43, 0xeb, 0x5b, 0xd9, 0xb8, - 0xda, 0xc1, 0x97, 0x7d, 0x3e, 0x59, 0x6a, 0x12, 0xef, 0xa7, 0x84, 0x9f, 0x7b}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1d, 0x49, 0x8d, 0x5e, 0xb9, 0xbc, 0x12, 0x7c, + 0x9f, 0x4d, 0xbd, 0xd1, 0x14, 0xd3, 0x31}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdd, 0x1b, 0x77, 0x43, 0xaa, 0x1b, 0x33, 0x16, 0xf7, 0xce}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4c, 0x9, 0x7d, 0x82, 0x7e, 0xdc, 0x38, 0xd3, 0xeb}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd2, 0x1f, 0x67, 0xcb, 0xb3, 0x40, 0x12, 0xae, 0x6c, 0xb, + 0xc1, 0x12, 0x29, 0x51, 0xe9, 0x2, 0x23, 0xb1, 0x43, 0xa4, + 0x5, 0x26, 0x40, 0x3b, 0x3d, 0xee, 0x8a, 0xd9, 0x9e}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17486, 3, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21908, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 7754 ["\211\172/9\239\190\154\155:\145\238\225c\242\144\159\183"] [] -TEST(Unsubscribe311QCTest, Encode12) { - uint8_t pkt[] = {0xa2, 0x15, 0x1e, 0x4a, 0x0, 0x11, 0xd3, 0xac, 0x2f, 0x39, 0xef, 0xbe, - 0x9a, 0x9b, 0x3a, 0x91, 0xee, 0xe1, 0x63, 0xf2, 0x90, 0x9f, 0xb7}; +// UnsubscribeRequest 12542 ["j\251j\160\243\235 +// \r\246R\192\234l\DC2.\153\144v\NAK\RSXz\DEL:","\DC4\SYN\240\227S!\ETX\ETBS\179\245t\185D+\225\&3n~\146z\194\143"] [] +TEST(Unsubscribe311QCTest, Encode14) { + uint8_t pkt[] = {0xa2, 0x35, 0x30, 0xfe, 0x0, 0x18, 0x6a, 0xfb, 0x6a, 0xa0, 0xf3, 0xeb, 0x20, 0xd, + 0xf6, 0x52, 0xc0, 0xea, 0x6c, 0x12, 0x2e, 0x99, 0x90, 0x76, 0x15, 0x1e, 0x58, 0x7a, + 0x7f, 0x3a, 0x0, 0x17, 0x14, 0x16, 0xf0, 0xe3, 0x53, 0x21, 0x3, 0x17, 0x53, 0xb3, + 0xf5, 0x74, 0xb9, 0x44, 0x2b, 0xe1, 0x33, 0x6e, 0x7e, 0x92, 0x7a, 0xc2, 0x8f}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x6a, 0xfb, 0x6a, 0xa0, 0xf3, 0xeb, 0x20, 0xd, 0xf6, 0x52, 0xc0, 0xea, + 0x6c, 0x12, 0x2e, 0x99, 0x90, 0x76, 0x15, 0x1e, 0x58, 0x7a, 0x7f, 0x3a}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x14, 0x16, 0xf0, 0xe3, 0x53, 0x21, 0x3, 0x17, 0x53, 0xb3, 0xf5, 0x74, + 0xb9, 0x44, 0x2b, 0xe1, 0x33, 0x6e, 0x7e, 0x92, 0x7a, 0xc2, 0x8f}; + lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12542, 2, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 22335 ["\171r\247N1\218","4\149\209gL^\241\220\171\227{YRF8\184,\212\205\157"] [] +TEST(Unsubscribe311QCTest, Encode15) { + uint8_t pkt[] = {0xa2, 0x20, 0x57, 0x3f, 0x0, 0x6, 0xab, 0x72, 0xf7, 0x4e, 0x31, 0xda, + 0x0, 0x14, 0x34, 0x95, 0xd1, 0x67, 0x4c, 0x5e, 0xf1, 0xdc, 0xab, 0xe3, + 0x7b, 0x59, 0x52, 0x46, 0x38, 0xb8, 0x2c, 0xd4, 0xcd, 0x9d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xab, 0x72, 0xf7, 0x4e, 0x31, 0xda}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x34, 0x95, 0xd1, 0x67, 0x4c, 0x5e, 0xf1, 0xdc, 0xab, 0xe3, + 0x7b, 0x59, 0x52, 0x46, 0x38, 0xb8, 0x2c, 0xd4, 0xcd, 0x9d}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22335, 2, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 6771 +// ["\135\US\219/\163+\FS-","\161\136\131Y\CAN\230t&\196\174\&4-\f\129\155\189N\211c\233\235q\138\227\250O\148\222\&3","JJ4\DEL\247{\189\166\DLE5\241-\195\141X\tN\138\248\171\247(\202Z\231\&6C\255","\182\r\144B[\233\NAK\194\179{\177\&6\206o\172h","","\163,+n\168M\SO\184\180","?\146X+Lw\191\EM\209\t\174\211\160s\192Fa\237\195\212\&1DY\131\163","z\255\213\SUBvQ\236M\152\208\149h","\137\237\131\198XD\SO^P\207\227\146\248\240\227}&\141\142v>\GS","\192\221\160N\167e\"R<\142",""] +// [] +TEST(Unsubscribe311QCTest, Encode16) { + uint8_t pkt[] = {0xa2, 0xb7, 0x1, 0x1a, 0x73, 0x0, 0x8, 0x87, 0x1f, 0xdb, 0x2f, 0xa3, 0x2b, 0x1c, 0x2d, 0x0, 0x1d, + 0xa1, 0x88, 0x83, 0x59, 0x18, 0xe6, 0x74, 0x26, 0xc4, 0xae, 0x34, 0x2d, 0xc, 0x81, 0x9b, 0xbd, 0x4e, + 0xd3, 0x63, 0xe9, 0xeb, 0x71, 0x8a, 0xe3, 0xfa, 0x4f, 0x94, 0xde, 0x33, 0x0, 0x1c, 0x4a, 0x4a, 0x34, + 0x7f, 0xf7, 0x7b, 0xbd, 0xa6, 0x10, 0x35, 0xf1, 0x2d, 0xc3, 0x8d, 0x58, 0x9, 0x4e, 0x8a, 0xf8, 0xab, + 0xf7, 0x28, 0xca, 0x5a, 0xe7, 0x36, 0x43, 0xff, 0x0, 0x10, 0xb6, 0xd, 0x90, 0x42, 0x5b, 0xe9, 0x15, + 0xc2, 0xb3, 0x7b, 0xb1, 0x36, 0xce, 0x6f, 0xac, 0x68, 0x0, 0x0, 0x0, 0x9, 0xa3, 0x2c, 0x2b, 0x6e, + 0xa8, 0x4d, 0xe, 0xb8, 0xb4, 0x0, 0x19, 0x3f, 0x92, 0x58, 0x2b, 0x4c, 0x77, 0xbf, 0x19, 0xd1, 0x9, + 0xae, 0xd3, 0xa0, 0x73, 0xc0, 0x46, 0x61, 0xed, 0xc3, 0xd4, 0x31, 0x44, 0x59, 0x83, 0xa3, 0x0, 0xc, + 0x7a, 0xff, 0xd5, 0x1a, 0x76, 0x51, 0xec, 0x4d, 0x98, 0xd0, 0x95, 0x68, 0x0, 0x16, 0x89, 0xed, 0x83, + 0xc6, 0x58, 0x44, 0xe, 0x5e, 0x50, 0xcf, 0xe3, 0x92, 0xf8, 0xf0, 0xe3, 0x7d, 0x26, 0x8d, 0x8e, 0x76, + 0x3e, 0x1d, 0x0, 0xa, 0xc0, 0xdd, 0xa0, 0x4e, 0xa7, 0x65, 0x22, 0x52, 0x3c, 0x8e, 0x0, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x87, 0x1f, 0xdb, 0x2f, 0xa3, 0x2b, 0x1c, 0x2d}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xa1, 0x88, 0x83, 0x59, 0x18, 0xe6, 0x74, 0x26, 0xc4, 0xae, + 0x34, 0x2d, 0xc, 0x81, 0x9b, 0xbd, 0x4e, 0xd3, 0x63, 0xe9, + 0xeb, 0x71, 0x8a, 0xe3, 0xfa, 0x4f, 0x94, 0xde, 0x33}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4a, 0x4a, 0x34, 0x7f, 0xf7, 0x7b, 0xbd, 0xa6, 0x10, 0x35, + 0xf1, 0x2d, 0xc3, 0x8d, 0x58, 0x9, 0x4e, 0x8a, 0xf8, 0xab, + 0xf7, 0x28, 0xca, 0x5a, 0xe7, 0x36, 0x43, 0xff}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xb6, 0xd, 0x90, 0x42, 0x5b, 0xe9, 0x15, 0xc2, + 0xb3, 0x7b, 0xb1, 0x36, 0xce, 0x6f, 0xac, 0x68}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa3, 0x2c, 0x2b, 0x6e, 0xa8, 0x4d, 0xe, 0xb8, 0xb4}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x3f, 0x92, 0x58, 0x2b, 0x4c, 0x77, 0xbf, 0x19, 0xd1, 0x9, 0xae, 0xd3, 0xa0, + 0x73, 0xc0, 0x46, 0x61, 0xed, 0xc3, 0xd4, 0x31, 0x44, 0x59, 0x83, 0xa3}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x7a, 0xff, 0xd5, 0x1a, 0x76, 0x51, 0xec, 0x4d, 0x98, 0xd0, 0x95, 0x68}; + lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x89, 0xed, 0x83, 0xc6, 0x58, 0x44, 0xe, 0x5e, 0x50, 0xcf, 0xe3, + 0x92, 0xf8, 0xf0, 0xe3, 0x7d, 0x26, 0x8d, 0x8e, 0x76, 0x3e, 0x1d}; + lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xc0, 0xdd, 0xa0, 0x4e, 0xa7, 0x65, 0x22, 0x52, 0x3c, 0x8e}; + lwmqtt_string_t topic_filter_s9 = {10, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6771, 11, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 19984 +// ["I|\192\176@\ETB\219a\254\217\n\238\172\EOT\202\143*?\ETB\130\172\174\CAN\DEL\177\163","~V\240~\192","b6\189\&0\244q","\143\166/\SO\r\r\240\212\181\136\172$\233\243\149\&70h_|\204\136 +// \206\146\134\236\&6\179","\157\168\227\SOH\242\183\153\nO\235\DEL\aW\227\196\225\179\210s\174\FS\155(\t\137\158\229","\ESCl\130\ACK\135\&4,D\208\141\243s\n*F*","\170\194\223-H\208r]UF+\221\\.\187\225\135]x\218\140on\180\233","\194\f\246\&1n\154\DC1\195\170\161\232\152\185\222\ESC"] +// [] +TEST(Unsubscribe311QCTest, Encode17) { + uint8_t pkt[] = { + 0xa2, 0xa7, 0x1, 0x4e, 0x10, 0x0, 0x1a, 0x49, 0x7c, 0xc0, 0xb0, 0x40, 0x17, 0xdb, 0x61, 0xfe, 0xd9, 0xa, 0xee, + 0xac, 0x4, 0xca, 0x8f, 0x2a, 0x3f, 0x17, 0x82, 0xac, 0xae, 0x18, 0x7f, 0xb1, 0xa3, 0x0, 0x5, 0x7e, 0x56, 0xf0, + 0x7e, 0xc0, 0x0, 0x6, 0x62, 0x36, 0xbd, 0x30, 0xf4, 0x71, 0x0, 0x1d, 0x8f, 0xa6, 0x2f, 0xe, 0xd, 0xd, 0xf0, + 0xd4, 0xb5, 0x88, 0xac, 0x24, 0xe9, 0xf3, 0x95, 0x37, 0x30, 0x68, 0x5f, 0x7c, 0xcc, 0x88, 0x20, 0xce, 0x92, 0x86, + 0xec, 0x36, 0xb3, 0x0, 0x1b, 0x9d, 0xa8, 0xe3, 0x1, 0xf2, 0xb7, 0x99, 0xa, 0x4f, 0xeb, 0x7f, 0x7, 0x57, 0xe3, + 0xc4, 0xe1, 0xb3, 0xd2, 0x73, 0xae, 0x1c, 0x9b, 0x28, 0x9, 0x89, 0x9e, 0xe5, 0x0, 0x10, 0x1b, 0x6c, 0x82, 0x6, + 0x87, 0x34, 0x2c, 0x44, 0xd0, 0x8d, 0xf3, 0x73, 0xa, 0x2a, 0x46, 0x2a, 0x0, 0x19, 0xaa, 0xc2, 0xdf, 0x2d, 0x48, + 0xd0, 0x72, 0x5d, 0x55, 0x46, 0x2b, 0xdd, 0x5c, 0x2e, 0xbb, 0xe1, 0x87, 0x5d, 0x78, 0xda, 0x8c, 0x6f, 0x6e, 0xb4, + 0xe9, 0x0, 0xf, 0xc2, 0xc, 0xf6, 0x31, 0x6e, 0x9a, 0x11, 0xc3, 0xaa, 0xa1, 0xe8, 0x98, 0xb9, 0xde, 0x1b}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xd3, 0xac, 0x2f, 0x39, 0xef, 0xbe, 0x9a, 0x9b, 0x3a, - 0x91, 0xee, 0xe1, 0x63, 0xf2, 0x90, 0x9f, 0xb7}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x49, 0x7c, 0xc0, 0xb0, 0x40, 0x17, 0xdb, 0x61, 0xfe, 0xd9, 0xa, 0xee, 0xac, + 0x4, 0xca, 0x8f, 0x2a, 0x3f, 0x17, 0x82, 0xac, 0xae, 0x18, 0x7f, 0xb1, 0xa3}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7e, 0x56, 0xf0, 0x7e, 0xc0}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x62, 0x36, 0xbd, 0x30, 0xf4, 0x71}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x8f, 0xa6, 0x2f, 0xe, 0xd, 0xd, 0xf0, 0xd4, 0xb5, 0x88, + 0xac, 0x24, 0xe9, 0xf3, 0x95, 0x37, 0x30, 0x68, 0x5f, 0x7c, + 0xcc, 0x88, 0x20, 0xce, 0x92, 0x86, 0xec, 0x36, 0xb3}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9d, 0xa8, 0xe3, 0x1, 0xf2, 0xb7, 0x99, 0xa, 0x4f, 0xeb, 0x7f, 0x7, 0x57, 0xe3, + 0xc4, 0xe1, 0xb3, 0xd2, 0x73, 0xae, 0x1c, 0x9b, 0x28, 0x9, 0x89, 0x9e, 0xe5}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1b, 0x6c, 0x82, 0x6, 0x87, 0x34, 0x2c, 0x44, + 0xd0, 0x8d, 0xf3, 0x73, 0xa, 0x2a, 0x46, 0x2a}; + lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xaa, 0xc2, 0xdf, 0x2d, 0x48, 0xd0, 0x72, 0x5d, 0x55, 0x46, 0x2b, 0xdd, 0x5c, + 0x2e, 0xbb, 0xe1, 0x87, 0x5d, 0x78, 0xda, 0x8c, 0x6f, 0x6e, 0xb4, 0xe9}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xc2, 0xc, 0xf6, 0x31, 0x6e, 0x9a, 0x11, 0xc3, + 0xaa, 0xa1, 0xe8, 0x98, 0xb9, 0xde, 0x1b}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7754, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19984, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 949 ["\139xV\142E\139\&7\179T\130\212\250G\195F\193\252\250\202{\196z\228\164\STX\US\219"] [] -TEST(Unsubscribe311QCTest, Encode13) { - uint8_t pkt[] = {0xa2, 0x1f, 0x3, 0xb5, 0x0, 0x1b, 0x8b, 0x78, 0x56, 0x8e, 0x45, 0x8b, 0x37, 0xb3, 0x54, 0x82, 0xd4, - 0xfa, 0x47, 0xc3, 0x46, 0xc1, 0xfc, 0xfa, 0xca, 0x7b, 0xc4, 0x7a, 0xe4, 0xa4, 0x2, 0x1f, 0xdb}; +// UnsubscribeRequest 8587 +// ["^\158\181\192J\FS\249","\248\243\ACK\NULSg}\128\177\154\&2\SUB-\242\GS\229\t\NAK\US\189m\225\230I\FS","\SUB\194\179C\203\152","\244#\152\175\194\153\231\239\ETBD\146Q\248g\246w\143K\194\245\181","\DC4\tIs\155jp\197\SYN'1,G(P\NAK$\163\144\146\159\USY\194M\151\157\255","\236\159","\228\132\130\254\213\173\&1\202\&0\136\135\231\157\167p\199}\139\ETX +// \191\189\168\245\227\DC2}","\233mc\155K\b!\RSu\SUB","t\178\DEL\DELy\240\224\228\141\238\EOT\EM\153;\190\234","\128xS\199\240\228\&0R\vR\180\&3\217\179\162H\189%\192\247\195e\179t\RS\"x\DC1my","\246\ESC\248\136\ETX>\225\204\ACK\136\170\"\v\232\253\219\199=\ACK"] +// [] +TEST(Unsubscribe311QCTest, Encode18) { + uint8_t pkt[] = {0xa2, 0xd7, 0x1, 0x21, 0x8b, 0x0, 0x7, 0x5e, 0x9e, 0xb5, 0xc0, 0x4a, 0x1c, 0xf9, 0x0, 0x19, 0xf8, + 0xf3, 0x6, 0x0, 0x53, 0x67, 0x7d, 0x80, 0xb1, 0x9a, 0x32, 0x1a, 0x2d, 0xf2, 0x1d, 0xe5, 0x9, 0x15, + 0x1f, 0xbd, 0x6d, 0xe1, 0xe6, 0x49, 0x1c, 0x0, 0x6, 0x1a, 0xc2, 0xb3, 0x43, 0xcb, 0x98, 0x0, 0x15, + 0xf4, 0x23, 0x98, 0xaf, 0xc2, 0x99, 0xe7, 0xef, 0x17, 0x44, 0x92, 0x51, 0xf8, 0x67, 0xf6, 0x77, 0x8f, + 0x4b, 0xc2, 0xf5, 0xb5, 0x0, 0x1c, 0x14, 0x9, 0x49, 0x73, 0x9b, 0x6a, 0x70, 0xc5, 0x16, 0x27, 0x31, + 0x2c, 0x47, 0x28, 0x50, 0x15, 0x24, 0xa3, 0x90, 0x92, 0x9f, 0x1f, 0x59, 0xc2, 0x4d, 0x97, 0x9d, 0xff, + 0x0, 0x2, 0xec, 0x9f, 0x0, 0x1b, 0xe4, 0x84, 0x82, 0xfe, 0xd5, 0xad, 0x31, 0xca, 0x30, 0x88, 0x87, + 0xe7, 0x9d, 0xa7, 0x70, 0xc7, 0x7d, 0x8b, 0x3, 0x20, 0xbf, 0xbd, 0xa8, 0xf5, 0xe3, 0x12, 0x7d, 0x0, + 0xa, 0xe9, 0x6d, 0x63, 0x9b, 0x4b, 0x8, 0x21, 0x1e, 0x75, 0x1a, 0x0, 0x10, 0x74, 0xb2, 0x7f, 0x7f, + 0x79, 0xf0, 0xe0, 0xe4, 0x8d, 0xee, 0x4, 0x19, 0x99, 0x3b, 0xbe, 0xea, 0x0, 0x1e, 0x80, 0x78, 0x53, + 0xc7, 0xf0, 0xe4, 0x30, 0x52, 0xb, 0x52, 0xb4, 0x33, 0xd9, 0xb3, 0xa2, 0x48, 0xbd, 0x25, 0xc0, 0xf7, + 0xc3, 0x65, 0xb3, 0x74, 0x1e, 0x22, 0x78, 0x11, 0x6d, 0x79, 0x0, 0x13, 0xf6, 0x1b, 0xf8, 0x88, 0x3, + 0x3e, 0xe1, 0xcc, 0x6, 0x88, 0xaa, 0x22, 0xb, 0xe8, 0xfd, 0xdb, 0xc7, 0x3d, 0x6}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x8b, 0x78, 0x56, 0x8e, 0x45, 0x8b, 0x37, 0xb3, 0x54, 0x82, 0xd4, 0xfa, 0x47, 0xc3, - 0x46, 0xc1, 0xfc, 0xfa, 0xca, 0x7b, 0xc4, 0x7a, 0xe4, 0xa4, 0x2, 0x1f, 0xdb}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x5e, 0x9e, 0xb5, 0xc0, 0x4a, 0x1c, 0xf9}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf8, 0xf3, 0x6, 0x0, 0x53, 0x67, 0x7d, 0x80, 0xb1, 0x9a, 0x32, 0x1a, 0x2d, + 0xf2, 0x1d, 0xe5, 0x9, 0x15, 0x1f, 0xbd, 0x6d, 0xe1, 0xe6, 0x49, 0x1c}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1a, 0xc2, 0xb3, 0x43, 0xcb, 0x98}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf4, 0x23, 0x98, 0xaf, 0xc2, 0x99, 0xe7, 0xef, 0x17, 0x44, 0x92, + 0x51, 0xf8, 0x67, 0xf6, 0x77, 0x8f, 0x4b, 0xc2, 0xf5, 0xb5}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x14, 0x9, 0x49, 0x73, 0x9b, 0x6a, 0x70, 0xc5, 0x16, 0x27, + 0x31, 0x2c, 0x47, 0x28, 0x50, 0x15, 0x24, 0xa3, 0x90, 0x92, + 0x9f, 0x1f, 0x59, 0xc2, 0x4d, 0x97, 0x9d, 0xff}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xec, 0x9f}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xe4, 0x84, 0x82, 0xfe, 0xd5, 0xad, 0x31, 0xca, 0x30, 0x88, 0x87, 0xe7, 0x9d, 0xa7, + 0x70, 0xc7, 0x7d, 0x8b, 0x3, 0x20, 0xbf, 0xbd, 0xa8, 0xf5, 0xe3, 0x12, 0x7d}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe9, 0x6d, 0x63, 0x9b, 0x4b, 0x8, 0x21, 0x1e, 0x75, 0x1a}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x74, 0xb2, 0x7f, 0x7f, 0x79, 0xf0, 0xe0, 0xe4, + 0x8d, 0xee, 0x4, 0x19, 0x99, 0x3b, 0xbe, 0xea}; + lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x80, 0x78, 0x53, 0xc7, 0xf0, 0xe4, 0x30, 0x52, 0xb, 0x52, + 0xb4, 0x33, 0xd9, 0xb3, 0xa2, 0x48, 0xbd, 0x25, 0xc0, 0xf7, + 0xc3, 0x65, 0xb3, 0x74, 0x1e, 0x22, 0x78, 0x11, 0x6d, 0x79}; + lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xf6, 0x1b, 0xf8, 0x88, 0x3, 0x3e, 0xe1, 0xcc, 0x6, 0x88, + 0xaa, 0x22, 0xb, 0xe8, 0xfd, 0xdb, 0xc7, 0x3d, 0x6}; + lwmqtt_string_t topic_filter_s10 = {19, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 949, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8587, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5184 -// ["\160\156\&1\155\217\US\192\233A\170\&6f\208I","\ENQ\r\NAK\179\221\CAN\215\212\191\237F\250\ESC'\255a\132\132W>\231","\169\255\rPZLI'\SO\SYN\158\226\192\203\CAN[\136\168\185","\227Jq\248\&3\215\SYN=\200\169(\221\NAKe0>\147\156pZ\131e\165\ETB\252\152d\245\133\174","\192\144\SI\216f\194_\160\160'\US}\195VY\222\235\217\186%\198T]\247","\239Z\211\232","J\184i\172\147\218PR\190~\at/\158\152T\135\"\144\RS3\139","\167\176.\244x\254S\EOT!N\202z\154T\210\DC3G\DLE\130","\194","\165\208\135\190\165G"] +// UnsubscribeRequest 24034 +// ["\156\234\208\197\181\158\172S\218","\132\v\NAK\170\230\US\216+\217\DEL\213\156F","MTu\239]\128\EOT\f\SYN_\203\250\250\148\128\\\SO\ETBuv\137\211w\174+\NULUh_\232","\134\175\155\DC1\190\137R%\247H\202\207","\135\ETX\221t\137\178A\194\131\189V\254\204\246\175\143x\NAK\162[\135*\235[\EOT","Sq\209\151pP","\185\181~\EM\159\160\137\183\ETXQ\129u\174'O\210\177\GSi\201\217","Ch\167\252[{V1Q\223D\152$70\147\DC1\158-t7\250\152+\244\255\RS^j","\134\&4\166Q\210\FS\194\136\206qe\DLE]CG\FSEj\169\156\NUL\213\185>H\ETX&\SI\140"] // [] -TEST(Unsubscribe311QCTest, Encode14) { - uint8_t pkt[] = {0xa2, 0xb6, 0x1, 0x14, 0x40, 0x0, 0xe, 0xa0, 0x9c, 0x31, 0x9b, 0xd9, 0x1f, 0xc0, 0xe9, 0x41, 0xaa, - 0x36, 0x66, 0xd0, 0x49, 0x0, 0x15, 0x5, 0xd, 0x15, 0xb3, 0xdd, 0x18, 0xd7, 0xd4, 0xbf, 0xed, 0x46, - 0xfa, 0x1b, 0x27, 0xff, 0x61, 0x84, 0x84, 0x57, 0x3e, 0xe7, 0x0, 0x13, 0xa9, 0xff, 0xd, 0x50, 0x5a, - 0x4c, 0x49, 0x27, 0xe, 0x16, 0x9e, 0xe2, 0xc0, 0xcb, 0x18, 0x5b, 0x88, 0xa8, 0xb9, 0x0, 0x1e, 0xe3, - 0x4a, 0x71, 0xf8, 0x33, 0xd7, 0x16, 0x3d, 0xc8, 0xa9, 0x28, 0xdd, 0x15, 0x65, 0x30, 0x3e, 0x93, 0x9c, - 0x70, 0x5a, 0x83, 0x65, 0xa5, 0x17, 0xfc, 0x98, 0x64, 0xf5, 0x85, 0xae, 0x0, 0x18, 0xc0, 0x90, 0xf, - 0xd8, 0x66, 0xc2, 0x5f, 0xa0, 0xa0, 0x27, 0x1f, 0x7d, 0xc3, 0x56, 0x59, 0xde, 0xeb, 0xd9, 0xba, 0x25, - 0xc6, 0x54, 0x5d, 0xf7, 0x0, 0x4, 0xef, 0x5a, 0xd3, 0xe8, 0x0, 0x16, 0x4a, 0xb8, 0x69, 0xac, 0x93, - 0xda, 0x50, 0x52, 0xbe, 0x7e, 0x7, 0x74, 0x2f, 0x9e, 0x98, 0x54, 0x87, 0x22, 0x90, 0x1e, 0x33, 0x8b, - 0x0, 0x13, 0xa7, 0xb0, 0x2e, 0xf4, 0x78, 0xfe, 0x53, 0x4, 0x21, 0x4e, 0xca, 0x7a, 0x9a, 0x54, 0xd2, - 0x13, 0x47, 0x10, 0x82, 0x0, 0x1, 0xc2, 0x0, 0x6, 0xa5, 0xd0, 0x87, 0xbe, 0xa5, 0x47}; +TEST(Unsubscribe311QCTest, Encode19) { + uint8_t pkt[] = {0xa2, 0xc2, 0x1, 0x5d, 0xe2, 0x0, 0x9, 0x9c, 0xea, 0xd0, 0xc5, 0xb5, 0x9e, 0xac, 0x53, 0xda, 0x0, + 0xd, 0x84, 0xb, 0x15, 0xaa, 0xe6, 0x1f, 0xd8, 0x2b, 0xd9, 0x7f, 0xd5, 0x9c, 0x46, 0x0, 0x1e, 0x4d, + 0x54, 0x75, 0xef, 0x5d, 0x80, 0x4, 0xc, 0x16, 0x5f, 0xcb, 0xfa, 0xfa, 0x94, 0x80, 0x5c, 0xe, 0x17, + 0x75, 0x76, 0x89, 0xd3, 0x77, 0xae, 0x2b, 0x0, 0x55, 0x68, 0x5f, 0xe8, 0x0, 0xc, 0x86, 0xaf, 0x9b, + 0x11, 0xbe, 0x89, 0x52, 0x25, 0xf7, 0x48, 0xca, 0xcf, 0x0, 0x19, 0x87, 0x3, 0xdd, 0x74, 0x89, 0xb2, + 0x41, 0xc2, 0x83, 0xbd, 0x56, 0xfe, 0xcc, 0xf6, 0xaf, 0x8f, 0x78, 0x15, 0xa2, 0x5b, 0x87, 0x2a, 0xeb, + 0x5b, 0x4, 0x0, 0x6, 0x53, 0x71, 0xd1, 0x97, 0x70, 0x50, 0x0, 0x15, 0xb9, 0xb5, 0x7e, 0x19, 0x9f, + 0xa0, 0x89, 0xb7, 0x3, 0x51, 0x81, 0x75, 0xae, 0x27, 0x4f, 0xd2, 0xb1, 0x1d, 0x69, 0xc9, 0xd9, 0x0, + 0x1d, 0x43, 0x68, 0xa7, 0xfc, 0x5b, 0x7b, 0x56, 0x31, 0x51, 0xdf, 0x44, 0x98, 0x24, 0x37, 0x30, 0x93, + 0x11, 0x9e, 0x2d, 0x74, 0x37, 0xfa, 0x98, 0x2b, 0xf4, 0xff, 0x1e, 0x5e, 0x6a, 0x0, 0x1d, 0x86, 0x34, + 0xa6, 0x51, 0xd2, 0x1c, 0xc2, 0x88, 0xce, 0x71, 0x65, 0x10, 0x5d, 0x43, 0x47, 0x1c, 0x45, 0x6a, 0xa9, + 0x9c, 0x0, 0xd5, 0xb9, 0x3e, 0x48, 0x3, 0x26, 0xf, 0x8c}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xa0, 0x9c, 0x31, 0x9b, 0xd9, 0x1f, 0xc0, - 0xe9, 0x41, 0xaa, 0x36, 0x66, 0xd0, 0x49}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x9c, 0xea, 0xd0, 0xc5, 0xb5, 0x9e, 0xac, 0x53, 0xda}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5, 0xd, 0x15, 0xb3, 0xdd, 0x18, 0xd7, 0xd4, 0xbf, 0xed, 0x46, - 0xfa, 0x1b, 0x27, 0xff, 0x61, 0x84, 0x84, 0x57, 0x3e, 0xe7}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x84, 0xb, 0x15, 0xaa, 0xe6, 0x1f, 0xd8, 0x2b, 0xd9, 0x7f, 0xd5, 0x9c, 0x46}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa9, 0xff, 0xd, 0x50, 0x5a, 0x4c, 0x49, 0x27, 0xe, 0x16, - 0x9e, 0xe2, 0xc0, 0xcb, 0x18, 0x5b, 0x88, 0xa8, 0xb9}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4d, 0x54, 0x75, 0xef, 0x5d, 0x80, 0x4, 0xc, 0x16, 0x5f, + 0xcb, 0xfa, 0xfa, 0x94, 0x80, 0x5c, 0xe, 0x17, 0x75, 0x76, + 0x89, 0xd3, 0x77, 0xae, 0x2b, 0x0, 0x55, 0x68, 0x5f, 0xe8}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe3, 0x4a, 0x71, 0xf8, 0x33, 0xd7, 0x16, 0x3d, 0xc8, 0xa9, - 0x28, 0xdd, 0x15, 0x65, 0x30, 0x3e, 0x93, 0x9c, 0x70, 0x5a, - 0x83, 0x65, 0xa5, 0x17, 0xfc, 0x98, 0x64, 0xf5, 0x85, 0xae}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x86, 0xaf, 0x9b, 0x11, 0xbe, 0x89, 0x52, 0x25, 0xf7, 0x48, 0xca, 0xcf}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc0, 0x90, 0xf, 0xd8, 0x66, 0xc2, 0x5f, 0xa0, 0xa0, 0x27, 0x1f, 0x7d, - 0xc3, 0x56, 0x59, 0xde, 0xeb, 0xd9, 0xba, 0x25, 0xc6, 0x54, 0x5d, 0xf7}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x87, 0x3, 0xdd, 0x74, 0x89, 0xb2, 0x41, 0xc2, 0x83, 0xbd, 0x56, 0xfe, 0xcc, + 0xf6, 0xaf, 0x8f, 0x78, 0x15, 0xa2, 0x5b, 0x87, 0x2a, 0xeb, 0x5b, 0x4}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xef, 0x5a, 0xd3, 0xe8}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x53, 0x71, 0xd1, 0x97, 0x70, 0x50}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4a, 0xb8, 0x69, 0xac, 0x93, 0xda, 0x50, 0x52, 0xbe, 0x7e, 0x7, - 0x74, 0x2f, 0x9e, 0x98, 0x54, 0x87, 0x22, 0x90, 0x1e, 0x33, 0x8b}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb9, 0xb5, 0x7e, 0x19, 0x9f, 0xa0, 0x89, 0xb7, 0x3, 0x51, 0x81, + 0x75, 0xae, 0x27, 0x4f, 0xd2, 0xb1, 0x1d, 0x69, 0xc9, 0xd9}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa7, 0xb0, 0x2e, 0xf4, 0x78, 0xfe, 0x53, 0x4, 0x21, 0x4e, - 0xca, 0x7a, 0x9a, 0x54, 0xd2, 0x13, 0x47, 0x10, 0x82}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x43, 0x68, 0xa7, 0xfc, 0x5b, 0x7b, 0x56, 0x31, 0x51, 0xdf, + 0x44, 0x98, 0x24, 0x37, 0x30, 0x93, 0x11, 0x9e, 0x2d, 0x74, + 0x37, 0xfa, 0x98, 0x2b, 0xf4, 0xff, 0x1e, 0x5e, 0x6a}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc2}; - lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x86, 0x34, 0xa6, 0x51, 0xd2, 0x1c, 0xc2, 0x88, 0xce, 0x71, + 0x65, 0x10, 0x5d, 0x43, 0x47, 0x1c, 0x45, 0x6a, 0xa9, 0x9c, + 0x0, 0xd5, 0xb9, 0x3e, 0x48, 0x3, 0x26, 0xf, 0x8c}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa5, 0xd0, 0x87, 0xbe, 0xa5, 0x47}; - lwmqtt_string_t topic_filter_s9 = {6, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5184, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24034, 9, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 21743 -// ["g\SUB\173Z5\135\245\NUL\138\243\130\165\170M\184/O\ETX\214$\241\DC3\147\&8WZ'","\243\253\202\167\210\ACK\253w\239\248\128\US\184\153\242E\242\132\219nOk\250\242qR","\"","U\138\193\246\162T_\SUB\206\&4","\154\&0Tav\255\213\&1\DC2Y","\252=\144O\"ETDc\221\130\228E_4a\DC2\253fn\209\187\138#3","F9\a\224\133\201\252\255\151\253\220\EOT\NUL\ETB3m\140o\135\215lSi\140\155\240\&2\SOH\211\128"] +// UnsubscribeRequest 5686 +// ["","\v}7\181\SI\131\156\ETX\158\RS<\237t\205^\236\158\139>","\179\158\242","","}>\\@\236\138X@Bu=P>J\STX\STXF&,?\129'\213\195\189","\\W=A\231m\181\237v\154\160","\254\234\210\&3`B\"/\175\253\131\244@\176]\211\159\163\160$\246"] // [] -TEST(Unsubscribe311QCTest, Encode15) { - uint8_t pkt[] = {0xa2, 0x91, 0x1, 0x54, 0xef, 0x0, 0x1b, 0x67, 0x1a, 0xad, 0x5a, 0x35, 0x87, 0xf5, 0x0, 0x8a, 0xf3, - 0x82, 0xa5, 0xaa, 0x4d, 0xb8, 0x2f, 0x4f, 0x3, 0xd6, 0x24, 0xf1, 0x13, 0x93, 0x38, 0x57, 0x5a, 0x27, - 0x0, 0x1a, 0xf3, 0xfd, 0xca, 0xa7, 0xd2, 0x6, 0xfd, 0x77, 0xef, 0xf8, 0x80, 0x1f, 0xb8, 0x99, 0xf2, - 0x45, 0xf2, 0x84, 0xdb, 0x6e, 0x4f, 0x6b, 0xfa, 0xf2, 0x71, 0x52, 0x0, 0x1, 0x22, 0x0, 0xa, 0x55, - 0x8a, 0xc1, 0xf6, 0xa2, 0x54, 0x5f, 0x1a, 0xce, 0x34, 0x0, 0xa, 0x9a, 0x30, 0x54, 0x61, 0x76, 0xff, - 0xd5, 0x31, 0x12, 0x59, 0x0, 0x19, 0xfc, 0x3d, 0x90, 0x4f, 0x22, 0x45, 0x54, 0x44, 0x63, 0xdd, 0x82, - 0xe4, 0x45, 0x5f, 0x34, 0x61, 0x12, 0xfd, 0x66, 0x6e, 0xd1, 0xbb, 0x8a, 0x23, 0x33, 0x0, 0x1e, 0x46, - 0x39, 0x7, 0xe0, 0x85, 0xc9, 0xfc, 0xff, 0x97, 0xfd, 0xdc, 0x4, 0x0, 0x17, 0x33, 0x6d, 0x8c, 0x6f, - 0x87, 0xd7, 0x6c, 0x53, 0x69, 0x8c, 0x9b, 0xf0, 0x32, 0x1, 0xd3, 0x80}; +TEST(Unsubscribe311QCTest, Encode20) { + uint8_t pkt[] = {0xa2, 0x5f, 0x16, 0x36, 0x0, 0x0, 0x0, 0x13, 0xb, 0x7d, 0x37, 0xb5, 0xf, 0x83, 0x9c, 0x3, 0x9e, + 0x1e, 0x3c, 0xed, 0x74, 0xcd, 0x5e, 0xec, 0x9e, 0x8b, 0x3e, 0x0, 0x3, 0xb3, 0x9e, 0xf2, 0x0, 0x0, + 0x0, 0x19, 0x7d, 0x3e, 0x5c, 0x40, 0xec, 0x8a, 0x58, 0x40, 0x42, 0x75, 0x3d, 0x50, 0x3e, 0x4a, 0x2, + 0x2, 0x46, 0x26, 0x2c, 0x3f, 0x81, 0x27, 0xd5, 0xc3, 0xbd, 0x0, 0xb, 0x5c, 0x57, 0x3d, 0x41, 0xe7, + 0x6d, 0xb5, 0xed, 0x76, 0x9a, 0xa0, 0x0, 0x15, 0xfe, 0xea, 0xd2, 0x33, 0x60, 0x42, 0x22, 0x2f, 0xaf, + 0xfd, 0x83, 0xf4, 0x40, 0xb0, 0x5d, 0xd3, 0x9f, 0xa3, 0xa0, 0x24, 0xf6}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x67, 0x1a, 0xad, 0x5a, 0x35, 0x87, 0xf5, 0x0, 0x8a, 0xf3, 0x82, 0xa5, 0xaa, 0x4d, - 0xb8, 0x2f, 0x4f, 0x3, 0xd6, 0x24, 0xf1, 0x13, 0x93, 0x38, 0x57, 0x5a, 0x27}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf3, 0xfd, 0xca, 0xa7, 0xd2, 0x6, 0xfd, 0x77, 0xef, 0xf8, 0x80, 0x1f, 0xb8, - 0x99, 0xf2, 0x45, 0xf2, 0x84, 0xdb, 0x6e, 0x4f, 0x6b, 0xfa, 0xf2, 0x71, 0x52}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb, 0x7d, 0x37, 0xb5, 0xf, 0x83, 0x9c, 0x3, 0x9e, 0x1e, + 0x3c, 0xed, 0x74, 0xcd, 0x5e, 0xec, 0x9e, 0x8b, 0x3e}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x22}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb3, 0x9e, 0xf2}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x55, 0x8a, 0xc1, 0xf6, 0xa2, 0x54, 0x5f, 0x1a, 0xce, 0x34}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9a, 0x30, 0x54, 0x61, 0x76, 0xff, 0xd5, 0x31, 0x12, 0x59}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x7d, 0x3e, 0x5c, 0x40, 0xec, 0x8a, 0x58, 0x40, 0x42, 0x75, 0x3d, 0x50, 0x3e, + 0x4a, 0x2, 0x2, 0x46, 0x26, 0x2c, 0x3f, 0x81, 0x27, 0xd5, 0xc3, 0xbd}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfc, 0x3d, 0x90, 0x4f, 0x22, 0x45, 0x54, 0x44, 0x63, 0xdd, 0x82, 0xe4, 0x45, - 0x5f, 0x34, 0x61, 0x12, 0xfd, 0x66, 0x6e, 0xd1, 0xbb, 0x8a, 0x23, 0x33}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x5c, 0x57, 0x3d, 0x41, 0xe7, 0x6d, 0xb5, 0xed, 0x76, 0x9a, 0xa0}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x46, 0x39, 0x7, 0xe0, 0x85, 0xc9, 0xfc, 0xff, 0x97, 0xfd, - 0xdc, 0x4, 0x0, 0x17, 0x33, 0x6d, 0x8c, 0x6f, 0x87, 0xd7, - 0x6c, 0x53, 0x69, 0x8c, 0x9b, 0xf0, 0x32, 0x1, 0xd3, 0x80}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xfe, 0xea, 0xd2, 0x33, 0x60, 0x42, 0x22, 0x2f, 0xaf, 0xfd, 0x83, + 0xf4, 0x40, 0xb0, 0x5d, 0xd3, 0x9f, 0xa3, 0xa0, 0x24, 0xf6}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21743, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5686, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 11426 ["\138\251 -// \SOH\190x\170(\EOT(\NUL\229\US\232\ETX\tH","\212\252_\137\222\158gd\rm\194;&w\RS\242\199\DLE\ETB\253\145\151","xD\194\160"] +// UnsubscribeRequest 24245 +// ["\187-s\231\141\DELJq\246","\NAK]%\227\253\FST\142?\253C;\SOH\191\250\223T\RS\DC2\247B\191\193\222\196I\129","\196\132\&8J\197\&8\163\133\229"] // [] -TEST(Unsubscribe311QCTest, Encode16) { - uint8_t pkt[] = {0xa2, 0x33, 0x2c, 0xa2, 0x0, 0x11, 0x8a, 0xfb, 0x20, 0x1, 0xbe, 0x78, 0xaa, 0x28, - 0x4, 0x28, 0x0, 0xe5, 0x1f, 0xe8, 0x3, 0x9, 0x48, 0x0, 0x16, 0xd4, 0xfc, 0x5f, - 0x89, 0xde, 0x9e, 0x67, 0x64, 0xd, 0x6d, 0xc2, 0x3b, 0x26, 0x77, 0x1e, 0xf2, 0xc7, - 0x10, 0x17, 0xfd, 0x91, 0x97, 0x0, 0x4, 0x78, 0x44, 0xc2, 0xa0}; +TEST(Unsubscribe311QCTest, Encode21) { + uint8_t pkt[] = {0xa2, 0x35, 0x5e, 0xb5, 0x0, 0x9, 0xbb, 0x2d, 0x73, 0xe7, 0x8d, 0x7f, 0x4a, 0x71, + 0xf6, 0x0, 0x1b, 0x15, 0x5d, 0x25, 0xe3, 0xfd, 0x1c, 0x54, 0x8e, 0x3f, 0xfd, 0x43, + 0x3b, 0x1, 0xbf, 0xfa, 0xdf, 0x54, 0x1e, 0x12, 0xf7, 0x42, 0xbf, 0xc1, 0xde, 0xc4, + 0x49, 0x81, 0x0, 0x9, 0xc4, 0x84, 0x38, 0x4a, 0xc5, 0x38, 0xa3, 0x85, 0xe5}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x8a, 0xfb, 0x20, 0x1, 0xbe, 0x78, 0xaa, 0x28, 0x4, - 0x28, 0x0, 0xe5, 0x1f, 0xe8, 0x3, 0x9, 0x48}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xbb, 0x2d, 0x73, 0xe7, 0x8d, 0x7f, 0x4a, 0x71, 0xf6}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd4, 0xfc, 0x5f, 0x89, 0xde, 0x9e, 0x67, 0x64, 0xd, 0x6d, 0xc2, - 0x3b, 0x26, 0x77, 0x1e, 0xf2, 0xc7, 0x10, 0x17, 0xfd, 0x91, 0x97}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x15, 0x5d, 0x25, 0xe3, 0xfd, 0x1c, 0x54, 0x8e, 0x3f, 0xfd, 0x43, 0x3b, 0x1, 0xbf, + 0xfa, 0xdf, 0x54, 0x1e, 0x12, 0xf7, 0x42, 0xbf, 0xc1, 0xde, 0xc4, 0x49, 0x81}; + lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x78, 0x44, 0xc2, 0xa0}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc4, 0x84, 0x38, 0x4a, 0xc5, 0x38, 0xa3, 0x85, 0xe5}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11426, 3, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24245, 3, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5841 ["yh\251\169","\178\SI\146G\210\133v\153\f\143T\188\187c\SI\227\n\n\NAK*fTRl\205M\224c!"," -// \161\vU\242\SYN:\224","\182o_\213\131\253HkX>\245{\190qc\163\162EH\NUL\a\ENQh","`\198\220\GSG6\209Q\236\251;","\139Hp\135\199d\160+"] +// UnsubscribeRequest 25032 ["\SYN;\174\NAK\140_\188\"[\SOH3z~7\194\136\&7\218\&2\SYN<\156w","V\219\229e\199 +// ","W\238\187\GS\SUB\132\133w\251\149h\178\201\DC3\204\209\201\SYN","}=\204\166\208\175.\200\192\SYNb\177","!\174\SO\173\137~:\238\166u\EOT\165\184r4\185l\201\128\190\&0f\156","\149:.\217?\"ev=\v;\158\129d\244\ACKxH{\DC4\245","J"] // [] -TEST(Unsubscribe311QCTest, Encode17) { - uint8_t pkt[] = {0xa2, 0x61, 0x16, 0xd1, 0x0, 0x4, 0x79, 0x68, 0xfb, 0xa9, 0x0, 0x1d, 0xb2, 0xf, 0x92, 0x47, 0xd2, - 0x85, 0x76, 0x99, 0xc, 0x8f, 0x54, 0xbc, 0xbb, 0x63, 0xf, 0xe3, 0xa, 0xa, 0x15, 0x2a, 0x66, 0x54, - 0x52, 0x6c, 0xcd, 0x4d, 0xe0, 0x63, 0x21, 0x0, 0x8, 0x20, 0xa1, 0xb, 0x55, 0xf2, 0x16, 0x3a, 0xe0, - 0x0, 0x17, 0xb6, 0x6f, 0x5f, 0xd5, 0x83, 0xfd, 0x48, 0x6b, 0x58, 0x3e, 0xf5, 0x7b, 0xbe, 0x71, 0x63, - 0xa3, 0xa2, 0x45, 0x48, 0x0, 0x7, 0x5, 0x68, 0x0, 0xb, 0x60, 0xc6, 0xdc, 0x1d, 0x47, 0x36, 0xd1, - 0x51, 0xec, 0xfb, 0x3b, 0x0, 0x8, 0x8b, 0x48, 0x70, 0x87, 0xc7, 0x64, 0xa0, 0x2b}; +TEST(Unsubscribe311QCTest, Encode22) { + uint8_t pkt[] = {0xa2, 0x78, 0x61, 0xc8, 0x0, 0x17, 0x16, 0x3b, 0xae, 0x15, 0x8c, 0x5f, 0xbc, 0x22, 0x5b, 0x1, + 0x33, 0x7a, 0x7e, 0x37, 0xc2, 0x88, 0x37, 0xda, 0x32, 0x16, 0x3c, 0x9c, 0x77, 0x0, 0x6, 0x56, + 0xdb, 0xe5, 0x65, 0xc7, 0x20, 0x0, 0x12, 0x57, 0xee, 0xbb, 0x1d, 0x1a, 0x84, 0x85, 0x77, 0xfb, + 0x95, 0x68, 0xb2, 0xc9, 0x13, 0xcc, 0xd1, 0xc9, 0x16, 0x0, 0xc, 0x7d, 0x3d, 0xcc, 0xa6, 0xd0, + 0xaf, 0x2e, 0xc8, 0xc0, 0x16, 0x62, 0xb1, 0x0, 0x17, 0x21, 0xae, 0xe, 0xad, 0x89, 0x7e, 0x3a, + 0xee, 0xa6, 0x75, 0x4, 0xa5, 0xb8, 0x72, 0x34, 0xb9, 0x6c, 0xc9, 0x80, 0xbe, 0x30, 0x66, 0x9c, + 0x0, 0x15, 0x95, 0x3a, 0x2e, 0xd9, 0x3f, 0x22, 0x65, 0x76, 0x3d, 0xb, 0x3b, 0x9e, 0x81, 0x64, + 0xf4, 0x6, 0x78, 0x48, 0x7b, 0x14, 0xf5, 0x0, 0x1, 0x4a}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x79, 0x68, 0xfb, 0xa9}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x16, 0x3b, 0xae, 0x15, 0x8c, 0x5f, 0xbc, 0x22, 0x5b, 0x1, 0x33, 0x7a, + 0x7e, 0x37, 0xc2, 0x88, 0x37, 0xda, 0x32, 0x16, 0x3c, 0x9c, 0x77}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb2, 0xf, 0x92, 0x47, 0xd2, 0x85, 0x76, 0x99, 0xc, 0x8f, - 0x54, 0xbc, 0xbb, 0x63, 0xf, 0xe3, 0xa, 0xa, 0x15, 0x2a, - 0x66, 0x54, 0x52, 0x6c, 0xcd, 0x4d, 0xe0, 0x63, 0x21}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x56, 0xdb, 0xe5, 0x65, 0xc7, 0x20}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x20, 0xa1, 0xb, 0x55, 0xf2, 0x16, 0x3a, 0xe0}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x57, 0xee, 0xbb, 0x1d, 0x1a, 0x84, 0x85, 0x77, 0xfb, + 0x95, 0x68, 0xb2, 0xc9, 0x13, 0xcc, 0xd1, 0xc9, 0x16}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb6, 0x6f, 0x5f, 0xd5, 0x83, 0xfd, 0x48, 0x6b, 0x58, 0x3e, 0xf5, 0x7b, - 0xbe, 0x71, 0x63, 0xa3, 0xa2, 0x45, 0x48, 0x0, 0x7, 0x5, 0x68}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x7d, 0x3d, 0xcc, 0xa6, 0xd0, 0xaf, 0x2e, 0xc8, 0xc0, 0x16, 0x62, 0xb1}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x60, 0xc6, 0xdc, 0x1d, 0x47, 0x36, 0xd1, 0x51, 0xec, 0xfb, 0x3b}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x21, 0xae, 0xe, 0xad, 0x89, 0x7e, 0x3a, 0xee, 0xa6, 0x75, 0x4, 0xa5, + 0xb8, 0x72, 0x34, 0xb9, 0x6c, 0xc9, 0x80, 0xbe, 0x30, 0x66, 0x9c}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8b, 0x48, 0x70, 0x87, 0xc7, 0x64, 0xa0, 0x2b}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x95, 0x3a, 0x2e, 0xd9, 0x3f, 0x22, 0x65, 0x76, 0x3d, 0xb, 0x3b, + 0x9e, 0x81, 0x64, 0xf4, 0x6, 0x78, 0x48, 0x7b, 0x14, 0xf5}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x4a}; + lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5841, 6, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25032, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 26803 -// ["h\b\248\219\SI\197\167\148#\226\147\153}","f\166\188I8\138","o\166\FS\210\138\156\166\234\SUB:%\155N\154\226\132\233E"] -// [] -TEST(Unsubscribe311QCTest, Encode18) { - uint8_t pkt[] = {0xa2, 0x2d, 0x68, 0xb3, 0x0, 0xd, 0x68, 0x8, 0xf8, 0xdb, 0xf, 0xc5, 0xa7, 0x94, 0x23, 0xe2, - 0x93, 0x99, 0x7d, 0x0, 0x6, 0x66, 0xa6, 0xbc, 0x49, 0x38, 0x8a, 0x0, 0x12, 0x6f, 0xa6, 0x1c, - 0xd2, 0x8a, 0x9c, 0xa6, 0xea, 0x1a, 0x3a, 0x25, 0x9b, 0x4e, 0x9a, 0xe2, 0x84, 0xe9, 0x45}; +// UnsubscribeRequest 9981 ["\234","\236\168cp","~","\224\178\190\NAK\250][\147CG\225f\248\DC3\243\"\t\""] [] +TEST(Unsubscribe311QCTest, Encode23) { + uint8_t pkt[] = {0xa2, 0x22, 0x26, 0xfd, 0x0, 0x1, 0xea, 0x0, 0x4, 0xec, 0xa8, 0x63, + 0x70, 0x0, 0x1, 0x7e, 0x0, 0x12, 0xe0, 0xb2, 0xbe, 0x15, 0xfa, 0x5d, + 0x5b, 0x93, 0x43, 0x47, 0xe1, 0x66, 0xf8, 0x13, 0xf3, 0x22, 0x9, 0x22}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x68, 0x8, 0xf8, 0xdb, 0xf, 0xc5, 0xa7, 0x94, 0x23, 0xe2, 0x93, 0x99, 0x7d}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xea}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x66, 0xa6, 0xbc, 0x49, 0x38, 0x8a}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xec, 0xa8, 0x63, 0x70}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6f, 0xa6, 0x1c, 0xd2, 0x8a, 0x9c, 0xa6, 0xea, 0x1a, - 0x3a, 0x25, 0x9b, 0x4e, 0x9a, 0xe2, 0x84, 0xe9, 0x45}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7e}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe0, 0xb2, 0xbe, 0x15, 0xfa, 0x5d, 0x5b, 0x93, 0x43, + 0x47, 0xe1, 0x66, 0xf8, 0x13, 0xf3, 0x22, 0x9, 0x22}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26803, 3, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9981, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22595 ["","r3\FS\a(<\131w\CAN\204\229"] [] -TEST(Unsubscribe311QCTest, Encode19) { - uint8_t pkt[] = {0xa2, 0x11, 0x58, 0x43, 0x0, 0x0, 0x0, 0xb, 0x72, 0x33, - 0x1c, 0x7, 0x28, 0x3c, 0x83, 0x77, 0x18, 0xcc, 0xe5}; +// UnsubscribeRequest 12131 [";\204\192\156\203","\131\141H4\GSjh\223\t{hE[\134\CAN\142"] [] +TEST(Unsubscribe311QCTest, Encode24) { + uint8_t pkt[] = {0xa2, 0x1b, 0x2f, 0x63, 0x0, 0x5, 0x3b, 0xcc, 0xc0, 0x9c, 0xcb, 0x0, 0x10, 0x83, 0x8d, + 0x48, 0x34, 0x1d, 0x6a, 0x68, 0xdf, 0x9, 0x7b, 0x68, 0x45, 0x5b, 0x86, 0x18, 0x8e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x3b, 0xcc, 0xc0, 0x9c, 0xcb}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x72, 0x33, 0x1c, 0x7, 0x28, 0x3c, 0x83, 0x77, 0x18, 0xcc, 0xe5}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x83, 0x8d, 0x48, 0x34, 0x1d, 0x6a, 0x68, 0xdf, + 0x9, 0x7b, 0x68, 0x45, 0x5b, 0x86, 0x18, 0x8e}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22595, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12131, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 907 -// ["\141\FS\ETX\162\204'\133\DLE7\237\140\\w>\252:\aS\161s\SI\179:\248\150E","*,\176\143\254R\241\242\DLE\173a.\225\151\159I:\161","\\X$\251\237\251W\215P\a\133A\163\145\225D\SYN^\163\bf\237\174\STX\141\230\189w\161\162","\217\182-\169\169\173\191Hx@\206Qi\188\231\210D\165\NUL\165\ENQ\220\232\224\226>"] +// UnsubscribeRequest 2785 +// ["\208\203\198\224\198v\210\132\218\207\b","\DC4g\193CEY\226\133{\205;","\129E\167\RSx\161\SI\218\ENQ\196\149\136\243\170j\166\208\132m\DEL","lI\225V\SYN&\228E\191\236\171\EM\199eL\DLE-\191\155\223\&5\193\b","\154\ENQp\158 +// dj\212\228\243\245\179\ESC\140\SI\ACK\193\215\a\FSR\DLE","\236\152b\183\203\239\189:A\241\200\CAN\207\221i","\198By$\ACK","\147\f\237\210\b\144w}\129d","\176\231\145U\138\241\252\185\178\238\136oQ\ENQ\187\168\228\197","*\210\FS\252"] // [] -TEST(Unsubscribe311QCTest, Encode20) { - uint8_t pkt[] = {0xa2, 0x6e, 0x3, 0x8b, 0x0, 0x1a, 0x8d, 0x1c, 0x3, 0xa2, 0xcc, 0x27, 0x85, 0x10, 0x37, 0xed, - 0x8c, 0x5c, 0x77, 0x3e, 0xfc, 0x3a, 0x7, 0x53, 0xa1, 0x73, 0xf, 0xb3, 0x3a, 0xf8, 0x96, 0x45, - 0x0, 0x12, 0x2a, 0x2c, 0xb0, 0x8f, 0xfe, 0x52, 0xf1, 0xf2, 0x10, 0xad, 0x61, 0x2e, 0xe1, 0x97, - 0x9f, 0x49, 0x3a, 0xa1, 0x0, 0x1e, 0x5c, 0x58, 0x24, 0xfb, 0xed, 0xfb, 0x57, 0xd7, 0x50, 0x7, - 0x85, 0x41, 0xa3, 0x91, 0xe1, 0x44, 0x16, 0x5e, 0xa3, 0x8, 0x66, 0xed, 0xae, 0x2, 0x8d, 0xe6, - 0xbd, 0x77, 0xa1, 0xa2, 0x0, 0x1a, 0xd9, 0xb6, 0x2d, 0xa9, 0xa9, 0xad, 0xbf, 0x48, 0x78, 0x40, - 0xce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0xfc}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x8d, 0x1c, 0x3, 0xa2, 0xcc, 0x27, 0x85, 0x10, 0x37, 0xed, 0x8c, 0x5c, 0x77, - 0x3e, 0xfc, 0x3a, 0x7, 0x53, 0xa1, 0x73, 0xf, 0xb3, 0x3a, 0xf8, 0x96, 0x45}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd0, 0xcb, 0xc6, 0xe0, 0xc6, 0x76, 0xd2, 0x84, 0xda, 0xcf, 0x8}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2a, 0x2c, 0xb0, 0x8f, 0xfe, 0x52, 0xf1, 0xf2, 0x10, - 0xad, 0x61, 0x2e, 0xe1, 0x97, 0x9f, 0x49, 0x3a, 0xa1}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x14, 0x67, 0xc1, 0x43, 0x45, 0x59, 0xe2, 0x85, 0x7b, 0xcd, 0x3b}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5c, 0x58, 0x24, 0xfb, 0xed, 0xfb, 0x57, 0xd7, 0x50, 0x7, - 0x85, 0x41, 0xa3, 0x91, 0xe1, 0x44, 0x16, 0x5e, 0xa3, 0x8, - 0x66, 0xed, 0xae, 0x2, 0x8d, 0xe6, 0xbd, 0x77, 0xa1, 0xa2}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x81, 0x45, 0xa7, 0x1e, 0x78, 0xa1, 0xf, 0xda, 0x5, 0xc4, + 0x95, 0x88, 0xf3, 0xaa, 0x6a, 0xa6, 0xd0, 0x84, 0x6d, 0x7f}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd9, 0xb6, 0x2d, 0xa9, 0xa9, 0xad, 0xbf, 0x48, 0x78, 0x40, 0xce, 0x51, 0x69, - 0xbc, 0xe7, 0xd2, 0x44, 0xa5, 0x0, 0xa5, 0x5, 0xdc, 0xe8, 0xe0, 0xe2, 0x3e}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6c, 0x49, 0xe1, 0x56, 0x16, 0x26, 0xe4, 0x45, 0xbf, 0xec, 0xab, 0x19, + 0xc7, 0x65, 0x4c, 0x10, 0x2d, 0xbf, 0x9b, 0xdf, 0x35, 0xc1, 0x8}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9a, 0x5, 0x70, 0x9e, 0x20, 0x64, 0x6a, 0xd4, 0xe4, 0xf3, 0xf5, + 0xb3, 0x1b, 0x8c, 0xf, 0x6, 0xc1, 0xd7, 0x7, 0x1c, 0x52, 0x10}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xec, 0x98, 0x62, 0xb7, 0xcb, 0xef, 0xbd, 0x3a, + 0x41, 0xf1, 0xc8, 0x18, 0xcf, 0xdd, 0x69}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc6, 0x42, 0x79, 0x24, 0x6}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x93, 0xc, 0xed, 0xd2, 0x8, 0x90, 0x77, 0x7d, 0x81, 0x64}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xb0, 0xe7, 0x91, 0x55, 0x8a, 0xf1, 0xfc, 0xb9, 0xb2, + 0xee, 0x88, 0x6f, 0x51, 0x5, 0xbb, 0xa8, 0xe4, 0xc5}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x2a, 0xd2, 0x1c, 0xfc}; + lwmqtt_string_t topic_filter_s9 = {4, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 907, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2785, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24572 -// ["\209r2\129\173f\255\143\237!\188m\134\&4#\167\156\211[@D\181\SO\161\210\n\235\&4","\133\164\149\&5\205\251\223","Bf.\183r\147H\252","/\130V\141\130\200\131\248\b\162Eb\DC2\EM\202r\182\251\FSKJ\186"] +// UnsubscribeRequest 3283 +// ["\151","\140k\206\231T4\165\221\&7\206\161\&9\DC2z9\GS\146\232`AuR/&\215\192\226\253","\243?\170\SYNAk\239?W\173","\143l\157\212\165\140<-\"\250\185\166\SOHpBD\213\&5Y3\178\150\186\n\187\194%","\r\250\DLE'?\210\182\153\215\198\173\206k\201Vo\185\236\229\229","\176\171\220\205\STX>\227\CAN\239\167OEZ0s\170\DC2\165B\132r\134?\170L\216\246\162\"\136","\208^\167Dh\248\177\171~k\f\134U8 +// \216\198\252\130\US\DEL*Mq)\186","\164[\150\159l\245a\169W]\ENQ=D\230\143\235\193\215\183:\217\244\EOT\236\CAN\221)\210","\191X\198\252\128?S\147\r>O\b\SUB\215L\222\239\201\157dEh\236\DC2\214'\186\243\\\161"] // [] -TEST(Unsubscribe311QCTest, Encode21) { - uint8_t pkt[] = {0xa2, 0x4b, 0x5f, 0xfc, 0x0, 0x1c, 0xd1, 0x72, 0x32, 0x81, 0xad, 0x66, 0xff, 0x8f, 0xed, 0x21, - 0xbc, 0x6d, 0x86, 0x34, 0x23, 0xa7, 0x9c, 0xd3, 0x5b, 0x40, 0x44, 0xb5, 0xe, 0xa1, 0xd2, 0xa, - 0xeb, 0x34, 0x0, 0x7, 0x85, 0xa4, 0x95, 0x35, 0xcd, 0xfb, 0xdf, 0x0, 0x8, 0x42, 0x66, 0x2e, - 0xb7, 0x72, 0x93, 0x48, 0xfc, 0x0, 0x16, 0x2f, 0x82, 0x56, 0x8d, 0x82, 0xc8, 0x83, 0xf8, 0x8, - 0xa2, 0x45, 0x62, 0x12, 0x19, 0xca, 0x72, 0xb6, 0xfb, 0x1c, 0x4b, 0x4a, 0xba}; +TEST(Unsubscribe311QCTest, Encode26) { + uint8_t pkt[] = { + 0xa2, 0x80, 0x2, 0xc, 0xd3, 0x0, 0x1, 0x97, 0x0, 0x1c, 0x8c, 0x6b, 0xce, 0xe7, 0x54, 0x34, 0xa5, 0xdd, 0x37, + 0xce, 0xa1, 0x39, 0x12, 0x7a, 0x39, 0x1d, 0x92, 0xe8, 0x60, 0x41, 0x75, 0x52, 0x2f, 0x26, 0xd7, 0xc0, 0xe2, 0xfd, + 0x0, 0xa, 0xf3, 0x3f, 0xaa, 0x16, 0x41, 0x6b, 0xef, 0x3f, 0x57, 0xad, 0x0, 0x1b, 0x8f, 0x6c, 0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0xd, 0x3e, 0x4f, 0x8, 0x1a, 0xd7, 0x4c, 0xde, 0xef, 0xc9, + 0x9d, 0x64, 0x45, 0x68, 0xec, 0x12, 0xd6, 0x27, 0xba, 0xf3, 0x5c, 0xa1}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xd1, 0x72, 0x32, 0x81, 0xad, 0x66, 0xff, 0x8f, 0xed, 0x21, - 0xbc, 0x6d, 0x86, 0x34, 0x23, 0xa7, 0x9c, 0xd3, 0x5b, 0x40, - 0x44, 0xb5, 0xe, 0xa1, 0xd2, 0xa, 0xeb, 0x34}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x97}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x85, 0xa4, 0x95, 0x35, 0xcd, 0xfb, 0xdf}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x8c, 0x6b, 0xce, 0xe7, 0x54, 0x34, 0xa5, 0xdd, 0x37, 0xce, + 0xa1, 0x39, 0x12, 0x7a, 0x39, 0x1d, 0x92, 0xe8, 0x60, 0x41, + 0x75, 0x52, 0x2f, 0x26, 0xd7, 0xc0, 0xe2, 0xfd}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x42, 0x66, 0x2e, 0xb7, 0x72, 0x93, 0x48, 0xfc}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf3, 0x3f, 0xaa, 0x16, 0x41, 0x6b, 0xef, 0x3f, 0x57, 0xad}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2f, 0x82, 0x56, 0x8d, 0x82, 0xc8, 0x83, 0xf8, 0x8, 0xa2, 0x45, - 0x62, 0x12, 0x19, 0xca, 0x72, 0xb6, 0xfb, 0x1c, 0x4b, 0x4a, 0xba}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x8f, 0x6c, 0x9d, 0xd4, 0xa5, 0x8c, 0x3c, 0x2d, 0x22, 0xfa, 0xb9, 0xa6, 0x1, 0x70, + 0x42, 0x44, 0xd5, 0x35, 0x59, 0x33, 0xb2, 0x96, 0xba, 0xa, 0xbb, 0xc2, 0x25}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd, 0xfa, 0x10, 0x3c, 0x67, 0x95, 0xe0, 0x9f, 0x9f, 0x98, + 0xd3, 0x69, 0x87, 0xa3, 0x8e, 0x26, 0xa5, 0xdb, 0x19, 0x3a, + 0xf, 0x10, 0x36, 0x5b, 0xbb, 0x71, 0x21, 0x24}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x3, 0x53, 0xfb, 0x81, 0x85, 0x2c, 0xb7, 0xba, 0x3e, 0x27, 0x3f, 0xd2, 0xb6, + 0x99, 0xd7, 0xc6, 0xad, 0xce, 0x6b, 0xc9, 0x56, 0x6f, 0xb9, 0xec, 0xe5, 0xe5}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xb0, 0xab, 0xdc, 0xcd, 0x2, 0x3e, 0xe3, 0x18, 0xef, 0xa7, + 0x4f, 0x45, 0x5a, 0x30, 0x73, 0xaa, 0x12, 0xa5, 0x42, 0x84, + 0x72, 0x86, 0x3f, 0xaa, 0x4c, 0xd8, 0xf6, 0xa2, 0x22, 0x88}; + lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xd0, 0x5e, 0xa7, 0x44, 0x68, 0xf8, 0xb1, 0xab, 0x7e, 0x6b, 0xc, 0x86, 0x55, + 0x38, 0x20, 0xd8, 0xc6, 0xfc, 0x82, 0x1f, 0x7f, 0x2a, 0x4d, 0x71, 0x29, 0xba}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa4, 0x5b, 0x96, 0x9f, 0x6c, 0xf5, 0x61, 0xa9, 0x57, 0x5d, + 0x5, 0x3d, 0x44, 0xe6, 0x8f, 0xeb, 0xc1, 0xd7, 0xb7, 0x3a, + 0xd9, 0xf4, 0x4, 0xec, 0x18, 0xdd, 0x29, 0xd2}; + lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xbf, 0x58, 0xc6, 0xfc, 0x80, 0x3f, 0x53, 0x93, 0xd, 0x3e, + 0x4f, 0x8, 0x1a, 0xd7, 0x4c, 0xde, 0xef, 0xc9, 0x9d, 0x64, + 0x45, 0x68, 0xec, 0x12, 0xd6, 0x27, 0xba, 0xf3, 0x5c, 0xa1}; + lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24572, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3283, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22215 -// ["tkb\217BA\193-\r\243\141\144\131?#\SO\181p\150,\n\DEL)!","`\148\&8\EOT\EM\209\DLEI\193\218\148\180?\184X`,","\177V]\a8>\139\248\US\158\&4Pz\232|\147S\229\149\145\150\170\185\240'","\242M!M\182ds\247I\DEL\233\&0X),\206\155\200\232\182","s\SOH\149\210\176E\148\180\164\142\v\225gk\198\168\139/\161\240\249T\155)\140*","\165\EM\192\148-\241\213\188\182w\155\ESC*\NUL\RS*)\177h","\244\148-\DC3A\174,d\225\215d\170x"] -// [] -TEST(Unsubscribe311QCTest, Encode22) { - uint8_t pkt[] = {0xa2, 0xa0, 0x1, 0x56, 0xc7, 0x0, 0x18, 0x74, 0x6b, 0x62, 0xd9, 0x42, 0x41, 0xc1, 0x2d, 0xd, 0xf3, - 0x8d, 0x90, 0x83, 0x3f, 0x23, 0xe, 0xb5, 0x70, 0x96, 0x2c, 0xa, 0x7f, 0x29, 0x21, 0x0, 0x11, 0x60, - 0x94, 0x38, 0x4, 0x19, 0xd1, 0x10, 0x49, 0xc1, 0xda, 0x94, 0xb4, 0x3f, 0xb8, 0x58, 0x60, 0x2c, 0x0, - 0x19, 0xb1, 0x56, 0x5d, 0x7, 0x38, 0x3e, 0x8b, 0xf8, 0x1f, 0x9e, 0x34, 0x50, 0x7a, 0xe8, 0x7c, 0x93, - 0x53, 0xe5, 0x95, 0x91, 0x96, 0xaa, 0xb9, 0xf0, 0x27, 0x0, 0x14, 0xf2, 0x4d, 0x21, 0x4d, 0xb6, 0x64, - 0x73, 0xf7, 0x49, 0x7f, 0xe9, 0x30, 0x58, 0x29, 0x2c, 0xce, 0x9b, 0xc8, 0xe8, 0xb6, 0x0, 0x1a, 0x73, - 0x1, 0x95, 0xd2, 0xb0, 0x45, 0x94, 0xb4, 0xa4, 0x8e, 0xb, 0xe1, 0x67, 0x6b, 0xc6, 0xa8, 0x8b, 0x2f, - 0xa1, 0xf0, 0xf9, 0x54, 0x9b, 0x29, 0x8c, 0x2a, 0x0, 0x13, 0xa5, 0x19, 0xc0, 0x94, 0x2d, 0xf1, 0xd5, - 0xbc, 0xb6, 0x77, 0x9b, 0x1b, 0x2a, 0x0, 0x1e, 0x2a, 0x29, 0xb1, 0x68, 0x0, 0xd, 0xf4, 0x94, 0x2d, - 0x13, 0x41, 0xae, 0x2c, 0x64, 0xe1, 0xd7, 0x64, 0xaa, 0x78}; +// UnsubscribeRequest 22892 +// ["\235\157\254\138\f\159\160H\226\159\167\206[L\221\133p\185;","/\162\192\a\217\171[\233\178\227GTN~\SOHzIl\DC3G\195C(FH\241=He\251","n\212\225g\136\SYNK\222\238\207\137","","\ETB7!\RSO\252\EM4B\253\DEL\USs}\246e\192\201\135\DC1\174","\183~\216m","\174K\216\SUB\179 +// \EMB\EMpq\EMl"] [] +TEST(Unsubscribe311QCTest, Encode27) { + uint8_t pkt[] = {0xa2, 0x72, 0x59, 0x6c, 0x0, 0x13, 0xeb, 0x9d, 0xfe, 0x8a, 0xc, 0x9f, 0xa0, 0x48, 0xe2, 0x9f, 0xa7, + 0xce, 0x5b, 0x4c, 0xdd, 0x85, 0x70, 0xb9, 0x3b, 0x0, 0x1e, 0x2f, 0xa2, 0xc0, 0x7, 0xd9, 0xab, 0x5b, + 0xe9, 0xb2, 0xe3, 0x47, 0x54, 0x4e, 0x7e, 0x1, 0x7a, 0x49, 0x6c, 0x13, 0x47, 0xc3, 0x43, 0x28, 0x46, + 0x48, 0xf1, 0x3d, 0x48, 0x65, 0xfb, 0x0, 0xb, 0x6e, 0xd4, 0xe1, 0x67, 0x88, 0x16, 0x4b, 0xde, 0xee, + 0xcf, 0x89, 0x0, 0x0, 0x0, 0x15, 0x17, 0x37, 0x21, 0x1e, 0x4f, 0xfc, 0x19, 0x34, 0x42, 0xfd, 0x7f, + 0x1f, 0x73, 0x7d, 0xf6, 0x65, 0xc0, 0xc9, 0x87, 0x11, 0xae, 0x0, 0x4, 0xb7, 0x7e, 0xd8, 0x6d, 0x0, + 0xd, 0xae, 0x4b, 0xd8, 0x1a, 0xb3, 0x20, 0x19, 0x42, 0x19, 0x70, 0x71, 0x19, 0x6c}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x74, 0x6b, 0x62, 0xd9, 0x42, 0x41, 0xc1, 0x2d, 0xd, 0xf3, 0x8d, 0x90, - 0x83, 0x3f, 0x23, 0xe, 0xb5, 0x70, 0x96, 0x2c, 0xa, 0x7f, 0x29, 0x21}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xeb, 0x9d, 0xfe, 0x8a, 0xc, 0x9f, 0xa0, 0x48, 0xe2, 0x9f, + 0xa7, 0xce, 0x5b, 0x4c, 0xdd, 0x85, 0x70, 0xb9, 0x3b}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x60, 0x94, 0x38, 0x4, 0x19, 0xd1, 0x10, 0x49, 0xc1, - 0xda, 0x94, 0xb4, 0x3f, 0xb8, 0x58, 0x60, 0x2c}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2f, 0xa2, 0xc0, 0x7, 0xd9, 0xab, 0x5b, 0xe9, 0xb2, 0xe3, + 0x47, 0x54, 0x4e, 0x7e, 0x1, 0x7a, 0x49, 0x6c, 0x13, 0x47, + 0xc3, 0x43, 0x28, 0x46, 0x48, 0xf1, 0x3d, 0x48, 0x65, 0xfb}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb1, 0x56, 0x5d, 0x7, 0x38, 0x3e, 0x8b, 0xf8, 0x1f, 0x9e, 0x34, 0x50, 0x7a, - 0xe8, 0x7c, 0x93, 0x53, 0xe5, 0x95, 0x91, 0x96, 0xaa, 0xb9, 0xf0, 0x27}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6e, 0xd4, 0xe1, 0x67, 0x88, 0x16, 0x4b, 0xde, 0xee, 0xcf, 0x89}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf2, 0x4d, 0x21, 0x4d, 0xb6, 0x64, 0x73, 0xf7, 0x49, 0x7f, - 0xe9, 0x30, 0x58, 0x29, 0x2c, 0xce, 0x9b, 0xc8, 0xe8, 0xb6}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x73, 0x1, 0x95, 0xd2, 0xb0, 0x45, 0x94, 0xb4, 0xa4, 0x8e, 0xb, 0xe1, 0x67, - 0x6b, 0xc6, 0xa8, 0x8b, 0x2f, 0xa1, 0xf0, 0xf9, 0x54, 0x9b, 0x29, 0x8c, 0x2a}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x17, 0x37, 0x21, 0x1e, 0x4f, 0xfc, 0x19, 0x34, 0x42, 0xfd, 0x7f, + 0x1f, 0x73, 0x7d, 0xf6, 0x65, 0xc0, 0xc9, 0x87, 0x11, 0xae}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa5, 0x19, 0xc0, 0x94, 0x2d, 0xf1, 0xd5, 0xbc, 0xb6, 0x77, - 0x9b, 0x1b, 0x2a, 0x0, 0x1e, 0x2a, 0x29, 0xb1, 0x68}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xb7, 0x7e, 0xd8, 0x6d}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf4, 0x94, 0x2d, 0x13, 0x41, 0xae, 0x2c, 0x64, 0xe1, 0xd7, 0x64, 0xaa, 0x78}; + uint8_t topic_filter_s6_bytes[] = {0xae, 0x4b, 0xd8, 0x1a, 0xb3, 0x20, 0x19, 0x42, 0x19, 0x70, 0x71, 0x19, 0x6c}; lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22215, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22892, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 6585 -// ["\230\183q\150\255f\RS\133,\EM\151s\DC4","\160\239\214T\CANS\255\134\169\182\167ri\233\201","B\149Ms7\DC2\234x\185t\233\239\247\EOT\150\\\225\NUL\DC4\SO$\tP\190\DC3","\231\130\&50\142?\232\228\STX\183\182\159h\211\140\218N\ESC\ENQL\161=\158\251\166","\218\230\&2\130\163\DLE","\130q\162\EOT:\240\"\206`\134|\162","l\185N\132\177\203*","SB\DC1\\\186\191\167iq\187\204\a\NAK\137\214u\155\n"] +// UnsubscribeRequest 19885 +// ["1PI\t\197=\237\156\210+\211\143\197F\237j\226K\DC1\ETB\231\195\ACK\162\148\247_\252\173","\t)\128a\GS\181\NUL\197\183{\205;m\230\199\US|l\166i\215'\180\129\184\186","\246D|d\241G\232+$\163\NAKm","\165","\r\189\ACK\138&\129\225V\220\215X\ESC\DLE<\192\150s\207","U\214xL\223\215.ob5\166\173wr\209\&1\167\&9\rJ\145\DC4\255","\DC3\215c\169\153\250\207@\186\242\r\"\183\129Q\RS\ETBbEj\160","L-\181*\192\&1}"] // [] -TEST(Unsubscribe311QCTest, Encode23) { - uint8_t pkt[] = {0xa2, 0x8b, 0x1, 0x19, 0xb9, 0x0, 0xd, 0xe6, 0xb7, 0x71, 0x96, 0xff, 0x66, 0x1e, 0x85, 0x2c, - 0x19, 0x97, 0x73, 0x14, 0x0, 0xf, 0xa0, 0xef, 0xd6, 0x54, 0x18, 0x53, 0xff, 0x86, 0xa9, 0xb6, - 0xa7, 0x72, 0x69, 0xe9, 0xc9, 0x0, 0x19, 0x42, 0x95, 0x4d, 0x73, 0x37, 0x12, 0xea, 0x78, 0xb9, - 0x74, 0xe9, 0xef, 0xf7, 0x4, 0x96, 0x5c, 0xe1, 0x0, 0x14, 0xe, 0x24, 0x9, 0x50, 0xbe, 0x13, - 0x0, 0x19, 0xe7, 0x82, 0x35, 0x30, 0x8e, 0x3f, 0xe8, 0xe4, 0x2, 0xb7, 0xb6, 0x9f, 0x68, 0xd3, - 0x8c, 0xda, 0x4e, 0x1b, 0x5, 0x4c, 0xa1, 0x3d, 0x9e, 0xfb, 0xa6, 0x0, 0x6, 0xda, 0xe6, 0x32, - 0x82, 0xa3, 0x10, 0x0, 0xc, 0x82, 0x71, 0xa2, 0x4, 0x3a, 0xf0, 0x22, 0xce, 0x60, 0x86, 0x7c, - 0xa2, 0x0, 0x7, 0x6c, 0xb9, 0x4e, 0x84, 0xb1, 0x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0x31, 0x7d}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xe6, 0xb7, 0x71, 0x96, 0xff, 0x66, 0x1e, 0x85, 0x2c, 0x19, 0x97, 0x73, 0x14}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x31, 0x50, 0x49, 0x9, 0xc5, 0x3d, 0xed, 0x9c, 0xd2, 0x2b, + 0xd3, 0x8f, 0xc5, 0x46, 0xed, 0x6a, 0xe2, 0x4b, 0x11, 0x17, + 0xe7, 0xc3, 0x6, 0xa2, 0x94, 0xf7, 0x5f, 0xfc, 0xad}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa0, 0xef, 0xd6, 0x54, 0x18, 0x53, 0xff, 0x86, - 0xa9, 0xb6, 0xa7, 0x72, 0x69, 0xe9, 0xc9}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9, 0x29, 0x80, 0x61, 0x1d, 0xb5, 0x0, 0xc5, 0xb7, 0x7b, 0xcd, 0x3b, 0x6d, + 0xe6, 0xc7, 0x1f, 0x7c, 0x6c, 0xa6, 0x69, 0xd7, 0x27, 0xb4, 0x81, 0xb8, 0xba}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x42, 0x95, 0x4d, 0x73, 0x37, 0x12, 0xea, 0x78, 0xb9, 0x74, 0xe9, 0xef, 0xf7, - 0x4, 0x96, 0x5c, 0xe1, 0x0, 0x14, 0xe, 0x24, 0x9, 0x50, 0xbe, 0x13}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf6, 0x44, 0x7c, 0x64, 0xf1, 0x47, 0xe8, 0x2b, 0x24, 0xa3, 0x15, 0x6d}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe7, 0x82, 0x35, 0x30, 0x8e, 0x3f, 0xe8, 0xe4, 0x2, 0xb7, 0xb6, 0x9f, 0x68, - 0xd3, 0x8c, 0xda, 0x4e, 0x1b, 0x5, 0x4c, 0xa1, 0x3d, 0x9e, 0xfb, 0xa6}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa5}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xda, 0xe6, 0x32, 0x82, 0xa3, 0x10}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd, 0xbd, 0x6, 0x8a, 0x26, 0x81, 0xe1, 0x56, 0xdc, + 0xd7, 0x58, 0x1b, 0x10, 0x3c, 0xc0, 0x96, 0x73, 0xcf}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x82, 0x71, 0xa2, 0x4, 0x3a, 0xf0, 0x22, 0xce, 0x60, 0x86, 0x7c, 0xa2}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x55, 0xd6, 0x78, 0x4c, 0xdf, 0xd7, 0x2e, 0x6f, 0x62, 0x35, 0xa6, 0xad, + 0x77, 0x72, 0xd1, 0x31, 0xa7, 0x39, 0xd, 0x4a, 0x91, 0x14, 0xff}; + lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6c, 0xb9, 0x4e, 0x84, 0xb1, 0xcb, 0x2a}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x13, 0xd7, 0x63, 0xa9, 0x99, 0xfa, 0xcf, 0x40, 0xba, 0xf2, 0xd, + 0x22, 0xb7, 0x81, 0x51, 0x1e, 0x17, 0x62, 0x45, 0x6a, 0xa0}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x53, 0x42, 0x11, 0x5c, 0xba, 0xbf, 0xa7, 0x69, 0x71, - 0xbb, 0xcc, 0x7, 0x15, 0x89, 0xd6, 0x75, 0x9b, 0xa}; - lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x4c, 0x2d, 0xb5, 0x2a, 0xc0, 0x31, 0x7d}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6585, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19885, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22838 -// ["@w%\186\210\164\154\ACKl\193]J?uN\fM\186","\206\247\DEL\254\199\EM\205\216\151KC\ETX\219\180etQ\135\188\195\197_\249\b","m\CAN\222\175|\164\198\ETBF","\186\147\228\156\151$\239K@\USJ\248\193`z\220\222\224M[\182","\154\n$qM4\nL\ETXb\ETX\241","K\154?\178\227p\162\200R\194\196","+\245t\230#}Ja\SOH\214x\220)\ESC\138\t\134\215J\222\131$dD\222","\169\191\191\193[\224tV&\218rG\196\SYNQ\224n\157\&7\215\165\207\153+\a\234\235","(\185\142\190\225\&7\FSf\147Obz\203\136||\198\&5\DC1\239\161\202","_>\198mEZ\153\&1\149\250r\146zt\ESC\239g\176\148\197\210\NUL\231-\212\138"] +// UnsubscribeRequest 27189 +// ["\150\235'\154\141\134|\222\223]bA\223\139E\175+\178\158\176FT\218\DC4","\128\213\212b\169;\241\208\"!\167","\162\SO\SYN\164P(\US\SIR{\147\253k\235G\169;ZQ\NULH\DC3\DELP\SOH\222","F\229\157\217\ACK\155\rz\245\&8/\173G5\177\244S-8\150\198\194\&3\222)\209\STX","\191\143\241\237\222\157\191\187\142M}\207LC|\146","8\ENQ\229\241|Z^","*g\f\244dM\235\193*\177\&9\149\133\161","\168/\EOT\222\a^z\187\139\135","\167\206\130\&1\168\ETBH\200\241\221C\235\134Z9J\193\215v\237\131\197"] // [] -TEST(Unsubscribe311QCTest, Encode24) { - uint8_t pkt[] = {0xa2, 0xd9, 0x1, 0x59, 0x36, 0x0, 0x12, 0x40, 0x77, 0x25, 0xba, 0xd2, 0xa4, 0x9a, 0x6, 0x6c, 0xc1, - 0x5d, 0x4a, 0x3f, 0x75, 0x4e, 0xc, 0x4d, 0xba, 0x0, 0x18, 0xce, 0xf7, 0x7f, 0xfe, 0xc7, 0x19, 0xcd, - 0xd8, 0x97, 0x4b, 0x43, 0x3, 0xdb, 0xb4, 0x65, 0x74, 0x51, 0x87, 0xbc, 0xc3, 0xc5, 0x5f, 0xf9, 0x8, - 0x0, 0x9, 0x6d, 0x18, 0xde, 0xaf, 0x7c, 0xa4, 0xc6, 0x17, 0x46, 0x0, 0x15, 0xba, 0x93, 0xe4, 0x9c, - 0x97, 0x24, 0xef, 0x4b, 0x40, 0x1f, 0x4a, 0xf8, 0xc1, 0x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, 0xd4, 0x62, 0xa9, 0x3b, 0xf1, 0xd0, 0x22, 0x21, 0xa7, 0x0, 0x1a, 0xa2, 0xe, 0x16, 0xa4, 0x50, + 0x28, 0x1f, 0xf, 0x52, 0x7b, 0x93, 0xfd, 0x6b, 0xeb, 0x47, 0xa9, 0x3b, 0x5a, 0x51, 0x0, 0x48, 0x13, + 0x7f, 0x50, 0x1, 0xde, 0x0, 0x1b, 0x46, 0xe5, 0x9d, 0xd9, 0x6, 0x9b, 0xd, 0x7a, 0xf5, 0x38, 0x2f, + 0xad, 0x47, 0x35, 0xb1, 0xf4, 0x53, 0x2d, 0x38, 0x96, 0xc6, 0xc2, 0x33, 0xde, 0x29, 0xd1, 0x2, 0x0, + 0x10, 0xbf, 0x8f, 0xf1, 0xed, 0xde, 0x9d, 0xbf, 0xbb, 0x8e, 0x4d, 0x7d, 0xcf, 0x4c, 0x43, 0x7c, 0x92, + 0x0, 0x7, 0x38, 0x5, 0xe5, 0xf1, 0x7c, 0x5a, 0x5e, 0x0, 0xe, 0x2a, 0x67, 0xc, 0xf4, 0x64, 0x4d, + 0xeb, 0xc1, 0x2a, 0xb1, 0x39, 0x95, 0x85, 0xa1, 0x0, 0xa, 0xa8, 0x2f, 0x4, 0xde, 0x7, 0x5e, 0x7a, + 0xbb, 0x8b, 0x87, 0x0, 0x16, 0xa7, 0xce, 0x82, 0x31, 0xa8, 0x17, 0x48, 0xc8, 0xf1, 0xdd, 0x43, 0xeb, + 0x86, 0x5a, 0x39, 0x4a, 0xc1, 0xd7, 0x76, 0xed, 0x83, 0xc5}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x40, 0x77, 0x25, 0xba, 0xd2, 0xa4, 0x9a, 0x6, 0x6c, - 0xc1, 0x5d, 0x4a, 0x3f, 0x75, 0x4e, 0xc, 0x4d, 0xba}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x96, 0xeb, 0x27, 0x9a, 0x8d, 0x86, 0x7c, 0xde, 0xdf, 0x5d, 0x62, 0x41, + 0xdf, 0x8b, 0x45, 0xaf, 0x2b, 0xb2, 0x9e, 0xb0, 0x46, 0x54, 0xda, 0x14}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xce, 0xf7, 0x7f, 0xfe, 0xc7, 0x19, 0xcd, 0xd8, 0x97, 0x4b, 0x43, 0x3, - 0xdb, 0xb4, 0x65, 0x74, 0x51, 0x87, 0xbc, 0xc3, 0xc5, 0x5f, 0xf9, 0x8}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x80, 0xd5, 0xd4, 0x62, 0xa9, 0x3b, 0xf1, 0xd0, 0x22, 0x21, 0xa7}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6d, 0x18, 0xde, 0xaf, 0x7c, 0xa4, 0xc6, 0x17, 0x46}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa2, 0xe, 0x16, 0xa4, 0x50, 0x28, 0x1f, 0xf, 0x52, 0x7b, 0x93, 0xfd, 0x6b, + 0xeb, 0x47, 0xa9, 0x3b, 0x5a, 0x51, 0x0, 0x48, 0x13, 0x7f, 0x50, 0x1, 0xde}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xba, 0x93, 0xe4, 0x9c, 0x97, 0x24, 0xef, 0x4b, 0x40, 0x1f, 0x4a, - 0xf8, 0xc1, 0x60, 0x7a, 0xdc, 0xde, 0xe0, 0x4d, 0x5b, 0xb6}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x46, 0xe5, 0x9d, 0xd9, 0x6, 0x9b, 0xd, 0x7a, 0xf5, 0x38, 0x2f, 0xad, 0x47, 0x35, + 0xb1, 0xf4, 0x53, 0x2d, 0x38, 0x96, 0xc6, 0xc2, 0x33, 0xde, 0x29, 0xd1, 0x2}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9a, 0xa, 0x24, 0x71, 0x4d, 0x34, 0xa, 0x4c, 0x3, 0x62, 0x3, 0xf1}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xbf, 0x8f, 0xf1, 0xed, 0xde, 0x9d, 0xbf, 0xbb, + 0x8e, 0x4d, 0x7d, 0xcf, 0x4c, 0x43, 0x7c, 0x92}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4b, 0x9a, 0x3f, 0xb2, 0xe3, 0x70, 0xa2, 0xc8, 0x52, 0xc2, 0xc4}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x38, 0x5, 0xe5, 0xf1, 0x7c, 0x5a, 0x5e}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x2b, 0xf5, 0x74, 0xe6, 0x23, 0x7d, 0x4a, 0x61, 0x1, 0xd6, 0x78, 0xdc, 0x29, - 0x1b, 0x8a, 0x9, 0x86, 0xd7, 0x4a, 0xde, 0x83, 0x24, 0x64, 0x44, 0xde}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x2a, 0x67, 0xc, 0xf4, 0x64, 0x4d, 0xeb, 0xc1, 0x2a, 0xb1, 0x39, 0x95, 0x85, 0xa1}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa9, 0xbf, 0xbf, 0xc1, 0x5b, 0xe0, 0x74, 0x56, 0x26, 0xda, 0x72, 0x47, 0xc4, 0x16, - 0x51, 0xe0, 0x6e, 0x9d, 0x37, 0xd7, 0xa5, 0xcf, 0x99, 0x2b, 0x7, 0xea, 0xeb}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xa8, 0x2f, 0x4, 0xde, 0x7, 0x5e, 0x7a, 0xbb, 0x8b, 0x87}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x28, 0xb9, 0x8e, 0xbe, 0xe1, 0x37, 0x1c, 0x66, 0x93, 0x4f, 0x62, - 0x7a, 0xcb, 0x88, 0x7c, 0x7c, 0xc6, 0x35, 0x11, 0xef, 0xa1, 0xca}; + uint8_t topic_filter_s8_bytes[] = {0xa7, 0xce, 0x82, 0x31, 0xa8, 0x17, 0x48, 0xc8, 0xf1, 0xdd, 0x43, + 0xeb, 0x86, 0x5a, 0x39, 0x4a, 0xc1, 0xd7, 0x76, 0xed, 0x83, 0xc5}; lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x5f, 0x3e, 0xc6, 0x6d, 0x45, 0x5a, 0x99, 0x31, 0x95, 0xfa, 0x72, 0x92, 0x7a, - 0x74, 0x1b, 0xef, 0x67, 0xb0, 0x94, 0xc5, 0xd2, 0x0, 0xe7, 0x2d, 0xd4, 0x8a}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22838, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27189, 9, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 14034 ["1\217\143\SOH~W~\ETX -// \191\NUL\173|\218L\CAN\229\ESC\249\241\169\130","T\140qo","\128k\172\167\180\235\144\222\r\129\254?,\152\187+\228\178F\194\225","\244\CAN\230/\246X\247\&1,\208\222\235(\219%\246\172\225\254\191\189|\218'\253","\ENQ\133\178\EOT\241\135\222\201\220\164\&3\179\157\222T\189\253","\ETB\DC4\159\210\ETB0\218\213;\180\EM\227\244Lr\245\EOTn\NULh","\173.N\n~\219o\214\205\167\190\139\196\185\246\174\&3\STX\215\235\135a","\172g\bAu\187r\au-\DC4!!Vw -// |x","\211\&6\175\180c\153\187s\NUL\v\140Em\215\144\244\&3|\246\ESC&\239tD\243\239","]\US\226A\165\\|\206U6\249d\144\241On-\153"] +// UnsubscribeRequest 10641 +// ["\195Sa\217\ACK\194\232\166\EOT\a\175\198\164\196r\252M\129\227\142\140","\191\&2\206V\211\208jL\223\162M\237i\241\128\DC1R\160UJ\195\175\194R\213","\213?\174\187\RS\DEL\245 +// \199\246\204","6\147z\129\248e\186\239\143\190\200\231\233\244\170(\225[\f\254\202\159-VJ\255Pp!","H\191\171\135\157){d~\181\190","\FSe\146\150\222","\DLE\228\196{\157hG\135~RV^\EOT5","\243\212\198\a\157\193\174\231\196\129N\182\137\243w"] +// [PropServerKeepAlive 13535,PropAuthenticationData "<\192\"U\244<+b\244a\231\234\231\130\\",PropContentType +// "\r\DC1\r=\224\191z/\185\144\133mB\208SC\CAN\196\r",PropSessionExpiryInterval 4234,PropSubscriptionIdentifier +// 31,PropServerKeepAlive 3176,PropMaximumQoS 31,PropResponseTopic +// "\249\GSFA\DLE\173)O\176\129\250\FS\152\196\230oF\227\224\143\164\150",PropTopicAliasMaximum +// 28456,PropResponseInformation +// "<\CAN\176\225\190\209\226\247!\254\218\EM\aVxr\139K\239b\191\147>\198\242",PropAuthenticationData +// "_I*\240\161\192\b\200\216by\191!\133z\222\DC3",PropAssignedClientIdentifier +// "\242\230\SO\142\DEL75(:x0}A\182",PropContentType "[\as$\141\171\166\204\162\176",PropCorrelationData +// "\EOTZ\EOT\151I",PropServerReference "1\EM\248",PropMessageExpiryInterval 32586,PropAuthenticationData +// "xN)\150$\231\157\177R1\171\184\138\216\223\212\134v\251\132",PropMessageExpiryInterval 1627,PropMaximumPacketSize +// 17000,PropAuthenticationMethod "j\199\131\140\249\228\198u\tG)\NUL\187i\176\172^\160\157\185\STX\STX\183\205\155"] +TEST(Unsubscribe5QCTest, Encode1) { + uint8_t pkt[] = { + 0xa2, 0x8f, 0x3, 0x52, 0xd, 0xf1, 0x1, 0x13, 0x34, 0xdf, 0x16, 0x0, 0xf, 0x3c, 0xc0, 0x22, 0x55, 0xf4, 0x3c, + 0x2b, 0x62, 0xf4, 0x61, 0xe7, 0xea, 0xe7, 0x82, 0x5c, 0x3, 0x0, 0x13, 0xd, 0x11, 0xd, 0x3d, 0xe0, 0xbf, 0x7a, + 0x2f, 0xb9, 0x90, 0x85, 0x6d, 0x42, 0xd0, 0x53, 0x43, 0x18, 0xc4, 0xd, 0x11, 0x0, 0x0, 0x10, 0x8a, 0xb, 0x1f, + 0x13, 0xc, 0x68, 0x24, 0x1f, 0x8, 0x0, 0x16, 0xf9, 0x1d, 0x46, 0x41, 0x10, 0xad, 0x29, 0x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0xd5, 0xaf, 0x51, 0xa3, 0x7, 0xf0, 0xc2, 0xd3, + 0x93, 0x31, 0xc4, 0xfb, 0x1f, 0x8e, 0x9f, 0x3e, 0x81, 0xe3, 0x8e, 0x8c, 0x0, 0x19, 0xbf, 0x32, 0xce, 0x56, 0xd3, + 0xd0, 0x6a, 0x4c, 0xdf, 0xa2, 0x4d, 0xed, 0x69, 0xf1, 0x80, 0x11, 0x52, 0xa0, 0x55, 0x4a, 0xc3, 0xaf, 0xc2, 0x52, + 0xd5, 0x0, 0xb, 0xd5, 0x3f, 0xae, 0xbb, 0x1e, 0x7f, 0xf5, 0x20, 0xc7, 0xf6, 0xcc, 0x0, 0x1d, 0x36, 0x93, 0x7a, + 0x81, 0xf8, 0x65, 0xba, 0xef, 0x8f, 0xbe, 0xc8, 0xe7, 0xe9, 0xf4, 0xaa, 0x28, 0xe1, 0x5b, 0xc, 0xfe, 0xca, 0x9f, + 0x2d, 0x56, 0x4a, 0xff, 0x50, 0x70, 0x21, 0x0, 0xb, 0x48, 0xbf, 0xab, 0x87, 0x9d, 0x29, 0x7b, 0x64, 0x7e, 0xb5, + 0xbe, 0x0, 0x5, 0x1c, 0x65, 0x92, 0x96, 0xde, 0x0, 0xe, 0x10, 0xe4, 0xc4, 0x7b, 0x9d, 0x68, 0x47, 0x87, 0x7e, + 0x52, 0x56, 0x5e, 0x4, 0x35, 0x0, 0xf, 0xf3, 0xd4, 0xc6, 0x7, 0x9d, 0xc1, 0xae, 0xe7, 0xc4, 0x81, 0x4e, 0xb6, + 0x89, 0xf3, 0x77}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x3c, 0xc0, 0x22, 0x55, 0xf4, 0x3c, 0x2b, 0x62, 0xf4, 0x61, 0xe7, 0xea, 0xe7, 0x82, 0x5c}; + uint8_t bytesprops1[] = {0xd, 0x11, 0xd, 0x3d, 0xe0, 0xbf, 0x7a, 0x2f, 0xb9, 0x90, + 0x85, 0x6d, 0x42, 0xd0, 0x53, 0x43, 0x18, 0xc4, 0xd}; + uint8_t bytesprops2[] = {0xf9, 0x1d, 0x46, 0x41, 0x10, 0xad, 0x29, 0x4f, 0xb0, 0x81, 0xfa, + 0x1c, 0x98, 0xc4, 0xe6, 0x6f, 0x46, 0xe3, 0xe0, 0x8f, 0xa4, 0x96}; + uint8_t bytesprops3[] = {0x3c, 0x18, 0xb0, 0xe1, 0xbe, 0xd1, 0xe2, 0xf7, 0x21, 0xfe, 0xda, 0x19, 0x7, + 0x56, 0x78, 0x72, 0x8b, 0x4b, 0xef, 0x62, 0xbf, 0x93, 0x3e, 0xc6, 0xf2}; + uint8_t bytesprops4[] = {0x5f, 0x49, 0x2a, 0xf0, 0xa1, 0xc0, 0x8, 0xc8, 0xd8, + 0x62, 0x79, 0xbf, 0x21, 0x85, 0x7a, 0xde, 0x13}; + uint8_t bytesprops5[] = {0xf2, 0xe6, 0xe, 0x8e, 0x7f, 0x37, 0x35, 0x28, 0x3a, 0x78, 0x30, 0x7d, 0x41, 0xb6}; + uint8_t bytesprops6[] = {0x5b, 0x7, 0x73, 0x24, 0x8d, 0xab, 0xa6, 0xcc, 0xa2, 0xb0}; + uint8_t bytesprops7[] = {0x4, 0x5a, 0x4, 0x97, 0x49}; + uint8_t bytesprops8[] = {0x31, 0x19, 0xf8}; + uint8_t bytesprops9[] = {0x78, 0x4e, 0x29, 0x96, 0x24, 0xe7, 0x9d, 0xb1, 0x52, 0x31, + 0xab, 0xb8, 0x8a, 0xd8, 0xdf, 0xd4, 0x86, 0x76, 0xfb, 0x84}; + uint8_t bytesprops10[] = {0x6a, 0xc7, 0x83, 0x8c, 0xf9, 0xe4, 0xc6, 0x75, 0x9, 0x47, 0x29, 0x0, 0xbb, + 0x69, 0xb0, 0xac, 0x5e, 0xa0, 0x9d, 0xb9, 0x2, 0x2, 0xb7, 0xcd, 0x9b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13535}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4234}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 31}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3176}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28456}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32586}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1627}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17000}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops10}}}, + }; + + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xa2, 0x55, 0xe5, 0x51, 0xcb, 0x3a, 0x97, 0xd4, 0xd5, 0xaf, + 0x51, 0xa3, 0x7, 0xf0, 0xc2, 0xd3, 0x93, 0x31, 0xc4, 0xfb, + 0x1f, 0x8e, 0x9f, 0x3e, 0x81, 0xe3, 0x8e, 0x8c}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xbf, 0x32, 0xce, 0x56, 0xd3, 0xd0, 0x6a, 0x4c, 0xdf, 0xa2, 0x4d, 0xed, 0x69, + 0xf1, 0x80, 0x11, 0x52, 0xa0, 0x55, 0x4a, 0xc3, 0xaf, 0xc2, 0x52, 0xd5}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xd5, 0x3f, 0xae, 0xbb, 0x1e, 0x7f, 0xf5, 0x20, 0xc7, 0xf6, 0xcc}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x36, 0x93, 0x7a, 0x81, 0xf8, 0x65, 0xba, 0xef, 0x8f, 0xbe, + 0xc8, 0xe7, 0xe9, 0xf4, 0xaa, 0x28, 0xe1, 0x5b, 0xc, 0xfe, + 0xca, 0x9f, 0x2d, 0x56, 0x4a, 0xff, 0x50, 0x70, 0x21}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x48, 0xbf, 0xab, 0x87, 0x9d, 0x29, 0x7b, 0x64, 0x7e, 0xb5, 0xbe}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x1c, 0x65, 0x92, 0x96, 0xde}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x10, 0xe4, 0xc4, 0x7b, 0x9d, 0x68, 0x47, 0x87, 0x7e, 0x52, 0x56, 0x5e, 0x4, 0x35}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf3, 0xd4, 0xc6, 0x7, 0x9d, 0xc1, 0xae, 0xe7, + 0xc4, 0x81, 0x4e, 0xb6, 0x89, 0xf3, 0x77}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21005, 8, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 17284 +// ["\219\&6\208\245\251\252\ESC\222\a\175]6\SUB\EM\187\163\135\251R\141\188\250_~#\250\154\253'6","\209\"I\SOW",":/\181!v\193\177A\DC4\ACK\181\218\218*\183\248\233","^}\ETB\204n1\129\156\159\193Y\160\v","\222}^v\153\247\244\185\129\n\220Cy\SUB\ETX","\247\184r"] +// [PropTopicAliasMaximum 19254,PropSubscriptionIdentifierAvailable 208,PropSubscriptionIdentifierAvailable 223] +TEST(Unsubscribe5QCTest, Encode2) { + uint8_t pkt[] = {0xa2, 0x69, 0x43, 0x84, 0x7, 0x22, 0x4b, 0x36, 0x29, 0xd0, 0x29, 0xdf, 0x0, 0x1e, 0xdb, 0x36, + 0xd0, 0xf5, 0xfb, 0xfc, 0x1b, 0xde, 0x7, 0xaf, 0x5d, 0x36, 0x1a, 0x19, 0xbb, 0xa3, 0x87, 0xfb, + 0x52, 0x8d, 0xbc, 0xfa, 0x5f, 0x7e, 0x23, 0xfa, 0x9a, 0xfd, 0x27, 0x36, 0x0, 0x5, 0xd1, 0x22, + 0x49, 0xe, 0x57, 0x0, 0x11, 0x3a, 0x2f, 0xb5, 0x21, 0x76, 0xc1, 0xb1, 0x41, 0x14, 0x6, 0xb5, + 0xda, 0xda, 0x2a, 0xb7, 0xf8, 0xe9, 0x0, 0xd, 0x5e, 0x7d, 0x17, 0xcc, 0x6e, 0x31, 0x81, 0x9c, + 0x9f, 0xc1, 0x59, 0xa0, 0xb, 0x0, 0xf, 0xde, 0x7d, 0x5e, 0x76, 0x99, 0xf7, 0xf4, 0xb9, 0x81, + 0xa, 0xdc, 0x43, 0x79, 0x1a, 0x3, 0x0, 0x3, 0xf7, 0xb8, 0x72}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19254}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, + }; + + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xdb, 0x36, 0xd0, 0xf5, 0xfb, 0xfc, 0x1b, 0xde, 0x7, 0xaf, + 0x5d, 0x36, 0x1a, 0x19, 0xbb, 0xa3, 0x87, 0xfb, 0x52, 0x8d, + 0xbc, 0xfa, 0x5f, 0x7e, 0x23, 0xfa, 0x9a, 0xfd, 0x27, 0x36}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xd1, 0x22, 0x49, 0xe, 0x57}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x3a, 0x2f, 0xb5, 0x21, 0x76, 0xc1, 0xb1, 0x41, 0x14, + 0x6, 0xb5, 0xda, 0xda, 0x2a, 0xb7, 0xf8, 0xe9}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x5e, 0x7d, 0x17, 0xcc, 0x6e, 0x31, 0x81, 0x9c, 0x9f, 0xc1, 0x59, 0xa0, 0xb}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xde, 0x7d, 0x5e, 0x76, 0x99, 0xf7, 0xf4, 0xb9, + 0x81, 0xa, 0xdc, 0x43, 0x79, 0x1a, 0x3}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xf7, 0xb8, 0x72}; + lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xad, 0x2e, 0x4e, 0xa, 0x7e, 0xdb, 0x6f, 0xd6, 0xcd, 0xa7, 0xbe, - 0x8b, 0xc4, 0xb9, 0xf6, 0xae, 0x33, 0x2, 0xd7, 0xeb, 0x87, 0x61}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xac, 0x67, 0x8, 0x41, 0x75, 0xbb, 0x72, 0x7, 0x75, - 0x2d, 0x14, 0x21, 0x21, 0x56, 0x77, 0x20, 0x7c, 0x78}; - lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd3, 0x36, 0xaf, 0xb4, 0x63, 0x99, 0xbb, 0x73, 0x0, 0xb, 0x8c, 0x45, 0x6d, - 0xd7, 0x90, 0xf4, 0x33, 0x7c, 0xf6, 0x1b, 0x26, 0xef, 0x74, 0x44, 0xf3, 0xef}; - lwmqtt_string_t topic_filter_s8 = {26, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x5d, 0x1f, 0xe2, 0x41, 0xa5, 0x5c, 0x7c, 0xce, 0x55, - 0x36, 0xf9, 0x64, 0x90, 0xf1, 0x4f, 0x6e, 0x2d, 0x99}; - lwmqtt_string_t topic_filter_s9 = {18, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14034, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17284, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22538 ["O\215\150\139h\178\159\233Bf\234x\tp\206\198\147s\142\236\132\SYN\221f\DELN\NAK\228\133"] -// [] -TEST(Unsubscribe311QCTest, Encode26) { - uint8_t pkt[] = {0xa2, 0x21, 0x58, 0xa, 0x0, 0x1d, 0x4f, 0xd7, 0x96, 0x8b, 0x68, 0xb2, - 0x9f, 0xe9, 0x42, 0x66, 0xea, 0x78, 0x9, 0x70, 0xce, 0xc6, 0x93, 0x73, - 0x8e, 0xec, 0x84, 0x16, 0xdd, 0x66, 0x7f, 0x4e, 0x15, 0xe4, 0x85}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// UnsubscribeRequest 26289 +// ["\140B\199\151L3\231\157\171K\204\197\224\217\DC2\144l\223\SYNH\185kEa\195","\170\250s\163&\SUB\DC3?I\176","*\244","\169\175\132P&\bp\128\&0B\ETB*\162u\148\&3p\fE\STX\ENQ\NAK)M{\199","\212j\250\SYN\247\NUL\139#9\128\SYN\141\DC1\198\182\221\128\146\130\239`3\STX\r","\179sq\146\SI\SYN\SUB\229\SUBT\SIeFJd\172\am\222\178|\234T\138\137\144"] +// [PropCorrelationData "\DEL\183",PropSubscriptionIdentifierAvailable 5,PropCorrelationData +// "\DC1\162\188MG\SYNI\246L\230\227\141\240l\SO\NUL&\148\157",PropMessageExpiryInterval 1519,PropServerKeepAlive +// 15506,PropRetainAvailable 132,PropReasonString "m\DEL\171\RS"] +TEST(Unsubscribe5QCTest, Encode4) { + uint8_t pkt[] = { + 0xa2, 0xa7, 0x2, 0x26, 0xa8, 0xec, 0x1, 0x2, 0x0, 0x0, 0x2f, 0x26, 0x9, 0x0, 0x1, 0xd0, 0x1a, 0x0, 0x1e, + 0x5a, 0x11, 0x26, 0xc0, 0x7d, 0x84, 0x9f, 0x69, 0x93, 0xcb, 0xdc, 0xca, 0xe4, 0x73, 0xda, 0x65, 0x4a, 0xd, 0x9e, + 0x4e, 0x8c, 0x35, 0xff, 0xce, 0x68, 0xbd, 0x9b, 0x73, 0xe1, 0x6a, 0x1f, 0x0, 0x16, 0x78, 0x5d, 0x45, 0x79, 0xd5, + 0x38, 0x9b, 0xbb, 0x68, 0xbb, 0x87, 0xf4, 0x9d, 0xa1, 0x73, 0x4c, 0xf2, 0x7c, 0x83, 0x7a, 0x73, 0x23, 0x25, 0xbd, + 0x26, 0x0, 0x4, 0x74, 0x22, 0x81, 0x7, 0x0, 0x18, 0x42, 0x30, 0xbd, 0x4f, 0xec, 0x21, 0xf6, 0x7f, 0x9a, 0x70, + 0xc1, 0x23, 0xc2, 0xe1, 0x8f, 0xfb, 0x90, 0x4e, 0x14, 0x7a, 0x63, 0xf5, 0x29, 0x6a, 0x19, 0x9f, 0x23, 0x73, 0xbd, + 0x28, 0xc8, 0x2, 0x0, 0x0, 0x66, 0xfe, 0x16, 0x0, 0xc, 0x4, 0x50, 0x34, 0x44, 0x77, 0x5c, 0x7b, 0x8b, 0x11, + 0xce, 0xee, 0xb9, 0x29, 0xcc, 0x28, 0xe8, 0x1c, 0x0, 0x14, 0xed, 0x4b, 0x8f, 0xf1, 0x2f, 0x7e, 0x69, 0xf7, 0xc5, + 0x8b, 0xbc, 0xae, 0xe8, 0x97, 0x43, 0xf4, 0xf0, 0xa7, 0xa2, 0x9e, 0x2, 0x0, 0x0, 0x6f, 0xe4, 0x19, 0xbf, 0x21, + 0xb, 0x98, 0x28, 0x7, 0x1, 0x6e, 0x16, 0x0, 0x11, 0xef, 0xe9, 0x16, 0x21, 0x24, 0x33, 0x5c, 0x3f, 0x52, 0x66, + 0x58, 0x88, 0x90, 0x82, 0xba, 0x33, 0xec, 0x29, 0x93, 0x2a, 0x37, 0x2, 0x0, 0x0, 0x28, 0x5a, 0x16, 0x0, 0x11, + 0x91, 0xd2, 0xf2, 0xc8, 0x82, 0x75, 0x3e, 0xe6, 0xe3, 0x8d, 0xf0, 0x6c, 0xe, 0x0, 0x26, 0x94, 0x9d, 0x2, 0x0, + 0x0, 0x5, 0xef, 0x13, 0x3c, 0x92, 0x25, 0x84, 0x1f, 0x0, 0x4, 0x6d, 0x7f, 0xab, 0x1e, 0x0, 0x8, 0x9, 0x42, + 0xae, 0xaf, 0x17, 0x8f, 0x20, 0xb, 0x0, 0x5, 0x5, 0x6d, 0x22, 0x6a, 0xf8, 0x0, 0xc, 0x57, 0x4b, 0xfa, 0xdf, + 0x0, 0x55, 0xcb, 0xf4, 0xc8, 0xac, 0x2a, 0x84, 0x0, 0x16, 0x1e, 0xf2, 0xba, 0xc7, 0x62, 0xe2, 0xc8, 0x4f, 0x52, + 0xb, 0x59, 0xb8, 0x23, 0x6e, 0xb7, 0xdd, 0xf2, 0x94, 0x62, 0x62, 0x1a, 0xb4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xd0}; + uint8_t bytesprops1[] = {0x5a, 0x11, 0x26, 0xc0, 0x7d, 0x84, 0x9f, 0x69, 0x93, 0xcb, 0xdc, 0xca, 0xe4, 0x73, 0xda, + 0x65, 0x4a, 0xd, 0x9e, 0x4e, 0x8c, 0x35, 0xff, 0xce, 0x68, 0xbd, 0x9b, 0x73, 0xe1, 0x6a}; + uint8_t bytesprops2[] = {0x78, 0x5d, 0x45, 0x79, 0xd5, 0x38, 0x9b, 0xbb, 0x68, 0xbb, 0x87, + 0xf4, 0x9d, 0xa1, 0x73, 0x4c, 0xf2, 0x7c, 0x83, 0x7a, 0x73, 0x23}; + uint8_t bytesprops4[] = {0x42, 0x30, 0xbd, 0x4f, 0xec, 0x21, 0xf6, 0x7f, 0x9a, 0x70, 0xc1, 0x23, + 0xc2, 0xe1, 0x8f, 0xfb, 0x90, 0x4e, 0x14, 0x7a, 0x63, 0xf5, 0x29, 0x6a}; + uint8_t bytesprops3[] = {0x74, 0x22, 0x81, 0x7}; + uint8_t bytesprops5[] = {0x4, 0x50, 0x34, 0x44, 0x77, 0x5c, 0x7b, 0x8b, 0x11, 0xce, 0xee, 0xb9}; + uint8_t bytesprops6[] = {0xed, 0x4b, 0x8f, 0xf1, 0x2f, 0x7e, 0x69, 0xf7, 0xc5, 0x8b, + 0xbc, 0xae, 0xe8, 0x97, 0x43, 0xf4, 0xf0, 0xa7, 0xa2, 0x9e}; + uint8_t bytesprops7[] = {0xef, 0xe9, 0x16, 0x21, 0x24, 0x33, 0x5c, 0x3f, 0x52, + 0x66, 0x58, 0x88, 0x90, 0x82, 0xba, 0x33, 0xec}; + uint8_t bytesprops8[] = {0x91, 0xd2, 0xf2, 0xc8, 0x82, 0x75, 0x3e, 0xe6, 0xe3, + 0x8d, 0xf0, 0x6c, 0xe, 0x0, 0x26, 0x94, 0x9d}; + uint8_t bytesprops9[] = {0x6d, 0x7f, 0xab, 0x1e}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12070}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops3}, .v = {24, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29629}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26366}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28644}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2968}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10330}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1519}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15506}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops9}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x47, 0x58, 0x29, 0x4, 0xc1, 0x1d, 0xc9, 0x41, 0xc4, 0xa9, 0x16, 0xb4}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x9, 0x42, 0xae, 0xaf, 0x17, 0x8f, 0x20, 0xb}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc0, 0xc2, 0x63, 0x8b, 0x58, 0xd7, 0xcc, 0x3c, 0x8, 0x61, 0x8f, 0xf0, 0x5e, 0xad, - 0xc6, 0xa9, 0x56, 0x1f, 0x46, 0x74, 0xe5, 0x8d, 0x3b, 0xa, 0xdf, 0xd7, 0x74}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5, 0x6d, 0x22, 0x6a, 0xf8}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe4, 0x26, 0xf0}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x57, 0x4b, 0xfa, 0xdf, 0x0, 0x55, 0xcb, 0xf4, 0xc8, 0xac, 0x2a, 0x84}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1e, 0xf2, 0xba, 0xc7, 0x62, 0xe2, 0xc8, 0x4f, 0x52, 0xb, 0x59, + 0xb8, 0x23, 0x6e, 0xb7, 0xdd, 0xf2, 0x94, 0x62, 0x62, 0x1a, 0xb4}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x52, 0xa4, 0x7d, 0x6a, 0x2e, 0x75, 0x34, 0xda, - 0x81, 0xaa, 0xf5, 0x6a, 0xf5, 0xc0, 0x29, 0xc4}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x69, 0xb7, 0xb5, 0x3b, 0xb6, 0x8e, 0x43}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x30, 0x7c, 0x3f, 0x72, 0x3f, 0xbf, 0x4, 0x3d, 0x3d, 0x6f, 0xf4, - 0xf3, 0x40, 0xc6, 0x15, 0xda, 0x9b, 0x9e, 0x0, 0x97, 0xb8, 0x7a}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x76, 0xca, 0x2e, 0x6a, 0xee, 0xf8, 0xa3, 0x54, 0xa7, - 0x94, 0x9e, 0x64, 0x6c, 0xf9, 0x54, 0xe4, 0x49, 0x76}; - lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30444, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9896, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 10904 -// ["\158\151(tQ&M3?\234\162qjZ\ENQ\146wd\180\249\&0","\148\148\181'\255Q\247\ETB\218\ESC\136\SYN\a\213\151t\229az1\208\253","z\245\157\159\151\241\225%\SOH^\129`\166\168\252\172\135}","|\SOq\189\SO","\ENQi\226\n}\143\149O\235\&1\SOHN\241\252\183GG\136\142"] -// [] -TEST(Unsubscribe311QCTest, Encode28) { - uint8_t pkt[] = {0xa2, 0x61, 0x2a, 0x98, 0x0, 0x15, 0x9e, 0x97, 0x28, 0x74, 0x51, 0x26, 0x4d, 0x33, 0x3f, 0xea, 0xa2, - 0x71, 0x6a, 0x5a, 0x5, 0x92, 0x77, 0x64, 0xb4, 0xf9, 0x30, 0x0, 0x16, 0x94, 0x94, 0xb5, 0x27, 0xff, - 0x51, 0xf7, 0x17, 0xda, 0x1b, 0x88, 0x16, 0x7, 0xd5, 0x97, 0x74, 0xe5, 0x61, 0x7a, 0x31, 0xd0, 0xfd, - 0x0, 0x12, 0x7a, 0xf5, 0x9d, 0x9f, 0x97, 0xf1, 0xe1, 0x25, 0x1, 0x5e, 0x81, 0x60, 0xa6, 0xa8, 0xfc, - 0xac, 0x87, 0x7d, 0x0, 0x5, 0x7c, 0xe, 0x71, 0xbd, 0xe, 0x0, 0x13, 0x5, 0x69, 0xe2, 0xa, 0x7d, - 0x8f, 0x95, 0x4f, 0xeb, 0x31, 0x1, 0x4e, 0xf1, 0xfc, 0xb7, 0x47, 0x47, 0x88, 0x8e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// UnsubscribeRequest 9659 +// ["\253","\160\188","\246\207o\213\149\183l\132M\244\133\167\244B[\202","\DC4\197.\n\245\152<\170X\185\RS?8\177\237\152\ENQ\173\173\191\249\&8x\ESC\215\145\250","\158F\EOT.\ESC\EMp\SUB\218\&9P\172LJ\198"] +// [PropServerReference +// "&\166Q\248\184\225\194\133\145\vz\181\US\211\230{\249J\SI\136\252\246+\214\239\176",PropRequestResponseInformation +// 195,PropContentType +// "~\219\209i\147\SYN^L(\214\165w\243\214G\207!\DLE\236\219D'\210\199\184\\",PropMessageExpiryInterval +// 19808,PropMessageExpiryInterval 24445,PropAuthenticationMethod "",PropTopicAliasMaximum 4660,PropTopicAliasMaximum +// 13231,PropRetainAvailable 25,PropReceiveMaximum 26084] +TEST(Unsubscribe5QCTest, Encode5) { + uint8_t pkt[] = {0xa2, 0x9e, 0x1, 0x25, 0xbb, 0x54, 0x1c, 0x0, 0x1a, 0x26, 0xa6, 0x51, 0xf8, 0xb8, 0xe1, 0xc2, 0x85, + 0x91, 0xb, 0x7a, 0xb5, 0x1f, 0xd3, 0xe6, 0x7b, 0xf9, 0x4a, 0xf, 0x88, 0xfc, 0xf6, 0x2b, 0xd6, 0xef, + 0xb0, 0x19, 0xc3, 0x3, 0x0, 0x1a, 0x7e, 0xdb, 0xd1, 0x69, 0x93, 0x16, 0x5e, 0x4c, 0x28, 0xd6, 0xa5, + 0x77, 0xf3, 0xd6, 0x47, 0xcf, 0x21, 0x10, 0xec, 0xdb, 0x44, 0x27, 0xd2, 0xc7, 0xb8, 0x5c, 0x2, 0x0, + 0x0, 0x4d, 0x60, 0x2, 0x0, 0x0, 0x5f, 0x7d, 0x15, 0x0, 0x0, 0x22, 0x12, 0x34, 0x22, 0x33, 0xaf, + 0x25, 0x19, 0x21, 0x65, 0xe4, 0x0, 0x1, 0xfd, 0x0, 0x2, 0xa0, 0xbc, 0x0, 0x10, 0xf6, 0xcf, 0x6f, + 0xd5, 0x95, 0xb7, 0x6c, 0x84, 0x4d, 0xf4, 0x85, 0xa7, 0xf4, 0x42, 0x5b, 0xca, 0x0, 0x1b, 0x14, 0xc5, + 0x2e, 0xa, 0xf5, 0x98, 0x3c, 0xaa, 0x58, 0xb9, 0x1e, 0x3f, 0x38, 0xb1, 0xed, 0x98, 0x5, 0xad, 0xad, + 0xbf, 0xf9, 0x38, 0x78, 0x1b, 0xd7, 0x91, 0xfa, 0x0, 0xf, 0x9e, 0x46, 0x4, 0x2e, 0x1b, 0x19, 0x70, + 0x1a, 0xda, 0x39, 0x50, 0xac, 0x4c, 0x4a, 0xc6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x26, 0xa6, 0x51, 0xf8, 0xb8, 0xe1, 0xc2, 0x85, 0x91, 0xb, 0x7a, 0xb5, 0x1f, + 0xd3, 0xe6, 0x7b, 0xf9, 0x4a, 0xf, 0x88, 0xfc, 0xf6, 0x2b, 0xd6, 0xef, 0xb0}; + uint8_t bytesprops1[] = {0x7e, 0xdb, 0xd1, 0x69, 0x93, 0x16, 0x5e, 0x4c, 0x28, 0xd6, 0xa5, 0x77, 0xf3, + 0xd6, 0x47, 0xcf, 0x21, 0x10, 0xec, 0xdb, 0x44, 0x27, 0xd2, 0xc7, 0xb8, 0x5c}; + uint8_t bytesprops2[] = {0}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19808}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24445}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4660}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13231}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26084}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x9e, 0x97, 0x28, 0x74, 0x51, 0x26, 0x4d, 0x33, 0x3f, 0xea, 0xa2, - 0x71, 0x6a, 0x5a, 0x5, 0x92, 0x77, 0x64, 0xb4, 0xf9, 0x30}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xfd}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x94, 0x94, 0xb5, 0x27, 0xff, 0x51, 0xf7, 0x17, 0xda, 0x1b, 0x88, - 0x16, 0x7, 0xd5, 0x97, 0x74, 0xe5, 0x61, 0x7a, 0x31, 0xd0, 0xfd}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa0, 0xbc}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7a, 0xf5, 0x9d, 0x9f, 0x97, 0xf1, 0xe1, 0x25, 0x1, - 0x5e, 0x81, 0x60, 0xa6, 0xa8, 0xfc, 0xac, 0x87, 0x7d}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf6, 0xcf, 0x6f, 0xd5, 0x95, 0xb7, 0x6c, 0x84, + 0x4d, 0xf4, 0x85, 0xa7, 0xf4, 0x42, 0x5b, 0xca}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x7c, 0xe, 0x71, 0xbd, 0xe}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x14, 0xc5, 0x2e, 0xa, 0xf5, 0x98, 0x3c, 0xaa, 0x58, 0xb9, 0x1e, 0x3f, 0x38, 0xb1, + 0xed, 0x98, 0x5, 0xad, 0xad, 0xbf, 0xf9, 0x38, 0x78, 0x1b, 0xd7, 0x91, 0xfa}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5, 0x69, 0xe2, 0xa, 0x7d, 0x8f, 0x95, 0x4f, 0xeb, 0x31, - 0x1, 0x4e, 0xf1, 0xfc, 0xb7, 0x47, 0x47, 0x88, 0x8e}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x9e, 0x46, 0x4, 0x2e, 0x1b, 0x19, 0x70, 0x1a, + 0xda, 0x39, 0x50, 0xac, 0x4c, 0x4a, 0xc6}; + lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10904, 5, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9659, 5, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5483 -// ["","\RSY|\167.\233=\245U,\193\250.\241\&8]Z\239\EOTi\DC2\193\235\212","\233\251\197\179\CAN\205\158\160\250\133\254\220\DC3\236\149k\249,w\223yf\239\240\193\&2\SO","1;\224awQA\b\129m\211-\177#y\130L;%\227\202'","\129\143;\208\166\210!h@\133","\212\213jo\156\238\193\DC2\188o\254\NUL\219\202","(\182Q\ENQ\158\220\233\233\228\196\226\218\163"] -// [] -TEST(Unsubscribe311QCTest, Encode29) { - uint8_t pkt[] = {0xa2, 0x7e, 0x15, 0x6b, 0x0, 0x0, 0x0, 0x18, 0x1e, 0x59, 0x7c, 0xa7, 0x2e, 0xe9, 0x3d, 0xf5, - 0x55, 0x2c, 0xc1, 0xfa, 0x2e, 0xf1, 0x38, 0x5d, 0x5a, 0xef, 0x4, 0x69, 0x12, 0xc1, 0xeb, 0xd4, - 0x0, 0x1b, 0xe9, 0xfb, 0xc5, 0xb3, 0x18, 0xcd, 0x9e, 0xa0, 0xfa, 0x85, 0xfe, 0xdc, 0x13, 0xec, - 0x95, 0x6b, 0xf9, 0x2c, 0x77, 0xdf, 0x79, 0x66, 0xef, 0xf0, 0xc1, 0x32, 0xe, 0x0, 0x16, 0x31, - 0x3b, 0xe0, 0x61, 0x77, 0x51, 0x41, 0x8, 0x81, 0x6d, 0xd3, 0x2d, 0xb1, 0x23, 0x79, 0x82, 0x4c, - 0x3b, 0x25, 0xe3, 0xca, 0x27, 0x0, 0xa, 0x81, 0x8f, 0x3b, 0xd0, 0xa6, 0xd2, 0x21, 0x68, 0x40, - 0x85, 0x0, 0xe, 0xd4, 0xd5, 0x6a, 0x6f, 0x9c, 0xee, 0xc1, 0x12, 0xbc, 0x6f, 0xfe, 0x0, 0xdb, - 0xca, 0x0, 0xd, 0x28, 0xb6, 0x51, 0x5, 0x9e, 0xdc, 0xe9, 0xe9, 0xe4, 0xc4, 0xe2, 0xda, 0xa3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// UnsubscribeRequest 5752 +// ["\a\tr\STXO4\140\DC2\166\&9\DC2\n\233","G\196\155\t.\170\213Y\229_\218\226k\NAKIi\229\145\SI\234","M!\NUL\223\224\185\128\215\200\186\241f\221vD\173\tW\162\EOT\200\&4!\n\160","Wu\227\181\230\224\215}\250\227\167\RS\140QIPk\192\135\b\STX\180\186\147\135U\174\155"] +// [PropMaximumPacketSize 16593,PropMaximumQoS 135,PropMaximumQoS 76,PropResponseInformation +// "\134G\164\193cR\ETB\EMM\133\183%p\171HS\141\206\&7\206\248",PropServerKeepAlive 21530,PropTopicAlias +// 19135,PropRequestProblemInformation 183,PropReasonString "\166\148",PropResponseInformation +// "\NAKB\DC4\180\138h\SYN\ETB\142\186t1",PropAuthenticationData +// "\164\227\163\137\155\163\163\251\SI\211\207jX\NULO\245\\\206B\239",PropSessionExpiryInterval +// 26346,PropMessageExpiryInterval 10899,PropServerKeepAlive 21711,PropResponseInformation +// "+\174|\191\229\228\222ayU\250\221\254\216\232\&6\243\155B\231\180\EM\DC3\255",PropAuthenticationData +// "\222\202\&8\239\206\ETXx^",PropRetainAvailable 213,PropRequestProblemInformation 196,PropResponseTopic +// "+G\226\177\&6\133;\128`\130\142\243\159\137DKr\181\148\132\198",PropWillDelayInterval +// 6318,PropRequestProblemInformation 19] +TEST(Unsubscribe5QCTest, Encode6) { + uint8_t pkt[] = {0xa2, 0x8c, 0x2, 0x16, 0x78, 0xaa, 0x1, 0x27, 0x0, 0x0, 0x40, 0xd1, 0x24, 0x87, 0x24, 0x4c, 0x1a, + 0x0, 0x15, 0x86, 0x47, 0xa4, 0xc1, 0x63, 0x52, 0x17, 0x19, 0x4d, 0x85, 0xb7, 0x25, 0x70, 0xab, 0x48, + 0x53, 0x8d, 0xce, 0x37, 0xce, 0xf8, 0x13, 0x54, 0x1a, 0x23, 0x4a, 0xbf, 0x17, 0xb7, 0x1f, 0x0, 0x2, + 0xa6, 0x94, 0x1a, 0x0, 0xc, 0x15, 0x42, 0x14, 0xb4, 0x8a, 0x68, 0x16, 0x17, 0x8e, 0xba, 0x74, 0x31, + 0x16, 0x0, 0x14, 0xa4, 0xe3, 0xa3, 0x89, 0x9b, 0xa3, 0xa3, 0xfb, 0xf, 0xd3, 0xcf, 0x6a, 0x58, 0x0, + 0x4f, 0xf5, 0x5c, 0xce, 0x42, 0xef, 0x11, 0x0, 0x0, 0x66, 0xea, 0x2, 0x0, 0x0, 0x2a, 0x93, 0x13, + 0x54, 0xcf, 0x1a, 0x0, 0x18, 0x2b, 0xae, 0x7c, 0xbf, 0xe5, 0xe4, 0xde, 0x61, 0x79, 0x55, 0xfa, 0xdd, + 0xfe, 0xd8, 0xe8, 0x36, 0xf3, 0x9b, 0x42, 0xe7, 0xb4, 0x19, 0x13, 0xff, 0x16, 0x0, 0x8, 0xde, 0xca, + 0x38, 0xef, 0xce, 0x3, 0x78, 0x5e, 0x25, 0xd5, 0x17, 0xc4, 0x8, 0x0, 0x15, 0x2b, 0x47, 0xe2, 0xb1, + 0x36, 0x85, 0x3b, 0x80, 0x60, 0x82, 0x8e, 0xf3, 0x9f, 0x89, 0x44, 0x4b, 0x72, 0xb5, 0x94, 0x84, 0xc6, + 0x18, 0x0, 0x0, 0x18, 0xae, 0x17, 0x13, 0x0, 0xd, 0x7, 0x9, 0x72, 0x2, 0x4f, 0x34, 0x8c, 0x12, + 0xa6, 0x39, 0x12, 0xa, 0xe9, 0x0, 0x14, 0x47, 0xc4, 0x9b, 0x9, 0x2e, 0xaa, 0xd5, 0x59, 0xe5, 0x5f, + 0xda, 0xe2, 0x6b, 0x15, 0x49, 0x69, 0xe5, 0x91, 0xf, 0xea, 0x0, 0x19, 0x4d, 0x21, 0x0, 0xdf, 0xe0, + 0xb9, 0x80, 0xd7, 0xc8, 0xba, 0xf1, 0x66, 0xdd, 0x76, 0x44, 0xad, 0x9, 0x57, 0xa2, 0x4, 0xc8, 0x34, + 0x21, 0xa, 0xa0, 0x0, 0x1c, 0x57, 0x75, 0xe3, 0xb5, 0xe6, 0xe0, 0xd7, 0x7d, 0xfa, 0xe3, 0xa7, 0x1e, + 0x8c, 0x51, 0x49, 0x50, 0x6b, 0xc0, 0x87, 0x8, 0x2, 0xb4, 0xba, 0x93, 0x87, 0x55, 0xae, 0x9b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x86, 0x47, 0xa4, 0xc1, 0x63, 0x52, 0x17, 0x19, 0x4d, 0x85, 0xb7, + 0x25, 0x70, 0xab, 0x48, 0x53, 0x8d, 0xce, 0x37, 0xce, 0xf8}; + uint8_t bytesprops1[] = {0xa6, 0x94}; + uint8_t bytesprops2[] = {0x15, 0x42, 0x14, 0xb4, 0x8a, 0x68, 0x16, 0x17, 0x8e, 0xba, 0x74, 0x31}; + uint8_t bytesprops3[] = {0xa4, 0xe3, 0xa3, 0x89, 0x9b, 0xa3, 0xa3, 0xfb, 0xf, 0xd3, + 0xcf, 0x6a, 0x58, 0x0, 0x4f, 0xf5, 0x5c, 0xce, 0x42, 0xef}; + uint8_t bytesprops4[] = {0x2b, 0xae, 0x7c, 0xbf, 0xe5, 0xe4, 0xde, 0x61, 0x79, 0x55, 0xfa, 0xdd, + 0xfe, 0xd8, 0xe8, 0x36, 0xf3, 0x9b, 0x42, 0xe7, 0xb4, 0x19, 0x13, 0xff}; + uint8_t bytesprops5[] = {0xde, 0xca, 0x38, 0xef, 0xce, 0x3, 0x78, 0x5e}; + uint8_t bytesprops6[] = {0x2b, 0x47, 0xe2, 0xb1, 0x36, 0x85, 0x3b, 0x80, 0x60, 0x82, 0x8e, + 0xf3, 0x9f, 0x89, 0x44, 0x4b, 0x72, 0xb5, 0x94, 0x84, 0xc6}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16593}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21530}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19135}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26346}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10899}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21711}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6318}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x7, 0x9, 0x72, 0x2, 0x4f, 0x34, 0x8c, 0x12, 0xa6, 0x39, 0x12, 0xa, 0xe9}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1e, 0x59, 0x7c, 0xa7, 0x2e, 0xe9, 0x3d, 0xf5, 0x55, 0x2c, 0xc1, 0xfa, - 0x2e, 0xf1, 0x38, 0x5d, 0x5a, 0xef, 0x4, 0x69, 0x12, 0xc1, 0xeb, 0xd4}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x47, 0xc4, 0x9b, 0x9, 0x2e, 0xaa, 0xd5, 0x59, 0xe5, 0x5f, + 0xda, 0xe2, 0x6b, 0x15, 0x49, 0x69, 0xe5, 0x91, 0xf, 0xea}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe9, 0xfb, 0xc5, 0xb3, 0x18, 0xcd, 0x9e, 0xa0, 0xfa, 0x85, 0xfe, 0xdc, 0x13, 0xec, - 0x95, 0x6b, 0xf9, 0x2c, 0x77, 0xdf, 0x79, 0x66, 0xef, 0xf0, 0xc1, 0x32, 0xe}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4d, 0x21, 0x0, 0xdf, 0xe0, 0xb9, 0x80, 0xd7, 0xc8, 0xba, 0xf1, 0x66, 0xdd, + 0x76, 0x44, 0xad, 0x9, 0x57, 0xa2, 0x4, 0xc8, 0x34, 0x21, 0xa, 0xa0}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x31, 0x3b, 0xe0, 0x61, 0x77, 0x51, 0x41, 0x8, 0x81, 0x6d, 0xd3, - 0x2d, 0xb1, 0x23, 0x79, 0x82, 0x4c, 0x3b, 0x25, 0xe3, 0xca, 0x27}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x57, 0x75, 0xe3, 0xb5, 0xe6, 0xe0, 0xd7, 0x7d, 0xfa, 0xe3, + 0xa7, 0x1e, 0x8c, 0x51, 0x49, 0x50, 0x6b, 0xc0, 0x87, 0x8, + 0x2, 0xb4, 0xba, 0x93, 0x87, 0x55, 0xae, 0x9b}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x81, 0x8f, 0x3b, 0xd0, 0xa6, 0xd2, 0x21, 0x68, 0x40, 0x85}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xd4, 0xd5, 0x6a, 0x6f, 0x9c, 0xee, 0xc1, 0x12, 0xbc, 0x6f, 0xfe, 0x0, 0xdb, 0xca}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x28, 0xb6, 0x51, 0x5, 0x9e, 0xdc, 0xe9, 0xe9, 0xe4, 0xc4, 0xe2, 0xda, 0xa3}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5483, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5752, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 27410 -// ["\142,\253\251\228\164\&6>\237\ETX\150\202\228\225\236\SUB\130}\144\142\196:\EOT","7$&\216\162\FSEn\RSsy\244]","\200\209D","\154,\164<","\211c\153","\DLE\221\175\212*","Pk)\217\129'\201\236\161\181o\176D\191L\241\158\153\EOT\228","#\231\205E\220\217&S\242","\211\145\204"] -// [] -TEST(Unsubscribe311QCTest, Encode30) { - uint8_t pkt[] = {0xa2, 0x67, 0x6b, 0x12, 0x0, 0x17, 0x8e, 0x2c, 0xfd, 0xfb, 0xe4, 0xa4, 0x36, 0x3e, 0xed, - 0x3, 0x96, 0xca, 0xe4, 0xe1, 0xec, 0x1a, 0x82, 0x7d, 0x90, 0x8e, 0xc4, 0x3a, 0x4, 0x0, - 0xd, 0x37, 0x24, 0x26, 0xd8, 0xa2, 0x1c, 0x45, 0x6e, 0x1e, 0x73, 0x79, 0xf4, 0x5d, 0x0, - 0x3, 0xc8, 0xd1, 0x44, 0x0, 0x4, 0x9a, 0x2c, 0xa4, 0x3c, 0x0, 0x3, 0xd3, 0x63, 0x99, - 0x0, 0x5, 0x10, 0xdd, 0xaf, 0xd4, 0x2a, 0x0, 0x14, 0x50, 0x6b, 0x29, 0xd9, 0x81, 0x27, - 0xc9, 0xec, 0xa1, 0xb5, 0x6f, 0xb0, 0x44, 0xbf, 0x4c, 0xf1, 0x9e, 0x99, 0x4, 0xe4, 0x0, - 0x9, 0x23, 0xe7, 0xcd, 0x45, 0xdc, 0xd9, 0x26, 0x53, 0xf2, 0x0, 0x3, 0xd3, 0x91, 0xcc}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// UnsubscribeRequest 26590 +// ["\"\128\&3`Z\154EIF","\191\216\128<6\157\128\f\207\159&h\207O\235|\169g\r\DC4\137\DC3\175\176\&3\201EN\NAK","\130{\210H\187 +// \219q\251wl\247&\nJ$\185\DLE\158\179","\167\NUL\ETX\172\207gd3\251C\170\SIM\239\157O\233\224-\251e-\224\148\188","\184\NAK\198\&2\137\SI:\164\DC3\SYN(#\174\242\179\138<\206\157\US","\222\SO=\194\210\132u\185\192\r5\181","O\231\246\135\209\137","B>\250\193\SOL\212\170\245\168)\237\134\187\204\232*+\218\EM7\r\142\EOTb\221\152l\148"] +// [PropAuthenticationMethod "\146\176\246\146F&~y",PropReceiveMaximum 11903,PropServerKeepAlive +// 30316,PropTopicAliasMaximum 20575,PropSharedSubscriptionAvailable 19,PropSubscriptionIdentifierAvailable +// 238,PropResponseTopic +// "\185X\250\vG>,\222YWiQ5\207\238\DC4\t\223\181~d\143G\233ZP\213\DC3\234",PropAssignedClientIdentifier +// "@f:\SUB6\186\ETX*f\231}\133\150\b\DC1\171\136\204\255\197\ENQFE\f\179<\ESC\250",PropSharedSubscriptionAvailable +// 42,PropRequestResponseInformation 231,PropPayloadFormatIndicator 28,PropAuthenticationMethod +// "\202e\133\&0\206\235W\195\132\250]\238",PropRequestProblemInformation 213,PropReceiveMaximum 11947] +TEST(Unsubscribe5QCTest, Encode7) { + uint8_t pkt[] = { + 0xa2, 0x9a, 0x2, 0x67, 0xde, 0x71, 0x15, 0x0, 0x8, 0x92, 0xb0, 0xf6, 0x92, 0x46, 0x26, 0x7e, 0x79, 0x21, 0x2e, + 0x7f, 0x13, 0x76, 0x6c, 0x22, 0x50, 0x5f, 0x2a,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 0xc6, 0x32, 0x89, 0xf, 0x3a, 0xa4, 0x13, 0x16, 0x28, 0x23, 0xae, 0xf2, 0xb3, 0x8a, + 0x3c, 0xce, 0x9d, 0x1f, 0x0, 0xc, 0xde, 0xe, 0x3d, 0xc2, 0xd2, 0x84, 0x75, 0xb9, 0xc0, 0xd, 0x35, 0xb5, 0x0, + 0x6, 0x4f, 0xe7, 0xf6, 0x87, 0xd1, 0x89, 0x0, 0x1d, 0x42, 0x3e, 0xfa, 0xc1, 0xe, 0x4c, 0xd4, 0xaa, 0xf5, 0xa8, + 0x29, 0xed, 0x86, 0xbb, 0xcc, 0xe8, 0x2a, 0x2b, 0xda, 0x19, 0x37, 0xd, 0x8e, 0x4, 0x62, 0xdd, 0x98, 0x6c, 0x94}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x92, 0xb0, 0xf6, 0x92, 0x46, 0x26, 0x7e, 0x79}; + uint8_t bytesprops1[] = {0xb9, 0x58, 0xfa, 0xb, 0x47, 0x3e, 0x2c, 0xde, 0x59, 0x57, 0x69, 0x51, 0x35, 0xcf, 0xee, + 0x14, 0x9, 0xdf, 0xb5, 0x7e, 0x64, 0x8f, 0x47, 0xe9, 0x5a, 0x50, 0xd5, 0x13, 0xea}; + uint8_t bytesprops2[] = {0x40, 0x66, 0x3a, 0x1a, 0x36, 0xba, 0x3, 0x2a, 0x66, 0xe7, 0x7d, 0x85, 0x96, 0x8, + 0x11, 0xab, 0x88, 0xcc, 0xff, 0xc5, 0x5, 0x46, 0x45, 0xc, 0xb3, 0x3c, 0x1b, 0xfa}; + uint8_t bytesprops3[] = {0xca, 0x65, 0x85, 0x30, 0xce, 0xeb, 0x57, 0xc3, 0x84, 0xfa, 0x5d, 0xee}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11903}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30316}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20575}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11947}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x8e, 0x2c, 0xfd, 0xfb, 0xe4, 0xa4, 0x36, 0x3e, 0xed, 0x3, 0x96, 0xca, - 0xe4, 0xe1, 0xec, 0x1a, 0x82, 0x7d, 0x90, 0x8e, 0xc4, 0x3a, 0x4}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x22, 0x80, 0x33, 0x60, 0x5a, 0x9a, 0x45, 0x49, 0x46}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x37, 0x24, 0x26, 0xd8, 0xa2, 0x1c, 0x45, 0x6e, 0x1e, 0x73, 0x79, 0xf4, 0x5d}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbf, 0xd8, 0x80, 0x3c, 0x36, 0x9d, 0x80, 0xc, 0xcf, 0x9f, + 0x26, 0x68, 0xcf, 0x4f, 0xeb, 0x7c, 0xa9, 0x67, 0xd, 0x14, + 0x89, 0x13, 0xaf, 0xb0, 0x33, 0xc9, 0x45, 0x4e, 0x15}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc8, 0xd1, 0x44}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x82, 0x7b, 0xd2, 0x48, 0xbb, 0x20, 0xdb, 0x71, 0xfb, 0x77, + 0x6c, 0xf7, 0x26, 0xa, 0x4a, 0x24, 0xb9, 0x10, 0x9e, 0xb3}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9a, 0x2c, 0xa4, 0x3c}; - lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa7, 0x0, 0x3, 0xac, 0xcf, 0x67, 0x64, 0x33, 0xfb, 0x43, 0xaa, 0xf, 0x4d, + 0xef, 0x9d, 0x4f, 0xe9, 0xe0, 0x2d, 0xfb, 0x65, 0x2d, 0xe0, 0x94, 0xbc}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd3, 0x63, 0x99}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xb8, 0x15, 0xc6, 0x32, 0x89, 0xf, 0x3a, 0xa4, 0x13, 0x16, + 0x28, 0x23, 0xae, 0xf2, 0xb3, 0x8a, 0x3c, 0xce, 0x9d, 0x1f}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x10, 0xdd, 0xaf, 0xd4, 0x2a}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xde, 0xe, 0x3d, 0xc2, 0xd2, 0x84, 0x75, 0xb9, 0xc0, 0xd, 0x35, 0xb5}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x50, 0x6b, 0x29, 0xd9, 0x81, 0x27, 0xc9, 0xec, 0xa1, 0xb5, - 0x6f, 0xb0, 0x44, 0xbf, 0x4c, 0xf1, 0x9e, 0x99, 0x4, 0xe4}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x4f, 0xe7, 0xf6, 0x87, 0xd1, 0x89}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x23, 0xe7, 0xcd, 0x45, 0xdc, 0xd9, 0x26, 0x53, 0xf2}; - lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x42, 0x3e, 0xfa, 0xc1, 0xe, 0x4c, 0xd4, 0xaa, 0xf5, 0xa8, + 0x29, 0xed, 0x86, 0xbb, 0xcc, 0xe8, 0x2a, 0x2b, 0xda, 0x19, + 0x37, 0xd, 0x8e, 0x4, 0x62, 0xdd, 0x98, 0x6c, 0x94}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd3, 0x91, 0xcc}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27410, 9, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26590, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 17193 -// ["\201\232\214-\249\178\243\205$\220\150\232<\145\247","\167\SOH\185\173{\128\&73b\161rO\230\187\148\214\163\169\130\195\177\233\159l\249","K\ENQ\f\ACK\152\223","\169\DC1\140\210\EMO\172%;\SI\DLE\128\170U\SI\180\&7g\221\229 -// ","\255/n\"\EOT\\P\199\f\DEL\254\EMgh\179\206\243>"] [] -TEST(Unsubscribe5QCTest, Encode1) { - uint8_t pkt[] = {0xa2, 0x62, 0x43, 0x29, 0x0, 0x0, 0xf, 0xc9, 0xe8, 0xd6, 0x2d, 0xf9, 0xb2, 0xf3, 0xcd, 0x24, 0xdc, - 0x96, 0xe8, 0x3c, 0x91, 0xf7, 0x0, 0x19, 0xa7, 0x1, 0xb9, 0xad, 0x7b, 0x80, 0x37, 0x33, 0x62, 0xa1, - 0x72, 0x4f, 0xe6, 0xbb, 0x94, 0xd6, 0xa3, 0xa9, 0x82, 0xc3, 0xb1, 0xe9, 0x9f, 0x6c, 0xf9, 0x0, 0x6, - 0x4b, 0x5, 0xc, 0x6, 0x98, 0xdf, 0x0, 0x15, 0xa9, 0x11, 0x8c, 0xd2, 0x19, 0x4f, 0xac, 0x25, 0x3b, - 0xf, 0x10, 0x80, 0xaa, 0x55, 0xf, 0xb4, 0x37, 0x67, 0xdd, 0xe5, 0x20, 0x0, 0x12, 0xff, 0x2f, 0x6e, - 0x22, 0x4, 0x5c, 0x50, 0xc7, 0xc, 0x7f, 0xfe, 0x19, 0x67, 0x68, 0xb3, 0xce, 0xf3, 0x3e}; +// UnsubscribeRequest 28467 ["\188j71/\157\SUBlO\ESC","N\195\136\SUB[L\203?\219","\USk\146!\197w\FSR\152\254\&3\216 +// \DEL\184\"\147\247\GS\137\168","\147\161\247W\NAKc\172\214*\254 17\201\164\177)\167e\233\179\198\197Wf\a\153x"] [] +TEST(Unsubscribe5QCTest, Encode8) { + uint8_t pkt[] = {0xa2, 0x4f, 0x6f, 0x33, 0x0, 0x0, 0xa, 0xbc, 0x6a, 0x37, 0x31, 0x2f, 0x9d, 0x1a, 0x6c, 0x4f, 0x1b, + 0x0, 0x9, 0x4e, 0xc3, 0x88, 0x1a, 0x5b, 0x4c, 0xcb, 0x3f, 0xdb, 0x0, 0x15, 0x1f, 0x6b, 0x92, 0x21, + 0xc5, 0x77, 0x1c, 0x52, 0x98, 0xfe, 0x33, 0xd8, 0x20, 0x7f, 0xb8, 0x22, 0x93, 0xf7, 0x1d, 0x89, 0xa8, + 0x0, 0x1c, 0x93, 0xa1, 0xf7, 0x57, 0x15, 0x63, 0xac, 0xd6, 0x2a, 0xfe, 0x20, 0x31, 0x37, 0xc9, 0xa4, + 0xb1, 0x29, 0xa7, 0x65, 0xe9, 0xb3, 0xc6, 0xc5, 0x57, 0x66, 0x7, 0x99, 0x78}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xc9, 0xe8, 0xd6, 0x2d, 0xf9, 0xb2, 0xf3, 0xcd, - 0x24, 0xdc, 0x96, 0xe8, 0x3c, 0x91, 0xf7}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xbc, 0x6a, 0x37, 0x31, 0x2f, 0x9d, 0x1a, 0x6c, 0x4f, 0x1b}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa7, 0x1, 0xb9, 0xad, 0x7b, 0x80, 0x37, 0x33, 0x62, 0xa1, 0x72, 0x4f, 0xe6, - 0xbb, 0x94, 0xd6, 0xa3, 0xa9, 0x82, 0xc3, 0xb1, 0xe9, 0x9f, 0x6c, 0xf9}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4e, 0xc3, 0x88, 0x1a, 0x5b, 0x4c, 0xcb, 0x3f, 0xdb}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4b, 0x5, 0xc, 0x6, 0x98, 0xdf}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1f, 0x6b, 0x92, 0x21, 0xc5, 0x77, 0x1c, 0x52, 0x98, 0xfe, 0x33, + 0xd8, 0x20, 0x7f, 0xb8, 0x22, 0x93, 0xf7, 0x1d, 0x89, 0xa8}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa9, 0x11, 0x8c, 0xd2, 0x19, 0x4f, 0xac, 0x25, 0x3b, 0xf, 0x10, - 0x80, 0xaa, 0x55, 0xf, 0xb4, 0x37, 0x67, 0xdd, 0xe5, 0x20}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x93, 0xa1, 0xf7, 0x57, 0x15, 0x63, 0xac, 0xd6, 0x2a, 0xfe, + 0x20, 0x31, 0x37, 0xc9, 0xa4, 0xb1, 0x29, 0xa7, 0x65, 0xe9, + 0xb3, 0xc6, 0xc5, 0x57, 0x66, 0x7, 0x99, 0x78}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xff, 0x2f, 0x6e, 0x22, 0x4, 0x5c, 0x50, 0xc7, 0xc, - 0x7f, 0xfe, 0x19, 0x67, 0x68, 0xb3, 0xce, 0xf3, 0x3e}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17193, 5, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28467, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 26830 -// ["\218+\CAN,\224\168w\RSA\238#\r\212'\236M7g\185\213H9V\247)","-\222\193hv\157\140\193\135\212\152\212","\DEL\rs\210\"\178\STX\ENQ\226\231\ETX\247)\157c\218\174","\243eC -// v|F\170\188e\246w\177:\197J\219\212\184i\139\EOT\207\187\177\228\192\150?\134","\159\157\FS\135\152\130u\DC4\194","\151O\204\&1\251\ACK","46\222nn\188#\191\208{\DC4\208\217\195"] -// [PropAssignedClientIdentifier "\128\221\179\247\163 \237\230B\150",PropAuthenticationMethod -// "h\177\&6\139\ETXu\143l^\246\155v\198H4\137\DC3\167\234\228\163\148\236\US\149\209\135q\130",PropPayloadFormatIndicator -// 50,PropResponseInformation "\ETXq\241%\238\151",PropSharedSubscriptionAvailable 148,PropWillDelayInterval -// 25509,PropTopicAlias 4710,PropContentType "\173\218T\210\215W~>XI\156/\250\152H",PropAuthenticationData -// "\240A1*\138\219\168\216'v\187\&0\153\CAN\202A\231o\DLE\202\251\210]\231\200",PropSessionExpiryInterval -// 22202,PropResponseInformation "\181\228\230",PropRetainAvailable 241,PropResponseInformation -// "\136\247\141o\191",PropServerReference "\249\246\v\DC2\183I\160\183z9"] -TEST(Unsubscribe5QCTest, Encode2) { +// UnsubscribeRequest 8404 ["\198\198Y,9\140\US\ETB\133\SI\228\DC4\186\&9\252\131\242 +// \160\ACK\250\190\133H\184","h|\216nA\142%q@$\216\a\145\EOTE{\207\164V16\251]\131\&8u\235\184Ez","\132T\176\161h\202^\226p\136\166%\163^5\146\232\ESC\STXi\ENQ(\228\223#\SOH\204","M","\172\206\130\186\208S\DC1\255\166\196a","\144}i\254(@\229\171\199YW\ESC:\DC2\SUBs\165k\t\164\175,PR\SYN\194\DEL","0pM\253Q\142\194\174\194\194G9c\235T\GS\235\199\205\220\170\a\vF"] +// [PropReceiveMaximum 26464,PropContentType "1\202V\139\a\219\200\200\128\239\194\147[\173",PropServerKeepAlive +// 22501,PropContentType "\206\191\191\SO\136\230*\158\219\228\142]3",PropSubscriptionIdentifier +// 26,PropWillDelayInterval 16408,PropMessageExpiryInterval 24346,PropResponseTopic +// "\239\&6\CAN\192\aq\EM\227\&5\SOH\244>\ESC\212{\CAN\213\213D\CAN\147WB",PropReasonString +// "\149\198\141\a\196\RS`\141\177\SYN\216\137\\(\133\209aN\178A\EM\200.(\204N\153\210xb",PropReasonString +// "",PropSubscriptionIdentifier 19,PropTopicAlias 25210,PropWillDelayInterval 12790,PropSubscriptionIdentifierAvailable +// 243,PropAuthenticationMethod "\243\220\NAK\199\145x\253&\188\223@ L\222>\ESC\192",PropAuthenticationData +// "\215=\139\184\ACKh\195\154\171",PropUserProperty "U\199L\168\162",PropCorrelationData -// "Fd\229\ACKS\206\180c\143y\153d\210\180\149+\165\207\179\NUL;\135\146v:\182\218\151\207\155",PropSharedSubscriptionAvailable -// 135,PropAuthenticationMethod "\225c\237 \183ve\FS\186",PropTopicAliasMaximum 30866,PropServerKeepAlive -// 32352,PropUserProperty "" "",PropUserProperty "\nY\DLE\150T\227W\160c\228" -// "\208\227\139\ENQ\t\RS\201\v\227\183y\243\215\183\f",PropAssignedClientIdentifier -// "X\SO\176\234\&0\195\253\204\ENQ\143\208y\f\SOH<\ACK",PropMessageExpiryInterval 30461,PropCorrelationData -// "\223A\205\193($\DEL\131\153zj6f@O\145c\243\RS\155\&0\130\143"] -TEST(Unsubscribe5QCTest, Encode3) { - uint8_t pkt[] = { - 0xa2, 0xa2, 0x2, 0x5d, 0x10, 0x92, 0x2, 0x19, 0x57, 0x21, 0x4f, 0xa4, 0x21, 0x6b, 0x97, 0x2, 0x0, 0x0, 0x44, - 0x30, 0x22, 0x7f, 0xec, 0x24, 0x91, 0x2, 0x0, 0x0, 0x7b, 0x70, 0x17, 0x3f, 0x15, 0x0, 0x14, 0x10, 0x51, 0xe8, - 0x46, 0xa2, 0x8f, 0x36, 0xe, 0xf2, 0xc8, 0x25, 0x88, 0xfb, 0x7a, 0x5b, 0x7c, 0x6, 0x81, 0xd5, 0x93, 0x13, 0x20, - 0x2, 0x19, 0x13, 0x19, 0xcd, 0x3, 0x0, 0x14, 0xcb, 0x6f, 0x44, 0xca, 0x2a, 0xb5, 0x2c, 0x25, 0xf8, 0xf0, 0x1a, - 0x6f, 0xe4, 0x77, 0x4a, 0xa8, 0x82, 0x15, 0xf3, 0xfd, 0x2, 0x0, 0x0, 0x2e, 0xba, 0x11, 0x0, 0x0, 0x38, 0xcb, - 0x26, 0x0, 0x0, 0x0, 0x1c, 0x6, 0x74, 0xce, 0x42, 0x48, 0xfa, 0xdd, 0xee, 0xe8, 0x5, 0xac, 0xcf, 0x89, 0x2, - 0xc3, 0xac, 0x6b, 0x1d, 0x18, 0x9a, 0xcb, 0x2d, 0x3, 0xcc, 0xe5, 0x32, 0x21, 0x3c, 0x23, 0x8, 0x6a, 0x3, 0x0, - 0x9, 0xec, 0xd3, 0x88, 0x3e, 0x55, 0xc7, 0x4c, 0xa8, 0xa2, 0x9, 0x0, 0x1e, 0x46, 0x64, 0xe5, 0x6, 0x53, 0xce, - 0xb4, 0x63, 0x8f, 0x79, 0x99, 0x64, 0xd2, 0xb4, 0x95, 0x2b, 0xa5, 0xcf, 0xb3, 0x0, 0x3b, 0x87, 0x92, 0x76, 0x3a, - 0xb6, 0xda, 0x97, 0xcf, 0x9b, 0x2a, 0x87, 0x15, 0x0, 0x9, 0xe1, 0x63, 0xed, 0x20, 0xb7, 0x76, 0x65, 0x1c, 0xba, - 0x22, 0x78, 0x92, 0x13, 0x7e, 0x60, 0x26, 0x0, 0x0, 0x0, 0x0, 0x26, 0x0, 0xa, 0xa, 0x59, 0x10, 0x96, 0x54, - 0xe3, 0x57, 0xa0, 0x63, 0xe4, 0x0, 0xf, 0xd0, 0xe3, 0x8b, 0x5, 0x9, 0x1e, 0xc9, 0xb, 0xe3, 0xb7, 0x79, 0xf3, - 0xd7, 0xb7, 0xc, 0x12, 0x0, 0x10, 0x58, 0xe, 0xb0, 0xea, 0x30, 0xc3, 0xfd, 0xcc, 0x5, 0x8f, 0xd0, 0x79, 0xc, - 0x1, 0x3c, 0x6, 0x2, 0x0, 0x0, 0x76, 0xfd, 0x9, 0x0, 0x17, 0xdf, 0x41, 0xcd, 0xc1, 0x28, 0x24, 0x7f, 0x83, - 0x99, 0x7a, 0x6a, 0x36, 0x66, 0x40, 0x4f, 0x91, 0x63, 0xf3, 0x1e, 0x9b, 0x30, 0x82, 0x8f, 0x0, 0xa, 0xe2, 0x57, - 0x3, 0xc0, 0x3b, 0xa7, 0x3f, 0xe, 0x20, 0x91}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x10, 0x51, 0xe8, 0x46, 0xa2, 0x8f, 0x36, 0xe, 0xf2, 0xc8, - 0x25, 0x88, 0xfb, 0x7a, 0x5b, 0x7c, 0x6, 0x81, 0xd5, 0x93}; - uint8_t bytesprops1[] = {0xcb, 0x6f, 0x44, 0xca, 0x2a, 0xb5, 0x2c, 0x25, 0xf8, 0xf0, - 0x1a, 0x6f, 0xe4, 0x77, 0x4a, 0xa8, 0x82, 0x15, 0xf3, 0xfd}; - uint8_t bytesprops3[] = {0x6, 0x74, 0xce, 0x42, 0x48, 0xfa, 0xdd, 0xee, 0xe8, 0x5, 0xac, 0xcf, 0x89, 0x2, - 0xc3, 0xac, 0x6b, 0x1d, 0x18, 0x9a, 0xcb, 0x2d, 0x3, 0xcc, 0xe5, 0x32, 0x21, 0x3c}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops4[] = {0xec, 0xd3, 0x88, 0x3e, 0x55, 0xc7, 0x4c, 0xa8, 0xa2}; - uint8_t bytesprops5[] = {0x46, 0x64, 0xe5, 0x6, 0x53, 0xce, 0xb4, 0x63, 0x8f, 0x79, 0x99, 0x64, 0xd2, 0xb4, 0x95, - 0x2b, 0xa5, 0xcf, 0xb3, 0x0, 0x3b, 0x87, 0x92, 0x76, 0x3a, 0xb6, 0xda, 0x97, 0xcf, 0x9b}; - uint8_t bytesprops6[] = {0xe1, 0x63, 0xed, 0x20, 0xb7, 0x76, 0x65, 0x1c, 0xba}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops10[] = {0xd0, 0xe3, 0x8b, 0x5, 0x9, 0x1e, 0xc9, 0xb, 0xe3, 0xb7, 0x79, 0xf3, 0xd7, 0xb7, 0xc}; - uint8_t bytesprops9[] = {0xa, 0x59, 0x10, 0x96, 0x54, 0xe3, 0x57, 0xa0, 0x63, 0xe4}; - uint8_t bytesprops11[] = {0x58, 0xe, 0xb0, 0xea, 0x30, 0xc3, 0xfd, 0xcc, 0x5, 0x8f, 0xd0, 0x79, 0xc, 0x1, 0x3c, 0x6}; - uint8_t bytesprops12[] = {0xdf, 0x41, 0xcd, 0xc1, 0x28, 0x24, 0x7f, 0x83, 0x99, 0x7a, 0x6a, 0x36, - 0x66, 0x40, 0x4f, 0x91, 0x63, 0xf3, 0x1e, 0x9b, 0x30, 0x82, 0x8f}; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8404, 7, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 27989 ["q\223fV4\ETB\205\139(\ENQ`\204\145\206\221\207\248\245"] [PropRetainAvailable +// 160,PropServerKeepAlive 11580,PropMessageExpiryInterval 22087,PropUserProperty "\169\242" +// "\152n!\224\136\241\rm\STX#\215m*\182\147$\ENQ>",PropRequestResponseInformation 125,PropRequestResponseInformation +// 90,PropMessageExpiryInterval 716,PropReceiveMaximum 10851,PropReceiveMaximum 23215,PropResponseTopic +// "FL}\163\244\228x\EOT\190\EM\152;9Fo(\DC3y\231\n\237\194\157p\145",PropResponseInformation +// "\129\b\STX\241C\NAK\189\169\CANI\163\240\162"] +TEST(Unsubscribe5QCTest, Encode10) { + uint8_t pkt[] = {0xa2, 0x75, 0x6d, 0x55, 0x5e, 0x25, 0xa0, 0x13, 0x2d, 0x3c, 0x2, 0x0, 0x0, 0x56, 0x47, + 0x26, 0x0, 0x2, 0xa9, 0xf2, 0x0, 0x12, 0x98, 0x6e, 0x21, 0xe0, 0x88, 0xf1, 0xd, 0x6d, + 0x2, 0x23, 0xd7, 0x6d, 0x2a, 0xb6, 0x93, 0x24, 0x5, 0x3e, 0x19, 0x7d, 0x19, 0x5a, 0x2, + 0x0, 0x0, 0x2, 0xcc, 0x21, 0x2a, 0x63, 0x21, 0x5a, 0xaf, 0x8, 0x0, 0x19, 0x46, 0x4c, + 0x7d, 0xa3, 0xf4, 0xe4, 0x78, 0x4, 0xbe, 0x19, 0x98, 0x3b, 0x39, 0x46, 0x6f, 0x28, 0x13, + 0x79, 0xe7, 0xa, 0xed, 0xc2, 0x9d, 0x70, 0x91, 0x1a, 0x0, 0xd, 0x81, 0x8, 0x2, 0xf1, + 0x43, 0x15, 0xbd, 0xa9, 0x18, 0x49, 0xa3, 0xf0, 0xa2, 0x0, 0x12, 0x71, 0xdf, 0x66, 0x56, + 0x34, 0x17, 0xcd, 0x8b, 0x28, 0x5, 0x60, 0xcc, 0x91, 0xce, 0xdd, 0xcf, 0xf8, 0xf5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x98, 0x6e, 0x21, 0xe0, 0x88, 0xf1, 0xd, 0x6d, 0x2, + 0x23, 0xd7, 0x6d, 0x2a, 0xb6, 0x93, 0x24, 0x5, 0x3e}; + uint8_t bytesprops0[] = {0xa9, 0xf2}; + uint8_t bytesprops2[] = {0x46, 0x4c, 0x7d, 0xa3, 0xf4, 0xe4, 0x78, 0x4, 0xbe, 0x19, 0x98, 0x3b, 0x39, + 0x46, 0x6f, 0x28, 0x13, 0x79, 0xe7, 0xa, 0xed, 0xc2, 0x9d, 0x70, 0x91}; + uint8_t bytesprops3[] = {0x81, 0x8, 0x2, 0xf1, 0x43, 0x15, 0xbd, 0xa9, 0x18, 0x49, 0xa3, 0xf0, 0xa2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20388}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27543}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17456}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32748}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31600}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8194}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11962}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14539}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops2}, .v = {28, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2154}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30866}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32352}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops7}, .v = {0, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops9}, .v = {15, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30461}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11580}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22087}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops0}, .v = {18, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 716}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10851}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23215}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xe2, 0x57, 0x3, 0xc0, 0x3b, 0xa7, 0x3f, 0xe, 0x20, 0x91}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x71, 0xdf, 0x66, 0x56, 0x34, 0x17, 0xcd, 0x8b, 0x28, + 0x5, 0x60, 0xcc, 0x91, 0xce, 0xdd, 0xcf, 0xf8, 0xf5}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23824, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27989, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 20314 -// ["\247$\SOcz\155#\129\206\189\129\151\230\250[\179\254\214=v\GS\230\237\227\174\157\ETB\ESC\189"] -// [PropAssignedClientIdentifier "]\222#\222G\232n\197\ACK\170f\139\157\154\183\a\167",PropUserProperty -// "\221\DLE\146)\186\136\&7\232" "\220\218,\136\219#4d\143\250\253\251\218\FS\ACK",PropAuthenticationMethod -// "\161\EM_\DEL\198\159i\164e\173\161#\SI\252\216\STX%\198\178Ij8~\162",PropTopicAliasMaximum 5392,PropServerReference -// "\132\255\141\149#\249\ESC;\SO\187\154*y\ETB\191\232Db\219\DLEIJtr\131Qk\247\DLE\169",PropServerKeepAlive -// 6076,PropTopicAliasMaximum 30910,PropSubscriptionIdentifierAvailable 160,PropMaximumQoS -// 92,PropRequestProblemInformation 171,PropServerKeepAlive 12856,PropTopicAlias 32229,PropMessageExpiryInterval -// 11092,PropRetainAvailable 106,PropUserProperty "\161\160>I\250f\174\SO\205\b\ESCD@\STXb\216{v\fT\248 -// $E\196\178\203\&4<" "",PropSubscriptionIdentifierAvailable 15,PropUserProperty -// ">\170\FS\193\205GS\209\211\247h\EM\DLEW\226\157" -// "\197/&4\163aHw\250S\145\&5)\SOH\204\240\182\209\SOH\145\169",PropResponseTopic -// "\147\147Y\243\232\&91fj;\184\243\135\&3\149&_\174L\ESC\203n49\206\198\147'w\197",PropMessageExpiryInterval -// 13776,PropAuthenticationData "\162\251,\206\178\249tR\180}\232\178\&3b0u\199\ENQC\GS)\169\198"] -TEST(Unsubscribe5QCTest, Encode4) { - uint8_t pkt[] = { - 0xa2, 0xb9, 0x2, 0x4f, 0x5a, 0x96, 0x2, 0x12, 0x0, 0x11, 0x5d, 0xde, 0x23, 0xde, 0x47, 0xe8, 0x6e, 0xc5, 0x6, - 0xaa, 0x66, 0x8b, 0x9d, 0x9a, 0xb7, 0x7, 0xa7, 0x26, 0x0, 0x8, 0xdd, 0x10, 0x92, 0x29, 0xba, 0x88, 0x37, 0xe8, - 0x0, 0xf, 0xdc, 0xda, 0x2c, 0x88, 0xdb, 0x23, 0x34, 0x64, 0x8f, 0xfa, 0xfd, 0xfb, 0xda, 0x1c, 0x6, 0x15, 0x0, - 0x18, 0xa1, 0x19, 0x5f, 0x7f, 0xc6, 0x9f, 0x69, 0xa4, 0x65, 0xad, 0xa1, 0x23, 0xf, 0xfc, 0xd8, 0x2, 0x25, 0xc6, - 0xb2, 0x49, 0x6a, 0x38, 0x7e, 0xa2, 0x22, 0x15, 0x10, 0x1c, 0x0, 0x1e, 0x84, 0xff, 0x8d, 0x95, 0x23, 0xf9, 0x1b, - 0x3b, 0xe, 0xbb, 0x9a, 0x2a, 0x79, 0x17, 0xbf, 0xe8, 0x44, 0x62, 0xdb,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x81, 0xce, 0xbd, 0x81, 0x97, 0xe6, 0xfa, 0x5b, 0xb3, 0xfe, - 0xd6, 0x3d, 0x76, 0x1d, 0xe6, 0xed, 0xe3, 0xae, 0x9d, 0x17, 0x1b, 0xbd}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x5d, 0xde, 0x23, 0xde, 0x47, 0xe8, 0x6e, 0xc5, 0x6, - 0xaa, 0x66, 0x8b, 0x9d, 0x9a, 0xb7, 0x7, 0xa7}; - uint8_t bytesprops2[] = {0xdc, 0xda, 0x2c, 0x88, 0xdb, 0x23, 0x34, 0x64, 0x8f, 0xfa, 0xfd, 0xfb, 0xda, 0x1c, 0x6}; - uint8_t bytesprops1[] = {0xdd, 0x10, 0x92, 0x29, 0xba, 0x88, 0x37, 0xe8}; - uint8_t bytesprops3[] = {0xa1, 0x19, 0x5f, 0x7f, 0xc6, 0x9f, 0x69, 0xa4, 0x65, 0xad, 0xa1, 0x23, - 0xf, 0xfc, 0xd8, 0x2, 0x25, 0xc6, 0xb2, 0x49, 0x6a, 0x38, 0x7e, 0xa2}; - uint8_t bytesprops4[] = {0x84, 0xff, 0x8d, 0x95, 0x23, 0xf9, 0x1b, 0x3b, 0xe, 0xbb, 0x9a, 0x2a, 0x79, 0x17, 0xbf, - 0xe8, 0x44, 0x62, 0xdb, 0x10, 0x49, 0x4a, 0x74, 0x72, 0x83, 0x51, 0x6b, 0xf7, 0x10, 0xa9}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops5[] = {0xa1, 0xa0, 0x3e, 0x49, 0xfa, 0x66, 0xae, 0xe, 0xcd, 0x8, 0x1b, 0x44, 0x40, 0x2, 0x62, - 0xd8, 0x7b, 0x76, 0xc, 0x54, 0xf8, 0x20, 0x24, 0x45, 0xc4, 0xb2, 0xcb, 0x34, 0x3c}; - uint8_t bytesprops8[] = {0xc5, 0x2f, 0x26, 0x34, 0xa3, 0x61, 0x48, 0x77, 0xfa, 0x53, 0x91, - 0x35, 0x29, 0x1, 0xcc, 0xf0, 0xb6, 0xd1, 0x1, 0x91, 0xa9}; - uint8_t bytesprops7[] = {0x3e, 0xaa, 0x1c, 0xc1, 0xcd, 0x47, 0x53, 0xd1, - 0xd3, 0xf7, 0x68, 0x19, 0x10, 0x57, 0xe2, 0x9d}; - uint8_t bytesprops9[] = {0x93, 0x93, 0x59, 0xf3, 0xe8, 0x39, 0x31, 0x66, 0x6a, 0x3b, 0xb8, 0xf3, 0x87, 0x33, 0x95, - 0x26, 0x5f, 0xae, 0x4c, 0x1b, 0xcb, 0x6e, 0x34, 0x39, 0xce, 0xc6, 0x93, 0x27, 0x77, 0xc5}; - uint8_t bytesprops10[] = {0xa2, 0xfb, 0x2c, 0xce, 0xb2, 0xf9, 0x74, 0x52, 0xb4, 0x7d, 0xe8, 0xb2, - 0x33, 0x62, 0x30, 0x75, 0xc7, 0x5, 0x43, 0x1d, 0x29, 0xa9, 0xc6}; +// UnsubscribeRequest 32178 +// ["k\238\167\&3}\189\230\213?\DC3gW\142\236\196\STX\221\176\151\150\233","\174\208{E\236","&\174#!)\239\207\EOT\192Rr\155\145","\239\248\168\STXO\\~\184\&3\RS'*l\DLE\246\168^\a\173\137\&2\139G\SYN\218\170\152ELh","\206N\152\&2x\DC1\205\128\249\189\CAN\200_\228\162\207\RS\149"] +// [PropContentType "_B\STX#\201\223V\215:7P\211q\STX\170t\SI\158",PropRequestProblemInformation +// 63,PropResponseInformation "\228\252\173",PropReceiveMaximum 22471,PropServerKeepAlive 3410,PropTopicAliasMaximum +// 16631,PropUserProperty "\160\238\190\135\&5A5\DC1\165\160*U\CANm\219\142N}\SYN\n\SO\CAN\142\212\129\153u\136\152\166" +// "Q\150\242\210\142X\RS\192\ETBg\EOT\166\134\248\&8Wu\255\ACK\254\169_",PropRetainAvailable 249,PropTopicAlias +// 2742,PropMessageExpiryInterval 1062,PropServerReference +// "\149:\172\&6\226\221\243pn\nP\222\241t{\192",PropSharedSubscriptionAvailable 98,PropWillDelayInterval 4817] +TEST(Unsubscribe5QCTest, Encode11) { + uint8_t pkt[] = {0xa2, 0xe8, 0x1, 0x7d, 0xb2, 0x83, 0x1, 0x3, 0x0, 0x12, 0x5f, 0x42, 0x2, 0x23, 0xc9, 0xdf, 0x56, + 0xd7, 0x3a, 0x37, 0x50, 0xd3, 0x71, 0x2, 0xaa, 0x74, 0xf, 0x9e, 0x17, 0x3f, 0x1a, 0x0, 0x3, 0xe4, + 0xfc, 0xad, 0x21, 0x57, 0xc7, 0x13, 0xd, 0x52, 0x22, 0x40, 0xf7, 0x26, 0x0, 0x1e, 0xa0, 0xee, 0xbe, + 0x87, 0x35, 0x41, 0x35, 0x11, 0xa5, 0xa0, 0x2a, 0x55, 0x18, 0x6d, 0xdb, 0x8e, 0x4e, 0x7d, 0x16, 0xa, + 0xe, 0x18, 0x8e, 0xd4, 0x81, 0x99, 0x75, 0x88, 0x98, 0xa6, 0x0, 0x16, 0x51, 0x96, 0xf2, 0xd2, 0x8e, + 0x58, 0x1e, 0xc0, 0x17, 0x67, 0x4, 0xa6, 0x86, 0xf8, 0x38, 0x57, 0x75, 0xff, 0x6, 0xfe, 0xa9, 0x5f, + 0x25, 0xf9, 0x23, 0xa, 0xb6, 0x2, 0x0, 0x0, 0x4, 0x26, 0x1c, 0x0, 0x10, 0x95, 0x3a, 0xac, 0x36, + 0xe2, 0xdd, 0xf3, 0x70, 0x6e, 0xa, 0x50, 0xde, 0xf1, 0x74, 0x7b, 0xc0, 0x2a, 0x62, 0x18, 0x0, 0x0, + 0x12, 0xd1, 0x0, 0x15, 0x6b, 0xee, 0xa7, 0x33, 0x7d, 0xbd, 0xe6, 0xd5, 0x3f, 0x13, 0x67, 0x57, 0x8e, + 0xec, 0xc4, 0x2, 0xdd, 0xb0, 0x97, 0x96, 0xe9, 0x0, 0x5, 0xae, 0xd0, 0x7b, 0x45, 0xec, 0x0, 0xd, + 0x26, 0xae, 0x23, 0x21, 0x29, 0xef, 0xcf, 0x4, 0xc0, 0x52, 0x72, 0x9b, 0x91, 0x0, 0x1e, 0xef, 0xf8, + 0xa8, 0x2, 0x4f, 0x5c, 0x7e, 0xb8, 0x33, 0x1e, 0x27, 0x2a, 0x6c, 0x10, 0xf6, 0xa8, 0x5e, 0x7, 0xad, + 0x89, 0x32, 0x8b, 0x47, 0x16, 0xda, 0xaa, 0x98, 0x45, 0x4c, 0x68, 0x0, 0x12, 0xce, 0x4e, 0x98, 0x32, + 0x78, 0x11, 0xcd, 0x80, 0xf9, 0xbd, 0x18, 0xc8, 0x5f, 0xe4, 0xa2, 0xcf, 0x1e, 0x95}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x5f, 0x42, 0x2, 0x23, 0xc9, 0xdf, 0x56, 0xd7, 0x3a, + 0x37, 0x50, 0xd3, 0x71, 0x2, 0xaa, 0x74, 0xf, 0x9e}; + uint8_t bytesprops1[] = {0xe4, 0xfc, 0xad}; + uint8_t bytesprops3[] = {0x51, 0x96, 0xf2, 0xd2, 0x8e, 0x58, 0x1e, 0xc0, 0x17, 0x67, 0x4, + 0xa6, 0x86, 0xf8, 0x38, 0x57, 0x75, 0xff, 0x6, 0xfe, 0xa9, 0x5f}; + uint8_t bytesprops2[] = {0xa0, 0xee, 0xbe, 0x87, 0x35, 0x41, 0x35, 0x11, 0xa5, 0xa0, 0x2a, 0x55, 0x18, 0x6d, 0xdb, + 0x8e, 0x4e, 0x7d, 0x16, 0xa, 0xe, 0x18, 0x8e, 0xd4, 0x81, 0x99, 0x75, 0x88, 0x98, 0xa6}; + uint8_t bytesprops4[] = {0x95, 0x3a, 0xac, 0x36, 0xe2, 0xdd, 0xf3, 0x70, + 0x6e, 0xa, 0x50, 0xde, 0xf1, 0x74, 0x7b, 0xc0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops1}, .v = {15, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5392}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6076}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30910}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12856}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32229}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11092}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops5}, .v = {0, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops7}, .v = {21, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13776}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22471}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3410}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16631}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops2}, .v = {22, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2742}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1062}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4817}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xf7, 0x24, 0xe, 0x63, 0x7a, 0x9b, 0x23, 0x81, 0xce, 0xbd, - 0x81, 0x97, 0xe6, 0xfa, 0x5b, 0xb3, 0xfe, 0xd6, 0x3d, 0x76, - 0x1d, 0xe6, 0xed, 0xe3, 0xae, 0x9d, 0x17, 0x1b, 0xbd}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x6b, 0xee, 0xa7, 0x33, 0x7d, 0xbd, 0xe6, 0xd5, 0x3f, 0x13, 0x67, + 0x57, 0x8e, 0xec, 0xc4, 0x2, 0xdd, 0xb0, 0x97, 0x96, 0xe9}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xae, 0xd0, 0x7b, 0x45, 0xec}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x26, 0xae, 0x23, 0x21, 0x29, 0xef, 0xcf, 0x4, 0xc0, 0x52, 0x72, 0x9b, 0x91}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xef, 0xf8, 0xa8, 0x2, 0x4f, 0x5c, 0x7e, 0xb8, 0x33, 0x1e, + 0x27, 0x2a, 0x6c, 0x10, 0xf6, 0xa8, 0x5e, 0x7, 0xad, 0x89, + 0x32, 0x8b, 0x47, 0x16, 0xda, 0xaa, 0x98, 0x45, 0x4c, 0x68}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xce, 0x4e, 0x98, 0x32, 0x78, 0x11, 0xcd, 0x80, 0xf9, + 0xbd, 0x18, 0xc8, 0x5f, 0xe4, 0xa2, 0xcf, 0x1e, 0x95}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20314, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32178, 5, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 29664 -// ["\214i\176\156X)\134(\251ux\210\240\DC1\SUB\200\219\EM\219l\213\170B","=\197\235\163\&1\EM\ENQ\255\181\143\201\171vu_o","6\134~W\204","7\223'\b\224\232u","\166v\184[x","z\n\135.Z\170\&9\208\249\231|\132",":1\229C\168\137","7\181\161\220\150\219:\219\171i\226u\150\195`\169","\223\233\205\n\174\ETB\193\ETB\v\255\&0\137u\158\136D\201\&1","\EMX\246C\131J -// \242>:\SOH\164"] [PropWillDelayInterval 13866,PropSharedSubscriptionAvailable 154,PropSubscriptionIdentifier -// 27,PropSessionExpiryInterval 26200,PropAuthenticationMethod -// "\136f\214T5\GSH\SI\148\188\205\247u\ETX\171\ESC\STX\245N\SOH5Ib(\222",PropRequestResponseInformation -// 65,PropReceiveMaximum 24317] -TEST(Unsubscribe5QCTest, Encode5) { - uint8_t pkt[] = {0xa2, 0xbe, 0x1, 0x73, 0xe0, 0x2f, 0x18, 0x0, 0x0, 0x36, 0x2a, 0x2a, 0x9a, 0xb, 0x1b, 0x11, 0x0, - 0x0, 0x66, 0x58, 0x15, 0x0, 0x19, 0x88, 0x66, 0xd6, 0x54, 0x35, 0x1d, 0x48, 0xf, 0x94, 0xbc, 0xcd, - 0xf7, 0x75, 0x3, 0xab, 0x1b, 0x2, 0xf5, 0x4e, 0x1, 0x35, 0x49, 0x62, 0x28, 0xde, 0x19, 0x41, 0x21, - 0x5e, 0xfd, 0x0, 0x17, 0xd6, 0x69, 0xb0, 0x9c, 0x58, 0x29, 0x86, 0x28, 0xfb, 0x75, 0x78, 0xd2, 0xf0, - 0x11, 0x1a, 0xc8, 0xdb, 0x19, 0xdb, 0x6c, 0xd5, 0xaa, 0x42, 0x0, 0x10, 0x3d, 0xc5, 0xeb, 0xa3, 0x31, - 0x19, 0x5, 0xff, 0xb5, 0x8f, 0xc9, 0xab, 0x76, 0x75, 0x5f, 0x6f, 0x0, 0x5, 0x36, 0x86, 0x7e, 0x57, - 0xcc, 0x0, 0x7, 0x37, 0xdf, 0x27, 0x8, 0xe0, 0xe8, 0x75, 0x0, 0x5, 0xa6, 0x76, 0xb8, 0x5b, 0x78, - 0x0, 0xc, 0x7a, 0xa, 0x87, 0x2e, 0x5a, 0xaa, 0x39, 0xd0, 0xf9, 0xe7, 0x7c, 0x84, 0x0, 0x6, 0x3a, - 0x31, 0xe5, 0x43, 0xa8, 0x89, 0x0, 0x10, 0x37, 0xb5, 0xa1, 0xdc, 0x96, 0xdb, 0x3a, 0xdb, 0xab, 0x69, - 0xe2, 0x75, 0x96, 0xc3, 0x60, 0xa9, 0x0, 0x12, 0xdf, 0xe9, 0xcd, 0xa, 0xae, 0x17, 0xc1, 0x17, 0xb, - 0xff, 0x30, 0x89, 0x75, 0x9e, 0x88, 0x44, 0xc9, 0x31, 0x0, 0xc, 0x19, 0x58, 0xf6, 0x43, 0x83, 0x4a, - 0x20, 0xf2, 0x3e, 0x3a, 0x1, 0xa4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x88, 0x66, 0xd6, 0x54, 0x35, 0x1d, 0x48, 0xf, 0x94, 0xbc, 0xcd, 0xf7, 0x75, - 0x3, 0xab, 0x1b, 0x2, 0xf5, 0x4e, 0x1, 0x35, 0x49, 0x62, 0x28, 0xde}; +// UnsubscribeRequest 17769 ["\192d\222\&2>\213\ESC_d\SUB\DC1N"] [PropMessageExpiryInterval 26793,PropMaximumPacketSize +// 6142,PropWillDelayInterval 30684,PropWillDelayInterval 12528,PropRequestProblemInformation +// 12,PropSharedSubscriptionAvailable 30,PropRequestResponseInformation 168,PropMessageExpiryInterval +// 9680,PropWillDelayInterval 2551,PropMaximumPacketSize 18149,PropServerReference +// "\139$\196\137",PropMessageExpiryInterval 27206,PropUserProperty "\NAKz\220\&5PE\229\206I\222\158,\195\230\t\t\210" +// "\DLEp\\\SOH\233r\"\n,\248:"] +TEST(Unsubscribe5QCTest, Encode12) { + uint8_t pkt[] = {0xa2, 0x67, 0x45, 0x69, 0x56, 0x2, 0x0, 0x0, 0x68, 0xa9, 0x27, 0x0, 0x0, 0x17, 0xfe, + 0x18, 0x0, 0x0, 0x77, 0xdc, 0x18, 0x0, 0x0, 0x30, 0xf0, 0x17, 0xc, 0x2a, 0x1e, 0x19, + 0xa8, 0x2, 0x0, 0x0, 0x25, 0xd0, 0x18, 0x0, 0x0, 0x9, 0xf7, 0x27, 0x0, 0x0, 0x46, + 0xe5, 0x1c, 0x0, 0x4, 0x8b, 0x24, 0xc4, 0x89, 0x2, 0x0, 0x0, 0x6a, 0x46, 0x26, 0x0, + 0x11, 0x15, 0x7a, 0xdc, 0x35, 0x50, 0x45, 0xe5, 0xce, 0x49, 0xde, 0x9e, 0x2c, 0xc3, 0xe6, + 0x9, 0x9, 0xd2, 0x0, 0xb, 0x10, 0x70, 0x5c, 0x1, 0xe9, 0x72, 0x22, 0xa, 0x2c, 0xf8, + 0x3a, 0x0, 0xc, 0xc0, 0x64, 0xde, 0x32, 0x3e, 0xd5, 0x1b, 0x5f, 0x64, 0x1a, 0x11, 0x4e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x8b, 0x24, 0xc4, 0x89}; + uint8_t bytesprops2[] = {0x10, 0x70, 0x5c, 0x1, 0xe9, 0x72, 0x22, 0xa, 0x2c, 0xf8, 0x3a}; + uint8_t bytesprops1[] = {0x15, 0x7a, 0xdc, 0x35, 0x50, 0x45, 0xe5, 0xce, 0x49, + 0xde, 0x9e, 0x2c, 0xc3, 0xe6, 0x9, 0x9, 0xd2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13866}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26200}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24317}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26793}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6142}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30684}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12528}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9680}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2551}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18149}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27206}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd6, 0x69, 0xb0, 0x9c, 0x58, 0x29, 0x86, 0x28, 0xfb, 0x75, 0x78, 0xd2, - 0xf0, 0x11, 0x1a, 0xc8, 0xdb, 0x19, 0xdb, 0x6c, 0xd5, 0xaa, 0x42}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xc0, 0x64, 0xde, 0x32, 0x3e, 0xd5, 0x1b, 0x5f, 0x64, 0x1a, 0x11, 0x4e}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3d, 0xc5, 0xeb, 0xa3, 0x31, 0x19, 0x5, 0xff, - 0xb5, 0x8f, 0xc9, 0xab, 0x76, 0x75, 0x5f, 0x6f}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x36, 0x86, 0x7e, 0x57, 0xcc}; - lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x37, 0xdf, 0x27, 0x8, 0xe0, 0xe8, 0x75}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa6, 0x76, 0xb8, 0x5b, 0x78}; - lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7a, 0xa, 0x87, 0x2e, 0x5a, 0xaa, 0x39, 0xd0, 0xf9, 0xe7, 0x7c, 0x84}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3a, 0x31, 0xe5, 0x43, 0xa8, 0x89}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x37, 0xb5, 0xa1, 0xdc, 0x96, 0xdb, 0x3a, 0xdb, - 0xab, 0x69, 0xe2, 0x75, 0x96, 0xc3, 0x60, 0xa9}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xdf, 0xe9, 0xcd, 0xa, 0xae, 0x17, 0xc1, 0x17, 0xb, - 0xff, 0x30, 0x89, 0x75, 0x9e, 0x88, 0x44, 0xc9, 0x31}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x19, 0x58, 0xf6, 0x43, 0x83, 0x4a, 0x20, 0xf2, 0x3e, 0x3a, 0x1, 0xa4}; - lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29664, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17769, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 28866 ["\ACK"] [PropAuthenticationData "\SI",PropMessageExpiryInterval -// 6437,PropPayloadFormatIndicator 115,PropSharedSubscriptionAvailable 176,PropMaximumQoS 86,PropUserProperty -// "F\148\DC1\254\194\179\208dX\243\151\t\b_\243X\165:\182\231~`\RSxh" "\164\135\153}\DC2.\162*",PropResponseInformation -// "X\220L\204@\140E\ACKo\235?\250\r\194\178h\230",PropServerReference "\220\194\f\146;",PropAssignedClientIdentifier -// "\230\"\CANp}\224\&4\132V\US\NUL+\133\168\193",PropTopicAlias 19678,PropMaximumQoS -// 88,PropSubscriptionIdentifierAvailable 19,PropSharedSubscriptionAvailable 13,PropRetainAvailable -// 199,PropResponseTopic "M\199m\129\254\222;3gj\GS","\192\221\160N\167e\"R<\142",""] +// [PropRequestProblemInformation 48,PropSharedSubscriptionAvailable 181,PropRequestProblemInformation +// 98,PropMaximumPacketSize 23754,PropMaximumPacketSize 5686,PropTopicAlias 13579,PropRequestProblemInformation +// 156,PropMaximumPacketSize 28901,PropAssignedClientIdentifier "$m\243",PropServerKeepAlive 735,PropWillDelayInterval +// 24039,PropCorrelationData "d\190/\128%$\147\136\193U\141%\223\ENQ\218r\CAN",PropRetainAvailable 178,PropTopicAlias +// 30758,PropMessageExpiryInterval 10917,PropWildcardSubscriptionAvailable 54,PropContentType +// "\236\179^\ETB\151\159\FSd&I\139"] +TEST(Unsubscribe5QCTest, Encode16) { uint8_t pkt[] = { - 0xa2, 0x8a, 0x4, 0x4f, 0x78, 0xfc, 0x2, 0x2, 0x0, 0x0, 0x78, 0x3a, 0x26, 0x0, 0x7, 0xc1, 0x23, 0xb, 0x14, - 0xeb, 0x1b, 0x3c, 0x0, 0x13, 0x11, 0xe, 0xde, 0x8b, 0x67, 0x11, 0x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0xe4, 0x37, 0x5d, 0x4, 0x4d, 0xa4, 0xce, 0xab, 0x49, 0x49, 0x4e, 0x5b, 0x57, - 0x0, 0x18, 0xea, 0xfc, 0xc3, 0xd6, 0xc9, 0x2e, 0xdf, 0xa0, 0x1c, 0x78, 0xcc, 0xe5, 0xed, 0x7b, 0x2d, 0x3c, 0x72, - 0xf9, 0xeb, 0xe4, 0xe9, 0x24, 0xd1, 0xc0, 0x0, 0xc, 0x2b, 0x83, 0xc1, 0x61, 0x37, 0x14, 0xd9, 0xfe, 0xc3, 0x27, - 0x55, 0x86, 0x0, 0xe, 0xd1, 0x40, 0xd1, 0x94, 0xe8, 0xe9, 0xad, 0x4b, 0xa7, 0xf5, 0x2f, 0xa2, 0xcf, 0xb0, 0x0, - 0x9, 0x12, 0xf, 0x2c, 0x43, 0xb2, 0xf6, 0x8, 0x84, 0x3, 0x0, 0x7, 0x69, 0xe4, 0xa3, 0x4, 0x48, 0xf4, 0xa9, - 0x0, 0x1d, 0x1a, 0xa2, 0xf9, 0xd3, 0x9a, 0x2d, 0xc2, 0xd4, 0xf6, 0x7a, 0xd7, 0x61, 0xce, 0x6c, 0xd3, 0xfd, 0xec, - 0x96, 0xb5, 0x5a, 0x6c, 0x95, 0xc1, 0x9e, 0xc6, 0xad, 0x48, 0xe2, 0x41}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x11, 0xe, 0xde, 0x8b, 0x67, 0x11, 0x46, 0x4f, 0x54, 0xc5, - 0x88, 0x90, 0x1, 0xcf, 0xfd, 0xa9, 0x74, 0x26, 0x73}; - uint8_t bytesprops0[] = {0xc1, 0x23, 0xb, 0x14, 0xeb, 0x1b, 0x3c}; - uint8_t bytesprops2[] = {0xe3, 0x9e, 0x4d, 0x19, 0x64, 0x6d, 0xbd, 0xb3, 0x13, 0x5e, 0x4a, 0xdb, 0x59, - 0x9e, 0xbc, 0x97, 0x2f, 0x52, 0x9b, 0xb1, 0xfa, 0xaa, 0x7e, 0xdc, 0xe0, 0x71}; - uint8_t bytesprops3[] = {0x10, 0xaa, 0x2c, 0xd6, 0x5c, 0xfa, 0xb0, 0x4e, 0x4f, 0x17, 0xe7, 0x13, 0x90, 0x14, 0x45, - 0x39, 0x2e, 0x93, 0x20, 0x17, 0xf0, 0x89, 0x3d, 0xaf, 0x89, 0xd8, 0x54, 0x4b, 0xa4, 0x16}; - uint8_t bytesprops4[] = {0xf3, 0x2, 0x51, 0xe4, 0x20, 0xc7, 0x90, 0x8f, 0xa3, - 0x28, 0x95, 0x88, 0x56, 0x16, 0x29, 0x30, 0xd8, 0x8f}; - uint8_t bytesprops5[] = {0xc5, 0xb6}; - uint8_t bytesprops6[] = {0x8e, 0xbb, 0x10, 0x7a, 0x29, 0x1, 0xaa, 0xf2, 0xc7, 0xa6, 0x49, 0x54, 0x90, 0xd2, 0x76}; - uint8_t bytesprops7[] = {0xb, 0x4a, 0x31, 0xae, 0x58, 0xa0}; - uint8_t bytesprops8[] = {0x69, 0xa4, 0x11, 0xbf, 0x20, 0xa1, 0x14, 0x15, 0x69, 0x5c, 0x51, 0x17, 0xa9, 0x2a, 0xf5}; - uint8_t bytesprops10[] = {0xb2, 0x31, 0x46, 0xff, 0x72, 0xbb}; - uint8_t bytesprops9[] = {0x40, 0x18, 0xe6, 0xe5, 0x16, 0x43, 0x89, 0xab, 0x36, - 0x8e, 0x44, 0x78, 0x87, 0x92, 0x25, 0x4d, 0x6}; - uint8_t bytesprops11[] = {0x72, 0x34, 0xfe, 0xe0, 0x39, 0xaa, 0x3d, 0xd8, 0xa, 0x94, 0xd7, - 0xd4, 0xad, 0xf7, 0x6e, 0x1e, 0x10, 0x79, 0x3, 0x99, 0x47}; - uint8_t bytesprops12[] = {0x18, 0xf5, 0x67, 0x57, 0x65, 0xdd, 0xa1, 0x75, 0x3f, 0xee, 0x4b, 0xdb, - 0x16, 0xbb, 0xaf, 0x6f, 0x13, 0xfa, 0x24, 0x6c, 0x40, 0x5c, 0xaa}; - uint8_t bytesprops13[] = {0x34, 0xda, 0x50, 0x8e, 0x2e, 0x79, 0x20, 0x9e, 0xfc, 0x85, - 0xde, 0xe9, 0xac, 0xfc, 0xf7, 0x33, 0x66, 0x9d, 0x86, 0x5f}; - uint8_t bytesprops14[] = {0xc1, 0x99, 0x6c, 0xeb, 0x27, 0x60, 0x58, 0x23, 0x43, 0xbe, 0x11}; - uint8_t bytesprops15[] = {0xb2, 0xcf, 0x63, 0x1c, 0xaf, 0xe0}; - uint8_t bytesprops16[] = {0x38, 0x3, 0x1a, 0x8b, 0x60, 0xa3, 0xd4, 0x9e, 0x7c, 0xf, 0xad, 0xd5, - 0x76, 0xf4, 0x6b, 0xe2, 0xc8, 0x96, 0x51, 0xf7, 0x41, 0x93, 0x91}; - uint8_t bytesprops17[] = {0x48, 0xa0, 0x7a, 0x95, 0x23, 0xbb, 0xf5, 0x3, 0x74, 0xb2, 0x59, 0xaa, 0xc5, - 0x6, 0xa0, 0xbf, 0x1a, 0x50, 0xb0, 0xa0, 0xec, 0xda, 0x70, 0x49, 0x68}; + 0xa2, 0x8e, 0x2, 0x1a, 0x73, 0x56, 0x17, 0x30, 0x2a, 0xb5, 0x17, 0x62, 0x27, 0x0, 0x0, 0x5c, 0xca, 0x27, 0x0, + 0x0, 0x16, 0x36, 0x23, 0x35, 0xb, 0x17, 0x9c, 0x27, 0x0, 0x0, 0x70, 0xe5, 0x12, 0x0, 0x3, 0x24, 0x6d, 0xf3, + 0x13, 0x2, 0xdf, 0x18, 0x0, 0x0, 0x5d, 0xe7, 0x9, 0x0, 0x11, 0x64, 0xbe, 0x2f, 0x80, 0x25, 0x24, 0x93, 0x88, + 0xc1, 0x55, 0x8d, 0x25, 0xdf, 0x5, 0xda, 0x72, 0x18, 0x25, 0xb2, 0x23, 0x78, 0x26, 0x2, 0x0, 0x0, 0x2a, 0xa5, + 0x28, 0x36, 0x3, 0x0, 0xb, 0xec, 0xb3, 0x5e, 0x17, 0x97, 0x9f, 0x1c, 0x64, 0x26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t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x24, 0x6d, 0xf3}; + uint8_t bytesprops1[] = {0x64, 0xbe, 0x2f, 0x80, 0x25, 0x24, 0x93, 0x88, 0xc1, + 0x55, 0x8d, 0x25, 0xdf, 0x5, 0xda, 0x72, 0x18}; + uint8_t bytesprops2[] = {0xec, 0xb3, 0x5e, 0x17, 0x97, 0x9f, 0x1c, 0x64, 0x26, 0x49, 0x8b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30778}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops0}, .v = {19, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32647}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops9}, .v = {6, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2273}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4340}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14649}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops15}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops16}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops17}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10260}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23754}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5686}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13579}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28901}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 735}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24039}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30758}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10917}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x84, 0x26, 0xbd, 0x53, 0x6f, 0xcf, 0x1f, 0xda, 0x56, 0x47, - 0x6f, 0xbe, 0xff, 0x75, 0xdf, 0xc0, 0xe4, 0x37, 0x5d, 0x4, - 0x4d, 0xa4, 0xce, 0xab, 0x49, 0x49, 0x4e, 0x5b, 0x57}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x87, 0x1f, 0xdb, 0x2f, 0xa3, 0x2b, 0x1c, 0x2d}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xea, 0xfc, 0xc3, 0xd6, 0xc9, 0x2e, 0xdf, 0xa0, 0x1c, 0x78, 0xcc, 0xe5, - 0xed, 0x7b, 0x2d, 0x3c, 0x72, 0xf9, 0xeb, 0xe4, 0xe9, 0x24, 0xd1, 0xc0}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa1, 0x88, 0x83, 0x59, 0x18, 0xe6, 0x74, 0x26, 0xc4, 0xae, + 0x34, 0x2d, 0xc, 0x81, 0x9b, 0xbd, 0x4e, 0xd3, 0x63, 0xe9, + 0xeb, 0x71, 0x8a, 0xe3, 0xfa, 0x4f, 0x94, 0xde, 0x33}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2b, 0x83, 0xc1, 0x61, 0x37, 0x14, 0xd9, 0xfe, 0xc3, 0x27, 0x55, 0x86}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4a, 0x4a, 0x34, 0x7f, 0xf7, 0x7b, 0xbd, 0xa6, 0x10, 0x35, + 0xf1, 0x2d, 0xc3, 0x8d, 0x58, 0x9, 0x4e, 0x8a, 0xf8, 0xab, + 0xf7, 0x28, 0xca, 0x5a, 0xe7, 0x36, 0x43, 0xff}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd1, 0x40, 0xd1, 0x94, 0xe8, 0xe9, 0xad, - 0x4b, 0xa7, 0xf5, 0x2f, 0xa2, 0xcf, 0xb0}; - lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xb6, 0xd, 0x90, 0x42, 0x5b, 0xe9, 0x15, 0xc2, + 0xb3, 0x7b, 0xb1, 0x36, 0xce, 0x6f, 0xac, 0x68}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x12, 0xf, 0x2c, 0x43, 0xb2, 0xf6, 0x8, 0x84, 0x3}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0}; + lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x69, 0xe4, 0xa3, 0x4, 0x48, 0xf4, 0xa9}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xa3, 0x2c, 0x2b, 0x6e, 0xa8, 0x4d, 0xe, 0xb8, 0xb4}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x1a, 0xa2, 0xf9, 0xd3, 0x9a, 0x2d, 0xc2, 0xd4, 0xf6, 0x7a, - 0xd7, 0x61, 0xce, 0x6c, 0xd3, 0xfd, 0xec, 0x96, 0xb5, 0x5a, - 0x6c, 0x95, 0xc1, 0x9e, 0xc6, 0xad, 0x48, 0xe2, 0x41}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x3f, 0x92, 0x58, 0x2b, 0x4c, 0x77, 0xbf, 0x19, 0xd1, 0x9, 0xae, 0xd3, 0xa0, + 0x73, 0xc0, 0x46, 0x61, 0xed, 0xc3, 0xd4, 0x31, 0x44, 0x59, 0x83, 0xa3}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x7a, 0xff, 0xd5, 0x1a, 0x76, 0x51, 0xec, 0x4d, 0x98, 0xd0, 0x95, 0x68}; + lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x89, 0xed, 0x83, 0xc6, 0x58, 0x44, 0xe, 0x5e, 0x50, 0xcf, 0xe3, + 0x92, 0xf8, 0xf0, 0xe3, 0x7d, 0x26, 0x8d, 0x8e, 0x76, 0x3e, 0x1d}; + lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xc0, 0xdd, 0xa0, 0x4e, 0xa7, 0x65, 0x22, 0x52, 0x3c, 0x8e}; + lwmqtt_string_t topic_filter_s9 = {10, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20344, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6771, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 17201 -// ["E9\225\244J\192JB\f\160(lt\188^bi","\ETB@\\{\134R\230\250\NAK\128\&8\150\248\143\251*\215ST\DC2$B\181","\188nV\144\253\231\229a\DC3]j4X\165\138\216a\227\242","\GS\140A\175\EMk\248\170\177\234\NAK\223\DEL\251\244\&7y\FS","Nw\187\SUBYj\DC2\239\167\132\159{","\221\ESCwC\170\ESC3\SYN\247\206"] -// [PropWildcardSubscriptionAvailable 205,PropResponseTopic -// "}\229\DC2Y[\239;\231\254\133v\EM\138O\226No",PropCorrelationData -// "\170Hr\170\199\SO\161\149Dy\229\248`\190\146\180\178w\178\DC4\222\226\ETXJ\253\144\DLE\163\DC2",PropMaximumQoS -// 231,PropUserProperty "\CAN\RS-\219\177\240\179d}\232\136\154\137\183\222nT}U\210\194" -// "\173\DC11\196j\167\156\255\a\DEL\140\245\243",PropSubscriptionIdentifier 28,PropMessageExpiryInterval -// 9872,PropUserProperty -// "\130\157\174\180\156\221\SOH\228\247Gl\SUB\194\133g\134P\NAK\223-\239[\199\138\128\224\NUL\178\\" -// "Z\213\219y\228\SOH\255",PropRequestProblemInformation 96,PropWillDelayInterval 30997,PropUserProperty -// "\139\240O\202\STX\238\217**\ESC" "\136r\228\199\191\162M.\191\133\160\246g:P\190\168 -// 8\137\155",PropAuthenticationData "w",PropSharedSubscriptionAvailable 215,PropSessionExpiryInterval -// 31240,PropRequestProblemInformation 153,PropMessageExpiryInterval 10229,PropCorrelationData -// "f\245EK7\247\194\171\143\163\v3P\169Q\178\212\254&\244^\204\NAK",PropAssignedClientIdentifier -// "V\170\209\&8b\190\165Rs\EM",PropServerKeepAlive 16887,PropResponseInformation -// "e\242\128\146\CAN",PropServerReference "\a\240\202\202\230|",PropTopicAlias 8989,PropRequestResponseInformation -// 49,PropSessionExpiryInterval 18001,PropResponseTopic "\129\242C\192\149\151<\197\194\180\187\SUBD\210",PropTopicAlias -// 854,PropSharedSubscriptionAvailable 130,PropRetainAvailable 248,PropMaximumQoS 251] -TEST(Unsubscribe5QCTest, Encode13) { +// UnsubscribeRequest 8587 +// ["^\158\181\192J\FS\249","\248\243\ACK\NULSg}\128\177\154\&2\SUB-\242\GS\229\t\NAK\US\189m\225\230I\FS","\SUB\194\179C\203\152","\244#\152\175\194\153\231\239\ETBD\146Q\248g\246w\143K\194\245\181","\DC4\tIs\155jp\197\SYN'1,G(P\NAK$\163\144\146\159\USY\194M\151\157\255","\236\159","\228\132\130\254\213\173\&1\202\&0\136\135\231\157\167p\199}\139\ETX +// \191\189\168\245\227\DC2}","\233mc\155K\b!\RSu\SUB","t\178\DEL\DELy\240\224\228\141\238\EOT\EM\153;\190\234","\128xS\199\240\228\&0R\vR\180\&3\217\179\162H\189%\192\247\195e\179t\RS\"x\DC1my","\246\ESC\248\136\ETX>\225\204\ACK\136\170\"\v\232\253\219\199=\ACK"] +// [PropMaximumQoS 241,PropServerKeepAlive 10894,PropResponseInformation "\FStN\244\173",PropContentType +// "`\183\173SH\237\225\251",PropResponseInformation "\227\226t\SYN\164\&6F \228\253\ENQ\177\SO\241\209/",PropTopicAlias +// 20782,PropSubscriptionIdentifierAvailable 123,PropWildcardSubscriptionAvailable 79,PropRetainAvailable +// 160,PropServerReference "\195\200\ETX\146\221/d\129h\135\SI+\241i",PropRequestProblemInformation +// 13,PropSessionExpiryInterval 10666,PropAuthenticationMethod +// "\250\"K\169\132\187\RS\252%\146\210\196\DC1Q\144\235\ESC\175\a\CAN=\155\170\157.",PropResponseTopic +// "\232d\215A",PropMaximumPacketSize 3468,PropReceiveMaximum 31173,PropContentType +// "\243\179\216\DC3\b\230",PropContentType "\197\223)\f",PropTopicAliasMaximum 15968,PropMessageExpiryInterval 26426] +TEST(Unsubscribe5QCTest, Encode18) { uint8_t pkt[] = { - 0xa2, 0xb8, 0x1, 0x3, 0xb5, 0x97, 0x1, 0x26, 0x0, 0xc, 0x9e, 0xb8, 0x23, 0xff, 0xf4, 0x3e, 0x2, 0xee, 0xd9, - 0x2a, 0x2a, 0x1b, 0x0, 0x15, 0x88, 0x72, 0xe4, 0xc7, 0xbf, 0xa2, 0x4d, 0x2e, 0xbf, 0x85, 0xa0, 0xf6, 0x67, 0x3a, - 0x50, 0xbe, 0xa8, 0x20, 0x38, 0x89, 0x9b, 0x16, 0x0, 0x1, 0x77, 0x2a, 0xd7, 0x11, 0x0, 0x0, 0x7a, 0x8, 0x17, - 0x99, 0x2, 0x0, 0x0, 0x27, 0xf5, 0x9, 0x0, 0x17, 0x66, 0xf5, 0x45, 0x4b, 0x37, 0xf7, 0xc2, 0xab, 0x8f, 0xa3, - 0xb, 0x33, 0x50, 0xa9, 0x51, 0xb2, 0xd4, 0xfe, 0x26, 0xf4, 0x5e, 0xcc, 0x15, 0x12, 0x0, 0xa, 0x56, 0xaa, 0xd1, - 0x38, 0x62, 0xbe, 0xa5, 0x52, 0x73, 0x19, 0x13, 0x41, 0xf7, 0x1a, 0x0, 0x5, 0x65, 0xf2, 0x80, 0x92, 0x18, 0x1c, - 0x0, 0x6, 0x7, 0xf0, 0xca, 0xca, 0xe6, 0x7c, 0x23, 0x23, 0x1d, 0x19, 0x31, 0x11, 0x0, 0x0, 0x46, 0x51, 0x8, - 0x0, 0xe, 0x81, 0xf2, 0x43, 0xc0, 0x95, 0x97, 0x3c, 0xc5, 0xc2, 0xb4, 0xbb, 0x1a, 0x44, 0xd2, 0x23, 0x3, 0x56, - 0x2a, 0x82, 0x25, 0xf8, 0x24, 0xfb, 0x0, 0x1b, 0x8b, 0x78, 0x56, 0x8e, 0x45, 0x8b, 0x37, 0xb3, 0x54, 0x82, 0xd4, - 0xfa, 0x47, 0xc3, 0x46, 0xc1, 0xfc, 0xfa, 0xca, 0x7b, 0xc4, 0x7a, 0xe4, 0xa4, 0x2, 0x1f, 0xdb}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x88, 0x72, 0xe4, 0xc7, 0xbf, 0xa2, 0x4d, 0x2e, 0xbf, 0x85, 0xa0, - 0xf6, 0x67, 0x3a, 0x50, 0xbe, 0xa8, 0x20, 0x38, 0x89, 0x9b}; - uint8_t bytesprops0[] = {0x9e, 0xb8, 0x23, 0xff, 0xf4, 0x3e, 0x2, 0xee, 0xd9, 0x2a, 0x2a, 0x1b}; - uint8_t bytesprops2[] = {0x77}; - uint8_t bytesprops3[] = {0x66, 0xf5, 0x45, 0x4b, 0x37, 0xf7, 0xc2, 0xab, 0x8f, 0xa3, 0xb, 0x33, - 0x50, 0xa9, 0x51, 0xb2, 0xd4, 0xfe, 0x26, 0xf4, 0x5e, 0xcc, 0x15}; - uint8_t bytesprops4[] = {0x56, 0xaa, 0xd1, 0x38, 0x62, 0xbe, 0xa5, 0x52, 0x73, 0x19}; - uint8_t bytesprops5[] = {0x65, 0xf2, 0x80, 0x92, 0x18}; - uint8_t bytesprops6[] = {0x7, 0xf0, 0xca, 0xca, 0xe6, 0x7c}; - uint8_t bytesprops7[] = {0x81, 0xf2, 0x43, 0xc0, 0x95, 0x97, 0x3c, 0xc5, 0xc2, 0xb4, 0xbb, 0x1a, 0x44, 0xd2}; + 0xa2, 0xe8, 0x2, 0x21, 0x8b, 0x8f, 0x1, 0x24, 0xf1, 0x13, 0x2a, 0x8e, 0x1a, 0x0, 0x5, 0x1c, 0x74, 0x4e, 0xf4, + 0xad, 0x3, 0x0, 0x8, 0x60, 0xb7, 0xad, 0x53, 0x48, 0xed, 0xe1, 0xfb, 0x1a, 0x0, 0x10, 0xe3, 0xe2, 0x74, 0x16, + 0xa4,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a, 0x70, 0xc5, 0x16, + 0x27, 0x31, 0x2c, 0x47, 0x28, 0x50, 0x15, 0x24, 0xa3, 0x90, 0x92, 0x9f, 0x1f, 0x59, 0xc2, 0x4d, 0x97, 0x9d, 0xff, + 0x0, 0x2, 0xec, 0x9f, 0x0, 0x1b, 0xe4, 0x84, 0x82, 0xfe, 0xd5, 0xad, 0x31, 0xca, 0x30, 0x88, 0x87, 0xe7, 0x9d, + 0xa7, 0x70, 0xc7, 0x7d, 0x8b, 0x3, 0x20, 0xbf, 0xbd, 0xa8, 0xf5, 0xe3, 0x12, 0x7d, 0x0, 0xa, 0xe9, 0x6d, 0x63, + 0x9b, 0x4b, 0x8, 0x21, 0x1e, 0x75, 0x1a, 0x0, 0x10, 0x74, 0xb2, 0x7f, 0x7f, 0x79, 0xf0, 0xe0, 0xe4, 0x8d, 0xee, + 0x4, 0x19, 0x99, 0x3b, 0xbe, 0xea, 0x0, 0x1e, 0x80, 0x78, 0x53, 0xc7, 0xf0, 0xe4, 0x30, 0x52, 0xb, 0x52, 0xb4, + 0x33, 0xd9, 0xb3, 0xa2, 0x48, 0xbd, 0x25, 0xc0, 0xf7, 0xc3, 0x65, 0xb3, 0x74, 0x1e, 0x22, 0x78, 0x11, 0x6d, 0x79, + 0x0, 0x13, 0xf6, 0x1b, 0xf8, 0x88, 0x3, 0x3e, 0xe1, 0xcc, 0x6, 0x88, 0xaa, 0x22, 0xb, 0xe8, 0xfd, 0xdb, 0xc7, + 0x3d, 0x6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1c, 0x74, 0x4e, 0xf4, 0xad}; + uint8_t bytesprops1[] = {0x60, 0xb7, 0xad, 0x53, 0x48, 0xed, 0xe1, 0xfb}; + uint8_t bytesprops2[] = {0xe3, 0xe2, 0x74, 0x16, 0xa4, 0x36, 0x46, 0x20, + 0xe4, 0xfd, 0x5, 0xb1, 0xe, 0xf1, 0xd1, 0x2f}; + uint8_t bytesprops3[] = {0xc3, 0xc8, 0x3, 0x92, 0xdd, 0x2f, 0x64, 0x81, 0x68, 0x87, 0xf, 0x2b, 0xf1, 0x69}; + uint8_t bytesprops4[] = {0xfa, 0x22, 0x4b, 0xa9, 0x84, 0xbb, 0x1e, 0xfc, 0x25, 0x92, 0xd2, 0xc4, 0x11, + 0x51, 0x90, 0xeb, 0x1b, 0xaf, 0x7, 0x18, 0x3d, 0x9b, 0xaa, 0x9d, 0x2e}; + uint8_t bytesprops5[] = {0xe8, 0x64, 0xd7, 0x41}; + uint8_t bytesprops6[] = {0xf3, 0xb3, 0xd8, 0x13, 0x8, 0xe6}; + uint8_t bytesprops7[] = {0xc5, 0xdf, 0x29, 0xc}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops0}, .v = {21, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31240}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10229}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16887}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8989}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18001}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 854}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10894}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20782}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10666}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3468}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31173}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15968}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26426}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x8b, 0x78, 0x56, 0x8e, 0x45, 0x8b, 0x37, 0xb3, 0x54, 0x82, 0xd4, 0xfa, 0x47, 0xc3, - 0x46, 0xc1, 0xfc, 0xfa, 0xca, 0x7b, 0xc4, 0x7a, 0xe4, 0xa4, 0x2, 0x1f, 0xdb}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x5e, 0x9e, 0xb5, 0xc0, 0x4a, 0x1c, 0xf9}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xf8, 0xf3, 0x6, 0x0, 0x53, 0x67, 0x7d, 0x80, 0xb1, 0x9a, 0x32, 0x1a, 0x2d, + 0xf2, 0x1d, 0xe5, 0x9, 0x15, 0x1f, 0xbd, 0x6d, 0xe1, 0xe6, 0x49, 0x1c}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x1a, 0xc2, 0xb3, 0x43, 0xcb, 0x98}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xf4, 0x23, 0x98, 0xaf, 0xc2, 0x99, 0xe7, 0xef, 0x17, 0x44, 0x92, + 0x51, 0xf8, 0x67, 0xf6, 0x77, 0x8f, 0x4b, 0xc2, 0xf5, 0xb5}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x14, 0x9, 0x49, 0x73, 0x9b, 0x6a, 0x70, 0xc5, 0x16, 0x27, + 0x31, 0x2c, 0x47, 0x28, 0x50, 0x15, 0x24, 0xa3, 0x90, 0x92, + 0x9f, 0x1f, 0x59, 0xc2, 0x4d, 0x97, 0x9d, 0xff}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xec, 0x9f}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xe4, 0x84, 0x82, 0xfe, 0xd5, 0xad, 0x31, 0xca, 0x30, 0x88, 0x87, 0xe7, 0x9d, 0xa7, + 0x70, 0xc7, 0x7d, 0x8b, 0x3, 0x20, 0xbf, 0xbd, 0xa8, 0xf5, 0xe3, 0x12, 0x7d}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe9, 0x6d, 0x63, 0x9b, 0x4b, 0x8, 0x21, 0x1e, 0x75, 0x1a}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x74, 0xb2, 0x7f, 0x7f, 0x79, 0xf0, 0xe0, 0xe4, + 0x8d, 0xee, 0x4, 0x19, 0x99, 0x3b, 0xbe, 0xea}; + lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x80, 0x78, 0x53, 0xc7, 0xf0, 0xe4, 0x30, 0x52, 0xb, 0x52, + 0xb4, 0x33, 0xd9, 0xb3, 0xa2, 0x48, 0xbd, 0x25, 0xc0, 0xf7, + 0xc3, 0x65, 0xb3, 0x74, 0x1e, 0x22, 0x78, 0x11, 0x6d, 0x79}; + lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xf6, 0x1b, 0xf8, 0x88, 0x3, 0x3e, 0xe1, 0xcc, 0x6, 0x88, + 0xaa, 0x22, 0xb, 0xe8, 0xfd, 0xdb, 0xc7, 0x3d, 0x6}; + lwmqtt_string_t topic_filter_s10 = {19, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 949, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8587, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5184 -// ["\160\156\&1\155\217\US\192\233A\170\&6f\208I","\ENQ\r\NAK\179\221\CAN\215\212\191\237F\250\ESC'\255a\132\132W>\231","\169\255\rPZLI'\SO\SYN\158\226\192\203\CAN[\136\168\185","\227Jq\248\&3\215\SYN=\200\169(\221\NAKe0>\147\156pZ\131e\165\ETB\252\152d\245\133\174","\192\144\SI\216f\194_\160\160'\US}\195VY\222\235\217\186%\198T]\247","\239Z\211\232","J\184i\172\147\218PR\190~\at/\158\152T\135\"\144\RS3\139","\167\176.\244x\254S\EOT!N\202z\154T\210\DC3G\DLE\130","\194","\165\208\135\190\165G"] -// [PropRequestResponseInformation 213,PropRequestResponseInformation 171,PropWillDelayInterval -// 6198,PropSubscriptionIdentifier 3] -TEST(Unsubscribe5QCTest, Encode14) { - uint8_t pkt[] = {0xa2, 0xc2, 0x1, 0x14, 0x40, 0xb, 0x19, 0xd5, 0x19, 0xab, 0x18, 0x0, 0x0, 0x18, 0x36, 0xb, 0x3, - 0x0, 0xe, 0xa0, 0x9c, 0x31, 0x9b, 0xd9, 0x1f, 0xc0, 0xe9, 0x41, 0xaa, 0x36, 0x66, 0xd0, 0x49, 0x0, - 0x15, 0x5, 0xd, 0x15, 0xb3, 0xdd, 0x18, 0xd7, 0xd4, 0xbf, 0xed, 0x46, 0xfa, 0x1b, 0x27, 0xff, 0x61, - 0x84, 0x84, 0x57, 0x3e, 0xe7, 0x0, 0x13, 0xa9, 0xff, 0xd, 0x50, 0x5a, 0x4c, 0x49, 0x27, 0xe, 0x16, - 0x9e, 0xe2, 0xc0, 0xcb, 0x18, 0x5b, 0x88, 0xa8, 0xb9, 0x0, 0x1e, 0xe3, 0x4a, 0x71, 0xf8, 0x33, 0xd7, - 0x16, 0x3d, 0xc8, 0xa9, 0x28, 0xdd, 0x15, 0x65, 0x30, 0x3e, 0x93, 0x9c, 0x70, 0x5a, 0x83, 0x65, 0xa5, - 0x17, 0xfc, 0x98, 0x64, 0xf5, 0x85, 0xae, 0x0, 0x18, 0xc0, 0x90, 0xf, 0xd8, 0x66, 0xc2, 0x5f, 0xa0, - 0xa0, 0x27, 0x1f, 0x7d, 0xc3, 0x56, 0x59, 0xde, 0xeb, 0xd9, 0xba, 0x25, 0xc6, 0x54, 0x5d, 0xf7, 0x0, - 0x4, 0xef, 0x5a, 0xd3, 0xe8, 0x0, 0x16, 0x4a, 0xb8, 0x69, 0xac, 0x93, 0xda, 0x50, 0x52, 0xbe, 0x7e, - 0x7, 0x74, 0x2f, 0x9e, 0x98, 0x54, 0x87, 0x22, 0x90, 0x1e, 0x33, 0x8b, 0x0, 0x13, 0xa7, 0xb0, 0x2e, - 0xf4, 0x78, 0xfe, 0x53, 0x4, 0x21, 0x4e, 0xca, 0x7a, 0x9a, 0x54, 0xd2, 0x13, 0x47, 0x10, 0x82, 0x0, - 0x1, 0xc2, 0x0, 0x6, 0xa5, 0xd0, 0x87, 0xbe, 0xa5, 0x47}; +// UnsubscribeRequest 24034 +// ["\156\234\208\197\181\158\172S\218","\132\v\NAK\170\230\US\216+\217\DEL\213\156F","MTu\239]\128\EOT\f\SYN_\203\250\250\148\128\\\SO\ETBuv\137\211w\174+\NULUh_\232","\134\175\155\DC1\190\137R%\247H\202\207","\135\ETX\221t\137\178A\194\131\189V\254\204\246\175\143x\NAK\162[\135*\235[\EOT","Sq\209\151pP","\185\181~\EM\159\160\137\183\ETXQ\129u\174'O\210\177\GSi\201\217","Ch\167\252[{V1Q\223D\152$70\147\DC1\158-t7\250\152+\244\255\RS^j","\134\&4\166Q\210\FS\194\136\206qe\DLE]CG\FSEj\169\156\NUL\213\185>H\ETX&\SI\140"] +// [PropTopicAlias 5045,PropServerKeepAlive 13352,PropUserProperty "ap\248\162\242R\251" "\128"] +TEST(Unsubscribe5QCTest, Encode19) { + uint8_t pkt[] = {0xa2, 0xd6, 0x1, 0x5d, 0xe2, 0x13, 0x23, 0x13, 0xb5, 0x13, 0x34, 0x28, 0x26, 0x0, 0x7, 0x61, 0x70, + 0xf8, 0xa2, 0xf2, 0x52, 0xfb, 0x0, 0x1, 0x80, 0x0, 0x9, 0x9c, 0xea, 0xd0, 0xc5, 0xb5, 0x9e, 0xac, + 0x53, 0xda, 0x0, 0xd, 0x84, 0xb, 0x15, 0xaa, 0xe6, 0x1f, 0xd8, 0x2b, 0xd9, 0x7f, 0xd5, 0x9c, 0x46, + 0x0, 0x1e, 0x4d, 0x54, 0x75, 0xef, 0x5d, 0x80, 0x4, 0xc, 0x16, 0x5f, 0xcb, 0xfa, 0xfa, 0x94, 0x80, + 0x5c, 0xe, 0x17, 0x75, 0x76, 0x89, 0xd3, 0x77, 0xae, 0x2b, 0x0, 0x55, 0x68, 0x5f, 0xe8, 0x0, 0xc, + 0x86, 0xaf, 0x9b, 0x11, 0xbe, 0x89, 0x52, 0x25, 0xf7, 0x48, 0xca, 0xcf, 0x0, 0x19, 0x87, 0x3, 0xdd, + 0x74, 0x89, 0xb2, 0x41, 0xc2, 0x83, 0xbd, 0x56, 0xfe, 0xcc, 0xf6, 0xaf, 0x8f, 0x78, 0x15, 0xa2, 0x5b, + 0x87, 0x2a, 0xeb, 0x5b, 0x4, 0x0, 0x6, 0x53, 0x71, 0xd1, 0x97, 0x70, 0x50, 0x0, 0x15, 0xb9, 0xb5, + 0x7e, 0x19, 0x9f, 0xa0, 0x89, 0xb7, 0x3, 0x51, 0x81, 0x75, 0xae, 0x27, 0x4f, 0xd2, 0xb1, 0x1d, 0x69, + 0xc9, 0xd9, 0x0, 0x1d, 0x43, 0x68, 0xa7, 0xfc, 0x5b, 0x7b, 0x56, 0x31, 0x51, 0xdf, 0x44, 0x98, 0x24, + 0x37, 0x30, 0x93, 0x11, 0x9e, 0x2d, 0x74, 0x37, 0xfa, 0x98, 0x2b, 0xf4, 0xff, 0x1e, 0x5e, 0x6a, 0x0, + 0x1d, 0x86, 0x34, 0xa6, 0x51, 0xd2, 0x1c, 0xc2, 0x88, 0xce, 0x71, 0x65, 0x10, 0x5d, 0x43, 0x47, 0x1c, + 0x45, 0x6a, 0xa9, 0x9c, 0x0, 0xd5, 0xb9, 0x3e, 0x48, 0x3, 0x26, 0xf, 0x8c}; uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x80}; + uint8_t bytesprops0[] = {0x61, 0x70, 0xf8, 0xa2, 0xf2, 0x52, 0xfb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6198}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5045}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13352}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops0}, .v = {1, (char*)&bytesprops1}}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xa0, 0x9c, 0x31, 0x9b, 0xd9, 0x1f, 0xc0, - 0xe9, 0x41, 0xaa, 0x36, 0x66, 0xd0, 0x49}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x9c, 0xea, 0xd0, 0xc5, 0xb5, 0x9e, 0xac, 0x53, 0xda}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5, 0xd, 0x15, 0xb3, 0xdd, 0x18, 0xd7, 0xd4, 0xbf, 0xed, 0x46, - 0xfa, 0x1b, 0x27, 0xff, 0x61, 0x84, 0x84, 0x57, 0x3e, 0xe7}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x84, 0xb, 0x15, 0xaa, 0xe6, 0x1f, 0xd8, 0x2b, 0xd9, 0x7f, 0xd5, 0x9c, 0x46}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa9, 0xff, 0xd, 0x50, 0x5a, 0x4c, 0x49, 0x27, 0xe, 0x16, - 0x9e, 0xe2, 0xc0, 0xcb, 0x18, 0x5b, 0x88, 0xa8, 0xb9}; - lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4d, 0x54, 0x75, 0xef, 0x5d, 0x80, 0x4, 0xc, 0x16, 0x5f, + 0xcb, 0xfa, 0xfa, 0x94, 0x80, 0x5c, 0xe, 0x17, 0x75, 0x76, + 0x89, 0xd3, 0x77, 0xae, 0x2b, 0x0, 0x55, 0x68, 0x5f, 0xe8}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe3, 0x4a, 0x71, 0xf8, 0x33, 0xd7, 0x16, 0x3d, 0xc8, 0xa9, - 0x28, 0xdd, 0x15, 0x65, 0x30, 0x3e, 0x93, 0x9c, 0x70, 0x5a, - 0x83, 0x65, 0xa5, 0x17, 0xfc, 0x98, 0x64, 0xf5, 0x85, 0xae}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x86, 0xaf, 0x9b, 0x11, 0xbe, 0x89, 0x52, 0x25, 0xf7, 0x48, 0xca, 0xcf}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc0, 0x90, 0xf, 0xd8, 0x66, 0xc2, 0x5f, 0xa0, 0xa0, 0x27, 0x1f, 0x7d, - 0xc3, 0x56, 0x59, 0xde, 0xeb, 0xd9, 0xba, 0x25, 0xc6, 0x54, 0x5d, 0xf7}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x87, 0x3, 0xdd, 0x74, 0x89, 0xb2, 0x41, 0xc2, 0x83, 0xbd, 0x56, 0xfe, 0xcc, + 0xf6, 0xaf, 0x8f, 0x78, 0x15, 0xa2, 0x5b, 0x87, 0x2a, 0xeb, 0x5b, 0x4}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xef, 0x5a, 0xd3, 0xe8}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x53, 0x71, 0xd1, 0x97, 0x70, 0x50}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4a, 0xb8, 0x69, 0xac, 0x93, 0xda, 0x50, 0x52, 0xbe, 0x7e, 0x7, - 0x74, 0x2f, 0x9e, 0x98, 0x54, 0x87, 0x22, 0x90, 0x1e, 0x33, 0x8b}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb9, 0xb5, 0x7e, 0x19, 0x9f, 0xa0, 0x89, 0xb7, 0x3, 0x51, 0x81, + 0x75, 0xae, 0x27, 0x4f, 0xd2, 0xb1, 0x1d, 0x69, 0xc9, 0xd9}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa7, 0xb0, 0x2e, 0xf4, 0x78, 0xfe, 0x53, 0x4, 0x21, 0x4e, - 0xca, 0x7a, 0x9a, 0x54, 0xd2, 0x13, 0x47, 0x10, 0x82}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x43, 0x68, 0xa7, 0xfc, 0x5b, 0x7b, 0x56, 0x31, 0x51, 0xdf, + 0x44, 0x98, 0x24, 0x37, 0x30, 0x93, 0x11, 0x9e, 0x2d, 0x74, + 0x37, 0xfa, 0x98, 0x2b, 0xf4, 0xff, 0x1e, 0x5e, 0x6a}; + lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xc2}; - lwmqtt_string_t topic_filter_s8 = {1, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x86, 0x34, 0xa6, 0x51, 0xd2, 0x1c, 0xc2, 0x88, 0xce, 0x71, + 0x65, 0x10, 0x5d, 0x43, 0x47, 0x1c, 0x45, 0x6a, 0xa9, 0x9c, + 0x0, 0xd5, 0xb9, 0x3e, 0x48, 0x3, 0x26, 0xf, 0x8c}; + lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xa5, 0xd0, 0x87, 0xbe, 0xa5, 0x47}; - lwmqtt_string_t topic_filter_s9 = {6, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5184, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24034, 9, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 21743 -// ["g\SUB\173Z5\135\245\NUL\138\243\130\165\170M\184/O\ETX\214$\241\DC3\147\&8WZ'","\243\253\202\167\210\ACK\253w\239\248\128\US\184\153\242E\242\132\219nOk\250\242qR","\"","U\138\193\246\162T_\SUB\206\&4","\154\&0Tav\255\213\&1\DC2Y","\252=\144O\"ETDc\221\130\228E_4a\DC2\253fn\209\187\138#3","F9\a\224\133\201\252\255\151\253\220\EOT\NUL\ETB3m\140o\135\215lSi\140\155\240\&2\SOH\211\128"] -// [PropSharedSubscriptionAvailable 98] -TEST(Unsubscribe5QCTest, Encode15) { - uint8_t pkt[] = {0xa2, 0x94, 0x1, 0x54, 0xef, 0x2, 0x2a, 0x62, 0x0, 0x1b, 0x67, 0x1a, 0xad, 0x5a, 0x35, 0x87, 0xf5, - 0x0, 0x8a, 0xf3, 0x82, 0xa5, 0xaa, 0x4d, 0xb8, 0x2f, 0x4f, 0x3, 0xd6, 0x24, 0xf1, 0x13, 0x93, 0x38, - 0x57, 0x5a, 0x27, 0x0, 0x1a, 0xf3, 0xfd, 0xca, 0xa7, 0xd2, 0x6, 0xfd, 0x77, 0xef, 0xf8, 0x80, 0x1f, - 0xb8, 0x99, 0xf2, 0x45, 0xf2, 0x84, 0xdb, 0x6e, 0x4f, 0x6b, 0xfa, 0xf2, 0x71, 0x52, 0x0, 0x1, 0x22, - 0x0, 0xa, 0x55, 0x8a, 0xc1, 0xf6, 0xa2, 0x54, 0x5f, 0x1a, 0xce, 0x34, 0x0, 0xa, 0x9a, 0x30, 0x54, - 0x61, 0x76, 0xff, 0xd5, 0x31, 0x12, 0x59, 0x0, 0x19, 0xfc, 0x3d, 0x90, 0x4f, 0x22, 0x45, 0x54, 0x44, - 0x63, 0xdd, 0x82, 0xe4, 0x45, 0x5f, 0x34, 0x61, 0x12, 0xfd, 0x66, 0x6e, 0xd1, 0xbb, 0x8a, 0x23, 0x33, - 0x0, 0x1e, 0x46, 0x39, 0x7, 0xe0, 0x85, 0xc9, 0xfc, 0xff, 0x97, 0xfd, 0xdc, 0x4, 0x0, 0x17, 0x33, - 0x6d, 0x8c, 0x6f, 0x87, 0xd7, 0x6c, 0x53, 0x69, 0x8c, 0x9b, 0xf0, 0x32, 0x1, 0xd3, 0x80}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// UnsubscribeRequest 5686 +// ["","\v}7\181\SI\131\156\ETX\158\RS<\237t\205^\236\158\139>","\179\158\242","","}>\\@\236\138X@Bu=P>J\STX\STXF&,?\129'\213\195\189","\\W=A\231m\181\237v\154\160","\254\234\210\&3`B\"/\175\253\131\244@\176]\211\159\163\160$\246"] +// [PropRequestProblemInformation 81,PropMessageExpiryInterval 13449,PropTopicAliasMaximum +// 21738,PropPayloadFormatIndicator 87,PropSessionExpiryInterval 22817,PropResponseTopic +// "\252\&9{_/\200\140\ETX",PropReceiveMaximum 16202,PropMessageExpiryInterval 32296,PropSubscriptionIdentifierAvailable +// 220,PropUserProperty "v\198\157\202a+\NUL2\222\a\DLEv\151" +// "\253\236fT\241\218YK\SOH\159#\156}\v\199\239)\249\144\ESC",PropRequestProblemInformation 191,PropReasonString +// "\EOT{I\FS{ep\216\139\201Ri\167\v#\165\&8B\a\145v^\131\200\201\153\177q\180\DC2",PropServerReference +// "G\171\191\199\&9",PropContentType +// "\STX\240\190\US\185Z\176\187+\144\209\&3\224\191Zm\STX\DC1%\DC1\142(\131\209^",PropReasonString +// "\US@\233w",PropSubscriptionIdentifierAvailable 252,PropServerKeepAlive 31044,PropReasonString +// "\176\153\SOH\183\DEL",PropServerKeepAlive 11070,PropRequestResponseInformation 182,PropResponseInformation +// "\232\157W\220\179<_",PropSubscriptionIdentifier 15,PropServerKeepAlive 3297,PropResponseTopic +// ".\ESC5\138E\147\194e\182",PropRetainAvailable 193] +TEST(Unsubscribe5QCTest, Encode20) { + uint8_t pkt[] = { + 0xa2, 0xaa, 0x2, 0x16, 0x36, 0xc9, 0x1, 0x17, 0x51, 0x2, 0x0, 0x0, 0x34, 0x89, 0x22, 0x54, 0xea, 0x1, 0x57, + 0x11, 0x0, 0x0, 0x59, 0x21, 0x8, 0x0, 0x8, 0xfc, 0x39, 0x7b, 0x5f, 0x2f, 0xc8, 0x8c, 0x3, 0x21, 0x3f, 0x4a, + 0x2, 0x0, 0x0, 0x7e, 0x28, 0x29, 0xdc, 0x26, 0x0, 0xd, 0x76, 0xc6, 0x9d, 0xca, 0x61, 0x2b, 0x0, 0x32, 0xde, + 0x7, 0x10, 0x76, 0x97, 0x0, 0x14, 0xfd, 0xec, 0x66, 0x54, 0xf1, 0xda, 0x59, 0x4b, 0x1, 0x9f, 0x23, 0x9c, 0x7d, + 0xb, 0xc7, 0xef, 0x29, 0xf9, 0x90, 0x1b, 0x17, 0xbf, 0x1f, 0x0, 0x1e, 0x4, 0x7b, 0x49, 0x1c, 0x7b, 0x65, 0x70, + 0xd8, 0x8b, 0xc9, 0x52, 0x69, 0xa7, 0xb, 0x23, 0xa5, 0x38, 0x42, 0x7, 0x91, 0x76, 0x5e, 0x83, 0xc8, 0xc9, 0x99, + 0xb1, 0x71, 0xb4, 0x12, 0x1c, 0x0, 0x5, 0x47, 0xab, 0xbf, 0xc7, 0x39, 0x3, 0x0, 0x19, 0x2, 0xf0, 0xbe, 0x1f, + 0xb9, 0x5a, 0xb0, 0xbb, 0x2b, 0x90, 0xd1, 0x33, 0xe0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0x4b, 0x1, 0x9f, + 0x23, 0x9c, 0x7d, 0xb, 0xc7, 0xef, 0x29, 0xf9, 0x90, 0x1b}; + uint8_t bytesprops1[] = {0x76, 0xc6, 0x9d, 0xca, 0x61, 0x2b, 0x0, 0x32, 0xde, 0x7, 0x10, 0x76, 0x97}; + uint8_t bytesprops3[] = {0x4, 0x7b, 0x49, 0x1c, 0x7b, 0x65, 0x70, 0xd8, 0x8b, 0xc9, 0x52, 0x69, 0xa7, 0xb, 0x23, + 0xa5, 0x38, 0x42, 0x7, 0x91, 0x76, 0x5e, 0x83, 0xc8, 0xc9, 0x99, 0xb1, 0x71, 0xb4, 0x12}; + uint8_t bytesprops4[] = {0x47, 0xab, 0xbf, 0xc7, 0x39}; + uint8_t bytesprops5[] = {0x2, 0xf0, 0xbe, 0x1f, 0xb9, 0x5a, 0xb0, 0xbb, 0x2b, 0x90, 0xd1, 0x33, 0xe0, + 0xbf, 0x5a, 0x6d, 0x2, 0x11, 0x25, 0x11, 0x8e, 0x28, 0x83, 0xd1, 0x5e}; + uint8_t bytesprops6[] = {0x1f, 0x40, 0xe9, 0x77}; + uint8_t bytesprops7[] = {0xb0, 0x99, 0x1, 0xb7, 0x7f}; + uint8_t bytesprops8[] = {0xe8, 0x9d, 0x57, 0xdc, 0xb3, 0x3c, 0x5f}; + uint8_t bytesprops9[] = {0x2e, 0x1b, 0x35, 0x8a, 0x45, 0x93, 0xc2, 0x65, 0xb6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13449}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21738}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22817}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16202}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32296}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops1}, .v = {20, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31044}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11070}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3297}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x67, 0x1a, 0xad, 0x5a, 0x35, 0x87, 0xf5, 0x0, 0x8a, 0xf3, 0x82, 0xa5, 0xaa, 0x4d, - 0xb8, 0x2f, 0x4f, 0x3, 0xd6, 0x24, 0xf1, 0x13, 0x93, 0x38, 0x57, 0x5a, 0x27}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf3, 0xfd, 0xca, 0xa7, 0xd2, 0x6, 0xfd, 0x77, 0xef, 0xf8, 0x80, 0x1f, 0xb8, - 0x99, 0xf2, 0x45, 0xf2, 0x84, 0xdb, 0x6e, 0x4f, 0x6b, 0xfa, 0xf2, 0x71, 0x52}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb, 0x7d, 0x37, 0xb5, 0xf, 0x83, 0x9c, 0x3, 0x9e, 0x1e, + 0x3c, 0xed, 0x74, 0xcd, 0x5e, 0xec, 0x9e, 0x8b, 0x3e}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x22}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb3, 0x9e, 0xf2}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x55, 0x8a, 0xc1, 0xf6, 0xa2, 0x54, 0x5f, 0x1a, 0xce, 0x34}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9a, 0x30, 0x54, 0x61, 0x76, 0xff, 0xd5, 0x31, 0x12, 0x59}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x7d, 0x3e, 0x5c, 0x40, 0xec, 0x8a, 0x58, 0x40, 0x42, 0x75, 0x3d, 0x50, 0x3e, + 0x4a, 0x2, 0x2, 0x46, 0x26, 0x2c, 0x3f, 0x81, 0x27, 0xd5, 0xc3, 0xbd}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfc, 0x3d, 0x90, 0x4f, 0x22, 0x45, 0x54, 0x44, 0x63, 0xdd, 0x82, 0xe4, 0x45, - 0x5f, 0x34, 0x61, 0x12, 0xfd, 0x66, 0x6e, 0xd1, 0xbb, 0x8a, 0x23, 0x33}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x5c, 0x57, 0x3d, 0x41, 0xe7, 0x6d, 0xb5, 0xed, 0x76, 0x9a, 0xa0}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x46, 0x39, 0x7, 0xe0, 0x85, 0xc9, 0xfc, 0xff, 0x97, 0xfd, - 0xdc, 0x4, 0x0, 0x17, 0x33, 0x6d, 0x8c, 0x6f, 0x87, 0xd7, - 0x6c, 0x53, 0x69, 0x8c, 0x9b, 0xf0, 0x32, 0x1, 0xd3, 0x80}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xfe, 0xea, 0xd2, 0x33, 0x60, 0x42, 0x22, 0x2f, 0xaf, 0xfd, 0x83, + 0xf4, 0x40, 0xb0, 0x5d, 0xd3, 0x9f, 0xa3, 0xa0, 0x24, 0xf6}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21743, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5686, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 11426 ["\138\251 -// \SOH\190x\170(\EOT(\NUL\229\US\232\ETX\tH","\212\252_\137\222\158gd\rm\194;&w\RS\242\199\DLE\ETB\253\145\151","xD\194\160"] -// [PropTopicAliasMaximum 5217,PropCorrelationData "*\169\DC1t",PropResponseInformation -// "\ACK0\224\&8\215\163\192\132\255\DC4\226\129\\\179A+o\157~\155\SO",PropUserProperty -// "\207\166@]\175\136\DC3'\r\184\130\159\147=\249\159\211a\186\207V\CANeL\196\&4\144wj" -// "C\a~\200\&4&\133\178\237\SI\237E\NUL",PropRequestProblemInformation 9,PropResponseInformation -// "N\190\&9i\SUBs.D\233$#]\DLE\136\149\170\228\224\SI\ACK\199\140\237\160\DC4Iz",PropReasonString "\NULB\195\248 -// 8\235\247z\b",PropAuthenticationData -// "\170\239G\224\203\229\161\152\160\232@oj6\152V\192>\176:^\CAN\160\SOH9\t\135\EOT",PropReasonString -// "\213\250\233\253\148\163\227\EME\ETX\245{\190qc\163\162EH\NUL\a\ENQh","`\198\220\GSG6\209Q\236\251;","\139Hp\135\199d\160+"] -// [PropResponseInformation -// "@t\NAK\239I\255T\NUL\234u$\b\162Xh\204\159\214:M\231\v\230\189\165$#",PropRequestResponseInformation -// 103,PropAuthenticationData "",PropResponseInformation "\DC4@UB\147\206\239\156`\231\137\bx",PropResponseTopic -// "\204n\229\a\ENQ\177]\226`\EM\209\&8\219u",PropAuthenticationMethod -// "0\232\179\185F\201\b\DLE\180\224z>\157L\226\141\226:h)\216\245\201\235\241|d1",PropResponseTopic -// "\220\223\128\&4\223\222^\193:_W\143G\140\154\SUBD\163",PropContentType -// "9\158\RS\202\251\FS)\132K]\217T\182a\131\217\CAN\185x",PropAuthenticationMethod -// "\220\132\182k\146\240\191\250R\149\168/$\157\216\&4;P\138\250",PropSessionExpiryInterval 17187,PropCorrelationData -// "\131\141\235\238\130w\236\ACKcQ5\166\135\134\160",PropContentType "p\155\&8\149\SO\181",PropUserProperty "Z8\b\234" -// "\161\249\241-\v\156\ESC",PropSubscriptionIdentifier 29,PropReceiveMaximum 23266,PropMaximumPacketSize -// 3356,PropTopicAliasMaximum 7145,PropResponseTopic "\221\244\SUB\SIC\210\165A\DC1\217\143(hW",PropServerKeepAlive -// 502,PropServerKeepAlive 3960,PropWillDelayInterval 1206,PropUserProperty "" -// "x\172\ESCf#\252\234\251\&3\185\211\f\130\244\247",PropAssignedClientIdentifier "",PropSessionExpiryInterval -// 29118,PropResponseInformation -// "\ETBq\221\176v\b\252\146\181\210\171\197\170\242W\247\188\181\SO\180\241\221\ETX",PropRetainAvailable -// 134,PropRequestProblemInformation 51,PropSharedSubscriptionAvailable 51,PropRetainAvailable 129,PropResponseTopic -// "\216\SI\236\&1\204\139\168T\138_\141 l\236\183f\250\135\248!ua\DC2\EM\245"] -TEST(Unsubscribe5QCTest, Encode17) { + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24245, 3, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 25032 ["\SYN;\174\NAK\140_\188\"[\SOH3z~7\194\136\&7\218\&2\SYN<\156w","V\219\229e\199 +// ","W\238\187\GS\SUB\132\133w\251\149h\178\201\DC3\204\209\201\SYN","}=\204\166\208\175.\200\192\SYNb\177","!\174\SO\173\137~:\238\166u\EOT\165\184r4\185l\201\128\190\&0f\156","\149:.\217?\"ev=\v;\158\129d\244\ACKxH{\DC4\245","J"] +// [PropAuthenticationData +// "\176\224\132\EOT\217\155yE\177\193\187\245\181\SOH\SUB@\232>\169\179\166\250\248o\139",PropTopicAlias +// 15556,PropMaximumPacketSize 12808,PropSessionExpiryInterval 32646,PropSubscriptionIdentifier +// 20,PropAssignedClientIdentifier +// "x\142b5_\202\ESC\180\209\&3\STX\252\156\226wp\237\242\240\129y\EOT\DEL\DC3\134\154\227",PropReceiveMaximum +// 26150,PropMessageExpiryInterval 32475,PropSharedSubscriptionAvailable 16,PropAssignedClientIdentifier +// "\ESC\158\248\b",PropMessageExpiryInterval 17120,PropWillDelayInterval 29419,PropMessageExpiryInterval +// 31352,PropServerReference +// "soB8\152\129\173\163\233\ESC\214/\195\254\213e\184\198\DC4\230\158l\229-\153\216I\191\SUB",PropMessageExpiryInterval +// 2639,PropMessageExpiryInterval 18192] +TEST(Unsubscribe5QCTest, Encode22) { uint8_t pkt[] = { - 0xa2, 0xbb, 0x3, 0x16, 0xd1, 0xd8, 0x2, 0x1a, 0x0, 0x1b, 0x40, 0x74, 0x15, 0xef, 0x49, 0xff, 0x54, 0x0, 0xea, - 0x75, 0x24, 0x8, 0xa2, 0x58, 0x68, 0xcc, 0x9f, 0xd6, 0x3a, 0x4d, 0xe7, 0xb, 0xe6, 0xbd, 0xa5, 0x24, 0x23, 0x19, - 0x67, 0x16, 0x0, 0x0, 0x1a, 0x0, 0xd, 0x14, 0x40, 0x55, 0x42, 0x93, 0xce, 0xef, 0x9c, 0x60, 0xe7, 0x89, 0x8, - 0x78, 0x8, 0x0, 0xe, 0xcc, 0x6e, 0xe5, 0x7, 0x5, 0xb1, 0x5d, 0xe2, 0x60, 0x19, 0xd1, 0x38, 0xdb, 0x75, 0x15, - 0x0, 0x1c, 0x30, 0xe8, 0xb3, 0xb9, 0x46, 0xc9, 0x8, 0x10, 0xb4, 0xe0, 0x7a, 0x3e, 0x9d, 0x4c, 0xe2, 0x8d, 0xe2, - 0x3a, 0x68, 0x29, 0xd8, 0xf5, 0xc9, 0xeb, 0xf1, 0x7c, 0x64, 0x31, 0x8, 0x0, 0x12, 0xdc, 0xd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, 0x92, 0xb5, 0xd2, 0xab, 0xc5, - 0xaa, 0xf2, 0x57, 0xf7, 0xbc, 0xb5, 0xe, 0xb4, 0xf1, 0xdd, 0x3, 0x25, 0x86, 0x17, 0x33, 0x2a, 0x33, 0x25, 0x81, - 0x8, 0x0, 0x19, 0xd8, 0xf, 0xec, 0x31, 0xcc, 0x8b, 0xa8, 0x54, 0x8a, 0x5f, 0x8d, 0x20, 0x6c, 0xec, 0xb7, 0x66, - 0xfa, 0x87, 0xf8, 0x21, 0x75, 0x61, 0x12, 0x19, 0xf5, 0x0, 0x4, 0x79, 0x68, 0xfb, 0xa9, 0x0, 0x1d, 0xb2, 0xf, - 0x92, 0x47, 0xd2, 0x85, 0x76, 0x99, 0xc, 0x8f, 0x54, 0xbc, 0xbb, 0x63, 0xf, 0xe3, 0xa, 0xa, 0x15, 0x2a, 0x66, - 0x54, 0x52, 0x6c, 0xcd, 0x4d, 0xe0, 0x63, 0x21, 0x0, 0x8, 0x20, 0xa1, 0xb, 0x55, 0xf2, 0x16, 0x3a, 0xe0, 0x0, - 0x17, 0xb6, 0x6f, 0x5f, 0xd5, 0x83, 0xfd, 0x48, 0x6b, 0x58, 0x3e, 0xf5, 0x7b, 0xbe, 0x71, 0x63, 0xa3, 0xa2, 0x45, - 0x48, 0x0, 0x7, 0x5, 0x68, 0x0, 0xb, 0x60, 0xc6, 0xdc, 0x1d, 0x47, 0x36, 0xd1, 0x51, 0xec, 0xfb, 0x3b, 0x0, - 0x8, 0x8b, 0x48, 0x70, 0x87, 0xc7, 0x64, 0xa0, 0x2b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x40, 0x74, 0x15, 0xef, 0x49, 0xff, 0x54, 0x0, 0xea, 0x75, 0x24, 0x8, 0xa2, 0x58, - 0x68, 0xcc, 0x9f, 0xd6, 0x3a, 0x4d, 0xe7, 0xb, 0xe6, 0xbd, 0xa5, 0x24, 0x23}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x14, 0x40, 0x55, 0x42, 0x93, 0xce, 0xef, 0x9c, 0x60, 0xe7, 0x89, 0x8, 0x78}; - uint8_t bytesprops3[] = {0xcc, 0x6e, 0xe5, 0x7, 0x5, 0xb1, 0x5d, 0xe2, 0x60, 0x19, 0xd1, 0x38, 0xdb, 0x75}; - uint8_t bytesprops4[] = {0x30, 0xe8, 0xb3, 0xb9, 0x46, 0xc9, 0x8, 0x10, 0xb4, 0xe0, 0x7a, 0x3e, 0x9d, 0x4c, - 0xe2, 0x8d, 0xe2, 0x3a, 0x68, 0x29, 0xd8, 0xf5, 0xc9, 0xeb, 0xf1, 0x7c, 0x64, 0x31}; - uint8_t bytesprops5[] = {0xdc, 0xdf, 0x80, 0x34, 0xdf, 0xde, 0x5e, 0xc1, 0x3a, - 0x5f, 0x57, 0x8f, 0x47, 0x8c, 0x9a, 0x1a, 0x44, 0xa3}; - uint8_t bytesprops6[] = {0x39, 0x9e, 0x1e, 0xca, 0xfb, 0x1c, 0x29, 0x84, 0x4b, 0x5d, - 0xd9, 0x54, 0xb6, 0x61, 0x83, 0xd9, 0x18, 0xb9, 0x78}; - uint8_t bytesprops7[] = {0xdc, 0x84, 0xb6, 0x6b, 0x92, 0xf0, 0xbf, 0xfa, 0x52, 0x95, - 0xa8, 0x2f, 0x24, 0x9d, 0xd8, 0x34, 0x3b, 0x50, 0x8a, 0xfa}; - uint8_t bytesprops8[] = {0x83, 0x8d, 0xeb, 0xee, 0x82, 0x77, 0xec, 0x6, 0x63, 0x51, 0x35, 0xa6, 0x87, 0x86, 0xa0}; - uint8_t bytesprops9[] = {0x70, 0x9b, 0x38, 0x95, 0xe, 0xb5}; - uint8_t bytesprops11[] = {0xa1, 0xf9, 0xf1, 0x2d, 0xb, 0x9c, 0x1b}; - uint8_t bytesprops10[] = {0x5a, 0x38, 0x8, 0xea}; - uint8_t bytesprops12[] = {0xdd, 0xf4, 0x1a, 0xf, 0x43, 0xd2, 0xa5, 0x41, 0x11, 0xd9, 0x8f, 0x28, 0x68, 0x57}; - uint8_t bytesprops14[] = {0x78, 0xac, 0x1b, 0x66, 0x23, 0xfc, 0xea, 0xfb, 0x33, 0xb9, 0xd3, 0xc, 0x82, 0xf4, 0xf7}; - uint8_t bytesprops13[] = {0}; - uint8_t bytesprops15[] = {0}; - uint8_t bytesprops16[] = {0x17, 0x71, 0xdd, 0xb0, 0x76, 0x8, 0xfc, 0x92, 0xb5, 0xd2, 0xab, 0xc5, - 0xaa, 0xf2, 0x57, 0xf7, 0xbc, 0xb5, 0xe, 0xb4, 0xf1, 0xdd, 0x3}; - uint8_t bytesprops17[] = {0xd8, 0xf, 0xec, 0x31, 0xcc, 0x8b, 0xa8, 0x54, 0x8a, 0x5f, 0x8d, 0x20, 0x6c, - 0xec, 0xb7, 0x66, 0xfa, 0x87, 0xf8, 0x21, 0x75, 0x61, 0x12, 0x19, 0xf5}; + 0xa2, 0x8d, 0x2, 0x61, 0xc8, 0x93, 0x1, 0x16, 0x0, 0x19, 0xb0, 0xe0, 0x84, 0x4, 0xd9, 0x9b, 0x79, 0x45, 0xb1, + 0xc1, 0xbb, 0xf5, 0xb5, 0x1, 0x1a, 0x40, 0xe8, 0x3e, 0xa9, 0xb3, 0xa6, 0xfa, 0xf8, 0x6f, 0x8b, 0x23, 0x3c, 0xc4, + 0x27, 0x0, 0x0, 0x32, 0x8, 0x11, 0x0, 0x0, 0x7f, 0x86, 0xb, 0x14, 0x12, 0x0, 0x1b, 0x78, 0x8e, 0x62, 0x35, + 0x5f, 0xca, 0x1b, 0xb4, 0xd1, 0x33, 0x2, 0xfc, 0x9c, 0xe2, 0x77, 0x70, 0xed, 0xf2, 0xf0, 0x81, 0x79, 0x4, 0x7f, + 0x13, 0x86, 0x9a, 0xe3, 0x21, 0x66, 0x26, 0x2, 0x0, 0x0, 0x7e, 0xdb, 0x2a, 0x10, 0x12, 0x0, 0x4, 0x1b, 0x9e, + 0xf8, 0x8, 0x2, 0x0, 0x0, 0x42, 0xe0, 0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b1, 0xc1, 0xbb, 0xf5, 0xb5, + 0x1, 0x1a, 0x40, 0xe8, 0x3e, 0xa9, 0xb3, 0xa6, 0xfa, 0xf8, 0x6f, 0x8b}; + uint8_t bytesprops1[] = {0x78, 0x8e, 0x62, 0x35, 0x5f, 0xca, 0x1b, 0xb4, 0xd1, 0x33, 0x2, 0xfc, 0x9c, 0xe2, + 0x77, 0x70, 0xed, 0xf2, 0xf0, 0x81, 0x79, 0x4, 0x7f, 0x13, 0x86, 0x9a, 0xe3}; + uint8_t bytesprops2[] = {0x1b, 0x9e, 0xf8, 0x8}; + uint8_t bytesprops3[] = {0x73, 0x6f, 0x42, 0x38, 0x98, 0x81, 0xad, 0xa3, 0xe9, 0x1b, 0xd6, 0x2f, 0xc3, 0xfe, 0xd5, + 0x65, 0xb8, 0xc6, 0x14, 0xe6, 0x9e, 0x6c, 0xe5, 0x2d, 0x99, 0xd8, 0x49, 0xbf, 0x1a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17187}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops10}, .v = {7, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23266}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3356}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7145}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 502}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3960}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1206}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops13}, .v = {15, (char*)&bytesprops14}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops15}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29118}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops16}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops17}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15556}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12808}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32646}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26150}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32475}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17120}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29419}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31352}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2639}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18192}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x79, 0x68, 0xfb, 0xa9}; - lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x16, 0x3b, 0xae, 0x15, 0x8c, 0x5f, 0xbc, 0x22, 0x5b, 0x1, 0x33, 0x7a, + 0x7e, 0x37, 0xc2, 0x88, 0x37, 0xda, 0x32, 0x16, 0x3c, 0x9c, 0x77}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb2, 0xf, 0x92, 0x47, 0xd2, 0x85, 0x76, 0x99, 0xc, 0x8f, - 0x54, 0xbc, 0xbb, 0x63, 0xf, 0xe3, 0xa, 0xa, 0x15, 0x2a, - 0x66, 0x54, 0x52, 0x6c, 0xcd, 0x4d, 0xe0, 0x63, 0x21}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x56, 0xdb, 0xe5, 0x65, 0xc7, 0x20}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x20, 0xa1, 0xb, 0x55, 0xf2, 0x16, 0x3a, 0xe0}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x57, 0xee, 0xbb, 0x1d, 0x1a, 0x84, 0x85, 0x77, 0xfb, + 0x95, 0x68, 0xb2, 0xc9, 0x13, 0xcc, 0xd1, 0xc9, 0x16}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb6, 0x6f, 0x5f, 0xd5, 0x83, 0xfd, 0x48, 0x6b, 0x58, 0x3e, 0xf5, 0x7b, - 0xbe, 0x71, 0x63, 0xa3, 0xa2, 0x45, 0x48, 0x0, 0x7, 0x5, 0x68}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x7d, 0x3d, 0xcc, 0xa6, 0xd0, 0xaf, 0x2e, 0xc8, 0xc0, 0x16, 0x62, 0xb1}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x60, 0xc6, 0xdc, 0x1d, 0x47, 0x36, 0xd1, 0x51, 0xec, 0xfb, 0x3b}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x21, 0xae, 0xe, 0xad, 0x89, 0x7e, 0x3a, 0xee, 0xa6, 0x75, 0x4, 0xa5, + 0xb8, 0x72, 0x34, 0xb9, 0x6c, 0xc9, 0x80, 0xbe, 0x30, 0x66, 0x9c}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8b, 0x48, 0x70, 0x87, 0xc7, 0x64, 0xa0, 0x2b}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x95, 0x3a, 0x2e, 0xd9, 0x3f, 0x22, 0x65, 0x76, 0x3d, 0xb, 0x3b, + 0x9e, 0x81, 0x64, 0xf4, 0x6, 0x78, 0x48, 0x7b, 0x14, 0xf5}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x4a}; + lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5841, 6, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25032, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 26803 -// ["h\b\248\219\SI\197\167\148#\226\147\153}","f\166\188I8\138","o\166\FS\210\138\156\166\234\SUB:%\155N\154\226\132\233E"] -// [PropResponseInformation "\USvE\182\163\248k\DC3 -// \221\254\232\167\186\181Y\155\173X\209\242\132t",PropMessageExpiryInterval 20360,PropMaximumPacketSize -// 13975,PropAuthenticationData -// "q\RS\SOH'\SYN\132j1\245\141\&4r\173\&9k\251f\DC2\233\238*\222\130o\194\203\EOTb",PropContentType -// "e)\148BfT6\DEL\181a\DC2\SYN\145",PropPayloadFormatIndicator 174,PropReasonString "\DLE\223\169\189\162Q\128\ENQ\154 -// |\226qCj\186\253`\222@\128\a \236",PropMaximumQoS 65,PropSubscriptionIdentifierAvailable -// 221,PropPayloadFormatIndicator 174,PropMaximumQoS 100,PropRequestResponseInformation 162,PropUserProperty -// "(\167\172\a\NAK\209\206\166\225nR{\130\177\146ZP\252l\SYN\a\251\164\146" "\241\US\"",PropSharedSubscriptionAvailable -// 34,PropRetainAvailable 89] -TEST(Unsubscribe5QCTest, Encode18) { - uint8_t pkt[] = { - 0xa2, 0xcd, 0x1, 0x68, 0xb3, 0x9e, 0x1, 0x1a, 0x0, 0x17, 0x1f, 0x76, 0x45, 0xb6, 0xa3, 0xf8, 0x6b, 0x13, 0x20, - 0xdd, 0xfe, 0xe8, 0xa7, 0xba, 0xb5, 0x59, 0x9b, 0xad, 0x58, 0xd1, 0xf2, 0x84, 0x74, 0x2, 0x0, 0x0, 0x4f, 0x88, - 0x27, 0x0, 0x0, 0x36, 0x97, 0x16, 0x0, 0x1c, 0x71, 0x1e, 0x1, 0x27, 0x16, 0x84, 0x6a, 0x31, 0xf5, 0x8d, 0x34, - 0x72, 0xad, 0x39, 0x6b, 0xfb, 0x66, 0x12, 0xe9, 0xee, 0x2a, 0xde, 0x82, 0x6f, 0xc2, 0xcb, 0x4, 0x62, 0x3, 0x0, - 0xd, 0x65, 0x29, 0x94, 0x42, 0x66, 0x54, 0x36, 0x7f, 0xb5, 0x61, 0x12, 0x16, 0x91, 0x1, 0xae, 0x1f, 0x0, 0x18, - 0x10, 0xdf, 0xa9, 0xbd, 0xa2, 0x51, 0x80, 0x5, 0x9a, 0x20, 0x7c, 0xe2, 0x71, 0x43, 0x6a, 0xba, 0xfd, 0x60, 0xde, - 0x40, 0x80, 0x7, 0x20, 0xec, 0x24, 0x41, 0x29, 0xdd, 0x1, 0xae, 0x24, 0x64, 0x19, 0xa2, 0x26, 0x0, 0x18, 0x28, - 0xa7, 0xac, 0x7, 0x15, 0xd1, 0xce, 0xa6, 0xe1, 0x6e, 0x52, 0x7b, 0x82, 0xb1, 0x92, 0x5a, 0x50, 0xfc, 0x6c, 0x16, - 0x7, 0xfb, 0xa4, 0x92, 0x0, 0x3, 0xf1, 0x1f, 0x22, 0x2a, 0x22, 0x25, 0x59, 0x0, 0xd, 0x68, 0x8, 0xf8, 0xdb, - 0xf, 0xc5, 0xa7, 0x94, 0x23, 0xe2, 0x93, 0x99, 0x7d, 0x0, 0x6, 0x66, 0xa6, 0xbc, 0x49, 0x38, 0x8a, 0x0, 0x12, - 0x6f, 0xa6, 0x1c, 0xd2, 0x8a, 0x9c, 0xa6, 0xea, 0x1a, 0x3a, 0x25, 0x9b, 0x4e, 0x9a, 0xe2, 0x84, 0xe9, 0x45}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1f, 0x76, 0x45, 0xb6, 0xa3, 0xf8, 0x6b, 0x13, 0x20, 0xdd, 0xfe, 0xe8, - 0xa7, 0xba, 0xb5, 0x59, 0x9b, 0xad, 0x58, 0xd1, 0xf2, 0x84, 0x74}; - uint8_t bytesprops1[] = {0x71, 0x1e, 0x1, 0x27, 0x16, 0x84, 0x6a, 0x31, 0xf5, 0x8d, 0x34, 0x72, 0xad, 0x39, - 0x6b, 0xfb, 0x66, 0x12, 0xe9, 0xee, 0x2a, 0xde, 0x82, 0x6f, 0xc2, 0xcb, 0x4, 0x62}; - uint8_t bytesprops2[] = {0x65, 0x29, 0x94, 0x42, 0x66, 0x54, 0x36, 0x7f, 0xb5, 0x61, 0x12, 0x16, 0x91}; - uint8_t bytesprops3[] = {0x10, 0xdf, 0xa9, 0xbd, 0xa2, 0x51, 0x80, 0x5, 0x9a, 0x20, 0x7c, 0xe2, - 0x71, 0x43, 0x6a, 0xba, 0xfd, 0x60, 0xde, 0x40, 0x80, 0x7, 0x20, 0xec}; - uint8_t bytesprops5[] = {0xf1, 0x1f, 0x22}; - uint8_t bytesprops4[] = {0x28, 0xa7, 0xac, 0x7, 0x15, 0xd1, 0xce, 0xa6, 0xe1, 0x6e, 0x52, 0x7b, - 0x82, 0xb1, 0x92, 0x5a, 0x50, 0xfc, 0x6c, 0x16, 0x7, 0xfb, 0xa4, 0x92}; +// UnsubscribeRequest 9981 ["\234","\236\168cp","~","\224\178\190\NAK\250][\147CG\225f\248\DC3\243\"\t\""] +// [PropSharedSubscriptionAvailable 83,PropMaximumPacketSize 12284,PropReasonString +// "\165\EOT\EOT\182\212_\146\172\131\222\247\253)\178_\210\RSO\SI\208\237$8p\ESC\138d",PropResponseInformation +// "\202\ETBPO",PropRetainAvailable 25,PropPayloadFormatIndicator 168,PropServerReference +// "\DC2\129(\154\245k4\239\158de\253\160\170\182l\173j",PropServerReference +// "\244h\NAK\216\SOH\NAK\154\240l^\172\193\138Z=tv\129\195\168\178\154$\154\244\214\184\ESCO",PropUserProperty +// "\190\247\160\199\252\195Q" "]hb\CAN\139\158\206\249\ESCHD%\175\n",PropAssignedClientIdentifier +// "\156\168\233\179\255\&5\173\140U\187&oi",PropRetainAvailable 187,PropSharedSubscriptionAvailable +// 238,PropSubscriptionIdentifierAvailable 17,PropRequestProblemInformation 207,PropServerKeepAlive +// 1787,PropSubscriptionIdentifierAvailable 187,PropAssignedClientIdentifier "\221",PropSessionExpiryInterval +// 22065,PropSessionExpiryInterval 24448,PropAuthenticationData "\199m\248\213[\219\249\FS\252\234<,f +// \254\206Z\142\FS\184\139\177\220\140W\RS\219\166x\160",PropWillDelayInterval 10612,PropRequestProblemInformation +// 154,PropReceiveMaximum 3414] +TEST(Unsubscribe5QCTest, Encode23) { + uint8_t pkt[] = {0xa2, 0xf9, 0x1, 0x26, 0xfd, 0xd5, 0x1, 0x2a, 0x53, 0x27, 0x0, 0x0, 0x2f, 0xfc, 0x1f, 0x0, 0x1b, + 0xa5, 0x4, 0x4, 0xb6, 0xd4, 0x5f, 0x92, 0xac, 0x83, 0xde, 0xf7, 0xfd, 0x29, 0xb2, 0x5f, 0xd2, 0x1e, + 0x4f, 0xf, 0xd0, 0xed, 0x24, 0x38, 0x70, 0x1b, 0x8a, 0x64, 0x1a, 0x0, 0x4, 0xca, 0x17, 0x50, 0x4f, + 0x25, 0x19, 0x1, 0xa8, 0x1c, 0x0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 0x93, 0x43, 0x47, 0xe1, 0x66, 0xf8, 0x13, 0xf3, 0x22, 0x9, 0x22}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa5, 0x4, 0x4, 0xb6, 0xd4, 0x5f, 0x92, 0xac, 0x83, 0xde, 0xf7, 0xfd, 0x29, 0xb2, + 0x5f, 0xd2, 0x1e, 0x4f, 0xf, 0xd0, 0xed, 0x24, 0x38, 0x70, 0x1b, 0x8a, 0x64}; + uint8_t bytesprops1[] = {0xca, 0x17, 0x50, 0x4f}; + uint8_t bytesprops2[] = {0x12, 0x81, 0x28, 0x9a, 0xf5, 0x6b, 0x34, 0xef, 0x9e, + 0x64, 0x65, 0xfd, 0xa0, 0xaa, 0xb6, 0x6c, 0xad, 0x6a}; + uint8_t bytesprops3[] = {0xf4, 0x68, 0x15, 0xd8, 0x1, 0x15, 0x9a, 0xf0, 0x6c, 0x5e, 0xac, 0xc1, 0x8a, 0x5a, 0x3d, + 0x74, 0x76, 0x81, 0xc3, 0xa8, 0xb2, 0x9a, 0x24, 0x9a, 0xf4, 0xd6, 0xb8, 0x1b, 0x4f}; + uint8_t bytesprops5[] = {0x5d, 0x68, 0x62, 0x18, 0x8b, 0x9e, 0xce, 0xf9, 0x1b, 0x48, 0x44, 0x25, 0xaf, 0xa}; + uint8_t bytesprops4[] = {0xbe, 0xf7, 0xa0, 0xc7, 0xfc, 0xc3, 0x51}; + uint8_t bytesprops6[] = {0x9c, 0xa8, 0xe9, 0xb3, 0xff, 0x35, 0xad, 0x8c, 0x55, 0xbb, 0x26, 0x6f, 0x69}; + uint8_t bytesprops7[] = {0xdd}; + uint8_t bytesprops8[] = {0xc7, 0x6d, 0xf8, 0xd5, 0x5b, 0xdb, 0xf9, 0x1c, 0xfc, 0xea, 0x3c, 0x2c, 0x66, 0x20, 0xfe, + 0xce, 0x5a, 0x8e, 0x1c, 0xb8, 0x8b, 0xb1, 0xdc, 0x8c, 0x57, 0x1e, 0xdb, 0xa6, 0x78, 0xa0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20360}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13975}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops4}, .v = {3, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12284}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops4}, .v = {14, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 238}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1787}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22065}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24448}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10612}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3414}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x68, 0x8, 0xf8, 0xdb, 0xf, 0xc5, 0xa7, 0x94, 0x23, 0xe2, 0x93, 0x99, 0x7d}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xea}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x66, 0xa6, 0xbc, 0x49, 0x38, 0x8a}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xec, 0xa8, 0x63, 0x70}; + lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6f, 0xa6, 0x1c, 0xd2, 0x8a, 0x9c, 0xa6, 0xea, 0x1a, - 0x3a, 0x25, 0x9b, 0x4e, 0x9a, 0xe2, 0x84, 0xe9, 0x45}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7e}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xe0, 0xb2, 0xbe, 0x15, 0xfa, 0x5d, 0x5b, 0x93, 0x43, + 0x47, 0xe1, 0x66, 0xf8, 0x13, 0xf3, 0x22, 0x9, 0x22}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26803, 3, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9981, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22595 ["","r3\FS\a(<\131w\CAN\204\229"] [PropMessageExpiryInterval 9208,PropMaximumQoS -// 227,PropTopicAliasMaximum 25061,PropTopicAliasMaximum 9521,PropWillDelayInterval -// 19511,PropSharedSubscriptionAvailable 152,PropServerReference -// "\233u\f\131\237\DC2\DC4\128\\\185\187R\218_\155t\ENQ\STX\140",PropMaximumPacketSize 4920,PropPayloadFormatIndicator -// 17,PropResponseInformation "\US\186a",PropTopicAlias 2483,PropMaximumPacketSize 139,PropCorrelationData -// "\t\FS\222\252",PropTopicAliasMaximum 602,PropSubscriptionIdentifierAvailable 119,PropWillDelayInterval -// 22699,PropRetainAvailable 215] -TEST(Unsubscribe5QCTest, Encode19) { - uint8_t pkt[] = {0xa2, 0x64, 0x58, 0x43, 0x52, 0x2, 0x0, 0x0, 0x23, 0xf8, 0x24, 0xe3, 0x22, 0x61, 0xe5, - 0x22, 0x25, 0x31, 0x18, 0x0, 0x0, 0x4c, 0x37, 0x2a, 0x98, 0x1c, 0x0, 0x13, 0xe9, 0x75, - 0xc, 0x83, 0xed, 0x12, 0x14, 0x80, 0x5c, 0xb9, 0xbb, 0x52, 0xda, 0x5f, 0x9b, 0x74, 0x5, - 0x2, 0x8c, 0x27, 0x0, 0x0, 0x13, 0x38, 0x1, 0x11, 0x1a, 0x0, 0x3, 0x1f, 0xba, 0x61, - 0x23, 0x9, 0xb3, 0x27, 0x0, 0x0, 0x0, 0x8b, 0x9, 0x0, 0x4, 0x9, 0x1c, 0xde, 0xfc, - 0x22, 0x2, 0x5a, 0x29, 0x77, 0x18, 0x0, 0x0, 0x58, 0xab, 0x25, 0xd7, 0x0, 0x0, 0x0, - 0xb, 0x72, 0x33, 0x1c, 0x7, 0x28, 0x3c, 0x83, 0x77, 0x18, 0xcc, 0xe5}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe9, 0x75, 0xc, 0x83, 0xed, 0x12, 0x14, 0x80, 0x5c, 0xb9, - 0xbb, 0x52, 0xda, 0x5f, 0x9b, 0x74, 0x5, 0x2, 0x8c}; - uint8_t bytesprops1[] = {0x1f, 0xba, 0x61}; - uint8_t bytesprops2[] = {0x9, 0x1c, 0xde, 0xfc}; +// UnsubscribeRequest 12131 [";\204\192\156\203","\131\141H4\GSjh\223\t{hE[\134\CAN\142"] [PropRetainAvailable +// 221,PropRequestProblemInformation 37,PropReceiveMaximum 2247,PropSharedSubscriptionAvailable 7,PropResponseTopic +// "\163\170\&0\238\148\by\229\227g\164\222&\153\137\238L\211\200\192\207\253n\243",PropMessageExpiryInterval +// 13609,PropSubscriptionIdentifier 4,PropResponseInformation +// "\208\ACK\139\252\DC1\ETB\SUB\SYN\154\222\228*\228\CAN\216\139\181",PropMaximumQoS 41,PropMaximumQoS +// 249,PropRequestResponseInformation 149,PropSubscriptionIdentifier 32,PropRequestResponseInformation +// 120,PropTopicAlias 26179,PropServerReference "\249",PropAuthenticationMethod +// "f\142k\131\137\241\&3%\EOT\133\148\168g\140\DC1Q\187\226\169>5\208",PropRetainAvailable 64,PropWillDelayInterval +// 28574,PropResponseTopic "\DLE\246\142\&5\157\168C\255pV\141\v\230\162\222h@ s",PropMessageExpiryInterval +// 32507,PropMaximumQoS 35,PropMaximumQoS 246,PropPayloadFormatIndicator 78,PropSessionExpiryInterval +// 24294,PropMaximumQoS 182,PropMaximumQoS 76,PropContentType "P\232\DC1\144\ETB.\162\147@",PropServerReference +// ".\202T\DLE\ENQy\248R\209\128",PropMessageExpiryInterval 4809] +TEST(Unsubscribe5QCTest, Encode24) { + uint8_t pkt[] = {0xa2, 0xd5, 0x1, 0x2f, 0x63, 0xb8, 0x1, 0x25, 0xdd, 0x17, 0x25, 0x21, 0x8, 0xc7, 0x2a, 0x7, 0x8, + 0x0, 0x18, 0xa3, 0xaa, 0x30, 0xee, 0x94, 0x8, 0x79, 0xe5, 0xe3, 0x67, 0xa4, 0xde, 0x26, 0x99, 0x89, + 0xee, 0x4c, 0xd3, 0xc8, 0xc0, 0xcf, 0xfd, 0x6e, 0xf3, 0x2, 0x0, 0x0, 0x35, 0x29, 0xb, 0x4, 0x1a, + 0x0, 0x11, 0xd0, 0x6, 0x8b, 0xfc, 0x11, 0x17, 0x1a, 0x16, 0x9a, 0xde, 0xe4, 0x2a, 0xe4, 0x18, 0xd8, + 0x8b, 0xb5, 0x24, 0x29, 0x24, 0xf9, 0x19, 0x95, 0xb, 0x20, 0x19, 0x78, 0x23, 0x66, 0x43, 0x1c, 0x0, + 0x1, 0xf9, 0x15, 0x0, 0x16, 0x66, 0x8e, 0x6b, 0x83, 0x89, 0xf1, 0x33, 0x25, 0x4, 0x85, 0x94, 0xa8, + 0x67, 0x8c, 0x11, 0x51, 0xbb, 0xe2, 0xa9, 0x3e, 0x35, 0xd0, 0x25, 0x40, 0x18, 0x0, 0x0, 0x6f, 0x9e, + 0x8, 0x0, 0x13, 0x10, 0xf6, 0x8e, 0x35, 0x9d, 0xa8, 0x43, 0xff, 0x70, 0x56, 0x8d, 0xb, 0xe6, 0xa2, + 0xde, 0x68, 0x40, 0x20, 0x73, 0x2, 0x0, 0x0, 0x7e, 0xfb, 0x24, 0x23, 0x24, 0xf6, 0x1, 0x4e, 0x11, + 0x0, 0x0, 0x5e, 0xe6, 0x24, 0xb6, 0x24, 0x4c, 0x3, 0x0, 0x9, 0x50, 0xe8, 0x11, 0x90, 0x17, 0x2e, + 0xa2, 0x93, 0x40, 0x1c, 0x0, 0xa, 0x2e, 0xca, 0x54, 0x10, 0x5, 0x79, 0xf8, 0x52, 0xd1, 0x80, 0x2, + 0x0, 0x0, 0x12, 0xc9, 0x0, 0x5, 0x3b, 0xcc, 0xc0, 0x9c, 0xcb, 0x0, 0x10, 0x83, 0x8d, 0x48, 0x34, + 0x1d, 0x6a, 0x68, 0xdf, 0x9, 0x7b, 0x68, 0x45, 0x5b, 0x86, 0x18, 0x8e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa3, 0xaa, 0x30, 0xee, 0x94, 0x8, 0x79, 0xe5, 0xe3, 0x67, 0xa4, 0xde, + 0x26, 0x99, 0x89, 0xee, 0x4c, 0xd3, 0xc8, 0xc0, 0xcf, 0xfd, 0x6e, 0xf3}; + uint8_t bytesprops1[] = {0xd0, 0x6, 0x8b, 0xfc, 0x11, 0x17, 0x1a, 0x16, 0x9a, + 0xde, 0xe4, 0x2a, 0xe4, 0x18, 0xd8, 0x8b, 0xb5}; + uint8_t bytesprops2[] = {0xf9}; + uint8_t bytesprops3[] = {0x66, 0x8e, 0x6b, 0x83, 0x89, 0xf1, 0x33, 0x25, 0x4, 0x85, 0x94, + 0xa8, 0x67, 0x8c, 0x11, 0x51, 0xbb, 0xe2, 0xa9, 0x3e, 0x35, 0xd0}; + uint8_t bytesprops4[] = {0x10, 0xf6, 0x8e, 0x35, 0x9d, 0xa8, 0x43, 0xff, 0x70, 0x56, + 0x8d, 0xb, 0xe6, 0xa2, 0xde, 0x68, 0x40, 0x20, 0x73}; + uint8_t bytesprops5[] = {0x50, 0xe8, 0x11, 0x90, 0x17, 0x2e, 0xa2, 0x93, 0x40}; + uint8_t bytesprops6[] = {0x2e, 0xca, 0x54, 0x10, 0x5, 0x79, 0xf8, 0x52, 0xd1, 0x80}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9208}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25061}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9521}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19511}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4920}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2483}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 139}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 602}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22699}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2247}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13609}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 32}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26179}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28574}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32507}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24294}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4809}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x3b, 0xcc, 0xc0, 0x9c, 0xcb}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x72, 0x33, 0x1c, 0x7, 0x28, 0x3c, 0x83, 0x77, 0x18, 0xcc, 0xe5}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x83, 0x8d, 0x48, 0x34, 0x1d, 0x6a, 0x68, 0xdf, + 0x9, 0x7b, 0x68, 0x45, 0x5b, 0x86, 0x18, 0x8e}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22595, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12131, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 907 -// ["\141\FS\ETX\162\204'\133\DLE7\237\140\\w>\252:\aS\161s\SI\179:\248\150E","*,\176\143\254R\241\242\DLE\173a.\225\151\159I:\161","\\X$\251\237\251W\215P\a\133A\163\145\225D\SYN^\163\bf\237\174\STX\141\230\189w\161\162","\217\182-\169\169\173\191Hx@\206Qi\188\231\210D\165\NUL\165\ENQ\220\232\224\226>"] -// [PropCorrelationData "\DC2D\234\t\n\241\140\244[^/\203\222\202^SSp\220\226\158(",PropMessageExpiryInterval -// 2595,PropRetainAvailable 14,PropMaximumPacketSize 149,PropServerKeepAlive 19177,PropReceiveMaximum -// 32247,PropWillDelayInterval 22627,PropUserProperty "" -// "\200\226\240\205\DEL\190{\DC2\132(s\ETB",PropMessageExpiryInterval 1055] -TEST(Unsubscribe5QCTest, Encode20) { - uint8_t pkt[] = {0xa2, 0xb5, 0x1, 0x3, 0x8b, 0x46, 0x9, 0x0, 0x16, 0x12, 0x44, 0xea, 0x9, 0xa, 0xf1, 0x8c, 0xf4, - 0x5b, 0x5e, 0x2f, 0xcb, 0xde, 0xca, 0x5e, 0x53, 0x53, 0x70, 0xdc, 0xe2, 0x9e, 0x28, 0x2, 0x0, 0x0, - 0xa, 0x23, 0x25, 0xe, 0x27, 0x0, 0x0, 0x0, 0x95, 0x13, 0x4a, 0xe9, 0x21, 0x7d, 0xf7, 0x18, 0x0, - 0x0, 0x58, 0x63, 0x26, 0x0, 0x0, 0x0, 0xc, 0xc8, 0xe2, 0xf0, 0xcd, 0x7f, 0xbe, 0x7b, 0x12, 0x84, - 0x28, 0x73, 0x17, 0x2, 0x0, 0x0, 0x4, 0x1f, 0x0, 0x1a, 0x8d, 0x1c, 0x3, 0xa2, 0xcc, 0x27, 0x85, - 0x10, 0x37, 0xed, 0x8c, 0x5c, 0x77, 0x3e, 0xfc, 0x3a, 0x7, 0x53, 0xa1, 0x73, 0xf, 0xb3, 0x3a, 0xf8, - 0x96, 0x45, 0x0, 0x12, 0x2a, 0x2c, 0xb0, 0x8f, 0xfe, 0x52, 0xf1, 0xf2, 0x10, 0xad, 0x61, 0x2e, 0xe1, - 0x97, 0x9f, 0x49, 0x3a, 0xa1, 0x0, 0x1e, 0x5c, 0x58, 0x24, 0xfb, 0xed, 0xfb, 0x57, 0xd7, 0x50, 0x7, - 0x85, 0x41, 0xa3, 0x91, 0xe1, 0x44, 0x16, 0x5e, 0xa3, 0x8, 0x66, 0xed, 0xae, 0x2, 0x8d, 0xe6, 0xbd, - 0x77, 0xa1, 0xa2, 0x0, 0x1a, 0xd9, 0xb6, 0x2d, 0xa9, 0xa9, 0xad, 0xbf, 0x48, 0x78, 0x40, 0xce, 0x51, - 0x69, 0xbc, 0xe7, 0xd2, 0x44, 0xa5, 0x0, 0xa5, 0x5, 0xdc, 0xe8, 0xe0, 0xe2, 0x3e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x12, 0x44, 0xea, 0x9, 0xa, 0xf1, 0x8c, 0xf4, 0x5b, 0x5e, 0x2f, - 0xcb, 0xde, 0xca, 0x5e, 0x53, 0x53, 0x70, 0xdc, 0xe2, 0x9e, 0x28}; - uint8_t bytesprops2[] = {0xc8, 0xe2, 0xf0, 0xcd, 0x7f, 0xbe, 0x7b, 0x12, 0x84, 0x28, 0x73, 0x17}; - uint8_t bytesprops1[] = {0}; +// UnsubscribeRequest 2785 +// ["\208\203\198\224\198v\210\132\218\207\b","\DC4g\193CEY\226\133{\205;","\129E\167\RSx\161\SI\218\ENQ\196\149\136\243\170j\166\208\132m\DEL","lI\225V\SYN&\228E\191\236\171\EM\199eL\DLE-\191\155\223\&5\193\b","\154\ENQp\158 +// dj\212\228\243\245\179\ESC\140\SI\ACK\193\215\a\FSR\DLE","\236\152b\183\203\239\189:A\241\200\CAN\207\221i","\198By$\ACK","\147\f\237\210\b\144w}\129d","\176\231\145U\138\241\252\185\178\238\136oQ\ENQ\187\168\228\197","*\210\FS\252"] +// [PropRetainAvailable 81,PropWildcardSubscriptionAvailable 94,PropPayloadFormatIndicator +// 176,PropSharedSubscriptionAvailable 192,PropUserProperty "\189f\SUBc\254\SO" +// "!6\174\DC4\EOTm%\182\180Ok$rV*\225\\(\167\232\&9q",PropSessionExpiryInterval 29837,PropAssignedClientIdentifier +// ":\246.\GS\193r\DC4\224\186-\209\176\208u\211\&2\251\135\ACK\136\212\145\161\195Y",PropMaximumPacketSize +// 1899,PropSharedSubscriptionAvailable 191,PropReceiveMaximum 8879,PropPayloadFormatIndicator 19,PropResponseTopic +// "\246\128\218f\254\213\&4R\145\140\244\212\173\221;\ENQ\168\255\&6m\STXK\203f",PropAuthenticationMethod +// "o\202\DC4-\246{w\202\234f\179 "] +TEST(Unsubscribe5QCTest, Encode25) { + uint8_t pkt[] = { + 0xa2, 0xa3, 0x2, 0xa, 0xe1, 0x80, 0x1, 0x25, 0x51, 0x28, 0x5e, 0x1, 0xb0, 0x2a, 0xc0, 0x26, 0x0, 0x6, 0xbd, + 0x66, 0x1a, 0x63, 0xfe, 0xe, 0x0, 0x16, 0x21, 0x36, 0xae, 0x14, 0x4, 0x6d, 0x25, 0xb6, 0xb4, 0x4f, 0x6b, 0x24, + 0x72, 0x56, 0x2a, 0xe1, 0x5c, 0x28, 0xa7, 0xe8, 0x39, 0x71, 0x11, 0x0, 0x0, 0x74, 0x8d, 0x12, 0x0, 0x19, 0x3a, + 0xf6, 0x2e, 0x1d, 0xc1, 0x72, 0x14, 0xe0, 0xba, 0x2d, 0xd1, 0xb0, 0xd0, 0x75, 0xd3, 0x32, 0xfb, 0x87, 0x6, 0x88, + 0xd4, 0x91, 0xa1, 0xc3, 0x59, 0x27, 0x0, 0x0, 0x7, 0x6b, 0x2a, 0xbf, 0x21, 0x22, 0xaf, 0x1, 0x13, 0x8, 0x0, + 0x18, 0xf6, 0x80, 0xda, 0x66, 0xfe, 0xd5, 0x34, 0x52, 0x91, 0x8c, 0xf4, 0xd4, 0xad, 0xdd, 0x3b, 0x5, 0xa8, 0xff, + 0x36, 0x6d, 0x2, 0x4b, 0xcb, 0x66, 0x15, 0x0, 0xc, 0x6f, 0xca, 0x14, 0x2d, 0xf6, 0x7b, 0x77, 0xca, 0xea, 0x66, + 0xb3, 0x20, 0x0, 0xb, 0xd0, 0xcb, 0xc6, 0xe0, 0xc6, 0x76, 0xd2, 0x84, 0xda, 0xcf, 0x8, 0x0, 0xb, 0x14, 0x67, + 0xc1, 0x43, 0x45, 0x59, 0xe2, 0x85, 0x7b, 0xcd, 0x3b, 0x0, 0x14, 0x81, 0x45, 0xa7, 0x1e, 0x78, 0xa1, 0xf, 0xda, + 0x5, 0xc4, 0x95, 0x88, 0xf3, 0xaa, 0x6a, 0xa6, 0xd0, 0x84, 0x6d, 0x7f, 0x0, 0x17, 0x6c, 0x49, 0xe1, 0x56, 0x16, + 0x26, 0xe4, 0x45, 0xbf, 0xec, 0xab, 0x19, 0xc7, 0x65, 0x4c, 0x10, 0x2d, 0xbf, 0x9b, 0xdf, 0x35, 0xc1, 0x8, 0x0, + 0x16, 0x9a, 0x5, 0x70, 0x9e, 0x20, 0x64, 0x6a, 0xd4, 0xe4, 0xf3, 0xf5, 0xb3, 0x1b, 0x8c, 0xf, 0x6, 0xc1, 0xd7, + 0x7, 0x1c, 0x52, 0x10, 0x0, 0xf, 0xec, 0x98, 0x62, 0xb7, 0xcb, 0xef, 0xbd, 0x3a, 0x41, 0xf1, 0xc8, 0x18, 0xcf, + 0xdd, 0x69, 0x0, 0x5, 0xc6, 0x42, 0x79, 0x24, 0x6, 0x0, 0xa, 0x93, 0xc, 0xed, 0xd2, 0x8, 0x90, 0x77, 0x7d, + 0x81, 0x64, 0x0, 0x12, 0xb0, 0xe7, 0x91, 0x55, 0x8a, 0xf1, 0xfc, 0xb9, 0xb2, 0xee, 0x88, 0x6f, 0x51, 0x5, 0xbb, + 0xa8, 0xe4, 0xc5, 0x0, 0x4, 0x2a, 0xd2, 0x1c, 0xfc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x21, 0x36, 0xae, 0x14, 0x4, 0x6d, 0x25, 0xb6, 0xb4, 0x4f, 0x6b, + 0x24, 0x72, 0x56, 0x2a, 0xe1, 0x5c, 0x28, 0xa7, 0xe8, 0x39, 0x71}; + uint8_t bytesprops0[] = {0xbd, 0x66, 0x1a, 0x63, 0xfe, 0xe}; + uint8_t bytesprops2[] = {0x3a, 0xf6, 0x2e, 0x1d, 0xc1, 0x72, 0x14, 0xe0, 0xba, 0x2d, 0xd1, 0xb0, 0xd0, + 0x75, 0xd3, 0x32, 0xfb, 0x87, 0x6, 0x88, 0xd4, 0x91, 0xa1, 0xc3, 0x59}; + uint8_t bytesprops3[] = {0xf6, 0x80, 0xda, 0x66, 0xfe, 0xd5, 0x34, 0x52, 0x91, 0x8c, 0xf4, 0xd4, + 0xad, 0xdd, 0x3b, 0x5, 0xa8, 0xff, 0x36, 0x6d, 0x2, 0x4b, 0xcb, 0x66}; + uint8_t bytesprops4[] = {0x6f, 0xca, 0x14, 0x2d, 0xf6, 0x7b, 0x77, 0xca, 0xea, 0x66, 0xb3, 0x20}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2595}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 149}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19177}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32247}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22627}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops1}, .v = {12, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1055}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {22, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29837}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1899}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8879}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x8d, 0x1c, 0x3, 0xa2, 0xcc, 0x27, 0x85, 0x10, 0x37, 0xed, 0x8c, 0x5c, 0x77, - 0x3e, 0xfc, 0x3a, 0x7, 0x53, 0xa1, 0x73, 0xf, 0xb3, 0x3a, 0xf8, 0x96, 0x45}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd0, 0xcb, 0xc6, 0xe0, 0xc6, 0x76, 0xd2, 0x84, 0xda, 0xcf, 0x8}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2a, 0x2c, 0xb0, 0x8f, 0xfe, 0x52, 0xf1, 0xf2, 0x10, - 0xad, 0x61, 0x2e, 0xe1, 0x97, 0x9f, 0x49, 0x3a, 0xa1}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x14, 0x67, 0xc1, 0x43, 0x45, 0x59, 0xe2, 0x85, 0x7b, 0xcd, 0x3b}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5c, 0x58, 0x24, 0xfb, 0xed, 0xfb, 0x57, 0xd7, 0x50, 0x7, - 0x85, 0x41, 0xa3, 0x91, 0xe1, 0x44, 0x16, 0x5e, 0xa3, 0x8, - 0x66, 0xed, 0xae, 0x2, 0x8d, 0xe6, 0xbd, 0x77, 0xa1, 0xa2}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x81, 0x45, 0xa7, 0x1e, 0x78, 0xa1, 0xf, 0xda, 0x5, 0xc4, + 0x95, 0x88, 0xf3, 0xaa, 0x6a, 0xa6, 0xd0, 0x84, 0x6d, 0x7f}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd9, 0xb6, 0x2d, 0xa9, 0xa9, 0xad, 0xbf, 0x48, 0x78, 0x40, 0xce, 0x51, 0x69, - 0xbc, 0xe7, 0xd2, 0x44, 0xa5, 0x0, 0xa5, 0x5, 0xdc, 0xe8, 0xe0, 0xe2, 0x3e}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6c, 0x49, 0xe1, 0x56, 0x16, 0x26, 0xe4, 0x45, 0xbf, 0xec, 0xab, 0x19, + 0xc7, 0x65, 0x4c, 0x10, 0x2d, 0xbf, 0x9b, 0xdf, 0x35, 0xc1, 0x8}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x9a, 0x5, 0x70, 0x9e, 0x20, 0x64, 0x6a, 0xd4, 0xe4, 0xf3, 0xf5, + 0xb3, 0x1b, 0x8c, 0xf, 0x6, 0xc1, 0xd7, 0x7, 0x1c, 0x52, 0x10}; + lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xec, 0x98, 0x62, 0xb7, 0xcb, 0xef, 0xbd, 0x3a, + 0x41, 0xf1, 0xc8, 0x18, 0xcf, 0xdd, 0x69}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc6, 0x42, 0x79, 0x24, 0x6}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x93, 0xc, 0xed, 0xd2, 0x8, 0x90, 0x77, 0x7d, 0x81, 0x64}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xb0, 0xe7, 0x91, 0x55, 0x8a, 0xf1, 0xfc, 0xb9, 0xb2, + 0xee, 0x88, 0x6f, 0x51, 0x5, 0xbb, 0xa8, 0xe4, 0xc5}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x2a, 0xd2, 0x1c, 0xfc}; + lwmqtt_string_t topic_filter_s9 = {4, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 907, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2785, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24572 -// ["\209r2\129\173f\255\143\237!\188m\134\&4#\167\156\211[@D\181\SO\161\210\n\235\&4","\133\164\149\&5\205\251\223","Bf.\183r\147H\252","/\130V\141\130\200\131\248\b\162Eb\DC2\EM\202r\182\251\FSKJ\186"] -// [PropCorrelationData -// "\205^\EM\241I\ACKH\152ni\249\224\&1\DC1\157\142>\149\218\&2\226\242\166\DLEL\141\217\158k?",PropCorrelationData -// "\"O\248\226\189\164\192",PropSessionExpiryInterval 43,PropServerReference "z\214\130",PropReasonString -// "b~3\ETX!Z\252\198\128\181#\243\202",PropMessageExpiryInterval 6944,PropRetainAvailable -// 127,PropSharedSubscriptionAvailable 183,PropAuthenticationMethod "\232\t\139\253!",PropContentType -// "\176\184#\GStZ$>\185Bk\175\183\RSb\DC3\235\204",PropPayloadFormatIndicator 239,PropSubscriptionIdentifier -// 3,PropRequestResponseInformation 209,PropServerReference "",PropSubscriptionIdentifier 17,PropSubscriptionIdentifier -// 4,PropServerKeepAlive 29028,PropRequestResponseInformation 90,PropMessageExpiryInterval 28968,PropRetainAvailable -// 43,PropResponseTopic "\141Mv\160\SOH\197|\226\136\&9Om)\176:\205\v]",PropAuthenticationData -// "\n\237\EOTp\SYN\195\158\155\171\230\t\226>\245N\249\191F\ETX\252\203Y\224C\229S",PropAuthenticationMethod -// "\135\166\CAN0\128\159\188\244\DC4-\130\191\173\188\225y\225\141\129S0\a\201D\231\159\222",PropTopicAlias -// 21823,PropWildcardSubscriptionAvailable 248,PropUserProperty "t\193\234\184\SYNi\DEL\147\ACK" "z\212#\175\144~\n"] -TEST(Unsubscribe5QCTest, Encode21) { +// UnsubscribeRequest 3283 +// ["\151","\140k\206\231T4\165\221\&7\206\161\&9\DC2z9\GS\146\232`AuR/&\215\192\226\253","\243?\170\SYNAk\239?W\173","\143l\157\212\165\140<-\"\250\185\166\SOHpBD\213\&5Y3\178\150\186\n\187\194%","\r\250\DLE'?\210\182\153\215\198\173\206k\201Vo\185\236\229\229","\176\171\220\205\STX>\227\CAN\239\167OEZ0s\170\DC2\165B\132r\134?\170L\216\246\162\"\136","\208^\167Dh\248\177\171~k\f\134U8 +// \216\198\252\130\US\DEL*Mq)\186","\164[\150\159l\245a\169W]\ENQ=D\230\143\235\193\215\183:\217\244\EOT\236\CAN\221)\210","\191X\198\252\128?S\147\r>O\b\SUB\215L\222\239\201\157dEh\236\DC2\214'\186\243\\\161"] +// [PropRequestResponseInformation 161,PropRetainAvailable 224,PropMaximumQoS 111] +TEST(Unsubscribe5QCTest, Encode26) { uint8_t pkt[] = { - 0xa2, 0xbc, 0x2, 0x5f, 0xfc, 0xef, 0x1, 0x9, 0x0, 0x1e, 0xcd, 0x5e, 0x19, 0xf1, 0x49, 0x6, 0x48, 0x98, 0x6e, - 0x69, 0xf9, 0xe0, 0x31, 0x11, 0x9d, 0x8e, 0x3e, 0x95, 0xda, 0x32, 0xe2, 0xf2, 0xa6, 0x10, 0x4c, 0x8d, 0xd9, 0x9e, - 0x6b, 0x3f, 0x9, 0x0, 0x7, 0x22, 0x4f, 0xf8, 0xe2, 0xbd, 0xa4, 0xc0, 0x11, 0x0, 0x0, 0x0, 0x2b, 0x1c, 0x0, - 0x3, 0x7a, 0xd6, 0x82, 0x1f, 0x0, 0xd, 0x62, 0x7e, 0x33, 0x3, 0x21, 0x5a, 0xfc, 0xc6, 0x80, 0xb5, 0x23, 0xf3, - 0xca, 0x2, 0x0, 0x0, 0x1b, 0x20, 0x25, 0x7f, 0x2a, 0xb7, 0x15, 0x0, 0x5, 0xe8, 0x9, 0x8b, 0xfd, 0x21, 0x3, - 0x0, 0x12, 0xb0, 0xb8, 0x23, 0x1d, 0x74, 0x5a, 0x24, 0x3e, 0xb9, 0x42, 0x6b, 0xaf, 0xb7, 0x1e, 0x62, 0x13, 0xeb, - 0xcc, 0x1, 0xef, 0xb, 0x3, 0x19, 0xd1, 0x1c, 0x0, 0x0, 0xb, 0x11, 0xb, 0x4, 0x13, 0x71, 0x64, 0x19, 0x5a, - 0x2, 0x0, 0x0, 0x71, 0x28, 0x25, 0x2b, 0x8, 0x0, 0x12, 0x8d, 0x4d, 0x76, 0xa0, 0x1, 0xc5, 0x7c, 0xe2, 0x88, - 0x39, 0x4f, 0x6d, 0x29, 0xb0, 0x3a, 0xcd, 0xb, 0x5d, 0x16, 0x0, 0x1a, 0xa, 0xed, 0x4, 0x70, 0x16, 0xc3, 0x9e, - 0x9b, 0xab, 0xe6, 0x9, 0xe2, 0x3e, 0xf5, 0x4e, 0xf9, 0xbf, 0x46, 0x3, 0xfc, 0xcb, 0x59, 0xe0, 0x43, 0xe5, 0x53, - 0x15, 0x0, 0x1b, 0x87, 0xa6, 0x18, 0x30, 0x80, 0x9f, 0xbc, 0xf4, 0x14, 0x2d, 0x82, 0xbf, 0xad, 0xbc, 0xe1, 0x79, - 0xe1, 0x8d, 0x81, 0x53, 0x30, 0x7, 0xc9, 0x44, 0xe7, 0x9f, 0xde, 0x23, 0x55, 0x3f, 0x28, 0xf8, 0x26, 0x0, 0x9, - 0x74, 0xc1, 0xea, 0xb8, 0x16, 0x69, 0x7f, 0x93, 0x6, 0x0, 0x7, 0x7a, 0xd4, 0x23, 0xaf, 0x90, 0x7e, 0xa, 0x0, - 0x1c, 0xd1, 0x72, 0x32, 0x81, 0xad, 0x66, 0xff, 0x8f, 0xed, 0x21, 0xbc, 0x6d, 0x86, 0x34, 0x23, 0xa7, 0x9c, 0xd3, - 0x5b, 0x40, 0x44, 0xb5, 0xe, 0xa1, 0xd2, 0xa, 0xeb, 0x34, 0x0, 0x7, 0x85, 0xa4, 0x95, 0x35, 0xcd, 0xfb, 0xdf, - 0x0, 0x8, 0x42, 0x66, 0x2e, 0xb7, 0x72, 0x93, 0x48, 0xfc, 0x0, 0x16, 0x2f, 0x82, 0x56, 0x8d, 0x82, 0xc8, 0x83, - 0xf8, 0x8, 0xa2, 0x45, 0x62, 0x12, 0x19, 0xca, 0x72, 0xb6, 0xfb, 0x1c, 0x4b, 0x4a, 0xba}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xcd, 0x5e, 0x19, 0xf1, 0x49, 0x6, 0x48, 0x98, 0x6e, 0x69, 0xf9, 0xe0, 0x31, 0x11, 0x9d, - 0x8e, 0x3e, 0x95, 0xda, 0x32, 0xe2, 0xf2, 0xa6, 0x10, 0x4c, 0x8d, 0xd9, 0x9e, 0x6b, 0x3f}; - uint8_t bytesprops1[] = {0x22, 0x4f, 0xf8, 0xe2, 0xbd, 0xa4, 0xc0}; - uint8_t bytesprops2[] = {0x7a, 0xd6, 0x82}; - uint8_t bytesprops3[] = {0x62, 0x7e, 0x33, 0x3, 0x21, 0x5a, 0xfc, 0xc6, 0x80, 0xb5, 0x23, 0xf3, 0xca}; - uint8_t bytesprops4[] = {0xe8, 0x9, 0x8b, 0xfd, 0x21}; - uint8_t bytesprops5[] = {0xb0, 0xb8, 0x23, 0x1d, 0x74, 0x5a, 0x24, 0x3e, 0xb9, - 0x42, 0x6b, 0xaf, 0xb7, 0x1e, 0x62, 0x13, 0xeb, 0xcc}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops7[] = {0x8d, 0x4d, 0x76, 0xa0, 0x1, 0xc5, 0x7c, 0xe2, 0x88, - 0x39, 0x4f, 0x6d, 0x29, 0xb0, 0x3a, 0xcd, 0xb, 0x5d}; - uint8_t bytesprops8[] = {0xa, 0xed, 0x4, 0x70, 0x16, 0xc3, 0x9e, 0x9b, 0xab, 0xe6, 0x9, 0xe2, 0x3e, - 0xf5, 0x4e, 0xf9, 0xbf, 0x46, 0x3, 0xfc, 0xcb, 0x59, 0xe0, 0x43, 0xe5, 0x53}; - uint8_t bytesprops9[] = {0x87, 0xa6, 0x18, 0x30, 0x80, 0x9f, 0xbc, 0xf4, 0x14, 0x2d, 0x82, 0xbf, 0xad, 0xbc, - 0xe1, 0x79, 0xe1, 0x8d, 0x81, 0x53, 0x30, 0x7, 0xc9, 0x44, 0xe7, 0x9f, 0xde}; - uint8_t bytesprops11[] = {0x7a, 0xd4, 0x23, 0xaf, 0x90, 0x7e, 0xa}; - uint8_t bytesprops10[] = {0x74, 0xc1, 0xea, 0xb8, 0x16, 0x69, 0x7f, 0x93, 0x6}; + 0xa2, 0x87, 0x2, 0xc, 0xd3, 0x6, 0x19, 0xa1, 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x20, 0xd8, 0xc6, 0xfc, 0x82, 0x1f, 0x7f, 0x2a, 0x4d, 0x71, 0x29, 0xba, 0x0, 0x1c, 0xa4, 0x5b, 0x96, + 0x9f, 0x6c, 0xf5, 0x61, 0xa9, 0x57, 0x5d, 0x5, 0x3d, 0x44, 0xe6, 0x8f, 0xeb, 0xc1, 0xd7, 0xb7, 0x3a, 0xd9, 0xf4, + 0x4, 0xec, 0x18, 0xdd, 0x29, 0xd2, 0x0, 0x1e, 0xbf, 0x58, 0xc6, 0xfc, 0x80, 0x3f, 0x53, 0x93, 0xd, 0x3e, 0x4f, + 0x8, 0x1a, 0xd7, 0x4c, 0xde, 0xef, 0xc9, 0x9d, 0x64, 0x45, 0x68, 0xec, 0x12, 0xd6, 0x27, 0xba, 0xf3, 0x5c, 0xa1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 43}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6944}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29028}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28968}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21823}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops10}, .v = {7, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 111}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xd1, 0x72, 0x32, 0x81, 0xad, 0x66, 0xff, 0x8f, 0xed, 0x21, - 0xbc, 0x6d, 0x86, 0x34, 0x23, 0xa7, 0x9c, 0xd3, 0x5b, 0x40, - 0x44, 0xb5, 0xe, 0xa1, 0xd2, 0xa, 0xeb, 0x34}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x97}; + lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x85, 0xa4, 0x95, 0x35, 0xcd, 0xfb, 0xdf}; - lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x8c, 0x6b, 0xce, 0xe7, 0x54, 0x34, 0xa5, 0xdd, 0x37, 0xce, + 0xa1, 0x39, 0x12, 0x7a, 0x39, 0x1d, 0x92, 0xe8, 0x60, 0x41, + 0x75, 0x52, 0x2f, 0x26, 0xd7, 0xc0, 0xe2, 0xfd}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x42, 0x66, 0x2e, 0xb7, 0x72, 0x93, 0x48, 0xfc}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf3, 0x3f, 0xaa, 0x16, 0x41, 0x6b, 0xef, 0x3f, 0x57, 0xad}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2f, 0x82, 0x56, 0x8d, 0x82, 0xc8, 0x83, 0xf8, 0x8, 0xa2, 0x45, - 0x62, 0x12, 0x19, 0xca, 0x72, 0xb6, 0xfb, 0x1c, 0x4b, 0x4a, 0xba}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x8f, 0x6c, 0x9d, 0xd4, 0xa5, 0x8c, 0x3c, 0x2d, 0x22, 0xfa, 0xb9, 0xa6, 0x1, 0x70, + 0x42, 0x44, 0xd5, 0x35, 0x59, 0x33, 0xb2, 0x96, 0xba, 0xa, 0xbb, 0xc2, 0x25}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xd, 0xfa, 0x10, 0x3c, 0x67, 0x95, 0xe0, 0x9f, 0x9f, 0x98, + 0xd3, 0x69, 0x87, 0xa3, 0x8e, 0x26, 0xa5, 0xdb, 0x19, 0x3a, + 0xf, 0x10, 0x36, 0x5b, 0xbb, 0x71, 0x21, 0x24}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x3, 0x53, 0xfb, 0x81, 0x85, 0x2c, 0xb7, 0xba, 0x3e, 0x27, 0x3f, 0xd2, 0xb6, + 0x99, 0xd7, 0xc6, 0xad, 0xce, 0x6b, 0xc9, 0x56, 0x6f, 0xb9, 0xec, 0xe5, 0xe5}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xb0, 0xab, 0xdc, 0xcd, 0x2, 0x3e, 0xe3, 0x18, 0xef, 0xa7, + 0x4f, 0x45, 0x5a, 0x30, 0x73, 0xaa, 0x12, 0xa5, 0x42, 0x84, + 0x72, 0x86, 0x3f, 0xaa, 0x4c, 0xd8, 0xf6, 0xa2, 0x22, 0x88}; + lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xd0, 0x5e, 0xa7, 0x44, 0x68, 0xf8, 0xb1, 0xab, 0x7e, 0x6b, 0xc, 0x86, 0x55, + 0x38, 0x20, 0xd8, 0xc6, 0xfc, 0x82, 0x1f, 0x7f, 0x2a, 0x4d, 0x71, 0x29, 0xba}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xa4, 0x5b, 0x96, 0x9f, 0x6c, 0xf5, 0x61, 0xa9, 0x57, 0x5d, + 0x5, 0x3d, 0x44, 0xe6, 0x8f, 0xeb, 0xc1, 0xd7, 0xb7, 0x3a, + 0xd9, 0xf4, 0x4, 0xec, 0x18, 0xdd, 0x29, 0xd2}; + lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xbf, 0x58, 0xc6, 0xfc, 0x80, 0x3f, 0x53, 0x93, 0xd, 0x3e, + 0x4f, 0x8, 0x1a, 0xd7, 0x4c, 0xde, 0xef, 0xc9, 0x9d, 0x64, + 0x45, 0x68, 0xec, 0x12, 0xd6, 0x27, 0xba, 0xf3, 0x5c, 0xa1}; + lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24572, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3283, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22215 -// ["tkb\217BA\193-\r\243\141\144\131?#\SO\181p\150,\n\DEL)!","`\148\&8\EOT\EM\209\DLEI\193\218\148\180?\184X`,","\177V]\a8>\139\248\US\158\&4Pz\232|\147S\229\149\145\150\170\185\240'","\242M!M\182ds\247I\DEL\233\&0X),\206\155\200\232\182","s\SOH\149\210\176E\148\180\164\142\v\225gk\198\168\139/\161\240\249T\155)\140*","\165\EM\192\148-\241\213\188\182w\155\ESC*\NUL\RS*)\177h","\244\148-\DC3A\174,d\225\215d\170x"] -// [PropTopicAliasMaximum 31672,PropWildcardSubscriptionAvailable 140,PropTopicAlias 31200,PropResponseInformation -// "\t\192\t",PropRequestProblemInformation 247,PropSharedSubscriptionAvailable 136,PropReceiveMaximum -// 3232,PropRequestResponseInformation 225,PropReceiveMaximum 12340] -T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0x94, 0x2d, 0x13, 0x41, 0xae, 0x2c, 0x64, 0xe1, 0xd7, 0x64, 0xaa, 0x78}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x9, 0xc0, 0x9}; +// UnsubscribeRequest 22892 +// ["\235\157\254\138\f\159\160H\226\159\167\206[L\221\133p\185;","/\162\192\a\217\171[\233\178\227GTN~\SOHzIl\DC3G\195C(FH\241=He\251","n\212\225g\136\SYNK\222\238\207\137","","\ETB7!\RSO\252\EM4B\253\DEL\USs}\246e\192\201\135\DC1\174","\183~\216m","\174K\216\SUB\179 +// \EMB\EMpq\EMl"] [PropMessageExpiryInterval 30491,PropMessageExpiryInterval 12126] +TEST(Unsubscribe5QCTest, Encode27) { + uint8_t pkt[] = {0xa2, 0x7d, 0x59, 0x6c, 0xa, 0x2, 0x0, 0x0, 0x77, 0x1b, 0x2, 0x0, 0x0, 0x2f, 0x5e, 0x0, + 0x13, 0xeb, 0x9d, 0xfe, 0x8a, 0xc, 0x9f, 0xa0, 0x48, 0xe2, 0x9f, 0xa7, 0xce, 0x5b, 0x4c, 0xdd, + 0x85, 0x70, 0xb9, 0x3b, 0x0, 0x1e, 0x2f, 0xa2, 0xc0, 0x7, 0xd9, 0xab, 0x5b, 0xe9, 0xb2, 0xe3, + 0x47, 0x54, 0x4e, 0x7e, 0x1, 0x7a, 0x49, 0x6c, 0x13, 0x47, 0xc3, 0x43, 0x28, 0x46, 0x48, 0xf1, + 0x3d, 0x48, 0x65, 0xfb, 0x0, 0xb, 0x6e, 0xd4, 0xe1, 0x67, 0x88, 0x16, 0x4b, 0xde, 0xee, 0xcf, + 0x89, 0x0, 0x0, 0x0, 0x15, 0x17, 0x37, 0x21, 0x1e, 0x4f, 0xfc, 0x19, 0x34, 0x42, 0xfd, 0x7f, + 0x1f, 0x73, 0x7d, 0xf6, 0x65, 0xc0, 0xc9, 0x87, 0x11, 0xae, 0x0, 0x4, 0xb7, 0x7e, 0xd8, 0x6d, + 0x0, 0xd, 0xae, 0x4b, 0xd8, 0x1a, 0xb3, 0x20, 0x19, 0x42, 0x19, 0x70, 0x71, 0x19, 0x6c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31672}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31200}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3232}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12340}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30491}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12126}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x74, 0x6b, 0x62, 0xd9, 0x42, 0x41, 0xc1, 0x2d, 0xd, 0xf3, 0x8d, 0x90, - 0x83, 0x3f, 0x23, 0xe, 0xb5, 0x70, 0x96, 0x2c, 0xa, 0x7f, 0x29, 0x21}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xeb, 0x9d, 0xfe, 0x8a, 0xc, 0x9f, 0xa0, 0x48, 0xe2, 0x9f, + 0xa7, 0xce, 0x5b, 0x4c, 0xdd, 0x85, 0x70, 0xb9, 0x3b}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x60, 0x94, 0x38, 0x4, 0x19, 0xd1, 0x10, 0x49, 0xc1, - 0xda, 0x94, 0xb4, 0x3f, 0xb8, 0x58, 0x60, 0x2c}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2f, 0xa2, 0xc0, 0x7, 0xd9, 0xab, 0x5b, 0xe9, 0xb2, 0xe3, + 0x47, 0x54, 0x4e, 0x7e, 0x1, 0x7a, 0x49, 0x6c, 0x13, 0x47, + 0xc3, 0x43, 0x28, 0x46, 0x48, 0xf1, 0x3d, 0x48, 0x65, 0xfb}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb1, 0x56, 0x5d, 0x7, 0x38, 0x3e, 0x8b, 0xf8, 0x1f, 0x9e, 0x34, 0x50, 0x7a, - 0xe8, 0x7c, 0x93, 0x53, 0xe5, 0x95, 0x91, 0x96, 0xaa, 0xb9, 0xf0, 0x27}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6e, 0xd4, 0xe1, 0x67, 0x88, 0x16, 0x4b, 0xde, 0xee, 0xcf, 0x89}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf2, 0x4d, 0x21, 0x4d, 0xb6, 0x64, 0x73, 0xf7, 0x49, 0x7f, - 0xe9, 0x30, 0x58, 0x29, 0x2c, 0xce, 0x9b, 0xc8, 0xe8, 0xb6}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x73, 0x1, 0x95, 0xd2, 0xb0, 0x45, 0x94, 0xb4, 0xa4, 0x8e, 0xb, 0xe1, 0x67, - 0x6b, 0xc6, 0xa8, 0x8b, 0x2f, 0xa1, 0xf0, 0xf9, 0x54, 0x9b, 0x29, 0x8c, 0x2a}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x17, 0x37, 0x21, 0x1e, 0x4f, 0xfc, 0x19, 0x34, 0x42, 0xfd, 0x7f, + 0x1f, 0x73, 0x7d, 0xf6, 0x65, 0xc0, 0xc9, 0x87, 0x11, 0xae}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa5, 0x19, 0xc0, 0x94, 0x2d, 0xf1, 0xd5, 0xbc, 0xb6, 0x77, - 0x9b, 0x1b, 0x2a, 0x0, 0x1e, 0x2a, 0x29, 0xb1, 0x68}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xb7, 0x7e, 0xd8, 0x6d}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xf4, 0x94, 0x2d, 0x13, 0x41, 0xae, 0x2c, 0x64, 0xe1, 0xd7, 0x64, 0xaa, 0x78}; + uint8_t topic_filter_s6_bytes[] = {0xae, 0x4b, 0xd8, 0x1a, 0xb3, 0x20, 0x19, 0x42, 0x19, 0x70, 0x71, 0x19, 0x6c}; lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22215, 7, topic_filters, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// UnsubscribeRequest 6585 -// ["\230\183q\150\255f\RS\133,\EM\151s\DC4","\160\239\214T\CANS\255\134\169\182\167ri\233\201","B\149Ms7\DC2\234x\185t\233\239\247\EOT\150\\\225\NUL\DC4\SO$\tP\190\DC3","\231\130\&50\142?\232\228\STX\183\182\159h\211\140\218N\ESC\ENQL\161=\158\251\166","\218\230\&2\130\163\DLE","\130q\162\EOT:\240\"\206`\134|\162","l\185N\132\177\203*","SB\DC1\\\186\191\167iq\187\204\a\NAK\137\214u\155\n"] -// [PropWildcardSubscriptionAvailable 25,PropWildcardSubscriptionAvailable 71,PropResponseInformation -// "\159\253\198f\154\DC1\143e\153\a|W\208\140f\210\DC4H\227\144\183",PropSubscriptionIdentifier 27,PropResponseTopic -// "\128\176XG\181\NUL\r\228\220\237\DC3O\173\ETB\239vD2\ENQ\156\180",PropTopicAlias 23925,PropReasonString -// "{=@F\SO\159\238\207w\145\136\243j\172L\200\246\192U*\212\131@\215A\239el*\187",PropMaximumQoS -// 225,PropWillDelayInterval 32196,PropSubscriptionIdentifierAvailable 174,PropServerReference -// "\238\186y\159\214\137j<\153\195\202\\\160W\"\204!\214C",PropMessageExpiryInterval 14388,PropPayloadFormatIndicator -// 179,PropServerReference "\"\GS\132\146\241\184\t\157\128",PropMessageExpiryInterval 25165,PropWillDelayInterval -// 5332,PropRequestProblemInformation 55,PropWillDelayInterval 1710,PropContentType -// "8\217\136\SYN\241\SI",PropMaximumPacketSize 11435,PropUserProperty "<\254\STX\227\&7\240D" -// "TswK\\L/\217\138A\195\230\158\227VT\r\178",PropMessageExpiryInterval 12725,PropTopicAliasMaximum -// 29756,PropResponseTopic "\253\&6w\174\223\r\bO\178#\156/\243\140:N\132U\155\244^",PropTopicAliasMaximum -// 30499,PropContentType "\138o4K\192\228\ETXR\165\172T\227GE3",PropServerReference -// "\158u\167{7\198\aC\160x[\199\128\144\213\140+s\226\128\191\146\221N\241Y",PropSubscriptionIdentifier 4] -TEST(Unsubscribe5QCTest, Encode23) { - uint8_t pkt[] = { - 0xa2, 0xaa, 0x3, 0x19, 0xb9, 0x9d, 0x2, 0x28, 0x19, 0x28, 0x47, 0x1a, 0x0, 0x15, 0x9f, 0xfd, 0xc6, 0x66, 0x9a, - 0x11, 0x8f, 0x65, 0x99, 0x7, 0x7c, 0x57, 0xd0, 0x8c, 0x66, 0xd2, 0x14, 0x48, 0xe3, 0x90, 0xb7, 0xb, 0x1b, 0x8, - 0x0, 0x15, 0x80, 0xb0, 0x58, 0x47, 0xb5, 0x0, 0xd, 0xe4, 0xdc, 0xed, 0x13, 0x4f, 0xad, 0x17, 0xef, 0x76, 0x44, - 0x32, 0x5, 0x9c, 0xb4, 0x23, 0x5d, 0x75, 0x1f, 0x0, 0x1e, 0x7b, 0x3d, 0x40, 0x46, 0xe, 0x9f, 0xee, 0xcf, 0x77, - 0x91, 0x88, 0xf3, 0x6a, 0xac, 0x4c, 0xc8, 0xf6, 0xc0, 0x55, 0x2a, 0xd4, 0x83, 0x40, 0xd7, 0x41, 0xef, 0x65, 0x6c, - 0x2a, 0xbb, 0x24, 0xe1, 0x18, 0x0, 0x0, 0x7d, 0xc4, 0x29, 0xae, 0x1c, 0x0, 0x13, 0xee, 0xba, 0x79, 0x9f, 0xd6, - 0x89, 0x6a, 0x3c, 0x99, 0xc3, 0xca, 0x5c, 0xa0, 0x57, 0x22, 0xcc, 0x21, 0xd6, 0x43, 0x2, 0x0, 0x0, 0x38, 0x34, - 0x1, 0xb3, 0x1c, 0x0, 0x9, 0x22, 0x1d, 0x84, 0x92, 0xf1, 0xb8, 0x9, 0x9d, 0x80, 0x2, 0x0, 0x0, 0x62, 0x4d, - 0x18, 0x0, 0x0, 0x14, 0xd4, 0x17, 0x37, 0x18, 0x0, 0x0, 0x6, 0xae, 0x3, 0x0, 0x6, 0x38, 0xd9, 0x88, 0x16, - 0xf1, 0xf, 0x27, 0x0, 0x0, 0x2c, 0xab, 0x26, 0x0, 0x7, 0x3c, 0x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0x4e, 0x1b, 0x5, 0x4c, 0xa1, 0x3d, 0x9e, 0xfb, 0xa6, 0x0, 0x6, - 0xda, 0xe6, 0x32, 0x82, 0xa3, 0x10, 0x0, 0xc, 0x82, 0x71, 0xa2, 0x4, 0x3a, 0xf0, 0x22, 0xce, 0x60, 0x86, 0x7c, - 0xa2, 0x0, 0x7, 0x6c, 0xb9, 0x4e, 0x84, 0xb1, 0xcb, 0x2a, 0x0, 0x12, 0x53, 0x42, 0x11, 0x5c, 0xba, 0xbf, 0xa7, - 0x69, 0x71, 0xbb, 0xcc, 0x7, 0x15, 0x89, 0xd6, 0x75, 0x9b, 0xa}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x9f, 0xfd, 0xc6, 0x66, 0x9a, 0x11, 0x8f, 0x65, 0x99, 0x7, 0x7c, - 0x57, 0xd0, 0x8c, 0x66, 0xd2, 0x14, 0x48, 0xe3, 0x90, 0xb7}; - uint8_t bytesprops1[] = {0x80, 0xb0, 0x58, 0x47, 0xb5, 0x0, 0xd, 0xe4, 0xdc, 0xed, 0x13, - 0x4f, 0xad, 0x17, 0xef, 0x76, 0x44, 0x32, 0x5, 0x9c, 0xb4}; - uint8_t bytesprops2[] = {0x7b, 0x3d, 0x40, 0x46, 0xe, 0x9f, 0xee, 0xcf, 0x77, 0x91, 0x88, 0xf3, 0x6a, 0xac, 0x4c, - 0xc8, 0xf6, 0xc0, 0x55, 0x2a, 0xd4, 0x83, 0x40, 0xd7, 0x41, 0xef, 0x65, 0x6c, 0x2a, 0xbb}; - uint8_t bytesprops3[] = {0xee, 0xba, 0x79, 0x9f, 0xd6, 0x89, 0x6a, 0x3c, 0x99, 0xc3, - 0xca, 0x5c, 0xa0, 0x57, 0x22, 0xcc, 0x21, 0xd6, 0x43}; - uint8_t bytesprops4[] = {0x22, 0x1d, 0x84, 0x92, 0xf1, 0xb8, 0x9, 0x9d, 0x80}; - uint8_t bytesprops5[] = {0x38, 0xd9, 0x88, 0x16, 0xf1, 0xf}; - uint8_t bytesprops7[] = {0x54, 0x73, 0x77, 0x4b, 0x5c, 0x4c, 0x2f, 0xd9, 0x8a, - 0x41, 0xc3, 0xe6, 0x9e, 0xe3, 0x56, 0x54, 0xd, 0xb2}; - uint8_t bytesprops6[] = {0x3c, 0xfe, 0x2, 0xe3, 0x37, 0xf0, 0x44}; - uint8_t bytesprops8[] = {0xfd, 0x36, 0x77, 0xae, 0xdf, 0xd, 0x8, 0x4f, 0xb2, 0x23, 0x9c, - 0x2f, 0xf3, 0x8c, 0x3a, 0x4e, 0x84, 0x55, 0x9b, 0xf4, 0x5e}; - uint8_t bytesprops9[] = {0x8a, 0x6f, 0x34, 0x4b, 0xc0, 0xe4, 0x3, 0x52, 0xa5, 0xac, 0x54, 0xe3, 0x47, 0x45, 0x33}; - uint8_t bytesprops10[] = {0x9e, 0x75, 0xa7, 0x7b, 0x37, 0xc6, 0x7, 0x43, 0xa0, 0x78, 0x5b, 0xc7, 0x80, - 0x90, 0xd5, 0x8c, 0x2b, 0x73, 0xe2, 0x80, 0xbf, 0x92, 0xdd, 0x4e, 0xf1, 0x59}; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22892, 7, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 19885 +// ["1PI\t\197=\237\156\210+\211\143\197F\237j\226K\DC1\ETB\231\195\ACK\162\148\247_\252\173","\t)\128a\GS\181\NUL\197\183{\205;m\230\199\US|l\166i\215'\180\129\184\186","\246D|d\241G\232+$\163\NAKm","\165","\r\189\ACK\138&\129\225V\220\215X\ESC\DLE<\192\150s\207","U\214xL\223\215.ob5\166\173wr\209\&1\167\&9\rJ\145\DC4\255","\DC3\215c\169\153\250\207@\186\242\r\"\183\129Q\RS\ETBbEj\160","L-\181*\192\&1}"] +// [PropReasonString "\159\193\135\239W\133\141\v\147\&9[<\156",PropContentType +// "\251n\183\239\139gc\DC2\"\GS0",PropSessionExpiryInterval 7449] +TEST(Unsubscribe5QCTest, Encode28) { + uint8_t pkt[] = {0xa2, 0xbf, 0x1, 0x4d, 0xad, 0x23, 0x1f, 0x0, 0xd, 0x9f, 0xc1, 0x87, 0xef, 0x57, 0x85, 0x8d, 0xb, + 0x93, 0x39, 0x5b, 0x3c, 0x9c, 0x3, 0x0, 0xb, 0xfb, 0x6e, 0xb7, 0xef, 0x8b, 0x67, 0x63, 0x12, 0x22, + 0x1d, 0x30, 0x11, 0x0, 0x0, 0x1d, 0x19, 0x0, 0x1d, 0x31, 0x50, 0x49, 0x9, 0xc5, 0x3d, 0xed, 0x9c, + 0xd2, 0x2b, 0xd3, 0x8f, 0xc5, 0x46, 0xed, 0x6a, 0xe2, 0x4b, 0x11, 0x17, 0xe7, 0xc3, 0x6, 0xa2, 0x94, + 0xf7, 0x5f, 0xfc, 0xad, 0x0, 0x1a, 0x9, 0x29, 0x80, 0x61, 0x1d, 0xb5, 0x0, 0xc5, 0xb7, 0x7b, 0xcd, + 0x3b, 0x6d, 0xe6, 0xc7, 0x1f, 0x7c, 0x6c, 0xa6, 0x69, 0xd7, 0x27, 0xb4, 0x81, 0xb8, 0xba, 0x0, 0xc, + 0xf6, 0x44, 0x7c, 0x64, 0xf1, 0x47, 0xe8, 0x2b, 0x24, 0xa3, 0x15, 0x6d, 0x0, 0x1, 0xa5, 0x0, 0x12, + 0xd, 0xbd, 0x6, 0x8a, 0x26, 0x81, 0xe1, 0x56, 0xdc, 0xd7, 0x58, 0x1b, 0x10, 0x3c, 0xc0, 0x96, 0x73, + 0xcf, 0x0, 0x17, 0x55, 0xd6, 0x78, 0x4c, 0xdf, 0xd7, 0x2e, 0x6f, 0x62, 0x35, 0xa6, 0xad, 0x77, 0x72, + 0xd1, 0x31, 0xa7, 0x39, 0xd, 0x4a, 0x91, 0x14, 0xff, 0x0, 0x15, 0x13, 0xd7, 0x63, 0xa9, 0x99, 0xfa, + 0xcf, 0x40, 0xba, 0xf2, 0xd, 0x22, 0xb7, 0x81, 0x51, 0x1e, 0x17, 0x62, 0x45, 0x6a, 0xa0, 0x0, 0x7, + 0x4c, 0x2d, 0xb5, 0x2a, 0xc0, 0x31, 0x7d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x9f, 0xc1, 0x87, 0xef, 0x57, 0x85, 0x8d, 0xb, 0x93, 0x39, 0x5b, 0x3c, 0x9c}; + uint8_t bytesprops1[] = {0xfb, 0x6e, 0xb7, 0xef, 0x8b, 0x67, 0x63, 0x12, 0x22, 0x1d, 0x30}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23925}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32196}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14388}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25165}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5332}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1710}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11435}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops6}, .v = {18, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12725}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29756}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30499}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7449}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xe6, 0xb7, 0x71, 0x96, 0xff, 0x66, 0x1e, 0x85, 0x2c, 0x19, 0x97, 0x73, 0x14}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x31, 0x50, 0x49, 0x9, 0xc5, 0x3d, 0xed, 0x9c, 0xd2, 0x2b, + 0xd3, 0x8f, 0xc5, 0x46, 0xed, 0x6a, 0xe2, 0x4b, 0x11, 0x17, + 0xe7, 0xc3, 0x6, 0xa2, 0x94, 0xf7, 0x5f, 0xfc, 0xad}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa0, 0xef, 0xd6, 0x54, 0x18, 0x53, 0xff, 0x86, - 0xa9, 0xb6, 0xa7, 0x72, 0x69, 0xe9, 0xc9}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9, 0x29, 0x80, 0x61, 0x1d, 0xb5, 0x0, 0xc5, 0xb7, 0x7b, 0xcd, 0x3b, 0x6d, + 0xe6, 0xc7, 0x1f, 0x7c, 0x6c, 0xa6, 0x69, 0xd7, 0x27, 0xb4, 0x81, 0xb8, 0xba}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x42, 0x95, 0x4d, 0x73, 0x37, 0x12, 0xea, 0x78, 0xb9, 0x74, 0xe9, 0xef, 0xf7, - 0x4, 0x96, 0x5c, 0xe1, 0x0, 0x14, 0xe, 0x24, 0x9, 0x50, 0xbe, 0x13}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf6, 0x44, 0x7c, 0x64, 0xf1, 0x47, 0xe8, 0x2b, 0x24, 0xa3, 0x15, 0x6d}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe7, 0x82, 0x35, 0x30, 0x8e, 0x3f, 0xe8, 0xe4, 0x2, 0xb7, 0xb6, 0x9f, 0x68, - 0xd3, 0x8c, 0xda, 0x4e, 0x1b, 0x5, 0x4c, 0xa1, 0x3d, 0x9e, 0xfb, 0xa6}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa5}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xda, 0xe6, 0x32, 0x82, 0xa3, 0x10}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd, 0xbd, 0x6, 0x8a, 0x26, 0x81, 0xe1, 0x56, 0xdc, + 0xd7, 0x58, 0x1b, 0x10, 0x3c, 0xc0, 0x96, 0x73, 0xcf}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x82, 0x71, 0xa2, 0x4, 0x3a, 0xf0, 0x22, 0xce, 0x60, 0x86, 0x7c, 0xa2}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x55, 0xd6, 0x78, 0x4c, 0xdf, 0xd7, 0x2e, 0x6f, 0x62, 0x35, 0xa6, 0xad, + 0x77, 0x72, 0xd1, 0x31, 0xa7, 0x39, 0xd, 0x4a, 0x91, 0x14, 0xff}; + lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6c, 0xb9, 0x4e, 0x84, 0xb1, 0xcb, 0x2a}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x13, 0xd7, 0x63, 0xa9, 0x99, 0xfa, 0xcf, 0x40, 0xba, 0xf2, 0xd, + 0x22, 0xb7, 0x81, 0x51, 0x1e, 0x17, 0x62, 0x45, 0x6a, 0xa0}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x53, 0x42, 0x11, 0x5c, 0xba, 0xbf, 0xa7, 0x69, 0x71, - 0xbb, 0xcc, 0x7, 0x15, 0x89, 0xd6, 0x75, 0x9b, 0xa}; - lwmqtt_string_t topic_filter_s7 = {18, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x4c, 0x2d, 0xb5, 0x2a, 0xc0, 0x31, 0x7d}; + lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6585, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19885, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22838 -// ["@w%\186\210\164\154\ACKl\193]J?uN\fM\186","\206\247\DEL\254\199\EM\205\216\151KC\ETX\219\180etQ\135\188\195\197_\249\b","m\CAN\222\175|\164\198\ETBF","\186\147\228\156\151$\239K@\USJ\248\193`z\220\222\224M[\182","\154\n$qM4\nL\ETXb\ETX\241","K\154?\178\227p\162\200R\194\196","+\245t\230#}Ja\SOH\214x\220)\ESC\138\t\134\215J\222\131$dD\222","\169\191\191\193[\224tV&\218rG\196\SYNQ\224n\157\&7\215\165\207\153+\a\234\235","(\185\142\190\225\&7\FSf\147Obz\203\136||\198\&5\DC1\239\161\202","_>\198mEZ\153\&1\149\250r\146zt\ESC\239g\176\148\197\210\NUL\231-\212\138"] -// [PropRetainAvailable 107,PropContentType "\248\135;\215w4\172\183\223\SOH\DEL\172\157\151!Z",PropReasonString -// "\173\227\&7\237\199)V \155\175\DEL\NUL\USd\ACK\161\138\150\207\255Vg\135mwS{j",PropAssignedClientIdentifier -// "?\209\182\SO"] -TEST(Unsubscribe5QCTest, Encode24) { - uint8_t pkt[] = { - 0xa2, 0x95, 0x2, 0x59, 0x36, 0x3b, 0x25, 0x6b, 0x3, 0x0, 0x10, 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, 0x64, 0x44, 0xde, 0x0, 0x1b, 0xa9, 0xbf, 0xbf, 0xc1, 0x5b, 0xe0, 0x74, 0x56, - 0x26, 0xda, 0x72, 0x47, 0xc4, 0x16, 0x51, 0xe0, 0x6e, 0x9d, 0x37, 0xd7, 0xa5, 0xcf, 0x99, 0x2b, 0x7, 0xea, 0xeb, - 0x0, 0x16, 0x28, 0xb9, 0x8e, 0xbe, 0xe1, 0x37, 0x1c, 0x66, 0x93, 0x4f, 0x62, 0x7a, 0xcb, 0x88, 0x7c, 0x7c, 0xc6, - 0x35, 0x11, 0xef, 0xa1, 0xca, 0x0, 0x1a, 0x5f, 0x3e, 0xc6, 0x6d, 0x45, 0x5a, 0x99, 0x31, 0x95, 0xfa, 0x72, 0x92, - 0x7a, 0x74, 0x1b, 0xef, 0x67, 0xb0, 0x94, 0xc5, 0xd2, 0x0, 0xe7, 0x2d, 0xd4, 0x8a}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf8, 0x87, 0x3b, 0xd7, 0x77, 0x34, 0xac, 0xb7, - 0xdf, 0x1, 0x7f, 0xac, 0x9d, 0x97, 0x21, 0x5a}; - uint8_t bytesprops1[] = {0xad, 0xe3, 0x37, 0xed, 0xc7, 0x29, 0x56, 0x20, 0x9b, 0xaf, 0x7f, 0x0, 0x1f, 0x64, - 0x6, 0xa1, 0x8a, 0x96, 0xcf, 0xff, 0x56, 0x67, 0x87, 0x6d, 0x77, 0x53, 0x7b, 0x6a}; - uint8_t bytesprops2[] = {0x3f, 0xd1, 0xb6, 0xe}; +// UnsubscribeRequest 27189 +// ["\150\235'\154\141\134|\222\223]bA\223\139E\175+\178\158\176FT\218\DC4","\128\213\212b\169;\241\208\"!\167","\162\SO\SYN\164P(\US\SIR{\147\253k\235G\169;ZQ\NULH\DC3\DELP\SOH\222","F\229\157\217\ACK\155\rz\245\&8/\173G5\177\244S-8\150\198\194\&3\222)\209\STX","\191\143\241\237\222\157\191\187\142M}\207LC|\146","8\ENQ\229\241|Z^","*g\f\244dM\235\193*\177\&9\149\133\161","\168/\EOT\222\a^z\187\139\135","\167\206\130\&1\168\ETBH\200\241\221C\235\134Z9J\193\215v\237\131\197"] +// [PropRequestProblemInformation 244,PropSubscriptionIdentifierAvailable 57,PropMessageExpiryInterval +// 25256,PropRetainAvailable 180,PropCorrelationData "\214\166\DC1\175\199/`",PropResponseInformation +// "\244D{\US\150\SYNk=\184\140A\225|0\138"] +TEST(Unsubscribe5QCTest, Encode29) { + uint8_t pkt[] = {0xa2, 0xd9, 0x1, 0x6a, 0x35, 0x27, 0x17, 0xf4, 0x29, 0x39, 0x2, 0x0, 0x0, 0x62, 0xa8, 0x25, 0xb4, + 0x9, 0x0, 0x7, 0xd6, 0xa6, 0x11, 0xaf, 0xc7, 0x2f, 0x60, 0x1a, 0x0, 0xf, 0xf4, 0x44, 0x7b, 0x1f, + 0x96, 0x16, 0x6b, 0x3d, 0xb8, 0x8c, 0x41, 0xe1, 0x7c, 0x30, 0x8a, 0x0, 0x18, 0x96, 0xeb, 0x27, 0x9a, + 0x8d, 0x86, 0x7c, 0xde, 0xdf, 0x5d, 0x62, 0x41, 0xdf, 0x8b, 0x45, 0xaf, 0x2b, 0xb2, 0x9e, 0xb0, 0x46, + 0x54, 0xda, 0x14, 0x0, 0xb, 0x80, 0xd5, 0xd4, 0x62, 0xa9, 0x3b, 0xf1, 0xd0, 0x22, 0x21, 0xa7, 0x0, + 0x1a, 0xa2, 0xe, 0x16, 0xa4, 0x50, 0x28, 0x1f, 0xf, 0x52, 0x7b, 0x93, 0xfd, 0x6b, 0xeb, 0x47, 0xa9, + 0x3b, 0x5a, 0x51, 0x0, 0x48, 0x13, 0x7f, 0x50, 0x1, 0xde, 0x0, 0x1b, 0x46, 0xe5, 0x9d, 0xd9, 0x6, + 0x9b, 0xd, 0x7a, 0xf5, 0x38, 0x2f, 0xad, 0x47, 0x35, 0xb1, 0xf4, 0x53, 0x2d, 0x38, 0x96, 0xc6, 0xc2, + 0x33, 0xde, 0x29, 0xd1, 0x2, 0x0, 0x10, 0xbf, 0x8f, 0xf1, 0xed, 0xde, 0x9d, 0xbf, 0xbb, 0x8e, 0x4d, + 0x7d, 0xcf, 0x4c, 0x43, 0x7c, 0x92, 0x0, 0x7, 0x38, 0x5, 0xe5, 0xf1, 0x7c, 0x5a, 0x5e, 0x0, 0xe, + 0x2a, 0x67, 0xc, 0xf4, 0x64, 0x4d, 0xeb, 0xc1, 0x2a, 0xb1, 0x39, 0x95, 0x85, 0xa1, 0x0, 0xa, 0xa8, + 0x2f, 0x4, 0xde, 0x7, 0x5e, 0x7a, 0xbb, 0x8b, 0x87, 0x0, 0x16, 0xa7, 0xce, 0x82, 0x31, 0xa8, 0x17, + 0x48, 0xc8, 0xf1, 0xdd, 0x43, 0xeb, 0x86, 0x5a, 0x39, 0x4a, 0xc1, 0xd7, 0x76, 0xed, 0x83, 0xc5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xd6, 0xa6, 0x11, 0xaf, 0xc7, 0x2f, 0x60}; + uint8_t bytesprops1[] = {0xf4, 0x44, 0x7b, 0x1f, 0x96, 0x16, 0x6b, 0x3d, 0xb8, 0x8c, 0x41, 0xe1, 0x7c, 0x30, 0x8a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25256}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x40, 0x77, 0x25, 0xba, 0xd2, 0xa4, 0x9a, 0x6, 0x6c, - 0xc1, 0x5d, 0x4a, 0x3f, 0x75, 0x4e, 0xc, 0x4d, 0xba}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x96, 0xeb, 0x27, 0x9a, 0x8d, 0x86, 0x7c, 0xde, 0xdf, 0x5d, 0x62, 0x41, + 0xdf, 0x8b, 0x45, 0xaf, 0x2b, 0xb2, 0x9e, 0xb0, 0x46, 0x54, 0xda, 0x14}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xce, 0xf7, 0x7f, 0xfe, 0xc7, 0x19, 0xcd, 0xd8, 0x97, 0x4b, 0x43, 0x3, - 0xdb, 0xb4, 0x65, 0x74, 0x51, 0x87, 0xbc, 0xc3, 0xc5, 0x5f, 0xf9, 0x8}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x80, 0xd5, 0xd4, 0x62, 0xa9, 0x3b, 0xf1, 0xd0, 0x22, 0x21, 0xa7}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6d, 0x18, 0xde, 0xaf, 0x7c, 0xa4, 0xc6, 0x17, 0x46}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa2, 0xe, 0x16, 0xa4, 0x50, 0x28, 0x1f, 0xf, 0x52, 0x7b, 0x93, 0xfd, 0x6b, + 0xeb, 0x47, 0xa9, 0x3b, 0x5a, 0x51, 0x0, 0x48, 0x13, 0x7f, 0x50, 0x1, 0xde}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xba, 0x93, 0xe4, 0x9c, 0x97, 0x24, 0xef, 0x4b, 0x40, 0x1f, 0x4a, - 0xf8, 0xc1, 0x60, 0x7a, 0xdc, 0xde, 0xe0, 0x4d, 0x5b, 0xb6}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x46, 0xe5, 0x9d, 0xd9, 0x6, 0x9b, 0xd, 0x7a, 0xf5, 0x38, 0x2f, 0xad, 0x47, 0x35, + 0xb1, 0xf4, 0x53, 0x2d, 0x38, 0x96, 0xc6, 0xc2, 0x33, 0xde, 0x29, 0xd1, 0x2}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9a, 0xa, 0x24, 0x71, 0x4d, 0x34, 0xa, 0x4c, 0x3, 0x62, 0x3, 0xf1}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xbf, 0x8f, 0xf1, 0xed, 0xde, 0x9d, 0xbf, 0xbb, + 0x8e, 0x4d, 0x7d, 0xcf, 0x4c, 0x43, 0x7c, 0x92}; + lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4b, 0x9a, 0x3f, 0xb2, 0xe3, 0x70, 0xa2, 0xc8, 0x52, 0xc2, 0xc4}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x38, 0x5, 0xe5, 0xf1, 0x7c, 0x5a, 0x5e}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x2b, 0xf5, 0x74, 0xe6, 0x23, 0x7d, 0x4a, 0x61, 0x1, 0xd6, 0x78, 0xdc, 0x29, - 0x1b, 0x8a, 0x9, 0x86, 0xd7, 0x4a, 0xde, 0x83, 0x24, 0x64, 0x44, 0xde}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x2a, 0x67, 0xc, 0xf4, 0x64, 0x4d, 0xeb, 0xc1, 0x2a, 0xb1, 0x39, 0x95, 0x85, 0xa1}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa9, 0xbf, 0xbf, 0xc1, 0x5b, 0xe0, 0x74, 0x56, 0x26, 0xda, 0x72, 0x47, 0xc4, 0x16, - 0x51, 0xe0, 0x6e, 0x9d, 0x37, 0xd7, 0xa5, 0xcf, 0x99, 0x2b, 0x7, 0xea, 0xeb}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xa8, 0x2f, 0x4, 0xde, 0x7, 0x5e, 0x7a, 0xbb, 0x8b, 0x87}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x28, 0xb9, 0x8e, 0xbe, 0xe1, 0x37, 0x1c, 0x66, 0x93, 0x4f, 0x62, - 0x7a, 0xcb, 0x88, 0x7c, 0x7c, 0xc6, 0x35, 0x11, 0xef, 0xa1, 0xca}; + uint8_t topic_filter_s8_bytes[] = {0xa7, 0xce, 0x82, 0x31, 0xa8, 0x17, 0x48, 0xc8, 0xf1, 0xdd, 0x43, + 0xeb, 0x86, 0x5a, 0x39, 0x4a, 0xc1, 0xd7, 0x76, 0xed, 0x83, 0xc5}; lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x5f, 0x3e, 0xc6, 0x6d, 0x45, 0x5a, 0x99, 0x31, 0x95, 0xfa, 0x72, 0x92, 0x7a, - 0x74, 0x1b, 0xef, 0x67, 0xb0, 0x94, 0xc5, 0xd2, 0x0, 0xe7, 0x2d, 0xd4, 0x8a}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22838, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27189, 9, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 14034 ["1\217\143\SOH~W~\ETX -// \191\NUL\173|\218L\CAN\229\ESC\249\241\169\130","T\140qo","\128k\172\167\180\235\144\222\r\129\254?,\152\187+\228\178F\194\225","\244\CAN\230/\246X\247\&1,\208\222\235(\219%\246\172\225\254\191\189|\218'\253","\ENQ\133\178\EOT\241\135\222\201\220\164\&3\179\157\222T\189\253","\ETB\DC4\159\210\ETB0\218\213;\180\EM\227\244Lr\245\EOTn\NULh","\173.N\n~\219o\214\205\167\190\139\196\185\246\174\&3\STX\215\235\135a","\172g\bAu\187r\au-\DC4!!Vw -// |x","\211\&6\175\180c\153\187s\NUL\v\140Em\215\144\244\&3|\246\ESC&\239tD\243\239","]\US\226A\165\\|\206U6\249d\144\241On-\153"] -// [PropMessageExpiryInterval 5120,PropTopicAliasMaximum 18895,PropSharedSubscriptionAvailable 79,PropServerKeepAlive -// 26825,PropRequestResponseInformation 31,PropMaximumQoS 209,PropMaximumQoS 168,PropAuthenticationData -// "R\143\140\ETB\229\&0\193\246~Z\131\166C)\151\226\&7",PropMessageExpiryInterval 11526,PropResponseInformation -// "\169\CAN\170\DEL\206\197",PropRequestProblemInformation 239,PropResponseInformation -// "\188\221\162\177\CAN\246\r\252\&2\198\211o\CAN\FS\ESC\136\&5\"\240`E\ETB",PropSubscriptionIdentifier -// 23,PropMaximumQoS 102,PropRequestResponseInformation 187,PropMessageExpiryInterval -// 20661,PropRequestProblemInformation 73,PropMaximumQoS 39] -TEST(Unsubscribe5QCTest, Encode25) { +// UnsubscribeRequest 10641 +// ["\195Sa\217\ACK\194\232\166\EOT\a\175\198\164\196r\252M\237\ETX\150\202\228\225\236\SUB\130}\144\142\196:\EOT","7$&\216\162\FSEn\RSsy\244]","\200\209D","\154,\164<","\211c\153","\DLE\221\175\212*","Pk)\217\129'\201\236\161\181o\176D\191L\241\158\153\EOT\228","#\231\205E\220\217&S\242","\211\145\204"] -// [PropMaximumPacketSize 25355,PropRetainAvailable 125,PropRetainAvailable 176,PropWillDelayInterval -// 6837,PropResponseInformation "\137\128\237q5K\SOE}{",PropCorrelationData -// "\224b#\254\157\&5`\ENQ]\128\GS\227@p\239",PropResponseInformation "\188",PropReasonString -// "\131o\165>A\196\165\n\139D \142\ACKjg",PropCorrelationData -// "P\STX{\US\ACKe\167\187/;\ah\134\160'\253\204",PropAuthenticationMethod -// "\224W\DLE$\223\242\a\FSU\245&\254\&1\251\SYN\t\218\222\&0XF\221;",PropSessionExpiryInterval -// 9119,PropSessionExpiryInterval 16118,PropServerKeepAlive 16036,PropMessageExpiryInterval -// 31819,PropAuthenticationMethod -// "\US\137DB7;\140\213\235\NUL&\NUL\162{\170\254C\192\207S\178;t\ENQ",PropMessageExpiryInterval -// 30475,PropServerReference -// "EK\\)\178\NUL\138\&4U\189]<>\163\232\147\244\204\&5;\n\241\169\193\SYN\211\245\DC2\211\180"] -TEST(Unsubscribe5QCTest, Encode30) { - uint8_t pkt[] = { - 0xa2, 0xad, 0x2, 0x6b, 0x12, 0xc4, 0x1, 0x27, 0x0, 0x0, 0x63, 0xb, 0x25, 0x7d, 0x25, 0xb0, 0x18, 0x0, 0x0, - 0x1a, 0xb5, 0x1a, 0x0, 0xa, 0x89, 0x80, 0xed, 0x71, 0x35, 0x4b, 0xe, 0x45, 0x7d, 0x7b, 0x9, 0x0, 0xf, 0xe0, - 0x62, 0x23, 0xfe, 0x9d, 0x35, 0x60, 0x5, 0x5d, 0x80, 0x1d, 0xe3, 0x40, 0x70, 0xef, 0x1a, 0x0, 0x1, 0xbc, 0x1f, - 0x0, 0xf, 0x83, 0x6f, 0xa5, 0x3e, 0x41, 0xc4, 0xa5, 0xa, 0x8b, 0x44, 0x20, 0x8e, 0x6, 0x6a, 0x67, 0x9, 0x0, - 0x11, 0x50, 0x2, 0x7b, 0x1f, 0x6, 0x65, 0xa7, 0xbb, 0x2f, 0x3b, 0x7, 0x68, 0x86, 0xa0, 0x27, 0xfd, 0xcc, 0x15, - 0x0, 0x17, 0xe0, 0x57, 0x10, 0x24, 0xdf, 0xf2, 0x7, 0x1c, 0x55, 0xf5, 0x26, 0xfe, 0x31, 0xfb, 0x16, 0x9, 0xda, - 0xde, 0x30, 0x58, 0x46, 0xdd, 0x3b, 0x11, 0x0, 0x0, 0x23, 0x9f, 0x11, 0x0, 0x0, 0x3e, 0xf6, 0x13, 0x3e, 0xa4, - 0x2, 0x0, 0x0, 0x7c, 0x4b, 0x15, 0x0, 0x18, 0x1f, 0x89, 0x44, 0x42, 0x37, 0x3b, 0x8c, 0xd5, 0xeb, 0x0, 0x26, - 0x0, 0xa2, 0x7b, 0xaa, 0xfe, 0x43, 0xc0, 0xcf, 0x53, 0xb2, 0x3b, 0x74, 0x5, 0x2, 0x0, 0x0, 0x77, 0xb, 0x1c, - 0x0, 0x1e, 0x45, 0x4b, 0x5c, 0x29, 0xb2, 0x0, 0x8a, 0x34, 0x55, 0xbd, 0x5d, 0x3c, 0x3e, 0xa3, 0xe8, 0x93, 0xf4, - 0xcc, 0x35, 0x3b, 0xa, 0xf1, 0xa9, 0xc1, 0x16, 0xd3, 0xf5, 0x12, 0xd3, 0xb4, 0x0, 0x17, 0x8e, 0x2c, 0xfd, 0xfb, - 0xe4, 0xa4, 0x36, 0x3e, 0xed, 0x3, 0x96, 0xca, 0xe4, 0xe1, 0xec, 0x1a, 0x82, 0x7d, 0x90, 0x8e, 0xc4, 0x3a, 0x4, - 0x0, 0xd, 0x37, 0x24, 0x26, 0xd8, 0xa2, 0x1c, 0x45, 0x6e, 0x1e, 0x73, 0x79, 0xf4, 0x5d, 0x0, 0x3, 0xc8, 0xd1, - 0x44, 0x0, 0x4, 0x9a, 0x2c, 0xa4, 0x3c, 0x0, 0x3, 0xd3, 0x63, 0x99, 0x0, 0x5, 0x10, 0xdd, 0xaf, 0xd4, 0x2a, - 0x0, 0x14, 0x50, 0x6b, 0x29, 0xd9, 0x81, 0x27, 0xc9, 0xec, 0xa1, 0xb5, 0x6f, 0xb0, 0x44, 0xbf, 0x4c, 0xf1, 0x9e, - 0x99, 0x4, 0xe4, 0x0, 0x9, 0x23, 0xe7, 0xcd, 0x45, 0xdc, 0xd9, 0x26, 0x53, 0xf2, 0x0, 0x3, 0xd3, 0x91, 0xcc}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x89, 0x80, 0xed, 0x71, 0x35, 0x4b, 0xe, 0x45, 0x7d, 0x7b}; - uint8_t bytesprops1[] = {0xe0, 0x62, 0x23, 0xfe, 0x9d, 0x35, 0x60, 0x5, 0x5d, 0x80, 0x1d, 0xe3, 0x40, 0x70, 0xef}; - uint8_t bytesprops2[] = {0xbc}; - uint8_t bytesprops3[] = {0x83, 0x6f, 0xa5, 0x3e, 0x41, 0xc4, 0xa5, 0xa, 0x8b, 0x44, 0x20, 0x8e, 0x6, 0x6a, 0x67}; - uint8_t bytesprops4[] = {0x50, 0x2, 0x7b, 0x1f, 0x6, 0x65, 0xa7, 0xbb, 0x2f, - 0x3b, 0x7, 0x68, 0x86, 0xa0, 0x27, 0xfd, 0xcc}; - uint8_t bytesprops5[] = {0xe0, 0x57, 0x10, 0x24, 0xdf, 0xf2, 0x7, 0x1c, 0x55, 0xf5, 0x26, 0xfe, - 0x31, 0xfb, 0x16, 0x9, 0xda, 0xde, 0x30, 0x58, 0x46, 0xdd, 0x3b}; - uint8_t bytesprops6[] = {0x1f, 0x89, 0x44, 0x42, 0x37, 0x3b, 0x8c, 0xd5, 0xeb, 0x0, 0x26, 0x0, - 0xa2, 0x7b, 0xaa, 0xfe, 0x43, 0xc0, 0xcf, 0x53, 0xb2, 0x3b, 0x74, 0x5}; - uint8_t bytesprops7[] = {0x45, 0x4b, 0x5c, 0x29, 0xb2, 0x0, 0x8a, 0x34, 0x55, 0xbd, 0x5d, 0x3c, 0x3e, 0xa3, 0xe8, - 0x93, 0xf4, 0xcc, 0x35, 0x3b, 0xa, 0xf1, 0xa9, 0xc1, 0x16, 0xd3, 0xf5, 0x12, 0xd3, 0xb4}; +// UnsubscribeResponse 25609 [] [] +TEST(UnsubACK311QCTest, Decode28) { + uint8_t pkt[] = {0xb0, 0x2, 0x64, 0x9}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[0]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 0, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 25609); + EXPECT_EQ(count, 0); +} - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25355}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6837}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9119}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16118}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16036}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31819}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30475}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops7}}}, - }; +// UnsubscribeResponse 8043 [] [] +TEST(UnsubACK311QCTest, Decode29) { + uint8_t pkt[] = {0xb0, 0x2, 0x1f, 0x6b}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[0]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 0, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8043); + EXPECT_EQ(count, 0); +} - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x8e, 0x2c, 0xfd, 0xfb, 0xe4, 0xa4, 0x36, 0x3e, 0xed, 0x3, 0x96, 0xca, - 0xe4, 0xe1, 0xec, 0x1a, 0x82, 0x7d, 0x90, 0x8e, 0xc4, 0x3a, 0x4}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x37, 0x24, 0x26, 0xd8, 0xa2, 0x1c, 0x45, 0x6e, 0x1e, 0x73, 0x79, 0xf4, 0x5d}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc8, 0xd1, 0x44}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9a, 0x2c, 0xa4, 0x3c}; - lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd3, 0x63, 0x99}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x10, 0xdd, 0xaf, 0xd4, 0x2a}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x50, 0x6b, 0x29, 0xd9, 0x81, 0x27, 0xc9, 0xec, 0xa1, 0xb5, - 0x6f, 0xb0, 0x44, 0xbf, 0x4c, 0xf1, 0x9e, 0x99, 0x4, 0xe4}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x23, 0xe7, 0xcd, 0x45, 0xdc, 0xd9, 0x26, 0x53, 0xf2}; - lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd3, 0x91, 0xcc}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27410, 9, topic_filters, props); +// UnsubscribeResponse 7204 [] [] +TEST(UnsubACK311QCTest, Decode30) { + uint8_t pkt[] = {0xb0, 0x2, 0x1c, 0x24}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[0]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 0, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7204); + EXPECT_EQ(count, 0); +} + +// UnsubscribeResponse 24860 [PropMessageExpiryInterval 25678,PropServerReference +// "/\253#\195\214\135\207",PropPayloadFormatIndicator 165,PropReceiveMaximum 10195,PropServerReference +// "\175I",PropCorrelationData +// "\235%b\133\177\167{W,\162]<\133\&2T`1\170\va\SO\226NNw\243\133Vh\156",PropRequestResponseInformation +// 153,PropContentType "\ENQ\RS7\SYNc\161\v\NUL\169\248\150J\201\197=\ENQ\190",PropMessageExpiryInterval +// 11970,PropAuthenticationData "",PropServerKeepAlive 4559,PropSubscriptionIdentifier 4,PropServerReference +// "C\176\CAN4\216[\136\187\223\198\184\205\a\SUB",PropReasonString +// "g\206\&5\128\227(\134\161\171\t\131f",PropSharedSubscriptionAvailable 29,PropReceiveMaximum 16106,PropResponseTopic +// "\158\152\GS:\STX1S\RS\EOT",PropTopicAliasMaximum 24112,PropAuthenticationMethod "\ETX\EM\187-\178\228U"] +// [UnsubNotAuthorized,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubNotAuthorized] +TEST(UnsubACK5QCTest, Decode1) { + uint8_t pkt[] = {0xb0, 0xb6, 0x1, 0x61, 0x1c, 0x9b, 0x1, 0x2, 0x0, 0x0, 0x64, 0x4e, 0x1c, 0x0, 0x7, 0x2f, 0xfd, + 0x23, 0xc3, 0xd6, 0x87, 0xcf, 0x1, 0xa5, 0x21, 0x27, 0xd3, 0x1c, 0x0, 0x2, 0xaf, 0x49, 0x9, 0x0, + 0x1e, 0xeb, 0x25, 0x62, 0x85, 0xb1, 0xa7, 0x7b, 0x57, 0x2c, 0xa2, 0x5d, 0x3c, 0x85, 0x32, 0x54, 0x60, + 0x31, 0xaa, 0xb, 0x61, 0xe, 0xe2, 0x4e, 0x4e, 0x77, 0xf3, 0x85, 0x56, 0x68, 0x9c, 0x19, 0x99, 0x3, + 0x0, 0x11, 0x5, 0x1e, 0x37, 0x16, 0x63, 0xa1, 0xb, 0x0, 0xa9, 0xf8, 0x96, 0x4a, 0xc9, 0xc5, 0x3d, + 0x5, 0xbe, 0x2, 0x0, 0x0, 0x2e, 0xc2, 0x16, 0x0, 0x0, 0x13, 0x11, 0xcf, 0xb, 0x4, 0x1c, 0x0, + 0xe, 0x43, 0xb0, 0x18, 0x34, 0xd8, 0x5b, 0x88, 0xbb, 0xdf, 0xc6, 0xb8, 0xcd, 0x7, 0x1a, 0x1f, 0x0, + 0xc, 0x67, 0xce, 0x35, 0x80, 0xe3, 0x28, 0x86, 0xa1, 0xab, 0x9, 0x83, 0x66, 0x2a, 0x1d, 0x21, 0x3e, + 0xea, 0x8, 0x0, 0x9, 0x9e, 0x98, 0x1d, 0x3a, 0x2, 0x31, 0x53, 0x1e, 0x4, 0x22, 0x5e, 0x30, 0x15, + 0x0, 0x7, 0x3, 0x19, 0xbb, 0x2d, 0xb2, 0xe4, 0x55, 0x87, 0x0, 0x91, 0x11, 0x87, 0x83, 0x80, 0x8f, + 0x11, 0x91, 0x83, 0x8f, 0x8f, 0x91, 0x80, 0x83, 0x80, 0x11, 0x91, 0x11, 0x91, 0x83, 0x87}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[23]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 23, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 24860); + EXPECT_EQ(count, 23); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NOT_AUTHORIZED); +} + +// UnsubscribeResponse 3894 [PropReasonString +// "A\238\220^\134u\207\244\233]\158\b+B\208\154\218\&9\206\US\200\193",PropRetainAvailable 121] +// [UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubNotAuthorized] +TEST(UnsubACK5QCTest, Decode2) { + uint8_t pkt[] = {0xb0, 0x21, 0xf, 0x36, 0x1b, 0x1f, 0x0, 0x16, 0x41, 0xee, 0xdc, 0x5e, + 0x86, 0x75, 0xcf, 0xf4, 0xe9, 0x5d, 0x9e, 0x8, 0x2b, 0x42, 0xd0, 0x9a, + 0xda, 0x39, 0xce, 0x1f, 0xc8, 0xc1, 0x25, 0x79, 0x87, 0x11, 0x87}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[3]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(packet_id, 3894); + EXPECT_EQ(count, 3); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); +} + +// UnsubscribeResponse 2326 [PropServerKeepAlive 24388,PropContentType +// "\152Q\214'{\169Cl\189_\164\USU\164(\202p\160\159\159\200d\NUL\DLEk\228\188",PropSubscriptionIdentifierAvailable +// 7,PropRequestProblemInformation 224,PropSubscriptionIdentifierAvailable 225,PropResponseInformation +// "@Y\255!\245\212G\157l|",PropReceiveMaximum 7833,PropPayloadFormatIndicator 27,PropResponseInformation +// "\200\ESC\GS\203xTA>hC\EOT\222\231\RSw\206L\183\217",PropSessionExpiryInterval 20207,PropMessageExpiryInterval +// 10350,PropRequestProblemInformation 187,PropSubscriptionIdentifier 12] +// [UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNoSubscriptionExisted] +TEST(UnsubACK5QCTest, Decode3) { + uint8_t pkt[] = {0xb0, 0x65, 0x9, 0x16, 0x5d, 0x13, 0x5f, 0x44, 0x3, 0x0, 0x1b, 0x98, 0x51, 0xd6, 0x27, + 0x7b, 0xa9, 0x43, 0x6c, 0xbd, 0x5f, 0xa4, 0x1f, 0x55, 0xa4, 0x28, 0xca, 0x70, 0xa0, 0x9f, + 0x9f, 0xc8, 0x64, 0x0, 0x10, 0x6b, 0xe4, 0xbc, 0x29, 0x7, 0x17, 0xe0, 0x29, 0xe1, 0x1a, + 0x0, 0xa, 0x40, 0x59, 0xff, 0x21, 0xf5, 0xd4, 0x47, 0x9d, 0x6c, 0x7c, 0x21, 0x1e, 0x99, + 0x1, 0x1b, 0x1a, 0x0, 0x13, 0xc8, 0x1b, 0x1d, 0xcb, 0x78, 0x54, 0x41, 0x3e, 0x68, 0x43, + 0x4, 0xde, 0xe7, 0x1e, 0x77, 0xce, 0x4c, 0xb7, 0xd9, 0x11, 0x0, 0x0, 0x4e, 0xef, 0x2, + 0x0, 0x0, 0x28, 0x6e, 0x17, 0xbb, 0xb, 0xc, 0x8f, 0x80, 0x91, 0x80, 0x11}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[5]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 2326); + EXPECT_EQ(count, 5); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); +} + +// UnsubscribeResponse 10530 [PropAuthenticationData +// "\209\210\SI\198\NUL]x~Jd\216l\174\DC2\160\168\199\145\n\SOHn\206\v",PropSubscriptionIdentifier +// 32,PropMessageExpiryInterval 17080,PropAuthenticationData "c\200",PropTopicAliasMaximum 14580,PropCorrelationData +// "\SYN\188\240\206\178>\241\"\CAN\EOT\230\185\238\199\191\&3\135\129\166\DC1\250\&6\246=\140:",PropServerReference +// "\149\179g\166\253X\EM\167\147\200\DC1\199\SUB}",PropReasonString +// "%\161(R\183&\SOH\220\135\&6N\SYN\DC4\149\132\247:B\SYN;\188\a",PropPayloadFormatIndicator +// 27,PropPayloadFormatIndicator 128,PropServerReference +// "\219\190\207\b\STXH\225}n\226\194`\172\&9\226\231Z\146\208\241!\DC2\240\164\ETBM \216",PropMaximumQoS +// 250,PropServerKeepAlive 27834,PropSessionExpiryInterval 18960,PropRetainAvailable 149,PropTopicAliasMaximum +// 25123,PropAuthenticationMethod +// "B\DC4\195\134\160\NAK\197\ETX\n\205\203\&8so\199\130\223=^h\234\139p4N",PropTopicAlias +// 24560,PropSubscriptionIdentifierAvailable 73,PropSharedSubscriptionAvailable 225] +// [UnsubSuccess,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode4) { + uint8_t pkt[] = { + 0xb0, 0xfd, 0x1, 0x29, 0x22, 0xeb, 0x1, 0x16, 0x0, 0x17, 0xd1, 0xd2, 0xf, 0xc6, 0x0, 0x5d, 0x78, 0x7e, 0x4a, + 0x64, 0xd8, 0x6c, 0xae, 0x12, 0xa0, 0xa8, 0xc7, 0x91, 0xa, 0x1, 0x6e, 0xce, 0xb, 0xb, 0x20, 0x2, 0x0, 0x0, + 0x42, 0xb8, 0x16, 0x0, 0x2, 0x63, 0xc8, 0x22, 0x38, 0xf4, 0x9, 0x0, 0x1a, 0x16, 0xbc, 0xf0, 0xce, 0xb2, 0x3e, + 0xf1, 0x22, 0x18, 0x4, 0xe6, 0xb9, 0xee, 0xc7, 0xbf, 0x33, 0x87, 0x81, 0xa6, 0x11, 0xfa, 0x36, 0xf6, 0x3d, 0x8c, + 0x3a, 0x1c, 0x0, 0xe, 0x95, 0xb3, 0x67, 0xa6, 0xfd, 0x58, 0x19, 0xa7, 0x93, 0xc8, 0x11, 0xc7, 0x1a, 0x7d, 0x1f, + 0x0, 0x1d, 0x25, 0xa1, 0x28, 0x52, 0xb7, 0x26, 0x1, 0xdc, 0x87, 0x36, 0x4e, 0x16, 0x3c, 0x72, 0x3f, 0x1e, 0xdb, + 0x1, 0xfd, 0x2a, 0x21, 0xd1, 0xe7, 0xe, 0x97, 0xd2, 0x9, 0xb8, 0xe9, 0x23, 0x1b, 0x33, 0x1c, 0x0, 0x19, 0x7b, + 0x72, 0x59, 0xcd, 0x35, 0x68, 0xc3, 0x9e, 0xbf, 0xbf, 0x4a, 0xa8, 0xca, 0x3, 0x3e, 0x14, 0x95, 0x84, 0xf7, 0x3a, + 0x42, 0x16, 0x3b, 0xbc, 0x7, 0x1, 0x1b, 0x1, 0x80, 0x1c, 0x0, 0x1c, 0xdb, 0xbe, 0xcf, 0x8, 0x2, 0x48, 0xe1, + 0x7d, 0x6e, 0xe2, 0xc2, 0x60, 0xac, 0x39, 0xe2, 0xe7, 0x5a, 0x92, 0xd0, 0xf1, 0x21, 0x12, 0xf0, 0xa4, 0x17, 0x4d, + 0x20, 0xd8, 0x24, 0xfa, 0x13, 0x6c, 0xba, 0x11, 0x0, 0x0, 0x4a, 0x10, 0x25, 0x95, 0x22, 0x62, 0x23, 0x15, 0x0, + 0x19, 0x42, 0x14, 0xc3, 0x86, 0xa0, 0x15, 0xc5, 0x3, 0xa, 0xcd, 0xcb, 0x38, 0x73, 0x6f, 0xc7, 0x82, 0xdf, 0x3d, + 0x5e, 0x68, 0xea, 0x8b, 0x70, 0x34, 0x4e, 0x23, 0x5f, 0xf0, 0x29, 0x49, 0x2a, 0xe1, 0x0, 0x8f, 0x8f, 0x83, 0x11, + 0x80, 0x87, 0x83, 0x11, 0x8f, 0x0, 0x91, 0x83, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[14]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 14, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 10530); + EXPECT_EQ(count, 14); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); +} + +// UnsubscribeResponse 29099 [PropUserProperty +// "5\209\150\165M\250\224\199\213Ze\168\DC4\r\205\193P#\GS\232\179dd\228\187=!\245" +// "\192\240\203\188%\240\133\a\130=\FS2\SOH\248\ACK\152",PropServerReference +// "\177\NAK\163\EOT\134d7\204\192=\237A\232p\214\153\227g\211\176x%'",PropMaximumPacketSize +// 25124,PropAssignedClientIdentifier +// "\246\150\248\ETX\SUB\139\220\151\235\217\246\US\205\&3\219\241\238\DLE\151\EM\ETX\158D\197P\186\244",PropMessageExpiryInterval +// 6475,PropServerKeepAlive 7420,PropCorrelationData "+\255\134G\153{\217Sx\145\241\CAN&%",PropMessageExpiryInterval +// 10192,PropCorrelationData +// "\155\219\130gz\157\&1\181`[\138\156\191\220}\SO;i\139\150\157\153\&0D\SOH\ESC<\166",PropCorrelationData +// "\131\172\171\&7h\135\222\137\DC1IW",PropRequestProblemInformation 5,PropMessageExpiryInterval +// 14885,PropSharedSubscriptionAvailable 70,PropReasonString "\SI\136gr\141\GS\142",PropTopicAliasMaximum 2086] +// [UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse] +TEST(UnsubACK5QCTest, Decode5) { + u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0x37, 0x68, 0x87, 0xde, 0x89, 0x11, + 0x49, 0x57, 0x17, 0x5, 0x2, 0x0, 0x0, 0x3a, 0x25, 0x2a, 0x46, 0x1f, 0x0, 0x7, 0xf, 0x88, 0x67, 0x72, 0x8d, + 0x1d, 0x8e, 0x22, 0x8, 0x26, 0x8f, 0x91, 0x8f, 0x0, 0x11, 0x80, 0x91, 0x80, 0x11, 0x83, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[11]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 29099); + EXPECT_EQ(count, 11); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); +} + +// UnsubscribeResponse 3499 [PropMaximumQoS 97,PropSubscriptionIdentifier 14,PropSubscriptionIdentifier +// 13,PropSharedSubscriptionAvailable 56,PropSubscriptionIdentifier 27,PropRequestProblemInformation +// 242,PropMessageExpiryInterval 26017,PropSessionExpiryInterval 17048,PropRetainAvailable +// 187,PropAssignedClientIdentifier "85\244\182\246)W\189:\215\211\197\139:\141d<\233",PropSubscriptionIdentifier +// 11,PropResponseInformation ">'\175\SYNZ\151\&6\180\217\&3\162\227\191\245\&0",PropMessageExpiryInterval +// 6524,PropTopicAlias 20579,PropMessageExpiryInterval 2741,PropMaximumQoS 195,PropUserProperty +// "\ETXIeK\163\ESC\164\STX\DC1n14\224\201\139\224\&6H\172\165\241m\210}3H3\EM" "\212",PropUserProperty +// "\136\206\175\143K\DC4\ENQ\168" "\132\196|\230H=l\149\v\223.\a_u\136",PropAuthenticationMethod +// "\FS",PropServerKeepAlive 12431,PropMessageExpiryInterval 22466,PropSharedSubscriptionAvailable +// 133,PropMaximumPacketSize 31328,PropAuthenticationMethod +// "\201SD\203y\v4P\184\198\181\GSc>\129B",PropPayloadFormatIndicator 18,PropSharedSubscriptionAvailable +// 186,PropSessionExpiryInterval 1470,PropRequestResponseInformation 50,PropMaximumQoS 19,PropSubscriptionIdentifier 12] +// [UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted] +TEST(UnsubACK5QCTest, Decode6) { + uint8_t pkt[] = {0xb0, 0xd6, 0x1, 0xd, 0xab, 0xc3, 0x1, 0x24, 0x61, 0xb, 0xe, 0xb, 0xd, 0x2a, 0x38, 0xb, 0x1b, + 0x17, 0xf2, 0x2, 0x0, 0x0, 0x65, 0xa1, 0x11, 0x0, 0x0, 0x42, 0x98, 0x25, 0xbb, 0x12, 0x0, 0x12, + 0x38, 0x35, 0xf4, 0xb6, 0xf6, 0x29, 0x57, 0xbd, 0x3a, 0xd7, 0xd3, 0xc5, 0x8b, 0x3a, 0x8d, 0x64, 0x3c, + 0xe9, 0xb, 0xb, 0x1a, 0x0, 0xf, 0x3e, 0x27, 0xaf, 0x16, 0x5a, 0x97, 0x36, 0xb4, 0xd9, 0x33, 0xa2, + 0xe3, 0xbf, 0xf5, 0x30, 0x2, 0x0, 0x0, 0x19, 0x7c, 0x23, 0x50, 0x63, 0x2, 0x0, 0x0, 0xa, 0xb5, + 0x24, 0xc3, 0x26, 0x0, 0x1c, 0x3, 0x49, 0x65, 0x4b, 0xa3, 0x1b, 0xa4, 0x2, 0x11, 0x6e, 0x31, 0x34, + 0xe0, 0xc9, 0x8b, 0xe0, 0x36, 0x48, 0xac, 0xa5, 0xf1, 0x6d, 0xd2, 0x7d, 0x33, 0x48, 0x33, 0x19, 0x0, + 0x1, 0xd4, 0x26, 0x0, 0x8, 0x88, 0xce, 0xaf, 0x8f, 0x4b, 0x14, 0x5, 0xa8, 0x0, 0xf, 0x84, 0xc4, + 0x7c, 0xe6, 0x48, 0x3d, 0x6c, 0x95, 0xb, 0xdf, 0x2e, 0x7, 0x5f, 0x75, 0x88, 0x15, 0x0, 0x1, 0x1c, + 0x13, 0x30, 0x8f, 0x2, 0x0, 0x0, 0x57, 0xc2, 0x2a, 0x85, 0x27, 0x0, 0x0, 0x7a, 0x60, 0x15, 0x0, + 0x10, 0xc9, 0x53, 0x44, 0xcb, 0x79, 0xb, 0x34, 0x50, 0xb8, 0xc6, 0xb5, 0x1d, 0x63, 0x3e, 0x81, 0x42, + 0x1, 0x12, 0x2a, 0xba, 0x11, 0x0, 0x0, 0x5, 0xbe, 0x19, 0x32, 0x24, 0x13, 0xb, 0xc, 0x91, 0x91, + 0x83, 0x80, 0x91, 0x91, 0x91, 0x80, 0x91, 0x80, 0x87, 0x80, 0x87, 0x83, 0x11}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[15]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 15, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 3499); + EXPECT_EQ(count, 15); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NO_SUB_EXISTED); +} + +// UnsubscribeResponse 25674 [PropResponseTopic "\251\172\163@\137*\EOT\243wZ\153\210\140\220\ETB\v5 +// \174}\179L\STXx",PropCorrelationData +// "\170Gh3!.\146\EMfLE\190\ETX\250s\220\144\&1t\184{[t%Rg\DEL\231\132",PropMaximumPacketSize +// 1709,PropPayloadFormatIndicator 243,PropWildcardSubscriptionAvailable 187,PropRequestProblemInformation +// 182,PropTopicAliasMaximum 30360,PropMessageExpiryInterval 6490,PropAssignedClientIdentifier +// "T\175\b\244\228G\235\DC3@\EM\139\174\148\170\241\255\139",PropAssignedClientIdentifier +// "\144\177\176\&9\SYN\128\181%\155\171",PropMessageExpiryInterval 538,PropTopicAliasMaximum 10132] +// [UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubSuccess,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubPacketIdentifierInUse] +TEST(UnsubACK5QCTest, Decode7) { + uint8_t pkt[] = {0xb0, 0x90, 0x1, 0x64, 0x4a, 0x77, 0x8, 0x0, 0x18, 0xfb, 0xac, 0xa3, 0x40, 0x89, 0x2a, 0x4, 0xf3, + 0x77, 0x5a, 0x99, 0xd2, 0x8c, 0xdc, 0x17, 0xb, 0x35, 0x20, 0xae, 0x7d, 0xb3, 0x4c, 0x2, 0x78, 0x9, + 0x0, 0x1d, 0xaa, 0x47, 0x68, 0x33, 0x21, 0x2e, 0x92, 0x19, 0x66, 0x4c, 0x45, 0xbe, 0x3, 0xfa, 0x73, + 0xdc, 0x90, 0x31, 0x74, 0xb8, 0x7b, 0x5b, 0x74, 0x25, 0x52, 0x67, 0x7f, 0xe7, 0x84, 0x27, 0x0, 0x0, + 0x6, 0xad, 0x1, 0xf3, 0x28, 0xbb, 0x17, 0xb6, 0x22, 0x76, 0x98, 0x2, 0x0, 0x0, 0x19, 0x5a, 0x12, + 0x0, 0x11, 0x54, 0xaf, 0x8, 0xf4, 0xe4, 0x47, 0xeb, 0x13, 0x40, 0x19, 0x8b, 0xae, 0x94, 0xaa, 0xf1, + 0xff, 0x8b, 0x12, 0x0, 0xa, 0x90, 0xb1, 0xb0, 0x39, 0x16, 0x80, 0xb5, 0x25, 0x9b, 0xab, 0x2, 0x0, + 0x0, 0x2, 0x1a, 0x22, 0x27, 0x94, 0x83, 0x8f, 0x0, 0x11, 0x80, 0x80, 0x87, 0x83, 0x87, 0x11, 0x11, + 0x87, 0x8f, 0x0, 0x83, 0x80, 0x8f, 0x0, 0x83, 0x83, 0x87, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[22]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 22, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 25674); + EXPECT_EQ(count, 22); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_PACKET_ID_IN_USE); +} + +// UnsubscribeResponse 11351 [PropSharedSubscriptionAvailable 5,PropAuthenticationMethod +// "\147L\NUL|8\218\130\203\a]M\252\142\DC1\130_#)\153F",PropMaximumPacketSize 19701,PropMaximumPacketSize +// 4611,PropAuthenticationMethod +// ">\200t{\194Y\163\&1wW\157\168\SI\ETX\141A\242t)\204O\195`!",PropAssignedClientIdentifier +// "\DLE\132i\162\130",PropServerReference +// "_\171\144\140\131\ESC\130\146\SI*\170\193U8\164A)\ENQ\238S9\DELuG",PropSharedSubscriptionAvailable 18,PropMaximumQoS +// 242,PropTopicAliasMaximum 11494,PropMaximumPacketSize 16918,PropTopicAlias 17194,PropRetainAvailable +// 72,PropContentType "0%\131\137\229\191\f\216ab",PropPayloadFormatIndicator 183,PropPayloadFormatIndicator +// 219,PropSubscriptionIdentifier 23,PropMessageExpiryInterval 5099,PropRetainAvailable 7,PropMaximumPacketSize +// 32687,PropReceiveMaximum 31244] +// [UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubImplementationSpecificError] +TEST(UnsubACK5QCTest, Decode8) { + uint8_t pkt[] = {0xb0, 0xb5, 0x1, 0x2c, 0x57, 0x94, 0x1, 0x2a, 0x5, 0x15, 0x0, 0x14, 0x93, 0x4c, 0x0, 0x7c, 0x38, + 0xda, 0x82, 0xcb, 0x7, 0x5d, 0x4d, 0xfc, 0x8e, 0x11, 0x82, 0x5f, 0x23, 0x29, 0x99, 0x46, 0x27, 0x0, + 0x0, 0x4c, 0xf5, 0x27, 0x0, 0x0, 0x12, 0x3, 0x15, 0x0, 0x18, 0x3e, 0xc8, 0x74, 0x7b, 0xc2, 0x59, + 0xa3, 0x31, 0x77, 0x57, 0x9d, 0xa8, 0xf, 0x3, 0x8d, 0x41, 0xf2, 0x74, 0x29, 0xcc, 0x4f, 0xc3, 0x60, + 0x21, 0x12, 0x0, 0x5, 0x10, 0x84, 0x69, 0xa2, 0x82, 0x1c, 0x0, 0x18, 0x5f, 0xab, 0x90, 0x8c, 0x83, + 0x1b, 0x82, 0x92, 0xf, 0x2a, 0xaa, 0xc1, 0x55, 0x38, 0xa4, 0x41, 0x29, 0x5, 0xee, 0x53, 0x39, 0x7f, + 0x75, 0x47, 0x2a, 0x12, 0x24, 0xf2, 0x22, 0x2c, 0xe6, 0x27, 0x0, 0x0, 0x42, 0x16, 0x23, 0x43, 0x2a, + 0x25, 0x48, 0x3, 0x0, 0xa, 0x30, 0x25, 0x83, 0x89, 0xe5, 0xbf, 0xc, 0xd8, 0x61, 0x62, 0x1, 0xb7, + 0x1, 0xdb, 0xb, 0x17, 0x2, 0x0, 0x0, 0x13, 0xeb, 0x25, 0x7, 0x27, 0x0, 0x0, 0x7f, 0xaf, 0x21, + 0x7a, 0xc, 0x11, 0x87, 0x8f, 0x8f, 0x8f, 0x87, 0x83, 0x83, 0x83, 0x11, 0x11, 0x87, 0x11, 0x80, 0x0, + 0x11, 0x11, 0x8f, 0x87, 0x83, 0x11, 0x91, 0x83, 0x80, 0x8f, 0x11, 0x91, 0x83, 0x83}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[29]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 29, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 11351); + EXPECT_EQ(count, 29); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[27], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[28], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); +} + +// UnsubscribeResponse 11966 [PropResponseInformation +// "\145\227\228&\228\DELM\RSc\140Vq\207\188\GS\229\174",PropAssignedClientIdentifier +// ",^\169\191\RSt\198\251\229iB\DC4\195\132G\202yI\223\171\SO\214\223u\143\150X",PropReasonString "-\203\&3\175 +// @\212\223\133\n\155J\141u\253\188d\177\f",PropSessionExpiryInterval 29407,PropTopicAlias 32744,PropResponseTopic +// "\188",PropReceiveMaximum 14635,PropWildcardSubscriptionAvailable 47] +// [UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubSuccess,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubUnspecifiedError] +TEST(UnsubACK5QCTest, Decode9) { + uint8_t pkt[] = {0xb0, 0x63, 0x2e, 0xbe, 0x59, 0x1a, 0x0, 0x11, 0x91, 0xe3, 0xe4, 0x26, 0xe4, 0x7f, 0x4d, 0x1e, 0x63, + 0x8c, 0x56, 0x71, 0xcf, 0xbc, 0x1d, 0xe5, 0xae, 0x12, 0x0, 0x1b, 0x2c, 0x5e, 0xa9, 0xbf, 0x1e, 0x74, + 0xc6, 0xfb, 0xe5, 0x69, 0x42, 0x14, 0xc3, 0x84, 0x47, 0xca, 0x79, 0x49, 0xdf, 0xab, 0xe, 0xd6, 0xdf, + 0x75, 0x8f, 0x96, 0x58, 0x1f, 0x0, 0x13, 0x2d, 0xcb, 0x33, 0xaf, 0x20, 0x40, 0xd4, 0xdf, 0x85, 0xa, + 0x9b, 0x4a, 0x8d, 0x75, 0xfd, 0xbc, 0x64, 0xb1, 0xc, 0x11, 0x0, 0x0, 0x72, 0xdf, 0x23, 0x7f, 0xe8, + 0x8, 0x0, 0x1, 0xbc, 0x21, 0x39, 0x2b, 0x28, 0x2f, 0x87, 0x91, 0x80, 0x0, 0x87, 0x8f, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[7]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 11966); + EXPECT_EQ(count, 7); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); +} + +// UnsubscribeResponse 28946 [PropAuthenticationMethod +// "7\240\150\195\&38\131m\233\159C\214\147>R\128\253|m\GS-\193\129",PropTopicAlias 5564,PropRequestProblemInformation +// 75,PropRequestProblemInformation 190,PropMessageExpiryInterval 834,PropRetainAvailable 33,PropResponseInformation +// "I\198",PropCorrelationData +// "\193\rCf+\STX\155\193\169\167\SOH)\137\145b\156h\ESC\219\154\225PE\DC2\239\ACK\244",PropResponseInformation +// "\133|o\247!\161\195m\165e1mJ\157e",PropReceiveMaximum 27827,PropServerKeepAlive 13713,PropReasonString +// ")\228I\174\175\245\179\225",PropRetainAvailable 106,PropSessionExpiryInterval 19620] +// [UnsubSuccess,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubSuccess,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode10) { + uint8_t pkt[] = {0xb0, 0x93, 0x1, 0x71, 0x12, 0x75, 0x15, 0x0, 0x17, 0x37, 0xf0, 0x96, 0xc3, 0x33, 0x38, 0x83, 0x6d, + 0xe9, 0x9f, 0x43, 0xd6, 0x93, 0x3e, 0x52, 0x80, 0xfd, 0x7c, 0x6d, 0x1d, 0x2d, 0xc1, 0x81, 0x23, 0x15, + 0xbc, 0x17, 0x4b, 0x17, 0xbe, 0x2, 0x0, 0x0, 0x3, 0x42, 0x25, 0x21, 0x1a, 0x0, 0x2, 0x49, 0xc6, + 0x9, 0x0, 0x1b, 0xc1, 0xd, 0x43, 0x66, 0x2b, 0x2, 0x9b, 0xc1, 0xa9, 0xa7, 0x1, 0x29, 0x89, 0x91, + 0x62, 0x9c, 0x68, 0x1b, 0xdb, 0x9a, 0xe1, 0x50, 0x45, 0x12, 0xef, 0x6, 0xf4, 0x1a, 0x0, 0xf, 0x85, + 0x7c, 0x6f, 0xf7, 0x21, 0xa1, 0xc3, 0x6d, 0xa5, 0x65, 0x31, 0x6d, 0x4a, 0x9d, 0x65, 0x21, 0x6c, 0xb3, + 0x13, 0x35, 0x91, 0x1f, 0x0, 0x8, 0x29, 0xe4, 0x49, 0xae, 0xaf, 0xf5, 0xb3, 0xe1, 0x25, 0x6a, 0x11, + 0x0, 0x0, 0x4c, 0xa4, 0x0, 0x0, 0x11, 0x8f, 0x80, 0x8f, 0x83, 0x11, 0x83, 0x80, 0x8f, 0x83, 0x80, + 0x0, 0x83, 0x91, 0x87, 0x83, 0x87, 0x8f, 0x80, 0x0, 0x11, 0x87, 0x0, 0x11, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[27]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 27, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 28946); + EXPECT_EQ(count, 27); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_SUCCESS); +} + +// UnsubscribeResponse 29805 [PropSharedSubscriptionAvailable 167,PropWildcardSubscriptionAvailable +// 36,PropRetainAvailable 125,PropReceiveMaximum 20880,PropServerKeepAlive 6088,PropTopicAliasMaximum +// 18031,PropTopicAliasMaximum 15408,PropSubscriptionIdentifierAvailable 7,PropRequestProblemInformation +// 160,PropSharedSubscriptionAvailable 138,PropWildcardSubscriptionAvailable 221,PropAuthenticationMethod +// "\150\233T\188",PropSharedSubscriptionAvailable 218,PropTopicAlias 11586] +// [UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode11) { + uint8_t pkt[] = {0xb0, 0x2e, 0x74, 0x6d, 0x26, 0x2a, 0xa7, 0x28, 0x24, 0x25, 0x7d, 0x21, 0x51, 0x90, 0x13, 0x17, + 0xc8, 0x22, 0x46, 0x6f, 0x22, 0x3c, 0x30, 0x29, 0x7, 0x17, 0xa0, 0x2a, 0x8a, 0x28, 0xdd, 0x15, + 0x0, 0x4, 0x96, 0xe9, 0x54, 0xbc, 0x2a, 0xda, 0x23, 0x2d, 0x42, 0x83, 0x80, 0x83, 0x8f, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[5]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 29805); + EXPECT_EQ(count, 5); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); +} + +// UnsubscribeResponse 19841 [PropRequestResponseInformation 195,PropSessionExpiryInterval 7099,PropCorrelationData +// "\253Q\149=\DC2\ESC \244\255\163G\186go\221\227M\SUB\224c\250\197a\SYN\167\151",PropServerReference +// "\160f\192\196\162",PropRequestProblemInformation 69,PropResponseInformation +// "\143\148\214\220\&6\248\182\150\135/\227\183\208#\244\&5\226\147\239\162+",PropSharedSubscriptionAvailable +// 5,PropTopicAlias 25859,PropAuthenticationMethod "\219*\147/^\ETB\RS-\219\ACK$6\\\185P%(",PropResponseInformation +// "\235g\205<\169\&98\245v\187\214\183\222\160\167\CAN\ETXkE\176 \137",PropSharedSubscriptionAvailable +// 1,PropMessageExpiryInterval 8462,PropAuthenticationMethod "\171",PropReceiveMaximum 23714,PropMessageExpiryInterval +// 31618,PropServerKeepAlive 15174,PropWillDelayInterval 30554,PropServerKeepAlive 28321,PropMaximumQoS +// 208,PropAuthenticationMethod "\251\188MB\GS\ESCW\186R\142A\tj\235@\166\"",PropMaximumPacketSize 26290,PropMaximumQoS +// 50,PropUserProperty "b\DC3\146\176(lv\171\154\&1\191\141\225\&5\145_O\245Y\192\EM\ESC" +// "\167\CAN|\150\ACK\214\214Q\ETX\152I\181I\a\164\155~\184\218\180Jq",PropSessionExpiryInterval 2734,PropContentType +// "m\176\&7\170\\"] +// [UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubSuccess,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubTopicFilterInvalid] +TEST(UnsubACK5QCTest, Decode12) { + uint8_t pkt[] = {0xb0, 0x88, 0x2, 0x4d, 0x81, 0xf1, 0x1, 0x19, 0xc3, 0x11, 0x0, 0x0, 0x1b, 0xbb, 0x9, 0x0, 0x1a, + 0xfd, 0x51, 0x95, 0x3d, 0x12, 0x1b, 0x20, 0xf4, 0xff, 0xa3, 0x47, 0xba, 0x67, 0x6f, 0xdd, 0xe3, 0x4d, + 0x1a, 0xe0, 0x63, 0xfa, 0xc5, 0x61, 0x16, 0xa7, 0x97, 0x1c, 0x0, 0x5, 0xa0, 0x66, 0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, 0x11, 0x0, 0x0, + 0xa, 0xae, 0x3, 0x0, 0x5, 0x6d, 0xb0, 0x37, 0xaa, 0x5c, 0x11, 0x11, 0x91, 0x8f, 0x0, 0x83, 0x11, + 0x80, 0x11, 0x8f, 0x80, 0x83, 0x11, 0x0, 0x8f, 0x0, 0x11, 0x80, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[19]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 19, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 19841); + EXPECT_EQ(count, 19); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); +} + +// UnsubscribeResponse 20127 [PropResponseInformation "\141",PropAuthenticationData +// "\SUB\224",PropAssignedClientIdentifier "\243",PropAuthenticationMethod "\145\DC2\201\DC4\250\153\"Xo0i\134D\215\223 +// w5\214\138\213\164f~\\\150\175\171;",PropReasonString +// "$\223\232\147\131e\183\175U\200Dv\234S\129X\202",PropAuthenticationMethod +// "\US\162w\181I\">p$\n",PropSharedSubscriptionAvailable 226,PropReceiveMaximum +// 3366,PropSubscriptionIdentifierAvailable 14,PropWillDelayInterval 9401,PropReceiveMaximum 23667,PropUserProperty +// "\tu\153\250\252\DC1S" "\238\169\232\b\146\135",PropSharedSubscriptionAvailable 108] +// [UnsubPacketIdentifierInUse,UnsubSuccess,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubSuccess,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubSuccess,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubImplementationSpecificError,UnsubSuccess,UnsubImplementationSpecificError,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode13) { + uint8_t pkt[] = {0xb0, 0x90, 0x1, 0x4e, 0x9f, 0x71, 0x1a, 0x0, 0x1, 0x8d, 0x16, 0x0, 0x2, 0x1a, 0xe0, 0x12, 0x0, + 0x1, 0xf3, 0x15, 0x0, 0x1d, 0x91, 0x12, 0xc9, 0x14, 0xfa, 0x99, 0x22, 0x58, 0x6f, 0x30, 0x69, 0x86, + 0x44, 0xd7, 0xdf, 0x20, 0x77, 0x35, 0xd6, 0x8a, 0xd5, 0xa4, 0x66, 0x7e, 0x5c, 0x96, 0xaf, 0xab, 0x3b, + 0x1f, 0x0, 0x11, 0x24, 0xdf, 0xe8, 0x93, 0x83, 0x65, 0xb7, 0xaf, 0x55, 0xc8, 0x44, 0x76, 0xea, 0x53, + 0x81, 0x58, 0xca, 0x15, 0x0, 0xa, 0x1f, 0xa2, 0x77, 0xb5, 0x49, 0x22, 0x3e, 0x70, 0x24, 0xa, 0x2a, + 0xe2, 0x21, 0xd, 0x26, 0x29, 0xe, 0x18, 0x0, 0x0, 0x24, 0xb9, 0x21, 0x5c, 0x73, 0x26, 0x0, 0x7, + 0x9, 0x75, 0x99, 0xfa, 0xfc, 0x11, 0x53, 0x0, 0x6, 0xee, 0xa9, 0xe8, 0x8, 0x92, 0x87, 0x2a, 0x6c, + 0x91, 0x0, 0x83, 0x83, 0x0, 0x80, 0x11, 0x83, 0x91, 0x91, 0x0, 0x8f, 0x8f, 0x87, 0x11, 0x87, 0x80, + 0x0, 0x80, 0x8f, 0x80, 0x0, 0x11, 0x0, 0x83, 0x0, 0x83, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[28]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 28, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 20127); + EXPECT_EQ(count, 28); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[27], LWMQTT_UNSUB_SUCCESS); +} + +// UnsubscribeResponse 6820 [PropAssignedClientIdentifier "&l\161Q\197\198\157\":\212o +// \179w\US~\197\144\244.\ETB\233\171",PropTopicAliasMaximum 7609,PropRequestProblemInformation 190,PropReasonString +// "[\209mi\197\160\NAK==\141\139\200 c\244",PropSubscriptionIdentifierAvailable 164] +// [UnsubNotAuthorized,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubSuccess,UnsubSuccess,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubSuccess,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubTopicFilterInvalid] +TEST(UnsubACK5QCTest, Decode14) { + uint8_t pkt[] = {0xb0, 0x52, 0x1a, 0xa4, 0x33, 0x12, 0x0, 0x17, 0x26, 0x6c, 0xa1, 0x51, 0xc5, 0xc6, 0x9d, 0x22, 0x3a, + 0xd4, 0x6f, 0x20, 0xb3, 0x77, 0x1f, 0x7e, 0xc5, 0x90, 0xf4, 0x2e, 0x17, 0xe9, 0xab, 0x22, 0x1d, 0xb9, + 0x17, 0xbe, 0x1f, 0x0, 0xf, 0x5b, 0xd1, 0x6d, 0x69, 0xc5, 0xa0, 0x15, 0x3d, 0x3d, 0x8d, 0x8b, 0xc8, + 0x20, 0x63, 0xf4, 0x29, 0xa4, 0x87, 0x80, 0x83, 0x91, 0x91, 0x83, 0x83, 0x87, 0x91, 0x91, 0x91, 0x8f, + 0x0, 0x0, 0x87, 0x83, 0x87, 0x0, 0x87, 0x83, 0x80, 0x80, 0x8f, 0x83, 0x80, 0x83, 0x80, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[28]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 28, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 6820); + EXPECT_EQ(count, 28); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[27], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); +} + +// UnsubscribeResponse 20949 [PropCorrelationData +// "\222\218_AT\185\SI\247\STX\156\252\152\SOE\186",PropSessionExpiryInterval 10976,PropAuthenticationData +// "\131I\RS\EOT\213n\135\197\206\129&\209\&4\191)\f\221U\159gR^]\184\173\131\152*\235",PropRequestProblemInformation +// 254,PropTopicAliasMaximum 23485,PropResponseInformation "2Y\223\239\209L\140)\153\144)& \156\164p",PropReceiveMaximum +// 636,PropPayloadFormatIndicator 97,PropMaximumPacketSize 26198,PropContentType "0\220\&5",PropWillDelayInterval +// 14882,PropTopicAlias 20936,PropRequestProblemInformation 127,PropResponseTopic +// "C\214\182\176\151\189\234\237'%g6\235\214\239\&3\246#\155\213\142",PropResponseInformation +// "\224zEl-\188RO\219\140?s\231\GSR\234)\200\197\238",PropContentType "\244\bC\217\SYN\152\&9\SI#\241~\186\214}\198"] +// [UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubSuccess,UnsubUnspecifiedError,UnsubImplementationSpecificError] +TEST(UnsubACK5QCTest, Decode15) { + uint8_t pkt[] = {0xb0, 0xb6, 0x1, 0x51, 0xd5, 0xaa, 0x1, 0x9, 0x0, 0xf, 0xde, 0xda, 0x5f, 0x41, 0x54, 0xb9, 0xf, + 0xf7, 0x2, 0x9c, 0xfc, 0x98, 0xe, 0x45, 0xba, 0x11, 0x0, 0x0, 0x2a, 0xe0, 0x16, 0x0, 0x1d, 0x83, + 0x49, 0x1e, 0x4, 0xd5, 0x6e, 0x87, 0xc5, 0xce, 0x81, 0x26, 0xd1, 0x34, 0xbf, 0x29, 0xc, 0xdd, 0x55, + 0x9f, 0x67, 0x52, 0x5e, 0x5d, 0xb8, 0xad, 0x83, 0x98, 0x2a, 0xeb, 0x17, 0xfe, 0x22, 0x5b, 0xbd, 0x1a, + 0x0, 0x10, 0x32, 0x59, 0xdf, 0xef, 0xd1, 0x4c, 0x8c, 0x29, 0x99, 0x90, 0x29, 0x26, 0x20, 0x9c, 0xa4, + 0x70, 0x21, 0x2, 0x7c, 0x1, 0x61, 0x27, 0x0, 0x0, 0x66, 0x56, 0x3, 0x0, 0x3, 0x30, 0xdc, 0x35, + 0x18, 0x0, 0x0, 0x3a, 0x22, 0x23, 0x51, 0xc8, 0x17, 0x7f, 0x8, 0x0, 0x15, 0x43, 0xd6, 0xb6, 0xb0, + 0x97, 0xbd, 0xea, 0xed, 0x27, 0x25, 0x67, 0x36, 0xeb, 0xd6, 0xef, 0x33, 0xf6, 0x23, 0x9b, 0xd5, 0x8e, + 0x1a, 0x0, 0x14, 0xe0, 0x7a, 0x45, 0x6c, 0x2d, 0xbc, 0x52, 0x4f, 0xdb, 0x8c, 0x3f, 0x73, 0xe7, 0x1d, + 0x52, 0xea, 0x29, 0xc8, 0xc5, 0xee, 0x3, 0x0, 0xf, 0xf4, 0x8, 0x43, 0xd9, 0x16, 0x98, 0x39, 0xf, + 0x23, 0xf1, 0x7e, 0xba, 0xd6, 0x7d, 0xc6, 0x83, 0x80, 0x83, 0x91, 0x83, 0x0, 0x80, 0x83}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[8]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 20949); + EXPECT_EQ(count, 8); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); +} + +// UnsubscribeResponse 15084 [PropTopicAliasMaximum 6984,PropUserProperty ",\189 +// \197\190&S,t\241E\ESC\248\211\DC4\177\187\b\238\205w\159\183\USK\148" +// "-\229\131\222\RS\193\171\151c\STX\138\139\214`\144\165\239k\146",PropSessionExpiryInterval +// 2451,PropSessionExpiryInterval 9205,PropAuthenticationMethod +// "\161E:&\206\194Z1\183\139\v~\SOH\255\STXx\SO\SO\ETXz\224R\161\209",PropMaximumQoS 80,PropReceiveMaximum +// 30671,PropAuthenticationData "Ya\157\&1Y\f\"\255*\248\SI\bf\EOTqd\168\USC'8\175\241!",PropResponseInformation +// "\138l\NAK",PropSubscriptionIdentifierAvailable 136,PropMaximumQoS 148,PropSubscriptionIdentifierAvailable +// 244,PropServerKeepAlive 25040,PropTopicAlias 1743,PropAuthenticationMethod +// "\216\201r\175]\219x@i5q\239e\238\160\218\DLE",PropUserProperty "0\164y\143N" "KD",PropReasonString +// "3C\210q\n\CAN{\131\237\224N\FS\170\183u|4R",PropServerKeepAlive 10794,PropMessageExpiryInterval +// 17780,PropSubscriptionIdentifierAvailable 204,PropSessionExpiryInterval 3287,PropRequestProblemInformation +// 246,PropSubscriptionIdentifier 19,PropSubscriptionIdentifier 10,PropContentType +// "\143?}\ESC\249}9\NUL\142\128\210r\SYNA\STX\176\250\132"] +// [UnsubNoSubscriptionExisted,UnsubSuccess,UnsubNotAuthorized,UnsubSuccess,UnsubNotAuthorized,UnsubNotAuthorized] +TEST(UnsubACK5QCTest, Decode19) { + uint8_t pkt[] = {0xb0, 0xa4, 0x1, 0x2d, 0x79, 0x9a, 0x1, 0x1f, 0x0, 0x0, 0x26, 0x0, 0xc, 0x2b, 0xb6, 0xb7, 0xc, + 0x4b, 0x67, 0x68, 0x3, 0x39, 0x81, 0xa6, 0x8d, 0x0, 0x15, 0x1c, 0xa7, 0xc5, 0xc2, 0x11, 0xd0, 0xf4, + 0x22, 0x3c, 0xdd, 0x3e, 0x71, 0x64, 0xa8, 0x1f, 0x43, 0x27, 0x38, 0xaf, 0xf1, 0x21, 0x1a, 0x0, 0x3, + 0x8a, 0x6c, 0x15, 0x29, 0x88, 0x24, 0x94, 0x29, 0xf4, 0x13, 0x61, 0xd0, 0x23, 0x6, 0xcf, 0x15, 0x0, + 0x11, 0xd8, 0xc9, 0x72, 0xaf, 0x5d, 0xdb, 0x78, 0x40, 0x69, 0x35, 0x71, 0xef, 0x65, 0xee, 0xa0, 0xda, + 0x10, 0x26, 0x0, 0x5, 0x30, 0xa4, 0x79, 0x8f, 0x4e, 0x0, 0x2, 0x4b, 0x44, 0x1f, 0x0, 0x12, 0x33, + 0x43, 0xd2, 0x71, 0xa, 0x18, 0x7b, 0x83, 0xed, 0xe0, 0x4e, 0x1c, 0xaa, 0xb7, 0x75, 0x7c, 0x34, 0x52, + 0x13, 0x2a, 0x2a, 0x2, 0x0, 0x0, 0x45, 0x74, 0x29, 0xcc, 0x11, 0x0, 0x0, 0xc, 0xd7, 0x17, 0xf6, + 0xb, 0x13, 0xb, 0xa, 0x3, 0x0, 0x12, 0x8f, 0x3f, 0x7d, 0x1b, 0xf9, 0x7d, 0x39, 0x0, 0x8e, 0x80, + 0xd2, 0x72, 0x16, 0x41, 0x2, 0xb0, 0xfa, 0x84, 0x11, 0x0, 0x87, 0x0, 0x87, 0x87}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[6]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 11641); + EXPECT_EQ(count, 6); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); +} + +// UnsubscribeResponse 5146 [PropReasonString +// "\214\192\142\182(b@\215w\222t\145\195\EM\141Er\161\US\255\136m\US\133'\219\164j ",PropCorrelationData +// "\200\USu_+<\195\139\163\156q\EOT\158\\\149\223\SYN\184\221\GS\f\202~\179A\187_"] +// [UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubSuccess,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubSuccess,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted] +TEST(UnsubACK5QCTest, Decode20) { + uint8_t pkt[] = {0xb0, 0x5a, 0x14, 0x1a, 0x3e, 0x1f, 0x0, 0x1d, 0xd6, 0xc0, 0x8e, 0xb6, 0x28, 0x62, 0x40, 0xd7, + 0x77, 0xde, 0x74, 0x91, 0xc3, 0x19, 0x8d, 0x45, 0x72, 0xa1, 0x1f, 0xff, 0x88, 0x6d, 0x1f, 0x85, + 0x27, 0xdb, 0xa4, 0x6a, 0x20, 0x9, 0x0, 0x1b, 0xc8, 0x1f, 0x75, 0x5f, 0x2b, 0x3c, 0xc3, 0x8b, + 0xa3, 0x9c, 0x71, 0x4, 0x9e, 0x5c, 0x95, 0xdf, 0x16, 0xb8, 0xdd, 0x1d, 0xc, 0xca, 0x7e, 0xb3, + 0x41, 0xbb, 0x5f, 0x83, 0x87, 0x87, 0x80, 0x87, 0x0, 0x87, 0x91, 0x11, 0x91, 0x87, 0x91, 0x11, + 0x0, 0x0, 0x91, 0x0, 0x8f, 0x8f, 0x87, 0x0, 0x83, 0x83, 0x11, 0x11}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[25]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 25, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 5146); + EXPECT_EQ(count, 25); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_NO_SUB_EXISTED); +} + +// UnsubscribeResponse 19495 [PropReceiveMaximum 12701,PropAuthenticationData "\DC24\224\169"] +// [UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubSuccess,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubSuccess,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubSuccess,UnsubUnspecifiedError,UnsubPacketIdentifierInUse] +TEST(UnsubACK5QCTest, Decode21) { + uint8_t pkt[] = {0xb0, 0x28, 0x4c, 0x27, 0xa, 0x21, 0x31, 0x9d, 0x16, 0x0, 0x4, 0x12, 0x34, 0xe0, + 0xa9, 0x91, 0x8f, 0x83, 0x0, 0x0, 0x11, 0x80, 0x8f, 0x91, 0x0, 0x8f, 0x0, 0x0, + 0x11, 0x87, 0x11, 0x91, 0x91, 0x83, 0x80, 0x11, 0x11, 0x11, 0x0, 0x0, 0x80, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[27]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 27, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 19495); + EXPECT_EQ(count, 27); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_PACKET_ID_IN_USE); +} + +// UnsubscribeResponse 2650 [PropMaximumPacketSize 23567,PropReceiveMaximum 460,PropReceiveMaximum 9781,PropReasonString +// "\223\167\182\215\NUL\210\201\211\218\131",PropServerKeepAlive 9721] +// [UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse] +TEST(UnsubACK5QCTest, Decode22) { + uint8_t pkt[] = {0xb0, 0x2b, 0xa, 0x5a, 0x1b, 0x27, 0x0, 0x0, 0x5c, 0xf, 0x21, 0x1, 0xcc, 0x21, 0x26, + 0x35, 0x1f, 0x0, 0xa, 0xdf, 0xa7, 0xb6, 0xd7, 0x0, 0xd2, 0xc9, 0xd3, 0xda, 0x83, 0x13, + 0x25, 0xf9, 0x83, 0x80, 0x83, 0x8f, 0x80, 0x80, 0x0, 0x11, 0x8f, 0x87, 0x83, 0x11, 0x91}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[13]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 13, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 2650); + EXPECT_EQ(count, 13); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_PACKET_ID_IN_USE); +} + +// UnsubscribeResponse 4720 [PropReasonString +// "\130\242\f\SYN\158?\183\229\174\203B\213\\\249\DC3I\134\138\252\129\SO\231\199.",PropReasonString +// "\187\196\213\ESC\128\213t\145OU/",PropServerReference "",PropReasonString +// "\DEL?z+\\\197\200\219\193\152!'\174\137",PropPayloadFormatIndicator 48,PropUserProperty "\202)+\188\172\192\223C" +// "\139\178H!\SUB\253\&8\190!\135]\CAN",PropSharedSubscriptionAvailable 34,PropMaximumPacketSize +// 14585,PropRequestProblemInformation 61,PropAssignedClientIdentifier +// "Xi\247yG\138_v\247-\181",PropRequestProblemInformation 16,PropMaximumPacketSize 13540,PropContentType +// "N\243W[\DEL\181\221H\240#\232",PropAuthenticationMethod +// "\209\131F\129\218\174\131O\220\166\253\238\b\164W(?\189\236\218\v\204M\215\NAKYXo",PropRetainAvailable +// 195,PropReceiveMaximum 20755,PropWildcardSubscriptionAvailable 251,PropUserProperty "\184\EM\148\DC4]\167" +// "",PropAuthenticationData "\175kB\217",PropSubscriptionIdentifierAvailable 154,PropWillDelayInterval +// 23743,PropMaximumQoS 106,PropSubscriptionIdentifier 25,PropSessionExpiryInterval 7290] +// [UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode23) { + uint8_t pkt[] = { + 0xb0, 0xdb, 0x1, 0x12, 0x70, 0xcc, 0x1, 0x1f, 0x0, 0x18, 0x82, 0xf2, 0xc, 0x16, 0x9e, 0x3f, 0xb7, 0xe5, 0xae, + 0xcb, 0x42, 0xd5, 0x5c, 0xf9, 0x13, 0x49, 0x86, 0x8a, 0xfc, 0x81, 0xe, 0xe7, 0xc7, 0x2e, 0x1f, 0x0, 0xb, 0xbb, + 0xc4, 0xd5, 0x1b, 0x80, 0xd5, 0x74, 0x91, 0x4f, 0x55, 0x2f, 0x1c, 0x0, 0x0, 0x1f, 0x0, 0xe, 0x7f, 0x3f, 0x7a, + 0x2b, 0x5c, 0xc5, 0xc8, 0xdb, 0xc1, 0x98, 0x21, 0x27, 0xae, 0x89, 0x1, 0x30, 0x26, 0x0, 0x8, 0xca, 0x29, 0x2b, + 0xbc, 0xac, 0xc0, 0xdf, 0x43, 0x0, 0xc, 0x8b, 0xb2, 0x48, 0x21, 0x1a, 0xfd, 0x38, 0xbe, 0x21, 0x87, 0x5d, 0x18, + 0x2a, 0x22, 0x27, 0x0, 0x0, 0x38, 0xf9, 0x17, 0x3d, 0x12, 0x0, 0xb, 0x58, 0x69, 0xf7, 0x79, 0x47, 0x8a, 0x5f, + 0x76, 0xf7, 0x2d, 0xb5, 0x17, 0x10, 0x27, 0x0, 0x0, 0x34, 0xe4, 0x3, 0x0, 0xb, 0x4e, 0xf3, 0x57, 0x5b, 0x7f, + 0xb5, 0xdd, 0x48, 0xf0, 0x23, 0xe8, 0x15, 0x0, 0x1c, 0xd1, 0x83, 0x46, 0x81, 0xda, 0xae, 0x83, 0x4f, 0xdc, 0xa6, + 0xfd, 0xee, 0x8, 0xa4, 0x57, 0x28, 0x3f, 0xbd, 0xec, 0xda, 0xb, 0xcc, 0x4d, 0xd7, 0x15, 0x59, 0x58, 0x6f, 0x25, + 0xc3, 0x21, 0x51, 0x13, 0x28, 0xfb, 0x26, 0x0, 0x6, 0xb8, 0x19, 0x94, 0x14, 0x5d, 0xa7, 0x0, 0x0, 0x16, 0x0, + 0x4, 0xaf, 0x6b, 0x42, 0xd9, 0x29, 0x9a, 0x18, 0x0, 0x0, 0x5c, 0xbf, 0x24, 0x6a, 0xb, 0x19, 0x11, 0x0, 0x0, + 0x1c, 0x7a, 0x8f, 0x11, 0x8f, 0x80, 0x8f, 0x0, 0x87, 0x87, 0x80, 0x8f, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[11]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4720); + EXPECT_EQ(count, 11); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); +} + +// UnsubscribeResponse 7392 [PropContentType +// "#\204w\172\159\245\142\174]\141\136\249\183-\SYNO\223\131\202",PropSubscriptionIdentifierAvailable +// 98,PropMessageExpiryInterval 23148,PropAssignedClientIdentifier +// "\252\168\233}\191\225\SI\199\td\207:\n\\\141\228p\b9\187\SUB\195\176\158\243\197l\202\ENQ\244",PropServerKeepAlive +// 18028,PropSubscriptionIdentifierAvailable 242,PropRequestResponseInformation 130] +// [UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubSuccess,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubSuccess,UnsubImplementationSpecificError] +TEST(UnsubACK5QCTest, Decode24) { + uint8_t pkt[] = {0xb0, 0x63, 0x1c, 0xe0, 0x45, 0x3, 0x0, 0x13, 0x23, 0xcc, 0x77, 0xac, 0x9f, 0xf5, 0x8e, 0xae, 0x5d, + 0x8d, 0x88, 0xf9, 0xb7, 0x2d, 0x16, 0x4f, 0xdf, 0x83, 0xca, 0x29, 0x62, 0x2, 0x0, 0x0, 0x5a, 0x6c, + 0x12, 0x0, 0x1e, 0xfc, 0xa8, 0xe9, 0x7d, 0xbf, 0xe1, 0xf, 0xc7, 0x9, 0x64, 0xcf, 0x3a, 0xa, 0x5c, + 0x8d, 0xe4, 0x70, 0x8, 0x39, 0xbb, 0x1a, 0xc3, 0xb0, 0x9e, 0xf3, 0xc5, 0x6c, 0xca, 0x5, 0xf4, 0x13, + 0x46, 0x6c, 0x29, 0xf2, 0x19, 0x82, 0x80, 0x8f, 0x8f, 0x11, 0x87, 0x11, 0x11, 0x87, 0x87, 0x11, 0x80, + 0x83, 0x80, 0x83, 0x8f, 0x0, 0x0, 0x87, 0x91, 0x0, 0x8f, 0x80, 0x83, 0x80, 0x83, 0x0, 0x83}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[27]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 27, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7392); + EXPECT_EQ(count, 27); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); +} + +// UnsubscribeResponse 18418 [PropPayloadFormatIndicator 73,PropSubscriptionIdentifier 27,PropMessageExpiryInterval +// 17696,PropPayloadFormatIndicator 158,PropRequestProblemInformation 251] +// [UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubSuccess,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode25) { + uint8_t pkt[] = {0xb0, 0x23, 0x47, 0xf2, 0xd, 0x1, 0x49, 0xb, 0x1b, 0x2, 0x0, 0x0, 0x45, + 0x20, 0x1, 0x9e, 0x17, 0xfb, 0x11, 0x87, 0x83, 0x91, 0x11, 0x8f, 0x80, 0x87, + 0x8f, 0x8f, 0x87, 0x80, 0x83, 0x8f, 0x11, 0x80, 0x80, 0x0, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[19]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 19, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 18418); + EXPECT_EQ(count, 19); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_SUCCESS); +} + +// UnsubscribeResponse 9706 [PropMaximumQoS 251,PropServerKeepAlive 26315,PropSharedSubscriptionAvailable +// 253,PropTopicAliasMaximum 9589,PropResponseInformation "*",PropUserProperty +// "\170\252A\186\171\246)\178\217\236\136\250x\153T\NAK\211W\CAN\214\ACK\208\132\164\&3\175." +// "6\192\t\182\242\160\FSJN",PropServerKeepAlive 1102,PropMaximumPacketSize 12716,PropWildcardSubscriptionAvailable +// 93,PropRequestResponseInformation 111,PropTopicAliasMaximum 7469,PropServerReference +// "}\189Q\204\235\166\&5",PropResponseTopic "\236\DC3\DLE\158Ri\185\176\NUL\136d\139` +// p\171\ENQ",PropSubscriptionIdentifierAvailable 133] +// [UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubSuccess,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubSuccess,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubSuccess,UnsubUnspecifiedError,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode26) { + uint8_t pkt[] = {0xb0, 0x80, 0x1, 0x25, 0xea, 0x66, 0x24, 0xfb, 0x13, 0x66, 0xcb, 0x2a, 0xfd, 0x22, 0x25, 0x75, 0x1a, + 0x0, 0x1, 0x2a, 0x26, 0x0, 0x1b, 0xaa, 0xfc, 0x41, 0xba, 0xab, 0xf6, 0x29, 0xb2, 0xd9, 0xec, 0x88, + 0xfa, 0x78, 0x99, 0x54, 0x15, 0xd3, 0x57, 0x18, 0xd6, 0x6, 0xd0, 0x84, 0xa4, 0x33, 0xaf, 0x2e, 0x0, + 0x9, 0x36, 0xc0, 0x9, 0xb6, 0xf2, 0xa0, 0x1c, 0x4a, 0x4e, 0x13, 0x4, 0x4e, 0x27, 0x0, 0x0, 0x31, + 0xac, 0x28, 0x5d, 0x19, 0x6f, 0x22, 0x1d, 0x2d, 0x1c, 0x0, 0x7, 0x7d, 0xbd, 0x51, 0xcc, 0xeb, 0xa6, + 0x35, 0x8, 0x0, 0x11, 0xec, 0x13, 0x10, 0x9e, 0x52, 0x69, 0xb9, 0xb0, 0x0, 0x88, 0x64, 0x8b, 0x60, + 0x20, 0x70, 0xab, 0x5, 0x29, 0x85, 0x80, 0x8f, 0x83, 0x8f, 0x83, 0x0, 0x8f, 0x83, 0x91, 0x80, 0x83, + 0x8f, 0x87, 0x0, 0x83, 0x87, 0x11, 0x80, 0x8f, 0x87, 0x0, 0x80, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[23]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 23, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 9706); + EXPECT_EQ(count, 23); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_SUCCESS); +} + +// UnsubscribeResponse 5357 [PropServerReference "\206\234\191\NAK: X\146\171\"\144\186M\137\&4\177",PropServerReference +// "\169\149\216\&6\137\215a\221!\132\DC4\240\CAN\DC2\150\138\183\133\169\170\170\218\GS\n\RS\178t\165",PropResponseInformation +// "\220\\@\247\235\229\202\154q\165?",PropCorrelationData +// "5\255\155\163o\236\228\203\143\252\178\&9\129\DC2\172\&1",PropMaximumQoS 160,PropAssignedClientIdentifier +// ":'\n\158{\194\135",PropSubscriptionIdentifierAvailable 169,PropServerReference +// "j\148\240\DEL*\ACK\240\189\219]p<\STX\ETXk2-XJ\145\&1\245",PropCorrelationData +// "B\FS\249\247\176\STXS\250\155:%\DC2\\\t\252_\161",PropServerKeepAlive 9127] +// [UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized,UnsubSuccess,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubTopicFilterInvalid] +TEST(UnsubACK5QCTest, Decode27) { + uint8_t pkt[] = {0xb0, 0xb1, 0x1, 0x14, 0xed, 0x91, 0x1, 0x1c, 0x0, 0x10, 0xce, 0xea, 0xbf, 0x15, 0x3a, 0x20, 0x58, + 0x92, 0xab, 0x22, 0x90, 0xba, 0x4d, 0x89, 0x34, 0xb1, 0x1c, 0x0, 0x1c, 0xa9, 0x95, 0xd8, 0x36, 0x89, + 0xd7, 0x61, 0xdd, 0x21, 0x84, 0x14, 0xf0, 0x18, 0x12, 0x96, 0x8a, 0xb7, 0x85, 0xa9, 0xaa, 0xaa, 0xda, + 0x1d, 0xa, 0x1e, 0xb2, 0x74, 0xa5, 0x1a, 0x0, 0xb, 0xdc, 0x5c, 0x40, 0xf7, 0xeb, 0xe5, 0xca, 0x9a, + 0x71, 0xa5, 0x3f, 0x9, 0x0, 0x10, 0x35, 0xff, 0x9b, 0xa3, 0x6f, 0xec, 0xe4, 0xcb, 0x8f, 0xfc, 0xb2, + 0x39, 0x81, 0x12, 0xac, 0x31, 0x24, 0xa0, 0x12, 0x0, 0x7, 0x3a, 0x27, 0xa, 0x9e, 0x7b, 0xc2, 0x87, + 0x29, 0xa9, 0x1c, 0x0, 0x16, 0x6a, 0x94, 0xf0, 0x7f, 0x2a, 0x6, 0xf0, 0xbd, 0xdb, 0x5d, 0x70, 0x3c, + 0x2, 0x3, 0x6b, 0x32, 0x2d, 0x58, 0x4a, 0x91, 0x31, 0xf5, 0x9, 0x0, 0x11, 0x42, 0x1c, 0xf9, 0xf7, + 0xb0, 0x2, 0x53, 0xfa, 0x9b, 0x3a, 0x25, 0x12, 0x5c, 0x9, 0xfc, 0x5f, 0xa1, 0x13, 0x23, 0xa7, 0x80, + 0x91, 0x83, 0x87, 0x91, 0x80, 0x91, 0x87, 0x0, 0x91, 0x11, 0x83, 0x11, 0x87, 0x83, 0x80, 0x91, 0x0, + 0x87, 0x0, 0x0, 0x91, 0x91, 0x80, 0x80, 0x91, 0x87, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[28]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 28, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 5357); + EXPECT_EQ(count, 28); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[27], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); +} + +// UnsubscribeResponse 25609 [PropMessageExpiryInterval 9067,PropResponseTopic "{\128r\NAK\243",PropContentType +// "\188{7\DC1",PropSubscriptionIdentifierAvailable 61,PropTopicAlias 16945,PropSubscriptionIdentifierAvailable +// 187,PropSharedSubscriptionAvailable 206,PropCorrelationData +// "\233//V\237q\181\252\175\v\228\148T-\148,\177\195\198\129\214",PropAuthenticationMethod "\180n\210j",PropMaximumQoS +// 221,PropSubscriptionIdentifierAvailable 160,PropSubscriptionIdentifier 30,PropCorrelationData +// "m\231x\175M^\208\130\203\253\152\204\186\227\161\204\"\218Ybp9z",PropMessageExpiryInterval 1351,PropResponseTopic +// "L\158\139\DC4#J\165\136k\SUB\129\&7t\227o",PropMessageExpiryInterval 6136,PropReceiveMaximum +// 26201,PropServerReference "\252\176\201>2Q\184H\140\231L\b\163B\221",PropRequestProblemInformation 95,PropContentType +// "\254h\216\EM\140=.\213\168\DC3\245\232V\201'{",PropServerKeepAlive 21516,PropMaximumQoS 182,PropMaximumQoS +// 194,PropMessageExpiryInterval 26010,PropServerReference +// "\rI\194\189\CAN\161\170\&8\161;\189(\139K\216/",PropServerKeepAlive 30668,PropCorrelationData +// "l\246h\220\220\&4k\176\173=\SYN\227\193@a\196\207\ACK\ACK\245\226",PropResponseInformation +// "Z\225\245w",PropTopicAlias 5475] +// [UnsubSuccess,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubSuccess,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNotAuthorized,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode28) { + uint8_t pkt[] = { + 0xb0, 0x86, 0x2, 0x64, 0x9, 0xe6, 0x1, 0x2, 0x0, 0x0, 0x23, 0x6b, 0x8, 0x0, 0x5, 0x7b, 0x80, 0x72, 0x15, + 0xf3, 0x3, 0x0, 0x4, 0xbc, 0x7b, 0x37, 0x11, 0x29, 0x3d, 0x23, 0x42, 0x31, 0x29, 0xbb, 0x2a, 0xce, 0x9, 0x0, + 0x15, 0xe9, 0x2f, 0x2f, 0x56, 0xed, 0x71, 0xb5, 0xfc, 0xaf, 0xb, 0xe4, 0x94, 0x54, 0x2d, 0x94, 0x2c, 0xb1, 0xc3, + 0xc6, 0x81, 0xd6, 0x15, 0x0, 0x4, 0xb4, 0x6e, 0xd2, 0x6a, 0x24, 0xdd, 0x29, 0xa0, 0xb, 0x1e, 0x9, 0x0, 0x17, + 0x6d, 0xe7, 0x78, 0xaf, 0x4d, 0x5e, 0xd0, 0x82, 0xcb, 0xfd, 0x98, 0xcc, 0xba, 0xe3, 0xa1, 0xcc, 0x22, 0xda, 0x59, + 0x62, 0x70, 0x39, 0x7a, 0x2, 0x0, 0x0, 0x5, 0x47, 0x8, 0x0, 0xf, 0x4c, 0x9e, 0x8b, 0x14, 0x23, 0x4a, 0xa5, + 0x88, 0x6b, 0x1a, 0x81, 0x37, 0x74, 0xe3, 0x6f, 0x2, 0x0, 0x0, 0x17, 0xf8, 0x21, 0x66, 0x59, 0x1c, 0x0, 0xf, + 0xfc, 0xb0, 0xc9, 0x3e, 0x32, 0x51, 0xb8, 0x48, 0x8c, 0xe7, 0x4c, 0x8, 0xa3, 0x42, 0xdd, 0x17, 0x5f, 0x3, 0x0, + 0x10, 0xfe, 0x68, 0xd8, 0x19, 0x8c, 0x3d, 0x2e, 0xd5, 0xa8, 0x13, 0xf5, 0xe8, 0x56, 0xc9, 0x27, 0x7b, 0x13, 0x54, + 0xc, 0x24, 0xb6, 0x24, 0xc2, 0x2, 0x0, 0x0, 0x65, 0x9a, 0x1c, 0x0, 0x10, 0xd, 0x49, 0xc2, 0xbd, 0x18, 0xa1, + 0xaa, 0x38, 0xa1, 0x3b, 0xbd, 0x28, 0x8b, 0x4b, 0xd8, 0x2f, 0x13, 0x77, 0xcc, 0x9, 0x0, 0x15, 0x6c, 0xf6, 0x68, + 0xdc, 0xdc, 0x34, 0x6b, 0xb0, 0xad, 0x3d, 0x16, 0xe3, 0xc1, 0x40, 0x61, 0xc4, 0xcf, 0x6, 0x6, 0xf5, 0xe2, 0x1a, + 0x0, 0x4, 0x5a, 0xe1, 0xf5, 0x77, 0x23, 0x15, 0x63, 0x0, 0x83, 0x87, 0x83, 0x87, 0x83, 0x11, 0x83, 0x8f, 0x87, + 0x8f, 0x0, 0x8f, 0x91, 0x91, 0x80, 0x11, 0x87, 0x87, 0x0, 0x91, 0x83, 0x80, 0x83, 0x8f, 0x8f, 0x11, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[28]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 28, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 25609); + EXPECT_EQ(count, 28); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[27], LWMQTT_UNSUB_SUCCESS); +} + +// UnsubscribeResponse 8043 [PropSubscriptionIdentifier 25,PropContentType +// "\161\&9M\177\b\244KwX\199\205\251P\178\179\232\211\RS\168o1\DLE\ESCB(\\\225\184\146m",PropUserProperty +// "\b\DC4\f&\SYN\228N\DLE3\DLE\160z\DC2f\170\146v" +// "\SO\145\232\139v\159\204\232\154\180\&1}#\r\ENQ\209",PropPayloadFormatIndicator +// 28,PropSubscriptionIdentifierAvailable 64,PropAssignedClientIdentifier "\186\208\242Ce\210\207x\206"] +// [UnsubUnspecifiedError,UnsubSuccess,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubSuccess,UnsubUnspecifiedError] +TEST(UnsubACK5QCTest, Decode29) { + uint8_t pkt[] = {0xb0, 0x6e, 0x1f, 0x6b, 0x59, 0xb, 0x19, 0x3, 0x0, 0x1e, 0xa1, 0x39, 0x4d, 0xb1, 0x8, 0xf4, + 0x4b, 0x77, 0x58, 0xc7, 0xcd, 0xfb, 0x50, 0xb2, 0xb3, 0xe8, 0xd3, 0x1e, 0xa8, 0x6f, 0x31, 0x10, + 0x1b, 0x42, 0x28, 0x5c, 0xe1, 0xb8, 0x92, 0x6d, 0x26, 0x0, 0x11, 0x8, 0x14, 0xc, 0x26, 0x16, + 0xe4, 0x4e, 0x10, 0x33, 0x10, 0xa0, 0x7a, 0x12, 0x66, 0xaa, 0x92, 0x76, 0x0, 0x10, 0xe, 0x91, + 0xe8, 0x8b, 0x76, 0x9f, 0xcc, 0xe8, 0x9a, 0xb4, 0x31, 0x7d, 0x23, 0xd, 0x5, 0xd1, 0x1, 0x1c, + 0x29, 0x40, 0x12, 0x0, 0x9, 0xba, 0xd0, 0xf2, 0x43, 0x65, 0xd2, 0xcf, 0x78, 0xce, 0x80, 0x0, + 0x87, 0x8f, 0x91, 0x87, 0x0, 0x11, 0x0, 0x80, 0x87, 0x87, 0x80, 0x8f, 0x8f, 0x83, 0x0, 0x80}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[18]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 18, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 8043); + EXPECT_EQ(count, 18); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_UNSPECIFIED_ERROR); +} + +// UnsubscribeResponse 7204 [PropMaximumPacketSize 20642] +// [UnsubSuccess,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNotAuthorized] +TEST(UnsubACK5QCTest, Decode30) { + uint8_t pkt[] = {0xb0, 0x1a, 0x1c, 0x24, 0x5, 0x27, 0x0, 0x0, 0x50, 0xa2, 0x0, 0x80, 0x11, 0x91, + 0x8f, 0x11, 0x91, 0x80, 0x83, 0x87, 0x11, 0x91, 0x8f, 0x8f, 0x83, 0x8f, 0x0, 0x87}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[18]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 18, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7204); + EXPECT_EQ(count, 18); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NOT_AUTHORIZED); } // DisconnectRequest DiscoNormalDisconnection [] @@ -21850,1072 +22955,980 @@ TEST(Disco311QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoServerMoved [PropAssignedClientIdentifier -// "\136h8s\245\148b\RS\211\129\135\138\SI\212\142\187\155\217:\220.\149f\FS\159[/\147\136\t",PropServerReference -// "\245\214\DC2q\254\171\SO\195\152\EOT\208\224z\236\SI\212lK^\253\211\208\170",PropReasonString -// "95Z\190\237\166\190Xy\187\196\170",PropServerReference -// "\133\177\221n\140\&1\239\157\ACK\148\ACK\136^\SOH\142C",PropResponseTopic -// "2&\ETX\151\DC1'\234\210Jve\168!z\181\\<\a\158\&8\SO",PropReceiveMaximum 20949,PropRetainAvailable -// 231,PropCorrelationData -// "y\GS\142\249\DC48P.\n\164'\138\DC1D.'\210{\STX\158\251KM\243\234\165",PropSubscriptionIdentifierAvailable -// 187,PropMessageExpiryInterval 19805,PropTopicAlias 27535,PropMessageExpiryInterval 23453,PropMessageExpiryInterval -// 9517,PropServerReference "\148$`\177",PropContentType "\214A",PropReasonString "\184H\169",PropPayloadFormatIndicator -// 104,PropMessageExpiryInterval 14956,PropSessionExpiryInterval 15208,PropWildcardSubscriptionAvailable -// 53,PropMaximumQoS 237,PropTopicAlias 7810,PropSessionExpiryInterval 3612,PropMaximumPacketSize -// 28521,PropResponseInformation "\188C|\137W\183\t\ENQ\155\&81\172^b\SUB\165\155&\SO\227"] +// DisconnectRequest DiscoMaximumConnectTime [PropReasonString "\191\242\214\230?\v",PropResponseInformation +// "\227]\205*mi\179\ENQ\196\227",PropMaximumPacketSize 18477,PropPayloadFormatIndicator 55,PropResponseInformation +// "\f\217\229)@Ys\156\135\174}\129!\243\129\ETB\219\172a|\168\v\143",PropAuthenticationMethod +// "\fd\152L0q\214OSP\224\DEL 7\227\182\219\186",PropResponseInformation "",PropMaximumPacketSize +// 13687,PropWildcardSubscriptionAvailable 118,PropPayloadFormatIndicator 51,PropReasonString "",PropCorrelationData +// "u(\184\161}\139\227E\ENQ\249\&8\183\139\240\181\206\223/\172h\128\&7\160\254\178\162\250\147\179\226",PropWildcardSubscriptionAvailable +// 108,PropMessageExpiryInterval 17592,PropRequestResponseInformation 153,PropSessionExpiryInterval +// 23985,PropTopicAliasMaximum 16607,PropSubscriptionIdentifierAvailable 88,PropSessionExpiryInterval +// 11289,PropAuthenticationMethod "\134#\163\160R2\132\&5\176\&4\250\129\192Z\225\143+",PropContentType +// "\200\224",PropAssignedClientIdentifier +// "\204\132\143\226|\135~\240\171T\188\241-P\147\219`\235\178\vi\225\142",PropMaximumPacketSize +// 25765,PropSubscriptionIdentifierAvailable 116,PropResponseInformation +// "\160\154\248\199,\190\ETXZ\SUB&SM\240(\220\244Q\129:\SUB",PropTopicAliasMaximum 588,PropMessageExpiryInterval +// 9192,PropReasonString "\189\183\178\156\DC4\DEL\196w\208\154c\231\a"] TEST(Disco5QCTest, Encode1) { uint8_t pkt[] = { -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0x0, 0x2, 0xd6, 0x41, 0x1f, - 0x0, 0x3, 0xb8, 0x48, 0xa9, 0x1, 0x68, 0x2, 0x0, 0x0, 0x3a, 0x6c, 0x11, 0x0, 0x0, 0x3b, 0x68, 0x28, 0x35, - 0x24, 0xed, 0x23, 0x1e, 0x82, 0x11, 0x0, 0x0, 0xe, 0x1c, 0x27, 0x0, 0x0, 0x6f, 0x69, 0x1a, 0x0, 0x14, 0xbc, - 0x43, 0x7c, 0x89, 0x57, 0xb7, 0x9, 0x5, 0x9b, 0x38, 0x31, 0xac, 0x5e, 0x62, 0x1a, 0xa5, 0x9b, 0x26, 0xe, 0xe3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x88, 0x68, 0x38, 0x73, 0xf5, 0x94, 0x62, 0x1e, 0xd3, 0x81, 0x87, 0x8a, 0xf, 0xd4, 0x8e, - 0xbb, 0x9b, 0xd9, 0x3a, 0xdc, 0x2e, 0x95, 0x66, 0x1c, 0x9f, 0x5b, 0x2f, 0x93, 0x88, 0x9}; - uint8_t bytesprops1[] = {0xf5, 0xd6, 0x12, 0x71, 0xfe, 0xab, 0xe, 0xc3, 0x98, 0x4, 0xd0, 0xe0, - 0x7a, 0xec, 0xf, 0xd4, 0x6c, 0x4b, 0x5e, 0xfd, 0xd3, 0xd0, 0xaa}; - uint8_t bytesprops2[] = {0x39, 0x35, 0x5a, 0xbe, 0xed, 0xa6, 0xbe, 0x58, 0x79, 0xbb, 0xc4, 0xaa}; - uint8_t bytesprops3[] = {0x85, 0xb1, 0xdd, 0x6e, 0x8c, 0x31, 0xef, 0x9d, 0x6, 0x94, 0x6, 0x88, 0x5e, 0x1, 0x8e, 0x43}; - uint8_t bytesprops4[] = {0x32, 0x26, 0x3, 0x97, 0x11, 0x27, 0xea, 0xd2, 0x4a, 0x76, 0x65, - 0xa8, 0x21, 0x7a, 0xb5, 0x5c, 0x3c, 0x7, 0x9e, 0x38, 0xe}; - uint8_t bytesprops5[] = {0x79, 0x1d, 0x8e, 0xf9, 0x14, 0x38, 0x50, 0x2e, 0xa, 0xa4, 0x27, 0x8a, 0x11, - 0x44, 0x2e, 0x27, 0xd2, 0x7b, 0x2, 0x9e, 0xfb, 0x4b, 0x4d, 0xf3, 0xea, 0xa5}; - uint8_t bytesprops6[] = {0x94, 0x24, 0x60, 0xb1}; - uint8_t bytesprops7[] = {0xd6, 0x41}; - uint8_t bytesprops8[] = {0xb8, 0x48, 0xa9}; - uint8_t bytesprops9[] = {0xbc, 0x43, 0x7c, 0x89, 0x57, 0xb7, 0x9, 0x5, 0x9b, 0x38, - 0x31, 0xac, 0x5e, 0x62, 0x1a, 0xa5, 0x9b, 0x26, 0xe, 0xe3}; + 0xe0, 0x80, 0x2, 0xa0, 0xfd, 0x1, 0x1f, 0x0, 0x6, 0xbf, 0xf2, 0xd6, 0xe6, 0x3f, 0xb, 0x1a, 0x0, 0xa, 0xe3, + 0x5d, 0xcd, 0x2a, 0x6d, 0x69, 0xb3, 0x5, 0xc4, 0xe3, 0x27, 0x0, 0x0, 0x48, 0x2d, 0x1, 0x37, 0x1a, 0x0, 0x17, + 0xc, 0xd9, 0xe5, 0x29, 0x40, 0x59, 0x73, 0x9c, 0x87, 0xae, 0x7d, 0x81, 0x21, 0xf3, 0x81, 0x17, 0xdb, 0xac, 0x61, + 0x7c, 0xa8, 0xb, 0x8f, 0x15, 0x0, 0x12, 0xc, 0x64, 0x98, 0x4c, 0x30, 0x71, 0xd6, 0x4f, 0x53, 0x50, 0xe0, 0x7f, + 0x20, 0x37, 0xe3, 0xb6, 0xdb, 0xba, 0x1a, 0x0, 0x0, 0x27, 0x0, 0x0, 0x35, 0x77, 0x28, 0x76, 0x1, 0x33, 0x1f, + 0x0, 0x0, 0x9, 0x0, 0x1e, 0x75, 0x28, 0xb8, 0xa1, 0x7d, 0x8b, 0xe3, 0x45, 0x5, 0xf9, 0x38, 0xb7, 0x8b, 0xf0, + 0xb5, 0xce, 0xdf, 0x2f, 0xac, 0x68, 0x80, 0x37, 0xa0, 0xfe, 0xb2, 0xa2, 0xfa, 0x93, 0xb3, 0xe2, 0x28, 0x6c, 0x2, + 0x0, 0x0, 0x44, 0xb8, 0x19, 0x99, 0x11, 0x0, 0x0, 0x5d, 0xb1, 0x22, 0x40, 0xdf, 0x29, 0x58, 0x11, 0x0, 0x0, + 0x2c, 0x19, 0x15, 0x0, 0x11, 0x86, 0x23, 0xa3, 0xa0, 0x52, 0x32, 0x84, 0x35, 0xb0, 0x34, 0xfa, 0x81, 0xc0, 0x5a, + 0xe1, 0x8f, 0x2b, 0x3, 0x0, 0x2, 0xc8, 0xe0, 0x12, 0x0, 0x17, 0xcc, 0x84, 0x8f, 0xe2, 0x7c, 0x87, 0x7e, 0xf0, + 0xab, 0x54, 0xbc, 0xf1, 0x2d, 0x50, 0x93, 0xdb, 0x60, 0xeb, 0xb2, 0xb, 0x69, 0xe1, 0x8e, 0x27, 0x0, 0x0, 0x64, + 0xa5, 0x29, 0x74, 0x1a, 0x0, 0x14, 0xa0, 0x9a, 0xf8, 0xc7, 0x2c, 0xbe, 0x3, 0x5a, 0x1a, 0x26, 0x53, 0x4d, 0xf0, + 0x28, 0xdc, 0xf4, 0x51, 0x81, 0x3a, 0x1a, 0x22, 0x2, 0x4c, 0x2, 0x0, 0x0, 0x23, 0xe8, 0x1f, 0x0, 0xd, 0xbd, + 0xb7, 0xb2, 0x9c, 0x14, 0x7f, 0xc4, 0x77, 0xd0, 0x9a, 0x63, 0xe7, 0x7}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbf, 0xf2, 0xd6, 0xe6, 0x3f, 0xb}; + uint8_t bytesprops1[] = {0xe3, 0x5d, 0xcd, 0x2a, 0x6d, 0x69, 0xb3, 0x5, 0xc4, 0xe3}; + uint8_t bytesprops2[] = {0xc, 0xd9, 0xe5, 0x29, 0x40, 0x59, 0x73, 0x9c, 0x87, 0xae, 0x7d, 0x81, + 0x21, 0xf3, 0x81, 0x17, 0xdb, 0xac, 0x61, 0x7c, 0xa8, 0xb, 0x8f}; + uint8_t bytesprops3[] = {0xc, 0x64, 0x98, 0x4c, 0x30, 0x71, 0xd6, 0x4f, 0x53, + 0x50, 0xe0, 0x7f, 0x20, 0x37, 0xe3, 0xb6, 0xdb, 0xba}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0}; + uint8_t bytesprops6[] = {0x75, 0x28, 0xb8, 0xa1, 0x7d, 0x8b, 0xe3, 0x45, 0x5, 0xf9, 0x38, 0xb7, 0x8b, 0xf0, 0xb5, + 0xce, 0xdf, 0x2f, 0xac, 0x68, 0x80, 0x37, 0xa0, 0xfe, 0xb2, 0xa2, 0xfa, 0x93, 0xb3, 0xe2}; + uint8_t bytesprops7[] = {0x86, 0x23, 0xa3, 0xa0, 0x52, 0x32, 0x84, 0x35, 0xb0, + 0x34, 0xfa, 0x81, 0xc0, 0x5a, 0xe1, 0x8f, 0x2b}; + uint8_t bytesprops8[] = {0xc8, 0xe0}; + uint8_t bytesprops9[] = {0xcc, 0x84, 0x8f, 0xe2, 0x7c, 0x87, 0x7e, 0xf0, 0xab, 0x54, 0xbc, 0xf1, + 0x2d, 0x50, 0x93, 0xdb, 0x60, 0xeb, 0xb2, 0xb, 0x69, 0xe1, 0x8e}; + uint8_t bytesprops10[] = {0xa0, 0x9a, 0xf8, 0xc7, 0x2c, 0xbe, 0x3, 0x5a, 0x1a, 0x26, + 0x53, 0x4d, 0xf0, 0x28, 0xdc, 0xf4, 0x51, 0x81, 0x3a, 0x1a}; + uint8_t bytesprops11[] = {0xbd, 0xb7, 0xb2, 0x9c, 0x14, 0x7f, 0xc4, 0x77, 0xd0, 0x9a, 0x63, 0xe7, 0x7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20949}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19805}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27535}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23453}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9517}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14956}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15208}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7810}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3612}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28521}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18477}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13687}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17592}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23985}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16607}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11289}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25765}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 588}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9192}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 157, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 160, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoNotAuthorized [PropReceiveMaximum 2365,PropAuthenticationMethod -// "9\185\198@\189q\ESC\180\156Z\147\151y\248\231\152\139k7\131\182\219\210#\130\252\ENQ"] +// DisconnectRequest DiscoImplementationSpecificError [PropSessionExpiryInterval 15056,PropSharedSubscriptionAvailable +// 72,PropResponseTopic "\129\DC3E",PropTopicAlias 16377,PropResponseInformation +// "\162\159C1O\159\168\197\NAK\157\179",PropSharedSubscriptionAvailable 106,PropMaximumQoS 44,PropTopicAlias +// 9466,PropRequestProblemInformation 78,PropRequestResponseInformation 138,PropSessionExpiryInterval +// 29538,PropRetainAvailable 222] TEST(Disco5QCTest, Encode2) { - uint8_t pkt[] = {0xe0, 0x23, 0x87, 0x21, 0x21, 0x9, 0x3d, 0x15, 0x0, 0x1b, 0x39, 0xb9, 0xc6, - 0x40, 0xbd, 0x71, 0x1b, 0xb4, 0x9c, 0x5a, 0x93, 0x97, 0x79, 0xf8, 0xe7, 0x98, - 0x8b, 0x6b, 0x37, 0x83, 0xb6, 0xdb, 0xd2, 0x23, 0x82, 0xfc, 0x5}; + uint8_t pkt[] = {0xe0, 0x32, 0x83, 0x30, 0x11, 0x0, 0x0, 0x3a, 0xd0, 0x2a, 0x48, 0x8, 0x0, + 0x3, 0x81, 0x13, 0x45, 0x23, 0x3f, 0xf9, 0x1a, 0x0, 0xb, 0xa2, 0x9f, 0x43, + 0x31, 0x4f, 0x9f, 0xa8, 0xc5, 0x15, 0x9d, 0xb3, 0x2a, 0x6a, 0x24, 0x2c, 0x23, + 0x24, 0xfa, 0x17, 0x4e, 0x19, 0x8a, 0x11, 0x0, 0x0, 0x73, 0x62, 0x25, 0xde}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x39, 0xb9, 0xc6, 0x40, 0xbd, 0x71, 0x1b, 0xb4, 0x9c, 0x5a, 0x93, 0x97, 0x79, 0xf8, - 0xe7, 0x98, 0x8b, 0x6b, 0x37, 0x83, 0xb6, 0xdb, 0xd2, 0x23, 0x82, 0xfc, 0x5}; + uint8_t bytesprops0[] = {0x81, 0x13, 0x45}; + uint8_t bytesprops1[] = {0xa2, 0x9f, 0x43, 0x31, 0x4f, 0x9f, 0xa8, 0xc5, 0x15, 0x9d, 0xb3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2365}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15056}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16377}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9466}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29538}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 222}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 135, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 131, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoQuotaExceeded [PropTopicAliasMaximum 15799,PropTopicAlias 2831,PropResponseInformation -// "\STX\163Q\131",PropSubscriptionIdentifierAvailable 184,PropAuthenticationMethod -// "\168\170\247\154\EM\145;\SO;\EM\166G\190`\149s\224\240\DELh\203@H\US-b\150",PropReasonString -// "\250\137;4\193\169\tvr_Q8\EOT\253\&4\214\189/\153!\DLE\DC4\135\207Fa\205b",PropPayloadFormatIndicator -// 155,PropWillDelayInterval 27802,PropMessageExpiryInterval 31388,PropResponseTopic -// "\128\165\224V<\"4-\133\a\161\253!\156\134X&\DC4,I.\180",PropAuthenticationData "Lp\145\249m{|\216\132Z\190\SOH\156"] +// DisconnectRequest DiscoUnspecifiedError [PropTopicAlias 13294,PropReasonString +// "\180\NAK\228\238h0\185s\254\DC1\136|-p\137]\137V\202\ACK6\SUB",PropServerKeepAlive 6998,PropSubscriptionIdentifier +// 2,PropWildcardSubscriptionAvailable 103,PropRequestResponseInformation 135,PropTopicAlias +// 22266,PropSubscriptionIdentifier 23,PropAuthenticationMethod "\140v\220%",PropMaximumQoS 167,PropAuthenticationMethod +// "\215\188/^\198\ESC\SI\DLE\163\156|",PropPayloadFormatIndicator 40,PropRequestResponseInformation +// 128,PropPayloadFormatIndicator 230,PropResponseTopic "_\174n\DLE\213s +// g\159\187\202\STX\\U0%\vqa\190\192",PropSessionExpiryInterval 3575,PropRequestProblemInformation +// 70,PropCorrelationData "\161(0\170 \a\188\168",PropRequestResponseInformation 248,PropAuthenticationData +// "\r\217{\205-\242T\152z\DC2\173*F\153\145\141\128\236H\n\154\186\227\254\&7",PropMessageExpiryInterval +// 23847,PropRequestResponseInformation 58] TEST(Disco5QCTest, Encode3) { - uint8_t pkt[] = {0xe0, 0x84, 0x1, 0x97, 0x81, 0x1, 0x22, 0x3d, 0xb7, 0x23, 0xb, 0xf, 0x1a, 0x0, 0x4, 0x2, 0xa3, - 0x51, 0x83, 0x29, 0xb8, 0x15, 0x0, 0x1b, 0xa8, 0xaa, 0xf7, 0x9a, 0x19, 0x91, 0x3b, 0xe, 0x3b, 0x19, - 0xa6, 0x47, 0xbe, 0x60, 0x95, 0x73, 0xe0, 0xf0, 0x7f, 0x68, 0xcb, 0x40, 0x48, 0x1f, 0x2d, 0x62, 0x96, - 0x1f, 0x0, 0x1c, 0xfa, 0x89, 0x3b, 0x34, 0xc1, 0xa9, 0x9, 0x76, 0x72, 0x5f, 0x51, 0x38, 0x4, 0xfd, - 0x34, 0xd6, 0xbd, 0x2f, 0x99, 0x21, 0x10, 0x14, 0x87, 0xcf, 0x46, 0x61, 0xcd, 0x62, 0x1, 0x9b, 0x18, - 0x0, 0x0, 0x6c, 0x9a, 0x2, 0x0, 0x0, 0x7a, 0x9c, 0x8, 0x0, 0x16, 0x80, 0xa5, 0xe0, 0x56, 0x3c, - 0x22, 0x34, 0x2d, 0x85, 0x7, 0xa1, 0xfd, 0x21, 0x9c, 0x86, 0x58, 0x26, 0x14, 0x2c, 0x49, 0x2e, 0xb4, - 0x16, 0x0, 0xd, 0x4c, 0x70, 0x91, 0xf9, 0x6d, 0x7b, 0x7c, 0xd8, 0x84, 0x5a, 0xbe, 0x1, 0x9c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x2, 0xa3, 0x51, 0x83}; - uint8_t bytesprops1[] = {0xa8, 0xaa, 0xf7, 0x9a, 0x19, 0x91, 0x3b, 0xe, 0x3b, 0x19, 0xa6, 0x47, 0xbe, 0x60, - 0x95, 0x73, 0xe0, 0xf0, 0x7f, 0x68, 0xcb, 0x40, 0x48, 0x1f, 0x2d, 0x62, 0x96}; - uint8_t bytesprops2[] = {0xfa, 0x89, 0x3b, 0x34, 0xc1, 0xa9, 0x9, 0x76, 0x72, 0x5f, 0x51, 0x38, 0x4, 0xfd, - 0x34, 0xd6, 0xbd, 0x2f, 0x99, 0x21, 0x10, 0x14, 0x87, 0xcf, 0x46, 0x61, 0xcd, 0x62}; - uint8_t bytesprops3[] = {0x80, 0xa5, 0xe0, 0x56, 0x3c, 0x22, 0x34, 0x2d, 0x85, 0x7, 0xa1, - 0xfd, 0x21, 0x9c, 0x86, 0x58, 0x26, 0x14, 0x2c, 0x49, 0x2e, 0xb4}; - uint8_t bytesprops4[] = {0x4c, 0x70, 0x91, 0xf9, 0x6d, 0x7b, 0x7c, 0xd8, 0x84, 0x5a, 0xbe, 0x1, 0x9c}; + uint8_t pkt[] = {0xe0, 0x99, 0x1, 0x80, 0x96, 0x1, 0x23, 0x33, 0xee, 0x1f, 0x0, 0x16, 0xb4, 0x15, 0xe4, 0xee, + 0x68, 0x30, 0xb9, 0x73, 0xfe, 0x11, 0x88, 0x7c, 0x2d, 0x70, 0x89, 0x5d, 0x89, 0x56, 0xca, 0x6, + 0x36, 0x1a, 0x13, 0x1b, 0x56, 0xb, 0x2, 0x28, 0x67, 0x19, 0x87, 0x23, 0x56, 0xfa, 0xb, 0x17, + 0x15, 0x0, 0x4, 0x8c, 0x76, 0xdc, 0x25, 0x24, 0xa7, 0x15, 0x0, 0xb, 0xd7, 0xbc, 0x2f, 0x5e, + 0xc6, 0x1b, 0xf, 0x10, 0xa3, 0x9c, 0x7c, 0x1, 0x28, 0x19, 0x80, 0x1, 0xe6, 0x8, 0x0, 0x15, + 0x5f, 0xae, 0x6e, 0x10, 0xd5, 0x73, 0x20, 0x67, 0x9f, 0xbb, 0xca, 0x2, 0x5c, 0x55, 0x30, 0x25, + 0xb, 0x71, 0x61, 0xbe, 0xc0, 0x11, 0x0, 0x0, 0xd, 0xf7, 0x17, 0x46, 0x9, 0x0, 0x8, 0xa1, + 0x28, 0x30, 0xaa, 0x20, 0x7, 0xbc, 0xa8, 0x19, 0xf8, 0x16, 0x0, 0x19, 0xd, 0xd9, 0x7b, 0xcd, + 0x2d, 0xf2, 0x54, 0x98, 0x7a, 0x12, 0xad, 0x2a, 0x46, 0x99, 0x91, 0x8d, 0x80, 0xec, 0x48, 0xa, + 0x9a, 0xba, 0xe3, 0xfe, 0x37, 0x2, 0x0, 0x0, 0x5d, 0x27, 0x19, 0x3a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb4, 0x15, 0xe4, 0xee, 0x68, 0x30, 0xb9, 0x73, 0xfe, 0x11, 0x88, + 0x7c, 0x2d, 0x70, 0x89, 0x5d, 0x89, 0x56, 0xca, 0x6, 0x36, 0x1a}; + uint8_t bytesprops1[] = {0x8c, 0x76, 0xdc, 0x25}; + uint8_t bytesprops2[] = {0xd7, 0xbc, 0x2f, 0x5e, 0xc6, 0x1b, 0xf, 0x10, 0xa3, 0x9c, 0x7c}; + uint8_t bytesprops3[] = {0x5f, 0xae, 0x6e, 0x10, 0xd5, 0x73, 0x20, 0x67, 0x9f, 0xbb, 0xca, + 0x2, 0x5c, 0x55, 0x30, 0x25, 0xb, 0x71, 0x61, 0xbe, 0xc0}; + uint8_t bytesprops4[] = {0xa1, 0x28, 0x30, 0xaa, 0x20, 0x7, 0xbc, 0xa8}; + uint8_t bytesprops5[] = {0xd, 0xd9, 0x7b, 0xcd, 0x2d, 0xf2, 0x54, 0x98, 0x7a, 0x12, 0xad, 0x2a, 0x46, + 0x99, 0x91, 0x8d, 0x80, 0xec, 0x48, 0xa, 0x9a, 0xba, 0xe3, 0xfe, 0x37}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15799}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2831}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27802}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31388}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13294}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6998}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22266}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3575}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23847}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 58}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 151, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 128, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoPayloadFormatInvalid [PropSubscriptionIdentifierAvailable 154,PropMaximumQoS -// 22,PropRetainAvailable 184,PropAuthenticationData -// "\182\209\149tT\EOTd%+Zf\152yw\206Y(m\160\147\\\FS\161\156",PropMessageExpiryInterval -// 16874,PropPayloadFormatIndicator 48,PropPayloadFormatIndicator 43,PropMaximumPacketSize -// 19500,PropMessageExpiryInterval 10936,PropResponseTopic "T\230\162",PropSessionExpiryInterval -// 7727,PropSharedSubscriptionAvailable 157,PropMaximumQoS 103,PropMaximumQoS 148,PropSubscriptionIdentifier -// 20,PropResponseInformation "\f\n\128",PropPayloadFormatIndicator 150,PropContentType -// "",PropRequestResponseInformation 67,PropResponseInformation "\162ECV\b%\FS\170\159\191M\140\151"] +// DisconnectRequest DiscoQuotaExceeded [PropRequestProblemInformation 118,PropUserProperty +// "`\145\189\145\220\130\179\213\162.'R`\153\218;\"K\214F5\245\218\204\200" +// "\150\207\255\&3s\167$*\235\ESC1",PropRetainAvailable 231,PropServerKeepAlive 22671,PropAuthenticationMethod +// "}>K:\143^\216\147\&3dt\212\SOHL",PropTopicAliasMaximum 28734,PropWillDelayInterval 19849,PropResponseTopic +// "\213\164\166B`\157\168\v\236\142~\255",PropUserProperty "1[L\181\174\152\186\STX\186X\175\140 \212\133<" +// "N\STX=\208",PropServerKeepAlive 5878,PropUserProperty +// "\181\210}X\ETB\201|\ETBP\243\NUL.9\233\215\DC3\RS\222\n\161\171" "\180*5\133L\247\237|]",PropMaximumQoS +// 98,PropCorrelationData "^\176\EMIG\188",PropResponseInformation +// "al\134|\237\250Q\157g\235jO\148\234\239`\201-\143oa\198\253|\155\221\&3\128\214^",PropMessageExpiryInterval +// 26521,PropUserProperty "\161\EMz\207u\DC2;\130\197A\ACKvf3o\178\228#K" +// "\214\163:\242\245\216\147y\253A\223\RSQAXx\DC1",PropMaximumPacketSize 17250] TEST(Disco5QCTest, Encode4) { - uint8_t pkt[] = {0xe0, 0x66, 0x99, 0x64, 0x29, 0x9a, 0x24, 0x16, 0x25, 0xb8, 0x16, 0x0, 0x18, 0xb6, 0xd1, - 0x95, 0x74, 0x54, 0x4, 0x64, 0x25, 0x2b, 0x5a, 0x66, 0x98, 0x79, 0x77, 0xce, 0x59, 0x28, - 0x6d, 0xa0, 0x93, 0x5c, 0x1c, 0xa1, 0x9c, 0x2, 0x0, 0x0, 0x41, 0xea, 0x1, 0x30, 0x1, - 0x2b, 0x27, 0x0, 0x0, 0x4c, 0x2c, 0x2, 0x0, 0x0, 0x2a, 0xb8, 0x8, 0x0, 0x3, 0x54, - 0xe6, 0xa2, 0x11, 0x0, 0x0, 0x1e, 0x2f, 0x2a, 0x9d, 0x24, 0x67, 0x24, 0x94, 0xb, 0x14, - 0x1a, 0x0, 0x3, 0xc, 0xa, 0x80, 0x1, 0x96, 0x3, 0x0, 0x0, 0x19, 0x43, 0x1a, 0x0, - 0xd, 0xa2, 0x45, 0x43, 0x56, 0x8, 0x25, 0x1c, 0xaa, 0x9f, 0xbf, 0x4d, 0x8c, 0x97}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb6, 0xd1, 0x95, 0x74, 0x54, 0x4, 0x64, 0x25, 0x2b, 0x5a, 0x66, 0x98, - 0x79, 0x77, 0xce, 0x59, 0x28, 0x6d, 0xa0, 0x93, 0x5c, 0x1c, 0xa1, 0x9c}; - uint8_t bytesprops1[] = {0x54, 0xe6, 0xa2}; - uint8_t bytesprops2[] = {0xc, 0xa, 0x80}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0xa2, 0x45, 0x43, 0x56, 0x8, 0x25, 0x1c, 0xaa, 0x9f, 0xbf, 0x4d, 0x8c, 0x97}; + uint8_t pkt[] = {0xe0, 0xf9, 0x1, 0x97, 0xf6, 0x1, 0x17, 0x76, 0x26, 0x0, 0x19, 0x60, 0x91, 0xbd, 0x91, 0xdc, 0x82, + 0xb3, 0xd5, 0xa2, 0x2e, 0x27, 0x52, 0x60, 0x99, 0xda, 0x3b, 0x22, 0x4b, 0xd6, 0x46, 0x35, 0xf5, 0xda, + 0xcc, 0xc8, 0x0, 0xb, 0x96, 0xcf, 0xff, 0x33, 0x73, 0xa7, 0x24, 0x2a, 0xeb, 0x1b, 0x31, 0x25, 0xe7, + 0x13, 0x58, 0x8f, 0x15, 0x0, 0xe, 0x7d, 0x3e, 0x4b, 0x3a, 0x8f, 0x5e, 0xd8, 0x93, 0x33, 0x64, 0x74, + 0xd4, 0x1, 0x4c, 0x22, 0x70, 0x3e, 0x18, 0x0, 0x0, 0x4d, 0x89, 0x8, 0x0, 0xc, 0xd5, 0xa4, 0xa6, + 0x42, 0x60, 0x9d, 0xa8, 0xb, 0xec, 0x8e, 0x7e, 0xff, 0x26, 0x0, 0x10, 0x31, 0x5b, 0x4c, 0xb5, 0xae, + 0x98, 0xba, 0x2, 0xba, 0x58, 0xaf, 0x8c, 0x20, 0xd4, 0x85, 0x3c, 0x0, 0x4, 0x4e, 0x2, 0x3d, 0xd0, + 0x13, 0x16, 0xf6, 0x26, 0x0, 0x15, 0xb5, 0xd2, 0x7d, 0x58, 0x17, 0xc9, 0x7c, 0x17, 0x50, 0xf3, 0x0, + 0x2e, 0x39, 0xe9, 0xd7, 0x13, 0x1e, 0xde, 0xa, 0xa1, 0xab, 0x0, 0x9, 0xb4, 0x2a, 0x35, 0x85, 0x4c, + 0xf7, 0xed, 0x7c, 0x5d, 0x24, 0x62, 0x9, 0x0, 0x6, 0x5e, 0xb0, 0x19, 0x49, 0x47, 0xbc, 0x1a, 0x0, + 0x1e, 0x61, 0x6c, 0x86, 0x7c, 0xed, 0xfa, 0x51, 0x9d, 0x67, 0xeb, 0x6a, 0x4f, 0x94, 0xea, 0xef, 0x60, + 0xc9, 0x2d, 0x8f, 0x6f, 0x61, 0xc6, 0xfd, 0x7c, 0x9b, 0xdd, 0x33, 0x80, 0xd6, 0x5e, 0x2, 0x0, 0x0, + 0x67, 0x99, 0x26, 0x0, 0x13, 0xa1, 0x19, 0x7a, 0xcf, 0x75, 0x12, 0x3b, 0x82, 0xc5, 0x41, 0x6, 0x76, + 0x66, 0x33, 0x6f, 0xb2, 0xe4, 0x23, 0x4b, 0x0, 0x11, 0xd6, 0xa3, 0x3a, 0xf2, 0xf5, 0xd8, 0x93, 0x79, + 0xfd, 0x41, 0xdf, 0x1e, 0x51, 0x41, 0x58, 0x78, 0x11, 0x27, 0x0, 0x0, 0x43, 0x62}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x96, 0xcf, 0xff, 0x33, 0x73, 0xa7, 0x24, 0x2a, 0xeb, 0x1b, 0x31}; + uint8_t bytesprops0[] = {0x60, 0x91, 0xbd, 0x91, 0xdc, 0x82, 0xb3, 0xd5, 0xa2, 0x2e, 0x27, 0x52, 0x60, + 0x99, 0xda, 0x3b, 0x22, 0x4b, 0xd6, 0x46, 0x35, 0xf5, 0xda, 0xcc, 0xc8}; + uint8_t bytesprops2[] = {0x7d, 0x3e, 0x4b, 0x3a, 0x8f, 0x5e, 0xd8, 0x93, 0x33, 0x64, 0x74, 0xd4, 0x1, 0x4c}; + uint8_t bytesprops3[] = {0xd5, 0xa4, 0xa6, 0x42, 0x60, 0x9d, 0xa8, 0xb, 0xec, 0x8e, 0x7e, 0xff}; + uint8_t bytesprops5[] = {0x4e, 0x2, 0x3d, 0xd0}; + uint8_t bytesprops4[] = {0x31, 0x5b, 0x4c, 0xb5, 0xae, 0x98, 0xba, 0x2, + 0xba, 0x58, 0xaf, 0x8c, 0x20, 0xd4, 0x85, 0x3c}; + uint8_t bytesprops7[] = {0xb4, 0x2a, 0x35, 0x85, 0x4c, 0xf7, 0xed, 0x7c, 0x5d}; + uint8_t bytesprops6[] = {0xb5, 0xd2, 0x7d, 0x58, 0x17, 0xc9, 0x7c, 0x17, 0x50, 0xf3, 0x0, + 0x2e, 0x39, 0xe9, 0xd7, 0x13, 0x1e, 0xde, 0xa, 0xa1, 0xab}; + uint8_t bytesprops8[] = {0x5e, 0xb0, 0x19, 0x49, 0x47, 0xbc}; + uint8_t bytesprops9[] = {0x61, 0x6c, 0x86, 0x7c, 0xed, 0xfa, 0x51, 0x9d, 0x67, 0xeb, 0x6a, 0x4f, 0x94, 0xea, 0xef, + 0x60, 0xc9, 0x2d, 0x8f, 0x6f, 0x61, 0xc6, 0xfd, 0x7c, 0x9b, 0xdd, 0x33, 0x80, 0xd6, 0x5e}; + uint8_t bytesprops11[] = {0xd6, 0xa3, 0x3a, 0xf2, 0xf5, 0xd8, 0x93, 0x79, 0xfd, + 0x41, 0xdf, 0x1e, 0x51, 0x41, 0x58, 0x78, 0x11}; + uint8_t bytesprops10[] = {0xa1, 0x19, 0x7a, 0xcf, 0x75, 0x12, 0x3b, 0x82, 0xc5, 0x41, + 0x6, 0x76, 0x66, 0x33, 0x6f, 0xb2, 0xe4, 0x23, 0x4b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16874}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19500}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10936}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7727}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops0}, .v = {11, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22671}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28734}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19849}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops4}, .v = {4, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5878}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops6}, .v = {9, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26521}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {19, (char*)&bytesprops10}, .v = {17, (char*)&bytesprops11}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17250}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 153, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 151, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoQoSNotSupported [PropContentType -// "\189\217\225N\157\189=\248iC\v\DLE\236e2\DC1\SI",PropAssignedClientIdentifier -// "rK\219\190\184\174\DC3g\142\US\130\243\225\&4\199\215\FSph\210\133Q\147\223r\r",PropServerKeepAlive -// 1413,PropWildcardSubscriptionAvailable 27,PropResponseInformation "\195",PropWildcardSubscriptionAvailable -// 41,PropPayloadFormatIndicator 101,PropSessionExpiryInterval 29285,PropCorrelationData -// "0/\218\191\179\132lT\US",PropSubscriptionIdentifierAvailable 135,PropRequestProblemInformation 194] +// DisconnectRequest DiscoServerBusy [PropReceiveMaximum 10661,PropWillDelayInterval 20242,PropAuthenticationMethod +// "\196e\DC2\241?\196D\245U",PropRequestResponseInformation 216,PropWillDelayInterval 4157,PropWillDelayInterval +// 32170,PropContentType "\211\"\138d\157g\225\t\202<\214\164",PropReasonString +// "AL+_\170",PropRequestResponseInformation 236,PropWillDelayInterval 7295,PropAuthenticationMethod +// "Np\254\214C\248\f\209",PropMaximumPacketSize 17116,PropAuthenticationMethod +// "D*\209W\233\253\186\&0~\208\185\147\195\133\163;\218\t\180\172\158\128(",PropRequestResponseInformation +// 91,PropMaximumQoS 177,PropTopicAliasMaximum 29607,PropRetainAvailable 79,PropSharedSubscriptionAvailable +// 194,PropMaximumPacketSize 4393,PropRetainAvailable 94,PropMaximumPacketSize 11798,PropResponseTopic +// "\154\205\233\153\235m\219\DLEJ8icp\RS43\187\243X\143\231\239\217\201\226\248\175\b0\254",PropRequestResponseInformation +// 161,PropMaximumPacketSize 24013,PropPayloadFormatIndicator 6,PropCorrelationData +// "\214\CAN\232\178\221\&8\138/y\251\236\137\225\&0D\f\156X\nQ\201IuU\STXU\t\143",PropSessionExpiryInterval +// 17417,PropWildcardSubscriptionAvailable 30,PropAssignedClientIdentifier "d\SYN\EM +// G\142\DLE\227\DC4i9\172\153\FS^].(\233\142\187p*d",PropMaximumPacketSize 6745] TEST(Disco5QCTest, Encode5) { - uint8_t pkt[] = {0xe0, 0x55, 0x9b, 0x53, 0x3, 0x0, 0x11, 0xbd, 0xd9, 0xe1, 0x4e, 0x9d, 0xbd, 0x3d, 0xf8, - 0x69, 0x43, 0xb, 0x10, 0xec, 0x65, 0x32, 0x11, 0xf, 0x12, 0x0, 0x1a, 0x72, 0x4b, 0xdb, - 0xbe, 0xb8, 0xae, 0x13, 0x67, 0x8e, 0x1f, 0x82, 0xf3, 0xe1, 0x34, 0xc7, 0xd7, 0x1c, 0x70, - 0x68, 0xd2, 0x85, 0x51, 0x93, 0xdf, 0x72, 0xd, 0x13, 0x5, 0x85, 0x28, 0x1b, 0x1a, 0x0, - 0x1, 0xc3, 0x28, 0x29, 0x1, 0x65, 0x11, 0x0, 0x0, 0x72, 0x65, 0x9, 0x0, 0x9, 0x30, - 0x2f, 0xda, 0xbf, 0xb3, 0x84, 0x6c, 0x54, 0x1f, 0x29, 0x87, 0x17, 0xc2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xbd, 0xd9, 0xe1, 0x4e, 0x9d, 0xbd, 0x3d, 0xf8, 0x69, - 0x43, 0xb, 0x10, 0xec, 0x65, 0x32, 0x11, 0xf}; - uint8_t bytesprops1[] = {0x72, 0x4b, 0xdb, 0xbe, 0xb8, 0xae, 0x13, 0x67, 0x8e, 0x1f, 0x82, 0xf3, 0xe1, - 0x34, 0xc7, 0xd7, 0x1c, 0x70, 0x68, 0xd2, 0x85, 0x51, 0x93, 0xdf, 0x72, 0xd}; - uint8_t bytesprops2[] = {0xc3}; - uint8_t bytesprops3[] = {0x30, 0x2f, 0xda, 0xbf, 0xb3, 0x84, 0x6c, 0x54, 0x1f}; + uint8_t pkt[] = { + 0xe0, 0xf2, 0x1, 0x89, 0xef, 0x1, 0x21, 0x29, 0xa5, 0x18, 0x0, 0x0, 0x4f, 0x12, 0x15, 0x0, 0x9, 0xc4, 0x65, + 0x12, 0xf1, 0x3f, 0xc4, 0x44, 0xf5, 0x55, 0x19, 0xd8, 0x18, 0x0, 0x0, 0x10, 0x3d, 0x18, 0x0, 0x0, 0x7d, 0xaa, + 0x3, 0x0, 0xc, 0xd3, 0x22, 0x8a, 0x64, 0x9d, 0x67, 0xe1, 0x9, 0xca, 0x3c, 0xd6, 0xa4, 0x1f, 0x0, 0x5, 0x41, + 0x4c, 0x2b, 0x5f, 0xaa, 0x19, 0xec, 0x18, 0x0, 0x0, 0x1c, 0x7f, 0x15, 0x0, 0x8, 0x4e, 0x70, 0xfe, 0xd6, 0x43, + 0xf8, 0xc, 0xd1, 0x27, 0x0, 0x0, 0x42, 0xdc, 0x15, 0x0, 0x17, 0x44, 0x2a, 0xd1, 0x57, 0xe9, 0xfd, 0xba, 0x30, + 0x7e, 0xd0, 0xb9, 0x93, 0xc3, 0x85, 0xa3, 0x3b, 0xda, 0x9, 0xb4, 0xac, 0x9e, 0x80, 0x28, 0x19, 0x5b, 0x24, 0xb1, + 0x22, 0x73, 0xa7, 0x25, 0x4f, 0x2a, 0xc2, 0x27, 0x0, 0x0, 0x11, 0x29, 0x25, 0x5e, 0x27, 0x0, 0x0, 0x2e, 0x16, + 0x8, 0x0, 0x1e, 0x9a, 0xcd, 0xe9, 0x99, 0xeb, 0x6d, 0xdb, 0x10, 0x4a, 0x38, 0x69, 0x63, 0x70, 0x1e, 0x34, 0x33, + 0xbb, 0xf3, 0x58, 0x8f, 0xe7, 0xef, 0xd9, 0xc9, 0xe2, 0xf8, 0xaf, 0x8, 0x30, 0xfe, 0x19, 0xa1, 0x27, 0x0, 0x0, + 0x5d, 0xcd, 0x1, 0x6, 0x9, 0x0, 0x1c, 0xd6, 0x18, 0xe8, 0xb2, 0xdd, 0x38, 0x8a, 0x2f, 0x79, 0xfb, 0xec, 0x89, + 0xe1, 0x30, 0x44, 0xc, 0x9c, 0x58, 0xa, 0x51, 0xc9, 0x49, 0x75, 0x55, 0x2, 0x55, 0x9, 0x8f, 0x11, 0x0, 0x0, + 0x44, 0x9, 0x28, 0x1e, 0x12, 0x0, 0x18, 0x64, 0x16, 0x19, 0x20, 0x47, 0x8e, 0x10, 0xe3, 0x14, 0x69, 0x39, 0xac, + 0x99, 0x1c, 0x5e, 0x5d, 0x2e, 0x28, 0xe9, 0x8e, 0xbb, 0x70, 0x2a, 0x64, 0x27, 0x0, 0x0, 0x1a, 0x59}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc4, 0x65, 0x12, 0xf1, 0x3f, 0xc4, 0x44, 0xf5, 0x55}; + uint8_t bytesprops1[] = {0xd3, 0x22, 0x8a, 0x64, 0x9d, 0x67, 0xe1, 0x9, 0xca, 0x3c, 0xd6, 0xa4}; + uint8_t bytesprops2[] = {0x41, 0x4c, 0x2b, 0x5f, 0xaa}; + uint8_t bytesprops3[] = {0x4e, 0x70, 0xfe, 0xd6, 0x43, 0xf8, 0xc, 0xd1}; + uint8_t bytesprops4[] = {0x44, 0x2a, 0xd1, 0x57, 0xe9, 0xfd, 0xba, 0x30, 0x7e, 0xd0, 0xb9, 0x93, + 0xc3, 0x85, 0xa3, 0x3b, 0xda, 0x9, 0xb4, 0xac, 0x9e, 0x80, 0x28}; + uint8_t bytesprops5[] = {0x9a, 0xcd, 0xe9, 0x99, 0xeb, 0x6d, 0xdb, 0x10, 0x4a, 0x38, 0x69, 0x63, 0x70, 0x1e, 0x34, + 0x33, 0xbb, 0xf3, 0x58, 0x8f, 0xe7, 0xef, 0xd9, 0xc9, 0xe2, 0xf8, 0xaf, 0x8, 0x30, 0xfe}; + uint8_t bytesprops6[] = {0xd6, 0x18, 0xe8, 0xb2, 0xdd, 0x38, 0x8a, 0x2f, 0x79, 0xfb, 0xec, 0x89, 0xe1, 0x30, + 0x44, 0xc, 0x9c, 0x58, 0xa, 0x51, 0xc9, 0x49, 0x75, 0x55, 0x2, 0x55, 0x9, 0x8f}; + uint8_t bytesprops7[] = {0x64, 0x16, 0x19, 0x20, 0x47, 0x8e, 0x10, 0xe3, 0x14, 0x69, 0x39, 0xac, + 0x99, 0x1c, 0x5e, 0x5d, 0x2e, 0x28, 0xe9, 0x8e, 0xbb, 0x70, 0x2a, 0x64}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1413}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29285}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10661}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20242}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4157}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32170}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7295}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17116}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29607}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4393}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11798}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24013}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17417}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6745}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 137, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoQoSNotSupported [PropResponseInformation "\228(\210io\200N\191p_\175",PropUserProperty -// "C\177+\b_\DC1\246G\141~\203 \156+\162\203\209v:\DC2\215\211" -// "\NAK\171\190\205\186\225L\184\191\ACK\204\133\&5-\236R{",PropWildcardSubscriptionAvailable 55,PropMaximumPacketSize -// 21821,PropMessageExpiryInterval 13767,PropTopicAlias 13552,PropAssignedClientIdentifier -// "\139\SI\bF\SYN\\o\213\133\&55",PropRequestProblemInformation 230,PropResponseInformation -// "NJ\182\163]\143\168\247\133\STX\207\v\149\146\166\RS\206kR0\EOT\236\160\SOH4\208\\\232\162",PropServerReference -// "\128c\v\215z\SUB\ESC\190\165@\150.\179 \241\153\&18\242g\201\EOT",PropSessionExpiryInterval 16675,PropResponseTopic -// "\177\EM\206\165\ETXy\247?\161\b\183\197\135\186\ACK\207",PropTopicAliasMaximum 12720,PropContentType -// "8\SO\198B\137a\209\210\170VE\n\169J\184"] +// DisconnectRequest DiscoSessiontakenOver [PropMessageExpiryInterval 31530,PropTopicAliasMaximum +// 20641,PropRequestProblemInformation 28,PropRetainAvailable 154,PropSubscriptionIdentifier 22,PropResponseTopic +// "\164$\241\130a\243",PropWildcardSubscriptionAvailable 222,PropCorrelationData "\147\197",PropPayloadFormatIndicator +// 149,PropWildcardSubscriptionAvailable 246,PropSharedSubscriptionAvailable 80,PropRequestProblemInformation +// 82,PropWillDelayInterval 24431,PropCorrelationData +// "M\185rj\222\SOH\NULb\140\166\153\231\181|\231\185\248\DC3{j\DC1\152\153\167\230",PropWillDelayInterval +// 5082,PropRequestResponseInformation 164,PropServerReference +// "\ETX\201pk\210pG\217\168\158\254\190\STX>\152\201Dj\231\&6\252yc",PropCorrelationData +// "xO\163\135\225\212z\220\150",PropServerReference "h\r\189\RS2\138\240\DLE",PropAuthenticationMethod +// "4\a\177\144\190@\162\190\147\&8\226:&\176\206\187",PropWillDelayInterval 16727,PropSessionExpiryInterval +// 30740,PropPayloadFormatIndicator 54] TEST(Disco5QCTest, Encode6) { - uint8_t pkt[] = {0xe0, 0xc2, 0x1, 0x9b, 0xbf, 0x1, 0x1a, 0x0, 0xb, 0xe4, 0x28, 0xd2, 0x69, 0x6f, 0xc8, 0x4e, 0xbf, - 0x70, 0x5f, 0xaf, 0x26, 0x0, 0x16, 0x43, 0xb1, 0x2b, 0x8, 0x5f, 0x11, 0xf6, 0x47, 0x8d, 0x7e, 0xcb, - 0x20, 0x9c, 0x2b, 0xa2, 0xcb, 0xd1, 0x76, 0x3a, 0x12, 0xd7, 0xd3, 0x0, 0x11, 0x15, 0xab, 0xbe, 0xcd, - 0xba, 0xe1, 0x4c, 0xb8, 0xbf, 0x6, 0xcc, 0x85, 0x35, 0x2d, 0xec, 0x52, 0x7b, 0x28, 0x37, 0x27, 0x0, - 0x0, 0x55, 0x3d, 0x2, 0x0, 0x0, 0x35, 0xc7, 0x23, 0x34, 0xf0, 0x12, 0x0, 0xb, 0x8b, 0xf, 0x8, - 0x46, 0x16, 0x5c, 0x6f, 0xd5, 0x85, 0x35, 0x35, 0x17, 0xe6, 0x1a, 0x0, 0x1d, 0x4e, 0x4a, 0xb6, 0xa3, - 0x5d, 0x8f, 0xa8, 0xf7, 0x85, 0x2, 0xcf, 0xb, 0x95, 0x92, 0xa6, 0x1e, 0xce, 0x6b, 0x52, 0x30, 0x4, - 0xec, 0xa0, 0x1, 0x34, 0xd0, 0x5c, 0xe8, 0xa2, 0x1c, 0x0, 0x16, 0x80, 0x63, 0xb, 0xd7, 0x7a, 0x1a, - 0x1b, 0xbe, 0xa5, 0x40, 0x96, 0x2e, 0xb3, 0x20, 0xf1, 0x99, 0x31, 0x38, 0xf2, 0x67, 0xc9, 0x4, 0x11, - 0x0, 0x0, 0x41, 0x23, 0x8, 0x0, 0x10, 0xb1, 0x19, 0xce, 0xa5, 0x3, 0x79, 0xf7, 0x3f, 0xa1, 0x8, - 0xb7, 0xc5, 0x87, 0xba, 0x6, 0xcf, 0x22, 0x31, 0xb0, 0x3, 0x0, 0xf, 0x38, 0xe, 0xc6, 0x42, 0x89, - 0x61, 0xd1, 0xd2, 0xaa, 0x56, 0x45, 0xa, 0xa9, 0x4a, 0xb8}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe4, 0x28, 0xd2, 0x69, 0x6f, 0xc8, 0x4e, 0xbf, 0x70, 0x5f, 0xaf}; - uint8_t bytesprops2[] = {0x15, 0xab, 0xbe, 0xcd, 0xba, 0xe1, 0x4c, 0xb8, 0xbf, - 0x6, 0xcc, 0x85, 0x35, 0x2d, 0xec, 0x52, 0x7b}; - uint8_t bytesprops1[] = {0x43, 0xb1, 0x2b, 0x8, 0x5f, 0x11, 0xf6, 0x47, 0x8d, 0x7e, 0xcb, - 0x20, 0x9c, 0x2b, 0xa2, 0xcb, 0xd1, 0x76, 0x3a, 0x12, 0xd7, 0xd3}; - uint8_t bytesprops3[] = {0x8b, 0xf, 0x8, 0x46, 0x16, 0x5c, 0x6f, 0xd5, 0x85, 0x35, 0x35}; - uint8_t bytesprops4[] = {0x4e, 0x4a, 0xb6, 0xa3, 0x5d, 0x8f, 0xa8, 0xf7, 0x85, 0x2, 0xcf, 0xb, 0x95, 0x92, 0xa6, - 0x1e, 0xce, 0x6b, 0x52, 0x30, 0x4, 0xec, 0xa0, 0x1, 0x34, 0xd0, 0x5c, 0xe8, 0xa2}; - uint8_t bytesprops5[] = {0x80, 0x63, 0xb, 0xd7, 0x7a, 0x1a, 0x1b, 0xbe, 0xa5, 0x40, 0x96, - 0x2e, 0xb3, 0x20, 0xf1, 0x99, 0x31, 0x38, 0xf2, 0x67, 0xc9, 0x4}; - uint8_t bytesprops6[] = {0xb1, 0x19, 0xce, 0xa5, 0x3, 0x79, 0xf7, 0x3f, 0xa1, 0x8, 0xb7, 0xc5, 0x87, 0xba, 0x6, 0xcf}; - uint8_t bytesprops7[] = {0x38, 0xe, 0xc6, 0x42, 0x89, 0x61, 0xd1, 0xd2, 0xaa, 0x56, 0x45, 0xa, 0xa9, 0x4a, 0xb8}; + uint8_t pkt[] = {0xe0, 0xa1, 0x1, 0x8e, 0x9e, 0x1, 0x2, 0x0, 0x0, 0x7b, 0x2a, 0x22, 0x50, 0xa1, 0x17, 0x1c, 0x25, + 0x9a, 0xb, 0x16, 0x8, 0x0, 0x6, 0xa4, 0x24, 0xf1, 0x82, 0x61, 0xf3, 0x28, 0xde, 0x9, 0x0, 0x2, + 0x93, 0xc5, 0x1, 0x95, 0x28, 0xf6, 0x2a, 0x50, 0x17, 0x52, 0x18, 0x0, 0x0, 0x5f, 0x6f, 0x9, 0x0, + 0x19, 0x4d, 0xb9, 0x72, 0x6a, 0xde, 0x1, 0x0, 0x62, 0x8c, 0xa6, 0x99, 0xe7, 0xb5, 0x7c, 0xe7, 0xb9, + 0xf8, 0x13, 0x7b, 0x6a, 0x11, 0x98, 0x99, 0xa7, 0xe6, 0x18, 0x0, 0x0, 0x13, 0xda, 0x19, 0xa4, 0x1c, + 0x0, 0x17, 0x3, 0xc9, 0x70, 0x6b, 0xd2, 0x70, 0x47, 0xd9, 0xa8, 0x9e, 0xfe, 0xbe, 0x2, 0x3e, 0x98, + 0xc9, 0x44, 0x6a, 0xe7, 0x36, 0xfc, 0x79, 0x63, 0x9, 0x0, 0x9, 0x78, 0x4f, 0xa3, 0x87, 0xe1, 0xd4, + 0x7a, 0xdc, 0x96, 0x1c, 0x0, 0x8, 0x68, 0xd, 0xbd, 0x1e, 0x32, 0x8a, 0xf0, 0x10, 0x15, 0x0, 0x10, + 0x34, 0x7, 0xb1, 0x90, 0xbe, 0x40, 0xa2, 0xbe, 0x93, 0x38, 0xe2, 0x3a, 0x26, 0xb0, 0xce, 0xbb, 0x18, + 0x0, 0x0, 0x41, 0x57, 0x11, 0x0, 0x0, 0x78, 0x14, 0x1, 0x36}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa4, 0x24, 0xf1, 0x82, 0x61, 0xf3}; + uint8_t bytesprops1[] = {0x93, 0xc5}; + uint8_t bytesprops2[] = {0x4d, 0xb9, 0x72, 0x6a, 0xde, 0x1, 0x0, 0x62, 0x8c, 0xa6, 0x99, 0xe7, 0xb5, + 0x7c, 0xe7, 0xb9, 0xf8, 0x13, 0x7b, 0x6a, 0x11, 0x98, 0x99, 0xa7, 0xe6}; + uint8_t bytesprops3[] = {0x3, 0xc9, 0x70, 0x6b, 0xd2, 0x70, 0x47, 0xd9, 0xa8, 0x9e, 0xfe, 0xbe, + 0x2, 0x3e, 0x98, 0xc9, 0x44, 0x6a, 0xe7, 0x36, 0xfc, 0x79, 0x63}; + uint8_t bytesprops4[] = {0x78, 0x4f, 0xa3, 0x87, 0xe1, 0xd4, 0x7a, 0xdc, 0x96}; + uint8_t bytesprops5[] = {0x68, 0xd, 0xbd, 0x1e, 0x32, 0x8a, 0xf0, 0x10}; + uint8_t bytesprops6[] = {0x34, 0x7, 0xb1, 0x90, 0xbe, 0x40, 0xa2, 0xbe, + 0x93, 0x38, 0xe2, 0x3a, 0x26, 0xb0, 0xce, 0xbb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops1}, .v = {17, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21821}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13767}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13552}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16675}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12720}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31530}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20641}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24431}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5082}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16727}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30740}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 54}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 142, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoSharedSubscriptionsNotSupported [PropMessageExpiryInterval 11490,PropPayloadFormatIndicator -// 13,PropServerKeepAlive 27670,PropSessionExpiryInterval 16138,PropTopicAlias 7546,PropUserProperty -// "\190\DC2z\155\239\207\177\rw\205\STX\156\139\131" "u\SUB.<\214\181\221P\237lI\239\246",PropSessionExpiryInterval -// 3968,PropUserProperty "\138\&5\250\&3\"r\144\179\248yH9\253\237S\CAN\157\EM\200x\SI\166K\156\183" -// "\244\f\224\208E^\b}\137x\193\232\177\196\209aP\223\&0\ESC",PropAssignedClientIdentifier -// "\176:s\251\174\192\NULz\137G\208$\137p\131\DC3\130\bX\US0\188\250\233\SO\f\ESCL",PropMaximumQoS 110,PropMaximumQoS -// 180,PropAuthenticationMethod "k\r\217\ru,\nB\235\213m\"]\247Sk\240\211\135zD)\183\240\245",PropTopicAliasMaximum -// 18518,PropServerReference "X\252\DC1\218oX\200\156h\172E-\224\132]\170\&3\175c",PropAssignedClientIdentifier -// "e\154\&4l",PropResponseInformation "}8e\161\183\RSI\229\202\US\144\220\r_\190\141\SUB}",PropSessionExpiryInterval -// 18101,PropCorrelationData "\\2\129O\159\195W}\150\DC1\137\&5\233\140S\DC3\EM\185'\SUB\192\159v\204r",PropContentType -// "\207P\v\RSj",PropRetainAvailable 235,PropContentType -// "w\200\234h{\222@\149\210\225\133\v\248\243\246(\US\128\&3&\136\201t\200\DC4\206\227",PropSubscriptionIdentifier 14] +// DisconnectRequest DiscoNotAuthorized [PropRequestResponseInformation 223,PropPayloadFormatIndicator +// 46,PropWillDelayInterval 3656,PropSubscriptionIdentifier 17,PropServerReference +// "\130\186?~>",PropSessionExpiryInterval 18554,PropContentType "",PropResponseInformation +// "\189.\DLE[\184\217Y\129b\144OW'\137i?\166~\216X'$\228",PropAssignedClientIdentifier +// "0\171\ETXf\229\161p\DC1-\227\146\181\178\132\223<\232+\207\160\182\176\190\&6\231K\132",PropServerKeepAlive +// 4852,PropServerKeepAlive 29505,PropTopicAliasMaximum 4105,PropMessageExpiryInterval 24745] TEST(Disco5QCTest, Encode7) { - uint8_t pkt[] = { - 0xe0, 0xab, 0x2, 0x9e, 0xa8, 0x2, 0x2, 0x0, 0x0, 0x2c, 0xe2, 0x1, 0xd, 0x13, 0x6c, 0x16, 0x11, 0x0, 0x0, - 0x3f, 0xa, 0x23, 0x1d, 0x7a, 0x26, 0x0, 0xe, 0xbe, 0x12, 0x7a, 0x9b, 0xef, 0xcf, 0xb1, 0xd, 0x77, 0xcd, 0x2, - 0x9c, 0x8b, 0x83, 0x0, 0xd, 0x75, 0x1a, 0x2e, 0x3c, 0xd6, 0xb5, 0xdd, 0x50, 0xed, 0x6c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0x9f, 0xc3, 0x57, 0x7d, 0x96, 0x11, 0x89, 0x35, - 0xe9, 0x8c, 0x53, 0x13, 0x19, 0xb9, 0x27, 0x1a, 0xc0, 0x9f, 0x76, 0xcc, 0x72, 0x3, 0x0, 0x5, 0xcf, 0x50, 0xb, - 0x1e, 0x6a, 0x25, 0xeb, 0x3, 0x0, 0x1b, 0x77, 0xc8, 0xea, 0x68, 0x7b, 0xde, 0x40, 0x95, 0xd2, 0xe1, 0x85, 0xb, - 0xf8, 0xf3, 0xf6, 0x28, 0x1f, 0x80, 0x33, 0x26, 0x88, 0xc9, 0x74, 0xc8, 0x14, 0xce, 0xe3, 0xb, 0xe}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x75, 0x1a, 0x2e, 0x3c, 0xd6, 0xb5, 0xdd, 0x50, 0xed, 0x6c, 0x49, 0xef, 0xf6}; - uint8_t bytesprops0[] = {0xbe, 0x12, 0x7a, 0x9b, 0xef, 0xcf, 0xb1, 0xd, 0x77, 0xcd, 0x2, 0x9c, 0x8b, 0x83}; - uint8_t bytesprops3[] = {0xf4, 0xc, 0xe0, 0xd0, 0x45, 0x5e, 0x8, 0x7d, 0x89, 0x78, - 0xc1, 0xe8, 0xb1, 0xc4, 0xd1, 0x61, 0x50, 0xdf, 0x30, 0x1b}; - uint8_t bytesprops2[] = {0x8a, 0x35, 0xfa, 0x33, 0x22, 0x72, 0x90, 0xb3, 0xf8, 0x79, 0x48, 0x39, 0xfd, - 0xed, 0x53, 0x18, 0x9d, 0x19, 0xc8, 0x78, 0xf, 0xa6, 0x4b, 0x9c, 0xb7}; - uint8_t bytesprops4[] = {0xb0, 0x3a, 0x73, 0xfb, 0xae, 0xc0, 0x0, 0x7a, 0x89, 0x47, 0xd0, 0x24, 0x89, 0x70, - 0x83, 0x13, 0x82, 0x8, 0x58, 0x1f, 0x30, 0xbc, 0xfa, 0xe9, 0xe, 0xc, 0x1b, 0x4c}; - uint8_t bytesprops5[] = {0x6b, 0xd, 0xd9, 0xd, 0x75, 0x2c, 0xa, 0x42, 0xeb, 0xd5, 0x6d, 0x22, 0x5d, - 0xf7, 0x53, 0x6b, 0xf0, 0xd3, 0x87, 0x7a, 0x44, 0x29, 0xb7, 0xf0, 0xf5}; - uint8_t bytesprops6[] = {0x58, 0xfc, 0x11, 0xda, 0x6f, 0x58, 0xc8, 0x9c, 0x68, 0xac, - 0x45, 0x2d, 0xe0, 0x84, 0x5d, 0xaa, 0x33, 0xaf, 0x63}; - uint8_t bytesprops7[] = {0x65, 0x9a, 0x34, 0x6c}; - uint8_t bytesprops8[] = {0x7d, 0x38, 0x65, 0xa1, 0xb7, 0x1e, 0x49, 0xe5, 0xca, - 0x1f, 0x90, 0xdc, 0xd, 0x5f, 0xbe, 0x8d, 0x1a, 0x7d}; - uint8_t bytesprops9[] = {0x5c, 0x32, 0x81, 0x4f, 0x9f, 0xc3, 0x57, 0x7d, 0x96, 0x11, 0x89, 0x35, 0xe9, - 0x8c, 0x53, 0x13, 0x19, 0xb9, 0x27, 0x1a, 0xc0, 0x9f, 0x76, 0xcc, 0x72}; - uint8_t bytesprops10[] = {0xcf, 0x50, 0xb, 0x1e, 0x6a}; - uint8_t bytesprops11[] = {0x77, 0xc8, 0xea, 0x68, 0x7b, 0xde, 0x40, 0x95, 0xd2, 0xe1, 0x85, 0xb, 0xf8, 0xf3, - 0xf6, 0x28, 0x1f, 0x80, 0x33, 0x26, 0x88, 0xc9, 0x74, 0xc8, 0x14, 0xce, 0xe3}; + uint8_t pkt[] = {0xe0, 0x63, 0x87, 0x61, 0x19, 0xdf, 0x1, 0x2e, 0x18, 0x0, 0x0, 0xe, 0x48, 0xb, 0x11, 0x1c, 0x0, + 0x5, 0x82, 0xba, 0x3f, 0x7e, 0x3e, 0x11, 0x0, 0x0, 0x48, 0x7a, 0x3, 0x0, 0x0, 0x1a, 0x0, 0x17, + 0xbd, 0x2e, 0x10, 0x5b, 0xb8, 0xd9, 0x59, 0x81, 0x62, 0x90, 0x4f, 0x57, 0x27, 0x89, 0x69, 0x3f, 0xa6, + 0x7e, 0xd8, 0x58, 0x27, 0x24, 0xe4, 0x12, 0x0, 0x1b, 0x30, 0xab, 0x3, 0x66, 0xe5, 0xa1, 0x70, 0x11, + 0x2d, 0xe3, 0x92, 0xb5, 0xb2, 0x84, 0xdf, 0x3c, 0xe8, 0x2b, 0xcf, 0xa0, 0xb6, 0xb0, 0xbe, 0x36, 0xe7, + 0x4b, 0x84, 0x13, 0x12, 0xf4, 0x13, 0x73, 0x41, 0x22, 0x10, 0x9, 0x2, 0x0, 0x0, 0x60, 0xa9}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x82, 0xba, 0x3f, 0x7e, 0x3e}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0xbd, 0x2e, 0x10, 0x5b, 0xb8, 0xd9, 0x59, 0x81, 0x62, 0x90, 0x4f, 0x57, + 0x27, 0x89, 0x69, 0x3f, 0xa6, 0x7e, 0xd8, 0x58, 0x27, 0x24, 0xe4}; + uint8_t bytesprops3[] = {0x30, 0xab, 0x3, 0x66, 0xe5, 0xa1, 0x70, 0x11, 0x2d, 0xe3, 0x92, 0xb5, 0xb2, 0x84, + 0xdf, 0x3c, 0xe8, 0x2b, 0xcf, 0xa0, 0xb6, 0xb0, 0xbe, 0x36, 0xe7, 0x4b, 0x84}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11490}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27670}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16138}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7546}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3968}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops2}, .v = {20, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18518}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18101}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3656}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18554}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4852}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29505}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4105}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24745}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 158, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 135, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoMaximumConnectTime [PropWildcardSubscriptionAvailable 9,PropResponseInformation -// "\242\"\144\253\155A\a\224\157\&0\250\167\202UU\DC3i\SO\216\ESCE\t\200e\236",PropAuthenticationData -// "\224q~\185\ACK\169\192g\DC2\146\&11iM\128\204\a\176\DC40M",PropRequestProblemInformation 236,PropCorrelationData -// "\164Z\140\175\231\192N\164\SOH{P\ETB\194\200\154\178\193",PropRequestResponseInformation -// 247,PropSubscriptionIdentifierAvailable 58,PropRequestResponseInformation 250,PropMessageExpiryInterval 31479] +// DisconnectRequest DiscoDisconnectWithWill [PropRequestResponseInformation 209,PropMaximumPacketSize +// 3936,PropSharedSubscriptionAvailable 137,PropWildcardSubscriptionAvailable 244,PropRequestResponseInformation +// 55,PropReceiveMaximum 25352,PropTopicAlias 28418,PropReceiveMaximum 11027,PropCorrelationData +// "3@\ac\EM\249",PropSubscriptionIdentifier 10,PropResponseTopic +// "\148\203\180\141Y'\192\226\DC1\n\CAN\254\237-\233d\159\241#\168NH\216/\229:",PropWillDelayInterval +// 1927,PropSessionExpiryInterval 11473,PropRequestResponseInformation 40,PropAssignedClientIdentifier "\192Y; +// A\v\169\190\203\187*\192\193W\210<\212j&H\241\143\151!\231\148\DC2\214\142",PropPayloadFormatIndicator +// 186,PropCorrelationData "o\200\210\164\229P\206\224~\ETX",PropReasonString "\149\&7X<\174I +// \DC2\GS\178\196\206s\140h`\211o"] TEST(Disco5QCTest, Encode8) { - uint8_t pkt[] = {0xe0, 0x59, 0xa0, 0x57, 0x28, 0x9, 0x1a, 0x0, 0x19, 0xf2, 0x22, 0x90, 0xfd, 0x9b, 0x41, 0x7, - 0xe0, 0x9d, 0x30, 0xfa, 0xa7, 0xca, 0x55, 0x55, 0x13, 0x69, 0xe, 0xd8, 0x1b, 0x45, 0x9, 0xc8, - 0x65, 0xec, 0x16, 0x0, 0x15, 0xe0, 0x71, 0x7e, 0xb9, 0x6, 0xa9, 0xc0, 0x67, 0x12, 0x92, 0x31, - 0x31, 0x69, 0x4d, 0x80, 0xcc, 0x7, 0xb0, 0x14, 0x30, 0x4d, 0x17, 0xec, 0x9, 0x0, 0x11, 0xa4, - 0x5a, 0x8c, 0xaf, 0xe7, 0xc0, 0x4e, 0xa4, 0x1, 0x7b, 0x50, 0x17, 0xc2, 0xc8, 0x9a, 0xb2, 0xc1, - 0x19, 0xf7, 0x29, 0x3a, 0x19, 0xfa, 0x2, 0x0, 0x0, 0x7a, 0xf7}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf2, 0x22, 0x90, 0xfd, 0x9b, 0x41, 0x7, 0xe0, 0x9d, 0x30, 0xfa, 0xa7, 0xca, - 0x55, 0x55, 0x13, 0x69, 0xe, 0xd8, 0x1b, 0x45, 0x9, 0xc8, 0x65, 0xec}; - uint8_t bytesprops1[] = {0xe0, 0x71, 0x7e, 0xb9, 0x6, 0xa9, 0xc0, 0x67, 0x12, 0x92, 0x31, - 0x31, 0x69, 0x4d, 0x80, 0xcc, 0x7, 0xb0, 0x14, 0x30, 0x4d}; - uint8_t bytesprops2[] = {0xa4, 0x5a, 0x8c, 0xaf, 0xe7, 0xc0, 0x4e, 0xa4, 0x1, - 0x7b, 0x50, 0x17, 0xc2, 0xc8, 0x9a, 0xb2, 0xc1}; + uint8_t pkt[] = {0xe0, 0x91, 0x1, 0x4, 0x8e, 0x1, 0x19, 0xd1, 0x27, 0x0, 0x0, 0xf, 0x60, 0x2a, 0x89, 0x28, 0xf4, + 0x19, 0x37, 0x21, 0x63, 0x8, 0x23, 0x6f, 0x2, 0x21, 0x2b, 0x13, 0x9, 0x0, 0x6, 0x33, 0x40, 0x7, + 0x63, 0x19, 0xf9, 0xb, 0xa, 0x8, 0x0, 0x1a, 0x94, 0xcb, 0xb4, 0x8d, 0x59, 0x27, 0xc0, 0xe2, 0x11, + 0xa, 0x18, 0xfe, 0xed, 0x2d, 0xe9, 0x64, 0x9f, 0xf1, 0x23, 0xa8, 0x4e, 0x48, 0xd8, 0x2f, 0xe5, 0x3a, + 0x18, 0x0, 0x0, 0x7, 0x87, 0x11, 0x0, 0x0, 0x2c, 0xd1, 0x19, 0x28, 0x12, 0x0, 0x1d, 0xc0, 0x59, + 0x3b, 0x20, 0x41, 0xb, 0xa9, 0xbe, 0xcb, 0xbb, 0x2a, 0xc0, 0xc1, 0x57, 0xd2, 0x3c, 0xd4, 0x6a, 0x26, + 0x48, 0xf1, 0x8f, 0x97, 0x21, 0xe7, 0x94, 0x12, 0xd6, 0x8e, 0x1, 0xba, 0x9, 0x0, 0xa, 0x6f, 0xc8, + 0xd2, 0xa4, 0xe5, 0x50, 0xce, 0xe0, 0x7e, 0x3, 0x1f, 0x0, 0x12, 0x95, 0x37, 0x58, 0x3c, 0xae, 0x49, + 0x20, 0x12, 0x1d, 0xb2, 0xc4, 0xce, 0x73, 0x8c, 0x68, 0x60, 0xd3, 0x6f}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x33, 0x40, 0x7, 0x63, 0x19, 0xf9}; + uint8_t bytesprops1[] = {0x94, 0xcb, 0xb4, 0x8d, 0x59, 0x27, 0xc0, 0xe2, 0x11, 0xa, 0x18, 0xfe, 0xed, + 0x2d, 0xe9, 0x64, 0x9f, 0xf1, 0x23, 0xa8, 0x4e, 0x48, 0xd8, 0x2f, 0xe5, 0x3a}; + uint8_t bytesprops2[] = {0xc0, 0x59, 0x3b, 0x20, 0x41, 0xb, 0xa9, 0xbe, 0xcb, 0xbb, 0x2a, 0xc0, 0xc1, 0x57, 0xd2, + 0x3c, 0xd4, 0x6a, 0x26, 0x48, 0xf1, 0x8f, 0x97, 0x21, 0xe7, 0x94, 0x12, 0xd6, 0x8e}; + uint8_t bytesprops3[] = {0x6f, 0xc8, 0xd2, 0xa4, 0xe5, 0x50, 0xce, 0xe0, 0x7e, 0x3}; + uint8_t bytesprops4[] = {0x95, 0x37, 0x58, 0x3c, 0xae, 0x49, 0x20, 0x12, 0x1d, + 0xb2, 0xc4, 0xce, 0x73, 0x8c, 0x68, 0x60, 0xd3, 0x6f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31479}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3936}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25352}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28418}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11027}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1927}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11473}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 160, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoImplementationSpecificError [PropAuthenticationData "\217/",PropCorrelationData -// "X",PropSharedSubscriptionAvailable 119,PropAuthenticationData "bx\153`\169",PropReceiveMaximum -// 29531,PropSessionExpiryInterval 139,PropMaximumPacketSize 17723,PropMaximumQoS 49,PropMessageExpiryInterval -// 6102,PropServerReference "1\187",PropAuthenticationData -// "\186a*#\148o\153\244F$gr\168j\248\241\235\&9\171\ETX\NUL\252",PropContentType "\245\CANo2\202\147\145\142"] +// DisconnectRequest DiscoNormalDisconnection [PropCorrelationData +// "+\199\231\205\129\214\129\220&\240\t\159\DC1N\GSG",PropTopicAlias 21761,PropTopicAlias 11810,PropWillDelayInterval +// 27354,PropAssignedClientIdentifier "\196\238\195\222{z\184\195\200\199_",PropContentType +// "s\241@%\233\216\129\213\246\&9\161)\193\ETB\EOT\149",PropTopicAlias 31127,PropReasonString +// "g*\SUB\214\218\230\"\135\FS\162X\ENQ",PropTopicAliasMaximum 2689,PropMaximumPacketSize +// 16049,PropSubscriptionIdentifier 23,PropSessionExpiryInterval 21820,PropCorrelationData +// "\213\225\173\213\ENQ\141@V\SYN\165\250`",PropServerKeepAlive 9762,PropWillDelayInterval 30730,PropMaximumPacketSize +// 23599,PropMaximumPacketSize 15159,PropServerReference "\v\187",PropReasonString +// "1\r\187\SUB\175U\DC3r}}\ACK\213\GS\248\189\129\193\236gcd\221\156'\132",PropAuthenticationData +// "\144\201\237P\232\211\221b\ESC,\242",PropSubscriptionIdentifier 23,PropRequestProblemInformation +// 95,PropCorrelationData "\170\&3s\225\220\144\223+\ENQ",PropAuthenticationData "~\181\246{\249"] TEST(Disco5QCTest, Encode9) { - uint8_t pkt[] = {0xe0, 0x52, 0x83, 0x50, 0x16, 0x0, 0x2, 0xd9, 0x2f, 0x9, 0x0, 0x1, 0x58, 0x2a, 0x77, 0x16, 0x0, - 0x5, 0x62, 0x78, 0x99, 0x60, 0xa9, 0x21, 0x73, 0x5b, 0x11, 0x0, 0x0, 0x0, 0x8b, 0x27, 0x0, 0x0, - 0x45, 0x3b, 0x24, 0x31, 0x2, 0x0, 0x0, 0x17, 0xd6, 0x1c, 0x0, 0x2, 0x31, 0xbb, 0x16, 0x0, 0x16, - 0xba, 0x61, 0x2a, 0x23, 0x94, 0x6f, 0x99, 0xf4, 0x46, 0x24, 0x67, 0x72, 0xa8, 0x6a, 0xf8, 0xf1, 0xeb, - 0x39, 0xab, 0x3, 0x0, 0xfc, 0x3, 0x0, 0x8, 0xf5, 0x18, 0x6f, 0x32, 0xca, 0x93, 0x91, 0x8e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd9, 0x2f}; - uint8_t bytesprops1[] = {0x58}; - uint8_t bytesprops2[] = {0x62, 0x78, 0x99, 0x60, 0xa9}; - uint8_t bytesprops3[] = {0x31, 0xbb}; - uint8_t bytesprops4[] = {0xba, 0x61, 0x2a, 0x23, 0x94, 0x6f, 0x99, 0xf4, 0x46, 0x24, 0x67, - 0x72, 0xa8, 0x6a, 0xf8, 0xf1, 0xeb, 0x39, 0xab, 0x3, 0x0, 0xfc}; - uint8_t bytesprops5[] = {0xf5, 0x18, 0x6f, 0x32, 0xca, 0x93, 0x91, 0x8e}; + uint8_t pkt[] = { + 0xe0, 0xcb, 0x1, 0x0, 0xc8, 0x1, 0x9, 0x0, 0x10, 0x2b, 0xc7, 0xe7, 0xcd, 0x81, 0xd6, 0x81, 0xdc, 0x26, 0xf0, + 0x9, 0x9f, 0x11, 0x4e, 0x1d, 0x47, 0x23, 0x55, 0x1, 0x23, 0x2e, 0x22, 0x18, 0x0, 0x0, 0x6a, 0xda, 0x12, 0x0, + 0xb, 0xc4, 0xee, 0xc3, 0xde, 0x7b, 0x7a, 0xb8, 0xc3, 0xc8, 0xc7, 0x5f, 0x3, 0x0, 0x10, 0x73, 0xf1, 0x40, 0x25, + 0xe9, 0xd8, 0x81, 0xd5, 0xf6, 0x39, 0xa1, 0x29, 0xc1, 0x17, 0x4, 0x95, 0x23, 0x79, 0x97, 0x1f, 0x0, 0xc, 0x67, + 0x2a, 0x1a, 0xd6, 0xda, 0xe6, 0x22, 0x87, 0x1c, 0xa2, 0x58, 0x5, 0x22, 0xa, 0x81, 0x27, 0x0, 0x0, 0x3e, 0xb1, + 0xb, 0x17, 0x11, 0x0, 0x0, 0x55, 0x3c, 0x9, 0x0, 0xc, 0xd5, 0xe1, 0xad, 0xd5, 0x5, 0x8d, 0x40, 0x56, 0x16, + 0xa5, 0xfa, 0x60, 0x13, 0x26, 0x22, 0x18, 0x0, 0x0, 0x78, 0xa, 0x27, 0x0, 0x0, 0x5c, 0x2f, 0x27, 0x0, 0x0, + 0x3b, 0x37, 0x1c, 0x0, 0x2, 0xb, 0xbb, 0x1f, 0x0, 0x19, 0x31, 0xd, 0xbb, 0x1a, 0xaf, 0x55, 0x13, 0x72, 0x7d, + 0x7d, 0x6, 0xd5, 0x1d, 0xf8, 0xbd, 0x81, 0xc1, 0xec, 0x67, 0x63, 0x64, 0xdd, 0x9c, 0x27, 0x84, 0x16, 0x0, 0xb, + 0x90, 0xc9, 0xed, 0x50, 0xe8, 0xd3, 0xdd, 0x62, 0x1b, 0x2c, 0xf2, 0xb, 0x17, 0x17, 0x5f, 0x9, 0x0, 0x9, 0xaa, + 0x33, 0x73, 0xe1, 0xdc, 0x90, 0xdf, 0x2b, 0x5, 0x16, 0x0, 0x5, 0x7e, 0xb5, 0xf6, 0x7b, 0xf9}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x2b, 0xc7, 0xe7, 0xcd, 0x81, 0xd6, 0x81, 0xdc, + 0x26, 0xf0, 0x9, 0x9f, 0x11, 0x4e, 0x1d, 0x47}; + uint8_t bytesprops1[] = {0xc4, 0xee, 0xc3, 0xde, 0x7b, 0x7a, 0xb8, 0xc3, 0xc8, 0xc7, 0x5f}; + uint8_t bytesprops2[] = {0x73, 0xf1, 0x40, 0x25, 0xe9, 0xd8, 0x81, 0xd5, + 0xf6, 0x39, 0xa1, 0x29, 0xc1, 0x17, 0x4, 0x95}; + uint8_t bytesprops3[] = {0x67, 0x2a, 0x1a, 0xd6, 0xda, 0xe6, 0x22, 0x87, 0x1c, 0xa2, 0x58, 0x5}; + uint8_t bytesprops4[] = {0xd5, 0xe1, 0xad, 0xd5, 0x5, 0x8d, 0x40, 0x56, 0x16, 0xa5, 0xfa, 0x60}; + uint8_t bytesprops5[] = {0xb, 0xbb}; + uint8_t bytesprops6[] = {0x31, 0xd, 0xbb, 0x1a, 0xaf, 0x55, 0x13, 0x72, 0x7d, 0x7d, 0x6, 0xd5, 0x1d, + 0xf8, 0xbd, 0x81, 0xc1, 0xec, 0x67, 0x63, 0x64, 0xdd, 0x9c, 0x27, 0x84}; + uint8_t bytesprops7[] = {0x90, 0xc9, 0xed, 0x50, 0xe8, 0xd3, 0xdd, 0x62, 0x1b, 0x2c, 0xf2}; + uint8_t bytesprops8[] = {0xaa, 0x33, 0x73, 0xe1, 0xdc, 0x90, 0xdf, 0x2b, 0x5}; + uint8_t bytesprops9[] = {0x7e, 0xb5, 0xf6, 0x7b, 0xf9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29531}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 139}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17723}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6102}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21761}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11810}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27354}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31127}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2689}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16049}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21820}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9762}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30730}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23599}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15159}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 131, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoTopicAliasInvalid [PropCorrelationData "M=\244-PP\EOT\SIU\137d,\234 -// Jvy",PropSubscriptionIdentifierAvailable 128] +// DisconnectRequest DiscoWildcardSubscriptionsNotSupported [PropRequestProblemInformation 151,PropMaximumQoS +// 174,PropMaximumPacketSize 25264,PropServerKeepAlive 13824,PropSubscriptionIdentifier 30,PropPayloadFormatIndicator +// 105,PropWillDelayInterval 9111,PropResponseTopic "\232@:\241o\NAK\163",PropSessionExpiryInterval 14049,PropMaximumPacketSize -// 6508,PropResponseTopic "\ETXCT(\\{\RS\DEL\206\EOT\183\141O",PropReasonString -// "\150AFn\165\146\189\&2\253\145-\SUB\US\162G\151\245\201\&4x\DLE\155\129\238",PropResponseInformation -// "\184\153\r\175\180\t\250\197/\DC1\190\210\208\186\187l\EM\216",PropWildcardSubscriptionAvailable -// 165,PropAuthenticationData "\US\USf\180\206\t/\248\167\ETB\246\DC2\213\SUBH\239+A\ENQ"] +// DisconnectRequest DiscoServershuttingDown [PropMessageExpiryInterval 25341,PropRetainAvailable 151,PropMaximumQoS +// 96,PropAssignedClientIdentifier "B\153N\174I\248IAV@y)C\188[\167",PropSharedSubscriptionAvailable +// 228,PropSubscriptionIdentifierAvailable 109,PropResponseInformation "\ETB\246\211\190s +// _\175\f\215\154\ENQ\187^\135",PropWildcardSubscriptionAvailable 39,PropReceiveMaximum 20521,PropRetainAvailable +// 140,PropResponseTopic "\203Vzi\198\190\192&\US\227A\ETB\ETB\143*vjH\SO\168\169\149",PropServerKeepAlive +// 15366,PropRequestResponseInformation 125,PropSharedSubscriptionAvailable 80,PropMaximumQoS 168,PropResponseTopic +// "z\236 g\181\160\232\252\193\n\175\&2\135*",PropWillDelayInterval 14402,PropWillDelayInterval 22794,PropResponseTopic +// "\NULp\185\203\201f&i\216&\134\164\SO\251",PropMaximumPacketSize 22505] TEST(Disco5QCTest, Encode11) { - uint8_t pkt[] = {0xe0, 0x84, 0x1, 0x9d, 0x81, 0x1, 0x24, 0x1f, 0x17, 0x91, 0x21, 0x30, 0x33, 0x2, 0x0, 0x0, 0x6, - 0x13, 0x19, 0x80, 0x23, 0x51, 0x2d, 0x23, 0x1a, 0x3d, 0x2, 0x0, 0x0, 0x36, 0x5f, 0x8, 0x0, 0x3, - 0x2d, 0x3e, 0xa3, 0x11, 0x0, 0x0, 0x36, 0xe1, 0x27, 0x0, 0x0, 0x19, 0x6c, 0x8, 0x0, 0xd, 0x3, - 0x43, 0x54, 0x28, 0x5c, 0x7b, 0x1e, 0x7f, 0xce, 0x4, 0xb7, 0x8d, 0x4f, 0x1f, 0x0, 0x18, 0x96, 0x41, - 0x46, 0x6e, 0xa5, 0x92, 0xbd, 0x32, 0xfd, 0x91, 0x2d, 0x1a, 0x1f, 0xa2, 0x47, 0x97, 0xf5, 0xc9, 0x34, - 0x78, 0x10, 0x9b, 0x81, 0xee, 0x1a, 0x0, 0x12, 0xb8, 0x99, 0xd, 0xaf, 0xb4, 0x9, 0xfa, 0xc5, 0x2f, - 0x11, 0xbe, 0xd2, 0xd0, 0xba, 0xbb, 0x6c, 0x19, 0xd8, 0x28, 0xa5, 0x16, 0x0, 0x13, 0x1f, 0x1f, 0x66, - 0xb4, 0xce, 0x9, 0x2f, 0xf8, 0xa7, 0x17, 0xf6, 0x12, 0xd5, 0x1a, 0x48, 0xef, 0x2b, 0x41, 0x5}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x2d, 0x3e, 0xa3}; - uint8_t bytesprops1[] = {0x3, 0x43, 0x54, 0x28, 0x5c, 0x7b, 0x1e, 0x7f, 0xce, 0x4, 0xb7, 0x8d, 0x4f}; - uint8_t bytesprops2[] = {0x96, 0x41, 0x46, 0x6e, 0xa5, 0x92, 0xbd, 0x32, 0xfd, 0x91, 0x2d, 0x1a, - 0x1f, 0xa2, 0x47, 0x97, 0xf5, 0xc9, 0x34, 0x78, 0x10, 0x9b, 0x81, 0xee}; - uint8_t bytesprops3[] = {0xb8, 0x99, 0xd, 0xaf, 0xb4, 0x9, 0xfa, 0xc5, 0x2f, - 0x11, 0xbe, 0xd2, 0xd0, 0xba, 0xbb, 0x6c, 0x19, 0xd8}; - uint8_t bytesprops4[] = {0x1f, 0x1f, 0x66, 0xb4, 0xce, 0x9, 0x2f, 0xf8, 0xa7, 0x17, - 0xf6, 0x12, 0xd5, 0x1a, 0x48, 0xef, 0x2b, 0x41, 0x5}; + uint8_t pkt[] = {0xe0, 0x8f, 0x1, 0x8b, 0x8c, 0x1, 0x2, 0x0, 0x0, 0x62, 0xfd, 0x25, 0x97, 0x24, 0x60, 0x12, 0x0, + 0x10, 0x42, 0x99, 0x4e, 0xae, 0x49, 0xf8, 0x49, 0x41, 0x56, 0x40, 0x79, 0x29, 0x43, 0xbc, 0x5b, 0xa7, + 0x2a, 0xe4, 0x29, 0x6d, 0x1a, 0x0, 0xf, 0x17, 0xf6, 0xd3, 0xbe, 0x73, 0x20, 0x5f, 0xaf, 0xc, 0xd7, + 0x9a, 0x5, 0xbb, 0x5e, 0x87, 0x28, 0x27, 0x21, 0x50, 0x29, 0x25, 0x8c, 0x8, 0x0, 0x16, 0xcb, 0x56, + 0x7a, 0x69, 0xc6, 0xbe, 0xc0, 0x26, 0x1f, 0xe3, 0x41, 0x17, 0x17, 0x8f, 0x2a, 0x76, 0x6a, 0x48, 0xe, + 0xa8, 0xa9, 0x95, 0x13, 0x3c, 0x6, 0x19, 0x7d, 0x2a, 0x50, 0x24, 0xa8, 0x8, 0x0, 0xe, 0x7a, 0xec, + 0x20, 0x67, 0xb5, 0xa0, 0xe8, 0xfc, 0xc1, 0xa, 0xaf, 0x32, 0x87, 0x2a, 0x18, 0x0, 0x0, 0x38, 0x42, + 0x18, 0x0, 0x0, 0x59, 0xa, 0x8, 0x0, 0xe, 0x0, 0x70, 0xb9, 0xcb, 0xc9, 0x66, 0x26, 0x69, 0xd8, + 0x26, 0x86, 0xa4, 0xe, 0xfb, 0x27, 0x0, 0x0, 0x57, 0xe9}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x42, 0x99, 0x4e, 0xae, 0x49, 0xf8, 0x49, 0x41, + 0x56, 0x40, 0x79, 0x29, 0x43, 0xbc, 0x5b, 0xa7}; + uint8_t bytesprops1[] = {0x17, 0xf6, 0xd3, 0xbe, 0x73, 0x20, 0x5f, 0xaf, 0xc, 0xd7, 0x9a, 0x5, 0xbb, 0x5e, 0x87}; + uint8_t bytesprops2[] = {0xcb, 0x56, 0x7a, 0x69, 0xc6, 0xbe, 0xc0, 0x26, 0x1f, 0xe3, 0x41, + 0x17, 0x17, 0x8f, 0x2a, 0x76, 0x6a, 0x48, 0xe, 0xa8, 0xa9, 0x95}; + uint8_t bytesprops3[] = {0x7a, 0xec, 0x20, 0x67, 0xb5, 0xa0, 0xe8, 0xfc, 0xc1, 0xa, 0xaf, 0x32, 0x87, 0x2a}; + uint8_t bytesprops4[] = {0x0, 0x70, 0xb9, 0xcb, 0xc9, 0x66, 0x26, 0x69, 0xd8, 0x26, 0x86, 0xa4, 0xe, 0xfb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12339}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1555}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20781}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6717}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13919}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14049}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6508}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25341}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20521}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15366}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14402}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22794}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22505}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 157, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 139, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoPayloadFormatInvalid [PropMessageExpiryInterval 6984,PropSubscriptionIdentifier -// 17,PropServerReference "k+\223\218\228\255\174\248\209D\140\181\164\SUB\136\175K\185",PropAssignedClientIdentifier -// "\150\224\191\129T\a\185[\172\158\DLE\208\186\ETB\238\168\222(L1\247\221",PropResponseTopic -// "\217\&4\155\216.\218\128\DC4\221B\143\SI\247\&1",PropSubscriptionIdentifierAvailable 6,PropAssignedClientIdentifier -// "",PropWildcardSubscriptionAvailable 87,PropTopicAliasMaximum 1948,PropResponseTopic -// "\192\176\194A\221y\194\187\207\201\"\128\NUL!?\169\EOT\DLE",PropContentType "\203",PropSessionExpiryInterval -// 20851,PropSubscriptionIdentifier 17,PropMessageExpiryInterval 30485,PropServerKeepAlive -// 8118,PropRequestProblemInformation 194,PropReceiveMaximum 31011,PropAuthenticationData -// "\201{H\210?\241\NAK\205",PropRequestResponseInformation 61] +// DisconnectRequest DiscoSharedSubscriptionsNotSupported [PropWildcardSubscriptionAvailable +// 234,PropSubscriptionIdentifierAvailable 75,PropAuthenticationMethod +// "\183\NAK\163\250\173",PropSharedSubscriptionAvailable 200,PropContentType +// "\182\&4\US\214t\a\b\156\251\183g\134*\148;\158\226",PropReasonString +// "\252\238\&9-Tl\212\224:",PropRequestResponseInformation 106,PropMaximumPacketSize 19925,PropServerReference +// "%{\214\SUB\205\191U\r\226\139X\"\155\STX\208\161\154\216R",PropMessageExpiryInterval 23694,PropResponseTopic +// "\190S\DC4K\205\208\DLE\151\194z\SO\222\191t\237\203\181",PropMessageExpiryInterval 16415,PropUserProperty +// "\197\217\237\f\134\130\tE\158\193\DC4G\DC1\248\242\198\193\187" +// "\233NT\"xU\SO}\FS\225\128\164\218\&5\253\156f&\139\223",PropReceiveMaximum 120] TEST(Disco5QCTest, Encode12) { - uint8_t pkt[] = {0xe0, 0x8d, 0x1, 0x99, 0x8a, 0x1, 0x2, 0x0, 0x0, 0x1b, 0x48, 0xb, 0x11, 0x1c, 0x0, 0x12, - 0x6b, 0x2b, 0xdf, 0xda, 0xe4, 0xff, 0xae, 0xf8, 0xd1, 0x44, 0x8c, 0xb5, 0xa4, 0x1a, 0x88, 0xaf, - 0x4b, 0xb9, 0x12, 0x0, 0x16, 0x96, 0xe0, 0xbf, 0x81, 0x54, 0x7, 0xb9, 0x5b, 0xac, 0x9e, 0x10, - 0xd0, 0xba, 0x17, 0xee, 0xa8, 0xde, 0x28, 0x4c, 0x31, 0xf7, 0xdd, 0x8, 0x0, 0xe, 0xd9, 0x34, - 0x9b, 0xd8, 0x2e, 0xda, 0x80, 0x14, 0xdd, 0x42, 0x8f, 0xf, 0xf7, 0x31, 0x29, 0x6, 0x12, 0x0, - 0x0, 0x28, 0x57, 0x22, 0x7, 0x9c, 0x8, 0x0, 0x12, 0xc0, 0xb0, 0xc2, 0x41, 0xdd, 0x79, 0xc2, - 0xbb, 0xcf, 0xc9, 0x22, 0x80, 0x0, 0x21, 0x3f, 0xa9, 0x4, 0x10, 0x3, 0x0, 0x1, 0xcb, 0x11, - 0x0, 0x0, 0x51, 0x73, 0xb, 0x11, 0x2, 0x0, 0x0, 0x77, 0x15, 0x13, 0x1f, 0xb6, 0x17, 0xc2, - 0x21, 0x79, 0x23, 0x16, 0x0, 0x8, 0xc9, 0x7b, 0x48, 0xd2, 0x3f, 0xf1, 0x15, 0xcd, 0x19, 0x3d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x6b, 0x2b, 0xdf, 0xda, 0xe4, 0xff, 0xae, 0xf8, 0xd1, - 0x44, 0x8c, 0xb5, 0xa4, 0x1a, 0x88, 0xaf, 0x4b, 0xb9}; - uint8_t bytesprops1[] = {0x96, 0xe0, 0xbf, 0x81, 0x54, 0x7, 0xb9, 0x5b, 0xac, 0x9e, 0x10, - 0xd0, 0xba, 0x17, 0xee, 0xa8, 0xde, 0x28, 0x4c, 0x31, 0xf7, 0xdd}; - uint8_t bytesprops2[] = {0xd9, 0x34, 0x9b, 0xd8, 0x2e, 0xda, 0x80, 0x14, 0xdd, 0x42, 0x8f, 0xf, 0xf7, 0x31}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0xc0, 0xb0, 0xc2, 0x41, 0xdd, 0x79, 0xc2, 0xbb, 0xcf, - 0xc9, 0x22, 0x80, 0x0, 0x21, 0x3f, 0xa9, 0x4, 0x10}; - uint8_t bytesprops5[] = {0xcb}; - uint8_t bytesprops6[] = {0xc9, 0x7b, 0x48, 0xd2, 0x3f, 0xf1, 0x15, 0xcd}; + uint8_t pkt[] = {0xe0, 0x9a, 0x1, 0x9e, 0x97, 0x1, 0x28, 0xea, 0x29, 0x4b, 0x15, 0x0, 0x5, 0xb7, 0x15, 0xa3, + 0xfa, 0xad, 0x2a, 0xc8, 0x3, 0x0, 0x11, 0xb6, 0x34, 0x1f, 0xd6, 0x74, 0x7, 0x8, 0x9c, 0xfb, + 0xb7, 0x67, 0x86, 0x2a, 0x94, 0x3b, 0x9e, 0xe2, 0x1f, 0x0, 0x9, 0xfc, 0xee, 0x39, 0x2d, 0x54, + 0x6c, 0xd4, 0xe0, 0x3a, 0x19, 0x6a, 0x27, 0x0, 0x0, 0x4d, 0xd5, 0x1c, 0x0, 0x13, 0x25, 0x7b, + 0xd6, 0x1a, 0xcd, 0xbf, 0x55, 0xd, 0xe2, 0x8b, 0x58, 0x22, 0x9b, 0x2, 0xd0, 0xa1, 0x9a, 0xd8, + 0x52, 0x2, 0x0, 0x0, 0x5c, 0x8e, 0x8, 0x0, 0x11, 0xbe, 0x53, 0x14, 0x4b, 0xcd, 0xd0, 0x10, + 0x97, 0xc2, 0x7a, 0xe, 0xde, 0xbf, 0x74, 0xed, 0xcb, 0xb5, 0x2, 0x0, 0x0, 0x40, 0x1f, 0x26, + 0x0, 0x12, 0xc5, 0xd9, 0xed, 0xc, 0x86, 0x82, 0x9, 0x45, 0x9e, 0xc1, 0x14, 0x47, 0x11, 0xf8, + 0xf2, 0xc6, 0xc1, 0xbb, 0x0, 0x14, 0xe9, 0x4e, 0x54, 0x22, 0x78, 0x55, 0xe, 0x7d, 0x1c, 0xe1, + 0x80, 0xa4, 0xda, 0x35, 0xfd, 0x9c, 0x66, 0x26, 0x8b, 0xdf, 0x21, 0x0, 0x78}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb7, 0x15, 0xa3, 0xfa, 0xad}; + uint8_t bytesprops1[] = {0xb6, 0x34, 0x1f, 0xd6, 0x74, 0x7, 0x8, 0x9c, 0xfb, + 0xb7, 0x67, 0x86, 0x2a, 0x94, 0x3b, 0x9e, 0xe2}; + uint8_t bytesprops2[] = {0xfc, 0xee, 0x39, 0x2d, 0x54, 0x6c, 0xd4, 0xe0, 0x3a}; + uint8_t bytesprops3[] = {0x25, 0x7b, 0xd6, 0x1a, 0xcd, 0xbf, 0x55, 0xd, 0xe2, 0x8b, + 0x58, 0x22, 0x9b, 0x2, 0xd0, 0xa1, 0x9a, 0xd8, 0x52}; + uint8_t bytesprops4[] = {0xbe, 0x53, 0x14, 0x4b, 0xcd, 0xd0, 0x10, 0x97, 0xc2, + 0x7a, 0xe, 0xde, 0xbf, 0x74, 0xed, 0xcb, 0xb5}; + uint8_t bytesprops6[] = {0xe9, 0x4e, 0x54, 0x22, 0x78, 0x55, 0xe, 0x7d, 0x1c, 0xe1, + 0x80, 0xa4, 0xda, 0x35, 0xfd, 0x9c, 0x66, 0x26, 0x8b, 0xdf}; + uint8_t bytesprops5[] = {0xc5, 0xd9, 0xed, 0xc, 0x86, 0x82, 0x9, 0x45, 0x9e, + 0xc1, 0x14, 0x47, 0x11, 0xf8, 0xf2, 0xc6, 0xc1, 0xbb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6984}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1948}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20851}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30485}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8118}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31011}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19925}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23694}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16415}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops5}, .v = {20, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 120}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 153, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 158, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoConnectionRateExceeded [PropContentType -// "C\240\216I\207~(\SOH\214\251\236X\186\&1\167j2&r\v\\\183HX",PropPayloadFormatIndicator 3,PropResponseInformation -// "\153\ESC\187Ce\169J\SOH\175",PropRequestProblemInformation 237,PropReasonString -// "\198i\156\243\DC3\176t\231\251\210?\138oA\226\174\143\SUB\207\174\\",PropServerKeepAlive -// 14943,PropAuthenticationData -// "7\141\216\204\&0\222\151\131\211B\215\208g\245-\214\145\133\132\&5\205;\159s,*G\185",PropReceiveMaximum -// 24237,PropRequestResponseInformation 147,PropServerReference "\236\216u\221CD\140x\211",PropAssignedClientIdentifier -// "\190\171t/\STX",PropRequestResponseInformation 147,PropReceiveMaximum 10434,PropMessageExpiryInterval -// 26344,PropSubscriptionIdentifier 25,PropResponseInformation "5\166\USnWv\163\v^\204\169!",PropReceiveMaximum -// 18516,PropUserProperty "\b\141T\173\209\191\206h+.\194\227\174" "\199Z\ACK\""] +// DisconnectRequest DiscoSubscriptionIdentifiersNotSupported [PropPayloadFormatIndicator +// 14,PropWildcardSubscriptionAvailable 22,PropAuthenticationMethod +// "\177Z\158*cP'\v\166\DC4|\198\200",PropWildcardSubscriptionAvailable 0,PropCorrelationData +// "\169x\202\194\153\192\189\&0C\226\239s$",PropTopicAliasMaximum 32648,PropAuthenticationMethod +// "C\203\219CNr.\166\195\EM\177",PropMaximumPacketSize 27898,PropMessageExpiryInterval +// 8577,PropRequestResponseInformation 78,PropPayloadFormatIndicator 72,PropWildcardSubscriptionAvailable +// 245,PropReceiveMaximum 13594,PropMaximumQoS 170,PropAssignedClientIdentifier +// "\SUB\246\217\219\156\167\DC1>$\NAK\139b\219\188>",PropTopicAlias 200] TEST(Disco5QCTest, Encode13) { - uint8_t pkt[] = {0xe0, 0xb5, 0x1, 0x9f, 0xb2, 0x1, 0x3, 0x0, 0x18, 0x43, 0xf0, 0xd8, 0x49, 0xcf, 0x7e, 0x28, 0x1, - 0xd6, 0xfb, 0xec, 0x58, 0xba, 0x31, 0xa7, 0x6a, 0x32, 0x26, 0x72, 0xb, 0x5c, 0xb7, 0x48, 0x58, 0x1, - 0x3, 0x1a, 0x0, 0x9, 0x99, 0x1b, 0xbb, 0x43, 0x65, 0xa9, 0x4a, 0x1, 0xaf, 0x17, 0xed, 0x1f, 0x0, - 0x15, 0xc6, 0x69, 0x9c, 0xf3, 0x13, 0xb0, 0x74, 0xe7, 0xfb, 0xd2, 0x3f, 0x8a, 0x6f, 0x41, 0xe2, 0xae, - 0x8f, 0x1a, 0xcf, 0xae, 0x5c, 0x13, 0x3a, 0x5f, 0x16, 0x0, 0x1c, 0x37, 0x8d, 0xd8, 0xcc, 0x30, 0xde, - 0x97, 0x83, 0xd3, 0x42, 0xd7, 0xd0, 0x67, 0xf5, 0x2d, 0xd6, 0x91, 0x85, 0x84, 0x35, 0xcd, 0x3b, 0x9f, - 0x73, 0x2c, 0x2a, 0x47, 0xb9, 0x21, 0x5e, 0xad, 0x19, 0x93, 0x1c, 0x0, 0x9, 0xec, 0xd8, 0x75, 0xdd, - 0x43, 0x44, 0x8c, 0x78, 0xd3, 0x12, 0x0, 0x5, 0xbe, 0xab, 0x74, 0x2f, 0x2, 0x19, 0x93, 0x21, 0x28, - 0xc2, 0x2, 0x0, 0x0, 0x66, 0xe8, 0xb, 0x19, 0x1a, 0x0, 0xc, 0x35, 0xa6, 0x1f, 0x6e, 0x57, 0x76, - 0xa3, 0xb, 0x5e, 0xcc, 0xa9, 0x21, 0x21, 0x48, 0x54, 0x26, 0x0, 0xd, 0x8, 0x8d, 0x54, 0xad, 0xd1, - 0xbf, 0xce, 0x68, 0x2b, 0x2e, 0xc2, 0xe3, 0xae, 0x0, 0x4, 0xc7, 0x5a, 0x6, 0x22}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x43, 0xf0, 0xd8, 0x49, 0xcf, 0x7e, 0x28, 0x1, 0xd6, 0xfb, 0xec, 0x58, - 0xba, 0x31, 0xa7, 0x6a, 0x32, 0x26, 0x72, 0xb, 0x5c, 0xb7, 0x48, 0x58}; - uint8_t bytesprops1[] = {0x99, 0x1b, 0xbb, 0x43, 0x65, 0xa9, 0x4a, 0x1, 0xaf}; - uint8_t bytesprops2[] = {0xc6, 0x69, 0x9c, 0xf3, 0x13, 0xb0, 0x74, 0xe7, 0xfb, 0xd2, 0x3f, - 0x8a, 0x6f, 0x41, 0xe2, 0xae, 0x8f, 0x1a, 0xcf, 0xae, 0x5c}; - uint8_t bytesprops3[] = {0x37, 0x8d, 0xd8, 0xcc, 0x30, 0xde, 0x97, 0x83, 0xd3, 0x42, 0xd7, 0xd0, 0x67, 0xf5, - 0x2d, 0xd6, 0x91, 0x85, 0x84, 0x35, 0xcd, 0x3b, 0x9f, 0x73, 0x2c, 0x2a, 0x47, 0xb9}; - uint8_t bytesprops4[] = {0xec, 0xd8, 0x75, 0xdd, 0x43, 0x44, 0x8c, 0x78, 0xd3}; - uint8_t bytesprops5[] = {0xbe, 0xab, 0x74, 0x2f, 0x2}; - uint8_t bytesprops6[] = {0x35, 0xa6, 0x1f, 0x6e, 0x57, 0x76, 0xa3, 0xb, 0x5e, 0xcc, 0xa9, 0x21}; - uint8_t bytesprops8[] = {0xc7, 0x5a, 0x6, 0x22}; - uint8_t bytesprops7[] = {0x8, 0x8d, 0x54, 0xad, 0xd1, 0xbf, 0xce, 0x68, 0x2b, 0x2e, 0xc2, 0xe3, 0xae}; + uint8_t pkt[] = {0xe0, 0x63, 0xa1, 0x61, 0x1, 0xe, 0x28, 0x16, 0x15, 0x0, 0xd, 0xb1, 0x5a, 0x9e, 0x2a, 0x63, 0x50, + 0x27, 0xb, 0xa6, 0x14, 0x7c, 0xc6, 0xc8, 0x28, 0x0, 0x9, 0x0, 0xd, 0xa9, 0x78, 0xca, 0xc2, 0x99, + 0xc0, 0xbd, 0x30, 0x43, 0xe2, 0xef, 0x73, 0x24, 0x22, 0x7f, 0x88, 0x15, 0x0, 0xb, 0x43, 0xcb, 0xdb, + 0x43, 0x4e, 0x72, 0x2e, 0xa6, 0xc3, 0x19, 0xb1, 0x27, 0x0, 0x0, 0x6c, 0xfa, 0x2, 0x0, 0x0, 0x21, + 0x81, 0x19, 0x4e, 0x1, 0x48, 0x28, 0xf5, 0x21, 0x35, 0x1a, 0x24, 0xaa, 0x12, 0x0, 0xf, 0x1a, 0xf6, + 0xd9, 0xdb, 0x9c, 0xa7, 0x11, 0x3e, 0x24, 0x15, 0x8b, 0x62, 0xdb, 0xbc, 0x3e, 0x23, 0x0, 0xc8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb1, 0x5a, 0x9e, 0x2a, 0x63, 0x50, 0x27, 0xb, 0xa6, 0x14, 0x7c, 0xc6, 0xc8}; + uint8_t bytesprops1[] = {0xa9, 0x78, 0xca, 0xc2, 0x99, 0xc0, 0xbd, 0x30, 0x43, 0xe2, 0xef, 0x73, 0x24}; + uint8_t bytesprops2[] = {0x43, 0xcb, 0xdb, 0x43, 0x4e, 0x72, 0x2e, 0xa6, 0xc3, 0x19, 0xb1}; + uint8_t bytesprops3[] = {0x1a, 0xf6, 0xd9, 0xdb, 0x9c, 0xa7, 0x11, 0x3e, 0x24, 0x15, 0x8b, 0x62, 0xdb, 0xbc, 0x3e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14943}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24237}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10434}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26344}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18516}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops7}, .v = {4, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32648}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27898}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8577}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13594}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 200}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 161, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoServerBusy [PropCorrelationData -// "\156c\234v\230\166\189^6\192\212\247\DELU\146",PropAuthenticationMethod "\128",PropSubscriptionIdentifierAvailable -// 136,PropRequestProblemInformation 9,PropContentType -// "ST6;|\147\194\r\152",PropCorrelationData -// "XQ\141\183i\193\CAN\220\187c\NUL",PropSubscriptionIdentifierAvailable 101,PropResponseInformation -// "&\173-H\175'\176YE\DC1\149\189\243\245%f \141a",PropMaximumQoS 8,PropRetainAvailable -// 83,PropReceiveMaximum 14438,PropSubscriptionIdentifier 7,PropRequestResponseInformation 70,PropMessageExpiryInterval -// 4714,PropSubscriptionIdentifier 16,PropSubscriptionIdentifier 21,PropAuthenticationData -// "csx/\172\f`\190\DC2\ACK\DLE\201\&6\169\168O\188",PropServerKeepAlive 15824,PropMessageExpiryInterval -// 8359,PropWillDelayInterval 26294,PropReceiveMaximum 15657,PropWillDelayInterval 3552,PropTopicAliasMaximum -// 19709,PropMessageExpiryInterval 31451,PropSubscriptionIdentifierAvailable 206,PropMessageExpiryInterval -// 30405,PropUserProperty "L&\216\DC33\DLE!Xa\236\SOQ\243\206G\USV21\179\ETB\246\ETX+w\239zm\SO" -// "\192\136",PropRetainAvailable 59,PropMessageExpiryInterval 26129] +// DisconnectRequest DiscoKeepAliveTimeout [PropRequestProblemInformation 30,PropResponseInformation +// "",PropRequestProblemInformation 166,PropMessageExpiryInterval 1456,PropSubscriptionIdentifierAvailable +// 66,PropUserProperty ":\SOH|\167\136\182\154'\EML J|\184Rd" +// "\128\ACK\215\191\196\am\243\159\244u\STX\"\b\252U\182p\139\138\r@\152\206\197\220\243",PropRetainAvailable +// 226,PropAssignedClientIdentifier +// ")<\145{\253\196Oi\192\n\181\231\SO9\NUL\GS\164\192\228J\243e\185/A\252\196\153",PropResponseTopic +// "\169f\217\DC2G",PropRequestProblemInformation 51,PropSubscriptionIdentifierAvailable 25] TEST(Disco5QCTest, Encode15) { - uint8_t pkt[] = {0xe0, 0xc5, 0x1, 0x8b, 0xc2, 0x1, 0x24, 0xd4, 0x12, 0x0, 0x19, 0xb2, 0xfa, 0xc5, 0xd5, 0x3f, 0xf5, - 0x59, 0x19, 0xe3, 0xa3, 0x8, 0xa, 0xc6, 0x5b, 0xdf, 0x10, 0x71, 0xbd, 0xa6, 0x3e, 0x7c, 0x93, 0xc2, - 0xd, 0x98, 0x9, 0x0, 0xb, 0x58, 0x51, 0x8d, 0xb7, 0x69, 0xc1, 0x18, 0xdc, 0xbb, 0x63, 0x0, 0x29, - 0x65, 0x1a, 0x0, 0x1a, 0x26, 0xad, 0x2d, 0x48, 0x3c, 0x4a, 0x3b, 0xee, 0xf1, 0xa6, 0x3e, 0xaf, 0x27, - 0xb0, 0x59, 0x45, 0x11, 0x95, 0xbd, 0xf3, 0xf5, 0x25, 0x66, 0x20, 0x8d, 0x61, 0x24, 0x8, 0x25, 0x53, - 0x21, 0x38, 0x66, 0xb, 0x7, 0x19, 0x46, 0x2, 0x0, 0x0, 0x12, 0x6a, 0xb, 0x10, 0xb, 0x15, 0x16, - 0x0, 0x11, 0x63, 0x73, 0x78, 0x2f, 0xac, 0xc, 0x60, 0xbe, 0x12, 0x6, 0x10, 0xc9, 0x36, 0xa9, 0xa8, - 0x4f, 0xbc, 0x13, 0x3d, 0xd0, 0x2, 0x0, 0x0, 0x20, 0xa7, 0x18, 0x0, 0x0, 0x66, 0xb6, 0x21, 0x3d, - 0x29, 0x18, 0x0, 0x0, 0xd, 0xe0, 0x22, 0x4c, 0xfd, 0x2, 0x0, 0x0, 0x7a, 0xdb, 0x29, 0xce, 0x2, - 0x0, 0x0, 0x76, 0xc5, 0x26, 0x0, 0x1d, 0x4c, 0x26, 0xd8, 0x13, 0x33, 0x10, 0x21, 0x58, 0x61, 0xec, - 0xe, 0x51, 0xf3, 0xce, 0x47, 0x1f, 0x56, 0x32, 0x31, 0xb3, 0x17, 0xf6, 0x3, 0x2b, 0x77, 0xef, 0x7a, - 0x6d, 0xe, 0x0, 0x2, 0xc0, 0x88, 0x25, 0x3b, 0x2, 0x0, 0x0, 0x66, 0x11}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb2, 0xfa, 0xc5, 0xd5, 0x3f, 0xf5, 0x59, 0x19, 0xe3, 0xa3, 0x8, 0xa, 0xc6, - 0x5b, 0xdf, 0x10, 0x71, 0xbd, 0xa6, 0x3e, 0x7c, 0x93, 0xc2, 0xd, 0x98}; - uint8_t bytesprops1[] = {0x58, 0x51, 0x8d, 0xb7, 0x69, 0xc1, 0x18, 0xdc, 0xbb, 0x63, 0x0}; - uint8_t bytesprops2[] = {0x26, 0xad, 0x2d, 0x48, 0x3c, 0x4a, 0x3b, 0xee, 0xf1, 0xa6, 0x3e, 0xaf, 0x27, - 0xb0, 0x59, 0x45, 0x11, 0x95, 0xbd, 0xf3, 0xf5, 0x25, 0x66, 0x20, 0x8d, 0x61}; - uint8_t bytesprops3[] = {0x63, 0x73, 0x78, 0x2f, 0xac, 0xc, 0x60, 0xbe, 0x12, - 0x6, 0x10, 0xc9, 0x36, 0xa9, 0xa8, 0x4f, 0xbc}; - uint8_t bytesprops5[] = {0xc0, 0x88}; - uint8_t bytesprops4[] = {0x4c, 0x26, 0xd8, 0x13, 0x33, 0x10, 0x21, 0x58, 0x61, 0xec, 0xe, 0x51, 0xf3, 0xce, 0x47, - 0x1f, 0x56, 0x32, 0x31, 0xb3, 0x17, 0xf6, 0x3, 0x2b, 0x77, 0xef, 0x7a, 0x6d, 0xe}; + uint8_t pkt[] = {0xe0, 0x6d, 0x8d, 0x6b, 0x17, 0x1e, 0x1a, 0x0, 0x0, 0x17, 0xa6, 0x2, 0x0, 0x0, 0x5, 0xb0, + 0x29, 0x42, 0x26, 0x0, 0x10, 0x3a, 0x1, 0x7c, 0xa7, 0x88, 0xb6, 0x9a, 0x27, 0x19, 0x4c, 0x20, + 0x4a, 0x7c, 0xb8, 0x52, 0x64, 0x0, 0x1b, 0x80, 0x6, 0xd7, 0xbf, 0xc4, 0x7, 0x6d, 0xf3, 0x9f, + 0xf4, 0x75, 0x2, 0x22, 0x8, 0xfc, 0x55, 0xb6, 0x70, 0x8b, 0x8a, 0xd, 0x40, 0x98, 0xce, 0xc5, + 0xdc, 0xf3, 0x25, 0xe2, 0x12, 0x0, 0x1c, 0x29, 0x3c, 0x91, 0x7b, 0xfd, 0xc4, 0x4f, 0x69, 0xc0, + 0xa, 0xb5, 0xe7, 0xe, 0x39, 0x0, 0x1d, 0xa4, 0xc0, 0xe4, 0x4a, 0xf3, 0x65, 0xb9, 0x2f, 0x41, + 0xfc, 0xc4, 0x99, 0x8, 0x0, 0x5, 0xa9, 0x66, 0xd9, 0x12, 0x47, 0x17, 0x33, 0x29, 0x19}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops2[] = {0x80, 0x6, 0xd7, 0xbf, 0xc4, 0x7, 0x6d, 0xf3, 0x9f, 0xf4, 0x75, 0x2, 0x22, 0x8, + 0xfc, 0x55, 0xb6, 0x70, 0x8b, 0x8a, 0xd, 0x40, 0x98, 0xce, 0xc5, 0xdc, 0xf3}; + uint8_t bytesprops1[] = {0x3a, 0x1, 0x7c, 0xa7, 0x88, 0xb6, 0x9a, 0x27, + 0x19, 0x4c, 0x20, 0x4a, 0x7c, 0xb8, 0x52, 0x64}; + uint8_t bytesprops3[] = {0x29, 0x3c, 0x91, 0x7b, 0xfd, 0xc4, 0x4f, 0x69, 0xc0, 0xa, 0xb5, 0xe7, 0xe, 0x39, + 0x0, 0x1d, 0xa4, 0xc0, 0xe4, 0x4a, 0xf3, 0x65, 0xb9, 0x2f, 0x41, 0xfc, 0xc4, 0x99}; + uint8_t bytesprops4[] = {0xa9, 0x66, 0xd9, 0x12, 0x47}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14438}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4714}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15824}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8359}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26294}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15657}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3552}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19709}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31451}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30405}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26129}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1456}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {27, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 25}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 139, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 141, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoConnectionRateExceeded [PropMaximumPacketSize 26235,PropWillDelayInterval -// 14753,PropServerKeepAlive 23091,PropCorrelationData "\221\220\197\146\147m\224l\189\137",PropServerKeepAlive -// 18977,PropRetainAvailable 40,PropAuthenticationData -// "\132H\t7\146\228\130\133\156\233\208\238\DC33\218\166T\250\193\185\225\217J\229\252q8\184",PropSubscriptionIdentifierAvailable -// 128,PropSharedSubscriptionAvailable 68,PropPayloadFormatIndicator 198,PropMessageExpiryInterval -// 30085,PropRequestProblemInformation 26,PropTopicAlias 9348,PropCorrelationData -// "k\189\172;\148\130:\194\253D8N'\225I",PropMaximumPacketSize 24904,PropSubscriptionIdentifierAvailable -// 201,PropContentType -// "\129\&2\182\229\200\SOHg]\161dbh\198\133\129/\202]\245\DC20\241\r\188>]",PropRequestResponseInformation -// 151,PropReasonString "\162\249\189\188",PropMessageExpiryInterval 16347,PropServerReference -// "\DC2\208\ESCC$,!|+\v\161\&9\221>\169\191\174\169Re\234\239\194\249 \162VSc\128",PropMaximumPacketSize -// 25464,PropAuthenticationMethod "?\198\243",PropSubscriptionIdentifierAvailable 147,PropServerReference -// "\233\DC3\237\143\167\190r\170o\230\SYN\241\251\ba",PropSessionExpiryInterval 20982,PropReceiveMaximum -// 21095,PropServerReference "\255E^kM:\238\148\US\SI\211\231\&9dM -// \227\244s\167\GS\146n\153\137\209\249",PropContentType "I\160\252\203f",PropAssignedClientIdentifier -// "\"'i\184f\v\194\157bJ\181\SOH"] +// DisconnectRequest DiscoWildcardSubscriptionsNotSupported [PropServerKeepAlive 21112,PropAssignedClientIdentifier +// "\203\147\245j!L\236\&9\146G\169\220\229Y\225",PropSharedSubscriptionAvailable 1,PropSessionExpiryInterval +// 27576,PropAuthenticationData "\225\ENQ\249\144H\196PN\166\EM\154\138",PropResponseInformation +// "\152\151\211|\230\CAN\235\248\DC49\\\134:\SUB\NAK\178\181\150LH\212t\253v\214\DC3\208\EOT\207\137",PropRequestProblemInformation +// 73] TEST(Disco5QCTest, Encode16) { - uint8_t pkt[] = { - 0xe0, 0x92, 0x2, 0x9f, 0x8f, 0x2, 0x27, 0x0, 0x0, 0x66, 0x7b, 0x18, 0x0, 0x0, 0x39, 0xa1, 0x13, 0x5a, 0x33, - 0x9, 0x0, 0xa, 0xdd, 0xdc, 0xc5, 0x92, 0x93, 0x6d, 0xe0, 0x6c, 0xbd, 0x89, 0x13, 0x4a, 0x21, 0x25, 0x28, 0x16, - 0x0, 0x1c, 0x84, 0x48, 0x9, 0x37, 0x92, 0xe4, 0x82, 0x85, 0x9c, 0xe9, 0xd0, 0xee, 0x13, 0x33, 0xda, 0xa6, 0x54, - 0xfa, 0xc1, 0xb9, 0xe1, 0xd9, 0x4a, 0xe5, 0xfc, 0x71, 0x38, 0xb8, 0x29, 0x80, 0x2a, 0x44, 0x1, 0xc6, 0x2, 0x0, - 0x0, 0x75, 0x85, 0x17, 0x1a, 0x23, 0x24, 0x84, 0x9, 0x0, 0xf, 0x6b, 0xbd, 0xac, 0x3b, 0x94, 0x82, 0x3a, 0xc2, - 0xfd, 0x44, 0x38, 0x4e, 0x27, 0xe1, 0x49, 0x27, 0x0, 0x0, 0x61, 0x48, 0x29, 0xc9, 0x3, 0x0, 0x1a, 0x81, 0x32, - 0xb6, 0xe5, 0xc8, 0x1, 0x67, 0x5d, 0xa1, 0x64, 0x62, 0x68, 0xc6, 0x85, 0x81, 0x2f, 0xca, 0x5d, 0xf5, 0x12, 0x30, - 0xf1, 0xd, 0xbc, 0x3e, 0x5d, 0x19, 0x97, 0x1f, 0x0, 0x4, 0xa2, 0xf9, 0xbd, 0xbc, 0x2, 0x0, 0x0, 0x3f, 0xdb, - 0x1c, 0x0, 0x1e, 0x12, 0xd0, 0x1b, 0x43, 0x24, 0x2c, 0x21, 0x7c, 0x2b, 0xb, 0xa1, 0x39, 0xdd, 0x3e, 0xa9, 0xbf, - 0xae, 0xa9, 0x52, 0x65, 0xea, 0xef, 0xc2, 0xf9, 0x20, 0xa2, 0x56, 0x53, 0x63, 0x80, 0x27, 0x0, 0x0, 0x63, 0x78, - 0x15, 0x0, 0x3, 0x3f, 0xc6, 0xf3, 0x29, 0x93, 0x1c, 0x0, 0xf, 0xe9, 0x13, 0xed, 0x8f, 0xa7, 0xbe, 0x72, 0xaa, - 0x6f, 0xe6, 0x16, 0xf1, 0xfb, 0x8, 0x61, 0x11, 0x0, 0x0, 0x51, 0xf6, 0x21, 0x52, 0x67, 0x1c, 0x0, 0x1b, 0xff, - 0x45, 0x5e, 0x6b, 0x4d, 0x3a, 0xee, 0x94, 0x1f, 0xf, 0xd3, 0xe7, 0x39, 0x64, 0x4d, 0x20, 0xe3, 0xf4, 0x73, 0xa7, - 0x1d, 0x92, 0x6e, 0x99, 0x89, 0xd1, 0xf9, 0x3, 0x0, 0x5, 0x49, 0xa0, 0xfc, 0xcb, 0x66, 0x12, 0x0, 0xc, 0x22, - 0x27, 0x69, 0xb8, 0x66, 0xb, 0xc2, 0x9d, 0x62, 0x4a, 0xb5, 0x1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xdd, 0xdc, 0xc5, 0x92, 0x93, 0x6d, 0xe0, 0x6c, 0xbd, 0x89}; - uint8_t bytesprops1[] = {0x84, 0x48, 0x9, 0x37, 0x92, 0xe4, 0x82, 0x85, 0x9c, 0xe9, 0xd0, 0xee, 0x13, 0x33, - 0xda, 0xa6, 0x54, 0xfa, 0xc1, 0xb9, 0xe1, 0xd9, 0x4a, 0xe5, 0xfc, 0x71, 0x38, 0xb8}; - uint8_t bytesprops2[] = {0x6b, 0xbd, 0xac, 0x3b, 0x94, 0x82, 0x3a, 0xc2, 0xfd, 0x44, 0x38, 0x4e, 0x27, 0xe1, 0x49}; - uint8_t bytesprops3[] = {0x81, 0x32, 0xb6, 0xe5, 0xc8, 0x1, 0x67, 0x5d, 0xa1, 0x64, 0x62, 0x68, 0xc6, - 0x85, 0x81, 0x2f, 0xca, 0x5d, 0xf5, 0x12, 0x30, 0xf1, 0xd, 0xbc, 0x3e, 0x5d}; - uint8_t bytesprops4[] = {0xa2, 0xf9, 0xbd, 0xbc}; - uint8_t bytesprops5[] = {0x12, 0xd0, 0x1b, 0x43, 0x24, 0x2c, 0x21, 0x7c, 0x2b, 0xb, 0xa1, 0x39, 0xdd, 0x3e, 0xa9, - 0xbf, 0xae, 0xa9, 0x52, 0x65, 0xea, 0xef, 0xc2, 0xf9, 0x20, 0xa2, 0x56, 0x53, 0x63, 0x80}; - uint8_t bytesprops6[] = {0x3f, 0xc6, 0xf3}; - uint8_t bytesprops7[] = {0xe9, 0x13, 0xed, 0x8f, 0xa7, 0xbe, 0x72, 0xaa, 0x6f, 0xe6, 0x16, 0xf1, 0xfb, 0x8, 0x61}; - uint8_t bytesprops8[] = {0xff, 0x45, 0x5e, 0x6b, 0x4d, 0x3a, 0xee, 0x94, 0x1f, 0xf, 0xd3, 0xe7, 0x39, 0x64, - 0x4d, 0x20, 0xe3, 0xf4, 0x73, 0xa7, 0x1d, 0x92, 0x6e, 0x99, 0x89, 0xd1, 0xf9}; - uint8_t bytesprops9[] = {0x49, 0xa0, 0xfc, 0xcb, 0x66}; - uint8_t bytesprops10[] = {0x22, 0x27, 0x69, 0xb8, 0x66, 0xb, 0xc2, 0x9d, 0x62, 0x4a, 0xb5, 0x1}; + uint8_t pkt[] = {0xe0, 0x50, 0xa2, 0x4e, 0x13, 0x52, 0x78, 0x12, 0x0, 0xf, 0xcb, 0x93, 0xf5, 0x6a, 0x21, 0x4c, 0xec, + 0x39, 0x92, 0x47, 0xa9, 0xdc, 0xe5, 0x59, 0xe1, 0x2a, 0x1, 0x11, 0x0, 0x0, 0x6b, 0xb8, 0x16, 0x0, + 0xc, 0xe1, 0x5, 0xf9, 0x90, 0x48, 0xc4, 0x50, 0x4e, 0xa6, 0x19, 0x9a, 0x8a, 0x1a, 0x0, 0x1e, 0x98, + 0x97, 0xd3, 0x7c, 0xe6, 0x18, 0xeb, 0xf8, 0x14, 0x39, 0x5c, 0x86, 0x3a, 0x1a, 0x15, 0xb2, 0xb5, 0x96, + 0x4c, 0x48, 0xd4, 0x74, 0xfd, 0x76, 0xd6, 0x13, 0xd0, 0x4, 0xcf, 0x89, 0x17, 0x49}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xcb, 0x93, 0xf5, 0x6a, 0x21, 0x4c, 0xec, 0x39, 0x92, 0x47, 0xa9, 0xdc, 0xe5, 0x59, 0xe1}; + uint8_t bytesprops1[] = {0xe1, 0x5, 0xf9, 0x90, 0x48, 0xc4, 0x50, 0x4e, 0xa6, 0x19, 0x9a, 0x8a}; + uint8_t bytesprops2[] = {0x98, 0x97, 0xd3, 0x7c, 0xe6, 0x18, 0xeb, 0xf8, 0x14, 0x39, 0x5c, 0x86, 0x3a, 0x1a, 0x15, + 0xb2, 0xb5, 0x96, 0x4c, 0x48, 0xd4, 0x74, 0xfd, 0x76, 0xd6, 0x13, 0xd0, 0x4, 0xcf, 0x89}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26235}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14753}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23091}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18977}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30085}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9348}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24904}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16347}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25464}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20982}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21095}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21112}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27576}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 162, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoConnectionRateExceeded [PropAssignedClientIdentifier "",PropRequestProblemInformation -// 58,PropWillDelayInterval 26540,PropSessionExpiryInterval 10965,PropUserProperty -// "\243\&2QIy!8\EOT\f\ETX\204g\241}@\133\134o\US\FS\231_kx\248" "d\EOT\"0T\238\236",PropContentType -// "\ETX\211\NUL\181\DC47\131}",PropMessageExpiryInterval 24904,PropPayloadFormatIndicator 169,PropMessageExpiryInterval -// 23817,PropAssignedClientIdentifier "\176\ENQ\222VC\188,\164\NAK\DEL\169Gq\182",PropResponseTopic -// "\165\NAK\DC1y_53\211\t\254c\175\213M\NUL&y\b\236V^\246\225\141g\ESC>\173\130",PropPayloadFormatIndicator -// 183,PropSharedSubscriptionAvailable 115,PropWillDelayInterval 25597,PropServerKeepAlive -// 17658,PropSubscriptionIdentifier 2,PropMessageExpiryInterval 14628,PropSessionExpiryInterval 26147] +// DisconnectRequest DiscoMalformedPacket [PropAuthenticationMethod +// "\227\221a\197\144\178J\169\218x\205\239F\156\203S\219\STX"] TEST(Disco5QCTest, Encode17) { - uint8_t pkt[] = {0xe0, 0x97, 0x1, 0x9f, 0x94, 0x1, 0x12, 0x0, 0x0, 0x17, 0x3a, 0x18, 0x0, 0x0, 0x67, 0xac, - 0x11, 0x0, 0x0, 0x2a, 0xd5, 0x26, 0x0, 0x19, 0xf3, 0x32, 0x51, 0x49, 0x79, 0x21, 0x38, 0x4, - 0xc, 0x3, 0xcc, 0x67, 0xf1, 0x7d, 0x40, 0x85, 0x86, 0x6f, 0x1f, 0x1c, 0xe7, 0x5f, 0x6b, 0x78, - 0xf8, 0x0, 0x7, 0x64, 0x4, 0x22, 0x30, 0x54, 0xee, 0xec, 0x3, 0x0, 0x8, 0x3, 0xd3, 0x0, - 0xb5, 0x14, 0x37, 0x83, 0x7d, 0x2, 0x0, 0x0, 0x61, 0x48, 0x1, 0xa9, 0x2, 0x0, 0x0, 0x5d, - 0x9, 0x12, 0x0, 0xe, 0xb0, 0x5, 0xde, 0x56, 0x43, 0xbc, 0x2c, 0xa4, 0x15, 0x7f, 0xa9, 0x47, - 0x71, 0xb6, 0x8, 0x0, 0x1d, 0xa5, 0x15, 0x11, 0x79, 0x5f, 0x35, 0x33, 0xd3, 0x9, 0xfe, 0x63, - 0xaf, 0xd5, 0x4d, 0x0, 0x26, 0x79, 0x8, 0xec, 0x56, 0x5e, 0xf6, 0xe1, 0x8d, 0x67, 0x1b, 0x3e, - 0xad, 0x82, 0x1, 0xb7, 0x2a, 0x73, 0x18, 0x0, 0x0, 0x63, 0xfd, 0x13, 0x44, 0xfa, 0xb, 0x2, - 0x2, 0x0, 0x0, 0x39, 0x24, 0x11, 0x0, 0x0, 0x66, 0x23}; + uint8_t pkt[] = {0xe0, 0x17, 0x81, 0x15, 0x15, 0x0, 0x12, 0xe3, 0xdd, 0x61, 0xc5, 0x90, 0xb2, + 0x4a, 0xa9, 0xda, 0x78, 0xcd, 0xef, 0x46, 0x9c, 0xcb, 0x53, 0xdb, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops2[] = {0x64, 0x4, 0x22, 0x30, 0x54, 0xee, 0xec}; - uint8_t bytesprops1[] = {0xf3, 0x32, 0x51, 0x49, 0x79, 0x21, 0x38, 0x4, 0xc, 0x3, 0xcc, 0x67, 0xf1, - 0x7d, 0x40, 0x85, 0x86, 0x6f, 0x1f, 0x1c, 0xe7, 0x5f, 0x6b, 0x78, 0xf8}; - uint8_t bytesprops3[] = {0x3, 0xd3, 0x0, 0xb5, 0x14, 0x37, 0x83, 0x7d}; - uint8_t bytesprops4[] = {0xb0, 0x5, 0xde, 0x56, 0x43, 0xbc, 0x2c, 0xa4, 0x15, 0x7f, 0xa9, 0x47, 0x71, 0xb6}; - uint8_t bytesprops5[] = {0xa5, 0x15, 0x11, 0x79, 0x5f, 0x35, 0x33, 0xd3, 0x9, 0xfe, 0x63, 0xaf, 0xd5, 0x4d, 0x0, - 0x26, 0x79, 0x8, 0xec, 0x56, 0x5e, 0xf6, 0xe1, 0x8d, 0x67, 0x1b, 0x3e, 0xad, 0x82}; + uint8_t bytesprops0[] = {0xe3, 0xdd, 0x61, 0xc5, 0x90, 0xb2, 0x4a, 0xa9, 0xda, + 0x78, 0xcd, 0xef, 0x46, 0x9c, 0xcb, 0x53, 0xdb, 0x2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26540}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10965}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops1}, .v = {7, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24904}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23817}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25597}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17658}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14628}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26147}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 129, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoReceiveMaximumExceeded [PropTopicAliasMaximum 7621,PropSubscriptionIdentifierAvailable -// 53,PropReceiveMaximum 8235,PropServerReference "\208-:Qp\231\239N\134\171/qe",PropReasonString -// "<\ENQ\164^k\164\DLEMH\237]3Z\196\158\177\201\ETX$\130\171g\204",PropWillDelayInterval -// 19719,PropSharedSubscriptionAvailable 115,PropAssignedClientIdentifier -// "\169{(\NAK\225\219\r-\157\169\240Xa\144\145\229\217",PropMaximumQoS 235,PropRetainAvailable -// 74,PropAuthenticationData "\152K",PropResponseInformation -// "w\149\151\221\147\238X\v\NUL\142<\DEL\178\t\130\nz\134\227N5",PropAuthenticationData -// "\180\199\128\217c\144\&8\227\&3\136\180\ENQ\FSFG\236\135\143p\139\SOH\128",PropSubscriptionIdentifier -// 24,PropTopicAliasMaximum 3541,PropPayloadFormatIndicator 8,PropSessionExpiryInterval 26303,PropAuthenticationMethod -// ",\230=\151\248\199z\191-$\223\239\154\154\193\196\177\157\153\181I\209\230\132<",PropSessionExpiryInterval -// 2383,PropSessionExpiryInterval 30622,PropRetainAvailable 28,PropSessionExpiryInterval 73,PropCorrelationData -// "\171\218\201\177ZS 5\133\STX\207\181d\\Cx\249\169\183\NAK}h\198\FSpH",PropMaximumQoS -// 135,PropAssignedClientIdentifier "\204~{",PropAuthenticationMethod "Yb",PropAuthenticationMethod -// "E\165\228\205\244\208h\210\129F\128\209\162\157c\219\US\153\149\237\255\137}\170\162t,"] +// DisconnectRequest DiscoServerBusy [PropCorrelationData +// "\242\168\171&\RS\132\166\131\176\220\230\252\155\RS\ACK\162\&4,s\160\131\&4\197",PropAuthenticationData +// "",PropContentType "m 0\129\192cM\134\143\211\193\168\174\235i3t\219\DEL\149B\165",PropSubscriptionIdentifier +// 2,PropUserProperty "O\164z\NULJC\EM\234\155a3\139\&6kk\214\161\129F\146\&1\140" +// "\156\241",PropRequestResponseInformation 44,PropWillDelayInterval 30451,PropServerKeepAlive 24287] TEST(Disco5QCTest, Encode18) { - uint8_t pkt[] = {0xe0, 0x8b, 0x2, 0x93, 0x88, 0x2, 0x22, 0x1d, 0xc5, 0x29, 0x35, 0x21, 0x20, 0x2b, 0x1c, 0x0, 0xd, - 0xd0, 0x2d, 0x3a, 0x51, 0x70, 0xe7, 0xef, 0x4e, 0x86, 0xab, 0x2f, 0x71, 0x65, 0x1f, 0x0, 0x17, 0x3c, - 0x5, 0xa4, 0x5e, 0x6b, 0xa4, 0x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, 0x24, 0x87, 0x12, 0x0, 0x3, 0xcc, 0x7e, 0x7b, 0x15, 0x0, 0x2, - 0x59, 0x62, 0x15, 0x0, 0x1b, 0x45, 0xa5, 0xe4, 0xcd, 0xf4, 0xd0, 0x68, 0xd2, 0x81, 0x46, 0x80, 0xd1, - 0xa2, 0x9d, 0x63, 0xdb, 0x1f, 0x99, 0x95, 0xed, 0xff, 0x89, 0x7d, 0xaa, 0xa2, 0x74, 0x2c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd0, 0x2d, 0x3a, 0x51, 0x70, 0xe7, 0xef, 0x4e, 0x86, 0xab, 0x2f, 0x71, 0x65}; - uint8_t bytesprops1[] = {0x3c, 0x5, 0xa4, 0x5e, 0x6b, 0xa4, 0x10, 0x4d, 0x48, 0xed, 0x5d, 0x33, - 0x5a, 0xc4, 0x9e, 0xb1, 0xc9, 0x3, 0x24, 0x82, 0xab, 0x67, 0xcc}; - uint8_t bytesprops2[] = {0xa9, 0x7b, 0x28, 0x15, 0xe1, 0xdb, 0xd, 0x2d, 0x9d, - 0xa9, 0xf0, 0x58, 0x61, 0x90, 0x91, 0xe5, 0xd9}; - uint8_t bytesprops3[] = {0x98, 0x4b}; - uint8_t bytesprops4[] = {0x77, 0x95, 0x97, 0xdd, 0x93, 0xee, 0x58, 0xb, 0x0, 0x8e, 0x3c, - 0x7f, 0xb2, 0x9, 0x82, 0xa, 0x7a, 0x86, 0xe3, 0x4e, 0x35}; - uint8_t bytesprops5[] = {0xb4, 0xc7, 0x80, 0xd9, 0x63, 0x90, 0x38, 0xe3, 0x33, 0x88, 0xb4, - 0x5, 0x1c, 0x46, 0x47, 0xec, 0x87, 0x8f, 0x70, 0x8b, 0x1, 0x80}; - uint8_t bytesprops6[] = {0x2c, 0xe6, 0x3d, 0x97, 0xf8, 0xc7, 0x7a, 0xbf, 0x2d, 0x24, 0xdf, 0xef, 0x9a, - 0x9a, 0xc1, 0xc4, 0xb1, 0x9d, 0x99, 0xb5, 0x49, 0xd1, 0xe6, 0x84, 0x3c}; - uint8_t bytesprops7[] = {0xab, 0xda, 0xc9, 0xb1, 0x5a, 0x53, 0x20, 0x35, 0x85, 0x2, 0xcf, 0xb5, 0x64, - 0x5c, 0x43, 0x78, 0xf9, 0xa9, 0xb7, 0x15, 0x7d, 0x68, 0xc6, 0x1c, 0x70, 0x48}; - uint8_t bytesprops8[] = {0xcc, 0x7e, 0x7b}; - uint8_t bytesprops9[] = {0x59, 0x62}; - uint8_t bytesprops10[] = {0x45, 0xa5, 0xe4, 0xcd, 0xf4, 0xd0, 0x68, 0xd2, 0x81, 0x46, 0x80, 0xd1, 0xa2, 0x9d, - 0x63, 0xdb, 0x1f, 0x99, 0x95, 0xed, 0xff, 0x89, 0x7d, 0xaa, 0xa2, 0x74, 0x2c}; + uint8_t pkt[] = {0xe0, 0x61, 0x89, 0x5f, 0x9, 0x0, 0x17, 0xf2, 0xa8, 0xab, 0x26, 0x1e, 0x84, 0xa6, 0x83, 0xb0, 0xdc, + 0xe6, 0xfc, 0x9b, 0x1e, 0x6, 0xa2, 0x34, 0x2c, 0x73, 0xa0, 0x83, 0x34, 0xc5, 0x16, 0x0, 0x0, 0x3, + 0x0, 0x16, 0x6d, 0x20, 0x30, 0x81, 0xc0, 0x63, 0x4d, 0x86, 0x8f, 0xd3, 0xc1, 0xa8, 0xae, 0xeb, 0x69, + 0x33, 0x74, 0xdb, 0x7f, 0x95, 0x42, 0xa5, 0xb, 0x2, 0x26, 0x0, 0x16, 0x4f, 0xa4, 0x7a, 0x0, 0x4a, + 0x43, 0x19, 0xea, 0x9b, 0x61, 0x33, 0x8b, 0x36, 0x6b, 0x6b, 0xd6, 0xa1, 0x81, 0x46, 0x92, 0x31, 0x8c, + 0x0, 0x2, 0x9c, 0xf1, 0x19, 0x2c, 0x18, 0x0, 0x0, 0x76, 0xf3, 0x13, 0x5e, 0xdf}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf2, 0xa8, 0xab, 0x26, 0x1e, 0x84, 0xa6, 0x83, 0xb0, 0xdc, 0xe6, 0xfc, + 0x9b, 0x1e, 0x6, 0xa2, 0x34, 0x2c, 0x73, 0xa0, 0x83, 0x34, 0xc5}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x6d, 0x20, 0x30, 0x81, 0xc0, 0x63, 0x4d, 0x86, 0x8f, 0xd3, 0xc1, + 0xa8, 0xae, 0xeb, 0x69, 0x33, 0x74, 0xdb, 0x7f, 0x95, 0x42, 0xa5}; + uint8_t bytesprops4[] = {0x9c, 0xf1}; + uint8_t bytesprops3[] = {0x4f, 0xa4, 0x7a, 0x0, 0x4a, 0x43, 0x19, 0xea, 0x9b, 0x61, 0x33, + 0x8b, 0x36, 0x6b, 0x6b, 0xd6, 0xa1, 0x81, 0x46, 0x92, 0x31, 0x8c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7621}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8235}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19719}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3541}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26303}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2383}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30622}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 73}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops3}, .v = {2, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30451}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24287}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 147, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 137, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoDisconnectWithWill [PropAuthenticationData -// "@\ACK\248%\233\FSHv\216",PropAssignedClientIdentifier -// "$\SUB\226\129\156hO\148j\179\180w\159\161\230Mw6\156S\198\f",PropContentType -// "|\b\136#\SYN\131\179\168\&8\167\201\157]\179\142%-\a\150\132\132",PropResponseTopic -// "%\253",PropRequestProblemInformation 226,PropSubscriptionIdentifier 10,PropRetainAvailable 101,PropServerKeepAlive -// 4043,PropRequestProblemInformation 24,PropRetainAvailable 35,PropContentType -// "\DC3\159\128\255\v'\194\225\152\ESC",PropRetainAvailable 166] +// DisconnectRequest DiscoDisconnectWithWill [PropWillDelayInterval 27833,PropResponseInformation +// "|&d\n\193\232\187\207o9c\230\GS\203\174Y\228\RS\204\152\DLE\RSZk\255v\190",PropAssignedClientIdentifier +// "\244\218eE\228\160\159`\DC2\202\138\143V}\219\&3\152\ETX",PropTopicAliasMaximum 9595,PropSubscriptionIdentifier 7] TEST(Disco5QCTest, Encode19) { - uint8_t pkt[] = {0xe0, 0x60, 0x4, 0x5e, 0x16, 0x0, 0x9, 0x40, 0x6, 0xf8, 0x25, 0xe9, 0x1c, 0x48, 0x76, 0xd8, 0x12, - 0x0, 0x16, 0x24, 0x1a, 0xe2, 0x81, 0x9c, 0x68, 0x4f, 0x94, 0x6a, 0xb3, 0xb4, 0x77, 0x9f, 0xa1, 0xe6, - 0x4d, 0x77, 0x36, 0x9c, 0x53, 0xc6, 0xc, 0x3, 0x0, 0x15, 0x7c, 0x8, 0x88, 0x23, 0x16, 0x83, 0xb3, - 0xa8, 0x38, 0xa7, 0xc9, 0x9d, 0x5d, 0xb3, 0x8e, 0x25, 0x2d, 0x7, 0x96, 0x84, 0x84, 0x8, 0x0, 0x2, - 0x25, 0xfd, 0x17, 0xe2, 0xb, 0xa, 0x25, 0x65, 0x13, 0xf, 0xcb, 0x17, 0x18, 0x25, 0x23, 0x3, 0x0, - 0xa, 0x13, 0x9f, 0x80, 0xff, 0xb, 0x27, 0xc2, 0xe1, 0x98, 0x1b, 0x25, 0xa6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x40, 0x6, 0xf8, 0x25, 0xe9, 0x1c, 0x48, 0x76, 0xd8}; - uint8_t bytesprops1[] = {0x24, 0x1a, 0xe2, 0x81, 0x9c, 0x68, 0x4f, 0x94, 0x6a, 0xb3, 0xb4, - 0x77, 0x9f, 0xa1, 0xe6, 0x4d, 0x77, 0x36, 0x9c, 0x53, 0xc6, 0xc}; - uint8_t bytesprops2[] = {0x7c, 0x8, 0x88, 0x23, 0x16, 0x83, 0xb3, 0xa8, 0x38, 0xa7, 0xc9, - 0x9d, 0x5d, 0xb3, 0x8e, 0x25, 0x2d, 0x7, 0x96, 0x84, 0x84}; - uint8_t bytesprops3[] = {0x25, 0xfd}; - uint8_t bytesprops4[] = {0x13, 0x9f, 0x80, 0xff, 0xb, 0x27, 0xc2, 0xe1, 0x98, 0x1b}; + uint8_t pkt[] = {0xe0, 0x3f, 0x4, 0x3d, 0x18, 0x0, 0x0, 0x6c, 0xb9, 0x1a, 0x0, 0x1b, 0x7c, 0x26, 0x64, 0xa, 0xc1, + 0xe8, 0xbb, 0xcf, 0x6f, 0x39, 0x63, 0xe6, 0x1d, 0xcb, 0xae, 0x59, 0xe4, 0x1e, 0xcc, 0x98, 0x10, 0x1e, + 0x5a, 0x6b, 0xff, 0x76, 0xbe, 0x12, 0x0, 0x12, 0xf4, 0xda, 0x65, 0x45, 0xe4, 0xa0, 0x9f, 0x60, 0x12, + 0xca, 0x8a, 0x8f, 0x56, 0x7d, 0xdb, 0x33, 0x98, 0x3, 0x22, 0x25, 0x7b, 0xb, 0x7}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7c, 0x26, 0x64, 0xa, 0xc1, 0xe8, 0xbb, 0xcf, 0x6f, 0x39, 0x63, 0xe6, 0x1d, 0xcb, + 0xae, 0x59, 0xe4, 0x1e, 0xcc, 0x98, 0x10, 0x1e, 0x5a, 0x6b, 0xff, 0x76, 0xbe}; + uint8_t bytesprops1[] = {0xf4, 0xda, 0x65, 0x45, 0xe4, 0xa0, 0x9f, 0x60, 0x12, + 0xca, 0x8a, 0x8f, 0x56, 0x7d, 0xdb, 0x33, 0x98, 0x3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4043}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27833}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9595}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); EXPECT_EQ(err, LWMQTT_SUCCESS); @@ -22923,594 +23936,596 @@ TEST(Disco5QCTest, Encode19) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoMaximumConnectTime [PropPayloadFormatIndicator 64,PropRetainAvailable 191,PropTopicAlias -// 20889,PropServerReference "6Kc4;*}\238\DC3\179\ETXT",PropServerKeepAlive 29920,PropReceiveMaximum -// 10201,PropWillDelayInterval 658,PropWillDelayInterval 28824,PropUserProperty "\230\132\149.\219" -// "\n\204\n\154\&3\GS\132\ENQ6",PropServerKeepAlive 7761,PropTopicAliasMaximum 13346,PropSubscriptionIdentifier -// 14,PropRequestProblemInformation 179,PropTopicAliasMaximum 26363,PropSessionExpiryInterval 12423,PropReasonString -// "pT6D\r@\153\162\184\138w+\233\&6\172\206\DC4]\129\&5\164\GS\208\179\187P\207\231"] +// DisconnectRequest DiscoTopicNameInvalid [PropPayloadFormatIndicator 242,PropTopicAlias +// 3083,PropSubscriptionIdentifier 17] TEST(Disco5QCTest, Encode20) { - uint8_t pkt[] = {0xe0, 0x6c, 0xa0, 0x6a, 0x1, 0x40, 0x25, 0xbf, 0x23, 0x51, 0x99, 0x1c, 0x0, 0xc, 0x36, 0x4b, - 0x63, 0x34, 0x3b, 0x2a, 0x7d, 0xee, 0x13, 0xb3, 0x3, 0x54, 0x13, 0x74, 0xe0, 0x21, 0x27, 0xd9, - 0x18, 0x0, 0x0, 0x2, 0x92, 0x18, 0x0, 0x0, 0x70, 0x98, 0x26, 0x0, 0x5, 0xe6, 0x84, 0x95, - 0x2e, 0xdb, 0x0, 0x9, 0xa, 0xcc, 0xa, 0x9a, 0x33, 0x1d, 0x84, 0x5, 0x36, 0x13, 0x1e, 0x51, - 0x22, 0x34, 0x22, 0xb, 0xe, 0x17, 0xb3, 0x22, 0x66, 0xfb, 0x11, 0x0, 0x0, 0x30, 0x87, 0x1f, - 0x0, 0x1c, 0x70, 0x54, 0x36, 0x44, 0xd, 0x40, 0x99, 0xa2, 0xb8, 0x8a, 0x77, 0x2b, 0xe9, 0x36, - 0xac, 0xce, 0x14, 0x5d, 0x81, 0x35, 0xa4, 0x1d, 0xd0, 0xb3, 0xbb, 0x50, 0xcf, 0xe7}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x36, 0x4b, 0x63, 0x34, 0x3b, 0x2a, 0x7d, 0xee, 0x13, 0xb3, 0x3, 0x54}; - uint8_t bytesprops2[] = {0xa, 0xcc, 0xa, 0x9a, 0x33, 0x1d, 0x84, 0x5, 0x36}; - uint8_t bytesprops1[] = {0xe6, 0x84, 0x95, 0x2e, 0xdb}; - uint8_t bytesprops3[] = {0x70, 0x54, 0x36, 0x44, 0xd, 0x40, 0x99, 0xa2, 0xb8, 0x8a, 0x77, 0x2b, 0xe9, 0x36, - 0xac, 0xce, 0x14, 0x5d, 0x81, 0x35, 0xa4, 0x1d, 0xd0, 0xb3, 0xbb, 0x50, 0xcf, 0xe7}; + uint8_t pkt[] = {0xe0, 0x9, 0x90, 0x7, 0x1, 0xf2, 0x23, 0xc, 0xb, 0xb, 0x11}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20889}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29920}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10201}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 658}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28824}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops1}, .v = {9, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7761}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13346}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26363}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12423}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3083}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 160, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoNotAuthorized [PropServerReference -// "\143\194@H\238\228\a\135\194>\200;\143\128\144M\ETX",PropReceiveMaximum 9209,PropServerReference -// "\254\155pu\225",PropMaximumQoS 188,PropServerReference "j\ENQ",PropSharedSubscriptionAvailable -// 103,PropSharedSubscriptionAvailable 206,PropTopicAlias 31456,PropResponseTopic -// "\205\&7b\203kH\224g\RSi\183\"\178\250\188\t",PropContentType "\186\&8\131\210d\"\163\196\133\162l\178p\131 -// \249\&7\n3\187\248\138\233\199\"\CAN\233\204\146",PropContentType "}\216",PropAuthenticationMethod -// "\191\SO",PropMessageExpiryInterval 25961,PropRetainAvailable 53] +// DisconnectRequest DiscoReceiveMaximumExceeded [PropMaximumQoS 118,PropReceiveMaximum 6069,PropServerReference +// "\189\&3`\210\132\222\203\SOH\153>F6\156\244Ll3an.\178\STX\240\227\186: ",PropRequestProblemInformation +// 52,PropServerKeepAlive 8463,PropWillDelayInterval 16370,PropWildcardSubscriptionAvailable +// 78,PropSubscriptionIdentifier 25,PropAuthenticationMethod +// "\150\bs\128\128\233T\US\SI\164\223\ENQ\FS\174^=\153\&2g\136'\190#\254",PropAuthenticationMethod +// "rn\128\&8F\206\154{\185\206\153>@",PropMessageExpiryInterval 25716,PropUserProperty +// "\174F\215\140j\DC1:\183g\171!\155\216\132\244\DC4\229\aQ\176\141\159\&7!" +// "S\162\146\205\n\213\183\174\ACK\154P\\\USg",PropMaximumQoS 90,PropReceiveMaximum +// 16541,PropSharedSubscriptionAvailable 103,PropAssignedClientIdentifier "\250\145\225\187DQ",PropCorrelationData +// "J\SYN7\194S\218\181\"\231\135\\\145\167\186\&0\167Y\b\b\ETBh\US\225",PropMaximumPacketSize +// 14554,PropResponseInformation "\206\GS\195",PropTopicAlias 10203,PropSubscriptionIdentifierAvailable +// 102,PropTopicAliasMaximum 18623,PropContentType +// "\197\173\166\250\171\168\165$|:|\237s\STXL\169x\DC3\232\136\&2\182\254\221\STX\241?\194"] TEST(Disco5QCTest, Encode21) { - uint8_t pkt[] = {0xe0, 0x73, 0x87, 0x71, 0x1c, 0x0, 0x11, 0x8f, 0xc2, 0x40, 0x48, 0xee, 0xe4, 0x7, 0x87, 0xc2, 0x3e, - 0xc8, 0x3b, 0x8f, 0x80, 0x90, 0x4d, 0x3, 0x21, 0x23, 0xf9, 0x1c, 0x0, 0x5, 0xfe, 0x9b, 0x70, 0x75, - 0xe1, 0x24, 0xbc, 0x1c, 0x0, 0x2, 0x6a, 0x5, 0x2a, 0x67, 0x2a, 0xce, 0x23, 0x7a, 0xe0, 0x8, 0x0, - 0x10, 0xcd, 0x37, 0x62, 0xcb, 0x6b, 0x48, 0xe0, 0x67, 0x1e, 0x69, 0xb7, 0x22, 0xb2, 0xfa, 0xbc, 0x9, - 0x3, 0x0, 0x1d, 0xba, 0x38, 0x83, 0xd2, 0x64, 0x22, 0xa3, 0xc4, 0x85, 0xa2, 0x6c, 0xb2, 0x70, 0x83, - 0x20, 0xf9, 0x37, 0xa, 0x33, 0xbb, 0xf8, 0x8a, 0xe9, 0xc7, 0x22, 0x18, 0xe9, 0xcc, 0x92, 0x3, 0x0, - 0x2, 0x7d, 0xd8, 0x15, 0x0, 0x2, 0xbf, 0xe, 0x2, 0x0, 0x0, 0x65, 0x69, 0x25, 0x35}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x8f, 0xc2, 0x40, 0x48, 0xee, 0xe4, 0x7, 0x87, 0xc2, - 0x3e, 0xc8, 0x3b, 0x8f, 0x80, 0x90, 0x4d, 0x3}; - uint8_t bytesprops1[] = {0xfe, 0x9b, 0x70, 0x75, 0xe1}; - uint8_t bytesprops2[] = {0x6a, 0x5}; - uint8_t bytesprops3[] = {0xcd, 0x37, 0x62, 0xcb, 0x6b, 0x48, 0xe0, 0x67, - 0x1e, 0x69, 0xb7, 0x22, 0xb2, 0xfa, 0xbc, 0x9}; - uint8_t bytesprops4[] = {0xba, 0x38, 0x83, 0xd2, 0x64, 0x22, 0xa3, 0xc4, 0x85, 0xa2, 0x6c, 0xb2, 0x70, 0x83, 0x20, - 0xf9, 0x37, 0xa, 0x33, 0xbb, 0xf8, 0x8a, 0xe9, 0xc7, 0x22, 0x18, 0xe9, 0xcc, 0x92}; - uint8_t bytesprops5[] = {0x7d, 0xd8}; - uint8_t bytesprops6[] = {0xbf, 0xe}; + uint8_t pkt[] = { + 0xe0, 0xeb, 0x1, 0x93, 0xe8, 0x1, 0x24, 0x76, 0x21, 0x17, 0xb5, 0x1c, 0x0, 0x1b, 0xbd, 0x33, 0x60, 0xd2, 0x84, + 0xde, 0xcb, 0x1, 0x99, 0x3e, 0x46, 0x36, 0x9c, 0xf4, 0x4c, 0x6c, 0x33, 0x61,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c, 0xed, 0x73, 0x2, 0x4c, 0xa9, 0x78, 0x13, + 0xe8, 0x88, 0x32, 0xb6, 0xfe, 0xdd, 0x2, 0xf1, 0x3f, 0xc2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbd, 0x33, 0x60, 0xd2, 0x84, 0xde, 0xcb, 0x1, 0x99, 0x3e, 0x46, 0x36, 0x9c, 0xf4, + 0x4c, 0x6c, 0x33, 0x61, 0x6e, 0x2e, 0xb2, 0x2, 0xf0, 0xe3, 0xba, 0x3a, 0x20}; + uint8_t bytesprops1[] = {0x96, 0x8, 0x73, 0x80, 0x80, 0xe9, 0x54, 0x1f, 0xf, 0xa4, 0xdf, 0x5, + 0x1c, 0xae, 0x5e, 0x3d, 0x99, 0x32, 0x67, 0x88, 0x27, 0xbe, 0x23, 0xfe}; + uint8_t bytesprops2[] = {0x72, 0x6e, 0x80, 0x38, 0x46, 0xce, 0x9a, 0x7b, 0xb9, 0xce, 0x99, 0x3e, 0x40}; + uint8_t bytesprops4[] = {0x53, 0xa2, 0x92, 0xcd, 0xa, 0xd5, 0xb7, 0xae, 0x6, 0x9a, 0x50, 0x5c, 0x1f, 0x67}; + uint8_t bytesprops3[] = {0xae, 0x46, 0xd7, 0x8c, 0x6a, 0x11, 0x3a, 0xb7, 0x67, 0xab, 0x21, 0x9b, + 0xd8, 0x84, 0xf4, 0x14, 0xe5, 0x7, 0x51, 0xb0, 0x8d, 0x9f, 0x37, 0x21}; + uint8_t bytesprops5[] = {0xfa, 0x91, 0xe1, 0xbb, 0x44, 0x51}; + uint8_t bytesprops6[] = {0x4a, 0x16, 0x37, 0xc2, 0x53, 0xda, 0xb5, 0x22, 0xe7, 0x87, 0x5c, 0x91, + 0xa7, 0xba, 0x30, 0xa7, 0x59, 0x8, 0x8, 0x17, 0x68, 0x1f, 0xe1}; + uint8_t bytesprops7[] = {0xce, 0x1d, 0xc3}; + uint8_t bytesprops8[] = {0xc5, 0xad, 0xa6, 0xfa, 0xab, 0xa8, 0xa5, 0x24, 0x7c, 0x3a, 0x7c, 0xed, 0x73, 0x2, + 0x4c, 0xa9, 0x78, 0x13, 0xe8, 0x88, 0x32, 0xb6, 0xfe, 0xdd, 0x2, 0xf1, 0x3f, 0xc2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9209}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6069}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8463}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16370}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25716}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops3}, .v = {14, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16541}}, {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31456}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25961}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14554}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10203}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18623}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 135, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 147, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoImplementationSpecificError [PropAuthenticationMethod -// "cr,\ACK\bC/\227\NAK\152\228\176\144\192t\v\"\246\130`_",PropMaximumPacketSize 14029,PropSessionExpiryInterval -// 12586,PropRequestResponseInformation 115,PropMaximumPacketSize 6061,PropServerReference -// "$\ACK\138\&0\208\247l\180\253~u\132\ESC\STX\ETBD\r\ETBc\DC3\180\149\140\164\129\183\134\140",PropResponseInformation -// "t",PropSubscriptionIdentifier 17,PropServerKeepAlive 20492,PropTopicAliasMaximum 14027,PropCorrelationData -// "\169\&8\135\SOH\aKzAK~E}\182\236\RS\161\208J8\155Y\202\136\v\196\230\240\ETB",PropServerReference -// "\163\229\183,\196\208\244\188q\166U\ETXh\EM",PropCorrelationData -// "\158\DC4\187\223\140\135oV\t7F\SOH/G\202\177\146\216iMA\ENQ\230\148"] +// DisconnectRequest DiscoNormalDisconnection [PropAssignedClientIdentifier +// "$\187:\SOH\237\204\231\196G",PropSessionExpiryInterval 18636,PropAssignedClientIdentifier +// "\ETXTo5\144\186",PropMaximumPacketSize 7534,PropReceiveMaximum 16577,PropMessageExpiryInterval +// 6685,PropRetainAvailable 107,PropRequestProblemInformation 90,PropAssignedClientIdentifier +// "*X\SOH\EOTl\US\SUB\148",PropPayloadFormatIndicator 73,PropContentType +// "\171\162\137\USX\b-a\a\190\nt\FS\175\DC4pqNv\208S\152I\159\&0",PropMaximumPacketSize +// 19535,PropSubscriptionIdentifier 9,PropResponseInformation "\228\198qN6\156C\149}\ACK\255)h\152)\155Gs\181\175\246"] TEST(Disco5QCTest, Encode22) { - uint8_t pkt[] = {0xe0, 0xa2, 0x1, 0x83, 0x9f, 0x1, 0x15, 0x0, 0x15, 0x63, 0x72, 0x2c, 0x6, 0x8, 0x43, 0x2f, 0xe3, - 0x15, 0x98, 0xe4, 0xb0, 0x90, 0xc0, 0x74, 0xb, 0x22, 0xf6, 0x82, 0x60, 0x5f, 0x27, 0x0, 0x0, 0x36, - 0xcd, 0x11, 0x0, 0x0, 0x31, 0x2a, 0x19, 0x73, 0x27, 0x0, 0x0, 0x17, 0xad, 0x1c, 0x0, 0x1c, 0x24, - 0x6, 0x8a, 0x30, 0xd0, 0xf7, 0x6c, 0xb4, 0xfd, 0x7e, 0x75, 0x84, 0x1b, 0x2, 0x17, 0x44, 0xd, 0x17, - 0x63, 0x13, 0xb4, 0x95, 0x8c, 0xa4, 0x81, 0xb7, 0x86, 0x8c, 0x1a, 0x0, 0x1, 0x74, 0xb, 0x11, 0x13, - 0x50, 0xc, 0x22, 0x36, 0xcb, 0x9, 0x0, 0x1c, 0xa9, 0x38, 0x87, 0x1, 0x7, 0x4b, 0x7a, 0x41, 0x4b, - 0x7e, 0x45, 0x7d, 0xb6, 0xec, 0x1e, 0xa1, 0xd0, 0x4a, 0x38, 0x9b, 0x59, 0xca, 0x88, 0xb, 0xc4, 0xe6, - 0xf0, 0x17, 0x1c, 0x0, 0xe, 0xa3, 0xe5, 0xb7, 0x2c, 0xc4, 0xd0, 0xf4, 0xbc, 0x71, 0xa6, 0x55, 0x3, - 0x68, 0x19, 0x9, 0x0, 0x18, 0x9e, 0x14, 0xbb, 0xdf, 0x8c, 0x87, 0x6f, 0x56, 0x9, 0x37, 0x46, 0x1, - 0x2f, 0x47, 0xca, 0xb1, 0x92, 0xd8, 0x69, 0x4d, 0x41, 0x5, 0xe6, 0x94}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x63, 0x72, 0x2c, 0x6, 0x8, 0x43, 0x2f, 0xe3, 0x15, 0x98, 0xe4, - 0xb0, 0x90, 0xc0, 0x74, 0xb, 0x22, 0xf6, 0x82, 0x60, 0x5f}; - uint8_t bytesprops1[] = {0x24, 0x6, 0x8a, 0x30, 0xd0, 0xf7, 0x6c, 0xb4, 0xfd, 0x7e, 0x75, 0x84, 0x1b, 0x2, - 0x17, 0x44, 0xd, 0x17, 0x63, 0x13, 0xb4, 0x95, 0x8c, 0xa4, 0x81, 0xb7, 0x86, 0x8c}; - uint8_t bytesprops2[] = {0x74}; - uint8_t bytesprops3[] = {0xa9, 0x38, 0x87, 0x1, 0x7, 0x4b, 0x7a, 0x41, 0x4b, 0x7e, 0x45, 0x7d, 0xb6, 0xec, - 0x1e, 0xa1, 0xd0, 0x4a, 0x38, 0x9b, 0x59, 0xca, 0x88, 0xb, 0xc4, 0xe6, 0xf0, 0x17}; - uint8_t bytesprops4[] = {0xa3, 0xe5, 0xb7, 0x2c, 0xc4, 0xd0, 0xf4, 0xbc, 0x71, 0xa6, 0x55, 0x3, 0x68, 0x19}; - uint8_t bytesprops5[] = {0x9e, 0x14, 0xbb, 0xdf, 0x8c, 0x87, 0x6f, 0x56, 0x9, 0x37, 0x46, 0x1, - 0x2f, 0x47, 0xca, 0xb1, 0x92, 0xd8, 0x69, 0x4d, 0x41, 0x5, 0xe6, 0x94}; + uint8_t pkt[] = {0xe0, 0x75, 0x0, 0x73, 0x12, 0x0, 0x9, 0x24, 0xbb, 0x3a, 0x1, 0xed, 0xcc, 0xe7, 0xc4, + 0x47, 0x11, 0x0, 0x0, 0x48, 0xcc, 0x12, 0x0, 0x6, 0x3, 0x54, 0x6f, 0x35, 0x90, 0xba, + 0x27, 0x0, 0x0, 0x1d, 0x6e, 0x21, 0x40, 0xc1, 0x2, 0x0, 0x0, 0x1a, 0x1d, 0x25, 0x6b, + 0x17, 0x5a, 0x12, 0x0, 0x8, 0x2a, 0x58, 0x1, 0x4, 0x6c, 0x1f, 0x1a, 0x94, 0x1, 0x49, + 0x3, 0x0, 0x19, 0xab, 0xa2, 0x89, 0x1f, 0x58, 0x8, 0x2d, 0x61, 0x7, 0xbe, 0xa, 0x74, + 0x1c, 0xaf, 0x14, 0x70, 0x71, 0x4e, 0x76, 0xd0, 0x53, 0x98, 0x49, 0x9f, 0x30, 0x27, 0x0, + 0x0, 0x4c, 0x4f, 0xb, 0x9, 0x1a, 0x0, 0x15, 0xe4, 0xc6, 0x71, 0x4e, 0x36, 0x9c, 0x43, + 0x95, 0x7d, 0x6, 0xff, 0x29, 0x68, 0x98, 0x29, 0x9b, 0x47, 0x73, 0xb5, 0xaf, 0xf6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x24, 0xbb, 0x3a, 0x1, 0xed, 0xcc, 0xe7, 0xc4, 0x47}; + uint8_t bytesprops1[] = {0x3, 0x54, 0x6f, 0x35, 0x90, 0xba}; + uint8_t bytesprops2[] = {0x2a, 0x58, 0x1, 0x4, 0x6c, 0x1f, 0x1a, 0x94}; + uint8_t bytesprops3[] = {0xab, 0xa2, 0x89, 0x1f, 0x58, 0x8, 0x2d, 0x61, 0x7, 0xbe, 0xa, 0x74, 0x1c, + 0xaf, 0x14, 0x70, 0x71, 0x4e, 0x76, 0xd0, 0x53, 0x98, 0x49, 0x9f, 0x30}; + uint8_t bytesprops4[] = {0xe4, 0xc6, 0x71, 0x4e, 0x36, 0x9c, 0x43, 0x95, 0x7d, 0x6, 0xff, + 0x29, 0x68, 0x98, 0x29, 0x9b, 0x47, 0x73, 0xb5, 0xaf, 0xf6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14029}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12586}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6061}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20492}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14027}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18636}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7534}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16577}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6685}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19535}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 131, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoTopicNameInvalid [PropTopicAliasMaximum 26497,PropRetainAvailable 72,PropReceiveMaximum -// 481,PropServerReference "",PropReceiveMaximum 1240,PropSubscriptionIdentifierAvailable 54,PropTopicAliasMaximum -// 14770,PropMessageExpiryInterval 24223,PropUserProperty "Y\244\136I\175\250\238\"u\223a\155" -// "\SOF\134\STX\181\&2\174\243\244\&3\192m\149\215F\144[\214\SYN\NAK\253\151\167\140\225-\DEL\rG\149",PropResponseTopic -// "\180U\fQ\144\&2\254\142\179\DC42N\128m\ESC\206\157=@\213%\253#",PropSubscriptionIdentifier 20,PropReasonString -// "^\215\146\207!2r\GS\156[M\236\247G<-)5C\150",PropReasonString "\129%z",PropRetainAvailable 39,PropTopicAliasMaximum -// 7771] +// DisconnectRequest DiscoNormalDisconnection [PropAssignedClientIdentifier +// "\239\236\193{\250\139\193O\220\250\EM>\193B",PropMessageExpiryInterval 19122,PropServerKeepAlive +// 32735,PropPayloadFormatIndicator 218,PropMessageExpiryInterval 28266,PropWildcardSubscriptionAvailable +// 233,PropWildcardSubscriptionAvailable 8,PropAssignedClientIdentifier +// "=:\174qX\199\243\226l\\`p\172i\153!-t\DC3DG\169\171\ETXx\239\fr3"] TEST(Disco5QCTest, Encode23) { - uint8_t pkt[] = {0xe0, 0x88, 0x1, 0x90, 0x85, 0x1, 0x22, 0x67, 0x81, 0x25, 0x48, 0x21, 0x1, 0xe1, 0x1c, 0x0, - 0x0, 0x21, 0x4, 0xd8, 0x29, 0x36, 0x22, 0x39, 0xb2, 0x2, 0x0, 0x0, 0x5e, 0x9f, 0x26, 0x0, - 0xc, 0x59, 0xf4, 0x88, 0x49, 0xaf, 0xfa, 0xee, 0x22, 0x75, 0xdf, 0x61, 0x9b, 0x0, 0x1e, 0xe, - 0x46, 0x86, 0x2, 0xb5, 0x32, 0xae, 0xf3, 0xf4, 0x33, 0xc0, 0x6d, 0x95, 0xd7, 0x46, 0x90, 0x5b, - 0xd6, 0x16, 0x15, 0xfd, 0x97, 0xa7, 0x8c, 0xe1, 0x2d, 0x7f, 0xd, 0x47, 0x95, 0x8, 0x0, 0x17, - 0xb4, 0x55, 0xc, 0x51, 0x90, 0x32, 0xfe, 0x8e, 0xb3, 0x14, 0x32, 0x4e, 0x80, 0x6d, 0x1b, 0xce, - 0x9d, 0x3d, 0x40, 0xd5, 0x25, 0xfd, 0x23, 0xb, 0x14, 0x1f, 0x0, 0x14, 0x5e, 0xd7, 0x92, 0xcf, - 0x21, 0x32, 0x72, 0x1d, 0x9c, 0x5b, 0x4d, 0xec, 0xf7, 0x47, 0x3c, 0x2d, 0x29, 0x35, 0x43, 0x96, - 0x1f, 0x0, 0x3, 0x81, 0x25, 0x7a, 0x25, 0x27, 0x22, 0x1e, 0x5b}; + uint8_t pkt[] = {0xe0, 0x46, 0x0, 0x44, 0x12, 0x0, 0xe, 0xef, 0xec, 0xc1, 0x7b, 0xfa, 0x8b, 0xc1, 0x4f, + 0xdc, 0xfa, 0x19, 0x3e, 0xc1, 0x42, 0x2, 0x0, 0x0, 0x4a, 0xb2, 0x13, 0x7f, 0xdf, 0x1, + 0xda, 0x2, 0x0, 0x0, 0x6e, 0x6a, 0x28, 0xe9, 0x28, 0x8, 0x12, 0x0, 0x1d, 0x3d, 0x3a, + 0xae, 0x71, 0x58, 0xc7, 0xf3, 0xe2, 0x6c, 0x5c, 0x60, 0x70, 0xac, 0x69, 0x99, 0x21, 0x2d, + 0x74, 0x13, 0x44, 0x47, 0xa9, 0xab, 0x3, 0x78, 0xef, 0xc, 0x72, 0x33}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops2[] = {0xe, 0x46, 0x86, 0x2, 0xb5, 0x32, 0xae, 0xf3, 0xf4, 0x33, 0xc0, 0x6d, 0x95, 0xd7, 0x46, - 0x90, 0x5b, 0xd6, 0x16, 0x15, 0xfd, 0x97, 0xa7, 0x8c, 0xe1, 0x2d, 0x7f, 0xd, 0x47, 0x95}; - uint8_t bytesprops1[] = {0x59, 0xf4, 0x88, 0x49, 0xaf, 0xfa, 0xee, 0x22, 0x75, 0xdf, 0x61, 0x9b}; - uint8_t bytesprops3[] = {0xb4, 0x55, 0xc, 0x51, 0x90, 0x32, 0xfe, 0x8e, 0xb3, 0x14, 0x32, 0x4e, - 0x80, 0x6d, 0x1b, 0xce, 0x9d, 0x3d, 0x40, 0xd5, 0x25, 0xfd, 0x23}; - uint8_t bytesprops4[] = {0x5e, 0xd7, 0x92, 0xcf, 0x21, 0x32, 0x72, 0x1d, 0x9c, 0x5b, - 0x4d, 0xec, 0xf7, 0x47, 0x3c, 0x2d, 0x29, 0x35, 0x43, 0x96}; - uint8_t bytesprops5[] = {0x81, 0x25, 0x7a}; + uint8_t bytesprops0[] = {0xef, 0xec, 0xc1, 0x7b, 0xfa, 0x8b, 0xc1, 0x4f, 0xdc, 0xfa, 0x19, 0x3e, 0xc1, 0x42}; + uint8_t bytesprops1[] = {0x3d, 0x3a, 0xae, 0x71, 0x58, 0xc7, 0xf3, 0xe2, 0x6c, 0x5c, 0x60, 0x70, 0xac, 0x69, 0x99, + 0x21, 0x2d, 0x74, 0x13, 0x44, 0x47, 0xa9, 0xab, 0x3, 0x78, 0xef, 0xc, 0x72, 0x33}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26497}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 481}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1240}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14770}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24223}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops1}, .v = {30, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7771}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19122}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32735}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28266}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoMessageRateTooHigh [PropServerKeepAlive 1529,PropMaximumPacketSize 22315,PropResponseTopic -// "\183L~\163\132\149#\132\245\b@\SOH\t&\180R\171b]\GSB1",PropResponseTopic -// "\250\153\199\236|\176(|\208\143Re\NAK\246*\129#\231g\225t\187\169\236U",PropRequestProblemInformation -// 142,PropAssignedClientIdentifier "i\250\194l0+\144Z\SI\ETX\175\251W\177\149\218-\155\162x.\222\171\146W.X/\250"] +// DisconnectRequest DiscoProtocolError [PropSharedSubscriptionAvailable 126,PropMessageExpiryInterval +// 22952,PropServerReference "\n\a6\222dV\218",PropPayloadFormatIndicator 241,PropUserProperty "\234\FS\b\EM" +// "\FS\SUBN'\170\191\STXZ\213\133\189K\190V)\160\255\&0",PropTopicAlias 12630,PropResponseInformation +// "\184\217Nw\DC1B\178\153m\164k\151\161 \EOTu",PropMessageExpiryInterval 22385,PropWillDelayInterval +// 8666,PropPayloadFormatIndicator 230,PropSessionExpiryInterval 28458,PropWildcardSubscriptionAvailable +// 22,PropSubscriptionIdentifierAvailable 61,PropResponseInformation "\236",PropAssignedClientIdentifier +// "#\EOT",PropWillDelayInterval 28536,PropServerKeepAlive 27227,PropReasonString +// "P\178\135I2\193\&7\206\209\223;\145\171\DC2\241",PropResponseTopic +// "\169\228\DC2\US\215,\140\226\150\131\143\134>\DC4\172.",PropContentType +// "V\218\247\196+\186x\233|",PropReceiveMaximum 21710,PropRequestProblemInformation 234,PropTopicAlias +// 21200,PropReceiveMaximum 13455,PropPayloadFormatIndicator 98] TEST(Disco5QCTest, Encode24) { - uint8_t pkt[] = {0xe0, 0x61, 0x96, 0x5f, 0x13, 0x5, 0xf9, 0x27, 0x0, 0x0, 0x57, 0x2b, 0x8, 0x0, 0x16, 0xb7, 0x4c, - 0x7e, 0xa3, 0x84, 0x95, 0x23, 0x84, 0xf5, 0x8, 0x40, 0x1, 0x9, 0x26, 0xb4, 0x52, 0xab, 0x62, 0x5d, - 0x1d, 0x42, 0x31, 0x8, 0x0, 0x19, 0xfa, 0x99, 0xc7, 0xec, 0x7c, 0xb0, 0x28, 0x7c, 0xd0, 0x8f, 0x52, - 0x65, 0x15, 0xf6, 0x2a, 0x81, 0x23, 0xe7, 0x67, 0xe1, 0x74, 0xbb, 0xa9, 0xec, 0x55, 0x17, 0x8e, 0x12, - 0x0, 0x1d, 0x69, 0xfa, 0xc2, 0x6c, 0x30, 0x2b, 0x90, 0x5a, 0xf, 0x3, 0xaf, 0xfb, 0x57, 0xb1, 0x95, - 0xda, 0x2d, 0x9b, 0xa2, 0x78, 0x2e, 0xde, 0xab, 0x92, 0x57, 0x2e, 0x58, 0x2f, 0xfa}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb7, 0x4c, 0x7e, 0xa3, 0x84, 0x95, 0x23, 0x84, 0xf5, 0x8, 0x40, - 0x1, 0x9, 0x26, 0xb4, 0x52, 0xab, 0x62, 0x5d, 0x1d, 0x42, 0x31}; - uint8_t bytesprops1[] = {0xfa, 0x99, 0xc7, 0xec, 0x7c, 0xb0, 0x28, 0x7c, 0xd0, 0x8f, 0x52, 0x65, 0x15, - 0xf6, 0x2a, 0x81, 0x23, 0xe7, 0x67, 0xe1, 0x74, 0xbb, 0xa9, 0xec, 0x55}; - uint8_t bytesprops2[] = {0x69, 0xfa, 0xc2, 0x6c, 0x30, 0x2b, 0x90, 0x5a, 0xf, 0x3, 0xaf, 0xfb, 0x57, 0xb1, 0x95, - 0xda, 0x2d, 0x9b, 0xa2, 0x78, 0x2e, 0xde, 0xab, 0x92, 0x57, 0x2e, 0x58, 0x2f, 0xfa}; + uint8_t pkt[] = {0xe0, 0xab, 0x1, 0x82, 0xa8, 0x1, 0x2a, 0x7e, 0x2, 0x0, 0x0, 0x59, 0xa8, 0x1c, 0x0, 0x7, + 0xa, 0x7, 0x36, 0xde, 0x64, 0x56, 0xda, 0x1, 0xf1, 0x26, 0x0, 0x4, 0xea, 0x1c, 0x8, 0x19, + 0x0, 0x12, 0x1c, 0x1a, 0x4e, 0x27, 0xaa, 0xbf, 0x2, 0x5a, 0xd5, 0x85, 0xbd, 0x4b, 0xbe, 0x56, + 0x29, 0xa0, 0xff, 0x30, 0x23, 0x31, 0x56, 0x1a, 0x0, 0x10, 0xb8, 0xd9, 0x4e, 0x77, 0x11, 0x42, + 0xb2, 0x99, 0x6d, 0xa4, 0x6b, 0x97, 0xa1, 0x20, 0x4, 0x75, 0x2, 0x0, 0x0, 0x57, 0x71, 0x18, + 0x0, 0x0, 0x21, 0xda, 0x1, 0xe6, 0x11, 0x0, 0x0, 0x6f, 0x2a, 0x28, 0x16, 0x29, 0x3d, 0x1a, + 0x0, 0x1, 0xec, 0x12, 0x0, 0x2, 0x23, 0x4, 0x18, 0x0, 0x0, 0x6f, 0x78, 0x13, 0x6a, 0x5b, + 0x1f, 0x0, 0xf, 0x50, 0xb2, 0x87, 0x49, 0x32, 0xc1, 0x37, 0xce, 0xd1, 0xdf, 0x3b, 0x91, 0xab, + 0x12, 0xf1, 0x8, 0x0, 0x10, 0xa9, 0xe4, 0x12, 0x1f, 0xd7, 0x2c, 0x8c, 0xe2, 0x96, 0x83, 0x8f, + 0x86, 0x3e, 0x14, 0xac, 0x2e, 0x3, 0x0, 0x9, 0x56, 0xda, 0xf7, 0xc4, 0x2b, 0xba, 0x78, 0xe9, + 0x7c, 0x21, 0x54, 0xce, 0x17, 0xea, 0x23, 0x52, 0xd0, 0x21, 0x34, 0x8f, 0x1, 0x62}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa, 0x7, 0x36, 0xde, 0x64, 0x56, 0xda}; + uint8_t bytesprops2[] = {0x1c, 0x1a, 0x4e, 0x27, 0xaa, 0xbf, 0x2, 0x5a, 0xd5, + 0x85, 0xbd, 0x4b, 0xbe, 0x56, 0x29, 0xa0, 0xff, 0x30}; + uint8_t bytesprops1[] = {0xea, 0x1c, 0x8, 0x19}; + uint8_t bytesprops3[] = {0xb8, 0xd9, 0x4e, 0x77, 0x11, 0x42, 0xb2, 0x99, + 0x6d, 0xa4, 0x6b, 0x97, 0xa1, 0x20, 0x4, 0x75}; + uint8_t bytesprops4[] = {0xec}; + uint8_t bytesprops5[] = {0x23, 0x4}; + uint8_t bytesprops6[] = {0x50, 0xb2, 0x87, 0x49, 0x32, 0xc1, 0x37, 0xce, 0xd1, 0xdf, 0x3b, 0x91, 0xab, 0x12, 0xf1}; + uint8_t bytesprops7[] = {0xa9, 0xe4, 0x12, 0x1f, 0xd7, 0x2c, 0x8c, 0xe2, + 0x96, 0x83, 0x8f, 0x86, 0x3e, 0x14, 0xac, 0x2e}; + uint8_t bytesprops8[] = {0x56, 0xda, 0xf7, 0xc4, 0x2b, 0xba, 0x78, 0xe9, 0x7c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1529}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22315}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22952}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12630}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22385}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8666}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28458}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28536}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27227}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21710}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21200}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13455}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 98}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 150, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 130, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoKeepAliveTimeout [PropMaximumQoS 246,PropServerKeepAlive -// 5558,PropSubscriptionIdentifierAvailable 253,PropAssignedClientIdentifier "V\SO\r\UScP\148\162"] +// DisconnectRequest DiscoMaximumConnectTime [PropRequestProblemInformation 237,PropSharedSubscriptionAvailable +// 191,PropWildcardSubscriptionAvailable 74,PropAssignedClientIdentifier +// "\211%\DEL;\174\234\EOT\128\ETXt,[\177\138O\DLE+\134\220Ut/\212\247\136\&4P\142\181",PropServerReference +// "9u\ENQz\160\172\253\129 \225\240\180\200hO",PropAssignedClientIdentifier +// "^\SOH\135l\163\233L>\bN\154\NUL\ESC\150\131",PropWillDelayInterval 7514,PropWildcardSubscriptionAvailable +// 226,PropSubscriptionIdentifier 29,PropMessageExpiryInterval 23285,PropSubscriptionIdentifier +// 11,PropResponseInformation +// "s\SIj\196\251L\167\ETX\NAK\137`\226\221\183\189\EM\DC1wWs\ETB4p\184\143&",PropSharedSubscriptionAvailable +// 6,PropWillDelayInterval 23559,PropAuthenticationData +// "\166\144\235\195h\240\&6\SOH\DC2\191\STX\153\&6\238\173ldx",PropMaximumQoS 190,PropContentType +// "\151\GS\229\176I\161h\203\172O\213\GS\232W\SOH\238\214\EOT\254\EOTX\f\193\251(\171\164s:\DEL",PropAuthenticationData +// "\208\139K\193\159H",PropRequestResponseInformation 104,PropTopicAliasMaximum 5762,PropReasonString +// "\174\206\147\209\232BH@R\140W\178\173/\165\230\&1\141\233\245\143i/\166\133",PropTopicAlias +// 11912,PropMessageExpiryInterval 5860,PropReceiveMaximum 20067,PropWillDelayInterval 32077,PropResponseTopic +// "\CAN[\DC4\232\176\181C\198\179h\187_\212\237\255\DLE\247\NUL\159\208\146P!\231\159",PropResponseTopic +// "\ETX-\239\169\\\ACKz",PropAuthenticationMethod +// "F\247*\181\NAKs\216\134`\145\220\211;2y\219\NUL",PropSessionExpiryInterval 19023,PropResponseInformation +// "Y\STX\DLEl_\ENQ\175\SO\f\174w-VL\DC3[\211\RS\158\211Z\SUB\DLE\aM"] TEST(Disco5QCTest, Encode27) { - uint8_t pkt[] = {0xe0, 0x3f, 0x82, 0x3d, 0x1a, 0x0, 0x1c, 0x40, 0x3b, 0xd8, 0x78, 0xf1, 0x94, 0x6, 0xa1, 0x51, 0xe1, - 0xe2, 0x87, 0x93, 0x63, 0x7e, 0xe9, 0xe5, 0x24, 0xe7, 0x12, 0x4b, 0xcd, 0x1b, 0xba, 0xab, 0x2c, 0x83, - 0x29, 0x29, 0xda, 0x12, 0x0, 0xa, 0x6f, 0x57, 0x80, 0xfe, 0x79, 0x28, 0xf3, 0x79, 0x1b, 0x25, 0x28, - 0x17, 0x13, 0x57, 0xce, 0xb, 0xa, 0x29, 0xe1, 0x2a, 0x7, 0x24, 0x27, 0x17, 0xf1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x40, 0x3b, 0xd8, 0x78, 0xf1, 0x94, 0x6, 0xa1, 0x51, 0xe1, 0xe2, 0x87, 0x93, 0x63, - 0x7e, 0xe9, 0xe5, 0x24, 0xe7, 0x12, 0x4b, 0xcd, 0x1b, 0xba, 0xab, 0x2c, 0x83, 0x29}; - uint8_t bytesprops1[] = {0x6f, 0x57,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 0x56, 0x4c, 0x13, 0x5b, 0xd3, 0x1e, 0x9e, 0xd3, 0x5a, 0x1a, 0x10, 0x7, 0x4d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf8, 0xe9, 0x10, 0xdf, 0x41, 0x71, 0x96, 0x99, 0x83, 0x60, 0x42, 0x6a, + 0x24, 0xd0, 0xb1, 0x13, 0x43, 0x87, 0xf5, 0x65, 0xd4, 0x72, 0x93, 0x41}; + uint8_t bytesprops1[] = {0x7f, 0x35, 0xa0, 0x3, 0xc3, 0xe9, 0xbc, 0xdf, 0x2, 0x60, 0x64, 0xd0}; + uint8_t bytesprops2[] = {0x2f, 0x34, 0xe3, 0x19, 0xa2, 0x8d, 0xe1, 0x27, 0x9, + 0xff, 0x10, 0x24, 0xc0, 0xf, 0x7b, 0x7a, 0xc1}; + uint8_t bytesprops3[] = {0xd1, 0x5f, 0x3e, 0x8f, 0x69, 0x2f, 0xa6, 0x85}; + uint8_t bytesprops4[] = {0x18, 0x5b, 0x14, 0xe8, 0xb0, 0xb5, 0x43, 0xc6, 0xb3, 0x68, 0xbb, 0x5f, 0xd4, + 0xed, 0xff, 0x10, 0xf7, 0x0, 0x9f, 0xd0, 0x92, 0x50, 0x21, 0xe7, 0x9f}; + uint8_t bytesprops5[] = {0x3, 0x2d, 0xef, 0xa9, 0x5c, 0x6, 0x7a}; + uint8_t bytesprops6[] = {0x46, 0xf7, 0x2a, 0xb5, 0x15, 0x73, 0xd8, 0x86, 0x60, + 0x91, 0xdc, 0xd3, 0x3b, 0x32, 0x79, 0xdb, 0x0}; + uint8_t bytesprops7[] = {0x59, 0x2, 0x10, 0x6c, 0x5f, 0x5, 0xaf, 0xe, 0xc, 0xae, 0x77, 0x2d, 0x56, + 0x4c, 0x13, 0x5b, 0xd3, 0x1e, 0x9e, 0xd3, 0x5a, 0x1a, 0x10, 0x7, 0x4d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22478}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11912}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5860}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20067}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32077}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19023}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 130, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoMessageRateTooHigh [PropCorrelationData -// "\131\130\210\132\224|V\230\ETXSGw\157\241\250\179\193g\141\220bo\197>u\146\221",PropResponseInformation -// "Y\147\235\NUL\144#Mw\145[\135\DELb\193)",PropSubscriptionIdentifier 29,PropCorrelationData "a\173\f\212\153u -// &\FS\173 e\ENQOVsAr\183\194\171\198/c5",PropWillDelayInterval 2734,PropMessageExpiryInterval -// 6794,PropRequestProblemInformation 128,PropAssignedClientIdentifier -// "y\136\237\SO1'\134y\179x\189\184K\138B\148^\133\226\170\&7\FS\NAK",PropResponseInformation -// "\203\n\155\233\133a\170V\222\&2i\CAN\170\&5\249\203\166'",PropRequestResponseInformation 136,PropMaximumQoS -// 237,PropMessageExpiryInterval 30501,PropResponseInformation -// "e\171Q+\159e\GS\222\ETX\187",PropRequestResponseInformation 137,PropResponseInformation -// "\ACK!\142\187\226W\n,I\196",PropSubscriptionIdentifier 26,PropPayloadFormatIndicator 131,PropReasonString -// "\198",PropAuthenticationData -// "\129\144\n\n#\SYNXD\136\DLE\225\200\175\129MVO\167B\233\152\130\GS\NUL\130e\208U\196",PropAuthenticationData -// "\171\253\221\227o\148\160E\185\198\232[dA\190\228\232\167\RS~\239\tb\236",PropMessageExpiryInterval -// 28849,PropCorrelationData "6R\144X7\204r~6\137\184\208\209`\207\192n\n%\146",PropTopicAliasMaximum 2747] +// DisconnectRequest DiscoSharedSubscriptionsNotSupported [PropServerReference +// "\EMD\178\rD\ENQ%H\203\DLE\231\ETBh\SO7m\204\196\167K\166\GS\200\&9O\150\215\225\GS",PropRetainAvailable +// 155,PropAuthenticationMethod "19W\242i?r;^z\170\169\f\183\134\168\227\DC4;",PropWildcardSubscriptionAvailable +// 65,PropMessageExpiryInterval 12219,PropRequestResponseInformation 65,PropResponseTopic "",PropMessageExpiryInterval +// 28021,PropRequestResponseInformation 74,PropWillDelayInterval 13573,PropContentType +// "~\195e2\131[\n-\b\162\135Y\DC2\212\167\174",PropReceiveMaximum 27401,PropResponseTopic +// "~\206\a4\129g\228#Z0\NAKN\175^<>\159\ETX;\254\187\250\253\131\174\166\FS\156",PropUserProperty +// "\204hY\237QL'\na]\233\163\DC15'z\165\224h\250\185\137\149\138\GS~\139i" +// "\144\150\SI,\191\206\CAN\133",PropMessageExpiryInterval 23185,PropWildcardSubscriptionAvailable +// 169,PropSubscriptionIdentifier 14,PropSharedSubscriptionAvailable 196,PropRetainAvailable 142,PropUserProperty +// "\156\135\242$}8\RS\214\240\ENQ\212\196\FS\142\171\222\221\ACK\233b " +// "&Z\190\GS\132\NUL\243\177\\\237^U\r\247",PropAuthenticationData +// "/G\162\230J\STX\176\231\176\180\134Y\STX]Z\DLE\200\&6mB"] TEST(Disco5QCTest, Encode28) { uint8_t pkt[] = { - 0xe0, 0x93, 0x2, 0x96, 0x90, 0x2, 0x9, 0x0, 0x1b, 0x83, 0x82, 0xd2, 0x84, 0xe0, 0x7c, 0x56, 0xe6, 0x3, 0x53, - 0x47, 0x77, 0x9d, 0xf1, 0xfa, 0xb3, 0xc1, 0x67, 0x8d, 0xdc, 0x62, 0x6f, 0xc5, 0x3e, 0x75, 0x92, 0xdd, 0x1a, 0x0, - 0xf, 0x59, 0x93, 0xeb, 0x0, 0x90, 0x23, 0x4d, 0x77, 0x91, 0x5b, 0x87, 0x7f, 0x62, 0xc1, 0x29, 0xb, 0x1d, 0x9, - 0x0, 0x19, 0x61, 0xad, 0xc, 0xd4, 0x99, 0x75, 0x20, 0x26, 0x1c, 0xad, 0x20, 0x65, 0x5, 0x4f, 0x56, 0x73, 0x41, - 0x72, 0xb7, 0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d1, 0x60, 0xcf, 0xc0, 0x6e, 0xa, 0x25, 0x92, 0x22, 0xa, 0xbb}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x83, 0x82, 0xd2, 0x84, 0xe0, 0x7c, 0x56, 0xe6, 0x3, 0x53, 0x47, 0x77, 0x9d, 0xf1, - 0xfa, 0xb3, 0xc1, 0x67, 0x8d, 0xdc, 0x62, 0x6f, 0xc5, 0x3e, 0x75, 0x92, 0xdd}; - uint8_t bytesprops1[] = {0x59, 0x93, 0xeb, 0x0, 0x90, 0x23, 0x4d, 0x77, 0x91, 0x5b, 0x87, 0x7f, 0x62, 0xc1, 0x29}; - uint8_t bytesprops2[] = {0x61, 0xad, 0xc, 0xd4, 0x99, 0x75, 0x20, 0x26, 0x1c, 0xad, 0x20, 0x65, 0x5, - 0x4f, 0x56, 0x73, 0x41, 0x72, 0xb7, 0xc2, 0xab, 0xc6, 0x2f, 0x63, 0x35}; - uint8_t bytesprops3[] = {0x79, 0x88, 0xed, 0xe, 0x31, 0x27, 0x86, 0x79, 0xb3, 0x78, 0xbd, 0xb8, - 0x4b, 0x8a, 0x42, 0x94, 0x5e, 0x85, 0xe2, 0xaa, 0x37, 0x1c, 0x15}; - uint8_t bytesprops4[] = {0xcb, 0xa, 0x9b, 0xe9, 0x85, 0x61, 0xaa, 0x56, 0xde, - 0x32, 0x69, 0x18, 0xaa, 0x35, 0xf9, 0xcb, 0xa6, 0x27}; - uint8_t bytesprops5[] = {0x65, 0xab, 0x51, 0x2b, 0x9f, 0x65, 0x1d, 0xde, 0x3, 0xbb}; - uint8_t bytesprops6[] = {0x6, 0x21, 0x8e, 0xbb, 0xe2, 0x57, 0xa, 0x2c, 0x49, 0xc4}; - uint8_t bytesprops7[] = {0xc6}; - uint8_t bytesprops8[] = {0x81, 0x90, 0xa, 0xa, 0x23, 0x16, 0x58, 0x44, 0x88, 0x10, 0xe1, 0xc8, 0xaf, 0x81, 0x4d, - 0x56, 0x4f, 0xa7, 0x42, 0xe9, 0x98, 0x82, 0x1d, 0x0, 0x82, 0x65, 0xd0, 0x55, 0xc4}; - uint8_t bytesprops9[] = {0xab, 0xfd, 0xdd, 0xe3, 0x6f, 0x94, 0xa0, 0x45, 0xb9, 0xc6, 0xe8, 0x5b, - 0x64, 0x41, 0xbe, 0xe4, 0xe8, 0xa7, 0x1e, 0x7e, 0xef, 0x9, 0x62, 0xec}; - uint8_t bytesprops10[] = {0x36, 0x52, 0x90, 0x58, 0x37, 0xcc, 0x72, 0x7e, 0x36, 0x89, - 0xb8, 0xd0, 0xd1, 0x60, 0xcf, 0xc0, 0x6e, 0xa, 0x25, 0x92}; + 0xe0, 0xfd, 0x1, 0x9e, 0xfa, 0x1, 0x1c, 0x0, 0x1d, 0x19, 0x44, 0xb2, 0xd, 0x44, 0x5, 0x25, 0x48, 0xcb, 0x10, + 0xe7, 0x17, 0x68, 0xe, 0x37, 0x6d, 0xcc, 0xc4, 0xa7, 0x4b, 0xa6, 0x1d, 0xc8, 0x39, 0x4f, 0x96, 0xd7, 0xe1, 0x1d, + 0x25, 0x9b, 0x15, 0x0, 0x13, 0x31, 0x39, 0x57, 0xf2, 0x69, 0x3f, 0x72, 0x3b, 0x5e, 0x7a, 0xaa, 0xa9, 0xc, 0xb7, + 0x86, 0xa8, 0xe3, 0x14, 0x3b, 0x28, 0x41, 0x2, 0x0, 0x0, 0x2f, 0xbb, 0x19, 0x41, 0x8, 0x0, 0x0, 0x2, 0x0, + 0x0, 0x6d, 0x75, 0x19, 0x4a, 0x18, 0x0, 0x0, 0x35, 0x5, 0x3, 0x0, 0x10, 0x7e, 0xc3, 0x65, 0x32, 0x83, 0x5b, + 0xa, 0x2d, 0x8, 0xa2, 0x87, 0x59, 0x12, 0xd4, 0xa7, 0xae, 0x21, 0x6b, 0x9, 0x8, 0x0, 0x1c, 0x7e, 0xce, 0x7, + 0x34, 0x81, 0x67, 0xe4, 0x23, 0x5a, 0x30, 0x15, 0x4e, 0xaf, 0x5e, 0x3c, 0x3e, 0x9f, 0x3, 0x3b, 0xfe, 0xbb, 0xfa, + 0xfd, 0x83, 0xae, 0xa6, 0x1c, 0x9c, 0x26, 0x0, 0x1c, 0xcc, 0x68, 0x59, 0xed, 0x51, 0x4c, 0x27, 0xa, 0x61, 0x5d, + 0xe9, 0xa3, 0x11, 0x35, 0x27, 0x7a, 0xa5, 0xe0, 0x68, 0xfa, 0xb9, 0x89, 0x95, 0x8a, 0x1d, 0x7e, 0x8b, 0x69, 0x0, + 0x8, 0x90, 0x96, 0xf, 0x2c, 0xbf, 0xce, 0x18, 0x85, 0x2, 0x0, 0x0, 0x5a, 0x91, 0x28, 0xa9, 0xb, 0xe, 0x2a, + 0xc4, 0x25, 0x8e, 0x26, 0x0, 0x15, 0x9c, 0x87, 0xf2, 0x24, 0x7d, 0x38, 0x1e, 0xd6, 0xf0, 0x5, 0xd4, 0xc4, 0x1c, + 0x8e, 0xab, 0xde, 0xdd, 0x6, 0xe9, 0x62, 0x20, 0x0, 0xe, 0x26, 0x5a, 0xbe, 0x1d, 0x84, 0x0, 0xf3, 0xb1, 0x5c, + 0xed, 0x5e, 0x55, 0xd, 0xf7, 0x16, 0x0, 0x14, 0x2f, 0x47, 0xa2, 0xe6, 0x4a, 0x2, 0xb0, 0xe7, 0xb0, 0xb4, 0x86, + 0x59, 0x2, 0x5d, 0x5a, 0x10, 0xc8, 0x36, 0x6d, 0x42}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x19, 0x44, 0xb2, 0xd, 0x44, 0x5, 0x25, 0x48, 0xcb, 0x10, 0xe7, 0x17, 0x68, 0xe, 0x37, + 0x6d, 0xcc, 0xc4, 0xa7, 0x4b, 0xa6, 0x1d, 0xc8, 0x39, 0x4f, 0x96, 0xd7, 0xe1, 0x1d}; + uint8_t bytesprops1[] = {0x31, 0x39, 0x57, 0xf2, 0x69, 0x3f, 0x72, 0x3b, 0x5e, 0x7a, + 0xaa, 0xa9, 0xc, 0xb7, 0x86, 0xa8, 0xe3, 0x14, 0x3b}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x7e, 0xc3, 0x65, 0x32, 0x83, 0x5b, 0xa, 0x2d, + 0x8, 0xa2, 0x87, 0x59, 0x12, 0xd4, 0xa7, 0xae}; + uint8_t bytesprops4[] = {0x7e, 0xce, 0x7, 0x34, 0x81, 0x67, 0xe4, 0x23, 0x5a, 0x30, 0x15, 0x4e, 0xaf, 0x5e, + 0x3c, 0x3e, 0x9f, 0x3, 0x3b, 0xfe, 0xbb, 0xfa, 0xfd, 0x83, 0xae, 0xa6, 0x1c, 0x9c}; + uint8_t bytesprops6[] = {0x90, 0x96, 0xf, 0x2c, 0xbf, 0xce, 0x18, 0x85}; + uint8_t bytesprops5[] = {0xcc, 0x68, 0x59, 0xed, 0x51, 0x4c, 0x27, 0xa, 0x61, 0x5d, 0xe9, 0xa3, 0x11, 0x35, + 0x27, 0x7a, 0xa5, 0xe0, 0x68, 0xfa, 0xb9, 0x89, 0x95, 0x8a, 0x1d, 0x7e, 0x8b, 0x69}; + uint8_t bytesprops8[] = {0x26, 0x5a, 0xbe, 0x1d, 0x84, 0x0, 0xf3, 0xb1, 0x5c, 0xed, 0x5e, 0x55, 0xd, 0xf7}; + uint8_t bytesprops7[] = {0x9c, 0x87, 0xf2, 0x24, 0x7d, 0x38, 0x1e, 0xd6, 0xf0, 0x5, 0xd4, + 0xc4, 0x1c, 0x8e, 0xab, 0xde, 0xdd, 0x6, 0xe9, 0x62, 0x20}; + uint8_t bytesprops9[] = {0x2f, 0x47, 0xa2, 0xe6, 0x4a, 0x2, 0xb0, 0xe7, 0xb0, 0xb4, + 0x86, 0x59, 0x2, 0x5d, 0x5a, 0x10, 0xc8, 0x36, 0x6d, 0x42}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2734}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6794}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30501}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28849}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2747}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12219}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28021}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13573}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27401}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops5}, .v = {8, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23185}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops7}, .v = {14, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 150, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 158, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoTopicNameInvalid [PropSubscriptionIdentifier 11,PropWillDelayInterval -// 21991,PropAssignedClientIdentifier ",\226\141u\SUB,O\211\188E\239\162\149\174\SOh\249\176[\227\143",PropContentType -// "B\a\160\171\STX!\SO5`\198\SI\177\213\197\n:\\\144",PropResponseTopic -// "\169UZ\203\162\SI\242\235\232=\206\233I\162\224\199",PropReasonString -// "\ETB\251U\131_\203i\253#\202\237\130",PropReceiveMaximum 26751,PropResponseInformation -// "\SYNm\232/R\180h;2t\241\216\&4\243\167\209\174\&1\178:\248uZ\CAN\174\130`"] +// DisconnectRequest DiscoProtocolError [PropSessionExpiryInterval 17134,PropReasonString +// "k\149",PropAuthenticationMethod "\177\SOH\241\RSP9\147\174\146\202\142%",PropTopicAlias +// 19959,PropPayloadFormatIndicator 75,PropPayloadFormatIndicator 70,PropTopicAliasMaximum 17295,PropUserProperty +// "`7\248\135\153\220-\219\145\\/\152\FS?O\171\DC4g#[\174D" +// "\181\CAN\204\159\227\159hK\146\189FV^\\\233$Y{\DC2\147\176\&0\ETX\200",PropRetainAvailable 177,PropContentType +// "|\133\238\230\191\255D\ESC\255r9\137\218\184\SUB \239=\218\\\ACK\151xd",PropRequestResponseInformation 222] TEST(Disco5QCTest, Encode29) { - uint8_t pkt[] = {0xe0, 0x79, 0x90, 0x77, 0xb, 0xb, 0x18, 0x0, 0x0, 0x55, 0xe7, 0x12, 0x0, 0x15, 0x2c, 0xe2, - 0x8d, 0x75, 0x1a, 0x2c, 0x4f, 0xd3, 0xbc, 0x45, 0xef, 0xa2, 0x95, 0xae, 0xe, 0x68, 0xf9, 0xb0, - 0x5b, 0xe3, 0x8f, 0x3, 0x0, 0x12, 0x42, 0x7, 0xa0, 0xab, 0x2, 0x21, 0xe, 0x35, 0x60, 0xc6, - 0xf, 0xb1, 0xd5, 0xc5, 0xa, 0x3a, 0x5c, 0x90, 0x8, 0x0, 0x10, 0xa9, 0x55, 0x5a, 0xcb, 0xa2, - 0xf, 0xf2, 0xeb, 0xe8, 0x3d, 0xce, 0xe9, 0x49, 0xa2, 0xe0, 0xc7, 0x1f, 0x0, 0xc, 0x17, 0xfb, - 0x55, 0x83, 0x5f, 0xcb, 0x69, 0xfd, 0x23, 0xca, 0xed, 0x82, 0x21, 0x68, 0x7f, 0x1a, 0x0, 0x1b, - 0x16, 0x6d, 0xe8, 0x2f, 0x52, 0xb4, 0x68, 0x3b, 0x32, 0x74, 0xf1, 0xd8, 0x34, 0xf3, 0xa7, 0xd1, - 0xae, 0x31, 0xb2, 0x3a, 0xf8, 0x75, 0x5a, 0x18, 0xae, 0x82, 0x60}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x2c, 0xe2, 0x8d, 0x75, 0x1a, 0x2c, 0x4f, 0xd3, 0xbc, 0x45, 0xef, - 0xa2, 0x95, 0xae, 0xe, 0x68, 0xf9, 0xb0, 0x5b, 0xe3, 0x8f}; - uint8_t bytesprops1[] = {0x42, 0x7, 0xa0, 0xab, 0x2, 0x21, 0xe, 0x35, 0x60, - 0xc6, 0xf, 0xb1, 0xd5, 0xc5, 0xa, 0x3a, 0x5c, 0x90}; - uint8_t bytesprops2[] = {0xa9, 0x55, 0x5a, 0xcb, 0xa2, 0xf, 0xf2, 0xeb, - 0xe8, 0x3d, 0xce, 0xe9, 0x49, 0xa2, 0xe0, 0xc7}; - uint8_t bytesprops3[] = {0x17, 0xfb, 0x55, 0x83, 0x5f, 0xcb, 0x69, 0xfd, 0x23, 0xca, 0xed, 0x82}; - uint8_t bytesprops4[] = {0x16, 0x6d, 0xe8, 0x2f, 0x52, 0xb4, 0x68, 0x3b, 0x32, 0x74, 0xf1, 0xd8, 0x34, 0xf3, - 0xa7, 0xd1, 0xae, 0x31, 0xb2, 0x3a, 0xf8, 0x75, 0x5a, 0x18, 0xae, 0x82, 0x60}; + uint8_t pkt[] = {0xe0, 0x77, 0x82, 0x75, 0x11, 0x0, 0x0, 0x42, 0xee, 0x1f, 0x0, 0x2, 0x6b, 0x95, 0x15, 0x0, + 0xc, 0xb1, 0x1, 0xf1, 0x1e, 0x50, 0x39, 0x93, 0xae, 0x92, 0xca, 0x8e, 0x25, 0x23, 0x4d, 0xf7, + 0x1, 0x4b, 0x1, 0x46, 0x22, 0x43, 0x8f, 0x26, 0x0, 0x16, 0x60, 0x37, 0xf8, 0x87, 0x99, 0xdc, + 0x2d, 0xdb, 0x91, 0x5c, 0x2f, 0x98, 0x1c, 0x3f, 0x4f, 0xab, 0x14, 0x67, 0x23, 0x5b, 0xae, 0x44, + 0x0, 0x18, 0xb5, 0x18, 0xcc, 0x9f, 0xe3, 0x9f, 0x68, 0x4b, 0x92, 0xbd, 0x46, 0x56, 0x5e, 0x5c, + 0xe9, 0x24, 0x59, 0x7b, 0x12, 0x93, 0xb0, 0x30, 0x3, 0xc8, 0x25, 0xb1, 0x3, 0x0, 0x18, 0x7c, + 0x85, 0xee, 0xe6, 0xbf, 0xff, 0x44, 0x1b, 0xff, 0x72, 0x39, 0x89, 0xda, 0xb8, 0x1a, 0x20, 0xef, + 0x3d, 0xda, 0x5c, 0x6, 0x97, 0x78, 0x64, 0x19, 0xde}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x6b, 0x95}; + uint8_t bytesprops1[] = {0xb1, 0x1, 0xf1, 0x1e, 0x50, 0x39, 0x93, 0xae, 0x92, 0xca, 0x8e, 0x25}; + uint8_t bytesprops3[] = {0xb5, 0x18, 0xcc, 0x9f, 0xe3, 0x9f, 0x68, 0x4b, 0x92, 0xbd, 0x46, 0x56, + 0x5e, 0x5c, 0xe9, 0x24, 0x59, 0x7b, 0x12, 0x93, 0xb0, 0x30, 0x3, 0xc8}; + uint8_t bytesprops2[] = {0x60, 0x37, 0xf8, 0x87, 0x99, 0xdc, 0x2d, 0xdb, 0x91, 0x5c, 0x2f, + 0x98, 0x1c, 0x3f, 0x4f, 0xab, 0x14, 0x67, 0x23, 0x5b, 0xae, 0x44}; + uint8_t bytesprops4[] = {0x7c, 0x85, 0xee, 0xe6, 0xbf, 0xff, 0x44, 0x1b, 0xff, 0x72, 0x39, 0x89, + 0xda, 0xb8, 0x1a, 0x20, 0xef, 0x3d, 0xda, 0x5c, 0x6, 0x97, 0x78, 0x64}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21991}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26751}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17134}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19959}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17295}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops2}, .v = {24, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 222}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 130, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoImplementationSpecificError [PropTopicAlias 14784,PropServerReference -// "\137jMZ",PropResponseTopic "zW\135\188\248\164yl\192+a\207miV\SOH\220\193\&8(\229/mh7\167\t",PropMaximumPacketSize -// 8003,PropUserProperty "\202\f\ACK*\229\EOT\134\241\DC4v\204\161A" -// "X'\187\165\147\137\207nO\n\233\148\138\138\248\DC4\157\219\155T\139",PropAuthenticationData -// "?\ETB\144p\130gQuI\184,\f\141C3",PropServerKeepAlive 21004,PropMessageExpiryInterval 18390,PropContentType -// "\200'\215P\181a\187\208H\152\210L",PropTopicAlias 18937,PropCorrelationData -// "\128\152\208\147\231\\\141y\138\191\145\167$\223\NAK\DC4 I\199\163\222",PropMessageExpiryInterval -// 4343,PropReceiveMaximum 10269,PropRequestResponseInformation 105,PropSubscriptionIdentifier 7,PropResponseInformation -// "\248&d\EM2#\204\203\219\163\161\177Q\159\147",PropAuthenticationMethod -// "\242\177\\\186\SUBO\240E\"\222\170\242rX\239\181AH\235\139\213\198|u",PropWildcardSubscriptionAvailable -// 44,PropMaximumPacketSize 3490,PropAssignedClientIdentifier "\GS\201\a\185{C",PropAuthenticationData -// "\182\"\FS\182h1l\195\148\a-\189\RSS\197l",PropPayloadFormatIndicator 218] +// DisconnectRequest DiscoServerBusy [PropTopicAlias 22226,PropWildcardSubscriptionAvailable +// 179,PropPayloadFormatIndicator 241,PropAuthenticationData "}D#\230\EM\153\170\180\175\198T\ETXI",PropServerReference +// "\186h\174\\\SOH\184\180\&7\180\203\bH\240f",PropTopicAlias 5079,PropServerReference "jZ(\b\RS!O\252*>j{{?%c\""] TEST(Disco5QCTest, Encode30) { - uint8_t pkt[] = {0xe0, 0xf9, 0x1, 0x83, 0xf6, 0x1, 0x23, 0x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, 0x1a, 0x4f, 0xf0, 0x45, 0x22, 0xde, 0xaa, 0xf2, 0x72, - 0x58, 0xef, 0xb5, 0x41, 0x48, 0xeb, 0x8b, 0xd5, 0xc6, 0x7c, 0x75, 0x28, 0x2c, 0x27, 0x0, 0x0, 0xd, - 0xa2, 0x12, 0x0, 0x6, 0x1d, 0xc9, 0x7, 0xb9, 0x7b, 0x43, 0x16, 0x0, 0x10, 0xb6, 0x22, 0x1c, 0xb6, - 0x68, 0x31, 0x6c, 0xc3, 0x94, 0x7, 0x2d, 0xbd, 0x1e, 0x53, 0xc5, 0x6c, 0x1, 0xda}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x89, 0x6a, 0x4d, 0x5a}; - uint8_t bytesprops1[] = {0x7a, 0x57, 0x87, 0xbc, 0xf8, 0xa4, 0x79, 0x6c, 0xc0, 0x2b, 0x61, 0xcf, 0x6d, 0x69, - 0x56, 0x1, 0xdc, 0xc1, 0x38, 0x28, 0xe5, 0x2f, 0x6d, 0x68, 0x37, 0xa7, 0x9}; - uint8_t bytesprops3[] = {0x58, 0x27, 0xbb, 0xa5, 0x93, 0x89, 0xcf, 0x6e, 0x4f, 0xa, 0xe9, - 0x94, 0x8a, 0x8a, 0xf8, 0x14, 0x9d, 0xdb, 0x9b, 0x54, 0x8b}; - uint8_t bytesprops2[] = {0xca, 0xc, 0x6, 0x2a, 0xe5, 0x4, 0x86, 0xf1, 0x14, 0x76, 0xcc, 0xa1, 0x41}; - uint8_t bytesprops4[] = {0x3f, 0x17, 0x90, 0x70, 0x82, 0x67, 0x51, 0x75, 0x49, 0xb8, 0x2c, 0xc, 0x8d, 0x43, 0x33}; - uint8_t bytesprops5[] = {0xc8, 0x27, 0xd7, 0x50, 0xb5, 0x61, 0xbb, 0xd0, 0x48, 0x98, 0xd2, 0x4c}; - uint8_t bytesprops6[] = {0x80, 0x98, 0xd0, 0x93, 0xe7, 0x5c, 0x8d, 0x79, 0x8a, 0xbf, 0x91, - 0xa7, 0x24, 0xdf, 0x15, 0x14, 0x20, 0x49, 0xc7, 0xa3, 0xde}; - uint8_t bytesprops7[] = {0xf8, 0x26, 0x64, 0x19, 0x32, 0x23, 0xcc, 0xcb, 0xdb, 0xa3, 0xa1, 0xb1, 0x51, 0x9f, 0x93}; - uint8_t bytesprops8[] = {0xf2, 0xb1, 0x5c, 0xba, 0x1a, 0x4f, 0xf0, 0x45, 0x22, 0xde, 0xaa, 0xf2, - 0x72, 0x58, 0xef, 0xb5, 0x41, 0x48, 0xeb, 0x8b, 0xd5, 0xc6, 0x7c, 0x75}; - uint8_t bytesprops9[] = {0x1d, 0xc9, 0x7, 0xb9, 0x7b, 0x43}; - uint8_t bytesprops10[] = {0xb6, 0x22, 0x1c, 0xb6, 0x68, 0x31, 0x6c, 0xc3, - 0x94, 0x7, 0x2d, 0xbd, 0x1e, 0x53, 0xc5, 0x6c}; + uint8_t pkt[] = {0xe0, 0x41, 0x89, 0x3f, 0x23, 0x56, 0xd2, 0x28, 0xb3, 0x1, 0xf1, 0x16, 0x0, 0xd, 0x7d, 0x44, 0x23, + 0xe6, 0x19, 0x99, 0xaa, 0xb4, 0xaf, 0xc6, 0x54, 0x3, 0x49, 0x1c, 0x0, 0xe, 0xba, 0x68, 0xae, 0x5c, + 0x1, 0xb8, 0xb4, 0x37, 0xb4, 0xcb, 0x8, 0x48, 0xf0, 0x66, 0x23, 0x13, 0xd7, 0x1c, 0x0, 0x11, 0x6a, + 0x5a, 0x28, 0x8, 0x1e, 0x21, 0x4f, 0xfc, 0x2a, 0x3e, 0x6a, 0x7b, 0x7b, 0x3f, 0x25, 0x63, 0x22}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7d, 0x44, 0x23, 0xe6, 0x19, 0x99, 0xaa, 0xb4, 0xaf, 0xc6, 0x54, 0x3, 0x49}; + uint8_t bytesprops1[] = {0xba, 0x68, 0xae, 0x5c, 0x1, 0xb8, 0xb4, 0x37, 0xb4, 0xcb, 0x8, 0x48, 0xf0, 0x66}; + uint8_t bytesprops2[] = {0x6a, 0x5a, 0x28, 0x8, 0x1e, 0x21, 0x4f, 0xfc, 0x2a, + 0x3e, 0x6a, 0x7b, 0x7b, 0x3f, 0x25, 0x63, 0x22}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14784}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8003}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops2}, .v = {21, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21004}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18390}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18937}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4343}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10269}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3490}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22226}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5079}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 131, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 137, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); From 64b8b08125629c394627009165bbe2b1486d1622 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Sat, 21 Sep 2019 11:59:26 -0700 Subject: [PATCH 23/26] Easier API for property visiting. --- examples/sync.c | 83 ++++++++++++++++-------------------------------- include/lwmqtt.h | 12 +++++-- src/client.c | 48 +++++++++++++++++++++------- 3 files changed, 73 insertions(+), 70 deletions(-) diff --git a/examples/sync.c b/examples/sync.c index cff1ede..2d4c003 100644 --- a/examples/sync.c +++ b/examples/sync.c @@ -13,60 +13,24 @@ lwmqtt_unix_timer_t timer1, timer2, timer3; lwmqtt_client_t client; -static void prop_printer(void *ref, lwmqtt_property_t prop) { - switch (prop.prop) { - // one byte - case LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR: - case LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION: - case LWMQTT_PROP_MAXIMUM_QOS: - case LWMQTT_PROP_RETAIN_AVAILABLE: - case LWMQTT_PROP_REQUEST_RESPONSE_INFORMATION: - case LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE: - case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE: - case LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE: - printf(" Property %x (byte): 0x%x\n", prop.prop, prop.value.byte); - break; - - // two byte int - case LWMQTT_PROP_SERVER_KEEP_ALIVE: - case LWMQTT_PROP_RECEIVE_MAXIMUM: - case LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM: - case LWMQTT_PROP_TOPIC_ALIAS: - printf(" Property %x (int): %d\n", prop.prop, prop.value.int16); - break; - - // 4 byte int - case LWMQTT_PROP_MESSAGE_EXPIRY_INTERVAL: - case LWMQTT_PROP_SESSION_EXPIRY_INTERVAL: - case LWMQTT_PROP_WILL_DELAY_INTERVAL: - case LWMQTT_PROP_MAXIMUM_PACKET_SIZE: - printf(" Property %x (int32): %d\n", prop.prop, prop.value.int32); - break; - - // Variable byte int - case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: - printf(" Property %x (varint): %d\n", prop.prop, prop.value.int32); - break; - - // UTF-8 string - case LWMQTT_PROP_CONTENT_TYPE: - case LWMQTT_PROP_RESPONSE_TOPIC: - case LWMQTT_PROP_ASSIGNED_CLIENT_IDENTIFIER: - case LWMQTT_PROP_AUTHENTICATION_METHOD: - case LWMQTT_PROP_RESPONSE_INFORMATION: - case LWMQTT_PROP_SERVER_REFERENCE: - case LWMQTT_PROP_REASON_STRING: - - // Arbitrary blobs as the same encoding. - case LWMQTT_PROP_CORRELATION_DATA: - case LWMQTT_PROP_AUTHENTICATION_DATA: - printf(" Property %x (string): %.*s\n", prop.prop, prop.value.str.len, prop.value.str.data); - break; - - case LWMQTT_PROP_USER_PROPERTY: - printf(" User property: k=%.*s, v=%.*s\n", prop.value.pair.k.len, prop.value.pair.k.data, prop.value.pair.v.len, - prop.value.pair.v.data); - } +static void prop_byte_printer(void *ref, lwmqtt_prop_t prop, uint8_t value) { + printf(" Property %x (byte): 0x%x\n", prop, value); +} + +static void prop_int16_printer(void *ref, lwmqtt_prop_t prop, int16_t value) { + printf(" Property %x (int): %d\n", prop, value); +} + +static void prop_int32_printer(void *ref, lwmqtt_prop_t prop, int32_t value) { + printf(" Property %x (int32): %d\n", prop, value); +} + +static void prop_str_printer(void *ref, lwmqtt_prop_t prop, lwmqtt_string_t value) { + printf(" Property %x (string): %.*s\n", prop, (int)value.len, value.data); +} + +static void prop_user_printer(void *ref, lwmqtt_string_t k, lwmqtt_string_t v) { + printf(" User property: k=%.*s, v=%.*s\n", (int)k.len, k.data, (int)v.len, v.data); } static void message_arrived(lwmqtt_client_t *_client, void *ref, lwmqtt_string_t topic, lwmqtt_message_t msg, @@ -74,7 +38,16 @@ static void message_arrived(lwmqtt_client_t *_client, void *ref, lwmqtt_string_t printf("message_arrived: %.*s => %.*s (%d)\n", (int)topic.len, topic.data, (int)msg.payload_len, (char *)msg.payload, (int)msg.payload_len); - lwmqtt_property_visitor(NULL, props, prop_printer); + lwmqtt_property_callbacks_t cb = { + .byte_prop = prop_byte_printer, + .int16_prop = prop_int16_printer, + .int32_prop = prop_int32_printer, + .str_prop = prop_str_printer, + .user_prop = prop_user_printer, + }; + if (lwmqtt_property_visitor(NULL, props, cb) != LWMQTT_SUCCESS) { + exit(1); + } } int main() { diff --git a/include/lwmqtt.h b/include/lwmqtt.h index af7ad8d..5adddcc 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -493,8 +493,14 @@ lwmqtt_err_t lwmqtt_yield(lwmqtt_client_t *client, size_t available, uint32_t ti */ lwmqtt_err_t lwmqtt_keep_alive(lwmqtt_client_t *client, uint32_t timeout); -typedef void (*lwmqtt_prop_callback_t)(void *ref, lwmqtt_property_t prop); - -lwmqtt_err_t lwmqtt_property_visitor(void *ref, lwmqtt_serialized_properties_t props, lwmqtt_prop_callback_t cb); +typedef struct { + void (*byte_prop)(void *ref, lwmqtt_prop_t prop, uint8_t value); + void (*int16_prop)(void *ref, lwmqtt_prop_t prop, int16_t value); + void (*int32_prop)(void *ref, lwmqtt_prop_t prop, int32_t value); + void (*str_prop)(void *ref, lwmqtt_prop_t prop, lwmqtt_string_t value); + void (*user_prop)(void *ref, lwmqtt_string_t key, lwmqtt_string_t val); +} lwmqtt_property_callbacks_t; + +lwmqtt_err_t lwmqtt_property_visitor(void *ref, lwmqtt_serialized_properties_t props, lwmqtt_property_callbacks_t cb); #endif // LWMQTT_H diff --git a/src/client.c b/src/client.c index 85b3ce4..d5dd13c 100644 --- a/src/client.c +++ b/src/client.c @@ -691,19 +691,22 @@ lwmqtt_err_t lwmqtt_keep_alive(lwmqtt_client_t *client, uint32_t timeout) { return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_property_visitor(void *ref, lwmqtt_serialized_properties_t props, lwmqtt_prop_callback_t cb) { +lwmqtt_err_t lwmqtt_property_visitor(void *ref, lwmqtt_serialized_properties_t props, lwmqtt_property_callbacks_t cb) { uint8_t *p = props.start; uint8_t *end = p + props.size; lwmqtt_err_t err; while (p < end) { - lwmqtt_property_t prop; - err = lwmqtt_read_byte(&p, end, (uint8_t *)&prop.prop); + uint8_t prop, bval; + uint16_t i16val; + uint32_t i32val; + lwmqtt_string_t strval, k, v; + err = lwmqtt_read_byte(&p, end, &prop); if (err != LWMQTT_SUCCESS) { return err; } - switch (prop.prop) { + switch (prop) { // one byte case LWMQTT_PROP_PAYLOAD_FORMAT_INDICATOR: case LWMQTT_PROP_REQUEST_PROBLEM_INFORMATION: @@ -713,10 +716,13 @@ lwmqtt_err_t lwmqtt_property_visitor(void *ref, lwmqtt_serialized_properties_t p case LWMQTT_PROP_WILDCARD_SUBSCRIPTION_AVAILABLE: case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE: case LWMQTT_PROP_SHARED_SUBSCRIPTION_AVAILABLE: - err = lwmqtt_read_byte(&p, end, &prop.value.byte); + err = lwmqtt_read_byte(&p, end, &bval); if (err != LWMQTT_SUCCESS) { return err; } + if (cb.byte_prop) { + cb.byte_prop(ref, prop, bval); + } break; // two byte int @@ -724,10 +730,13 @@ lwmqtt_err_t lwmqtt_property_visitor(void *ref, lwmqtt_serialized_properties_t p case LWMQTT_PROP_RECEIVE_MAXIMUM: case LWMQTT_PROP_TOPIC_ALIAS_MAXIMUM: case LWMQTT_PROP_TOPIC_ALIAS: - err = lwmqtt_read_num(&p, end, &prop.value.int16); + err = lwmqtt_read_num(&p, end, &i16val); if (err != LWMQTT_SUCCESS) { return err; } + if (cb.int16_prop) { + cb.int16_prop(ref, prop, i16val); + } break; // 4 byte int @@ -735,18 +744,24 @@ lwmqtt_err_t lwmqtt_property_visitor(void *ref, lwmqtt_serialized_properties_t p case LWMQTT_PROP_SESSION_EXPIRY_INTERVAL: case LWMQTT_PROP_WILL_DELAY_INTERVAL: case LWMQTT_PROP_MAXIMUM_PACKET_SIZE: - err = lwmqtt_read_num32(&p, end, &prop.value.int32); + err = lwmqtt_read_num32(&p, end, &i32val); if (err != LWMQTT_SUCCESS) { return err; } + if (cb.int32_prop) { + cb.int32_prop(ref, prop, i32val); + } break; // Variable byte int case LWMQTT_PROP_SUBSCRIPTION_IDENTIFIER: - err = lwmqtt_read_varnum(&p, end, &prop.value.int32); + err = lwmqtt_read_varnum(&p, end, &i32val); if (err != LWMQTT_SUCCESS) { return err; } + if (cb.int32_prop) { + cb.int32_prop(ref, prop, i32val); + } break; // UTF-8 string @@ -761,23 +776,32 @@ lwmqtt_err_t lwmqtt_property_visitor(void *ref, lwmqtt_serialized_properties_t p // Arbitrary blobs as the same encoding. case LWMQTT_PROP_CORRELATION_DATA: case LWMQTT_PROP_AUTHENTICATION_DATA: - err = lwmqtt_read_string(&p, end, &prop.value.str); + err = lwmqtt_read_string(&p, end, &strval); if (err != LWMQTT_SUCCESS) { return err; } + if (cb.str_prop) { + cb.str_prop(ref, prop, strval); + } break; case LWMQTT_PROP_USER_PROPERTY: - err = lwmqtt_read_string(&p, end, &prop.value.pair.k); + err = lwmqtt_read_string(&p, end, &k); if (err != LWMQTT_SUCCESS) { return err; } - err = lwmqtt_read_string(&p, end, &prop.value.pair.v); + err = lwmqtt_read_string(&p, end, &v); if (err != LWMQTT_SUCCESS) { return err; } + if (cb.user_prop) { + cb.user_prop(ref, k, v); + } + break; + + default: + return LWMQTT_MISSING_OR_WRONG_PACKET; } - cb(ref, prop); } return LWMQTT_SUCCESS; From ee814689505830c03dd605f8d0b957d972e7d9b6 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Sat, 21 Sep 2019 14:54:06 -0700 Subject: [PATCH 24/26] Implemented all the various puback messages. --- gentests/app/Main.hs | 75 + src/client.c | 27 +- src/packet.c | 56 +- src/packet.h | 10 +- tests/generated.cpp | 40853 +++++++++++++++++++++++------------------ tests/packet.cpp | 16 +- 6 files changed, 22854 insertions(+), 18183 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 0f6f165..97e8482 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -40,6 +40,22 @@ shortprot Protocol50 = "5" v311PubReq :: PublishRequest -> PublishRequest v311PubReq p50 = let (PublishPkt p) = v311mask (PublishPkt p50) in p +data PubACKs = ACK PubACK | REC PubREC | REL PubREL | COMP PubCOMP deriving(Show, Eq) + +instance Arbitrary PubACKs where + arbitrary = oneof [ + ACK <$> arbitrary, + REC <$> arbitrary, + REL <$> arbitrary, + COMP <$> arbitrary + ] + +v311ACKs :: PubACKs -> PubACKs +v311ACKs (ACK p50) = let (PubACKPkt a) = v311mask (PubACKPkt p50) in ACK a +v311ACKs (REC p50) = let (PubRECPkt a) = v311mask (PubRECPkt p50) in REC a +v311ACKs (REL p50) = let (PubRELPkt a) = v311mask (PubRELPkt p50) in REL a +v311ACKs (COMP p50) = let (PubCOMPPkt a) = v311mask (PubCOMPPkt p50) in COMP a + v311SubReq :: SubscribeRequest -> SubscribeRequest v311SubReq p50 = let (SubscribePkt p) = v311mask (SubscribePkt p50) in p @@ -416,6 +432,61 @@ genDiscoTest prot i p@(DisconnectRequest rsn props) = do dr DiscoSubscriptionIdentifiersNotSupported = 0xa1 dr DiscoWildcardSubscriptionsNotSupported = 0xa2 +genPubACKTest :: ProtocolLevel -> Int -> PubACKs -> String +genPubACKTest prot i pkt = enc <> dec + + where + enc = tf (name pkt) "Encode" $ mconcat [ + "uint8_t buf[sizeof(pkt)+10];\n", + genProperties "props" props, + "size_t len;\n", + "lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, ", protlvl prot, ", ", cname pkt, ", 0, ", show pid, ", ", show st, ", props);\n", + "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + "EXPECT_EQ(len, sizeof(pkt));\n", + "EXPECT_ARRAY_EQ(pkt, buf, len);\n" + ] + dec = tf (name pkt) "Decode" $ mconcat [ + "uint16_t packet_id;\n", + "uint8_t status;\n", + "lwmqtt_serialized_properties_t props;\n", + "bool dup;\n", + "lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), ", protlvl prot, ", ", cname pkt, ", &dup, &packet_id, &status, &props);\n", + "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + "EXPECT_EQ(packet_id, ", show pid, ");\n", + "EXPECT_EQ(status, ", show st, ");\n" + ] + + name = ("PubACK" <>) . head . words . show + val (ACK x) = toByteString prot x + val (REC x) = toByteString prot x + val (REL x) = toByteString prot x + val (COMP x) = toByteString prot x + + pid = let (p,_,_) = parts pkt in p + st = let (_,s,_) = parts pkt in s + props = let (_,_,p) = parts pkt in p + + parts (ACK (PubACK a b p)) = (a,b,p) + parts (REC (PubREC a b p)) = (a,b,p) + parts (REL (PubREL a b p)) = (a,b,p) + parts (COMP (PubCOMP a b p)) = (a,b,p) + + cname (ACK _) = "LWMQTT_PUBACK_PACKET" + cname (REC _) = "LWMQTT_PUBREC_PACKET" + cname (REL _) = "LWMQTT_PUBREL_PACKET" + cname (COMP _) = "LWMQTT_PUBCOMP_PACKET" + + -- this is genTestFunc specialized to be more informative here. + tf test tname body = let e = val pkt in + mconcat [ + "// ", show pkt, "\n", + "TEST(", test, shortprot prot, "QCTest, ", tname, show i <> ") {\n", + "uint8_t pkt[] = {" <> hexa e <> "};\n", + body, "\n", + "}\n\n" + ] + + main :: IO () main = do putStrLn [r|#include @@ -447,6 +518,10 @@ extern "C" { f genPublishTest Protocol311 (v311PubReq <$> pubs) f genPublishTest Protocol50 pubs + pubax <- replicateM numTests $ generate arbitrary + f genPubACKTest Protocol311 (v311ACKs <$> pubax) + f genPubACKTest Protocol50 pubax + conns <- replicateM numTests $ generate arbitrary f genConnectTest Protocol311 (userFix . v311ConnReq <$> conns) f genConnectTest Protocol50 (userFix <$> conns) diff --git a/src/client.c b/src/client.c index d5dd13c..7c078d9 100644 --- a/src/client.c +++ b/src/client.c @@ -293,7 +293,9 @@ static lwmqtt_err_t lwmqtt_cycle(lwmqtt_client_t *client, size_t *read, lwmqtt_p // encode ack packet size_t len; - err = lwmqtt_encode_ack(client->write_buf, client->write_buf_size, &len, ack_type, false, packet_id); + lwmqtt_properties_t ackprops = lwmqtt_empty_props; + err = lwmqtt_encode_ack(client->write_buf, client->write_buf_size, &len, client->protocol, ack_type, false, + packet_id, 0, ackprops); if (err != LWMQTT_SUCCESS) { return err; } @@ -312,14 +314,19 @@ static lwmqtt_err_t lwmqtt_cycle(lwmqtt_client_t *client, size_t *read, lwmqtt_p // decode pubrec packet bool dup; uint16_t packet_id; - err = lwmqtt_decode_ack(client->read_buf, client->read_buf_size, LWMQTT_PUBREC_PACKET, &dup, &packet_id); + uint8_t status; + lwmqtt_serialized_properties_t ackprops; + err = lwmqtt_decode_ack(client->read_buf, client->read_buf_size, client->protocol, LWMQTT_PUBREC_PACKET, &dup, + &packet_id, &status, &ackprops); if (err != LWMQTT_SUCCESS) { return err; } // encode pubrel packet size_t len; - err = lwmqtt_encode_ack(client->write_buf, client->write_buf_size, &len, LWMQTT_PUBREL_PACKET, 0, packet_id); + lwmqtt_properties_t props = lwmqtt_empty_props; + err = lwmqtt_encode_ack(client->write_buf, client->write_buf_size, &len, client->protocol, LWMQTT_PUBREL_PACKET, + 0, packet_id, 0, props); if (err != LWMQTT_SUCCESS) { return err; } @@ -338,14 +345,19 @@ static lwmqtt_err_t lwmqtt_cycle(lwmqtt_client_t *client, size_t *read, lwmqtt_p // decode pubrec packet bool dup; uint16_t packet_id; - err = lwmqtt_decode_ack(client->read_buf, client->read_buf_size, LWMQTT_PUBREL_PACKET, &dup, &packet_id); + uint8_t status; + lwmqtt_serialized_properties_t ackprops; + err = lwmqtt_decode_ack(client->read_buf, client->read_buf_size, client->protocol, LWMQTT_PUBREL_PACKET, &dup, + &packet_id, &status, &ackprops); if (err != LWMQTT_SUCCESS) { return err; } // encode pubcomp packet size_t len; - err = lwmqtt_encode_ack(client->write_buf, client->write_buf_size, &len, LWMQTT_PUBCOMP_PACKET, 0, packet_id); + lwmqtt_properties_t props = lwmqtt_empty_props; + err = lwmqtt_encode_ack(client->write_buf, client->write_buf_size, &len, client->protocol, LWMQTT_PUBCOMP_PACKET, + 0, packet_id, 0, props); if (err != LWMQTT_SUCCESS) { return err; } @@ -629,7 +641,10 @@ lwmqtt_err_t lwmqtt_publish(lwmqtt_client_t *client, lwmqtt_string_t topic, lwmq // decode ack packet bool dup; - err = lwmqtt_decode_ack(client->read_buf, client->read_buf_size, ack_type, &dup, &packet_id); + uint8_t status; + lwmqtt_serialized_properties_t ackprops; + err = lwmqtt_decode_ack(client->read_buf, client->read_buf_size, client->protocol, ack_type, &dup, &packet_id, + &status, &ackprops); if (err != LWMQTT_SUCCESS) { return err; } diff --git a/src/packet.c b/src/packet.c index 923d270..098c844 100644 --- a/src/packet.c +++ b/src/packet.c @@ -1,5 +1,8 @@ #include "packet.h" +static lwmqtt_err_t decode_props(uint8_t **buf, const uint8_t *buf_len, lwmqtt_protocol_t protocol, + lwmqtt_serialized_properties_t *props); + lwmqtt_err_t lwmqtt_detect_packet_type(uint8_t *buf, size_t buf_len, lwmqtt_packet_type_t *packet_type) { // set default packet type *packet_type = LWMQTT_NO_PACKET; @@ -311,12 +314,16 @@ lwmqtt_err_t lwmqtt_encode_zero(uint8_t *buf, size_t buf_len, size_t *len, lwmqt return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_decode_ack(uint8_t *buf, size_t buf_len, lwmqtt_packet_type_t packet_type, bool *dup, - uint16_t *packet_id) { +lwmqtt_err_t lwmqtt_decode_ack(uint8_t *buf, size_t buf_len, lwmqtt_protocol_t protocol, + lwmqtt_packet_type_t packet_type, bool *dup, uint16_t *packet_id, uint8_t *status, + lwmqtt_serialized_properties_t *props) { // prepare pointer uint8_t *buf_ptr = buf; uint8_t *buf_end = buf + buf_len; + *status = 0; + props->size = 0; + // read header uint8_t header = 0; lwmqtt_err_t err = lwmqtt_read_byte(&buf_ptr, buf_end, &header); @@ -340,7 +347,7 @@ lwmqtt_err_t lwmqtt_decode_ack(uint8_t *buf, size_t buf_len, lwmqtt_packet_type_ } // check remaining length - if (rem_len != 2) { + if (protocol == LWMQTT_MQTT311 && rem_len != 2) { return LWMQTT_REMAINING_LENGTH_MISMATCH; } @@ -350,11 +357,29 @@ lwmqtt_err_t lwmqtt_decode_ack(uint8_t *buf, size_t buf_len, lwmqtt_packet_type_ return err; } + rem_len -= 2; + + if (rem_len > 0) { + lwmqtt_err_t err = lwmqtt_read_byte(&buf_ptr, buf_end, status); + if (err != LWMQTT_SUCCESS) { + return err; + } + rem_len--; + } + + if (rem_len > 0) { + err = decode_props(&buf_ptr, buf_end, protocol, props); + if (err != LWMQTT_SUCCESS) { + return err; + } + } + return LWMQTT_SUCCESS; } -lwmqtt_err_t lwmqtt_encode_ack(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_packet_type_t packet_type, bool dup, - uint16_t packet_id) { +lwmqtt_err_t lwmqtt_encode_ack(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, + lwmqtt_packet_type_t packet_type, bool dup, uint16_t packet_id, uint8_t status, + lwmqtt_properties_t props) { // prepare pointer uint8_t *buf_ptr = buf; uint8_t *buf_end = buf + buf_len; @@ -377,8 +402,13 @@ lwmqtt_err_t lwmqtt_encode_ack(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt return err; } + size_t rem_len = 2 + (protocol == LWMQTT_MQTT5 ? 1 : 0); + if (props.len > 0) { + rem_len += lwmqtt_propslen(protocol, props); + } + // write remaining length - err = lwmqtt_write_varnum(&buf_ptr, buf_end, 2); + err = lwmqtt_write_varnum(&buf_ptr, buf_end, rem_len); if (err != LWMQTT_SUCCESS) { return err; } @@ -389,6 +419,20 @@ lwmqtt_err_t lwmqtt_encode_ack(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt return err; } + if (protocol == LWMQTT_MQTT5) { + err = lwmqtt_write_byte(&buf_ptr, buf_end, status); + if (err != LWMQTT_SUCCESS) { + return err; + } + } + + if (props.len > 0) { + err = lwmqtt_write_props(&buf_ptr, buf_end, protocol, props); + if (err != LWMQTT_SUCCESS) { + return err; + } + } + // set written length *len = buf_ptr - buf; diff --git a/src/packet.h b/src/packet.h index a2f1fda..70b7ad0 100644 --- a/src/packet.h +++ b/src/packet.h @@ -98,8 +98,9 @@ lwmqtt_err_t lwmqtt_encode_disconnect(uint8_t *buf, size_t buf_len, size_t *len, * @param packet_id - The packet id. * @return An error value. */ -lwmqtt_err_t lwmqtt_decode_ack(uint8_t *buf, size_t buf_len, lwmqtt_packet_type_t packet_type, bool *dup, - uint16_t *packet_id); +lwmqtt_err_t lwmqtt_decode_ack(uint8_t *buf, size_t buf_len, lwmqtt_protocol_t protocol, + lwmqtt_packet_type_t packet_type, bool *dup, uint16_t *packet_id, uint8_t *status, + lwmqtt_serialized_properties_t *props); /** * Encodes an ack (puback, pubrec, pubrel, pubcomp) packet into the supplied buffer. @@ -112,8 +113,9 @@ lwmqtt_err_t lwmqtt_decode_ack(uint8_t *buf, size_t buf_len, lwmqtt_packet_type_ * @param packet_id - The packet id. * @return An error value. */ -lwmqtt_err_t lwmqtt_encode_ack(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_packet_type_t packet_type, bool dup, - uint16_t packet_id); +lwmqtt_err_t lwmqtt_encode_ack(uint8_t *buf, size_t buf_len, size_t *len, lwmqtt_protocol_t protocol, + lwmqtt_packet_type_t packet_type, bool dup, uint16_t packet_id, uint8_t status, + lwmqtt_properties_t props); /** * Decodes a publish packet from the supplied buffer. diff --git a/tests/generated.cpp b/tests/generated.cpp index 4c2d66f..cb64cd4 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,42 +21,43 @@ extern "C" { } \ } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "L\255\GS\208o\194\236\140\156\225\135\244\SO\154#", _pubPktID = 6184, _pubBody = -// "_\160\218auw5\192\154w\154\194:T\135\200\157", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "W\217\244\199\US\166I\171\225H\165\&0\148+>'\185\243\243\254\182\&3\158\130", _pubPktID = 5484, _pubBody = +// "N\151Gu\207\213\209\175\151\241[\RS\128P\129\237\157\250K", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x3c, 0x24, 0x0, 0xf, 0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, - 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23, 0x18, 0x28, 0x5f, 0xa0, 0xda, 0x61, 0x75, - 0x77, 0x35, 0xc0, 0x9a, 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; - uint8_t topic_bytes[] = {0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x2f, 0x0, 0x18, 0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, 0xa5, 0x30, 0x94, + 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82, 0x15, 0x6c, 0x4e, 0x97, 0x47, 0x75, + 0xcf, 0xd5, 0xd1, 0xaf, 0x97, 0xf1, 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; + uint8_t topic_bytes[] = {0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, 0xa5, 0x30, + 0x94, 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, 0x9a, - 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x4e, 0x97, 0x47, 0x75, 0xcf, 0xd5, 0xd1, 0xaf, 0x97, 0xf1, + 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6184, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5484, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "L\255\GS\208o\194\236\140\156\225\135\244\SO\154#", _pubPktID = 6184, _pubBody = -// "_\160\218auw5\192\154w\154\194:T\135\200\157", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "W\217\244\199\US\166I\171\225H\165\&0\148+>'\185\243\243\254\182\&3\158\130", _pubPktID = 5484, _pubBody = +// "N\151Gu\207\213\209\175\151\241[\RS\128P\129\237\157\250K", _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x3c, 0x24, 0x0, 0xf, 0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, - 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23, 0x18, 0x28, 0x5f, 0xa0, 0xda, 0x61, 0x75, - 0x77, 0x35, 0xc0, 0x9a, 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; + uint8_t pkt[] = {0x3b, 0x2f, 0x0, 0x18, 0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, 0xa5, 0x30, 0x94, + 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82, 0x15, 0x6c, 0x4e, 0x97, 0x47, 0x75, + 0xcf, 0xd5, 0xd1, 0xaf, 0x97, 0xf1, 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -65,53 +66,62 @@ TEST(Publish311QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, 0x9a, - 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, 0xa5, 0x30, + 0x94, 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4e, 0x97, 0x47, 0x75, 0xcf, 0xd5, 0xd1, 0xaf, 0x97, 0xf1, + 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 6184); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 5484); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\198\DC1L:\231)\185\220\223D\v\EOT\217<", _pubPktID = 6873, _pubBody = "\ESC\"[|\180", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\164_xCoe\161\\\SYN8\247~X\178U\EOT\201\239d\NUL\v\219\239", _pubPktID = 617, _pubBody = +// "\203\"\151M\221\179{\230\DC3c\185\FS\183-\225\169\214\ETX\128\159\170E\186\239\ESC\153\192\142", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x35, 0x17, 0x0, 0xe, 0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, - 0x44, 0xb, 0x4, 0xd9, 0x3c, 0x1a, 0xd9, 0x1b, 0x22, 0x5b, 0x7c, 0xb4}; - uint8_t topic_bytes[] = {0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x37, 0x0, 0x17, 0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, + 0x7e, 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef, 0x2, 0x69, 0xcb, + 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, 0xe1, 0xa9, + 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; + uint8_t topic_bytes[] = {0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, + 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x1b, 0x22, 0x5b, 0x7c, 0xb4}; + uint8_t msg_bytes[] = {0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, + 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + msg.payload_len = 28; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 6873, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 617, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\198\DC1L:\231)\185\220\223D\v\EOT\217<", _pubPktID = 6873, _pubBody = "\ESC\"[|\180", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\164_xCoe\161\\\SYN8\247~X\178U\EOT\201\239d\NUL\v\219\239", _pubPktID = 617, _pubBody = +// "\203\"\151M\221\179{\230\DC3c\185\FS\183-\225\169\214\ETX\128\159\170E\186\239\ESC\153\192\142", _pubProps = []} TEST(Publish311QCTest, Decode2) { - uint8_t pkt[] = {0x35, 0x17, 0x0, 0xe, 0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, - 0x44, 0xb, 0x4, 0xd9, 0x3c, 0x1a, 0xd9, 0x1b, 0x22, 0x5b, 0x7c, 0xb4}; + uint8_t pkt[] = {0x3b, 0x37, 0x0, 0x17, 0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, + 0x7e, 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef, 0x2, 0x69, 0xcb, + 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, 0xe1, 0xa9, + 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -120,57 +130,59 @@ TEST(Publish311QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1b, 0x22, 0x5b, 0x7c, 0xb4}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, + 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, + 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 6873); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + EXPECT_EQ(packet_id, 617); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "^W\131\160\253B\156\130SrVB\238=\158m_\253\242\178N", _pubPktID = 12282, _pubBody = -// "\169\159cc\RSh\239_U\ETB\NAK\223f", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "]\DEL\239p\251\205\214zi\204\179\194Y\158", _pubPktID = 0, _pubBody = +// "|\207v\144\230\175\FSN\178\165\215\DC3\EM\250\162\187\135\181", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x3a, 0x26, 0x0, 0x15, 0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, - 0x56, 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e, 0x2f, 0xfa, 0xa9, - 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; - uint8_t topic_bytes[] = {0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, 0x56, - 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x22, 0x0, 0xe, 0x5d, 0x7f, 0xef, 0x70, 0xfb, 0xcd, 0xd6, 0x7a, + 0x69, 0xcc, 0xb3, 0xc2, 0x59, 0x9e, 0x7c, 0xcf, 0x76, 0x90, 0xe6, 0xaf, + 0x1c, 0x4e, 0xb2, 0xa5, 0xd7, 0x13, 0x19, 0xfa, 0xa2, 0xbb, 0x87, 0xb5}; + uint8_t topic_bytes[] = {0x5d, 0x7f, 0xef, 0x70, 0xfb, 0xcd, 0xd6, 0x7a, 0x69, 0xcc, 0xb3, 0xc2, 0x59, 0x9e}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xa9, 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x7c, 0xcf, 0x76, 0x90, 0xe6, 0xaf, 0x1c, 0x4e, 0xb2, + 0xa5, 0xd7, 0x13, 0x19, 0xfa, 0xa2, 0xbb, 0x87, 0xb5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 18; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 12282, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "^W\131\160\253B\156\130SrVB\238=\158m_\253\242\178N", _pubPktID = 12282, _pubBody = -// "\169\159cc\RSh\239_U\ETB\NAK\223f", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "]\DEL\239p\251\205\214zi\204\179\194Y\158", _pubPktID = 0, _pubBody = +// "|\207v\144\230\175\FSN\178\165\215\DC3\EM\250\162\187\135\181", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x3a, 0x26, 0x0, 0x15, 0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, - 0x56, 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e, 0x2f, 0xfa, 0xa9, - 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; + uint8_t pkt[] = {0x39, 0x22, 0x0, 0xe, 0x5d, 0x7f, 0xef, 0x70, 0xfb, 0xcd, 0xd6, 0x7a, + 0x69, 0xcc, 0xb3, 0xc2, 0x59, 0x9e, 0x7c, 0xcf, 0x76, 0x90, 0xe6, 0xaf, + 0x1c, 0x4e, 0xb2, 0xa5, 0xd7, 0x13, 0x19, 0xfa, 0xa2, 0xbb, 0x87, 0xb5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -179,58 +191,51 @@ TEST(Publish311QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5e, 0x57, 0x83, 0xa0, 0xfd, 0x42, 0x9c, 0x82, 0x53, 0x72, 0x56, - 0x42, 0xee, 0x3d, 0x9e, 0x6d, 0x5f, 0xfd, 0xf2, 0xb2, 0x4e}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa9, 0x9f, 0x63, 0x63, 0x1e, 0x68, 0xef, 0x5f, 0x55, 0x17, 0x15, 0xdf, 0x66}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x5d, 0x7f, 0xef, 0x70, 0xfb, 0xcd, 0xd6, 0x7a, 0x69, 0xcc, 0xb3, 0xc2, 0x59, 0x9e}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x7c, 0xcf, 0x76, 0x90, 0xe6, 0xaf, 0x1c, 0x4e, 0xb2, + 0xa5, 0xd7, 0x13, 0x19, 0xfa, 0xa2, 0xbb, 0x87, 0xb5}; + lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 12282); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 13); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\223~\247S\221_\137\253\202\t\SO<\197\171X=\DC1'\196\ACK", _pubPktID = 7369, _pubBody = -// "\218\SI\242\t\138\r\SO\ESC[\224\207", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\&8\RSE", _pubPktID = 14265, +// _pubBody = "OtS\167", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x34, 0x23, 0x0, 0x14, 0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, - 0x9, 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6, 0x1c, 0xc9, - 0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; - uint8_t topic_bytes[] = {0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, - 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0xc, 0x0, 0x4, 0xff, 0x38, 0x1e, 0x45, 0x37, 0xb9, 0x4f, 0x74, 0x53, 0xa7}; + uint8_t topic_bytes[] = {0xff, 0x38, 0x1e, 0x45}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; + msg.retained = true; + uint8_t msg_bytes[] = {0x4f, 0x74, 0x53, 0xa7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 4; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7369, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 14265, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\223~\247S\221_\137\253\202\t\SO<\197\171X=\DC1'\196\ACK", _pubPktID = 7369, _pubBody = -// "\218\SI\242\t\138\r\SO\ESC[\224\207", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\&8\RSE", _pubPktID = 14265, +// _pubBody = "OtS\167", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x34, 0x23, 0x0, 0x14, 0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, - 0x9, 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6, 0x1c, 0xc9, - 0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; + uint8_t pkt[] = {0x3d, 0xc, 0x0, 0x4, 0xff, 0x38, 0x1e, 0x45, 0x37, 0xb9, 0x4f, 0x74, 0x53, 0xa7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -239,53 +244,57 @@ TEST(Publish311QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, - 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xff, 0x38, 0x1e, 0x45}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4f, 0x74, 0x53, 0xa7}; + lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 7369); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 14265); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 4); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\250\191\190jan\209", _pubPktID = -// 6761, _pubBody = "z-\195\235\243\220Q", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\175\137\vj?Vv\214\&1|l\a\RS\191\237\148\187\223g^\158f\195W\245R\159", _pubPktID = 0, _pubBody = +// "\133\170\157HgVe\197\170\203V\231", _pubProps = []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x3c, 0x12, 0x0, 0x7, 0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, - 0xd1, 0x1a, 0x69, 0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; - uint8_t topic_bytes[] = {0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x29, 0x0, 0x1b, 0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, + 0x7, 0x1e, 0xbf, 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, + 0x9f, 0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; + uint8_t topic_bytes[] = {0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, 0x7, 0x1e, 0xbf, + 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 12; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 6761, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\250\191\190jan\209", _pubPktID = -// 6761, _pubBody = "z-\195\235\243\220Q", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\175\137\vj?Vv\214\&1|l\a\RS\191\237\148\187\223g^\158f\195W\245R\159", _pubPktID = 0, _pubBody = +// "\133\170\157HgVe\197\170\203V\231", _pubProps = []} TEST(Publish311QCTest, Decode5) { - uint8_t pkt[] = {0x3c, 0x12, 0x0, 0x7, 0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, - 0xd1, 0x1a, 0x69, 0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; + uint8_t pkt[] = {0x39, 0x29, 0x0, 0x1b, 0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, + 0x7, 0x1e, 0xbf, 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, + 0x9f, 0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -294,57 +303,53 @@ TEST(Publish311QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, 0x7, 0x1e, 0xbf, + 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 6761); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\229Y\156\186GOd\EOT\247\ETB\224\251-\228h{^Q!\246\b\DEL\225\NUL{/Q ", _pubPktID = 0, _pubBody = "<@\201Iv", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\fn)\RS", _pubPktID = 5499, _pubBody +// = "\156I\SUB\231\236b\ENQ\137\237\r\NAK:[\222g\135", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x39, 0x23, 0x0, 0x1c, 0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, - 0x17, 0xe0, 0xfb, 0x2d, 0xe4, 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, - 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20, 0x3c, 0x40, 0xc9, 0x49, 0x76}; - uint8_t topic_bytes[] = {0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, 0x2d, 0xe4, - 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x18, 0x0, 0x4, 0xc, 0x6e, 0x29, 0x1e, 0x15, 0x7b, 0x9c, 0x49, 0x1a, + 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; + uint8_t topic_bytes[] = {0xc, 0x6e, 0x29, 0x1e}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x3c, 0x40, 0xc9, 0x49, 0x76}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x9c, 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + msg.payload_len = 16; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5499, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\229Y\156\186GOd\EOT\247\ETB\224\251-\228h{^Q!\246\b\DEL\225\NUL{/Q ", _pubPktID = 0, _pubBody = "<@\201Iv", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\fn)\RS", _pubPktID = 5499, _pubBody +// = "\156I\SUB\231\236b\ENQ\137\237\r\NAK:[\222g\135", _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x39, 0x23, 0x0, 0x1c, 0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, - 0x17, 0xe0, 0xfb, 0x2d, 0xe4, 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, - 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20, 0x3c, 0x40, 0xc9, 0x49, 0x76}; + uint8_t pkt[] = {0x3a, 0x18, 0x0, 0x4, 0xc, 0x6e, 0x29, 0x1e, 0x15, 0x7b, 0x9c, 0x49, 0x1a, + 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -353,58 +358,61 @@ TEST(Publish311QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, 0x2d, 0xe4, - 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x3c, 0x40, 0xc9, 0x49, 0x76}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc, 0x6e, 0x29, 0x1e}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9c, 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, + 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 5499); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\242\EM\182T\137\181\\_\NUL\137\135\&0\211", _pubPktID = 31937, _pubBody = -// "\242\196\240\145t\150mj\CANV\251\200\142o\192\150G", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\213\v\236\218d\193\162h[\237\155\196\145\159\198g\146\138\155\197\164", _pubPktID = 0, _pubBody = +// "\189\233\193\r`$@\171\DC1\230\203j\203\187J\148oG\177\155\SUB\253\232\211\t\DC4#\230", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x35, 0x22, 0x0, 0xd, 0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, - 0x0, 0x89, 0x87, 0x30, 0xd3, 0x7c, 0xc1, 0xf2, 0xc4, 0xf0, 0x91, 0x74, - 0x96, 0x6d, 0x6a, 0x18, 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; - uint8_t topic_bytes[] = {0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x33, 0x0, 0x15, 0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, + 0x9b, 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4, 0xbd, 0xe9, 0xc1, + 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, 0x4a, 0x94, 0x6f, + 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; + uint8_t topic_bytes[] = {0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, 0x9b, + 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, - 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, + 0x4a, 0x94, 0x6f, 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; + msg.payload_len = 28; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31937, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\242\EM\182T\137\181\\_\NUL\137\135\&0\211", _pubPktID = 31937, _pubBody = -// "\242\196\240\145t\150mj\CANV\251\200\142o\192\150G", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\213\v\236\218d\193\162h[\237\155\196\145\159\198g\146\138\155\197\164", _pubPktID = 0, _pubBody = +// "\189\233\193\r`$@\171\DC1\230\203j\203\187J\148oG\177\155\SUB\253\232\211\t\DC4#\230", _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x35, 0x22, 0x0, 0xd, 0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, - 0x0, 0x89, 0x87, 0x30, 0xd3, 0x7c, 0xc1, 0xf2, 0xc4, 0xf0, 0x91, 0x74, - 0x96, 0x6d, 0x6a, 0x18, 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; + uint8_t pkt[] = {0x38, 0x33, 0x0, 0x15, 0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, + 0x9b, 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4, 0xbd, 0xe9, 0xc1, + 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, 0x4a, 0x94, 0x6f, + 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -413,51 +421,60 @@ TEST(Publish311QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, - 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 31937); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + uint8_t exp_topic_bytes[] = {0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, 0x9b, + 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, + 0x4a, 0x94, 0x6f, 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q", _pubPktID = 31364, _pubBody = -// "J\NAK\203\196\226\"\223\GS\200a", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "=\249\252\228\210\187\154\150C8*\146,\US8\152\128\152", _pubPktID = 8421, _pubBody = +// "4O\FS\186T\238#\USg\NULl\152\154\239\249\SUB2>H#\188", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x33, 0xf, 0x0, 0x1, 0x71, 0x7a, 0x84, 0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; - uint8_t topic_bytes[] = {0x71}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x2b, 0x0, 0x12, 0x3d, 0xf9, 0xfc, 0xe4, 0xd2, 0xbb, 0x9a, 0x96, 0x43, 0x38, 0x2a, + 0x92, 0x2c, 0x1f, 0x38, 0x98, 0x80, 0x98, 0x20, 0xe5, 0x34, 0x4f, 0x1c, 0xba, 0x54, 0xee, + 0x23, 0x1f, 0x67, 0x0, 0x6c, 0x98, 0x9a, 0xef, 0xf9, 0x1a, 0x32, 0x3e, 0x48, 0x23, 0xbc}; + uint8_t topic_bytes[] = {0x3d, 0xf9, 0xfc, 0xe4, 0xd2, 0xbb, 0x9a, 0x96, 0x43, + 0x38, 0x2a, 0x92, 0x2c, 0x1f, 0x38, 0x98, 0x80, 0x98}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; + msg.retained = false; + uint8_t msg_bytes[] = {0x34, 0x4f, 0x1c, 0xba, 0x54, 0xee, 0x23, 0x1f, 0x67, 0x0, 0x6c, + 0x98, 0x9a, 0xef, 0xf9, 0x1a, 0x32, 0x3e, 0x48, 0x23, 0xbc}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31364, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8421, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q", _pubPktID = 31364, _pubBody = -// "J\NAK\203\196\226\"\223\GS\200a", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "=\249\252\228\210\187\154\150C8*\146,\US8\152\128\152", _pubPktID = 8421, _pubBody = +// "4O\FS\186T\238#\USg\NULl\152\154\239\249\SUB2>H#\188", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x33, 0xf, 0x0, 0x1, 0x71, 0x7a, 0x84, 0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; + uint8_t pkt[] = {0x32, 0x2b, 0x0, 0x12, 0x3d, 0xf9, 0xfc, 0xe4, 0xd2, 0xbb, 0x9a, 0x96, 0x43, 0x38, 0x2a, + 0x92, 0x2c, 0x1f, 0x38, 0x98, 0x80, 0x98, 0x20, 0xe5, 0x34, 0x4f, 0x1c, 0xba, 0x54, 0xee, + 0x23, 0x1f, 0x67, 0x0, 0x6c, 0x98, 0x9a, 0xef, 0xf9, 0x1a, 0x32, 0x3e, 0x48, 0x23, 0xbc}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -466,57 +483,54 @@ TEST(Publish311QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x71}; - lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4a, 0x15, 0xcb, 0xc4, 0xe2, 0x22, 0xdf, 0x1d, 0xc8, 0x61}; - lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3d, 0xf9, 0xfc, 0xe4, 0xd2, 0xbb, 0x9a, 0x96, 0x43, + 0x38, 0x2a, 0x92, 0x2c, 0x1f, 0x38, 0x98, 0x80, 0x98}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x34, 0x4f, 0x1c, 0xba, 0x54, 0xee, 0x23, 0x1f, 0x67, 0x0, 0x6c, + 0x98, 0x9a, 0xef, 0xf9, 0x1a, 0x32, 0x3e, 0x48, 0x23, 0xbc}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 31364); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 8421); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\144\171\130\USB\155\212\163\136\212\154", _pubPktID = 8173, _pubBody = -// "\142\178\132u\236\130\153F\CANno\142\151\241\209\208\162\246\156\249\199", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\SO\191\141\159\DC1$vw", _pubPktID = +// 301, _pubBody = "`\195\&7\ESC_\216\219\237?~,\244", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x33, 0x24, 0x0, 0xb, 0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, - 0xd4, 0x9a, 0x1f, 0xed, 0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, - 0x6e, 0x6f, 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; - uint8_t topic_bytes[] = {0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x18, 0x0, 0x8, 0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77, 0x1, + 0x2d, 0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; + uint8_t topic_bytes[] = {0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, - 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; + uint8_t msg_bytes[] = {0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 12; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8173, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 301, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\144\171\130\USB\155\212\163\136\212\154", _pubPktID = 8173, _pubBody = -// "\142\178\132u\236\130\153F\CANno\142\151\241\209\208\162\246\156\249\199", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\SO\191\141\159\DC1$vw", _pubPktID = +// 301, _pubBody = "`\195\&7\ESC_\216\219\237?~,\244", _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x33, 0x24, 0x0, 0xb, 0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, - 0xd4, 0x9a, 0x1f, 0xed, 0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, - 0x6e, 0x6f, 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; + uint8_t pkt[] = {0x3b, 0x18, 0x0, 0x8, 0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77, 0x1, + 0x2d, 0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -525,54 +539,52 @@ TEST(Publish311QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, - 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 8173); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 301); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "@\179\160", _pubPktID = 5779, -// _pubBody = "+>\SI\ESC\130^\213\173\147\167D\FS\254\153\218c\237\133\220\156Zk\211\207", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\227=\STX\236\214\&2\250\EM@M^\ENQ\161\aE8", _pubPktID = 19635, _pubBody = "\EOT\EM", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x34, 0x1f, 0x0, 0x3, 0x40, 0xb3, 0xa0, 0x16, 0x93, 0x2b, 0x3e, 0xf, 0x1b, 0x82, 0x5e, 0xd5, 0xad, - 0x93, 0xa7, 0x44, 0x1c, 0xfe, 0x99, 0xda, 0x63, 0xed, 0x85, 0xdc, 0x9c, 0x5a, 0x6b, 0xd3, 0xcf}; - uint8_t topic_bytes[] = {0x40, 0xb3, 0xa0}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x16, 0x0, 0x10, 0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, + 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38, 0x4c, 0xb3, 0x4, 0x19}; + uint8_t topic_bytes[] = {0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x2b, 0x3e, 0xf, 0x1b, 0x82, 0x5e, 0xd5, 0xad, 0x93, 0xa7, 0x44, 0x1c, - 0xfe, 0x99, 0xda, 0x63, 0xed, 0x85, 0xdc, 0x9c, 0x5a, 0x6b, 0xd3, 0xcf}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x4, 0x19}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 2; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 5779, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 19635, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "@\179\160", _pubPktID = 5779, -// _pubBody = "+>\SI\ESC\130^\213\173\147\167D\FS\254\153\218c\237\133\220\156Zk\211\207", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\227=\STX\236\214\&2\250\EM@M^\ENQ\161\aE8", _pubPktID = 19635, _pubBody = "\EOT\EM", _pubProps = []} TEST(Publish311QCTest, Decode10) { - uint8_t pkt[] = {0x34, 0x1f, 0x0, 0x3, 0x40, 0xb3, 0xa0, 0x16, 0x93, 0x2b, 0x3e, 0xf, 0x1b, 0x82, 0x5e, 0xd5, 0xad, - 0x93, 0xa7, 0x44, 0x1c, 0xfe, 0x99, 0xda, 0x63, 0xed, 0x85, 0xdc, 0x9c, 0x5a, 0x6b, 0xd3, 0xcf}; + uint8_t pkt[] = {0x3b, 0x16, 0x0, 0x10, 0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, + 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38, 0x4c, 0xb3, 0x4, 0x19}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -581,40 +593,40 @@ TEST(Publish311QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x40, 0xb3, 0xa0}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2b, 0x3e, 0xf, 0x1b, 0x82, 0x5e, 0xd5, 0xad, 0x93, 0xa7, 0x44, 0x1c, - 0xfe, 0x99, 0xda, 0x63, 0xed, 0x85, 0xdc, 0x9c, 0x5a, 0x6b, 0xd3, 0xcf}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 5779); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + uint8_t exp_topic_bytes[] = {0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, + 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38}; + lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4, 0x19}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 19635); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "P\177\NAK.\190\171\224\139\&2\248]=\179n\DC4k\146\152\175\210\205`3|\135\&8i\209", _pubPktID = 19270, _pubBody = -// "\134\ENQKL\159E.\211+^\240\187\146\NAK7dRg\129.m\133\DLE\152C\ESCJ\160\203", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\207FX\fp\139\210\201Q\185\161i$\222\214\221\238\n.\134\157L7\178\&1", _pubPktID = 10816, _pubBody = +// "b[\173.*\158(\194-\180ZS\221\236\188\168\182\172p\192\216\246\196\176\200\248\&1\232a", _pubProps = []} TEST(Publish311QCTest, Encode11) { - uint8_t pkt[] = {0x32, 0x3d, 0x0, 0x1c, 0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, - 0xb3, 0x6e, 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1, - 0x4b, 0x46, 0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, - 0x37, 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; - uint8_t topic_bytes[] = {0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, 0xb3, 0x6e, - 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x3a, 0x0, 0x19, 0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, + 0x69, 0x24, 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31, 0x2a, + 0x40, 0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, + 0xbc, 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; + uint8_t topic_bytes[] = {0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, 0x69, 0x24, + 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, - 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; + uint8_t msg_bytes[] = {0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, 0xbc, + 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 29; @@ -622,20 +634,20 @@ TEST(Publish311QCTest, Encode11) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 19270, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10816, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "P\177\NAK.\190\171\224\139\&2\248]=\179n\DC4k\146\152\175\210\205`3|\135\&8i\209", _pubPktID = 19270, _pubBody = -// "\134\ENQKL\159E.\211+^\240\187\146\NAK7dRg\129.m\133\DLE\152C\ESCJ\160\203", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\207FX\fp\139\210\201Q\185\161i$\222\214\221\238\n.\134\157L7\178\&1", _pubPktID = 10816, _pubBody = +// "b[\173.*\158(\194-\180ZS\221\236\188\168\182\172p\192\216\246\196\176\200\248\&1\232a", _pubProps = []} TEST(Publish311QCTest, Decode11) { - uint8_t pkt[] = {0x32, 0x3d, 0x0, 0x1c, 0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, - 0xb3, 0x6e, 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1, - 0x4b, 0x46, 0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, - 0x37, 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; + uint8_t pkt[] = {0x34, 0x3a, 0x0, 0x19, 0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, + 0x69, 0x24, 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31, 0x2a, + 0x40, 0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, + 0xbc, 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -644,57 +656,62 @@ TEST(Publish311QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, 0xb3, 0x6e, - 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, - 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; + uint8_t exp_topic_bytes[] = {0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, 0x69, 0x24, + 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, 0xbc, + 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 19270); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(packet_id, 10816); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); EXPECT_EQ(msg.payload_len, 29); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DLE", _pubPktID = 0, _pubBody = -// "\DC4s\199\ACKg\249\133\ENQ\157\223\145\&2NM^T\137xH3\226=j,\r\239U\ACK\153\210", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "C:\210I?H\140\153\163\FS\190\141PA\209Z6\210G=S\217\242\219S\237\226\a", _pubPktID = 780, _pubBody = +// "\185b.\FS\147|\157\223\176\240\ENQy\185\208\DC4\186(topic.data), 1); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + uint8_t exp_topic_bytes[] = {0x43, 0x3a, 0xd2, 0x49, 0x3f, 0x48, 0x8c, 0x99, 0xa3, 0x1c, 0xbe, 0x8d, 0x50, 0x41, + 0xd1, 0x5a, 0x36, 0xd2, 0x47, 0x3d, 0x53, 0xd9, 0xf2, 0xdb, 0x53, 0xed, 0xe2, 0x7}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb9, 0x62, 0x2e, 0x1c, 0x93, 0x7c, 0x9d, 0xdf, 0xb0, 0xf0, 0x5, 0x79, 0xb9, 0xd0, + 0x14, 0xba, 0x3c, 0x45, 0xdb, 0x94, 0x83, 0xd4, 0xdf, 0x85, 0xb3, 0x11, 0xfd, 0xa9}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 780); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\171b\DC1\233\"[\161x\tR2\b\143\ap\176)0\156/\230\155\ETBx\154h*|", _pubPktID = 3357, _pubBody = "\139", _pubProps = -// []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "x\170\228C2\140C\ACKD\FS/[\214\EOT\SOH", _pubPktID = 0, _pubBody = "\185", _pubProps = []} TEST(Publish311QCTest, Encode13) { - uint8_t pkt[] = {0x3c, 0x21, 0x0, 0x1c, 0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, - 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, - 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c, 0xd, 0x1d, 0x8b}; - uint8_t topic_bytes[] = {0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, - 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x12, 0x0, 0xf, 0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, + 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1, 0xb9}; + uint8_t topic_bytes[] = {0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x8b}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xb9}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 1; @@ -742,19 +757,17 @@ TEST(Publish311QCTest, Encode13) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 3357, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\171b\DC1\233\"[\161x\tR2\b\143\ap\176)0\156/\230\155\ETBx\154h*|", _pubPktID = 3357, _pubBody = "\139", _pubProps = -// []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "x\170\228C2\140C\ACKD\FS/[\214\EOT\SOH", _pubPktID = 0, _pubBody = "\185", _pubProps = []} TEST(Publish311QCTest, Decode13) { - uint8_t pkt[] = {0x3c, 0x21, 0x0, 0x1c, 0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, - 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, - 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c, 0xd, 0x1d, 0x8b}; + uint8_t pkt[] = {0x31, 0x12, 0x0, 0xf, 0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, + 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1, 0xb9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -763,61 +776,55 @@ TEST(Publish311QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, - 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8b}; + uint8_t exp_topic_bytes[] = {0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb9}; lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 3357); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); EXPECT_EQ(msg.payload_len, 1); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\243\197\208\135\165\n\174^Z4\184\231\152+\166\ETX\175`\187\229\171:\143\196\rO\140G", _pubPktID = 31669, _pubBody = -// "\165yk,.\240\234\134]\245eA\SI\171\146\201\234a.\165", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\EM\181N`\v\241\NAKi\133lU\172 +// ~\192\152\DLE2\173\193\158\SOH\252\&8/.\RS", _pubPktID = 21275, _pubBody = "'\189s+\222o/\187^\161", _pubProps = []} TEST(Publish311QCTest, Encode14) { - uint8_t pkt[] = {0x34, 0x34, 0x0, 0x1c, 0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, - 0xb8, 0xe7, 0x98, 0x2b, 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, - 0xd, 0x4f, 0x8c, 0x47, 0x7b, 0xb5, 0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, - 0x5d, 0xf5, 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; - uint8_t topic_bytes[] = {0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, 0x2b, - 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x29, 0x0, 0x1b, 0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, + 0xac, 0x20, 0x7e, 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, + 0x1e, 0x53, 0x1b, 0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; + uint8_t topic_bytes[] = {0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, 0xac, 0x20, 0x7e, + 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, 0x1e}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, 0x5d, 0xf5, - 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; + uint8_t msg_bytes[] = {0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 10; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31669, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 21275, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\243\197\208\135\165\n\174^Z4\184\231\152+\166\ETX\175`\187\229\171:\143\196\rO\140G", _pubPktID = 31669, _pubBody = -// "\165yk,.\240\234\134]\245eA\SI\171\146\201\234a.\165", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\EM\181N`\v\241\NAKi\133lU\172 +// ~\192\152\DLE2\173\193\158\SOH\252\&8/.\RS", _pubPktID = 21275, _pubBody = "'\189s+\222o/\187^\161", _pubProps = []} TEST(Publish311QCTest, Decode14) { - uint8_t pkt[] = {0x34, 0x34, 0x0, 0x1c, 0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, - 0xb8, 0xe7, 0x98, 0x2b, 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, - 0xd, 0x4f, 0x8c, 0x47, 0x7b, 0xb5, 0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, - 0x5d, 0xf5, 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; + uint8_t pkt[] = {0x32, 0x29, 0x0, 0x1b, 0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, + 0xac, 0x20, 0x7e, 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, + 0x1e, 0x53, 0x1b, 0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -826,59 +833,56 @@ TEST(Publish311QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, 0x2b, - 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, 0x5d, 0xf5, - 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, 0xac, 0x20, 0x7e, + 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, 0x1e}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 31669); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_EQ(packet_id, 21275); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\v\172h\241z\159Z'\153h\STXiS.\STX&a\166|\147~\ETBbP\194\242$`q", _pubPktID = 29118, _pubBody = -// "\155\GS\134h\241\DC2\174", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\176\EMg\233", _pubPktID = 31111, +// _pubBody = "e\163\181)\SYN\133\198/d\225\216\252\177\&5v[\251\&3\219\232\135\&2\251>E\155#\DLE\254", _pubProps = []} TEST(Publish311QCTest, Encode15) { - uint8_t pkt[] = {0x33, 0x28, 0x0, 0x1d, 0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, - 0x2, 0x69, 0x53, 0x2e, 0x2, 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, - 0xc2, 0xf2, 0x24, 0x60, 0x71, 0x71, 0xbe, 0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; - uint8_t topic_bytes[] = {0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, 0x53, 0x2e, 0x2, - 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x25, 0x0, 0x4, 0xb0, 0x19, 0x67, 0xe9, 0x79, 0x87, 0x65, 0xa3, 0xb5, + 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, 0x5b, + 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; + uint8_t topic_bytes[] = {0xb0, 0x19, 0x67, 0xe9}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x65, 0xa3, 0xb5, 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, + 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 29; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 29118, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31111, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\v\172h\241z\159Z'\153h\STXiS.\STX&a\166|\147~\ETBbP\194\242$`q", _pubPktID = 29118, _pubBody = -// "\155\GS\134h\241\DC2\174", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\176\EMg\233", _pubPktID = 31111, +// _pubBody = "e\163\181)\SYN\133\198/d\225\216\252\177\&5v[\251\&3\219\232\135\&2\251>E\155#\DLE\254", _pubProps = []} TEST(Publish311QCTest, Decode15) { - uint8_t pkt[] = {0x33, 0x28, 0x0, 0x1d, 0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, - 0x2, 0x69, 0x53, 0x2e, 0x2, 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, - 0xc2, 0xf2, 0x24, 0x60, 0x71, 0x71, 0xbe, 0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; + uint8_t pkt[] = {0x34, 0x25, 0x0, 0x4, 0xb0, 0x19, 0x67, 0xe9, 0x79, 0x87, 0x65, 0xa3, 0xb5, + 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, 0x5b, + 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -887,61 +891,58 @@ TEST(Publish311QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, 0x53, 0x2e, 0x2, - 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb0, 0x19, 0x67, 0xe9}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x65, 0xa3, 0xb5, 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, + 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29118); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 31111); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "q+J\205\r\197\201+\DLE\216\DC4\207\206\SI\242\241\137\SUB\213\246\&1\NUL%\242b\204", _pubPktID = 0, _pubBody = -// "\137[\151L+\\\238\187\158\137/}8}\vL\159\208\134\DC4\192", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\169\&0\211V\249\144\&4+[\166\254\135\144\241\n\198\162\233\181\161i\132\132\ENQ\204\191", _pubPktID = 8952, +// _pubBody = "\173A\231|1\170\255\146o\191\190\DC2+uY", _pubProps = []} TEST(Publish311QCTest, Encode16) { - uint8_t pkt[] = {0x39, 0x31, 0x0, 0x1a, 0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, - 0xd8, 0x14, 0xcf, 0xce, 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, - 0x25, 0xf2, 0x62, 0xcc, 0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, - 0x89, 0x2f, 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; - uint8_t topic_bytes[] = {0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, 0xd8, 0x14, 0xcf, 0xce, - 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, 0x25, 0xf2, 0x62, 0xcc}; + uint8_t pkt[] = {0x3b, 0x2d, 0x0, 0x1a, 0xa9, 0x30, 0xd3, 0x56, 0xf9, 0x90, 0x34, 0x2b, 0x5b, 0xa6, 0xfe, 0x87, + 0x90, 0xf1, 0xa, 0xc6, 0xa2, 0xe9, 0xb5, 0xa1, 0x69, 0x84, 0x84, 0x5, 0xcc, 0xbf, 0x22, 0xf8, + 0xad, 0x41, 0xe7, 0x7c, 0x31, 0xaa, 0xff, 0x92, 0x6f, 0xbf, 0xbe, 0x12, 0x2b, 0x75, 0x59}; + uint8_t topic_bytes[] = {0xa9, 0x30, 0xd3, 0x56, 0xf9, 0x90, 0x34, 0x2b, 0x5b, 0xa6, 0xfe, 0x87, 0x90, + 0xf1, 0xa, 0xc6, 0xa2, 0xe9, 0xb5, 0xa1, 0x69, 0x84, 0x84, 0x5, 0xcc, 0xbf}; lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, 0x89, 0x2f, - 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; + uint8_t msg_bytes[] = {0xad, 0x41, 0xe7, 0x7c, 0x31, 0xaa, 0xff, 0x92, 0x6f, 0xbf, 0xbe, 0x12, 0x2b, 0x75, 0x59}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 8952, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "q+J\205\r\197\201+\DLE\216\DC4\207\206\SI\242\241\137\SUB\213\246\&1\NUL%\242b\204", _pubPktID = 0, _pubBody = -// "\137[\151L+\\\238\187\158\137/}8}\vL\159\208\134\DC4\192", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\169\&0\211V\249\144\&4+[\166\254\135\144\241\n\198\162\233\181\161i\132\132\ENQ\204\191", _pubPktID = 8952, +// _pubBody = "\173A\231|1\170\255\146o\191\190\DC2+uY", _pubProps = []} TEST(Publish311QCTest, Decode16) { - uint8_t pkt[] = {0x39, 0x31, 0x0, 0x1a, 0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, - 0xd8, 0x14, 0xcf, 0xce, 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, - 0x25, 0xf2, 0x62, 0xcc, 0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, - 0x89, 0x2f, 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; + uint8_t pkt[] = {0x3b, 0x2d, 0x0, 0x1a, 0xa9, 0x30, 0xd3, 0x56, 0xf9, 0x90, 0x34, 0x2b, 0x5b, 0xa6, 0xfe, 0x87, + 0x90, 0xf1, 0xa, 0xc6, 0xa2, 0xe9, 0xb5, 0xa1, 0x69, 0x84, 0x84, 0x5, 0xcc, 0xbf, 0x22, 0xf8, + 0xad, 0x41, 0xe7, 0x7c, 0x31, 0xaa, 0xff, 0x92, 0x6f, 0xbf, 0xbe, 0x12, 0x2b, 0x75, 0x59}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -950,52 +951,58 @@ TEST(Publish311QCTest, Decode16) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, 0xd8, 0x14, 0xcf, 0xce, - 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, 0x25, 0xf2, 0x62, 0xcc}; + uint8_t exp_topic_bytes[] = {0xa9, 0x30, 0xd3, 0x56, 0xf9, 0x90, 0x34, 0x2b, 0x5b, 0xa6, 0xfe, 0x87, 0x90, + 0xf1, 0xa, 0xc6, 0xa2, 0xe9, 0xb5, 0xa1, 0x69, 0x84, 0x84, 0x5, 0xcc, 0xbf}; lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, 0x89, 0x2f, - 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_body_bytes[] = {0xad, 0x41, 0xe7, 0x7c, 0x31, 0xaa, 0xff, 0x92, 0x6f, 0xbf, 0xbe, 0x12, 0x2b, 0x75, 0x59}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); + EXPECT_EQ(packet_id, 8952); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "6", _pubPktID = 0, _pubBody = "b", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\192!\207\251\220\139\197\DC3\237\227", _pubPktID = 0, _pubBody = +// "\245Ha\212\EM\NAK\214Qf\253*\177\142\202P\176\144\184\149N\DC4", _pubProps = []} TEST(Publish311QCTest, Encode17) { - uint8_t pkt[] = {0x31, 0x4, 0x0, 0x1, 0x36, 0x62}; - uint8_t topic_bytes[] = {0x36}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x21, 0x0, 0xa, 0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, + 0xed, 0xe3, 0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, + 0x2a, 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; + uint8_t topic_bytes[] = {0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x62}; + msg.retained = false; + uint8_t msg_bytes[] = {0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, + 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "6", _pubPktID = 0, _pubBody = "b", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\192!\207\251\220\139\197\DC3\237\227", _pubPktID = 0, _pubBody = +// "\245Ha\212\EM\NAK\214Qf\253*\177\142\202P\176\144\184\149N\DC4", _pubProps = []} TEST(Publish311QCTest, Decode17) { - uint8_t pkt[] = {0x31, 0x4, 0x0, 0x1, 0x36, 0x62}; + uint8_t pkt[] = {0x38, 0x21, 0x0, 0xa, 0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, + 0xed, 0xe3, 0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, + 0x2a, 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1004,52 +1011,58 @@ TEST(Publish311QCTest, Decode17) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x36}; - lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x62}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, + 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\184\EOT\177\237[w\205\DC4E\GS@", -// _pubPktID = 11334, _pubBody = "\247ax\ESCb", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\244\163\195\181~\198`:\150F\212N", +// _pubPktID = 32625, _pubBody = +// "\158m\139\172\171\135\&7\154\136\129\210{\228\197\SI[\STXw\192\242\239k\178\152Q\211\143S\146", _pubProps = []} TEST(Publish311QCTest, Encode18) { - uint8_t pkt[] = {0x3b, 0x15, 0x0, 0xc, 0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, - 0x14, 0x45, 0x1d, 0x40, 0x2c, 0x46, 0xf7, 0x61, 0x78, 0x1b, 0x62}; - uint8_t topic_bytes[] = {0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, 0x14, 0x45, 0x1d, 0x40}; + uint8_t pkt[] = {0x33, 0x2d, 0x0, 0xc, 0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e, + 0x7f, 0x71, 0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, + 0xf, 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; + uint8_t topic_bytes[] = {0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e}; lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xf7, 0x61, 0x78, 0x1b, 0x62}; + uint8_t msg_bytes[] = {0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, + 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + msg.payload_len = 29; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 11334, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32625, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\184\EOT\177\237[w\205\DC4E\GS@", -// _pubPktID = 11334, _pubBody = "\247ax\ESCb", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\244\163\195\181~\198`:\150F\212N", +// _pubPktID = 32625, _pubBody = +// "\158m\139\172\171\135\&7\154\136\129\210{\228\197\SI[\STXw\192\242\239k\178\152Q\211\143S\146", _pubProps = []} TEST(Publish311QCTest, Decode18) { - uint8_t pkt[] = {0x3b, 0x15, 0x0, 0xc, 0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, - 0x14, 0x45, 0x1d, 0x40, 0x2c, 0x46, 0xf7, 0x61, 0x78, 0x1b, 0x62}; + uint8_t pkt[] = {0x33, 0x2d, 0x0, 0xc, 0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e, + 0x7f, 0x71, 0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, + 0xf, 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1058,57 +1071,57 @@ TEST(Publish311QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, 0x14, 0x45, 0x1d, 0x40}; + uint8_t exp_topic_bytes[] = {0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e}; lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf7, 0x61, 0x78, 0x1b, 0x62}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_body_bytes[] = {0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, + 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 11334); + EXPECT_EQ(packet_id, 32625); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\tm5\139\DC1\DC18\255>\b\a\EM\145\213XbT\218|", _pubPktID = 0, _pubBody = "\DC4\GS+\EM\ESC\132B\172\232|\215", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\156\\\v`\145\USn?\217L\147\211\\\SI\254", _pubPktID = 25006, _pubBody = +// "\207\181\171\145\132\166r/\NUL\137\195|e\244P\185", _pubProps = []} TEST(Publish311QCTest, Encode19) { - uint8_t pkt[] = {0x31, 0x20, 0x0, 0x13, 0x9, 0x6d, 0x35, 0x8b, 0x11, 0x11, 0x38, 0xff, - 0x3e, 0x8, 0x7, 0x19, 0x91, 0xd5, 0x58, 0x62, 0x54, 0xda, 0x7c, 0x14, - 0x1d, 0x2b, 0x19, 0x1b, 0x84, 0x42, 0xac, 0xe8, 0x7c, 0xd7}; - uint8_t topic_bytes[] = {0x9, 0x6d, 0x35, 0x8b, 0x11, 0x11, 0x38, 0xff, 0x3e, 0x8, - 0x7, 0x19, 0x91, 0xd5, 0x58, 0x62, 0x54, 0xda, 0x7c}; - lwmqtt_string_t topic = {19, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x23, 0x0, 0xf, 0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, + 0x4c, 0x93, 0xd3, 0x5c, 0xf, 0xfe, 0x61, 0xae, 0xcf, 0xb5, 0xab, 0x91, 0x84, + 0xa6, 0x72, 0x2f, 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; + uint8_t topic_bytes[] = {0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, 0x4c, 0x93, 0xd3, 0x5c, 0xf, 0xfe}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x14, 0x1d, 0x2b, 0x19, 0x1b, 0x84, 0x42, 0xac, 0xe8, 0x7c, 0xd7}; + uint8_t msg_bytes[] = {0xcf, 0xb5, 0xab, 0x91, 0x84, 0xa6, 0x72, 0x2f, 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 16; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25006, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\tm5\139\DC1\DC18\255>\b\a\EM\145\213XbT\218|", _pubPktID = 0, _pubBody = "\DC4\GS+\EM\ESC\132B\172\232|\215", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\156\\\v`\145\USn?\217L\147\211\\\SI\254", _pubPktID = 25006, _pubBody = +// "\207\181\171\145\132\166r/\NUL\137\195|e\244P\185", _pubProps = []} TEST(Publish311QCTest, Decode19) { - uint8_t pkt[] = {0x31, 0x20, 0x0, 0x13, 0x9, 0x6d, 0x35, 0x8b, 0x11, 0x11, 0x38, 0xff, - 0x3e, 0x8, 0x7, 0x19, 0x91, 0xd5, 0x58, 0x62, 0x54, 0xda, 0x7c, 0x14, - 0x1d, 0x2b, 0x19, 0x1b, 0x84, 0x42, 0xac, 0xe8, 0x7c, 0xd7}; + uint8_t pkt[] = {0x33, 0x23, 0x0, 0xf, 0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, + 0x4c, 0x93, 0xd3, 0x5c, 0xf, 0xfe, 0x61, 0xae, 0xcf, 0xb5, 0xab, 0x91, 0x84, + 0xa6, 0x72, 0x2f, 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1117,40 +1130,37 @@ TEST(Publish311QCTest, Decode19) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9, 0x6d, 0x35, 0x8b, 0x11, 0x11, 0x38, 0xff, 0x3e, 0x8, - 0x7, 0x19, 0x91, 0xd5, 0x58, 0x62, 0x54, 0xda, 0x7c}; - lwmqtt_string_t exp_topic = {19, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x14, 0x1d, 0x2b, 0x19, 0x1b, 0x84, 0x42, 0xac, 0xe8, 0x7c, 0xd7}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, 0x4c, 0x93, 0xd3, 0x5c, 0xf, 0xfe}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcf, 0xb5, 0xab, 0x91, 0x84, 0xa6, 0x72, 0x2f, + 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 19); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(packet_id, 25006); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\211Q\204\149\142\&8\217\174\213\221\133\214\221\166\207E\151\t\221y\192>\ETBqK[", _pubPktID = 0, _pubBody = -// "\189\221\169\130\f\211\DC1\DC2\252", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\239p\183", _pubPktID = 0, _pubBody +// = "\STX\249\&8\215\vJ\163\136\174\235\187\163\ESCJ(\246", _pubProps = []} TEST(Publish311QCTest, Encode20) { - uint8_t pkt[] = {0x30, 0x25, 0x0, 0x1a, 0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, - 0xdd, 0x85, 0xd6, 0xdd, 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, - 0x17, 0x71, 0x4b, 0x5b, 0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; - uint8_t topic_bytes[] = {0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, 0xdd, - 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x15, 0x0, 0x3, 0xef, 0x70, 0xb7, 0x2, 0xf9, 0x38, 0xd7, 0xb, + 0x4a, 0xa3, 0x88, 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; + uint8_t topic_bytes[] = {0xef, 0x70, 0xb7}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; + msg.retained = true; + uint8_t msg_bytes[] = {0x2, 0xf9, 0x38, 0xd7, 0xb, 0x4a, 0xa3, 0x88, 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 16; lwmqtt_property_t propslist[] = {}; @@ -1162,13 +1172,11 @@ TEST(Publish311QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\211Q\204\149\142\&8\217\174\213\221\133\214\221\166\207E\151\t\221y\192>\ETBqK[", _pubPktID = 0, _pubBody = -// "\189\221\169\130\f\211\DC1\DC2\252", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\239p\183", _pubPktID = 0, _pubBody +// = "\STX\249\&8\215\vJ\163\136\174\235\187\163\ESCJ(\246", _pubProps = []} TEST(Publish311QCTest, Decode20) { - uint8_t pkt[] = {0x30, 0x25, 0x0, 0x1a, 0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, - 0xdd, 0x85, 0xd6, 0xdd, 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, - 0x17, 0x71, 0x4b, 0x5b, 0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; + uint8_t pkt[] = {0x31, 0x15, 0x0, 0x3, 0xef, 0x70, 0xb7, 0x2, 0xf9, 0x38, 0xd7, 0xb, + 0x4a, 0xa3, 0x88, 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1177,58 +1185,58 @@ TEST(Publish311QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, 0xdd, - 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xef, 0x70, 0xb7}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2, 0xf9, 0x38, 0xd7, 0xb, 0x4a, 0xa3, 0x88, + 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "p\211K\218>w\SOHst%h%\249P\an\SYNF\157q=]", _pubPktID = 0, _pubBody = "\135 \184\208\200\r\GSu\205w\SOHst%h%\249P\an\SYNF\157q=]", _pubPktID = 0, _pubBody = "\135 \184\208\200\r\GSu\205(topic.data), 22); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\249", _pubPktID = 7383, _pubBody = -// "\166\v\241D\ESCtx4\151\196\206=\239 r\RS\159\195\249NT_", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "D\SO\EOTH\207S\243\176T\n\246\234'~^\ETBtz\220X", _pubPktID = 0, _pubBody = +// "\179>\ENQUu\215k\216\ETX\201m\DC2\251\&2\ETB\187m\200\248\140{\n8", _pubProps = []} TEST(Publish311QCTest, Encode22) { - uint8_t pkt[] = {0x32, 0x1b, 0x0, 0x1, 0xf9, 0x1c, 0xd7, 0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, 0x34, - 0x97, 0xc4, 0xce, 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; - uint8_t topic_bytes[] = {0xf9}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x2d, 0x0, 0x14, 0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, 0xf6, 0xea, + 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58, 0xb3, 0x3e, 0x5, 0x55, 0x75, 0xd7, 0x6b, 0xd8, + 0x3, 0xc9, 0x6d, 0x12, 0xfb, 0x32, 0x17, 0xbb, 0x6d, 0xc8, 0xf8, 0x8c, 0x7b, 0xa, 0x38}; + uint8_t topic_bytes[] = {0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, + 0xf6, 0xea, 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, 0x34, 0x97, 0xc4, 0xce, - 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xb3, 0x3e, 0x5, 0x55, 0x75, 0xd7, 0x6b, 0xd8, 0x3, 0xc9, 0x6d, 0x12, + 0xfb, 0x32, 0x17, 0xbb, 0x6d, 0xc8, 0xf8, 0x8c, 0x7b, 0xa, 0x38}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 23; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7383, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\249", _pubPktID = 7383, _pubBody = -// "\166\v\241D\ESCtx4\151\196\206=\239 r\RS\159\195\249NT_", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "D\SO\EOTH\207S\243\176T\n\246\234'~^\ETBtz\220X", _pubPktID = 0, _pubBody = +// "\179>\ENQUu\215k\216\ETX\201m\DC2\251\&2\ETB\187m\200\248\140{\n8", _pubProps = []} TEST(Publish311QCTest, Decode22) { - uint8_t pkt[] = {0x32, 0x1b, 0x0, 0x1, 0xf9, 0x1c, 0xd7, 0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, 0x34, - 0x97, 0xc4, 0xce, 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; + uint8_t pkt[] = {0x31, 0x2d, 0x0, 0x14, 0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, 0xf6, 0xea, + 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58, 0xb3, 0x3e, 0x5, 0x55, 0x75, 0xd7, 0x6b, 0xd8, + 0x3, 0xc9, 0x6d, 0x12, 0xfb, 0x32, 0x17, 0xbb, 0x6d, 0xc8, 0xf8, 0x8c, 0x7b, 0xa, 0x38}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1293,61 +1306,59 @@ TEST(Publish311QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf9}; - lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa6, 0xb, 0xf1, 0x44, 0x1b, 0x74, 0x78, 0x34, 0x97, 0xc4, 0xce, - 0x3d, 0xef, 0x20, 0x72, 0x1e, 0x9f, 0xc3, 0xf9, 0x4e, 0x54, 0x5f}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, + 0xf6, 0xea, 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb3, 0x3e, 0x5, 0x55, 0x75, 0xd7, 0x6b, 0xd8, 0x3, 0xc9, 0x6d, 0x12, + 0xfb, 0x32, 0x17, 0xbb, 0x6d, 0xc8, 0xf8, 0x8c, 0x7b, 0xa, 0x38}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 7383); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\156\249\196\168\224\205\FS\219\244\128\231\SYN\252\239j\NAK\164\171G]\133\229\147Q\199(\f\249y", _pubPktID = 11390, -// _pubBody = "s\226]\184\NUL\176A\242\&3\195\ETBC\RSN\254\t\t\\\203\255=\180B\201k\163", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\178\144*)\STX\195\&3\195\193\213~9\191FW\136R", _pubPktID = 0, _pubBody = "\155U0$\ENQ\134dV\214\ts.+\ETX\143", +// _pubProps = []} TEST(Publish311QCTest, Encode23) { - uint8_t pkt[] = {0x3a, 0x3b, 0x0, 0x1d, 0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, - 0xfc, 0xef, 0x6a, 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, - 0x79, 0x2c, 0x7e, 0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, - 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; - uint8_t topic_bytes[] = {0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, 0x6a, - 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, 0x79}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x22, 0x0, 0x11, 0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, + 0xc1, 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52, 0x9b, 0x55, 0x30, + 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; + uint8_t topic_bytes[] = {0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, + 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, - 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 11390, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\156\249\196\168\224\205\FS\219\244\128\231\SYN\252\239j\NAK\164\171G]\133\229\147Q\199(\f\249y", _pubPktID = 11390, -// _pubBody = "s\226]\184\NUL\176A\242\&3\195\ETBC\RSN\254\t\t\\\203\255=\180B\201k\163", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\178\144*)\STX\195\&3\195\193\213~9\191FW\136R", _pubPktID = 0, _pubBody = "\155U0$\ENQ\134dV\214\ts.+\ETX\143", +// _pubProps = []} TEST(Publish311QCTest, Decode23) { - uint8_t pkt[] = {0x3a, 0x3b, 0x0, 0x1d, 0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, - 0xfc, 0xef, 0x6a, 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, - 0x79, 0x2c, 0x7e, 0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, - 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; + uint8_t pkt[] = {0x39, 0x22, 0x0, 0x11, 0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, + 0xc1, 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52, 0x9b, 0x55, 0x30, + 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1356,60 +1367,58 @@ TEST(Publish311QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, 0x6a, - 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, 0x79}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, - 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, + 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52}; + lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 11390); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\247\&51\173<\172\250\229U\SOH\214a\211n>\225\&2^", _pubPktID = 0, _pubBody = -// "\r\136\219Jg\197\169\234\190\251\255K\212\139c\186,\229", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "G\195\186\214\239K +// \\\226\162\\\"\182", _pubPktID = 3720, _pubBody = +// "\SYN\172\191'(v\"S#\253\175\191\180\243%y\205\195\143\140\247\239\228\\", _pubProps = []} TEST(Publish311QCTest, Encode24) { - uint8_t pkt[] = {0x30, 0x26, 0x0, 0x12, 0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, 0x1, - 0xd6, 0x61, 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e, 0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, - 0xa9, 0xea, 0xbe, 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; - uint8_t topic_bytes[] = {0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, - 0x1, 0xd6, 0x61, 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x29, 0x0, 0xd, 0x47, 0xc3, 0xba, 0xd6, 0xef, 0x4b, 0x20, 0x5c, 0xe2, 0xa2, 0x5c, + 0x22, 0xb6, 0xe, 0x88, 0x16, 0xac, 0xbf, 0x27, 0x28, 0x76, 0x22, 0x53, 0x23, 0xfd, 0xaf, + 0xbf, 0xb4, 0xf3, 0x25, 0x79, 0xcd, 0xc3, 0x8f, 0x8c, 0xf7, 0xef, 0xe4, 0x5c}; + uint8_t topic_bytes[] = {0x47, 0xc3, 0xba, 0xd6, 0xef, 0x4b, 0x20, 0x5c, 0xe2, 0xa2, 0x5c, 0x22, 0xb6}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, 0xa9, 0xea, 0xbe, - 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x16, 0xac, 0xbf, 0x27, 0x28, 0x76, 0x22, 0x53, 0x23, 0xfd, 0xaf, 0xbf, + 0xb4, 0xf3, 0x25, 0x79, 0xcd, 0xc3, 0x8f, 0x8c, 0xf7, 0xef, 0xe4, 0x5c}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 24; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3720, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\247\&51\173<\172\250\229U\SOH\214a\211n>\225\&2^", _pubPktID = 0, _pubBody = -// "\r\136\219Jg\197\169\234\190\251\255K\212\139c\186,\229", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "G\195\186\214\239K +// \\\226\162\\\"\182", _pubPktID = 3720, _pubBody = +// "\SYN\172\191'(v\"S#\253\175\191\180\243%y\205\195\143\140\247\239\228\\", _pubProps = []} TEST(Publish311QCTest, Decode24) { - uint8_t pkt[] = {0x30, 0x26, 0x0, 0x12, 0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, 0x1, - 0xd6, 0x61, 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e, 0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, - 0xa9, 0xea, 0xbe, 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; + uint8_t pkt[] = {0x33, 0x29, 0x0, 0xd, 0x47, 0xc3, 0xba, 0xd6, 0xef, 0x4b, 0x20, 0x5c, 0xe2, 0xa2, 0x5c, + 0x22, 0xb6, 0xe, 0x88, 0x16, 0xac, 0xbf, 0x27, 0x28, 0x76, 0x22, 0x53, 0x23, 0xfd, 0xaf, + 0xbf, 0xb4, 0xf3, 0x25, 0x79, 0xcd, 0xc3, 0x8f, 0x8c, 0xf7, 0xef, 0xe4, 0x5c}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1418,59 +1427,54 @@ TEST(Publish311QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf7, 0x35, 0x31, 0xad, 0x3c, 0xac, 0xfa, 0xe5, 0x55, - 0x1, 0xd6, 0x61, 0xd3, 0x6e, 0x3e, 0xe1, 0x32, 0x5e}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xd, 0x88, 0xdb, 0x4a, 0x67, 0xc5, 0xa9, 0xea, 0xbe, - 0xfb, 0xff, 0x4b, 0xd4, 0x8b, 0x63, 0xba, 0x2c, 0xe5}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x47, 0xc3, 0xba, 0xd6, 0xef, 0x4b, 0x20, 0x5c, 0xe2, 0xa2, 0x5c, 0x22, 0xb6}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x16, 0xac, 0xbf, 0x27, 0x28, 0x76, 0x22, 0x53, 0x23, 0xfd, 0xaf, 0xbf, + 0xb4, 0xf3, 0x25, 0x79, 0xcd, 0xc3, 0x8f, 0x8c, 0xf7, 0xef, 0xe4, 0x5c}; + lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 3720); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\DC3 -// \244\212\ETX\143\186\222G-\212", _pubPktID = 0, _pubBody = "cndv<\250\182\170?\140\SYN\204\158n'\161tLKL\DC4\131", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 9592, _pubBody = +// "\ETX\195\133\tbr,\140\146.tE\159\135\176\168{\162X\178Z", _pubProps = []} TEST(Publish311QCTest, Encode25) { - uint8_t pkt[] = {0x30, 0x23, 0x0, 0xb, 0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, - 0x2d, 0xd4, 0x63, 0x6e, 0x64, 0x76, 0x3c, 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, - 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; - uint8_t topic_bytes[] = {0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, 0x2d, 0xd4}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x19, 0x0, 0x0, 0x25, 0x78, 0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, + 0x92, 0x2e, 0x74, 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x63, 0x6e, 0x64, 0x76, 0x3c, 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, - 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; + uint8_t msg_bytes[] = {0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, 0x92, 0x2e, 0x74, + 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; + msg.payload_len = 21; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 9592, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\DC3 -// \244\212\ETX\143\186\222G-\212", _pubPktID = 0, _pubBody = "cndv<\250\182\170?\140\SYN\204\158n'\161tLKL\DC4\131", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 9592, _pubBody = +// "\ETX\195\133\tbr,\140\146.tE\159\135\176\168{\162X\178Z", _pubProps = []} TEST(Publish311QCTest, Decode25) { - uint8_t pkt[] = {0x30, 0x23, 0x0, 0xb, 0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, - 0x2d, 0xd4, 0x63, 0x6e, 0x64, 0x76, 0x3c, 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, - 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; + uint8_t pkt[] = {0x34, 0x19, 0x0, 0x0, 0x25, 0x78, 0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, + 0x92, 0x2e, 0x74, 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1479,58 +1483,51 @@ TEST(Publish311QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, 0x2d, 0xd4}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x63, 0x6e, 0x64, 0x76, 0x3c, 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, - 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, 0x92, 0x2e, 0x74, + 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(packet_id, 9592); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "o#L\177\210\EOT\140\230w\252ir\220-\217\230\154\182\a0(\169\225\232uo", _pubPktID = 0, _pubBody = -// "2\137\n\NUL\201\149\252e\191]\CAN#`\250", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "y\216", _pubPktID = 27633, _pubBody +// = "\t\219\155@MR", _pubProps = []} TEST(Publish311QCTest, Encode26) { - uint8_t pkt[] = {0x31, 0x2a, 0x0, 0x1a, 0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, - 0x72, 0xdc, 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f, - 0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; - uint8_t topic_bytes[] = {0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, - 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0xc, 0x0, 0x2, 0x79, 0xd8, 0x6b, 0xf1, 0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; + uint8_t topic_bytes[] = {0x79, 0xd8}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; + uint8_t msg_bytes[] = {0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; + msg.payload_len = 6; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 27633, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "o#L\177\210\EOT\140\230w\252ir\220-\217\230\154\182\a0(\169\225\232uo", _pubPktID = 0, _pubBody = -// "2\137\n\NUL\201\149\252e\191]\CAN#`\250", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "y\216", _pubPktID = 27633, _pubBody +// = "\t\219\155@MR", _pubProps = []} TEST(Publish311QCTest, Decode26) { - uint8_t pkt[] = {0x31, 0x2a, 0x0, 0x1a, 0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, - 0x72, 0xdc, 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f, - 0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; + uint8_t pkt[] = {0x33, 0xc, 0x0, 0x2, 0x79, 0xd8, 0x6b, 0xf1, 0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1539,53 +1536,50 @@ TEST(Publish311QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, - 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x79, 0xd8}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_EQ(packet_id, 27633); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O\216\186", _pubPktID = 31863, -// _pubBody = "\206\US\183\184\207\198X\216\SOn\202 \214", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\253d\178]\206\DLE\163;", _pubProps = []} TEST(Publish311QCTest, Encode27) { - uint8_t pkt[] = {0x3d, 0x14, 0x0, 0x3, 0x4f, 0xd8, 0xba, 0x7c, 0x77, 0xce, 0x1f, - 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; - uint8_t topic_bytes[] = {0x4f, 0xd8, 0xba}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0xa, 0x0, 0x0, 0xfd, 0x64, 0xb2, 0x5d, 0xce, 0x10, 0xa3, 0x3b}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xce, 0x1f, 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; + uint8_t msg_bytes[] = {0xfd, 0x64, 0xb2, 0x5d, 0xce, 0x10, 0xa3, 0x3b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 8; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 31863, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O\216\186", _pubPktID = 31863, -// _pubBody = "\206\US\183\184\207\198X\216\SOn\202 \214", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\253d\178]\206\DLE\163;", _pubProps = []} TEST(Publish311QCTest, Decode27) { - uint8_t pkt[] = {0x3d, 0x14, 0x0, 0x3, 0x4f, 0xd8, 0xba, 0x7c, 0x77, 0xce, 0x1f, - 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; + uint8_t pkt[] = {0x39, 0xa, 0x0, 0x0, 0xfd, 0x64, 0xb2, 0x5d, 0xce, 0x10, 0xa3, 0x3b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1594,57 +1588,52 @@ TEST(Publish311QCTest, Decode27) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x4f, 0xd8, 0xba}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xce, 0x1f, 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfd, 0x64, 0xb2, 0x5d, 0xce, 0x10, 0xa3, 0x3b}; + lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 31863); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 13); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 8); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "r8* -// \EM\150\251uUH\DEL\151\232\SOH\RS\240\192\167=\255\246\193\250*<", _pubPktID = 26145, _pubBody = -// "\165\DC2\SOH6&\169\226\233\172\134`\205\149\221__", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// ";\204\SI\135:\SYN%u\222\217#\130\225N", _pubPktID = 14774, _pubBody = "\250v\SUB", _pubProps = []} TEST(Publish311QCTest, Encode28) { - uint8_t pkt[] = {0x32, 0x2d, 0x0, 0x19, 0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, - 0xe8, 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c, 0x66, 0x21, 0xa5, - 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; - uint8_t topic_bytes[] = {0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, 0xe8, - 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x15, 0x0, 0xe, 0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, + 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e, 0x39, 0xb6, 0xfa, 0x76, 0x1a}; + uint8_t topic_bytes[] = {0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xfa, 0x76, 0x1a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 3; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 26145, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 14774, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "r8* -// \EM\150\251uUH\DEL\151\232\SOH\RS\240\192\167=\255\246\193\250*<", _pubPktID = 26145, _pubBody = -// "\165\DC2\SOH6&\169\226\233\172\134`\205\149\221__", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// ";\204\SI\135:\SYN%u\222\217#\130\225N", _pubPktID = 14774, _pubBody = "\250v\SUB", _pubProps = []} TEST(Publish311QCTest, Decode28) { - uint8_t pkt[] = {0x32, 0x2d, 0x0, 0x19, 0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, - 0xe8, 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c, 0x66, 0x21, 0xa5, - 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; + uint8_t pkt[] = {0x35, 0x15, 0x0, 0xe, 0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, + 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e, 0x39, 0xb6, 0xfa, 0x76, 0x1a}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1653,52 +1642,58 @@ TEST(Publish311QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, 0xe8, - 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, - 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfa, 0x76, 0x1a}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 26145); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 14774); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 7976, _pubBody = -// "\ENQP\a\164\163\166{\250{", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "M\189d\165\NAK\165J\222\187)\216\178d^\194{\141\141y\145", _pubPktID = 0, _pubBody = +// "\245\129\188\154\242\232\161\228\255\&1lz\153\252~D\r\222\166\ENQ", _pubProps = []} TEST(Publish311QCTest, Encode29) { - uint8_t pkt[] = {0x3b, 0xd, 0x0, 0x0, 0x1f, 0x28, 0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x30, 0x2a, 0x0, 0x14, 0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, 0xd8, + 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91, 0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, + 0xa1, 0xe4, 0xff, 0x31, 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; + uint8_t topic_bytes[] = {0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, + 0xd8, 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, + 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 20; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 7976, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 7976, _pubBody = -// "\ENQP\a\164\163\166{\250{", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "M\189d\165\NAK\165J\222\187)\216\178d^\194{\141\141y\145", _pubPktID = 0, _pubBody = +// "\245\129\188\154\242\232\161\228\255\&1lz\153\252~D\r\222\166\ENQ", _pubProps = []} TEST(Publish311QCTest, Decode29) { - uint8_t pkt[] = {0x3b, 0xd, 0x0, 0x0, 0x1f, 0x28, 0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; + uint8_t pkt[] = {0x30, 0x2a, 0x0, 0x14, 0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, 0xd8, + 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91, 0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, + 0xa1, 0xe4, 0xff, 0x31, 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1707,60 +1702,54 @@ TEST(Publish311QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 7976); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + uint8_t exp_topic_bytes[] = {0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, + 0xd8, 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, + 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\197\a\164\SUB\DC1\195\RS`\FS\155?\206\154I\134\181\139\252Vc\161i`\DC3\245", _pubPktID = 3213, _pubBody = -// "\249a\NAK\209f+\v\251'\141\199\&6\195s\160^:v\251\&5\174\FS\240\191k\205\"\201\222=", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "3V\138y.\181\&0", _pubPktID = 0, +// _pubBody = "2\248\176\206\GS<\197b\195`\241\aH", _pubProps = []} TEST(Publish311QCTest, Encode30) { - uint8_t pkt[] = {0x35, 0x3b, 0x0, 0x19, 0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, - 0x9a, 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5, 0xc, 0x8d, 0xf9, - 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, 0x5e, 0x3a, - 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; - uint8_t topic_bytes[] = {0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, 0x9a, - 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x16, 0x0, 0x7, 0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30, 0x32, + 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; + uint8_t topic_bytes[] = {0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xf9, 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, - 0x5e, 0x3a, 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; + uint8_t msg_bytes[] = {0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; + msg.payload_len = 13; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3213, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\197\a\164\SUB\DC1\195\RS`\FS\155?\206\154I\134\181\139\252Vc\161i`\DC3\245", _pubPktID = 3213, _pubBody = -// "\249a\NAK\209f+\v\251'\141\199\&6\195s\160^:v\251\&5\174\FS\240\191k\205\"\201\222=", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "3V\138y.\181\&0", _pubPktID = 0, +// _pubBody = "2\248\176\206\GS<\197b\195`\241\aH", _pubProps = []} TEST(Publish311QCTest, Decode30) { - uint8_t pkt[] = {0x35, 0x3b, 0x0, 0x19, 0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, - 0x9a, 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5, 0xc, 0x8d, 0xf9, - 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, 0x5e, 0x3a, - 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; + uint8_t pkt[] = {0x31, 0x16, 0x0, 0x7, 0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30, 0x32, + 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1769,153 +1758,62 @@ TEST(Publish311QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, 0x9a, - 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf9, 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, - 0x5e, 0x3a, 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 3213); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "L\255\GS\208o\194\236\140\156\225\135\244\SO\154#", _pubPktID = 6184, _pubBody = -// "_\160\218auw5\192\154w\154\194:T\135\200\157", _pubProps = [PropTopicAliasMaximum -// 15521,PropRequestResponseInformation 202,PropServerReference "",PropServerKeepAlive 27747,PropUserProperty -// "1\250^n\DELx\208e/~\246we" "8,\249\179r\DC2",PropSubscriptionIdentifierAvailable 146,PropSharedSubscriptionAvailable -// 249,PropRetainAvailable 178,PropCorrelationData "\ENQ\231",PropServerReference "F",PropWildcardSubscriptionAvailable -// 173,PropMaximumPacketSize 23566,PropSubscriptionIdentifier 22,PropSubscriptionIdentifierAvailable 53,PropTopicAlias -// 15812,PropServerKeepAlive 31656,PropContentType -// "_\240\vO\162;\136g\247\135\144ae\182;\154\237X\DELCf2\EOT*\171h",PropReasonString -// "\146\r]\239\153\&5r`1#\251",PropResponseTopic -// "G\164\230\178G\CAN\234\254p\DEL\156\250KR\r\219x@\247t\164\141\&9",PropAuthenticationData -// "B]0.\181\174\177\221T\128`D\210\253@\137[\DC2\174\160\245\227\170u\SI{^\241",PropWillDelayInterval -// 30420,PropAuthenticationData "\NUL\245\ETX\229[\STX\140\179V\227\226\220t\DC20\164R",PropReceiveMaximum -// 12547,PropTopicAlias 18835,PropMaximumQoS 44,PropMaximumPacketSize 5027,PropSharedSubscriptionAvailable -// 105,PropTopicAlias 9204,PropServerKeepAlive 4590,PropRequestProblemInformation 67]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "W\217\244\199\US\166I\171\225H\165\&0\148+>'\185\243\243\254\182\&3\158\130", _pubPktID = 5484, _pubBody = +// "N\151Gu\207\213\209\175\151\241[\RS\128P\129\237\157\250K", _pubProps = [PropReceiveMaximum 26936]} TEST(Publish5QCTest, Encode1) { - uint8_t pkt[] = { - 0x3c, 0xfd, 0x1, 0x0, 0xf, 0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, - 0x23, 0x18, 0x28, 0xd7, 0x1, 0x22, 0x3c, 0xa1, 0x19, 0xca, 0x1c, 0x0, 0x0, 0x13, 0x6c, 0x63, 0x26, 0x0, 0xd, - 0x31, 0xfa, 0x5e, 0x6e, 0x7f, 0x78, 0xd0, 0x65, 0x2f, 0x7e, 0xf6, 0x77, 0x65, 0x0, 0x6, 0x38, 0x2c, 0xf9, 0xb3, - 0x72, 0x12, 0x29, 0x92, 0x2a, 0xf9, 0x25, 0xb2, 0x9, 0x0, 0x2, 0x5, 0xe7, 0x1c, 0x0, 0x1, 0x46, 0x28, 0xad, - 0x27, 0x0, 0x0, 0x5c, 0xe, 0xb, 0x16, 0x29, 0x35, 0x23, 0x3d, 0xc4, 0x13, 0x7b, 0xa8, 0x3, 0x0, 0x1a, 0x5f, - 0xf0, 0xb, 0x4f, 0xa2, 0x3b, 0x88, 0x67, 0xf7, 0x87, 0x90, 0x61, 0x65, 0xb6, 0x3b, 0x9a, 0xed, 0x58, 0x7f, 0x43, - 0x66, 0x32, 0x4, 0x2a, 0xab, 0x68, 0x1f, 0x0, 0xb, 0x92, 0xd, 0x5d, 0xef, 0x99, 0x35, 0x72, 0x60, 0x31, 0x23, - 0xfb, 0x8, 0x0, 0x17, 0x47, 0xa4, 0xe6, 0xb2, 0x47, 0x18, 0xea, 0xfe, 0x70, 0x7f, 0x9c, 0xfa, 0x4b, 0x52, 0xd, - 0xdb, 0x78, 0x40, 0xf7, 0x74, 0xa4, 0x8d, 0x39, 0x16, 0x0, 0x1c, 0x42, 0x5d, 0x30, 0x2e, 0xb5, 0xae, 0xb1, 0xdd, - 0x54, 0x80, 0x60, 0x44, 0xd2, 0xfd, 0x40, 0x89, 0x5b, 0x12, 0xae, 0xa0, 0xf5, 0xe3, 0xaa, 0x75, 0xf, 0x7b, 0x5e, - 0xf1, 0x18, 0x0, 0x0, 0x76, 0xd4, 0x16, 0x0, 0x11, 0x0, 0xf5, 0x3, 0xe5, 0x5b, 0x2, 0x8c, 0xb3, 0x56, 0xe3, - 0xe2, 0xdc, 0x74, 0x12, 0x30, 0xa4, 0x52, 0x21, 0x31, 0x3, 0x23, 0x49, 0x93, 0x24, 0x2c, 0x27, 0x0, 0x0, 0x13, - 0xa3, 0x2a, 0x69, 0x23, 0x23, 0xf4, 0x13, 0x11, 0xee, 0x17, 0x43, 0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, - 0x9a, 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; - uint8_t topic_bytes[] = {0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x33, 0x0, 0x18, 0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, + 0xa5, 0x30, 0x94, 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82, + 0x15, 0x6c, 0x3, 0x21, 0x69, 0x38, 0x4e, 0x97, 0x47, 0x75, 0xcf, 0xd5, 0xd1, 0xaf, + 0x97, 0xf1, 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; + uint8_t topic_bytes[] = {0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, 0xa5, 0x30, + 0x94, 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, 0x9a, - 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x4e, 0x97, 0x47, 0x75, 0xcf, 0xd5, 0xd1, 0xaf, 0x97, 0xf1, + 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; - - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops2[] = {0x38, 0x2c, 0xf9, 0xb3, 0x72, 0x12}; - uint8_t bytesprops1[] = {0x31, 0xfa, 0x5e, 0x6e, 0x7f, 0x78, 0xd0, 0x65, 0x2f, 0x7e, 0xf6, 0x77, 0x65}; - uint8_t bytesprops3[] = {0x5, 0xe7}; - uint8_t bytesprops4[] = {0x46}; - uint8_t bytesprops5[] = {0x5f, 0xf0, 0xb, 0x4f, 0xa2, 0x3b, 0x88, 0x67, 0xf7, 0x87, 0x90, 0x61, 0x65, - 0xb6, 0x3b, 0x9a, 0xed, 0x58, 0x7f, 0x43, 0x66, 0x32, 0x4, 0x2a, 0xab, 0x68}; - uint8_t bytesprops6[] = {0x92, 0xd, 0x5d, 0xef, 0x99, 0x35, 0x72, 0x60, 0x31, 0x23, 0xfb}; - uint8_t bytesprops7[] = {0x47, 0xa4, 0xe6, 0xb2, 0x47, 0x18, 0xea, 0xfe, 0x70, 0x7f, 0x9c, 0xfa, - 0x4b, 0x52, 0xd, 0xdb, 0x78, 0x40, 0xf7, 0x74, 0xa4, 0x8d, 0x39}; - uint8_t bytesprops8[] = {0x42, 0x5d, 0x30, 0x2e, 0xb5, 0xae, 0xb1, 0xdd, 0x54, 0x80, 0x60, 0x44, 0xd2, 0xfd, - 0x40, 0x89, 0x5b, 0x12, 0xae, 0xa0, 0xf5, 0xe3, 0xaa, 0x75, 0xf, 0x7b, 0x5e, 0xf1}; - uint8_t bytesprops9[] = {0x0, 0xf5, 0x3, 0xe5, 0x5b, 0x2, 0x8c, 0xb3, 0x56, - 0xe3, 0xe2, 0xdc, 0x74, 0x12, 0x30, 0xa4, 0x52}; + msg.payload_len = 19; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15521}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27747}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23566}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15812}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31656}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30420}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12547}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18835}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5027}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9204}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4590}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26936}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6184, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5484, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "L\255\GS\208o\194\236\140\156\225\135\244\SO\154#", _pubPktID = 6184, _pubBody = -// "_\160\218auw5\192\154w\154\194:T\135\200\157", _pubProps = [PropTopicAliasMaximum -// 15521,PropRequestResponseInformation 202,PropServerReference "",PropServerKeepAlive 27747,PropUserProperty -// "1\250^n\DELx\208e/~\246we" "8,\249\179r\DC2",PropSubscriptionIdentifierAvailable 146,PropSharedSubscriptionAvailable -// 249,PropRetainAvailable 178,PropCorrelationData "\ENQ\231",PropServerReference "F",PropWildcardSubscriptionAvailable -// 173,PropMaximumPacketSize 23566,PropSubscriptionIdentifier 22,PropSubscriptionIdentifierAvailable 53,PropTopicAlias -// 15812,PropServerKeepAlive 31656,PropContentType -// "_\240\vO\162;\136g\247\135\144ae\182;\154\237X\DELCf2\EOT*\171h",PropReasonString -// "\146\r]\239\153\&5r`1#\251",PropResponseTopic -// "G\164\230\178G\CAN\234\254p\DEL\156\250KR\r\219x@\247t\164\141\&9",PropAuthenticationData -// "B]0.\181\174\177\221T\128`D\210\253@\137[\DC2\174\160\245\227\170u\SI{^\241",PropWillDelayInterval -// 30420,PropAuthenticationData "\NUL\245\ETX\229[\STX\140\179V\227\226\220t\DC20\164R",PropReceiveMaximum -// 12547,PropTopicAlias 18835,PropMaximumQoS 44,PropMaximumPacketSize 5027,PropSharedSubscriptionAvailable -// 105,PropTopicAlias 9204,PropServerKeepAlive 4590,PropRequestProblemInformation 67]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "W\217\244\199\US\166I\171\225H\165\&0\148+>'\185\243\243\254\182\&3\158\130", _pubPktID = 5484, _pubBody = +// "N\151Gu\207\213\209\175\151\241[\RS\128P\129\237\157\250K", _pubProps = [PropReceiveMaximum 26936]} TEST(Publish5QCTest, Decode1) { - uint8_t pkt[] = { - 0x3c, 0xfd, 0x1, 0x0, 0xf, 0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, - 0x23, 0x18, 0x28, 0xd7, 0x1, 0x22, 0x3c, 0xa1, 0x19, 0xca, 0x1c, 0x0, 0x0, 0x13, 0x6c, 0x63, 0x26, 0x0, 0xd, - 0x31, 0xfa, 0x5e, 0x6e, 0x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69, 0x23, 0x23, 0xf4, 0x13, 0x11, 0xee, 0x17, 0x43, 0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, - 0x9a, 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; + uint8_t pkt[] = {0x3b, 0x33, 0x0, 0x18, 0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, + 0xa5, 0x30, 0x94, 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82, + 0x15, 0x6c, 0x3, 0x21, 0x69, 0x38, 0x4e, 0x97, 0x47, 0x75, 0xcf, 0xd5, 0xd1, 0xaf, + 0x97, 0xf1, 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1924,132 +1822,122 @@ TEST(Publish5QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x4c, 0xff, 0x1d, 0xd0, 0x6f, 0xc2, 0xec, 0x8c, 0x9c, 0xe1, 0x87, 0xf4, 0xe, 0x9a, 0x23}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5f, 0xa0, 0xda, 0x61, 0x75, 0x77, 0x35, 0xc0, 0x9a, - 0x77, 0x9a, 0xc2, 0x3a, 0x54, 0x87, 0xc8, 0x9d}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, 0xa5, 0x30, + 0x94, 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4e, 0x97, 0x47, 0x75, 0xcf, 0xd5, 0xd1, 0xaf, 0x97, 0xf1, + 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 6184); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 5484); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\198\DC1L:\231)\185\220\223D\v\EOT\217<", _pubPktID = 6873, _pubBody = "\ESC\"[|\180", _pubProps = -// [PropSubscriptionIdentifier 26,PropSubscriptionIdentifier 20,PropSubscriptionIdentifierAvailable -// 97,PropSessionExpiryInterval 1270,PropMaximumQoS 17,PropTopicAliasMaximum 10662,PropServerReference -// "1\200T%r\131\SOHr\212\191\242\CAN\247#\238v\nH\DC4\201Z\164\245\223\FS]",PropWillDelayInterval 643,PropMaximumQoS -// 77,PropPayloadFormatIndicator 204,PropAuthenticationData "\191 -// \136a\144\SUB\218\233\142\192\141\188\130\200\&2\140\234\168.\182\244`\169",PropRequestResponseInformation -// 99,PropRequestProblemInformation 98,PropSessionExpiryInterval 4736,PropSessionExpiryInterval 22872,PropResponseTopic -// "\143(Q\146\&7\171ew}S^\134\238QZ\DC3E \182\230'\234`",PropAuthenticationData -// "\207\179g\145M\145\246\226Ij\173\US\145\ETX\155\251\132^E\219\179\185\SO\136",PropServerReference -// "\250|\135#h",PropRetainAvailable 1,PropServerReference -// "1\GS\178\129~-{+\US\SUBBe\DEL\SI\174q\210\241Zq\201_mb\129@\210E\208",PropSubscriptionIdentifier -// 14,PropMessageExpiryInterval 1239]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\164_xCoe\161\\\SYN8\247~X\178U\EOT\201\239d\NUL\v\219\239", _pubPktID = 617, _pubBody = +// "\203\"\151M\221\179{\230\DC3c\185\FS\183-\225\169\214\ETX\128\159\170E\186\239\ESC\153\192\142", _pubProps = +// [PropMaximumQoS 222,PropReceiveMaximum 32352,PropResponseTopic "_-\213",PropSharedSubscriptionAvailable +// 77,PropMessageExpiryInterval 27318,PropSubscriptionIdentifierAvailable 17,PropTopicAlias 4804,PropMaximumQoS +// 245,PropMaximumQoS 33,PropServerReference "\165KJ\219Ap\192\151\200\134\149",PropSharedSubscriptionAvailable +// 196,PropTopicAlias 28672,PropAssignedClientIdentifier "Tl\129`\180&EKq6\201\232\EM(\235\US",PropRetainAvailable +// 117,PropAssignedClientIdentifier "\232\242't\134w\152\212\DC27\155Y\DELx\209s5\197",PropPayloadFormatIndicator +// 133,PropWildcardSubscriptionAvailable 232,PropAuthenticationMethod +// "\227\193\NUL:K\134X\134\245\232\231RB\148\229\214\203\178\186\237\247\252\a9\129lc\DEL\153",PropMaximumQoS +// 231,PropRetainAvailable 124]} TEST(Publish5QCTest, Encode2) { uint8_t pkt[] = { - 0x35, 0xdd, 0x1, 0x0, 0xe, 0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c, - 0x1a, 0xd9, 0xc4, 0x1, 0xb, 0x1a, 0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e, 0x2, 0x0, 0x0, 0x4, 0xd7, 0x1b, 0x22, 0x5b, 0x7c, 0xb4}; - uint8_t topic_bytes[] = {0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + 0x3b, 0xb9, 0x1, 0x0, 0x17, 0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, 0x58, 0xb2, + 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef, 0x2, 0x69, 0x80, 0x1, 0x24, 0xde, 0x21, 0x7e, 0x60, 0x8, + 0x0, 0x3, 0x5f, 0x2d, 0xd5, 0x2a, 0x4d, 0x2, 0x0, 0x0, 0x6a, 0xb6, 0x29, 0x11, 0x23, 0x12, 0xc4, 0x24, 0xf5, + 0x24, 0x21, 0x1c, 0x0, 0xb, 0xa5, 0x4b, 0x4a, 0xdb, 0x41, 0x70, 0xc0, 0x97, 0xc8, 0x86, 0x95, 0x2a, 0xc4, 0x23, + 0x70, 0x0, 0x12, 0x0, 0x10, 0x54, 0x6c, 0x81, 0x60, 0xb4, 0x26, 0x45, 0x4b, 0x71, 0x36, 0xc9, 0xe8, 0x19, 0x28, + 0xeb, 0x1f, 0x25, 0x75, 0x12, 0x0, 0x12, 0xe8, 0xf2, 0x27, 0x74, 0x86, 0x77, 0x98, 0xd4, 0x12, 0x37, 0x9b, 0x59, + 0x7f, 0x78, 0xd1, 0x73, 0x35, 0xc5, 0x1, 0x85, 0x28, 0xe8, 0x15, 0x0, 0x1d, 0xe3, 0xc1, 0x0, 0x3a, 0x4b, 0x86, + 0x58, 0x86, 0xf5, 0xe8, 0xe7, 0x52, 0x42, 0x94, 0xe5, 0xd6, 0xcb, 0xb2, 0xba, 0xed, 0xf7, 0xfc, 0x7, 0x39, 0x81, + 0x6c, 0x63, 0x7f, 0x99, 0x24, 0xe7, 0x25, 0x7c, 0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, + 0x1c, 0xb7, 0x2d, 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; + uint8_t topic_bytes[] = {0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, + 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef}; + lwmqtt_string_t topic = {23, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x1b, 0x22, 0x5b, 0x7c, 0xb4}; + uint8_t msg_bytes[] = {0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, + 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; - - uint8_t bytesprops0[] = {0x31, 0xc8, 0x54, 0x25, 0x72, 0x83, 0x1, 0x72, 0xd4, 0xbf, 0xf2, 0x18, 0xf7, - 0x23, 0xee, 0x76, 0xa, 0x48, 0x14, 0xc9, 0x5a, 0xa4, 0xf5, 0xdf, 0x1c, 0x5d}; - uint8_t bytesprops1[] = {0xbf, 0x20, 0x88, 0x61, 0x90, 0x1a, 0xda, 0xe9, 0x8e, 0xc0, 0x8d, 0xbc, - 0x82, 0xc8, 0x32, 0x8c, 0xea, 0xa8, 0x2e, 0xb6, 0xf4, 0x60, 0xa9}; - uint8_t bytesprops2[] = {0x8f, 0x28, 0x51, 0x92, 0x37, 0xab, 0x65, 0x77, 0x7d, 0x53, 0x5e, 0x86, - 0xee, 0x51, 0x5a, 0x13, 0x45, 0x20, 0xb6, 0xe6, 0x27, 0xea, 0x60}; - uint8_t bytesprops3[] = {0xcf, 0xb3, 0x67, 0x91, 0x4d, 0x91, 0xf6, 0xe2, 0x49, 0x6a, 0xad, 0x1f, - 0x91, 0x3, 0x9b, 0xfb, 0x84, 0x5e, 0x45, 0xdb, 0xb3, 0xb9, 0xe, 0x88}; - uint8_t bytesprops4[] = {0xfa, 0x7c, 0x87, 0x23, 0x68}; - uint8_t bytesprops5[] = {0x31, 0x1d, 0xb2, 0x81, 0x7e, 0x2d, 0x7b, 0x2b, 0x1f, 0x1a, 0x42, 0x65, 0x7f, 0xf, 0xae, - 0x71, 0xd2, 0xf1, 0x5a, 0x71, 0xc9, 0x5f, 0x6d, 0x62, 0x81, 0x40, 0xd2, 0x45, 0xd0}; + msg.payload_len = 28; + + uint8_t bytesprops0[] = {0x5f, 0x2d, 0xd5}; + uint8_t bytesprops1[] = {0xa5, 0x4b, 0x4a, 0xdb, 0x41, 0x70, 0xc0, 0x97, 0xc8, 0x86, 0x95}; + uint8_t bytesprops2[] = {0x54, 0x6c, 0x81, 0x60, 0xb4, 0x26, 0x45, 0x4b, + 0x71, 0x36, 0xc9, 0xe8, 0x19, 0x28, 0xeb, 0x1f}; + uint8_t bytesprops3[] = {0xe8, 0xf2, 0x27, 0x74, 0x86, 0x77, 0x98, 0xd4, 0x12, + 0x37, 0x9b, 0x59, 0x7f, 0x78, 0xd1, 0x73, 0x35, 0xc5}; + uint8_t bytesprops4[] = {0xe3, 0xc1, 0x0, 0x3a, 0x4b, 0x86, 0x58, 0x86, 0xf5, 0xe8, 0xe7, 0x52, 0x42, 0x94, 0xe5, + 0xd6, 0xcb, 0xb2, 0xba, 0xed, 0xf7, 0xfc, 0x7, 0x39, 0x81, 0x6c, 0x63, 0x7f, 0x99}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1270}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10662}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 643}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4736}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22872}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1239}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32352}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27318}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4804}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28672}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 124}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 6873, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 617, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\198\DC1L:\231)\185\220\223D\v\EOT\217<", _pubPktID = 6873, _pubBody = "\ESC\"[|\180", _pubProps = -// [PropSubscriptionIdentifier 26,PropSubscriptionIdentifier 20,PropSubscriptionIdentifierAvailable -// 97,PropSessionExpiryInterval 1270,PropMaximumQoS 17,PropTopicAliasMaximum 10662,PropServerReference -// "1\200T%r\131\SOHr\212\191\242\CAN\247#\238v\nH\DC4\201Z\164\245\223\FS]",PropWillDelayInterval 643,PropMaximumQoS -// 77,PropPayloadFormatIndicator 204,PropAuthenticationData "\191 -// \136a\144\SUB\218\233\142\192\141\188\130\200\&2\140\234\168.\182\244`\169",PropRequestResponseInformation -// 99,PropRequestProblemInformation 98,PropSessionExpiryInterval 4736,PropSessionExpiryInterval 22872,PropResponseTopic -// "\143(Q\146\&7\171ew}S^\134\238QZ\DC3E \182\230'\234`",PropAuthenticationData -// "\207\179g\145M\145\246\226Ij\173\US\145\ETX\155\251\132^E\219\179\185\SO\136",PropServerReference -// "\250|\135#h",PropRetainAvailable 1,PropServerReference -// "1\GS\178\129~-{+\US\SUBBe\DEL\SI\174q\210\241Zq\201_mb\129@\210E\208",PropSubscriptionIdentifier -// 14,PropMessageExpiryInterval 1239]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\164_xCoe\161\\\SYN8\247~X\178U\EOT\201\239d\NUL\v\219\239", _pubPktID = 617, _pubBody = +// "\203\"\151M\221\179{\230\DC3c\185\FS\183-\225\169\214\ETX\128\159\170E\186\239\ESC\153\192\142", _pubProps = +// [PropMaximumQoS 222,PropReceiveMaximum 32352,PropResponseTopic "_-\213",PropSharedSubscriptionAvailable +// 77,PropMessageExpiryInterval 27318,PropSubscriptionIdentifierAvailable 17,PropTopicAlias 4804,PropMaximumQoS +// 245,PropMaximumQoS 33,PropServerReference "\165KJ\219Ap\192\151\200\134\149",PropSharedSubscriptionAvailable +// 196,PropTopicAlias 28672,PropAssignedClientIdentifier "Tl\129`\180&EKq6\201\232\EM(\235\US",PropRetainAvailable +// 117,PropAssignedClientIdentifier "\232\242't\134w\152\212\DC27\155Y\DELx\209s5\197",PropPayloadFormatIndicator +// 133,PropWildcardSubscriptionAvailable 232,PropAuthenticationMethod +// "\227\193\NUL:K\134X\134\245\232\231RB\148\229\214\203\178\186\237\247\252\a9\129lc\DEL\153",PropMaximumQoS +// 231,PropRetainAvailable 124]} TEST(Publish5QCTest, Decode2) { uint8_t pkt[] = { - 0x35, 0xdd, 0x1, 0x0, 0xe, 0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c, - 0x1a, 0xd9, 0xc4, 0x1, 0xb, 0x1a, 0xb, 0x14, 0x29, 0x61, 0x11, 0x0, 0x0, 0x4, 0xf6, 0x24, 0x11, 0x22, 0x29, - 0xa6, 0x1c, 0x0, 0x1a, 0x31, 0xc8, 0x54, 0x25, 0x72, 0x83, 0x1, 0x72, 0xd4, 0xbf, 0xf2, 0x18, 0xf7, 0x23, 0xee, - 0x76, 0xa, 0x48, 0x14, 0xc9, 0x5a, 0xa4, 0xf5, 0xdf, 0x1c, 0x5d, 0x18, 0x0, 0x0, 0x2, 0x83, 0x24, 0x4d, 0x1, - 0xcc, 0x16, 0x0, 0x17, 0xbf, 0x20, 0x88, 0x61, 0x90, 0x1a, 0xda, 0xe9, 0x8e, 0xc0, 0x8d, 0xbc, 0x82, 0xc8, 0x32, - 0x8c, 0xea, 0xa8, 0x2e, 0xb6, 0xf4, 0x60, 0xa9, 0x19, 0x63, 0x17, 0x62, 0x11, 0x0, 0x0, 0x12, 0x80, 0x11, 0x0, - 0x0, 0x59, 0x58, 0x8, 0x0, 0x17, 0x8f, 0x28, 0x51, 0x92, 0x37, 0xab, 0x65, 0x77, 0x7d, 0x53, 0x5e, 0x86, 0xee, - 0x51, 0x5a, 0x13, 0x45, 0x20, 0xb6, 0xe6, 0x27, 0xea, 0x60, 0x16, 0x0, 0x18, 0xcf, 0xb3, 0x67, 0x91, 0x4d, 0x91, - 0xf6, 0xe2, 0x49, 0x6a, 0xad, 0x1f, 0x91, 0x3, 0x9b, 0xfb, 0x84, 0x5e, 0x45, 0xdb, 0xb3, 0xb9, 0xe, 0x88, 0x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x58, 0x86, 0xf5, 0xe8, 0xe7, 0x52, 0x42, 0x94, 0xe5, 0xd6, 0xcb, 0xb2, 0xba, 0xed, 0xf7, 0xfc, 0x7, 0x39, 0x81, + 0x6c, 0x63, 0x7f, 0x99, 0x24, 0xe7, 0x25, 0x7c, 0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, + 0x1c, 0xb7, 0x2d, 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2058,67 +1946,149 @@ TEST(Publish5QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc6, 0x11, 0x4c, 0x3a, 0xe7, 0x29, 0xb9, 0xdc, 0xdf, 0x44, 0xb, 0x4, 0xd9, 0x3c}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x1b, 0x22, 0x5b, 0x7c, 0xb4}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + uint8_t exp_topic_bytes[] = {0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, + 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef}; + lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, + 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 6873); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + EXPECT_EQ(packet_id, 617); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "^W\131\160\253B\156\130SrVB\238=\158m_\253\242\178N", _pubPktID = 12282, _pubBody = -// "\169\159cc\RSh\239_U\ETB\NAK\223f", _pubProps = [PropMessageExpiryInterval 2866,PropServerReference -// "\216\SOH\NAKu\157\159\n\164\172",PropRequestProblemInformation 154]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "]\DEL\239p\251\205\214zi\204\179\194Y\158", _pubPktID = 0, _pubBody = +// "|\207v\144\230\175\FSN\178\165\215\DC3\EM\250\162\187\135\181", _pubProps = [PropMaximumPacketSize +// 10488,PropPayloadFormatIndicator 12,PropResponseTopic +// "`n\227\135Df\149W\177\181\204\163\199\167\227\179\153sS\SYN8\EOTo",PropAuthenticationMethod +// "\138s\203u\213",PropSharedSubscriptionAvailable 77,PropWildcardSubscriptionAvailable +// 166,PropSubscriptionIdentifierAvailable 21,PropResponseTopic "}\182,\rz\137?\187\r",PropAuthenticationMethod +// "",PropResponseInformation "*hT\196\138\173\SO3[\153\&1\238[.\155[",PropSubscriptionIdentifier 3,PropRetainAvailable +// 191,PropServerKeepAlive 21972,PropAuthenticationData "\249\200\209\&2/",PropContentType +// "\198-\246s1u\142h\151\153",PropSubscriptionIdentifier 7,PropRetainAvailable 255,PropCorrelationData +// "\157gh\147\193INa\203\FS\a\232\a\200\ENQ\190\201\192\182\166\139\177\CAN\vRu",PropMaximumQoS 193,PropResponseTopic +// "\199\236#\244J\216\&4#!",PropAssignedClientIdentifier +// "\230\163=9\213|\128[\232\152\148\255M\STX\209>\225\131\131ba\181\199\234\206\231\NULl",PropMaximumPacketSize +// 4488,PropTopicAliasMaximum 28636,PropAssignedClientIdentifier +// "\153\236\225\131\131ba\181\199\234\206\231\NULl",PropMaximumPacketSize +// 4488,PropTopicAliasMaximum 28636,PropAssignedClientIdentifier +// "\153\236(topic.data), 21); - EXPECT_EQ(msg.payload_len, 13); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 18); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\223~\247S\221_\137\253\202\t\SO<\197\171X=\DC1'\196\ACK", _pubPktID = 7369, _pubBody = -// "\218\SI\242\t\138\r\SO\ESC[\224\207", _pubProps = [PropMaximumPacketSize 12936,PropServerKeepAlive -// 29399,PropRetainAvailable 124,PropTopicAliasMaximum 20663,PropReasonString -// "\189\DC2u}o&\218G\239\DC4\202;\143\b",PropCorrelationData -// "\129=\183\174f\210\184\204h\195\223\\\138\141",PropMessageExpiryInterval 17593,PropMaximumPacketSize -// 27303,PropServerReference "d\146\185<\255\151\&8\ETB\"\163[\176|\214g/w\210N\250s",PropRequestResponseInformation -// 140,PropResponseTopic "\172\144\DC2\140\130\\\EM\rj\243\135\&6",PropRequestResponseInformation 24,PropReceiveMaximum -// 24602,PropRetainAvailable 197,PropWillDelayInterval 7751,PropRequestProblemInformation -// 36,PropRequestResponseInformation 76,PropSubscriptionIdentifier 7,PropRequestResponseInformation 2]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\&8\RSE", _pubPktID = 14265, +// _pubBody = "OtS\167", _pubProps = [PropTopicAliasMaximum 24809]} TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = {0x34, 0x9a, 0x1, 0x0, 0x14, 0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, 0xe, - 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6, 0x1c, 0xc9, 0x76, 0x27, 0x0, 0x0, 0x32, - 0x88, 0x13, 0x72, 0xd7, 0x25, 0x7c, 0x22, 0x50, 0xb7, 0x1f, 0x0, 0xe, 0xbd, 0x12, 0x75, 0x7d, - 0x6f, 0x26, 0xda, 0x47, 0xef, 0x14, 0xca, 0x3b, 0x8f, 0x8, 0x9, 0x0, 0xe, 0x81, 0x3d, 0xb7, - 0xae, 0x66, 0xd2, 0xb8, 0xcc, 0x68, 0xc3, 0xdf, 0x5c, 0x8a, 0x8d, 0x2, 0x0, 0x0, 0x44, 0xb9, - 0x27, 0x0, 0x0, 0x6a, 0xa7, 0x1c, 0x0, 0x15, 0x64, 0x92, 0xb9, 0x3c, 0xff, 0x97, 0x38, 0x17, - 0x22, 0xa3, 0x5b, 0xb0, 0x7c, 0xd6, 0x67, 0x2f, 0x77, 0xd2, 0x4e, 0xfa, 0x73, 0x19, 0x8c, 0x8, - 0x0, 0xc, 0xac, 0x90, 0x12, 0x8c, 0x82, 0x5c, 0x19, 0xd, 0x6a, 0xf3, 0x87, 0x36, 0x19, 0x18, - 0x21, 0x60, 0x1a, 0x25, 0xc5, 0x18, 0x0, 0x0, 0x1e, 0x47, 0x17, 0x24, 0x19, 0x4c, 0xb, 0x7, - 0x19, 0x2, 0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; - uint8_t topic_bytes[] = {0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, - 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3d, 0x10, 0x0, 0x4, 0xff, 0x38, 0x1e, 0x45, 0x37, + 0xb9, 0x3, 0x22, 0x60, 0xe9, 0x4f, 0x74, 0x53, 0xa7}; + uint8_t topic_bytes[] = {0xff, 0x38, 0x1e, 0x45}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; + msg.retained = true; + uint8_t msg_bytes[] = {0x4f, 0x74, 0x53, 0xa7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; - - uint8_t bytesprops0[] = {0xbd, 0x12, 0x75, 0x7d, 0x6f, 0x26, 0xda, 0x47, 0xef, 0x14, 0xca, 0x3b, 0x8f, 0x8}; - uint8_t bytesprops1[] = {0x81, 0x3d, 0xb7, 0xae, 0x66, 0xd2, 0xb8, 0xcc, 0x68, 0xc3, 0xdf, 0x5c, 0x8a, 0x8d}; - uint8_t bytesprops2[] = {0x64, 0x92, 0xb9, 0x3c, 0xff, 0x97, 0x38, 0x17, 0x22, 0xa3, 0x5b, - 0xb0, 0x7c, 0xd6, 0x67, 0x2f, 0x77, 0xd2, 0x4e, 0xfa, 0x73}; - uint8_t bytesprops3[] = {0xac, 0x90, 0x12, 0x8c, 0x82, 0x5c, 0x19, 0xd, 0x6a, 0xf3, 0x87, 0x36}; + msg.payload_len = 4; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12936}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29399}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20663}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17593}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27303}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24602}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7751}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24809}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7369, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 14265, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\223~\247S\221_\137\253\202\t\SO<\197\171X=\DC1'\196\ACK", _pubPktID = 7369, _pubBody = -// "\218\SI\242\t\138\r\SO\ESC[\224\207", _pubProps = [PropMaximumPacketSize 12936,PropServerKeepAlive -// 29399,PropRetainAvailable 124,PropTopicAliasMaximum 20663,PropReasonString -// "\189\DC2u}o&\218G\239\DC4\202;\143\b",PropCorrelationData -// "\129=\183\174f\210\184\204h\195\223\\\138\141",PropMessageExpiryInterval 17593,PropMaximumPacketSize -// 27303,PropServerReference "d\146\185<\255\151\&8\ETB\"\163[\176|\214g/w\210N\250s",PropRequestResponseInformation -// 140,PropResponseTopic "\172\144\DC2\140\130\\\EM\rj\243\135\&6",PropRequestResponseInformation 24,PropReceiveMaximum -// 24602,PropRetainAvailable 197,PropWillDelayInterval 7751,PropRequestProblemInformation -// 36,PropRequestResponseInformation 76,PropSubscriptionIdentifier 7,PropRequestResponseInformation 2]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\&8\RSE", _pubPktID = 14265, +// _pubBody = "OtS\167", _pubProps = [PropTopicAliasMaximum 24809]} TEST(Publish5QCTest, Decode4) { - uint8_t pkt[] = {0x34, 0x9a, 0x1, 0x0, 0x14, 0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, 0xe, - 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6, 0x1c, 0xc9, 0x76, 0x27, 0x0, 0x0, 0x32, - 0x88, 0x13, 0x72, 0xd7, 0x25, 0x7c, 0x22, 0x50, 0xb7, 0x1f, 0x0, 0xe, 0xbd, 0x12, 0x75, 0x7d, - 0x6f, 0x26, 0xda, 0x47, 0xef, 0x14, 0xca, 0x3b, 0x8f, 0x8, 0x9, 0x0, 0xe, 0x81, 0x3d, 0xb7, - 0xae, 0x66, 0xd2, 0xb8, 0xcc, 0x68, 0xc3, 0xdf, 0x5c, 0x8a, 0x8d, 0x2, 0x0, 0x0, 0x44, 0xb9, - 0x27, 0x0, 0x0, 0x6a, 0xa7, 0x1c, 0x0, 0x15, 0x64, 0x92, 0xb9, 0x3c, 0xff, 0x97, 0x38, 0x17, - 0x22, 0xa3, 0x5b, 0xb0, 0x7c, 0xd6, 0x67, 0x2f, 0x77, 0xd2, 0x4e, 0xfa, 0x73, 0x19, 0x8c, 0x8, - 0x0, 0xc, 0xac, 0x90, 0x12, 0x8c, 0x82, 0x5c, 0x19, 0xd, 0x6a, 0xf3, 0x87, 0x36, 0x19, 0x18, - 0x21, 0x60, 0x1a, 0x25, 0xc5, 0x18, 0x0, 0x0, 0x1e, 0x47, 0x17, 0x24, 0x19, 0x4c, 0xb, 0x7, - 0x19, 0x2, 0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; + uint8_t pkt[] = {0x3d, 0x10, 0x0, 0x4, 0xff, 0x38, 0x1e, 0x45, 0x37, + 0xb9, 0x3, 0x22, 0x60, 0xe9, 0x4f, 0x74, 0x53, 0xa7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2241,72 +2154,102 @@ TEST(Publish5QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xdf, 0x7e, 0xf7, 0x53, 0xdd, 0x5f, 0x89, 0xfd, 0xca, 0x9, - 0xe, 0x3c, 0xc5, 0xab, 0x58, 0x3d, 0x11, 0x27, 0xc4, 0x6}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xda, 0xf, 0xf2, 0x9, 0x8a, 0xd, 0xe, 0x1b, 0x5b, 0xe0, 0xcf}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xff, 0x38, 0x1e, 0x45}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4f, 0x74, 0x53, 0xa7}; + lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 7369); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 14265); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 4); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\250\191\190jan\209", _pubPktID = -// 6761, _pubBody = "z-\195\235\243\220Q", _pubProps = [PropMaximumQoS 51,PropWildcardSubscriptionAvailable -// 241,PropWillDelayInterval 30710,PropAuthenticationData "m\144\196p",PropRetainAvailable 66,PropMaximumPacketSize -// 28886,PropWillDelayInterval 10121,PropSharedSubscriptionAvailable 136]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\175\137\vj?Vv\214\&1|l\a\RS\191\237\148\187\223g^\158f\195W\245R\159", _pubPktID = 0, _pubBody = +// "\133\170\157HgVe\197\170\203V\231", _pubProps = [PropReceiveMaximum 21892,PropTopicAlias +// 15063,PropResponseInformation "\182H\aU\ETX$\176_\214a\178\217;PJN\DC1\237\149\219\EM\155\174\249",PropReceiveMaximum +// 4741,PropWildcardSubscriptionAvailable 144,PropMaximumPacketSize 15811,PropAuthenticationData +// "\159&\DLE\t\236\229\181\205\174\191\247\190\212\182\&8\177\160#\239\230\200a",PropAuthenticationData +// "\191\240\208\200fEkt\239\ESC\162XS3X\ACK\180\241\204\185",PropMessageExpiryInterval 32048,PropRetainAvailable +// 81,PropCorrelationData "\163\233\156\b'\241\197\238\227'\203\&7~\b\202\235q\234\171\213\201WX"]} TEST(Publish5QCTest, Encode5) { - uint8_t pkt[] = {0x3c, 0x31, 0x0, 0x7, 0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1, 0x1a, 0x69, - 0x1e, 0x24, 0x33, 0x28, 0xf1, 0x18, 0x0, 0x0, 0x77, 0xf6, 0x16, 0x0, 0x4, - 0x6d, 0x90, 0xc4, 0x70, 0x25, 0x42, 0x27, 0x0, 0x0, 0x70, 0xd6, 0x18, 0x0, - 0x0, 0x27, 0x89, 0x2a, 0x88, 0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; - uint8_t topic_bytes[] = {0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0xa6, 0x1, 0x0, 0x1b, 0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, 0x7, + 0x1e, 0xbf, 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f, 0x7c, 0x21, + 0x55, 0x84, 0x23, 0x3a, 0xd7, 0x1a, 0x0, 0x18, 0xb6, 0x48, 0x7, 0x55, 0x3, 0x24, 0xb0, 0x5f, 0xd6, + 0x61, 0xb2, 0xd9, 0x3b, 0x50, 0x4a, 0x4e, 0x11, 0xed, 0x95, 0xdb, 0x19, 0x9b, 0xae, 0xf9, 0x21, 0x12, + 0x85, 0x28, 0x90, 0x27, 0x0, 0x0, 0x3d, 0xc3, 0x16, 0x0, 0x16, 0x9f, 0x26, 0x10, 0x9, 0xec, 0xe5, + 0xb5, 0xcd, 0xae, 0xbf, 0xf7, 0xbe, 0xd4, 0xb6, 0x38, 0xb1, 0xa0, 0x23, 0xef, 0xe6, 0xc8, 0x61, 0x16, + 0x0, 0x14, 0xbf, 0xf0, 0xd0, 0xc8, 0x66, 0x45, 0x6b, 0x74, 0xef, 0x1b, 0xa2, 0x58, 0x53, 0x33, 0x58, + 0x6, 0xb4, 0xf1, 0xcc, 0xb9, 0x2, 0x0, 0x0, 0x7d, 0x30, 0x25, 0x51, 0x9, 0x0, 0x17, 0xa3, 0xe9, + 0x9c, 0x8, 0x27, 0xf1, 0xc5, 0xee, 0xe3, 0x27, 0xcb, 0x37, 0x7e, 0x8, 0xca, 0xeb, 0x71, 0xea, 0xab, + 0xd5, 0xc9, 0x57, 0x58, 0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; + uint8_t topic_bytes[] = {0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, 0x7, 0x1e, 0xbf, + 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 12; - uint8_t bytesprops0[] = {0x6d, 0x90, 0xc4, 0x70}; + uint8_t bytesprops0[] = {0xb6, 0x48, 0x7, 0x55, 0x3, 0x24, 0xb0, 0x5f, 0xd6, 0x61, 0xb2, 0xd9, + 0x3b, 0x50, 0x4a, 0x4e, 0x11, 0xed, 0x95, 0xdb, 0x19, 0x9b, 0xae, 0xf9}; + uint8_t bytesprops1[] = {0x9f, 0x26, 0x10, 0x9, 0xec, 0xe5, 0xb5, 0xcd, 0xae, 0xbf, 0xf7, + 0xbe, 0xd4, 0xb6, 0x38, 0xb1, 0xa0, 0x23, 0xef, 0xe6, 0xc8, 0x61}; + uint8_t bytesprops2[] = {0xbf, 0xf0, 0xd0, 0xc8, 0x66, 0x45, 0x6b, 0x74, 0xef, 0x1b, + 0xa2, 0x58, 0x53, 0x33, 0x58, 0x6, 0xb4, 0xf1, 0xcc, 0xb9}; + uint8_t bytesprops3[] = {0xa3, 0xe9, 0x9c, 0x8, 0x27, 0xf1, 0xc5, 0xee, 0xe3, 0x27, 0xcb, 0x37, + 0x7e, 0x8, 0xca, 0xeb, 0x71, 0xea, 0xab, 0xd5, 0xc9, 0x57, 0x58}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30710}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28886}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10121}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21892}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15063}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4741}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15811}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32048}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 6761, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\250\191\190jan\209", _pubPktID = -// 6761, _pubBody = "z-\195\235\243\220Q", _pubProps = [PropMaximumQoS 51,PropWildcardSubscriptionAvailable -// 241,PropWillDelayInterval 30710,PropAuthenticationData "m\144\196p",PropRetainAvailable 66,PropMaximumPacketSize -// 28886,PropWillDelayInterval 10121,PropSharedSubscriptionAvailable 136]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\175\137\vj?Vv\214\&1|l\a\RS\191\237\148\187\223g^\158f\195W\245R\159", _pubPktID = 0, _pubBody = +// "\133\170\157HgVe\197\170\203V\231", _pubProps = [PropReceiveMaximum 21892,PropTopicAlias +// 15063,PropResponseInformation "\182H\aU\ETX$\176_\214a\178\217;PJN\DC1\237\149\219\EM\155\174\249",PropReceiveMaximum +// 4741,PropWildcardSubscriptionAvailable 144,PropMaximumPacketSize 15811,PropAuthenticationData +// "\159&\DLE\t\236\229\181\205\174\191\247\190\212\182\&8\177\160#\239\230\200a",PropAuthenticationData +// "\191\240\208\200fEkt\239\ESC\162XS3X\ACK\180\241\204\185",PropMessageExpiryInterval 32048,PropRetainAvailable +// 81,PropCorrelationData "\163\233\156\b'\241\197\238\227'\203\&7~\b\202\235q\234\171\213\201WX"]} TEST(Publish5QCTest, Decode5) { - uint8_t pkt[] = {0x3c, 0x31, 0x0, 0x7, 0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1, 0x1a, 0x69, - 0x1e, 0x24, 0x33, 0x28, 0xf1, 0x18, 0x0, 0x0, 0x77, 0xf6, 0x16, 0x0, 0x4, - 0x6d, 0x90, 0xc4, 0x70, 0x25, 0x42, 0x27, 0x0, 0x0, 0x70, 0xd6, 0x18, 0x0, - 0x0, 0x27, 0x89, 0x2a, 0x88, 0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; + uint8_t pkt[] = {0x39, 0xa6, 0x1, 0x0, 0x1b, 0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, 0x7, + 0x1e, 0xbf, 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f, 0x7c, 0x21, + 0x55, 0x84, 0x23, 0x3a, 0xd7, 0x1a, 0x0, 0x18, 0xb6, 0x48, 0x7, 0x55, 0x3, 0x24, 0xb0, 0x5f, 0xd6, + 0x61, 0xb2, 0xd9, 0x3b, 0x50, 0x4a, 0x4e, 0x11, 0xed, 0x95, 0xdb, 0x19, 0x9b, 0xae, 0xf9, 0x21, 0x12, + 0x85, 0x28, 0x90, 0x27, 0x0, 0x0, 0x3d, 0xc3, 0x16, 0x0, 0x16, 0x9f, 0x26, 0x10, 0x9, 0xec, 0xe5, + 0xb5, 0xcd, 0xae, 0xbf, 0xf7, 0xbe, 0xd4, 0xb6, 0x38, 0xb1, 0xa0, 0x23, 0xef, 0xe6, 0xc8, 0x61, 0x16, + 0x0, 0x14, 0xbf, 0xf0, 0xd0, 0xc8, 0x66, 0x45, 0x6b, 0x74, 0xef, 0x1b, 0xa2, 0x58, 0x53, 0x33, 0x58, + 0x6, 0xb4, 0xf1, 0xcc, 0xb9, 0x2, 0x0, 0x0, 0x7d, 0x30, 0x25, 0x51, 0x9, 0x0, 0x17, 0xa3, 0xe9, + 0x9c, 0x8, 0x27, 0xf1, 0xc5, 0xee, 0xe3, 0x27, 0xcb, 0x37, 0x7e, 0x8, 0xca, 0xeb, 0x71, 0xea, 0xab, + 0xd5, 0xc9, 0x57, 0x58, 0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2315,109 +2258,130 @@ TEST(Publish5QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xfa, 0xbf, 0xbe, 0x6a, 0x61, 0x6e, 0xd1}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7a, 0x2d, 0xc3, 0xeb, 0xf3, 0xdc, 0x51}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, 0x7, 0x1e, 0xbf, + 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 6761); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\229Y\156\186GOd\EOT\247\ETB\224\251-\228h{^Q!\246\b\DEL\225\NUL{/Q ", _pubPktID = 0, _pubBody = "<@\201Iv", -// _pubProps = [PropWildcardSubscriptionAvailable 30,PropRequestProblemInformation 173,PropSharedSubscriptionAvailable -// 114,PropRequestProblemInformation 48,PropSharedSubscriptionAvailable 63,PropWildcardSubscriptionAvailable -// 80,PropAssignedClientIdentifier "j",PropReceiveMaximum 7010,PropTopicAliasMaximum 29063,PropResponseInformation -// "\150\206\240\187U\152#\224]2=,\t\189\138\205\255\254`\175{}",PropServerKeepAlive 31184,PropReasonString -// "\ETXA",PropRequestProblemInformation 225,PropRetainAvailable 107,PropResponseTopic -// "\153\228\225A$\189h\217",PropAuthenticationMethod ";\180\240#\146Z \140_\212$\176\156Nt| -// \r",PropAuthenticationMethod "\175V\149+\250\164\254\205\181\234v`\233\247j\161\146\174"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\fn)\RS", _pubPktID = 5499, _pubBody +// = "\156I\SUB\231\236b\ENQ\137\237\r\NAK:[\222g\135", _pubProps = [PropResponseInformation +// "!mQ\NUL\213\194T\222",PropAuthenticationData +// "L\185\136R\252E\189\233\220\193\SYN;\182\234\239[\188\&1\171\143%\144\242",PropReceiveMaximum 4689,PropResponseTopic +// "\CANgB#\ENQz\195$\SOH\221\164M\STXa\203d8K*",PropSharedSubscriptionAvailable 169,PropMaximumPacketSize +// 5137,PropRequestProblemInformation 210,PropResponseTopic +// "\185$\SO\155\135\151\DLE\ETB\178#\200\\\210\216\SOH\197u\CAN'\n\224\206",PropUserProperty +// "l6\149r\NAK\188\191~\155\128@8c\245\\'\144\169\231" +// "\\\204E\175\SI\156\150XH\185\247\254\RSy",PropSessionExpiryInterval 8146,PropReasonString +// "s\221@M\SI\254",PropReceiveMaximum 14585,PropUserProperty ")H\207\234P\197Pv" +// "s8tQ\163QX\SUB\171\223\149\178\248H\a\243\136\163\183",PropMessageExpiryInterval 11331,PropReasonString +// "(R!\207\172E*-\192\184\227",PropWillDelayInterval 23672]} TEST(Publish5QCTest, Encode6) { - uint8_t pkt[] = {0x39, 0x94, 0x1, 0x0, 0x1c, 0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, - 0x2d, 0xe4, 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20, 0x70, - 0x28, 0x1e, 0x17, 0xad, 0x2a, 0x72, 0x17, 0x30, 0x2a, 0x3f, 0x28, 0x50, 0x12, 0x0, 0x1, 0x6a, 0x21, - 0x1b, 0x62, 0x22, 0x71, 0x87, 0x1a, 0x0, 0x16, 0x96, 0xce, 0xf0, 0xbb, 0x55, 0x98, 0x23, 0xe0, 0x5d, - 0x32, 0x3d, 0x2c, 0x9, 0xbd, 0x8a, 0xcd, 0xff, 0xfe, 0x60, 0xaf, 0x7b, 0x7d, 0x13, 0x79, 0xd0, 0x1f, - 0x0, 0x2, 0x3, 0x41, 0x17, 0xe1, 0x25, 0x6b, 0x8, 0x0, 0x8, 0x99, 0xe4, 0xe1, 0x41, 0x24, 0xbd, - 0x68, 0xd9, 0x15, 0x0, 0x12, 0x3b, 0xb4, 0xf0, 0x23, 0x92, 0x5a, 0x20, 0x8c, 0x5f, 0xd4, 0x24, 0xb0, - 0x9c, 0x4e, 0x74, 0x7c, 0x20, 0xd, 0x15, 0x0, 0x12, 0xaf, 0x56, 0x95, 0x2b, 0xfa, 0xa4, 0xfe, 0xcd, - 0xb5, 0xea, 0x76, 0x60, 0xe9, 0xf7, 0x6a, 0xa1, 0x92, 0xae, 0x3c, 0x40, 0xc9, 0x49, 0x76}; - uint8_t topic_bytes[] = {0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, 0x2d, 0xe4, - 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0xe9, 0x1, 0x0, 0x4, 0xc, 0x6e, 0x29, 0x1e, 0x15, 0x7b, 0xcf, 0x1, 0x1a, 0x0, 0x8, 0x21, + 0x6d, 0x51, 0x0, 0xd5, 0xc2, 0x54, 0xde, 0x16, 0x0, 0x17, 0x4c, 0xb9, 0x88, 0x52, 0xfc, 0x45, 0xbd, + 0xe9, 0xdc, 0xc1, 0x16, 0x3b, 0xb6, 0xea, 0xef, 0x5b, 0xbc, 0x31, 0xab, 0x8f, 0x25, 0x90, 0xf2, 0x21, + 0x12, 0x51, 0x8, 0x0, 0x13, 0x18, 0x67, 0x42, 0x23, 0x5, 0x7a, 0xc3, 0x24, 0x1, 0xdd, 0xa4, 0x4d, + 0x2, 0x61, 0xcb, 0x64, 0x38, 0x4b, 0x2a, 0x2a, 0xa9, 0x27, 0x0, 0x0, 0x14, 0x11, 0x17, 0xd2, 0x8, + 0x0, 0x16, 0xb9, 0x24, 0xe, 0x9b, 0x87, 0x97, 0x10, 0x17, 0xb2, 0x23, 0xc8, 0x5c, 0xd2, 0xd8, 0x1, + 0xc5, 0x75, 0x18, 0x27, 0xa, 0xe0, 0xce, 0x26, 0x0, 0x13, 0x6c, 0x36, 0x95, 0x72, 0x15, 0xbc, 0xbf, + 0x7e, 0x9b, 0x80, 0x40, 0x38, 0x63, 0xf5, 0x5c, 0x27, 0x90, 0xa9, 0xe7, 0x0, 0xe, 0x5c, 0xcc, 0x45, + 0xaf, 0xf, 0x9c, 0x96, 0x58, 0x48, 0xb9, 0xf7, 0xfe, 0x1e, 0x79, 0x11, 0x0, 0x0, 0x1f, 0xd2, 0x1f, + 0x0, 0x6, 0x73, 0xdd, 0x40, 0x4d, 0xf, 0xfe, 0x21, 0x38, 0xf9, 0x26, 0x0, 0x8, 0x29, 0x48, 0xcf, + 0xea, 0x50, 0xc5, 0x50, 0x76, 0x0, 0x13, 0x73, 0x38, 0x74, 0x51, 0xa3, 0x51, 0x58, 0x1a, 0xab, 0xdf, + 0x95, 0xb2, 0xf8, 0x48, 0x7, 0xf3, 0x88, 0xa3, 0xb7, 0x2, 0x0, 0x0, 0x2c, 0x43, 0x1f, 0x0, 0xb, + 0x28, 0x52, 0x21, 0xcf, 0xac, 0x45, 0x2a, 0x2d, 0xc0, 0xb8, 0xe3, 0x18, 0x0, 0x0, 0x5c, 0x78, 0x9c, + 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; + uint8_t topic_bytes[] = {0xc, 0x6e, 0x29, 0x1e}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x3c, 0x40, 0xc9, 0x49, 0x76}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x9c, 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; - - uint8_t bytesprops0[] = {0x6a}; - uint8_t bytesprops1[] = {0x96, 0xce, 0xf0, 0xbb, 0x55, 0x98, 0x23, 0xe0, 0x5d, 0x32, 0x3d, - 0x2c, 0x9, 0xbd, 0x8a, 0xcd, 0xff, 0xfe, 0x60, 0xaf, 0x7b, 0x7d}; - uint8_t bytesprops2[] = {0x3, 0x41}; - uint8_t bytesprops3[] = {0x99, 0xe4, 0xe1, 0x41, 0x24, 0xbd, 0x68, 0xd9}; - uint8_t bytesprops4[] = {0x3b, 0xb4, 0xf0, 0x23, 0x92, 0x5a, 0x20, 0x8c, 0x5f, - 0xd4, 0x24, 0xb0, 0x9c, 0x4e, 0x74, 0x7c, 0x20, 0xd}; - uint8_t bytesprops5[] = {0xaf, 0x56, 0x95, 0x2b, 0xfa, 0xa4, 0xfe, 0xcd, 0xb5, - 0xea, 0x76, 0x60, 0xe9, 0xf7, 0x6a, 0xa1, 0x92, 0xae}; + msg.payload_len = 16; + + uint8_t bytesprops0[] = {0x21, 0x6d, 0x51, 0x0, 0xd5, 0xc2, 0x54, 0xde}; + uint8_t bytesprops1[] = {0x4c, 0xb9, 0x88, 0x52, 0xfc, 0x45, 0xbd, 0xe9, 0xdc, 0xc1, 0x16, 0x3b, + 0xb6, 0xea, 0xef, 0x5b, 0xbc, 0x31, 0xab, 0x8f, 0x25, 0x90, 0xf2}; + uint8_t bytesprops2[] = {0x18, 0x67, 0x42, 0x23, 0x5, 0x7a, 0xc3, 0x24, 0x1, 0xdd, + 0xa4, 0x4d, 0x2, 0x61, 0xcb, 0x64, 0x38, 0x4b, 0x2a}; + uint8_t bytesprops3[] = {0xb9, 0x24, 0xe, 0x9b, 0x87, 0x97, 0x10, 0x17, 0xb2, 0x23, 0xc8, + 0x5c, 0xd2, 0xd8, 0x1, 0xc5, 0x75, 0x18, 0x27, 0xa, 0xe0, 0xce}; + uint8_t bytesprops5[] = {0x5c, 0xcc, 0x45, 0xaf, 0xf, 0x9c, 0x96, 0x58, 0x48, 0xb9, 0xf7, 0xfe, 0x1e, 0x79}; + uint8_t bytesprops4[] = {0x6c, 0x36, 0x95, 0x72, 0x15, 0xbc, 0xbf, 0x7e, 0x9b, 0x80, + 0x40, 0x38, 0x63, 0xf5, 0x5c, 0x27, 0x90, 0xa9, 0xe7}; + uint8_t bytesprops6[] = {0x73, 0xdd, 0x40, 0x4d, 0xf, 0xfe}; + uint8_t bytesprops8[] = {0x73, 0x38, 0x74, 0x51, 0xa3, 0x51, 0x58, 0x1a, 0xab, 0xdf, + 0x95, 0xb2, 0xf8, 0x48, 0x7, 0xf3, 0x88, 0xa3, 0xb7}; + uint8_t bytesprops7[] = {0x29, 0x48, 0xcf, 0xea, 0x50, 0xc5, 0x50, 0x76}; + uint8_t bytesprops9[] = {0x28, 0x52, 0x21, 0xcf, 0xac, 0x45, 0x2a, 0x2d, 0xc0, 0xb8, 0xe3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7010}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29063}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31184}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4689}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5137}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops4}, .v = {14, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8146}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14585}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops7}, .v = {19, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11331}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23672}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5499, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\229Y\156\186GOd\EOT\247\ETB\224\251-\228h{^Q!\246\b\DEL\225\NUL{/Q ", _pubPktID = 0, _pubBody = "<@\201Iv", -// _pubProps = [PropWildcardSubscriptionAvailable 30,PropRequestProblemInformation 173,PropSharedSubscriptionAvailable -// 114,PropRequestProblemInformation 48,PropSharedSubscriptionAvailable 63,PropWildcardSubscriptionAvailable -// 80,PropAssignedClientIdentifier "j",PropReceiveMaximum 7010,PropTopicAliasMaximum 29063,PropResponseInformation -// "\150\206\240\187U\152#\224]2=,\t\189\138\205\255\254`\175{}",PropServerKeepAlive 31184,PropReasonString -// "\ETXA",PropRequestProblemInformation 225,PropRetainAvailable 107,PropResponseTopic -// "\153\228\225A$\189h\217",PropAuthenticationMethod ";\180\240#\146Z \140_\212$\176\156Nt| -// \r",PropAuthenticationMethod "\175V\149+\250\164\254\205\181\234v`\233\247j\161\146\174"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\fn)\RS", _pubPktID = 5499, _pubBody +// = "\156I\SUB\231\236b\ENQ\137\237\r\NAK:[\222g\135", _pubProps = [PropResponseInformation +// "!mQ\NUL\213\194T\222",PropAuthenticationData +// "L\185\136R\252E\189\233\220\193\SYN;\182\234\239[\188\&1\171\143%\144\242",PropReceiveMaximum 4689,PropResponseTopic +// "\CANgB#\ENQz\195$\SOH\221\164M\STXa\203d8K*",PropSharedSubscriptionAvailable 169,PropMaximumPacketSize +// 5137,PropRequestProblemInformation 210,PropResponseTopic +// "\185$\SO\155\135\151\DLE\ETB\178#\200\\\210\216\SOH\197u\CAN'\n\224\206",PropUserProperty +// "l6\149r\NAK\188\191~\155\128@8c\245\\'\144\169\231" +// "\\\204E\175\SI\156\150XH\185\247\254\RSy",PropSessionExpiryInterval 8146,PropReasonString +// "s\221@M\SI\254",PropReceiveMaximum 14585,PropUserProperty ")H\207\234P\197Pv" +// "s8tQ\163QX\SUB\171\223\149\178\248H\a\243\136\163\183",PropMessageExpiryInterval 11331,PropReasonString +// "(R!\207\172E*-\192\184\227",PropWillDelayInterval 23672]} TEST(Publish5QCTest, Decode6) { - uint8_t pkt[] = {0x39, 0x94, 0x1, 0x0, 0x1c, 0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, - 0x2d, 0xe4, 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20, 0x70, - 0x28, 0x1e, 0x17, 0xad, 0x2a, 0x72, 0x17, 0x30, 0x2a, 0x3f, 0x28, 0x50, 0x12, 0x0, 0x1, 0x6a, 0x21, - 0x1b, 0x62, 0x22, 0x71, 0x87, 0x1a, 0x0, 0x16, 0x96, 0xce, 0xf0, 0xbb, 0x55, 0x98, 0x23, 0xe0, 0x5d, - 0x32, 0x3d, 0x2c, 0x9, 0xbd, 0x8a, 0xcd, 0xff, 0xfe, 0x60, 0xaf, 0x7b, 0x7d, 0x13, 0x79, 0xd0, 0x1f, - 0x0, 0x2, 0x3, 0x41, 0x17, 0xe1, 0x25, 0x6b, 0x8, 0x0, 0x8, 0x99, 0xe4, 0xe1, 0x41, 0x24, 0xbd, - 0x68, 0xd9, 0x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 0x9c, 0x96, 0x58, 0x48, 0xb9, 0xf7, 0xfe, 0x1e, 0x79, 0x11, 0x0, 0x0, 0x1f, 0xd2, 0x1f, + 0x0, 0x6, 0x73, 0xdd, 0x40, 0x4d, 0xf, 0xfe, 0x21, 0x38, 0xf9, 0x26, 0x0, 0x8, 0x29, 0x48, 0xcf, + 0xea, 0x50, 0xc5, 0x50, 0x76, 0x0, 0x13, 0x73, 0x38, 0x74, 0x51, 0xa3, 0x51, 0x58, 0x1a, 0xab, 0xdf, + 0x95, 0xb2, 0xf8, 0x48, 0x7, 0xf3, 0x88, 0xa3, 0xb7, 0x2, 0x0, 0x0, 0x2c, 0x43, 0x1f, 0x0, 0xb, + 0x28, 0x52, 0x21, 0xcf, 0xac, 0x45, 0x2a, 0x2d, 0xc0, 0xb8, 0xe3, 0x18, 0x0, 0x0, 0x5c, 0x78, 0x9c, + 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2426,119 +2390,138 @@ TEST(Publish5QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe5, 0x59, 0x9c, 0xba, 0x47, 0x4f, 0x64, 0x4, 0xf7, 0x17, 0xe0, 0xfb, 0x2d, 0xe4, - 0x68, 0x7b, 0x5e, 0x51, 0x21, 0xf6, 0x8, 0x7f, 0xe1, 0x0, 0x7b, 0x2f, 0x51, 0x20}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x3c, 0x40, 0xc9, 0x49, 0x76}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xc, 0x6e, 0x29, 0x1e}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9c, 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, + 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 5499); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\242\EM\182T\137\181\\_\NUL\137\135\&0\211", _pubPktID = 31937, _pubBody = -// "\242\196\240\145t\150mj\CANV\251\200\142o\192\150G", _pubProps = [PropRetainAvailable 122,PropSubscriptionIdentifier -// 19,PropReasonString -// "\140l=\142\212\166k\196\222\153\204\166\224!-\SOt\135\152\221\fy\192k!\FS\221\f",PropSharedSubscriptionAvailable -// 194,PropSessionExpiryInterval 2254,PropResponseInformation "\222\199\193\131a@\249",PropWillDelayInterval -// 14313,PropSessionExpiryInterval 29233,PropResponseInformation "\184\154\187\142\"?\231\147",PropResponseInformation -// "\"\US\156\n^\143\tH\US\133\160$g\171\241\173\FS",PropRequestResponseInformation 58,PropResponseInformation -// "Rdn\237\230",PropMessageExpiryInterval 25080,PropReceiveMaximum 25894,PropServerKeepAlive 22192,PropServerReference -// "\166",PropAssignedClientIdentifier -// "\164\233=z\206\223\177<\187\250A\226z.\158;:\ENQ\177J\206\t\v\249\181U\221\240\135"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\213\v\236\218d\193\162h[\237\155\196\145\159\198g\146\138\155\197\164", _pubPktID = 0, _pubBody = +// "\189\233\193\r`$@\171\DC1\230\203j\203\187J\148oG\177\155\SUB\253\232\211\t\DC4#\230", _pubProps = +// [PropAssignedClientIdentifier "\189Q\242\130\236\n\SI\134\185\171",PropReasonString +// "\131y\173\229O\161\156\238\EM\233\174\174\DC1\FS\DLEQ\158",PropCorrelationData +// "Yz\DC3]\196RY\139y3\194\252\&7\v\221\b\192\228\170\251\132\200\200",PropAuthenticationMethod +// "\243\133e\207\EOT,\198\&3S\151\225\222\US\161f",PropAssignedClientIdentifier +// "\200\195-\140+\SYN#U\249\153",PropAuthenticationMethod ">\211\231Y\154\190XNa)",PropWillDelayInterval +// 21746,PropServerReference "\DC2\150\230P%",PropAuthenticationData "4Up\210\193a",PropSubscriptionIdentifier +// 17,PropMessageExpiryInterval 29495,PropWildcardSubscriptionAvailable 235,PropMessageExpiryInterval +// 30240,PropWildcardSubscriptionAvailable 67,PropAuthenticationData +// "\ETB\141@\176,\234B\164t]l\US\232\RS)\\\SUB\175:,\221Jg>",PropRequestResponseInformation 169,PropServerReference +// "7\\\156U\140b\ESC\248",PropReceiveMaximum 29471,PropAuthenticationData "\149\152\199\&2-8M\229\209\182U\137\241"]} TEST(Publish5QCTest, Encode7) { uint8_t pkt[] = { - 0x35, 0xba, 0x1, 0x0, 0xd, 0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3, 0x7c, - 0xc1, 0x96, 0x1, 0x25, 0x7a, 0xb, 0x13, 0x1f, 0x0, 0x1c, 0x8c, 0x6c, 0x3d, 0x8e, 0xd4, 0xa6, 0x6b, 0xc4, 0xde, - 0x99, 0xcc, 0xa6, 0xe0, 0x21, 0x2d, 0xe, 0x74, 0x87, 0x98, 0xdd, 0xc, 0x79, 0xc0, 0x6b, 0x21, 0x1c, 0xdd, 0xc, - 0x2a, 0xc2, 0x11, 0x0, 0x0, 0x8, 0xce, 0x1a, 0x0, 0x7, 0xde, 0xc7, 0xc1, 0x83, 0x61, 0x40, 0xf9, 0x18, 0x0, - 0x0, 0x37, 0xe9, 0x11, 0x0, 0x0, 0x72, 0x31, 0x1a, 0x0, 0x8, 0xb8, 0x9a, 0xbb, 0x8e, 0x22, 0x3f, 0xe7, 0x93, - 0x1a, 0x0, 0x11, 0x22, 0x1f, 0x9c, 0xa, 0x5e, 0x8f, 0x9, 0x48, 0x1f, 0x85, 0xa0, 0x24, 0x67, 0xab, 0xf1, 0xad, - 0x1c, 0x19, 0x3a, 0x1a, 0x0, 0x5, 0x52, 0x64, 0x6e, 0xed, 0xe6, 0x2, 0x0, 0x0, 0x61, 0xf8, 0x21, 0x65, 0x26, - 0x13, 0x56, 0xb0, 0x1c, 0x0, 0x1, 0xa6, 0x12, 0x0, 0x1d, 0xa4, 0xe9, 0x3d, 0x7a, 0xce, 0xdf, 0xb1, 0x3c, 0xbb, - 0xfa, 0x41, 0xe2, 0x7a, 0x2e, 0x9e, 0x3b, 0x3a, 0x5, 0xb1, 0x4a, 0xce, 0x9, 0xb, 0xf9, 0xb5, 0x55, 0xdd, 0xf0, - 0x87, 0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; - uint8_t topic_bytes[] = {0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + 0x38, 0xfd, 0x1, 0x0, 0x15, 0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0x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 0x5c, 0x9c, 0x55, 0x8c, 0x62, 0x1b, 0xf8, + 0x21, 0x73, 0x1f, 0x16, 0x0, 0xd, 0x95, 0x98, 0xc7, 0x32, 0x2d, 0x38, 0x4d, 0xe5, 0xd1, 0xb6, 0x55, 0x89, 0xf1, + 0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, 0x4a, 0x94, 0x6f, 0x47, 0xb1, + 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; + uint8_t topic_bytes[] = {0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, 0x9b, + 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, - 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, + 0x4a, 0x94, 0x6f, 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 17; - - uint8_t bytesprops0[] = {0x8c, 0x6c, 0x3d, 0x8e, 0xd4, 0xa6, 0x6b, 0xc4, 0xde, 0x99, 0xcc, 0xa6, 0xe0, 0x21, - 0x2d, 0xe, 0x74, 0x87, 0x98, 0xdd, 0xc, 0x79, 0xc0, 0x6b, 0x21, 0x1c, 0xdd, 0xc}; - uint8_t bytesprops1[] = {0xde, 0xc7, 0xc1, 0x83, 0x61, 0x40, 0xf9}; - uint8_t bytesprops2[] = {0xb8, 0x9a, 0xbb, 0x8e, 0x22, 0x3f, 0xe7, 0x93}; - uint8_t bytesprops3[] = {0x22, 0x1f, 0x9c, 0xa, 0x5e, 0x8f, 0x9, 0x48, 0x1f, - 0x85, 0xa0, 0x24, 0x67, 0xab, 0xf1, 0xad, 0x1c}; - uint8_t bytesprops4[] = {0x52, 0x64, 0x6e, 0xed, 0xe6}; - uint8_t bytesprops5[] = {0xa6}; - uint8_t bytesprops6[] = {0xa4, 0xe9, 0x3d, 0x7a, 0xce, 0xdf, 0xb1, 0x3c, 0xbb, 0xfa, 0x41, 0xe2, 0x7a, 0x2e, 0x9e, - 0x3b, 0x3a, 0x5, 0xb1, 0x4a, 0xce, 0x9, 0xb, 0xf9, 0xb5, 0x55, 0xdd, 0xf0, 0x87}; + msg.payload_len = 28; + + uint8_t bytesprops0[] = {0xbd, 0x51, 0xf2, 0x82, 0xec, 0xa, 0xf, 0x86, 0xb9, 0xab}; + uint8_t bytesprops1[] = {0x83, 0x79, 0xad, 0xe5, 0x4f, 0xa1, 0x9c, 0xee, 0x19, + 0xe9, 0xae, 0xae, 0x11, 0x1c, 0x10, 0x51, 0x9e}; + uint8_t bytesprops2[] = {0x59, 0x7a, 0x13, 0x5d, 0xc4, 0x52, 0x59, 0x8b, 0x79, 0x33, 0xc2, 0xfc, + 0x37, 0xb, 0xdd, 0x8, 0xc0, 0xe4, 0xaa, 0xfb, 0x84, 0xc8, 0xc8}; + uint8_t bytesprops3[] = {0xf3, 0x85, 0x65, 0xcf, 0x4, 0x2c, 0xc6, 0x33, 0x53, 0x97, 0xe1, 0xde, 0x1f, 0xa1, 0x66}; + uint8_t bytesprops4[] = {0xc8, 0xc3, 0x2d, 0x8c, 0x2b, 0x16, 0x23, 0x55, 0xf9, 0x99}; + uint8_t bytesprops5[] = {0x3e, 0xd3, 0xe7, 0x59, 0x9a, 0xbe, 0x58, 0x4e, 0x61, 0x29}; + uint8_t bytesprops6[] = {0x12, 0x96, 0xe6, 0x50, 0x25}; + uint8_t bytesprops7[] = {0x34, 0x55, 0x70, 0xd2, 0xc1, 0x61}; + uint8_t bytesprops8[] = {0x17, 0x8d, 0x40, 0xb0, 0x2c, 0xea, 0x42, 0xa4, 0x74, 0x5d, 0x6c, 0x1f, + 0xe8, 0x1e, 0x29, 0x5c, 0x1a, 0xaf, 0x3a, 0x2c, 0xdd, 0x4a, 0x67, 0x3e}; + uint8_t bytesprops9[] = {0x37, 0x5c, 0x9c, 0x55, 0x8c, 0x62, 0x1b, 0xf8}; + uint8_t bytesprops10[] = {0x95, 0x98, 0xc7, 0x32, 0x2d, 0x38, 0x4d, 0xe5, 0xd1, 0xb6, 0x55, 0x89, 0xf1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2254}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14313}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29233}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25080}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25894}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22192}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21746}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29495}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30240}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29471}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 31937, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\242\EM\182T\137\181\\_\NUL\137\135\&0\211", _pubPktID = 31937, _pubBody = -// "\242\196\240\145t\150mj\CANV\251\200\142o\192\150G", _pubProps = [PropRetainAvailable 122,PropSubscriptionIdentifier -// 19,PropReasonString -// "\140l=\142\212\166k\196\222\153\204\166\224!-\SOt\135\152\221\fy\192k!\FS\221\f",PropSharedSubscriptionAvailable -// 194,PropSessionExpiryInterval 2254,PropResponseInformation "\222\199\193\131a@\249",PropWillDelayInterval -// 14313,PropSessionExpiryInterval 29233,PropResponseInformation "\184\154\187\142\"?\231\147",PropResponseInformation -// "\"\US\156\n^\143\tH\US\133\160$g\171\241\173\FS",PropRequestResponseInformation 58,PropResponseInformation -// "Rdn\237\230",PropMessageExpiryInterval 25080,PropReceiveMaximum 25894,PropServerKeepAlive 22192,PropServerReference -// "\166",PropAssignedClientIdentifier -// "\164\233=z\206\223\177<\187\250A\226z.\158;:\ENQ\177J\206\t\v\249\181U\221\240\135"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\213\v\236\218d\193\162h[\237\155\196\145\159\198g\146\138\155\197\164", _pubPktID = 0, _pubBody = +// "\189\233\193\r`$@\171\DC1\230\203j\203\187J\148oG\177\155\SUB\253\232\211\t\DC4#\230", _pubProps = +// [PropAssignedClientIdentifier "\189Q\242\130\236\n\SI\134\185\171",PropReasonString +// "\131y\173\229O\161\156\238\EM\233\174\174\DC1\FS\DLEQ\158",PropCorrelationData +// "Yz\DC3]\196RY\139y3\194\252\&7\v\221\b\192\228\170\251\132\200\200",PropAuthenticationMethod +// "\243\133e\207\EOT,\198\&3S\151\225\222\US\161f",PropAssignedClientIdentifier +// "\200\195-\140+\SYN#U\249\153",PropAuthenticationMethod ">\211\231Y\154\190XNa)",PropWillDelayInterval +// 21746,PropServerReference "\DC2\150\230P%",PropAuthenticationData "4Up\210\193a",PropSubscriptionIdentifier +// 17,PropMessageExpiryInterval 29495,PropWildcardSubscriptionAvailable 235,PropMessageExpiryInterval +// 30240,PropWildcardSubscriptionAvailable 67,PropAuthenticationData +// "\ETB\141@\176,\234B\164t]l\US\232\RS)\\\SUB\175:,\221Jg>",PropRequestResponseInformation 169,PropServerReference +// "7\\\156U\140b\ESC\248",PropReceiveMaximum 29471,PropAuthenticationData "\149\152\199\&2-8M\229\209\182U\137\241"]} TEST(Publish5QCTest, Decode7) { uint8_t pkt[] = { - 0x35, 0xba, 0x1, 0x0, 0xd, 0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3, 0x7c, - 0xc1, 0x96, 0x1, 0x25, 0x7a, 0xb, 0x13, 0x1f, 0x0, 0x1c, 0x8c, 0x6c, 0x3d, 0x8e, 0xd4, 0xa6, 0x6b, 0xc4, 0xde, - 0x99, 0xcc, 0xa6, 0xe0, 0x21, 0x2d, 0xe, 0x74, 0x87, 0x98, 0xdd, 0xc, 0x79, 0xc0, 0x6b, 0x21, 0x1c, 0xdd, 0xc, - 0x2a, 0xc2, 0x11, 0x0, 0x0, 0x8, 0xce, 0x1a, 0x0, 0x7, 0xde, 0xc7, 0xc1, 0x83, 0x61, 0x40, 0xf9, 0x18, 0x0, - 0x0, 0x37, 0xe9, 0x11, 0x0, 0x0, 0x72, 0x31, 0x1a, 0x0, 0x8, 0xb8, 0x9a, 0xbb, 0x8e, 0x22, 0x3f, 0xe7, 0x93, - 0x1a, 0x0, 0x11, 0x22, 0x1f, 0x9c, 0xa, 0x5e, 0x8f, 0x9, 0x48, 0x1f, 0x85, 0xa0, 0x24, 0x67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 0xa, 0xc8, 0xc3, 0x2d, 0x8c, 0x2b, 0x16, + 0x23, 0x55, 0xf9, 0x99, 0x15, 0x0, 0xa, 0x3e, 0xd3, 0xe7, 0x59, 0x9a, 0xbe, 0x58, 0x4e, 0x61, 0x29, 0x18, 0x0, + 0x0, 0x54, 0xf2, 0x1c, 0x0, 0x5, 0x12, 0x96, 0xe6, 0x50, 0x25, 0x16, 0x0, 0x6, 0x34, 0x55, 0x70, 0xd2, 0xc1, + 0x61, 0xb, 0x11, 0x2, 0x0, 0x0, 0x73, 0x37, 0x28, 0xeb, 0x2, 0x0, 0x0, 0x76, 0x20, 0x28, 0x43, 0x16, 0x0, + 0x18, 0x17, 0x8d, 0x40, 0xb0, 0x2c, 0xea, 0x42, 0xa4, 0x74, 0x5d, 0x6c, 0x1f, 0xe8, 0x1e, 0x29, 0x5c, 0x1a, 0xaf, + 0x3a, 0x2c, 0xdd, 0x4a, 0x67, 0x3e, 0x19, 0xa9, 0x1c, 0x0, 0x8, 0x37, 0x5c, 0x9c, 0x55, 0x8c, 0x62, 0x1b, 0xf8, + 0x21, 0x73, 0x1f, 0x16, 0x0, 0xd, 0x95, 0x98, 0xc7, 0x32, 0x2d, 0x38, 0x4d, 0xe5, 0xd1, 0xb6, 0x55, 0x89, 0xf1, + 0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, 0x4a, 0x94, 0x6f, 0x47, 0xb1, + 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2547,164 +2530,185 @@ TEST(Publish5QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf2, 0x19, 0xb6, 0x54, 0x89, 0xb5, 0x5c, 0x5f, 0x0, 0x89, 0x87, 0x30, 0xd3}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf2, 0xc4, 0xf0, 0x91, 0x74, 0x96, 0x6d, 0x6a, 0x18, - 0x56, 0xfb, 0xc8, 0x8e, 0x6f, 0xc0, 0x96, 0x47}; - lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 31937); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 17); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); + uint8_t exp_topic_bytes[] = {0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, 0x9b, + 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, + 0x4a, 0x94, 0x6f, 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q", _pubPktID = 31364, _pubBody = -// "J\NAK\203\196\226\"\223\GS\200a", _pubProps = [PropResponseTopic -// "s\189\254=\155q+\137\192=\248J\fp\152\162<",PropTopicAliasMaximum 24003,PropServerKeepAlive -// 19136,PropAssignedClientIdentifier "v\160!%L>\161\232\190&]U\199'&Z\224z\249",PropResponseTopic -// "\229\161+\255\128u?\DC1",PropAuthenticationMethod -// "\ACK2\135\209F\135\136\253x\RS\141\227\165",PropSubscriptionIdentifier 9,PropAuthenticationData -// "i\EM\192\253\161f;MIF\130B\159\160\212\183Y\192\237}\136\224",PropReasonString -// "~O\167\ESC\194\253\147K\217\193\222\219",PropAuthenticationMethod "",PropAuthenticationMethod -// "\225\164\b\DLE\SI\246\ETBE\187\220\&7kW\NAKC\206\205\239\227\&9\147\173uTz\139\176",PropServerKeepAlive -// 10976,PropReasonString "\160",PropCorrelationData "L\251\158X\237\135\138\ETB\SYN\208",PropMessageExpiryInterval -// 13532,PropSubscriptionIdentifier 18,PropMaximumQoS 0,PropServerKeepAlive 1892,PropContentType -// "r",PropSubscriptionIdentifierAvailable 72,PropSharedSubscriptionAvailable 67,PropReceiveMaximum -// 5584,PropRequestResponseInformation 193,PropUserProperty -// "0o\232\US\216\196(\156w\234\"\SIz\217\137\135\vw\232\178\160y\144\224\f\NUL7\224" -// "#\DC2'\206[\156\194\217\172\194\b{0\146",PropWildcardSubscriptionAvailable 155,PropRequestProblemInformation -// 110,PropAuthenticationMethod "*\195\218\FS4L\130^!\230:\227RH\US\150\241\175\198\245\134",PropMessageExpiryInterval -// 11523]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "=\249\252\228\210\187\154\150C8*\146,\US8\152\128\152", _pubPktID = 8421, _pubBody = +// "4O\FS\186T\238#\USg\NULl\152\154\239\249\SUB2>H#\188", _pubProps = [PropReasonString +// "\191\&3j\158\NUL%\255\ACK\a\180^\EOT\b\211 &H\239\168\"\229X",PropSessionExpiryInterval 27418,PropWillDelayInterval +// 22825,PropRetainAvailable 208,PropSharedSubscriptionAvailable 195,PropSubscriptionIdentifierAvailable +// 100,PropReasonString " +// r\155\221\NUL\139!\219\DC3\153\178|\160\248\210M5!\201\155\bV\232T\144I-",PropPayloadFormatIndicator +// 140,PropUserProperty "@R\"\149\188\183\140\161l\133\175,\249\230\EM\159\141+^\172Ncp\SII'\179*" +// "\218\251\177\193\218b\EM\250\"\222)\192Dx\180\DC2]\179\245\222\246}\135\169\171\152\n\240t",PropSubscriptionIdentifier +// 0,PropAssignedClientIdentifier "|'G\210\215\153\210\203\248\210@\152Ih\NAK90\205q\161&",PropAuthenticationData +// "\RSk%'\253\241",PropAuthenticationMethod "\190",PropAuthenticationData +// "\248k\129\199\250\US\198\\f\158\190\213\144Q\245~\166\205+\\m%\179\"i\\\191",PropAuthenticationData +// "\146\ESC\DLE\152E\151\228u\214_\214EW\143-\219U(df\186\DC1\ETX\208\230O",PropUserProperty +// "\171\235{\242q\162\178E\209\193\136*\195I\151e\177L\165\164\179\b~\161\232\190&]U\199'&Z\224z\249",PropResponseTopic -// "\229\161+\255\128u?\DC1",PropAuthenticationMethod -// "\ACK2\135\209F\135\136\253x\RS\141\227\165",PropSubscriptionIdentifier 9,PropAuthenticationData -// "i\EM\192\253\161f;MIF\130B\159\160\212\183Y\192\237}\136\224",PropReasonString -// "~O\167\ESC\194\253\147K\217\193\222\219",PropAuthenticationMethod "",PropAuthenticationMethod -// "\225\164\b\DLE\SI\246\ETBE\187\220\&7kW\NAKC\206\205\239\227\&9\147\173uTz\139\176",PropServerKeepAlive -// 10976,PropReasonString "\160",PropCorrelationData "L\251\158X\237\135\138\ETB\SYN\208",PropMessageExpiryInterval -// 13532,PropSubscriptionIdentifier 18,PropMaximumQoS 0,PropServerKeepAlive 1892,PropContentType -// "r",PropSubscriptionIdentifierAvailable 72,PropSharedSubscriptionAvailable 67,PropReceiveMaximum -// 5584,PropRequestResponseInformation 193,PropUserProperty -// "0o\232\US\216\196(\156w\234\"\SIz\217\137\135\vw\232\178\160y\144\224\f\NUL7\224" -// "#\DC2'\206[\156\194\217\172\194\b{0\146",PropWildcardSubscriptionAvailable 155,PropRequestProblemInformation -// 110,PropAuthenticationMethod "*\195\218\FS4L\130^!\230:\227RH\US\150\241\175\198\245\134",PropMessageExpiryInterval -// 11523]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "=\249\252\228\210\187\154\150C8*\146,\US8\152\128\152", _pubPktID = 8421, _pubBody = +// "4O\FS\186T\238#\USg\NULl\152\154\239\249\SUB2>H#\188", _pubProps = [PropReasonString +// "\191\&3j\158\NUL%\255\ACK\a\180^\EOT\b\211 &H\239\168\"\229X",PropSessionExpiryInterval 27418,PropWillDelayInterval +// 22825,PropRetainAvailable 208,PropSharedSubscriptionAvailable 195,PropSubscriptionIdentifierAvailable +// 100,PropReasonString " +// r\155\221\NUL\139!\219\DC3\153\178|\160\248\210M5!\201\155\bV\232T\144I-",PropPayloadFormatIndicator +// 140,PropUserProperty "@R\"\149\188\183\140\161l\133\175,\249\230\EM\159\141+^\172Ncp\SII'\179*" +// "\218\251\177\193\218b\EM\250\"\222)\192Dx\180\DC2]\179\245\222\246}\135\169\171\152\n\240t",PropSubscriptionIdentifier +// 0,PropAssignedClientIdentifier "|'G\210\215\153\210\203\248\210@\152Ih\NAK90\205q\161&",PropAuthenticationData +// "\RSk%'\253\241",PropAuthenticationMethod "\190",PropAuthenticationData +// "\248k\129\199\250\US\198\\f\158\190\213\144Q\245~\166\205+\\m%\179\"i\\\191",PropAuthenticationData +// "\146\ESC\DLE\152E\151\228u\214_\214EW\143-\219U(df\186\DC1\ETX\208\230O",PropUserProperty +// "\171\235{\242q\162\178E\209\193\136*\195I\151e\177L\165\164\179\b~(topic.data), 1); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 8421); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\144\171\130\USB\155\212\163\136\212\154", _pubPktID = 8173, _pubBody = -// "\142\178\132u\236\130\153F\CANno\142\151\241\209\208\162\246\156\249\199", _pubProps = -// [PropRequestResponseInformation 100,PropAssignedClientIdentifier -// "u\235\b'?\200\200\222\209\170\244\a\163",PropAuthenticationMethod -// "\130\170\149\228\NAK\DC3(\236\185\239\206\199Ie\136X",PropPayloadFormatIndicator 109,PropReceiveMaximum -// 17095,PropContentType "\132X\255\250z3T;\180\219\144,gS\137BB\144\DC3w\170\248\173a\245\211\246",PropCorrelationData -// "\RSN\167\184\187bki4\152\197F=H\168"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\SO\191\141\159\DC1$vw", _pubPktID = +// 301, _pubBody = "`\195\&7\ESC_\216\219\237?~,\244", _pubProps = [PropRequestProblemInformation +// 64,PropAuthenticationMethod "\195(Y\170_\225oG\251\178\174",PropSubscriptionIdentifier 23,PropAuthenticationMethod +// "&+E\184\152\135P",PropRequestResponseInformation 211,PropCorrelationData +// "\209\236W\234V0\EM\GS`\168[\NUL",PropSessionExpiryInterval 22216,PropPayloadFormatIndicator 110,PropTopicAlias +// 1570,PropContentType "\190J]\222\198tA\254Y\135\152D\175\DEL\214\217\135h\225",PropMessageExpiryInterval +// 13095,PropContentType "\t{\ACK\234?/\240[\ESC\141\&5b\181\238t\170u\154\176",PropContentType +// "\ESC\USR\241\&4\134\&7\167\RSWIJMl4)S\204\SO_\\\152\173\192",PropRequestProblemInformation 132,PropResponseTopic +// "f\ETB\177\135\237\ETX\NAKb6\166\162\167,Mke\165",PropResponseInformation +// "\f\237-'\145\&7#\145\177\148X",PropServerReference +// "\178,m}\251I\185\250\EM;}d>T(p\253\226\NUL80\141B\r6",PropReceiveMaximum 30594,PropTopicAlias +// 26876,PropWildcardSubscriptionAvailable 211,PropRequestResponseInformation 173,PropMaximumPacketSize +// 2974,PropReceiveMaximum 6700,PropRequestResponseInformation 193,PropTopicAlias 29250,PropAuthenticationData +// "]\240\151\162\&3\175\154\202\221\RS>8\SOH\247c \209\240j\162\191",PropServerReference +// "PQ$\158l\254\DC1",PropMessageExpiryInterval 31929,PropSessionExpiryInterval 31705,PropAssignedClientIdentifier +// "\153\139\247\160\179\134uyzk\243i_H7\r\255\STXg\189(\v"]} TEST(Publish5QCTest, Encode9) { - uint8_t pkt[] = {0x33, 0x7f, 0x0, 0xb, 0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a, 0x1f, 0xed, - 0x5a, 0x19, 0x64, 0x12, 0x0, 0xd, 0x75, 0xeb, 0x8, 0x27, 0x3f, 0xc8, 0xc8, 0xde, 0xd1, 0xaa, 0xf4, - 0x7, 0xa3, 0x15, 0x0, 0x10, 0x82, 0xaa, 0x95, 0xe4, 0x15, 0x13, 0x28, 0xec, 0xb9, 0xef, 0xce, 0xc7, - 0x49, 0x65, 0x88, 0x58, 0x1, 0x6d, 0x21, 0x42, 0xc7, 0x3, 0x0, 0x1b, 0x84, 0x58, 0xff, 0xfa, 0x7a, - 0x33, 0x54, 0x3b, 0xb4, 0xdb, 0x90, 0x2c, 0x67, 0x53, 0x89, 0x42, 0x42, 0x90, 0x13, 0x77, 0xaa, 0xf8, - 0xad, 0x61, 0xf5, 0xd3, 0xf6, 0x9, 0x0, 0xf, 0x1e, 0x4e, 0xa7, 0xb8, 0xbb, 0x62, 0x6b, 0x69, 0x34, - 0x98, 0xc5, 0x46, 0x3d, 0x48, 0xa8, 0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, - 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; - uint8_t topic_bytes[] = {0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x3b, 0xb9, 0x2, 0x0, 0x8, 0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77, 0x1, 0x2d, 0x9f, 0x2, 0x17, 0x40, + 0x15, 0x0, 0xb, 0xc3, 0x28, 0x59, 0xaa, 0x5f, 0xe1, 0x6f, 0x47, 0xfb, 0xb2, 0xae, 0xb, 0x17, 0x15, 0x0, 0x7, + 0x26, 0x2b, 0x45, 0xb8, 0x98, 0x87, 0x50, 0x19, 0xd3, 0x9, 0x0, 0xc, 0xd1, 0xec, 0x57, 0xea, 0x56, 0x30, 0x19, + 0x1d, 0x60, 0xa8, 0x5b, 0x0, 0x11, 0x0, 0x0, 0x56, 0xc8, 0x1, 0x6e, 0x23, 0x6, 0x22, 0x3, 0x0, 0x13, 0xbe, + 0x4a, 0x5d, 0xde, 0xc6, 0x74, 0x41, 0xfe, 0x59, 0x87, 0x98, 0x44, 0xaf, 0x7f, 0xd6, 0xd9, 0x87, 0x68, 0xe1, 0x2, + 0x0, 0x0, 0x33, 0x27, 0x3, 0x0, 0x13, 0x9, 0x7b, 0x6, 0xea, 0x3f, 0x2f, 0xf0, 0x5b, 0x1b, 0x8d, 0x35, 0x62, + 0xb5, 0xee, 0x74, 0xaa, 0x75, 0x9a, 0xb0, 0x3, 0x0, 0x18, 0x1b, 0x1f, 0x52, 0xf1, 0x34, 0x86, 0x37, 0xa7, 0x1e, + 0x57, 0x49, 0x4a, 0x4d, 0x6c, 0x34, 0x29, 0x53, 0xcc, 0xe, 0x5f, 0x5c, 0x98, 0xad, 0xc0, 0x17, 0x84, 0x8, 0x0, + 0x11, 0x66, 0x17, 0xb1, 0x87, 0xed, 0x3, 0x15, 0x62, 0x36, 0xa6, 0xa2, 0xa7, 0x2c, 0x4d, 0x6b, 0x65, 0xa5, 0x1a, + 0x0, 0xb, 0xc, 0xed, 0x2d, 0x27, 0x91, 0x37, 0x23, 0x91, 0xb1, 0x94, 0x58, 0x1c, 0x0, 0x19, 0xb2, 0x2c, 0x6d, + 0x7d, 0xfb, 0x49, 0xb9, 0xfa, 0x19, 0x3b, 0x7d, 0x64, 0x3e, 0x54, 0x28, 0x70, 0xfd, 0xe2, 0x0, 0x38, 0x30, 0x8d, + 0x42, 0xd, 0x36, 0x21, 0x77, 0x82, 0x23, 0x68, 0xfc, 0x28, 0xd3, 0x19, 0xad, 0x27, 0x0, 0x0, 0xb, 0x9e, 0x21, + 0x1a, 0x2c, 0x19, 0xc1, 0x23, 0x72, 0x42, 0x16, 0x0, 0x15, 0x5d, 0xf0, 0x97, 0xa2, 0x33, 0xaf, 0x9a, 0xca, 0xdd, + 0x1e, 0x3e, 0x38, 0x1, 0xf7, 0x63, 0x20, 0xd1, 0xf0, 0x6a, 0xa2, 0xbf, 0x1c, 0x0, 0x7, 0x50, 0x51, 0x24, 0x9e, + 0x6c, 0xfe, 0x11, 0x2, 0x0, 0x0, 0x7c, 0xb9, 0x11, 0x0, 0x0, 0x7b, 0xd9, 0x12, 0x0, 0x16, 0x99, 0x8b, 0xf7, + 0xa0, 0xb3, 0x86, 0x75, 0x79, 0x7a, 0x6b, 0xf3, 0x69, 0x5f, 0x48, 0x37, 0xd, 0xff, 0x2, 0x67, 0xbd, 0x28, 0xb, + 0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; + uint8_t topic_bytes[] = {0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, - 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; + uint8_t msg_bytes[] = {0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 12; - uint8_t bytesprops0[] = {0x75, 0xeb, 0x8, 0x27, 0x3f, 0xc8, 0xc8, 0xde, 0xd1, 0xaa, 0xf4, 0x7, 0xa3}; - uint8_t bytesprops1[] = {0x82, 0xaa, 0x95, 0xe4, 0x15, 0x13, 0x28, 0xec, - 0xb9, 0xef, 0xce, 0xc7, 0x49, 0x65, 0x88, 0x58}; - uint8_t bytesprops2[] = {0x84, 0x58, 0xff, 0xfa, 0x7a, 0x33, 0x54, 0x3b, 0xb4, 0xdb, 0x90, 0x2c, 0x67, 0x53, - 0x89, 0x42, 0x42, 0x90, 0x13, 0x77, 0xaa, 0xf8, 0xad, 0x61, 0xf5, 0xd3, 0xf6}; - uint8_t bytesprops3[] = {0x1e, 0x4e, 0xa7, 0xb8, 0xbb, 0x62, 0x6b, 0x69, 0x34, 0x98, 0xc5, 0x46, 0x3d, 0x48, 0xa8}; + uint8_t bytesprops0[] = {0xc3, 0x28, 0x59, 0xaa, 0x5f, 0xe1, 0x6f, 0x47, 0xfb, 0xb2, 0xae}; + uint8_t bytesprops1[] = {0x26, 0x2b, 0x45, 0xb8, 0x98, 0x87, 0x50}; + uint8_t bytesprops2[] = {0xd1, 0xec, 0x57, 0xea, 0x56, 0x30, 0x19, 0x1d, 0x60, 0xa8, 0x5b, 0x0}; + uint8_t bytesprops3[] = {0xbe, 0x4a, 0x5d, 0xde, 0xc6, 0x74, 0x41, 0xfe, 0x59, 0x87, + 0x98, 0x44, 0xaf, 0x7f, 0xd6, 0xd9, 0x87, 0x68, 0xe1}; + uint8_t bytesprops4[] = {0x9, 0x7b, 0x6, 0xea, 0x3f, 0x2f, 0xf0, 0x5b, 0x1b, 0x8d, + 0x35, 0x62, 0xb5, 0xee, 0x74, 0xaa, 0x75, 0x9a, 0xb0}; + uint8_t bytesprops5[] = {0x1b, 0x1f, 0x52, 0xf1, 0x34, 0x86, 0x37, 0xa7, 0x1e, 0x57, 0x49, 0x4a, + 0x4d, 0x6c, 0x34, 0x29, 0x53, 0xcc, 0xe, 0x5f, 0x5c, 0x98, 0xad, 0xc0}; + uint8_t bytesprops6[] = {0x66, 0x17, 0xb1, 0x87, 0xed, 0x3, 0x15, 0x62, 0x36, + 0xa6, 0xa2, 0xa7, 0x2c, 0x4d, 0x6b, 0x65, 0xa5}; + uint8_t bytesprops7[] = {0xc, 0xed, 0x2d, 0x27, 0x91, 0x37, 0x23, 0x91, 0xb1, 0x94, 0x58}; + uint8_t bytesprops8[] = {0xb2, 0x2c, 0x6d, 0x7d, 0xfb, 0x49, 0xb9, 0xfa, 0x19, 0x3b, 0x7d, 0x64, 0x3e, + 0x54, 0x28, 0x70, 0xfd, 0xe2, 0x0, 0x38, 0x30, 0x8d, 0x42, 0xd, 0x36}; + uint8_t bytesprops9[] = {0x5d, 0xf0, 0x97, 0xa2, 0x33, 0xaf, 0x9a, 0xca, 0xdd, 0x1e, 0x3e, + 0x38, 0x1, 0xf7, 0x63, 0x20, 0xd1, 0xf0, 0x6a, 0xa2, 0xbf}; + uint8_t bytesprops10[] = {0x50, 0x51, 0x24, 0x9e, 0x6c, 0xfe, 0x11}; + uint8_t bytesprops11[] = {0x99, 0x8b, 0xf7, 0xa0, 0xb3, 0x86, 0x75, 0x79, 0x7a, 0x6b, 0xf3, + 0x69, 0x5f, 0x48, 0x37, 0xd, 0xff, 0x2, 0x67, 0xbd, 0x28, 0xb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17095}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22216}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1570}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13095}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30594}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26876}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2974}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6700}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29250}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31929}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31705}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 8173, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 301, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\144\171\130\USB\155\212\163\136\212\154", _pubPktID = 8173, _pubBody = -// "\142\178\132u\236\130\153F\CANno\142\151\241\209\208\162\246\156\249\199", _pubProps = -// [PropRequestResponseInformation 100,PropAssignedClientIdentifier -// "u\235\b'?\200\200\222\209\170\244\a\163",PropAuthenticationMethod -// "\130\170\149\228\NAK\DC3(\236\185\239\206\199Ie\136X",PropPayloadFormatIndicator 109,PropReceiveMaximum -// 17095,PropContentType "\132X\255\250z3T;\180\219\144,gS\137BB\144\DC3w\170\248\173a\245\211\246",PropCorrelationData -// "\RSN\167\184\187bki4\152\197F=H\168"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\SO\191\141\159\DC1$vw", _pubPktID = +// 301, _pubBody = "`\195\&7\ESC_\216\219\237?~,\244", _pubProps = [PropRequestProblemInformation +// 64,PropAuthenticationMethod "\195(Y\170_\225oG\251\178\174",PropSubscriptionIdentifier 23,PropAuthenticationMethod +// "&+E\184\152\135P",PropRequestResponseInformation 211,PropCorrelationData +// "\209\236W\234V0\EM\GS`\168[\NUL",PropSessionExpiryInterval 22216,PropPayloadFormatIndicator 110,PropTopicAlias +// 1570,PropContentType "\190J]\222\198tA\254Y\135\152D\175\DEL\214\217\135h\225",PropMessageExpiryInterval +// 13095,PropContentType "\t{\ACK\234?/\240[\ESC\141\&5b\181\238t\170u\154\176",PropContentType +// "\ESC\USR\241\&4\134\&7\167\RSWIJMl4)S\204\SO_\\\152\173\192",PropRequestProblemInformation 132,PropResponseTopic +// "f\ETB\177\135\237\ETX\NAKb6\166\162\167,Mke\165",PropResponseInformation +// "\f\237-'\145\&7#\145\177\148X",PropServerReference +// "\178,m}\251I\185\250\EM;}d>T(p\253\226\NUL80\141B\r6",PropReceiveMaximum 30594,PropTopicAlias +// 26876,PropWildcardSubscriptionAvailable 211,PropRequestResponseInformation 173,PropMaximumPacketSize +// 2974,PropReceiveMaximum 6700,PropRequestResponseInformation 193,PropTopicAlias 29250,PropAuthenticationData +// "]\240\151\162\&3\175\154\202\221\RS>8\SOH\247c \209\240j\162\191",PropServerReference +// "PQ$\158l\254\DC1",PropMessageExpiryInterval 31929,PropSessionExpiryInterval 31705,PropAssignedClientIdentifier +// "\153\139\247\160\179\134uyzk\243i_H7\r\255\STXg\189(\v"]} TEST(Publish5QCTest, Decode9) { - uint8_t pkt[] = {0x33, 0x7f, 0x0, 0xb, 0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a, 0x1f, 0xed, - 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, 0x7, 0x50, 0x51, 0x24, 0x9e, + 0x6c, 0xfe, 0x11, 0x2, 0x0, 0x0, 0x7c, 0xb9, 0x11, 0x0, 0x0, 0x7b, 0xd9, 0x12, 0x0, 0x16, 0x99, 0x8b, 0xf7, + 0xa0, 0xb3, 0x86, 0x75, 0x79, 0x7a, 0x6b, 0xf3, 0x69, 0x5f, 0x48, 0x37, 0xd, 0xff, 0x2, 0x67, 0xbd, 0x28, 0xb, + 0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2807,56 +2884,94 @@ TEST(Publish5QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x90, 0xab, 0x82, 0x1f, 0x42, 0x9b, 0xd4, 0xa3, 0x88, 0xd4, 0x9a}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8e, 0xb2, 0x84, 0x75, 0xec, 0x82, 0x99, 0x46, 0x18, 0x6e, 0x6f, - 0x8e, 0x97, 0xf1, 0xd1, 0xd0, 0xa2, 0xf6, 0x9c, 0xf9, 0xc7}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 8173); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 301); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "@\179\160", _pubPktID = 5779, -// _pubBody = "+>\SI\ESC\130^\213\173\147\167D\FS\254\153\218c\237\133\220\156Zk\211\207", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\227=\STX\236\214\&2\250\EM@M^\ENQ\161\aE8", _pubPktID = 19635, _pubBody = "\EOT\EM", _pubProps = [PropTopicAlias +// 28762,PropReceiveMaximum 4549,PropCorrelationData "\237o*OO%\201P\232^u[\158",PropAuthenticationData +// "\128\189\154\SO\180\SOH]sH\253s\165w\148\219\215\251\130f\NAK\131\152\208;",PropCorrelationData +// "\214\NAK\214MlRr\138\242\DC4\167e]`X;\ENQ\188A^\218+\DC4>6%\155\255\250O",PropReceiveMaximum +// 6189,PropSubscriptionIdentifier 13,PropMaximumPacketSize 31985,PropServerReference +// "\NUL\229\SOH\tJu\233\131NV\203\168\239\220\203\SOH\166E5\228\141\212\173\250X\DLE>?"]} TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = {0x34, 0x20, 0x0, 0x3, 0x40, 0xb3, 0xa0, 0x16, 0x93, 0x0, 0x2b, 0x3e, - 0xf, 0x1b, 0x82, 0x5e, 0xd5, 0xad, 0x93, 0xa7, 0x44, 0x1c, 0xfe, 0x99, - 0xda, 0x63, 0xed, 0x85, 0xdc, 0x9c, 0x5a, 0x6b, 0xd3, 0xcf}; - uint8_t topic_bytes[] = {0x40, 0xb3, 0xa0}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x92, 0x1, 0x0, 0x10, 0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, 0x40, 0x4d, 0x5e, 0x5, + 0xa1, 0x7, 0x45, 0x38, 0x4c, 0xb3, 0x7b, 0x23, 0x70, 0x5a, 0x21, 0x11, 0xc5, 0x9, 0x0, 0xd, 0xed, + 0x6f, 0x2a, 0x4f, 0x4f, 0x25, 0xc9, 0x50, 0xe8, 0x5e, 0x75, 0x5b, 0x9e, 0x16, 0x0, 0x18, 0x80, 0xbd, + 0x9a, 0xe, 0xb4, 0x1, 0x5d, 0x73, 0x48, 0xfd, 0x73, 0xa5, 0x77, 0x94, 0xdb, 0xd7, 0xfb, 0x82, 0x66, + 0x15, 0x83, 0x98, 0xd0, 0x3b, 0x9, 0x0, 0x1e, 0xd6, 0x15, 0xd6, 0x4d, 0x6c, 0x52, 0x72, 0x8a, 0xf2, + 0x14, 0xa7, 0x65, 0x5d, 0x60, 0x58, 0x3b, 0x5, 0xbc, 0x41, 0x5e, 0xda, 0x2b, 0x14, 0x3e, 0x36, 0x25, + 0x9b, 0xff, 0xfa, 0x4f, 0x21, 0x18, 0x2d, 0xb, 0xd, 0x27, 0x0, 0x0, 0x7c, 0xf1, 0x1c, 0x0, 0x1c, + 0x0, 0xe5, 0x1, 0x9, 0x4a, 0x75, 0xe9, 0x83, 0x4e, 0x56, 0xcb, 0xa8, 0xef, 0xdc, 0xcb, 0x1, 0xa6, + 0x45, 0x35, 0xe4, 0x8d, 0xd4, 0xad, 0xfa, 0x58, 0x10, 0x3e, 0x3f, 0x4, 0x19}; + uint8_t topic_bytes[] = {0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38}; + lwmqtt_string_t topic = {16, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x2b, 0x3e, 0xf, 0x1b, 0x82, 0x5e, 0xd5, 0xad, 0x93, 0xa7, 0x44, 0x1c, - 0xfe, 0x99, 0xda, 0x63, 0xed, 0x85, 0xdc, 0x9c, 0x5a, 0x6b, 0xd3, 0xcf}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x4, 0x19}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 2; - lwmqtt_property_t propslist[] = {}; + uint8_t bytesprops0[] = {0xed, 0x6f, 0x2a, 0x4f, 0x4f, 0x25, 0xc9, 0x50, 0xe8, 0x5e, 0x75, 0x5b, 0x9e}; + uint8_t bytesprops1[] = {0x80, 0xbd, 0x9a, 0xe, 0xb4, 0x1, 0x5d, 0x73, 0x48, 0xfd, 0x73, 0xa5, + 0x77, 0x94, 0xdb, 0xd7, 0xfb, 0x82, 0x66, 0x15, 0x83, 0x98, 0xd0, 0x3b}; + uint8_t bytesprops2[] = {0xd6, 0x15, 0xd6, 0x4d, 0x6c, 0x52, 0x72, 0x8a, 0xf2, 0x14, 0xa7, 0x65, 0x5d, 0x60, 0x58, + 0x3b, 0x5, 0xbc, 0x41, 0x5e, 0xda, 0x2b, 0x14, 0x3e, 0x36, 0x25, 0x9b, 0xff, 0xfa, 0x4f}; + uint8_t bytesprops3[] = {0x0, 0xe5, 0x1, 0x9, 0x4a, 0x75, 0xe9, 0x83, 0x4e, 0x56, 0xcb, 0xa8, 0xef, 0xdc, + 0xcb, 0x1, 0xa6, 0x45, 0x35, 0xe4, 0x8d, 0xd4, 0xad, 0xfa, 0x58, 0x10, 0x3e, 0x3f}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28762}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4549}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6189}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31985}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops3}}}, + }; + + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 5779, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 19635, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "@\179\160", _pubPktID = 5779, -// _pubBody = "+>\SI\ESC\130^\213\173\147\167D\FS\254\153\218c\237\133\220\156Zk\211\207", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\227=\STX\236\214\&2\250\EM@M^\ENQ\161\aE8", _pubPktID = 19635, _pubBody = "\EOT\EM", _pubProps = [PropTopicAlias +// 28762,PropReceiveMaximum 4549,PropCorrelationData "\237o*OO%\201P\232^u[\158",PropAuthenticationData +// "\128\189\154\SO\180\SOH]sH\253s\165w\148\219\215\251\130f\NAK\131\152\208;",PropCorrelationData +// "\214\NAK\214MlRr\138\242\DC4\167e]`X;\ENQ\188A^\218+\DC4>6%\155\255\250O",PropReceiveMaximum +// 6189,PropSubscriptionIdentifier 13,PropMaximumPacketSize 31985,PropServerReference +// "\NUL\229\SOH\tJu\233\131NV\203\168\239\220\203\SOH\166E5\228\141\212\173\250X\DLE>?"]} TEST(Publish5QCTest, Decode10) { - uint8_t pkt[] = {0x34, 0x20, 0x0, 0x3, 0x40, 0xb3, 0xa0, 0x16, 0x93, 0x0, 0x2b, 0x3e, - 0xf, 0x1b, 0x82, 0x5e, 0xd5, 0xad, 0x93, 0xa7, 0x44, 0x1c, 0xfe, 0x99, - 0xda, 0x63, 0xed, 0x85, 0xdc, 0x9c, 0x5a, 0x6b, 0xd3, 0xcf}; + uint8_t pkt[] = {0x3b, 0x92, 0x1, 0x0, 0x10, 0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, 0x40, 0x4d, 0x5e, 0x5, + 0xa1, 0x7, 0x45, 0x38, 0x4c, 0xb3, 0x7b, 0x23, 0x70, 0x5a, 0x21, 0x11, 0xc5, 0x9, 0x0, 0xd, 0xed, + 0x6f, 0x2a, 0x4f, 0x4f, 0x25, 0xc9, 0x50, 0xe8, 0x5e, 0x75, 0x5b, 0x9e, 0x16, 0x0, 0x18, 0x80, 0xbd, + 0x9a, 0xe, 0xb4, 0x1, 0x5d, 0x73, 0x48, 0xfd, 0x73, 0xa5, 0x77, 0x94, 0xdb, 0xd7, 0xfb, 0x82, 0x66, + 0x15, 0x83, 0x98, 0xd0, 0x3b, 0x9, 0x0, 0x1e, 0xd6, 0x15, 0xd6, 0x4d, 0x6c, 0x52, 0x72, 0x8a, 0xf2, + 0x14, 0xa7, 0x65, 0x5d, 0x60, 0x58, 0x3b, 0x5, 0xbc, 0x41, 0x5e, 0xda, 0x2b, 0x14, 0x3e, 0x36, 0x25, + 0x9b, 0xff, 0xfa, 0x4f, 0x21, 0x18, 0x2d, 0xb, 0xd, 0x27, 0x0, 0x0, 0x7c, 0xf1, 0x1c, 0x0, 0x1c, + 0x0, 0xe5, 0x1, 0x9, 0x4a, 0x75, 0xe9, 0x83, 0x4e, 0x56, 0xcb, 0xa8, 0xef, 0xdc, 0xcb, 0x1, 0xa6, + 0x45, 0x35, 0xe4, 0x8d, 0xd4, 0xad, 0xfa, 0x58, 0x10, 0x3e, 0x3f, 0x4, 0x19}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2865,95 +2980,123 @@ TEST(Publish5QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x40, 0xb3, 0xa0}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2b, 0x3e, 0xf, 0x1b, 0x82, 0x5e, 0xd5, 0xad, 0x93, 0xa7, 0x44, 0x1c, - 0xfe, 0x99, 0xda, 0x63, 0xed, 0x85, 0xdc, 0x9c, 0x5a, 0x6b, 0xd3, 0xcf}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 5779); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + uint8_t exp_topic_bytes[] = {0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, + 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38}; + lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4, 0x19}; + lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 19635); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); + EXPECT_EQ(msg.payload_len, 2); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "P\177\NAK.\190\171\224\139\&2\248]=\179n\DC4k\146\152\175\210\205`3|\135\&8i\209", _pubPktID = 19270, _pubBody = -// "\134\ENQKL\159E.\211+^\240\187\146\NAK7dRg\129.m\133\DLE\152C\ESCJ\160\203", _pubProps = [PropAuthenticationData -// "\249\128\218!m\186\b\174\&6\228q\130iQ\252O2\t\134\f\159\211n\150K\164\213\196?\149",PropResponseInformation -// "\244\162%",PropAuthenticationData "\156\195]t",PropContentType -// "7o\211\198\220\230\ETB",PropSubscriptionIdentifierAvailable 49,PropContentType -// "\161\192\204\175\207\205\182\229\236.\247C\EMZf/\223\243\205",PropWillDelayInterval 20097]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\207FX\fp\139\210\201Q\185\161i$\222\214\221\238\n.\134\157L7\178\&1", _pubPktID = 10816, _pubBody = +// "b[\173.*\158(\194-\180ZS\221\236\188\168\182\172p\192\216\246\196\176\200\248\&1\232a", _pubProps = +// [PropReceiveMaximum 25251,PropResponseInformation +// "X\221\143\223\163\136V\DC1\175\145\155\US\\\DC3\ESC\159l\DC2/\a\143v\163\227\n\235",PropMaximumQoS +// 199,PropAssignedClientIdentifier "\ETBk\211",PropMessageExpiryInterval 1041,PropTopicAliasMaximum +// 2064,PropMessageExpiryInterval 14828,PropReasonString +// "x\DLE\ESC\244\138\235\246\137\235:\255\177",PropAuthenticationData +// "\162\233\a\215\148\245\255\148NIrB",PropUserProperty "\225}q\142\171-Z^Bt}\179r\241\SO\ETX2e\ACK0\249" +// "L\160/\NULi\177E%o\191x>",PropMaximumQoS 99,PropSessionExpiryInterval 8860,PropWildcardSubscriptionAvailable +// 211,PropReasonString "\189\253\207\129\167\209VT\SOH}[\t\220\CANAB\146\168",PropAuthenticationMethod ""]} TEST(Publish5QCTest, Encode11) { - uint8_t pkt[] = {0x32, 0x93, 0x1, 0x0, 0x1c, 0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, - 0xb3, 0x6e, 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1, 0x4b, - 0x46, 0x55, 0x16, 0x0, 0x1e, 0xf9, 0x80, 0xda, 0x21, 0x6d, 0xba, 0x8, 0xae, 0x36, 0xe4, 0x71, 0x82, - 0x69, 0x51, 0xfc, 0x4f, 0x32, 0x9, 0x86, 0xc, 0x9f, 0xd3, 0x6e, 0x96, 0x4b, 0xa4, 0xd5, 0xc4, 0x3f, - 0x95, 0x1a, 0x0, 0x3, 0xf4, 0xa2, 0x25, 0x16, 0x0, 0x4, 0x9c, 0xc3, 0x5d, 0x74, 0x3, 0x0, 0x7, - 0x37, 0x6f, 0xd3, 0xc6, 0xdc, 0xe6, 0x17, 0x29, 0x31, 0x3, 0x0, 0x13, 0xa1, 0xc0, 0xcc, 0xaf, 0xcf, - 0xcd, 0xb6, 0xe5, 0xec, 0x2e, 0xf7, 0x43, 0x19, 0x5a, 0x66, 0x2f, 0xdf, 0xf3, 0xcd, 0x18, 0x0, 0x0, - 0x4e, 0x81, 0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, - 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; - uint8_t topic_bytes[] = {0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, 0xb3, 0x6e, - 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0xd6, 0x1, 0x0, 0x19, 0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, 0x69, + 0x24, 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31, 0x2a, 0x40, 0x9a, 0x1, + 0x21, 0x62, 0xa3, 0x1a, 0x0, 0x1a, 0x58, 0xdd, 0x8f, 0xdf, 0xa3, 0x88, 0x56, 0x11, 0xaf, 0x91, 0x9b, + 0x1f, 0x5c, 0x13, 0x1b, 0x9f, 0x6c, 0x12, 0x2f, 0x7, 0x8f, 0x76, 0xa3, 0xe3, 0xa, 0xeb, 0x24, 0xc7, + 0x12, 0x0, 0x3, 0x17, 0x6b, 0xd3, 0x2, 0x0, 0x0, 0x4, 0x11, 0x22, 0x8, 0x10, 0x2, 0x0, 0x0, + 0x39, 0xec, 0x1f, 0x0, 0xc, 0x78, 0x10, 0x1b, 0xf4, 0x8a, 0xeb, 0xf6, 0x89, 0xeb, 0x3a, 0xff, 0xb1, + 0x16, 0x0, 0xc, 0xa2, 0xe9, 0x7, 0xd7, 0x94, 0xf5, 0xff, 0x94, 0x4e, 0x49, 0x72, 0x42, 0x26, 0x0, + 0x15, 0xe1, 0x7d, 0x71, 0x8e, 0xab, 0x2d, 0x5a, 0x5e, 0x42, 0x74, 0x7d, 0xb3, 0x72, 0xf1, 0xe, 0x3, + 0x32, 0x65, 0x6, 0x30, 0xf9, 0x0, 0xc, 0x4c, 0xa0, 0x2f, 0x0, 0x69, 0xb1, 0x45, 0x25, 0x6f, 0xbf, + 0x78, 0x3e, 0x24, 0x63, 0x11, 0x0, 0x0, 0x22, 0x9c, 0x28, 0xd3, 0x1f, 0x0, 0x12, 0xbd, 0xfd, 0xcf, + 0x81, 0xa7, 0xd1, 0x56, 0x54, 0x1, 0x7d, 0x5b, 0x9, 0xdc, 0x18, 0x41, 0x42, 0x92, 0xa8, 0x15, 0x0, + 0x0, 0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, 0xbc, 0xa8, + 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; + uint8_t topic_bytes[] = {0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, 0x69, 0x24, + 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, - 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; + uint8_t msg_bytes[] = {0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, 0xbc, + 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 29; - uint8_t bytesprops0[] = {0xf9, 0x80, 0xda, 0x21, 0x6d, 0xba, 0x8, 0xae, 0x36, 0xe4, 0x71, 0x82, 0x69, 0x51, 0xfc, - 0x4f, 0x32, 0x9, 0x86, 0xc, 0x9f, 0xd3, 0x6e, 0x96, 0x4b, 0xa4, 0xd5, 0xc4, 0x3f, 0x95}; - uint8_t bytesprops1[] = {0xf4, 0xa2, 0x25}; - uint8_t bytesprops2[] = {0x9c, 0xc3, 0x5d, 0x74}; - uint8_t bytesprops3[] = {0x37, 0x6f, 0xd3, 0xc6, 0xdc, 0xe6, 0x17}; - uint8_t bytesprops4[] = {0xa1, 0xc0, 0xcc, 0xaf, 0xcf, 0xcd, 0xb6, 0xe5, 0xec, 0x2e, - 0xf7, 0x43, 0x19, 0x5a, 0x66, 0x2f, 0xdf, 0xf3, 0xcd}; + uint8_t bytesprops0[] = {0x58, 0xdd, 0x8f, 0xdf, 0xa3, 0x88, 0x56, 0x11, 0xaf, 0x91, 0x9b, 0x1f, 0x5c, + 0x13, 0x1b, 0x9f, 0x6c, 0x12, 0x2f, 0x7, 0x8f, 0x76, 0xa3, 0xe3, 0xa, 0xeb}; + uint8_t bytesprops1[] = {0x17, 0x6b, 0xd3}; + uint8_t bytesprops2[] = {0x78, 0x10, 0x1b, 0xf4, 0x8a, 0xeb, 0xf6, 0x89, 0xeb, 0x3a, 0xff, 0xb1}; + uint8_t bytesprops3[] = {0xa2, 0xe9, 0x7, 0xd7, 0x94, 0xf5, 0xff, 0x94, 0x4e, 0x49, 0x72, 0x42}; + uint8_t bytesprops5[] = {0x4c, 0xa0, 0x2f, 0x0, 0x69, 0xb1, 0x45, 0x25, 0x6f, 0xbf, 0x78, 0x3e}; + uint8_t bytesprops4[] = {0xe1, 0x7d, 0x71, 0x8e, 0xab, 0x2d, 0x5a, 0x5e, 0x42, 0x74, 0x7d, + 0xb3, 0x72, 0xf1, 0xe, 0x3, 0x32, 0x65, 0x6, 0x30, 0xf9}; + uint8_t bytesprops6[] = {0xbd, 0xfd, 0xcf, 0x81, 0xa7, 0xd1, 0x56, 0x54, 0x1, + 0x7d, 0x5b, 0x9, 0xdc, 0x18, 0x41, 0x42, 0x92, 0xa8}; + uint8_t bytesprops7[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20097}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25251}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1041}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2064}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14828}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops4}, .v = {12, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8860}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 19270, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10816, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "P\177\NAK.\190\171\224\139\&2\248]=\179n\DC4k\146\152\175\210\205`3|\135\&8i\209", _pubPktID = 19270, _pubBody = -// "\134\ENQKL\159E.\211+^\240\187\146\NAK7dRg\129.m\133\DLE\152C\ESCJ\160\203", _pubProps = [PropAuthenticationData -// "\249\128\218!m\186\b\174\&6\228q\130iQ\252O2\t\134\f\159\211n\150K\164\213\196?\149",PropResponseInformation -// "\244\162%",PropAuthenticationData "\156\195]t",PropContentType -// "7o\211\198\220\230\ETB",PropSubscriptionIdentifierAvailable 49,PropContentType -// "\161\192\204\175\207\205\182\229\236.\247C\EMZf/\223\243\205",PropWillDelayInterval 20097]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\207FX\fp\139\210\201Q\185\161i$\222\214\221\238\n.\134\157L7\178\&1", _pubPktID = 10816, _pubBody = +// "b[\173.*\158(\194-\180ZS\221\236\188\168\182\172p\192\216\246\196\176\200\248\&1\232a", _pubProps = +// [PropReceiveMaximum 25251,PropResponseInformation +// "X\221\143\223\163\136V\DC1\175\145\155\US\\\DC3\ESC\159l\DC2/\a\143v\163\227\n\235",PropMaximumQoS +// 199,PropAssignedClientIdentifier "\ETBk\211",PropMessageExpiryInterval 1041,PropTopicAliasMaximum +// 2064,PropMessageExpiryInterval 14828,PropReasonString +// "x\DLE\ESC\244\138\235\246\137\235:\255\177",PropAuthenticationData +// "\162\233\a\215\148\245\255\148NIrB",PropUserProperty "\225}q\142\171-Z^Bt}\179r\241\SO\ETX2e\ACK0\249" +// "L\160/\NULi\177E%o\191x>",PropMaximumQoS 99,PropSessionExpiryInterval 8860,PropWildcardSubscriptionAvailable +// 211,PropReasonString "\189\253\207\129\167\209VT\SOH}[\t\220\CANAB\146\168",PropAuthenticationMethod ""]} TEST(Publish5QCTest, Decode11) { - uint8_t pkt[] = {0x32, 0x93, 0x1, 0x0, 0x1c, 0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, - 0xb3, 0x6e, 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1, 0x4b, - 0x46, 0x55, 0x16, 0x0, 0x1e, 0xf9, 0x80, 0xda, 0x21, 0x6d, 0xba, 0x8, 0xae, 0x36, 0xe4, 0x71, 0x82, - 0x69, 0x51, 0xfc, 0x4f, 0x32, 0x9, 0x86, 0xc, 0x9f, 0xd3, 0x6e, 0x96, 0x4b, 0xa4, 0xd5, 0xc4, 0x3f, - 0x95, 0x1a, 0x0, 0x3, 0xf4, 0xa2, 0x25, 0x16, 0x0, 0x4, 0x9c, 0xc3, 0x5d, 0x74, 0x3, 0x0, 0x7, - 0x37, 0x6f, 0xd3, 0xc6, 0xdc, 0xe6, 0x17, 0x29, 0x31, 0x3, 0x0, 0x13, 0xa1, 0xc0, 0xcc, 0xaf, 0xcf, - 0xcd, 0xb6, 0xe5, 0xec, 0x2e, 0xf7, 0x43, 0x19, 0x5a, 0x66, 0x2f, 0xdf, 0xf3, 0xcd, 0x18, 0x0, 0x0, - 0x4e, 0x81, 0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, - 0x64, 0x52, 0x67, 0x81, 0x2e, 0x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1, 0x7d, 0x5b, 0x9, 0xdc, 0x18, 0x41, 0x42, 0x92, 0xa8, 0x15, 0x0, + 0x0, 0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, 0xbc, 0xa8, + 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2962,109 +3105,73 @@ TEST(Publish5QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x50, 0xb1, 0x15, 0x2e, 0xbe, 0xab, 0xe0, 0x8b, 0x32, 0xf8, 0x5d, 0x3d, 0xb3, 0x6e, - 0x14, 0x6b, 0x92, 0x98, 0xaf, 0xd2, 0xcd, 0x60, 0x33, 0x7c, 0x87, 0x38, 0x69, 0xd1}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x86, 0x5, 0x4b, 0x4c, 0x9f, 0x45, 0x2e, 0xd3, 0x2b, 0x5e, 0xf0, 0xbb, 0x92, 0x15, 0x37, - 0x64, 0x52, 0x67, 0x81, 0x2e, 0x6d, 0x85, 0x10, 0x98, 0x43, 0x1b, 0x4a, 0xa0, 0xcb}; + uint8_t exp_topic_bytes[] = {0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, 0x69, 0x24, + 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, 0xbc, + 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 19270); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(packet_id, 10816); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); EXPECT_EQ(msg.payload_len, 29); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\DLE", _pubPktID = 0, _pubBody = -// "\DC4s\199\ACKg\249\133\ENQ\157\223\145\&2NM^T\137xH3\226=j,\r\239U\ACK\153\210", _pubProps = [PropWillDelayInterval -// 13975,PropAuthenticationMethod "\178y~\133\229\US\134f",PropSubscriptionIdentifier 24,PropPayloadFormatIndicator -// 112,PropAuthenticationData "\226\221\243\164*\209\&1_F\NAKcK\194",PropServerReference -// "\RSW\194s\202\203\172/\207R",PropServerReference "\248\244\133\DC4",PropTopicAlias 12118,PropAuthenticationData -// "\181\221\RS{\134\247\SUB\195\SO",PropServerReference -// "\225\232\152\176yO\DEL{\233x\170^\b\193g\ETXd\v\\\252wc\175\149eU\a\DC4",PropResponseTopic -// "Z\FSr\DC3\220{\RS\206V\168\197\&0\210\203\ENQ\160\&5\176W\213\&64\vu",PropCorrelationData "Jh"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "C:\210I?H\140\153\163\FS\190\141PA\209Z6\210G=S\217\242\219S\237\226\a", _pubPktID = 780, _pubBody = +// "\185b.\FS\147|\157\223\176\240\ENQy\185\208\DC4\186(topic.data), 1); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + uint8_t exp_topic_bytes[] = {0x43, 0x3a, 0xd2, 0x49, 0x3f, 0x48, 0x8c, 0x99, 0xa3, 0x1c, 0xbe, 0x8d, 0x50, 0x41, + 0xd1, 0x5a, 0x36, 0xd2, 0x47, 0x3d, 0x53, 0xd9, 0xf2, 0xdb, 0x53, 0xed, 0xe2, 0x7}; + lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb9, 0x62, 0x2e, 0x1c, 0x93, 0x7c, 0x9d, 0xdf, 0xb0, 0xf0, 0x5, 0x79, 0xb9, 0xd0, + 0x14, 0xba, 0x3c, 0x45, 0xdb, 0x94, 0x83, 0xd4, 0xdf, 0x85, 0xb3, 0x11, 0xfd, 0xa9}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 780); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\171b\DC1\233\"[\161x\tR2\b\143\ap\176)0\156/\230\155\ETBx\154h*|", _pubPktID = 3357, _pubBody = "\139", _pubProps = -// [PropTopicAlias 26188,PropRetainAvailable 55,PropReasonString -// "w\181\DC2\242\168\ACK\248@\224\ACK\SOH\135",PropMaximumPacketSize 1661,PropWillDelayInterval -// 877,PropRequestResponseInformation 164,PropWillDelayInterval 28432,PropSessionExpiryInterval -// 27592,PropMessageExpiryInterval 19299,PropTopicAliasMaximum 32078,PropAuthenticationMethod "\154 -// 0o}R\229`h\198\&0\STX0D\221\218\242\&3e\162\164\225\248\183\SIZ\209\251\226\251",PropMessageExpiryInterval -// 7477,PropSubscriptionIdentifier 1,PropReasonString -// "YS\ETB\STX\157\204_\155\&2\244\201\"\143X\142&\241\US\131\&0\ETB\177",PropTopicAlias 10274]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "x\170\228C2\140C\ACKD\FS/[\214\EOT\SOH", _pubPktID = 0, _pubBody = "\185", _pubProps = [PropTopicAliasMaximum +// 21735,PropMaximumPacketSize 23247,PropResponseTopic "\253\195\224\216d\206\EOT\167?\163CZ\163",PropServerKeepAlive +// 1098,PropMessageExpiryInterval 15291,PropWildcardSubscriptionAvailable 116,PropTopicAlias +// 13184,PropSubscriptionIdentifier 23,PropTopicAliasMaximum 22231,PropRetainAvailable 205,PropUserProperty +// "\164\227\165\164\178\EOT.\134X\216\ENQ^\198\&8\206\133\249\131\t]=\208\177\174" "c",PropMaximumPacketSize +// 1168,PropReceiveMaximum 18513]} TEST(Publish5QCTest, Encode13) { - uint8_t pkt[] = {0x3c, 0x98, 0x1, 0x0, 0x1c, 0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, - 0x8, 0x8f, 0x7, 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, - 0x7c, 0xd, 0x1d, 0x76, 0x23, 0x66, 0x4c, 0x25, 0x37, 0x1f, 0x0, 0xc, 0x77, 0xb5, 0x12, 0xf2, - 0xa8, 0x6, 0xf8, 0x40, 0xe0, 0x6, 0x1, 0x87, 0x27, 0x0, 0x0, 0x6, 0x7d, 0x18, 0x0, 0x0, - 0x3, 0x6d, 0x19, 0xa4, 0x18, 0x0, 0x0, 0x6f, 0x10, 0x11, 0x0, 0x0, 0x6b, 0xc8, 0x2, 0x0, - 0x0, 0x4b, 0x63, 0x22, 0x7d, 0x4e, 0x15, 0x0, 0x1e, 0x9a, 0x20, 0x30, 0x6f, 0x7d, 0x52, 0xe5, - 0x60, 0x68, 0xc6, 0x30, 0x2, 0x30, 0x44, 0xdd, 0xda, 0xf2, 0x33, 0x65, 0xa2, 0xa4, 0xe1, 0xf8, - 0xb7, 0xf, 0x5a, 0xd1, 0xfb, 0xe2, 0xfb, 0x2, 0x0, 0x0, 0x1d, 0x35, 0xb, 0x1, 0x1f, 0x0, - 0x16, 0x59, 0x53, 0x17, 0x2, 0x9d, 0xcc, 0x5f, 0x9b, 0x32, 0xf4, 0xc9, 0x22, 0x8f, 0x58, 0x8e, - 0x26, 0xf1, 0x1f, 0x83, 0x30, 0x17, 0xb1, 0x23, 0x28, 0x22, 0x8b}; - uint8_t topic_bytes[] = {0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, - 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x65, 0x0, 0xf, 0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, + 0x5b, 0xd6, 0x4, 0x1, 0x52, 0x22, 0x54, 0xe7, 0x27, 0x0, 0x0, 0x5a, 0xcf, 0x8, 0x0, + 0xd, 0xfd, 0xc3, 0xe0, 0xd8, 0x64, 0xce, 0x4, 0xa7, 0x3f, 0xa3, 0x43, 0x5a, 0xa3, 0x13, + 0x4, 0x4a, 0x2, 0x0, 0x0, 0x3b, 0xbb, 0x28, 0x74, 0x23, 0x33, 0x80, 0xb, 0x17, 0x22, + 0x56, 0xd7, 0x25, 0xcd, 0x26, 0x0, 0x18, 0xa4, 0xe3, 0xa5, 0xa4, 0xb2, 0x4, 0x2e, 0x86, + 0x58, 0xd8, 0x5, 0x5e, 0xc6, 0x38, 0xce, 0x85, 0xf9, 0x83, 0x9, 0x5d, 0x3d, 0xd0, 0xb1, + 0xae, 0x0, 0x1, 0x63, 0x27, 0x0, 0x0, 0x4, 0x90, 0x21, 0x48, 0x51, 0xb9}; + uint8_t topic_bytes[] = {0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x8b}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0xb9}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 1; - uint8_t bytesprops0[] = {0x77, 0xb5, 0x12, 0xf2, 0xa8, 0x6, 0xf8, 0x40, 0xe0, 0x6, 0x1, 0x87}; - uint8_t bytesprops1[] = {0x9a, 0x20, 0x30, 0x6f, 0x7d, 0x52, 0xe5, 0x60, 0x68, 0xc6, 0x30, 0x2, 0x30, 0x44, 0xdd, - 0xda, 0xf2, 0x33, 0x65, 0xa2, 0xa4, 0xe1, 0xf8, 0xb7, 0xf, 0x5a, 0xd1, 0xfb, 0xe2, 0xfb}; - uint8_t bytesprops2[] = {0x59, 0x53, 0x17, 0x2, 0x9d, 0xcc, 0x5f, 0x9b, 0x32, 0xf4, 0xc9, - 0x22, 0x8f, 0x58, 0x8e, 0x26, 0xf1, 0x1f, 0x83, 0x30, 0x17, 0xb1}; + uint8_t bytesprops0[] = {0xfd, 0xc3, 0xe0, 0xd8, 0x64, 0xce, 0x4, 0xa7, 0x3f, 0xa3, 0x43, 0x5a, 0xa3}; + uint8_t bytesprops2[] = {0x63}; + uint8_t bytesprops1[] = {0xa4, 0xe3, 0xa5, 0xa4, 0xb2, 0x4, 0x2e, 0x86, 0x58, 0xd8, 0x5, 0x5e, + 0xc6, 0x38, 0xce, 0x85, 0xf9, 0x83, 0x9, 0x5d, 0x3d, 0xd0, 0xb1, 0xae}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26188}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1661}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 877}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28432}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27592}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19299}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32078}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7477}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10274}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21735}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23247}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1098}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15291}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13184}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22231}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops1}, .v = {1, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1168}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18513}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 3357, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\171b\DC1\233\"[\161x\tR2\b\143\ap\176)0\156/\230\155\ETBx\154h*|", _pubPktID = 3357, _pubBody = "\139", _pubProps = -// [PropTopicAlias 26188,PropRetainAvailable 55,PropReasonString -// "w\181\DC2\242\168\ACK\248@\224\ACK\SOH\135",PropMaximumPacketSize 1661,PropWillDelayInterval -// 877,PropRequestResponseInformation 164,PropWillDelayInterval 28432,PropSessionExpiryInterval -// 27592,PropMessageExpiryInterval 19299,PropTopicAliasMaximum 32078,PropAuthenticationMethod "\154 -// 0o}R\229`h\198\&0\STX0D\221\218\242\&3e\162\164\225\248\183\SIZ\209\251\226\251",PropMessageExpiryInterval -// 7477,PropSubscriptionIdentifier 1,PropReasonString -// "YS\ETB\STX\157\204_\155\&2\244\201\"\143X\142&\241\US\131\&0\ETB\177",PropTopicAlias 10274]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "x\170\228C2\140C\ACKD\FS/[\214\EOT\SOH", _pubPktID = 0, _pubBody = "\185", _pubProps = [PropTopicAliasMaximum +// 21735,PropMaximumPacketSize 23247,PropResponseTopic "\253\195\224\216d\206\EOT\167?\163CZ\163",PropServerKeepAlive +// 1098,PropMessageExpiryInterval 15291,PropWildcardSubscriptionAvailable 116,PropTopicAlias +// 13184,PropSubscriptionIdentifier 23,PropTopicAliasMaximum 22231,PropRetainAvailable 205,PropUserProperty +// "\164\227\165\164\178\EOT.\134X\216\ENQ^\198\&8\206\133\249\131\t]=\208\177\174" "c",PropMaximumPacketSize +// 1168,PropReceiveMaximum 18513]} TEST(Publish5QCTest, Decode13) { - uint8_t pkt[] = {0x3c, 0x98, 0x1, 0x0, 0x1c, 0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, - 0x8, 0x8f, 0x7, 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, - 0x7c, 0xd, 0x1d, 0x76, 0x23, 0x66, 0x4c, 0x25, 0x37, 0x1f, 0x0, 0xc, 0x77, 0xb5, 0x12, 0xf2, - 0xa8, 0x6, 0xf8, 0x40, 0xe0, 0x6, 0x1, 0x87, 0x27, 0x0, 0x0, 0x6, 0x7d, 0x18, 0x0, 0x0, - 0x3, 0x6d, 0x19, 0xa4, 0x18, 0x0, 0x0, 0x6f, 0x10, 0x11, 0x0, 0x0, 0x6b, 0xc8, 0x2, 0x0, - 0x0, 0x4b, 0x63, 0x22, 0x7d, 0x4e, 0x15, 0x0, 0x1e, 0x9a, 0x20, 0x30, 0x6f, 0x7d, 0x52, 0xe5, - 0x60, 0x68, 0xc6, 0x30, 0x2, 0x30, 0x44, 0xdd, 0xda, 0xf2, 0x33, 0x65, 0xa2, 0xa4, 0xe1, 0xf8, - 0xb7, 0xf, 0x5a, 0xd1, 0xfb, 0xe2, 0xfb, 0x2, 0x0, 0x0, 0x1d, 0x35, 0xb, 0x1, 0x1f, 0x0, - 0x16, 0x59, 0x53, 0x17, 0x2, 0x9d, 0xcc, 0x5f, 0x9b, 0x32, 0xf4, 0xc9, 0x22, 0x8f, 0x58, 0x8e, - 0x26, 0xf1, 0x1f, 0x83, 0x30, 0x17, 0xb1, 0x23, 0x28, 0x22, 0x8b}; + uint8_t pkt[] = {0x31, 0x65, 0x0, 0xf, 0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, + 0x5b, 0xd6, 0x4, 0x1, 0x52, 0x22, 0x54, 0xe7, 0x27, 0x0, 0x0, 0x5a, 0xcf, 0x8, 0x0, + 0xd, 0xfd, 0xc3, 0xe0, 0xd8, 0x64, 0xce, 0x4, 0xa7, 0x3f, 0xa3, 0x43, 0x5a, 0xa3, 0x13, + 0x4, 0x4a, 0x2, 0x0, 0x0, 0x3b, 0xbb, 0x28, 0x74, 0x23, 0x33, 0x80, 0xb, 0x17, 0x22, + 0x56, 0xd7, 0x25, 0xcd, 0x26, 0x0, 0x18, 0xa4, 0xe3, 0xa5, 0xa4, 0xb2, 0x4, 0x2e, 0x86, + 0x58, 0xd8, 0x5, 0x5e, 0xc6, 0x38, 0xce, 0x85, 0xf9, 0x83, 0x9, 0x5d, 0x3d, 0xd0, 0xb1, + 0xae, 0x0, 0x1, 0x63, 0x27, 0x0, 0x0, 0x4, 0x90, 0x21, 0x48, 0x51, 0xb9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3181,65 +3275,112 @@ TEST(Publish5QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xab, 0x62, 0x11, 0xe9, 0x22, 0x5b, 0xa1, 0x78, 0x9, 0x52, 0x32, 0x8, 0x8f, 0x7, - 0x70, 0xb0, 0x29, 0x30, 0x9c, 0x2f, 0xe6, 0x9b, 0x17, 0x78, 0x9a, 0x68, 0x2a, 0x7c}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x8b}; + uint8_t exp_topic_bytes[] = {0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb9}; lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 3357); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); EXPECT_EQ(msg.payload_len, 1); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\243\197\208\135\165\n\174^Z4\184\231\152+\166\ETX\175`\187\229\171:\143\196\rO\140G", _pubPktID = 31669, _pubBody = -// "\165yk,.\240\234\134]\245eA\SI\171\146\201\234a.\165", _pubProps = [PropCorrelationData "w2\170x\169\&4\199\\"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\EM\181N`\v\241\NAKi\133lU\172 +// ~\192\152\DLE2\173\193\158\SOH\252\&8/.\RS", _pubPktID = 21275, _pubBody = "'\189s+\222o/\187^\161", _pubProps = +// [PropTopicAliasMaximum 21929,PropResponseInformation "9\236S.4\nB\SYN",PropMaximumPacketSize 29128,PropUserProperty +// "'\209\DC2\f%l\254\138\"\180;\165\235\174\228f\247$r\ETB\DEL\176\167>#xJm\254" +// "\160\182\229\218|\\\172\216\161Q\SI]\141\252\192\&3\210;\181\236\DC2\191BQ",PropAuthenticationData +// "R='\201\138\DC3c\SUBXM\155\129\200@\189B\186H6\EM]\131x\130\159\215\189\238K",PropUserProperty +// "O\CAN\191\144\250\GSL6\193a\ENQu\ETX\151\EMW\145\r\223\178\ETX" +// "\GSv\248\238L\234\137\SYN\DC2%:V\129yh\199\189\DC3\167N\DC49{\t\137",PropMaximumPacketSize 20573,PropContentType +// "F$'T\241\232\151\161",PropSharedSubscriptionAvailable 97]} TEST(Publish5QCTest, Encode14) { - uint8_t pkt[] = {0x34, 0x40, 0x0, 0x1c, 0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, - 0x2b, 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47, 0x7b, 0xb5, - 0xb, 0x9, 0x0, 0x8, 0x77, 0x32, 0xaa, 0x78, 0xa9, 0x34, 0xc7, 0x5c, 0xa5, 0x79, 0x6b, 0x2c, 0x2e, - 0xf0, 0xea, 0x86, 0x5d, 0xf5, 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; - uint8_t topic_bytes[] = {0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, 0x2b, - 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47}; - lwmqtt_string_t topic = {28, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x32, 0xdd, 0x1, 0x0, 0x1b, 0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0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x50, 0x5d, 0x3, 0x0, 0x8, 0x46, 0x24, 0x27, 0x54, 0xf1, + 0xe8, 0x97, 0xa1, 0x2a, 0x61, 0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; + uint8_t topic_bytes[] = {0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, 0xac, 0x20, 0x7e, + 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, 0x1e}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, 0x5d, 0xf5, - 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; + uint8_t msg_bytes[] = {0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 10; - uint8_t bytesprops0[] = {0x77, 0x32, 0xaa, 0x78, 0xa9, 0x34, 0xc7, 0x5c}; + uint8_t bytesprops0[] = {0x39, 0xec, 0x53, 0x2e, 0x34, 0xa, 0x42, 0x16}; + uint8_t bytesprops2[] = {0xa0, 0xb6, 0xe5, 0xda, 0x7c, 0x5c, 0xac, 0xd8, 0xa1, 0x51, 0xf, 0x5d, + 0x8d, 0xfc, 0xc0, 0x33, 0xd2, 0x3b, 0xb5, 0xec, 0x12, 0xbf, 0x42, 0x51}; + uint8_t bytesprops1[] = {0x27, 0xd1, 0x12, 0xc, 0x25, 0x6c, 0xfe, 0x8a, 0x22, 0xb4, 0x3b, 0xa5, 0xeb, 0xae, 0xe4, + 0x66, 0xf7, 0x24, 0x72, 0x17, 0x7f, 0xb0, 0xa7, 0x3e, 0x23, 0x78, 0x4a, 0x6d, 0xfe}; + uint8_t bytesprops3[] = {0x52, 0x3d, 0x27, 0xc9, 0x8a, 0x13, 0x63, 0x1a, 0x58, 0x4d, 0x9b, 0x81, 0xc8, 0x40, 0xbd, + 0x42, 0xba, 0x48, 0x36, 0x19, 0x5d, 0x83, 0x78, 0x82, 0x9f, 0xd7, 0xbd, 0xee, 0x4b}; + uint8_t bytesprops5[] = {0x1d, 0x76, 0xf8, 0xee, 0x4c, 0xea, 0x89, 0x16, 0x12, 0x25, 0x3a, 0x56, 0x81, + 0x79, 0x68, 0xc7, 0xbd, 0x13, 0xa7, 0x4e, 0x14, 0x39, 0x7b, 0x9, 0x89}; + uint8_t bytesprops4[] = {0x4f, 0x18, 0xbf, 0x90, 0xfa, 0x1d, 0x4c, 0x36, 0xc1, 0x61, 0x5, + 0x75, 0x3, 0x97, 0x19, 0x57, 0x91, 0xd, 0xdf, 0xb2, 0x3}; + uint8_t bytesprops6[] = {0x46, 0x24, 0x27, 0x54, 0xf1, 0xe8, 0x97, 0xa1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21929}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29128}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {24, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops4}, .v = {25, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20573}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 97}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 31669, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 21275, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\243\197\208\135\165\n\174^Z4\184\231\152+\166\ETX\175`\187\229\171:\143\196\rO\140G", _pubPktID = 31669, _pubBody = -// "\165yk,.\240\234\134]\245eA\SI\171\146\201\234a.\165", _pubProps = [PropCorrelationData "w2\170x\169\&4\199\\"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\EM\181N`\v\241\NAKi\133lU\172 +// ~\192\152\DLE2\173\193\158\SOH\252\&8/.\RS", _pubPktID = 21275, _pubBody = "'\189s+\222o/\187^\161", _pubProps = +// [PropTopicAliasMaximum 21929,PropResponseInformation "9\236S.4\nB\SYN",PropMaximumPacketSize 29128,PropUserProperty +// "'\209\DC2\f%l\254\138\"\180;\165\235\174\228f\247$r\ETB\DEL\176\167>#xJm\254" +// "\160\182\229\218|\\\172\216\161Q\SI]\141\252\192\&3\210;\181\236\DC2\191BQ",PropAuthenticationData +// "R='\201\138\DC3c\SUBXM\155\129\200@\189B\186H6\EM]\131x\130\159\215\189\238K",PropUserProperty +// "O\CAN\191\144\250\GSL6\193a\ENQu\ETX\151\EMW\145\r\223\178\ETX" +// "\GSv\248\238L\234\137\SYN\DC2%:V\129yh\199\189\DC3\167N\DC49{\t\137",PropMaximumPacketSize 20573,PropContentType +// "F$'T\241\232\151\161",PropSharedSubscriptionAvailable 97]} TEST(Publish5QCTest, Decode14) { - uint8_t pkt[] = {0x34, 0x40, 0x0, 0x1c, 0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, - 0x2b, 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47, 0x7b, 0xb5, - 0xb, 0x9, 0x0, 0x8, 0x77, 0x32, 0xaa, 0x78, 0xa9, 0x34, 0xc7, 0x5c, 0xa5, 0x79, 0x6b, 0x2c, 0x2e, - 0xf0, 0xea, 0x86, 0x5d, 0xf5, 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; + uint8_t pkt[] = { + 0x32, 0xdd, 0x1, 0x0, 0x1b, 0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, 0xac, 0x20, 0x7e, + 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, 0x1e, 0x53, 0x1b, 0xb2, 0x1, 0x22, 0x55, + 0xa9, 0x1a, 0x0, 0x8, 0x39, 0xec, 0x53, 0x2e, 0x34, 0xa, 0x42, 0x16, 0x27, 0x0, 0x0, 0x71, 0xc8, 0x26, 0x0, + 0x1d, 0x27, 0xd1, 0x12, 0xc, 0x25, 0x6c, 0xfe, 0x8a, 0x22, 0xb4, 0x3b, 0xa5, 0xeb, 0xae, 0xe4, 0x66, 0xf7, 0x24, + 0x72, 0x17, 0x7f, 0xb0, 0xa7, 0x3e, 0x23, 0x78, 0x4a, 0x6d, 0xfe, 0x0, 0x18, 0xa0, 0xb6, 0xe5, 0xda, 0x7c, 0x5c, + 0xac, 0xd8, 0xa1, 0x51, 0xf, 0x5d, 0x8d, 0xfc, 0xc0, 0x33, 0xd2, 0x3b, 0xb5, 0xec, 0x12, 0xbf, 0x42, 0x51, 0x16, + 0x0, 0x1d, 0x52, 0x3d, 0x27, 0xc9, 0x8a, 0x13, 0x63, 0x1a, 0x58, 0x4d, 0x9b, 0x81, 0xc8, 0x40, 0xbd, 0x42, 0xba, + 0x48, 0x36, 0x19, 0x5d, 0x83, 0x78, 0x82, 0x9f, 0xd7, 0xbd, 0xee, 0x4b, 0x26, 0x0, 0x15, 0x4f, 0x18, 0xbf, 0x90, + 0xfa, 0x1d, 0x4c, 0x36, 0xc1, 0x61, 0x5, 0x75, 0x3, 0x97, 0x19, 0x57, 0x91, 0xd, 0xdf, 0xb2, 0x3, 0x0, 0x19, + 0x1d, 0x76, 0xf8, 0xee, 0x4c, 0xea, 0x89, 0x16, 0x12, 0x25, 0x3a, 0x56, 0x81, 0x79, 0x68, 0xc7, 0xbd, 0x13, 0xa7, + 0x4e, 0x14, 0x39, 0x7b, 0x9, 0x89, 0x27, 0x0, 0x0, 0x50, 0x5d, 0x3, 0x0, 0x8, 0x46, 0x24, 0x27, 0x54, 0xf1, + 0xe8, 0x97, 0xa1, 0x2a, 0x61, 0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3248,120 +3389,148 @@ TEST(Publish5QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf3, 0xc5, 0xd0, 0x87, 0xa5, 0xa, 0xae, 0x5e, 0x5a, 0x34, 0xb8, 0xe7, 0x98, 0x2b, - 0xa6, 0x3, 0xaf, 0x60, 0xbb, 0xe5, 0xab, 0x3a, 0x8f, 0xc4, 0xd, 0x4f, 0x8c, 0x47}; - lwmqtt_string_t exp_topic = {28, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa5, 0x79, 0x6b, 0x2c, 0x2e, 0xf0, 0xea, 0x86, 0x5d, 0xf5, - 0x65, 0x41, 0xf, 0xab, 0x92, 0xc9, 0xea, 0x61, 0x2e, 0xa5}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, 0xac, 0x20, 0x7e, + 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, 0x1e}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 31669); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 28); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_EQ(packet_id, 21275); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\v\172h\241z\159Z'\153h\STXiS.\STX&a\166|\147~\ETBbP\194\242$`q", _pubPktID = 29118, _pubBody = -// "\155\GS\134h\241\DC2\174", _pubProps = [PropRequestProblemInformation 58,PropSubscriptionIdentifierAvailable -// 41,PropSubscriptionIdentifier 30,PropMessageExpiryInterval 13507,PropPayloadFormatIndicator -// 213,PropWildcardSubscriptionAvailable 147,PropSubscriptionIdentifierAvailable 57,PropReceiveMaximum -// 3682,PropServerReference "5C\CAN$\STXi\214\131o\r\205\&8X\143",PropWildcardSubscriptionAvailable -// 131,PropRequestResponseInformation 174,PropWildcardSubscriptionAvailable 121,PropSharedSubscriptionAvailable -// 106,PropMaximumPacketSize 6087,PropMessageExpiryInterval 1138,PropMaximumQoS 166,PropResponseTopic -// "e:\SYN\202\158\161\132\161\SOH\139\ETBr\ACK\ESC7\160+\183}\221#\201",PropRequestResponseInformation -// 40,PropAuthenticationData "\203\213\NUL#\207\DC4?5Y\249n\"\174\140\150\216\"3sz",PropWildcardSubscriptionAvailable -// 42,PropSubscriptionIdentifier 19,PropMaximumPacketSize 27196,PropCorrelationData "\b\223\191e\227"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\176\EMg\233", _pubPktID = 31111, +// _pubBody = "e\163\181)\SYN\133\198/d\225\216\252\177\&5v[\251\&3\219\232\135\&2\251>E\155#\DLE\254", _pubProps = +// [PropWillDelayInterval 9651,PropAssignedClientIdentifier +// "\187\193]\153&\208#\238\DLE\180n?\NAK\244n\SYN\248\167\151\135\164\179\183\205",PropServerReference +// "p",PropServerKeepAlive 9508,PropReceiveMaximum 4115,PropContentType +// "\fP\153\219\190\224\GS\229\FS\175\176\202\&8CD\193\131h",PropAuthenticationMethod "w\\",PropTopicAliasMaximum +// 13378,PropWildcardSubscriptionAvailable 106,PropWildcardSubscriptionAvailable 38,PropSessionExpiryInterval +// 1710,PropReceiveMaximum 22280,PropAssignedClientIdentifier ")",PropCorrelationData +// "\a*\163\&9W.\223N\RS\215\170{\a\DC23\"\f\207\129{\212a\bxK",PropAuthenticationMethod +// "i\183\129\NAK\129\v\190\CAN4",PropRetainAvailable 213,PropMaximumPacketSize 11201,PropMessageExpiryInterval +// 14252,PropResponseInformation "w2\248\193",PropTopicAlias 1304,PropReasonString +// "Z\ACK\230\131\214\146\&7\228\141\229\209\&5\214z\221\NAK\244\241y\220\252\193\240p\189\&7J\154\196",PropPayloadFormatIndicator +// 153,PropMaximumPacketSize 11435,PropWildcardSubscriptionAvailable 74,PropMaximumPacketSize +// 23532,PropRequestResponseInformation 85,PropServerReference "\229bn\164\160*X\192\237\195js?\226\163\&8bx\187"]} TEST(Publish5QCTest, Encode15) { - uint8_t pkt[] = {0x33, 0xa5, 0x1, 0x0, 0x1d, 0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, - 0x53, 0x2e, 0x2, 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71, - 0x71, 0xbe, 0x7c, 0x17, 0x3a, 0x29, 0x29, 0xb, 0x1e, 0x2, 0x0, 0x0, 0x34, 0xc3, 0x1, 0xd5, 0x28, - 0x93, 0x29, 0x39, 0x21, 0xe, 0x62, 0x1c, 0x0, 0xe, 0x35, 0x43, 0x18, 0x24, 0x2, 0x69, 0xd6, 0x83, - 0x6f, 0xd, 0xcd, 0x38, 0x58, 0x8f, 0x28, 0x83, 0x19, 0xae, 0x28, 0x79, 0x2a, 0x6a, 0x27, 0x0, 0x0, - 0x17, 0xc7, 0x2, 0x0, 0x0, 0x4, 0x72, 0x24, 0xa6, 0x8, 0x0, 0x16, 0x65, 0x3a, 0x16, 0xca, 0x9e, - 0xa1, 0x84, 0xa1, 0x1, 0x8b, 0x17, 0x72, 0x6, 0x1b, 0x37, 0xa0, 0x2b, 0xb7, 0x7d, 0xdd, 0x23, 0xc9, - 0x19, 0x28, 0x16, 0x0, 0x14, 0xcb, 0xd5, 0x0, 0x23, 0xcf, 0x14, 0x3f, 0x35, 0x59, 0xf9, 0x6e, 0x22, - 0xae, 0x8c, 0x96, 0xd8, 0x22, 0x33, 0x73, 0x7a, 0x28, 0x2a, 0xb, 0x13, 0x27, 0x0, 0x0, 0x6a, 0x3c, - 0x9, 0x0, 0x5, 0x8, 0xdf, 0xbf, 0x65, 0xe3, 0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; - uint8_t topic_bytes[] = {0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, 0x53, 0x2e, 0x2, - 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x34, 0x82, 0x2, 0x0, 0x4, 0xb0, 0x19, 0x67, 0xe9, 0x79, 0x87, 0xdb, 0x1, 0x18, 0x0, 0x0, 0x25, 0xb3, 0x12, + 0x0, 0x18, 0xbb, 0xc1, 0x5d, 0x99, 0x26, 0xd0, 0x23, 0xee, 0x10, 0xb4, 0x6e, 0x3f, 0x15, 0xf4, 0x6e, 0x16, 0xf8, + 0xa7, 0x97, 0x87, 0xa4, 0xb3, 0xb7, 0xcd, 0x1c, 0x0, 0x1, 0x70, 0x13, 0x25, 0x24, 0x21, 0x10, 0x13, 0x3, 0x0, + 0x12, 0xc, 0x50, 0x99, 0xdb, 0xbe, 0xe0, 0x1d, 0xe5, 0x1c, 0xaf, 0xb0, 0xca, 0x38, 0x43, 0x44, 0xc1, 0x83, 0x68, + 0x15, 0x0, 0x2, 0x77, 0x5c, 0x22, 0x34, 0x42, 0x28, 0x6a, 0x28, 0x26, 0x11, 0x0, 0x0, 0x6, 0xae, 0x21, 0x57, + 0x8, 0x12, 0x0, 0x1, 0x29, 0x9, 0x0, 0x19, 0x7, 0x2a, 0xa3, 0x39, 0x57, 0x2e, 0xdf, 0x4e, 0x1e, 0xd7, 0xaa, + 0x7b, 0x7, 0x12, 0x33, 0x22, 0xc, 0xcf, 0x81, 0x7b, 0xd4, 0x61, 0x8, 0x78, 0x4b, 0x15, 0x0, 0x9, 0x69, 0xb7, + 0x81, 0x15, 0x81, 0xb, 0xbe, 0x18, 0x34, 0x25, 0xd5, 0x27, 0x0, 0x0, 0x2b, 0xc1, 0x2, 0x0, 0x0, 0x37, 0xac, + 0x1a, 0x0, 0x4, 0x77, 0x32, 0xf8, 0xc1, 0x23, 0x5, 0x18, 0x1f, 0x0, 0x1d, 0x5a, 0x6, 0xe6, 0x83, 0xd6, 0x92, + 0x37, 0xe4, 0x8d, 0xe5, 0xd1, 0x35, 0xd6, 0x7a, 0xdd, 0x15, 0xf4, 0xf1, 0x79, 0xdc, 0xfc, 0xc1, 0xf0, 0x70, 0xbd, + 0x37, 0x4a, 0x9a, 0xc4, 0x1, 0x99, 0x27, 0x0, 0x0, 0x2c, 0xab, 0x28, 0x4a, 0x27, 0x0, 0x0, 0x5b, 0xec, 0x19, + 0x55, 0x1c, 0x0, 0x13, 0xe5, 0x62, 0x6e, 0xa4, 0xa0, 0x2a, 0x58, 0xc0, 0xed, 0xc3, 0x6a, 0x73, 0x3f, 0xe2, 0xa3, + 0x38, 0x62, 0x78, 0xbb, 0x65, 0xa3, 0xb5, 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, + 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; + uint8_t topic_bytes[] = {0xb0, 0x19, 0x67, 0xe9}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x65, 0xa3, 0xb5, 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, + 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 7; + msg.payload_len = 29; - uint8_t bytesprops0[] = {0x35, 0x43, 0x18, 0x24, 0x2, 0x69, 0xd6, 0x83, 0x6f, 0xd, 0xcd, 0x38, 0x58, 0x8f}; - uint8_t bytesprops1[] = {0x65, 0x3a, 0x16, 0xca, 0x9e, 0xa1, 0x84, 0xa1, 0x1, 0x8b, 0x17, - 0x72, 0x6, 0x1b, 0x37, 0xa0, 0x2b, 0xb7, 0x7d, 0xdd, 0x23, 0xc9}; - uint8_t bytesprops2[] = {0xcb, 0xd5, 0x0, 0x23, 0xcf, 0x14, 0x3f, 0x35, 0x59, 0xf9, - 0x6e, 0x22, 0xae, 0x8c, 0x96, 0xd8, 0x22, 0x33, 0x73, 0x7a}; - uint8_t bytesprops3[] = {0x8, 0xdf, 0xbf, 0x65, 0xe3}; + uint8_t bytesprops0[] = {0xbb, 0xc1, 0x5d, 0x99, 0x26, 0xd0, 0x23, 0xee, 0x10, 0xb4, 0x6e, 0x3f, + 0x15, 0xf4, 0x6e, 0x16, 0xf8, 0xa7, 0x97, 0x87, 0xa4, 0xb3, 0xb7, 0xcd}; + uint8_t bytesprops1[] = {0x70}; + uint8_t bytesprops2[] = {0xc, 0x50, 0x99, 0xdb, 0xbe, 0xe0, 0x1d, 0xe5, 0x1c, + 0xaf, 0xb0, 0xca, 0x38, 0x43, 0x44, 0xc1, 0x83, 0x68}; + uint8_t bytesprops3[] = {0x77, 0x5c}; + uint8_t bytesprops4[] = {0x29}; + uint8_t bytesprops5[] = {0x7, 0x2a, 0xa3, 0x39, 0x57, 0x2e, 0xdf, 0x4e, 0x1e, 0xd7, 0xaa, 0x7b, 0x7, + 0x12, 0x33, 0x22, 0xc, 0xcf, 0x81, 0x7b, 0xd4, 0x61, 0x8, 0x78, 0x4b}; + uint8_t bytesprops6[] = {0x69, 0xb7, 0x81, 0x15, 0x81, 0xb, 0xbe, 0x18, 0x34}; + uint8_t bytesprops7[] = {0x77, 0x32, 0xf8, 0xc1}; + uint8_t bytesprops8[] = {0x5a, 0x6, 0xe6, 0x83, 0xd6, 0x92, 0x37, 0xe4, 0x8d, 0xe5, 0xd1, 0x35, 0xd6, 0x7a, 0xdd, + 0x15, 0xf4, 0xf1, 0x79, 0xdc, 0xfc, 0xc1, 0xf0, 0x70, 0xbd, 0x37, 0x4a, 0x9a, 0xc4}; + uint8_t bytesprops9[] = {0xe5, 0x62, 0x6e, 0xa4, 0xa0, 0x2a, 0x58, 0xc0, 0xed, 0xc3, + 0x6a, 0x73, 0x3f, 0xe2, 0xa3, 0x38, 0x62, 0x78, 0xbb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13507}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3682}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6087}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1138}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27196}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9651}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9508}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4115}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13378}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1710}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22280}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11201}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14252}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1304}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11435}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23532}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 29118, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 31111, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\v\172h\241z\159Z'\153h\STXiS.\STX&a\166|\147~\ETBbP\194\242$`q", _pubPktID = 29118, _pubBody = -// "\155\GS\134h\241\DC2\174", _pubProps = [PropRequestProblemInformation 58,PropSubscriptionIdentifierAvailable -// 41,PropSubscriptionIdentifier 30,PropMessageExpiryInterval 13507,PropPayloadFormatIndicator -// 213,PropWildcardSubscriptionAvailable 147,PropSubscriptionIdentifierAvailable 57,PropReceiveMaximum -// 3682,PropServerReference "5C\CAN$\STXi\214\131o\r\205\&8X\143",PropWildcardSubscriptionAvailable -// 131,PropRequestResponseInformation 174,PropWildcardSubscriptionAvailable 121,PropSharedSubscriptionAvailable -// 106,PropMaximumPacketSize 6087,PropMessageExpiryInterval 1138,PropMaximumQoS 166,PropResponseTopic -// "e:\SYN\202\158\161\132\161\SOH\139\ETBr\ACK\ESC7\160+\183}\221#\201",PropRequestResponseInformation -// 40,PropAuthenticationData "\203\213\NUL#\207\DC4?5Y\249n\"\174\140\150\216\"3sz",PropWildcardSubscriptionAvailable -// 42,PropSubscriptionIdentifier 19,PropMaximumPacketSize 27196,PropCorrelationData "\b\223\191e\227"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\176\EMg\233", _pubPktID = 31111, +// _pubBody = "e\163\181)\SYN\133\198/d\225\216\252\177\&5v[\251\&3\219\232\135\&2\251>E\155#\DLE\254", _pubProps = +// [PropWillDelayInterval 9651,PropAssignedClientIdentifier +// "\187\193]\153&\208#\238\DLE\180n?\NAK\244n\SYN\248\167\151\135\164\179\183\205",PropServerReference +// "p",PropServerKeepAlive 9508,PropReceiveMaximum 4115,PropContentType +// "\fP\153\219\190\224\GS\229\FS\175\176\202\&8CD\193\131h",PropAuthenticationMethod "w\\",PropTopicAliasMaximum +// 13378,PropWildcardSubscriptionAvailable 106,PropWildcardSubscriptionAvailable 38,PropSessionExpiryInterval +// 1710,PropReceiveMaximum 22280,PropAssignedClientIdentifier ")",PropCorrelationData +// "\a*\163\&9W.\223N\RS\215\170{\a\DC23\"\f\207\129{\212a\bxK",PropAuthenticationMethod +// "i\183\129\NAK\129\v\190\CAN4",PropRetainAvailable 213,PropMaximumPacketSize 11201,PropMessageExpiryInterval +// 14252,PropResponseInformation "w2\248\193",PropTopicAlias 1304,PropReasonString +// "Z\ACK\230\131\214\146\&7\228\141\229\209\&5\214z\221\NAK\244\241y\220\252\193\240p\189\&7J\154\196",PropPayloadFormatIndicator +// 153,PropMaximumPacketSize 11435,PropWildcardSubscriptionAvailable 74,PropMaximumPacketSize +// 23532,PropRequestResponseInformation 85,PropServerReference "\229bn\164\160*X\192\237\195js?\226\163\&8bx\187"]} TEST(Publish5QCTest, Decode15) { - uint8_t pkt[] = {0x33, 0xa5, 0x1, 0x0, 0x1d, 0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, - 0x53, 0x2e, 0x2, 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71, - 0x71, 0xbe, 0x7c, 0x17, 0x3a, 0x29, 0x29, 0xb, 0x1e, 0x2, 0x0, 0x0, 0x34, 0xc3, 0x1, 0xd5, 0x28, - 0x93, 0x29, 0x39, 0x21, 0xe, 0x62, 0x1c, 0x0, 0xe, 0x35, 0x43, 0x18, 0x24, 0x2, 0x69, 0xd6, 0x83, - 0x6f, 0xd, 0xcd, 0x38, 0x58, 0x8f, 0x28, 0x83, 0x19, 0xae, 0x28, 0x79, 0x2a, 0x6a, 0x27, 0x0, 0x0, - 0x17, 0xc7, 0x2, 0x0, 0x0, 0x4, 0x72, 0x24, 0xa6, 0x8, 0x0, 0x16, 0x65, 0x3a, 0x16, 0xca, 0x9e, - 0xa1, 0x84, 0xa1, 0x1, 0x8b, 0x17, 0x72, 0x6, 0x1b, 0x37, 0xa0, 0x2b, 0xb7, 0x7d, 0xdd, 0x23, 0xc9, - 0x19, 0x28, 0x16, 0x0, 0x14, 0xcb, 0xd5, 0x0, 0x23, 0xcf, 0x14, 0x3f, 0x35, 0x59, 0xf9, 0x6e, 0x22, - 0xae, 0x8c, 0x96, 0xd8, 0x22, 0x33, 0x73, 0x7a, 0x28, 0x2a, 0xb, 0x13, 0x27, 0x0, 0x0, 0x6a, 0x3c, - 0x9, 0x0, 0x5, 0x8, 0xdf, 0xbf, 0x65, 0xe3, 0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; + uint8_t pkt[] = { + 0x34, 0x82, 0x2, 0x0, 0x4, 0xb0, 0x19, 0x67, 0xe9, 0x79, 0x87, 0xdb, 0x1, 0x18, 0x0, 0x0, 0x25, 0xb3, 0x12, + 0x0, 0x18, 0xbb, 0xc1, 0x5d, 0x99, 0x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 0x62, 0x6e, 0xa4, 0xa0, 0x2a, 0x58, 0xc0, 0xed, 0xc3, 0x6a, 0x73, 0x3f, 0xe2, 0xa3, + 0x38, 0x62, 0x78, 0xbb, 0x65, 0xa3, 0xb5, 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, + 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3370,61 +3539,134 @@ TEST(Publish5QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb, 0xac, 0x68, 0xf1, 0x7a, 0x9f, 0x5a, 0x27, 0x99, 0x68, 0x2, 0x69, 0x53, 0x2e, 0x2, - 0x26, 0x61, 0xa6, 0x7c, 0x93, 0x7e, 0x17, 0x62, 0x50, 0xc2, 0xf2, 0x24, 0x60, 0x71}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9b, 0x1d, 0x86, 0x68, 0xf1, 0x12, 0xae}; - lwmqtt_string_t exp_body = {7, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb0, 0x19, 0x67, 0xe9}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x65, 0xa3, 0xb5, 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, + 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 29118); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 7); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 7); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 31111); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "q+J\205\r\197\201+\DLE\216\DC4\207\206\SI\242\241\137\SUB\213\246\&1\NUL%\242b\204", _pubPktID = 0, _pubBody = -// "\137[\151L+\\\238\187\158\137/}8}\vL\159\208\134\DC4\192", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\169\&0\211V\249\144\&4+[\166\254\135\144\241\n\198\162\233\181\161i\132\132\ENQ\204\191", _pubPktID = 8952, +// _pubBody = "\173A\231|1\170\255\146o\191\190\DC2+uY", _pubProps = [PropSessionExpiryInterval +// 30113,PropAuthenticationData "F\253?\\\253\158\SYN\SOw\214\165\154\216\150G\189\234\235:\166",PropAuthenticationData +// "\233\DC1\174\158\255L\201\&1\254\155\229\213\228\150\156\220\234\159\&7\131*\249\208z\182\129n$",PropPayloadFormatIndicator +// 15,PropSessionExpiryInterval 21520,PropSubscriptionIdentifierAvailable 118,PropReasonString +// "\238\160|\130\186\233",PropResponseTopic "\165L\199\251m7H\RS\146 N\ESC1\163Pf",PropTopicAliasMaximum +// 10251,PropMaximumQoS 145,PropAuthenticationMethod +// "\155t\149\&8m\SUB\DC3\229\210\139\218\168\226\236,\143\195\DC4\a\RS\NUL2\193",PropTopicAlias +// 14385,PropCorrelationData +// "#\147\235m\194j\255_\202\196\148\166M\189\146\213\128\155K\236\237\150]h\RS6\212\STX\153\189",PropServerReference +// "\242",PropReceiveMaximum 30036,PropSubscriptionIdentifier 7,PropMessageExpiryInterval +// 20179,PropSubscriptionIdentifierAvailable 224,PropServerReference "="]} TEST(Publish5QCTest, Encode16) { - uint8_t pkt[] = {0x39, 0x32, 0x0, 0x1a, 0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, - 0xd8, 0x14, 0xcf, 0xce, 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, - 0x25, 0xf2, 0x62, 0xcc, 0x0, 0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, - 0x9e, 0x89, 0x2f, 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; - uint8_t topic_bytes[] = {0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, 0xd8, 0x14, 0xcf, 0xce, - 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, 0x25, 0xf2, 0x62, 0xcc}; + uint8_t pkt[] = {0x3b, 0xe6, 0x1, 0x0, 0x1a, 0xa9, 0x30, 0xd3, 0x56, 0xf9, 0x90, 0x34, 0x2b, 0x5b, 0xa6, 0xfe, 0x87, + 0x90, 0xf1, 0xa, 0xc6, 0xa2, 0xe9, 0xb5, 0xa1, 0x69, 0x84, 0x84, 0x5, 0xcc, 0xbf, 0x22, 0xf8, 0xb7, + 0x1, 0x11, 0x0, 0x0, 0x75, 0xa1, 0x16, 0x0, 0x14, 0x46, 0xfd, 0x3f, 0x5c, 0xfd, 0x9e, 0x16, 0xe, + 0x77, 0xd6, 0xa5, 0x9a, 0xd8, 0x96, 0x47, 0xbd, 0xea, 0xe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xfe, 0x87, 0x90, + 0xf1, 0xa, 0xc6, 0xa2, 0xe9, 0xb5, 0xa1, 0x69, 0x84, 0x84, 0x5, 0xcc, 0xbf}; lwmqtt_string_t topic = {26, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, 0x89, 0x2f, - 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; + uint8_t msg_bytes[] = {0xad, 0x41, 0xe7, 0x7c, 0x31, 0xaa, 0xff, 0x92, 0x6f, 0xbf, 0xbe, 0x12, 0x2b, 0x75, 0x59}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 15; + + uint8_t bytesprops0[] = {0x46, 0xfd, 0x3f, 0x5c, 0xfd, 0x9e, 0x16, 0xe, 0x77, 0xd6, + 0xa5, 0x9a, 0xd8, 0x96, 0x47, 0xbd, 0xea, 0xeb, 0x3a, 0xa6}; + uint8_t bytesprops1[] = {0xe9, 0x11, 0xae, 0x9e, 0xff, 0x4c, 0xc9, 0x31, 0xfe, 0x9b, 0xe5, 0xd5, 0xe4, 0x96, + 0x9c, 0xdc, 0xea, 0x9f, 0x37, 0x83, 0x2a, 0xf9, 0xd0, 0x7a, 0xb6, 0x81, 0x6e, 0x24}; + uint8_t bytesprops2[] = {0xee, 0xa0, 0x7c, 0x82, 0xba, 0xe9}; + uint8_t bytesprops3[] = {0xa5, 0x4c, 0xc7, 0xfb, 0x6d, 0x37, 0x48, 0x1e, + 0x92, 0x20, 0x4e, 0x1b, 0x31, 0xa3, 0x50, 0x66}; + uint8_t bytesprops4[] = {0x9b, 0x74, 0x95, 0x38, 0x6d, 0x1a, 0x13, 0xe5, 0xd2, 0x8b, 0xda, 0xa8, + 0xe2, 0xec, 0x2c, 0x8f, 0xc3, 0x14, 0x7, 0x1e, 0x0, 0x32, 0xc1}; + uint8_t bytesprops5[] = {0x23, 0x93, 0xeb, 0x6d, 0xc2, 0x6a, 0xff, 0x5f, 0xca, 0xc4, 0x94, 0xa6, 0x4d, 0xbd, 0x92, + 0xd5, 0x80, 0x9b, 0x4b, 0xec, 0xed, 0x96, 0x5d, 0x68, 0x1e, 0x36, 0xd4, 0x2, 0x99, 0xbd}; + uint8_t bytesprops6[] = {0xf2}; + uint8_t bytesprops7[] = {0x3d}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30113}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21520}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10251}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14385}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30036}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20179}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops7}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 8952, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "q+J\205\r\197\201+\DLE\216\DC4\207\206\SI\242\241\137\SUB\213\246\&1\NUL%\242b\204", _pubPktID = 0, _pubBody = -// "\137[\151L+\\\238\187\158\137/}8}\vL\159\208\134\DC4\192", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\169\&0\211V\249\144\&4+[\166\254\135\144\241\n\198\162\233\181\161i\132\132\ENQ\204\191", _pubPktID = 8952, +// _pubBody = "\173A\231|1\170\255\146o\191\190\DC2+uY", _pubProps = [PropSessionExpiryInterval +// 30113,PropAuthenticationData "F\253?\\\253\158\SYN\SOw\214\165\154\216\150G\189\234\235:\166",PropAuthenticationData +// "\233\DC1\174\158\255L\201\&1\254\155\229\213\228\150\156\220\234\159\&7\131*\249\208z\182\129n$",PropPayloadFormatIndicator +// 15,PropSessionExpiryInterval 21520,PropSubscriptionIdentifierAvailable 118,PropReasonString +// "\238\160|\130\186\233",PropResponseTopic "\165L\199\251m7H\RS\146 N\ESC1\163Pf",PropTopicAliasMaximum +// 10251,PropMaximumQoS 145,PropAuthenticationMethod +// "\155t\149\&8m\SUB\DC3\229\210\139\218\168\226\236,\143\195\DC4\a\RS\NUL2\193",PropTopicAlias +// 14385,PropCorrelationData +// "#\147\235m\194j\255_\202\196\148\166M\189\146\213\128\155K\236\237\150]h\RS6\212\STX\153\189",PropServerReference +// "\242",PropReceiveMaximum 30036,PropSubscriptionIdentifier 7,PropMessageExpiryInterval +// 20179,PropSubscriptionIdentifierAvailable 224,PropServerReference "="]} TEST(Publish5QCTest, Decode16) { - uint8_t pkt[] = {0x39, 0x32, 0x0, 0x1a, 0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, - 0xd8, 0x14, 0xcf, 0xce, 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, - 0x25, 0xf2, 0x62, 0xcc, 0x0, 0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, - 0x9e, 0x89, 0x2f, 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; + uint8_t pkt[] = {0x3b, 0xe6, 0x1, 0x0, 0x1a, 0xa9, 0x30, 0xd3, 0x56, 0xf9, 0x90, 0x34, 0x2b, 0x5b, 0xa6, 0xfe, 0x87, + 0x90, 0xf1, 0xa, 0xc6, 0xa2, 0xe9, 0xb5, 0xa1, 0x69, 0x84, 0x84, 0x5, 0xcc, 0xbf, 0x22, 0xf8, 0xb7, + 0x1, 0x11, 0x0, 0x0, 0x75, 0xa1, 0x16, 0x0, 0x14, 0x46, 0xfd, 0x3f, 0x5c, 0xfd, 0x9e, 0x16, 0xe, + 0x77, 0xd6, 0xa5, 0x9a, 0xd8, 0x96, 0x47, 0xbd, 0xea, 0xeb, 0x3a, 0xa6, 0x16, 0x0, 0x1c, 0xe9, 0x11, + 0xae, 0x9e, 0xff, 0x4c, 0xc9, 0x31, 0xfe, 0x9b, 0xe5, 0xd5, 0xe4, 0x96, 0x9c, 0xdc, 0xea, 0x9f, 0x37, + 0x83, 0x2a, 0xf9, 0xd0, 0x7a, 0xb6, 0x81, 0x6e, 0x24, 0x1, 0xf, 0x11, 0x0, 0x0, 0x54, 0x10, 0x29, + 0x76, 0x1f, 0x0, 0x6, 0xee, 0xa0, 0x7c, 0x82, 0xba, 0xe9, 0x8, 0x0, 0x10, 0xa5, 0x4c, 0xc7, 0xfb, + 0x6d, 0x37, 0x48, 0x1e, 0x92, 0x20, 0x4e, 0x1b, 0x31, 0xa3, 0x50, 0x66, 0x22, 0x28, 0xb, 0x24, 0x91, + 0x15, 0x0, 0x17, 0x9b, 0x74, 0x95, 0x38, 0x6d, 0x1a, 0x13, 0xe5, 0xd2, 0x8b, 0xda, 0xa8, 0xe2, 0xec, + 0x2c, 0x8f, 0xc3, 0x14, 0x7, 0x1e, 0x0, 0x32, 0xc1, 0x23, 0x38, 0x31, 0x9, 0x0, 0x1e, 0x23, 0x93, + 0xeb, 0x6d, 0xc2, 0x6a, 0xff, 0x5f, 0xca, 0xc4, 0x94, 0xa6, 0x4d, 0xbd, 0x92, 0xd5, 0x80, 0x9b, 0x4b, + 0xec, 0xed, 0x96, 0x5d, 0x68, 0x1e, 0x36, 0xd4, 0x2, 0x99, 0xbd, 0x1c, 0x0, 0x1, 0xf2, 0x21, 0x75, + 0x54, 0xb, 0x7, 0x2, 0x0, 0x0, 0x4e, 0xd3, 0x29, 0xe0, 0x1c, 0x0, 0x1, 0x3d, 0xad, 0x41, 0xe7, + 0x7c, 0x31, 0xaa, 0xff, 0x92, 0x6f, 0xbf, 0xbe, 0x12, 0x2b, 0x75, 0x59}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3433,150 +3675,144 @@ TEST(Publish5QCTest, Decode16) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x71, 0x2b, 0x4a, 0xcd, 0xd, 0xc5, 0xc9, 0x2b, 0x10, 0xd8, 0x14, 0xcf, 0xce, - 0xf, 0xf2, 0xf1, 0x89, 0x1a, 0xd5, 0xf6, 0x31, 0x0, 0x25, 0xf2, 0x62, 0xcc}; + uint8_t exp_topic_bytes[] = {0xa9, 0x30, 0xd3, 0x56, 0xf9, 0x90, 0x34, 0x2b, 0x5b, 0xa6, 0xfe, 0x87, 0x90, + 0xf1, 0xa, 0xc6, 0xa2, 0xe9, 0xb5, 0xa1, 0x69, 0x84, 0x84, 0x5, 0xcc, 0xbf}; lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x89, 0x5b, 0x97, 0x4c, 0x2b, 0x5c, 0xee, 0xbb, 0x9e, 0x89, 0x2f, - 0x7d, 0x38, 0x7d, 0xb, 0x4c, 0x9f, 0xd0, 0x86, 0x14, 0xc0}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_body_bytes[] = {0xad, 0x41, 0xe7, 0x7c, 0x31, 0xaa, 0xff, 0x92, 0x6f, 0xbf, 0xbe, 0x12, 0x2b, 0x75, 0x59}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); + EXPECT_EQ(packet_id, 8952); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "6", _pubPktID = 0, _pubBody = "b", -// _pubProps = [PropResponseTopic "l\135\EM",PropSessionExpiryInterval 27254,PropSubscriptionIdentifierAvailable -// 134,PropMaximumPacketSize 4947,PropRequestResponseInformation 129,PropServerReference -// "\152$\STX\215\220\243\246\202@\129_V%\158\176",PropServerReference "\246bNa\175@;\160\187\144o\232 -// ",PropServerReference "\246} \172\ETB?\252U\254\a\237Q\226WE\173\162b\163\217\246",PropMaximumPacketSize -// 23596,PropReasonString "]\CAN!\SUB\191~\131}S\202$f\141\155\&0~\189\ENQ^\228\203\206",PropContentType -// "@/\238{\253\142\158t\206&\143\160\&2\225\244\162x\195\r\235\DELx",PropReceiveMaximum 15263,PropCorrelationData -// "\241\234\181\&8\220^\161\239SU",PropAuthenticationData -// "\212\211G%\134\NUL&\185\242\159+\139J\177\177",PropResponseTopic -// "\230\238s\143\164\133-\212\SOV++\249\138",PropServerReference -// "PV\128\209\&0$\172M\231l\153\129\199\184\&84\244\152F\170C\225\179\208\b\137",PropMessageExpiryInterval -// 26834,PropServerKeepAlive 26744,PropRequestResponseInformation 214,PropTopicAlias 21354,PropServerReference -// "\164\244\229\233\151\187k}v\237",PropRetainAvailable 118,PropAuthenticationMethod -// "IX\131\171r\178\196u",PropTopicAliasMaximum 8893,PropCorrelationData "`\146\151\209}\EOT\177\230\236S"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\192!\207\251\220\139\197\DC3\237\227", _pubPktID = 0, _pubBody = +// "\245Ha\212\EM\NAK\214Qf\253*\177\142\202P\176\144\184\149N\DC4", _pubProps = [PropTopicAlias +// 3759,PropResponseInformation +// "\245\164\GS\240\187}\174_\151\ACK?s\DLE2\169+>\151\236\152c\182\b\170\246",PropAssignedClientIdentifier +// "\169\144\210\176\DLE\251Z\157\181.\146\208\224h\194DM\GS\167\NUL\250p\230dN",PropResponseInformation +// "X\142\143\234\134\SUB",PropSharedSubscriptionAvailable 170,PropAssignedClientIdentifier +// "5H\226\179\205\205:\DLE\EOT7\197",PropRequestProblemInformation 49,PropMaximumPacketSize +// 20134,PropAuthenticationData "\248'/Y\163M\183\162wG\"\214O\157\154\241_0\138\221\142\ENQ",PropAuthenticationData +// "\129\142\250\191\157\CANwJP\NUL\234\159\&2v\213{\ENQ\226",PropWillDelayInterval 29261,PropRequestResponseInformation +// 250,PropSubscriptionIdentifierAvailable 166,PropReceiveMaximum 5141,PropContentType +// "\248E\130iq\199\135\148\247\210\249\161\239",PropWillDelayInterval 13294,PropResponseTopic "\192\253\130 +// \186\b\183",PropReasonString "8\209Z\ETX\240uer\136F\242\SYNJZ\202\&2\216&\208\&4M6\146",PropReasonString +// "\242\&9h%\150{\204\238\219\162\231\248\194\216,D\178\194O\230\209\t5\134",PropMessageExpiryInterval 21649]} TEST(Publish5QCTest, Encode17) { uint8_t pkt[] = { - 0x31, 0x92, 0x2, 0x0, 0x1, 0x36, 0x8c, 0x2, 0x8, 0x0, 0x3, 0x6c, 0x87, 0x19, 0x11, 0x0, 0x0, 0x6a, 0x76, - 0x29, 0x86, 0x27, 0x0, 0x0, 0x13, 0x53, 0x19, 0x81, 0x1c, 0x0, 0xf, 0x98, 0x24, 0x2, 0xd7, 0xdc, 0xf3, 0xf6, - 0xca, 0x40, 0x81, 0x5f, 0x56, 0x25, 0x9e, 0xb0, 0x1c, 0x0, 0xd, 0xf6, 0x62, 0x4e, 0x61, 0xaf, 0x40, 0x3b, 0xa0, - 0xbb, 0x90, 0x6f, 0xe8, 0x20, 0x1c, 0x0, 0x15, 0xf6, 0x7d, 0x20, 0xac, 0x17, 0x3f, 0xfc, 0x55, 0xfe, 0x7, 0xed, - 0x51, 0xe2, 0x57, 0x45, 0xad, 0xa2, 0x62, 0xa3, 0xd9, 0xf6, 0x27, 0x0, 0x0, 0x5c, 0x2c, 0x1f, 0x0, 0x16, 0x5d, - 0x18, 0x21, 0x1a, 0xbf, 0x7e, 0x83, 0x7d, 0x53, 0xca, 0x24, 0x66, 0x8d, 0x9b, 0x30, 0x7e, 0xbd, 0x5, 0x5e, 0xe4, - 0xcb, 0xce, 0x3, 0x0, 0x16, 0x40, 0x2f, 0xee, 0x7b, 0xfd, 0x8e, 0x9e, 0x74, 0xce, 0x26, 0x8f, 0xa0, 0x32, 0xe1, - 0xf4, 0xa2, 0x78, 0xc3, 0xd, 0xeb, 0x7f, 0x78, 0x21, 0x3b, 0x9f, 0x9, 0x0, 0xa, 0xf1, 0xea, 0xb5, 0x38, 0xdc, - 0x5e, 0xa1, 0xef, 0x53, 0x55, 0x16, 0x0, 0xf, 0xd4, 0xd3, 0x47, 0x25, 0x86, 0x0, 0x26, 0xb9, 0xf2, 0x9f, 0x2b, - 0x8b, 0x4a, 0xb1, 0xb1, 0x8, 0x0, 0xe, 0xe6, 0xee, 0x73, 0x8f, 0xa4, 0x85, 0x2d, 0xd4, 0xe, 0x56, 0x2b, 0x2b, - 0xf9, 0x8a, 0x1c, 0x0, 0x1a, 0x50, 0x56, 0x80, 0xd1, 0x30, 0x24, 0xac, 0x4d, 0xe7, 0x6c, 0x99, 0x81, 0xc7, 0xb8, - 0x38, 0x34, 0xf4, 0x98, 0x46, 0xaa, 0x43, 0xe1, 0xb3, 0xd0, 0x8, 0x89, 0x2, 0x0, 0x0, 0x68, 0xd2, 0x13, 0x68, - 0x78, 0x19, 0xd6, 0x23, 0x53, 0x6a, 0x1c, 0x0, 0xa, 0xa4, 0xf4, 0xe5, 0xe9, 0x97, 0xbb, 0x6b, 0x7d, 0x76, 0xed, - 0x25, 0x76, 0x15, 0x0, 0x8, 0x49, 0x58, 0x83, 0xab, 0x72, 0xb2, 0xc4, 0x75, 0x22, 0x22, 0xbd, 0x9, 0x0, 0xa, - 0x60, 0x92, 0x97, 0xd1, 0x7d, 0x4, 0xb1, 0xe6, 0xec, 0x53, 0x62}; - uint8_t topic_bytes[] = {0x36}; - lwmqtt_string_t topic = {1, (char*)&topic_bytes}; + 0x38, 0x91, 0x2, 0x0, 0xa, 0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3, 0xee, 0x1, 0x23, 0xe, + 0xaf, 0x1a, 0x0, 0x19, 0xf5, 0xa4, 0x1d, 0x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a, 0x5a, 0xca, 0x32, 0xd8, 0x26, 0xd0, 0x34, 0x4d, 0x36, 0x92, 0x1f, 0x0, 0x18, 0xf2, 0x39, + 0x68, 0x25, 0x96, 0x7b, 0xcc, 0xee, 0xdb, 0xa2, 0xe7, 0xf8, 0xc2, 0xd8, 0x2c, 0x44, 0xb2, 0xc2, 0x4f, 0xe6, 0xd1, + 0x9, 0x35, 0x86, 0x2, 0x0, 0x0, 0x54, 0x91, 0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, + 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; + uint8_t topic_bytes[] = {0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3}; + lwmqtt_string_t topic = {10, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x62}; + msg.retained = false; + uint8_t msg_bytes[] = {0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, + 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 21; - uint8_t bytesprops0[] = {0x6c, 0x87, 0x19}; - uint8_t bytesprops1[] = {0x98, 0x24, 0x2, 0xd7, 0xdc, 0xf3, 0xf6, 0xca, 0x40, 0x81, 0x5f, 0x56, 0x25, 0x9e, 0xb0}; - uint8_t bytesprops2[] = {0xf6, 0x62, 0x4e, 0x61, 0xaf, 0x40, 0x3b, 0xa0, 0xbb, 0x90, 0x6f, 0xe8, 0x20}; - uint8_t bytesprops3[] = {0xf6, 0x7d, 0x20, 0xac, 0x17, 0x3f, 0xfc, 0x55, 0xfe, 0x7, 0xed, - 0x51, 0xe2, 0x57, 0x45, 0xad, 0xa2, 0x62, 0xa3, 0xd9, 0xf6}; - uint8_t bytesprops4[] = {0x5d, 0x18, 0x21, 0x1a, 0xbf, 0x7e, 0x83, 0x7d, 0x53, 0xca, 0x24, - 0x66, 0x8d, 0x9b, 0x30, 0x7e, 0xbd, 0x5, 0x5e, 0xe4, 0xcb, 0xce}; - uint8_t bytesprops5[] = {0x40, 0x2f, 0xee, 0x7b, 0xfd, 0x8e, 0x9e, 0x74, 0xce, 0x26, 0x8f, - 0xa0, 0x32, 0xe1, 0xf4, 0xa2, 0x78, 0xc3, 0xd, 0xeb, 0x7f, 0x78}; - uint8_t bytesprops6[] = {0xf1, 0xea, 0xb5, 0x38, 0xdc, 0x5e, 0xa1, 0xef, 0x53, 0x55}; - uint8_t bytesprops7[] = {0xd4, 0xd3, 0x47, 0x25, 0x86, 0x0, 0x26, 0xb9, 0xf2, 0x9f, 0x2b, 0x8b, 0x4a, 0xb1, 0xb1}; - uint8_t bytesprops8[] = {0xe6, 0xee, 0x73, 0x8f, 0xa4, 0x85, 0x2d, 0xd4, 0xe, 0x56, 0x2b, 0x2b, 0xf9, 0x8a}; - uint8_t bytesprops9[] = {0x50, 0x56, 0x80, 0xd1, 0x30, 0x24, 0xac, 0x4d, 0xe7, 0x6c, 0x99, 0x81, 0xc7, - 0xb8, 0x38, 0x34, 0xf4, 0x98, 0x46, 0xaa, 0x43, 0xe1, 0xb3, 0xd0, 0x8, 0x89}; - uint8_t bytesprops10[] = {0xa4, 0xf4, 0xe5, 0xe9, 0x97, 0xbb, 0x6b, 0x7d, 0x76, 0xed}; - uint8_t bytesprops11[] = {0x49, 0x58, 0x83, 0xab, 0x72, 0xb2, 0xc4, 0x75}; - uint8_t bytesprops12[] = {0x60, 0x92, 0x97, 0xd1, 0x7d, 0x4, 0xb1, 0xe6, 0xec, 0x53}; + uint8_t bytesprops0[] = {0xf5, 0xa4, 0x1d, 0xf0, 0xbb, 0x7d, 0xae, 0x5f, 0x97, 0x6, 0x3f, 0x73, 0x10, + 0x32, 0xa9, 0x2b, 0x3e, 0x97, 0xec, 0x98, 0x63, 0xb6, 0x8, 0xaa, 0xf6}; + uint8_t bytesprops1[] = {0xa9, 0x90, 0xd2, 0xb0, 0x10, 0xfb, 0x5a, 0x9d, 0xb5, 0x2e, 0x92, 0xd0, 0xe0, + 0x68, 0xc2, 0x44, 0x4d, 0x1d, 0xa7, 0x0, 0xfa, 0x70, 0xe6, 0x64, 0x4e}; + uint8_t bytesprops2[] = {0x58, 0x8e, 0x8f, 0xea, 0x86, 0x1a}; + uint8_t bytesprops3[] = {0x35, 0x48, 0xe2, 0xb3, 0xcd, 0xcd, 0x3a, 0x10, 0x4, 0x37, 0xc5}; + uint8_t bytesprops4[] = {0xf8, 0x27, 0x2f, 0x59, 0xa3, 0x4d, 0xb7, 0xa2, 0x77, 0x47, 0x22, + 0xd6, 0x4f, 0x9d, 0x9a, 0xf1, 0x5f, 0x30, 0x8a, 0xdd, 0x8e, 0x5}; + uint8_t bytesprops5[] = {0x81, 0x8e, 0xfa, 0xbf, 0x9d, 0x18, 0x77, 0x4a, 0x50, + 0x0, 0xea, 0x9f, 0x32, 0x76, 0xd5, 0x7b, 0x5, 0xe2}; + uint8_t bytesprops6[] = {0xf8, 0x45, 0x82, 0x69, 0x71, 0xc7, 0x87, 0x94, 0xf7, 0xd2, 0xf9, 0xa1, 0xef}; + uint8_t bytesprops7[] = {0xc0, 0xfd, 0x82, 0x20, 0xba, 0x8, 0xb7}; + uint8_t bytesprops8[] = {0x38, 0xd1, 0x5a, 0x3, 0xf0, 0x75, 0x65, 0x72, 0x88, 0x46, 0xf2, 0x16, + 0x4a, 0x5a, 0xca, 0x32, 0xd8, 0x26, 0xd0, 0x34, 0x4d, 0x36, 0x92}; + uint8_t bytesprops9[] = {0xf2, 0x39, 0x68, 0x25, 0x96, 0x7b, 0xcc, 0xee, 0xdb, 0xa2, 0xe7, 0xf8, + 0xc2, 0xd8, 0x2c, 0x44, 0xb2, 0xc2, 0x4f, 0xe6, 0xd1, 0x9, 0x35, 0x86}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27254}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4947}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23596}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15263}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26834}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26744}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21354}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8893}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3759}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20134}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29261}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5141}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13294}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21649}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "6", _pubPktID = 0, _pubBody = "b", -// _pubProps = [PropResponseTopic "l\135\EM",PropSessionExpiryInterval 27254,PropSubscriptionIdentifierAvailable -// 134,PropMaximumPacketSize 4947,PropRequestResponseInformation 129,PropServerReference -// "\152$\STX\215\220\243\246\202@\129_V%\158\176",PropServerReference "\246bNa\175@;\160\187\144o\232 -// ",PropServerReference "\246} \172\ETB?\252U\254\a\237Q\226WE\173\162b\163\217\246",PropMaximumPacketSize -// 23596,PropReasonString "]\CAN!\SUB\191~\131}S\202$f\141\155\&0~\189\ENQ^\228\203\206",PropContentType -// "@/\238{\253\142\158t\206&\143\160\&2\225\244\162x\195\r\235\DELx",PropReceiveMaximum 15263,PropCorrelationData -// "\241\234\181\&8\220^\161\239SU",PropAuthenticationData -// "\212\211G%\134\NUL&\185\242\159+\139J\177\177",PropResponseTopic -// "\230\238s\143\164\133-\212\SOV++\249\138",PropServerReference -// "PV\128\209\&0$\172M\231l\153\129\199\184\&84\244\152F\170C\225\179\208\b\137",PropMessageExpiryInterval -// 26834,PropServerKeepAlive 26744,PropRequestResponseInformation 214,PropTopicAlias 21354,PropServerReference -// "\164\244\229\233\151\187k}v\237",PropRetainAvailable 118,PropAuthenticationMethod -// "IX\131\171r\178\196u",PropTopicAliasMaximum 8893,PropCorrelationData "`\146\151\209}\EOT\177\230\236S"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\192!\207\251\220\139\197\DC3\237\227", _pubPktID = 0, _pubBody = +// "\245Ha\212\EM\NAK\214Qf\253*\177\142\202P\176\144\184\149N\DC4", _pubProps = [PropTopicAlias +// 3759,PropResponseInformation +// "\245\164\GS\240\187}\174_\151\ACK?s\DLE2\169+>\151\236\152c\182\b\170\246",PropAssignedClientIdentifier +// "\169\144\210\176\DLE\251Z\157\181.\146\208\224h\194DM\GS\167\NUL\250p\230dN",PropResponseInformation +// "X\142\143\234\134\SUB",PropSharedSubscriptionAvailable 170,PropAssignedClientIdentifier +// "5H\226\179\205\205:\DLE\EOT7\197",PropRequestProblemInformation 49,PropMaximumPacketSize +// 20134,PropAuthenticationData "\248'/Y\163M\183\162wG\"\214O\157\154\241_0\138\221\142\ENQ",PropAuthenticationData +// "\129\142\250\191\157\CANwJP\NUL\234\159\&2v\213{\ENQ\226",PropWillDelayInterval 29261,PropRequestResponseInformation +// 250,PropSubscriptionIdentifierAvailable 166,PropReceiveMaximum 5141,PropContentType +// "\248E\130iq\199\135\148\247\210\249\161\239",PropWillDelayInterval 13294,PropResponseTopic "\192\253\130 +// \186\b\183",PropReasonString "8\209Z\ETX\240uer\136F\242\SYNJZ\202\&2\216&\208\&4M6\146",PropReasonString +// "\242\&9h%\150{\204\238\219\162\231\248\194\216,D\178\194O\230\209\t5\134",PropMessageExpiryInterval 21649]} TEST(Publish5QCTest, Decode17) { uint8_t pkt[] = { - 0x31, 0x92, 0x2, 0x0, 0x1, 0x36, 0x8c, 0x2, 0x8, 0x0, 0x3, 0x6c, 0x87, 0x19, 0x11, 0x0, 0x0, 0x6a, 0x76, - 0x29, 0x86, 0x27, 0x0, 0x0, 0x13, 0x53, 0x19, 0x81, 0x1c, 0x0, 0xf, 0x98, 0x24, 0x2, 0xd7, 0xdc, 0xf3, 0xf6, - 0xca, 0x40, 0x81, 0x5f, 0x56, 0x25, 0x9e, 0xb0, 0x1c, 0x0, 0xd, 0xf6, 0x62, 0x4e, 0x61, 0xaf, 0x40, 0x3b, 0xa0, - 0xbb, 0x90, 0x6f, 0xe8, 0x20, 0x1c, 0x0, 0x15, 0xf6, 0x7d, 0x20, 0xac, 0x17, 0x3f, 0xfc, 0x55, 0xfe, 0x7, 0xed, - 0x51, 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0x82, 0x69, 0x71, 0xc7, 0x87, 0x94, 0xf7, 0xd2, 0xf9, 0xa1, 0xef, 0x18, 0x0, 0x0, 0x33, 0xee, 0x8, 0x0, 0x7, + 0xc0, 0xfd, 0x82, 0x20, 0xba, 0x8, 0xb7, 0x1f, 0x0, 0x17, 0x38, 0xd1, 0x5a, 0x3, 0xf0, 0x75, 0x65, 0x72, 0x88, + 0x46, 0xf2, 0x16, 0x4a, 0x5a, 0xca, 0x32, 0xd8, 0x26, 0xd0, 0x34, 0x4d, 0x36, 0x92, 0x1f, 0x0, 0x18, 0xf2, 0x39, + 0x68, 0x25, 0x96, 0x7b, 0xcc, 0xee, 0xdb, 0xa2, 0xe7, 0xf8, 0xc2, 0xd8, 0x2c, 0x44, 0xb2, 0xc2, 0x4f, 0xe6, 0xd1, + 0x9, 0x35, 0x86, 0x2, 0x0, 0x0, 0x54, 0x91, 0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, + 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3585,52 +3821,87 @@ TEST(Publish5QCTest, Decode17) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x36}; - lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x62}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3}; + lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, + 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\184\EOT\177\237[w\205\DC4E\GS@", -// _pubPktID = 11334, _pubBody = "\247ax\ESCb", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\244\163\195\181~\198`:\150F\212N", +// _pubPktID = 32625, _pubBody = +// "\158m\139\172\171\135\&7\154\136\129\210{\228\197\SI[\STXw\192\242\239k\178\152Q\211\143S\146", _pubProps = +// [PropRetainAvailable 200,PropUserProperty "%\166w" "",PropReasonString "\237\166:\221\247RP\b",PropResponseTopic +// "F\161\242\a\175\186\140'\182\EOT=\208-\218\EOTL\225",PropAuthenticationData +// "\154?.'<\181\175R\167\197j\217\183\232\r\134\216\215\n\EOT",PropSubscriptionIdentifier 28]} TEST(Publish5QCTest, Encode18) { - uint8_t pkt[] = {0x3b, 0x16, 0x0, 0xc, 0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, - 0x14, 0x45, 0x1d, 0x40, 0x2c, 0x46, 0x0, 0xf7, 0x61, 0x78, 0x1b, 0x62}; - uint8_t topic_bytes[] = {0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, 0x14, 0x45, 0x1d, 0x40}; + uint8_t pkt[] = {0x33, 0x70, 0x0, 0xc, 0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e, 0x7f, + 0x71, 0x42, 0x25, 0xc8, 0x26, 0x0, 0x3, 0x25, 0xa6, 0x77, 0x0, 0x0, 0x1f, 0x0, 0x8, 0xed, 0xa6, + 0x3a, 0xdd, 0xf7, 0x52, 0x50, 0x8, 0x8, 0x0, 0x11, 0x46, 0xa1, 0xf2, 0x7, 0xaf, 0xba, 0x8c, 0x27, + 0xb6, 0x4, 0x3d, 0xd0, 0x2d, 0xda, 0x4, 0x4c, 0xe1, 0x16, 0x0, 0x14, 0x9a, 0x3f, 0x2e, 0x27, 0x3c, + 0xb5, 0xaf, 0x52, 0xa7, 0xc5, 0x6a, 0xd9, 0xb7, 0xe8, 0xd, 0x86, 0xd8, 0xd7, 0xa, 0x4, 0xb, 0x1c, + 0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, 0x5b, 0x2, + 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; + uint8_t topic_bytes[] = {0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e}; lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xf7, 0x61, 0x78, 0x1b, 0x62}; + uint8_t msg_bytes[] = {0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, + 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 5; + msg.payload_len = 29; - lwmqtt_property_t propslist[] = {}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops0[] = {0x25, 0xa6, 0x77}; + uint8_t bytesprops2[] = {0xed, 0xa6, 0x3a, 0xdd, 0xf7, 0x52, 0x50, 0x8}; + uint8_t bytesprops3[] = {0x46, 0xa1, 0xf2, 0x7, 0xaf, 0xba, 0x8c, 0x27, 0xb6, + 0x4, 0x3d, 0xd0, 0x2d, 0xda, 0x4, 0x4c, 0xe1}; + uint8_t bytesprops4[] = {0x9a, 0x3f, 0x2e, 0x27, 0x3c, 0xb5, 0xaf, 0x52, 0xa7, 0xc5, + 0x6a, 0xd9, 0xb7, 0xe8, 0xd, 0x86, 0xd8, 0xd7, 0xa, 0x4}; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + }; + + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 11334, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32625, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\150\184\EOT\177\237[w\205\DC4E\GS@", -// _pubPktID = 11334, _pubBody = "\247ax\ESCb", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\244\163\195\181~\198`:\150F\212N", +// _pubPktID = 32625, _pubBody = +// "\158m\139\172\171\135\&7\154\136\129\210{\228\197\SI[\STXw\192\242\239k\178\152Q\211\143S\146", _pubProps = +// [PropRetainAvailable 200,PropUserProperty "%\166w" "",PropReasonString "\237\166:\221\247RP\b",PropResponseTopic +// "F\161\242\a\175\186\140'\182\EOT=\208-\218\EOTL\225",PropAuthenticationData +// "\154?.'<\181\175R\167\197j\217\183\232\r\134\216\215\n\EOT",PropSubscriptionIdentifier 28]} TEST(Publish5QCTest, Decode18) { - uint8_t pkt[] = {0x3b, 0x16, 0x0, 0xc, 0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, - 0x14, 0x45, 0x1d, 0x40, 0x2c, 0x46, 0x0, 0xf7, 0x61, 0x78, 0x1b, 0x62}; + uint8_t pkt[] = {0x33, 0x70, 0x0, 0xc, 0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e, 0x7f, + 0x71, 0x42, 0x25, 0xc8, 0x26, 0x0, 0x3, 0x25, 0xa6, 0x77, 0x0, 0x0, 0x1f, 0x0, 0x8, 0xed, 0xa6, + 0x3a, 0xdd, 0xf7, 0x52, 0x50, 0x8, 0x8, 0x0, 0x11, 0x46, 0xa1, 0xf2, 0x7, 0xaf, 0xba, 0x8c, 0x27, + 0xb6, 0x4, 0x3d, 0xd0, 0x2d, 0xda, 0x4, 0x4c, 0xe1, 0x16, 0x0, 0x14, 0x9a, 0x3f, 0x2e, 0x27, 0x3c, + 0xb5, 0xaf, 0x52, 0xa7, 0xc5, 0x6a, 0xd9, 0xb7, 0xe8, 0xd, 0x86, 0xd8, 0xd7, 0xa, 0x4, 0xb, 0x1c, + 0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, 0x5b, 0x2, + 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3639,126 +3910,165 @@ TEST(Publish5QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x96, 0xb8, 0x4, 0xb1, 0xed, 0x5b, 0x77, 0xcd, 0x14, 0x45, 0x1d, 0x40}; + uint8_t exp_topic_bytes[] = {0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e}; lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf7, 0x61, 0x78, 0x1b, 0x62}; - lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_body_bytes[] = {0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, + 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 11334); + EXPECT_EQ(packet_id, 32625); EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 5); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\tm5\139\DC1\DC18\255>\b\a\EM\145\213XbT\218|", _pubPktID = 0, _pubBody = "\DC4\GS+\EM\ESC\132B\172\232|\215", -// _pubProps = [PropTopicAliasMaximum 14496,PropServerReference -// "\176\251s\234\234\&2\201O&\DLE",PropSharedSubscriptionAvailable 24,PropUserProperty -// "\249Z\DC3\EOT\145\166\&4\182U\162t}\DC2\139\128]1\211@L\DC22&M\157\&7" -// "\254\223\&7\220BMq\175Un",PropMaximumPacketSize 6785,PropServerKeepAlive 10085,PropPayloadFormatIndicator -// 74,PropAuthenticationData "\213\150\137\148W\231\160",PropTopicAliasMaximum 7081,PropContentType -// "\155A\166\188\NAK,\180\206\154\226j\f!\160",PropWillDelayInterval 17165,PropMaximumPacketSize -// 15345,PropAuthenticationData -// "\206@\151\167\b\a\EM\145\213XbT\218|", _pubPktID = 0, _pubBody = "\DC4\GS+\EM\ESC\132B\172\232|\215", -// _pubProps = [PropTopicAliasMaximum 14496,PropServerReference -// "\176\251s\234\234\&2\201O&\DLE",PropSharedSubscriptionAvailable 24,PropUserProperty -// "\249Z\DC3\EOT\145\166\&4\182U\162t}\DC2\139\128]1\211@L\DC22&M\157\&7" -// "\254\223\&7\220BMq\175Un",PropMaximumPacketSize 6785,PropServerKeepAlive 10085,PropPayloadFormatIndicator -// 74,PropAuthenticationData "\213\150\137\148W\231\160",PropTopicAliasMaximum 7081,PropContentType -// "\155A\166\188\NAK,\180\206\154\226j\f!\160",PropWillDelayInterval 17165,PropMaximumPacketSize -// 15345,PropAuthenticationData -// "\206@\151\167(topic.data), 19); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); - lwmqtt_string_t x = exp_topic; - x = exp_body; + EXPECT_EQ(packet_id, 25006); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + lwmqtt_string_t x = exp_topic; + x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\211Q\204\149\142\&8\217\174\213\221\133\214\221\166\207E\151\t\221y\192>\ETBqK[", _pubPktID = 0, _pubBody = -// "\189\221\169\130\f\211\DC1\DC2\252", _pubProps = [PropWildcardSubscriptionAvailable 130,PropRetainAvailable -// 210,PropPayloadFormatIndicator 124,PropReasonString "\SIO\248m?>tR\149\216l\CANUVY\236",PropMessageExpiryInterval -// 13933,PropRequestResponseInformation 138,PropSharedSubscriptionAvailable 224,PropWildcardSubscriptionAvailable 148]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\239p\183", _pubPktID = 0, _pubBody +// = "\STX\249\&8\215\vJ\163\136\174\235\187\163\ESCJ(\246", _pubProps = [PropResponseInformation +// "\235SGi\157",PropMaximumQoS 13,PropTopicAliasMaximum 11062,PropRetainAvailable 5,PropContentType +// "\225T\209m5\145\241\225\244VH\131\192",PropServerReference +// "\147\213\137%\253\130\240A~=\245\208KQ\252\225\170\182\237\162x\",\\",PropTopicAliasMaximum +// 4266,PropAuthenticationMethod "T\237o\195;\130\&2/",PropSubscriptionIdentifier 26,PropSharedSubscriptionAvailable +// 217,PropMessageExpiryInterval 25018,PropReasonString "\171%",PropSubscriptionIdentifier 12,PropTopicAlias +// 23933,PropServerKeepAlive 18136,PropReasonString +// "\f\141$cR\131\&2f6\157\157R\SO`\238-\f\245m\221\&2\DC1\128C\182\143\250",PropAuthenticationData +// "{\197\227\&1\ETB\SYN\GS\190l\243",PropContentType +// "\245>C;\130\233{R\215\DLED\226K",PropWildcardSubscriptionAvailable 158,PropMessageExpiryInterval +// 14738,PropRequestResponseInformation 28,PropMaximumPacketSize 12465,PropMaximumQoS 234,PropReceiveMaximum +// 4522,PropPayloadFormatIndicator 153,PropTopicAlias 5567,PropRetainAvailable 217]} TEST(Publish5QCTest, Encode20) { - uint8_t pkt[] = {0x30, 0x4a, 0x0, 0x1a, 0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, - 0xdd, 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b, 0x24, 0x28, - 0x82, 0x25, 0xd2, 0x1, 0x7c, 0x1f, 0x0, 0x10, 0xf, 0x4f, 0xf8, 0x6d, 0x3f, 0x3e, 0x74, 0x52, - 0x95, 0xd8, 0x6c, 0x18, 0x55, 0x56, 0x59, 0xec, 0x2, 0x0, 0x0, 0x36, 0x6d, 0x19, 0x8a, 0x2a, - 0xe0, 0x28, 0x94, 0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; - uint8_t topic_bytes[] = {0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, 0xdd, - 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x31, 0xca, 0x1, 0x0, 0x3, 0xef, 0x70, 0xb7, 0xb3, 0x1, 0x1a, 0x0, 0x5, 0xeb, 0x53, 0x47, 0x69, 0x9d, 0x24, + 0xd, 0x22, 0x2b, 0x36, 0x25, 0x5, 0x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_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; + msg.retained = true; + uint8_t msg_bytes[] = {0x2, 0xf9, 0x38, 0xd7, 0xb, 0x4a, 0xa3, 0x88, 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 16; - uint8_t bytesprops0[] = {0xf, 0x4f, 0xf8, 0x6d, 0x3f, 0x3e, 0x74, 0x52, - 0x95, 0xd8, 0x6c, 0x18, 0x55, 0x56, 0x59, 0xec}; + uint8_t bytesprops0[] = {0xeb, 0x53, 0x47, 0x69, 0x9d}; + uint8_t bytesprops1[] = {0xe1, 0x54, 0xd1, 0x6d, 0x35, 0x91, 0xf1, 0xe1, 0xf4, 0x56, 0x48, 0x83, 0xc0}; + uint8_t bytesprops2[] = {0x93, 0xd5, 0x89, 0x25, 0xfd, 0x82, 0xf0, 0x41, 0x7e, 0x3d, 0xf5, 0xd0, + 0x4b, 0x51, 0xfc, 0xe1, 0xaa, 0xb6, 0xed, 0xa2, 0x78, 0x22, 0x2c, 0x5c}; + uint8_t bytesprops3[] = {0x54, 0xed, 0x6f, 0xc3, 0x3b, 0x82, 0x32, 0x2f}; + uint8_t bytesprops4[] = {0xab, 0x25}; + uint8_t bytesprops5[] = {0xc, 0x8d, 0x24, 0x63, 0x52, 0x83, 0x32, 0x66, 0x36, 0x9d, 0x9d, 0x52, 0xe, 0x60, + 0xee, 0x2d, 0xc, 0xf5, 0x6d, 0xdd, 0x32, 0x11, 0x80, 0x43, 0xb6, 0x8f, 0xfa}; + uint8_t bytesprops6[] = {0x7b, 0xc5, 0xe3, 0x31, 0x17, 0x16, 0x1d, 0xbe, 0x6c, 0xf3}; + uint8_t bytesprops7[] = {0xf5, 0x3e, 0x43, 0x3b, 0x82, 0xe9, 0x7b, 0x52, 0xd7, 0x10, 0x44, 0xe2, 0x4b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13933}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11062}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4266}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25018}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23933}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18136}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14738}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12465}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4522}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5567}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 217}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); @@ -3828,17 +4179,32 @@ TEST(Publish5QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\211Q\204\149\142\&8\217\174\213\221\133\214\221\166\207E\151\t\221y\192>\ETBqK[", _pubPktID = 0, _pubBody = -// "\189\221\169\130\f\211\DC1\DC2\252", _pubProps = [PropWildcardSubscriptionAvailable 130,PropRetainAvailable -// 210,PropPayloadFormatIndicator 124,PropReasonString "\SIO\248m?>tR\149\216l\CANUVY\236",PropMessageExpiryInterval -// 13933,PropRequestResponseInformation 138,PropSharedSubscriptionAvailable 224,PropWildcardSubscriptionAvailable 148]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\239p\183", _pubPktID = 0, _pubBody +// = "\STX\249\&8\215\vJ\163\136\174\235\187\163\ESCJ(\246", _pubProps = [PropResponseInformation +// "\235SGi\157",PropMaximumQoS 13,PropTopicAliasMaximum 11062,PropRetainAvailable 5,PropContentType +// "\225T\209m5\145\241\225\244VH\131\192",PropServerReference +// "\147\213\137%\253\130\240A~=\245\208KQ\252\225\170\182\237\162x\",\\",PropTopicAliasMaximum +// 4266,PropAuthenticationMethod "T\237o\195;\130\&2/",PropSubscriptionIdentifier 26,PropSharedSubscriptionAvailable +// 217,PropMessageExpiryInterval 25018,PropReasonString "\171%",PropSubscriptionIdentifier 12,PropTopicAlias +// 23933,PropServerKeepAlive 18136,PropReasonString +// "\f\141$cR\131\&2f6\157\157R\SO`\238-\f\245m\221\&2\DC1\128C\182\143\250",PropAuthenticationData +// "{\197\227\&1\ETB\SYN\GS\190l\243",PropContentType +// "\245>C;\130\233{R\215\DLED\226K",PropWildcardSubscriptionAvailable 158,PropMessageExpiryInterval +// 14738,PropRequestResponseInformation 28,PropMaximumPacketSize 12465,PropMaximumQoS 234,PropReceiveMaximum +// 4522,PropPayloadFormatIndicator 153,PropTopicAlias 5567,PropRetainAvailable 217]} TEST(Publish5QCTest, Decode20) { - uint8_t pkt[] = {0x30, 0x4a, 0x0, 0x1a, 0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, - 0xdd, 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b, 0x24, 0x28, - 0x82, 0x25, 0xd2, 0x1, 0x7c, 0x1f, 0x0, 0x10, 0xf, 0x4f, 0xf8, 0x6d, 0x3f, 0x3e, 0x74, 0x52, - 0x95, 0xd8, 0x6c, 0x18, 0x55, 0x56, 0x59, 0xec, 0x2, 0x0, 0x0, 0x36, 0x6d, 0x19, 0x8a, 0x2a, - 0xe0, 0x28, 0x94, 0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; + uint8_t pkt[]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, 0xd9, 0x2, + 0xf9, 0x38, 0xd7, 0xb, 0x4a, 0xa3, 0x88, 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3847,113 +4213,102 @@ TEST(Publish5QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xd3, 0x51, 0xcc, 0x95, 0x8e, 0x38, 0xd9, 0xae, 0xd5, 0xdd, 0x85, 0xd6, 0xdd, - 0xa6, 0xcf, 0x45, 0x97, 0x9, 0xdd, 0x79, 0xc0, 0x3e, 0x17, 0x71, 0x4b, 0x5b}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbd, 0xdd, 0xa9, 0x82, 0xc, 0xd3, 0x11, 0x12, 0xfc}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xef, 0x70, 0xb7}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2, 0xf9, 0x38, 0xd7, 0xb, 0x4a, 0xa3, 0x88, + 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "p\211K\218>w\SOHst%h%\249P\an\SYNF\157q=]", _pubPktID = 0, _pubBody = "\135 \184\208\200\r\GSu\205w\SOHst%h%\249P\an\SYNF\157q=]", _pubPktID = 0, _pubBody = "\135 \184\208\200\r\GSu\205(topic.data), 22); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\249", _pubPktID = 7383, _pubBody = -// "\166\v\241D\ESCtx4\151\196\206=\239 r\RS\159\195\249NT_", _pubProps = [PropPayloadFormatIndicator -// 118,PropWillDelayInterval 17649,PropServerKeepAlive 8042,PropSessionExpiryInterval 18970]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "D\SO\EOTH\207S\243\176T\n\246\234'~^\ETBtz\220X", _pubPktID = 0, _pubBody = +// "\179>\ENQUu\215k\216\ETX\201m\DC2\251\&2\ETB\187m\200\248\140{\n8", _pubProps = [PropServerReference +// "\DLEE>i\167+\232\177\165\211\CAN\162F4\143*\251\GS\206",PropReceiveMaximum 15189,PropAuthenticationData +// "{Q\174\191\n\216\188",PropSharedSubscriptionAvailable 244,PropResponseInformation +// "#\175^\233\133\154I\187",PropMessageExpiryInterval 854,PropResponseTopic "\248\245\237n",PropResponseTopic +// "\137a\227ZD\136",PropResponseTopic ")\GS",PropRetainAvailable 56,PropWildcardSubscriptionAvailable +// 220,PropSubscriptionIdentifierAvailable 177,PropMaximumQoS 216,PropReceiveMaximum +// 21295,PropSharedSubscriptionAvailable 193,PropWillDelayInterval 30278,PropSessionExpiryInterval 21047,PropMaximumQoS +// 120,PropWillDelayInterval 18244,PropRequestResponseInformation 191,PropMessageExpiryInterval 24947,PropUserProperty +// "\149\165\NUL\253\137\219\t" +// "\146\DC2\216u\164\ESC\153dVP\b\174v\162~\222\140\204\b\STX\143)\245\243H\241\199\154\216\199",PropAuthenticationData +// "c\203\158",PropSubscriptionIdentifierAvailable 114,PropSubscriptionIdentifierAvailable 194,PropAuthenticationMethod +// "\SI",PropCorrelationData "E(\233\128|\205\178\136\SOH\DC3\216\&9\240W\ENQUu\215k\216\ETX\201m\DC2\251\&2\ETB\187m\200\248\140{\n8", _pubProps = [PropServerReference +// "\DLEE>i\167+\232\177\165\211\CAN\162F4\143*\251\GS\206",PropReceiveMaximum 15189,PropAuthenticationData +// "{Q\174\191\n\216\188",PropSharedSubscriptionAvailable 244,PropResponseInformation +// "#\175^\233\133\154I\187",PropMessageExpiryInterval 854,PropResponseTopic "\248\245\237n",PropResponseTopic +// "\137a\227ZD\136",PropResponseTopic ")\GS",PropRetainAvailable 56,PropWildcardSubscriptionAvailable +// 220,PropSubscriptionIdentifierAvailable 177,PropMaximumQoS 216,PropReceiveMaximum +// 21295,PropSharedSubscriptionAvailable 193,PropWillDelayInterval 30278,PropSessionExpiryInterval 21047,PropMaximumQoS +// 120,PropWillDelayInterval 18244,PropRequestResponseInformation 191,PropMessageExpiryInterval 24947,PropUserProperty +// "\149\165\NUL\253\137\219\t" +// "\146\DC2\216u\164\ESC\153dVP\b\174v\162~\222\140\204\b\STX\143)\245\243H\241\199\154\216\199",PropAuthenticationData +// "c\203\158",PropSubscriptionIdentifierAvailable 114,PropSubscriptionIdentifierAvailable 194,PropAuthenticationMethod +// "\SI",PropCorrelationData "E(\233\128|\205\178\136\SOH\DC3\216\&9\240W(topic.data), 1); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\156\249\196\168\224\205\FS\219\244\128\231\SYN\252\239j\NAK\164\171G]\133\229\147Q\199(\f\249y", _pubPktID = 11390, -// _pubBody = "s\226]\184\NUL\176A\242\&3\195\ETBC\RSN\254\t\t\\\203\255=\180B\201k\163", _pubProps = [PropResponseTopic -// "\FS,J\229`\170\204\255\133\133G\208(]+j\132\230x\244\CAN\148\143\227\151H",PropMessageExpiryInterval -// 23325,PropUserProperty "\224\150\SUB\154\&6d:y\142\239\232\RS_\181CY\184\150\254\242\226\a\"\132\159#\158Fk" -// "\ESC\180|3&\134",PropAuthenticationMethod "\230\198",PropAuthenticationData -// "\255\246\195f\b,.\176\150\222",PropResponseTopic "\182\CANu\SOH\SO\151\224@N -// \200\220\199\168S\NAKD\NAK'\DC3\fA\243\135\195\147^",PropRetainAvailable 157,PropServerReference -// "V?\225\174\237\154y9\175\195oX\212d\182\214\157\vb\239\157-p\US\155>\ACK\242",PropRequestResponseInformation -// 114,PropSubscriptionIdentifier 23,PropAssignedClientIdentifier -// "\221\200\143\NUL\229\132\232H`2O\213\DC1\SOHL\142\bz\241\138\167A",PropTopicAliasMaximum 14201,PropServerReference -// "c\146\NAK\140cS\135G\172?j\144\244\232\141g\239F\DC4\ETB#\255\r\207\&7\129N\183\143",PropAuthenticationMethod -// "R\141\240\142\180Ky",PropMaximumPacketSize 27523,PropSessionExpiryInterval 9563,PropAssignedClientIdentifier -// "V\229\STX\153\n\153\DC2\204=\DC4\147B\b\153\169\175\191CW"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\178\144*)\STX\195\&3\195\193\213~9\191FW\136R", _pubPktID = 0, _pubBody = "\155U0$\ENQ\134dV\214\ts.+\ETX\143", +// _pubProps = [PropCorrelationData "\208\213\188\228\159~\156\197P\146a",PropResponseInformation "Jk +// ,\178\176\200\140\fi\137p\253k\172E`\139J\221\&4\197p\166AO\180\169\238\198",PropMaximumPacketSize +// 9290,PropUserProperty "o\187\161\DEL;" +// "\200\&1z\DC3\250`\228\&2t?@\DC3\165\131K\USq\GS\170\212S",PropWillDelayInterval 4415,PropResponseTopic +// "\137\173\CAN\ENQ\205B\\\222\SOH~\230a",PropResponseInformation "B\136e&\153\161\f\ESCCP\132\131$\SIj\191"]} TEST(Publish5QCTest, Encode23) { - uint8_t pkt[] = { - 0x3a, 0xc2, 0x2, 0x0, 0x1d, 0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, - 0x6a, 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, 0x79, 0x2c, 0x7e, 0x85, 0x2, - 0x8, 0x0, 0x1a, 0x1c, 0x2c, 0x4a, 0xe5, 0x60, 0xaa, 0xcc, 0xff, 0x85, 0x85, 0x47, 0xd0, 0x28, 0x5d, 0x2b, 0x6a, - 0x84, 0xe6, 0x78, 0xf4, 0x18, 0x94, 0x8f, 0xe3, 0x97, 0x48, 0x2, 0x0, 0x0, 0x5b, 0x1d, 0x26, 0x0, 0x1d, 0xe0, - 0x96, 0x1a, 0x9a, 0x36, 0x64, 0x3a, 0x79, 0x8e, 0xef, 0xe8, 0x1e, 0x5f, 0xb5, 0x43, 0x59, 0xb8, 0x96, 0xfe, 0xf2, - 0xe2, 0x7, 0x22, 0x84, 0x9f, 0x23, 0x9e, 0x46, 0x6b, 0x0, 0x6, 0x1b, 0xb4, 0x7c, 0x33, 0x26, 0x86, 0x15, 0x0, -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d, 0xb8, 0x0, - 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, - 0x6b, 0xa3}; - uint8_t topic_bytes[] = {0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, 0x6a, - 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, 0x79}; - lwmqtt_string_t topic = {29, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x9d, 0x1, 0x0, 0x11, 0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, 0xd5, 0x7e, + 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52, 0x7a, 0x9, 0x0, 0xb, 0xd0, 0xd5, 0xbc, 0xe4, 0x9f, 0x7e, + 0x9c, 0xc5, 0x50, 0x92, 0x61, 0x1a, 0x0, 0x1e, 0x4a, 0x6b, 0x20, 0x2c, 0xb2, 0xb0, 0xc8, 0x8c, + 0xc, 0x69, 0x89, 0x70, 0xfd, 0x6b, 0xac, 0x45, 0x60, 0x8b, 0x4a, 0xdd, 0x34, 0xc5, 0x70, 0xa6, + 0x41, 0x4f, 0xb4, 0xa9, 0xee, 0xc6, 0x27, 0x0, 0x0, 0x24, 0x4a, 0x26, 0x0, 0x5, 0x6f, 0xbb, + 0xa1, 0x7f, 0x3b, 0x0, 0x15, 0xc8, 0x31, 0x7a, 0x13, 0xfa, 0x60, 0xe4, 0x32, 0x74, 0x3f, 0x40, + 0x13, 0xa5, 0x83, 0x4b, 0x1f, 0x71, 0x1d, 0xaa, 0xd4, 0x53, 0x18, 0x0, 0x0, 0x11, 0x3f, 0x8, + 0x0, 0xc, 0x89, 0xad, 0x18, 0x5, 0xcd, 0x42, 0x5c, 0xde, 0x1, 0x7e, 0xe6, 0x61, 0x1a, 0x0, + 0x10, 0x42, 0x88, 0x65, 0x26, 0x99, 0xa1, 0xc, 0x1b, 0x43, 0x50, 0x84, 0x83, 0x24, 0xf, 0x6a, + 0xbf, 0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; + uint8_t topic_bytes[] = {0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, + 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52}; + lwmqtt_string_t topic = {17, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, - 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 26; - - uint8_t bytesprops0[] = {0x1c, 0x2c, 0x4a, 0xe5, 0x60, 0xaa, 0xcc, 0xff, 0x85, 0x85, 0x47, 0xd0, 0x28, - 0x5d, 0x2b, 0x6a, 0x84, 0xe6, 0x78, 0xf4, 0x18, 0x94, 0x8f, 0xe3, 0x97, 0x48}; - uint8_t bytesprops2[] = {0x1b, 0xb4, 0x7c, 0x33, 0x26, 0x86}; - uint8_t bytesprops1[] = {0xe0, 0x96, 0x1a, 0x9a, 0x36, 0x64, 0x3a, 0x79, 0x8e, 0xef, 0xe8, 0x1e, 0x5f, 0xb5, 0x43, - 0x59, 0xb8, 0x96, 0xfe, 0xf2, 0xe2, 0x7, 0x22, 0x84, 0x9f, 0x23, 0x9e, 0x46, 0x6b}; - uint8_t bytesprops3[] = {0xe6, 0xc6}; - uint8_t bytesprops4[] = {0xff, 0xf6, 0xc3, 0x66, 0x8, 0x2c, 0x2e, 0xb0, 0x96, 0xde}; - uint8_t bytesprops5[] = {0xb6, 0x18, 0x75, 0x1, 0xe, 0x97, 0xe0, 0x40, 0x4e, 0x20, 0xc8, 0xdc, 0xc7, 0xa8, - 0x53, 0x15, 0x44, 0x15, 0x27, 0x13, 0xc, 0x41, 0xf3, 0x87, 0xc3, 0x93, 0x5e}; - uint8_t bytesprops6[] = {0x56, 0x3f, 0xe1, 0xae, 0xed, 0x9a, 0x79, 0x39, 0xaf, 0xc3, 0x6f, 0x58, 0xd4, 0x64, - 0xb6, 0xd6, 0x9d, 0xb, 0x62, 0xef, 0x9d, 0x2d, 0x70, 0x1f, 0x9b, 0x3e, 0x6, 0xf2}; - uint8_t bytesprops7[] = {0xdd, 0xc8, 0x8f, 0x0, 0xe5, 0x84, 0xe8, 0x48, 0x60, 0x32, 0x4f, - 0xd5, 0x11, 0x1, 0x4c, 0x8e, 0x8, 0x7a, 0xf1, 0x8a, 0xa7, 0x41}; - uint8_t bytesprops8[] = {0x63, 0x92, 0x15, 0x8c, 0x63, 0x53, 0x87, 0x47, 0xac, 0x3f, 0x6a, 0x90, 0xf4, 0xe8, 0x8d, - 0x67, 0xef, 0x46, 0x14, 0x17, 0x23, 0xff, 0xd, 0xcf, 0x37, 0x81, 0x4e, 0xb7, 0x8f}; - uint8_t bytesprops9[] = {0x52, 0x8d, 0xf0, 0x8e, 0xb4, 0x4b, 0x79}; - uint8_t bytesprops10[] = {0x56, 0xe5, 0x2, 0x99, 0xa, 0x99, 0x12, 0xcc, 0x3d, 0x14, - 0x93, 0x42, 0x8, 0x99, 0xa9, 0xaf, 0xbf, 0x43, 0x57}; + msg.payload_len = 15; + + uint8_t bytesprops0[] = {0xd0, 0xd5, 0xbc, 0xe4, 0x9f, 0x7e, 0x9c, 0xc5, 0x50, 0x92, 0x61}; + uint8_t bytesprops1[] = {0x4a, 0x6b, 0x20, 0x2c, 0xb2, 0xb0, 0xc8, 0x8c, 0xc, 0x69, 0x89, 0x70, 0xfd, 0x6b, 0xac, + 0x45, 0x60, 0x8b, 0x4a, 0xdd, 0x34, 0xc5, 0x70, 0xa6, 0x41, 0x4f, 0xb4, 0xa9, 0xee, 0xc6}; + uint8_t bytesprops3[] = {0xc8, 0x31, 0x7a, 0x13, 0xfa, 0x60, 0xe4, 0x32, 0x74, 0x3f, 0x40, + 0x13, 0xa5, 0x83, 0x4b, 0x1f, 0x71, 0x1d, 0xaa, 0xd4, 0x53}; + uint8_t bytesprops2[] = {0x6f, 0xbb, 0xa1, 0x7f, 0x3b}; + uint8_t bytesprops4[] = {0x89, 0xad, 0x18, 0x5, 0xcd, 0x42, 0x5c, 0xde, 0x1, 0x7e, 0xe6, 0x61}; + uint8_t bytesprops5[] = {0x42, 0x88, 0x65, 0x26, 0x99, 0xa1, 0xc, 0x1b, + 0x43, 0x50, 0x84, 0x83, 0x24, 0xf, 0x6a, 0xbf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23325}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14201}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27523}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9563}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9290}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops2}, .v = {21, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4415}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 11390, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "\156\249\196\168\224\205\FS\219\244\128\231\SYN\252\239j\NAK\164\171G]\133\229\147Q\199(\f\249y", _pubPktID = 11390, -// _pubBody = "s\226]\184\NUL\176A\242\&3\195\ETBC\RSN\254\t\t\\\203\255=\180B\201k\163", _pubProps = [PropResponseTopic -// "\FS,J\229`\170\204\255\133\133G\208(]+j\132\230x\244\CAN\148\143\227\151H",PropMessageExpiryInterval -// 23325,PropUserProperty "\224\150\SUB\154\&6d:y\142\239\232\RS_\181CY\184\150\254\242\226\a\"\132\159#\158Fk" -// "\ESC\180|3&\134",PropAuthenticationMethod "\230\198",PropAuthenticationData -// "\255\246\195f\b,.\176\150\222",PropResponseTopic "\182\CANu\SOH\SO\151\224@N -// \200\220\199\168S\NAKD\NAK'\DC3\fA\243\135\195\147^",PropRetainAvailable 157,PropServerReference -// "V?\225\174\237\154y9\175\195oX\212d\182\214\157\vb\239\157-p\US\155>\ACK\242",PropRequestResponseInformation -// 114,PropSubscriptionIdentifier 23,PropAssignedClientIdentifier -// "\221\200\143\NUL\229\132\232H`2O\213\DC1\SOHL\142\bz\241\138\167A",PropTopicAliasMaximum 14201,PropServerReference -// "c\146\NAK\140cS\135G\172?j\144\244\232\141g\239F\DC4\ETB#\255\r\207\&7\129N\183\143",PropAuthenticationMethod -// "R\141\240\142\180Ky",PropMaximumPacketSize 27523,PropSessionExpiryInterval 9563,PropAssignedClientIdentifier -// "V\229\STX\153\n\153\DC2\204=\DC4\147B\b\153\169\175\191CW"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\178\144*)\STX\195\&3\195\193\213~9\191FW\136R", _pubPktID = 0, _pubBody = "\155U0$\ENQ\134dV\214\ts.+\ETX\143", +// _pubProps = [PropCorrelationData "\208\213\188\228\159~\156\197P\146a",PropResponseInformation "Jk +// ,\178\176\200\140\fi\137p\253k\172E`\139J\221\&4\197p\166AO\180\169\238\198",PropMaximumPacketSize +// 9290,PropUserProperty "o\187\161\DEL;" +// "\200\&1z\DC3\250`\228\&2t?@\DC3\165\131K\USq\GS\170\212S",PropWillDelayInterval 4415,PropResponseTopic +// "\137\173\CAN\ENQ\205B\\\222\SOH~\230a",PropResponseInformation "B\136e&\153\161\f\ESCCP\132\131$\SIj\191"]} TEST(Publish5QCTest, Decode23) { - uint8_t pkt[] = { - 0x3a, 0xc2, 0x2, 0x0, 0x1d, 0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, - 0x6a, 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, 0x79, 0x2c, 0x7e, 0x85, 0x2, - 0x8, 0x0, 0x1a, 0x1c, 0x2c, 0x4a, 0xe5, 0x60, 0xaa, 0xcc, 0xff, 0x85, 0x85, 0x47, 0xd0, 0x28, 0x5d, 0x2b, 0x6a, - 0x84, 0xe6, 0x78, 0xf4, 0x18, 0x94, 0x8f, 0xe3, 0x97, 0x48, 0x2, 0x0, 0x0, 0x5b, 0x1d, 0x26, 0x0, 0x1d, 0xe0, - 0x96, 0x1a, 0x9a, 0x36, 0x64, 0x3a, 0x79, 0x8e, 0xef, 0xe8, 0x1e, 0x5f, 0xb5, 0x43, 0x59, 0xb8, 0x96, 0xfe, 0xf2, - 0xe2, 0x7, 0x22, 0x84, 0x9f, 0x23, 0x9e, 0x46, 0x6b, 0x0, 0x6, 0x1b, 0xb4, 0x7c, 0x33, 0x26, 0x86, 0x15, 0x0, - 0x2, 0xe6, 0xc6, 0x16, 0x0, 0xa, 0xff, 0xf6, 0xc3, 0x66, 0x8, 0x2c, 0x2e, 0xb0, 0x96, 0xde, 0x8, 0x0, 0x1b, - 0xb6, 0x18, 0x75, 0x1, 0xe, 0x97, 0xe0, 0x40, 0x4e, 0x20, 0xc8, 0xdc, 0xc7, 0xa8, 0x53, 0x15, 0x44, 0x15, 0x27, - 0x13, 0xc, 0x41, 0xf3, 0x87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e, + 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52, 0x7a, 0x9, 0x0, 0xb, 0xd0, 0xd5, 0xbc, 0xe4, 0x9f, 0x7e, + 0x9c, 0xc5, 0x50, 0x92, 0x61, 0x1a, 0x0, 0x1e, 0x4a, 0x6b, 0x20, 0x2c, 0xb2, 0xb0, 0xc8, 0x8c, + 0xc, 0x69, 0x89, 0x70, 0xfd, 0x6b, 0xac, 0x45, 0x60, 0x8b, 0x4a, 0xdd, 0x34, 0xc5, 0x70, 0xa6, + 0x41, 0x4f, 0xb4, 0xa9, 0xee, 0xc6, 0x27, 0x0, 0x0, 0x24, 0x4a, 0x26, 0x0, 0x5, 0x6f, 0xbb, + 0xa1, 0x7f, 0x3b, 0x0, 0x15, 0xc8, 0x31, 0x7a, 0x13, 0xfa, 0x60, 0xe4, 0x32, 0x74, 0x3f, 0x40, + 0x13, 0xa5, 0x83, 0x4b, 0x1f, 0x71, 0x1d, 0xaa, 0xd4, 0x53, 0x18, 0x0, 0x0, 0x11, 0x3f, 0x8, + 0x0, 0xc, 0x89, 0xad, 0x18, 0x5, 0xcd, 0x42, 0x5c, 0xde, 0x1, 0x7e, 0xe6, 0x61, 0x1a, 0x0, + 0x10, 0x42, 0x88, 0x65, 0x26, 0x99, 0xa1, 0xc, 0x1b, 0x43, 0x50, 0x84, 0x83, 0x24, 0xf, 0x6a, + 0xbf, 0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4179,94 +4566,167 @@ TEST(Publish5QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9c, 0xf9, 0xc4, 0xa8, 0xe0, 0xcd, 0x1c, 0xdb, 0xf4, 0x80, 0xe7, 0x16, 0xfc, 0xef, 0x6a, - 0x15, 0xa4, 0xab, 0x47, 0x5d, 0x85, 0xe5, 0x93, 0x51, 0xc7, 0x28, 0xc, 0xf9, 0x79}; - lwmqtt_string_t exp_topic = {29, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x73, 0xe2, 0x5d, 0xb8, 0x0, 0xb0, 0x41, 0xf2, 0x33, 0xc3, 0x17, 0x43, 0x1e, - 0x4e, 0xfe, 0x9, 0x9, 0x5c, 0xcb, 0xff, 0x3d, 0xb4, 0x42, 0xc9, 0x6b, 0xa3}; - lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, + 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52}; + lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 11390); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 29); - EXPECT_EQ(msg.payload_len, 26); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\247\&51\173<\172\250\229U\SOH\214a\211n>\225\&2^", _pubPktID = 0, _pubBody = -// "\r\136\219Jg\197\169\234\190\251\255K\212\139c\186,\229", _pubProps = [PropAuthenticationMethod -// "\160\209\234jK\216\216:)\166\146\205\&8\249\CAN\191E\188\ESC",PropWillDelayInterval 18526,PropMaximumQoS -// 140,PropAssignedClientIdentifier "\GSd\199\233",PropServerReference -// "\249\DC2e^I\139\STX\232\195\NUL\ACK\233Z\214\206\STX\180\191&\t\DC1\249\154\158\\\NUL\EM",PropWillDelayInterval -// 6427,PropServerReference "b\SI_\254",PropRequestProblemInformation 249]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "G\195\186\214\239K +// \\\226\162\\\"\182", _pubPktID = 3720, _pubBody = +// "\SYN\172\191'(v\"S#\253\175\191\180\243%y\205\195\143\140\247\239\228\\", _pubProps = [PropServerReference +// "\DLEH+*\229\139\&6\242\210\b\221}hh6\219Cm\249\130U\230\168d\b\158",PropSubscriptionIdentifierAvailable +// 251,PropAssignedClientIdentifier "\198\DC1\n\161WEz\128",PropMessageExpiryInterval 8698,PropTopicAlias +// 21888,PropRetainAvailable 83,PropSubscriptionIdentifier 3,PropAuthenticationData +// "\203\240wO\tq>\150\163\145c7!Xg\135\\\239/",PropTopicAliasMaximum 20949,PropPayloadFormatIndicator +// 248,PropServerReference "\222\128\154\141\152=\DC3NW'_\222\241\NUL\221",PropSharedSubscriptionAvailable +// 142,PropSessionExpiryInterval 21222,PropAuthenticationMethod "\158B\NAK\210\148v*",PropPayloadFormatIndicator +// 47,PropRetainAvailable 106,PropResponseInformation +// "1Zl\199\205\143\249\234\232\237\214\128\130<\187\228I\EM\186\208\228#\247D\202\226\141",PropResponseTopic +// "a#\152\218C>",PropReceiveMaximum 17584,PropPayloadFormatIndicator 157,PropSubscriptionIdentifier +// 15,PropAuthenticationData "|\220\CAN\225\&2^", _pubPktID = 0, _pubBody = -// "\r\136\219Jg\197\169\234\190\251\255K\212\139c\186,\229", _pubProps = [PropAuthenticationMethod -// "\160\209\234jK\216\216:)\166\146\205\&8\249\CAN\191E\188\ESC",PropWillDelayInterval 18526,PropMaximumQoS -// 140,PropAssignedClientIdentifier "\GSd\199\233",PropServerReference -// "\249\DC2e^I\139\STX\232\195\NUL\ACK\233Z\214\206\STX\180\191&\t\DC1\249\154\158\\\NUL\EM",PropWillDelayInterval -// 6427,PropServerReference "b\SI_\254",PropRequestProblemInformation 249]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "G\195\186\214\239K +// \\\226\162\\\"\182", _pubPktID = 3720, _pubBody = +// "\SYN\172\191'(v\"S#\253\175\191\180\243%y\205\195\143\140\247\239\228\\", _pubProps = [PropServerReference +// "\DLEH+*\229\139\&6\242\210\b\221}hh6\219Cm\249\130U\230\168d\b\158",PropSubscriptionIdentifierAvailable +// 251,PropAssignedClientIdentifier "\198\DC1\n\161WEz\128",PropMessageExpiryInterval 8698,PropTopicAlias +// 21888,PropRetainAvailable 83,PropSubscriptionIdentifier 3,PropAuthenticationData +// "\203\240wO\tq>\150\163\145c7!Xg\135\\\239/",PropTopicAliasMaximum 20949,PropPayloadFormatIndicator +// 248,PropServerReference "\222\128\154\141\152=\DC3NW'_\222\241\NUL\221",PropSharedSubscriptionAvailable +// 142,PropSessionExpiryInterval 21222,PropAuthenticationMethod "\158B\NAK\210\148v*",PropPayloadFormatIndicator +// 47,PropRetainAvailable 106,PropResponseInformation +// "1Zl\199\205\143\249\234\232\237\214\128\130<\187\228I\EM\186\208\228#\247D\202\226\141",PropResponseTopic +// "a#\152\218C>",PropReceiveMaximum 17584,PropPayloadFormatIndicator 157,PropSubscriptionIdentifier +// 15,PropAuthenticationData "|\220\CAN(topic.data), 18); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 3720); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 24); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\DC3 -// \244\212\ETX\143\186\222G-\212", _pubPktID = 0, _pubBody = "cndv<\250\182\170?\140\SYN\204\158n'\161tLKL\DC4\131", -// _pubProps = [PropPayloadFormatIndicator 90,PropMessageExpiryInterval 11159,PropSessionExpiryInterval -// 2113,PropAuthenticationMethod "\128\249OaH;\232",PropTopicAliasMaximum 15946,PropAuthenticationData -// "\168\187\142\SO\157\223\&5\t\242g\246\141\t\FS\237\217\EM\DLE\203L\134\175\189<(#\DC2",PropMessageExpiryInterval -// 27559,PropWildcardSubscriptionAvailable 13,PropSubscriptionIdentifierAvailable 37,PropResponseTopic -// "\147\215\NAK\\\NUL\181\ETBQ\254\200\135\US\250\229\EOTI\149\163\254\190\178-\RS\EOT\191UX\RSTi\217\218\187",PropMessageExpiryInterval +// 14822,PropTopicAliasMaximum 7462,PropRequestProblemInformation 58,PropUserProperty +// "\237\217\129\178\170\183s\203\DC2g\162\152\SO\202m\162\219*\179" +// "\238Q?\150\189E[\218\175U\SYN\213\228\179|w\215\&9\EM9\151Y\ENQ_",PropUserProperty "\SI\DC2\166Ml\"$e~\128B" +// "\133\209\242\249\155\SYN\255\134\134\&6'+\194)\131\205\194\175%\US\135\ENQ\ENQ\192\184\219",PropCorrelationData +// "\ENQ\\\216T4\174",PropTopicAliasMaximum 14458,PropMaximumPacketSize 16732,PropMessageExpiryInterval +// 5436,PropSubscriptionIdentifier 4,PropContentType "\t\ESC\DC2\187\213L\236",PropRequestResponseInformation +// 153,PropMessageExpiryInterval 16625,PropTopicAliasMaximum 11137,PropAuthenticationMethod ""]} TEST(Publish5QC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, 0x5f, 0x6a, 0xdf, 0x58, 0xf2, 0x5f, - 0x5f, 0x26, 0x17, 0x78, 0x9, 0x0, 0x2, 0xb, 0x2b, 0x2, 0x0, 0x0, 0x47, 0x3f, 0x63, 0x6e, 0x64, 0x76, 0x3c, - 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; - uint8_t topic_bytes[] = {0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, 0x2d, 0xd4}; - lwmqtt_string_t topic = {11, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0xe7, 0x1, 0x0, 0x0, 0x25, 0x78, 0xcc, 0x1, 0x19, 0x37, 0x29, 0x5b, 0x25, 0xdb, 0x8, 0x0, + 0x15, 0xd0, 0x77, 0x23, 0x9e, 0x28, 0xe0, 0xd2, 0x19, 0x7d, 0x6d, 0x27, 0x8, 0xda, 0x4e, 0xef, 0x49, + 0x18, 0xe8, 0xc4, 0xbc, 0x94, 0x15, 0x0, 0x18, 0x75, 0xd7, 0xcd, 0xfd, 0x92, 0xeb, 0x93, 0x3e, 0xa3, + 0xfe, 0xbe, 0xb2, 0x2d, 0x1e, 0x4, 0xbf, 0x55, 0x58, 0x1e, 0x54, 0x69, 0xd9, 0xda, 0xbb, 0x2, 0x0, + 0x0, 0x39, 0xe6, 0x22, 0x1d, 0x26, 0x17, 0x3a, 0x26, 0x0, 0x13, 0xed, 0xd9, 0x81, 0xb2, 0xaa, 0xb7, + 0x73, 0xcb, 0x12, 0x67, 0xa2, 0x98, 0xe, 0xca, 0x6d, 0xa2, 0xdb, 0x2a, 0xb3, 0x0, 0x18, 0xee, 0x51, + 0x3f, 0x96, 0xbd, 0x45, 0x5b, 0xda, 0xaf, 0x55, 0x16, 0xd5, 0xe4, 0xb3, 0x7c, 0x77, 0xd7, 0x39, 0x19, + 0x39, 0x97, 0x59, 0x5, 0x5f, 0x26, 0x0, 0xb, 0xf, 0x12, 0xa6, 0x4d, 0x6c, 0x22, 0x24, 0x65, 0x7e, + 0x80, 0x42, 0x0, 0x1a, 0x85, 0xd1, 0xf2, 0xf9, 0x9b, 0x16, 0xff, 0x86, 0x86, 0x36, 0x27, 0x2b, 0xc2, + 0x29, 0x83, 0xcd, 0xc2, 0xaf, 0x25, 0x1f, 0x87, 0x5, 0x5, 0xc0, 0xb8, 0xdb, 0x9, 0x0, 0x6, 0x5, + 0x5c, 0xd8, 0x54, 0x34, 0xae, 0x22, 0x38, 0x7a, 0x27, 0x0, 0x0, 0x41, 0x5c, 0x2, 0x0, 0x0, 0x15, + 0x3c, 0xb, 0x4, 0x3, 0x0, 0x7, 0x9, 0x1b, 0x12, 0xbb, 0xd5, 0x4c, 0xec, 0x19, 0x99, 0x2, 0x0, + 0x0, 0x40, 0xf1, 0x22, 0x2b, 0x81, 0x15, 0x0, 0x0, 0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, + 0x92, 0x2e, 0x74, 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x63, 0x6e, 0x64, 0x76, 0x3c, 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, - 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; + uint8_t msg_bytes[] = {0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, 0x92, 0x2e, 0x74, + 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 22; - - uint8_t bytesprops0[] = {0x80, 0xf9, 0x4f, 0x61, 0x48, 0x3b, 0xe8}; - uint8_t bytesprops1[] = {0xa8, 0xbb, 0x8e, 0xe, 0x9d, 0xdf, 0x35, 0x9, 0xf2, 0x67, 0xf6, 0x8d, 0x9, 0x1c, - 0xed, 0xd9, 0x19, 0x10, 0xcb, 0x4c, 0x86, 0xaf, 0xbd, 0x3c, 0x28, 0x23, 0x12}; - uint8_t bytesprops2[] = {0x93, 0xd7, 0x15, 0x5c, 0x0, 0xb5, 0x17, 0x51, 0xfe, 0xc8, 0x87, 0x1f, 0xfa, 0xe5, 0x4, - 0x49, 0x95, 0x3c, 0x47, 0xec, 0x68, 0x34, 0xd9, 0x5c, 0x9, 0xdf, 0x3b, 0xed, 0xe2}; - uint8_t bytesprops3[] = {0x8, 0xd7, 0xce, 0xce}; - uint8_t bytesprops4[] = {0x92, 0x1, 0xf, 0x97, 0xe7, 0xba, 0x87}; - uint8_t bytesprops5[] = {0x1b, 0x24, 0x2d, 0x91, 0xfd, 0xd9, 0x18, 0xea, 0xe1, - 0xd, 0x9, 0x1, 0x49, 0xf4, 0x24, 0x35, 0xf3}; - uint8_t bytesprops6[] = {0x63, 0xd4, 0xf1, 0xa8, 0x78, 0x3c, 0xcf, 0xcb, 0x94, 0xc3, 0x2d, 0x81, 0xe6, - 0xc8, 0x1d, 0xd7, 0x7c, 0x5f, 0x6a, 0xdf, 0x58, 0xf2, 0x5f, 0x5f, 0x26}; - uint8_t bytesprops7[] = {0xb, 0x2b}; + msg.payload_len = 21; + + uint8_t bytesprops0[] = {0xd0, 0x77, 0x23, 0x9e, 0x28, 0xe0, 0xd2, 0x19, 0x7d, 0x6d, 0x27, + 0x8, 0xda, 0x4e, 0xef, 0x49, 0x18, 0xe8, 0xc4, 0xbc, 0x94}; + uint8_t bytesprops1[] = {0x75, 0xd7, 0xcd, 0xfd, 0x92, 0xeb, 0x93, 0x3e, 0xa3, 0xfe, 0xbe, 0xb2, + 0x2d, 0x1e, 0x4, 0xbf, 0x55, 0x58, 0x1e, 0x54, 0x69, 0xd9, 0xda, 0xbb}; + uint8_t bytesprops3[] = {0xee, 0x51, 0x3f, 0x96, 0xbd, 0x45, 0x5b, 0xda, 0xaf, 0x55, 0x16, 0xd5, + 0xe4, 0xb3, 0x7c, 0x77, 0xd7, 0x39, 0x19, 0x39, 0x97, 0x59, 0x5, 0x5f}; + uint8_t bytesprops2[] = {0xed, 0xd9, 0x81, 0xb2, 0xaa, 0xb7, 0x73, 0xcb, 0x12, 0x67, + 0xa2, 0x98, 0xe, 0xca, 0x6d, 0xa2, 0xdb, 0x2a, 0xb3}; + uint8_t bytesprops5[] = {0x85, 0xd1, 0xf2, 0xf9, 0x9b, 0x16, 0xff, 0x86, 0x86, 0x36, 0x27, 0x2b, 0xc2, + 0x29, 0x83, 0xcd, 0xc2, 0xaf, 0x25, 0x1f, 0x87, 0x5, 0x5, 0xc0, 0xb8, 0xdb}; + uint8_t bytesprops4[] = {0xf, 0x12, 0xa6, 0x4d, 0x6c, 0x22, 0x24, 0x65, 0x7e, 0x80, 0x42}; + uint8_t bytesprops6[] = {0x5, 0x5c, 0xd8, 0x54, 0x34, 0xae}; + uint8_t bytesprops7[] = {0x9, 0x1b, 0x12, 0xbb, 0xd5, 0x4c, 0xec}; + uint8_t bytesprops8[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11159}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2113}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15946}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27559}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26589}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4355}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12530}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18239}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14822}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7462}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops2}, .v = {24, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops4}, .v = {26, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14458}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16732}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5436}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16625}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11137}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 9592, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\DC3 -// \244\212\ETX\143\186\222G-\212", _pubPktID = 0, _pubBody = "cndv<\250\182\170?\140\SYN\204\158n'\161tLKL\DC4\131", -// _pubProps = [PropPayloadFormatIndicator 90,PropMessageExpiryInterval 11159,PropSessionExpiryInterval -// 2113,PropAuthenticationMethod "\128\249OaH;\232",PropTopicAliasMaximum 15946,PropAuthenticationData -// "\168\187\142\SO\157\223\&5\t\242g\246\141\t\FS\237\217\EM\DLE\203L\134\175\189<(#\DC2",PropMessageExpiryInterval -// 27559,PropWildcardSubscriptionAvailable 13,PropSubscriptionIdentifierAvailable 37,PropResponseTopic -// "\147\215\NAK\\\NUL\181\ETBQ\254\200\135\US\250\229\EOTI\149\163\254\190\178-\RS\EOT\191UX\RSTi\217\218\187",PropMessageExpiryInterval +// 14822,PropTopicAliasMaximum 7462,PropRequestProblemInformation 58,PropUserProperty +// "\237\217\129\178\170\183s\203\DC2g\162\152\SO\202m\162\219*\179" +// "\238Q?\150\189E[\218\175U\SYN\213\228\179|w\215\&9\EM9\151Y\ENQ_",PropUserProperty "\SI\DC2\166Ml\"$e~\128B" +// "\133\209\242\249\155\SYN\255\134\134\&6'+\194)\131\205\194\175%\US\135\ENQ\ENQ\192\184\219",PropCorrelationData +// "\ENQ\\\216T4\174",PropTopicAliasMaximum 14458,PropMaximumPacketSize 16732,PropMessageExpiryInterval +// 5436,PropSubscriptionIdentifier 4,PropContentType "\t\ESC\DC2\187\213L\236",PropRequestResponseInformation +// 153,PropMessageExpiryInterval 16625,PropTopicAliasMaximum 11137,PropAuthenticationMethod ""]} TEST(Publish5QCTest, Decode25) { - uint8_t pkt[] = { - 0x30, 0xdf, 0x1, 0x0, 0xb, 0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, 0x2d, 0xd4, 0xba, 0x1, 0x1, - 0x5a, 0x2, 0x0, 0x0, 0x2b, 0x97, 0x11, 0x0, 0x0, 0x8, 0x41, 0x15, 0x0, 0x7, 0x80, 0xf9, 0x4f, 0x61, 0x48, - 0x3b, 0xe8, 0x22, 0x3e, 0x4a, 0x16, 0x0, 0x1b, 0xa8, 0xbb, 0x8e, 0xe, 0x9d, 0xdf, 0x35, 0x9, 0xf2, 0x67, 0xf6, - 0x8d, 0x9, 0x1c, 0xed, 0xd9, 0x19, 0x10, 0xcb, 0x4c, 0x86, 0xaf, 0xbd, 0x3c, 0x28, 0x23, 0x12, 0x2, 0x0, 0x0, - 0x6b, 0xa7, 0x28, 0xd, 0x29, 0x25, 0x8, 0x0, 0x1d, 0x93, 0xd7, 0x15, 0x5c, 0x0, 0xb5, 0x17, 0x51, 0xfe, 0xc8, - 0x87, 0x1f, 0xfa, 0xe5, 0x4, 0x49, 0x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 0x1e, 0x54, 0x69, 0xd9, 0xda, 0xbb, 0x2, 0x0, + 0x0, 0x39, 0xe6, 0x22, 0x1d, 0x26, 0x17, 0x3a, 0x26, 0x0, 0x13, 0xed, 0xd9, 0x81, 0xb2, 0xaa, 0xb7, + 0x73, 0xcb, 0x12, 0x67, 0xa2, 0x98, 0xe, 0xca, 0x6d, 0xa2, 0xdb, 0x2a, 0xb3, 0x0, 0x18, 0xee, 0x51, + 0x3f, 0x96, 0xbd, 0x45, 0x5b, 0xda, 0xaf, 0x55, 0x16, 0xd5, 0xe4, 0xb3, 0x7c, 0x77, 0xd7, 0x39, 0x19, + 0x39, 0x97, 0x59, 0x5, 0x5f, 0x26, 0x0, 0xb, 0xf, 0x12, 0xa6, 0x4d, 0x6c, 0x22, 0x24, 0x65, 0x7e, + 0x80, 0x42, 0x0, 0x1a, 0x85, 0xd1, 0xf2, 0xf9, 0x9b, 0x16, 0xff, 0x86, 0x86, 0x36, 0x27, 0x2b, 0xc2, + 0x29, 0x83, 0xcd, 0xc2, 0xaf, 0x25, 0x1f, 0x87, 0x5, 0x5, 0xc0, 0xb8, 0xdb, 0x9, 0x0, 0x6, 0x5, + 0x5c, 0xd8, 0x54, 0x34, 0xae, 0x22, 0x38, 0x7a, 0x27, 0x0, 0x0, 0x41, 0x5c, 0x2, 0x0, 0x0, 0x15, + 0x3c, 0xb, 0x4, 0x3, 0x0, 0x7, 0x9, 0x1b, 0x12, 0xbb, 0xd5, 0x4c, 0xec, 0x19, 0x99, 0x2, 0x0, + 0x0, 0x40, 0xf1, 0x22, 0x2b, 0x81, 0x15, 0x0, 0x0, 0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, + 0x92, 0x2e, 0x74, 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4409,162 +4871,131 @@ TEST(Publish5QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x13, 0x20, 0xf4, 0xd4, 0x3, 0x8f, 0xba, 0xde, 0x47, 0x2d, 0xd4}; - lwmqtt_string_t exp_topic = {11, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x63, 0x6e, 0x64, 0x76, 0x3c, 0xfa, 0xb6, 0xaa, 0x3f, 0x8c, 0x16, - 0xcc, 0x9e, 0x6e, 0x27, 0xa1, 0x74, 0x4c, 0x4b, 0x4c, 0x14, 0x83}; - lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, 0x92, 0x2e, 0x74, + 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; + lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 11); - EXPECT_EQ(msg.payload_len, 22); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); + EXPECT_EQ(packet_id, 9592); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 21); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "o#L\177\210\EOT\140\230w\252ir\220-\217\230\154\182\a0(\169\225\232uo", _pubPktID = 0, _pubBody = -// "2\137\n\NUL\201\149\252e\191]\CAN#`\250", _pubProps = [PropSubscriptionIdentifierAvailable -// 236,PropAssignedClientIdentifier "\152\SOHt\252\165",PropTopicAliasMaximum 13490,PropWillDelayInterval -// 22209,PropPayloadFormatIndicator 60,PropTopicAlias 16841,PropRetainAvailable 107,PropResponseTopic -// "ah\ETB\139iQ\b\n\164\233Q\132g\GSU\160\212\b\191K\211\157\200\165",PropMessageExpiryInterval -// 1549,PropAuthenticationMethod "\229\224\206\vA\237\182\FS![1=U\218,V>\ETX\210p3",PropSharedSubscriptionAvailable -// 99,PropAuthenticationData "o\213\198\161'A?P\ENQ'\144\235qY\144\192\210\156\214\200*M",PropRetainAvailable -// 220,PropServerKeepAlive 26426,PropAuthenticationData -// "\212O\226\198\214\236\150D_\DC2\135",PropRequestProblemInformation 170,PropTopicAliasMaximum -// 10106,PropResponseInformation -// "\ESCu\152M\180V\202\DLE\220&`\244\RS\234\&5X\137\237\DC1\230\210\208u\RS\180\ETB",PropContentType -// "",PropAuthenticationData -// "R\178\230b\169\192\188\232\161\168\230K\SOMj>|s@b\140\243\197\246\t\156\b^",PropSubscriptionIdentifier -// 12,PropSessionExpiryInterval 28419,PropSharedSubscriptionAvailable 28,PropMaximumPacketSize 19043,PropServerKeepAlive -// 19008,PropRetainAvailable 208,PropUserProperty "\195\DEL\252}\STX.\234\130\189\255:)\SO\136x\143\133\129" -// "\159\161:z\170\255\DC3\230\249\ETBZ\204}\178T\190\222\198\DEL\181\150\245\253\f\255#\218\t*M"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "y\216", _pubPktID = 27633, _pubBody +// = "\t\219\155@MR", _pubProps = [PropMessageExpiryInterval 13541,PropSubscriptionIdentifierAvailable +// 64,PropRequestProblemInformation 165,PropSessionExpiryInterval 19172,PropSubscriptionIdentifierAvailable +// 207,PropSharedSubscriptionAvailable 216,PropReasonString +// "\239\&7\209\&4\"\RS\210\252\152\247w\DELq\137}\231\221\&25\250\166\156\209\215C\232\US,",PropSubscriptionIdentifier +// 17,PropCorrelationData +// "\169`\195\182Q\144Rs\133\247\157\229Q1`o\SYN\NUL1\245S\v\SYN\167\155\129\&6\226\SUB\203",PropPayloadFormatIndicator +// 164,PropTopicAlias 25481,PropTopicAliasMaximum 2367,PropCorrelationData +// "\DC4{\160{\203\130\240\201\r\218\212\168O",PropSubscriptionIdentifier 24,PropAssignedClientIdentifier +// "gfW\212\230\243\228\235\182\223\RSxZ\135\227\163\249\217\177[\218|\194Nt\143\224\239G\t",PropReasonString +// "\239\242\158q#\202\v\221\SYN\191\&2N\218\129]=sa",PropRetainAvailable 139,PropTopicAliasMaximum +// 31979,PropSubscriptionIdentifier 19,PropServerReference +// "\157C\209\r\201\233\136W\195\229\f=\ENQJ\230%.\142\138j\208\175p\146",PropSubscriptionIdentifier 16]} TEST(Publish5QCTest, Encode26) { - uint8_t pkt[] = { - 0x31, 0xb7, 0x2, 0x0, 0x1a, 0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, 0x2d, - 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f, 0x8b, 0x2, 0x29, 0xec, 0x12, 0x0, 0x5, - 0x98, 0x1, 0x74, 0xfc, 0xa5, 0x22, 0x34, 0xb2, 0x18, 0x0, 0x0, 0x56, 0xc1, 0x1, 0x3c, 0x23, 0x41, 0xc9, 0x25, - 0x6b, 0x8, 0x0, 0x18, 0x61, 0x68, 0x17, 0x8b, 0x69, 0x51, 0x8, 0xa, 0xa4, 0xe9, 0x51, 0x84, 0x67, 0x1d, 0x55, - 0xa0, 0xd4, 0x8, 0xbf, 0x4b, 0xd3, 0x9d, 0xc8, 0xa5, 0x2, 0x0, 0x0, 0x6, 0xd, 0x15, 0x0, 0x15,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0xf9, 0x17, 0x5a, 0xcc, 0x7d, 0xb2, 0x54, - 0xbe, 0xde, 0xc6, 0x7f, 0xb5, 0x96, 0xf5, 0xfd, 0xc, 0xff, 0x23, 0xda, 0x9, 0x2a, 0x4d, 0x32, 0x89, 0xa, 0x0, - 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; - uint8_t topic_bytes[] = {0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, - 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f}; - lwmqtt_string_t topic = {26, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0xd6, 0x1, 0x0, 0x2, 0x79, 0xd8, 0x6b, 0xf1, 0xc8, 0x1, 0x2, 0x0, 0x0, 0x34, 0xe5, 0x29, + 0x40, 0x17, 0xa5, 0x11, 0x0, 0x0, 0x4a, 0xe4, 0x29, 0xcf, 0x2a, 0xd8, 0x1f, 0x0, 0x1c, 0xef, 0x37, + 0xd1, 0x34, 0x22, 0x1e, 0xd2, 0xfc, 0x98, 0xf7, 0x77, 0x7f, 0x71, 0x89, 0x7d, 0xe7, 0xdd, 0x32, 0x35, + 0xfa, 0xa6, 0x9c, 0xd1, 0xd7, 0x43, 0xe8, 0x1f, 0x2c, 0xb, 0x11, 0x9, 0x0, 0x1e, 0xa9, 0x60, 0xc3, + 0xb6, 0x51, 0x90, 0x52, 0x73, 0x85, 0xf7, 0x9d, 0xe5, 0x51, 0x31, 0x60, 0x6f, 0x16, 0x0, 0x31, 0xf5, + 0x53, 0xb, 0x16, 0xa7, 0x9b, 0x81, 0x36, 0xe2, 0x1a, 0xcb, 0x1, 0xa4, 0x23, 0x63, 0x89, 0x22, 0x9, + 0x3f, 0x9, 0x0, 0xd, 0x14, 0x7b, 0xa0, 0x7b, 0xcb, 0x82, 0xf0, 0xc9, 0xd, 0xda, 0xd4, 0xa8, 0x4f, + 0xb, 0x18, 0x12, 0x0, 0x1e, 0x67, 0x66, 0x57, 0xd4, 0xe6, 0xf3, 0xe4, 0xeb, 0xb6, 0xdf, 0x1e, 0x78, + 0x5a, 0x87, 0xe3, 0xa3, 0xf9, 0xd9, 0xb1, 0x5b, 0xda, 0x7c, 0xc2, 0x4e, 0x74, 0x8f, 0xe0, 0xef, 0x47, + 0x9, 0x1f, 0x0, 0x12, 0xef, 0xf2, 0x9e, 0x71, 0x23, 0xca, 0xb, 0xdd, 0x16, 0xbf, 0x32, 0x4e, 0xda, + 0x81, 0x5d, 0x3d, 0x73, 0x61, 0x25, 0x8b, 0x22, 0x7c, 0xeb, 0xb, 0x13, 0x1c, 0x0, 0x18, 0x9d, 0x43, + 0xd1, 0xd, 0xc9, 0xe9, 0x88, 0x57, 0xc3, 0xe5, 0xc, 0x3d, 0x5, 0x4a, 0xe6, 0x25, 0x2e, 0x8e, 0x8a, + 0x6a, 0xd0, 0xaf, 0x70, 0x92, 0xb, 0x10, 0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; + uint8_t topic_bytes[] = {0x79, 0xd8}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; + uint8_t msg_bytes[] = {0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 14; - - uint8_t bytesprops0[] = {0x98, 0x1, 0x74, 0xfc, 0xa5}; - uint8_t bytesprops1[] = {0x61, 0x68, 0x17, 0x8b, 0x69, 0x51, 0x8, 0xa, 0xa4, 0xe9, 0x51, 0x84, - 0x67, 0x1d, 0x55, 0xa0, 0xd4, 0x8, 0xbf, 0x4b, 0xd3, 0x9d, 0xc8, 0xa5}; - uint8_t bytesprops2[] = {0xe5, 0xe0, 0xce, 0xb, 0x41, 0xed, 0xb6, 0x1c, 0x21, 0x5b, 0x31, - 0x3d, 0x55, 0xda, 0x2c, 0x56, 0x3e, 0x3, 0xd2, 0x70, 0x33}; - uint8_t bytesprops3[] = {0x6f, 0xd5, 0xc6, 0xa1, 0x27, 0x41, 0x3f, 0x50, 0x5, 0x27, 0x90, - 0xeb, 0x71, 0x59, 0x90, 0xc0, 0xd2, 0x9c, 0xd6, 0xc8, 0x2a, 0x4d}; - uint8_t bytesprops4[] = {0xd4, 0x4f, 0xe2, 0xc6, 0xd6, 0xec, 0x96, 0x44, 0x5f, 0x12, 0x87}; - uint8_t bytesprops5[] = {0x1b, 0x75, 0x98, 0x4d, 0xb4, 0x56, 0xca, 0x10, 0xdc, 0x26, 0x60, 0xf4, 0x1e, - 0xea, 0x35, 0x58, 0x89, 0xed, 0x11, 0xe6, 0xd2, 0xd0, 0x75, 0x1e, 0xb4, 0x17}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops7[] = {0x52, 0xb2, 0xe6, 0x62, 0xa9, 0xc0, 0xbc, 0xe8, 0xa1, 0xa8, 0xe6, 0x4b, 0xe, 0x4d, - 0x6a, 0x3e, 0x7c, 0x73, 0x40, 0x62, 0x8c, 0xf3, 0xc5, 0xf6, 0x9, 0x9c, 0x8, 0x5e}; - uint8_t bytesprops9[] = {0x9f, 0xa1, 0x3a, 0x7a, 0xaa, 0xff, 0x13, 0xe6, 0xf9, 0x17, 0x5a, 0xcc, 0x7d, 0xb2, 0x54, - 0xbe, 0xde, 0xc6, 0x7f, 0xb5, 0x96, 0xf5, 0xfd, 0xc, 0xff, 0x23, 0xda, 0x9, 0x2a, 0x4d}; - uint8_t bytesprops8[] = {0xc3, 0x7f, 0xfc, 0x7d, 0x2, 0x2e, 0xea, 0x82, 0xbd, - 0xff, 0x3a, 0x29, 0xe, 0x88, 0x78, 0x8f, 0x85, 0x81}; + msg.payload_len = 6; + + uint8_t bytesprops0[] = {0xef, 0x37, 0xd1, 0x34, 0x22, 0x1e, 0xd2, 0xfc, 0x98, 0xf7, 0x77, 0x7f, 0x71, 0x89, + 0x7d, 0xe7, 0xdd, 0x32, 0x35, 0xfa, 0xa6, 0x9c, 0xd1, 0xd7, 0x43, 0xe8, 0x1f, 0x2c}; + uint8_t bytesprops1[] = {0xa9, 0x60, 0xc3, 0xb6, 0x51, 0x90, 0x52, 0x73, 0x85, 0xf7, 0x9d, 0xe5, 0x51, 0x31, 0x60, + 0x6f, 0x16, 0x0, 0x31, 0xf5, 0x53, 0xb, 0x16, 0xa7, 0x9b, 0x81, 0x36, 0xe2, 0x1a, 0xcb}; + uint8_t bytesprops2[] = {0x14, 0x7b, 0xa0, 0x7b, 0xcb, 0x82, 0xf0, 0xc9, 0xd, 0xda, 0xd4, 0xa8, 0x4f}; + uint8_t bytesprops3[] = {0x67, 0x66, 0x57, 0xd4, 0xe6, 0xf3, 0xe4, 0xeb, 0xb6, 0xdf, 0x1e, 0x78, 0x5a, 0x87, 0xe3, + 0xa3, 0xf9, 0xd9, 0xb1, 0x5b, 0xda, 0x7c, 0xc2, 0x4e, 0x74, 0x8f, 0xe0, 0xef, 0x47, 0x9}; + uint8_t bytesprops4[] = {0xef, 0xf2, 0x9e, 0x71, 0x23, 0xca, 0xb, 0xdd, 0x16, + 0xbf, 0x32, 0x4e, 0xda, 0x81, 0x5d, 0x3d, 0x73, 0x61}; + uint8_t bytesprops5[] = {0x9d, 0x43, 0xd1, 0xd, 0xc9, 0xe9, 0x88, 0x57, 0xc3, 0xe5, 0xc, 0x3d, + 0x5, 0x4a, 0xe6, 0x25, 0x2e, 0x8e, 0x8a, 0x6a, 0xd0, 0xaf, 0x70, 0x92}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13490}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22209}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16841}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1549}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26426}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10106}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28419}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19043}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19008}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops8}, .v = {30, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13541}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19172}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25481}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2367}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31979}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 27633, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "o#L\177\210\EOT\140\230w\252ir\220-\217\230\154\182\a0(\169\225\232uo", _pubPktID = 0, _pubBody = -// "2\137\n\NUL\201\149\252e\191]\CAN#`\250", _pubProps = [PropSubscriptionIdentifierAvailable -// 236,PropAssignedClientIdentifier "\152\SOHt\252\165",PropTopicAliasMaximum 13490,PropWillDelayInterval -// 22209,PropPayloadFormatIndicator 60,PropTopicAlias 16841,PropRetainAvailable 107,PropResponseTopic -// "ah\ETB\139iQ\b\n\164\233Q\132g\GSU\160\212\b\191K\211\157\200\165",PropMessageExpiryInterval -// 1549,PropAuthenticationMethod "\229\224\206\vA\237\182\FS![1=U\218,V>\ETX\210p3",PropSharedSubscriptionAvailable -// 99,PropAuthenticationData "o\213\198\161'A?P\ENQ'\144\235qY\144\192\210\156\214\200*M",PropRetainAvailable -// 220,PropServerKeepAlive 26426,PropAuthenticationData -// "\212O\226\198\214\236\150D_\DC2\135",PropRequestProblemInformation 170,PropTopicAliasMaximum -// 10106,PropResponseInformation -// "\ESCu\152M\180V\202\DLE\220&`\244\RS\234\&5X\137\237\DC1\230\210\208u\RS\180\ETB",PropContentType -// "",PropAuthenticationData -// "R\178\230b\169\192\188\232\161\168\230K\SOMj>|s@b\140\243\197\246\t\156\b^",PropSubscriptionIdentifier -// 12,PropSessionExpiryInterval 28419,PropSharedSubscriptionAvailable 28,PropMaximumPacketSize 19043,PropServerKeepAlive -// 19008,PropRetainAvailable 208,PropUserProperty "\195\DEL\252}\STX.\234\130\189\255:)\SO\136x\143\133\129" -// "\159\161:z\170\255\DC3\230\249\ETBZ\204}\178T\190\222\198\DEL\181\150\245\253\f\255#\218\t*M"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "y\216", _pubPktID = 27633, _pubBody +// = "\t\219\155@MR", _pubProps = [PropMessageExpiryInterval 13541,PropSubscriptionIdentifierAvailable +// 64,PropRequestProblemInformation 165,PropSessionExpiryInterval 19172,PropSubscriptionIdentifierAvailable +// 207,PropSharedSubscriptionAvailable 216,PropReasonString +// "\239\&7\209\&4\"\RS\210\252\152\247w\DELq\137}\231\221\&25\250\166\156\209\215C\232\US,",PropSubscriptionIdentifier +// 17,PropCorrelationData +// "\169`\195\182Q\144Rs\133\247\157\229Q1`o\SYN\NUL1\245S\v\SYN\167\155\129\&6\226\SUB\203",PropPayloadFormatIndicator +// 164,PropTopicAlias 25481,PropTopicAliasMaximum 2367,PropCorrelationData +// "\DC4{\160{\203\130\240\201\r\218\212\168O",PropSubscriptionIdentifier 24,PropAssignedClientIdentifier +// "gfW\212\230\243\228\235\182\223\RSxZ\135\227\163\249\217\177[\218|\194Nt\143\224\239G\t",PropReasonString +// "\239\242\158q#\202\v\221\SYN\191\&2N\218\129]=sa",PropRetainAvailable 139,PropTopicAliasMaximum +// 31979,PropSubscriptionIdentifier 19,PropServerReference +// "\157C\209\r\201\233\136W\195\229\f=\ENQJ\230%.\142\138j\208\175p\146",PropSubscriptionIdentifier 16]} TEST(Publish5QCTest, Decode26) { - uint8_t pkt[] = { - 0x31, 0xb7, 0x2, 0x0, 0x1a, 0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, 0x2d, - 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f, 0x8b, 0x2, 0x29, 0xec, 0x12, 0x0, 0x5, - 0x98, 0x1, 0x74, 0xfc, 0xa5, 0x22, 0x34, 0xb2, 0x18, 0x0, 0x0, 0x56, 0xc1, 0x1, 0x3c, 0x23, 0x41, 0xc9, 0x25, - 0x6b, 0x8, 0x0, 0x18, 0x61, 0x68, 0x17, 0x8b, 0x69, 0x51, 0x8, 0xa, 0xa4, 0xe9, 0x51, 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, 0xd4, 0xe6, 0xf3, 0xe4, 0xeb, 0xb6, 0xdf, 0x1e, 0x78, + 0x5a, 0x87, 0xe3, 0xa3, 0xf9, 0xd9, 0xb1, 0x5b, 0xda, 0x7c, 0xc2, 0x4e, 0x74, 0x8f, 0xe0, 0xef, 0x47, + 0x9, 0x1f, 0x0, 0x12, 0xef, 0xf2, 0x9e, 0x71, 0x23, 0xca, 0xb, 0xdd, 0x16, 0xbf, 0x32, 0x4e, 0xda, + 0x81, 0x5d, 0x3d, 0x73, 0x61, 0x25, 0x8b, 0x22, 0x7c, 0xeb, 0xb, 0x13, 0x1c, 0x0, 0x18, 0x9d, 0x43, + 0xd1, 0xd, 0xc9, 0xe9, 0x88, 0x57, 0xc3, 0xe5, 0xc, 0x3d, 0x5, 0x4a, 0xe6, 0x25, 0x2e, 0x8e, 0x8a, + 0x6a, 0xd0, 0xaf, 0x70, 0x92, 0xb, 0x10, 0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4573,104 +5004,76 @@ TEST(Publish5QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x6f, 0x23, 0x4c, 0xb1, 0xd2, 0x4, 0x8c, 0xe6, 0x77, 0xfc, 0x69, 0x72, 0xdc, - 0x2d, 0xd9, 0xe6, 0x9a, 0xb6, 0x7, 0x30, 0x28, 0xa9, 0xe1, 0xe8, 0x75, 0x6f}; - lwmqtt_string_t exp_topic = {26, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x32, 0x89, 0xa, 0x0, 0xc9, 0x95, 0xfc, 0x65, 0xbf, 0x5d, 0x18, 0x23, 0x60, 0xfa}; - lwmqtt_string_t exp_body = {14, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x79, 0xd8}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 26); - EXPECT_EQ(msg.payload_len, 14); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 14); + EXPECT_EQ(packet_id, 27633); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O\216\186", _pubPktID = 31863, -// _pubBody = "\206\US\183\184\207\198X\216\SOn\202 \214", _pubProps = [PropServerKeepAlive -// 3457,PropAssignedClientIdentifier "y",PropCorrelationData "\RS\202\193",PropMaximumQoS 253,PropUserProperty -// "n\150\v\139\139\166K\163lr$-#\CANEK\243(;\253" "\164N\244\218LO#\214\vfMF\176\136\FS\138",PropPayloadFormatIndicator -// 113,PropMessageExpiryInterval 28096,PropServerReference -// "d\172q\231\174\232v\SYN\ACK\213\189,=\132\DC2\144\235z\t%\DEL\227\230\147\&9\198;",PropWildcardSubscriptionAvailable -// 100,PropRequestProblemInformation 159,PropTopicAlias 29659,PropResponseTopic "\ENQt\165[",PropReceiveMaximum -// 23882,PropWildcardSubscriptionAvailable 19]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\253d\178]\206\DLE\163;", _pubProps = [PropWillDelayInterval 17530,PropTopicAliasMaximum +// 20683,PropMessageExpiryInterval 5805,PropRetainAvailable 19,PropUserProperty +// "\175\144\192\152\231U\141\191\ETB\149\254\227X\149\a\CAN\168Qa2\DLE" +// "\200c\DLE\204\149b\146\231\&4eO\FS\170\145.\253\247o\134'h\160",PropMessageExpiryInterval 804]} TEST(Publish5QCTest, Encode27) { - uint8_t pkt[] = {0x3d, 0x85, 0x1, 0x0, 0x3, 0x4f, 0xd8, 0xba, 0x7c, 0x77, 0x70, 0x13, 0xd, 0x81, 0x12, 0x0, - 0x1, 0x79, 0x9, 0x0, 0x3, 0x1e, 0xca, 0xc1, 0x24, 0xfd, 0x26, 0x0, 0x14, 0x6e, 0x96, 0xb, - 0x8b, 0x8b, 0xa6, 0x4b, 0xa3, 0x6c, 0x72, 0x24, 0x2d, 0x23, 0x18, 0x45, 0x4b, 0xf3, 0x28, 0x3b, - 0xfd, 0x0, 0x10, 0xa4, 0x4e, 0xf4, 0xda, 0x4c, 0x4f, 0x23, 0xd6, 0xb, 0x66, 0x4d, 0x46, 0xb0, - 0x88, 0x1c, 0x8a, 0x1, 0x71, 0x2, 0x0, 0x0, 0x6d, 0xc0, 0x1c, 0x0, 0x1b, 0x64, 0xac, 0x71, - 0xe7, 0xae, 0xe8, 0x76, 0x16, 0x6, 0xd5, 0xbd, 0x2c, 0x3d, 0x84, 0x12, 0x90, 0xeb, 0x7a, 0x9, - 0x25, 0x7f, 0xe3, 0xe6, 0x93, 0x39, 0xc6, 0x3b, 0x28, 0x64, 0x17, 0x9f, 0x23, 0x73, 0xdb, 0x8, - 0x0, 0x4, 0x5, 0x74, 0xa5, 0x5b, 0x21, 0x5d, 0x4a, 0x28, 0x13, 0xce, 0x1f, 0xb7, 0xb8, 0xcf, - 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; - uint8_t topic_bytes[] = {0x4f, 0xd8, 0xba}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x4f, 0x0, 0x0, 0x44, 0x18, 0x0, 0x0, 0x44, 0x7a, 0x22, 0x50, 0xcb, 0x2, 0x0, 0x0, 0x16, + 0xad, 0x25, 0x13, 0x26, 0x0, 0x15, 0xaf, 0x90, 0xc0, 0x98, 0xe7, 0x55, 0x8d, 0xbf, 0x17, 0x95, 0xfe, + 0xe3, 0x58, 0x95, 0x7, 0x18, 0xa8, 0x51, 0x61, 0x32, 0x10, 0x0, 0x16, 0xc8, 0x63, 0x10, 0xcc, 0x95, + 0x62, 0x92, 0xe7, 0x34, 0x65, 0x4f, 0x1c, 0xaa, 0x91, 0x2e, 0xfd, 0xf7, 0x6f, 0x86, 0x27, 0x68, 0xa0, + 0x2, 0x0, 0x0, 0x3, 0x24, 0xfd, 0x64, 0xb2, 0x5d, 0xce, 0x10, 0xa3, 0x3b}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xce, 0x1f, 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; + uint8_t msg_bytes[] = {0xfd, 0x64, 0xb2, 0x5d, 0xce, 0x10, 0xa3, 0x3b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 13; + msg.payload_len = 8; - uint8_t bytesprops0[] = {0x79}; - uint8_t bytesprops1[] = {0x1e, 0xca, 0xc1}; - uint8_t bytesprops3[] = {0xa4, 0x4e, 0xf4, 0xda, 0x4c, 0x4f, 0x23, 0xd6, - 0xb, 0x66, 0x4d, 0x46, 0xb0, 0x88, 0x1c, 0x8a}; - uint8_t bytesprops2[] = {0x6e, 0x96, 0xb, 0x8b, 0x8b, 0xa6, 0x4b, 0xa3, 0x6c, 0x72, - 0x24, 0x2d, 0x23, 0x18, 0x45, 0x4b, 0xf3, 0x28, 0x3b, 0xfd}; - uint8_t bytesprops4[] = {0x64, 0xac, 0x71, 0xe7, 0xae, 0xe8, 0x76, 0x16, 0x6, 0xd5, 0xbd, 0x2c, 0x3d, 0x84, - 0x12, 0x90, 0xeb, 0x7a, 0x9, 0x25, 0x7f, 0xe3, 0xe6, 0x93, 0x39, 0xc6, 0x3b}; - uint8_t bytesprops5[] = {0x5, 0x74, 0xa5, 0x5b}; + uint8_t bytesprops1[] = {0xc8, 0x63, 0x10, 0xcc, 0x95, 0x62, 0x92, 0xe7, 0x34, 0x65, 0x4f, + 0x1c, 0xaa, 0x91, 0x2e, 0xfd, 0xf7, 0x6f, 0x86, 0x27, 0x68, 0xa0}; + uint8_t bytesprops0[] = {0xaf, 0x90, 0xc0, 0x98, 0xe7, 0x55, 0x8d, 0xbf, 0x17, 0x95, 0xfe, + 0xe3, 0x58, 0x95, 0x7, 0x18, 0xa8, 0x51, 0x61, 0x32, 0x10}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3457}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops2}, .v = {16, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28096}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29659}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23882}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17530}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20683}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5805}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops0}, .v = {22, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 804}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 31863, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "O\216\186", _pubPktID = 31863, -// _pubBody = "\206\US\183\184\207\198X\216\SOn\202 \214", _pubProps = [PropServerKeepAlive -// 3457,PropAssignedClientIdentifier "y",PropCorrelationData "\RS\202\193",PropMaximumQoS 253,PropUserProperty -// "n\150\v\139\139\166K\163lr$-#\CANEK\243(;\253" "\164N\244\218LO#\214\vfMF\176\136\FS\138",PropPayloadFormatIndicator -// 113,PropMessageExpiryInterval 28096,PropServerReference -// "d\172q\231\174\232v\SYN\ACK\213\189,=\132\DC2\144\235z\t%\DEL\227\230\147\&9\198;",PropWildcardSubscriptionAvailable -// 100,PropRequestProblemInformation 159,PropTopicAlias 29659,PropResponseTopic "\ENQt\165[",PropReceiveMaximum -// 23882,PropWildcardSubscriptionAvailable 19]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\253d\178]\206\DLE\163;", _pubProps = [PropWillDelayInterval 17530,PropTopicAliasMaximum +// 20683,PropMessageExpiryInterval 5805,PropRetainAvailable 19,PropUserProperty +// "\175\144\192\152\231U\141\191\ETB\149\254\227X\149\a\CAN\168Qa2\DLE" +// "\200c\DLE\204\149b\146\231\&4eO\FS\170\145.\253\247o\134'h\160",PropMessageExpiryInterval 804]} TEST(Publish5QCTest, Decode27) { - uint8_t pkt[] = {0x3d, 0x85, 0x1, 0x0, 0x3, 0x4f, 0xd8, 0xba, 0x7c, 0x77, 0x70, 0x13, 0xd, 0x81, 0x12, 0x0, - 0x1, 0x79, 0x9, 0x0, 0x3, 0x1e, 0xca, 0xc1, 0x24, 0xfd, 0x26, 0x0, 0x14, 0x6e, 0x96, 0xb, - 0x8b, 0x8b, 0xa6, 0x4b, 0xa3, 0x6c, 0x72, 0x24, 0x2d, 0x23, 0x18, 0x45, 0x4b, 0xf3, 0x28, 0x3b, - 0xfd, 0x0, 0x10, 0xa4, 0x4e, 0xf4, 0xda, 0x4c, 0x4f, 0x23, 0xd6, 0xb, 0x66, 0x4d, 0x46, 0xb0, - 0x88, 0x1c, 0x8a, 0x1, 0x71, 0x2, 0x0, 0x0, 0x6d, 0xc0, 0x1c, 0x0, 0x1b, 0x64, 0xac, 0x71, - 0xe7, 0xae, 0xe8, 0x76, 0x16, 0x6, 0xd5, 0xbd, 0x2c, 0x3d, 0x84, 0x12, 0x90, 0xeb, 0x7a, 0x9, - 0x25, 0x7f, 0xe3, 0xe6, 0x93, 0x39, 0xc6, 0x3b, 0x28, 0x64, 0x17, 0x9f, 0x23, 0x73, 0xdb, 0x8, - 0x0, 0x4, 0x5, 0x74, 0xa5, 0x5b, 0x21, 0x5d, 0x4a, 0x28, 0x13, 0xce, 0x1f, 0xb7, 0xb8, 0xcf, - 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; + uint8_t pkt[] = {0x39, 0x4f, 0x0, 0x0, 0x44, 0x18, 0x0, 0x0, 0x44, 0x7a, 0x22, 0x50, 0xcb, 0x2, 0x0, 0x0, 0x16, + 0xad, 0x25, 0x13, 0x26, 0x0, 0x15, 0xaf, 0x90, 0xc0, 0x98, 0xe7, 0x55, 0x8d, 0xbf, 0x17, 0x95, 0xfe, + 0xe3, 0x58, 0x95, 0x7, 0x18, 0xa8, 0x51, 0x61, 0x32, 0x10, 0x0, 0x16, 0xc8, 0x63, 0x10, 0xcc, 0x95, + 0x62, 0x92, 0xe7, 0x34, 0x65, 0x4f, 0x1c, 0xaa, 0x91, 0x2e, 0xfd, 0xf7, 0x6f, 0x86, 0x27, 0x68, 0xa0, + 0x2, 0x0, 0x0, 0x3, 0x24, 0xfd, 0x64, 0xb2, 0x5d, 0xce, 0x10, 0xa3, 0x3b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4679,134 +5082,83 @@ TEST(Publish5QCTest, Decode27) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x4f, 0xd8, 0xba}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xce, 0x1f, 0xb7, 0xb8, 0xcf, 0xc6, 0x58, 0xd8, 0xe, 0x6e, 0xca, 0x20, 0xd6}; - lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfd, 0x64, 0xb2, 0x5d, 0xce, 0x10, 0xa3, 0x3b}; + lwmqtt_string_t exp_body = {8, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 31863); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 13); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 8); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "r8* -// \EM\150\251uUH\DEL\151\232\SOH\RS\240\192\167=\255\246\193\250*<", _pubPktID = 26145, _pubBody = -// "\165\DC2\SOH6&\169\226\233\172\134`\205\149\221__", _pubProps = [PropRequestProblemInformation 48,PropReceiveMaximum -// 6809,PropMessageExpiryInterval 14400,PropUserProperty "\212\RSv!\211" -// "\156h\\\138^\159\139P\172\217\153\"\130|\137}\SOH\249\187\141\215\172",PropMessageExpiryInterval -// 29289,PropAuthenticationData -// "\DC4\DEL\172\&5\147\250\NUL\154M\t\146@\234\176\244\226q\218i\252\147\170NpB\213\248\134w!",PropSessionExpiryInterval -// 14509,PropReceiveMaximum 27484,PropContentType -// "H\228\SYN\255;x\209\150\154\165\179!\200\159O)E\189\128*\132\SI\154\235\ENQ{\180\154h",PropSubscriptionIdentifierAvailable -// 195,PropTopicAliasMaximum 24651,PropContentType -// "\140\196p2\EM\213p\178\139`o&\139\215CP\210\198\170\227A\221\195\205",PropWillDelayInterval -// 31842,PropServerKeepAlive 227,PropRequestResponseInformation 96,PropSubscriptionIdentifierAvailable -// 234,PropTopicAlias 30778,PropSubscriptionIdentifierAvailable 201,PropRequestResponseInformation -// 153,PropSubscriptionIdentifier 8,PropWildcardSubscriptionAvailable 6,PropMessageExpiryInterval 27590]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// ";\204\SI\135:\SYN%u\222\217#\130\225N", _pubPktID = 14774, _pubBody = "\250v\SUB", _pubProps = +// [PropMessageExpiryInterval 2660,PropRequestProblemInformation 166,PropSessionExpiryInterval 11525,PropServerKeepAlive +// 5182,PropMessageExpiryInterval 27872,PropMessageExpiryInterval 24795,PropWillDelayInterval +// 12455,PropMessageExpiryInterval 27092,PropCorrelationData "\165s9\164\151\186",PropPayloadFormatIndicator +// 6,PropReasonString "\DLE%q\242@\130`\133lp\155\179\145"]} TEST(Publish5QCTest, Encode28) { - uint8_t pkt[] = {0x32, 0xe3, 0x1, 0x0, 0x19, 0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, - 0xe8, 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c, 0x66, 0x21, 0xb4, 0x1, - 0x17, 0x30, 0x21, 0x1a, 0x99, 0x2, 0x0, 0x0, 0x38, 0x40, 0x26, 0x0, 0x5, 0xd4, 0x1e, 0x76, 0x21, - 0xd3, 0x0, 0x16, 0x9c, 0x68, 0x5c, 0x8a, 0x5e, 0x9f, 0x8b, 0x50, 0xac, 0xd9, 0x99, 0x22, 0x82, 0x7c, - 0x89, 0x7d, 0x1, 0xf9, 0xbb, 0x8d, 0xd7, 0xac, 0x2, 0x0, 0x0, 0x72, 0x69, 0x16, 0x0, 0x1e, 0x14, - 0x7f, 0xac, 0x35, 0x93, 0xfa, 0x0, 0x9a, 0x4d, 0x9, 0x92, 0x40, 0xea, 0xb0, 0xf4, 0xe2, 0x71, 0xda, - 0x69, 0xfc, 0x93, 0xaa, 0x4e, 0x70, 0x42, 0xd5, 0xf8, 0x86, 0x77, 0x21, 0x11, 0x0, 0x0, 0x38, 0xad, - 0x21, 0x6b, 0x5c, 0x3, 0x0, 0x1d, 0x48, 0xe4, 0x16, 0xff, 0x3b, 0x78, 0xd1, 0x96, 0x9a, 0xa5, 0xb3, - 0x21, 0xc8, 0x9f, 0x4f, 0x29, 0x45, 0xbd, 0x80, 0x2a, 0x84, 0xf, 0x9a, 0xeb, 0x5, 0x7b, 0xb4, 0x9a, - 0x68, 0x29, 0xc3, 0x22, 0x60, 0x4b, 0x3, 0x0, 0x18, 0x8c, 0xc4, 0x70, 0x32, 0x19, 0xd5, 0x70, 0xb2, - 0x8b, 0x60, 0x6f, 0x26, 0x8b, 0xd7, 0x43, 0x50, 0xd2, 0xc6, 0xaa, 0xe3, 0x41, 0xdd, 0xc3, 0xcd, 0x18, - 0x0, 0x0, 0x7c, 0x62, 0x13, 0x0, 0xe3, 0x19, 0x60, 0x29, 0xea, 0x23, 0x78, 0x3a, 0x29, 0xc9, 0x19, - 0x99, 0xb, 0x8, 0x28, 0x6, 0x2, 0x0, 0x0, 0x6b, 0xc6, 0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, - 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; - uint8_t topic_bytes[] = {0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, 0xe8, - 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x35, 0x54, 0x0, 0xe, 0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, + 0x82, 0xe1, 0x4e, 0x39, 0xb6, 0x3e, 0x2, 0x0, 0x0, 0xa, 0x64, 0x17, 0xa6, 0x11, 0x0, + 0x0, 0x2d, 0x5, 0x13, 0x14, 0x3e, 0x2, 0x0, 0x0, 0x6c, 0xe0, 0x2, 0x0, 0x0, 0x60, + 0xdb, 0x18, 0x0, 0x0, 0x30, 0xa7, 0x2, 0x0, 0x0, 0x69, 0xd4, 0x9, 0x0, 0x6, 0xa5, + 0x73, 0x39, 0xa4, 0x97, 0xba, 0x1, 0x6, 0x1f, 0x0, 0xd, 0x10, 0x25, 0x71, 0xf2, 0x40, + 0x82, 0x60, 0x85, 0x6c, 0x70, 0x9b, 0xb3, 0x91, 0xfa, 0x76, 0x1a}; + uint8_t topic_bytes[] = {0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; + msg.qos = LWMQTT_QOS2; + msg.retained = true; + uint8_t msg_bytes[] = {0xfa, 0x76, 0x1a}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 3; - uint8_t bytesprops1[] = {0x9c, 0x68, 0x5c, 0x8a, 0x5e, 0x9f, 0x8b, 0x50, 0xac, 0xd9, 0x99, - 0x22, 0x82, 0x7c, 0x89, 0x7d, 0x1, 0xf9, 0xbb, 0x8d, 0xd7, 0xac}; - uint8_t bytesprops0[] = {0xd4, 0x1e, 0x76, 0x21, 0xd3}; - uint8_t bytesprops2[] = {0x14, 0x7f, 0xac, 0x35, 0x93, 0xfa, 0x0, 0x9a, 0x4d, 0x9, 0x92, 0x40, 0xea, 0xb0, 0xf4, - 0xe2, 0x71, 0xda, 0x69, 0xfc, 0x93, 0xaa, 0x4e, 0x70, 0x42, 0xd5, 0xf8, 0x86, 0x77, 0x21}; - uint8_t bytesprops3[] = {0x48, 0xe4, 0x16, 0xff, 0x3b, 0x78, 0xd1, 0x96, 0x9a, 0xa5, 0xb3, 0x21, 0xc8, 0x9f, 0x4f, - 0x29, 0x45, 0xbd, 0x80, 0x2a, 0x84, 0xf, 0x9a, 0xeb, 0x5, 0x7b, 0xb4, 0x9a, 0x68}; - uint8_t bytesprops4[] = {0x8c, 0xc4, 0x70, 0x32, 0x19, 0xd5, 0x70, 0xb2, 0x8b, 0x60, 0x6f, 0x26, - 0x8b, 0xd7, 0x43, 0x50, 0xd2, 0xc6, 0xaa, 0xe3, 0x41, 0xdd, 0xc3, 0xcd}; + uint8_t bytesprops0[] = {0xa5, 0x73, 0x39, 0xa4, 0x97, 0xba}; + uint8_t bytesprops1[] = {0x10, 0x25, 0x71, 0xf2, 0x40, 0x82, 0x60, 0x85, 0x6c, 0x70, 0x9b, 0xb3, 0x91}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6809}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14400}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops0}, .v = {22, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29289}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14509}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27484}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24651}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31842}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 227}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30778}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27590}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2660}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11525}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5182}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27872}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24795}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12455}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27092}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 26145, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14774, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "r8* -// \EM\150\251uUH\DEL\151\232\SOH\RS\240\192\167=\255\246\193\250*<", _pubPktID = 26145, _pubBody = -// "\165\DC2\SOH6&\169\226\233\172\134`\205\149\221__", _pubProps = [PropRequestProblemInformation 48,PropReceiveMaximum -// 6809,PropMessageExpiryInterval 14400,PropUserProperty "\212\RSv!\211" -// "\156h\\\138^\159\139P\172\217\153\"\130|\137}\SOH\249\187\141\215\172",PropMessageExpiryInterval -// 29289,PropAuthenticationData -// "\DC4\DEL\172\&5\147\250\NUL\154M\t\146@\234\176\244\226q\218i\252\147\170NpB\213\248\134w!",PropSessionExpiryInterval -// 14509,PropReceiveMaximum 27484,PropContentType -// "H\228\SYN\255;x\209\150\154\165\179!\200\159O)E\189\128*\132\SI\154\235\ENQ{\180\154h",PropSubscriptionIdentifierAvailable -// 195,PropTopicAliasMaximum 24651,PropContentType -// "\140\196p2\EM\213p\178\139`o&\139\215CP\210\198\170\227A\221\195\205",PropWillDelayInterval -// 31842,PropServerKeepAlive 227,PropRequestResponseInformation 96,PropSubscriptionIdentifierAvailable -// 234,PropTopicAlias 30778,PropSubscriptionIdentifierAvailable 201,PropRequestResponseInformation -// 153,PropSubscriptionIdentifier 8,PropWildcardSubscriptionAvailable 6,PropMessageExpiryInterval 27590]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = +// ";\204\SI\135:\SYN%u\222\217#\130\225N", _pubPktID = 14774, _pubBody = "\250v\SUB", _pubProps = +// [PropMessageExpiryInterval 2660,PropRequestProblemInformation 166,PropSessionExpiryInterval 11525,PropServerKeepAlive +// 5182,PropMessageExpiryInterval 27872,PropMessageExpiryInterval 24795,PropWillDelayInterval +// 12455,PropMessageExpiryInterval 27092,PropCorrelationData "\165s9\164\151\186",PropPayloadFormatIndicator +// 6,PropReasonString "\DLE%q\242@\130`\133lp\155\179\145"]} TEST(Publish5QCTest, Decode28) { - uint8_t pkt[] = {0x32, 0xe3, 0x1, 0x0, 0x19, 0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, - 0xe8, 0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, 0xb, 0x8, 0x28, 0x6, 0x2, 0x0, 0x0, 0x6b, 0xc6, 0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, - 0xe9, 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; + uint8_t pkt[] = {0x35, 0x54, 0x0, 0xe, 0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, + 0x82, 0xe1, 0x4e, 0x39, 0xb6, 0x3e, 0x2, 0x0, 0x0, 0xa, 0x64, 0x17, 0xa6, 0x11, 0x0, + 0x0, 0x2d, 0x5, 0x13, 0x14, 0x3e, 0x2, 0x0, 0x0, 0x6c, 0xe0, 0x2, 0x0, 0x0, 0x60, + 0xdb, 0x18, 0x0, 0x0, 0x30, 0xa7, 0x2, 0x0, 0x0, 0x69, 0xd4, 0x9, 0x0, 0x6, 0xa5, + 0x73, 0x39, 0xa4, 0x97, 0xba, 0x1, 0x6, 0x1f, 0x0, 0xd, 0x10, 0x25, 0x71, 0xf2, 0x40, + 0x82, 0x60, 0x85, 0x6c, 0x70, 0x9b, 0xb3, 0x91, 0xfa, 0x76, 0x1a}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4815,66 +5167,136 @@ TEST(Publish5QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x72, 0x38, 0x2a, 0x20, 0x19, 0x96, 0xfb, 0x75, 0x55, 0x48, 0x7f, 0x97, 0xe8, - 0x1, 0x1e, 0xf0, 0xc0, 0xa7, 0x3d, 0xff, 0xf6, 0xc1, 0xfa, 0x2a, 0x3c}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xa5, 0x12, 0x1, 0x36, 0x26, 0xa9, 0xe2, 0xe9, - 0xac, 0x86, 0x60, 0xcd, 0x95, 0xdd, 0x5f, 0x5f}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfa, 0x76, 0x1a}; + lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 26145); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 14774); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 7976, _pubBody = -// "\ENQP\a\164\163\166{\250{", _pubProps = [PropWillDelayInterval 3340,PropSubscriptionIdentifierAvailable -// 115,PropAuthenticationMethod "0\192j1e\ACK",PropReasonString "\r\173"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "M\189d\165\NAK\165J\222\187)\216\178d^\194{\141\141y\145", _pubPktID = 0, _pubBody = +// "\245\129\188\154\242\232\161\228\255\&1lz\153\252~D\r\222\166\ENQ", _pubProps = [PropPayloadFormatIndicator +// 241,PropPayloadFormatIndicator 35,PropTopicAliasMaximum 26102,PropTopicAlias 18197,PropTopicAlias +// 25483,PropSessionExpiryInterval 27654,PropAssignedClientIdentifier "\206\145\164\154V\DC3!\f(",PropResponseTopic +// "F\233\225\208\172A\218\165ql\212\244\168\174Z\158:Q\ESC\153\245\176\&6\142",PropCorrelationData +// "\146\169!\238\195D\204\250c8(\128\SYN\251\166\239)\138\178\156i\162\156]",PropSharedSubscriptionAvailable +// 64,PropCorrelationData "x2\137\204(\204\222",PropSharedSubscriptionAvailable 227,PropCorrelationData +// "g\STXSE*\131\240-\190\ACK\155%n_\130\226\255dR\162",PropReasonString +// "\193\185pZ\NUL\156\171\185LE\132\253\US\229\185\DEL\211\201i\DLE8\184\228\RS\196S\247\247",PropAuthenticationData +// "\238\172",PropSharedSubscriptionAvailable 148,PropUserProperty +// "\160\193\191\DC2AA\232\150W\161\252\177\227\a\175\160\SYNL\212\239fO\247'<.\ENQ\224{" +// "\184?u*}_F\134\&8(\r\242|a\186O2"]} TEST(Publish5QCTest, Encode29) { - uint8_t pkt[] = {0x3b, 0x23, 0x0, 0x0, 0x1f, 0x28, 0x15, 0x18, 0x0, 0x0, 0xd, 0xc, 0x29, - 0x73, 0x15, 0x0, 0x6, 0x30, 0xc0, 0x6a, 0x31, 0x65, 0x6, 0x1f, 0x0, 0x2, - 0xd, 0xad, 0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x30, 0xfe, 0x1, 0x0, 0x14, 0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, 0xd8, 0xb2, 0x64, 0x5e, + 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91, 0xd2, 0x1, 0x1, 0xf1, 0x1, 0x23, 0x22, 0x65, 0xf6, 0x23, 0x47, 0x15, 0x23, + 0x63, 0x8b, 0x11, 0x0, 0x0, 0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0x38, 0x28, 0xd, 0xf2, 0x7c, 0x61, 0xba, 0x4f, 0x32, 0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, + 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; + uint8_t topic_bytes[] = {0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, + 0xd8, 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, + 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 9; + msg.payload_len = 20; - uint8_t bytesprops0[] = {0x30, 0xc0, 0x6a, 0x31, 0x65, 0x6}; - uint8_t bytesprops1[] = {0xd, 0xad}; + uint8_t bytesprops0[] = {0xce, 0x91, 0xa4, 0x9a, 0x56, 0x13, 0x21, 0xc, 0x28}; + uint8_t bytesprops1[] = {0x46, 0xe9, 0xe1, 0xd0, 0xac, 0x41, 0xda, 0xa5, 0x71, 0x6c, 0xd4, 0xf4, + 0xa8, 0xae, 0x5a, 0x9e, 0x3a, 0x51, 0x1b, 0x99, 0xf5, 0xb0, 0x36, 0x8e}; + uint8_t bytesprops2[] = {0x92, 0xa9, 0x21, 0xee, 0xc3, 0x44, 0xcc, 0xfa, 0x63, 0x38, 0x28, 0x80, + 0x16, 0xfb, 0xa6, 0xef, 0x29, 0x8a, 0xb2, 0x9c, 0x69, 0xa2, 0x9c, 0x5d}; + uint8_t bytesprops3[] = {0x78, 0x32, 0x89, 0xcc, 0x28, 0xcc, 0xde}; + uint8_t bytesprops4[] = {0x67, 0x2, 0x53, 0x45, 0x2a, 0x83, 0xf0, 0x2d, 0xbe, 0x6, + 0x9b, 0x25, 0x6e, 0x5f, 0x82, 0xe2, 0xff, 0x64, 0x52, 0xa2}; + uint8_t bytesprops5[] = {0xc1, 0xb9, 0x70, 0x5a, 0x0, 0x9c, 0xab, 0xb9, 0x4c, 0x45, 0x84, 0xfd, 0x1f, 0xe5, + 0xb9, 0x7f, 0xd3, 0xc9, 0x69, 0x10, 0x38, 0xb8, 0xe4, 0x1e, 0xc4, 0x53, 0xf7, 0xf7}; + uint8_t bytesprops6[] = {0xee, 0xac}; + uint8_t bytesprops8[] = {0xb8, 0x3f, 0x75, 0x2a, 0x7d, 0x5f, 0x46, 0x86, 0x38, + 0x28, 0xd, 0xf2, 0x7c, 0x61, 0xba, 0x4f, 0x32}; + uint8_t bytesprops7[] = {0xa0, 0xc1, 0xbf, 0x12, 0x41, 0x41, 0xe8, 0x96, 0x57, 0xa1, 0xfc, 0xb1, 0xe3, 0x7, 0xaf, + 0xa0, 0x16, 0x4c, 0xd4, 0xef, 0x66, 0x4f, 0xf7, 0x27, 0x3c, 0x2e, 0x5, 0xe0, 0x7b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3340}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26102}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18197}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25483}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27654}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops7}, .v = {17, (char*)&bytesprops8}}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 7976, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "", _pubPktID = 7976, _pubBody = -// "\ENQP\a\164\163\166{\250{", _pubProps = [PropWillDelayInterval 3340,PropSubscriptionIdentifierAvailable -// 115,PropAuthenticationMethod "0\192j1e\ACK",PropReasonString "\r\173"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "M\189d\165\NAK\165J\222\187)\216\178d^\194{\141\141y\145", _pubPktID = 0, _pubBody = +// "\245\129\188\154\242\232\161\228\255\&1lz\153\252~D\r\222\166\ENQ", _pubProps = [PropPayloadFormatIndicator +// 241,PropPayloadFormatIndicator 35,PropTopicAliasMaximum 26102,PropTopicAlias 18197,PropTopicAlias +// 25483,PropSessionExpiryInterval 27654,PropAssignedClientIdentifier "\206\145\164\154V\DC3!\f(",PropResponseTopic +// "F\233\225\208\172A\218\165ql\212\244\168\174Z\158:Q\ESC\153\245\176\&6\142",PropCorrelationData +// "\146\169!\238\195D\204\250c8(\128\SYN\251\166\239)\138\178\156i\162\156]",PropSharedSubscriptionAvailable +// 64,PropCorrelationData "x2\137\204(\204\222",PropSharedSubscriptionAvailable 227,PropCorrelationData +// "g\STXSE*\131\240-\190\ACK\155%n_\130\226\255dR\162",PropReasonString +// "\193\185pZ\NUL\156\171\185LE\132\253\US\229\185\DEL\211\201i\DLE8\184\228\RS\196S\247\247",PropAuthenticationData +// "\238\172",PropSharedSubscriptionAvailable 148,PropUserProperty +// "\160\193\191\DC2AA\232\150W\161\252\177\227\a\175\160\SYNL\212\239fO\247'<.\ENQ\224{" +// "\184?u*}_F\134\&8(\r\242|a\186O2"]} TEST(Publish5QCTest, Decode29) { - uint8_t pkt[] = {0x3b, 0x23, 0x0, 0x0, 0x1f, 0x28, 0x15, 0x18, 0x0, 0x0, 0xd, 0xc, 0x29, - 0x73, 0x15, 0x0, 0x6, 0x30, 0xc0, 0x6a, 0x31, 0x65, 0x6, 0x1f, 0x0, 0x2, - 0xd, 0xad, 0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; + uint8_t pkt[] = { + 0x30, 0xfe, 0x1, 0x0, 0x14, 0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0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a1, 0xfc, 0xb1, 0xe3, 0x7, 0xaf, 0xa0, 0x16, 0x4c, 0xd4, 0xef, + 0x66, 0x4f, 0xf7, 0x27, 0x3c, 0x2e, 0x5, 0xe0, 0x7b, 0x0, 0x11, 0xb8, 0x3f, 0x75, 0x2a, 0x7d, 0x5f, 0x46, 0x86, + 0x38, 0x28, 0xd, 0xf2, 0x7c, 0x61, 0xba, 0x4f, 0x32, 0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, + 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4883,100 +5305,56 @@ TEST(Publish5QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x5, 0x50, 0x7, 0xa4, 0xa3, 0xa6, 0x7b, 0xfa, 0x7b}; - lwmqtt_string_t exp_body = {9, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 7976); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 9); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 9); + uint8_t exp_topic_bytes[] = {0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, + 0xd8, 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, + 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; + lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 20); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\197\a\164\SUB\DC1\195\RS`\FS\155?\206\154I\134\181\139\252Vc\161i`\DC3\245", _pubPktID = 3213, _pubBody = -// "\249a\NAK\209f+\v\251'\141\199\&6\195s\160^:v\251\&5\174\FS\240\191k\205\"\201\222=", _pubProps = [PropResponseTopic -// "\227\163\184+",PropAssignedClientIdentifier "\231\&6\243\150\NAK\194\191\142e",PropPayloadFormatIndicator -// 184,PropRequestProblemInformation 163,PropResponseInformation -// "\213^\232,F\184\\p\DC3L?\221\DC1\DC1\153#\DC3UYf\242\192\234\142LV",PropMaximumQoS 81,PropCorrelationData -// "\131\229\227oU\136O\"zQ\191\211$\214\&79",PropAuthenticationData "\213\215\v\179~l\190c -// \165wh.\181\208u\128\133\t\243\161\232\SOHB"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "3V\138y.\181\&0", _pubPktID = 0, +// _pubBody = "2\248\176\206\GS<\197b\195`\241\aH", _pubProps = [PropRequestProblemInformation 172]} TEST(Publish5QCTest, Encode30) { - uint8_t pkt[] = {0x35, 0xa0, 0x1, 0x0, 0x19, 0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, - 0x9a, 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5, 0xc, 0x8d, 0x64, 0x8, - 0x0, 0x4, 0xe3, 0xa3, 0xb8, 0x2b, 0x12, 0x0, 0x9, 0xe7, 0x36, 0xf3, 0x96, 0x15, 0xc2, 0xbf, 0x8e, - 0x65, 0x1, 0xb8, 0x17, 0xa3, 0x1a, 0x0, 0x1a, 0xd5, 0x5e, 0xe8, 0x2c, 0x46, 0xb8, 0x5c, 0x70, 0x13, - 0x4c, 0x3f, 0xdd, 0x11, 0x11, 0x99, 0x23, 0x13, 0x55, 0x59, 0x66, 0xf2, 0xc0, 0xea, 0x8e, 0x4c, 0x56, - 0x24, 0x51, 0x9, 0x0, 0x10, 0x83, 0xe5, 0xe3, 0x6f, 0x55, 0x88, 0x4f, 0x22, 0x7a, 0x51, 0xbf, 0xd3, - 0x24, 0xd6, 0x37, 0x39, 0x16, 0x0, 0x18, 0xd5, 0xd7, 0xb, 0xb3, 0x7e, 0x6c, 0xbe, 0x63, 0x20, 0xa5, - 0x77, 0x68, 0x2e, 0xb5, 0xd0, 0x75, 0x80, 0x85, 0x9, 0xf3, 0xa1, 0xe8, 0x1, 0x42, 0xf9, 0x61, 0x15, - 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, 0x5e, 0x3a, 0x76, 0xfb, 0x35, - 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; - uint8_t topic_bytes[] = {0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, 0x9a, - 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x19, 0x0, 0x7, 0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30, 0x2, 0x17, 0xac, + 0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; + uint8_t topic_bytes[] = {0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0xf9, 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, - 0x5e, 0x3a, 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; + uint8_t msg_bytes[] = {0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 30; - - uint8_t bytesprops0[] = {0xe3, 0xa3, 0xb8, 0x2b}; - uint8_t bytesprops1[] = {0xe7, 0x36, 0xf3, 0x96, 0x15, 0xc2, 0xbf, 0x8e, 0x65}; - uint8_t bytesprops2[] = {0xd5, 0x5e, 0xe8, 0x2c, 0x46, 0xb8, 0x5c, 0x70, 0x13, 0x4c, 0x3f, 0xdd, 0x11, - 0x11, 0x99, 0x23, 0x13, 0x55, 0x59, 0x66, 0xf2, 0xc0, 0xea, 0x8e, 0x4c, 0x56}; - uint8_t bytesprops3[] = {0x83, 0xe5, 0xe3, 0x6f, 0x55, 0x88, 0x4f, 0x22, - 0x7a, 0x51, 0xbf, 0xd3, 0x24, 0xd6, 0x37, 0x39}; - uint8_t bytesprops4[] = {0xd5, 0xd7, 0xb, 0xb3, 0x7e, 0x6c, 0xbe, 0x63, 0x20, 0xa5, 0x77, 0x68, - 0x2e, 0xb5, 0xd0, 0x75, 0x80, 0x85, 0x9, 0xf3, 0xa1, 0xe8, 0x1, 0x42}; + msg.payload_len = 13; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 172}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 3213, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// "\197\a\164\SUB\DC1\195\RS`\FS\155?\206\154I\134\181\139\252Vc\161i`\DC3\245", _pubPktID = 3213, _pubBody = -// "\249a\NAK\209f+\v\251'\141\199\&6\195s\160^:v\251\&5\174\FS\240\191k\205\"\201\222=", _pubProps = [PropResponseTopic -// "\227\163\184+",PropAssignedClientIdentifier "\231\&6\243\150\NAK\194\191\142e",PropPayloadFormatIndicator -// 184,PropRequestProblemInformation 163,PropResponseInformation -// "\213^\232,F\184\\p\DC3L?\221\DC1\DC1\153#\DC3UYf\242\192\234\142LV",PropMaximumQoS 81,PropCorrelationData -// "\131\229\227oU\136O\"zQ\191\211$\214\&79",PropAuthenticationData "\213\215\v\179~l\190c -// \165wh.\181\208u\128\133\t\243\161\232\SOHB"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "3V\138y.\181\&0", _pubPktID = 0, +// _pubBody = "2\248\176\206\GS<\197b\195`\241\aH", _pubProps = [PropRequestProblemInformation 172]} TEST(Publish5QCTest, Decode30) { - uint8_t pkt[] = {0x35, 0xa0, 0x1, 0x0, 0x19, 0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, - 0x9a, 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5, 0xc, 0x8d, 0x64, 0x8, - 0x0, 0x4, 0xe3, 0xa3, 0xb8, 0x2b, 0x12, 0x0, 0x9, 0xe7, 0x36, 0xf3, 0x96, 0x15, 0xc2, 0xbf, 0x8e, - 0x65, 0x1, 0xb8, 0x17, 0xa3, 0x1a, 0x0, 0x1a, 0xd5, 0x5e, 0xe8, 0x2c, 0x46, 0xb8, 0x5c, 0x70, 0x13, - 0x4c, 0x3f, 0xdd, 0x11, 0x11, 0x99, 0x23, 0x13, 0x55, 0x59, 0x66, 0xf2, 0xc0, 0xea, 0x8e, 0x4c, 0x56, - 0x24, 0x51, 0x9, 0x0, 0x10, 0x83, 0xe5, 0xe3, 0x6f, 0x55, 0x88, 0x4f, 0x22, 0x7a, 0x51, 0xbf, 0xd3, - 0x24, 0xd6, 0x37, 0x39, 0x16, 0x0, 0x18, 0xd5, 0xd7, 0xb, 0xb3, 0x7e, 0x6c, 0xbe, 0x63, 0x20, 0xa5, - 0x77, 0x68, 0x2e, 0xb5, 0xd0, 0x75, 0x80, 0x85, 0x9, 0xf3, 0xa1, 0xe8, 0x1, 0x42, 0xf9, 0x61, 0x15, - 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, 0x5e, 0x3a, 0x76, 0xfb, 0x35, - 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; + uint8_t pkt[] = {0x31, 0x19, 0x0, 0x7, 0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30, 0x2, 0x17, 0xac, + 0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4985,4526 +5363,3480 @@ TEST(Publish5QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc5, 0x7, 0xa4, 0x1a, 0x11, 0xc3, 0x1e, 0x60, 0x1c, 0x9b, 0x3f, 0xce, 0x9a, - 0x49, 0x86, 0xb5, 0x8b, 0xfc, 0x56, 0x63, 0xa1, 0x69, 0x60, 0x13, 0xf5}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf9, 0x61, 0x15, 0xd1, 0x66, 0x2b, 0xb, 0xfb, 0x27, 0x8d, 0xc7, 0x36, 0xc3, 0x73, 0xa0, - 0x5e, 0x3a, 0x76, 0xfb, 0x35, 0xae, 0x1c, 0xf0, 0xbf, 0x6b, 0xcd, 0x22, 0xc9, 0xde, 0x3d}; - lwmqtt_string_t exp_body = {30, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 3213); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 30); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 30); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// ConnectRequest {_username = Just "\160\151\149a\211\ACK*?\149\202\211vrIu\153\DC2\173\173!\ACK", _password = Just -// "\212\133\STX\STX\240\131p", _lastWill = Nothing, _cleanSession = False, _keepAlive = 1099, _connID = -// "1\a\221\162V\235\244\238\188\&2v1%G\151H4@{\224\180\180\184\194\165\&2\138\141\204", _properties = []} -TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x49, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x4, 0x4b, 0x0, 0x1d, 0x31, - 0x7, 0xdd, 0xa2, 0x56, 0xeb, 0xf4, 0xee, 0xbc, 0x32, 0x76, 0x31, 0x25, 0x47, 0x97, 0x48, - 0x34, 0x40, 0x7b, 0xe0, 0xb4, 0xb4, 0xb8, 0xc2, 0xa5, 0x32, 0x8a, 0x8d, 0xcc, 0x0, 0x15, - 0xa0, 0x97, 0x95, 0x61, 0xd3, 0x6, 0x2a, 0x3f, 0x95, 0xca, 0xd3, 0x76, 0x72, 0x49, 0x75, - 0x99, 0x12, 0xad, 0xad, 0x21, 0x6, 0x0, 0x7, 0xd4, 0x85, 0x2, 0x2, 0xf0, 0x83, 0x70}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 14158 0 []) +TEST(PubACKACK311QCTest, Encode1) { + uint8_t pkt[] = {0x40, 0x2, 0x37, 0x4e}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 1099; - uint8_t client_id_bytes[] = {0x31, 0x7, 0xdd, 0xa2, 0x56, 0xeb, 0xf4, 0xee, 0xbc, 0x32, 0x76, 0x31, 0x25, 0x47, 0x97, - 0x48, 0x34, 0x40, 0x7b, 0xe0, 0xb4, 0xb4, 0xb8, 0xc2, 0xa5, 0x32, 0x8a, 0x8d, 0xcc}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa0, 0x97, 0x95, 0x61, 0xd3, 0x6, 0x2a, 0x3f, 0x95, 0xca, 0xd3, - 0x76, 0x72, 0x49, 0x75, 0x99, 0x12, 0xad, 0xad, 0x21, 0x6}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xd4, 0x85, 0x2, 0x2, 0xf0, 0x83, 0x70}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 14158, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\245\FSg\131", _password = Just "\SO\141\210", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS0, _willTopic = "\152\255\131ME_\ENQ\227\fVV\141\172", _willMsg = -// "\152\v\143\189\254\149a\FS7i\f_\220\240\209\232", _willProps = []}), _cleanSession = True, _keepAlive = 4861, -// _connID = "=\b:\142\144", _properties = []} -TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x12, 0xfd, 0x0, 0x5, 0x3d, 0x8, - 0x3a, 0x8e, 0x90, 0x0, 0xd, 0x98, 0xff, 0x83, 0x4d, 0x45, 0x5f, 0x5, 0xe3, 0xc, 0x56, 0x56, - 0x8d, 0xac, 0x0, 0x10, 0x98, 0xb, 0x8f, 0xbd, 0xfe, 0x95, 0x61, 0x1c, 0x37, 0x69, 0xc, 0x5f, - 0xdc, 0xf0, 0xd1, 0xe8, 0x0, 0x4, 0xf5, 0x1c, 0x67, 0x83, 0x0, 0x3, 0xe, 0x8d, 0xd2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 14158 0 []) +TEST(PubACKACK311QCTest, Decode1) { + uint8_t pkt[] = {0x40, 0x2, 0x37, 0x4e}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 14158); + EXPECT_EQ(status, 0); +} + +// ACK (PubACK 24514 0 []) +TEST(PubACKACK311QCTest, Encode2) { + uint8_t pkt[] = {0x40, 0x2, 0x5f, 0xc2}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x98, 0xff, 0x83, 0x4d, 0x45, 0x5f, 0x5, 0xe3, 0xc, 0x56, 0x56, 0x8d, 0xac}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x98, 0xb, 0x8f, 0xbd, 0xfe, 0x95, 0x61, 0x1c, - 0x37, 0x69, 0xc, 0x5f, 0xdc, 0xf0, 0xd1, 0xe8}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 4861; - uint8_t client_id_bytes[] = {0x3d, 0x8, 0x3a, 0x8e, 0x90}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xf5, 0x1c, 0x67, 0x83}; - lwmqtt_string_t username = {4, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe, 0x8d, 0xd2}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 24514, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\190~\232\224\v\218x\135\ESC\193\243\132\192\&1\150\134+\245\EOT9\235j\175", -// _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 11488, _connID = "", _properties = []} -TEST(Connect311QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0x25, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x2c, 0xe0, 0x0, - 0x0, 0x0, 0x17, 0xbe, 0x7e, 0xe8, 0xe0, 0xb, 0xda, 0x78, 0x87, 0x1b, 0xc1, - 0xf3, 0x84, 0xc0, 0x31, 0x96, 0x86, 0x2b, 0xf5, 0x4, 0x39, 0xeb, 0x6a, 0xaf}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 24514 0 []) +TEST(PubACKACK311QCTest, Decode2) { + uint8_t pkt[] = {0x40, 0x2, 0x5f, 0xc2}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 24514); + EXPECT_EQ(status, 0); +} + +// REC (PubREC 28006 0 []) +TEST(PubACKREC311QCTest, Encode3) { + uint8_t pkt[] = {0x50, 0x2, 0x6d, 0x66}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 11488; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xbe, 0x7e, 0xe8, 0xe0, 0xb, 0xda, 0x78, 0x87, 0x1b, 0xc1, 0xf3, 0x84, - 0xc0, 0x31, 0x96, 0x86, 0x2b, 0xf5, 0x4, 0x39, 0xeb, 0x6a, 0xaf}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 28006, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "_\DLE\201\254`\162\246\240I", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "\248J", _willMsg = -// "\RSG\205\252\RSP\173\SO\195\CAN\209PX\DC1c:\218\166G\158\ACK", _willProps = []}), _cleanSession = True, _keepAlive = -// 31889, _connID = "I.j%\170?\194\183h\143.\150\255", _properties = []} -TEST(Connect311QCTest, Encode4) { - uint8_t pkt[] = {0x10, 0x3f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xae, 0x7c, 0x91, 0x0, 0xd, 0x49, 0x2e, 0x6a, - 0x25, 0xaa, 0x3f, 0xc2, 0xb7, 0x68, 0x8f, 0x2e, 0x96, 0xff, 0x0, 0x2, 0xf8, 0x4a, 0x0, 0x15, 0x1e, - 0x47, 0xcd, 0xfc, 0x1e, 0x50, 0xad, 0xe, 0xc3, 0x18, 0xd1, 0x50, 0x58, 0x11, 0x63, 0x3a, 0xda, 0xa6, - 0x47, 0x9e, 0x6, 0x0, 0x9, 0x5f, 0x10, 0xc9, 0xfe, 0x60, 0xa2, 0xf6, 0xf0, 0x49}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// REC (PubREC 28006 0 []) +TEST(PubACKREC311QCTest, Decode3) { + uint8_t pkt[] = {0x50, 0x2, 0x6d, 0x66}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 28006); + EXPECT_EQ(status, 0); +} + +// COMP (PubCOMP 4881 0 []) +TEST(PubACKCOMP311QCTest, Encode4) { + uint8_t pkt[] = {0x70, 0x2, 0x13, 0x11}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf8, 0x4a}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1e, 0x47, 0xcd, 0xfc, 0x1e, 0x50, 0xad, 0xe, 0xc3, 0x18, 0xd1, - 0x50, 0x58, 0x11, 0x63, 0x3a, 0xda, 0xa6, 0x47, 0x9e, 0x6}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 31889; - uint8_t client_id_bytes[] = {0x49, 0x2e, 0x6a, 0x25, 0xaa, 0x3f, 0xc2, 0xb7, 0x68, 0x8f, 0x2e, 0x96, 0xff}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x5f, 0x10, 0xc9, 0xfe, 0x60, 0xa2, 0xf6, 0xf0, 0x49}; - lwmqtt_string_t username = {9, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 4881, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "T\207\211", _willMsg = "\bM\f\154\142\&6\191\r\DC3\RS\222", _willProps = []}), _cleanSession = -// False, _keepAlive = 12566, _connID = "\137\175)\181\207\247\&7@\223\162\&1\146;\226\v8", _properties = []} -TEST(Connect311QCTest, Encode5) { - uint8_t pkt[] = {0x10, 0x2e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0x31, 0x16, 0x0, 0x10, 0x89, 0xaf, - 0x29, 0xb5, 0xcf, 0xf7, 0x37, 0x40, 0xdf, 0xa2, 0x31, 0x92, 0x3b, 0xe2, 0xb, 0x38, 0x0, 0x3, - 0x54, 0xcf, 0xd3, 0x0, 0xb, 0x8, 0x4d, 0xc, 0x9a, 0x8e, 0x36, 0xbf, 0xd, 0x13, 0x1e, 0xde}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// COMP (PubCOMP 4881 0 []) +TEST(PubACKCOMP311QCTest, Decode4) { + uint8_t pkt[] = {0x70, 0x2, 0x13, 0x11}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4881); + EXPECT_EQ(status, 0); +} + +// COMP (PubCOMP 4353 0 []) +TEST(PubACKCOMP311QCTest, Encode5) { + uint8_t pkt[] = {0x70, 0x2, 0x11, 0x1}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 4353, 0, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_property_t willpropslist[] = {}; +// COMP (PubCOMP 4353 0 []) +TEST(PubACKCOMP311QCTest, Decode5) { + uint8_t pkt[] = {0x70, 0x2, 0x11, 0x1}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4353); + EXPECT_EQ(status, 0); +} - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x54, 0xcf, 0xd3}; - lwmqtt_string_t will_topic = {3, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x8, 0x4d, 0xc, 0x9a, 0x8e, 0x36, 0xbf, 0xd, 0x13, 0x1e, 0xde}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 12566; - uint8_t client_id_bytes[] = {0x89, 0xaf, 0x29, 0xb5, 0xcf, 0xf7, 0x37, 0x40, - 0xdf, 0xa2, 0x31, 0x92, 0x3b, 0xe2, 0xb, 0x38}; - lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +// ACK (PubACK 15872 0 []) +TEST(PubACKACK311QCTest, Encode6) { + uint8_t pkt[] = {0x40, 0x2, 0x3e, 0x0}; + uint8_t buf[sizeof(pkt) + 10]; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 15872, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just -// "\174g-~\US\254\174\RS5\r\148\251\190\141\147ed,\178\FS\148'\DELb\174\216", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "\SI%\202\210^\187\&7\227\165\SI\236\b\199,\159\238\169", _willMsg = -// "\167\235\ACK\211F\n\211\\@!Wh\n", _willProps = []}), _cleanSession = True, _keepAlive = 4901, _connID = "bDc", -// _properties = []} -TEST(Connect311QCTest, Encode6) { - uint8_t pkt[] = {0x10, 0x31, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x13, 0x25, 0x0, 0x3, 0x62, 0x44, 0x63, - 0x0, 0x11, 0xf, 0x25, 0xca, 0xd2, 0x5e, 0xbb, 0x37, 0xe3, 0xa5, 0xf, 0xec, 0x8, 0xc7, 0x2c, 0x9f, - 0xee, 0xa9, 0x0, 0xd, 0xa7, 0xeb, 0x6, 0xd3, 0x46, 0xa, 0xd3, 0x5c, 0x40, 0x21, 0x57, 0x68, 0xa}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 15872 0 []) +TEST(PubACKACK311QCTest, Decode6) { + uint8_t pkt[] = {0x40, 0x2, 0x3e, 0x0}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 15872); + EXPECT_EQ(status, 0); +} + +// REL (PubREL 21231 0 []) +TEST(PubACKREL311QCTest, Encode7) { + uint8_t pkt[] = {0x62, 0x2, 0x52, 0xef}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 21231, 0, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_property_t willpropslist[] = {}; +// REL (PubREL 21231 0 []) +TEST(PubACKREL311QCTest, Decode7) { + uint8_t pkt[] = {0x62, 0x2, 0x52, 0xef}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 21231); + EXPECT_EQ(status, 0); +} - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf, 0x25, 0xca, 0xd2, 0x5e, 0xbb, 0x37, 0xe3, 0xa5, - 0xf, 0xec, 0x8, 0xc7, 0x2c, 0x9f, 0xee, 0xa9}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa7, 0xeb, 0x6, 0xd3, 0x46, 0xa, 0xd3, 0x5c, 0x40, 0x21, 0x57, 0x68, 0xa}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 4901; - uint8_t client_id_bytes[] = {0x62, 0x44, 0x63}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xae, 0x67, 0x2d, 0x7e, 0x1f, 0xfe, 0xae, 0x1e, 0x35, 0xd, 0x94, 0xfb, 0xbe, - 0x8d, 0x93, 0x65, 0x64, 0x2c, 0xb2, 0x1c, 0x94, 0x27, 0x7f, 0x62, 0xae, 0xd8}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +// REL (PubREL 10396 0 []) +TEST(PubACKREL311QCTest, Encode8) { + uint8_t pkt[] = {0x62, 0x2, 0x28, 0x9c}; + uint8_t buf[sizeof(pkt) + 10]; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 10396, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "c_\DC1\222(\232\&7", _willMsg = -// "\213z\217-\215\&3\195\ETB\188G\198\140\251+\139\183\183\222\232\204M\187\145\252\EOT\n\192\129", _willProps = []}), -// _cleanSession = True, _keepAlive = 7652, _connID = "m\186 \189\208z", _properties = []} -TEST(Connect311QCTest, Encode7) { - uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0x1d, 0xe4, 0x0, 0x6, 0x6d, - 0xba, 0x20, 0xbd, 0xd0, 0x7a, 0x0, 0x7, 0x63, 0x5f, 0x11, 0xde, 0x28, 0xe8, 0x37, 0x0, - 0x1c, 0xd5, 0x7a, 0xd9, 0x2d, 0xd7, 0x33, 0xc3, 0x17, 0xbc, 0x47, 0xc6, 0x8c, 0xfb, 0x2b, - 0x8b, 0xb7, 0xb7, 0xde, 0xe8, 0xcc, 0x4d, 0xbb, 0x91, 0xfc, 0x4, 0xa, 0xc0, 0x81}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// REL (PubREL 10396 0 []) +TEST(PubACKREL311QCTest, Decode8) { + uint8_t pkt[] = {0x62, 0x2, 0x28, 0x9c}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 10396); + EXPECT_EQ(status, 0); +} + +// ACK (PubACK 26705 0 []) +TEST(PubACKACK311QCTest, Encode9) { + uint8_t pkt[] = {0x40, 0x2, 0x68, 0x51}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x63, 0x5f, 0x11, 0xde, 0x28, 0xe8, 0x37}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd5, 0x7a, 0xd9, 0x2d, 0xd7, 0x33, 0xc3, 0x17, 0xbc, 0x47, 0xc6, 0x8c, 0xfb, 0x2b, - 0x8b, 0xb7, 0xb7, 0xde, 0xe8, 0xcc, 0x4d, 0xbb, 0x91, 0xfc, 0x4, 0xa, 0xc0, 0x81}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 7652; - uint8_t client_id_bytes[] = {0x6d, 0xba, 0x20, 0xbd, 0xd0, 0x7a}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 26705, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS2, _willTopic = "\167\186,\225\231\n\229RS\158n\EOT\157pX\SI\134\254\187\&5\178[\235\215\141", _willMsg = "\183~", -// _willProps = []}), _cleanSession = True, _keepAlive = 4897, _connID = "\215ES)\213\"\RS\149\165\167\252\216_\166", -// _properties = []} -TEST(Connect311QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x13, 0x21, 0x0, 0xe, 0xd7, - 0x45, 0x53, 0x29, 0xd5, 0x22, 0x1e, 0x95, 0xa5, 0xa7, 0xfc, 0xd8, 0x5f, 0xa6, 0x0, 0x19, - 0xa7, 0xba, 0x2c, 0xe1, 0xe7, 0xa, 0xe5, 0x52, 0x53, 0x9e, 0x6e, 0x4, 0x9d, 0x70, 0x58, - 0xf, 0x86, 0xfe, 0xbb, 0x35, 0xb2, 0x5b, 0xeb, 0xd7, 0x8d, 0x0, 0x2, 0xb7, 0x7e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 26705 0 []) +TEST(PubACKACK311QCTest, Decode9) { + uint8_t pkt[] = {0x40, 0x2, 0x68, 0x51}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 26705); + EXPECT_EQ(status, 0); +} + +// ACK (PubACK 17554 0 []) +TEST(PubACKACK311QCTest, Encode10) { + uint8_t pkt[] = {0x40, 0x2, 0x44, 0x92}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa7, 0xba, 0x2c, 0xe1, 0xe7, 0xa, 0xe5, 0x52, 0x53, 0x9e, 0x6e, 0x4, 0x9d, - 0x70, 0x58, 0xf, 0x86, 0xfe, 0xbb, 0x35, 0xb2, 0x5b, 0xeb, 0xd7, 0x8d}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb7, 0x7e}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 4897; - uint8_t client_id_bytes[] = {0xd7, 0x45, 0x53, 0x29, 0xd5, 0x22, 0x1e, 0x95, 0xa5, 0xa7, 0xfc, 0xd8, 0x5f, 0xa6}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 17554, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\179\171\192\219e27\202\244Y\238\&9\151", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\221\239\USQ\"", _willMsg = "", _willProps = []}), -// _cleanSession = False, _keepAlive = 28246, _connID = -// "6S\138\205\221\220lm\242_x6\230\192\DC4\219\134u\DC40\191tP^\212\247", _properties = []} -TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x2f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x14, 0x6e, 0x56, 0x0, 0x1a, 0x36, 0x53, 0x8a, - 0xcd, 0xdd, 0xdc, 0x6c, 0x6d, 0xf2, 0x5f, 0x78, 0x36, 0xe6, 0xc0, 0x14, 0xdb, 0x86, 0x75, 0x14, 0x30, - 0xbf, 0x74, 0x50, 0x5e, 0xd4, 0xf7, 0x0, 0x5, 0xdd, 0xef, 0x1f, 0x51, 0x22, 0x0, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 17554 0 []) +TEST(PubACKACK311QCTest, Decode10) { + uint8_t pkt[] = {0x40, 0x2, 0x44, 0x92}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 17554); + EXPECT_EQ(status, 0); +} + +// ACK (PubACK 24500 0 []) +TEST(PubACKACK311QCTest, Encode11) { + uint8_t pkt[] = {0x40, 0x2, 0x5f, 0xb4}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xdd, 0xef, 0x1f, 0x51, 0x22}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 28246; - uint8_t client_id_bytes[] = {0x36, 0x53, 0x8a, 0xcd, 0xdd, 0xdc, 0x6c, 0x6d, 0xf2, 0x5f, 0x78, 0x36, 0xe6, - 0xc0, 0x14, 0xdb, 0x86, 0x75, 0x14, 0x30, 0xbf, 0x74, 0x50, 0x5e, 0xd4, 0xf7}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xb3, 0xab, 0xc0, 0xdb, 0x65, 0x32, 0x37, 0xca, 0xf4, 0x59, 0xee, 0x39, 0x97}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 24500, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "a\240\130l{", _password = Just -// "\139\168iv\184\216p\167\249\142\150\188G^'\235a\GS", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = -// "\DC4\144\178\229\CAN\160\DC2\233\SI\160\DC1G\219\173\175\r\161\&3\250\246\200\250\r\199J\154\165\195\221\237", -// _willMsg = " \207(\FS?\175Cq\NUL\154(\203(\186\197\156`\189O\255\195\169\153\RS\226\b`h", _willProps = []}), -// _cleanSession = True, _keepAlive = 13826, _connID = "", _properties = []} -TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x65, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe6, 0x36, 0x2, 0x0, 0x0, 0x0, - 0x1e, 0x14, 0x90, 0xb2, 0xe5, 0x18, 0xa0, 0x12, 0xe9, 0xf, 0xa0, 0x11, 0x47, 0xdb, 0xad, - 0xaf, 0xd, 0xa1, 0x33, 0xfa, 0xf6, 0xc8, 0xfa, 0xd, 0xc7, 0x4a, 0x9a, 0xa5, 0xc3, 0xdd, - 0xed, 0x0, 0x1c, 0x20, 0xcf, 0x28, 0x1c, 0x3f, 0xaf, 0x43, 0x71, 0x0, 0x9a, 0x28, 0xcb, - 0x28, 0xba, 0xc5, 0x9c, 0x60, 0xbd, 0x4f, 0xff, 0xc3, 0xa9, 0x99, 0x1e, 0xe2, 0x8, 0x60, - 0x68, 0x0, 0x5, 0x61, 0xf0, 0x82, 0x6c, 0x7b, 0x0, 0x12, 0x8b, 0xa8, 0x69, 0x76, 0xb8, - 0xd8, 0x70, 0xa7, 0xf9, 0x8e, 0x96, 0xbc, 0x47, 0x5e, 0x27, 0xeb, 0x61, 0x1d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 24500 0 []) +TEST(PubACKACK311QCTest, Decode11) { + uint8_t pkt[] = {0x40, 0x2, 0x5f, 0xb4}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 24500); + EXPECT_EQ(status, 0); +} + +// COMP (PubCOMP 30295 0 []) +TEST(PubACKCOMP311QCTest, Encode12) { + uint8_t pkt[] = {0x70, 0x2, 0x76, 0x57}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x14, 0x90, 0xb2, 0xe5, 0x18, 0xa0, 0x12, 0xe9, 0xf, 0xa0, - 0x11, 0x47, 0xdb, 0xad, 0xaf, 0xd, 0xa1, 0x33, 0xfa, 0xf6, - 0xc8, 0xfa, 0xd, 0xc7, 0x4a, 0x9a, 0xa5, 0xc3, 0xdd, 0xed}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x20, 0xcf, 0x28, 0x1c, 0x3f, 0xaf, 0x43, 0x71, 0x0, 0x9a, 0x28, 0xcb, 0x28, 0xba, - 0xc5, 0x9c, 0x60, 0xbd, 0x4f, 0xff, 0xc3, 0xa9, 0x99, 0x1e, 0xe2, 0x8, 0x60, 0x68}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 13826; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x61, 0xf0, 0x82, 0x6c, 0x7b}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x8b, 0xa8, 0x69, 0x76, 0xb8, 0xd8, 0x70, 0xa7, 0xf9, - 0x8e, 0x96, 0xbc, 0x47, 0x5e, 0x27, 0xeb, 0x61, 0x1d}; - lwmqtt_string_t password = {18, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 30295, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\212\GS\145\247\v\161", _password = Just "{!\212\236\201\231Q", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "", _willMsg = -// "]9\230\162rqS\215\197\SI\129\173\160\"j\ACK\181\v\226\253X\189\&4\146\169\138%\143$", _willProps = []}), -// _cleanSession = True, _keepAlive = 10261, _connID = "\137\n\r\250!\209\SO\245\&0\146@>\253V:\197D", _properties = []} -TEST(Connect311QCTest, Encode11) { - uint8_t pkt[] = {0x10, 0x4f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x28, 0x15, 0x0, 0x11, 0x89, 0xa, 0xd, - 0xfa, 0x21, 0xd1, 0xe, 0xf5, 0x30, 0x92, 0x40, 0x3e, 0xfd, 0x56, 0x3a, 0xc5, 0x44, 0x0, 0x0, 0x0, - 0x1d, 0x5d, 0x39, 0xe6, 0xa2, 0x72, 0x71, 0x53, 0xd7, 0xc5, 0xf, 0x81, 0xad, 0xa0, 0x22, 0x6a, 0x6, - 0xb5, 0xb, 0xe2, 0xfd, 0x58, 0xbd, 0x34, 0x92, 0xa9, 0x8a, 0x25, 0x8f, 0x24, 0x0, 0x6, 0xd4, 0x1d, - 0x91, 0xf7, 0xb, 0xa1, 0x0, 0x7, 0x7b, 0x21, 0xd4, 0xec, 0xc9, 0xe7, 0x51}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// COMP (PubCOMP 30295 0 []) +TEST(PubACKCOMP311QCTest, Decode12) { + uint8_t pkt[] = {0x70, 0x2, 0x76, 0x57}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 30295); + EXPECT_EQ(status, 0); +} + +// ACK (PubACK 17870 0 []) +TEST(PubACKACK311QCTest, Encode13) { + uint8_t pkt[] = {0x40, 0x2, 0x45, 0xce}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5d, 0x39, 0xe6, 0xa2, 0x72, 0x71, 0x53, 0xd7, 0xc5, 0xf, - 0x81, 0xad, 0xa0, 0x22, 0x6a, 0x6, 0xb5, 0xb, 0xe2, 0xfd, - 0x58, 0xbd, 0x34, 0x92, 0xa9, 0x8a, 0x25, 0x8f, 0x24}; - lwmqtt_string_t will_payload = {29, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 10261; - uint8_t client_id_bytes[] = {0x89, 0xa, 0xd, 0xfa, 0x21, 0xd1, 0xe, 0xf5, 0x30, - 0x92, 0x40, 0x3e, 0xfd, 0x56, 0x3a, 0xc5, 0x44}; - lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xd4, 0x1d, 0x91, 0xf7, 0xb, 0xa1}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x7b, 0x21, 0xd4, 0xec, 0xc9, 0xe7, 0x51}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 17870, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\221\242}\231\174B\GS\239\159Y\168\135+?h\249\&9`9<\191\211!\157\134\174", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\181\SUB\128:,a\250\247V)\184\235rKQORD!\154\244M\a", _willMsg = -// "\160\135:w_\160cdu\218\207\198\170\214\131\252w*0\v\204\191\186\ACK\224v", _willProps = []}), _cleanSession = False, -// _keepAlive = 27848, _connID = "|c\",E\248\&4\129\STX\254\128^\SYNv\175", _properties = []} -TEST(Connect311QCTest, Encode12) { - uint8_t pkt[] = {0x10, 0x6c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0x6c, 0xc8, 0x0, 0xf, 0x7c, 0x63, - 0x22, 0x2c, 0x45, 0xf8, 0x34, 0x81, 0x2, 0xfe, 0x80, 0x5e, 0x16, 0x76, 0xaf, 0x0, 0x17, 0xb5, - 0x1a, 0x80, 0x3a, 0x2c, 0x61, 0xfa, 0xf7, 0x56, 0x29, 0xb8, 0xeb, 0x72, 0x4b, 0x51, 0x4f, 0x52, - 0x44, 0x21, 0x9a, 0xf4, 0x4d, 0x7, 0x0, 0x1a, 0xa0, 0x87, 0x3a, 0x77, 0x5f, 0xa0, 0x63, 0x64, - 0x75, 0xda, 0xcf, 0xc6, 0xaa, 0xd6, 0x83, 0xfc, 0x77, 0x2a, 0x30, 0xb, 0xcc, 0xbf, 0xba, 0x6, - 0xe0, 0x76, 0x0, 0x1a, 0xdd, 0xf2, 0x7d, 0xe7, 0xae, 0x42, 0x1d, 0xef, 0x9f, 0x59, 0xa8, 0x87, - 0x2b, 0x3f, 0x68, 0xf9, 0x39, 0x60, 0x39, 0x3c, 0xbf, 0xd3, 0x21, 0x9d, 0x86, 0xae}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 17870 0 []) +TEST(PubACKACK311QCTest, Decode13) { + uint8_t pkt[] = {0x40, 0x2, 0x45, 0xce}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 17870); + EXPECT_EQ(status, 0); +} + +// ACK (PubACK 18661 0 []) +TEST(PubACKACK311QCTest, Encode14) { + uint8_t pkt[] = {0x40, 0x2, 0x48, 0xe5}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb5, 0x1a, 0x80, 0x3a, 0x2c, 0x61, 0xfa, 0xf7, 0x56, 0x29, 0xb8, 0xeb, - 0x72, 0x4b, 0x51, 0x4f, 0x52, 0x44, 0x21, 0x9a, 0xf4, 0x4d, 0x7}; - lwmqtt_string_t will_topic = {23, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa0, 0x87, 0x3a, 0x77, 0x5f, 0xa0, 0x63, 0x64, 0x75, 0xda, 0xcf, 0xc6, 0xaa, - 0xd6, 0x83, 0xfc, 0x77, 0x2a, 0x30, 0xb, 0xcc, 0xbf, 0xba, 0x6, 0xe0, 0x76}; - lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 27848; - uint8_t client_id_bytes[] = {0x7c, 0x63, 0x22, 0x2c, 0x45, 0xf8, 0x34, 0x81, 0x2, 0xfe, 0x80, 0x5e, 0x16, 0x76, 0xaf}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xdd, 0xf2, 0x7d, 0xe7, 0xae, 0x42, 0x1d, 0xef, 0x9f, 0x59, 0xa8, 0x87, 0x2b, - 0x3f, 0x68, 0xf9, 0x39, 0x60, 0x39, 0x3c, 0xbf, 0xd3, 0x21, 0x9d, 0x86, 0xae}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 18661, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\235w\132m]\248$4\232\&0\249V\214\DEL\182\170\EOT\DLE\DC1\212X\147-\207\&0", -// _password = Just "B\245\236\128\196\"\v\166[\CAN\160u\146&\ENQ*\DC1tN?h", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "\141", _willMsg = "\251\154\202\252\&51i(\SOK", _willProps = []}), -// _cleanSession = True, _keepAlive = 7077, _connID = "\166\&2\183R\234\EM*\227 \nz\SYN\ENQ", _properties = []} -TEST(Connect311QCTest, Encode13) { - uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x1b, 0xa5, 0x0, 0xd, 0xa6, 0x32, - 0xb7, 0x52, 0xea, 0x19, 0x2a, 0xe3, 0x20, 0xa, 0x7a, 0x16, 0x5, 0x0, 0x1, 0x8d, 0x0, 0xa, - 0xfb, 0x9a, 0xca, 0xfc, 0x35, 0x31, 0x69, 0x28, 0xe, 0x4b, 0x0, 0x19, 0xeb, 0x77, 0x84, 0x6d, - 0x5d, 0xf8, 0x24, 0x34, 0xe8, 0x30, 0xf9, 0x56, 0xd6, 0x7f, 0xb6, 0xaa, 0x4, 0x10, 0x11, 0xd4, - 0x58, 0x93, 0x2d, 0xcf, 0x30, 0x0, 0x15, 0x42, 0xf5, 0xec, 0x80, 0xc4, 0x22, 0xb, 0xa6, 0x5b, - 0x18, 0xa0, 0x75, 0x92, 0x26, 0x5, 0x2a, 0x11, 0x74, 0x4e, 0x3f, 0x68}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 18661 0 []) +TEST(PubACKACK311QCTest, Decode14) { + uint8_t pkt[] = {0x40, 0x2, 0x48, 0xe5}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 18661); + EXPECT_EQ(status, 0); +} + +// REC (PubREC 32292 0 []) +TEST(PubACKREC311QCTest, Encode15) { + uint8_t pkt[] = {0x50, 0x2, 0x7e, 0x24}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8d}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfb, 0x9a, 0xca, 0xfc, 0x35, 0x31, 0x69, 0x28, 0xe, 0x4b}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 7077; - uint8_t client_id_bytes[] = {0xa6, 0x32, 0xb7, 0x52, 0xea, 0x19, 0x2a, 0xe3, 0x20, 0xa, 0x7a, 0x16, 0x5}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xeb, 0x77, 0x84, 0x6d, 0x5d, 0xf8, 0x24, 0x34, 0xe8, 0x30, 0xf9, 0x56, 0xd6, - 0x7f, 0xb6, 0xaa, 0x4, 0x10, 0x11, 0xd4, 0x58, 0x93, 0x2d, 0xcf, 0x30}; - lwmqtt_string_t username = {25, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x42, 0xf5, 0xec, 0x80, 0xc4, 0x22, 0xb, 0xa6, 0x5b, 0x18, 0xa0, - 0x75, 0x92, 0x26, 0x5, 0x2a, 0x11, 0x74, 0x4e, 0x3f, 0x68}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 32292, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just " \173\&3f\DC4", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "\SUB\224\241\aY%\155\222\143G\155T\163lx\218+", _willMsg = -// "m\130Tq\186R\196\157\v\245\FS\140\202\ETB\143\v\188\159\199\242\237\249A\DEL", _willProps = []}), _cleanSession = -// True, _keepAlive = 16885, _connID = "", _properties = []} -TEST(Connect311QCTest, Encode14) { - uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0x41, 0xf5, 0x0, 0x0, 0x0, 0x11, 0x1a, - 0xe0, 0xf1, 0x7, 0x59, 0x25, 0x9b, 0xde, 0x8f, 0x47, 0x9b, 0x54, 0xa3, 0x6c, 0x78, 0xda, 0x2b, 0x0, - 0x18, 0x6d, 0x82, 0x54, 0x71, 0xba, 0x52, 0xc4, 0x9d, 0xb, 0xf5, 0x1c, 0x8c, 0xca, 0x17, 0x8f, 0xb, - 0xbc, 0x9f, 0xc7, 0xf2, 0xed, 0xf9, 0x41, 0x7f, 0x0, 0x5, 0x20, 0xad, 0x33, 0x66, 0x14}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// REC (PubREC 32292 0 []) +TEST(PubACKREC311QCTest, Decode15) { + uint8_t pkt[] = {0x50, 0x2, 0x7e, 0x24}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 32292); + EXPECT_EQ(status, 0); +} + +// ACK (PubACK 11679 0 []) +TEST(PubACKACK311QCTest, Encode16) { + uint8_t pkt[] = {0x40, 0x2, 0x2d, 0x9f}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1a, 0xe0, 0xf1, 0x7, 0x59, 0x25, 0x9b, 0xde, 0x8f, - 0x47, 0x9b, 0x54, 0xa3, 0x6c, 0x78, 0xda, 0x2b}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6d, 0x82, 0x54, 0x71, 0xba, 0x52, 0xc4, 0x9d, 0xb, 0xf5, 0x1c, 0x8c, - 0xca, 0x17, 0x8f, 0xb, 0xbc, 0x9f, 0xc7, 0xf2, 0xed, 0xf9, 0x41, 0x7f}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 16885; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x20, 0xad, 0x33, 0x66, 0x14}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 11679, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\162\146\138\141K)\DEL\142\&8zW\163\DC2M#\138\ENQ\NUL\134\235\203", _password = -// Just "\133\n\206/_y\134\132\146/\225s 4O\210\144\130\GS\148b", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS1, _willTopic = "\251\220\159\161T\129^\175\210\212\RS0Yh\NAK\141{5\207lv\193\253\209", _willMsg = -// "\202{q\255\165\RS", _willProps = []}), _cleanSession = False, _keepAlive = 28167, _connID = -// "v\243\203T}\236\142\226\SI\204\157\191\223\138y\DC4\252\163\134", _properties = []} -TEST(Connect311QCTest, Encode15) { - uint8_t pkt[] = {0x10, 0x6f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x6e, 0x7, 0x0, 0x13, 0x76, 0xf3, 0xcb, - 0x54, 0x7d, 0xec, 0x8e, 0xe2, 0xf, 0xcc, 0x9d, 0xbf, 0xdf, 0x8a, 0x79, 0x14, 0xfc, 0xa3, 0x86, 0x0, - 0x18, 0xfb, 0xdc, 0x9f, 0xa1, 0x54, 0x81, 0x5e, 0xaf, 0xd2, 0xd4, 0x1e, 0x30, 0x59, 0x68, 0x15, 0x8d, - 0x7b, 0x35, 0xcf, 0x6c, 0x76, 0xc1, 0xfd, 0xd1, 0x0, 0x6, 0xca, 0x7b, 0x71, 0xff, 0xa5, 0x1e, 0x0, - 0x15, 0xa2, 0x92, 0x8a, 0x8d, 0x4b, 0x29, 0x7f, 0x8e, 0x38, 0x7a, 0x57, 0xa3, 0x12, 0x4d, 0x23, 0x8a, - 0x5, 0x0, 0x86, 0xeb, 0xcb, 0x0, 0x15, 0x85, 0xa, 0xce, 0x2f, 0x5f, 0x79, 0x86, 0x84, 0x92, 0x2f, - 0xe1, 0x73, 0x20, 0x34, 0x4f, 0xd2, 0x90, 0x82, 0x1d, 0x94, 0x62}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 11679 0 []) +TEST(PubACKACK311QCTest, Decode16) { + uint8_t pkt[] = {0x40, 0x2, 0x2d, 0x9f}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 11679); + EXPECT_EQ(status, 0); +} + +// COMP (PubCOMP 24709 0 []) +TEST(PubACKCOMP311QCTest, Encode17) { + uint8_t pkt[] = {0x70, 0x2, 0x60, 0x85}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xfb, 0xdc, 0x9f, 0xa1, 0x54, 0x81, 0x5e, 0xaf, 0xd2, 0xd4, 0x1e, 0x30, - 0x59, 0x68, 0x15, 0x8d, 0x7b, 0x35, 0xcf, 0x6c, 0x76, 0xc1, 0xfd, 0xd1}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xca, 0x7b, 0x71, 0xff, 0xa5, 0x1e}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 28167; - uint8_t client_id_bytes[] = {0x76, 0xf3, 0xcb, 0x54, 0x7d, 0xec, 0x8e, 0xe2, 0xf, 0xcc, - 0x9d, 0xbf, 0xdf, 0x8a, 0x79, 0x14, 0xfc, 0xa3, 0x86}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa2, 0x92, 0x8a, 0x8d, 0x4b, 0x29, 0x7f, 0x8e, 0x38, 0x7a, 0x57, - 0xa3, 0x12, 0x4d, 0x23, 0x8a, 0x5, 0x0, 0x86, 0xeb, 0xcb}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x85, 0xa, 0xce, 0x2f, 0x5f, 0x79, 0x86, 0x84, 0x92, 0x2f, 0xe1, - 0x73, 0x20, 0x34, 0x4f, 0xd2, 0x90, 0x82, 0x1d, 0x94, 0x62}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 24709, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "Ub", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS2, _willTopic = "\EM\162\218\226Q\179}\211\ETB\242\188\157(\150\&7-", _willMsg = "\146#K\CAN-7w\161\228\157", -// _willProps = []}), _cleanSession = False, _keepAlive = 618, _connID = "\193\150\ENQ", _properties = []} -TEST(Connect311QCTest, Encode16) { - uint8_t pkt[] = {0x10, 0x31, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xb4, 0x2, 0x6a, 0x0, - 0x3, 0xc1, 0x96, 0x5, 0x0, 0x10, 0x19, 0xa2, 0xda, 0xe2, 0x51, 0xb3, 0x7d, - 0xd3, 0x17, 0xf2, 0xbc, 0x9d, 0x28, 0x96, 0x37, 0x2d, 0x0, 0xa, 0x92, 0x23, - 0x4b, 0x18, 0x2d, 0x37, 0x77, 0xa1, 0xe4, 0x9d, 0x0, 0x2, 0x55, 0x62}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// COMP (PubCOMP 24709 0 []) +TEST(PubACKCOMP311QCTest, Decode17) { + uint8_t pkt[] = {0x70, 0x2, 0x60, 0x85}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 24709); + EXPECT_EQ(status, 0); +} + +// REL (PubREL 19085 0 []) +TEST(PubACKREL311QCTest, Encode18) { + uint8_t pkt[] = {0x62, 0x2, 0x4a, 0x8d}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x19, 0xa2, 0xda, 0xe2, 0x51, 0xb3, 0x7d, 0xd3, - 0x17, 0xf2, 0xbc, 0x9d, 0x28, 0x96, 0x37, 0x2d}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x92, 0x23, 0x4b, 0x18, 0x2d, 0x37, 0x77, 0xa1, 0xe4, 0x9d}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 618; - uint8_t client_id_bytes[] = {0xc1, 0x96, 0x5}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x55, 0x62}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 19085, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "\212\178\194\175\",\DC4\189\220\226\206U\131Q\182\202p\244\242D;\212\175m*\194WT\207", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\DC24\133\225%k\SOHa\149\232\DC3}q\224", _willMsg = "\226\225\232\214\198L7\156\&6H\247\231\176X'm", _willProps = -// []}), _cleanSession = True, _keepAlive = 5852, _connID = "|\199", _properties = []} -TEST(Connect311QCTest, Encode17) { - uint8_t pkt[] = {0x10, 0x4f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xae, 0x16, 0xdc, 0x0, 0x2, 0x7c, 0xc7, 0x0, - 0xe, 0x12, 0x34, 0x85, 0xe1, 0x25, 0x6b, 0x1, 0x61, 0x95, 0xe8, 0x13, 0x7d, 0x71, 0xe0, 0x0, 0x10, - 0xe2, 0xe1, 0xe8, 0xd6, 0xc6, 0x4c, 0x37, 0x9c, 0x36, 0x48, 0xf7, 0xe7, 0xb0, 0x58, 0x27, 0x6d, 0x0, - 0x1d, 0xd4, 0xb2, 0xc2, 0xaf, 0x22, 0x2c, 0x14, 0xbd, 0xdc, 0xe2, 0xce, 0x55, 0x83, 0x51, 0xb6, 0xca, - 0x70, 0xf4, 0xf2, 0x44, 0x3b, 0xd4, 0xaf, 0x6d, 0x2a, 0xc2, 0x57, 0x54, 0xcf}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// REL (PubREL 19085 0 []) +TEST(PubACKREL311QCTest, Decode18) { + uint8_t pkt[] = {0x62, 0x2, 0x4a, 0x8d}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 19085); + EXPECT_EQ(status, 0); +} + +// ACK (PubACK 23245 0 []) +TEST(PubACKACK311QCTest, Encode19) { + uint8_t pkt[] = {0x40, 0x2, 0x5a, 0xcd}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x12, 0x34, 0x85, 0xe1, 0x25, 0x6b, 0x1, 0x61, 0x95, 0xe8, 0x13, 0x7d, 0x71, 0xe0}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe2, 0xe1, 0xe8, 0xd6, 0xc6, 0x4c, 0x37, 0x9c, - 0x36, 0x48, 0xf7, 0xe7, 0xb0, 0x58, 0x27, 0x6d}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 5852; - uint8_t client_id_bytes[] = {0x7c, 0xc7}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xd4, 0xb2, 0xc2, 0xaf, 0x22, 0x2c, 0x14, 0xbd, 0xdc, 0xe2, 0xce, 0x55, 0x83, 0x51, 0xb6, - 0xca, 0x70, 0xf4, 0xf2, 0x44, 0x3b, 0xd4, 0xaf, 0x6d, 0x2a, 0xc2, 0x57, 0x54, 0xcf}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 23245, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "2\DC1\197\140\172\STX\245\224", _password = Just -// "C\232\160\f\216\162\204\154\165\248\249\194\&5g\172\177\236\DC2\EOT\245\214\156", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = -// "$\RSC_\156\STX\165$\246x_\195(]^\f\a%\232O\vf\"\180\174\135\223!8`", _willMsg = -// "\190'c\128\&6\169\239\f\a\GS\246\152}\153\215\ACK\SOH9\248\193A\224\237\179", _willProps = []}), _cleanSession = -// True, _keepAlive = 12387, _connID = "\ETX\SYN\DC2\a\ETB\224\158xuW\n\236S\134\138\198\CAN\SI\bp", _properties = []} -TEST(Connect311QCTest, Encode18) { - uint8_t pkt[] = {0x10, 0x7c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x30, 0x63, 0x0, 0x14, 0x3, 0x16, - 0x12, 0x7, 0x17, 0xe0, 0x9e, 0x78, 0x75, 0x57, 0xa, 0xec, 0x53, 0x86, 0x8a, 0xc6, 0x18, 0xf, - 0x8, 0x70, 0x0, 0x1e, 0x24, 0x1e, 0x43, 0x5f, 0x9c, 0x2, 0xa5, 0x24, 0xf6, 0x78, 0x5f, 0xc3, - 0x28, 0x5d, 0x5e, 0xc, 0x7, 0x25, 0xe8, 0x4f, 0xb, 0x66, 0x22, 0xb4, 0xae, 0x87, 0xdf, 0x21, - 0x38, 0x60, 0x0, 0x18, 0xbe, 0x27, 0x63, 0x80, 0x36, 0xa9, 0xef, 0xc, 0x7, 0x1d, 0xf6, 0x98, - 0x7d, 0x99, 0xd7, 0x6, 0x1, 0x39, 0xf8, 0xc1, 0x41, 0xe0, 0xed, 0xb3, 0x0, 0x8, 0x32, 0x11, - 0xc5, 0x8c, 0xac, 0x2, 0xf5, 0xe0, 0x0, 0x16, 0x43, 0xe8, 0xa0, 0xc, 0xd8, 0xa2, 0xcc, 0x9a, - 0xa5, 0xf8, 0xf9, 0xc2, 0x35, 0x67, 0xac, 0xb1, 0xec, 0x12, 0x4, 0xf5, 0xd6, 0x9c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 23245 0 []) +TEST(PubACKACK311QCTest, Decode19) { + uint8_t pkt[] = {0x40, 0x2, 0x5a, 0xcd}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 23245); + EXPECT_EQ(status, 0); +} + +// REL (PubREL 27855 0 []) +TEST(PubACKREL311QCTest, Encode20) { + uint8_t pkt[] = {0x62, 0x2, 0x6c, 0xcf}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x24, 0x1e, 0x43, 0x5f, 0x9c, 0x2, 0xa5, 0x24, 0xf6, 0x78, - 0x5f, 0xc3, 0x28, 0x5d, 0x5e, 0xc, 0x7, 0x25, 0xe8, 0x4f, - 0xb, 0x66, 0x22, 0xb4, 0xae, 0x87, 0xdf, 0x21, 0x38, 0x60}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbe, 0x27, 0x63, 0x80, 0x36, 0xa9, 0xef, 0xc, 0x7, 0x1d, 0xf6, 0x98, - 0x7d, 0x99, 0xd7, 0x6, 0x1, 0x39, 0xf8, 0xc1, 0x41, 0xe0, 0xed, 0xb3}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 12387; - uint8_t client_id_bytes[] = {0x3, 0x16, 0x12, 0x7, 0x17, 0xe0, 0x9e, 0x78, 0x75, 0x57, - 0xa, 0xec, 0x53, 0x86, 0x8a, 0xc6, 0x18, 0xf, 0x8, 0x70}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x32, 0x11, 0xc5, 0x8c, 0xac, 0x2, 0xf5, 0xe0}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x43, 0xe8, 0xa0, 0xc, 0xd8, 0xa2, 0xcc, 0x9a, 0xa5, 0xf8, 0xf9, - 0xc2, 0x35, 0x67, 0xac, 0xb1, 0xec, 0x12, 0x4, 0xf5, 0xd6, 0x9c}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 27855, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "m\224J\233E\DC3\ETB\NUL`\145\194\ETXi", _lastWill = Nothing, -// _cleanSession = True, _keepAlive = 8004, _connID = "\152\175\205\ESC\239\142|}6k\238\178", _properties = []} -TEST(Connect311QCTest, Encode19) { - uint8_t pkt[] = {0x10, 0x18, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x1f, 0x44, 0x0, - 0xc, 0x98, 0xaf, 0xcd, 0x1b, 0xef, 0x8e, 0x7c, 0x7d, 0x36, 0x6b, 0xee, 0xb2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// REL (PubREL 27855 0 []) +TEST(PubACKREL311QCTest, Decode20) { + uint8_t pkt[] = {0x62, 0x2, 0x6c, 0xcf}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 27855); + EXPECT_EQ(status, 0); +} + +// REL (PubREL 3263 0 []) +TEST(PubACKREL311QCTest, Encode21) { + uint8_t pkt[] = {0x62, 0x2, 0xc, 0xbf}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 8004; - uint8_t client_id_bytes[] = {0x98, 0xaf, 0xcd, 0x1b, 0xef, 0x8e, 0x7c, 0x7d, 0x36, 0x6b, 0xee, 0xb2}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x6d, 0xe0, 0x4a, 0xe9, 0x45, 0x13, 0x17, 0x0, 0x60, 0x91, 0xc2, 0x3, 0x69}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); - + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 3263, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\238", _password = Just "\224\167\178Vb~\222\DLE\192\146\197\133L", _lastWill = -// Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\STX", _willMsg = -// "6D\137\167,4\131\&6\166\145\201\149|\221\&2i\192", _willProps = []}), _cleanSession = False, _keepAlive = 19508, -// _connID = "|\238>", _properties = []} -TEST(Connect311QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0x37, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x4c, 0x34, 0x0, 0x3, 0x7c, - 0xee, 0x3e, 0x0, 0x1, 0x2, 0x0, 0x11, 0x36, 0x44, 0x89, 0xa7, 0x2c, 0x34, 0x83, 0x36, - 0xa6, 0x91, 0xc9, 0x95, 0x7c, 0xdd, 0x32, 0x69, 0xc0, 0x0, 0x1, 0xee, 0x0, 0xd, 0xe0, - 0xa7, 0xb2, 0x56, 0x62, 0x7e, 0xde, 0x10, 0xc0, 0x92, 0xc5, 0x85, 0x4c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// REL (PubREL 3263 0 []) +TEST(PubACKREL311QCTest, Decode21) { + uint8_t pkt[] = {0x62, 0x2, 0xc, 0xbf}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 3263); + EXPECT_EQ(status, 0); +} + +// ACK (PubACK 4790 0 []) +TEST(PubACKACK311QCTest, Encode22) { + uint8_t pkt[] = {0x40, 0x2, 0x12, 0xb6}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x36, 0x44, 0x89, 0xa7, 0x2c, 0x34, 0x83, 0x36, 0xa6, - 0x91, 0xc9, 0x95, 0x7c, 0xdd, 0x32, 0x69, 0xc0}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 19508; - uint8_t client_id_bytes[] = {0x7c, 0xee, 0x3e}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xee}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe0, 0xa7, 0xb2, 0x56, 0x62, 0x7e, 0xde, 0x10, 0xc0, 0x92, 0xc5, 0x85, 0x4c}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 4790, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS0, _willTopic = "e\178\176 \SO\167T!\SOH\NAK;b\193\247\SUB\136\189\199\232", _willMsg = -// "\221}\161\196zS\178P*\152}\254\220\196\216\136\161\220\"\NAK", _willProps = []}), _cleanSession = True, _keepAlive = -// 9446, _connID = "\146\132J\ENQ\144\192\ty\167>\184:C\152\133o\\1C\128\253\189]VH\210", _properties = []} -TEST(Connect311QCTest, Encode21) { - uint8_t pkt[] = {0x10, 0x51, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x6, 0x24, 0xe6, 0x0, 0x1a, 0x92, 0x84, 0x4a, - 0x5, 0x90, 0xc0, 0x9, 0x79, 0xa7, 0x3e, 0xb8, 0x3a, 0x43, 0x98, 0x85, 0x6f, 0x5c, 0x31, 0x43, 0x80, - 0xfd, 0xbd, 0x5d, 0x56, 0x48, 0xd2, 0x0, 0x13, 0x65, 0xb2, 0xb0, 0x20, 0xe, 0xa7, 0x54, 0x21, 0x1, - 0x15, 0x3b, 0x62, 0xc1, 0xf7, 0x1a, 0x88, 0xbd, 0xc7, 0xe8, 0x0, 0x14, 0xdd, 0x7d, 0xa1, 0xc4, 0x7a, - 0x53, 0xb2, 0x50, 0x2a, 0x98, 0x7d, 0xfe, 0xdc, 0xc4, 0xd8, 0x88, 0xa1, 0xdc, 0x22, 0x15}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 4790 0 []) +TEST(PubACKACK311QCTest, Decode22) { + uint8_t pkt[] = {0x40, 0x2, 0x12, 0xb6}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4790); + EXPECT_EQ(status, 0); +} + +// REL (PubREL 7224 0 []) +TEST(PubACKREL311QCTest, Encode23) { + uint8_t pkt[] = {0x62, 0x2, 0x1c, 0x38}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x65, 0xb2, 0xb0, 0x20, 0xe, 0xa7, 0x54, 0x21, 0x1, 0x15, - 0x3b, 0x62, 0xc1, 0xf7, 0x1a, 0x88, 0xbd, 0xc7, 0xe8}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xdd, 0x7d, 0xa1, 0xc4, 0x7a, 0x53, 0xb2, 0x50, 0x2a, 0x98, - 0x7d, 0xfe, 0xdc, 0xc4, 0xd8, 0x88, 0xa1, 0xdc, 0x22, 0x15}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 9446; - uint8_t client_id_bytes[] = {0x92, 0x84, 0x4a, 0x5, 0x90, 0xc0, 0x9, 0x79, 0xa7, 0x3e, 0xb8, 0x3a, 0x43, - 0x98, 0x85, 0x6f, 0x5c, 0x31, 0x43, 0x80, 0xfd, 0xbd, 0x5d, 0x56, 0x48, 0xd2}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 7224, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "0\219\168\207u\209FQb\194\255\SYN:\216` ", _password = Just -// "\224\206\238\173\&1\157LS\135\STX\RSL\213\178A\184\&6\185\133\180r1\191O\169\153m\246O", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "\210\254({", _willMsg = "Z\128\204\SOH\NUL\v%", _willProps = -// []}), _cleanSession = False, _keepAlive = 10802, _connID = "\229U\154\147\141\141XPP\181I\226\208\SYN", _properties = -// []} -TEST(Connect311QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x2a, 0x32, 0x0, 0xe, 0xe5, 0x55, - 0x9a, 0x93, 0x8d, 0x8d, 0x58, 0x50, 0x50, 0xb5, 0x49, 0xe2, 0xd0, 0x16, 0x0, 0x4, 0xd2, 0xfe, - 0x28, 0x7b, 0x0, 0x7, 0x5a, 0x80, 0xcc, 0x1, 0x0, 0xb, 0x25, 0x0, 0x10, 0x30, 0xdb, 0xa8, - 0xcf, 0x75, 0xd1, 0x46, 0x51, 0x62, 0xc2, 0xff, 0x16, 0x3a, 0xd8, 0x60, 0x20, 0x0, 0x1d, 0xe0, - 0xce, 0xee, 0xad, 0x31, 0x9d, 0x4c, 0x53, 0x87, 0x2, 0x1e, 0x4c, 0xd5, 0xb2, 0x41, 0xb8, 0x36, - 0xb9, 0x85, 0xb4, 0x72, 0x31, 0xbf, 0x4f, 0xa9, 0x99, 0x6d, 0xf6, 0x4f}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// REL (PubREL 7224 0 []) +TEST(PubACKREL311QCTest, Decode23) { + uint8_t pkt[] = {0x62, 0x2, 0x1c, 0x38}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7224); + EXPECT_EQ(status, 0); +} + +// REL (PubREL 15593 0 []) +TEST(PubACKREL311QCTest, Encode24) { + uint8_t pkt[] = {0x62, 0x2, 0x3c, 0xe9}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 15593, 0, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_property_t willpropslist[] = {}; +// REL (PubREL 15593 0 []) +TEST(PubACKREL311QCTest, Decode24) { + uint8_t pkt[] = {0x62, 0x2, 0x3c, 0xe9}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 15593); + EXPECT_EQ(status, 0); +} - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd2, 0xfe, 0x28, 0x7b}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5a, 0x80, 0xcc, 0x1, 0x0, 0xb, 0x25}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 10802; - uint8_t client_id_bytes[] = {0xe5, 0x55, 0x9a, 0x93, 0x8d, 0x8d, 0x58, 0x50, 0x50, 0xb5, 0x49, 0xe2, 0xd0, 0x16}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x30, 0xdb, 0xa8, 0xcf, 0x75, 0xd1, 0x46, 0x51, - 0x62, 0xc2, 0xff, 0x16, 0x3a, 0xd8, 0x60, 0x20}; - lwmqtt_string_t username = {16, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe0, 0xce, 0xee, 0xad, 0x31, 0x9d, 0x4c, 0x53, 0x87, 0x2, 0x1e, 0x4c, 0xd5, 0xb2, 0x41, - 0xb8, 0x36, 0xb9, 0x85, 0xb4, 0x72, 0x31, 0xbf, 0x4f, 0xa9, 0x99, 0x6d, 0xf6, 0x4f}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); +// ACK (PubACK 9801 0 []) +TEST(PubACKACK311QCTest, Encode25) { + uint8_t pkt[] = {0x40, 0x2, 0x26, 0x49}; + uint8_t buf[sizeof(pkt) + 10]; + + lwmqtt_property_t propslist[] = {}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 9801, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\159V\EOT\ENQR\a\169J\EOT", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\SI\SO", _willMsg = "\SUB{\SO\EM\190", _willProps = []}), -// _cleanSession = True, _keepAlive = 3695, _connID = "V\159\161\231\237\200\154\134\206X\143", _properties = []} -TEST(Connect311QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0x22, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0xe, 0x6f, - 0x0, 0xb, 0x56, 0x9f, 0xa1, 0xe7, 0xed, 0xc8, 0x9a, 0x86, 0xce, 0x58, - 0x8f, 0x0, 0x2, 0xf, 0xe, 0x0, 0x5, 0x1a, 0x7b, 0xe, 0x19, 0xbe}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// ACK (PubACK 9801 0 []) +TEST(PubACKACK311QCTest, Decode25) { + uint8_t pkt[] = {0x40, 0x2, 0x26, 0x49}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 9801); + EXPECT_EQ(status, 0); +} + +// ACK (PubACK 19499 0 []) +TEST(PubACKACK311QCTest, Encode26) { + uint8_t pkt[] = {0x40, 0x2, 0x4c, 0x2b}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf, 0xe}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1a, 0x7b, 0xe, 0x19, 0xbe}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 3695; - uint8_t client_id_bytes[] = {0x56, 0x9f, 0xa1, 0xe7, 0xed, 0xc8, 0x9a, 0x86, 0xce, 0x58, 0x8f}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0x9f, 0x56, 0x4, 0x5, 0x52, 0x7, 0xa9, 0x4a, 0x4}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 19499, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\US\184\177\250\165\178m\202\177\229\250+d\229", _password = Just "4#", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\DLE\157\231\207\176$D\205\246cj\139\212\151\237\181\225\198\182>C\FS", _willMsg = -// "\242\166\\\SYN\191\r\DC2d8\129\239\138\135\230\214]\CAN#K\206\USb%R\215\254\242\255\GS\139", _willProps = []}), -// _cleanSession = True, _keepAlive = 21935, _connID = "", _properties = []} -TEST(Connect311QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x58, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x55, 0xaf, 0x0, 0x0, 0x0, - 0x16, 0x10, 0x9d, 0xe7, 0xcf, 0xb0, 0x24, 0x44, 0xcd, 0xf6, 0x63, 0x6a, 0x8b, 0xd4, 0x97, - 0xed, 0xb5, 0xe1, 0xc6, 0xb6, 0x3e, 0x43, 0x1c, 0x0, 0x1e, 0xf2, 0xa6, 0x5c, 0x16, 0xbf, - 0xd, 0x12, 0x64, 0x38, 0x81, 0xef, 0x8a, 0x87, 0xe6, 0xd6, 0x5d, 0x18, 0x23, 0x4b, 0xce, - 0x1f, 0x62, 0x25, 0x52, 0xd7, 0xfe, 0xf2, 0xff, 0x1d, 0x8b, 0x0, 0xe, 0x1f, 0xb8, 0xb1, - 0xfa, 0xa5, 0xb2, 0x6d, 0xca, 0xb1, 0xe5, 0xfa, 0x2b, 0x64, 0xe5, 0x0, 0x2, 0x34, 0x23}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x10, 0x9d, 0xe7, 0xcf, 0xb0, 0x24, 0x44, 0xcd, 0xf6, 0x63, 0x6a, - 0x8b, 0xd4, 0x97, 0xed, 0xb5, 0xe1, 0xc6, 0xb6, 0x3e, 0x43, 0x1c}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf2, 0xa6, 0x5c, 0x16, 0xbf, 0xd, 0x12, 0x64, 0x38, 0x81, - 0xef, 0x8a, 0x87, 0xe6, 0xd6, 0x5d, 0x18, 0x23, 0x4b, 0xce, - 0x1f, 0x62, 0x25, 0x52, 0xd7, 0xfe, 0xf2, 0xff, 0x1d, 0x8b}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 21935; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x1f, 0xb8, 0xb1, 0xfa, 0xa5, 0xb2, 0x6d, 0xca, 0xb1, 0xe5, 0xfa, 0x2b, 0x64, 0xe5}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x34, 0x23}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - +// ACK (PubACK 19499 0 []) +TEST(PubACKACK311QCTest, Decode26) { + uint8_t pkt[] = {0x40, 0x2, 0x4c, 0x2b}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(packet_id, 19499); + EXPECT_EQ(status, 0); } -// ConnectRequest {_username = Nothing, _password = Just "\223\FS\149\212{Q\139+/s\191U\174l\n\173", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "AbQ~\153\211\195\255aR\240\202u\223", _willMsg = -// "\254\139\131\221\&7y\167\ETX\187I\188O~e\199", _willProps = []}), _cleanSession = False, _keepAlive = 5033, _connID -// = "\168\223\181\140\b\149\&4\184\157\178\201.\ETX\169Tm\178;\228b\\\246\DLE", _properties = []} -TEST(Connect311QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x13, 0xa9, 0x0, 0x17, - 0xa8, 0xdf, 0xb5, 0x8c, 0x8, 0x95, 0x34, 0xb8, 0x9d, 0xb2, 0xc9, 0x2e, 0x3, 0xa9, - 0x54, 0x6d, 0xb2, 0x3b, 0xe4, 0x62, 0x5c, 0xf6, 0x10, 0x0, 0xe, 0x41, 0x62, 0x51, - 0x7e, 0x99, 0xd3, 0xc3, 0xff, 0x61, 0x52, 0xf0, 0xca, 0x75, 0xdf, 0x0, 0xf, 0xfe, - 0x8b, 0x83, 0xdd, 0x37, 0x79, 0xa7, 0x3, 0xbb, 0x49, 0xbc, 0x4f, 0x7e, 0x65, 0xc7}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// COMP (PubCOMP 13110 0 []) +TEST(PubACKCOMP311QCTest, Encode27) { + uint8_t pkt[] = {0x70, 0x2, 0x33, 0x36}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x41, 0x62, 0x51, 0x7e, 0x99, 0xd3, 0xc3, 0xff, 0x61, 0x52, 0xf0, 0xca, 0x75, 0xdf}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfe, 0x8b, 0x83, 0xdd, 0x37, 0x79, 0xa7, 0x3, - 0xbb, 0x49, 0xbc, 0x4f, 0x7e, 0x65, 0xc7}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 5033; - uint8_t client_id_bytes[] = {0xa8, 0xdf, 0xb5, 0x8c, 0x8, 0x95, 0x34, 0xb8, 0x9d, 0xb2, 0xc9, 0x2e, - 0x3, 0xa9, 0x54, 0x6d, 0xb2, 0x3b, 0xe4, 0x62, 0x5c, 0xf6, 0x10}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xdf, 0x1c, 0x95, 0xd4, 0x7b, 0x51, 0x8b, 0x2b, - 0x2f, 0x73, 0xbf, 0x55, 0xae, 0x6c, 0xa, 0xad}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 13110, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "Q\ESC&\174\247\148\240\DEL]\244\244\245", _password = Just "*\202 ;\132", _lastWill -// = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\130\&6pS\DC2\ACK(Y\152Y\FS\150\ETBy\207\136\204", _willMsg = -// "\164w\254._0\196?\182\141eY\201\165\141n\163\251|\199\160", _willProps = []}), _cleanSession = False, _keepAlive = -// 6835, _connID = "=7\240F\243\217", _properties = []} -TEST(Connect311QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0x51, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x1a, 0xb3, 0x0, 0x6, 0x3d, 0x37, 0xf0, - 0x46, 0xf3, 0xd9, 0x0, 0x11, 0x82, 0x36, 0x70, 0x53, 0x12, 0x6, 0x28, 0x59, 0x98, 0x59, 0x1c, 0x96, - 0x17, 0x79, 0xcf, 0x88, 0xcc, 0x0, 0x15, 0xa4, 0x77, 0xfe, 0x2e, 0x5f, 0x30, 0xc4, 0x3f, 0xb6, 0x8d, - 0x65, 0x59, 0xc9, 0xa5, 0x8d, 0x6e, 0xa3, 0xfb, 0x7c, 0xc7, 0xa0, 0x0, 0xc, 0x51, 0x1b, 0x26, 0xae, - 0xf7, 0x94, 0xf0, 0x7f, 0x5d, 0xf4, 0xf4, 0xf5, 0x0, 0x5, 0x2a, 0xca, 0x20, 0x3b, 0x84}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x82, 0x36, 0x70, 0x53, 0x12, 0x6, 0x28, 0x59, 0x98, - 0x59, 0x1c, 0x96, 0x17, 0x79, 0xcf, 0x88, 0xcc}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa4, 0x77, 0xfe, 0x2e, 0x5f, 0x30, 0xc4, 0x3f, 0xb6, 0x8d, 0x65, - 0x59, 0xc9, 0xa5, 0x8d, 0x6e, 0xa3, 0xfb, 0x7c, 0xc7, 0xa0}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 6835; - uint8_t client_id_bytes[] = {0x3d, 0x37, 0xf0, 0x46, 0xf3, 0xd9}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x51, 0x1b, 0x26, 0xae, 0xf7, 0x94, 0xf0, 0x7f, 0x5d, 0xf4, 0xf4, 0xf5}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x2a, 0xca, 0x20, 0x3b, 0x84}; - lwmqtt_string_t password = {5, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - +// COMP (PubCOMP 13110 0 []) +TEST(PubACKCOMP311QCTest, Decode27) { + uint8_t pkt[] = {0x70, 0x2, 0x33, 0x36}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(packet_id, 13110); + EXPECT_EQ(status, 0); } -// ConnectRequest {_username = Just ">\GSG\161K\206,\183\NAKu{\239\227y\214\238\251\157?\147!,XQ\180\vF\251P", _password -// = Just "\f\192\209\&7\135\205f\134\181\170)xCW.\190E", _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "\236\202:\200\SO\EMYd\145y6:\171-\DC4 \194", _willMsg = -// "\241\156\177\145\136\DC3h\r\128\187P\182\239\173#\153y0o'\158G\149", _willProps = []}), _cleanSession = True, -// _keepAlive = 12883, _connID = "\191\194\&3\136\GS\t\240", _properties = []} -TEST(Connect311QCTest, Encode27) { - uint8_t pkt[] = {0x10, 0x71, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x32, 0x53, 0x0, 0x7, 0xbf, 0xc2, 0x33, - 0x88, 0x1d, 0x9, 0xf0, 0x0, 0x11, 0xec, 0xca, 0x3a, 0xc8, 0xe, 0x19, 0x59, 0x64, 0x91, 0x79, 0x36, - 0x3a, 0xab, 0x2d, 0x14, 0x20, 0xc2, 0x0, 0x17, 0xf1, 0x9c, 0xb1, 0x91, 0x88, 0x13, 0x68, 0xd, 0x80, - 0xbb, 0x50, 0xb6, 0xef, 0xad, 0x23, 0x99, 0x79, 0x30, 0x6f, 0x27, 0x9e, 0x47, 0x95, 0x0, 0x1d, 0x3e, - 0x1d, 0x47, 0xa1, 0x4b, 0xce, 0x2c, 0xb7, 0x15, 0x75, 0x7b, 0xef, 0xe3, 0x79, 0xd6, 0xee, 0xfb, 0x9d, - 0x3f, 0x93, 0x21, 0x2c, 0x58, 0x51, 0xb4, 0xb, 0x46, 0xfb, 0x50, 0x0, 0x11, 0xc, 0xc0, 0xd1, 0x37, - 0x87, 0xcd, 0x66, 0x86, 0xb5, 0xaa, 0x29, 0x78, 0x43, 0x57, 0x2e, 0xbe, 0x45}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// REC (PubREC 25388 0 []) +TEST(PubACKREC311QCTest, Encode28) { + uint8_t pkt[] = {0x50, 0x2, 0x63, 0x2c}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xec, 0xca, 0x3a, 0xc8, 0xe, 0x19, 0x59, 0x64, 0x91, - 0x79, 0x36, 0x3a, 0xab, 0x2d, 0x14, 0x20, 0xc2}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf1, 0x9c, 0xb1, 0x91, 0x88, 0x13, 0x68, 0xd, 0x80, 0xbb, 0x50, 0xb6, - 0xef, 0xad, 0x23, 0x99, 0x79, 0x30, 0x6f, 0x27, 0x9e, 0x47, 0x95}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 12883; - uint8_t client_id_bytes[] = {0xbf, 0xc2, 0x33, 0x88, 0x1d, 0x9, 0xf0}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x3e, 0x1d, 0x47, 0xa1, 0x4b, 0xce, 0x2c, 0xb7, 0x15, 0x75, 0x7b, 0xef, 0xe3, 0x79, 0xd6, - 0xee, 0xfb, 0x9d, 0x3f, 0x93, 0x21, 0x2c, 0x58, 0x51, 0xb4, 0xb, 0x46, 0xfb, 0x50}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xc, 0xc0, 0xd1, 0x37, 0x87, 0xcd, 0x66, 0x86, 0xb5, - 0xaa, 0x29, 0x78, 0x43, 0x57, 0x2e, 0xbe, 0x45}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 25388, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\148o\200m\186<\174\187@H*\199\199k\241N\207z\181$\235z\253j\134{", _password = -// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "", _willMsg = -// "U\STX\188\199\130;", _willProps = []}), _cleanSession = True, _keepAlive = 3904, _connID = -// "\197#\190r4\236\133\t\SIY\198\226\213\244\145", _properties = []} -TEST(Connect311QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0xf, 0x40, 0x0, 0xf, 0xc5, 0x23, 0xbe, - 0x72, 0x34, 0xec, 0x85, 0x9, 0xf, 0x59, 0xc6, 0xe2, 0xd5, 0xf4, 0x91, 0x0, 0x0, 0x0, 0x6, 0x55, - 0x2, 0xbc, 0xc7, 0x82, 0x3b, 0x0, 0x1a, 0x94, 0x6f, 0xc8, 0x6d, 0xba, 0x3c, 0xae, 0xbb, 0x40, 0x48, - 0x2a, 0xc7, 0xc7, 0x6b, 0xf1, 0x4e, 0xcf, 0x7a, 0xb5, 0x24, 0xeb, 0x7a, 0xfd, 0x6a, 0x86, 0x7b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x55, 0x2, 0xbc, 0xc7, 0x82, 0x3b}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 3904; - uint8_t client_id_bytes[] = {0xc5, 0x23, 0xbe, 0x72, 0x34, 0xec, 0x85, 0x9, 0xf, 0x59, 0xc6, 0xe2, 0xd5, 0xf4, 0x91}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x94, 0x6f, 0xc8, 0x6d, 0xba, 0x3c, 0xae, 0xbb, 0x40, 0x48, 0x2a, 0xc7, 0xc7, - 0x6b, 0xf1, 0x4e, 0xcf, 0x7a, 0xb5, 0x24, 0xeb, 0x7a, 0xfd, 0x6a, 0x86, 0x7b}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - +// REC (PubREC 25388 0 []) +TEST(PubACKREC311QCTest, Decode28) { + uint8_t pkt[] = {0x50, 0x2, 0x63, 0x2c}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(len, sizeof(pkt)); - EXPECT_ARRAY_EQ(pkt, buf, len); + EXPECT_EQ(packet_id, 25388); + EXPECT_EQ(status, 0); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\166@\DEL\142", _willMsg = "\DC3x\226\245Jp\148\STX%\DC1\141\240\169\253\ETXfd\193t^", _willProps -// = []}), _cleanSession = True, _keepAlive = 24545, _connID = "\183#J\202\157\184-\233Zr\211\247l\185=\182\150\193", -// _properties = []} -TEST(Connect311QCTest, Encode29) { - uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x5f, 0xe1, 0x0, 0x12, 0xb7, - 0x23, 0x4a, 0xca, 0x9d, 0xb8, 0x2d, 0xe9, 0x5a, 0x72, 0xd3, 0xf7, 0x6c, 0xb9, 0x3d, 0xb6, - 0x96, 0xc1, 0x0, 0x4, 0xa6, 0x40, 0x7f, 0x8e, 0x0, 0x14, 0x13, 0x78, 0xe2, 0xf5, 0x4a, - 0x70, 0x94, 0x2, 0x25, 0x11, 0x8d, 0xf0, 0xa9, 0xfd, 0x3, 0x66, 0x64, 0xc1, 0x74, 0x5e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// COMP (PubCOMP 5812 0 []) +TEST(PubACKCOMP311QCTest, Encode29) { + uint8_t pkt[] = {0x70, 0x2, 0x16, 0xb4}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa6, 0x40, 0x7f, 0x8e}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x13, 0x78, 0xe2, 0xf5, 0x4a, 0x70, 0x94, 0x2, 0x25, 0x11, - 0x8d, 0xf0, 0xa9, 0xfd, 0x3, 0x66, 0x64, 0xc1, 0x74, 0x5e}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 24545; - uint8_t client_id_bytes[] = {0xb7, 0x23, 0x4a, 0xca, 0x9d, 0xb8, 0x2d, 0xe9, 0x5a, - 0x72, 0xd3, 0xf7, 0x6c, 0xb9, 0x3d, 0xb6, 0x96, 0xc1}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 5812, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\\\143\216", _password = Just "\151\&6\134W]\238P\207\167\&0Z", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "9", _willMsg = -// "]v\243\130\NULm\134'\201\ESCs\176\166\a;\239\EM", _willProps = []}), _cleanSession = True, _keepAlive = 17718, -// _connID = "\225qY\140\214\227+/\167\SI7\177", _properties = []} -TEST(Connect311QCTest, Encode30) { - uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x45, 0x36, 0x0, 0xc, 0xe1, 0x71, 0x59, - 0x8c, 0xd6, 0xe3, 0x2b, 0x2f, 0xa7, 0xf, 0x37, 0xb1, 0x0, 0x1, 0x39, 0x0, 0x11, 0x5d, 0x76, 0xf3, - 0x82, 0x0, 0x6d, 0x86, 0x27, 0xc9, 0x1b, 0x73, 0xb0, 0xa6, 0x7, 0x3b, 0xef, 0x19, 0x0, 0x3, 0x5c, - 0x8f, 0xd8, 0x0, 0xb, 0x97, 0x36, 0x86, 0x57, 0x5d, 0xee, 0x50, 0xcf, 0xa7, 0x30, 0x5a}; - uint8_t buf[sizeof(pkt) + 10] = {0}; +// COMP (PubCOMP 5812 0 []) +TEST(PubACKCOMP311QCTest, Decode29) { + uint8_t pkt[] = {0x70, 0x2, 0x16, 0xb4}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 5812); + EXPECT_EQ(status, 0); +} + +// COMP (PubCOMP 30696 0 []) +TEST(PubACKCOMP311QCTest, Encode30) { + uint8_t pkt[] = {0x70, 0x2, 0x77, 0xe8}; + uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x39}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5d, 0x76, 0xf3, 0x82, 0x0, 0x6d, 0x86, 0x27, 0xc9, - 0x1b, 0x73, 0xb0, 0xa6, 0x7, 0x3b, 0xef, 0x19}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 17718; - uint8_t client_id_bytes[] = {0xe1, 0x71, 0x59, 0x8c, 0xd6, 0xe3, 0x2b, 0x2f, 0xa7, 0xf, 0x37, 0xb1}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x5c, 0x8f, 0xd8}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x97, 0x36, 0x86, 0x57, 0x5d, 0xee, 0x50, 0xcf, 0xa7, 0x30, 0x5a}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); - + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 30696, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\160\151\149a\211\ACK*?\149\202\211vrIu\153\DC2\173\173!\ACK", _password = Just -// "\212\133\STX\STX\240\131p", _lastWill = Nothing, _cleanSession = False, _keepAlive = 1099, _connID = -// "1\a\221\162V\235\244\238\188\&2v1%G\151H4@{\224\180\180\184\194\165\&2\138\141\204", _properties = -// [PropTopicAliasMaximum 31313,PropCorrelationData -// "\EM\156`\194\144Q\221Y\128T\245\213e\134x\b\178\&6\139\210O\142\150\175\244:K\DLE\130",PropResponseTopic -// "\139\&65\223zD[\226\128\144#\142\&5/\237\&0]h\231\145\228\212\253\248p\222k",PropWillDelayInterval -// 16733,PropMessageExpiryInterval 18158,PropSessionExpiryInterval 27136,PropTopicAliasMaximum -// 4386,PropAssignedClientIdentifier -// "VC\234\151/a\191E\ETB\203On\215\244's]\STXPT\204\171\205\ESC/l6\"w!",PropRetainAvailable 236,PropServerReference -// "v\221\208?g\141\SO\&H\174\215\209\n",PropSubscriptionIdentifierAvailable 144,PropMaximumPacketSize -// 25477,PropWillDelayInterval 18212,PropContentType "lo\137\203\SO\DC2\143hj\SYNVTE\243\197P",PropAuthenticationMethod -// "",PropResponseTopic "$\220+\241\ACK\255\154\161\\[\196C\230@\183\151\DC1\218\&8",PropMessageExpiryInterval -// 22702,PropCorrelationData "",PropMaximumPacketSize 15828,PropReasonString "\129\177\229",PropResponseInformation -// "\213\128\226\159X>\243\ETX\135}\133\&58\220x\213y\252\v(C=C\205\157\205",PropWillDelayInterval 26379]}), -// _cleanSession = True, _keepAlive = 4861, _connID = "=\b:\142\144", _properties = [PropUserProperty -// "\159\246\235\237\139\128\212\129\\\220\222\223\196\232\172\r)\132\&2" -// "c\CAN\ESC'\DC2\DEL/N\204W-\182\226\228\189k\CAN\241'B\186/\ETX\133\"\193J\137N",PropWildcardSubscriptionAvailable -// 95,PropRetainAvailable 190,PropSubscriptionIdentifierAvailable 194,PropCorrelationData -// "0\ETXL\136\181",PropWildcardSubscriptionAvailable 128,PropRetainAvailable 219,PropUserProperty "s" -// "\139|\244\136\ETB\253\223\191\EOT\DC2I\225G\218\218\190nE\217DR",PropSharedSubscriptionAvailable -// 220,PropRetainAvailable 8,PropRequestProblemInformation 64,PropMessageExpiryInterval 6339,PropMaximumQoS -// 142,PropRequestResponseInformation 171,PropTopicAliasMaximum 27261,PropRequestProblemInformation -// 243,PropReceiveMaximum 26619,PropAuthenticationData "j.\254",PropResponseTopic -// "\189\181JM'!\255\213;d\175\182G~j",PropRetainAvailable 249,PropWillDelayInterval 4276,PropSessionExpiryInterval -// 15218,PropSessionExpiryInterval 26486,PropMessageExpiryInterval 22520,PropSubscriptionIdentifier -// 13,PropResponseInformation "N\b\236\146\171\225\169\acTL{\245/\129[q",PropMaximumQoS 191]} -TEST(Connect5QCTest, Encode2) { +// ACK (PubACK 14158 242 [PropPayloadFormatIndicator 151,PropAssignedClientIdentifier +// "$\221x7Y6M\132qc\213\177_\129vMq\157j\DEL@\229\186\210\252~\DC1C\ESC\195",PropWildcardSubscriptionAvailable +// 68,PropWildcardSubscriptionAvailable 216,PropAuthenticationMethod +// "\219\159g\228G\204\177X^\STXPU\246Dr\176/\151\n;\176\188\135\145",PropUserProperty +// "\DLE\250\235\241G\199\229?\250\240\218\&8\171\130M\251\244K" +// "-\242\233j\203[\200z\163\136\206\&6^\135\170\169\151\&5\240\217h\174",PropMessageExpiryInterval +// 31665,PropReasonString "\129\215\202\&2\236\142x\136\\\232e\245B\ETB\n",PropReceiveMaximum 23944,PropReasonString +// "\170|\244\a\139\143u}\243\140%\SI`tu\180\CANCF\161\173\129\161 \v\173X\206as",PropContentType "<50\231!M)"]) +TEST(PubACKACK5QCTest, Decode1) { uint8_t pkt[] = { - 0x10, 0x94, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x12, 0xfd, 0xbf, 0x1, 0x26, 0x0, 0x13, 0x9f, - 0xf6, 0xeb, 0xed, 0x8b, 0x80, 0xd4, 0x81, 0x5c, 0xdc, 0xde, 0xdf, 0xc4, 0xe8, 0xac, 0xd, 0x29, 0x84, 0x32, 0x0, - 0x1d, 0x63, 0x18, 0x1b, 0x27, 0x12, 0x7f, 0x2f, 0x4e, 0xcc, 0x57, 0x2d, 0xb6, 0xe2, 0xe4, 0xbd, 0x6b, 0x18, 0xf1, - 0x27, 0x42, 0xba, 0x2f, 0x3, 0x85, 0x22, 0xc1, 0x4a, 0x89, 0x4e, 0x28, 0x5f, 0x25, 0xbe, 0x29, 0xc2, 0x9, 0x0, - 0x5, 0x30, 0x3, 0x4c, 0x88, 0xb5, 0x28, 0x80, 0x25, 0xdb, 0x26, 0x0, 0x1, 0x73, 0x0, 0x15, 0x8b, 0x7c, 0xf4, - 0x88, 0x17, 0xfd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, 0x79, 0xfc, 0xb, 0x28, 0x43, 0x3d, 0x43, 0xcd, 0x9d, 0xcd, 0x18, 0x0, 0x0, 0x67, 0xb, 0x0, 0xd, 0x98, - 0xff, 0x83, 0x4d, 0x45, 0x5f, 0x5, 0xe3, 0xc, 0x56, 0x56, 0x8d, 0xac, 0x0, 0x10, 0x98, 0xb, 0x8f, 0xbd, 0xfe, - 0x95, 0x61, 0x1c, 0x37, 0x69, 0xc, 0x5f, 0xdc, 0xf0, 0xd1, 0xe8, 0x0, 0x4, 0xf5, 0x1c, 0x67, 0x83, 0x0, 0x3, - 0xe, 0x8d, 0xd2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x63, 0x18, 0x1b, 0x27, 0x12, 0x7f, 0x2f, 0x4e, 0xcc, 0x57, 0x2d, 0xb6, 0xe2, 0xe4, 0xbd, - 0x6b, 0x18, 0xf1, 0x27, 0x42, 0xba, 0x2f, 0x3, 0x85, 0x22, 0xc1, 0x4a, 0x89, 0x4e}; - uint8_t bytesprops0[] = {0x9f, 0xf6, 0xeb, 0xed, 0x8b, 0x80, 0xd4, 0x81, 0x5c, 0xdc, - 0xde, 0xdf, 0xc4, 0xe8, 0xac, 0xd, 0x29, 0x84, 0x32}; - uint8_t bytesprops2[] = {0x30, 0x3, 0x4c, 0x88, 0xb5}; - uint8_t bytesprops4[] = {0x8b, 0x7c, 0xf4, 0x88, 0x17, 0xfd, 0xdf, 0xbf, 0x4, 0x12, 0x49, - 0xe1, 0x47, 0xda, 0xda, 0xbe, 0x6e, 0x45, 0xd9, 0x44, 0x52}; - uint8_t bytesprops3[] = {0x73}; - uint8_t bytesprops5[] = {0x6a, 0x2e, 0xfe}; - uint8_t bytesprops6[] = {0xbd, 0xb5, 0x4a, 0x4d, 0x27, 0x21, 0xff, 0xd5, 0x3b, 0x64, 0xaf, 0xb6, 0x47, 0x7e, 0x6a}; - uint8_t bytesprops7[] = {0x4e, 0x8, 0xec, 0x92, 0xab, 0x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xad, 0x58, 0xce, 0x61, 0x73, 0x3, 0x0, 0x7, 0x3c, 0x35, 0x30, 0xe7, 0x21, 0x4d, 0x29}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 14158); + EXPECT_EQ(status, 242); +} + +// ACK (PubACK 24514 112 [PropRetainAvailable 24,PropRetainAvailable 183,PropUserProperty "7\a\a\194~\164\142\SYN\149" +// "\160\a6!\175U>\200\188\228\254s",PropAssignedClientIdentifier +// ":\188\SUB/\NAK\219\183`X\144\&3\167\166\155O\232",PropMaximumQoS 118,PropRetainAvailable 81,PropResponseInformation +// "\253\237\DC3\186\158\STX\197\DELm\FS ",PropSharedSubscriptionAvailable 106,PropSubscriptionIdentifier +// 5,PropReasonString "\232\183H\138\140\DC1%\154\154?\t*X\163",PropTopicAlias 15968,PropAuthenticationMethod +// "\212\168[;t2\b\DELc\216\201\213r\189\226\SOH\227\238\225u\232\&7\158\SOHk\204\171\146",PropRequestProblemInformation +// 163]) +TEST(PubACKACK5QCTest, Encode2) { + uint8_t pkt[] = {0x40, 0x80, 0x1, 0x5f, 0xc2, 0x70, 0x7c, 0x25, 0x18, 0x25, 0xb7, 0x26, 0x0, 0x9, 0x37, 0x7, 0x7, + 0xc2, 0x7e, 0xa4, 0x8e, 0x16, 0x95, 0x0, 0xc, 0xa0, 0x7, 0x36, 0x21, 0xaf, 0x55, 0x3e, 0xc8, 0xbc, + 0xe4, 0xfe, 0x73, 0x12, 0x0, 0x10, 0x3a, 0xbc, 0x1a, 0x2f, 0x15, 0xdb, 0xb7, 0x60, 0x58, 0x90, 0x33, + 0xa7, 0xa6, 0x9b, 0x4f, 0xe8, 0x24, 0x76, 0x25, 0x51, 0x1a, 0x0, 0xb, 0xfd, 0xed, 0x13, 0xba, 0x9e, + 0x2, 0xc5, 0x7f, 0x6d, 0x1c, 0x20, 0x2a, 0x6a, 0xb, 0x5, 0x1f, 0x0, 0xe, 0xe8, 0xb7, 0x48, 0x8a, + 0x8c, 0x11, 0x25, 0x9a, 0x9a, 0x3f, 0x9, 0x2a, 0x58, 0xa3, 0x23, 0x3e, 0x60, 0x15, 0x0, 0x1c, 0xd4, + 0xa8, 0x5b, 0x3b, 0x74, 0x32, 0x8, 0x7f, 0x63, 0xd8, 0xc9, 0xd5, 0x72, 0xbd, 0xe2, 0x1, 0xe3, 0xee, + 0xe1, 0x75, 0xe8, 0x37, 0x9e, 0x1, 0x6b, 0xcc, 0xab, 0x92, 0x17, 0xa3}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops1[] = {0xa0, 0x7, 0x36, 0x21, 0xaf, 0x55, 0x3e, 0xc8, 0xbc, 0xe4, 0xfe, 0x73}; + uint8_t bytesprops0[] = {0x37, 0x7, 0x7, 0xc2, 0x7e, 0xa4, 0x8e, 0x16, 0x95}; + uint8_t bytesprops2[] = {0x3a, 0xbc, 0x1a, 0x2f, 0x15, 0xdb, 0xb7, 0x60, + 0x58, 0x90, 0x33, 0xa7, 0xa6, 0x9b, 0x4f, 0xe8}; + uint8_t bytesprops3[] = {0xfd, 0xed, 0x13, 0xba, 0x9e, 0x2, 0xc5, 0x7f, 0x6d, 0x1c, 0x20}; + uint8_t bytesprops4[] = {0xe8, 0xb7, 0x48, 0x8a, 0x8c, 0x11, 0x25, 0x9a, 0x9a, 0x3f, 0x9, 0x2a, 0x58, 0xa3}; + uint8_t bytesprops5[] = {0xd4, 0xa8, 0x5b, 0x3b, 0x74, 0x32, 0x8, 0x7f, 0x63, 0xd8, 0xc9, 0xd5, 0x72, 0xbd, + 0xe2, 0x1, 0xe3, 0xee, 0xe1, 0x75, 0xe8, 0x37, 0x9e, 0x1, 0x6b, 0xcc, 0xab, 0x92}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops0}, .v = {29, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops3}, .v = {21, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6339}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27261}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26619}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4276}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15218}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26486}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22520}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 191}}, - }; - - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x39, 0xd6, 0xbc, 0x67, 0xeb, 0x97, 0x23, 0x1, 0xfe, 0x8c, 0x2f, 0x86, 0x40, 0xcb}; - uint8_t byteswillprops1[] = {0x4f, 0x73, 0x98, 0xe9, 0xbe, 0x4, 0xe6, 0x2f, 0x7c, 0x66, 0xb3, 0xdb, 0xce, - 0xe1, 0x72, 0xa4, 0xc4, 0xed, 0x44, 0x38, 0xb9, 0x87, 0x2c, 0x1f, 0xf, 0x75}; - uint8_t byteswillprops2[] = {0x96, 0xda, 0x77, 0xcd, 0x88, 0x88, 0x53, 0x52, 0x71, 0xf, 0xa0, 0x61, - 0xfd, 0x17, 0xf2, 0x97, 0x16, 0x6, 0x3b, 0x3a, 0x29, 0x71, 0xae, 0xdc}; - uint8_t byteswillprops3[] = {0x72, 0x87, 0xdd, 0x80, 0x28, 0xae, 0xc, 0xdf, 0x15, 0x99, 0x20, - 0xf7, 0xa8, 0xf4, 0x52, 0x82, 0x74, 0xe8, 0xa2, 0x2d, 0x90, 0xbd}; - uint8_t byteswillprops4[] = {0xa0, 0xf6, 0xbc, 0x50, 0x2f, 0x28, 0x6a, 0x2b, 0x28}; - uint8_t byteswillprops5[] = {0xd4, 0xd4, 0x94, 0x74, 0xed, 0x79, 0x43, 0x29, 0x5c, 0x78, - 0x7f, 0xe7, 0x2a, 0x61, 0x40, 0x9a, 0xd9, 0x3e, 0xa}; - uint8_t byteswillprops6[] = {0x6c, 0x6f, 0x89, 0xcb, 0xe, 0x12, 0x8f, 0x68, - 0x6a, 0x16, 0x56, 0x54, 0x45, 0xf3, 0xc5, 0x50}; - uint8_t byteswillprops7[] = {0}; - uint8_t byteswillprops8[] = {0x24, 0xdc, 0x2b, 0xf1, 0x6, 0xff, 0x9a, 0xa1, 0x5c, 0x5b, - 0xc4, 0x43, 0xe6, 0x40, 0xb7, 0x97, 0x11, 0xda, 0x38}; - uint8_t byteswillprops9[] = {0}; - uint8_t byteswillprops10[] = {0x81, 0xb1, 0xe5}; - uint8_t byteswillprops11[] = {0xd5, 0x80, 0xe2, 0x9f, 0x58, 0x3e, 0xf3, 0x3, 0x87, 0x7d, 0x85, 0x35, 0x38, - 0xdc, 0x78, 0xd5, 0x79, 0xfc, 0xb, 0x28, 0x43, 0x3d, 0x43, 0xcd, 0x9d, 0xcd}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11626}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 920}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25442}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28647}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4995}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2060}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24384}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25477}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18212}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22702}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15828}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26379}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops0}, .v = {12, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15968}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 163}}, }; - lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x98, 0xff, 0x83, 0x4d, 0x45, 0x5f, 0x5, 0xe3, 0xc, 0x56, 0x56, 0x8d, 0xac}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x98, 0xb, 0x8f, 0xbd, 0xfe, 0x95, 0x61, 0x1c, - 0x37, 0x69, 0xc, 0x5f, 0xdc, 0xf0, 0xd1, 0xe8}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 4861; - uint8_t client_id_bytes[] = {0x3d, 0x8, 0x3a, 0x8e, 0x90}; - lwmqtt_string_t client_id = {5, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xf5, 0x1c, 0x67, 0x83}; - lwmqtt_string_t username = {4, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe, 0x8d, 0xd2}; - lwmqtt_string_t password = {3, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 24514, 112, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\190~\232\224\v\218x\135\ESC\193\243\132\192\&1\150\134+\245\EOT9\235j\175", -// _password = Nothing, _lastWill = Nothing, _cleanSession = False, _keepAlive = 11488, _connID = "", _properties = -// [PropMaximumQoS 223,PropWildcardSubscriptionAvailable 149,PropAuthenticationData -// "-_/y\147\ENQa\135\188\238\227\231M\225F\161\STX",PropResponseTopic "",PropSharedSubscriptionAvailable -// 166,PropReasonString "\136-W\248Fp\FS\128P\"",PropMaximumPacketSize 25315,PropRetainAvailable -// 63,PropMaximumPacketSize 6919,PropMaximumQoS 71,PropReasonString -// "\137\233\ENQ\ETB\207#\ETB\133s\205\209\247\ENQ\135\166u\232\252",PropRequestProblemInformation -// 115,PropServerReference "\219\229\161t|\255&\195!\" \169\248\&0\157\242j\233\228A\195",PropContentType -// "",PropWillDelayInterval 7778,PropRequestProblemInformation 53,PropAuthenticationData -// "\DLE\152\177\194\aV1\129\129\209c\241\249\201\CANb\162*k\194\246.\193q\190\213\145",PropResponseTopic -// "\178\216\236\130\131\234\173\165\&3\222\STX|C\237\197\191}\193\166z\227\160\186\205\176\219\tPW\NAK",PropAuthenticationMethod -// "\202j\240\220\140\STX\182\SI\DC3\SI\200\147\NUL\SYN\fp\n\132)\188\CANp\163\&1\US",PropCorrelationData -// "n;\254\190E\166\160A",PropSubscriptionIdentifier 15,PropSharedSubscriptionAvailable 228,PropPayloadFormatIndicator -// 39,PropServerKeepAlive 29814]} -TEST(Connect5QCTest, Encode3) { +// ACK (PubACK 24514 112 [PropRetainAvailable 24,PropRetainAvailable 183,PropUserProperty "7\a\a\194~\164\142\SYN\149" +// "\160\a6!\175U>\200\188\228\254s",PropAssignedClientIdentifier +// ":\188\SUB/\NAK\219\183`X\144\&3\167\166\155O\232",PropMaximumQoS 118,PropRetainAvailable 81,PropResponseInformation +// "\253\237\DC3\186\158\STX\197\DELm\FS ",PropSharedSubscriptionAvailable 106,PropSubscriptionIdentifier +// 5,PropReasonString "\232\183H\138\140\DC1%\154\154?\t*X\163",PropTopicAlias 15968,PropAuthenticationMethod +// "\212\168[;t2\b\DELc\216\201\213r\189\226\SOH\227\238\225u\232\&7\158\SOHk\204\171\146",PropRequestProblemInformation +// 163]) +TEST(PubACKACK5QCTest, Decode2) { + uint8_t pkt[] = {0x40, 0x80, 0x1, 0x5f, 0xc2, 0x70, 0x7c, 0x25, 0x18, 0x25, 0xb7, 0x26, 0x0, 0x9, 0x37, 0x7, 0x7, + 0xc2, 0x7e, 0xa4, 0x8e, 0x16, 0x95, 0x0, 0xc, 0xa0, 0x7, 0x36, 0x21, 0xaf, 0x55, 0x3e, 0xc8, 0xbc, + 0xe4, 0xfe, 0x73, 0x12, 0x0, 0x10, 0x3a, 0xbc, 0x1a, 0x2f, 0x15, 0xdb, 0xb7, 0x60, 0x58, 0x90, 0x33, + 0xa7, 0xa6, 0x9b, 0x4f, 0xe8, 0x24, 0x76, 0x25, 0x51, 0x1a, 0x0, 0xb, 0xfd, 0xed, 0x13, 0xba, 0x9e, + 0x2, 0xc5, 0x7f, 0x6d, 0x1c, 0x20, 0x2a, 0x6a, 0xb, 0x5, 0x1f, 0x0, 0xe, 0xe8, 0xb7, 0x48, 0x8a, + 0x8c, 0x11, 0x25, 0x9a, 0x9a, 0x3f, 0x9, 0x2a, 0x58, 0xa3, 0x23, 0x3e, 0x60, 0x15, 0x0, 0x1c, 0xd4, + 0xa8, 0x5b, 0x3b, 0x74, 0x32, 0x8, 0x7f, 0x63, 0xd8, 0xc9, 0xd5, 0x72, 0xbd, 0xe2, 0x1, 0xe3, 0xee, + 0xe1, 0x75, 0xe8, 0x37, 0x9e, 0x1, 0x6b, 0xcc, 0xab, 0x92, 0x17, 0xa3}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 24514); + EXPECT_EQ(status, 112); +} + +// REC (PubREC 28006 97 [PropContentType "G\182\185\187}\152\140",PropServerReference +// "5\240\171\174\178kR\175\144\171\CAN]\138K\ACK\NULX\237\203\183r1\182f\156",PropReasonString +// "\244QV\168\&3\168\&7\158\SOH\RS\205\nk",PropServerKeepAlive 524,PropResponseTopic +// "2\246\135C3\200\202x2|E;\156\DLE\207\184\222\212\255\STX\205\196 0G",PropUserProperty +// "\a\251\249\215G\242\&9\NAKW\GS\217\r4JX\184\164\186:@\f\b\181\205" +// "\188nW\NAK;\192\161\229\189\175\EMG\222\&1\ACK\ETB\160",PropSharedSubscriptionAvailable 48,PropServerReference +// "#~\RS\246\ETB1t\206\246F\SUB\161\193\145\224N\154 D\213#",PropRequestResponseInformation 234,PropAuthenticationData +// "\148\194W\253)\169=@\t",PropReasonString +// "\a\173Z\203h\204\168\209)\DEL\SOH\ETX\159`\181-\208\175N_\173",PropTopicAliasMaximum 30918,PropRetainAvailable +// 251,PropResponseTopic +// "\ACKB\US\176[\180\128\210\178\182\236\ACK\236\161\ETX;\209\142-*\241\248\146",PropSessionExpiryInterval +// 12702,PropRequestProblemInformation 195,PropAuthenticationMethod +// "\221D\238F\235]\ETB\145]\137V\226N\179\220",PropRequestResponseInformation 33,PropReasonString +// "\139\177\248\195\&7K\165*Ep\132L\210\&7nN@\r\209",PropAuthenticationMethod +// "\180\255\&7\188\CANdr?m\142\218i\SI\173\222v",PropRequestResponseInformation 216,PropMaximumPacketSize +// 898,PropWillDelayInterval 13715,PropRequestProblemInformation 163,PropWillDelayInterval +// 7662,PropSharedSubscriptionAvailable 214]) +TEST(PubACKREC5QCTest, Encode3) { uint8_t pkt[] = { - 0x10, 0x87, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x80, 0x2c, 0xe0, 0xe0, 0x1, 0x24, 0xdf, 0x28, 0x95, - 0x16, 0x0, 0x11, 0x2d, 0x5f, 0x2f, 0x79, 0x93, 0x5, 0x61, 0x87, 0xbc, 0xee, 0xe3, 0xe7, 0x4d, 0xe1, 0x46, 0xa1, - 0x2, 0x8, 0x0, 0x0, 0x2a, 0xa6, 0x1f, 0x0, 0xa, 0x88, 0x2d, 0x57, 0xf8, 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76, 0x0, 0x0, 0x0, 0x17, 0xbe, 0x7e, 0xe8, 0xe0, - 0xb, 0xda, 0x78, 0x87, 0x1b, 0xc1, 0xf3, 0x84, 0xc0, 0x31, 0x96, 0x86, 0x2b, 0xf5, 0x4, 0x39, 0xeb, 0x6a, 0xaf}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x2d, 0x5f, 0x2f, 0x79, 0x93, 0x5, 0x61, 0x87, 0xbc, - 0xee, 0xe3, 0xe7, 0x4d, 0xe1, 0x46, 0xa1, 0x2}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x88, 0x2d, 0x57, 0xf8, 0x46, 0x70, 0x1c, 0x80, 0x50, 0x22}; - uint8_t bytesprops3[] = {0x89, 0xe9, 0x5, 0x17, 0xcf, 0x23, 0x17, 0x85, 0x73, - 0xcd, 0xd1, 0xf7, 0x5, 0x87, 0xa6, 0x75, 0xe8, 0xfc}; - uint8_t bytesprops4[] = {0xdb, 0xe5, 0xa1, 0x74, 0x7c, 0xff, 0x26, 0xc3, 0x21, 0x22, 0x20, - 0xa9, 0xf8, 0x30, 0x9d, 0xf2, 0x6a, 0xe9, 0xe4, 0x41, 0xc3}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0x10, 0x98, 0xb1, 0xc2, 0x7, 0x56, 0x31, 0x81, 0x81, 0xd1, 0x63, 0xf1, 0xf9, 0xc9, - 0x18, 0x62, 0xa2, 0x2a, 0x6b, 0xc2, 0xf6, 0x2e, 0xc1, 0x71, 0xbe, 0xd5, 0x91}; - uint8_t bytesprops7[] = {0xb2, 0xd8, 0xec, 0x82, 0x83, 0xea, 0xad, 0xa5, 0x33, 0xde, 0x2, 0x7c, 0x43, 0xed, 0xc5, - 0xbf, 0x7d, 0xc1, 0xa6, 0x7a, 0xe3, 0xa0, 0xba, 0xcd, 0xb0, 0xdb, 0x9, 0x50, 0x57, 0x15}; - uint8_t bytesprops8[] = {0xca, 0x6a, 0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 0x46, 0x1a, 0xa1, 0xc1, 0x91, 0xe0, 0x4e, 0x9a, 0x20, 0x44, 0xd5, 0x23, 0x19, 0xea, 0x16, 0x0, 0x9, 0x94, + 0xc2, 0x57, 0xfd, 0x29, 0xa9, 0x3d, 0x40, 0x9, 0x1f, 0x0, 0x15, 0x7, 0xad, 0x5a, 0xcb, 0x68, 0xcc, 0xa8, 0xd1, + 0x29, 0x7f, 0x1, 0x3, 0x9f, 0x60, 0xb5, 0x2d, 0xd0, 0xaf, 0x4e, 0x5f, 0xad, 0x22, 0x78, 0xc6, 0x25, 0xfb, 0x8, + 0x0, 0x17, 0x6, 0x42, 0x1f, 0xb0, 0x5b, 0xb4, 0x80, 0xd2, 0xb2, 0xb6, 0xec, 0x6, 0xec, 0xa1, 0x3, 0x3b, 0xd1, + 0x8e, 0x2d, 0x2a, 0xf1, 0xf8, 0x92, 0x11, 0x0, 0x0, 0x31, 0x9e, 0x17, 0xc3, 0x15, 0x0, 0xf, 0xdd, 0x44, 0xee, + 0x46, 0xeb, 0x5d, 0x17, 0x91, 0x5d, 0x89, 0x56, 0xe2, 0x4e, 0xb3, 0xdc, 0x19, 0x21, 0x1f, 0x0, 0x13, 0x8b, 0xb1, + 0xf8, 0xc3, 0x37, 0x4b, 0xa5, 0x2a, 0x45, 0x70, 0x84, 0x4c, 0xd2, 0x37, 0x6e, 0x4e, 0x40, 0xd, 0xd1, 0x15, 0x0, + 0x10, 0xb4, 0xff, 0x37, 0xbc, 0x18, 0x64, 0x72, 0x3f, 0x6d, 0x8e, 0xda, 0x69, 0xf, 0xad, 0xde, 0x76, 0x19, 0xd8, + 0x27, 0x0, 0x0, 0x3, 0x82, 0x18, 0x0, 0x0, 0x35, 0x93, 0x17, 0xa3, 0x18, 0x0, 0x0, 0x1d, 0xee, 0x2a, 0xd6}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0x47, 0xb6, 0xb9, 0xbb, 0x7d, 0x98, 0x8c}; + uint8_t bytesprops1[] = {0x35, 0xf0, 0xab, 0xae, 0xb2, 0x6b, 0x52, 0xaf, 0x90, 0xab, 0x18, 0x5d, 0x8a, + 0x4b, 0x6, 0x0, 0x58, 0xed, 0xcb, 0xb7, 0x72, 0x31, 0xb6, 0x66, 0x9c}; + uint8_t bytesprops2[] = {0xf4, 0x51, 0x56, 0xa8, 0x33, 0xa8, 0x37, 0x9e, 0x1, 0x1e, 0xcd, 0xa, 0x6b}; + uint8_t bytesprops3[] = {0x32, 0xf6, 0x87, 0x43, 0x33, 0xc8, 0xca, 0x78, 0x32, 0x7c, 0x45, 0x3b, 0x9c, + 0x10, 0xcf, 0xb8, 0xde, 0xd4, 0xff, 0x2, 0xcd, 0xc4, 0x20, 0x30, 0x47}; + uint8_t bytesprops5[] = {0xbc, 0x6e, 0x57, 0x15, 0x3b, 0xc0, 0xa1, 0xe5, 0xbd, + 0xaf, 0x19, 0x47, 0xde, 0x31, 0x6, 0x17, 0xa0}; + uint8_t bytesprops4[] = {0x7, 0xfb, 0xf9, 0xd7, 0x47, 0xf2, 0x39, 0x15, 0x57, 0x1d, 0xd9, 0xd, + 0x34, 0x4a, 0x58, 0xb8, 0xa4, 0xba, 0x3a, 0x40, 0xc, 0x8, 0xb5, 0xcd}; + uint8_t bytesprops6[] = {0x23, 0x7e, 0x1e, 0xf6, 0x17, 0x31, 0x74, 0xce, 0xf6, 0x46, 0x1a, + 0xa1, 0xc1, 0x91, 0xe0, 0x4e, 0x9a, 0x20, 0x44, 0xd5, 0x23}; + uint8_t bytesprops7[] = {0x94, 0xc2, 0x57, 0xfd, 0x29, 0xa9, 0x3d, 0x40, 0x9}; + uint8_t bytesprops8[] = {0x7, 0xad, 0x5a, 0xcb, 0x68, 0xcc, 0xa8, 0xd1, 0x29, 0x7f, 0x1, + 0x3, 0x9f, 0x60, 0xb5, 0x2d, 0xd0, 0xaf, 0x4e, 0x5f, 0xad}; + uint8_t bytesprops9[] = {0x6, 0x42, 0x1f, 0xb0, 0x5b, 0xb4, 0x80, 0xd2, 0xb2, 0xb6, 0xec, 0x6, + 0xec, 0xa1, 0x3, 0x3b, 0xd1, 0x8e, 0x2d, 0x2a, 0xf1, 0xf8, 0x92}; + uint8_t bytesprops10[] = {0xdd, 0x44, 0xee, 0x46, 0xeb, 0x5d, 0x17, 0x91, 0x5d, 0x89, 0x56, 0xe2, 0x4e, 0xb3, 0xdc}; + uint8_t bytesprops11[] = {0x8b, 0xb1, 0xf8, 0xc3, 0x37, 0x4b, 0xa5, 0x2a, 0x45, 0x70, + 0x84, 0x4c, 0xd2, 0x37, 0x6e, 0x4e, 0x40, 0xd, 0xd1}; + uint8_t bytesprops12[] = {0xb4, 0xff, 0x37, 0xbc, 0x18, 0x64, 0x72, 0x3f, + 0x6d, 0x8e, 0xda, 0x69, 0xf, 0xad, 0xde, 0x76}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25315}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6919}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7778}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29814}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 524}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops4}, .v = {17, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30918}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12702}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 898}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13715}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7662}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 214}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 11488; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xbe, 0x7e, 0xe8, 0xe0, 0xb, 0xda, 0x78, 0x87, 0x1b, 0xc1, 0xf3, 0x84, - 0xc0, 0x31, 0x96, 0x86, 0x2b, 0xf5, 0x4, 0x39, 0xeb, 0x6a, 0xaf}; - lwmqtt_string_t username = {23, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); - + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, 0, 28006, 97, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "_\DLE\201\254`\162\246\240I", _password = Nothing, _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "\248J", _willMsg = -// "\RSG\205\252\RSP\173\SO\195\CAN\209PX\DC1c:\218\166G\158\ACK", _willProps = [PropReceiveMaximum -// 2303,PropRetainAvailable 55,PropMessageExpiryInterval 30752,PropRetainAvailable 95,PropResponseTopic -// "\vKr\227\129\189d",PropContentType "#\SOz\SOH\223\DC2;\ESC;\NULc8\199",PropSharedSubscriptionAvailable -// 83,PropWillDelayInterval 19746]}), _cleanSession = True, _keepAlive = 31889, _connID = -// "I.j%\170?\194\183h\143.\150\255", _properties = [PropAssignedClientIdentifier -// "\234P\ETB(T\179\STX\247\STXs\207SoA\133(=\STXG\191\201{\ENQ\225\DC2",PropAssignedClientIdentifier -// "\141^o",PropPayloadFormatIndicator 172,PropWillDelayInterval 32628,PropServerReference -// "\135V\185W\131B^\149\189\&8\216\232K\244",PropUserProperty "q2F\169" -// "\191Vo,\205a\218\174\USbTj\162G\243\177_>1\158$\232",PropMaximumQoS 203,PropTopicAliasMaximum -// 6794,PropAuthenticationMethod -// "\225)Q$>\220E\215\169\243$r\247{\241\&6\138\152 C\233\147e\v\172B\203\132",PropWildcardSubscriptionAvailable +// 205,PropContentType "f\b{\208\232C",PropSessionExpiryInterval 10209,PropMaximumQoS 161,PropReasonString +// "\188\179\240\f/\188Hd\r1\231\144\f\173p\\\134\SO_\213\EOT\253\&3~{\235M\RSZ",PropAuthenticationMethod +// "\205\213u\DLE\n\238"]) +TEST(PubACKACK5QCTest, Encode6) { + uint8_t pkt[] = {0x40, 0xc4, 0x1, 0x3e, 0x0, 0xd6, 0xbf, 0x1, 0x21, 0x78, 0xcb, 0x1c, 0x0, 0x4, 0xbf, 0xdd, 0x75, + 0xaf, 0x26, 0x0, 0xf, 0x34, 0x76, 0x5d, 0x9, 0xa, 0x7e, 0x20, 0x9, 0xd2, 0x61, 0xde, 0x16, 0x4e, + 0x33, 0x98, 0x0, 0xf, 0xec, 0xcb, 0xd9, 0x72, 0xa1, 0xb3, 0xf5, 0x5, 0x75, 0xff, 0xfa, 0x98, 0x15, + 0x46, 0xee, 0x23, 0x2e, 0xa, 0x27, 0x0, 0x0, 0x75, 0xd3, 0x29, 0xa, 0xb, 0x10, 0x15, 0x0, 0xc, + 0x3a, 0xb, 0x88, 0x31, 0x8a, 0xb7, 0x12, 0x3d, 0xb5, 0x1a, 0x87, 0x35, 0x12, 0x0, 0x3, 0x62, 0x29, + 0x8b, 0x3, 0x0, 0x13, 0x54, 0xb2, 0xba, 0x86, 0x5e, 0x95, 0x82, 0xc8, 0x7, 0xc7, 0x80, 0x4e, 0x74, + 0x43, 0xb8, 0x6f, 0x9c, 0x51, 0xac, 0x12, 0x0, 0x1d, 0x74, 0x75, 0x2f, 0xb4, 0x8d, 0xbf, 0xb8, 0x2a, + 0x86, 0x9, 0xa5, 0xe, 0x52, 0x25, 0xbe, 0xf3, 0x3e, 0x8a, 0x98, 0x20, 0x43, 0xe9, 0x93, 0x65, 0xb, + 0xac, 0x42, 0xcb, 0x84, 0x28, 0xcd, 0x3, 0x0, 0x6, 0x66, 0x8, 0x7b, 0xd0, 0xe8, 0x43, 0x11, 0x0, + 0x0, 0x27, 0xe1, 0x24, 0xa1, 0x1f, 0x0, 0x1d, 0xbc, 0xb3, 0xf0, 0xc, 0x2f, 0xbc, 0x48, 0x64, 0xd, + 0x31, 0xe7, 0x90, 0xc, 0xad, 0x70, 0x5c, 0x86, 0xe, 0x5f, 0xd5, 0x4, 0xfd, 0x33, 0x7e, 0x7b, 0xeb, + 0x4d, 0x1e, 0x5a, 0x15, 0x0, 0x6, 0xcd, 0xd5, 0x75, 0x10, 0xa, 0xee}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0xbf, 0xdd, 0x75, 0xaf}; + uint8_t bytesprops2[] = {0xec, 0xcb, 0xd9, 0x72, 0xa1, 0xb3, 0xf5, 0x5, 0x75, 0xff, 0xfa, 0x98, 0x15, 0x46, 0xee}; + uint8_t bytesprops1[] = {0x34, 0x76, 0x5d, 0x9, 0xa, 0x7e, 0x20, 0x9, 0xd2, 0x61, 0xde, 0x16, 0x4e, 0x33, 0x98}; + uint8_t bytesprops3[] = {0x3a, 0xb, 0x88, 0x31, 0x8a, 0xb7, 0x12, 0x3d, 0xb5, 0x1a, 0x87, 0x35}; + uint8_t bytesprops4[] = {0x62, 0x29, 0x8b}; + uint8_t bytesprops5[] = {0x54, 0xb2, 0xba, 0x86, 0x5e, 0x95, 0x82, 0xc8, 0x7, 0xc7, + 0x80, 0x4e, 0x74, 0x43, 0xb8, 0x6f, 0x9c, 0x51, 0xac}; + uint8_t bytesprops6[] = {0x74, 0x75, 0x2f, 0xb4, 0x8d, 0xbf, 0xb8, 0x2a, 0x86, 0x9, 0xa5, 0xe, 0x52, 0x25, 0xbe, + 0xf3, 0x3e, 0x8a, 0x98, 0x20, 0x43, 0xe9, 0x93, 0x65, 0xb, 0xac, 0x42, 0xcb, 0x84}; + uint8_t bytesprops7[] = {0x66, 0x8, 0x7b, 0xd0, 0xe8, 0x43}; + uint8_t bytesprops8[] = {0xbc, 0xb3, 0xf0, 0xc, 0x2f, 0xbc, 0x48, 0x64, 0xd, 0x31, 0xe7, 0x90, 0xc, 0xad, 0x70, + 0x5c, 0x86, 0xe, 0x5f, 0xd5, 0x4, 0xfd, 0x33, 0x7e, 0x7b, 0xeb, 0x4d, 0x1e, 0x5a}; + uint8_t bytesprops9[] = {0xcd, 0xd5, 0x75, 0x10, 0xa, 0xee}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6085}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32239}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26513}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27052}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13374}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14469}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15730}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20899}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3724}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4163}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13157}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops4}}}, - }; - - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xfb, 0xf3, 0x95, 0xfd, 0x7b, 0xba, 0xab, 0xc5, - 0xac, 0xa4, 0xc1, 0x1d, 0xd2, 0x47, 0x41, 0x31}; - uint8_t byteswillprops1[] = {0xbb, 0xd, 0xcd, 0xc, 0x54, 0x47, 0x8a, 0xda, 0x85, 0x10, 0x80, 0xf4, 0x3, 0xc6, 0xc0, - 0xd4, 0xe0, 0x38, 0x27, 0xd4, 0x83, 0xa2, 0xee, 0x75, 0x59, 0x80, 0x55, 0x72, 0xde}; - uint8_t byteswillprops2[] = {0xd3, 0x71, 0x7f, 0xf9, 0x75}; - uint8_t byteswillprops3[] = {0x4b, 0xe7, 0xcf, 0x31, 0x75, 0xce, 0x4c, 0x72, 0x8f, 0x75, 0xb1, 0xf0, 0x14, 0xbb, - 0x63, 0x6, 0xa8, 0x27, 0xea, 0xe2, 0xcd, 0x60, 0x6d, 0x80, 0xc2, 0xc0, 0x2c, 0x56}; - uint8_t byteswillprops5[] = {0xf6, 0xb7, 0x68, 0x9c}; - uint8_t byteswillprops4[] = {0xa0, 0x98, 0x9, 0x4e, 0x12, 0x68, 0x30, 0xfc, 0xad, 0x1, - 0x58, 0x2f, 0x1e, 0x1d, 0x2e, 0xd8, 0xb8, 0x11, 0x23, 0x73}; - uint8_t byteswillprops6[] = {0x8b, 0xf, 0x8e, 0xb6, 0x46, 0xd0, 0xe5, 0x9c, 0xd6}; - uint8_t byteswillprops7[] = {0x6d, 0xef, 0x4f, 0x14}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31865}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5958}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20550}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1297}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4777}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {20, (char*)&byteswillprops4}, .v = {4, (char*)&byteswillprops5}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1527}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10288}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11822}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18800}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25564}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1795}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10052}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30923}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops1}, .v = {15, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11786}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30163}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10209}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t willprops = {30, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf, 0x25, 0xca, 0xd2, 0x5e, 0xbb, 0x37, 0xe3, 0xa5, - 0xf, 0xec, 0x8, 0xc7, 0x2c, 0x9f, 0xee, 0xa9}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa7, 0xeb, 0x6, 0xd3, 0x46, 0xa, 0xd3, 0x5c, 0x40, 0x21, 0x57, 0x68, 0xa}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 4901; - uint8_t client_id_bytes[] = {0x62, 0x44, 0x63}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xae, 0x67, 0x2d, 0x7e, 0x1f, 0xfe, 0xae, 0x1e, 0x35, 0xd, 0x94, 0xfb, 0xbe, - 0x8d, 0x93, 0x65, 0x64, 0x2c, 0xb2, 0x1c, 0x94, 0x27, 0x7f, 0x62, 0xae, 0xd8}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 15872, 214, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS1, _willTopic = "c_\DC1\222(\232\&7", _willMsg = -// "\213z\217-\215\&3\195\ETB\188G\198\140\251+\139\183\183\222\232\204M\187\145\252\EOT\n\192\129", _willProps = -// [PropResponseInformation "u",PropAuthenticationData -// "\NAK9\201\234S\189\240C\251\ETB\182\187\t\187\144]\"|\139",PropRequestProblemInformation 231,PropMaximumPacketSize -// 25564,PropReceiveMaximum 26307,PropSessionExpiryInterval 3535,PropSubscriptionIdentifierAvailable 156,PropContentType -// "1\235\244~\199I\"\180\SYN\ACK\176\153P\148\255c\237\161[\USL\191\a\f&\232\137\151>)",PropAuthenticationMethod -// "Z#\f",PropSubscriptionIdentifier 5,PropSubscriptionIdentifier 19,PropServerReference -// "\212b4\143\148\223\232\250\163\228\138.\135\237`\195\SO&\130\RS\168\CAN\149\a\150\226\221\247?",PropSubscriptionIdentifier -// 7,PropContentType "\186\190?\ETXv;Q\GS\179\141\215\t2\179\233",PropReasonString -// "B/\ESC\165\176\135\235\200=\ETX\225<\150\224\149\197\200\NAK-I\214P\144\161\fJ/",PropAuthenticationData -// "\229\180M\232i\215~\143\DC3",PropReceiveMaximum 3850,PropMaximumPacketSize 19044,PropSubscriptionIdentifierAvailable -// 27,PropWillDelayInterval 8865,PropResponseTopic "u\"\DC3\246 -// \187\191\176`\146\GS\247\NAKQ~E\152i\196",PropRequestProblemInformation 35,PropMaximumQoS -// 212,PropRequestResponseInformation 160,PropResponseInformation -// "\237\190\209K-\180\155\253\153s\210\235p\221S\153\206\142\165%\DC28?",PropSubscriptionIdentifier 18]}), -// _cleanSession = True, _keepAlive = 7652, _connID = "m\186 \189\208z", _properties = [PropTopicAliasMaximum -// 7752,PropWildcardSubscriptionAvailable 167,PropSubscriptionIdentifier 19,PropUserProperty "\153\230" -// "\145m5q\238U\ETB\136*",PropSessionExpiryInterval 19199,PropServerKeepAlive 11861,PropSubscriptionIdentifierAvailable -// 196,PropMaximumPacketSize 19471,PropTopicAlias 18512,PropContentType -// "-oGT\128\163\EOTR\171\195\143\248\153.",PropReceiveMaximum 12290,PropReceiveMaximum 23080,PropMessageExpiryInterval -// 8200,PropUserProperty "\198\b^\159\210i_*\238\241\tFl\224\239RJ+\167\CAN\232u\185\DC4\183\249" -// "\140k\231\194\181\213^o \211\\\244\214\145\130\174\190\158=\255\143 \146\195n\151\145\202",PropServerReference -// "t\a\166xR$\213W\142\241\RS\203",PropRequestResponseInformation 132,PropRequestResponseInformation -// 227,PropSubscriptionIdentifierAvailable 22,PropResponseInformation "\US\160\170\180",PropPayloadFormatIndicator -// 131,PropRetainAvailable 204,PropResponseInformation "\214\DLE\218\190fG"]} -TEST(Connect5QCTest, Encode7) { - uint8_t pkt[] = { - 0x10, 0xe1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe, 0x1d, 0xe4, 0xa9, 0x1, 0x22, 0x1e, 0x48, 0x28, - 0xa7, 0xb, 0x13, 0x26, 0x0, 0x2, 0x99, 0xe6, 0x0, 0x9, 0x91, 0x6d, 0x35, 0x71, 0xee, 0x55, 0x17, 0x88, 0x2a, - 0x11, 0x0, 0x0, 0x4a, 0xff, 0x13, 0x2e, 0x55, 0x29, 0xc4, 0x27, 0x0, 0x0, 0x4c, 0xf, 0x23, 0x48, 0x50, 0x3, - 0x0, 0xe, 0x2d, 0x6f, 0x47, 0x54, 0x80, 0xa3, 0x4, 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8e, 0xa5, 0x25, 0x12, 0x38, 0x3f, 0xb, 0x12, 0x0, 0x7, 0x63, 0x5f, 0x11, 0xde, 0x28, 0xe8, 0x37, 0x0, 0x1c, - 0xd5, 0x7a, 0xd9, 0x2d, 0xd7, 0x33, 0xc3, 0x17, 0xbc, 0x47, 0xc6, 0x8c, 0xfb, 0x2b, 0x8b, 0xb7, 0xb7, 0xde, 0xe8, - 0xcc, 0x4d, 0xbb, 0x91, 0xfc, 0x4, 0xa, 0xc0, 0x81}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x91, 0x6d, 0x35, 0x71, 0xee, 0x55, 0x17, 0x88, 0x2a}; - uint8_t bytesprops0[] = {0x99, 0xe6}; - uint8_t bytesprops2[] = {0x2d, 0x6f, 0x47, 0x54, 0x80, 0xa3, 0x4, 0x52, 0xab, 0xc3, 0x8f, 0xf8, 0x99, 0x2e}; - uint8_t bytesprops4[] = {0x8c, 0x6b, 0xe7, 0xc2, 0xb5, 0xd5, 0x5e, 0x6f, 0x20, 0xd3, 0x5c, 0xf4, 0xd6, 0x91, - 0x82, 0xae, 0xbe, 0x9e, 0x3d, 0xff, 0x8f, 0x20, 0x92, 0xc3, 0x6e, 0x97, 0x91, 0xca}; - uint8_t bytesprops3[] = {0xc6, 0x8, 0x5e, 0x9f, 0xd2, 0x69, 0x5f, 0x2a, 0xee, 0xf1, 0x9, 0x46, 0x6c, - 0xe0, 0xef, 0x52, 0x4a, 0x2b, 0xa7, 0x18, 0xe8, 0x75, 0xb9, 0x14, 0xb7, 0xf9}; - uint8_t bytesprops5[] = {0x74, 0x7, 0xa6, 0x78, 0x52, 0x24, 0xd5, 0x57, 0x8e, 0xf1, 0x1e, 0xcb}; - uint8_t bytesprops6[] = {0x1f, 0xa0, 0xaa, 0xb4}; - uint8_t bytesprops7[] = {0xd6, 0x10, 0xda, 0xbe, 0x66, 0x47}; +// ACK (PubACK 15872 214 [PropReceiveMaximum 30923,PropServerReference "\191\221u\175",PropUserProperty "4v]\t\n~ +// \t\210a\222\SYNN3\152" "\236\203\217r\161\179\245\ENQu\255\250\152\NAKF\238",PropTopicAlias +// 11786,PropMaximumPacketSize 30163,PropSubscriptionIdentifierAvailable 10,PropSubscriptionIdentifier +// 16,PropAuthenticationMethod ":\v\136\&1\138\183\DC2=\181\SUB\135\&5",PropAssignedClientIdentifier +// "b)\139",PropContentType "T\178\186\134^\149\130\200\a\199\128NtC\184o\156Q\172",PropAssignedClientIdentifier +// "tu/\180\141\191\184*\134\t\165\SOR%\190\243>\138\152 C\233\147e\v\172B\203\132",PropWildcardSubscriptionAvailable +// 205,PropContentType "f\b{\208\232C",PropSessionExpiryInterval 10209,PropMaximumQoS 161,PropReasonString +// "\188\179\240\f/\188Hd\r1\231\144\f\173p\\\134\SO_\213\EOT\253\&3~{\235M\RSZ",PropAuthenticationMethod +// "\205\213u\DLE\n\238"]) +TEST(PubACKACK5QCTest, Decode6) { + uint8_t pkt[] = {0x40, 0xc4, 0x1, 0x3e, 0x0, 0xd6, 0xbf, 0x1, 0x21, 0x78, 0xcb, 0x1c, 0x0, 0x4, 0xbf, 0xdd, 0x75, + 0xaf, 0x26, 0x0, 0xf, 0x34, 0x76, 0x5d, 0x9, 0xa, 0x7e, 0x20, 0x9, 0xd2, 0x61, 0xde, 0x16, 0x4e, + 0x33, 0x98, 0x0, 0xf, 0xec, 0xcb, 0xd9, 0x72, 0xa1, 0xb3, 0xf5, 0x5, 0x75, 0xff, 0xfa, 0x98, 0x15, + 0x46, 0xee, 0x23, 0x2e, 0xa, 0x27, 0x0, 0x0, 0x75, 0xd3, 0x29, 0xa, 0xb, 0x10, 0x15, 0x0, 0xc, + 0x3a, 0xb, 0x88, 0x31, 0x8a, 0xb7, 0x12, 0x3d, 0xb5, 0x1a, 0x87, 0x35, 0x12, 0x0, 0x3, 0x62, 0x29, + 0x8b, 0x3, 0x0, 0x13, 0x54, 0xb2, 0xba, 0x86, 0x5e, 0x95, 0x82, 0xc8, 0x7, 0xc7, 0x80, 0x4e, 0x74, + 0x43, 0xb8, 0x6f, 0x9c, 0x51, 0xac, 0x12, 0x0, 0x1d, 0x74, 0x75, 0x2f, 0xb4, 0x8d, 0xbf, 0xb8, 0x2a, + 0x86, 0x9, 0xa5, 0xe, 0x52, 0x25, 0xbe, 0xf3, 0x3e, 0x8a, 0x98, 0x20, 0x43, 0xe9, 0x93, 0x65, 0xb, + 0xac, 0x42, 0xcb, 0x84, 0x28, 0xcd, 0x3, 0x0, 0x6, 0x66, 0x8, 0x7b, 0xd0, 0xe8, 0x43, 0x11, 0x0, + 0x0, 0x27, 0xe1, 0x24, 0xa1, 0x1f, 0x0, 0x1d, 0xbc, 0xb3, 0xf0, 0xc, 0x2f, 0xbc, 0x48, 0x64, 0xd, + 0x31, 0xe7, 0x90, 0xc, 0xad, 0x70, 0x5c, 0x86, 0xe, 0x5f, 0xd5, 0x4, 0xfd, 0x33, 0x7e, 0x7b, 0xeb, + 0x4d, 0x1e, 0x5a, 0x15, 0x0, 0x6, 0xcd, 0xd5, 0x75, 0x10, 0xa, 0xee}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 15872); + EXPECT_EQ(status, 214); +} + +// REL (PubREL 21231 228 [PropUserProperty "\v" +// "\138\213\v=-\147\SYN8\221%\224\240!S\135JEj\210\203\206\217`\202H\ETB+",PropServerKeepAlive +// 5414,PropWillDelayInterval 17971,PropContentType "\244\a",PropTopicAliasMaximum 17656,PropReceiveMaximum +// 9191,PropRetainAvailable 122,PropUserProperty "h\140\179\254\r\232\172\215&\144\189\146\131\SUB@l\255\138\162" +// "\186/-U)\232\245\&2",PropMessageExpiryInterval 660,PropServerKeepAlive 9579,PropPayloadFormatIndicator +// 187,PropPayloadFormatIndicator 214,PropReasonString "\247b\200g\248y\137!\220k8o\221\&6",PropResponseInformation +// "wkdM/\138\232\SO\199\203\US\180\143Qfof\161\RSv\247\233B\132OM"]) +TEST(PubACKREL5QCTest, Encode7) { + uint8_t pkt[] = {0x62, 0x95, 0x1, 0x52, 0xef, 0xe4, 0x90, 0x1, 0x26, 0x0, 0x1, 0xb, 0x0, 0x1b, 0x8a, 0xd5, 0xb, + 0x3d, 0x2d, 0x93, 0x16, 0x38, 0xdd, 0x25, 0xe0, 0xf0, 0x21, 0x53, 0x87, 0x4a, 0x45, 0x6a, 0xd2, 0xcb, + 0xce, 0xd9, 0x60, 0xca, 0x48, 0x17, 0x2b, 0x13, 0x15, 0x26, 0x18, 0x0, 0x0, 0x46, 0x33, 0x3, 0x0, + 0x2, 0xf4, 0x7, 0x22, 0x44, 0xf8, 0x21, 0x23, 0xe7, 0x25, 0x7a, 0x26, 0x0, 0x13, 0x68, 0x8c, 0xb3, + 0xfe, 0xd, 0xe8, 0xac, 0xd7, 0x26, 0x90, 0xbd, 0x92, 0x83, 0x1a, 0x40, 0x6c, 0xff, 0x8a, 0xa2, 0x0, + 0x8, 0xba, 0x2f, 0x2d, 0x55, 0x29, 0xe8, 0xf5, 0x32, 0x2, 0x0, 0x0, 0x2, 0x94, 0x13, 0x25, 0x6b, + 0x1, 0xbb, 0x1, 0xd6, 0x1f, 0x0, 0xe, 0xf7, 0x62, 0xc8, 0x67, 0xf8, 0x79, 0x89, 0x21, 0xdc, 0x6b, + 0x38, 0x6f, 0xdd, 0x36, 0x1a, 0x0, 0x1a, 0x77, 0x6b, 0x64, 0x4d, 0x2f, 0x8a, 0xe8, 0xe, 0xc7, 0xcb, + 0x1f, 0xb4, 0x8f, 0x51, 0x66, 0x6f, 0x66, 0xa1, 0x1e, 0x76, 0xf7, 0xe9, 0x42, 0x84, 0x4f, 0x4d}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops1[] = {0x8a, 0xd5, 0xb, 0x3d, 0x2d, 0x93, 0x16, 0x38, 0xdd, 0x25, 0xe0, 0xf0, 0x21, 0x53, + 0x87, 0x4a, 0x45, 0x6a, 0xd2, 0xcb, 0xce, 0xd9, 0x60, 0xca, 0x48, 0x17, 0x2b}; + uint8_t bytesprops0[] = {0xb}; + uint8_t bytesprops2[] = {0xf4, 0x7}; + uint8_t bytesprops4[] = {0xba, 0x2f, 0x2d, 0x55, 0x29, 0xe8, 0xf5, 0x32}; + uint8_t bytesprops3[] = {0x68, 0x8c, 0xb3, 0xfe, 0xd, 0xe8, 0xac, 0xd7, 0x26, 0x90, + 0xbd, 0x92, 0x83, 0x1a, 0x40, 0x6c, 0xff, 0x8a, 0xa2}; + uint8_t bytesprops5[] = {0xf7, 0x62, 0xc8, 0x67, 0xf8, 0x79, 0x89, 0x21, 0xdc, 0x6b, 0x38, 0x6f, 0xdd, 0x36}; + uint8_t bytesprops6[] = {0x77, 0x6b, 0x64, 0x4d, 0x2f, 0x8a, 0xe8, 0xe, 0xc7, 0xcb, 0x1f, 0xb4, 0x8f, + 0x51, 0x66, 0x6f, 0x66, 0xa1, 0x1e, 0x76, 0xf7, 0xe9, 0x42, 0x84, 0x4f, 0x4d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7752}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops0}, .v = {9, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19199}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11861}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19471}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18512}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12290}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23080}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8200}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops7}}}, - }; - - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x75}; - uint8_t byteswillprops1[] = {0x15, 0x39, 0xc9, 0xea, 0x53, 0xbd, 0xf0, 0x43, 0xfb, 0x17, - 0xb6, 0xbb, 0x9, 0xbb, 0x90, 0x5d, 0x22, 0x7c, 0x8b}; - uint8_t byteswillprops2[] = {0x31, 0xeb, 0xf4, 0x7e, 0xc7, 0x49, 0x22, 0xb4, 0x16, 0x6, - 0xb0, 0x99, 0x50, 0x94, 0xff, 0x63, 0xed, 0xa1, 0x5b, 0x1f, - 0x4c, 0xbf, 0x7, 0xc, 0x26, 0xe8, 0x89, 0x97, 0x3e, 0x29}; - uint8_t byteswillprops3[] = {0x5a, 0x23, 0xc}; - uint8_t byteswillprops4[] = {0xd4, 0x62, 0x34, 0x8f, 0x94, 0xdf, 0xe8, 0xfa, 0xa3, 0xe4, 0x8a, 0x2e, 0x87, 0xed, 0x60, - 0xc3, 0xe, 0x26, 0x82, 0x1e, 0xa8, 0x18, 0x95, 0x7, 0x96, 0xe2, 0xdd, 0xf7, 0x3f}; - uint8_t byteswillprops5[] = {0xba, 0xbe, 0x3f, 0x3, 0x76, 0x3b, 0x51, 0x1d, 0xb3, 0x8d, 0xd7, 0x9, 0x32, 0xb3, 0xe9}; - uint8_t byteswillprops6[] = {0x42, 0x2f, 0x1b, 0xa5, 0xb0, 0x87, 0xeb, 0xc8, 0x3d, 0x3, 0xe1, 0x3c, 0x96, 0xe0, - 0x95, 0xc5, 0xc8, 0x15, 0x2d, 0x49, 0xd6, 0x50, 0x90, 0xa1, 0xc, 0x4a, 0x2f}; - uint8_t byteswillprops7[] = {0xe5, 0xb4, 0x4d, 0xe8, 0x69, 0xd7, 0x7e, 0x8f, 0x13}; - uint8_t byteswillprops8[] = {0x75, 0x22, 0x13, 0xf6, 0x20, 0xbb, 0xbf, 0xb0, 0x60, 0x92, - 0x1d, 0xf7, 0x15, 0x51, 0x7e, 0x45, 0x98, 0x69, 0xc4}; - uint8_t byteswillprops9[] = {0xed, 0xbe, 0xd1, 0x4b, 0x2d, 0xb4, 0x9b, 0xfd, 0x99, 0x73, 0xd2, 0xeb, - 0x70, 0xdd, 0x53, 0x99, 0xce, 0x8e, 0xa5, 0x25, 0x12, 0x38, 0x3f}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25564}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26307}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3535}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3850}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19044}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8865}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {27, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5414}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17971}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17656}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9191}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops3}, .v = {8, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 660}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9579}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x63, 0x5f, 0x11, 0xde, 0x28, 0xe8, 0x37}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd5, 0x7a, 0xd9, 0x2d, 0xd7, 0x33, 0xc3, 0x17, 0xbc, 0x47, 0xc6, 0x8c, 0xfb, 0x2b, - 0x8b, 0xb7, 0xb7, 0xde, 0xe8, 0xcc, 0x4d, 0xbb, 0x91, 0xfc, 0x4, 0xa, 0xc0, 0x81}; - lwmqtt_string_t will_payload = {28, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 7652; - uint8_t client_id_bytes[] = {0x6d, 0xba, 0x20, 0xbd, 0xd0, 0x7a}; - lwmqtt_string_t client_id = {6, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 21231, 228, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS2, _willTopic = "\167\186,\225\231\n\229RS\158n\EOT\157pX\SI\134\254\187\&5\178[\235\215\141", _willMsg = "\183~", -// _willProps = [PropReasonString "\131\239}\233\220"]}), _cleanSession = True, _keepAlive = 4897, _connID = -// "\215ES)\213\"\RS\149\165\167\252\216_\166", _properties = [PropAssignedClientIdentifier -// "\128\128D\184\170\196U\255\162\EOT8}6\229b\DLE\170n\214\186\201"]} -TEST(Connect5QCTest, Encode8) { - uint8_t pkt[] = {0x10, 0x5b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x36, 0x13, 0x21, 0x18, 0x12, 0x0, 0x15, - 0x80, 0x80, 0x44, 0xb8, 0xaa, 0xc4, 0x55, 0xff, 0xa2, 0x4, 0x38, 0x7d, 0x36, 0xe5, 0x62, 0x10, - 0xaa, 0x6e, 0xd6, 0xba, 0xc9, 0x0, 0xe, 0xd7, 0x45, 0x53, 0x29, 0xd5, 0x22, 0x1e, 0x95, 0xa5, - 0xa7, 0xfc, 0xd8, 0x5f, 0xa6, 0x8, 0x1f, 0x0, 0x5, 0x83, 0xef, 0x7d, 0xe9, 0xdc, 0x0, 0x19, - 0xa7, 0xba, 0x2c, 0xe1, 0xe7, 0xa, 0xe5, 0x52, 0x53, 0x9e, 0x6e, 0x4, 0x9d, 0x70, 0x58, 0xf, - 0x86, 0xfe, 0xbb, 0x35, 0xb2, 0x5b, 0xeb, 0xd7, 0x8d, 0x0, 0x2, 0xb7, 0x7e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x80, 0x80, 0x44, 0xb8, 0xaa, 0xc4, 0x55, 0xff, 0xa2, 0x4, 0x38, - 0x7d, 0x36, 0xe5, 0x62, 0x10, 0xaa, 0x6e, 0xd6, 0xba, 0xc9}; +// REL (PubREL 21231 228 [PropUserProperty "\v" +// "\138\213\v=-\147\SYN8\221%\224\240!S\135JEj\210\203\206\217`\202H\ETB+",PropServerKeepAlive +// 5414,PropWillDelayInterval 17971,PropContentType "\244\a",PropTopicAliasMaximum 17656,PropReceiveMaximum +// 9191,PropRetainAvailable 122,PropUserProperty "h\140\179\254\r\232\172\215&\144\189\146\131\SUB@l\255\138\162" +// "\186/-U)\232\245\&2",PropMessageExpiryInterval 660,PropServerKeepAlive 9579,PropPayloadFormatIndicator +// 187,PropPayloadFormatIndicator 214,PropReasonString "\247b\200g\248y\137!\220k8o\221\&6",PropResponseInformation +// "wkdM/\138\232\SO\199\203\US\180\143Qfof\161\RSv\247\233B\132OM"]) +TEST(PubACKREL5QCTest, Decode7) { + uint8_t pkt[] = {0x62, 0x95, 0x1, 0x52, 0xef, 0xe4, 0x90, 0x1, 0x26, 0x0, 0x1, 0xb, 0x0, 0x1b, 0x8a, 0xd5, 0xb, + 0x3d, 0x2d, 0x93, 0x16, 0x38, 0xdd, 0x25, 0xe0, 0xf0, 0x21, 0x53, 0x87, 0x4a, 0x45, 0x6a, 0xd2, 0xcb, + 0xce, 0xd9, 0x60, 0xca, 0x48, 0x17, 0x2b, 0x13, 0x15, 0x26, 0x18, 0x0, 0x0, 0x46, 0x33, 0x3, 0x0, + 0x2, 0xf4, 0x7, 0x22, 0x44, 0xf8, 0x21, 0x23, 0xe7, 0x25, 0x7a, 0x26, 0x0, 0x13, 0x68, 0x8c, 0xb3, + 0xfe, 0xd, 0xe8, 0xac, 0xd7, 0x26, 0x90, 0xbd, 0x92, 0x83, 0x1a, 0x40, 0x6c, 0xff, 0x8a, 0xa2, 0x0, + 0x8, 0xba, 0x2f, 0x2d, 0x55, 0x29, 0xe8, 0xf5, 0x32, 0x2, 0x0, 0x0, 0x2, 0x94, 0x13, 0x25, 0x6b, + 0x1, 0xbb, 0x1, 0xd6, 0x1f, 0x0, 0xe, 0xf7, 0x62, 0xc8, 0x67, 0xf8, 0x79, 0x89, 0x21, 0xdc, 0x6b, + 0x38, 0x6f, 0xdd, 0x36, 0x1a, 0x0, 0x1a, 0x77, 0x6b, 0x64, 0x4d, 0x2f, 0x8a, 0xe8, 0xe, 0xc7, 0xcb, + 0x1f, 0xb4, 0x8f, 0x51, 0x66, 0x6f, 0x66, 0xa1, 0x1e, 0x76, 0xf7, 0xe9, 0x42, 0x84, 0x4f, 0x4d}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 21231); + EXPECT_EQ(status, 228); +} + +// REL (PubREL 10396 126 [PropWildcardSubscriptionAvailable 80,PropReceiveMaximum 30778,PropSubscriptionIdentifier +// 13,PropRequestProblemInformation 23,PropMaximumQoS 91,PropContentType +// "\164\248\174\155\177\251\SOH\187\SOH*\179Q\132\146\171\201\254\254\187\223\132\226Z\DC3E",PropServerReference +// "\185\163\188DA\253\SOH\224\239\t\199\136\173\219#\229Ty\151\210)",PropTopicAliasMaximum 15956,PropAuthenticationData +// "\SYN\171U\192\141\251\196\b\196\180p\140C\234aH5\228\241~\165F\245\197\169",PropRequestResponseInformation +// 16,PropReasonString +// "\208U?\187\206S_5\129\215V\255\196q\188e\244L\229W\135\184\247\253",PropRequestProblemInformation 233]) +TEST(PubACKREL5QCTest, Encode8) { + uint8_t pkt[] = {0x62, 0x81, 0x1, 0x28, 0x9c, 0x7e, 0x7d, 0x28, 0x50, 0x21, 0x78, 0x3a, 0xb, 0xd, 0x17, 0x17, 0x24, + 0x5b, 0x3, 0x0, 0x19, 0xa4, 0xf8, 0xae, 0x9b, 0xb1, 0xfb, 0x1, 0xbb, 0x1, 0x2a, 0xb3, 0x51, 0x84, + 0x92, 0xab, 0xc9, 0xfe, 0xfe, 0xbb, 0xdf, 0x84, 0xe2, 0x5a, 0x13, 0x45, 0x1c, 0x0, 0x15, 0xb9, 0xa3, + 0xbc, 0x44, 0x41, 0xfd, 0x1, 0xe0, 0xef, 0x9, 0xc7, 0x88, 0xad, 0xdb, 0x23, 0xe5, 0x54, 0x79, 0x97, + 0xd2, 0x29, 0x22, 0x3e, 0x54, 0x16, 0x0, 0x19, 0x16, 0xab, 0x55, 0xc0, 0x8d, 0xfb, 0xc4, 0x8, 0xc4, + 0xb4, 0x70, 0x8c, 0x43, 0xea, 0x61, 0x48, 0x35, 0xe4, 0xf1, 0x7e, 0xa5, 0x46, 0xf5, 0xc5, 0xa9, 0x19, + 0x10, 0x1f, 0x0, 0x18, 0xd0, 0x55, 0x3f, 0xbb, 0xce, 0x53, 0x5f, 0x35, 0x81, 0xd7, 0x56, 0xff, 0xc4, + 0x71, 0xbc, 0x65, 0xf4, 0x4c, 0xe5, 0x57, 0x87, 0xb8, 0xf7, 0xfd, 0x17, 0xe9}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0xa4, 0xf8, 0xae, 0x9b, 0xb1, 0xfb, 0x1, 0xbb, 0x1, 0x2a, 0xb3, 0x51, 0x84, + 0x92, 0xab, 0xc9, 0xfe, 0xfe, 0xbb, 0xdf, 0x84, 0xe2, 0x5a, 0x13, 0x45}; + uint8_t bytesprops1[] = {0xb9, 0xa3, 0xbc, 0x44, 0x41, 0xfd, 0x1, 0xe0, 0xef, 0x9, 0xc7, + 0x88, 0xad, 0xdb, 0x23, 0xe5, 0x54, 0x79, 0x97, 0xd2, 0x29}; + uint8_t bytesprops2[] = {0x16, 0xab, 0x55, 0xc0, 0x8d, 0xfb, 0xc4, 0x8, 0xc4, 0xb4, 0x70, 0x8c, 0x43, + 0xea, 0x61, 0x48, 0x35, 0xe4, 0xf1, 0x7e, 0xa5, 0x46, 0xf5, 0xc5, 0xa9}; + uint8_t bytesprops3[] = {0xd0, 0x55, 0x3f, 0xbb, 0xce, 0x53, 0x5f, 0x35, 0x81, 0xd7, 0x56, 0xff, + 0xc4, 0x71, 0xbc, 0x65, 0xf4, 0x4c, 0xe5, 0x57, 0x87, 0xb8, 0xf7, 0xfd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30778}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15956}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 233}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x83, 0xef, 0x7d, 0xe9, 0xdc}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 10396, 126, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops0}}}, +// REL (PubREL 10396 126 [PropWildcardSubscriptionAvailable 80,PropReceiveMaximum 30778,PropSubscriptionIdentifier +// 13,PropRequestProblemInformation 23,PropMaximumQoS 91,PropContentType +// "\164\248\174\155\177\251\SOH\187\SOH*\179Q\132\146\171\201\254\254\187\223\132\226Z\DC3E",PropServerReference +// "\185\163\188DA\253\SOH\224\239\t\199\136\173\219#\229Ty\151\210)",PropTopicAliasMaximum 15956,PropAuthenticationData +// "\SYN\171U\192\141\251\196\b\196\180p\140C\234aH5\228\241~\165F\245\197\169",PropRequestResponseInformation +// 16,PropReasonString +// "\208U?\187\206S_5\129\215V\255\196q\188e\244L\229W\135\184\247\253",PropRequestProblemInformation 233]) +TEST(PubACKREL5QCTest, Decode8) { + uint8_t pkt[] = {0x62, 0x81, 0x1, 0x28, 0x9c, 0x7e, 0x7d, 0x28, 0x50, 0x21, 0x78, 0x3a, 0xb, 0xd, 0x17, 0x17, 0x24, + 0x5b, 0x3, 0x0, 0x19, 0xa4, 0xf8, 0xae, 0x9b, 0xb1, 0xfb, 0x1, 0xbb, 0x1, 0x2a, 0xb3, 0x51, 0x84, + 0x92, 0xab, 0xc9, 0xfe, 0xfe, 0xbb, 0xdf, 0x84, 0xe2, 0x5a, 0x13, 0x45, 0x1c, 0x0, 0x15, 0xb9, 0xa3, + 0xbc, 0x44, 0x41, 0xfd, 0x1, 0xe0, 0xef, 0x9, 0xc7, 0x88, 0xad, 0xdb, 0x23, 0xe5, 0x54, 0x79, 0x97, + 0xd2, 0x29, 0x22, 0x3e, 0x54, 0x16, 0x0, 0x19, 0x16, 0xab, 0x55, 0xc0, 0x8d, 0xfb, 0xc4, 0x8, 0xc4, + 0xb4, 0x70, 0x8c, 0x43, 0xea, 0x61, 0x48, 0x35, 0xe4, 0xf1, 0x7e, 0xa5, 0x46, 0xf5, 0xc5, 0xa9, 0x19, + 0x10, 0x1f, 0x0, 0x18, 0xd0, 0x55, 0x3f, 0xbb, 0xce, 0x53, 0x5f, 0x35, 0x81, 0xd7, 0x56, 0xff, 0xc4, + 0x71, 0xbc, 0x65, 0xf4, 0x4c, 0xe5, 0x57, 0x87, 0xb8, 0xf7, 0xfd, 0x17, 0xe9}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 10396); + EXPECT_EQ(status, 126); +} + +// ACK (PubACK 26705 173 [PropMessageExpiryInterval 20244,PropMessageExpiryInterval 16583,PropTopicAliasMaximum 21731]) +TEST(PubACKACK5QCTest, Encode9) { + uint8_t pkt[] = {0x40, 0x11, 0x68, 0x51, 0xad, 0xd, 0x2, 0x0, 0x0, 0x4f, + 0x14, 0x2, 0x0, 0x0, 0x40, 0xc7, 0x22, 0x54, 0xe3}; + uint8_t buf[sizeof(pkt) + 10]; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20244}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16583}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21731}}, }; - lwmqtt_properties_t willprops = {1, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa7, 0xba, 0x2c, 0xe1, 0xe7, 0xa, 0xe5, 0x52, 0x53, 0x9e, 0x6e, 0x4, 0x9d, - 0x70, 0x58, 0xf, 0x86, 0xfe, 0xbb, 0x35, 0xb2, 0x5b, 0xeb, 0xd7, 0x8d}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xb7, 0x7e}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 4897; - uint8_t client_id_bytes[] = {0xd7, 0x45, 0x53, 0x29, 0xd5, 0x22, 0x1e, 0x95, 0xa5, 0xa7, 0xfc, 0xd8, 0x5f, 0xa6}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 26705, 173, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\179\171\192\219e27\202\244Y\238\&9\151", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = "\221\239\USQ\"", _willMsg = "", _willProps = -// [PropResponseInformation "",PropMessageExpiryInterval 22718,PropMessageExpiryInterval 30489,PropServerReference -// "\SOH9\SI\231n\192\&0\131\174(K\137G\157..\".)\r\200",PropAuthenticationData -// "\SI\153\128\245\140\187\fq\157\195\155\ETX",PropContentType -// "\232\163\189\148d\GS\190\DC2\223\245\164\a\153",PropSubscriptionIdentifier 26,PropWildcardSubscriptionAvailable -// 103,PropAssignedClientIdentifier "\161v\133c",PropWildcardSubscriptionAvailable 179,PropTopicAlias -// 28960,PropSessionExpiryInterval 4948,PropReasonString -// "(\ETX\234\205Th\243\249\210\244\148\&2\DC3\204^\236S\222\245\EM2W",PropReasonString -// "\EMO\240\STX;\DC2\n\214\158!\216\156d\236G\226",PropMaximumQoS 112,PropMaximumQoS 191,PropRetainAvailable -// 33,PropUserProperty "\SO}\GSW\RS,\137t\152\DC2\249wQ" -// "\148\209\242\207\218\&2\128?\DLEa\184\191\141L\225.\183f\155U\DC4\135(",PropMessageExpiryInterval -// 31362,PropWillDelayInterval 19268,PropResponseInformation -// "\179\230\206\&9\227n#!\178@\v\200oj\192\155LU\170\141\161c\202k",PropMaximumQoS 128]} -TEST(Connect5QCTest, Encode9) { - uint8_t pkt[] = { - 0x10, 0xbb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x54, 0x6e, 0x56, 0x9d, 0x1, 0x1a, 0x0, 0x2, 0x69, - 0xa0, 0x8, 0x0, 0x15, 0x59, 0xfe, 0xc3, 0x6a, 0xf3, 0xa2, 0x2a, 0xf0, 0x8d, 0xe5, 0x40, 0xa8, 0xd2, 0xbd, 0xbf, - 0x79, 0xa0, 0xe4, 0xaa, 0xdd, 0xd5, 0x11, 0x0, 0x0, 0xa, 0xdd, 0x16, 0x0, 0x1c, 0xf, 0x5e, 0x7e, 0x20, 0xf9, - 0x85, 0xed, 0x63, 0xc5, 0xdf, 0x87, 0xaa, 0xb6, 0xc5, 0x7a, 0x73, 0x8e, 0x42, 0x57, 0xcb, 0x42, 0xf4, 0x83, 0x8c, - 0x4, 0xde, 0x6d, 0x47, 0x2a, 0x45, 0x1f, 0x0, 0xc, 0x8, 0xa, 0x53, 0x90, 0x9, 0x93, 0xa2, 0x79, 0xf5, 0x7b, - 0x87, 0x53, 0x25, 0xda, 0x2, 0x0, 0x0, 0xe, 0xf2, 0x22, 0x51, 0x98, 0x15, 0x0, 0xd, 0xcb, 0xdc, 0xc5, 0x15, - 0x46, 0x77, 0xcc, 0x61, 0x92, 0x1c, 0x9e, 0x49, 0x3a, 0x11, 0x0, 0x0, 0x5f, 0x15, 0x26, 0x0, 0x7, 0xa2, 0x4a, - 0xf7, 0x34, 0x30, 0x70, 0xaf, 0x0, 0xe, 0x71, 0xa1, 0x55, 0x53, 0xf, 0x78, 0x57, 0xdd, 0xa3, 0x98, 0x2d, 0x68, - 0x77, 0x94, 0x1c, 0x0, 0xd, 0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7d, 0x1d, 0x57, 0x1e, 0x2c, 0x89, 0x74, 0x98, 0x12, 0xf9, 0x77, 0x51, 0x0, 0x17, 0x94, 0xd1, - 0xf2, 0xcf, 0xda, 0x32, 0x80, 0x3f, 0x10, 0x61, 0xb8, 0xbf, 0x8d, 0x4c, 0xe1, 0x2e, 0xb7, 0x66, 0x9b, 0x55, 0x14, - 0x87, 0x28, 0x2, 0x0, 0x0, 0x7a, 0x82, 0x18, 0x0, 0x0, 0x4b, 0x44, 0x1a, 0x0, 0x1b, 0xb3, 0xe6, 0xce, 0x39, - 0xe3, 0x6e, 0x23, 0x21, 0xb2, 0x40, 0xb, 0xc8, 0x6f, 0x6a, 0xc0, 0x9b, 0x4c, 0x55, 0xaa, 0x8d, 0xa1, 0x63, 0xca, - 0x3c, 0x75, 0x82, 0xf5, 0x0, 0x5, 0xdd, 0xef, 0x1f, 0x51, 0x22, 0x0, 0x0, 0x0, 0xd, 0xb3, 0xab, 0xc0, 0xdb, - 0x65, 0x32, 0x37, 0xca, 0xf4, 0x59, 0xee, 0x39, 0x97}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x69, 0xa0}; - uint8_t bytesprops1[] = {0x59, 0xfe, 0xc3, 0x6a, 0xf3, 0xa2, 0x2a, 0xf0, 0x8d, 0xe5, 0x40, - 0xa8, 0xd2, 0xbd, 0xbf, 0x79, 0xa0, 0xe4, 0xaa, 0xdd, 0xd5}; - uint8_t bytesprops2[] = {0xf, 0x5e, 0x7e, 0x20, 0xf9, 0x85, 0xed, 0x63, 0xc5, 0xdf, 0x87, 0xaa, 0xb6, 0xc5, - 0x7a, 0x73, 0x8e, 0x42, 0x57, 0xcb, 0x42, 0xf4, 0x83, 0x8c, 0x4, 0xde, 0x6d, 0x47}; - uint8_t bytesprops3[] = {0x8, 0xa, 0x53, 0x90, 0x9, 0x93, 0xa2, 0x79, 0xf5, 0x7b, 0x87, 0x53}; - uint8_t bytesprops4[] = {0xcb, 0xdc, 0xc5, 0x15, 0x46, 0x77, 0xcc, 0x61, 0x92, 0x1c, 0x9e, 0x49, 0x3a}; - uint8_t bytesprops6[] = {0x71, 0xa1, 0x55, 0x53, 0xf, 0x78, 0x57, 0xdd, 0xa3, 0x98, 0x2d, 0x68, 0x77, 0x94}; - uint8_t bytesprops5[] = {0xa2, 0x4a, 0xf7, 0x34, 0x30, 0x70, 0xaf}; - uint8_t bytesprops7[] = {0xa9, 0x8b, 0x67, 0xae, 0x7c, 0x90, 0x5e, 0x23, 0xd5, 0xf2, 0x50, 0x3e, 0x6b}; +// ACK (PubACK 26705 173 [PropMessageExpiryInterval 20244,PropMessageExpiryInterval 16583,PropTopicAliasMaximum 21731]) +TEST(PubACKACK5QCTest, Decode9) { + uint8_t pkt[] = {0x40, 0x11, 0x68, 0x51, 0xad, 0xd, 0x2, 0x0, 0x0, 0x4f, + 0x14, 0x2, 0x0, 0x0, 0x40, 0xc7, 0x22, 0x54, 0xe3}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 26705); + EXPECT_EQ(status, 173); +} + +// ACK (PubACK 17554 3 [PropResponseTopic "\236\&7c\190\212%\SI\177\208\201e\220)\251",PropAssignedClientIdentifier +// "\EOTU\155\252e\156\155l\EM\214t\192\170\184_\213\207\SI\SUB\243\152\253\151\FS\210\244\193\235\SYN-",PropMessageExpiryInterval +// 742,PropTopicAliasMaximum 3228,PropServerKeepAlive 28550,PropServerKeepAlive 4076]) +TEST(PubACKACK5QCTest, Encode10) { + uint8_t pkt[] = {0x40, 0x44, 0x44, 0x92, 0x3, 0x40, 0x8, 0x0, 0xe, 0xec, 0x37, 0x63, 0xbe, 0xd4, + 0x25, 0xf, 0xb1, 0xd0, 0xc9, 0x65, 0xdc, 0x29, 0xfb, 0x12, 0x0, 0x1e, 0x4, 0x55, + 0x9b, 0xfc, 0x65, 0x9c, 0x9b, 0x6c, 0x19, 0xd6, 0x74, 0xc0, 0xaa, 0xb8, 0x5f, 0xd5, + 0xcf, 0xf, 0x1a, 0xf3, 0x98, 0xfd, 0x97, 0x1c, 0xd2, 0xf4, 0xc1, 0xeb, 0x16, 0x2d, + 0x2, 0x0, 0x0, 0x2, 0xe6, 0x22, 0xc, 0x9c, 0x13, 0x6f, 0x86, 0x13, 0xf, 0xec}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0xec, 0x37, 0x63, 0xbe, 0xd4, 0x25, 0xf, 0xb1, 0xd0, 0xc9, 0x65, 0xdc, 0x29, 0xfb}; + uint8_t bytesprops1[] = {0x4, 0x55, 0x9b, 0xfc, 0x65, 0x9c, 0x9b, 0x6c, 0x19, 0xd6, 0x74, 0xc0, 0xaa, 0xb8, 0x5f, + 0xd5, 0xcf, 0xf, 0x1a, 0xf3, 0x98, 0xfd, 0x97, 0x1c, 0xd2, 0xf4, 0xc1, 0xeb, 0x16, 0x2d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2781}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3826}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20888}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24341}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops5}, .v = {14, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, - }; - - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0}; - uint8_t byteswillprops1[] = {0x1, 0x39, 0xf, 0xe7, 0x6e, 0xc0, 0x30, 0x83, 0xae, 0x28, 0x4b, - 0x89, 0x47, 0x9d, 0x2e, 0x2e, 0x22, 0x2e, 0x29, 0xd, 0xc8}; - uint8_t byteswillprops2[] = {0xf, 0x99, 0x80, 0xf5, 0x8c, 0xbb, 0xc, 0x71, 0x9d, 0xc3, 0x9b, 0x3}; - uint8_t byteswillprops3[] = {0xe8, 0xa3, 0xbd, 0x94, 0x64, 0x1d, 0xbe, 0x12, 0xdf, 0xf5, 0xa4, 0x7, 0x99}; - uint8_t byteswillprops4[] = {0xa1, 0x76, 0x85, 0x63}; - uint8_t byteswillprops5[] = {0x28, 0x3, 0xea, 0xcd, 0x54, 0x68, 0xf3, 0xf9, 0xd2, 0xf4, 0x94, - 0x32, 0x13, 0xcc, 0x5e, 0xec, 0x53, 0xde, 0xf5, 0x19, 0x32, 0x57}; - uint8_t byteswillprops6[] = {0x19, 0x4f, 0xf0, 0x2, 0x3b, 0x12, 0xa, 0xd6, - 0x9e, 0x21, 0xd8, 0x9c, 0x64, 0xec, 0x47, 0xe2}; - uint8_t byteswillprops8[] = {0x94, 0xd1, 0xf2, 0xcf, 0xda, 0x32, 0x80, 0x3f, 0x10, 0x61, 0xb8, 0xbf, - 0x8d, 0x4c, 0xe1, 0x2e, 0xb7, 0x66, 0x9b, 0x55, 0x14, 0x87, 0x28}; - uint8_t byteswillprops7[] = {0xe, 0x7d, 0x1d, 0x57, 0x1e, 0x2c, 0x89, 0x74, 0x98, 0x12, 0xf9, 0x77, 0x51}; - uint8_t byteswillprops9[] = {0xb3, 0xe6, 0xce, 0x39, 0xe3, 0x6e, 0x23, 0x21, 0xb2, 0x40, 0xb, 0xc8, 0x6f, 0x6a, - 0xc0, 0x9b, 0x4c, 0x55, 0xaa, 0x8d, 0xa1, 0x63, 0xca, 0x3c, 0x75, 0x82, 0xf5}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22718}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30489}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28960}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4948}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {13, (char*)&byteswillprops7}, .v = {23, (char*)&byteswillprops8}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31362}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19268}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 742}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3228}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28550}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4076}}, }; - lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xdd, 0xef, 0x1f, 0x51, 0x22}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 28246; - uint8_t client_id_bytes[] = {0x36, 0x53, 0x8a, 0xcd, 0xdd, 0xdc, 0x6c, 0x6d, 0xf2, 0x5f, 0x78, 0x36, 0xe6, - 0xc0, 0x14, 0xdb, 0x86, 0x75, 0x14, 0x30, 0xbf, 0x74, 0x50, 0x5e, 0xd4, 0xf7}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t password_bytes[] = {0xb3, 0xab, 0xc0, 0xdb, 0x65, 0x32, 0x37, 0xca, 0xf4, 0x59, 0xee, 0x39, 0x97}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 17554, 3, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "a\240\130l{", _password = Just -// "\139\168iv\184\216p\167\249\142\150\188G^'\235a\GS", _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = -// "\DC4\144\178\229\CAN\160\DC2\233\SI\160\DC1G\219\173\175\r\161\&3\250\246\200\250\r\199J\154\165\195\221\237", -// _willMsg = " \207(\FS?\175Cq\NUL\154(\203(\186\197\156`\189O\255\195\169\153\RS\226\b`h", _willProps = -// [PropCorrelationData -// "\236\178\197~\STX\NULy\189\224\b*\v\238\151\152\203\DC4H~\189\189J\168\202\234\223\132\168",PropReceiveMaximum -// 30115,PropTopicAlias 12374,PropResponseTopic "o\232",PropWillDelayInterval 27982,PropServerKeepAlive -// 23541,PropRetainAvailable 187,PropMessageExpiryInterval 22446,PropServerReference -// "\177\183\219\223\162E\151EIW\226/\154\128s)\187\242"]}), _cleanSession = True, _keepAlive = 13826, _connID = "", -// _properties = [PropRequestResponseInformation 160,PropMaximumPacketSize 26751,PropAuthenticationMethod -// "Z\t",PropPayloadFormatIndicator 71,PropContentType "\RSC\154\FS;\DC2",PropRequestResponseInformation -// 197,PropRequestProblemInformation 183,PropSubscriptionIdentifierAvailable 243,PropMessageExpiryInterval -// 18872,PropRetainAvailable 244,PropMaximumPacketSize 13684,PropCorrelationData -// "\204\STX\236q,\211'\138P\161S\136+\163\SI\240x\DC2\131\129\210",PropResponseTopic -// "$\142\152\245\&6\ENQ\163\238\179\"O\162\215*\251\177\&3\ACK\231\149",PropRequestProblemInformation -// 163,PropWillDelayInterval 24681,PropSessionExpiryInterval 31574,PropReasonString -// "\ETB\216*p\rd\248*dIe\154(\166\194\222\205\206\222\215",PropContentType -// ",#\227\179\151+{",PropSharedSubscriptionAvailable 219,PropAuthenticationMethod -// "\139N\EM\180\186x\145\131`l2h)\201\155\152\177\144\FSC\223\238\154\237\&6dRu4\170",PropUserProperty -// "\237_\195\211\163\204P2f\162\DLE\177a\DC2\US\n\131`\196\203a\214\169\DC2\164k",PropAssignedClientIdentifier -// "\241?\174A\148\194\220\207\b\232o'\191f\196g\202&\241\181]\NUL8\139X\180\229\167\&6\212",PropSubscriptionIdentifier -// 0]}), _cleanSession = True, _keepAlive = 7077, _connID = "\166\&2\183R\234\EM*\227 \nz\SYN\ENQ", _properties = -// [PropSubscriptionIdentifierAvailable 184,PropSessionExpiryInterval 30559,PropSubscriptionIdentifier -// 25,PropUserProperty "\v\DC3T\175R\161\245\244" "",PropMessageExpiryInterval 9738,PropPayloadFormatIndicator -// 210,PropSharedSubscriptionAvailable 42,PropSharedSubscriptionAvailable 253,PropTopicAlias 4943,PropResponseTopic -// "gY\132",PropTopicAlias 8971,PropAuthenticationMethod -// "\161a\230q\SYN\ACK\204\168P\EOT\165\USz\203\228\227\240\DC3\141n\211Vu{\243\201,\NULE\161",PropTopicAlias -// 11926,PropAssignedClientIdentifier "\NAK\223",PropAuthenticationMethod -// "\158\171\141\228\145\225(\133d\194\&9\186\209\ENQ",PropSharedSubscriptionAvailable 39,PropMaximumQoS -// 223,PropUserProperty "\227\178\161\167\232\149\174>\STX\233\SO\156\ACKD\190&Iq\168\191" -// "\160\151\239|Fq\216\129\&8\250N\130T\152\167\ETB\246\b\178\130\RS[W\132",PropMaximumPacketSize -// 12119,PropMessageExpiryInterval 11980,PropReasonString -// "\187\156\155\226\ENQ(ym\234\DLE1i\234\SO\171c\207p",PropTopicAlias 15565,PropSessionExpiryInterval -// 19627,PropSubscriptionIdentifierAvailable 9,PropMaximumPacketSize 1238]} -TEST(Connect5QCTest, Encode13) { - uint8_t pkt[] = { - 0x10, 0x89, 0x3, 0x0, 0x4, 0x4d,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b, 0xa6, 0x5b, 0x18, 0xa0, 0x75, 0x92, 0x26, 0x5, 0x2a, 0x11, 0x74, 0x4e, 0x3f, 0x68}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops0[] = {0xb, 0x13, 0x54, 0xaf, 0x52, 0xa1, 0xf5, 0xf4}; - uint8_t bytesprops2[] = {0x67, 0x59, 0x84}; - uint8_t bytesprops3[] = {0xa1, 0x61, 0xe6, 0x71, 0x16, 0x6, 0xcc, 0xa8, 0x50, 0x4, 0xa5, 0x1f, 0x7a, 0xcb, 0xe4, - 0xe3, 0xf0, 0x13, 0x8d, 0x6e, 0xd3, 0x56, 0x75, 0x7b, 0xf3, 0xc9, 0x2c, 0x0, 0x45, 0xa1}; - uint8_t bytesprops4[] = {0x15, 0xdf}; - uint8_t bytesprops5[] = {0x9e, 0xab, 0x8d, 0xe4, 0x91, 0xe1, 0x28, 0x85, 0x64, 0xc2, 0x39, 0xba, 0xd1, 0x5}; - uint8_t bytesprops7[] = {0xa0, 0x97, 0xef, 0x7c, 0x46, 0x71, 0xd8, 0x81, 0x38, 0xfa, 0x4e, 0x82, - 0x54, 0x98, 0xa7, 0x17, 0xf6, 0x8, 0xb2, 0x82, 0x1e, 0x5b, 0x57, 0x84}; - uint8_t bytesprops6[] = {0xe3, 0xb2, 0xa1, 0xa7, 0xe8, 0x95, 0xae, 0x3e, 0x2, 0xe9, - 0xe, 0x9c, 0x6, 0x44, 0xbe, 0x26, 0x49, 0x71, 0xa8, 0xbf}; - uint8_t bytesprops8[] = {0xbb, 0x9c, 0x9b, 0xe2, 0x5, 0x28, 0x79, 0x6d, 0xea, - 0x10, 0x31, 0x69, 0xea, 0xe, 0xab, 0x63, 0xcf, 0x70}; +// ACK (PubACK 18661 48 [PropResponseInformation "\208W1\a\216]\131\236U\r\219",PropMessageExpiryInterval +// 16564,PropMessageExpiryInterval 3562,PropWillDelayInterval 4868,PropSubscriptionIdentifier 27,PropTopicAlias 12787]) +TEST(PubACKACK5QCTest, Decode14) { + uint8_t pkt[] = {0x40, 0x26, 0x48, 0xe5, 0x30, 0x22, 0x1a, 0x0, 0xb, 0xd0, 0x57, 0x31, 0x7, 0xd8, + 0x5d, 0x83, 0xec, 0x55, 0xd, 0xdb, 0x2, 0x0, 0x0, 0x40, 0xb4, 0x2, 0x0, 0x0, + 0xd, 0xea, 0x18, 0x0, 0x0, 0x13, 0x4, 0xb, 0x1b, 0x23, 0x31, 0xf3}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 18661); + EXPECT_EQ(status, 48); +} + +// REC (PubREC 32292 34 [PropSessionExpiryInterval 19966,PropSessionExpiryInterval 16597,PropServerKeepAlive +// 16525,PropUserProperty "\214d\189\196\EM\163\224\198D\205\176\DLE\\\220\166\149\162(\176" +// "\DEL\b\216\138Y^.\SOH<\242",PropResponseInformation +// "\193\&6\208]\239\211A\188G\226\152\GS\162{&\221",PropTopicAliasMaximum 5330,PropPayloadFormatIndicator +// 244,PropAssignedClientIdentifier +// "\207\207\180\230uB\228<\208\162I\246\152\169Y\tTB!HQ\ENQ\191\191bP\n\237y\145",PropRequestProblemInformation +// 72,PropWildcardSubscriptionAvailable 53,PropUserProperty "\239#1\142\242\&5\237\173\254\ACK\r\226\137`e~\232" +// "W\SUB",PropReasonString "\214",PropContentType "\159\193+Gt\153|\210\133\218",PropSharedSubscriptionAvailable +// 17,PropSubscriptionIdentifier 6,PropAuthenticationData +// "j\192g\216\&1\208\158\152\238\176\218\164w",PropRetainAvailable 251,PropServerReference +// "\SUB\247\226\ETBpb\255\235_\EM\133\145\198kA\192\188\&5\217\213X\130\170/\208-mv\205",PropWillDelayInterval +// 6096,PropTopicAliasMaximum 27681]) +TEST(PubACKREC5QCTest, Encode15) { + uint8_t pkt[] = {0x50, 0xd8, 0x1, 0x7e, 0x24, 0x22, 0xd3, 0x1, 0x11, 0x0, 0x0, 0x4d, 0xfe, 0x11, 0x0, 0x0, 0x40, + 0xd5, 0x13, 0x40, 0x8d, 0x26, 0x0, 0x13, 0xd6, 0x64, 0xbd, 0xc4, 0x19, 0xa3, 0xe0, 0xc6, 0x44, 0xcd, + 0xb0, 0x10, 0x5c, 0xdc, 0xa6, 0x95, 0xa2, 0x28, 0xb0, 0x0, 0xa, 0x7f, 0x8, 0xd8, 0x8a, 0x59, 0x5e, + 0x2e, 0x1, 0x3c, 0xf2, 0x1a, 0x0, 0x10, 0xc1, 0x36, 0xd0, 0x5d, 0xef, 0xd3, 0x41, 0xbc, 0x47, 0xe2, + 0x98, 0x1d, 0xa2, 0x7b, 0x26, 0xdd, 0x22, 0x14, 0xd2, 0x1, 0xf4, 0x12, 0x0, 0x1e, 0xcf, 0xcf, 0xb4, + 0xe6, 0x75, 0x42, 0xe4, 0x3c, 0xd0, 0xa2, 0x49, 0xf6, 0x98, 0xa9, 0x59, 0x9, 0x54, 0x42, 0x21, 0x48, + 0x51, 0x5, 0xbf, 0xbf, 0x62, 0x50, 0xa, 0xed, 0x79, 0x91, 0x17, 0x48, 0x28, 0x35, 0x26, 0x0, 0x11, + 0xef, 0x23, 0x31, 0x8e, 0xf2, 0x35, 0xed, 0xad, 0xfe, 0x6, 0xd, 0xe2, 0x89, 0x60, 0x65, 0x7e, 0xe8, + 0x0, 0x2, 0x57, 0x1a, 0x1f, 0x0, 0x1, 0xd6, 0x3, 0x0, 0xa, 0x9f, 0xc1, 0x2b, 0x47, 0x74, 0x99, + 0x7c, 0xd2, 0x85, 0xda, 0x2a, 0x11, 0xb, 0x6, 0x16, 0x0, 0xd, 0x6a, 0xc0, 0x67, 0xd8, 0x31, 0xd0, + 0x9e, 0x98, 0xee, 0xb0, 0xda, 0xa4, 0x77, 0x25, 0xfb, 0x1c, 0x0, 0x1d, 0x1a, 0xf7, 0xe2, 0x17, 0x70, + 0x62, 0xff, 0xeb, 0x5f, 0x19, 0x85, 0x91, 0xc6, 0x6b, 0x41, 0xc0, 0xbc, 0x35, 0xd9, 0xd5, 0x58, 0x82, + 0xaa, 0x2f, 0xd0, 0x2d, 0x6d, 0x76, 0xcd, 0x18, 0x0, 0x0, 0x17, 0xd0, 0x22, 0x6c, 0x21}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops1[] = {0x7f, 0x8, 0xd8, 0x8a, 0x59, 0x5e, 0x2e, 0x1, 0x3c, 0xf2}; + uint8_t bytesprops0[] = {0xd6, 0x64, 0xbd, 0xc4, 0x19, 0xa3, 0xe0, 0xc6, 0x44, 0xcd, + 0xb0, 0x10, 0x5c, 0xdc, 0xa6, 0x95, 0xa2, 0x28, 0xb0}; + uint8_t bytesprops2[] = {0xc1, 0x36, 0xd0, 0x5d, 0xef, 0xd3, 0x41, 0xbc, + 0x47, 0xe2, 0x98, 0x1d, 0xa2, 0x7b, 0x26, 0xdd}; + uint8_t bytesprops3[] = {0xcf, 0xcf, 0xb4, 0xe6, 0x75, 0x42, 0xe4, 0x3c, 0xd0, 0xa2, 0x49, 0xf6, 0x98, 0xa9, 0x59, + 0x9, 0x54, 0x42, 0x21, 0x48, 0x51, 0x5, 0xbf, 0xbf, 0x62, 0x50, 0xa, 0xed, 0x79, 0x91}; + uint8_t bytesprops5[] = {0x57, 0x1a}; + uint8_t bytesprops4[] = {0xef, 0x23, 0x31, 0x8e, 0xf2, 0x35, 0xed, 0xad, 0xfe, + 0x6, 0xd, 0xe2, 0x89, 0x60, 0x65, 0x7e, 0xe8}; + uint8_t bytesprops6[] = {0xd6}; + uint8_t bytesprops7[] = {0x9f, 0xc1, 0x2b, 0x47, 0x74, 0x99, 0x7c, 0xd2, 0x85, 0xda}; + uint8_t bytesprops8[] = {0x6a, 0xc0, 0x67, 0xd8, 0x31, 0xd0, 0x9e, 0x98, 0xee, 0xb0, 0xda, 0xa4, 0x77}; + uint8_t bytesprops9[] = {0x1a, 0xf7, 0xe2, 0x17, 0x70, 0x62, 0xff, 0xeb, 0x5f, 0x19, 0x85, 0x91, 0xc6, 0x6b, 0x41, + 0xc0, 0xbc, 0x35, 0xd9, 0xd5, 0x58, 0x82, 0xaa, 0x2f, 0xd0, 0x2d, 0x6d, 0x76, 0xcd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30559}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9738}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4943}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8971}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11926}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops6}, .v = {24, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12119}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11980}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15565}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19627}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1238}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19966}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16597}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16525}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5330}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6096}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27681}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xf0, 0xa6, 0xf7, 0xdf, 0x7c, 0x23, 0xc1, 0xc1, 0xb2, - 0xc1, 0x61, 0x8a, 0xb7, 0xe4, 0x7c, 0xa2, 0x3d, 0x80}; - uint8_t byteswillprops1[] = {0xf4, 0xf2, 0x3e, 0x61, 0x12, 0x1f, 0xa, 0x83, 0x60, - 0xc4, 0xcb, 0x61, 0xd6, 0xa9, 0x12, 0xa4, 0x6b}; - uint8_t byteswillprops2[] = {0xf1, 0x3f, 0xae, 0x41, 0x94, 0xc2, 0xdc, 0xcf, 0x8, 0xe8, - 0x6f, 0x27, 0xbf, 0x66, 0xc4, 0x67, 0xca, 0x26, 0xf1, 0xb5, - 0x5d, 0x0, 0x38, 0x8b, 0x58, 0xb4, 0xe5, 0xa7, 0x36, 0xd4}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, 0, 32292, 34, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13107}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12452}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30328}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21462}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, - }; +// REC (PubREC 32292 34 [PropSessionExpiryInterval 19966,PropSessionExpiryInterval 16597,PropServerKeepAlive +// 16525,PropUserProperty "\214d\189\196\EM\163\224\198D\205\176\DLE\\\220\166\149\162(\176" +// "\DEL\b\216\138Y^.\SOH<\242",PropResponseInformation +// "\193\&6\208]\239\211A\188G\226\152\GS\162{&\221",PropTopicAliasMaximum 5330,PropPayloadFormatIndicator +// 244,PropAssignedClientIdentifier +// "\207\207\180\230uB\228<\208\162I\246\152\169Y\tTB!HQ\ENQ\191\191bP\n\237y\145",PropRequestProblemInformation +// 72,PropWildcardSubscriptionAvailable 53,PropUserProperty "\239#1\142\242\&5\237\173\254\ACK\r\226\137`e~\232" +// "W\SUB",PropReasonString "\214",PropContentType "\159\193+Gt\153|\210\133\218",PropSharedSubscriptionAvailable +// 17,PropSubscriptionIdentifier 6,PropAuthenticationData +// "j\192g\216\&1\208\158\152\238\176\218\164w",PropRetainAvailable 251,PropServerReference +// "\SUB\247\226\ETBpb\255\235_\EM\133\145\198kA\192\188\&5\217\213X\130\170/\208-mv\205",PropWillDelayInterval +// 6096,PropTopicAliasMaximum 27681]) +TEST(PubACKREC5QCTest, Decode15) { + uint8_t pkt[] = {0x50, 0xd8, 0x1, 0x7e, 0x24, 0x22, 0xd3, 0x1, 0x11, 0x0, 0x0, 0x4d, 0xfe, 0x11, 0x0, 0x0, 0x40, + 0xd5, 0x13, 0x40, 0x8d, 0x26, 0x0, 0x13, 0xd6, 0x64, 0xbd, 0xc4, 0x19, 0xa3, 0xe0, 0xc6, 0x44, 0xcd, + 0xb0, 0x10, 0x5c, 0xdc, 0xa6, 0x95, 0xa2, 0x28, 0xb0, 0x0, 0xa, 0x7f, 0x8, 0xd8, 0x8a, 0x59, 0x5e, + 0x2e, 0x1, 0x3c, 0xf2, 0x1a, 0x0, 0x10, 0xc1, 0x36, 0xd0, 0x5d, 0xef, 0xd3, 0x41, 0xbc, 0x47, 0xe2, + 0x98, 0x1d, 0xa2, 0x7b, 0x26, 0xdd, 0x22, 0x14, 0xd2, 0x1, 0xf4, 0x12, 0x0, 0x1e, 0xcf, 0xcf, 0xb4, + 0xe6, 0x75, 0x42, 0xe4, 0x3c, 0xd0, 0xa2, 0x49, 0xf6, 0x98, 0xa9, 0x59, 0x9, 0x54, 0x42, 0x21, 0x48, + 0x51, 0x5, 0xbf, 0xbf, 0x62, 0x50, 0xa, 0xed, 0x79, 0x91, 0x17, 0x48, 0x28, 0x35, 0x26, 0x0, 0x11, + 0xef, 0x23, 0x31, 0x8e, 0xf2, 0x35, 0xed, 0xad, 0xfe, 0x6, 0xd, 0xe2, 0x89, 0x60, 0x65, 0x7e, 0xe8, + 0x0, 0x2, 0x57, 0x1a, 0x1f, 0x0, 0x1, 0xd6, 0x3, 0x0, 0xa, 0x9f, 0xc1, 0x2b, 0x47, 0x74, 0x99, + 0x7c, 0xd2, 0x85, 0xda, 0x2a, 0x11, 0xb, 0x6, 0x16, 0x0, 0xd, 0x6a, 0xc0, 0x67, 0xd8, 0x31, 0xd0, + 0x9e, 0x98, 0xee, 0xb0, 0xda, 0xa4, 0x77, 0x25, 0xfb, 0x1c, 0x0, 0x1d, 0x1a, 0xf7, 0xe2, 0x17, 0x70, + 0x62, 0xff, 0xeb, 0x5f, 0x19, 0x85, 0x91, 0xc6, 0x6b, 0x41, 0xc0, 0xbc, 0x35, 0xd9, 0xd5, 0x58, 0x82, + 0xaa, 0x2f, 0xd0, 0x2d, 0x6d, 0x76, 0xcd, 0x18, 0x0, 0x0, 0x17, 0xd0, 0x22, 0x6c, 0x21}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 32292); + EXPECT_EQ(status, 34); +} + +// ACK (PubACK 11679 6 [PropAssignedClientIdentifier +// "\220\SO\167\167t\180\223\201\n^<\b\r\221\ETX\226\212\RS",PropResponseTopic "\168\SOf",PropMessageExpiryInterval +// 14878,PropRequestResponseInformation 5,PropWillDelayInterval 14209,PropReceiveMaximum 10194,PropSessionExpiryInterval +// 3797,PropResponseInformation "Xc",PropReceiveMaximum 3172,PropRetainAvailable 121,PropRetainAvailable +// 176,PropAssignedClientIdentifier +// "1\211sTO3q\SOH\230\r\142\172\SUB\193\176\133X\135\132\130\246\CAN\153\217\251",PropServerReference +// "-\SOH\140EEI<\184",PropCorrelationData +// "\146\205&\252\217\144|\DC1\151\218O\NUL,\RS\200\218\174\144\DEL\251\247$Z\239T'"]) +TEST(PubACKACK5QCTest, Encode16) { + uint8_t pkt[] = {0x40, 0x83, 0x1, 0x2d, 0x9f, 0x6, 0x7f, 0x12, 0x0, 0x12, 0xdc, 0xe, 0xa7, 0xa7, 0x74, 0xb4, 0xdf, + 0xc9, 0xa, 0x5e, 0x3c, 0x8, 0xd, 0xdd, 0x3, 0xe2, 0xd4, 0x1e, 0x8, 0x0, 0x3, 0xa8, 0xe, 0x66, + 0x2, 0x0, 0x0, 0x3a, 0x1e, 0x19, 0x5, 0x18, 0x0, 0x0, 0x37, 0x81, 0x21, 0x27, 0xd2, 0x11, 0x0, + 0x0, 0xe, 0xd5, 0x1a, 0x0, 0x2, 0x58, 0x63, 0x21, 0xc, 0x64, 0x25, 0x79, 0x25, 0xb0, 0x12, 0x0, + 0x19, 0x31, 0xd3, 0x73, 0x54, 0x4f, 0x33, 0x71, 0x1, 0xe6, 0xd, 0x8e, 0xac, 0x1a, 0xc1, 0xb0, 0x85, + 0x58, 0x87, 0x84, 0x82, 0xf6, 0x18, 0x99, 0xd9, 0xfb, 0x1c, 0x0, 0x8, 0x2d, 0x1, 0x8c, 0x45, 0x45, + 0x49, 0x3c, 0xb8, 0x9, 0x0, 0x1a, 0x92, 0xcd, 0x26, 0xfc, 0xd9, 0x90, 0x7c, 0x11, 0x97, 0xda, 0x4f, + 0x0, 0x2c, 0x1e, 0xc8, 0xda, 0xae, 0x90, 0x7f, 0xfb, 0xf7, 0x24, 0x5a, 0xef, 0x54, 0x27}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0xdc, 0xe, 0xa7, 0xa7, 0x74, 0xb4, 0xdf, 0xc9, 0xa, + 0x5e, 0x3c, 0x8, 0xd, 0xdd, 0x3, 0xe2, 0xd4, 0x1e}; + uint8_t bytesprops1[] = {0xa8, 0xe, 0x66}; + uint8_t bytesprops2[] = {0x58, 0x63}; + uint8_t bytesprops3[] = {0x31, 0xd3, 0x73, 0x54, 0x4f, 0x33, 0x71, 0x1, 0xe6, 0xd, 0x8e, 0xac, 0x1a, + 0xc1, 0xb0, 0x85, 0x58, 0x87, 0x84, 0x82, 0xf6, 0x18, 0x99, 0xd9, 0xfb}; + uint8_t bytesprops4[] = {0x2d, 0x1, 0x8c, 0x45, 0x45, 0x49, 0x3c, 0xb8}; + uint8_t bytesprops5[] = {0x92, 0xcd, 0x26, 0xfc, 0xd9, 0x90, 0x7c, 0x11, 0x97, 0xda, 0x4f, 0x0, 0x2c, + 0x1e, 0xc8, 0xda, 0xae, 0x90, 0x7f, 0xfb, 0xf7, 0x24, 0x5a, 0xef, 0x54, 0x27}; - lwmqtt_properties_t willprops = {11, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x8d}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfb, 0x9a, 0xca, 0xfc, 0x35, 0x31, 0x69, 0x28, 0xe, 0x4b}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 7077; - uint8_t client_id_bytes[] = {0xa6, 0x32, 0xb7, 0x52, 0xea, 0x19, 0x2a, 0xe3, 0x20, 0xa, 0x7a, 0x16, 0x5}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xeb, 0x77, 0x84, 0x6d, 0x5d, 0xf8, 0x24, 0x34, 0xe8, 0x30, 0xf9, 0x56, 0xd6, - 0x7f, 0xb6, 0xaa, 0x4, 0x10, 0x11, 0xd4, 0x58, 0x93, 0x2d, 0xcf, 0x30}; - lwmqtt_string_t username = {25, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x42, 0xf5, 0xec, 0x80, 0xc4, 0x22, 0xb, 0xa6, 0x5b, 0x18, 0xa0, - 0x75, 0x92, 0x26, 0x5, 0x2a, 0x11, 0x74, 0x4e, 0x3f, 0x68}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14878}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14209}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10194}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3797}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3172}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops5}}}, + }; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 11679, 6, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just " \173\&3f\DC4", _password = Nothing, _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS1, _willTopic = "\SUB\224\241\aY%\155\222\143G\155T\163lx\218+", _willMsg = -// "m\130Tq\186R\196\157\v\245\FS\140\202\ETB\143\v\188\159\199\242\237\249A\DEL", _willProps = [PropTopicAlias -// 12587,PropTopicAlias 20812,PropRequestProblemInformation 63,PropServerKeepAlive 6655,PropTopicAliasMaximum -// 24552,PropContentType "\229\251\&4R\180\208\DC4/\147\141\196\EOT\211\149",PropMaximumQoS 199,PropCorrelationData -// "\252\240\SYN\147\221\204V\169\&2j\SOY\156\EOT\140\248\211|u\b\ACK\231\&6\223a\227"]}), _cleanSession = True, -// _keepAlive = 16885, _connID = "", _properties = [PropServerReference "\SOHRM\GS\154",PropResponseTopic -// ":g6\165\129\139|h\f2\210}\n2*M\186\142\149\157\129e\161\164M\157\199j:",PropPayloadFormatIndicator -// 74,PropMessageExpiryInterval 7166,PropSharedSubscriptionAvailable 99,PropReasonString -// "Fw3ry\206`s\DC4%I\ETB\226W\137\176\217k\130-\237\"*D\134\232\207\176W",PropServerKeepAlive 31247,PropUserProperty -// "\199P\237\222`\FS\153\STX\213m\217\254\156\218\ESC\ENQ0" "\173i\138\vj\231\246\199`"]} -TEST(Connect5QCTest, Encode14) { +// ACK (PubACK 11679 6 [PropAssignedClientIdentifier +// "\220\SO\167\167t\180\223\201\n^<\b\r\221\ETX\226\212\RS",PropResponseTopic "\168\SOf",PropMessageExpiryInterval +// 14878,PropRequestResponseInformation 5,PropWillDelayInterval 14209,PropReceiveMaximum 10194,PropSessionExpiryInterval +// 3797,PropResponseInformation "Xc",PropReceiveMaximum 3172,PropRetainAvailable 121,PropRetainAvailable +// 176,PropAssignedClientIdentifier +// "1\211sTO3q\SOH\230\r\142\172\SUB\193\176\133X\135\132\130\246\CAN\153\217\251",PropServerReference +// "-\SOH\140EEI<\184",PropCorrelationData +// "\146\205&\252\217\144|\DC1\151\218O\NUL,\RS\200\218\174\144\DEL\251\247$Z\239T'"]) +TEST(PubACKACK5QCTest, Decode16) { + uint8_t pkt[] = {0x40, 0x83, 0x1, 0x2d, 0x9f, 0x6, 0x7f, 0x12, 0x0, 0x12, 0xdc, 0xe, 0xa7, 0xa7, 0x74, 0xb4, 0xdf, + 0xc9, 0xa, 0x5e, 0x3c, 0x8, 0xd, 0xdd, 0x3, 0xe2, 0xd4, 0x1e, 0x8, 0x0, 0x3, 0xa8, 0xe, 0x66, + 0x2, 0x0, 0x0, 0x3a, 0x1e, 0x19, 0x5, 0x18, 0x0, 0x0, 0x37, 0x81, 0x21, 0x27, 0xd2, 0x11, 0x0, + 0x0, 0xe, 0xd5, 0x1a, 0x0, 0x2, 0x58, 0x63, 0x21, 0xc, 0x64, 0x25, 0x79, 0x25, 0xb0, 0x12, 0x0, + 0x19, 0x31, 0xd3, 0x73, 0x54, 0x4f, 0x33, 0x71, 0x1, 0xe6, 0xd, 0x8e, 0xac, 0x1a, 0xc1, 0xb0, 0x85, + 0x58, 0x87, 0x84, 0x82, 0xf6, 0x18, 0x99, 0xd9, 0xfb, 0x1c, 0x0, 0x8, 0x2d, 0x1, 0x8c, 0x45, 0x45, + 0x49, 0x3c, 0xb8, 0x9, 0x0, 0x1a, 0x92, 0xcd, 0x26, 0xfc, 0xd9, 0x90, 0x7c, 0x11, 0x97, 0xda, 0x4f, + 0x0, 0x2c, 0x1e, 0xc8, 0xda, 0xae, 0x90, 0x7f, 0xfb, 0xf7, 0x24, 0x5a, 0xef, 0x54, 0x27}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 11679); + EXPECT_EQ(status, 6); +} + +// COMP (PubCOMP 24709 179 [PropUserProperty "s" "\STX\133&\236f\NUL\137\STXXg\215+!",PropServerReference +// ":\238M<\197\&8\229\&8\168c\150\217\190A\206\a\166\166\DC4[mo",PropTopicAlias 3894,PropTopicAliasMaximum +// 26084,PropRetainAvailable 195,PropServerReference +// "\224\DEL|\149\SI\200\169N\208)Tw\DLE\FS\DEL",PropResponseInformation "\160]\SIL\226\EOT\172mJ\149\184J1~\US\DEL*2 +// \USE\215K\188*h\188\141\151",PropSubscriptionIdentifier 3,PropSessionExpiryInterval +// 25529,PropAssignedClientIdentifier +// "\129a\SUB\233\&2\DC4Pl=F\190Z\DEL7\186\140U\243\213\220\170C",PropSubscriptionIdentifier 19,PropRetainAvailable +// 243,PropServerKeepAlive 4192,PropUserProperty "\228\129\255\131\ENQ\216\211\255D" +// "\215\220V\NAK\249\&8\164\EMqH\143\229\199G}B\186",PropPayloadFormatIndicator 191,PropRequestProblemInformation +// 77,PropServerReference "o\145S\207wq\245G\202\ESC\188\169\139",PropMessageExpiryInterval 4286,PropWillDelayInterval +// 7675,PropPayloadFormatIndicator 79,PropAssignedClientIdentifier "i\253\DELSEQ\t\tze8",PropTopicAliasMaximum +// 28032,PropCorrelationData "C\168\\k\DLE\244\240r\142vRy\132",PropMessageExpiryInterval +// 19088,PropSubscriptionIdentifierAvailable 208,PropResponseInformation +// "EP\143\SYN\ACK\196\152\SI\185`\220&\NAKq%i\206C\168\243C#\202\204\138\154",PropReceiveMaximum 21789]) +TEST(PubACKCOMP5QCTest, Encode17) { uint8_t pkt[] = { - 0x10, 0xf3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0x41, 0xf5, 0x73, 0x1c, 0x0, 0x5, 0x1, 0x52, - 0x4d, 0x1d, 0x9a, 0x8, 0x0, 0x1d, 0x3a, 0x67, 0x36, 0xa5, 0x81, 0x8b, 0x7c, 0x68, 0xc, 0x32, 0xd2, 0x7d, 0xa, - 0x32, 0x2a, 0x4d, 0xba, 0x8e, 0x95, 0x9d, 0x81, 0x65, 0xa1, 0xa4, 0x4d, 0x9d, 0xc7, 0x6a, 0x3a, 0x1, 0x4a, 0x2, - 0x0, 0x0, 0x1b, 0xfe, 0x2a, 0x63, 0x1f, 0x0, 0x1d, 0x46, 0x77, 0x33, 0x72, 0x79, 0xce, 0x60, 0x73, 0x14, 0x25, - 0x49, 0x17, 0xe2, 0x57, 0x89, 0xb0, 0xd9, 0x6b, 0x82, 0x2d, 0xed, 0x22, 0x2a, 0x44, 0x86, 0xe8, 0xcf, 0xb0, 0x57, - 0x13, 0x7a, 0xf, 0x26, 0x0, 0x11, 0xc7, 0x50, 0xed, 0xde, 0x60, 0x1c, 0x99, 0x2, 0xd5, 0x6d, 0xd9, 0xfe, 0x9c, - 0xda, 0x1b, 0x5, 0x30, 0x0, 0x9, 0xad, 0x69, 0x8a, 0xb, 0x6a, 0xe7, 0xf6, 0xc7, 0x60, 0x0, 0x0, 0x3e, 0x23, - 0x31, 0x2b, 0x23, 0x51, 0x4c, 0x17, 0x3f, 0x13, 0x19, 0xff, 0x22, 0x5f, 0xe8, 0x3, 0x0, 0xe, 0xe5, 0xfb, 0x34, - 0x52, 0xb4, 0xd0, 0x14, 0x2f, 0x93, 0x8d, 0xc4, 0x4, 0xd3, 0x95, 0x24, 0xc7, 0x9, 0x0, 0x1a, 0xfc, 0xf0, 0x16, - 0x93, 0xdd, 0xcc, 0x56, 0xa9, 0x32, 0x6a, 0xe, 0x59, 0x9c, 0x4, 0x8c, 0xf8, 0xd3, 0x7c, 0x75, 0x8, 0x6, 0xe7, - 0x36, 0xdf, 0x61, 0xe3, 0x0, 0x11, 0x1a, 0xe0, 0xf1, 0x7, 0x59, 0x25, 0x9b, 0xde, 0x8f, 0x47, 0x9b, 0x54, 0xa3, - 0x6c, 0x78, 0xda, 0x2b, 0x0, 0x18, 0x6d, 0x82, 0x54, 0x71, 0xba, 0x52, 0xc4, 0x9d, 0xb, 0xf5, 0x1c, 0x8c, 0xca, - 0x17, 0x8f, 0xb, 0xbc, 0x9f, 0xc7, 0xf2, 0xed, 0xf9, 0x41, 0x7f, 0x0, 0x5, 0x20, 0xad, 0x33, 0x66, 0x14}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1, 0x52, 0x4d, 0x1d, 0x9a}; - uint8_t bytesprops1[] = {0x3a, 0x67, 0x36, 0xa5, 0x81, 0x8b, 0x7c, 0x68, 0xc, 0x32, 0xd2, 0x7d, 0xa, 0x32, 0x2a, - 0x4d, 0xba, 0x8e, 0x95, 0x9d, 0x81, 0x65, 0xa1, 0xa4, 0x4d, 0x9d, 0xc7, 0x6a, 0x3a}; - uint8_t bytesprops2[] = {0x46, 0x77, 0x33, 0x72, 0x79, 0xce, 0x60, 0x73, 0x14, 0x25, 0x49, 0x17, 0xe2, 0x57, 0x89, - 0xb0, 0xd9, 0x6b, 0x82, 0x2d, 0xed, 0x22, 0x2a, 0x44, 0x86, 0xe8, 0xcf, 0xb0, 0x57}; - uint8_t bytesprops4[] = {0xad, 0x69, 0x8a, 0xb, 0x6a, 0xe7, 0xf6, 0xc7, 0x60}; - uint8_t bytesprops3[] = {0xc7, 0x50, 0xed, 0xde, 0x60, 0x1c, 0x99, 0x2, 0xd5, - 0x6d, 0xd9, 0xfe, 0x9c,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0x4d, 0x1c, 0x0, 0xd, 0x6f, 0x91, 0x53, + 0xcf, 0x77, 0x71, 0xf5, 0x47, 0xca, 0x1b, 0xbc, 0xa9, 0x8b, 0x2, 0x0, 0x0, 0x10, 0xbe, 0x18, 0x0, 0x0, 0x1d, + 0xfb, 0x1, 0x4f, 0x12, 0x0, 0xb, 0x69, 0xfd, 0x7f, 0x53, 0x45, 0x51, 0x9, 0x9, 0x7a, 0x65, 0x38, 0x22, 0x6d, + 0x80, 0x9, 0x0, 0xd, 0x43, 0xa8, 0x5c, 0x6b, 0x10, 0xf4, 0xf0, 0x72, 0x8e, 0x76, 0x52, 0x79, 0x84, 0x2, 0x0, + 0x0, 0x4a, 0x90, 0x29, 0xd0, 0x1a, 0x0, 0x1a, 0x45, 0x50, 0x8f, 0x16, 0x6, 0xc4, 0x98, 0xf, 0xb9, 0x60, 0xdc, + 0x26, 0x15, 0x71, 0x25, 0x69, 0xce, 0x43, 0xa8, 0xf3, 0x43, 0x23, 0xca, 0xcc, 0x8a, 0x9a, 0x21, 0x55, 0x1d}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops1[] = {0x2, 0x85, 0x26, 0xec, 0x66, 0x0, 0x89, 0x2, 0x58, 0x67, 0xd7, 0x2b, 0x21}; + uint8_t bytesprops0[] = {0x73}; + uint8_t bytesprops2[] = {0x3a, 0xee, 0x4d, 0x3c, 0xc5, 0x38, 0xe5, 0x38, 0xa8, 0x63, 0x96, + 0xd9, 0xbe, 0x41, 0xce, 0x7, 0xa6, 0xa6, 0x14, 0x5b, 0x6d, 0x6f}; + uint8_t bytesprops3[] = {0xe0, 0x7f, 0x7c, 0x95, 0xf, 0xc8, 0xa9, 0x4e, 0xd0, 0x29, 0x54, 0x77, 0x10, 0x1c, 0x7f}; + uint8_t bytesprops4[] = {0xa0, 0x5d, 0xf, 0x4c, 0xe2, 0x4, 0xac, 0x6d, 0x4a, 0x95, 0xb8, 0x4a, 0x31, 0x7e, 0x1f, + 0x7f, 0x2a, 0x32, 0x20, 0x1f, 0x45, 0xd7, 0x4b, 0xbc, 0x2a, 0x68, 0xbc, 0x8d, 0x97}; + uint8_t bytesprops5[] = {0x81, 0x61, 0x1a, 0xe9, 0x32, 0x14, 0x50, 0x6c, 0x3d, 0x46, 0xbe, + 0x5a, 0x7f, 0x37, 0xba, 0x8c, 0x55, 0xf3, 0xd5, 0xdc, 0xaa, 0x43}; + uint8_t bytesprops7[] = {0xd7, 0xdc, 0x56, 0x15, 0xf9, 0x38, 0xa4, 0x19, 0x71, + 0x48, 0x8f, 0xe5, 0xc7, 0x47, 0x7d, 0x42, 0xba}; + uint8_t bytesprops6[] = {0xe4, 0x81, 0xff, 0x83, 0x5, 0xd8, 0xd3, 0xff, 0x44}; + uint8_t bytesprops8[] = {0x6f, 0x91, 0x53, 0xcf, 0x77, 0x71, 0xf5, 0x47, 0xca, 0x1b, 0xbc, 0xa9, 0x8b}; + uint8_t bytesprops9[] = {0x69, 0xfd, 0x7f, 0x53, 0x45, 0x51, 0x9, 0x9, 0x7a, 0x65, 0x38}; + uint8_t bytesprops10[] = {0x43, 0xa8, 0x5c, 0x6b, 0x10, 0xf4, 0xf0, 0x72, 0x8e, 0x76, 0x52, 0x79, 0x84}; + uint8_t bytesprops11[] = {0x45, 0x50, 0x8f, 0x16, 0x6, 0xc4, 0x98, 0xf, 0xb9, 0x60, 0xdc, 0x26, 0x15, + 0x71, 0x25, 0x69, 0xce, 0x43, 0xa8, 0xf3, 0x43, 0x23, 0xca, 0xcc, 0x8a, 0x9a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7166}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31247}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops3}, .v = {9, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3894}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26084}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25529}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4192}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops6}, .v = {17, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4286}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7675}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28032}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19088}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21789}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xe5, 0xfb, 0x34, 0x52, 0xb4, 0xd0, 0x14, 0x2f, 0x93, 0x8d, 0xc4, 0x4, 0xd3, 0x95}; - uint8_t byteswillprops1[] = {0xfc, 0xf0, 0x16, 0x93, 0xdd, 0xcc, 0x56, 0xa9, 0x32, 0x6a, 0xe, 0x59, 0x9c, - 0x4, 0x8c, 0xf8, 0xd3, 0x7c, 0x75, 0x8, 0x6, 0xe7, 0x36, 0xdf, 0x61, 0xe3}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12587}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20812}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6655}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24552}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&byteswillprops1}}}, - }; - - lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1a, 0xe0, 0xf1, 0x7, 0x59, 0x25, 0x9b, 0xde, 0x8f, - 0x47, 0x9b, 0x54, 0xa3, 0x6c, 0x78, 0xda, 0x2b}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x6d, 0x82, 0x54, 0x71, 0xba, 0x52, 0xc4, 0x9d, 0xb, 0xf5, 0x1c, 0x8c, - 0xca, 0x17, 0x8f, 0xb, 0xbc, 0x9f, 0xc7, 0xf2, 0xed, 0xf9, 0x41, 0x7f}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 16885; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x20, 0xad, 0x33, 0x66, 0x14}; - lwmqtt_string_t username = {5, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 24709, 179, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\162\146\138\141K)\DEL\142\&8zW\163\DC2M#\138\ENQ\NUL\134\235\203", _password = -// Just "\133\n\206/_y\134\132\146/\225s 4O\210\144\130\GS\148b", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS1, _willTopic = "\251\220\159\161T\129^\175\210\212\RS0Yh\NAK\141{5\207lv\193\253\209", _willMsg = -// "\202{q\255\165\RS", _willProps = [PropReasonString "\168\154\234\&83o\192\NAK\202",PropRequestProblemInformation -// 231,PropRetainAvailable 97,PropUserProperty "q\142\NUL,\255\238\211\245\224\DC4\DC2\235\RS\145" -// ">\US\141r\136\162\CAN\254\209\139\160\178\162n\220RI",PropContentType "\142\247DZ^\180e]\n",PropContentType -// "5(NH>\143x",PropTopicAlias 27268,PropReasonString -// "'\227w\244\183\240\230\146+\SI\186C_C\172y$",PropRequestProblemInformation 87,PropWillDelayInterval -// 31902,PropRequestResponseInformation 176,PropMessageExpiryInterval 30405,PropUserProperty -// "\SI\204Vp}Z\199]\ETX\160\179u\247~y\194" "6bN\162\245\&3%\158\243\214\vo\239\151",PropCorrelationData -// "\204\&9\DC2\US\170=\209"]}), -// _cleanSession = False, _keepAlive = 28167, _connID = -// "v\243\203T}\236\142\226\SI\204\157\191\223\138y\DC4\252\163\134", _properties = [PropResponseTopic -// "/3\SOHI\158%/\137v\174\&1\233Qf\168Mm*\189~\ETX\150\232A\244\129",PropSubscriptionIdentifier 24,PropServerReference -// ".-8Qz\239le",PropTopicAliasMaximum 3736,PropWillDelayInterval 24917,PropMessageExpiryInterval -// 20599,PropAuthenticationMethod "\144b\171\CAN\130\235R\162",PropMaximumQoS 223,PropWillDelayInterval -// 24968,PropCorrelationData "\199\GS\128N\212\&6}U\131(\200",PropResponseInformation -// "\192\231e\176Q5P\183\175>\183I\NAK`\253\235\132\168\148\238\ESCy2\SI\140\241\161\EOT",PropResponseTopic -// "\159\238F\145\170>\183_\142\t\184\&4OB\185\190:\175\f\175'\RS\"/\158\155}==\191",PropContentType -// "\243\234(\159\206\202\222\143#\192\ACKj\217\b\t\175`\"\139\r8\198b\SUBZ`\172/\GS2",PropResponseTopic -// "O\250w\212w+\ENQ\NUL\194'\148\177\136",PropSubscriptionIdentifierAvailable 242,PropRequestProblemInformation -// 255,PropWildcardSubscriptionAvailable 72,PropTopicAlias 11275]} -TEST(Connect5QCTest, Encode15) { +// COMP (PubCOMP 24709 179 [PropUserProperty "s" "\STX\133&\236f\NUL\137\STXXg\215+!",PropServerReference +// ":\238M<\197\&8\229\&8\168c\150\217\190A\206\a\166\166\DC4[mo",PropTopicAlias 3894,PropTopicAliasMaximum +// 26084,PropRetainAvailable 195,PropServerReference +// "\224\DEL|\149\SI\200\169N\208)Tw\DLE\FS\DEL",PropResponseInformation "\160]\SIL\226\EOT\172mJ\149\184J1~\US\DEL*2 +// \USE\215K\188*h\188\141\151",PropSubscriptionIdentifier 3,PropSessionExpiryInterval +// 25529,PropAssignedClientIdentifier +// "\129a\SUB\233\&2\DC4Pl=F\190Z\DEL7\186\140U\243\213\220\170C",PropSubscriptionIdentifier 19,PropRetainAvailable +// 243,PropServerKeepAlive 4192,PropUserProperty "\228\129\255\131\ENQ\216\211\255D" +// "\215\220V\NAK\249\&8\164\EMqH\143\229\199G}B\186",PropPayloadFormatIndicator 191,PropRequestProblemInformation +// 77,PropServerReference "o\145S\207wq\245G\202\ESC\188\169\139",PropMessageExpiryInterval 4286,PropWillDelayInterval +// 7675,PropPayloadFormatIndicator 79,PropAssignedClientIdentifier "i\253\DELSEQ\t\tze8",PropTopicAliasMaximum +// 28032,PropCorrelationData "C\168\\k\DLE\244\240r\142vRy\132",PropMessageExpiryInterval +// 19088,PropSubscriptionIdentifierAvailable 208,PropResponseInformation +// "EP\143\SYN\ACK\196\152\SI\185`\220&\NAKq%i\206C\168\243C#\202\204\138\154",PropReceiveMaximum 21789]) +TEST(PubACKCOMP5QCTest, Decode17) { uint8_t pkt[] = { - 0x10, 0xbf, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x6e, 0x7, 0xd1, 0x1, 0x8, 0x0, 0x1a, 0x2f, - 0x33, 0x1, 0x49, 0x9e, 0x25, 0x2f, 0x89, 0x76, 0xae, 0x31, 0xe9, 0x51, 0x66, 0xa8, 0x4d, 0x6d, 0x2a, 0xbd, 0x7e, - 0x3, 0x96, 0xe8, 0x41, 0xf4, 0x81, 0xb, 0x18, 0x1c, 0x0, 0x8, 0x2e, 0x2d, 0x38, 0x51, 0x7a, 0xef, 0x6c, 0x65, - 0x22,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0xed, 0xef, 0x91, 0x5c, 0xfa, - 0x6b, 0xd9, 0x3c, 0x6, 0xcf, 0xba, 0x61, 0x78, 0x0, 0xd, 0xa1, 0xb5, 0x46, 0x38, 0x44, 0x25, 0xa7, 0x54, 0x2d, - 0x2e, 0x72, 0x96, 0xba, 0x2a, 0x19, 0x23, 0x4a, 0x8b, 0x15, 0x0, 0x1e, 0xbb, 0x7d, 0xec, 0x26, 0xb0, 0x34, 0x58, - 0x2e, 0x16, 0xda, 0x17, 0x21, 0x9a, 0xee, 0xe3, 0xd8, 0x85, 0xb8, 0xc, 0xa4, 0x1, 0xeb, 0x5, 0x98, 0x5, 0xa0, - 0xb9, 0xb5, 0x3e, 0xd1, 0x0, 0x18, 0xfb, 0xdc, 0x9f, 0xa1, 0x54, 0x81, 0x5e, 0xaf, 0xd2, 0xd4, 0x1e, 0x30, 0x59, - 0x68, 0x15, 0x8d, 0x7b, 0x35, 0xcf, 0x6c, 0x76, 0xc1, 0xfd, 0xd1, 0x0, 0x6, 0xca, 0x7b, 0x71, 0xff, 0xa5, 0x1e, - 0x0, 0x15, 0xa2, 0x92, 0x8a, 0x8d, 0x4b, 0x29, 0x7f, 0x8e, 0x38, 0x7a, 0x57, 0xa3, 0x12, 0x4d, 0x23, 0x8a, 0x5, - 0x0, 0x86, 0xeb, 0xcb, 0x0, 0x15, 0x85, 0xa, 0xce, 0x2f, 0x5f, 0x79, 0x86, 0x84, 0x92, 0x2f, 0xe1, 0x73, 0x20, - 0x34, 0x4f, 0xd2, 0x90, 0x82, 0x1d, 0x94, 0x62}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x2f, 0x33, 0x1, 0x49, 0x9e, 0x25, 0x2f, 0x89, 0x76, 0xae, 0x31, 0xe9, 0x51, - 0x66, 0xa8, 0x4d, 0x6d, 0x2a, 0xbd, 0x7e, 0x3, 0x96, 0xe8, 0x41, 0xf4, 0x81}; - uint8_t bytesprops1[] = {0x2e, 0x2d, 0x38, 0x51, 0x7a, 0xef, 0x6c, 0x65}; - uint8_t bytesprops2[] = {0x90, 0x62, 0xab, 0x18, 0x82, 0xeb, 0x52, 0xa2}; - uint8_t bytesprops3[] = {0xc7, 0x1d, 0x80, 0x4e, 0xd4, 0x36, 0x7d, 0x55, 0x83, 0x28, 0xc8}; - uint8_t bytesprops4[] = {0xc0, 0xe7, 0x65, 0xb0, 0x51, 0x35, 0x50, 0xb7, 0xaf, 0x3e, 0xb7, 0x49, 0x15, 0x60, - 0xfd, 0xeb, 0x84, 0xa8, 0x94, 0xee, 0x1b, 0x79, 0x32, 0xf, 0x8c, 0xf1, 0xa1, 0x4}; - uint8_t bytesprops5[] = {0x9f, 0xee, 0x46, 0x91, 0xaa, 0x3e, 0xb7, 0x5f, 0x8e, 0x9, 0xb8, 0x34, 0x4f, 0x42, 0xb9, - 0xbe, 0x3a, 0xaf, 0xc, 0xaf, 0x27, 0x1e, 0x22, 0x2f, 0x9e, 0x9b, 0x7d, 0x3d, 0x3d, 0xbf}; - uint8_t bytesprops6[] = {0xf3, 0xea, 0x28, 0x9f, 0xce, 0xca, 0xde, 0x8f, 0x23, 0xc0, 0x6, 0x6a, 0xd9, 0x8, 0x9, - 0xaf, 0x60, 0x22, 0x8b, 0xd, 0x38, 0xc6, 0x62, 0x1a, 0x5a, 0x60, 0xac, 0x2f, 0x1d, 0x32}; - uint8_t bytesprops7[] = {0x4f, 0xfa, 0x77, 0xd4, 0x77, 0x2b, 0x5, 0x0, 0xc2, 0x27, 0x94, 0xb1, 0x88}; + 0x70, 0x99, 0x2, 0x60, 0x85, 0xb3, 0x94, 0x2, 0x26, 0x0, 0x1, 0x73, 0x0, 0xd, 0x2, 0x85, 0x26, 0xec, 0x66, + 0x0, 0x89, 0x2, 0x58, 0x67, 0xd7, 0x2b, 0x21, 0x1c, 0x0, 0x16, 0x3a, 0xee, 0x4d, 0x3c, 0xc5, 0x38, 0xe5, 0x38, + 0xa8, 0x63, 0x96, 0xd9, 0xbe, 0x41,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0, 0xd, 0x43, 0xa8, 0x5c, 0x6b, 0x10, 0xf4, 0xf0, 0x72, 0x8e, 0x76, 0x52, 0x79, 0x84, 0x2, 0x0, + 0x0, 0x4a, 0x90, 0x29, 0xd0, 0x1a, 0x0, 0x1a, 0x45, 0x50, 0x8f, 0x16, 0x6, 0xc4, 0x98, 0xf, 0xb9, 0x60, 0xdc, + 0x26, 0x15, 0x71, 0x25, 0x69, 0xce, 0x43, 0xa8, 0xf3, 0x43, 0x23, 0xca, 0xcc, 0x8a, 0x9a, 0x21, 0x55, 0x1d}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 24709); + EXPECT_EQ(status, 179); +} + +// REL (PubREL 19085 19 [PropAuthenticationData "\229\EMU\215\170\189\150q\171\133\137\143\GS",PropContentType +// "|\203?\153\139\v\164\NAKo\190\&2y\224\246[\203\156\234\170\149\186\153\241_4\247\252\182\139",PropTopicAliasMaximum +// 23515,PropResponseTopic "\202QE\EM\128\131\254\206w\ETBg",PropServerKeepAlive 2467,PropMessageExpiryInterval +// 23054,PropWildcardSubscriptionAvailable 68,PropSessionExpiryInterval 14963,PropWillDelayInterval +// 26769,PropRequestProblemInformation 93,PropResponseInformation "\142",PropTopicAliasMaximum +// 12142,PropAuthenticationData ")\232\161Yh\138\205\172:\SI\221\tD\238\GSR\135!<\200",PropSessionExpiryInterval +// 26062,PropSubscriptionIdentifier 1,PropRequestProblemInformation 12,PropResponseInformation +// "+\236\139\&6%\170",PropServerKeepAlive 27551,PropSharedSubscriptionAvailable 176,PropAuthenticationData +// "\NAK#\203\137\157\133)E\138\&9\168\142\SOH\228m\221\199\214\240\249\151\215J\233$B\190\161\178",PropWillDelayInterval +// 3405,PropPayloadFormatIndicator 15,PropUserProperty "\244\&6\179" +// "[\187\130LMUA*\STX\168Mk\232\DELe\145\134\137",PropMaximumPacketSize 6947,PropPayloadFormatIndicator 122]) +TEST(PubACKREL5QCTest, Encode18) { + uint8_t pkt[] = {0x62, 0xd9, 0x1, 0x4a, 0x8d, 0x13, 0xd4, 0x1, 0x16, 0x0, 0xd, 0xe5, 0x19, 0x55, 0xd7, 0xaa, 0xbd, + 0x96, 0x71, 0xab, 0x85, 0x89, 0x8f, 0x1d, 0x3, 0x0, 0x1d, 0x7c, 0xcb, 0x3f, 0x99, 0x8b, 0xb, 0xa4, + 0x15, 0x6f, 0xbe, 0x32, 0x79, 0xe0, 0xf6, 0x5b, 0xcb, 0x9c, 0xea, 0xaa, 0x95, 0xba, 0x99, 0xf1, 0x5f, + 0x34, 0xf7, 0xfc, 0xb6, 0x8b, 0x22, 0x5b, 0xdb, 0x8, 0x0, 0xb, 0xca, 0x51, 0x45, 0x19, 0x80, 0x83, + 0xfe, 0xce, 0x77, 0x17, 0x67, 0x13, 0x9, 0xa3, 0x2, 0x0, 0x0, 0x5a, 0xe, 0x28, 0x44, 0x11, 0x0, + 0x0, 0x3a, 0x73, 0x18, 0x0, 0x0, 0x68, 0x91, 0x17, 0x5d, 0x1a, 0x0, 0x1, 0x8e, 0x22, 0x2f, 0x6e, + 0x16, 0x0, 0x14, 0x29, 0xe8, 0xa1, 0x59, 0x68, 0x8a, 0xcd, 0xac, 0x3a, 0xf, 0xdd, 0x9, 0x44, 0xee, + 0x1d, 0x52, 0x87, 0x21, 0x3c, 0xc8, 0x11, 0x0, 0x0, 0x65, 0xce, 0xb, 0x1, 0x17, 0xc, 0x1a, 0x0, + 0x6, 0x2b, 0xec, 0x8b, 0x36, 0x25, 0xaa, 0x13, 0x6b, 0x9f, 0x2a, 0xb0, 0x16, 0x0, 0x1d, 0x15, 0x23, + 0xcb, 0x89, 0x9d, 0x85, 0x29, 0x45, 0x8a, 0x39, 0xa8, 0x8e, 0x1, 0xe4, 0x6d, 0xdd, 0xc7, 0xd6, 0xf0, + 0xf9, 0x97, 0xd7, 0x4a, 0xe9, 0x24, 0x42, 0xbe, 0xa1, 0xb2, 0x18, 0x0, 0x0, 0xd, 0x4d, 0x1, 0xf, + 0x26, 0x0, 0x3, 0xf4, 0x36, 0xb3, 0x0, 0x12, 0x5b, 0xbb, 0x82, 0x4c, 0x4d, 0x55, 0x41, 0x2a, 0x2, + 0xa8, 0x4d, 0x6b, 0xe8, 0x7f, 0x65, 0x91, 0x86, 0x89, 0x27, 0x0, 0x0, 0x1b, 0x23, 0x1, 0x7a}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0xe5, 0x19, 0x55, 0xd7, 0xaa, 0xbd, 0x96, 0x71, 0xab, 0x85, 0x89, 0x8f, 0x1d}; + uint8_t bytesprops1[] = {0x7c, 0xcb, 0x3f, 0x99, 0x8b, 0xb, 0xa4, 0x15, 0x6f, 0xbe, 0x32, 0x79, 0xe0, 0xf6, 0x5b, + 0xcb, 0x9c, 0xea, 0xaa, 0x95, 0xba, 0x99, 0xf1, 0x5f, 0x34, 0xf7, 0xfc, 0xb6, 0x8b}; + uint8_t bytesprops2[] = {0xca, 0x51, 0x45, 0x19, 0x80, 0x83, 0xfe, 0xce, 0x77, 0x17, 0x67}; + uint8_t bytesprops3[] = {0x8e}; + uint8_t bytesprops4[] = {0x29, 0xe8, 0xa1, 0x59, 0x68, 0x8a, 0xcd, 0xac, 0x3a, 0xf, + 0xdd, 0x9, 0x44, 0xee, 0x1d, 0x52, 0x87, 0x21, 0x3c, 0xc8}; + uint8_t bytesprops5[] = {0x2b, 0xec, 0x8b, 0x36, 0x25, 0xaa}; + uint8_t bytesprops6[] = {0x15, 0x23, 0xcb, 0x89, 0x9d, 0x85, 0x29, 0x45, 0x8a, 0x39, 0xa8, 0x8e, 0x1, 0xe4, 0x6d, + 0xdd, 0xc7, 0xd6, 0xf0, 0xf9, 0x97, 0xd7, 0x4a, 0xe9, 0x24, 0x42, 0xbe, 0xa1, 0xb2}; + uint8_t bytesprops8[] = {0x5b, 0xbb, 0x82, 0x4c, 0x4d, 0x55, 0x41, 0x2a, 0x2, + 0xa8, 0x4d, 0x6b, 0xe8, 0x7f, 0x65, 0x91, 0x86, 0x89}; + uint8_t bytesprops7[] = {0xf4, 0x36, 0xb3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3736}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24917}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20599}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24968}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 255}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11275}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23515}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2467}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23054}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14963}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26769}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12142}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26062}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27551}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3405}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops7}, .v = {18, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6947}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 122}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xa8, 0x9a, 0xea, 0x38, 0x33, 0x6f, 0xc0, 0x15, 0xca}; - uint8_t byteswillprops2[] = {0x3e, 0x1f, 0x8d, 0x72, 0x88, 0xa2, 0x18, 0xfe, 0xd1, - 0x8b, 0xa0, 0xb2, 0xa2, 0x6e, 0xdc, 0x52, 0x49}; - uint8_t byteswillprops1[] = {0x71, 0x8e, 0x0, 0x2c, 0xff, 0xee, 0xd3, 0xf5, 0xe0, 0x14, 0x12, 0xeb, 0x1e, 0x91}; - uint8_t byteswillprops3[] = {0x8e, 0xf7, 0x44, 0x5a, 0x5e, 0xb4, 0x65, 0x5d, 0xa}; - uint8_t byteswillprops4[] = {0x35, 0x28, 0x4e, 0x48, 0x3e, 0x8f, 0x78}; - uint8_t byteswillprops5[] = {0x27, 0xe3, 0x77, 0xf4, 0xb7, 0xf0, 0xe6, 0x92, 0x2b, - 0xf, 0xba, 0x43, 0x5f, 0x43, 0xac, 0x79, 0x24}; - uint8_t byteswillprops7[] = {0x36, 0x62, 0x4e, 0xa2, 0xf5, 0x33, 0x25, 0x9e, 0xf3, 0xd6, 0xb, 0x6f, 0xef, 0x97}; - uint8_t byteswillprops6[] = {0xf, 0xcc, 0x56, 0x70, 0x7d, 0x5a, 0xc7, 0x5d, - 0x3, 0xa0, 0xb3, 0x75, 0xf7, 0x7e, 0x79, 0xc2}; - uint8_t byteswillprops8[] = {0xcc, 0x39, 0x12, 0x1f, 0xaa, 0x3d, 0x3c, 0x58, 0x7c, 0x5a, 0xa4}; - uint8_t byteswillprops10[] = {0xa1, 0xb5, 0x46, 0x38, 0x44, 0x25, 0xa7, 0x54, 0x2d, 0x2e, 0x72, 0x96, 0xba}; - uint8_t byteswillprops9[] = {0xed, 0xef, 0x91, 0x5c, 0xfa, 0x6b, 0xd9, 0x3c, 0x6, 0xcf, 0xba, 0x61, 0x78}; - uint8_t byteswillprops11[] = {0xbb, 0x7d, 0xec, 0x26, 0xb0, 0x34, 0x58, 0x2e, 0x16, 0xda, - 0x17, 0x21, 0x9a, 0xee, 0xe3, 0xd8, 0x85, 0xb8, 0xc, 0xa4, - 0x1, 0xeb, 0x5, 0x98, 0x5, 0xa0, 0xb9, 0xb5, 0x3e, 0xd1}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 19085, 19, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {14, (char*)&byteswillprops1}, .v = {17, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27268}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31902}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30405}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {16, (char*)&byteswillprops6}, .v = {14, (char*)&byteswillprops7}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3339}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29385}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 699}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17173}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {13, (char*)&byteswillprops9}, .v = {13, (char*)&byteswillprops10}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19083}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops11}}}, - }; +// REL (PubREL 19085 19 [PropAuthenticationData "\229\EMU\215\170\189\150q\171\133\137\143\GS",PropContentType +// "|\203?\153\139\v\164\NAKo\190\&2y\224\246[\203\156\234\170\149\186\153\241_4\247\252\182\139",PropTopicAliasMaximum +// 23515,PropResponseTopic "\202QE\EM\128\131\254\206w\ETBg",PropServerKeepAlive 2467,PropMessageExpiryInterval +// 23054,PropWildcardSubscriptionAvailable 68,PropSessionExpiryInterval 14963,PropWillDelayInterval +// 26769,PropRequestProblemInformation 93,PropResponseInformation "\142",PropTopicAliasMaximum +// 12142,PropAuthenticationData ")\232\161Yh\138\205\172:\SI\221\tD\238\GSR\135!<\200",PropSessionExpiryInterval +// 26062,PropSubscriptionIdentifier 1,PropRequestProblemInformation 12,PropResponseInformation +// "+\236\139\&6%\170",PropServerKeepAlive 27551,PropSharedSubscriptionAvailable 176,PropAuthenticationData +// "\NAK#\203\137\157\133)E\138\&9\168\142\SOH\228m\221\199\214\240\249\151\215J\233$B\190\161\178",PropWillDelayInterval +// 3405,PropPayloadFormatIndicator 15,PropUserProperty "\244\&6\179" +// "[\187\130LMUA*\STX\168Mk\232\DELe\145\134\137",PropMaximumPacketSize 6947,PropPayloadFormatIndicator 122]) +TEST(PubACKREL5QCTest, Decode18) { + uint8_t pkt[] = {0x62, 0xd9, 0x1, 0x4a, 0x8d, 0x13, 0xd4, 0x1, 0x16, 0x0, 0xd, 0xe5, 0x19, 0x55, 0xd7, 0xaa, 0xbd, + 0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a8, 0x4d, 0x6b, 0xe8, 0x7f, 0x65, 0x91, 0x86, 0x89, 0x27, 0x0, 0x0, 0x1b, 0x23, 0x1, 0x7a}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 19085); + EXPECT_EQ(status, 19); +} - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xfb, 0xdc, 0x9f, 0xa1, 0x54, 0x81, 0x5e, 0xaf, 0xd2, 0xd4, 0x1e, 0x30, - 0x59, 0x68, 0x15, 0x8d, 0x7b, 0x35, 0xcf, 0x6c, 0x76, 0xc1, 0xfd, 0xd1}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xca, 0x7b, 0x71, 0xff, 0xa5, 0x1e}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 28167; - uint8_t client_id_bytes[] = {0x76, 0xf3, 0xcb, 0x54, 0x7d, 0xec, 0x8e, 0xe2, 0xf, 0xcc, - 0x9d, 0xbf, 0xdf, 0x8a, 0x79, 0x14, 0xfc, 0xa3, 0x86}; - lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xa2, 0x92, 0x8a, 0x8d, 0x4b, 0x29, 0x7f, 0x8e, 0x38, 0x7a, 0x57, - 0xa3, 0x12, 0x4d, 0x23, 0x8a, 0x5, 0x0, 0x86, 0xeb, 0xcb}; - lwmqtt_string_t username = {21, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x85, 0xa, 0xce, 0x2f, 0x5f, 0x79, 0x86, 0x84, 0x92, 0x2f, 0xe1, - 0x73, 0x20, 0x34, 0x4f, 0xd2, 0x90, 0x82, 0x1d, 0x94, 0x62}; - lwmqtt_string_t password = {21, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); +// ACK (PubACK 23245 69 []) +TEST(PubACKACK5QCTest, Encode19) { + uint8_t pkt[] = {0x40, 0x3, 0x5a, 0xcd, 0x45}; + uint8_t buf[sizeof(pkt) + 10]; + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 23245, 69, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "Ub", _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS -// = QoS2, _willTopic = "\EM\162\218\226Q\179}\211\ETB\242\188\157(\150\&7-", _willMsg = "\146#K\CAN-7w\161\228\157", -// _willProps = [PropContentType "'\193\181\DC3zy\170p\GS\r\191\129\&7\"\141\162\128-\249i\138 -// KIN\222\198J",PropWildcardSubscriptionAvailable 118,PropMaximumQoS 163,PropTopicAlias 27085,PropMessageExpiryInterval -// 28560,PropTopicAliasMaximum 5360,PropSubscriptionIdentifierAvailable 70,PropTopicAlias 7674,PropServerKeepAlive -// 24177,PropMessageExpiryInterval 7765,PropWillDelayInterval 31134,PropServerKeepAlive 25331,PropServerKeepAlive -// 13361]}), _cleanSession = False, _keepAlive = 618, _connID = "\193\150\ENQ", _properties = [PropContentType -// "\RS\163\209\\Kg\ESC\139%\192",PropContentType "\172_\167\130\t\159\152\a",PropMessageExpiryInterval -// 29459,PropPayloadFormatIndicator 84,PropTopicAlias 10884,PropServerReference -// "\245{\232\189\&0PI\DC3\160\254\NUL\235*\230\157\182x\146",PropReasonString -// "&b\EOTAb\217\ax\bD\vz\222\234x\196\212\&5fEI\thW\241",PropTopicAliasMaximum 6153,PropResponseTopic -// "e-l.d\\d\184\ETB\ENQ\197\179\143\245\186\EMD!",PropServerKeepAlive 25494,PropMaximumPacketSize -// 12721,PropReceiveMaximum 3532,PropSubscriptionIdentifier 23,PropAssignedClientIdentifier -// "#\237\144\214\228NA\185p\166\DC3E\ETB",PropWillDelayInterval 19226,PropTopicAliasMaximum 16287,PropWillDelayInterval -// 26966,PropReceiveMaximum 22426,PropRetainAvailable 175,PropPayloadFormatIndicator 116,PropSubscriptionIdentifier -// 4,PropCorrelationData "i\252\ETX\226",PropSubscriptionIdentifierAvailable 152,PropSubscriptionIdentifierAvailable -// 66,PropMessageExpiryInterval 8075,PropContentType -// "\SYN\250\NAK\GS\154N\EMC3P\DC3\DC1d%\SO\177\140\239@\182\171\142\"\146\190ub\SO\DC2\135",PropMessageExpiryInterval -// 29700]} -TEST(Connect5QCTest, Encode16) { - uint8_t pkt[] = { - 0x10, 0xce, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xb4, 0x2, 0x6a, 0xd4, 0x1, 0x3, 0x0, 0xa, 0x1e, - 0xa3, 0xd1, 0x5c, 0x4b, 0x67, 0x1b, 0x8b, 0x25, 0xc0, 0x3, 0x0, 0x8, 0xac, 0x5f, 0xa7, 0x82, 0x9, 0x9f, 0x98, - 0x7, 0x2, 0x0, 0x0, 0x73, 0x13, 0x1, 0x54, 0x23, 0x2a, 0x84, 0x1c, 0x0, 0x12, 0xf5, 0x7b, 0xe8, 0xbd, 0x30, - 0x50, 0x49, 0x13, 0xa0, 0xfe, 0x0, 0xeb, 0x2a, 0xe6, 0x9d, 0xb6, 0x78, 0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, 0xde, 0xc6, 0x4a, 0x28, 0x76, - 0x24, 0xa3, 0x23, 0x69, 0xcd, 0x2, 0x0, 0x0, 0x6f, 0x90, 0x22, 0x14, 0xf0, 0x29, 0x46, 0x23, 0x1d, 0xfa, 0x13, - 0x5e, 0x71, 0x2, 0x0, 0x0, 0x1e, 0x55, 0x18, 0x0, 0x0, 0x79, 0x9e, 0x13, 0x62, 0xf3, 0x13, 0x34, 0x31, 0x0, - 0x10, 0x19, 0xa2, 0xda, 0xe2, 0x51, 0xb3, 0x7d, 0xd3, 0x17, 0xf2, 0xbc, 0x9d, 0x28, 0x96, 0x37, 0x2d, 0x0, 0xa, - 0x92, 0x23, 0x4b, 0x18, 0x2d, 0x37, 0x77, 0xa1, 0xe4, 0x9d, 0x0, 0x2, 0x55, 0x62}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1e, 0xa3, 0xd1, 0x5c, 0x4b, 0x67, 0x1b, 0x8b, 0x25, 0xc0}; - uint8_t bytesprops1[] = {0xac, 0x5f, 0xa7, 0x82, 0x9, 0x9f, 0x98, 0x7}; - uint8_t bytesprops2[] = {0xf5, 0x7b, 0xe8, 0xbd, 0x30, 0x50, 0x49, 0x13, 0xa0, - 0xfe, 0x0, 0xeb, 0x2a, 0xe6, 0x9d, 0xb6, 0x78, 0x92}; - uint8_t bytesprops3[] = {0x26, 0x62, 0x4, 0x41, 0x62, 0xd9, 0x7, 0x78, 0x8, 0x44, 0xb, 0x7a, 0xde, - 0xea, 0x78, 0xc4, 0xd4, 0x35, 0x66, 0x45, 0x49, 0x9, 0x68, 0x57, 0xf1}; - uint8_t bytesprops4[] = {0x65, 0x2d, 0x6c, 0x2e, 0x64, 0x5c, 0x64, 0xb8, 0x17, - 0x5, 0xc5, 0xb3, 0x8f, 0xf5, 0xba, 0x19, 0x44, 0x21}; - uint8_t bytesprops5[] = {0x23, 0xed, 0x90, 0xd6, 0xe4, 0x4e, 0x41, 0xb9, 0x70, 0xa6, 0x13, 0x45, 0x17}; - uint8_t bytesprops6[] = {0x69, 0xfc, 0x3, 0xe2}; - uint8_t bytesprops7[] = {0x16, 0xfa, 0x15, 0x1d, 0x9a, 0x4e, 0x19, 0x43, 0x33, 0x50, 0x13, 0x11, 0x64, 0x25, 0xe, - 0xb1, 0x8c, 0xef, 0x40, 0xb6, 0xab, 0x8e, 0x22, 0x92, 0xbe, 0x75, 0x62, 0xe, 0x12, 0x87}; +// ACK (PubACK 23245 69 []) +TEST(PubACKACK5QCTest, Decode19) { + uint8_t pkt[] = {0x40, 0x3, 0x5a, 0xcd, 0x45}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 23245); + EXPECT_EQ(status, 69); +} + +// REL (PubREL 27855 141 [PropServerKeepAlive 19509,PropContentType "m\t\147\154\249\169\\\137V\224\t",PropReasonString +// "J\EMe_\213\196\176\242M4\180\153\246\237\242\fW}\169\246\&5J\151Y",PropReasonString "\216\194'^\203\162#"]) +TEST(PubACKREL5QCTest, Encode20) { + uint8_t pkt[] = {0x62, 0x3a, 0x6c, 0xcf, 0x8d, 0x36, 0x13, 0x4c, 0x35, 0x3, 0x0, 0xb, 0x6d, 0x9, 0x93, + 0x9a, 0xf9, 0xa9, 0x5c, 0x89, 0x56, 0xe0, 0x9, 0x1f, 0x0, 0x18, 0x4a, 0x19, 0x65, 0x5f, + 0xd5, 0xc4, 0xb0, 0xf2, 0x4d, 0x34, 0xb4, 0x99, 0xf6, 0xed, 0xf2, 0xc, 0x57, 0x7d, 0xa9, + 0xf6, 0x35, 0x4a, 0x97, 0x59, 0x1f, 0x0, 0x7, 0xd8, 0xc2, 0x27, 0x5e, 0xcb, 0xa2, 0x23}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0x6d, 0x9, 0x93, 0x9a, 0xf9, 0xa9, 0x5c, 0x89, 0x56, 0xe0, 0x9}; + uint8_t bytesprops1[] = {0x4a, 0x19, 0x65, 0x5f, 0xd5, 0xc4, 0xb0, 0xf2, 0x4d, 0x34, 0xb4, 0x99, + 0xf6, 0xed, 0xf2, 0xc, 0x57, 0x7d, 0xa9, 0xf6, 0x35, 0x4a, 0x97, 0x59}; + uint8_t bytesprops2[] = {0xd8, 0xc2, 0x27, 0x5e, 0xcb, 0xa2, 0x23}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29459}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10884}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6153}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25494}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12721}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3532}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19226}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16287}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26966}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22426}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8075}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29700}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19509}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x27, 0xc1, 0xb5, 0x13, 0x7a, 0x79, 0xaa, 0x70, 0x1d, 0xd, 0xbf, 0x81, 0x37, 0x22, - 0x8d, 0xa2, 0x80, 0x2d, 0xf9, 0x69, 0x8a, 0x20, 0x4b, 0x49, 0x4e, 0xde, 0xc6, 0x4a}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 27855, 141, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27085}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28560}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5360}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7674}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24177}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7765}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31134}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25331}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13361}}, - }; +// REL (PubREL 27855 141 [PropServerKeepAlive 19509,PropContentType "m\t\147\154\249\169\\\137V\224\t",PropReasonString +// "J\EMe_\213\196\176\242M4\180\153\246\237\242\fW}\169\246\&5J\151Y",PropReasonString "\216\194'^\203\162#"]) +TEST(PubACKREL5QCTest, Decode20) { + uint8_t pkt[] = {0x62, 0x3a, 0x6c, 0xcf, 0x8d, 0x36, 0x13, 0x4c, 0x35, 0x3, 0x0, 0xb, 0x6d, 0x9, 0x93, + 0x9a, 0xf9, 0xa9, 0x5c, 0x89, 0x56, 0xe0, 0x9, 0x1f, 0x0, 0x18, 0x4a, 0x19, 0x65, 0x5f, + 0xd5, 0xc4, 0xb0, 0xf2, 0x4d, 0x34, 0xb4, 0x99, 0xf6, 0xed, 0xf2, 0xc, 0x57, 0x7d, 0xa9, + 0xf6, 0x35, 0x4a, 0x97, 0x59, 0x1f, 0x0, 0x7, 0xd8, 0xc2, 0x27, 0x5e, 0xcb, 0xa2, 0x23}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 27855); + EXPECT_EQ(status, 141); +} + +// REL (PubREL 3263 165 [PropWillDelayInterval 32544,PropResponseTopic "\137{\DC2\203",PropWillDelayInterval +// 23614,PropUserProperty "\168\DLET\187\239" +// "Mzl\aL~\247-\196\176\128\t\133b\n\139\156\SYN\215$",PropMessageExpiryInterval +// 21151,PropSubscriptionIdentifierAvailable 159,PropServerReference +// "\251p\131\223iH\195\165L*\SO\148\147\163\166aNK4\155?U\DC4j?\EM\245",PropTopicAlias 1847,PropMaximumPacketSize +// 21817,PropSubscriptionIdentifierAvailable 13,PropServerKeepAlive 6055]) +TEST(PubACKREL5QCTest, Encode21) { + uint8_t pkt[] = {0x62, 0x65, 0xc, 0xbf, 0xa5, 0x61, 0x18, 0x0, 0x0, 0x7f, 0x20, 0x8, 0x0, 0x4, 0x89, + 0x7b, 0x12, 0xcb, 0x18, 0x0, 0x0, 0x5c, 0x3e, 0x26, 0x0, 0x5, 0xa8, 0x10, 0x54, 0xbb, + 0xef, 0x0, 0x14, 0x4d, 0x7a, 0x6c, 0x7, 0x4c, 0x7e, 0xf7, 0x2d, 0xc4, 0xb0, 0x80, 0x9, + 0x85, 0x62, 0xa, 0x8b, 0x9c, 0x16, 0xd7, 0x24, 0x2, 0x0, 0x0, 0x52, 0x9f, 0x29, 0x9f, + 0x1c, 0x0, 0x1b, 0xfb, 0x70, 0x83, 0xdf, 0x69, 0x48, 0xc3, 0xa5, 0x4c, 0x2a, 0xe, 0x94, + 0x93, 0xa3, 0xa6, 0x61, 0x4e, 0x4b, 0x34, 0x9b, 0x3f, 0x55, 0x14, 0x6a, 0x3f, 0x19, 0xf5, + 0x23, 0x7, 0x37, 0x27, 0x0, 0x0, 0x55, 0x39, 0x29, 0xd, 0x13, 0x17, 0xa7}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0x89, 0x7b, 0x12, 0xcb}; + uint8_t bytesprops2[] = {0x4d, 0x7a, 0x6c, 0x7, 0x4c, 0x7e, 0xf7, 0x2d, 0xc4, 0xb0, + 0x80, 0x9, 0x85, 0x62, 0xa, 0x8b, 0x9c, 0x16, 0xd7, 0x24}; + uint8_t bytesprops1[] = {0xa8, 0x10, 0x54, 0xbb, 0xef}; + uint8_t bytesprops3[] = {0xfb, 0x70, 0x83, 0xdf, 0x69, 0x48, 0xc3, 0xa5, 0x4c, 0x2a, 0xe, 0x94, 0x93, 0xa3, + 0xa6, 0x61, 0x4e, 0x4b, 0x34, 0x9b, 0x3f, 0x55, 0x14, 0x6a, 0x3f, 0x19, 0xf5}; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x19, 0xa2, 0xda, 0xe2, 0x51, 0xb3, 0x7d, 0xd3, - 0x17, 0xf2, 0xbc, 0x9d, 0x28, 0x96, 0x37, 0x2d}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x92, 0x23, 0x4b, 0x18, 0x2d, 0x37, 0x77, 0xa1, 0xe4, 0x9d}; - lwmqtt_string_t will_payload = {10, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 618; - uint8_t client_id_bytes[] = {0xc1, 0x96, 0x5}; - lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x55, 0x62}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32544}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23614}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops1}, .v = {20, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21151}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1847}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21817}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6055}}, + }; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 3263, 165, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just -// "\212\178\194\175\",\DC4\189\220\226\206U\131Q\182\202p\244\242D;\212\175m*\194WT\207", _password = Nothing, -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\DC24\133\225%k\SOHa\149\232\DC3}q\224", _willMsg = "\226\225\232\214\198L7\156\&6H\247\231\176X'm", _willProps = -// [PropRequestResponseInformation 60,PropMaximumQoS 151,PropServerReference "\175K\156",PropResponseTopic -// "P3\246S\222\&3\172\246\179\&4\DC3\r\220\&0\147\200|\204\174I\GS\203 \216\199d$",PropResponseInformation -// "\220\196\163\176\SYNy6\"\154\214\244\160\233\&9u\163\251\185",PropReasonString -// "6\214\n\182\231\180\&3x\176g\142r?F\218\&4&P T\214\188\238\141\171\229,\160",PropRetainAvailable -// 170,PropUserProperty "p\231\183\DC2\181\143\217\224\158\159snl\204\SO\151" -// "\219\148\139l\211x\221\143\240\187",PropWildcardSubscriptionAvailable 5]}), _cleanSession = True, _keepAlive = 5852, -// _connID = "|\199", _properties = [PropMaximumQoS 226,PropContentType " -// ,\ETB\189c\a^\181\200{\NUL\163\DLE\NAK\215g\"6\156'\169\215h\199\249\179\210\130+\144",PropServerReference -// "K\183T\166\151L\234\143\193\234C:\134\GS\220\138\206\179",PropSharedSubscriptionAvailable 218,PropMaximumQoS -// 115,PropContentType "MkR\DLEx\252\148j\174C\187\182\220\161\250",PropTopicAliasMaximum 18250,PropRetainAvailable -// 97,PropMessageExpiryInterval 18382,PropMaximumQoS 171,PropSubscriptionIdentifierAvailable -// 58,PropRequestResponseInformation 98,PropAssignedClientIdentifier -// "\168}\160\147\NAK\128V\DC1\214\177\v<\DC44\218\179",PropReasonString -// "\STX2\227.PW\187\161z\148\170\217\174\\\227<|\204\&4\204N\245\SI&z\173v=\233"]} -TEST(Connect5QCTest, Encode17) { +// REL (PubREL 3263 165 [PropWillDelayInterval 32544,PropResponseTopic "\137{\DC2\203",PropWillDelayInterval +// 23614,PropUserProperty "\168\DLET\187\239" +// "Mzl\aL~\247-\196\176\128\t\133b\n\139\156\SYN\215$",PropMessageExpiryInterval +// 21151,PropSubscriptionIdentifierAvailable 159,PropServerReference +// "\251p\131\223iH\195\165L*\SO\148\147\163\166aNK4\155?U\DC4j?\EM\245",PropTopicAlias 1847,PropMaximumPacketSize +// 21817,PropSubscriptionIdentifierAvailable 13,PropServerKeepAlive 6055]) +TEST(PubACKREL5QCTest, Decode21) { + uint8_t pkt[] = {0x62, 0x65, 0xc, 0xbf, 0xa5, 0x61, 0x18, 0x0, 0x0, 0x7f, 0x20, 0x8, 0x0, 0x4, 0x89, + 0x7b, 0x12, 0xcb, 0x18, 0x0, 0x0, 0x5c, 0x3e, 0x26, 0x0, 0x5, 0xa8, 0x10, 0x54, 0xbb, + 0xef, 0x0, 0x14, 0x4d, 0x7a, 0x6c, 0x7, 0x4c, 0x7e, 0xf7, 0x2d, 0xc4, 0xb0, 0x80, 0x9, + 0x85, 0x62, 0xa, 0x8b, 0x9c, 0x16, 0xd7, 0x24, 0x2, 0x0, 0x0, 0x52, 0x9f, 0x29, 0x9f, + 0x1c, 0x0, 0x1b, 0xfb, 0x70, 0x83, 0xdf, 0x69, 0x48, 0xc3, 0xa5, 0x4c, 0x2a, 0xe, 0x94, + 0x93, 0xa3, 0xa6, 0x61, 0x4e, 0x4b, 0x34, 0x9b, 0x3f, 0x55, 0x14, 0x6a, 0x3f, 0x19, 0xf5, + 0x23, 0x7, 0x37, 0x27, 0x0, 0x0, 0x55, 0x39, 0x29, 0xd, 0x13, 0x17, 0xa7}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 3263); + EXPECT_EQ(status, 165); +} + +// ACK (PubACK 4790 175 [PropMaximumQoS 117,PropReasonString +// "\181\DLE\138gK<\208\137\191(\b\171J\248",PropPayloadFormatIndicator 127,PropReasonString +// "\230\227T'",PropAssignedClientIdentifier "\151\246<",PropPayloadFormatIndicator 43,PropRequestResponseInformation +// 68,PropSharedSubscriptionAvailable 86,PropResponseInformation +// "\DC46\138\142\169^\ACKI\169#\158",PropTopicAliasMaximum 10914,PropMaximumPacketSize 27768,PropPayloadFormatIndicator +// 121,PropAuthenticationMethod "\244+",PropMaximumPacketSize 10461,PropPayloadFormatIndicator 40,PropUserProperty +// "\135\n\128\&5\253Q)\189\252\183\149&\146\180\226\254b\181\208B\NUL" +// "\151\230\165\&8\149Z\152\165\182\DC4\175\ETB\247\223Wd\DC3m8\250a&\DC2\147\t6%0jF",PropMessageExpiryInterval +// 8278,PropUserProperty "\211\NUL\164[_,\164\136\254)\178=@\t!MY\243\139j\210F\225}" +// "\164\213\&7M/\212\193\163\164M0\234\145jIi\128\240\178\170\143\SOB\157W\EM",PropUserProperty +// "\DEL\n\198\185\NUL\DEL\217,\234\203\152#" +// "g\NUL\242\ETX\v\255\DC1\220<\235\175\FS\150f\FS\247",PropRequestResponseInformation 215,PropReceiveMaximum +// 27875,PropServerReference +// "{;`\241\188\ACK\229\155\&4H\189\DC4X\199\175\b\157\184\253\&5\141\231\152\142\145\212\211\&6",PropCorrelationData +// "\130@\234U\232\223l\179\185",PropAssignedClientIdentifier +// "[\193A\ENQz#\251\201\179:\213Z\161\ESC7M\SI\193%&",PropAssignedClientIdentifier +// ">\216\141E\166(\SO\172\128\151",PropMessageExpiryInterval 31417,PropMessageExpiryInterval +// 10052,PropWillDelayInterval 26979]) +TEST(PubACKACK5QCTest, Encode22) { uint8_t pkt[] = { - 0x10, 0xe2, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xae, 0x16, 0xdc, 0x91, 0x1, 0x24, 0xe2, 0x3, 0x0, - 0x1e, 0x20, 0x2c, 0x17, 0xbd, 0x63, 0x7, 0x5e, 0xb5, 0xc8, 0x7b, 0x0, 0xa3, 0x10, 0x15, 0xd7, 0x67, 0x22, 0x36, - 0x9c, 0x27, 0xa9, 0xd7, 0x68, 0xc7, 0xf9, 0xb3, 0xd2, 0x82, 0x2b, 0x90, 0x1c, 0x0, 0x12, 0x4b, 0xb7, 0x54, 0xa6, - 0x97, 0x4c, 0xea, 0x8f, 0xc1, 0xea, 0x43, 0x3a, 0x86, 0x1d, 0xdc, 0x8a, 0xce, 0xb3, 0x2a, 0xda, 0x24, 0x73, 0x3, - 0x0, 0xf, 0x4d, 0x6b, 0x52, 0x10, 0x78, 0xfc, 0x94, 0x6a, 0xae, 0x43, 0xbb, 0xb6, 0xdc, 0xa1, 0xfa, 0x22, 0x47, - 0x4a, 0x25, 0x61, 0x2, 0x0, 0x0, 0x47, 0xce, 0x24, 0xab, 0x29, 0x3a, 0x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x5, 0x0, 0xe, 0x12, 0x34, 0x85, 0xe1, 0x25, 0x6b, 0x1, 0x61, 0x95, 0xe8, - 0x13, 0x7d, 0x71, 0xe0, 0x0, 0x10, 0xe2, 0xe1, 0xe8, 0xd6, 0xc6, 0x4c, 0x37, 0x9c, 0x36, 0x48, 0xf7, 0xe7, 0xb0, - 0x58, 0x27, 0x6d, 0x0, 0x1d, 0xd4, 0xb2, 0xc2, 0xaf, 0x22, 0x2c, 0x14, 0xbd, 0xdc, 0xe2, 0xce, 0x55, 0x83, 0x51, - 0xb6, 0xca, 0x70, 0xf4, 0xf2, 0x44, 0x3b, 0xd4, 0xaf, 0x6d, 0x2a, 0xc2, 0x57, 0x54, 0xcf}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x20, 0x2c, 0x17, 0xbd, 0x63, 0x7, 0x5e, 0xb5, 0xc8, 0x7b, 0x0, 0xa3, 0x10, 0x15, 0xd7, - 0x67, 0x22, 0x36, 0x9c, 0x27, 0xa9, 0xd7, 0x68, 0xc7, 0xf9, 0xb3, 0xd2, 0x82, 0x2b, 0x90}; - uint8_t bytesprops1[] = {0x4b, 0xb7, 0x54, 0xa6, 0x97, 0x4c, 0xea, 0x8f, 0xc1, - 0xea, 0x43, 0x3a, 0x86, 0x1d, 0xdc, 0x8a, 0xce, 0xb3}; - uint8_t bytesprops2[] = {0x4d, 0x6b, 0x52, 0x10, 0x78, 0xfc, 0x94, 0x6a, 0xae, 0x43, 0xbb, 0xb6, 0xdc, 0xa1, 0xfa}; - uint8_t bytesprops3[] = {0xa8, 0x7d, 0xa0, 0x93, 0x15, 0x80, 0x56, 0x11, - 0xd6, 0xb1, 0xb, 0x3c, 0x14, 0x34, 0xda, 0xb3}; - uint8_t bytesprops4[] = {0x2, 0x32, 0xe3, 0x2e, 0x50, 0x57, 0xbb, 0xa1, 0x7a, 0x94, 0xaa, 0xd9, 0xae, 0x5c, 0xe3, - 0x3c, 0x7c, 0xcc, 0x34, 0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 0x4d, 0x2f, 0xd4, 0xc1, 0xa3, 0xa4, 0x4d, 0x30, 0xea, 0x91, 0x6a, 0x49, 0x69, + 0x80, 0xf0, 0xb2, 0xaa, 0x8f, 0xe, 0x42, 0x9d, 0x57, 0x19, 0x26, 0x0, 0xc, 0x7f, 0xa, 0xc6, 0xb9, 0x0, 0x7f, + 0xd9, 0x2c, 0xea, 0xcb, 0x98, 0x23, 0x0, 0x10, 0x67, 0x0, 0xf2, 0x3, 0xb, 0xff, 0x11, 0xdc, 0x3c, 0xeb, 0xaf, + 0x1c, 0x96, 0x66, 0x1c, 0xf7, 0x19, 0xd7, 0x21, 0x6c, 0xe3, 0x1c, 0x0, 0x1c, 0x7b, 0x3b, 0x60, 0xf1, 0xbc, 0x6, + 0xe5, 0x9b, 0x34, 0x48, 0xbd, 0x14, 0x58, 0xc7, 0xaf, 0x8, 0x9d, 0xb8, 0xfd, 0x35, 0x8d, 0xe7, 0x98, 0x8e, 0x91, + 0xd4, 0xd3, 0x36, 0x9, 0x0, 0x9, 0x82, 0x40, 0xea, 0x55, 0xe8, 0xdf, 0x6c, 0xb3, 0xb9, 0x12, 0x0, 0x14, 0x5b, + 0xc1, 0x41, 0x5, 0x7a, 0x23, 0xfb, 0xc9, 0xb3, 0x3a, 0xd5, 0x5a, 0xa1, 0x1b, 0x37, 0x4d, 0xf, 0xc1, 0x25, 0x26, + 0x12, 0x0, 0xa, 0x3e, 0xd8, 0x8d, 0x45, 0xa6, 0x28, 0xe, 0xac, 0x80, 0x97, 0x2, 0x0, 0x0, 0x7a, 0xb9, 0x2, + 0x0, 0x0, 0x27, 0x44, 0x18, 0x0, 0x0, 0x69, 0x63}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0xb5, 0x10, 0x8a, 0x67, 0x4b, 0x3c, 0xd0, 0x89, 0xbf, 0x28, 0x8, 0xab, 0x4a, 0xf8}; + uint8_t bytesprops1[] = {0xe6, 0xe3, 0x54, 0x27}; + uint8_t bytesprops2[] = {0x97, 0xf6, 0x3c}; + uint8_t bytesprops3[] = {0x14, 0x36, 0x8a, 0x8e, 0xa9, 0x5e, 0x6, 0x49, 0xa9, 0x23, 0x9e}; + uint8_t bytesprops4[] = {0xf4, 0x2b}; + uint8_t bytesprops6[] = {0x97, 0xe6, 0xa5, 0x38, 0x95, 0x5a, 0x98, 0xa5, 0xb6, 0x14, 0xaf, 0x17, 0xf7, 0xdf, 0x57, + 0x64, 0x13, 0x6d, 0x38, 0xfa, 0x61, 0x26, 0x12, 0x93, 0x9, 0x36, 0x25, 0x30, 0x6a, 0x46}; + uint8_t bytesprops5[] = {0x87, 0xa, 0x80, 0x35, 0xfd, 0x51, 0x29, 0xbd, 0xfc, 0xb7, 0x95, + 0x26, 0x92, 0xb4, 0xe2, 0xfe, 0x62, 0xb5, 0xd0, 0x42, 0x0}; + uint8_t bytesprops8[] = {0xa4, 0xd5, 0x37, 0x4d, 0x2f, 0xd4, 0xc1, 0xa3, 0xa4, 0x4d, 0x30, 0xea, 0x91, + 0x6a, 0x49, 0x69, 0x80, 0xf0, 0xb2, 0xaa, 0x8f, 0xe, 0x42, 0x9d, 0x57, 0x19}; + uint8_t bytesprops7[] = {0xd3, 0x0, 0xa4, 0x5b, 0x5f, 0x2c, 0xa4, 0x88, 0xfe, 0x29, 0xb2, 0x3d, + 0x40, 0x9, 0x21, 0x4d, 0x59, 0xf3, 0x8b, 0x6a, 0xd2, 0x46, 0xe1, 0x7d}; + uint8_t bytesprops10[] = {0x67, 0x0, 0xf2, 0x3, 0xb, 0xff, 0x11, 0xdc, + 0x3c, 0xeb, 0xaf, 0x1c, 0x96, 0x66, 0x1c, 0xf7}; + uint8_t bytesprops9[] = {0x7f, 0xa, 0xc6, 0xb9, 0x0, 0x7f, 0xd9, 0x2c, 0xea, 0xcb, 0x98, 0x23}; + uint8_t bytesprops11[] = {0x7b, 0x3b, 0x60, 0xf1, 0xbc, 0x6, 0xe5, 0x9b, 0x34, 0x48, 0xbd, 0x14, 0x58, 0xc7, + 0xaf, 0x8, 0x9d, 0xb8, 0xfd, 0x35, 0x8d, 0xe7, 0x98, 0x8e, 0x91, 0xd4, 0xd3, 0x36}; + uint8_t bytesprops12[] = {0x82, 0x40, 0xea, 0x55, 0xe8, 0xdf, 0x6c, 0xb3, 0xb9}; + uint8_t bytesprops13[] = {0x5b, 0xc1, 0x41, 0x5, 0x7a, 0x23, 0xfb, 0xc9, 0xb3, 0x3a, + 0xd5, 0x5a, 0xa1, 0x1b, 0x37, 0x4d, 0xf, 0xc1, 0x25, 0x26}; + uint8_t bytesprops14[] = {0x3e, 0xd8, 0x8d, 0x45, 0xa6, 0x28, 0xe, 0xac, 0x80, 0x97}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18250}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18382}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops4}}}, - }; - - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xaf, 0x4b, 0x9c}; - uint8_t byteswillprops1[] = {0x50, 0x33, 0xf6, 0x53, 0xde, 0x33, 0xac, 0xf6, 0xb3, 0x34, 0x13, 0xd, 0xdc, 0x30, - 0x93, 0xc8, 0x7c, 0xcc, 0xae, 0x49, 0x1d, 0xcb, 0x20, 0xd8, 0xc7, 0x64, 0x24}; - uint8_t byteswillprops2[] = {0xdc, 0xc4, 0xa3, 0xb0, 0x16, 0x79, 0x36, 0x22, 0x9a, - 0xd6, 0xf4, 0xa0, 0xe9, 0x39, 0x75, 0xa3, 0xfb, 0xb9}; - uint8_t byteswillprops3[] = {0x36, 0xd6, 0xa, 0xb6, 0xe7, 0xb4, 0x33, 0x78, 0xb0, 0x67, 0x8e, 0x72, 0x3f, 0x46, - 0xda, 0x34, 0x26, 0x50, 0x20, 0x54, 0xd6, 0xbc, 0xee, 0x8d, 0xab, 0xe5, 0x2c, 0xa0}; - uint8_t byteswillprops5[] = {0xdb, 0x94, 0x8b, 0x6c, 0xd3, 0x78, 0xdd, 0x8f, 0xf0, 0xbb}; - uint8_t byteswillprops4[] = {0x70, 0xe7, 0xb7, 0x12, 0xb5, 0x8f, 0xd9, 0xe0, - 0x9e, 0x9f, 0x73, 0x6e, 0x6c, 0xcc, 0xe, 0x97}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {16, (char*)&byteswillprops4}, .v = {10, (char*)&byteswillprops5}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10914}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27768}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10461}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops5}, .v = {30, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8278}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops7}, .v = {26, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops9}, .v = {16, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27875}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31417}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10052}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26979}}, }; - lwmqtt_properties_t willprops = {9, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x12, 0x34, 0x85, 0xe1, 0x25, 0x6b, 0x1, 0x61, 0x95, 0xe8, 0x13, 0x7d, 0x71, 0xe0}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe2, 0xe1, 0xe8, 0xd6, 0xc6, 0x4c, 0x37, 0x9c, - 0x36, 0x48, 0xf7, 0xe7, 0xb0, 0x58, 0x27, 0x6d}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 5852; - uint8_t client_id_bytes[] = {0x7c, 0xc7}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0xd4, 0xb2, 0xc2, 0xaf, 0x22, 0x2c, 0x14, 0xbd, 0xdc, 0xe2, 0xce, 0x55, 0x83, 0x51, 0xb6, - 0xca, 0x70, 0xf4, 0xf2, 0x44, 0x3b, 0xd4, 0xaf, 0x6d, 0x2a, 0xc2, 0x57, 0x54, 0xcf}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 4790, 175, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "2\DC1\197\140\172\STX\245\224", _password = Just -// "C\232\160\f\216\162\204\154\165\248\249\194\&5g\172\177\236\DC2\EOT\245\214\156", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = -// "$\RSC_\156\STX\165$\246x_\195(]^\f\a%\232O\vf\"\180\174\135\223!8`", _willMsg = -// "\190'c\128\&6\169\239\f\a\GS\246\152}\153\215\ACK\SOH9\248\193A\224\237\179", _willProps = -// [PropSessionExpiryInterval 28866,PropMessageExpiryInterval 5544,PropAuthenticationData -// "\170\250\133s\NAK\140\167\t\209",PropTopicAliasMaximum 28843,PropMessageExpiryInterval -// 11044,PropAssignedClientIdentifier "\180T8\237}\182\204\RSr",PropAuthenticationMethod "\138\179 -// ?",PropSessionExpiryInterval 27762,PropMaximumPacketSize 16384,PropResponseTopic -// "W\235\149U",PropMessageExpiryInterval 14766,PropWillDelayInterval 26866,PropWillDelayInterval -// 8680,PropMaximumPacketSize 16961,PropMessageExpiryInterval 6312,PropMaximumPacketSize 28045,PropRetainAvailable -// 220,PropSessionExpiryInterval 31091,PropSharedSubscriptionAvailable 27,PropWildcardSubscriptionAvailable -// 139,PropReceiveMaximum 19162,PropAuthenticationMethod -// "\188\170\148Z\CAN\211L\SUB\175\158#\192\236B\193V\162",PropWildcardSubscriptionAvailable -// 142,PropSharedSubscriptionAvailable 27]}), _cleanSession = True, _keepAlive = 12387, _connID = -// "\ETX\SYN\DC2\a\ETB\224\158xuW\n\236S\134\138\198\CAN\SI\bp", _properties = [PropContentType -// "\194\251\188\239\FS\176\180!\193\141\210 \251%e\203!\254\182k\SI",PropWildcardSubscriptionAvailable -// 207,PropMaximumPacketSize 3626,PropWillDelayInterval 12740,PropAuthenticationMethod -// "\DC4\STXj\145\185k\160\SYN\181\SUBlW\171\142\207j\177\v\192",PropMessageExpiryInterval 13928,PropServerKeepAlive -// 13861]} -TEST(Connect5QCTest, Encode18) { +// ACK (PubACK 4790 175 [PropMaximumQoS 117,PropReasonString +// "\181\DLE\138gK<\208\137\191(\b\171J\248",PropPayloadFormatIndicator 127,PropReasonString +// "\230\227T'",PropAssignedClientIdentifier "\151\246<",PropPayloadFormatIndicator 43,PropRequestResponseInformation +// 68,PropSharedSubscriptionAvailable 86,PropResponseInformation +// "\DC46\138\142\169^\ACKI\169#\158",PropTopicAliasMaximum 10914,PropMaximumPacketSize 27768,PropPayloadFormatIndicator +// 121,PropAuthenticationMethod "\244+",PropMaximumPacketSize 10461,PropPayloadFormatIndicator 40,PropUserProperty +// "\135\n\128\&5\253Q)\189\252\183\149&\146\180\226\254b\181\208B\NUL" +// "\151\230\165\&8\149Z\152\165\182\DC4\175\ETB\247\223Wd\DC3m8\250a&\DC2\147\t6%0jF",PropMessageExpiryInterval +// 8278,PropUserProperty "\211\NUL\164[_,\164\136\254)\178=@\t!MY\243\139j\210F\225}" +// "\164\213\&7M/\212\193\163\164M0\234\145jIi\128\240\178\170\143\SOB\157W\EM",PropUserProperty +// "\DEL\n\198\185\NUL\DEL\217,\234\203\152#" +// "g\NUL\242\ETX\v\255\DC1\220<\235\175\FS\150f\FS\247",PropRequestResponseInformation 215,PropReceiveMaximum +// 27875,PropServerReference +// "{;`\241\188\ACK\229\155\&4H\189\DC4X\199\175\b\157\184\253\&5\141\231\152\142\145\212\211\&6",PropCorrelationData +// "\130@\234U\232\223l\179\185",PropAssignedClientIdentifier +// "[\193A\ENQz#\251\201\179:\213Z\161\ESC7M\SI\193%&",PropAssignedClientIdentifier +// ">\216\141E\166(\SO\172\128\151",PropMessageExpiryInterval 31417,PropMessageExpiryInterval +// 10052,PropWillDelayInterval 26979]) +TEST(PubACKACK5QCTest, Decode22) { + uint8_t pkt[] = { +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, 0x6a, 0x49, 0x69, + 0x80, 0xf0, 0xb2, 0xaa, 0x8f, 0xe, 0x42, 0x9d, 0x57, 0x19, 0x26, 0x0, 0xc, 0x7f, 0xa, 0xc6, 0xb9, 0x0, 0x7f, + 0xd9, 0x2c, 0xea, 0xcb, 0x98, 0x23, 0x0, 0x10, 0x67, 0x0, 0xf2, 0x3, 0xb, 0xff, 0x11, 0xdc, 0x3c, 0xeb, 0xaf, + 0x1c, 0x96, 0x66, 0x1c, 0xf7, 0x19, 0xd7, 0x21, 0x6c, 0xe3, 0x1c, 0x0, 0x1c, 0x7b, 0x3b, 0x60, 0xf1, 0xbc, 0x6, + 0xe5, 0x9b, 0x34, 0x48, 0xbd, 0x14, 0x58, 0xc7, 0xaf, 0x8, 0x9d, 0xb8, 0xfd, 0x35, 0x8d, 0xe7, 0x98, 0x8e, 0x91, + 0xd4, 0xd3, 0x36, 0x9, 0x0, 0x9, 0x82, 0x40, 0xea, 0x55, 0xe8, 0xdf, 0x6c, 0xb3, 0xb9, 0x12, 0x0, 0x14, 0x5b, + 0xc1, 0x41, 0x5, 0x7a, 0x23, 0xfb, 0xc9, 0xb3, 0x3a, 0xd5, 0x5a, 0xa1, 0x1b, 0x37, 0x4d, 0xf, 0xc1, 0x25, 0x26, + 0x12, 0x0, 0xa, 0x3e, 0xd8, 0x8d, 0x45, 0xa6, 0x28, 0xe, 0xac, 0x80, 0x97, 0x2, 0x0, 0x0, 0x7a, 0xb9, 0x2, + 0x0, 0x0, 0x27, 0x44, 0x18, 0x0, 0x0, 0x69, 0x63}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 4790); + EXPECT_EQ(status, 175); +} + +// REL (PubREL 7224 239 [PropResponseInformation "\199[\249",PropServerReference +// "\f\DC3{(\200Z\154\ETBc\215\216\169A8\170\183\DC1\159\209\139\&0[\242\230\143m\242\&2",PropContentType +// "\196~\ESC",PropAuthenticationMethod "\152\&4P\136",PropSessionExpiryInterval 6962,PropWildcardSubscriptionAvailable +// 7,PropPayloadFormatIndicator 79,PropCorrelationData +// "\181\187\SOH\157\180\183m9x\137m\164\166\SUB\248\207D\186\140\162\183\&4\247\158\n\b",PropResponseInformation +// "{\DEL\245\EOT\240!\196\177h\146\SI\203a\CAN\231{G8\231\237wu8\186qq \RS",PropMessageExpiryInterval +// 188,PropTopicAlias 5684,PropSubscriptionIdentifier 3,PropServerReference +// "!L\185\237e\229\213\200\179",PropContentType "\GS\231\156T",PropTopicAliasMaximum 19004,PropMessageExpiryInterval +// 5773,PropRequestResponseInformation 61,PropMessageExpiryInterval 32275,PropTopicAliasMaximum +// 15152,PropSessionExpiryInterval 17393,PropRequestProblemInformation 50,PropSessionExpiryInterval 1871,PropMaximumQoS +// 106,PropAuthenticationMethod "!\SI\DC2L\160\240\215>=\221dyqs\158y\177",PropReasonString +// ")\166Rt\207\180[\215Mt\f\205\138\SOH-T\ACK\196ee\222H]\177\215\175~\193\198",PropSessionExpiryInterval +// 16563,PropSessionExpiryInterval 29528,PropContentType "B\163\DC4/\177q;@? \146{\144"]) +TEST(PubACKREL5QCTest, Encode23) { uint8_t pkt[] = { - 0x10, 0xc7, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x30, 0x63, 0x42, 0x3, 0x0, 0x15, 0xc2, 0xfb, - 0xbc, 0xef, 0x1c, 0xb0, 0xb4, 0x21, 0xc1, 0x8d, 0xd2, 0x20, 0xfb, 0x25, 0x65, 0xcb, 0x21, 0xfe, 0xb6, 0x6b, 0xf, - 0x28, 0xcf, 0x27, 0x0, 0x0, 0xe, 0x2a, 0x18, 0x0, 0x0, 0x31, 0xc4, 0x15, 0x0, 0x13, 0x14, 0x2, 0x6a, 0x91, - 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7e, 0xc1, 0xc6, 0x11, 0x0, 0x0, 0x40, 0xb3, 0x11, 0x0, + 0x0, 0x73, 0x58, 0x3, 0x0, 0xd, 0x42, 0xa3, 0x14, 0x2f, 0xb1, 0x71, 0x3b, 0x40, 0x3f, 0x20, 0x92, 0x7b, 0x90}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0xc7, 0x5b, 0xf9}; + uint8_t bytesprops1[] = {0xc, 0x13, 0x7b, 0x28, 0xc8, 0x5a, 0x9a, 0x17, 0x63, 0xd7, 0xd8, 0xa9, 0x41, 0x38, + 0xaa, 0xb7, 0x11, 0x9f, 0xd1, 0x8b, 0x30, 0x5b, 0xf2, 0xe6, 0x8f, 0x6d, 0xf2, 0x32}; + uint8_t bytesprops2[] = {0xc4, 0x7e, 0x1b}; + uint8_t bytesprops3[] = {0x98, 0x34, 0x50, 0x88}; + uint8_t bytesprops4[] = {0xb5, 0xbb, 0x1, 0x9d, 0xb4, 0xb7, 0x6d, 0x39, 0x78, 0x89, 0x6d, 0xa4, 0xa6, + 0x1a, 0xf8, 0xcf, 0x44, 0xba, 0x8c, 0xa2, 0xb7, 0x34, 0xf7, 0x9e, 0xa, 0x8}; + uint8_t bytesprops5[] = {0x7b, 0x7f, 0xf5, 0x4, 0xf0, 0x21, 0xc4, 0xb1, 0x68, 0x92, 0xf, 0xcb, 0x61, 0x18, + 0xe7, 0x7b, 0x47, 0x38, 0xe7, 0xed, 0x77, 0x75, 0x38, 0xba, 0x71, 0x71, 0x20, 0x1e}; + uint8_t bytesprops6[] = {0x21, 0x4c, 0xb9, 0xed, 0x65, 0xe5, 0xd5, 0xc8, 0xb3}; + uint8_t bytesprops7[] = {0x1d, 0xe7, 0x9c, 0x54}; + uint8_t bytesprops8[] = {0x21, 0xf, 0x12, 0x4c, 0xa0, 0xf0, 0xd7, 0x3e, 0x3d, + 0xdd, 0x64, 0x79, 0x71, 0x73, 0x9e, 0x79, 0xb1}; + uint8_t bytesprops9[] = {0x29, 0xa6, 0x52, 0x74, 0xcf, 0xb4, 0x5b, 0xd7, 0x4d, 0x74, 0xc, 0xcd, 0x8a, 0x1, 0x2d, + 0x54, 0x6, 0xc4, 0x65, 0x65, 0xde, 0x48, 0x5d, 0xb1, 0xd7, 0xaf, 0x7e, 0xc1, 0xc6}; + uint8_t bytesprops10[] = {0x42, 0xa3, 0x14, 0x2f, 0xb1, 0x71, 0x3b, 0x40, 0x3f, 0x20, 0x92, 0x7b, 0x90}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3626}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12740}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13928}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13861}}, - }; - - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xaa, 0xfa, 0x85, 0x73, 0x15, 0x8c, 0xa7, 0x9, 0xd1}; - uint8_t byteswillprops1[] = {0xb4, 0x54, 0x38, 0xed, 0x7d, 0xb6, 0xcc, 0x1e, 0x72}; - uint8_t byteswillprops2[] = {0x8a, 0xb3, 0x20, 0x3f}; - uint8_t byteswillprops3[] = {0x57, 0xeb, 0x95, 0x55}; - uint8_t byteswillprops4[] = {0xbc, 0xaa, 0x94, 0x5a, 0x18, 0xd3, 0x4c, 0x1a, 0xaf, - 0x9e, 0x23, 0xc0, 0xec, 0x42, 0xc1, 0x56, 0xa2}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28866}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5544}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28843}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11044}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27762}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16384}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14766}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26866}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8680}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16961}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6312}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28045}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31091}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19162}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6962}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 188}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5684}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19004}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5773}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32275}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15152}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17393}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1871}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16563}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29528}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x24, 0x1e, 0x43, 0x5f, 0x9c, 0x2, 0xa5, 0x24, 0xf6, 0x78, - 0x5f, 0xc3, 0x28, 0x5d, 0x5e, 0xc, 0x7, 0x25, 0xe8, 0x4f, - 0xb, 0x66, 0x22, 0xb4, 0xae, 0x87, 0xdf, 0x21, 0x38, 0x60}; - lwmqtt_string_t will_topic = {30, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xbe, 0x27, 0x63, 0x80, 0x36, 0xa9, 0xef, 0xc, 0x7, 0x1d, 0xf6, 0x98, - 0x7d, 0x99, 0xd7, 0x6, 0x1, 0x39, 0xf8, 0xc1, 0x41, 0xe0, 0xed, 0xb3}; - lwmqtt_string_t will_payload = {24, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 12387; - uint8_t client_id_bytes[] = {0x3, 0x16, 0x12, 0x7, 0x17, 0xe0, 0x9e, 0x78, 0x75, 0x57, - 0xa, 0xec, 0x53, 0x86, 0x8a, 0xc6, 0x18, 0xf, 0x8, 0x70}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x32, 0x11, 0xc5, 0x8c, 0xac, 0x2, 0xf5, 0xe0}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x43, 0xe8, 0xa0, 0xc, 0xd8, 0xa2, 0xcc, 0x9a, 0xa5, 0xf8, 0xf9, - 0xc2, 0x35, 0x67, 0xac, 0xb1, 0xec, 0x12, 0x4, 0xf5, 0xd6, 0x9c}; - lwmqtt_string_t password = {22, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 7224, 239, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "m\224J\233E\DC3\ETB\NUL`\145\194\ETXi", _lastWill = Nothing, -// _cleanSession = True, _keepAlive = 8004, _connID = "\152\175\205\ESC\239\142|}6k\238\178", _properties = -// [PropWildcardSubscriptionAvailable 80,PropRetainAvailable 187,PropReceiveMaximum 22643,PropResponseInformation -// "\187\173\&8\139\232!=",PropTopicAliasMaximum 32061,PropSharedSubscriptionAvailable 144,PropMessageExpiryInterval -// 21234,PropServerKeepAlive 17963,PropPayloadFormatIndicator 196,PropServerReference -// "\196\&4dF+]\206jD]\217\206\168^\138\248U\253\141\SOH\STX\222\186\184",PropMessageExpiryInterval -// 7126,PropWildcardSubscriptionAvailable 228,PropPayloadFormatIndicator 253,PropSessionExpiryInterval -// 14518,PropResponseInformation -// "\219\249\154\SYN/\139\177\142v\188\153\189\148\216XtX\139\237c\219B",PropRetainAvailable -// 4,PropRequestResponseInformation 105,PropSubscriptionIdentifierAvailable 243,PropMessageExpiryInterval -// 15556,PropTopicAliasMaximum 20230,PropServerReference -// "G\225\nh\248\NUL%\254\193S\131\227,b\137l\ACK\DC2.\STX0\222l\143\142\228\128\135",PropReceiveMaximum -// 20167,PropMessageExpiryInterval 26552,PropTopicAliasMaximum 18024]} -TEST(Connect5QCTest, Encode19) { - uint8_t pkt[] = {0x10, 0xc3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x42, 0x1f, 0x44, 0x9a, 0x1, 0x28, 0x50, - 0x25, 0xbb, 0x21, 0x58, 0x73, 0x1a, 0x0, 0x7, 0xbb, 0xad, 0x38, 0x8b, 0xe8, 0x21, 0x3d, 0x22, 0x7d, - 0x3d, 0x2a, 0x90, 0x2, 0x0, 0x0, 0x52, 0xf2, 0x13, 0x46, 0x2b, 0x1, 0xc4, 0x1c, 0x0, 0x18, 0xc4, - 0x34, 0x64, 0x46, 0x2b, 0x5d, 0xce, 0x6a, 0x44, 0x5d, 0xd9, 0xce, 0xa8, 0x5e, 0x8a, 0xf8, 0x55, 0xfd, - 0x8d, 0x1, 0x2, 0xde, 0xba, 0xb8, 0x2, 0x0, 0x0, 0x1b, 0xd6, 0x28, 0xe4, 0x1, 0xfd, 0x11, 0x0, - 0x0, 0x38, 0xb6, 0x1a, 0x0, 0x16, 0xdb, 0xf9, 0x9a, 0x16, 0x2f, 0x8b, 0xb1, 0x8e, 0x76, 0xbc, 0x99, - 0xbd, 0x94, 0xd8, 0x58, 0x74, 0x58, 0x8b, 0xed, 0x63, 0xdb, 0x42, 0x25, 0x4, 0x19, 0x69, 0x29, 0xf3, - 0x2, 0x0, 0x0, 0x3c, 0xc4, 0x22, 0x4f, 0x6, 0x1c, 0x0, 0x1c, 0x47, 0xe1, 0xa, 0x68, 0xf8, 0x0, - 0x25, 0xfe, 0xc1, 0x53, 0x83, 0xe3, 0x2c, 0x62, 0x89, 0x6c, 0x6, 0x12, 0x2e, 0x2, 0x30, 0xde, 0x6c, - 0x8f, 0x8e, 0xe4, 0x80, 0x87, 0x21, 0x4e, 0xc7, 0x2, 0x0, 0x0, 0x67, 0xb8, 0x22, 0x46, 0x68, 0x0, - 0xc, 0x98, 0xaf, 0xcd, 0x1b, 0xef, 0x8e, 0x7c, 0x7d, 0x36, 0x6b, 0xee, 0xb2, 0x0, 0xd, 0x6d, 0xe0, - 0x4a, 0xe9, 0x45, 0x13, 0x17, 0x0, 0x60, 0x91, 0xc2, 0x3, 0x69}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xbb, 0xad, 0x38, 0x8b, 0xe8, 0x21, 0x3d}; - uint8_t bytesprops1[] = {0xc4, 0x34, 0x64, 0x46, 0x2b, 0x5d, 0xce, 0x6a, 0x44, 0x5d, 0xd9, 0xce, - 0xa8, 0x5e, 0x8a, 0xf8, 0x55, 0xfd, 0x8d, 0x1, 0x2, 0xde, 0xba, 0xb8}; - uint8_t bytesprops2[] = {0xdb, 0xf9, 0x9a, 0x16, 0x2f, 0x8b, 0xb1, 0x8e, 0x76, 0xbc, 0x99, - 0xbd, 0x94, 0xd8, 0x58, 0x74, 0x58, 0x8b, 0xed, 0x63, 0xdb, 0x42}; - uint8_t bytesprops3[] = {0x47, 0xe1, 0xa, 0x68, 0xf8, 0x0, 0x25, 0xfe, 0xc1, 0x53, 0x83, 0xe3, 0x2c, 0x62, - 0x89, 0x6c, 0x6, 0x12, 0x2e, 0x2, 0x30, 0xde, 0x6c, 0x8f, 0x8e, 0xe4, 0x80, 0x87}; +// REL (PubREL 7224 239 [PropResponseInformation "\199[\249",PropServerReference +// "\f\DC3{(\200Z\154\ETBc\215\216\169A8\170\183\DC1\159\209\139\&0[\242\230\143m\242\&2",PropContentType +// "\196~\ESC",PropAuthenticationMethod "\152\&4P\136",PropSessionExpiryInterval 6962,PropWildcardSubscriptionAvailable +// 7,PropPayloadFormatIndicator 79,PropCorrelationData +// "\181\187\SOH\157\180\183m9x\137m\164\166\SUB\248\207D\186\140\162\183\&4\247\158\n\b",PropResponseInformation +// "{\DEL\245\EOT\240!\196\177h\146\SI\203a\CAN\231{G8\231\237wu8\186qq \RS",PropMessageExpiryInterval +// 188,PropTopicAlias 5684,PropSubscriptionIdentifier 3,PropServerReference +// "!L\185\237e\229\213\200\179",PropContentType "\GS\231\156T",PropTopicAliasMaximum 19004,PropMessageExpiryInterval +// 5773,PropRequestResponseInformation 61,PropMessageExpiryInterval 32275,PropTopicAliasMaximum +// 15152,PropSessionExpiryInterval 17393,PropRequestProblemInformation 50,PropSessionExpiryInterval 1871,PropMaximumQoS +// 106,PropAuthenticationMethod "!\SI\DC2L\160\240\215>=\221dyqs\158y\177",PropReasonString +// ")\166Rt\207\180[\215Mt\f\205\138\SOH-T\ACK\196ee\222H]\177\215\175~\193\198",PropSessionExpiryInterval +// 16563,PropSessionExpiryInterval 29528,PropContentType "B\163\DC4/\177q;@? \146{\144"]) +TEST(PubACKREL5QCTest, Decode23) { + uint8_t pkt[] = { + 0x62, 0x87, 0x2, 0x1c, 0x38, 0xef, 0x82, 0x2, 0x1a, 0x0, 0x3, 0xc7, 0x5b, 0xf9, 0x1c, 0x0, 0x1c, 0xc, 0x13, + 0x7b, 0x28, 0xc8, 0x5a, 0x9a, 0x17, 0x63, 0xd7, 0xd8, 0xa9, 0x41, 0x38, 0xaa, 0xb7, 0x11, 0x9f, 0xd1, 0x8b, 0x30, + 0x5b, 0xf2, 0xe6, 0x8f, 0x6d, 0xf2, 0x32, 0x3, 0x0, 0x3, 0xc4, 0x7e, 0x1b, 0x15, 0x0, 0x4, 0x98, 0x34, 0x50, + 0x88, 0x11, 0x0, 0x0, 0x1b, 0x32, 0x28, 0x7, 0x1, 0x4f, 0x9, 0x0, 0x1a, 0xb5, 0xbb, 0x1, 0x9d, 0xb4, 0xb7, + 0x6d, 0x39, 0x78, 0x89, 0x6d, 0xa4, 0xa6, 0x1a, 0xf8, 0xcf, 0x44, 0xba, 0x8c, 0xa2, 0xb7, 0x34, 0xf7, 0x9e, 0xa, + 0x8, 0x1a, 0x0, 0x1c, 0x7b, 0x7f, 0xf5, 0x4, 0xf0, 0x21, 0xc4, 0xb1, 0x68, 0x92, 0xf, 0xcb, 0x61, 0x18, 0xe7, + 0x7b, 0x47, 0x38, 0xe7, 0xed, 0x77, 0x75, 0x38, 0xba, 0x71, 0x71, 0x20, 0x1e, 0x2, 0x0, 0x0, 0x0, 0xbc, 0x23, + 0x16, 0x34, 0xb, 0x3, 0x1c, 0x0, 0x9, 0x21, 0x4c, 0xb9, 0xed, 0x65, 0xe5, 0xd5, 0xc8, 0xb3, 0x3, 0x0, 0x4, + 0x1d, 0xe7, 0x9c, 0x54, 0x22, 0x4a, 0x3c, 0x2, 0x0, 0x0, 0x16, 0x8d, 0x19, 0x3d, 0x2, 0x0, 0x0, 0x7e, 0x13, + 0x22, 0x3b, 0x30, 0x11, 0x0, 0x0, 0x43, 0xf1, 0x17, 0x32, 0x11, 0x0, 0x0, 0x7, 0x4f, 0x24, 0x6a, 0x15, 0x0, + 0x11, 0x21, 0xf, 0x12, 0x4c, 0xa0, 0xf0, 0xd7, 0x3e, 0x3d, 0xdd, 0x64, 0x79, 0x71, 0x73, 0x9e, 0x79, 0xb1, 0x1f, + 0x0, 0x1d, 0x29, 0xa6, 0x52, 0x74, 0xcf, 0xb4, 0x5b, 0xd7, 0x4d, 0x74, 0xc, 0xcd, 0x8a, 0x1, 0x2d, 0x54, 0x6, + 0xc4, 0x65, 0x65, 0xde, 0x48, 0x5d, 0xb1, 0xd7, 0xaf, 0x7e, 0xc1, 0xc6, 0x11, 0x0, 0x0, 0x40, 0xb3, 0x11, 0x0, + 0x0, 0x73, 0x58, 0x3, 0x0, 0xd, 0x42, 0xa3, 0x14, 0x2f, 0xb1, 0x71, 0x3b, 0x40, 0x3f, 0x20, 0x92, 0x7b, 0x90}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 7224); + EXPECT_EQ(status, 239); +} + +// REL (PubREL 15593 241 [PropSubscriptionIdentifier 15,PropServerReference "g\155\204r",PropContentType +// "~\185\214g\196n\162\178j\STX\242\145\130\140\162~j\176\220'\201\163\NAK\131\166\143\GS",PropSubscriptionIdentifierAvailable +// 86,PropServerReference "5;\132zUx\169azP",PropResponseTopic +// "\139\226\248\211R=9\227\&3\195\247-;@k",PropResponseTopic "q\185yDL\184\189", _properties = [PropReceiveMaximum 6419,PropUserProperty "\STX\194\196\164\209@\152\NUL\248\149a\ENQL" -// "}\167h6tf0h!\200L\STX\SIv\190\183\165\225\DC3\217\237$\173\&4\tK\FS\149\221\GS",PropAuthenticationData -// "\182",PropRequestProblemInformation 122,PropAssignedClientIdentifier "",PropMessageExpiryInterval -// 23247,PropRequestProblemInformation 18,PropMaximumPacketSize 25523,PropWildcardSubscriptionAvailable -// 88,PropMaximumPacketSize 27103,PropSubscriptionIdentifier 30,PropSubscriptionIdentifierAvailable -// 145,PropTopicAliasMaximum 11597,PropResponseTopic -// "\178M\160PH\183\241\149\DLE\144\150y\233\ENQ\253\233\148\SO\DC4\212\222\b\246\182\DC4\vG",PropServerReference -// "L\224",PropMessageExpiryInterval 31337,PropResponseTopic -// "\ACK\130S\DC3\159>\232\132\&3\175\184\149\191\255x\SOH\NAK",PropMaximumQoS 247]} -TEST(Connect5QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0xae, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x4c, 0x34, 0x94, 0x1, 0x21, 0x19, - 0x13, 0x26, 0x0, 0xd, 0x2, 0xc2, 0xc4, 0xa4, 0xd1, 0x40, 0x98, 0x0, 0xf8, 0x95, 0x61, 0x5, 0x4c, - 0x0, 0x1e, 0x7d, 0xa7, 0x68, 0x36, 0x74, 0x66, 0x30, 0x68, 0x21, 0xc8, 0x4c, 0x2, 0xf, 0x76, 0xbe, - 0xb7, 0xa5, 0xe1, 0x13, 0xd9, 0xed, 0x24, 0xad, 0x34, 0x9, 0x4b, 0x1c, 0x95, 0xdd, 0x1d, 0x16, 0x0, - 0x1, 0xb6, 0x17, 0x7a, 0x12, 0x0, 0x0, 0x2, 0x0, 0x0, 0x5a, 0xcf, 0x17, 0x12, 0x27, 0x0, 0x0, - 0x63, 0xb3, 0x28, 0x58, 0x27, 0x0, 0x0, 0x69, 0xdf, 0xb, 0x1e, 0x29, 0x91, 0x22, 0x2d, 0x4d, 0x8, - 0x0, 0x1b, 0xb2, 0x4d, 0xa0, 0x50, 0x48, 0xb7, 0xf1, 0x95, 0x10, 0x90, 0x96, 0x79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, 0x4c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x7d, 0xa7, 0x68, 0x36, 0x74, 0x66, 0x30, 0x68, 0x21, 0xc8, 0x4c, 0x2, 0xf, 0x76, 0xbe, - 0xb7, 0xa5, 0xe1, 0x13, 0xd9, 0xed, 0x24, 0xad, 0x34, 0x9, 0x4b, 0x1c, 0x95, 0xdd, 0x1d}; - uint8_t bytesprops0[] = {0x2, 0xc2, 0xc4, 0xa4, 0xd1, 0x40, 0x98, 0x0, 0xf8, 0x95, 0x61, 0x5, 0x4c}; - uint8_t bytesprops2[] = {0xb6}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0xb2, 0x4d, 0xa0, 0x50, 0x48, 0xb7, 0xf1, 0x95, 0x10, 0x90, 0x96, 0x79, 0xe9, 0x5, - 0xfd, 0xe9, 0x94, 0xe, 0x14, 0xd4, 0xde, 0x8, 0xf6, 0xb6, 0x14, 0xb, 0x47}; - uint8_t bytesprops5[] = {0x4c, 0xe0}; - uint8_t bytesprops6[] = {0x6, 0x82, 0x53, 0x13, 0x9f, 0x3e, 0xe8, 0x84, 0x33, - 0xaf, 0xb8, 0x95, 0xbf, 0xff, 0x78, 0x1, 0x15}; +// REL (PubREL 15593 241 [PropSubscriptionIdentifier 15,PropServerReference "g\155\204r",PropContentType +// "~\185\214g\196n\162\178j\STX\242\145\130\140\162~j\176\220'\201\163\NAK\131\166\143\GS",PropSubscriptionIdentifierAvailable +// 86,PropServerReference "5;\132zUx\169azP",PropResponseTopic +// "\139\226\248\211R=9\227\&3\195\247-;@k",PropResponseTopic "q\185yDL\184\189\SUB\211\248M\169l/p\172m\"",PropSubscriptionIdentifier 4,PropServerReference -// "\NULV\211\225\152A%",PropSubscriptionIdentifier 18,PropMessageExpiryInterval 14776,PropAssignedClientIdentifier -// "\NUL\255\152\137\144\229\186}{\213\173\227\152\131\249\219%!>\DC3\234kn",PropReceiveMaximum -// 26829,PropResponseInformation -// "H\"\255\170l\158\193\141\\\199\168n\STXg\252\197q\133\174W\203ov\131\174k\192\196\GS\167",PropResponseTopic -// "lEe\202\150\130%\146xf\212\255\f\233\&5U@\178\208\212\149\ACK\145@\202_b\241\ACK",PropSubscriptionIdentifier -// 22,PropSessionExpiryInterval 20393,PropAuthenticationMethod -// "\\\242k\155\215\150b\233Q+\217\196\165\166\138\ETX$\248",PropReasonString "nr~\SO\v\242*\199\193 \180"]}), -// _cleanSession = True, _keepAlive = 9446, _connID = -// "\146\132J\ENQ\144\192\ty\167>\184:C\152\133o\\1C\128\253\189]VH\210", _properties = [PropServerKeepAlive -// 15281,PropMessageExpiryInterval 321,PropAuthenticationData -// "\190!H7\224\152\SYNg4\164d2\208\255gR\134",PropRetainAvailable 111,PropServerKeepAlive -// 26493,PropRequestResponseInformation 29,PropAuthenticationMethod -// "\147\NUL>\US\145\&3\139\&8tE\CANV\232F\158\209\149\181\191\130\185\255\196c",PropMaximumQoS -// 44,PropSubscriptionIdentifier 11,PropContentType -// "P\EM\232\185\128:Rju\139a+\171\249hU\221W\DEL&[\178\164\238Cw\ETBn\157_",PropWildcardSubscriptionAvailable -// 71,PropWildcardSubscriptionAvailable 2,PropWillDelayInterval 5770,PropMaximumPacketSize 12405,PropAuthenticationData -// "\183\EOT\SO_\249\f\SO\148\\C\ACK\158\148\251\US\203\171Bu",PropAuthenticationData -// "$hlnO\140Pg\219k\FSPX,\234\DC3\128\166\253h\225\197\SUB\"\243\239\NUL\160",PropRetainAvailable -// 195,PropSessionExpiryInterval 28432,PropAuthenticationData -// "\ENQn\243\212\SOH>k!\151t\212\189\175\165\SYNV\233\ENQ\250\ETB\201\247\&3",PropMaximumQoS -// 223,PropSessionExpiryInterval 1570,PropTopicAliasMaximum 17694,PropSubscriptionIdentifierAvailable -// 230,PropWillDelayInterval 3740,PropSubscriptionIdentifierAvailable 101,PropServerReference -// "3\157\"Cg\215\196r",PropPayloadFormatIndicator 21,PropSubscriptionIdentifier 30,PropAuthenticationData -// "1\196D",PropMaximumPacketSize 9841]} -TEST(Connect5QCTest, Encode21) { +// ACK (PubACK 19499 97 [PropSubscriptionIdentifierAvailable 13,PropSessionExpiryInterval 1817,PropContentType +// "H\v",PropMessageExpiryInterval 381,PropContentType "5",PropCorrelationData +// "[\249\213jv\149e\ENQ+\149.\152\200",PropAssignedClientIdentifier +// "\187{h\152\223\DC1\188_\201\131Eu\180\158\156\195^",PropAuthenticationMethod +// "1\140o\236\220H\188\207\US\203",PropRequestProblemInformation 228,PropUserProperty +// "$q\DC2\ACK\244\186s\237\180\163\&5\255\218\251\253\134\163\202\CAN\182\196\ESC\244\205$s" +// "\ESC\ACK\US=t\ESC/&\225+",PropTopicAlias 9888,PropMessageExpiryInterval 18438,PropServerReference +// "\202j\141\155\157\EOT9\171\220\231-\254\FS#@T\178j\240\165.\237b",PropRetainAvailable +// 164,PropRequestProblemInformation 220,PropRequestResponseInformation 86,PropMessageExpiryInterval +// 29647,PropPayloadFormatIndicator 168,PropReasonString "L",PropMaximumQoS 156,PropTopicAlias +// 300,PropPayloadFormatIndicator 9,PropPayloadFormatIndicator 171,PropUserProperty "\EOT\232\151\201\186)" +// "\219\128g\197Q\190fhro\186\ACK\139YA"]) +TEST(PubACKACK5QCTest, Decode26) { uint8_t pkt[] = { - 0x10, 0x9d, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6, 0x24, 0xe6, 0xf4, 0x1, 0x13, 0x3b, 0xb1, 0x2, - 0x0, 0x0, 0x1, 0x41, 0x16, 0x0, 0x11, 0xbe, 0x21, 0x48, 0x37, 0xe0, 0x98, 0x16, 0x67, 0x34, 0xa4, 0x64, 0x32, - 0xd0, 0xff, 0x67, 0x52, 0x86, 0x25, 0x6f, 0x13, 0x67, 0x7d, 0x19, 0x1d, 0x15, 0x0, 0x18, 0x93, 0x0, 0x3e, 0x1f, - 0x91, 0x33, 0x8b, 0x38, 0x74, 0x45, 0x18, 0x56, 0xe8, 0x46, 0x9e, 0xd1, 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x35, 0x55, 0x40, 0xb2, 0xd0, 0xd4, 0x95, 0x6, 0x91, 0x40, 0xca, 0x5f, - 0x62, 0xf1, 0x6, 0xb, 0x16, 0x11, 0x0, 0x0, 0x4f, 0xa9, 0x15, 0x0, 0x12, 0x5c, 0xf2, 0x6b, 0x9b, 0xd7, 0x96, - 0x62, 0xe9, 0x51, 0x2b, 0xd9, 0xc4, 0xa5, 0xa6, 0x8a, 0x3, 0x24, 0xf8, 0x1f, 0x0, 0xb, 0x6e, 0x72, 0x7e, 0xe, - 0xb, 0xf2, 0x2a, 0xc7, 0xc1, 0x20, 0xb4, 0x0, 0x13, 0x65, 0xb2, 0xb0, 0x20, 0xe, 0xa7, 0x54, 0x21, 0x1, 0x15, - 0x3b, 0x62, 0xc1, 0xf7, 0x1a, 0x88, 0xbd, 0xc7, 0xe8, 0x0, 0x14, 0xdd, 0x7d, 0xa1, 0xc4, 0x7a, 0x53, 0xb2, 0x50, - 0x2a, 0x98, 0x7d, 0xfe, 0xdc, 0xc4, 0xd8, 0x88, 0xa1, 0xdc, 0x22, 0x15}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xbe, 0x21, 0x48, 0x37, 0xe0, 0x98, 0x16, 0x67, 0x34, - 0xa4, 0x64, 0x32, 0xd0, 0xff, 0x67, 0x52, 0x86}; - uint8_t bytesprops1[] = {0x93, 0x0, 0x3e, 0x1f, 0x91, 0x33, 0x8b, 0x38, 0x74, 0x45, 0x18, 0x56, - 0xe8, 0x46, 0x9e, 0xd1, 0x95, 0xb5, 0xbf, 0x82, 0xb9, 0xff, 0xc4, 0x63}; - uint8_t bytesprops2[] = {0x50, 0x19, 0xe8, 0xb9, 0x80, 0x3a, 0x52, 0x6a, 0x75, 0x8b, 0x61, 0x2b, 0xab, 0xf9, 0x68, - 0x55, 0xdd, 0x57, 0x7f, 0x26, 0x5b, 0xb2, 0xa4, 0xee, 0x43, 0x77, 0x17, 0x6e, 0x9d, 0x5f}; - uint8_t bytesprops3[] = {0xb7, 0x4, 0xe, 0x5f, 0xf9, 0xc, 0xe, 0x94, 0x5c, 0x43, - 0x6, 0x9e, 0x94, 0xfb, 0x1f, 0xcb, 0xab, 0x42, 0x75}; - uint8_t bytesprops4[] = {0x24, 0x68, 0x6c, 0x6e, 0x4f, 0x8c, 0x50, 0x67, 0xdb, 0x6b, 0x1c, 0x50, 0x58, 0x2c, - 0xea, 0x13, 0x80, 0xa6, 0xfd, 0x68, 0xe1, 0xc5, 0x1a, 0x22, 0xf3, 0xef, 0x0, 0xa0}; - uint8_t bytesprops5[] = {0x5, 0x6e, 0xf3, 0xd4, 0x1, 0x3e, 0x6b, 0x21, 0x97, 0x74, 0xd4, 0xbd, - 0xaf, 0xa5, 0x16, 0x56, 0xe9, 0x5, 0xfa, 0x17, 0xc9, 0xf7, 0x33}; - uint8_t bytesprops6[] = {0x33, 0x9d, 0x22, 0x43, 0x67, 0xd7, 0xc4, 0x72}; - uint8_t bytesprops7[] = {0x31, 0xc4, 0x44}; + 0x40, 0xcc, 0x1, 0x4c, 0x2b, 0x61, 0xc7, 0x1, 0x29, 0xd, 0x11, 0x0, 0x0, 0x7, 0x19, 0x3, 0x0, 0x2, 0x48, + 0xb, 0x2, 0x0, 0x0, 0x1, 0x7d, 0x3, 0x0, 0x1, 0x35, 0x9, 0x0, 0xd, 0x5b, 0xf9, 0xd5, 0x6a, 0x76, 0x95, + 0x65, 0x5, 0x2b, 0x95, 0x2e, 0x98, 0xc8, 0x12, 0x0, 0x11, 0xbb, 0x7b, 0x68, 0x98, 0xdf, 0x11, 0xbc, 0x5f, 0xc9, + 0x83, 0x45, 0x75, 0xb4, 0x9e, 0x9c, 0xc3, 0x5e, 0x15, 0x0, 0xa, 0x31, 0x8c, 0x6f, 0xec, 0xdc, 0x48, 0xbc, 0xcf, + 0x1f, 0xcb, 0x17, 0xe4, 0x26, 0x0, 0x1a, 0x24, 0x71, 0x12, 0x6, 0xf4, 0xba, 0x73, 0xed, 0xb4, 0xa3, 0x35, 0xff, + 0xda, 0xfb, 0xfd, 0x86, 0xa3, 0xca, 0x18, 0xb6, 0xc4, 0x1b, 0xf4, 0xcd, 0x24, 0x73, 0x0, 0xa, 0x1b, 0x6, 0x1f, + 0x3d, 0x74, 0x1b, 0x2f, 0x26, 0xe1, 0x2b, 0x23, 0x26, 0xa0, 0x2, 0x0, 0x0, 0x48, 0x6, 0x1c, 0x0, 0x17, 0xca, + 0x6a, 0x8d, 0x9b, 0x9d, 0x4, 0x39, 0xab, 0xdc, 0xe7, 0x2d, 0xfe, 0x1c, 0x23, 0x40, 0x54, 0xb2, 0x6a, 0xf0, 0xa5, + 0x2e, 0xed, 0x62, 0x25, 0xa4, 0x17, 0xdc, 0x19, 0x56, 0x2, 0x0, 0x0, 0x73, 0xcf, 0x1, 0xa8, 0x1f, 0x0, 0x1, + 0x4c, 0x24, 0x9c, 0x23, 0x1, 0x2c, 0x1, 0x9, 0x1, 0xab, 0x26, 0x0, 0x6, 0x4, 0xe8, 0x97, 0xc9, 0xba, 0x29, + 0x0, 0xf, 0xdb, 0x80, 0x67, 0xc5, 0x51, 0xbe, 0x66, 0x68, 0x72, 0x6f, 0xba, 0x6, 0x8b, 0x59, 0x41}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 19499); + EXPECT_EQ(status, 97); +} + +// COMP (PubCOMP 13110 221 [PropReceiveMaximum 13389,PropMaximumQoS 104,PropResponseTopic +// "\167\204\129\136\201\EM\167\219\SYN\212\192\232\SOnI\132",PropWildcardSubscriptionAvailable +// 49,PropSharedSubscriptionAvailable 241,PropSharedSubscriptionAvailable 113,PropReceiveMaximum +// 11896,PropAuthenticationData "z\250^:\194\184\143\221\US8\150\143\164\227",PropRequestResponseInformation +// 55,PropPayloadFormatIndicator 168,PropWillDelayInterval 15344,PropReceiveMaximum 14492,PropRequestProblemInformation +// 195,PropReceiveMaximum 13118,PropTopicAliasMaximum 32101,PropSubscriptionIdentifier 13,PropAssignedClientIdentifier +// "\250x\156J\243\200\&5\DC1T\161\vl\215\131\230\180\182\DEL\173\234lO5",PropMaximumQoS 27,PropMaximumQoS +// 221,PropSessionExpiryInterval 6935,PropTopicAliasMaximum 3750]) +TEST(PubACKCOMP5QCTest, Encode27) { + uint8_t pkt[] = {0x70, 0x72, 0x33, 0x36, 0xdd, 0x6e, 0x21, 0x34, 0x4d, 0x24, 0x68, 0x8, 0x0, 0x10, 0xa7, 0xcc, 0x81, + 0x88, 0xc9, 0x19, 0xa7, 0xdb, 0x16, 0xd4, 0xc0, 0xe8, 0xe, 0x6e, 0x49, 0x84, 0x28, 0x31, 0x2a, 0xf1, + 0x2a, 0x71, 0x21, 0x2e, 0x78, 0x16, 0x0, 0xe, 0x7a, 0xfa, 0x5e, 0x3a, 0xc2, 0xb8, 0x8f, 0xdd, 0x1f, + 0x38, 0x96, 0x8f, 0xa4, 0xe3, 0x19, 0x37, 0x1, 0xa8, 0x18, 0x0, 0x0, 0x3b, 0xf0, 0x21, 0x38, 0x9c, + 0x17, 0xc3, 0x21, 0x33, 0x3e, 0x22, 0x7d, 0x65, 0xb, 0xd, 0x12, 0x0, 0x17, 0xfa, 0x78, 0x9c, 0x4a, + 0xf3, 0xc8, 0x35, 0x11, 0x54, 0xa1, 0xb, 0x6c, 0xd7, 0x83, 0xe6, 0xb4, 0xb6, 0x7f, 0xad, 0xea, 0x6c, + 0x4f, 0x35, 0x24, 0x1b, 0x24, 0xdd, 0x11, 0x0, 0x0, 0x1b, 0x17, 0x22, 0xe, 0xa6}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0xa7, 0xcc, 0x81, 0x88, 0xc9, 0x19, 0xa7, 0xdb, + 0x16, 0xd4, 0xc0, 0xe8, 0xe, 0x6e, 0x49, 0x84}; + uint8_t bytesprops1[] = {0x7a, 0xfa, 0x5e, 0x3a, 0xc2, 0xb8, 0x8f, 0xdd, 0x1f, 0x38, 0x96, 0x8f, 0xa4, 0xe3}; + uint8_t bytesprops2[] = {0xfa, 0x78, 0x9c, 0x4a, 0xf3, 0xc8, 0x35, 0x11, 0x54, 0xa1, 0xb, 0x6c, + 0xd7, 0x83, 0xe6, 0xb4, 0xb6, 0x7f, 0xad, 0xea, 0x6c, 0x4f, 0x35}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15281}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 321}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26493}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5770}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12405}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28432}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1570}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17694}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3740}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9841}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13389}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11896}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15344}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14492}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13118}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32101}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 27}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6935}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3750}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x6e, 0x10, 0xe1, 0xa9, 0x7f, 0x49, 0x2, 0x3e, 0x1a, 0xd3, - 0xf8, 0x4d, 0xa9, 0x6c, 0x2f, 0x70, 0xac, 0x6d, 0x22}; - uint8_t byteswillprops0[] = {0x6b, 0x51, 0x50, 0x47, 0x0, 0xe4, 0xe5, 0xf9, 0x9c, - 0x57, 0xd9, 0xf6, 0xcc, 0x3b, 0x64, 0xa3, 0x5c}; - uint8_t byteswillprops2[] = {0x0, 0x56, 0xd3, 0xe1, 0x98, 0x41, 0x25}; - uint8_t byteswillprops3[] = {0x0, 0xff, 0x98, 0x89, 0x90, 0xe5, 0xba, 0x7d, 0x7b, 0xd5, 0xad, 0xe3, - 0x98, 0x83, 0xf9, 0xdb, 0x25, 0x21, 0x3e, 0x13, 0xea, 0x6b, 0x6e}; - uint8_t byteswillprops4[] = {0x48, 0x22, 0xff, 0xaa, 0x6c, 0x9e, 0xc1, 0x8d, 0x5c, 0xc7, - 0xa8, 0x6e, 0x2, 0x67, 0xfc, 0xc5, 0x71, 0x85, 0xae, 0x57, - 0xcb, 0x6f, 0x76, 0x83, 0xae, 0x6b, 0xc0, 0xc4, 0x1d, 0xa7}; - uint8_t byteswillprops5[] = {0x6c, 0x45, 0x65, 0xca, 0x96, 0x82, 0x25, 0x92, 0x78, 0x66, 0xd4, 0xff, 0xc, 0xe9, 0x35, - 0x55, 0x40, 0xb2, 0xd0, 0xd4, 0x95, 0x6, 0x91, 0x40, 0xca, 0x5f, 0x62, 0xf1, 0x6}; - uint8_t byteswillprops6[] = {0x5c, 0xf2, 0x6b, 0x9b, 0xd7, 0x96, 0x62, 0xe9, 0x51, - 0x2b, 0xd9, 0xc4, 0xa5, 0xa6, 0x8a, 0x3, 0x24, 0xf8}; - uint8_t byteswillprops7[] = {0x6e, 0x72, 0x7e, 0xe, 0xb, 0xf2, 0x2a, 0xc7, 0xc1, 0x20, 0xb4}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 13110, 221, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16380}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6209}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29194}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2368}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {17, (char*)&byteswillprops0}, .v = {19, (char*)&byteswillprops1}}}}, +// COMP (PubCOMP 13110 221 [PropReceiveMaximum 13389,PropMaximumQoS 104,PropResponseTopic +// "\167\204\129\136\201\EM\167\219\SYN\212\192\232\SOnI\132",PropWildcardSubscriptionAvailable +// 49,PropSharedSubscriptionAvailable 241,PropSharedSubscriptionAvailable 113,PropReceiveMaximum +// 11896,PropAuthenticationData "z\250^:\194\184\143\221\US8\150\143\164\227",PropRequestResponseInformation +// 55,PropPayloadFormatIndicator 168,PropWillDelayInterval 15344,PropReceiveMaximum 14492,PropRequestProblemInformation +// 195,PropReceiveMaximum 13118,PropTopicAliasMaximum 32101,PropSubscriptionIdentifier 13,PropAssignedClientIdentifier +// "\250x\156J\243\200\&5\DC1T\161\vl\215\131\230\180\182\DEL\173\234lO5",PropMaximumQoS 27,PropMaximumQoS +// 221,PropSessionExpiryInterval 6935,PropTopicAliasMaximum 3750]) +TEST(PubACKCOMP5QCTest, Decode27) { + uint8_t pkt[] = {0x70, 0x72, 0x33, 0x36, 0xdd, 0x6e, 0x21, 0x34, 0x4d, 0x24, 0x68, 0x8, 0x0, 0x10, 0xa7, 0xcc, 0x81, + 0x88, 0xc9, 0x19, 0xa7, 0xdb, 0x16, 0xd4, 0xc0, 0xe8, 0xe, 0x6e, 0x49, 0x84, 0x28, 0x31, 0x2a, 0xf1, + 0x2a, 0x71, 0x21, 0x2e, 0x78, 0x16, 0x0, 0xe, 0x7a, 0xfa, 0x5e, 0x3a, 0xc2, 0xb8, 0x8f, 0xdd, 0x1f, + 0x38, 0x96, 0x8f, 0xa4, 0xe3, 0x19, 0x37, 0x1, 0xa8, 0x18, 0x0, 0x0, 0x3b, 0xf0, 0x21, 0x38, 0x9c, + 0x17, 0xc3, 0x21, 0x33, 0x3e, 0x22, 0x7d, 0x65, 0xb, 0xd, 0x12, 0x0, 0x17, 0xfa, 0x78, 0x9c, 0x4a, + 0xf3, 0xc8, 0x35, 0x11, 0x54, 0xa1, 0xb, 0x6c, 0xd7, 0x83, 0xe6, 0xb4, 0xb6, 0x7f, 0xad, 0xea, 0x6c, + 0x4f, 0x35, 0x24, 0x1b, 0x24, 0xdd, 0x11, 0x0, 0x0, 0x1b, 0x17, 0x22, 0xe, 0xa6}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 13110); + EXPECT_EQ(status, 221); +} + +// REC (PubREC 25388 230 [PropMaximumQoS 62,PropCorrelationData "\185\195",PropMessageExpiryInterval +// 31098,PropServerReference "",PropSubscriptionIdentifier 4,PropResponseTopic +// "GA\182z\195%b\234i\155\176\b\ETB+\149",PropServerReference "1\161\164=",PropSessionExpiryInterval +// 30227,PropResponseTopic "\240i",PropResponseTopic +// "e\EOT\188\148`!\179\194\&2n\245w\150\250(\140\231\205'\ENQ\DC3",PropSubscriptionIdentifierAvailable 57]) +TEST(PubACKREC5QCTest, Encode28) { + uint8_t pkt[] = {0x50, 0x52, 0x63, 0x2c, 0xe6, 0x4e, 0x24, 0x3e, 0x9, 0x0, 0x2, 0xb9, 0xc3, 0x2, 0x0, 0x0, 0x79, + 0x7a, 0x1c, 0x0, 0x0, 0xb, 0x4, 0x8, 0x0, 0xf, 0x47, 0x41, 0xb6, 0x7a, 0xc3, 0x25, 0x62, 0xea, + 0x69, 0x9b, 0xb0, 0x8, 0x17, 0x2b, 0x95, 0x1c, 0x0, 0x4, 0x31, 0xa1, 0xa4, 0x3d, 0x11, 0x0, 0x0, + 0x76, 0x13, 0x8, 0x0, 0x2, 0xf0, 0x69, 0x8, 0x0, 0x15, 0x65, 0x4, 0xbc, 0x94, 0x60, 0x21, 0xb3, + 0xc2, 0x32, 0x6e, 0xf5, 0x77, 0x96, 0xfa, 0x28, 0x8c, 0xe7, 0xcd, 0x27, 0x5, 0x13, 0x29, 0x39}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0xb9, 0xc3}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x47, 0x41, 0xb6, 0x7a, 0xc3, 0x25, 0x62, 0xea, 0x69, 0x9b, 0xb0, 0x8, 0x17, 0x2b, 0x95}; + uint8_t bytesprops3[] = {0x31, 0xa1, 0xa4, 0x3d}; + uint8_t bytesprops4[] = {0xf0, 0x69}; + uint8_t bytesprops5[] = {0x65, 0x4, 0xbc, 0x94, 0x60, 0x21, 0xb3, 0xc2, 0x32, 0x6e, 0xf5, + 0x77, 0x96, 0xfa, 0x28, 0x8c, 0xe7, 0xcd, 0x27, 0x5, 0x13}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 62}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31098}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops1}}}, {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14776}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26829}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20393}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30227}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, }; - lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x65, 0xb2, 0xb0, 0x20, 0xe, 0xa7, 0x54, 0x21, 0x1, 0x15, - 0x3b, 0x62, 0xc1, 0xf7, 0x1a, 0x88, 0xbd, 0xc7, 0xe8}; - lwmqtt_string_t will_topic = {19, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xdd, 0x7d, 0xa1, 0xc4, 0x7a, 0x53, 0xb2, 0x50, 0x2a, 0x98, - 0x7d, 0xfe, 0xdc, 0xc4, 0xd8, 0x88, 0xa1, 0xdc, 0x22, 0x15}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = false; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 9446; - uint8_t client_id_bytes[] = {0x92, 0x84, 0x4a, 0x5, 0x90, 0xc0, 0x9, 0x79, 0xa7, 0x3e, 0xb8, 0x3a, 0x43, - 0x98, 0x85, 0x6f, 0x5c, 0x31, 0x43, 0x80, 0xfd, 0xbd, 0x5d, 0x56, 0x48, 0xd2}; - lwmqtt_string_t client_id = {26, (char*)&client_id_bytes}; - opts.client_id = client_id; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, 0, 25388, 230, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "0\219\168\207u\209FQb\194\255\SYN:\216` ", _password = Just -// "\224\206\238\173\&1\157LS\135\STX\RSL\213\178A\184\&6\185\133\180r1\191O\169\153m\246O", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "\210\254({", _willMsg = "Z\128\204\SOH\NUL\v%", _willProps = -// [PropResponseInformation "\152\&8\173\FSM*G\129w\204\184\247\224\STX\CANn\168\STX\173\227/u",PropReasonString -// "\233\146Y\178,\161\&2\ETB\179\220\200\243\162\SI[",PropTopicAliasMaximum 2888,PropTopicAliasMaximum -// 31004,PropSessionExpiryInterval 32704,PropReasonString " -// \250\210\140\217\149>\216\255\232\209I\171\180\US\239",PropMessageExpiryInterval 2234]}), _cleanSession = False, -// _keepAlive = 10802, _connID = "\229U\154\147\141\141XPP\181I\226\208\SYN", _properties = -// [PropRequestProblemInformation 180,PropAuthenticationData "w\144",PropRetainAvailable -// 254,PropSubscriptionIdentifierAvailable 147,PropAuthenticationData "\214\130\181",PropWildcardSubscriptionAvailable -// 225]} -TEST(Connect5QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0xbd, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x2a, 0x32, 0x13, 0x17, 0xb4, - 0x16, 0x0, 0x2, 0x77, 0x90, 0x25, 0xfe, 0x29, 0x93, 0x16, 0x0, 0x3, 0xd6, 0x82, 0xb5, 0x28, - 0xe1, 0x0, 0xe, 0xe5, 0x55, 0x9a, 0x93, 0x8d, 0x8d, 0x58, 0x50, 0x50, 0xb5, 0x49, 0xe2, 0xd0, - 0x16, 0x4e, 0x1a, 0x0, 0x16, 0x98, 0x38, 0xad, 0x1c, 0x4d, 0x2a, 0x47, 0x81, 0x77, 0xcc, 0xb8, - 0xf7, 0xe0, 0x2, 0x18, 0x6e, 0xa8, 0x2, 0xad, 0xe3, 0x2f, 0x75, 0x1f, 0x0, 0xf, 0xe9, 0x92, - 0x59, 0xb2, 0x2c, 0xa1, 0x32, 0x17, 0xb3, 0xdc, 0xc8, 0xf3, 0xa2, 0xf, 0x5b, 0x22, 0xb, 0x48, - 0x22, 0x79, 0x1c, 0x11, 0x0, 0x0, 0x7f, 0xc0, 0x1f, 0x0, 0x10, 0x20, 0xfa, 0xd2, 0x8c, 0xd9, - 0x95, 0x3e, 0xd8, 0xff, 0xe8, 0xd1, 0x49, 0xab, 0xb4, 0x1f, 0xef, 0x2, 0x0, 0x0, 0x8, 0xba, - 0x0, 0x4, 0xd2, 0xfe, 0x28, 0x7b, 0x0, 0x7, 0x5a, 0x80, 0xcc, 0x1, 0x0, 0xb, 0x25, 0x0, - 0x10, 0x30, 0xdb, 0xa8, 0xcf, 0x75, 0xd1, 0x46, 0x51, 0x62, 0xc2, 0xff, 0x16, 0x3a, 0xd8, 0x60, - 0x20, 0x0, 0x1d, 0xe0, 0xce, 0xee, 0xad, 0x31, 0x9d, 0x4c, 0x53, 0x87, 0x2, 0x1e, 0x4c, 0xd5, - 0xb2, 0x41, 0xb8, 0x36, 0xb9, 0x85, 0xb4, 0x72, 0x31, 0xbf, 0x4f, 0xa9, 0x99, 0x6d, 0xf6, 0x4f}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x77, 0x90}; - uint8_t bytesprops1[] = {0xd6, 0x82, 0xb5}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 225}}, - }; +// REC (PubREC 25388 230 [PropMaximumQoS 62,PropCorrelationData "\185\195",PropMessageExpiryInterval +// 31098,PropServerReference "",PropSubscriptionIdentifier 4,PropResponseTopic +// "GA\182z\195%b\234i\155\176\b\ETB+\149",PropServerReference "1\161\164=",PropSessionExpiryInterval +// 30227,PropResponseTopic "\240i",PropResponseTopic +// "e\EOT\188\148`!\179\194\&2n\245w\150\250(\140\231\205'\ENQ\DC3",PropSubscriptionIdentifierAvailable 57]) +TEST(PubACKREC5QCTest, Decode28) { + uint8_t pkt[] = {0x50, 0x52, 0x63, 0x2c, 0xe6, 0x4e, 0x24, 0x3e, 0x9, 0x0, 0x2, 0xb9, 0xc3, 0x2, 0x0, 0x0, 0x79, + 0x7a, 0x1c, 0x0, 0x0, 0xb, 0x4, 0x8, 0x0, 0xf, 0x47, 0x41, 0xb6, 0x7a, 0xc3, 0x25, 0x62, 0xea, + 0x69, 0x9b, 0xb0, 0x8, 0x17, 0x2b, 0x95, 0x1c, 0x0, 0x4, 0x31, 0xa1, 0xa4, 0x3d, 0x11, 0x0, 0x0, + 0x76, 0x13, 0x8, 0x0, 0x2, 0xf0, 0x69, 0x8, 0x0, 0x15, 0x65, 0x4, 0xbc, 0x94, 0x60, 0x21, 0xb3, + 0xc2, 0x32, 0x6e, 0xf5, 0x77, 0x96, 0xfa, 0x28, 0x8c, 0xe7, 0xcd, 0x27, 0x5, 0x13, 0x29, 0x39}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 25388); + EXPECT_EQ(status, 230); +} - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x98, 0x38, 0xad, 0x1c, 0x4d, 0x2a, 0x47, 0x81, 0x77, 0xcc, 0xb8, - 0xf7, 0xe0, 0x2, 0x18, 0x6e, 0xa8, 0x2, 0xad, 0xe3, 0x2f, 0x75}; - uint8_t byteswillprops1[] = {0xe9, 0x92, 0x59, 0xb2, 0x2c, 0xa1, 0x32, 0x17, 0xb3, 0xdc, 0xc8, 0xf3, 0xa2, 0xf, 0x5b}; - uint8_t byteswillprops2[] = {0x20, 0xfa, 0xd2, 0x8c, 0xd9, 0x95, 0x3e, 0xd8, - 0xff, 0xe8, 0xd1, 0x49, 0xab, 0xb4, 0x1f, 0xef}; +// COMP (PubCOMP 5812 238 [PropAuthenticationData "P9\\\230\247",PropSubscriptionIdentifier +// 2,PropSubscriptionIdentifierAvailable 110]) +TEST(PubACKCOMP5QCTest, Encode29) { + uint8_t pkt[] = {0x70, 0x10, 0x16, 0xb4, 0xee, 0xc, 0x16, 0x0, 0x5, + 0x50, 0x39, 0x5c, 0xe6, 0xf7, 0xb, 0x2, 0x29, 0x6e}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0x50, 0x39, 0x5c, 0xe6, 0xf7}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2888}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31004}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32704}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2234}}, + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 110}}, }; - lwmqtt_properties_t willprops = {7, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd2, 0xfe, 0x28, 0x7b}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5a, 0x80, 0xcc, 0x1, 0x0, 0xb, 0x25}; - lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 10802; - uint8_t client_id_bytes[] = {0xe5, 0x55, 0x9a, 0x93, 0x8d, 0x8d, 0x58, 0x50, 0x50, 0xb5, 0x49, 0xe2, 0xd0, 0x16}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x30, 0xdb, 0xa8, 0xcf, 0x75, 0xd1, 0x46, 0x51, - 0x62, 0xc2, 0xff, 0x16, 0x3a, 0xd8, 0x60, 0x20}; - lwmqtt_string_t username = {16, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe0, 0xce, 0xee, 0xad, 0x31, 0x9d, 0x4c, 0x53, 0x87, 0x2, 0x1e, 0x4c, 0xd5, 0xb2, 0x41, - 0xb8, 0x36, 0xb9, 0x85, 0xb4, 0x72, 0x31, 0xbf, 0x4f, 0xa9, 0x99, 0x6d, 0xf6, 0x4f}; - lwmqtt_string_t password = {29, (char*)&password_bytes}; - opts.password = password; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); - + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 5812, 238, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\159V\EOT\ENQR\a\169J\EOT", _lastWill = Just (LastWill -// {_willRetain = False, _willQoS = QoS1, _willTopic = "\SI\SO", _willMsg = "\SUB{\SO\EM\190", _willProps = -// [PropWillDelayInterval 5775,PropResponseTopic -// "\140\225i)\252N\183\&5\199\SOH\140\234\131\v;\SOH?\DEL\174k\252Ec\US&\EOT|y\178\r",PropTopicAlias -// 30510,PropReceiveMaximum 21817,PropAuthenticationMethod -// "\203\131\189\214\DC37\DEL\212cm,\254\173\168\RS\185",PropRequestResponseInformation 44,PropServerReference -// "\200\225-\175\171\&7\v\ENQ\226\209\&5\195CL:\163)g\ENQ\181\135\CANqM",PropTopicAlias 24660,PropAuthenticationData -// "rR\237\185\200\186\207\EOT\166f\184\193d\v\GS\\\US#;\238N\172\142\175\198\240",PropMessageExpiryInterval -// 20356,PropSubscriptionIdentifier 18,PropSessionExpiryInterval 11181,PropReceiveMaximum -// 3137,PropRequestResponseInformation 79,PropSessionExpiryInterval 6595,PropAuthenticationData -// ")n\183vS\DC2m\248\ACK`]\251J2\180\175\132,X",PropWildcardSubscriptionAvailable 98,PropWillDelayInterval -// 5996,PropMaximumQoS 190,PropRetainAvailable 40,PropAuthenticationData "",PropAuthenticationData -// "\ESC\STX{\vt\142u\254\161\141Cii\t\217\171`\212\&0\230G",PropSubscriptionIdentifier 4,PropMessageExpiryInterval -// 23967,PropPayloadFormatIndicator 96,PropSubscriptionIdentifier 26,PropServerReference -// "Q$Z\ACK\179\240\155\200\192\204\246x\140\139\ESC",PropRetainAvailable 57,PropMaximumPacketSize 32201]}), -// _cleanSession = True, _keepAlive = 3695, _connID = "V\159\161\231\237\200\154\134\206X\143", _properties = -// [PropAuthenticationMethod "c\143pZf\163]\251gI9S5-O\128l]\v}\249\174o",PropServerKeepAlive -// 9332,PropSubscriptionIdentifier 11,PropMessageExpiryInterval 1769,PropRequestResponseInformation 244,PropUserProperty -// "`\183z(\192\160\144Y=>w8{\136,\183\248\181,\233\247w\252+\ESC\250\203\t\139" -// "\138\218\139z\246@\n\161\244\SOHJ\232\235\DC1\220xX\\?\213\166\DLE\140r\150p",PropResponseInformation -// "\220\147tPcV\NAK\212\f\158\157s\156(\128",PropSessionExpiryInterval 28700,PropSubscriptionIdentifier -// 17,PropCorrelationData "\SICy",PropResponseInformation -// "\NUL\230\136@\146\247\150P*\172\153/\254\174\STX\191",PropReasonString -// "2\163\DC3\220Q\217\133Kg&\163\DC4\254\155;?;\168M[\b-\237z.\FS\249\DC3\202\SI",PropRequestProblemInformation -// 181,PropServerKeepAlive 3262,PropAuthenticationData "$\b\235\EM",PropCorrelationData -// "\184\131\245e\n:\DC3\238",PropTopicAlias 25579,PropUserProperty "\ETX\EOT\167\US\248\139\fB\173" -// "\183\186\&1l\FS\195;\167",PropAssignedClientIdentifier -// "\DC48#GK=,\"\234\253\128\205\177\222\255\195e\173",PropCorrelationData -// "G\173\255m\161\184\247\171T\"a\132",PropTopicAlias 31936,PropUserProperty -// "|\211\196|\176\192\&2\247\156!!L\RS\250\SO" "",PropMessageExpiryInterval 12658,PropRetainAvailable -// 205,PropPayloadFormatIndicator 53]} -TEST(Connect5QCTest, Encode23) { - uint8_t pkt[] = { - 0x10, 0xcc, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x4e, 0xe, 0x6f, 0xa9, 0x2, 0x15, 0x0, 0x17, 0x63, - 0x8f, 0x70, 0x5a, 0x66, 0xa3, 0x5d, 0xfb, 0x67, 0x49, 0x39, 0x53, 0x35, 0x2d, 0x4f, 0x80, 0x6c, 0x5d, 0xb, 0x7d, - 0xf9, 0xae, 0x6f, 0x13, 0x24, 0x74, 0xb, 0xb, 0x2, 0x0, 0x0, 0x6, 0xe9, 0x19, 0xf4, 0x26, 0x0, 0x1d, 0x60, - 0xb7, 0x7a, 0x28, 0xc0, 0xa0, 0x90, 0x59, 0x3d, 0x3e, 0x77, 0x38, 0x7b, 0x88, 0x2c, 0xb7, 0xf8, 0xb5, 0x2c, 0xe9, - 0xf7, 0x77, 0xfc, 0x2b, 0x1b, 0xfa, 0xcb, 0x9, 0x8b, 0x0, 0x1a, 0x8a, 0xda, 0x8b, 0x7a, 0xf6, 0x40, 0xa, 0xa1, - 0xf4, 0x1, 0x4a, 0xe8, 0xeb, 0x11, 0xdc, 0x78, 0x58, 0x5c, 0x3f, 0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, 0x6d, 0xf8, 0x6, 0x60, 0x5d, 0xfb, 0x4a, 0x32, 0xb4, 0xaf, 0x84, 0x2c, - 0x58, 0x28, 0x62, 0x18, 0x0, 0x0, 0x17, 0x6c, 0x24, 0xbe, 0x25, 0x28, 0x16, 0x0, 0x0, 0x16, 0x0, 0x15, 0x1b, - 0x2, 0x7b, 0xb, 0x74, 0x8e, 0x75, 0xfe, 0xa1, 0x8d, 0x43, 0x69, 0x69, 0x9, 0xd9, 0xab, 0x60, 0xd4, 0x30, 0xe6, - 0x47, 0xb, 0x4, 0x2, 0x0, 0x0, 0x5d, 0x9f, 0x1, 0x60, 0xb, 0x1a, 0x1c, 0x0, 0xf, 0x51, 0x24, 0x5a, 0x6, - 0xb3, 0xf0, 0x9b, 0xc8, 0xc0, 0xcc, 0xf6, 0x78, 0x8c, 0x8b, 0x1b, 0x25, 0x39, 0x27, 0x0, 0x0, 0x7d, 0xc9, 0x0, - 0x2, 0xf, 0xe, 0x0, 0x5, 0x1a, 0x7b, 0xe, 0x19, 0xbe, 0x0, 0x9, 0x9f, 0x56, 0x4, 0x5, 0x52, 0x7, 0xa9, - 0x4a, 0x4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x63, 0x8f, 0x70, 0x5a, 0x66, 0xa3, 0x5d, 0xfb, 0x67, 0x49, 0x39, 0x53, - 0x35, 0x2d, 0x4f, 0x80, 0x6c, 0x5d, 0xb, 0x7d, 0xf9, 0xae, 0x6f}; - uint8_t bytesprops2[] = {0x8a, 0xda, 0x8b, 0x7a, 0xf6, 0x40, 0xa, 0xa1, 0xf4, 0x1, 0x4a, 0xe8, 0xeb, - 0x11, 0xdc, 0x78, 0x58, 0x5c, 0x3f, 0xd5, 0xa6, 0x10, 0x8c, 0x72, 0x96, 0x70}; - uint8_t bytesprops1[] = {0x60, 0xb7, 0x7a, 0x28, 0xc0, 0xa0, 0x90, 0x59, 0x3d, 0x3e, 0x77, 0x38, 0x7b, 0x88, 0x2c, - 0xb7, 0xf8, 0xb5, 0x2c, 0xe9, 0xf7, 0x77, 0xfc, 0x2b, 0x1b, 0xfa, 0xcb, 0x9, 0x8b}; - uint8_t bytesprops3[] = {0xdc, 0x93, 0x74, 0x50, 0x63, 0x56, 0x15, 0xd4, 0xc, 0x9e, 0x9d, 0x73, 0x9c, 0x28, 0x80}; - uint8_t bytesprops4[] = {0xf, 0x43, 0x79}; - uint8_t bytesprops5[] = {0x0, 0xe6, 0x88, 0x40, 0x92, 0xf7, 0x96, 0x50, - 0x2a, 0xac, 0x99, 0x2f, 0xfe, 0xae, 0x2, 0xbf}; - uint8_t bytesprops6[] = {0x32, 0xa3, 0x13, 0xdc, 0x51, 0xd9, 0x85, 0x4b, 0x67, 0x26, 0xa3, 0x14, 0xfe, 0x9b, 0x3b, - 0x3f, 0x3b, 0xa8, 0x4d, 0x5b, 0x8, 0x2d, 0xed, 0x7a, 0x2e, 0x1c, 0xf9, 0x13, 0xca, 0xf}; - uint8_t bytesprops7[] = {0x24, 0x8, 0xeb, 0x19}; - uint8_t bytesprops8[] = {0xb8, 0x83, 0xf5, 0x65, 0xa, 0x3a, 0x13, 0xee}; - uint8_t bytesprops10[] = {0xb7, 0xba, 0x31, 0x6c, 0x1c, 0xc3, 0x3b, 0xa7}; - uint8_t bytesprops9[] = {0x3, 0x4, 0xa7, 0x1f, 0xf8, 0x8b, 0xc, 0x42, 0xad}; - uint8_t bytesprops11[] = {0x14, 0x38, 0x23, 0x47, 0x4b, 0x3d, 0x2c, 0x22, 0xea, - 0xfd, 0x80, 0xcd, 0xb1, 0xde, 0xff, 0xc3, 0x65, 0xad}; - uint8_t bytesprops12[] = {0x47, 0xad, 0xff, 0x6d, 0xa1, 0xb8, 0xf7, 0xab, 0x54, 0x22, 0x61, 0x84}; - uint8_t bytesprops14[] = {0}; - uint8_t bytesprops13[] = {0x7c, 0xd3, 0xc4, 0x7c, 0xb0, 0xc0, 0x32, 0xf7, 0x9c, 0x21, 0x21, 0x4c, 0x1e, 0xfa, 0xe}; +// COMP (PubCOMP 5812 238 [PropAuthenticationData "P9\\\230\247",PropSubscriptionIdentifier +// 2,PropSubscriptionIdentifierAvailable 110]) +TEST(PubACKCOMP5QCTest, Decode29) { + uint8_t pkt[] = {0x70, 0x10, 0x16, 0xb4, 0xee, 0xc, 0x16, 0x0, 0x5, + 0x50, 0x39, 0x5c, 0xe6, 0xf7, 0xb, 0x2, 0x29, 0x6e}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 5812); + EXPECT_EQ(status, 238); +} + +// COMP (PubCOMP 30696 65 [PropServerKeepAlive 9554,PropContentType "\ESC+\236\172p",PropMaximumPacketSize +// 29701,PropAuthenticationMethod +// "h\254\204\141\200\234\188\&8\242\246\212*B\RS\EM\246\r\168\202\ACKm",PropWillDelayInterval 4219,PropRetainAvailable +// 71,PropRetainAvailable 100,PropMaximumQoS 214,PropSessionExpiryInterval 7076,PropSharedSubscriptionAvailable +// 145,PropServerReference "r\183\253C\157\200k \249w\164\147e=x\179T\134[$\240o\198K",PropRetainAvailable +// 98,PropPayloadFormatIndicator 154,PropServerKeepAlive 31424,PropRequestProblemInformation +// 217,PropSharedSubscriptionAvailable 181,PropPayloadFormatIndicator 219,PropMessageExpiryInterval +// 31400,PropRequestProblemInformation 53,PropServerKeepAlive 18882,PropRequestProblemInformation +// 36,PropSubscriptionIdentifierAvailable 44,PropServerKeepAlive 17813,PropRetainAvailable 254,PropTopicAlias +// 5704,PropAssignedClientIdentifier "|\210\200Vg\247i\133\SUB\221\168y\255",PropMaximumQoS +// 72,PropWildcardSubscriptionAvailable 227,PropSessionExpiryInterval 8466]) +TEST(PubACKCOMP5QCTest, Encode30) { + uint8_t pkt[] = {0x70, 0x96, 0x1, 0x77, 0xe8, 0x41, 0x91, 0x1, 0x13, 0x25, 0x52, 0x3, 0x0, 0x5, 0x1b, 0x2b, + 0xec, 0xac, 0x70, 0x27, 0x0, 0x0, 0x74, 0x5, 0x15, 0x0, 0x15, 0x68, 0xfe, 0xcc, 0x8d, 0xc8, + 0xea, 0xbc, 0x38, 0xf2, 0xf6, 0xd4, 0x2a, 0x42, 0x1e, 0x19, 0xf6, 0xd, 0xa8, 0xca, 0x6, 0x6d, + 0x18, 0x0, 0x0, 0x10, 0x7b, 0x25, 0x47, 0x25, 0x64, 0x24, 0xd6, 0x11, 0x0, 0x0, 0x1b, 0xa4, + 0x2a, 0x91, 0x1c, 0x0, 0x18, 0x72, 0xb7, 0xfd, 0x43, 0x9d, 0xc8, 0x6b, 0x20, 0xf9, 0x77, 0xa4, + 0x93, 0x65, 0x3d, 0x78, 0xb3, 0x54, 0x86, 0x5b, 0x24, 0xf0, 0x6f, 0xc6, 0x4b, 0x25, 0x62, 0x1, + 0x9a, 0x13, 0x7a, 0xc0, 0x17, 0xd9, 0x2a, 0xb5, 0x1, 0xdb, 0x2, 0x0, 0x0, 0x7a, 0xa8, 0x17, + 0x35, 0x13, 0x49, 0xc2, 0x17, 0x24, 0x29, 0x2c, 0x13, 0x45, 0x95, 0x25, 0xfe, 0x23, 0x16, 0x48, + 0x12, 0x0, 0xd, 0x7c, 0xd2, 0xc8, 0x56, 0x67, 0xf7, 0x69, 0x85, 0x1a, 0xdd, 0xa8, 0x79, 0xff, + 0x24, 0x48, 0x28, 0xe3, 0x11, 0x0, 0x0, 0x21, 0x12}; + uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0x1b, 0x2b, 0xec, 0xac, 0x70}; + uint8_t bytesprops1[] = {0x68, 0xfe, 0xcc, 0x8d, 0xc8, 0xea, 0xbc, 0x38, 0xf2, 0xf6, 0xd4, + 0x2a, 0x42, 0x1e, 0x19, 0xf6, 0xd, 0xa8, 0xca, 0x6, 0x6d}; + uint8_t bytesprops2[] = {0x72, 0xb7, 0xfd, 0x43, 0x9d, 0xc8, 0x6b, 0x20, 0xf9, 0x77, 0xa4, 0x93, + 0x65, 0x3d, 0x78, 0xb3, 0x54, 0x86, 0x5b, 0x24, 0xf0, 0x6f, 0xc6, 0x4b}; + uint8_t bytesprops3[] = {0x7c, 0xd2, 0xc8, 0x56, 0x67, 0xf7, 0x69, 0x85, 0x1a, 0xdd, 0xa8, 0x79, 0xff}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9332}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1769}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {26, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28700}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3262}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25579}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops9}, .v = {8, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31936}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops13}, .v = {0, (char*)&bytesprops14}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12658}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9554}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29701}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4219}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7076}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31424}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31400}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18882}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17813}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5704}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8466}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x8c, 0xe1, 0x69, 0x29, 0xfc, 0x4e, 0xb7, 0x35, 0xc7, 0x1, 0x8c, 0xea, 0x83, 0xb, 0x3b, - 0x1, 0x3f, 0x7f, 0xae, 0x6b, 0xfc, 0x45, 0x63, 0x1f, 0x26, 0x4, 0x7c, 0x79, 0xb2, 0xd}; - uint8_t byteswillprops1[] = {0xcb, 0x83, 0xbd, 0xd6, 0x13, 0x37, 0x7f, 0xd4, - 0x63, 0x6d, 0x2c, 0xfe, 0xad, 0xa8, 0x1e, 0xb9}; - uint8_t byteswillprops2[] = {0xc8, 0xe1, 0x2d, 0xaf, 0xab, 0x37, 0xb, 0x5, 0xe2, 0xd1, 0x35, 0xc3, - 0x43, 0x4c, 0x3a, 0xa3, 0x29, 0x67, 0x5, 0xb5, 0x87, 0x18, 0x71, 0x4d}; - uint8_t byteswillprops3[] = {0x72, 0x52, 0xed, 0xb9, 0xc8, 0xba, 0xcf, 0x4, 0xa6, 0x66, 0xb8, 0xc1, 0x64, - 0xb, 0x1d, 0x5c, 0x1f, 0x23, 0x3b, 0xee, 0x4e, 0xac, 0x8e, 0xaf, 0xc6, 0xf0}; - uint8_t byteswillprops4[] = {0x29, 0x6e, 0xb7, 0x76, 0x53, 0x12, 0x6d, 0xf8, 0x6, 0x60, - 0x5d, 0xfb, 0x4a, 0x32, 0xb4, 0xaf, 0x84, 0x2c, 0x58}; - uint8_t byteswillprops5[] = {0}; - uint8_t byteswillprops6[] = {0x1b, 0x2, 0x7b, 0xb, 0x74, 0x8e, 0x75, 0xfe, 0xa1, 0x8d, 0x43, - 0x69, 0x69, 0x9, 0xd9, 0xab, 0x60, 0xd4, 0x30, 0xe6, 0x47}; - uint8_t byteswillprops7[] = {0x51, 0x24, 0x5a, 0x6, 0xb3, 0xf0, 0x9b, 0xc8, 0xc0, 0xcc, 0xf6, 0x78, 0x8c, 0x8b, 0x1b}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + size_t len; + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 30696, 65, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5775}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30510}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21817}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24660}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20356}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11181}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3137}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6595}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5996}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23967}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32201}}, - }; +// COMP (PubCOMP 30696 65 [PropServerKeepAlive 9554,PropContentType "\ESC+\236\172p",PropMaximumPacketSize +// 29701,PropAuthenticationMethod +// "h\254\204\141\200\234\188\&8\242\246\212*B\RS\EM\246\r\168\202\ACKm",PropWillDelayInterval 4219,PropRetainAvailable +// 71,PropRetainAvailable 100,PropMaximumQoS 214,PropSessionExpiryInterval 7076,PropSharedSubscriptionAvailable +// 145,PropServerReference "r\183\253C\157\200k \249w\164\147e=x\179T\134[$\240o\198K",PropRetainAvailable +// 98,PropPayloadFormatIndicator 154,PropServerKeepAlive 31424,PropRequestProblemInformation +// 217,PropSharedSubscriptionAvailable 181,PropPayloadFormatIndicator 219,PropMessageExpiryInterval +// 31400,PropRequestProblemInformation 53,PropServerKeepAlive 18882,PropRequestProblemInformation +// 36,PropSubscriptionIdentifierAvailable 44,PropServerKeepAlive 17813,PropRetainAvailable 254,PropTopicAlias +// 5704,PropAssignedClientIdentifier "|\210\200Vg\247i\133\SUB\221\168y\255",PropMaximumQoS +// 72,PropWildcardSubscriptionAvailable 227,PropSessionExpiryInterval 8466]) +TEST(PubACKCOMP5QCTest, Decode30) { + uint8_t pkt[] = {0x70, 0x96, 0x1, 0x77, 0xe8, 0x41, 0x91, 0x1, 0x13, 0x25, 0x52, 0x3, 0x0, 0x5, 0x1b, 0x2b, + 0xec, 0xac, 0x70, 0x27, 0x0, 0x0, 0x74, 0x5, 0x15, 0x0, 0x15, 0x68, 0xfe, 0xcc, 0x8d, 0xc8, + 0xea, 0xbc, 0x38, 0xf2, 0xf6, 0xd4, 0x2a, 0x42, 0x1e, 0x19, 0xf6, 0xd, 0xa8, 0xca, 0x6, 0x6d, + 0x18, 0x0, 0x0, 0x10, 0x7b, 0x25, 0x47, 0x25, 0x64, 0x24, 0xd6, 0x11, 0x0, 0x0, 0x1b, 0xa4, + 0x2a, 0x91, 0x1c, 0x0, 0x18, 0x72, 0xb7, 0xfd, 0x43, 0x9d, 0xc8, 0x6b, 0x20, 0xf9, 0x77, 0xa4, + 0x93, 0x65, 0x3d, 0x78, 0xb3, 0x54, 0x86, 0x5b, 0x24, 0xf0, 0x6f, 0xc6, 0x4b, 0x25, 0x62, 0x1, + 0x9a, 0x13, 0x7a, 0xc0, 0x17, 0xd9, 0x2a, 0xb5, 0x1, 0xdb, 0x2, 0x0, 0x0, 0x7a, 0xa8, 0x17, + 0x35, 0x13, 0x49, 0xc2, 0x17, 0x24, 0x29, 0x2c, 0x13, 0x45, 0x95, 0x25, 0xfe, 0x23, 0x16, 0x48, + 0x12, 0x0, 0xd, 0x7c, 0xd2, 0xc8, 0x56, 0x67, 0xf7, 0x69, 0x85, 0x1a, 0xdd, 0xa8, 0x79, 0xff, + 0x24, 0x48, 0x28, 0xe3, 0x11, 0x0, 0x0, 0x21, 0x12}; + uint16_t packet_id; + uint8_t status; + lwmqtt_serialized_properties_t props; + bool dup; + lwmqtt_err_t err = + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 30696); + EXPECT_EQ(status, 65); +} - lwmqtt_properties_t willprops = {29, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xf, 0xe}; - lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x1a, 0x7b, 0xe, 0x19, 0xbe}; - lwmqtt_string_t will_payload = {5, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; - will.properties = willprops; +// ConnectRequest {_username = Just "]k\133\158\155\DC3\CANdB\149\244\NAKV\174", _password = Just +// "\243e\SUB\196D\v\196W8P\245\&6", _lastWill = Nothing, _cleanSession = True, _keepAlive = 1258, _connID = +// "q\SOH\220\128\ncN%\188\&7\248FP@\170\NUL\DELN\194\221o", _properties = []} +TEST(Connect311QCTest, Encode1) { + uint8_t pkt[] = {0x10, 0x3f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x4, 0xea, 0x0, 0x15, 0x71, 0x1, 0xdc, + 0x80, 0xa, 0x63, 0x4e, 0x25, 0xbc, 0x37, 0xf8, 0x46, 0x50, 0x40, 0xaa, 0x0, 0x7f, 0x4e, 0xc2, 0xdd, + 0x6f, 0x0, 0xe, 0x5d, 0x6b, 0x85, 0x9e, 0x9b, 0x13, 0x18, 0x64, 0x42, 0x95, 0xf4, 0x15, 0x56, 0xae, + 0x0, 0xc, 0xf3, 0x65, 0x1a, 0xc4, 0x44, 0xb, 0xc4, 0x57, 0x38, 0x50, 0xf5, 0x36}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 3695; - uint8_t client_id_bytes[] = {0x56, 0x9f, 0xa1, 0xe7, 0xed, 0xc8, 0x9a, 0x86, 0xce, 0x58, 0x8f}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.keep_alive = 1258; + uint8_t client_id_bytes[] = {0x71, 0x1, 0xdc, 0x80, 0xa, 0x63, 0x4e, 0x25, 0xbc, 0x37, 0xf8, + 0x46, 0x50, 0x40, 0xaa, 0x0, 0x7f, 0x4e, 0xc2, 0xdd, 0x6f}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x9f, 0x56, 0x4, 0x5, 0x52, 0x7, 0xa9, 0x4a, 0x4}; - lwmqtt_string_t password = {9, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x5d, 0x6b, 0x85, 0x9e, 0x9b, 0x13, 0x18, 0x64, 0x42, 0x95, 0xf4, 0x15, 0x56, 0xae}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf3, 0x65, 0x1a, 0xc4, 0x44, 0xb, 0xc4, 0x57, 0x38, 0x50, 0xf5, 0x36}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\US\184\177\250\165\178m\202\177\229\250+d\229", _password = Just "4#", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\DLE\157\231\207\176$D\205\246cj\139\212\151\237\181\225\198\182>C\FS", _willMsg = -// "\242\166\\\SYN\191\r\DC2d8\129\239\138\135\230\214]\CAN#K\206\USb%R\215\254\242\255\GS\139", _willProps = -// [PropMessageExpiryInterval 10172,PropServerKeepAlive 6438,PropWildcardSubscriptionAvailable 190,PropResponseTopic -// "",PropMessageExpiryInterval 30408,PropMessageExpiryInterval 16984,PropRetainAvailable -// 240,PropSubscriptionIdentifierAvailable 176,PropAssignedClientIdentifier "[\228\138d\USq\v\FS\172",PropReceiveMaximum -// 14049,PropMaximumQoS 252,PropContentType "\252",PropServerKeepAlive 31013]}), _cleanSession = True, _keepAlive = -// 21935, _connID = "", _properties = [PropUserProperty "\169\176\198\202\133\GS\188\USq\SYN\194\135\249\187J" -// "\211\224S;\229\176ID\210\168\US\185Mo\241\137\144\153\143\203\250\ETXW\251",PropTopicAliasMaximum -// 23665,PropServerReference "\SUB\DC1\253\168\&7\NAK'&\186\137\215\158O\229b9",PropSessionExpiryInterval 15033]} -TEST(Connect5QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0xd4, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x55, 0xaf, 0x47, 0x26, 0x0, 0xf, - 0xa9, 0xb0, 0xc6, 0xca, 0x85, 0x1d, 0xbc, 0x1f, 0x71, 0x16, 0xc2, 0x87, 0xf9, 0xbb, 0x4a, 0x0, 0x18, - 0xd3, 0xe0, 0x53, 0x3b, 0xe5, 0xb0, 0x49, 0x44, 0xd2, 0xa8, 0x1f, 0xb9, 0x4d, 0x6f, 0xf1, 0x89, 0x90, - 0x99, 0x8f, 0xcb, 0xfa, 0x3, 0x57, 0xfb, 0x22, 0x5c, 0x71, 0x1c, 0x0, 0x10, 0x1a, 0x11, 0xfd, 0xa8, - 0x37, 0x15, 0x27, 0x26, 0xba, 0x89, 0xd7, 0x9e, 0x4f, 0xe5, 0x62, 0x39, 0x11, 0x0, 0x0, 0x3a, 0xb9, - 0x0, 0x0, 0x33, 0x2, 0x0, 0x0, 0x27, 0xbc, 0x13, 0x19, 0x26, 0x28, 0xbe, 0x8, 0x0, 0x0, 0x2, - 0x0, 0x0, 0x76, 0xc8, 0x2, 0x0, 0x0, 0x42, 0x58, 0x25, 0xf0, 0x29, 0xb0, 0x12, 0x0, 0x9, 0x5b, - 0xe4, 0x8a, 0x64, 0x1f, 0x71, 0xb, 0x1c, 0xac, 0x21, 0x36, 0xe1, 0x24, 0xfc, 0x3, 0x0, 0x1, 0xfc, - 0x13, 0x79, 0x25, 0x0, 0x16, 0x10, 0x9d, 0xe7, 0xcf, 0xb0, 0x24, 0x44, 0xcd, 0xf6, 0x63, 0x6a, 0x8b, - 0xd4, 0x97, 0xed, 0xb5, 0xe1, 0xc6, 0xb6, 0x3e, 0x43, 0x1c, 0x0, 0x1e, 0xf2, 0xa6, 0x5c, 0x16, 0xbf, - 0xd, 0x12, 0x64, 0x38, 0x81, 0xef, 0x8a, 0x87, 0xe6, 0xd6, 0x5d, 0x18, 0x23, 0x4b, 0xce, 0x1f, 0x62, - 0x25, 0x52, 0xd7, 0xfe, 0xf2, 0xff, 0x1d, 0x8b, 0x0, 0xe, 0x1f, 0xb8, 0xb1, 0xfa, 0xa5, 0xb2, 0x6d, - 0xca, 0xb1, 0xe5, 0xfa, 0x2b, 0x64, 0xe5, 0x0, 0x2, 0x34, 0x23}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0xd3, 0xe0, 0x53, 0x3b, 0xe5, 0xb0, 0x49, 0x44, 0xd2, 0xa8, 0x1f, 0xb9, - 0x4d, 0x6f, 0xf1, 0x89, 0x90, 0x99, 0x8f, 0xcb, 0xfa, 0x3, 0x57, 0xfb}; - uint8_t bytesprops0[] = {0xa9, 0xb0, 0xc6, 0xca, 0x85, 0x1d, 0xbc, 0x1f, 0x71, 0x16, 0xc2, 0x87, 0xf9, 0xbb, 0x4a}; - uint8_t bytesprops2[] = {0x1a, 0x11, 0xfd, 0xa8, 0x37, 0x15, 0x27, 0x26, - 0xba, 0x89, 0xd7, 0x9e, 0x4f, 0xe5, 0x62, 0x39}; +// ConnectRequest {_username = Just "G>+\146\187X\SUB\205\220Z.\247\207\STX", _password = Just "l\254", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "H\158\252\SO\244\128\177\DC3\140m\154C\228\255\209\SO\252\215Wt\129t}\131", _willMsg = +// ";\228r\149\RS]\243u\250o\247\164,_\199", _willProps = []}), _cleanSession = False, _keepAlive = 6895, _connID = +// "/\215\GS\133\&67\233\250\218\RS\249)\ETB", _properties = []} +TEST(Connect311QCTest, Encode2) { + uint8_t pkt[] = {0x10, 0x58, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x1a, 0xef, 0x0, 0xd, 0x2f, + 0xd7, 0x1d, 0x85, 0x36, 0x37, 0xe9, 0xfa, 0xda, 0x1e, 0xf9, 0x29, 0x17, 0x0, 0x18, 0x48, + 0x9e, 0xfc, 0xe, 0xf4, 0x80, 0xb1, 0x13, 0x8c, 0x6d, 0x9a, 0x43, 0xe4, 0xff, 0xd1, 0xe, + 0xfc, 0xd7, 0x57, 0x74, 0x81, 0x74, 0x7d, 0x83, 0x0, 0xf, 0x3b, 0xe4, 0x72, 0x95, 0x1e, + 0x5d, 0xf3, 0x75, 0xfa, 0x6f, 0xf7, 0xa4, 0x2c, 0x5f, 0xc7, 0x0, 0xe, 0x47, 0x3e, 0x2b, + 0x92, 0xbb, 0x58, 0x1a, 0xcd, 0xdc, 0x5a, 0x2e, 0xf7, 0xcf, 0x2, 0x0, 0x2, 0x6c, 0xfe}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23665}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15033}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0}; - uint8_t byteswillprops1[] = {0x5b, 0xe4, 0x8a, 0x64, 0x1f, 0x71, 0xb, 0x1c, 0xac}; - uint8_t byteswillprops2[] = {0xfc}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10172}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6438}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30408}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16984}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 240}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14049}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31013}}, - }; + lwmqtt_property_t willpropslist[] = {}; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x10, 0x9d, 0xe7, 0xcf, 0xb0, 0x24, 0x44, 0xcd, 0xf6, 0x63, 0x6a, - 0x8b, 0xd4, 0x97, 0xed, 0xb5, 0xe1, 0xc6, 0xb6, 0x3e, 0x43, 0x1c}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf2, 0xa6, 0x5c, 0x16, 0xbf, 0xd, 0x12, 0x64, 0x38, 0x81, - 0xef, 0x8a, 0x87, 0xe6, 0xd6, 0x5d, 0x18, 0x23, 0x4b, 0xce, - 0x1f, 0x62, 0x25, 0x52, 0xd7, 0xfe, 0xf2, 0xff, 0x1d, 0x8b}; - lwmqtt_string_t will_payload = {30, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x48, 0x9e, 0xfc, 0xe, 0xf4, 0x80, 0xb1, 0x13, 0x8c, 0x6d, 0x9a, 0x43, + 0xe4, 0xff, 0xd1, 0xe, 0xfc, 0xd7, 0x57, 0x74, 0x81, 0x74, 0x7d, 0x83}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3b, 0xe4, 0x72, 0x95, 0x1e, 0x5d, 0xf3, 0x75, + 0xfa, 0x6f, 0xf7, 0xa4, 0x2c, 0x5f, 0xc7}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -9512,657 +8844,326 @@ TEST(Connect5QCTest, Encode24) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 21935; - uint8_t client_id_bytes[] = {0}; - lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 6895; + uint8_t client_id_bytes[] = {0x2f, 0xd7, 0x1d, 0x85, 0x36, 0x37, 0xe9, 0xfa, 0xda, 0x1e, 0xf9, 0x29, 0x17}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x1f, 0xb8, 0xb1, 0xfa, 0xa5, 0xb2, 0x6d, 0xca, 0xb1, 0xe5, 0xfa, 0x2b, 0x64, 0xe5}; + uint8_t username_bytes[] = {0x47, 0x3e, 0x2b, 0x92, 0xbb, 0x58, 0x1a, 0xcd, 0xdc, 0x5a, 0x2e, 0xf7, 0xcf, 0x2}; lwmqtt_string_t username = {14, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x34, 0x23}; + uint8_t password_bytes[] = {0x6c, 0xfe}; lwmqtt_string_t password = {2, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\223\FS\149\212{Q\139+/s\191U\174l\n\173", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "AbQ~\153\211\195\255aR\240\202u\223", _willMsg = -// "\254\139\131\221\&7y\167\ETX\187I\188O~e\199", _willProps = [PropContentType -// "'\161^\GS\NAK*\DC4\158A\141\229\135",PropResponseTopic "\222\229\&7\167\192\177",PropReasonString -// "jJL\n7\250\173\NULx\ENQ\245",PropContentType -// "\SOH\253\f&\217\230\253,\164\246\162\227ms,\172\161\218\b\168\178w3",PropMessageExpiryInterval 15070]}), -// _cleanSession = False, _keepAlive = 5033, _connID = -// "\168\223\181\140\b\149\&4\184\157\178\201.\ETX\169Tm\178;\228b\\\246\DLE", _properties = [PropResponseInformation -// "\212\SYN\137\165Fi\152\ETB%\128\216\254\142C\150:\r\254\203S\RS\229\149\188&yS\137\239\GS",PropWildcardSubscriptionAvailable -// 197,PropWildcardSubscriptionAvailable 24,PropServerKeepAlive 21035,PropMessageExpiryInterval 969,PropRetainAvailable -// 9,PropServerReference -// "\147\ETX\233\SI^\128\n\152VB\254\142\252\174\252\160K\219\229\254n\234\&3\SYNbK\186",PropMaximumQoS -// 116,PropMaximumPacketSize 7900,PropReasonString "&\248\165w\200\ENQ\223\213J",PropMaximumQoS -// 31,PropSharedSubscriptionAvailable 112]} -TEST(Connect5QCTest, Encode25) { - uint8_t pkt[] = { - 0x10, 0x81, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x4c, 0x13, 0xa9, 0x64, 0x1a, 0x0, 0x1e, 0xd4, 0x16, - 0x89, 0xa5, 0x46, 0x69, 0x98, 0x17, 0x25, 0x80, 0xd8, 0xfe, 0x8e, 0x43, 0x96, 0x3a, 0xd, 0xfe, 0xcb, 0x53, 0x1e, - 0xe5, 0x95, 0xbc, 0x26, 0x79, 0x53, 0x89, 0xef, 0x1d, 0x28, 0xc5, 0x28, 0x18, 0x13, 0x52, 0x2b, 0x2, 0x0, 0x0, - 0x3, 0xc9, 0x25, 0x9, 0x1c, 0x0, 0x1b, 0x93, 0x3, 0xe9, 0xf, 0x5e, 0x80, 0xa, 0x98, 0x56, 0x42, 0xfe, 0x8e, - 0xfc, 0xae, 0xfc, 0xa0, 0x4b, 0xdb, 0xe5, 0xfe, 0x6e, 0xea, 0x33, 0x16, 0x62, 0x4b, 0xba, 0x24, 0x74, 0x27, 0x0, - 0x0, 0x1e, 0xdc, 0x1f, 0x0, 0x9, 0x26, 0xf8, 0xa5, 0x77, 0xc8, 0x5, 0xdf, 0xd5, 0x4a, 0x24, 0x1f, 0x2a, 0x70, - 0x0, 0x17, 0xa8, 0xdf, 0xb5, 0x8c, 0x8, 0x95, 0x34, 0xb8, 0x9d, 0xb2, 0xc9, 0x2e, 0x3, 0xa9, 0x54, 0x6d, 0xb2, - 0x3b, 0xe4, 0x62, 0x5c, 0xf6, 0x10, 0x45, 0x3, 0x0, 0xc, 0x27, 0xa1, 0x5e, 0x1d, 0x15, 0x2a, 0x14, 0x9e, 0x41, - 0x8d, 0xe5, 0x87, 0x8, 0x0, 0x6, 0xde, 0xe5, 0x37, 0xa7, 0xc0, 0xb1, 0x1f, 0x0, 0xb, 0x6a, 0x4a, 0x4c, 0xa, - 0x37, 0xfa, 0xad, 0x0, 0x78, 0x5, 0xf5, 0x3, 0x0, 0x17, 0x1, 0xfd, 0xc, 0x26, 0xd9, 0xe6, 0xfd, 0x2c, 0xa4, - 0xf6, 0xa2, 0xe3, 0x6d, 0x73, 0x2c, 0xac, 0xa1, 0xda, 0x8, 0xa8, 0xb2, 0x77, 0x33, 0x2, 0x0, 0x0, 0x3a, 0xde, - 0x0, 0xe, 0x41, 0x62, 0x51, 0x7e, 0x99, 0xd3, 0xc3, 0xff, 0x61, 0x52, 0xf0, 0xca, 0x75, 0xdf, 0x0, 0xf, 0xfe, - 0x8b, 0x83, 0xdd, 0x37, 0x79, 0xa7, 0x3, 0xbb, 0x49, 0xbc, 0x4f, 0x7e, 0x65, 0xc7, 0x0, 0x10, 0xdf, 0x1c, 0x95, - 0xd4, 0x7b, 0x51, 0x8b, 0x2b, 0x2f, 0x73, 0xbf, 0x55, 0xae, 0x6c, 0xa, 0xad}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd4, 0x16, 0x89, 0xa5, 0x46, 0x69, 0x98, 0x17, 0x25, 0x80, 0xd8, 0xfe, 0x8e, 0x43, 0x96, - 0x3a, 0xd, 0xfe, 0xcb, 0x53, 0x1e, 0xe5, 0x95, 0xbc, 0x26, 0x79, 0x53, 0x89, 0xef, 0x1d}; - uint8_t bytesprops1[] = {0x93, 0x3, 0xe9, 0xf, 0x5e, 0x80, 0xa, 0x98, 0x56, 0x42, 0xfe, 0x8e, 0xfc, 0xae, - 0xfc, 0xa0, 0x4b, 0xdb, 0xe5, 0xfe, 0x6e, 0xea, 0x33, 0x16, 0x62, 0x4b, 0xba}; - uint8_t bytesprops2[] = {0x26, 0xf8, 0xa5, 0x77, 0xc8, 0x5, 0xdf, 0xd5, 0x4a}; +// ConnectRequest {_username = Just "P\174D\148^\175O\GS", _password = Nothing, _lastWill = Just (LastWill {_willRetain +// = True, _willQoS = QoS0, _willTopic = +// "\133\148;\217\ETX\ESCx\227\193\b\220\220\&2^\206\247,\208\184E\206g\130\RS\174\176\224", _willMsg = +// "&2\134`\139\156\254r\254!RA2\206\243\188", _willProps = []}), _cleanSession = False, _keepAlive = 25004, _connID = +// "/}b5\208\133\FS\133\214c\NUL\151\144\NUL\172\SO\168&&\150\174\191N\206", _properties = []} +TEST(Connect311QCTest, Encode3) { + uint8_t pkt[] = {0x10, 0x5d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa4, 0x61, 0xac, 0x0, 0x18, 0x2f, 0x7d, + 0x62, 0x35, 0xd0, 0x85, 0x1c, 0x85, 0xd6, 0x63, 0x0, 0x97, 0x90, 0x0, 0xac, 0xe, 0xa8, 0x26, + 0x26, 0x96, 0xae, 0xbf, 0x4e, 0xce, 0x0, 0x1b, 0x85, 0x94, 0x3b, 0xd9, 0x3, 0x1b, 0x78, 0xe3, + 0xc1, 0x8, 0xdc, 0xdc, 0x32, 0x5e, 0xce, 0xf7, 0x2c, 0xd0, 0xb8, 0x45, 0xce, 0x67, 0x82, 0x1e, + 0xae, 0xb0, 0xe0, 0x0, 0x10, 0x26, 0x32, 0x86, 0x60, 0x8b, 0x9c, 0xfe, 0x72, 0xfe, 0x21, 0x52, + 0x41, 0x32, 0xce, 0xf3, 0xbc, 0x0, 0x8, 0x50, 0xae, 0x44, 0x94, 0x5e, 0xaf, 0x4f, 0x1d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 197}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21035}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 969}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7900}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 112}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x27, 0xa1, 0x5e, 0x1d, 0x15, 0x2a, 0x14, 0x9e, 0x41, 0x8d, 0xe5, 0x87}; - uint8_t byteswillprops1[] = {0xde, 0xe5, 0x37, 0xa7, 0xc0, 0xb1}; - uint8_t byteswillprops2[] = {0x6a, 0x4a, 0x4c, 0xa, 0x37, 0xfa, 0xad, 0x0, 0x78, 0x5, 0xf5}; - uint8_t byteswillprops3[] = {0x1, 0xfd, 0xc, 0x26, 0xd9, 0xe6, 0xfd, 0x2c, 0xa4, 0xf6, 0xa2, 0xe3, - 0x6d, 0x73, 0x2c, 0xac, 0xa1, 0xda, 0x8, 0xa8, 0xb2, 0x77, 0x33}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15070}}, - }; + lwmqtt_property_t willpropslist[] = {}; - lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x41, 0x62, 0x51, 0x7e, 0x99, 0xd3, 0xc3, 0xff, 0x61, 0x52, 0xf0, 0xca, 0x75, 0xdf}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfe, 0x8b, 0x83, 0xdd, 0x37, 0x79, 0xa7, 0x3, - 0xbb, 0x49, 0xbc, 0x4f, 0x7e, 0x65, 0xc7}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x85, 0x94, 0x3b, 0xd9, 0x3, 0x1b, 0x78, 0xe3, 0xc1, 0x8, 0xdc, 0xdc, 0x32, 0x5e, + 0xce, 0xf7, 0x2c, 0xd0, 0xb8, 0x45, 0xce, 0x67, 0x82, 0x1e, 0xae, 0xb0, 0xe0}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x26, 0x32, 0x86, 0x60, 0x8b, 0x9c, 0xfe, 0x72, + 0xfe, 0x21, 0x52, 0x41, 0x32, 0xce, 0xf3, 0xbc}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 5033; - uint8_t client_id_bytes[] = {0xa8, 0xdf, 0xb5, 0x8c, 0x8, 0x95, 0x34, 0xb8, 0x9d, 0xb2, 0xc9, 0x2e, - 0x3, 0xa9, 0x54, 0x6d, 0xb2, 0x3b, 0xe4, 0x62, 0x5c, 0xf6, 0x10}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 25004; + uint8_t client_id_bytes[] = {0x2f, 0x7d, 0x62, 0x35, 0xd0, 0x85, 0x1c, 0x85, 0xd6, 0x63, 0x0, 0x97, + 0x90, 0x0, 0xac, 0xe, 0xa8, 0x26, 0x26, 0x96, 0xae, 0xbf, 0x4e, 0xce}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xdf, 0x1c, 0x95, 0xd4, 0x7b, 0x51, 0x8b, 0x2b, - 0x2f, 0x73, 0xbf, 0x55, 0xae, 0x6c, 0xa, 0xad}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; - opts.password = password; + uint8_t username_bytes[] = {0x50, 0xae, 0x44, 0x94, 0x5e, 0xaf, 0x4f, 0x1d}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "Q\ESC&\174\247\148\240\DEL]\244\244\245", _password = Just "*\202 ;\132", _lastWill -// = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "\130\&6pS\DC2\ACK(Y\152Y\FS\150\ETBy\207\136\204", _willMsg = -// "\164w\254._0\196?\182\141eY\201\165\141n\163\251|\199\160", _willProps = [PropContentType -// "\154\206-*'Q(\236D@xx\151\148\167T\239xC\195+\142\v\186SA\174\138\166s",PropResponseTopic -// "A\191\DC2E$(\239%vB^\212\181\152?7\150\164f\DEL\220Zp\158\SYNvF\226\151",PropPayloadFormatIndicator -// 101,PropCorrelationData ",2\176$",PropServerKeepAlive 11601,PropMaximumQoS 120,PropServerReference -// "s\230h.\SUB5p9\178\248\227\DC3\n\STXf*\ACKN\242+\225",PropReceiveMaximum 10666,PropMessageExpiryInterval -// 5491,PropRequestProblemInformation 111,PropRequestResponseInformation 47,PropCorrelationData -// "T\200\254\157[x\210\185\228+\186\190P\155*[z\r\188",PropTopicAlias 26651,PropAssignedClientIdentifier -// "",PropSubscriptionIdentifierAvailable 199,PropSessionExpiryInterval 12887,PropContentType -// "J\199fS-_\250\180\160\129K\171\151\155y\220-1"]}), _cleanSession = False, _keepAlive = 6835, _connID = -// "=7\240F\243\217", _properties = [PropSharedSubscriptionAvailable 204,PropResponseInformation -// "e",PropSharedSubscriptionAvailable 192,PropRequestProblemInformation 201,PropSessionExpiryInterval -// 19992,PropAssignedClientIdentifier "\186\&2\ETB\169\190\129o\ETXN\160I",PropUserProperty -// "a?\166r\172\240\159\250\128\187" "kX{\140\215\235/\248\SO\152L\239\229\175~O\199",PropUserProperty "\131\173" -// "\189c\135\&4\t\DEL\130[\176\171\241O\192\189q\149\&3\255\&0\ETBq",PropServerKeepAlive 15269,PropResponseInformation -// "\214\161\150\SOH\136\247cV\158\&2\ENQ\154\249\DC2!\141p:-C%\250q1",PropAssignedClientIdentifier -// "\211<5\229Y$",PropRequestProblemInformation 252,PropServerReference -// "\SOoo\f\156\CAN\157\249S\170\218o\SYN\153\142\207\236\133\176XN6\219iZ",PropTopicAlias -// 27820,PropSubscriptionIdentifierAvailable 228,PropSubscriptionIdentifier 3,PropServerKeepAlive 30256,PropMaximumQoS -// 231]} -TEST(Connect5QCTest, Encode26) { - uint8_t pkt[] = { - 0x10, 0xd6, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x1a, 0xb3, 0xd6, 0x2, 0x2a, 0xcc, 0x1a, 0x0, - 0x1, 0x65, 0x2a, 0xc0, 0x17, 0xc9, 0x11, 0x0, 0x0, 0x4e, 0x18, 0x12, 0x0, 0xb, 0xba, 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 0x5, 0x2a, 0xca, 0x20, 0x3b, 0x84}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x65}; - uint8_t bytesprops1[] = {0xba, 0x32, 0x17, 0xa9, 0xbe, 0x81, 0x6f, 0x3, 0x4e, 0xa0, 0x49}; - uint8_t bytesprops3[] = {0x6b, 0x58, 0x7b, 0x8c, 0xd7, 0xeb, 0x2f, 0xf8, 0xe, - 0x98, 0x4c, 0xef, 0xe5, 0xaf, 0x7e, 0x4f, 0xc7}; - uint8_t bytesprops2[] = {0x61, 0x3f, 0xa6, 0x72, 0xac, 0xf0, 0x9f, 0xfa, 0x80, 0xbb}; - uint8_t bytesprops5[] = {0xbd, 0x63, 0x87, 0x34, 0x9, 0x7f, 0x82, 0x5b, 0xb0, 0xab, 0xf1, - 0x4f, 0xc0, 0xbd, 0x71, 0x95, 0x33, 0xff, 0x30, 0x17, 0x71}; - uint8_t bytesprops4[] = {0x83, 0xad}; - uint8_t bytesprops6[] = {0xd6, 0xa1, 0x96, 0x1, 0x88, 0xf7, 0x63, 0x56, 0x9e, 0x32, 0x3c, - 0x2f, 0x86, 0x3c, 0xbb, 0x87, 0x8b, 0x42, 0xcb, 0x5, 0x17, 0x22}; - uint8_t bytesprops7[] = {0xf6, 0x61, 0x72, 0xcf, 0xe0, 0x94, 0xf9, 0x15, 0x4, - 0x78, 0x11, 0x44, 0xb7, 0xfb, 0x36, 0x90, 0xca}; - uint8_t bytesprops8[] = {0x57, 0xea, 0x4e, 0xf5, 0xe, 0x1f, 0x63, 0x96, 0x72, 0x5c, 0x14}; - uint8_t bytesprops9[] = {0x4e, 0x0, 0xef, 0x91, 0x51, 0x69, 0xd0, 0xde, 0xa2, 0x57, 0x5f, 0x4f, 0x9c, 0x12, 0x30, - 0x9d, 0x82, 0x8f, 0x94, 0x67, 0x28, 0xee, 0xb5, 0xa3, 0xa1, 0x6b, 0xf6, 0xe9, 0x99}; - uint8_t bytesprops10[] = {0x5a, 0xb6, 0x8b, 0xc2, 0x92, 0x8, 0x79, 0x5b, 0x6d, 0x4, 0xfd, - 0xba, 0x19, 0xf1, 0x62, 0xe9, 0x74, 0x9e, 0xad, 0x5e, 0x89, 0x74}; - uint8_t bytesprops11[] = {0xe4, 0x55, 0x4, 0x8f, 0x39, 0xc7, 0x73, 0x73, 0xae, 0xf3, - 0x5e, 0x5f, 0x37, 0xd5, 0x4, 0x9c, 0x5d, 0x4d, 0x24}; - uint8_t bytesprops12[] = {0xbc, 0x8b, 0x5d, 0xd7, 0x34, 0xc2, 0xab, 0x4, 0x3b, 0x78, 0xc9, - 0x4d, 0xfc, 0x8a, 0x1e, 0x8a, 0x13, 0xc7, 0xec, 0x90, 0x55, 0x80}; - uint8_t bytesprops13[] = {0x2d, 0xc0, 0x5c, 0x2, 0x1d, 0x5, 0x6, 0x96, 0x6f, 0x3e, 0x5, 0x9a, - 0xf9, 0x12, 0x21, 0x8d, 0x70, 0x3a, 0x2d, 0x43, 0x25, 0xfa, 0x71, 0x31}; - uint8_t bytesprops14[] = {0xd3, 0x3c, 0x35, 0xe5, 0x59, 0x24}; - uint8_t bytesprops15[] = {0xe, 0x6f, 0x6f, 0xc, 0x9c, 0x18, 0x9d, 0xf9, 0x53, 0xaa, 0xda, 0x6f, 0x16, - 0x99, 0x8e, 0xcf, 0xec, 0x85, 0xb0, 0x58, 0x4e, 0x36, 0xdb, 0x69, 0x5a}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19992}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops2}, .v = {17, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops4}, .v = {21, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15269}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28984}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops15}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27820}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30256}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, - }; +// ConnectRequest {_username = Nothing, _password = Just "t~B\193\194g\135.\205\195'\202\&4\254\167\130&}\131\SO(", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\167\209\SI\144\184\148\175\153P3\152[\245s\f\160\STX\173\250\248\&6|\vh\134\236\&6\214\237E", _willMsg = +// "K9\178\239\192\180\&4\159\238\219\254cw\137\\K\177\175\230", _willProps = []}), _cleanSession = False, _keepAlive = +// 30510, _connID = "\254\DC1x\142\180\241\164\178u\EMn\150\196Ks\GSG\161K\206,\183\NAKu{\239\227y\214\238\251\157?\147!,XQ\180\vF\251P", _password -// = Just "\f\192\209\&7\135\205f\134\181\170)xCW.\190E", _lastWill = Just (LastWill {_willRetain = False, _willQoS = -// QoS2, _willTopic = "\236\202:\200\SO\EMYd\145y6:\171-\DC4 \194", _willMsg = -// "\241\156\177\145\136\DC3h\r\128\187P\182\239\173#\153y0o'\158G\149", _willProps = [PropTopicAlias -// 21,PropWildcardSubscriptionAvailable 157,PropRetainAvailable 182,PropAuthenticationData -// "\194\245\254~wi#\142\214\131\248O\248\196\175Mck3",PropServerKeepAlive 22229,PropAuthenticationData -// "\236\171D\173C]U\192",PropWildcardSubscriptionAvailable 147,PropContentType -// "\220\246\153\DLE\162&\216K\232xv\174;\254\165\135\190\EOT\180J\134~O\195mm\SI\197\b\EM",PropRetainAvailable -// 220,PropUserProperty "\167\194\244p\245=\238\DC1\201" "\238D#5S\160B\242",PropWillDelayInterval -// 10510,PropRequestProblemInformation 144,PropServerReference "e\221\133\147A\NAK\v\139\\\157\131t\208C_I\239\FS -// \232\168]\183Q",PropUserProperty "\216\t\198\192" -// "\136\143\229\225U\194lb%\141\200\&1R`\254\225\192\136;z`\216CgR",PropCorrelationData -// "\180\207\178x\STX\142",PropAuthenticationData -// "\240\DC1\254\162\155\&0\180\243s\195\223\STX\179\168\149F\174\150v\NAK\188\136\DC3\213\226(\137R",PropServerKeepAlive -// 11277,PropWildcardSubscriptionAvailable 162,PropSharedSubscriptionAvailable 16,PropMessageExpiryInterval -// 30939,PropAuthenticationMethod ".\203\&4\150\r\ETB\214\146\&4\225\253\133\215\223",PropTopicAlias -// 4379,PropWillDelayInterval 22271,PropSubscriptionIdentifierAvailable 53,PropAuthenticationData -// "\236;\228$\176\133yZg\ETX\DC1\188\230=\255jI'S\197",PropRequestProblemInformation 132,PropReceiveMaximum 16913]}), -// _cleanSession = True, _keepAlive = 12883, _connID = "\191\194\&3\136\GS\t\240", _properties = -// [PropSubscriptionIdentifier 22,PropUserProperty "\RSP\240{\242\140\r" "e",PropWildcardSubscriptionAvailable -// 74,PropSubscriptionIdentifierAvailable 79,PropMessageExpiryInterval 5364,PropServerReference -// "\222\145\154\252\ESC\163\147\152\203",PropMessageExpiryInterval 22212,PropReasonString -// "\168",PropPayloadFormatIndicator 212,PropRetainAvailable 246,PropUserProperty -// "\237\&4\146}\DC3\252G=^,\SIuu\132\196\143\233\240\SYN" -// ":\198\183\192\218al[\DELNr\206\245\152\236\196\198l\151\SUB\195\188_",PropSharedSubscriptionAvailable -// 192,PropServerKeepAlive 9518,PropCorrelationData "\156>\SO?\216^g\197\146",PropAuthenticationData -// "|>\136\187\214w2",PropMessageExpiryInterval 5171,PropWillDelayInterval 30792,PropAssignedClientIdentifier -// "",PropMaximumQoS 160,PropSharedSubscriptionAvailable 59,PropContentType -// "\238U\161av\178!p\175\197Zz<\ACKC\162\208\177\US\RS\ETBqg1",PropMessageExpiryInterval 2410,PropServerKeepAlive -// 21813,PropRequestProblemInformation 2,PropContentType "\EM\DC1\v\ACK\DC1\177\185\f+",PropMessageExpiryInterval -// 30176,PropUserProperty "a\180U" "\163\156\183\NAK\195\193\a]/|\253\171\US\190[ 4\227\195\214\ETX",PropUserProperty -// "\240\151\205\238\\H" "@\194\234\209`\132\NUL\144T"]} -TEST(Connect5QCTest, Encode27) { - uint8_t pkt[] = { - 0x10, 0xfd, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x32, 0x53, 0xf3, 0x1, 0xb, 0x16, 0x26, 0x0, - 0x7, 0x1e, 0x50, 0xf0, 0x7b, 0xf2, 0x8c, 0xd,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 0x5d, 0xb7, 0x51, 0x26, 0x0, 0x4, 0xd8, 0x9, 0xc6, 0xc0, 0x0, 0x19, 0x88, 0x8f, 0xe5, 0xe1, - 0x55, 0xc2, 0x6c, 0x62, 0x25, 0x8d, 0xc8, 0x31, 0x52, 0x60, 0xfe, 0xe1, 0xc0, 0x88, 0x3b, 0x7a, 0x60, 0xd8, 0x43, - 0x67, 0x52, 0x9, 0x0, 0x6, 0xb4, 0xcf, 0xb2, 0x78, 0x2, 0x8e, 0x16, 0x0, 0x1c, 0xf0, 0x11, 0xfe, 0xa2, 0x9b, - 0x30, 0xb4, 0xf3, 0x73, 0xc3, 0xdf, 0x2, 0xb3, 0xa8, 0x95, 0x46, 0xae, 0x96, 0x76, 0x15, 0xbc, 0x88, 0x13, 0xd5, - 0xe2, 0x28, 0x89, 0x52, 0x13, 0x2c, 0xd, 0x28, 0xa2, 0x2a, 0x10, 0x2, 0x0, 0x0, 0x78, 0xdb, 0x15, 0x0, 0xe, - 0x2e, 0xcb, 0x34, 0x96, 0xd, 0x17, 0xd6, 0x92, 0x34, 0xe1, 0xfd, 0x85, 0xd7, 0xdf, 0x23, 0x11, 0x1b, 0x18, 0x0, - 0x0, 0x56, 0xff, 0x29, 0x35, 0x16, 0x0, 0x14, 0xec, 0x3b, 0xe4, 0x24, 0xb0, 0x85, 0x79, 0x5a, 0x67, 0x3, 0x11, - 0xbc, 0xe6, 0x3d, 0xff, 0x6a, 0x49, 0x27, 0x53, 0xc5, 0x17, 0x84, 0x21, 0x42, 0x11, 0x0, 0x11, 0xec, 0xca, 0x3a, - 0xc8, 0xe, 0x19, 0x59, 0x64, 0x91, 0x79, 0x36, 0x3a, 0xab, 0x2d, 0x14, 0x20, 0xc2, 0x0, 0x17, 0xf1, 0x9c, 0xb1, - 0x91, 0x88, 0x13, 0x68, 0xd, 0x80, 0xbb, 0x50, 0xb6, 0xef, 0xad, 0x23, 0x99, 0x79, 0x30, 0x6f, 0x27, 0x9e, 0x47, - 0x95, 0x0, 0x1d, 0x3e, 0x1d, 0x47, 0xa1, 0x4b, 0xce, 0x2c, 0xb7, 0x15, 0x75, 0x7b, 0xef, 0xe3, 0x79, 0xd6, 0xee, - 0xfb, 0x9d, 0x3f, 0x93, 0x21, 0x2c, 0x58, 0x51, 0xb4, 0xb, 0x46, 0xfb, 0x50, 0x0, 0x11, 0xc, 0xc0, 0xd1, 0x37, - 0x87, 0xcd, 0x66, 0x86, 0xb5, 0xaa, 0x29, 0x78, 0x43, 0x57, 0x2e, 0xbe, 0x45}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x65}; - uint8_t bytesprops0[] = {0x1e, 0x50, 0xf0, 0x7b, 0xf2, 0x8c, 0xd}; - uint8_t bytesprops2[] = {0xde, 0x91, 0x9a, 0xfc, 0x1b, 0xa3, 0x93, 0x98, 0xcb}; - uint8_t bytesprops3[] = {0xa8}; - uint8_t bytesprops5[] = {0x3a, 0xc6, 0xb7, 0xc0, 0xda, 0x61, 0x6c, 0x5b, 0x7f, 0x4e, 0x72, 0xce, - 0xf5, 0x98, 0xec, 0xc4, 0xc6, 0x6c, 0x97, 0x1a, 0xc3, 0xbc, 0x5f}; - uint8_t bytesprops4[] = {0xed, 0x34, 0x92, 0x7d, 0x13, 0xfc, 0x47, 0x3d, 0x5e, 0x2c, - 0xf, 0x75, 0x75, 0x84, 0xc4, 0x8f, 0xe9, 0xf0, 0x16}; - uint8_t bytesprops6[] = {0x9c, 0x3e, 0xe, 0x3f, 0xd8, 0x5e, 0x67, 0xc5, 0x92}; - uint8_t bytesprops7[] = {0x7c, 0x3e, 0x88, 0xbb, 0xd6, 0x77, 0x32}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops9[] = {0xee, 0x55, 0xa1, 0x61, 0x76, 0xb2, 0x21, 0x70, 0xaf, 0xc5, 0x5a, 0x7a, - 0x3c, 0x6, 0x43, 0xa2, 0xd0, 0xb1, 0x1f, 0x1e, 0x17, 0x71, 0x67, 0x31}; - uint8_t bytesprops10[] = {0x19, 0x11, 0xb, 0x6, 0x11, 0xb1, 0xb9, 0xc, 0x2b}; - uint8_t bytesprops12[] = {0xa3, 0x9c, 0xb7, 0x15, 0xc3, 0xc1, 0x7, 0x5d, 0x2f, 0x7c, 0xfd, - 0xab, 0x1f, 0xbe, 0x5b, 0x20, 0x34, 0xe3, 0xc3, 0xd6, 0x3}; - uint8_t bytesprops11[] = {0x61, 0xb4, 0x55}; - uint8_t bytesprops14[] = {0x40, 0xc2, 0xea, 0xd1, 0x60, 0x84, 0x0, 0x90, 0x54}; - uint8_t bytesprops13[] = {0xf0, 0x97, 0xcd, 0xee, 0x5c, 0x48}; +// ConnectRequest {_username = Just "+a\134G\173&O\244\236\DEL\157\220\208cK%\244", _password = Nothing, _lastWill = +// Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\STX", _willMsg = +// "9\f\152&\203\196\153\156^\250\135\135\203\221\139\220S", _willProps = []}), _cleanSession = True, _keepAlive = +// 19375, _connID = "/\\r\181\177\142o\161\139@\150@F", _properties = []} +TEST(Connect311QCTest, Encode5) { + uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0x4b, 0xaf, 0x0, 0xd, + 0x2f, 0x5c, 0x72, 0xb5, 0xb1, 0x8e, 0x6f, 0xa1, 0x8b, 0x40, 0x96, 0x40, 0x46, 0x0, + 0x1, 0x2, 0x0, 0x11, 0x39, 0xc, 0x98, 0x26, 0xcb, 0xc4, 0x99, 0x9c, 0x5e, 0xfa, + 0x87, 0x87, 0xcb, 0xdd, 0x8b, 0xdc, 0x53, 0x0, 0x11, 0x2b, 0x61, 0x86, 0x47, 0xad, + 0x26, 0x4f, 0xf4, 0xec, 0x7f, 0x9d, 0xdc, 0xd0, 0x63, 0x4b, 0x25, 0xf4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops0}, .v = {1, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5364}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22212}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops4}, .v = {23, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9518}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5171}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30792}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2410}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21813}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30176}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops11}, .v = {21, (char*)&bytesprops12}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops13}, .v = {9, (char*)&bytesprops14}}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc2, 0xf5, 0xfe, 0x7e, 0x77, 0x69, 0x23, 0x8e, 0xd6, 0x83, - 0xf8, 0x4f, 0xf8, 0xc4, 0xaf, 0x4d, 0x63, 0x6b, 0x33}; - uint8_t byteswillprops1[] = {0xec, 0xab, 0x44, 0xad, 0x43, 0x5d, 0x55, 0xc0}; - uint8_t byteswillprops2[] = {0xdc, 0xf6, 0x99, 0x10, 0xa2, 0x26, 0xd8, 0x4b, 0xe8, 0x78, - 0x76, 0xae, 0x3b, 0xfe, 0xa5, 0x87, 0xbe, 0x4, 0xb4, 0x4a, - 0x86, 0x7e, 0x4f, 0xc3, 0x6d, 0x6d, 0xf, 0xc5, 0x8, 0x19}; - uint8_t byteswillprops4[] = {0xee, 0x44, 0x23, 0x35, 0x53, 0xa0, 0x42, 0xf2}; - uint8_t byteswillprops3[] = {0xa7, 0xc2, 0xf4, 0x70, 0xf5, 0x3d, 0xee, 0x11, 0xc9}; - uint8_t byteswillprops5[] = {0x65, 0xdd, 0x85, 0x93, 0x41, 0x15, 0xb, 0x8b, 0x5c, 0x9d, 0x83, 0x74, - 0xd0, 0x43, 0x5f, 0x49, 0xef, 0x1c, 0x20, 0xe8, 0xa8, 0x5d, 0xb7, 0x51}; - uint8_t byteswillprops7[] = {0x88, 0x8f, 0xe5, 0xe1, 0x55, 0xc2, 0x6c, 0x62, 0x25, 0x8d, 0xc8, 0x31, 0x52, - 0x60, 0xfe, 0xe1, 0xc0, 0x88, 0x3b, 0x7a, 0x60, 0xd8, 0x43, 0x67, 0x52}; - uint8_t byteswillprops6[] = {0xd8, 0x9, 0xc6, 0xc0}; - uint8_t byteswillprops8[] = {0xb4, 0xcf, 0xb2, 0x78, 0x2, 0x8e}; - uint8_t byteswillprops9[] = {0xf0, 0x11, 0xfe, 0xa2, 0x9b, 0x30, 0xb4, 0xf3, 0x73, 0xc3, 0xdf, 0x2, 0xb3, 0xa8, - 0x95, 0x46, 0xae, 0x96, 0x76, 0x15, 0xbc, 0x88, 0x13, 0xd5, 0xe2, 0x28, 0x89, 0x52}; - uint8_t byteswillprops10[] = {0x2e, 0xcb, 0x34, 0x96, 0xd, 0x17, 0xd6, 0x92, 0x34, 0xe1, 0xfd, 0x85, 0xd7, 0xdf}; - uint8_t byteswillprops11[] = {0xec, 0x3b, 0xe4, 0x24, 0xb0, 0x85, 0x79, 0x5a, 0x67, 0x3, - 0x11, 0xbc, 0xe6, 0x3d, 0xff, 0x6a, 0x49, 0x27, 0x53, 0xc5}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22229}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {9, (char*)&byteswillprops3}, .v = {8, (char*)&byteswillprops4}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10510}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {4, (char*)&byteswillprops6}, .v = {25, (char*)&byteswillprops7}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11277}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30939}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops10}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4379}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22271}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&byteswillprops11}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16913}}, - }; + lwmqtt_property_t willpropslist[] = {}; - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xec, 0xca, 0x3a, 0xc8, 0xe, 0x19, 0x59, 0x64, 0x91, - 0x79, 0x36, 0x3a, 0xab, 0x2d, 0x14, 0x20, 0xc2}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xf1, 0x9c, 0xb1, 0x91, 0x88, 0x13, 0x68, 0xd, 0x80, 0xbb, 0x50, 0xb6, - 0xef, 0xad, 0x23, 0x99, 0x79, 0x30, 0x6f, 0x27, 0x9e, 0x47, 0x95}; - lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x39, 0xc, 0x98, 0x26, 0xcb, 0xc4, 0x99, 0x9c, 0x5e, + 0xfa, 0x87, 0x87, 0xcb, 0xdd, 0x8b, 0xdc, 0x53}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 12883; - uint8_t client_id_bytes[] = {0xbf, 0xc2, 0x33, 0x88, 0x1d, 0x9, 0xf0}; + opts.keep_alive = 19375; + uint8_t client_id_bytes[] = {0x2f, 0x5c, 0x72, 0xb5, 0xb1, 0x8e, 0x6f, 0xa1, 0x8b, 0x40, 0x96, 0x40, 0x46}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x2b, 0x61, 0x86, 0x47, 0xad, 0x26, 0x4f, 0xf4, 0xec, + 0x7f, 0x9d, 0xdc, 0xd0, 0x63, 0x4b, 0x25, 0xf4}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\190\145\130w(G[n\144\185\"\138A\235\255GZ\SI\251\136*\210 +// \238$*\DC3\136\223\238", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "\154\153\177L7?\EM \243\242#e\CAN,\194\180\CANV\230y\\\RS", _willMsg = "\147\239z\187\224\229", _willProps = []}), +// _cleanSession = True, _keepAlive = 14576, _connID = "m\168E>\DC1\GSp", _properties = []} +TEST(Connect311QCTest, Encode6) { + uint8_t pkt[] = {0x10, 0x33, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x38, 0xf0, 0x0, 0x7, + 0x6d, 0xa8, 0x45, 0x3e, 0x11, 0x1d, 0x70, 0x0, 0x16, 0x9a, 0x99, 0xb1, 0x4c, 0x37, + 0x3f, 0x19, 0x20, 0xf3, 0xf2, 0x23, 0x65, 0x18, 0x2c, 0xc2, 0xb4, 0x18, 0x56, 0xe6, + 0x79, 0x5c, 0x1e, 0x0, 0x6, 0x93, 0xef, 0x7a, 0xbb, 0xe0, 0xe5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9a, 0x99, 0xb1, 0x4c, 0x37, 0x3f, 0x19, 0x20, 0xf3, 0xf2, 0x23, + 0x65, 0x18, 0x2c, 0xc2, 0xb4, 0x18, 0x56, 0xe6, 0x79, 0x5c, 0x1e}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x93, 0xef, 0x7a, 0xbb, 0xe0, 0xe5}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 14576; + uint8_t client_id_bytes[] = {0x6d, 0xa8, 0x45, 0x3e, 0x11, 0x1d, 0x70}; lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x3e, 0x1d, 0x47, 0xa1, 0x4b, 0xce, 0x2c, 0xb7, 0x15, 0x75, 0x7b, 0xef, 0xe3, 0x79, 0xd6, - 0xee, 0xfb, 0x9d, 0x3f, 0x93, 0x21, 0x2c, 0x58, 0x51, 0xb4, 0xb, 0x46, 0xfb, 0x50}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; + uint8_t password_bytes[] = {0xbe, 0x91, 0x82, 0x77, 0x28, 0x47, 0x5b, 0x6e, 0x90, 0xb9, 0x22, 0x8a, 0x41, 0xeb, 0xff, + 0x47, 0x5a, 0xf, 0xfb, 0x88, 0x2a, 0xd2, 0x20, 0xee, 0x24, 0x2a, 0x13, 0x88, 0xdf, 0xee}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Ibz\161\NAK]\135\187\244P\201n\128\254LP\157\215\&5 ", _password = Just +// "\DC1\179\173\241Kq\135\157\&0\174?\226\202\185?\NUL\225\201\214\r", _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 25611, _connID = "Q0\230c\ENQ\197x\GS\144k\195\162", _properties = []} +TEST(Connect311QCTest, Encode7) { + uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x64, 0xb, 0x0, 0xc, + 0x51, 0x30, 0xe6, 0x63, 0x5, 0xc5, 0x78, 0x1d, 0x90, 0x6b, 0xc3, 0xa2, 0x0, 0x14, + 0x49, 0x62, 0x7a, 0xa1, 0x15, 0x5d, 0x87, 0xbb, 0xf4, 0x50, 0xc9, 0x6e, 0x80, 0xfe, + 0x4c, 0x50, 0x9d, 0xd7, 0x35, 0x20, 0x0, 0x14, 0x11, 0xb3, 0xad, 0xf1, 0x4b, 0x71, + 0x87, 0x9d, 0x30, 0xae, 0x3f, 0xe2, 0xca, 0xb9, 0x3f, 0x0, 0xe1, 0xc9, 0xd6, 0xd}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 25611; + uint8_t client_id_bytes[] = {0x51, 0x30, 0xe6, 0x63, 0x5, 0xc5, 0x78, 0x1d, 0x90, 0x6b, 0xc3, 0xa2}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x49, 0x62, 0x7a, 0xa1, 0x15, 0x5d, 0x87, 0xbb, 0xf4, 0x50, + 0xc9, 0x6e, 0x80, 0xfe, 0x4c, 0x50, 0x9d, 0xd7, 0x35, 0x20}; + lwmqtt_string_t username = {20, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xc, 0xc0, 0xd1, 0x37, 0x87, 0xcd, 0x66, 0x86, 0xb5, - 0xaa, 0x29, 0x78, 0x43, 0x57, 0x2e, 0xbe, 0x45}; - lwmqtt_string_t password = {17, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x11, 0xb3, 0xad, 0xf1, 0x4b, 0x71, 0x87, 0x9d, 0x30, 0xae, + 0x3f, 0xe2, 0xca, 0xb9, 0x3f, 0x0, 0xe1, 0xc9, 0xd6, 0xd}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\148o\200m\186<\174\187@H*\199\199k\241N\207z\181$\235z\253j\134{", _password = -// Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "", _willMsg = -// "U\STX\188\199\130;", _willProps = [PropPayloadFormatIndicator 132,PropServerReference -// "\170\132t\195V",PropPayloadFormatIndicator 178,PropRequestResponseInformation 96,PropServerKeepAlive -// 9172,PropAssignedClientIdentifier "i\192",PropRequestResponseInformation 37,PropMessageExpiryInterval -// 19524,PropSharedSubscriptionAvailable 118,PropWillDelayInterval 17746,PropSubscriptionIdentifierAvailable -// 127,PropSessionExpiryInterval 472,PropResponseInformation -// "\141\250qW\223\253\SUB\252\&4D\170\137\DC3n\b\183\208=\153\236\159\201\159",PropSharedSubscriptionAvailable -// 150,PropWildcardSubscriptionAvailable 221,PropSubscriptionIdentifierAvailable 233,PropResponseTopic -// "",PropSubscriptionIdentifier 13,PropAssignedClientIdentifier -// "FI\195a\235\207\ETBV\146e\ESC\140\DLE\203G\248\175\219\226\&3\238\245\183\249\169\145\DC3",PropRetainAvailable -// 121,PropServerReference "<\174D\171p#\215\&0\252{Hz\218\f5f\185\189\SOH\246?",PropMessageExpiryInterval -// 15394,PropServerKeepAlive 17437,PropAssignedClientIdentifier "q\129\t\232g\vx\DC3\247V2,\240",PropAuthenticationData -// "[\215\255\168\194\203\r\DC39T\145e\207\223\n\154\152",PropContentType -// "7>\218\155\&7\EOT\194?4\219\&9\147^[\208\SI\DC2\ETB\128\a",PropAuthenticationData "\232\244r\172\150\172\202\r"]}), -// _cleanSession = True, _keepAlive = 3904, _connID = "\197#\190r4\236\133\t\SIY\198\226\213\244\145", _properties = -// [PropAssignedClientIdentifier -// "\232\255\&0\209\230;\163\SOH\DC1W\195\245\151\152.k4\199\184\160\SOHK5\253\bs\227\243",PropRetainAvailable -// 233,PropTopicAliasMaximum 12059,PropServerKeepAlive 30416,PropServerReference -// "\STX\233(\186\n\178\236",PropWildcardSubscriptionAvailable 183,PropWillDelayInterval -// 3122,PropRequestProblemInformation 134,PropResponseInformation "\210\191B\190\229\138\&0",PropContentType -// "F|\179y\166H\200>!\175\227\154\151\139\206Z\151\179S\EM\251",PropRequestProblemInformation -// 132,PropResponseInformation "L_\172\207_lX\164\STX4J\236\211!\245\STX[\128\&23\163] ",PropUserProperty "\168" -// "\183T\242\131\181\r\229\191\200\212\252\154\175\\Q\167\\\182\232T\188\n\EOT\130"]} -TEST(Connect5QCTest, Encode28) { - uint8_t pkt[] = { - 0x10, 0xb1, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0xf, 0x40, 0x96, 0x1, 0x12, 0x0, 0x1c, 0xe8, - 0xff, 0x30, 0xd1, 0xe6, 0x3b, 0xa3, 0x1, 0x11, 0x57, 0xc3, 0xf5, 0x97, 0x98, 0x2e, 0x6b, 0x34, 0xc7, 0xb8, 0xa0, - 0x1, 0x4b, 0x35, 0xfd, 0x8, 0x73, 0xe3, 0xf3, 0x25, 0xe9, 0x22, 0x2f, 0x1b, 0x13, 0x76, 0xd0, 0x1c, 0x0, 0x7, - 0x2, 0xe9, 0x28, 0xba, 0xa, 0xb2, 0xec, 0x28, 0xb7, 0x18, 0x0, 0x0, 0xc, 0x32, 0x17, 0x86, 0x1a, 0x0, 0x7, - 0xd2, 0xbf, 0x42, 0xbe, 0xe5, 0x8a, 0x30, 0x3, 0x0, 0x15, 0x46, 0x7c, 0xb3, 0x79, 0xa6, 0x48, 0xc8, 0x3e, 0x21, - 0xaf, 0xe3, 0x9a, 0x97, 0x8b, 0xce, 0x5a, 0x97, 0xb3, 0x53, 0x19, 0xfb, 0x17, 0x84, 0x1a, 0x0, 0x17, 0x4c, 0x5f, - 0xac, 0xcf, 0x5f, 0x6c, 0x58, 0xa4, 0x2, 0x34, 0x4a, 0xec, 0xd3, 0x21, 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35, 0x66, 0xb9, 0xbd, 0x1, 0xf6, 0x3f, 0x2, 0x0, 0x0, - 0x3c, 0x22, 0x13, 0x44, 0x1d, 0x12, 0x0, 0xd, 0x71, 0x81, 0x9, 0xe8, 0x67, 0xb, 0x78, 0x13, 0xf7, 0x56, 0x32, - 0x2c, 0xf0, 0x16, 0x0, 0x11, 0x5b, 0xd7, 0xff, 0xa8, 0xc2, 0xcb, 0xd, 0x13, 0x39, 0x54, 0x91, 0x65, 0xcf, 0xdf, - 0xa, 0x9a, 0x98, 0x3, 0x0, 0x14, 0x37, 0x3e, 0xda, 0x9b, 0x37, 0x4, 0xc2, 0x3f, 0x34, 0xdb, 0x39, 0x93, 0x5e, - 0x5b, 0xd0, 0xf, 0x12, 0x17, 0x80, 0x7, 0x16, 0x0, 0x8, 0xe8, 0xf4, 0x72, 0xac, 0x96, 0xac, 0xca, 0xd, 0x0, - 0x0, 0x0, 0x6, 0x55, 0x2, 0xbc, 0xc7, 0x82, 0x3b, 0x0, 0x1a, 0x94, 0x6f, 0xc8, 0x6d, 0xba, 0x3c, 0xae, 0xbb, - 0x40, 0x48, 0x2a, 0xc7, 0xc7, 0x6b, 0xf1, 0x4e, 0xcf, 0x7a, 0xb5, 0x24, 0xeb, 0x7a, 0xfd, 0x6a, 0x86, 0x7b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe8, 0xff, 0x30, 0xd1, 0xe6, 0x3b, 0xa3, 0x1, 0x11, 0x57, 0xc3, 0xf5, 0x97, 0x98, - 0x2e, 0x6b, 0x34, 0xc7, 0xb8, 0xa0, 0x1, 0x4b, 0x35, 0xfd, 0x8, 0x73, 0xe3, 0xf3}; - uint8_t bytesprops1[] = {0x2, 0xe9, 0x28, 0xba, 0xa, 0xb2, 0xec}; - uint8_t bytesprops2[] = {0xd2, 0xbf, 0x42, 0xbe, 0xe5, 0x8a, 0x30}; - uint8_t bytesprops3[] = {0x46, 0x7c, 0xb3, 0x79, 0xa6, 0x48, 0xc8, 0x3e, 0x21, 0xaf, 0xe3, - 0x9a, 0x97, 0x8b, 0xce, 0x5a, 0x97, 0xb3, 0x53, 0x19, 0xfb}; - uint8_t bytesprops4[] = {0x4c, 0x5f, 0xac, 0xcf, 0x5f, 0x6c, 0x58, 0xa4, 0x2, 0x34, 0x4a, 0xec, - 0xd3, 0x21, 0xf5, 0x2, 0x5b, 0x80, 0x32, 0x33, 0xa3, 0x5d, 0x20}; - uint8_t bytesprops6[] = {0xb7, 0x54, 0xf2, 0x83, 0xb5, 0xd, 0xe5, 0xbf, 0xc8, 0xd4, 0xfc, 0x9a, - 0xaf, 0x5c, 0x51, 0xa7, 0x5c, 0xb6, 0xe8, 0x54, 0xbc, 0xa, 0x4, 0x82}; - uint8_t bytesprops5[] = {0xa8}; +// ConnectRequest {_username = Just "\211\231\&0\207\223D\193V\147\196\212\176\247\139\172\\\193", _password = Nothing, +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 29750, _connID = "{\160+gG\160\227*\159\208'h\197K\222\&2\tP +// \144\148\149\214l\201", _properties = []} +TEST(Connect311QCTest, Encode8) { + uint8_t pkt[] = {0x10, 0x38, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x80, 0x74, 0x36, 0x0, 0x19, 0x7b, + 0xa0, 0x2b, 0x67, 0x47, 0xa0, 0xe3, 0x2a, 0x9f, 0xd0, 0x27, 0x68, 0xc5, 0x4b, 0xde, 0x32, + 0x9, 0x50, 0x20, 0x90, 0x94, 0x95, 0xd6, 0x6c, 0xc9, 0x0, 0x11, 0xd3, 0xe7, 0x30, 0xcf, + 0xdf, 0x44, 0xc1, 0x56, 0x93, 0xc4, 0xd4, 0xb0, 0xf7, 0x8b, 0xac, 0x5c, 0xc1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12059}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30416}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3122}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops5}, .v = {24, (char*)&bytesprops6}}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 29750; + uint8_t client_id_bytes[] = {0x7b, 0xa0, 0x2b, 0x67, 0x47, 0xa0, 0xe3, 0x2a, 0x9f, 0xd0, 0x27, 0x68, 0xc5, + 0x4b, 0xde, 0x32, 0x9, 0x50, 0x20, 0x90, 0x94, 0x95, 0xd6, 0x6c, 0xc9}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xd3, 0xe7, 0x30, 0xcf, 0xdf, 0x44, 0xc1, 0x56, 0x93, + 0xc4, 0xd4, 0xb0, 0xf7, 0x8b, 0xac, 0x5c, 0xc1}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "?\212\154\234\129\129", _password = Just "p~)\DELVv\232\EOT,\SUB\142a\223", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\182\210\210\208\161*\ng>\174\214\175\228\181\167\162I=\146!", _willMsg = "2\138c9\234`\186@\186E\164\&9+", +// _willProps = []}), _cleanSession = False, _keepAlive = 19395, _connID = +// "\149n\238G\238\237)\201\164\252\154Z`O\144Gm\245xzg\DC3P", _properties = []} +TEST(Connect311QCTest, Encode9) { + uint8_t pkt[] = {0x10, 0x5f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x4b, 0xc3, 0x0, 0x17, 0x95, 0x6e, 0xee, + 0x47, 0xee, 0xed, 0x29, 0xc9, 0xa4, 0xfc, 0x9a, 0x5a, 0x60, 0x4f, 0x90, 0x47, 0x6d, 0xf5, 0x78, 0x7a, + 0x67, 0x13, 0x50, 0x0, 0x14, 0xb6, 0xd2, 0xd2, 0xd0, 0xa1, 0x2a, 0xa, 0x67, 0x3e, 0xae, 0xd6, 0xaf, + 0xe4, 0xb5, 0xa7, 0xa2, 0x49, 0x3d, 0x92, 0x21, 0x0, 0xd, 0x32, 0x8a, 0x63, 0x39, 0xea, 0x60, 0xba, + 0x40, 0xba, 0x45, 0xa4, 0x39, 0x2b, 0x0, 0x6, 0x3f, 0xd4, 0x9a, 0xea, 0x81, 0x81, 0x0, 0xd, 0x70, + 0x7e, 0x29, 0x7f, 0x56, 0x76, 0xe8, 0x4, 0x2c, 0x1a, 0x8e, 0x61, 0xdf}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xaa, 0x84, 0x74, 0xc3, 0x56}; - uint8_t byteswillprops1[] = {0x69, 0xc0}; - uint8_t byteswillprops2[] = {0x8d, 0xfa, 0x71, 0x57, 0xdf, 0xfd, 0x1a, 0xfc, 0x34, 0x44, 0xaa, 0x89, - 0x13, 0x6e, 0x8, 0xb7, 0xd0, 0x3d, 0x99, 0xec, 0x9f, 0xc9, 0x9f}; - uint8_t byteswillprops3[] = {0}; - uint8_t byteswillprops4[] = {0x46, 0x49, 0xc3, 0x61, 0xeb, 0xcf, 0x17, 0x56, 0x92, 0x65, 0x1b, 0x8c, 0x10, 0xcb, - 0x47, 0xf8, 0xaf, 0xdb, 0xe2, 0x33, 0xee, 0xf5, 0xb7, 0xf9, 0xa9, 0x91, 0x13}; - uint8_t byteswillprops5[] = {0x3c, 0xae, 0x44, 0xab, 0x70, 0x23, 0xd7, 0x30, 0xfc, 0x7b, 0x48, - 0x7a, 0xda, 0xc, 0x35, 0x66, 0xb9, 0xbd, 0x1, 0xf6, 0x3f}; - uint8_t byteswillprops6[] = {0x71, 0x81, 0x9, 0xe8, 0x67, 0xb, 0x78, 0x13, 0xf7, 0x56, 0x32, 0x2c, 0xf0}; - uint8_t byteswillprops7[] = {0x5b, 0xd7, 0xff, 0xa8, 0xc2, 0xcb, 0xd, 0x13, 0x39, - 0x54, 0x91, 0x65, 0xcf, 0xdf, 0xa, 0x9a, 0x98}; - uint8_t byteswillprops8[] = {0x37, 0x3e, 0xda, 0x9b, 0x37, 0x4, 0xc2, 0x3f, 0x34, 0xdb, - 0x39, 0x93, 0x5e, 0x5b, 0xd0, 0xf, 0x12, 0x17, 0x80, 0x7}; - uint8_t byteswillprops9[] = {0xe8, 0xf4, 0x72, 0xac, 0x96, 0xac, 0xca, 0xd}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9172}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19524}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17746}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 472}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15394}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17437}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&byteswillprops9}}}, - }; + lwmqtt_property_t willpropslist[] = {}; - lwmqtt_properties_t willprops = {27, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0}; - lwmqtt_string_t will_topic = {0, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x55, 0x2, 0xbc, 0xc7, 0x82, 0x3b}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb6, 0xd2, 0xd2, 0xd0, 0xa1, 0x2a, 0xa, 0x67, 0x3e, 0xae, + 0xd6, 0xaf, 0xe4, 0xb5, 0xa7, 0xa2, 0x49, 0x3d, 0x92, 0x21}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x32, 0x8a, 0x63, 0x39, 0xea, 0x60, 0xba, 0x40, 0xba, 0x45, 0xa4, 0x39, 0x2b}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -10170,424 +9171,4932 @@ TEST(Connect5QCTest, Encode28) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 3904; - uint8_t client_id_bytes[] = {0xc5, 0x23, 0xbe, 0x72, 0x34, 0xec, 0x85, 0x9, 0xf, 0x59, 0xc6, 0xe2, 0xd5, 0xf4, 0x91}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 19395; + uint8_t client_id_bytes[] = {0x95, 0x6e, 0xee, 0x47, 0xee, 0xed, 0x29, 0xc9, 0xa4, 0xfc, 0x9a, 0x5a, + 0x60, 0x4f, 0x90, 0x47, 0x6d, 0xf5, 0x78, 0x7a, 0x67, 0x13, 0x50}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x94, 0x6f, 0xc8, 0x6d, 0xba, 0x3c, 0xae, 0xbb, 0x40, 0x48, 0x2a, 0xc7, 0xc7, - 0x6b, 0xf1, 0x4e, 0xcf, 0x7a, 0xb5, 0x24, 0xeb, 0x7a, 0xfd, 0x6a, 0x86, 0x7b}; - lwmqtt_string_t username = {26, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x3f, 0xd4, 0x9a, 0xea, 0x81, 0x81}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x70, 0x7e, 0x29, 0x7f, 0x56, 0x76, 0xe8, 0x4, 0x2c, 0x1a, 0x8e, 0x61, 0xdf}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = -// QoS0, _willTopic = "\166@\DEL\142", _willMsg = "\DC3x\226\245Jp\148\STX%\DC1\141\240\169\253\ETXfd\193t^", _willProps -// = [PropSessionExpiryInterval 7530,PropReceiveMaximum 31785,PropMaximumQoS 65,PropRetainAvailable 194,PropTopicAlias -// 21418,PropUserProperty "\224d\226;k\168\171\DC1" -// "i\240\218\201\&0z\254\253\SOHJ\242\163y\179&\vU\153Y\STX&\154\162p\197)b\190\172\164",PropUserProperty -// "6\238\176~7q\238\246\244" "",PropRequestResponseInformation 178,PropTopicAlias -// 12178,PropSubscriptionIdentifierAvailable 60,PropServerKeepAlive 3346,PropRequestProblemInformation -// 21,PropRequestResponseInformation 121,PropReceiveMaximum 12214,PropContentType "P\CAN;\v\185\238I"]}), _cleanSession -// = True, _keepAlive = 24545, _connID = "\183#J\202\157\184-\233Zr\211\247l\185=\182\150\193", _properties = -// [PropMessageExpiryInterval 31631,PropAssignedClientIdentifier -// "\249\225\a\NAK\SI\208\131\134\214\160\183\245\239*'\211eW\230\&2f\196",PropMaximumQoS -// 18,PropAssignedClientIdentifier -// "\252C\255\232\155\"\206\242\174\250\194i\184\184\142-$.",PropSubscriptionIdentifierAvailable -// 222,PropAuthenticationData "n.\154/\a\222m}\161\165\ESC\183[\154\193",PropResponseInformation -// "\199$\GS\CAN\ENQ)J\173\175\&0\vx'\154",PropResponseInformation -// "\184\228G\241\161\230\r+\CAN\132\156",PropRetainAvailable 229,PropWillDelayInterval 21182,PropUserProperty -// "\190\242\161M\185\225\143-\232" "Qdd\252\245\141\203",PropSessionExpiryInterval 9172,PropPayloadFormatIndicator -// 8,PropAuthenticationMethod "(C\164\132S\160AU3\208>p\179\208\SYN,\216M\235\161\DEL",PropSubscriptionIdentifier -// 17,PropReasonString -// "\ETB\179\226_(\215m\183\134\210\160\214\245)n\194j]I\205T\170o&h\192\157,",PropSubscriptionIdentifierAvailable -// 205,PropServerKeepAlive 439,PropResponseTopic -// "\155\204\228y\SUB\224\f\200(\165\189\241\\b9\141\205\239'\ETBV\SUB\DC1\229-\EOT'",PropTopicAlias -// 6588,PropServerKeepAlive 28469,PropReasonString "\220\131\238\SOHh\247\186\184\192%n\ACK",PropWillDelayInterval -// 6420,PropResponseTopic ";",PropReasonString -// "\213]\DC1\215\239B\DC3\139\161\NAK\147\135\ETX\DELL\148\&6#?\144\225\145j\231",PropAuthenticationData -// "I\v\fz$\216\249@\204 -\231\EM",PropMessageExpiryInterval 30414,PropSubscriptionIdentifierAvailable -// 228,PropSharedSubscriptionAvailable 117,PropPayloadFormatIndicator 40]} -TEST(Connect5QCTest, Encode29) { - uint8_t pkt[] = { - 0x10, 0xdb, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x5f, 0xe1, 0xbb, 0x2, 0x2, 0x0, 0x0, 0x7b, - 0x8f, 0x12, 0x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79, 0xb3, 0x26, 0xb, 0x55, 0x99, 0x59, 0x2, - 0x26, 0x9a, 0xa2, 0x70, 0xc5, 0x29, 0x62, 0xbe, 0xac, 0xa4, 0x26, 0x0, 0x9, 0x36, 0xee, 0xb0, 0x7e, 0x37, 0x71, - 0xee, 0xf6, 0xf4, 0x0, 0x0, 0x19, 0xb2, 0x23, 0x2f, 0x92, 0x29, 0x3c, 0x13, 0xd, 0x12, 0x17, 0x15, 0x19, 0x79, - 0x21, 0x2f, 0xb6, 0x3, 0x0, 0x7, 0x50, 0x18, 0x3b, 0xb, 0xb9, 0xee, 0x49, 0x0, 0x4, 0xa6, 0x40, 0x7f, 0x8e, - 0x0, 0x14, 0x13, 0x78, 0xe2, 0xf5, 0x4a, 0x70, 0x94, 0x2, 0x25, 0x11, 0x8d, 0xf0, 0xa9, 0xfd, 0x3, 0x66, 0x64, - 0xc1, 0x74, 0x5e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf9, 0xe1, 0x7, 0x15, 0xf, 0xd0, 0x83, 0x86, 0xd6, 0xa0, 0xb7, - 0xf5, 0xef, 0x2a, 0x27, 0xd3, 0x65, 0x57, 0xe6, 0x32, 0x66, 0xc4}; - uint8_t bytesprops1[] = {0xfc, 0x43, 0xff, 0xe8, 0x9b, 0x22, 0xce, 0xf2, 0xae, - 0xfa, 0xc2, 0x69, 0xb8, 0xb8, 0x8e, 0x2d, 0x24, 0x2e}; - uint8_t bytesprops2[] = {0x6e, 0x2e, 0x9a, 0x2f, 0x7, 0xde, 0x6d, 0x7d, 0xa1, 0xa5, 0x1b, 0xb7, 0x5b, 0x9a, 0xc1}; - uint8_t bytesprops3[] = {0xc7, 0x24, 0x1d, 0x18, 0x5, 0x29, 0x4a, 0xad, 0xaf, 0x30, 0xb, 0x78, 0x27, 0x9a}; - uint8_t bytesprops4[] = {0xb8, 0xe4, 0x47, 0xf1, 0xa1, 0xe6, 0xd, 0x2b, 0x18, 0x84, 0x9c}; - uint8_t bytesprops6[] = {0x51, 0x64, 0x64, 0xfc, 0xf5, 0x8d, 0xcb}; - uint8_t bytesprops5[] = {0xbe, 0xf2, 0xa1, 0x4d, 0xb9, 0xe1, 0x8f, 0x2d, 0xe8}; - uint8_t bytesprops7[] = {0x28, 0x43, 0xa4, 0x84, 0x53, 0xa0, 0x41, 0x55, 0x33, 0xd0, 0x3e, - 0x70, 0xb3, 0xd0, 0x16, 0x2c, 0xd8, 0x4d, 0xeb, 0xa1, 0x7f}; - uint8_t bytesprops8[] = {0x17, 0xb3, 0xe2, 0x5f, 0x28, 0xd7, 0x6d, 0xb7, 0x86, 0xd2, 0xa0, 0xd6, 0xf5, 0x29, - 0x6e, 0xc2, 0x6a, 0x5d, 0x49, 0xcd, 0x54, 0xaa, 0x6f, 0x26, 0x68, 0xc0, 0x9d, 0x2c}; - uint8_t bytesprops9[] = {0x9b, 0xcc, 0xe4, 0x79, 0x1a, 0xe0, 0xc, 0xc8, 0x28, 0xa5, 0xbd, 0xf1, 0x5c, 0x62, - 0x39, 0x8d, 0xcd, 0xef, 0x27, 0x17, 0x56, 0x1a, 0x11, 0xe5, 0x2d, 0x4, 0x27}; - uint8_t bytesprops10[] = {0xdc, 0x83, 0xee, 0x1, 0x68, 0xf7, 0xba, 0xb8, 0xc0, 0x25, 0x6e, 0x6}; - uint8_t bytesprops11[] = {0x3b}; - uint8_t bytesprops12[] = {0xd5, 0x5d, 0x11, 0xd7, 0xef, 0x42, 0x13, 0x8b, 0xa1, 0x15, 0x93, 0x87, - 0x3, 0x7f, 0x4c, 0x94, 0x36, 0x23, 0x3f, 0x90, 0xe1, 0x91, 0x6a, 0xe7}; - uint8_t bytesprops13[] = {0x49, 0xb, 0xc, 0x7a, 0x24, 0xd8, 0xf9, 0x40, 0xcc, 0x20, 0x2d, 0xe7, 0x19}; +// ConnectRequest {_username = Just "\150\213\175\169yq`\DC3\185\158\240\US\228H\158\158\192\153", _password = Just +// "\206c\DC1\187", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "'gY\b\203\149\DC3\206\CAN<\CAN\177\205$a\160\135", _willMsg = +// "\162<\STX\222\185\208\196\140\169\175\155\150\NAK\216\r\145\194\173\159\210/\222\f\180\NAK=", _willProps = []}), +// _cleanSession = True, _keepAlive = 5366, _connID = "\230\209$f\202\238\227", _properties = []} +TEST(Connect311QCTest, Encode10) { + uint8_t pkt[] = {0x10, 0x5c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x14, 0xf6, 0x0, 0x7, 0xe6, 0xd1, + 0x24, 0x66, 0xca, 0xee, 0xe3, 0x0, 0x11, 0x27, 0x67, 0x59, 0x8, 0xcb, 0x95, 0x13, 0xce, 0x18, + 0x3c, 0x18, 0xb1, 0xcd, 0x24, 0x61, 0xa0, 0x87, 0x0, 0x1a, 0xa2, 0x3c, 0x2, 0xde, 0xb9, 0xd0, + 0xc4, 0x8c, 0xa9, 0xaf, 0x9b, 0x96, 0x15, 0xd8, 0xd, 0x91, 0xc2, 0xad, 0x9f, 0xd2, 0x2f, 0xde, + 0xc, 0xb4, 0x15, 0x3d, 0x0, 0x12, 0x96, 0xd5, 0xaf, 0xa9, 0x79, 0x71, 0x60, 0x13, 0xb9, 0x9e, + 0xf0, 0x1f, 0xe4, 0x48, 0x9e, 0x9e, 0xc0, 0x99, 0x0, 0x4, 0xce, 0x63, 0x11, 0xbb}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31631}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 229}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21182}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops5}, .v = {7, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9172}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 439}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6588}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28469}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6420}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30414}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 40}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x69, 0xf0, 0xda, 0xc9, 0x30, 0x7a, 0xfe, 0xfd, 0x1, 0x4a, - 0xf2, 0xa3, 0x79, 0xb3, 0x26, 0xb, 0x55, 0x99, 0x59, 0x2, - 0x26, 0x9a, 0xa2, 0x70, 0xc5, 0x29, 0x62, 0xbe, 0xac, 0xa4}; - uint8_t byteswillprops0[] = {0xe0, 0x64, 0xe2, 0x3b, 0x6b, 0xa8, 0xab, 0x11}; - uint8_t byteswillprops3[] = {0}; - uint8_t byteswillprops2[] = {0x36, 0xee, 0xb0, 0x7e, 0x37, 0x71, 0xee, 0xf6, 0xf4}; - uint8_t byteswillprops4[] = {0x50, 0x18, 0x3b, 0xb, 0xb9, 0xee, 0x49}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7530}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31785}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21418}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {8, (char*)&byteswillprops0}, .v = {30, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {9, (char*)&byteswillprops2}, .v = {0, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12178}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 60}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3346}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12214}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&byteswillprops4}}}, - }; + lwmqtt_property_t willpropslist[] = {}; - lwmqtt_properties_t willprops = {15, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa6, 0x40, 0x7f, 0x8e}; - lwmqtt_string_t will_topic = {4, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x13, 0x78, 0xe2, 0xf5, 0x4a, 0x70, 0x94, 0x2, 0x25, 0x11, - 0x8d, 0xf0, 0xa9, 0xfd, 0x3, 0x66, 0x64, 0xc1, 0x74, 0x5e}; - lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x27, 0x67, 0x59, 0x8, 0xcb, 0x95, 0x13, 0xce, 0x18, + 0x3c, 0x18, 0xb1, 0xcd, 0x24, 0x61, 0xa0, 0x87}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa2, 0x3c, 0x2, 0xde, 0xb9, 0xd0, 0xc4, 0x8c, 0xa9, 0xaf, 0x9b, 0x96, 0x15, + 0xd8, 0xd, 0x91, 0xc2, 0xad, 0x9f, 0xd2, 0x2f, 0xde, 0xc, 0xb4, 0x15, 0x3d}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 24545; - uint8_t client_id_bytes[] = {0xb7, 0x23, 0x4a, 0xca, 0x9d, 0xb8, 0x2d, 0xe9, 0x5a, - 0x72, 0xd3, 0xf7, 0x6c, 0xb9, 0x3d, 0xb6, 0x96, 0xc1}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.keep_alive = 5366; + uint8_t client_id_bytes[] = {0xe6, 0xd1, 0x24, 0x66, 0xca, 0xee, 0xe3}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t username_bytes[] = {0x96, 0xd5, 0xaf, 0xa9, 0x79, 0x71, 0x60, 0x13, 0xb9, + 0x9e, 0xf0, 0x1f, 0xe4, 0x48, 0x9e, 0x9e, 0xc0, 0x99}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xce, 0x63, 0x11, 0xbb}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\\\143\216", _password = Just "\151\&6\134W]\238P\207\167\&0Z", _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "9", _willMsg = -// "]v\243\130\NULm\134'\201\ESCs\176\166\a;\239\EM", _willProps = [PropSharedSubscriptionAvailable 43,PropMaximumQoS -// 74,PropMessageExpiryInterval 14419,PropAssignedClientIdentifier -// "\134\183\136\208\159\DC1M\141\142\DC3\FS\237\155$",PropRetainAvailable 128,PropResponseTopic -// "\206\129\SIY>CI\193\192n\236\&4\226\185#\168@u\CAN\ETB\212\212\225\251\207",PropSessionExpiryInterval -// 24313,PropMaximumQoS 77,PropAssignedClientIdentifier "\206\237\&9\246\213\tt\GS\186H\198k\ETB[",PropMaximumQoS -// 145,PropMessageExpiryInterval 9405,PropSubscriptionIdentifierAvailable 222,PropMaximumPacketSize 705,PropTopicAlias -// 16865]}), _cleanSession = True, _keepAlive = 17718, _connID = "\225qY\140\214\227+/\167\SI7\177", _properties = -// [PropContentType "\229\150\211\156\128\237\250J=\219\181",PropSessionExpiryInterval 21507,PropCorrelationData -// "\215\234ZT\219\251a\DC2lHJ\250\133\243z\132\145T?%\241Y[",PropReceiveMaximum 25812,PropTopicAlias -// 9975,PropPayloadFormatIndicator 188]} -TEST(Connect5QCTest, Encode30) { - uint8_t pkt[] = {0x10, 0xd8, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x45, 0x36, 0x35, 0x3, 0x0, 0xb, - 0xe5, 0x96, 0xd3, 0x9c, 0x80, 0xed, 0xfa, 0x4a, 0x3d, 0xdb, 0xb5, 0x11, 0x0, 0x0, 0x54, 0x3, 0x9, - 0x0, 0x17, 0xd7, 0xea, 0x5a, 0x54, 0xdb, 0xfb, 0x61, 0x12, 0x6c, 0x48, 0x4a, 0xfa, 0x85, 0xf3, 0x7a, - 0x84, 0x91, 0x54, 0x3f, 0x25, 0xf1, 0x59, 0x5b, 0x21, 0x64, 0xd4, 0x23, 0x26, 0xf7, 0x1, 0xbc, 0x0, - 0xc, 0xe1, 0x71, 0x59, 0x8c, 0xd6, 0xe3, 0x2b, 0x2f, 0xa7, 0xf, 0x37, 0xb1, 0x61, 0x2a, 0x2b, 0x24, - 0x4a, 0x2, 0x0, 0x0, 0x38, 0x53, 0x12, 0x0, 0xe, 0x86, 0xb7, 0x88, 0xd0, 0x9f, 0x11, 0x4d, 0x8d, - 0x8e, 0x13, 0x1c, 0xed, 0x9b, 0x24, 0x25, 0x80, 0x8, 0x0, 0x19, 0xce, 0x81, 0xf, 0x59, 0x3e, 0x43, - 0x49, 0xc1, 0xc0, 0x6e, 0xec, 0x34, 0xe2, 0xb9, 0x23, 0xa8, 0x40, 0x75, 0x18, 0x17, 0xd4, 0xd4, 0xe1, - 0xfb, 0xcf, 0x11, 0x0, 0x0, 0x5e, 0xf9, 0x24, 0x4d, 0x12, 0x0, 0xe, 0xce, 0xed, 0x39, 0xf6, 0xd5, - 0x9, 0x74, 0x1d, 0xba, 0x48, 0xc6, 0x6b, 0x17, 0x5b, 0x24, 0x91, 0x2, 0x0, 0x0, 0x24, 0xbd, 0x29, - 0xde, 0x27, 0x0, 0x0, 0x2, 0xc1, 0x23, 0x41, 0xe1, 0x0, 0x1, 0x39, 0x0, 0x11, 0x5d, 0x76, 0xf3, - 0x82, 0x0, 0x6d, 0x86, 0x27, 0xc9, 0x1b, 0x73, 0xb0, 0xa6, 0x7, 0x3b, 0xef, 0x19, 0x0, 0x3, 0x5c, - 0x8f, 0xd8, 0x0, 0xb, 0x97, 0x36, 0x86, 0x57, 0x5d, 0xee, 0x50, 0xcf, 0xa7, 0x30, 0x5a}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe5, 0x96, 0xd3, 0x9c, 0x80, 0xed, 0xfa, 0x4a, 0x3d, 0xdb, 0xb5}; - uint8_t bytesprops1[] = {0xd7, 0xea, 0x5a, 0x54, 0xdb, 0xfb, 0x61, 0x12, 0x6c, 0x48, 0x4a, 0xfa, - 0x85, 0xf3, 0x7a, 0x84, 0x91, 0x54, 0x3f, 0x25, 0xf1, 0x59, 0x5b}; +// ConnectRequest {_username = Just "\129\128\161\159\147\245-e\bJ_\149 \184p.t,\236Q\211\160XD\SUB\239\DEL\DC2\144", +// _password = Just "\240\244", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\135\ETXg\SIO\185\150d\172+QZ", _willMsg = "\232\GS\202P\180x\186\243}<\155\148:\217\145'", _willProps = []}), +// _cleanSession = True, _keepAlive = 30463, _connID = "\171v+\163\172\203\229S\191\242VUR\b\DLE\179J\234", _properties +// = []} +TEST(Connect311QCTest, Encode11) { + uint8_t pkt[] = {0x10, 0x61, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x76, 0xff, 0x0, 0x12, 0xab, 0x76, 0x2b, + 0xa3, 0xac, 0xcb, 0xe5, 0x53, 0xbf, 0xf2, 0x56, 0x55, 0x52, 0x8, 0x10, 0xb3, 0x4a, 0xea, 0x0, 0xc, + 0x87, 0x3, 0x67, 0xf, 0x4f, 0xb9, 0x96, 0x64, 0xac, 0x2b, 0x51, 0x5a, 0x0, 0x10, 0xe8, 0x1d, 0xca, + 0x50, 0xb4, 0x78, 0xba, 0xf3, 0x7d, 0x3c, 0x9b, 0x94, 0x3a, 0xd9, 0x91, 0x27, 0x0, 0x1d, 0x81, 0x80, + 0xa1, 0x9f, 0x93, 0xf5, 0x2d, 0x65, 0x8, 0x4a, 0x5f, 0x95, 0x20, 0xb8, 0x70, 0x2e, 0x74, 0x2c, 0xec, + 0x51, 0xd3, 0xa0, 0x58, 0x44, 0x1a, 0xef, 0x7f, 0x12, 0x90, 0x0, 0x2, 0xf0, 0xf4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21507}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25812}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9975}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 188}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x86, 0xb7, 0x88, 0xd0, 0x9f, 0x11, 0x4d, 0x8d, 0x8e, 0x13, 0x1c, 0xed, 0x9b, 0x24}; - uint8_t byteswillprops1[] = {0xce, 0x81, 0xf, 0x59, 0x3e, 0x43, 0x49, 0xc1, 0xc0, 0x6e, 0xec, 0x34, 0xe2, - 0xb9, 0x23, 0xa8, 0x40, 0x75, 0x18, 0x17, 0xd4, 0xd4, 0xe1, 0xfb, 0xcf}; - uint8_t byteswillprops2[] = {0xce, 0xed, 0x39, 0xf6, 0xd5, 0x9, 0x74, 0x1d, 0xba, 0x48, 0xc6, 0x6b, 0x17, 0x5b}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14419}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24313}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9405}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 705}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16865}}, - }; + lwmqtt_property_t willpropslist[] = {}; - lwmqtt_properties_t willprops = {14, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x39}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5d, 0x76, 0xf3, 0x82, 0x0, 0x6d, 0x86, 0x27, 0xc9, - 0x1b, 0x73, 0xb0, 0xa6, 0x7, 0x3b, 0xef, 0x19}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x87, 0x3, 0x67, 0xf, 0x4f, 0xb9, 0x96, 0x64, 0xac, 0x2b, 0x51, 0x5a}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe8, 0x1d, 0xca, 0x50, 0xb4, 0x78, 0xba, 0xf3, + 0x7d, 0x3c, 0x9b, 0x94, 0x3a, 0xd9, 0x91, 0x27}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 17718; - uint8_t client_id_bytes[] = {0xe1, 0x71, 0x59, 0x8c, 0xd6, 0xe3, 0x2b, 0x2f, 0xa7, 0xf, 0x37, 0xb1}; - lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.keep_alive = 30463; + uint8_t client_id_bytes[] = {0xab, 0x76, 0x2b, 0xa3, 0xac, 0xcb, 0xe5, 0x53, 0xbf, + 0xf2, 0x56, 0x55, 0x52, 0x8, 0x10, 0xb3, 0x4a, 0xea}; + lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x5c, 0x8f, 0xd8}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x81, 0x80, 0xa1, 0x9f, 0x93, 0xf5, 0x2d, 0x65, 0x8, 0x4a, 0x5f, 0x95, 0x20, 0xb8, 0x70, + 0x2e, 0x74, 0x2c, 0xec, 0x51, 0xd3, 0xa0, 0x58, 0x44, 0x1a, 0xef, 0x7f, 0x12, 0x90}; + lwmqtt_string_t username = {29, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x97, 0x36, 0x86, 0x57, 0x5d, 0xee, 0x50, 0xcf, 0xa7, 0x30, 0x5a}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xf0, 0xf4}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18112 [("\217\163\ETBT\231\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\199}\169\229\237\168.,U\215W4W\211\197\172\&1&\235\203\213",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\225\200[H\253e\NUL\230l[hR\220\215\242\223\175\133\169\231}",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("X",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("D\ACK\181\185\&4\239\235M\227\131\252\255M\176\r\219\180\ETB\217\167\232\190\223\236",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("B)`\234\&1'\221\218\171\ETBd\196\&4\229\170Y\SYN\164y\164b\174E\240",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\165\213\SYN\240\249\ETX\f\225\171\188j\164(\170\190\189\248\223\202",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\182\208\135BB\223",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("7",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x9b, 0x1, 0x46, 0xc0, 0x0, 0x6, 0xd9, 0xa3, 0x17, 0x54, 0xe7, 0xd9, 0x0, 0x0, 0x15, - 0xc7, 0x7d, 0xa9, 0xe5, 0xed, 0xa8, 0x2e, 0x2c, 0x55, 0xd7, 0x57, 0x34, 0x57, 0xd3, 0xc5, 0xac, - 0x31, 0x26, 0xeb, 0xcb, 0xd5, 0x0, 0x0, 0x15, 0xe1, 0xc8, 0x5b, 0x48, 0xfd, 0x65, 0x0, 0xe6, - 0x6c, 0x5b, 0x68, 0x52, 0xdc, 0xd7, 0xf2, 0xdf, 0xaf, 0x85, 0xa9, 0xe7, 0x7d, 0x0, 0x0, 0x1, - 0x58, 0x1, 0x0, 0x18, 0x44, 0x6, 0xb5, 0xb9, 0x34, 0xef, 0xeb, 0x4d, 0xe3, 0x83, 0xfc, 0xff, - 0x4d, 0xb0, 0xd, 0xdb, 0xb4, 0x17, 0xd9, 0xa7, 0xe8, 0xbe, 0xdf, 0xec, 0x1, 0x0, 0x18, 0x42, - 0x29, 0x60, 0xea, 0x31, 0x27, 0xdd, 0xda, 0xab, 0x17, 0x64, 0xc4, 0x34, 0xe5, 0xaa, 0x59, 0x16, - 0xa4, 0x79, 0xa4, 0x62, 0xae, 0x45, 0xf0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x13, 0xa5, 0xd5, 0x16, - 0xf0, 0xf9, 0x3, 0xc, 0xe1, 0xab, 0xbc, 0x6a, 0xa4, 0x28, 0xaa, 0xbe, 0xbd, 0xf8, 0xdf, 0xca, - 0x0, 0x0, 0x6, 0xb6, 0xd0, 0x87, 0x42, 0x42, 0xdf, 0x2, 0x0, 0x1, 0x37, 0x0}; +// ConnectRequest {_username = Just ".2\214\236%\167C\190\248\193\211@$\248", _password = Nothing, _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\211\192\177\134\&8\245\197\148\144\238\147T?", +// _willMsg = "Ws\ETB\210;\DC3\230~\159t\212k(\175\174\"\239\CAN\193\229\255", _willProps = []}), _cleanSession = False, +// _keepAlive = 24806, _connID = "\226W\228\136%h\248C\190\131\204\147f\NAKn\148 \184\208#\240\FSf\FS3T\231", +// _properties = []} +TEST(Connect311QCTest, Encode12) { + uint8_t pkt[] = {0x10, 0x5d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0x60, 0xe6, 0x0, 0x1b, 0xe2, 0x57, + 0xe4, 0x88, 0x25, 0x68, 0xf8, 0x43, 0xbe, 0x83, 0xcc, 0x93, 0x66, 0x15, 0x6e, 0x94, 0x20, 0xb8, + 0xd0, 0x23, 0xf0, 0x1c, 0x66, 0x1c, 0x33, 0x54, 0xe7, 0x0, 0xd, 0xd3, 0xc0, 0xb1, 0x86, 0x38, + 0xf5, 0xc5, 0x94, 0x90, 0xee, 0x93, 0x54, 0x3f, 0x0, 0x15, 0x57, 0x73, 0x17, 0xd2, 0x3b, 0x13, + 0xe6, 0x7e, 0x9f, 0x74, 0xd4, 0x6b, 0x28, 0xaf, 0xae, 0x22, 0xef, 0x18, 0xc1, 0xe5, 0xff, 0x0, + 0xe, 0x2e, 0x32, 0xd6, 0xec, 0x25, 0xa7, 0x43, 0xbe, 0xf8, 0xc1, 0xd3, 0x40, 0x24, 0xf8}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd9, 0xa3, 0x17, 0x54, 0xe7, 0xd9}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc7, 0x7d, 0xa9, 0xe5, 0xed, 0xa8, 0x2e, 0x2c, 0x55, 0xd7, 0x57, - 0x34, 0x57, 0xd3, 0xc5, 0xac, 0x31, 0x26, 0xeb, 0xcb, 0xd5}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xd3, 0xc0, 0xb1, 0x86, 0x38, 0xf5, 0xc5, 0x94, 0x90, 0xee, 0x93, 0x54, 0x3f}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x57, 0x73, 0x17, 0xd2, 0x3b, 0x13, 0xe6, 0x7e, 0x9f, 0x74, 0xd4, + 0x6b, 0x28, 0xaf, 0xae, 0x22, 0xef, 0x18, 0xc1, 0xe5, 0xff}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 24806; + uint8_t client_id_bytes[] = {0xe2, 0x57, 0xe4, 0x88, 0x25, 0x68, 0xf8, 0x43, 0xbe, 0x83, 0xcc, 0x93, 0x66, 0x15, + 0x6e, 0x94, 0x20, 0xb8, 0xd0, 0x23, 0xf0, 0x1c, 0x66, 0x1c, 0x33, 0x54, 0xe7}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x2e, 0x32, 0xd6, 0xec, 0x25, 0xa7, 0x43, 0xbe, 0xf8, 0xc1, 0xd3, 0x40, 0x24, 0xf8}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\RST\210\144\vR\152\r\144sH\140S\216X\252D\232\156", _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\DC3\214I\EM\233B\b", _willMsg = +// "iT\rof/\249~4Z(<[iN\168@!g", _willProps = []}), _cleanSession = False, _keepAlive = 10052, _connID = +// "\ENQB\207E\189\199FE\196\245\ACK\135\200N\n\187\177\209\128\171", _properties = []} +TEST(Connect311QCTest, Encode13) { + uint8_t pkt[] = {0x10, 0x3e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x4, 0x27, 0x44, 0x0, 0x14, 0x5, 0x42, + 0xcf, 0x45, 0xbd, 0xc7, 0x46, 0x45, 0xc4, 0xf5, 0x6, 0x87, 0xc8, 0x4e, 0xa, 0xbb, 0xb1, 0xd1, + 0x80, 0xab, 0x0, 0x7, 0x13, 0xd6, 0x49, 0x19, 0xe9, 0x42, 0x8, 0x0, 0x13, 0x69, 0x54, 0xd, + 0x6f, 0x66, 0x2f, 0xf9, 0x7e, 0x34, 0x5a, 0x28, 0x3c, 0x5b, 0x69, 0x4e, 0xa8, 0x40, 0x21, 0x67}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x13, 0xd6, 0x49, 0x19, 0xe9, 0x42, 0x8}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x69, 0x54, 0xd, 0x6f, 0x66, 0x2f, 0xf9, 0x7e, 0x34, 0x5a, + 0x28, 0x3c, 0x5b, 0x69, 0x4e, 0xa8, 0x40, 0x21, 0x67}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 10052; + uint8_t client_id_bytes[] = {0x5, 0x42, 0xcf, 0x45, 0xbd, 0xc7, 0x46, 0x45, 0xc4, 0xf5, + 0x6, 0x87, 0xc8, 0x4e, 0xa, 0xbb, 0xb1, 0xd1, 0x80, 0xab}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x1e, 0x54, 0xd2, 0x90, 0xb, 0x52, 0x98, 0xd, 0x90, 0x73, + 0x48, 0x8c, 0x53, 0xd8, 0x58, 0xfc, 0x44, 0xe8, 0x9c}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "jp\210\SYN<%F\215\168\207J\225\152z\151X\253\132\"", _password = Nothing, _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\181J\251\141\ETX", _willMsg = "|\ETB", +// _willProps = []}), _cleanSession = True, _keepAlive = 2920, _connID = +// "\203M+\171|\132nj\193\FS\a\\\DC1\230\202\DC2Id;\200", _properties = []} +TEST(Connect311QCTest, Encode14) { + uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0xb, 0x68, 0x0, 0x14, 0xcb, 0x4d, 0x2b, + 0xab, 0x7c, 0x84, 0x6e, 0x6a, 0xc1, 0x1c, 0x7, 0x5c, 0x11, 0xe6, 0xca, 0x12, 0x49, 0x64, 0x3b, 0xc8, + 0x0, 0x5, 0xb5, 0x4a, 0xfb, 0x8d, 0x3, 0x0, 0x2, 0x7c, 0x17, 0x0, 0x13, 0x6a, 0x70, 0xd2, 0x16, + 0x3c, 0x25, 0x46, 0xd7, 0xa8, 0xcf, 0x4a, 0xe1, 0x98, 0x7a, 0x97, 0x58, 0xfd, 0x84, 0x22}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb5, 0x4a, 0xfb, 0x8d, 0x3}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7c, 0x17}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 2920; + uint8_t client_id_bytes[] = {0xcb, 0x4d, 0x2b, 0xab, 0x7c, 0x84, 0x6e, 0x6a, 0xc1, 0x1c, + 0x7, 0x5c, 0x11, 0xe6, 0xca, 0x12, 0x49, 0x64, 0x3b, 0xc8}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x6a, 0x70, 0xd2, 0x16, 0x3c, 0x25, 0x46, 0xd7, 0xa8, 0xcf, + 0x4a, 0xe1, 0x98, 0x7a, 0x97, 0x58, 0xfd, 0x84, 0x22}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\192\STX\129_\195-\215\163\200JG\249<", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "\152e\130\v\SOH\ACK\224\EOT\165\199(&g\SO\ACK\211\169\&1\DC3\243\199\ETB\221\138+", _willMsg = +// "H\197\&7\SOH\253\237", _willProps = []}), _cleanSession = True, _keepAlive = 2714, _connID = +// "\243Q\STX\222\243oB\DC4\136\201n\GS\146", _properties = []} +TEST(Connect311QCTest, Encode15) { + uint8_t pkt[] = {0x10, 0x3c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0xa, 0x9a, 0x0, 0xd, 0xf3, 0x51, + 0x2, 0xde, 0xf3, 0x6f, 0x42, 0x14, 0x88, 0xc9, 0x6e, 0x1d, 0x92, 0x0, 0x19, 0x98, 0x65, 0x82, + 0xb, 0x1, 0x6, 0xe0, 0x4, 0xa5, 0xc7, 0x28, 0x26, 0x67, 0xe, 0x6, 0xd3, 0xa9, 0x31, 0x13, + 0xf3, 0xc7, 0x17, 0xdd, 0x8a, 0x2b, 0x0, 0x6, 0x48, 0xc5, 0x37, 0x1, 0xfd, 0xed}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x98, 0x65, 0x82, 0xb, 0x1, 0x6, 0xe0, 0x4, 0xa5, 0xc7, 0x28, 0x26, 0x67, + 0xe, 0x6, 0xd3, 0xa9, 0x31, 0x13, 0xf3, 0xc7, 0x17, 0xdd, 0x8a, 0x2b}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x48, 0xc5, 0x37, 0x1, 0xfd, 0xed}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 2714; + uint8_t client_id_bytes[] = {0xf3, 0x51, 0x2, 0xde, 0xf3, 0x6f, 0x42, 0x14, 0x88, 0xc9, 0x6e, 0x1d, 0x92}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xc0, 0x2, 0x81, 0x5f, 0xc3, 0x2d, 0xd7, 0xa3, 0xc8, 0x4a, 0x47, 0xf9, 0x3c}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = +// 26866, _connID = "^\239\188\197\142\229[\ESC\211E\188\233\195", _properties = []} +TEST(Connect311QCTest, Encode16) { + uint8_t pkt[] = {0x10, 0x19, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x68, 0xf2, 0x0, 0xd, + 0x5e, 0xef, 0xbc, 0xc5, 0x8e, 0xe5, 0x5b, 0x1b, 0xd3, 0x45, 0xbc, 0xe9, 0xc3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 26866; + uint8_t client_id_bytes[] = {0x5e, 0xef, 0xbc, 0xc5, 0x8e, 0xe5, 0x5b, 0x1b, 0xd3, 0x45, 0xbc, 0xe9, 0xc3}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\159\254c\245[\164\r\135bMz\150\205`e\233\140\135YrN\180\GS\186\140\209As", +// _password = Just "<\FS\172b\196\SI\220\203\NUL`\239\135", _willMsg = +// "\232\233\vx\202\163\SOH\188\142\245iS\"H\226\158\228\235\182tA\252\ACK\191\183j8", _willProps = []}), _cleanSession +// = False, _keepAlive = 2005, _connID = "\SODv\236\176\168\ETB \EOT", _properties = []} +TEST(Connect311QCTest, Encode18) { + uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0x7, 0xd5, 0x0, 0x9, 0xe, 0x44, + 0x76, 0xec, 0xb0, 0xa8, 0x17, 0x20, 0x4, 0x0, 0x1a, 0x23, 0x93, 0x46, 0x1c, 0x9b, 0x14, 0x23, + 0xbe, 0xb5, 0xc5, 0xa4, 0x1b, 0xa6, 0xbf, 0x5a, 0x5, 0xf7, 0x8f, 0xd8, 0xfb, 0x8c, 0xe8, 0xa1, + 0x3e, 0xef, 0x87, 0x0, 0x1b, 0xe8, 0xe9, 0xb, 0x78, 0xca, 0xa3, 0x1, 0xbc, 0x8e, 0xf5, 0x69, + 0x53, 0x22, 0x48, 0xe2, 0x9e, 0xe4, 0xeb, 0xb6, 0x74, 0x41, 0xfc, 0x6, 0xbf, 0xb7, 0x6a, 0x38}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x23, 0x93, 0x46, 0x1c, 0x9b, 0x14, 0x23, 0xbe, 0xb5, 0xc5, 0xa4, 0x1b, 0xa6, + 0xbf, 0x5a, 0x5, 0xf7, 0x8f, 0xd8, 0xfb, 0x8c, 0xe8, 0xa1, 0x3e, 0xef, 0x87}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe8, 0xe9, 0xb, 0x78, 0xca, 0xa3, 0x1, 0xbc, 0x8e, 0xf5, 0x69, 0x53, 0x22, 0x48, + 0xe2, 0x9e, 0xe4, 0xeb, 0xb6, 0x74, 0x41, 0xfc, 0x6, 0xbf, 0xb7, 0x6a, 0x38}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 2005; + uint8_t client_id_bytes[] = {0xe, 0x44, 0x76, 0xec, 0xb0, 0xa8, 0x17, 0x20, 0x4}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x36, 0x8b, 0xe1, 0xa0, 0xde, 0x59, 0x76, 0x17, + 0xb8, 0x1a, 0x1e, 0xe, 0xea, 0x7d, 0x47, 0xe7}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "5\189\229", _password = Just "\SO\229\SUB\207\196\181|6\242\192@", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "v<3?)\161", _willMsg = +// "\202\&9\147\164]\233\219\201F\146ox)xa", _willProps = []}), _cleanSession = False, _keepAlive = 31959, _connID = +// "K\181", _properties = []} +TEST(Connect311QCTest, Encode19) { + uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x7c, 0xd7, 0x0, 0x2, 0x4b, + 0xb5, 0x0, 0x6, 0x76, 0x3c, 0x33, 0x3f, 0x29, 0xa1, 0x0, 0xf, 0xca, 0x39, 0x93, 0xa4, + 0x5d, 0xe9, 0xdb, 0xc9, 0x46, 0x92, 0x6f, 0x78, 0x29, 0x78, 0x61, 0x0, 0x3, 0x35, 0xbd, + 0xe5, 0x0, 0xb, 0xe, 0xe5, 0x1a, 0xcf, 0xc4, 0xb5, 0x7c, 0x36, 0xf2, 0xc0, 0x40}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x76, 0x3c, 0x33, 0x3f, 0x29, 0xa1}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xca, 0x39, 0x93, 0xa4, 0x5d, 0xe9, 0xdb, 0xc9, + 0x46, 0x92, 0x6f, 0x78, 0x29, 0x78, 0x61}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 31959; + uint8_t client_id_bytes[] = {0x4b, 0xb5}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x35, 0xbd, 0xe5}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xe, 0xe5, 0x1a, 0xcf, 0xc4, 0xb5, 0x7c, 0x36, 0xf2, 0xc0, 0x40}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "$\DC3o!\SI\253}\212\230\FS`\217X\171[", _password = Just "u", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\SOH$\ETB\192\157\196En", _willMsg = +// "\215\209\DLE\STX\164!\185\142\223\197\154\"\159\249\167,[\130", _willProps = []}), _cleanSession = True, _keepAlive +// = 14833, _connID = "\ETX@W\177\213>\v\227\232\224C\r\156\220j\DC4\170\177g\190-&\193", _properties = []} +TEST(Connect311QCTest, Encode20) { + uint8_t pkt[] = {0x10, 0x55, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x39, 0xf1, 0x0, 0x17, 0x3, + 0x40, 0x57, 0xb1, 0xd5, 0x3e, 0xb, 0xe3, 0xe8, 0xe0, 0x43, 0xd, 0x9c, 0xdc, 0x6a, 0x14, + 0xaa, 0xb1, 0x67, 0xbe, 0x2d, 0x26, 0xc1, 0x0, 0x8, 0x1, 0x24, 0x17, 0xc0, 0x9d, 0xc4, + 0x45, 0x6e, 0x0, 0x12, 0xd7, 0xd1, 0x10, 0x2, 0xa4, 0x21, 0xb9, 0x8e, 0xdf, 0xc5, 0x9a, + 0x22, 0x9f, 0xf9, 0xa7, 0x2c, 0x5b, 0x82, 0x0, 0xf, 0x24, 0x13, 0x6f, 0x21, 0xf, 0xfd, + 0x7d, 0xd4, 0xe6, 0x1c, 0x60, 0xd9, 0x58, 0xab, 0x5b, 0x0, 0x1, 0x75}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1, 0x24, 0x17, 0xc0, 0x9d, 0xc4, 0x45, 0x6e}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd7, 0xd1, 0x10, 0x2, 0xa4, 0x21, 0xb9, 0x8e, 0xdf, + 0xc5, 0x9a, 0x22, 0x9f, 0xf9, 0xa7, 0x2c, 0x5b, 0x82}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 14833; + uint8_t client_id_bytes[] = {0x3, 0x40, 0x57, 0xb1, 0xd5, 0x3e, 0xb, 0xe3, 0xe8, 0xe0, 0x43, 0xd, + 0x9c, 0xdc, 0x6a, 0x14, 0xaa, 0xb1, 0x67, 0xbe, 0x2d, 0x26, 0xc1}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x24, 0x13, 0x6f, 0x21, 0xf, 0xfd, 0x7d, 0xd4, 0xe6, 0x1c, 0x60, 0xd9, 0x58, 0xab, 0x5b}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x75}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\vA%3\NAK\141\215\DC1\202\232\133\157m&\195\DLE\177S\169-s\174ot\177\US\t\176", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\168\SO\185\228vJA\194DR\140\201\EOT\155\ETB!", _willMsg = "a\EM\252\SYNH\190\200 B\143\EOT\ETXl' \174\145\159n", +// _willProps = []}), _cleanSession = True, _keepAlive = 28777, _connID = +// "+3\250\223\230[8\232\GS\FS\191\141\166\159\EOT", _properties = []} +TEST(Connect311QCTest, Encode21) { + uint8_t pkt[] = {0x10, 0x60, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0x70, 0x69, 0x0, 0xf, 0x2b, 0x33, 0xfa, + 0xdf, 0xe6, 0x5b, 0x38, 0xe8, 0x1d, 0x1c, 0xbf, 0x8d, 0xa6, 0x9f, 0x4, 0x0, 0x10, 0xa8, 0xe, 0xb9, + 0xe4, 0x76, 0x4a, 0x41, 0xc2, 0x44, 0x52, 0x8c, 0xc9, 0x4, 0x9b, 0x17, 0x21, 0x0, 0x13, 0x61, 0x19, + 0xfc, 0x16, 0x48, 0xbe, 0xc8, 0x20, 0x42, 0x8f, 0x4, 0x3, 0x6c, 0x27, 0x20, 0xae, 0x91, 0x9f, 0x6e, + 0x0, 0x1c, 0xb, 0x41, 0x25, 0x33, 0x15, 0x8d, 0xd7, 0x11, 0xca, 0xe8, 0x85, 0x9d, 0x6d, 0x26, 0xc3, + 0x10, 0xb1, 0x53, 0xa9, 0x2d, 0x73, 0xae, 0x6f, 0x74, 0xb1, 0x1f, 0x9, 0xb0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa8, 0xe, 0xb9, 0xe4, 0x76, 0x4a, 0x41, 0xc2, + 0x44, 0x52, 0x8c, 0xc9, 0x4, 0x9b, 0x17, 0x21}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x61, 0x19, 0xfc, 0x16, 0x48, 0xbe, 0xc8, 0x20, 0x42, 0x8f, + 0x4, 0x3, 0x6c, 0x27, 0x20, 0xae, 0x91, 0x9f, 0x6e}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 28777; + uint8_t client_id_bytes[] = {0x2b, 0x33, 0xfa, 0xdf, 0xe6, 0x5b, 0x38, 0xe8, 0x1d, 0x1c, 0xbf, 0x8d, 0xa6, 0x9f, 0x4}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xb, 0x41, 0x25, 0x33, 0x15, 0x8d, 0xd7, 0x11, 0xca, 0xe8, 0x85, 0x9d, 0x6d, 0x26, + 0xc3, 0x10, 0xb1, 0x53, 0xa9, 0x2d, 0x73, 0xae, 0x6f, 0x74, 0xb1, 0x1f, 0x9, 0xb0}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\154\187ln", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "\147\234\128\171\v\219\164\138\218W\166", _willMsg = +// "\210\254\161\ENQ\v\192\253\DLE\176\204-\222Uv\154m\FSi+", _willProps = []}), _cleanSession = True, _keepAlive = +// 23669, _connID = "$\237\&8\219\166I\143>\251N\190&hL\173\150*\131\212>\211\244\SI\149\243\SYN\179\154\EOT", +// _properties = []} +TEST(Connect311QCTest, Encode22) { + uint8_t pkt[] = {0x10, 0x4b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x5c, 0x75, 0x0, 0x1d, 0x24, 0xed, + 0x38, 0xdb, 0xa6, 0x49, 0x8f, 0x3e, 0xfb, 0x4e, 0xbe, 0x26, 0x68, 0x4c, 0xad, 0x96, 0x2a, 0x83, + 0xd4, 0x3e, 0xd3, 0xf4, 0xf, 0x95, 0xf3, 0x16, 0xb3, 0x9a, 0x4, 0x0, 0xb, 0x93, 0xea, 0x80, + 0xab, 0xb, 0xdb, 0xa4, 0x8a, 0xda, 0x57, 0xa6, 0x0, 0x13, 0xd2, 0xfe, 0xa1, 0x5, 0xb, 0xc0, + 0xfd, 0x10, 0xb0, 0xcc, 0x2d, 0xde, 0x55, 0x76, 0x9a, 0x6d, 0x1c, 0x69, 0x2b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x93, 0xea, 0x80, 0xab, 0xb, 0xdb, 0xa4, 0x8a, 0xda, 0x57, 0xa6}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd2, 0xfe, 0xa1, 0x5, 0xb, 0xc0, 0xfd, 0x10, 0xb0, 0xcc, + 0x2d, 0xde, 0x55, 0x76, 0x9a, 0x6d, 0x1c, 0x69, 0x2b}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23669; + uint8_t client_id_bytes[] = {0x24, 0xed, 0x38, 0xdb, 0xa6, 0x49, 0x8f, 0x3e, 0xfb, 0x4e, 0xbe, 0x26, 0x68, 0x4c, 0xad, + 0x96, 0x2a, 0x83, 0xd4, 0x3e, 0xd3, 0xf4, 0xf, 0x95, 0xf3, 0x16, 0xb3, 0x9a, 0x4}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x9a, 0xbb, 0x6c, 0x6e}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\143,\SOH\155g\228PV\DC2<\233\167\240`\US", _password = Just +// "e\nm=f\140\230Dl\161\225\170\162v\164\EOTc\207\195\255\131n$G\179w", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS2, _willTopic = "\178\225\170J\183\NAK\128\201\233\247\215q\NAK\v\165A\US\228", _willMsg = +// "-\155\216\170\221I\188\147:\179\167:", _willProps = []}), _cleanSession = False, _keepAlive = 24031, _connID = +// "\SI5", _properties = []} +TEST(Connect311QCTest, Encode23) { + uint8_t pkt[] = {0x10, 0x5d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x5d, 0xdf, 0x0, 0x2, 0xf, 0x35, + 0x0, 0x12, 0xb2, 0xe1, 0xaa, 0x4a, 0xb7, 0x15, 0x80, 0xc9, 0xe9, 0xf7, 0xd7, 0x71, 0x15, 0xb, + 0xa5, 0x41, 0x1f, 0xe4, 0x0, 0xc, 0x2d, 0x9b, 0xd8, 0xaa, 0xdd, 0x49, 0xbc, 0x93, 0x3a, 0xb3, + 0xa7, 0x3a, 0x0, 0xf, 0x8f, 0x2c, 0x1, 0x9b, 0x67, 0xe4, 0x50, 0x56, 0x12, 0x3c, 0xe9, 0xa7, + 0xf0, 0x60, 0x1f, 0x0, 0x1a, 0x65, 0xa, 0x6d, 0x3d, 0x66, 0x8c, 0xe6, 0x44, 0x6c, 0xa1, 0xe1, + 0xaa, 0xa2, 0x76, 0xa4, 0x4, 0x63, 0xcf, 0xc3, 0xff, 0x83, 0x6e, 0x24, 0x47, 0xb3, 0x77}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb2, 0xe1, 0xaa, 0x4a, 0xb7, 0x15, 0x80, 0xc9, 0xe9, + 0xf7, 0xd7, 0x71, 0x15, 0xb, 0xa5, 0x41, 0x1f, 0xe4}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2d, 0x9b, 0xd8, 0xaa, 0xdd, 0x49, 0xbc, 0x93, 0x3a, 0xb3, 0xa7, 0x3a}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 24031; + uint8_t client_id_bytes[] = {0xf, 0x35}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x8f, 0x2c, 0x1, 0x9b, 0x67, 0xe4, 0x50, 0x56, 0x12, 0x3c, 0xe9, 0xa7, 0xf0, 0x60, 0x1f}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x65, 0xa, 0x6d, 0x3d, 0x66, 0x8c, 0xe6, 0x44, 0x6c, 0xa1, 0xe1, 0xaa, 0xa2, + 0x76, 0xa4, 0x4, 0x63, 0xcf, 0xc3, 0xff, 0x83, 0x6e, 0x24, 0x47, 0xb3, 0x77}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\141\198\185\130\140v\STX\135\128\CAN", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "Y\242i\225Ly\163\177\f\138\135/TW\n\DC3\217\RS\251c\244\DLEs\CAN\178mU>\SO", _willMsg = "Z", _willProps = []}), +// _cleanSession = True, _keepAlive = 14148, _connID = "hRi\ESC\170\202\226\252\ACK\209\SYN\222k\188", _properties = []} +TEST(Connect311QCTest, Encode24) { + uint8_t pkt[] = {0x10, 0x3c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x37, 0x44, 0x0, 0xe, 0x68, 0x52, + 0x69, 0x1b, 0xaa, 0xca, 0xe2, 0xfc, 0x6, 0xd1, 0x16, 0xde, 0x6b, 0xbc, 0x0, 0x1d, 0x59, 0xf2, + 0x69, 0xe1, 0x4c, 0x79, 0xa3, 0xb1, 0xc, 0x8a, 0x87, 0x2f, 0x54, 0x57, 0xa, 0x13, 0xd9, 0x1e, + 0xfb, 0x63, 0xf4, 0x10, 0x73, 0x18, 0xb2, 0x6d, 0x55, 0x3e, 0xe, 0x0, 0x1, 0x5a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x59, 0xf2, 0x69, 0xe1, 0x4c, 0x79, 0xa3, 0xb1, 0xc, 0x8a, 0x87, 0x2f, 0x54, 0x57, 0xa, + 0x13, 0xd9, 0x1e, 0xfb, 0x63, 0xf4, 0x10, 0x73, 0x18, 0xb2, 0x6d, 0x55, 0x3e, 0xe}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5a}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 14148; + uint8_t client_id_bytes[] = {0x68, 0x52, 0x69, 0x1b, 0xaa, 0xca, 0xe2, 0xfc, 0x6, 0xd1, 0x16, 0xde, 0x6b, 0xbc}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x8d, 0xc6, 0xb9, 0x82, 0x8c, 0x76, 0x2, 0x87, 0x80, 0x18}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\167\155\251\197h\150N", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = "'m\f$\SI\138a\SInjUa;\229\155Z\157\&2", _willMsg = +// "94H\150\255\251\134\159\242\&1H", _willProps = []}), _cleanSession = True, _keepAlive = 31273, _connID = +// "\211\132J\179\217\&3\245\247\151\a\182", _properties = []} +TEST(Connect311QCTest, Encode25) { + uint8_t pkt[] = {0x10, 0x38, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2e, 0x7a, 0x29, 0x0, 0xb, 0xd3, + 0x84, 0x4a, 0xb3, 0xd9, 0x33, 0xf5, 0xf7, 0x97, 0x7, 0xb6, 0x0, 0x12, 0x27, 0x6d, 0xc, + 0x24, 0xf, 0x8a, 0x61, 0xf, 0x6e, 0x6a, 0x55, 0x61, 0x3b, 0xe5, 0x9b, 0x5a, 0x9d, 0x32, + 0x0, 0xb, 0x39, 0x34, 0x48, 0x96, 0xff, 0xfb, 0x86, 0x9f, 0xf2, 0x31, 0x48}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x27, 0x6d, 0xc, 0x24, 0xf, 0x8a, 0x61, 0xf, 0x6e, + 0x6a, 0x55, 0x61, 0x3b, 0xe5, 0x9b, 0x5a, 0x9d, 0x32}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x39, 0x34, 0x48, 0x96, 0xff, 0xfb, 0x86, 0x9f, 0xf2, 0x31, 0x48}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 31273; + uint8_t client_id_bytes[] = {0xd3, 0x84, 0x4a, 0xb3, 0xd9, 0x33, 0xf5, 0xf7, 0x97, 0x7, 0xb6}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xa7, 0x9b, 0xfb, 0xc5, 0x68, 0x96, 0x4e}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\152", _password = Just +// "\174\152x,\214O\183\249,o\"\137\170m\244\164\203\ACK\186\179\217@ _[\r>", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS1, _willTopic = "A\SUB\166x\NUL", _willMsg = "\253\&0\131n\162\236\192\DEL \150.\SI\174\163", +// _willProps = []}), _cleanSession = True, _keepAlive = 11096, _connID = +// "\207\r\183\&5c`\208+\186d/\132'X\238\247\DLEO\130\241\201\158\234", _properties = []} +TEST(Connect311QCTest, Encode26) { + uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x2b, 0x58, 0x0, 0x17, 0xcf, 0xd, + 0xb7, 0x35, 0x63, 0x60, 0xd0, 0x2b, 0xba, 0x64, 0x2f, 0x84, 0x27, 0x58, 0xee, 0xf7, 0x10, 0x4f, + 0x82, 0xf1, 0xc9, 0x9e, 0xea, 0x0, 0x5, 0x41, 0x1a, 0xa6, 0x78, 0x0, 0x0, 0xe, 0xfd, 0x30, + 0x83, 0x6e, 0xa2, 0xec, 0xc0, 0x7f, 0x20, 0x96, 0x2e, 0xf, 0xae, 0xa3, 0x0, 0x1, 0x98, 0x0, + 0x1b, 0xae, 0x98, 0x78, 0x2c, 0xd6, 0x4f, 0xb7, 0xf9, 0x2c, 0x6f, 0x22, 0x89, 0xaa, 0x6d, 0xf4, + 0xa4, 0xcb, 0x6, 0xba, 0xb3, 0xd9, 0x40, 0x20, 0x5f, 0x5b, 0xd, 0x3e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x41, 0x1a, 0xa6, 0x78, 0x0}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfd, 0x30, 0x83, 0x6e, 0xa2, 0xec, 0xc0, 0x7f, 0x20, 0x96, 0x2e, 0xf, 0xae, 0xa3}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 11096; + uint8_t client_id_bytes[] = {0xcf, 0xd, 0xb7, 0x35, 0x63, 0x60, 0xd0, 0x2b, 0xba, 0x64, 0x2f, 0x84, + 0x27, 0x58, 0xee, 0xf7, 0x10, 0x4f, 0x82, 0xf1, 0xc9, 0x9e, 0xea}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x98}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xae, 0x98, 0x78, 0x2c, 0xd6, 0x4f, 0xb7, 0xf9, 0x2c, 0x6f, 0x22, 0x89, 0xaa, 0x6d, + 0xf4, 0xa4, 0xcb, 0x6, 0xba, 0xb3, 0xd9, 0x40, 0x20, 0x5f, 0x5b, 0xd, 0x3e}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\254\216\220\247\151\136\DC1\188~L\248\142", _password = Nothing, _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "U6Dw\178\166\201q\230\187\STX\187>P\180\&1\224[W\181\GS:", _willMsg = "", _willProps = []}), _cleanSession = False, +// _keepAlive = 29562, _connID = "~\233\223\144\214,\GSg\DLE\144\196=<", _properties = []} +TEST(Connect311QCTest, Encode27) { + uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8c, 0x73, 0x7a, 0x0, 0xd, 0x7e, 0xe9, 0xdf, + 0x90, 0xd6, 0x2c, 0x1d, 0x67, 0x10, 0x90, 0xc4, 0x3d, 0x3c, 0x0, 0x16, 0x55, 0x36, 0x44, 0x77, 0xb2, + 0xa6, 0xc9, 0x71, 0xe6, 0xbb, 0x2, 0xbb, 0x3e, 0x50, 0xb4, 0x31, 0xe0, 0x5b, 0x57, 0xb5, 0x1d, 0x3a, + 0x0, 0x0, 0x0, 0xc, 0xfe, 0xd8, 0xdc, 0xf7, 0x97, 0x88, 0x11, 0xbc, 0x7e, 0x4c, 0xf8, 0x8e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x55, 0x36, 0x44, 0x77, 0xb2, 0xa6, 0xc9, 0x71, 0xe6, 0xbb, 0x2, + 0xbb, 0x3e, 0x50, 0xb4, 0x31, 0xe0, 0x5b, 0x57, 0xb5, 0x1d, 0x3a}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 29562; + uint8_t client_id_bytes[] = {0x7e, 0xe9, 0xdf, 0x90, 0xd6, 0x2c, 0x1d, 0x67, 0x10, 0x90, 0xc4, 0x3d, 0x3c}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xfe, 0xd8, 0xdc, 0xf7, 0x97, 0x88, 0x11, 0xbc, 0x7e, 0x4c, 0xf8, 0x8e}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "W\NAK1\208\fP\SYN\143\223", _password = Just +// "-\161\CAN\233\GSA\129\195n,\214\STX\138", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, +// _willTopic = "\163", _willMsg = "^\216\194\&8-V`\191\"\215\247\221\210\t\EOT\SOt\209\205\SI\SO", _willProps = []}), +// _cleanSession = True, _keepAlive = 7229, _connID = "h$3\ESC%\229\134-\RS\205O", _properties = []} +TEST(Connect311QCTest, Encode28) { + uint8_t pkt[] = {0x10, 0x4b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x1c, 0x3d, 0x0, 0xb, 0x68, 0x24, + 0x33, 0x1b, 0x25, 0xe5, 0x86, 0x2d, 0x1e, 0xcd, 0x4f, 0x0, 0x1, 0xa3, 0x0, 0x15, 0x5e, 0xd8, + 0xc2, 0x38, 0x2d, 0x56, 0x60, 0xbf, 0x22, 0xd7, 0xf7, 0xdd, 0xd2, 0x9, 0x4, 0xe, 0x74, 0xd1, + 0xcd, 0xf, 0xe, 0x0, 0x9, 0x57, 0x15, 0x31, 0xd0, 0xc, 0x50, 0x16, 0x8f, 0xdf, 0x0, 0xd, + 0x2d, 0xa1, 0x18, 0xe9, 0x1d, 0x41, 0x81, 0xc3, 0x6e, 0x2c, 0xd6, 0x2, 0x8a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa3}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5e, 0xd8, 0xc2, 0x38, 0x2d, 0x56, 0x60, 0xbf, 0x22, 0xd7, 0xf7, + 0xdd, 0xd2, 0x9, 0x4, 0xe, 0x74, 0xd1, 0xcd, 0xf, 0xe}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 7229; + uint8_t client_id_bytes[] = {0x68, 0x24, 0x33, 0x1b, 0x25, 0xe5, 0x86, 0x2d, 0x1e, 0xcd, 0x4f}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x57, 0x15, 0x31, 0xd0, 0xc, 0x50, 0x16, 0x8f, 0xdf}; + lwmqtt_string_t username = {9, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x2d, 0xa1, 0x18, 0xe9, 0x1d, 0x41, 0x81, 0xc3, 0x6e, 0x2c, 0xd6, 0x2, 0x8a}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "E\158", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS0, _willTopic = "\SUB\167\200rR\DEL\237>\147\&3\t-\134,", _willMsg = +// "\EOT{\DC2S\216=\181\216\SOH\225\153\&6(\205\197\&1\ETX\STX\DEL", _willProps = []}), _cleanSession = True, _keepAlive +// = 27479, _connID = "\237\&2\143\179g\138\189\190\155l\NUL\242~\ETXJ\222^\147-\STX\140\210\198a\249", _properties = +// []} +TEST(Connect311QCTest, Encode29) { + uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x86, 0x6b, 0x57, 0x0, 0x19, 0xed, 0x32, + 0x8f, 0xb3, 0x67, 0x8a, 0xbd, 0xbe, 0x9b, 0x6c, 0x0, 0xf2, 0x7e, 0x3, 0x4a, 0xde, 0x5e, 0x93, + 0x2d, 0x2, 0x8c, 0xd2, 0xc6, 0x61, 0xf9, 0x0, 0xe, 0x1a, 0xa7, 0xc8, 0x72, 0x52, 0x7f, 0xed, + 0x3e, 0x93, 0x33, 0x9, 0x2d, 0x86, 0x2c, 0x0, 0x13, 0x4, 0x7b, 0x12, 0x53, 0xd8, 0x3d, 0xb5, + 0xd8, 0x1, 0xe1, 0x99, 0x36, 0x28, 0xcd, 0xc5, 0x31, 0x3, 0x2, 0x7f, 0x0, 0x2, 0x45, 0x9e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1a, 0xa7, 0xc8, 0x72, 0x52, 0x7f, 0xed, 0x3e, 0x93, 0x33, 0x9, 0x2d, 0x86, 0x2c}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4, 0x7b, 0x12, 0x53, 0xd8, 0x3d, 0xb5, 0xd8, 0x1, 0xe1, + 0x99, 0x36, 0x28, 0xcd, 0xc5, 0x31, 0x3, 0x2, 0x7f}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 27479; + uint8_t client_id_bytes[] = {0xed, 0x32, 0x8f, 0xb3, 0x67, 0x8a, 0xbd, 0xbe, 0x9b, 0x6c, 0x0, 0xf2, 0x7e, + 0x3, 0x4a, 0xde, 0x5e, 0x93, 0x2d, 0x2, 0x8c, 0xd2, 0xc6, 0x61, 0xf9}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x45, 0x9e}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\201\216\NAK\238\243\185\202\212?\188\224\STX/\198h\162\159z\193", _password = Just +// "\220\192\199\173G\186\161\178", _lastWill = Nothing, _cleanSession = True, _keepAlive = 7221, _connID = +// "\191nx\FSO\157\147i\209\143\DC2\STX\160\SI\215", _properties = []} +TEST(Connect311QCTest, Encode30) { + uint8_t pkt[] = {0x10, 0x3a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x1c, 0x35, 0x0, 0xf, 0xbf, + 0x6e, 0x78, 0x1c, 0x4f, 0x9d, 0x93, 0x69, 0xd1, 0x8f, 0x12, 0x2, 0xa0, 0xf, 0xd7, 0x0, + 0x13, 0xc9, 0xd8, 0x15, 0xee, 0xf3, 0xb9, 0xca, 0xd4, 0x3f, 0xbc, 0xe0, 0x2, 0x2f, 0xc6, + 0x68, 0xa2, 0x9f, 0x7a, 0xc1, 0x0, 0x8, 0xdc, 0xc0, 0xc7, 0xad, 0x47, 0xba, 0xa1, 0xb2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 7221; + uint8_t client_id_bytes[] = {0xbf, 0x6e, 0x78, 0x1c, 0x4f, 0x9d, 0x93, 0x69, 0xd1, 0x8f, 0x12, 0x2, 0xa0, 0xf, 0xd7}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xc9, 0xd8, 0x15, 0xee, 0xf3, 0xb9, 0xca, 0xd4, 0x3f, 0xbc, + 0xe0, 0x2, 0x2f, 0xc6, 0x68, 0xa2, 0x9f, 0x7a, 0xc1}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xdc, 0xc0, 0xc7, 0xad, 0x47, 0xba, 0xa1, 0xb2}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "]k\133\158\155\DC3\CANdB\149\244\NAKV\174", _password = Just +// "\243e\SUB\196D\v\196W8P\245\&6", _lastWill = Nothing, _cleanSession = True, _keepAlive = 1258, _connID = +// "q\SOH\220\128\ncN%\188\&7\248FP@\170\NUL\DELN\194\221o", _properties = [PropResponseInformation +// "\206Z\167\210\141\164\"\180\184mzlv\176\149\207?\137\234",PropAssignedClientIdentifier "hf",PropServerReference +// "aj\NUL\173\200\232\211\EMC,q\b]y\136f\EOT\ENQ:>E",PropTopicAliasMaximum 23557,PropSubscriptionIdentifierAvailable +// 215,PropReasonString +// "\192|;\RS\214}\216\205\196\151\160q\178\DLE\251\224\201`\209\DLE=\198\EOT-",PropSharedSubscriptionAvailable +// 29,PropReceiveMaximum 13694,PropServerKeepAlive 28821,PropRetainAvailable 74,PropResponseTopic "\190\129\133\208"]} +TEST(Connect5QCTest, Encode1) { + uint8_t pkt[] = {0x10, 0xa4, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x4, 0xea, 0x64, 0x1a, 0x0, 0x13, + 0xce, 0x5a, 0xa7, 0xd2, 0x8d, 0xa4, 0x22, 0xb4, 0xb8, 0x6d, 0x7a, 0x6c, 0x76, 0xb0, 0x95, 0xcf, 0x3f, + 0x89, 0xea, 0x12, 0x0, 0x2, 0x68, 0x66, 0x1c, 0x0, 0x15, 0x61, 0x6a, 0x0, 0xad, 0xc8, 0xe8, 0xd3, + 0x19, 0x43, 0x2c, 0x71, 0x8, 0x5d, 0x79, 0x88, 0x66, 0x4, 0x5, 0x3a, 0x3e, 0x45, 0x22, 0x5c, 0x5, + 0x29, 0xd7, 0x1f, 0x0, 0x18, 0xc0, 0x7c, 0x3b, 0x1e, 0xd6, 0x7d, 0xd8, 0xcd, 0xc4, 0x97, 0xa0, 0x71, + 0xb2, 0x10, 0xfb, 0xe0, 0xc9, 0x60, 0xd1, 0x10, 0x3d, 0xc6, 0x4, 0x2d, 0x2a, 0x1d, 0x21, 0x35, 0x7e, + 0x13, 0x70, 0x95, 0x25, 0x4a, 0x8, 0x0, 0x4, 0xbe, 0x81, 0x85, 0xd0, 0x0, 0x15, 0x71, 0x1, 0xdc, + 0x80, 0xa, 0x63, 0x4e, 0x25, 0xbc, 0x37, 0xf8, 0x46, 0x50, 0x40, 0xaa, 0x0, 0x7f, 0x4e, 0xc2, 0xdd, + 0x6f, 0x0, 0xe, 0x5d, 0x6b, 0x85, 0x9e, 0x9b, 0x13, 0x18, 0x64, 0x42, 0x95, 0xf4, 0x15, 0x56, 0xae, + 0x0, 0xc, 0xf3, 0x65, 0x1a, 0xc4, 0x44, 0xb, 0xc4, 0x57, 0x38, 0x50, 0xf5, 0x36}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xce, 0x5a, 0xa7, 0xd2, 0x8d, 0xa4, 0x22, 0xb4, 0xb8, 0x6d, + 0x7a, 0x6c, 0x76, 0xb0, 0x95, 0xcf, 0x3f, 0x89, 0xea}; + uint8_t bytesprops1[] = {0x68, 0x66}; + uint8_t bytesprops2[] = {0x61, 0x6a, 0x0, 0xad, 0xc8, 0xe8, 0xd3, 0x19, 0x43, 0x2c, 0x71, + 0x8, 0x5d, 0x79, 0x88, 0x66, 0x4, 0x5, 0x3a, 0x3e, 0x45}; + uint8_t bytesprops3[] = {0xc0, 0x7c, 0x3b, 0x1e, 0xd6, 0x7d, 0xd8, 0xcd, 0xc4, 0x97, 0xa0, 0x71, + 0xb2, 0x10, 0xfb, 0xe0, 0xc9, 0x60, 0xd1, 0x10, 0x3d, 0xc6, 0x4, 0x2d}; + uint8_t bytesprops4[] = {0xbe, 0x81, 0x85, 0xd0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23557}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13694}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28821}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, + }; + + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 1258; + uint8_t client_id_bytes[] = {0x71, 0x1, 0xdc, 0x80, 0xa, 0x63, 0x4e, 0x25, 0xbc, 0x37, 0xf8, + 0x46, 0x50, 0x40, 0xaa, 0x0, 0x7f, 0x4e, 0xc2, 0xdd, 0x6f}; + lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x5d, 0x6b, 0x85, 0x9e, 0x9b, 0x13, 0x18, 0x64, 0x42, 0x95, 0xf4, 0x15, 0x56, 0xae}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xf3, 0x65, 0x1a, 0xc4, 0x44, 0xb, 0xc4, 0x57, 0x38, 0x50, 0xf5, 0x36}; + lwmqtt_string_t password = {12, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "G>+\146\187X\SUB\205\220Z.\247\207\STX", _password = Just "l\254", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "H\158\252\SO\244\128\177\DC3\140m\154C\228\255\209\SO\252\215Wt\129t}\131", _willMsg = +// ";\228r\149\RS]\243u\250o\247\164,_\199", _willProps = [PropSubscriptionIdentifier 9,PropSessionExpiryInterval +// 20324,PropRequestResponseInformation 35,PropServerReference "",PropRequestProblemInformation +// 170,PropSessionExpiryInterval 14603,PropWillDelayInterval 29990,PropSubscriptionIdentifierAvailable 90]}), +// _cleanSession = False, _keepAlive = 6895, _connID = "/\215\GS\133\&67\233\250\218\RS\249)\ETB", _properties = +// [PropSharedSubscriptionAvailable 226,PropTopicAliasMaximum 13928]} +TEST(Connect5QCTest, Encode2) { + uint8_t pkt[] = {0x10, 0x79, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x1a, 0xef, 0x5, 0x2a, 0xe2, 0x22, + 0x36, 0x68, 0x0, 0xd, 0x2f, 0xd7, 0x1d, 0x85, 0x36, 0x37, 0xe9, 0xfa, 0xda, 0x1e, 0xf9, 0x29, + 0x17, 0x1a, 0xb, 0x9, 0x11, 0x0, 0x0, 0x4f, 0x64, 0x19, 0x23, 0x1c, 0x0, 0x0, 0x17, 0xaa, + 0x11, 0x0, 0x0, 0x39, 0xb, 0x18, 0x0, 0x0, 0x75, 0x26, 0x29, 0x5a, 0x0, 0x18, 0x48, 0x9e, + 0xfc, 0xe, 0xf4, 0x80, 0xb1, 0x13, 0x8c, 0x6d, 0x9a, 0x43, 0xe4, 0xff, 0xd1, 0xe, 0xfc, 0xd7, + 0x57, 0x74, 0x81, 0x74, 0x7d, 0x83, 0x0, 0xf, 0x3b, 0xe4, 0x72, 0x95, 0x1e, 0x5d, 0xf3, 0x75, + 0xfa, 0x6f, 0xf7, 0xa4, 0x2c, 0x5f, 0xc7, 0x0, 0xe, 0x47, 0x3e, 0x2b, 0x92, 0xbb, 0x58, 0x1a, + 0xcd, 0xdc, 0x5a, 0x2e, 0xf7, 0xcf, 0x2, 0x0, 0x2, 0x6c, 0xfe}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13928}}, + }; + + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20324}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14603}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29990}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 90}}, + }; + + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x48, 0x9e, 0xfc, 0xe, 0xf4, 0x80, 0xb1, 0x13, 0x8c, 0x6d, 0x9a, 0x43, + 0xe4, 0xff, 0xd1, 0xe, 0xfc, 0xd7, 0x57, 0x74, 0x81, 0x74, 0x7d, 0x83}; + lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x3b, 0xe4, 0x72, 0x95, 0x1e, 0x5d, 0xf3, 0x75, + 0xfa, 0x6f, 0xf7, 0xa4, 0x2c, 0x5f, 0xc7}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 6895; + uint8_t client_id_bytes[] = {0x2f, 0xd7, 0x1d, 0x85, 0x36, 0x37, 0xe9, 0xfa, 0xda, 0x1e, 0xf9, 0x29, 0x17}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x47, 0x3e, 0x2b, 0x92, 0xbb, 0x58, 0x1a, 0xcd, 0xdc, 0x5a, 0x2e, 0xf7, 0xcf, 0x2}; + lwmqtt_string_t username = {14, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x6c, 0xfe}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "P\174D\148^\175O\GS", _password = Nothing, _lastWill = Just (LastWill {_willRetain +// = True, _willQoS = QoS0, _willTopic = +// "\133\148;\217\ETX\ESCx\227\193\b\220\220\&2^\206\247,\208\184E\206g\130\RS\174\176\224", _willMsg = +// "&2\134`\139\156\254r\254!RA2\206\243\188", _willProps = [PropRequestResponseInformation 41,PropServerKeepAlive +// 6037,PropWillDelayInterval 27175,PropRequestResponseInformation 221,PropResponseInformation +// "~\DC1?\131\177\194E\176\251mF\241\251\180E\SOH\159",PropServerReference +// "\180'\165\245\215\158",PropWildcardSubscriptionAvailable 180,PropCorrelationData +// "Id\SOH\213\219L\168\173\DC1y",PropSubscriptionIdentifier 9,PropMessageExpiryInterval 13265,PropResponseTopic +// "<\208\227\226Q\vIi\163\231\244\200F\162\&1)\SO\EM\206",PropUserProperty +// "\139\145bW\CAN\204\244\213B\245\245\SO\242\189K\176\137\231T-\\\DC3" +// "cx_\162\173\171+dB\ETB\198Z\216\232jpq\140\211HX:\248\158\US,",PropTopicAlias +// 30639,PropSubscriptionIdentifierAvailable 134,PropWillDelayInterval 32737,PropServerReference +// "\SI\b",PropMessageExpiryInterval 15476,PropCorrelationData "\161\240*\233n\RS\216 +// \213p)\146B\136e\199\158\223\166X\169\183",PropPayloadFormatIndicator 9]}), _cleanSession = False, _keepAlive = +// 25004, _connID = "/}b5\208\133\FS\133\214c\NUL\151\144\NUL\172\SO\168&&\150\174\191N\206", _properties = +// [PropServerReference "Z\160\206\229X\251-H\tu'\NUL\252\RS\244d\238",PropSharedSubscriptionAvailable +// 203,PropSharedSubscriptionAvailable 239,PropContentType "\165\SUBU\206\&5\250;H",PropAssignedClientIdentifier +// "yHF3\182\170\&0\174%\238\SO\152\ESC\191\176\&7Ov",PropMaximumQoS 220,PropServerKeepAlive +// 29952,PropSubscriptionIdentifier 11,PropMaximumQoS 184,PropReasonString +// "\214\136n*\250\233\\m\208\DC3L\a\135\192\EM\201\RSL\228",PropResponseInformation +// "\ETX\137\247F",PropMessageExpiryInterval 6277,PropAuthenticationData "\DC1q\214\&2\206F\137#\240\144D<4p\NUL"]} +TEST(Connect5QCTest, Encode3) { + uint8_t pkt[] = { + 0x10, 0x8e, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xa4, 0x61, 0xac, 0x75, 0x1c, 0x0, 0x11, 0x5a, 0xa0, + 0xce, 0xe5, 0x58, 0xfb, 0x2d, 0x48, 0x9, 0x75, 0x27, 0x0, 0xfc, 0x1e, 0xf4, 0x64, 0xee, 0x2a, 0xcb, 0x2a, 0xef, + 0x3, 0x0, 0x8, 0xa5, 0x1a, 0x55, 0xce, 0x35, 0xfa, 0x3b, 0x48, 0x12, 0x0, 0x12, 0x79, 0x48, 0x46, 0x33, 0xb6, + 0xaa, 0x30, 0xae, 0x25, 0xee, 0xe, 0x98, 0x1b, 0xbf, 0xb0, 0x37, 0x4f, 0x76, 0x24, 0xdc, 0x13, 0x75, 0x0, 0xb, + 0xb, 0x24, 0xb8, 0x1f, 0x0, 0x13, 0xd6, 0x88, 0x6e, 0x2a, 0xfa, 0xe9, 0x5c, 0x6d, 0xd0, 0x13, 0x4c, 0x7, 0x87, + 0xc0, 0x19, 0xc9, 0x1e, 0x4c, 0xe4, 0x1a, 0x0, 0x4, 0x3, 0x89, 0xf7, 0x46, 0x2, 0x0, 0x0, 0x18, 0x85, 0x16, + 0x0, 0xf, 0x11, 0x71, 0xd6, 0x32, 0xce, 0x46, 0x89, 0x23, 0xf0, 0x90, 0x44, 0x3c, 0x34, 0x70, 0x0, 0x0, 0x18, + 0x2f, 0x7d, 0x62, 0x35, 0xd0, 0x85, 0x1c, 0x85, 0xd6, 0x63, 0x0, 0x97, 0x90, 0x0, 0xac, 0xe, 0xa8, 0x26, 0x26, + 0x96, 0xae, 0xbf, 0x4e, 0xce, 0xb9, 0x1, 0x19, 0x29, 0x13, 0x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3b, 0xd9, 0x3, 0x1b, 0x78, 0xe3, 0xc1, 0x8, 0xdc, 0xdc, 0x32, 0x5e, 0xce, + 0xf7, 0x2c, 0xd0, 0xb8, 0x45, 0xce, 0x67, 0x82, 0x1e, 0xae, 0xb0, 0xe0, 0x0, 0x10, 0x26, 0x32, 0x86, 0x60, 0x8b, + 0x9c, 0xfe, 0x72, 0xfe, 0x21, 0x52, 0x41, 0x32, 0xce, 0xf3, 0xbc, 0x0, 0x8, 0x50, 0xae, 0x44, 0x94, 0x5e, 0xaf, + 0x4f, 0x1d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x5a, 0xa0, 0xce, 0xe5, 0x58, 0xfb, 0x2d, 0x48, 0x9, + 0x75, 0x27, 0x0, 0xfc, 0x1e, 0xf4, 0x64, 0xee}; + uint8_t bytesprops1[] = {0xa5, 0x1a, 0x55, 0xce, 0x35, 0xfa, 0x3b, 0x48}; + uint8_t bytesprops2[] = {0x79, 0x48, 0x46, 0x33, 0xb6, 0xaa, 0x30, 0xae, 0x25, + 0xee, 0xe, 0x98, 0x1b, 0xbf, 0xb0, 0x37, 0x4f, 0x76}; + uint8_t bytesprops3[] = {0xd6, 0x88, 0x6e, 0x2a, 0xfa, 0xe9, 0x5c, 0x6d, 0xd0, 0x13, + 0x4c, 0x7, 0x87, 0xc0, 0x19, 0xc9, 0x1e, 0x4c, 0xe4}; + uint8_t bytesprops4[] = {0x3, 0x89, 0xf7, 0x46}; + uint8_t bytesprops5[] = {0x11, 0x71, 0xd6, 0x32, 0xce, 0x46, 0x89, 0x23, 0xf0, 0x90, 0x44, 0x3c, 0x34, 0x70, 0x0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29952}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6277}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops5}}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x7e, 0x11, 0x3f, 0x83, 0xb1, 0xc2, 0x45, 0xb0, 0xfb, + 0x6d, 0x46, 0xf1, 0xfb, 0xb4, 0x45, 0x1, 0x9f}; + uint8_t byteswillprops1[] = {0xb4, 0x27, 0xa5, 0xf5, 0xd7, 0x9e}; + uint8_t byteswillprops2[] = {0x49, 0x64, 0x1, 0xd5, 0xdb, 0x4c, 0xa8, 0xad, 0x11, 0x79}; + uint8_t byteswillprops3[] = {0x3c, 0xd0, 0xe3, 0xe2, 0x51, 0xb, 0x49, 0x69, 0xa3, 0xe7, + 0xf4, 0xc8, 0x46, 0xa2, 0x31, 0x29, 0xe, 0x19, 0xce}; + uint8_t byteswillprops5[] = {0x63, 0x78, 0x5f, 0xa2, 0xad, 0xab, 0x2b, 0x64, 0x42, 0x17, 0xc6, 0x5a, 0xd8, + 0xe8, 0x6a, 0x70, 0x71, 0x8c, 0xd3, 0x48, 0x58, 0x3a, 0xf8, 0x9e, 0x1f, 0x2c}; + uint8_t byteswillprops4[] = {0x8b, 0x91, 0x62, 0x57, 0x18, 0xcc, 0xf4, 0xd5, 0x42, 0xf5, 0xf5, + 0xe, 0xf2, 0xbd, 0x4b, 0xb0, 0x89, 0xe7, 0x54, 0x2d, 0x5c, 0x13}; + uint8_t byteswillprops6[] = {0xf, 0x8}; + uint8_t byteswillprops7[] = {0xa1, 0xf0, 0x2a, 0xe9, 0x6e, 0x1e, 0xd8, 0x20, 0xd5, 0x70, 0x29, + 0x92, 0x42, 0x88, 0x65, 0xc7, 0x9e, 0xdf, 0xa6, 0x58, 0xa9, 0xb7}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6037}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27175}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13265}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {22, (char*)&byteswillprops4}, .v = {26, (char*)&byteswillprops5}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30639}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32737}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15476}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 9}}, + }; + + lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x85, 0x94, 0x3b, 0xd9, 0x3, 0x1b, 0x78, 0xe3, 0xc1, 0x8, 0xdc, 0xdc, 0x32, 0x5e, + 0xce, 0xf7, 0x2c, 0xd0, 0xb8, 0x45, 0xce, 0x67, 0x82, 0x1e, 0xae, 0xb0, 0xe0}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x26, 0x32, 0x86, 0x60, 0x8b, 0x9c, 0xfe, 0x72, + 0xfe, 0x21, 0x52, 0x41, 0x32, 0xce, 0xf3, 0xbc}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 25004; + uint8_t client_id_bytes[] = {0x2f, 0x7d, 0x62, 0x35, 0xd0, 0x85, 0x1c, 0x85, 0xd6, 0x63, 0x0, 0x97, + 0x90, 0x0, 0xac, 0xe, 0xa8, 0x26, 0x26, 0x96, 0xae, 0xbf, 0x4e, 0xce}; + lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x50, 0xae, 0x44, 0x94, 0x5e, 0xaf, 0x4f, 0x1d}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "t~B\193\194g\135.\205\195'\202\&4\254\167\130&}\131\SO(", +// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = +// "\167\209\SI\144\184\148\175\153P3\152[\245s\f\160\STX\173\250\248\&6|\vh\134\236\&6\214\237E", _willMsg = +// "K9\178\239\192\180\&4\159\238\219\254cw\137\\K\177\175\230", _willProps = [PropReasonString +// "\CAN<&\222\203P5N\225\250\235\225\186\240<@\227\&6\169\169",PropReasonString +// "\205\n\152#\251\168\162\NUL\f\133\252\b\FS\151\US\180\136\&5\209k\237\154",PropMessageExpiryInterval +// 177,PropSharedSubscriptionAvailable 106,PropResponseInformation +// "c7`F#l\162\173\133\236\v\198\224\DC4E\n\167\ACK",PropMaximumQoS 250,PropReceiveMaximum 1733,PropRetainAvailable +// 190,PropSharedSubscriptionAvailable 152,PropMaximumPacketSize 18199,PropResponseInformation "\166\171\210\207\135 +// \190\134\188\"\SOW4\136\&2~\163\&0\237\195\191\&9\237\189 2",PropSubscriptionIdentifier 6,PropTopicAlias +// 3403,PropServerReference "",PropTopicAliasMaximum 6329,PropSharedSubscriptionAvailable +// 65,PropSubscriptionIdentifierAvailable 0,PropAuthenticationData "_\STX\222?P\253\STX}\165s\141"]}), _cleanSession = +// False, _keepAlive = 30510, _connID = +// "\254\DC1x\142\180\241\164\178u\EMn\150\196Ks\162\161\152\&1\SYN\233Bh\180\177D",PropRetainAvailable 215,PropMessageExpiryInterval +// 7547,PropMessageExpiryInterval 10918]}), _cleanSession = True, _keepAlive = 19375, _connID = +// "/\\r\181\177\142o\161\139@\150@F", _properties = [PropAuthenticationMethod +// "\vo\194$\179o\253LB\SO\ACK\ETB\227T?zh\218\196\158\&5\SI'`B\137",PropAuthenticationData +// "\170\199",PropMaximumPacketSize 21294,PropAuthenticationData +// "\142j\132^\171\191\174U(\249\193\223\SYN-\237\145\128\146",PropAssignedClientIdentifier +// "\239W\rf\218}5\202g\RS\NUL\128-\198\179\223\227\145 \145\b\184",PropServerKeepAlive 9655,PropTopicAliasMaximum +// 23525,PropAuthenticationData "\166\169\&0\b\DEL\251\243\&3\STX\251\140n\224eMvn\ETB",PropRetainAvailable +// 61,PropMessageExpiryInterval 26294,PropSessionExpiryInterval 20677,PropTopicAliasMaximum +// 24479,PropMessageExpiryInterval 4904,PropUserProperty "\249\&0\217#\141\140\DLE\153f\154\CANnZ\DC1VzoY" +// "\216\191\206\168\a'\147\134",PropMaximumQoS 234,PropServerReference +// "V\RST\239\"J\214\128\146\246=bZ\DC3\182r\DLE",PropSharedSubscriptionAvailable 158,PropContentType +// "\tP\222\197\146\ENQ\211L\227D\232\171_h\NAK\146k[\STX\221\n\146",PropWillDelayInterval +// 27789,PropSubscriptionIdentifier 16]} +TEST(Connect5QCTest, Encode5) { + uint8_t pkt[] = { + 0x10, 0xc9, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0x4b, 0xaf, 0xdb, 0x1, 0x15, 0x0, 0x1a, 0xb, + 0x6f, 0xc2, 0x24, 0xb3, 0x6f, 0xfd, 0x4c, 0x42, 0xe, 0x6, 0x17, 0xe3, 0x54, 0x3f, 0x7a, 0x68, 0xda, 0xc4, 0x9e, + 0x35, 0xf, 0x27, 0x60, 0x42, 0x89, 0x16, 0x0, 0x2, 0xaa, 0xc7, 0x27, 0x0, 0x0, 0x53, 0x2e, 0x16, 0x0, 0x12, + 0x8e, 0x6a, 0x84, 0x5e, 0xab, 0xbf, 0xae, 0x55, 0x28, 0xf9, 0xc1, 0xdf, 0x16, 0x2d, 0xed, 0x91, 0x80, 0x92, 0x12, + 0x0, 0x16, 0xef, 0x57, 0xd, 0x66, 0xda, 0x7d, 0x35, 0xca, 0x67, 0x1e, 0x0, 0x80, 0x2d, 0xc6, 0xb3, 0xdf, 0xe3, + 0x91, 0x20, 0x91, 0x8, 0xb8, 0x13, 0x25, 0xb7, 0x22, 0x5b, 0xe5, 0x16, 0x0, 0x12, 0xa6, 0xa9, 0x30, 0x8, 0x7f, + 0xfb, 0xf3, 0x33, 0x2, 0xfb, 0x8c, 0x6e, 0xe0, 0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, 0x19, 0x17, 0x21, 0x9, 0x4a, 0x26, 0x0, 0xa, 0xc6, 0x38, 0xf3, 0x91, + 0xe, 0x8c, 0x1e, 0x7d, 0x6d, 0xaf, 0x0, 0x4, 0xa7, 0x88, 0x66, 0x6c, 0x2, 0x0, 0x0, 0x5e, 0x7c, 0x1c, 0x0, + 0x3, 0x71, 0x78, 0x26, 0x22, 0x73, 0xf6, 0x2a, 0x60, 0x15, 0x0, 0x1e, 0xc6, 0xef, 0x74, 0xd0, 0xf7, 0xca, 0x67, + 0x24, 0xbc, 0x4, 0x6a, 0x7, 0xd7, 0xb6, 0x9f, 0x73, 0xe3, 0xe9, 0x2b, 0x43, 0xa2, 0x11, 0x3c, 0xe1, 0x4c, 0xe, + 0xfd, 0xec, 0x0, 0xd3, 0x3, 0x0, 0x14, 0x72, 0xe3, 0x8a, 0x75, 0x25, 0x77, 0xd1, 0xab, 0x3e, 0xa2, 0xa1, 0x98, + 0x31, 0x16, 0xe9, 0x42, 0x68, 0xb4, 0xb1, 0x44, 0x25, 0xd7, 0x2, 0x0, 0x0, 0x1d, 0x7b, 0x2, 0x0, 0x0, 0x2a, + 0xa6, 0x0, 0x1, 0x2, 0x0, 0x11, 0x39, 0xc, 0x98, 0x26, 0xcb, 0xc4, 0x99, 0x9c, 0x5e, 0xfa, 0x87, 0x87, 0xcb, + 0xdd, 0x8b, 0xdc, 0x53, 0x0, 0x11, 0x2b, 0x61, 0x86, 0x47, 0xad, 0x26, 0x4f, 0xf4, 0xec, 0x7f, 0x9d, 0xdc, 0xd0, + 0x63, 0x4b, 0x25, 0xf4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb, 0x6f, 0xc2, 0x24, 0xb3, 0x6f, 0xfd, 0x4c, 0x42, 0xe, 0x6, 0x17, 0xe3, + 0x54, 0x3f, 0x7a, 0x68, 0xda, 0xc4, 0x9e, 0x35, 0xf, 0x27, 0x60, 0x42, 0x89}; + uint8_t bytesprops1[] = {0xaa, 0xc7}; + uint8_t bytesprops2[] = {0x8e, 0x6a, 0x84, 0x5e, 0xab, 0xbf, 0xae, 0x55, 0x28, + 0xf9, 0xc1, 0xdf, 0x16, 0x2d, 0xed, 0x91, 0x80, 0x92}; + uint8_t bytesprops3[] = {0xef, 0x57, 0xd, 0x66, 0xda, 0x7d, 0x35, 0xca, 0x67, 0x1e, 0x0, + 0x80, 0x2d, 0xc6, 0xb3, 0xdf, 0xe3, 0x91, 0x20, 0x91, 0x8, 0xb8}; + uint8_t bytesprops4[] = {0xa6, 0xa9, 0x30, 0x8, 0x7f, 0xfb, 0xf3, 0x33, 0x2, + 0xfb, 0x8c, 0x6e, 0xe0, 0x65, 0x4d, 0x76, 0x6e, 0x17}; + uint8_t bytesprops6[] = {0xd8, 0xbf, 0xce, 0xa8, 0x7, 0x27, 0x93, 0x86}; + uint8_t bytesprops5[] = {0xf9, 0x30, 0xd9, 0x23, 0x8d, 0x8c, 0x10, 0x99, 0x66, + 0x9a, 0x18, 0x6e, 0x5a, 0x11, 0x56, 0x7a, 0x6f, 0x59}; + uint8_t bytesprops7[] = {0x56, 0x1e, 0x54, 0xef, 0x22, 0x4a, 0xd6, 0x80, 0x92, + 0xf6, 0x3d, 0x62, 0x5a, 0x13, 0xb6, 0x72, 0x10}; + uint8_t bytesprops8[] = {0x9, 0x50, 0xde, 0xc5, 0x92, 0x5, 0xd3, 0x4c, 0xe3, 0x44, 0xe8, + 0xab, 0x5f, 0x68, 0x15, 0x92, 0x6b, 0x5b, 0x2, 0xdd, 0xa, 0x92}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21294}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9655}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23525}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26294}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20677}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24479}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4904}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops5}, .v = {8, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27789}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + }; + + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x53, 0x4a, 0x95, 0xe3, 0x6a, 0xa1, 0xd7, 0xe6, 0xd1, 0xbe, 0x81, 0xf5, 0xed, + 0x53, 0x3c, 0x97, 0xef, 0x2a, 0x3c, 0xc0, 0xe1, 0x48, 0x66, 0xa7, 0xcd}; + uint8_t byteswillprops2[] = {0xa7, 0x88, 0x66, 0x6c}; + uint8_t byteswillprops1[] = {0xc6, 0x38, 0xf3, 0x91, 0xe, 0x8c, 0x1e, 0x7d, 0x6d, 0xaf}; + uint8_t byteswillprops3[] = {0x71, 0x78, 0x26}; + uint8_t byteswillprops4[] = {0xc6, 0xef, 0x74, 0xd0, 0xf7, 0xca, 0x67, 0x24, 0xbc, 0x4, + 0x6a, 0x7, 0xd7, 0xb6, 0x9f, 0x73, 0xe3, 0xe9, 0x2b, 0x43, + 0xa2, 0x11, 0x3c, 0xe1, 0x4c, 0xe, 0xfd, 0xec, 0x0, 0xd3}; + uint8_t byteswillprops5[] = {0x72, 0xe3, 0x8a, 0x75, 0x25, 0x77, 0xd1, 0xab, 0x3e, 0xa2, + 0xa1, 0x98, 0x31, 0x16, 0xe9, 0x42, 0x68, 0xb4, 0xb1, 0x44}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15607}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6513}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16736}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24529}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30836}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26676}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2378}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {10, (char*)&byteswillprops1}, .v = {4, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24188}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29686}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7547}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10918}}, + }; + + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x2}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x39, 0xc, 0x98, 0x26, 0xcb, 0xc4, 0x99, 0x9c, 0x5e, + 0xfa, 0x87, 0x87, 0xcb, 0xdd, 0x8b, 0xdc, 0x53}; + lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 19375; + uint8_t client_id_bytes[] = {0x2f, 0x5c, 0x72, 0xb5, 0xb1, 0x8e, 0x6f, 0xa1, 0x8b, 0x40, 0x96, 0x40, 0x46}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x2b, 0x61, 0x86, 0x47, 0xad, 0x26, 0x4f, 0xf4, 0xec, + 0x7f, 0x9d, 0xdc, 0xd0, 0x63, 0x4b, 0x25, 0xf4}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\190\145\130w(G[n\144\185\"\138A\235\255GZ\SI\251\136*\210 +// \238$*\DC3\136\223\238", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "\154\153\177L7?\EM \243\242#e\CAN,\194\180\CANV\230y\\\RS", _willMsg = "\147\239z\187\224\229", _willProps = +// [PropAuthenticationData "\241\210\DC1Z1~\SI\144\145\147\128wM\240j$JO",PropCorrelationData +// "\243~\240\171\SUBIE\146||\180bl*\177Tl\DC2<\166\214m\200n^Z\235%",PropResponseTopic +// "\186\147%X\DLE?\144\190\FS\231\181\235",PropRetainAvailable 229,PropUserProperty "\ENQ\138\178\161+" +// "\ESC\DC3\173\228-\131\243\244\160\168c\185\139t\177\175\235\140B\147\ENQ\DC1",PropSharedSubscriptionAvailable +// 184,PropSubscriptionIdentifierAvailable 161,PropReasonString +// "\134b\131\172\139\167+\193O+\247kz:\NAK\199\&6\175f",PropServerReference +// "\172\ENQ\FS\236\213\210\215\188;%\SO\149",PropResponseTopic "\NUL[T\ETX\140\NAK\206\138",PropMaximumPacketSize +// 6713,PropSessionExpiryInterval 3395,PropMessageExpiryInterval 10996,PropServerKeepAlive 1444,PropReasonString +// "D\158\254YfR\212h\206w\ETXR=\185\142\SOL@\177\221\159\154\166\221\SYN\231%",PropMessageExpiryInterval +// 21083,PropServerReference "\206\r\ACK\SYN\175\238o\SOEO\160.%n\173\SYND\157\226g\209\225Q",PropMessageExpiryInterval +// 6337,PropTopicAliasMaximum 716,PropMessageExpiryInterval 25841,PropSubscriptionIdentifierAvailable +// 229,PropReasonString "\225P\193\&9",PropWildcardSubscriptionAvailable 159,PropMaximumQoS 51,PropTopicAliasMaximum +// 6727,PropReceiveMaximum 11377]}), _cleanSession = True, _keepAlive = 14576, _connID = "m\168E>\DC1\GSp", _properties +// = [PropAuthenticationMethod +// "A%\137\149\&1\210_|\201\174\181\172;\209g&\207\&6\241\134aC\NUL\197\SUBH\191",PropAuthenticationData +// "\185\230\ENQ\152\203\183\SYNc\192\GS{;\b\217\142\255",PropRequestProblemInformation 150,PropResponseTopic +// "\236\250\153\194yY]\167\194\249\157o\241\144*\185[\219\244",PropSharedSubscriptionAvailable +// 15,PropSubscriptionIdentifierAvailable 77,PropRetainAvailable 151,PropSessionExpiryInterval 17635,PropContentType +// "\170wU\187\DC2)/O0\183;\220\140J\193\190r\136",PropServerKeepAlive 30845,PropWillDelayInterval +// 20450,PropAuthenticationMethod +// "\159\227Q\">\223\251'\242e\146v\138\237\&8\140\170\t\ENQP\151\tcc\241\EOT&\224\198\140",PropContentType +// "\139\244",PropRequestProblemInformation 170,PropSharedSubscriptionAvailable 140,PropSubscriptionIdentifierAvailable +// 23,PropTopicAlias 20455,PropPayloadFormatIndicator 187]} +TEST(Connect5QCTest, Encode6) { + uint8_t pkt[] = { + 0x10, 0x81, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x38, 0xf0, 0xa2, 0x1, 0x15, 0x0, 0x1b, 0x41, + 0x25, 0x89, 0x95, 0x31, 0xd2, 0x5f, 0x7c, 0xc9, 0xae, 0xb5, 0xac, 0x3b, 0xd1, 0x67, 0x26, 0xcf, 0x36, 0xf1, 0x86, + 0x61, 0x43, 0x0, 0xc5, 0x1a, 0x48, 0xbf, 0x16, 0x0, 0x10, 0xb9, 0xe6, 0x5, 0x98, 0xcb, 0xb7, 0x16, 0x63, 0xc0, + 0x1d, 0x7b, 0x3b, 0x8, 0xd9, 0x8e, 0xff, 0x17, 0x96, 0x8, 0x0, 0x13, 0xec, 0xfa, 0x99, 0xc2, 0x79, 0x59, 0x5d, + 0xa7, 0xc2, 0xf9, 0x9d, 0x6f, 0xf1, 0x90, 0x2a, 0xb9, 0x5b, 0xdb, 0xf4, 0x2a, 0xf, 0x29, 0x4d, 0x25, 0x97, 0x11, + 0x0, 0x0, 0x44, 0xe3, 0x3, 0x0, 0x12, 0xaa, 0x77, 0x55, 0xbb, 0x12, 0x29, 0x2f, 0x4f, 0x30, 0xb7, 0x3b, 0xdc, + 0x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 0xbe, 0x91, 0x82, 0x77, 0x28, 0x47, 0x5b, 0x6e, + 0x90, 0xb9, 0x22, 0x8a, 0x41, 0xeb, 0xff, 0x47, 0x5a, 0xf, 0xfb, 0x88, 0x2a, 0xd2, 0x20, 0xee, 0x24, 0x2a, 0x13, + 0x88, 0xdf, 0xee}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x41, 0x25, 0x89, 0x95, 0x31, 0xd2, 0x5f, 0x7c, 0xc9, 0xae, 0xb5, 0xac, 0x3b, 0xd1, + 0x67, 0x26, 0xcf, 0x36, 0xf1, 0x86, 0x61, 0x43, 0x0, 0xc5, 0x1a, 0x48, 0xbf}; + uint8_t bytesprops1[] = {0xb9, 0xe6, 0x5, 0x98, 0xcb, 0xb7, 0x16, 0x63, + 0xc0, 0x1d, 0x7b, 0x3b, 0x8, 0xd9, 0x8e, 0xff}; + uint8_t bytesprops2[] = {0xec, 0xfa, 0x99, 0xc2, 0x79, 0x59, 0x5d, 0xa7, 0xc2, 0xf9, + 0x9d, 0x6f, 0xf1, 0x90, 0x2a, 0xb9, 0x5b, 0xdb, 0xf4}; + uint8_t bytesprops3[] = {0xaa, 0x77, 0x55, 0xbb, 0x12, 0x29, 0x2f, 0x4f, 0x30, + 0xb7, 0x3b, 0xdc, 0x8c, 0x4a, 0xc1, 0xbe, 0x72, 0x88}; + uint8_t bytesprops4[] = {0x9f, 0xe3, 0x51, 0x22, 0x3e, 0xdf, 0xfb, 0x27, 0xf2, 0x65, 0x92, 0x76, 0x8a, 0xed, 0x38, + 0x8c, 0xaa, 0x9, 0x5, 0x50, 0x97, 0x9, 0x63, 0x63, 0xf1, 0x4, 0x26, 0xe0, 0xc6, 0x8c}; + uint8_t bytesprops5[] = {0x8b, 0xf4}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17635}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30845}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20450}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20455}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 187}}, + }; + + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xf1, 0xd2, 0x11, 0x5a, 0x31, 0x7e, 0xf, 0x90, 0x91, + 0x93, 0x80, 0x77, 0x4d, 0xf0, 0x6a, 0x24, 0x4a, 0x4f}; + uint8_t byteswillprops1[] = {0xf3, 0x7e, 0xf0, 0xab, 0x1a, 0x49, 0x45, 0x92, 0x7c, 0x7c, 0xb4, 0x62, 0x6c, 0x2a, + 0xb1, 0x54, 0x6c, 0x12, 0x3c, 0xa6, 0xd6, 0x6d, 0xc8, 0x6e, 0x5e, 0x5a, 0xeb, 0x25}; + uint8_t byteswillprops2[] = {0xba, 0x93, 0x25, 0x58, 0x10, 0x3f, 0x90, 0xbe, 0x1c, 0xe7, 0xb5, 0xeb}; + uint8_t byteswillprops4[] = {0x1b, 0x13, 0xad, 0xe4, 0x2d, 0x83, 0xf3, 0xf4, 0xa0, 0xa8, 0x63, + 0xb9, 0x8b, 0x74, 0xb1, 0xaf, 0xeb, 0x8c, 0x42, 0x93, 0x5, 0x11}; + uint8_t byteswillprops3[] = {0x5, 0x8a, 0xb2, 0xa1, 0x2b}; + uint8_t byteswillprops5[] = {0x86, 0x62, 0x83, 0xac, 0x8b, 0xa7, 0x2b, 0xc1, 0x4f, 0x2b, + 0xf7, 0x6b, 0x7a, 0x3a, 0x15, 0xc7, 0x36, 0xaf, 0x66}; + uint8_t byteswillprops6[] = {0xac, 0x5, 0x1c, 0xec, 0xd5, 0xd2, 0xd7, 0xbc, 0x3b, 0x25, 0xe, 0x95}; + uint8_t byteswillprops7[] = {0x0, 0x5b, 0x54, 0x3, 0x8c, 0x15, 0xce, 0x8a}; + uint8_t byteswillprops8[] = {0x44, 0x9e, 0xfe, 0x59, 0x66, 0x52, 0xd4, 0x68, 0xce, 0x77, 0x3, 0x52, 0x3d, 0xb9, + 0x8e, 0xe, 0x4c, 0x40, 0xb1, 0xdd, 0x9f, 0x9a, 0xa6, 0xdd, 0x16, 0xe7, 0x25}; + uint8_t byteswillprops9[] = {0xce, 0xd, 0x6, 0x16, 0xaf, 0xee, 0x6f, 0xe, 0x45, 0x4f, 0xa0, 0x2e, + 0x25, 0x6e, 0xad, 0x16, 0x44, 0x9d, 0xe2, 0x67, 0xd1, 0xe1, 0x51}; + uint8_t byteswillprops10[] = {0xe1, 0x50, 0xc1, 0x39}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {5, (char*)&byteswillprops3}, .v = {22, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6713}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3395}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10996}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1444}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21083}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6337}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 716}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25841}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6727}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11377}}, + }; + + lwmqtt_properties_t willprops = {26, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x9a, 0x99, 0xb1, 0x4c, 0x37, 0x3f, 0x19, 0x20, 0xf3, 0xf2, 0x23, + 0x65, 0x18, 0x2c, 0xc2, 0xb4, 0x18, 0x56, 0xe6, 0x79, 0x5c, 0x1e}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x93, 0xef, 0x7a, 0xbb, 0xe0, 0xe5}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 14576; + uint8_t client_id_bytes[] = {0x6d, 0xa8, 0x45, 0x3e, 0x11, 0x1d, 0x70}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xbe, 0x91, 0x82, 0x77, 0x28, 0x47, 0x5b, 0x6e, 0x90, 0xb9, 0x22, 0x8a, 0x41, 0xeb, 0xff, + 0x47, 0x5a, 0xf, 0xfb, 0x88, 0x2a, 0xd2, 0x20, 0xee, 0x24, 0x2a, 0x13, 0x88, 0xdf, 0xee}; + lwmqtt_string_t password = {30, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "Ibz\161\NAK]\135\187\244P\201n\128\254LP\157\215\&5 ", _password = Just +// "\DC1\179\173\241Kq\135\157\&0\174?\226\202\185?\NUL\225\201\214\r", _lastWill = Nothing, _cleanSession = True, +// _keepAlive = 25611, _connID = "Q0\230c\ENQ\197x\GS\144k\195\162", _properties = [PropServerKeepAlive +// 949,PropSessionExpiryInterval 22333,PropResponseInformation +// "-\251\FS3\188k|aR]\144\EM\129R\194\227O",PropReceiveMaximum 31115,PropSubscriptionIdentifierAvailable +// 71,PropServerKeepAlive 4790,PropRequestProblemInformation 225,PropSessionExpiryInterval 21644,PropMaximumQoS +// 202,PropSessionExpiryInterval 2656,PropSharedSubscriptionAvailable 125,PropContentType +// "S\154\157\137=\FS\196\169\DC4d\188\211w\216\241\SUB\DC1{S\191\ETX",PropCorrelationData +// "P\ESC\149\223\201M\244<\SI\218\157?m1<\152X-\221\221\FS\161?",PropPayloadFormatIndicator +// 166,PropRequestResponseInformation 48,PropRequestProblemInformation 60,PropAssignedClientIdentifier +// "F\236\f\FS\236\234\167sx\138F\162\194RXo\172H\a\165",PropSessionExpiryInterval 10945,PropAuthenticationData +// "iV\ACK\202\159\254c\220\212\171@\215\134\168\194.?\167\244\EOT",PropServerReference +// "\173\195K\STX\176\158\NUL]\EM\243z\251\129\147Z\195",PropResponseTopic +// "[\US\EOT\240|\241\234j",PropPayloadFormatIndicator 219,PropAuthenticationData +// "\175\196\163]\133\206\&7\208q\228\194\&9H"]} +TEST(Connect5QCTest, Encode7) { + uint8_t pkt[] = { + 0x10, 0x95, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x64, 0xb, 0xcf, 0x1, 0x13, 0x3, 0xb5, 0x11, + 0x0, 0x0, 0x57, 0x3d, 0x1a, 0x0, 0x11, 0x2d, 0xfb, 0x1c, 0x33, 0xbc, 0x6b, 0x7c, 0x61, 0x52, 0x5d, 0x90, 0x19, + 0x81, 0x52, 0xc2, 0xe3, 0x4f, 0x21, 0x79, 0x8b, 0x29, 0x47, 0x13, 0x12, 0xb6, 0x17, 0xe1, 0x11, 0x0, 0x0, 0x54, + 0x8c, 0x24, 0xca, 0x11, 0x0, 0x0, 0xa, 0x60, 0x2a, 0x7d, 0x3, 0x0, 0x15, 0x53, 0x9a, 0x9d, 0x89, 0x3d, 0x1c, + 0xc4, 0xa9, 0x14, 0x64, 0xbc, 0xd3, 0x77, 0xd8, 0xf1, 0x1a, 0x11, 0x7b, 0x53, 0xbf, 0x3, 0x9, 0x0, 0x17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d6, 0xd}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x2d, 0xfb, 0x1c, 0x33, 0xbc, 0x6b, 0x7c, 0x61, 0x52, + 0x5d, 0x90, 0x19, 0x81, 0x52, 0xc2, 0xe3, 0x4f}; + uint8_t bytesprops1[] = {0x53, 0x9a, 0x9d, 0x89, 0x3d, 0x1c, 0xc4, 0xa9, 0x14, 0x64, 0xbc, + 0xd3, 0x77, 0xd8, 0xf1, 0x1a, 0x11, 0x7b, 0x53, 0xbf, 0x3}; + uint8_t bytesprops2[] = {0x50, 0x1b, 0x95, 0xdf, 0xc9, 0x4d, 0xf4, 0x3c, 0xf, 0xda, 0x9d, 0x3f, + 0x6d, 0x31, 0x3c, 0x98, 0x58, 0x2d, 0xdd, 0xdd, 0x1c, 0xa1, 0x3f}; + uint8_t bytesprops3[] = {0x46, 0xec, 0xc, 0x1c, 0xec, 0xea, 0xa7, 0x73, 0x78, 0x8a, + 0x46, 0xa2, 0xc2, 0x52, 0x58, 0x6f, 0xac, 0x48, 0x7, 0xa5}; + uint8_t bytesprops4[] = {0x69, 0x56, 0x6, 0xca, 0x9f, 0xfe, 0x63, 0xdc, 0xd4, 0xab, + 0x40, 0xd7, 0x86, 0xa8, 0xc2, 0x2e, 0x3f, 0xa7, 0xf4, 0x4}; + uint8_t bytesprops5[] = {0xad, 0xc3, 0x4b, 0x2, 0xb0, 0x9e, 0x0, 0x5d, + 0x19, 0xf3, 0x7a, 0xfb, 0x81, 0x93, 0x5a, 0xc3}; + uint8_t bytesprops6[] = {0x5b, 0x1f, 0x4, 0xf0, 0x7c, 0xf1, 0xea, 0x6a}; + uint8_t bytesprops7[] = {0xaf, 0xc4, 0xa3, 0x5d, 0x85, 0xce, 0x37, 0xd0, 0x71, 0xe4, 0xc2, 0x39, 0x48}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 949}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22333}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31115}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4790}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21644}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2656}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10945}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops7}}}, + }; + + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 25611; + uint8_t client_id_bytes[] = {0x51, 0x30, 0xe6, 0x63, 0x5, 0xc5, 0x78, 0x1d, 0x90, 0x6b, 0xc3, 0xa2}; + lwmqtt_string_t client_id = {12, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x49, 0x62, 0x7a, 0xa1, 0x15, 0x5d, 0x87, 0xbb, 0xf4, 0x50, + 0xc9, 0x6e, 0x80, 0xfe, 0x4c, 0x50, 0x9d, 0xd7, 0x35, 0x20}; + lwmqtt_string_t username = {20, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x11, 0xb3, 0xad, 0xf1, 0x4b, 0x71, 0x87, 0x9d, 0x30, 0xae, + 0x3f, 0xe2, 0xca, 0xb9, 0x3f, 0x0, 0xe1, 0xc9, 0xd6, 0xd}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\211\231\&0\207\223D\193V\147\196\212\176\247\139\172\\\193", _password = Nothing, +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 29750, _connID = "{\160+gG\160\227*\159\208'h\197K\222\&2\tP +// \144\148\149\214l\201", _properties = [PropRequestProblemInformation 82,PropTopicAlias +// 30469,PropPayloadFormatIndicator 16,PropWildcardSubscriptionAvailable 2,PropSessionExpiryInterval +// 29247,PropReceiveMaximum 21019,PropPayloadFormatIndicator 103,PropWildcardSubscriptionAvailable +// 180,PropResponseInformation "\187_\188\240\187\DEL\148\224o1\187\151\161o\206\154hT",PropAuthenticationData +// "\SIF[\230\SOH\158?\\\248",PropAuthenticationData "{\247\132\200M",PropUserProperty +// "\220\245\193\&7\239t\\l;\144D\236\SI\205\239`" +// "M\215\206\150\231{\177v\163\212\178\223\149<\DC3t\250:\160Nk[\216",PropResponseTopic +// "f\152\SYN\\bVz\fEl\172\&5",PropRequestProblemInformation 242,PropPayloadFormatIndicator +// 179,PropMessageExpiryInterval 12926,PropWildcardSubscriptionAvailable 184,PropMaximumPacketSize +// 27860,PropPayloadFormatIndicator 161,PropServerKeepAlive 9236,PropSubscriptionIdentifierAvailable 174,PropContentType +// "\130k\162@\aqL${\206\156&y\159\254_\169\254\131~q\SOH\174x",PropResponseTopic +// "\ETX-y\ETXT\255&!1\142\197\209\199\138\215\132\254$\245",PropResponseInformation "\"\247\"",PropMaximumQoS 8]} +TEST(Connect5QCTest, Encode8) { + uint8_t pkt[] = { + 0x10, 0x83, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x80, 0x74, 0x36, 0xc9, 0x1, 0x17, 0x52, 0x23, 0x77, + 0x5, 0x1, 0x10, 0x28, 0x2, 0x11, 0x0, 0x0, 0x72, 0x3f, 0x21, 0x52, 0x1b, 0x1, 0x67, 0x28, 0xb4, 0x1a, 0x0, + 0x12, 0xbb, 0x5f, 0xbc, 0xf0, 0xbb, 0x7f, 0x94, 0xe0, 0x6f, 0x31, 0xbb, 0x97, 0xa1, 0x6f, 0xce, 0x9a, 0x68, 0x54, + 0x16, 0x0, 0x9, 0xf, 0x46, 0x5b, 0xe6, 0x1, 0x9e, 0x3f, 0x5c, 0xf8, 0x16, 0x0, 0x5, 0x7b, 0xf7, 0x84, 0xc8, + 0x4d, 0x26, 0x0, 0x10, 0xdc, 0xf5, 0xc1, 0x37, 0xef, 0x74, 0x5c, 0x6c, 0x3b, 0x90, 0x44, 0xec, 0xf, 0xcd, 0xef, + 0x60, 0x0, 0x17, 0x4d, 0xd7, 0xce, 0x96, 0xe7, 0x7b, 0xb1, 0x76, 0xa3, 0xd4, 0xb2, 0xdf, 0x95, 0x3c, 0x13, 0x74, + 0xfa, 0x3a, 0xa0, 0x4e, 0x6b, 0x5b, 0xd8, 0x8, 0x0, 0xc, 0x66, 0x98, 0x16, 0x5c, 0x62, 0x56, 0x7a, 0xc, 0x45, + 0x6c, 0xac, 0x35, 0x17, 0xf2, 0x1, 0xb3, 0x2, 0x0, 0x0, 0x32, 0x7e, 0x28, 0xb8, 0x27, 0x0, 0x0, 0x6c, 0xd4, + 0x1, 0xa1, 0x13, 0x24, 0x14, 0x29, 0xae, 0x3, 0x0, 0x18, 0x82, 0x6b, 0xa2, 0x40, 0x7, 0x71, 0x4c, 0x24, 0x7b, + 0xce, 0x9c, 0x26, 0x79, 0x9f, 0xfe, 0x5f, 0xa9, 0xfe, 0x83, 0x7e, 0x71, 0x1, 0xae, 0x78, 0x8, 0x0, 0x13, 0x3, + 0x2d, 0x79, 0x3, 0x54, 0xff, 0x26, 0x21, 0x31, 0x8e, 0xc5, 0xd1, 0xc7, 0x8a, 0xd7, 0x84, 0xfe, 0x24, 0xf5, 0x1a, + 0x0, 0x3, 0x22, 0xf7, 0x22, 0x24, 0x8, 0x0, 0x19, 0x7b, 0xa0, 0x2b, 0x67, 0x47, 0xa0, 0xe3, 0x2a, 0x9f, 0xd0, + 0x27, 0x68, 0xc5, 0x4b, 0xde, 0x32, 0x9, 0x50, 0x20, 0x90, 0x94, 0x95, 0xd6, 0x6c, 0xc9, 0x0, 0x11, 0xd3, 0xe7, + 0x30, 0xcf, 0xdf, 0x44, 0xc1, 0x56, 0x93, 0xc4, 0xd4, 0xb0, 0xf7, 0x8b, 0xac, 0x5c, 0xc1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbb, 0x5f, 0xbc, 0xf0, 0xbb, 0x7f, 0x94, 0xe0, 0x6f, + 0x31, 0xbb, 0x97, 0xa1, 0x6f, 0xce, 0x9a, 0x68, 0x54}; + uint8_t bytesprops1[] = {0xf, 0x46, 0x5b, 0xe6, 0x1, 0x9e, 0x3f, 0x5c, 0xf8}; + uint8_t bytesprops2[] = {0x7b, 0xf7, 0x84, 0xc8, 0x4d}; + uint8_t bytesprops4[] = {0x4d, 0xd7, 0xce, 0x96, 0xe7, 0x7b, 0xb1, 0x76, 0xa3, 0xd4, 0xb2, 0xdf, + 0x95, 0x3c, 0x13, 0x74, 0xfa, 0x3a, 0xa0, 0x4e, 0x6b, 0x5b, 0xd8}; + uint8_t bytesprops3[] = {0xdc, 0xf5, 0xc1, 0x37, 0xef, 0x74, 0x5c, 0x6c, + 0x3b, 0x90, 0x44, 0xec, 0xf, 0xcd, 0xef, 0x60}; + uint8_t bytesprops5[] = {0x66, 0x98, 0x16, 0x5c, 0x62, 0x56, 0x7a, 0xc, 0x45, 0x6c, 0xac, 0x35}; + uint8_t bytesprops6[] = {0x82, 0x6b, 0xa2, 0x40, 0x7, 0x71, 0x4c, 0x24, 0x7b, 0xce, 0x9c, 0x26, + 0x79, 0x9f, 0xfe, 0x5f, 0xa9, 0xfe, 0x83, 0x7e, 0x71, 0x1, 0xae, 0x78}; + uint8_t bytesprops7[] = {0x3, 0x2d, 0x79, 0x3, 0x54, 0xff, 0x26, 0x21, 0x31, 0x8e, + 0xc5, 0xd1, 0xc7, 0x8a, 0xd7, 0x84, 0xfe, 0x24, 0xf5}; + uint8_t bytesprops8[] = {0x22, 0xf7, 0x22}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30469}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29247}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21019}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops3}, .v = {23, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12926}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27860}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9236}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, + }; + + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 29750; + uint8_t client_id_bytes[] = {0x7b, 0xa0, 0x2b, 0x67, 0x47, 0xa0, 0xe3, 0x2a, 0x9f, 0xd0, 0x27, 0x68, 0xc5, + 0x4b, 0xde, 0x32, 0x9, 0x50, 0x20, 0x90, 0x94, 0x95, 0xd6, 0x6c, 0xc9}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xd3, 0xe7, 0x30, 0xcf, 0xdf, 0x44, 0xc1, 0x56, 0x93, + 0xc4, 0xd4, 0xb0, 0xf7, 0x8b, 0xac, 0x5c, 0xc1}; + lwmqtt_string_t username = {17, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "?\212\154\234\129\129", _password = Just "p~)\DELVv\232\EOT,\SUB\142a\223", +// _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\182\210\210\208\161*\ng>\174\214\175\228\181\167\162I=\146!", _willMsg = "2\138c9\234`\186@\186E\164\&9+", +// _willProps = [PropMaximumPacketSize 25044,PropMaximumQoS 93,PropSubscriptionIdentifierAvailable 130,PropUserProperty +// "\230\188\156\182\145\220mb\fpl\178<\194\&1Hm\132\181?\166|\ACKg\137\&8x\EOT" "\155\&96k",PropResponseTopic +// "\158\239\253j\168\ENQV>\133<\189",PropWildcardSubscriptionAvailable 150,PropSubscriptionIdentifier +// 14,PropCorrelationData "\240\129\155u\164\216\161\178/C",PropSharedSubscriptionAvailable 161,PropServerReference +// "\134*:\200,\219s\EM\253F\255\209.\229\227",PropRequestResponseInformation 96,PropPayloadFormatIndicator +// 45,PropRequestProblemInformation 133,PropRetainAvailable 164,PropServerReference +// "V?rv\237\150\169F\191|\a\162\ENQ\211\193\&4\239\&1\231>",PropRequestResponseInformation +// 227,PropSubscriptionIdentifier 18]}), _cleanSession = False, _keepAlive = 19395, _connID = +// "\149n\238G\238\237)\201\164\252\154Z`O\144Gm\245xzg\DC3P", _properties = [PropSubscriptionIdentifierAvailable +// 150,PropAuthenticationMethod +// "|\ESC\221\172\ESC\171\190\216\190d\154\148i\216\&1\225\&9\211r\185;\FS\fy",PropWildcardSubscriptionAvailable +// 151,PropPayloadFormatIndicator 78,PropAuthenticationMethod "",PropTopicAlias 3919,PropUserProperty +// "\ETB\211\SUBY\224\&1\146\189/\159\ESC" "\245m\175\226\nn\225\164\172(u\r3\152\223\b\227\174Q",PropMaximumQoS +// 237,PropTopicAlias 1648,PropReceiveMaximum 8601,PropAuthenticationData "D\138}\191\133{",PropSessionExpiryInterval +// 12319,PropWildcardSubscriptionAvailable 99,PropReasonString +// "h\231\NULS\DEL6F1?\156`No\ACK$~\191\v\180-KQ\128\228.\171*",PropMaximumPacketSize 16400,PropMessageExpiryInterval +// 3583,PropResponseTopic +// "\205_\ENQ]\130\234_\128\RS\176\235\216\247M\211\234u\aC\161\163\190k\184h",PropServerReference +// "a\167Y4\r\211\196}\236\DELO\156",PropWildcardSubscriptionAvailable 14]} +TEST(Connect5QCTest, Encode9) { + uint8_t pkt[] = { + 0x10, 0x9e, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x4b, 0xc3, 0xb7, 0x1, 0x29, 0x96, 0x15, 0x0, + 0x18, 0x7c, 0x1b, 0xdd, 0xac, 0x1b, 0xab, 0xbe, 0xd8, 0xbe, 0x64, 0x9a, 0x94, 0x69, 0xd8, 0x31, 0xe1, 0x39, 0xd3, + 0x72, 0xb9, 0x3b, 0x1c, 0xc, 0x79, 0x28, 0x97, 0x1, 0x4e, 0x15, 0x0, 0x0, 0x23, 0xf, 0x4f, 0x26, 0x0, 0xb, + 0x17, 0xd3, 0x1a, 0x59, 0xe0, 0x31, 0x92, 0xbd, 0x2f, 0x9f, 0x1b, 0x0, 0x13, 0xf5, 0x6d, 0xaf, 0xe2, 0xa, 0x6e, + 0xe1, 0xa4, 0xac, 0x28, 0x75, 0xd, 0x33, 0x98, 0xdf, 0x8, 0xe3, 0xae, 0x51, 0x24, 0xed, 0x23, 0x6, 0x70, 0x21, + 0x21, 0x99, 0x16, 0x0, 0x6, 0x44, 0x8a, 0x7d, 0xbf, 0x85, 0x7b, 0x11, 0x0, 0x0, 0x30, 0x1f, 0x28, 0x63, 0x1f, + 0x0, 0x1b, 0x68, 0xe7, 0x0, 0x53, 0x7f, 0x36, 0x46, 0x31, 0x3f, 0x9c, 0x60, 0x4e, 0x6f, 0x6, 0x24, 0x7e, 0xbf, + 0xb, 0xb4, 0x2d, 0x4b, 0x51, 0x80, 0xe4, 0x2e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 0x85, 0x25, 0xa4, 0x1c, 0x0, 0x14, 0x56, 0x3f, 0x72, 0x76, 0xed, 0x96, 0xa9, 0x46, 0xbf, + 0x7c, 0x7, 0xa2, 0x5, 0xd3, 0xc1, 0x34, 0xef, 0x31, 0xe7, 0x3e, 0x19, 0xe3, 0xb, 0x12, 0x0, 0x14, 0xb6, 0xd2, + 0xd2, 0xd0, 0xa1, 0x2a, 0xa, 0x67, 0x3e, 0xae, 0xd6, 0xaf, 0xe4, 0xb5, 0xa7, 0xa2, 0x49, 0x3d, 0x92, 0x21, 0x0, + 0xd, 0x32, 0x8a, 0x63, 0x39, 0xea, 0x60, 0xba, 0x40, 0xba, 0x45, 0xa4, 0x39, 0x2b, 0x0, 0x6, 0x3f, 0xd4, 0x9a, + 0xea, 0x81, 0x81, 0x0, 0xd, 0x70, 0x7e, 0x29, 0x7f, 0x56, 0x76, 0xe8, 0x4, 0x2c, 0x1a, 0x8e, 0x61, 0xdf}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7c, 0x1b, 0xdd, 0xac, 0x1b, 0xab, 0xbe, 0xd8, 0xbe, 0x64, 0x9a, 0x94, + 0x69, 0xd8, 0x31, 0xe1, 0x39, 0xd3, 0x72, 0xb9, 0x3b, 0x1c, 0xc, 0x79}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops3[] = {0xf5, 0x6d, 0xaf, 0xe2, 0xa, 0x6e, 0xe1, 0xa4, 0xac, 0x28, + 0x75, 0xd, 0x33, 0x98, 0xdf, 0x8, 0xe3, 0xae, 0x51}; + uint8_t bytesprops2[] = {0x17, 0xd3, 0x1a, 0x59, 0xe0, 0x31, 0x92, 0xbd, 0x2f, 0x9f, 0x1b}; + uint8_t bytesprops4[] = {0x44, 0x8a, 0x7d, 0xbf, 0x85, 0x7b}; + uint8_t bytesprops5[] = {0x68, 0xe7, 0x0, 0x53, 0x7f, 0x36, 0x46, 0x31, 0x3f, 0x9c, 0x60, 0x4e, 0x6f, 0x6, + 0x24, 0x7e, 0xbf, 0xb, 0xb4, 0x2d, 0x4b, 0x51, 0x80, 0xe4, 0x2e, 0xab, 0x2a}; + uint8_t bytesprops6[] = {0xcd, 0x5f, 0x5, 0x5d, 0x82, 0xea, 0x5f, 0x80, 0x1e, 0xb0, 0xeb, 0xd8, 0xf7, + 0x4d, 0xd3, 0xea, 0x75, 0x7, 0x43, 0xa1, 0xa3, 0xbe, 0x6b, 0xb8, 0x68}; + uint8_t bytesprops7[] = {0x61, 0xa7, 0x59, 0x34, 0xd, 0xd3, 0xc4, 0x7d, 0xec, 0x7f, 0x4f, 0x9c}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3919}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops2}, .v = {19, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1648}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8601}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12319}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16400}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3583}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 14}}, + }; + + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x9b, 0x39, 0x36, 0x6b}; + uint8_t byteswillprops0[] = {0xe6, 0xbc, 0x9c, 0xb6, 0x91, 0xdc, 0x6d, 0x62, 0xc, 0x70, 0x6c, 0xb2, 0x3c, 0xc2, + 0x31, 0x48, 0x6d, 0x84, 0xb5, 0x3f, 0xa6, 0x7c, 0x6, 0x67, 0x89, 0x38, 0x78, 0x4}; + uint8_t byteswillprops2[] = {0x9e, 0xef, 0xfd, 0x6a, 0xa8, 0x5, 0x56, 0x3e, 0x85, 0x3c, 0xbd}; + uint8_t byteswillprops3[] = {0xf0, 0x81, 0x9b, 0x75, 0xa4, 0xd8, 0xa1, 0xb2, 0x2f, 0x43}; + uint8_t byteswillprops4[] = {0x86, 0x2a, 0x3a, 0xc8, 0x2c, 0xdb, 0x73, 0x19, + 0xfd, 0x46, 0xff, 0xd1, 0x2e, 0xe5, 0xe3}; + uint8_t byteswillprops5[] = {0x56, 0x3f, 0x72, 0x76, 0xed, 0x96, 0xa9, 0x46, 0xbf, 0x7c, + 0x7, 0xa2, 0x5, 0xd3, 0xc1, 0x34, 0xef, 0x31, 0xe7, 0x3e}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25044}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {28, (char*)&byteswillprops0}, .v = {4, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + }; + + lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb6, 0xd2, 0xd2, 0xd0, 0xa1, 0x2a, 0xa, 0x67, 0x3e, 0xae, + 0xd6, 0xaf, 0xe4, 0xb5, 0xa7, 0xa2, 0x49, 0x3d, 0x92, 0x21}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x32, 0x8a, 0x63, 0x39, 0xea, 0x60, 0xba, 0x40, 0xba, 0x45, 0xa4, 0x39, 0x2b}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 19395; + uint8_t client_id_bytes[] = {0x95, 0x6e, 0xee, 0x47, 0xee, 0xed, 0x29, 0xc9, 0xa4, 0xfc, 0x9a, 0x5a, + 0x60, 0x4f, 0x90, 0x47, 0x6d, 0xf5, 0x78, 0x7a, 0x67, 0x13, 0x50}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x3f, 0xd4, 0x9a, 0xea, 0x81, 0x81}; + lwmqtt_string_t username = {6, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x70, 0x7e, 0x29, 0x7f, 0x56, 0x76, 0xe8, 0x4, 0x2c, 0x1a, 0x8e, 0x61, 0xdf}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\150\213\175\169yq`\DC3\185\158\240\US\228H\158\158\192\153", _password = Just +// "\206c\DC1\187", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "'gY\b\203\149\DC3\206\CAN<\CAN\177\205$a\160\135", _willMsg = +// "\162<\STX\222\185\208\196\140\169\175\155\150\NAK\216\r\145\194\173\159\210/\222\f\180\NAK=", _willProps = +// [PropReceiveMaximum 726,PropMessageExpiryInterval 30408,PropSharedSubscriptionAvailable 87,PropResponseTopic +// "\165\"x\149\130\196\231N\234\222\180]'\RS\241\"K\189\239\213",PropResponseInformation +// "G{($\238\&3\184\135w\r\245\215\237\131\157\ENQ'\140\SYN",PropResponseTopic +// "\160\163\192Sx\193\234\220\164\FS\161\163.\192U\182#=RA",PropSubscriptionIdentifier 7,PropRequestProblemInformation +// 165,PropReceiveMaximum 10578,PropSubscriptionIdentifier 2,PropTopicAliasMaximum 7623,PropSharedSubscriptionAvailable +// 28,PropRequestProblemInformation 169,PropWillDelayInterval 32532,PropAuthenticationData +// "\218\a\152\197)" +// "\202^\229G\149\166\NUL=\186\179\201\216,\185\231\154;\FS\228\241\&8\215M\133",PropAssignedClientIdentifier +// "\153\238_dL}\251\226r\191\145\240>",PropReceiveMaximum 11564,PropResponseInformation +// "\138{\ESC\137A|\240_,H1\202F\243",PropSharedSubscriptionAvailable 196,PropResponseTopic +// "-6p\190\&3\160`\186\247jK,R{-\203\146",PropAuthenticationMethod +// "\251\168\249n\"\STXu\NAK\167!\184h-\255F\170s",PropRequestProblemInformation 50,PropWillDelayInterval +// 8644,PropContentType "9\147]\133s\f2)\EM\168\&5\166\DELNl\242\t\145\&6+\182\223",PropServerKeepAlive +// 28557,PropTopicAlias 12014,PropRetainAvailable 73,PropResponseInformation "6\a\CAN0\EOT.\170\DC1P"]} +TEST(Connect5QCTest, Encode10) { + uint8_t pkt[] = { + 0x10, 0xe7, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x14, 0xf6, 0xcd, 0x2, 0x27, 0x0, 0x0, 0x18, + 0xf8, 0x2, 0x0, 0x0, 0x2a, 0x77, 0x21, 0x47, 0x65, 0x28, 0x1c, 0x17, 0xdd, 0x12, 0x0, 0x18, 0xb1, 0x35, 0x5d, + 0x3b, 0xd7, 0xbf, 0xba, 0x43, 0x59, 0xb8, 0x2b, 0xa7, 0xf2, 0x10, 0x85, 0xbe, 0x6e, 0xe1, 0x22, 0xc5, 0xdb, 0xe, + 0xd9, 0xa3, 0x23, 0xb, 0x76, 0x1c, 0x0, 0x9, 0xdd, 0x32, 0x7f, 0xec, 0x99, 0x15, 0xa1, 0xac, 0x43, 0x1c, 0x0, + 0xc, 0x19, 0x23, 0x33, 0xca, 0x27, 0xf, 0x4, 0xb1, 0xd7, 0xd3, 0xe1, 0x1c, 0x8, 0x0, 0x14, 0xd, 0x4d, 0x42, + 0xe7, 0x83, 0x37, 0x57, 0xbb, 0xbd, 0x36, 0x2b, 0x36, 0xf5, 0xd6, 0x73, 0x7, 0xb4, 0x81, 0xba, 0x91, 0x1a, 0x0, + 0x1d, 0x76, 0xa1, 0x8e, 0x24, 0x81, 0xb5, 0xc9, 0x9d, 0x87, 0xc, 0x8, 0x8b, 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, 0xfb, 0xe3, 0x43, 0xcd, 0x4, 0x73, 0xda, 0xac, 0x21, 0x7f, 0xf4, 0x7d, + 0x56, 0xba, 0x47, 0x2c, 0xe5, 0x3d, 0x48, 0x15, 0x0, 0x0, 0x13, 0x4f, 0x1, 0x1f, 0x0, 0xd, 0x1e, 0x33, 0xcd, + 0xaf, 0xd7, 0x2d, 0x4a, 0xda, 0xfe, 0x56, 0x2c, 0xeb, 0xbd, 0x13, 0x59, 0xdc, 0x0, 0x11, 0x27, 0x67, 0x59, 0x8, + 0xcb, 0x95, 0x13, 0xce, 0x18, 0x3c, 0x18, 0xb1, 0xcd, 0x24, 0x61, 0xa0, 0x87, 0x0, 0x1a, 0xa2, 0x3c, 0x2, 0xde, + 0xb9, 0xd0, 0xc4, 0x8c, 0xa9, 0xaf, 0x9b, 0x96, 0x15, 0xd8, 0xd, 0x91, 0xc2, 0xad, 0x9f, 0xd2, 0x2f, 0xde, 0xc, + 0xb4, 0x15, 0x3d, 0x0, 0x12, 0x96, 0xd5, 0xaf, 0xa9, 0x79, 0x71, 0x60, 0x13, 0xb9, 0x9e, 0xf0, 0x1f, 0xe4, 0x48, + 0x9e, 0x9e, 0xc0, 0x99, 0x0, 0x4, 0xce, 0x63, 0x11, 0xbb}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb1, 0x35, 0x5d, 0x3b, 0xd7, 0xbf, 0xba, 0x43, 0x59, 0xb8, 0x2b, 0xa7, + 0xf2, 0x10, 0x85, 0xbe, 0x6e, 0xe1, 0x22, 0xc5, 0xdb, 0xe, 0xd9, 0xa3}; + uint8_t bytesprops1[] = {0xdd, 0x32, 0x7f, 0xec, 0x99, 0x15, 0xa1, 0xac, 0x43}; + uint8_t bytesprops2[] = {0x19, 0x23, 0x33, 0xca, 0x27, 0xf, 0x4, 0xb1, 0xd7, 0xd3, 0xe1, 0x1c}; + uint8_t bytesprops3[] = {0xd, 0x4d, 0x42, 0xe7, 0x83, 0x37, 0x57, 0xbb, 0xbd, 0x36, + 0x2b, 0x36, 0xf5, 0xd6, 0x73, 0x7, 0xb4, 0x81, 0xba, 0x91}; + uint8_t bytesprops4[] = {0x76, 0xa1, 0x8e, 0x24, 0x81, 0xb5, 0xc9, 0x9d, 0x87, 0xc, 0x8, 0x8b, 0x46, 0x4, 0x4d, + 0x41, 0x27, 0xae, 0x29, 0x55, 0xb4, 0x1a, 0x81, 0xd9, 0xd9, 0x71, 0xc0, 0x4, 0x4b}; + uint8_t bytesprops5[] = {0x76, 0xea, 0xe8, 0x6c}; + uint8_t bytesprops6[] = {0x61, 0x49, 0xbb, 0xb8, 0x75, 0xf4, 0xd7, 0x77, 0x17, 0xd8, 0xbc, 0x55, 0x21, 0x19, 0xb7}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops9[] = {0xca, 0x5e, 0xe5, 0x47, 0x95, 0xa6, 0x0, 0x3d, 0xba, 0xb3, 0xc9, 0xd8, + 0x2c, 0xb9, 0xe7, 0x9a, 0x3b, 0x1c, 0xe4, 0xf1, 0x38, 0xd7, 0x4d, 0x85}; + uint8_t bytesprops8[] = {0x0, 0xe3, 0xbe, 0xbf, 0x8c, 0xc0, 0x56, 0xed, 0x4a, 0x6d, 0x3e, 0x7, 0x98, 0xc5, 0x29}; + uint8_t bytesprops10[] = {0x99, 0xee, 0x5f, 0x64, 0x4c, 0x7d, 0xfb, 0xe2, 0x72, 0xbf, 0x91, 0xf0, 0x3e}; + uint8_t bytesprops11[] = {0x8a, 0x7b, 0x1b, 0x89, 0x41, 0x7c, 0xf0, 0x5f, 0x2c, 0x48, 0x31, 0xca, 0x46, 0xf3}; + uint8_t bytesprops12[] = {0x2d, 0x36, 0x70, 0xbe, 0x33, 0xa0, 0x60, 0xba, 0xf7, + 0x6a, 0x4b, 0x2c, 0x52, 0x7b, 0x2d, 0xcb, 0x92}; + uint8_t bytesprops13[] = {0xfb, 0xa8, 0xf9, 0x6e, 0x22, 0x2, 0x75, 0x15, 0xa7, + 0x21, 0xb8, 0x68, 0x2d, 0xff, 0x46, 0xaa, 0x73}; + uint8_t bytesprops14[] = {0x39, 0x93, 0x5d, 0x85, 0x73, 0xc, 0x32, 0x29, 0x19, 0xa8, 0x35, + 0xa6, 0x7f, 0x4e, 0x6c, 0xf2, 0x9, 0x91, 0x36, 0x2b, 0xb6, 0xdf}; + uint8_t bytesprops15[] = {0x36, 0x7, 0x18, 0x30, 0x4, 0x2e, 0xaa, 0x11, 0x50}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6392}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10871}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18277}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 221}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2934}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops8}, .v = {24, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11564}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8644}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28557}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12014}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops15}}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xa5, 0x22, 0x78, 0x95, 0x82, 0xc4, 0xe7, 0x4e, 0xea, 0xde, + 0xb4, 0x5d, 0x27, 0x1e, 0xf1, 0x22, 0x4b, 0xbd, 0xef, 0xd5}; + uint8_t byteswillprops1[] = {0x47, 0x7b, 0x28, 0x24, 0xee, 0x33, 0xb8, 0x87, 0x77, 0xd, + 0xf5, 0xd7, 0xed, 0x83, 0x9d, 0x5, 0x27, 0x8c, 0x16}; + uint8_t byteswillprops2[] = {0xa0, 0xa3, 0xc0, 0x53, 0x78, 0xc1, 0xea, 0xdc, 0xa4, 0x1c, + 0xa1, 0xa3, 0x2e, 0xc0, 0x55, 0xb6, 0x23, 0x3d, 0x52, 0x41}; + uint8_t byteswillprops3[] = {0xda, 0x3c, 0x4e, 0x64, 0xee, 0x68, 0xcd, 0x9c, 0x21, 0x24, 0x5d, 0xdc}; + uint8_t byteswillprops4[] = {0x28, 0x8f, 0x62, 0x85, 0x2f, 0x3f, 0xc1, 0x56, 0xa1, 0xfb, 0xe3, 0x43, 0xcd, 0x4, + 0x73, 0xda, 0xac, 0x21, 0x7f, 0xf4, 0x7d, 0x56, 0xba, 0x47, 0x2c, 0xe5, 0x3d, 0x48}; + uint8_t byteswillprops5[] = {0}; + uint8_t byteswillprops6[] = {0x1e, 0x33, 0xcd, 0xaf, 0xd7, 0x2d, 0x4a, 0xda, 0xfe, 0x56, 0x2c, 0xeb, 0xbd}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 726}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30408}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10578}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7623}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32532}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12084}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22979}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28253}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14469}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20225}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23004}}, + }; + + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x27, 0x67, 0x59, 0x8, 0xcb, 0x95, 0x13, 0xce, 0x18, + 0x3c, 0x18, 0xb1, 0xcd, 0x24, 0x61, 0xa0, 0x87}; + lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa2, 0x3c, 0x2, 0xde, 0xb9, 0xd0, 0xc4, 0x8c, 0xa9, 0xaf, 0x9b, 0x96, 0x15, + 0xd8, 0xd, 0x91, 0xc2, 0xad, 0x9f, 0xd2, 0x2f, 0xde, 0xc, 0xb4, 0x15, 0x3d}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 5366; + uint8_t client_id_bytes[] = {0xe6, 0xd1, 0x24, 0x66, 0xca, 0xee, 0xe3}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x96, 0xd5, 0xaf, 0xa9, 0x79, 0x71, 0x60, 0x13, 0xb9, + 0x9e, 0xf0, 0x1f, 0xe4, 0x48, 0x9e, 0x9e, 0xc0, 0x99}; + lwmqtt_string_t username = {18, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xce, 0x63, 0x11, 0xbb}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\129\128\161\159\147\245-e\bJ_\149 \184p.t,\236Q\211\160XD\SUB\239\DEL\DC2\144", +// _password = Just "\240\244", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\135\ETXg\SIO\185\150d\172+QZ", _willMsg = "\232\GS\202P\180x\186\243}<\155\148:\217\145'", _willProps = +// [PropResponseInformation "\156\196\210\158\219\156+'\RS\190\199yd\"\NAK",PropMessageExpiryInterval +// 23010,PropAssignedClientIdentifier "\DEL\231K\158\NUL\FS",PropSubscriptionIdentifier 24,PropAuthenticationData +// "W\EOT\GS\192l",PropRequestProblemInformation 26,PropSubscriptionIdentifierAvailable 196,PropSubscriptionIdentifier +// 7,PropMaximumQoS 107,PropReceiveMaximum 6946,PropSubscriptionIdentifierAvailable +// 74,PropSubscriptionIdentifierAvailable 84,PropRetainAvailable 210,PropRetainAvailable 227,PropCorrelationData +// "4T\235",PropTopicAlias 2606,PropContentType +// "\196_\RSz\218\DC2\129\240\142\SI;\178\128\214\n2Xa\255\152",PropReasonString +// "\188\SO\EOT\153\ETBi\251",PropCorrelationData "\ACK\151j",PropServerKeepAlive 32148,PropResponseTopic +// "\233\244(",PropUserProperty "\144\&4\SOH\DC4\211\148\238p" "\208\142\165],=\178\246",PropSubscriptionIdentifier +// 7,PropAuthenticationData "\213\&3\164\208JRg\195yY\201\186U\DC4w2*\230a\140\194K%\CAN\198\136",PropMaximumPacketSize +// 9903,PropReceiveMaximum 8076,PropRetainAvailable 52]}), _cleanSession = True, _keepAlive = 30463, _connID = +// "\171v+\163\172\203\229S\191\242VUR\b\DLE\179J\234", _properties = [PropSharedSubscriptionAvailable +// 231,PropServerKeepAlive 30540,PropWillDelayInterval 5194,PropWillDelayInterval 15709,PropAuthenticationData +// "\247\&5\f\212\162\r\198\148\245A\191u\188pHR",PropRequestProblemInformation 159,PropAuthenticationData +// "\145<\GSaD\195",PropSharedSubscriptionAvailable 185,PropReasonString +// "!\183\142\222L[8\141\DC1\184c\163\tMb\173\DC3}\133\250\189\183",PropCorrelationData +// "\173\144\163\ENQ%V\221\viP",PropCorrelationData "\251\189\NUL\175\199R\rL\226IT\205",PropPayloadFormatIndicator +// 251,PropSharedSubscriptionAvailable 19,PropAssignedClientIdentifier +// "\221\175\203/ii\241\176\164E\US\196#\180\201A-=q8\242\230f\v`",PropResponseInformation +// "v9m5@\235\192\204\202\246\249\132\238\155Er\234\213]\163\212\151\ENQJ",PropTopicAlias 4538,PropUserProperty "K" +// "NF\225SC\170)\240\174\143\DC4\219\176L.\201\249\238?\227",PropResponseTopic +// "\NUL\169(3\131\&4.\135\&1L\189\191%Y\144\175\196\DLE\ETB\251\223'^[F\238-\172R",PropPayloadFormatIndicator +// 243,PropRetainAvailable 64,PropSharedSubscriptionAvailable 101,PropRequestResponseInformation 30]} +TEST(Connect5QCTest, Encode13) { + uint8_t pkt[] = {0x10, 0xd6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x44, 0x27, 0x44, 0x7a, 0x1c, 0x0, 0x2, + 0x4b, 0x49, 0x12, 0x0, 0x8, 0xe1, 0xf2, 0x37, 0x2f, 0x3f, 0xf0, 0xd5, 0xe8, 0x1f, 0x0, 0x9, 0x28, + 0xc, 0x16, 0xea, 0xc7, 0x8a, 0x89, 0xf4, 0x4a, 0x15, 0x0, 0xd, 0xbf, 0x30, 0x67, 0xd4, 0xb8, 0xfd, + 0x1, 0xa9, 0x8e, 0x69, 0xf5, 0x27, 0x89, 0x1f, 0x0, 0x6, 0x3e, 0xa3, 0xd4, 0x97, 0x5, 0x4a, 0x23, + 0x11, 0xba, 0x26, 0x0, 0x1, 0x4b, 0x0, 0x14, 0x4e, 0x46, 0xe1, 0x53, 0x43, 0xaa, 0x29, 0xf0, 0xae, + 0x8f, 0x14, 0xdb, 0xb0, 0x4c, 0x2e, 0xc9, 0xf9, 0xee, 0x3f, 0xe3, 0x8, 0x0, 0x1d, 0x0, 0xa9, 0x28, + 0x33, 0x83, 0x34, 0x2e, 0x87, 0x31, 0x4c, 0xbd, 0xbf, 0x25, 0x59, 0x90, 0xaf, 0xc4, 0x10, 0x17, 0xfb, + 0xdf, 0x27, 0x5e, 0x5b, 0x46, 0xee, 0x2d, 0xac, 0x52, 0x1, 0xf3, 0x25, 0x40, 0x2a, 0x65, 0x19, 0x1e, + 0x0, 0x14, 0x5, 0x42, 0xcf, 0x45, 0xbd, 0xc7, 0x46, 0x45, 0xc4, 0xf5, 0x6, 0x87, 0xc8, 0x4e, 0xa, + 0xbb, 0xb1, 0xd1, 0x80, 0xab, 0x7, 0x24, 0xa7, 0x27, 0x0, 0x0, 0x2f, 0xd2, 0x0, 0x7, 0x13, 0xd6, + 0x49, 0x19, 0xe9, 0x42, 0x8, 0x0, 0x13, 0x69, 0x54, 0xd, 0x6f, 0x66, 0x2f, 0xf9, 0x7e, 0x34, 0x5a, + 0x28, 0x3c, 0x5b, 0x69, 0x4e, 0xa8, 0x40, 0x21, 0x67, 0x0, 0x13, 0x1e, 0x54, 0xd2, 0x90, 0xb, 0x52, + 0x98, 0xd, 0x90, 0x73, 0x48, 0x8c, 0x53, 0xd8, 0x58, 0xfc, 0x44, 0xe8, 0x9c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x4b, 0x49}; + uint8_t bytesprops1[] = {0xe1, 0xf2, 0x37, 0x2f, 0x3f, 0xf0, 0xd5, 0xe8}; + uint8_t bytesprops2[] = {0x28, 0xc, 0x16, 0xea, 0xc7, 0x8a, 0x89, 0xf4, 0x4a}; + uint8_t bytesprops3[] = {0xbf, 0x30, 0x67, 0xd4, 0xb8, 0xfd, 0x1, 0xa9, 0x8e, 0x69, 0xf5, 0x27, 0x89}; + uint8_t bytesprops4[] = {0x3e, 0xa3, 0xd4, 0x97, 0x5, 0x4a}; + uint8_t bytesprops6[] = {0x4e, 0x46, 0xe1, 0x53, 0x43, 0xaa, 0x29, 0xf0, 0xae, 0x8f, + 0x14, 0xdb, 0xb0, 0x4c, 0x2e, 0xc9, 0xf9, 0xee, 0x3f, 0xe3}; + uint8_t bytesprops5[] = {0x4b}; + uint8_t bytesprops7[] = {0x0, 0xa9, 0x28, 0x33, 0x83, 0x34, 0x2e, 0x87, 0x31, 0x4c, 0xbd, 0xbf, 0x25, 0x59, 0x90, + 0xaf, 0xc4, 0x10, 0x17, 0xfb, 0xdf, 0x27, 0x5e, 0x5b, 0x46, 0xee, 0x2d, 0xac, 0x52}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4538}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops5}, .v = {20, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 30}}, + }; + + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12242}}, + }; + + lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x13, 0xd6, 0x49, 0x19, 0xe9, 0x42, 0x8}; + lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x69, 0x54, 0xd, 0x6f, 0x66, 0x2f, 0xf9, 0x7e, 0x34, 0x5a, + 0x28, 0x3c, 0x5b, 0x69, 0x4e, 0xa8, 0x40, 0x21, 0x67}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 10052; + uint8_t client_id_bytes[] = {0x5, 0x42, 0xcf, 0x45, 0xbd, 0xc7, 0x46, 0x45, 0xc4, 0xf5, + 0x6, 0x87, 0xc8, 0x4e, 0xa, 0xbb, 0xb1, 0xd1, 0x80, 0xab}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x1e, 0x54, 0xd2, 0x90, 0xb, 0x52, 0x98, 0xd, 0x90, 0x73, + 0x48, 0x8c, 0x53, 0xd8, 0x58, 0xfc, 0x44, 0xe8, 0x9c}; + lwmqtt_string_t password = {19, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "jp\210\SYN<%F\215\168\207J\225\152z\151X\253\132\"", _password = Nothing, _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\181J\251\141\ETX", _willMsg = "|\ETB", +// _willProps = [PropMaximumPacketSize 28427,PropUserProperty "#H'\FS\151\161\162\DC2!\DEL$" +// "\249\225yW\183<\204(\CAN\ESC\253\DC2",PropWildcardSubscriptionAvailable 72,PropSessionExpiryInterval +// 30643,PropMaximumPacketSize 19796,PropMaximumPacketSize 29954,PropReceiveMaximum 12271,PropMaximumQoS +// 96,PropReceiveMaximum 15941,PropRequestResponseInformation 113,PropMaximumQoS 138,PropServerReference +// "\213\133\146\239\133\193N\177\249\133\200\243\158\&7\205\187\215\129\"",PropWildcardSubscriptionAvailable +// 169,PropRequestResponseInformation 145,PropContentType +// "\233\134\&6\163\140#/?\161G\b\SOwA\245\186\169\DLE\194\142c\135\161\193\233s\207{R\255",PropSharedSubscriptionAvailable +// 26,PropAssignedClientIdentifier +// "\ACK\ETB!\218a\ENQH\157\192\244\210\178\203\146\212\225\138\&9d\152\253\220\SO\156}\209\159",PropSharedSubscriptionAvailable +// 67,PropPayloadFormatIndicator 111,PropAuthenticationData "\207\234E!\209[\157 +// \"\130K\182\219\215\224\twg\242\229u\149\r\CAN\215J\137\170\188",PropMessageExpiryInterval 27923]}), _cleanSession = +// True, _keepAlive = 2920, _connID = "\203M+\171|\132nj\193\FS\a\\\DC1\230\202\DC2Id;\200", _properties = +// [PropResponseTopic "\152\r_\209\243\142\DC1\147\195\155i~\221]\130\160\156\ETXq\226",PropServerReference +// "@\164\241\EM\US1\250\SI",PropSubscriptionIdentifierAvailable 109,PropAuthenticationMethod +// "\173\138",PropWillDelayInterval 11874,PropSubscriptionIdentifierAvailable 154,PropSubscriptionIdentifierAvailable +// 219,PropServerKeepAlive 11283,PropMaximumQoS 158,PropReasonString +// "&\232\254\190z\234t\EOT\251G\219\232\160Ed",PropServerReference +// "\n\226\nR!\198\234\227\166\130",PropMessageExpiryInterval 2976,PropMessageExpiryInterval 30462,PropServerReference +// "\232\215\237\161\140\"\208a:\DC4g\174\253\217\172e\179\176\v",PropWildcardSubscriptionAvailable 187,PropMaximumQoS +// 52,PropReceiveMaximum 10715,PropAuthenticationMethod "?\194\132\SI\225\203\189\164\220x\229\183@\DC3\ETX +// \a\DELn\159\190\232S\v",PropTopicAlias 23900,PropMaximumPacketSize 1537,PropAuthenticationData +// "\NUL",PropMessageExpiryInterval 8705,PropMaximumPacketSize 19667,PropMessageExpiryInterval +// 2344,PropRequestResponseInformation 137,PropContentType +// "\195\201\&8\174\144\203\146\136^\DLE:n\USN\199\160\&4\ESC:,v4e\161\ETB",PropTopicAliasMaximum 18306]} +TEST(Connect5QCTest, Encode14) { + uint8_t pkt[] = { + 0x10, 0xda, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0xb, 0x68, 0xd4, 0x1, 0x8, 0x0, 0x14, 0x98, + 0xd, 0x5f, 0xd1, 0xf3, 0x8e, 0x11, 0x93, 0xc3, 0x9b, 0x69, 0x7e, 0xdd, 0x5d, 0x82, 0xa0, 0x9c, 0x3, 0x71, 0xe2, + 0x1c, 0x0, 0x8, 0x40, 0xa4, 0xf1, 0x19, 0x1f, 0x31, 0xfa, 0xf, 0x29, 0x6d, 0x15, 0x0, 0x2, 0xad, 0x8a, 0x18, + 0x0, 0x0, 0x2e, 0x62, 0x29, 0x9a, 0x29, 0xdb, 0x13, 0x2c, 0x13, 0x24, 0x9e, 0x1f, 0x0, 0xf, 0x26, 0xe8, 0xfe, + 0xbe, 0x7a, 0xea, 0x74, 0x4, 0xfb, 0x47, 0xdb, 0xe8, 0xa0, 0x45, 0x64, 0x1c, 0x0, 0xa, 0xa, 0xe2, 0xa, 0x52, + 0x21, 0xc6, 0xea, 0xe3, 0xa6, 0x82, 0x2, 0x0, 0x0, 0xb, 0xa0, 0x2, 0x0, 0x0, 0x76, 0xfe, 0x1c, 0x0, 0x13, + 0xe8, 0xd7, 0xed, 0xa1, 0x8c, 0x22, 0xd0, 0x61, 0x3a, 0x14, 0x67, 0xae, 0xfd, 0xd9, 0xac, 0x65, 0xb3, 0xb0, 0xb, + 0x28, 0xbb, 0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f9, 0x85, 0xc8, 0xf3, 0x9e, 0x37, 0xcd, 0xbb, 0xd7, 0x81, 0x22, 0x28, 0xa9, 0x19, 0x91, 0x3, 0x0, 0x1e, + 0xe9, 0x86, 0x36, 0xa3, 0x8c, 0x23, 0x2f, 0x3f, 0xa1, 0x47, 0x8, 0xe, 0x77, 0x41, 0xf5, 0xba, 0xa9, 0x10, 0xc2, + 0x8e, 0x63, 0x87, 0xa1, 0xc1, 0xe9, 0x73, 0xcf, 0x7b, 0x52, 0xff, 0x2a, 0x1a, 0x12, 0x0, 0x1b, 0x6, 0x17, 0x21, + 0xda, 0x61, 0x5, 0x48, 0x9d, 0xc0, 0xf4, 0xd2, 0xb2, 0xcb, 0x92, 0xd4, 0xe1, 0x8a, 0x39, 0x64, 0x98, 0xfd, 0xdc, + 0xe, 0x9c, 0x7d, 0xd1, 0x9f, 0x2a, 0x43, 0x1, 0x6f, 0x16, 0x0, 0x1d, 0xcf, 0xea, 0x45, 0x21, 0xd1, 0x5b, 0x9d, + 0x20, 0x22, 0x82, 0x4b, 0xb6, 0xdb, 0xd7, 0xe0, 0x9, 0x77, 0x67, 0xf2, 0xe5, 0x75, 0x95, 0xd, 0x18, 0xd7, 0x4a, + 0x89, 0xaa, 0xbc, 0x2, 0x0, 0x0, 0x6d, 0x13, 0x0, 0x5, 0xb5, 0x4a, 0xfb, 0x8d, 0x3, 0x0, 0x2, 0x7c, 0x17, + 0x0, 0x13, 0x6a, 0x70, 0xd2, 0x16, 0x3c, 0x25, 0x46, 0xd7, 0xa8, 0xcf, 0x4a, 0xe1, 0x98, 0x7a, 0x97, 0x58, 0xfd, + 0x84, 0x22}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x98, 0xd, 0x5f, 0xd1, 0xf3, 0x8e, 0x11, 0x93, 0xc3, 0x9b, + 0x69, 0x7e, 0xdd, 0x5d, 0x82, 0xa0, 0x9c, 0x3, 0x71, 0xe2}; + uint8_t bytesprops1[] = {0x40, 0xa4, 0xf1, 0x19, 0x1f, 0x31, 0xfa, 0xf}; + uint8_t bytesprops2[] = {0xad, 0x8a}; + uint8_t bytesprops3[] = {0x26, 0xe8, 0xfe, 0xbe, 0x7a, 0xea, 0x74, 0x4, 0xfb, 0x47, 0xdb, 0xe8, 0xa0, 0x45, 0x64}; + uint8_t bytesprops4[] = {0xa, 0xe2, 0xa, 0x52, 0x21, 0xc6, 0xea, 0xe3, 0xa6, 0x82}; + uint8_t bytesprops5[] = {0xe8, 0xd7, 0xed, 0xa1, 0x8c, 0x22, 0xd0, 0x61, 0x3a, 0x14, + 0x67, 0xae, 0xfd, 0xd9, 0xac, 0x65, 0xb3, 0xb0, 0xb}; + uint8_t bytesprops6[] = {0x3f, 0xc2, 0x84, 0xf, 0xe1, 0xcb, 0xbd, 0xa4, 0xdc, 0x78, 0xe5, 0xb7, + 0x40, 0x13, 0x3, 0x20, 0x7, 0x7f, 0x6e, 0x9f, 0xbe, 0xe8, 0x53, 0xb}; + uint8_t bytesprops7[] = {0x0}; + uint8_t bytesprops8[] = {0xc3, 0xc9, 0x38, 0xae, 0x90, 0xcb, 0x92, 0x88, 0x5e, 0x10, 0x3a, 0x6e, 0x1f, + 0x4e, 0xc7, 0xa0, 0x34, 0x1b, 0x3a, 0x2c, 0x76, 0x34, 0x65, 0xa1, 0x17}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11874}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11283}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2976}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30462}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10715}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23900}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1537}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8705}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19667}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2344}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18306}}, + }; + + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xf9, 0xe1, 0x79, 0x57, 0xb7, 0x3c, 0xcc, 0x28, 0x18, 0x1b, 0xfd, 0x12}; + uint8_t byteswillprops0[] = {0x23, 0x48, 0x27, 0x1c, 0x97, 0xa1, 0xa2, 0x12, 0x21, 0x7f, 0x24}; + uint8_t byteswillprops2[] = {0xd5, 0x85, 0x92, 0xef, 0x85, 0xc1, 0x4e, 0xb1, 0xf9, 0x85, + 0xc8, 0xf3, 0x9e, 0x37, 0xcd, 0xbb, 0xd7, 0x81, 0x22}; + uint8_t byteswillprops3[] = {0xe9, 0x86, 0x36, 0xa3, 0x8c, 0x23, 0x2f, 0x3f, 0xa1, 0x47, + 0x8, 0xe, 0x77, 0x41, 0xf5, 0xba, 0xa9, 0x10, 0xc2, 0x8e, + 0x63, 0x87, 0xa1, 0xc1, 0xe9, 0x73, 0xcf, 0x7b, 0x52, 0xff}; + uint8_t byteswillprops4[] = {0x6, 0x17, 0x21, 0xda, 0x61, 0x5, 0x48, 0x9d, 0xc0, 0xf4, 0xd2, 0xb2, 0xcb, 0x92, + 0xd4, 0xe1, 0x8a, 0x39, 0x64, 0x98, 0xfd, 0xdc, 0xe, 0x9c, 0x7d, 0xd1, 0x9f}; + uint8_t byteswillprops5[] = {0xcf, 0xea, 0x45, 0x21, 0xd1, 0x5b, 0x9d, 0x20, 0x22, 0x82, 0x4b, 0xb6, 0xdb, 0xd7, 0xe0, + 0x9, 0x77, 0x67, 0xf2, 0xe5, 0x75, 0x95, 0xd, 0x18, 0xd7, 0x4a, 0x89, 0xaa, 0xbc}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28427}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {11, (char*)&byteswillprops0}, .v = {12, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30643}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19796}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29954}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12271}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15941}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27923}}, + }; + + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb5, 0x4a, 0xfb, 0x8d, 0x3}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7c, 0x17}; + lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 2920; + uint8_t client_id_bytes[] = {0xcb, 0x4d, 0x2b, 0xab, 0x7c, 0x84, 0x6e, 0x6a, 0xc1, 0x1c, + 0x7, 0x5c, 0x11, 0xe6, 0xca, 0x12, 0x49, 0x64, 0x3b, 0xc8}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x6a, 0x70, 0xd2, 0x16, 0x3c, 0x25, 0x46, 0xd7, 0xa8, 0xcf, + 0x4a, 0xe1, 0x98, 0x7a, 0x97, 0x58, 0xfd, 0x84, 0x22}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\192\STX\129_\195-\215\163\200JG\249<", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = +// "\152e\130\v\SOH\ACK\224\EOT\165\199(&g\SO\ACK\211\169\&1\DC3\243\199\ETB\221\138+", _willMsg = +// "H\197\&7\SOH\253\237", _willProps = [PropTopicAlias 18478,PropMessageExpiryInterval 9048,PropUserProperty +// "\CAN\246G" "d\187\128B\136\196",PropWillDelayInterval 13590,PropSubscriptionIdentifierAvailable 146]}), +// _cleanSession = True, _keepAlive = 2714, _connID = "\243Q\STX\222\243oB\DC4\136\201n\GS\146", _properties = +// [PropMessageExpiryInterval 5905,PropWildcardSubscriptionAvailable 81,PropMaximumQoS 39,PropUserProperty +// "_\183o\SOS\ETX\255(\DC4\r3N\159\&5\171\219\210\151\173\215\r0\229\151\132}\187\149;" +// "l\247ax\228\155\195$\EOT\DC3",PropAuthenticationMethod +// "\236\DC1\176;\NAK\NAK\160",PropSubscriptionIdentifierAvailable 215,PropServerKeepAlive 4430,PropResponseInformation +// "\232\182Nh\211\&3\CAN\212\148\220\157\&4\212wR\251Rw>\vJ\v\221",PropMessageExpiryInterval 9422,PropTopicAliasMaximum +// 10403,PropRetainAvailable 248,PropRetainAvailable 204,PropReasonString +// "\242gK\218`&\129\170p`\248c\NAKXC\177\"\b\228g\238\205,\168",PropTopicAliasMaximum 22359,PropReasonString +// "\200\226\191\167K\ACK\206\154\214D(\US\250\231\&7\218\158Q\242\"U\239\STX",PropTopicAlias +// 30940,PropAssignedClientIdentifier "\204r1\fp\SO\NUL`.\166\221e\234Z",PropWildcardSubscriptionAvailable +// 231,PropPayloadFormatIndicator 67,PropSubscriptionIdentifier 26,PropServerReference "N\234\b\175 +// \150&\194Z\va!!\149*\"\143{U\231",PropServerKeepAlive 12428,PropAssignedClientIdentifier +// "\FS\142\245\147\169DU\ETB\242[\245\198\186\132\158\135\164q\173[\210\129\189\165A\\2",PropServerReference +// ">\RS\249\190\132\158\248\192\180\206\131u\168=\SYN\FS!\DELZ\221|\136K\179\162\196\SOH\226e[",PropResponseInformation +// "(\187\187\198\&3\ESC\189r~\DLE\143\204h<",PropAssignedClientIdentifier +// "\248\189\155S6}\128w\160\181\ETB2g]\154\133m/\163\160\ESCW\DC2\181",PropMessageExpiryInterval +// 7073,PropServerReference "\216=\207\233\242R]",PropReceiveMaximum 8978]} +TEST(Connect5QCTest, Encode15) { + uint8_t pkt[] = { + 0x10, 0xbe, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0xa, 0x9a, 0xd3, 0x2, 0x2, 0x0, 0x0, 0x17, + 0x11, 0x28, 0x51, 0x24, 0x27, 0x26, 0x0, 0x1d, 0x5f, 0xb7, 0x6f, 0xe, 0x53, 0x3, 0xff, 0x28, 0x14, 0xd, 0x33, + 0x4e, 0x9f, 0x35, 0xab, 0xdb, 0xd2, 0x97, 0xad, 0xd7, 0xd, 0x30, 0xe5, 0x97, 0x84, 0x7d, 0xbb, 0x95, 0x3b, 0x0, + 0xa, 0x6c, 0xf7, 0x61, 0x78, 0xe4, 0x9b, 0xc3, 0x24, 0x4, 0x13, 0x15, 0x0, 0x7, 0xec, 0x11, 0xb0, 0x3b, 0x15, + 0x15, 0xa0, 0x29, 0xd7, 0x13, 0x11, 0x4e, 0x1a, 0x0, 0x17, 0xe8, 0xb6, 0x4e, 0x68, 0xd3, 0x33, 0x18, 0xd4, 0x94, + 0xdc, 0x9d, 0x34, 0xd4, 0x77, 0x52, 0xfb, 0x52, 0x77, 0x3e, 0xb, 0x4a, 0xb, 0xdd, 0x2, 0x0, 0x0, 0x24, 0xce, + 0x22, 0x28, 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bd, 0x72, 0x7e, + 0x10, 0x8f, 0xcc, 0x68, 0x3c, 0x12, 0x0, 0x18, 0xf8, 0xbd, 0x9b, 0x53, 0x36, 0x7d, 0x80, 0x77, 0xa0, 0xb5, 0x17, + 0x32, 0x67, 0x5d, 0x9a, 0x85, 0x6d, 0x2f, 0xa3, 0xa0, 0x1b, 0x57, 0x12, 0xb5, 0x2, 0x0, 0x0, 0x1b, 0xa1, 0x1c, + 0x0, 0x7, 0xd8, 0x3d, 0xcf, 0xe9, 0xf2, 0x52, 0x5d, 0x21, 0x23, 0x12, 0x0, 0xd, 0xf3, 0x51, 0x2, 0xde, 0xf3, + 0x6f, 0x42, 0x14, 0x88, 0xc9, 0x6e, 0x1d, 0x92, 0x1d, 0x23, 0x48, 0x2e, 0x2, 0x0, 0x0, 0x23, 0x58, 0x26, 0x0, + 0x3, 0x18, 0xf6, 0x47, 0x0, 0x6, 0x64, 0xbb, 0x80, 0x42, 0x88, 0xc4, 0x18, 0x0, 0x0, 0x35, 0x16, 0x29, 0x92, + 0x0, 0x19, 0x98, 0x65, 0x82, 0xb, 0x1, 0x6, 0xe0, 0x4, 0xa5, 0xc7, 0x28, 0x26, 0x67, 0xe, 0x6, 0xd3, 0xa9, + 0x31, 0x13, 0xf3, 0xc7, 0x17, 0xdd, 0x8a, 0x2b, 0x0, 0x6, 0x48, 0xc5, 0x37, 0x1, 0xfd, 0xed, 0x0, 0xd, 0xc0, + 0x2, 0x81, 0x5f, 0xc3, 0x2d, 0xd7, 0xa3, 0xc8, 0x4a, 0x47, 0xf9, 0x3c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x6c, 0xf7, 0x61, 0x78, 0xe4, 0x9b, 0xc3, 0x24, 0x4, 0x13}; + uint8_t bytesprops0[] = {0x5f, 0xb7, 0x6f, 0xe, 0x53, 0x3, 0xff, 0x28, 0x14, 0xd, 0x33, 0x4e, 0x9f, 0x35, 0xab, + 0xdb, 0xd2, 0x97, 0xad, 0xd7, 0xd, 0x30, 0xe5, 0x97, 0x84, 0x7d, 0xbb, 0x95, 0x3b}; + uint8_t bytesprops2[] = {0xec, 0x11, 0xb0, 0x3b, 0x15, 0x15, 0xa0}; + uint8_t bytesprops3[] = {0xe8, 0xb6, 0x4e, 0x68, 0xd3, 0x33, 0x18, 0xd4, 0x94, 0xdc, 0x9d, 0x34, + 0xd4, 0x77, 0x52, 0xfb, 0x52, 0x77, 0x3e, 0xb, 0x4a, 0xb, 0xdd}; + uint8_t bytesprops4[] = {0xf2, 0x67, 0x4b, 0xda, 0x60, 0x26, 0x81, 0xaa, 0x70, 0x60, 0xf8, 0x63, + 0x15, 0x58, 0x43, 0xb1, 0x22, 0x8, 0xe4, 0x67, 0xee, 0xcd, 0x2c, 0xa8}; + uint8_t bytesprops5[] = {0xc8, 0xe2, 0xbf, 0xa7, 0x4b, 0x6, 0xce, 0x9a, 0xd6, 0x44, 0x28, 0x1f, + 0xfa, 0xe7, 0x37, 0xda, 0x9e, 0x51, 0xf2, 0x22, 0x55, 0xef, 0x2}; + uint8_t bytesprops6[] = {0xcc, 0x72, 0x31, 0xc, 0x70, 0xe, 0x0, 0x60, 0x2e, 0xa6, 0xdd, 0x65, 0xea, 0x5a}; + uint8_t bytesprops7[] = {0x4e, 0xea, 0x8, 0xaf, 0x20, 0x96, 0x26, 0xc2, 0x5a, 0xb, + 0x61, 0x21, 0x21, 0x95, 0x2a, 0x22, 0x8f, 0x7b, 0x55, 0xe7}; + uint8_t bytesprops8[] = {0x1c, 0x8e, 0xf5, 0x93, 0xa9, 0x44, 0x55, 0x17, 0xf2, 0x5b, 0xf5, 0xc6, 0xba, 0x84, + 0x9e, 0x87, 0xa4, 0x71, 0xad, 0x5b, 0xd2, 0x81, 0xbd, 0xa5, 0x41, 0x5c, 0x32}; + uint8_t bytesprops9[] = {0x3e, 0x1e, 0xf9, 0xbe, 0x84, 0x9e, 0xf8, 0xc0, 0xb4, 0xce, 0x83, 0x75, 0xa8, 0x3d, 0x16, + 0x1c, 0x21, 0x7f, 0x5a, 0xdd, 0x7c, 0x88, 0x4b, 0xb3, 0xa2, 0xc4, 0x1, 0xe2, 0x65, 0x5b}; + uint8_t bytesprops10[] = {0x28, 0xbb, 0xbb, 0xc6, 0x33, 0x1b, 0xbd, 0x72, 0x7e, 0x10, 0x8f, 0xcc, 0x68, 0x3c}; + uint8_t bytesprops11[] = {0xf8, 0xbd, 0x9b, 0x53, 0x36, 0x7d, 0x80, 0x77, 0xa0, 0xb5, 0x17, 0x32, + 0x67, 0x5d, 0x9a, 0x85, 0x6d, 0x2f, 0xa3, 0xa0, 0x1b, 0x57, 0x12, 0xb5}; + uint8_t bytesprops12[] = {0xd8, 0x3d, 0xcf, 0xe9, 0xf2, 0x52, 0x5d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5905}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4430}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9422}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10403}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22359}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30940}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12428}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7073}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8978}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0x64, 0xbb, 0x80, 0x42, 0x88, 0xc4}; + uint8_t byteswillprops0[] = {0x18, 0xf6, 0x47}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18478}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9048}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {3, (char*)&byteswillprops0}, .v = {6, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13590}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 146}}, + }; + + lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x98, 0x65, 0x82, 0xb, 0x1, 0x6, 0xe0, 0x4, 0xa5, 0xc7, 0x28, 0x26, 0x67, + 0xe, 0x6, 0xd3, 0xa9, 0x31, 0x13, 0xf3, 0xc7, 0x17, 0xdd, 0x8a, 0x2b}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x48, 0xc5, 0x37, 0x1, 0xfd, 0xed}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 2714; + uint8_t client_id_bytes[] = {0xf3, 0x51, 0x2, 0xde, 0xf3, 0x6f, 0x42, 0x14, 0x88, 0xc9, 0x6e, 0x1d, 0x92}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xc0, 0x2, 0x81, 0x5f, 0xc3, 0x2d, 0xd7, 0xa3, 0xc8, 0x4a, 0x47, 0xf9, 0x3c}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = +// 26866, _connID = "^\239\188\197\142\229[\ESC\211E\188\233\195", _properties = [PropPayloadFormatIndicator +// 176,PropAuthenticationData +// "\158\211w\167\182<\128#\237:{\130\139\247\220\179z\137\NAK&\190\236\ENQ>\210l8\141\241",PropAssignedClientIdentifier +// "IY=\r\180\164\181%{",PropWildcardSubscriptionAvailable 192,PropCorrelationData +// "G\210\STX\231\151h\ENQH\166\RS\254\207y",PropMaximumQoS 165,PropSessionExpiryInterval 9460,PropResponseInformation +// "\238\168f\154\218RA\188\179oo\140\155\DC2d?$p1U\149\230\169\240\DLE\161\188\SOH\176\165",PropReasonString +// "\t!",PropMaximumPacketSize 28298,PropContentType " +// \209\174\146\178\214\141\160n&\DLE\b\154U\234\&9\rn\SI=\158\151\252",PropRequestProblemInformation +// 244,PropRequestProblemInformation 196,PropMessageExpiryInterval 31638,PropPayloadFormatIndicator +// 143,PropSubscriptionIdentifier 26,PropCorrelationData "[\200\152r\ETX"]} +TEST(Connect5QCTest, Encode16) { + uint8_t pkt[] = {0x10, 0xbc, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2, 0x68, 0xf2, 0xa1, 0x1, 0x1, + 0xb0, 0x16, 0x0, 0x1d, 0x9e, 0xd3, 0x77, 0xa7, 0xb6, 0x3c, 0x80, 0x23, 0xed, 0x3a, 0x7b, 0x82, + 0x8b, 0xf7, 0xdc, 0xb3, 0x7a, 0x89, 0x15, 0x26, 0xbe, 0xec, 0x5, 0x3e, 0xd2, 0x6c, 0x38, 0x8d, + 0xf1, 0x12, 0x0, 0x9, 0x49, 0x59, 0x3d, 0xd, 0xb4, 0xa4, 0xb5, 0x25, 0x7b, 0x28, 0xc0, 0x9, + 0x0, 0xd, 0x47, 0xd2, 0x2, 0xe7, 0x97, 0x68, 0x5, 0x48, 0xa6, 0x1e, 0xfe, 0xcf, 0x79, 0x24, + 0xa5, 0x11, 0x0, 0x0, 0x24, 0xf4, 0x1a, 0x0, 0x1e, 0xee, 0xa8, 0x66, 0x9a, 0xda, 0x52, 0x41, + 0xbc, 0xb3, 0x6f, 0x6f, 0x8c, 0x9b, 0x12, 0x64, 0x3f, 0x24, 0x70, 0x31, 0x55, 0x95, 0xe6, 0xa9, + 0xf0, 0x10, 0xa1, 0xbc, 0x1, 0xb0, 0xa5, 0x1f, 0x0, 0x2, 0x9, 0x21, 0x27, 0x0, 0x0, 0x6e, + 0x8a, 0x3, 0x0, 0x17, 0x20, 0xd1, 0xae, 0x92, 0xb2, 0xd6, 0x8d, 0xa0, 0x6e, 0x26, 0x10, 0x8, + 0x9a, 0x55, 0xea, 0x39, 0xd, 0x6e, 0xf, 0x3d, 0x9e, 0x97, 0xfc, 0x17, 0xf4, 0x17, 0xc4, 0x2, + 0x0, 0x0, 0x7b, 0x96, 0x1, 0x8f, 0xb, 0x1a, 0x9, 0x0, 0x5, 0x5b, 0xc8, 0x98, 0x72, 0x3, + 0x0, 0xd, 0x5e, 0xef, 0xbc, 0xc5, 0x8e, 0xe5, 0x5b, 0x1b, 0xd3, 0x45, 0xbc, 0xe9, 0xc3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x9e, 0xd3, 0x77, 0xa7, 0xb6, 0x3c, 0x80, 0x23, 0xed, 0x3a, 0x7b, 0x82, 0x8b, 0xf7, 0xdc, + 0xb3, 0x7a, 0x89, 0x15, 0x26, 0xbe, 0xec, 0x5, 0x3e, 0xd2, 0x6c, 0x38, 0x8d, 0xf1}; + uint8_t bytesprops1[] = {0x49, 0x59, 0x3d, 0xd, 0xb4, 0xa4, 0xb5, 0x25, 0x7b}; + uint8_t bytesprops2[] = {0x47, 0xd2, 0x2, 0xe7, 0x97, 0x68, 0x5, 0x48, 0xa6, 0x1e, 0xfe, 0xcf, 0x79}; + uint8_t bytesprops3[] = {0xee, 0xa8, 0x66, 0x9a, 0xda, 0x52, 0x41, 0xbc, 0xb3, 0x6f, 0x6f, 0x8c, 0x9b, 0x12, 0x64, + 0x3f, 0x24, 0x70, 0x31, 0x55, 0x95, 0xe6, 0xa9, 0xf0, 0x10, 0xa1, 0xbc, 0x1, 0xb0, 0xa5}; + uint8_t bytesprops4[] = {0x9, 0x21}; + uint8_t bytesprops5[] = {0x20, 0xd1, 0xae, 0x92, 0xb2, 0xd6, 0x8d, 0xa0, 0x6e, 0x26, 0x10, 0x8, + 0x9a, 0x55, 0xea, 0x39, 0xd, 0x6e, 0xf, 0x3d, 0x9e, 0x97, 0xfc}; + uint8_t bytesprops6[] = {0x5b, 0xc8, 0x98, 0x72, 0x3}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9460}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28298}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31638}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops6}}}, + }; + + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 26866; + uint8_t client_id_bytes[] = {0x5e, 0xef, 0xbc, 0xc5, 0x8e, 0xe5, 0x5b, 0x1b, 0xd3, 0x45, 0xbc, 0xe9, 0xc3}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\159\254c\245[\164\r\135bMz\150\205`e\233\140\135YrN\180\GS\186\140\209As", +// _password = Just "<\FS\172b\196\SI\220\203\NUL`\187\209)9\165<\EOT\174\n\248\135\224m\140~\ar",PropTopicAliasMaximum 25773,PropCorrelationData +// "D\153\200f-\134",PropUserProperty "_\STX\142\230\DC2\227F\255U\NAK\ENQ@[\243\140\243G\195" +// "]\EM\213\167\243\144\187X\188\232\226\183\DLEz|=\196n\236!\235\SOH\223J\182^C)"]} +TEST(Connect5QCTest, Encode17) { + uint8_t pkt[] = { + 0x10, 0xe6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x6a, 0xf4, 0x9e, 0x2, 0x27, 0x0, 0x0, 0x3, + 0x91, 0x12, 0x0, 0x0, 0x25, 0xbd, 0x2, 0x0, 0x0, 0x2, 0x16, 0x13, 0x15, 0x4f, 0x2, 0x0, 0x0, 0x4f, 0x21, + 0x26, 0x0, 0x19, 0xc5, 0x3f, 0xf, 0x4e, 0xdf, 0x21, 0xd5, 0x7d, 0x78, 0x63, 0xb0, 0x7, 0x55, 0xb1, 0xc5, 0xed, + 0x42, 0xa9, 0xe9, 0xa1, 0xb6, 0x1b, 0x72, 0x49, 0x39, 0x0, 0xe, 0xa, 0x12, 0xd9, 0xd2, 0xdb, 0x93, 0x94, 0xac, + 0x25, 0x30, 0x89, 0xde, 0xab, 0xcc, 0x2a, 0x82, 0x11, 0x0, 0x0, 0x29, 0xea, 0x9, 0x0, 0x1b, 0x2b, 0x42, 0xd8, + 0xf5, 0x8f, 0xf7, 0xea, 0x40, 0xe2, 0x24, 0xc8, 0x77, 0x66, 0x42, 0x70, 0xbb, 0xca, 0xfd, 0x47, 0x7a, 0x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, 0x5e, 0x43, 0x29, 0x0, 0xb, 0xa4, + 0xfd, 0xff, 0xbe, 0x2f, 0x50, 0x76, 0xe8, 0x1b, 0x7f, 0x10, 0x0, 0x1c, 0x9f, 0xfe, 0x63, 0xf5, 0x5b, 0xa4, 0xd, + 0x87, 0x62, 0x4d, 0x7a, 0x96, 0xcd, 0x60, 0x65, 0xe9, 0x8c, 0x87, 0x59, 0x72, 0x4e, 0xb4, 0x1d, 0xba, 0x8c, 0xd1, + 0x41, 0x73, 0x0, 0xf, 0x3c, 0x1c, 0xac, 0x62, 0xc4, 0xf, 0xdc, 0xcb, 0x0, 0x60, 0x3c, 0x76, 0x86, 0xc3, 0x65}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops2[] = {0xa, 0x12, 0xd9, 0xd2, 0xdb, 0x93, 0x94, 0xac, 0x25, 0x30, 0x89, 0xde, 0xab, 0xcc}; + uint8_t bytesprops1[] = {0xc5, 0x3f, 0xf, 0x4e, 0xdf, 0x21, 0xd5, 0x7d, 0x78, 0x63, 0xb0, 0x7, 0x55, + 0xb1, 0xc5, 0xed, 0x42, 0xa9, 0xe9, 0xa1, 0xb6, 0x1b, 0x72, 0x49, 0x39}; + uint8_t bytesprops3[] = {0x2b, 0x42, 0xd8, 0xf5, 0x8f, 0xf7, 0xea, 0x40, 0xe2, 0x24, 0xc8, 0x77, 0x66, 0x42, + 0x70, 0xbb, 0xca, 0xfd, 0x47, 0x7a, 0xfc, 0xc6, 0x52, 0x5e, 0x26, 0x25, 0x48}; + uint8_t bytesprops4[] = {0xdc, 0xd3, 0x25, 0xa6}; + uint8_t bytesprops5[] = {0x55, 0x7b, 0x48, 0x59, 0x2a, 0x8b, 0xb7, 0x47, 0xe7, 0xb2, 0x44, 0xfc, 0x45, + 0x0, 0x80, 0x7, 0xd1, 0x4a, 0xb3, 0x1f, 0xb2, 0xdb, 0xf7, 0xcd, 0xc0, 0xd7}; + uint8_t bytesprops7[] = {0x94, 0x84, 0x2e, 0xd5, 0x7b, 0x21, 0xde, 0x92, 0x24, 0x15, 0x26, 0xf8, 0x40, + 0x28, 0x8a, 0xa, 0x2b, 0xd2, 0x54, 0xa2, 0x56, 0x3f, 0xf5, 0x8b, 0xe8}; + uint8_t bytesprops6[] = {0x7d, 0x8b}; + uint8_t bytesprops8[] = {0x18, 0xce, 0xc3, 0x85, 0xba, 0xf4, 0xa4}; + uint8_t bytesprops9[] = {0xae, 0x60, 0x3e, 0xbb, 0xd1, 0x29, 0x39, 0xa5, 0x3c, 0x4, + 0xae, 0xa, 0xf8, 0x87, 0xe0, 0x6d, 0x8c, 0x7e, 0x7, 0x72}; + uint8_t bytesprops10[] = {0x44, 0x99, 0xc8, 0x66, 0x2d, 0x86}; + uint8_t bytesprops12[] = {0x5d, 0x19, 0xd5, 0xa7, 0xf3, 0x90, 0xbb, 0x58, 0xbc, 0xe8, 0xe2, 0xb7, 0x10, 0x7a, + 0x7c, 0x3d, 0xc4, 0x6e, 0xec, 0x21, 0xeb, 0x1, 0xdf, 0x4a, 0xb6, 0x5e, 0x43, 0x29}; + uint8_t bytesprops11[] = {0x5f, 0x2, 0x8e, 0xe6, 0x12, 0xe3, 0x46, 0xff, 0x55, + 0x15, 0x5, 0x40, 0x5b, 0xf3, 0x8c, 0xf3, 0x47, 0xc3}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 913}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 534}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5455}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20257}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops1}, .v = {14, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10730}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26571}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19598}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops6}, .v = {25, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25773}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {18, (char*)&bytesprops11}, .v = {28, (char*)&bytesprops12}}}}, + }; + + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 27380; + uint8_t client_id_bytes[] = {0xa4, 0xfd, 0xff, 0xbe, 0x2f, 0x50, 0x76, 0xe8, 0x1b, 0x7f, 0x10}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x9f, 0xfe, 0x63, 0xf5, 0x5b, 0xa4, 0xd, 0x87, 0x62, 0x4d, 0x7a, 0x96, 0xcd, 0x60, + 0x65, 0xe9, 0x8c, 0x87, 0x59, 0x72, 0x4e, 0xb4, 0x1d, 0xba, 0x8c, 0xd1, 0x41, 0x73}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x3c, 0x1c, 0xac, 0x62, 0xc4, 0xf, 0xdc, 0xcb, 0x0, 0x60, 0x3c, 0x76, 0x86, 0xc3, 0x65}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "6\139\225\160\222Yv\ETB\184\SUB\RS\SO\234}G\231", _lastWill = +// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "#\147F\FS\155\DC4#\190\181\197\164\ESC\166\191Z\ENQ\247\143\216\251\140\232\161>\239\135", _willMsg = +// "\232\233\vx\202\163\SOH\188\142\245iS\"H\226\158\228\235\182tA\252\ACK\191\183j8", _willProps = +// [PropRequestProblemInformation 207,PropTopicAlias 4199,PropResponseInformation +// "\183\249\163+\210\167/\229",PropContentType "\191\220\171\CAN\213\&5;\235\140 +// \231HX\248p.\132-\199W\168X\239#oa\172\162g(",PropUserProperty "" +// "\218\&1R\149p\193\226\143",PropAuthenticationMethod "\130",PropSessionExpiryInterval 2593,PropTopicAlias +// 23065,PropSessionExpiryInterval 4102,PropPayloadFormatIndicator 35,PropAuthenticationMethod "1r4"]}), _cleanSession = +// False, _keepAlive = 2005, _connID = "\SODv\236\176\168\ETB \EOT", _properties = [PropAuthenticationData +// "\247v\GS\229TS\208\161\DC1\235_\242\236\147J\175*R]",PropAssignedClientIdentifier "",PropCorrelationData +// "t\185\183\SOH!n\197\215\177\DC1O\fI\167\217(\\\253\138\206\193\213",PropReasonString +// "9\185\FSh\184\223l\134\162\151x\246O\226\216\164",PropTopicAliasMaximum 11736,PropMaximumQoS 32,PropServerReference +// "\199[3\248\148\186\DC4\149\NAK\166\"\132\198\249\v\t\167*H/z\183r\DC4#\191\STXT",PropResponseTopic +// "\236\196\199\207;N\222M\162\f\"\175\221\186",PropResponseTopic +// "\218\139\220f\247\ESC}\132\152\205\149\154\156\RS\ESC\199\223\223\158\&8\230$",PropResponseTopic +// "\STXs\246\190\ENQB`\178o\186\218\153\131\RS",PropAuthenticationData +// "\173V\209T\246\ENQ\v\152\ENQ\152\247\157\DEL\218\186u\202\a\193",PropWillDelayInterval +// 4378,PropMessageExpiryInterval 17537,PropRequestResponseInformation 119,PropReceiveMaximum 18892,PropServerReference +// "\200\132\&4\128W\178\DEL\156\131\182\149\240\GS\GS\182B\225N\152A`^\154P",PropRequestResponseInformation +// 200,PropWildcardSubscriptionAvailable 134,PropMessageExpiryInterval 8274,PropSharedSubscriptionAvailable +// 11,PropMaximumQoS 111,PropCorrelationData "R/\147\191\&1\132\233y\131\136\&0\248F",PropPayloadFormatIndicator +// 50,PropTopicAliasMaximum 2391]} +TEST(Connect5QCTest, Encode18) { + uint8_t pkt[] = { + 0x10, 0xc0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x64, 0x7, 0xd5, 0x86, 0x2, 0x16, 0x0, 0x13, 0xf7, + 0x76, 0x1d, 0xe5, 0x54, 0x53, 0xd0, 0xa1, 0x11, 0xeb, 0x5f, 0xf2, 0xec, 0x93, 0x4a, 0xaf, 0x2a, 0x52, 0x5d, 0x12, + 0x0, 0x0, 0x9, 0x0, 0x16, 0x74, 0xb9, 0xb7, 0x1, 0x21, 0x6e, 0xc5, 0xd7, 0xb1, 0x11, 0x4f, 0xc, 0x49, 0xa7, + 0xd9, 0x28, 0x5c, 0xfd, 0x8a, 0xce, 0xc1, 0xd5, 0x1f,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, 0x76, 0x17, 0xb8, 0x1a, 0x1e, 0xe, 0xea, 0x7d, 0x47, 0xe7}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf7, 0x76, 0x1d, 0xe5, 0x54, 0x53, 0xd0, 0xa1, 0x11, 0xeb, + 0x5f, 0xf2, 0xec, 0x93, 0x4a, 0xaf, 0x2a, 0x52, 0x5d}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x74, 0xb9, 0xb7, 0x1, 0x21, 0x6e, 0xc5, 0xd7, 0xb1, 0x11, 0x4f, + 0xc, 0x49, 0xa7, 0xd9, 0x28, 0x5c, 0xfd, 0x8a, 0xce, 0xc1, 0xd5}; + uint8_t bytesprops3[] = {0x39, 0xb9, 0x1c, 0x68, 0xb8, 0xdf, 0x6c, 0x86, + 0xa2, 0x97, 0x78, 0xf6, 0x4f, 0xe2, 0xd8, 0xa4}; + uint8_t bytesprops4[] = {0xc7, 0x5b, 0x33, 0xf8, 0x94, 0xba, 0x14, 0x95, 0x15, 0xa6, 0x22, 0x84, 0xc6, 0xf9, + 0xb, 0x9, 0xa7, 0x2a, 0x48, 0x2f, 0x7a, 0xb7, 0x72, 0x14, 0x23, 0xbf, 0x2, 0x54}; + uint8_t bytesprops5[] = {0xec, 0xc4, 0xc7, 0xcf, 0x3b, 0x4e, 0xde, 0x4d, 0xa2, 0xc, 0x22, 0xaf, 0xdd, 0xba}; + uint8_t bytesprops6[] = {0xda, 0x8b, 0xdc, 0x66, 0xf7, 0x1b, 0x7d, 0x84, 0x98, 0xcd, 0x95, + 0x9a, 0x9c, 0x1e, 0x1b, 0xc7, 0xdf, 0xdf, 0x9e, 0x38, 0xe6, 0x24}; + uint8_t bytesprops7[] = {0x2, 0x73, 0xf6, 0xbe, 0x5, 0x42, 0x60, 0xb2, 0x6f, 0xba, 0xda, 0x99, 0x83, 0x1e}; + uint8_t bytesprops8[] = {0xad, 0x56, 0xd1, 0x54, 0xf6, 0x5, 0xb, 0x98, 0x5, 0x98, + 0xf7, 0x9d, 0x7f, 0xda, 0xba, 0x75, 0xca, 0x7, 0xc1}; + uint8_t bytesprops9[] = {0xc8, 0x84, 0x34, 0x80, 0x57, 0xb2, 0x7f, 0x9c, 0x83, 0xb6, 0x95, 0xf0, + 0x1d, 0x1d, 0xb6, 0x42, 0xe1, 0x4e, 0x98, 0x41, 0x60, 0x5e, 0x9a, 0x50}; + uint8_t bytesprops10[] = {0x52, 0x2f, 0x93, 0xbf, 0x31, 0x84, 0xe9, 0x79, 0x83, 0x88, 0x30, 0xf8, 0x46}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11736}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4378}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17537}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18892}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8274}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2391}}, + }; + + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xb7, 0xf9, 0xa3, 0x2b, 0xd2, 0xa7, 0x2f, 0xe5}; + uint8_t byteswillprops1[] = {0xbf, 0xdc, 0xab, 0x18, 0xd5, 0x35, 0x3b, 0xeb, 0x8c, 0x20, + 0xe7, 0x48, 0x58, 0xf8, 0x70, 0x2e, 0x84, 0x2d, 0xc7, 0x57, + 0xa8, 0x58, 0xef, 0x23, 0x6f, 0x61, 0xac, 0xa2, 0x67, 0x28}; + uint8_t byteswillprops3[] = {0xda, 0x31, 0x52, 0x95, 0x70, 0xc1, 0xe2, 0x8f}; + uint8_t byteswillprops2[] = {0}; + uint8_t byteswillprops4[] = {0x82}; + uint8_t byteswillprops5[] = {0x31, 0x72, 0x34}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4199}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {0, (char*)&byteswillprops2}, .v = {8, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2593}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23065}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4102}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&byteswillprops5}}}, + }; + + lwmqtt_properties_t willprops = {11, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x23, 0x93, 0x46, 0x1c, 0x9b, 0x14, 0x23, 0xbe, 0xb5, 0xc5, 0xa4, 0x1b, 0xa6, + 0xbf, 0x5a, 0x5, 0xf7, 0x8f, 0xd8, 0xfb, 0x8c, 0xe8, 0xa1, 0x3e, 0xef, 0x87}; + lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xe8, 0xe9, 0xb, 0x78, 0xca, 0xa3, 0x1, 0xbc, 0x8e, 0xf5, 0x69, 0x53, 0x22, 0x48, + 0xe2, 0x9e, 0xe4, 0xeb, 0xb6, 0x74, 0x41, 0xfc, 0x6, 0xbf, 0xb7, 0x6a, 0x38}; + lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 2005; + uint8_t client_id_bytes[] = {0xe, 0x44, 0x76, 0xec, 0xb0, 0xa8, 0x17, 0x20, 0x4}; + lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x36, 0x8b, 0xe1, 0xa0, 0xde, 0x59, 0x76, 0x17, + 0xb8, 0x1a, 0x1e, 0xe, 0xea, 0x7d, 0x47, 0xe7}; + lwmqtt_string_t password = {16, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "5\189\229", _password = Just "\SO\229\SUB\207\196\181|6\242\192@", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "v<3?)\161", _willMsg = +// "\202\&9\147\164]\233\219\201F\146ox)xa", _willProps = [PropAssignedClientIdentifier +// "Dc\147\242\153",PropResponseTopic "\EM\b-\DELBH@}\187\218\162\213\134",PropResponseInformation +// "\n1b\217:bmW\202_jM\223\157\162\CAN\ETX\168",PropSubscriptionIdentifierAvailable 100,PropAuthenticationData +// "\204z\an",PropSessionExpiryInterval 8296,PropContentType "\235\149\162!\EOT\244 +// \207\170\221\185\238e\174\167:n}A~\172\255*\165\NUL\131\128a",PropAuthenticationMethod "%",PropResponseTopic +// "\DC4\191Y\141\&9\170m",PropMaximumPacketSize 24666,PropPayloadFormatIndicator 239,PropReceiveMaximum +// 30525,PropTopicAliasMaximum 26970,PropRequestProblemInformation 125,PropServerReference +// "\190\205;9?\139\178\185\SYN\SUB\201\a",PropTopicAlias 26971,PropMessageExpiryInterval 5356,PropReceiveMaximum +// 5790,PropRequestResponseInformation 218,PropServerReference "\206",PropServerReference +// "-\SUB\149\226\222",PropSubscriptionIdentifier 12,PropWillDelayInterval 9880,PropRequestResponseInformation 52]}), +// _cleanSession = False, _keepAlive = 31959, _connID = "K\181", _properties = [PropWildcardSubscriptionAvailable +// 193,PropTopicAlias 23844,PropRequestProblemInformation 174,PropWildcardSubscriptionAvailable +// 246,PropResponseInformation "H",PropMessageExpiryInterval 4039,PropTopicAlias 29447,PropMessageExpiryInterval +// 9745,PropContentType "\220b\195\246X\148\GS&\192\211%\136\149",PropCorrelationData +// "\137C\140\217\ETX\165\196\135g\224\196\130\237\NAK\198\224\DEL\179",PropResponseTopic +// "\142\191\170\182\239\131\SUB\251\141\182VI",PropServerReference +// "k&|\204\142\171\220\133\163\248l\247\136,\136`\182e;)\219nY\DC4\129",PropRetainAvailable 42,PropRetainAvailable +// 141,PropResponseTopic "\196\177\&7\243\DC4\245\193\DC4\234",PropMaximumPacketSize 23721,PropAuthenticationMethod +// "\231`@P\184\169U\255|\DLE",PropReasonString "\228/\245lwe)\150\SO\246\ESCT\135>\188\250",PropAuthenticationMethod +// "\158\164\182\SO-O\192\205\162\175\161\172\SI\198B\224WS\207\212\145\DC4",PropSharedSubscriptionAvailable +// 210,PropPayloadFormatIndicator 185,PropMessageExpiryInterval 2096,PropTopicAlias 13639,PropRetainAvailable +// 168,PropTopicAliasMaximum 9785,PropContentType "\v\DC3I",PropAssignedClientIdentifier +// "\176\155\178\141",PropRetainAvailable 76]} +TEST(Connect5QCTest, Encode19) { + uint8_t pkt[] = { + 0x10, 0xbd, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x7c, 0xd7, 0xd8, 0x1, 0x28, 0xc1, 0x23, 0x5d, + 0x24, 0x17, 0xae, 0x28, 0xf6, 0x1a, 0x0, 0x1, 0x48, 0x2, 0x0, 0x0, 0xf, 0xc7, 0x23, 0x73, 0x7, 0x2, 0x0, + 0x0, 0x26, 0x11, 0x3, 0x0, 0xd, 0xdc, 0x62, 0xc3, 0xf6, 0x58, 0x94, 0x1d, 0x26, 0xc0, 0xd3, 0x25, 0x88, 0x95, + 0x9, 0x0, 0x12, 0x89, 0x43, 0x8c, 0xd9, 0x3, 0xa5, 0xc4, 0x87, 0x67, 0xe0, 0xc4, 0x82, 0xed, 0x15, 0xc6, 0xe0, + 0x7f, 0xb3, 0x8, 0x0, 0xc, 0x8e, 0xbf, 0xaa, 0xb6, 0xef, 0x83, 0x1a, 0xfb, 0x8d, 0xb6, 0x56, 0x49, 0x1c, 0x0, + 0x19, 0x6b, 0x26, 0x7c, 0xcc, 0x8e, 0xab, 0xdc, 0x85, 0xa3, 0xf8, 0x6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0x20, 0x68, 0x3, 0x0, 0x1c, 0xeb, 0x95, 0xa2, 0x21, 0x4, + 0xf4, 0x20, 0xcf, 0xaa, 0xdd, 0xb9, 0xee, 0x65, 0xae, 0xa7, 0x3a, 0x6e, 0x7d, 0x41, 0x7e, 0xac, 0xff, 0x2a, 0xa5, + 0x0, 0x83, 0x80, 0x61, 0x15, 0x0, 0x1, 0x25, 0x8, 0x0, 0x7, 0x14, 0xbf, 0x59, 0x8d, 0x39, 0xaa, 0x6d, 0x27, + 0x0, 0x0, 0x60, 0x5a, 0x1, 0xef, 0x21, 0x77, 0x3d, 0x22, 0x69, 0x5a, 0x17, 0x7d, 0x1c, 0x0, 0xc, 0xbe, 0xcd, + 0x3b, 0x39, 0x3f, 0x8b, 0xb2, 0xb9, 0x16, 0x1a, 0xc9, 0x7, 0x23, 0x69, 0x5b, 0x2, 0x0, 0x0, 0x14, 0xec, 0x21, + 0x16, 0x9e, 0x19, 0xda, 0x1c, 0x0, 0x1, 0xce, 0x1c, 0x0, 0x5, 0x2d, 0x1a, 0x95, 0xe2, 0xde, 0xb, 0xc, 0x18, + 0x0, 0x0, 0x26, 0x98, 0x19, 0x34, 0x0, 0x6, 0x76, 0x3c, 0x33, 0x3f, 0x29, 0xa1, 0x0, 0xf, 0xca, 0x39, 0x93, + 0xa4, 0x5d, 0xe9, 0xdb, 0xc9, 0x46, 0x92, 0x6f, 0x78, 0x29, 0x78, 0x61, 0x0, 0x3, 0x35, 0xbd, 0xe5, 0x0, 0xb, + 0xe, 0xe5, 0x1a, 0xcf, 0xc4, 0xb5, 0x7c, 0x36, 0xf2, 0xc0, 0x40}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x48}; + uint8_t bytesprops1[] = {0xdc, 0x62, 0xc3, 0xf6, 0x58, 0x94, 0x1d, 0x26, 0xc0, 0xd3, 0x25, 0x88, 0x95}; + uint8_t bytesprops2[] = {0x89, 0x43, 0x8c, 0xd9, 0x3, 0xa5, 0xc4, 0x87, 0x67, + 0xe0, 0xc4, 0x82, 0xed, 0x15, 0xc6, 0xe0, 0x7f, 0xb3}; + uint8_t bytesprops3[] = {0x8e, 0xbf, 0xaa, 0xb6, 0xef, 0x83, 0x1a, 0xfb, 0x8d, 0xb6, 0x56, 0x49}; + uint8_t bytesprops4[] = {0x6b, 0x26, 0x7c, 0xcc, 0x8e, 0xab, 0xdc, 0x85, 0xa3, 0xf8, 0x6c, 0xf7, 0x88, + 0x2c, 0x88, 0x60, 0xb6, 0x65, 0x3b, 0x29, 0xdb, 0x6e, 0x59, 0x14, 0x81}; + uint8_t bytesprops5[] = {0xc4, 0xb1, 0x37, 0xf3, 0x14, 0xf5, 0xc1, 0x14, 0xea}; + uint8_t bytesprops6[] = {0xe7, 0x60, 0x40, 0x50, 0xb8, 0xa9, 0x55, 0xff, 0x7c, 0x10}; + uint8_t bytesprops7[] = {0xe4, 0x2f, 0xf5, 0x6c, 0x77, 0x65, 0x29, 0x96, + 0xe, 0xf6, 0x1b, 0x54, 0x87, 0x3e, 0xbc, 0xfa}; + uint8_t bytesprops8[] = {0x9e, 0xa4, 0xb6, 0xe, 0x2d, 0x4f, 0xc0, 0xcd, 0xa2, 0xaf, 0xa1, + 0xac, 0xf, 0xc6, 0x42, 0xe0, 0x57, 0x53, 0xcf, 0xd4, 0x91, 0x14}; + uint8_t bytesprops9[] = {0xb, 0x13, 0x49}; + uint8_t bytesprops10[] = {0xb0, 0x9b, 0xb2, 0x8d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23844}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4039}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29447}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9745}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23721}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2096}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13639}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9785}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 76}}, + }; + + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x44, 0x63, 0x93, 0xf2, 0x99}; + uint8_t byteswillprops1[] = {0x19, 0x8, 0x2d, 0x7f, 0x42, 0x48, 0x40, 0x7d, 0xbb, 0xda, 0xa2, 0xd5, 0x86}; + uint8_t byteswillprops2[] = {0xa, 0x31, 0x62, 0xd9, 0x3a, 0x62, 0x6d, 0x57, 0xca, + 0x5f, 0x6a, 0x4d, 0xdf, 0x9d, 0xa2, 0x18, 0x3, 0xa8}; + uint8_t byteswillprops3[] = {0xcc, 0x7a, 0x7, 0x6e}; + uint8_t byteswillprops4[] = {0xeb, 0x95, 0xa2, 0x21, 0x4, 0xf4, 0x20, 0xcf, 0xaa, 0xdd, 0xb9, 0xee, 0x65, 0xae, + 0xa7, 0x3a, 0x6e, 0x7d, 0x41, 0x7e, 0xac, 0xff, 0x2a, 0xa5, 0x0, 0x83, 0x80, 0x61}; + uint8_t byteswillprops5[] = {0x25}; + uint8_t byteswillprops6[] = {0x14, 0xbf, 0x59, 0x8d, 0x39, 0xaa, 0x6d}; + uint8_t byteswillprops7[] = {0xbe, 0xcd, 0x3b, 0x39, 0x3f, 0x8b, 0xb2, 0xb9, 0x16, 0x1a, 0xc9, 0x7}; + uint8_t byteswillprops8[] = {0xce}; + uint8_t byteswillprops9[] = {0x2d, 0x1a, 0x95, 0xe2, 0xde}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8296}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24666}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30525}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26970}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26971}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5356}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5790}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9880}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 52}}, + }; + + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x76, 0x3c, 0x33, 0x3f, 0x29, 0xa1}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xca, 0x39, 0x93, 0xa4, 0x5d, 0xe9, 0xdb, 0xc9, + 0x46, 0x92, 0x6f, 0x78, 0x29, 0x78, 0x61}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 31959; + uint8_t client_id_bytes[] = {0x4b, 0xb5}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x35, 0xbd, 0xe5}; + lwmqtt_string_t username = {3, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xe, 0xe5, 0x1a, 0xcf, 0xc4, 0xb5, 0x7c, 0x36, 0xf2, 0xc0, 0x40}; + lwmqtt_string_t password = {11, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "$\DC3o!\SI\253}\212\230\FS`\217X\171[", _password = Just "u", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\SOH$\ETB\192\157\196En", _willMsg = +// "\215\209\DLE\STX\164!\185\142\223\197\154\"\159\249\167,[\130", _willProps = [PropResponseInformation +// "X\203\245\ETX\160\216$T\219\195\ETB\193\226$\226\t\nKAcO\175\191\142\ACK\DC45\177]",PropWildcardSubscriptionAvailable +// 17,PropSubscriptionIdentifierAvailable 13,PropSharedSubscriptionAvailable 69,PropMessageExpiryInterval +// 3564,PropRequestResponseInformation 11,PropRetainAvailable 134,PropServerReference +// "\ETB\224A\152\215\RS\SO",PropSharedSubscriptionAvailable 37,PropRequestProblemInformation +// 119,PropSubscriptionIdentifierAvailable 218,PropResponseTopic "\159W\b\243",PropRequestResponseInformation +// 83,PropMessageExpiryInterval 11545,PropWildcardSubscriptionAvailable 245,PropPayloadFormatIndicator +// 154,PropMaximumQoS 150,PropSubscriptionIdentifier 22,PropServerKeepAlive 19385,PropWildcardSubscriptionAvailable +// 14,PropServerReference "\230",PropTopicAliasMaximum 19038]}), _cleanSession = True, _keepAlive = 14833, _connID = +// "\ETX@W\177\213>\v\227\232\224C\r\156\220j\DC4\170\177g\190-&\193", _properties = [PropTopicAlias +// 5177,PropServerKeepAlive 10636,PropAuthenticationMethod +// "\139\ETB\255\239\DLEL\180m\163I\SYN\233\SI\GS\CAN\155]p3\243\220\&8\243\b\192\SI&B",PropReasonString +// "J\138\STX\NAKz\207\&5\191\b\SUB\163\246R\US\135\211k\DC2)6[",PropMessageExpiryInterval 13679,PropReceiveMaximum +// 379,PropSubscriptionIdentifier 6,PropMessageExpiryInterval 28433,PropSubscriptionIdentifier +// 10,PropAssignedClientIdentifier "\148\177\154",PropReasonString "+\NULN\159\154R2\155R\170\FS",PropServerReference +// "4!+\178\141+\186\&5~\220F\134\GSUH\166\132\171aH",PropAuthenticationMethod +// "\250\209?\194\195\EMzH\224M\182\131\GS\\",PropSharedSubscriptionAvailable 22,PropPayloadFormatIndicator +// 213,PropResponseTopic "e",PropMessageExpiryInterval 30484,PropRequestProblemInformation +// 196,PropPayloadFormatIndicator 191,PropServerReference "\254\216\ACK\159\156\187\255!\234\NUL\r",PropReasonString +// "9Q\r\239\f",PropResponseTopic +// "bR\154\214v\148\139\252\153\225\128\\L\143\131\ESC\f\220\225\238\&8\ETB\201",PropWillDelayInterval +// 18510,PropMessageExpiryInterval 19228]} +TEST(Connect5QCTest, Encode20) { + uint8_t pkt[] = { + 0x10, 0x8e, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x39, 0xf1, 0xd5, 0x1, 0x23, 0x14, 0x39, 0x13, + 0x29, 0x8c, 0x15, 0x0, 0x1c, 0x8b, 0x17, 0xff, 0xef, 0x10, 0x4c, 0xb4, 0x6d, 0xa3, 0x49, 0x16, 0xe9, 0xf, 0x1d, + 0x18, 0x9b, 0x5d, 0x70, 0x33, 0xf3, 0xdc, 0x38, 0xf3, 0x8, 0xc0, 0xf, 0x26, 0x42, 0x1f, 0x0, 0x15, 0x4a, 0x8a, + 0x2, 0x15, 0x7a, 0xcf, 0x35, 0xbf, 0x8, 0x1a, 0xa3, 0xf6, 0x52, 0x1f, 0x87, 0xd3, 0x6b, 0x12, 0x29, 0x36, 0x5b, + 0x2, 0x0, 0x0, 0x35,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3, 0x17, 0xc1, 0xe2, 0x24, 0xe2, 0x9, 0xa, 0x4b, 0x41, 0x63, 0x4f, 0xaf, 0xbf, 0x8e, 0x6, 0x14, 0x35, 0xb1, + 0x5d, 0x28, 0x11, 0x29, 0xd, 0x2a, 0x45, 0x2, 0x0, 0x0, 0xd, 0xec, 0x19, 0xb, 0x25, 0x86, 0x1c, 0x0, 0x7, + 0x17, 0xe0, 0x41, 0x98, 0xd7, 0x1e, 0xe, 0x2a, 0x25, 0x17, 0x77, 0x29, 0xda, 0x8, 0x0, 0x4, 0x9f, 0x57, 0x8, + 0xf3, 0x19, 0x53, 0x2, 0x0, 0x0, 0x2d, 0x19, 0x28, 0xf5, 0x1, 0x9a, 0x24, 0x96, 0xb, 0x16, 0x13, 0x4b, 0xb9, + 0x28, 0xe, 0x1c, 0x0, 0x1, 0xe6, 0x22, 0x4a, 0x5e, 0x0, 0x8, 0x1, 0x24, 0x17, 0xc0, 0x9d, 0xc4, 0x45, 0x6e, + 0x0, 0x12, 0xd7, 0xd1, 0x10, 0x2, 0xa4, 0x21, 0xb9, 0x8e, 0xdf, 0xc5, 0x9a, 0x22, 0x9f, 0xf9, 0xa7, 0x2c, 0x5b, + 0x82, 0x0, 0xf, 0x24, 0x13, 0x6f, 0x21, 0xf, 0xfd, 0x7d, 0xd4, 0xe6, 0x1c, 0x60, 0xd9, 0x58, 0xab, 0x5b, 0x0, + 0x1, 0x75}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x8b, 0x17, 0xff, 0xef, 0x10, 0x4c, 0xb4, 0x6d, 0xa3, 0x49, 0x16, 0xe9, 0xf, 0x1d, + 0x18, 0x9b, 0x5d, 0x70, 0x33, 0xf3, 0xdc, 0x38, 0xf3, 0x8, 0xc0, 0xf, 0x26, 0x42}; + uint8_t bytesprops1[] = {0x4a, 0x8a, 0x2, 0x15, 0x7a, 0xcf, 0x35, 0xbf, 0x8, 0x1a, 0xa3, + 0xf6, 0x52, 0x1f, 0x87, 0xd3, 0x6b, 0x12, 0x29, 0x36, 0x5b}; + uint8_t bytesprops2[] = {0x94, 0xb1, 0x9a}; + uint8_t bytesprops3[] = {0x2b, 0x0, 0x4e, 0x9f, 0x9a, 0x52, 0x32, 0x9b, 0x52, 0xaa, 0x1c}; + uint8_t bytesprops4[] = {0x34, 0x21, 0x2b, 0xb2, 0x8d, 0x2b, 0xba, 0x35, 0x7e, 0xdc, + 0x46, 0x86, 0x1d, 0x55, 0x48, 0xa6, 0x84, 0xab, 0x61, 0x48}; + uint8_t bytesprops5[] = {0xfa, 0xd1, 0x3f, 0xc2, 0xc3, 0x19, 0x7a, 0x48, 0xe0, 0x4d, 0xb6, 0x83, 0x1d, 0x5c}; + uint8_t bytesprops6[] = {0x65}; + uint8_t bytesprops7[] = {0xfe, 0xd8, 0x6, 0x9f, 0x9c, 0xbb, 0xff, 0x21, 0xea, 0x0, 0xd}; + uint8_t bytesprops8[] = {0x39, 0x51, 0xd, 0xef, 0xc}; + uint8_t bytesprops9[] = {0x62, 0x52, 0x9a, 0xd6, 0x76, 0x94, 0x8b, 0xfc, 0x99, 0xe1, 0x80, 0x5c, + 0x4c, 0x8f, 0x83, 0x1b, 0xc, 0xdc, 0xe1, 0xee, 0x38, 0x17, 0xc9}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5177}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10636}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13679}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 379}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28433}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30484}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18510}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19228}}, + }; + + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x58, 0xcb, 0xf5, 0x3, 0xa0, 0xd8, 0x24, 0x54, 0xdb, 0xc3, 0x17, 0xc1, 0xe2, 0x24, 0xe2, + 0x9, 0xa, 0x4b, 0x41, 0x63, 0x4f, 0xaf, 0xbf, 0x8e, 0x6, 0x14, 0x35, 0xb1, 0x5d}; + uint8_t byteswillprops1[] = {0x17, 0xe0, 0x41, 0x98, 0xd7, 0x1e, 0xe}; + uint8_t byteswillprops2[] = {0x9f, 0x57, 0x8, 0xf3}; + uint8_t byteswillprops3[] = {0xe6}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3564}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11545}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19385}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19038}}, + }; + + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1, 0x24, 0x17, 0xc0, 0x9d, 0xc4, 0x45, 0x6e}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd7, 0xd1, 0x10, 0x2, 0xa4, 0x21, 0xb9, 0x8e, 0xdf, + 0xc5, 0x9a, 0x22, 0x9f, 0xf9, 0xa7, 0x2c, 0x5b, 0x82}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 14833; + uint8_t client_id_bytes[] = {0x3, 0x40, 0x57, 0xb1, 0xd5, 0x3e, 0xb, 0xe3, 0xe8, 0xe0, 0x43, 0xd, + 0x9c, 0xdc, 0x6a, 0x14, 0xaa, 0xb1, 0x67, 0xbe, 0x2d, 0x26, 0xc1}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x24, 0x13, 0x6f, 0x21, 0xf, 0xfd, 0x7d, 0xd4, 0xe6, 0x1c, 0x60, 0xd9, 0x58, 0xab, 0x5b}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x75}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\vA%3\NAK\141\215\DC1\202\232\133\157m&\195\DLE\177S\169-s\174ot\177\US\t\176", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\168\SO\185\228vJA\194DR\140\201\EOT\155\ETB!", _willMsg = "a\EM\252\SYNH\190\200 B\143\EOT\ETXl' \174\145\159n", +// _willProps = [PropReasonString +// "\DC3\255\206k\133-D\SYN39\212\\\242iul\tw\239Tn\227I\251R\233Y|\216",PropRetainAvailable +// 252,PropWildcardSubscriptionAvailable 49,PropSubscriptionIdentifier 1,PropTopicAlias 562,PropAuthenticationData +// "\248v4\196\DC2\211^G\189[\178\n\255\148",PropUserProperty +// "R\DC4\176\244\&13a\237\140\214\216:\171\136n\202\170\213\ETB\f%" +// "\195\149J\141RA\209E;H\176\134\179\209\156\164\197\229=<\129\DC4",PropReasonString +// "\DC34\NUL<\245\177\164\CAN?\255nK.[\153\201\233\242\220\135\160\198\149\169",PropTopicAliasMaximum +// 29408,PropSessionExpiryInterval 21193,PropSubscriptionIdentifier 7,PropWildcardSubscriptionAvailable +// 147,PropSharedSubscriptionAvailable 26,PropReasonString "",PropServerKeepAlive 14535,PropWillDelayInterval +// 21614,PropRequestResponseInformation 161,PropAuthenticationData "",PropAuthenticationMethod +// "sV\187\173=\biD\168\181\r_\SO\167\230\208\232V{\254\177]",PropSharedSubscriptionAvailable +// 40,PropMessageExpiryInterval 13486,PropSubscriptionIdentifierAvailable 33]}), _cleanSession = True, _keepAlive = +// 28777, _connID = "+3\250\223\230[8\232\GS\FS\191\141\166\159\EOT", _properties = [PropWildcardSubscriptionAvailable +// 102,PropRequestResponseInformation 196,PropSubscriptionIdentifier 14,PropMessageExpiryInterval +// 15373,PropWillDelayInterval 5915,PropRequestProblemInformation 1,PropAuthenticationMethod +// "\FS\205",PropSubscriptionIdentifierAvailable 112,PropMessageExpiryInterval 14235,PropResponseTopic +// "\DLE\155y\190\200G\220H\248\200`5y\216\243\255\214&\170%\251\DC1\140&\247\249\129",PropServerKeepAlive +// 5011,PropRetainAvailable 132,PropSubscriptionIdentifier 6,PropSubscriptionIdentifier 28,PropTopicAliasMaximum +// 10090,PropSubscriptionIdentifierAvailable 185,PropSharedSubscriptionAvailable 254,PropSubscriptionIdentifierAvailable +// 93,PropTopicAlias 90,PropMessageExpiryInterval 1532,PropResponseInformation +// "\155\171\&5\210J\184K",PropServerKeepAlive 28224]} +TEST(Connect5QCTest, Encode21) { + uint8_t pkt[] = { + 0x10, 0x8b, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0x70, 0x69, 0x63, 0x28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 0x2d, 0x73, 0xae, 0x6f, 0x74, 0xb1, 0x1f, 0x9, 0xb0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1c, 0xcd}; + uint8_t bytesprops1[] = {0x10, 0x9b, 0x79, 0xbe, 0xc8, 0x47, 0xdc, 0x48, 0xf8, 0xc8, 0x60, 0x35, 0x79, 0xd8, + 0xf3, 0xff, 0xd6, 0x26, 0xaa, 0x25, 0xfb, 0x11, 0x8c, 0x26, 0xf7, 0xf9, 0x81}; + uint8_t bytesprops2[] = {0x9b, 0xab, 0x35, 0xd2, 0x4a, 0xb8, 0x4b}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15373}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5915}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14235}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5011}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10090}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 90}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1532}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28224}}, + }; + + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x13, 0xff, 0xce, 0x6b, 0x85, 0x2d, 0x44, 0x16, 0x33, 0x39, 0xd4, 0x5c, 0xf2, 0x69, 0x75, + 0x6c, 0x9, 0x77, 0xef, 0x54, 0x6e, 0xe3, 0x49, 0xfb, 0x52, 0xe9, 0x59, 0x7c, 0xd8}; + uint8_t byteswillprops1[] = {0xf8, 0x76, 0x34, 0xc4, 0x12, 0xd3, 0x5e, 0x47, 0xbd, 0x5b, 0xb2, 0xa, 0xff, 0x94}; + uint8_t byteswillprops3[] = {0xc3, 0x95, 0x4a, 0x8d, 0x52, 0x41, 0xd1, 0x45, 0x3b, 0x48, 0xb0, + 0x86, 0xb3, 0xd1, 0x9c, 0xa4, 0xc5, 0xe5, 0x3d, 0x3c, 0x81, 0x14}; + uint8_t byteswillprops2[] = {0x52, 0x14, 0xb0, 0xf4, 0x31, 0x33, 0x61, 0xed, 0x8c, 0xd6, 0xd8, + 0x3a, 0xab, 0x88, 0x6e, 0xca, 0xaa, 0xd5, 0x17, 0xc, 0x25}; + uint8_t byteswillprops4[] = {0x13, 0x34, 0x0, 0x3c, 0xf5, 0xb1, 0xa4, 0x18, 0x3f, 0xff, 0x6e, 0x4b, + 0x2e, 0x5b, 0x99, 0xc9, 0xe9, 0xf2, 0xdc, 0x87, 0xa0, 0xc6, 0x95, 0xa9}; + uint8_t byteswillprops5[] = {0}; + uint8_t byteswillprops6[] = {0}; + uint8_t byteswillprops7[] = {0x73, 0x56, 0xbb, 0xad, 0x3d, 0x8, 0x69, 0x44, 0xa8, 0xb5, 0xd, + 0x5f, 0xe, 0xa7, 0xe6, 0xd0, 0xe8, 0x56, 0x7b, 0xfe, 0xb1, 0x5d}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 562}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {21, (char*)&byteswillprops2}, .v = {22, (char*)&byteswillprops3}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29408}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21193}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14535}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21614}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13486}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 33}}, + }; + + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa8, 0xe, 0xb9, 0xe4, 0x76, 0x4a, 0x41, 0xc2, + 0x44, 0x52, 0x8c, 0xc9, 0x4, 0x9b, 0x17, 0x21}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x61, 0x19, 0xfc, 0x16, 0x48, 0xbe, 0xc8, 0x20, 0x42, 0x8f, + 0x4, 0x3, 0x6c, 0x27, 0x20, 0xae, 0x91, 0x9f, 0x6e}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 28777; + uint8_t client_id_bytes[] = {0x2b, 0x33, 0xfa, 0xdf, 0xe6, 0x5b, 0x38, 0xe8, 0x1d, 0x1c, 0xbf, 0x8d, 0xa6, 0x9f, 0x4}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xb, 0x41, 0x25, 0x33, 0x15, 0x8d, 0xd7, 0x11, 0xca, 0xe8, 0x85, 0x9d, 0x6d, 0x26, + 0xc3, 0x10, 0xb1, 0x53, 0xa9, 0x2d, 0x73, 0xae, 0x6f, 0x74, 0xb1, 0x1f, 0x9, 0xb0}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\154\187ln", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "\147\234\128\171\v\219\164\138\218W\166", _willMsg = +// "\210\254\161\ENQ\v\192\253\DLE\176\204-\222Uv\154m\FSi+", _willProps = [PropAuthenticationData +// "\133\184W\221\160:\250\209q\DELF",PropMessageExpiryInterval 30765,PropTopicAlias 6533]}), _cleanSession = True, +// _keepAlive = 23669, _connID = +// "$\237\&8\219\166I\143>\251N\190&hL\173\150*\131\212>\211\244\SI\149\243\SYN\179\154\EOT", _properties = +// [PropContentType "\ETX\255)\146\212\218E8\SIt\STX}\203\215\210\DC3\ETB\248\216!\202\169Z\233\151",PropTopicAlias +// 13785,PropRequestProblemInformation 107,PropAssignedClientIdentifier "G\161\SYN\168[\154\210\195f\233n'"]} +TEST(Connect5QCTest, Encode22) { + uint8_t pkt[] = {0x10, 0x99, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x5c, 0x75, 0x30, 0x3, 0x0, + 0x19, 0x3, 0xff, 0x29, 0x92, 0xd4, 0xda, 0x45, 0x38, 0xf, 0x74, 0x2, 0x7d, 0xcb, 0xd7, 0xd2, + 0x13, 0x17, 0xf8, 0xd8, 0x21, 0xca, 0xa9, 0x5a, 0xe9, 0x97, 0x23, 0x35, 0xd9, 0x17, 0x6b, 0x12, + 0x0, 0xc, 0x47, 0xa1, 0x16, 0xa8, 0x5b, 0x9a, 0xd2, 0xc3, 0x66, 0xe9, 0x6e, 0x27, 0x0, 0x1d, + 0x24, 0xed, 0x38, 0xdb, 0xa6, 0x49, 0x8f, 0x3e, 0xfb, 0x4e, 0xbe, 0x26, 0x68, 0x4c, 0xad, 0x96, + 0x2a, 0x83, 0xd4, 0x3e, 0xd3, 0xf4, 0xf, 0x95, 0xf3, 0x16, 0xb3, 0x9a, 0x4, 0x16, 0x16, 0x0, + 0xb, 0x85, 0xb8, 0x57, 0xdd, 0xa0, 0x3a, 0xfa, 0xd1, 0x71, 0x7f, 0x46, 0x2, 0x0, 0x0, 0x78, + 0x2d, 0x23, 0x19, 0x85, 0x0, 0xb, 0x93, 0xea, 0x80, 0xab, 0xb, 0xdb, 0xa4, 0x8a, 0xda, 0x57, + 0xa6, 0x0, 0x13, 0xd2, 0xfe, 0xa1, 0x5, 0xb, 0xc0, 0xfd, 0x10, 0xb0, 0xcc, 0x2d, 0xde, 0x55, + 0x76, 0x9a, 0x6d, 0x1c, 0x69, 0x2b, 0x0, 0x4, 0x9a, 0xbb, 0x6c, 0x6e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x3, 0xff, 0x29, 0x92, 0xd4, 0xda, 0x45, 0x38, 0xf, 0x74, 0x2, 0x7d, 0xcb, + 0xd7, 0xd2, 0x13, 0x17, 0xf8, 0xd8, 0x21, 0xca, 0xa9, 0x5a, 0xe9, 0x97}; + uint8_t bytesprops1[] = {0x47, 0xa1, 0x16, 0xa8, 0x5b, 0x9a, 0xd2, 0xc3, 0x66, 0xe9, 0x6e, 0x27}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13785}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops1}}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x85, 0xb8, 0x57, 0xdd, 0xa0, 0x3a, 0xfa, 0xd1, 0x71, 0x7f, 0x46}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30765}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6533}}, + }; + + lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x93, 0xea, 0x80, 0xab, 0xb, 0xdb, 0xa4, 0x8a, 0xda, 0x57, 0xa6}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd2, 0xfe, 0xa1, 0x5, 0xb, 0xc0, 0xfd, 0x10, 0xb0, 0xcc, + 0x2d, 0xde, 0x55, 0x76, 0x9a, 0x6d, 0x1c, 0x69, 0x2b}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 23669; + uint8_t client_id_bytes[] = {0x24, 0xed, 0x38, 0xdb, 0xa6, 0x49, 0x8f, 0x3e, 0xfb, 0x4e, 0xbe, 0x26, 0x68, 0x4c, 0xad, + 0x96, 0x2a, 0x83, 0xd4, 0x3e, 0xd3, 0xf4, 0xf, 0x95, 0xf3, 0x16, 0xb3, 0x9a, 0x4}; + lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x9a, 0xbb, 0x6c, 0x6e}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\143,\SOH\155g\228PV\DC2<\233\167\240`\US", _password = Just +// "e\nm=f\140\230Dl\161\225\170\162v\164\EOTc\207\195\255\131n$G\179w", _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS2, _willTopic = "\178\225\170J\183\NAK\128\201\233\247\215q\NAK\v\165A\US\228", _willMsg = +// "-\155\216\170\221I\188\147:\179\167:", _willProps = []}), _cleanSession = False, _keepAlive = 24031, _connID = +// "\SI5", _properties = [PropSharedSubscriptionAvailable 174,PropMaximumQoS 176,PropCorrelationData "\216\189j, +// i0djrea&|L<\194\r\190\229\239\174\253\193\GS",PropAssignedClientIdentifier +// "\ESC\234\207\&0kQky\146\132\177R\173C",PropResponseTopic "\fS~\173\230d +// \178\175\197\251K\161I$\226\148\ETB\237g\137~R\US",PropRequestResponseInformation 150,PropServerKeepAlive +// 20269,PropReceiveMaximum 13007,PropSharedSubscriptionAvailable 86,PropWildcardSubscriptionAvailable +// 86,PropSubscriptionIdentifier 9,PropSharedSubscriptionAvailable 61,PropSharedSubscriptionAvailable +// 165,PropWildcardSubscriptionAvailable 74,PropResponseInformation +// "\"<\192&\ENQ\253\215\137-\245\236\US\252`\184\&1\DC3V\t\130d\201\EOTj7",PropRetainAvailable 228,PropUserProperty +// "\SI\224j^J'\204e\214\181\137\162\185}\182\221\204P\179.H" +// "el\244\142B\137C}\CAN+6,\DEL;hg\234\226\151\237\&7\168",PropMaximumQoS 67,PropRequestProblemInformation +// 72,PropAuthenticationMethod "\200C\DLET\192\226h\134\167KO\ACK\132f\US\237",PropCorrelationData +// "\232\251\196\248nH\158\ENQ\192\129\STX\240\203\STX\137w\128\FS.\134Z\NAK\165x\229\"\203\DC3:",PropAuthenticationMethod +// "\159k\224\206\DC2\176\US\183,\216\&7\175\161\150/\227\&7\250s\201\128$K\249\239\151",PropAssignedClientIdentifier +// "\DEL6=\143\SI\246\a\163r\SOH\217\NUL\EMnd!",PropMessageExpiryInterval 25593,PropMaximumPacketSize +// 24532,PropRequestProblemInformation 63,PropSubscriptionIdentifierAvailable 47,PropReceiveMaximum +// 22000,PropMaximumPacketSize 7757,PropRetainAvailable 32]} +TEST(Connect5QCTest, Encode23) { + uint8_t pkt[] = { + 0x10, 0x8d, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x5d, 0xdf, 0xad, 0x2, 0x2a, 0xae, 0x24, 0xb0, + 0x9, 0x0, 0x19, 0xd8, 0xbd, 0x6a, 0x2c, 0x20, 0x69, 0x30, 0x64, 0x6a, 0x72, 0x65, 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 10] = {0}; + uint8_t bytesprops0[] = {0xd8, 0xbd, 0x6a, 0x2c, 0x20, 0x69, 0x30, 0x64, 0x6a, 0x72, 0x65, 0x61, 0x26, + 0x7c, 0x4c, 0x3c, 0xc2, 0xd, 0xbe, 0xe5, 0xef, 0xae, 0xfd, 0xc1, 0x1d}; + uint8_t bytesprops1[] = {0x1b, 0xea, 0xcf, 0x30, 0x6b, 0x51, 0x6b, 0x79, 0x92, 0x84, 0xb1, 0x52, 0xad, 0x43}; + uint8_t bytesprops2[] = {0xc, 0x53, 0x7e, 0xad, 0xe6, 0x64, 0x20, 0xb2, 0xaf, 0xc5, 0xfb, 0x4b, + 0xa1, 0x49, 0x24, 0xe2, 0x94, 0x17, 0xed, 0x67, 0x89, 0x7e, 0x52, 0x1f}; + uint8_t bytesprops3[] = {0x22, 0x3c, 0xc0, 0x26, 0x5, 0xfd, 0xd7, 0x89, 0x2d, 0xf5, 0xec, 0x1f, 0xfc, + 0x60, 0xb8, 0x31, 0x13, 0x56, 0x9, 0x82, 0x64, 0xc9, 0x4, 0x6a, 0x37}; + uint8_t bytesprops5[] = {0x65, 0x6c, 0xf4, 0x8e, 0x42, 0x89, 0x43, 0x7d, 0x18, 0x2b, 0x36, + 0x2c, 0x7f, 0x3b, 0x68, 0x67, 0xea, 0xe2, 0x97, 0xed, 0x37, 0xa8}; + uint8_t bytesprops4[] = {0xf, 0xe0, 0x6a, 0x5e, 0x4a, 0x27, 0xcc, 0x65, 0xd6, 0xb5, 0x89, + 0xa2, 0xb9, 0x7d, 0xb6, 0xdd, 0xcc, 0x50, 0xb3, 0x2e, 0x48}; + uint8_t bytesprops6[] = {0xc8, 0x43, 0x10, 0x54, 0xc0, 0xe2, 0x68, 0x86, + 0xa7, 0x4b, 0x4f, 0x6, 0x84, 0x66, 0x1f, 0xed}; + uint8_t bytesprops7[] = {0xe8, 0xfb, 0xc4, 0xf8, 0x6e, 0x48, 0x9e, 0x5, 0xc0, 0x81, 0x2, 0xf0, 0xcb, 0x2, 0x89, + 0x77, 0x80, 0x1c, 0x2e, 0x86, 0x5a, 0x15, 0xa5, 0x78, 0xe5, 0x22, 0xcb, 0x13, 0x3a}; + uint8_t bytesprops8[] = {0x9f, 0x6b, 0xe0, 0xce, 0x12, 0xb0, 0x1f, 0xb7, 0x2c, 0xd8, 0x37, 0xaf, 0xa1, + 0x96, 0x2f, 0xe3, 0x37, 0xfa, 0x73, 0xc9, 0x80, 0x24, 0x4b, 0xf9, 0xef, 0x97}; + uint8_t bytesprops9[] = {0x7f, 0x36, 0x3d, 0x8f, 0xf, 0xf6, 0x7, 0xa3, 0x72, 0x1, 0xd9, 0x0, 0x19, 0x6e, 0x64, 0x21}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20269}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13007}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops4}, .v = {22, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 72}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25593}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24532}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 47}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22000}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7757}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 32}}, + }; + + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + + lwmqtt_property_t willpropslist[] = {}; + + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xb2, 0xe1, 0xaa, 0x4a, 0xb7, 0x15, 0x80, 0xc9, 0xe9, + 0xf7, 0xd7, 0x71, 0x15, 0xb, 0xa5, 0x41, 0x1f, 0xe4}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2d, 0x9b, 0xd8, 0xaa, 0xdd, 0x49, 0xbc, 0x93, 0x3a, 0xb3, 0xa7, 0x3a}; + lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS2; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 24031; + uint8_t client_id_bytes[] = {0xf, 0x35}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x8f, 0x2c, 0x1, 0x9b, 0x67, 0xe4, 0x50, 0x56, 0x12, 0x3c, 0xe9, 0xa7, 0xf0, 0x60, 0x1f}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x65, 0xa, 0x6d, 0x3d, 0x66, 0x8c, 0xe6, 0x44, 0x6c, 0xa1, 0xe1, 0xaa, 0xa2, + 0x76, 0xa4, 0x4, 0x63, 0xcf, 0xc3, 0xff, 0x83, 0x6e, 0x24, 0x47, 0xb3, 0x77}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\141\198\185\130\140v\STX\135\128\CAN", _lastWill = Just +// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "Y\242i\225Ly\163\177\f\138\135/TW\n\DC3\217\RS\251c\244\DLEs\CAN\178mU>\SO", _willMsg = "Z", _willProps = +// [PropSharedSubscriptionAvailable 173,PropRetainAvailable 148,PropAuthenticationData +// "l\225\ETX\t2\EOT>\248~\235\230\191\167\ACK\t\164\198\GS\NAK\243\165\128\130[1\181\210",PropContentType +// "`w\166Xy\224\226\193\153",PropAssignedClientIdentifier +// "!W\150o6\128\137\183\144\FS,c\227\144f\216\157",PropWillDelayInterval 23920,PropRetainAvailable +// 175,PropSharedSubscriptionAvailable 98,PropPayloadFormatIndicator 78,PropResponseInformation +// "\241^n}\171-\fv'\EOT\205_\177",PropAuthenticationMethod "\151,\142\177\133\213",PropServerKeepAlive +// 8086,PropSubscriptionIdentifierAvailable 121,PropMessageExpiryInterval 18973,PropTopicAlias +// 10091,PropMessageExpiryInterval 1594,PropServerKeepAlive 18996,PropWillDelayInterval 5991,PropContentType +// "\ETX\SOH\159Wp\214\187\176\246\166\185\235}\154\141s\178G\208G",PropRequestResponseInformation +// 14,PropMaximumPacketSize 23991,PropMessageExpiryInterval 21828,PropPayloadFormatIndicator +// 18,PropSessionExpiryInterval 24926]}), _cleanSession = True, _keepAlive = 14148, _connID = +// "hRi\ESC\170\202\226\252\ACK\209\SYN\222k\188", _properties = [PropTopicAliasMaximum +// 25143,PropAssignedClientIdentifier +// "\182\214\141\162k(\231?\161I\168\189\220\236\DC4\DLE\131\240!Z\166\183p\a_",PropRetainAvailable +// 207,PropRetainAvailable 84,PropTopicAlias 30203]} +TEST(Connect5QCTest, Encode24) { + uint8_t pkt[] = {0x10, 0x9b, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x66, 0x37, 0x44, 0x26, 0x22, 0x62, 0x37, + 0x12, 0x0, 0x19, 0xb6, 0xd6, 0x8d, 0xa2, 0x6b, 0x28, 0xe7, 0x3f, 0xa1, 0x49, 0xa8, 0xbd, 0xdc, 0xec, + 0x14, 0x10, 0x83, 0xf0, 0x21, 0x5a, 0xa6, 0xb7, 0x70, 0x7, 0x5f, 0x25, 0xcf, 0x25, 0x54, 0x23, 0x75, + 0xfb, 0x0, 0xe, 0x68, 0x52, 0x69, 0x1b, 0xaa, 0xca, 0xe2, 0xfc, 0x6, 0xd1, 0x16, 0xde, 0x6b, 0xbc, + 0xaa, 0x1, 0x2a, 0xad, 0x25, 0x94, 0x16, 0x0, 0x1b, 0x6c, 0xe1, 0x3, 0x9, 0x32, 0x4, 0x3e, 0xf8, + 0x7e, 0xeb, 0xe6, 0xbf, 0xa7, 0x6, 0x9, 0xa4, 0xc6, 0x1d, 0x15, 0xf3, 0xa5, 0x80, 0x82, 0x5b, 0x31, + 0xb5, 0xd2, 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ytesprops0[] = {0xb6, 0xd6, 0x8d, 0xa2, 0x6b, 0x28, 0xe7, 0x3f, 0xa1, 0x49, 0xa8, 0xbd, 0xdc, + 0xec, 0x14, 0x10, 0x83, 0xf0, 0x21, 0x5a, 0xa6, 0xb7, 0x70, 0x7, 0x5f}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25143}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30203}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x6c, 0xe1, 0x3, 0x9, 0x32, 0x4, 0x3e, 0xf8, 0x7e, 0xeb, 0xe6, 0xbf, 0xa7, 0x6, + 0x9, 0xa4, 0xc6, 0x1d, 0x15, 0xf3, 0xa5, 0x80, 0x82, 0x5b, 0x31, 0xb5, 0xd2}; + uint8_t byteswillprops1[] = {0x60, 0x77, 0xa6, 0x58, 0x79, 0xe0, 0xe2, 0xc1, 0x99}; + uint8_t byteswillprops2[] = {0x21, 0x57, 0x96, 0x6f, 0x36, 0x80, 0x89, 0xb7, 0x90, + 0x1c, 0x2c, 0x63, 0xe3, 0x90, 0x66, 0xd8, 0x9d}; + uint8_t byteswillprops3[] = {0xf1, 0x5e, 0x6e, 0x7d, 0xab, 0x2d, 0xc, 0x76, 0x27, 0x4, 0xcd, 0x5f, 0xb1}; + uint8_t byteswillprops4[] = {0x97, 0x2c, 0x8e, 0xb1, 0x85, 0xd5}; + uint8_t byteswillprops5[] = {0x3, 0x1, 0x9f, 0x57, 0x70, 0xd6, 0xbb, 0xb0, 0xf6, 0xa6, + 0xb9, 0xeb, 0x7d, 0x9a, 0x8d, 0x73, 0xb2, 0x47, 0xd0, 0x47}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23920}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8086}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18973}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10091}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1594}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18996}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5991}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23991}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21828}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24926}}, + }; + + lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x59, 0xf2, 0x69, 0xe1, 0x4c, 0x79, 0xa3, 0xb1, 0xc, 0x8a, 0x87, 0x2f, 0x54, 0x57, 0xa, + 0x13, 0xd9, 0x1e, 0xfb, 0x63, 0xf4, 0x10, 0x73, 0x18, 0xb2, 0x6d, 0x55, 0x3e, 0xe}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5a}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 14148; + uint8_t client_id_bytes[] = {0x68, 0x52, 0x69, 0x1b, 0xaa, 0xca, 0xe2, 0xfc, 0x6, 0xd1, 0x16, 0xde, 0x6b, 0xbc}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x8d, 0xc6, 0xb9, 0x82, 0x8c, 0x76, 0x2, 0x87, 0x80, 0x18}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Nothing, _password = Just "\167\155\251\197h\150N", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS1, _willTopic = "'m\f$\SI\138a\SInjUa;\229\155Z\157\&2", _willMsg = +// "94H\150\255\251\134\159\242\&1H", _willProps = [PropSubscriptionIdentifier 5,PropResponseTopic +// "h\STXD1\243\FS\186\195\&7\200\191\134\187\DC3\157\158^\188\SIQ\151\&9\182_\bN$M",PropMessageExpiryInterval +// 24513,PropTopicAliasMaximum 1955,PropSubscriptionIdentifierAvailable 212,PropServerReference +// "M[\201NC\169\SO\195\194l\138$$\169\167\US\v"]}), _cleanSession = True, _keepAlive = 31273, _connID = +// "\211\132J\179\217\&3\245\247\151\a\182", _properties = [PropRequestProblemInformation 110,PropReceiveMaximum +// 4976,PropServerKeepAlive 27226,PropWildcardSubscriptionAvailable 69,PropSubscriptionIdentifier 6]} +TEST(Connect5QCTest, Encode25) { + uint8_t pkt[] = {0x10, 0x8e, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x6e, 0x7a, 0x29, 0xc, 0x17, 0x6e, 0x21, + 0x13, 0x70, 0x13, 0x6a, 0x5a, 0x28, 0x45, 0xb, 0x6, 0x0, 0xb, 0xd3, 0x84, 0x4a, 0xb3, 0xd9, 0x33, + 0xf5, 0xf7, 0x97, 0x7, 0xb6, 0x3f, 0xb, 0x5, 0x8, 0x0, 0x1c, 0x68, 0x2, 0x44, 0x31, 0xf3, 0x1c, + 0xba, 0xc3, 0x37, 0xc8, 0xbf, 0x86, 0xbb, 0x13, 0x9d, 0x9e, 0x5e, 0xbc, 0xf, 0x51, 0x97, 0x39, 0xb6, + 0x5f, 0x8, 0x4e, 0x24, 0x4d, 0x2, 0x0, 0x0, 0x5f, 0xc1, 0x22, 0x7, 0xa3, 0x29, 0xd4, 0x1c, 0x0, + 0x11, 0x4d, 0x5b, 0xc9, 0x4e, 0x43, 0xa9, 0xe, 0xc3, 0xc2, 0x6c, 0x8a, 0x24, 0x24, 0xa9, 0xa7, 0x1f, + 0xb, 0x0, 0x12, 0x27, 0x6d, 0xc, 0x24, 0xf, 0x8a, 0x61, 0xf, 0x6e, 0x6a, 0x55, 0x61, 0x3b, 0xe5, + 0x9b, 0x5a, 0x9d, 0x32, 0x0, 0xb, 0x39, 0x34, 0x48, 0x96, 0xff, 0xfb, 0x86, 0x9f, 0xf2, 0x31, 0x48, + 0x0, 0x7, 0xa7, 0x9b, 0xfb, 0xc5, 0x68, 0x96, 0x4e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4976}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27226}}, {.prop = (lwmqtt_prop_t)40, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + }; + + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x68, 0x2, 0x44, 0x31, 0xf3, 0x1c, 0xba, 0xc3, 0x37, 0xc8, 0xbf, 0x86, 0xbb, 0x13, + 0x9d, 0x9e, 0x5e, 0xbc, 0xf, 0x51, 0x97, 0x39, 0xb6, 0x5f, 0x8, 0x4e, 0x24, 0x4d}; + uint8_t byteswillprops1[] = {0x4d, 0x5b, 0xc9, 0x4e, 0x43, 0xa9, 0xe, 0xc3, 0xc2, + 0x6c, 0x8a, 0x24, 0x24, 0xa9, 0xa7, 0x1f, 0xb}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24513}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1955}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops1}}}, + }; + + lwmqtt_properties_t willprops = {6, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x27, 0x6d, 0xc, 0x24, 0xf, 0x8a, 0x61, 0xf, 0x6e, + 0x6a, 0x55, 0x61, 0x3b, 0xe5, 0x9b, 0x5a, 0x9d, 0x32}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x39, 0x34, 0x48, 0x96, 0xff, 0xfb, 0x86, 0x9f, 0xf2, 0x31, 0x48}; + lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 31273; + uint8_t client_id_bytes[] = {0xd3, 0x84, 0x4a, 0xb3, 0xd9, 0x33, 0xf5, 0xf7, 0x97, 0x7, 0xb6}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0xa7, 0x9b, 0xfb, 0xc5, 0x68, 0x96, 0x4e}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\152", _password = Just +// "\174\152x,\214O\183\249,o\"\137\170m\244\164\203\ACK\186\179\217@ _[\r>", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS1, _willTopic = "A\SUB\166x\NUL", _willMsg = "\253\&0\131n\162\236\192\DEL \150.\SI\174\163", +// _willProps = [PropTopicAliasMaximum 29074,PropResponseInformation +// "\DC1:\215Jj/]\232k\GS\185\209r\148L\ETB\180{\254D\189\248\b\208\227",PropMessageExpiryInterval +// 29782,PropAssignedClientIdentifier "H\DC1\STXQ>9H\GS\129\243\199\238\168\&7a",PropSessionExpiryInterval +// 30959,PropMessageExpiryInterval 28052,PropTopicAlias 24618,PropRequestProblemInformation 237,PropServerReference +// "Pq#\186\195\246\&8*\132\&1\240]\167E\139\236\NAK\253\EM\130\178\SOSF\RS\146\v>e\147",PropMaximumPacketSize +// 15564,PropCorrelationData "\174\232\166+\155\182\172\ACKX\ACK\154\190\206\182",PropTopicAlias 28312,PropTopicAlias +// 21162,PropMaximumPacketSize 29667,PropSharedSubscriptionAvailable 101,PropTopicAlias 5194,PropCorrelationData +// "\153{\152\231A\216\226\146\ACK\247h9C\194\233",PropPayloadFormatIndicator 112,PropAssignedClientIdentifier +// "@\204\136\246\229\209{c\233\n",PropSubscriptionIdentifierAvailable 156]}), _cleanSession = True, _keepAlive = 11096, +// _connID = "\207\r\183\&5c`\208+\186d/\132'X\238\247\DLEO\130\241\201\158\234", _properties = [PropCorrelationData +// "\248\DC1\135`\136\191\f\199\169>\EMt\SUB\CAN\145I\181\216&",PropUserProperty +// "\DC2\v\219\&7K\147\nL\189\219\163\230\166$\ETB\214kc\178r\236s\231" +// "\140A\244\133\155O\224x\US\138\221\153\176\216\132,\SOH\236\129\253\DELb",PropResponseTopic +// "\213\219nQ/\210@y\173\191\178bk\USs\SOH\197",PropUserProperty "\187\232\149z\147\STXw\178\188;\253" +// "\225W^\187\201n&\t!0\131~\218\ACK\173W]\188\188\f\192\143\SOH\NULBs\160}\154",PropSubscriptionIdentifierAvailable +// 80,PropMaximumQoS 214,PropMaximumPacketSize 30233,PropResponseInformation +// "\186N\SOT\202\163\f\144\241f\130\&5\153:",PropMaximumPacketSize 30201,PropUserProperty +// "\ESC\174\231\185y\167\182E\EM\ESC\DC23p\233\181H\DLE\166\216" +// "3\145\253\180\213\174\228P\n\208\181\SI\146\231I",PropTopicAlias 6216,PropSubscriptionIdentifierAvailable +// 68,PropCorrelationData +// "X\172\&5\ESC\224k`P\USX[\219te\183\188\134\224\227\192\SIT\156\243<\152",PropAuthenticationData +// "\164\248\165\169\&4_\146\230~\143GG\ESC\231\a\221\209\202\223\&8\185db\155>\RS\208\161\US",PropRequestProblemInformation +// 252,PropRequestResponseInformation 153,PropServerKeepAlive 26215,PropServerKeepAlive 322,PropResponseInformation +// "Q\NUL&\198\EMn\165\222\239\160\190\130\186\232\170\225/\\\189\DC1",PropSharedSubscriptionAvailable +// 226,PropRequestProblemInformation 166,PropSharedSubscriptionAvailable 58,PropResponseTopic +// "\149\168\171_s\164\&1S\160\208#C|\195\201\194",PropAuthenticationMethod +// "\176\186\181\ACK\250\218\CAN\ETB\DC3\170\148\ETB",PropMaximumPacketSize 25408,PropAuthenticationMethod +// "^\209\215\243\225]\184n\157\174>\226w@<\228\196\GS\145",PropMaximumPacketSize 28989,PropUserProperty +// "\208\141rK\240\232\NAK" "\SOHZn +// \SYN\219\&7uu<\255\179\DC3r&\152p\166\233\154!L\SUB\SOH!Q\157\135/",PropReceiveMaximum 22326,PropAuthenticationMethod +// "u\191\238\160\165\SUB"]} +TEST(Connect5QCTest, Encode26) { + uint8_t pkt[] = { + 0x10, 0xbc, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x2b, 0x58, 0xaf, 0x3, 0x9, 0x0, 0x13, 0xf8, + 0x11, 0x87, 0x60, 0x88, 0xbf, 0xc, 0xc7, 0xa9, 0x3e, 0x19, 0x74, 0x1a, 0x18, 0x91, 0x49, 0xb5, 0xd8, 0x26, 0x26, + 0x0, 0x17, 0x12, 0xb, 0xdb, 0x37, 0x4b, 0x93, 0xa, 0x4c, 0xbd, 0xdb, 0xa3, 0xe6, 0xa6, 0x24, 0x17, 0xd6, 0x6b, + 0x63, 0xb2, 0x72, 0xec, 0x73, 0xe7, 0x0, 0x16, 0x8c, 0x41, 0xf4, 0x85, 0x9b, 0x4f, 0xe0, 0x78, 0x1f, 0x8a, 0xdd, + 0x99, 0xb0, 0xd8, 0x84, 0x2c, 0x1, 0xec, 0x81, 0xfd, 0x7f, 0x62, 0x8, 0x0, 0x11, 0xd5, 0xdb, 0x6e, 0x51, 0x2f, + 0xd2, 0x40, 0x79, 0xad, 0xbf, 0xb2, 0x62, 0x6b, 0x1f, 0x73, 0x1, 0xc5, 0x26, 0x0, 0xb, 0xbb, 0xe8, 0x95, 0x7a, + 0x93, 0x2, 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0x98, 0x78, 0x2c, 0xd6, 0x4f, 0xb7, 0xf9, + 0x2c, 0x6f, 0x22, 0x89, 0xaa, 0x6d, 0xf4, 0xa4, 0xcb, 0x6, 0xba, 0xb3, 0xd9, 0x40, 0x20, 0x5f, 0x5b, 0xd, 0x3e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf8, 0x11, 0x87, 0x60, 0x88, 0xbf, 0xc, 0xc7, 0xa9, 0x3e, + 0x19, 0x74, 0x1a, 0x18, 0x91, 0x49, 0xb5, 0xd8, 0x26}; + uint8_t bytesprops2[] = {0x8c, 0x41, 0xf4, 0x85, 0x9b, 0x4f, 0xe0, 0x78, 0x1f, 0x8a, 0xdd, + 0x99, 0xb0, 0xd8, 0x84, 0x2c, 0x1, 0xec, 0x81, 0xfd, 0x7f, 0x62}; + uint8_t bytesprops1[] = {0x12, 0xb, 0xdb, 0x37, 0x4b, 0x93, 0xa, 0x4c, 0xbd, 0xdb, 0xa3, 0xe6, + 0xa6, 0x24, 0x17, 0xd6, 0x6b, 0x63, 0xb2, 0x72, 0xec, 0x73, 0xe7}; + uint8_t bytesprops3[] = {0xd5, 0xdb, 0x6e, 0x51, 0x2f, 0xd2, 0x40, 0x79, 0xad, + 0xbf, 0xb2, 0x62, 0x6b, 0x1f, 0x73, 0x1, 0xc5}; + uint8_t bytesprops5[] = {0xe1, 0x57, 0x5e, 0xbb, 0xc9, 0x6e, 0x26, 0x9, 0x21, 0x30, 0x83, 0x7e, 0xda, 0x6, 0xad, + 0x57, 0x5d, 0xbc, 0xbc, 0xc, 0xc0, 0x8f, 0x1, 0x0, 0x42, 0x73, 0xa0, 0x7d, 0x9a}; + uint8_t bytesprops4[] = {0xbb, 0xe8, 0x95, 0x7a, 0x93, 0x2, 0x77, 0xb2, 0xbc, 0x3b, 0xfd}; + uint8_t bytesprops6[] = {0xba, 0x4e, 0xe, 0x54, 0xca, 0xa3, 0xc, 0x90, 0xf1, 0x66, 0x82, 0x35, 0x99, 0x3a}; + uint8_t bytesprops8[] = {0x33, 0x91, 0xfd, 0xb4, 0xd5, 0xae, 0xe4, 0x50, 0xa, 0xd0, 0xb5, 0xf, 0x92, 0xe7, 0x49}; + uint8_t bytesprops7[] = {0x1b, 0xae, 0xe7, 0xb9, 0x79, 0xa7, 0xb6, 0x45, 0x19, 0x1b, + 0x12, 0x33, 0x70, 0xe9, 0xb5, 0x48, 0x10, 0xa6, 0xd8}; + uint8_t bytesprops9[] = {0x58, 0xac, 0x35, 0x1b, 0xe0, 0x6b, 0x60, 0x50, 0x1f, 0x58, 0x5b, 0xdb, 0x74, + 0x65, 0xb7, 0xbc, 0x86, 0xe0, 0xe3, 0xc0, 0xf, 0x54, 0x9c, 0xf3, 0x3c, 0x98}; + uint8_t bytesprops10[] = {0xa4, 0xf8, 0xa5, 0xa9, 0x34, 0x5f, 0x92, 0xe6, 0x7e, 0x8f, 0x47, 0x47, 0x1b, 0xe7, 0x7, + 0xdd, 0xd1, 0xca, 0xdf, 0x38, 0xb9, 0x64, 0x62, 0x9b, 0x3e, 0x1e, 0xd0, 0xa1, 0x1f}; + uint8_t bytesprops11[] = {0x51, 0x0, 0x26, 0xc6, 0x19, 0x6e, 0xa5, 0xde, 0xef, 0xa0, + 0xbe, 0x82, 0xba, 0xe8, 0xaa, 0xe1, 0x2f, 0x5c, 0xbd, 0x11}; + uint8_t bytesprops12[] = {0x95, 0xa8, 0xab, 0x5f, 0x73, 0xa4, 0x31, 0x53, + 0xa0, 0xd0, 0x23, 0x43, 0x7c, 0xc3, 0xc9, 0xc2}; + uint8_t bytesprops13[] = {0xb0, 0xba, 0xb5, 0x6, 0xfa, 0xda, 0x18, 0x17, 0x13, 0xaa, 0x94, 0x17}; + uint8_t bytesprops14[] = {0x5e, 0xd1, 0xd7, 0xf3, 0xe1, 0x5d, 0xb8, 0x6e, 0x9d, 0xae, + 0x3e, 0xe2, 0x77, 0x40, 0x3c, 0xe4, 0xc4, 0x1d, 0x91}; + uint8_t bytesprops16[] = {0x1, 0x5a, 0x6e, 0x20, 0x16, 0xdb, 0x37, 0x75, 0x75, 0x3c, 0xff, 0xb3, 0x13, 0x72, 0x26, + 0x98, 0x70, 0xa6, 0xe9, 0x9a, 0x21, 0x4c, 0x1a, 0x1, 0x21, 0x51, 0x9d, 0x87, 0x2f}; + uint8_t bytesprops15[] = {0xd0, 0x8d, 0x72, 0x4b, 0xf0, 0xe8, 0x15}; + uint8_t bytesprops17[] = {0x75, 0xbf, 0xee, 0xa0, 0xa5, 0x1a}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops1}, .v = {22, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops4}, .v = {29, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30233}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30201}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops7}, .v = {15, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6216}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26215}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 322}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25408}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28989}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops15}, .v = {29, (char*)&bytesprops16}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22326}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops17}}}, + }; + + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x11, 0x3a, 0xd7, 0x4a, 0x6a, 0x2f, 0x5d, 0xe8, 0x6b, 0x1d, 0xb9, 0xd1, 0x72, + 0x94, 0x4c, 0x17, 0xb4, 0x7b, 0xfe, 0x44, 0xbd, 0xf8, 0x8, 0xd0, 0xe3}; + uint8_t byteswillprops1[] = {0x48, 0x11, 0x2, 0x51, 0x3e, 0x39, 0x48, 0x1d, 0x81, 0xf3, 0xc7, 0xee, 0xa8, 0x37, 0x61}; + uint8_t byteswillprops2[] = {0x50, 0x71, 0x23, 0xba, 0xc3, 0xf6, 0x38, 0x2a, 0x84, 0x31, + 0xf0, 0x5d, 0xa7, 0x45, 0x8b, 0xec, 0x15, 0xfd, 0x19, 0x82, + 0xb2, 0xe, 0x53, 0x46, 0x1e, 0x92, 0xb, 0x3e, 0x65, 0x93}; + uint8_t byteswillprops3[] = {0xae, 0xe8, 0xa6, 0x2b, 0x9b, 0xb6, 0xac, 0x6, 0x58, 0x6, 0x9a, 0xbe, 0xce, 0xb6}; + uint8_t byteswillprops4[] = {0x99, 0x7b, 0x98, 0xe7, 0x41, 0xd8, 0xe2, 0x92, 0x6, 0xf7, 0x68, 0x39, 0x43, 0xc2, 0xe9}; + uint8_t byteswillprops5[] = {0x40, 0xcc, 0x88, 0xf6, 0xe5, 0xd1, 0x7b, 0x63, 0xe9, 0xa}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29074}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29782}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30959}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28052}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24618}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15564}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28312}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21162}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29667}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5194}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 156}}, + }; + + lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x41, 0x1a, 0xa6, 0x78, 0x0}; + lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfd, 0x30, 0x83, 0x6e, 0xa2, 0xec, 0xc0, 0x7f, 0x20, 0x96, 0x2e, 0xf, 0xae, 0xa3}; + lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 11096; + uint8_t client_id_bytes[] = {0xcf, 0xd, 0xb7, 0x35, 0x63, 0x60, 0xd0, 0x2b, 0xba, 0x64, 0x2f, 0x84, + 0x27, 0x58, 0xee, 0xf7, 0x10, 0x4f, 0x82, 0xf1, 0xc9, 0x9e, 0xea}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x98}; + lwmqtt_string_t username = {1, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xae, 0x98, 0x78, 0x2c, 0xd6, 0x4f, 0xb7, 0xf9, 0x2c, 0x6f, 0x22, 0x89, 0xaa, 0x6d, + 0xf4, 0xa4, 0xcb, 0x6, 0xba, 0xb3, 0xd9, 0x40, 0x20, 0x5f, 0x5b, 0xd, 0x3e}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\254\216\220\247\151\136\DC1\188~L\248\142", _password = Nothing, _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "U6Dw\178\166\201q\230\187\STX\187>P\180\&1\224[W\181\GS:", _willMsg = "", _willProps = [PropSubscriptionIdentifier +// 25,PropAuthenticationMethod "E\191\190\250<\151\DC1\DC4\224\176\SIg\150",PropMaximumQoS 137,PropTopicAlias +// 21105,PropReceiveMaximum 18226,PropTopicAliasMaximum 5839,PropAssignedClientIdentifier +// "\242D",PropRequestResponseInformation 6,PropPayloadFormatIndicator 144,PropSessionExpiryInterval 500,PropContentType +// "\135F\188K&\177\206-g\SO\EOT\249\143VE+B\196@P5\EOT\230\a\185\228\EM\130",PropRetainAvailable 6,PropServerReference +// "cA\195\179\&0\173\173\220=%;\f\139\158M",PropReasonString "\247Ir\176\"l\128",PropReasonString +// "\179D\192\169\242fb\b-\192\NAK",PropMaximumPacketSize 10906]}), _cleanSession = False, _keepAlive = 29562, _connID = +// "~\233\223\144\214,\GSg\DLE\144\196=<", _properties = [PropSharedSubscriptionAvailable 138,PropWillDelayInterval +// 12879,PropServerKeepAlive 6550,PropReceiveMaximum 10913,PropUserProperty "\234:\143a_\244\"\244\STX3\240\220y\141" +// "!\FS\166\169\238\145\136)\239\199*\208a\175\225\171\230\238\194\144n\ACK\SOH\174\178",PropMessageExpiryInterval +// 30709,PropSharedSubscriptionAvailable 102,PropAuthenticationMethod +// "b0\181\226\ENQ\130\189uwJ\166/\178\176\SOH=\205\&1\240E\190\164\r8G*B"]} +TEST(Connect5QCTest, Encode27) { + uint8_t pkt[] = {0x10, 0x9c, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8c, 0x73, 0x7a, 0x5e, 0x2a, 0x8a, 0x18, + 0x0, 0x0, 0x32, 0x4f, 0x13, 0x19, 0x96, 0x21, 0x2a, 0xa1, 0x26, 0x0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x9e, 0x4d, 0x1f, 0x0, 0x7, + 0xf7, 0x49, 0x72, 0xb0, 0x22, 0x6c, 0x80, 0x1f, 0x0, 0xb, 0xb3, 0x44, 0xc0, 0xa9, 0xf2, 0x66, 0x62, + 0x8, 0x2d, 0xc0, 0x15, 0x27, 0x0, 0x0, 0x2a, 0x9a, 0x0, 0x16, 0x55, 0x36, 0x44, 0x77, 0xb2, 0xa6, + 0xc9, 0x71, 0xe6, 0xbb, 0x2, 0xbb, 0x3e, 0x50, 0xb4, 0x31, 0xe0, 0x5b, 0x57, 0xb5, 0x1d, 0x3a, 0x0, + 0x0, 0x0, 0xc, 0xfe, 0xd8, 0xdc, 0xf7, 0x97, 0x88, 0x11, 0xbc, 0x7e, 0x4c, 0xf8, 0x8e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x21, 0x1c, 0xa6, 0xa9, 0xee, 0x91, 0x88, 0x29, 0xef, 0xc7, 0x2a, 0xd0, 0x61, + 0xaf, 0xe1, 0xab, 0xe6, 0xee, 0xc2, 0x90, 0x6e, 0x6, 0x1, 0xae, 0xb2}; + uint8_t bytesprops0[] = {0xea, 0x3a, 0x8f, 0x61, 0x5f, 0xf4, 0x22, 0xf4, 0x2, 0x33, 0xf0, 0xdc, 0x79, 0x8d}; + uint8_t bytesprops2[] = {0x62, 0x30, 0xb5, 0xe2, 0x5, 0x82, 0xbd, 0x75, 0x77, 0x4a, 0xa6, 0x2f, 0xb2, 0xb0, + 0x1, 0x3d, 0xcd, 0x31, 0xf0, 0x45, 0xbe, 0xa4, 0xd, 0x38, 0x47, 0x2a, 0x42}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12879}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6550}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10913}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30709}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops2}}}, + }; + + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x45, 0xbf, 0xbe, 0xfa, 0x3c, 0x97, 0x11, 0x14, 0xe0, 0xb0, 0xf, 0x67, 0x96}; + uint8_t byteswillprops1[] = {0xf2, 0x44}; + uint8_t byteswillprops2[] = {0x87, 0x46, 0xbc, 0x4b, 0x26, 0xb1, 0xce, 0x2d, 0x67, 0xe, 0x4, 0xf9, 0x8f, 0x56, + 0x45, 0x2b, 0x42, 0xc4, 0x40, 0x50, 0x35, 0x4, 0xe6, 0x7, 0xb9, 0xe4, 0x19, 0x82}; + uint8_t byteswillprops3[] = {0x63, 0x41, 0xc3, 0xb3, 0x30, 0xad, 0xad, 0xdc, 0x3d, 0x25, 0x3b, 0xc, 0x8b, 0x9e, 0x4d}; + uint8_t byteswillprops4[] = {0xf7, 0x49, 0x72, 0xb0, 0x22, 0x6c, 0x80}; + uint8_t byteswillprops5[] = {0xb3, 0x44, 0xc0, 0xa9, 0xf2, 0x66, 0x62, 0x8, 0x2d, 0xc0, 0x15}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21105}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18226}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5839}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 500}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10906}}, + }; + + lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x55, 0x36, 0x44, 0x77, 0xb2, 0xa6, 0xc9, 0x71, 0xe6, 0xbb, 0x2, + 0xbb, 0x3e, 0x50, 0xb4, 0x31, 0xe0, 0x5b, 0x57, 0xb5, 0x1d, 0x3a}; + lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0}; + lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 29562; + uint8_t client_id_bytes[] = {0x7e, 0xe9, 0xdf, 0x90, 0xd6, 0x2c, 0x1d, 0x67, 0x10, 0x90, 0xc4, 0x3d, 0x3c}; + lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xfe, 0xd8, 0xdc, 0xf7, 0x97, 0x88, 0x11, 0xbc, 0x7e, 0x4c, 0xf8, 0x8e}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "W\NAK1\208\fP\SYN\143\223", _password = Just +// "-\161\CAN\233\GSA\129\195n,\214\STX\138", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, +// _willTopic = "\163", _willMsg = "^\216\194\&8-V`\191\"\215\247\221\210\t\EOT\SOt\209\205\SI\SO", _willProps = +// [PropContentType "\193\248h\151I\195\152\213\179o\200\169\171^M",PropMaximumPacketSize 9787,PropRetainAvailable +// 109,PropMaximumQoS 223,PropAuthenticationMethod +// "\187G\SYN\192>Z\DEL\211\206\248I@\161c7\149\f\162+\202\129\SI\EOT\176}1$\213\210",PropContentType +// "\135\DC2,=:\ACK\224H\176\207\131\142\240\151\208.",PropReasonString +// "\134_\167\DLE\234",PropSubscriptionIdentifierAvailable 104,PropContentType +// "\150\158\135\212g\132\145\246_5\255!\"g*",PropTopicAliasMaximum 597,PropAuthenticationMethod +// "m\218\166/;\223-\DC2Q\255\150\144\152\242\251\132\223\t\156\212\190ej\217W\n\218\134\182",PropMaximumPacketSize +// 28656,PropRequestResponseInformation 219]}), _cleanSession = True, _keepAlive = 7229, _connID = +// "h$3\ESC%\229\134-\RS\205O", _properties = [PropMessageExpiryInterval 23408]} +TEST(Connect5QCTest, Encode28) { + uint8_t pkt[] = {0x10, 0xe7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x1c, 0x3d, 0x5, 0x2, 0x0, 0x0, + 0x5b, 0x70, 0x0, 0xb, 0x68, 0x24, 0x33, 0x1b, 0x25, 0xe5, 0x86, 0x2d, 0x1e, 0xcd, 0x4f, 0x94, 0x1, + 0x3, 0x0, 0xf, 0xc1, 0xf8, 0x68, 0x97, 0x49, 0xc3, 0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6e, 0x2c, 0xd6, 0x2, 0x8a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23408}}, + }; + + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0xc1, 0xf8, 0x68, 0x97, 0x49, 0xc3, 0x98, 0xd5, + 0xb3, 0x6f, 0xc8, 0xa9, 0xab, 0x5e, 0x4d}; + uint8_t byteswillprops1[] = {0xbb, 0x47, 0x16, 0xc0, 0x3e, 0x5a, 0x7f, 0xd3, 0xce, 0xf8, 0x49, 0x40, 0xa1, 0x63, 0x37, + 0x95, 0xc, 0xa2, 0x2b, 0xca, 0x81, 0xf, 0x4, 0xb0, 0x7d, 0x31, 0x24, 0xd5, 0xd2}; + uint8_t byteswillprops2[] = {0x87, 0x12, 0x2c, 0x3d, 0x3a, 0x6, 0xe0, 0x48, + 0xb0, 0xcf, 0x83, 0x8e, 0xf0, 0x97, 0xd0, 0x2e}; + uint8_t byteswillprops3[] = {0x86, 0x5f, 0xa7, 0x10, 0xea}; + uint8_t byteswillprops4[] = {0x96, 0x9e, 0x87, 0xd4, 0x67, 0x84, 0x91, 0xf6, + 0x5f, 0x35, 0xff, 0x21, 0x22, 0x67, 0x2a}; + uint8_t byteswillprops5[] = {0x6d, 0xda, 0xa6, 0x2f, 0x3b, 0xdf, 0x2d, 0x12, 0x51, 0xff, 0x96, 0x90, 0x98, 0xf2, 0xfb, + 0x84, 0xdf, 0x9, 0x9c, 0xd4, 0xbe, 0x65, 0x6a, 0xd9, 0x57, 0xa, 0xda, 0x86, 0xb6}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9787}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 597}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28656}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, + }; + + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa3}; + lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5e, 0xd8, 0xc2, 0x38, 0x2d, 0x56, 0x60, 0xbf, 0x22, 0xd7, 0xf7, + 0xdd, 0xd2, 0x9, 0x4, 0xe, 0x74, 0xd1, 0xcd, 0xf, 0xe}; + lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 7229; + uint8_t client_id_bytes[] = {0x68, 0x24, 0x33, 0x1b, 0x25, 0xe5, 0x86, 0x2d, 0x1e, 0xcd, 0x4f}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x57, 0x15, 0x31, 0xd0, 0xc, 0x50, 0x16, 0x8f, 0xdf}; + lwmqtt_string_t username = {9, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x2d, 0xa1, 0x18, 0xe9, 0x1d, 0x41, 0x81, 0xc3, 0x6e, 0x2c, 0xd6, 0x2, 0x8a}; + lwmqtt_string_t password = {13, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "E\158", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS0, _willTopic = "\SUB\167\200rR\DEL\237>\147\&3\t-\134,", _willMsg = +// "\EOT{\DC2S\216=\181\216\SOH\225\153\&6(\205\197\&1\ETX\STX\DEL", _willProps = [PropAssignedClientIdentifier +// "\128\147\216",PropResponseTopic "\223\n\ETX\154",PropAuthenticationMethod "",PropMessageExpiryInterval +// 25357,PropRetainAvailable 106,PropUserProperty "\143\RS=-\160\211kh/\145\222\245Y_P\b" +// "\230v\246\"\\",PropRequestProblemInformation 234,PropResponseTopic ",",PropMaximumPacketSize +// 5551,PropSessionExpiryInterval 17112,PropSharedSubscriptionAvailable 218,PropReceiveMaximum +// 12477,PropSharedSubscriptionAvailable 247]}), _cleanSession = True, _keepAlive = 27479, _connID = +// "\237\&2\143\179g\138\189\190\155l\NUL\242~\ETXJ\222^\147-\STX\140\210\198a\249", _properties = [PropRetainAvailable +// 170,PropRequestProblemInformation 45,PropAssignedClientIdentifier +// "\234\177`\245r\153\235\130\209\227-\190a\208\n\195\141\188\RSD",PropRequestResponseInformation 3]} +TEST(Connect5QCTest, Encode29) { + uint8_t pkt[] = {0x10, 0xb5, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x86, 0x6b, 0x57, 0x1d, 0x25, 0xaa, 0x17, + 0x2d, 0x12, 0x0, 0x14, 0xea, 0xb1, 0x60, 0xf5, 0x72, 0x99,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tt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 3}}, + }; + + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x80, 0x93, 0xd8}; + uint8_t byteswillprops1[] = {0xdf, 0xa, 0x3, 0x9a}; + uint8_t byteswillprops2[] = {0}; + uint8_t byteswillprops4[] = {0xe6, 0x76, 0xf6, 0x22, 0x5c}; + uint8_t byteswillprops3[] = {0x8f, 0x1e, 0x3d, 0x2d, 0xa0, 0xd3, 0x6b, 0x68, + 0x2f, 0x91, 0xde, 0xf5, 0x59, 0x5f, 0x50, 0x8}; + uint8_t byteswillprops5[] = {0x2c}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25357}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 106}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {16, (char*)&byteswillprops3}, .v = {5, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5551}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17112}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12477}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 247}}, + }; + + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1a, 0xa7, 0xc8, 0x72, 0x52, 0x7f, 0xed, 0x3e, 0x93, 0x33, 0x9, 0x2d, 0x86, 0x2c}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4, 0x7b, 0x12, 0x53, 0xd8, 0x3d, 0xb5, 0xd8, 0x1, 0xe1, + 0x99, 0x36, 0x28, 0xcd, 0xc5, 0x31, 0x3, 0x2, 0x7f}; + lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS0; + will.retained = false; + will.properties = willprops; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 27479; + uint8_t client_id_bytes[] = {0xed, 0x32, 0x8f, 0xb3, 0x67, 0x8a, 0xbd, 0xbe, 0x9b, 0x6c, 0x0, 0xf2, 0x7e, + 0x3, 0x4a, 0xde, 0x5e, 0x93, 0x2d, 0x2, 0x8c, 0xd2, 0xc6, 0x61, 0xf9}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0x45, 0x9e}; + lwmqtt_string_t username = {2, (char*)&username_bytes}; + opts.username = username; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\201\216\NAK\238\243\185\202\212?\188\224\STX/\198h\162\159z\193", _password = Just +// "\220\192\199\173G\186\161\178", _lastWill = Nothing, _cleanSession = True, _keepAlive = 7221, _connID = +// "\191nx\FSO\157\147i\209\143\DC2\STX\160\SI\215", _properties = [PropServerKeepAlive 1856,PropMaximumQoS +// 140,PropWillDelayInterval 20535,PropRequestProblemInformation 95,PropRequestResponseInformation +// 227,PropTopicAliasMaximum 7849,PropAuthenticationMethod "\GS=\US3\242\255\249\EM\245",PropMaximumPacketSize +// 2330,PropResponseTopic +// "\178-\216<\130\163\141\171\190\198W\173\222\FS\a\251\152\b\RS\CAN\186\189z\DC3E\141",PropSharedSubscriptionAvailable +// 179,PropRequestResponseInformation 51,PropWillDelayInterval 26586,PropSubscriptionIdentifierAvailable 192]} +TEST(Connect5QCTest, Encode30) { + uint8_t pkt[] = {0x10, 0x85, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x1c, 0x35, 0x4a, 0x13, 0x7, + 0x40, 0x24, 0x8c, 0x18, 0x0, 0x0, 0x50, 0x37, 0x17, 0x5f, 0x19, 0xe3, 0x22, 0x1e, 0xa9, 0x15, + 0x0, 0x9, 0x1d, 0x3d, 0x1f, 0x33, 0xf2, 0xff, 0xf9, 0x19, 0xf5, 0x27, 0x0, 0x0, 0x9, 0x1a, + 0x8, 0x0, 0x1a, 0xb2, 0x2d, 0xd8, 0x3c, 0x82, 0xa3, 0x8d, 0xab, 0xbe, 0xc6, 0x57, 0xad, 0xde, + 0x1c, 0x7, 0xfb, 0x98, 0x8, 0x1e, 0x18, 0xba, 0xbd, 0x7a, 0x13, 0x45, 0x8d, 0x2a, 0xb3, 0x19, + 0x33, 0x18, 0x0, 0x0, 0x67, 0xda, 0x29, 0xc0, 0x0, 0xf, 0xbf, 0x6e, 0x78, 0x1c, 0x4f, 0x9d, + 0x93, 0x69, 0xd1, 0x8f, 0x12, 0x2, 0xa0, 0xf, 0xd7, 0x0, 0x13, 0xc9, 0xd8, 0x15, 0xee, 0xf3, + 0xb9, 0xca, 0xd4, 0x3f, 0xbc, 0xe0, 0x2, 0x2f, 0xc6, 0x68, 0xa2, 0x9f, 0x7a, 0xc1, 0x0, 0x8, + 0xdc, 0xc0, 0xc7, 0xad, 0x47, 0xba, 0xa1, 0xb2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1d, 0x3d, 0x1f, 0x33, 0xf2, 0xff, 0xf9, 0x19, 0xf5}; + uint8_t bytesprops1[] = {0xb2, 0x2d, 0xd8, 0x3c, 0x82, 0xa3, 0x8d, 0xab, 0xbe, 0xc6, 0x57, 0xad, 0xde, + 0x1c, 0x7, 0xfb, 0x98, 0x8, 0x1e, 0x18, 0xba, 0xbd, 0x7a, 0x13, 0x45, 0x8d}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1856}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20535}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7849}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2330}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26586}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 192}}, + }; + + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 7221; + uint8_t client_id_bytes[] = {0xbf, 0x6e, 0x78, 0x1c, 0x4f, 0x9d, 0x93, 0x69, 0xd1, 0x8f, 0x12, 0x2, 0xa0, 0xf, 0xd7}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xc9, 0xd8, 0x15, 0xee, 0xf3, 0xb9, 0xca, 0xd4, 0x3f, 0xbc, + 0xe0, 0x2, 0x2f, 0xc6, 0x68, 0xa2, 0x9f, 0x7a, 0xc1}; + lwmqtt_string_t username = {19, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xdc, 0xc0, 0xc7, 0xad, 0x47, 0xba, 0xa1, 0xb2}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 15317 [("\211!\219\245}\191K\196\v\188\"\238\237R\242F\240\177\144\229",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\200c\DC2\DC4\SO",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\ni",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("v\212>\RS\195wS\195p",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\DLE|\233_$",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\249\204\STX\180\161\213{b_\SOHVAT",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\191\217\230\191\SUB\239\135\250\206K\133\131\159)OE\ACK\DC2#\203\133=~",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("B\a\136\184\225Dtd\170\&1\162\128O\189e\160\233\186\135B\248",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode1) { + uint8_t pkt[] = {0x82, 0x7c, 0x3b, 0xd5, 0x0, 0x14, 0xd3, 0x21, 0xdb, 0xf5, 0x7d, 0xbf, 0x4b, 0xc4, 0xb, 0xbc, + 0x22, 0xee, 0xed, 0x52, 0xf2, 0x46, 0xf0, 0xb1, 0x90, 0xe5, 0x1, 0x0, 0x5, 0xc8, 0x63, 0x12, + 0x14, 0xe, 0x1, 0x0, 0x2, 0xa, 0x69, 0x0, 0x0, 0x9, 0x76, 0xd4, 0x3e, 0x1e, 0xc3, 0x77, + 0x53, 0xc3, 0x70, 0x0, 0x0, 0x5, 0x10, 0x7c, 0xe9, 0x5f, 0x24, 0x2, 0x0, 0xd, 0xf9, 0xcc, + 0x2, 0xb4, 0xa1, 0xd5, 0x7b, 0x62, 0x5f, 0x1, 0x56, 0x41, 0x54, 0x1, 0x0, 0x17, 0xbf, 0xd9, + 0xe6, 0xbf, 0x1a, 0xef, 0x87, 0xfa, 0xce, 0x4b, 0x85, 0x83, 0x9f, 0x29, 0x4f, 0x45, 0x6, 0x12, + 0x23, 0xcb, 0x85, 0x3d, 0x7e, 0x2, 0x0, 0x15, 0x42, 0x7, 0x88, 0xb8, 0xe1, 0x44, 0x74, 0x64, + 0xaa, 0x31, 0xa2, 0x80, 0x4f, 0xbd, 0x65, 0xa0, 0xe9, 0xba, 0x87, 0x42, 0xf8, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xd3, 0x21, 0xdb, 0xf5, 0x7d, 0xbf, 0x4b, 0xc4, 0xb, 0xbc, + 0x22, 0xee, 0xed, 0x52, 0xf2, 0x46, 0xf0, 0xb1, 0x90, 0xe5}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0xc8, 0x63, 0x12, 0x14, 0xe}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe1, 0xc8, 0x5b, 0x48, 0xfd, 0x65, 0x0, 0xe6, 0x6c, 0x5b, 0x68, - 0x52, 0xdc, 0xd7, 0xf2, 0xdf, 0xaf, 0x85, 0xa9, 0xe7, 0x7d}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa, 0x69}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x58}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x76, 0xd4, 0x3e, 0x1e, 0xc3, 0x77, 0x53, 0xc3, 0x70}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x44, 0x6, 0xb5, 0xb9, 0x34, 0xef, 0xeb, 0x4d, 0xe3, 0x83, 0xfc, 0xff, - 0x4d, 0xb0, 0xd, 0xdb, 0xb4, 0x17, 0xd9, 0xa7, 0xe8, 0xbe, 0xdf, 0xec}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x10, 0x7c, 0xe9, 0x5f, 0x24}; + lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x42, 0x29, 0x60, 0xea, 0x31, 0x27, 0xdd, 0xda, 0xab, 0x17, 0x64, 0xc4, - 0x34, 0xe5, 0xaa, 0x59, 0x16, 0xa4, 0x79, 0xa4, 0x62, 0xae, 0x45, 0xf0}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf9, 0xcc, 0x2, 0xb4, 0xa1, 0xd5, 0x7b, 0x62, 0x5f, 0x1, 0x56, 0x41, 0x54}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xbf, 0xd9, 0xe6, 0xbf, 0x1a, 0xef, 0x87, 0xfa, 0xce, 0x4b, 0x85, 0x83, + 0x9f, 0x29, 0x4f, 0x45, 0x6, 0x12, 0x23, 0xcb, 0x85, 0x3d, 0x7e}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa5, 0xd5, 0x16, 0xf0, 0xf9, 0x3, 0xc, 0xe1, 0xab, 0xbc, - 0x6a, 0xa4, 0x28, 0xaa, 0xbe, 0xbd, 0xf8, 0xdf, 0xca}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x42, 0x7, 0x88, 0xb8, 0xe1, 0x44, 0x74, 0x64, 0xaa, 0x31, 0xa2, + 0x80, 0x4f, 0xbd, 0x65, 0xa0, 0xe9, 0xba, 0x87, 0x42, 0xf8}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xb6, 0xd0, 0x87, 0x42, 0x42, 0xdf}; - lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x37}; - lwmqtt_string_t topic_filter_s9 = {1, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15317, 8, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 2981 [("p\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("^w\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2}),("Q\CANiG\n\136\149\SOH\aL\225\243%\139\253W\156FD)\188r5\236s\179^\166",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\144\145\182\194\&1'\245",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode2) { + uint8_t pkt[] = {0x82, 0x36, 0xb, 0xa5, 0x0, 0x2, 0x70, 0xc5, 0x1, 0x0, 0x3, 0x5e, 0x77, 0xba, + 0x2, 0x0, 0x1c, 0x51, 0x18, 0x69, 0x47, 0xa, 0x88, 0x95, 0x1, 0x7, 0x4c, 0xe1, + 0xf3, 0x25, 0x8b, 0xfd, 0x57, 0x9c, 0x46, 0x44, 0x29, 0xbc, 0x72, 0x35, 0xec, 0x73, + 0xb3, 0x5e, 0xa6, 0x1, 0x0, 0x7, 0x90, 0x91, 0xb6, 0xc2, 0x31, 0x27, 0xf5, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x70, 0xc5}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x5e, 0x77, 0xba}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x51, 0x18, 0x69, 0x47, 0xa, 0x88, 0x95, 0x1, 0x7, 0x4c, + 0xe1, 0xf3, 0x25, 0x8b, 0xfd, 0x57, 0x9c, 0x46, 0x44, 0x29, + 0xbc, 0x72, 0x35, 0xec, 0x73, 0xb3, 0x5e, 0xa6}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x90, 0x91, 0xb6, 0xc2, 0x31, 0x27, 0xf5}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18112, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2981, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8048 [("=\136\230h\216\226(\250c\195\226\174/9",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\216k\253Z\203\ETX\218\SYN&\169m",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0x21, 0x1f, 0x70, 0x0, 0xe, 0x3d, 0x88, 0xe6, 0x68, 0xd8, 0xe2, - 0x28, 0xfa, 0x63, 0xc3, 0xe2, 0xae, 0x2f, 0x39, 0x2, 0x0, 0xb, 0xd8, - 0x6b, 0xfd, 0x5a, 0xcb, 0x3, 0xda, 0x16, 0x26, 0xa9, 0x6d, 0x2}; +// SubscribeRequest 15094 [("\210\248\243\&0\128\183m\131\255\nK\158\GS\237\168\184^\196\151 +// \163i\204\242\EM/\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("\195=\233\&0\253\&5Li\207\224\152Y@mA[\139<\135y;\188",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode3) { + uint8_t pkt[] = {0x82, 0x39, 0x3a, 0xf6, 0x0, 0x1b, 0xd2, 0xf8, 0xf3, 0x30, 0x80, 0xb7, 0x6d, 0x83, 0xff, + 0xa, 0x4b, 0x9e, 0x1d, 0xed, 0xa8, 0xb8, 0x5e, 0xc4, 0x97, 0x20, 0xa3, 0x69, 0xcc, 0xf2, + 0x19, 0x2f, 0xd0, 0x2, 0x0, 0x16, 0xc3, 0x3d, 0xe9, 0x30, 0xfd, 0x35, 0x4c, 0x69, 0xcf, + 0xe0, 0x98, 0x59, 0x40, 0x6d, 0x41, 0x5b, 0x8b, 0x3c, 0x87, 0x79, 0x3b, 0xbc, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x3d, 0x88, 0xe6, 0x68, 0xd8, 0xe2, 0x28, - 0xfa, 0x63, 0xc3, 0xe2, 0xae, 0x2f, 0x39}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xd2, 0xf8, 0xf3, 0x30, 0x80, 0xb7, 0x6d, 0x83, 0xff, 0xa, 0x4b, 0x9e, 0x1d, 0xed, + 0xa8, 0xb8, 0x5e, 0xc4, 0x97, 0x20, 0xa3, 0x69, 0xcc, 0xf2, 0x19, 0x2f, 0xd0}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd8, 0x6b, 0xfd, 0x5a, 0xcb, 0x3, 0xda, 0x16, 0x26, 0xa9, 0x6d}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc3, 0x3d, 0xe9, 0x30, 0xfd, 0x35, 0x4c, 0x69, 0xcf, 0xe0, 0x98, + 0x59, 0x40, 0x6d, 0x41, 0x5b, 0x8b, 0x3c, 0x87, 0x79, 0x3b, 0xbc}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; lwmqtt_sub_options_t sub_opts[2]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -10597,73 +14106,90 @@ TEST(Subscribe311QCTest, Encode2) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8048, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15094, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21602 [("\218I\151?\251\157\177r\DC2$\167\179\239",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\DELM\163P3T\138\133=\251\243C\218\218\133`\166",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 31975 [("v\DC3\131\242\151\153\129\216\200a\205\NAK\v\195!\164#\222\225\ESC<",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("a\238tQ\162\133\229\228\DC3<\233\243=Bx`\165\DLE\146J\255",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\SYN\189'\252\223\241\r\ENQ?\146.\216n\235jI",SubOptions {_retainHandling = SendOnSubscribe, +// QoS1}),("*i\190\134\153\235\221\NUL\181\244\166\143\v\164o2",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("{\242\196\145X\GS +// \170E\155\&3m\235\143B\220h-",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\240\182WL\223\230\175\ETX\195gN\NAK\STXM\DC4\SYN\240k\a\229\195\151\248\199",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\144\195e\r\DC2\190\186\229\NUL\DEL\167\202\DC4\190\184X\bB\189\217\236\174<\253\&2\144\US\SYNq",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\136\&9\f\v\189\145\182%\141\241\CAN\176>-\209|;",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("K$\SYNda\EOT\253\217\190\241p\RS\f\191\f.\252\152\244\DEL\215\RSn\195\EOTyZ\150",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\167",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("c7\142\243",SubOptions +// QoS1}),("\191u\SYN\194\143\199\229#\182\174\STX\150\132\152\142\DC3\US{\221}\245\208\241\211B\155\&8",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\155\184\145gf\215\SYN|%",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x72, 0x54, 0x62, 0x0, 0xd, 0xda, 0x49, 0x97, 0x3f, 0xfb, 0x9d, 0xb1, 0x72, 0x12, 0x24, 0xa7, - 0xb3, 0xef, 0x1, 0x0, 0x11, 0x7f, 0x4d, 0xa3, 0x50, 0x33, 0x54, 0x8a, 0x85, 0x3d, 0xfb, 0xf3, 0x43, - 0xda, 0xda, 0x85, 0x60, 0xa6, 0x2, 0x0, 0x10, 0x16, 0xbd, 0x27, 0xfc, 0xdf, 0xf1, 0xd, 0x5, 0x3f, - 0x92, 0x2e, 0xd8, 0x6e, 0xeb, 0x6a, 0x49, 0x0, 0x0, 0x1c, 0x4b, 0x24, 0x16, 0x64, 0x61, 0x4, 0xfd, - 0xd9, 0xbe, 0xf1, 0x70, 0x1e, 0xc, 0xbf, 0xc, 0x2e, 0xfc, 0x98, 0xf4, 0x7f, 0xd7, 0x1e, 0x6e, 0xc3, - 0x4, 0x79, 0x5a, 0x96, 0x0, 0x0, 0x1, 0xa7, 0x2, 0x0, 0x0, 0x0, 0x0, 0x4, 0x63, 0x37, 0x8e, - 0xf3, 0x1, 0x0, 0x9, 0x9b, 0xb8, 0x91, 0x67, 0x66, 0xd7, 0x16, 0x7c, 0x25, 0x2}; +// QoS1}),("63\167",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS +// = QoS0})] [] +TEST(Subscribe311QCTest, Encode4) { + uint8_t pkt[] = { + 0x82, 0xcd, 0x1, 0x7c, 0xe7, 0x0, 0x15, 0x76, 0x13, 0x83, 0xf2, 0x97, 0x99, 0x81, 0xd8, 0xc8, 0x61, 0xcd, 0x15, + 0xb, 0xc3, 0x21, 0xa4, 0x23, 0xde, 0xe1, 0x1b, 0x3c, 0x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tt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xda, 0x49, 0x97, 0x3f, 0xfb, 0x9d, 0xb1, 0x72, 0x12, 0x24, 0xa7, 0xb3, 0xef}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x76, 0x13, 0x83, 0xf2, 0x97, 0x99, 0x81, 0xd8, 0xc8, 0x61, 0xcd, + 0x15, 0xb, 0xc3, 0x21, 0xa4, 0x23, 0xde, 0xe1, 0x1b, 0x3c}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7f, 0x4d, 0xa3, 0x50, 0x33, 0x54, 0x8a, 0x85, 0x3d, - 0xfb, 0xf3, 0x43, 0xda, 0xda, 0x85, 0x60, 0xa6}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x61, 0xee, 0x74, 0x51, 0xa2, 0x85, 0xe5, 0xe4, 0x13, 0x3c, 0xe9, + 0xf3, 0x3d, 0x42, 0x78, 0x60, 0xa5, 0x10, 0x92, 0x4a, 0xff}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x16, 0xbd, 0x27, 0xfc, 0xdf, 0xf1, 0xd, 0x5, - 0x3f, 0x92, 0x2e, 0xd8, 0x6e, 0xeb, 0x6a, 0x49}; + uint8_t topic_filter_s2_bytes[] = {0x2a, 0x69, 0xbe, 0x86, 0x99, 0xeb, 0xdd, 0x0, + 0xb5, 0xf4, 0xa6, 0x8f, 0xb, 0xa4, 0x6f, 0x32}; lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x4b, 0x24, 0x16, 0x64, 0x61, 0x4, 0xfd, 0xd9, 0xbe, 0xf1, - 0x70, 0x1e, 0xc, 0xbf, 0xc, 0x2e, 0xfc, 0x98, 0xf4, 0x7f, - 0xd7, 0x1e, 0x6e, 0xc3, 0x4, 0x79, 0x5a, 0x96}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x7b, 0xf2, 0xc4, 0x91, 0x58, 0x1d, 0x20, 0xaa, 0x45, + 0x9b, 0x33, 0x6d, 0xeb, 0x8f, 0x42, 0xdc, 0x68, 0x2d}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa7}; - lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xf0, 0xb6, 0x57, 0x4c, 0xdf, 0xe6, 0xaf, 0x3, 0xc3, 0x67, 0x4e, 0x15, + 0x2, 0x4d, 0x14, 0x16, 0xf0, 0x6b, 0x7, 0xe5, 0xc3, 0x97, 0xf8, 0xc7}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x90, 0xc3, 0x65, 0xd, 0x12, 0xbe, 0xba, 0xe5, 0x0, 0x7f, + 0xa7, 0xca, 0x14, 0xbe, 0xb8, 0x58, 0x8, 0x42, 0xbd, 0xd9, + 0xec, 0xae, 0x3c, 0xfd, 0x32, 0x90, 0x1f, 0x16, 0x71}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x63, 0x37, 0x8e, 0xf3}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x88, 0x39, 0xc, 0xb, 0xbd, 0x91, 0xb6, 0x25, 0x8d, + 0xf1, 0x18, 0xb0, 0x3e, 0x2d, 0xd1, 0x7c, 0x3b}; + lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x9b, 0xb8, 0x91, 0x67, 0x66, 0xd7, 0x16, 0x7c, 0x25}; - lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xbf, 0x75, 0x16, 0xc2, 0x8f, 0xc7, 0xe5, 0x23, 0xb6, 0xae, 0x2, 0x96, 0x84, 0x98, + 0x8e, 0x13, 0x1f, 0x7b, 0xdd, 0x7d, 0xf5, 0xd0, 0xf1, 0xd3, 0x42, 0x9b, 0x38}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; + uint8_t topic_filter_s8_bytes[] = {0x36, 0x33, 0xa7}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -10671,11 +14197,11 @@ TEST(Subscribe311QCTest, Encode3) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -10683,232 +14209,295 @@ TEST(Subscribe311QCTest, Encode3) { sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21602, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31975, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20894 [("\237B-\128DW\251-\ENQ\236~\v\231",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\235\144\244p\b",SubOptions {_retainHandling = +// SubscribeRequest 25478 [("\219SY?\CAN\SOHQE\164",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\183\ENQ\209\132\194\DELz\220\v\150\RSf\145?a\170\217x\159\172",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\162\EM\147\205\188{m\242\133S\193\173\220\173H\227m\DC3\251\217\SUB\DC4\184\DC4~\255\a",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\237M\170\&2IG\163",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("N\168\164\212\213\140\SO|b\223\242P\195\226\192\139\128\NUL\SYN8 C",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\ETB\a\246\155\191\141\202\183\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode4) { - uint8_t pkt[] = {0x82, 0x6a, 0x51, 0x9e, 0x0, 0xd, 0xed, 0x42, 0x2d, 0x80, 0x44, 0x57, 0xfb, 0x2d, 0x5, 0xec, - 0x7e, 0xb, 0xe7, 0x0, 0x0, 0x5, 0xeb, 0x90, 0xf4, 0x70, 0x8, 0x1, 0x0, 0x1b, 0xa2, 0x19, - 0x93, 0xcd, 0xbc, 0x7b, 0x6d, 0xf2, 0x85, 0x53, 0xc1, 0xad, 0xdc, 0xad, 0x48, 0xe3, 0x6d, 0x13, - 0xfb, 0xd9, 0x1a, 0x14, 0xb8, 0x14, 0x7e, 0xff, 0x7, 0x1, 0x0, 0x0, 0x2, 0x0, 0x7, 0xed, - 0x4d, 0xaa, 0x32, 0x49, 0x47, 0xa3, 0x2, 0x0, 0x16, 0x4e, 0xa8, 0xa4, 0xd4, 0xd5, 0x8c, 0xe, - 0x7c, 0x62, 0xdf, 0xf2, 0x50, 0xc3, 0xe2, 0xc0, 0x8b, 0x80, 0x0, 0x16, 0x38, 0x20, 0x43, 0x1, - 0x0, 0x9, 0x17, 0x7, 0xf6, 0x9b, 0xbf, 0x8d, 0xca, 0xb7, 0x98, 0x2}; +// QoS2}),("v\193\162\ETX\200\RSE\250\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode5) { + uint8_t pkt[] = {0x82, 0x31, 0x63, 0x86, 0x0, 0x9, 0xdb, 0x53, 0x59, 0x3f, 0x18, 0x1, 0x51, 0x45, 0xa4, 0x0, 0x0, + 0x14, 0xb7, 0x5, 0xd1, 0x84, 0xc2, 0x7f, 0x7a, 0xdc, 0xb, 0x96, 0x1e, 0x66, 0x91, 0x3f, 0x61, 0xaa, + 0xd9, 0x78, 0x9f, 0xac, 0x2, 0x0, 0x9, 0x76, 0xc1, 0xa2, 0x3, 0xc8, 0x1e, 0x45, 0xfa, 0xeb, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x42, 0x2d, 0x80, 0x44, 0x57, 0xfb, 0x2d, 0x5, 0xec, 0x7e, 0xb, 0xe7}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xdb, 0x53, 0x59, 0x3f, 0x18, 0x1, 0x51, 0x45, 0xa4}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xeb, 0x90, 0xf4, 0x70, 0x8}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb7, 0x5, 0xd1, 0x84, 0xc2, 0x7f, 0x7a, 0xdc, 0xb, 0x96, + 0x1e, 0x66, 0x91, 0x3f, 0x61, 0xaa, 0xd9, 0x78, 0x9f, 0xac}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa2, 0x19, 0x93, 0xcd, 0xbc, 0x7b, 0x6d, 0xf2, 0x85, 0x53, 0xc1, 0xad, 0xdc, 0xad, - 0x48, 0xe3, 0x6d, 0x13, 0xfb, 0xd9, 0x1a, 0x14, 0xb8, 0x14, 0x7e, 0xff, 0x7}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x76, 0xc1, 0xa2, 0x3, 0xc8, 0x1e, 0x45, 0xfa, 0xeb}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xed, 0x4d, 0xaa, 0x32, 0x49, 0x47, 0xa3}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4e, 0xa8, 0xa4, 0xd4, 0xd5, 0x8c, 0xe, 0x7c, 0x62, 0xdf, 0xf2, - 0x50, 0xc3, 0xe2, 0xc0, 0x8b, 0x80, 0x0, 0x16, 0x38, 0x20, 0x43}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x17, 0x7, 0xf6, 0x9b, 0xbf, 0x8d, 0xca, 0xb7, 0x98}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; + lwmqtt_sub_options_t sub_opts[3]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20894, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25478, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15574 -// [("]\129\160\v\144]\DC3^\204\220\DEL\ETX2_\SI\"\197\208\215\196\b\176^\158\233\177\180\164\255",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x22, 0x3c, 0xd6, 0x0, 0x1d, 0x5d, 0x81, 0xa0, 0xb, 0x90, 0x5d, - 0x13, 0x5e, 0xcc, 0xdc, 0x7f, 0x3, 0x32, 0x5f, 0xf, 0x22, 0xc5, 0xd0, - 0xd7, 0xc4, 0x8, 0xb0, 0x5e, 0x9e, 0xe9, 0xb1, 0xb4, 0xa4, 0xff, 0x1}; +// SubscribeRequest 10292 +// [("\216C\ACK\176Ru\154\153\169y\232\US\188\236\130\166\245\218\&8\219\141\156\&2\174\210\231\171\f",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("F\251\229\161W\204c\GS\232y\155\133\149\FS\RS\168!Ni!\230\225\223\"*",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("z\255\209",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode6) { + uint8_t pkt[] = {0x82, 0x43, 0x28, 0x34, 0x0, 0x1c, 0xd8, 0x43, 0x6, 0xb0, 0x52, 0x75, 0x9a, 0x99, + 0xa9, 0x79, 0xe8, 0x1f, 0xbc, 0xec, 0x82, 0xa6, 0xf5, 0xda, 0x38, 0xdb, 0x8d, 0x9c, + 0x32, 0xae, 0xd2, 0xe7, 0xab, 0xc, 0x2, 0x0, 0x19, 0x46, 0xfb, 0xe5, 0xa1, 0x57, + 0xcc, 0x63, 0x1d, 0xe8, 0x79, 0x9b, 0x85, 0x95, 0x1c, 0x1e, 0xa8, 0x21, 0x4e, 0x69, + 0x21, 0xe6, 0xe1, 0xdf, 0x22, 0x2a, 0x1, 0x0, 0x3, 0x7a, 0xff, 0xd1, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x5d, 0x81, 0xa0, 0xb, 0x90, 0x5d, 0x13, 0x5e, 0xcc, 0xdc, - 0x7f, 0x3, 0x32, 0x5f, 0xf, 0x22, 0xc5, 0xd0, 0xd7, 0xc4, - 0x8, 0xb0, 0x5e, 0x9e, 0xe9, 0xb1, 0xb4, 0xa4, 0xff}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xd8, 0x43, 0x6, 0xb0, 0x52, 0x75, 0x9a, 0x99, 0xa9, 0x79, 0xe8, 0x1f, 0xbc, 0xec, + 0x82, 0xa6, 0xf5, 0xda, 0x38, 0xdb, 0x8d, 0x9c, 0x32, 0xae, 0xd2, 0xe7, 0xab, 0xc}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s1_bytes[] = {0x46, 0xfb, 0xe5, 0xa1, 0x57, 0xcc, 0x63, 0x1d, 0xe8, 0x79, 0x9b, 0x85, 0x95, + 0x1c, 0x1e, 0xa8, 0x21, 0x4e, 0x69, 0x21, 0xe6, 0xe1, 0xdf, 0x22, 0x2a}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x7a, 0xff, 0xd1}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15574, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10292, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 17105 [("\251AO\229\203\204a\247\204\191\DC4\162\204\146JU\160\SUB\157\195",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\155\216\r\EOT\169\SO\224\155n\235\FS\nu\159\142g;\149\246\147E\179]b\231\&8\US/<\FS",SubOptions +// SubscribeRequest 28082 +// [("\140\149\246\194\167\STX\161y\249\132\156~\130\254\201\SOH\t]\158a%Ix(\237v\155\239",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\239\191\NAKC\239\fO\ENQ\137\212*j\228\209\255\241\218\177\130",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\249]\224\SUBw\152l\185\139\aYg\DC1\SOHS\133\172",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("9\191\NAK(\225n\196\ETBp\206\175",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("{,\159\154j\185o\n\143m\178\242\207>=R\NAK\247nHl\242\STX\213&oY",SubOptions {_retainHandling = +// QoS1}),("\131\SOHT\174\251+&V\131\139\217F\DC1\151\228j\247b\229",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\138\148\167\139=\204k2\161\181/\146\&0\141]\181\151\NUL\r\188\"\v\132\&1",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\202}\DLEqP\f\228\&3\199\161dJk\216\142XIapF0\134_\205\197\141\244\222\135",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\137ya\140\155\\\DEL\204\FS\216\244Xt\190\NULg\242\174\151\160\243",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\"\DC4#\179\&1\GS#B\162\161\244\172c\DC4&\225",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\193^\197\214\CAN\240\155v(\145\239\174\201\134\236\232l\177\163",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0x58, 0x42, 0xd1, 0x0, 0x14, 0xfb, 0x41, 0x4f, 0xe5, 0xcb, 0xcc, 0x61, 0xf7, 0xcc, - 0xbf, 0x14, 0xa2, 0xcc, 0x92, 0x4a, 0x55, 0xa0, 0x1a, 0x9d, 0xc3, 0x1, 0x0, 0x1e, 0x9b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xa7, + 0x8b, 0x3d, 0xcc, 0x6b, 0x32, 0xa1, 0xb5, 0x2f, 0x92, 0x30, 0x8d, 0x5d, 0xb5, 0x97, 0x0, 0xd, 0xbc, + 0x22, 0xb, 0x84, 0x31, 0x1, 0x0, 0x1d, 0xca, 0x7d, 0x10, 0x71, 0x50, 0xc, 0xe4, 0x33, 0xc7, 0xa1, + 0x64, 0x4a, 0x6b, 0xd8, 0x8e, 0x58, 0x49, 0x61, 0x70, 0x46, 0x30, 0x86, 0x5f, 0xcd, 0xc5, 0x8d, 0xf4, + 0xde, 0x87, 0x0, 0x0, 0x15, 0x89, 0x79, 0x61, 0x8c, 0x9b, 0x5c, 0x7f, 0xcc, 0x1c, 0xd8, 0xf4, 0x58, + 0x74, 0xbe, 0x0, 0x67, 0xf2, 0xae, 0x97, 0xa0, 0xf3, 0x2, 0x0, 0x10, 0x22, 0x14, 0x23, 0xb3, 0x31, + 0x1d, 0x23, 0x42, 0xa2, 0xa1, 0xf4, 0xac, 0x63, 0x14, 0x26, 0xe1, 0x2, 0x0, 0x13, 0xc1, 0x5e, 0xc5, + 0xd6, 0x18, 0xf0, 0x9b, 0x76, 0x28, 0x91, 0xef, 0xae, 0xc9, 0x86, 0xec, 0xe8, 0x6c, 0xb1, 0xa3, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xfb, 0x41, 0x4f, 0xe5, 0xcb, 0xcc, 0x61, 0xf7, 0xcc, 0xbf, - 0x14, 0xa2, 0xcc, 0x92, 0x4a, 0x55, 0xa0, 0x1a, 0x9d, 0xc3}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x8c, 0x95, 0xf6, 0xc2, 0xa7, 0x2, 0xa1, 0x79, 0xf9, 0x84, + 0x9c, 0x7e, 0x82, 0xfe, 0xc9, 0x1, 0x9, 0x5d, 0x9e, 0x61, + 0x25, 0x49, 0x78, 0x28, 0xed, 0x76, 0x9b, 0xef}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9b, 0xd8, 0xd, 0x4, 0xa9, 0xe, 0xe0, 0x9b, 0x6e, 0xeb, - 0x1c, 0xa, 0x75, 0x9f, 0x8e, 0x67, 0x3b, 0x95, 0xf6, 0x93, - 0x45, 0xb3, 0x5d, 0x62, 0xe7, 0x38, 0x1f, 0x2f, 0x3c, 0x1c}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xef, 0xbf, 0x15, 0x43, 0xef, 0xc, 0x4f, 0x5, 0x89, 0xd4, + 0x2a, 0x6a, 0xe4, 0xd1, 0xff, 0xf1, 0xda, 0xb1, 0x82}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7b, 0x2c, 0x9f, 0x9a, 0x6a, 0xb9, 0x6f, 0xa, 0x8f, 0x6d, 0xb2, 0xf2, 0xcf, 0x3e, - 0x3d, 0x52, 0x15, 0xf7, 0x6e, 0x48, 0x6c, 0xf2, 0x2, 0xd5, 0x26, 0x6f, 0x59}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf9, 0x5d, 0xe0, 0x1a, 0x77, 0x98, 0x6c, 0xb9, 0x8b, + 0x7, 0x59, 0x67, 0x11, 0x1, 0x53, 0x85, 0xac}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; + uint8_t topic_filter_s3_bytes[] = {0x39, 0xbf, 0x15, 0x28, 0xe1, 0x6e, 0xc4, 0x17, 0x70, 0xce, 0xaf}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x83, 0x1, 0x54, 0xae, 0xfb, 0x2b, 0x26, 0x56, 0x83, 0x8b, + 0xd9, 0x46, 0x11, 0x97, 0xe4, 0x6a, 0xf7, 0x62, 0xe5}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8a, 0x94, 0xa7, 0x8b, 0x3d, 0xcc, 0x6b, 0x32, 0xa1, 0xb5, 0x2f, 0x92, + 0x30, 0x8d, 0x5d, 0xb5, 0x97, 0x0, 0xd, 0xbc, 0x22, 0xb, 0x84, 0x31}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xca, 0x7d, 0x10, 0x71, 0x50, 0xc, 0xe4, 0x33, 0xc7, 0xa1, + 0x64, 0x4a, 0x6b, 0xd8, 0x8e, 0x58, 0x49, 0x61, 0x70, 0x46, + 0x30, 0x86, 0x5f, 0xcd, 0xc5, 0x8d, 0xf4, 0xde, 0x87}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x89, 0x79, 0x61, 0x8c, 0x9b, 0x5c, 0x7f, 0xcc, 0x1c, 0xd8, 0xf4, + 0x58, 0x74, 0xbe, 0x0, 0x67, 0xf2, 0xae, 0x97, 0xa0, 0xf3}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x22, 0x14, 0x23, 0xb3, 0x31, 0x1d, 0x23, 0x42, + 0xa2, 0xa1, 0xf4, 0xac, 0x63, 0x14, 0x26, 0xe1}; + lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xc1, 0x5e, 0xc5, 0xd6, 0x18, 0xf0, 0x9b, 0x76, 0x28, 0x91, + 0xef, 0xae, 0xc9, 0x86, 0xec, 0xe8, 0x6c, 0xb1, 0xa3}; + lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17105, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28082, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26860 [("\\\141\254\CAN\217\DC4\240\244\DELx;\238\SO\168\&6A\223v\163\128",SubOptions +// SubscribeRequest 8250 [("\237(\254^Q",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("=\197G\215j^\203%xY\252S\159\251\180\234\169\174\246\185\251",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("t\181>5/\245\f\155\161\184\211",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\STX=\b\150d\219\200\177\178\226D\153\252A\229",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\245\138\fl\228\159\224Bny",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\194t\244\206\158\155>\128\183y\199\173\195\199~F\150;\142\178d",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0x5e, 0x68, 0xec, 0x0, 0x14, 0x5c, 0x8d, 0xfe, 0x18, 0xd9, 0x14, 0xf0, 0xf4, 0x7f, 0x78, - 0x3b, 0xee, 0xe, 0xa8, 0x36, 0x41, 0xdf, 0x76, 0xa3, 0x80, 0x1, 0x0, 0xb, 0x74, 0xb5, 0x3e, - 0x35, 0x2f, 0xf5, 0xc, 0x9b, 0xa1, 0xb8, 0xd3, 0x0, 0x0, 0xf, 0x2, 0x3d, 0x8, 0x96, 0x64, - 0xdb, 0xc8, 0xb1, 0xb2, 0xe2, 0x44, 0x99, 0xfc, 0x41, 0xe5, 0x1, 0x0, 0xa, 0xf5, 0x8a, 0xc, - 0x6c, 0xe4, 0x9f, 0xe0, 0x42, 0x6e, 0x79, 0x0, 0x0, 0x15, 0xc2, 0x74, 0xf4, 0xce, 0x9e, 0x9b, - 0x3e, 0x80, 0xb7, 0x79, 0xc7, 0xad, 0xc3, 0xc7, 0x7e, 0x46, 0x96, 0x3b, 0x8e, 0xb2, 0x64, 0x0}; +// QoS2}),("\223H\213n$\254\160\161A\252\180\193Z\219\143",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("=\193w\237l:\149\177\EOT\a\200",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\217k\215\DC3\211\248\152\216\156\139\ETBo\175\246\239\183\DC3&\SYN1G\139\196n\164",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode8) { + uint8_t pkt[] = {0x82, 0x5e, 0x20, 0x3a, 0x0, 0x5, 0xed, 0x28, 0xfe, 0x5e, 0x51, 0x1, 0x0, 0x15, 0x3d, 0xc5, + 0x47, 0xd7, 0x6a, 0x5e, 0xcb, 0x25, 0x78, 0x59, 0xfc, 0x53, 0x9f, 0xfb, 0xb4, 0xea, 0xa9, 0xae, + 0xf6, 0xb9, 0xfb, 0x2, 0x0, 0xf, 0xdf, 0x48, 0xd5, 0x6e, 0x24, 0xfe, 0xa0, 0xa1, 0x41, 0xfc, + 0xb4, 0xc1, 0x5a, 0xdb, 0x8f, 0x1, 0x0, 0xb, 0x3d, 0xc1, 0x77, 0xed, 0x6c, 0x3a, 0x95, 0xb1, + 0x4, 0x7, 0xc8, 0x0, 0x0, 0x19, 0xd9, 0x6b, 0xd7, 0x13, 0xd3, 0xf8, 0x98, 0xd8, 0x9c, 0x8b, + 0x17, 0x6f, 0xaf, 0xf6, 0xef, 0xb7, 0x13, 0x26, 0x16, 0x31, 0x47, 0x8b, 0xc4, 0x6e, 0xa4, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x5c, 0x8d, 0xfe, 0x18, 0xd9, 0x14, 0xf0, 0xf4, 0x7f, 0x78, - 0x3b, 0xee, 0xe, 0xa8, 0x36, 0x41, 0xdf, 0x76, 0xa3, 0x80}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xed, 0x28, 0xfe, 0x5e, 0x51}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x74, 0xb5, 0x3e, 0x35, 0x2f, 0xf5, 0xc, 0x9b, 0xa1, 0xb8, 0xd3}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x3d, 0xc5, 0x47, 0xd7, 0x6a, 0x5e, 0xcb, 0x25, 0x78, 0x59, 0xfc, + 0x53, 0x9f, 0xfb, 0xb4, 0xea, 0xa9, 0xae, 0xf6, 0xb9, 0xfb}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2, 0x3d, 0x8, 0x96, 0x64, 0xdb, 0xc8, 0xb1, - 0xb2, 0xe2, 0x44, 0x99, 0xfc, 0x41, 0xe5}; + uint8_t topic_filter_s2_bytes[] = {0xdf, 0x48, 0xd5, 0x6e, 0x24, 0xfe, 0xa0, 0xa1, + 0x41, 0xfc, 0xb4, 0xc1, 0x5a, 0xdb, 0x8f}; lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf5, 0x8a, 0xc, 0x6c, 0xe4, 0x9f, 0xe0, 0x42, 0x6e, 0x79}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3d, 0xc1, 0x77, 0xed, 0x6c, 0x3a, 0x95, 0xb1, 0x4, 0x7, 0xc8}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc2, 0x74, 0xf4, 0xce, 0x9e, 0x9b, 0x3e, 0x80, 0xb7, 0x79, 0xc7, - 0xad, 0xc3, 0xc7, 0x7e, 0x46, 0x96, 0x3b, 0x8e, 0xb2, 0x64}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd9, 0x6b, 0xd7, 0x13, 0xd3, 0xf8, 0x98, 0xd8, 0x9c, 0x8b, 0x17, 0x6f, 0xaf, + 0xf6, 0xef, 0xb7, 0x13, 0x26, 0x16, 0x31, 0x47, 0x8b, 0xc4, 0x6e, 0xa4}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -10920,7 +14509,7 @@ TEST(Subscribe311QCTest, Encode7) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -10930,39 +14519,81 @@ TEST(Subscribe311QCTest, Encode7) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26860, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8250, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11675 [("n\192\248\255\205<\240\238\SO!\140\179\201",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("o",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\232\ETXX\162\232\228\251b8Y\146c\244\143\247\RS\135",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 2359 [("\EM\174:\184\155\&9\131\194\148",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x2a, 0x2d, 0x9b, 0x0, 0xd, 0x6e, 0xc0, 0xf8, 0xff, 0xcd, 0x3c, 0xf0, 0xee, 0xe, - 0x21, 0x8c, 0xb3, 0xc9, 0x1, 0x0, 0x1, 0x6f, 0x0, 0x0, 0x11, 0xe8, 0x3, 0x58, 0xa2, - 0xe8, 0xe4, 0xfb, 0x62, 0x38, 0x59, 0x92, 0x63, 0xf4, 0x8f, 0xf7, 0x1e, 0x87, 0x0}; +TEST(Subscribe311QCTest, Encode9) { + uint8_t pkt[] = {0x82, 0xe, 0x9, 0x37, 0x0, 0x9, 0x19, 0xae, 0x3a, 0xb8, 0x9b, 0x39, 0x83, 0xc2, 0x94, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x19, 0xae, 0x3a, 0xb8, 0x9b, 0x39, 0x83, 0xc2, 0x94}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2359, 1, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 16794 [("K\236r=\152\194\134Z}\181\&3:\143\143u\164\DC1\208\150\146\248\ETB",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\RS\SUB\bJ\131u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("\195J\198\164\135",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\188\161\156\135\DEL\148\RS\249@\DC3\187",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\216mP\206\&1\135\r\155\237\&0\DC4R\175$\254h\NAKN\f",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode10) { + uint8_t pkt[] = {0x82, 0x53, 0x41, 0x9a, 0x0, 0x16, 0x4b, 0xec, 0x72, 0x3d, 0x98, 0xc2, 0x86, 0x5a, 0x7d, 0xb5, 0x33, + 0x3a, 0x8f, 0x8f, 0x75, 0xa4, 0x11, 0xd0, 0x96, 0x92, 0xf8, 0x17, 0x1, 0x0, 0x6, 0x1e, 0x1a, 0x8, + 0x4a, 0x83, 0x75, 0x1, 0x0, 0x0, 0x0, 0x0, 0x5, 0xc3, 0x4a, 0xc6, 0xa4, 0x87, 0x0, 0x0, 0xb, + 0xbc, 0xa1, 0x9c, 0x87, 0x7f, 0x94, 0x1e, 0xf9, 0x40, 0x13, 0xbb, 0x0, 0x0, 0x13, 0xd8, 0x6d, 0x50, + 0xce, 0x31, 0x87, 0xd, 0x9b, 0xed, 0x30, 0x14, 0x52, 0xaf, 0x24, 0xfe, 0x68, 0x15, 0x4e, 0xc, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x6e, 0xc0, 0xf8, 0xff, 0xcd, 0x3c, 0xf0, 0xee, 0xe, 0x21, 0x8c, 0xb3, 0xc9}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x4b, 0xec, 0x72, 0x3d, 0x98, 0xc2, 0x86, 0x5a, 0x7d, 0xb5, 0x33, + 0x3a, 0x8f, 0x8f, 0x75, 0xa4, 0x11, 0xd0, 0x96, 0x92, 0xf8, 0x17}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6f}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0x1a, 0x8, 0x4a, 0x83, 0x75}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe8, 0x3, 0x58, 0xa2, 0xe8, 0xe4, 0xfb, 0x62, 0x38, - 0x59, 0x92, 0x63, 0xf4, 0x8f, 0xf7, 0x1e, 0x87}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; + uint8_t topic_filter_s3_bytes[] = {0xc3, 0x4a, 0xc6, 0xa4, 0x87}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xbc, 0xa1, 0x9c, 0x87, 0x7f, 0x94, 0x1e, 0xf9, 0x40, 0x13, 0xbb}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xd8, 0x6d, 0x50, 0xce, 0x31, 0x87, 0xd, 0x9b, 0xed, 0x30, + 0x14, 0x52, 0xaf, 0x24, 0xfe, 0x68, 0x15, 0x4e, 0xc}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -10970,97 +14601,100 @@ TEST(Subscribe311QCTest, Encode8) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11675, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16794, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3007 [("<\ESCJ\DC2V\230\n\158\168\250G%\212R\210V\227\229\134j\165\&3)\146\165\&95",SubOptions +// SubscribeRequest 9525 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("Y",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("yTU\212\STX\n0g\ETB\216;\193\141^of\176\131l\247\243\175\226W!\218\226\143&Y",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\129",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("_\234\180~!\246(\231}4\200\221\168\191\149\197$0\202\223\&0\150\vE\169\217\189",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\GS\195\202\227\242t}K9k\EMD\149|\186\ESC~tO\216\200\234",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Nz\DC2\155\&2\182\ETB>)\DC2&?\246\193i`\151\NAK_\US4\DC1\252\234\DC2Z\NUL\a\153",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("@\194TRT -// \178\157\251\225q\SO\181(\194\220\217p",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\206\DLE\241X5E\154\204\CAN\229~hlj{`f1\155y\181\DEL\217;",SubOptions +// QoS2}),("\158\142\237\223\DEL\238TE#\174\&4\RS\247x\152d\195\167u\246\255\201\167\162=\206-",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\201{}\179\NAK",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("f\t\SYN\165=\225\132\NUL\207\161F\250\237\SOH\195\142\"\148",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\186\ETX[",SubOptions +// QoS0}),("\169\195$\148J\198r\134D\151\160\STX%j\191\201\209\170\156t\r\244k\183\198",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\DC4&y\247\168\&1W\NUL\245\&6\237\210\150i",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("cQ_y\200\249",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\STX\217 \170>\EM",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\234\250\254\182(\DEL\154mqQ\135K\160MA\174\234\211\145}\187\DC2hn/_",SubOptions {_retainHandling = +// QoS1}),("\STX\135*",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("]\141\210\RS\186\238\n\ESC\GSj\131\174\190;\136\207Ofzf'",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0xea, 0x1, 0xb, 0xbf, 0x0, 0x1b, 0x3c, 0x1b, 0x4a, 0x12, 0x56, 0xe6, 0xa, 0x9e, 0xa8, 0xfa, - 0x47, 0x25, 0xd4, 0x52, 0xd2, 0x56, 0xe3, 0xe5, 0x86, 0x6a, 0xa5, 0x33, 0x29, 0x92, 0xa5, 0x39, 0x35, - 0x0, 0x0, 0x1b, 0x5f, 0xea, 0xb4, 0x7e, 0x21, 0xf6, 0x28, 0xe7, 0x7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12, 0x68, 0x6e, 0x2f, 0x5f, 0x0}; +TEST(Subscribe311QCTest, Encode11) { + uint8_t pkt[] = {0x82, 0xa9, 0x1, 0x25, 0x35, 0x0, 0x0, 0x1, 0x0, 0x1, 0x59, 0x0, 0x0, 0x1e, 0x79, 0x54, + 0x55, 0xd4, 0x2, 0xa, 0x30, 0x67, 0x17, 0xd8, 0x3b, 0xc1, 0x8d, 0x5e, 0x6f, 0x66, 0xb0, 0x83, + 0x6c, 0xf7, 0xf3, 0xaf, 0xe2, 0x57, 0x21, 0xda, 0xe2, 0x8f, 0x26, 0x59, 0x0, 0x0, 0x1, 0x81, + 0x2, 0x0, 0x1b, 0x9e, 0x8e, 0xed, 0xdf, 0x7f, 0xee, 0x54, 0x45, 0x23, 0xae, 0x34, 0x1e, 0xf7, + 0x78, 0x98, 0x64, 0xc3, 0xa7, 0x75, 0xf6, 0xff, 0xc9, 0xa7, 0xa2, 0x3d, 0xce, 0x2d, 0x0, 0x0, + 0x19, 0xa9, 0xc3, 0x24, 0x94, 0x4a, 0xc6, 0x72, 0x86, 0x44, 0x97, 0xa0, 0x2, 0x25, 0x6a, 0xbf, + 0xc9, 0xd1, 0xaa, 0x9c, 0x74, 0xd, 0xf4, 0x6b, 0xb7, 0xc6, 0x1, 0x0, 0xe, 0x14, 0x26, 0x79, + 0xf7, 0xa8, 0x31, 0x57, 0x0, 0xf5, 0x36, 0xed, 0xd2, 0x96, 0x69, 0x2, 0x0, 0x6, 0x63, 0x51, + 0x5f, 0x79, 0xc8, 0xf9, 0x1, 0x0, 0x6, 0x2, 0xd9, 0x20, 0xaa, 0x3e, 0x19, 0x1, 0x0, 0x3, + 0x2, 0x87, 0x2a, 0x0, 0x0, 0x15, 0x5d, 0x8d, 0xd2, 0x1e, 0xba, 0xee, 0xa, 0x1b, 0x1d, 0x6a, + 0x83, 0xae, 0xbe, 0x3b, 0x88, 0xcf, 0x4f, 0x66, 0x7a, 0x66, 0x27, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x3c, 0x1b, 0x4a, 0x12, 0x56, 0xe6, 0xa, 0x9e, 0xa8, 0xfa, 0x47, 0x25, 0xd4, 0x52, - 0xd2, 0x56, 0xe3, 0xe5, 0x86, 0x6a, 0xa5, 0x33, 0x29, 0x92, 0xa5, 0x39, 0x35}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5f, 0xea, 0xb4, 0x7e, 0x21, 0xf6, 0x28, 0xe7, 0x7d, 0x34, 0xc8, 0xdd, 0xa8, 0xbf, - 0x95, 0xc5, 0x24, 0x30, 0xca, 0xdf, 0x30, 0x96, 0xb, 0x45, 0xa9, 0xd9, 0xbd}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x59}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1d, 0xc3, 0xca, 0xe3, 0xf2, 0x74, 0x7d, 0x4b, 0x39, 0x6b, 0x19, - 0x44, 0x95, 0x7c, 0xba, 0x1b, 0x7e, 0x74, 0x4f, 0xd8, 0xc8, 0xea}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x79, 0x54, 0x55, 0xd4, 0x2, 0xa, 0x30, 0x67, 0x17, 0xd8, + 0x3b, 0xc1, 0x8d, 0x5e, 0x6f, 0x66, 0xb0, 0x83, 0x6c, 0xf7, + 0xf3, 0xaf, 0xe2, 0x57, 0x21, 0xda, 0xe2, 0x8f, 0x26, 0x59}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x81}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4e, 0x7a, 0x12, 0x9b, 0x32, 0xb6, 0x17, 0x3e, 0x29, 0x12, - 0x26, 0x3f, 0xf6, 0xc1, 0x69, 0x60, 0x97, 0x15, 0x5f, 0x1f, - 0x34, 0x11, 0xfc, 0xea, 0x12, 0x5a, 0x0, 0x7, 0x99}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x9e, 0x8e, 0xed, 0xdf, 0x7f, 0xee, 0x54, 0x45, 0x23, 0xae, 0x34, 0x1e, 0xf7, 0x78, + 0x98, 0x64, 0xc3, 0xa7, 0x75, 0xf6, 0xff, 0xc9, 0xa7, 0xa2, 0x3d, 0xce, 0x2d}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x40, 0xc2, 0x54, 0x52, 0x54, 0x20, 0xb2, 0x9d, 0xfb, - 0xe1, 0x71, 0xe, 0xb5, 0x28, 0xc2, 0xdc, 0xd9, 0x70}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xa9, 0xc3, 0x24, 0x94, 0x4a, 0xc6, 0x72, 0x86, 0x44, 0x97, 0xa0, 0x2, 0x25, + 0x6a, 0xbf, 0xc9, 0xd1, 0xaa, 0x9c, 0x74, 0xd, 0xf4, 0x6b, 0xb7, 0xc6}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xce, 0x10, 0xf1, 0x58, 0x35, 0x45, 0x9a, 0xcc, 0x18, 0xe5, 0x7e, 0x68, - 0x6c, 0x6a, 0x7b, 0x60, 0x66, 0x31, 0x9b, 0x79, 0xb5, 0x7f, 0xd9, 0x3b}; - lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x14, 0x26, 0x79, 0xf7, 0xa8, 0x31, 0x57, 0x0, 0xf5, 0x36, 0xed, 0xd2, 0x96, 0x69}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xc9, 0x7b, 0x7d, 0xb3, 0x15}; - lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x63, 0x51, 0x5f, 0x79, 0xc8, 0xf9}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x66, 0x9, 0x16, 0xa5, 0x3d, 0xe1, 0x84, 0x0, 0xcf, - 0xa1, 0x46, 0xfa, 0xed, 0x1, 0xc3, 0x8e, 0x22, 0x94}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x2, 0xd9, 0x20, 0xaa, 0x3e, 0x19}; + lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xba, 0x3, 0x5b}; + uint8_t topic_filter_s9_bytes[] = {0x2, 0x87, 0x2a}; lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xea, 0xfa, 0xfe, 0xb6, 0x28, 0x7f, 0x9a, 0x6d, 0x71, 0x51, 0x87, 0x4b, 0xa0, - 0x4d, 0x41, 0xae, 0xea, 0xd3, 0x91, 0x7d, 0xbb, 0x12, 0x68, 0x6e, 0x2f, 0x5f}; - lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; + uint8_t topic_filter_s10_bytes[] = {0x5d, 0x8d, 0xd2, 0x1e, 0xba, 0xee, 0xa, 0x1b, 0x1d, 0x6a, 0x83, + 0xae, 0xbe, 0x3b, 0x88, 0xcf, 0x4f, 0x66, 0x7a, 0x66, 0x27}; + lwmqtt_string_t topic_filter_s10 = {21, (char*)&topic_filter_s10_bytes}; topic_filters[10] = topic_filter_s10; lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11076,7 +14710,7 @@ TEST(Subscribe311QCTest, Encode9) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -11084,19 +14718,19 @@ TEST(Subscribe311QCTest, Encode9) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].qos = LWMQTT_QOS1; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].qos = LWMQTT_QOS0; sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; @@ -11110,56 +14744,82 @@ TEST(Subscribe311QCTest, Encode9) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3007, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9525, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30616 [("b\GS\215\182QH\USjKr\230\129\142?Q\129UE\243\147n\229\160)\137",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\164\EMyC\254\225\STX33_\EOTAsM\"\DEL\236\&3jy",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("}\159dgE^\200\218v",SubOptions {_retainHandling = +// SubscribeRequest 25695 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\186\219\215",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\201bK\187'\a\ENQ\157\250\DLE",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("X\223\196\156",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\244hB>\204s +// 1\US\233\145\133\178:\129\154\238z\SYN\152-\244tq\DC1\146",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\EOT\188\214C\158\190\234\ETBt\229\GSR\139N\217\SO\240\245\ENQ\173G;\153@\183",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\DC2\249\217\184\DEL\147\151g\128\169}\221\168\236~l",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\227\172\EM\147eL\199B -// \USLxP\210\a4as\191\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0x6b, 0x77, 0x98, 0x0, 0x19, 0x62, 0x1d, 0xd7, 0xb6, 0x51, 0x48, 0x1f, 0x6a, 0x4b, 0x72, - 0xe6, 0x81, 0x8e, 0x3f, 0x51, 0x81, 0x55, 0x45, 0xf3, 0x93, 0x6e, 0xe5, 0xa0, 0x29, 0x89, 0x2, - 0x0, 0x14, 0xa4, 0x19, 0x79, 0x43, 0xfe, 0xe1, 0x2, 0x33, 0x33, 0x5f, 0x4, 0x41, 0x73, 0x4d, - 0x22, 0x7f, 0xec, 0x33, 0x6a, 0x79, 0x2, 0x0, 0x9, 0x7d, 0x9f, 0x64, 0x67, 0x45, 0x5e, 0xc8, - 0xda, 0x76, 0x2, 0x0, 0x10, 0x12, 0xf9, 0xd9, 0xb8, 0x7f, 0x93, 0x97, 0x67, 0x80, 0xa9, 0x7d, - 0xdd, 0xa8, 0xec, 0x7e, 0x6c, 0x1, 0x0, 0x14, 0xe3, 0xac, 0x19, 0x93, 0x65, 0x4c, 0xc7, 0x42, - 0x20, 0x1f, 0x4c, 0x78, 0x50, 0xd2, 0x7, 0x34, 0x61, 0x73, 0xbf, 0xe8, 0x1}; +// QoS1}),("W406\252\156\\\212\&3\b\203$\187\247\DC2\235\v\134\181\231",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\191\ESC+\"q",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("!\138\RS@\137\CANP!\SOH]\f\250\244\251h\232\242\241\241\218",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\STX\134\223\174XA\133.\245g\FS~\224\173\r\158\EOT\165\NAK",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode12) { + uint8_t pkt[] = {0x82, 0xa4, 0x1, 0x64, 0x5f, 0x0, 0x0, 0x2, 0x0, 0x3, 0xba, 0xdb, 0xd7, 0x0, 0x0, 0xa, 0xc9, + 0x62, 0x4b, 0xbb, 0x27, 0x7, 0x5, 0x9d, 0xfa, 0x10, 0x2, 0x0, 0x4, 0x58, 0xdf, 0xc4, 0x9c, 0x2, + 0x0, 0x1a, 0xf4, 0x68, 0x42, 0x3e, 0xcc, 0x73, 0x20, 0x31, 0x1f, 0xe9, 0x91, 0x85, 0xb2, 0x3a, 0x81, + 0x9a, 0xee, 0x7a, 0x16, 0x98, 0x2d, 0xf4, 0x74, 0x71, 0x11, 0x92, 0x0, 0x0, 0x19, 0x4, 0xbc, 0xd6, + 0x43, 0x9e, 0xbe, 0xea, 0x17, 0x74, 0xe5, 0x1d, 0x52, 0x8b, 0x4e, 0xd9, 0xe, 0xf0, 0xf5, 0x5, 0xad, + 0x47, 0x3b, 0x99, 0x40, 0xb7, 0x1, 0x0, 0x14, 0x57, 0x34, 0x30, 0x36, 0xfc, 0x9c, 0x5c, 0xd4, 0x33, + 0x8, 0xcb, 0x24, 0xbb, 0xf7, 0x12, 0xeb, 0xb, 0x86, 0xb5, 0xe7, 0x1, 0x0, 0x5, 0xbf, 0x1b, 0x2b, + 0x22, 0x71, 0x0, 0x0, 0x14, 0x21, 0x8a, 0x1e, 0x40, 0x89, 0x18, 0x50, 0x21, 0x1, 0x5d, 0xc, 0xfa, + 0xf4, 0xfb, 0x68, 0xe8, 0xf2, 0xf1, 0xf1, 0xda, 0x2, 0x0, 0x13, 0x2, 0x86, 0xdf, 0xae, 0x58, 0x41, + 0x85, 0x2e, 0xf5, 0x67, 0x1c, 0x7e, 0xe0, 0xad, 0xd, 0x9e, 0x4, 0xa5, 0x15, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x62, 0x1d, 0xd7, 0xb6, 0x51, 0x48, 0x1f, 0x6a, 0x4b, 0x72, 0xe6, 0x81, 0x8e, - 0x3f, 0x51, 0x81, 0x55, 0x45, 0xf3, 0x93, 0x6e, 0xe5, 0xa0, 0x29, 0x89}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa4, 0x19, 0x79, 0x43, 0xfe, 0xe1, 0x2, 0x33, 0x33, 0x5f, - 0x4, 0x41, 0x73, 0x4d, 0x22, 0x7f, 0xec, 0x33, 0x6a, 0x79}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xba, 0xdb, 0xd7}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7d, 0x9f, 0x64, 0x67, 0x45, 0x5e, 0xc8, 0xda, 0x76}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc9, 0x62, 0x4b, 0xbb, 0x27, 0x7, 0x5, 0x9d, 0xfa, 0x10}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x12, 0xf9, 0xd9, 0xb8, 0x7f, 0x93, 0x97, 0x67, - 0x80, 0xa9, 0x7d, 0xdd, 0xa8, 0xec, 0x7e, 0x6c}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x58, 0xdf, 0xc4, 0x9c}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe3, 0xac, 0x19, 0x93, 0x65, 0x4c, 0xc7, 0x42, 0x20, 0x1f, - 0x4c, 0x78, 0x50, 0xd2, 0x7, 0x34, 0x61, 0x73, 0xbf, 0xe8}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xf4, 0x68, 0x42, 0x3e, 0xcc, 0x73, 0x20, 0x31, 0x1f, 0xe9, 0x91, 0x85, 0xb2, + 0x3a, 0x81, 0x9a, 0xee, 0x7a, 0x16, 0x98, 0x2d, 0xf4, 0x74, 0x71, 0x11, 0x92}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; + uint8_t topic_filter_s5_bytes[] = {0x4, 0xbc, 0xd6, 0x43, 0x9e, 0xbe, 0xea, 0x17, 0x74, 0xe5, 0x1d, 0x52, 0x8b, + 0x4e, 0xd9, 0xe, 0xf0, 0xf5, 0x5, 0xad, 0x47, 0x3b, 0x99, 0x40, 0xb7}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x57, 0x34, 0x30, 0x36, 0xfc, 0x9c, 0x5c, 0xd4, 0x33, 0x8, + 0xcb, 0x24, 0xbb, 0xf7, 0x12, 0xeb, 0xb, 0x86, 0xb5, 0xe7}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xbf, 0x1b, 0x2b, 0x22, 0x71}; + lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x21, 0x8a, 0x1e, 0x40, 0x89, 0x18, 0x50, 0x21, 0x1, 0x5d, + 0xc, 0xfa, 0xf4, 0xfb, 0x68, 0xe8, 0xf2, 0xf1, 0xf1, 0xda}; + lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x2, 0x86, 0xdf, 0xae, 0x58, 0x41, 0x85, 0x2e, 0xf5, 0x67, + 0x1c, 0x7e, 0xe0, 0xad, 0xd, 0x9e, 0x4, 0xa5, 0x15}; + lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -11167,68 +14827,93 @@ TEST(Subscribe311QCTest, Encode10) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30616, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25695, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27910 [("\146\183",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\190\186\217w\248\160\225))",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\178\157\206\191\161S\255!{\198\145\131E2\133W2",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\181\210p\180\241\184\&6\233r\192\145\128\159Q1\210\199",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 14957 +// [("'\STX-\199\148\232\\4\ETB\240D\\\DC2G\221\175\253\255\200\151\129\253\175\163\209a",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\133%J[\196Z\167\222\147\176\SYN\173\170@h\164",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\DLE5#\237\150\213-\170\158\FS\165\166\EOTJ\249\144T\SOH\158`N\200\168B\EM",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0x57, 0x6d, 0x6, 0x0, 0x2, 0x92, 0xb7, 0x2, 0x0, 0x9, 0xbe, 0xba, 0xd9, 0x77, - 0xf8, 0xa0, 0xe1, 0x29, 0x29, 0x2, 0x0, 0x11, 0xb2, 0x9d, 0xce, 0xbf, 0xa1, 0x53, 0xff, - 0x21, 0x7b, 0xc6, 0x91, 0x83, 0x45, 0x32, 0x85, 0x57, 0x32, 0x2, 0x0, 0x11, 0xb5, 0xd2, - 0x70, 0xb4, 0xf1, 0xb8, 0x36, 0xe9, 0x72, 0xc0, 0x91, 0x80, 0x9f, 0x51, 0x31, 0xd2, 0xc7, - 0x2, 0x0, 0x19, 0x10, 0x35, 0x23, 0xed, 0x96, 0xd5, 0x2d, 0xaa, 0x9e, 0x1c, 0xa5, 0xa6, - 0x4, 0x4a, 0xf9, 0x90, 0x54, 0x1, 0x9e, 0x60, 0x4e, 0xc8, 0xa8, 0x42, 0x19, 0x1}; +// QoS1}),("\214\172\142\169\CANa\255\&7!H+OU`z\"\SUB\129\146[[",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\136`\150!\205",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("Ig\181\204}",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\GS\157",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode13) { + uint8_t pkt[] = {0x82, 0x5f, 0x3a, 0x6d, 0x0, 0x1a, 0x27, 0x2, 0x2d, 0xc7, 0x94, 0xe8, 0x5c, 0x34, 0x17, 0xf0, 0x44, + 0x5c, 0x12, 0x47, 0xdd, 0xaf, 0xfd, 0xff, 0xc8, 0x97, 0x81, 0xfd, 0xaf, 0xa3, 0xd1, 0x61, 0x0, 0x0, + 0x10, 0x85, 0x25, 0x4a, 0x5b, 0xc4, 0x5a, 0xa7, 0xde, 0x93, 0xb0, 0x16, 0xad, 0xaa, 0x40, 0x68, 0xa4, + 0x1, 0x0, 0x15, 0xd6, 0xac, 0x8e, 0xa9, 0x18, 0x61, 0xff, 0x37, 0x21, 0x48, 0x2b, 0x4f, 0x55, 0x60, + 0x7a, 0x22, 0x1a, 0x81, 0x92, 0x5b, 0x5b, 0x2, 0x0, 0x5, 0x88, 0x60, 0x96, 0x21, 0xcd, 0x1, 0x0, + 0x5, 0x49, 0x67, 0xb5, 0xcc, 0x7d, 0x0, 0x0, 0x2, 0x1d, 0x9d, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x92, 0xb7}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x27, 0x2, 0x2d, 0xc7, 0x94, 0xe8, 0x5c, 0x34, 0x17, 0xf0, 0x44, 0x5c, 0x12, + 0x47, 0xdd, 0xaf, 0xfd, 0xff, 0xc8, 0x97, 0x81, 0xfd, 0xaf, 0xa3, 0xd1, 0x61}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbe, 0xba, 0xd9, 0x77, 0xf8, 0xa0, 0xe1, 0x29, 0x29}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x85, 0x25, 0x4a, 0x5b, 0xc4, 0x5a, 0xa7, 0xde, + 0x93, 0xb0, 0x16, 0xad, 0xaa, 0x40, 0x68, 0xa4}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb2, 0x9d, 0xce, 0xbf, 0xa1, 0x53, 0xff, 0x21, 0x7b, - 0xc6, 0x91, 0x83, 0x45, 0x32, 0x85, 0x57, 0x32}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xd6, 0xac, 0x8e, 0xa9, 0x18, 0x61, 0xff, 0x37, 0x21, 0x48, 0x2b, + 0x4f, 0x55, 0x60, 0x7a, 0x22, 0x1a, 0x81, 0x92, 0x5b, 0x5b}; + lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb5, 0xd2, 0x70, 0xb4, 0xf1, 0xb8, 0x36, 0xe9, 0x72, - 0xc0, 0x91, 0x80, 0x9f, 0x51, 0x31, 0xd2, 0xc7}; - lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x88, 0x60, 0x96, 0x21, 0xcd}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x10, 0x35, 0x23, 0xed, 0x96, 0xd5, 0x2d, 0xaa, 0x9e, 0x1c, 0xa5, 0xa6, 0x4, - 0x4a, 0xf9, 0x90, 0x54, 0x1, 0x9e, 0x60, 0x4e, 0xc8, 0xa8, 0x42, 0x19}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x49, 0x67, 0xb5, 0xcc, 0x7d}; + lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s5_bytes[] = {0x1d, 0x9d}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -11236,100 +14921,106 @@ TEST(Subscribe311QCTest, Encode11) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27910, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14957, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 31365 [("\241\182\221\CAN\nn8\n\144\151\&9\198\NUL<>\212",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),(".6V",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("N\199\249\DC2\184\STX\149\167\166je\254\207\152\130\210\151\ETB\144\RS\162\130\128\207I\DLE~\162\244<",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\162\199}\255V\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("\215\SOM\234!\158\&7\167\225\183\250\173",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("&\v\205\128\233\230\187\129\181\128S\NUL\222\253\185$*\180i\183",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\135z\215D\NAK\225\197",SubOptions +// SubscribeRequest 12087 [("\SOH\160\au5\136\&6\222",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS2}),("\202SR62\ENQ<\140\142k",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\141\ACK\147\209\&2\239\163\250\214V",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\227a\EOT0{ +// \198\DC2\248\240s_m`\210\198~\128e\240\202\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\197%;s04\250{\144\SIN\157\136\156\157\221\232\250",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("v\236\188\199\GS\206N.\208J\187\188q~\n\173.\199\154\SIQ\215\&7",SubOptions {_retainHandling = +// QoS1}),("86f\234\181\141#g\FS]\237x\187\200B\224Q\158\&3\234\STX\a1\233\\\FS",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("d\128\&5B\227\&7\DC3\221\200",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode12) { - uint8_t pkt[] = {0x82, 0x9b, 0x1, 0x7a, 0x85, 0x0, 0x10, 0xf1, 0xb6, 0xdd, 0x18, 0xa, 0x6e, 0x38, 0xa, 0x90, - 0x97, 0x39, 0xc6, 0x0, 0x3c, 0x3e, 0xd4, 0x0, 0x0, 0x3, 0x2e, 0x36, 0x56, 0x2, 0x0, 0x1e, - 0x4e, 0xc7, 0xf9, 0x12, 0xb8, 0x2, 0x95, 0xa7, 0xa6, 0x6a, 0x65, 0xfe, 0xcf, 0x98, 0x82, 0xd2, - 0x97, 0x17, 0x90, 0x1e, 0xa2, 0x82, 0x80, 0xcf, 0x49, 0x10, 0x7e, 0xa2, 0xf4, 0x3c, 0x0, 0x0, - 0x6, 0xa2, 0xc7, 0x7d, 0xff, 0x56, 0x83, 0x1, 0x0, 0xc, 0xd7, 0xe, 0x4d, 0xea, 0x21, 0x9e, - 0x37, 0xa7, 0xe1, 0xb7, 0xfa, 0xad, 0x2, 0x0, 0x14, 0x26, 0xb, 0xcd, 0x80, 0xe9, 0xe6, 0xbb, - 0x81, 0xb5, 0x80, 0x53, 0x0, 0xde, 0xfd, 0xb9, 0x24, 0x2a, 0xb4, 0x69, 0xb7, 0x0, 0x0, 0x7, - 0x87, 0x7a, 0xd7, 0x44, 0x15, 0xe1, 0xc5, 0x0, 0x0, 0x17, 0x76, 0xec, 0xbc, 0xc7, 0x1d, 0xce, - 0x4e, 0x2e, 0xd0, 0x4a, 0xbb, 0xbc, 0x71, 0x7e, 0xa, 0xad, 0x2e, 0xc7, 0x9a, 0xf, 0x51, 0xd7, - 0x37, 0x2, 0x0, 0x9, 0x64, 0x80, 0x35, 0x42, 0xe3, 0x37, 0x13, 0xdd, 0xc8, 0x0}; +// QoS2}),("0\194w\220\142\208!>\246\138\133\163\SOH|\246I\FS$D\252`!\FS@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\172\226p\DC4E\160\DC3\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\230A<\165\132",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode14) { + uint8_t pkt[] = {0x82, 0xa3, 0x1, 0x2f, 0x37, 0x0, 0x8, 0x1, 0xa0, 0x7, 0x75, 0x35, 0x88, 0x36, 0xde, 0x2, 0x0, + 0xa, 0xca, 0x53, 0x52, 0x36, 0x32, 0x5, 0x3c, 0x8c, 0x8e, 0x6b, 0x1, 0x0, 0xa, 0x8d, 0x6, 0x93, + 0xd1, 0x32, 0xef, 0xa3, 0xfa, 0xd6, 0x56, 0x2, 0x0, 0x16, 0xe3, 0x61, 0x4, 0x30, 0x7b, 0x20, 0xc6, + 0x12, 0xf8, 0xf0, 0x73, 0x5f, 0x6d, 0x60, 0xd2, 0xc6, 0x7e, 0x80, 0x65, 0xf0, 0xca, 0x1, 0x2, 0x0, + 0x12, 0xc5, 0x25, 0x3b, 0x73, 0x30, 0x34, 0xfa, 0x7b, 0x90, 0xf, 0x4e, 0x9d, 0x88, 0x9c, 0x9d, 0xdd, + 0xe8, 0xfa, 0x2, 0x0, 0x0, 0x1, 0x0, 0x1a, 0x38, 0x36, 0x66, 0xea, 0xb5, 0x8d, 0x23, 0x67, 0x1c, + 0x5d, 0xed, 0x78, 0xbb, 0xc8, 0x42, 0xe0, 0x51, 0x9e, 0x33, 0xea, 0x2, 0x7, 0x31, 0xe9, 0x5c, 0x1c, + 0x2, 0x0, 0x18, 0x30, 0xc2, 0x77, 0xdc, 0x8e, 0xd0, 0x21, 0x3e, 0xf6, 0x8a, 0x85, 0xa3, 0x1, 0x7c, + 0xf6, 0x49, 0x1c, 0x24, 0x44, 0xfc, 0x60, 0x21, 0x1c, 0x40, 0x0, 0x0, 0x8, 0xac, 0xe2, 0x70, 0x14, + 0x45, 0xa0, 0x13, 0xe1, 0x0, 0x0, 0x5, 0xe6, 0x41, 0x3c, 0xa5, 0x84, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xf1, 0xb6, 0xdd, 0x18, 0xa, 0x6e, 0x38, 0xa, - 0x90, 0x97, 0x39, 0xc6, 0x0, 0x3c, 0x3e, 0xd4}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x1, 0xa0, 0x7, 0x75, 0x35, 0x88, 0x36, 0xde}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2e, 0x36, 0x56}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xca, 0x53, 0x52, 0x36, 0x32, 0x5, 0x3c, 0x8c, 0x8e, 0x6b}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4e, 0xc7, 0xf9, 0x12, 0xb8, 0x2, 0x95, 0xa7, 0xa6, 0x6a, - 0x65, 0xfe, 0xcf, 0x98, 0x82, 0xd2, 0x97, 0x17, 0x90, 0x1e, - 0xa2, 0x82, 0x80, 0xcf, 0x49, 0x10, 0x7e, 0xa2, 0xf4, 0x3c}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8d, 0x6, 0x93, 0xd1, 0x32, 0xef, 0xa3, 0xfa, 0xd6, 0x56}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa2, 0xc7, 0x7d, 0xff, 0x56, 0x83}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xe3, 0x61, 0x4, 0x30, 0x7b, 0x20, 0xc6, 0x12, 0xf8, 0xf0, 0x73, + 0x5f, 0x6d, 0x60, 0xd2, 0xc6, 0x7e, 0x80, 0x65, 0xf0, 0xca, 0x1}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd7, 0xe, 0x4d, 0xea, 0x21, 0x9e, 0x37, 0xa7, 0xe1, 0xb7, 0xfa, 0xad}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc5, 0x25, 0x3b, 0x73, 0x30, 0x34, 0xfa, 0x7b, 0x90, + 0xf, 0x4e, 0x9d, 0x88, 0x9c, 0x9d, 0xdd, 0xe8, 0xfa}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x26, 0xb, 0xcd, 0x80, 0xe9, 0xe6, 0xbb, 0x81, 0xb5, 0x80, - 0x53, 0x0, 0xde, 0xfd, 0xb9, 0x24, 0x2a, 0xb4, 0x69, 0xb7}; - lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x87, 0x7a, 0xd7, 0x44, 0x15, 0xe1, 0xc5}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x38, 0x36, 0x66, 0xea, 0xb5, 0x8d, 0x23, 0x67, 0x1c, 0x5d, 0xed, 0x78, 0xbb, + 0xc8, 0x42, 0xe0, 0x51, 0x9e, 0x33, 0xea, 0x2, 0x7, 0x31, 0xe9, 0x5c, 0x1c}; + lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x76, 0xec, 0xbc, 0xc7, 0x1d, 0xce, 0x4e, 0x2e, 0xd0, 0x4a, 0xbb, 0xbc, - 0x71, 0x7e, 0xa, 0xad, 0x2e, 0xc7, 0x9a, 0xf, 0x51, 0xd7, 0x37}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x30, 0xc2, 0x77, 0xdc, 0x8e, 0xd0, 0x21, 0x3e, 0xf6, 0x8a, 0x85, 0xa3, + 0x1, 0x7c, 0xf6, 0x49, 0x1c, 0x24, 0x44, 0xfc, 0x60, 0x21, 0x1c, 0x40}; + lwmqtt_string_t topic_filter_s7 = {24, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x64, 0x80, 0x35, 0x42, 0xe3, 0x37, 0x13, 0xdd, 0xc8}; - lwmqtt_string_t topic_filter_s8 = {9, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xac, 0xe2, 0x70, 0x14, 0x45, 0xa0, 0x13, 0xe1}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s9_bytes[] = {0xe6, 0x41, 0x3c, 0xa5, 0x84}; + lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -11337,15 +15028,15 @@ TEST(Subscribe311QCTest, Encode12) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].qos = LWMQTT_QOS0; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; @@ -11353,116 +15044,80 @@ TEST(Subscribe311QCTest, Encode12) { sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31365, 9, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 3963 [("&\249+\165\255",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0xa, 0xf, 0x7b, 0x0, 0x5, 0x26, 0xf9, 0x2b, 0xa5, 0xff, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x26, 0xf9, 0x2b, 0xa5, 0xff}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3963, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12087, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27481 [("\173\187\212\&85\132\164-<\f",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("j\187\191\158GB4 -// \150\146\235\244\140\&1\188\t\220\225\SI+O\165\163\DLE'\SI\226\221\181\254",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\210\&5",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("a\169{+\204\189x\GS{`\\\195",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("Q\\\225\194\n\180\179d|\208<\202R,\183\137\RSh",SubOptions +// SubscribeRequest 12264 [("\196k\DC4\147L\142U\156\ENQ\US\184Vi",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("v\GSMX\152\167\US\241\&0\144",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("^\135\131R\219\\\129W@5`^\130\225?\243\200\157",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Z\177\195\252s\ESCh\253 \b\f6\DC4",SubOptions +// QoS1}),("ZW\174\198D$\r\232\220afgJM\NAKe\174\158\192\138\223\ESCs\172d\140M",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\EOT\184\184Pt\214-\228:\SI\193\207\136",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\202\223|X\252\nU\158b~\143\&8\GS#",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\162#D\147((1X ",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\166\138\DC3\154:7\189]-\201p\160\223*R,\224",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("6\EM\165\136\194\149\NULb\236I\138\FS\207\&5qi\206\228\169i\r\252\132R\237",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0xb4, 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SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("|\141\195",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode15) { + uint8_t pkt[] = {0x82, 0x79, 0x2f, 0xe8, 0x0, 0xd, 0xc4, 0x6b, 0x14, 0x93, 0x4c, 0x8e, 0x55, 0x9c, 0x5, 0x1f, + 0xb8, 0x56, 0x69, 0x0, 0x0, 0xa, 0x76, 0x1d, 0x4d, 0x58, 0x98, 0xa7, 0x1f, 0xf1, 0x30, 0x90, + 0x1, 0x0, 0x1b, 0x5a, 0x57, 0xae, 0xc6, 0x44, 0x24, 0xd, 0xe8, 0xdc, 0x61, 0x66, 0x67, 0x4a, + 0x4d, 0x15, 0x65, 0xae, 0x9e, 0xc0, 0x8a, 0xdf, 0x1b, 0x73, 0xac, 0x64, 0x8c, 0x4d, 0x1, 0x0, + 0xd, 0x4, 0xb8, 0xb8, 0x50, 0x74, 0xd6, 0x2d, 0xe4, 0x3a, 0xf, 0xc1, 0xcf, 0x88, 0x0, 0x0, + 0xe, 0xca, 0xdf, 0x7c, 0x58, 0xfc, 0xa, 0x55, 0x9e, 0x62, 0x7e, 0x8f, 0x38, 0x1d, 0x23, 0x1, + 0x0, 0x9, 0xa2, 0x23, 0x44, 0x93, 0x28, 0x28, 0x31, 0x58, 0x20, 0x1, 0x0, 0x6, 0x82, 0xdb, + 0x14, 0x9d, 0x96, 0x77, 0x2, 0x0, 0x3, 0x7c, 0x8d, 0xc3, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xad, 0xbb, 0xd4, 0x38, 0x35, 0x84, 0xa4, 0x2d, 0x3c, 0xc}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xc4, 0x6b, 0x14, 0x93, 0x4c, 0x8e, 0x55, 0x9c, 0x5, 0x1f, 0xb8, 0x56, 0x69}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6a, 0xbb, 0xbf, 0x9e, 0x47, 0x42, 0x34, 0x20, 0x96, 0x92, - 0xeb, 0xf4, 0x8c, 0x31, 0xbc, 0x9, 0xdc, 0xe1, 0xf, 0x2b, - 0x4f, 0xa5, 0xa3, 0x10, 0x27, 0xf, 0xe2, 0xdd, 0xb5, 0xfe}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x76, 0x1d, 0x4d, 0x58, 0x98, 0xa7, 0x1f, 0xf1, 0x30, 0x90}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd2, 0x35}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5a, 0x57, 0xae, 0xc6, 0x44, 0x24, 0xd, 0xe8, 0xdc, 0x61, 0x66, 0x67, 0x4a, 0x4d, + 0x15, 0x65, 0xae, 0x9e, 0xc0, 0x8a, 0xdf, 0x1b, 0x73, 0xac, 0x64, 0x8c, 0x4d}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x61, 0xa9, 0x7b, 0x2b, 0xcc, 0xbd, 0x78, 0x1d, 0x7b, 0x60, 0x5c, 0xc3}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x4, 0xb8, 0xb8, 0x50, 0x74, 0xd6, 0x2d, 0xe4, 0x3a, 0xf, 0xc1, 0xcf, 0x88}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x51, 0x5c, 0xe1, 0x3c, 0x54, 0x70, 0xcc, 0x3c, 0x3e, 0xc2, 0xa, 0xb4, - 0xb3, 0x64, 0x7c, 0xd0, 0x3c, 0xca, 0x52, 0x2c, 0xb7, 0x89, 0x1e, 0x68}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xca, 0xdf, 0x7c, 0x58, 0xfc, 0xa, 0x55, 0x9e, 0x62, 0x7e, 0x8f, 0x38, 0x1d, 0x23}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5e, 0x87, 0x83, 0x52, 0xdb, 0x5c, 0x81, 0x57, 0x40, - 0x35, 0x60, 0x5e, 0x82, 0xe1, 0x3f, 0xf3, 0xc8, 0x9d}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xa2, 0x23, 0x44, 0x93, 0x28, 0x28, 0x31, 0x58, 0x20}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5a, 0xb1, 0xc3, 0xfc, 0x73, 0x1b, 0x68, 0xfd, 0x20, 0x8, 0xc, 0x36, 0x14}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x82, 0xdb, 0x14, 0x9d, 0x96, 0x77}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa6, 0x8a, 0x13, 0x9a, 0x3a, 0x37, 0xbd, 0x5d, 0x2d, - 0xc9, 0x70, 0xa0, 0xdf, 0x2a, 0x52, 0x2c, 0xe0}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x7c, 0x8d, 0xc3}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x36, 0x19, 0xa5, 0x88, 0xc2, 0x95, 0x0, 0x62, 0xec, 0x49, 0x8a, 0x1c, 0xcf, - 0x35, 0x71, 0x69, 0xce, 0xe4, 0xa9, 0x69, 0xd, 0xfc, 0x84, 0x52, 0xed}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -11470,11 +15125,11 @@ TEST(Subscribe311QCTest, Encode14) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -11482,45 +15137,69 @@ TEST(Subscribe311QCTest, Encode14) { sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27481, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12264, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32387 -// [("\205Yv\244\133\240o\244\240\227\&6\170r\201\GS\177\160\165\236\219\187K\FS\205\151\152",SubOptions +// SubscribeRequest 23519 [("R\219\&9\207\231\198)2}\160",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\229\250\209",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("P\243-\232\133v`;l\157\243\238\130\251x\239\172\210\144\US2\251@h\138\228Mt\140",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\n\133g\194",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\164\170z",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode15) { - uint8_t pkt[] = {0x82, 0x25, 0x7e, 0x83, 0x0, 0x1a, 0xcd, 0x59, 0x76, 0xf4, 0x85, 0xf0, 0x6f, - 0xf4, 0xf0, 0xe3, 0x36, 0xaa, 0x72, 0xc9, 0x1d, 0xb1, 0xa0, 0xa5, 0xec, 0xdb, - 0xbb, 0x4b, 0x1c, 0xcd, 0x97, 0x98, 0x0, 0x0, 0x3, 0xa4, 0xaa, 0x7a, 0x1}; +// QoS1}),("y\239\128\199)K\206~\242\246\SO*Anb2&\190\169#b",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\tz\SI\249\US2%R\176\a\163Kn\141\187\198\211x\246)]",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode16) { + uint8_t pkt[] = {0x82, 0x6f, 0x5b, 0xdf, 0x0, 0xa, 0x52, 0xdb, 0x39, 0xcf, 0xe7, 0xc6, 0x29, 0x32, 0x7d, 0xa0, 0x0, + 0x0, 0x0, 0x1, 0x0, 0x3, 0xe5, 0xfa, 0xd1, 0x0, 0x0, 0x1d, 0x50, 0xf3, 0x2d, 0xe8, 0x85, 0x76, + 0x60, 0x3b, 0x6c, 0x9d, 0xf3, 0xee, 0x82, 0xfb, 0x78, 0xef, 0xac, 0xd2, 0x90, 0x1f, 0x32, 0xfb, 0x40, + 0x68, 0x8a, 0xe4, 0x4d, 0x74, 0x8c, 0x0, 0x0, 0x4, 0xa, 0x85, 0x67, 0xc2, 0x1, 0x0, 0x15, 0x79, + 0xef, 0x80, 0xc7, 0x29, 0x4b, 0xce, 0x7e, 0xf2, 0xf6, 0xe, 0x2a, 0x41, 0x6e, 0x62, 0x32, 0x26, 0xbe, + 0xa9, 0x23, 0x62, 0x0, 0x0, 0x15, 0x9, 0x7a, 0xf, 0xf9, 0x1f, 0x32, 0x25, 0x52, 0xb0, 0x7, 0xa3, + 0x4b, 0x6e, 0x8d, 0xbb, 0xc6, 0xd3, 0x78, 0xf6, 0x29, 0x5d, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xcd, 0x59, 0x76, 0xf4, 0x85, 0xf0, 0x6f, 0xf4, 0xf0, 0xe3, 0x36, 0xaa, 0x72, - 0xc9, 0x1d, 0xb1, 0xa0, 0xa5, 0xec, 0xdb, 0xbb, 0x4b, 0x1c, 0xcd, 0x97, 0x98}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x52, 0xdb, 0x39, 0xcf, 0xe7, 0xc6, 0x29, 0x32, 0x7d, 0xa0}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa4, 0xaa, 0x7a}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; + uint8_t topic_filter_s2_bytes[] = {0xe5, 0xfa, 0xd1}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x50, 0xf3, 0x2d, 0xe8, 0x85, 0x76, 0x60, 0x3b, 0x6c, 0x9d, + 0xf3, 0xee, 0x82, 0xfb, 0x78, 0xef, 0xac, 0xd2, 0x90, 0x1f, + 0x32, 0xfb, 0x40, 0x68, 0x8a, 0xe4, 0x4d, 0x74, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa, 0x85, 0x67, 0xc2}; + lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x79, 0xef, 0x80, 0xc7, 0x29, 0x4b, 0xce, 0x7e, 0xf2, 0xf6, 0xe, + 0x2a, 0x41, 0x6e, 0x62, 0x32, 0x26, 0xbe, 0xa9, 0x23, 0x62}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x9, 0x7a, 0xf, 0xf9, 0x1f, 0x32, 0x25, 0x52, 0xb0, 0x7, 0xa3, + 0x4b, 0x6e, 0x8d, 0xbb, 0xc6, 0xd3, 0x78, 0xf6, 0x29, 0x5d}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -11529,93 +15208,130 @@ TEST(Subscribe311QCTest, Encode15) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32387, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23519, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27695 [("\244savN\237\&9\ETB\SUB\239C\CAN\184a\157b\NUL\151u\142\230\r",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("D\153\DC2\SOH",SubOptions +// SubscribeRequest 29383 [(",\NAK\169\178hV\136\f\td\219\232\130\128\161",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("x\r\128\171A\130\134\&6\DC1oU\179\212\t~\136\247\SO3",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),(")o=\233\v\SOH\204,\183\ESCkM^\133\224\&5\200H",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\210\198\219\203\239\165d<\213b\DC4UR\142\235\248\NULp\131\235\184\147\223kF\157\137\150\218\b",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\SYN\139\192\ETB\205fr\136\n\229V\162C\DC3\130\ENQ\DC1\228\179\196C\192\RS\DEL",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\149\140\bL\128\SI\252T",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = -// QoS0}),("\164\138\235VW\242\242\a\134\243\168\215tQK\DLE\179\202\207\250A\EM\226\174]\a",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("!W\178\139't\202\166K\r\223\151",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\180\239\139\STX\NULd",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\133\235X3\227\134\248\236\248\231",SubOptions +// QoS1}),("mm\223\&8\CAN\fO\no",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\192\143D`V'\SYNt\SI\233\133\&5\248\252\145\247C\130\192\218\SUBo",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\170\153\226",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0x90, 0x1, 0x6c, 0x2f, 0x0, 0x16, 0xf4, 0x73, 0x61, 0x76, 0x4e, 0xed, 0x39, 0x17, 0x1a, 0xef, - 0x43, 0x18, 0xb8, 0x61, 0x9d, 0x62, 0x0, 0x97, 0x75, 0x8e, 0xe6, 0xd, 0x1, 0x0, 0x4, 0x44, 0x99, - 0x12, 0x1, 0x0, 0x0, 0x18, 0x16, 0x8b, 0xc0, 0x17, 0xcd, 0x66, 0x72, 0x88, 0xa, 0xe5, 0x56, 0xa2, - 0x43, 0x13, 0x82, 0x5, 0x11, 0xe4, 0xb3, 0xc4, 0x43, 0xc0, 0x1e, 0x7f, 0x1, 0x0, 0x8, 0x95, 0x8c, - 0x8, 0x4c, 0x80, 0xf, 0xfc, 0x54, 0x0, 0x0, 0x1a, 0xa4, 0x8a, 0xeb, 0x56, 0x57, 0xf2, 0xf2, 0x7, - 0x86, 0xf3, 0xa8, 0xd7, 0x74, 0x51, 0x4b, 0x10, 0xb3, 0xca, 0xcf, 0xfa, 0x41, 0x19, 0xe2, 0xae, 0x5d, - 0x7, 0x2, 0x0, 0xc, 0x21, 0x57, 0xb2, 0x8b, 0x27, 0x74, 0xca, 0xa6, 0x4b, 0xd, 0xdf, 0x97, 0x2, - 0x0, 0x6, 0xb4, 0xef, 0x8b, 0x2, 0x0, 0x64, 0x1, 0x0, 0xa, 0x85, 0xeb, 0x58, 0x33, 0xe3, 0x86, - 0xf8, 0xec, 0xf8, 0xe7, 0x0, 0x0, 0x3, 0xaa, 0x99, 0xe2, 0x1}; +// QoS0}),("\173\253\163N\216\207\129+_ \235e2\r5}\146",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\223\ETX\244nSoNK",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("/\239uT\EOT",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("f\241DK\SUB\ETB\DLEfe[\RS\CAN\222\ESCp\230Z\232v9e\246",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode17) { + uint8_t pkt[] = {0x82, 0xc8, 0x1, 0x72, 0xc7, 0x0, 0xf, 0x2c, 0x15, 0xa9, 0xb2, 0x68, 0x56, 0x88, 0xc, 0x9, 0x64, + 0xdb, 0xe8, 0x82, 0x80, 0xa1, 0x1, 0x0, 0x13, 0x78, 0xd, 0x80, 0xab, 0x41, 0x82, 0x86, 0x36, 0x11, + 0x6f, 0x55, 0xb3, 0xd4, 0x9, 0x7e, 0x88, 0xf7, 0xe, 0x33, 0x2, 0x0, 0x12, 0x29, 0x6f, 0x3d, 0xe9, + 0xb, 0x1, 0xcc, 0x2c, 0xb7, 0x1b, 0x6b, 0x4d, 0x5e, 0x85, 0xe0, 0x35, 0xc8, 0x48, 0x0, 0x0, 0x1e, + 0xd2, 0xc6, 0xdb, 0xcb, 0xef, 0xa5, 0x64, 0x3c, 0xd5, 0x62, 0x14, 0x55, 0x52, 0x8e, 0xeb, 0xf8, 0x0, + 0x70, 0x83, 0xeb, 0xb8, 0x93, 0xdf, 0x6b, 0x46, 0x9d, 0x89, 0x96, 0xda, 0x8, 0x1, 0x0, 0x9, 0x6d, + 0x6d, 0xdf, 0x38, 0x18, 0xc, 0x4f, 0xa, 0x6f, 0x0, 0x0, 0x0, 0x2, 0x0, 0x16, 0xc0, 0x8f, 0x44, + 0x60, 0x56, 0x27, 0x16, 0x74, 0xf, 0xe9, 0x85, 0x35, 0xf8, 0xfc, 0x91, 0xf7, 0x43, 0x82, 0xc0, 0xda, + 0x1a, 0x6f, 0x0, 0x0, 0x11, 0xad, 0xfd, 0xa3, 0x4e, 0xd8, 0xcf, 0x81, 0x2b, 0x5f, 0x20, 0xeb, 0x65, + 0x32, 0xd, 0x35, 0x7d, 0x92, 0x1, 0x0, 0x8, 0xdf, 0x3, 0xf4, 0x6e, 0x53, 0x6f, 0x4e, 0x4b, 0x1, + 0x0, 0x5, 0x2f, 0xef, 0x75, 0x54, 0x4, 0x1, 0x0, 0x16, 0x66, 0xf1, 0x44, 0x4b, 0x1a, 0x17, 0x10, + 0x66, 0x65, 0x5b, 0x1e, 0x18, 0xde, 0x1b, 0x70, 0xe6, 0x5a, 0xe8, 0x76, 0x39, 0x65, 0xf6, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xf4, 0x73, 0x61, 0x76, 0x4e, 0xed, 0x39, 0x17, 0x1a, 0xef, 0x43, - 0x18, 0xb8, 0x61, 0x9d, 0x62, 0x0, 0x97, 0x75, 0x8e, 0xe6, 0xd}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x2c, 0x15, 0xa9, 0xb2, 0x68, 0x56, 0x88, 0xc, + 0x9, 0x64, 0xdb, 0xe8, 0x82, 0x80, 0xa1}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x44, 0x99, 0x12, 0x1}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x78, 0xd, 0x80, 0xab, 0x41, 0x82, 0x86, 0x36, 0x11, 0x6f, + 0x55, 0xb3, 0xd4, 0x9, 0x7e, 0x88, 0xf7, 0xe, 0x33}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x16, 0x8b, 0xc0, 0x17, 0xcd, 0x66, 0x72, 0x88, 0xa, 0xe5, 0x56, 0xa2, - 0x43, 0x13, 0x82, 0x5, 0x11, 0xe4, 0xb3, 0xc4, 0x43, 0xc0, 0x1e, 0x7f}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x29, 0x6f, 0x3d, 0xe9, 0xb, 0x1, 0xcc, 0x2c, 0xb7, + 0x1b, 0x6b, 0x4d, 0x5e, 0x85, 0xe0, 0x35, 0xc8, 0x48}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x95, 0x8c, 0x8, 0x4c, 0x80, 0xf, 0xfc, 0x54}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd2, 0xc6, 0xdb, 0xcb, 0xef, 0xa5, 0x64, 0x3c, 0xd5, 0x62, + 0x14, 0x55, 0x52, 0x8e, 0xeb, 0xf8, 0x0, 0x70, 0x83, 0xeb, + 0xb8, 0x93, 0xdf, 0x6b, 0x46, 0x9d, 0x89, 0x96, 0xda, 0x8}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa4, 0x8a, 0xeb, 0x56, 0x57, 0xf2, 0xf2, 0x7, 0x86, 0xf3, 0xa8, 0xd7, 0x74, - 0x51, 0x4b, 0x10, 0xb3, 0xca, 0xcf, 0xfa, 0x41, 0x19, 0xe2, 0xae, 0x5d, 0x7}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x6d, 0x6d, 0xdf, 0x38, 0x18, 0xc, 0x4f, 0xa, 0x6f}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x21, 0x57, 0xb2, 0x8b, 0x27, 0x74, 0xca, 0xa6, 0x4b, 0xd, 0xdf, 0x97}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb4, 0xef, 0x8b, 0x2, 0x0, 0x64}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xc0, 0x8f, 0x44, 0x60, 0x56, 0x27, 0x16, 0x74, 0xf, 0xe9, 0x85, + 0x35, 0xf8, 0xfc, 0x91, 0xf7, 0x43, 0x82, 0xc0, 0xda, 0x1a, 0x6f}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x85, 0xeb, 0x58, 0x33, 0xe3, 0x86, 0xf8, 0xec, 0xf8, 0xe7}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xad, 0xfd, 0xa3, 0x4e, 0xd8, 0xcf, 0x81, 0x2b, 0x5f, + 0x20, 0xeb, 0x65, 0x32, 0xd, 0x35, 0x7d, 0x92}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xaa, 0x99, 0xe2}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xdf, 0x3, 0xf4, 0x6e, 0x53, 0x6f, 0x4e, 0x4b}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; + uint8_t topic_filter_s9_bytes[] = {0x2f, 0xef, 0x75, 0x54, 0x4}; + lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x66, 0xf1, 0x44, 0x4b, 0x1a, 0x17, 0x10, 0x66, 0x65, 0x5b, 0x1e, + 0x18, 0xde, 0x1b, 0x70, 0xe6, 0x5a, 0xe8, 0x76, 0x39, 0x65, 0xf6}; + lwmqtt_string_t topic_filter_s10 = {22, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -11623,11 +15339,11 @@ TEST(Subscribe311QCTest, Encode16) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; @@ -11635,149 +15351,147 @@ TEST(Subscribe311QCTest, Encode16) { sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27695, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29383, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29411 [(")\137\189d\189&\250#\214n1\GS\218A\245\158\136\t;\247\175:A\180\233",SubOptions +// SubscribeRequest 22596 [("Z\234}C\SUB\171\&5&\204(&\179-\EOTJ4Z\158^\r/\210",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\155\DLE\244\181\FSv!R\140\a\235\ENQ\187D\133;",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\247\DC267\FS'\131\SI\183\GS(6\151",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\209\DLEs\183`\203\204*\136K\202\223k",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("\214?\172zE\154=\DLE\186u!\132\140a\183\249\&3\189\186)\139\SUB",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode17) { - uint8_t pkt[] = {0x82, 0x47, 0x72, 0xe3, 0x0, 0x19, 0x29, 0x89, 0xbd, 0x64, 0xbd, 0x26, 0xfa, 0x23, 0xd6, - 0x6e, 0x31, 0x1d, 0xda, 0x41, 0xf5, 0x9e, 0x88, 0x9, 0x3b, 0xf7, 0xaf, 0x3a, 0x41, 0xb4, - 0xe9, 0x2, 0x0, 0xd, 0xd1, 0x10, 0x73, 0xb7, 0x60, 0xcb, 0xcc, 0x2a, 0x88, 0x4b, 0xca, - 0xdf, 0x6b, 0x2, 0x0, 0x16, 0xd6, 0x3f, 0xac, 0x7a, 0x45, 0x9a, 0x3d, 0x10, 0xba, 0x75, - 0x21, 0x84, 0x8c, 0x61, 0xb7, 0xf9, 0x33, 0xbd, 0xba, 0x29, 0x8b, 0x1a, 0x1}; +// QoS0}),("-F\209r\195e^\215\133\254\177R\253\173\165\FS\DLE?\DC3\203Qm\153\228 4\EM\156\228",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("*\206\rj\188y\249\188o\SI\163Sfn\ENQ:II3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1}),("\177B:\171\142\240\238\222",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode18) { + uint8_t pkt[] = {0x82, 0x7f, 0x58, 0x44, 0x0, 0x16, 0x5a, 0xea, 0x7d, 0x43, 0x1a, 0xab, 0x35, 0x26, 0xcc, 0x28, 0x26, + 0xb3, 0x2d, 0x4, 0x4a, 0x34, 0x5a, 0x9e, 0x5e, 0xd, 0x2f, 0xd2, 0x1, 0x0, 0x10, 0x9b, 0x10, 0xf4, + 0xb5, 0x1c, 0x76, 0x21, 0x52, 0x8c, 0x7, 0xeb, 0x5, 0xbb, 0x44, 0x85, 0x3b, 0x1, 0x0, 0xd, 0xf7, + 0x12, 0x36, 0x37, 0x1c, 0x27, 0x83, 0xf, 0xb7, 0x1d, 0x28, 0x36, 0x97, 0x0, 0x0, 0x1d, 0x2d, 0x46, + 0xd1, 0x72, 0xc3, 0x65, 0x5e, 0xd7, 0x85, 0xfe, 0xb1, 0x52, 0xfd, 0xad, 0xa5, 0x1c, 0x10, 0x3f, 0x13, + 0xcb, 0x51, 0x6d, 0x99, 0xe4, 0x20, 0x34, 0x19, 0x9c, 0xe4, 0x0, 0x0, 0x13, 0x2a, 0xce, 0xd, 0x6a, + 0xbc, 0x79, 0xf9, 0xbc, 0x6f, 0xf, 0xa3, 0x53, 0x66, 0x6e, 0x5, 0x3a, 0x49, 0x49, 0x33, 0x1, 0x0, + 0x8, 0xb1, 0x42, 0x3a, 0xab, 0x8e, 0xf0, 0xee, 0xde, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x29, 0x89, 0xbd, 0x64, 0xbd, 0x26, 0xfa, 0x23, 0xd6, 0x6e, 0x31, 0x1d, 0xda, - 0x41, 0xf5, 0x9e, 0x88, 0x9, 0x3b, 0xf7, 0xaf, 0x3a, 0x41, 0xb4, 0xe9}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x5a, 0xea, 0x7d, 0x43, 0x1a, 0xab, 0x35, 0x26, 0xcc, 0x28, 0x26, + 0xb3, 0x2d, 0x4, 0x4a, 0x34, 0x5a, 0x9e, 0x5e, 0xd, 0x2f, 0xd2}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd1, 0x10, 0x73, 0xb7, 0x60, 0xcb, 0xcc, 0x2a, 0x88, 0x4b, 0xca, 0xdf, 0x6b}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9b, 0x10, 0xf4, 0xb5, 0x1c, 0x76, 0x21, 0x52, + 0x8c, 0x7, 0xeb, 0x5, 0xbb, 0x44, 0x85, 0x3b}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd6, 0x3f, 0xac, 0x7a, 0x45, 0x9a, 0x3d, 0x10, 0xba, 0x75, 0x21, - 0x84, 0x8c, 0x61, 0xb7, 0xf9, 0x33, 0xbd, 0xba, 0x29, 0x8b, 0x1a}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf7, 0x12, 0x36, 0x37, 0x1c, 0x27, 0x83, 0xf, 0xb7, 0x1d, 0x28, 0x36, 0x97}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s3_bytes[] = {0x2d, 0x46, 0xd1, 0x72, 0xc3, 0x65, 0x5e, 0xd7, 0x85, 0xfe, + 0xb1, 0x52, 0xfd, 0xad, 0xa5, 0x1c, 0x10, 0x3f, 0x13, 0xcb, + 0x51, 0x6d, 0x99, 0xe4, 0x20, 0x34, 0x19, 0x9c, 0xe4}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x2a, 0xce, 0xd, 0x6a, 0xbc, 0x79, 0xf9, 0xbc, 0x6f, 0xf, + 0xa3, 0x53, 0x66, 0x6e, 0x5, 0x3a, 0x49, 0x49, 0x33}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xb1, 0x42, 0x3a, 0xab, 0x8e, 0xf0, 0xee, 0xde}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29411, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22596, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22557 [("#\164A\r\139\STX;\197\SIwh\SYN\201\230\252\196\208K",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\137\185l\EOT\205\r\219\t.\239j\181j,*k\255\SO}L",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("d\196T\247\DC4\198\165\SUB1\a\181\255",SubOptions +// SubscribeRequest 11045 [("\234\249\222\145'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("\217Z\205\221w\220\&3\151\252\147\160\134\236\ru\149\189",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\ACK\155R\SYN\217\207\&3\145V\215ws\192\177\184S",SubOptions {_retainHandling = SendOnSubscribe, +// QoS0}),("J\221\215\236\181\158\210\253l\a\191z\189\211\SOq\150",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("#\161\214\195\f@H\130\av\155\169\241\157\251\196\231\233\135V\142",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("/\172\STX\DC2\"`\224+\179{\129\239\180\165\221\248\189\133",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\169\228LZ\199^-&\NAKA\f\129\251\EOT]\FS\185h\190Zn6\252\DLE\187\153\170d\148",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\251\166\176\214=\STX\232\&4\248\r\254\\\184(\142\213\SO\140L\217\DC4\221y\202\169\138\206\145\182\192",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\170*\229'\207\130\193\237\139\159>\223\200\200\153\SOH\132\208\190\DC2\153\190\213O\190\DLE.\\y",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode18) { - uint8_t pkt[] = { - 0x82, 0xde, 0x1, 0x58, 0x1d, 0x0, 0x12, 0x23, 0xa4, 0x41, 0xd, 0x8b, 0x2, 0x3b, 0xc5, 0xf, 0x77, 0x68, 0x16, - 0xc9, 0xe6, 0xfc, 0xc4, 0xd0, 0x4b, 0x0, 0x0, 0x14, 0x89, 0xb9, 0x6c, 0x4, 0xcd, 0xd, 0xdb, 0x9, 0x2e, 0xef, - 0x6a, 0xb5, 0x6a, 0x2c, 0x2a, 0x6b, 0xff, 0xe, 0x7d, 0x4c, 0x1, 0x0, 0xc, 0x64, 0xc4, 0x54, 0xf7, 0x14, 0xc6, - 0xa5, 0x1a, 0x31, 0x7, 0xb5, 0xff, 0x2, 0x0, 0x10, 0x6, 0x9b, 0x52, 0x16, 0xd9, 0xcf, 0x33, 0x91, 0x56, 0xd7, - 0x77, 0x73, 0xc0, 0xb1, 0xb8, 0x53, 0x0, 0x0, 0x15, 0x23, 0xa1, 0xd6, 0xc3, 0xc, 0x40, 0x48, 0x82, 0x7, 0x76, - 0x9b, 0xa9, 0xf1, 0x9d, 0xfb, 0xc4, 0xe7, 0xe9, 0x87, 0x56, 0x8e, 0x1, 0x0, 0x12, 0x2f, 0xac, 0x2, 0x12, 0x22, - 0x60, 0xe0, 0x2b, 0xb3, 0x7b, 0x81, 0xef, 0xb4, 0xa5, 0xdd, 0xf8, 0xbd, 0x85, 0x0, 0x0, 0x1d, 0xa9, 0xe4, 0x4c, - 0x5a, 0xc7, 0x5e, 0x2d, 0x26, 0x15, 0x41, 0xc, 0x81, 0xfb, 0x4, 0x5d, 0x1c, 0xb9, 0x68, 0xbe, 0x5a, 0x6e, 0x36, - 0xfc, 0x10, 0xbb, 0x99, 0xaa, 0x64, 0x94, 0x2, 0x0, 0x1e, 0xfb, 0xa6, 0xb0, 0xd6, 0x3d, 0x2, 0xe8, 0x34, 0xf8, - 0xd, 0xfe, 0x5c, 0xb8, 0x28, 0x8e, 0xd5, 0xe, 0x8c, 0x4c, 0xd9, 0x14, 0xdd, 0x79, 0xca, 0xa9, 0x8a, 0xce, 0x91, - 0xb6, 0xc0, 0x2, 0x0, 0x1d, 0xaa, 0x2a, 0xe5, 0x27, 0xcf, 0x82, 0xc1, 0xed, 0x8b, 0x9f, 0x3e, 0xdf, 0xc8, 0xc8, - 0x99, 0x1, 0x84, 0xd0, 0xbe, 0x12, 0x99, 0xbe, 0xd5, 0x4f, 0xbe, 0x10, 0x2e, 0x5c, 0x79, 0x0}; +// QoS0}),("BFVB\232\190z@:\164\132\215)\182\230\141\225\GS",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode19) { + uint8_t pkt[] = {0x82, 0x47, 0x2b, 0x25, 0x0, 0x5, 0xea, 0xf9, 0xde, 0x91, 0x27, 0x0, 0x0, 0x11, 0xd9, + 0x5a, 0xcd, 0xdd, 0x77, 0xdc, 0x33, 0x97, 0xfc, 0x93, 0xa0, 0x86, 0xec, 0xd, 0x75, 0x95, + 0xbd, 0x0, 0x0, 0x11, 0x4a, 0xdd, 0xd7, 0xec, 0xb5, 0x9e, 0xd2, 0xfd, 0x6c, 0x7, 0xbf, + 0x7a, 0xbd, 0xd3, 0xe, 0x71, 0x96, 0x0, 0x0, 0x12, 0x42, 0x46, 0x56, 0x42, 0xe8, 0xbe, + 0x7a, 0x40, 0x3a, 0xa4, 0x84, 0xd7, 0x29, 0xb6, 0xe6, 0x8d, 0xe1, 0x1d, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x23, 0xa4, 0x41, 0xd, 0x8b, 0x2, 0x3b, 0xc5, 0xf, - 0x77, 0x68, 0x16, 0xc9, 0xe6, 0xfc, 0xc4, 0xd0, 0x4b}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xea, 0xf9, 0xde, 0x91, 0x27}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x89, 0xb9, 0x6c, 0x4, 0xcd, 0xd, 0xdb, 0x9, 0x2e, 0xef, - 0x6a, 0xb5, 0x6a, 0x2c, 0x2a, 0x6b, 0xff, 0xe, 0x7d, 0x4c}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd9, 0x5a, 0xcd, 0xdd, 0x77, 0xdc, 0x33, 0x97, 0xfc, + 0x93, 0xa0, 0x86, 0xec, 0xd, 0x75, 0x95, 0xbd}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x64, 0xc4, 0x54, 0xf7, 0x14, 0xc6, 0xa5, 0x1a, 0x31, 0x7, 0xb5, 0xff}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4a, 0xdd, 0xd7, 0xec, 0xb5, 0x9e, 0xd2, 0xfd, 0x6c, + 0x7, 0xbf, 0x7a, 0xbd, 0xd3, 0xe, 0x71, 0x96}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6, 0x9b, 0x52, 0x16, 0xd9, 0xcf, 0x33, 0x91, - 0x56, 0xd7, 0x77, 0x73, 0xc0, 0xb1, 0xb8, 0x53}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x42, 0x46, 0x56, 0x42, 0xe8, 0xbe, 0x7a, 0x40, 0x3a, + 0xa4, 0x84, 0xd7, 0x29, 0xb6, 0xe6, 0x8d, 0xe1, 0x1d}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x23, 0xa1, 0xd6, 0xc3, 0xc, 0x40, 0x48, 0x82, 0x7, 0x76, 0x9b, - 0xa9, 0xf1, 0x9d, 0xfb, 0xc4, 0xe7, 0xe9, 0x87, 0x56, 0x8e}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x2f, 0xac, 0x2, 0x12, 0x22, 0x60, 0xe0, 0x2b, 0xb3, - 0x7b, 0x81, 0xef, 0xb4, 0xa5, 0xdd, 0xf8, 0xbd, 0x85}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa9, 0xe4, 0x4c, 0x5a, 0xc7, 0x5e, 0x2d, 0x26, 0x15, 0x41, - 0xc, 0x81, 0xfb, 0x4, 0x5d, 0x1c, 0xb9, 0x68, 0xbe, 0x5a, - 0x6e, 0x36, 0xfc, 0x10, 0xbb, 0x99, 0xaa, 0x64, 0x94}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xfb, 0xa6, 0xb0, 0xd6, 0x3d, 0x2, 0xe8, 0x34, 0xf8, 0xd, - 0xfe, 0x5c, 0xb8, 0x28, 0x8e, 0xd5, 0xe, 0x8c, 0x4c, 0xd9, - 0x14, 0xdd, 0x79, 0xca, 0xa9, 0x8a, 0xce, 0x91, 0xb6, 0xc0}; - lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xaa, 0x2a, 0xe5, 0x27, 0xcf, 0x82, 0xc1, 0xed, 0x8b, 0x9f, - 0x3e, 0xdf, 0xc8, 0xc8, 0x99, 0x1, 0x84, 0xd0, 0xbe, 0x12, - 0x99, 0xbe, 0xd5, 0x4f, 0xbe, 0x10, 0x2e, 0x5c, 0x79}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; + lwmqtt_sub_options_t sub_opts[4]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -11785,99 +15499,82 @@ TEST(Subscribe311QCTest, Encode18) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22557, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11045, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 10879 [("k\CAN\STX\230?\231\199\145\130\DLE\182\233W\233\&5F\250\153Hoip\242W\164",SubOptions +// SubscribeRequest 21249 [("7\141\154\230\129\244\236\138'\RS\208h&Y\170\r\229q",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("Q",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\150+:_xw\178Z\250\SYN\210\178L",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\t\253\178\254a\b\217\143\162\FS\221\238PG\177\229\208*\DEL$k\160O\DLEs`\132\DC2\NAKV",SubOptions +// QoS2}),("\250z\226\216\161\ETX\ACK\136\206\ESC\173\US\218\247\CAN\SI\213)z>z\188-E\195\128\181L\248'",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\216/\149I\232hE\247*RW\244\251\134\204",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\FS9Yu\225\234\246\SOHB>\199#\188\"i\162<\168\185?\219`\237\163\NUL%",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\201\177D\132y\246}ad\135\228\US\t",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\132lyi].N\135g\164se\160\235!n\158\239MqZ",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode19) { - uint8_t pkt[] = { - 0x82, 0xba, 0x1, 0x2a, 0x7f, 0x0, 0x19, 0x6b, 0x18, 0x2, 0xe6, 0x3f, 0xe7, 0xc7, 0x91, 0x82, 0x10, 0xb6, 0xe9, - 0x57, 0xe9, 0x35, 0x46, 0xfa, 0x99, 0x48, 0x6f, 0x69, 0x70, 0xf2, 0x57, 0xa4, 0x1, 0x0, 0x1e, 0x9, 0xfd, 0xb2, - 0xfe, 0x61, 0x8, 0xd9, 0x8f, 0xa2, 0x1c, 0xdd, 0xee, 0x50, 0x47, 0xb1, 0xe5, 0xd0, 0x2a, 0x7f, 0x24, 0x6b, 0xa0, - 0x4f, 0x10, 0x73, 0x60, 0x84, 0x12, 0x15, 0x56, 0x0, 0x0, 0xf, 0xd8, 0x2f, 0x95, 0x49, 0xe8, 0x68, 0x45, 0xf7, - 0x2a, 0x52, 0x57, 0xf4, 0xfb, 0x86, 0xcc, 0x0, 0x0, 0x1a, 0x1c, 0x39, 0x59, 0x75, 0xe1, 0xea, 0xf6, 0x1, 0x42, - 0x3e, 0xc7, 0x23, 0xbc, 0x22, 0x69, 0xa2, 0x3c, 0xa8, 0xb9, 0x3f, 0xdb, 0x60, 0xed, 0xa3, 0x0, 0x25, 0x2, 0x0, - 0x17, 0xc9, 0xb1, 0x44, 0x84, 0x79, 0xf6, 0x7d, 0x61, 0x64, 0x87, 0xe4, 0x1f, 0x3c, 0x48, 0x32, 0x5d, 0x56, 0xff, - 0x9e, 0x65, 0xdf, 0xff, 0xfa, 0x1, 0x0, 0x4, 0x3d, 0xcd, 0x6f, 0x15, 0x2, 0x0, 0x10, 0x83, 0xcf, 0x36, 0x57, - 0xc3, 0x20, 0x67, 0x4c, 0xb2, 0xda, 0x82, 0x98, 0x75, 0xd1, 0x3e, 0x9, 0x0, 0x0, 0x15, 0x84, 0x6c, 0x79, 0x69, - 0x5d, 0x2e, 0x4e, 0x87, 0x67, 0xa4, 0x73, 0x65, 0xa0, 0xeb, 0x21, 0x6e, 0x9e, 0xef, 0x4d, 0x71, 0x5a, 0x0}; +// QoS1}),("W\185i\STX8n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0}),(",\244N\145.o\200\211.\221B{\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode20) { + uint8_t pkt[] = {0x82, 0xad, 0x1, 0x53, 0x1, 0x0, 0x12, 0x37, 0x8d, 0x9a, 0xe6, 0x81, 0xf4, 0xec, 0x8a, 0x27, + 0x1e, 0xd0, 0x68, 0x26, 0x59, 0xaa, 0xd, 0xe5, 0x71, 0x1, 0x0, 0x1, 0x51, 0x0, 0x0, 0x16, + 0x96, 0x2b, 0x3a, 0x5f, 0x78, 0x3c, 0x53, 0xa5, 0x6f, 0x22, 0x7d, 0x8a, 0x1d, 0xbd, 0xef, 0xf6, + 0x68, 0xdf, 0xcb, 0xf5, 0x8a, 0xbb, 0x1, 0x0, 0x1a, 0x5a, 0xdc, 0xb, 0x62, 0xaa, 0x2d, 0xf9, + 0xc3, 0xd1, 0xbf, 0x5b, 0xc3, 0x45, 0x95, 0xcd, 0x22, 0xcd, 0x7e, 0xf9, 0xd3, 0x3a, 0xd3, 0x65, + 0x5a, 0xf8, 0x52, 0x2, 0x0, 0x1c, 0xa7, 0xf8, 0xf6, 0x8b, 0x9d, 0x7b, 0x9f, 0x74, 0x62, 0xa3, + 0xcc, 0x5f, 0xd2, 0x38, 0xb1, 0xc, 0xb6, 0xea, 0x1e, 0x3e, 0x77, 0xb2, 0x5a, 0xfa, 0x16, 0xd2, + 0xb2, 0x4c, 0x2, 0x0, 0x1e, 0xfa, 0x7a, 0xe2, 0xd8, 0xa1, 0x3, 0x6, 0x88, 0xce, 0x1b, 0xad, + 0x1f, 0xda, 0xf7, 0x18, 0xf, 0xd5, 0x29, 0x7a, 0x3e, 0x7a, 0xbc, 0x2d, 0x45, 0xc3, 0x80, 0xb5, + 0x4c, 0xf8, 0x27, 0x1, 0x0, 0x6, 0x57, 0xb9, 0x69, 0x2, 0x38, 0x6e, 0x0, 0x0, 0x0, 0x0, + 0x0, 0xd, 0x2c, 0xf4, 0x4e, 0x91, 0x2e, 0x6f, 0xc8, 0xd3, 0x2e, 0xdd, 0x42, 0x7b, 0xb9, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x6b, 0x18, 0x2, 0xe6, 0x3f, 0xe7, 0xc7, 0x91, 0x82, 0x10, 0xb6, 0xe9, 0x57, - 0xe9, 0x35, 0x46, 0xfa, 0x99, 0x48, 0x6f, 0x69, 0x70, 0xf2, 0x57, 0xa4}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x37, 0x8d, 0x9a, 0xe6, 0x81, 0xf4, 0xec, 0x8a, 0x27, + 0x1e, 0xd0, 0x68, 0x26, 0x59, 0xaa, 0xd, 0xe5, 0x71}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9, 0xfd, 0xb2, 0xfe, 0x61, 0x8, 0xd9, 0x8f, 0xa2, 0x1c, - 0xdd, 0xee, 0x50, 0x47, 0xb1, 0xe5, 0xd0, 0x2a, 0x7f, 0x24, - 0x6b, 0xa0, 0x4f, 0x10, 0x73, 0x60, 0x84, 0x12, 0x15, 0x56}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x51}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd8, 0x2f, 0x95, 0x49, 0xe8, 0x68, 0x45, 0xf7, - 0x2a, 0x52, 0x57, 0xf4, 0xfb, 0x86, 0xcc}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x96, 0x2b, 0x3a, 0x5f, 0x78, 0x3c, 0x53, 0xa5, 0x6f, 0x22, 0x7d, + 0x8a, 0x1d, 0xbd, 0xef, 0xf6, 0x68, 0xdf, 0xcb, 0xf5, 0x8a, 0xbb}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1c, 0x39, 0x59, 0x75, 0xe1, 0xea, 0xf6, 0x1, 0x42, 0x3e, 0xc7, 0x23, 0xbc, - 0x22, 0x69, 0xa2, 0x3c, 0xa8, 0xb9, 0x3f, 0xdb, 0x60, 0xed, 0xa3, 0x0, 0x25}; + uint8_t topic_filter_s3_bytes[] = {0x5a, 0xdc, 0xb, 0x62, 0xaa, 0x2d, 0xf9, 0xc3, 0xd1, 0xbf, 0x5b, 0xc3, 0x45, + 0x95, 0xcd, 0x22, 0xcd, 0x7e, 0xf9, 0xd3, 0x3a, 0xd3, 0x65, 0x5a, 0xf8, 0x52}; lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc9, 0xb1, 0x44, 0x84, 0x79, 0xf6, 0x7d, 0x61, 0x64, 0x87, 0xe4, 0x1f, - 0x3c, 0x48, 0x32, 0x5d, 0x56, 0xff, 0x9e, 0x65, 0xdf, 0xff, 0xfa}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa7, 0xf8, 0xf6, 0x8b, 0x9d, 0x7b, 0x9f, 0x74, 0x62, 0xa3, + 0xcc, 0x5f, 0xd2, 0x38, 0xb1, 0xc, 0xb6, 0xea, 0x1e, 0x3e, + 0x77, 0xb2, 0x5a, 0xfa, 0x16, 0xd2, 0xb2, 0x4c}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x3d, 0xcd, 0x6f, 0x15}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xfa, 0x7a, 0xe2, 0xd8, 0xa1, 0x3, 0x6, 0x88, 0xce, 0x1b, + 0xad, 0x1f, 0xda, 0xf7, 0x18, 0xf, 0xd5, 0x29, 0x7a, 0x3e, + 0x7a, 0xbc, 0x2d, 0x45, 0xc3, 0x80, 0xb5, 0x4c, 0xf8, 0x27}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x83, 0xcf, 0x36, 0x57, 0xc3, 0x20, 0x67, 0x4c, - 0xb2, 0xda, 0x82, 0x98, 0x75, 0xd1, 0x3e, 0x9}; - lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x57, 0xb9, 0x69, 0x2, 0x38, 0x6e}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x84, 0x6c, 0x79, 0x69, 0x5d, 0x2e, 0x4e, 0x87, 0x67, 0xa4, 0x73, - 0x65, 0xa0, 0xeb, 0x21, 0x6e, 0x9e, 0xef, 0x4d, 0x71, 0x5a}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; + uint8_t topic_filter_s8_bytes[] = {0x2c, 0xf4, 0x4e, 0x91, 0x2e, 0x6f, 0xc8, 0xd3, 0x2e, 0xdd, 0x42, 0x7b, 0xb9}; + lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -11886,7 +15583,7 @@ TEST(Subscribe311QCTest, Encode19) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -11894,11 +15591,11 @@ TEST(Subscribe311QCTest, Encode19) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -11910,57 +15607,63 @@ TEST(Subscribe311QCTest, Encode19) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10879, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21249, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26713 [("i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("0\150\163\DC3)S\193\165K\135\211\DC43\159\\/\250+\200MF\149sGs{t\158",SubOptions +// SubscribeRequest 32237 [("4kW\253\213\191\228\173\&8\EM\n",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("n\199=\255]\ETX\237\&4\249V\187\139\228\DELVS\208~\231\232\208\203\187JH\153D\214\183",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\180+?\143\187\GS",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("s\t\186\187\183\237\241gr\201",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\SYN\179\228\226\252EZ\t\240$\ENQ\239JJq",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("D",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode20) { - uint8_t pkt[] = {0x82, 0x51, 0x68, 0x59, 0x0, 0x1, 0x69, 0x2, 0x0, 0x1c, 0x30, 0x96, 0xa3, 0x13, 0x29, 0x53, 0xc1, - 0xa5, 0x4b, 0x87, 0xd3, 0x14, 0x33, 0x9f, 0x5c, 0x2f, 0xfa, 0x2b, 0xc8, 0x4d, 0x46, 0x95, 0x73, 0x47, - 0x73, 0x7b, 0x74, 0x9e, 0x1, 0x0, 0x6, 0xb4, 0x2b, 0x3f, 0x8f, 0xbb, 0x1d, 0x0, 0x0, 0xa, 0x73, - 0x9, 0xba, 0xbb, 0xb7, 0xed, 0xf1, 0x67, 0x72, 0xc9, 0x0, 0x0, 0xf, 0x16, 0xb3, 0xe4, 0xe2, 0xfc, - 0x45, 0x5a, 0x9, 0xf0, 0x24, 0x5, 0xef, 0x4a, 0x4a, 0x71, 0x1, 0x0, 0x1, 0x44, 0x1}; +// QoS1}),("I\199\145I:\210\ETX\150\215N\aE3l\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS2}),("\NAK6\182D\195\163\&3y\228P\236\212\201\235T\a\151\SUB4\235\185\ETBs",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\128j\150\163\160%mXs\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode21) { + uint8_t pkt[] = {0x82, 0x69, 0x7d, 0xed, 0x0, 0xb, 0x34, 0x6b, 0x57, 0xfd, 0xd5, 0xbf, 0xe4, 0xad, 0x38, 0x19, + 0xa, 0x1, 0x0, 0x1d, 0x6e, 0xc7, 0x3d, 0xff, 0x5d, 0x3, 0xed, 0x34, 0xf9, 0x56, 0xbb, 0x8b, + 0xe4, 0x7f, 0x56, 0x53, 0xd0, 0x7e, 0xe7, 0xe8, 0xd0, 0xcb, 0xbb, 0x4a, 0x48, 0x99, 0x44, 0xd6, + 0xb7, 0x1, 0x0, 0xf, 0x49, 0xc7, 0x91, 0x49, 0x3a, 0xd2, 0x3, 0x96, 0xd7, 0x4e, 0x7, 0x45, + 0x33, 0x6c, 0xb8, 0x2, 0x0, 0x17, 0x15, 0x36, 0xb6, 0x44, 0xc3, 0xa3, 0x33, 0x79, 0xe4, 0x50, + 0xec, 0xd4, 0xc9, 0xeb, 0x54, 0x7, 0x97, 0x1a, 0x34, 0xeb, 0xb9, 0x17, 0x73, 0x2, 0x0, 0xa, + 0x80, 0x6a, 0x96, 0xa3, 0xa0, 0x25, 0x6d, 0x58, 0x73, 0x98, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x69}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x34, 0x6b, 0x57, 0xfd, 0xd5, 0xbf, 0xe4, 0xad, 0x38, 0x19, 0xa}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x30, 0x96, 0xa3, 0x13, 0x29, 0x53, 0xc1, 0xa5, 0x4b, 0x87, - 0xd3, 0x14, 0x33, 0x9f, 0x5c, 0x2f, 0xfa, 0x2b, 0xc8, 0x4d, - 0x46, 0x95, 0x73, 0x47, 0x73, 0x7b, 0x74, 0x9e}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6e, 0xc7, 0x3d, 0xff, 0x5d, 0x3, 0xed, 0x34, 0xf9, 0x56, + 0xbb, 0x8b, 0xe4, 0x7f, 0x56, 0x53, 0xd0, 0x7e, 0xe7, 0xe8, + 0xd0, 0xcb, 0xbb, 0x4a, 0x48, 0x99, 0x44, 0xd6, 0xb7}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb4, 0x2b, 0x3f, 0x8f, 0xbb, 0x1d}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x49, 0xc7, 0x91, 0x49, 0x3a, 0xd2, 0x3, 0x96, + 0xd7, 0x4e, 0x7, 0x45, 0x33, 0x6c, 0xb8}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x73, 0x9, 0xba, 0xbb, 0xb7, 0xed, 0xf1, 0x67, 0x72, 0xc9}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x15, 0x36, 0xb6, 0x44, 0xc3, 0xa3, 0x33, 0x79, 0xe4, 0x50, 0xec, 0xd4, + 0xc9, 0xeb, 0x54, 0x7, 0x97, 0x1a, 0x34, 0xeb, 0xb9, 0x17, 0x73}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x16, 0xb3, 0xe4, 0xe2, 0xfc, 0x45, 0x5a, 0x9, - 0xf0, 0x24, 0x5, 0xef, 0x4a, 0x4a, 0x71}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x80, 0x6a, 0x96, 0xa3, 0xa0, 0x25, 0x6d, 0x58, 0x73, 0x98}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x44}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -11968,50 +15671,61 @@ TEST(Subscribe311QCTest, Encode20) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS0; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; + sub_opts[4].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26713, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32237, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25908 [("\158\154$vc\165\145gf\234i\231\148\155\181",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\RS\209\233$}",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode21) { - uint8_t pkt[] = {0x82, 0x1c, 0x65, 0x34, 0x0, 0xf, 0x9e, 0x9a, 0x24, 0x76, 0x63, 0xa5, 0x91, 0x67, 0x66, - 0xea, 0x69, 0xe7, 0x94, 0x9b, 0xb5, 0x2, 0x0, 0x5, 0x1e, 0xd1, 0xe9, 0x24, 0x7d, 0x0}; +// SubscribeRequest 1376 [(";\183\191\187\221\202\191\DC3FT\197\175\DC4\217>'\224\SIEx\189\194,",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("IaJ\ACK{\144@\ACK)XK\128\\7\ETX\159\146\SYN\141",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("o\209\197\246\162b\NAK\141\232A8\174\ACK\205\242+\ETX\SOHp\129\232\SUB\205\209&",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\US",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode22) { + uint8_t pkt[] = {0x82, 0x52, 0x5, 0x60, 0x0, 0x17, 0x3b, 0xb7, 0xbf, 0xbb, 0xdd, 0xca, 0xbf, 0x13, 0x46, 0x54, 0xc5, + 0xaf, 0x14, 0xd9, 0x3e, 0x27, 0xe0, 0xf, 0x45, 0x78, 0xbd, 0xc2, 0x2c, 0x2, 0x0, 0x13, 0x49, 0x61, + 0x4a, 0x6, 0x7b, 0x90, 0x40, 0x6, 0x29, 0x58, 0x4b, 0x80, 0x5c, 0x37, 0x3, 0x9f, 0x92, 0x16, 0x8d, + 0x0, 0x0, 0x19, 0x6f, 0xd1, 0xc5, 0xf6, 0xa2, 0x62, 0x15, 0x8d, 0xe8, 0x41, 0x38, 0xae, 0x6, 0xcd, + 0xf2, 0x2b, 0x3, 0x1, 0x70, 0x81, 0xe8, 0x1a, 0xcd, 0xd1, 0x26, 0x2, 0x0, 0x1, 0x1f, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x9e, 0x9a, 0x24, 0x76, 0x63, 0xa5, 0x91, 0x67, - 0x66, 0xea, 0x69, 0xe7, 0x94, 0x9b, 0xb5}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x3b, 0xb7, 0xbf, 0xbb, 0xdd, 0xca, 0xbf, 0x13, 0x46, 0x54, 0xc5, 0xaf, + 0x14, 0xd9, 0x3e, 0x27, 0xe0, 0xf, 0x45, 0x78, 0xbd, 0xc2, 0x2c}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1e, 0xd1, 0xe9, 0x24, 0x7d}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x49, 0x61, 0x4a, 0x6, 0x7b, 0x90, 0x40, 0x6, 0x29, 0x58, + 0x4b, 0x80, 0x5c, 0x37, 0x3, 0x9f, 0x92, 0x16, 0x8d}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; + uint8_t topic_filter_s2_bytes[] = {0x6f, 0xd1, 0xc5, 0xf6, 0xa2, 0x62, 0x15, 0x8d, 0xe8, 0x41, 0x38, 0xae, 0x6, + 0xcd, 0xf2, 0x2b, 0x3, 0x1, 0x70, 0x81, 0xe8, 0x1a, 0xcd, 0xd1, 0x26}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x1f}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -12020,183 +15734,397 @@ TEST(Subscribe311QCTest, Encode21) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25908, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1376, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20578 [("\224\194C\240\225\DC1\DEL\202~\187o\222v\157/\164<\CAN\230;\141",SubOptions +// SubscribeRequest 20213 [("\228\181kq\t",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\217\&9\137\SYN\SUB\221t\182\SImim\223\212]",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\128",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\182\130\204\SOH\136\244\204\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("\163\SI&zW\202\147_\174~O\152\137\242\205\DC3\131\180w \252\148",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("m\173}5\SUB\254\SI\157\231",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\r$\DLE9\US*E\226",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("H\DELG\141Np",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("b\201E\195z\240\\k\177\&0\240\216\209\199=\139\251\222\254\173",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("cw,\227\r\161\128\EM:\197/\f\DEL\143\174\169\241\238&",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("-\131\DC3-/\EOTY\146\153]\138\149\250e\132m\EOTrrX\226",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode22) { - uint8_t pkt[] = {0x82, 0x31, 0x50, 0x62, 0x0, 0x15, 0xe0, 0xc2, 0x43, 0xf0, 0xe1, 0x11, 0x7f, 0xca, 0x7e, 0xbb, 0x6f, - 0xde, 0x76, 0x9d, 0x2f, 0xa4, 0x3c, 0x18, 0xe6, 0x3b, 0x8d, 0x1, 0x0, 0x9, 0x6d, 0xad, 0x7d, 0x35, - 0x1a, 0xfe, 0xf, 0x9d, 0xe7, 0x2, 0x0, 0x8, 0xd, 0x24, 0x10, 0x39, 0x1f, 0x2a, 0x45, 0xe2, 0x1}; +TEST(Subscribe311QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0x95, 0x1, 0x4e, 0xf5, 0x0, 0x5, 0xe4, 0xb5, 0x6b, 0x71, 0x9, 0x0, 0x0, 0xf, 0xd9, 0x39, + 0x89, 0x16, 0x1a, 0xdd, 0x74, 0xb6, 0xf, 0x6d, 0x69, 0x6d, 0xdf, 0xd4, 0x5d, 0x1, 0x0, 0x1, 0x80, + 0x0, 0x0, 0x0, 0x2, 0x0, 0x8, 0xb6, 0x82, 0xcc, 0x1, 0x88, 0xf4, 0xcc, 0x98, 0x1, 0x0, 0x16, + 0xa3, 0xf, 0x26, 0x7a, 0x57, 0xca, 0x93, 0x5f, 0xae, 0x7e, 0x4f, 0x98, 0x89, 0xf2, 0xcd, 0x13, 0x83, + 0xb4, 0x77, 0x20, 0xfc, 0x94, 0x2, 0x0, 0x6, 0x48, 0x7f, 0x47, 0x8d, 0x4e, 0x70, 0x1, 0x0, 0x14, + 0x62, 0xc9, 0x45, 0xc3, 0x7a, 0xf0, 0x5c, 0x6b, 0xb1, 0x30, 0xf0, 0xd8, 0xd1, 0xc7, 0x3d, 0x8b, 0xfb, + 0xde, 0xfe, 0xad, 0x2, 0x0, 0x13, 0x63, 0x77, 0x2c, 0xe3, 0xd, 0xa1, 0x80, 0x19, 0x3a, 0xc5, 0x2f, + 0xc, 0x7f, 0x8f, 0xae, 0xa9, 0xf1, 0xee, 0x26, 0x1, 0x0, 0x15, 0x2d, 0x83, 0x13, 0x2d, 0x2f, 0x4, + 0x59, 0x92, 0x99, 0x5d, 0x8a, 0x95, 0xfa, 0x65, 0x84, 0x6d, 0x4, 0x72, 0x72, 0x58, 0xe2, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xe0, 0xc2, 0x43, 0xf0, 0xe1, 0x11, 0x7f, 0xca, 0x7e, 0xbb, 0x6f, - 0xde, 0x76, 0x9d, 0x2f, 0xa4, 0x3c, 0x18, 0xe6, 0x3b, 0x8d}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xe4, 0xb5, 0x6b, 0x71, 0x9}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6d, 0xad, 0x7d, 0x35, 0x1a, 0xfe, 0xf, 0x9d, 0xe7}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd9, 0x39, 0x89, 0x16, 0x1a, 0xdd, 0x74, 0xb6, + 0xf, 0x6d, 0x69, 0x6d, 0xdf, 0xd4, 0x5d}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd, 0x24, 0x10, 0x39, 0x1f, 0x2a, 0x45, 0xe2}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x80}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xb6, 0x82, 0xcc, 0x1, 0x88, 0xf4, 0xcc, 0x98}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xa3, 0xf, 0x26, 0x7a, 0x57, 0xca, 0x93, 0x5f, 0xae, 0x7e, 0x4f, + 0x98, 0x89, 0xf2, 0xcd, 0x13, 0x83, 0xb4, 0x77, 0x20, 0xfc, 0x94}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x48, 0x7f, 0x47, 0x8d, 0x4e, 0x70}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x62, 0xc9, 0x45, 0xc3, 0x7a, 0xf0, 0x5c, 0x6b, 0xb1, 0x30, + 0xf0, 0xd8, 0xd1, 0xc7, 0x3d, 0x8b, 0xfb, 0xde, 0xfe, 0xad}; + lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x63, 0x77, 0x2c, 0xe3, 0xd, 0xa1, 0x80, 0x19, 0x3a, 0xc5, + 0x2f, 0xc, 0x7f, 0x8f, 0xae, 0xa9, 0xf1, 0xee, 0x26}; + lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x2d, 0x83, 0x13, 0x2d, 0x2f, 0x4, 0x59, 0x92, 0x99, 0x5d, 0x8a, + 0x95, 0xfa, 0x65, 0x84, 0x6d, 0x4, 0x72, 0x72, 0x58, 0xe2}; + lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20578, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20213, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 13418 [("\EM\171z\153z\136\168{\150\208\134\ENQ\134\225\231\CAN}",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode23) { - uint8_t pkt[] = {0x82, 0x16, 0x34, 0x6a, 0x0, 0x11, 0x19, 0xab, 0x7a, 0x99, 0x7a, 0x88, - 0xa8, 0x7b, 0x96, 0xd0, 0x86, 0x5, 0x86, 0xe1, 0xe7, 0x18, 0x7d, 0x0}; +// SubscribeRequest 2875 [("\171\ESC\137\SO\239\178N8\149$\239",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\n\NUL\183\220@\191 +// \EOTb\199+\141\"\152\234\207\191=\166\f\nR;\249:",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode24) { + uint8_t pkt[] = {0x82, 0x2c, 0xb, 0x3b, 0x0, 0xb, 0xab, 0x1b, 0x89, 0xe, 0xef, 0xb2, 0x4e, 0x38, 0x95, 0x24, + 0xef, 0x1, 0x0, 0x19, 0xa, 0x0, 0xb7, 0xdc, 0x40, 0xbf, 0x20, 0x4, 0x62, 0xc7, 0x2b, 0x8d, + 0x22, 0x98, 0xea, 0xcf, 0xbf, 0x3d, 0xa6, 0xc, 0xa, 0x52, 0x3b, 0xf9, 0x3a, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x19, 0xab, 0x7a, 0x99, 0x7a, 0x88, 0xa8, 0x7b, 0x96, - 0xd0, 0x86, 0x5, 0x86, 0xe1, 0xe7, 0x18, 0x7d}; - lwmqtt_string_t topic_filter_s0 = {17, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xab, 0x1b, 0x89, 0xe, 0xef, 0xb2, 0x4e, 0x38, 0x95, 0x24, 0xef}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s1_bytes[] = {0xa, 0x0, 0xb7, 0xdc, 0x40, 0xbf, 0x20, 0x4, 0x62, 0xc7, 0x2b, 0x8d, 0x22, + 0x98, 0xea, 0xcf, 0xbf, 0x3d, 0xa6, 0xc, 0xa, 0x52, 0x3b, 0xf9, 0x3a}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13418, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2875, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22728 [("\166f3\207\139\210\163\t\187Z#\n\170",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 13469 [("\144\198\151\135\DC4%l",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\249\GS\245H\207\198\162qF\184@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\198\163V\201\199\CANp\234\161a\f",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\212R\209'",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\172\151\200\161\130zE\214\&3\212\199\SIg\129^\tMy",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("G\151j0\232B\192\231\172\a\206\224T\237",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x38, 0x58, 0xc8, 0x0, 0xd, 0xa6, 0x66, 0x33, 0xcf, 0x8b, 0xd2, 0xa3, 0x9, 0xbb, - 0x5a, 0x23, 0xa, 0xaa, 0x2, 0x0, 0x12, 0xac, 0x97, 0xc8, 0xa1, 0x82, 0x7a, 0x45, 0xd6, - 0x33, 0xd4, 0xc7, 0xf, 0x67, 0x81, 0x5e, 0x9, 0x4d, 0x79, 0x0, 0x0, 0xe, 0x47, 0x97, - 0x6a, 0x30, 0xe8, 0x42, 0xc0, 0xe7, 0xac, 0x7, 0xce, 0xe0, 0x54, 0xed, 0x1}; +// QoS1}),("\STX\192\151\241\157\237\211\129SA\NUL\189\a\138\161\204\137\RS",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("a\225rVu\DLE\US\SOH\242\166$5\217\135?,\DLE\229HF\180\"\207\151",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\232\224",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("oI\179\175\197\204\237\STX\216\167",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\146G*\165",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\v\ENQU\202r'\152\228+\231dA\182MS\255*\137\135\175(",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("+\221^T7\161\222\SOHq>U\192R\187\247\201\195\249\165\214\&9\138\&0b",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode25) { + uint8_t pkt[] = {0x82, 0xab, 0x1, 0x34, 0x9d, 0x0, 0x7, 0x90, 0xc6, 0x97, 0x87, 0x14, 0x25, 0x6c, 0x1, 0x0, + 0xb, 0xf9, 0x1d, 0xf5, 0x48, 0xcf, 0xc6, 0xa2, 0x71, 0x46, 0xb8, 0x40, 0x1, 0x0, 0xb, 0xc6, + 0xa3, 0x56, 0xc9, 0xc7, 0x18, 0x70, 0xea, 0xa1, 0x61, 0xc, 0x2, 0x0, 0x4, 0xd4, 0x52, 0xd1, + 0x27, 0x1, 0x0, 0x12, 0x2, 0xc0, 0x97, 0xf1, 0x9d, 0xed, 0xd3, 0x81, 0x53, 0x41, 0x0, 0xbd, + 0x7, 0x8a, 0xa1, 0xcc, 0x89, 0x1e, 0x1, 0x0, 0x18, 0x61, 0xe1, 0x72, 0x56, 0x75, 0x10, 0x1f, + 0x1, 0xf2, 0xa6, 0x24, 0x35, 0xd9, 0x87, 0x3f, 0x2c, 0x10, 0xe5, 0x48, 0x46, 0xb4, 0x22, 0xcf, + 0x97, 0x0, 0x0, 0x2, 0xe8, 0xe0, 0x1, 0x0, 0xa, 0x6f, 0x49, 0xb3, 0xaf, 0xc5, 0xcc, 0xed, + 0x2, 0xd8, 0xa7, 0x1, 0x0, 0x4, 0x92, 0x47, 0x2a, 0xa5, 0x2, 0x0, 0x15, 0xb, 0x5, 0x55, + 0xca, 0x72, 0x27, 0x98, 0xe4, 0x2b, 0xe7, 0x64, 0x41, 0xb6, 0x4d, 0x53, 0xff, 0x2a, 0x89, 0x87, + 0xaf, 0x28, 0x2, 0x0, 0x18, 0x2b, 0xdd, 0x5e, 0x54, 0x37, 0xa1, 0xde, 0x1, 0x71, 0x3e, 0x55, + 0xc0, 0x52, 0xbb, 0xf7, 0xc9, 0xc3, 0xf9, 0xa5, 0xd6, 0x39, 0x8a, 0x30, 0x62, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xa6, 0x66, 0x33, 0xcf, 0x8b, 0xd2, 0xa3, 0x9, 0xbb, 0x5a, 0x23, 0xa, 0xaa}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x90, 0xc6, 0x97, 0x87, 0x14, 0x25, 0x6c}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xac, 0x97, 0xc8, 0xa1, 0x82, 0x7a, 0x45, 0xd6, 0x33, - 0xd4, 0xc7, 0xf, 0x67, 0x81, 0x5e, 0x9, 0x4d, 0x79}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf9, 0x1d, 0xf5, 0x48, 0xcf, 0xc6, 0xa2, 0x71, 0x46, 0xb8, 0x40}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x47, 0x97, 0x6a, 0x30, 0xe8, 0x42, 0xc0, 0xe7, 0xac, 0x7, 0xce, 0xe0, 0x54, 0xed}; - lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc6, 0xa3, 0x56, 0xc9, 0xc7, 0x18, 0x70, 0xea, 0xa1, 0x61, 0xc}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s3_bytes[] = {0xd4, 0x52, 0xd1, 0x27}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x2, 0xc0, 0x97, 0xf1, 0x9d, 0xed, 0xd3, 0x81, 0x53, + 0x41, 0x0, 0xbd, 0x7, 0x8a, 0xa1, 0xcc, 0x89, 0x1e}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x61, 0xe1, 0x72, 0x56, 0x75, 0x10, 0x1f, 0x1, 0xf2, 0xa6, 0x24, 0x35, + 0xd9, 0x87, 0x3f, 0x2c, 0x10, 0xe5, 0x48, 0x46, 0xb4, 0x22, 0xcf, 0x97}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xe8, 0xe0}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6f, 0x49, 0xb3, 0xaf, 0xc5, 0xcc, 0xed, 0x2, 0xd8, 0xa7}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x92, 0x47, 0x2a, 0xa5}; + lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xb, 0x5, 0x55, 0xca, 0x72, 0x27, 0x98, 0xe4, 0x2b, 0xe7, 0x64, + 0x41, 0xb6, 0x4d, 0x53, 0xff, 0x2a, 0x89, 0x87, 0xaf, 0x28}; + lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x2b, 0xdd, 0x5e, 0x54, 0x37, 0xa1, 0xde, 0x1, 0x71, 0x3e, 0x55, 0xc0, + 0x52, 0xbb, 0xf7, 0xc9, 0xc3, 0xf9, 0xa5, 0xd6, 0x39, 0x8a, 0x30, 0x62}; + lwmqtt_string_t topic_filter_s10 = {24, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22728, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13469, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 17738 [("\217\130'@BS\183\201\137\SOH\DC4\225o",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0x12, 0x45, 0x4a, 0x0, 0xd, 0xd9, 0x82, 0x27, 0x40, - 0x42, 0x53, 0xb7, 0xc9, 0x89, 0x1, 0x14, 0xe1, 0x6f, 0x2}; +// SubscribeRequest 9632 [("9\192\243\129\177\140\182\244C\213\169\203\&4z!Y\215\&3\200\FS|K\216)",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\150M\179",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode26) { + uint8_t pkt[] = {0x82, 0x23, 0x25, 0xa0, 0x0, 0x18, 0x39, 0xc0, 0xf3, 0x81, 0xb1, 0x8c, 0xb6, + 0xf4, 0x43, 0xd5, 0xa9, 0xcb, 0x34, 0x7a, 0x21, 0x59, 0xd7, 0x33, 0xc8, 0x1c, + 0x7c, 0x4b, 0xd8, 0x29, 0x1, 0x0, 0x3, 0x96, 0x4d, 0xb3, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xd9, 0x82, 0x27, 0x40, 0x42, 0x53, 0xb7, 0xc9, 0x89, 0x1, 0x14, 0xe1, 0x6f}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x39, 0xc0, 0xf3, 0x81, 0xb1, 0x8c, 0xb6, 0xf4, 0x43, 0xd5, 0xa9, 0xcb, + 0x34, 0x7a, 0x21, 0x59, 0xd7, 0x33, 0xc8, 0x1c, 0x7c, 0x4b, 0xd8, 0x29}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s1_bytes[] = {0x96, 0x4d, 0xb3}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17738, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9632, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21727 [("\220\186\EOT'\230\ACK\148x\215=1\233\144*\214{t\159\208X\ENQ\n*n\NAK",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("O\nf",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x24, 0x54, 0xdf, 0x0, 0x19, 0xdc, 0xba, 0x4, 0x27, 0xe6, 0x6, 0x94, - 0x78, 0xd7, 0x3d, 0x31, 0xe9, 0x90, 0x2a, 0xd6, 0x7b, 0x74, 0x9f, 0xd0, 0x58, - 0x5, 0xa, 0x2a, 0x6e, 0x15, 0x1, 0x0, 0x3, 0x4f, 0xa, 0x66, 0x1}; +// SubscribeRequest 32536 [("\STXFdF1}k\173 c{\188a\199\bh$\SYN\179\&1\a6\DLE\DC1\181",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("{\238\131\204\f\255\221\189\217b\165\148-\170\248\223\222\134{\151p\247\153\164\n",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\137\236\169\249\206aNj\160O\152b\176\230M\205\GS\146\184\213",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("N=\251\238D\139\DC3\SYNL\154))\182\221\132\150\225",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\223!\135V\191\128\&4\190\223\171\&3\234][\195%\175\f||mp\"\214\252\170",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("r\158\170l\"uyP\tR\f\152\176\140\213\227\&6I\249\187A\177\&7\159\136",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\163\196",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode27) { + uint8_t pkt[] = {0x82, 0xa3, 0x1, 0x7f, 0x18, 0x0, 0x19, 0x2, 0x46, 0x64, 0x46, 0x31, 0x7d, 0x6b, 0xad, 0x20, 0x63, + 0x7b, 0xbc, 0x61, 0xc7, 0x8, 0x68, 0x24, 0x16, 0xb3, 0x31, 0x7, 0x36, 0x10, 0x11, 0xb5, 0x1, 0x0, + 0x19, 0x7b, 0xee, 0x83, 0xcc, 0xc, 0xff, 0xdd, 0xbd, 0xd9, 0x62, 0xa5, 0x94, 0x2d, 0xaa, 0xf8, 0xdf, + 0xde, 0x86, 0x7b, 0x97, 0x70, 0xf7, 0x99, 0xa4, 0xa, 0x1, 0x0, 0x14, 0x89, 0xec, 0xa9, 0xf9, 0xce, + 0x61, 0x4e, 0x6a, 0xa0, 0x4f, 0x98, 0x62, 0xb0, 0xe6, 0x4d, 0xcd, 0x1d, 0x92, 0xb8, 0xd5, 0x2, 0x0, + 0x11, 0x4e, 0x3d, 0xfb, 0xee, 0x44, 0x8b, 0x13, 0x16, 0x4c, 0x9a, 0x29, 0x29, 0xb6, 0xdd, 0x84, 0x96, + 0xe1, 0x2, 0x0, 0x1a, 0xdf, 0x21, 0x87, 0x56, 0xbf, 0x80, 0x34, 0xbe, 0xdf, 0xab, 0x33, 0xea, 0x5d, + 0x5b, 0xc3, 0x25, 0xaf, 0xc, 0x7c, 0x7c, 0x6d, 0x70, 0x22, 0xd6, 0xfc, 0xaa, 0x2, 0x0, 0x19, 0x72, + 0x9e, 0xaa, 0x6c, 0x22, 0x75, 0x79, 0x50, 0x9, 0x52, 0xc, 0x98, 0xb0, 0x8c, 0xd5, 0xe3, 0x36, 0x49, + 0xf9, 0xbb, 0x41, 0xb1, 0x37, 0x9f, 0x88, 0x2, 0x0, 0x2, 0xa3, 0xc4, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xdc, 0xba, 0x4, 0x27, 0xe6, 0x6, 0x94, 0x78, 0xd7, 0x3d, 0x31, 0xe9, 0x90, - 0x2a, 0xd6, 0x7b, 0x74, 0x9f, 0xd0, 0x58, 0x5, 0xa, 0x2a, 0x6e, 0x15}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x2, 0x46, 0x64, 0x46, 0x31, 0x7d, 0x6b, 0xad, 0x20, 0x63, 0x7b, 0xbc, 0x61, + 0xc7, 0x8, 0x68, 0x24, 0x16, 0xb3, 0x31, 0x7, 0x36, 0x10, 0x11, 0xb5}; lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4f, 0xa, 0x66}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7b, 0xee, 0x83, 0xcc, 0xc, 0xff, 0xdd, 0xbd, 0xd9, 0x62, 0xa5, 0x94, 0x2d, + 0xaa, 0xf8, 0xdf, 0xde, 0x86, 0x7b, 0x97, 0x70, 0xf7, 0x99, 0xa4, 0xa}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; + uint8_t topic_filter_s2_bytes[] = {0x89, 0xec, 0xa9, 0xf9, 0xce, 0x61, 0x4e, 0x6a, 0xa0, 0x4f, + 0x98, 0x62, 0xb0, 0xe6, 0x4d, 0xcd, 0x1d, 0x92, 0xb8, 0xd5}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x4e, 0x3d, 0xfb, 0xee, 0x44, 0x8b, 0x13, 0x16, 0x4c, + 0x9a, 0x29, 0x29, 0xb6, 0xdd, 0x84, 0x96, 0xe1}; + lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xdf, 0x21, 0x87, 0x56, 0xbf, 0x80, 0x34, 0xbe, 0xdf, 0xab, 0x33, 0xea, 0x5d, + 0x5b, 0xc3, 0x25, 0xaf, 0xc, 0x7c, 0x7c, 0x6d, 0x70, 0x22, 0xd6, 0xfc, 0xaa}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x72, 0x9e, 0xaa, 0x6c, 0x22, 0x75, 0x79, 0x50, 0x9, 0x52, 0xc, 0x98, 0xb0, + 0x8c, 0xd5, 0xe3, 0x36, 0x49, 0xf9, 0xbb, 0x41, 0xb1, 0x37, 0x9f, 0x88}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa3, 0xc4}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -12205,41 +16133,97 @@ TEST(Subscribe311QCTest, Encode26) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21727, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32536, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19375 [("\225\165Uj\\\240\190*Vv\135:f)\169i/up&",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\203N\154\STXXt\245\221\238\134 ?=",SubOptions +// SubscribeRequest 8552 [("]4\248\137\131\225_b\212\169\ETB\r",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\189\197\252R\ESC\GSJu",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("8#\221F96b\232\216\162\191\129(\152\184\DEL",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("`\173\EM\193X\175l}[\182\b\194\146S0;0\ESCkSX#:",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\139E\182\226c{\194\248\214N?\196\221\221\195%<\SI9",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\134\147\229\f\251`A\191\GS",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\SUB\205",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0x2e, 0x4b, 0xaf, 0x0, 0x14, 0xe1, 0xa5, 0x55, 0x6a, 0x5c, 0xf0, 0xbe, 0x2a, 0x56, 0x76, - 0x87, 0x3a, 0x66, 0x29, 0xa9, 0x69, 0x2f, 0x75, 0x70, 0x26, 0x0, 0x0, 0xd, 0xcb, 0x4e, 0x9a, - 0x2, 0x58, 0x74, 0xf5, 0xdd, 0xee, 0x86, 0x20, 0x3f, 0x3d, 0x2, 0x0, 0x2, 0x1a, 0xcd, 0x0}; +// QoS0}),("h\248Ay\190)%\\6\168\199",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\182\ETB\208\179\128\200\169RV\232=S+D\223S",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\172\216\203\210O\225",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode28) { + uint8_t pkt[] = {0x82, 0x95, 0x1, 0x21, 0x68, 0x0, 0xc, 0x5d, 0x34, 0xf8, 0x89, 0x83, 0xe1, 0x5f, 0x62, 0xd4, 0xa9, + 0x17, 0xd, 0x2, 0x0, 0x8, 0xbd, 0xc5, 0xfc, 0x52, 0x1b, 0x1d, 0x4a, 0x75, 0x2, 0x0, 0x10, 0x38, + 0x23, 0xdd, 0x46, 0x39, 0x36, 0x62, 0xe8, 0xd8, 0xa2, 0xbf, 0x81, 0x28, 0x98, 0xb8, 0x7f, 0x2, 0x0, + 0x17, 0x60, 0xad, 0x19, 0xc1, 0x58, 0xaf, 0x6c, 0x7d, 0x5b, 0xb6, 0x8, 0xc2, 0x92, 0x53, 0x30, 0x3b, + 0x30, 0x1b, 0x6b, 0x53, 0x58, 0x23, 0x3a, 0x1, 0x0, 0x13, 0x8b, 0x45, 0xb6, 0xe2, 0x63, 0x7b, 0xc2, + 0xf8, 0xd6, 0x4e, 0x3f, 0xc4, 0xdd, 0xdd, 0xc3, 0x25, 0x3c, 0xf, 0x39, 0x1, 0x0, 0x9, 0x86, 0x93, + 0xe5, 0xc, 0xfb, 0x60, 0x41, 0xbf, 0x1d, 0x0, 0x0, 0xb, 0x68, 0xf8, 0x41, 0x79, 0xbe, 0x29, 0x25, + 0x5c, 0x36, 0xa8, 0xc7, 0x0, 0x0, 0x10, 0xb6, 0x17, 0xd0, 0xb3, 0x80, 0xc8, 0xa9, 0x52, 0x56, 0xe8, + 0x3d, 0x53, 0x2b, 0x44, 0xdf, 0x53, 0x1, 0x0, 0x6, 0xac, 0xd8, 0xcb, 0xd2, 0x4f, 0xe1, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xe1, 0xa5, 0x55, 0x6a, 0x5c, 0xf0, 0xbe, 0x2a, 0x56, 0x76, - 0x87, 0x3a, 0x66, 0x29, 0xa9, 0x69, 0x2f, 0x75, 0x70, 0x26}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x5d, 0x34, 0xf8, 0x89, 0x83, 0xe1, 0x5f, 0x62, 0xd4, 0xa9, 0x17, 0xd}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xcb, 0x4e, 0x9a, 0x2, 0x58, 0x74, 0xf5, 0xdd, 0xee, 0x86, 0x20, 0x3f, 0x3d}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbd, 0xc5, 0xfc, 0x52, 0x1b, 0x1d, 0x4a, 0x75}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1a, 0xcd}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x38, 0x23, 0xdd, 0x46, 0x39, 0x36, 0x62, 0xe8, + 0xd8, 0xa2, 0xbf, 0x81, 0x28, 0x98, 0xb8, 0x7f}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s3_bytes[] = {0x60, 0xad, 0x19, 0xc1, 0x58, 0xaf, 0x6c, 0x7d, 0x5b, 0xb6, 0x8, 0xc2, + 0x92, 0x53, 0x30, 0x3b, 0x30, 0x1b, 0x6b, 0x53, 0x58, 0x23, 0x3a}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x8b, 0x45, 0xb6, 0xe2, 0x63, 0x7b, 0xc2, 0xf8, 0xd6, 0x4e, + 0x3f, 0xc4, 0xdd, 0xdd, 0xc3, 0x25, 0x3c, 0xf, 0x39}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x86, 0x93, 0xe5, 0xc, 0xfb, 0x60, 0x41, 0xbf, 0x1d}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x68, 0xf8, 0x41, 0x79, 0xbe, 0x29, 0x25, 0x5c, 0x36, 0xa8, 0xc7}; + lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xb6, 0x17, 0xd0, 0xb3, 0x80, 0xc8, 0xa9, 0x52, + 0x56, 0xe8, 0x3d, 0x53, 0x2b, 0x44, 0xdf, 0x53}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xac, 0xd8, 0xcb, 0xd2, 0x4f, 0xe1}; + lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -12247,88 +16231,120 @@ TEST(Subscribe311QCTest, Encode27) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19375, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8552, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28027 [("\"g&\184\164\188M\DC4'tW=\211iw\223\142\177\135\221\193\212\ETX\235",SubOptions +// SubscribeRequest 21918 [("\253`\DLE\211u\248\DLE\EM\254\171\202\139\231",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\232K\189x\159_\CAN>\184'\159\128dT\156,Sx",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\143\f\GS\206\232\253e\EOTnk\201\SOH\129\176\DLE}\249\186\178*\248C\143\134\192\232\DC1T",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("Ef\203H",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("\174\&6\157\194{p\223\202\255Fi\201O\EM}\223\234$\EOTq\SYN\201\182\219\164:\136|x",SubOptions +// QoS2}),("\152\143d\215c\ACK\243*\227%\223e5a\210z}\170=7%c\157",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\213\\n\ETX\EM\163L\232\170",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(".",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("m\t\200\200|++\177\DLE\DC4,\198\195:SP44\161-",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("cW\193\160\232\166\&8@\244 -// \"\SI\171\&5Ky\215;\131\US\243c\144\128\214\138",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\174\&7\208h4ML@\STX\167Mp\vQ\232\148\r\254\b\189\132\219}\235\155\131\\,\255",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\219\233",SubOptions +// QoS1}),("\130$g=T];\221D\158\145\220\214\154",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),(")?Gbx/Ti\252/-\ACK\149\&5\176\184\156\\\CAN\ENQ\GS\191",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\139\228'\CAN\224\233y\170z\235\168\b'\237\"\171\177",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0xb1, 0x1, 0x6d, 0x7b, 0x0, 0x18, 0x22, 0x67, 0x26, 0xb8, 0xa4, 0xbc, 0x4d, 0x14, 0x27, 0x74, - 0x57, 0x3d, 0xd3, 0x69, 0x77, 0xdf, 0x8e, 0xb1, 0x87, 0xdd, 0xc1, 0xd4, 0x3, 0xeb, 0x2, 0x0, 0x4, - 0x45, 0x66, 0xcb, 0x48, 0x2, 0x0, 0x1d, 0xae, 0x36, 0x9d, 0xc2, 0x7b, 0x70, 0xdf, 0xca, 0xff, 0x46, - 0x69, 0xc9, 0x4f, 0x19, 0x7d, 0xdf, 0xea, 0x24, 0x4, 0x71, 0x16, 0xc9, 0xb6, 0xdb, 0xa4, 0x3a, 0x88, - 0x7c, 0x78, 0x2, 0x0, 0x14, 0x6d, 0x9, 0xc8, 0xc8, 0x7c, 0x2b, 0x2b, 0xb1, 0x10, 0x14, 0x2c, 0xc6, - 0xc3, 0x3a, 0x53, 0x50, 0x34, 0x34, 0xa1, 0x2d, 0x1, 0x0, 0x1a, 0x63, 0x57, 0xc1, 0xa0, 0xe8, 0xa6, - 0x38, 0x40, 0xf4, 0x20, 0x22, 0xf, 0xab, 0x35, 0x4b, 0x79, 0xd7, 0x3b, 0x83, 0x1f, 0xf3, 0x63, 0x90, - 0x80, 0xd6, 0x8a, 0x0, 0x0, 0x1d, 0xae, 0x37, 0xd0, 0x68, 0x34, 0x4d, 0x4c, 0x40, 0x2, 0xa7, 0x4d, - 0x70, 0xb, 0x51, 0xe8, 0x94, 0xd, 0xfe, 0x8, 0xbd, 0x84, 0xdb, 0x7d, 0xeb, 0x9b, 0x83, 0x5c, 0x2c, - 0xff, 0x0, 0x0, 0x2, 0xdb, 0xe9, 0x1, 0x0, 0x11, 0x8b, 0xe4, 0x27, 0x18, 0xe0, 0xe9, 0x79, 0xaa, - 0x7a, 0xeb, 0xa8, 0x8, 0x27, 0xed, 0x22, 0xab, 0xb1, 0x1}; +// QoS2}),("\139~1f\212\151\NUL\158C_8P",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("mt\246\185$\ENQjC\163\161\DC1\CAN\195\SO-i\224\241\208m",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode29) { + uint8_t pkt[] = {0x82, 0xc0, 0x1, 0x55, 0x9e, 0x0, 0xd, 0xfd, 0x60, 0x10, 0xd3, 0x75, 0xf8, 0x10, 0x19, 0xfe, 0xab, + 0xca, 0x8b, 0xe7, 0x0, 0x0, 0x12, 0xe8, 0x4b, 0xbd, 0x78, 0x9f, 0x5f, 0x18, 0x3e, 0xb8, 0x27, 0x9f, + 0x80, 0x64, 0x54, 0x9c, 0x2c, 0x53, 0x78, 0x0, 0x0, 0x1c, 0x8f, 0xc, 0x1d, 0xce, 0xe8, 0xfd, 0x65, + 0x4, 0x6e, 0x6b, 0xc9, 0x1, 0x81, 0xb0, 0x10, 0x7d, 0xf9, 0xba, 0xb2, 0x2a, 0xf8, 0x43, 0x8f, 0x86, + 0xc0, 0xe8, 0x11, 0x54, 0x2, 0x0, 0x17, 0x98, 0x8f, 0x64, 0xd7, 0x63, 0x6, 0xf3, 0x2a, 0xe3, 0x25, + 0xdf, 0x65, 0x35, 0x61, 0xd2, 0x7a, 0x7d, 0xaa, 0x3d, 0x37, 0x25, 0x63, 0x9d, 0x2, 0x0, 0x9, 0xd5, + 0x5c, 0x6e, 0x3, 0x19, 0xa3, 0x4c, 0xe8, 0xaa, 0x1, 0x0, 0x1, 0x2e, 0x1, 0x0, 0xe, 0x82, 0x24, + 0x67, 0x3d, 0x54, 0x5d, 0x3b, 0xdd, 0x44, 0x9e, 0x91, 0xdc, 0xd6, 0x9a, 0x1, 0x0, 0x16, 0x29, 0x3f, + 0x47, 0x62, 0x78, 0x2f, 0x54, 0x69, 0xfc, 0x2f, 0x2d, 0x6, 0x95, 0x35, 0xb0, 0xb8, 0x9c, 0x5c, 0x18, + 0x5, 0x1d, 0xbf, 0x2, 0x0, 0xc, 0x8b, 0x7e, 0x31, 0x66, 0xd4, 0x97, 0x0, 0x9e, 0x43, 0x5f, 0x38, + 0x50, 0x2, 0x0, 0x14, 0x6d, 0x74, 0xf6, 0xb9, 0x24, 0x5, 0x6a, 0x43, 0xa3, 0xa1, 0x11, 0x18, 0xc3, + 0xe, 0x2d, 0x69, 0xe0, 0xf1, 0xd0, 0x6d, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x22, 0x67, 0x26, 0xb8, 0xa4, 0xbc, 0x4d, 0x14, 0x27, 0x74, 0x57, 0x3d, - 0xd3, 0x69, 0x77, 0xdf, 0x8e, 0xb1, 0x87, 0xdd, 0xc1, 0xd4, 0x3, 0xeb}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xfd, 0x60, 0x10, 0xd3, 0x75, 0xf8, 0x10, 0x19, 0xfe, 0xab, 0xca, 0x8b, 0xe7}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x45, 0x66, 0xcb, 0x48}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe8, 0x4b, 0xbd, 0x78, 0x9f, 0x5f, 0x18, 0x3e, 0xb8, + 0x27, 0x9f, 0x80, 0x64, 0x54, 0x9c, 0x2c, 0x53, 0x78}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xae, 0x36, 0x9d, 0xc2, 0x7b, 0x70, 0xdf, 0xca, 0xff, 0x46, - 0x69, 0xc9, 0x4f, 0x19, 0x7d, 0xdf, 0xea, 0x24, 0x4, 0x71, - 0x16, 0xc9, 0xb6, 0xdb, 0xa4, 0x3a, 0x88, 0x7c, 0x78}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8f, 0xc, 0x1d, 0xce, 0xe8, 0xfd, 0x65, 0x4, 0x6e, 0x6b, + 0xc9, 0x1, 0x81, 0xb0, 0x10, 0x7d, 0xf9, 0xba, 0xb2, 0x2a, + 0xf8, 0x43, 0x8f, 0x86, 0xc0, 0xe8, 0x11, 0x54}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6d, 0x9, 0xc8, 0xc8, 0x7c, 0x2b, 0x2b, 0xb1, 0x10, 0x14, - 0x2c, 0xc6, 0xc3, 0x3a, 0x53, 0x50, 0x34, 0x34, 0xa1, 0x2d}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x98, 0x8f, 0x64, 0xd7, 0x63, 0x6, 0xf3, 0x2a, 0xe3, 0x25, 0xdf, 0x65, + 0x35, 0x61, 0xd2, 0x7a, 0x7d, 0xaa, 0x3d, 0x37, 0x25, 0x63, 0x9d}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x63, 0x57, 0xc1, 0xa0, 0xe8, 0xa6, 0x38, 0x40, 0xf4, 0x20, 0x22, 0xf, 0xab, - 0x35, 0x4b, 0x79, 0xd7, 0x3b, 0x83, 0x1f, 0xf3, 0x63, 0x90, 0x80, 0xd6, 0x8a}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd5, 0x5c, 0x6e, 0x3, 0x19, 0xa3, 0x4c, 0xe8, 0xaa}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xae, 0x37, 0xd0, 0x68, 0x34, 0x4d, 0x4c, 0x40, 0x2, 0xa7, - 0x4d, 0x70, 0xb, 0x51, 0xe8, 0x94, 0xd, 0xfe, 0x8, 0xbd, - 0x84, 0xdb, 0x7d, 0xeb, 0x9b, 0x83, 0x5c, 0x2c, 0xff}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x2e}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xdb, 0xe9}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x82, 0x24, 0x67, 0x3d, 0x54, 0x5d, 0x3b, + 0xdd, 0x44, 0x9e, 0x91, 0xdc, 0xd6, 0x9a}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x8b, 0xe4, 0x27, 0x18, 0xe0, 0xe9, 0x79, 0xaa, 0x7a, - 0xeb, 0xa8, 0x8, 0x27, 0xed, 0x22, 0xab, 0xb1}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x29, 0x3f, 0x47, 0x62, 0x78, 0x2f, 0x54, 0x69, 0xfc, 0x2f, 0x2d, + 0x6, 0x95, 0x35, 0xb0, 0xb8, 0x9c, 0x5c, 0x18, 0x5, 0x1d, 0xbf}; + lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s8_bytes[] = {0x8b, 0x7e, 0x31, 0x66, 0xd4, 0x97, 0x0, 0x9e, 0x43, 0x5f, 0x38, 0x50}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x6d, 0x74, 0xf6, 0xb9, 0x24, 0x5, 0x6a, 0x43, 0xa3, 0xa1, + 0x11, 0x18, 0xc3, 0xe, 0x2d, 0x69, 0xe0, 0xf1, 0xd0, 0x6d}; + lwmqtt_string_t topic_filter_s9 = {20, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -12336,15 +16352,15 @@ TEST(Subscribe311QCTest, Encode28) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -12352,1552 +16368,1703 @@ TEST(Subscribe311QCTest, Encode28) { sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28027, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21918, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 16403 [("36\t\GS\147",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\219(\232\129\147/\NAKI\148\189\191\241l\207\134M; -// \146\255\164\SI\129\251\252g\253\DLE=",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = -// QoS2}),("\178]k\204\209\202\239\157m\227\SI\182M\tft\NUL?\184]}\128\149%\202\234",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(",\249N\129\196\212+ft,\180\v\166\t\164j\DEL\ETB\SYNC\244GIO\203\176\180|\148",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode29) { - uint8_t pkt[] = {0x82, 0x67, 0x40, 0x13, 0x0, 0x5, 0x33, 0x36, 0x9, 0x1d, 0x93, 0x1, 0x0, 0x1d, 0xdb, - 0x28, 0xe8, 0x81, 0x93, 0x2f, 0x15, 0x49, 0x94, 0xbd, 0xbf, 0xf1, 0x6c, 0xcf, 0x86, 0x4d, - 0x3b, 0x20, 0x92, 0xff, 0xa4, 0xf, 0x81, 0xfb, 0xfc, 0x67, 0xfd, 0x10, 0x3d, 0x2, 0x0, - 0x1a, 0xb2, 0x5d, 0x6b, 0xcc, 0xd1, 0xca, 0xef, 0x9d, 0x6d, 0xe3, 0xf, 0xb6, 0x4d, 0x9, - 0x66, 0x74, 0x0, 0x3f, 0xb8, 0x5d, 0x7d, 0x80, 0x95, 0x25, 0xca, 0xea, 0x2, 0x0, 0x1d, - 0x2c, 0xf9, 0x4e, 0x81, 0xc4, 0xd4, 0x2b, 0x66, 0x74, 0x2c, 0xb4, 0xb, 0xa6, 0x9, 0xa4, - 0x6a, 0x7f, 0x17, 0x16, 0x43, 0xf4, 0x47, 0x49, 0x4f, 0xcb, 0xb0, 0xb4, 0x7c, 0x94, 0x0}; +// SubscribeRequest 32402 [("\222d\154J\229\133\152\210\152Q\129\228R\184<\202\149\147\206\245\169",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\195\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode30) { + uint8_t pkt[] = {0x82, 0x1f, 0x7e, 0x92, 0x0, 0x15, 0xde, 0x64, 0x9a, 0x4a, 0xe5, 0x85, 0x98, 0xd2, 0x98, 0x51, 0x81, + 0xe4, 0x52, 0xb8, 0x3c, 0xca, 0x95, 0x93, 0xce, 0xf5, 0xa9, 0x1, 0x0, 0x2, 0xc3, 0xba, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x33, 0x36, 0x9, 0x1d, 0x93}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xde, 0x64, 0x9a, 0x4a, 0xe5, 0x85, 0x98, 0xd2, 0x98, 0x51, 0x81, + 0xe4, 0x52, 0xb8, 0x3c, 0xca, 0x95, 0x93, 0xce, 0xf5, 0xa9}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xdb, 0x28, 0xe8, 0x81, 0x93, 0x2f, 0x15, 0x49, 0x94, 0xbd, - 0xbf, 0xf1, 0x6c, 0xcf, 0x86, 0x4d, 0x3b, 0x20, 0x92, 0xff, - 0xa4, 0xf, 0x81, 0xfb, 0xfc, 0x67, 0xfd, 0x10, 0x3d}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc3, 0xba}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb2, 0x5d, 0x6b, 0xcc, 0xd1, 0xca, 0xef, 0x9d, 0x6d, 0xe3, 0xf, 0xb6, 0x4d, - 0x9, 0x66, 0x74, 0x0, 0x3f, 0xb8, 0x5d, 0x7d, 0x80, 0x95, 0x25, 0xca, 0xea}; - lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2c, 0xf9, 0x4e, 0x81, 0xc4, 0xd4, 0x2b, 0x66, 0x74, 0x2c, - 0xb4, 0xb, 0xa6, 0x9, 0xa4, 0x6a, 0x7f, 0x17, 0x16, 0x43, - 0xf4, 0x47, 0x49, 0x4f, 0xcb, 0xb0, 0xb4, 0x7c, 0x94}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + lwmqtt_sub_options_t sub_opts[2]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16403, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32402, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25747 [(":\163i\190\141\188d\208\&4\STX\b\EMn\ETB.y\192\230kO\177\204'\156\206",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\184\200\144sIg\248\r\181<\187\NUL\207\160Y\137I\224\151]U'g[\v\ACKr",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SubscribeRequest 15317 [("\211!\219\245}\191K\196\v\188\"\238\237R\242F\240\177\144\229",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\200c\DC2\DC4\SO",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\ni",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("v\212>\RS\195wS\195p",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS0}),("\DLE|\233_$",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS2}),("\249\204\STX\180\161\213{b_\SOHVAT",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\191\217\230\191\SUB\239\135\250\206K\133\131\159)OE\ACK\DC2#\203\133=~",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\136\159\161\ETB\151\211$\128E",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("v\ay\rA\210\DC2\243",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("e\174q\139U\145\139 -// \140\238i\152?\244\239\ACKBN\248\218\188\238\DELu\EOT\ENQ/",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),(",\196\144\&6$\US\DC3\212\195n\RS\149\140\204}\235\149\DC2\234\254\f",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("[\241\133m#\240#\175",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x97, 0x1, 0x64, 0x93, 0x0, 0x19, 0x3a, 0xa3, 0x69, 0xbe, 0x8d, 0xbc, 0x64, 0xd0, 0x34, - 0x2, 0x8, 0x19, 0x6e, 0x17, 0x2e, 0x79, 0xc0, 0xe6, 0x6b, 0x4f, 0xb1, 0xcc, 0x27, 0x9c, 0xce, - 0x1, 0x0, 0x1b, 0xb8, 0xc8, 0x90, 0x73, 0x49, 0x67, 0xf8, 0xd, 0xb5, 0x3c, 0xbb, 0x0, 0xcf, - 0xa0, 0x59, 0x89, 0x49, 0xe0, 0x97, 0x5d, 0x55, 0x27, 0x67, 0x5b, 0xb, 0x6, 0x72, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x9, 0x88, 0x9f, 0xa1, 0x17, 0x97, 0xd3, 0x24, 0x80, 0x45, 0x0, 0x0, 0x8, - 0x76, 0x7, 0x79, 0xd, 0x41, 0xd2, 0x12, 0xf3, 0x1, 0x0, 0x1b, 0x65, 0xae, 0x71, 0x8b, 0x55, - 0x91, 0x8b, 0x20, 0x8c, 0xee, 0x69, 0x98, 0x3f, 0xf4, 0xef, 0x6, 0x42, 0x4e, 0xf8, 0xda, 0xbc, - 0xee, 0x7f, 0x75, 0x4, 0x5, 0x2f, 0x0, 0x0, 0x15, 0x2c, 0xc4, 0x90, 0x36, 0x24, 0x1f, 0x13, - 0xd4, 0xc3, 0x6e, 0x1e, 0x95, 0x8c, 0xcc, 0x7d, 0xeb, 0x95, 0x12, 0xea, 0xfe, 0xc, 0x0, 0x0, - 0x8, 0x5b, 0xf1, 0x85, 0x6d, 0x23, 0xf0, 0x23, 0xaf, 0x2}; +// QoS2}),("B\a\136\184\225Dtd\170\&1\162\128O\189e\160\233\186\135B\248",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropUserProperty "\183\208\ETXh" +// "\218\144)@\207\212",PropAuthenticationMethod "\239r6\SYN0\247\147\148\239\246\140S",PropTopicAliasMaximum +// 24388,PropResponseTopic "\190CB\238O\209U\252\241",PropWildcardSubscriptionAvailable 22,PropMessageExpiryInterval +// 1942,PropSubscriptionIdentifier 10,PropRequestProblemInformation 248,PropWillDelayInterval +// 10721,PropWillDelayInterval 18164,PropWildcardSubscriptionAvailable 164,PropReasonString "n\199@\RS\137\ACK(`\244"] +TEST(Subscribe5QCTest, Encode1) { + uint8_t pkt[] = { + 0x82, 0xcd, 0x1, 0x3b, 0xd5, 0x50, 0x26, 0x0, 0x4, 0xb7, 0xd0, 0x3, 0x68, 0x0, 0x6, 0xda, 0x90, 0x29, 0x40, + 0xcf, 0xd4, 0x15, 0x0, 0xc, 0xef, 0x72, 0x36, 0x16, 0x30, 0xf7, 0x93, 0x94, 0xef, 0xf6, 0x8c, 0x53, 0x22, 0x5f, + 0x44, 0x8, 0x0, 0x9, 0xbe, 0x43, 0x42, 0xee, 0x4f, 0xd1, 0x55, 0xfc, 0xf1, 0x28, 0x16, 0x2, 0x0, 0x0, 0x7, + 0x96, 0xb, 0xa, 0x17, 0xf8, 0x18, 0x0, 0x0, 0x29, 0xe1, 0x18, 0x0, 0x0, 0x46, 0xf4, 0x28, 0xa4, 0x1f, 0x0, + 0x9, 0x6e, 0xc7, 0x40, 0x1e, 0x89, 0x6, 0x28, 0x60, 0xf4, 0x0, 0x14, 0xd3, 0x21, 0xdb, 0xf5, 0x7d, 0xbf, 0x4b, + 0xc4, 0xb, 0xbc, 0x22, 0xee, 0xed, 0x52, 0xf2, 0x46, 0xf0, 0xb1, 0x90, 0xe5, 0x1, 0x0, 0x5, 0xc8, 0x63, 0x12, + 0x14, 0xe, 0x29, 0x0, 0x2, 0xa, 0x69, 0x4, 0x0, 0x9, 0x76, 0xd4, 0x3e, 0x1e, 0xc3, 0x77, 0x53, 0xc3, 0x70, + 0x10, 0x0, 0x5, 0x10, 0x7c, 0xe9, 0x5f, 0x24, 0x16, 0x0, 0xd, 0xf9, 0xcc, 0x2, 0xb4, 0xa1, 0xd5, 0x7b, 0x62, + 0x5f, 0x1, 0x56, 0x41, 0x54, 0x21, 0x0, 0x17, 0xbf, 0xd9, 0xe6, 0xbf, 0x1a, 0xef, 0x87, 0xfa, 0xce, 0x4b, 0x85, + 0x83, 0x9f, 0x29, 0x4f, 0x45, 0x6, 0x12, 0x23, 0xcb, 0x85, 0x3d, 0x7e, 0x2, 0x0, 0x15, 0x42, 0x7, 0x88, 0xb8, + 0xe1, 0x44, 0x74, 0x64, 0xaa, 0x31, 0xa2, 0x80, 0x4f, 0xbd, 0x65, 0xa0, 0xe9, 0xba, 0x87, 0x42, 0xf8, 0x19}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x3a, 0xa3, 0x69, 0xbe, 0x8d, 0xbc, 0x64, 0xd0, 0x34, 0x2, 0x8, 0x19, 0x6e, - 0x17, 0x2e, 0x79, 0xc0, 0xe6, 0x6b, 0x4f, 0xb1, 0xcc, 0x27, 0x9c, 0xce}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xd3, 0x21, 0xdb, 0xf5, 0x7d, 0xbf, 0x4b, 0xc4, 0xb, 0xbc, + 0x22, 0xee, 0xed, 0x52, 0xf2, 0x46, 0xf0, 0xb1, 0x90, 0xe5}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb8, 0xc8, 0x90, 0x73, 0x49, 0x67, 0xf8, 0xd, 0xb5, 0x3c, 0xbb, 0x0, 0xcf, 0xa0, - 0x59, 0x89, 0x49, 0xe0, 0x97, 0x5d, 0x55, 0x27, 0x67, 0x5b, 0xb, 0x6, 0x72}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc8, 0x63, 0x12, 0x14, 0xe}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa, 0x69}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x88, 0x9f, 0xa1, 0x17, 0x97, 0xd3, 0x24, 0x80, 0x45}; + uint8_t topic_filter_s3_bytes[] = {0x76, 0xd4, 0x3e, 0x1e, 0xc3, 0x77, 0x53, 0xc3, 0x70}; lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x76, 0x7, 0x79, 0xd, 0x41, 0xd2, 0x12, 0xf3}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x10, 0x7c, 0xe9, 0x5f, 0x24}; + lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x65, 0xae, 0x71, 0x8b, 0x55, 0x91, 0x8b, 0x20, 0x8c, 0xee, 0x69, 0x98, 0x3f, 0xf4, - 0xef, 0x6, 0x42, 0x4e, 0xf8, 0xda, 0xbc, 0xee, 0x7f, 0x75, 0x4, 0x5, 0x2f}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf9, 0xcc, 0x2, 0xb4, 0xa1, 0xd5, 0x7b, 0x62, 0x5f, 0x1, 0x56, 0x41, 0x54}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x2c, 0xc4, 0x90, 0x36, 0x24, 0x1f, 0x13, 0xd4, 0xc3, 0x6e, 0x1e, - 0x95, 0x8c, 0xcc, 0x7d, 0xeb, 0x95, 0x12, 0xea, 0xfe, 0xc}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xbf, 0xd9, 0xe6, 0xbf, 0x1a, 0xef, 0x87, 0xfa, 0xce, 0x4b, 0x85, 0x83, + 0x9f, 0x29, 0x4f, 0x45, 0x6, 0x12, 0x23, 0xcb, 0x85, 0x3d, 0x7e}; + lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x5b, 0xf1, 0x85, 0x6d, 0x23, 0xf0, 0x23, 0xaf}; - lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x42, 0x7, 0x88, 0xb8, 0xe1, 0x44, 0x74, 0x64, 0xaa, 0x31, 0xa2, + 0x80, 0x4f, 0xbd, 0x65, 0xa0, 0xe9, 0xba, 0x87, 0x42, 0xf8}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; lwmqtt_sub_options_t sub_opts[8]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; + sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; sub_opts[7].no_local = false; + uint8_t bytesprops1[] = {0xda, 0x90, 0x29, 0x40, 0xcf, 0xd4}; + uint8_t bytesprops0[] = {0xb7, 0xd0, 0x3, 0x68}; + uint8_t bytesprops2[] = {0xef, 0x72, 0x36, 0x16, 0x30, 0xf7, 0x93, 0x94, 0xef, 0xf6, 0x8c, 0x53}; + uint8_t bytesprops3[] = {0xbe, 0x43, 0x42, 0xee, 0x4f, 0xd1, 0x55, 0xfc, 0xf1}; + uint8_t bytesprops4[] = {0x6e, 0xc7, 0x40, 0x1e, 0x89, 0x6, 0x28, 0x60, 0xf4}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops0}, .v = {6, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24388}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1942}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10721}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18164}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops4}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25747, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15317, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 18112 [("\217\163\ETBT\231\217",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished -// = True, _noLocal = False, _subQoS = QoS0}),("\199}\169\229\237\168.,U\215W4W\211\197\172\&1&\235\203\213",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\225\200[H\253e\NUL\230l[hR\220\215\242\223\175\133\169\231}",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("X",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("D\ACK\181\185\&4\239\235M\227\131\252\255M\176\r\219\180\ETB\217\167\232\190\223\236",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("B)`\234\&1'\221\218\171\ETBd\196\&4\229\170Y\SYN\164y\164b\174E\240",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\165\213\SYN\240\249\ETX\f\225\171\188j\164(\170\190\189\248\223\202",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\182\208\135BB\223",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("7",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0})] [PropResponseTopic "\185\135'\a\a7w\240)%\STX\159&m\206\&0\166\244\143l\211\NAK.&H",PropContentType -// "%J\151\213\176\av\128\232\176\217\185\193\172\144\128\243\SI\241(FXa\187\232\155{",PropAuthenticationData -// "o\RS\157\ENQ7\219M>\246W\239\223&\183|yIe\202\130",PropAuthenticationMethod "\RS0[",PropMessageExpiryInterval -// 28857,PropMaximumQoS 254,PropWildcardSubscriptionAvailable 30,PropRetainAvailable 142,PropResponseInformation -// "`\229\&7\140\135\136\158\155\167",PropTopicAliasMaximum 26525,PropWildcardSubscriptionAvailable -// 230,PropRetainAvailable 219,PropResponseInformation "\162\SOH\231\175#k\213x\144\r",PropTopicAlias -// 21056,PropWillDelayInterval 27038,PropSessionExpiryInterval 11270,PropSharedSubscriptionAvailable -// 235,PropMessageExpiryInterval 22008,PropResponseInformation "3\193\168\DLE\137\220\135",PropRequestProblemInformation -// 36,PropResponseTopic "\158$\182g5\191\210\129^u\139\168\240KN\194n\NUL?]_\SUBQE\189p\240%\218",PropMaximumQoS -// 194,PropMaximumPacketSize 20583,PropSessionExpiryInterval 24442,PropWillDelayInterval -// 23910,PropWildcardSubscriptionAvailable 159,PropServerReference -// "\211\189#27\227\ETB4-,0\153$\190\200\216\ETX\173q\ETB\203v=",PropSharedSubscriptionAvailable -// 104,PropMaximumPacketSize 10426,PropReasonString -// "=\172N\203;\246v\211\130Y\182\162d\228\254\&5\b\216\133\179\153\223"] -TEST(Subscribe5QCTest, Encode1) { +// SubscribeRequest 2981 [("p\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("^w\186",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS2}),("Q\CANiG\n\136\149\SOH\aL\225\243%\139\253W\156FD)\188r5\236s\179^\166",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\144\145\182\194\&1'\245",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS2})] [PropRequestProblemInformation 162,PropAuthenticationData +// "\141L<\210>",PropUserProperty "\217\204b\CAN\139 \167\225\179\&7\128" +// "/I\219\193\\2\237~\ESC\243\247,\238es\225`",PropUserProperty "\220C\150(Y\241\CAN" +// "\232\199\224@\ESC$\193\140\190&\173?r",PropPayloadFormatIndicator 83,PropTopicAlias 1481,PropAuthenticationMethod +// "D-b\187\&5\206",PropServerReference "\199\253\232",PropSubscriptionIdentifierAvailable 142,PropRetainAvailable +// 222,PropReceiveMaximum 20709,PropAssignedClientIdentifier +// "\EOT\202\&0\227TN\202\178E<\139\ESC\249$I\246n\EOTs\216*\210\ESC\155",PropSharedSubscriptionAvailable +// 49,PropSubscriptionIdentifier 6,PropSubscriptionIdentifierAvailable 103] +TEST(Subscribe5QCTest, Encode2) { uint8_t pkt[] = { - 0x82, 0xac, 0x3, 0x46, 0xc0, 0x8f, 0x2, 0x8, 0x0, 0x19, 0xb9, 0x87, 0x27, 0x7, 0x7, 0x37, 0x77, 0xf0, 0x29, - 0x25, 0x2, 0x9f, 0x26, 0x6d, 0xce, 0x30, 0xa6, 0xf4, 0x8f, 0x6c, 0xd3, 0x15, 0x2e, 0x26, 0x48, 0x3, 0x0, 0x1b, - 0x25, 0x4a, 0x97, 0xd5, 0xb0, 0x7, 0x76, 0x80, 0xe8, 0xb0, 0xd9, 0xb9, 0xc1, 0xac, 0x90, 0x80, 0xf3, 0xf, 0xf1, - 0x28, 0x46, 0x58, 0x61, 0xbb, 0xe8, 0x9b, 0x7b, 0x16, 0x0, 0x14, 0x6f, 0x1e, 0x9d, 0x5, 0x37, 0xdb, 0x4d, 0x3e, - 0xf6, 0x57, 0xef, 0xdf, 0x26, 0xb7, 0x7c, 0x79, 0x49, 0x65, 0xca, 0x82, 0x15, 0x0, 0x3, 0x1e, 0x30, 0x5b, 0x2, - 0x0, 0x0, 0x70, 0xb9, 0x24, 0xfe, 0x28, 0x1e, 0x25, 0x8e, 0x1a, 0x0, 0x9, 0x60, 0xe5, 0x37, 0x8c, 0x87, 0x88, - 0x9e, 0x9b, 0xa7, 0x22, 0x67, 0x9d, 0x28, 0xe6, 0x25, 0xdb, 0x1a, 0x0, 0xa, 0xa2, 0x1, 0xe7, 0xaf, 0x23, 0x6b, - 0xd5, 0x78, 0x90, 0xd, 0x23, 0x52, 0x40, 0x18, 0x0, 0x0, 0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2d, 0x62, 0xbb, 0x35, 0xce, 0x1c, 0x0, 0x3, 0xc7, 0xfd, 0xe8, + 0x29, 0x8e, 0x25, 0xde, 0x21, 0x50, 0xe5, 0x12, 0x0, 0x18, 0x4, 0xca, 0x30, 0xe3, 0x54, 0x4e, 0xca, 0xb2, 0x45, + 0x3c, 0x8b, 0x1b, 0xf9, 0x24, 0x49, 0xf6, 0x6e, 0x4, 0x73, 0xd8, 0x2a, 0xd2, 0x1b, 0x9b, 0x2a, 0x31, 0xb, 0x6, + 0x29, 0x67, 0x0, 0x2, 0x70, 0xc5, 0x1, 0x0, 0x3, 0x5e, 0x77, 0xba, 0x26, 0x0, 0x1c, 0x51, 0x18, 0x69, 0x47, + 0xa, 0x88, 0x95, 0x1, 0x7, 0x4c, 0xe1, 0xf3, 0x25, 0x8b, 0xfd, 0x57, 0x9c, 0x46, 0x44, 0x29, 0xbc, 0x72, 0x35, + 0xec, 0x73, 0xb3, 0x5e, 0xa6, 0x9, 0x0, 0x7, 0x90, 0x91, 0xb6, 0xc2, 0x31, 0x27, 0xf5, 0x26}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd9, 0xa3, 0x17, 0x54, 0xe7, 0xd9}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x70, 0xc5}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc7, 0x7d, 0xa9, 0xe5, 0xed, 0xa8, 0x2e, 0x2c, 0x55, 0xd7, 0x57, - 0x34, 0x57, 0xd3, 0xc5, 0xac, 0x31, 0x26, 0xeb, 0xcb, 0xd5}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5e, 0x77, 0xba}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe1, 0xc8, 0x5b, 0x48, 0xfd, 0x65, 0x0, 0xe6, 0x6c, 0x5b, 0x68, - 0x52, 0xdc, 0xd7, 0xf2, 0xdf, 0xaf, 0x85, 0xa9, 0xe7, 0x7d}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x51, 0x18, 0x69, 0x47, 0xa, 0x88, 0x95, 0x1, 0x7, 0x4c, + 0xe1, 0xf3, 0x25, 0x8b, 0xfd, 0x57, 0x9c, 0x46, 0x44, 0x29, + 0xbc, 0x72, 0x35, 0xec, 0x73, 0xb3, 0x5e, 0xa6}; + lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x58}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x90, 0x91, 0xb6, 0xc2, 0x31, 0x27, 0xf5}; + lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x44, 0x6, 0xb5, 0xb9, 0x34, 0xef, 0xeb, 0x4d, 0xe3, 0x83, 0xfc, 0xff, - 0x4d, 0xb0, 0xd, 0xdb, 0xb4, 0x17, 0xd9, 0xa7, 0xe8, 0xbe, 0xdf, 0xec}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x42, 0x29, 0x60, 0xea, 0x31, 0x27, 0xdd, 0xda, 0xab, 0x17, 0x64, 0xc4, - 0x34, 0xe5, 0xaa, 0x59, 0x16, 0xa4, 0x79, 0xa4, 0x62, 0xae, 0x45, 0xf0}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa5, 0xd5, 0x16, 0xf0, 0xf9, 0x3, 0xc, 0xe1, 0xab, 0xbc, - 0x6a, 0xa4, 0x28, 0xaa, 0xbe, 0xbd, 0xf8, 0xdf, 0xca}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xb6, 0xd0, 0x87, 0x42, 0x42, 0xdf}; - lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x37}; - lwmqtt_string_t topic_filter_s9 = {1, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = true; - uint8_t bytesprops0[] = {0xb9, 0x87, 0x27, 0x7, 0x7, 0x37, 0x77, 0xf0, 0x29, 0x25, 0x2, 0x9f, 0x26, - 0x6d, 0xce, 0x30, 0xa6, 0xf4, 0x8f, 0x6c, 0xd3, 0x15, 0x2e, 0x26, 0x48}; - uint8_t bytesprops1[] = {0x25, 0x4a, 0x97, 0xd5, 0xb0, 0x7, 0x76, 0x80, 0xe8, 0xb0, 0xd9, 0xb9, 0xc1, 0xac, - 0x90, 0x80, 0xf3, 0xf, 0xf1, 0x28, 0x46, 0x58, 0x61, 0xbb, 0xe8, 0x9b, 0x7b}; - uint8_t bytesprops2[] = {0x6f, 0x1e, 0x9d, 0x5, 0x37, 0xdb, 0x4d, 0x3e, 0xf6, 0x57, - 0xef, 0xdf, 0x26, 0xb7, 0x7c, 0x79, 0x49, 0x65, 0xca, 0x82}; - uint8_t bytesprops3[] = {0x1e, 0x30, 0x5b}; - uint8_t bytesprops4[] = {0x60, 0xe5, 0x37, 0x8c, 0x87, 0x88, 0x9e, 0x9b, 0xa7}; - uint8_t bytesprops5[] = {0xa2, 0x1, 0xe7, 0xaf, 0x23, 0x6b, 0xd5, 0x78, 0x90, 0xd}; - uint8_t bytesprops6[] = {0x33, 0xc1, 0xa8, 0x10, 0x89, 0xdc, 0x87}; - uint8_t bytesprops7[] = {0x9e, 0x24, 0xb6, 0x67, 0x35, 0xbf, 0xd2, 0x81, 0x5e, 0x75, 0x8b, 0xa8, 0xf0, 0x4b, 0x4e, - 0xc2, 0x6e, 0x0, 0x3f, 0x5d, 0x5f, 0x1a, 0x51, 0x45, 0xbd, 0x70, 0xf0, 0x25, 0xda}; - uint8_t bytesprops8[] = {0xd3, 0xbd, 0x23, 0x32, 0x37, 0xe3, 0x17, 0x34, 0x2d, 0x2c, 0x30, 0x99, - 0x24, 0xbe, 0xc8, 0xd8, 0x3, 0xad, 0x71, 0x17, 0xcb, 0x76, 0x3d}; - uint8_t bytesprops9[] = {0x3d, 0xac, 0x4e, 0xcb, 0x3b, 0xf6, 0x76, 0xd3, 0x82, 0x59, 0xb6, - 0xa2, 0x64, 0xe4, 0xfe, 0x35, 0x8, 0xd8, 0x85, 0xb3, 0x99, 0xdf}; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + uint8_t bytesprops0[] = {0x8d, 0x4c, 0x3c, 0xd2, 0x3e}; + uint8_t bytesprops2[] = {0x2f, 0x49, 0xdb, 0xc1, 0x5c, 0x32, 0xed, 0x7e, 0x1b, + 0xf3, 0xf7, 0x2c, 0xee, 0x65, 0x73, 0xe1, 0x60}; + uint8_t bytesprops1[] = {0xd9, 0xcc, 0x62, 0x18, 0x8b, 0x20, 0xa7, 0xe1, 0xb3, 0x37, 0x80}; + uint8_t bytesprops4[] = {0xe8, 0xc7, 0xe0, 0x40, 0x1b, 0x24, 0xc1, 0x8c, 0xbe, 0x26, 0xad, 0x3f, 0x72}; + uint8_t bytesprops3[] = {0xdc, 0x43, 0x96, 0x28, 0x59, 0xf1, 0x18}; + uint8_t bytesprops5[] = {0x44, 0x2d, 0x62, 0xbb, 0x35, 0xce}; + uint8_t bytesprops6[] = {0xc7, 0xfd, 0xe8}; + uint8_t bytesprops7[] = {0x4, 0xca, 0x30, 0xe3, 0x54, 0x4e, 0xca, 0xb2, 0x45, 0x3c, 0x8b, 0x1b, + 0xf9, 0x24, 0x49, 0xf6, 0x6e, 0x4, 0x73, 0xd8, 0x2a, 0xd2, 0x1b, 0x9b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28857}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26525}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21056}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27038}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11270}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22008}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20583}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24442}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23910}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10426}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {17, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {13, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1481}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20709}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 103}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18112, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2981, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8048 [("=\136\230h\216\226(\250c\195\226\174/9",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\216k\253Z\203\ETX\218\SYN&\169m",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] -// [PropSharedSubscriptionAvailable 45,PropMaximumPacketSize 3495,PropRetainAvailable 129,PropTopicAliasMaximum -// 16323,PropSubscriptionIdentifierAvailable 118,PropContentType "\EMr\219\211\237\200A\140oe",PropTopicAlias 12732] -TEST(Subscribe5QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0x40, 0x1f, 0x70, 0x1e, 0x2a, 0x2d, 0x27, 0x0, 0x0, 0xd, 0xa7, 0x25, 0x81, 0x22, 0x3f, 0xc3, - 0x29, 0x76, 0x3, 0x0, 0xa, 0x19, 0x72, 0xdb, 0xd3, 0xed, 0xc8, 0x41, 0x8c, 0x6f, 0x65, 0x23, 0x31, - 0xbc, 0x0, 0xe, 0x3d, 0x88, 0xe6, 0x68, 0xd8, 0xe2, 0x28, 0xfa, 0x63, 0xc3, 0xe2, 0xae, 0x2f, 0x39, - 0x22, 0x0, 0xb, 0xd8, 0x6b, 0xfd, 0x5a, 0xcb, 0x3, 0xda, 0x16, 0x26, 0xa9, 0x6d, 0x2e}; +// SubscribeRequest 15094 [("\210\248\243\&0\128\183m\131\255\nK\158\GS\237\168\184^\196\151 +// \163i\204\242\EM/\208",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\195=\233\&0\253\&5Li\207\224\152Y@mA[\139<\135y;\188",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropMaximumQoS +// 158,PropCorrelationData "\236\181\195\200s\249>",PropMessageExpiryInterval 1325,PropServerReference +// "",PropRetainAvailable 7,PropWildcardSubscriptionAvailable 73,PropMessageExpiryInterval 11841,PropRetainAvailable +// 253,PropWillDelayInterval 9896,PropPayloadFormatIndicator 235,PropResponseInformation "\157",PropTopicAlias +// 7986,PropRequestResponseInformation 160,PropServerReference "\182\NUL#\212\223\230a\214\249 +// \199\174\240\177\198J",PropReceiveMaximum 12853,PropResponseTopic +// "A}7X\179\CAN\154\f\184\147o\b\199\217\149\192\SYN\202\161",PropSessionExpiryInterval 25693,PropTopicAlias +// 28576,PropResponseTopic +// "\SO\166\EM\SI\161\183\NUL[\231\&0\STX\168\145\178H\129g\196\FS",PropSubscriptionIdentifierAvailable +// 17,PropTopicAlias 3483,PropMessageExpiryInterval 23576,PropServerReference +// "\251\142",PropWildcardSubscriptionAvailable 154,PropTopicAliasMaximum 8968,PropRequestResponseInformation +// 107,PropReceiveMaximum 23712,PropReceiveMaximum 12987] +TEST(Subscribe5QCTest, Encode3) { + uint8_t pkt[] = {0x82, 0xd0, 0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 0x3d, 0xe9, 0x30, 0xfd, 0x35, 0x4c, 0x69, 0xcf, 0xe0, 0x98, 0x59, 0x40, 0x6d, 0x41, 0x5b, + 0x8b, 0x3c, 0x87, 0x79, 0x3b, 0xbc, 0x5}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x3d, 0x88, 0xe6, 0x68, 0xd8, 0xe2, 0x28, - 0xfa, 0x63, 0xc3, 0xe2, 0xae, 0x2f, 0x39}; - lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xd2, 0xf8, 0xf3, 0x30, 0x80, 0xb7, 0x6d, 0x83, 0xff, 0xa, 0x4b, 0x9e, 0x1d, 0xed, + 0xa8, 0xb8, 0x5e, 0xc4, 0x97, 0x20, 0xa3, 0x69, 0xcc, 0xf2, 0x19, 0x2f, 0xd0}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd8, 0x6b, 0xfd, 0x5a, 0xcb, 0x3, 0xda, 0x16, 0x26, 0xa9, 0x6d}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc3, 0x3d, 0xe9, 0x30, 0xfd, 0x35, 0x4c, 0x69, 0xcf, 0xe0, 0x98, + 0x59, 0x40, 0x6d, 0x41, 0x5b, 0x8b, 0x3c, 0x87, 0x79, 0x3b, 0xbc}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; lwmqtt_sub_options_t sub_opts[2]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - uint8_t bytesprops0[] = {0x19, 0x72, 0xdb, 0xd3, 0xed, 0xc8, 0x41, 0x8c, 0x6f, 0x65}; + uint8_t bytesprops0[] = {0xec, 0xb5, 0xc3, 0xc8, 0x73, 0xf9, 0x3e}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x9d}; + uint8_t bytesprops3[] = {0xb6, 0x0, 0x23, 0xd4, 0xdf, 0xe6, 0x61, 0xd6, + 0xf9, 0x20, 0xc7, 0xae, 0xf0, 0xb1, 0xc6, 0x4a}; + uint8_t bytesprops4[] = {0x41, 0x7d, 0x37, 0x58, 0xb3, 0x18, 0x9a, 0xc, 0xb8, 0x93, + 0x6f, 0x8, 0xc7, 0xd9, 0x95, 0xc0, 0x16, 0xca, 0xa1}; + uint8_t bytesprops5[] = {0xe, 0xa6, 0x19, 0xf, 0xa1, 0xb7, 0x0, 0x5b, 0xe7, 0x30, + 0x2, 0xa8, 0x91, 0xb2, 0x48, 0x81, 0x67, 0xc4, 0x1c}; + uint8_t bytesprops6[] = {0xfb, 0x8e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3495}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16323}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12732}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1325}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11841}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9896}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7986}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12853}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25693}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28576}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3483}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23576}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8968}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23712}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12987}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8048, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15094, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21602 [("\218I\151?\251\157\177r\DC2$\167\179\239",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\DELM\163P3T\138\133=\251\243C\218\218\133`\166",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\SYN\189'\252\223\241\r\ENQ?\146.\216n\235jI",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("K$\SYNda\EOT\253\217\190\241p\RS\f\191\f.\252\152\244\DEL\215\RSn\195\EOTyZ\150",SubOptions {_retainHandling -// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\167",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("c7\142\243",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, -// _subQoS = QoS1}),("\155\184\145gf\215\SYN|%",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe5QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x73, 0x54, 0x62, 0x0, 0x0, 0xd, 0xda, 0x49, 0x97, 0x3f, 0xfb, 0x9d, 0xb1, 0x72, 0x12, 0x24, - 0xa7, 0xb3, 0xef, 0x25, 0x0, 0x11, 0x7f, 0x4d, 0xa3, 0x50, 0x33, 0x54, 0x8a, 0x85, 0x3d, 0xfb, 0xf3, - 0x43, 0xda, 0xda, 0x85, 0x60, 0xa6, 0x22, 0x0, 0x10, 0x16, 0xbd, 0x27, 0xfc, 0xdf, 0xf1, 0xd, 0x5, - 0x3f, 0x92, 0x2e, 0xd8, 0x6e, 0xeb, 0x6a, 0x49, 0x18, 0x0, 0x1c, 0x4b, 0x24, 0x16, 0x64, 0x61, 0x4, - 0xfd, 0xd9, 0xbe, 0xf1, 0x70, 0x1e, 0xc, 0xbf, 0xc, 0x2e, 0xfc, 0x98, 0xf4, 0x7f, 0xd7, 0x1e, 0x6e, - 0xc3, 0x4, 0x79, 0x5a, 0x96, 0x1c, 0x0, 0x1, 0xa7, 0x16, 0x0, 0x0, 0x8, 0x0, 0x4, 0x63, 0x37, - 0x8e, 0xf3, 0xd, 0x0, 0x9, 0x9b, 0xb8, 0x91, 0x67, 0x66, 0xd7, 0x16, 0x7c, 0x25, 0x22}; +// SubscribeRequest 31975 [("v\DC3\131\242\151\153\129\216\200a\205\NAK\v\195!\164#\222\225\ESC<",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("a\238tQ\162\133\229\228\DC3<\233\243=Bx`\165\DLE\146J\255",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("*i\190\134\153\235\221\NUL\181\244\166\143\v\164o2",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("{\242\196\145X\GS +// \170E\155\&3m\235\143B\220h-",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// True, _subQoS = QoS0}),("\240\182WL\223\230\175\ETX\195gN\NAK\STXM\DC4\SYN\240k\a\229\195\151\248\199",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\144\195e\r\DC2\190\186\229\NUL\DEL\167\202\DC4\190\184X\bB\189\217\236\174<\253\&2\144\US\SYNq",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\136\&9\f\v\189\145\182%\141\241\CAN\176>-\209|;",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\191u\SYN\194\143\199\229#\182\174\STX\150\132\152\142\DC3\US{\221}\245\208\241\211B\155\&8",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("63\167",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, +// _subQoS = QoS0})] [PropSharedSubscriptionAvailable 156,PropServerReference +// "\137@\183\246\174\160fX(8\171\202\DLEG\129\224`\135\DEL:\158",PropTopicAliasMaximum +// 19848,PropSubscriptionIdentifierAvailable 207,PropSharedSubscriptionAvailable 239,PropMaximumQoS +// 196,PropMessageExpiryInterval 12949,PropWillDelayInterval 19141,PropSubscriptionIdentifierAvailable 84] +TEST(Subscribe5QCTest, Encode4) { + uint8_t pkt[] = { + 0x82, 0xfd, 0x1, 0x7c, 0xe7, 0x2f, 0x2a, 0x9c, 0x1c, 0x0, 0x15, 0x89, 0x40, 0xb7, 0xf6, 0xae, 0xa0, 0x66, 0x58, + 0x28, 0x38, 0xab, 0xca, 0x10, 0x47, 0x81, 0xe0, 0x60, 0x87, 0x7f, 0x3a, 0x9e, 0x22, 0x4d, 0x88, 0x29, 0xcf, 0x2a, + 0xef, 0x24, 0xc4, 0x2, 0x0, 0x0, 0x32, 0x95, 0x18, 0x0, 0x0, 0x4a, 0xc5, 0x29, 0x54, 0x0, 0x15, 0x76, 0x13, + 0x83, 0xf2, 0x97, 0x99, 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d3, 0x42, + 0x9b, 0x38, 0x29, 0x0, 0x3, 0x36, 0x33, 0xa7, 0x24}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xda, 0x49, 0x97, 0x3f, 0xfb, 0x9d, 0xb1, 0x72, 0x12, 0x24, 0xa7, 0xb3, 0xef}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x76, 0x13, 0x83, 0xf2, 0x97, 0x99, 0x81, 0xd8, 0xc8, 0x61, 0xcd, + 0x15, 0xb, 0xc3, 0x21, 0xa4, 0x23, 0xde, 0xe1, 0x1b, 0x3c}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7f, 0x4d, 0xa3, 0x50, 0x33, 0x54, 0x8a, 0x85, 0x3d, - 0xfb, 0xf3, 0x43, 0xda, 0xda, 0x85, 0x60, 0xa6}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x61, 0xee, 0x74, 0x51, 0xa2, 0x85, 0xe5, 0xe4, 0x13, 0x3c, 0xe9, + 0xf3, 0x3d, 0x42, 0x78, 0x60, 0xa5, 0x10, 0x92, 0x4a, 0xff}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x16, 0xbd, 0x27, 0xfc, 0xdf, 0xf1, 0xd, 0x5, - 0x3f, 0x92, 0x2e, 0xd8, 0x6e, 0xeb, 0x6a, 0x49}; + uint8_t topic_filter_s2_bytes[] = {0x2a, 0x69, 0xbe, 0x86, 0x99, 0xeb, 0xdd, 0x0, + 0xb5, 0xf4, 0xa6, 0x8f, 0xb, 0xa4, 0x6f, 0x32}; lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x4b, 0x24, 0x16, 0x64, 0x61, 0x4, 0xfd, 0xd9, 0xbe, 0xf1, - 0x70, 0x1e, 0xc, 0xbf, 0xc, 0x2e, 0xfc, 0x98, 0xf4, 0x7f, - 0xd7, 0x1e, 0x6e, 0xc3, 0x4, 0x79, 0x5a, 0x96}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x7b, 0xf2, 0xc4, 0x91, 0x58, 0x1d, 0x20, 0xaa, 0x45, + 0x9b, 0x33, 0x6d, 0xeb, 0x8f, 0x42, 0xdc, 0x68, 0x2d}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa7}; - lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xf0, 0xb6, 0x57, 0x4c, 0xdf, 0xe6, 0xaf, 0x3, 0xc3, 0x67, 0x4e, 0x15, + 0x2, 0x4d, 0x14, 0x16, 0xf0, 0x6b, 0x7, 0xe5, 0xc3, 0x97, 0xf8, 0xc7}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x90, 0xc3, 0x65, 0xd, 0x12, 0xbe, 0xba, 0xe5, 0x0, 0x7f, + 0xa7, 0xca, 0x14, 0xbe, 0xb8, 0x58, 0x8, 0x42, 0xbd, 0xd9, + 0xec, 0xae, 0x3c, 0xfd, 0x32, 0x90, 0x1f, 0x16, 0x71}; + lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x63, 0x37, 0x8e, 0xf3}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x88, 0x39, 0xc, 0xb, 0xbd, 0x91, 0xb6, 0x25, 0x8d, + 0xf1, 0x18, 0xb0, 0x3e, 0x2d, 0xd1, 0x7c, 0x3b}; + lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x9b, 0xb8, 0x91, 0x67, 0x66, 0xd7, 0x16, 0x7c, 0x25}; - lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xbf, 0x75, 0x16, 0xc2, 0x8f, 0xc7, 0xe5, 0x23, 0xb6, 0xae, 0x2, 0x96, 0x84, 0x98, + 0x8e, 0x13, 0x1f, 0x7b, 0xdd, 0x7d, 0xf5, 0xd0, 0xf1, 0xd3, 0x42, 0x9b, 0x38}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; + uint8_t topic_filter_s8_bytes[] = {0x36, 0x33, 0xa7}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; + sub_opts[5].no_local = true; sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[6].retain_as_published = true; sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; + sub_opts[7].retain_as_published = true; sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; + uint8_t bytesprops0[] = {0x89, 0x40, 0xb7, 0xf6, 0xae, 0xa0, 0x66, 0x58, 0x28, 0x38, 0xab, + 0xca, 0x10, 0x47, 0x81, 0xe0, 0x60, 0x87, 0x7f, 0x3a, 0x9e}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19848}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12949}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19141}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21602, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31975, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20894 [("\237B-\128DW\251-\ENQ\236~\v\231",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\235\144\244p\b",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\162\EM\147\205\188{m\242\133S\193\173\220\173H\227m\DC3\251\217\SUB\DC4\184\DC4~\255\a",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\237M\170\&2IG\163",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = -// True, _subQoS = QoS2}),("N\168\164\212\213\140\SO|b\223\242P\195\226\192\139\128\NUL\SYN8 C",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\ETB\a\246\155\191\141\202\183\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// True, _noLocal = False, _subQoS = QoS2})] [PropSubscriptionIdentifier 6,PropResponseInformation -// "\178\168^^\182\241\241\131\ENQ_a\201\211\216\rN\173",PropReasonString -// "\STX\169\229\229\133\129\243\183\235\131\229\t\149anD\136\&3\DC4.N\DC4\130\237N\222l",PropServerReference -// "\EM\140b\EOTZzsq",PropContentType "",PropResponseInformation -// ";\246\&2\EM`B\215\214\185\DEL`\NUL\171\138\226\145\221\148\234\134\199]S{,\200",PropMaximumPacketSize -// 3807,PropMaximumQoS 104,PropMaximumPacketSize 17251,PropTopicAliasMaximum 6956,PropWildcardSubscriptionAvailable -// 2,PropMessageExpiryInterval 16191,PropAuthenticationMethod "",PropReceiveMaximum 21313,PropMessageExpiryInterval -// 30861,PropMessageExpiryInterval 17656,PropServerReference "",PropContentType -// "oi6\DC3\186\190\147\231\221u",PropMaximumPacketSize 25970,PropReceiveMaximum 27606,PropMaximumQoS -// 107,PropAssignedClientIdentifier -// "\134\201i/*\DLEBEC\162Y{\144\&5Vz\224\170\255\186=\195\208h",PropSubscriptionIdentifierAvailable -// 104,PropAuthenticationMethod "\148\FS",PropRetainAvailable 189,PropSharedSubscriptionAvailable 253] -TEST(Subscribe5QCTest, Encode4) { - uint8_t pkt[] = { - 0x82, 0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d, - 0xc3, 0xd0, 0x68, 0x29, 0x68, 0x15, 0x0, 0x2, 0x94, 0x1c, 0x25, 0xbd, 0x2a, 0xfd, 0x0, 0xd, 0xed, 0x42, 0x2d, - 0x80, 0x44, 0x57, 0xfb, 0x2d, 0x5, 0xec, 0x7e, 0xb, 0xe7, 0x0, 0x0, 0x5, 0xeb, 0x90, 0xf4, 0x70, 0x8, 0x9, - 0x0, 0x1b, 0xa2, 0x19, 0x93, 0xcd, 0xbc, 0x7b, 0x6d, 0xf2, 0x85, 0x53, 0xc1, 0xad, 0xdc, 0xad, 0x48, 0xe3, 0x6d, - 0x13, 0xfb, 0xd9, 0x1a, 0x14, 0xb8, 0x14, 0x7e, 0xff, 0x7, 0x29, 0x0, 0x0, 0x12, 0x0, 0x7, 0xed, 0x4d, 0xaa, - 0x32, 0x49, 0x47, 0xa3, 0xe, 0x0, 0x16, 0x4e, 0xa8, 0xa4, 0xd4, 0xd5, 0x8c, 0xe, 0x7c, 0x62, 0xdf, 0xf2, 0x50, - 0xc3, 0xe2, 0xc0, 0x8b, 0x80, 0x0, 0x16, 0x38, 0x20, 0x43, 0x5, 0x0, 0x9, 0x17, 0x7, 0xf6, 0x9b, 0xbf, 0x8d, - 0xca, 0xb7, 0x98, 0xa}; +// SubscribeRequest 25478 [("\219SY?\CAN\SOHQE\164",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\183\ENQ\209\132\194\DELz\220\v\150\RSf\145?a\170\217x\159\172",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("v\193\162\ETX\200\RSE\250\235",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// True, _noLocal = True, _subQoS = QoS0})] [PropRequestResponseInformation 169,PropReceiveMaximum +// 141,PropReceiveMaximum 29474,PropMessageExpiryInterval 31401,PropMessageExpiryInterval 5256,PropContentType +// "",PropReasonString "\DC1\STX\191\DC2\170\249@\195\226\146\253\f\219\205\135",PropAuthenticationData +// "\133\234\222\210NY\137\155\DC1\148\208;\216\138\254\166",PropMessageExpiryInterval 7843,PropAuthenticationData +// "\134\150\EMu\202\134\SUB\DC1\DC4N\189\239w\170pWY\212\175i\193\r\216\SYN",PropMaximumPacketSize +// 12152,PropContentType "\215\234\214%\FS\160\195[\"\248",PropSubscriptionIdentifierAvailable 224] +TEST(Subscribe5QCTest, Encode5) { + uint8_t pkt[] = {0x82, 0xa0, 0x1, 0x63, 0x86, 0x6e, 0x19, 0xa9, 0x21, 0x0, 0x8d, 0x21, 0x73, 0x22, 0x2, 0x0, 0x0, + 0x7a, 0xa9, 0x2, 0x0, 0x0, 0x14, 0x88, 0x3, 0x0, 0x0, 0x1f, 0x0, 0xf, 0x11, 0x2, 0xbf, 0x12, + 0xaa, 0xf9, 0x40, 0xc3, 0xe2, 0x92, 0xfd, 0xc, 0xdb, 0xcd, 0x87, 0x16, 0x0, 0x10, 0x85, 0xea, 0xde, + 0xd2, 0x4e, 0x59, 0x89, 0x9b, 0x11, 0x94, 0xd0, 0x3b, 0xd8, 0x8a, 0xfe, 0xa6, 0x2, 0x0, 0x0, 0x1e, + 0xa3, 0x16, 0x0, 0x18, 0x86, 0x96, 0x19, 0x75, 0xca, 0x86, 0x1a, 0x11, 0x14, 0x4e, 0xbd, 0xef, 0x77, + 0xaa, 0x70, 0x57, 0x59, 0xd4, 0xaf, 0x69, 0xc1, 0xd, 0xd8, 0x16, 0x27, 0x0, 0x0, 0x2f, 0x78, 0x3, + 0x0, 0xa, 0xd7, 0xea, 0xd6, 0x25, 0x1c, 0xa0, 0xc3, 0x5b, 0x22, 0xf8, 0x29, 0xe0, 0x0, 0x9, 0xdb, + 0x53, 0x59, 0x3f, 0x18, 0x1, 0x51, 0x45, 0xa4, 0x2c, 0x0, 0x14, 0xb7, 0x5, 0xd1, 0x84, 0xc2, 0x7f, + 0x7a, 0xdc, 0xb, 0x96, 0x1e, 0x66, 0x91, 0x3f, 0x61, 0xaa, 0xd9, 0x78, 0x9f, 0xac, 0x16, 0x0, 0x9, + 0x76, 0xc1, 0xa2, 0x3, 0xc8, 0x1e, 0x45, 0xfa, 0xeb, 0x2c}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x42, 0x2d, 0x80, 0x44, 0x57, 0xfb, 0x2d, 0x5, 0xec, 0x7e, 0xb, 0xe7}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xdb, 0x53, 0x59, 0x3f, 0x18, 0x1, 0x51, 0x45, 0xa4}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xeb, 0x90, 0xf4, 0x70, 0x8}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb7, 0x5, 0xd1, 0x84, 0xc2, 0x7f, 0x7a, 0xdc, 0xb, 0x96, + 0x1e, 0x66, 0x91, 0x3f, 0x61, 0xaa, 0xd9, 0x78, 0x9f, 0xac}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa2, 0x19, 0x93, 0xcd, 0xbc, 0x7b, 0x6d, 0xf2, 0x85, 0x53, 0xc1, 0xad, 0xdc, 0xad, - 0x48, 0xe3, 0x6d, 0x13, 0xfb, 0xd9, 0x1a, 0x14, 0xb8, 0x14, 0x7e, 0xff, 0x7}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x76, 0xc1, 0xa2, 0x3, 0xc8, 0x1e, 0x45, 0xfa, 0xeb}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xed, 0x4d, 0xaa, 0x32, 0x49, 0x47, 0xa3}; - lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4e, 0xa8, 0xa4, 0xd4, 0xd5, 0x8c, 0xe, 0x7c, 0x62, 0xdf, 0xf2, - 0x50, 0xc3, 0xe2, 0xc0, 0x8b, 0x80, 0x0, 0x16, 0x38, 0x20, 0x43}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x17, 0x7, 0xf6, 0x9b, 0xbf, 0x8d, 0xca, 0xb7, 0x98}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; + lwmqtt_sub_options_t sub_opts[3]; sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - uint8_t bytesprops0[] = {0xb2, 0xa8, 0x5e, 0x5e, 0xb6, 0xf1, 0xf1, 0x83, 0x5, - 0x5f, 0x61, 0xc9, 0xd3, 0xd8, 0xd, 0x4e, 0xad}; - uint8_t bytesprops1[] = {0x2, 0xa9, 0xe5, 0xe5, 0x85, 0x81, 0xf3, 0xb7, 0xeb, 0x83, 0xe5, 0x9, 0x95, 0x61, - 0x6e, 0x44, 0x88, 0x33, 0x14, 0x2e, 0x4e, 0x14, 0x82, 0xed, 0x4e, 0xde, 0x6c}; - uint8_t bytesprops2[] = {0x19, 0x8c, 0x62, 0x4, 0x5a, 0x7a, 0x73, 0x71}; - uint8_t bytesprops3[] = {0}; - uint8_t bytesprops4[] = {0x3b, 0xf6, 0x32, 0x19, 0x60, 0x42, 0xd7, 0xd6, 0xb9, 0x7f, 0x60, 0x0, 0xab, - 0x8a, 0xe2, 0x91, 0xdd, 0x94, 0xea, 0x86, 0xc7, 0x5d, 0x53, 0x7b, 0x2c, 0xc8}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0}; - uint8_t bytesprops7[] = {0x6f, 0x69, 0x36, 0x13, 0xba, 0xbe, 0x93, 0xe7, 0xdd, 0x75}; - uint8_t bytesprops8[] = {0x86, 0xc9, 0x69, 0x2f, 0x2a, 0x10, 0x42, 0x45, 0x43, 0xa2, 0x59, 0x7b, - 0x90, 0x35, 0x56, 0x7a, 0xe0, 0xaa, 0xff, 0xba, 0x3d, 0xc3, 0xd0, 0x68}; - uint8_t bytesprops9[] = {0x94, 0x1c}; + sub_opts[2].no_local = true; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x11, 0x2, 0xbf, 0x12, 0xaa, 0xf9, 0x40, 0xc3, 0xe2, 0x92, 0xfd, 0xc, 0xdb, 0xcd, 0x87}; + uint8_t bytesprops2[] = {0x85, 0xea, 0xde, 0xd2, 0x4e, 0x59, 0x89, 0x9b, + 0x11, 0x94, 0xd0, 0x3b, 0xd8, 0x8a, 0xfe, 0xa6}; + uint8_t bytesprops3[] = {0x86, 0x96, 0x19, 0x75, 0xca, 0x86, 0x1a, 0x11, 0x14, 0x4e, 0xbd, 0xef, + 0x77, 0xaa, 0x70, 0x57, 0x59, 0xd4, 0xaf, 0x69, 0xc1, 0xd, 0xd8, 0x16}; + uint8_t bytesprops4[] = {0xd7, 0xea, 0xd6, 0x25, 0x1c, 0xa0, 0xc3, 0x5b, 0x22, 0xf8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3807}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17251}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6956}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16191}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21313}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30861}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17656}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25970}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27606}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 141}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29474}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31401}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5256}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7843}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12152}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 224}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20894, 7, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 15574 -// [("]\129\160\v\144]\DC3^\204\220\DEL\ETX2_\SI\"\197\208\215\196\b\176^\158\233\177\180\164\255",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] -// [PropSharedSubscriptionAvailable 88,PropServerKeepAlive 7219,PropWildcardSubscriptionAvailable -// 143,PropPayloadFormatIndicator 61,PropMaximumPacketSize 20794,PropSubscriptionIdentifier 5,PropMessageExpiryInterval -// 31212,PropResponseInformation -// "\DC22\181\175>\228\190i\148\139{\SI\DC3R\ACK\198\170K\SUB\185\189\164\129\190",PropReasonString -// "\192\145SO\207*\186\227\223",PropSubscriptionIdentifierAvailable 133,PropPayloadFormatIndicator -// 58,PropMessageExpiryInterval 5405,PropServerReference "\150\140\151\180\226Xe\b",PropTopicAliasMaximum -// 27080,PropResponseInformation -// "\184\254\&9Tn#Q\192\SYN\244\193\240/\180\DLE~\206\FS*\207\187\152\"\DC2",PropUserProperty -// "\252\&4=R\NAK\247nHl\242\STX\213&oY",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropReasonString "\223b -// @\167?\143\&7L\163\146\216\197;\DC2\213\228\234\208",PropMessageExpiryInterval 31326,PropTopicAlias -// 16320,PropReceiveMaximum 6351,PropWildcardSubscriptionAvailable 31,PropMessageExpiryInterval -// 8699,PropMaximumPacketSize 25430,PropPayloadFormatIndicator 87,PropReasonString -// "az\138\221\181\197\191\NAK{=\137)\243\181\184\209W4\231\253\229\153\163\170\156",PropSubscriptionIdentifier -// 9,PropMessageExpiryInterval 26330,PropTopicAlias 22270,PropMessageExpiryInterval 27322,PropCorrelationData -// "\131\145H\141\152\159\218H\153*\192\&7\186\154\231",PropMaximumQoS 32,PropMaximumQoS 233,PropWillDelayInterval -// 24371,PropRequestResponseInformation 149,PropSharedSubscriptionAvailable 31,PropSharedSubscriptionAvailable -// 199,PropRetainAvailable 125] -TEST(Subscribe5QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0xd6, 0x1, 0x42, 0xd1, 0x7d, 0x1f, 0x0, 0x13, 0xdf, 0x62, 0x20, 0x40, 0xa7, 0x3f, 0x8f, 0x37, - 0x4c, 0xa3, 0x92, 0xd8, 0xc5, 0x3b, 0x12, 0xd5, 0xe4, 0xea, 0xd0, 0x2, 0x0, 0x0, 0x7a, 0x5e, 0x23, - 0x3f, 0xc0, 0x21, 0x18, 0xcf, 0x28, 0x1f, 0x2, 0x0, 0x0, 0x21, 0xfb, 0x27, 0x0, 0x0, 0x63, 0x56, - 0x1, 0x57, 0x1f, 0x0, 0x19, 0x61, 0x7a, 0x8a, 0xdd, 0xb5, 0xc5, 0xbf, 0x15, 0x7b, 0x3d, 0x89, 0x29, - 0xf3, 0xb5, 0xb8, 0xd1, 0x57, 0x34, 0xe7, 0xfd, 0xe5, 0x99, 0xa3, 0xaa, 0x9c, 0xb, 0x9, 0x2, 0x0, - 0x0, 0x66, 0xda, 0x23, 0x56, 0xfe, 0x2, 0x0, 0x0, 0x6a, 0xba, 0x9, 0x0, 0xf, 0x83, 0x91, 0x48, - 0x8d, 0x98, 0x9f, 0xda, 0x48, 0x99, 0x2a, 0xc0, 0x37, 0xba, 0x9a, 0xe7, 0x24, 0x20, 0x24, 0xe9, 0x18, - 0x0, 0x0, 0x5f, 0x33, 0x19, 0x95, 0x2a, 0x1f, 0x2a, 0xc7, 0x25, 0x7d, 0x0, 0x14, 0xfb, 0x41, 0x4f, - 0xe5, 0xcb, 0xcc, 0x61, 0xf7, 0xcc, 0xbf, 0x14, 0xa2, 0xcc, 0x92, 0x4a, 0x55, 0xa0, 0x1a, 0x9d, 0xc3, - 0x19, 0x0, 0x1e, 0x9b, 0xd8, 0xd, 0x4, 0xa9, 0xe, 0xe0, 0x9b, 0x6e, 0xeb, 0x1c, 0xa, 0x75, 0x9f, - 0x8e, 0x67, 0x3b, 0x95, 0xf6, 0x93, 0x45, 0xb3, 0x5d, 0x62, 0xe7, 0x38, 0x1f, 0x2f, 0x3c, 0x1c, 0x6, - 0x0, 0x1b, 0x7b, 0x2c, 0x9f, 0x9a, 0x6a, 0xb9, 0x6f, 0xa, 0x8f, 0x6d, 0xb2, 0xf2, 0xcf, 0x3e, 0x3d, - 0x52, 0x15, 0xf7, 0x6e, 0x48, 0x6c, 0xf2, 0x2, 0xd5, 0x26, 0x6f, 0x59, 0x26}; +// QoS1}),("\131\SOHT\174\251+&V\131\139\217F\DC1\151\228j\247b\229",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\138\148\167\139=\204k2\161\181/\146\&0\141]\181\151\NUL\r\188\"\v\132\&1",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\202}\DLEqP\f\228\&3\199\161dJk\216\142XIapF0\134_\205\197\141\244\222\135",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\137ya\140\155\\\DEL\204\FS\216\244Xt\190\NULg\242\174\151\160\243",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\"\DC4#\179\&1\GS#B\162\161\244\172c\DC4&\225",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\193^\197\214\CAN\240\155v(\145\239\174\201\134\236\232l\177\163",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropReasonString +// ";\f\183\150=\237\DLE\162\\H)\183\ENQ\157\DC4\186\224\&0"] +TEST(Subscribe5QCTest, Encode7) { + uint8_t pkt[] = { + 0x82, 0x81, 0x2, 0x6d, 0xb2, 0x15, 0x1f, 0x0, 0x12, 0x3b, 0xc, 0xb7, 0x96, 0x3d, 0xed, 0x10, 0xa2, 0x5c, 0x48, + 0x29, 0xb7, 0x5, 0x9d, 0x14, 0xba, 0xe0, 0x30, 0x0, 0x1c, 0x8c, 0x95, 0xf6, 0xc2, 0xa7, 0x2, 0xa1, 0x79, 0xf9, + 0x84, 0x9c, 0x7e, 0x82, 0xfe, 0xc9, 0x1, 0x9, 0x5d, 0x9e, 0x61, 0x25, 0x49, 0x78, 0x28, 0xed, 0x76, 0x9b, 0xef, + 0x9, 0x0, 0x13, 0xef, 0xbf, 0x15, 0x43, 0xef, 0xc, 0x4f, 0x5, 0x89, 0xd4, 0x2a, 0x6a, 0xe4, 0xd1, 0xff, 0xf1, + 0xda, 0xb1, 0x82, 0x29, 0x0, 0x11, 0xf9, 0x5d, 0xe0, 0x1a, 0x77, 0x98, 0x6c, 0xb9, 0x8b, 0x7, 0x59, 0x67, 0x11, + 0x1, 0x53, 0x85, 0xac, 0x4, 0x0, 0xb, 0x39, 0xbf, 0x15, 0x28, 0xe1, 0x6e, 0xc4, 0x17, 0x70, 0xce, 0xaf, 0x19, + 0x0, 0x13, 0x83, 0x1, 0x54, 0xae, 0xfb, 0x2b, 0x26, 0x56, 0x83, 0x8b, 0xd9, 0x46, 0x11, 0x97, 0xe4, 0x6a, 0xf7, + 0x62, 0xe5, 0x4, 0x0, 0x18, 0x8a, 0x94, 0xa7, 0x8b, 0x3d, 0xcc, 0x6b, 0x32, 0xa1, 0xb5, 0x2f, 0x92, 0x30, 0x8d, + 0x5d, 0xb5, 0x97, 0x0, 0xd, 0xbc, 0x22, 0xb, 0x84, 0x31, 0xd, 0x0, 0x1d, 0xca, 0x7d, 0x10, 0x71, 0x50, 0xc, + 0xe4, 0x33, 0xc7, 0xa1, 0x64, 0x4a, 0x6b, 0xd8, 0x8e, 0x58, 0x49, 0x61, 0x70, 0x46, 0x30, 0x86, 0x5f, 0xcd, 0xc5, + 0x8d, 0xf4, 0xde, 0x87, 0x18, 0x0, 0x15, 0x89, 0x79, 0x61, 0x8c, 0x9b, 0x5c, 0x7f, 0xcc, 0x1c, 0xd8, 0xf4, 0x58, + 0x74, 0xbe, 0x0, 0x67, 0xf2, 0xae, 0x97, 0xa0, 0xf3, 0x1e, 0x0, 0x10, 0x22, 0x14, 0x23, 0xb3, 0x31, 0x1d, 0x23, + 0x42, 0xa2, 0xa1, 0xf4, 0xac, 0x63, 0x14, 0x26, 0xe1, 0x2, 0x0, 0x13, 0xc1, 0x5e, 0xc5, 0xd6, 0x18, 0xf0, 0x9b, + 0x76, 0x28, 0x91, 0xef, 0xae, 0xc9, 0x86, 0xec, 0xe8, 0x6c, 0xb1, 0xa3, 0x2e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xfb, 0x41, 0x4f, 0xe5, 0xcb, 0xcc, 0x61, 0xf7, 0xcc, 0xbf, - 0x14, 0xa2, 0xcc, 0x92, 0x4a, 0x55, 0xa0, 0x1a, 0x9d, 0xc3}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x8c, 0x95, 0xf6, 0xc2, 0xa7, 0x2, 0xa1, 0x79, 0xf9, 0x84, + 0x9c, 0x7e, 0x82, 0xfe, 0xc9, 0x1, 0x9, 0x5d, 0x9e, 0x61, + 0x25, 0x49, 0x78, 0x28, 0xed, 0x76, 0x9b, 0xef}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9b, 0xd8, 0xd, 0x4, 0xa9, 0xe, 0xe0, 0x9b, 0x6e, 0xeb, - 0x1c, 0xa, 0x75, 0x9f, 0x8e, 0x67, 0x3b, 0x95, 0xf6, 0x93, - 0x45, 0xb3, 0x5d, 0x62, 0xe7, 0x38, 0x1f, 0x2f, 0x3c, 0x1c}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xef, 0xbf, 0x15, 0x43, 0xef, 0xc, 0x4f, 0x5, 0x89, 0xd4, + 0x2a, 0x6a, 0xe4, 0xd1, 0xff, 0xf1, 0xda, 0xb1, 0x82}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7b, 0x2c, 0x9f, 0x9a, 0x6a, 0xb9, 0x6f, 0xa, 0x8f, 0x6d, 0xb2, 0xf2, 0xcf, 0x3e, - 0x3d, 0x52, 0x15, 0xf7, 0x6e, 0x48, 0x6c, 0xf2, 0x2, 0xd5, 0x26, 0x6f, 0x59}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf9, 0x5d, 0xe0, 0x1a, 0x77, 0x98, 0x6c, 0xb9, 0x8b, + 0x7, 0x59, 0x67, 0x11, 0x1, 0x53, 0x85, 0xac}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; + uint8_t topic_filter_s3_bytes[] = {0x39, 0xbf, 0x15, 0x28, 0xe1, 0x6e, 0xc4, 0x17, 0x70, 0xce, 0xaf}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x83, 0x1, 0x54, 0xae, 0xfb, 0x2b, 0x26, 0x56, 0x83, 0x8b, + 0xd9, 0x46, 0x11, 0x97, 0xe4, 0x6a, 0xf7, 0x62, 0xe5}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x8a, 0x94, 0xa7, 0x8b, 0x3d, 0xcc, 0x6b, 0x32, 0xa1, 0xb5, 0x2f, 0x92, + 0x30, 0x8d, 0x5d, 0xb5, 0x97, 0x0, 0xd, 0xbc, 0x22, 0xb, 0x84, 0x31}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xca, 0x7d, 0x10, 0x71, 0x50, 0xc, 0xe4, 0x33, 0xc7, 0xa1, + 0x64, 0x4a, 0x6b, 0xd8, 0x8e, 0x58, 0x49, 0x61, 0x70, 0x46, + 0x30, 0x86, 0x5f, 0xcd, 0xc5, 0x8d, 0xf4, 0xde, 0x87}; + lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x89, 0x79, 0x61, 0x8c, 0x9b, 0x5c, 0x7f, 0xcc, 0x1c, 0xd8, 0xf4, + 0x58, 0x74, 0xbe, 0x0, 0x67, 0xf2, 0xae, 0x97, 0xa0, 0xf3}; + lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x22, 0x14, 0x23, 0xb3, 0x31, 0x1d, 0x23, 0x42, + 0xa2, 0xa1, 0xf4, 0xac, 0x63, 0x14, 0x26, 0xe1}; + lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xc1, 0x5e, 0xc5, 0xd6, 0x18, 0xf0, 0x9b, 0x76, 0x28, 0x91, + 0xef, 0xae, 0xc9, 0x86, 0xec, 0xe8, 0x6c, 0xb1, 0xa3}; + lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - uint8_t bytesprops0[] = {0xdf, 0x62, 0x20, 0x40, 0xa7, 0x3f, 0x8f, 0x37, 0x4c, 0xa3, - 0x92, 0xd8, 0xc5, 0x3b, 0x12, 0xd5, 0xe4, 0xea, 0xd0}; - uint8_t bytesprops1[] = {0x61, 0x7a, 0x8a, 0xdd, 0xb5, 0xc5, 0xbf, 0x15, 0x7b, 0x3d, 0x89, 0x29, 0xf3, - 0xb5, 0xb8, 0xd1, 0x57, 0x34, 0xe7, 0xfd, 0xe5, 0x99, 0xa3, 0xaa, 0x9c}; - uint8_t bytesprops2[] = {0x83, 0x91, 0x48, 0x8d, 0x98, 0x9f, 0xda, 0x48, 0x99, 0x2a, 0xc0, 0x37, 0xba, 0x9a, 0xe7}; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = true; + uint8_t bytesprops0[] = {0x3b, 0xc, 0xb7, 0x96, 0x3d, 0xed, 0x10, 0xa2, 0x5c, + 0x48, 0x29, 0xb7, 0x5, 0x9d, 0x14, 0xba, 0xe0, 0x30}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31326}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16320}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6351}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8699}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25430}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26330}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22270}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27322}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24371}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17105, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28082, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26860 [("\\\141\254\CAN\217\DC4\240\244\DELx;\238\SO\168\&6A\223v\163\128",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("t\181>5/\245\f\155\161\184\211",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// True, _noLocal = False, _subQoS = QoS0}),("\STX=\b\150d\219\200\177\178\226D\153\252A\229",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\245\138\fl\228\159\224Bny",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS0}),("\194t\244\206\158\155>\128\183y\199\173\195\199~F\150;\142\178d",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] -// [PropRetainAvailable 154,PropSubscriptionIdentifierAvailable 188,PropMaximumPacketSize -// 17727,PropRequestResponseInformation 216,PropResponseTopic "Y\168\178\200/\208",PropReceiveMaximum -// 30281,PropTopicAliasMaximum 7251,PropSessionExpiryInterval 20135,PropSessionExpiryInterval 569,PropTopicAliasMaximum -// 7009,PropTopicAlias 16877,PropCorrelationData "\154\229V\235\EOT\190b\152",PropReceiveMaximum 12069,PropMaximumQoS -// 161,PropMessageExpiryInterval 426,PropSubscriptionIdentifierAvailable 154] -TEST(Subscribe5QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0xa0, 0x1, 0x68, 0xec, 0x41, 0x25, 0x9a, 0x29, 0xbc, 0x27, 0x0, 0x0, 0x45, 0x3f, 0x19, 0xd8, - 0x8, 0x0, 0x6, 0x59, 0xa8, 0xb2, 0xc8, 0x2f, 0xd0, 0x21, 0x76, 0x49, 0x22, 0x1c, 0x53, 0x11, 0x0, - 0x0, 0x4e, 0xa7, 0x11, 0x0, 0x0, 0x2, 0x39, 0x22, 0x1b, 0x61, 0x23, 0x41, 0xed, 0x9, 0x0, 0x8, - 0x9a, 0xe5, 0x56, 0xeb, 0x4, 0xbe, 0x62, 0x98, 0x21, 0x2f, 0x25, 0x24, 0xa1, 0x2, 0x0, 0x0, 0x1, - 0xaa, 0x29, 0x9a, 0x0, 0x14, 0x5c, 0x8d, 0xfe, 0x18, 0xd9, 0x14, 0xf0, 0xf4, 0x7f, 0x78, 0x3b, 0xee, - 0xe, 0xa8, 0x36, 0x41, 0xdf, 0x76, 0xa3, 0x80, 0x1d, 0x0, 0xb, 0x74, 0xb5, 0x3e, 0x35, 0x2f, 0xf5, - 0xc, 0x9b, 0xa1, 0xb8, 0xd3, 0x28, 0x0, 0xf, 0x2, 0x3d, 0x8, 0x96, 0x64, 0xdb, 0xc8, 0xb1, 0xb2, - 0xe2, 0x44, 0x99, 0xfc, 0x41, 0xe5, 0x11, 0x0, 0xa, 0xf5, 0x8a, 0xc, 0x6c, 0xe4, 0x9f, 0xe0, 0x42, - 0x6e, 0x79, 0x8, 0x0, 0x15, 0xc2, 0x74, 0xf4, 0xce, 0x9e, 0x9b, 0x3e, 0x80, 0xb7, 0x79, 0xc7, 0xad, - 0xc3, 0xc7, 0x7e, 0x46, 0x96, 0x3b, 0x8e, 0xb2, 0x64, 0x1c}; +// SubscribeRequest 8250 [("\237(\254^Q",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS1}),("=\197G\215j^\203%xY\252S\159\251\180\234\169\174\246\185\251",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\223H\213n$\254\160\161A\252\180\193Z\219\143",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("=\193w\237l:\149\177\EOT\a\200",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\217k\215\DC3\211\248\152\216\156\139\ETBo\175\246\239\183\DC3&\SYN1G\139\196n\164",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] +// [PropSubscriptionIdentifierAvailable 201,PropRetainAvailable 127,PropReceiveMaximum 3921,PropSessionExpiryInterval +// 14620,PropSessionExpiryInterval 13880,PropWillDelayInterval 25317,PropPayloadFormatIndicator 13,PropTopicAliasMaximum +// 29847,PropMessageExpiryInterval 10331,PropRequestProblemInformation 216,PropPayloadFormatIndicator +// 234,PropMaximumPacketSize 3753,PropMessageExpiryInterval 2418,PropSubscriptionIdentifier +// 6,PropRequestProblemInformation 153,PropPayloadFormatIndicator 236,PropWillDelayInterval 7178,PropServerReference +// "yV\198\185\167n0\RS\178\DELs\221\218\163d\186\128h\150\252\246`\189\133\164\166]\210",PropReceiveMaximum +// 16636,PropPayloadFormatIndicator 119,PropCorrelationData "\FS(WY=\235\139\209f\228\NAK",PropPayloadFormatIndicator +// 0,PropReasonString "",PropReasonString "Iv\173\184O\EM|J\DC3\243\"\255ft4"] +TEST(Subscribe5QCTest, Encode8) { + uint8_t pkt[] = {0x82, 0xe2, 0x1, 0x20, 0x3a, 0x82, 0x1, 0x29, 0xc9, 0x25, 0x7f, 0x21, 0xf, 0x51, 0x11, 0x0, 0x0, + 0x39, 0x1c, 0x11, 0x0, 0x0, 0x36, 0x38, 0x18, 0x0, 0x0, 0x62, 0xe5, 0x1, 0xd, 0x22, 0x74, 0x97, + 0x2, 0x0, 0x0, 0x28, 0x5b, 0x17, 0xd8, 0x1, 0xea, 0x27, 0x0, 0x0, 0xe, 0xa9, 0x2, 0x0, 0x0, + 0x9, 0x72, 0xb, 0x6, 0x17, 0x99, 0x1, 0xec, 0x18, 0x0, 0x0, 0x1c, 0xa, 0x1c, 0x0, 0x1c, 0x79, + 0x56, 0xc6, 0xb9, 0xa7, 0x6e, 0x30, 0x1e, 0xb2, 0x7f, 0x73, 0xdd, 0xda, 0xa3, 0x64, 0xba, 0x80, 0x68, + 0x96, 0xfc, 0xf6, 0x60, 0xbd, 0x85, 0xa4, 0xa6, 0x5d, 0xd2, 0x21, 0x40, 0xfc, 0x1, 0x77, 0x9, 0x0, + 0xb, 0x1c, 0x28, 0x57, 0x59, 0x3d, 0xeb, 0x8b, 0xd1, 0x66, 0xe4, 0x15, 0x1, 0x0, 0x1f, 0x0, 0x0, + 0x1f, 0x0, 0xf, 0x49, 0x76, 0xad, 0xb8, 0x4f, 0x19, 0x7c, 0x4a, 0x13, 0xf3, 0x22, 0xff, 0x66, 0x74, + 0x34, 0x0, 0x5, 0xed, 0x28, 0xfe, 0x5e, 0x51, 0x25, 0x0, 0x15, 0x3d, 0xc5, 0x47, 0xd7, 0x6a, 0x5e, + 0xcb, 0x25, 0x78, 0x59, 0xfc, 0x53, 0x9f, 0xfb, 0xb4, 0xea, 0xa9, 0xae, 0xf6, 0xb9, 0xfb, 0x22, 0x0, + 0xf, 0xdf, 0x48, 0xd5, 0x6e, 0x24, 0xfe, 0xa0, 0xa1, 0x41, 0xfc, 0xb4, 0xc1, 0x5a, 0xdb, 0x8f, 0xd, + 0x0, 0xb, 0x3d, 0xc1, 0x77, 0xed, 0x6c, 0x3a, 0x95, 0xb1, 0x4, 0x7, 0xc8, 0x14, 0x0, 0x19, 0xd9, + 0x6b, 0xd7, 0x13, 0xd3, 0xf8, 0x98, 0xd8, 0x9c, 0x8b, 0x17, 0x6f, 0xaf, 0xf6, 0xef, 0xb7, 0x13, 0x26, + 0x16, 0x31, 0x47, 0x8b, 0xc4, 0x6e, 0xa4, 0x2e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x5c, 0x8d, 0xfe, 0x18, 0xd9, 0x14, 0xf0, 0xf4, 0x7f, 0x78, - 0x3b, 0xee, 0xe, 0xa8, 0x36, 0x41, 0xdf, 0x76, 0xa3, 0x80}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xed, 0x28, 0xfe, 0x5e, 0x51}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x74, 0xb5, 0x3e, 0x35, 0x2f, 0xf5, 0xc, 0x9b, 0xa1, 0xb8, 0xd3}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x3d, 0xc5, 0x47, 0xd7, 0x6a, 0x5e, 0xcb, 0x25, 0x78, 0x59, 0xfc, + 0x53, 0x9f, 0xfb, 0xb4, 0xea, 0xa9, 0xae, 0xf6, 0xb9, 0xfb}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2, 0x3d, 0x8, 0x96, 0x64, 0xdb, 0xc8, 0xb1, - 0xb2, 0xe2, 0x44, 0x99, 0xfc, 0x41, 0xe5}; + uint8_t topic_filter_s2_bytes[] = {0xdf, 0x48, 0xd5, 0x6e, 0x24, 0xfe, 0xa0, 0xa1, + 0x41, 0xfc, 0xb4, 0xc1, 0x5a, 0xdb, 0x8f}; lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf5, 0x8a, 0xc, 0x6c, 0xe4, 0x9f, 0xe0, 0x42, 0x6e, 0x79}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x3d, 0xc1, 0x77, 0xed, 0x6c, 0x3a, 0x95, 0xb1, 0x4, 0x7, 0xc8}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc2, 0x74, 0xf4, 0xce, 0x9e, 0x9b, 0x3e, 0x80, 0xb7, 0x79, 0xc7, - 0xad, 0xc3, 0xc7, 0x7e, 0x46, 0x96, 0x3b, 0x8e, 0xb2, 0x64}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd9, 0x6b, 0xd7, 0x13, 0xd3, 0xf8, 0x98, 0xd8, 0x9c, 0x8b, 0x17, 0x6f, 0xaf, + 0xf6, 0xef, 0xb7, 0x13, 0x26, 0x16, 0x31, 0x47, 0x8b, 0xc4, 0x6e, 0xa4}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = true; - uint8_t bytesprops0[] = {0x59, 0xa8, 0xb2, 0xc8, 0x2f, 0xd0}; - uint8_t bytesprops1[] = {0x9a, 0xe5, 0x56, 0xeb, 0x4, 0xbe, 0x62, 0x98}; + uint8_t bytesprops0[] = {0x79, 0x56, 0xc6, 0xb9, 0xa7, 0x6e, 0x30, 0x1e, 0xb2, 0x7f, 0x73, 0xdd, 0xda, 0xa3, + 0x64, 0xba, 0x80, 0x68, 0x96, 0xfc, 0xf6, 0x60, 0xbd, 0x85, 0xa4, 0xa6, 0x5d, 0xd2}; + uint8_t bytesprops1[] = {0x1c, 0x28, 0x57, 0x59, 0x3d, 0xeb, 0x8b, 0xd1, 0x66, 0xe4, 0x15}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x49, 0x76, 0xad, 0xb8, 0x4f, 0x19, 0x7c, 0x4a, 0x13, 0xf3, 0x22, 0xff, 0x66, 0x74, 0x34}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17727}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30281}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7251}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20135}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 569}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7009}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16877}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12069}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 426}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3921}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14620}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13880}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25317}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29847}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10331}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3753}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2418}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7178}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16636}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26860, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8250, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11675 [("n\192\248\255\205<\240\238\SO!\140\179\201",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("o",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\232\ETXX\162\232\228\251b8Y\146c\244\143\247\RS\135",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropTopicAlias 32522,PropTopicAliasMaximum -// 473,PropRequestResponseInformation 137,PropTopicAliasMaximum 6865,PropMaximumPacketSize -// 20987,PropAuthenticationMethod "\227\&2\SI/bp6",PropSessionExpiryInterval 15350,PropWildcardSubscriptionAvailable -// 52,PropServerReference "\225\214\182\253A\198\159V\185D\226h\135D*Q\187\242/\247\FS0\223K",PropCorrelationData -// "\181\137t5",PropWildcardSubscriptionAvailable 22,PropReceiveMaximum 31071,PropWildcardSubscriptionAvailable -// 134,PropMessageExpiryInterval 1718,PropUserProperty "\223\NAK\191" -// "\129\DEL\SI\239\241^\224\147\&5\"5\210-\153@H.!ES\148\183",PropSubscriptionIdentifierAvailable -// 101,PropRequestProblemInformation 134] -TEST(Subscribe5QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x9c, 0x1, 0x2d, 0x9b, 0x71, 0x23, 0x7f, 0xa, 0x22, 0x1, 0xd9, 0x19, 0x89, 0x22, 0x1a, - 0xd1, 0x27, 0x0, 0x0, 0x51, 0xfb, 0x15, 0x0, 0x7, 0xe3, 0x32, 0xf, 0x2f, 0x62, 0x70, 0x36, - 0x11, 0x0, 0x0, 0x3b, 0xf6, 0x28, 0x34, 0x1c, 0x0, 0x18, 0xe1, 0xd6, 0xb6, 0xfd, 0x41, 0xc6, - 0x9f, 0x56, 0xb9, 0x44, 0xe2, 0x68, 0x87, 0x44, 0x2a, 0x51, 0xbb, 0xf2, 0x2f, 0xf7, 0x1c, 0x30, - 0xdf, 0x4b, 0x9, 0x0, 0x4, 0xb5, 0x89, 0x74, 0x35, 0x28, 0x16, 0x21, 0x79, 0x5f, 0x28, 0x86, - 0x2, 0x0, 0x0, 0x6, 0xb6, 0x26, 0x0, 0x3, 0xdf, 0x15, 0xbf, 0x0, 0x16, 0x81, 0x7f, 0xf, - 0xef, 0xf1, 0x5e, 0xe0, 0x93, 0x35, 0x22, 0x35, 0xd2, 0x2d, 0x99, 0x40, 0x48, 0x2e, 0x21, 0x45, - 0x53, 0x94, 0xb7, 0x29, 0x65, 0x17, 0x86, 0x0, 0xd, 0x6e, 0xc0, 0xf8, 0xff, 0xcd, 0x3c, 0xf0, - 0xee, 0xe, 0x21, 0x8c, 0xb3, 0xc9, 0xd, 0x0, 0x1, 0x6f, 0x4, 0x0, 0x11, 0xe8, 0x3, 0x58, - 0xa2, 0xe8, 0xe4, 0xfb, 0x62, 0x38, 0x59, 0x92, 0x63, 0xf4, 0x8f, 0xf7, 0x1e, 0x87, 0x8}; +// SubscribeRequest 2359 [("\EM\174:\184\155\&9\131\194\148",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropSharedSubscriptionAvailable +// 213,PropPayloadFormatIndicator 45,PropRequestProblemInformation 15,PropResponseInformation +// "2Z\216W7\DLEa\ESC4r\DC4h`\EOT\157\&4*Y\181\159\151\201P\152\SYN\245ke",PropTopicAlias 17577,PropMaximumQoS +// 139,PropMessageExpiryInterval 13699,PropRequestResponseInformation 147,PropSubscriptionIdentifierAvailable +// 7,PropSubscriptionIdentifier 25,PropRetainAvailable 108,PropSubscriptionIdentifierAvailable 214,PropContentType +// "M",PropSubscriptionIdentifier 4,PropWildcardSubscriptionAvailable 226,PropReceiveMaximum +// 9422,PropAuthenticationMethod "\242\SO\a\EM",PropWillDelayInterval 26420,PropResponseInformation +// "\\\b(<\201\190\229_\152",PropMessageExpiryInterval 18588,PropAuthenticationData +// "\147\150\&7\241\182\197\209",PropReasonString +// "6\184\&3\145\152\193\242\139\128\201S\224\&9",PropAssignedClientIdentifier +// "\ESC\164\SOH\245\249\197\255\DC3b\155\199\132.",PropWildcardSubscriptionAvailable 76,PropContentType +// "\233\t\166",PropSubscriptionIdentifierAvailable 84,PropMessageExpiryInterval 3926,PropCorrelationData +// "H\172\172\&2\159\\\ETX\164\NAKhc\251\220\206\183 \151\252\140]\166\196",PropTopicAliasMaximum 5271] +TEST(Subscribe5QCTest, Encode9) { + uint8_t pkt[] = {0x82, 0xc6, 0x1, 0x9, 0x37, 0xb6, 0x1, 0x2a, 0xd5, 0x1, 0x2d, 0x17, 0xf, 0x1a, 0x0, 0x1c, 0x32, + 0x5a, 0xd8, 0x57, 0x37, 0x10, 0x61, 0x1b, 0x34, 0x72, 0x14, 0x68, 0x60, 0x4, 0x9d, 0x34, 0x2a, 0x59, + 0xb5, 0x9f, 0x97, 0xc9, 0x50, 0x98, 0x16, 0xf5, 0x6b, 0x65, 0x23, 0x44, 0xa9, 0x24, 0x8b, 0x2, 0x0, + 0x0, 0x35, 0x83, 0x19, 0x93, 0x29, 0x7, 0xb, 0x19, 0x25, 0x6c, 0x29, 0xd6, 0x3, 0x0, 0x1, 0x4d, + 0xb, 0x4, 0x28, 0xe2, 0x21, 0x24, 0xce, 0x15, 0x0, 0x4, 0xf2, 0xe, 0x7, 0x19, 0x18, 0x0, 0x0, + 0x67, 0x34, 0x1a, 0x0, 0x9, 0x5c, 0x8, 0x28, 0x3c, 0xc9, 0xbe, 0xe5, 0x5f, 0x98, 0x2, 0x0, 0x0, + 0x48, 0x9c, 0x16, 0x0, 0x7, 0x93, 0x96, 0x37, 0xf1, 0xb6, 0xc5, 0xd1, 0x1f, 0x0, 0xd, 0x36, 0xb8, + 0x33, 0x91, 0x98, 0xc1, 0xf2, 0x8b, 0x80, 0xc9, 0x53, 0xe0, 0x39, 0x12, 0x0, 0xd, 0x1b, 0xa4, 0x1, + 0xf5, 0xf9, 0xc5, 0xff, 0x13, 0x62, 0x9b, 0xc7, 0x84, 0x2e, 0x28, 0x4c, 0x3, 0x0, 0x3, 0xe9, 0x9, + 0xa6, 0x29, 0x54, 0x2, 0x0, 0x0, 0xf, 0x56, 0x9, 0x0, 0x16, 0x48, 0xac, 0xac, 0x32, 0x9f, 0x5c, + 0x3, 0xa4, 0x15, 0x68, 0x63, 0xfb, 0xdc, 0xce, 0xb7, 0x20, 0x97, 0xfc, 0x8c, 0x5d, 0xa6, 0xc4, 0x22, + 0x14, 0x97, 0x0, 0x9, 0x19, 0xae, 0x3a, 0xb8, 0x9b, 0x39, 0x83, 0xc2, 0x94, 0x24}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x6e, 0xc0, 0xf8, 0xff, 0xcd, 0x3c, 0xf0, 0xee, 0xe, 0x21, 0x8c, 0xb3, 0xc9}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x19, 0xae, 0x3a, 0xb8, 0x9b, 0x39, 0x83, 0xc2, 0x94}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6f}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + uint8_t bytesprops0[] = {0x32, 0x5a, 0xd8, 0x57, 0x37, 0x10, 0x61, 0x1b, 0x34, 0x72, 0x14, 0x68, 0x60, 0x4, + 0x9d, 0x34, 0x2a, 0x59, 0xb5, 0x9f, 0x97, 0xc9, 0x50, 0x98, 0x16, 0xf5, 0x6b, 0x65}; + uint8_t bytesprops1[] = {0x4d}; + uint8_t bytesprops2[] = {0xf2, 0xe, 0x7, 0x19}; + uint8_t bytesprops3[] = {0x5c, 0x8, 0x28, 0x3c, 0xc9, 0xbe, 0xe5, 0x5f, 0x98}; + uint8_t bytesprops4[] = {0x93, 0x96, 0x37, 0xf1, 0xb6, 0xc5, 0xd1}; + uint8_t bytesprops5[] = {0x36, 0xb8, 0x33, 0x91, 0x98, 0xc1, 0xf2, 0x8b, 0x80, 0xc9, 0x53, 0xe0, 0x39}; + uint8_t bytesprops6[] = {0x1b, 0xa4, 0x1, 0xf5, 0xf9, 0xc5, 0xff, 0x13, 0x62, 0x9b, 0xc7, 0x84, 0x2e}; + uint8_t bytesprops7[] = {0xe9, 0x9, 0xa6}; + uint8_t bytesprops8[] = {0x48, 0xac, 0xac, 0x32, 0x9f, 0x5c, 0x3, 0xa4, 0x15, 0x68, 0x63, + 0xfb, 0xdc, 0xce, 0xb7, 0x20, 0x97, 0xfc, 0x8c, 0x5d, 0xa6, 0xc4}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 213}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17577}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13699}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9422}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26420}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18588}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3926}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5271}}, + }; + + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2359, 1, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 16794 [("K\236r=\152\194\134Z}\181\&3:\143\143u\164\DC1\208\150\146\248\ETB",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\RS\SUB\bJ\131u",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = +// True, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS0}),("\195J\198\164\135",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// True, _noLocal = True, _subQoS = QoS0}),("\188\161\156\135\DEL\148\RS\249@\DC3\187",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\216mP\206\&1\135\r\155\237\&0\DC4R\175$\254h\NAKN\f",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropAssignedClientIdentifier +// "",PropMessageExpiryInterval 18708,PropContentType +// "F1\ETXrk]@\239\211(\SOH\235\143\DC2\ESCiSucsM\184\161$",PropReceiveMaximum 15395,PropServerReference +// "\181\182/\141L\140\237K\DC2\138\183\NAK\193\&7\132\139k\165\213\151",PropMessageExpiryInterval 5921,PropContentType +// "g\197\204z*\206\186\141\195ln\DLE\190m\DC2\235\213",PropResponseInformation +// "\240\FS,\135\203yI\146e\160\133\190",PropRequestProblemInformation 70,PropSessionExpiryInterval 10978,PropMaximumQoS +// 128,PropMaximumQoS 111] +TEST(Subscribe5QCTest, Encode10) { + uint8_t pkt[] = {0x82, 0xc4, 0x1, 0x41, 0x9a, 0x70, 0x12, 0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0x68, 0x15, 0x4e, 0xc, 0x16}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x4b, 0xec, 0x72, 0x3d, 0x98, 0xc2, 0x86, 0x5a, 0x7d, 0xb5, 0x33, + 0x3a, 0x8f, 0x8f, 0x75, 0xa4, 0x11, 0xd0, 0x96, 0x92, 0xf8, 0x17}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0x1a, 0x8, 0x4a, 0x83, 0x75}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe8, 0x3, 0x58, 0xa2, 0xe8, 0xe4, 0xfb, 0x62, 0x38, - 0x59, 0x92, 0x63, 0xf4, 0x8f, 0xf7, 0x1e, 0x87}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; + uint8_t topic_filter_s3_bytes[] = {0xc3, 0x4a, 0xc6, 0xa4, 0x87}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xbc, 0xa1, 0x9c, 0x87, 0x7f, 0x94, 0x1e, 0xf9, 0x40, 0x13, 0xbb}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xd8, 0x6d, 0x50, 0xce, 0x31, 0x87, 0xd, 0x9b, 0xed, 0x30, + 0x14, 0x52, 0xaf, 0x24, 0xfe, 0x68, 0x15, 0x4e, 0xc}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + lwmqtt_sub_options_t sub_opts[6]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = false; - uint8_t bytesprops0[] = {0xe3, 0x32, 0xf, 0x2f, 0x62, 0x70, 0x36}; - uint8_t bytesprops1[] = {0xe1, 0xd6, 0xb6, 0xfd, 0x41, 0xc6, 0x9f, 0x56, 0xb9, 0x44, 0xe2, 0x68, - 0x87, 0x44, 0x2a, 0x51, 0xbb, 0xf2, 0x2f, 0xf7, 0x1c, 0x30, 0xdf, 0x4b}; - uint8_t bytesprops2[] = {0xb5, 0x89, 0x74, 0x35}; - uint8_t bytesprops4[] = {0x81, 0x7f, 0xf, 0xef, 0xf1, 0x5e, 0xe0, 0x93, 0x35, 0x22, 0x35, - 0xd2, 0x2d, 0x99, 0x40, 0x48, 0x2e, 0x21, 0x45, 0x53, 0x94, 0xb7}; - uint8_t bytesprops3[] = {0xdf, 0x15, 0xbf}; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x46, 0x31, 0x3, 0x72, 0x6b, 0x5d, 0x40, 0xef, 0xd3, 0x28, 0x1, 0xeb, + 0x8f, 0x12, 0x1b, 0x69, 0x53, 0x75, 0x63, 0x73, 0x4d, 0xb8, 0xa1, 0x24}; + uint8_t bytesprops2[] = {0xb5, 0xb6, 0x2f, 0x8d, 0x4c, 0x8c, 0xed, 0x4b, 0x12, 0x8a, + 0xb7, 0x15, 0xc1, 0x37, 0x84, 0x8b, 0x6b, 0xa5, 0xd5, 0x97}; + uint8_t bytesprops3[] = {0x67, 0xc5, 0xcc, 0x7a, 0x2a, 0xce, 0xba, 0x8d, 0xc3, + 0x6c, 0x6e, 0x10, 0xbe, 0x6d, 0x12, 0xeb, 0xd5}; + uint8_t bytesprops4[] = {0xf0, 0x1c, 0x2c, 0x87, 0xcb, 0x79, 0x49, 0x92, 0x65, 0xa0, 0x85, 0xbe}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32522}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 473}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6865}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20987}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15350}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31071}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1718}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops3}, .v = {22, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18708}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15395}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5921}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10978}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 111}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11675, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16794, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 3007 [("<\ESCJ\DC2V\230\n\158\168\250G%\212R\210V\227\229\134j\165\&3)\146\165\&95",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("_\234\180~!\246(\231}4\200\221\168\191\149\197$0\202\223\&0\150\vE\169\217\189",SubOptions {_retainHandling -// = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\GS\195\202\227\242t}K9k\EMD\149|\186\ESC~tO\216\200\234",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("Nz\DC2\155\&2\182\ETB>)\DC2&?\246\193i`\151\NAK_\US4\DC1\252\234\DC2Z\NUL\a\153",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("@\194TRT -// \178\157\251\225q\SO\181(\194\220\217p",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\206\DLE\241X5E\154\204\CAN\229~hlj{`f1\155y\181\DEL\217;",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\201{}\179\NAK",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS0}),("f\t\SYN\165=\225\132\NUL\207\161F\250\237\SOH\195\142\"\148",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0}),("\186\ETX[",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\234\250\254\182(\DEL\154mqQ\135K\160MA\174\234\211\145}\187\DC2hn/_",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropReasonString -// "",PropServerKeepAlive 8062] -TEST(Subscribe5QCTest, Encode9) { - uint8_t pkt[] = { - 0x82, 0xf1, 0x1, 0xb, 0xbf, 0x6, 0x1f, 0x0, 0x0, 0x13, 0x1f, 0x7e, 0x0, 0x1b, 0x3c, 0x1b, 0x4a, 0x12, 0x56, - 0xe6, 0xa, 0x9e, 0xa8, 0xfa, 0x47, 0x25, 0xd4, 0x52, 0xd2, 0x56, 0xe3, 0xe5, 0x86, 0x6a, 0xa5, 0x33, 0x29, 0x92, - 0xa5, 0x39, 0x35, 0x10, 0x0, 0x1b, 0x5f, 0xea, 0xb4, 0x7e, 0x21, 0xf6, 0x28, 0xe7, 0x7d, 0x34, 0xc8, 0xdd, 0xa8, - 0xbf, 0x95, 0xc5, 0x24, 0x30, 0xca, 0xdf, 0x30, 0x96, 0xb, 0x45, 0xa9, 0xd9, 0xbd, 0x20, 0x0, 0x16, 0x1d, 0xc3, - 0xca, 0xe3, 0xf2, 0x74, 0x7d, 0x4b, 0x39, 0x6b, 0x19, 0x44, 0x95, 0x7c, 0xba, 0x1b, 0x7e, 0x74, 0x4f, 0xd8, 0xc8, - 0xea, 0x4, 0x0, 0x0, 0x2a, 0x0, 0x1d, 0x4e, 0x7a, 0x12, 0x9b, 0x32, 0xb6, 0x17, 0x3e, 0x29, 0x12, 0x26, 0x3f, - 0xf6, 0xc1, 0x69, 0x60, 0x97, 0x15, 0x5f, 0x1f, 0x34, 0x11, 0xfc, 0xea, 0x12, 0x5a, 0x0, 0x7, 0x99, 0xd, 0x0, - 0x12, 0x40, 0xc2, 0x54, 0x52, 0x54, 0x20, 0xb2, 0x9d, 0xfb, 0xe1, 0x71, 0xe, 0xb5, 0x28, 0xc2, 0xdc, 0xd9, 0x70, - 0x11, 0x0, 0x18, 0xce, 0x10, 0xf1, 0x58, 0x35, 0x45, 0x9a, 0xcc, 0x18, 0xe5, 0x7e, 0x68, 0x6c, 0x6a, 0x7b, 0x60, - 0x66, 0x31, 0x9b, 0x79, 0xb5, 0x7f, 0xd9, 0x3b, 0x14, 0x0, 0x5, 0xc9, 0x7b, 0x7d, 0xb3, 0x15, 0x14, 0x0, 0x12, - 0x66, 0x9, 0x16, 0xa5, 0x3d, 0xe1, 0x84, 0x0, 0xcf, 0xa1, 0x46, 0xfa, 0xed, 0x1, 0xc3, 0x8e, 0x22, 0x94, 0x8, - 0x0, 0x3, 0xba, 0x3, 0x5b, 0x5, 0x0, 0x1a, 0xea, 0xfa, 0xfe, 0xb6, 0x28, 0x7f, 0x9a, 0x6d, 0x71, 0x51, 0x87, - 0x4b, 0xa0, 0x4d, 0x41, 0xae, 0xea, 0xd3, 0x91, 0x7d, 0xbb, 0x12, 0x68, 0x6e, 0x2f, 0x5f, 0x0}; +// SubscribeRequest 9525 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("Y",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS0}),("yTU\212\STX\n0g\ETB\216;\193\141^of\176\131l\247\243\175\226W!\218\226\143&Y",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\129",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2}),("\158\142\237\223\DEL\238TE#\174\&4\RS\247x\152d\195\167u\246\255\201\167\162=\206-",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\169\195$\148J\198r\134D\151\160\STX%j\191\201\209\170\156t\r\244k\183\198",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\DC4&y\247\168\&1W\NUL\245\&6\237\210\150i",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("cQ_y\200\249",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\STX\217 \170>\EM",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\STX\135*",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, +// _subQoS = QoS0}),("]\141\210\RS\186\238\n\ESC\GSj\131\174\190;\136\207Ofzf'",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] +// [PropWildcardSubscriptionAvailable 205,PropMessageExpiryInterval 18112,PropReceiveMaximum +// 22374,PropPayloadFormatIndicator 97,PropReasonString +// "D:\165\232\200\&4\239=\222\147\149Ck\207\228\130\SOHi\253\161q8\223p\FS\133\SO\156\181\159"] +TEST(Subscribe5QCTest, Encode11) { + uint8_t pkt[] = {0x82, 0xd7, 0x1, 0x25, 0x35, 0x2d, 0x28, 0xcd, 0x2, 0x0, 0x0, 0x46, 0xc0, 0x21, 0x57, 0x66, 0x1, + 0x61, 0x1f, 0x0, 0x1e, 0x44, 0x3a, 0xa5, 0xe8, 0xc8, 0x34, 0xef, 0x3d, 0xde, 0x93, 0x95, 0x43, 0x6b, + 0xcf, 0xe4, 0x82, 0x1, 0x69, 0xfd, 0xa1, 0x71, 0x38, 0xdf, 0x70, 0x1c, 0x85, 0xe, 0x9c, 0xb5, 0x9f, + 0x0, 0x0, 0x1, 0x0, 0x1, 0x59, 0x18, 0x0, 0x1e, 0x79, 0x54, 0x55, 0xd4, 0x2, 0xa, 0x30, 0x67, + 0x17, 0xd8, 0x3b, 0xc1, 0x8d, 0x5e, 0x6f, 0x66, 0xb0, 0x83, 0x6c, 0xf7, 0xf3, 0xaf, 0xe2, 0x57, 0x21, + 0xda, 0xe2, 0x8f, 0x26, 0x59, 0x24, 0x0, 0x1, 0x81, 0x22, 0x0, 0x1b, 0x9e, 0x8e, 0xed, 0xdf, 0x7f, + 0xee, 0x54, 0x45, 0x23, 0xae, 0x34, 0x1e, 0xf7, 0x78, 0x98, 0x64, 0xc3, 0xa7, 0x75, 0xf6, 0xff, 0xc9, + 0xa7, 0xa2, 0x3d, 0xce, 0x2d, 0x28, 0x0, 0x19, 0xa9, 0xc3, 0x24, 0x94, 0x4a, 0xc6, 0x72, 0x86, 0x44, + 0x97, 0xa0, 0x2, 0x25, 0x6a, 0xbf, 0xc9, 0xd1, 0xaa, 0x9c, 0x74, 0xd, 0xf4, 0x6b, 0xb7, 0xc6, 0x15, + 0x0, 0xe, 0x14, 0x26, 0x79, 0xf7, 0xa8, 0x31, 0x57, 0x0, 0xf5, 0x36, 0xed, 0xd2, 0x96, 0x69, 0x16, + 0x0, 0x6, 0x63, 0x51, 0x5f, 0x79, 0xc8, 0xf9, 0x5, 0x0, 0x6, 0x2, 0xd9, 0x20, 0xaa, 0x3e, 0x19, + 0x21, 0x0, 0x3, 0x2, 0x87, 0x2a, 0x8, 0x0, 0x15, 0x5d, 0x8d, 0xd2, 0x1e, 0xba, 0xee, 0xa, 0x1b, + 0x1d, 0x6a, 0x83, 0xae, 0xbe, 0x3b, 0x88, 0xcf, 0x4f, 0x66, 0x7a, 0x66, 0x27, 0x28}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x3c, 0x1b, 0x4a, 0x12, 0x56, 0xe6, 0xa, 0x9e, 0xa8, 0xfa, 0x47, 0x25, 0xd4, 0x52, - 0xd2, 0x56, 0xe3, 0xe5, 0x86, 0x6a, 0xa5, 0x33, 0x29, 0x92, 0xa5, 0x39, 0x35}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5f, 0xea, 0xb4, 0x7e, 0x21, 0xf6, 0x28, 0xe7, 0x7d, 0x34, 0xc8, 0xdd, 0xa8, 0xbf, - 0x95, 0xc5, 0x24, 0x30, 0xca, 0xdf, 0x30, 0x96, 0xb, 0x45, 0xa9, 0xd9, 0xbd}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x59}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1d, 0xc3, 0xca, 0xe3, 0xf2, 0x74, 0x7d, 0x4b, 0x39, 0x6b, 0x19, - 0x44, 0x95, 0x7c, 0xba, 0x1b, 0x7e, 0x74, 0x4f, 0xd8, 0xc8, 0xea}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x79, 0x54, 0x55, 0xd4, 0x2, 0xa, 0x30, 0x67, 0x17, 0xd8, + 0x3b, 0xc1, 0x8d, 0x5e, 0x6f, 0x66, 0xb0, 0x83, 0x6c, 0xf7, + 0xf3, 0xaf, 0xe2, 0x57, 0x21, 0xda, 0xe2, 0x8f, 0x26, 0x59}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x81}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4e, 0x7a, 0x12, 0x9b, 0x32, 0xb6, 0x17, 0x3e, 0x29, 0x12, - 0x26, 0x3f, 0xf6, 0xc1, 0x69, 0x60, 0x97, 0x15, 0x5f, 0x1f, - 0x34, 0x11, 0xfc, 0xea, 0x12, 0x5a, 0x0, 0x7, 0x99}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x9e, 0x8e, 0xed, 0xdf, 0x7f, 0xee, 0x54, 0x45, 0x23, 0xae, 0x34, 0x1e, 0xf7, 0x78, + 0x98, 0x64, 0xc3, 0xa7, 0x75, 0xf6, 0xff, 0xc9, 0xa7, 0xa2, 0x3d, 0xce, 0x2d}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x40, 0xc2, 0x54, 0x52, 0x54, 0x20, 0xb2, 0x9d, 0xfb, - 0xe1, 0x71, 0xe, 0xb5, 0x28, 0xc2, 0xdc, 0xd9, 0x70}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xa9, 0xc3, 0x24, 0x94, 0x4a, 0xc6, 0x72, 0x86, 0x44, 0x97, 0xa0, 0x2, 0x25, + 0x6a, 0xbf, 0xc9, 0xd1, 0xaa, 0x9c, 0x74, 0xd, 0xf4, 0x6b, 0xb7, 0xc6}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xce, 0x10, 0xf1, 0x58, 0x35, 0x45, 0x9a, 0xcc, 0x18, 0xe5, 0x7e, 0x68, - 0x6c, 0x6a, 0x7b, 0x60, 0x66, 0x31, 0x9b, 0x79, 0xb5, 0x7f, 0xd9, 0x3b}; - lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x14, 0x26, 0x79, 0xf7, 0xa8, 0x31, 0x57, 0x0, 0xf5, 0x36, 0xed, 0xd2, 0x96, 0x69}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xc9, 0x7b, 0x7d, 0xb3, 0x15}; - lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x63, 0x51, 0x5f, 0x79, 0xc8, 0xf9}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x66, 0x9, 0x16, 0xa5, 0x3d, 0xe1, 0x84, 0x0, 0xcf, - 0xa1, 0x46, 0xfa, 0xed, 0x1, 0xc3, 0x8e, 0x22, 0x94}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x2, 0xd9, 0x20, 0xaa, 0x3e, 0x19}; + lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xba, 0x3, 0x5b}; + uint8_t topic_filter_s9_bytes[] = {0x2, 0x87, 0x2a}; lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xea, 0xfa, 0xfe, 0xb6, 0x28, 0x7f, 0x9a, 0x6d, 0x71, 0x51, 0x87, 0x4b, 0xa0, - 0x4d, 0x41, 0xae, 0xea, 0xd3, 0x91, 0x7d, 0xbb, 0x12, 0x68, 0x6e, 0x2f, 0x5f}; - lwmqtt_string_t topic_filter_s10 = {26, (char*)&topic_filter_s10_bytes}; + uint8_t topic_filter_s10_bytes[] = {0x5d, 0x8d, 0xd2, 0x1e, 0xba, 0xee, 0xa, 0x1b, 0x1d, 0x6a, 0x83, + 0xae, 0xbe, 0x3b, 0x88, 0xcf, 0x4f, 0x66, 0x7a, 0x66, 0x27}; + lwmqtt_string_t topic_filter_s10 = {21, (char*)&topic_filter_s10_bytes}; topic_filters[10] = topic_filter_s10; lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; + sub_opts[4].no_local = false; sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[5].no_local = true; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].qos = LWMQTT_QOS0; sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = true; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = false; sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; + sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[10].retain_as_published = true; sub_opts[10].no_local = false; - uint8_t bytesprops0[] = {0}; + uint8_t bytesprops0[] = {0x44, 0x3a, 0xa5, 0xe8, 0xc8, 0x34, 0xef, 0x3d, 0xde, 0x93, 0x95, 0x43, 0x6b, 0xcf, 0xe4, + 0x82, 0x1, 0x69, 0xfd, 0xa1, 0x71, 0x38, 0xdf, 0x70, 0x1c, 0x85, 0xe, 0x9c, 0xb5, 0x9f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8062}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18112}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22374}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3007, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9525, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 30616 [("b\GS\215\182QH\USjKr\230\129\142?Q\129UE\243\147n\229\160)\137",SubOptions {_retainHandling -// = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\164\EMyC\254\225\STX33_\EOTAsM\"\DEL\236\&3jy",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("}\159dgE^\200\218v",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\DC2\249\217\184\DEL\147\151g\128\169}\221\168\236~l",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\227\172\EM\147eL\199B -// \USLxP\210\a4as\191\232",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, -// _subQoS = QoS1})] [PropRequestResponseInformation 255,PropAssignedClientIdentifier -// "\190\DLE\FS\134c\141\255\181\"\248z\206N\t@\160{\200]\SYN\140\f\198\232\176>\252\243\t\203",PropReceiveMaximum -// 29184,PropTopicAliasMaximum 29191,PropRetainAvailable 168,PropServerKeepAlive 31897,PropServerKeepAlive -// 26301,PropUserProperty "\230I\187\DC3X\225\190\156\156E\249\132\DC2\244\&3v\158\144\182F" -// "\131\238\138\225\SI\204r\200#\SYN?\234&\ESCg4\176\213\&3\227;\146\228\209k\246",PropAuthenticationData -// "\254\172\138\226\"bfv\179\220\166",PropAuthenticationMethod -// "TlTU\SUBqZU\187\b\156\160\&8\224\244\252\CAN\190\152",PropResponseInformation -// "\246\164\160zZ",PropWildcardSubscriptionAvailable 0,PropContentType "",PropReceiveMaximum 29467,PropUserProperty -// "\253\RSI\129\158\223IT\156\186\DC2~\161\161\194/\130\179\168\213VX\247QY" "d5",PropUserProperty -// "q\207\173\188\221\183\194\223\155\181\193/c\247a" -// "\236d\219pJ%\DC3gf1\189\196\166\227\224\NAKx\243$\ETB\194\163\147",PropMessageExpiryInterval 9079,PropMaximumQoS -// 74,PropRequestProblemInformation 57] -TEST(Subscribe5QCTest, Encode10) { +// SubscribeRequest 25695 [("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal +// = True, _subQoS = QoS2}),("\186\219\215",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\201bK\187'\a\ENQ\157\250\DLE",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("X\223\196\156",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\244hB>\204s +// 1\US\233\145\133\178:\129\154\238z\SYN\152-\244tq\DC1\146",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\EOT\188\214C\158\190\234\ETBt\229\GSR\139N\217\SO\240\245\ENQ\173G;\153@\183",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("W406\252\156\\\212\&3\b\203$\187\247\DC2\235\v\134\181\231",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\191\ESC+\"q",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("!\138\RS@\137\CANP!\SOH]\f\250\244\251h\232\242\241\241\218",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\STX\134\223\174XA\133.\245g\FS~\224\173\r\158\EOT\165\NAK",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropContentType +// "13\214}\186\247\170\vg}",PropSharedSubscriptionAvailable 57,PropReceiveMaximum 1860,PropRequestResponseInformation +// 201,PropServerKeepAlive 31340,PropTopicAliasMaximum 14073,PropRequestProblemInformation 46,PropSessionExpiryInterval +// 7295,PropCorrelationData "\143\&5\135w\134\SOH\211v\141\132\202\187%s\140",PropServerReference +// "\DC1\215\170\&9d\155z\225",PropMessageExpiryInterval 6877,PropServerReference +// "\240Q/",PropSharedSubscriptionAvailable 143,PropSharedSubscriptionAvailable 239,PropServerReference +// "\rwMl\152\198h\219\175\148j\198M\244\EOT\227H}\210",PropReceiveMaximum 26293,PropCorrelationData +// "\241n\226\&0\250e\SOH\165\195\255",PropWillDelayInterval 24693,PropAuthenticationData +// "v\NAKa\240h\212",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),(".6V",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("N\199\249\DC2\184\STX\149\167\166je\254\207\152\130\210\151\ETB\144\RS\162\130\128\207I\DLE~\162\244<",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\162\199}\255V\131",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS1}),("\215\SOM\234!\158\&7\167\225\183\250\173",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("&\v\205\128\233\230\187\129\181\128S\NUL\222\253\185$*\180i\183",SubOptions {_retainHandling = +// SubscribeRequest 12087 [("\SOH\160\au5\136\&6\222",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\202SR62\ENQ<\140\142k",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\141\ACK\147\209\&2\239\163\250\214V",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\227a\EOT0{ \198\DC2\248\240s_m`\210\198~\128e\240\202\SOH",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\197%;s04\250{\144\SIN\157\136\156\157\221\232\250",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("86f\234\181\141#g\FS]\237x\187\200B\224Q\158\&3\234\STX\a1\233\\\FS",SubOptions {_retainHandling = // SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\135z\215D\NAK\225\197",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("v\236\188\199\GS\206N.\208J\187\188q~\n\173.\199\154\SIQ\215\&7",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("d\128\&5B\227\&7\DC3\221\200",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS0})] [PropResponseInformation "\150\142\";\245\DC4",PropAuthenticationMethod -// "\142\197%iY\t\156\255V\203\167\DLEA\SYN5\159Rb.`L|\SO%\GS\157=\SYN",PropReasonString -// "}\253\139\EM\150\229\RS",PropResponseTopic "=`\216\230\156\148\240\148\223\188bA\161z\144\196\143",PropResponseTopic -// "5\229\214\SOt\234)\r\129\181\200\r\229\209\DLE\213\238\146\ETX\177\131",PropCorrelationData "",PropTopicAliasMaximum -// 20281,PropAuthenticationMethod "\203\204k\"\168\132M\194\133\157\b@\155\&9"] -TEST(Subscribe5QCTest, Encode12) { +// QoS2}),("0\194w\220\142\208!>\246\138\133\163\SOH|\246I\FS$D\252`!\FS@",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\172\226p\DC4E\160\DC3\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS0}),("\230A<\165\132",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = True, _noLocal = False, _subQoS = QoS1})] [PropMaximumPacketSize 27560,PropReasonString +// "\216\&7\160s\166\151\187\239L\146\177`\136\233\176G",PropServerReference "\RS\254!\151\CAN",PropResponseInformation +// "K*H7\NAK\227\131\&8",PropCorrelationData "o\177\168NB\203\DC1\241\189\SO?\202",PropSessionExpiryInterval +// 6634,PropSubscriptionIdentifier 15,PropAuthenticationData "\198x@\ETB#\198\220\248",PropMessageExpiryInterval +// 24925,PropWillDelayInterval 13925,PropSubscriptionIdentifierAvailable 170,PropAuthenticationData +// "g#H\192\183+\SUB\170y`x\216\159\213?\180\254*\ETB\197\158\159\209\&3sPA",PropUserProperty +// "hp\150\177\128$\SO\SOH\219\131\174\&3 g\240e\134\EOT\187A" +// "\150\170\218\217\n(~\161\242\169\141\144\248\211",PropCorrelationData +// "\185\CANR;4\218A\229\&27\EM3o\188\230\&0%;|je'\148W\142\150>&\NAK\216",PropWillDelayInterval 4592] +TEST(Subscribe5QCTest, Encode14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, 0xfa, 0x2a, + 0x0, 0x0, 0x19, 0x0, 0x1a, 0x38, 0x36, 0x66, 0xea, 0xb5, 0x8d, 0x23, 0x67, 0x1c, 0x5d, 0xed, 0x78, 0xbb, 0xc8, + 0x42, 0xe0, 0x51, 0x9e, 0x33, 0xea, 0x2, 0x7, 0x31, 0xe9, 0x5c, 0x1c, 0x1a, 0x0, 0x18, 0x30, 0xc2, 0x77, 0xdc, + 0x8e, 0xd0, 0x21, 0x3e, 0xf6, 0x8a, 0x85, 0xa3, 0x1, 0x7c, 0xf6, 0x49, 0x1c, 0x24, 0x44, 0xfc, 0x60, 0x21, 0x1c, + 0x40, 0x4, 0x0, 0x8, 0xac, 0xe2, 0x70, 0x14, 0x45, 0xa0, 0x13, 0xe1, 0xc, 0x0, 0x5, 0xe6, 0x41, 0x3c, 0xa5, + 0x84, 0x9}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xf1, 0xb6, 0xdd, 0x18, 0xa, 0x6e, 0x38, 0xa, - 0x90, 0x97, 0x39, 0xc6, 0x0, 0x3c, 0x3e, 0xd4}; - lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x1, 0xa0, 0x7, 0x75, 0x35, 0x88, 0x36, 0xde}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2e, 0x36, 0x56}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xca, 0x53, 0x52, 0x36, 0x32, 0x5, 0x3c, 0x8c, 0x8e, 0x6b}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4e, 0xc7, 0xf9, 0x12, 0xb8, 0x2, 0x95, 0xa7, 0xa6, 0x6a, - 0x65, 0xfe, 0xcf, 0x98, 0x82, 0xd2, 0x97, 0x17, 0x90, 0x1e, - 0xa2, 0x82, 0x80, 0xcf, 0x49, 0x10, 0x7e, 0xa2, 0xf4, 0x3c}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8d, 0x6, 0x93, 0xd1, 0x32, 0xef, 0xa3, 0xfa, 0xd6, 0x56}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa2, 0xc7, 0x7d, 0xff, 0x56, 0x83}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xe3, 0x61, 0x4, 0x30, 0x7b, 0x20, 0xc6, 0x12, 0xf8, 0xf0, 0x73, + 0x5f, 0x6d, 0x60, 0xd2, 0xc6, 0x7e, 0x80, 0x65, 0xf0, 0xca, 0x1}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd7, 0xe, 0x4d, 0xea, 0x21, 0x9e, 0x37, 0xa7, 0xe1, 0xb7, 0xfa, 0xad}; - lwmqtt_string_t topic_filter_s4 = {12, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc5, 0x25, 0x3b, 0x73, 0x30, 0x34, 0xfa, 0x7b, 0x90, + 0xf, 0x4e, 0x9d, 0x88, 0x9c, 0x9d, 0xdd, 0xe8, 0xfa}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x26, 0xb, 0xcd, 0x80, 0xe9, 0xe6, 0xbb, 0x81, 0xb5, 0x80, - 0x53, 0x0, 0xde, 0xfd, 0xb9, 0x24, 0x2a, 0xb4, 0x69, 0xb7}; - lwmqtt_string_t topic_filter_s5 = {20, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x87, 0x7a, 0xd7, 0x44, 0x15, 0xe1, 0xc5}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x38, 0x36, 0x66, 0xea, 0xb5, 0x8d, 0x23, 0x67, 0x1c, 0x5d, 0xed, 0x78, 0xbb, + 0xc8, 0x42, 0xe0, 0x51, 0x9e, 0x33, 0xea, 0x2, 0x7, 0x31, 0xe9, 0x5c, 0x1c}; + lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x76, 0xec, 0xbc, 0xc7, 0x1d, 0xce, 0x4e, 0x2e, 0xd0, 0x4a, 0xbb, 0xbc, - 0x71, 0x7e, 0xa, 0xad, 0x2e, 0xc7, 0x9a, 0xf, 0x51, 0xd7, 0x37}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x30, 0xc2, 0x77, 0xdc, 0x8e, 0xd0, 0x21, 0x3e, 0xf6, 0x8a, 0x85, 0xa3, + 0x1, 0x7c, 0xf6, 0x49, 0x1c, 0x24, 0x44, 0xfc, 0x60, 0x21, 0x1c, 0x40}; + lwmqtt_string_t topic_filter_s7 = {24, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x64, 0x80, 0x35, 0x42, 0xe3, 0x37, 0x13, 0xdd, 0xc8}; - lwmqtt_string_t topic_filter_s8 = {9, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xac, 0xe2, 0x70, 0x14, 0x45, 0xa0, 0x13, 0xe1}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + uint8_t topic_filter_s9_bytes[] = {0xe6, 0x41, 0x3c, 0xa5, 0x84}; + lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = true; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; + sub_opts[6].retain_as_published = true; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].qos = LWMQTT_QOS0; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = true; @@ -13905,9024 +18072,9313 @@ TEST(Subscribe5QCTest, Encode12) { sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = true; sub_opts[8].no_local = true; - uint8_t bytesprops0[] = {0x96, 0x8e, 0x22, 0x3b, 0xf5, 0x14}; - uint8_t bytesprops1[] = {0x8e, 0xc5, 0x25, 0x69, 0x59, 0x9, 0x9c, 0xff, 0x56, 0xcb, 0xa7, 0x10, 0x41, 0x16, - 0x35, 0x9f, 0x52, 0x62, 0x2e, 0x60, 0x4c, 0x7c, 0xe, 0x25, 0x1d, 0x9d, 0x3d, 0x16}; - uint8_t bytesprops2[] = {0x7d, 0xfd, 0x8b, 0x19, 0x96, 0xe5, 0x1e}; - uint8_t bytesprops3[] = {0x3d, 0x60, 0xd8, 0xe6, 0x9c, 0x94, 0xf0, 0x94, 0xdf, - 0xbc, 0x62, 0x41, 0xa1, 0x7a, 0x90, 0xc4, 0x8f}; - uint8_t bytesprops4[] = {0x35, 0xe5, 0xd6, 0xe, 0x74, 0xea, 0x29, 0xd, 0x81, 0xb5, 0xc8, - 0xd, 0xe5, 0xd1, 0x10, 0xd5, 0xee, 0x92, 0x3, 0xb1, 0x83}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0xcb, 0xcc, 0x6b, 0x22, 0xa8, 0x84, 0x4d, 0xc2, 0x85, 0x9d, 0x8, 0x40, 0x9b, 0x39}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20281}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops6}}}, - }; - - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31365, 9, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 3963 [("&\249+\165\255",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS2})] [PropTopicAliasMaximum 15126,PropMessageExpiryInterval 4277,PropTopicAlias -// 4146,PropRequestProblemInformation 97,PropMaximumPacketSize 4331,PropSharedSubscriptionAvailable -// 226,PropRetainAvailable 242,PropWillDelayInterval 30502,PropServerReference "\132\189p\225q\153rV\203\130%"] -TEST(Subscribe5QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0x34, 0xf, 0x7b, 0x29, 0x22, 0x3b, 0x16, 0x2, 0x0, 0x0, 0x10, 0xb5, 0x23, - 0x10, 0x32, 0x17, 0x61, 0x27, 0x0, 0x0, 0x10, 0xeb, 0x2a, 0xe2, 0x25, 0xf2, 0x18, - 0x0, 0x0, 0x77, 0x26, 0x1c, 0x0, 0xb, 0x84, 0xbd, 0x70, 0xe1, 0x71, 0x99, 0x72, - 0x56, 0xcb, 0x82, 0x25, 0x0, 0x5, 0x26, 0xf9, 0x2b, 0xa5, 0xff, 0x16}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x26, 0xf9, 0x2b, 0xa5, 0xff}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - uint8_t bytesprops0[] = {0x84, 0xbd, 0x70, 0xe1, 0x71, 0x99, 0x72, 0x56, 0xcb, 0x82, 0x25}; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = true; + sub_opts[9].no_local = false; + uint8_t bytesprops0[] = {0xd8, 0x37, 0xa0, 0x73, 0xa6, 0x97, 0xbb, 0xef, + 0x4c, 0x92, 0xb1, 0x60, 0x88, 0xe9, 0xb0, 0x47}; + uint8_t bytesprops1[] = {0x1e, 0xfe, 0x21, 0x97, 0x18}; + uint8_t bytesprops2[] = {0x4b, 0x2a, 0x48, 0x37, 0x15, 0xe3, 0x83, 0x38}; + uint8_t bytesprops3[] = {0x6f, 0xb1, 0xa8, 0x4e, 0x42, 0xcb, 0x11, 0xf1, 0xbd, 0xe, 0x3f, 0xca}; + uint8_t bytesprops4[] = {0xc6, 0x78, 0x40, 0x17, 0x23, 0xc6, 0xdc, 0xf8}; + uint8_t bytesprops5[] = {0x67, 0x23, 0x48, 0xc0, 0xb7, 0x2b, 0x1a, 0xaa, 0x79, 0x60, 0x78, 0xd8, 0x9f, 0xd5, + 0x3f, 0xb4, 0xfe, 0x2a, 0x17, 0xc5, 0x9e, 0x9f, 0xd1, 0x33, 0x73, 0x50, 0x41}; + uint8_t bytesprops7[] = {0x96, 0xaa, 0xda, 0xd9, 0xa, 0x28, 0x7e, 0xa1, 0xf2, 0xa9, 0x8d, 0x90, 0xf8, 0xd3}; + uint8_t bytesprops6[] = {0x68, 0x70, 0x96, 0xb1, 0x80, 0x24, 0xe, 0x1, 0xdb, 0x83, + 0xae, 0x33, 0x20, 0x67, 0xf0, 0x65, 0x86, 0x4, 0xbb, 0x41}; + uint8_t bytesprops8[] = {0xb9, 0x18, 0x52, 0x3b, 0x34, 0xda, 0x41, 0xe5, 0x32, 0x37, 0x19, 0x33, 0x6f, 0xbc, 0xe6, + 0x30, 0x25, 0x3b, 0x7c, 0x6a, 0x65, 0x27, 0x94, 0x57, 0x8e, 0x96, 0x3e, 0x26, 0x15, 0xd8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15126}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4277}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4146}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4331}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30502}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27560}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6634}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24925}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13925}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops6}, .v = {14, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4592}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3963, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12087, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27481 [("\173\187\212\&85\132\164-<\f",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("j\187\191\158GB4 -// \150\146\235\244\140\&1\188\t\220\225\SI+O\165\163\DLE'\SI\226\221\181\254",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\210\&5",SubOptions +// SubscribeRequest 12264 [("\196k\DC4\147L\142U\156\ENQ\US\184Vi",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("v\GSMX\152\167\US\241\&0\144",SubOptions // {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("a\169{+\204\189x\GS{`\\\195",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("Q\\\225\194\n\180\179d|\208<\202R,\183\137\RSh",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("^\135\131R\219\\\129W@5`^\130\225?\243\200\157",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("Z\177\195\252s\ESCh\253 \b\f6\DC4",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\166\138\DC3\154:7\189]-\201p\160\223*R,\224",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("6\EM\165\136\194\149\NULb\236I\138\FS\207\&5qi\206\228\169i\r\252\132R\237",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe5QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0xb5, 0x1, 0x6b, 0x59, 0x0, 0x0, 0xa, 0xad, 0xbb, 0xd4, 0x38, 0x35, 0x84, 0xa4, 0x2d, 0x3c, - 0xc, 0x1d, 0x0, 0x1e, 0x6a, 0xbb, 0xbf, 0x9e, 0x47, 0x42, 0x34, 0x20, 0x96, 0x92, 0xeb, 0xf4, 0x8c, - 0x31, 0xbc, 0x9, 0xdc, 0xe1, 0xf, 0x2b, 0x4f, 0xa5, 0xa3, 0x10, 0x27, 0xf, 0xe2, 0xdd, 0xb5, 0xfe, - 0x12, 0x0, 0x2, 0xd2, 0x35, 0x16, 0x0, 0xc, 0x61, 0xa9, 0x7b, 0x2b, 0xcc, 0xbd, 0x78, 0x1d, 0x7b, - 0x60, 0x5c, 0xc3, 0x20, 0x0, 0x18, 0x51, 0x5c, 0xe1, 0x3c, 0x54, 0x70, 0xcc, 0x3c, 0x3e, 0xc2, 0xa, - 0xb4, 0xb3, 0x64, 0x7c, 0xd0, 0x3c, 0xca, 0x52, 0x2c, 0xb7, 0x89, 0x1e, 0x68, 0x2a, 0x0, 0x12, 0x5e, - 0x87, 0x83, 0x52, 0xdb, 0x5c, 0x81, 0x57, 0x40, 0x35, 0x60, 0x5e, 0x82, 0xe1, 0x3f, 0xf3, 0xc8, 0x9d, - 0x6, 0x0, 0xd, 0x5a, 0xb1, 0xc3, 0xfc, 0x73, 0x1b, 0x68, 0xfd, 0x20, 0x8, 0xc, 0x36, 0x14, 0x6, - 0x0, 0x11, 0xa6, 0x8a, 0x13, 0x9a, 0x3a, 0x37, 0xbd, 0x5d, 0x2d, 0xc9, 0x70, 0xa0, 0xdf, 0x2a, 0x52, - 0x2c, 0xe0, 0xa, 0x0, 0x19, 0x36, 0x19, 0xa5, 0x88, 0xc2, 0x95, 0x0, 0x62, 0xec, 0x49, 0x8a, 0x1c, - 0xcf, 0x35, 0x71, 0x69, 0xce, 0xe4, 0xa9, 0x69, 0xd, 0xfc, 0x84, 0x52, 0xed, 0x2}; +// QoS1}),("ZW\174\198D$\r\232\220afgJM\NAKe\174\158\192\138\223\ESCs\172d\140M",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\EOT\184\184Pt\214-\228:\SI\193\207\136",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\202\223|X\252\nU\158b~\143\&8\GS#",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\162#D\147((1X +// ",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\130\219\DC4\157\150w",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS2}),("|\141\195",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1})] [PropServerReference "\214\STX\ESC[~\135\&4\149\208H\173\SO\233Z +// \156\162\209\207\226>\165\251\247",PropRequestResponseInformation 114,PropResponseTopic +// "\144\131S^\232\227\206{\SO\156\238n\173;\209\246\153\177\136\GS\236\142\220\217",PropServerKeepAlive +// 241,PropRequestProblemInformation 7,PropMaximumQoS 79,PropReasonString +// "\GSHr\217\ETX\211\227\229\197Sg\129?\195D",PropResponseInformation "pZi\157\138\183$J7\150Y<\230 +// \220\182\150g\NAK\239A\165g\222\250\SOC",PropSharedSubscriptionAvailable 18,PropTopicAlias 8978,PropResponseTopic +// "\220\187\SOH'\US\172HL\DC2\226z=;$\157f\161\237\190\CAN\186%\254%U\205\250",PropRequestResponseInformation +// 30,PropAuthenticationMethod "\234",PropCorrelationData "\179\242\211\250\195",PropWildcardSubscriptionAvailable +// 200,PropReasonString "\184\135u\222gG\222v\158",PropRetainAvailable 169,PropSubscriptionIdentifier +// 14,PropMessageExpiryInterval 26125] +TEST(Subscribe5QCTest, Encode15) { + uint8_t pkt[] = { + 0x82, 0xb2, 0x2, 0x2f, 0xe8, 0xb7, 0x1, 0x1c, 0x0, 0x18, 0xd6, 0x2, 0x1b, 0x5b, 0x7e, 0x87, 0x34, 0x95, 0xd0, + 0x48, 0xad, 0xe, 0xe9, 0x5a, 0x20, 0x9c, 0xa2, 0xd1, 0xcf, 0xe2, 0x3e, 0xa5, 0xfb, 0xf7, 0x19, 0x72, 0x8, 0x0, + 0x18, 0x90, 0x83, 0x53, 0x5e, 0xe8, 0xe3, 0xce, 0x7b, 0x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4d, 0x15, 0x65, 0xae, 0x9e, 0xc0, 0x8a, 0xdf, 0x1b, 0x73, 0xac, 0x64, 0x8c, + 0x4d, 0x2d, 0x0, 0xd, 0x4, 0xb8, 0xb8, 0x50, 0x74, 0xd6, 0x2d, 0xe4, 0x3a, 0xf, 0xc1, 0xcf, 0x88, 0x1c, 0x0, + 0xe, 0xca, 0xdf, 0x7c, 0x58, 0xfc, 0xa, 0x55, 0x9e, 0x62, 0x7e, 0x8f, 0x38, 0x1d, 0x23, 0x1d, 0x0, 0x9, 0xa2, + 0x23, 0x44, 0x93, 0x28, 0x28, 0x31, 0x58, 0x20, 0x1d, 0x0, 0x6, 0x82, 0xdb, 0x14, 0x9d, 0x96, 0x77, 0x26, 0x0, + 0x3, 0x7c, 0x8d, 0xc3, 0x21}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xad, 0xbb, 0xd4, 0x38, 0x35, 0x84, 0xa4, 0x2d, 0x3c, 0xc}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xc4, 0x6b, 0x14, 0x93, 0x4c, 0x8e, 0x55, 0x9c, 0x5, 0x1f, 0xb8, 0x56, 0x69}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6a, 0xbb, 0xbf, 0x9e, 0x47, 0x42, 0x34, 0x20, 0x96, 0x92, - 0xeb, 0xf4, 0x8c, 0x31, 0xbc, 0x9, 0xdc, 0xe1, 0xf, 0x2b, - 0x4f, 0xa5, 0xa3, 0x10, 0x27, 0xf, 0xe2, 0xdd, 0xb5, 0xfe}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x76, 0x1d, 0x4d, 0x58, 0x98, 0xa7, 0x1f, 0xf1, 0x30, 0x90}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd2, 0x35}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5a, 0x57, 0xae, 0xc6, 0x44, 0x24, 0xd, 0xe8, 0xdc, 0x61, 0x66, 0x67, 0x4a, 0x4d, + 0x15, 0x65, 0xae, 0x9e, 0xc0, 0x8a, 0xdf, 0x1b, 0x73, 0xac, 0x64, 0x8c, 0x4d}; + lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x61, 0xa9, 0x7b, 0x2b, 0xcc, 0xbd, 0x78, 0x1d, 0x7b, 0x60, 0x5c, 0xc3}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x4, 0xb8, 0xb8, 0x50, 0x74, 0xd6, 0x2d, 0xe4, 0x3a, 0xf, 0xc1, 0xcf, 0x88}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x51, 0x5c, 0xe1, 0x3c, 0x54, 0x70, 0xcc, 0x3c, 0x3e, 0xc2, 0xa, 0xb4, - 0xb3, 0x64, 0x7c, 0xd0, 0x3c, 0xca, 0x52, 0x2c, 0xb7, 0x89, 0x1e, 0x68}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xca, 0xdf, 0x7c, 0x58, 0xfc, 0xa, 0x55, 0x9e, 0x62, 0x7e, 0x8f, 0x38, 0x1d, 0x23}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5e, 0x87, 0x83, 0x52, 0xdb, 0x5c, 0x81, 0x57, 0x40, - 0x35, 0x60, 0x5e, 0x82, 0xe1, 0x3f, 0xf3, 0xc8, 0x9d}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xa2, 0x23, 0x44, 0x93, 0x28, 0x28, 0x31, 0x58, 0x20}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x5a, 0xb1, 0xc3, 0xfc, 0x73, 0x1b, 0x68, 0xfd, 0x20, 0x8, 0xc, 0x36, 0x14}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x82, 0xdb, 0x14, 0x9d, 0x96, 0x77}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa6, 0x8a, 0x13, 0x9a, 0x3a, 0x37, 0xbd, 0x5d, 0x2d, - 0xc9, 0x70, 0xa0, 0xdf, 0x2a, 0x52, 0x2c, 0xe0}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x7c, 0x8d, 0xc3}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x36, 0x19, 0xa5, 0x88, 0xc2, 0x95, 0x0, 0x62, 0xec, 0x49, 0x8a, 0x1c, 0xcf, - 0x35, 0x71, 0x69, 0xce, 0xe4, 0xa9, 0x69, 0xd, 0xfc, 0x84, 0x52, 0xed}; - lwmqtt_string_t topic_filter_s8 = {25, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; + lwmqtt_sub_options_t sub_opts[8]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = true; sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; + uint8_t bytesprops0[] = {0xd6, 0x2, 0x1b, 0x5b, 0x7e, 0x87, 0x34, 0x95, 0xd0, 0x48, 0xad, 0xe, + 0xe9, 0x5a, 0x20, 0x9c, 0xa2, 0xd1, 0xcf, 0xe2, 0x3e, 0xa5, 0xfb, 0xf7}; + uint8_t bytesprops1[] = {0x90, 0x83, 0x53, 0x5e, 0xe8, 0xe3, 0xce, 0x7b, 0xe, 0x9c, 0xee, 0x6e, + 0xad, 0x3b, 0xd1, 0xf6, 0x99, 0xb1, 0x88, 0x1d, 0xec, 0x8e, 0xdc, 0xd9}; + uint8_t bytesprops2[] = {0x1d, 0x48, 0x72, 0xd9, 0x3, 0xd3, 0xe3, 0xe5, 0xc5, 0x53, 0x67, 0x81, 0x3f, 0xc3, 0x44}; + uint8_t bytesprops3[] = {0x70, 0x5a, 0x69, 0x9d, 0x8a, 0xb7, 0x24, 0x4a, 0x37, 0x96, 0x59, 0x3c, 0xe6, 0x20, + 0xdc, 0xb6, 0x96, 0x67, 0x15, 0xef, 0x41, 0xa5, 0x67, 0xde, 0xfa, 0xe, 0x43}; + uint8_t bytesprops4[] = {0xdc, 0xbb, 0x1, 0x27, 0x1f, 0xac, 0x48, 0x4c, 0x12, 0xe2, 0x7a, 0x3d, 0x3b, 0x24, + 0x9d, 0x66, 0xa1, 0xed, 0xbe, 0x18, 0xba, 0x25, 0xfe, 0x25, 0x55, 0xcd, 0xfa}; + uint8_t bytesprops5[] = {0xea}; + uint8_t bytesprops6[] = {0xb3, 0xf2, 0xd3, 0xfa, 0xc3}; + uint8_t bytesprops7[] = {0xb8, 0x87, 0x75, 0xde, 0x67, 0x47, 0xde, 0x76, 0x9e}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 241}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8978}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26125}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27481, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12264, 8, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32387 -// [("\205Yv\244\133\240o\244\240\227\&6\170r\201\GS\177\160\165\236\219\187K\FS\205\151\152",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\164\170z",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, -// _subQoS = QoS1})] [PropContentType -// "\180\152w\228\156\212\184=\145}\222\233e\NAK\147\246\178;\EOT\v>ADt\176\130\244\151g\166",PropRequestResponseInformation -// 80,PropSharedSubscriptionAvailable 77,PropMessageExpiryInterval 13371,PropTopicAliasMaximum -// 31269,PropResponseInformation "\\\248\"\136|\205\SOH\199\t\EM,\f\130\150\145\NUL\209\197[Or",PropServerKeepAlive -// 27813,PropMessageExpiryInterval 4055,PropResponseInformation "\206\154\235\a",PropMaximumPacketSize -// 22528,PropAuthenticationData "\249\178\159\175\&8W\220ZP\135\135\145\ESC\154\180qm\215",PropRequestProblemInformation -// 145,PropAuthenticationData "",PropWildcardSubscriptionAvailable 69,PropSubscriptionIdentifier -// 16,PropResponseInformation "\187\139\137",PropContentType "\DEL\240\137",PropAssignedClientIdentifier -// "\246;O\145\161\200\SOY6\186\246\155\v\US0\229Z&\131\202\220\175v\142\132c\ESC\220\167&",PropSessionExpiryInterval -// 27386,PropWildcardSubscriptionAvailable 84,PropReceiveMaximum 20115,PropMaximumPacketSize -// 27201,PropWildcardSubscriptionAvailable 252,PropSessionExpiryInterval 21491,PropRetainAvailable -// 238,PropMessageExpiryInterval 11536,PropWildcardSubscriptionAvailable 92,PropRequestResponseInformation -// 103,PropAuthenticationData -// "\198\183\ACKLl\180H\200\194\209\200)\252\149!\195\199\156\226\191x\218{\250\SOH\235\254\226\158"] -TEST(Subscribe5QCTest, Encode15) { - uint8_t pkt[] = {0x82, 0x8c, 0x2, 0x7e, 0x83, 0xe5, 0x1, 0x3, 0x0, 0x1e, 0xb4, 0x98, 0x77, 0xe4, 0x9c, 0xd4, 0xb8, - 0x3d, 0x91, 0x7d, 0xde, 0xe9, 0x65, 0x15, 0x93, 0xf6, 0xb2, 0x3b, 0x4, 0xb, 0x3e, 0x41, 0x44, 0x74, - 0xb0, 0x82, 0xf4, 0x97, 0x67, 0xa6, 0x19, 0x50, 0x2a, 0x4d, 0x2, 0x0, 0x0, 0x34, 0x3b, 0x22, 0x7a, - 0x25, 0x1a, 0x0, 0x15, 0x5c, 0xf8, 0x22, 0x88, 0x7c, 0xcd, 0x1, 0xc7, 0x9, 0x19, 0x2c, 0xc, 0x82, - 0x96, 0x91, 0x0, 0xd1, 0xc5, 0x5b, 0x4f, 0x72, 0x13, 0x6c, 0xa5, 0x2, 0x0, 0x0, 0xf, 0xd7, 0x1a, - 0x0, 0x4, 0xce, 0x9a, 0xeb, 0x7, 0x27, 0x0, 0x0, 0x58, 0x0, 0x16, 0x0, 0x12, 0xf9, 0xb2, 0x9f, - 0xaf, 0x38, 0x57, 0xdc, 0x5a, 0x50, 0x87, 0x87, 0x91, 0x1b, 0x9a, 0xb4, 0x71, 0x6d, 0xd7, 0x17, 0x91, - 0x16, 0x0, 0x0, 0x28, 0x45, 0xb, 0x10, 0x1a, 0x0, 0x3, 0xbb, 0x8b, 0x89, 0x3, 0x0, 0x3, 0x7f, - 0xf0, 0x89, 0x12, 0x0, 0x1e, 0xf6, 0x3b, 0x4f, 0x91, 0xa1, 0xc8, 0xe, 0x59, 0x36, 0xba, 0xf6, 0x9b, - 0xb, 0x1f, 0x30, 0xe5, 0x5a, 0x26, 0x83, 0xca, 0xdc, 0xaf, 0x76, 0x8e, 0x84, 0x63, 0x1b, 0xdc, 0xa7, - 0x26, 0x11, 0x0, 0x0, 0x6a, 0xfa, 0x28, 0x54, 0x21, 0x4e, 0x93, 0x27, 0x0, 0x0, 0x6a, 0x41, 0x28, - 0xfc, 0x11, 0x0, 0x0, 0x53, 0xf3, 0x25, 0xee, 0x2, 0x0, 0x0, 0x2d, 0x10, 0x28, 0x5c, 0x19, 0x67, - 0x16, 0x0, 0x1d, 0xc6, 0xb7, 0x6, 0x4c, 0x6c, 0xb4, 0x48, 0xc8, 0xc2, 0xd1, 0xc8, 0x29, 0xfc, 0x95, - 0x21, 0xc3, 0xc7, 0x9c, 0xe2, 0xbf, 0x78, 0xda, 0x7b, 0xfa, 0x1, 0xeb, 0xfe, 0xe2, 0x9e, 0x0, 0x1a, - 0xcd, 0x59, 0x76, 0xf4, 0x85, 0xf0, 0x6f, 0xf4, 0xf0, 0xe3, 0x36, 0xaa, 0x72, 0xc9, 0x1d, 0xb1, 0xa0, - 0xa5, 0xec, 0xdb, 0xbb, 0x4b, 0x1c, 0xcd, 0x97, 0x98, 0x14, 0x0, 0x3, 0xa4, 0xaa, 0x7a, 0x19}; +// SubscribeRequest 23519 [("R\219\&9\207\231\198)2}\160",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\229\250\209",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("P\243-\232\133v`;l\157\243\238\130\251x\239\172\210\144\US2\251@h\138\228Mt\140",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\n\133g\194",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("y\239\128\199)K\206~\242\246\SO*Anb2&\190\169#b",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\tz\SI\249\US2%R\176\a\163Kn\141\187\198\211x\246)]",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropAssignedClientIdentifier +// "\ESCd\175\ACK",PropSubscriptionIdentifierAvailable 53,PropMessageExpiryInterval 10167,PropUserProperty "" +// "\240\STX\237\185\239\171\252D\175%\214\231\&2\173$",PropServerKeepAlive 27442,PropServerReference +// ".\190\176F\ACK\"\181-\SYN\150\232O5\242\250\186\171\185EgGt",PropRequestResponseInformation 54,PropResponseTopic +// "\SIwVD\245\239",PropRequestResponseInformation 203,PropServerKeepAlive 27526,PropMessageExpiryInterval +// 14075,PropSharedSubscriptionAvailable 167,PropAuthenticationMethod +// "M\245V\212\136G\132\150\187\166\160hRZ$t%q.?Z\179",PropTopicAlias 8832,PropRequestResponseInformation +// 65,PropMessageExpiryInterval 13256,PropResponseTopic +// "\218\220\184s\219\206\151\169\208\231\131p\ENQ\RS\200\201\DC4\f\224\147\t\168"] +TEST(Subscribe5QCTest, Encode16) { + uint8_t pkt[] = { + 0x82, 0x82, 0x2, 0x5b, 0xdf, 0x91, 0x1, 0x12, 0x0, 0x4, 0x1b, 0x64, 0xaf, 0x6, 0x29, 0x35, 0x2, 0x0, 0x0, + 0x27, 0xb7, 0x26, 0x0, 0x0, 0x0, 0xf, 0xf0, 0x2, 0xed, 0xb9, 0xef, 0xab, 0xfc, 0x44, 0xaf, 0x25, 0xd6, 0xe7, + 0x32, 0xad, 0x24, 0x13, 0x6b, 0x32, 0x1c, 0x0, 0x16, 0x2e, 0xbe, 0xb0, 0x46, 0x6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x7a, 0xf, 0xf9, 0x1f, 0x32, 0x25, 0x52, + 0xb0, 0x7, 0xa3, 0x4b, 0x6e, 0x8d, 0xbb, 0xc6, 0xd3, 0x78, 0xf6, 0x29, 0x5d, 0x26}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xcd, 0x59, 0x76, 0xf4, 0x85, 0xf0, 0x6f, 0xf4, 0xf0, 0xe3, 0x36, 0xaa, 0x72, - 0xc9, 0x1d, 0xb1, 0xa0, 0xa5, 0xec, 0xdb, 0xbb, 0x4b, 0x1c, 0xcd, 0x97, 0x98}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x52, 0xdb, 0x39, 0xcf, 0xe7, 0xc6, 0x29, 0x32, 0x7d, 0xa0}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa4, 0xaa, 0x7a}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; + uint8_t topic_filter_s2_bytes[] = {0xe5, 0xfa, 0xd1}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x50, 0xf3, 0x2d, 0xe8, 0x85, 0x76, 0x60, 0x3b, 0x6c, 0x9d, + 0xf3, 0xee, 0x82, 0xfb, 0x78, 0xef, 0xac, 0xd2, 0x90, 0x1f, + 0x32, 0xfb, 0x40, 0x68, 0x8a, 0xe4, 0x4d, 0x74, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xa, 0x85, 0x67, 0xc2}; + lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x79, 0xef, 0x80, 0xc7, 0x29, 0x4b, 0xce, 0x7e, 0xf2, 0xf6, 0xe, + 0x2a, 0x41, 0x6e, 0x62, 0x32, 0x26, 0xbe, 0xa9, 0x23, 0x62}; + lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x9, 0x7a, 0xf, 0xf9, 0x1f, 0x32, 0x25, 0x52, 0xb0, 0x7, 0xa3, + 0x4b, 0x6e, 0x8d, 0xbb, 0xc6, 0xd3, 0x78, 0xf6, 0x29, 0x5d}; + lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; + sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - uint8_t bytesprops0[] = {0xb4, 0x98, 0x77, 0xe4, 0x9c, 0xd4, 0xb8, 0x3d, 0x91, 0x7d, 0xde, 0xe9, 0x65, 0x15, 0x93, - 0xf6, 0xb2, 0x3b, 0x4, 0xb, 0x3e, 0x41, 0x44, 0x74, 0xb0, 0x82, 0xf4, 0x97, 0x67, 0xa6}; - uint8_t bytesprops1[] = {0x5c, 0xf8, 0x22, 0x88, 0x7c, 0xcd, 0x1, 0xc7, 0x9, 0x19, 0x2c, - 0xc, 0x82, 0x96, 0x91, 0x0, 0xd1, 0xc5, 0x5b, 0x4f, 0x72}; - uint8_t bytesprops2[] = {0xce, 0x9a, 0xeb, 0x7}; - uint8_t bytesprops3[] = {0xf9, 0xb2, 0x9f, 0xaf, 0x38, 0x57, 0xdc, 0x5a, 0x50, - 0x87, 0x87, 0x91, 0x1b, 0x9a, 0xb4, 0x71, 0x6d, 0xd7}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0xbb, 0x8b, 0x89}; - uint8_t bytesprops6[] = {0x7f, 0xf0, 0x89}; - uint8_t bytesprops7[] = {0xf6, 0x3b, 0x4f, 0x91, 0xa1, 0xc8, 0xe, 0x59, 0x36, 0xba, 0xf6, 0x9b, 0xb, 0x1f, 0x30, - 0xe5, 0x5a, 0x26, 0x83, 0xca, 0xdc, 0xaf, 0x76, 0x8e, 0x84, 0x63, 0x1b, 0xdc, 0xa7, 0x26}; - uint8_t bytesprops8[] = {0xc6, 0xb7, 0x6, 0x4c, 0x6c, 0xb4, 0x48, 0xc8, 0xc2, 0xd1, 0xc8, 0x29, 0xfc, 0x95, 0x21, - 0xc3, 0xc7, 0x9c, 0xe2, 0xbf, 0x78, 0xda, 0x7b, 0xfa, 0x1, 0xeb, 0xfe, 0xe2, 0x9e}; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; + uint8_t bytesprops0[] = {0x1b, 0x64, 0xaf, 0x6}; + uint8_t bytesprops2[] = {0xf0, 0x2, 0xed, 0xb9, 0xef, 0xab, 0xfc, 0x44, 0xaf, 0x25, 0xd6, 0xe7, 0x32, 0xad, 0x24}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops3[] = {0x2e, 0xbe, 0xb0, 0x46, 0x6, 0x22, 0xb5, 0x2d, 0x16, 0x96, 0xe8, + 0x4f, 0x35, 0xf2, 0xfa, 0xba, 0xab, 0xb9, 0x45, 0x67, 0x47, 0x74}; + uint8_t bytesprops4[] = {0xf, 0x77, 0x56, 0x44, 0xf5, 0xef}; + uint8_t bytesprops5[] = {0x4d, 0xf5, 0x56, 0xd4, 0x88, 0x47, 0x84, 0x96, 0xbb, 0xa6, 0xa0, + 0x68, 0x52, 0x5a, 0x24, 0x74, 0x25, 0x71, 0x2e, 0x3f, 0x5a, 0xb3}; + uint8_t bytesprops6[] = {0xda, 0xdc, 0xb8, 0x73, 0xdb, 0xce, 0x97, 0xa9, 0xd0, 0xe7, 0x83, + 0x70, 0x5, 0x1e, 0xc8, 0xc9, 0x14, 0xc, 0xe0, 0x93, 0x9, 0xa8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13371}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31269}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27813}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4055}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22528}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27386}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20115}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27201}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21491}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11536}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10167}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops1}, .v = {15, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27442}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27526}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14075}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8832}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13256}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32387, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23519, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 27695 [("\244savN\237\&9\ETB\SUB\239C\CAN\184a\157b\NUL\151u\142\230\r",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("D\153\DC2\SOH",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\SYN\139\192\ETB\205fr\136\n\229V\162C\DC3\130\ENQ\DC1\228\179\196C\192\RS\DEL",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\149\140\bL\128\SI\252T",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\164\138\235VW\242\242\a\134\243\168\215tQK\DLE\179\202\207\250A\EM\226\174]\a",SubOptions {_retainHandling -// = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("!W\178\139't\202\166K\r\223\151",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// True, _noLocal = False, _subQoS = QoS2}),("\180\239\139\STX\NULd",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\133\235X3\227\134\248\236\248\231",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\170\153\226",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS1})] [PropWildcardSubscriptionAvailable 234,PropReceiveMaximum 14285,PropResponseTopic -// "\172\210\DC2V\192\181\r\246 \134\220\223\158g\ESC\253[\177A\159;",PropAuthenticationMethod -// "I\179\204z]\EMI\129}T<\198",PropCorrelationData -// "\227\228\229\232\195\192)\252o;\166u\160\155\GS\199*\184Z\ENQ\151x",PropReceiveMaximum -// 19610,PropMessageExpiryInterval 13043,PropServerKeepAlive 8811,PropReasonString -// "\184\203\209\211\252\175\\\198\165\234\b\131\NAK)\208z2\214M]\132",PropAssignedClientIdentifier -// "o\244$c\DLET\ENQ\190\188n\232\222\DC4\181\189y\211\208 \211\163\130\193\212V\178\139s",PropUserProperty -// "\128\156T\160\146\244;\154\a~\135\201K\128\253\169{e\175\ACK" "o8\153\tujsS#\162~",PropUserProperty -// "y\188\150\225\160Q\214\228\189,C" "\170\215`\226\186\ENQ\156\"z\190O%\182\&7{9z\218>"] -TEST(Subscribe5QCTest, Encode16) { +// SubscribeRequest 29383 [(",\NAK\169\178hV\136\f\td\219\232\130\128\161",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("x\r\128\171A\130\134\&6\DC1oU\179\212\t~\136\247\SO3",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),(")o=\233\v\SOH\204,\183\ESCkM^\133\224\&5\200H",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\210\198\219\203\239\165d<\213b\DC4UR\142\235\248\NULp\131\235\184\147\223kF\157\137\150\218\b",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("mm\223\&8\CAN\fO\no",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal +// = True, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\192\143D`V'\SYNt\SI\233\133\&5\248\252\145\247C\130\192\218\SUBo",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\173\253\163N\216\207\129+_ \235e2\r5}\146",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\223\ETX\244nSoNK",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("/\239uT\EOT",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("f\241DK\SUB\ETB\DLEfe[\RS\CAN\222\ESCp\230Z\232v9e\246",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropResponseTopic +// "&.J\226+",PropRequestProblemInformation 153,PropWillDelayInterval 31281,PropRequestProblemInformation 220] +TEST(Subscribe5QCTest, Encode17) { uint8_t pkt[] = { - 0x82, 0xe0, 0x2, 0x6c, 0x2f, 0xce, 0x1, 0x28, 0xea, 0x21, 0x37, 0xcd, 0x8, 0x0, 0x15, 0xac, 0xd2, 0x12, 0x56, - 0xc0, 0xb5, 0xd, 0xf6, 0x20, 0x86, 0xdc, 0xdf, 0x9e, 0x67, 0x1b, 0xfd, 0x5b, 0xb1, 0x41, 0x9f, 0x3b, 0x15, 0x0, - 0xc, 0x49, 0xb3, 0xcc, 0x7a, 0x5d, 0x19, 0x49, 0x81, 0x7d, 0x54, 0x3c, 0xc6, 0x9, 0x0, 0x16, 0xe3, 0xe4, 0xe5, - 0xe8, 0xc3, 0xc0, 0x29, 0xfc, 0x6f, 0x3b, 0xa6, 0x75, 0xa0, 0x9b, 0x1d, 0xc7, 0x2a, 0xb8, 0x5a, 0x5, 0x97, 0x78, - 0x21, 0x4c, 0x9a, 0x2, 0x0, 0x0, 0x32, 0xf3, 0x13, 0x22, 0x6b, 0x1f, 0x0, 0x15, 0xb8, 0xcb, 0xd1, 0xd3, 0xfc, - 0xaf, 0x5c, 0xc6, 0xa5, 0xea, 0x8, 0x83, 0x15, 0x29, 0xd0, 0x7a, 0x32, 0xd6, 0x4d, 0x5d, 0x84, 0x12, 0x0, 0x1c, - 0x6f, 0xf4, 0x24, 0x63, 0x10, 0x54, 0x5, 0xbe, 0xbc, 0x6e, 0xe8, 0xde, 0x14, 0xb5, 0xbd, 0x79, 0xd3, 0xd0, 0x20, - 0xd3, 0xa3, 0x82, 0xc1, 0xd4, 0x56, 0xb2, 0x8b, 0x73, 0x26, 0x0, 0x14, 0x80, 0x9c, 0x54, 0xa0, 0x92, 0xf4, 0x3b, - 0x9a, 0x7, 0x7e, 0x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0xd, 0x0, 0x8, 0xdf, 0x3, 0xf4, 0x6e, 0x53, 0x6f, 0x4e, 0x4b, 0x1d, 0x0, 0x5, + 0x2f, 0xef, 0x75, 0x54, 0x4, 0x11, 0x0, 0x16, 0x66, 0xf1, 0x44, 0x4b, 0x1a, 0x17, 0x10, 0x66, 0x65, 0x5b, 0x1e, + 0x18, 0xde, 0x1b, 0x70, 0xe6, 0x5a, 0xe8, 0x76, 0x39, 0x65, 0xf6, 0x2d}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0xf4, 0x73, 0x61, 0x76, 0x4e, 0xed, 0x39, 0x17, 0x1a, 0xef, 0x43, - 0x18, 0xb8, 0x61, 0x9d, 0x62, 0x0, 0x97, 0x75, 0x8e, 0xe6, 0xd}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x2c, 0x15, 0xa9, 0xb2, 0x68, 0x56, 0x88, 0xc, + 0x9, 0x64, 0xdb, 0xe8, 0x82, 0x80, 0xa1}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x44, 0x99, 0x12, 0x1}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x78, 0xd, 0x80, 0xab, 0x41, 0x82, 0x86, 0x36, 0x11, 0x6f, + 0x55, 0xb3, 0xd4, 0x9, 0x7e, 0x88, 0xf7, 0xe, 0x33}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x16, 0x8b, 0xc0, 0x17, 0xcd, 0x66, 0x72, 0x88, 0xa, 0xe5, 0x56, 0xa2, - 0x43, 0x13, 0x82, 0x5, 0x11, 0xe4, 0xb3, 0xc4, 0x43, 0xc0, 0x1e, 0x7f}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x29, 0x6f, 0x3d, 0xe9, 0xb, 0x1, 0xcc, 0x2c, 0xb7, + 0x1b, 0x6b, 0x4d, 0x5e, 0x85, 0xe0, 0x35, 0xc8, 0x48}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x95, 0x8c, 0x8, 0x4c, 0x80, 0xf, 0xfc, 0x54}; - lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd2, 0xc6, 0xdb, 0xcb, 0xef, 0xa5, 0x64, 0x3c, 0xd5, 0x62, + 0x14, 0x55, 0x52, 0x8e, 0xeb, 0xf8, 0x0, 0x70, 0x83, 0xeb, + 0xb8, 0x93, 0xdf, 0x6b, 0x46, 0x9d, 0x89, 0x96, 0xda, 0x8}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa4, 0x8a, 0xeb, 0x56, 0x57, 0xf2, 0xf2, 0x7, 0x86, 0xf3, 0xa8, 0xd7, 0x74, - 0x51, 0x4b, 0x10, 0xb3, 0xca, 0xcf, 0xfa, 0x41, 0x19, 0xe2, 0xae, 0x5d, 0x7}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x6d, 0x6d, 0xdf, 0x38, 0x18, 0xc, 0x4f, 0xa, 0x6f}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x21, 0x57, 0xb2, 0x8b, 0x27, 0x74, 0xca, 0xa6, 0x4b, 0xd, 0xdf, 0x97}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb4, 0xef, 0x8b, 0x2, 0x0, 0x64}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xc0, 0x8f, 0x44, 0x60, 0x56, 0x27, 0x16, 0x74, 0xf, 0xe9, 0x85, + 0x35, 0xf8, 0xfc, 0x91, 0xf7, 0x43, 0x82, 0xc0, 0xda, 0x1a, 0x6f}; + lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x85, 0xeb, 0x58, 0x33, 0xe3, 0x86, 0xf8, 0xec, 0xf8, 0xe7}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xad, 0xfd, 0xa3, 0x4e, 0xd8, 0xcf, 0x81, 0x2b, 0x5f, + 0x20, 0xeb, 0x65, 0x32, 0xd, 0x35, 0x7d, 0x92}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xaa, 0x99, 0xe2}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xdf, 0x3, 0xf4, 0x6e, 0x53, 0x6f, 0x4e, 0x4b}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; + uint8_t topic_filter_s9_bytes[] = {0x2f, 0xef, 0x75, 0x54, 0x4}; + lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x66, 0xf1, 0x44, 0x4b, 0x1a, 0x17, 0x10, 0x66, 0x65, 0x5b, 0x1e, + 0x18, 0xde, 0x1b, 0x70, 0xe6, 0x5a, 0xe8, 0x76, 0x39, 0x65, 0xf6}; + lwmqtt_string_t topic_filter_s10 = {22, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = true; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = true; sub_opts[7].no_local = true; sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[8].retain_as_published = true; sub_opts[8].no_local = true; - uint8_t bytesprops0[] = {0xac, 0xd2, 0x12, 0x56, 0xc0, 0xb5, 0xd, 0xf6, 0x20, 0x86, 0xdc, - 0xdf, 0x9e, 0x67, 0x1b, 0xfd, 0x5b, 0xb1, 0x41, 0x9f, 0x3b}; - uint8_t bytesprops1[] = {0x49, 0xb3, 0xcc, 0x7a, 0x5d, 0x19, 0x49, 0x81, 0x7d, 0x54, 0x3c, 0xc6}; - uint8_t bytesprops2[] = {0xe3, 0xe4, 0xe5, 0xe8, 0xc3, 0xc0, 0x29, 0xfc, 0x6f, 0x3b, 0xa6, - 0x75, 0xa0, 0x9b, 0x1d, 0xc7, 0x2a, 0xb8, 0x5a, 0x5, 0x97, 0x78}; - uint8_t bytesprops3[] = {0xb8, 0xcb, 0xd1, 0xd3, 0xfc, 0xaf, 0x5c, 0xc6, 0xa5, 0xea, 0x8, - 0x83, 0x15, 0x29, 0xd0, 0x7a, 0x32, 0xd6, 0x4d, 0x5d, 0x84}; - uint8_t bytesprops4[] = {0x6f, 0xf4, 0x24, 0x63, 0x10, 0x54, 0x5, 0xbe, 0xbc, 0x6e, 0xe8, 0xde, 0x14, 0xb5, - 0xbd, 0x79, 0xd3, 0xd0, 0x20, 0xd3, 0xa3, 0x82, 0xc1, 0xd4, 0x56, 0xb2, 0x8b, 0x73}; - uint8_t bytesprops6[] = {0x6f, 0x38, 0x99, 0x9, 0x75, 0x6a, 0x73, 0x53, 0x23, 0xa2, 0x7e}; - uint8_t bytesprops5[] = {0x80, 0x9c, 0x54, 0xa0, 0x92, 0xf4, 0x3b, 0x9a, 0x7, 0x7e, - 0x87, 0xc9, 0x4b, 0x80, 0xfd, 0xa9, 0x7b, 0x65, 0xaf, 0x6}; - uint8_t bytesprops8[] = {0xaa, 0xd7, 0x60, 0xe2, 0xba, 0x5, 0x9c, 0x22, 0x7a, 0xbe, - 0x4f, 0x25, 0xb6, 0x37, 0x7b, 0x39, 0x7a, 0xda, 0x3e}; - uint8_t bytesprops7[] = {0x79, 0xbc, 0x96, 0xe1, 0xa0, 0x51, 0xd6, 0xe4, 0xbd, 0x2c, 0x43}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14285}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19610}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13043}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8811}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops5}, .v = {11, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops7}, .v = {19, (char*)&bytesprops8}}}}, - }; - - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27695, 9, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 29411 [(")\137\189d\189&\250#\214n1\GS\218A\245\158\136\t;\247\175:A\180\233",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\209\DLEs\183`\203\204*\136K\202\223k",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished -// = True, _noLocal = True, _subQoS = -// QoS2}),("\214?\172zE\154=\DLE\186u!\132\140a\183\249\&3\189\186)\139\SUB",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropSharedSubscriptionAvailable -// 165,PropRequestResponseInformation 235,PropAuthenticationMethod -// "\DC2\t\188\157&$\245\GSX\196zgV\211\138q\208\196>\DLE\232\198f\166\224\223",PropAssignedClientIdentifier -// "EH",PropRetainAvailable 186,PropMessageExpiryInterval 4196,PropMessageExpiryInterval -// 5834,PropRequestResponseInformation 226,PropRequestProblemInformation 73,PropContentType "<",PropRetainAvailable -// 62,PropCorrelationData "2\ESC\245\&0",PropWildcardSubscriptionAvailable 39,PropRetainAvailable -// 243,PropCorrelationData ":\150\175\195\204\EOT\133\245\202\NUL\160\240_\NUL\219\251<\228",PropAuthenticationData -// "\245\EM\159B\215\228\255\166@4B?*'|G\143"] -TEST(Subscribe5QCTest, Encode17) { - uint8_t pkt[] = { - 0x82, 0xb8, 0x1, 0x72, 0xe3, 0x70, 0x2a, 0xa5, 0x19, 0xeb, 0x15, 0x0, 0x1a, 0x12, 0x9, 0xbc, 0x9d, 0x26, 0x24, - 0xf5, 0x1d, 0x58, 0xc4, 0x7a, 0x67, 0x56, 0xd3, 0x8a, 0x71, 0xd0, 0xc4, 0x3e, 0x10, 0xe8, 0xc6, 0x66, 0xa6, 0xe0, - 0xdf, 0x12, 0x0, 0x2, 0x45, 0x48, 0x25, 0xba, 0x2, 0x0, 0x0, 0x10, 0x64, 0x2, 0x0, 0x0, 0x16, 0xca, 0x19, - 0xe2, 0x17, 0x49, 0x3, 0x0, 0x1, 0x3c, 0x25, 0x3e, 0x9, 0x0, 0x4, 0x32, 0x1b, 0xf5, 0x30, 0x28, 0x27, 0x25, - 0xf3, 0x9, 0x0, 0x12, 0x3a, 0x96, 0xaf, 0xc3, 0xcc, 0x4, 0x85, 0xf5, 0xca, 0x0, 0xa0, 0xf0, 0x5f, 0x0, 0xdb, - 0xfb, 0x3c, 0xe4, 0x16, 0x0, 0x11, 0xf5, 0x19, 0x9f, 0x42, 0xd7, 0xe4, 0xff, 0xa6, 0x40, 0x34, 0x42, 0x3f, 0x2a, - 0x27, 0x7c, 0x47, 0x8f, 0x0, 0x19, 0x29, 0x89, 0xbd, 0x64, 0xbd, 0x26, 0xfa, 0x23, 0xd6, 0x6e, 0x31, 0x1d, 0xda, - 0x41, 0xf5, 0x9e, 0x88, 0x9, 0x3b, 0xf7, 0xaf, 0x3a, 0x41, 0xb4, 0xe9, 0x16, 0x0, 0xd, 0xd1, 0x10, 0x73, 0xb7, - 0x60, 0xcb, 0xcc, 0x2a, 0x88, 0x4b, 0xca, 0xdf, 0x6b, 0x1e, 0x0, 0x16, 0xd6, 0x3f, 0xac, 0x7a, 0x45, 0x9a, 0x3d, - 0x10, 0xba, 0x75, 0x21, 0x84, 0x8c, 0x61, 0xb7, 0xf9, 0x33, 0xbd, 0xba, 0x29, 0x8b, 0x1a, 0x1d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0x29, 0x89, 0xbd, 0x64, 0xbd, 0x26, 0xfa, 0x23, 0xd6, 0x6e, 0x31, 0x1d, 0xda, - 0x41, 0xf5, 0x9e, 0x88, 0x9, 0x3b, 0xf7, 0xaf, 0x3a, 0x41, 0xb4, 0xe9}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd1, 0x10, 0x73, 0xb7, 0x60, 0xcb, 0xcc, 0x2a, 0x88, 0x4b, 0xca, 0xdf, 0x6b}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd6, 0x3f, 0xac, 0x7a, 0x45, 0x9a, 0x3d, 0x10, 0xba, 0x75, 0x21, - 0x84, 0x8c, 0x61, 0xb7, 0xf9, 0x33, 0xbd, 0xba, 0x29, 0x8b, 0x1a}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = true; - uint8_t bytesprops0[] = {0x12, 0x9, 0xbc, 0x9d, 0x26, 0x24, 0xf5, 0x1d, 0x58, 0xc4, 0x7a, 0x67, 0x56, - 0xd3, 0x8a, 0x71, 0xd0, 0xc4, 0x3e, 0x10, 0xe8, 0xc6, 0x66, 0xa6, 0xe0, 0xdf}; - uint8_t bytesprops1[] = {0x45, 0x48}; - uint8_t bytesprops2[] = {0x3c}; - uint8_t bytesprops3[] = {0x32, 0x1b, 0xf5, 0x30}; - uint8_t bytesprops4[] = {0x3a, 0x96, 0xaf, 0xc3, 0xcc, 0x4, 0x85, 0xf5, 0xca, - 0x0, 0xa0, 0xf0, 0x5f, 0x0, 0xdb, 0xfb, 0x3c, 0xe4}; - uint8_t bytesprops5[] = {0xf5, 0x19, 0x9f, 0x42, 0xd7, 0xe4, 0xff, 0xa6, 0x40, - 0x34, 0x42, 0x3f, 0x2a, 0x27, 0x7c, 0x47, 0x8f}; + sub_opts[9].qos = LWMQTT_QOS1; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS1; + sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = true; + uint8_t bytesprops0[] = {0x26, 0x2e, 0x4a, 0xe2, 0x2b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4196}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5834}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31281}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29411, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29383, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22557 [("#\164A\r\139\STX;\197\SIwh\SYN\201\230\252\196\208K",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\137\185l\EOT\205\r\219\t.\239j\181j,*k\255\SO}L",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("d\196T\247\DC4\198\165\SUB1\a\181\255",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\ACK\155R\SYN\217\207\&3\145V\215ws\192\177\184S",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("#\161\214\195\f@H\130\av\155\169\241\157\251\196\231\233\135V\142",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("/\172\STX\DC2\"`\224+\179{\129\239\180\165\221\248\189\133",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\169\228LZ\199^-&\NAKA\f\129\251\EOT]\FS\185h\190Zn6\252\DLE\187\153\170d\148",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\251\166\176\214=\STX\232\&4\248\r\254\\\184(\142\213\SO\140L\217\DC4\221y\202\169\138\206\145\182\192",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\170*\229'\207\130\193\237\139\159>\223\200\200\153\SOH\132\208\190\DC2\153\190\213O\190\DLE.\\y",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] -// [PropCorrelationData "\219\232\\\149f\b\DLE\248\250\168O\137Z\145\179\NULo\131\221",PropMaximumQoS -// 52,PropReasonString "n\SUB\132\189\253\138\247t",PropTopicAlias 31150,PropServerReference -// "\149w\214w\141\f\DC3\216\f\163\133\198^g\164\255\207\r\188a\201",PropReceiveMaximum 12814,PropServerReference -// ")\241C38s\146\152\ESCu\195\201\FS",PropAssignedClientIdentifier "\225",PropReceiveMaximum 26923,PropServerKeepAlive -// 21509,PropAuthenticationData -// "\\\228>xr[\227\207\154\DC3z\ETX\SYN\FSnw\163\195\139\240+&\168k\180\128",PropSharedSubscriptionAvailable -// 181,PropSharedSubscriptionAvailable 46,PropAssignedClientIdentifier -// "\DC3\218\251\245a\157\158\192\250\193?/\143\183P\180\189\ACK\146\250_",PropAuthenticationData -// "\172-jq\222\188^4\250\241\161\EM\133\189\245\142\228\148\216\238Q\179\SO\134&6?\ETB]\244",PropRetainAvailable -// 16,PropSharedSubscriptionAvailable 13,PropReceiveMaximum 25304,PropMessageExpiryInterval 30495,PropServerReference -// "yH\210U\184\&6\GS\a\131\148\&1",PropReceiveMaximum 2552,PropSessionExpiryInterval 29036,PropSessionExpiryInterval -// 17544,PropSubscriptionIdentifier 28,PropAuthenticationMethod -// "?\187\128M\206f\225\177G\175AJ0\156\185\219h\219\231\&5\138on\248\157"] +// SubscribeRequest 22596 [("Z\234}C\SUB\171\&5&\204(&\179-\EOTJ4Z\158^\r/\210",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\155\DLE\244\181\FSv!R\140\a\235\ENQ\187D\133;",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\247\DC267\FS'\131\SI\183\GS(6\151",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("-F\209r\195e^\215\133\254\177R\253\173\165\FS\DLE?\DC3\203Qm\153\228 4\EM\156\228",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("*\206\rj\188y\249\188o\SI\163Sfn\ENQ:II3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS1}),("\177B:\171\142\240\238\222",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropMaximumPacketSize +// 14660,PropUserProperty "\168q\218\252\245\145\&6)\201qf\150\RS\EOT\185v\EOT\209\&2" +// "\209_\132\197]J\t\144?\157\192\219\200##2",PropRetainAvailable 205,PropTopicAliasMaximum +// 27309,PropMessageExpiryInterval 18006,PropSessionExpiryInterval 32484,PropCorrelationData +// "{e\150w\178\ENQ",PropServerReference "\170\158E\aB\211D\171M",PropServerReference +// "]\178\135\US\146\241\227\169\&5@\214\197\252\ESC\140MP\211",PropMessageExpiryInterval 27729,PropMaximumPacketSize +// 31247,PropSharedSubscriptionAvailable 63,PropSubscriptionIdentifier 23,PropSessionExpiryInterval +// 15648,PropRequestProblemInformation 36,PropServerReference +// "\202\229\162\218\NAK\NAK\\\n\DC2\f\217",PropSharedSubscriptionAvailable 93,PropMessageExpiryInterval +// 26613,PropMaximumPacketSize 2627,PropContentType "\DC4\178N\138\225\160",PropPayloadFormatIndicator +// 111,PropReasonString "\215\140\212\192\228\DC3\192\191K\n\221T\129;\169\RS\224",PropRequestProblemInformation +// 176,PropRequestProblemInformation 49,PropResponseTopic "",PropServerKeepAlive 17214,PropSubscriptionIdentifier +// 23,PropSubscriptionIdentifier 27,PropRequestProblemInformation 187,PropCorrelationData "\215iw\146\242x\202\184Q"] TEST(Subscribe5QCTest, Encode18) { uint8_t pkt[] = { - 0x82, 0xda, 0x3, 0x58, 0x1d, 0xfa, 0x1, 0x9, 0x0, 0x13, 0xdb, 0xe8, 0x5c, 0x95, 0x66, 0x8, 0x10, 0xf8, 0xfa, - 0xa8, 0x4f, 0x89, 0x5a, 0x91, 0xb3, 0x0, 0x6f, 0x83, 0xdd, 0x24, 0x34, 0x1f, 0x0, 0x8, 0x6e, 0x1a, 0x84, 0xbd, - 0xfd, 0x8a, 0xf7, 0x74, 0x23, 0x79, 0xae, 0x1c, 0x0, 0x15, 0x95, 0x77, 0xd6, 0x77, 0x8d, 0xc, 0x13, 0xd8, 0xc, - 0xa3, 0x85, 0xc6, 0x5e, 0x67, 0xa4, 0xff, 0xcf, 0xd, 0xbc, 0x61, 0xc9, 0x21, 0x32,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, 0xf0, 0xee, 0xde, 0x26}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x23, 0xa4, 0x41, 0xd, 0x8b, 0x2, 0x3b, 0xc5, 0xf, - 0x77, 0x68, 0x16, 0xc9, 0xe6, 0xfc, 0xc4, 0xd0, 0x4b}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x5a, 0xea, 0x7d, 0x43, 0x1a, 0xab, 0x35, 0x26, 0xcc, 0x28, 0x26, + 0xb3, 0x2d, 0x4, 0x4a, 0x34, 0x5a, 0x9e, 0x5e, 0xd, 0x2f, 0xd2}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x89, 0xb9, 0x6c, 0x4, 0xcd, 0xd, 0xdb, 0x9, 0x2e, 0xef, - 0x6a, 0xb5, 0x6a, 0x2c, 0x2a, 0x6b, 0xff, 0xe, 0x7d, 0x4c}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9b, 0x10, 0xf4, 0xb5, 0x1c, 0x76, 0x21, 0x52, + 0x8c, 0x7, 0xeb, 0x5, 0xbb, 0x44, 0x85, 0x3b}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x64, 0xc4, 0x54, 0xf7, 0x14, 0xc6, 0xa5, 0x1a, 0x31, 0x7, 0xb5, 0xff}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xf7, 0x12, 0x36, 0x37, 0x1c, 0x27, 0x83, 0xf, 0xb7, 0x1d, 0x28, 0x36, 0x97}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6, 0x9b, 0x52, 0x16, 0xd9, 0xcf, 0x33, 0x91, - 0x56, 0xd7, 0x77, 0x73, 0xc0, 0xb1, 0xb8, 0x53}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x2d, 0x46, 0xd1, 0x72, 0xc3, 0x65, 0x5e, 0xd7, 0x85, 0xfe, + 0xb1, 0x52, 0xfd, 0xad, 0xa5, 0x1c, 0x10, 0x3f, 0x13, 0xcb, + 0x51, 0x6d, 0x99, 0xe4, 0x20, 0x34, 0x19, 0x9c, 0xe4}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x23, 0xa1, 0xd6, 0xc3, 0xc, 0x40, 0x48, 0x82, 0x7, 0x76, 0x9b, - 0xa9, 0xf1, 0x9d, 0xfb, 0xc4, 0xe7, 0xe9, 0x87, 0x56, 0x8e}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x2a, 0xce, 0xd, 0x6a, 0xbc, 0x79, 0xf9, 0xbc, 0x6f, 0xf, + 0xa3, 0x53, 0x66, 0x6e, 0x5, 0x3a, 0x49, 0x49, 0x33}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x2f, 0xac, 0x2, 0x12, 0x22, 0x60, 0xe0, 0x2b, 0xb3, - 0x7b, 0x81, 0xef, 0xb4, 0xa5, 0xdd, 0xf8, 0xbd, 0x85}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xb1, 0x42, 0x3a, 0xab, 0x8e, 0xf0, 0xee, 0xde}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa9, 0xe4, 0x4c, 0x5a, 0xc7, 0x5e, 0x2d, 0x26, 0x15, 0x41, - 0xc, 0x81, 0xfb, 0x4, 0x5d, 0x1c, 0xb9, 0x68, 0xbe, 0x5a, - 0x6e, 0x36, 0xfc, 0x10, 0xbb, 0x99, 0xaa, 0x64, 0x94}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xfb, 0xa6, 0xb0, 0xd6, 0x3d, 0x2, 0xe8, 0x34, 0xf8, 0xd, - 0xfe, 0x5c, 0xb8, 0x28, 0x8e, 0xd5, 0xe, 0x8c, 0x4c, 0xd9, - 0x14, 0xdd, 0x79, 0xca, 0xa9, 0x8a, 0xce, 0x91, 0xb6, 0xc0}; - lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xaa, 0x2a, 0xe5, 0x27, 0xcf, 0x82, 0xc1, 0xed, 0x8b, 0x9f, - 0x3e, 0xdf, 0xc8, 0xc8, 0x99, 0x1, 0x84, 0xd0, 0xbe, 0x12, - 0x99, 0xbe, 0xd5, 0x4f, 0xbe, 0x10, 0x2e, 0x5c, 0x79}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; + sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; + sub_opts[3].no_local = false; sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = true; - uint8_t bytesprops0[] = {0xdb, 0xe8, 0x5c, 0x95, 0x66, 0x8, 0x10, 0xf8, 0xfa, 0xa8, - 0x4f, 0x89, 0x5a, 0x91, 0xb3, 0x0, 0x6f, 0x83, 0xdd}; - uint8_t bytesprops1[] = {0x6e, 0x1a, 0x84, 0xbd, 0xfd, 0x8a, 0xf7, 0x74}; - uint8_t bytesprops2[] = {0x95, 0x77, 0xd6, 0x77, 0x8d, 0xc, 0x13, 0xd8, 0xc, 0xa3, 0x85, - 0xc6, 0x5e, 0x67, 0xa4, 0xff, 0xcf, 0xd, 0xbc, 0x61, 0xc9}; - uint8_t bytesprops3[] = {0x29, 0xf1, 0x43, 0x33, 0x38, 0x73, 0x92, 0x98, 0x1b, 0x75, 0xc3, 0xc9, 0x1c}; - uint8_t bytesprops4[] = {0xe1}; - uint8_t bytesprops5[] = {0x5c, 0xe4, 0x3e, 0x78, 0x72, 0x5b, 0xe3, 0xcf, 0x9a, 0x13, 0x7a, 0x3, 0x16, - 0x1c, 0x6e, 0x77, 0xa3, 0xc3, 0x8b, 0xf0, 0x2b, 0x26, 0xa8, 0x6b, 0xb4, 0x80}; - uint8_t bytesprops6[] = {0x13, 0xda, 0xfb, 0xf5, 0x61, 0x9d, 0x9e, 0xc0, 0xfa, 0xc1, 0x3f, - 0x2f, 0x8f, 0xb7, 0x50, 0xb4, 0xbd, 0x6, 0x92, 0xfa, 0x5f}; - uint8_t bytesprops7[] = {0xac, 0x2d, 0x6a, 0x71, 0xde, 0xbc, 0x5e, 0x34, 0xfa, 0xf1, 0xa1, 0x19, 0x85, 0xbd, 0xf5, - 0x8e, 0xe4, 0x94, 0xd8, 0xee, 0x51, 0xb3, 0xe, 0x86, 0x26, 0x36, 0x3f, 0x17, 0x5d, 0xf4}; - uint8_t bytesprops8[] = {0x79, 0x48, 0xd2, 0x55, 0xb8, 0x36, 0x1d, 0x7, 0x83, 0x94, 0x31}; - uint8_t bytesprops9[] = {0x3f, 0xbb, 0x80, 0x4d, 0xce, 0x66, 0xe1, 0xb1, 0x47, 0xaf, 0x41, 0x4a, 0x30, - 0x9c, 0xb9, 0xdb, 0x68, 0xdb, 0xe7, 0x35, 0x8a, 0x6f, 0x6e, 0xf8, 0x9d}; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = true; + uint8_t bytesprops1[] = {0xd1, 0x5f, 0x84, 0xc5, 0x5d, 0x4a, 0x9, 0x90, + 0x3f, 0x9d, 0xc0, 0xdb, 0xc8, 0x23, 0x23, 0x32}; + uint8_t bytesprops0[] = {0xa8, 0x71, 0xda, 0xfc, 0xf5, 0x91, 0x36, 0x29, 0xc9, 0x71, + 0x66, 0x96, 0x1e, 0x4, 0xb9, 0x76, 0x4, 0xd1, 0x32}; + uint8_t bytesprops2[] = {0x7b, 0x65, 0x96, 0x77, 0xb2, 0x5}; + uint8_t bytesprops3[] = {0xaa, 0x9e, 0x45, 0x7, 0x42, 0xd3, 0x44, 0xab, 0x4d}; + uint8_t bytesprops4[] = {0x5d, 0xb2, 0x87, 0x1f, 0x92, 0xf1, 0xe3, 0xa9, 0x35, + 0x40, 0xd6, 0xc5, 0xfc, 0x1b, 0x8c, 0x4d, 0x50, 0xd3}; + uint8_t bytesprops5[] = {0xca, 0xe5, 0xa2, 0xda, 0x15, 0x15, 0x5c, 0xa, 0x12, 0xc, 0xd9}; + uint8_t bytesprops6[] = {0x14, 0xb2, 0x4e, 0x8a, 0xe1, 0xa0}; + uint8_t bytesprops7[] = {0xd7, 0x8c, 0xd4, 0xc0, 0xe4, 0x13, 0xc0, 0xbf, 0x4b, + 0xa, 0xdd, 0x54, 0x81, 0x3b, 0xa9, 0x1e, 0xe0}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0xd7, 0x69, 0x77, 0x92, 0xf2, 0x78, 0xca, 0xb8, 0x51}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31150}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12814}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26923}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21509}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25304}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30495}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2552}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29036}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17544}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14660}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27309}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18006}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32484}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27729}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31247}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15648}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26613}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2627}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17214}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22557, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22596, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 10879 [("k\CAN\STX\230?\231\199\145\130\DLE\182\233W\233\&5F\250\153Hoip\242W\164",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\t\253\178\254a\b\217\143\162\FS\221\238PG\177\229\208*\DEL$k\160O\DLEs`\132\DC2\NAKV",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\216/\149I\232hE\247*RW\244\251\134\204",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\FS9Yu\225\234\246\SOHB>\199#\188\"i\162<\168\185?\219`\237\163\NUL%",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\201\177D\132y\246}ad\135\228\US\t",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS0}),("\132lyi].N\135g\164se\160\235!n\158\239MqZ",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropMaximumPacketSize -// 5146,PropSessionExpiryInterval 25344,PropSubscriptionIdentifier 9,PropMessageExpiryInterval -// 11213,PropWillDelayInterval 9631,PropRequestResponseInformation 142,PropResponseTopic -// "\170\224\174/\170\135\131\ENQ\235\194\247h",PropUserProperty ";T\ETX]^\235;F|\153Z\157/h\242'c|\147\178M!" -// "7\238KB\173\223%4\178a\RS\US\174~\157k\145\158\141\EM\184\242_\221<\170\&9\214",PropRetainAvailable -// 235,PropWillDelayInterval 23966,PropMessageExpiryInterval 27117,PropContentType "W\166",PropMessageExpiryInterval -// 2184,PropAssignedClientIdentifier "\181\&1\145;\250\248p1\144\145z\DC1\236",PropContentType -// "\238\168G\197\219\136\142i\243\&8I\220eyc\163\254e\f\193\f)SB\205\246\188B",PropWildcardSubscriptionAvailable -// 5,PropMessageExpiryInterval 2521,PropMaximumQoS 243,PropSubscriptionIdentifier 8,PropRequestResponseInformation -// 226,PropSharedSubscriptionAvailable 105,PropPayloadFormatIndicator 50,PropWildcardSubscriptionAvailable -// 13,PropAssignedClientIdentifier "0wW[P\155;\165A",PropMessageExpiryInterval 8553,PropTopicAliasMaximum -// 21395,PropSubscriptionIdentifier 18,PropMaximumQoS 178,PropContentType -// "\r`\209\159\254\ACK\148\236\161+\185\&6%\201~\198MC",PropReasonString "\170\215y\147\243U\216\222UI"] +// SubscribeRequest 11045 [("\234\249\222\145'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS0}),("\217Z\205\221w\220\&3\151\252\147\160\134\236\ru\149\189",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("J\221\215\236\181\158\210\253l\a\191z\189\211\SOq\150",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("BFVB\232\190z@:\164\132\215)\182\230\141\225\GS",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropMaximumPacketSize 12065,PropAuthenticationMethod +// "\227J\166\US*\180\DEL",PropSharedSubscriptionAvailable 15,PropWildcardSubscriptionAvailable +// 214,PropMessageExpiryInterval 4051,PropAuthenticationMethod "\191\217^E\178\249\146\183P?W",PropAuthenticationMethod +// "\FS\167\172\154\171\249\150l%E(\244\164\142D\218\179\&0d\184d\130",PropTopicAlias 26889,PropContentType +// "\142\203}\239&\216\188QFQ\DC1\a5tx\199tX?W\203",PropReceiveMaximum 28577,PropUserProperty "\DC2\128\251\&9" +// "a\DELL\n\218(\236",PropSubscriptionIdentifierAvailable 78,PropWildcardSubscriptionAvailable +// 189,PropSessionExpiryInterval 2405,PropSharedSubscriptionAvailable 232,PropTopicAliasMaximum +// 7516,PropAuthenticationMethod "\NAK\203\171\174M\FSV!\200\SIl0\137O\163sO\228",PropSessionExpiryInterval +// 30122,PropRequestProblemInformation 158,PropResponseInformation +// "D\206\196G\ENQ\227\190a{N\CANS\202\147\ETB\182\210\t\SOH\FS\230\230\192\227;iC!\193\SO",PropMaximumQoS +// 93,PropSharedSubscriptionAvailable 146,PropWildcardSubscriptionAvailable 218,PropRequestProblemInformation +// 110,PropTopicAlias 6109,PropSubscriptionIdentifierAvailable 67,PropContentType +// "\204\253(\255\222\176\228q\251\235\149\US\141L\167\228\146\202\172}W\215\&6\242\142"] TEST(Subscribe5QCTest, Encode19) { uint8_t pkt[] = { - 0x82, 0xac, 0x3, 0x2a, 0x7f, 0xf0, 0x1, 0x27, 0x0, 0x0, 0x14, 0x1a, 0x11, 0x0, 0x0, 0x63, 0x0, 0xb, 0x9, - 0x2, 0x0, 0x0, 0x2b, 0xcd, 0x18, 0x0, 0x0, 0x25, 0x9f, 0x19, 0x8e, 0x8, 0x0, 0xc, 0xaa, 0xe0, 0xae, 0x2f, - 0xaa, 0x87, 0x83, 0x5, 0xeb, 0xc2, 0xf7, 0x68, 0x26, 0x0, 0x16, 0x3b, 0x54, 0x3, 0x5d, 0x5e, 0xeb, 0x3b, 0x46, - 0x7c, 0x99, 0x5a, 0x9d, 0x2f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, 0x2a, 0x92, 0x28, 0xda, 0x17, 0x6e, 0x23, 0x17, 0xdd, 0x29, 0x43, 0x3, 0x0, 0x19, 0xcc, 0xfd, + 0x28, 0xff, 0xde, 0xb0, 0xe4, 0x71, 0xfb, 0xeb, 0x95, 0x1f, 0x8d, 0x4c, 0xa7, 0xe4, 0x92, 0xca, 0xac, 0x7d, 0x57, + 0xd7, 0x36, 0xf2, 0x8e, 0x0, 0x5, 0xea, 0xf9, 0xde, 0x91, 0x27, 0x4, 0x0, 0x11, 0xd9, 0x5a, 0xcd, 0xdd, 0x77, + 0xdc, 0x33, 0x97, 0xfc, 0x93, 0xa0, 0x86, 0xec, 0xd, 0x75, 0x95, 0xbd, 0x1c, 0x0, 0x11, 0x4a, 0xdd, 0xd7, 0xec, + 0xb5, 0x9e, 0xd2, 0xfd, 0x6c, 0x7, 0xbf, 0x7a, 0xbd, 0xd3, 0xe, 0x71, 0x96, 0x1c, 0x0, 0x12, 0x42, 0x46, 0x56, + 0x42, 0xe8, 0xbe, 0x7a, 0x40, 0x3a, 0xa4, 0x84, 0xd7, 0x29, 0xb6, 0xe6, 0x8d, 0xe1, 0x1d, 0x4}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x6b, 0x18, 0x2, 0xe6, 0x3f, 0xe7, 0xc7, 0x91, 0x82, 0x10, 0xb6, 0xe9, 0x57, - 0xe9, 0x35, 0x46, 0xfa, 0x99, 0x48, 0x6f, 0x69, 0x70, 0xf2, 0x57, 0xa4}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xea, 0xf9, 0xde, 0x91, 0x27}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9, 0xfd, 0xb2, 0xfe, 0x61, 0x8, 0xd9, 0x8f, 0xa2, 0x1c, - 0xdd, 0xee, 0x50, 0x47, 0xb1, 0xe5, 0xd0, 0x2a, 0x7f, 0x24, - 0x6b, 0xa0, 0x4f, 0x10, 0x73, 0x60, 0x84, 0x12, 0x15, 0x56}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd9, 0x5a, 0xcd, 0xdd, 0x77, 0xdc, 0x33, 0x97, 0xfc, + 0x93, 0xa0, 0x86, 0xec, 0xd, 0x75, 0x95, 0xbd}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd8, 0x2f, 0x95, 0x49, 0xe8, 0x68, 0x45, 0xf7, - 0x2a, 0x52, 0x57, 0xf4, 0xfb, 0x86, 0xcc}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x4a, 0xdd, 0xd7, 0xec, 0xb5, 0x9e, 0xd2, 0xfd, 0x6c, + 0x7, 0xbf, 0x7a, 0xbd, 0xd3, 0xe, 0x71, 0x96}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1c, 0x39, 0x59, 0x75, 0xe1, 0xea, 0xf6, 0x1, 0x42, 0x3e, 0xc7, 0x23, 0xbc, - 0x22, 0x69, 0xa2, 0x3c, 0xa8, 0xb9, 0x3f, 0xdb, 0x60, 0xed, 0xa3, 0x0, 0x25}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x42, 0x46, 0x56, 0x42, 0xe8, 0xbe, 0x7a, 0x40, 0x3a, + 0xa4, 0x84, 0xd7, 0x29, 0xb6, 0xe6, 0x8d, 0xe1, 0x1d}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc9, 0xb1, 0x44, 0x84, 0x79, 0xf6, 0x7d, 0x61, 0x64, 0x87, 0xe4, 0x1f, - 0x3c, 0x48, 0x32, 0x5d, 0x56, 0xff, 0x9e, 0x65, 0xdf, 0xff, 0xfa}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x3d, 0xcd, 0x6f, 0x15}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x83, 0xcf, 0x36, 0x57, 0xc3, 0x20, 0x67, 0x4c, - 0xb2, 0xda, 0x82, 0x98, 0x75, 0xd1, 0x3e, 0x9}; - lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x84, 0x6c, 0x79, 0x69, 0x5d, 0x2e, 0x4e, 0x87, 0x67, 0xa4, 0x73, - 0x65, 0xa0, 0xeb, 0x21, 0x6e, 0x9e, 0xef, 0x4d, 0x71, 0x5a}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; + sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - uint8_t bytesprops0[] = {0xaa, 0xe0, 0xae, 0x2f, 0xaa, 0x87, 0x83, 0x5, 0xeb, 0xc2, 0xf7, 0x68}; - uint8_t bytesprops2[] = {0x37, 0xee, 0x4b, 0x42, 0xad, 0xdf, 0x25, 0x34, 0xb2, 0x61, 0x1e, 0x1f, 0xae, 0x7e, - 0x9d, 0x6b, 0x91, 0x9e, 0x8d, 0x19, 0xb8, 0xf2, 0x5f, 0xdd, 0x3c, 0xaa, 0x39, 0xd6}; - uint8_t bytesprops1[] = {0x3b, 0x54, 0x3, 0x5d, 0x5e, 0xeb, 0x3b, 0x46, 0x7c, 0x99, 0x5a, - 0x9d, 0x2f, 0x68, 0xf2, 0x27, 0x63, 0x7c, 0x93, 0xb2, 0x4d, 0x21}; - uint8_t bytesprops3[] = {0x57, 0xa6}; - uint8_t bytesprops4[] = {0xb5, 0x31, 0x91, 0x3b, 0xfa, 0xf8, 0x70, 0x31, 0x90, 0x91, 0x7a, 0x11, 0xec}; - uint8_t bytesprops5[] = {0xee, 0xa8, 0x47, 0xc5, 0xdb, 0x88, 0x8e, 0x69, 0xf3, 0x38, 0x49, 0xdc, 0x65, 0x79, - 0x63, 0xa3, 0xfe, 0x65, 0xc, 0xc1, 0xc, 0x29, 0x53, 0x42, 0xcd, 0xf6, 0xbc, 0x42}; - uint8_t bytesprops6[] = {0x30, 0x77, 0x57, 0x5b, 0x50, 0x9b, 0x3b, 0xa5, 0x41}; - uint8_t bytesprops7[] = {0xd, 0x60, 0xd1, 0x9f, 0xfe, 0x6, 0x94, 0xec, 0xa1, - 0x2b, 0xb9, 0x36, 0x25, 0xc9, 0x7e, 0xc6, 0x4d, 0x43}; - uint8_t bytesprops8[] = {0xaa, 0xd7, 0x79, 0x93, 0xf3, 0x55, 0xd8, 0xde, 0x55, 0x49}; + uint8_t bytesprops0[] = {0xe3, 0x4a, 0xa6, 0x1f, 0x2a, 0xb4, 0x7f}; + uint8_t bytesprops1[] = {0xbf, 0xd9, 0x5e, 0x45, 0xb2, 0xf9, 0x92, 0xb7, 0x50, 0x3f, 0x57}; + uint8_t bytesprops2[] = {0x1c, 0xa7, 0xac, 0x9a, 0xab, 0xf9, 0x96, 0x6c, 0x25, 0x45, 0x28, + 0xf4, 0xa4, 0x8e, 0x44, 0xda, 0xb3, 0x30, 0x64, 0xb8, 0x64, 0x82}; + uint8_t bytesprops3[] = {0x8e, 0xcb, 0x7d, 0xef, 0x26, 0xd8, 0xbc, 0x51, 0x46, 0x51, 0x11, + 0x7, 0x35, 0x74, 0x78, 0xc7, 0x74, 0x58, 0x3f, 0x57, 0xcb}; + uint8_t bytesprops5[] = {0x61, 0x7f, 0x4c, 0xa, 0xda, 0x28, 0xec}; + uint8_t bytesprops4[] = {0x12, 0x80, 0xfb, 0x39}; + uint8_t bytesprops6[] = {0x15, 0xcb, 0xab, 0xae, 0x4d, 0x1c, 0x56, 0x21, 0xc8, + 0xf, 0x6c, 0x30, 0x89, 0x4f, 0xa3, 0x73, 0x4f, 0xe4}; + uint8_t bytesprops7[] = {0x44, 0xce, 0xc4, 0x47, 0x5, 0xe3, 0xbe, 0x61, 0x7b, 0x4e, 0x18, 0x53, 0xca, 0x93, 0x17, + 0xb6, 0xd2, 0x9, 0x1, 0x1c, 0xe6, 0xe6, 0xc0, 0xe3, 0x3b, 0x69, 0x43, 0x21, 0xc1, 0xe}; + uint8_t bytesprops8[] = {0xcc, 0xfd, 0x28, 0xff, 0xde, 0xb0, 0xe4, 0x71, 0xfb, 0xeb, 0x95, 0x1f, 0x8d, + 0x4c, 0xa7, 0xe4, 0x92, 0xca, 0xac, 0x7d, 0x57, 0xd7, 0x36, 0xf2, 0x8e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5146}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25344}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11213}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9631}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops1}, .v = {28, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23966}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27117}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2184}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2521}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8553}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21395}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12065}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4051}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26889}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28577}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops4}, .v = {7, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2405}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7516}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30122}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6109}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10879, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 11045, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 26713 [("i",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = -// True, _subQoS = QoS2}),("0\150\163\DC3)S\193\165K\135\211\DC43\159\\/\250+\200MF\149sGs{t\158",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\180+?\143\187\GS",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = -// False, _subQoS = QoS0}),("s\t\186\187\183\237\241gr\201",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\SYN\179\228\226\252EZ\t\240$\ENQ\239JJq",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("D",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropResponseTopic -// "\223\150\233R;\FS\196o:\236\230\&7U\196\135\157\241\193",PropResponseInformation -// "\136\SUB\197qd\255\131\226\DC1\\J\\\206\172\197\NAK\253\189^",PropSessionExpiryInterval 19197,PropContentType -// "p",PropMessageExpiryInterval 25930,PropServerKeepAlive 24518,PropCorrelationData -// "\ENQ:e\DC2\145\ESC\195q\191\143\t\132\bX\154\SYN\210\230\196_`\"\201G",PropSharedSubscriptionAvailable -// 124,PropRequestResponseInformation 109,PropWildcardSubscriptionAvailable 99,PropMessageExpiryInterval -// 3866,PropReasonString "\162\132`\154\166\235\173\155G\215\236T\202!$z\ENQL"] +// SubscribeRequest 21249 [("7\141\154\230\129\244\236\138'\RS\208h&Y\170\r\229q",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("Q",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\150+:_xw\178Z\250\SYN\210\178L",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\250z\226\216\161\ETX\ACK\136\206\ESC\173\US\218\247\CAN\SI\213)z>z\188-E\195\128\181L\248'",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("W\185i\STX8n",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = +// False, _subQoS = QoS0}),(",\244N\145.o\200\211.\221B{\185",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropWillDelayInterval 2019,PropMessageExpiryInterval +// 19515,PropMaximumPacketSize 11361,PropContentType +// "\202'\227\FS\137\206\&6&\131\231\&6\242\ENQ\169",PropTopicAliasMaximum 14955,PropAuthenticationData +// "\146\131,$`=2\DLE\136M\180\184\204y!}\ETX",PropReasonString +// "G\195\238\\\144\162\231\135\249\140'\152\213\&6\200\&7\180U\227\191\t\182f\DC3v3\249Z",PropRequestProblemInformation +// 101,PropPayloadFormatIndicator 153,PropWillDelayInterval 20161,PropAuthenticationData +// "\248\206\195D\167&H\189aFd,\136",PropMaximumPacketSize 8548] TEST(Subscribe5QCTest, Encode20) { - uint8_t pkt[] = {0x82, 0xc9, 0x1, 0x68, 0x59, 0x77, 0x8, 0x0, 0x12, 0xdf, 0x96, 0xe9, 0x52, 0x3b, 0x1c, 0xc4, 0x6f, - 0x3a, 0xec, 0xe6, 0x37, 0x55, 0xc4, 0x87, 0x9d, 0xf1, 0xc1, 0x1a, 0x0, 0x13, 0x88, 0x1a, 0xc5, 0x71, - 0x64, 0xff, 0x83, 0xe2, 0x11, 0x5c, 0x4a, 0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0x7b, + 0x9f, 0x74, 0x62, 0xa3, 0xcc, 0x5f, 0xd2, 0x38, 0xb1, 0xc, 0xb6, 0xea, 0x1e, 0x3e, 0x77, 0xb2, 0x5a, 0xfa, 0x16, + 0xd2, 0xb2, 0x4c, 0x2, 0x0, 0x1e, 0xfa, 0x7a, 0xe2, 0xd8, 0xa1, 0x3, 0x6, 0x88, 0xce, 0x1b, 0xad, 0x1f, 0xda, + 0xf7, 0x18, 0xf, 0xd5, 0x29, 0x7a, 0x3e, 0x7a, 0xbc, 0x2d, 0x45, 0xc3, 0x80, 0xb5, 0x4c, 0xf8, 0x27, 0x21, 0x0, + 0x6, 0x57, 0xb9, 0x69, 0x2, 0x38, 0x6e, 0x28, 0x0, 0x0, 0x8, 0x0, 0xd, 0x2c, 0xf4, 0x4e, 0x91, 0x2e, 0x6f, + 0xc8, 0xd3, 0x2e, 0xdd, 0x42, 0x7b, 0xb9, 0x22}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x69}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x37, 0x8d, 0x9a, 0xe6, 0x81, 0xf4, 0xec, 0x8a, 0x27, + 0x1e, 0xd0, 0x68, 0x26, 0x59, 0xaa, 0xd, 0xe5, 0x71}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x30, 0x96, 0xa3, 0x13, 0x29, 0x53, 0xc1, 0xa5, 0x4b, 0x87, - 0xd3, 0x14, 0x33, 0x9f, 0x5c, 0x2f, 0xfa, 0x2b, 0xc8, 0x4d, - 0x46, 0x95, 0x73, 0x47, 0x73, 0x7b, 0x74, 0x9e}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x51}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb4, 0x2b, 0x3f, 0x8f, 0xbb, 0x1d}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x96, 0x2b, 0x3a, 0x5f, 0x78, 0x3c, 0x53, 0xa5, 0x6f, 0x22, 0x7d, + 0x8a, 0x1d, 0xbd, 0xef, 0xf6, 0x68, 0xdf, 0xcb, 0xf5, 0x8a, 0xbb}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x73, 0x9, 0xba, 0xbb, 0xb7, 0xed, 0xf1, 0x67, 0x72, 0xc9}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x5a, 0xdc, 0xb, 0x62, 0xaa, 0x2d, 0xf9, 0xc3, 0xd1, 0xbf, 0x5b, 0xc3, 0x45, + 0x95, 0xcd, 0x22, 0xcd, 0x7e, 0xf9, 0xd3, 0x3a, 0xd3, 0x65, 0x5a, 0xf8, 0x52}; + lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x16, 0xb3, 0xe4, 0xe2, 0xfc, 0x45, 0x5a, 0x9, - 0xf0, 0x24, 0x5, 0xef, 0x4a, 0x4a, 0x71}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa7, 0xf8, 0xf6, 0x8b, 0x9d, 0x7b, 0x9f, 0x74, 0x62, 0xa3, + 0xcc, 0x5f, 0xd2, 0x38, 0xb1, 0xc, 0xb6, 0xea, 0x1e, 0x3e, + 0x77, 0xb2, 0x5a, 0xfa, 0x16, 0xd2, 0xb2, 0x4c}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x44}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xfa, 0x7a, 0xe2, 0xd8, 0xa1, 0x3, 0x6, 0x88, 0xce, 0x1b, + 0xad, 0x1f, 0xda, 0xf7, 0x18, 0xf, 0xd5, 0x29, 0x7a, 0x3e, + 0x7a, 0xbc, 0x2d, 0x45, 0xc3, 0x80, 0xb5, 0x4c, 0xf8, 0x27}; + lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s6_bytes[] = {0x57, 0xb9, 0x69, 0x2, 0x38, 0x6e}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x2c, 0xf4, 0x4e, 0x91, 0x2e, 0x6f, 0xc8, 0xd3, 0x2e, 0xdd, 0x42, 0x7b, 0xb9}; + lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - uint8_t bytesprops0[] = {0xdf, 0x96, 0xe9, 0x52, 0x3b, 0x1c, 0xc4, 0x6f, 0x3a, - 0xec, 0xe6, 0x37, 0x55, 0xc4, 0x87, 0x9d, 0xf1, 0xc1}; - uint8_t bytesprops1[] = {0x88, 0x1a, 0xc5, 0x71, 0x64, 0xff, 0x83, 0xe2, 0x11, 0x5c, - 0x4a, 0x5c, 0xce, 0xac, 0xc5, 0x15, 0xfd, 0xbd, 0x5e}; - uint8_t bytesprops2[] = {0x70}; - uint8_t bytesprops3[] = {0x5, 0x3a, 0x65, 0x12, 0x91, 0x1b, 0xc3, 0x71, 0xbf, 0x8f, 0x9, 0x84, - 0x8, 0x58, 0x9a, 0x16, 0xd2, 0xe6, 0xc4, 0x5f, 0x60, 0x22, 0xc9, 0x47}; - uint8_t bytesprops4[] = {0xa2, 0x84, 0x60, 0x9a, 0xa6, 0xeb, 0xad, 0x9b, 0x47, - 0xd7, 0xec, 0x54, 0xca, 0x21, 0x24, 0x7a, 0x5, 0x4c}; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + uint8_t bytesprops0[] = {0xca, 0x27, 0xe3, 0x1c, 0x89, 0xce, 0x36, 0x26, 0x83, 0xe7, 0x36, 0xf2, 0x5, 0xa9}; + uint8_t bytesprops1[] = {0x92, 0x83, 0x2c, 0x24, 0x60, 0x3d, 0x32, 0x10, 0x88, + 0x4d, 0xb4, 0xb8, 0xcc, 0x79, 0x21, 0x7d, 0x3}; + uint8_t bytesprops2[] = {0x47, 0xc3, 0xee, 0x5c, 0x90, 0xa2, 0xe7, 0x87, 0xf9, 0x8c, 0x27, 0x98, 0xd5, 0x36, + 0xc8, 0x37, 0xb4, 0x55, 0xe3, 0xbf, 0x9, 0xb6, 0x66, 0x13, 0x76, 0x33, 0xf9, 0x5a}; + uint8_t bytesprops3[] = {0xf8, 0xce, 0xc3, 0x44, 0xa7, 0x26, 0x48, 0xbd, 0x61, 0x46, 0x64, 0x2c, 0x88}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19197}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25930}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24518}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3866}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2019}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19515}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11361}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14955}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20161}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8548}}, }; lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26713, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21249, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25908 [("\158\154$vc\165\145gf\234i\231\148\155\181",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\RS\209\233$}",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] -// [PropMaximumPacketSize 30821,PropAuthenticationData -// "*\169G\209g~n26\184@\177\173{e\US\178L\188\167\165\130l",PropTopicAliasMaximum 29506,PropSessionExpiryInterval -// 19470,PropReasonString "o\EOT\159\170J5\136M\STX\189\189",PropSharedSubscriptionAvailable 133,PropResponseTopic -// "\218\SUB%\182\174\&2\178Sv\151\SYN@\155B\193B(#\161~\135",PropServerReference -// "\145H\203T%\196\244\219,\209K\246q0\171\167\EMxG\b\206\189\241\197\149X",PropServerReference -// ")\237+\191\222?\136\139\177#\166",PropSessionExpiryInterval 19900,PropServerReference -// ")\189v3\142G",PropSessionExpiryInterval 9354,PropPayloadFormatIndicator 193,PropMessageExpiryInterval -// 24898,PropWildcardSubscriptionAvailable 103,PropRequestResponseInformation 94,PropMessageExpiryInterval -// 3135,PropResponseInformation "\208S",PropReceiveMaximum 3314,PropSubscriptionIdentifierAvailable 172] +// SubscribeRequest 32237 [("4kW\253\213\191\228\173\&8\EM\n",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("n\199=\255]\ETX\237\&4\249V\187\139\228\DELVS\208~\231\232\208\203\187JH\153D\214\183",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("I\199\145I:\210\ETX\150\215N\aE3l\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = True, _subQoS = +// QoS2}),("\NAK6\182D\195\163\&3y\228P\236\212\201\235T\a\151\SUB4\235\185\ETBs",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\128j\150\163\160%mXs\152",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS0})] [PropSubscriptionIdentifier 31,PropMaximumQoS 183,PropSubscriptionIdentifier +// 15,PropSessionExpiryInterval 3789,PropReceiveMaximum 2999] TEST(Subscribe5QCTest, Encode21) { - uint8_t pkt[] = {0x82, 0xc5, 0x1, 0x65, 0x34, 0xa7, 0x1, 0x27, 0x0, 0x0, 0x78, 0x65, 0x16, 0x0, 0x17, 0x2a, 0xa9, - 0x47, 0xd1, 0x67, 0x7e, 0x6e, 0x32, 0x36, 0xb8, 0x40, 0xb1, 0xad, 0x7b, 0x65, 0x1f, 0xb2, 0x4c, 0xbc, - 0xa7, 0xa5, 0x82, 0x6c, 0x22, 0x73, 0x42, 0x11, 0x0, 0x0, 0x4c, 0xe, 0x1f, 0x0, 0xb, 0x6f, 0x4, - 0x9f, 0xaa, 0x4a, 0x35, 0x88, 0x4d, 0x2, 0xbd, 0xbd, 0x2a, 0x85, 0x8, 0x0, 0x15, 0xda, 0x1a, 0x25, - 0xb6, 0xae, 0x32, 0xb2, 0x53, 0x76, 0x97, 0x16, 0x40, 0x9b, 0x42, 0xc1, 0x42, 0x28, 0x23, 0xa1, 0x7e, - 0x87, 0x1c, 0x0, 0x1a, 0x91, 0x48, 0xcb, 0x54, 0x25, 0xc4, 0xf4, 0xdb, 0x2c, 0xd1, 0x4b, 0xf6, 0x71, - 0x30, 0xab, 0xa7, 0x19, 0x78, 0x47, 0x8, 0xce, 0xbd, 0xf1, 0xc5, 0x95, 0x58, 0x1c, 0x0, 0xb, 0x29, - 0xed, 0x2b, 0xbf, 0xde, 0x3f, 0x88, 0x8b, 0xb1, 0x23, 0xa6, 0x11, 0x0, 0x0, 0x4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, 0x58, 0x73, 0x98, 0x2c}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x9e, 0x9a, 0x24, 0x76, 0x63, 0xa5, 0x91, 0x67, - 0x66, 0xea, 0x69, 0xe7, 0x94, 0x9b, 0xb5}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x34, 0x6b, 0x57, 0xfd, 0xd5, 0xbf, 0xe4, 0xad, 0x38, 0x19, 0xa}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1e, 0xd1, 0xe9, 0x24, 0x7d}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6e, 0xc7, 0x3d, 0xff, 0x5d, 0x3, 0xed, 0x34, 0xf9, 0x56, + 0xbb, 0x8b, 0xe4, 0x7f, 0x56, 0x53, 0xd0, 0x7e, 0xe7, 0xe8, + 0xd0, 0xcb, 0xbb, 0x4a, 0x48, 0x99, 0x44, 0xd6, 0xb7}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + uint8_t topic_filter_s2_bytes[] = {0x49, 0xc7, 0x91, 0x49, 0x3a, 0xd2, 0x3, 0x96, + 0xd7, 0x4e, 0x7, 0x45, 0x33, 0x6c, 0xb8}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x15, 0x36, 0xb6, 0x44, 0xc3, 0xa3, 0x33, 0x79, 0xe4, 0x50, 0xec, 0xd4, + 0xc9, 0xeb, 0x54, 0x7, 0x97, 0x1a, 0x34, 0xeb, 0xb9, 0x17, 0x73}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x80, 0x6a, 0x96, 0xa3, 0xa0, 0x25, 0x6d, 0x58, 0x73, 0x98}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - uint8_t bytesprops0[] = {0x2a, 0xa9, 0x47, 0xd1, 0x67, 0x7e, 0x6e, 0x32, 0x36, 0xb8, 0x40, 0xb1, - 0xad, 0x7b, 0x65, 0x1f, 0xb2, 0x4c, 0xbc, 0xa7, 0xa5, 0x82, 0x6c}; - uint8_t bytesprops1[] = {0x6f, 0x4, 0x9f, 0xaa, 0x4a, 0x35, 0x88, 0x4d, 0x2, 0xbd, 0xbd}; - uint8_t bytesprops2[] = {0xda, 0x1a, 0x25, 0xb6, 0xae, 0x32, 0xb2, 0x53, 0x76, 0x97, 0x16, - 0x40, 0x9b, 0x42, 0xc1, 0x42, 0x28, 0x23, 0xa1, 0x7e, 0x87}; - uint8_t bytesprops3[] = {0x91, 0x48, 0xcb, 0x54, 0x25, 0xc4, 0xf4, 0xdb, 0x2c, 0xd1, 0x4b, 0xf6, 0x71, - 0x30, 0xab, 0xa7, 0x19, 0x78, 0x47, 0x8, 0xce, 0xbd, 0xf1, 0xc5, 0x95, 0x58}; - uint8_t bytesprops4[] = {0x29, 0xed, 0x2b, 0xbf, 0xde, 0x3f, 0x88, 0x8b, 0xb1, 0x23, 0xa6}; - uint8_t bytesprops5[] = {0x29, 0xbd, 0x76, 0x33, 0x8e, 0x47}; - uint8_t bytesprops6[] = {0xd0, 0x53}; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = true; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30821}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29506}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19470}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19900}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9354}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24898}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3135}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3314}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 31}}, {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3789}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2999}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25908, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32237, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20578 [("\224\194C\240\225\DC1\DEL\202~\187o\222v\157/\164<\CAN\230;\141",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("m\173}5\SUB\254\SI\157\231",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\r$\DLE9\US*E\226",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [PropAuthenticationData -// "\240\203\GS\191\198\140g\225~d\237\136\231oHF\167o\SI_\129\207\DEL\131\239\243C\173R",PropSharedSubscriptionAvailable -// 31,PropRetainAvailable 143,PropUserProperty "\254\199.t\235\132\145\197\fY^\250\255\185\187\211" -// "i\129\190\202\142\134\177%\237\180K\142\n\DC4/\236\188\169\160\135K",PropWildcardSubscriptionAvailable -// 165,PropSubscriptionIdentifier 0,PropWillDelayInterval 11724,PropTopicAliasMaximum 2174,PropResponseInformation -// "z\156\158\150Q\177U\168",PropCorrelationData -// "\202\184\170/\229\145\&7\"\255:]\237\215\DC3\228\158/N\DC4_\233b~\196\250iy\162\202",PropRequestResponseInformation -// 248,PropWildcardSubscriptionAvailable 99,PropReceiveMaximum 29354,PropContentType "\166",PropRetainAvailable -// 99,PropSubscriptionIdentifierAvailable 214,PropMaximumPacketSize 12704,PropServerReference -// "k\184{\254\DC2u\DC4,\213\DC1\ESC@\201\227\225=\141\ESC\US\149"] +// SubscribeRequest 1376 [(";\183\191\187\221\202\191\DC3FT\197\175\DC4\217>'\224\SIEx\189\194,",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("IaJ\ACK{\144@\ACK)XK\128\\7\ETX\159\146\SYN\141",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("o\209\197\246\162b\NAK\141\232A8\174\ACK\205\242+\ETX\SOHp\129\232\SUB\205\209&",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\US",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropTopicAliasMaximum +// 3417,PropWildcardSubscriptionAvailable 14,PropAuthenticationMethod +// "\154\196\197Yi\207+\182\&4\179Y\170O\174YW\ETX0*Ga\240'/\144\NAK\DC1",PropCorrelationData +// "\159Mp\235\237\145Z\166}\bOz}H\228sPO\196\150\t\242\231\219\201\235\STX;\140%",PropRequestProblemInformation +// 205,PropSubscriptionIdentifier 14,PropWillDelayInterval 11750,PropAuthenticationMethod +// "\195\190y\139\237\226\177\&9\180\145\250\182\&1yLQ\229\185\245|\205",PropUserProperty +// "\133\144;j\FS\240\ETBCYC\SI\240(\199\151\135\186\241\182-G~\190\192(\206\218\227\252<" "\227$\196 ",PropTopicAlias +// 5360,PropAuthenticationData "\167\215\156\DEL.\221\f\190\141\139B,",PropAuthenticationData +// "\159\ETB",PropReceiveMaximum 13603,PropMessageExpiryInterval 30397,PropMessageExpiryInterval +// 19344,PropMessageExpiryInterval 29512,PropServerKeepAlive 4828,PropMaximumQoS 131,PropSharedSubscriptionAvailable +// 56,PropRetainAvailable 52,PropWillDelayInterval 22307,PropMaximumPacketSize 18923,PropCorrelationData +// "\132\204\197\179\&2\136"] TEST(Subscribe5QCTest, Encode22) { - uint8_t pkt[] = {0x82, 0xe3, 0x1, 0x50, 0x62, 0xb0, 0x1, 0x16, 0x0, 0x1d, 0xf0, 0xcb, 0x1d, 0xbf, 0xc6, 0x8c, 0x67, - 0xe1, 0x7e, 0x64, 0xed, 0x88, 0xe7, 0x6f, 0x48, 0x46, 0xa7, 0x6f, 0xf, 0x5f, 0x81, 0xcf, 0x7f, 0x83, - 0xef, 0xf3, 0x43, 0xad, 0x52, 0x2a, 0x1f, 0x25, 0x8f, 0x26, 0x0, 0x10, 0xfe, 0xc7, 0x2e, 0x74, 0xeb, - 0x84, 0x91, 0xc5, 0xc, 0x59, 0x5e, 0xfa, 0xff, 0xb9, 0xbb, 0xd3, 0x0, 0x15, 0x69, 0x81, 0xbe, 0xca, - 0x8e, 0x86, 0xb1, 0x25, 0xed, 0xb4, 0x4b, 0x8e, 0xa, 0x14, 0x2f, 0xec, 0xbc, 0xa9, 0xa0, 0x87, 0x4b, - 0x28, 0xa5, 0xb, 0x0, 0x18, 0x0, 0x0, 0x2d, 0xcc, 0x22, 0x8, 0x7e, 0x1a, 0x0, 0x8, 0x7a, 0x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x2c, 0xa, 0x0, 0x13, 0x49, 0x61, 0x4a, + 0x6, 0x7b, 0x90, 0x40, 0x6, 0x29, 0x58, 0x4b, 0x80, 0x5c, 0x37, 0x3, 0x9f, 0x92, 0x16, 0x8d, 0x28, 0x0, 0x19, + 0x6f, 0xd1, 0xc5, 0xf6, 0xa2, 0x62, 0x15, 0x8d, 0xe8, 0x41, 0x38, 0xae, 0x6, 0xcd, 0xf2, 0x2b, 0x3, 0x1, 0x70, + 0x81, 0xe8, 0x1a, 0xcd, 0xd1, 0x26, 0x6, 0x0, 0x1, 0x1f, 0x15}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xe0, 0xc2, 0x43, 0xf0, 0xe1, 0x11, 0x7f, 0xca, 0x7e, 0xbb, 0x6f, - 0xde, 0x76, 0x9d, 0x2f, 0xa4, 0x3c, 0x18, 0xe6, 0x3b, 0x8d}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x3b, 0xb7, 0xbf, 0xbb, 0xdd, 0xca, 0xbf, 0x13, 0x46, 0x54, 0xc5, 0xaf, + 0x14, 0xd9, 0x3e, 0x27, 0xe0, 0xf, 0x45, 0x78, 0xbd, 0xc2, 0x2c}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6d, 0xad, 0x7d, 0x35, 0x1a, 0xfe, 0xf, 0x9d, 0xe7}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x49, 0x61, 0x4a, 0x6, 0x7b, 0x90, 0x40, 0x6, 0x29, 0x58, + 0x4b, 0x80, 0x5c, 0x37, 0x3, 0x9f, 0x92, 0x16, 0x8d}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd, 0x24, 0x10, 0x39, 0x1f, 0x2a, 0x45, 0xe2}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6f, 0xd1, 0xc5, 0xf6, 0xa2, 0x62, 0x15, 0x8d, 0xe8, 0x41, 0x38, 0xae, 0x6, + 0xcd, 0xf2, 0x2b, 0x3, 0x1, 0x70, 0x81, 0xe8, 0x1a, 0xcd, 0xd1, 0x26}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s3_bytes[] = {0x1f}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - uint8_t bytesprops0[] = {0xf0, 0xcb, 0x1d, 0xbf, 0xc6, 0x8c, 0x67, 0xe1, 0x7e, 0x64, 0xed, 0x88, 0xe7, 0x6f, 0x48, - 0x46, 0xa7, 0x6f, 0xf, 0x5f, 0x81, 0xcf, 0x7f, 0x83, 0xef, 0xf3, 0x43, 0xad, 0x52}; - uint8_t bytesprops2[] = {0x69, 0x81, 0xbe, 0xca, 0x8e, 0x86, 0xb1, 0x25, 0xed, 0xb4, 0x4b, - 0x8e, 0xa, 0x14, 0x2f, 0xec, 0xbc, 0xa9, 0xa0, 0x87, 0x4b}; - uint8_t bytesprops1[] = {0xfe, 0xc7, 0x2e, 0x74, 0xeb, 0x84, 0x91, 0xc5, - 0xc, 0x59, 0x5e, 0xfa, 0xff, 0xb9, 0xbb, 0xd3}; - uint8_t bytesprops3[] = {0x7a, 0x9c, 0x9e, 0x96, 0x51, 0xb1, 0x55, 0xa8}; - uint8_t bytesprops4[] = {0xca, 0xb8, 0xaa, 0x2f, 0xe5, 0x91, 0x37, 0x22, 0xff, 0x3a, 0x5d, 0xed, 0xd7, 0x13, 0xe4, - 0x9e, 0x2f, 0x4e, 0x14, 0x5f, 0xe9, 0x62, 0x7e, 0xc4, 0xfa, 0x69, 0x79, 0xa2, 0xca}; - uint8_t bytesprops5[] = {0xa6}; - uint8_t bytesprops6[] = {0x6b, 0xb8, 0x7b, 0xfe, 0x12, 0x75, 0x14, 0x2c, 0xd5, 0x11, - 0x1b, 0x40, 0xc9, 0xe3, 0xe1, 0x3d, 0x8d, 0x1b, 0x1f, 0x95}; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + uint8_t bytesprops0[] = {0x9a, 0xc4, 0xc5, 0x59, 0x69, 0xcf, 0x2b, 0xb6, 0x34, 0xb3, 0x59, 0xaa, 0x4f, 0xae, + 0x59, 0x57, 0x3, 0x30, 0x2a, 0x47, 0x61, 0xf0, 0x27, 0x2f, 0x90, 0x15, 0x11}; + uint8_t bytesprops1[] = {0x9f, 0x4d, 0x70, 0xeb, 0xed, 0x91, 0x5a, 0xa6, 0x7d, 0x8, 0x4f, 0x7a, 0x7d, 0x48, 0xe4, + 0x73, 0x50, 0x4f, 0xc4, 0x96, 0x9, 0xf2, 0xe7, 0xdb, 0xc9, 0xeb, 0x2, 0x3b, 0x8c, 0x25}; + uint8_t bytesprops2[] = {0xc3, 0xbe, 0x79, 0x8b, 0xed, 0xe2, 0xb1, 0x39, 0xb4, 0x91, 0xfa, + 0xb6, 0x31, 0x79, 0x4c, 0x51, 0xe5, 0xb9, 0xf5, 0x7c, 0xcd}; + uint8_t bytesprops4[] = {0xe3, 0x24, 0xc4, 0x20}; + uint8_t bytesprops3[] = {0x85, 0x90, 0x3b, 0x6a, 0x1c, 0xf0, 0x17, 0x43, 0x59, 0x43, 0xf, 0xf0, 0x28, 0xc7, 0x97, + 0x87, 0xba, 0xf1, 0xb6, 0x2d, 0x47, 0x7e, 0xbe, 0xc0, 0x28, 0xce, 0xda, 0xe3, 0xfc, 0x3c}; + uint8_t bytesprops5[] = {0xa7, 0xd7, 0x9c, 0x7f, 0x2e, 0xdd, 0xc, 0xbe, 0x8d, 0x8b, 0x42, 0x2c}; + uint8_t bytesprops6[] = {0x9f, 0x17}; + uint8_t bytesprops7[] = {0x84, 0xcc, 0xc5, 0xb3, 0x32, 0x88}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {21, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11724}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2174}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29354}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12704}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3417}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11750}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops3}, .v = {4, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5360}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13603}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30397}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19344}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29512}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4828}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22307}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18923}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20578, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1376, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 13418 [("\EM\171z\153z\136\168{\150\208\134\ENQ\134\225\231\CAN}",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropResponseInformation -// "B\187\220L\DLE",PropAuthenticationMethod "\130\196\&9~\195\ACK\152\&1\170\nI",PropSubscriptionIdentifierAvailable -// 123,PropMaximumQoS 103,PropSharedSubscriptionAvailable 60,PropTopicAlias 26601,PropTopicAlias -// 29510,PropReceiveMaximum 8856,PropSubscriptionIdentifierAvailable 204,PropUserProperty -// "\149y\130\172\239\250\154X>P\193\175u\132\221\236\228 }\192\FS\166on\"4\DC2\146" "e",PropSessionExpiryInterval -// 5464,PropWillDelayInterval 6090,PropReasonString "\249\188\SO\197\&7",PropAuthenticationMethod -// "_4;\253\209\216f\167\&5;\235\177\201\EOT\255\226\192\174\FSC5\SUB\230\ETX",PropSessionExpiryInterval -// 7464,PropServerReference "\245\169\255T\239\199jO\214\238\147\175\246N\a\181+\DC3",PropResponseTopic -// "\190\DLE\239",PropMaximumQoS 137,PropReceiveMaximum 27863,PropSharedSubscriptionAvailable 120,PropReceiveMaximum -// 3606,PropServerKeepAlive 27761,PropReasonString -// "\184\203\DC2\252[)\133\220-\US$\178V'\146\EOT\149\DC1\161\160d\142*\229\224",PropAuthenticationData -// "`^\v\ACK\206\225\130_\199w0 \rU"] +// SubscribeRequest 20213 [("\228\181kq\t",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS0}),("\217\&9\137\SYN\SUB\221t\182\SImim\223\212]",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\128",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\182\130\204\SOH\136\244\204\152",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\163\SI&zW\202\147_\174~O\152\137\242\205\DC3\131\180w +// \252\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("H\DELG\141Np",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1}),("b\201E\195z\240\\k\177\&0\240\216\209\199=\139\251\222\254\173",SubOptions {_retainHandling +// = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("cw,\227\r\161\128\EM:\197/\f\DEL\143\174\169\241\238&",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("-\131\DC3-/\EOTY\146\153]\138\149\250e\132m\EOTrrX\226",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropServerReference +// "\ESC[a\203\142\130h\DC3\241\218\DC2",PropResponseInformation "\131\&5\a\225uB",PropSubscriptionIdentifier +// 29,PropAuthenticationMethod "*\178| +// (\t\230\220\221m\159\194\b\205\r\211\215\159\195\156\245\131\233\187\b\247\&7\183\133I",PropTopicAliasMaximum +// 22977,PropServerReference "\158\SOH\187",PropUserProperty "\163[(Z\241%hh\231m" +// "/\160\220\175Z\US\236\&8\231\EM\167=t\160",PropRequestResponseInformation 47,PropReasonString +// "\229A5\f\NAK\153\150\SYN\206\EM\166Th\219\STX\233",PropWildcardSubscriptionAvailable 148,PropWillDelayInterval +// 2769,PropPayloadFormatIndicator 147,PropSubscriptionIdentifier 5,PropReasonString "\ETB +// h\201A\138H\142\207\240\252\150\a\226\a\255\134*",PropCorrelationData "\198\132@D@*\DC1Q\152",PropWillDelayInterval +// 29082,PropAuthenticationMethod "\ETX\137\r\154\189o0m\202Wn<&\193dl",PropAuthenticationData +// "E!\195B5o\193\&6\212\129\DC2j\141\frEb\229\187a\STX\250\&0\215\214\200\185\233",PropPayloadFormatIndicator +// 107,PropServerReference +// "\220\225\221\DC3\146\190\\^\220\ETXd\EML\143t\157Z\153$p\SYN\222\181",PropAssignedClientIdentifier +// "\199\184\DEL\NUL{/\ETB\244\220\ENQx\229\159\a\188\172",PropMaximumPacketSize 26239,PropResponseInformation +// "\\\GStFU\192R\187\247\201\195\249\165\214\&9\138\&0b",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropMaximumQoS 235] TEST(Subscribe5QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0x5c, 0x45, 0x4a, 0x49, 0x16, 0x0, 0x0, 0x27, 0x0, 0x0, 0x33, 0xaa, 0x23, 0x62, 0x22, - 0x1, 0x5c, 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, 0xc5, 0xcc, 0xed, 0x2, 0xd8, 0xa7, 0x29, + 0x0, 0x4, 0x92, 0x47, 0x2a, 0xa5, 0x6, 0x0, 0x15, 0xb, 0x5, 0x55, 0xca, 0x72, 0x27, 0x98, 0xe4, + 0x2b, 0xe7, 0x64, 0x41, 0xb6, 0x4d, 0x53, 0xff, 0x2a, 0x89, 0x87, 0xaf, 0x28, 0x6, 0x0, 0x18, 0x2b, + 0xdd, 0x5e, 0x54, 0x37, 0xa1, 0xde, 0x1, 0x71, 0x3e, 0x55, 0xc0, 0x52, 0xbb, 0xf7, 0xc9, 0xc3, 0xf9, + 0xa5, 0xd6, 0x39, 0x8a, 0x30, 0x62, 0x2a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xd9, 0x82, 0x27, 0x40, 0x42, 0x53, 0xb7, 0xc9, 0x89, 0x1, 0x14, 0xe1, 0x6f}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x90, 0xc6, 0x97, 0x87, 0x14, 0x25, 0x6c}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = true; + uint8_t topic_filter_s1_bytes[] = {0xf9, 0x1d, 0xf5, 0x48, 0xcf, 0xc6, 0xa2, 0x71, 0x46, 0xb8, 0x40}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc6, 0xa3, 0x56, 0xc9, 0xc7, 0x18, 0x70, 0xea, 0xa1, 0x61, 0xc}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xd4, 0x52, 0xd1, 0x27}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x2, 0xc0, 0x97, 0xf1, 0x9d, 0xed, 0xd3, 0x81, 0x53, + 0x41, 0x0, 0xbd, 0x7, 0x8a, 0xa1, 0xcc, 0x89, 0x1e}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x61, 0xe1, 0x72, 0x56, 0x75, 0x10, 0x1f, 0x1, 0xf2, 0xa6, 0x24, 0x35, + 0xd9, 0x87, 0x3f, 0x2c, 0x10, 0xe5, 0x48, 0x46, 0xb4, 0x22, 0xcf, 0x97}; + lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xe8, 0xe0}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6f, 0x49, 0xb3, 0xaf, 0xc5, 0xcc, 0xed, 0x2, 0xd8, 0xa7}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x92, 0x47, 0x2a, 0xa5}; + lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xb, 0x5, 0x55, 0xca, 0x72, 0x27, 0x98, 0xe4, 0x2b, 0xe7, 0x64, + 0x41, 0xb6, 0x4d, 0x53, 0xff, 0x2a, 0x89, 0x87, 0xaf, 0x28}; + lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x2b, 0xdd, 0x5e, 0x54, 0x37, 0xa1, 0xde, 0x1, 0x71, 0x3e, 0x55, 0xc0, + 0x52, 0xbb, 0xf7, 0xc9, 0xc3, 0xf9, 0xa5, 0xd6, 0x39, 0x8a, 0x30, 0x62}; + lwmqtt_string_t topic_filter_s10 = {24, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xd6, 0x85, 0x2, 0xf6, 0x11}; - uint8_t bytesprops3[] = {0xb2, 0x94, 0xcf}; - uint8_t bytesprops2[] = {0xbb, 0x1a, 0x5f, 0x38, 0x1c, 0xaa, 0x47, 0xad, 0x69}; - uint8_t bytesprops4[] = {0xf0, 0x8b, 0x41, 0x7}; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = true; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = true; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13226}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25122}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28878}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25882}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops2}, .v = {3, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17596}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24979}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25290}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29088}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17738, 1, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13469, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21727 [("\220\186\EOT'\230\ACK\148x\215=1\233\144*\214{t\159\208X\ENQ\n*n\NAK",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("O\nf",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] -// [PropRequestProblemInformation 67,PropCorrelationData "",PropWillDelayInterval 13240,PropPayloadFormatIndicator -// 111,PropResponseTopic "\245\152\DC3\133",PropTopicAliasMaximum 30298,PropServerReference -// "\150P\SYN\NUL\157\ETX\207\161\141/\182\&7\n\218G4\186",PropSubscriptionIdentifier -// 11,PropSubscriptionIdentifierAvailable 122,PropTopicAliasMaximum 29334,PropReceiveMaximum -// 29243,PropWildcardSubscriptionAvailable 210,PropWildcardSubscriptionAvailable 145,PropSubscriptionIdentifierAvailable -// 70,PropWildcardSubscriptionAvailable 17] +// SubscribeRequest 9632 [("9\192\243\129\177\140\182\244C\213\169\203\&4z!Y\215\&3\200\FS|K\216)",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\150M\179",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS2})] [PropAuthenticationData "P,\186K+\tq\225\141\&0\242A\243\128:",PropPayloadFormatIndicator 184] TEST(Subscribe5QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x61, 0x54, 0xdf, 0x3c, 0x17, 0x43, 0x9, 0x0, 0x0, 0x18, 0x0, 0x0, 0x33, 0xb8, 0x1, 0x6f, - 0x8, 0x0, 0x4, 0xf5, 0x98, 0x13, 0x85, 0x22, 0x76, 0x5a, 0x1c, 0x0, 0x11, 0x96, 0x50, 0x16, 0x0, - 0x9d, 0x3, 0xcf, 0xa1, 0x8d, 0x2f, 0xb6, 0x37, 0xa, 0xda, 0x47, 0x34, 0xba, 0xb, 0xb, 0x29, 0x7a, - 0x22, 0x72, 0x96, 0x21, 0x72, 0x3b, 0x28, 0xd2, 0x28, 0x91, 0x29, 0x46, 0x28, 0x11, 0x0, 0x19, 0xdc, - 0xba, 0x4, 0x27, 0xe6, 0x6, 0x94, 0x78, 0xd7, 0x3d, 0x31, 0xe9, 0x90, 0x2a, 0xd6, 0x7b, 0x74, 0x9f, - 0xd0, 0x58, 0x5, 0xa, 0x2a, 0x6e, 0x15, 0x1, 0x0, 0x3, 0x4f, 0xa, 0x66, 0x2d}; + uint8_t pkt[] = {0x82, 0x38, 0x25, 0xa0, 0x14, 0x16, 0x0, 0xf, 0x50, 0x2c, 0xba, 0x4b, 0x2b, 0x9, 0x71, + 0xe1, 0x8d, 0x30, 0xf2, 0x41, 0xf3, 0x80, 0x3a, 0x1, 0xb8, 0x0, 0x18, 0x39, 0xc0, 0xf3, + 0x81, 0xb1, 0x8c, 0xb6, 0xf4, 0x43, 0xd5, 0xa9, 0xcb, 0x34, 0x7a, 0x21, 0x59, 0xd7, 0x33, + 0xc8, 0x1c, 0x7c, 0x4b, 0xd8, 0x29, 0xd, 0x0, 0x3, 0x96, 0x4d, 0xb3, 0x12}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xdc, 0xba, 0x4, 0x27, 0xe6, 0x6, 0x94, 0x78, 0xd7, 0x3d, 0x31, 0xe9, 0x90, - 0x2a, 0xd6, 0x7b, 0x74, 0x9f, 0xd0, 0x58, 0x5, 0xa, 0x2a, 0x6e, 0x15}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x39, 0xc0, 0xf3, 0x81, 0xb1, 0x8c, 0xb6, 0xf4, 0x43, 0xd5, 0xa9, 0xcb, + 0x34, 0x7a, 0x21, 0x59, 0xd7, 0x33, 0xc8, 0x1c, 0x7c, 0x4b, 0xd8, 0x29}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4f, 0xa, 0x66}; + uint8_t topic_filter_s1_bytes[] = {0x96, 0x4d, 0xb3}; lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; lwmqtt_sub_options_t sub_opts[2]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0xf5, 0x98, 0x13, 0x85}; - uint8_t bytesprops2[] = {0x96, 0x50, 0x16, 0x0, 0x9d, 0x3, 0xcf, 0xa1, 0x8d, - 0x2f, 0xb6, 0x37, 0xa, 0xda, 0x47, 0x34, 0xba}; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + uint8_t bytesprops0[] = {0x50, 0x2c, 0xba, 0x4b, 0x2b, 0x9, 0x71, 0xe1, 0x8d, 0x30, 0xf2, 0x41, 0xf3, 0x80, 0x3a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13240}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30298}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29334}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29243}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21727, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9632, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 19375 [("\225\165Uj\\\240\190*Vv\135:f)\169i/up&",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\203N\154\STXXt\245\221\238\134 ?=",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\SUB\205",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, -// _subQoS = QoS0})] [PropAuthenticationData "\179\140vn5\142'\154\215l\129\171I\175\188\CANs\172/",PropMaximumQoS -// 49,PropMaximumPacketSize 29237,PropTopicAliasMaximum 8231,PropRequestResponseInformation 182,PropMaximumPacketSize -// 18717,PropResponseInformation "\178\129\246W",PropServerReference "*IE\245\240\167<\DC2 -// \247-\STX\241\218\184n\225yl\145\179\161\190\145",PropResponseInformation -// "\165|\136\145Z\150\245F\USI\STX\154\232\224\158\168\SUB_\169\DC3\204\169v",PropServerReference -// "\NAK\143$\235",PropWildcardSubscriptionAvailable 222,PropTopicAliasMaximum 1110,PropSubscriptionIdentifierAvailable -// 115,PropMessageExpiryInterval 23125,PropContentType "m\SUB",PropSubscriptionIdentifier 12,PropMaximumPacketSize -// 8589,PropRetainAvailable 108,PropRetainAvailable 35,PropTopicAlias 7606,PropSessionExpiryInterval 28011] +// SubscribeRequest 32536 [("\STXFdF1}k\173 c{\188a\199\bh$\SYN\179\&1\a6\DLE\DC1\181",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("{\238\131\204\f\255\221\189\217b\165\148-\170\248\223\222\134{\151p\247\153\164\n",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\137\236\169\249\206aNj\160O\152b\176\230M\205\GS\146\184\213",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("N=\251\238D\139\DC3\SYNL\154))\182\221\132\150\225",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\223!\135V\191\128\&4\190\223\171\&3\234][\195%\175\f||mp\"\214\252\170",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("r\158\170l\"uyP\tR\f\152\176\140\213\227\&6I\249\187A\177\&7\159\136",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\163\196",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] +// [PropWillDelayInterval 24166,PropAuthenticationMethod +// "\217f\220\DC2\146H\160\233\166q",PropRequestResponseInformation -// 123,PropAuthenticationMethod "\143\252\247S\189\RSE\165\190B\173Ab^\r \217\170\DLE\214\142]@V\165\&9\185L"] +// QoS1}),("\139E\182\226c{\194\248\214N?\196\221\221\195%<\SI9",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\134\147\229\f\251`A\191\GS",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("h\248Ay\190)%\\6\168\199",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS0}),("\182\ETB\208\179\128\200\169RV\232=S+D\223S",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\172\216\203\210O\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS1})] [] TEST(Subscribe5QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0xf6, 0x1, 0x6d, 0x7b, 0x44, 0x23, 0x42, 0x69, 0x1a, 0x0, 0x1d, 0x80, 0xf4, 0xb0, 0xbe, 0xc7, - 0x15, 0x2d, 0xb7, 0xba, 0xb8, 0xe1, 0x72, 0xf2, 0xca, 0x63, 0xed, 0x12, 0xfb, 0xe9, 0x3e, 0x66, 0xdc, - 0x12, 0x92, 0x48, 0xa0, 0xe9, 0xa6, 0x71, 0x19, 0x7b, 0x15, 0x0, 0x1c, 0x8f, 0xfc, 0xf7, 0x53, 0xbd, - 0x1e, 0x45, 0xa5, 0xbe, 0x42, 0xad, 0x41, 0x62, 0x5e, 0xd, 0x20, 0xd9, 0xaa, 0x10, 0xd6, 0x8e, 0x5d, - 0x40, 0x56, 0xa5, 0x39, 0xb9, 0x4c, 0x0, 0x18, 0x22, 0x67, 0x26, 0xb8, 0xa4, 0xbc, 0x4d, 0x14, 0x27, - 0x74, 0x57, 0x3d, 0xd3, 0x69, 0x77, 0xdf, 0x8e, 0xb1, 0x87, 0xdd, 0xc1, 0xd4, 0x3, 0xeb, 0x22, 0x0, - 0x4, 0x45, 0x66, 0xcb, 0x48, 0x2e, 0x0, 0x1d, 0xae, 0x36, 0x9d, 0xc2, 0x7b, 0x70, 0xdf, 0xca, 0xff, - 0x46, 0x69, 0xc9, 0x4f, 0x19, 0x7d, 0xdf, 0xea, 0x24, 0x4, 0x71, 0x16, 0xc9, 0xb6, 0xdb, 0xa4, 0x3a, - 0x88, 0x7c, 0x78, 0x12, 0x0, 0x14, 0x6d, 0x9, 0xc8, 0xc8, 0x7c, 0x2b, 0x2b, 0xb1, 0x10, 0x14, 0x2c, - 0xc6, 0xc3, 0x3a, 0x53, 0x50, 0x34, 0x34, 0xa1, 0x2d, 0x9, 0x0, 0x1a, 0x63, 0x57, 0xc1, 0xa0, 0xe8, - 0xa6, 0x38, 0x40, 0xf4, 0x20, 0x22, 0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0x0, 0xb, 0x68, 0xf8, 0x41, 0x79, 0xbe, 0x29, + 0x25, 0x5c, 0x36, 0xa8, 0xc7, 0x18, 0x0, 0x10, 0xb6, 0x17, 0xd0, 0xb3, 0x80, 0xc8, 0xa9, 0x52, 0x56, + 0xe8, 0x3d, 0x53, 0x2b, 0x44, 0xdf, 0x53, 0x2d, 0x0, 0x6, 0xac, 0xd8, 0xcb, 0xd2, 0x4f, 0xe1, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x22, 0x67, 0x26, 0xb8, 0xa4, 0xbc, 0x4d, 0x14, 0x27, 0x74, 0x57, 0x3d, - 0xd3, 0x69, 0x77, 0xdf, 0x8e, 0xb1, 0x87, 0xdd, 0xc1, 0xd4, 0x3, 0xeb}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x5d, 0x34, 0xf8, 0x89, 0x83, 0xe1, 0x5f, 0x62, 0xd4, 0xa9, 0x17, 0xd}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x45, 0x66, 0xcb, 0x48}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbd, 0xc5, 0xfc, 0x52, 0x1b, 0x1d, 0x4a, 0x75}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xae, 0x36, 0x9d, 0xc2, 0x7b, 0x70, 0xdf, 0xca, 0xff, 0x46, - 0x69, 0xc9, 0x4f, 0x19, 0x7d, 0xdf, 0xea, 0x24, 0x4, 0x71, - 0x16, 0xc9, 0xb6, 0xdb, 0xa4, 0x3a, 0x88, 0x7c, 0x78}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x38, 0x23, 0xdd, 0x46, 0x39, 0x36, 0x62, 0xe8, + 0xd8, 0xa2, 0xbf, 0x81, 0x28, 0x98, 0xb8, 0x7f}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6d, 0x9, 0xc8, 0xc8, 0x7c, 0x2b, 0x2b, 0xb1, 0x10, 0x14, - 0x2c, 0xc6, 0xc3, 0x3a, 0x53, 0x50, 0x34, 0x34, 0xa1, 0x2d}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x60, 0xad, 0x19, 0xc1, 0x58, 0xaf, 0x6c, 0x7d, 0x5b, 0xb6, 0x8, 0xc2, + 0x92, 0x53, 0x30, 0x3b, 0x30, 0x1b, 0x6b, 0x53, 0x58, 0x23, 0x3a}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x63, 0x57, 0xc1, 0xa0, 0xe8, 0xa6, 0x38, 0x40, 0xf4, 0x20, 0x22, 0xf, 0xab, - 0x35, 0x4b, 0x79, 0xd7, 0x3b, 0x83, 0x1f, 0xf3, 0x63, 0x90, 0x80, 0xd6, 0x8a}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x8b, 0x45, 0xb6, 0xe2, 0x63, 0x7b, 0xc2, 0xf8, 0xd6, 0x4e, + 0x3f, 0xc4, 0xdd, 0xdd, 0xc3, 0x25, 0x3c, 0xf, 0x39}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xae, 0x37, 0xd0, 0x68, 0x34, 0x4d, 0x4c, 0x40, 0x2, 0xa7, - 0x4d, 0x70, 0xb, 0x51, 0xe8, 0x94, 0xd, 0xfe, 0x8, 0xbd, - 0x84, 0xdb, 0x7d, 0xeb, 0x9b, 0x83, 0x5c, 0x2c, 0xff}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x86, 0x93, 0xe5, 0xc, 0xfb, 0x60, 0x41, 0xbf, 0x1d}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xdb, 0xe9}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x68, 0xf8, 0x41, 0x79, 0xbe, 0x29, 0x25, 0x5c, 0x36, 0xa8, 0xc7}; + lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x8b, 0xe4, 0x27, 0x18, 0xe0, 0xe9, 0x79, 0xaa, 0x7a, - 0xeb, 0xa8, 0x8, 0x27, 0xed, 0x22, 0xab, 0xb1}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xb6, 0x17, 0xd0, 0xb3, 0x80, 0xc8, 0xa9, 0x52, + 0x56, 0xe8, 0x3d, 0x53, 0x2b, 0x44, 0xdf, 0x53}; + lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; + uint8_t topic_filter_s8_bytes[] = {0xac, 0xd8, 0xcb, 0xd2, 0x4f, 0xe1}; + lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[6].retain_as_published = true; sub_opts[6].no_local = false; sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - uint8_t bytesprops0[] = {0x80, 0xf4, 0xb0, 0xbe, 0xc7, 0x15, 0x2d, 0xb7, 0xba, 0xb8, 0xe1, 0x72, 0xf2, 0xca, 0x63, - 0xed, 0x12, 0xfb, 0xe9, 0x3e, 0x66, 0xdc, 0x12, 0x92, 0x48, 0xa0, 0xe9, 0xa6, 0x71}; - uint8_t bytesprops1[] = {0x8f, 0xfc, 0xf7, 0x53, 0xbd, 0x1e, 0x45, 0xa5, 0xbe, 0x42, 0xad, 0x41, 0x62, 0x5e, - 0xd, 0x20, 0xd9, 0xaa, 0x10, 0xd6, 0x8e, 0x5d, 0x40, 0x56, 0xa5, 0x39, 0xb9, 0x4c}; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17001}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28027, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8552, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 16403 [("36\t\GS\147",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS1}),("\219(\232\129\147/\NAKI\148\189\191\241l\207\134M; -// \146\255\164\SI\129\251\252g\253\DLE=",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("\178]k\204\209\202\239\157m\227\SI\182M\tft\NUL?\184]}\128\149%\202\234",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(",\249N\129\196\212+ft,\180\v\166\t\164j\DEL\ETB\SYNC\244GIO\203\176\180|\148",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropRequestProblemInformation -// 104,PropMessageExpiryInterval 8176,PropServerReference -// "$;3O@\155\252;\218*\227\DC2\171A\142~\169\&4\154i\ETX\FS\134\216\215\200\FS.",PropTopicAlias 3118,PropMaximumQoS -// 36,PropAuthenticationData "\146\t",PropResponseTopic -// "\153\138\ETBB\224C\196\174\224\ESC\EOT\249\vHT\163/\208e\192\215\&1\238\213\179O\224",PropTopicAlias -// 3095,PropReasonString -// "\212U\142\147\208\216\242\NAK\212\160\153\198\149\205\216\n\154\171\SUB\146\135:`:\186\SO\178B\GS\192",PropSharedSubscriptionAvailable -// 17,PropSubscriptionIdentifier 16,PropMessageExpiryInterval 4489,PropReceiveMaximum 32086,PropTopicAliasMaximum -// 29734,PropWillDelayInterval 24777,PropMaximumQoS 102,PropServerReference -// "\189\DLE\136lf\172\162ON",PropSubscriptionIdentifierAvailable 80,PropRequestProblemInformation -// 86,PropRetainAvailable 104,PropSharedSubscriptionAvailable 21,PropMaximumQoS 169,PropServerReference -// "\ETX9\150\170\210\235",PropAuthenticationData -// "\165`\DC1\240\DEL\STX\FS\EMH\CAN\179\197\147\249\215\209.\223\DC1\t\162o\164",PropRetainAvailable -// 155,PropUserProperty "\\\194\166?\"\207\143&hS\150\&2\193\180\162W\v" -// "\167\144AL,\160\184\231\185\231\ESC\209\&3\132\208\STXO\DLE\158b",PropSubscriptionIdentifier -// 28,PropMessageExpiryInterval 25290,PropServerReference "\159\235\tf -// ~\148\239\212\243e4iyG\177\198,\177o\218\228fb\182y\141\205P",PropAssignedClientIdentifier -// "\189\ESC!O\GS\248\FS\224^X\ETB}\142\DC4\DC1|T\243\226\218\145d\232\191\153[\129\253\ACK\ETX"] +// SubscribeRequest 21918 [("\253`\DLE\211u\248\DLE\EM\254\171\202\139\231",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\232K\189x\159_\CAN>\184'\159\128dT\156,Sx",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\143\f\GS\206\232\253e\EOTnk\201\SOH\129\176\DLE}\249\186\178*\248C\143\134\192\232\DC1T",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\152\143d\215c\ACK\243*\227%\223e5a\210z}\170=7%c\157",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\213\\n\ETX\EM\163L\232\170",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),(".",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\130$g=T];\221D\158\145\220\214\154",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = False, _subQoS = QoS1}),(")?Gbx/Ti\252/-\ACK\149\&5\176\184\156\\\CAN\ENQ\GS\191",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\139~1f\212\151\NUL\158C_8P",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS2}),("mt\246\185$\ENQjC\163\161\DC1\CAN\195\SO-i\224\241\208m",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] +// [PropReceiveMaximum 15228,PropPayloadFormatIndicator 153,PropMessageExpiryInterval 10918,PropAuthenticationMethod +// "\253\155)\236",PropAssignedClientIdentifier "\199Oy9\184\130\214SC",PropPayloadFormatIndicator +// 206,PropCorrelationData "\138v>\252\195\147\131\201\248\214W\210",PropRetainAvailable 151,PropPayloadFormatIndicator +// 31,PropMaximumQoS 75,PropReasonString "\212\f",PropSessionExpiryInterval 3402,PropAuthenticationMethod +// "?\181\217\248\DC3gG\177P\232\153\215\182\146\224\197\USyy",PropRequestProblemInformation 35,PropTopicAlias +// 15652,PropAuthenticationData "\DLE3|",PropUserProperty "A\213\211+eKtm2Yi\193\166\138" +// "\220\&4zq&|p\131M\167\NAK\SOHB\168d(u\SOH\254\187\196",PropAuthenticationMethod +// "\DEL",PropWildcardSubscriptionAvailable 87,PropAuthenticationData "\214_\a\ESC\180\155",PropWillDelayInterval +// 16782,PropSubscriptionIdentifier 31,PropCorrelationData "\144\154c\128\FS\142\252\231\234\129:V +// \130\DC3\DC3{\215\199\185K\EOTM\172Q\128\150\208[\128\164\149",PropUserProperty ",bEZ\239\ESC\SOH\148_\ETXo" -// "A:I\242\215o\237\194\183\224\133",PropUserProperty "\129\183 \220\212\DC4']\180\247\ACK" -// "\140W\224.P\SYNpR\a\236$~\254\137\204\150",PropReceiveMaximum 32665,PropServerKeepAlive 9559,PropRetainAvailable -// 138] +// SubscribeRequest 32402 [("\222d\154J\229\133\152\210\152Q\129\228R\184<\202\149\147\206\245\169",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\195\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS +// = QoS1})] [] TEST(Subscribe5QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0xfc, 0x1, 0x64, 0x93, 0x64, 0x23, 0x26, 0x8f, 0x28, 0xf5, 0x29, 0x99, 0x1f, 0x0, 0x17, 0xbd, - 0xe1, 0x4b, 0xc9, 0x9, 0x3e, 0x13, 0x7b, 0xd7, 0xc7, 0xb9, 0x4b, 0x4, 0x4d, 0xac, 0x51, 0x80, 0x96, - 0xd0, 0x5b, 0x80, 0xa4, 0x95, 0x26, 0x0, 0xb, 0x2c, 0x62, 0x45, 0x5a, 0xef, 0x1b, 0x1, 0x94, 0x5f, - 0x3, 0x6f, 0x0, 0xb, 0x41, 0x3a, 0x49, 0xf2, 0xd7, 0x6f, 0xed, 0xc2, 0xb7, 0xe0, 0x85, 0x26, 0x0, - 0xb, 0x81, 0xb7, 0x20, 0xdc, 0xd4, 0x14, 0x27, 0x5d, 0xb4, 0xf7, 0x6, 0x0, 0x10, 0x8c, 0x57, 0xe0, - 0x2e, 0x50, 0x16, 0x70, 0x52, 0x7, 0xec, 0x24, 0x7e, 0xfe, 0x89, 0xcc, 0x96, 0x21, 0x7f, 0x99, 0x13, - 0x25, 0x57, 0x25, 0x8a, 0x0, 0x19, 0x3a, 0xa3, 0x69, 0xbe, 0x8d, 0xbc, 0x64, 0xd0, 0x34, 0x2, 0x8, - 0x19, 0x6e, 0x17, 0x2e, 0x79, 0xc0, 0xe6, 0x6b, 0x4f, 0xb1, 0xcc, 0x27, 0x9c, 0xce, 0x1, 0x0, 0x1b, - 0xb8, 0xc8, 0x90, 0x73, 0x49, 0x67, 0xf8, 0xd, 0xb5, 0x3c, 0xbb, 0x0, 0xcf, 0xa0, 0x59, 0x89, 0x49, - 0xe0, 0x97, 0x5d, 0x55, 0x27, 0x67, 0x5b, 0xb, 0x6, 0x72, 0x10, 0x0, 0x0, 0x18, 0x0, 0x9, 0x88, - 0x9f, 0xa1, 0x17, 0x97, 0xd3, 0x24, 0x80, 0x45, 0x0, 0x0, 0x8, 0x76, 0x7, 0x79, 0xd, 0x41, 0xd2, - 0x12, 0xf3, 0x15, 0x0, 0x1b, 0x65, 0xae, 0x71, 0x8b, 0x55, 0x91, 0x8b, 0x20, 0x8c, 0xee, 0x69, 0x98, - 0x3f, 0xf4, 0xef, 0x6, 0x42, 0x4e, 0xf8, 0xda, 0xbc, 0xee, 0x7f, 0x75, 0x4, 0x5, 0x2f, 0x2c, 0x0, - 0x15, 0x2c, 0xc4, 0x90, 0x36, 0x24, 0x1f, 0x13, 0xd4, 0xc3, 0x6e, 0x1e, 0x95, 0x8c, 0xcc, 0x7d, 0xeb, - 0x95, 0x12, 0xea, 0xfe, 0xc, 0x1c, 0x0, 0x8, 0x5b, 0xf1, 0x85, 0x6d, 0x23, 0xf0, 0x23, 0xaf, 0x2}; + uint8_t pkt[] = {0x82, 0x20, 0x7e, 0x92, 0x0, 0x0, 0x15, 0xde, 0x64, 0x9a, 0x4a, 0xe5, 0x85, 0x98, 0xd2, 0x98, 0x51, + 0x81, 0xe4, 0x52, 0xb8, 0x3c, 0xca, 0x95, 0x93, 0xce, 0xf5, 0xa9, 0x11, 0x0, 0x2, 0xc3, 0xba, 0xd}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x3a, 0xa3, 0x69, 0xbe, 0x8d, 0xbc, 0x64, 0xd0, 0x34, 0x2, 0x8, 0x19, 0x6e, - 0x17, 0x2e, 0x79, 0xc0, 0xe6, 0x6b, 0x4f, 0xb1, 0xcc, 0x27, 0x9c, 0xce}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xde, 0x64, 0x9a, 0x4a, 0xe5, 0x85, 0x98, 0xd2, 0x98, 0x51, 0x81, + 0xe4, 0x52, 0xb8, 0x3c, 0xca, 0x95, 0x93, 0xce, 0xf5, 0xa9}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb8, 0xc8, 0x90, 0x73, 0x49, 0x67, 0xf8, 0xd, 0xb5, 0x3c, 0xbb, 0x0, 0xcf, 0xa0, - 0x59, 0x89, 0x49, 0xe0, 0x97, 0x5d, 0x55, 0x27, 0x67, 0x5b, 0xb, 0x6, 0x72}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc3, 0xba}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x88, 0x9f, 0xa1, 0x17, 0x97, 0xd3, 0x24, 0x80, 0x45}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x76, 0x7, 0x79, 0xd, 0x41, 0xd2, 0x12, 0xf3}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x65, 0xae, 0x71, 0x8b, 0x55, 0x91, 0x8b, 0x20, 0x8c, 0xee, 0x69, 0x98, 0x3f, 0xf4, - 0xef, 0x6, 0x42, 0x4e, 0xf8, 0xda, 0xbc, 0xee, 0x7f, 0x75, 0x4, 0x5, 0x2f}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x2c, 0xc4, 0x90, 0x36, 0x24, 0x1f, 0x13, 0xd4, 0xc3, 0x6e, 0x1e, - 0x95, 0x8c, 0xcc, 0x7d, 0xeb, 0x95, 0x12, 0xea, 0xfe, 0xc}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x5b, 0xf1, 0x85, 0x6d, 0x23, 0xf0, 0x23, 0xaf}; - lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; + lwmqtt_sub_options_t sub_opts[2]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - uint8_t bytesprops0[] = {0xbd, 0xe1, 0x4b, 0xc9, 0x9, 0x3e, 0x13, 0x7b, 0xd7, 0xc7, 0xb9, 0x4b, - 0x4, 0x4d, 0xac, 0x51, 0x80, 0x96, 0xd0, 0x5b, 0x80, 0xa4, 0x95}; - uint8_t bytesprops2[] = {0x41, 0x3a, 0x49, 0xf2, 0xd7, 0x6f, 0xed, 0xc2, 0xb7, 0xe0, 0x85}; - uint8_t bytesprops1[] = {0x2c, 0x62, 0x45, 0x5a, 0xef, 0x1b, 0x1, 0x94, 0x5f, 0x3, 0x6f}; - uint8_t bytesprops4[] = {0x8c, 0x57, 0xe0, 0x2e, 0x50, 0x16, 0x70, 0x52, - 0x7, 0xec, 0x24, 0x7e, 0xfe, 0x89, 0xcc, 0x96}; - uint8_t bytesprops3[] = {0x81, 0xb7, 0x20, 0xdc, 0xd4, 0x14, 0x27, 0x5d, 0xb4, 0xf7, 0x6}; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9871}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops3}, .v = {16, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32665}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9559}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 138}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25747, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32402, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeResponse 8450 [Right QoS0] [] +// SubscribeResponse 9775 [Left SubErrUnspecifiedError,Right QoS1,Left SubErrUnspecifiedError,Left +// SubErrSharedSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode1) { - uint8_t pkt[] = {0x90, 0x3, 0x21, 0x2, 0x0}; + uint8_t pkt[] = {0x90, 0x6, 0x26, 0x2f, 0x80, 0x1, 0x80, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8450); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); -} - -// SubscribeResponse 20275 [Right QoS2,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Right QoS2,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Right QoS2] [] -TEST(SubACK311QCTest, Decode2) { - uint8_t pkt[] = {0x90, 0xb, 0x4f, 0x33, 0x2, 0x0, 0x97, 0x0, 0x2, 0x9e, 0x97, 0x80, 0x2}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 20275); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 9775); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x80); } -// SubscribeResponse 3848 [Right QoS0,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Right QoS2,Left -// SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError,Right QoS1,Right QoS0] [] -TEST(SubACK311QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0xb, 0xf, 0x8, 0x0, 0x97, 0x80, 0x2, 0x91, 0x87, 0x83, 0x1, 0x0}; +// SubscribeResponse 5148 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left SubErrQuotaExceeded,Right +// QoS2,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right +// QoS2] [] +TEST(SubACK311QCTest, Decode2) { + uint8_t pkt[] = {0x90, 0xc, 0x14, 0x1c, 0x9e, 0x0, 0x97, 0x2, 0xa2, 0x0, 0x1, 0x0, 0x87, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3848); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(packet_id, 5148); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); } -// SubscribeResponse 21048 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Left -// SubErrSubscriptionIdentifiersNotSupported,Left SubErrUnspecifiedError,Right QoS1,Left SubErrUnspecifiedError] [] -TEST(SubACK311QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0x8, 0x52, 0x38, 0xa2, 0x2, 0xa1, 0x80, 0x1, 0x80}; +// SubscribeResponse 6967 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS2,Right QoS2] [] +TEST(SubACK311QCTest, Decode3) { + uint8_t pkt[] = {0x90, 0x7, 0x1b, 0x37, 0xa2, 0x2, 0x1, 0x2, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21048); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 6967); + EXPECT_EQ(count, 5); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); } -// SubscribeResponse 24181 [Right QoS0,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS0] [] -TEST(SubACK311QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0x6, 0x5e, 0x75, 0x0, 0x80, 0x87, 0x0}; +// SubscribeResponse 10422 [Right QoS1,Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported] [] +TEST(SubACK311QCTest, Decode4) { + uint8_t pkt[] = {0x90, 0x6, 0x28, 0xb6, 0x1, 0x0, 0x2, 0xa2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[4]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24181); + EXPECT_EQ(packet_id, 10422); EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x80); } -// SubscribeResponse 29704 [Right QoS2,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS0,Right -// QoS1] [] -TEST(SubACK311QCTest, Decode6) { - uint8_t pkt[] = {0x90, 0x8, 0x74, 0x8, 0x2, 0x1, 0x9e, 0x0, 0x0, 0x1}; +// SubscribeResponse 9120 [Left SubErrTopicFilterInvalid,Right QoS0,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Left +// SubErrImplementationSpecificError] [] +TEST(SubACK311QCTest, Decode5) { + uint8_t pkt[] = {0x90, 0x8, 0x23, 0xa0, 0x8f, 0x0, 0x0, 0x97, 0x0, 0x83}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[6]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29704); + EXPECT_EQ(packet_id, 9120); EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x80); +} + +// SubscribeResponse 32151 [Right QoS2,Left SubErrNotAuthorized,Right QoS1,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS0] [] +TEST(SubACK311QCTest, Decode6) { + uint8_t pkt[] = {0x90, 0x7, 0x7d, 0x97, 0x2, 0x87, 0x1, 0xa2, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 32151); + EXPECT_EQ(count, 5); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 8 [Right QoS2] [] +// SubscribeResponse 26123 [Right QoS1,Right QoS0,Right QoS2] [] TEST(SubACK311QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0x3, 0x0, 0x8, 0x2}; + uint8_t pkt[] = {0x90, 0x5, 0x66, 0xb, 0x1, 0x0, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 26123); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); } -// SubscribeResponse 24329 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Right QoS2,Right QoS0,Right QoS0,Right -// QoS1,Right QoS2] [] +// SubscribeResponse 29973 [Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrImplementationSpecificError,Right +// QoS0,Right QoS2,Right QoS1] [] TEST(SubACK311QCTest, Decode8) { - uint8_t pkt[] = {0x90, 0xc, 0x5f, 0x9, 0x2, 0x9e, 0xa2, 0x80, 0x0, 0x2, 0x0, 0x0, 0x1, 0x2}; + uint8_t pkt[] = {0x90, 0x8, 0x75, 0x15, 0x2, 0x91, 0x83, 0x0, 0x2, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24329); - EXPECT_EQ(count, 10); + EXPECT_EQ(packet_id, 29973); + EXPECT_EQ(count, 6); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 10189 [Left SubErrImplementationSpecificError,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS2,Left SubErrUnspecifiedError,Right QoS1,Left -// SubErrImplementationSpecificError,Right QoS2,Left SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left -// SubErrWildcardSubscriptionsNotSupported] [] +// SubscribeResponse 14366 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS1,Left +// SubErrSharedSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode9) { - uint8_t pkt[] = {0x90, 0xd, 0x27, 0xcd, 0x83, 0x0, 0x9e, 0x2, 0x80, 0x1, 0x83, 0x2, 0x83, 0x97, 0xa2}; + uint8_t pkt[] = {0x90, 0x6, 0x38, 0x1e, 0x9e, 0x2, 0x1, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10189); - EXPECT_EQ(count, 11); + EXPECT_EQ(packet_id, 14366); + EXPECT_EQ(count, 4); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], 0x80); - EXPECT_EQ(granted_qos_levels[10], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); } -// SubscribeResponse 11213 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right QoS0,Right -// QoS0,Right QoS0,Right QoS2,Left SubErrTopicFilterInvalid] [] +// SubscribeResponse 10906 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right +// QoS1,Left SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Left SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0x9, 0x2b, 0xcd, 0x9e, 0x97, 0x0, 0x0, 0x0, 0x2, 0x8f}; + uint8_t pkt[] = {0x90, 0xd, 0x2a, 0x9a, 0x80, 0xa2, 0x2, 0x1, 0x91, 0x87, 0x83, 0x9e, 0x1, 0x8f, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11213); - EXPECT_EQ(count, 7); + EXPECT_EQ(packet_id, 10906); + EXPECT_EQ(count, 11); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 16288 [Right QoS0,Right QoS1,Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Left -// SubErrNotAuthorized,Right QoS1,Right QoS1,Right QoS2,Left SubErrNotAuthorized] [] +// SubscribeResponse 11558 [Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Left +// SubErrUnspecifiedError,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded,Left +// SubErrNotAuthorized,Right QoS0,Right QoS2,Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError] [] TEST(SubACK311QCTest, Decode11) { - uint8_t pkt[] = {0x90, 0xb, 0x3f, 0xa0, 0x0, 0x1, 0x80, 0x80, 0x87, 0x1, 0x1, 0x2, 0x87}; + uint8_t pkt[] = {0x90, 0xc, 0x2d, 0x26, 0x83, 0x80, 0x80, 0xa1, 0x97, 0x87, 0x0, 0x2, 0x97, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 16288); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 11558); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], 0x80); } -// SubscribeResponse 12823 [Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported] [] +// SubscribeResponse 9362 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrPacketIdentifierInUse,Left +// SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode12) { - uint8_t pkt[] = {0x90, 0x6, 0x32, 0x17, 0x8f, 0xa1, 0x0, 0x9e}; + uint8_t pkt[] = {0x90, 0x5, 0x24, 0x92, 0xa1, 0x91, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12823); - EXPECT_EQ(count, 4); + EXPECT_EQ(packet_id, 9362); + EXPECT_EQ(count, 3); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); } -// SubscribeResponse 27996 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS2,Left -// SubErrImplementationSpecificError,Right QoS1,Right QoS2,Left SubErrUnspecifiedError,Left -// SubErrTopicFilterInvalid,Left SubErrPacketIdentifierInUse,Left SubErrSharedSubscriptionsNotSupported] [] +// SubscribeResponse 23793 [Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS2,Right QoS0,Left SubErrImplementationSpecificError,Right +// QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Right QoS0] [] TEST(SubACK311QCTest, Decode13) { - uint8_t pkt[] = {0x90, 0xc, 0x6d, 0x5c, 0x9e, 0x2, 0x2, 0x83, 0x1, 0x2, 0x80, 0x8f, 0x91, 0x9e}; + uint8_t pkt[] = {0x90, 0xc, 0x5c, 0xf1, 0xa2, 0x9e, 0x1, 0x2, 0x0, 0x83, 0x0, 0x9e, 0x9e, 0x0}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[10]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27996); + EXPECT_EQ(packet_id, 23793); EXPECT_EQ(count, 10); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[7], 0x80); EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); } -// SubscribeResponse 30878 [Left SubErrUnspecifiedError,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left -// SubErrTopicFilterInvalid,Right QoS0] [] +// SubscribeResponse 11397 [Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError,Left +// SubErrTopicFilterInvalid,Right QoS1,Right QoS0,Right QoS1,Right QoS1] [] TEST(SubACK311QCTest, Decode14) { - uint8_t pkt[] = {0x90, 0xa, 0x78, 0x9e, 0x80, 0x1, 0xa2, 0x80, 0xa2, 0x80, 0x8f, 0x0}; + uint8_t pkt[] = {0x90, 0xd, 0x2c, 0x85, 0x8f, 0xa1, 0x0, 0xa2, 0x1, 0x83, 0x8f, 0x1, 0x0, 0x1, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 30878); - EXPECT_EQ(count, 8); + EXPECT_EQ(packet_id, 11397); + EXPECT_EQ(count, 11); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[5], 0x80); EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS1); } -// SubscribeResponse 7754 [Right QoS0,Right QoS2,Right QoS1,Right QoS1,Right QoS1,Right QoS2,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS0,Right QoS1,Left -// SubErrSubscriptionIdentifiersNotSupported] [] +// SubscribeResponse 5337 [Left SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0xd, 0x1e, 0x4a, 0x0, 0x2, 0x1, 0x1, 0x1, 0x2, 0x9e, 0x1, 0x0, 0x1, 0xa1}; + uint8_t pkt[] = {0x90, 0x3, 0x14, 0xd9, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7754); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[10], 0x80); + EXPECT_EQ(packet_id, 5337); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], 0x80); } -// SubscribeResponse 29991 [Left SubErrPacketIdentifierInUse,Right QoS1,Right QoS0,Left -// SubErrPacketIdentifierInUse,Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS0] [] +// SubscribeResponse 32213 [Left SubErrQuotaExceeded,Right QoS0,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1] [] TEST(SubACK311QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0xb, 0x75, 0x27, 0x91, 0x1, 0x0, 0x91, 0x1, 0x1, 0x83, 0xa1, 0x0}; + uint8_t pkt[] = {0x90, 0x8, 0x7d, 0xd5, 0x97, 0x0, 0x0, 0x9e, 0xa2, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29991); - EXPECT_EQ(count, 9); + EXPECT_EQ(packet_id, 32213); + EXPECT_EQ(count, 6); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x80); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); } -// SubscribeResponse 6273 [Right QoS1,Right QoS0] [] +// SubscribeResponse 1504 [Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS1,Right QoS1] [] TEST(SubACK311QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0x4, 0x18, 0x81, 0x1, 0x0}; + uint8_t pkt[] = {0x90, 0x8, 0x5, 0xe0, 0xa1, 0x9e, 0x1, 0x8f, 0x1, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6273); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 1504); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 10407 [Left SubErrUnspecifiedError] [] +// SubscribeResponse 2008 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right +// QoS2,Left SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode18) { - uint8_t pkt[] = {0x90, 0x3, 0x28, 0xa7, 0x80}; + uint8_t pkt[] = {0x90, 0x7, 0x7, 0xd8, 0x2, 0x9e, 0x91, 0x2, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10407); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(packet_id, 2008); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); } -// SubscribeResponse 13436 [Left SubErrPacketIdentifierInUse,Left SubErrImplementationSpecificError,Left -// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left SubErrNotAuthorized,Right QoS0,Right QoS1,Left -// SubErrQuotaExceeded,Right QoS0,Right QoS0] [] +// SubscribeResponse 19894 [Left SubErrNotAuthorized,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrQuotaExceeded] [] TEST(SubACK311QCTest, Decode19) { - uint8_t pkt[] = {0x90, 0xc, 0x34, 0x7c, 0x91, 0x83, 0x83, 0x97, 0x87, 0x0, 0x1, 0x97, 0x0, 0x0}; + uint8_t pkt[] = {0x90, 0x8, 0x4d, 0xb6, 0x87, 0x9e, 0xa1, 0x0, 0xa1, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13436); - EXPECT_EQ(count, 10); + EXPECT_EQ(packet_id, 19894); + EXPECT_EQ(count, 6); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x80); } -// SubscribeResponse 634 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left -// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported] -// [] +// SubscribeResponse 12423 [Left SubErrNotAuthorized,Right QoS0,Right QoS2,Right QoS2] [] TEST(SubACK311QCTest, Decode20) { - uint8_t pkt[] = {0x90, 0x9, 0x2, 0x7a, 0x2, 0x91, 0x1, 0x83, 0x97, 0x0, 0xa2}; + uint8_t pkt[] = {0x90, 0x6, 0x30, 0x87, 0x87, 0x0, 0x2, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 634); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x80); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 12423); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); } -// SubscribeResponse 742 [Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrPacketIdentifierInUse,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Right QoS1,Left SubErrTopicFilterInvalid] [] +// SubscribeResponse 21901 [Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError,Right QoS0,Right QoS0] [] TEST(SubACK311QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0xb, 0x2, 0xe6, 0x0, 0xa1, 0x91, 0x2, 0x9e, 0x83, 0x97, 0x1, 0x8f}; + uint8_t pkt[] = {0x90, 0x6, 0x55, 0x8d, 0x97, 0x83, 0x0, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 742); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 21901); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); } -// SubscribeResponse 14677 [Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrTopicFilterInvalid] [] +// SubscribeResponse 9953 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1] [] TEST(SubACK311QCTest, Decode22) { - uint8_t pkt[] = {0x90, 0x5, 0x39, 0x55, 0x8f, 0x0, 0x8f}; + uint8_t pkt[] = {0x90, 0x5, 0x26, 0xe1, 0x0, 0xa2, 0x1}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[3]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14677); + EXPECT_EQ(packet_id, 9953); EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); } -// SubscribeResponse 22954 [Right QoS1,Left SubErrTopicFilterInvalid,Left SubErrQuotaExceeded,Right QoS0,Left -// SubErrUnspecifiedError] [] +// SubscribeResponse 21846 [Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Right QoS2,Right +// QoS1,Right QoS0,Right QoS0,Left SubErrImplementationSpecificError,Left SubErrTopicFilterInvalid,Right QoS2] [] TEST(SubACK311QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0x7, 0x59, 0xaa, 0x1, 0x8f, 0x97, 0x0, 0x80}; + uint8_t pkt[] = {0x90, 0xb, 0x55, 0x56, 0x8f, 0x83, 0x2, 0x1, 0x0, 0x0, 0x83, 0x8f, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 22954); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 21846); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); } -// SubscribeResponse 18733 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrPacketIdentifierInUse,Right QoS2,Right QoS1,Right QoS1] [] +// SubscribeResponse 25983 [Right QoS2] [] TEST(SubACK311QCTest, Decode24) { - uint8_t pkt[] = {0x90, 0x8, 0x49, 0x2d, 0x2, 0xa2, 0x91, 0x2, 0x1, 0x1}; + uint8_t pkt[] = {0x90, 0x3, 0x65, 0x7f, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18733); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 25983); + EXPECT_EQ(count, 1); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 22455 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left -// SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded,Right QoS0,Left -// SubErrTopicFilterInvalid,Right QoS1,Right QoS1] [] +// SubscribeResponse 803 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrNotAuthorized,Right +// QoS2,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [] TEST(SubACK311QCTest, Decode25) { - uint8_t pkt[] = {0x90, 0xb, 0x57, 0xb7, 0x9e, 0x97, 0x8f, 0xa1, 0x97, 0x0, 0x8f, 0x1, 0x1}; + uint8_t pkt[] = {0x90, 0x8, 0x3, 0x23, 0x0, 0xa2, 0x87, 0x2, 0xa1, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 22455); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(packet_id, 803); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 556 [Right QoS1,Left SubErrImplementationSpecificError,Right QoS1] [] +// SubscribeResponse 6677 [Right QoS0,Right QoS1,Left SubErrTopicFilterInvalid,Left +// SubErrImplementationSpecificError,Right QoS0,Right QoS1,Right QoS2,Right QoS2,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrNotAuthorized,Right QoS0] [] TEST(SubACK311QCTest, Decode26) { - uint8_t pkt[] = {0x90, 0x5, 0x2, 0x2c, 0x1, 0x83, 0x1}; + uint8_t pkt[] = {0x90, 0xd, 0x1a, 0x15, 0x0, 0x1, 0x8f, 0x83, 0x0, 0x1, 0x2, 0x2, 0xa1, 0x87, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 556); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 6677); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); } -// SubscribeResponse 15417 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Left SubErrNotAuthorized] -// [] +// SubscribeResponse 7481 [Left SubErrNotAuthorized,Right QoS1,Right QoS2,Left SubErrNotAuthorized] [] TEST(SubACK311QCTest, Decode27) { - uint8_t pkt[] = {0x90, 0x6, 0x3c, 0x39, 0x2, 0xa2, 0x0, 0x87}; + uint8_t pkt[] = {0x90, 0x6, 0x1d, 0x39, 0x87, 0x1, 0x2, 0x87}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[4]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15417); + EXPECT_EQ(packet_id, 7481); EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[3], 0x80); } -// SubscribeResponse 26950 [Left SubErrImplementationSpecificError,Right QoS2,Right QoS2,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [] +// SubscribeResponse 26117 [Right QoS2,Right QoS0,Right QoS0] [] TEST(SubACK311QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0x7, 0x69, 0x46, 0x83, 0x2, 0x2, 0xa1, 0x1}; + uint8_t pkt[] = {0x90, 0x5, 0x66, 0x5, 0x2, 0x0, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26950); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 26117); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); } -// SubscribeResponse 24196 [Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Left -// SubErrImplementationSpecificError,Right QoS0,Right QoS0,Left SubErrTopicFilterInvalid,Left -// SubErrPacketIdentifierInUse,Right QoS2] [] +// SubscribeResponse 4603 [Left SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0xb, 0x5e, 0x84, 0x9e, 0x1, 0x8f, 0x83, 0x0, 0x0, 0x8f, 0x91, 0x2}; + uint8_t pkt[] = {0x90, 0x3, 0x11, 0xfb, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24196); - EXPECT_EQ(count, 9); + EXPECT_EQ(packet_id, 4603); + EXPECT_EQ(count, 1); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); } -// SubscribeResponse 19551 [Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrUnspecifiedError,Right QoS1,Right -// QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrQuotaExceeded,Right QoS0] [] +// SubscribeResponse 32025 [Left SubErrPacketIdentifierInUse] [] TEST(SubACK311QCTest, Decode30) { - uint8_t pkt[] = {0x90, 0xc, 0x4c, 0x5f, 0x91, 0x2, 0x80, 0x1, 0x2, 0x91, 0x1, 0x9e, 0x97, 0x0}; + uint8_t pkt[] = {0x90, 0x3, 0x7d, 0x19, 0x91}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19551); - EXPECT_EQ(count, 10); + EXPECT_EQ(packet_id, 32025); + EXPECT_EQ(count, 1); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); } -// SubscribeResponse 8450 [Right QoS0] [PropResponseInformation "\253u\180K`\159\150\fE\153}H",PropReceiveMaximum -// 24891,PropMaximumPacketSize 28088] +// SubscribeResponse 9775 [Left SubErrUnspecifiedError,Right QoS1,Left SubErrUnspecifiedError,Left +// SubErrSharedSubscriptionsNotSupported] [PropAuthenticationData +// "\234\f\220v\216\CAN\145\150Z\136\149e\141\251\177Y",PropMaximumQoS 189,PropMaximumQoS 26,PropServerKeepAlive +// 13776,PropSubscriptionIdentifierAvailable 80,PropReceiveMaximum 20785,PropMaximumQoS +// 175,PropSharedSubscriptionAvailable 235,PropAssignedClientIdentifier "\135\196u\130(",PropAuthenticationData +// "\169=0K\139C\199\228|8a\167A\131\251\170\248\253\173p\GS0\DC1\218:",PropRequestResponseInformation +// 90,PropMessageExpiryInterval 19327,PropAuthenticationMethod +// "\246++\171\157\242\170b\130\146\170\166\196\r\162{e\ETB\139wB\DC4<\ACK",PropReceiveMaximum 22897,PropResponseTopic +// "6\149"] TEST(SubACK5QCTest, Decode1) { - uint8_t pkt[] = {0x90, 0x1b, 0x21, 0x2, 0x17, 0x1a, 0x0, 0xc, 0xfd, 0x75, 0xb4, 0x4b, 0x60, 0x9f, 0x96, - 0xc, 0x45, 0x99, 0x7d, 0x48, 0x21, 0x61, 0x3b, 0x27, 0x0, 0x0, 0x6d, 0xb8, 0x0}; + uint8_t pkt[] = {0x90, 0x78, 0x26, 0x2f, 0x71, 0x16, 0x0, 0x10, 0xea, 0xc, 0xdc, 0x76, 0xd8, 0x18, 0x91, 0x96, + 0x5a, 0x88, 0x95, 0x65, 0x8d, 0xfb, 0xb1, 0x59, 0x24, 0xbd, 0x24, 0x1a, 0x13, 0x35, 0xd0, 0x29, + 0x50, 0x21, 0x51, 0x31, 0x24, 0xaf, 0x2a, 0xeb, 0x12, 0x0, 0x5, 0x87, 0xc4, 0x75, 0x82, 0x28, + 0x16, 0x0, 0x19, 0xa9, 0x3d, 0x30, 0x4b, 0x8b, 0x43, 0xc7, 0xe4, 0x7c, 0x38, 0x61, 0xa7, 0x41, + 0x83, 0xfb, 0xaa, 0xf8, 0xfd, 0xad, 0x70, 0x1d, 0x30, 0x11, 0xda, 0x3a, 0x19, 0x5a, 0x2, 0x0, + 0x0, 0x4b, 0x7f, 0x15, 0x0, 0x18, 0xf6, 0x2b, 0x2b, 0xab, 0x9d, 0xf2, 0xaa, 0x62, 0x82, 0x92, + 0xaa, 0xa6, 0xc4, 0xd, 0xa2, 0x7b, 0x65, 0x17, 0x8b, 0x77, 0x42, 0x14, 0x3c, 0x6, 0x21, 0x59, + 0x71, 0x8, 0x0, 0x2, 0x36, 0x95, 0x80, 0x1, 0x80, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8450); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 9775); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x9E); } -// SubscribeResponse 20275 [Right QoS2,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Right QoS2,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Right QoS2] -// [PropAuthenticationData "\143\227\202\173[{\229$\148j<\161\220\DLE\204\194B",PropReasonString -// "rQ\202\231\161\&9\180\219\188\237\213U\157\233jKkC=\194\159\184T\187%\248\DC3j\156",PropSubscriptionIdentifierAvailable -// 97,PropWillDelayInterval 25789,PropTopicAliasMaximum 20234,PropServerKeepAlive 26883,PropPayloadFormatIndicator -// 65,PropWillDelayInterval 21939,PropServerReference -// "-\ETB\173\v\224\231Q\NAKr\b\196\158a\238\EM\185\244\&8h\152\UShJ\146",PropMaximumPacketSize -// 10688,PropWildcardSubscriptionAvailable 25,PropResponseInformation -// "\216\152\200\230\208o\208\DLE",PropAssignedClientIdentifier "\n",PropSessionExpiryInterval 20612,PropCorrelationData -// "\188{\132\187\247\ACK"] +// SubscribeResponse 5148 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left SubErrQuotaExceeded,Right +// QoS2,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right +// QoS2] [PropContentType "\207\134\165\ti\229",PropSharedSubscriptionAvailable 140,PropServerKeepAlive +// 25332,PropRequestResponseInformation 19,PropResponseTopic " +// \246\RS\136I\208\133\STX\153\171\"\249_\193X\b\183PW\SOL\235\215p"] TEST(SubACK5QCTest, Decode2) { - uint8_t pkt[] = {0x90, 0x94, 0x1, 0x4f, 0x33, 0x87, 0x1, 0x16, 0x0, 0x11, 0x8f, 0xe3, 0xca, 0xad, 0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9e, 0x0, 0x97, 0x2, 0xa2, 0x0, 0x1, 0x0, 0x87, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 20275); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 5148); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x9E); EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], 0x97); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x9E); - EXPECT_EQ(granted_qos_levels[6], 0x97); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0xA2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], 0x87); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); } -// SubscribeResponse 3848 [Right QoS0,Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Right QoS2,Left -// SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError,Right QoS1,Right QoS0] -// [PropTopicAliasMaximum 10554,PropSubscriptionIdentifierAvailable 81,PropTopicAlias 14436,PropReceiveMaximum -// 20441,PropCorrelationData "\148\162\129Gq\a\SYN\CAN\194\&4",PropResponseInformation -// "\231\CAN\128\ETXI\154\GS\249Jp\a.",PropSubscriptionIdentifierAvailable 23,PropContentType -// "\172\162&\f\194\135\128\154\DC32\179\222\&1\252\a\ACK\SIs!\DC4\185\131n;*",PropRetainAvailable -// 236,PropWillDelayInterval 13881,PropAuthenticationMethod -// "\228\216\192\DC3{W\USs\205\148F\192\&6a\204\152\242\&4\237?\169\174\216;\211\204\223\f",PropCorrelationData -// "\FS\SYN9\208\&2\146y\254\144\202g\234\161%\GSS\EOT0\226\162\SOH\137U",PropServerKeepAlive 25204] +// SubscribeResponse 6967 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS2,Right QoS2] +// [PropAssignedClientIdentifier "\ENQv\150\148=o\252S\153h",PropCorrelationData "\181\132\131",PropReasonString +// "\175\183\131\164\191\174\r\218g\149\128\222,\213]\188\ACK\131\191\&5",PropTopicAliasMaximum +// 24384,PropSubscriptionIdentifier 14,PropWillDelayInterval 7334,PropRequestProblemInformation 112,PropServerReference +// "\214\154\137\133\160\188\\K"] TEST(SubACK5QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0x95, 0x1, 0xf, 0x8, 0x88, 0x1, 0x22, 0x29, 0x3a, 0x29, 0x51, 0x23, 0x38, 0x64, 0x21, 0x4f, - 0xd9, 0x9, 0x0, 0xa, 0x94, 0xa2, 0x81, 0x47, 0x71, 0x7, 0x16, 0x18, 0xc2, 0x34, 0x1a, 0x0, 0xc, - 0xe7, 0x18, 0x80, 0x3, 0x49, 0x9a, 0x1d, 0xf9, 0x4a, 0x70, 0x7, 0x2e, 0x29, 0x17, 0x3, 0x0, 0x19, - 0xac, 0xa2, 0x26, 0xc, 0xc2, 0x87, 0x80, 0x9a, 0x13, 0x32, 0xb3, 0xde, 0x31, 0xfc, 0x7, 0x6, 0xf, - 0x73, 0x21, 0x14, 0xb9, 0x83, 0x6e, 0x3b, 0x2a, 0x25, 0xec, 0x18, 0x0, 0x0, 0x36, 0x39, 0x15, 0x0, - 0x1c, 0xe4, 0xd8, 0xc0, 0x13, 0x7b, 0x57, 0x1f, 0x73, 0xcd, 0x94, 0x46, 0xc0, 0x36, 0x61, 0xcc, 0x98, - 0xf2, 0x34, 0xed, 0x3f, 0xa9, 0xae, 0xd8, 0x3b, 0xd3, 0xcc, 0xdf, 0xc, 0x9, 0x0, 0x17, 0x1c, 0x16, - 0x39, 0xd0, 0x32, 0x92, 0x79, 0xfe, 0x90, 0xca, 0x67, 0xea, 0xa1, 0x25, 0x1d, 0x53, 0x4, 0x30, 0xe2, - 0xa2, 0x1, 0x89, 0x55, 0x13, 0x62, 0x74, 0x0, 0x97, 0x80, 0x2, 0x91, 0x87, 0x83, 0x1, 0x0}; + uint8_t pkt[] = {0x90, 0x49, 0x1b, 0x37, 0x41, 0x12, 0x0, 0xa, 0x5, 0x76, 0x96, 0x94, 0x3d, 0x6f, 0xfc, + 0x53, 0x99, 0x68, 0x9, 0x0, 0x3, 0xb5, 0x84, 0x83, 0x1f, 0x0, 0x14, 0xaf, 0xb7, 0x83, + 0xa4, 0xbf, 0xae, 0xd, 0xda, 0x67, 0x95, 0x80, 0xde, 0x2c, 0xd5, 0x5d, 0xbc, 0x6, 0x83, + 0xbf, 0x35, 0x22, 0x5f, 0x40, 0xb, 0xe, 0x18, 0x0, 0x0, 0x1c, 0xa6, 0x17, 0x70, 0x1c, + 0x0, 0x8, 0xd6, 0x9a, 0x89, 0x85, 0xa0, 0xbc, 0x5c, 0x4b, 0xa2, 0x2, 0x1, 0x2, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3848); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x97); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(packet_id, 6967); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0xA2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x91); - EXPECT_EQ(granted_qos_levels[5], 0x87); - EXPECT_EQ(granted_qos_levels[6], 0x83); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); } -// SubscribeResponse 21048 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Left -// SubErrSubscriptionIdentifiersNotSupported,Left SubErrUnspecifiedError,Right QoS1,Left SubErrUnspecifiedError] -// [PropReasonString "o\143\223\139\170\249\182\142\220\FS\DC4\214\173\NUL\234+p\177Zd\247\&1*V\140",PropContentType -// "\RS*\SUB\ESC\NAK\nB\224\173\214\212\163z/\225",PropRetainAvailable 255,PropResponseTopic -// "\191\STX\221\172j\247\210\208",PropPayloadFormatIndicator 92,PropPayloadFormatIndicator 61,PropWillDelayInterval -// 3196,PropMaximumQoS 45,PropSessionExpiryInterval 11712,PropSessionExpiryInterval 21681,PropSessionExpiryInterval -// 10572,PropWildcardSubscriptionAvailable 93,PropAuthenticationData "\196\236\231",PropMessageExpiryInterval -// 11997,PropReasonString "v\RS(+hC\194B",PropSubscriptionIdentifierAvailable 77,PropTopicAlias -// 14811,PropRetainAvailable 155,PropResponseTopic "\217\178q\229|\154[1\a\CAN\138 \166",PropReceiveMaximum -// 86,PropReceiveMaximum 17084,PropWildcardSubscriptionAvailable 136,PropReceiveMaximum 8446,PropContentType -// "\193\168\176\&6X\185\203\232\SOH\219\194\176\f;J\191\155\237\"\206\n\225\DC1",PropMessageExpiryInterval 7662] +// SubscribeResponse 10422 [Right QoS1,Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported] +// [PropCorrelationData "J",PropTopicAliasMaximum 11259,PropReceiveMaximum 24478,PropRetainAvailable +// 69,PropServerKeepAlive 15906,PropMessageExpiryInterval 21672,PropCorrelationData +// "\202\248\217\205\162\240L\181\164\DC2\DC19E\DEL\234\141\171\149/(A\131*",PropRequestResponseInformation +// 152,PropServerReference "\255\190\b\160\242\247\&9\153\191\145\158\SYNX\DC4^\239\145\181\142",PropResponseTopic +// "B2(\229\218\146",PropMessageExpiryInterval 11438,PropMessageExpiryInterval 15978,PropMaximumQoS +// 147,PropWillDelayInterval 27201,PropSubscriptionIdentifierAvailable 166,PropAssignedClientIdentifier +// "]\183\254\191\148\223\138\248\179\DC42_\170",PropWildcardSubscriptionAvailable 168,PropMaximumQoS +// 166,PropResponseInformation "\218\191o\170f\171\230k\242\&3\155\185\218\ESC\191\193E"] TEST(SubACK5QCTest, Decode4) { - uint8_t pkt[] = { - 0x90, 0xb8, 0x1, 0x52, 0x38, 0xae, 0x1, 0x1f, 0x0, 0x19, 0x6f, 0x8f, 0xdf, 0x8b, 0xaa, 0xf9, 0xb6, 0x8e, 0xdc, - 0x1c, 0x14, 0xd6, 0xad, 0x0, 0xea, 0x2b, 0x70, 0xb1, 0x5a, 0x64, 0xf7, 0x31, 0x2a, 0x56, 0x8c, 0x3, 0x0, 0xf, - 0x1e, 0x2a, 0x1a, 0x1b, 0x15, 0xa, 0x42, 0xe0, 0xad, 0xd6, 0xd4, 0xa3, 0x7a, 0x2f, 0xe1, 0x25, 0xff, 0x8, 0x0, - 0x8, 0xbf,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13, 0xff, 0xbe, 0x8, 0xa0, 0xf2, 0xf7, 0x39, 0x99, 0xbf, 0x91, + 0x9e, 0x16, 0x58, 0x14, 0x5e, 0xef, 0x91, 0xb5, 0x8e, 0x8, 0x0, 0x6, 0x42, 0x32, 0x28, 0xe5, 0xda, + 0x92, 0x2, 0x0, 0x0, 0x2c, 0xae, 0x2, 0x0, 0x0, 0x3e, 0x6a, 0x24, 0x93, 0x18, 0x0, 0x0, 0x6a, + 0x41, 0x29, 0xa6, 0x12, 0x0, 0xd, 0x5d, 0xb7, 0xfe, 0xbf, 0x94, 0xdf, 0x8a, 0xf8, 0xb3, 0x14, 0x32, + 0x5f, 0xaa, 0x28, 0xa8, 0x24, 0xa6, 0x1a, 0x0, 0x11, 0xda, 0xbf, 0x6f, 0xaa, 0x66, 0xab, 0xe6, 0x6b, + 0xf2, 0x33, 0x9b, 0xb9, 0xda, 0x1b, 0xbf, 0xc1, 0x45, 0x1, 0x0, 0x2, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21048); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], 0xA2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0xA1); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(packet_id, 10422); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0xA2); } -// SubscribeResponse 24181 [Right QoS0,Left SubErrUnspecifiedError,Left SubErrNotAuthorized,Right QoS0] [PropTopicAlias -// 30523,PropPayloadFormatIndicator 73,PropPayloadFormatIndicator 92,PropAuthenticationMethod -// "4\173\163\200\211\178\&3",PropMaximumPacketSize 30847,PropMaximumPacketSize 4545,PropRetainAvailable -// 244,PropSessionExpiryInterval 28627,PropAuthenticationData -// "\a1\238\201\DC4L?\207NRyxAd\165\179b\143",PropResponseTopic -// "\198i\220\134\GS\253\157\176\140\a\169\218\172\204",PropMaximumQoS 172,PropReceiveMaximum -// 24080,PropWillDelayInterval 10878] +// SubscribeResponse 9120 [Left SubErrTopicFilterInvalid,Right QoS0,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Left +// SubErrImplementationSpecificError] [PropSubscriptionIdentifierAvailable 68,PropReceiveMaximum 13676] TEST(SubACK5QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0x59, 0x5e, 0x75, 0x52, 0x23, 0x77, 0x3b, 0x1, 0x49, 0x1, 0x5c, 0x15, 0x0, 0x7, 0x34, - 0xad, 0xa3, 0xc8, 0xd3, 0xb2, 0x33, 0x27, 0x0, 0x0, 0x78, 0x7f, 0x27, 0x0, 0x0, 0x11, 0xc1, - 0x25, 0xf4, 0x11, 0x0, 0x0, 0x6f, 0xd3, 0x16, 0x0, 0x12, 0x7, 0x31, 0xee, 0xc9, 0x14, 0x4c, - 0x3f, 0xcf, 0x4e, 0x52, 0x79, 0x78, 0x41, 0x64, 0xa5, 0xb3, 0x62, 0x8f, 0x8, 0x0, 0xe, 0xc6, - 0x69, 0xdc, 0x86, 0x1d, 0xfd, 0x9d, 0xb0, 0x8c, 0x7, 0xa9, 0xda, 0xac, 0xcc, 0x24, 0xac, 0x21, - 0x5e, 0x10, 0x18, 0x0, 0x0, 0x2a, 0x7e, 0x0, 0x80, 0x87, 0x0}; + uint8_t pkt[] = {0x90, 0xe, 0x23, 0xa0, 0x5, 0x29, 0x44, 0x21, 0x35, 0x6c, 0x8f, 0x0, 0x0, 0x97, 0x0, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24181); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x87); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 9120); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0x8F); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x97); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x83); } -// SubscribeResponse 29704 [Right QoS2,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Right QoS0,Right -// QoS1] [PropSessionExpiryInterval 29415,PropSessionExpiryInterval 7070,PropReceiveMaximum 22071,PropResponseTopic -// "\226A\227\210\173\250\186\190\198\149p5\218\233k\154\153\135\161",PropMaximumPacketSize 29817,PropServerKeepAlive -// 22934,PropAssignedClientIdentifier "q\217\FS+u\251j\DEL\ACK\ETXc\146\233\190W#\168;\DC1\as -// \146\186",PropAssignedClientIdentifier -// "\168\197/\142\SUB)\DEL\192\164X\229\180\238\221{6\251k#\251\177?p\ESC-\230\229",PropServerReference -// "x\201\219#\195b`\144/Vs\128t\198\211\&7\160\CAN\190\DEL\EM>\151",PropCorrelationData -// "o\133c\153\191\&4\215%",PropTopicAlias 26118,PropSharedSubscriptionAvailable 115,PropCorrelationData -// "0{\216v\211ti\200\&3\"\177\173\143\210A\183\202\&3\145\176L\129\USJl\253",PropSessionExpiryInterval -// 18085,PropSharedSubscriptionAvailable 204,PropRequestResponseInformation 162,PropSubscriptionIdentifier -// 18,PropTopicAlias 29222,PropReceiveMaximum 26778,PropSessionExpiryInterval 21467,PropMessageExpiryInterval -// 25987,PropMaximumQoS 167,PropContentType -// "\252\143\173\221\235\141\145\138\NUL\254\NAK\175\201\234\193\255\218\150\182"] +// SubscribeResponse 32151 [Right QoS2,Left SubErrNotAuthorized,Right QoS1,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS0] [PropSubscriptionIdentifierAvailable 110,PropAuthenticationMethod +// "\EOT\150\215r\DC4yV\136\161\NAK\221\156\152F\249ROH",PropServerKeepAlive 19882,PropWillDelayInterval +// 1198,PropWillDelayInterval 3411,PropSubscriptionIdentifier 7,PropRequestResponseInformation 86,PropReceiveMaximum +// 19407,PropSubscriptionIdentifier 31,PropAuthenticationData "HLz\144",PropAssignedClientIdentifier +// "\ESC\133\212fS\163P1\238\&5\DC2g\DC3\232T\170\155u\203\202!\DC1\165\189",PropServerKeepAlive +// 25841,PropMessageExpiryInterval 14535,PropResponseTopic "'\228\220\199\175i\171\235V^8M\196X\243\154Q\US\151o\210 +// \158\&0\ETB\178\a_\249",PropMaximumQoS 88] TEST(SubACK5QCTest, Decode6) { - uint8_t pkt[] = {0x90, 0xe8, 0x1, 0x74, 0x8, 0xde, 0x1, 0x11, 0x0, 0x0, 0x72, 0xe7, 0x11, 0x0, 0x0, 0x1b, 0x9e, - 0x21, 0x56, 0x37, 0x8, 0x0, 0x13, 0xe2, 0x41, 0xe3, 0xd2, 0xad, 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, 0x8d, 0x91, 0x8a, 0x0, 0xfe, 0x15, - 0xaf, 0xc9, 0xea, 0xc1, 0xff, 0xda, 0x96, 0xb6, 0x2, 0x1, 0x9e, 0x0, 0x0, 0x1}; + uint8_t pkt[] = {0x90, 0x81, 0x1, 0x7d, 0x97, 0x79, 0x29, 0x6e, 0x15, 0x0, 0x12, 0x4, 0x96, 0xd7, 0x72, 0x14, 0x79, + 0x56, 0x88, 0xa1, 0x15, 0xdd, 0x9c, 0x98, 0x46, 0xf9, 0x52, 0x4f, 0x48, 0x13, 0x4d, 0xaa, 0x18, 0x0, + 0x0, 0x4, 0xae, 0x18, 0x0, 0x0, 0xd, 0x53, 0xb, 0x7, 0x19, 0x56, 0x21, 0x4b, 0xcf, 0xb, 0x1f, + 0x16, 0x0, 0x4, 0x48, 0x4c, 0x7a, 0x90, 0x12, 0x0, 0x18, 0x1b, 0x85, 0xd4, 0x66, 0x53, 0xa3, 0x50, + 0x31, 0xee, 0x35, 0x12, 0x67, 0x13, 0xe8, 0x54, 0xaa, 0x9b, 0x75, 0xcb, 0xca, 0x21, 0x11, 0xa5, 0xbd, + 0x13, 0x64, 0xf1, 0x2, 0x0, 0x0, 0x38, 0xc7, 0x8, 0x0, 0x1d, 0x27, 0xe4, 0xdc, 0xc7, 0xaf, 0x69, + 0xab, 0xeb, 0x56, 0x5e, 0x38, 0x4d, 0xc4, 0x58, 0xf3, 0x9a, 0x51, 0x1f, 0x97, 0x6f, 0xd2, 0x20, 0x9e, + 0x30, 0x17, 0xb2, 0x7, 0x5f, 0xf9, 0x24, 0x58, 0x2, 0x87, 0x1, 0xa2, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29704); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 32151); + EXPECT_EQ(count, 5); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x9E); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x87); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0xA2); EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 8 [Right QoS2] [PropAuthenticationMethod -// "\219\DC3\203\236\192<\167-\168*Q\133\138\ETX",PropSubscriptionIdentifierAvailable 27,PropAuthenticationData -// "\ESC\245r\158!\172\\u\184\USu\253f\164",PropSubscriptionIdentifier 30,PropMessageExpiryInterval -// 18702,PropPayloadFormatIndicator 181,PropReceiveMaximum 15038,PropWildcardSubscriptionAvailable -// 106,PropReceiveMaximum 24360,PropServerReference -// ">\133%\129\139\179\174\207\189\141l\ENQ\180\149\SYN'p\178\229\174\202",PropAuthenticationData -// "{\200\n\210\234]\233\130\204w \239\151:\228\&4\132+\234rY\176\SYN\249\&7\145\NAK\nd",PropResponseInformation -// "\215\251\159\227\154\130\234$\226\ACK\174\f\224#N\EM\254\205\151\141\192]s"] +// SubscribeResponse 26123 [Right QoS1,Right QoS0,Right QoS2] [PropSubscriptionIdentifier 29,PropResponseTopic +// "\211\252\208z\210\233\130\ETB\209?g)@",PropTopicAliasMaximum 12492,PropRetainAvailable 204,PropMessageExpiryInterval +// 130,PropReasonString "\RS4",PropAuthenticationMethod "",PropSessionExpiryInterval 6330,PropServerReference +// "\240\178",PropRequestResponseInformation 108,PropTopicAliasMaximum 7015,PropWillDelayInterval +// 3068,PropSharedSubscriptionAvailable 154,PropTopicAlias 14277,PropRetainAvailable 230] TEST(SubACK5QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0x8c, 0x1, 0x0, 0x8, 0x87, 0x1, 0x15, 0x0, 0xe, 0xdb, 0x13, 0xcb, 0xec, 0xc0, 0x3c, - 0xa7, 0x2d, 0xa8, 0x2a, 0x51, 0x85, 0x8a, 0x3, 0x29, 0x1b, 0x16, 0x0, 0xe, 0x1b, 0xf5, 0x72, - 0x9e, 0x21, 0xac, 0x5c, 0x75, 0xb8, 0x1f, 0x75, 0xfd, 0x66, 0xa4, 0xb, 0x1e, 0x2, 0x0, 0x0, - 0x49, 0xe, 0x1, 0xb5, 0x21, 0x3a, 0xbe, 0x28, 0x6a, 0x21, 0x5f, 0x28, 0x1c, 0x0, 0x15, 0x3e, - 0x85, 0x25, 0x81, 0x8b, 0xb3, 0xae, 0xcf, 0xbd, 0x8d, 0x6c, 0x5, 0xb4, 0x95, 0x16, 0x27, 0x70, - 0xb2, 0xe5, 0xae, 0xca, 0x16, 0x0, 0x1d, 0x7b, 0xc8, 0xa, 0xd2, 0xea, 0x5d, 0xe9, 0x82, 0xcc, - 0x77, 0x20, 0xef, 0x97, 0x3a, 0xe4, 0x34, 0x84, 0x2b, 0xea, 0x72, 0x59, 0xb0, 0x16, 0xf9, 0x37, - 0x91, 0x15, 0xa, 0x64, 0x1a, 0x0, 0x17, 0xd7, 0xfb, 0x9f, 0xe3, 0x9a, 0x82, 0xea, 0x24, 0xe2, - 0x6, 0xae, 0xc, 0xe0, 0x23, 0x4e, 0x19, 0xfe, 0xcd, 0x97, 0x8d, 0xc0, 0x5d, 0x73, 0x2}; + uint8_t pkt[] = {0x90, 0x45, 0x66, 0xb, 0x3f, 0xb, 0x1d, 0x8, 0x0, 0xd, 0xd3, 0xfc, 0xd0, 0x7a, 0xd2, + 0xe9, 0x82, 0x17, 0xd1, 0x3f, 0x67, 0x29, 0x40, 0x22, 0x30, 0xcc, 0x25, 0xcc, 0x2, 0x0, + 0x0, 0x0, 0x82, 0x1f, 0x0, 0x2, 0x1e, 0x34, 0x15, 0x0, 0x0, 0x11, 0x0, 0x0, 0x18, + 0xba, 0x1c, 0x0, 0x2, 0xf0, 0xb2, 0x19, 0x6c, 0x22, 0x1b, 0x67, 0x18, 0x0, 0x0, 0xb, + 0xfc, 0x2a, 0x9a, 0x23, 0x37, 0xc5, 0x25, 0xe6, 0x1, 0x0, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 26123); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); } -// SubscribeResponse 24329 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Right QoS2,Right QoS0,Right QoS0,Right -// QoS1,Right QoS2] [PropSessionExpiryInterval 3602,PropResponseTopic -// "/5x\ETBj\ACK0\DC3q\176\252\191\150\234\214\236\193\249\167\&5\225\&2\215\195i\132",PropCorrelationData -// "\198ww\135\192\229\234",PropReceiveMaximum 21158,PropResponseTopic -// "\255\a\ACKU\RSN\NAK5=\185,j\162",PropUserProperty "p1\CAN\188\144\DC4\146\207Q" -// "\NUL+\214\149G\195xo\177>\ACK\SYN\167\&2\220 \183\156\247\142#\196\STX\ETX{N0\220\230\243",PropTopicAlias -// 32590,PropRetainAvailable 229,PropServerKeepAlive 13344,PropSharedSubscriptionAvailable 121,PropUserProperty -// "@2K?\\\231\252\221\212S.\190\140\227\189\FSL\185\137\179\&7!\132\130\SUB\t\163\149\211" -// "\132#{\178\\\172\250\219\US\STX\ETB",PropSessionExpiryInterval 16041,PropReasonString -// "\249\165\157\CANk!\166\237\DC1\228\228O\187\STX\SYNT\170e\ETB>\167\151m\200\253r1r\GS\SOH",PropRequestProblemInformation -// 224,PropReasonString "B\244\133n{\179\DC1\129yE",PropResponseTopic -// "\177\171\SOm\243\192\vy=\182\133",PropReceiveMaximum 10480,PropAuthenticationData -// "\DC4q\131\160\239\241}^e\192m\252\187D\169\azt\239\DC1\EOT\RS",PropTopicAliasMaximum 11512,PropMessageExpiryInterval -// 6187,PropSubscriptionIdentifierAvailable 243,PropServerReference "\\\227\180",PropMessageExpiryInterval -// 6636,PropUserProperty "\241\243\139\207Fh\EM\GSo:\ESC" "\173\229{>\233\247-\SOHp",PropServerReference -// "",PropSubscriptionIdentifier 23] +// SubscribeResponse 29973 [Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrImplementationSpecificError,Right +// QoS0,Right QoS2,Right QoS1] [PropSharedSubscriptionAvailable 1] TEST(SubACK5QCTest, Decode8) { - uint8_t pkt[] = { - 0x90, 0xc2, 0x2, 0x5f, 0x9, 0xb4, 0x2, 0x11, 0x0, 0x0, 0xe, 0x12, 0x8, 0x0, 0x1a, 0x2f, 0x35, 0x78, 0x17, - 0x6a, 0x6, 0x30, 0x13, 0x71, 0xb0, 0xfc, 0xbf, 0x96, 0xea, 0xd6, 0xec, 0xc1, 0xf9, 0xa7, 0x35, 0xe1, 0x32, 0xd7, - 0xc3, 0x69, 0x84, 0x9, 0x0, 0x7, 0xc6, 0x77, 0x77, 0x87, 0xc0, 0xe5, 0xea, 0x21, 0x52, 0xa6, 0x8, 0x0, 0xd, - 0xff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14, 0x71, 0x83, 0xa0, 0xef, - 0xf1, 0x7d, 0x5e, 0x65, 0xc0, 0x6d, 0xfc, 0xbb, 0x44, 0xa9, 0x7, 0x7a, 0x74, 0xef, 0x11, 0x4, 0x1e, 0x22, 0x2c, - 0xf8, 0x2, 0x0, 0x0, 0x18, 0x2b, 0x29, 0xf3, 0x1c, 0x0, 0x3, 0x5c, 0xe3, 0xb4, 0x2, 0x0, 0x0, 0x19, 0xec, - 0x26, 0x0, 0xb, 0xf1, 0xf3, 0x8b, 0xcf, 0x46, 0x68, 0x19, 0x1d, 0x6f, 0x3a, 0x1b, 0x0, 0x9, 0xad, 0xe5, 0x7b, - 0x3e, 0xe9, 0xf7, 0x2d, 0x1, 0x70, 0x1c, 0x0, 0x0, 0xb, 0x17, 0x2, 0x9e, 0xa2, 0x80, 0x0, 0x2, 0x0, 0x0, - 0x1, 0x2}; + uint8_t pkt[] = {0x90, 0xb, 0x75, 0x15, 0x2, 0x2a, 0x1, 0x2, 0x91, 0x83, 0x0, 0x2, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24329); - EXPECT_EQ(count, 10); + EXPECT_EQ(packet_id, 29973); + EXPECT_EQ(count, 6); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x9E); - EXPECT_EQ(granted_qos_levels[2], 0xA2); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x91); + EXPECT_EQ(granted_qos_levels[2], 0x83); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 10189 [Left SubErrImplementationSpecificError,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS2,Left SubErrUnspecifiedError,Right QoS1,Left -// SubErrImplementationSpecificError,Right QoS2,Left SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left -// SubErrWildcardSubscriptionsNotSupported] [PropAssignedClientIdentifier -// "\ETX\142\176\SI\135\229\156\165\&6TU\141\EOTR\196\ETBn&I~qx\220\SOD\ETB\183",PropSessionExpiryInterval -// 23384,PropUserProperty "\229\&7_'\206\145\128_\222C\153" ")*",PropAuthenticationData "=",PropPayloadFormatIndicator -// 144,PropMessageExpiryInterval 32480,PropCorrelationData -// "\SI\162JG\DC1\244\150\234\151\&2r\207\133\158\a\199&I\225\139\246E\v",PropMaximumQoS -// 76,PropSharedSubscriptionAvailable 193,PropReasonString "\177",PropRequestProblemInformation -// 85,PropAssignedClientIdentifier "T\179\"",PropAssignedClientIdentifier -// "AC}\ETX@\152H\238\150\154\185\ESC",PropResponseInformation "tM\128\192\157\173A",PropRetainAvailable -// 52,PropUserProperty "Z\153\222\f\RS\128t` 4\177\150\&5n\DC1\CANZx\207\DLE\\\GS\250\DC13\194\v" -// "_\245\182K\158",PropWillDelayInterval 30645,PropWildcardSubscriptionAvailable 207] +// SubscribeResponse 14366 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS1,Left +// SubErrSharedSubscriptionsNotSupported] [PropResponseInformation +// "\249\249\190\245\ESC\233z\156\130c\162\SO8?\ESCI\150g\vt\161",PropMessageExpiryInterval 25992,PropContentType +// "\181\v\225\135\SYN\STXUpqu\215\251p\147\DEL\215k\168\r?\GS",PropReasonString +// "\245F\211\152nT\167\232z\216\226\250\NAK\132\232\200\&3",PropAuthenticationMethod +// "\tF\STX\ETB\207.\DC2k\207\181\183c\128e\183\164\225:\198b\131A:\161\216",PropSessionExpiryInterval +// 13747,PropCorrelationData "dJ\150h\185\131\227\172\197;7!\147\151\131\230\ETX\161",PropCorrelationData +// "",PropMessageExpiryInterval 27691,PropSubscriptionIdentifier 2,PropUserProperty ",\224\220U" +// "*\218\139\184\251\223-vb\247\&8&\NAKm;\215\DC11>x\142\250\224$u",PropWildcardSubscriptionAvailable +// 53,PropRequestProblemInformation 219,PropRetainAvailable 131,PropMessageExpiryInterval +// 2028,PropRequestResponseInformation 217,PropRetainAvailable 152,PropRetainAvailable 2,PropRequestResponseInformation +// 108,PropMaximumQoS 202,PropTopicAlias 28925,PropServerKeepAlive 18424] TEST(SubACK5QCTest, Decode9) { - uint8_t pkt[] = {0x90, 0xc0, 0x1, 0x27, 0xcd, 0xb1, 0x1, 0x12, 0x0, 0x1b, 0x3, 0x8e, 0xb0, 0xf, 0x87, 0xe5, 0x9c, - 0xa5, 0x36, 0x54, 0x55, 0x8d, 0x4, 0x52, 0xc4, 0x17, 0x6e, 0x26, 0x49, 0x7e, 0x71, 0x78, 0xdc, 0xe, - 0x44, 0x17, 0xb7, 0x11, 0x0, 0x0, 0x5b, 0x58, 0x26, 0x0, 0xb, 0xe5, 0x37, 0x5f, 0x27, 0xce, 0x91, - 0x80, 0x5f, 0xde, 0x43, 0x99, 0x0, 0x2, 0x29, 0x2a, 0x16, 0x0, 0x1, 0x3d, 0x1, 0x90, 0x2, 0x0, - 0x0, 0x7e, 0xe0, 0x9, 0x0, 0x17, 0xf, 0xa2, 0x4a, 0x47, 0x11, 0xf4, 0x96, 0xea, 0x97,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0xe2, 0xfa, 0x15, + 0x84, 0xe8, 0xc8, 0x33, 0x15, 0x0, 0x19, 0x9, 0x46, 0x2, 0x17, 0xcf, 0x2e, 0x12, 0x6b, 0xcf, 0xb5, 0xb7, 0x63, + 0x80, 0x65, 0xb7, 0xa4, 0xe1, 0x3a, 0xc6, 0x62, 0x83, 0x41, 0x3a, 0xa1, 0xd8, 0x11, 0x0, 0x0, 0x35, 0xb3, 0x9, + 0x0, 0x12, 0x64, 0x4a, 0x96, 0x68, 0xb9, 0x83, 0xe3, 0xac, 0xc5, 0x3b, 0x37, 0x21, 0x93, 0x97, 0x83, 0xe6, 0x3, + 0xa1, 0x9, 0x0, 0x0, 0x2, 0x0, 0x0, 0x6c, 0x2b, 0xb, 0x2, 0x26, 0x0, 0x4, 0x2c, 0xe0, 0xdc, 0x55, 0x0, + 0x19, 0x2a, 0xda, 0x8b, 0xb8, 0xfb, 0xdf, 0x2d, 0x76, 0x62, 0xf7, 0x38, 0x26, 0x15, 0x6d, 0x3b, 0xd7, 0x11, 0x31, + 0x3e, 0x78, 0x8e, 0xfa, 0xe0, 0x24, 0x75, 0x28, 0x35, 0x17, 0xdb, 0x25, 0x83, 0x2, 0x0, 0x0, 0x7, 0xec, 0x19, + 0xd9, 0x25, 0x98, 0x25, 0x2, 0x19, 0x6c, 0x24, 0xca, 0x23, 0x70, 0xfd, 0x13, 0x47, 0xf8, 0x9e, 0x2, 0x1, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10189); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x83); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x9E); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x83); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], 0x83); - EXPECT_EQ(granted_qos_levels[9], 0x97); - EXPECT_EQ(granted_qos_levels[10], 0xA2); + EXPECT_EQ(packet_id, 14366); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x9E); } -// SubscribeResponse 11213 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Right QoS0,Right -// QoS0,Right QoS0,Right QoS2,Left SubErrTopicFilterInvalid] [] +// SubscribeResponse 10906 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right +// QoS1,Left SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Left SubErrTopicFilterInvalid] +// [PropRequestResponseInformation 143,PropResponseTopic +// "p\DC2\EOT\"\197]\158\199\GS6\US\176\SIK\170\152\134\\\ETXF\231\210\219\195\204\GS\DC3\228A",PropServerKeepAlive +// 19736,PropSubscriptionIdentifier 13,PropAuthenticationMethod "\182>\232\218\NAK\221\DC3 +// \DC3\157\175",PropMaximumPacketSize 28526,PropResponseTopic +// "\214P\235\164\151]\147\STX\b\SYNi\144]&g\142\145U\139q",PropReceiveMaximum 14778,PropRequestProblemInformation +// 80,PropRequestProblemInformation 53,PropSubscriptionIdentifierAvailable 113,PropServerKeepAlive +// 11340,PropReceiveMaximum 3459,PropMaximumQoS 115,PropMessageExpiryInterval 13266,PropAssignedClientIdentifier +// "\DEL\179\247\171h\174\243",PropContentType "\145Z\249W\157\159D\206m}V\250E\234\229",PropAuthenticationData +// "\240\182",PropServerKeepAlive 14931,PropRequestProblemInformation 2,PropMaximumPacketSize 23805] TEST(SubACK5QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0xa, 0x2b, 0xcd, 0x0, 0x9e, 0x97, 0x0, 0x0, 0x0, 0x2, 0x8f}; + uint8_t pkt[] = {0x90, 0xa1, 0x1, 0x2a, 0x9a, 0x92, 0x1, 0x19, 0x8f, 0x8, 0x0, 0x1d, 0x70, 0x12, 0x4, 0x22, 0xc5, + 0x5d, 0x9e, 0xc7, 0x1d, 0x36, 0x1f, 0xb0, 0xf, 0x4b, 0xaa, 0x98, 0x86, 0x5c, 0x3, 0x46, 0xe7, 0xd2, + 0xdb, 0xc3, 0xcc, 0x1d, 0x13, 0xe4, 0x41, 0x13, 0x4d, 0x18, 0xb, 0xd, 0x15, 0x0, 0xb, 0xb6, 0x3e, + 0xe8, 0xda, 0x15, 0xdd, 0x13, 0x20, 0x13, 0x9d, 0xaf, 0x27, 0x0, 0x0, 0x6f, 0x6e, 0x8, 0x0, 0x14, + 0xd6, 0x50, 0xeb, 0xa4, 0x97, 0x5d, 0x93, 0x2, 0x8, 0x16, 0x69, 0x90, 0x5d, 0x26, 0x67, 0x8e, 0x91, + 0x55, 0x8b, 0x71, 0x21, 0x39, 0xba, 0x17, 0x50, 0x17, 0x35, 0x29, 0x71, 0x13, 0x2c, 0x4c, 0x21, 0xd, + 0x83, 0x24, 0x73, 0x2, 0x0, 0x0, 0x33, 0xd2, 0x12, 0x0, 0x7, 0x7f, 0xb3, 0xf7, 0xab, 0x68, 0xae, + 0xf3, 0x3, 0x0, 0xf, 0x91, 0x5a, 0xf9, 0x57, 0x9d, 0x9f, 0x44, 0xce, 0x6d, 0x7d, 0x56, 0xfa, 0x45, + 0xea, 0xe5, 0x16, 0x0, 0x2, 0xf0, 0xb6, 0x13, 0x3a, 0x53, 0x17, 0x2, 0x27, 0x0, 0x0, 0x5c, 0xfd, + 0x80, 0xa2, 0x2, 0x1, 0x91, 0x87, 0x83, 0x9e, 0x1, 0x8f, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11213); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], 0x97); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0x8F); + EXPECT_EQ(packet_id, 10906); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x91); + EXPECT_EQ(granted_qos_levels[5], 0x87); + EXPECT_EQ(granted_qos_levels[6], 0x83); + EXPECT_EQ(granted_qos_levels[7], 0x9E); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[9], 0x8F); + EXPECT_EQ(granted_qos_levels[10], 0x8F); } -// SubscribeResponse 16288 [Right QoS0,Right QoS1,Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Left -// SubErrNotAuthorized,Right QoS1,Right QoS1,Right QoS2,Left SubErrNotAuthorized] [PropTopicAliasMaximum -// 30519,PropAssignedClientIdentifier "\233\239U\129J\243",PropMessageExpiryInterval 32558,PropUserProperty -// "\140\191\189\162\129\153\128\203\DLEp\205" "\172\213\&7\228\140\170",PropSharedSubscriptionAvailable -// 227,PropCorrelationData -// "\159\199\&7X\\\t\169\209V\180C\206\158\198x,c\n|X\GS\214\165?%\128\199\131\131",PropSharedSubscriptionAvailable -// 133,PropRequestResponseInformation 128,PropServerReference "\230\155\144#\146\251\DELPI",PropSessionExpiryInterval -// 4721,PropContentType "\177d\239L\196",PropServerKeepAlive 26462,PropResponseTopic -// "\223\197\139",PropRequestProblemInformation 137,PropWillDelayInterval 16506,PropMessageExpiryInterval -// 3229,PropMaximumPacketSize 30608,PropServerKeepAlive 5792,PropSessionExpiryInterval 5438,PropServerReference "\201"] +// SubscribeResponse 11558 [Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Left +// SubErrUnspecifiedError,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded,Left +// SubErrNotAuthorized,Right QoS0,Right QoS2,Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError] +// [PropResponseInformation "3\SUB\158\ESC\144g\231\155\234/\171",PropSessionExpiryInterval +// 24450,PropPayloadFormatIndicator 177] TEST(SubACK5QCTest, Decode11) { - uint8_t pkt[] = {0x90, 0x99, 0x1, 0x3f, 0xa0, 0x8c, 0x1, 0x22, 0x77, 0x37, 0x12, 0x0, 0x6, 0xe9, 0xef, 0x55, - 0x81, 0x4a, 0xf3, 0x2, 0x0, 0x0, 0x7f, 0x2e, 0x26, 0x0, 0xb, 0x8c, 0xbf, 0xbd, 0xa2, 0x81, - 0x99, 0x80, 0xcb, 0x10, 0x70, 0xcd, 0x0, 0x6, 0xac, 0xd5, 0x37, 0xe4, 0x8c, 0xaa, 0x2a, 0xe3, - 0x9, 0x0, 0x1d, 0x9f, 0xc7, 0x37, 0x58, 0x5c, 0x9, 0xa9, 0xd1, 0x56, 0xb4, 0x43, 0xce, 0x9e, - 0xc6, 0x78, 0x2c, 0x63, 0xa, 0x7c, 0x58, 0x1d, 0xd6, 0xa5, 0x3f, 0x25, 0x80, 0xc7, 0x83, 0x83, - 0x2a, 0x85, 0x19, 0x80, 0x1c, 0x0, 0x9, 0xe6, 0x9b, 0x90, 0x23, 0x92, 0xfb, 0x7f, 0x50, 0x49, - 0x11, 0x0, 0x0, 0x12, 0x71, 0x3, 0x0, 0x5, 0xb1, 0x64, 0xef, 0x4c, 0xc4, 0x13, 0x67, 0x5e, - 0x8, 0x0, 0x3, 0xdf, 0xc5, 0x8b, 0x17, 0x89, 0x18, 0x0, 0x0, 0x40, 0x7a, 0x2, 0x0, 0x0, - 0xc, 0x9d, 0x27, 0x0, 0x0, 0x77, 0x90, 0x13, 0x16, 0xa0, 0x11, 0x0, 0x0, 0x15, 0x3e, 0x1c, - 0x0, 0x1, 0xc9, 0x0, 0x1, 0x80, 0x80, 0x87, 0x1, 0x1, 0x2, 0x87}; + uint8_t pkt[] = {0x90, 0x22, 0x2d, 0x26, 0x15, 0x1a, 0x0, 0xb, 0x33, 0x1a, 0x9e, 0x1b, + 0x90, 0x67, 0xe7, 0x9b, 0xea, 0x2f, 0xab, 0x11, 0x0, 0x0, 0x5f, 0x82, + 0x1, 0xb1, 0x83, 0x80, 0x80, 0xa1, 0x97, 0x87, 0x0, 0x2, 0x97, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[10]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 16288); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 11558); + EXPECT_EQ(count, 10); + EXPECT_EQ(granted_qos_levels[0], 0x83); + EXPECT_EQ(granted_qos_levels[1], 0x80); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x87); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0xA1); + EXPECT_EQ(granted_qos_levels[4], 0x97); + EXPECT_EQ(granted_qos_levels[5], 0x87); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], 0x87); + EXPECT_EQ(granted_qos_levels[8], 0x97); + EXPECT_EQ(granted_qos_levels[9], 0x83); } -// SubscribeResponse 12823 [Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported] [PropCorrelationData "\181\216w _\250\170I\a",PropUserProperty -// "\174\196\238\142\&6N\212\r+\GS\b\231\192IT\198l\129\217c\163nq\185" "p\154\162\140`",PropPayloadFormatIndicator -// 64,PropMessageExpiryInterval 2937,PropMaximumQoS 140,PropContentType "\FS\227!",PropContentType -// "/~*\155\194\159]\161Z\192\184\238\SOH\244\131\188\188e\198]\165\244\130",PropRequestProblemInformation -// 85,PropRequestProblemInformation 65,PropSubscriptionIdentifier 18,PropTopicAlias 24580,PropReceiveMaximum -// 215,PropSharedSubscriptionAvailable 136,PropRetainAvailable 236,PropSessionExpiryInterval 15801,PropTopicAliasMaximum -// 8932,PropPayloadFormatIndicator 162,PropReceiveMaximum 27309,PropWillDelayInterval -// 22879,PropRequestProblemInformation 244,PropUserProperty "\186r" -// "B\242|$\ENQd\137\247B\200\&0\252\153\DC1\189\251\EOT)X",PropResponseTopic -// "\196\133\188\245\r\183",PropAuthenticationData -// "u@\182\ETX\192{\196\STX\175\135\196LR\166\209\&7E)N\138\159\204B\204\SUB",PropContentType -// "$\v\152'L\184\242",PropServerReference "\178 \186\207\147>\158u\NAKh\215\EOT\ACK\191\181",PropWillDelayInterval -// 5469,PropMessageExpiryInterval 27203] +// SubscribeResponse 9362 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrPacketIdentifierInUse,Left +// SubErrTopicFilterInvalid] [PropCorrelationData +// "\195\153!\134/\183\202\231\ENQ1\247e\162\&0\202k6",PropTopicAliasMaximum 3409,PropSubscriptionIdentifierAvailable +// 195,PropTopicAliasMaximum 14152,PropSubscriptionIdentifier 16,PropAuthenticationMethod +// "\182\191%p\205JB\254\175\130\SO\235x4Y\ETX\192",PropWillDelayInterval 19872,PropMaximumQoS 150] TEST(SubACK5QCTest, Decode12) { - uint8_t pkt[] = {0x90, 0xe8, 0x1, 0x32, 0x17, 0xe0, 0x1, 0x9, 0x0, 0x9, 0xb5, 0xd8, 0x77, 0x20, 0x5f, 0xfa, 0xaa, - 0x49, 0x7, 0x26, 0x0, 0x18, 0xae, 0xc4, 0xee, 0x8e, 0x36, 0x4e, 0xd4, 0xd, 0x2b, 0x1d, 0x8, 0xe7, - 0xc0, 0x49, 0x54, 0xc6, 0x6c, 0x81, 0xd9, 0x63, 0xa3, 0x6e, 0x71, 0xb9, 0x0, 0x5, 0x70, 0x9a, 0xa2, - 0x8c, 0x60, 0x1, 0x40, 0x2, 0x0, 0x0, 0xb, 0x79, 0x24, 0x8c, 0x3, 0x0, 0x3, 0x1c, 0xe3, 0x21, - 0x3, 0x0, 0x17, 0x2f, 0x7e, 0x2a, 0x9b, 0xc2, 0x9f, 0x5d, 0xa1, 0x5a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0x37, 0x48, 0xb, + 0x10, 0x15, 0x0, 0x11, 0xb6, 0xbf, 0x25, 0x70, 0xcd, 0x4a, 0x42, 0xfe, 0xaf, 0x82, 0xe, 0xeb, 0x78, + 0x34, 0x59, 0x3, 0xc0, 0x18, 0x0, 0x0, 0x4d, 0xa0, 0x24, 0x96, 0xa1, 0x91, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12823); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], 0x8F); - EXPECT_EQ(granted_qos_levels[1], 0xA1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x9E); + EXPECT_EQ(packet_id, 9362); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], 0x91); + EXPECT_EQ(granted_qos_levels[2], 0x8F); } -// SubscribeResponse 27996 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS2,Left -// SubErrImplementationSpecificError,Right QoS1,Right QoS2,Left SubErrUnspecifiedError,Left -// SubErrTopicFilterInvalid,Left SubErrPacketIdentifierInUse,Left SubErrSharedSubscriptionsNotSupported] -// [PropRequestProblemInformation 225,PropReceiveMaximum 12966,PropMaximumPacketSize 9315,PropSubscriptionIdentifier -// 22,PropContentType "\242\143",PropReasonString "y",PropContentType "\221\186\187\DLE!\219F",PropTopicAlias -// 31775,PropSharedSubscriptionAvailable 225,PropPayloadFormatIndicator 94,PropRequestResponseInformation 212] +// SubscribeResponse 23793 [Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS2,Right QoS0,Left SubErrImplementationSpecificError,Right +// QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Right QoS0] +// [PropAuthenticationData "\218J\135\ACK]\180\255\&7\144\212\v\167H\249$t\153C\222(TEp\220\156$",PropAuthenticationData +// "\223\165^.3{\SUB\213\151\RS\227w!\144\ACKMY\r\198\158\211\250^[\ENQ\238A\SUB\247",PropCorrelationData +// "qN\171\212\209f\NAK9\157\254\225pZ\156\DLEI\173\185\\",PropMessageExpiryInterval 4328,PropMessageExpiryInterval +// 1128,PropSubscriptionIdentifier 21,PropServerReference "\224\158\nd\221\SO\248\222v",PropServerReference +// "\164\233",PropAssignedClientIdentifier "\NAKm@sFU\170A\232\200\166ha\208",PropContentType +// "e\209P\236\130\184\130\138Yf\152f\ETX5X\175",PropRetainAvailable 24,PropRetainAvailable +// 194,PropMessageExpiryInterval 2103,PropWildcardSubscriptionAvailable 90,PropPayloadFormatIndicator +// 104,PropSubscriptionIdentifier 11,PropWildcardSubscriptionAvailable 69,PropReasonString +// "3\255\243",PropRequestResponseInformation 218,PropWillDelayInterval 8806] TEST(SubACK5QCTest, Decode13) { - uint8_t pkt[] = {0x90, 0x35, 0x6d, 0x5c, 0x28, 0x17, 0xe1, 0x21, 0x32, 0xa6, 0x27, 0x0, 0x0, 0x24, - 0x63, 0xb, 0x16, 0x3, 0x0, 0x2, 0xf2, 0x8f, 0x1f, 0x0, 0x1, 0x79, 0x3, 0x0, - 0x7, 0xdd, 0xba, 0xbb, 0x10, 0x21, 0xdb, 0x46, 0x23, 0x7c, 0x1f, 0x2a, 0xe1, 0x1, - 0x5e, 0x19, 0xd4, 0x9e, 0x2, 0x2, 0x83, 0x1, 0x2, 0x80, 0x8f, 0x91, 0x9e}; + uint8_t pkt[] = {0x90, 0xc0, 0x1, 0x5c, 0xf1, 0xb2, 0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t packet_id; int count; lwmqtt_qos_t granted_qos_levels[10]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27996); + EXPECT_EQ(packet_id, 23793); EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x83); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x8F); - EXPECT_EQ(granted_qos_levels[8], 0x91); - EXPECT_EQ(granted_qos_levels[9], 0x9E); + EXPECT_EQ(granted_qos_levels[0], 0xA2); + EXPECT_EQ(granted_qos_levels[1], 0x9E); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x83); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[7], 0x9E); + EXPECT_EQ(granted_qos_levels[8], 0x9E); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); } -// SubscribeResponse 30878 [Left SubErrUnspecifiedError,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Left -// SubErrTopicFilterInvalid,Right QoS0] [PropWildcardSubscriptionAvailable 185] +// SubscribeResponse 11397 [Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError,Left +// SubErrTopicFilterInvalid,Right QoS1,Right QoS0,Right QoS1,Right QoS1] [PropServerKeepAlive +// 1598,PropSubscriptionIdentifier 11,PropMessageExpiryInterval 3147,PropReasonString +// "W\247\177\220\221\211\134o8\198\199\237\135SW\167eo\174\f\165\165\226\US\v",PropRequestResponseInformation +// 114,PropReasonString "\STX\187\".\226i\180'",PropRequestResponseInformation 81,PropTopicAlias +// 21854,PropResponseInformation "\DEL\254b)A\131\204(\227\194\226\202",PropCorrelationData +// "\235\185\201\&8\152iV",PropMaximumPacketSize 4310,PropMessageExpiryInterval 6070,PropServerReference +// "M\231\232Vv?m0\SO\214#\143\"\238\133\199+sc",PropTopicAlias 26799,PropRequestResponseInformation +// 100,PropServerReference "\220",PropResponseInformation "\254!-\245C",PropContentType +// "\162\197\244\DC4L\RSPM~2P8\217\132\204>\201\227X\251\134\251",PropSharedSubscriptionAvailable 103,PropReceiveMaximum +// 26130,PropCorrelationData "\NUL\153v\179j\197#\192\235t\164\221V\NAK|i0"] TEST(SubACK5QCTest, Decode14) { - uint8_t pkt[] = {0x90, 0xd, 0x78, 0x9e, 0x2, 0x28, 0xb9, 0x80, 0x1, 0xa2, 0x80, 0xa2, 0x80, 0x8f, 0x0}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[8]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 30878); - EXPECT_EQ(count, 8); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0xA2); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0xA2); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x8F); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); -} - -// SubscribeResponse 7754 [Right QoS0,Right QoS2,Right QoS1,Right QoS1,Right QoS1,Right QoS2,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS0,Right QoS1,Left -// SubErrSubscriptionIdentifiersNotSupported] [PropAuthenticationMethod -// "\139\254\DC4\195\152n\197k\139\CAN\241/",PropSubscriptionIdentifier 10,PropReasonString -// "p\148(\243\SO\251\216$5\205\163\DEL\148\245\f",PropResponseInformation -// "\165\n\DC4\SYN\178\185\135\214\SO\150`\218!\t-\159\fv\248\STX,\193\159 Y"] -TEST(SubACK5QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0x4d, 0x1e, 0x4a, 0x3f, 0x15, 0x0, 0xc, 0x8b, 0xfe, 0x14, 0xc3, 0x98, 0x6e, 0xc5, 0x6b, - 0x8b, 0x18, 0xf1, 0x2f, 0xb, 0xa, 0x1f, 0x0, 0xf, 0x70, 0x94, 0x28, 0xf3, 0xe, 0xfb, 0xd8, - 0x24, 0x35, 0xcd, 0xa3, 0x7f, 0x94, 0xf5, 0xc, 0x1a, 0x0, 0x19, 0xa5, 0xa, 0x14, 0x16, 0xb2, - 0xb9, 0x87, 0xd6, 0xe, 0x96, 0x60, 0xda, 0x21, 0x9, 0x2d, 0x9f, 0xc, 0x76, 0xf8, 0x2, 0x2c, - 0xc1, 0x9f, 0x20, 0x59, 0x0, 0x2, 0x1, 0x1, 0x1, 0x2, 0x9e, 0x1, 0x0, 0x1, 0xa1}; + uint8_t pkt[] = {0x90, 0xc3, 0x1, 0x2c, 0x85, 0xb4, 0x1, 0x13, 0x6, 0x3e, 0xb, 0xb, 0x2, 0x0, 0x0, 0xc, 0x4b, + 0x1f, 0x0, 0x19, 0x57, 0xf7, 0xb1, 0xdc, 0xdd, 0xd3, 0x86, 0x6f, 0x38, 0xc6, 0xc7, 0xed, 0x87, 0x53, + 0x57, 0xa7, 0x65, 0x6f, 0xae, 0xc, 0xa5, 0xa5, 0xe2, 0x1f, 0xb, 0x19, 0x72, 0x1f, 0x0, 0x8, 0x2, + 0xbb, 0x22, 0x2e, 0xe2, 0x69, 0xb4, 0x27, 0x19, 0x51, 0x23, 0x55, 0x5e, 0x1a, 0x0, 0xc, 0x7f, 0xfe, + 0x62, 0x29, 0x41, 0x83, 0xcc, 0x28, 0xe3, 0xc2, 0xe2, 0xca, 0x9, 0x0, 0x7, 0xeb, 0xb9, 0xc9, 0x38, + 0x98, 0x69, 0x56, 0x27, 0x0, 0x0, 0x10, 0xd6, 0x2, 0x0, 0x0, 0x17, 0xb6, 0x1c, 0x0, 0x13, 0x4d, + 0xe7, 0xe8, 0x56, 0x76, 0x3f, 0x6d, 0x30, 0xe, 0xd6, 0x23, 0x8f, 0x22, 0xee, 0x85, 0xc7, 0x2b, 0x73, + 0x63, 0x23, 0x68, 0xaf, 0x19, 0x64, 0x1c, 0x0, 0x1, 0xdc, 0x1a, 0x0, 0x5, 0xfe, 0x21, 0x2d, 0xf5, + 0x43, 0x3, 0x0, 0x16, 0xa2, 0xc5, 0xf4, 0x14, 0x4c, 0x1e, 0x50, 0x4d, 0x7e, 0x32, 0x50, 0x38, 0xd9, + 0x84, 0xcc, 0x3e, 0xc9, 0xe3, 0x58, 0xfb, 0x86, 0xfb, 0x2a, 0x67, 0x21, 0x66, 0x12, 0x9, 0x0, 0x11, + 0x0, 0x99, 0x76, 0xb3, 0x6a, 0xc5, 0x23, 0xc0, 0xeb, 0x74, 0xa4, 0xdd, 0x56, 0x15, 0x7c, 0x69, 0x30, + 0x8f, 0xa1, 0x0, 0xa2, 0x1, 0x83, 0x8f, 0x1, 0x0, 0x1, 0x1}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[11]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7754); + EXPECT_EQ(packet_id, 11397); EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[0], 0x8F); + EXPECT_EQ(granted_qos_levels[1], 0xA1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0xA2); EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[6], 0x9E); + EXPECT_EQ(granted_qos_levels[5], 0x83); + EXPECT_EQ(granted_qos_levels[6], 0x8F); EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[10], 0xA1); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS1); +} + +// SubscribeResponse 5337 [Left SubErrTopicFilterInvalid] [PropSubscriptionIdentifierAvailable 45,PropCorrelationData +// "\204\r\185L\153\176\USc\190m\215\233\221\NUL\174",PropTopicAlias 5305,PropReasonString "",PropContentType +// "\171\190\177\196\244\164_S3#\229\USc\162H7T\DC19\155_\145\210\203\154\190m5",PropSubscriptionIdentifier +// 26,PropMaximumQoS 122,PropReasonString "q\208\160\130[\213VO\170",PropPayloadFormatIndicator 47,PropMaximumPacketSize +// 10768,PropSubscriptionIdentifier 17,PropSubscriptionIdentifierAvailable 104,PropMessageExpiryInterval +// 27024,PropRequestProblemInformation 236,PropAssignedClientIdentifier +// "\228\SUB\233\ESC",PropWildcardSubscriptionAvailable 194,PropResponseInformation "",PropCorrelationData +// "\237\219\248\"6\v\236\128\NAK\233",PropRequestResponseInformation 80,PropTopicAlias 19929,PropTopicAlias +// 3674,PropAuthenticationMethod "FQp",PropWillDelayInterval 8789,PropSharedSubscriptionAvailable 166,PropTopicAlias +// 17706,PropTopicAlias 3711,PropPayloadFormatIndicator 75,PropAuthenticationData +// "_\133\195\STX:%{\181a\128\204pxv\152\239\170\132\216\139\227",PropReasonString +// "\133\236\146]7c\236a\GS$v\248\230\182\169\165\SO\241\ACK",PropResponseInformation "b;"] +TEST(SubACK5QCTest, Decode15) { + uint8_t pkt[] = { + 0x90, 0xc9, 0x1, 0x14, 0xd9, 0xc4, 0x1, 0x29, 0x2d, 0x9, 0x0, 0xf, 0xcc, 0xd, 0xb9, 0x4c, 0x99, 0xb0, 0x1f, + 0x63, 0xbe, 0x6d, 0xd7, 0xe9, 0xdd, 0x0, 0xae, 0x23, 0x14, 0xb9, 0x1f, 0x0, 0x0, 0x3, 0x0, 0x1c, 0xab, 0xbe, + 0xb1, 0xc4, 0xf4, 0xa4, 0x5f, 0x53, 0x33, 0x23, 0xe5, 0x1f, 0x63, 0xa2, 0x48, 0x37, 0x54, 0x11, 0x39, 0x9b, 0x5f, + 0x91, 0xd2, 0xcb, 0x9a, 0xbe, 0x6d, 0x35, 0xb, 0x1a, 0x24, 0x7a, 0x1f, 0x0, 0x9, 0x71, 0xd0, 0xa0, 0x82, 0x5b, + 0xd5, 0x56, 0x4f, 0xaa, 0x1, 0x2f, 0x27, 0x0, 0x0, 0x2a, 0x10, 0xb, 0x11, 0x29, 0x68, 0x2, 0x0, 0x0, 0x69, + 0x90, 0x17, 0xec, 0x12, 0x0, 0x4, 0xe4, 0x1a, 0xe9, 0x1b, 0x28, 0xc2, 0x1a, 0x0, 0x0, 0x9, 0x0, 0xa, 0xed, + 0xdb, 0xf8, 0x22, 0x36, 0xb, 0xec, 0x80, 0x15, 0xe9, 0x19, 0x50, 0x23, 0x4d, 0xd9, 0x23, 0xe, 0x5a, 0x15, 0x0, + 0x3, 0x46, 0x51, 0x70, 0x18, 0x0, 0x0, 0x22, 0x55, 0x2a, 0xa6, 0x23, 0x45, 0x2a, 0x23, 0xe, 0x7f, 0x1, 0x4b, + 0x16, 0x0, 0x15, 0x5f, 0x85, 0xc3, 0x2, 0x3a, 0x25, 0x7b, 0xb5, 0x61, 0x80, 0xcc, 0x70, 0x78, 0x76, 0x98, 0xef, + 0xaa, 0x84, 0xd8, 0x8b, 0xe3, 0x1f, 0x0, 0x13, 0x85, 0xec, 0x92, 0x5d, 0x37, 0x63, 0xec, 0x61, 0x1d, 0x24, 0x76, + 0xf8, 0xe6, 0xb6, 0xa9, 0xa5, 0xe, 0xf1, 0x6, 0x1a, 0x0, 0x2, 0x62, 0x3b, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 5337); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], 0x8F); } -// SubscribeResponse 29991 [Left SubErrPacketIdentifierInUse,Right QoS1,Right QoS0,Left -// SubErrPacketIdentifierInUse,Right QoS1,Right QoS1,Left SubErrImplementationSpecificError,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS0] [PropTopicAliasMaximum 3368,PropWildcardSubscriptionAvailable -// 46,PropServerReference "wF\202\DEL\134\171H\239\153J\ETX\DLE\DLE/H\190un",PropReasonString -// "$\130\250\&1~1\173\158_\196\130\241\&2\141)\138h\EOT-Z\n",PropPayloadFormatIndicator 204,PropTopicAlias -// 21439,PropAssignedClientIdentifier "\227\STX\228>K\187",PropRequestProblemInformation 245,PropPayloadFormatIndicator -// 235,PropSubscriptionIdentifier 13,PropServerReference "\237\249\f\243\191\254\129\ACK\226%\232",PropTopicAliasMaximum -// 15309,PropReceiveMaximum 23314] +// SubscribeResponse 32213 [Left SubErrQuotaExceeded,Right QoS0,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1] +// [PropRequestResponseInformation 95,PropAuthenticationMethod "R\NAK",PropWillDelayInterval 32360,PropMaximumPacketSize +// 7542,PropResponseInformation +// "S\150\133\ESC\186\136\230\187\237O\232\164\251\236\190,2\146\147\198\139\152\&6",PropMaximumPacketSize +// 8765,PropSubscriptionIdentifier 19,PropAuthenticationMethod +// "\NAKV\239\253\251\DEL\197\250!\f\249\DC2\229<\145\DC2\130\SUB\DC4\168\132\182\250\245\159\193\SUB\SI\214?",PropResponseInformation +// "V5d6\ENQ",PropContentType "R7\136\236T/G",PropRetainAvailable 232,PropServerKeepAlive 16300,PropWillDelayInterval +// 8409,PropPayloadFormatIndicator 63,PropContentType "\229\149'/\STXd\227\200%\254\159W",PropUserProperty +// "Dj\147\209\216\"\226&6S\158\224\SYN@" +// "k\226V\204\207\174\196q\178pQ\162\183\&1\t\239\&2\135\232(\138N\228\&5\153\234&G",PropServerKeepAlive +// 10969,PropRetainAvailable 217,PropReasonString "\210\FS\138\150M",PropTopicAlias 533] TEST(SubACK5QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0x66, 0x75, 0x27, 0x5a, 0x22, 0xd, 0x28, 0x28, 0x2e, 0x1c, 0x0, 0x12, 0x77, 0x46, - 0xca, 0x7f, 0x86, 0xab, 0x48, 0xef, 0x99, 0x4a, 0x3, 0x10, 0x10, 0x2f, 0x48, 0xbe, 0x75, - 0x6e, 0x1f, 0x0, 0x15, 0x24, 0x82, 0xfa, 0x31, 0x7e, 0x31, 0xad, 0x9e, 0x5f, 0xc4, 0x82, - 0xf1, 0x32, 0x8d, 0x29, 0x8a, 0x68, 0x4, 0x2d, 0x5a, 0xa, 0x1, 0xcc, 0x23, 0x53, 0xbf, - 0x12, 0x0, 0x6, 0xe3, 0x2, 0xe4, 0x3e, 0x4b, 0xbb, 0x17, 0xf5, 0x1, 0xeb, 0xb, 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 0x56, 0xcc, 0xcf, 0xae, 0xc4, 0x71, 0xb2, 0x70, 0x51, 0xa2, 0xb7, 0x31, 0x9, 0xef, + 0x32, 0x87, 0xe8, 0x28, 0x8a, 0x4e, 0xe4, 0x35, 0x99, 0xea, 0x26, 0x47, 0x13, 0x2a, 0xd9, 0x25, 0xd9, + 0x1f, 0x0, 0x5, 0xd2, 0x1c, 0x8a, 0x96, 0x4d, 0x23, 0x2, 0x15, 0x97, 0x0, 0x0, 0x9e, 0xa2, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29991); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x91); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 32213); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0x97); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x91); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x9E); + EXPECT_EQ(granted_qos_levels[4], 0xA2); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], 0x83); - EXPECT_EQ(granted_qos_levels[7], 0xA1); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); } -// SubscribeResponse 6273 [Right QoS1,Right QoS0] [PropWildcardSubscriptionAvailable 63,PropAssignedClientIdentifier -// "*\165!\210&D\246\SO\ENQ\162{\ACKv\DELm\SUB\142"] +// SubscribeResponse 1504 [Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS1,Right QoS1] +// [PropAssignedClientIdentifier +// "]{=K\190\169\DC1\ACK\198O\136\201Q\139A\f\166\129\ENQ_'\129\177-",PropMessageExpiryInterval +// 790,PropWildcardSubscriptionAvailable 36,PropMessageExpiryInterval 14665,PropCorrelationData +// "\DC4z\197\143",PropServerKeepAlive 22506,PropSubscriptionIdentifierAvailable 30,PropSharedSubscriptionAvailable +// 13,PropSharedSubscriptionAvailable 219,PropWildcardSubscriptionAvailable 255,PropMaximumPacketSize +// 14962,PropServerKeepAlive 19142,PropSharedSubscriptionAvailable 249,PropResponseInformation +// "\b$\\\SOH\160",PropAssignedClientIdentifier +// "\EM\157$\ETXj\EOTx\165\212\140@\191\SOH)\148\ENQ\t\129{\SODX\196\US",PropPayloadFormatIndicator +// 195,PropMaximumPacketSize 23289,PropRequestResponseInformation 44,PropResponseTopic +// "\NUL\199\EM{\183\&3h\150-\255\222\220",PropWillDelayInterval 8389,PropUserProperty "\165=\171)`\156\230\219:" +// "]\194",PropAuthenticationData +// "\161US\214\135'c\NUL\ESC\252Qp\DC1,QN_\223\162\EM\197\178bI:",PropMessageExpiryInterval 15146,PropMaximumPacketSize +// 27405,PropCorrelationData "B}\198\SOH\163",PropMessageExpiryInterval 26861,PropAssignedClientIdentifier +// "\159\129\199\236\243\179\b\219\239RU\227\159\149\183b\161r|y\172\202FQ\NUL\"\136\186",PropSessionExpiryInterval +// 30259] TEST(SubACK5QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0x1b, 0x18, 0x81, 0x16, 0x28, 0x3f, 0x12, 0x0, 0x11, 0x2a, 0xa5, 0x21, 0xd2, 0x26, - 0x44, 0xf6, 0xe, 0x5, 0xa2, 0x7b, 0x6, 0x76, 0x7f, 0x6d, 0x1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x2, 0x0, 0x0, 0x3b, 0x2a, 0x27, 0x0, 0x0, + 0x6b, 0xd, 0x9, 0x0, 0x5, 0x42, 0x7d, 0xc6, 0x1, 0xa3, 0x2, 0x0, 0x0, 0x68, 0xed, 0x12, 0x0, 0x1c, 0x9f, + 0x81, 0xc7, 0xec, 0xf3, 0xb3, 0x8, 0xdb, 0xef, 0x52, 0x55, 0xe3, 0x9f, 0x95, 0xb7, 0x62, 0xa1, 0x72, 0x7c, 0x79, + 0xac, 0xca, 0x46, 0x51, 0x0, 0x22, 0x88, 0xba, 0x11, 0x0, 0x0, 0x76, 0x33, 0xa1, 0x9e, 0x1, 0x8f, 0x1, 0x1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[2]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6273); - EXPECT_EQ(count, 2); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 1504); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], 0x9E); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], 0x8F); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 10407 [Left SubErrUnspecifiedError] [PropRequestProblemInformation -// 215,PropWildcardSubscriptionAvailable 161,PropRetainAvailable 44,PropMaximumQoS 1,PropMessageExpiryInterval -// 21069,PropAuthenticationData "~\EOTwE'\249\129\197\212\195\201\167&\208\240",PropMaximumQoS -// 34,PropSubscriptionIdentifier 17,PropAssignedClientIdentifier "\154\193\171B\f\171G",PropAuthenticationData -// "",PropResponseTopic -// "C\DC2\141\138W\234\235\136\177h\226\255\134\137b\148'ig\SOHZc]X\244\199\176+",PropWillDelayInterval -// 26669,PropReceiveMaximum 7925,PropAssignedClientIdentifier -// "0\147\&6\EM\231p\235\254Rk+\131\141",PropMaximumPacketSize 3698,PropAssignedClientIdentifier -// "\ACKJ\SOH\254Mb\131\138\192B\140\156\191\239\217\245;7\139\&1/u\215\139\&1\222\186\183",PropResponseInformation -// "\250e\DC1E\212\204?7y\236n0C\r",PropMaximumPacketSize 6648,PropReceiveMaximum -// 24409,PropSubscriptionIdentifierAvailable 230,PropWillDelayInterval 7378,PropServerKeepAlive -// 31324,PropSubscriptionIdentifier 6,PropSharedSubscriptionAvailable 10,PropAuthenticationData -// "\167\179MJ\ETX\174\185\166;\175\157nX\146",PropMessageExpiryInterval 8462,PropCorrelationData -// "\198f%h\140\253\213g#\163\251X\DC4\194\&4N\247\129\168\148\143\248Xc\138\215",PropUserProperty -// "\140\194m$C\226\235\183Gt\176\210\135\169H\133\144\213\156Z" "\176p9\ETB2y\251o<\145%\173\ENQ\244AX\r\204\167\238"] +// SubscribeResponse 2008 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right +// QoS2,Left SubErrUnspecifiedError] [PropMessageExpiryInterval 29625,PropMessageExpiryInterval +// 15421,PropRequestProblemInformation 41,PropCorrelationData +// "_\233\&9\245\tW<\EMf\218\240v\188\211\DLE\253\141\171\248\214DM\"\149\159}4\167\NUL",PropRequestResponseInformation +// 19,PropReasonString "2\164BN%\a\b\253\242\233\204",PropTopicAlias 26560,PropSharedSubscriptionAvailable +// 21,PropContentType "a\159-\243\&1",PropMessageExpiryInterval 7597,PropRetainAvailable 98,PropPayloadFormatIndicator +// 87,PropSubscriptionIdentifier 31,PropWildcardSubscriptionAvailable 5,PropContentType "",PropUserProperty +// "\ESC\249\SYNna\169" +// "\NAK\221\215\207\r\155Qf\231\194c\177e\226k\187z\191t\212\241D\181\&4\188\f\FS\140",PropSessionExpiryInterval +// 18569,PropSubscriptionIdentifierAvailable 223,PropAssignedClientIdentifier +// "8,\254\&7\160vs\166\&3",PropSharedSubscriptionAvailable 170,PropSharedSubscriptionAvailable 53] TEST(SubACK5QCTest, Decode18) { - uint8_t pkt[] = { - 0x90, 0x97, 0x2, 0x28, 0xa7, 0x92, 0x2, 0x17, 0xd7, 0x28, 0xa1, 0x25, 0x2c, 0x24, 0x1, 0x2, 0x0, 0x0, 0x52, - 0x4d, 0x16, 0x0, 0xf, 0x7e, 0x4, 0x77, 0x45, 0x27, 0xf9, 0x81, 0xc5, 0xd4, 0xc3, 0xc9, 0xa7, 0x26, 0xd0, 0xf0, - 0x24, 0x22, 0xb, 0x11, 0x12, 0x0, 0x7, 0x9a, 0xc1, 0xab, 0x42, 0xc, 0xab, 0x47, 0x16, 0x0, 0x0, 0x8, 0x0, - 0x1c, 0x43, 0x12, 0x8d, 0x8a, 0x57, 0xea, 0xeb, 0x88, 0xb1, 0x68, 0xe2, 0xff, 0x86, 0x89, 0x62, 0x94, 0x27, 0x69, - 0x67, 0x1, 0x5a, 0x63, 0x5d, 0x58, 0xf4, 0xc7, 0xb0, 0x2b, 0x18, 0x0, 0x0, 0x68, 0x2d, 0x21, 0x1e, 0xf5, 0x12, - 0x0, 0xd, 0x30, 0x93, 0x36, 0x19, 0xe7, 0x70, 0xeb, 0xfe, 0x52, 0x6b, 0x2b, 0x83, 0x8d, 0x27, 0x0, 0x0, 0xe, - 0x72, 0x12, 0x0, 0x1c, 0x6, 0x4a, 0x1, 0xfe, 0x4d, 0x62, 0x83, 0x8a, 0xc0, 0x42, 0x8c, 0x9c, 0xbf, 0xef, 0xd9, - 0xf5, 0x3b, 0x37, 0x8b, 0x31, 0x2f, 0x75, 0xd7, 0x8b, 0x31, 0xde,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, 0x7d, 0x34, 0xa7, 0x0, + 0x19, 0x13, 0x1f, 0x0, 0xb, 0x32, 0xa4, 0x42, 0x4e, 0x25, 0x7, 0x8, 0xfd, 0xf2, 0xe9, 0xcc, 0x23, + 0x67, 0xc0, 0x2a, 0x15, 0x3, 0x0, 0x5, 0x61, 0x9f, 0x2d, 0xf3, 0x31, 0x2, 0x0, 0x0, 0x1d, 0xad, + 0x25, 0x62, 0x1, 0x57, 0xb, 0x1f, 0x28, 0x5, 0x3, 0x0, 0x0, 0x26, 0x0, 0x6, 0x1b, 0xf9, 0x16, + 0x6e, 0x61, 0xa9, 0x0, 0x1c, 0x15, 0xdd, 0xd7, 0xcf, 0xd, 0x9b, 0x51, 0x66, 0xe7, 0xc2, 0x63, 0xb1, + 0x65, 0xe2, 0x6b, 0xbb, 0x7a, 0xbf, 0x74, 0xd4, 0xf1, 0x44, 0xb5, 0x34, 0xbc, 0xc, 0x1c, 0x8c, 0x11, + 0x0, 0x0, 0x48, 0x89, 0x29, 0xdf, 0x12, 0x0, 0x9, 0x38, 0x2c, 0xfe, 0x37, 0xa0, 0x76, 0x73, 0xa6, + 0x33, 0x2a, 0xaa, 0x2a, 0x35, 0x2, 0x9e, 0x91, 0x2, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10407); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(packet_id, 2008); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x9E); + EXPECT_EQ(granted_qos_levels[2], 0x91); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); } -// SubscribeResponse 13436 [Left SubErrPacketIdentifierInUse,Left SubErrImplementationSpecificError,Left -// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left SubErrNotAuthorized,Right QoS0,Right QoS1,Left -// SubErrQuotaExceeded,Right QoS0,Right QoS0] [PropServerKeepAlive 21556,PropReceiveMaximum 13390,PropUserProperty -// "P\129" "\198\207\160",PropTopicAliasMaximum 22735,PropTopicAliasMaximum 13713,PropCorrelationData -// "\219\137\CAN\153\223\\\198\164\161\190,\255e\253\219\211",PropSessionExpiryInterval 27448,PropMaximumPacketSize -// 13892,PropReasonString "\149\204[\147\151\198\145\131\EM~\250\&3\174\161\136\254\148n",PropReceiveMaximum -// 27195,PropTopicAlias 857,PropAuthenticationMethod -// "\ESC\233\211\237\133\246\177\198\212\136\213\160\154\143\202\143z\ETB\ESCW",PropSubscriptionIdentifier -// 20,PropSubscriptionIdentifierAvailable 95] +// SubscribeResponse 19894 [Left SubErrNotAuthorized,Left SubErrSharedSubscriptionsNotSupported,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrQuotaExceeded] [PropMessageExpiryInterval 5546,PropRetainAvailable 128,PropSharedSubscriptionAvailable +// 109,PropUserProperty "\180E\ESC\241\198\216\"\a\146\141!\162-\237\177\&0\249^\132\218\190\EM\NAK" +// "\153\180",PropTopicAliasMaximum 11791] TEST(SubACK5QCTest, Decode19) { - uint8_t pkt[] = {0x90, 0x76, 0x34, 0x7c, 0x69, 0x13, 0x54, 0x34, 0x21, 0x34, 0x4e, 0x26, 0x0, 0x2, 0x50, - 0x81, 0x0, 0x3, 0xc6, 0xcf, 0xa0, 0x22, 0x58, 0xcf, 0x22, 0x35, 0x91, 0x9, 0x0, 0x10, - 0xdb, 0x89, 0x18, 0x99, 0xdf, 0x5c, 0xc6, 0xa4, 0xa1, 0xbe, 0x2c, 0xff, 0x65, 0xfd, 0xdb, - 0xd3, 0x11, 0x0, 0x0, 0x6b, 0x38, 0x27, 0x0, 0x0, 0x36, 0x44, 0x1f, 0x0, 0x12, 0x95, - 0xcc, 0x5b, 0x93, 0x97, 0xc6, 0x91, 0x83, 0x19, 0x7e, 0xfa, 0x33, 0xae, 0xa1, 0x88, 0xfe, - 0x94, 0x6e, 0x21, 0x6a, 0x3b, 0x23, 0x3, 0x59, 0x15, 0x0, 0x14, 0x1b, 0xe9, 0xd3, 0xed, - 0x85, 0xf6, 0xb1, 0xc6, 0xd4, 0x88, 0xd5, 0xa0, 0x9a, 0x8f, 0xca, 0x8f, 0x7a, 0x17, 0x1b, - 0x57, 0xb, 0x14, 0x29, 0x5f, 0x91, 0x83, 0x83, 0x97, 0x87, 0x0, 0x1, 0x97, 0x0, 0x0}; + uint8_t pkt[] = {0x90, 0x33, 0x4d, 0xb6, 0x2a, 0x2, 0x0, 0x0, 0x15, 0xaa, 0x25, 0x80, 0x2a, 0x6d, + 0x26, 0x0, 0x17, 0xb4, 0x45, 0x1b, 0xf1, 0xc6, 0xd8, 0x22, 0x7, 0x92, 0x8d, 0x21, + 0xa2, 0x2d, 0xed, 0xb1, 0x30, 0xf9, 0x5e, 0x84, 0xda, 0xbe, 0x19, 0x15, 0x0, 0x2, + 0x99, 0xb4, 0x22, 0x2e, 0xf, 0x87, 0x9e, 0xa1, 0x0, 0xa1, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13436); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x91); - EXPECT_EQ(granted_qos_levels[1], 0x83); - EXPECT_EQ(granted_qos_levels[2], 0x83); - EXPECT_EQ(granted_qos_levels[3], 0x97); - EXPECT_EQ(granted_qos_levels[4], 0x87); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], 0x97); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); -} - -// SubscribeResponse 634 [Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left -// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Right QoS0,Left SubErrWildcardSubscriptionsNotSupported] -// [PropUserProperty "\239\&6\vvf\231\184Wm!\159" "\138\241\203Z\171*\189~\151^\tw&@",PropRetainAvailable -// 131,PropSubscriptionIdentifierAvailable 177,PropReceiveMaximum 32035,PropContentType -// "\185\176z#\225\150h6\171\145^",PropMaximumPacketSize 18026,PropPayloadFormatIndicator 233,PropAuthenticationData -// "\ETB\243\GS\DC3",PropServerReference -// "\161\183\130\246\207,\129\254\244\242\141Lr\161\DC1\192\&2",PropTopicAliasMaximum 23013,PropMaximumPacketSize -// 10661,PropServerKeepAlive 13847,PropSharedSubscriptionAvailable 98,PropWillDelayInterval 31057] + EXPECT_EQ(packet_id, 19894); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0x87); + EXPECT_EQ(granted_qos_levels[1], 0x9E); + EXPECT_EQ(granted_qos_levels[2], 0xA1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0xA1); + EXPECT_EQ(granted_qos_levels[5], 0x97); +} + +// SubscribeResponse 12423 [Left SubErrNotAuthorized,Right QoS0,Right QoS2,Right QoS2] [PropRetainAvailable +// 88,PropRetainAvailable 171,PropAssignedClientIdentifier "\147",PropResponseTopic +// "UT\236\244Fb\191\205\240\222]\NAK",PropSubscriptionIdentifierAvailable 66,PropRequestProblemInformation +// 51,PropResponseInformation "Cp\229\155\174\SUB\216a\252\v\227lk;\SO5\182\252",PropReceiveMaximum +// 4603,PropWillDelayInterval 20903,PropTopicAlias 17266,PropAuthenticationData +// "\NUL\231k\154\231V\163",PropSubscriptionIdentifierAvailable 202,PropAuthenticationMethod "\219",PropResponseTopic +// "D\222\131\GS\185p\161\178:_\187\228\237Q]\164\DC30",PropMaximumPacketSize 30253,PropServerKeepAlive +// 10546,PropSessionExpiryInterval 22254,PropPayloadFormatIndicator 253,PropWillDelayInterval 7844,PropWillDelayInterval +// 28606,PropAssignedClientIdentifier +// "1T\254\243I\161\151-\229\232\193\145q\DLE)\DLE\178\223w\128\181\225\195\143\240\v}",PropWildcardSubscriptionAvailable +// 130,PropTopicAliasMaximum 7964,PropWillDelayInterval 25559] TEST(SubACK5QCTest, Decode20) { - uint8_t pkt[] = {0x90, 0x71, 0x2, 0x7a, 0x67, 0x26, 0x0, 0xb, 0xef, 0x36, 0xb, 0x76, 0x66, 0xe7, 0xb8, 0x57, 0x6d, - 0x21, 0x9f, 0x0, 0xe, 0x8a, 0xf1, 0xcb, 0x5a, 0xab, 0x2a, 0xbd, 0x7e, 0x97, 0x5e, 0x9, 0x77, 0x26, - 0x40, 0x25, 0x83, 0x29, 0xb1, 0x21, 0x7d, 0x23, 0x3, 0x0, 0xb, 0xb9, 0xb0, 0x7a, 0x23, 0xe1, 0x96, - 0x68, 0x36, 0xab, 0x91, 0x5e, 0x27, 0x0, 0x0, 0x46, 0x6a, 0x1, 0xe9, 0x16, 0x0, 0x4, 0x17, 0xf3, - 0x1d, 0x13, 0x1c, 0x0, 0x11, 0xa1, 0xb7, 0x82, 0xf6, 0xcf, 0x2c, 0x81, 0xfe, 0xf4, 0xf2, 0x8d, 0x4c, - 0x72, 0xa1, 0x11, 0xc0, 0x32, 0x22, 0x59, 0xe5, 0x27, 0x0, 0x0, 0x29, 0xa5, 0x13, 0x36, 0x17, 0x2a, - 0x62, 0x18, 0x0, 0x0, 0x79, 0x51, 0x2, 0x91, 0x1, 0x83, 0x97, 0x0, 0xa2}; + uint8_t pkt[] = {0x90, 0xa9, 0x1, 0x30, 0x87, 0xa1, 0x1, 0x25, 0x58, 0x25, 0xab, 0x12, 0x0, 0x1, 0x93, 0x8, + 0x0, 0xc, 0x55, 0x54, 0xec, 0xf4, 0x46, 0x62, 0xbf, 0xcd, 0xf0, 0xde, 0x5d, 0x15, 0x29, 0x42, + 0x17, 0x33, 0x1a, 0x0, 0x12, 0x43, 0x70, 0xe5, 0x9b, 0xae, 0x1a, 0xd8, 0x61, 0xfc, 0xb, 0xe3, + 0x6c, 0x6b, 0x3b, 0xe, 0x35, 0xb6, 0xfc, 0x21, 0x11, 0xfb, 0x18, 0x0, 0x0, 0x51, 0xa7, 0x23, + 0x43, 0x72, 0x16, 0x0, 0x7, 0x0, 0xe7, 0x6b, 0x9a, 0xe7, 0x56, 0xa3, 0x29, 0xca, 0x15, 0x0, + 0x1, 0xdb, 0x8, 0x0, 0x12, 0x44, 0xde, 0x83, 0x1d, 0xb9, 0x70, 0xa1, 0xb2, 0x3a, 0x5f, 0xbb, + 0xe4, 0xed, 0x51, 0x5d, 0xa4, 0x13, 0x30, 0x27, 0x0, 0x0, 0x76, 0x2d, 0x13, 0x29, 0x32, 0x11, + 0x0, 0x0, 0x56, 0xee, 0x1, 0xfd, 0x18, 0x0, 0x0, 0x1e, 0xa4, 0x18, 0x0, 0x0, 0x6f, 0xbe, + 0x12, 0x0, 0x1b, 0x31, 0x54, 0xfe, 0xf3, 0x49, 0xa1, 0x97, 0x2d, 0xe5, 0xe8, 0xc1, 0x91, 0x71, + 0x10, 0x29, 0x10, 0xb2, 0xdf, 0x77, 0x80, 0xb5, 0xe1, 0xc3, 0x8f, 0xf0, 0xb, 0x7d, 0x28, 0x82, + 0x22, 0x1f, 0x1c, 0x18, 0x0, 0x0, 0x63, 0xd7, 0x87, 0x0, 0x2, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[7]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 634); - EXPECT_EQ(count, 7); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x91); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x83); - EXPECT_EQ(granted_qos_levels[4], 0x97); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0xA2); -} - -// SubscribeResponse 742 [Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrPacketIdentifierInUse,Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Right QoS1,Left SubErrTopicFilterInvalid] -// [PropReceiveMaximum 9630,PropMessageExpiryInterval 1477,PropAuthenticationMethod -// "\SYNe\DC2\234\203\229\STX\ENQ\240\167\NAK\146\130*\ESC$\SYN\236\148\195\137\179\183|\182\173\134",PropContentType -// "\242\253",PropMessageExpiryInterval 13288,PropWillDelayInterval 13555,PropReasonString -// "\213E\175+TG\142$t\EOT:aO\SO\228Iq\180\221\200'Z\244q]f",PropSubscriptionIdentifier 21,PropSessionExpiryInterval -// 2187,PropReasonString "\CAN-\219\198\DC4\128L=zQ\242\244",PropCorrelationData -// "\SO|\250M\EM\DC3\207e\213;\153\202",PropSubscriptionIdentifierAvailable 108] + EXPECT_EQ(packet_id, 12423); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x87); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); +} + +// SubscribeResponse 21901 [Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError,Right QoS0,Right QoS0] +// [PropAssignedClientIdentifier "\161\185\170\238\ACK",PropTopicAliasMaximum 13624,PropResponseTopic +// "\US{E\249\134\SOx\215J\243\250#]\130!\165\202e\143\194x'C\DLE\199\223\223f",PropSharedSubscriptionAvailable +// 32,PropTopicAlias 20663,PropRetainAvailable 159,PropResponseTopic "\239%\203\232\173 +// \230\177\252e\206\144",PropAuthenticationMethod +// "\132\SYN\DC1\SIJ\189J\225r\134\DC1\130\232@5\ACK",PropAssignedClientIdentifier "\199\144\239\197",PropReceiveMaximum +// 12035,PropAssignedClientIdentifier "\170\147\&0#\147\251n\139\217^~b\229\129",PropMessageExpiryInterval +// 17213,PropAuthenticationMethod +// "\180c\180\170\226\a\134\236\151^Lt\203\175\RSw\149X4Cj\"g\v",PropWildcardSubscriptionAvailable +// 118,PropWildcardSubscriptionAvailable 100,PropUserProperty "c\ah\156" +// "\213\149g\229\252\154U\165\139\194\EOT\139v\247\138bK2\192\187B\224*-\134\155\175 \b\170",PropServerReference +// "x%\SUBm\229\ENQ",PropWildcardSubscriptionAvailable 107,PropServerReference +// "\CAN\182#\213'\228\239\130\205c>\EM|\ETB\131\225V\f\224|k$\176v\208\&5",PropTopicAlias 551,PropMaximumPacketSize +// 28489,PropSessionExpiryInterval 11350,PropTopicAlias 3242,PropRetainAvailable 58] TEST(SubACK5QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0x85, 0x1, 0x2, 0xe6, 0x79, 0x21, 0x25, 0x9e, 0x2, 0x0, 0x0, 0x5, 0xc5, 0x15, 0x0, - 0x1b, 0x16, 0x65, 0x12, 0x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, 0xce, 0x90, 0x15, 0x0, 0x10, 0x84, 0x16, 0x11, 0xf, 0x4a, 0xbd, 0x4a, 0xe1, 0x72, 0x86, 0x11, + 0x82, 0xe8, 0x40, 0x35, 0x6, 0x12, 0x0, 0x4, 0xc7, 0x90, 0xef, 0xc5, 0x21, 0x2f, 0x3, 0x12, 0x0, + 0xe, 0xaa, 0x93, 0x30, 0x23, 0x93, 0xfb, 0x6e, 0x8b, 0xd9, 0x5e, 0x7e, 0x62, 0xe5, 0x81, 0x2, 0x0, + 0x0, 0x43, 0x3d, 0x15, 0x0, 0x18, 0xb4, 0x63, 0xb4, 0xaa, 0xe2, 0x7, 0x86, 0xec, 0x97, 0x5e, 0x4c, + 0x74, 0xcb, 0xaf, 0x1e, 0x77, 0x95, 0x58, 0x34, 0x43, 0x6a, 0x22, 0x67, 0xb, 0x28, 0x76, 0x28, 0x64, + 0x26, 0x0, 0x4, 0x63, 0x7, 0x68, 0x9c, 0x0, 0x1e, 0xd5, 0x95, 0x67, 0xe5, 0xfc, 0x9a, 0x55, 0xa5, + 0x8b, 0xc2, 0x4, 0x8b, 0x76, 0xf7, 0x8a, 0x62, 0x4b, 0x32, 0xc0, 0xbb, 0x42, 0xe0, 0x2a, 0x2d, 0x86, + 0x9b, 0xaf, 0x20, 0x8, 0xaa, 0x1c, 0x0, 0x6, 0x78, 0x25, 0x1a, 0x6d, 0xe5, 0x5, 0x28, 0x6b, 0x1c, + 0x0, 0x1a, 0x18, 0xb6, 0x23, 0xd5, 0x27, 0xe4, 0xef, 0x82, 0xcd, 0x63, 0x3e, 0x19, 0x7c, 0x17, 0x83, + 0xe1, 0x56, 0xc, 0xe0, 0x7c, 0x6b, 0x24, 0xb0, 0x76, 0xd0, 0x35, 0x23, 0x2, 0x27, 0x27, 0x0, 0x0, + 0x6f, 0x49, 0x11, 0x0, 0x0, 0x2c, 0x56, 0x23, 0xc, 0xaa, 0x25, 0x3a, 0x97, 0x83, 0x0, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 742); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0xA1); - EXPECT_EQ(granted_qos_levels[2], 0x91); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x9E); - EXPECT_EQ(granted_qos_levels[5], 0x83); - EXPECT_EQ(granted_qos_levels[6], 0x97); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], 0x8F); + EXPECT_EQ(packet_id, 21901); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x97); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); } -// SubscribeResponse 14677 [Left SubErrTopicFilterInvalid,Right QoS0,Left SubErrTopicFilterInvalid] -// [PropAuthenticationData "",PropMaximumQoS 183,PropWildcardSubscriptionAvailable 152,PropTopicAlias -// 10631,PropRequestResponseInformation 108,PropServerKeepAlive 7360,PropMessageExpiryInterval -// 29434,PropSubscriptionIdentifierAvailable 168,PropMaximumPacketSize 23853,PropMaximumQoS 108,PropReceiveMaximum -// 11783] +// SubscribeResponse 9953 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1] +// [PropSessionExpiryInterval 12233,PropSubscriptionIdentifierAvailable 133,PropTopicAliasMaximum +// 26913,PropReceiveMaximum 13582,PropReceiveMaximum 4922,PropAuthenticationMethod +// "\204\r\b:fo\DC2\160\238\ETX\ENQ\128\139\&0\139\246\218\&8\194",PropMessageExpiryInterval +// 15793,PropAuthenticationMethod "J",PropSubscriptionIdentifierAvailable 80,PropAssignedClientIdentifier +// "",PropResponseTopic "",PropSessionExpiryInterval 23870,PropUserProperty "\185\t" +// "Qi\202\&1\173#\ETB\212L5\226l\DC1H\223\132\157\238\&9\131\184\219\205\t",PropReceiveMaximum +// 16774,PropTopicAliasMaximum 28939,PropResponseInformation +// "\187y\185C\173\136\210\241\209\194X\ETB\212(\197\192\212A\\\226\DC3\206&o0\144\226\173\252)",PropMaximumQoS +// 209,PropTopicAliasMaximum 30629,PropSubscriptionIdentifierAvailable 235,PropMessageExpiryInterval +// 16775,PropWildcardSubscriptionAvailable 24,PropSubscriptionIdentifier 0,PropReasonString +// "\169\255\EOT*\218\131L\182bR@\SO4",PropReasonString "[0qc\193\200\154\181t\USUEF"] TEST(SubACK5QCTest, Decode22) { - uint8_t pkt[] = {0x90, 0x26, 0x39, 0x55, 0x20, 0x16, 0x0, 0x0, 0x24, 0xb7, 0x28, 0x98, 0x23, 0x29, - 0x87, 0x19, 0x6c, 0x13, 0x1c, 0xc0, 0x2, 0x0, 0x0, 0x72, 0xfa, 0x29, 0xa8, 0x27, - 0x0, 0x0, 0x5d, 0x2d, 0x24, 0x6c, 0x21, 0x2e, 0x7, 0x8f, 0x0, 0x8f}; + uint8_t pkt[] = { + 0x90, 0xb9, 0x1, 0x26, 0xe1, 0xb2, 0x1, 0x11, 0x0, 0x0, 0x2f, 0xc9, 0x29, 0x85, 0x22, 0x69, 0x21, 0x21, 0x35, + 0xe, 0x21, 0x13, 0x3a, 0x15, 0x0, 0x13, 0xcc, 0xd, 0x8, 0x3a, 0x66, 0x6f, 0x12, 0xa0, 0xee, 0x3, 0x5, 0x80, + 0x8b, 0x30, 0x8b, 0xf6, 0xda, 0x38, 0xc2, 0x2, 0x0, 0x0, 0x3d, 0xb1, 0x15, 0x0, 0x1, 0x4a, 0x29, 0x50, 0x12, + 0x0, 0x0, 0x8, 0x0, 0x0, 0x11, 0x0, 0x0, 0x5d, 0x3e, 0x26, 0x0, 0x2, 0xb9, 0x9, 0x0, 0x18, 0x51, 0x69, + 0xca, 0x31, 0xad, 0x23, 0x17, 0xd4, 0x4c, 0x35, 0xe2, 0x6c, 0x11, 0x48, 0xdf, 0x84, 0x9d, 0xee, 0x39, 0x83, 0xb8, + 0xdb, 0xcd, 0x9, 0x21, 0x41, 0x86, 0x22, 0x71, 0xb, 0x1a, 0x0, 0x1e, 0xbb, 0x79, 0xb9, 0x43, 0xad, 0x88, 0xd2, + 0xf1, 0xd1, 0xc2, 0x58, 0x17, 0xd4, 0x28, 0xc5, 0xc0, 0xd4, 0x41, 0x5c, 0xe2, 0x13, 0xce, 0x26, 0x6f, 0x30, 0x90, + 0xe2, 0xad, 0xfc, 0x29, 0x24, 0xd1, 0x22, 0x77, 0xa5, 0x29, 0xeb, 0x2, 0x0, 0x0, 0x41, 0x87, 0x28, 0x18, 0xb, + 0x0, 0x1f, 0x0, 0xd, 0xa9, 0xff, 0x4, 0x2a, 0xda, 0x83, 0x4c, 0xb6, 0x62, 0x52, 0x40, 0xe, 0x34, 0x1f, 0x0, + 0xd, 0x5b, 0x30, 0x71, 0x63, 0xc1, 0xc8, 0x9a, 0xb5, 0x74, 0x1f, 0x55, 0x45, 0x46, 0x0, 0xa2, 0x1}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[3]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14677); + EXPECT_EQ(packet_id, 9953); EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0x8F); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x8F); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); } -// SubscribeResponse 22954 [Right QoS1,Left SubErrTopicFilterInvalid,Left SubErrQuotaExceeded,Right QoS0,Left -// SubErrUnspecifiedError] [PropRequestProblemInformation 173,PropContentType -// "\NAK\139j\215\189\191\162Iq\237\240q}\143\176\131\232\228\176#",PropTopicAliasMaximum -// 15589,PropSubscriptionIdentifierAvailable 54,PropServerKeepAlive 18613,PropSessionExpiryInterval -// 19845,PropSessionExpiryInterval 20838,PropReasonString -// "\168\164\252\190\143\164\141\198\NUL\176\138\235\CAN\187K\193*\US\147\SUB\254+\202y\150}\212{",PropContentType -// "",PropPayloadFormatIndicator 225,PropMaximumPacketSize 12913,PropTopicAliasMaximum 20068,PropCorrelationData -// "@\181I0\140\182\FS"] +// SubscribeResponse 21846 [Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Right QoS2,Right +// QoS1,Right QoS0,Right QoS0,Left SubErrImplementationSpecificError,Left SubErrTopicFilterInvalid,Right QoS2] +// [PropResponseTopic "1\219\195",PropReceiveMaximum 15914] TEST(SubACK5QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0x69, 0x59, 0xaa, 0x61, 0x17, 0xad, 0x3, 0x0, 0x14, 0x15, 0x8b, 0x6a, 0xd7, 0xbd, 0xbf, - 0xa2, 0x49, 0x71, 0xed, 0xf0, 0x71, 0x7d, 0x8f, 0xb0, 0x83, 0xe8, 0xe4, 0xb0, 0x23, 0x22, 0x3c, - 0xe5, 0x29, 0x36, 0x13, 0x48, 0xb5, 0x11, 0x0, 0x0, 0x4d, 0x85, 0x11, 0x0, 0x0, 0x51, 0x66, - 0x1f, 0x0, 0x1c, 0xa8, 0xa4, 0xfc, 0xbe, 0x8f, 0xa4, 0x8d, 0xc6, 0x0, 0xb0, 0x8a, 0xeb, 0x18, - 0xbb, 0x4b, 0xc1, 0x2a, 0x1f, 0x93, 0x1a, 0xfe, 0x2b, 0xca, 0x79, 0x96, 0x7d, 0xd4, 0x7b, 0x3, - 0x0, 0x0, 0x1, 0xe1, 0x27, 0x0, 0x0, 0x32, 0x71, 0x22, 0x4e, 0x64, 0x9, 0x0, 0x7, 0x40, - 0xb5, 0x49, 0x30, 0x8c, 0xb6, 0x1c, 0x1, 0x8f, 0x97, 0x0, 0x80}; + uint8_t pkt[] = {0x90, 0x15, 0x55, 0x56, 0x9, 0x8, 0x0, 0x3, 0x31, 0xdb, 0xc3, 0x21, + 0x3e, 0x2a, 0x8f, 0x83, 0x2, 0x1, 0x0, 0x0, 0x83, 0x8f, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 22954); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], 0x8F); - EXPECT_EQ(granted_qos_levels[2], 0x97); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(packet_id, 21846); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0x8F); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x83); + EXPECT_EQ(granted_qos_levels[7], 0x8F); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); } -// SubscribeResponse 18733 [Right QoS2,Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrPacketIdentifierInUse,Right QoS2,Right QoS1,Right QoS1] [PropPayloadFormatIndicator -// 98,PropSharedSubscriptionAvailable 87,PropRequestResponseInformation 52,PropCorrelationData -// "\134>?J\255\142\&8PT\238<\NUL\198.\165\206\229\a\216\211\239-X\218jL\249"] +// SubscribeResponse 25983 [Right QoS2] [PropContentType +// "\226\147\228\236\217\ACK\EM\208\EOT\226\&2R\194\220?o\ESC\195;\167",PropAuthenticationData +// "s);\STX\212}\159\149\EOTojM]X\190\250\243\255\206y\228\247W\184\FS",PropTopicAlias +// 7197,PropSharedSubscriptionAvailable 46,PropRequestResponseInformation 68,PropResponseInformation +// "\133S\SIZy\249@",PropReasonString "8'\180\EOT\178V\144\210\133\198b\\V\146l\US|a\218\&4\v",PropAuthenticationMethod +// "\SOHwl<\204K\233\221\SI",PropReceiveMaximum 20194,PropWildcardSubscriptionAvailable 45,PropMessageExpiryInterval +// 5182,PropContentType "\197\158\212\SOH\163\206\241`\177G\164\238\RS\187\185\v",PropContentType +// "Kb\140.\224\233\144\182E\"B\214\DLE\162Ry\228o\135\180\DC1\SI\139\&4\ESC\168\246\CANE|",PropContentType +// "\172X\191\201\149\166\DC3\212\218\\\137\193\255\179\GS_\230\232\tS\169\137\SOH\202Y\ETBH\208\133",PropWildcardSubscriptionAvailable +// 87,PropTopicAlias 26805,PropReasonString +// "r\ETX\137\EOT@\223,\222\DC4b\EOT\229\152\EOT\ENQ\ENQC\157i\SO\234\DLE\EOT",PropPayloadFormatIndicator +// 16,PropAssignedClientIdentifier "\151\253;#\236\208/;\ENQq\138\157KR\239\169\230.\150\203,l\137\197",PropReasonString +// "\253`j\135K\142\ENQ6\182\t",PropRetainAvailable 151,PropSubscriptionIdentifierAvailable 255,PropResponseInformation +// "",PropReceiveMaximum 23704,PropReasonString "\ACK\235I\SOH\208\254\150l\172",PropAuthenticationMethod +// "e*{\ESC\215H2\SYN!\re1\208G\173[\SYNdX\194\185\FS\DLE\142[dyt",PropAssignedClientIdentifier +// "\227\SYN\147\170O\223\v\RSp\219D\ETB",PropMaximumPacketSize 23197] TEST(SubACK5QCTest, Decode24) { - uint8_t pkt[] = {0x90, 0x2d, 0x49, 0x2d, 0x24, 0x1, 0x62, 0x2a, 0x57, 0x19, 0x34, 0x9, 0x0, 0x1b, 0x86, 0x3e, - 0x3f, 0x4a, 0xff, 0x8e, 0x38, 0x50, 0x54, 0xee, 0x3c, 0x0, 0xc6, 0x2e, 0xa5, 0xce, 0xe5, 0x7, - 0xd8, 0xd3, 0xef, 0x2d, 0x58, 0xda, 0x6a, 0x4c, 0xf9, 0x2, 0xa2, 0x91, 0x2, 0x1, 0x1}; + uint8_t pkt[] = { + 0x90, 0xdd, 0x2, 0x65, 0x7f, 0xd8, 0x2, 0x3, 0x0, 0x14, 0xe2, 0x93, 0xe4, 0xec, 0xd9, 0x6, 0x19, 0xd0, 0x4, + 0xe2, 0x32, 0x52, 0xc2, 0xdc, 0x3f, 0x6f, 0x1b, 0xc3, 0x3b, 0xa7, 0x16, 0x0, 0x19, 0x73, 0x29, 0x3b, 0x2, 0xd4, + 0x7d, 0x9f, 0x95, 0x4, 0x6f, 0x6a, 0x4d, 0x5d, 0x58, 0xbe, 0xfa, 0xf3, 0xff, 0xce, 0x79, 0xe4, 0xf7, 0x57, 0xb8, + 0x1c, 0x23, 0x1c, 0x1d, 0x2a, 0x2e, 0x19, 0x44, 0x1a, 0x0, 0x7, 0x85, 0x53, 0xf, 0x5a, 0x79, 0xf9, 0x40, 0x1f, + 0x0, 0x15, 0x38, 0x27, 0xb4, 0x4, 0xb2, 0x56, 0x90, 0xd2, 0x85, 0xc6, 0x62, 0x5c, 0x56, 0x92, 0x6c, 0x1f, 0x7c, + 0x61, 0xda, 0x34, 0xb, 0x15, 0x0, 0x9, 0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 0x0, 0x9, 0x6, 0xeb, 0x49, 0x1, 0xd0, 0xfe, 0x96, 0x6c, 0xac, 0x15, 0x0, 0x1c, 0x65, + 0x2a, 0x7b, 0x1b, 0xd7, 0x48, 0x32, 0x16, 0x21, 0xd, 0x65, 0x31, 0xd0, 0x47, 0xad, 0x5b, 0x16, 0x64, 0x58, 0xc2, + 0xb9, 0x1c, 0x10, 0x8e, 0x5b, 0x64, 0x79, 0x74, 0x12, 0x0, 0xc, 0xe3, 0x16, 0x93, 0xaa, 0x4f, 0xdf, 0xb, 0x1e, + 0x70, 0xdb, 0x44, 0x17, 0x27, 0x0, 0x0, 0x5a, 0x9d, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18733); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 25983); + EXPECT_EQ(count, 1); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0xA2); - EXPECT_EQ(granted_qos_levels[2], 0x91); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 22455 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrQuotaExceeded,Left -// SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded,Right QoS0,Left -// SubErrTopicFilterInvalid,Right QoS1,Right QoS1] [PropMaximumQoS 125,PropCorrelationData -// "\US\144ST\228\202\ETX\225\EOT\163-\199\201 \191\180\235sf\n\186\158",PropReasonString -// "\NUL\FS\235\&6k\143v\171\SO\166\189\190x\254\162\243\182\255\157\222*d\219\178\187D",PropUserProperty -// "\231\144\n,\152\201\147\232\FSX\141B\158WY\182\166\242\244\ACK\230\165\233<)\165" -// "h\r9f\203\&8\202\146\DC4x\SI0\188\176\168\157\FSGj\157{FV\239\182Y",PropAuthenticationMethod -// "\231\&7\204\DELr\210\NUL\t7\162\245\&6H\136q\190\201\139v",PropTopicAliasMaximum -// 24385,PropSubscriptionIdentifierAvailable 37,PropAssignedClientIdentifier -// "q\149\212\165\220\240\146\&4b\167\164\244\180\165\254\191l\183\199@R",PropMessageExpiryInterval -// 23,PropSessionExpiryInterval 16436,PropAuthenticationMethod "",PropReceiveMaximum 8596,PropSessionExpiryInterval -// 14740,PropCorrelationData "\196A\NUL5\213\197J<@\180\STX\134W",PropAuthenticationData -// "\EOT\217`\180x\206\206!\187\204\172\236\&2B\189\235\167jap\161\196\&3wxl\131",PropPayloadFormatIndicator -// 140,PropContentType "\144\224\155\219\&5C\178\EM>\ESC./I\GS\242yx}\146\227=v\250DM\157",PropRequestProblemInformation -// 132,PropResponseTopic "b\RS\208r(#\a'\EOT\CAN\236h\187\213\tc\189`\243p\184q_\157\&4",PropReceiveMaximum -// 27370,PropMaximumPacketSize 23288,PropSubscriptionIdentifier 29,PropReasonString -// "[\169\145/\185f$\ESC\222\179'\226\134\ACK\129\218=A\DLE",PropServerReference -// "\187\US\179]\140\&4f\238",PropResponseInformation "\213\ENQ -// N\ACK\198v\STX6\231-\161\&0\132v\128\249",PropTopicAliasMaximum 27985,PropSharedSubscriptionAvailable -// 107,PropSubscriptionIdentifierAvailable 62] +// SubscribeResponse 803 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrNotAuthorized,Right +// QoS2,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [PropResponseInformation +// "\198d&ULmk\177@C\ETB\212\229\213\246\193\222\SOH\204",PropRequestResponseInformation 141,PropWillDelayInterval +// 31029,PropMessageExpiryInterval 293,PropMaximumQoS 13,PropUserProperty "\143" +// "a\153Z\DEL\162d\248\129\255\133\173\178R7\173\162\206=\212\DC4",PropAuthenticationData +// "\212%mM\160\229\196\206\140\135\236tC\154>Q\NUL\196|",PropCorrelationData +// "\136.\179z\150\154Z-\232\fL\232",PropMessageExpiryInterval 16324,PropSubscriptionIdentifierAvailable +// 30,PropMessageExpiryInterval 25682,PropWildcardSubscriptionAvailable 61] TEST(SubACK5QCTest, Decode25) { - uint8_t pkt[] = { - 0x90, 0xf7, 0x2, 0x57, 0xb7, 0xea, 0x2, 0x24, 0x7d, 0x9, 0x0, 0x16, 0x1f, 0x90, 0x53, 0x54, 0xe4, 0xca, 0x3, - 0xe1, 0x4, 0xa3, 0x2d, 0xc7, 0xc9, 0x20, 0xbf, 0xb4, 0xeb, 0x73, 0x66, 0xa, 0xba, 0x9e, 0x1f, 0x0, 0x1a, 0x0, - 0x1c, 0xeb, 0x36, 0x6b, 0x8f, 0x76, 0xab, 0xe, 0xa6, 0xbd, 0xbe, 0x78, 0xfe, 0xa2, 0xf3, 0xb6, 0xff, 0x9d, 0xde, - 0x2a, 0x64, 0xdb, 0xb2, 0xbb, 0x44, 0x26, 0x0, 0x1a, 0xe7, 0x90, 0xa, 0x2c, 0x98, 0xc9, 0x93, 0xe8, 0x1c, 0x58, - 0x8d, 0x42, 0x9e, 0x57, 0x59, 0xb6, 0xa6, 0xf2, 0xf4, 0x6, 0xe6, 0xa5, 0xe9, 0x3c, 0x29, 0xa5, 0x0, 0x1a, 0x68, - 0xd, 0x39, 0x66, 0xcb, 0x38, 0xca, 0x92, 0x14, 0x78, 0xf, 0x30, 0xbc, 0xb0, 0xa8, 0x9d, 0x1c, 0x47, 0x6a, 0x9d, - 0x7b, 0x46, 0x56, 0xef, 0xb6, 0x59, 0x15, 0x0, 0x13, 0xe7, 0x37, 0xcc, 0x7f, 0x72, 0xd2, 0x0, 0x9, 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count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 22455); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], 0x97); - EXPECT_EQ(granted_qos_levels[2], 0x8F); - EXPECT_EQ(granted_qos_levels[3], 0xA1); - EXPECT_EQ(granted_qos_levels[4], 0x97); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x8F); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 803); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0xA2); + EXPECT_EQ(granted_qos_levels[2], 0x87); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0xA1); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); } -// SubscribeResponse 556 [Right QoS1,Left SubErrImplementationSpecificError,Right QoS1] [PropCorrelationData -// "\r\176\163\148\188\204\158}\243\207\214Z\b\a\208\157",PropRequestProblemInformation -// 75,PropSubscriptionIdentifierAvailable 129,PropAssignedClientIdentifier -// "\EOTx=`\208\142\153\149\224\224\161)@\166\SYN\EOT\224\162*\129*.;~\254\&1\193\252p8",PropMaximumQoS -// 38,PropAuthenticationMethod "Hb)\a{V[\252j\206^\222\&3\221V\192G\255o",PropRequestProblemInformation -// 31,PropWillDelayInterval 5553,PropMessageExpiryInterval 2889,PropWillDelayInterval 21169,PropAssignedClientIdentifier -// "\176m\159`Q\ETBF\196\DC4+\vv",PropResponseInformation -// "Tp7\179\236\EM\179kwZ\212g\143$\128\208\150*(\208q\255*\236\128\EM;",PropReasonString -// "\135\189\172\247\130\153\174\240\246\207\161,\201",PropMaximumQoS 212,PropRequestResponseInformation -// 227,PropCorrelationData "^\\k#\DC3\159\240\ENQ\208{\167[ml\253\173\b\163\134\157\185",PropWillDelayInterval -// 20829,PropServerKeepAlive 21836,PropReceiveMaximum 9146,PropWillDelayInterval 6516,PropResponseInformation -// "\227\203\253\152\aj"] +// SubscribeResponse 6677 [Right QoS0,Right QoS1,Left SubErrTopicFilterInvalid,Left +// SubErrImplementationSpecificError,Right QoS0,Right QoS1,Right QoS2,Right QoS2,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrNotAuthorized,Right QoS0] [PropTopicAliasMaximum +// 15406,PropMaximumPacketSize 23595,PropReasonString " \193\129.\STXT\160",PropAuthenticationMethod +// "\181\&0",PropCorrelationData "\185\169\158\190V\137\206\aH&l\138\159z\233\RS\254\&6\ENQ\144",PropMaximumPacketSize +// 1098,PropRequestResponseInformation 86,PropMaximumPacketSize 5354,PropSharedSubscriptionAvailable +// 83,PropRequestProblemInformation 221,PropRequestProblemInformation 203,PropRequestResponseInformation +// 204,PropResponseInformation "*>=\DC3z \252",PropContentType +// "$\133:\188N\213\STXk\144@\226\SYNSd\147\ETX\187",PropAuthenticationData +// "\226]\238\t\234,\251\154\153y\b\132",PropMessageExpiryInterval 17116,PropWildcardSubscriptionAvailable +// 4,PropReceiveMaximum 32286,PropWillDelayInterval 16552,PropCorrelationData +// "t\187\179\f\200\178",PropSharedSubscriptionAvailable 251,PropResponseTopic +// "\178\181$\156\245$M\GS\189h\SIy\129\169\204",PropContentType +// "L\v\247\232\254\209a}\140=\241'\238\236\f\EM,\237",PropRequestProblemInformation -// 62,PropSharedSubscriptionAvailable 29,PropWildcardSubscriptionAvailable 131,PropRequestResponseInformation -// 224,PropTopicAlias 32256,PropRequestProblemInformation 194,PropSharedSubscriptionAvailable 79,PropRetainAvailable -// 34,PropRetainAvailable 19,PropSharedSubscriptionAvailable 92,PropContentType -// "\150\160\236\SYNp}\f",PropSubscriptionIdentifierAvailable 213,PropServerKeepAlive 8068] + EXPECT_EQ(packet_id, 6677); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x8F); + EXPECT_EQ(granted_qos_levels[3], 0x83); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[8], 0xA1); + EXPECT_EQ(granted_qos_levels[9], 0x87); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); +} + +// SubscribeResponse 7481 [Left SubErrNotAuthorized,Right QoS1,Right QoS2,Left SubErrNotAuthorized] [PropServerKeepAlive +// 8029,PropAuthenticationMethod "rS\179\220\137\207\170\247v8D0\ETBs\206\191\v\156/\158\173",PropServerKeepAlive +// 2400,PropRequestProblemInformation 151,PropAuthenticationMethod +// "\170\139\188\SOH+\130\184\166\189\GS\221J}\230v\ACKU\143\DC4\150\254.}E\SUBj",PropTopicAlias +// 18638,PropMessageExpiryInterval 5512,PropReasonString +// "\195\218\"\223\244\188\a\130\ETB6\211X\230Xt\128v\163",PropWildcardSubscriptionAvailable 58,PropServerKeepAlive +// 17394] TEST(SubACK5QCTest, Decode27) { - uint8_t pkt[] = {0x90, 0x85, 0x1, 0x3c, 0x39, 0x7e, 0x2, 0x0, 0x0, 0xd, 0xe, 0x15, 0x0, 0x13, 0xc5, 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7d, 0x45, 0x1a, 0x6a, 0x23, 0x48, 0xce, 0x2, 0x0, 0x0, 0x15, 0x88, 0x1f, + 0x0, 0x12, 0xc3, 0xda, 0x22, 0xdf, 0xf4, 0xbc, 0x7, 0x82, 0x17, 0x36, 0xd3, 0x58, 0xe6, + 0x58, 0x74, 0x80, 0x76, 0xa3, 0x28, 0x3a, 0x13, 0x43, 0xf2, 0x87, 0x1, 0x2, 0x87}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[4]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15417); + EXPECT_EQ(packet_id, 7481); EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0xA2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[0], 0x87); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[3], 0x87); } -// SubscribeResponse 26950 [Left SubErrImplementationSpecificError,Right QoS2,Right QoS2,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [PropSubscriptionIdentifierAvailable -// 90,PropAssignedClientIdentifier "\245\DC3x\171w\SOx\129\DC3\a\249\239\252\188Y<\149>",PropReasonString -// "\194\253\ENQE\169\153\t8A?1S\200\249",PropServerReference "\211'\b\129:\147a\191",PropAuthenticationData -// "\162",PropMaximumPacketSize 9056,PropSubscriptionIdentifierAvailable 35,PropSessionExpiryInterval -// 8594,PropAuthenticationMethod "\238\150\215\189\233\132\SO\192\167^\SYN",PropCorrelationData "\155Si;8'7 -// nh\232\209+Q6\FS",PropSharedSubscriptionAvailable 107,PropSessionExpiryInterval 16867,PropResponseInformation -// "\185\ESCf"] +// SubscribeResponse 26117 [Right QoS2,Right QoS0,Right QoS0] [PropReasonString +// "\NAK\203\155",PropRequestProblemInformation 235,PropWildcardSubscriptionAvailable 50,PropContentType +// "\176E\219\128\153\155\152\147\154AT\200T\150\SOH0\RS",PropWildcardSubscriptionAvailable 9,PropResponseInformation +// "%\248\239",PropSharedSubscriptionAvailable 2,PropPayloadFormatIndicator 46,PropAuthenticationData +// "\181\147\SO\237\203\159H\199\v\US\177\129E\221)UD\156\188"] TEST(SubACK5QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0x79, 0x69, 0x46, 0x71, 0x29, 0x5a, 0x12, 0x0, 0x12, 0xf5, 0x13, 0x78, 0xab, 0x77, 0xe, - 0x78, 0x81, 0x13, 0x7, 0xf9, 0xef, 0xfc, 0xbc, 0x59, 0x3c, 0x95, 0x3e, 0x1f, 0x0, 0xe, 0xc2, - 0xfd, 0x5, 0x45, 0xa9, 0x99, 0x9, 0x38, 0x41, 0x3f, 0x31, 0x53, 0xc8, 0xf9, 0x1c, 0x0, 0x8, - 0xd3, 0x27, 0x8, 0x81, 0x3a, 0x93, 0x61, 0xbf, 0x16, 0x0, 0x1, 0xa2, 0x27, 0x0, 0x0, 0x23, - 0x60, 0x29, 0x23, 0x11, 0x0, 0x0, 0x21, 0x92, 0x15, 0x0, 0xb, 0xee, 0x96, 0xd7, 0xbd, 0xe9, - 0x84, 0xe, 0xc0, 0xa7, 0x5e, 0x16, 0x9, 0x0, 0x10, 0x9b, 0x53, 0x69, 0x3b, 0x38, 0x27, 0x37, - 0x20, 0x6e, 0x68, 0xe8, 0xd1, 0x2b, 0x51, 0x36, 0x1c, 0x2a, 0x6b, 0x11, 0x0, 0x0, 0x41, 0xe3, - 0x1a, 0x0, 0x3, 0xb9, 0x1b, 0x66, 0x83, 0x2, 0x2, 0xa1, 0x1}; + uint8_t pkt[] = {0x90, 0x46, 0x66, 0x5, 0x40, 0x1f, 0x0, 0x3, 0x15, 0xcb, 0x9b, 0x17, 0xeb, 0x28, 0x32, + 0x3, 0x0, 0x11, 0xb0, 0x45, 0xdb, 0x80, 0x99, 0x9b, 0x98, 0x93, 0x9a, 0x41, 0x54, 0xc8, + 0x54, 0x96, 0x1, 0x30, 0x1e, 0x28, 0x9, 0x1a, 0x0, 0x3, 0x25, 0xf8, 0xef, 0x2a, 0x2, + 0x1, 0x2e, 0x16, 0x0, 0x13, 0xb5, 0x93, 0xe, 0xed, 0xcb, 0x9f, 0x48, 0xc7, 0xb, 0x1f, + 0xb1, 0x81, 0x45, 0xdd, 0x29, 0x55, 0x44, 0x9c, 0xbc, 0x2, 0x0, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26950); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x83); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0xA1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 26117); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); } -// SubscribeResponse 24196 [Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Left -// SubErrImplementationSpecificError,Right QoS0,Right QoS0,Left SubErrTopicFilterInvalid,Left -// SubErrPacketIdentifierInUse,Right QoS2] [PropSessionExpiryInterval 3870,PropSubscriptionIdentifierAvailable -// 240,PropAuthenticationMethod -// "\177\&3\SOH\212\US\176\160\237z\230\255\173\236[}u\135\240\137\187\159\140\191]",PropSubscriptionIdentifier -// 29,PropMaximumQoS 47,PropReasonString "\233*\a\152l~OR\188\184o\139",PropServerKeepAlive 12968,PropTopicAliasMaximum -// 5292,PropResponseInformation "1A\219XL\n\212\n\220\137\213",PropResponseTopic -// "\DC3\164q\212X\ACK\201D\164\128\&9\182\&8D6&",PropMaximumPacketSize 2747] +// SubscribeResponse 4603 [Left SubErrWildcardSubscriptionsNotSupported] [PropServerReference +// "\226\204`2\212\&4tl\135\151L\154\149&",PropWildcardSubscriptionAvailable 197,PropSessionExpiryInterval +// 21325,PropAssignedClientIdentifier "\ACKc\180\232\225\182N\181\206\169\129<$",PropWildcardSubscriptionAvailable +// 166,PropServerKeepAlive 21338,PropServerKeepAlive 8899,PropWildcardSubscriptionAvailable +// 156,PropMessageExpiryInterval 3096,PropServerKeepAlive 25030,PropSubscriptionIdentifier 29,PropPayloadFormatIndicator +// 59,PropServerKeepAlive 5386,PropWildcardSubscriptionAvailable 67,PropMessageExpiryInterval 14429] TEST(SubACK5QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0x6d, 0x5e, 0x84, 0x61, 0x11, 0x0, 0x0, 0xf, 0x1e, 0x29, 0xf0, 0x15, 0x0, 0x18, 0xb1, - 0x33, 0x1, 0xd4, 0x1f, 0xb0, 0xa0, 0xed, 0x7a, 0xe6, 0xff, 0xad, 0xec, 0x5b, 0x7d, 0x75, 0x87, - 0xf0, 0x89, 0xbb, 0x9f, 0x8c, 0xbf, 0x5d, 0xb, 0x1d, 0x24, 0x2f, 0x1f, 0x0, 0xc, 0xe9, 0x2a, - 0x7, 0x98, 0x6c, 0x7e, 0x4f, 0x52, 0xbc, 0xb8, 0x6f, 0x8b, 0x13, 0x32, 0xa8, 0x22, 0x14, 0xac, - 0x1a, 0x0, 0xb, 0x31, 0x41, 0xdb, 0x58, 0x4c, 0xa, 0xd4, 0xa, 0xdc, 0x89, 0xd5, 0x8, 0x0, - 0x10, 0x13, 0xa4, 0x71, 0xd4, 0x58, 0x6, 0xc9, 0x44, 0xa4, 0x80, 0x39, 0xb6, 0x38, 0x44, 0x36, - 0x26, 0x27, 0x0, 0x0, 0xa, 0xbb, 0x9e, 0x1, 0x8f, 0x83, 0x0, 0x0, 0x8f, 0x91, 0x2}; + uint8_t pkt[] = {0x90, 0x4c, 0x11, 0xfb, 0x48, 0x1c, 0x0, 0xe, 0xe2, 0xcc, 0x60, 0x32, 0xd4, 0x34, 0x74, 0x6c, + 0x87, 0x97, 0x4c, 0x9a, 0x95, 0x26, 0x28, 0xc5, 0x11, 0x0, 0x0, 0x53, 0x4d, 0x12, 0x0, 0xd, + 0x6, 0x63, 0xb4, 0xe8, 0xe1, 0xb6, 0x4e, 0xb5, 0xce, 0xa9, 0x81, 0x3c, 0x24, 0x28, 0xa6, 0x13, + 0x53, 0x5a, 0x13, 0x22, 0xc3, 0x28, 0x9c, 0x2, 0x0, 0x0, 0xc, 0x18, 0x13, 0x61, 0xc6, 0xb, + 0x1d, 0x1, 0x3b, 0x13, 0x15, 0xa, 0x28, 0x43, 0x2, 0x0, 0x0, 0x38, 0x5d, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24196); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x8F); - EXPECT_EQ(granted_qos_levels[3], 0x83); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x8F); - EXPECT_EQ(granted_qos_levels[7], 0x91); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 4603); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], 0xA2); } -// SubscribeResponse 19551 [Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrUnspecifiedError,Right QoS1,Right -// QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrQuotaExceeded,Right QoS0] [PropResponseTopic "\251!\DELS\130\176\&6\CAN>r\196\211\217\209",PropAuthenticationMethod +// "=\228ya-\142\EMD\232\217\137\129=\177\214}\192`\205",PropServerKeepAlive 20374,PropTopicAliasMaximum +// 22407,PropWildcardSubscriptionAvailable 208,PropReceiveMaximum 17593,PropMessageExpiryInterval +// 31603,PropReceiveMaximum 17390,PropCorrelationData "\SOm\151\203y\242\191(\173g\178\&9\199>U\187Z\228"] TEST(SubACK5QCTest, Decode30) { - uint8_t pkt[] = {0x90, 0x96, 0x1, 0x4c, 0x5f, 0x88, 0x1, 0x8, 0x0, 0xe, 0xfb, 0x21, 0x3c, 0x76, 0x1d, 0x7b, 0x84, - 0xf7, 0x40, 0xb3, 0x85, 0x54, 0x4a, 0x8a, 0x13, 0x5b, 0x9b, 0x1, 0x28, 0x2, 0x0, 0x0, 0x6f, 0x3, - 0x25, 0xd2, 0x17, 0x51, 0x1f, 0x0, 0x13, 0x16, 0x3a, 0x3, 0xdd, 0xd9, 0x7a, 0x7e, 0x6c, 0x81, 0xa7, - 0x62, 0x9b, 0x9, 0x7b, 0xbc, 0x89, 0x3f, 0x49, 0x69, 0x2a, 0xc1, 0x26, 0x0, 0x1d, 0xf1, 0x84, 0xe7, - 0x1, 0x56, 0x64, 0x97, 0xab, 0x67, 0x57, 0x9c, 0xa3, 0x96, 0x75, 0x35, 0x74, 0xa8, 0xcc, 0x49, 0xed, - 0xa9, 0xae, 0x30, 0x98, 0xfb, 0x8, 0x96, 0x71, 0x67, 0x0, 0x9, 0x40, 0xa7, 0x9e, 0x9f, 0x37, 0x80, - 0xfc, 0x8, 0xac, 0x25, 0x44, 0x13, 0x3a, 0xb, 0x2, 0x0, 0x0, 0x6, 0x49, 0x1c, 0x0, 0x2, 0xe7, - 0xef, 0x1f, 0x0, 0x3, 0x2e, 0xf0, 0xcd, 0x2, 0x0, 0x0, 0x28, 0xe5, 0x8, 0x0, 0x9, 0xb2, 0x83, - 0xf4, 0x34, 0xee, 0x86, 0xd3, 0x2f, 0xa8, 0x91, 0x2, 0x80, 0x1, 0x2, 0x91, 0x1, 0x9e, 0x97, 0x0}; + uint8_t pkt[] = { + 0x90, 0xf0, 0x1, 0x7d, 0x19, 0xeb, 0x1, 0x9, 0x0, 0x15, 0x0, 0x75, 0xa0, 0xfb, 0xf7, 0x97, 0x4f, 0x14, 0x24, + 0x73, 0x34, 0x59, 0x5c, 0xfc, 0x1b, 0x65, 0x3d, 0x12, 0xdf, 0xb3, 0x58, 0x1c, 0x0, 0xc, 0x6, 0x41, 0xc2, 0x4b, + 0x80, 0xf1, 0x20, 0xc1, 0xc0, 0x51, 0x6a, 0xb, 0x25, 0x90, 0x26, 0x0, 0x8, 0xc3, 0xd0, 0x0, 0x94, 0x49, 0x1d, + 0x89, 0x10, 0x0, 0x10, 0xea, 0x66, 0xd8, 0x91, 0x36, 0x26, 0xa, 0x67, 0x78, 0x70, 0x26, 0x51, 0x9a, 0x2a, 0x82, + 0x77, 0x12, 0x0, 0x12, 0x1e, 0x98, 0xe2, 0xd3, 0xa6, 0x86, 0x5c, 0x16, 0xee, 0xb4, 0x17, 0x31, 0x37, 0x5a, 0x7, + 0x28, 0xb0, 0x59, 0x12, 0x0, 0x1e, 0xe3, 0xbc, 0x49, 0xfe, 0xa2, 0xb8, 0xc1, 0x3f, 0xd2, 0x43, 0x8d, 0xc5, 0x9e, + 0x5a, 0xbf, 0x8f, 0xc4, 0x74, 0x33, 0x1, 0x95, 0xf6, 0x7c, 0x2c, 0xc1, 0xb6, 0x40, 0x7e, 0xef, 0xbf, 0x15, 0x0, + 0x1, 0xda, 0x13, 0x10, 0xf, 0x28, 0x73, 0x24, 0x5d, 0x1a, 0x0, 0x1, 0x1b, 0x1, 0x1a, 0x9, 0x0, 0x1d, 0xb6, + 0x7c, 0x1e, 0xf8, 0xbf, 0xff, 0x37, 0xb4, 0xdc, 0x1c, 0x28, 0x25, 0xba, 0xa0, 0x7, 0xdd, 0x3e, 0x7f, 0x53, 0x82, + 0xb0, 0x36, 0x18, 0x3e, 0x72, 0xc4, 0xd3, 0xd9, 0xd1, 0x15, 0x0, 0x13, 0x3d, 0xe4, 0x79, 0x61, 0x2d, 0x8e, 0x19, + 0x44, 0xe8, 0xd9, 0x89, 0x81, 0x3d, 0xb1, 0xd6, 0x7d, 0xc0, 0x60, 0xcd, 0x13, 0x4f, 0x96, 0x22, 0x57, 0x87, 0x28, + 0xd0, 0x21, 0x44, 0xb9, 0x2, 0x0, 0x0, 0x7b, 0x73, 0x21, 0x43, 0xee, 0x9, 0x0, 0x12, 0xe, 0x6d, 0x97, 0xcb, + 0x79, 0xf2, 0xbf, 0x28, 0xad, 0x67, 0xb2, 0x39, 0xc7, 0x3e, 0x55, 0xbb, 0x5a, 0xe4, 0x91}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19551); - EXPECT_EQ(count, 10); + EXPECT_EQ(packet_id, 32025); + EXPECT_EQ(count, 1); EXPECT_EQ(granted_qos_levels[0], 0x91); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], 0x91); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], 0x9E); - EXPECT_EQ(granted_qos_levels[8], 0x97); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); } -// UnsubscribeRequest 21005 -// ["\162U\229Q\203:\151\212\213\175Q\163\a\240\194\211\147\&1\196\251\US\142\159>\129\227\142\140","\191\&2\206V\211\208jL\223\162M\237i\241\128\DC1R\160UJ\195\175\194R\213","\213?\174\187\RS\DEL\245 -// \199\246\204","6\147z\129\248e\186\239\143\190\200\231\233\244\170(\225[\f\254\202\159-VJ\255Pp!","H\191\171\135\157){d~\181\190","\FSe\146\150\222","\DLE\228\196{\157hG\135~RV^\EOT5","\243\212\198\a\157\193\174\231\196\129N\182\137\243w"] +// UnsubscribeRequest 24378 ["\214\DC35\253\159\129F#\236\204y?\150\128\DC2u\230\211 +// O\133\185\r\135\163\177","\225\161,\196C\187\132IH\245\164\210!e\185\145e\139\243\181X8\n\242\182\204\151^\228","{\SUBC\158","\252\142\163gsP\ACK\133\234LY\203\&8\183\251\223\147\128\249","G}\173\207o\181\247\NULk\180\255\243\157o\SOH\199\NAKxD6","\220\ACK\170\&3)c\200`\251o\158"] // [] TEST(Unsubscribe311QCTest, Encode1) { - uint8_t pkt[] = {0xa2, 0x9c, 0x1, 0x52, 0xd, 0x0, 0x1c, 0xa2, 0x55, 0xe5, 0x51, 0xcb, 0x3a, 0x97, 0xd4, 0xd5, - 0xaf, 0x51, 0xa3, 0x7, 0xf0, 0xc2,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 0xa4, 0xd2, 0x21, 0x65, + 0xb9, 0x91, 0x65, 0x8b, 0xf3, 0xb5, 0x58, 0x38, 0xa, 0xf2, 0xb6, 0xcc, 0x97, 0x5e, 0xe4, 0x0, + 0x4, 0x7b, 0x1a, 0x43, 0x9e, 0x0, 0x13, 0xfc, 0x8e, 0xa3, 0x67, 0x73, 0x50, 0x6, 0x85, 0xea, + 0x4c, 0x59, 0xcb, 0x38, 0xb7, 0xfb, 0xdf, 0x93, 0x80, 0xf9, 0x0, 0x14, 0x47, 0x7d, 0xad, 0xcf, + 0x6f, 0xb5, 0xf7, 0x0, 0x6b, 0xb4, 0xff, 0xf3, 0x9d, 0x6f, 0x1, 0xc7, 0x15, 0x78, 0x44, 0x36, + 0x0, 0xb, 0xdc, 0x6, 0xaa, 0x33, 0x29, 0x63, 0xc8, 0x60, 0xfb, 0x6f, 0x9e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xa2, 0x55, 0xe5, 0x51, 0xcb, 0x3a, 0x97, 0xd4, 0xd5, 0xaf, - 0x51, 0xa3, 0x7, 0xf0, 0xc2, 0xd3, 0x93, 0x31, 0xc4, 0xfb, - 0x1f, 0x8e, 0x9f, 0x3e, 0x81, 0xe3, 0x8e, 0x8c}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xd6, 0x13, 0x35, 0xfd, 0x9f, 0x81, 0x46, 0x23, 0xec, 0xcc, 0x79, 0x3f, 0x96, + 0x80, 0x12, 0x75, 0xe6, 0xd3, 0x20, 0x4f, 0x85, 0xb9, 0xd, 0x87, 0xa3, 0xb1}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbf, 0x32, 0xce, 0x56, 0xd3, 0xd0, 0x6a, 0x4c, 0xdf, 0xa2, 0x4d, 0xed, 0x69, - 0xf1, 0x80, 0x11, 0x52, 0xa0, 0x55, 0x4a, 0xc3, 0xaf, 0xc2, 0x52, 0xd5}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe1, 0xa1, 0x2c, 0xc4, 0x43, 0xbb, 0x84, 0x49, 0x48, 0xf5, + 0xa4, 0xd2, 0x21, 0x65, 0xb9, 0x91, 0x65, 0x8b, 0xf3, 0xb5, + 0x58, 0x38, 0xa, 0xf2, 0xb6, 0xcc, 0x97, 0x5e, 0xe4}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd5, 0x3f, 0xae, 0xbb, 0x1e, 0x7f, 0xf5, 0x20, 0xc7, 0xf6, 0xcc}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7b, 0x1a, 0x43, 0x9e}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x36, 0x93, 0x7a, 0x81, 0xf8, 0x65, 0xba, 0xef, 0x8f, 0xbe, - 0xc8, 0xe7, 0xe9, 0xf4, 0xaa, 0x28, 0xe1, 0x5b, 0xc, 0xfe, - 0xca, 0x9f, 0x2d, 0x56, 0x4a, 0xff, 0x50, 0x70, 0x21}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfc, 0x8e, 0xa3, 0x67, 0x73, 0x50, 0x6, 0x85, 0xea, 0x4c, + 0x59, 0xcb, 0x38, 0xb7, 0xfb, 0xdf, 0x93, 0x80, 0xf9}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x48, 0xbf, 0xab, 0x87, 0x9d, 0x29, 0x7b, 0x64, 0x7e, 0xb5, 0xbe}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x47, 0x7d, 0xad, 0xcf, 0x6f, 0xb5, 0xf7, 0x0, 0x6b, 0xb4, + 0xff, 0xf3, 0x9d, 0x6f, 0x1, 0xc7, 0x15, 0x78, 0x44, 0x36}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1c, 0x65, 0x92, 0x96, 0xde}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xdc, 0x6, 0xaa, 0x33, 0x29, 0x63, 0xc8, 0x60, 0xfb, 0x6f, 0x9e}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x10, 0xe4, 0xc4, 0x7b, 0x9d, 0x68, 0x47, 0x87, 0x7e, 0x52, 0x56, 0x5e, 0x4, 0x35}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf3, 0xd4, 0xc6, 0x7, 0x9d, 0xc1, 0xae, 0xe7, - 0xc4, 0x81, 0x4e, 0xb6, 0x89, 0xf3, 0x77}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21005, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24378, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 17284 -// ["\219\&6\208\245\251\252\ESC\222\a\175]6\SUB\EM\187\163\135\251R\141\188\250_~#\250\154\253'6","\209\"I\SOW",":/\181!v\193\177A\DC4\ACK\181\218\218*\183\248\233","^}\ETB\204n1\129\156\159\193Y\160\v","\222}^v\153\247\244\185\129\n\220Cy\SUB\ETX","\247\184r"] +// UnsubscribeRequest 2051 +// ["","\193\252\EOT\NAK\244\187T\"A\224\181\EOT\232\248Q\175[\132*\231\160\&9cK\158\209wc1","A3\151\238\144\145\195:\165\&6R\SUB\239\198ypa\225\254\219\245\ETB\225\222e\GS","Q\EM\157\DC2\249\155h\249\139\&89)\243$\186u\190\135t\141\240\&7\164\246","\SUBTW","\132\180L","\212R\181Q4A7m,\SO\SYN\232I\181\207/\239\247\184\209\158w\SI_X0T","E\243","\225\CAN*E8Q\t-\252B\136.\247\185\250","\144e\204Xj","\195?}\251*\158\210a,W\235\&3\249\219Z\143;","\239\251","","\170/\199\164\194\231\210\t\165(#\r\235i\151d\176QN\SUBX\249\195",",\176%\165\203\137\141\230K\EOT\SUBc\197\155N\202\195\t","5\129\227KZ\180\&7\DC4y^","n\227a\231\134C~\181\163^]\213\146"] // [] TEST(Unsubscribe311QCTest, Encode5) { - uint8_t pkt[] = {0xa2, 0x49, 0x25, 0xbb, 0x0, 0x1, 0xfd, 0x0, 0x2, 0xa0, 0xbc, 0x0, 0x10, 0xf6, 0xcf, - 0x6f, 0xd5, 0x95, 0xb7, 0x6c, 0x84, 0x4d, 0xf4, 0x85, 0xa7, 0xf4, 0x42, 0x5b, 0xca, 0x0, - 0x1b, 0x14, 0xc5, 0x2e, 0xa, 0xf5, 0x98, 0x3c, 0xaa, 0x58, 0xb9, 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f[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xfd}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xc0, 0x65, 0xe5, 0x3e, 0xef, 0xf7, 0xb8, 0xd1, + 0x9e, 0x77, 0xf, 0x5f, 0x58, 0x30, 0x54}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa0, 0xbc}; + uint8_t topic_filter_s1_bytes[] = {0x45, 0xf3}; lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf6, 0xcf, 0x6f, 0xd5, 0x95, 0xb7, 0x6c, 0x84, - 0x4d, 0xf4, 0x85, 0xa7, 0xf4, 0x42, 0x5b, 0xca}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe1, 0x18, 0x2a, 0x45, 0x38, 0x51, 0x9, 0x2d, + 0xfc, 0x42, 0x88, 0x2e, 0xf7, 0xb9, 0xfa}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x14, 0xc5, 0x2e, 0xa, 0xf5, 0x98, 0x3c, 0xaa, 0x58, 0xb9, 0x1e, 0x3f, 0x38, 0xb1, - 0xed, 0x98, 0x5, 0xad, 0xad, 0xbf, 0xf9, 0x38, 0x78, 0x1b, 0xd7, 0x91, 0xfa}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x90, 0x65, 0xcc, 0x58, 0x6a}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9e, 0x46, 0x4, 0x2e, 0x1b, 0x19, 0x70, 0x1a, - 0xda, 0x39, 0x50, 0xac, 0x4c, 0x4a, 0xc6}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc3, 0x3f, 0x7d, 0xfb, 0x2a, 0x9e, 0xd2, 0x61, 0x2c, + 0x57, 0xeb, 0x33, 0xf9, 0xdb, 0x5a, 0x8f, 0x3b}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xef, 0xfb}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xaa, 0x2f, 0xc7, 0xa4, 0xc2, 0xe7, 0xd2, 0x9, 0xa5, 0x28, 0x23, 0xd, + 0xeb, 0x69, 0x97, 0x64, 0xb0, 0x51, 0x4e, 0x1a, 0x58, 0xf9, 0xc3}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x2c, 0xb0, 0x25, 0xa5, 0xcb, 0x89, 0x8d, 0xe6, 0x4b, + 0x4, 0x1a, 0x63, 0xc5, 0x9b, 0x4e, 0xca, 0xc3, 0x9}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x35, 0x81, 0xe3, 0x4b, 0x5a, 0xb4, 0x37, 0x14, 0x79, 0x5e}; + lwmqtt_string_t topic_filter_s9 = {10, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x6e, 0xe3, 0x61, 0xe7, 0x86, 0x43, 0x7e, 0xb5, 0xa3, 0x5e, 0x5d, 0xd5, 0x92}; + lwmqtt_string_t topic_filter_s10 = {13, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9659, 5, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2710, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5752 -// ["\a\tr\STXO4\140\DC2\166\&9\DC2\n\233","G\196\155\t.\170\213Y\229_\218\226k\NAKIi\229\145\SI\234","M!\NUL\223\224\185\128\215\200\186\241f\221vD\173\tW\162\EOT\200\&4!\n\160","Wu\227\181\230\224\215}\250\227\167\RS\140QIPk\192\135\b\STX\180\186\147\135U\174\155"] +// UnsubscribeRequest 5130 +// ["\246\197\169\&5\b\231f\149\170\236\240\171d\142Uq\241\RS\138\&2\222\160F\162\243\176NN\249\208","\STXt(\EM\234#}\242B~\248","","\166\"\128\192\131x\250\193\SOL\212\170\245\168)\237\134\187\204\232*+\218\EM7\r\142\EOTb\221\152l\148"] +// UnsubscribeRequest 10000 +// ["\FS\130\191W5L\182\156$\165\150tm\255l\234\202\179\208>\219\194\231\DELs\163","\188\202\DLE\SO\251z!\203\ETB\156.Mu\241\151","s\132\130\222\fE\142T\128\&3\v\230\218\&2\210_G6\128\220\251\STX","\t\171%#\219\251\SOH}\175@O\169","1d\CAN\f\SOH\183\253%F*","\195f\ry\161\STX\235\147\NAK\\\189\168","\SUBq;\RS\183\209\228z\166\187\217\155\EM\133[\133:\252\148\SYN","\207\ETB\179"] // [] TEST(Unsubscribe311QCTest, Encode7) { - uint8_t pkt[] = { - 0xa2, 0xa8, 0x1, 0x67, 0xde, 0x0, 0x9, 0x22, 0x80, 0x33, 0x60, 0x5a, 0x9a, 0x45, 0x49, 0x46, 0x0, 0x1d, 0xbf, - 0xd8, 0x80, 0x3c, 0x36, 0x9d, 0x80, 0xc, 0xcf, 0x9f, 0x26, 0x68, 0xcf, 0x4f, 0xeb, 0x7c, 0xa9, 0x67, 0xd, 0x14, - 0x89, 0x13, 0xaf, 0xb0, 0x33, 0xc9, 0x45, 0x4e, 0x15, 0x0, 0x14, 0x82, 0x7b, 0xd2, 0x48, 0xbb, 0x20, 0xdb, 0x71, - 0xfb, 0x77, 0x6c, 0xf7, 0x26, 0xa, 0x4a, 0x24, 0xb9, 0x10, 0x9e, 0xb3, 0x0, 0x19, 0xa7, 0x0, 0x3, 0xac, 0xcf, - 0x67, 0x64, 0x33, 0xfb, 0x43, 0xaa, 0xf, 0x4d, 0xef, 0x9d, 0x4f, 0xe9, 0xe0, 0x2d, 0xfb, 0x65, 0x2d, 0xe0, 0x94, - 0xbc, 0x0, 0x14, 0xb8, 0x15, 0xc6, 0x32, 0x89, 0xf, 0x3a, 0xa4, 0x13, 0x16, 0x28, 0x23, 0xae, 0xf2, 0xb3, 0x8a, - 0x3c, 0xce, 0x9d, 0x1f, 0x0, 0xc, 0xde, 0xe, 0x3d, 0xc2, 0xd2, 0x84, 0x75, 0xb9, 0xc0, 0xd, 0x35, 0xb5, 0x0, - 0x6, 0x4f, 0xe7, 0xf6, 0x87, 0xd1, 0x89, 0x0, 0x1d, 0x42, 0x3e, 0xfa, 0xc1, 0xe, 0x4c, 0xd4, 0xaa, 0xf5, 0xa8, - 0x29, 0xed, 0x86, 0xbb, 0xcc, 0xe8, 0x2a, 0x2b, 0xda, 0x19, 0x37, 0xd, 0x8e, 0x4, 0x62, 0xdd, 0x98, 0x6c, 0x94}; + uint8_t pkt[] = {0xa2, 0x8a, 0x1, 0x27, 0x10, 0x0, 0x1a, 0x1c, 0x82, 0xbf, 0x57, 0x35, 0x4c, 0xb6, 0x9c, 0x24, + 0xa5, 0x96, 0x74, 0x6d, 0xff, 0x6c, 0xea, 0xca, 0xb3, 0xd0, 0x3e, 0xdb, 0xc2, 0xe7, 0x7f, 0x73, + 0xa3, 0x0, 0xf, 0xbc, 0xca, 0x10, 0xe, 0xfb, 0x7a, 0x21, 0xcb, 0x17, 0x9c, 0x2e, 0x4d, 0x75, + 0xf1, 0x97, 0x0, 0x16, 0x73, 0x84, 0x82, 0xde, 0xc, 0x45, 0x8e, 0x54, 0x80, 0x33, 0xb, 0xe6, + 0xda, 0x32, 0xd2, 0x5f, 0x47, 0x36, 0x80, 0xdc, 0xfb, 0x2, 0x0, 0xc, 0x9, 0xab, 0x25, 0x23, + 0xdb, 0xfb, 0x1, 0x7d, 0xaf, 0x40, 0x4f, 0xa9, 0x0, 0xa, 0x31, 0x64, 0x18, 0xc, 0x1, 0xb7, + 0xfd, 0x25, 0x46, 0x2a, 0x0, 0xc, 0xc3, 0x66, 0xd, 0x79, 0xa1, 0x2, 0xeb, 0x93, 0x15, 0x5c, + 0xbd, 0xa8, 0x0, 0x14, 0x1a, 0x71, 0x3b, 0x1e, 0xb7, 0xd1, 0xe4, 0x7a, 0xa6, 0xbb, 0xd9, 0x9b, + 0x19, 0x85, 0x5b, 0x85, 0x3a, 0xfc, 0x94, 0x16, 0x0, 0x3, 0xcf, 0x17, 0xb3}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x22, 0x80, 0x33, 0x60, 0x5a, 0x9a, 0x45, 0x49, 0x46}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x1c, 0x82, 0xbf, 0x57, 0x35, 0x4c, 0xb6, 0x9c, 0x24, 0xa5, 0x96, 0x74, 0x6d, + 0xff, 0x6c, 0xea, 0xca, 0xb3, 0xd0, 0x3e, 0xdb, 0xc2, 0xe7, 0x7f, 0x73, 0xa3}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbf, 0xd8, 0x80, 0x3c, 0x36, 0x9d, 0x80, 0xc, 0xcf, 0x9f, - 0x26, 0x68, 0xcf, 0x4f, 0xeb, 0x7c, 0xa9, 0x67, 0xd, 0x14, - 0x89, 0x13, 0xaf, 0xb0, 0x33, 0xc9, 0x45, 0x4e, 0x15}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbc, 0xca, 0x10, 0xe, 0xfb, 0x7a, 0x21, 0xcb, + 0x17, 0x9c, 0x2e, 0x4d, 0x75, 0xf1, 0x97}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x82, 0x7b, 0xd2, 0x48, 0xbb, 0x20, 0xdb, 0x71, 0xfb, 0x77, - 0x6c, 0xf7, 0x26, 0xa, 0x4a, 0x24, 0xb9, 0x10, 0x9e, 0xb3}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x73, 0x84, 0x82, 0xde, 0xc, 0x45, 0x8e, 0x54, 0x80, 0x33, 0xb, + 0xe6, 0xda, 0x32, 0xd2, 0x5f, 0x47, 0x36, 0x80, 0xdc, 0xfb, 0x2}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa7, 0x0, 0x3, 0xac, 0xcf, 0x67, 0x64, 0x33, 0xfb, 0x43, 0xaa, 0xf, 0x4d, - 0xef, 0x9d, 0x4f, 0xe9, 0xe0, 0x2d, 0xfb, 0x65, 0x2d, 0xe0, 0x94, 0xbc}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9, 0xab, 0x25, 0x23, 0xdb, 0xfb, 0x1, 0x7d, 0xaf, 0x40, 0x4f, 0xa9}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb8, 0x15, 0xc6, 0x32, 0x89, 0xf, 0x3a, 0xa4, 0x13, 0x16, - 0x28, 0x23, 0xae, 0xf2, 0xb3, 0x8a, 0x3c, 0xce, 0x9d, 0x1f}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x64, 0x18, 0xc, 0x1, 0xb7, 0xfd, 0x25, 0x46, 0x2a}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xde, 0xe, 0x3d, 0xc2, 0xd2, 0x84, 0x75, 0xb9, 0xc0, 0xd, 0x35, 0xb5}; + uint8_t topic_filter_s5_bytes[] = {0xc3, 0x66, 0xd, 0x79, 0xa1, 0x2, 0xeb, 0x93, 0x15, 0x5c, 0xbd, 0xa8}; lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4f, 0xe7, 0xf6, 0x87, 0xd1, 0x89}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x1a, 0x71, 0x3b, 0x1e, 0xb7, 0xd1, 0xe4, 0x7a, 0xa6, 0xbb, + 0xd9, 0x9b, 0x19, 0x85, 0x5b, 0x85, 0x3a, 0xfc, 0x94, 0x16}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x42, 0x3e, 0xfa, 0xc1, 0xe, 0x4c, 0xd4, 0xaa, 0xf5, 0xa8, - 0x29, 0xed, 0x86, 0xbb, 0xcc, 0xe8, 0x2a, 0x2b, 0xda, 0x19, - 0x37, 0xd, 0x8e, 0x4, 0x62, 0xdd, 0x98, 0x6c, 0x94}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xcf, 0x17, 0xb3}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26590, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10000, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 28467 ["\188j71/\157\SUBlO\ESC","N\195\136\SUB[L\203?\219","\USk\146!\197w\FSR\152\254\&3\216 -// \DEL\184\"\147\247\GS\137\168","\147\161\247W\NAKc\172\214*\254 17\201\164\177)\167e\233\179\198\197Wf\a\153x"] [] +// UnsubscribeRequest 27754 ["\172U5\DEL\CAN\228","8\240H\r\196\215\174\249;\DEL","\196\130@ +// \243\239\224\EM\205\229\136\207\254\167\223\132\193\tA\194A\245\NUL","\224\222\248\EOT\133p^\181\176C\236i7\193\233","\196\184Q\132\RS\SYN&y-\220\&3\GSN\220\172i\ENQ-\143\&9\b\203\226z\253\SI\ACK","\DC1\DC2\SOH\203\"\201\150\136G\ACK\DC3","Y;\167C\134\239\208\r\219\234J\222\197*R\184\150L.\\\178&\NUL\221\229\185\222]","\252\225\DC2~\145\SUBH\232\240\145\206m_u\146*$\254\SYNI\\\174\rk1\157\&5\253\&3\220","1r\226\USM\210o\252\161=\241","]\201\&9"] +// [] TEST(Unsubscribe311QCTest, Encode8) { - uint8_t pkt[] = {0xa2, 0x4e, 0x6f, 0x33, 0x0, 0xa, 0xbc, 0x6a, 0x37, 0x31, 0x2f, 0x9d, 0x1a, 0x6c, 0x4f, 0x1b, - 0x0, 0x9, 0x4e, 0xc3, 0x88, 0x1a, 0x5b, 0x4c, 0xcb, 0x3f, 0xdb, 0x0, 0x15, 0x1f, 0x6b, 0x92, - 0x21, 0xc5, 0x77, 0x1c, 0x52, 0x98, 0xfe, 0x33, 0xd8, 0x20, 0x7f, 0xb8, 0x22, 0x93, 0xf7, 0x1d, - 0x89, 0xa8, 0x0, 0x1c, 0x93, 0xa1, 0xf7, 0x57, 0x15, 0x63, 0xac, 0xd6, 0x2a, 0xfe, 0x20, 0x31, - 0x37, 0xc9, 0xa4, 0xb1, 0x29, 0xa7, 0x65, 0xe9, 0xb3, 0xc6, 0xc5, 0x57, 0x66, 0x7, 0x99, 0x78}; + uint8_t pkt[] = { + 0xa2, 0xba, 0x1, 0x6c, 0x6a, 0x0, 0x6, 0xac, 0x55, 0x35, 0x7f, 0x18, 0xe4, 0x0, 0xa, 0x38, 0xf0, 0x48, 0xd, + 0xc4, 0xd7, 0xae, 0xf9, 0x3b, 0x7f, 0x0, 0x17, 0xc4, 0x82, 0x40, 0x20, 0xf3, 0xef, 0xe0, 0x19, 0xcd, 0xe5, 0x88, + 0xcf, 0xfe, 0xa7, 0xdf, 0x84, 0xc1, 0x9, 0x41, 0xc2, 0x41, 0xf5, 0x0, 0x0, 0xf, 0xe0, 0xde, 0xf8, 0x4, 0x85, + 0x70, 0x5e, 0xb5, 0xb0, 0x43, 0xec, 0x69, 0x37, 0xc1, 0xe9, 0x0, 0x1b, 0xc4, 0xb8, 0x51, 0x84, 0x1e, 0x16, 0x26, + 0x79, 0x2d, 0xdc, 0x33, 0x1d, 0x4e, 0xdc, 0xac, 0x69, 0x5, 0x2d, 0x8f, 0x39, 0x8, 0xcb, 0xe2, 0x7a, 0xfd, 0xf, + 0x6, 0x0, 0xb, 0x11, 0x12, 0x1, 0xcb, 0x22, 0xc9, 0x96, 0x88, 0x47, 0x6, 0x13, 0x0, 0x1c, 0x59, 0x3b, 0xa7, + 0x43, 0x86, 0xef, 0xd0, 0xd, 0xdb, 0xea, 0x4a, 0xde, 0xc5, 0x2a, 0x52, 0xb8, 0x96, 0x4c, 0x2e, 0x5c, 0xb2, 0x26, + 0x0, 0xdd, 0xe5, 0xb9, 0xde, 0x5d, 0x0, 0x1e, 0xfc, 0xe1, 0x12, 0x7e, 0x91, 0x1a, 0x48, 0xe8, 0xf0, 0x91, 0xce, + 0x6d, 0x5f, 0x75, 0x92, 0x2a, 0x24, 0xfe, 0x16, 0x49, 0x5c, 0xae, 0xd, 0x6b, 0x31, 0x9d, 0x35, 0xfd, 0x33, 0xdc, + 0x0, 0xb, 0x31, 0x72, 0xe2, 0x1f, 0x4d, 0xd2, 0x6f, 0xfc, 0xa1, 0x3d, 0xf1, 0x0, 0x3, 0x5d, 0xc9, 0x39}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xbc, 0x6a, 0x37, 0x31, 0x2f, 0x9d, 0x1a, 0x6c, 0x4f, 0x1b}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xac, 0x55, 0x35, 0x7f, 0x18, 0xe4}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4e, 0xc3, 0x88, 0x1a, 0x5b, 0x4c, 0xcb, 0x3f, 0xdb}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x38, 0xf0, 0x48, 0xd, 0xc4, 0xd7, 0xae, 0xf9, 0x3b, 0x7f}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1f, 0x6b, 0x92, 0x21, 0xc5, 0x77, 0x1c, 0x52, 0x98, 0xfe, 0x33, - 0xd8, 0x20, 0x7f, 0xb8, 0x22, 0x93, 0xf7, 0x1d, 0x89, 0xa8}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc4, 0x82, 0x40, 0x20, 0xf3, 0xef, 0xe0, 0x19, 0xcd, 0xe5, 0x88, 0xcf, + 0xfe, 0xa7, 0xdf, 0x84, 0xc1, 0x9, 0x41, 0xc2, 0x41, 0xf5, 0x0}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x93, 0xa1, 0xf7, 0x57, 0x15, 0x63, 0xac, 0xd6, 0x2a, 0xfe, - 0x20, 0x31, 0x37, 0xc9, 0xa4, 0xb1, 0x29, 0xa7, 0x65, 0xe9, - 0xb3, 0xc6, 0xc5, 0x57, 0x66, 0x7, 0x99, 0x78}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xe0, 0xde, 0xf8, 0x4, 0x85, 0x70, 0x5e, 0xb5, + 0xb0, 0x43, 0xec, 0x69, 0x37, 0xc1, 0xe9}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xc4, 0xb8, 0x51, 0x84, 0x1e, 0x16, 0x26, 0x79, 0x2d, 0xdc, 0x33, 0x1d, 0x4e, 0xdc, + 0xac, 0x69, 0x5, 0x2d, 0x8f, 0x39, 0x8, 0xcb, 0xe2, 0x7a, 0xfd, 0xf, 0x6}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x11, 0x12, 0x1, 0xcb, 0x22, 0xc9, 0x96, 0x88, 0x47, 0x6, 0x13}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x59, 0x3b, 0xa7, 0x43, 0x86, 0xef, 0xd0, 0xd, 0xdb, 0xea, + 0x4a, 0xde, 0xc5, 0x2a, 0x52, 0xb8, 0x96, 0x4c, 0x2e, 0x5c, + 0xb2, 0x26, 0x0, 0xdd, 0xe5, 0xb9, 0xde, 0x5d}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xfc, 0xe1, 0x12, 0x7e, 0x91, 0x1a, 0x48, 0xe8, 0xf0, 0x91, + 0xce, 0x6d, 0x5f, 0x75, 0x92, 0x2a, 0x24, 0xfe, 0x16, 0x49, + 0x5c, 0xae, 0xd, 0x6b, 0x31, 0x9d, 0x35, 0xfd, 0x33, 0xdc}; + lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x31, 0x72, 0xe2, 0x1f, 0x4d, 0xd2, 0x6f, 0xfc, 0xa1, 0x3d, 0xf1}; + lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x5d, 0xc9, 0x39}; + lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28467, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27754, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 8404 ["\198\198Y,9\140\US\ETB\133\SI\228\DC4\186\&9\252\131\242 -// \160\ACK\250\190\133H\184","h|\216nA\142%q@$\216\a\145\EOTE{\207\164V16\251]\131\&8u\235\184Ez","\132T\176\161h\202^\226p\136\166%\163^5\146\232\ESC\STXi\ENQ(\228\223#\SOH\204","M","\172\206\130\186\208S\DC1\255\166\196a","\144}i\254(@\229\171\199YW\ESC:\DC2\SUBs\165k\t\164\175,PR\SYN\194\DEL","0pM\253Q\142\194\174\194\194G9c\235T\GS\235\199\205\220\170\a\vF"] -// [] +// UnsubscribeRequest 13532 ["\240\FS[\152\DLE\226\153","\239?\170"] [] TEST(Unsubscribe311QCTest, Encode9) { - uint8_t pkt[] = {0xa2, 0xa1, 0x1, 0x20, 0xd4, 0x0, 0x19, 0xc6, 0xc6, 0x59, 0x2c, 0x39, 0x8c, 0x1f, 0x17, 0x85, 0xf, - 0xe4, 0x14, 0xba, 0x39, 0xfc, 0x83, 0xf2, 0x20, 0xa0, 0x6, 0xfa, 0xbe, 0x85, 0x48, 0xb8, 0x0, 0x1e, - 0x68, 0x7c, 0xd8, 0x6e, 0x41, 0x8e, 0x25, 0x71, 0x40, 0x24, 0xd8, 0x7, 0x91, 0x4, 0x45, 0x7b, 0xcf, - 0xa4, 0x56, 0x31, 0x36, 0xfb, 0x5d, 0x83, 0x38, 0x75, 0xeb, 0xb8, 0x45, 0x7a, 0x0, 0x1b, 0x84, 0x54, - 0xb0, 0xa1, 0x68, 0xca, 0x5e, 0xe2, 0x70, 0x88, 0xa6, 0x25, 0xa3, 0x5e, 0x35, 0x92, 0xe8, 0x1b, 0x2, - 0x69, 0x5, 0x28, 0xe4, 0xdf, 0x23, 0x1, 0xcc, 0x0, 0x1, 0x4d, 0x0, 0xb, 0xac, 0xce, 0x82, 0xba, - 0xd0, 0x53, 0x11, 0xff, 0xa6, 0xc4, 0x61, 0x0, 0x1b, 0x90, 0x7d, 0x69, 0xfe, 0x28, 0x40, 0xe5, 0xab, - 0xc7, 0x59, 0x57, 0x1b, 0x3a, 0x12, 0x1a, 0x73, 0xa5, 0x6b, 0x9, 0xa4, 0xaf, 0x2c, 0x50, 0x52, 0x16, - 0xc2, 0x7f, 0x0, 0x18, 0x30, 0x70, 0x4d, 0xfd, 0x51, 0x8e, 0xc2, 0xae, 0xc2, 0xc2, 0x47, 0x39, 0x63, - 0xeb, 0x54, 0x1d, 0xeb, 0xc7, 0xcd, 0xdc, 0xaa, 0x7, 0xb, 0x46}; + uint8_t pkt[] = {0xa2, 0x10, 0x34, 0xdc, 0x0, 0x7, 0xf0, 0x1c, 0x5b, + 0x98, 0x10, 0xe2, 0x99, 0x0, 0x3, 0xef, 0x3f, 0xaa}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xc6, 0xc6, 0x59, 0x2c, 0x39, 0x8c, 0x1f, 0x17, 0x85, 0xf, 0xe4, 0x14, 0xba, - 0x39, 0xfc, 0x83, 0xf2, 0x20, 0xa0, 0x6, 0xfa, 0xbe, 0x85, 0x48, 0xb8}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xf0, 0x1c, 0x5b, 0x98, 0x10, 0xe2, 0x99}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x68, 0x7c, 0xd8, 0x6e, 0x41, 0x8e, 0x25, 0x71, 0x40, 0x24, - 0xd8, 0x7, 0x91, 0x4, 0x45, 0x7b, 0xcf, 0xa4, 0x56, 0x31, - 0x36, 0xfb, 0x5d, 0x83, 0x38, 0x75, 0xeb, 0xb8, 0x45, 0x7a}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xef, 0x3f, 0xaa}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x84, 0x54, 0xb0, 0xa1, 0x68, 0xca, 0x5e, 0xe2, 0x70, 0x88, 0xa6, 0x25, 0xa3, 0x5e, - 0x35, 0x92, 0xe8, 0x1b, 0x2, 0x69, 0x5, 0x28, 0xe4, 0xdf, 0x23, 0x1, 0xcc}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x4d}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xac, 0xce, 0x82, 0xba, 0xd0, 0x53, 0x11, 0xff, 0xa6, 0xc4, 0x61}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x90, 0x7d, 0x69, 0xfe, 0x28, 0x40, 0xe5, 0xab, 0xc7, 0x59, 0x57, 0x1b, 0x3a, 0x12, - 0x1a, 0x73, 0xa5, 0x6b, 0x9, 0xa4, 0xaf, 0x2c, 0x50, 0x52, 0x16, 0xc2, 0x7f}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x30, 0x70, 0x4d, 0xfd, 0x51, 0x8e, 0xc2, 0xae, 0xc2, 0xc2, 0x47, 0x39, - 0x63, 0xeb, 0x54, 0x1d, 0xeb, 0xc7, 0xcd, 0xdc, 0xaa, 0x7, 0xb, 0x46}; - lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8404, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13532, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 27989 ["q\223fV4\ETB\205\139(\ENQ`\204\145\206\221\207\248\245"] [] +// UnsubscribeRequest 8446 ["N-\DC2\189\173\241\ETB\177\&9 +// \159\f\fj~\213!7\235\ESCx\194@\217\US[<","-","e\189\238\251\177\189\195\DLE\192\"c\166\SUB\DEL\145\133L\154^\"W\ETB\217\212","\155","X\139\243\DEL","\209\253\253\NUL9D\178\250\155BHo!\229=\135\146","\EM\217\251","\193S","\173M\228Y\v","\DC4>\252W0Y"] +// [] TEST(Unsubscribe311QCTest, Encode10) { - uint8_t pkt[] = {0xa2, 0x16, 0x6d, 0x55, 0x0, 0x12, 0x71, 0xdf, 0x66, 0x56, 0x34, 0x17, - 0xcd, 0x8b, 0x28, 0x5, 0x60, 0xcc, 0x91, 0xce, 0xdd, 0xcf, 0xf8, 0xf5}; + uint8_t pkt[] = {0xa2, 0x70, 0x20, 0xfe, 0x0, 0x1b, 0x4e, 0x2d, 0x12, 0xbd, 0xad, 0xf1, 0x17, 0xb1, 0x39, 0x20, 0x9f, + 0xc, 0xc, 0x6a, 0x7e, 0xd5, 0x21, 0x37, 0xeb, 0x1b, 0x78, 0xc2, 0x40, 0xd9, 0x1f, 0x5b, 0x3c, 0x0, + 0x1, 0x2d, 0x0, 0x18, 0x65, 0xbd, 0xee, 0xfb, 0xb1, 0xbd, 0xc3, 0x10, 0xc0, 0x22, 0x63, 0xa6, 0x1a, + 0x7f, 0x91, 0x85, 0x4c, 0x9a, 0x5e, 0x22, 0x57, 0x17, 0xd9, 0xd4, 0x0, 0x1, 0x9b, 0x0, 0x4, 0x58, + 0x8b, 0xf3, 0x7f, 0x0, 0x11, 0xd1, 0xfd, 0xfd, 0x0, 0x39, 0x44, 0xb2, 0xfa, 0x9b, 0x42, 0x48, 0x6f, + 0x21, 0xe5, 0x3d, 0x87, 0x92, 0x0, 0x3, 0x19, 0xd9, 0xfb, 0x0, 0x2, 0xc1, 0x53, 0x0, 0x5, 0xad, + 0x4d, 0xe4, 0x59, 0xb, 0x0, 0x6, 0x14, 0x3e, 0xfc, 0x57, 0x30, 0x59}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x71, 0xdf, 0x66, 0x56, 0x34, 0x17, 0xcd, 0x8b, 0x28, - 0x5, 0x60, 0xcc, 0x91, 0xce, 0xdd, 0xcf, 0xf8, 0xf5}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x4e, 0x2d, 0x12, 0xbd, 0xad, 0xf1, 0x17, 0xb1, 0x39, 0x20, 0x9f, 0xc, 0xc, 0x6a, + 0x7e, 0xd5, 0x21, 0x37, 0xeb, 0x1b, 0x78, 0xc2, 0x40, 0xd9, 0x1f, 0x5b, 0x3c}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2d}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x65, 0xbd, 0xee, 0xfb, 0xb1, 0xbd, 0xc3, 0x10, 0xc0, 0x22, 0x63, 0xa6, + 0x1a, 0x7f, 0x91, 0x85, 0x4c, 0x9a, 0x5e, 0x22, 0x57, 0x17, 0xd9, 0xd4}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x9b}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x58, 0x8b, 0xf3, 0x7f}; + lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xd1, 0xfd, 0xfd, 0x0, 0x39, 0x44, 0xb2, 0xfa, 0x9b, + 0x42, 0x48, 0x6f, 0x21, 0xe5, 0x3d, 0x87, 0x92}; + lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x19, 0xd9, 0xfb}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xc1, 0x53}; + lwmqtt_string_t topic_filter_s7 = {2, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xad, 0x4d, 0xe4, 0x59, 0xb}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x14, 0x3e, 0xfc, 0x57, 0x30, 0x59}; + lwmqtt_string_t topic_filter_s9 = {6, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27989, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8446, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 32178 -// ["k\238\167\&3}\189\230\213?\DC3gW\142\236\196\STX\221\176\151\150\233","\174\208{E\236","&\174#!)\239\207\EOT\192Rr\155\145","\239\248\168\STXO\\~\184\&3\RS'*l\DLE\246\168^\a\173\137\&2\139G\SYN\218\170\152ELh","\206N\152\&2x\DC1\205\128\249\189\CAN\200_\228\162\207\RS\149"] +// UnsubscribeRequest 16062 +// ["\DC4\200\182\217\165`\168\SUB\DLE7\161\153>`\251\222\164\236/\237\214y#\151\242.z","\139\214\221#G*U\227T\173Rn@x\190\128\&5y\194\247\195\175\253wE","\GS\251H\DC4\vJP\189\140\185\154\&6\ETB\ETX","\128","\164\134\216\194\&6\188\138H\199\EOT\183\NULcZ?\216\152\181\221Q\186\186(","N\153\169\195C0fs\136\178\185\191\163\GS\DLE\NUL\163\137\203\244\EM\134","%N\154_","\182\139\236\&1\DEL\208\223\&6&D\244\191\208\GS\155S\221","\133 +// \226-gm\142m\195\143\ACK\187RL\224}\157S=\135\230j\143","\221A\DC405q\245^U\188\239\212","\141\201\141\157\242\ACKk\161\185\131\247\CAN\a\240L\180\218Wn\218%\f\247"] // [] TEST(Unsubscribe311QCTest, Encode11) { - uint8_t pkt[] = {0xa2, 0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, 0xd8, + 0xc2, 0x36, 0xbc, 0x8a, 0x48, 0xc7, 0x4, 0xb7, 0x0, 0x63, 0x5a, 0x3f, 0xd8, 0x98, 0xb5, 0xdd, 0x51, + 0xba, 0xba, 0x28, 0x0, 0x16, 0x4e, 0x99, 0xa9, 0xc3, 0x43, 0x30, 0x66, 0x73, 0x88, 0xb2, 0xb9, 0xbf, + 0xa3, 0x1d, 0x10, 0x0, 0xa3, 0x89, 0xcb, 0xf4, 0x19, 0x86, 0x0, 0x4, 0x25, 0x4e, 0x9a, 0x5f, 0x0, + 0x11, 0xb6, 0x8b, 0xec, 0x31, 0x7f, 0xd0, 0xdf, 0x36, 0x26, 0x44, 0xf4, 0xbf, 0xd0, 0x1d, 0x9b, 0x53, + 0xdd, 0x0, 0x17, 0x85, 0x20, 0xe2, 0x2d, 0x67, 0x6d, 0x8e, 0x6d, 0xc3, 0x8f, 0x6, 0xbb, 0x52, 0x4c, + 0xe0, 0x7d, 0x9d, 0x53, 0x3d, 0x87, 0xe6, 0x6a, 0x8f, 0x0, 0xc, 0xdd, 0x41, 0x14, 0x30, 0x35, 0x71, + 0xf5, 0x5e, 0x55, 0xbc, 0xef, 0xd4, 0x0, 0x17, 0x8d, 0xc9, 0x8d, 0x9d, 0xf2, 0x6, 0x6b, 0xa1, 0xb9, + 0x83, 0xf7, 0x18, 0x7, 0xf0, 0x4c, 0xb4, 0xda, 0x57, 0x6e, 0xda, 0x25, 0xc, 0xf7}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x6b, 0xee, 0xa7, 0x33, 0x7d, 0xbd, 0xe6, 0xd5, 0x3f, 0x13, 0x67, - 0x57, 0x8e, 0xec, 0xc4, 0x2, 0xdd, 0xb0, 0x97, 0x96, 0xe9}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x14, 0xc8, 0xb6, 0xd9, 0xa5, 0x60, 0xa8, 0x1a, 0x10, 0x37, 0xa1, 0x99, 0x3e, 0x60, + 0xfb, 0xde, 0xa4, 0xec, 0x2f, 0xed, 0xd6, 0x79, 0x23, 0x97, 0xf2, 0x2e, 0x7a}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xae, 0xd0, 0x7b, 0x45, 0xec}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x8b, 0xd6, 0xdd, 0x23, 0x47, 0x2a, 0x55, 0xe3, 0x54, 0xad, 0x52, 0x6e, 0x40, + 0x78, 0xbe, 0x80, 0x35, 0x79, 0xc2, 0xf7, 0xc3, 0xaf, 0xfd, 0x77, 0x45}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x26, 0xae, 0x23, 0x21, 0x29, 0xef, 0xcf, 0x4, 0xc0, 0x52, 0x72, 0x9b, 0x91}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1d, 0xfb, 0x48, 0x14, 0xb, 0x4a, 0x50, 0xbd, 0x8c, 0xb9, 0x9a, 0x36, 0x17, 0x3}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xef, 0xf8, 0xa8, 0x2, 0x4f, 0x5c, 0x7e, 0xb8, 0x33, 0x1e, - 0x27, 0x2a, 0x6c, 0x10, 0xf6, 0xa8, 0x5e, 0x7, 0xad, 0x89, - 0x32, 0x8b, 0x47, 0x16, 0xda, 0xaa, 0x98, 0x45, 0x4c, 0x68}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x80}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xce, 0x4e, 0x98, 0x32, 0x78, 0x11, 0xcd, 0x80, 0xf9, - 0xbd, 0x18, 0xc8, 0x5f, 0xe4, 0xa2, 0xcf, 0x1e, 0x95}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa4, 0x86, 0xd8, 0xc2, 0x36, 0xbc, 0x8a, 0x48, 0xc7, 0x4, 0xb7, 0x0, + 0x63, 0x5a, 0x3f, 0xd8, 0x98, 0xb5, 0xdd, 0x51, 0xba, 0xba, 0x28}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x4e, 0x99, 0xa9, 0xc3, 0x43, 0x30, 0x66, 0x73, 0x88, 0xb2, 0xb9, + 0xbf, 0xa3, 0x1d, 0x10, 0x0, 0xa3, 0x89, 0xcb, 0xf4, 0x19, 0x86}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x25, 0x4e, 0x9a, 0x5f}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xb6, 0x8b, 0xec, 0x31, 0x7f, 0xd0, 0xdf, 0x36, 0x26, + 0x44, 0xf4, 0xbf, 0xd0, 0x1d, 0x9b, 0x53, 0xdd}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x85, 0x20, 0xe2, 0x2d, 0x67, 0x6d, 0x8e, 0x6d, 0xc3, 0x8f, 0x6, 0xbb, + 0x52, 0x4c, 0xe0, 0x7d, 0x9d, 0x53, 0x3d, 0x87, 0xe6, 0x6a, 0x8f}; + lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xdd, 0x41, 0x14, 0x30, 0x35, 0x71, 0xf5, 0x5e, 0x55, 0xbc, 0xef, 0xd4}; + lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x8d, 0xc9, 0x8d, 0x9d, 0xf2, 0x6, 0x6b, 0xa1, 0xb9, 0x83, 0xf7, 0x18, + 0x7, 0xf0, 0x4c, 0xb4, 0xda, 0x57, 0x6e, 0xda, 0x25, 0xc, 0xf7}; + lwmqtt_string_t topic_filter_s10 = {23, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32178, 5, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16062, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 17769 ["\192d\222\&2>\213\ESC_d\SUB\DC1N"] [] +// UnsubscribeRequest 999 +// ["kz8\"x_\167\&7\"\185\142\244:j\DC1","|","$\185\f4w\233","T\165\216\ETB\180p\NULe\ETX8\144\DLE4\DC4\GS\226\218\129\RS\SOHz","\172|>\168&\208\226\212\228lp\RSw\196\153\ESC\218\178l\207\rqgP\t\155$\145\ENQ","\EOT\244\t\200\GS\218\166\a\ETBL\218\191\198\183\130OR\ENQn\151\"|"] +// [] TEST(Unsubscribe311QCTest, Encode12) { - uint8_t pkt[] = {0xa2, 0x10, 0x45, 0x69, 0x0, 0xc, 0xc0, 0x64, 0xde, - 0x32, 0x3e, 0xd5, 0x1b, 0x5f, 0x64, 0x1a, 0x11, 0x4e}; + uint8_t pkt[] = {0xa2, 0x6c, 0x3, 0xe7, 0x0, 0xf, 0x6b, 0x7a, 0x38, 0x22, 0x78, 0x5f, 0xa7, 0x37, 0x22, 0xb9, + 0x8e, 0xf4, 0x3a, 0x6a, 0x11, 0x0, 0x1, 0x7c, 0x0, 0x6, 0x24, 0xb9, 0xc, 0x34, 0x77, 0xe9, + 0x0, 0x15, 0x54, 0xa5, 0xd8, 0x17, 0xb4, 0x70, 0x0, 0x65, 0x3, 0x38, 0x90, 0x10, 0x34, 0x14, + 0x1d, 0xe2, 0xda, 0x81, 0x1e, 0x1, 0x7a, 0x0, 0x1d, 0xac, 0x7c, 0x3e, 0xa8, 0x26, 0xd0, 0xe2, + 0xd4, 0xe4, 0x6c, 0x70, 0x1e, 0x77, 0xc4, 0x99, 0x1b, 0xda, 0xb2, 0x6c, 0xcf, 0xd, 0x71, 0x67, + 0x50, 0x9, 0x9b, 0x24, 0x91, 0x5, 0x0, 0x16, 0x4, 0xf4, 0x9, 0xc8, 0x1d, 0xda, 0xa6, 0x7, + 0x17, 0x4c, 0xda, 0xbf, 0xc6, 0xb7, 0x82, 0x4f, 0x52, 0x5, 0x6e, 0x97, 0x22, 0x7c}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xc0, 0x64, 0xde, 0x32, 0x3e, 0xd5, 0x1b, 0x5f, 0x64, 0x1a, 0x11, 0x4e}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x6b, 0x7a, 0x38, 0x22, 0x78, 0x5f, 0xa7, 0x37, + 0x22, 0xb9, 0x8e, 0xf4, 0x3a, 0x6a, 0x11}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7c}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x24, 0xb9, 0xc, 0x34, 0x77, 0xe9}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x54, 0xa5, 0xd8, 0x17, 0xb4, 0x70, 0x0, 0x65, 0x3, 0x38, 0x90, + 0x10, 0x34, 0x14, 0x1d, 0xe2, 0xda, 0x81, 0x1e, 0x1, 0x7a}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xac, 0x7c, 0x3e, 0xa8, 0x26, 0xd0, 0xe2, 0xd4, 0xe4, 0x6c, + 0x70, 0x1e, 0x77, 0xc4, 0x99, 0x1b, 0xda, 0xb2, 0x6c, 0xcf, + 0xd, 0x71, 0x67, 0x50, 0x9, 0x9b, 0x24, 0x91, 0x5}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x4, 0xf4, 0x9, 0xc8, 0x1d, 0xda, 0xa6, 0x7, 0x17, 0x4c, 0xda, + 0xbf, 0xc6, 0xb7, 0x82, 0x4f, 0x52, 0x5, 0x6e, 0x97, 0x22, 0x7c}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17769, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 999, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 21908 -// ["$","\GSI\141^\185\188\DC2|\159M\189\209\DC4\211\&1","L\t}\130~\220\&8\211\235","\210\USg\203\179@\DC2\174l\v\193\DC2)Q\233\STX#\177C\164\ENQ&@;=\238\138\217\158"] -// [] +// UnsubscribeRequest 5737 +// ["\216\200`8N","z\226\248\NULq\EOT\232\158\NUL\178\131\247\130\n\240\192\225^","?x\STX-5\217\158\213\253+\165\134\173`#\190\229\177\228\177\183\\\204V","[Q","\190\180u\222#\171\SUBik\221\246\227\164)\239\210\EOT4[-","f\SO\237iS\197T\247\250\167?\228\242\170\213_b\215\241\221\153\136\138\229\175","E}\SUB\221S\172 +// \FS\189&}v\220"] [] TEST(Unsubscribe311QCTest, Encode13) { - uint8_t pkt[] = {0xa2, 0x40, 0x55, 0x94, 0x0, 0x1, 0x24, 0x0, 0xf, 0x1d, 0x49, 0x8d, 0x5e, 0xb9, 0xbc, 0x12, 0x7c, - 0x9f, 0x4d, 0xbd, 0xd1, 0x14, 0xd3, 0x31, 0x0, 0x9, 0x4c, 0x9, 0x7d, 0x82, 0x7e, 0xdc, 0x38, 0xd3, - 0xeb, 0x0, 0x1d, 0xd2, 0x1f, 0x67, 0xcb, 0xb3, 0x40, 0x12, 0xae, 0x6c, 0xb, 0xc1, 0x12, 0x29, 0x51, - 0xe9, 0x2, 0x23, 0xb1, 0x43, 0xa4, 0x5, 0x26, 0x40, 0x3b, 0x3d, 0xee, 0x8a, 0xd9, 0x9e}; + uint8_t pkt[] = {0xa2, 0x7b, 0x16, 0x69, 0x0, 0x5, 0xd8, 0xc8, 0x60, 0x38, 0x4e, 0x0, 0x12, 0x7a, 0xe2, 0xf8, + 0x0, 0x71, 0x4, 0xe8, 0x9e, 0x0, 0xb2, 0x83, 0xf7, 0x82, 0xa, 0xf0, 0xc0, 0xe1, 0x5e, 0x0, + 0x18, 0x3f, 0x78, 0x2, 0x2d, 0x35, 0xd9, 0x9e, 0xd5, 0xfd, 0x2b, 0xa5, 0x86, 0xad, 0x60, 0x23, + 0xbe, 0xe5, 0xb1, 0xe4, 0xb1, 0xb7, 0x5c, 0xcc, 0x56, 0x0, 0x2, 0x5b, 0x51, 0x0, 0x14, 0xbe, + 0xb4, 0x75, 0xde, 0x23, 0xab, 0x1a, 0x69, 0x6b, 0xdd, 0xf6, 0xe3, 0xa4, 0x29, 0xef, 0xd2, 0x4, + 0x34, 0x5b, 0x2d, 0x0, 0x19, 0x66, 0xe, 0xed, 0x69, 0x53, 0xc5, 0x54, 0xf7, 0xfa, 0xa7, 0x3f, + 0xe4, 0xf2, 0xaa, 0xd5, 0x5f, 0x62, 0xd7, 0xf1, 0xdd, 0x99, 0x88, 0x8a, 0xe5, 0xaf, 0x0, 0xd, + 0x45, 0x7d, 0x1a, 0xdd, 0x53, 0xac, 0x20, 0x1c, 0xbd, 0x26, 0x7d, 0x76, 0xdc}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x24}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xd8, 0xc8, 0x60, 0x38, 0x4e}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1d, 0x49, 0x8d, 0x5e, 0xb9, 0xbc, 0x12, 0x7c, - 0x9f, 0x4d, 0xbd, 0xd1, 0x14, 0xd3, 0x31}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7a, 0xe2, 0xf8, 0x0, 0x71, 0x4, 0xe8, 0x9e, 0x0, + 0xb2, 0x83, 0xf7, 0x82, 0xa, 0xf0, 0xc0, 0xe1, 0x5e}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4c, 0x9, 0x7d, 0x82, 0x7e, 0xdc, 0x38, 0xd3, 0xeb}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x3f, 0x78, 0x2, 0x2d, 0x35, 0xd9, 0x9e, 0xd5, 0xfd, 0x2b, 0xa5, 0x86, + 0xad, 0x60, 0x23, 0xbe, 0xe5, 0xb1, 0xe4, 0xb1, 0xb7, 0x5c, 0xcc, 0x56}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd2, 0x1f, 0x67, 0xcb, 0xb3, 0x40, 0x12, 0xae, 0x6c, 0xb, - 0xc1, 0x12, 0x29, 0x51, 0xe9, 0x2, 0x23, 0xb1, 0x43, 0xa4, - 0x5, 0x26, 0x40, 0x3b, 0x3d, 0xee, 0x8a, 0xd9, 0x9e}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x5b, 0x51}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xbe, 0xb4, 0x75, 0xde, 0x23, 0xab, 0x1a, 0x69, 0x6b, 0xdd, + 0xf6, 0xe3, 0xa4, 0x29, 0xef, 0xd2, 0x4, 0x34, 0x5b, 0x2d}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x66, 0xe, 0xed, 0x69, 0x53, 0xc5, 0x54, 0xf7, 0xfa, 0xa7, 0x3f, 0xe4, 0xf2, + 0xaa, 0xd5, 0x5f, 0x62, 0xd7, 0xf1, 0xdd, 0x99, 0x88, 0x8a, 0xe5, 0xaf}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x45, 0x7d, 0x1a, 0xdd, 0x53, 0xac, 0x20, 0x1c, 0xbd, 0x26, 0x7d, 0x76, 0xdc}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21908, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5737, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 12542 ["j\251j\160\243\235 -// \r\246R\192\234l\DC2.\153\144v\NAK\RSXz\DEL:","\DC4\SYN\240\227S!\ETX\ETBS\179\245t\185D+\225\&3n~\146z\194\143"] [] +// UnsubscribeRequest 1255 +// ["\153\GSI\185K\229\aE*T\235?5*(","9\225=)\198\150\245\192\130\194N\204d\137\162(\248\142n","\163\168\DEL\193\254\161\250\166\204\221\231\250\&9\228\202\163\162%\242c\223\217\250\182","\255\201\247\&9\DC4?\255\229\SI\EOT\228fc\ETB\177\225+b\159\&5O\218\ACK\132","\251\n\SYN~\RS\180\172y\RS\f\228\211*\214","Uq\215s\244Y",""] +// []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; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x6a, 0xfb, 0x6a, 0xa0, 0xf3, 0xeb, 0x20, 0xd, 0xf6, 0x52, 0xc0, 0xea, - 0x6c, 0x12, 0x2e, 0x99, 0x90, 0x76, 0x15, 0x1e, 0x58, 0x7a, 0x7f, 0x3a}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x99, 0x1d, 0x49, 0xb9, 0x4b, 0xe5, 0x7, 0x45, + 0x2a, 0x54, 0xeb, 0x3f, 0x35, 0x2a, 0x28}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x14, 0x16, 0xf0, 0xe3, 0x53, 0x21, 0x3, 0x17, 0x53, 0xb3, 0xf5, 0x74, - 0xb9, 0x44, 0x2b, 0xe1, 0x33, 0x6e, 0x7e, 0x92, 0x7a, 0xc2, 0x8f}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x39, 0xe1, 0x3d, 0x29, 0xc6, 0x96, 0xf5, 0xc0, 0x82, 0xc2, + 0x4e, 0xcc, 0x64, 0x89, 0xa2, 0x28, 0xf8, 0x8e, 0x6e}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa3, 0xa8, 0x7f, 0xc1, 0xfe, 0xa1, 0xfa, 0xa6, 0xcc, 0xdd, 0xe7, 0xfa, + 0x39, 0xe4, 0xca, 0xa3, 0xa2, 0x25, 0xf2, 0x63, 0xdf, 0xd9, 0xfa, 0xb6}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xff, 0xc9, 0xf7, 0x39, 0x14, 0x3f, 0xff, 0xe5, 0xf, 0x4, 0xe4, 0x66, + 0x63, 0x17, 0xb1, 0xe1, 0x2b, 0x62, 0x9f, 0x35, 0x4f, 0xda, 0x6, 0x84}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xfb, 0xa, 0x16, 0x7e, 0x1e, 0xb4, 0xac, 0x79, 0x1e, 0xc, 0xe4, 0xd3, 0x2a, 0xd6}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x55, 0x71, 0xd7, 0x73, 0xf4, 0x59}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12542, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1255, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22335 ["\171r\247N1\218","4\149\209gL^\241\220\171\227{YRF8\184,\212\205\157"] [] +// UnsubscribeRequest 22682 +// ["\DEL\148\206K\136Hx\216\137\137*\209\248*\186\130\163\206@\US%\179s","\232\&0\131\241\219a\152\207V\185\213v\186[\165\191\DC4`K\144\228\194\ETBVgW","\195\211\171c\216\f\DC2\165`\183Pj\228\216~\238@","5\234\US\174\183$\196V\DLE\168\247\255","h7\224\134\254\229\GSn\131_1\200>e","H\ETB\172+\157d!VF\131\157!\EM\201","\179U.\225i\222\SYN\136b\NULw\SOH\187\&1M\135p:","Y\189?\174\nQyM\165.\"\ENQ\140__\192\254\187\228","\239\222\226\181\184\209\133\199\&7O\254\175","\EOT\229\DC4.X\129\129\&5\204;\230"] +// [] TEST(Unsubscribe311QCTest, Encode15) { - uint8_t pkt[] = {0xa2, 0x20, 0x57, 0x3f, 0x0, 0x6, 0xab, 0x72, 0xf7, 0x4e, 0x31, 0xda, - 0x0, 0x14, 0x34, 0x95, 0xd1, 0x67, 0x4c, 0x5e, 0xf1, 0xdc, 0xab, 0xe3, - 0x7b, 0x59, 0x52, 0x46, 0x38, 0xb8, 0x2c, 0xd4, 0xcd, 0x9d}; + uint8_t pkt[] = {0xa2, 0xbc, 0x1, 0x58, 0x9a, 0x0, 0x17, 0x7f, 0x94, 0xce, 0x4b, 0x88, 0x48, 0x78, 0xd8, 0x89, + 0x89, 0x2a, 0xd1, 0xf8, 0x2a, 0xba, 0x82, 0xa3, 0xce, 0x40, 0x1f, 0x25, 0xb3, 0x73, 0x0, 0x1a, + 0xe8, 0x30, 0x83, 0xf1, 0xdb, 0x61, 0x98, 0xcf, 0x56, 0xb9, 0xd5, 0x76, 0xba, 0x5b, 0xa5, 0xbf, + 0x14, 0x60, 0x4b, 0x90, 0xe4, 0xc2, 0x17, 0x56, 0x67, 0x57, 0x0, 0x11, 0xc3, 0xd3, 0xab, 0x63, + 0xd8, 0xc, 0x12, 0xa5, 0x60, 0xb7, 0x50, 0x6a, 0xe4, 0xd8, 0x7e, 0xee, 0x40, 0x0, 0xc, 0x35, + 0xea, 0x1f, 0xae, 0xb7, 0x24, 0xc4, 0x56, 0x10, 0xa8, 0xf7, 0xff, 0x0, 0xe, 0x68, 0x37, 0xe0, + 0x86, 0xfe, 0xe5, 0x1d, 0x6e, 0x83, 0x5f, 0x31, 0xc8, 0x3e, 0x65, 0x0, 0xe, 0x48, 0x17, 0xac, + 0x2b, 0x9d, 0x64, 0x21, 0x56, 0x46, 0x83, 0x9d, 0x21, 0x19, 0xc9, 0x0, 0x12, 0xb3, 0x55, 0x2e, + 0xe1, 0x69, 0xde, 0x16, 0x88, 0x62, 0x0, 0x77, 0x1, 0xbb, 0x31, 0x4d, 0x87, 0x70, 0x3a, 0x0, + 0x13, 0x59, 0xbd, 0x3f, 0xae, 0xa, 0x51, 0x79, 0x4d, 0xa5, 0x2e, 0x22, 0x5, 0x8c, 0x5f, 0x5f, + 0xc0, 0xfe, 0xbb, 0xe4, 0x0, 0xc, 0xef, 0xde, 0xe2, 0xb5, 0xb8, 0xd1, 0x85, 0xc7, 0x37, 0x4f, + 0xfe, 0xaf, 0x0, 0xb, 0x4, 0xe5, 0x14, 0x2e, 0x58, 0x81, 0x81, 0x35, 0xcc, 0x3b, 0xe6}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xab, 0x72, 0xf7, 0x4e, 0x31, 0xda}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x7f, 0x94, 0xce, 0x4b, 0x88, 0x48, 0x78, 0xd8, 0x89, 0x89, 0x2a, 0xd1, + 0xf8, 0x2a, 0xba, 0x82, 0xa3, 0xce, 0x40, 0x1f, 0x25, 0xb3, 0x73}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x34, 0x95, 0xd1, 0x67, 0x4c, 0x5e, 0xf1, 0xdc, 0xab, 0xe3, - 0x7b, 0x59, 0x52, 0x46, 0x38, 0xb8, 0x2c, 0xd4, 0xcd, 0x9d}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe8, 0x30, 0x83, 0xf1, 0xdb, 0x61, 0x98, 0xcf, 0x56, 0xb9, 0xd5, 0x76, 0xba, + 0x5b, 0xa5, 0xbf, 0x14, 0x60, 0x4b, 0x90, 0xe4, 0xc2, 0x17, 0x56, 0x67, 0x57}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc3, 0xd3, 0xab, 0x63, 0xd8, 0xc, 0x12, 0xa5, 0x60, + 0xb7, 0x50, 0x6a, 0xe4, 0xd8, 0x7e, 0xee, 0x40}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x35, 0xea, 0x1f, 0xae, 0xb7, 0x24, 0xc4, 0x56, 0x10, 0xa8, 0xf7, 0xff}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x68, 0x37, 0xe0, 0x86, 0xfe, 0xe5, 0x1d, + 0x6e, 0x83, 0x5f, 0x31, 0xc8, 0x3e, 0x65}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x48, 0x17, 0xac, 0x2b, 0x9d, 0x64, 0x21, + 0x56, 0x46, 0x83, 0x9d, 0x21, 0x19, 0xc9}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xb3, 0x55, 0x2e, 0xe1, 0x69, 0xde, 0x16, 0x88, 0x62, + 0x0, 0x77, 0x1, 0xbb, 0x31, 0x4d, 0x87, 0x70, 0x3a}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x59, 0xbd, 0x3f, 0xae, 0xa, 0x51, 0x79, 0x4d, 0xa5, 0x2e, + 0x22, 0x5, 0x8c, 0x5f, 0x5f, 0xc0, 0xfe, 0xbb, 0xe4}; + lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xef, 0xde, 0xe2, 0xb5, 0xb8, 0xd1, 0x85, 0xc7, 0x37, 0x4f, 0xfe, 0xaf}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x4, 0xe5, 0x14, 0x2e, 0x58, 0x81, 0x81, 0x35, 0xcc, 0x3b, 0xe6}; + lwmqtt_string_t topic_filter_s9 = {11, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22335, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22682, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 6771 -// ["\135\US\219/\163+\FS-","\161\136\131Y\CAN\230t&\196\174\&4-\f\129\155\189N\211c\233\235q\138\227\250O\148\222\&3","JJ4\DEL\247{\189\166\DLE5\241-\195\141X\tN\138\248\171\247(\202Z\231\&6C\255","\182\r\144B[\233\NAK\194\179{\177\&6\206o\172h","","\163,+n\168M\SO\184\180","?\146X+Lw\191\EM\209\t\174\211\160s\192Fa\237\195\212\&1DY\131\163","z\255\213\SUBvQ\236M\152\208\149h","\137\237\131\198XD\SO^P\207\227\146\248\240\227}&\141\142v>\GS","\192\221\160N\167e\"R<\142",""] -// [] +// UnsubscribeRequest 24213 ["\253g\ETX\138\DLEW\170\231\214\133H\RS\206+f|@C\175*,\178\EM"] [] TEST(Unsubscribe311QCTest, Encode16) { - uint8_t pkt[] = {0xa2, 0xb7, 0x1, 0x1a, 0x73, 0x0, 0x8, 0x87, 0x1f, 0xdb, 0x2f, 0xa3, 0x2b, 0x1c, 0x2d, 0x0, 0x1d, - 0xa1, 0x88, 0x83, 0x59, 0x18, 0xe6, 0x74, 0x26, 0xc4, 0xae, 0x34, 0x2d, 0xc, 0x81, 0x9b, 0xbd, 0x4e, - 0xd3, 0x63, 0xe9, 0xeb, 0x71, 0x8a, 0xe3, 0xfa, 0x4f, 0x94, 0xde, 0x33, 0x0, 0x1c, 0x4a, 0x4a, 0x34, - 0x7f, 0xf7, 0x7b, 0xbd, 0xa6, 0x10, 0x35, 0xf1, 0x2d, 0xc3, 0x8d, 0x58, 0x9, 0x4e, 0x8a, 0xf8, 0xab, - 0xf7, 0x28, 0xca, 0x5a, 0xe7, 0x36, 0x43, 0xff, 0x0, 0x10, 0xb6, 0xd, 0x90, 0x42, 0x5b, 0xe9, 0x15, - 0xc2, 0xb3, 0x7b, 0xb1, 0x36, 0xce, 0x6f, 0xac, 0x68, 0x0, 0x0, 0x0, 0x9, 0xa3, 0x2c, 0x2b, 0x6e, - 0xa8, 0x4d, 0xe, 0xb8, 0xb4, 0x0, 0x19, 0x3f, 0x92, 0x58, 0x2b, 0x4c, 0x77, 0xbf, 0x19, 0xd1, 0x9, - 0xae, 0xd3, 0xa0, 0x73, 0xc0, 0x46, 0x61, 0xed, 0xc3, 0xd4, 0x31, 0x44, 0x59, 0x83, 0xa3, 0x0, 0xc, - 0x7a, 0xff, 0xd5, 0x1a, 0x76, 0x51, 0xec, 0x4d, 0x98, 0xd0, 0x95, 0x68, 0x0, 0x16, 0x89, 0xed, 0x83, - 0xc6, 0x58, 0x44, 0xe, 0x5e, 0x50, 0xcf, 0xe3, 0x92, 0xf8, 0xf0, 0xe3, 0x7d, 0x26, 0x8d, 0x8e, 0x76, - 0x3e, 0x1d, 0x0, 0xa, 0xc0, 0xdd, 0xa0, 0x4e, 0xa7, 0x65, 0x22, 0x52, 0x3c, 0x8e, 0x0, 0x0}; + uint8_t pkt[] = {0xa2, 0x1b, 0x5e, 0x95, 0x0, 0x17, 0xfd, 0x67, 0x3, 0x8a, 0x10, 0x57, 0xaa, 0xe7, 0xd6, + 0x85, 0x48, 0x1e, 0xce, 0x2b, 0x66, 0x7c, 0x40, 0x43, 0xaf, 0x2a, 0x2c, 0xb2, 0x19}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x87, 0x1f, 0xdb, 0x2f, 0xa3, 0x2b, 0x1c, 0x2d}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xfd, 0x67, 0x3, 0x8a, 0x10, 0x57, 0xaa, 0xe7, 0xd6, 0x85, 0x48, 0x1e, + 0xce, 0x2b, 0x66, 0x7c, 0x40, 0x43, 0xaf, 0x2a, 0x2c, 0xb2, 0x19}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa1, 0x88, 0x83, 0x59, 0x18, 0xe6, 0x74, 0x26, 0xc4, 0xae, - 0x34, 0x2d, 0xc, 0x81, 0x9b, 0xbd, 0x4e, 0xd3, 0x63, 0xe9, - 0xeb, 0x71, 0x8a, 0xe3, 0xfa, 0x4f, 0x94, 0xde, 0x33}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4a, 0x4a, 0x34, 0x7f, 0xf7, 0x7b, 0xbd, 0xa6, 0x10, 0x35, - 0xf1, 0x2d, 0xc3, 0x8d, 0x58, 0x9, 0x4e, 0x8a, 0xf8, 0xab, - 0xf7, 0x28, 0xca, 0x5a, 0xe7, 0x36, 0x43, 0xff}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb6, 0xd, 0x90, 0x42, 0x5b, 0xe9, 0x15, 0xc2, - 0xb3, 0x7b, 0xb1, 0x36, 0xce, 0x6f, 0xac, 0x68}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa3, 0x2c, 0x2b, 0x6e, 0xa8, 0x4d, 0xe, 0xb8, 0xb4}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3f, 0x92, 0x58, 0x2b, 0x4c, 0x77, 0xbf, 0x19, 0xd1, 0x9, 0xae, 0xd3, 0xa0, - 0x73, 0xc0, 0x46, 0x61, 0xed, 0xc3, 0xd4, 0x31, 0x44, 0x59, 0x83, 0xa3}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7a, 0xff, 0xd5, 0x1a, 0x76, 0x51, 0xec, 0x4d, 0x98, 0xd0, 0x95, 0x68}; - lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x89, 0xed, 0x83, 0xc6, 0x58, 0x44, 0xe, 0x5e, 0x50, 0xcf, 0xe3, - 0x92, 0xf8, 0xf0, 0xe3, 0x7d, 0x26, 0x8d, 0x8e, 0x76, 0x3e, 0x1d}; - lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xc0, 0xdd, 0xa0, 0x4e, 0xa7, 0x65, 0x22, 0x52, 0x3c, 0x8e}; - lwmqtt_string_t topic_filter_s9 = {10, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0}; - lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6771, 11, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24213, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 19984 -// ["I|\192\176@\ETB\219a\254\217\n\238\172\EOT\202\143*?\ETB\130\172\174\CAN\DEL\177\163","~V\240~\192","b6\189\&0\244q","\143\166/\SO\r\r\240\212\181\136\172$\233\243\149\&70h_|\204\136 -// \206\146\134\236\&6\179","\157\168\227\SOH\242\183\153\nO\235\DEL\aW\227\196\225\179\210s\174\FS\155(\t\137\158\229","\ESCl\130\ACK\135\&4,D\208\141\243s\n*F*","\170\194\223-H\208r]UF+\221\\.\187\225\135]x\218\140on\180\233","\194\f\246\&1n\154\DC1\195\170\161\232\152\185\222\ESC"] +// UnsubscribeRequest 26833 ["U\246\DEL\"\254\131\166\165\187} +// \200\GShm\235K\206G\207\253\148\237\168#\193","\250","\234\199f)*\128@\216\214'\215\213","\SO\NULF\227\255\SUBc\189X\168\213\213","\DC2Q\176m\\J","!f2>\204\138\CAN\NUL:\235\222"] // [] TEST(Unsubscribe311QCTest, Encode17) { - uint8_t pkt[] = { - 0xa2, 0xa7, 0x1, 0x4e, 0x10, 0x0, 0x1a, 0x49, 0x7c, 0xc0, 0xb0, 0x40, 0x17, 0xdb, 0x61, 0xfe, 0xd9, 0xa, 0xee, - 0xac, 0x4, 0xca, 0x8f, 0x2a, 0x3f, 0x17, 0x82, 0xac, 0xae, 0x18, 0x7f, 0xb1, 0xa3, 0x0, 0x5, 0x7e, 0x56, 0xf0, - 0x7e, 0xc0, 0x0, 0x6, 0x62, 0x36, 0xbd, 0x30, 0xf4, 0x71, 0x0, 0x1d, 0x8f, 0xa6, 0x2f, 0xe, 0xd, 0xd, 0xf0, - 0xd4, 0xb5, 0x88, 0xac, 0x24, 0xe9, 0xf3, 0x95, 0x37, 0x30, 0x68, 0x5f, 0x7c, 0xcc, 0x88, 0x20, 0xce, 0x92, 0x86, - 0xec, 0x36, 0xb3, 0x0, 0x1b, 0x9d, 0xa8, 0xe3, 0x1, 0xf2, 0xb7, 0x99, 0xa, 0x4f, 0xeb, 0x7f, 0x7, 0x57, 0xe3, - 0xc4, 0xe1, 0xb3, 0xd2, 0x73, 0xae, 0x1c, 0x9b, 0x28, 0x9, 0x89, 0x9e, 0xe5, 0x0, 0x10, 0x1b, 0x6c, 0x82, 0x6, - 0x87, 0x34, 0x2c, 0x44, 0xd0, 0x8d, 0xf3, 0x73, 0xa, 0x2a, 0x46, 0x2a, 0x0, 0x19, 0xaa, 0xc2, 0xdf, 0x2d, 0x48, - 0xd0, 0x72, 0x5d, 0x55, 0x46, 0x2b, 0xdd, 0x5c, 0x2e, 0xbb, 0xe1, 0x87, 0x5d, 0x78, 0xda, 0x8c, 0x6f, 0x6e, 0xb4, - 0xe9, 0x0, 0xf, 0xc2, 0xc, 0xf6, 0x31, 0x6e, 0x9a, 0x11, 0xc3, 0xaa, 0xa1, 0xe8, 0x98, 0xb9, 0xde, 0x1b}; + uint8_t pkt[] = {0xa2, 0x52, 0x68, 0xd1, 0x0, 0x1a, 0x55, 0xf6, 0x7f, 0x22, 0xfe, 0x83, 0xa6, 0xa5, 0xbb, 0x7d, 0x20, + 0xc8, 0x1d, 0x68, 0x6d, 0xeb, 0x4b, 0xce, 0x47, 0xcf, 0xfd, 0x94, 0xed, 0xa8, 0x23, 0xc1, 0x0, 0x1, + 0xfa, 0x0, 0xc, 0xea, 0xc7, 0x66, 0x29, 0x2a, 0x80, 0x40, 0xd8, 0xd6, 0x27, 0xd7, 0xd5, 0x0, 0xc, + 0xe, 0x0, 0x46, 0xe3, 0xff, 0x1a, 0x63, 0xbd, 0x58, 0xa8, 0xd5, 0xd5, 0x0, 0x6, 0x12, 0x51, 0xb0, + 0x6d, 0x5c, 0x4a, 0x0, 0xb, 0x21, 0x66, 0x32, 0x3e, 0xcc, 0x8a, 0x18, 0x0, 0x3a, 0xeb, 0xde}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x49, 0x7c, 0xc0, 0xb0, 0x40, 0x17, 0xdb, 0x61, 0xfe, 0xd9, 0xa, 0xee, 0xac, - 0x4, 0xca, 0x8f, 0x2a, 0x3f, 0x17, 0x82, 0xac, 0xae, 0x18, 0x7f, 0xb1, 0xa3}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x55, 0xf6, 0x7f, 0x22, 0xfe, 0x83, 0xa6, 0xa5, 0xbb, 0x7d, 0x20, 0xc8, 0x1d, + 0x68, 0x6d, 0xeb, 0x4b, 0xce, 0x47, 0xcf, 0xfd, 0x94, 0xed, 0xa8, 0x23, 0xc1}; lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7e, 0x56, 0xf0, 0x7e, 0xc0}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xfa}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x62, 0x36, 0xbd, 0x30, 0xf4, 0x71}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xea, 0xc7, 0x66, 0x29, 0x2a, 0x80, 0x40, 0xd8, 0xd6, 0x27, 0xd7, 0xd5}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8f, 0xa6, 0x2f, 0xe, 0xd, 0xd, 0xf0, 0xd4, 0xb5, 0x88, - 0xac, 0x24, 0xe9, 0xf3, 0x95, 0x37, 0x30, 0x68, 0x5f, 0x7c, - 0xcc, 0x88, 0x20, 0xce, 0x92, 0x86, 0xec, 0x36, 0xb3}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xe, 0x0, 0x46, 0xe3, 0xff, 0x1a, 0x63, 0xbd, 0x58, 0xa8, 0xd5, 0xd5}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9d, 0xa8, 0xe3, 0x1, 0xf2, 0xb7, 0x99, 0xa, 0x4f, 0xeb, 0x7f, 0x7, 0x57, 0xe3, - 0xc4, 0xe1, 0xb3, 0xd2, 0x73, 0xae, 0x1c, 0x9b, 0x28, 0x9, 0x89, 0x9e, 0xe5}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x12, 0x51, 0xb0, 0x6d, 0x5c, 0x4a}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1b, 0x6c, 0x82, 0x6, 0x87, 0x34, 0x2c, 0x44, - 0xd0, 0x8d, 0xf3, 0x73, 0xa, 0x2a, 0x46, 0x2a}; - lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x21, 0x66, 0x32, 0x3e, 0xcc, 0x8a, 0x18, 0x0, 0x3a, 0xeb, 0xde}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xaa, 0xc2, 0xdf, 0x2d, 0x48, 0xd0, 0x72, 0x5d, 0x55, 0x46, 0x2b, 0xdd, 0x5c, - 0x2e, 0xbb, 0xe1, 0x87, 0x5d, 0x78, 0xda, 0x8c, 0x6f, 0x6e, 0xb4, 0xe9}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xc2, 0xc, 0xf6, 0x31, 0x6e, 0x9a, 0x11, 0xc3, - 0xaa, 0xa1, 0xe8, 0x98, 0xb9, 0xde, 0x1b}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19984, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26833, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 8587 -// ["^\158\181\192J\FS\249","\248\243\ACK\NULSg}\128\177\154\&2\SUB-\242\GS\229\t\NAK\US\189m\225\230I\FS","\SUB\194\179C\203\152","\244#\152\175\194\153\231\239\ETBD\146Q\248g\246w\143K\194\245\181","\DC4\tIs\155jp\197\SYN'1,G(P\NAK$\163\144\146\159\USY\194M\151\157\255","\236\159","\228\132\130\254\213\173\&1\202\&0\136\135\231\157\167p\199}\139\ETX -// \191\189\168\245\227\DC2}","\233mc\155K\b!\RSu\SUB","t\178\DEL\DELy\240\224\228\141\238\EOT\EM\153;\190\234","\128xS\199\240\228\&0R\vR\180\&3\217\179\162H\189%\192\247\195e\179t\RS\"x\DC1my","\246\ESC\248\136\ETX>\225\204\ACK\136\170\"\v\232\253\219\199=\ACK"] -// [] +// UnsubscribeRequest 24597 ["\t\134\178\219\159\249\235\250\187","\166)\230\184Y\252\r.B"] [] TEST(Unsubscribe311QCTest, Encode18) { - uint8_t pkt[] = {0xa2, 0xd7, 0x1, 0x21, 0x8b, 0x0, 0x7, 0x5e, 0x9e, 0xb5, 0xc0, 0x4a, 0x1c, 0xf9, 0x0, 0x19, 0xf8, - 0xf3, 0x6, 0x0, 0x53, 0x67, 0x7d, 0x80, 0xb1, 0x9a, 0x32, 0x1a, 0x2d, 0xf2, 0x1d, 0xe5, 0x9, 0x15, - 0x1f, 0xbd, 0x6d, 0xe1, 0xe6, 0x49, 0x1c, 0x0, 0x6, 0x1a, 0xc2, 0xb3, 0x43, 0xcb, 0x98, 0x0, 0x15, - 0xf4, 0x23, 0x98, 0xaf, 0xc2, 0x99, 0xe7, 0xef, 0x17, 0x44, 0x92, 0x51, 0xf8, 0x67, 0xf6, 0x77, 0x8f, - 0x4b, 0xc2, 0xf5, 0xb5, 0x0, 0x1c, 0x14, 0x9, 0x49, 0x73, 0x9b, 0x6a, 0x70, 0xc5, 0x16, 0x27, 0x31, - 0x2c, 0x47, 0x28, 0x50, 0x15, 0x24, 0xa3, 0x90, 0x92, 0x9f, 0x1f, 0x59, 0xc2, 0x4d, 0x97, 0x9d, 0xff, - 0x0, 0x2, 0xec, 0x9f, 0x0, 0x1b, 0xe4, 0x84, 0x82, 0xfe, 0xd5, 0xad, 0x31, 0xca, 0x30, 0x88, 0x87, - 0xe7, 0x9d, 0xa7, 0x70, 0xc7, 0x7d, 0x8b, 0x3, 0x20, 0xbf, 0xbd, 0xa8, 0xf5, 0xe3, 0x12, 0x7d, 0x0, - 0xa, 0xe9, 0x6d, 0x63, 0x9b, 0x4b, 0x8, 0x21, 0x1e, 0x75, 0x1a, 0x0, 0x10, 0x74, 0xb2, 0x7f, 0x7f, - 0x79, 0xf0, 0xe0, 0xe4, 0x8d, 0xee, 0x4, 0x19, 0x99, 0x3b, 0xbe, 0xea, 0x0, 0x1e, 0x80, 0x78, 0x53, - 0xc7, 0xf0, 0xe4, 0x30, 0x52, 0xb, 0x52, 0xb4, 0x33, 0xd9, 0xb3, 0xa2, 0x48, 0xbd, 0x25, 0xc0, 0xf7, - 0xc3, 0x65, 0xb3, 0x74, 0x1e, 0x22, 0x78, 0x11, 0x6d, 0x79, 0x0, 0x13, 0xf6, 0x1b, 0xf8, 0x88, 0x3, - 0x3e, 0xe1, 0xcc, 0x6, 0x88, 0xaa, 0x22, 0xb, 0xe8, 0xfd, 0xdb, 0xc7, 0x3d, 0x6}; + uint8_t pkt[] = {0xa2, 0x18, 0x60, 0x15, 0x0, 0x9, 0x9, 0x86, 0xb2, 0xdb, 0x9f, 0xf9, 0xeb, + 0xfa, 0xbb, 0x0, 0x9, 0xa6, 0x29, 0xe6, 0xb8, 0x59, 0xfc, 0xd, 0x2e, 0x42}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x5e, 0x9e, 0xb5, 0xc0, 0x4a, 0x1c, 0xf9}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x9, 0x86, 0xb2, 0xdb, 0x9f, 0xf9, 0xeb, 0xfa, 0xbb}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf8, 0xf3, 0x6, 0x0, 0x53, 0x67, 0x7d, 0x80, 0xb1, 0x9a, 0x32, 0x1a, 0x2d, - 0xf2, 0x1d, 0xe5, 0x9, 0x15, 0x1f, 0xbd, 0x6d, 0xe1, 0xe6, 0x49, 0x1c}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa6, 0x29, 0xe6, 0xb8, 0x59, 0xfc, 0xd, 0x2e, 0x42}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1a, 0xc2, 0xb3, 0x43, 0xcb, 0x98}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf4, 0x23, 0x98, 0xaf, 0xc2, 0x99, 0xe7, 0xef, 0x17, 0x44, 0x92, - 0x51, 0xf8, 0x67, 0xf6, 0x77, 0x8f, 0x4b, 0xc2, 0xf5, 0xb5}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x14, 0x9, 0x49, 0x73, 0x9b, 0x6a, 0x70, 0xc5, 0x16, 0x27, - 0x31, 0x2c, 0x47, 0x28, 0x50, 0x15, 0x24, 0xa3, 0x90, 0x92, - 0x9f, 0x1f, 0x59, 0xc2, 0x4d, 0x97, 0x9d, 0xff}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xec, 0x9f}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xe4, 0x84, 0x82, 0xfe, 0xd5, 0xad, 0x31, 0xca, 0x30, 0x88, 0x87, 0xe7, 0x9d, 0xa7, - 0x70, 0xc7, 0x7d, 0x8b, 0x3, 0x20, 0xbf, 0xbd, 0xa8, 0xf5, 0xe3, 0x12, 0x7d}; - lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe9, 0x6d, 0x63, 0x9b, 0x4b, 0x8, 0x21, 0x1e, 0x75, 0x1a}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x74, 0xb2, 0x7f, 0x7f, 0x79, 0xf0, 0xe0, 0xe4, - 0x8d, 0xee, 0x4, 0x19, 0x99, 0x3b, 0xbe, 0xea}; - lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x80, 0x78, 0x53, 0xc7, 0xf0, 0xe4, 0x30, 0x52, 0xb, 0x52, - 0xb4, 0x33, 0xd9, 0xb3, 0xa2, 0x48, 0xbd, 0x25, 0xc0, 0xf7, - 0xc3, 0x65, 0xb3, 0x74, 0x1e, 0x22, 0x78, 0x11, 0x6d, 0x79}; - lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xf6, 0x1b, 0xf8, 0x88, 0x3, 0x3e, 0xe1, 0xcc, 0x6, 0x88, - 0xaa, 0x22, 0xb, 0xe8, 0xfd, 0xdb, 0xc7, 0x3d, 0x6}; - lwmqtt_string_t topic_filter_s10 = {19, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8587, 11, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24597, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24034 -// ["\156\234\208\197\181\158\172S\218","\132\v\NAK\170\230\US\216+\217\DEL\213\156F","MTu\239]\128\EOT\f\SYN_\203\250\250\148\128\\\SO\ETBuv\137\211w\174+\NULUh_\232","\134\175\155\DC1\190\137R%\247H\202\207","\135\ETX\221t\137\178A\194\131\189V\254\204\246\175\143x\NAK\162[\135*\235[\EOT","Sq\209\151pP","\185\181~\EM\159\160\137\183\ETXQ\129u\174'O\210\177\GSi\201\217","Ch\167\252[{V1Q\223D\152$70\147\DC1\158-t7\250\152+\244\255\RS^j","\134\&4\166Q\210\FS\194\136\206qe\DLE]CG\FSEj\169\156\NUL\213\185>H\ETX&\SI\140"] +// UnsubscribeRequest 17778 +// ["\136x\150\168\US\251\133\245\161\132","","\156","\b\158G{\v-Ms1\169\219\152\168\DC4\152\236\156\169\r +// L{\144]w<\161","^\n\242r\171T8\161Q\v\135\252\STX8r\191\232\164\NUL\USM\199\151|8G\166","y\b\179\128O\138\242\240@2\163\187~\137\EOT\212\&2\EOT\167\\}f\170:\169x\186~","\b4\215\223kA\248\252\v\173\218\f\217.\171O\210\199\&4\ETX\NULk\f7~\151\&5\142\USL","\223\248\DC3<\163N\164?\DC2%\ENQ\251\214\223\&4\239\&13_3\DEL\SYN*c\NUL\ETX","\215\DC1\218\DC1l\160\ESCV@L\v$\203\195","\221M\253c3\176\146Y\151\250\249^YYC\182n`\ENQg\203s\198\249\232"] // [] TEST(Unsubscribe311QCTest, Encode19) { - uint8_t pkt[] = {0xa2, 0xc2, 0x1, 0x5d, 0xe2, 0x0, 0x9, 0x9c, 0xea, 0xd0, 0xc5, 0xb5, 0x9e, 0xac, 0x53, 0xda, 0x0, - 0xd, 0x84, 0xb, 0x15, 0xaa, 0xe6, 0x1f, 0xd8, 0x2b, 0xd9, 0x7f, 0xd5, 0x9c, 0x46, 0x0, 0x1e, 0x4d, - 0x54, 0x75, 0xef, 0x5d, 0x80, 0x4, 0xc, 0x16, 0x5f, 0xcb, 0xfa, 0xfa, 0x94, 0x80, 0x5c, 0xe, 0x17, - 0x75, 0x76, 0x89, 0xd3, 0x77, 0xae, 0x2b, 0x0, 0x55, 0x68, 0x5f, 0xe8, 0x0, 0xc, 0x86, 0xaf, 0x9b, - 0x11, 0xbe, 0x89, 0x52, 0x25, 0xf7, 0x48, 0xca, 0xcf, 0x0, 0x19, 0x87, 0x3, 0xdd, 0x74, 0x89, 0xb2, - 0x41, 0xc2, 0x83, 0xbd, 0x56, 0xfe, 0xcc, 0xf6, 0xaf, 0x8f, 0x78, 0x15, 0xa2, 0x5b, 0x87, 0x2a, 0xeb, - 0x5b, 0x4, 0x0, 0x6, 0x53, 0x71, 0xd1, 0x97, 0x70, 0x50, 0x0, 0x15, 0xb9, 0xb5, 0x7e, 0x19, 0x9f, - 0xa0, 0x89, 0xb7, 0x3, 0x51, 0x81, 0x75, 0xae, 0x27, 0x4f, 0xd2, 0xb1, 0x1d, 0x69, 0xc9, 0xd9, 0x0, - 0x1d, 0x43, 0x68, 0xa7, 0xfc, 0x5b, 0x7b, 0x56, 0x31, 0x51, 0xdf, 0x44, 0x98, 0x24, 0x37, 0x30, 0x93, - 0x11, 0x9e, 0x2d, 0x74, 0x37, 0xfa, 0x98, 0x2b, 0xf4, 0xff, 0x1e, 0x5e, 0x6a, 0x0, 0x1d, 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0x25, 0x5, 0xfb, 0xd6, 0xdf, 0x34, 0xef, 0x31, 0x33, 0x5f, 0x33, 0x7f, 0x16, 0x2a, 0x63, 0x0, 0x3, + 0x0, 0xe, 0xd7, 0x11, 0xda, 0x11, 0x6c, 0xa0, 0x1b, 0x56, 0x40, 0x4c, 0xb, 0x24, 0xcb, 0xc3, 0x0, + 0x19, 0xdd, 0x4d, 0xfd, 0x63, 0x33, 0xb0, 0x92, 0x59, 0x97, 0xfa, 0xf9, 0x5e, 0x59, 0x59, 0x43, 0xb6, + 0x6e, 0x60, 0x5, 0x67, 0xcb, 0x73, 0xc6, 0xf9, 0xe8}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x9c, 0xea, 0xd0, 0xc5, 0xb5, 0x9e, 0xac, 0x53, 0xda}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x88, 0x78, 0x96, 0xa8, 0x1f, 0xfb, 0x85, 0xf5, 0xa1, 0x84}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x84, 0xb, 0x15, 0xaa, 0xe6, 0x1f, 0xd8, 0x2b, 0xd9, 0x7f, 0xd5, 0x9c, 0x46}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4d, 0x54, 0x75, 0xef, 0x5d, 0x80, 0x4, 0xc, 0x16, 0x5f, - 0xcb, 0xfa, 0xfa, 0x94, 0x80, 0x5c, 0xe, 0x17, 0x75, 0x76, - 0x89, 0xd3, 0x77, 0xae, 0x2b, 0x0, 0x55, 0x68, 0x5f, 0xe8}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x9c}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x86, 0xaf, 0x9b, 0x11, 0xbe, 0x89, 0x52, 0x25, 0xf7, 0x48, 0xca, 0xcf}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x8, 0x9e, 0x47, 0x7b, 0xb, 0x2d, 0x4d, 0x73, 0x31, 0xa9, 0xdb, 0x98, 0xa8, 0x14, + 0x98, 0xec, 0x9c, 0xa9, 0xd, 0x20, 0x4c, 0x7b, 0x90, 0x5d, 0x77, 0x3c, 0xa1}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x87, 0x3, 0xdd, 0x74, 0x89, 0xb2, 0x41, 0xc2, 0x83, 0xbd, 0x56, 0xfe, 0xcc, - 0xf6, 0xaf, 0x8f, 0x78, 0x15, 0xa2, 0x5b, 0x87, 0x2a, 0xeb, 0x5b, 0x4}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x5e, 0xa, 0xf2, 0x72, 0xab, 0x54, 0x38, 0xa1, 0x51, 0xb, 0x87, 0xfc, 0x2, 0x38, + 0x72, 0xbf, 0xe8, 0xa4, 0x0, 0x1f, 0x4d, 0xc7, 0x97, 0x7c, 0x38, 0x47, 0xa6}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x53, 0x71, 0xd1, 0x97, 0x70, 0x50}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x79, 0x8, 0xb3, 0x80, 0x4f, 0x8a, 0xf2, 0xf0, 0x40, 0x32, + 0xa3, 0xbb, 0x7e, 0x89, 0x4, 0xd4, 0x32, 0x4, 0xa7, 0x5c, + 0x7d, 0x66, 0xaa, 0x3a, 0xa9, 0x78, 0xba, 0x7e}; + lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb9, 0xb5, 0x7e, 0x19, 0x9f, 0xa0, 0x89, 0xb7, 0x3, 0x51, 0x81, - 0x75, 0xae, 0x27, 0x4f, 0xd2, 0xb1, 0x1d, 0x69, 0xc9, 0xd9}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x8, 0x34, 0xd7, 0xdf, 0x6b, 0x41, 0xf8, 0xfc, 0xb, 0xad, + 0xda, 0xc, 0xd9, 0x2e, 0xab, 0x4f, 0xd2, 0xc7, 0x34, 0x3, + 0x0, 0x6b, 0xc, 0x37, 0x7e, 0x97, 0x35, 0x8e, 0x1f, 0x4c}; + lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x43, 0x68, 0xa7, 0xfc, 0x5b, 0x7b, 0x56, 0x31, 0x51, 0xdf, - 0x44, 0x98, 0x24, 0x37, 0x30, 0x93, 0x11, 0x9e, 0x2d, 0x74, - 0x37, 0xfa, 0x98, 0x2b, 0xf4, 0xff, 0x1e, 0x5e, 0x6a}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xdf, 0xf8, 0x13, 0x3c, 0xa3, 0x4e, 0xa4, 0x3f, 0x12, 0x25, 0x5, 0xfb, 0xd6, + 0xdf, 0x34, 0xef, 0x31, 0x33, 0x5f, 0x33, 0x7f, 0x16, 0x2a, 0x63, 0x0, 0x3}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x86, 0x34, 0xa6, 0x51, 0xd2, 0x1c, 0xc2, 0x88, 0xce, 0x71, - 0x65, 0x10, 0x5d, 0x43, 0x47, 0x1c, 0x45, 0x6a, 0xa9, 0x9c, - 0x0, 0xd5, 0xb9, 0x3e, 0x48, 0x3, 0x26, 0xf, 0x8c}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xd7, 0x11, 0xda, 0x11, 0x6c, 0xa0, 0x1b, 0x56, 0x40, 0x4c, 0xb, 0x24, 0xcb, 0xc3}; + lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xdd, 0x4d, 0xfd, 0x63, 0x33, 0xb0, 0x92, 0x59, 0x97, 0xfa, 0xf9, 0x5e, 0x59, + 0x59, 0x43, 0xb6, 0x6e, 0x60, 0x5, 0x67, 0xcb, 0x73, 0xc6, 0xf9, 0xe8}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24034, 9, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17778, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5686 -// ["","\v}7\181\SI\131\156\ETX\158\RS<\237t\205^\236\158\139>","\179\158\242","","}>\\@\236\138X@Bu=P>J\STX\STXF&,?\129'\213\195\189","\\W=A\231m\181\237v\154\160","\254\234\210\&3`B\"/\175\253\131\244@\176]\211\159\163\160$\246"] +// UnsubscribeRequest 4976 +// ["_\190\245~5\207\156\SOHtV\FSY\253Gq\220\&8R\"\148","\CAN\141\210\134\ETBEiWm\158\t}\150O\175\CANHzh\157]q\173BuK\182p","\SUB\156\FS\ENQo#V\174\SYN\EM\150\161\a\231S\236\217\251\185\142\186\216\132\DC1I\"\172=5","\200d\202\182\185\147","\196\172'","kx\GS\134,&\222\152\&0\US\188\202zs\141g\170\174\164\SUB\246\184Wd\135\237","\254\207M\NAK\202g\EOT\135\186\213.\229\222\152","=\137\241~\EOTl","&\"","6\239R\208\161@\FS\US\250\170`\SUB\155{"] // [] TEST(Unsubscribe311QCTest, Encode20) { - uint8_t pkt[] = {0xa2, 0x5f, 0x16, 0x36, 0x0, 0x0, 0x0, 0x13, 0xb, 0x7d, 0x37, 0xb5, 0xf, 0x83, 0x9c, 0x3, 0x9e, - 0x1e, 0x3c, 0xed, 0x74, 0xcd, 0x5e, 0xec, 0x9e, 0x8b, 0x3e, 0x0, 0x3, 0xb3, 0x9e, 0xf2, 0x0, 0x0, - 0x0, 0x19, 0x7d, 0x3e, 0x5c, 0x40, 0xec, 0x8a, 0x58, 0x40, 0x42, 0x75, 0x3d, 0x50, 0x3e, 0x4a, 0x2, - 0x2, 0x46, 0x26, 0x2c, 0x3f, 0x81, 0x27, 0xd5, 0xc3, 0xbd, 0x0, 0xb, 0x5c, 0x57, 0x3d, 0x41, 0xe7, - 0x6d, 0xb5, 0xed, 0x76, 0x9a, 0xa0, 0x0, 0x15, 0xfe, 0xea, 0xd2, 0x33, 0x60, 0x42, 0x22, 0x2f, 0xaf, - 0xfd, 0x83, 0xf4, 0x40, 0xb0, 0x5d, 0xd3, 0x9f, 0xa3, 0xa0, 0x24, 0xf6}; + uint8_t pkt[] = {0xa2, 0xaa, 0x1, 0x13, 0x70, 0x0, 0x14, 0x5f, 0xbe, 0xf5, 0x7e, 0x35, 0xcf, 0x9c, 0x1, 0x74, + 0x56, 0x1c, 0x59, 0xfd, 0x47, 0x71, 0xdc, 0x38, 0x52, 0x22, 0x94, 0x0, 0x1c, 0x18, 0x8d, 0xd2, + 0x86, 0x17, 0x45, 0x69, 0x57, 0x6d, 0x9e, 0x9, 0x7d, 0x96, 0x4f, 0xaf, 0x18, 0x48, 0x7a, 0x68, + 0x9d, 0x5d, 0x71, 0xad, 0x42, 0x75, 0x4b, 0xb6, 0x70, 0x0, 0x1d, 0x1a, 0x9c, 0x1c, 0x5, 0x6f, + 0x23, 0x56, 0xae, 0x16, 0x19, 0x96, 0xa1, 0x7, 0xe7, 0x53, 0xec, 0xd9, 0xfb, 0xb9, 0x8e, 0xba, + 0xd8, 0x84, 0x11, 0x49, 0x22, 0xac, 0x3d, 0x35, 0x0, 0x6, 0xc8, 0x64, 0xca, 0xb6, 0xb9, 0x93, + 0x0, 0x3, 0xc4, 0xac, 0x27, 0x0, 0x1a, 0x6b, 0x78, 0x1d, 0x86, 0x2c, 0x26, 0xde, 0x98, 0x30, + 0x1f, 0xbc, 0xca, 0x7a, 0x73, 0x8d, 0x67, 0xaa, 0xae, 0xa4, 0x1a, 0xf6, 0xb8, 0x57, 0x64, 0x87, + 0xed, 0x0, 0xe, 0xfe, 0xcf, 0x4d, 0x15, 0xca, 0x67, 0x4, 0x87, 0xba, 0xd5, 0x2e, 0xe5, 0xde, + 0x98, 0x0, 0x6, 0x3d, 0x89, 0xf1, 0x7e, 0x4, 0x6c, 0x0, 0x2, 0x26, 0x22, 0x0, 0xe, 0x36, + 0xef, 0x52, 0xd0, 0xa1, 0x40, 0x1c, 0x1f, 0xfa, 0xaa, 0x60, 0x1a, 0x9b, 0x7b}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x5f, 0xbe, 0xf5, 0x7e, 0x35, 0xcf, 0x9c, 0x1, 0x74, 0x56, + 0x1c, 0x59, 0xfd, 0x47, 0x71, 0xdc, 0x38, 0x52, 0x22, 0x94}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb, 0x7d, 0x37, 0xb5, 0xf, 0x83, 0x9c, 0x3, 0x9e, 0x1e, - 0x3c, 0xed, 0x74, 0xcd, 0x5e, 0xec, 0x9e, 0x8b, 0x3e}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x18, 0x8d, 0xd2, 0x86, 0x17, 0x45, 0x69, 0x57, 0x6d, 0x9e, + 0x9, 0x7d, 0x96, 0x4f, 0xaf, 0x18, 0x48, 0x7a, 0x68, 0x9d, + 0x5d, 0x71, 0xad, 0x42, 0x75, 0x4b, 0xb6, 0x70}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb3, 0x9e, 0xf2}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1a, 0x9c, 0x1c, 0x5, 0x6f, 0x23, 0x56, 0xae, 0x16, 0x19, + 0x96, 0xa1, 0x7, 0xe7, 0x53, 0xec, 0xd9, 0xfb, 0xb9, 0x8e, + 0xba, 0xd8, 0x84, 0x11, 0x49, 0x22, 0xac, 0x3d, 0x35}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc8, 0x64, 0xca, 0xb6, 0xb9, 0x93}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7d, 0x3e, 0x5c, 0x40, 0xec, 0x8a, 0x58, 0x40, 0x42, 0x75, 0x3d, 0x50, 0x3e, - 0x4a, 0x2, 0x2, 0x46, 0x26, 0x2c, 0x3f, 0x81, 0x27, 0xd5, 0xc3, 0xbd}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc4, 0xac, 0x27}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5c, 0x57, 0x3d, 0x41, 0xe7, 0x6d, 0xb5, 0xed, 0x76, 0x9a, 0xa0}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x6b, 0x78, 0x1d, 0x86, 0x2c, 0x26, 0xde, 0x98, 0x30, 0x1f, 0xbc, 0xca, 0x7a, + 0x73, 0x8d, 0x67, 0xaa, 0xae, 0xa4, 0x1a, 0xf6, 0xb8, 0x57, 0x64, 0x87, 0xed}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xfe, 0xea, 0xd2, 0x33, 0x60, 0x42, 0x22, 0x2f, 0xaf, 0xfd, 0x83, - 0xf4, 0x40, 0xb0, 0x5d, 0xd3, 0x9f, 0xa3, 0xa0, 0x24, 0xf6}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xfe, 0xcf, 0x4d, 0x15, 0xca, 0x67, 0x4, 0x87, 0xba, 0xd5, 0x2e, 0xe5, 0xde, 0x98}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x3d, 0x89, 0xf1, 0x7e, 0x4, 0x6c}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x26, 0x22}; + lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x36, 0xef, 0x52, 0xd0, 0xa1, 0x40, 0x1c, + 0x1f, 0xfa, 0xaa, 0x60, 0x1a, 0x9b, 0x7b}; + lwmqtt_string_t topic_filter_s9 = {14, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5686, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4976, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24245 -// ["\187-s\231\141\DELJq\246","\NAK]%\227\253\FST\142?\253C;\SOH\191\250\223T\RS\DC2\247B\191\193\222\196I\129","\196\132\&8J\197\&8\163\133\229"] +// UnsubscribeRequest 12973 +// ["\DC1As\216\DLE\214\246\194\220\178\DC3\NULON\198\226\147P\205\SO\129\&4\RS\DC3\206","\171\&0\204\160\CAN.\142\255 +// \134\198\220\DEL@\163\216\&2\165\142\225\208","^\163\204\213TZ\"\SO","\136!\167=\170\214\"\232\ESC +// \216\174%\ENQ]\219\133}\226\235","J\182\bT\140Z","\188n\150\191L#\NAK\197\136\194[\192m\141\196\n\211\252","\195\157\173\ACKh\DEL\178\230\r","e(y\DC3\r|+\138\216\196*\227~\180\140DX\250\181\135#\214#;!\225\161\201","1\252\225\175\STX\172\236\SYN\176\&2\"\204\v\RS\b\189","\218\181\178\245x\187\245\167\&5\144\249L:\209\146"] // [] TEST(Unsubscribe311QCTest, Encode21) { - uint8_t pkt[] = {0xa2, 0x35, 0x5e, 0xb5, 0x0, 0x9, 0xbb, 0x2d, 0x73, 0xe7, 0x8d, 0x7f, 0x4a, 0x71, - 0xf6, 0x0, 0x1b, 0x15, 0x5d, 0x25, 0xe3, 0xfd, 0x1c, 0x54, 0x8e, 0x3f, 0xfd, 0x43, - 0x3b, 0x1, 0xbf, 0xfa, 0xdf, 0x54, 0x1e, 0x12, 0xf7, 0x42, 0xbf, 0xc1, 0xde, 0xc4, - 0x49, 0x81, 0x0, 0x9, 0xc4, 0x84, 0x38, 0x4a, 0xc5, 0x38, 0xa3, 0x85, 0xe5}; + uint8_t pkt[] = {0xa2, 0xbc, 0x1, 0x32, 0xad, 0x0, 0x19, 0x11, 0x41, 0x73, 0xd8, 0x10, 0xd6, 0xf6, 0xc2, 0xdc, + 0xb2, 0x13, 0x0, 0x4f, 0x4e, 0xc6, 0xe2, 0x93, 0x50, 0xcd, 0xe, 0x81, 0x34, 0x1e, 0x13, 0xce, + 0x0, 0x15, 0xab, 0x30, 0xcc, 0xa0, 0x18, 0x2e, 0x8e, 0xff, 0x20, 0x86, 0xc6, 0xdc, 0x7f, 0x40, + 0xa3, 0xd8, 0x32, 0xa5, 0x8e, 0xe1, 0xd0, 0x0, 0x8, 0x5e, 0xa3, 0xcc, 0xd5, 0x54, 0x5a, 0x22, + 0xe, 0x0, 0x14, 0x88, 0x21, 0xa7, 0x3d, 0xaa, 0xd6, 0x22, 0xe8, 0x1b, 0x20, 0xd8, 0xae, 0x25, + 0x5, 0x5d, 0xdb, 0x85, 0x7d, 0xe2, 0xeb, 0x0, 0x6, 0x4a, 0xb6, 0x8, 0x54, 0x8c, 0x5a, 0x0, + 0x12, 0xbc, 0x6e, 0x96, 0xbf, 0x4c, 0x23, 0x15, 0xc5, 0x88, 0xc2, 0x5b, 0xc0, 0x6d, 0x8d, 0xc4, + 0xa, 0xd3, 0xfc, 0x0, 0x9, 0xc3, 0x9d, 0xad, 0x6, 0x68, 0x7f, 0xb2, 0xe6, 0xd, 0x0, 0x1c, + 0x65, 0x28, 0x79, 0x13, 0xd, 0x7c, 0x2b, 0x8a, 0xd8, 0xc4, 0x2a, 0xe3, 0x7e, 0xb4, 0x8c, 0x44, + 0x58, 0xfa, 0xb5, 0x87, 0x23, 0xd6, 0x23, 0x3b, 0x21, 0xe1, 0xa1, 0xc9, 0x0, 0x10, 0x31, 0xfc, + 0xe1, 0xaf, 0x2, 0xac, 0xec, 0x16, 0xb0, 0x32, 0x22, 0xcc, 0xb, 0x1e, 0x8, 0xbd, 0x0, 0xf, + 0xda, 0xb5, 0xb2, 0xf5, 0x78, 0xbb, 0xf5, 0xa7, 0x35, 0x90, 0xf9, 0x4c, 0x3a, 0xd1, 0x92}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xbb, 0x2d, 0x73, 0xe7, 0x8d, 0x7f, 0x4a, 0x71, 0xf6}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x11, 0x41, 0x73, 0xd8, 0x10, 0xd6, 0xf6, 0xc2, 0xdc, 0xb2, 0x13, 0x0, 0x4f, + 0x4e, 0xc6, 0xe2, 0x93, 0x50, 0xcd, 0xe, 0x81, 0x34, 0x1e, 0x13, 0xce}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x15, 0x5d, 0x25, 0xe3, 0xfd, 0x1c, 0x54, 0x8e, 0x3f, 0xfd, 0x43, 0x3b, 0x1, 0xbf, - 0xfa, 0xdf, 0x54, 0x1e, 0x12, 0xf7, 0x42, 0xbf, 0xc1, 0xde, 0xc4, 0x49, 0x81}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xab, 0x30, 0xcc, 0xa0, 0x18, 0x2e, 0x8e, 0xff, 0x20, 0x86, 0xc6, + 0xdc, 0x7f, 0x40, 0xa3, 0xd8, 0x32, 0xa5, 0x8e, 0xe1, 0xd0}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc4, 0x84, 0x38, 0x4a, 0xc5, 0x38, 0xa3, 0x85, 0xe5}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5e, 0xa3, 0xcc, 0xd5, 0x54, 0x5a, 0x22, 0xe}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x88, 0x21, 0xa7, 0x3d, 0xaa, 0xd6, 0x22, 0xe8, 0x1b, 0x20, + 0xd8, 0xae, 0x25, 0x5, 0x5d, 0xdb, 0x85, 0x7d, 0xe2, 0xeb}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x4a, 0xb6, 0x8, 0x54, 0x8c, 0x5a}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xbc, 0x6e, 0x96, 0xbf, 0x4c, 0x23, 0x15, 0xc5, 0x88, + 0xc2, 0x5b, 0xc0, 0x6d, 0x8d, 0xc4, 0xa, 0xd3, 0xfc}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc3, 0x9d, 0xad, 0x6, 0x68, 0x7f, 0xb2, 0xe6, 0xd}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x65, 0x28, 0x79, 0x13, 0xd, 0x7c, 0x2b, 0x8a, 0xd8, 0xc4, + 0x2a, 0xe3, 0x7e, 0xb4, 0x8c, 0x44, 0x58, 0xfa, 0xb5, 0x87, + 0x23, 0xd6, 0x23, 0x3b, 0x21, 0xe1, 0xa1, 0xc9}; + lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x31, 0xfc, 0xe1, 0xaf, 0x2, 0xac, 0xec, 0x16, + 0xb0, 0x32, 0x22, 0xcc, 0xb, 0x1e, 0x8, 0xbd}; + lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xda, 0xb5, 0xb2, 0xf5, 0x78, 0xbb, 0xf5, 0xa7, + 0x35, 0x90, 0xf9, 0x4c, 0x3a, 0xd1, 0x92}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24245, 3, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12973, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 25032 ["\SYN;\174\NAK\140_\188\"[\SOH3z~7\194\136\&7\218\&2\SYN<\156w","V\219\229e\199 -// ","W\238\187\GS\SUB\132\133w\251\149h\178\201\DC3\204\209\201\SYN","}=\204\166\208\175.\200\192\SYNb\177","!\174\SO\173\137~:\238\166u\EOT\165\184r4\185l\201\128\190\&0f\156","\149:.\217?\"ev=\v;\158\129d\244\ACKxH{\DC4\245","J"] +// UnsubscribeRequest 26764 +// ["\228\129\194\154UZ\162#\ENQ\166y\194\131\134\146\CAN\249\179\195=\\H\131_\195\ACK","\157>\170,\252e\253\207?\202o\189\&8\149\170\251\138\173}\GS\224\ACK\181\156","\139O+\138\ESC$!\248\160\249K\171\161\214,l\r\191X\ETB*\160\246\a/","","\139\149j\246C\170\168\SI\n\151\SOH\219\243\RS\222\206k\199\ESC\SUB\DC2x(5:!D","\245x0\213\130\200\229\176\SUB$\SOH\ENQ\243\153\147\242\157\219\190","jv\130p\n\255\130\158\213\218O\SYN\194W\191\188","\210\132\229-R&\239\246\ESCe\194\US.\222\DC2&\135$\210YE\129","hM{7","\206N\242@%2\218\216\138\232\155\156\n\US\248z@\207\SYN\211\221\&8\164\239\155"] // [] TEST(Unsubscribe311QCTest, Encode22) { - uint8_t pkt[] = {0xa2, 0x78, 0x61, 0xc8, 0x0, 0x17, 0x16, 0x3b, 0xae, 0x15, 0x8c, 0x5f, 0xbc, 0x22, 0x5b, 0x1, - 0x33, 0x7a, 0x7e, 0x37, 0xc2, 0x88, 0x37, 0xda, 0x32, 0x16, 0x3c, 0x9c, 0x77, 0x0, 0x6, 0x56, - 0xdb, 0xe5, 0x65, 0xc7, 0x20, 0x0, 0x12, 0x57, 0xee, 0xbb, 0x1d, 0x1a, 0x84, 0x85, 0x77, 0xfb, - 0x95, 0x68, 0xb2, 0xc9, 0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x12, 0x78, 0x28, 0x35, 0x3a, 0x21, 0x44, 0x0, 0x13, + 0xf5, 0x78, 0x30, 0xd5, 0x82, 0xc8, 0xe5, 0xb0, 0x1a, 0x24, 0x1, 0x5, 0xf3, 0x99, 0x93, 0xf2, 0x9d, + 0xdb, 0xbe, 0x0, 0x10, 0x6a, 0x76, 0x82, 0x70, 0xa, 0xff, 0x82, 0x9e, 0xd5, 0xda, 0x4f, 0x16, 0xc2, + 0x57, 0xbf, 0xbc, 0x0, 0x16, 0xd2, 0x84, 0xe5, 0x2d, 0x52, 0x26, 0xef, 0xf6, 0x1b, 0x65, 0xc2, 0x1f, + 0x2e, 0xde, 0x12, 0x26, 0x87, 0x24, 0xd2, 0x59, 0x45, 0x81, 0x0, 0x4, 0x68, 0x4d, 0x7b, 0x37, 0x0, + 0x19, 0xce, 0x4e, 0xf2, 0x40, 0x25, 0x32, 0xda, 0xd8, 0x8a, 0xe8, 0x9b, 0x9c, 0xa, 0x1f, 0xf8, 0x7a, + 0x40, 0xcf, 0x16, 0xd3, 0xdd, 0x38, 0xa4, 0xef, 0x9b}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x16, 0x3b, 0xae, 0x15, 0x8c, 0x5f, 0xbc, 0x22, 0x5b, 0x1, 0x33, 0x7a, - 0x7e, 0x37, 0xc2, 0x88, 0x37, 0xda, 0x32, 0x16, 0x3c, 0x9c, 0x77}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xe4, 0x81, 0xc2, 0x9a, 0x55, 0x5a, 0xa2, 0x23, 0x5, 0xa6, 0x79, 0xc2, 0x83, + 0x86, 0x92, 0x18, 0xf9, 0xb3, 0xc3, 0x3d, 0x5c, 0x48, 0x83, 0x5f, 0xc3, 0x6}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x56, 0xdb, 0xe5, 0x65, 0xc7, 0x20}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9d, 0x3e, 0xaa, 0x2c, 0xfc, 0x65, 0xfd, 0xcf, 0x3f, 0xca, 0x6f, 0xbd, + 0x38, 0x95, 0xaa, 0xfb, 0x8a, 0xad, 0x7d, 0x1d, 0xe0, 0x6, 0xb5, 0x9c}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x57, 0xee, 0xbb, 0x1d, 0x1a, 0x84, 0x85, 0x77, 0xfb, - 0x95, 0x68, 0xb2, 0xc9, 0x13, 0xcc, 0xd1, 0xc9, 0x16}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8b, 0x4f, 0x2b, 0x8a, 0x1b, 0x24, 0x21, 0xf8, 0xa0, 0xf9, 0x4b, 0xab, 0xa1, + 0xd6, 0x2c, 0x6c, 0xd, 0xbf, 0x58, 0x17, 0x2a, 0xa0, 0xf6, 0x7, 0x2f}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x7d, 0x3d, 0xcc, 0xa6, 0xd0, 0xaf, 0x2e, 0xc8, 0xc0, 0x16, 0x62, 0xb1}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x21, 0xae, 0xe, 0xad, 0x89, 0x7e, 0x3a, 0xee, 0xa6, 0x75, 0x4, 0xa5, - 0xb8, 0x72, 0x34, 0xb9, 0x6c, 0xc9, 0x80, 0xbe, 0x30, 0x66, 0x9c}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x8b, 0x95, 0x6a, 0xf6, 0x43, 0xaa, 0xa8, 0xf, 0xa, 0x97, 0x1, 0xdb, 0xf3, 0x1e, + 0xde, 0xce, 0x6b, 0xc7, 0x1b, 0x1a, 0x12, 0x78, 0x28, 0x35, 0x3a, 0x21, 0x44}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x95, 0x3a, 0x2e, 0xd9, 0x3f, 0x22, 0x65, 0x76, 0x3d, 0xb, 0x3b, - 0x9e, 0x81, 0x64, 0xf4, 0x6, 0x78, 0x48, 0x7b, 0x14, 0xf5}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf5, 0x78, 0x30, 0xd5, 0x82, 0xc8, 0xe5, 0xb0, 0x1a, 0x24, + 0x1, 0x5, 0xf3, 0x99, 0x93, 0xf2, 0x9d, 0xdb, 0xbe}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4a}; - lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x6a, 0x76, 0x82, 0x70, 0xa, 0xff, 0x82, 0x9e, + 0xd5, 0xda, 0x4f, 0x16, 0xc2, 0x57, 0xbf, 0xbc}; + lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xd2, 0x84, 0xe5, 0x2d, 0x52, 0x26, 0xef, 0xf6, 0x1b, 0x65, 0xc2, + 0x1f, 0x2e, 0xde, 0x12, 0x26, 0x87, 0x24, 0xd2, 0x59, 0x45, 0x81}; + lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x68, 0x4d, 0x7b, 0x37}; + lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xce, 0x4e, 0xf2, 0x40, 0x25, 0x32, 0xda, 0xd8, 0x8a, 0xe8, 0x9b, 0x9c, 0xa, + 0x1f, 0xf8, 0x7a, 0x40, 0xcf, 0x16, 0xd3, 0xdd, 0x38, 0xa4, 0xef, 0x9b}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25032, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26764, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 9981 ["\234","\236\168cp","~","\224\178\190\NAK\250][\147CG\225f\248\DC3\243\"\t\""] [] +// UnsubscribeRequest 25855 +// ["*\148\DEL\172\179\158\a\ETX\SONJH`\204\245\213\178\t","","\132\212~\"a\157\185J\138:\200\142","\137\206\187\149\181\150l\210\253\178V\167\ESC\239@\GSD\231\139","\219\198\215\184]\249\ESC\146\186\ETB","K\140\254\EOT`\134\206\GS\195\219e\213\200\SIDy\239 +// \164","\164\146\155I\172w\DC3b\DC4qa","1k\NAK\130\DLE\202\GS\191\239B\tL\162z\ETX\213l\194\143\&6\SYN\152/\154\219e\NAKi","\247k3\164\228?\NUL\158\201\136y\202\169\202"] +// [] TEST(Unsubscribe311QCTest, Encode23) { - uint8_t pkt[] = {0xa2, 0x22, 0x26, 0xfd, 0x0, 0x1, 0xea, 0x0, 0x4, 0xec, 0xa8, 0x63, - 0x70, 0x0, 0x1, 0x7e, 0x0, 0x12, 0xe0, 0xb2, 0xbe, 0x15, 0xfa, 0x5d, - 0x5b, 0x93, 0x43, 0x47, 0xe1, 0x66, 0xf8, 0x13, 0xf3, 0x22, 0x9, 0x22}; + uint8_t pkt[] = {0xa2, 0x97, 0x1, 0x64, 0xff, 0x0, 0x12, 0x2a, 0x94, 0x7f, 0xac, 0xb3, 0x9e, 0x7, 0x3, 0xe, + 0x4e, 0x4a, 0x48, 0x60, 0xcc, 0xf5, 0xd5, 0xb2, 0x9, 0x0, 0x0, 0x0, 0xc, 0x84, 0xd4, 0x7e, + 0x22, 0x61, 0x9d, 0xb9, 0x4a, 0x8a, 0x3a, 0xc8, 0x8e, 0x0, 0x13, 0x89, 0xce, 0xbb, 0x95, 0xb5, + 0x96, 0x6c, 0xd2, 0xfd, 0xb2, 0x56, 0xa7, 0x1b, 0xef, 0x40, 0x1d, 0x44, 0xe7, 0x8b, 0x0, 0xa, + 0xdb, 0xc6, 0xd7, 0xb8, 0x5d, 0xf9, 0x1b, 0x92, 0xba, 0x17, 0x0, 0x13, 0x4b, 0x8c, 0xfe, 0x4, + 0x60, 0x86, 0xce, 0x1d, 0xc3, 0xdb, 0x65, 0xd5, 0xc8, 0xf, 0x44, 0x79, 0xef, 0x20, 0xa4, 0x0, + 0xb, 0xa4, 0x92, 0x9b, 0x49, 0xac, 0x77, 0x13, 0x62, 0x14, 0x71, 0x61, 0x0, 0x1c, 0x31, 0x6b, + 0x15, 0x82, 0x10, 0xca, 0x1d, 0xbf, 0xef, 0x42, 0x9, 0x4c, 0xa2, 0x7a, 0x3, 0xd5, 0x6c, 0xc2, + 0x8f, 0x36, 0x16, 0x98, 0x2f, 0x9a, 0xdb, 0x65, 0x15, 0x69, 0x0, 0xe, 0xf7, 0x6b, 0x33, 0xa4, + 0xe4, 0x3f, 0x0, 0x9e, 0xc9, 0x88, 0x79, 0xca, 0xa9, 0xca}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xea}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x2a, 0x94, 0x7f, 0xac, 0xb3, 0x9e, 0x7, 0x3, 0xe, + 0x4e, 0x4a, 0x48, 0x60, 0xcc, 0xf5, 0xd5, 0xb2, 0x9}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xec, 0xa8, 0x63, 0x70}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7e}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x84, 0xd4, 0x7e, 0x22, 0x61, 0x9d, 0xb9, 0x4a, 0x8a, 0x3a, 0xc8, 0x8e}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe0, 0xb2, 0xbe, 0x15, 0xfa, 0x5d, 0x5b, 0x93, 0x43, - 0x47, 0xe1, 0x66, 0xf8, 0x13, 0xf3, 0x22, 0x9, 0x22}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x89, 0xce, 0xbb, 0x95, 0xb5, 0x96, 0x6c, 0xd2, 0xfd, 0xb2, + 0x56, 0xa7, 0x1b, 0xef, 0x40, 0x1d, 0x44, 0xe7, 0x8b}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xdb, 0xc6, 0xd7, 0xb8, 0x5d, 0xf9, 0x1b, 0x92, 0xba, 0x17}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x4b, 0x8c, 0xfe, 0x4, 0x60, 0x86, 0xce, 0x1d, 0xc3, 0xdb, + 0x65, 0xd5, 0xc8, 0xf, 0x44, 0x79, 0xef, 0x20, 0xa4}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa4, 0x92, 0x9b, 0x49, 0xac, 0x77, 0x13, 0x62, 0x14, 0x71, 0x61}; + lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x31, 0x6b, 0x15, 0x82, 0x10, 0xca, 0x1d, 0xbf, 0xef, 0x42, + 0x9, 0x4c, 0xa2, 0x7a, 0x3, 0xd5, 0x6c, 0xc2, 0x8f, 0x36, + 0x16, 0x98, 0x2f, 0x9a, 0xdb, 0x65, 0x15, 0x69}; + lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xf7, 0x6b, 0x33, 0xa4, 0xe4, 0x3f, 0x0, 0x9e, 0xc9, 0x88, 0x79, 0xca, 0xa9, 0xca}; + lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9981, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25855, 9, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 12131 [";\204\192\156\203","\131\141H4\GSjh\223\t{hE[\134\CAN\142"] [] +// UnsubscribeRequest 20087 ["","\223$\157\133\154\STXu\172d\221\239W\239\v\142#\151b"] [] TEST(Unsubscribe311QCTest, Encode24) { - uint8_t pkt[] = {0xa2, 0x1b, 0x2f, 0x63, 0x0, 0x5, 0x3b, 0xcc, 0xc0, 0x9c, 0xcb, 0x0, 0x10, 0x83, 0x8d, - 0x48, 0x34, 0x1d, 0x6a, 0x68, 0xdf, 0x9, 0x7b, 0x68, 0x45, 0x5b, 0x86, 0x18, 0x8e}; + uint8_t pkt[] = {0xa2, 0x18, 0x4e, 0x77, 0x0, 0x0, 0x0, 0x12, 0xdf, 0x24, 0x9d, 0x85, 0x9a, + 0x2, 0x75, 0xac, 0x64, 0xdd, 0xef, 0x57, 0xef, 0xb, 0x8e, 0x23, 0x97, 0x62}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x3b, 0xcc, 0xc0, 0x9c, 0xcb}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x83, 0x8d, 0x48, 0x34, 0x1d, 0x6a, 0x68, 0xdf, - 0x9, 0x7b, 0x68, 0x45, 0x5b, 0x86, 0x18, 0x8e}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xdf, 0x24, 0x9d, 0x85, 0x9a, 0x2, 0x75, 0xac, 0x64, + 0xdd, 0xef, 0x57, 0xef, 0xb, 0x8e, 0x23, 0x97, 0x62}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12131, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20087, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 2785 -// ["\208\203\198\224\198v\210\132\218\207\b","\DC4g\193CEY\226\133{\205;","\129E\167\RSx\161\SI\218\ENQ\196\149\136\243\170j\166\208\132m\DEL","lI\225V\SYN&\228E\191\236\171\EM\199eL\DLE-\191\155\223\&5\193\b","\154\ENQp\158 -// dj\212\228\243\245\179\ESC\140\SI\ACK\193\215\a\FSR\DLE","\236\152b\183\203\239\189:A\241\200\CAN\207\221i","\198By$\ACK","\147\f\237\210\b\144w}\129d","\176\231\145U\138\241\252\185\178\238\136oQ\ENQ\187\168\228\197","*\210\FS\252"] +// UnsubscribeRequest 23904 +// ["\149\138G<\153B","\176\152\174\227C\212\140\237\176F\225\157","\250\193{\220\129\129\245u\242\229\214\GS\252\173y\184p\165*\244}\215","\ESCB3C\185\170*\235\146\140H11H\198\156\223\DEL\131\144\131\136\224s\209k\b\195\FS"] // [] TEST(Unsubscribe311QCTest, Encode25) { - uint8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, 0x43, 0xd4, 0x8c, 0xed, 0xb0, 0x46, 0xe1, 0x9d, 0x0, 0x16, 0xfa, 0xc1, 0x7b, 0xdc, 0x81, 0x81, + 0xf5, 0x75, 0xf2, 0xe5, 0xd6, 0x1d, 0xfc, 0xad, 0x79, 0xb8, 0x70, 0xa5, 0x2a, 0xf4, 0x7d, 0xd7, 0x0, + 0x1d, 0x1b, 0x42, 0x33, 0x43, 0xb9, 0xaa, 0x2a, 0xeb, 0x92, 0x8c, 0x48, 0x31, 0x31, 0x48, 0xc6, 0x9c, + 0xdf, 0x7f, 0x83, 0x90, 0x83, 0x88, 0xe0, 0x73, 0xd1, 0x6b, 0x8, 0xc3, 0x1c}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd0, 0xcb, 0xc6, 0xe0, 0xc6, 0x76, 0xd2, 0x84, 0xda, 0xcf, 0x8}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x95, 0x8a, 0x47, 0x3c, 0x99, 0x42}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x14, 0x67, 0xc1, 0x43, 0x45, 0x59, 0xe2, 0x85, 0x7b, 0xcd, 0x3b}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb0, 0x98, 0xae, 0xe3, 0x43, 0xd4, 0x8c, 0xed, 0xb0, 0x46, 0xe1, 0x9d}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x81, 0x45, 0xa7, 0x1e, 0x78, 0xa1, 0xf, 0xda, 0x5, 0xc4, - 0x95, 0x88, 0xf3, 0xaa, 0x6a, 0xa6, 0xd0, 0x84, 0x6d, 0x7f}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xfa, 0xc1, 0x7b, 0xdc, 0x81, 0x81, 0xf5, 0x75, 0xf2, 0xe5, 0xd6, + 0x1d, 0xfc, 0xad, 0x79, 0xb8, 0x70, 0xa5, 0x2a, 0xf4, 0x7d, 0xd7}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6c, 0x49, 0xe1, 0x56, 0x16, 0x26, 0xe4, 0x45, 0xbf, 0xec, 0xab, 0x19, - 0xc7, 0x65, 0x4c, 0x10, 0x2d, 0xbf, 0x9b, 0xdf, 0x35, 0xc1, 0x8}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1b, 0x42, 0x33, 0x43, 0xb9, 0xaa, 0x2a, 0xeb, 0x92, 0x8c, + 0x48, 0x31, 0x31, 0x48, 0xc6, 0x9c, 0xdf, 0x7f, 0x83, 0x90, + 0x83, 0x88, 0xe0, 0x73, 0xd1, 0x6b, 0x8, 0xc3, 0x1c}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9a, 0x5, 0x70, 0x9e, 0x20, 0x64, 0x6a, 0xd4, 0xe4, 0xf3, 0xf5, - 0xb3, 0x1b, 0x8c, 0xf, 0x6, 0xc1, 0xd7, 0x7, 0x1c, 0x52, 0x10}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xec, 0x98, 0x62, 0xb7, 0xcb, 0xef, 0xbd, 0x3a, - 0x41, 0xf1, 0xc8, 0x18, 0xcf, 0xdd, 0x69}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc6, 0x42, 0x79, 0x24, 0x6}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x93, 0xc, 0xed, 0xd2, 0x8, 0x90, 0x77, 0x7d, 0x81, 0x64}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xb0, 0xe7, 0x91, 0x55, 0x8a, 0xf1, 0xfc, 0xb9, 0xb2, - 0xee, 0x88, 0x6f, 0x51, 0x5, 0xbb, 0xa8, 0xe4, 0xc5}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x2a, 0xd2, 0x1c, 0xfc}; - lwmqtt_string_t topic_filter_s9 = {4, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2785, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23904, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 3283 -// ["\151","\140k\206\231T4\165\221\&7\206\161\&9\DC2z9\GS\146\232`AuR/&\215\192\226\253","\243?\170\SYNAk\239?W\173","\143l\157\212\165\140<-\"\250\185\166\SOHpBD\213\&5Y3\178\150\186\n\187\194%","\r\250\DLE'?\210\182\153\215\198\173\206k\201Vo\185\236\229\229","\176\171\220\205\STX>\227\CAN\239\167OEZ0s\170\DC2\165B\132r\134?\170L\216\246\162\"\136","\208^\167Dh\248\177\171~k\f\134U8 -// \216\198\252\130\US\DEL*Mq)\186","\164[\150\159l\245a\169W]\ENQ=D\230\143\235\193\215\183:\217\244\EOT\236\CAN\221)\210","\191X\198\252\128?S\147\r>O\b\SUB\215L\222\239\201\157dEh\236\DC2\214'\186\243\\\161"] +// UnsubscribeRequest 18211 ["RU\203\SOH\227Nbl11R~\206d\203\245\&9b\205\253","`\149\SUB<\b\128\137\250\185\176\EM\204"] // [] TEST(Unsubscribe311QCTest, Encode26) { - uint8_t pkt[] = { - 0xa2, 0x80, 0x2, 0xc, 0xd3, 0x0, 0x1, 0x97, 0x0, 0x1c, 0x8c, 0x6b, 0xce, 0xe7, 0x54, 0x34, 0xa5, 0xdd, 0x37, - 0xce, 0xa1, 0x39, 0x12, 0x7a, 0x39, 0x1d, 0x92, 0xe8, 0x60, 0x41, 0x75, 0x52, 0x2f, 0x26, 0xd7, 0xc0, 0xe2, 0xfd, - 0x0, 0xa, 0xf3, 0x3f, 0xaa, 0x16, 0x41, 0x6b, 0xef, 0x3f, 0x57, 0xad, 0x0, 0x1b, 0x8f, 0x6c, 0x9d, 0xd4, 0xa5, - 0x8c, 0x3c, 0x2d, 0x22, 0xfa, 0xb9, 0xa6, 0x1, 0x70, 0x42, 0x44, 0xd5, 0x35, 0x59, 0x33, 0xb2, 0x96, 0xba, 0xa, - 0xbb, 0xc2, 0x25, 0x0, 0x1c, 0xd, 0xfa, 0x10, 0x3c, 0x67, 0x95, 0xe0, 0x9f, 0x9f, 0x98, 0xd3, 0x69, 0x87, 0xa3, - 0x8e, 0x26, 0xa5, 0xdb, 0x19, 0x3a, 0xf, 0x10, 0x36, 0x5b, 0xbb, 0x71, 0x21, 0x24, 0x0, 0x1a, 0x3, 0x53, 0xfb, - 0x81, 0x85, 0x2c,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0xcc}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x97}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x52, 0x55, 0xcb, 0x1, 0xe3, 0x4e, 0x62, 0x6c, 0x31, 0x31, + 0x52, 0x7e, 0xce, 0x64, 0xcb, 0xf5, 0x39, 0x62, 0xcd, 0xfd}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8c, 0x6b, 0xce, 0xe7, 0x54, 0x34, 0xa5, 0xdd, 0x37, 0xce, - 0xa1, 0x39, 0x12, 0x7a, 0x39, 0x1d, 0x92, 0xe8, 0x60, 0x41, - 0x75, 0x52, 0x2f, 0x26, 0xd7, 0xc0, 0xe2, 0xfd}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x60, 0x95, 0x1a, 0x3c, 0x8, 0x80, 0x89, 0xfa, 0xb9, 0xb0, 0x19, 0xcc}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf3, 0x3f, 0xaa, 0x16, 0x41, 0x6b, 0xef, 0x3f, 0x57, 0xad}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8f, 0x6c, 0x9d, 0xd4, 0xa5, 0x8c, 0x3c, 0x2d, 0x22, 0xfa, 0xb9, 0xa6, 0x1, 0x70, - 0x42, 0x44, 0xd5, 0x35, 0x59, 0x33, 0xb2, 0x96, 0xba, 0xa, 0xbb, 0xc2, 0x25}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd, 0xfa, 0x10, 0x3c, 0x67, 0x95, 0xe0, 0x9f, 0x9f, 0x98, - 0xd3, 0x69, 0x87, 0xa3, 0x8e, 0x26, 0xa5, 0xdb, 0x19, 0x3a, - 0xf, 0x10, 0x36, 0x5b, 0xbb, 0x71, 0x21, 0x24}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x3, 0x53, 0xfb, 0x81, 0x85, 0x2c, 0xb7, 0xba, 0x3e, 0x27, 0x3f, 0xd2, 0xb6, - 0x99, 0xd7, 0xc6, 0xad, 0xce, 0x6b, 0xc9, 0x56, 0x6f, 0xb9, 0xec, 0xe5, 0xe5}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb0, 0xab, 0xdc, 0xcd, 0x2, 0x3e, 0xe3, 0x18, 0xef, 0xa7, - 0x4f, 0x45, 0x5a, 0x30, 0x73, 0xaa, 0x12, 0xa5, 0x42, 0x84, - 0x72, 0x86, 0x3f, 0xaa, 0x4c, 0xd8, 0xf6, 0xa2, 0x22, 0x88}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xd0, 0x5e, 0xa7, 0x44, 0x68, 0xf8, 0xb1, 0xab, 0x7e, 0x6b, 0xc, 0x86, 0x55, - 0x38, 0x20, 0xd8, 0xc6, 0xfc, 0x82, 0x1f, 0x7f, 0x2a, 0x4d, 0x71, 0x29, 0xba}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa4, 0x5b, 0x96, 0x9f, 0x6c, 0xf5, 0x61, 0xa9, 0x57, 0x5d, - 0x5, 0x3d, 0x44, 0xe6, 0x8f, 0xeb, 0xc1, 0xd7, 0xb7, 0x3a, - 0xd9, 0xf4, 0x4, 0xec, 0x18, 0xdd, 0x29, 0xd2}; - lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xbf, 0x58, 0xc6, 0xfc, 0x80, 0x3f, 0x53, 0x93, 0xd, 0x3e, - 0x4f, 0x8, 0x1a, 0xd7, 0x4c, 0xde, 0xef, 0xc9, 0x9d, 0x64, - 0x45, 0x68, 0xec, 0x12, 0xd6, 0x27, 0xba, 0xf3, 0x5c, 0xa1}; - lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 3283, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18211, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22892 -// ["\235\157\254\138\f\159\160H\226\159\167\206[L\221\133p\185;","/\162\192\a\217\171[\233\178\227GTN~\SOHzIl\DC3G\195C(FH\241=He\251","n\212\225g\136\SYNK\222\238\207\137","","\ETB7!\RSO\252\EM4B\253\DEL\USs}\246e\192\201\135\DC1\174","\183~\216m","\174K\216\SUB\179 -// \EMB\EMpq\EMl"] [] +// UnsubscribeRequest 14225 +// ["w9A\n=\f\239P\248iomV\246\230\219\f\234i\245,\136e","\200\&0&V\131\EM%\176\170R\209\166^<\170\200\220f\222\a\FSD",".2^.\242\r\198","\r\229\166\187f\244\188%\151\213W\198\150\a\f\201\245yH\193\137&9\246\209Ka\148\140\RS","\RSCb/b\143\151\172\STXL\167\129\186\142\252\160\218\NAK\155\134\EOT\191\247w","\206A\231S\173\254M9R\DC3\177$O\225d\222\175+\207\138FN\249\225\231\251"] +// [] TEST(Unsubscribe311QCTest, Encode27) { - uint8_t pkt[] = {0xa2, 0x72, 0x59, 0x6c, 0x0, 0x13, 0xeb, 0x9d, 0xfe, 0x8a, 0xc, 0x9f, 0xa0, 0x48, 0xe2, 0x9f, 0xa7, - 0xce, 0x5b, 0x4c, 0xdd, 0x85, 0x70, 0xb9, 0x3b, 0x0, 0x1e, 0x2f, 0xa2, 0xc0, 0x7, 0xd9, 0xab, 0x5b, - 0xe9, 0xb2, 0xe3, 0x47, 0x54, 0x4e, 0x7e, 0x1, 0x7a, 0x49, 0x6c, 0x13, 0x47, 0xc3, 0x43, 0x28, 0x46, - 0x48, 0xf1, 0x3d, 0x48, 0x65, 0xfb, 0x0, 0xb, 0x6e, 0xd4, 0xe1, 0x67, 0x88, 0x16, 0x4b, 0xde, 0xee, - 0xcf, 0x89, 0x0, 0x0, 0x0, 0x15, 0x17, 0x37, 0x21, 0x1e, 0x4f, 0xfc, 0x19, 0x34, 0x42, 0xfd, 0x7f, - 0x1f, 0x73, 0x7d, 0xf6, 0x65, 0xc0, 0xc9, 0x87, 0x11, 0xae, 0x0, 0x4, 0xb7, 0x7e, 0xd8, 0x6d, 0x0, - 0xd, 0xae, 0x4b, 0xd8, 0x1a, 0xb3, 0x20, 0x19, 0x42, 0x19, 0x70, 0x71, 0x19, 0x6c}; + uint8_t pkt[] = {0xa2, 0x92, 0x1, 0x37, 0x91, 0x0, 0x17, 0x77, 0x39, 0x41, 0xa, 0x3d, 0xc, 0xef, 0x50, 0xf8, 0x69, + 0x6f, 0x6d, 0x56, 0xf6, 0xe6, 0xdb, 0xc, 0xea, 0x69, 0xf5, 0x2c, 0x88, 0x65, 0x0, 0x16, 0xc8, 0x30, + 0x26, 0x56, 0x83, 0x19, 0x25, 0xb0, 0xaa, 0x52, 0xd1, 0xa6, 0x5e, 0x3c, 0xaa, 0xc8, 0xdc, 0x66, 0xde, + 0x7, 0x1c, 0x44, 0x0, 0x7, 0x2e, 0x32, 0x5e, 0x2e, 0xf2, 0xd, 0xc6, 0x0, 0x1e, 0xd, 0xe5, 0xa6, + 0xbb, 0x66, 0xf4, 0xbc, 0x25, 0x97, 0xd5, 0x57, 0xc6, 0x96, 0x7, 0xc, 0xc9, 0xf5, 0x79, 0x48, 0xc1, + 0x89, 0x26, 0x39, 0xf6, 0xd1, 0x4b, 0x61, 0x94, 0x8c, 0x1e, 0x0, 0x18, 0x1e, 0x43, 0x62, 0x2f, 0x62, + 0x8f, 0x97, 0xac, 0x2, 0x4c, 0xa7, 0x81, 0xba, 0x8e, 0xfc, 0xa0, 0xda, 0x15, 0x9b, 0x86, 0x4, 0xbf, + 0xf7, 0x77, 0x0, 0x1a, 0xce, 0x41, 0xe7, 0x53, 0xad, 0xfe, 0x4d, 0x39, 0x52, 0x13, 0xb1, 0x24, 0x4f, + 0xe1, 0x64, 0xde, 0xaf, 0x2b, 0xcf, 0x8a, 0x46, 0x4e, 0xf9, 0xe1, 0xe7, 0xfb}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xeb, 0x9d, 0xfe, 0x8a, 0xc, 0x9f, 0xa0, 0x48, 0xe2, 0x9f, - 0xa7, 0xce, 0x5b, 0x4c, 0xdd, 0x85, 0x70, 0xb9, 0x3b}; - lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x77, 0x39, 0x41, 0xa, 0x3d, 0xc, 0xef, 0x50, 0xf8, 0x69, 0x6f, 0x6d, + 0x56, 0xf6, 0xe6, 0xdb, 0xc, 0xea, 0x69, 0xf5, 0x2c, 0x88, 0x65}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2f, 0xa2, 0xc0, 0x7, 0xd9, 0xab, 0x5b, 0xe9, 0xb2, 0xe3, - 0x47, 0x54, 0x4e, 0x7e, 0x1, 0x7a, 0x49, 0x6c, 0x13, 0x47, - 0xc3, 0x43, 0x28, 0x46, 0x48, 0xf1, 0x3d, 0x48, 0x65, 0xfb}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc8, 0x30, 0x26, 0x56, 0x83, 0x19, 0x25, 0xb0, 0xaa, 0x52, 0xd1, + 0xa6, 0x5e, 0x3c, 0xaa, 0xc8, 0xdc, 0x66, 0xde, 0x7, 0x1c, 0x44}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6e, 0xd4, 0xe1, 0x67, 0x88, 0x16, 0x4b, 0xde, 0xee, 0xcf, 0x89}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2e, 0x32, 0x5e, 0x2e, 0xf2, 0xd, 0xc6}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd, 0xe5, 0xa6, 0xbb, 0x66, 0xf4, 0xbc, 0x25, 0x97, 0xd5, + 0x57, 0xc6, 0x96, 0x7, 0xc, 0xc9, 0xf5, 0x79, 0x48, 0xc1, + 0x89, 0x26, 0x39, 0xf6, 0xd1, 0x4b, 0x61, 0x94, 0x8c, 0x1e}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x17, 0x37, 0x21, 0x1e, 0x4f, 0xfc, 0x19, 0x34, 0x42, 0xfd, 0x7f, - 0x1f, 0x73, 0x7d, 0xf6, 0x65, 0xc0, 0xc9, 0x87, 0x11, 0xae}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x1e, 0x43, 0x62, 0x2f, 0x62, 0x8f, 0x97, 0xac, 0x2, 0x4c, 0xa7, 0x81, + 0xba, 0x8e, 0xfc, 0xa0, 0xda, 0x15, 0x9b, 0x86, 0x4, 0xbf, 0xf7, 0x77}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb7, 0x7e, 0xd8, 0x6d}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xce, 0x41, 0xe7, 0x53, 0xad, 0xfe, 0x4d, 0x39, 0x52, 0x13, 0xb1, 0x24, 0x4f, + 0xe1, 0x64, 0xde, 0xaf, 0x2b, 0xcf, 0x8a, 0x46, 0x4e, 0xf9, 0xe1, 0xe7, 0xfb}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xae, 0x4b, 0xd8, 0x1a, 0xb3, 0x20, 0x19, 0x42, 0x19, 0x70, 0x71, 0x19, 0x6c}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22892, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14225, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 19885 -// ["1PI\t\197=\237\156\210+\211\143\197F\237j\226K\DC1\ETB\231\195\ACK\162\148\247_\252\173","\t)\128a\GS\181\NUL\197\183{\205;m\230\199\US|l\166i\215'\180\129\184\186","\246D|d\241G\232+$\163\NAKm","\165","\r\189\ACK\138&\129\225V\220\215X\ESC\DLE<\192\150s\207","U\214xL\223\215.ob5\166\173wr\209\&1\167\&9\rJ\145\DC4\255","\DC3\215c\169\153\250\207@\186\242\r\"\183\129Q\RS\ETBbEj\160","L-\181*\192\&1}"] +// UnsubscribeRequest 19016 +// ["Jg\224\251\204?\245=","\241\203b\228\136\148R&\163\232S\US\233R","\202g\168\178\ENQ;\ETB\131\t!4\227\199.E\251","+\200\171{ZW\DC4\ACK\170 +// n\253\171=\157'_\155\tW\163\242\a\223","\224_L\250\174\189\ETB\170\156\243\NUL","#V\247\220\&3\202\129\146s\GS\244\149\158xi\231\149\242\DEL\148\172\159\210]\226\EMN","R\ACK\SOH9\148\244/","\153%\252\231\&9\254\131\161\180\161\151\"\239P!_\141T\EMsz\"0"] // [] TEST(Unsubscribe311QCTest, Encode28) { - uint8_t pkt[] = {0xa2, 0x9b, 0x1, 0x4d, 0xad, 0x0, 0x1d, 0x31, 0x50, 0x49, 0x9, 0xc5, 0x3d, 0xed, 0x9c, 0xd2, - 0x2b, 0xd3, 0x8f, 0xc5, 0x46, 0xed, 0x6a, 0xe2, 0x4b, 0x11, 0x17, 0xe7, 0xc3, 0x6, 0xa2, 0x94, - 0xf7, 0x5f, 0xfc, 0xad, 0x0, 0x1a, 0x9, 0x29, 0x80, 0x61, 0x1d, 0xb5, 0x0, 0xc5, 0xb7, 0x7b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 0xf2, 0x7, 0xdf, 0x0, 0xb, 0xe0, 0x5f, 0x4c, 0xfa, 0xae, 0xbd, 0x17, 0xaa, + 0x9c, 0xf3, 0x0, 0x0, 0x1b, 0x23, 0x56, 0xf7, 0xdc, 0x33, 0xca, 0x81, 0x92, 0x73, 0x1d, 0xf4, 0x95, + 0x9e, 0x78, 0x69, 0xe7, 0x95, 0xf2, 0x7f, 0x94, 0xac, 0x9f, 0xd2, 0x5d, 0xe2, 0x19, 0x4e, 0x0, 0x7, + 0x52, 0x6, 0x1, 0x39, 0x94, 0xf4, 0x2f, 0x0, 0x17, 0x99, 0x25, 0xfc, 0xe7, 0x39, 0xfe, 0x83, 0xa1, + 0xb4, 0xa1, 0x97, 0x22, 0xef, 0x50, 0x21, 0x5f, 0x8d, 0x54, 0x19, 0x73, 0x7a, 0x22, 0x30}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x31, 0x50, 0x49, 0x9, 0xc5, 0x3d, 0xed, 0x9c, 0xd2, 0x2b, - 0xd3, 0x8f, 0xc5, 0x46, 0xed, 0x6a, 0xe2, 0x4b, 0x11, 0x17, - 0xe7, 0xc3, 0x6, 0xa2, 0x94, 0xf7, 0x5f, 0xfc, 0xad}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x4a, 0x67, 0xe0, 0xfb, 0xcc, 0x3f, 0xf5, 0x3d}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9, 0x29, 0x80, 0x61, 0x1d, 0xb5, 0x0, 0xc5, 0xb7, 0x7b, 0xcd, 0x3b, 0x6d, - 0xe6, 0xc7, 0x1f, 0x7c, 0x6c, 0xa6, 0x69, 0xd7, 0x27, 0xb4, 0x81, 0xb8, 0xba}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf1, 0xcb, 0x62, 0xe4, 0x88, 0x94, 0x52, + 0x26, 0xa3, 0xe8, 0x53, 0x1f, 0xe9, 0x52}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf6, 0x44, 0x7c, 0x64, 0xf1, 0x47, 0xe8, 0x2b, 0x24, 0xa3, 0x15, 0x6d}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xca, 0x67, 0xa8, 0xb2, 0x5, 0x3b, 0x17, 0x83, + 0x9, 0x21, 0x34, 0xe3, 0xc7, 0x2e, 0x45, 0xfb}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa5}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x2b, 0xc8, 0xab, 0x7b, 0x5a, 0x57, 0x14, 0x6, 0xaa, 0x20, 0x6e, 0xfd, + 0xab, 0x3d, 0x9d, 0x27, 0x5f, 0x9b, 0x9, 0x57, 0xa3, 0xf2, 0x7, 0xdf}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd, 0xbd, 0x6, 0x8a, 0x26, 0x81, 0xe1, 0x56, 0xdc, - 0xd7, 0x58, 0x1b, 0x10, 0x3c, 0xc0, 0x96, 0x73, 0xcf}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xe0, 0x5f, 0x4c, 0xfa, 0xae, 0xbd, 0x17, 0xaa, 0x9c, 0xf3, 0x0}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x55, 0xd6, 0x78, 0x4c, 0xdf, 0xd7, 0x2e, 0x6f, 0x62, 0x35, 0xa6, 0xad, - 0x77, 0x72, 0xd1, 0x31, 0xa7, 0x39, 0xd, 0x4a, 0x91, 0x14, 0xff}; - lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x23, 0x56, 0xf7, 0xdc, 0x33, 0xca, 0x81, 0x92, 0x73, 0x1d, 0xf4, 0x95, 0x9e, 0x78, + 0x69, 0xe7, 0x95, 0xf2, 0x7f, 0x94, 0xac, 0x9f, 0xd2, 0x5d, 0xe2, 0x19, 0x4e}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x13, 0xd7, 0x63, 0xa9, 0x99, 0xfa, 0xcf, 0x40, 0xba, 0xf2, 0xd, - 0x22, 0xb7, 0x81, 0x51, 0x1e, 0x17, 0x62, 0x45, 0x6a, 0xa0}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x52, 0x6, 0x1, 0x39, 0x94, 0xf4, 0x2f}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x4c, 0x2d, 0xb5, 0x2a, 0xc0, 0x31, 0x7d}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x99, 0x25, 0xfc, 0xe7, 0x39, 0xfe, 0x83, 0xa1, 0xb4, 0xa1, 0x97, 0x22, + 0xef, 0x50, 0x21, 0x5f, 0x8d, 0x54, 0x19, 0x73, 0x7a, 0x22, 0x30}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19885, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19016, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 27189 -// ["\150\235'\154\141\134|\222\223]bA\223\139E\175+\178\158\176FT\218\DC4","\128\213\212b\169;\241\208\"!\167","\162\SO\SYN\164P(\US\SIR{\147\253k\235G\169;ZQ\NULH\DC3\DELP\SOH\222","F\229\157\217\ACK\155\rz\245\&8/\173G5\177\244S-8\150\198\194\&3\222)\209\STX","\191\143\241\237\222\157\191\187\142M}\207LC|\146","8\ENQ\229\241|Z^","*g\f\244dM\235\193*\177\&9\149\133\161","\168/\EOT\222\a^z\187\139\135","\167\206\130\&1\168\ETBH\200\241\221C\235\134Z9J\193\215v\237\131\197"] +// UnsubscribeRequest 24261 +// ["/\168j\253\190Jy7\185~F\236J","S\225\251?H\DC1\249\DC3\ETX\182\155[\CAN","}\EOT\136\245\&6b\203\202","9\222\252{E\t\SYNK5\162El\EOTA\171\&4\152\ESC","w\157\&9N\nW\242K\NUL\150a\166~\196\168\226\187\DEL\tU\186\218f\168","l\194\247\SOB\246P/\139","?fa\190\246c\DC2|/\206\SO\149\246\149Ar\153\174\EM\168\SOH\150\163\175\&3\236\191\ENQ\f\158","R$\140\171\234d\136\145\221\151\US8|3\254","\DLE\SI_\219/\178\128k\149\188\203\130J%\245\200P","\186\237'\227\&6\220\179\227\170\228\SOH?=\GS\DC3\224\204\166\tj\ESC|-s;\179",""] // [] TEST(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x1, 0x3f, 0x3d, 0x1d, 0x13, + 0xe0, 0xcc, 0xa6, 0x9, 0x6a, 0x1b, 0x7c, 0x2d, 0x73, 0x3b, 0xb3, 0x0, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x96, 0xeb, 0x27, 0x9a, 0x8d, 0x86, 0x7c, 0xde, 0xdf, 0x5d, 0x62, 0x41, - 0xdf, 0x8b, 0x45, 0xaf, 0x2b, 0xb2, 0x9e, 0xb0, 0x46, 0x54, 0xda, 0x14}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x2f, 0xa8, 0x6a, 0xfd, 0xbe, 0x4a, 0x79, 0x37, 0xb9, 0x7e, 0x46, 0xec, 0x4a}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x80, 0xd5, 0xd4, 0x62, 0xa9, 0x3b, 0xf1, 0xd0, 0x22, 0x21, 0xa7}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x53, 0xe1, 0xfb, 0x3f, 0x48, 0x11, 0xf9, 0x13, 0x3, 0xb6, 0x9b, 0x5b, 0x18}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa2, 0xe, 0x16, 0xa4, 0x50, 0x28, 0x1f, 0xf, 0x52, 0x7b, 0x93, 0xfd, 0x6b, - 0xeb, 0x47, 0xa9, 0x3b, 0x5a, 0x51, 0x0, 0x48, 0x13, 0x7f, 0x50, 0x1, 0xde}; - lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7d, 0x4, 0x88, 0xf5, 0x36, 0x62, 0xcb, 0xca}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x46, 0xe5, 0x9d, 0xd9, 0x6, 0x9b, 0xd, 0x7a, 0xf5, 0x38, 0x2f, 0xad, 0x47, 0x35, - 0xb1, 0xf4, 0x53, 0x2d, 0x38, 0x96, 0xc6, 0xc2, 0x33, 0xde, 0x29, 0xd1, 0x2}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x39, 0xde, 0xfc, 0x7b, 0x45, 0x9, 0x16, 0x4b, 0x35, + 0xa2, 0x45, 0x6c, 0x4, 0x41, 0xab, 0x34, 0x98, 0x1b}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xbf, 0x8f, 0xf1, 0xed, 0xde, 0x9d, 0xbf, 0xbb, - 0x8e, 0x4d, 0x7d, 0xcf, 0x4c, 0x43, 0x7c, 0x92}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x77, 0x9d, 0x39, 0x4e, 0xa, 0x57, 0xf2, 0x4b, 0x0, 0x96, 0x61, 0xa6, + 0x7e, 0xc4, 0xa8, 0xe2, 0xbb, 0x7f, 0x9, 0x55, 0xba, 0xda, 0x66, 0xa8}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x38, 0x5, 0xe5, 0xf1, 0x7c, 0x5a, 0x5e}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x6c, 0xc2, 0xf7, 0xe, 0x42, 0xf6, 0x50, 0x2f, 0x8b}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x2a, 0x67, 0xc, 0xf4, 0x64, 0x4d, 0xeb, 0xc1, 0x2a, 0xb1, 0x39, 0x95, 0x85, 0xa1}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x3f, 0x66, 0x61, 0xbe, 0xf6, 0x63, 0x12, 0x7c, 0x2f, 0xce, + 0xe, 0x95, 0xf6, 0x95, 0x41, 0x72, 0x99, 0xae, 0x19, 0xa8, + 0x1, 0x96, 0xa3, 0xaf, 0x33, 0xec, 0xbf, 0x5, 0xc, 0x9e}; + lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa8, 0x2f, 0x4, 0xde, 0x7, 0x5e, 0x7a, 0xbb, 0x8b, 0x87}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x52, 0x24, 0x8c, 0xab, 0xea, 0x64, 0x88, 0x91, + 0xdd, 0x97, 0x1f, 0x38, 0x7c, 0x33, 0xfe}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa7, 0xce, 0x82, 0x31, 0xa8, 0x17, 0x48, 0xc8, 0xf1, 0xdd, 0x43, - 0xeb, 0x86, 0x5a, 0x39, 0x4a, 0xc1, 0xd7, 0x76, 0xed, 0x83, 0xc5}; - lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x10, 0xf, 0x5f, 0xdb, 0x2f, 0xb2, 0x80, 0x6b, 0x95, + 0xbc, 0xcb, 0x82, 0x4a, 0x25, 0xf5, 0xc8, 0x50}; + lwmqtt_string_t topic_filter_s8 = {17, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xba, 0xed, 0x27, 0xe3, 0x36, 0xdc, 0xb3, 0xe3, 0xaa, 0xe4, 0x1, 0x3f, 0x3d, + 0x1d, 0x13, 0xe0, 0xcc, 0xa6, 0x9, 0x6a, 0x1b, 0x7c, 0x2d, 0x73, 0x3b, 0xb3}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27189, 9, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24261, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 10641 -// ["\195Sa\217\ACK\194\232\166\EOT\a\175\198\164\196r\252M\129\227\142\140","\191\&2\206V\211\208jL\223\162M\237i\241\128\DC1R\160UJ\195\175\194R\213","\213?\174\187\RS\DEL\245 -// \199\246\204","6\147z\129\248e\186\239\143\190\200\231\233\244\170(\225[\f\254\202\159-VJ\255Pp!","H\191\171\135\157){d~\181\190","\FSe\146\150\222","\DLE\228\196{\157hG\135~RV^\EOT5","\243\212\198\a\157\193\174\231\196\129N\182\137\243w"] -// [PropServerKeepAlive 13535,PropAuthenticationData "<\192\"U\244<+b\244a\231\234\231\130\\",PropContentType -// "\r\DC1\r=\224\191z/\185\144\133mB\208SC\CAN\196\r",PropSessionExpiryInterval 4234,PropSubscriptionIdentifier -// 31,PropServerKeepAlive 3176,PropMaximumQoS 31,PropResponseTopic -// "\249\GSFA\DLE\173)O\176\129\250\FS\152\196\230oF\227\224\143\164\150",PropTopicAliasMaximum -// 28456,PropResponseInformation -// "<\CAN\176\225\190\209\226\247!\254\218\EM\aVxr\139K\239b\191\147>\198\242",PropAuthenticationData -// "_I*\240\161\192\b\200\216by\191!\133z\222\DC3",PropAssignedClientIdentifier -// "\242\230\SO\142\DEL75(:x0}A\182",PropContentType "[\as$\141\171\166\204\162\176",PropCorrelationData -// "\EOTZ\EOT\151I",PropServerReference "1\EM\248",PropMessageExpiryInterval 32586,PropAuthenticationData -// "xN)\150$\231\157\177R1\171\184\138\216\223\212\134v\251\132",PropMessageExpiryInterval 1627,PropMaximumPacketSize -// 17000,PropAuthenticationMethod "j\199\131\140\249\228\198u\tG)\NUL\187i\176\172^\160\157\185\STX\STX\183\205\155"] +// UnsubscribeRequest 24378 ["\214\DC35\253\159\129F#\236\204y?\150\128\DC2u\230\211 +// O\133\185\r\135\163\177","\225\161,\196C\187\132IH\245\164\210!e\185\145e\139\243\181X8\n\242\182\204\151^\228","{\SUBC\158","\252\142\163gsP\ACK\133\234LY\203\&8\183\251\223\147\128\249","G}\173\207o\181\247\NULk\180\255\243\157o\SOH\199\NAKxD6","\220\ACK\170\&3)c\200`\251o\158"] +// [PropSharedSubscriptionAvailable 212,PropMaximumQoS 50,PropSharedSubscriptionAvailable 163,PropServerReference +// "\182\250",PropTopicAliasMaximum 21621,PropTopicAliasMaximum 5299,PropSharedSubscriptionAvailable +// 40,PropSubscriptionIdentifierAvailable 20,PropAssignedClientIdentifier "\221I\r\179\165\139lK\170\229\183H\241u"] TEST(Unsubscribe5QCTest, Encode1) { - uint8_t pkt[] = { - 0xa2, 0x8f, 0x3, 0x52, 0xd, 0xf1, 0x1, 0x13, 0x34, 0xdf, 0x16, 0x0, 0xf,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0x4, 0x35, 0x0, 0xf, 0xf3, 0xd4, 0xc6, 0x7, 0x9d, 0xc1, 0xae, 0xe7, 0xc4, 0x81, 0x4e, 0xb6, - 0x89, 0xf3, 0x77}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x3c, 0xc0, 0x22, 0x55, 0xf4, 0x3c, 0x2b, 0x62, 0xf4, 0x61, 0xe7, 0xea, 0xe7, 0x82, 0x5c}; - uint8_t bytesprops1[] = {0xd, 0x11, 0xd, 0x3d, 0xe0, 0xbf, 0x7a, 0x2f, 0xb9, 0x90, - 0x85, 0x6d, 0x42, 0xd0, 0x53, 0x43, 0x18, 0xc4, 0xd}; - uint8_t bytesprops2[] = {0xf9, 0x1d, 0x46, 0x41, 0x10, 0xad, 0x29, 0x4f, 0xb0, 0x81, 0xfa, - 0x1c, 0x98, 0xc4, 0xe6, 0x6f, 0x46, 0xe3, 0xe0, 0x8f, 0xa4, 0x96}; - uint8_t bytesprops3[] = {0x3c, 0x18, 0xb0, 0xe1, 0xbe, 0xd1, 0xe2, 0xf7, 0x21, 0xfe, 0xda, 0x19, 0x7, - 0x56, 0x78, 0x72, 0x8b, 0x4b, 0xef, 0x62, 0xbf, 0x93, 0x3e, 0xc6, 0xf2}; - uint8_t bytesprops4[] = {0x5f, 0x49, 0x2a, 0xf0, 0xa1, 0xc0, 0x8, 0xc8, 0xd8, - 0x62, 0x79, 0xbf, 0x21, 0x85, 0x7a, 0xde, 0x13}; - uint8_t bytesprops5[] = {0xf2, 0xe6, 0xe, 0x8e, 0x7f, 0x37, 0x35, 0x28, 0x3a, 0x78, 0x30, 0x7d, 0x41, 0xb6}; - uint8_t bytesprops6[] = {0x5b, 0x7, 0x73, 0x24, 0x8d, 0xab, 0xa6, 0xcc, 0xa2, 0xb0}; - uint8_t bytesprops7[] = {0x4, 0x5a, 0x4, 0x97, 0x49}; - uint8_t bytesprops8[] = {0x31, 0x19, 0xf8}; - uint8_t bytesprops9[] = {0x78, 0x4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f, + 0x6f, 0xb5, 0xf7, 0x0, 0x6b, 0xb4, 0xff, 0xf3, 0x9d, 0x6f, 0x1, 0xc7, 0x15, 0x78, 0x44, 0x36, 0x0, + 0xb, 0xdc, 0x6, 0xaa, 0x33, 0x29, 0x63, 0xc8, 0x60, 0xfb, 0x6f, 0x9e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb6, 0xfa}; + uint8_t bytesprops1[] = {0xdd, 0x49, 0xd, 0xb3, 0xa5, 0x8b, 0x6c, 0x4b, 0xaa, 0xe5, 0xb7, 0x48, 0xf1, 0x75}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13535}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4234}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 31}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3176}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28456}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32586}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1627}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17000}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21621}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5299}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xa2, 0x55, 0xe5, 0x51, 0xcb, 0x3a, 0x97, 0xd4, 0xd5, 0xaf, - 0x51, 0xa3, 0x7, 0xf0, 0xc2, 0xd3, 0x93, 0x31, 0xc4, 0xfb, - 0x1f, 0x8e, 0x9f, 0x3e, 0x81, 0xe3, 0x8e, 0x8c}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0xd6, 0x13, 0x35, 0xfd, 0x9f, 0x81, 0x46, 0x23, 0xec, 0xcc, 0x79, 0x3f, 0x96, + 0x80, 0x12, 0x75, 0xe6, 0xd3, 0x20, 0x4f, 0x85, 0xb9, 0xd, 0x87, 0xa3, 0xb1}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbf, 0x32, 0xce, 0x56, 0xd3, 0xd0, 0x6a, 0x4c, 0xdf, 0xa2, 0x4d, 0xed, 0x69, - 0xf1, 0x80, 0x11, 0x52, 0xa0, 0x55, 0x4a, 0xc3, 0xaf, 0xc2, 0x52, 0xd5}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe1, 0xa1, 0x2c, 0xc4, 0x43, 0xbb, 0x84, 0x49, 0x48, 0xf5, + 0xa4, 0xd2, 0x21, 0x65, 0xb9, 0x91, 0x65, 0x8b, 0xf3, 0xb5, + 0x58, 0x38, 0xa, 0xf2, 0xb6, 0xcc, 0x97, 0x5e, 0xe4}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd5, 0x3f, 0xae, 0xbb, 0x1e, 0x7f, 0xf5, 0x20, 0xc7, 0xf6, 0xcc}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7b, 0x1a, 0x43, 0x9e}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x36, 0x93, 0x7a, 0x81, 0xf8, 0x65, 0xba, 0xef, 0x8f, 0xbe, - 0xc8, 0xe7, 0xe9, 0xf4, 0xaa, 0x28, 0xe1, 0x5b, 0xc, 0xfe, - 0xca, 0x9f, 0x2d, 0x56, 0x4a, 0xff, 0x50, 0x70, 0x21}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xfc, 0x8e, 0xa3, 0x67, 0x73, 0x50, 0x6, 0x85, 0xea, 0x4c, + 0x59, 0xcb, 0x38, 0xb7, 0xfb, 0xdf, 0x93, 0x80, 0xf9}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x48, 0xbf, 0xab, 0x87, 0x9d, 0x29, 0x7b, 0x64, 0x7e, 0xb5, 0xbe}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x47, 0x7d, 0xad, 0xcf, 0x6f, 0xb5, 0xf7, 0x0, 0x6b, 0xb4, + 0xff, 0xf3, 0x9d, 0x6f, 0x1, 0xc7, 0x15, 0x78, 0x44, 0x36}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1c, 0x65, 0x92, 0x96, 0xde}; - lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xdc, 0x6, 0xaa, 0x33, 0x29, 0x63, 0xc8, 0x60, 0xfb, 0x6f, 0x9e}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x10, 0xe4, 0xc4, 0x7b, 0x9d, 0x68, 0x47, 0x87, 0x7e, 0x52, 0x56, 0x5e, 0x4, 0x35}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xf3, 0xd4, 0xc6, 0x7, 0x9d, 0xc1, 0xae, 0xe7, - 0xc4, 0x81, 0x4e, 0xb6, 0x89, 0xf3, 0x77}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21005, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24378, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 17284 -// ["\219\&6\208\245\251\252\ESC\222\a\175]6\SUB\EM\187\163\135\251R\141\188\250_~#\250\154\253'6","\209\"I\SOW",":/\181!v\193\177A\DC4\ACK\181\218\218*\183\248\233","^}\ETB\204n1\129\156\159\193Y\160\v","\222}^v\153\247\244\185\129\n\220Cy\SUB\ETX","\247\184r"] -// [PropTopicAliasMaximum 19254,PropSubscriptionIdentifierAvailable 208,PropSubscriptionIdentifierAvailable 223] +// UnsubscribeRequest 2051 +// ["","\193\252\EOT\NAK\244\187T\"A\224\181\EOT\232\248Q\175[\132*\231\160\&9cK\158\209wc1","A3\151\238\144\145\195:\165\&6R\SUB\239\198ypa\225\254\219\245\ETB\225\222e\GS","Q\EM\157\DC2\249\155h\249\139\&89)\243$\186u\190\135t\141\240\&7\164\246","\SUBTW","\132\180L","\212R\181Q4A7m,\SO\SYN\232I\181\207/\230\227\141\240l\SO\NUL&\148\157",PropMessageExpiryInterval 1519,PropServerKeepAlive -// 15506,PropRetainAvailable 132,PropReasonString "m\DEL\171\RS"] + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16794, 4, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 15779 +// ["q\143\179\SUB\203\191\213\177]\DC1\148S\175\ESC\200C5\NAK\246\167r\152\198\254\ETXI","jv\241\208\SUB\210","\183\192\222;F\253\246vU\179\SIO\222","\150T\145\198J\tp\138\137'\ESC\157"] +// [PropTopicAlias 20522,PropCorrelationData "\128\138\241\234\135\208\f\231\197\205",PropAssignedClientIdentifier +// "\202\US\242By\224\DC1_U\DC2j\212\215\182\220\\\254\250r\207\197\rS\195\154\ETB\195",PropPayloadFormatIndicator +// 13,PropAuthenticationData "{\165\180\226^\145G,5:\153I\154-I\228>L",PropMessageExpiryInterval +// 5120,PropSubscriptionIdentifierAvailable 159,PropSubscriptionIdentifierAvailable 44,PropRequestProblemInformation +// 81,PropRequestResponseInformation 129,PropResponseTopic "\186\169\233\FS\248\225v\NUL",PropTopicAlias +// 13028,PropSubscriptionIdentifierAvailable 36] TEST(Unsubscribe5QCTest, Encode4) { - uint8_t pkt[] = { - 0xa2, 0xa7, 0x2, 0x26, 0xa8, 0xec, 0x1, 0x2, 0x0, 0x0, 0x2f, 0x26, 0x9, 0x0, 0x1, 0xd0, 0x1a, 0x0, 0x1e, - 0x5a, 0x11, 0x26, 0xc0, 0x7d, 0x84, 0x9f, 0x69, 0x93, 0xcb, 0xdc, 0xca, 0xe4, 0x73, 0xda, 0x65, 0x4a, 0xd, 0x9e, - 0x4e, 0x8c, 0x35, 0xff, 0xce, 0x68, 0xbd, 0x9b, 0x73, 0xe1, 0x6a, 0x1f, 0x0, 0x16, 0x78, 0x5d, 0x45, 0x79, 0xd5, - 0x38, 0x9b, 0xbb, 0x68, 0xbb, 0x87, 0xf4, 0x9d, 0xa1, 0x73, 0x4c, 0xf2, 0x7c, 0x83, 0x7a, 0x73, 0x23, 0x25, 0xbd, - 0x26, 0x0, 0x4, 0x74, 0x22, 0x81, 0x7, 0x0, 0x18, 0x42, 0x30, 0xbd, 0x4f, 0xec, 0x21, 0xf6, 0x7f, 0x9a, 0x70, - 0xc1, 0x23, 0xc2, 0xe1, 0x8f, 0xfb, 0x90, 0x4e, 0x14, 0x7a, 0x63, 0xf5, 0x29, 0x6a, 0x19, 0x9f, 0x23, 0x73, 0xbd, - 0x28, 0xc8, 0x2, 0x0, 0x0, 0x66, 0xfe, 0x16, 0x0, 0xc, 0x4, 0x50, 0x34, 0x44, 0x77, 0x5c, 0x7b, 0x8b, 0x11, - 0xce, 0xee, 0xb9, 0x29, 0xcc, 0x28, 0xe8, 0x1c, 0x0, 0x14, 0xed, 0x4b, 0x8f, 0xf1, 0x2f, 0x7e, 0x69, 0xf7, 0xc5, - 0x8b, 0xbc, 0xae, 0xe8, 0x97, 0x43, 0xf4, 0xf0, 0xa7, 0xa2, 0x9e, 0x2, 0x0, 0x0, 0x6f, 0xe4, 0x19, 0xbf, 0x21, - 0xb, 0x98, 0x28, 0x7, 0x1, 0x6e, 0x16, 0x0, 0x11, 0xef, 0xe9, 0x16, 0x21, 0x24, 0x33, 0x5c, 0x3f, 0x52, 0x66, - 0x58, 0x88, 0x90, 0x82, 0xba, 0x33, 0xec, 0x29, 0x93, 0x2a, 0x37, 0x2, 0x0, 0x0, 0x28, 0x5a, 0x16, 0x0, 0x11, - 0x91, 0xd2, 0xf2, 0xc8, 0x82, 0x75, 0x3e, 0xe6, 0xe3, 0x8d, 0xf0, 0x6c, 0xe, 0x0, 0x26, 0x94, 0x9d, 0x2, 0x0, - 0x0, 0x5, 0xef, 0x13, 0x3c, 0x92, 0x25, 0x84, 0x1f, 0x0, 0x4, 0x6d, 0x7f, 0xab, 0x1e, 0x0, 0x8, 0x9, 0x42, - 0xae, 0xaf, 0x17, 0x8f, 0x20, 0xb, 0x0, 0x5, 0x5, 0x6d, 0x22, 0x6a, 0xf8, 0x0, 0xc, 0x57, 0x4b, 0xfa, 0xdf, - 0x0, 0x55, 0xcb, 0xf4, 0xc8, 0xac, 0x2a, 0x84, 0x0, 0x16, 0x1e, 0xf2, 0xba, 0xc7, 0x62, 0xe2, 0xc8, 0x4f, 0x52, - 0xb, 0x59, 0xb8, 0x23, 0x6e, 0xb7, 0xdd, 0xf2, 0x94, 0x62, 0x62, 0x1a, 0xb4}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd0}; - uint8_t bytesprops1[] = {0x5a, 0x11, 0x26, 0xc0, 0x7d, 0x84, 0x9f, 0x69, 0x93, 0xcb, 0xdc, 0xca, 0xe4, 0x73, 0xda, - 0x65, 0x4a, 0xd, 0x9e, 0x4e, 0x8c, 0x35, 0xff, 0xce, 0x68, 0xbd, 0x9b, 0x73, 0xe1, 0x6a}; - uint8_t bytesprops2[] = {0x78, 0x5d, 0x45, 0x79, 0xd5, 0x38, 0x9b, 0xbb, 0x68, 0xbb, 0x87, - 0xf4, 0x9d, 0xa1, 0x73, 0x4c, 0xf2, 0x7c, 0x83, 0x7a, 0x73, 0x23}; - uint8_t bytesprops4[] = {0x42, 0x30, 0xbd, 0x4f, 0xec, 0x21, 0xf6, 0x7f, 0x9a, 0x70, 0xc1, 0x23, - 0xc2, 0xe1, 0x8f, 0xfb, 0x90, 0x4e, 0x14, 0x7a, 0x63, 0xf5, 0x29, 0x6a}; - uint8_t bytesprops3[] = {0x74, 0x22, 0x81, 0x7}; - uint8_t bytesprops5[] = {0x4, 0x50, 0x34, 0x44, 0x77, 0x5c, 0x7b, 0x8b, 0x11, 0xce, 0xee, 0xb9}; - uint8_t bytesprops6[] = {0xed, 0x4b, 0x8f, 0xf1, 0x2f, 0x7e, 0x69, 0xf7, 0xc5, 0x8b, - 0xbc, 0xae, 0xe8, 0x97, 0x43, 0xf4, 0xf0, 0xa7, 0xa2, 0x9e}; - uint8_t bytesprops7[] = {0xef, 0xe9, 0x16, 0x21, 0x24, 0x33, 0x5c, 0x3f, 0x52, - 0x66, 0x58, 0x88, 0x90, 0x82, 0xba, 0x33, 0xec}; - uint8_t bytesprops8[] = {0x91, 0xd2, 0xf2, 0xc8, 0x82, 0x75, 0x3e, 0xe6, 0xe3, - 0x8d, 0xf0, 0x6c, 0xe, 0x0, 0x26, 0x94, 0x9d}; - uint8_t bytesprops9[] = {0x6d, 0x7f, 0xab, 0x1e}; + uint8_t pkt[] = {0xa2, 0xa6, 0x1, 0x3d, 0xa3, 0x62, 0x23, 0x50, 0x2a, 0x9, 0x0, 0xa, 0x80, 0x8a, 0xf1, 0xea, 0x87, + 0xd0, 0xc, 0xe7, 0xc5, 0xcd, 0x12, 0x0, 0x1b, 0xca, 0x1f, 0xf2, 0x42, 0x79, 0xe0, 0x11, 0x5f, 0x55, + 0x12, 0x6a, 0xd4, 0xd7, 0xb6, 0xdc, 0x5c, 0xfe, 0xfa, 0x72, 0xcf, 0xc5, 0xd, 0x53, 0xc3, 0x9a, 0x17, + 0xc3, 0x1, 0xd, 0x16, 0x0, 0x12, 0x7b, 0xa5, 0xb4, 0xe2, 0x5e, 0x91, 0x47, 0x2c, 0x35, 0x3a, 0x99, + 0x49, 0x9a, 0x2d, 0x49, 0xe4, 0x3e, 0x4c, 0x2, 0x0, 0x0, 0x14, 0x0, 0x29, 0x9f, 0x29, 0x2c, 0x17, + 0x51, 0x19, 0x81, 0x8, 0x0, 0x8, 0xba, 0xa9, 0xe9, 0x1c, 0xf8, 0xe1, 0x76, 0x0, 0x23, 0x32, 0xe4, + 0x29, 0x24, 0x0, 0x1a, 0x71, 0x8f, 0xb3, 0x1a, 0xcb, 0xbf, 0xd5, 0xb1, 0x5d, 0x11, 0x94, 0x53, 0xaf, + 0x1b, 0xc8, 0x43, 0x35, 0x15, 0xf6, 0xa7, 0x72, 0x98, 0xc6, 0xfe, 0x3, 0x49, 0x0, 0x6, 0x6a, 0x76, + 0xf1, 0xd0, 0x1a, 0xd2, 0x0, 0xd, 0xb7, 0xc0, 0xde, 0x3b, 0x46, 0xfd, 0xf6, 0x76, 0x55, 0xb3, 0xf, + 0x4f, 0xde, 0x0, 0xc, 0x96, 0x54, 0x91, 0xc6, 0x4a, 0x9, 0x70, 0x8a, 0x89, 0x27, 0x1b, 0x9d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x80, 0x8a, 0xf1, 0xea, 0x87, 0xd0, 0xc, 0xe7, 0xc5, 0xcd}; + uint8_t bytesprops1[] = {0xca, 0x1f, 0xf2, 0x42, 0x79, 0xe0, 0x11, 0x5f, 0x55, 0x12, 0x6a, 0xd4, 0xd7, 0xb6, + 0xdc, 0x5c, 0xfe, 0xfa, 0x72, 0xcf, 0xc5, 0xd, 0x53, 0xc3, 0x9a, 0x17, 0xc3}; + uint8_t bytesprops2[] = {0x7b, 0xa5, 0xb4, 0xe2, 0x5e, 0x91, 0x47, 0x2c, 0x35, + 0x3a, 0x99, 0x49, 0x9a, 0x2d, 0x49, 0xe4, 0x3e, 0x4c}; + uint8_t bytesprops3[] = {0xba, 0xa9, 0xe9, 0x1c, 0xf8, 0xe1, 0x76, 0x0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12070}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops3}, .v = {24, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29629}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26366}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28644}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2968}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10330}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1519}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15506}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20522}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5120}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13028}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 36}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x9, 0x42, 0xae, 0xaf, 0x17, 0x8f, 0x20, 0xb}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x71, 0x8f, 0xb3, 0x1a, 0xcb, 0xbf, 0xd5, 0xb1, 0x5d, 0x11, 0x94, 0x53, 0xaf, + 0x1b, 0xc8, 0x43, 0x35, 0x15, 0xf6, 0xa7, 0x72, 0x98, 0xc6, 0xfe, 0x3, 0x49}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5, 0x6d, 0x22, 0x6a, 0xf8}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6a, 0x76, 0xf1, 0xd0, 0x1a, 0xd2}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x57, 0x4b, 0xfa, 0xdf, 0x0, 0x55, 0xcb, 0xf4, 0xc8, 0xac, 0x2a, 0x84}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb7, 0xc0, 0xde, 0x3b, 0x46, 0xfd, 0xf6, 0x76, 0x55, 0xb3, 0xf, 0x4f, 0xde}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1e, 0xf2, 0xba, 0xc7, 0x62, 0xe2, 0xc8, 0x4f, 0x52, 0xb, 0x59, - 0xb8, 0x23, 0x6e, 0xb7, 0xdd, 0xf2, 0x94, 0x62, 0x62, 0x1a, 0xb4}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x96, 0x54, 0x91, 0xc6, 0x4a, 0x9, 0x70, 0x8a, 0x89, 0x27, 0x1b, 0x9d}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9896, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15779, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 9659 -// ["\253","\160\188","\246\207o\213\149\183l\132M\244\133\167\244B[\202","\DC4\197.\n\245\152<\170X\185\RS?8\177\237\152\ENQ\173\173\191\249\&8x\ESC\215\145\250","\158F\EOT.\ESC\EMp\SUB\218\&9P\172LJ\198"] -// [PropServerReference -// "&\166Q\248\184\225\194\133\145\vz\181\US\211\230{\249J\SI\136\252\246+\214\239\176",PropRequestResponseInformation -// 195,PropContentType -// "~\219\209i\147\SYN^L(\214\165w\243\214G\207!\DLE\236\219D'\210\199\184\\",PropMessageExpiryInterval -// 19808,PropMessageExpiryInterval 24445,PropAuthenticationMethod "",PropTopicAliasMaximum 4660,PropTopicAliasMaximum -// 13231,PropRetainAvailable 25,PropReceiveMaximum 26084] +// UnsubscribeRequest 2710 +// ["\192e\229>\239\247\184\209\158w\SI_X0T","E\243","\225\CAN*E8Q\t-\252B\136.\247\185\250","\144e\204Xj","\195?}\251*\158\210a,W\235\&3\249\219Z\143;","\239\251","","\170/\199\164\194\231\210\t\165(#\r\235i\151d\176QN\SUBX\249\195",",\176%\165\203\137\141\230K\EOT\SUBc\197\155N\202\195\t","5\129\227KZ\180\&7\DC4y^","n\227a\231\134C~\181\163^]\213\146"] +// [PropServerReference "\206\FS\243\193\158ik\ENQ\207^K\233{\227\&3%\222\"\167\217\206\163&\204qn\241",PropUserProperty +// "\150q\131t\134u" "\STXC\\\205J\192\134\241\&3\170",PropRetainAvailable 182,PropRequestProblemInformation +// 103,PropWildcardSubscriptionAvailable 20,PropContentType +// "\249/\251u\250\138\n\133\128\226y\222{\167\137Z\183F\198jaw\SYN\215\252\201L",PropSubscriptionIdentifierAvailable +// 208,PropRetainAvailable 195,PropResponseInformation "4|\179+&\161\148m>g\192'\162\ETXO_\153",PropResponseInformation +// "l\137",PropMessageExpiryInterval 14662,PropSharedSubscriptionAvailable 87,PropServerKeepAlive 31815,PropTopicAlias +// 858,PropReceiveMaximum 19278,PropSubscriptionIdentifierAvailable 48,PropWildcardSubscriptionAvailable +// 33,PropTopicAlias 30007,PropRequestResponseInformation 64,PropAssignedClientIdentifier +// "\190\249\131\132M\145\168\EOT\213\187\183T\155~\147\146",PropAuthenticationMethod +// "\NAK\132\215R\NUL\DC3\208):\SYNZT7#\163c\203\185\138-yrNV\173\146",PropSubscriptionIdentifierAvailable +// 116,PropReceiveMaximum 4013,PropUserProperty "\182U\129\228>/\214\254\204" +// "\161\241|B\202\190\r?a\236\128\n\181^\230@\219p",PropServerKeepAlive 22624,PropMessageExpiryInterval 5586] TEST(Unsubscribe5QCTest, Encode5) { - uint8_t pkt[] = {0xa2, 0x9e, 0x1, 0x25, 0xbb, 0x54, 0x1c, 0x0, 0x1a, 0x26, 0xa6, 0x51, 0xf8, 0xb8, 0xe1, 0xc2, 0x85, - 0x91, 0xb, 0x7a, 0xb5, 0x1f, 0xd3, 0xe6, 0x7b, 0xf9, 0x4a, 0xf, 0x88, 0xfc, 0xf6, 0x2b, 0xd6, 0xef, - 0xb0, 0x19, 0xc3, 0x3, 0x0, 0x1a, 0x7e, 0xdb, 0xd1, 0x69, 0x93, 0x16, 0x5e, 0x4c, 0x28, 0xd6, 0xa5, - 0x77, 0xf3, 0xd6, 0x47, 0xcf, 0x21, 0x10, 0xec, 0xdb, 0x44, 0x27, 0xd2, 0xc7, 0xb8, 0x5c, 0x2, 0x0, - 0x0, 0x4d, 0x60, 0x2, 0x0, 0x0, 0x5f, 0x7d, 0x15, 0x0, 0x0, 0x22, 0x12, 0x34, 0x22, 0x33, 0xaf, - 0x25, 0x19, 0x21, 0x65, 0xe4, 0x0, 0x1, 0xfd, 0x0, 0x2, 0xa0, 0xbc, 0x0, 0x10, 0xf6, 0xcf, 0x6f, - 0xd5, 0x95, 0xb7, 0x6c, 0x84, 0x4d, 0xf4, 0x85, 0xa7, 0xf4, 0x42, 0x5b, 0xca, 0x0, 0x1b, 0x14, 0xc5, - 0x2e, 0xa, 0xf5, 0x98, 0x3c, 0xaa, 0x58, 0xb9, 0x1e, 0x3f, 0x38, 0xb1, 0xed, 0x98, 0x5, 0xad, 0xad, - 0xbf, 0xf9, 0x38, 0x78, 0x1b, 0xd7, 0x91, 0xfa, 0x0, 0xf, 0x9e, 0x46, 0x4, 0x2e, 0x1b, 0x19, 0x70, - 0x1a, 0xda, 0x39, 0x50, 0xac, 0x4c, 0x4a, 0xc6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x26, 0xa6, 0x51, 0xf8, 0xb8, 0xe1, 0xc2, 0x85, 0x91, 0xb, 0x7a, 0xb5, 0x1f, - 0xd3, 0xe6, 0x7b, 0xf9, 0x4a, 0xf, 0x88, 0xfc, 0xf6, 0x2b, 0xd6, 0xef, 0xb0}; - uint8_t bytesprops1[] = {0x7e, 0xdb, 0xd1, 0x69, 0x93, 0x16, 0x5e, 0x4c, 0x28, 0xd6, 0xa5, 0x77, 0xf3, - 0xd6, 0x47, 0xcf, 0x21, 0x10, 0xec, 0xdb, 0x44, 0x27, 0xd2, 0xc7, 0xb8, 0x5c}; - uint8_t bytesprops2[] = {0}; + uint8_t pkt[] = { + 0xa2, 0xfc, 0x2, 0xa, 0x96, 0xea, 0x1, 0x1c, 0x0, 0x1b, 0xce, 0x1c, 0xf3, 0xc1, 0x9e, 0x69, 0x6b, 0x5, 0xcf, + 0x5e, 0x4b, 0xe9, 0x7b, 0xe3, 0x33, 0x25, 0xde, 0x22, 0xa7, 0xd9, 0xce, 0xa3, 0x26, 0xcc, 0x71, 0x6e, 0x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0x22, 0xa7, 0xd9, 0xce, 0xa3, 0x26, 0xcc, 0x71, 0x6e, 0xf1}; + uint8_t bytesprops2[] = {0x2, 0x43, 0x5c, 0xcd, 0x4a, 0xc0, 0x86, 0xf1, 0x33, 0xaa}; + uint8_t bytesprops1[] = {0x96, 0x71, 0x83, 0x74, 0x86, 0x75}; + uint8_t bytesprops3[] = {0xf9, 0x2f, 0xfb, 0x75, 0xfa, 0x8a, 0xa, 0x85, 0x80, 0xe2, 0x79, 0xde, 0x7b, 0xa7, + 0x89, 0x5a, 0xb7, 0x46, 0xc6, 0x6a, 0x61, 0x77, 0x16, 0xd7, 0xfc, 0xc9, 0x4c}; + uint8_t bytesprops4[] = {0x34, 0x7c, 0xb3, 0x2b, 0x26, 0xa1, 0x94, 0x6d, 0x3e, + 0x67, 0xc0, 0x27, 0xa2, 0x3, 0x4f, 0x5f, 0x99}; + uint8_t bytesprops5[] = {0x6c, 0x89}; + uint8_t bytesprops6[] = {0xbe, 0xf9, 0x83, 0x84, 0x4d, 0x91, 0xa8, 0x4, + 0xd5, 0xbb, 0xb7, 0x54, 0x9b, 0x7e, 0x93, 0x92}; + uint8_t bytesprops7[] = {0x15, 0x84, 0xd7, 0x52, 0x0, 0x13, 0xd0, 0x29, 0x3a, 0x16, 0x5a, 0x54, 0x37, + 0x23, 0xa3, 0x63, 0xcb, 0xb9, 0x8a, 0x2d, 0x79, 0x72, 0x4e, 0x56, 0xad, 0x92}; + uint8_t bytesprops9[] = {0xa1, 0xf1, 0x7c, 0x42, 0xca, 0xbe, 0xd, 0x3f, 0x61, + 0xec, 0x80, 0xa, 0xb5, 0x5e, 0xe6, 0x40, 0xdb, 0x70}; + uint8_t bytesprops8[] = {0xb6, 0x55, 0x81, 0xe4, 0x3e, 0x2f, 0xd6, 0xfe, 0xcc}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19808}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24445}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4660}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13231}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26084}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {10, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 208}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14662}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31815}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 858}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19278}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 48}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30007}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4013}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops8}, .v = {18, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22624}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5586}}, }; - lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xfd}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xc0, 0x65, 0xe5, 0x3e, 0xef, 0xf7, 0xb8, 0xd1, + 0x9e, 0x77, 0xf, 0x5f, 0x58, 0x30, 0x54}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa0, 0xbc}; + uint8_t topic_filter_s1_bytes[] = {0x45, 0xf3}; lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf6, 0xcf, 0x6f, 0xd5, 0x95, 0xb7, 0x6c, 0x84, - 0x4d, 0xf4, 0x85, 0xa7, 0xf4, 0x42, 0x5b, 0xca}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe1, 0x18, 0x2a, 0x45, 0x38, 0x51, 0x9, 0x2d, + 0xfc, 0x42, 0x88, 0x2e, 0xf7, 0xb9, 0xfa}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x14, 0xc5, 0x2e, 0xa, 0xf5, 0x98, 0x3c, 0xaa, 0x58, 0xb9, 0x1e, 0x3f, 0x38, 0xb1, - 0xed, 0x98, 0x5, 0xad, 0xad, 0xbf, 0xf9, 0x38, 0x78, 0x1b, 0xd7, 0x91, 0xfa}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x90, 0x65, 0xcc, 0x58, 0x6a}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9e, 0x46, 0x4, 0x2e, 0x1b, 0x19, 0x70, 0x1a, - 0xda, 0x39, 0x50, 0xac, 0x4c, 0x4a, 0xc6}; - lwmqtt_string_t topic_filter_s4 = {15, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc3, 0x3f, 0x7d, 0xfb, 0x2a, 0x9e, 0xd2, 0x61, 0x2c, + 0x57, 0xeb, 0x33, 0xf9, 0xdb, 0x5a, 0x8f, 0x3b}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xef, 0xfb}; + lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xaa, 0x2f, 0xc7, 0xa4, 0xc2, 0xe7, 0xd2, 0x9, 0xa5, 0x28, 0x23, 0xd, + 0xeb, 0x69, 0x97, 0x64, 0xb0, 0x51, 0x4e, 0x1a, 0x58, 0xf9, 0xc3}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x2c, 0xb0, 0x25, 0xa5, 0xcb, 0x89, 0x8d, 0xe6, 0x4b, + 0x4, 0x1a, 0x63, 0xc5, 0x9b, 0x4e, 0xca, 0xc3, 0x9}; + lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x35, 0x81, 0xe3, 0x4b, 0x5a, 0xb4, 0x37, 0x14, 0x79, 0x5e}; + lwmqtt_string_t topic_filter_s9 = {10, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x6e, 0xe3, 0x61, 0xe7, 0x86, 0x43, 0x7e, 0xb5, 0xa3, 0x5e, 0x5d, 0xd5, 0x92}; + lwmqtt_string_t topic_filter_s10 = {13, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9659, 5, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2710, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5752 -// ["\a\tr\STXO4\140\DC2\166\&9\DC2\n\233","G\196\155\t.\170\213Y\229_\218\226k\NAKIi\229\145\SI\234","M!\NUL\223\224\185\128\215\200\186\241f\221vD\173\tW\162\EOT\200\&4!\n\160","Wu\227\181\230\224\215}\250\227\167\RS\140QIPk\192\135\b\STX\180\186\147\135U\174\155"] -// [PropMaximumPacketSize 16593,PropMaximumQoS 135,PropMaximumQoS 76,PropResponseInformation -// "\134G\164\193cR\ETB\EMM\133\183%p\171HS\141\206\&7\206\248",PropServerKeepAlive 21530,PropTopicAlias -// 19135,PropRequestProblemInformation 183,PropReasonString "\166\148",PropResponseInformation -// "\NAKB\DC4\180\138h\SYN\ETB\142\186t1",PropAuthenticationData -// "\164\227\163\137\155\163\163\251\SI\211\207jX\NULO\245\\\206B\239",PropSessionExpiryInterval -// 26346,PropMessageExpiryInterval 10899,PropServerKeepAlive 21711,PropResponseInformation -// "+\174|\191\229\228\222ayU\250\221\254\216\232\&6\243\155B\231\180\EM\DC3\255",PropAuthenticationData -// "\222\202\&8\239\206\ETXx^",PropRetainAvailable 213,PropRequestProblemInformation 196,PropResponseTopic -// "+G\226\177\&6\133;\128`\130\142\243\159\137DKr\181\148\132\198",PropWillDelayInterval -// 6318,PropRequestProblemInformation 19] +// UnsubscribeRequest 5130 +// ["\246\197\169\&5\b\231f\149\170\236\240\171d\142Uq\241\RS\138\&2\222\160F\162\243\176NN\249\208","\STXt(\EM\234#}\242B~\248","","\166\"\128\192\131x\151\250\FS\RS\150\175n~CD0apa[B\212\163",PropRequestResponseInformation 73,PropServerReference +// "\220!\196\255v\205\238\246",PropWillDelayInterval 18917,PropRequestProblemInformation 227,PropAuthenticationMethod +// "\180 \156\EOT\165\ENQ\DC4\173\231\ENQ\DEL\fNsC\148\163\241\221\207\CAN\SOH\209",PropResponseTopic +// "'m\175\213\RSS\131\133F\133+%L;\138M\224",PropSharedSubscriptionAvailable 118,PropResponseInformation +// "\GS/\236\200\FSS\217\210\EM\154\224\217",PropContentType "\252\a\228\NULL<\RS\223\r\186\137\191\253\200\183\ACK"] TEST(Unsubscribe5QCTest, Encode6) { - uint8_t pkt[] = {0xa2, 0x8c, 0x2, 0x16, 0x78, 0xaa, 0x1, 0x27, 0x0, 0x0, 0x40, 0xd1, 0x24, 0x87, 0x24, 0x4c, 0x1a, - 0x0, 0x15, 0x86, 0x47, 0x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, 0xe5, 0x91, 0xf, 0xea, 0x0, 0x19, 0x4d, 0x21, 0x0, 0xdf, 0xe0, - 0xb9, 0x80, 0xd7, 0xc8, 0xba, 0xf1, 0x66, 0xdd, 0x76, 0x44, 0xad, 0x9, 0x57, 0xa2, 0x4, 0xc8, 0x34, - 0x21, 0xa, 0xa0, 0x0, 0x1c, 0x57, 0x75, 0xe3, 0xb5, 0xe6, 0xe0, 0xd7, 0x7d, 0xfa, 0xe3, 0xa7, 0x1e, - 0x8c, 0x51, 0x49, 0x50, 0x6b, 0xc0, 0x87, 0x8, 0x2, 0xb4, 0xba, 0x93, 0x87, 0x55, 0xae, 0x9b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x86, 0x47, 0xa4, 0xc1, 0x63, 0x52, 0x17, 0x19, 0x4d, 0x85, 0xb7, - 0x25, 0x70, 0xab, 0x48, 0x53, 0x8d, 0xce, 0x37, 0xce, 0xf8}; - uint8_t bytesprops1[] = {0xa6, 0x94}; - uint8_t bytesprops2[] = {0x15, 0x42, 0x14, 0xb4, 0x8a, 0x68, 0x16, 0x17, 0x8e, 0xba, 0x74, 0x31}; - uint8_t bytesprops3[] = {0xa4, 0xe3, 0xa3, 0x89, 0x9b, 0xa3, 0xa3, 0xfb, 0xf, 0xd3, - 0xcf, 0x6a, 0x58, 0x0, 0x4f, 0xf5, 0x5c, 0xce, 0x42, 0xef}; - uint8_t bytesprops4[] = {0x2b, 0xae, 0x7c, 0xbf, 0xe5, 0xe4, 0xde, 0x61, 0x79, 0x55, 0xfa, 0xdd, - 0xfe, 0xd8, 0xe8, 0x36, 0xf3, 0x9b, 0x42, 0xe7, 0xb4, 0x19, 0x13, 0xff}; - uint8_t bytesprops5[] = {0xde, 0xca, 0x38, 0xef, 0xce, 0x3, 0x78, 0x5e}; - uint8_t bytesprops6[] = {0x2b, 0x47, 0xe2, 0xb1, 0x36, 0x85, 0x3b, 0x80, 0x60, 0x82, 0x8e, - 0xf3, 0x9f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kt) + 10] = {0}; + uint8_t bytesprops0[] = {0xd, 0x59, 0x61, 0x34, 0xc6, 0xac, 0x1b, 0x7d, 0x5, 0xdc, 0xed, 0x23}; + uint8_t bytesprops1[] = {0x6f, 0xd0, 0xda, 0xdf, 0x64, 0x3a, 0xe3, 0x67, 0x8e, 0xb6, 0xc7, 0xba, 0x43, + 0x11, 0x14, 0x6b, 0xd4, 0xe, 0x67, 0x20, 0xd2, 0x4f, 0xe2, 0xd, 0x31, 0x94}; + uint8_t bytesprops2[] = {0xb5, 0x15, 0x80, 0xe2}; + uint8_t bytesprops3[] = {0x46, 0x2d, 0xf, 0xb9, 0xf3, 0x17, 0xf2, 0x55, 0xfe}; + uint8_t bytesprops4[] = {0x75}; + uint8_t bytesprops5[] = {0x32, 0xf2, 0x3e, 0x97, 0xfa, 0x1c, 0x1e, 0x96, 0xaf, 0x6e, 0x7e, + 0x43, 0x44, 0x30, 0x61, 0x70, 0x61, 0x5b, 0x42, 0xd4, 0xa3}; + uint8_t bytesprops6[] = {0xdc, 0x21, 0xc4, 0xff, 0x76, 0xcd, 0xee, 0xf6}; + uint8_t bytesprops7[] = {0xb4, 0x20, 0x9c, 0x4, 0xa5, 0x5, 0x14, 0xad, 0xe7, 0x5, 0x7f, 0xc, + 0x4e, 0x73, 0x43, 0x94, 0xa3, 0xf1, 0xdd, 0xcf, 0x18, 0x1, 0xd1}; + uint8_t bytesprops8[] = {0x27, 0x6d, 0xaf, 0xd5, 0x1e, 0x53, 0x83, 0x85, 0x46, + 0x85, 0x2b, 0x25, 0x4c, 0x3b, 0x8a, 0x4d, 0xe0}; + uint8_t bytesprops9[] = {0x1d, 0x2f, 0xec, 0xc8, 0x1c, 0x53, 0xd9, 0xd2, 0x19, 0x9a, 0xe0, 0xd9}; + uint8_t bytesprops10[] = {0xfc, 0x7, 0xe4, 0x0, 0x4c, 0x3c, 0x1e, 0xdf, 0xd, 0xba, 0x89, 0xbf, 0xfd, 0xc8, 0xb7, 0x6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16593}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21530}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19135}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26346}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10899}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21711}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6318}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18401}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11451}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26947}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18917}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x7, 0x9, 0x72, 0x2, 0x4f, 0x34, 0x8c, 0x12, 0xa6, 0x39, 0x12, 0xa, 0xe9}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xf6, 0xc5, 0xa9, 0x35, 0x8, 0xe7, 0x66, 0x95, 0xaa, 0xec, + 0xf0, 0xab, 0x64, 0x8e, 0x55, 0x71, 0xf1, 0x1e, 0x8a, 0x32, + 0xde, 0xa0, 0x46, 0xa2, 0xf3, 0xb0, 0x4e, 0x4e, 0xf9, 0xd0}; + lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x47, 0xc4, 0x9b, 0x9, 0x2e, 0xaa, 0xd5, 0x59, 0xe5, 0x5f, - 0xda, 0xe2, 0x6b, 0x15, 0x49, 0x69, 0xe5, 0x91, 0xf, 0xea}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2, 0x74, 0x28, 0x19, 0xea, 0x23, 0x7d, 0xf2, 0x42, 0x7e, 0xf8}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4d, 0x21, 0x0, 0xdf, 0xe0, 0xb9, 0x80, 0xd7, 0xc8, 0xba, 0xf1, 0x66, 0xdd, - 0x76, 0x44, 0xad, 0x9, 0x57, 0xa2, 0x4, 0xc8, 0x34, 0x21, 0xa, 0xa0}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x57, 0x75, 0xe3, 0xb5, 0xe6, 0xe0, 0xd7, 0x7d, 0xfa, 0xe3, - 0xa7, 0x1e, 0x8c, 0x51, 0x49, 0x50, 0x6b, 0xc0, 0x87, 0x8, - 0x2, 0xb4, 0xba, 0x93, 0x87, 0x55, 0xae, 0x9b}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa6, 0x22, 0x80, 0xc0, 0x83, 0x78, 0x3c, 0x50, 0x74, 0xb0, + 0x42, 0x53, 0x9e, 0x44, 0xb, 0x18, 0x81, 0x98, 0x38}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xfb, 0xb5, 0xb2, 0xc9, 0x93, 0xb0, 0x6e, 0x73, 0x70, 0x9a, + 0xb, 0x93, 0x41, 0x31, 0x61, 0xbe, 0xd0, 0x15, 0xde}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x3c, 0x7, 0x51, 0xc8, 0xee, 0x22, 0x84, 0x70, 0x76, 0x2a, 0xca, 0x8f}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x4d, 0xc8, 0xc8, 0x5a, 0x8b, 0xee}; + lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x91, 0x8f, 0xc0, 0x54, 0x62, 0x28, 0x2d, 0x79, 0xb8, 0xfc, + 0x59, 0x71, 0x40, 0x4a, 0x5f, 0xa, 0xc9, 0x72, 0x45}; + lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5752, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5130, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 26590 -// ["\"\128\&3`Z\154EIF","\191\216\128<6\157\128\f\207\159&h\207O\235|\169g\r\DC4\137\DC3\175\176\&3\201EN\NAK","\130{\210H\187 -// \219q\251wl\247&\nJ$\185\DLE\158\179","\167\NUL\ETX\172\207gd3\251C\170\SIM\239\157O\233\224-\251e-\224\148\188","\184\NAK\198\&2\137\SI:\164\DC3\SYN(#\174\242\179\138<\206\157\US","\222\SO=\194\210\132u\185\192\r5\181","O\231\246\135\209\137","B>\250\193\SOL\212\170\245\168)\237\134\187\204\232*+\218\EM7\r\142\EOTb\221\152l\148"] -// [PropAuthenticationMethod "\146\176\246\146F&~y",PropReceiveMaximum 11903,PropServerKeepAlive -// 30316,PropTopicAliasMaximum 20575,PropSharedSubscriptionAvailable 19,PropSubscriptionIdentifierAvailable -// 238,PropResponseTopic -// "\185X\250\vG>,\222YWiQ5\207\238\DC4\t\223\181~d\143G\233ZP\213\DC3\234",PropAssignedClientIdentifier -// "@f:\SUB6\186\ETX*f\231}\133\150\b\DC1\171\136\204\255\197\ENQFE\f\179<\ESC\250",PropSharedSubscriptionAvailable -// 42,PropRequestResponseInformation 231,PropPayloadFormatIndicator 28,PropAuthenticationMethod -// "\202e\133\&0\206\235W\195\132\250]\238",PropRequestProblemInformation 213,PropReceiveMaximum 11947] +// UnsubscribeRequest 10000 +// ["\FS\130\191W5L\182\156$\165\150tm\255l\234\202\179\208>\219\194\231\DELs\163","\188\202\DLE\SO\251z!\203\ETB\156.Mu\241\151","s\132\130\222\fE\142T\128\&3\v\230\218\&2\210_G6\128\220\251\STX","\t\171%#\219\251\SOH}\175@O\169","1d\CAN\f\SOH\183\253%F*","\195f\ry\161\STX\235\147\NAK\\\189\168","\SUBq;\RS\183\209\228z\166\187\217\155\EM\133[\133:\252\148\SYN","\207\ETB\179"] +// [PropRequestResponseInformation 152,PropResponseInformation "\231x\165\\\183hU\131\196\GS\STXo\DC2<\203t\168z\155"] TEST(Unsubscribe5QCTest, Encode7) { - uint8_t pkt[] = { - 0xa2, 0x9a, 0x2, 0x67, 0xde, 0x71, 0x15, 0x0, 0x8, 0x92, 0xb0, 0xf6, 0x92, 0x46, 0x26, 0x7e, 0x79, 0x21, 0x2e, - 0x7f, 0x13, 0x76, 0x6c, 0x22, 0x50, 0x5f, 0x2a, 0x13, 0x29, 0xee, 0x8, 0x0, 0x1d, 0xb9, 0x58, 0xfa, 0xb, 0x47, - 0x3e, 0x2c, 0xde, 0x59, 0x57, 0x69, 0x51, 0x35, 0xcf, 0xee, 0x14, 0x9, 0xdf, 0xb5, 0x7e, 0x64, 0x8f, 0x47, 0xe9, - 0x5a, 0x50, 0xd5, 0x13, 0xea, 0x12, 0x0, 0x1c, 0x40, 0x66, 0x3a, 0x1a, 0x36, 0xba, 0x3, 0x2a, 0x66, 0xe7, 0x7d, - 0x85, 0x96, 0x8, 0x11, 0xab, 0x88, 0xcc, 0xff, 0xc5, 0x5, 0x46, 0x45, 0xc, 0xb3, 0x3c, 0x1b, 0xfa, 0x2a, 0x2a, - 0x19, 0xe7, 0x1, 0x1c, 0x15, 0x0, 0xc, 0xca, 0x65, 0x85, 0x30, 0xce, 0xeb, 0x57, 0xc3, 0x84, 0xfa, 0x5d, 0xee, - 0x17, 0xd5, 0x21, 0x2e, 0xab, 0x0, 0x9, 0x22, 0x80, 0x33, 0x60, 0x5a, 0x9a, 0x45, 0x49, 0x46, 0x0, 0x1d, 0xbf, - 0xd8, 0x80, 0x3c, 0x36, 0x9d, 0x80, 0xc, 0xcf, 0x9f, 0x26, 0x68, 0xcf, 0x4f, 0xeb, 0x7c, 0xa9, 0x67, 0xd, 0x14, - 0x89, 0x13, 0xaf, 0xb0, 0x33, 0xc9, 0x45, 0x4e, 0x15, 0x0, 0x14, 0x82, 0x7b, 0xd2, 0x48, 0xbb, 0x20, 0xdb, 0x71, - 0xfb, 0x77, 0x6c, 0xf7, 0x26, 0xa, 0x4a, 0x24, 0xb9, 0x10, 0x9e, 0xb3, 0x0, 0x19, 0xa7, 0x0, 0x3, 0xac, 0xcf, - 0x67, 0x64, 0x33, 0xfb, 0x43, 0xaa, 0xf, 0x4d, 0xef, 0x9d, 0x4f, 0xe9, 0xe0, 0x2d, 0xfb, 0x65, 0x2d, 0xe0, 0x94, - 0xbc, 0x0, 0x14, 0xb8, 0x15, 0xc6, 0x32, 0x89, 0xf, 0x3a, 0xa4, 0x13, 0x16, 0x28, 0x23, 0xae, 0xf2, 0xb3, 0x8a, - 0x3c, 0xce, 0x9d, 0x1f, 0x0, 0xc, 0xde, 0xe, 0x3d, 0xc2, 0xd2, 0x84, 0x75, 0xb9, 0xc0, 0xd, 0x35, 0xb5, 0x0, - 0x6, 0x4f, 0xe7, 0xf6, 0x87, 0xd1, 0x89, 0x0, 0x1d, 0x42, 0x3e, 0xfa, 0xc1, 0xe, 0x4c, 0xd4, 0xaa, 0xf5, 0xa8, - 0x29, 0xed, 0x86, 0xbb, 0xcc, 0xe8, 0x2a, 0x2b, 0xda, 0x19, 0x37, 0xd, 0x8e, 0x4, 0x62, 0xdd, 0x98, 0x6c, 0x94}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x92, 0xb0, 0xf6, 0x92, 0x46, 0x26, 0x7e, 0x79}; - uint8_t bytesprops1[] = {0xb9, 0x58, 0xfa, 0xb, 0x47, 0x3e, 0x2c, 0xde, 0x59, 0x57, 0x69, 0x51, 0x35, 0xcf, 0xee, - 0x14, 0x9, 0xdf, 0xb5, 0x7e, 0x64, 0x8f, 0x47, 0xe9, 0x5a, 0x50, 0xd5, 0x13, 0xea}; - uint8_t bytesprops2[] = {0x40, 0x66, 0x3a, 0x1a, 0x36, 0xba, 0x3, 0x2a, 0x66, 0xe7, 0x7d, 0x85, 0x96, 0x8, - 0x11, 0xab, 0x88, 0xcc, 0xff, 0xc5, 0x5, 0x46, 0x45, 0xc, 0xb3, 0x3c, 0x1b, 0xfa}; - uint8_t bytesprops3[] = {0xca, 0x65, 0x85, 0x30, 0xce, 0xeb, 0x57, 0xc3, 0x84, 0xfa, 0x5d, 0xee}; + uint8_t pkt[] = {0xa2, 0xa3, 0x1, 0x27, 0x10, 0x18, 0x19, 0x98, 0x1a, 0x0, 0x13, 0xe7, 0x78, 0xa5, 0x5c, 0xb7, 0x68, + 0x55, 0x83, 0xc4, 0x1d, 0x2, 0x6f, 0x12, 0x3c, 0xcb, 0x74, 0xa8, 0x7a, 0x9b, 0x0, 0x1a, 0x1c, 0x82, + 0xbf, 0x57, 0x35, 0x4c, 0xb6, 0x9c, 0x24, 0xa5, 0x96, 0x74, 0x6d, 0xff, 0x6c, 0xea, 0xca, 0xb3, 0xd0, + 0x3e, 0xdb, 0xc2, 0xe7, 0x7f, 0x73, 0xa3, 0x0, 0xf, 0xbc, 0xca, 0x10, 0xe, 0xfb, 0x7a, 0x21, 0xcb, + 0x17, 0x9c, 0x2e, 0x4d, 0x75, 0xf1, 0x97, 0x0, 0x16, 0x73, 0x84, 0x82, 0xde, 0xc, 0x45, 0x8e, 0x54, + 0x80, 0x33, 0xb, 0xe6, 0xda, 0x32, 0xd2, 0x5f, 0x47, 0x36, 0x80, 0xdc, 0xfb, 0x2, 0x0, 0xc, 0x9, + 0xab, 0x25, 0x23, 0xdb, 0xfb, 0x1, 0x7d, 0xaf, 0x40, 0x4f, 0xa9, 0x0, 0xa, 0x31, 0x64, 0x18, 0xc, + 0x1, 0xb7, 0xfd, 0x25, 0x46, 0x2a, 0x0, 0xc, 0xc3, 0x66, 0xd, 0x79, 0xa1, 0x2, 0xeb, 0x93, 0x15, + 0x5c, 0xbd, 0xa8, 0x0, 0x14, 0x1a, 0x71, 0x3b, 0x1e, 0xb7, 0xd1, 0xe4, 0x7a, 0xa6, 0xbb, 0xd9, 0x9b, + 0x19, 0x85, 0x5b, 0x85, 0x3a, 0xfc, 0x94, 0x16, 0x0, 0x3, 0xcf, 0x17, 0xb3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe7, 0x78, 0xa5, 0x5c, 0xb7, 0x68, 0x55, 0x83, 0xc4, 0x1d, + 0x2, 0x6f, 0x12, 0x3c, 0xcb, 0x74, 0xa8, 0x7a, 0x9b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11903}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30316}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20575}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11947}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x22, 0x80, 0x33, 0x60, 0x5a, 0x9a, 0x45, 0x49, 0x46}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x1c, 0x82, 0xbf, 0x57, 0x35, 0x4c, 0xb6, 0x9c, 0x24, 0xa5, 0x96, 0x74, 0x6d, + 0xff, 0x6c, 0xea, 0xca, 0xb3, 0xd0, 0x3e, 0xdb, 0xc2, 0xe7, 0x7f, 0x73, 0xa3}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbf, 0xd8, 0x80, 0x3c, 0x36, 0x9d, 0x80, 0xc, 0xcf, 0x9f, - 0x26, 0x68, 0xcf, 0x4f, 0xeb, 0x7c, 0xa9, 0x67, 0xd, 0x14, - 0x89, 0x13, 0xaf, 0xb0, 0x33, 0xc9, 0x45, 0x4e, 0x15}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbc, 0xca, 0x10, 0xe, 0xfb, 0x7a, 0x21, 0xcb, + 0x17, 0x9c, 0x2e, 0x4d, 0x75, 0xf1, 0x97}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x82, 0x7b, 0xd2, 0x48, 0xbb, 0x20, 0xdb, 0x71, 0xfb, 0x77, - 0x6c, 0xf7, 0x26, 0xa, 0x4a, 0x24, 0xb9, 0x10, 0x9e, 0xb3}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x73, 0x84, 0x82, 0xde, 0xc, 0x45, 0x8e, 0x54, 0x80, 0x33, 0xb, + 0xe6, 0xda, 0x32, 0xd2, 0x5f, 0x47, 0x36, 0x80, 0xdc, 0xfb, 0x2}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa7, 0x0, 0x3, 0xac, 0xcf, 0x67, 0x64, 0x33, 0xfb, 0x43, 0xaa, 0xf, 0x4d, - 0xef, 0x9d, 0x4f, 0xe9, 0xe0, 0x2d, 0xfb, 0x65, 0x2d, 0xe0, 0x94, 0xbc}; - lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x9, 0xab, 0x25, 0x23, 0xdb, 0xfb, 0x1, 0x7d, 0xaf, 0x40, 0x4f, 0xa9}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb8, 0x15, 0xc6, 0x32, 0x89, 0xf, 0x3a, 0xa4, 0x13, 0x16, - 0x28, 0x23, 0xae, 0xf2, 0xb3, 0x8a, 0x3c, 0xce, 0x9d, 0x1f}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x64, 0x18, 0xc, 0x1, 0xb7, 0xfd, 0x25, 0x46, 0x2a}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xde, 0xe, 0x3d, 0xc2, 0xd2, 0x84, 0x75, 0xb9, 0xc0, 0xd, 0x35, 0xb5}; + uint8_t topic_filter_s5_bytes[] = {0xc3, 0x66, 0xd, 0x79, 0xa1, 0x2, 0xeb, 0x93, 0x15, 0x5c, 0xbd, 0xa8}; lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4f, 0xe7, 0xf6, 0x87, 0xd1, 0x89}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x1a, 0x71, 0x3b, 0x1e, 0xb7, 0xd1, 0xe4, 0x7a, 0xa6, 0xbb, + 0xd9, 0x9b, 0x19, 0x85, 0x5b, 0x85, 0x3a, 0xfc, 0x94, 0x16}; + lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x42, 0x3e, 0xfa, 0xc1, 0xe, 0x4c, 0xd4, 0xaa, 0xf5, 0xa8, - 0x29, 0xed, 0x86, 0xbb, 0xcc, 0xe8, 0x2a, 0x2b, 0xda, 0x19, - 0x37, 0xd, 0x8e, 0x4, 0x62, 0xdd, 0x98, 0x6c, 0x94}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xcf, 0x17, 0xb3}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26590, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10000, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 28467 ["\188j71/\157\SUBlO\ESC","N\195\136\SUB[L\203?\219","\USk\146!\197w\FSR\152\254\&3\216 -// \DEL\184\"\147\247\GS\137\168","\147\161\247W\NAKc\172\214*\254 17\201\164\177)\167e\233\179\198\197Wf\a\153x"] [] +// UnsubscribeRequest 27754 ["\172U5\DEL\CAN\228","8\240H\r\196\215\174\249;\DEL","\196\130@ +// \243\239\224\EM\205\229\136\207\254\167\223\132\193\tA\194A\245\NUL","\224\222\248\EOT\133p^\181\176C\236i7\193\233","\196\184Q\132\RS\SYN&y-\220\&3\GSN\220\172i\ENQ-\143\&9\b\203\226z\253\SI\ACK","\DC1\DC2\SOH\203\"\201\150\136G\ACK\DC3","Y;\167C\134\239\208\r\219\234J\222\197*R\184\150L.\\\178&\NUL\221\229\185\222]","\252\225\DC2~\145\SUBH\232\240\145\206m_u\146*$\254\SYNI\\\174\rk1\157\&5\253\&3\220","1r\226\USM\210o\252\161=\241","]\201\&9"] +// [PropCorrelationData "\236u\137\RS\NAK\136\209{",PropSubscriptionIdentifierAvailable 53,PropAuthenticationData +// "5\255\183l!9\173\162\181\157\159*K\238\131\171\253%\SOH\150\165\226"] TEST(Unsubscribe5QCTest, Encode8) { - uint8_t pkt[] = {0xa2, 0x4f, 0x6f, 0x33, 0x0, 0x0, 0xa, 0xbc, 0x6a, 0x37, 0x31, 0x2f, 0x9d, 0x1a, 0x6c, 0x4f, 0x1b, - 0x0, 0x9, 0x4e, 0xc3, 0x88, 0x1a, 0x5b, 0x4c, 0xcb, 0x3f, 0xdb, 0x0, 0x15, 0x1f, 0x6b, 0x92, 0x21, - 0xc5, 0x77, 0x1c, 0x52, 0x98, 0xfe, 0x33, 0xd8, 0x20, 0x7f, 0xb8, 0x22, 0x93, 0xf7, 0x1d, 0x89, 0xa8, - 0x0, 0x1c, 0x93, 0xa1, 0xf7, 0x57, 0x15, 0x63, 0xac, 0xd6, 0x2a, 0xfe, 0x20, 0x31, 0x37, 0xc9, 0xa4, - 0xb1, 0x29, 0xa7, 0x65, 0xe9, 0xb3, 0xc6, 0xc5, 0x57, 0x66, 0x7, 0x99, 0x78}; - uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t pkt[] = { + 0xa2, 0xe1, 0x1, 0x6c, 0x6a, 0x26, 0x9, 0x0, 0x8, 0xec, 0x75, 0x89, 0x1e, 0x15, 0x88, 0xd1, 0x7b, 0x29, 0x35, + 0x16, 0x0, 0x16, 0x35, 0xff, 0xb7, 0x6c, 0x21, 0x39, 0xad, 0xa2, 0xb5, 0x9d, 0x9f, 0x2a, 0x4b, 0xee, 0x83, 0xab, + 0xfd, 0x25, 0x1, 0x96, 0xa5, 0xe2, 0x0, 0x6, 0xac, 0x55, 0x35, 0x7f, 0x18, 0xe4, 0x0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 0x89, 0x1e, 0x15, 0x88, 0xd1, 0x7b}; + uint8_t bytesprops1[] = {0x35, 0xff, 0xb7, 0x6c, 0x21, 0x39, 0xad, 0xa2, 0xb5, 0x9d, 0x9f, + 0x2a, 0x4b, 0xee, 0x83, 0xab, 0xfd, 0x25, 0x1, 0x96, 0xa5, 0xe2}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops1}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xbc, 0x6a, 0x37, 0x31, 0x2f, 0x9d, 0x1a, 0x6c, 0x4f, 0x1b}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xac, 0x55, 0x35, 0x7f, 0x18, 0xe4}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x4e, 0xc3, 0x88, 0x1a, 0x5b, 0x4c, 0xcb, 0x3f, 0xdb}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x38, 0xf0, 0x48, 0xd, 0xc4, 0xd7, 0xae, 0xf9, 0x3b, 0x7f}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1f, 0x6b, 0x92, 0x21, 0xc5, 0x77, 0x1c, 0x52, 0x98, 0xfe, 0x33, - 0xd8, 0x20, 0x7f, 0xb8, 0x22, 0x93, 0xf7, 0x1d, 0x89, 0xa8}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xc4, 0x82, 0x40, 0x20, 0xf3, 0xef, 0xe0, 0x19, 0xcd, 0xe5, 0x88, 0xcf, + 0xfe, 0xa7, 0xdf, 0x84, 0xc1, 0x9, 0x41, 0xc2, 0x41, 0xf5, 0x0}; + lwmqtt_string_t topic_filter_s2 = {23, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x93, 0xa1, 0xf7, 0x57, 0x15, 0x63, 0xac, 0xd6, 0x2a, 0xfe, - 0x20, 0x31, 0x37, 0xc9, 0xa4, 0xb1, 0x29, 0xa7, 0x65, 0xe9, - 0xb3, 0xc6, 0xc5, 0x57, 0x66, 0x7, 0x99, 0x78}; - lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xe0, 0xde, 0xf8, 0x4, 0x85, 0x70, 0x5e, 0xb5, + 0xb0, 0x43, 0xec, 0x69, 0x37, 0xc1, 0xe9}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xc4, 0xb8, 0x51, 0x84, 0x1e, 0x16, 0x26, 0x79, 0x2d, 0xdc, 0x33, 0x1d, 0x4e, 0xdc, + 0xac, 0x69, 0x5, 0x2d, 0x8f, 0x39, 0x8, 0xcb, 0xe2, 0x7a, 0xfd, 0xf, 0x6}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x11, 0x12, 0x1, 0xcb, 0x22, 0xc9, 0x96, 0x88, 0x47, 0x6, 0x13}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x59, 0x3b, 0xa7, 0x43, 0x86, 0xef, 0xd0, 0xd, 0xdb, 0xea, + 0x4a, 0xde, 0xc5, 0x2a, 0x52, 0xb8, 0x96, 0x4c, 0x2e, 0x5c, + 0xb2, 0x26, 0x0, 0xdd, 0xe5, 0xb9, 0xde, 0x5d}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xfc, 0xe1, 0x12, 0x7e, 0x91, 0x1a, 0x48, 0xe8, 0xf0, 0x91, + 0xce, 0x6d, 0x5f, 0x75, 0x92, 0x2a, 0x24, 0xfe, 0x16, 0x49, + 0x5c, 0xae, 0xd, 0x6b, 0x31, 0x9d, 0x35, 0xfd, 0x33, 0xdc}; + lwmqtt_string_t topic_filter_s7 = {30, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x31, 0x72, 0xe2, 0x1f, 0x4d, 0xd2, 0x6f, 0xfc, 0xa1, 0x3d, 0xf1}; + lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x5d, 0xc9, 0x39}; + lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28467, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27754, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 8404 ["\198\198Y,9\140\US\ETB\133\SI\228\DC4\186\&9\252\131\242 -// \160\ACK\250\190\133H\184","h|\216nA\142%q@$\216\a\145\EOTE{\207\164V16\251]\131\&8u\235\184Ez","\132T\176\161h\202^\226p\136\166%\163^5\146\232\ESC\STXi\ENQ(\228\223#\SOH\204","M","\172\206\130\186\208S\DC1\255\166\196a","\144}i\254(@\229\171\199YW\ESC:\DC2\SUBs\165k\t\164\175,PR\SYN\194\DEL","0pM\253Q\142\194\174\194\194G9c\235T\GS\235\199\205\220\170\a\vF"] -// [PropReceiveMaximum 26464,PropContentType "1\202V\139\a\219\200\200\128\239\194\147[\173",PropServerKeepAlive -// 22501,PropContentType "\206\191\191\SO\136\230*\158\219\228\142]3",PropSubscriptionIdentifier -// 26,PropWillDelayInterval 16408,PropMessageExpiryInterval 24346,PropResponseTopic -// "\239\&6\CAN\192\aq\EM\227\&5\SOH\244>\ESC\212{\CAN\213\213D\CAN\147WB",PropReasonString -// "\149\198\141\a\196\RS`\141\177\SYN\216\137\\(\133\209aN\178A\EM\200.(\204N\153\210xb",PropReasonString -// "",PropSubscriptionIdentifier 19,PropTopicAlias 25210,PropWillDelayInterval 12790,PropSubscriptionIdentifierAvailable -// 243,PropAuthenticationMethod "\243\220\NAK\199\145x\253&\188\223@ L\222>\ESC\192",PropAuthenticationData -// "\215=\139\184\ACKh\195\154\171",PropUserProperty "\DC3\"\224\FSr\215Z\r\207=\155\153\210@\168k\194\b\200Wlh!\US",PropReceiveMaximum +// 5693,PropSharedSubscriptionAvailable 209,PropServerKeepAlive 8126,PropSubscriptionIdentifierAvailable +// 188,PropTopicAliasMaximum 6378,PropWildcardSubscriptionAvailable 112,PropMessageExpiryInterval 9354,PropReasonString +// "L\142K\176\GS\240N*)\198? \241\156\146\218#K\186\195\176-\187\164",PropRetainAvailable 127,PropMessageExpiryInterval +// 13953,PropRequestResponseInformation 67,PropWillDelayInterval 27638,PropResponseInformation +// "\169\ETX\197s\196<\153\151\201\133\137\n\FS\DC4\170\134wL+\ESCp\STX\205",PropTopicAliasMaximum 18649] TEST(Unsubscribe5QCTest, Encode9) { uint8_t pkt[] = { - 0xa2, 0x8c, 0x3, 0x20, 0xd4, 0xe9, 0x1, 0x21, 0x67, 0x60, 0x3, 0x0, 0xe, 0x31, 0xca, 0x56, 0x8b, 0x7, 0xdb, - 0xc8, 0xc8, 0x80, 0xef, 0xc2, 0x93, 0x5b, 0xad, 0x13, 0x57, 0xe5, 0x3, 0x0, 0xd, 0xce, 0xbf, 0xbf, 0xe, 0x88, - 0xe6, 0x2a, 0x9e, 0xdb, 0xe4, 0x8e, 0x5d, 0x33, 0xb, 0x1a, 0x18, 0x0, 0x0, 0x40, 0x18, 0x2, 0x0, 0x0, 0x5f, - 0x1a, 0x8, 0x0, 0x17, 0xef, 0x36, 0x18, 0xc0, 0x7, 0x71, 0x19, 0xe3, 0x35, 0x1, 0xf4, 0x3e, 0x1b, 0xd4, 0x7b, - 0x18, 0xd5, 0xd5, 0x44, 0x18, 0x93, 0x57, 0x42, 0x1f, 0x0, 0x1e, 0x95, 0xc6, 0x8d, 0x7, 0xc4, 0x1e, 0x60, 0x8d, - 0xb1, 0x16, 0xd8, 0x89, 0x5c, 0x28, 0x85, 0xd1, 0x61, 0x4e, 0xb2, 0x41, 0x19, 0xc8, 0x2e, 0x28, 0xcc, 0x4e, 0x99, - 0xd2, 0x78, 0x62, 0x1f, 0x0, 0x0, 0xb, 0x13, 0x23, 0x62, 0x7a, 0x18, 0x0, 0x0, 0x31, 0xf6, 0x29, 0xf3, 0x15, - 0x0, 0x11, 0xf3, 0xdc, 0x15, 0xc7, 0x91, 0x78, 0xfd, 0x26, 0xbc, 0xdf, 0x40, 0x20, 0x4c, 0xde, 0x3e, 0x1b, 0xc0, - 0x16, 0x0, 0x9, 0xd7, 0x3d, 0x8b, 0xb8, 0x6, 0x68, 0xc3, 0x9a, 0xab, 0x26, 0x0, 0x7, 0x3c, 0x46, 0xe, 0x98, - 0x2f, 0x7d, 0x13, 0x0, 0x0, 0x2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x6b, 0x9, 0xa4, 0xaf, 0x2c, 0x50, 0x52, 0x16, 0xc2, 0x7f, 0x0, 0x18, 0x30, 0x70, 0x4d, 0xfd, 0x51, - 0x8e, 0xc2, 0xae, 0xc2, 0xc2, 0x47, 0x39, 0x63, 0xeb, 0x54, 0x1d, 0xeb, 0xc7, 0xcd, 0xdc, 0xaa, 0x7, 0xb, 0x46}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x31, 0xca, 0x56, 0x8b, 0x7, 0xdb, 0xc8, 0xc8, 0x80, 0xef, 0xc2, 0x93, 0x5b, 0xad}; - uint8_t bytesprops1[] = {0xce, 0xbf, 0xbf, 0xe, 0x88, 0xe6, 0x2a, 0x9e, 0xdb, 0xe4, 0x8e, 0x5d, 0x33}; - uint8_t bytesprops2[] = {0xef, 0x36, 0x18, 0xc0, 0x7, 0x71, 0x19, 0xe3, 0x35, 0x1, 0xf4, 0x3e, - 0x1b, 0xd4, 0x7b, 0x18, 0xd5, 0xd5, 0x44, 0x18, 0x93, 0x57, 0x42}; - uint8_t bytesprops3[] = {0x95, 0xc6, 0x8d, 0x7, 0xc4, 0x1e, 0x60, 0x8d, 0xb1, 0x16, 0xd8, 0x89, 0x5c, 0x28, 0x85, - 0xd1, 0x61, 0x4e, 0xb2, 0x41, 0x19, 0xc8, 0x2e, 0x28, 0xcc, 0x4e, 0x99, 0xd2, 0x78, 0x62}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0xf3, 0xdc, 0x15, 0xc7, 0x91, 0x78, 0xfd, 0x26, 0xbc, - 0xdf, 0x40, 0x20, 0x4c, 0xde, 0x3e, 0x1b, 0xc0}; - uint8_t bytesprops6[] = {0xd7, 0x3d, 0x8b, 0xb8, 0x6, 0x68, 0xc3, 0x9a, 0xab}; - uint8_t bytesprops8[] = {0}; - uint8_t bytesprops7[] = {0x3c, 0x46, 0xe, 0x98, 0x2f, 0x7d, 0x13}; - uint8_t bytesprops9[] = {0x52, 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 0xc5, 0x73, + 0xc4, 0x3c, 0x99, 0x97, 0xc9, 0x85, 0x89, 0xa, 0x1c, 0x14, 0xaa, 0x86, 0x77, 0x4c, 0x2b, 0x1b, 0x70, 0x2, 0xcd, + 0x22, 0x48, 0xd9, 0x0, 0x7, 0xf0, 0x1c, 0x5b, 0x98, 0x10, 0xe2, 0x99, 0x0, 0x3, 0xef, 0x3f, 0xaa}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc3, 0x67, 0x39, 0x8a, 0x69, 0x42, 0xf, 0x70, 0x17, + 0x5, 0xbc, 0x7b, 0x63, 0x6e, 0x41, 0x7d, 0x6e, 0x45}; + uint8_t bytesprops1[] = {0x96, 0x90, 0x5, 0xca, 0xb2, 0xa1, 0xaf, 0xa6}; + uint8_t bytesprops2[] = {0xb9, 0x7b}; + uint8_t bytesprops3[] = {0x5a, 0xe0, 0xf9, 0x3e, 0x13, 0x22, 0xe0, 0x1c, 0x72, 0xd7, 0x5a, 0xd, 0xcf, 0x3d, + 0x9b, 0x99, 0xd2, 0x40, 0xa8, 0x6b, 0xc2, 0x8, 0xc8, 0x57, 0x6c, 0x68, 0x21, 0x1f}; + uint8_t bytesprops4[] = {0x4c, 0x8e, 0x4b, 0xb0, 0x1d, 0xf0, 0x4e, 0x2a, 0x29, 0xc6, 0x3f, 0x20, + 0xf1, 0x9c, 0x92, 0xda, 0x23, 0x4b, 0xba, 0xc3, 0xb0, 0x2d, 0xbb, 0xa4}; + uint8_t bytesprops5[] = {0xa9, 0x3, 0xc5, 0x73, 0xc4, 0x3c, 0x99, 0x97, 0xc9, 0x85, 0x89, 0xa, + 0x1c, 0x14, 0xaa, 0x86, 0x77, 0x4c, 0x2b, 0x1b, 0x70, 0x2, 0xcd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26464}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22501}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16408}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24346}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25210}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12790}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops7}, .v = {0, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 124}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22077}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30123}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28226}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 225}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18770}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5693}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8126}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6378}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9354}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13953}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27638}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18649}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xc6, 0xc6, 0x59, 0x2c, 0x39, 0x8c, 0x1f, 0x17, 0x85, 0xf, 0xe4, 0x14, 0xba, - 0x39, 0xfc, 0x83, 0xf2, 0x20, 0xa0, 0x6, 0xfa, 0xbe, 0x85, 0x48, 0xb8}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xf0, 0x1c, 0x5b, 0x98, 0x10, 0xe2, 0x99}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x68, 0x7c, 0xd8, 0x6e, 0x41, 0x8e, 0x25, 0x71, 0x40, 0x24, - 0xd8, 0x7, 0x91, 0x4, 0x45, 0x7b, 0xcf, 0xa4, 0x56, 0x31, - 0x36, 0xfb, 0x5d, 0x83, 0x38, 0x75, 0xeb, 0xb8, 0x45, 0x7a}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x84, 0x54, 0xb0, 0xa1, 0x68, 0xca, 0x5e, 0xe2, 0x70, 0x88, 0xa6, 0x25, 0xa3, 0x5e, - 0x35, 0x92, 0xe8, 0x1b, 0x2, 0x69, 0x5, 0x28, 0xe4, 0xdf, 0x23, 0x1, 0xcc}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x4d}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xac, 0xce, 0x82, 0xba, 0xd0, 0x53, 0x11, 0xff, 0xa6, 0xc4, 0x61}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x90, 0x7d, 0x69, 0xfe, 0x28, 0x40, 0xe5, 0xab, 0xc7, 0x59, 0x57, 0x1b, 0x3a, 0x12, - 0x1a, 0x73, 0xa5, 0x6b, 0x9, 0xa4, 0xaf, 0x2c, 0x50, 0x52, 0x16, 0xc2, 0x7f}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x30, 0x70, 0x4d, 0xfd, 0x51, 0x8e, 0xc2, 0xae, 0xc2, 0xc2, 0x47, 0x39, - 0x63, 0xeb, 0x54, 0x1d, 0xeb, 0xc7, 0xcd, 0xdc, 0xaa, 0x7, 0xb, 0x46}; - lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s1_bytes[] = {0xef, 0x3f, 0xaa}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8404, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13532, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 27989 ["q\223fV4\ETB\205\139(\ENQ`\204\145\206\221\207\248\245"] [PropRetainAvailable -// 160,PropServerKeepAlive 11580,PropMessageExpiryInterval 22087,PropUserProperty "\169\242" -// "\152n!\224\136\241\rm\STX#\215m*\182\147$\ENQ>",PropRequestResponseInformation 125,PropRequestResponseInformation -// 90,PropMessageExpiryInterval 716,PropReceiveMaximum 10851,PropReceiveMaximum 23215,PropResponseTopic -// "FL}\163\244\228x\EOT\190\EM\152;9Fo(\DC3y\231\n\237\194\157p\145",PropResponseInformation -// "\129\b\STX\241C\NAK\189\169\CANI\163\240\162"] +// UnsubscribeRequest 8446 ["N-\DC2\189\173\241\ETB\177\&9 +// \159\f\fj~\213!7\235\ESCx\194@\217\US[<","-","e\189\238\251\177\189\195\DLE\192\"c\166\SUB\DEL\145\133L\154^\"W\ETB\217\212","\155","X\139\243\DEL","\209\253\253\NUL9D\178\250\155BHo!\229=\135\146","\EM\217\251","\193S","\173M\228Y\v","\DC4>\252W0Y"] +// [PropTopicAlias 28644,PropUserProperty "\157\n\137\241G`]\ACK\SOH\236}\185\146\228\251\217\156Za\146\129\162" +// "\206\169\210S\208\244\NAK\191d\187Y1\213\186\241\255\&3\242o\ENQ\229\191\228\DC2\156",PropRetainAvailable +// 98,PropPayloadFormatIndicator 207,PropRequestProblemInformation 63,PropAssignedClientIdentifier +// "\131\173f\CAN\210_\128+\131\235\180\222\218u7K\199\CAN\CAN\190\206\158\152\232\250",PropSubscriptionIdentifier +// 4,PropSharedSubscriptionAvailable 7,PropMaximumPacketSize 9667,PropSubscriptionIdentifierAvailable 158,PropMaximumQoS +// 80,PropCorrelationData "3\189\&5({Pi\175\&8\135\176\198-\162\155\CAN\209I\NAK*/\DC1\186\137",PropMaximumPacketSize +// 9314,PropSharedSubscriptionAvailable 77,PropReceiveMaximum 15880,PropRetainAvailable 172,PropSessionExpiryInterval +// 28303,PropSubscriptionIdentifierAvailable 18,PropWildcardSubscriptionAvailable 20,PropContentType +// "\221\194\221\145\&7\149\156\204\172\252\158\160N.\179\148\FS\220\167",PropRetainAvailable 128,PropCorrelationData +// "\171\NUL\v\SIY\210\174\"\v\134\154\166\199\131",PropSessionExpiryInterval 2186,PropCorrelationData +// "\133w\187\216<\238wcW\149",PropAuthenticationMethod "\196\221\254(\160 \232\181\NAKE"] TEST(Unsubscribe5QCTest, Encode10) { - uint8_t pkt[] = {0xa2, 0x75, 0x6d, 0x55, 0x5e, 0x25, 0xa0, 0x13, 0x2d, 0x3c, 0x2, 0x0, 0x0, 0x56, 0x47, - 0x26, 0x0, 0x2, 0xa9, 0xf2, 0x0, 0x12, 0x98, 0x6e, 0x21, 0xe0, 0x88, 0xf1, 0xd, 0x6d, - 0x2, 0x23, 0xd7, 0x6d, 0x2a, 0xb6, 0x93, 0x24, 0x5, 0x3e, 0x19, 0x7d, 0x19, 0x5a, 0x2, - 0x0, 0x0, 0x2, 0xcc, 0x21, 0x2a, 0x63, 0x21, 0x5a, 0xaf, 0x8, 0x0, 0x19, 0x46, 0x4c, - 0x7d, 0xa3, 0xf4, 0xe4, 0x78, 0x4, 0xbe, 0x19, 0x98, 0x3b, 0x39, 0x46, 0x6f, 0x28, 0x13, - 0x79, 0xe7, 0xa, 0xed, 0xc2, 0x9d, 0x70, 0x91, 0x1a, 0x0, 0xd, 0x81, 0x8, 0x2, 0xf1, - 0x43, 0x15, 0xbd, 0xa9, 0x18, 0x49, 0xa3, 0xf0, 0xa2, 0x0, 0x12, 0x71, 0xdf, 0x66, 0x56, - 0x34, 0x17, 0xcd, 0x8b, 0x28, 0x5, 0x60, 0xcc, 0x91, 0xce, 0xdd, 0xcf, 0xf8, 0xf5}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x98, 0x6e, 0x21, 0xe0, 0x88, 0xf1, 0xd, 0x6d, 0x2, - 0x23, 0xd7, 0x6d, 0x2a, 0xb6, 0x93, 0x24, 0x5, 0x3e}; - uint8_t bytesprops0[] = {0xa9, 0xf2}; - uint8_t bytesprops2[] = {0x46, 0x4c, 0x7d, 0xa3, 0xf4, 0xe4, 0x78, 0x4, 0xbe, 0x19, 0x98, 0x3b, 0x39, - 0x46, 0x6f, 0x28, 0x13, 0x79, 0xe7, 0xa, 0xed, 0xc2, 0x9d, 0x70, 0x91}; - uint8_t bytesprops3[] = {0x81, 0x8, 0x2, 0xf1, 0x43, 0x15, 0xbd, 0xa9, 0x18, 0x49, 0xa3, 0xf0, 0xa2}; + uint8_t pkt[] = { + 0xa2, 0xd0, 0x2, 0x20, 0xfe, 0xde, 0x1, 0x23, 0x6f, 0xe4, 0x26, 0x0, 0x16, 0x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x8, 0x8a, 0x9, 0x0, 0xa, 0x85, 0x77, 0xbb, + 0xd8, 0x3c, 0xee, 0x77, 0x63, 0x57, 0x95, 0x15, 0x0, 0xa, 0xc4, 0xdd, 0xfe, 0x28, 0xa0, 0x20, 0xe8, 0xb5, 0x15, + 0x45, 0x0, 0x1b, 0x4e, 0x2d, 0x12, 0xbd, 0xad, 0xf1, 0x17, 0xb1, 0x39, 0x20, 0x9f, 0xc, 0xc, 0x6a, 0x7e, 0xd5, + 0x21, 0x37, 0xeb, 0x1b, 0x78, 0xc2, 0x40, 0xd9, 0x1f, 0x5b, 0x3c, 0x0, 0x1, 0x2d, 0x0, 0x18, 0x65, 0xbd, 0xee, + 0xfb, 0xb1, 0xbd, 0xc3, 0x10, 0xc0, 0x22, 0x63, 0xa6, 0x1a, 0x7f, 0x91, 0x85, 0x4c, 0x9a, 0x5e, 0x22, 0x57, 0x17, + 0xd9, 0xd4, 0x0, 0x1, 0x9b, 0x0, 0x4, 0x58, 0x8b, 0xf3, 0x7f, 0x0, 0x11, 0xd1, 0xfd, 0xfd, 0x0, 0x39, 0x44, + 0xb2, 0xfa, 0x9b, 0x42, 0x48, 0x6f, 0x21, 0xe5, 0x3d, 0x87, 0x92, 0x0, 0x3, 0x19, 0xd9, 0xfb, 0x0, 0x2, 0xc1, + 0x53, 0x0, 0x5, 0xad, 0x4d, 0xe4, 0x59, 0xb, 0x0, 0x6, 0x14, 0x3e, 0xfc, 0x57, 0x30, 0x59}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0xce, 0xa9, 0xd2, 0x53, 0xd0, 0xf4, 0x15, 0xbf, 0x64, 0xbb, 0x59, 0x31, 0xd5, + 0xba, 0xf1, 0xff, 0x33, 0xf2, 0x6f, 0x5, 0xe5, 0xbf, 0xe4, 0x12, 0x9c}; + uint8_t bytesprops0[] = {0x9d, 0xa, 0x89, 0xf1, 0x47, 0x60, 0x5d, 0x6, 0x1, 0xec, 0x7d, + 0xb9, 0x92, 0xe4, 0xfb, 0xd9, 0x9c, 0x5a, 0x61, 0x92, 0x81, 0xa2}; + uint8_t bytesprops2[] = {0x83, 0xad, 0x66, 0x18, 0xd2, 0x5f, 0x80, 0x2b, 0x83, 0xeb, 0xb4, 0xde, 0xda, + 0x75, 0x37, 0x4b, 0xc7, 0x18, 0x18, 0xbe, 0xce, 0x9e, 0x98, 0xe8, 0xfa}; + uint8_t bytesprops3[] = {0x33, 0xbd, 0x35, 0x28, 0x7b, 0x50, 0x69, 0xaf, 0x38, 0x87, 0xb0, 0xc6, + 0x2d, 0xa2, 0x9b, 0x18, 0xd1, 0x49, 0x15, 0x2a, 0x2f, 0x11, 0xba, 0x89}; + uint8_t bytesprops4[] = {0xdd, 0xc2, 0xdd, 0x91, 0x37, 0x95, 0x9c, 0xcc, 0xac, 0xfc, + 0x9e, 0xa0, 0x4e, 0x2e, 0xb3, 0x94, 0x1c, 0xdc, 0xa7}; + uint8_t bytesprops5[] = {0xab, 0x0, 0xb, 0xf, 0x59, 0xd2, 0xae, 0x22, 0xb, 0x86, 0x9a, 0xa6, 0xc7, 0x83}; + uint8_t bytesprops6[] = {0x85, 0x77, 0xbb, 0xd8, 0x3c, 0xee, 0x77, 0x63, 0x57, 0x95}; + uint8_t bytesprops7[] = {0xc4, 0xdd, 0xfe, 0x28, 0xa0, 0x20, 0xe8, 0xb5, 0x15, 0x45}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11580}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22087}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops0}, .v = {18, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 716}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10851}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23215}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28644}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9667}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9314}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15880}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28303}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2186}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x71, 0xdf, 0x66, 0x56, 0x34, 0x17, 0xcd, 0x8b, 0x28, - 0x5, 0x60, 0xcc, 0x91, 0xce, 0xdd, 0xcf, 0xf8, 0xf5}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x4e, 0x2d, 0x12, 0xbd, 0xad, 0xf1, 0x17, 0xb1, 0x39, 0x20, 0x9f, 0xc, 0xc, 0x6a, + 0x7e, 0xd5, 0x21, 0x37, 0xeb, 0x1b, 0x78, 0xc2, 0x40, 0xd9, 0x1f, 0x5b, 0x3c}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x2d}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x65, 0xbd, 0xee, 0xfb, 0xb1, 0xbd, 0xc3, 0x10, 0xc0, 0x22, 0x63, 0xa6, + 0x1a, 0x7f, 0x91, 0x85, 0x4c, 0x9a, 0x5e, 0x22, 0x57, 0x17, 0xd9, 0xd4}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x9b}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x58, 0x8b, 0xf3, 0x7f}; + lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xd1, 0xfd, 0xfd, 0x0, 0x39, 0x44, 0xb2, 0xfa, 0x9b, + 0x42, 0x48, 0x6f, 0x21, 0xe5, 0x3d, 0x87, 0x92}; + lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x19, 0xd9, 0xfb}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xc1, 0x53}; + lwmqtt_string_t topic_filter_s7 = {2, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xad, 0x4d, 0xe4, 0x59, 0xb}; + lwmqtt_string_t topic_filter_s8 = {5, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x14, 0x3e, 0xfc, 0x57, 0x30, 0x59}; + lwmqtt_string_t topic_filter_s9 = {6, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27989, 1, topic_filters, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// UnsubscribeRequest 32178 -// ["k\238\167\&3}\189\230\213?\DC3gW\142\236\196\STX\221\176\151\150\233","\174\208{E\236","&\174#!)\239\207\EOT\192Rr\155\145","\239\248\168\STXO\\~\184\&3\RS'*l\DLE\246\168^\a\173\137\&2\139G\SYN\218\170\152ELh","\206N\152\&2x\DC1\205\128\249\189\CAN\200_\228\162\207\RS\149"] -// [PropContentType "_B\STX#\201\223V\215:7P\211q\STX\170t\SI\158",PropRequestProblemInformation -// 63,PropResponseInformation "\228\252\173",PropReceiveMaximum 22471,PropServerKeepAlive 3410,PropTopicAliasMaximum -// 16631,PropUserProperty "\160\238\190\135\&5A5\DC1\165\160*U\CANm\219\142N}\SYN\n\SO\CAN\142\212\129\153u\136\152\166" -// "Q\150\242\210\142X\RS\192\ETBg\EOT\166\134\248\&8Wu\255\ACK\254\169_",PropRetainAvailable 249,PropTopicAlias -// 2742,PropMessageExpiryInterval 1062,PropServerReference -// "\149:\172\&6\226\221\243pn\nP\222\241t{\192",PropSharedSubscriptionAvailable 98,PropWillDelayInterval 4817] + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8446, 10, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 16062 +// ["\DC4\200\182\217\165`\168\SUB\DLE7\161\153>`\251\222\164\236/\237\214y#\151\242.z","\139\214\221#G*U\227T\173Rn@x\190\128\&5y\194\247\195\175\253wE","\GS\251H\DC4\vJP\189\140\185\154\&6\ETB\ETX","\128","\164\134\216\194\&6\188\138H\199\EOT\183\NULcZ?\216\152\181\221Q\186\186(","N\153\169\195C0fs\136\178\185\191\163\GS\DLE\NUL\163\137\203\244\EM\134","%N\154_","\182\139\236\&1\DEL\208\223\&6&D\244\191\208\GS\155S\221","\133 +// \226-gm\142m\195\143\ACK\187RL\224}\157S=\135\230j\143","\221A\DC405q\245^U\188\239\212","\141\201\141\157\242\ACKk\161\185\131\247\CAN\a\240L\180\218Wn\218%\f\247"] +// [PropRetainAvailable 126,PropCorrelationData "\196\225\180\173",PropMaximumPacketSize +// 15050,PropWildcardSubscriptionAvailable 132,PropTopicAlias 5379,PropServerReference +// "\254\250\184vZ\180,Vau\230p\128\ACKO\248B\194\&7B4\240}\218\&4!",PropTopicAlias 12587,PropContentType +// "uO\220\242\162\220Y\161\149\196\229\180=\213\v\FSXU\137:",PropResponseInformation +// "(\NUL\180\&4J\254\154\170",PropCorrelationData "",PropAuthenticationMethod "6\DLE",PropReceiveMaximum +// 21115,PropResponseInformation "y\158\152I\133\133\147?rj\186z\161\&0\143s",PropSharedSubscriptionAvailable +// 14,PropAuthenticationMethod "V\144z\151\156\241<\223\183\171{\200\211k_\210\&32E\215",PropReasonString +// "\222g2v#\247R\158Z\185\236\158",PropMessageExpiryInterval 15220,PropWildcardSubscriptionAvailable +// 112,PropResponseTopic "7",PropRetainAvailable 91,PropResponseInformation +// "\247l\174\144]l\237\134|\238w",PropMessageExpiryInterval 23113,PropSubscriptionIdentifierAvailable +// 9,PropResponseTopic "\184\228q\"\r\232",PropCorrelationData "3\140\192\224\ENQ\224\138\&0\228q +// \251\139\227\239}\135:\254\236\138\DEL\182L\139\SUB\210",PropPayloadFormatIndicator 216,PropServerReference +// "\r\135U\185B\ETBj\200\149\198\SYN\NAK\ACK*\188\r\216\&5\DEL.\SOH4\147",PropContentType +// "\131k\230\193BewT%\251\236",PropRequestResponseInformation 75,PropWillDelayInterval 26761] TEST(Unsubscribe5QCTest, Encode11) { - uint8_t pkt[] = {0xa2, 0xe8, 0x1, 0x7d, 0xb2, 0x83, 0x1, 0x3, 0x0, 0x12, 0x5f, 0x42, 0x2, 0x23, 0xc9, 0xdf, 0x56, - 0xd7, 0x3a, 0x37, 0x50, 0xd3, 0x71, 0x2, 0xaa, 0x74, 0xf, 0x9e, 0x17, 0x3f, 0x1a, 0x0, 0x3, 0xe4, - 0xfc, 0xad, 0x21, 0x57, 0xc7, 0x13, 0xd, 0x52, 0x22, 0x40, 0xf7, 0x26, 0x0, 0x1e, 0xa0, 0xee, 0xbe, - 0x87, 0x35, 0x41, 0x35, 0x11, 0xa5, 0xa0, 0x2a, 0x55, 0x18, 0x6d, 0xdb, 0x8e, 0x4e, 0x7d, 0x16, 0xa, - 0xe, 0x18, 0x8e, 0xd4, 0x81, 0x99, 0x75, 0x88, 0x98, 0xa6, 0x0, 0x16, 0x51, 0x96, 0xf2, 0xd2, 0x8e, - 0x58, 0x1e, 0xc0, 0x17, 0x67, 0x4, 0xa6, 0x86, 0xf8, 0x38, 0x57, 0x75, 0xff, 0x6, 0xfe, 0xa9, 0x5f, - 0x25, 0xf9, 0x23, 0xa, 0xb6, 0x2, 0x0, 0x0, 0x4, 0x26, 0x1c, 0x0, 0x10, 0x95, 0x3a, 0xac, 0x36, - 0xe2, 0xdd, 0xf3, 0x70, 0x6e, 0xa, 0x50, 0xde, 0xf1, 0x74, 0x7b, 0xc0, 0x2a, 0x62, 0x18, 0x0, 0x0, - 0x12, 0xd1, 0x0, 0x15, 0x6b, 0xee, 0xa7, 0x33, 0x7d, 0xbd, 0xe6, 0xd5, 0x3f, 0x13, 0x67, 0x57, 0x8e, - 0xec, 0xc4, 0x2, 0xdd, 0xb0, 0x97, 0x96, 0xe9, 0x0, 0x5, 0xae, 0xd0, 0x7b, 0x45, 0xec, 0x0, 0xd, - 0x26, 0xae, 0x23, 0x21, 0x29, 0xef, 0xcf, 0x4, 0xc0, 0x52, 0x72, 0x9b, 0x91, 0x0, 0x1e, 0xef, 0xf8, - 0xa8, 0x2, 0x4f, 0x5c, 0x7e, 0xb8, 0x33, 0x1e, 0x27, 0x2a, 0x6c, 0x10, 0xf6, 0xa8, 0x5e, 0x7, 0xad, - 0x89, 0x32, 0x8b, 0x47, 0x16, 0xda, 0xaa, 0x98, 0x45, 0x4c, 0x68, 0x0, 0x12, 0xce, 0x4e, 0x98, 0x32, - 0x78, 0x11, 0xcd, 0x80, 0xf9, 0xbd, 0x18, 0xc8, 0x5f, 0xe4, 0xa2, 0xcf, 0x1e, 0x95}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x5f, 0x42, 0x2, 0x23, 0xc9, 0xdf, 0x56, 0xd7, 0x3a, - 0x37, 0x50, 0xd3, 0x71, 0x2, 0xaa, 0x74, 0xf, 0x9e}; - uint8_t bytesprops1[] = {0xe4, 0xfc, 0xad}; - uint8_t bytesprops3[] = {0x51, 0x96, 0xf2, 0xd2, 0x8e, 0x58, 0x1e, 0xc0, 0x17, 0x67, 0x4, - 0xa6, 0x86, 0xf8, 0x38, 0x57, 0x75, 0xff, 0x6, 0xfe, 0xa9, 0x5f}; - uint8_t bytesprops2[] = {0xa0, 0xee, 0xbe, 0x87, 0x35, 0x41, 0x35, 0x11, 0xa5, 0xa0, 0x2a, 0x55, 0x18, 0x6d, 0xdb, - 0x8e, 0x4e, 0x7d, 0x16, 0xa, 0xe, 0x18, 0x8e, 0xd4, 0x81, 0x99, 0x75, 0x88, 0x98, 0xa6}; - uint8_t bytesprops4[] = {0x95, 0x3a, 0xac, 0x36, 0xe2, 0xdd, 0xf3, 0x70, - 0x6e, 0xa, 0x50, 0xde, 0xf1, 0x74, 0x7b, 0xc0}; + uint8_t pkt[] = { + 0xa2, 0xee, 0x3, 0x3e, 0xbe, 0x95, 0x2, 0x25, 0x7e, 0x9, 0x0, 0x4, 0xc4, 0xe1, 0xb4, 0xad, 0x27, 0x0, 0x0, + 0x3a, 0xca, 0x28, 0x84, 0x23, 0x15, 0x3, 0x1c, 0x0, 0x1a, 0xfe, 0xfa, 0xb8, 0x76, 0x5a, 0xb4, 0x2c, 0x56, 0x61, + 0x75, 0xe6, 0x70, 0x80, 0x6, 0x4f, 0xf8, 0x42, 0xc2, 0x37, 0x42, 0x34, 0xf0, 0x7d, 0xda, 0x34, 0x21, 0x23, 0x31, + 0x2b, 0x3, 0x0, 0x14, 0x75, 0x4f, 0xdc, 0xf2, 0xa2, 0xdc, 0x59, 0xa1, 0x95, 0xc4, 0xe5, 0xb4, 0x3d, 0xd5, 0xb, + 0x1c, 0x58, 0x55, 0x89, 0x3a, 0x1a, 0x0, 0x8, 0x28, 0x0, 0xb4, 0x34, 0x4a, 0xfe, 0x9a, 0xaa, 0x9, 0x0, 0x0, + 0x15, 0x0, 0x2, 0x36, 0x10, 0x21,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 0x17, 0x8d, + 0xc9, 0x8d, 0x9d, 0xf2, 0x6, 0x6b, 0xa1, 0xb9, 0x83, 0xf7, 0x18, 0x7, 0xf0, 0x4c, 0xb4, 0xda, 0x57, 0x6e, 0xda, + 0x25, 0xc, 0xf7}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc4, 0xe1, 0xb4, 0xad}; + uint8_t bytesprops1[] = {0xfe, 0xfa, 0xb8, 0x76, 0x5a, 0xb4, 0x2c, 0x56, 0x61, 0x75, 0xe6, 0x70, 0x80, + 0x6, 0x4f, 0xf8, 0x42, 0xc2, 0x37, 0x42, 0x34, 0xf0, 0x7d, 0xda, 0x34, 0x21}; + uint8_t bytesprops2[] = {0x75, 0x4f, 0xdc, 0xf2, 0xa2, 0xdc, 0x59, 0xa1, 0x95, 0xc4, + 0xe5, 0xb4, 0x3d, 0xd5, 0xb, 0x1c, 0x58, 0x55, 0x89, 0x3a}; + uint8_t bytesprops3[] = {0x28, 0x0, 0xb4, 0x34, 0x4a, 0xfe, 0x9a, 0xaa}; + uint8_t bytesprops4[] = {0}; + uint8_t bytesprops5[] = {0x36, 0x10}; + uint8_t bytesprops6[] = {0x79, 0x9e, 0x98, 0x49, 0x85, 0x85, 0x93, 0x3f, + 0x72, 0x6a, 0xba, 0x7a, 0xa1, 0x30, 0x8f, 0x73}; + uint8_t bytesprops7[] = {0x56, 0x90, 0x7a, 0x97, 0x9c, 0xf1, 0x3c, 0xdf, 0xb7, 0xab, + 0x7b, 0xc8, 0xd3, 0x6b, 0x5f, 0xd2, 0x33, 0x32, 0x45, 0xd7}; + uint8_t bytesprops8[] = {0xde, 0x67, 0x32, 0x76, 0x23, 0xf7, 0x52, 0x9e, 0x5a, 0xb9, 0xec, 0x9e}; + uint8_t bytesprops9[] = {0x37}; + uint8_t bytesprops10[] = {0xf7, 0x6c, 0xae, 0x90, 0x5d, 0x6c, 0xed, 0x86, 0x7c, 0xee, 0x77}; + uint8_t bytesprops11[] = {0xb8, 0xe4, 0x71, 0x22, 0xd, 0xe8}; + uint8_t bytesprops12[] = {0x33, 0x8c, 0xc0, 0xe0, 0x5, 0xe0, 0x8a, 0x30, 0xe4, 0x71, 0x20, 0xfb, 0x8b, 0xe3, + 0xef, 0x7d, 0x87, 0x3a, 0xfe, 0xec, 0x8a, 0x7f, 0xb6, 0x4c, 0x8b, 0x1a, 0xd2}; + uint8_t bytesprops13[] = {0xd, 0x87, 0x55, 0xb9, 0x42, 0x17, 0x6a, 0xc8, 0x95, 0xc6, 0x16, 0x15, + 0x6, 0x2a, 0xbc, 0xd, 0xd8, 0x35, 0x7f, 0x2e, 0x1, 0x34, 0x93}; + uint8_t bytesprops14[] = {0x83, 0x6b, 0xe6, 0xc1, 0x42, 0x65, 0x77, 0x54, 0x25, 0xfb, 0xec}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22471}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3410}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16631}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops2}, .v = {22, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2742}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1062}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4817}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15050}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5379}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12587}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21115}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15220}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23113}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 75}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26761}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x6b, 0xee, 0xa7, 0x33, 0x7d, 0xbd, 0xe6, 0xd5, 0x3f, 0x13, 0x67, - 0x57, 0x8e, 0xec, 0xc4, 0x2, 0xdd, 0xb0, 0x97, 0x96, 0xe9}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x14, 0xc8, 0xb6, 0xd9, 0xa5, 0x60, 0xa8, 0x1a, 0x10, 0x37, 0xa1, 0x99, 0x3e, 0x60, + 0xfb, 0xde, 0xa4, 0xec, 0x2f, 0xed, 0xd6, 0x79, 0x23, 0x97, 0xf2, 0x2e, 0x7a}; + lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xae, 0xd0, 0x7b, 0x45, 0xec}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x8b, 0xd6, 0xdd, 0x23, 0x47, 0x2a, 0x55, 0xe3, 0x54, 0xad, 0x52, 0x6e, 0x40, + 0x78, 0xbe, 0x80, 0x35, 0x79, 0xc2, 0xf7, 0xc3, 0xaf, 0xfd, 0x77, 0x45}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x26, 0xae, 0x23, 0x21, 0x29, 0xef, 0xcf, 0x4, 0xc0, 0x52, 0x72, 0x9b, 0x91}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1d, 0xfb, 0x48, 0x14, 0xb, 0x4a, 0x50, 0xbd, 0x8c, 0xb9, 0x9a, 0x36, 0x17, 0x3}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xef, 0xf8, 0xa8, 0x2, 0x4f, 0x5c, 0x7e, 0xb8, 0x33, 0x1e, - 0x27, 0x2a, 0x6c, 0x10, 0xf6, 0xa8, 0x5e, 0x7, 0xad, 0x89, - 0x32, 0x8b, 0x47, 0x16, 0xda, 0xaa, 0x98, 0x45, 0x4c, 0x68}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x80}; + lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xce, 0x4e, 0x98, 0x32, 0x78, 0x11, 0xcd, 0x80, 0xf9, - 0xbd, 0x18, 0xc8, 0x5f, 0xe4, 0xa2, 0xcf, 0x1e, 0x95}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xa4, 0x86, 0xd8, 0xc2, 0x36, 0xbc, 0x8a, 0x48, 0xc7, 0x4, 0xb7, 0x0, + 0x63, 0x5a, 0x3f, 0xd8, 0x98, 0xb5, 0xdd, 0x51, 0xba, 0xba, 0x28}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x4e, 0x99, 0xa9, 0xc3, 0x43, 0x30, 0x66, 0x73, 0x88, 0xb2, 0xb9, + 0xbf, 0xa3, 0x1d, 0x10, 0x0, 0xa3, 0x89, 0xcb, 0xf4, 0x19, 0x86}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x25, 0x4e, 0x9a, 0x5f}; + lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xb6, 0x8b, 0xec, 0x31, 0x7f, 0xd0, 0xdf, 0x36, 0x26, + 0x44, 0xf4, 0xbf, 0xd0, 0x1d, 0x9b, 0x53, 0xdd}; + lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x85, 0x20, 0xe2, 0x2d, 0x67, 0x6d, 0x8e, 0x6d, 0xc3, 0x8f, 0x6, 0xbb, + 0x52, 0x4c, 0xe0, 0x7d, 0x9d, 0x53, 0x3d, 0x87, 0xe6, 0x6a, 0x8f}; + lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xdd, 0x41, 0x14, 0x30, 0x35, 0x71, 0xf5, 0x5e, 0x55, 0xbc, 0xef, 0xd4}; + lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x8d, 0xc9, 0x8d, 0x9d, 0xf2, 0x6, 0x6b, 0xa1, 0xb9, 0x83, 0xf7, 0x18, + 0x7, 0xf0, 0x4c, 0xb4, 0xda, 0x57, 0x6e, 0xda, 0x25, 0xc, 0xf7}; + lwmqtt_string_t topic_filter_s10 = {23, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32178, 5, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16062, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 17769 ["\192d\222\&2>\213\ESC_d\SUB\DC1N"] [PropMessageExpiryInterval 26793,PropMaximumPacketSize -// 6142,PropWillDelayInterval 30684,PropWillDelayInterval 12528,PropRequestProblemInformation -// 12,PropSharedSubscriptionAvailable 30,PropRequestResponseInformation 168,PropMessageExpiryInterval -// 9680,PropWillDelayInterval 2551,PropMaximumPacketSize 18149,PropServerReference -// "\139$\196\137",PropMessageExpiryInterval 27206,PropUserProperty "\NAKz\220\&5PE\229\206I\222\158,\195\230\t\t\210" -// "\DLEp\\\SOH\233r\"\n,\248:"] +// UnsubscribeRequest 999 +// ["kz8\"x_\167\&7\"\185\142\244:j\DC1","|","$\185\f4w\233","T\165\216\ETB\180p\NULe\ETX8\144\DLE4\DC4\GS\226\218\129\RS\SOHz","\172|>\168&\208\226\212\228lp\RSw\196\153\ESC\218\178l\207\rqgP\t\155$\145\ENQ","\EOT\244\t\200\GS\218\166\a\ETBL\218\191\198\183\130OR\ENQn\151\"|"] +// [] TEST(Unsubscribe5QCTest, Encode12) { - uint8_t pkt[] = {0xa2, 0x67, 0x45, 0x69, 0x56, 0x2, 0x0, 0x0, 0x68, 0xa9, 0x27, 0x0, 0x0, 0x17, 0xfe, - 0x18, 0x0, 0x0, 0x77, 0xdc, 0x18, 0x0, 0x0, 0x30, 0xf0, 0x17, 0xc, 0x2a, 0x1e, 0x19, - 0xa8, 0x2, 0x0, 0x0, 0x25, 0xd0, 0x18, 0x0, 0x0, 0x9, 0xf7, 0x27, 0x0, 0x0, 0x46, - 0xe5, 0x1c, 0x0, 0x4, 0x8b, 0x24, 0xc4, 0x89, 0x2, 0x0, 0x0, 0x6a, 0x46, 0x26, 0x0, - 0x11, 0x15, 0x7a, 0xdc, 0x35, 0x50, 0x45, 0xe5, 0xce, 0x49, 0xde, 0x9e, 0x2c, 0xc3, 0xe6, - 0x9, 0x9, 0xd2, 0x0, 0xb, 0x10, 0x70, 0x5c, 0x1, 0xe9, 0x72, 0x22, 0xa, 0x2c, 0xf8, - 0x3a, 0x0, 0xc, 0xc0, 0x64, 0xde, 0x32, 0x3e, 0xd5, 0x1b, 0x5f, 0x64, 0x1a, 0x11, 0x4e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x8b, 0x24, 0xc4, 0x89}; - uint8_t bytesprops2[] = {0x10, 0x70, 0x5c, 0x1, 0xe9, 0x72, 0x22, 0xa, 0x2c, 0xf8, 0x3a}; - uint8_t bytesprops1[] = {0x15, 0x7a, 0xdc, 0x35, 0x50, 0x45, 0xe5, 0xce, 0x49, - 0xde, 0x9e, 0x2c, 0xc3, 0xe6, 0x9, 0x9, 0xd2}; + uint8_t pkt[] = {0xa2, 0x6d, 0x3, 0xe7, 0x0, 0x0, 0xf, 0x6b, 0x7a, 0x38, 0x22, 0x78, 0x5f, 0xa7, 0x37, 0x22, + 0xb9, 0x8e, 0xf4, 0x3a, 0x6a, 0x11, 0x0, 0x1, 0x7c, 0x0, 0x6, 0x24, 0xb9, 0xc, 0x34, 0x77, + 0xe9, 0x0, 0x15, 0x54, 0xa5, 0xd8, 0x17, 0xb4, 0x70, 0x0, 0x65, 0x3, 0x38, 0x90, 0x10, 0x34, + 0x14, 0x1d, 0xe2, 0xda, 0x81, 0x1e, 0x1, 0x7a, 0x0, 0x1d, 0xac, 0x7c, 0x3e, 0xa8, 0x26, 0xd0, + 0xe2, 0xd4, 0xe4, 0x6c, 0x70, 0x1e, 0x77, 0xc4, 0x99, 0x1b, 0xda, 0xb2, 0x6c, 0xcf, 0xd, 0x71, + 0x67, 0x50, 0x9, 0x9b, 0x24, 0x91, 0x5, 0x0, 0x16, 0x4, 0xf4, 0x9, 0xc8, 0x1d, 0xda, 0xa6, + 0x7, 0x17, 0x4c, 0xda, 0xbf, 0xc6, 0xb7, 0x82, 0x4f, 0x52, 0x5, 0x6e, 0x97, 0x22, 0x7c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26793}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6142}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30684}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12528}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9680}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2551}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18149}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27206}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {11, (char*)&bytesprops2}}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xc0, 0x64, 0xde, 0x32, 0x3e, 0xd5, 0x1b, 0x5f, 0x64, 0x1a, 0x11, 0x4e}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x6b, 0x7a, 0x38, 0x22, 0x78, 0x5f, 0xa7, 0x37, + 0x22, 0xb9, 0x8e, 0xf4, 0x3a, 0x6a, 0x11}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x7c}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x24, 0xb9, 0xc, 0x34, 0x77, 0xe9}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x54, 0xa5, 0xd8, 0x17, 0xb4, 0x70, 0x0, 0x65, 0x3, 0x38, 0x90, + 0x10, 0x34, 0x14, 0x1d, 0xe2, 0xda, 0x81, 0x1e, 0x1, 0x7a}; + lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xac, 0x7c, 0x3e, 0xa8, 0x26, 0xd0, 0xe2, 0xd4, 0xe4, 0x6c, + 0x70, 0x1e, 0x77, 0xc4, 0x99, 0x1b, 0xda, 0xb2, 0x6c, 0xcf, + 0xd, 0x71, 0x67, 0x50, 0x9, 0x9b, 0x24, 0x91, 0x5}; + lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x4, 0xf4, 0x9, 0xc8, 0x1d, 0xda, 0xa6, 0x7, 0x17, 0x4c, 0xda, + 0xbf, 0xc6, 0xb7, 0x82, 0x4f, 0x52, 0x5, 0x6e, 0x97, 0x22, 0x7c}; + lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17769, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 999, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 21908 -// ["$","\GSI\141^\185\188\DC2|\159M\189\209\DC4\211\&1","L\t}\130~\220\&8\211\235","\210\USg\203\179@\DC2\174l\v\193\DC2)Q\233\STX#\177C\164\ENQ&@;=\238\138\217\158"] -// [PropRequestResponseInformation 28,PropResponseTopic -// "\172\213\248F\182$\184f\232\184\224\135\173\187",PropAssignedClientIdentifier -// "\200\DLE\205\216\204djT^\210/\170heT|l\251\SO\183f",PropWildcardSubscriptionAvailable 188,PropMessageExpiryInterval -// 9268,PropPayloadFormatIndicator 31,PropRequestResponseInformation 161,PropSharedSubscriptionAvailable -// 221,PropRequestResponseInformation 19,PropRequestResponseInformation 157,PropResponseInformation -// "\157\197\145\138\215\192\149\208",PropReceiveMaximum 11044,PropSubscriptionIdentifierAvailable 188,PropTopicAlias -// 21441,PropRequestResponseInformation 200,PropSubscriptionIdentifierAvailable 174,PropMessageExpiryInterval -// 16750,PropMaximumQoS 214,PropTopicAlias 14613,PropRetainAvailable 254,PropCorrelationData -// "\202\168j",PropUserProperty "'\171b\132\201Q\185\SYN" -// "\167\180\128\200\254\ETX\187R\231\199\175\182\250",PropRequestProblemInformation 61,PropAuthenticationData -// "JF\RS\149[\DEL\221\240",PropServerKeepAlive 25680,PropSessionExpiryInterval 24444] +// UnsubscribeRequest 5737 +// ["\216\200`8N","z\226\248\NULq\EOT\232\158\NUL\178\131\247\130\n\240\192\225^","?x\STX-5\217\158\213\253+\165\134\173`#\190\229\177\228\177\183\\\204V","[Q","\190\180u\222#\171\SUBik\221\246\227\164)\239\210\EOT4[-","f\SO\237iS\197T\247\250\167?\228\242\170\213_b\215\241\221\153\136\138\229\175","E}\SUB\221S\172 +// \FS\189&}v\220"] [PropUserProperty "\178\171%\133\134\131\203x\200\180\&4C\236\173\133" +// "`\221\NAKfB\RST\195",PropMaximumPacketSize 15484,PropResponseTopic +// "\242tw\US\r\146\"G\146+\201\140\225\134|d\249\a\151^w\232",PropCorrelationData +// "T\204\188\141$\158)\139?S\ETX\SYNbS\185\DEL\249&\131~\233F\128E\245\201N",PropWildcardSubscriptionAvailable +// 118,PropAuthenticationMethod "\207\211\218\137\138\t\SO\EM",PropSubscriptionIdentifier 20,PropMaximumQoS +// 204,PropSharedSubscriptionAvailable 219,PropWildcardSubscriptionAvailable 204,PropReceiveMaximum +// 30300,PropSharedSubscriptionAvailable 43,PropSubscriptionIdentifierAvailable 32,PropCorrelationData +// "\139\135)\198\226\241\166\165\221\RS\144\166\247\128k@\251\213",PropContentType +// "5S(\134\136!#\202\\\175\a",PropContentType +// "\r\149\141\222\209\159k\133\&5U\157\ACK",PropWildcardSubscriptionAvailable 166,PropMessageExpiryInterval +// 32142,PropContentType "\239\215\172\152\182\206\205\163~ [\134\ETX\228A\185",PropPayloadFormatIndicator +// 241,PropTopicAliasMaximum 28855,PropSharedSubscriptionAvailable 18] TEST(Unsubscribe5QCTest, Encode13) { - uint8_t pkt[] = {0xa2, 0xd6, 0x1, 0x55, 0x94, 0x94, 0x1, 0x19, 0x1c, 0x8, 0x0, 0xe, 0xac, 0xd5, 0xf8, 0x46, 0xb6, - 0x24, 0xb8, 0x66, 0xe8, 0xb8, 0xe0, 0x87, 0xad, 0xbb, 0x12, 0x0, 0x15, 0xc8, 0x10, 0xcd, 0xd8, 0xcc, - 0x64, 0x6a, 0x54, 0x5e, 0xd2, 0x2f, 0xaa, 0x68, 0x65, 0x54, 0x7c, 0x6c, 0xfb, 0xe, 0xb7, 0x66, 0x28, - 0xbc, 0x2, 0x0, 0x0, 0x24, 0x34, 0x1, 0x1f, 0x19, 0xa1, 0x2a, 0xdd, 0x19, 0x13, 0x19, 0x9d, 0x1a, - 0x0, 0x8, 0x9d, 0xc5, 0x91, 0x8a, 0xd7, 0xc0, 0x95, 0xd0, 0x21, 0x2b, 0x24, 0x29, 0xbc, 0x23, 0x53, - 0xc1, 0x19, 0xc8, 0x29, 0xae, 0x2, 0x0, 0x0, 0x41, 0x6e, 0x24, 0xd6, 0x23, 0x39, 0x15, 0x25, 0xfe, - 0x9, 0x0, 0x3, 0xca, 0xa8, 0x6a, 0x26, 0x0, 0x8, 0x27, 0xab, 0x62, 0x84, 0xc9, 0x51, 0xb9, 0x16, - 0x0, 0xd, 0xa7, 0xb4, 0x80, 0xc8, 0xfe, 0x3, 0xbb, 0x52, 0xe7, 0xc7, 0xaf, 0xb6, 0xfa, 0x17, 0x3d, - 0x16, 0x0, 0x8, 0x4a, 0x46, 0x1e, 0x95, 0x5b, 0x7f, 0xdd, 0xf0, 0x13, 0x64, 0x50, 0x11, 0x0, 0x0, - 0x5f, 0x7c, 0x0, 0x1, 0x24, 0x0, 0xf, 0x1d, 0x49, 0x8d, 0x5e, 0xb9, 0xbc, 0x12, 0x7c, 0x9f, 0x4d, - 0xbd, 0xd1, 0x14, 0xd3, 0x31, 0x0, 0x9, 0x4c, 0x9, 0x7d, 0x82, 0x7e, 0xdc, 0x38, 0xd3, 0xeb, 0x0, - 0x1d, 0xd2, 0x1f, 0x67, 0xcb, 0xb3, 0x40, 0x12, 0xae, 0x6c, 0xb, 0xc1, 0x12, 0x29, 0x51, 0xe9, 0x2, - 0x23, 0xb1, 0x43, 0xa4, 0x5, 0x26, 0x40, 0x3b, 0x3d, 0xee, 0x8a, 0xd9, 0x9e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xac, 0xd5, 0xf8, 0x46, 0xb6, 0x24, 0xb8, 0x66, 0xe8, 0xb8, 0xe0, 0x87, 0xad, 0xbb}; - uint8_t bytesprops1[] = {0xc8, 0x10, 0xcd, 0xd8, 0xcc, 0x64, 0x6a, 0x54, 0x5e, 0xd2, 0x2f, - 0xaa, 0x68, 0x65, 0x54, 0x7c, 0x6c, 0xfb, 0xe, 0xb7, 0x66}; - uint8_t bytesprops2[] = {0x9d, 0xc5, 0x91, 0x8a, 0xd7, 0xc0, 0x95, 0xd0}; - uint8_t bytesprops3[] = {0xca, 0xa8, 0x6a}; - uint8_t bytesprops5[] = {0xa7, 0xb4, 0x80, 0xc8, 0xfe, 0x3, 0xbb, 0x52, 0xe7, 0xc7, 0xaf, 0xb6, 0xfa}; - uint8_t bytesprops4[] = {0x27, 0xab, 0x62, 0x84, 0xc9, 0x51, 0xb9, 0x16}; - uint8_t bytesprops6[] = {0x4a, 0x46, 0x1e, 0x95, 0x5b, 0x7f, 0xdd, 0xf0}; + uint8_t pkt[] = { + 0xa2, 0xc4, 0x2, 0x16, 0x69, 0xc7, 0x1, 0x26, 0x0, 0xf, 0xb2, 0xab, 0x25, 0x85, 0x86, 0x83, 0xcb, 0x78, 0xc8, + 0xb4, 0x34, 0x43, 0xec, 0xad, 0x85, 0x0, 0x8, 0x60, 0xdd, 0x15, 0x66, 0x42, 0x1e, 0x54, 0xc3, 0x27, 0x0, 0x0, + 0x3c, 0x7c, 0x8, 0x0, 0x16, 0xf2, 0x74, 0x77, 0x1f, 0xd, 0x92, 0x22, 0x47, 0x92, 0x2b, 0xc9, 0x8c, 0xe1, 0x86, + 0x7c, 0x64, 0xf9, 0x7, 0x97, 0x5e, 0x77, 0xe8, 0x9, 0x0, 0x1b, 0x54, 0xcc, 0xbc, 0x8d, 0x24, 0x9e, 0x29, 0x8b, + 0x3f, 0x53, 0x3, 0x16, 0x62, 0x53, 0xb9, 0x7f, 0xf9, 0x26, 0x83, 0x7e, 0xe9, 0x46, 0x80, 0x45, 0xf5, 0xc9, 0x4e, + 0x28, 0x76, 0x15, 0x0, 0x8, 0xcf, 0xd3, 0xda, 0x89, 0x8a, 0x9, 0xe, 0x19, 0xb, 0x14, 0x24, 0xcc, 0x2a, 0xdb, + 0x28, 0xcc, 0x21, 0x76, 0x5c, 0x2a, 0x2b, 0x29, 0x20, 0x9, 0x0, 0x12, 0x8b, 0x87, 0x29, 0xc6, 0xe2, 0xf1, 0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0xdd, 0x53, 0xac, 0x20, 0x1c, 0xbd, + 0x26, 0x7d, 0x76, 0xdc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x60, 0xdd, 0x15, 0x66, 0x42, 0x1e, 0x54, 0xc3}; + uint8_t bytesprops0[] = {0xb2, 0xab, 0x25, 0x85, 0x86, 0x83, 0xcb, 0x78, 0xc8, 0xb4, 0x34, 0x43, 0xec, 0xad, 0x85}; + uint8_t bytesprops2[] = {0xf2, 0x74, 0x77, 0x1f, 0xd, 0x92, 0x22, 0x47, 0x92, 0x2b, 0xc9, + 0x8c, 0xe1, 0x86, 0x7c, 0x64, 0xf9, 0x7, 0x97, 0x5e, 0x77, 0xe8}; + uint8_t bytesprops3[] = {0x54, 0xcc, 0xbc, 0x8d, 0x24, 0x9e, 0x29, 0x8b, 0x3f, 0x53, 0x3, 0x16, 0x62, 0x53, + 0xb9, 0x7f, 0xf9, 0x26, 0x83, 0x7e, 0xe9, 0x46, 0x80, 0x45, 0xf5, 0xc9, 0x4e}; + uint8_t bytesprops4[] = {0xcf, 0xd3, 0xda, 0x89, 0x8a, 0x9, 0xe, 0x19}; + uint8_t bytesprops5[] = {0x8b, 0x87, 0x29, 0xc6, 0xe2, 0xf1, 0xa6, 0xa5, 0xdd, + 0x1e, 0x90, 0xa6, 0xf7, 0x80, 0x6b, 0x40, 0xfb, 0xd5}; + uint8_t bytesprops6[] = {0x35, 0x53, 0x28, 0x86, 0x88, 0x21, 0x23, 0xca, 0x5c, 0xaf, 0x7}; + uint8_t bytesprops7[] = {0xd, 0x95, 0x8d, 0xde, 0xd1, 0x9f, 0x6b, 0x85, 0x35, 0x55, 0x9d, 0x6}; + uint8_t bytesprops8[] = {0xef, 0xd7, 0xac, 0x98, 0xb6, 0xce, 0xcd, 0xa3, + 0x7e, 0x20, 0x5b, 0x86, 0x3, 0xe4, 0x41, 0xb9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9268}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 157}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11044}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21441}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16750}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14613}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops4}, .v = {13, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25680}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24444}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15484}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30300}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32142}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28855}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x24}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0xd8, 0xc8, 0x60, 0x38, 0x4e}; + lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1d, 0x49, 0x8d, 0x5e, 0xb9, 0xbc, 0x12, 0x7c, - 0x9f, 0x4d, 0xbd, 0xd1, 0x14, 0xd3, 0x31}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7a, 0xe2, 0xf8, 0x0, 0x71, 0x4, 0xe8, 0x9e, 0x0, + 0xb2, 0x83, 0xf7, 0x82, 0xa, 0xf0, 0xc0, 0xe1, 0x5e}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4c, 0x9, 0x7d, 0x82, 0x7e, 0xdc, 0x38, 0xd3, 0xeb}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x3f, 0x78, 0x2, 0x2d, 0x35, 0xd9, 0x9e, 0xd5, 0xfd, 0x2b, 0xa5, 0x86, + 0xad, 0x60, 0x23, 0xbe, 0xe5, 0xb1, 0xe4, 0xb1, 0xb7, 0x5c, 0xcc, 0x56}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd2, 0x1f, 0x67, 0xcb, 0xb3, 0x40, 0x12, 0xae, 0x6c, 0xb, - 0xc1, 0x12, 0x29, 0x51, 0xe9, 0x2, 0x23, 0xb1, 0x43, 0xa4, - 0x5, 0x26, 0x40, 0x3b, 0x3d, 0xee, 0x8a, 0xd9, 0x9e}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x5b, 0x51}; + lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xbe, 0xb4, 0x75, 0xde, 0x23, 0xab, 0x1a, 0x69, 0x6b, 0xdd, + 0xf6, 0xe3, 0xa4, 0x29, 0xef, 0xd2, 0x4, 0x34, 0x5b, 0x2d}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x66, 0xe, 0xed, 0x69, 0x53, 0xc5, 0x54, 0xf7, 0xfa, 0xa7, 0x3f, 0xe4, 0xf2, + 0xaa, 0xd5, 0x5f, 0x62, 0xd7, 0xf1, 0xdd, 0x99, 0x88, 0x8a, 0xe5, 0xaf}; + lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x45, 0x7d, 0x1a, 0xdd, 0x53, 0xac, 0x20, 0x1c, 0xbd, 0x26, 0x7d, 0x76, 0xdc}; + lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21908, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5737, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 12542 ["j\251j\160\243\235 -// \r\246R\192\234l\DC2.\153\144v\NAK\RSXz\DEL:","\DC4\SYN\240\227S!\ETX\ETBS\179\245t\185D+\225\&3n~\146z\194\143"] -// [PropSharedSubscriptionAvailable 1,PropTopicAlias 16745,PropAuthenticationMethod -// "\171\212\181\188\130\NUL\DC2\STXn\186\RS\141j\184a1\DC3 y1",PropWildcardSubscriptionAvailable -// 120,PropResponseInformation "\222\159\143",PropServerReference "\200K\SUB\175-2_x\136\&8 -// \218O\211|\151\129z~`\252i\244\255\230",PropRequestProblemInformation 76,PropRequestProblemInformation -// 170,PropMessageExpiryInterval 14379,PropMessageExpiryInterval 11089,PropMaximumQoS 130,PropRequestResponseInformation -// 159,PropMaximumQoS 250,PropCorrelationData -// "\159\FSB\166\ETBt\182\131\213.~Y\230\178\180\214\SIC\175\136\DC2",PropSharedSubscriptionAvailable -// 185,PropTopicAliasMaximum 24719,PropWillDelayInterval 9537,PropRequestResponseInformation 18,PropContentType -// ":\140G\146\240;\134\RSn*\DC1\143d\177\225\153\SUBRo\178\&8\248|:\SI\145\129\180",PropRequestResponseInformation -// 228,PropReceiveMaximum 973] +// UnsubscribeRequest 1255 +// ["\153\GSI\185K\229\aE*T\235?5*(","9\225=)\198\150\245\192\130\194N\204d\137\162(\248\142n","\163\168\DEL\193\254\161\250\166\204\221\231\250\&9\228\202\163\162%\242c\223\217\250\182","\255\201\247\&9\DC4?\255\229\SI\EOT\228fc\ETB\177\225+b\159\&5O\218\ACK\132","\251\n\SYN~\RS\180\172y\RS\f\228\211*\214","Uq\215s\244Y",""] +// [PropTopicAlias 4162,PropPayloadFormatIndicator 254,PropUserProperty +// "5\180\&0\209`\241\DC3Q\153\174O\ETX\bc<<\162[\141\129P\220\216\148\220x" +// "\146S\252\226\\\149\181\202\US\145\b\182\223\234\173\224",PropUserProperty "t\185\147" +// "m\251\147\fY\178\145\135\209\199\248-s0",PropReasonString +// "\231\252\248\150I\STX\176\DLEz\222\201\SI\DC2\NUL\193Q\207* ",PropSubscriptionIdentifier 30,PropMaximumQoS +// 59,PropRetainAvailable 10,PropServerKeepAlive 9939] TEST(Unsubscribe5QCTest, Encode14) { - uint8_t pkt[] = {0xa2, 0xd3, 0x1, 0x30, 0xfe, 0x9c, 0x1, 0x2a, 0x1, 0x23, 0x41, 0x69, 0x15, 0x0,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 0xb3, 0xf5, 0x74, 0xb9, - 0x44, 0x2b, 0xe1, 0x33, 0x6e, 0x7e, 0x92, 0x7a, 0xc2, 0x8f}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xab, 0xd4, 0xb5, 0xbc, 0x82, 0x0, 0x12, 0x2, 0x6e, 0xba, - 0x1e, 0x8d, 0x6a, 0xb8, 0x61, 0x31, 0x13, 0x20, 0x79, 0x31}; - uint8_t bytesprops1[] = {0xde, 0x9f, 0x8f}; - uint8_t bytesprops2[] = {0xc8, 0x4b, 0x1a, 0xaf, 0x2d, 0x32, 0x5f, 0x78, 0x88, 0x38, 0x20, 0xda, 0x4f, - 0xd3, 0x7c, 0x97, 0x81, 0x7a, 0x7e, 0x60, 0xfc, 0x69, 0xf4, 0xff, 0xe6}; - uint8_t bytesprops3[] = {0x9f, 0x1c, 0x42, 0xa6, 0x17, 0x74, 0xb6, 0x83, 0xd5, 0x2e, 0x7e, - 0x59, 0xe6, 0xb2, 0xb4, 0xd6, 0xf, 0x43, 0xaf, 0x88, 0x12}; - uint8_t bytesprops4[] = {0x3a, 0x8c, 0x47, 0x92, 0xf0, 0x3b, 0x86, 0x1e, 0x6e, 0x2a, 0x11, 0x8f, 0x64, 0xb1, - 0xe1, 0x99, 0x1a, 0x52, 0x6f, 0xb2, 0x38, 0xf8, 0x7c, 0x3a, 0xf, 0x91, 0x81, 0xb4}; + uint8_t pkt[] = { + 0xa2, 0xe0, 0x1, 0x4, 0xe7, 0x69, 0x23, 0x10, 0x42, 0x1, 0xfe, 0x26, 0x0, 0x1a, 0x35, 0xb4, 0x30, 0xd1, 0x60, + 0xf1, 0x13, 0x51, 0x99, 0xae, 0x4f, 0x3, 0x8, 0x63, 0x3c, 0x3c, 0xa2, 0x5b, 0x8d, 0x81, 0x50, 0xdc, 0xd8, 0x94, + 0xdc, 0x78, 0x0, 0x10, 0x92, 0x53, 0xfc, 0xe2, 0x5c, 0x95, 0xb5, 0xca, 0x1f,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x53, 0xfc, 0xe2, 0x5c, 0x95, 0xb5, 0xca, + 0x1f, 0x91, 0x8, 0xb6, 0xdf, 0xea, 0xad, 0xe0}; + uint8_t bytesprops0[] = {0x35, 0xb4, 0x30, 0xd1, 0x60, 0xf1, 0x13, 0x51, 0x99, 0xae, 0x4f, 0x3, 0x8, + 0x63, 0x3c, 0x3c, 0xa2, 0x5b, 0x8d, 0x81, 0x50, 0xdc, 0xd8, 0x94, 0xdc, 0x78}; + uint8_t bytesprops3[] = {0x6d, 0xfb, 0x93, 0xc, 0x59, 0xb2, 0x91, 0x87, 0xd1, 0xc7, 0xf8, 0x2d, 0x73, 0x30}; + uint8_t bytesprops2[] = {0x74, 0xb9, 0x93}; + uint8_t bytesprops4[] = {0xe7, 0xfc, 0xf8, 0x96, 0x49, 0x2, 0xb0, 0x10, 0x7a, 0xde, + 0xc9, 0xf, 0x12, 0x0, 0xc1, 0x51, 0xcf, 0x2a, 0x20}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16745}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14379}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11089}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24719}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9537}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 973}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4162}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 254}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops2}, .v = {14, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9939}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x6a, 0xfb, 0x6a, 0xa0, 0xf3, 0xeb, 0x20, 0xd, 0xf6, 0x52, 0xc0, 0xea, - 0x6c, 0x12, 0x2e, 0x99, 0x90, 0x76, 0x15, 0x1e, 0x58, 0x7a, 0x7f, 0x3a}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x99, 0x1d, 0x49, 0xb9, 0x4b, 0xe5, 0x7, 0x45, + 0x2a, 0x54, 0xeb, 0x3f, 0x35, 0x2a, 0x28}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x14, 0x16, 0xf0, 0xe3, 0x53, 0x21, 0x3, 0x17, 0x53, 0xb3, 0xf5, 0x74, - 0xb9, 0x44, 0x2b, 0xe1, 0x33, 0x6e, 0x7e, 0x92, 0x7a, 0xc2, 0x8f}; - lwmqtt_string_t topic_filter_s1 = {23, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x39, 0xe1, 0x3d, 0x29, 0xc6, 0x96, 0xf5, 0xc0, 0x82, 0xc2, + 0x4e, 0xcc, 0x64, 0x89, 0xa2, 0x28, 0xf8, 0x8e, 0x6e}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xa3, 0xa8, 0x7f, 0xc1, 0xfe, 0xa1, 0xfa, 0xa6, 0xcc, 0xdd, 0xe7, 0xfa, + 0x39, 0xe4, 0xca, 0xa3, 0xa2, 0x25, 0xf2, 0x63, 0xdf, 0xd9, 0xfa, 0xb6}; + lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xff, 0xc9, 0xf7, 0x39, 0x14, 0x3f, 0xff, 0xe5, 0xf, 0x4, 0xe4, 0x66, + 0x63, 0x17, 0xb1, 0xe1, 0x2b, 0x62, 0x9f, 0x35, 0x4f, 0xda, 0x6, 0x84}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xfb, 0xa, 0x16, 0x7e, 0x1e, 0xb4, 0xac, 0x79, 0x1e, 0xc, 0xe4, 0xd3, 0x2a, 0xd6}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x55, 0x71, 0xd7, 0x73, 0xf4, 0x59}; + lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0}; + lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12542, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1255, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22335 ["\171r\247N1\218","4\149\209gL^\241\220\171\227{YRF8\184,\212\205\157"] [PropTopicAlias -// 10559,PropContentType "\211M\158\190",PropPayloadFormatIndicator 171,PropServerKeepAlive -// 3533,PropSubscriptionIdentifier 8,PropRequestResponseInformation 48,PropSubscriptionIdentifierAvailable -// 232,PropPayloadFormatIndicator 146,PropMessageExpiryInterval 26688,PropWillDelayInterval -// 11039,PropSubscriptionIdentifierAvailable 95,PropServerKeepAlive 27841,PropAuthenticationMethod -// "4c:\156-\214\161M\223\212\EOT\168\b",PropServerReference "\f\249\&0\EOT\154"] +// UnsubscribeRequest 22682 +// ["\DEL\148\206K\136Hx\216\137\137*\209\248*\186\130\163\206@\US%\179s","\232\&0\131\241\219a\152\207V\185\213v\186[\165\191\DC4`K\144\228\194\ETBVgW","\195\211\171c\216\f\DC2\165`\183Pj\228\216~\238@","5\234\US\174\183$\196V\DLE\168\247\255","h7\224\134\254\229\GSn\131_1\200>e","H\ETB\172+\157d!VF\131\157!\EM\201","\179U.\225i\222\SYN\136b\NULw\SOH\187\&1M\135p:","Y\189?\174\nQyM\165.\"\ENQ\140__\192\254\187\228","\239\222\226\181\184\209\133\199\&7O\254\175","\EOT\229\DC4.X\129\129\&5\204;\230"] +// [PropTopicAliasMaximum 15955,PropSubscriptionIdentifierAvailable 218,PropAuthenticationData +// ",'\230\136\175\237L^S",PropMessageExpiryInterval 20146,PropSharedSubscriptionAvailable 119,PropMaximumPacketSize +// 717,PropMaximumQoS 165,PropUserProperty "e\\ +// \193\USx\224\213ke\ESC\182\207\&5\145\169\&3\195\165\252\DELw\247l\205tT\147\DC4" +// "\CAN\243\223A\186\155\b\201\206\190m\138\131\252\213<\173\&6\131\184\&5Qc\206",PropAssignedClientIdentifier +// "&\195\165\134\165~UM\243\248\203\&9\ETB|\141*\234\129\149\212",PropServerKeepAlive 16880,PropMessageExpiryInterval +// 32380,PropMessageExpiryInterval 24349,PropTopicAliasMaximum 10485] TEST(Unsubscribe5QCTest, Encode15) { - uint8_t pkt[] = {0xa2, 0x5f, 0x57, 0x3f, 0x3e, 0x23, 0x29, 0x3f, 0x3, 0x0, 0x4, 0xd3, 0x4d, 0x9e, 0xbe, 0x1, 0xab, - 0x13, 0xd, 0xcd, 0xb, 0x8, 0x19, 0x30, 0x29, 0xe8, 0x1, 0x92, 0x2, 0x0, 0x0, 0x68, 0x40, 0x18, - 0x0, 0x0, 0x2b, 0x1f, 0x29, 0x5f, 0x13, 0x6c, 0xc1, 0x15, 0x0, 0xd, 0x34, 0x63, 0x3a, 0x9c, 0x2d, - 0xd6, 0xa1, 0x4d, 0xdf, 0xd4, 0x4, 0xa8, 0x8, 0x1c, 0x0, 0x5, 0xc, 0xf9, 0x30, 0x4, 0x9a, 0x0, - 0x6, 0xab, 0x72, 0xf7, 0x4e, 0x31, 0xda, 0x0, 0x14, 0x34, 0x95, 0xd1, 0x67, 0x4c, 0x5e, 0xf1, 0xdc, - 0xab, 0xe3, 0x7b, 0x59, 0x52, 0x46, 0x38, 0xb8, 0x2c, 0xd4, 0xcd, 0x9d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd3, 0x4d, 0x9e, 0xbe}; - uint8_t bytesprops1[] = {0x34, 0x63, 0x3a, 0x9c, 0x2d, 0xd6, 0xa1, 0x4d, 0xdf, 0xd4, 0x4, 0xa8, 0x8}; - uint8_t bytesprops2[] = {0xc, 0xf9, 0x30, 0x4, 0x9a}; + uint8_t pkt[] = { + 0xa2, 0xbe, 0x2, 0x58, 0x9a, 0x80, 0x1, 0x22, 0x3e, 0x53, 0x29, 0xda, 0x16, 0x0, 0x9, 0x2c, 0x27, 0xe6, 0x88, + 0xaf, 0xed, 0x4c, 0x5e, 0x53, 0x2, 0x0, 0x0, 0x4e, 0xb2, 0x2a, 0x77, 0x27, 0x0, 0x0, 0x2, 0xcd, 0x24, 0xa5, + 0x26, 0x0, 0x1d, 0x65, 0x5c, 0x20, 0xc1, 0x1f, 0x78, 0xe0, 0xd5, 0x6b, 0x65, 0x1b, 0xb6, 0xcf, 0x35, 0x91, 0xa9, + 0x33, 0xc3, 0xa5, 0xfc, 0x7f, 0x77, 0xf7, 0x6c, 0xcd, 0x74, 0x54, 0x93, 0x14, 0x0, 0x18, 0x18, 0xf3, 0xdf, 0x41, + 0xba, 0x9b, 0x8, 0xc9, 0xce, 0xbe, 0x6d, 0x8a, 0x83, 0xfc, 0xd5, 0x3c, 0xad, 0x36, 0x83, 0xb8, 0x35, 0x51, 0x63, + 0xce, 0x12, 0x0, 0x14, 0x26, 0xc3, 0xa5, 0x86, 0xa5, 0x7e, 0x55, 0x4d, 0xf3, 0xf8, 0xcb, 0x39, 0x17, 0x7c, 0x8d, + 0x2a, 0xea, 0x81, 0x95, 0xd4, 0x13, 0x41, 0xf0, 0x2, 0x0, 0x0, 0x7e, 0x7c, 0x2, 0x0, 0x0, 0x5f, 0x1d, 0x22, + 0x28, 0xf5, 0x0, 0x17, 0x7f, 0x94, 0xce, 0x4b, 0x88, 0x48, 0x78, 0xd8, 0x89, 0x89, 0x2a, 0xd1, 0xf8, 0x2a, 0xba, + 0x82, 0xa3, 0xce, 0x40, 0x1f, 0x25, 0xb3, 0x73, 0x0, 0x1a, 0xe8, 0x30, 0x83, 0xf1, 0xdb, 0x61, 0x98, 0xcf, 0x56, + 0xb9, 0xd5, 0x76, 0xba, 0x5b, 0xa5, 0xbf, 0x14, 0x60, 0x4b, 0x90, 0xe4, 0xc2, 0x17, 0x56, 0x67, 0x57, 0x0, 0x11, + 0xc3, 0xd3, 0xab, 0x63, 0xd8, 0xc, 0x12, 0xa5, 0x60, 0xb7, 0x50, 0x6a, 0xe4, 0xd8, 0x7e, 0xee, 0x40, 0x0, 0xc, + 0x35, 0xea, 0x1f, 0xae, 0xb7, 0x24, 0xc4, 0x56, 0x10, 0xa8, 0xf7, 0xff, 0x0, 0xe, 0x68, 0x37, 0xe0, 0x86, 0xfe, + 0xe5, 0x1d, 0x6e, 0x83, 0x5f, 0x31, 0xc8, 0x3e, 0x65, 0x0, 0xe, 0x48, 0x17, 0xac, 0x2b, 0x9d, 0x64, 0x21, 0x56, + 0x46, 0x83, 0x9d, 0x21, 0x19, 0xc9, 0x0, 0x12, 0xb3, 0x55, 0x2e, 0xe1, 0x69, 0xde, 0x16, 0x88, 0x62, 0x0, 0x77, + 0x1, 0xbb, 0x31, 0x4d, 0x87, 0x70, 0x3a, 0x0, 0x13, 0x59, 0xbd, 0x3f, 0xae, 0xa, 0x51, 0x79, 0x4d, 0xa5, 0x2e, + 0x22, 0x5, 0x8c, 0x5f, 0x5f, 0xc0, 0xfe, 0xbb, 0xe4, 0x0, 0xc, 0xef, 0xde, 0xe2, 0xb5, 0xb8, 0xd1, 0x85, 0xc7, + 0x37, 0x4f, 0xfe, 0xaf, 0x0, 0xb, 0x4, 0xe5, 0x14, 0x2e, 0x58, 0x81, 0x81, 0x35, 0xcc, 0x3b, 0xe6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x2c, 0x27, 0xe6, 0x88, 0xaf, 0xed, 0x4c, 0x5e, 0x53}; + uint8_t bytesprops2[] = {0x18, 0xf3, 0xdf, 0x41, 0xba, 0x9b, 0x8, 0xc9, 0xce, 0xbe, 0x6d, 0x8a, + 0x83, 0xfc, 0xd5, 0x3c, 0xad, 0x36, 0x83, 0xb8, 0x35, 0x51, 0x63, 0xce}; + uint8_t bytesprops1[] = {0x65, 0x5c, 0x20, 0xc1, 0x1f, 0x78, 0xe0, 0xd5, 0x6b, 0x65, 0x1b, 0xb6, 0xcf, 0x35, 0x91, + 0xa9, 0x33, 0xc3, 0xa5, 0xfc, 0x7f, 0x77, 0xf7, 0x6c, 0xcd, 0x74, 0x54, 0x93, 0x14}; + uint8_t bytesprops3[] = {0x26, 0xc3, 0xa5, 0x86, 0xa5, 0x7e, 0x55, 0x4d, 0xf3, 0xf8, + 0xcb, 0x39, 0x17, 0x7c, 0x8d, 0x2a, 0xea, 0x81, 0x95, 0xd4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10559}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3533}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26688}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11039}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27841}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15955}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20146}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 717}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {24, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16880}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32380}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24349}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10485}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xab, 0x72, 0xf7, 0x4e, 0x31, 0xda}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x7f, 0x94, 0xce, 0x4b, 0x88, 0x48, 0x78, 0xd8, 0x89, 0x89, 0x2a, 0xd1, + 0xf8, 0x2a, 0xba, 0x82, 0xa3, 0xce, 0x40, 0x1f, 0x25, 0xb3, 0x73}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x34, 0x95, 0xd1, 0x67, 0x4c, 0x5e, 0xf1, 0xdc, 0xab, 0xe3, - 0x7b, 0x59, 0x52, 0x46, 0x38, 0xb8, 0x2c, 0xd4, 0xcd, 0x9d}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe8, 0x30, 0x83, 0xf1, 0xdb, 0x61, 0x98, 0xcf, 0x56, 0xb9, 0xd5, 0x76, 0xba, + 0x5b, 0xa5, 0xbf, 0x14, 0x60, 0x4b, 0x90, 0xe4, 0xc2, 0x17, 0x56, 0x67, 0x57}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xc3, 0xd3, 0xab, 0x63, 0xd8, 0xc, 0x12, 0xa5, 0x60, + 0xb7, 0x50, 0x6a, 0xe4, 0xd8, 0x7e, 0xee, 0x40}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x35, 0xea, 0x1f, 0xae, 0xb7, 0x24, 0xc4, 0x56, 0x10, 0xa8, 0xf7, 0xff}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x68, 0x37, 0xe0, 0x86, 0xfe, 0xe5, 0x1d, + 0x6e, 0x83, 0x5f, 0x31, 0xc8, 0x3e, 0x65}; + lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x48, 0x17, 0xac, 0x2b, 0x9d, 0x64, 0x21, + 0x56, 0x46, 0x83, 0x9d, 0x21, 0x19, 0xc9}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xb3, 0x55, 0x2e, 0xe1, 0x69, 0xde, 0x16, 0x88, 0x62, + 0x0, 0x77, 0x1, 0xbb, 0x31, 0x4d, 0x87, 0x70, 0x3a}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x59, 0xbd, 0x3f, 0xae, 0xa, 0x51, 0x79, 0x4d, 0xa5, 0x2e, + 0x22, 0x5, 0x8c, 0x5f, 0x5f, 0xc0, 0xfe, 0xbb, 0xe4}; + lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xef, 0xde, 0xe2, 0xb5, 0xb8, 0xd1, 0x85, 0xc7, 0x37, 0x4f, 0xfe, 0xaf}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x4, 0xe5, 0x14, 0x2e, 0x58, 0x81, 0x81, 0x35, 0xcc, 0x3b, 0xe6}; + lwmqtt_string_t topic_filter_s9 = {11, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22335, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22682, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 6771 -// ["\135\US\219/\163+\FS-","\161\136\131Y\CAN\230t&\196\174\&4-\f\129\155\189N\211c\233\235q\138\227\250O\148\222\&3","JJ4\DEL\247{\189\166\DLE5\241-\195\141X\tN\138\248\171\247(\202Z\231\&6C\255","\182\r\144B[\233\NAK\194\179{\177\&6\206o\172h","","\163,+n\168M\SO\184\180","?\146X+Lw\191\EM\209\t\174\211\160s\192Fa\237\195\212\&1DY\131\163","z\255\213\SUBvQ\236M\152\208\149h","\137\237\131\198XD\SO^P\207\227\146\248\240\227}&\141\142v>\GS","\192\221\160N\167e\"R<\142",""] -// [PropRequestProblemInformation 48,PropSharedSubscriptionAvailable 181,PropRequestProblemInformation -// 98,PropMaximumPacketSize 23754,PropMaximumPacketSize 5686,PropTopicAlias 13579,PropRequestProblemInformation -// 156,PropMaximumPacketSize 28901,PropAssignedClientIdentifier "$m\243",PropServerKeepAlive 735,PropWillDelayInterval -// 24039,PropCorrelationData "d\190/\128%$\147\136\193U\141%\223\ENQ\218r\CAN",PropRetainAvailable 178,PropTopicAlias -// 30758,PropMessageExpiryInterval 10917,PropWildcardSubscriptionAvailable 54,PropContentType -// "\236\179^\ETB\151\159\FSd&I\139"] +// UnsubscribeRequest 24213 ["\253g\ETX\138\DLEW\170\231\214\133H\RS\206+f|@C\175*,\178\EM"] [PropReasonString +// "\186\180\226c\131\202\223\151\STX`",PropServerReference "x\218\225\CAN\220\235E\DC3t",PropContentType +// "\238c\t\181\SOH\159y\196?\EM\228\241\150",PropPayloadFormatIndicator 49,PropReasonString +// "\177u\EOT\140y\182\SIP\159X",PropSessionExpiryInterval 22727,PropSharedSubscriptionAvailable +// 247,PropWillDelayInterval 17613,PropMaximumQoS 207,PropMaximumPacketSize 23689,PropServerKeepAlive +// 3885,PropContentType "\241,$\a\253H\233\190A\241g\"\184Z\171\233\203Q4\186d\"=\163%M\180",PropSessionExpiryInterval +// 24885,PropMaximumQoS 39,PropServerKeepAlive 2980] TEST(Unsubscribe5QCTest, Encode16) { - uint8_t pkt[] = { - 0xa2, 0x8e, 0x2, 0x1a, 0x73, 0x56, 0x17, 0x30, 0x2a, 0xb5, 0x17, 0x62, 0x27, 0x0, 0x0, 0x5c, 0xca, 0x27, 0x0, - 0x0, 0x16, 0x36, 0x23, 0x35, 0xb, 0x17, 0x9c, 0x27, 0x0, 0x0, 0x70, 0xe5, 0x12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, 0x83, 0xa3, 0x0, 0xc, 0x7a, 0xff, 0xd5, 0x1a, 0x76, - 0x51, 0xec, 0x4d, 0x98, 0xd0, 0x95, 0x68, 0x0, 0x16, 0x89, 0xed, 0x83, 0xc6, 0x58, 0x44, 0xe, 0x5e, 0x50, 0xcf, - 0xe3, 0x92, 0xf8, 0xf0, 0xe3, 0x7d, 0x26, 0x8d, 0x8e, 0x76, 0x3e, 0x1d, 0x0, 0xa, 0xc0, 0xdd, 0xa0, 0x4e, 0xa7, - 0x65, 0x22, 0x52, 0x3c, 0x8e, 0x0, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x24, 0x6d, 0xf3}; - uint8_t bytesprops1[] = {0x64, 0xbe, 0x2f, 0x80, 0x25, 0x24, 0x93, 0x88, 0xc1, - 0x55, 0x8d, 0x25, 0xdf, 0x5, 0xda, 0x72, 0x18}; - uint8_t bytesprops2[] = {0xec, 0xb3, 0x5e, 0x17, 0x97, 0x9f, 0x1c, 0x64, 0x26, 0x49, 0x8b}; + uint8_t pkt[] = {0xa2, 0x92, 0x1, 0x5e, 0x95, 0x76, 0x1f, 0x0, 0xa, 0xba, 0xb4, 0xe2, 0x63, 0x83, 0xca, 0xdf, 0x97, + 0x2, 0x60, 0x1c, 0x0, 0x9, 0x78, 0xda, 0xe1, 0x18, 0xdc, 0xeb, 0x45, 0x13, 0x74, 0x3, 0x0, 0xd, + 0xee, 0x63, 0x9, 0xb5, 0x1, 0x9f, 0x79, 0xc4, 0x3f, 0x19, 0xe4, 0xf1, 0x96, 0x1, 0x31, 0x1f, 0x0, + 0xa, 0xb1, 0x75, 0x4, 0x8c, 0x79, 0xb6, 0xf, 0x50, 0x9f, 0x58, 0x11, 0x0, 0x0, 0x58, 0xc7, 0x2a, + 0xf7, 0x18, 0x0, 0x0, 0x44, 0xcd, 0x24, 0xcf, 0x27, 0x0, 0x0, 0x5c, 0x89, 0x13, 0xf, 0x2d, 0x3, + 0x0, 0x1b, 0xf1, 0x2c, 0x24, 0x7, 0xfd, 0x48, 0xe9, 0xbe, 0x41, 0xf1, 0x67, 0x22, 0xb8, 0x5a, 0xab, + 0xe9, 0xcb, 0x51, 0x34, 0xba, 0x64, 0x22, 0x3d, 0xa3, 0x25, 0x4d, 0xb4, 0x11, 0x0, 0x0, 0x61, 0x35, + 0x24, 0x27, 0x13, 0xb, 0xa4, 0x0, 0x17, 0xfd, 0x67, 0x3, 0x8a, 0x10, 0x57, 0xaa, 0xe7, 0xd6, 0x85, + 0x48, 0x1e, 0xce, 0x2b, 0x66, 0x7c, 0x40, 0x43, 0xaf, 0x2a, 0x2c, 0xb2, 0x19}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xba, 0xb4, 0xe2, 0x63, 0x83, 0xca, 0xdf, 0x97, 0x2, 0x60}; + uint8_t bytesprops1[] = {0x78, 0xda, 0xe1, 0x18, 0xdc, 0xeb, 0x45, 0x13, 0x74}; + uint8_t bytesprops2[] = {0xee, 0x63, 0x9, 0xb5, 0x1, 0x9f, 0x79, 0xc4, 0x3f, 0x19, 0xe4, 0xf1, 0x96}; + uint8_t bytesprops3[] = {0xb1, 0x75, 0x4, 0x8c, 0x79, 0xb6, 0xf, 0x50, 0x9f, 0x58}; + uint8_t bytesprops4[] = {0xf1, 0x2c, 0x24, 0x7, 0xfd, 0x48, 0xe9, 0xbe, 0x41, 0xf1, 0x67, 0x22, 0xb8, 0x5a, + 0xab, 0xe9, 0xcb, 0x51, 0x34, 0xba, 0x64, 0x22, 0x3d, 0xa3, 0x25, 0x4d, 0xb4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23754}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5686}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13579}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28901}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 735}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24039}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30758}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10917}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22727}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17613}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23689}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3885}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24885}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2980}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x87, 0x1f, 0xdb, 0x2f, 0xa3, 0x2b, 0x1c, 0x2d}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xfd, 0x67, 0x3, 0x8a, 0x10, 0x57, 0xaa, 0xe7, 0xd6, 0x85, 0x48, 0x1e, + 0xce, 0x2b, 0x66, 0x7c, 0x40, 0x43, 0xaf, 0x2a, 0x2c, 0xb2, 0x19}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa1, 0x88, 0x83, 0x59, 0x18, 0xe6, 0x74, 0x26, 0xc4, 0xae, - 0x34, 0x2d, 0xc, 0x81, 0x9b, 0xbd, 0x4e, 0xd3, 0x63, 0xe9, - 0xeb, 0x71, 0x8a, 0xe3, 0xfa, 0x4f, 0x94, 0xde, 0x33}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4a, 0x4a, 0x34, 0x7f, 0xf7, 0x7b, 0xbd, 0xa6, 0x10, 0x35, - 0xf1, 0x2d, 0xc3, 0x8d, 0x58, 0x9, 0x4e, 0x8a, 0xf8, 0xab, - 0xf7, 0x28, 0xca, 0x5a, 0xe7, 0x36, 0x43, 0xff}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xb6, 0xd, 0x90, 0x42, 0x5b, 0xe9, 0x15, 0xc2, - 0xb3, 0x7b, 0xb1, 0x36, 0xce, 0x6f, 0xac, 0x68}; - lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0}; - lwmqtt_string_t topic_filter_s4 = {0, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa3, 0x2c, 0x2b, 0x6e, 0xa8, 0x4d, 0xe, 0xb8, 0xb4}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3f, 0x92, 0x58, 0x2b, 0x4c, 0x77, 0xbf, 0x19, 0xd1, 0x9, 0xae, 0xd3, 0xa0, - 0x73, 0xc0, 0x46, 0x61, 0xed, 0xc3, 0xd4, 0x31, 0x44, 0x59, 0x83, 0xa3}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7a, 0xff, 0xd5, 0x1a, 0x76, 0x51, 0xec, 0x4d, 0x98, 0xd0, 0x95, 0x68}; - lwmqtt_string_t topic_filter_s7 = {12, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x89, 0xed, 0x83, 0xc6, 0x58, 0x44, 0xe, 0x5e, 0x50, 0xcf, 0xe3, - 0x92, 0xf8, 0xf0, 0xe3, 0x7d, 0x26, 0x8d, 0x8e, 0x76, 0x3e, 0x1d}; - lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xc0, 0xdd, 0xa0, 0x4e, 0xa7, 0x65, 0x22, 0x52, 0x3c, 0x8e}; - lwmqtt_string_t topic_filter_s9 = {10, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0}; - lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6771, 11, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24213, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 19984 -// ["I|\192\176@\ETB\219a\254\217\n\238\172\EOT\202\143*?\ETB\130\172\174\CAN\DEL\177\163","~V\240~\192","b6\189\&0\244q","\143\166/\SO\r\r\240\212\181\136\172$\233\243\149\&70h_|\204\136 -// \206\146\134\236\&6\179","\157\168\227\SOH\242\183\153\nO\235\DEL\aW\227\196\225\179\210s\174\FS\155(\t\137\158\229","\ESCl\130\ACK\135\&4,D\208\141\243s\n*F*","\170\194\223-H\208r]UF+\221\\.\187\225\135]x\218\140on\180\233","\194\f\246\&1n\154\DC1\195\170\161\232\152\185\222\ESC"] -// [PropServerReference "K\143\138",PropMaximumQoS 8,PropServerKeepAlive 1748,PropAuthenticationData -// "\t\128XT\154gS\137\155\169*\161T\235U%\210\GS\245\242B\247\155\181\172\179do",PropServerReference -// "\181K\177\155",PropMaximumQoS 21,PropMessageExpiryInterval 5656,PropResponseInformation -// "\193\250Wq\170\178",PropSubscriptionIdentifierAvailable 224,PropWildcardSubscriptionAvailable -// 4,PropMaximumPacketSize 12873,PropWildcardSubscriptionAvailable 89,PropMessageExpiryInterval -// 15950,PropWillDelayInterval 2869,PropRetainAvailable 154,PropResponseTopic "\168\227\153",PropRetainAvailable -// 219,PropServerReference "=r\180gs\232#\253\249\138\192\STX\250",PropMessageExpiryInterval 32704,PropWillDelayInterval -// 25062,PropReceiveMaximum 20057,PropContentType "\146@\169D}\ENQ\DC2a",PropRequestProblemInformation -// 29,PropWillDelayInterval 22196,PropPayloadFormatIndicator 196,PropPayloadFormatIndicator 88] +// UnsubscribeRequest 26833 ["U\246\DEL\"\254\131\166\165\187} +// \200\GShm\235K\206G\207\253\148\237\168#\193","\250","\234\199f)*\128@\216\214'\215\213","\SO\NULF\227\255\SUBc\189X\168\213\213","\DC2Q\176m\\J","!f2>\204\138\CAN\NUL:\235\222"] +// [PropWildcardSubscriptionAvailable 200,PropSharedSubscriptionAvailable 227,PropMessageExpiryInterval +// 13811,PropSubscriptionIdentifier 14,PropServerKeepAlive 18124,PropRequestResponseInformation +// 22,PropAuthenticationData "3;\135\242nm2\175w\164\185\230 \240\194\209\137J,\SIk\129\235",PropAuthenticationData +// "W2",PropReasonString "",PropAuthenticationMethod +// "\141L\254\172y\221\160\177\162Q\253M\139a\175C\214>\SUB\DC1\144\&9'\188f7\195",PropAuthenticationData +// "\131K\255k\244\226\171\205\241"] TEST(Unsubscribe5QCTest, Encode17) { - uint8_t pkt[] = { - 0xa2, 0xbc, 0x2, 0x4e, 0x10, 0x93, 0x1, 0x1c, 0x0, 0x3, 0x4b, 0x8f, 0x8a, 0x24, 0x8, 0x13, 0x6, 0xd4, 0x16, - 0x0, 0x1c, 0x9, 0x80, 0x58, 0x54, 0x9a, 0x67, 0x53, 0x89, 0x9b, 0xa9, 0x2a, 0xa1, 0x54, 0xeb, 0x55, 0x25, 0xd2, - 0x1d, 0xf5, 0xf2, 0x42, 0xf7, 0x9b, 0xb5, 0xac, 0xb3, 0x64, 0x6f, 0x1c, 0x0, 0x4, 0xb5, 0x4b, 0xb1, 0x9b, 0x24, - 0x15, 0x2, 0x0, 0x0, 0x16, 0x18, 0x1a, 0x0, 0x6, 0xc1, 0xfa, 0x57, 0x71, 0xaa, 0xb2, 0x29, 0xe0, 0x28, 0x4, - 0x27, 0x0, 0x0, 0x32, 0x49, 0x28, 0x59, 0x2, 0x0, 0x0, 0x3e, 0x4e, 0x18, 0x0, 0x0, 0xb, 0x35, 0x25, 0x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d, 0x48, 0xd0, 0x72, 0x5d, - 0x55, 0x46, 0x2b, 0xdd, 0x5c, 0x2e, 0xbb, 0xe1, 0x87, 0x5d, 0x78, 0xda, 0x8c, 0x6f, 0x6e, 0xb4, 0xe9, 0x0, 0xf, - 0xc2, 0xc, 0xf6, 0x31, 0x6e, 0x9a, 0x11, 0xc3, 0xaa, 0xa1, 0xe8, 0x98, 0xb9, 0xde, 0x1b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x4b, 0x8f, 0x8a}; - uint8_t bytesprops1[] = {0x9, 0x80, 0x58, 0x54, 0x9a, 0x67, 0x53, 0x89, 0x9b, 0xa9, 0x2a, 0xa1, 0x54, 0xeb, - 0x55, 0x25, 0xd2, 0x1d, 0xf5, 0xf2, 0x42, 0xf7, 0x9b, 0xb5, 0xac, 0xb3, 0x64, 0x6f}; - uint8_t bytesprops2[] = {0xb5, 0x4b, 0xb1, 0x9b}; - uint8_t bytesprops3[] = {0xc1, 0xfa, 0x57, 0x71, 0xaa, 0xb2}; - uint8_t bytesprops4[] = {0xa8, 0xe3, 0x99}; - uint8_t bytesprops5[] = {0x3d, 0x72, 0xb4, 0x67, 0x73, 0xe8, 0x23, 0xfd, 0xf9, 0x8a, 0xc0, 0x2, 0xfa}; - uint8_t bytesprops6[] = {0x92, 0x40, 0xa9, 0x44, 0x7d, 0x5, 0x12, 0x61}; + uint8_t pkt[] = {0xa2, 0xaf, 0x1, 0x68, 0xd1, 0x5c, 0x28, 0xc8, 0x2a, 0xe3, 0x2, 0x0, 0x0, 0x35, 0xf3, 0xb, 0xe, + 0x13, 0x46, 0xcc, 0x19, 0x16, 0x16, 0x0, 0x17, 0x33, 0x3b, 0x87, 0xf2, 0x6e, 0x6d, 0x32, 0xaf, 0x77, + 0xa4, 0xb9, 0xe6, 0x20, 0xf0, 0xc2, 0xd1, 0x89, 0x4a, 0x2c, 0xf, 0x6b, 0x81, 0xeb, 0x16, 0x0, 0x2, + 0x57, 0x32, 0x1f, 0x0, 0x0, 0x15, 0x0, 0x1b, 0x8d, 0x4c, 0xfe, 0xac, 0x79, 0xdd, 0xa0, 0xb1, 0xa2, + 0x51, 0xfd, 0x4d, 0x8b, 0x61, 0xaf, 0x43, 0xd6, 0x3e, 0x1a, 0x11, 0x90, 0x39, 0x27, 0xbc, 0x66, 0x37, + 0xc3, 0x16, 0x0, 0x9, 0x83, 0x4b, 0xff, 0x6b, 0xf4, 0xe2, 0xab, 0xcd, 0xf1, 0x0, 0x1a, 0x55, 0xf6, + 0x7f, 0x22, 0xfe, 0x83, 0xa6, 0xa5, 0xbb, 0x7d, 0x20, 0xc8, 0x1d, 0x68, 0x6d, 0xeb, 0x4b, 0xce, 0x47, + 0xcf, 0xfd, 0x94, 0xed, 0xa8, 0x23, 0xc1, 0x0, 0x1, 0xfa, 0x0, 0xc, 0xea, 0xc7, 0x66, 0x29, 0x2a, + 0x80, 0x40, 0xd8, 0xd6, 0x27, 0xd7, 0xd5, 0x0, 0xc, 0xe, 0x0, 0x46, 0xe3, 0xff, 0x1a, 0x63, 0xbd, + 0x58, 0xa8, 0xd5, 0xd5, 0x0, 0x6, 0x12, 0x51, 0xb0, 0x6d, 0x5c, 0x4a, 0x0, 0xb, 0x21, 0x66, 0x32, + 0x3e, 0xcc, 0x8a, 0x18, 0x0, 0x3a, 0xeb, 0xde}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x33, 0x3b, 0x87, 0xf2, 0x6e, 0x6d, 0x32, 0xaf, 0x77, 0xa4, 0xb9, 0xe6, + 0x20, 0xf0, 0xc2, 0xd1, 0x89, 0x4a, 0x2c, 0xf, 0x6b, 0x81, 0xeb}; + uint8_t bytesprops1[] = {0x57, 0x32}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x8d, 0x4c, 0xfe, 0xac, 0x79, 0xdd, 0xa0, 0xb1, 0xa2, 0x51, 0xfd, 0x4d, 0x8b, 0x61, + 0xaf, 0x43, 0xd6, 0x3e, 0x1a, 0x11, 0x90, 0x39, 0x27, 0xbc, 0x66, 0x37, 0xc3}; + uint8_t bytesprops4[] = {0x83, 0x4b, 0xff, 0x6b, 0xf4, 0xe2, 0xab, 0xcd, 0xf1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1748}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5656}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12873}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15950}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2869}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32704}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25062}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20057}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22196}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13811}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18124}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x49, 0x7c, 0xc0, 0xb0, 0x40, 0x17, 0xdb, 0x61, 0xfe, 0xd9, 0xa, 0xee, 0xac, - 0x4, 0xca, 0x8f, 0x2a, 0x3f, 0x17, 0x82, 0xac, 0xae, 0x18, 0x7f, 0xb1, 0xa3}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x55, 0xf6, 0x7f, 0x22, 0xfe, 0x83, 0xa6, 0xa5, 0xbb, 0x7d, 0x20, 0xc8, 0x1d, + 0x68, 0x6d, 0xeb, 0x4b, 0xce, 0x47, 0xcf, 0xfd, 0x94, 0xed, 0xa8, 0x23, 0xc1}; lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7e, 0x56, 0xf0, 0x7e, 0xc0}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xfa}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x62, 0x36, 0xbd, 0x30, 0xf4, 0x71}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xea, 0xc7, 0x66, 0x29, 0x2a, 0x80, 0x40, 0xd8, 0xd6, 0x27, 0xd7, 0xd5}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8f, 0xa6, 0x2f, 0xe, 0xd, 0xd, 0xf0, 0xd4, 0xb5, 0x88, - 0xac, 0x24, 0xe9, 0xf3, 0x95, 0x37, 0x30, 0x68, 0x5f, 0x7c, - 0xcc, 0x88, 0x20, 0xce, 0x92, 0x86, 0xec, 0x36, 0xb3}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xe, 0x0, 0x46, 0xe3, 0xff, 0x1a, 0x63, 0xbd, 0x58, 0xa8, 0xd5, 0xd5}; + lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9d, 0xa8, 0xe3, 0x1, 0xf2, 0xb7, 0x99, 0xa, 0x4f, 0xeb, 0x7f, 0x7, 0x57, 0xe3, - 0xc4, 0xe1, 0xb3, 0xd2, 0x73, 0xae, 0x1c, 0x9b, 0x28, 0x9, 0x89, 0x9e, 0xe5}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x12, 0x51, 0xb0, 0x6d, 0x5c, 0x4a}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1b, 0x6c, 0x82, 0x6, 0x87, 0x34, 0x2c, 0x44, - 0xd0, 0x8d, 0xf3, 0x73, 0xa, 0x2a, 0x46, 0x2a}; - lwmqtt_string_t topic_filter_s5 = {16, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x21, 0x66, 0x32, 0x3e, 0xcc, 0x8a, 0x18, 0x0, 0x3a, 0xeb, 0xde}; + lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xaa, 0xc2, 0xdf, 0x2d, 0x48, 0xd0, 0x72, 0x5d, 0x55, 0x46, 0x2b, 0xdd, 0x5c, - 0x2e, 0xbb, 0xe1, 0x87, 0x5d, 0x78, 0xda, 0x8c, 0x6f, 0x6e, 0xb4, 0xe9}; - lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xc2, 0xc, 0xf6, 0x31, 0x6e, 0x9a, 0x11, 0xc3, - 0xaa, 0xa1, 0xe8, 0x98, 0xb9, 0xde, 0x1b}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19984, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26833, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 8587 -// ["^\158\181\192J\FS\249","\248\243\ACK\NULSg}\128\177\154\&2\SUB-\242\GS\229\t\NAK\US\189m\225\230I\FS","\SUB\194\179C\203\152","\244#\152\175\194\153\231\239\ETBD\146Q\248g\246w\143K\194\245\181","\DC4\tIs\155jp\197\SYN'1,G(P\NAK$\163\144\146\159\USY\194M\151\157\255","\236\159","\228\132\130\254\213\173\&1\202\&0\136\135\231\157\167p\199}\139\ETX -// \191\189\168\245\227\DC2}","\233mc\155K\b!\RSu\SUB","t\178\DEL\DELy\240\224\228\141\238\EOT\EM\153;\190\234","\128xS\199\240\228\&0R\vR\180\&3\217\179\162H\189%\192\247\195e\179t\RS\"x\DC1my","\246\ESC\248\136\ETX>\225\204\ACK\136\170\"\v\232\253\219\199=\ACK"] -// [PropMaximumQoS 241,PropServerKeepAlive 10894,PropResponseInformation "\FStN\244\173",PropContentType -// "`\183\173SH\237\225\251",PropResponseInformation "\227\226t\SYN\164\&6F \228\253\ENQ\177\SO\241\209/",PropTopicAlias -// 20782,PropSubscriptionIdentifierAvailable 123,PropWildcardSubscriptionAvailable 79,PropRetainAvailable -// 160,PropServerReference "\195\200\ETX\146\221/d\129h\135\SI+\241i",PropRequestProblemInformation -// 13,PropSessionExpiryInterval 10666,PropAuthenticationMethod -// "\250\"K\169\132\187\RS\252%\146\210\196\DC1Q\144\235\ESC\175\a\CAN=\155\170\157.",PropResponseTopic -// "\232d\215A",PropMaximumPacketSize 3468,PropReceiveMaximum 31173,PropContentType -// "\243\179\216\DC3\b\230",PropContentType "\197\223)\f",PropTopicAliasMaximum 15968,PropMessageExpiryInterval 26426] +// UnsubscribeRequest 24597 ["\t\134\178\219\159\249\235\250\187","\166)\230\184Y\252\r.B"] [PropContentType +// "\240\211\EOT\253M(\135",PropServerKeepAlive 6586,PropReceiveMaximum 11671,PropAssignedClientIdentifier +// ":\151\235;\153&/d'Y\183V\227\212\200\223\148\238\204o\238\230\235\183\189\DC4\DC1",PropAuthenticationMethod +// "\DC1\DC1\207\184\DC4K\159\227\217\DC2\255\150",PropResponseInformation "^:k\148\222z\132\220&^",PropReceiveMaximum +// 9190,PropAuthenticationData "\219\EM\n\186\192\134\DC2\206/w\164T\STX\SO3>",PropUserProperty +// "\141j\SYN\159\212O\254\a\213\142\161?\NAK\255_\190\146\149'\180\169\214\246K@\154\230X" +// "\184\US\175\158\160\&6\153\SUBRRN\199$\219E4\214",PropSharedSubscriptionAvailable 44,PropContentType +// "\142\136\178\137\180\&23t\185\243a\207nB\200;\162w\193n\vX\163`h",PropSubscriptionIdentifier +// 11,PropMaximumPacketSize 24049,PropReceiveMaximum 24721,PropAssignedClientIdentifier +// "\237\FSGN\132j3%\DC3\vb\222\222aN",PropWildcardSubscriptionAvailable 128,PropWildcardSubscriptionAvailable +// 186,PropResponseInformation "]a]\148$\147\209:\204\164\207\155\251\f\143\194+\241\RS\200",PropPayloadFormatIndicator +// 42,PropMessageExpiryInterval 27416,PropMaximumQoS 5,PropTopicAlias 2410,PropReasonString +// "n\189k\144\152\197`}C_\242\SO\ENQ\240\a\ETXV\145\232\198T"] TEST(Unsubscribe5QCTest, Encode18) { uint8_t pkt[] = { - 0xa2, 0xe8, 0x2, 0x21, 0x8b, 0x8f, 0x1, 0x24, 0xf1, 0x13, 0x2a, 0x8e, 0x1a, 0x0, 0x5, 0x1c, 0x74, 0x4e, 0xf4, - 0xad, 0x3, 0x0, 0x8, 0x60, 0xb7, 0xad, 0x53, 0x48, 0xed, 0xe1, 0xfb, 0x1a, 0x0, 0x10, 0xe3, 0xe2, 0x74, 0x16, - 0xa4, 0x36, 0x46, 0x20, 0xe4, 0xfd, 0x5, 0xb1, 0xe, 0xf1, 0xd1, 0x2f, 0x23, 0x51, 0x2e, 0x29, 0x7b, 0x28, 0x4f, - 0x25, 0xa0, 0x1c, 0x0, 0xe, 0xc3, 0xc8, 0x3, 0x92, 0xdd, 0x2f, 0x64, 0x81, 0x68, 0x87, 0xf, 0x2b,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 0xca, 0x30, 0x88, 0x87, 0xe7, 0x9d, - 0xa7, 0x70, 0xc7, 0x7d, 0x8b, 0x3, 0x20, 0xbf, 0xbd, 0xa8, 0xf5, 0xe3, 0x12, 0x7d, 0x0, 0xa, 0xe9, 0x6d, 0x63, - 0x9b, 0x4b, 0x8, 0x21, 0x1e, 0x75, 0x1a, 0x0, 0x10, 0x74, 0xb2, 0x7f, 0x7f, 0x79, 0xf0, 0xe0, 0xe4, 0x8d, 0xee, - 0x4, 0x19, 0x99, 0x3b, 0xbe, 0xea, 0x0, 0x1e, 0x80, 0x78, 0x53, 0xc7, 0xf0, 0xe4, 0x30, 0x52, 0xb, 0x52, 0xb4, - 0x33, 0xd9, 0xb3, 0xa2, 0x48, 0xbd, 0x25, 0xc0, 0xf7, 0xc3, 0x65, 0xb3, 0x74, 0x1e, 0x22, 0x78, 0x11, 0x6d, 0x79, - 0x0, 0x13, 0xf6, 0x1b, 0xf8, 0x88, 0x3, 0x3e, 0xe1, 0xcc, 0x6, 0x88, 0xaa, 0x22, 0xb, 0xe8, 0xfd, 0xdb, 0xc7, - 0x3d, 0x6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1c, 0x74, 0x4e, 0xf4, 0xad}; - uint8_t bytesprops1[] = {0x60, 0xb7, 0xad, 0x53, 0x48, 0xed, 0xe1, 0xfb}; - uint8_t bytesprops2[] = {0xe3, 0xe2, 0x74, 0x16, 0xa4, 0x36, 0x46, 0x20, - 0xe4, 0xfd, 0x5, 0xb1, 0xe, 0xf1, 0xd1, 0x2f}; - uint8_t bytesprops3[] = {0xc3, 0xc8, 0x3, 0x92, 0xdd, 0x2f, 0x64, 0x81, 0x68, 0x87, 0xf, 0x2b, 0xf1, 0x69}; - uint8_t bytesprops4[] = {0xfa, 0x22, 0x4b, 0xa9, 0x84, 0xbb, 0x1e, 0xfc, 0x25, 0x92, 0xd2, 0xc4, 0x11, - 0x51, 0x90, 0xeb, 0x1b, 0xaf, 0x7, 0x18, 0x3d, 0x9b, 0xaa, 0x9d, 0x2e}; - uint8_t bytesprops5[] = {0xe8, 0x64, 0xd7, 0x41}; - uint8_t bytesprops6[] = {0xf3, 0xb3, 0xd8, 0x13, 0x8, 0xe6}; - uint8_t bytesprops7[] = {0xc5, 0xdf, 0x29, 0xc}; + 0xa2, 0xa5, 0x2, 0x60, 0x15, 0x8b, 0x2, 0x3, 0x0, 0x7, 0xf0, 0xd3, 0x4, 0xfd, 0x4d, 0x28, 0x87, 0x13, 0x19, + 0xba, 0x21, 0x2d, 0x97, 0x12, 0x0, 0x1b, 0x3a, 0x97, 0xeb, 0x3b, 0x99, 0x26, 0x2f, 0x64, 0x27, 0x59, 0xb7, 0x56, + 0xe3, 0xd4, 0xc8, 0xdf, 0x94, 0xee, 0xcc, 0x6f, 0xee, 0xe6, 0xeb, 0xb7, 0xbd, 0x14, 0x11, 0x15, 0x0, 0xc, 0x11, + 0x11, 0xcf, 0xb8, 0x14, 0x4b, 0x9f, 0xe3, 0xd9, 0x12, 0xff, 0x96, 0x1a, 0x0, 0xa, 0x5e, 0x3a, 0x6b, 0x94, 0xde, + 0x7a, 0x84, 0xdc, 0x26, 0x5e, 0x21, 0x23, 0xe6, 0x16, 0x0, 0x10, 0xdb, 0x19, 0xa, 0xba, 0xc0, 0x86, 0x12, 0xce, + 0x2f, 0x77, 0xa4, 0x54, 0x2, 0xe, 0x33, 0x3e, 0x26, 0x0, 0x1c, 0x8d, 0x6a, 0x16, 0x9f, 0xd4, 0x4f, 0xfe, 0x7, + 0xd5, 0x8e, 0xa1, 0x3f, 0x15, 0xff, 0x5f, 0xbe, 0x92, 0x95, 0x27, 0xb4, 0xa9, 0xd6, 0xf6, 0x4b, 0x40, 0x9a, 0xe6, + 0x58, 0x0, 0x11, 0xb8, 0x1f, 0xaf, 0x9e, 0xa0, 0x36, 0x99, 0x1a, 0x52, 0x52, 0x4e, 0xc7, 0x24, 0xdb, 0x45, 0x34, + 0xd6, 0x2a, 0x2c, 0x3, 0x0, 0x19, 0x8e, 0x88, 0xb2, 0x89, 0xb4, 0x32, 0x33, 0x74, 0xb9, 0xf3, 0x61, 0xcf, 0x6e, + 0x42, 0xc8, 0x3b, 0xa2, 0x77, 0xc1, 0x6e, 0xb, 0x58, 0xa3, 0x60, 0x68, 0xb, 0xb, 0x27, 0x0, 0x0, 0x5d, 0xf1, + 0x21, 0x60, 0x91, 0x12, 0x0, 0xf, 0xed, 0x1c, 0x47, 0x4e, 0x84, 0x6a, 0x33, 0x25, 0x13, 0xb, 0x62, 0xde, 0xde, + 0x61, 0x4e, 0x28, 0x80, 0x28, 0xba, 0x1a, 0x0, 0x14, 0x5d, 0x61, 0x5d, 0x94, 0x24, 0x93, 0xd1, 0x3a, 0xcc, 0xa4, + 0xcf, 0x9b, 0xfb, 0xc, 0x8f, 0xc2, 0x2b, 0xf1, 0x1e, 0xc8, 0x1, 0x2a, 0x2, 0x0, 0x0, 0x6b, 0x18, 0x24, 0x5, + 0x23, 0x9, 0x6a, 0x1f, 0x0, 0x15, 0x6e, 0xbd, 0x6b, 0x90, 0x98, 0xc5, 0x60, 0x7d, 0x43, 0x5f, 0xf2, 0xe, 0x5, + 0xf0, 0x7, 0x3, 0x56, 0x91, 0xe8, 0xc6, 0x54, 0x0, 0x9, 0x9, 0x86, 0xb2, 0xdb, 0x9f, 0xf9, 0xeb, 0xfa, 0xbb, + 0x0, 0x9, 0xa6, 0x29, 0xe6, 0xb8, 0x59, 0xfc, 0xd, 0x2e, 0x42}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf0, 0xd3, 0x4, 0xfd, 0x4d, 0x28, 0x87}; + uint8_t bytesprops1[] = {0x3a, 0x97, 0xeb, 0x3b, 0x99, 0x26, 0x2f, 0x64, 0x27, 0x59, 0xb7, 0x56, 0xe3, 0xd4, + 0xc8, 0xdf, 0x94, 0xee, 0xcc, 0x6f, 0xee, 0xe6, 0xeb, 0xb7, 0xbd, 0x14, 0x11}; + uint8_t bytesprops2[] = {0x11, 0x11, 0xcf, 0xb8, 0x14, 0x4b, 0x9f, 0xe3, 0xd9, 0x12, 0xff, 0x96}; + uint8_t bytesprops3[] = {0x5e, 0x3a, 0x6b, 0x94, 0xde, 0x7a, 0x84, 0xdc, 0x26, 0x5e}; + uint8_t bytesprops4[] = {0xdb, 0x19, 0xa, 0xba, 0xc0, 0x86, 0x12, 0xce, 0x2f, 0x77, 0xa4, 0x54, 0x2, 0xe, 0x33, 0x3e}; + uint8_t bytesprops6[] = {0xb8, 0x1f, 0xaf, 0x9e, 0xa0, 0x36, 0x99, 0x1a, 0x52, + 0x52, 0x4e, 0xc7, 0x24, 0xdb, 0x45, 0x34, 0xd6}; + uint8_t bytesprops5[] = {0x8d, 0x6a, 0x16, 0x9f, 0xd4, 0x4f, 0xfe, 0x7, 0xd5, 0x8e, 0xa1, 0x3f, 0x15, 0xff, + 0x5f, 0xbe, 0x92, 0x95, 0x27, 0xb4, 0xa9, 0xd6, 0xf6, 0x4b, 0x40, 0x9a, 0xe6, 0x58}; + uint8_t bytesprops7[] = {0x8e, 0x88, 0xb2, 0x89, 0xb4, 0x32, 0x33, 0x74, 0xb9, 0xf3, 0x61, 0xcf, 0x6e, + 0x42, 0xc8, 0x3b, 0xa2, 0x77, 0xc1, 0x6e, 0xb, 0x58, 0xa3, 0x60, 0x68}; + uint8_t bytesprops8[] = {0xed, 0x1c, 0x47, 0x4e, 0x84, 0x6a, 0x33, 0x25, 0x13, 0xb, 0x62, 0xde, 0xde, 0x61, 0x4e}; + uint8_t bytesprops9[] = {0x5d, 0x61, 0x5d, 0x94, 0x24, 0x93, 0xd1, 0x3a, 0xcc, 0xa4, + 0xcf, 0x9b, 0xfb, 0xc, 0x8f, 0xc2, 0x2b, 0xf1, 0x1e, 0xc8}; + uint8_t bytesprops10[] = {0x6e, 0xbd, 0x6b, 0x90, 0x98, 0xc5, 0x60, 0x7d, 0x43, 0x5f, 0xf2, + 0xe, 0x5, 0xf0, 0x7, 0x3, 0x56, 0x91, 0xe8, 0xc6, 0x54}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10894}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20782}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 123}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10666}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3468}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31173}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15968}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26426}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6586}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11671}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9190}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops5}, .v = {17, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24049}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24721}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27416}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2410}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x5e, 0x9e, 0xb5, 0xc0, 0x4a, 0x1c, 0xf9}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x9, 0x86, 0xb2, 0xdb, 0x9f, 0xf9, 0xeb, 0xfa, 0xbb}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf8, 0xf3, 0x6, 0x0, 0x53, 0x67, 0x7d, 0x80, 0xb1, 0x9a, 0x32, 0x1a, 0x2d, - 0xf2, 0x1d, 0xe5, 0x9, 0x15, 0x1f, 0xbd, 0x6d, 0xe1, 0xe6, 0x49, 0x1c}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1a, 0xc2, 0xb3, 0x43, 0xcb, 0x98}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xf4, 0x23, 0x98, 0xaf, 0xc2, 0x99, 0xe7, 0xef, 0x17, 0x44, 0x92, - 0x51, 0xf8, 0x67, 0xf6, 0x77, 0x8f, 0x4b, 0xc2, 0xf5, 0xb5}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x14, 0x9, 0x49, 0x73, 0x9b, 0x6a, 0x70, 0xc5, 0x16, 0x27, - 0x31, 0x2c, 0x47, 0x28, 0x50, 0x15, 0x24, 0xa3, 0x90, 0x92, - 0x9f, 0x1f, 0x59, 0xc2, 0x4d, 0x97, 0x9d, 0xff}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xec, 0x9f}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xe4, 0x84, 0x82, 0xfe, 0xd5, 0xad, 0x31, 0xca, 0x30, 0x88, 0x87, 0xe7, 0x9d, 0xa7, - 0x70, 0xc7, 0x7d, 0x8b, 0x3, 0x20, 0xbf, 0xbd, 0xa8, 0xf5, 0xe3, 0x12, 0x7d}; - lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xe9, 0x6d, 0x63, 0x9b, 0x4b, 0x8, 0x21, 0x1e, 0x75, 0x1a}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x74, 0xb2, 0x7f, 0x7f, 0x79, 0xf0, 0xe0, 0xe4, - 0x8d, 0xee, 0x4, 0x19, 0x99, 0x3b, 0xbe, 0xea}; - lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x80, 0x78, 0x53, 0xc7, 0xf0, 0xe4, 0x30, 0x52, 0xb, 0x52, - 0xb4, 0x33, 0xd9, 0xb3, 0xa2, 0x48, 0xbd, 0x25, 0xc0, 0xf7, - 0xc3, 0x65, 0xb3, 0x74, 0x1e, 0x22, 0x78, 0x11, 0x6d, 0x79}; - lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0xf6, 0x1b, 0xf8, 0x88, 0x3, 0x3e, 0xe1, 0xcc, 0x6, 0x88, - 0xaa, 0x22, 0xb, 0xe8, 0xfd, 0xdb, 0xc7, 0x3d, 0x6}; - lwmqtt_string_t topic_filter_s10 = {19, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; + uint8_t topic_filter_s1_bytes[] = {0xa6, 0x29, 0xe6, 0xb8, 0x59, 0xfc, 0xd, 0x2e, 0x42}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8587, 11, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24597, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24034 -// ["\156\234\208\197\181\158\172S\218","\132\v\NAK\170\230\US\216+\217\DEL\213\156F","MTu\239]\128\EOT\f\SYN_\203\250\250\148\128\\\SO\ETBuv\137\211w\174+\NULUh_\232","\134\175\155\DC1\190\137R%\247H\202\207","\135\ETX\221t\137\178A\194\131\189V\254\204\246\175\143x\NAK\162[\135*\235[\EOT","Sq\209\151pP","\185\181~\EM\159\160\137\183\ETXQ\129u\174'O\210\177\GSi\201\217","Ch\167\252[{V1Q\223D\152$70\147\DC1\158-t7\250\152+\244\255\RS^j","\134\&4\166Q\210\FS\194\136\206qe\DLE]CG\FSEj\169\156\NUL\213\185>H\ETX&\SI\140"] -// [PropTopicAlias 5045,PropServerKeepAlive 13352,PropUserProperty "ap\248\162\242R\251" "\128"] +// UnsubscribeRequest 17778 +// ["\136x\150\168\US\251\133\245\161\132","","\156","\b\158G{\v-Ms1\169\219\152\168\DC4\152\236\156\169\r +// L{\144]w<\161","^\n\242r\171T8\161Q\v\135\252\STX8r\191\232\164\NUL\USM\199\151|8G\166","y\b\179\128O\138\242\240@2\163\187~\137\EOT\212\&2\EOT\167\\}f\170:\169x\186~","\b4\215\223kA\248\252\v\173\218\f\217.\171O\210\199\&4\ETX\NULk\f7~\151\&5\142\USL","\223\248\DC3<\163N\164?\DC2%\ENQ\251\214\223\&4\239\&13_3\DEL\SYN*c\NUL\ETX","\215\DC1\218\DC1l\160\ESCV@L\v$\203\195","\221M\253c3\176\146Y\151\250\249^YYC\182n`\ENQg\203s\198\249\232"] +// [PropResponseTopic +// "\255\217W=\224\165\251\223b\157q\154l\236\208\160\211\157\155~\175\230\247x\213G\150",PropSessionExpiryInterval +// 21312,PropServerKeepAlive 11757] TEST(Unsubscribe5QCTest, Encode19) { - uint8_t pkt[] = {0xa2, 0xd6, 0x1, 0x5d, 0xe2, 0x13, 0x23, 0x13, 0xb5, 0x13, 0x34, 0x28, 0x26, 0x0, 0x7, 0x61, 0x70, - 0xf8, 0xa2, 0xf2, 0x52, 0xfb, 0x0, 0x1, 0x80, 0x0, 0x9, 0x9c, 0xea, 0xd0, 0xc5, 0xb5, 0x9e, 0xac, - 0x53, 0xda, 0x0, 0xd, 0x84, 0xb, 0x15, 0xaa, 0xe6, 0x1f, 0xd8, 0x2b, 0xd9, 0x7f, 0xd5, 0x9c, 0x46, - 0x0, 0x1e, 0x4d, 0x54, 0x75, 0xef, 0x5d, 0x80, 0x4, 0xc, 0x16, 0x5f, 0xcb, 0xfa, 0xfa, 0x94, 0x80, - 0x5c, 0xe, 0x17, 0x75, 0x76, 0x89, 0xd3, 0x77, 0xae, 0x2b, 0x0, 0x55, 0x68, 0x5f, 0xe8, 0x0, 0xc, - 0x86, 0xaf, 0x9b, 0x11, 0xbe, 0x89, 0x52, 0x25, 0xf7, 0x48, 0xca, 0xcf, 0x0, 0x19, 0x87, 0x3, 0xdd, - 0x74, 0x89, 0xb2, 0x41, 0xc2, 0x83, 0xbd, 0x56, 0xfe, 0xcc, 0xf6, 0xaf, 0x8f, 0x78, 0x15, 0xa2, 0x5b, - 0x87, 0x2a, 0xeb, 0x5b, 0x4, 0x0, 0x6, 0x53, 0x71, 0xd1, 0x97, 0x70, 0x50, 0x0, 0x15, 0xb9, 0xb5, - 0x7e, 0x19, 0x9f, 0xa0, 0x89, 0xb7, 0x3, 0x51, 0x81, 0x75, 0xae, 0x27, 0x4f, 0xd2, 0xb1, 0x1d, 0x69, - 0xc9, 0xd9, 0x0, 0x1d, 0x43, 0x68, 0xa7, 0xfc, 0x5b, 0x7b, 0x56, 0x31, 0x51, 0xdf, 0x44, 0x98, 0x24, - 0x37, 0x30, 0x93, 0x11, 0x9e, 0x2d, 0x74, 0x37, 0xfa, 0x98, 0x2b, 0xf4, 0xff, 0x1e, 0x5e, 0x6a, 0x0, - 0x1d, 0x86, 0x34, 0xa6, 0x51, 0xd2, 0x1c, 0xc2, 0x88, 0xce, 0x71, 0x65, 0x10, 0x5d, 0x43, 0x47, 0x1c, - 0x45, 0x6a, 0xa9, 0x9c, 0x0, 0xd5, 0xb9, 0x3e, 0x48, 0x3, 0x26, 0xf, 0x8c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x80}; - uint8_t bytesprops0[] = {0x61, 0x70, 0xf8, 0xa2, 0xf2, 0x52, 0xfb}; + uint8_t pkt[] = {0xa2, 0xf9, 0x1, 0x45, 0x72, 0x26, 0x8, 0x0, 0x1b, 0xff, 0xd9, 0x57, 0x3d, 0xe0, 0xa5, 0xfb, 0xdf, + 0x62, 0x9d, 0x71, 0x9a, 0x6c, 0xec, 0xd0, 0xa0, 0xd3, 0x9d, 0x9b, 0x7e, 0xaf, 0xe6, 0xf7, 0x78, 0xd5, + 0x47, 0x96, 0x11, 0x0, 0x0, 0x53, 0x40, 0x13, 0x2d, 0xed, 0x0, 0xa, 0x88, 0x78, 0x96, 0xa8, 0x1f, + 0xfb, 0x85, 0xf5, 0xa1, 0x84, 0x0, 0x0, 0x0, 0x1, 0x9c, 0x0, 0x1b, 0x8, 0x9e, 0x47, 0x7b, 0xb, + 0x2d, 0x4d, 0x73, 0x31, 0xa9, 0xdb, 0x98, 0xa8, 0x14, 0x98, 0xec, 0x9c, 0xa9, 0xd, 0x20, 0x4c, 0x7b, + 0x90, 0x5d, 0x77, 0x3c, 0xa1, 0x0, 0x1b, 0x5e, 0xa, 0xf2, 0x72, 0xab, 0x54, 0x38, 0xa1, 0x51, 0xb, + 0x87, 0xfc, 0x2, 0x38, 0x72, 0xbf, 0xe8, 0xa4, 0x0, 0x1f, 0x4d, 0xc7, 0x97, 0x7c, 0x38, 0x47, 0xa6, + 0x0, 0x1c, 0x79, 0x8, 0xb3, 0x80, 0x4f, 0x8a, 0xf2, 0xf0, 0x40, 0x32, 0xa3, 0xbb, 0x7e, 0x89, 0x4, + 0xd4, 0x32, 0x4, 0xa7, 0x5c, 0x7d, 0x66, 0xaa, 0x3a, 0xa9, 0x78, 0xba, 0x7e, 0x0, 0x1e, 0x8, 0x34, + 0xd7, 0xdf, 0x6b, 0x41, 0xf8, 0xfc, 0xb, 0xad, 0xda, 0xc, 0xd9, 0x2e, 0xab, 0x4f, 0xd2, 0xc7, 0x34, + 0x3, 0x0, 0x6b, 0xc, 0x37, 0x7e, 0x97, 0x35, 0x8e, 0x1f, 0x4c, 0x0, 0x1a, 0xdf, 0xf8, 0x13, 0x3c, + 0xa3, 0x4e, 0xa4, 0x3f, 0x12, 0x25, 0x5, 0xfb, 0xd6, 0xdf, 0x34, 0xef, 0x31, 0x33, 0x5f, 0x33, 0x7f, + 0x16, 0x2a, 0x63, 0x0, 0x3, 0x0, 0xe, 0xd7, 0x11, 0xda, 0x11, 0x6c, 0xa0, 0x1b, 0x56, 0x40, 0x4c, + 0xb, 0x24, 0xcb, 0xc3, 0x0, 0x19, 0xdd, 0x4d, 0xfd, 0x63, 0x33, 0xb0, 0x92, 0x59, 0x97, 0xfa, 0xf9, + 0x5e, 0x59, 0x59, 0x43, 0xb6, 0x6e, 0x60, 0x5, 0x67, 0xcb, 0x73, 0xc6, 0xf9, 0xe8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xff, 0xd9, 0x57, 0x3d, 0xe0, 0xa5, 0xfb, 0xdf, 0x62, 0x9d, 0x71, 0x9a, 0x6c, 0xec, + 0xd0, 0xa0, 0xd3, 0x9d, 0x9b, 0x7e, 0xaf, 0xe6, 0xf7, 0x78, 0xd5, 0x47, 0x96}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5045}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13352}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops0}, .v = {1, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21312}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11757}}, }; lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x9c, 0xea, 0xd0, 0xc5, 0xb5, 0x9e, 0xac, 0x53, 0xda}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x88, 0x78, 0x96, 0xa8, 0x1f, 0xfb, 0x85, 0xf5, 0xa1, 0x84}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x84, 0xb, 0x15, 0xaa, 0xe6, 0x1f, 0xd8, 0x2b, 0xd9, 0x7f, 0xd5, 0x9c, 0x46}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4d, 0x54, 0x75, 0xef, 0x5d, 0x80, 0x4, 0xc, 0x16, 0x5f, - 0xcb, 0xfa, 0xfa, 0x94, 0x80, 0x5c, 0xe, 0x17, 0x75, 0x76, - 0x89, 0xd3, 0x77, 0xae, 0x2b, 0x0, 0x55, 0x68, 0x5f, 0xe8}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x9c}; + lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x86, 0xaf, 0x9b, 0x11, 0xbe, 0x89, 0x52, 0x25, 0xf7, 0x48, 0xca, 0xcf}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x8, 0x9e, 0x47, 0x7b, 0xb, 0x2d, 0x4d, 0x73, 0x31, 0xa9, 0xdb, 0x98, 0xa8, 0x14, + 0x98, 0xec, 0x9c, 0xa9, 0xd, 0x20, 0x4c, 0x7b, 0x90, 0x5d, 0x77, 0x3c, 0xa1}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x87, 0x3, 0xdd, 0x74, 0x89, 0xb2, 0x41, 0xc2, 0x83, 0xbd, 0x56, 0xfe, 0xcc, - 0xf6, 0xaf, 0x8f, 0x78, 0x15, 0xa2, 0x5b, 0x87, 0x2a, 0xeb, 0x5b, 0x4}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x5e, 0xa, 0xf2, 0x72, 0xab, 0x54, 0x38, 0xa1, 0x51, 0xb, 0x87, 0xfc, 0x2, 0x38, + 0x72, 0xbf, 0xe8, 0xa4, 0x0, 0x1f, 0x4d, 0xc7, 0x97, 0x7c, 0x38, 0x47, 0xa6}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x53, 0x71, 0xd1, 0x97, 0x70, 0x50}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x79, 0x8, 0xb3, 0x80, 0x4f, 0x8a, 0xf2, 0xf0, 0x40, 0x32, + 0xa3, 0xbb, 0x7e, 0x89, 0x4, 0xd4, 0x32, 0x4, 0xa7, 0x5c, + 0x7d, 0x66, 0xaa, 0x3a, 0xa9, 0x78, 0xba, 0x7e}; + lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb9, 0xb5, 0x7e, 0x19, 0x9f, 0xa0, 0x89, 0xb7, 0x3, 0x51, 0x81, - 0x75, 0xae, 0x27, 0x4f, 0xd2, 0xb1, 0x1d, 0x69, 0xc9, 0xd9}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x8, 0x34, 0xd7, 0xdf, 0x6b, 0x41, 0xf8, 0xfc, 0xb, 0xad, + 0xda, 0xc, 0xd9, 0x2e, 0xab, 0x4f, 0xd2, 0xc7, 0x34, 0x3, + 0x0, 0x6b, 0xc, 0x37, 0x7e, 0x97, 0x35, 0x8e, 0x1f, 0x4c}; + lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x43, 0x68, 0xa7, 0xfc, 0x5b, 0x7b, 0x56, 0x31, 0x51, 0xdf, - 0x44, 0x98, 0x24, 0x37, 0x30, 0x93, 0x11, 0x9e, 0x2d, 0x74, - 0x37, 0xfa, 0x98, 0x2b, 0xf4, 0xff, 0x1e, 0x5e, 0x6a}; - lwmqtt_string_t topic_filter_s7 = {29, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xdf, 0xf8, 0x13, 0x3c, 0xa3, 0x4e, 0xa4, 0x3f, 0x12, 0x25, 0x5, 0xfb, 0xd6, + 0xdf, 0x34, 0xef, 0x31, 0x33, 0x5f, 0x33, 0x7f, 0x16, 0x2a, 0x63, 0x0, 0x3}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x86, 0x34, 0xa6, 0x51, 0xd2, 0x1c, 0xc2, 0x88, 0xce, 0x71, - 0x65, 0x10, 0x5d, 0x43, 0x47, 0x1c, 0x45, 0x6a, 0xa9, 0x9c, - 0x0, 0xd5, 0xb9, 0x3e, 0x48, 0x3, 0x26, 0xf, 0x8c}; - lwmqtt_string_t topic_filter_s8 = {29, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xd7, 0x11, 0xda, 0x11, 0x6c, 0xa0, 0x1b, 0x56, 0x40, 0x4c, 0xb, 0x24, 0xcb, 0xc3}; + lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xdd, 0x4d, 0xfd, 0x63, 0x33, 0xb0, 0x92, 0x59, 0x97, 0xfa, 0xf9, 0x5e, 0x59, + 0x59, 0x43, 0xb6, 0x6e, 0x60, 0x5, 0x67, 0xcb, 0x73, 0xc6, 0xf9, 0xe8}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24034, 9, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17778, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5686 -// ["","\v}7\181\SI\131\156\ETX\158\RS<\237t\205^\236\158\139>","\179\158\242","","}>\\@\236\138X@Bu=P>J\STX\STXF&,?\129'\213\195\189","\\W=A\231m\181\237v\154\160","\254\234\210\&3`B\"/\175\253\131\244@\176]\211\159\163\160$\246"] -// [PropRequestProblemInformation 81,PropMessageExpiryInterval 13449,PropTopicAliasMaximum -// 21738,PropPayloadFormatIndicator 87,PropSessionExpiryInterval 22817,PropResponseTopic -// "\252\&9{_/\200\140\ETX",PropReceiveMaximum 16202,PropMessageExpiryInterval 32296,PropSubscriptionIdentifierAvailable -// 220,PropUserProperty "v\198\157\202a+\NUL2\222\a\DLEv\151" -// "\253\236fT\241\218YK\SOH\159#\156}\v\199\239)\249\144\ESC",PropRequestProblemInformation 191,PropReasonString -// "\EOT{I\FS{ep\216\139\201Ri\167\v#\165\&8B\a\145v^\131\200\201\153\177q\180\DC2",PropServerReference -// "G\171\191\199\&9",PropContentType -// "\STX\240\190\US\185Z\176\187+\144\209\&3\224\191Zm\STX\DC1%\DC1\142(\131\209^",PropReasonString -// "\US@\233w",PropSubscriptionIdentifierAvailable 252,PropServerKeepAlive 31044,PropReasonString -// "\176\153\SOH\183\DEL",PropServerKeepAlive 11070,PropRequestResponseInformation 182,PropResponseInformation -// "\232\157W\220\179<_",PropSubscriptionIdentifier 15,PropServerKeepAlive 3297,PropResponseTopic -// ".\ESC5\138E\147\194e\182",PropRetainAvailable 193] +// UnsubscribeRequest 4976 +// ["_\190\245~5\207\156\SOHtV\FSY\253Gq\220\&8R\"\148","\CAN\141\210\134\ETBEiWm\158\t}\150O\175\CANHzh\157]q\173BuK\182p","\SUB\156\FS\ENQo#V\174\SYN\EM\150\161\a\231S\236\217\251\185\142\186\216\132\DC1I\"\172=5","\200d\202\182\185\147","\196\172'","kx\GS\134,&\222\152\&0\US\188\202zs\141g\170\174\164\SUB\246\184Wd\135\237","\254\207M\NAK\202g\EOT\135\186\213.\229\222\152","=\137\241~\EOTl","&\"","6\239R\208\161@\FS\US\250\170`\SUB\155{"] +// [PropWildcardSubscriptionAvailable 188,PropAssignedClientIdentifier +// ">\243{6\aL\141y\146\192Z\159\&1",PropCorrelationData +// "\223\153\146\190\DC1\155P\EOT\191\211\133+y\218\250\DC31Ah\181\&4",PropMaximumQoS 228,PropTopicAlias +// 31268,PropPayloadFormatIndicator 132,PropSessionExpiryInterval 6581,PropAuthenticationData "F",PropWillDelayInterval +// 5403,PropCorrelationData "\254j\232\SOHY{\251Wg\136r\NUL\193)`\223\241\252fs",PropAuthenticationMethod +// "w\EOT\202\ACK\152\\\US>\211#\ETBm\235\163\&1\233\169a\241)\253\173",PropMaximumPacketSize +// 26144,PropWildcardSubscriptionAvailable 252,PropContentType "\132\ETBvZM\164\195\191;\133\EMt\195\202[\213 +// ",PropContentType +// "\242r\227f\210\SYN\NUL{\255\t\226k_z\161d\161\199\DC3\SI\221\DC2\137\ETB\238\DLE-\157\235X",PropMaximumPacketSize +// 9944,PropRetainAvailable 146] TEST(Unsubscribe5QCTest, Encode20) { uint8_t pkt[] = { - 0xa2, 0xaa, 0x2, 0x16, 0x36, 0xc9, 0x1, 0x17, 0x51, 0x2, 0x0, 0x0, 0x34, 0x89, 0x22, 0x54, 0xea, 0x1, 0x57, - 0x11, 0x0, 0x0, 0x59, 0x21, 0x8, 0x0, 0x8, 0xfc, 0x39, 0x7b, 0x5f, 0x2f, 0xc8, 0x8c, 0x3, 0x21, 0x3f, 0x4a, - 0x2, 0x0, 0x0, 0x7e, 0x28, 0x29, 0xdc, 0x26, 0x0, 0xd, 0x76, 0xc6, 0x9d, 0xca, 0x61, 0x2b, 0x0, 0x32, 0xde, - 0x7, 0x10, 0x76, 0x97, 0x0, 0x14, 0xfd, 0xec, 0x66, 0x54, 0xf1, 0xda, 0x59, 0x4b, 0x1, 0x9f, 0x23, 0x9c, 0x7d, - 0xb, 0xc7, 0xef, 0x29, 0xf9, 0x90, 0x1b, 0x17, 0xbf, 0x1f, 0x0, 0x1e, 0x4, 0x7b, 0x49, 0x1c, 0x7b, 0x65, 0x70, - 0xd8, 0x8b, 0xc9, 0x52, 0x69, 0xa7, 0xb, 0x23, 0xa5, 0x38, 0x42, 0x7, 0x91, 0x76, 0x5e, 0x83, 0xc8, 0xc9, 0x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xa0, 0x24, 0xf6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xfc, 0x39, 0x7b, 0x5f, 0x2f, 0xc8, 0x8c, 0x3}; - uint8_t bytesprops2[] = {0xfd, 0xec, 0x66, 0x54, 0xf1, 0xda, 0x59, 0x4b, 0x1, 0x9f, - 0x23, 0x9c, 0x7d, 0xb, 0xc7, 0xef, 0x29, 0xf9, 0x90, 0x1b}; - uint8_t bytesprops1[] = {0x76, 0xc6, 0x9d, 0xca, 0x61, 0x2b, 0x0, 0x32, 0xde, 0x7, 0x10, 0x76, 0x97}; - uint8_t bytesprops3[] = {0x4, 0x7b, 0x49, 0x1c, 0x7b, 0x65, 0x70, 0xd8, 0x8b, 0xc9, 0x52, 0x69, 0xa7, 0xb, 0x23, - 0xa5, 0x38, 0x42, 0x7, 0x91, 0x76, 0x5e, 0x83, 0xc8, 0xc9, 0x99, 0xb1, 0x71, 0xb4, 0x12}; - uint8_t bytesprops4[] = {0x47, 0xab, 0xbf, 0xc7, 0x39}; - uint8_t bytesprops5[] = {0x2, 0xf0, 0xbe, 0x1f, 0xb9, 0x5a, 0xb0, 0xbb, 0x2b, 0x90, 0xd1, 0x33, 0xe0, - 0xbf, 0x5a, 0x6d, 0x2, 0x11, 0x25, 0x11, 0x8e, 0x28, 0x83, 0xd1, 0x5e}; - uint8_t bytesprops6[] = {0x1f, 0x40, 0xe9, 0x77}; - uint8_t bytesprops7[] = {0xb0, 0x99, 0x1, 0xb7, 0x7f}; - uint8_t bytesprops8[] = {0xe8, 0x9d, 0x57, 0xdc, 0xb3, 0x3c, 0x5f}; - uint8_t bytesprops9[] = {0x2e, 0x1b, 0x35, 0x8a, 0x45, 0x93, 0xc2, 0x65, 0xb6}; + 0xa2, 0xde, 0x2, 0x13, 0x70, 0xb2, 0x1, 0x28, 0xbc, 0x12, 0x0, 0xd, 0x3e, 0xf3, 0x7b, 0x36, 0x7, 0x4c, 0x8d, + 0x79, 0x92, 0xc0, 0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, 0xd2, 0x86, 0x17, 0x45, 0x69, 0x57, 0x6d, 0x9e, 0x9, 0x7d, 0x96, 0x4f, 0xaf, 0x18, 0x48, 0x7a, 0x68, + 0x9d, 0x5d, 0x71, 0xad, 0x42, 0x75, 0x4b, 0xb6, 0x70, 0x0, 0x1d, 0x1a, 0x9c, 0x1c, 0x5, 0x6f, 0x23, 0x56, 0xae, + 0x16, 0x19, 0x96, 0xa1, 0x7, 0xe7, 0x53, 0xec, 0xd9, 0xfb, 0xb9, 0x8e, 0xba, 0xd8, 0x84, 0x11, 0x49, 0x22, 0xac, + 0x3d, 0x35, 0x0, 0x6, 0xc8, 0x64, 0xca, 0xb6, 0xb9, 0x93, 0x0, 0x3, 0xc4, 0xac, 0x27, 0x0, 0x1a, 0x6b, 0x78, + 0x1d, 0x86, 0x2c, 0x26, 0xde, 0x98, 0x30, 0x1f, 0xbc, 0xca, 0x7a, 0x73, 0x8d, 0x67, 0xaa, 0xae, 0xa4, 0x1a, 0xf6, + 0xb8, 0x57, 0x64, 0x87, 0xed, 0x0, 0xe, 0xfe, 0xcf, 0x4d, 0x15, 0xca, 0x67, 0x4, 0x87, 0xba, 0xd5, 0x2e, 0xe5, + 0xde, 0x98, 0x0, 0x6, 0x3d, 0x89, 0xf1, 0x7e, 0x4, 0x6c, 0x0, 0x2, 0x26, 0x22, 0x0, 0xe, 0x36, 0xef, 0x52, + 0xd0, 0xa1, 0x40, 0x1c, 0x1f, 0xfa, 0xaa, 0x60, 0x1a, 0x9b, 0x7b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x3e, 0xf3, 0x7b, 0x36, 0x7, 0x4c, 0x8d, 0x79, 0x92, 0xc0, 0x5a, 0x9f, 0x31}; + uint8_t bytesprops1[] = {0xdf, 0x99, 0x92, 0xbe, 0x11, 0x9b, 0x50, 0x4, 0xbf, 0xd3, 0x85, + 0x2b, 0x79, 0xda, 0xfa, 0x13, 0x31, 0x41, 0x68, 0xb5, 0x34}; + uint8_t bytesprops2[] = {0x46}; + uint8_t bytesprops3[] = {0xfe, 0x6a, 0xe8, 0x1, 0x59, 0x7b, 0xfb, 0x57, 0x67, 0x88, + 0x72, 0x0, 0xc1, 0x29, 0x60, 0xdf, 0xf1, 0xfc, 0x66, 0x73}; + uint8_t bytesprops4[] = {0x77, 0x4, 0xca, 0x6, 0x98, 0x5c, 0x1f, 0x3e, 0xd3, 0x23, 0x17, + 0x6d, 0xeb, 0xa3, 0x31, 0xe9, 0xa9, 0x61, 0xf1, 0x29, 0xfd, 0xad}; + uint8_t bytesprops5[] = {0x84, 0x17, 0x76, 0x5a, 0x4d, 0xa4, 0xc3, 0xbf, 0x3b, + 0x85, 0x19, 0x74, 0xc3, 0xca, 0x5b, 0xd5, 0x20}; + uint8_t bytesprops6[] = {0xf2, 0x72, 0xe3, 0x66, 0xd2, 0x16, 0x0, 0x7b, 0xff, 0x9, 0xe2, 0x6b, 0x5f, 0x7a, 0xa1, + 0x64, 0xa1, 0xc7, 0x13, 0xf, 0xdd, 0x12, 0x89, 0x17, 0xee, 0x10, 0x2d, 0x9d, 0xeb, 0x58}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13449}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21738}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22817}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16202}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32296}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops1}, .v = {20, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31044}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11070}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3297}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31268}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6581}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5403}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26144}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9944}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x5f, 0xbe, 0xf5, 0x7e, 0x35, 0xcf, 0x9c, 0x1, 0x74, 0x56, + 0x1c, 0x59, 0xfd, 0x47, 0x71, 0xdc, 0x38, 0x52, 0x22, 0x94}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb, 0x7d, 0x37, 0xb5, 0xf, 0x83, 0x9c, 0x3, 0x9e, 0x1e, - 0x3c, 0xed, 0x74, 0xcd, 0x5e, 0xec, 0x9e, 0x8b, 0x3e}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x18, 0x8d, 0xd2, 0x86, 0x17, 0x45, 0x69, 0x57, 0x6d, 0x9e, + 0x9, 0x7d, 0x96, 0x4f, 0xaf, 0x18, 0x48, 0x7a, 0x68, 0x9d, + 0x5d, 0x71, 0xad, 0x42, 0x75, 0x4b, 0xb6, 0x70}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb3, 0x9e, 0xf2}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x1a, 0x9c, 0x1c, 0x5, 0x6f, 0x23, 0x56, 0xae, 0x16, 0x19, + 0x96, 0xa1, 0x7, 0xe7, 0x53, 0xec, 0xd9, 0xfb, 0xb9, 0x8e, + 0xba, 0xd8, 0x84, 0x11, 0x49, 0x22, 0xac, 0x3d, 0x35}; + lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc8, 0x64, 0xca, 0xb6, 0xb9, 0x93}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x7d, 0x3e, 0x5c, 0x40, 0xec, 0x8a, 0x58, 0x40, 0x42, 0x75, 0x3d, 0x50, 0x3e, - 0x4a, 0x2, 0x2, 0x46, 0x26, 0x2c, 0x3f, 0x81, 0x27, 0xd5, 0xc3, 0xbd}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc4, 0xac, 0x27}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x5c, 0x57, 0x3d, 0x41, 0xe7, 0x6d, 0xb5, 0xed, 0x76, 0x9a, 0xa0}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x6b, 0x78, 0x1d, 0x86, 0x2c, 0x26, 0xde, 0x98, 0x30, 0x1f, 0xbc, 0xca, 0x7a, + 0x73, 0x8d, 0x67, 0xaa, 0xae, 0xa4, 0x1a, 0xf6, 0xb8, 0x57, 0x64, 0x87, 0xed}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xfe, 0xea, 0xd2, 0x33, 0x60, 0x42, 0x22, 0x2f, 0xaf, 0xfd, 0x83, - 0xf4, 0x40, 0xb0, 0x5d, 0xd3, 0x9f, 0xa3, 0xa0, 0x24, 0xf6}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xfe, 0xcf, 0x4d, 0x15, 0xca, 0x67, 0x4, 0x87, 0xba, 0xd5, 0x2e, 0xe5, 0xde, 0x98}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x3d, 0x89, 0xf1, 0x7e, 0x4, 0x6c}; + lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x26, 0x22}; + lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x36, 0xef, 0x52, 0xd0, 0xa1, 0x40, 0x1c, + 0x1f, 0xfa, 0xaa, 0x60, 0x1a, 0x9b, 0x7b}; + lwmqtt_string_t topic_filter_s9 = {14, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5686, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4976, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24245 -// ["\187-s\231\141\DELJq\246","\NAK]%\227\253\FST\142?\253C;\SOH\191\250\223T\RS\DC2\247B\191\193\222\196I\129","\196\132\&8J\197\&8\163\133\229"] -// [PropAuthenticationMethod "\152\248\&1\250M\n\162\131\DLEs\230"] +// UnsubscribeRequest 12973 +// ["\DC1As\216\DLE\214\246\194\220\178\DC3\NULON\198\226\147P\205\SO\129\&4\RS\DC3\206","\171\&0\204\160\CAN.\142\255 +// \134\198\220\DEL@\163\216\&2\165\142\225\208","^\163\204\213TZ\"\SO","\136!\167=\170\214\"\232\ESC +// \216\174%\ENQ]\219\133}\226\235","J\182\bT\140Z","\188n\150\191L#\NAK\197\136\194[\192m\141\196\n\211\252","\195\157\173\ACKh\DEL\178\230\r","e(y\DC3\r|+\138\216\196*\227~\180\140DX\250\181\135#\214#;!\225\161\201","1\252\225\175\STX\172\236\SYN\176\&2\"\204\v\RS\b\189","\218\181\178\245x\187\245\167\&5\144\249L:\209\146"] +// [PropReasonString "\197\173\128\210\&6^E\180y\CAN\152\"\149",PropServerKeepAlive 31457,PropResponseTopic +// "\140\142;]\130\155\161\DEL\179\200\204D9\226\228\193\255\138M^\171\254\141\136v\181\199\135\GS",PropAuthenticationMethod +// "\EM\225\243\176\175?\247\201\ENQ\SOHF\244\NUL\239\&8b\208\220\DEL\240\255%",PropPayloadFormatIndicator +// 109,PropSubscriptionIdentifier 23,PropRequestResponseInformation 219,PropCorrelationData "\DC3\129\EMQ +// Y\DC3R\140\DC1/R\139",PropSubscriptionIdentifierAvailable 137,PropResponseTopic +// "\252{\129\169\EMr\214\&4\205\226O\156\198\GS;}\242_hnG\226\225\EM\219.\215\233\232",PropAssignedClientIdentifier +// "\STXA",PropWildcardSubscriptionAvailable 230,PropAssignedClientIdentifier +// "\238\192\187%a_\SOH\175/x\DEL\162\&4\SO\217\SO\213\242:\170\233O\158\EM[|",PropTopicAlias 26429,PropReasonString +// "\135\\h\193n\214-+2D\180\rg\177r\255`//\186]\206\157D"] TEST(Unsubscribe5QCTest, Encode21) { - uint8_t pkt[] = {0xa2, 0x44, 0x5e, 0xb5, 0xe, 0x15, 0x0, 0xb, 0x98, 0xf8, 0x31, 0xfa, 0x4d, 0xa, - 0xa2, 0x83, 0x10, 0x73, 0xe6, 0x0, 0x9, 0xbb, 0x2d, 0x73, 0xe7, 0x8d, 0x7f, 0x4a, - 0x71, 0xf6, 0x0, 0x1b, 0x15, 0x5d, 0x25, 0xe3, 0xfd, 0x1c, 0x54, 0x8e, 0x3f, 0xfd, - 0x43, 0x3b, 0x1, 0xbf, 0xfa, 0xdf, 0x54, 0x1e, 0x12, 0xf7, 0x42, 0xbf, 0xc1, 0xde, - 0xc4, 0x49, 0x81, 0x0, 0x9, 0xc4, 0x84, 0x38, 0x4a, 0xc5, 0x38, 0xa3, 0x85, 0xe5}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x98, 0xf8, 0x31, 0xfa, 0x4d, 0xa, 0xa2, 0x83, 0x10, 0x73, 0xe6}; + uint8_t pkt[] = { + 0xa2, 0x84, 0x3, 0x32, 0xad, 0xc6, 0x1, 0x1f, 0x0, 0xd, 0xc5, 0xad, 0x80, 0xd2, 0x36, 0x5e, 0x45, 0xb4, 0x79, + 0x18, 0x98, 0x22, 0x95, 0x13, 0x7a, 0xe1, 0x8, 0x0, 0x1d, 0x8c, 0x8e, 0x3b, 0x5d, 0x82, 0x9b, 0xa1, 0x7f, 0xb3, + 0xc8, 0xcc, 0x44, 0x39, 0xe2, 0xe4, 0xc1, 0xff, 0x8a, 0x4d, 0x5e, 0xab, 0xfe, 0x8d, 0x88, 0x76, 0xb5, 0xc7, 0x87, + 0x1d, 0x15, 0x0, 0x16, 0x19, 0xe1, 0xf3, 0xb0, 0xaf, 0x3f, 0xf7, 0xc9, 0x5, 0x1, 0x46, 0xf4, 0x0, 0xef, 0x38, + 0x62, 0xd0, 0xdc, 0x7f, 0xf0, 0xff,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14, 0x88, 0x21, 0xa7, 0x3d, 0xaa, 0xd6, 0x22, 0xe8, 0x1b, 0x20, 0xd8, 0xae, 0x25, 0x5, 0x5d, 0xdb, 0x85, 0x7d, + 0xe2, 0xeb, 0x0, 0x6, 0x4a, 0xb6, 0x8, 0x54, 0x8c, 0x5a, 0x0, 0x12, 0xbc, 0x6e, 0x96, 0xbf, 0x4c, 0x23, 0x15, + 0xc5, 0x88, 0xc2, 0x5b, 0xc0, 0x6d, 0x8d, 0xc4, 0xa, 0xd3, 0xfc, 0x0, 0x9, 0xc3, 0x9d, 0xad, 0x6, 0x68, 0x7f, + 0xb2, 0xe6, 0xd, 0x0, 0x1c, 0x65, 0x28, 0x79, 0x13, 0xd, 0x7c, 0x2b, 0x8a, 0xd8, 0xc4, 0x2a, 0xe3, 0x7e, 0xb4, + 0x8c, 0x44, 0x58, 0xfa, 0xb5, 0x87, 0x23, 0xd6, 0x23, 0x3b, 0x21, 0xe1, 0xa1, 0xc9, 0x0, 0x10, 0x31, 0xfc, 0xe1, + 0xaf, 0x2, 0xac, 0xec, 0x16, 0xb0, 0x32, 0x22, 0xcc, 0xb, 0x1e, 0x8, 0xbd, 0x0, 0xf, 0xda, 0xb5, 0xb2, 0xf5, + 0x78, 0xbb, 0xf5, 0xa7, 0x35, 0x90, 0xf9, 0x4c, 0x3a, 0xd1, 0x92}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc5, 0xad, 0x80, 0xd2, 0x36, 0x5e, 0x45, 0xb4, 0x79, 0x18, 0x98, 0x22, 0x95}; + uint8_t bytesprops1[] = {0x8c, 0x8e, 0x3b, 0x5d, 0x82, 0x9b, 0xa1, 0x7f, 0xb3, 0xc8, 0xcc, 0x44, 0x39, 0xe2, 0xe4, + 0xc1, 0xff, 0x8a, 0x4d, 0x5e, 0xab, 0xfe, 0x8d, 0x88, 0x76, 0xb5, 0xc7, 0x87, 0x1d}; + uint8_t bytesprops2[] = {0x19, 0xe1, 0xf3, 0xb0, 0xaf, 0x3f, 0xf7, 0xc9, 0x5, 0x1, 0x46, + 0xf4, 0x0, 0xef, 0x38, 0x62, 0xd0, 0xdc, 0x7f, 0xf0, 0xff, 0x25}; + uint8_t bytesprops3[] = {0x13, 0x81, 0x19, 0x51, 0x20, 0x59, 0x13, 0x52, 0x8c, 0x11, 0x2f, 0x52, 0x8b}; + uint8_t bytesprops4[] = {0xfc, 0x7b, 0x81, 0xa9, 0x19, 0x72, 0xd6, 0x34, 0xcd, 0xe2, 0x4f, 0x9c, 0xc6, 0x1d, 0x3b, + 0x7d, 0xf2, 0x5f, 0x68, 0x6e, 0x47, 0xe2, 0xe1, 0x19, 0xdb, 0x2e, 0xd7, 0xe9, 0xe8}; + uint8_t bytesprops5[] = {0x2, 0x41}; + uint8_t bytesprops6[] = {0xee, 0xc0, 0xbb, 0x25, 0x61, 0x5f, 0x1, 0xaf, 0x2f, 0x78, 0x7f, 0xa2, 0x34, + 0xe, 0xd9, 0xe, 0xd5, 0xf2, 0x3a, 0xaa, 0xe9, 0x4f, 0x9e, 0x19, 0x5b, 0x7c}; + uint8_t bytesprops7[] = {0x87, 0x5c, 0x68, 0xc1, 0x6e, 0xd6, 0x2d, 0x2b, 0x32, 0x44, 0xb4, 0xd, + 0x67, 0xb1, 0x72, 0xff, 0x60, 0x2f, 0x2f, 0xba, 0x5d, 0xce, 0x9d, 0x44}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31457}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26429}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xbb, 0x2d, 0x73, 0xe7, 0x8d, 0x7f, 0x4a, 0x71, 0xf6}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x11, 0x41, 0x73, 0xd8, 0x10, 0xd6, 0xf6, 0xc2, 0xdc, 0xb2, 0x13, 0x0, 0x4f, + 0x4e, 0xc6, 0xe2, 0x93, 0x50, 0xcd, 0xe, 0x81, 0x34, 0x1e, 0x13, 0xce}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x15, 0x5d, 0x25, 0xe3, 0xfd, 0x1c, 0x54, 0x8e, 0x3f, 0xfd, 0x43, 0x3b, 0x1, 0xbf, - 0xfa, 0xdf, 0x54, 0x1e, 0x12, 0xf7, 0x42, 0xbf, 0xc1, 0xde, 0xc4, 0x49, 0x81}; - lwmqtt_string_t topic_filter_s1 = {27, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xab, 0x30, 0xcc, 0xa0, 0x18, 0x2e, 0x8e, 0xff, 0x20, 0x86, 0xc6, + 0xdc, 0x7f, 0x40, 0xa3, 0xd8, 0x32, 0xa5, 0x8e, 0xe1, 0xd0}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc4, 0x84, 0x38, 0x4a, 0xc5, 0x38, 0xa3, 0x85, 0xe5}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x5e, 0xa3, 0xcc, 0xd5, 0x54, 0x5a, 0x22, 0xe}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x88, 0x21, 0xa7, 0x3d, 0xaa, 0xd6, 0x22, 0xe8, 0x1b, 0x20, + 0xd8, 0xae, 0x25, 0x5, 0x5d, 0xdb, 0x85, 0x7d, 0xe2, 0xeb}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x4a, 0xb6, 0x8, 0x54, 0x8c, 0x5a}; + lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xbc, 0x6e, 0x96, 0xbf, 0x4c, 0x23, 0x15, 0xc5, 0x88, + 0xc2, 0x5b, 0xc0, 0x6d, 0x8d, 0xc4, 0xa, 0xd3, 0xfc}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xc3, 0x9d, 0xad, 0x6, 0x68, 0x7f, 0xb2, 0xe6, 0xd}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x65, 0x28, 0x79, 0x13, 0xd, 0x7c, 0x2b, 0x8a, 0xd8, 0xc4, + 0x2a, 0xe3, 0x7e, 0xb4, 0x8c, 0x44, 0x58, 0xfa, 0xb5, 0x87, + 0x23, 0xd6, 0x23, 0x3b, 0x21, 0xe1, 0xa1, 0xc9}; + lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x31, 0xfc, 0xe1, 0xaf, 0x2, 0xac, 0xec, 0x16, + 0xb0, 0x32, 0x22, 0xcc, 0xb, 0x1e, 0x8, 0xbd}; + lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xda, 0xb5, 0xb2, 0xf5, 0x78, 0xbb, 0xf5, 0xa7, + 0x35, 0x90, 0xf9, 0x4c, 0x3a, 0xd1, 0x92}; + lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24245, 3, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12973, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 25032 ["\SYN;\174\NAK\140_\188\"[\SOH3z~7\194\136\&7\218\&2\SYN<\156w","V\219\229e\199 -// ","W\238\187\GS\SUB\132\133w\251\149h\178\201\DC3\204\209\201\SYN","}=\204\166\208\175.\200\192\SYNb\177","!\174\SO\173\137~:\238\166u\EOT\165\184r4\185l\201\128\190\&0f\156","\149:.\217?\"ev=\v;\158\129d\244\ACKxH{\DC4\245","J"] -// [PropAuthenticationData -// "\176\224\132\EOT\217\155yE\177\193\187\245\181\SOH\SUB@\232>\169\179\166\250\248o\139",PropTopicAlias -// 15556,PropMaximumPacketSize 12808,PropSessionExpiryInterval 32646,PropSubscriptionIdentifier -// 20,PropAssignedClientIdentifier -// "x\142b5_\202\ESC\180\209\&3\STX\252\156\226wp\237\242\240\129y\EOT\DEL\DC3\134\154\227",PropReceiveMaximum -// 26150,PropMessageExpiryInterval 32475,PropSharedSubscriptionAvailable 16,PropAssignedClientIdentifier -// "\ESC\158\248\b",PropMessageExpiryInterval 17120,PropWillDelayInterval 29419,PropMessageExpiryInterval -// 31352,PropServerReference -// "soB8\152\129\173\163\233\ESC\214/\195\254\213e\184\198\DC4\230\158l\229-\153\216I\191\SUB",PropMessageExpiryInterval -// 2639,PropMessageExpiryInterval 18192] +// UnsubscribeRequest 26764 +// ["\228\129\194\154UZ\162#\ENQ\166y\194\131\134\146\CAN\249\179\195=\\H\131_\195\ACK","\157>\170,\252e\253\207?\202o\189\&8\149\170\251\138\173}\GS\224\ACK\181\156","\139O+\138\ESC$!\248\160\249K\171\161\214,l\r\191X\ETB*\160\246\a/","","\139\149j\246C\170\168\SI\n\151\SOH\219\243\RS\222\206k\199\ESC\SUB\DC2x(5:!D","\245x0\213\130\200\229\176\SUB$\SOH\ENQ\243\153\147\242\157\219\190","jv\130p\n\255\130\158\213\218O\SYN\194W\191\188","\210\132\229-R&\239\246\ESCe\194\US.\222\DC2&\135$\210YE\129","hM{7","\206N\242@%2\218\216\138\232\155\156\n\US\248z@\207\SYN\211\221\&8\164\239\155"] +// [PropRequestProblemInformation 159,PropTopicAlias 26553,PropMaximumPacketSize 21445,PropMessageExpiryInterval +// 30316,PropMessageExpiryInterval 1951,PropRequestResponseInformation 68,PropSharedSubscriptionAvailable +// 111,PropAuthenticationData "",PropMaximumPacketSize 24610,PropRequestResponseInformation 200,PropMaximumQoS +// 96,PropMessageExpiryInterval 27215,PropMaximumQoS 97,PropRequestProblemInformation +// 195,PropSubscriptionIdentifierAvailable 110,PropServerReference "Y\220n\133\153",PropResponseTopic +// "W\199\150\221",PropAssignedClientIdentifier +// "\SYN\227A%q\207\237\NUL\200\197:\157?\247\162\201\128\186",PropContentType +// "\168_\152\181\239\150\248^K\221\190\230"] TEST(Unsubscribe5QCTest, Encode22) { uint8_t pkt[] = { - 0xa2, 0x8d, 0x2, 0x61, 0xc8, 0x93, 0x1, 0x16, 0x0, 0x19, 0xb0, 0xe0, 0x84, 0x4, 0xd9, 0x9b, 0x79, 0x45, 0xb1, - 0xc1, 0xbb, 0xf5, 0xb5, 0x1, 0x1a, 0x40, 0xe8, 0x3e, 0xa9, 0xb3, 0xa6, 0xfa, 0xf8, 0x6f, 0x8b, 0x23, 0x3c, 0xc4, - 0x27, 0x0, 0x0, 0x32, 0x8, 0x11, 0x0, 0x0, 0x7f, 0x86, 0xb, 0x14, 0x12, 0x0, 0x1b, 0x78, 0x8e, 0x62, 0x35, - 0x5f, 0xca, 0x1b, 0xb4, 0xd1, 0x33, 0x2, 0xfc, 0x9c, 0xe2, 0x77, 0x70, 0xed, 0xf2, 0xf0, 0x81, 0x79, 0x4, 0x7f, - 0x13, 0x86, 0x9a, 0xe3, 0x21, 0x66, 0x26, 0x2, 0x0, 0x0, 0x7e, 0xdb, 0x2a, 0x10, 0x12, 0x0, 0x4, 0x1b, 0x9e, - 0xf8, 0x8, 0x2, 0x0, 0x0, 0x42, 0xe0, 0x18, 0x0, 0x0, 0x72, 0xeb, 0x2, 0x0, 0x0, 0x7a, 0x78, 0x1c, 0x0, - 0x1d, 0x73, 0x6f, 0x42, 0x38, 0x98, 0x81, 0xad, 0xa3, 0xe9, 0x1b, 0xd6, 0x2f, 0xc3, 0xfe, 0xd5, 0x65, 0xb8, 0xc6, - 0x14, 0xe6, 0x9e, 0x6c, 0xe5, 0x2d, 0x99, 0xd8, 0x49, 0xbf, 0x1a, 0x2, 0x0, 0x0, 0xa, 0x4f, 0x2, 0x0, 0x0, - 0x47, 0x10, 0x0, 0x17, 0x16, 0x3b, 0xae, 0x15, 0x8c, 0x5f, 0xbc, 0x22, 0x5b, 0x1, 0x33, 0x7a, 0x7e, 0x37, 0xc2, - 0x88, 0x37, 0xda, 0x32, 0x16, 0x3c, 0x9c, 0x77, 0x0, 0x6, 0x56, 0xdb, 0xe5, 0x65, 0xc7, 0x20, 0x0, 0x12, 0x57, - 0xee, 0xbb, 0x1d, 0x1a, 0x84, 0x85, 0x77, 0xfb, 0x95, 0x68, 0xb2, 0xc9, 0x13, 0xcc, 0xd1, 0xc9, 0x16, 0x0, 0xc, - 0x7d, 0x3d, 0xcc, 0xa6, 0xd0, 0xaf, 0x2e, 0xc8, 0xc0, 0x16, 0x62, 0xb1, 0x0, 0x17, 0x21, 0xae, 0xe, 0xad, 0x89, - 0x7e, 0x3a, 0xee, 0xa6, 0x75, 0x4, 0xa5, 0xb8, 0x72, 0x34, 0xb9, 0x6c, 0xc9, 0x80, 0xbe, 0x30, 0x66, 0x9c, 0x0, - 0x15, 0x95, 0x3a, 0x2e, 0xd9, 0x3f, 0x22, 0x65, 0x76, 0x3d, 0xb, 0x3b, 0x9e, 0x81, 0x64, 0xf4, 0x6, 0x78, 0x48, - 0x7b, 0x14, 0xf5, 0x0, 0x1, 0x4a}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb0, 0xe0, 0x84, 0x4, 0xd9, 0x9b, 0x79, 0x45, 0xb1, 0xc1, 0xbb, 0xf5, 0xb5, - 0x1, 0x1a, 0x40, 0xe8, 0x3e, 0xa9, 0xb3, 0xa6, 0xfa, 0xf8, 0x6f, 0x8b}; - uint8_t bytesprops1[] = {0x78, 0x8e, 0x62, 0x35, 0x5f, 0xca, 0x1b, 0xb4, 0xd1, 0x33, 0x2, 0xfc, 0x9c, 0xe2, - 0x77, 0x70, 0xed, 0xf2, 0xf0, 0x81, 0x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0xfd, 0xcf, 0x3f, 0xca, 0x6f, 0xbd, 0x38, 0x95, 0xaa, 0xfb, 0x8a, 0xad, + 0x7d, 0x1d, 0xe0, 0x6, 0xb5, 0x9c, 0x0, 0x19, 0x8b, 0x4f, 0x2b, 0x8a, 0x1b, 0x24, 0x21, 0xf8, 0xa0, 0xf9, 0x4b, + 0xab, 0xa1, 0xd6, 0x2c, 0x6c, 0xd, 0xbf, 0x58, 0x17, 0x2a, 0xa0, 0xf6, 0x7, 0x2f, 0x0, 0x0, 0x0, 0x1b, 0x8b, + 0x95, 0x6a, 0xf6, 0x43, 0xaa, 0xa8, 0xf, 0xa, 0x97, 0x1, 0xdb, 0xf3, 0x1e, 0xde, 0xce, 0x6b, 0xc7, 0x1b, 0x1a, + 0x12, 0x78, 0x28, 0x35, 0x3a, 0x21, 0x44, 0x0, 0x13, 0xf5, 0x78, 0x30, 0xd5, 0x82, 0xc8, 0xe5, 0xb0, 0x1a, 0x24, + 0x1, 0x5, 0xf3, 0x99, 0x93, 0xf2, 0x9d, 0xdb, 0xbe, 0x0, 0x10, 0x6a, 0x76, 0x82, 0x70, 0xa, 0xff, 0x82, 0x9e, + 0xd5, 0xda, 0x4f, 0x16, 0xc2, 0x57, 0xbf, 0xbc, 0x0, 0x16, 0xd2, 0x84, 0xe5, 0x2d, 0x52, 0x26, 0xef, 0xf6, 0x1b, + 0x65, 0xc2, 0x1f, 0x2e, 0xde, 0x12, 0x26, 0x87, 0x24, 0xd2, 0x59, 0x45, 0x81, 0x0, 0x4, 0x68, 0x4d, 0x7b, 0x37, + 0x0, 0x19, 0xce, 0x4e, 0xf2, 0x40, 0x25, 0x32, 0xda, 0xd8, 0x8a, 0xe8, 0x9b, 0x9c, 0xa, 0x1f, 0xf8, 0x7a, 0x40, + 0xcf, 0x16, 0xd3, 0xdd, 0x38, 0xa4, 0xef, 0x9b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x59, 0xdc, 0x6e, 0x85, 0x99}; + uint8_t bytesprops2[] = {0x57, 0xc7, 0x96, 0xdd}; + uint8_t bytesprops3[] = {0x16, 0xe3, 0x41, 0x25, 0x71, 0xcf, 0xed, 0x0, 0xc8, + 0xc5, 0x3a, 0x9d, 0x3f, 0xf7, 0xa2, 0xc9, 0x80, 0xba}; + uint8_t bytesprops4[] = {0xa8, 0x5f, 0x98, 0xb5, 0xef, 0x96, 0xf8, 0x5e, 0x4b, 0xdd, 0xbe, 0xe6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15556}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12808}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32646}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26150}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32475}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17120}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29419}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31352}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2639}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18192}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26553}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21445}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30316}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1951}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24610}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27215}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x16, 0x3b, 0xae, 0x15, 0x8c, 0x5f, 0xbc, 0x22, 0x5b, 0x1, 0x33, 0x7a, - 0x7e, 0x37, 0xc2, 0x88, 0x37, 0xda, 0x32, 0x16, 0x3c, 0x9c, 0x77}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xe4, 0x81, 0xc2, 0x9a, 0x55, 0x5a, 0xa2, 0x23, 0x5, 0xa6, 0x79, 0xc2, 0x83, + 0x86, 0x92, 0x18, 0xf9, 0xb3, 0xc3, 0x3d, 0x5c, 0x48, 0x83, 0x5f, 0xc3, 0x6}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x56, 0xdb, 0xe5, 0x65, 0xc7, 0x20}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9d, 0x3e, 0xaa, 0x2c, 0xfc, 0x65, 0xfd, 0xcf, 0x3f, 0xca, 0x6f, 0xbd, + 0x38, 0x95, 0xaa, 0xfb, 0x8a, 0xad, 0x7d, 0x1d, 0xe0, 0x6, 0xb5, 0x9c}; + lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x57, 0xee, 0xbb, 0x1d, 0x1a, 0x84, 0x85, 0x77, 0xfb, - 0x95, 0x68, 0xb2, 0xc9, 0x13, 0xcc, 0xd1, 0xc9, 0x16}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8b, 0x4f, 0x2b, 0x8a, 0x1b, 0x24, 0x21, 0xf8, 0xa0, 0xf9, 0x4b, 0xab, 0xa1, + 0xd6, 0x2c, 0x6c, 0xd, 0xbf, 0x58, 0x17, 0x2a, 0xa0, 0xf6, 0x7, 0x2f}; + lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x7d, 0x3d, 0xcc, 0xa6, 0xd0, 0xaf, 0x2e, 0xc8, 0xc0, 0x16, 0x62, 0xb1}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x21, 0xae, 0xe, 0xad, 0x89, 0x7e, 0x3a, 0xee, 0xa6, 0x75, 0x4, 0xa5, - 0xb8, 0x72, 0x34, 0xb9, 0x6c, 0xc9, 0x80, 0xbe, 0x30, 0x66, 0x9c}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x8b, 0x95, 0x6a, 0xf6, 0x43, 0xaa, 0xa8, 0xf, 0xa, 0x97, 0x1, 0xdb, 0xf3, 0x1e, + 0xde, 0xce, 0x6b, 0xc7, 0x1b, 0x1a, 0x12, 0x78, 0x28, 0x35, 0x3a, 0x21, 0x44}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x95, 0x3a, 0x2e, 0xd9, 0x3f, 0x22, 0x65, 0x76, 0x3d, 0xb, 0x3b, - 0x9e, 0x81, 0x64, 0xf4, 0x6, 0x78, 0x48, 0x7b, 0x14, 0xf5}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf5, 0x78, 0x30, 0xd5, 0x82, 0xc8, 0xe5, 0xb0, 0x1a, 0x24, + 0x1, 0x5, 0xf3, 0x99, 0x93, 0xf2, 0x9d, 0xdb, 0xbe}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4a}; - lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x6a, 0x76, 0x82, 0x70, 0xa, 0xff, 0x82, 0x9e, + 0xd5, 0xda, 0x4f, 0x16, 0xc2, 0x57, 0xbf, 0xbc}; + lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xd2, 0x84, 0xe5, 0x2d, 0x52, 0x26, 0xef, 0xf6, 0x1b, 0x65, 0xc2, + 0x1f, 0x2e, 0xde, 0x12, 0x26, 0x87, 0x24, 0xd2, 0x59, 0x45, 0x81}; + lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x68, 0x4d, 0x7b, 0x37}; + lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xce, 0x4e, 0xf2, 0x40, 0x25, 0x32, 0xda, 0xd8, 0x8a, 0xe8, 0x9b, 0x9c, 0xa, + 0x1f, 0xf8, 0x7a, 0x40, 0xcf, 0x16, 0xd3, 0xdd, 0x38, 0xa4, 0xef, 0x9b}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25032, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26764, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 9981 ["\234","\236\168cp","~","\224\178\190\NAK\250][\147CG\225f\248\DC3\243\"\t\""] -// [PropSharedSubscriptionAvailable 83,PropMaximumPacketSize 12284,PropReasonString -// "\165\EOT\EOT\182\212_\146\172\131\222\247\253)\178_\210\RSO\SI\208\237$8p\ESC\138d",PropResponseInformation -// "\202\ETBPO",PropRetainAvailable 25,PropPayloadFormatIndicator 168,PropServerReference -// "\DC2\129(\154\245k4\239\158de\253\160\170\182l\173j",PropServerReference -// "\244h\NAK\216\SOH\NAK\154\240l^\172\193\138Z=tv\129\195\168\178\154$\154\244\214\184\ESCO",PropUserProperty -// "\190\247\160\199\252\195Q" "]hb\CAN\139\158\206\249\ESCHD%\175\n",PropAssignedClientIdentifier -// "\156\168\233\179\255\&5\173\140U\187&oi",PropRetainAvailable 187,PropSharedSubscriptionAvailable -// 238,PropSubscriptionIdentifierAvailable 17,PropRequestProblemInformation 207,PropServerKeepAlive -// 1787,PropSubscriptionIdentifierAvailable 187,PropAssignedClientIdentifier "\221",PropSessionExpiryInterval -// 22065,PropSessionExpiryInterval 24448,PropAuthenticationData "\199m\248\213[\219\249\FS\252\234<,f -// \254\206Z\142\FS\184\139\177\220\140W\RS\219\166x\160",PropWillDelayInterval 10612,PropRequestProblemInformation -// 154,PropReceiveMaximum 3414] +// UnsubscribeRequest 25855 +// ["*\148\DEL\172\179\158\a\ETX\SONJH`\204\245\213\178\t","","\132\212~\"a\157\185J\138:\200\142","\137\206\187\149\181\150l\210\253\178V\167\ESC\239@\GSD\231\139","\219\198\215\184]\249\ESC\146\186\ETB","K\140\254\EOT`\134\206\GS\195\219e\213\200\SIDy\239 +// \164","\164\146\155I\172w\DC3b\DC4qa","1k\NAK\130\DLE\202\GS\191\239B\tL\162z\ETX\213l\194\143\&6\SYN\152/\154\219e\NAKi","\247k3\164\228?\NUL\158\201\136y\202\169\202"] +// [PropReceiveMaximum 4746,PropMaximumQoS 155,PropRequestResponseInformation 245,PropMessageExpiryInterval +// 30886,PropTopicAlias 26829,PropServerKeepAlive 27060,PropSubscriptionIdentifierAvailable +// 115,PropSubscriptionIdentifier 19,PropMessageExpiryInterval 15916,PropMaximumQoS 205,PropAuthenticationMethod +// "]\DC1hJ\193\nyLW",PropTopicAlias 1188,PropUserProperty "'EF\DC4\186\211\194W\174r\200\SItbt\148" +// "\\",PropTopicAliasMaximum 18803,PropRetainAvailable 193,PropSessionExpiryInterval +// 31962,PropSubscriptionIdentifierAvailable 70,PropRetainAvailable 34,PropSubscriptionIdentifierAvailable +// 227,PropMaximumPacketSize 19223,PropWildcardSubscriptionAvailable 7,PropWildcardSubscriptionAvailable +// 21,PropMaximumPacketSize 8858,PropMessageExpiryInterval 17787,PropRequestResponseInformation 91,PropServerReference +// "\NAK\166\156B=\185\ESC\205\&7Zh\205\202\255\192\&6\STX\n\179\136_\132\245\187\&7",PropAuthenticationData +// "\180\222X\251",PropRequestProblemInformation 202,PropRequestProblemInformation 194,PropReasonString +// "&\197]$\GS\225f\222\EM"] TEST(Unsubscribe5QCTest, Encode23) { - uint8_t pkt[] = {0xa2, 0xf9, 0x1, 0x26, 0xfd, 0xd5, 0x1, 0x2a, 0x53, 0x27, 0x0, 0x0, 0x2f, 0xfc, 0x1f, 0x0, 0x1b, - 0xa5, 0x4, 0x4, 0xb6, 0xd4, 0x5f, 0x92, 0xac, 0x83, 0xde, 0xf7, 0xfd, 0x29, 0xb2, 0x5f, 0xd2, 0x1e, - 0x4f, 0xf, 0xd0, 0xed, 0x24, 0x38, 0x70, 0x1b, 0x8a, 0x64, 0x1a, 0x0, 0x4, 0xca, 0x17, 0x50, 0x4f, - 0x25, 0x19, 0x1, 0xa8, 0x1c, 0x0, 0x12, 0x12, 0x81, 0x28, 0x9a, 0xf5, 0x6b, 0x34, 0xef, 0x9e, 0x64, - 0x65, 0xfd, 0xa0, 0xaa, 0xb6, 0x6c, 0xad, 0x6a, 0x1c, 0x0, 0x1d, 0xf4, 0x68, 0x15, 0xd8, 0x1, 0x15, - 0x9a, 0xf0, 0x6c, 0x5e, 0xac, 0xc1, 0x8a, 0x5a, 0x3d, 0x74, 0x76, 0x81, 0xc3, 0xa8, 0xb2, 0x9a, 0x24, - 0x9a, 0xf4, 0xd6, 0xb8, 0x1b, 0x4f, 0x26, 0x0, 0x7, 0xbe, 0xf7, 0xa0, 0xc7, 0xfc, 0xc3, 0x51, 0x0, - 0xe, 0x5d, 0x68, 0x62, 0x18, 0x8b, 0x9e, 0xce, 0xf9, 0x1b, 0x48, 0x44, 0x25, 0xaf, 0xa, 0x12, 0x0, - 0xd, 0x9c, 0xa8, 0xe9, 0xb3, 0xff, 0x35, 0xad, 0x8c, 0x55, 0xbb, 0x26, 0x6f, 0x69, 0x25, 0xbb, 0x2a, - 0xee, 0x29, 0x11, 0x17, 0xcf, 0x13, 0x6, 0xfb, 0x29, 0xbb, 0x12, 0x0, 0x1, 0xdd, 0x11, 0x0, 0x0, - 0x56, 0x31, 0x11, 0x0, 0x0, 0x5f, 0x80, 0x16, 0x0, 0x1e, 0xc7, 0x6d, 0xf8, 0xd5, 0x5b, 0xdb, 0xf9, - 0x1c, 0xfc, 0xea, 0x3c, 0x2c, 0x66, 0x20, 0xfe, 0xce, 0x5a, 0x8e, 0x1c, 0xb8, 0x8b, 0xb1, 0xdc, 0x8c, - 0x57, 0x1e, 0xdb, 0xa6, 0x78, 0xa0, 0x18, 0x0, 0x0, 0x29, 0x74, 0x17, 0x9a, 0x21, 0xd, 0x56, 0x0, - 0x1, 0xea, 0x0, 0x4, 0xec, 0xa8, 0x63, 0x70, 0x0, 0x1, 0x7e, 0x0, 0x12, 0xe0, 0xb2, 0xbe, 0x15, - 0xfa, 0x5d, 0x5b, 0x93, 0x43, 0x47, 0xe1, 0x66, 0xf8, 0x13, 0xf3, 0x22, 0x9, 0x22}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xa5, 0x4, 0x4, 0xb6, 0xd4, 0x5f, 0x92, 0xac, 0x83, 0xde, 0xf7, 0xfd, 0x29, 0xb2, - 0x5f, 0xd2, 0x1e, 0x4f, 0xf, 0xd0, 0xed, 0x24, 0x38, 0x70, 0x1b, 0x8a, 0x64}; - uint8_t bytesprops1[] = {0xca, 0x17, 0x50, 0x4f}; - uint8_t bytesprops2[] = {0x12, 0x81, 0x28, 0x9a, 0xf5, 0x6b, 0x34, 0xef, 0x9e, - 0x64, 0x65, 0xfd, 0xa0, 0xaa, 0xb6, 0x6c, 0xad, 0x6a}; - uint8_t bytesprops3[] = {0xf4, 0x68, 0x15, 0xd8, 0x1, 0x15, 0x9a, 0xf0, 0x6c, 0x5e, 0xac, 0xc1, 0x8a, 0x5a, 0x3d, - 0x74, 0x76, 0x81, 0xc3, 0xa8, 0xb2, 0x9a, 0x24, 0x9a, 0xf4, 0xd6, 0xb8, 0x1b, 0x4f}; - uint8_t bytesprops5[] = {0x5d, 0x68, 0x62, 0x18, 0x8b, 0x9e, 0xce, 0xf9, 0x1b, 0x48, 0x44, 0x25, 0xaf, 0xa}; - uint8_t bytesprops4[] = {0xbe, 0xf7, 0xa0, 0xc7, 0xfc, 0xc3, 0x51}; - uint8_t bytesprops6[] = {0x9c, 0xa8, 0xe9, 0xb3, 0xff, 0x35, 0xad, 0x8c, 0x55, 0xbb, 0x26, 0x6f, 0x69}; - uint8_t bytesprops7[] = {0xdd}; - uint8_t bytesprops8[] = {0xc7, 0x6d, 0xf8, 0xd5, 0x5b, 0xdb, 0xf9, 0x1c, 0xfc, 0xea, 0x3c, 0x2c, 0x66, 0x20, 0xfe, - 0xce, 0x5a, 0x8e, 0x1c, 0xb8, 0x8b, 0xb1, 0xdc, 0x8c, 0x57, 0x1e, 0xdb, 0xa6, 0x78, 0xa0}; + uint8_t pkt[] = { + 0xa2, 0xb3, 0x2, 0x64, 0xff, 0x9a, 0x1, 0x21, 0x12, 0x8a, 0x24, 0x9b, 0x19, 0xf5, 0x2, 0x0, 0x0, 0x78, 0xa6, + 0x23, 0x68, 0xcd, 0x13, 0x69, 0xb4, 0x29, 0x73, 0xb, 0x13, 0x2, 0x0, 0x0, 0x3e, 0x2c, 0x24, 0xcd, 0x15, 0x0, + 0x9, 0x5d, 0x11, 0x68, 0x4a, 0xc1, 0xa, 0x79, 0x4c, 0x57, 0x23, 0x4, 0xa4, 0x26, 0x0, 0x10, 0x27, 0x45, 0x46, + 0x14, 0xba, 0xd3, 0xc2, 0x57, 0xae, 0x72, 0xc8, 0xf, 0x74, 0x62, 0x74, 0x94, 0x0, 0x1, 0x5c, 0x22, 0x49, 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71, 0x61, 0x0, 0x1c, + 0x31, 0x6b, 0x15, 0x82, 0x10, 0xca, 0x1d, 0xbf, 0xef, 0x42, 0x9, 0x4c, 0xa2, 0x7a, 0x3, 0xd5, 0x6c, 0xc2, 0x8f, + 0x36, 0x16, 0x98, 0x2f, 0x9a, 0xdb, 0x65, 0x15, 0x69, 0x0, 0xe, 0xf7, 0x6b, 0x33, 0xa4, 0xe4, 0x3f, 0x0, 0x9e, + 0xc9, 0x88, 0x79, 0xca, 0xa9, 0xca}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x5d, 0x11, 0x68, 0x4a, 0xc1, 0xa, 0x79, 0x4c, 0x57}; + uint8_t bytesprops2[] = {0x5c}; + uint8_t bytesprops1[] = {0x27, 0x45, 0x46, 0x14, 0xba, 0xd3, 0xc2, 0x57, + 0xae, 0x72, 0xc8, 0xf, 0x74, 0x62, 0x74, 0x94}; + uint8_t bytesprops3[] = {0x15, 0xa6, 0x9c, 0x42, 0x3d, 0xb9, 0x1b, 0xcd, 0x37, 0x5a, 0x68, 0xcd, 0xca, + 0xff, 0xc0, 0x36, 0x2, 0xa, 0xb3, 0x88, 0x5f, 0x84, 0xf5, 0xbb, 0x37}; + uint8_t bytesprops4[] = {0xb4, 0xde, 0x58, 0xfb}; + uint8_t bytesprops5[] = {0x26, 0xc5, 0x5d, 0x24, 0x1d, 0xe1, 0x66, 0xde, 0x19}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12284}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 25}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops4}, .v = {14, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 238}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1787}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22065}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24448}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10612}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3414}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4746}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 155}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30886}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26829}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27060}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15916}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1188}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {1, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18803}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31962}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19223}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8858}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17787}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xea}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x2a, 0x94, 0x7f, 0xac, 0xb3, 0x9e, 0x7, 0x3, 0xe, + 0x4e, 0x4a, 0x48, 0x60, 0xcc, 0xf5, 0xd5, 0xb2, 0x9}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xec, 0xa8, 0x63, 0x70}; - lwmqtt_string_t topic_filter_s1 = {4, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0}; + lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7e}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x84, 0xd4, 0x7e, 0x22, 0x61, 0x9d, 0xb9, 0x4a, 0x8a, 0x3a, 0xc8, 0x8e}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe0, 0xb2, 0xbe, 0x15, 0xfa, 0x5d, 0x5b, 0x93, 0x43, - 0x47, 0xe1, 0x66, 0xf8, 0x13, 0xf3, 0x22, 0x9, 0x22}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x89, 0xce, 0xbb, 0x95, 0xb5, 0x96, 0x6c, 0xd2, 0xfd, 0xb2, + 0x56, 0xa7, 0x1b, 0xef, 0x40, 0x1d, 0x44, 0xe7, 0x8b}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xdb, 0xc6, 0xd7, 0xb8, 0x5d, 0xf9, 0x1b, 0x92, 0xba, 0x17}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x4b, 0x8c, 0xfe, 0x4, 0x60, 0x86, 0xce, 0x1d, 0xc3, 0xdb, + 0x65, 0xd5, 0xc8, 0xf, 0x44, 0x79, 0xef, 0x20, 0xa4}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xa4, 0x92, 0x9b, 0x49, 0xac, 0x77, 0x13, 0x62, 0x14, 0x71, 0x61}; + lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x31, 0x6b, 0x15, 0x82, 0x10, 0xca, 0x1d, 0xbf, 0xef, 0x42, + 0x9, 0x4c, 0xa2, 0x7a, 0x3, 0xd5, 0x6c, 0xc2, 0x8f, 0x36, + 0x16, 0x98, 0x2f, 0x9a, 0xdb, 0x65, 0x15, 0x69}; + lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xf7, 0x6b, 0x33, 0xa4, 0xe4, 0x3f, 0x0, 0x9e, 0xc9, 0x88, 0x79, 0xca, 0xa9, 0xca}; + lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9981, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25855, 9, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 12131 [";\204\192\156\203","\131\141H4\GSjh\223\t{hE[\134\CAN\142"] [PropRetainAvailable -// 221,PropRequestProblemInformation 37,PropReceiveMaximum 2247,PropSharedSubscriptionAvailable 7,PropResponseTopic -// "\163\170\&0\238\148\by\229\227g\164\222&\153\137\238L\211\200\192\207\253n\243",PropMessageExpiryInterval -// 13609,PropSubscriptionIdentifier 4,PropResponseInformation -// "\208\ACK\139\252\DC1\ETB\SUB\SYN\154\222\228*\228\CAN\216\139\181",PropMaximumQoS 41,PropMaximumQoS -// 249,PropRequestResponseInformation 149,PropSubscriptionIdentifier 32,PropRequestResponseInformation -// 120,PropTopicAlias 26179,PropServerReference "\249",PropAuthenticationMethod -// "f\142k\131\137\241\&3%\EOT\133\148\168g\140\DC1Q\187\226\169>5\208",PropRetainAvailable 64,PropWillDelayInterval -// 28574,PropResponseTopic "\DLE\246\142\&5\157\168C\255pV\141\v\230\162\222h@ s",PropMessageExpiryInterval -// 32507,PropMaximumQoS 35,PropMaximumQoS 246,PropPayloadFormatIndicator 78,PropSessionExpiryInterval -// 24294,PropMaximumQoS 182,PropMaximumQoS 76,PropContentType "P\232\DC1\144\ETB.\162\147@",PropServerReference -// ".\202T\DLE\ENQy\248R\209\128",PropMessageExpiryInterval 4809] +// UnsubscribeRequest 20087 ["","\223$\157\133\154\STXu\172d\221\239W\239\v\142#\151b"] [PropRequestResponseInformation +// 3,PropReasonString ")%\140\151\134E\255I\165\DC1\"\184]",PropSubscriptionIdentifierAvailable +// 226,PropResponseInformation +// "\152t\255\184Y[\128\217\FS\143\204S\186g\129W\137\239\224\171S\159\FS;",PropRetainAvailable +// 150,PropResponseInformation "R,\246g\249\&1y\136\219",PropSubscriptionIdentifier 0,PropTopicAlias +// 8160,PropAuthenticationMethod "\135\232\217w\144\SI\133@\128\&2S_d\137\183\140",PropUserProperty "\167\215\240" +// "\197\169\ETB\219\250",PropRetainAvailable 186] TEST(Unsubscribe5QCTest, Encode24) { - uint8_t pkt[] = {0xa2, 0xd5, 0x1, 0x2f, 0x63, 0xb8, 0x1, 0x25, 0xdd, 0x17, 0x25, 0x21, 0x8, 0xc7, 0x2a, 0x7, 0x8, - 0x0, 0x18, 0xa3, 0xaa, 0x30, 0xee, 0x94, 0x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, 0x86, 0x18, 0x8e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xa3, 0xaa, 0x30, 0xee, 0x94, 0x8, 0x79, 0xe5, 0xe3, 0x67, 0xa4, 0xde, - 0x26, 0x99, 0x89, 0xee, 0x4c, 0xd3, 0xc8, 0xc0, 0xcf, 0xfd, 0x6e, 0xf3}; - uint8_t bytesprops1[] = {0xd0, 0x6, 0x8b, 0xfc, 0x11, 0x17, 0x1a, 0x16, 0x9a, - 0xde, 0xe4, 0x2a, 0xe4, 0x18, 0xd8, 0x8b, 0xb5}; - uint8_t bytesprops2[] = {0xf9}; - uint8_t bytesprops3[] = {0x66, 0x8e, 0x6b, 0x83, 0x89, 0xf1, 0x33, 0x25, 0x4, 0x85, 0x94, - 0xa8, 0x67, 0x8c, 0x11, 0x51, 0xbb, 0xe2, 0xa9, 0x3e, 0x35, 0xd0}; - uint8_t bytesprops4[] = {0x10, 0xf6, 0x8e, 0x35, 0x9d, 0xa8, 0x43, 0xff, 0x70, 0x56, - 0x8d, 0xb, 0xe6, 0xa2, 0xde, 0x68, 0x40, 0x20, 0x73}; - uint8_t bytesprops5[] = {0x50, 0xe8, 0x11, 0x90, 0x17, 0x2e, 0xa2, 0x93, 0x40}; - uint8_t bytesprops6[] = {0x2e, 0xca, 0x54, 0x10, 0x5, 0x79, 0xf8, 0x52, 0xd1, 0x80}; + uint8_t pkt[] = {0xa2, 0x7d, 0x4e, 0x77, 0x64, 0x19, 0x3, 0x1f, 0x0, 0xd, 0x29, 0x25, 0x8c, 0x97, 0x86, 0x45, + 0xff, 0x49, 0xa5, 0x11, 0x22, 0xb8, 0x5d, 0x29, 0xe2, 0x1a, 0x0, 0x18, 0x98, 0x74, 0xff, 0xb8, + 0x59, 0x5b, 0x80, 0xd9, 0x1c, 0x8f, 0xcc, 0x53, 0xba, 0x67, 0x81, 0x57, 0x89, 0xef, 0xe0, 0xab, + 0x53, 0x9f, 0x1c, 0x3b, 0x25, 0x96, 0x1a, 0x0, 0x9, 0x52, 0x2c, 0xf6, 0x67, 0xf9, 0x31, 0x79, + 0x88, 0xdb, 0xb, 0x0, 0x23, 0x1f, 0xe0, 0x15, 0x0, 0x10, 0x87, 0xe8, 0xd9, 0x77, 0x90, 0xf, + 0x85, 0x40, 0x80, 0x32, 0x53, 0x5f, 0x64, 0x89, 0xb7, 0x8c, 0x26, 0x0, 0x3, 0xa7, 0xd7, 0xf0, + 0x0, 0x5, 0xc5, 0xa9, 0x17, 0xdb, 0xfa, 0x25, 0xba, 0x0, 0x0, 0x0, 0x12, 0xdf, 0x24, 0x9d, + 0x85, 0x9a, 0x2, 0x75, 0xac, 0x64, 0xdd, 0xef, 0x57, 0xef, 0xb, 0x8e, 0x23, 0x97, 0x62}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x29, 0x25, 0x8c, 0x97, 0x86, 0x45, 0xff, 0x49, 0xa5, 0x11, 0x22, 0xb8, 0x5d}; + uint8_t bytesprops1[] = {0x98, 0x74, 0xff, 0xb8, 0x59, 0x5b, 0x80, 0xd9, 0x1c, 0x8f, 0xcc, 0x53, + 0xba, 0x67, 0x81, 0x57, 0x89, 0xef, 0xe0, 0xab, 0x53, 0x9f, 0x1c, 0x3b}; + uint8_t bytesprops2[] = {0x52, 0x2c, 0xf6, 0x67, 0xf9, 0x31, 0x79, 0x88, 0xdb}; + uint8_t bytesprops3[] = {0x87, 0xe8, 0xd9, 0x77, 0x90, 0xf, 0x85, 0x40, + 0x80, 0x32, 0x53, 0x5f, 0x64, 0x89, 0xb7, 0x8c}; + uint8_t bytesprops5[] = {0xc5, 0xa9, 0x17, 0xdb, 0xfa}; + uint8_t bytesprops4[] = {0xa7, 0xd7, 0xf0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2247}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13609}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 32}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26179}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28574}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32507}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24294}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4809}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8160}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops4}, .v = {5, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 186}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x3b, 0xcc, 0xc0, 0x9c, 0xcb}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x83, 0x8d, 0x48, 0x34, 0x1d, 0x6a, 0x68, 0xdf, - 0x9, 0x7b, 0x68, 0x45, 0x5b, 0x86, 0x18, 0x8e}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xdf, 0x24, 0x9d, 0x85, 0x9a, 0x2, 0x75, 0xac, 0x64, + 0xdd, 0xef, 0x57, 0xef, 0xb, 0x8e, 0x23, 0x97, 0x62}; + lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12131, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20087, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 2785 -// ["\208\203\198\224\198v\210\132\218\207\b","\DC4g\193CEY\226\133{\205;","\129E\167\RSx\161\SI\218\ENQ\196\149\136\243\170j\166\208\132m\DEL","lI\225V\SYN&\228E\191\236\171\EM\199eL\DLE-\191\155\223\&5\193\b","\154\ENQp\158 -// dj\212\228\243\245\179\ESC\140\SI\ACK\193\215\a\FSR\DLE","\236\152b\183\203\239\189:A\241\200\CAN\207\221i","\198By$\ACK","\147\f\237\210\b\144w}\129d","\176\231\145U\138\241\252\185\178\238\136oQ\ENQ\187\168\228\197","*\210\FS\252"] -// [PropRetainAvailable 81,PropWildcardSubscriptionAvailable 94,PropPayloadFormatIndicator -// 176,PropSharedSubscriptionAvailable 192,PropUserProperty "\189f\SUBc\254\SO" -// "!6\174\DC4\EOTm%\182\180Ok$rV*\225\\(\167\232\&9q",PropSessionExpiryInterval 29837,PropAssignedClientIdentifier -// ":\246.\GS\193r\DC4\224\186-\209\176\208u\211\&2\251\135\ACK\136\212\145\161\195Y",PropMaximumPacketSize -// 1899,PropSharedSubscriptionAvailable 191,PropReceiveMaximum 8879,PropPayloadFormatIndicator 19,PropResponseTopic -// "\246\128\218f\254\213\&4R\145\140\244\212\173\221;\ENQ\168\255\&6m\STXK\203f",PropAuthenticationMethod -// "o\202\DC4-\246{w\202\234f\179 "] +// UnsubscribeRequest 23904 +// ["\149\138G<\153B","\176\152\174\227C\212\140\237\176F\225\157","\250\193{\220\129\129\245u\242\229\214\GS\252\173y\184p\165*\244}\215","\ESCB3C\185\170*\235\146\140H11H\198\156\223\DEL\131\144\131\136\224s\209k\b\195\FS"] +// [PropRequestResponseInformation 126,PropMessageExpiryInterval 20576,PropResponseInformation +// "\GS\210\159\237\184\ETXZx",PropAssignedClientIdentifier +// "f\141?\139F\241<\223\DC2\\\201\166\153!\216\r\174\219\197X|y\251\206 \US\178",PropAuthenticationMethod +// "[)wR)\191\177\239",PropUserProperty "B\162\na(Jq\ETB\164%I\163\187\154s\181\244\&2\n;\166\185&9" +// "\225~\227\214{bd\204\152[)c\SOk\DC4,\156c;\189\169\&3\ACK\142\EOT7",PropSubscriptionIdentifierAvailable +// 121,PropRequestResponseInformation 136,PropSessionExpiryInterval 1977,PropCorrelationData +// "\DC1\158\198\247\f\DC2\164U{\a\172\244Ks\213T\SOH\178\NUL\219H\189&IS\191-\rR\254",PropSubscriptionIdentifier +// 22,PropWillDelayInterval 22819,PropReasonString +// "\r\200Y\248\191\228\153\196,\f\144\143\\\244\SI\145<\214\226\135\f\f\169",PropTopicAlias 25943,PropUserProperty +// "\153\NUL\233\&0\180\203\v" "\203"] TEST(Unsubscribe5QCTest, Encode25) { uint8_t pkt[] = { - 0xa2, 0xa3, 0x2, 0xa, 0xe1, 0x80, 0x1, 0x25, 0x51, 0x28, 0x5e, 0x1, 0xb0, 0x2a, 0xc0, 0x26, 0x0, 0x6, 0xbd, - 0x66, 0x1a, 0x63, 0xfe, 0xe, 0x0, 0x16, 0x21, 0x36, 0xae, 0x14, 0x4, 0x6d, 0x25, 0xb6, 0xb4, 0x4f, 0x6b, 0x24, - 0x72, 0x56, 0x2a, 0xe1, 0x5c, 0x28, 0xa7, 0xe8, 0x39, 0x71, 0x11, 0x0, 0x0, 0x74, 0x8d, 0x12, 0x0, 0x19, 0x3a, - 0xf6, 0x2e, 0x1d, 0xc1, 0x72, 0x14, 0xe0, 0xba, 0x2d, 0xd1, 0xb0, 0xd0, 0x75, 0xd3, 0x32, 0xfb, 0x87, 0x6, 0x88, - 0xd4, 0x91, 0xa1, 0xc3, 0x59, 0x27, 0x0, 0x0, 0x7, 0x6b, 0x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x55, 0x8a, 0xf1, 0xfc, 0xb9, 0xb2, 0xee, 0x88, 0x6f, 0x51, 0x5, 0xbb, - 0xa8, 0xe4, 0xc5, 0x0, 0x4, 0x2a, 0xd2, 0x1c, 0xfc}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x21, 0x36, 0xae, 0x14, 0x4, 0x6d, 0x25, 0xb6, 0xb4, 0x4f, 0x6b, - 0x24, 0x72, 0x56, 0x2a, 0xe1, 0x5c, 0x28, 0xa7, 0xe8, 0x39, 0x71}; - uint8_t bytesprops0[] = {0xbd, 0x66, 0x1a, 0x63, 0xfe, 0xe}; - uint8_t bytesprops2[] = {0x3a, 0xf6, 0x2e, 0x1d, 0xc1, 0x72, 0x14, 0xe0, 0xba, 0x2d, 0xd1, 0xb0, 0xd0, - 0x75, 0xd3, 0x32, 0xfb, 0x87, 0x6, 0x88, 0xd4, 0x91, 0xa1, 0xc3, 0x59}; - uint8_t bytesprops3[] = {0xf6, 0x80, 0xda, 0x66, 0xfe, 0xd5, 0x34, 0x52, 0x91, 0x8c, 0xf4, 0xd4, - 0xad, 0xdd, 0x3b, 0x5, 0xa8, 0xff, 0x36, 0x6d, 0x2, 0x4b, 0xcb, 0x66}; - uint8_t bytesprops4[] = {0x6f, 0xca, 0x14, 0x2d, 0xf6, 0x7b, 0x77, 0xca, 0xea, 0x66, 0xb3, 0x20}; + 0xa2, 0x9e, 0x2, 0x5d, 0x60, 0xcd, 0x1, 0x19, 0x7e, 0x2, 0x0, 0x0, 0x50, 0x60, 0x1a, 0x0, 0x8, 0x1d, 0xd2, + 0x9f, 0xed, 0xb8, 0x3, 0x5a, 0x78, 0x12, 0x0, 0x1b, 0x66, 0x8d, 0x3f, 0x8b, 0x46, 0xf1, 0x3c, 0xdf, 0x12, 0x5c, + 0xc9, 0xa6, 0x99, 0x21, 0xd8, 0xd, 0xae, 0xdb, 0xc5, 0x58, 0x7c, 0x79, 0xfb, 0xce, 0x20, 0x1f, 0xb2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xf5, 0x75, 0xf2, 0xe5, 0xd6, + 0x1d, 0xfc, 0xad, 0x79, 0xb8, 0x70, 0xa5, 0x2a, 0xf4, 0x7d, 0xd7, 0x0, 0x1d, 0x1b, 0x42, 0x33, 0x43, 0xb9, 0xaa, + 0x2a, 0xeb, 0x92, 0x8c, 0x48, 0x31, 0x31, 0x48, 0xc6, 0x9c, 0xdf, 0x7f, 0x83, 0x90, 0x83, 0x88, 0xe0, 0x73, 0xd1, + 0x6b, 0x8, 0xc3, 0x1c}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1d, 0xd2, 0x9f, 0xed, 0xb8, 0x3, 0x5a, 0x78}; + uint8_t bytesprops1[] = {0x66, 0x8d, 0x3f, 0x8b, 0x46, 0xf1, 0x3c, 0xdf, 0x12, 0x5c, 0xc9, 0xa6, 0x99, 0x21, + 0xd8, 0xd, 0xae, 0xdb, 0xc5, 0x58, 0x7c, 0x79, 0xfb, 0xce, 0x20, 0x1f, 0xb2}; + uint8_t bytesprops2[] = {0x5b, 0x29, 0x77, 0x52, 0x29, 0xbf, 0xb1, 0xef}; + uint8_t bytesprops4[] = {0xe1, 0x7e, 0xe3, 0xd6, 0x7b, 0x62, 0x64, 0xcc, 0x98, 0x5b, 0x29, 0x63, 0xe, + 0x6b, 0x14, 0x2c, 0x9c, 0x63, 0x3b, 0xbd, 0xa9, 0x33, 0x6, 0x8e, 0x4, 0x37}; + uint8_t bytesprops3[] = {0x42, 0xa2, 0xa, 0x61, 0x28, 0x4a, 0x71, 0x17, 0xa4, 0x25, 0x49, 0xa3, + 0xbb, 0x9a, 0x73, 0xb5, 0xf4, 0x32, 0xa, 0x3b, 0xa6, 0xb9, 0x26, 0x39}; + uint8_t bytesprops5[] = {0x11, 0x9e, 0xc6, 0xf7, 0xc, 0x12, 0xa4, 0x55, 0x7b, 0x7, 0xac, 0xf4, 0x4b, 0x73, 0xd5, + 0x54, 0x1, 0xb2, 0x0, 0xdb, 0x48, 0xbd, 0x26, 0x49, 0x53, 0xbf, 0x2d, 0xd, 0x52, 0xfe}; + uint8_t bytesprops6[] = {0xd, 0xc8, 0x59, 0xf8, 0xbf, 0xe4, 0x99, 0xc4, 0x2c, 0xc, 0x90, 0x8f, + 0x5c, 0xf4, 0xf, 0x91, 0x3c, 0xd6, 0xe2, 0x87, 0xc, 0xc, 0xa9}; + uint8_t bytesprops8[] = {0xcb}; + uint8_t bytesprops7[] = {0x99, 0x0, 0xe9, 0x30, 0xb4, 0xcb, 0xb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {22, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29837}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1899}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8879}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 19}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20576}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops3}, .v = {26, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1977}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22819}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25943}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops7}, .v = {1, (char*)&bytesprops8}}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xd0, 0xcb, 0xc6, 0xe0, 0xc6, 0x76, 0xd2, 0x84, 0xda, 0xcf, 0x8}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x95, 0x8a, 0x47, 0x3c, 0x99, 0x42}; + lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x14, 0x67, 0xc1, 0x43, 0x45, 0x59, 0xe2, 0x85, 0x7b, 0xcd, 0x3b}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb0, 0x98, 0xae, 0xe3, 0x43, 0xd4, 0x8c, 0xed, 0xb0, 0x46, 0xe1, 0x9d}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x81, 0x45, 0xa7, 0x1e, 0x78, 0xa1, 0xf, 0xda, 0x5, 0xc4, - 0x95, 0x88, 0xf3, 0xaa, 0x6a, 0xa6, 0xd0, 0x84, 0x6d, 0x7f}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xfa, 0xc1, 0x7b, 0xdc, 0x81, 0x81, 0xf5, 0x75, 0xf2, 0xe5, 0xd6, + 0x1d, 0xfc, 0xad, 0x79, 0xb8, 0x70, 0xa5, 0x2a, 0xf4, 0x7d, 0xd7}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x6c, 0x49, 0xe1, 0x56, 0x16, 0x26, 0xe4, 0x45, 0xbf, 0xec, 0xab, 0x19, - 0xc7, 0x65, 0x4c, 0x10, 0x2d, 0xbf, 0x9b, 0xdf, 0x35, 0xc1, 0x8}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x1b, 0x42, 0x33, 0x43, 0xb9, 0xaa, 0x2a, 0xeb, 0x92, 0x8c, + 0x48, 0x31, 0x31, 0x48, 0xc6, 0x9c, 0xdf, 0x7f, 0x83, 0x90, + 0x83, 0x88, 0xe0, 0x73, 0xd1, 0x6b, 0x8, 0xc3, 0x1c}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9a, 0x5, 0x70, 0x9e, 0x20, 0x64, 0x6a, 0xd4, 0xe4, 0xf3, 0xf5, - 0xb3, 0x1b, 0x8c, 0xf, 0x6, 0xc1, 0xd7, 0x7, 0x1c, 0x52, 0x10}; - lwmqtt_string_t topic_filter_s4 = {22, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xec, 0x98, 0x62, 0xb7, 0xcb, 0xef, 0xbd, 0x3a, - 0x41, 0xf1, 0xc8, 0x18, 0xcf, 0xdd, 0x69}; - lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc6, 0x42, 0x79, 0x24, 0x6}; - lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x93, 0xc, 0xed, 0xd2, 0x8, 0x90, 0x77, 0x7d, 0x81, 0x64}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xb0, 0xe7, 0x91, 0x55, 0x8a, 0xf1, 0xfc, 0xb9, 0xb2, - 0xee, 0x88, 0x6f, 0x51, 0x5, 0xbb, 0xa8, 0xe4, 0xc5}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x2a, 0xd2, 0x1c, 0xfc}; - lwmqtt_string_t topic_filter_s9 = {4, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2785, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23904, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 3283 -// ["\151","\140k\206\231T4\165\221\&7\206\161\&9\DC2z9\GS\146\232`AuR/&\215\192\226\253","\243?\170\SYNAk\239?W\173","\143l\157\212\165\140<-\"\250\185\166\SOHpBD\213\&5Y3\178\150\186\n\187\194%","\r\250\DLE'?\210\182\153\215\198\173\206k\201Vo\185\236\229\229","\176\171\220\205\STX>\227\CAN\239\167OEZ0s\170\DC2\165B\132r\134?\170L\216\246\162\"\136","\208^\167Dh\248\177\171~k\f\134U8 -// \216\198\252\130\US\DEL*Mq)\186","\164[\150\159l\245a\169W]\ENQ=D\230\143\235\193\215\183:\217\244\EOT\236\CAN\221)\210","\191X\198\252\128?S\147\r>O\b\SUB\215L\222\239\201\157dEh\236\DC2\214'\186\243\\\161"] -// [PropRequestResponseInformation 161,PropRetainAvailable 224,PropMaximumQoS 111] +// UnsubscribeRequest 18211 ["RU\203\SOH\227Nbl11R~\206d\203\245\&9b\205\253","`\149\SUB<\b\128\137\250\185\176\EM\204"] +// [PropResponseTopic "\228\226;\179\141\151C\192J\132\179M\156#\ENQ\151\ACK/_Vw\209\218\220 ",PropReceiveMaximum +// 9650,PropAuthenticationData "\179\202\rA\NAKH\170[",PropSubscriptionIdentifierAvailable 9,PropSubscriptionIdentifier +// 8,PropRequestResponseInformation 187,PropSubscriptionIdentifierAvailable 252,PropSubscriptionIdentifierAvailable +// 40,PropTopicAliasMaximum 31349,PropSharedSubscriptionAvailable 79,PropMaximumQoS 249,PropResponseInformation +// "\SUB\EOT\154\167",PropReasonString +// "\STX\173\152x\235-\233\166)\244\237$\162\ETB\231\190\147xsk\253\&4\145\193BV\ETB"] TEST(Unsubscribe5QCTest, Encode26) { - uint8_t pkt[] = { - 0xa2, 0x87, 0x2, 0xc, 0xd3, 0x6, 0x19, 0xa1, 0x25, 0xe0, 0x24, 0x6f, 0x0, 0x1, 0x97, 0x0, 0x1c, 0x8c, 0x6b, - 0xce, 0xe7, 0x54, 0x34, 0xa5, 0xdd, 0x37, 0xce, 0xa1, 0x39, 0x12, 0x7a, 0x39, 0x1d, 0x92, 0xe8, 0x60, 0x41, 0x75, - 0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eb, 0xc1, 0xd7, 0xb7, 0x3a, 0xd9, 0xf4, - 0x4, 0xec, 0x18, 0xdd, 0x29, 0xd2, 0x0, 0x1e, 0xbf, 0x58, 0xc6, 0xfc, 0x80, 0x3f, 0x53, 0x93, 0xd, 0x3e, 0x4f, - 0x8, 0x1a, 0xd7, 0x4c, 0xde, 0xef, 0xc9, 0x9d, 0x64, 0x45, 0x68, 0xec, 0x12, 0xd6, 0x27, 0xba, 0xf3, 0x5c, 0xa1}; - uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t pkt[] = {0xa2, 0x87, 0x1, 0x47, 0x23, 0x60, 0x8, 0x0, 0x19, 0xe4, 0xe2, 0x3b, 0xb3, 0x8d, 0x97, 0x43, + 0xc0, 0x4a, 0x84, 0xb3, 0x4d, 0x9c, 0x23, 0x5, 0x97, 0x6, 0x2f, 0x5f, 0x56, 0x77, 0xd1, 0xda, + 0xdc, 0x20, 0x21, 0x25, 0xb2, 0x16, 0x0, 0x8, 0xb3, 0xca, 0xd, 0x41, 0x15, 0x48, 0xaa, 0x5b, + 0x29, 0x9, 0xb, 0x8, 0x19, 0xbb, 0x29, 0xfc, 0x29, 0x28, 0x22, 0x7a, 0x75, 0x2a, 0x4f, 0x24, + 0xf9, 0x1a, 0x0, 0x4, 0x1a, 0x4, 0x9a, 0xa7, 0x1f, 0x0, 0x1b, 0x2, 0xad, 0x98, 0x78, 0xeb, + 0x2d, 0xe9, 0xa6, 0x29, 0xf4, 0xed, 0x24, 0xa2, 0x17, 0xe7, 0xbe, 0x93, 0x78, 0x73, 0x6b, 0xfd, + 0x34, 0x91, 0xc1, 0x42, 0x56, 0x17, 0x0, 0x14, 0x52, 0x55, 0xcb, 0x1, 0xe3, 0x4e, 0x62, 0x6c, + 0x31, 0x31, 0x52, 0x7e, 0xce, 0x64, 0xcb, 0xf5, 0x39, 0x62, 0xcd, 0xfd, 0x0, 0xc, 0x60, 0x95, + 0x1a, 0x3c, 0x8, 0x80, 0x89, 0xfa, 0xb9, 0xb0, 0x19, 0xcc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe4, 0xe2, 0x3b, 0xb3, 0x8d, 0x97, 0x43, 0xc0, 0x4a, 0x84, 0xb3, 0x4d, 0x9c, + 0x23, 0x5, 0x97, 0x6, 0x2f, 0x5f, 0x56, 0x77, 0xd1, 0xda, 0xdc, 0x20}; + uint8_t bytesprops1[] = {0xb3, 0xca, 0xd, 0x41, 0x15, 0x48, 0xaa, 0x5b}; + uint8_t bytesprops2[] = {0x1a, 0x4, 0x9a, 0xa7}; + uint8_t bytesprops3[] = {0x2, 0xad, 0x98, 0x78, 0xeb, 0x2d, 0xe9, 0xa6, 0x29, 0xf4, 0xed, 0x24, 0xa2, 0x17, + 0xe7, 0xbe, 0x93, 0x78, 0x73, 0x6b, 0xfd, 0x34, 0x91, 0xc1, 0x42, 0x56, 0x17}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9650}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31349}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x97}; - lwmqtt_string_t topic_filter_s0 = {1, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x52, 0x55, 0xcb, 0x1, 0xe3, 0x4e, 0x62, 0x6c, 0x31, 0x31, + 0x52, 0x7e, 0xce, 0x64, 0xcb, 0xf5, 0x39, 0x62, 0xcd, 0xfd}; + lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8c, 0x6b, 0xce, 0xe7, 0x54, 0x34, 0xa5, 0xdd, 0x37, 0xce, - 0xa1, 0x39, 0x12, 0x7a, 0x39, 0x1d, 0x92, 0xe8, 0x60, 0x41, - 0x75, 0x52, 0x2f, 0x26, 0xd7, 0xc0, 0xe2, 0xfd}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x60, 0x95, 0x1a, 0x3c, 0x8, 0x80, 0x89, 0xfa, 0xb9, 0xb0, 0x19, 0xcc}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf3, 0x3f, 0xaa, 0x16, 0x41, 0x6b, 0xef, 0x3f, 0x57, 0xad}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8f, 0x6c, 0x9d, 0xd4, 0xa5, 0x8c, 0x3c, 0x2d, 0x22, 0xfa, 0xb9, 0xa6, 0x1, 0x70, - 0x42, 0x44, 0xd5, 0x35, 0x59, 0x33, 0xb2, 0x96, 0xba, 0xa, 0xbb, 0xc2, 0x25}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd, 0xfa, 0x10, 0x3c, 0x67, 0x95, 0xe0, 0x9f, 0x9f, 0x98, - 0xd3, 0x69, 0x87, 0xa3, 0x8e, 0x26, 0xa5, 0xdb, 0x19, 0x3a, - 0xf, 0x10, 0x36, 0x5b, 0xbb, 0x71, 0x21, 0x24}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x3, 0x53, 0xfb, 0x81, 0x85, 0x2c, 0xb7, 0xba, 0x3e, 0x27, 0x3f, 0xd2, 0xb6, - 0x99, 0xd7, 0xc6, 0xad, 0xce, 0x6b, 0xc9, 0x56, 0x6f, 0xb9, 0xec, 0xe5, 0xe5}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb0, 0xab, 0xdc, 0xcd, 0x2, 0x3e, 0xe3, 0x18, 0xef, 0xa7, - 0x4f, 0x45, 0x5a, 0x30, 0x73, 0xaa, 0x12, 0xa5, 0x42, 0x84, - 0x72, 0x86, 0x3f, 0xaa, 0x4c, 0xd8, 0xf6, 0xa2, 0x22, 0x88}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xd0, 0x5e, 0xa7, 0x44, 0x68, 0xf8, 0xb1, 0xab, 0x7e, 0x6b, 0xc, 0x86, 0x55, - 0x38, 0x20, 0xd8, 0xc6, 0xfc, 0x82, 0x1f, 0x7f, 0x2a, 0x4d, 0x71, 0x29, 0xba}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa4, 0x5b, 0x96, 0x9f, 0x6c, 0xf5, 0x61, 0xa9, 0x57, 0x5d, - 0x5, 0x3d, 0x44, 0xe6, 0x8f, 0xeb, 0xc1, 0xd7, 0xb7, 0x3a, - 0xd9, 0xf4, 0x4, 0xec, 0x18, 0xdd, 0x29, 0xd2}; - lwmqtt_string_t topic_filter_s8 = {28, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xbf, 0x58, 0xc6, 0xfc, 0x80, 0x3f, 0x53, 0x93, 0xd, 0x3e, - 0x4f, 0x8, 0x1a, 0xd7, 0x4c, 0xde, 0xef, 0xc9, 0x9d, 0x64, - 0x45, 0x68, 0xec, 0x12, 0xd6, 0x27, 0xba, 0xf3, 0x5c, 0xa1}; - lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 3283, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18211, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22892 -// ["\235\157\254\138\f\159\160H\226\159\167\206[L\221\133p\185;","/\162\192\a\217\171[\233\178\227GTN~\SOHzIl\DC3G\195C(FH\241=He\251","n\212\225g\136\SYNK\222\238\207\137","","\ETB7!\RSO\252\EM4B\253\DEL\USs}\246e\192\201\135\DC1\174","\183~\216m","\174K\216\SUB\179 -// \EMB\EMpq\EMl"] [PropMessageExpiryInterval 30491,PropMessageExpiryInterval 12126] +// UnsubscribeRequest 14225 +// ["w9A\n=\f\239P\248iomV\246\230\219\f\234i\245,\136e","\200\&0&V\131\EM%\176\170R\209\166^<\170\200\220f\222\a\FSD",".2^.\242\r\198","\r\229\166\187f\244\188%\151\213W\198\150\a\f\201\245yH\193\137&9\246\209Ka\148\140\RS","\RSCb/b\143\151\172\STXL\167\129\186\142\252\160\218\NAK\155\134\EOT\191\247w","\206A\231S\173\254M9R\DC3\177$O\225d\222\175+\207\138FN\249\225\231\251"] +// [PropMessageExpiryInterval 14571,PropSubscriptionIdentifier 13,PropAuthenticationMethod +// "3^D\214jp\215\148\138K6\253\238\EMsL\bZn[/\195\238\195uc\ETB",PropSubscriptionIdentifier 19,PropContentType +// "\187\246\195\252\139k\149\142\234\225+8!\167Tcm\130\241e\245&\aR\240\249",PropWildcardSubscriptionAvailable +// 182,PropResponseTopic +// "\231\219E\255\NAK#\225\a\NUL\248X(\159\250=8\234\236\249)\160\133\140\v\225\143",PropSharedSubscriptionAvailable +// 127,PropWillDelayInterval 12781,PropResponseTopic +// "\201\242\a\233\DEL\235\f\177\209\244^",PropSubscriptionIdentifierAvailable 83,PropSubscriptionIdentifierAvailable +// 134,PropRequestProblemInformation 131,PropSubscriptionIdentifierAvailable 134,PropUserProperty +// "\141\&4o\186\135\209\251\236\ENQ\179t\147\160y" "R\FS\NUL",PropWillDelayInterval +// 14661,PropRequestResponseInformation 172] TEST(Unsubscribe5QCTest, Encode27) { - uint8_t pkt[] = {0xa2, 0x7d, 0x59, 0x6c, 0xa, 0x2, 0x0, 0x0, 0x77, 0x1b, 0x2, 0x0, 0x0, 0x2f, 0x5e, 0x0, - 0x13, 0xeb, 0x9d, 0xfe, 0x8a, 0xc, 0x9f, 0xa0, 0x48, 0xe2, 0x9f, 0xa7, 0xce, 0x5b, 0x4c, 0xdd, - 0x85, 0x70, 0xb9, 0x3b, 0x0, 0x1e, 0x2f, 0xa2, 0xc0, 0x7, 0xd9, 0xab, 0x5b, 0xe9, 0xb2, 0xe3, - 0x47, 0x54, 0x4e, 0x7e, 0x1, 0x7a, 0x49, 0x6c, 0x13, 0x47, 0xc3, 0x43, 0x28, 0x46, 0x48, 0xf1, - 0x3d, 0x48, 0x65, 0xfb, 0x0, 0xb, 0x6e, 0xd4, 0xe1, 0x67, 0x88, 0x16, 0x4b, 0xde, 0xee, 0xcf, - 0x89, 0x0, 0x0, 0x0, 0x15, 0x17, 0x37, 0x21, 0x1e, 0x4f, 0xfc, 0x19, 0x34, 0x42, 0xfd, 0x7f, - 0x1f, 0x73, 0x7d, 0xf6, 0x65, 0xc0, 0xc9, 0x87, 0x11, 0xae, 0x0, 0x4, 0xb7, 0x7e, 0xd8, 0x6d, - 0x0, 0xd, 0xae, 0x4b, 0xd8, 0x1a, 0xb3, 0x20, 0x19, 0x42, 0x19, 0x70, 0x71, 0x19, 0x6c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t pkt[] = { + 0xa2, 0xb1, 0x2, 0x37, 0x91, 0x9d, 0x1, 0x2, 0x0, 0x0, 0x38, 0xeb, 0xb, 0xd, 0x15, 0x0, 0x1b, 0x33, 0x5e, + 0x44, 0xd6, 0x6a, 0x70, 0xd7, 0x94, 0x8a, 0x4b, 0x36, 0xfd, 0xee, 0x19, 0x73, 0x4c, 0x8, 0x5a, 0x6e, 0x5b, 0x2f, + 0xc3, 0xee, 0xc3, 0x75, 0x63, 0x17, 0xb, 0x13, 0x3, 0x0, 0x1a, 0xbb, 0xf6, 0xc3, 0xfc, 0x8b, 0x6b, 0x95, 0x8e, + 0xea, 0xe1, 0x2b, 0x38, 0x21, 0xa7, 0x54, 0x63, 0x6d, 0x82, 0xf1, 0x65, 0xf5, 0x26, 0x7, 0x52, 0xf0, 0xf9, 0x28, + 0xb6, 0x8, 0x0, 0x1a, 0xe7, 0xdb, 0x45, 0xff, 0x15, 0x23, 0xe1, 0x7, 0x0, 0xf8, 0x58, 0x28, 0x9f, 0xfa, 0x3d, + 0x38, 0xea, 0xec, 0xf9, 0x29, 0xa0, 0x85,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x39, 0x52, 0x13, 0xb1, 0x24, 0x4f, 0xe1, 0x64, 0xde, 0xaf, 0x2b, 0xcf, 0x8a, 0x46, 0x4e, + 0xf9, 0xe1, 0xe7, 0xfb}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x33, 0x5e, 0x44, 0xd6, 0x6a, 0x70, 0xd7, 0x94, 0x8a, 0x4b, 0x36, 0xfd, 0xee, 0x19, + 0x73, 0x4c, 0x8, 0x5a, 0x6e, 0x5b, 0x2f, 0xc3, 0xee, 0xc3, 0x75, 0x63, 0x17}; + uint8_t bytesprops1[] = {0xbb, 0xf6, 0xc3, 0xfc, 0x8b, 0x6b, 0x95, 0x8e, 0xea, 0xe1, 0x2b, 0x38, 0x21, + 0xa7, 0x54, 0x63, 0x6d, 0x82, 0xf1, 0x65, 0xf5, 0x26, 0x7, 0x52, 0xf0, 0xf9}; + uint8_t bytesprops2[] = {0xe7, 0xdb, 0x45, 0xff, 0x15, 0x23, 0xe1, 0x7, 0x0, 0xf8, 0x58, 0x28, 0x9f, + 0xfa, 0x3d, 0x38, 0xea, 0xec, 0xf9, 0x29, 0xa0, 0x85, 0x8c, 0xb, 0xe1, 0x8f}; + uint8_t bytesprops3[] = {0xc9, 0xf2, 0x7, 0xe9, 0x7f, 0xeb, 0xc, 0xb1, 0xd1, 0xf4, 0x5e}; + uint8_t bytesprops5[] = {0x52, 0x1c, 0x0}; + uint8_t bytesprops4[] = {0x8d, 0x34, 0x6f, 0xba, 0x87, 0xd1, 0xfb, 0xec, 0x5, 0xb3, 0x74, 0x93, 0xa0, 0x79}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30491}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12126}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14571}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12781}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 134}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops4}, .v = {3, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14661}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 172}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xeb, 0x9d, 0xfe, 0x8a, 0xc, 0x9f, 0xa0, 0x48, 0xe2, 0x9f, - 0xa7, 0xce, 0x5b, 0x4c, 0xdd, 0x85, 0x70, 0xb9, 0x3b}; - lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x77, 0x39, 0x41, 0xa, 0x3d, 0xc, 0xef, 0x50, 0xf8, 0x69, 0x6f, 0x6d, + 0x56, 0xf6, 0xe6, 0xdb, 0xc, 0xea, 0x69, 0xf5, 0x2c, 0x88, 0x65}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2f, 0xa2, 0xc0, 0x7, 0xd9, 0xab, 0x5b, 0xe9, 0xb2, 0xe3, - 0x47, 0x54, 0x4e, 0x7e, 0x1, 0x7a, 0x49, 0x6c, 0x13, 0x47, - 0xc3, 0x43, 0x28, 0x46, 0x48, 0xf1, 0x3d, 0x48, 0x65, 0xfb}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc8, 0x30, 0x26, 0x56, 0x83, 0x19, 0x25, 0xb0, 0xaa, 0x52, 0xd1, + 0xa6, 0x5e, 0x3c, 0xaa, 0xc8, 0xdc, 0x66, 0xde, 0x7, 0x1c, 0x44}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6e, 0xd4, 0xe1, 0x67, 0x88, 0x16, 0x4b, 0xde, 0xee, 0xcf, 0x89}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x2e, 0x32, 0x5e, 0x2e, 0xf2, 0xd, 0xc6}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xd, 0xe5, 0xa6, 0xbb, 0x66, 0xf4, 0xbc, 0x25, 0x97, 0xd5, + 0x57, 0xc6, 0x96, 0x7, 0xc, 0xc9, 0xf5, 0x79, 0x48, 0xc1, + 0x89, 0x26, 0x39, 0xf6, 0xd1, 0x4b, 0x61, 0x94, 0x8c, 0x1e}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x17, 0x37, 0x21, 0x1e, 0x4f, 0xfc, 0x19, 0x34, 0x42, 0xfd, 0x7f, - 0x1f, 0x73, 0x7d, 0xf6, 0x65, 0xc0, 0xc9, 0x87, 0x11, 0xae}; - lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x1e, 0x43, 0x62, 0x2f, 0x62, 0x8f, 0x97, 0xac, 0x2, 0x4c, 0xa7, 0x81, + 0xba, 0x8e, 0xfc, 0xa0, 0xda, 0x15, 0x9b, 0x86, 0x4, 0xbf, 0xf7, 0x77}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb7, 0x7e, 0xd8, 0x6d}; - lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xce, 0x41, 0xe7, 0x53, 0xad, 0xfe, 0x4d, 0x39, 0x52, 0x13, 0xb1, 0x24, 0x4f, + 0xe1, 0x64, 0xde, 0xaf, 0x2b, 0xcf, 0x8a, 0x46, 0x4e, 0xf9, 0xe1, 0xe7, 0xfb}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xae, 0x4b, 0xd8, 0x1a, 0xb3, 0x20, 0x19, 0x42, 0x19, 0x70, 0x71, 0x19, 0x6c}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22892, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14225, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 19885 -// ["1PI\t\197=\237\156\210+\211\143\197F\237j\226K\DC1\ETB\231\195\ACK\162\148\247_\252\173","\t)\128a\GS\181\NUL\197\183{\205;m\230\199\US|l\166i\215'\180\129\184\186","\246D|d\241G\232+$\163\NAKm","\165","\r\189\ACK\138&\129\225V\220\215X\ESC\DLE<\192\150s\207","U\214xL\223\215.ob5\166\173wr\209\&1\167\&9\rJ\145\DC4\255","\DC3\215c\169\153\250\207@\186\242\r\"\183\129Q\RS\ETBbEj\160","L-\181*\192\&1}"] -// [PropReasonString "\159\193\135\239W\133\141\v\147\&9[<\156",PropContentType -// "\251n\183\239\139gc\DC2\"\GS0",PropSessionExpiryInterval 7449] +// UnsubscribeRequest 19016 +// ["Jg\224\251\204?\245=","\241\203b\228\136\148R&\163\232S\US\233R","\202g\168\178\ENQ;\ETB\131\t!4\227\199.E\251","+\200\171{ZW\DC4\ACK\170 +// n\253\171=\157'_\155\tW\163\242\a\223","\224_L\250\174\189\ETB\170\156\243\NUL","#V\247\220\&3\202\129\146s\GS\244\149\158xi\231\149\242\DEL\148\172\159\210]\226\EMN","R\ACK\SOH9\148\244/","\153%\252\231\&9\254\131\161\180\161\151\"\239P!_\141T\EMsz\"0"] +// [PropServerKeepAlive 23263] TEST(Unsubscribe5QCTest, Encode28) { - uint8_t pkt[] = {0xa2, 0xbf, 0x1, 0x4d, 0xad, 0x23, 0x1f, 0x0, 0xd, 0x9f, 0xc1, 0x87, 0xef, 0x57, 0x85, 0x8d, 0xb, - 0x93, 0x39, 0x5b, 0x3c, 0x9c, 0x3, 0x0, 0xb, 0xfb, 0x6e, 0xb7, 0xef, 0x8b, 0x67, 0x63, 0x12, 0x22, - 0x1d, 0x30, 0x11, 0x0, 0x0, 0x1d, 0x19, 0x0, 0x1d, 0x31, 0x50, 0x49, 0x9, 0xc5, 0x3d, 0xed, 0x9c, - 0xd2, 0x2b, 0xd3, 0x8f, 0xc5, 0x46, 0xed, 0x6a, 0xe2, 0x4b, 0x11, 0x17, 0xe7, 0xc3, 0x6, 0xa2, 0x94, - 0xf7, 0x5f, 0xfc, 0xad, 0x0, 0x1a, 0x9, 0x29, 0x80, 0x61, 0x1d, 0xb5, 0x0, 0xc5, 0xb7, 0x7b, 0xcd, - 0x3b, 0x6d, 0xe6, 0xc7, 0x1f, 0x7c, 0x6c, 0xa6, 0x69, 0xd7, 0x27, 0xb4, 0x81, 0xb8, 0xba, 0x0, 0xc, - 0xf6, 0x44, 0x7c, 0x64, 0xf1, 0x47, 0xe8, 0x2b, 0x24, 0xa3, 0x15, 0x6d, 0x0, 0x1, 0xa5, 0x0, 0x12, - 0xd, 0xbd, 0x6, 0x8a, 0x26, 0x81, 0xe1, 0x56, 0xdc, 0xd7, 0x58, 0x1b, 0x10, 0x3c, 0xc0, 0x96, 0x73, - 0xcf, 0x0, 0x17, 0x55, 0xd6, 0x78, 0x4c, 0xdf, 0xd7, 0x2e, 0x6f, 0x62, 0x35, 0xa6, 0xad, 0x77, 0x72, - 0xd1, 0x31, 0xa7, 0x39, 0xd, 0x4a, 0x91, 0x14, 0xff, 0x0, 0x15, 0x13, 0xd7, 0x63, 0xa9, 0x99, 0xfa, - 0xcf, 0x40, 0xba, 0xf2, 0xd, 0x22, 0xb7, 0x81, 0x51, 0x1e, 0x17, 0x62, 0x45, 0x6a, 0xa0, 0x0, 0x7, - 0x4c, 0x2d, 0xb5, 0x2a, 0xc0, 0x31, 0x7d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x9f, 0xc1, 0x87, 0xef, 0x57, 0x85, 0x8d, 0xb, 0x93, 0x39, 0x5b, 0x3c, 0x9c}; - uint8_t bytesprops1[] = {0xfb, 0x6e, 0xb7, 0xef, 0x8b, 0x67, 0x63, 0x12, 0x22, 0x1d, 0x30}; + uint8_t pkt[] = {0xa2, 0x98, 0x1, 0x4a, 0x48, 0x3, 0x13, 0x5a, 0xdf, 0x0, 0x8, 0x4a, 0x67, 0xe0, 0xfb, 0xcc, + 0x3f, 0xf5, 0x3d, 0x0, 0xe, 0xf1, 0xcb, 0x62, 0xe4, 0x88, 0x94, 0x52, 0x26, 0xa3, 0xe8, 0x53, + 0x1f, 0xe9, 0x52, 0x0, 0x10, 0xca, 0x67, 0xa8, 0xb2, 0x5, 0x3b, 0x17, 0x83, 0x9, 0x21, 0x34, + 0xe3, 0xc7, 0x2e, 0x45, 0xfb, 0x0, 0x18, 0x2b, 0xc8, 0xab, 0x7b, 0x5a, 0x57, 0x14, 0x6, 0xaa, + 0x20, 0x6e, 0xfd, 0xab, 0x3d, 0x9d, 0x27, 0x5f, 0x9b, 0x9, 0x57, 0xa3, 0xf2, 0x7, 0xdf, 0x0, + 0xb, 0xe0, 0x5f, 0x4c, 0xfa, 0xae, 0xbd, 0x17, 0xaa, 0x9c, 0xf3, 0x0, 0x0, 0x1b, 0x23, 0x56, + 0xf7, 0xdc, 0x33, 0xca, 0x81, 0x92, 0x73, 0x1d, 0xf4, 0x95, 0x9e, 0x78, 0x69, 0xe7, 0x95, 0xf2, + 0x7f, 0x94, 0xac, 0x9f, 0xd2, 0x5d, 0xe2, 0x19, 0x4e, 0x0, 0x7, 0x52, 0x6, 0x1, 0x39, 0x94, + 0xf4, 0x2f, 0x0, 0x17, 0x99, 0x25, 0xfc, 0xe7, 0x39, 0xfe, 0x83, 0xa1, 0xb4, 0xa1, 0x97, 0x22, + 0xef, 0x50, 0x21, 0x5f, 0x8d, 0x54, 0x19, 0x73, 0x7a, 0x22, 0x30}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7449}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23263}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x31, 0x50, 0x49, 0x9, 0xc5, 0x3d, 0xed, 0x9c, 0xd2, 0x2b, - 0xd3, 0x8f, 0xc5, 0x46, 0xed, 0x6a, 0xe2, 0x4b, 0x11, 0x17, - 0xe7, 0xc3, 0x6, 0xa2, 0x94, 0xf7, 0x5f, 0xfc, 0xad}; - lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0x4a, 0x67, 0xe0, 0xfb, 0xcc, 0x3f, 0xf5, 0x3d}; + lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9, 0x29, 0x80, 0x61, 0x1d, 0xb5, 0x0, 0xc5, 0xb7, 0x7b, 0xcd, 0x3b, 0x6d, - 0xe6, 0xc7, 0x1f, 0x7c, 0x6c, 0xa6, 0x69, 0xd7, 0x27, 0xb4, 0x81, 0xb8, 0xba}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf1, 0xcb, 0x62, 0xe4, 0x88, 0x94, 0x52, + 0x26, 0xa3, 0xe8, 0x53, 0x1f, 0xe9, 0x52}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf6, 0x44, 0x7c, 0x64, 0xf1, 0x47, 0xe8, 0x2b, 0x24, 0xa3, 0x15, 0x6d}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xca, 0x67, 0xa8, 0xb2, 0x5, 0x3b, 0x17, 0x83, + 0x9, 0x21, 0x34, 0xe3, 0xc7, 0x2e, 0x45, 0xfb}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa5}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x2b, 0xc8, 0xab, 0x7b, 0x5a, 0x57, 0x14, 0x6, 0xaa, 0x20, 0x6e, 0xfd, + 0xab, 0x3d, 0x9d, 0x27, 0x5f, 0x9b, 0x9, 0x57, 0xa3, 0xf2, 0x7, 0xdf}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd, 0xbd, 0x6, 0x8a, 0x26, 0x81, 0xe1, 0x56, 0xdc, - 0xd7, 0x58, 0x1b, 0x10, 0x3c, 0xc0, 0x96, 0x73, 0xcf}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xe0, 0x5f, 0x4c, 0xfa, 0xae, 0xbd, 0x17, 0xaa, 0x9c, 0xf3, 0x0}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x55, 0xd6, 0x78, 0x4c, 0xdf, 0xd7, 0x2e, 0x6f, 0x62, 0x35, 0xa6, 0xad, - 0x77, 0x72, 0xd1, 0x31, 0xa7, 0x39, 0xd, 0x4a, 0x91, 0x14, 0xff}; - lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x23, 0x56, 0xf7, 0xdc, 0x33, 0xca, 0x81, 0x92, 0x73, 0x1d, 0xf4, 0x95, 0x9e, 0x78, + 0x69, 0xe7, 0x95, 0xf2, 0x7f, 0x94, 0xac, 0x9f, 0xd2, 0x5d, 0xe2, 0x19, 0x4e}; + lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x13, 0xd7, 0x63, 0xa9, 0x99, 0xfa, 0xcf, 0x40, 0xba, 0xf2, 0xd, - 0x22, 0xb7, 0x81, 0x51, 0x1e, 0x17, 0x62, 0x45, 0x6a, 0xa0}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x52, 0x6, 0x1, 0x39, 0x94, 0xf4, 0x2f}; + lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x4c, 0x2d, 0xb5, 0x2a, 0xc0, 0x31, 0x7d}; - lwmqtt_string_t topic_filter_s7 = {7, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x99, 0x25, 0xfc, 0xe7, 0x39, 0xfe, 0x83, 0xa1, 0xb4, 0xa1, 0x97, 0x22, + 0xef, 0x50, 0x21, 0x5f, 0x8d, 0x54, 0x19, 0x73, 0x7a, 0x22, 0x30}; + lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19885, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19016, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 27189 -// ["\150\235'\154\141\134|\222\223]bA\223\139E\175+\178\158\176FT\218\DC4","\128\213\212b\169;\241\208\"!\167","\162\SO\SYN\164P(\US\SIR{\147\253k\235G\169;ZQ\NULH\DC3\DELP\SOH\222","F\229\157\217\ACK\155\rz\245\&8/\173G5\177\244S-8\150\198\194\&3\222)\209\STX","\191\143\241\237\222\157\191\187\142M}\207LC|\146","8\ENQ\229\241|Z^","*g\f\244dM\235\193*\177\&9\149\133\161","\168/\EOT\222\a^z\187\139\135","\167\206\130\&1\168\ETBH\200\241\221C\235\134Z9J\193\215v\237\131\197"] -// [PropRequestProblemInformation 244,PropSubscriptionIdentifierAvailable 57,PropMessageExpiryInterval -// 25256,PropRetainAvailable 180,PropCorrelationData "\214\166\DC1\175\199/`",PropResponseInformation -// "\244D{\US\150\SYNk=\184\140A\225|0\138"] +// UnsubscribeRequest 24261 +// ["/\168j\253\190Jy7\185~F\236J","S\225\251?H\DC1\249\DC3\ETX\182\155[\CAN","}\EOT\136\245\&6b\203\202","9\222\252{E\t\SYNK5\162El\EOTA\171\&4\152\ESC","w\157\&9N\nW\242K\NUL\150a\166~\196\168\226\187\DEL\tU\186\218f\168","l\194\247\SOB\246P/\139","?fa\190\246c\DC2|/\206\SO\149\246\149Ar\153\174\EM\168\SOH\150\163\175\&3\236\191\ENQ\f\158","R$\140\171\234d\136\145\221\151\US8|3\254","\DLE\SI_\219/\178\128k\149\188\203\130J%\245\200P","\186\237'\227\&6\220\179\227\170\228\SOH?=\GS\DC3\224\204\166\tj\ESC|-s;\179",""] +// [PropUserProperty "p\207\DC1\170\239\132" "\US\195VAb\210\\\RS\160x",PropServerKeepAlive +// 8037,PropSubscriptionIdentifier 4,PropRetainAvailable 158,PropContentType +// "p\210\149\156}\129\157\152'\EOT\255\184\217W\221\165\&9^\ACK\220C\SI\184v\146\ENQ\241\173\208\&4",PropMaximumQoS +// 193,PropTopicAlias 8090] TEST(Unsubscribe5QCTest, Encode29) { - uint8_t pkt[] = {0xa2, 0xd9, 0x1, 0x6a, 0x35, 0x27, 0x17, 0xf4, 0x29, 0x39, 0x2, 0x0, 0x0, 0x62, 0xa8, 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, 0xce, 0x82, 0x31, 0xa8, 0x17, - 0x48, 0xc8, 0xf1, 0xdd, 0x43, 0xeb, 0x86, 0x5a, 0x39, 0x4a, 0xc1, 0xd7, 0x76, 0xed, 0x83, 0xc5}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd6, 0xa6, 0x11, 0xaf, 0xc7, 0x2f, 0x60}; - uint8_t bytesprops1[] = {0xf4, 0x44, 0x7b, 0x1f, 0x96, 0x16, 0x6b, 0x3d, 0xb8, 0x8c, 0x41, 0xe1, 0x7c, 0x30, 0x8a}; + uint8_t pkt[] = {0xa2, 0x88, 0x2, 0x5e, 0xc5, 0x42, 0x26, 0x0, 0x6, 0x70, 0xcf, 0x11, 0xaa, 0xef, 0x84, 0x0, 0xa, + 0x1f, 0xc3, 0x56, 0x41, 0x62, 0xd2, 0x5c, 0x1e, 0xa0, 0x78, 0x13, 0x1f, 0x65, 0xb, 0x4, 0x25, 0x9e, + 0x3, 0x0, 0x1e, 0x70, 0xd2, 0x95, 0x9c, 0x7d, 0x81, 0x9d, 0x98, 0x27, 0x4, 0xff, 0xb8, 0xd9, 0x57, + 0xdd, 0xa5, 0x39, 0x5e, 0x6, 0xdc, 0x43, 0xf, 0xb8, 0x76, 0x92, 0x5, 0xf1, 0xad, 0xd0, 0x34, 0x24, + 0xc1, 0x23, 0x1f, 0x9a, 0x0, 0xd, 0x2f, 0xa8, 0x6a, 0xfd, 0xbe, 0x4a, 0x79, 0x37, 0xb9, 0x7e, 0x46, + 0xec, 0x4a, 0x0, 0xd, 0x53, 0xe1, 0xfb, 0x3f, 0x48, 0x11, 0xf9, 0x13, 0x3, 0xb6, 0x9b, 0x5b, 0x18, + 0x0, 0x8, 0x7d, 0x4, 0x88, 0xf5, 0x36, 0x62, 0xcb, 0xca, 0x0, 0x12, 0x39, 0xde, 0xfc, 0x7b, 0x45, + 0x9, 0x16, 0x4b, 0x35, 0xa2, 0x45, 0x6c, 0x4, 0x41, 0xab, 0x34, 0x98, 0x1b, 0x0, 0x18, 0x77, 0x9d, + 0x39, 0x4e, 0xa, 0x57, 0xf2, 0x4b, 0x0, 0x96, 0x61, 0xa6, 0x7e, 0xc4, 0xa8, 0xe2, 0xbb, 0x7f, 0x9, + 0x55, 0xba, 0xda, 0x66, 0xa8, 0x0, 0x9, 0x6c, 0xc2, 0xf7, 0xe, 0x42, 0xf6, 0x50, 0x2f, 0x8b, 0x0, + 0x1e, 0x3f, 0x66, 0x61, 0xbe, 0xf6, 0x63, 0x12, 0x7c, 0x2f, 0xce, 0xe, 0x95, 0xf6, 0x95, 0x41, 0x72, + 0x99, 0xae, 0x19, 0xa8, 0x1, 0x96, 0xa3, 0xaf, 0x33, 0xec, 0xbf, 0x5, 0xc, 0x9e, 0x0, 0xf, 0x52, + 0x24, 0x8c, 0xab, 0xea, 0x64, 0x88, 0x91, 0xdd, 0x97, 0x1f, 0x38, 0x7c, 0x33, 0xfe, 0x0, 0x11, 0x10, + 0xf, 0x5f, 0xdb, 0x2f, 0xb2, 0x80, 0x6b, 0x95, 0xbc, 0xcb, 0x82, 0x4a, 0x25, 0xf5, 0xc8, 0x50, 0x0, + 0x1a, 0xba, 0xed, 0x27, 0xe3, 0x36, 0xdc, 0xb3, 0xe3, 0xaa, 0xe4, 0x1, 0x3f, 0x3d, 0x1d, 0x13, 0xe0, + 0xcc, 0xa6, 0x9, 0x6a, 0x1b, 0x7c, 0x2d, 0x73, 0x3b, 0xb3, 0x0, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x1f, 0xc3, 0x56, 0x41, 0x62, 0xd2, 0x5c, 0x1e, 0xa0, 0x78}; + uint8_t bytesprops0[] = {0x70, 0xcf, 0x11, 0xaa, 0xef, 0x84}; + uint8_t bytesprops2[] = {0x70, 0xd2, 0x95, 0x9c, 0x7d, 0x81, 0x9d, 0x98, 0x27, 0x4, 0xff, 0xb8, 0xd9, 0x57, 0xdd, + 0xa5, 0x39, 0x5e, 0x6, 0xdc, 0x43, 0xf, 0xb8, 0x76, 0x92, 0x5, 0xf1, 0xad, 0xd0, 0x34}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25256}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8037}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8090}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x96, 0xeb, 0x27, 0x9a, 0x8d, 0x86, 0x7c, 0xde, 0xdf, 0x5d, 0x62, 0x41, - 0xdf, 0x8b, 0x45, 0xaf, 0x2b, 0xb2, 0x9e, 0xb0, 0x46, 0x54, 0xda, 0x14}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x2f, 0xa8, 0x6a, 0xfd, 0xbe, 0x4a, 0x79, 0x37, 0xb9, 0x7e, 0x46, 0xec, 0x4a}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x80, 0xd5, 0xd4, 0x62, 0xa9, 0x3b, 0xf1, 0xd0, 0x22, 0x21, 0xa7}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x53, 0xe1, 0xfb, 0x3f, 0x48, 0x11, 0xf9, 0x13, 0x3, 0xb6, 0x9b, 0x5b, 0x18}; + lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa2, 0xe, 0x16, 0xa4, 0x50, 0x28, 0x1f, 0xf, 0x52, 0x7b, 0x93, 0xfd, 0x6b, - 0xeb, 0x47, 0xa9, 0x3b, 0x5a, 0x51, 0x0, 0x48, 0x13, 0x7f, 0x50, 0x1, 0xde}; - lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7d, 0x4, 0x88, 0xf5, 0x36, 0x62, 0xcb, 0xca}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x46, 0xe5, 0x9d, 0xd9, 0x6, 0x9b, 0xd, 0x7a, 0xf5, 0x38, 0x2f, 0xad, 0x47, 0x35, - 0xb1, 0xf4, 0x53, 0x2d, 0x38, 0x96, 0xc6, 0xc2, 0x33, 0xde, 0x29, 0xd1, 0x2}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x39, 0xde, 0xfc, 0x7b, 0x45, 0x9, 0x16, 0x4b, 0x35, + 0xa2, 0x45, 0x6c, 0x4, 0x41, 0xab, 0x34, 0x98, 0x1b}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xbf, 0x8f, 0xf1, 0xed, 0xde, 0x9d, 0xbf, 0xbb, - 0x8e, 0x4d, 0x7d, 0xcf, 0x4c, 0x43, 0x7c, 0x92}; - lwmqtt_string_t topic_filter_s4 = {16, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x77, 0x9d, 0x39, 0x4e, 0xa, 0x57, 0xf2, 0x4b, 0x0, 0x96, 0x61, 0xa6, + 0x7e, 0xc4, 0xa8, 0xe2, 0xbb, 0x7f, 0x9, 0x55, 0xba, 0xda, 0x66, 0xa8}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x38, 0x5, 0xe5, 0xf1, 0x7c, 0x5a, 0x5e}; - lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x6c, 0xc2, 0xf7, 0xe, 0x42, 0xf6, 0x50, 0x2f, 0x8b}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x2a, 0x67, 0xc, 0xf4, 0x64, 0x4d, 0xeb, 0xc1, 0x2a, 0xb1, 0x39, 0x95, 0x85, 0xa1}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x3f, 0x66, 0x61, 0xbe, 0xf6, 0x63, 0x12, 0x7c, 0x2f, 0xce, + 0xe, 0x95, 0xf6, 0x95, 0x41, 0x72, 0x99, 0xae, 0x19, 0xa8, + 0x1, 0x96, 0xa3, 0xaf, 0x33, 0xec, 0xbf, 0x5, 0xc, 0x9e}; + lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xa8, 0x2f, 0x4, 0xde, 0x7, 0x5e, 0x7a, 0xbb, 0x8b, 0x87}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x52, 0x24, 0x8c, 0xab, 0xea, 0x64, 0x88, 0x91, + 0xdd, 0x97, 0x1f, 0x38, 0x7c, 0x33, 0xfe}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xa7, 0xce, 0x82, 0x31, 0xa8, 0x17, 0x48, 0xc8, 0xf1, 0xdd, 0x43, - 0xeb, 0x86, 0x5a, 0x39, 0x4a, 0xc1, 0xd7, 0x76, 0xed, 0x83, 0xc5}; - lwmqtt_string_t topic_filter_s8 = {22, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x10, 0xf, 0x5f, 0xdb, 0x2f, 0xb2, 0x80, 0x6b, 0x95, + 0xbc, 0xcb, 0x82, 0x4a, 0x25, 0xf5, 0xc8, 0x50}; + lwmqtt_string_t topic_filter_s8 = {17, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xba, 0xed, 0x27, 0xe3, 0x36, 0xdc, 0xb3, 0xe3, 0xaa, 0xe4, 0x1, 0x3f, 0x3d, + 0x1d, 0x13, 0xe0, 0xcc, 0xa6, 0x9, 0x6a, 0x1b, 0x7c, 0x2d, 0x73, 0x3b, 0xb3}; + lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0}; + lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27189, 9, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24261, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 10641 -// ["\195Sa\217\ACK\194\232\166\EOT\a\175\198\164\196r\252MKH\243\DC3\NAK\238`\253\&8gp" +// "\138\154\167\153\224\195\&01&",PropPayloadFormatIndicator 19,PropSessionExpiryInterval +// 13790,PropSubscriptionIdentifierAvailable 79,PropContentType "\240r\197",PropCorrelationData +// "@\193\190\203\DLE\rE",PropContentType +// "\218\140\t\226\219V\246$#\204e\142s\244\245^\222\173\178!-Wbb\187D",PropSubscriptionIdentifier +// 4,PropRequestResponseInformation 211,PropRequestProblemInformation 122] +// [UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted] TEST(UnsubACK5QCTest, Decode1) { - uint8_t pkt[] = {0xb0, 0xb6, 0x1, 0x61, 0x1c, 0x9b, 0x1, 0x2, 0x0, 0x0, 0x64, 0x4e, 0x1c, 0x0, 0x7, 0x2f, 0xfd, - 0x23, 0xc3, 0xd6, 0x87, 0xcf, 0x1, 0xa5, 0x21, 0x27, 0xd3, 0x1c, 0x0, 0x2, 0xaf, 0x49, 0x9, 0x0, - 0x1e, 0xeb, 0x25, 0x62, 0x85, 0xb1, 0xa7, 0x7b, 0x57, 0x2c, 0xa2, 0x5d, 0x3c, 0x85, 0x32, 0x54, 0x60, - 0x31, 0xaa, 0xb, 0x61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a, 0xa7, 0x99, 0xe0, 0xc3, 0x30, 0x31, 0x26, + 0x1, 0x13, 0x11, 0x0, 0x0, 0x35, 0xde, 0x29, 0x4f, 0x3, 0x0, 0x3, 0xf0, 0x72, 0xc5, 0x9, + 0x0, 0x7, 0x40, 0xc1, 0xbe, 0xcb, 0x10, 0xd, 0x45, 0x3, 0x0, 0x1a, 0xda, 0x8c, 0x9, 0xe2, + 0xdb, 0x56, 0xf6, 0x24, 0x23, 0xcc, 0x65, 0x8e, 0x73, 0xf4, 0xf5, 0x5e, 0xde, 0xad, 0xb2, 0x21, + 0x2d, 0x57, 0x62, 0x62, 0xbb, 0x44, 0xb, 0x4, 0x19, 0xd3, 0x17, 0x7a, 0x91, 0x0, 0x8f, 0x91, + 0x11, 0x80, 0x83, 0x80, 0x83, 0x80, 0x80, 0x11, 0x87, 0x8f, 0x80, 0x91, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[23]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 23, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[17]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 17, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24860); - EXPECT_EQ(count, 23); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(packet_id, 5190); + EXPECT_EQ(count, 17); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); EXPECT_EQ(statuses[14], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); } -// UnsubscribeResponse 3894 [PropReasonString -// "A\238\220^\134u\207\244\233]\158\b+B\208\154\218\&9\206\US\200\193",PropRetainAvailable 121] -// [UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubNotAuthorized] +// UnsubscribeResponse 10905 [PropTopicAliasMaximum 27710,PropResponseInformation +// "\NUL$\160\192\EOT\141V\208\174\135\215\222c",PropSessionExpiryInterval 17495,PropMessageExpiryInterval +// 14281,PropSharedSubscriptionAvailable 37,PropAuthenticationMethod "ix\140",PropWillDelayInterval +// 1500,PropCorrelationData "m\152\227\182\STX\202l\201g\SO\134\187\216\209n%\DELP|\135\135",PropMessageExpiryInterval +// 3420,PropMaximumQoS 39,PropAuthenticationData +// "7\255:\182q\246\RS\248\&5\144\220\154/79\230T\174\ENQ|\222~\146+\223\214\DLE\252\159",PropServerKeepAlive +// 18407,PropUserProperty "\219M\177'_" +// "\228\212l/\211\250z\145\&1\231\224Y:l\129\201\n\208\DEL\133\205\128B5\147\SOp\239\DC3",PropContentType +// "\228]\218\225j\163/\138+^\DLEVsY*\220\202\163\176\191\141\176\&9\SO\155\252\r\177I\185",PropMessageExpiryInterval +// 24830,PropTopicAlias 22210,PropRetainAvailable 94,PropUserProperty +// "\229C9\222\223\156\&8\DC1\191\154\159\241)\ad\240\215\195" "\223\&3\250\240y\230\248@\136",PropAuthenticationMethod +// "\175\f\160\145\SOHhC\EOT\222\231\RSw\206L\183\217",PropSessionExpiryInterval 20207,PropMessageExpiryInterval -// 10350,PropRequestProblemInformation 187,PropSubscriptionIdentifier 12] -// [UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNoSubscriptionExisted] +// UnsubscribeResponse 19692 [] +// [UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubImplementationSpecificError,UnsubSuccess,UnsubPacketIdentifierInUse] TEST(UnsubACK5QCTest, Decode3) { - uint8_t pkt[] = {0xb0, 0x65, 0x9, 0x16, 0x5d, 0x13, 0x5f, 0x44, 0x3, 0x0, 0x1b, 0x98, 0x51, 0xd6, 0x27, - 0x7b, 0xa9, 0x43, 0x6c, 0xbd, 0x5f, 0xa4, 0x1f, 0x55, 0xa4, 0x28, 0xca, 0x70, 0xa0, 0x9f, - 0x9f, 0xc8, 0x64, 0x0, 0x10, 0x6b, 0xe4, 0xbc, 0x29, 0x7, 0x17, 0xe0, 0x29, 0xe1, 0x1a, - 0x0, 0xa, 0x40, 0x59, 0xff, 0x21, 0xf5, 0xd4, 0x47, 0x9d, 0x6c, 0x7c, 0x21, 0x1e, 0x99, - 0x1, 0x1b, 0x1a, 0x0, 0x13, 0xc8, 0x1b, 0x1d, 0xcb, 0x78, 0x54, 0x41, 0x3e, 0x68, 0x43, - 0x4, 0xde, 0xe7, 0x1e, 0x77, 0xce, 0x4c, 0xb7, 0xd9, 0x11, 0x0, 0x0, 0x4e, 0xef, 0x2, - 0x0, 0x0, 0x28, 0x6e, 0x17, 0xbb, 0xb, 0xc, 0x8f, 0x80, 0x91, 0x80, 0x11}; + uint8_t pkt[] = {0xb0, 0xf, 0x4c, 0xec, 0x0, 0x8f, 0x91, 0x11, 0x87, 0x87, 0x91, 0x80, 0x8f, 0x0, 0x83, 0x0, 0x91}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[5]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[12]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 12, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 2326); - EXPECT_EQ(count, 5); + EXPECT_EQ(packet_id, 19692); + EXPECT_EQ(count, 12); EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); } -// UnsubscribeResponse 10530 [PropAuthenticationData -// "\209\210\SI\198\NUL]x~Jd\216l\174\DC2\160\168\199\145\n\SOHn\206\v",PropSubscriptionIdentifier -// 32,PropMessageExpiryInterval 17080,PropAuthenticationData "c\200",PropTopicAliasMaximum 14580,PropCorrelationData -// "\SYN\188\240\206\178>\241\"\CAN\EOT\230\185\238\199\191\&3\135\129\166\DC1\250\&6\246=\140:",PropServerReference -// "\149\179g\166\253X\EM\167\147\200\DC1\199\SUB}",PropReasonString -// "%\161(R\183&\SOH\220\135\&6N\SYN\DC4\149\132\247:B\SYN;\188\a",PropPayloadFormatIndicator -// 27,PropPayloadFormatIndicator 128,PropServerReference -// "\219\190\207\b\STXH\225}n\226\194`\172\&9\226\231Z\146\208\241!\DC2\240\164\ETBM \216",PropMaximumQoS -// 250,PropServerKeepAlive 27834,PropSessionExpiryInterval 18960,PropRetainAvailable 149,PropTopicAliasMaximum -// 25123,PropAuthenticationMethod -// "B\DC4\195\134\160\NAK\197\ETX\n\205\203\&8so\199\130\223=^h\234\139p4N",PropTopicAlias -// 24560,PropSubscriptionIdentifierAvailable 73,PropSharedSubscriptionAvailable 225] -// [UnsubSuccess,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubSuccess] +// UnsubscribeResponse 16153 [PropMaximumQoS 141,PropResponseTopic +// "\194\FS\183\SI\245\167\181\185b\EOTn\160\195\202}\ESC\153\136\215\157Z`\183\242\RS0.\\\200\\",PropMaximumQoS +// 174,PropReceiveMaximum 10330,PropRetainAvailable 24,PropMaximumQoS 0,PropWillDelayInterval 19848,PropRetainAvailable +// 90,PropMessageExpiryInterval 95,PropTopicAliasMaximum 10955,PropMaximumPacketSize 22512,PropMessageExpiryInterval +// 4945,PropWillDelayInterval 5332,PropAssignedClientIdentifier +// "-\188\DC3\RSy\237\249\161t\213\133\171O\196\&8\132i\207",PropWillDelayInterval 8228,PropServerKeepAlive +// 21124,PropMaximumPacketSize 2428,PropRetainAvailable 209,PropContentType +// "\189\147N\132[2\SI\DC1\238\SOHc\n\220\156\SIa",PropSharedSubscriptionAvailable 108,PropMaximumQoS +// 241,PropAssignedClientIdentifier +// "\228N\196\145\188\167\&5\129h|1`f\208cM\199v\177ib91\177\191\170\255\224\172",PropResponseInformation +// "\SYN\128uv\228Kb\164d\132\FS\207!?\235\&2a\181\254\NUL\168\137\154\200\v\241\212w",PropRequestResponseInformation +// 69,PropMaximumQoS 175,PropTopicAlias 7798,PropMaximumQoS 1] +// [UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted] TEST(UnsubACK5QCTest, Decode4) { - uint8_t pkt[] = { - 0xb0, 0xfd, 0x1, 0x29, 0x22, 0xeb, 0x1, 0x16, 0x0, 0x17, 0xd1, 0xd2, 0xf, 0xc6, 0x0, 0x5d, 0x78, 0x7e, 0x4a, - 0x64, 0xd8, 0x6c, 0xae, 0x12, 0xa0, 0xa8, 0xc7, 0x91, 0xa, 0x1, 0x6e, 0xce, 0xb, 0xb, 0x20, 0x2, 0x0, 0x0, - 0x42, 0xb8, 0x16, 0x0, 0x2, 0x63,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0x4d, 0xc7, 0x76, 0xb1, 0x69, 0x62, 0x39, 0x31, 0xb1, 0xbf, 0xaa, 0xff, + 0xe0, 0xac, 0x1a, 0x0, 0x1c, 0x16, 0x80, 0x75, 0x76, 0xe4, 0x4b, 0x62, 0xa4, 0x64, 0x84, 0x1c, 0xcf, + 0x21, 0x3f, 0xeb, 0x32, 0x61, 0xb5, 0xfe, 0x0, 0xa8, 0x89, 0x9a, 0xc8, 0xb, 0xf1, 0xd4, 0x77, 0x19, + 0x45, 0x24, 0xaf, 0x23, 0x1e, 0x76, 0x24, 0x1, 0x83, 0x80, 0x11, 0x91, 0x80, 0x11, 0x91, 0x80, 0x87, + 0x83, 0x91, 0x11, 0x80, 0x11, 0x91, 0x87, 0x11, 0x83, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[14]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 14, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[19]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 19, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10530); - EXPECT_EQ(count, 14); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); -} - -// UnsubscribeResponse 29099 [PropUserProperty -// "5\209\150\165M\250\224\199\213Ze\168\DC4\r\205\193P#\GS\232\179dd\228\187=!\245" -// "\192\240\203\188%\240\133\a\130=\FS2\SOH\248\ACK\152",PropServerReference -// "\177\NAK\163\EOT\134d7\204\192=\237A\232p\214\153\227g\211\176x%'",PropMaximumPacketSize -// 25124,PropAssignedClientIdentifier -// "\246\150\248\ETX\SUB\139\220\151\235\217\246\US\205\&3\219\241\238\DLE\151\EM\ETX\158D\197P\186\244",PropMessageExpiryInterval -// 6475,PropServerKeepAlive 7420,PropCorrelationData "+\255\134G\153{\217Sx\145\241\CAN&%",PropMessageExpiryInterval -// 10192,PropCorrelationData -// "\155\219\130gz\157\&1\181`[\138\156\191\220}\SO;i\139\150\157\153\&0D\SOH\ESC<\166",PropCorrelationData -// "\131\172\171\&7h\135\222\137\DC1IW",PropRequestProblemInformation 5,PropMessageExpiryInterval -// 14885,PropSharedSubscriptionAvailable 70,PropReasonString "\SI\136gr\141\GS\142",PropTopicAliasMaximum 2086] -// [UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse] + EXPECT_EQ(packet_id, 16153); + EXPECT_EQ(count, 19); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NO_SUB_EXISTED); +} + +// UnsubscribeResponse 6562 [PropMaximumQoS 132,PropAssignedClientIdentifier +// "\164\229\241\213\138\215f{\231B\172\158\173\151\164J",PropMaximumQoS 240,PropWildcardSubscriptionAvailable +// 191,PropTopicAlias 16111,PropReceiveMaximum 1701,PropWildcardSubscriptionAvailable 86,PropAuthenticationData +// "-sB\229(\200;\229[\GS\155\233\&4\226\196\185\158\179\FS\169\241\177z|\160B\233=\165"] +// [UnsubNoSubscriptionExisted,UnsubSuccess,UnsubSuccess,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubTopicFilterInvalid] TEST(UnsubACK5QCTest, Decode5) { - uint8_t pkt[] = { - 0xb0, 0xde, 0x1, 0x71, 0xab, 0xcf, 0x1, 0x26, 0x0, 0x1c, 0x35, 0xd1, 0x96, 0xa5, 0x4d, 0xfa, 0xe0, 0xc7, 0xd5, - 0x5a, 0x65, 0xa8, 0x14, 0xd, 0xcd, 0xc1, 0x50, 0x23, 0x1d, 0xe8, 0xb3, 0x64, 0x64, 0xe4, 0xbb, 0x3d, 0x21, 0xf5, - 0x0, 0x10, 0xc0, 0xf0, 0xcb, 0xbc, 0x25, 0xf0, 0x85, 0x7, 0x82, 0x3d, 0x1c, 0x32, 0x1, 0xf8, 0x6, 0x98, 0x1c, - 0x0, 0x17, 0xb1, 0x15, 0xa3, 0x4, 0x86, 0x64, 0x37, 0xcc, 0xc0, 0x3d, 0xed, 0x41, 0xe8, 0x70, 0xd6, 0x99, 0xe3, - 0x67, 0xd3, 0xb0, 0x78, 0x25, 0x27, 0x27, 0x0, 0x0, 0x62, 0x24, 0x12, 0x0, 0x1b, 0xf6, 0x96, 0xf8, 0x3, 0x1a, - 0x8b, 0xdc, 0x97, 0xeb, 0xd9, 0xf6, 0x1f, 0xcd, 0x33, 0xdb, 0xf1, 0xee, 0x10, 0x97, 0x19, 0x3, 0x9e, 0x44, 0xc5, - 0x50, 0xba, 0xf4, 0x2, 0x0, 0x0, 0x19, 0x4b, 0x13, 0x1c, 0xfc, 0x9, 0x0, 0xe, 0x2b, 0xff, 0x86, 0x47, 0x99, - 0x7b, 0xd9, 0x53, 0x78, 0x91, 0xf1, 0x18, 0x26, 0x25, 0x2, 0x0, 0x0, 0x27, 0xd0, 0x9, 0x0, 0x1c, 0x9b, 0xdb, - 0x82, 0x67, 0x7a, 0x9d, 0x31, 0xb5, 0x60, 0x5b, 0x8a, 0x9c, 0xbf, 0xdc, 0x7d, 0xe, 0x3b, 0x69, 0x8b, 0x96, 0x9d, - 0x99, 0x30, 0x44, 0x1, 0x1b, 0x3c, 0xa6, 0x9, 0x0, 0xb, 0x83, 0xac, 0xab, 0x37, 0x68, 0x87, 0xde, 0x89, 0x11, - 0x49, 0x57, 0x17, 0x5, 0x2, 0x0, 0x0, 0x3a, 0x25, 0x2a, 0x46, 0x1f, 0x0, 0x7, 0xf, 0x88, 0x67, 0x72, 0x8d, - 0x1d, 0x8e, 0x22, 0x8, 0x26, 0x8f, 0x91, 0x8f, 0x0, 0x11, 0x80, 0x91, 0x80, 0x11, 0x83, 0x91}; + uint8_t pkt[] = {0xb0, 0x51, 0x19, 0xa2, 0x41, 0x24, 0x84, 0x12, 0x0, 0x10, 0xa4, 0xe5, 0xf1, 0xd5, 0x8a, 0xd7, 0x66, + 0x7b, 0xe7, 0x42, 0xac, 0x9e, 0xad, 0x97, 0xa4, 0x4a, 0x24, 0xf0, 0x28, 0xbf, 0x23, 0x3e, 0xef, 0x21, + 0x6, 0xa5, 0x28, 0x56, 0x16, 0x0, 0x1d, 0x2d, 0x73, 0x42, 0xe5, 0x28, 0xc8, 0x3b, 0xe5, 0x5b, 0x1d, + 0x9b, 0xe9, 0x34, 0xe2, 0xc4, 0xb9, 0x9e, 0xb3, 0x1c, 0xa9, 0xf1, 0xb1, 0x7a, 0x7c, 0xa0, 0x42, 0xe9, + 0x3d, 0xa5, 0x11, 0x0, 0x0, 0x80, 0x87, 0x80, 0x87, 0x80, 0x91, 0x0, 0x11, 0x0, 0x8f}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[11]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[13]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 13, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29099); - EXPECT_EQ(count, 11); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(packet_id, 6562); + EXPECT_EQ(count, 13); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); } -// UnsubscribeResponse 3499 [PropMaximumQoS 97,PropSubscriptionIdentifier 14,PropSubscriptionIdentifier -// 13,PropSharedSubscriptionAvailable 56,PropSubscriptionIdentifier 27,PropRequestProblemInformation -// 242,PropMessageExpiryInterval 26017,PropSessionExpiryInterval 17048,PropRetainAvailable -// 187,PropAssignedClientIdentifier "85\244\182\246)W\189:\215\211\197\139:\141d<\233",PropSubscriptionIdentifier -// 11,PropResponseInformation ">'\175\SYNZ\151\&6\180\217\&3\162\227\191\245\&0",PropMessageExpiryInterval -// 6524,PropTopicAlias 20579,PropMessageExpiryInterval 2741,PropMaximumQoS 195,PropUserProperty -// "\ETXIeK\163\ESC\164\STX\DC1n14\224\201\139\224\&6H\172\165\241m\210}3H3\EM" "\212",PropUserProperty -// "\136\206\175\143K\DC4\ENQ\168" "\132\196|\230H=l\149\v\223.\a_u\136",PropAuthenticationMethod -// "\FS",PropServerKeepAlive 12431,PropMessageExpiryInterval 22466,PropSharedSubscriptionAvailable -// 133,PropMaximumPacketSize 31328,PropAuthenticationMethod -// "\201SD\203y\v4P\184\198\181\GSc>\129B",PropPayloadFormatIndicator 18,PropSharedSubscriptionAvailable -// 186,PropSessionExpiryInterval 1470,PropRequestResponseInformation 50,PropMaximumQoS 19,PropSubscriptionIdentifier 12] -// [UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted] +// UnsubscribeResponse 32484 [PropMessageExpiryInterval 24715,PropSessionExpiryInterval 6744,PropSubscriptionIdentifier +// 7,PropAuthenticationData +// "`\252\187q\147\140\132\210\180\227b\201K\142\183\230\244![+\239-\226h\151\STX",PropSubscriptionIdentifierAvailable +// 20,PropTopicAlias 2199,PropServerReference "\246\&2a'\171",PropResponseTopic +// "\200t{\194Y\163\&1wW\157\168\SI\ETX\141A\242t)\204O\195`!",PropAssignedClientIdentifier -// "\DLE\132i\162\130",PropServerReference -// "_\171\144\140\131\ESC\130\146\SI*\170\193U8\164A)\ENQ\238S9\DELuG",PropSharedSubscriptionAvailable 18,PropMaximumQoS -// 242,PropTopicAliasMaximum 11494,PropMaximumPacketSize 16918,PropTopicAlias 17194,PropRetainAvailable -// 72,PropContentType "0%\131\137\229\191\f\216ab",PropPayloadFormatIndicator 183,PropPayloadFormatIndicator -// 219,PropSubscriptionIdentifier 23,PropMessageExpiryInterval 5099,PropRetainAvailable 7,PropMaximumPacketSize -// 32687,PropReceiveMaximum 31244] -// [UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubImplementationSpecificError] +// UnsubscribeResponse 18278 [PropTopicAliasMaximum 29170,PropTopicAliasMaximum 12797,PropSharedSubscriptionAvailable +// 147,PropMaximumPacketSize 27684,PropReasonString +// "\208\DLE\242\174\201\ETX[\170'\DELv\235f\219h\SI\169\228)%J\128\171\178G\208\171\131",PropRequestResponseInformation +// 215,PropSessionExpiryInterval 21356,PropWillDelayInterval 2475,PropAuthenticationData +// "\247\158\ff\177",PropPayloadFormatIndicator 122,PropRequestResponseInformation 195,PropRetainAvailable +// 117,PropResponseInformation +// "\DC1\206\222\194=QL\CAN\GS\133\192\&5:\RS\EM\161\254\n\133\v\211+\254\DC1b",PropReceiveMaximum +// 8036,PropSubscriptionIdentifier 13,PropAuthenticationMethod +// "\176\237-4\165f\DC3j[]4~\186\133\183\&7\150\142k\247{\t\233\DEL\161",PropTopicAlias 26886,PropTopicAlias +// 27587,PropTopicAliasMaximum 22088,PropContentType "\216'\231Y"] +// [UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubImplementationSpecificError] TEST(UnsubACK5QCTest, Decode8) { - uint8_t pkt[] = {0xb0, 0xb5, 0x1, 0x2c, 0x57, 0x94, 0x1, 0x2a, 0x5, 0x15, 0x0, 0x14, 0x93, 0x4c, 0x0, 0x7c, 0x38, - 0xda, 0x82, 0xcb, 0x7, 0x5d, 0x4d, 0xfc, 0x8e, 0x11, 0x82, 0x5f, 0x23, 0x29, 0x99, 0x46, 0x27, 0x0, - 0x0, 0x4c, 0xf5, 0x27, 0x0, 0x0, 0x12, 0x3, 0x15, 0x0, 0x18, 0x3e, 0xc8, 0x74, 0x7b, 0xc2, 0x59, - 0xa3, 0x31, 0x77, 0x57, 0x9d, 0xa8, 0xf, 0x3, 0x8d, 0x41, 0xf2, 0x74, 0x29, 0xcc, 0x4f, 0xc3, 0x60, - 0x21, 0x12, 0x0, 0x5, 0x10, 0x84, 0x69, 0xa2, 0x82, 0x1c, 0x0, 0x18, 0x5f, 0xab, 0x90, 0x8c, 0x83, - 0x1b, 0x82, 0x92, 0xf, 0x2a, 0xaa, 0xc1, 0x55, 0x38, 0xa4, 0x41, 0x29, 0x5, 0xee, 0x53, 0x39, 0x7f, - 0x75, 0x47, 0x2a, 0x12, 0x24, 0xf2, 0x22, 0x2c, 0xe6, 0x27, 0x0, 0x0, 0x42, 0x16, 0x23, 0x43, 0x2a, - 0x25, 0x48, 0x3, 0x0, 0xa, 0x30, 0x25, 0x83, 0x89, 0xe5, 0xbf, 0xc, 0xd8, 0x61, 0x62, 0x1, 0xb7, - 0x1, 0xdb, 0xb, 0x17, 0x2, 0x0, 0x0, 0x13, 0xeb, 0x25, 0x7, 0x27, 0x0, 0x0, 0x7f, 0xaf, 0x21, - 0x7a, 0xc, 0x11, 0x87, 0x8f, 0x8f, 0x8f, 0x87, 0x83, 0x83, 0x83, 0x11, 0x11, 0x87, 0x11, 0x80, 0x0, - 0x11, 0x11, 0x8f, 0x87, 0x83, 0x11, 0x91, 0x83, 0x80, 0x8f, 0x11, 0x91, 0x83, 0x83}; + uint8_t pkt[] = { + 0xb0, 0xa8, 0x1, 0x47, 0x66, 0x93, 0x1, 0x22, 0x71, 0xf2, 0x22, 0x31, 0xfd, 0x2a, 0x93, 0x27, 0x0, 0x0, 0x6c, + 0x24, 0x1f, 0x0, 0x1c, 0xd0, 0x10, 0xf2, 0xae, 0xc9, 0x3, 0x5b, 0xaa, 0x27, 0x7f, 0x76, 0xeb, 0x66, 0xdb, 0x68, + 0xf, 0xa9, 0xe4, 0x29, 0x25, 0x4a, 0x80, 0xab, 0xb2, 0x47, 0xd0, 0xab, 0x83, 0x19, 0xd7, 0x11, 0x0, 0x0, 0x53, + 0x6c, 0x18, 0x0, 0x0, 0x9, 0xab, 0x16, 0x0, 0x5, 0xf7, 0x9e, 0xc, 0x66, 0xb1, 0x1, 0x7a, 0x19, 0xc3, 0x25, + 0x75, 0x1a, 0x0, 0x19, 0x11, 0xce, 0xde, 0xc2, 0x3d, 0x51, 0x4c, 0x18, 0x1d, 0x85, 0xc0, 0x35, 0x3a, 0x1e, 0x19, + 0xa1, 0xfe, 0xa, 0x85, 0xb, 0xd3, 0x2b, 0xfe, 0x11, 0x62, 0x21, 0x1f, 0x64, 0xb, 0xd, 0x15, 0x0, 0x19, 0xb0, + 0xed, 0x2d, 0x34, 0xa5, 0x66, 0x13, 0x6a, 0x5b, 0x5d, 0x34, 0x7e, 0xba, 0x85, 0xb7, 0x37, 0x96, 0x8e, 0x6b, 0xf7, + 0x7b, 0x9, 0xe9, 0x7f, 0xa1, 0x23, 0x69, 0x6, 0x23, 0x6b, 0xc3, 0x22, 0x56, 0x48, 0x3, 0x0, 0x4, 0xd8, 0x27, + 0xe7, 0x59, 0x8f, 0x87, 0x91, 0x0, 0x0, 0x11, 0x91, 0x0, 0x11, 0x87, 0x87, 0x80, 0x0, 0x11, 0x91, 0x0, 0x83}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[29]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 29, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[17]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 17, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11351); - EXPECT_EQ(count, 29); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(packet_id, 18278); + EXPECT_EQ(count, 17); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[25], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[26], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[27], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[28], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); -} - -// UnsubscribeResponse 11966 [PropResponseInformation -// "\145\227\228&\228\DELM\RSc\140Vq\207\188\GS\229\174",PropAssignedClientIdentifier -// ",^\169\191\RSt\198\251\229iB\DC4\195\132G\202yI\223\171\SO\214\223u\143\150X",PropReasonString "-\203\&3\175 -// @\212\223\133\n\155J\141u\253\188d\177\f",PropSessionExpiryInterval 29407,PropTopicAlias 32744,PropResponseTopic -// "\188",PropReceiveMaximum 14635,PropWildcardSubscriptionAvailable 47] -// [UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubSuccess,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubUnspecifiedError] + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); +} + +// UnsubscribeResponse 8788 [PropServerKeepAlive 26978,PropSessionExpiryInterval 7992,PropMessageExpiryInterval +// 32063,PropAssignedClientIdentifier "\219\202\EOT=1\221\ETX#\206\205\228r\254\230\194`|",PropMaximumPacketSize +// 17219,PropSubscriptionIdentifier 29,PropSubscriptionIdentifierAvailable 175,PropMessageExpiryInterval +// 12813,PropSubscriptionIdentifierAvailable 62,PropSubscriptionIdentifierAvailable 92,PropRequestResponseInformation +// 223,PropReasonString "\SUB\DC3\237\225\130O\142\n\f\232;\221\191\164-\242",PropServerReference +// "\162\245a\NUL0\186%\207&\"\222\238\220\238s\\X\184@k\144\"\229\&9\254\231#\169\228",PropServerKeepAlive +// 10678,PropMaximumQoS 213,PropMaximumQoS 255,PropServerReference "\156\220\&2",PropMaximumPacketSize +// 28763,PropRequestProblemInformation 144] +// [UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted] TEST(UnsubACK5QCTest, Decode9) { - uint8_t pkt[] = {0xb0, 0x63, 0x2e, 0xbe, 0x59, 0x1a, 0x0, 0x11, 0x91, 0xe3, 0xe4, 0x26, 0xe4, 0x7f, 0x4d, 0x1e, 0x63, - 0x8c, 0x56, 0x71, 0xcf, 0xbc, 0x1d, 0xe5, 0xae, 0x12, 0x0, 0x1b, 0x2c, 0x5e, 0xa9, 0xbf, 0x1e, 0x74, - 0xc6, 0xfb, 0xe5, 0x69, 0x42, 0x14, 0xc3, 0x84, 0x47, 0xca, 0x79, 0x49, 0xdf, 0xab, 0xe, 0xd6, 0xdf, - 0x75, 0x8f, 0x96, 0x58, 0x1f, 0x0, 0x13, 0x2d, 0xcb, 0x33, 0xaf, 0x20, 0x40, 0xd4, 0xdf, 0x85, 0xa, - 0x9b, 0x4a, 0x8d, 0x75, 0xfd, 0xbc, 0x64, 0xb1, 0xc, 0x11, 0x0, 0x0, 0x72, 0xdf, 0x23, 0x7f, 0xe8, - 0x8, 0x0, 0x1, 0xbc, 0x21, 0x39, 0x2b, 0x28, 0x2f, 0x87, 0x91, 0x80, 0x0, 0x87, 0x8f, 0x80}; + uint8_t pkt[] = {0xb0, 0x88, 0x1, 0x22, 0x54, 0x7c, 0x13, 0x69, 0x62, 0x11, 0x0, 0x0, 0x1f, 0x38, 0x2, 0x0, + 0x0, 0x7d, 0x3f, 0x12, 0x0, 0x11, 0xdb, 0xca, 0x4, 0x3d, 0x31, 0xdd, 0x3, 0x23, 0xce, 0xcd, + 0xe4, 0x72, 0xfe, 0xe6, 0xc2, 0x60, 0x7c, 0x27, 0x0, 0x0, 0x43, 0x43, 0xb, 0x1d, 0x29, 0xaf, + 0x2, 0x0, 0x0, 0x32, 0xd, 0x29, 0x3e, 0x29, 0x5c, 0x19, 0xdf, 0x1f, 0x0, 0x10, 0x1a, 0x13, + 0xed, 0xe1, 0x82, 0x4f, 0x8e, 0xa, 0xc, 0xe8, 0x3b, 0xdd, 0xbf, 0xa4, 0x2d, 0xf2, 0x1c, 0x0, + 0x1d, 0xa2, 0xf5, 0x61, 0x0, 0x30, 0xba, 0x25, 0xcf, 0x26, 0x22, 0xde, 0xee, 0xdc, 0xee, 0x73, + 0x5c, 0x58, 0xb8, 0x40, 0x6b, 0x90, 0x22, 0xe5, 0x39, 0xfe, 0xe7, 0x23, 0xa9, 0xe4, 0x13, 0x29, + 0xb6, 0x24, 0xd5, 0x24, 0xff, 0x1c, 0x0, 0x3, 0x9c, 0xdc, 0x32, 0x27, 0x0, 0x0, 0x70, 0x5b, + 0x17, 0x90, 0x87, 0x11, 0x80, 0x80, 0x80, 0x80, 0x91, 0x8f, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[7]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[9]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11966); - EXPECT_EQ(count, 7); + EXPECT_EQ(packet_id, 8788); + EXPECT_EQ(count, 9); EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); EXPECT_EQ(statuses[2], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); } -// UnsubscribeResponse 28946 [PropAuthenticationMethod -// "7\240\150\195\&38\131m\233\159C\214\147>R\128\253|m\GS-\193\129",PropTopicAlias 5564,PropRequestProblemInformation -// 75,PropRequestProblemInformation 190,PropMessageExpiryInterval 834,PropRetainAvailable 33,PropResponseInformation -// "I\198",PropCorrelationData -// "\193\rCf+\STX\155\193\169\167\SOH)\137\145b\156h\ESC\219\154\225PE\DC2\239\ACK\244",PropResponseInformation -// "\133|o\247!\161\195m\165e1mJ\157e",PropReceiveMaximum 27827,PropServerKeepAlive 13713,PropReasonString -// ")\228I\174\175\245\179\225",PropRetainAvailable 106,PropSessionExpiryInterval 19620] -// [UnsubSuccess,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubSuccess,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubSuccess] +// UnsubscribeResponse 27653 [PropMessageExpiryInterval 27137,PropCorrelationData +// "\150\&3\172q:\231\135",PropReceiveMaximum 28977,PropMaximumPacketSize 8765,PropCorrelationData +// "u\213\140\152\&7o\181\DLE\145\US*\152\140\135\204,o\151\aO",PropReceiveMaximum 31861,PropMessageExpiryInterval +// 9228,PropSubscriptionIdentifier 21,PropReasonString "]ft\FS2\238\216\204\166\215_\227\142\157\188\179\135\229\146j"] +// [UnsubSuccess,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted] TEST(UnsubACK5QCTest, Decode10) { - uint8_t pkt[] = {0xb0, 0x93, 0x1, 0x71, 0x12, 0x75, 0x15, 0x0, 0x17, 0x37, 0xf0, 0x96, 0xc3, 0x33, 0x38, 0x83, 0x6d, - 0xe9, 0x9f, 0x43, 0xd6, 0x93, 0x3e, 0x52, 0x80, 0xfd, 0x7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 0x14, 0x5d, 0x66, 0x74, 0x1c, + 0x32, 0xee, 0xd8, 0xcc, 0xa6, 0xd7, 0x5f, 0xe3, 0x8e, 0x9d, 0xbc, 0xb3, 0x87, 0xe5, 0x92, 0x6a, 0x0, + 0x91, 0x11, 0x80, 0x91, 0x0, 0x80, 0x91, 0x0, 0x87, 0x80, 0x0, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[27]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 27, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[13]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 13, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 28946); - EXPECT_EQ(count, 27); + EXPECT_EQ(packet_id, 27653); + EXPECT_EQ(count, 13); EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[25], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[26], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); } -// UnsubscribeResponse 29805 [PropSharedSubscriptionAvailable 167,PropWildcardSubscriptionAvailable -// 36,PropRetainAvailable 125,PropReceiveMaximum 20880,PropServerKeepAlive 6088,PropTopicAliasMaximum -// 18031,PropTopicAliasMaximum 15408,PropSubscriptionIdentifierAvailable 7,PropRequestProblemInformation -// 160,PropSharedSubscriptionAvailable 138,PropWildcardSubscriptionAvailable 221,PropAuthenticationMethod -// "\150\233T\188",PropSharedSubscriptionAvailable 218,PropTopicAlias 11586] -// [UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubSuccess] +// UnsubscribeResponse 11848 [PropTopicAliasMaximum 14660,PropServerReference +// "\200\174\198\133a\207y\236\232J\192\206\SI2\231\209\NAK\v\205\&1",PropResponseTopic +// "H@(\153\SOua\135;!\170K\159",PropAssignedClientIdentifier ".j",PropRequestResponseInformation 196,PropReceiveMaximum +// 7860,PropCorrelationData +// "d\156\193\141\250\128\NUL\NAK\212>\EOT\239\133\143J\201\&2\216\144\"\STX\165",PropTopicAliasMaximum +// 8812,PropRetainAvailable 216] +// [UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubSuccess,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubImplementationSpecificError] TEST(UnsubACK5QCTest, Decode11) { - uint8_t pkt[] = {0xb0, 0x2e, 0x74, 0x6d, 0x26, 0x2a, 0xa7, 0x28, 0x24, 0x25, 0x7d, 0x21, 0x51, 0x90, 0x13, 0x17, - 0xc8, 0x22, 0x46, 0x6f, 0x22, 0x3c, 0x30, 0x29, 0x7, 0x17, 0xa0, 0x2a, 0x8a, 0x28, 0xdd, 0x15, - 0x0, 0x4, 0x96, 0xe9, 0x54, 0xbc, 0x2a, 0xda, 0x23, 0x2d, 0x42, 0x83, 0x80, 0x83, 0x8f, 0x0}; + uint8_t pkt[] = {0xb0, 0x66, 0x2e, 0x48, 0x52, 0x22, 0x39, 0x44, 0x1c, 0x0, 0x14, 0xc8, 0xae, 0xc6, 0x85, + 0x61, 0xcf, 0x79, 0xec, 0xe8, 0x4a, 0xc0, 0xce, 0xf, 0x32, 0xe7, 0xd1, 0x15, 0xb, 0xcd, + 0x31, 0x8, 0x0, 0xd, 0x48, 0x40, 0x28, 0x99, 0xe, 0x75, 0x61, 0x87, 0x3b, 0x21, 0xaa, + 0x4b, 0x9f, 0x12, 0x0, 0x2, 0x2e, 0x6a, 0x19, 0xc4, 0x21, 0x1e, 0xb4, 0x9, 0x0, 0x16, + 0x64, 0x9c, 0xc1, 0x8d, 0xfa, 0x80, 0x0, 0x15, 0xd4, 0x3e, 0x4, 0xef, 0x85, 0x8f, 0x4a, + 0xc9, 0x32, 0xd8, 0x90, 0x22, 0x2, 0xa5, 0x22, 0x22, 0x6c, 0x25, 0xd8, 0x80, 0x11, 0x83, + 0x0, 0x11, 0x8f, 0x11, 0x83, 0x0, 0x80, 0x91, 0x0, 0x83, 0x80, 0x91, 0x0, 0x83}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[5]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[17]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 17, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29805); - EXPECT_EQ(count, 5); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(packet_id, 11848); + EXPECT_EQ(count, 17); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); -} - -// UnsubscribeResponse 19841 [PropRequestResponseInformation 195,PropSessionExpiryInterval 7099,PropCorrelationData -// "\253Q\149=\DC2\ESC \244\255\163G\186go\221\227M\SUB\224c\250\197a\SYN\167\151",PropServerReference -// "\160f\192\196\162",PropRequestProblemInformation 69,PropResponseInformation -// "\143\148\214\220\&6\248\182\150\135/\227\183\208#\244\&5\226\147\239\162+",PropSharedSubscriptionAvailable -// 5,PropTopicAlias 25859,PropAuthenticationMethod "\219*\147/^\ETB\RS-\219\ACK$6\\\185P%(",PropResponseInformation -// "\235g\205<\169\&98\245v\187\214\183\222\160\167\CAN\ETXkE\176 \137",PropSharedSubscriptionAvailable -// 1,PropMessageExpiryInterval 8462,PropAuthenticationMethod "\171",PropReceiveMaximum 23714,PropMessageExpiryInterval -// 31618,PropServerKeepAlive 15174,PropWillDelayInterval 30554,PropServerKeepAlive 28321,PropMaximumQoS -// 208,PropAuthenticationMethod "\251\188MB\GS\ESCW\186R\142A\tj\235@\166\"",PropMaximumPacketSize 26290,PropMaximumQoS -// 50,PropUserProperty "b\DC3\146\176(lv\171\154\&1\191\141\225\&5\145_O\245Y\192\EM\ESC" -// "\167\CAN|\150\ACK\214\214Q\ETX\152I\181I\a\164\155~\184\218\180Jq",PropSessionExpiryInterval 2734,PropContentType -// "m\176\&7\170\\"] -// [UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubSuccess,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubTopicFilterInvalid] + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); +} + +// UnsubscribeResponse 10434 [PropContentType "\231\153\188v`\178\CAN\142",PropServerReference +// "\STX\144\147\199l5\169=\236\&8\ENQ\218L\247\161\159\172",PropMessageExpiryInterval +// 26774,PropSharedSubscriptionAvailable 189,PropMessageExpiryInterval 150,PropServerReference +// "\141\160\207\&4PJ)\129\138\204\224KB\241\212I\199)s\180\182\FS\194\163\171j\200(^\206",PropAssignedClientIdentifier +// "\227",PropMessageExpiryInterval 627,PropCorrelationData +// "\192\146\252z\140\244&\249S\233\STX\229\DELm",PropContentType "\167\139\DC4\213L7",PropMessageExpiryInterval +// 26701,PropRequestProblemInformation 168,PropSubscriptionIdentifierAvailable 74,PropSubscriptionIdentifierAvailable +// 150,PropResponseInformation "zW\142u\213q\236G\211A\202\"\245\210,\DC4\239\233\245N'",PropMessageExpiryInterval +// 3303,PropUserProperty "\RS\129b\249H~\170ot\143\187I-\211J\199\167\181\212\160\&9\206\216\237\252f^" +// "\145\251|-\183\172\254",PropSessionExpiryInterval 13760,PropMaximumQoS 98] +// [UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubNotAuthorized,UnsubNoSubscriptionExisted] TEST(UnsubACK5QCTest, Decode12) { - uint8_t pkt[] = {0xb0, 0x88, 0x2, 0x4d, 0x81, 0xf1, 0x1, 0x19, 0xc3, 0x11, 0x0, 0x0, 0x1b, 0xbb, 0x9, 0x0, 0x1a, - 0xfd, 0x51, 0x95, 0x3d, 0x12, 0x1b, 0x20, 0xf4, 0xff, 0xa3, 0x47, 0xba, 0x67, 0x6f, 0xdd, 0xe3, 0x4d, - 0x1a, 0xe0, 0x63, 0xfa, 0xc5, 0x61, 0x16, 0xa7, 0x97, 0x1c, 0x0, 0x5, 0xa0, 0x66, 0xc0, 0xc4, 0xa2, - 0x17, 0x45, 0x1a, 0x0, 0x15, 0x8f, 0x94, 0xd6, 0xdc, 0x36, 0xf8, 0xb6, 0x96, 0x87, 0x2f, 0xe3, 0xb7, - 0xd0, 0x23, 0xf4, 0x35, 0xe2, 0x93, 0xef, 0xa2, 0x2b, 0x2a, 0x5, 0x23, 0x65, 0x3, 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0x66, + 0x5e, 0x0, 0x7, 0x91, 0xfb, 0x7c, 0x2d, 0xb7, 0xac, 0xfe, 0x11, 0x0, 0x0, 0x35, 0xc0, 0x24, 0x62, + 0x80, 0x80, 0x80, 0x80, 0x91, 0x83, 0x91, 0x87, 0x11, 0x87, 0x91, 0x87, 0x87, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[19]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 19, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[14]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 14, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19841); - EXPECT_EQ(count, 19); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(packet_id, 10434); + EXPECT_EQ(count, 14); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); } -// UnsubscribeResponse 20127 [PropResponseInformation "\141",PropAuthenticationData -// "\SUB\224",PropAssignedClientIdentifier "\243",PropAuthenticationMethod "\145\DC2\201\DC4\250\153\"Xo0i\134D\215\223 -// w5\214\138\213\164f~\\\150\175\171;",PropReasonString -// "$\223\232\147\131e\183\175U\200Dv\234S\129X\202",PropAuthenticationMethod -// "\US\162w\181I\">p$\n",PropSharedSubscriptionAvailable 226,PropReceiveMaximum -// 3366,PropSubscriptionIdentifierAvailable 14,PropWillDelayInterval 9401,PropReceiveMaximum 23667,PropUserProperty -// "\tu\153\250\252\DC1S" "\238\169\232\b\146\135",PropSharedSubscriptionAvailable 108] -// [UnsubPacketIdentifierInUse,UnsubSuccess,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubSuccess,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubSuccess,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubImplementationSpecificError,UnsubSuccess,UnsubImplementationSpecificError,UnsubSuccess] +// UnsubscribeResponse 16799 [PropAuthenticationMethod +// "\GSx\195\222)\194\238&\181]\238\162\198\144\209\217\185\149\144\225",PropResponseTopic +// "(",PropRequestProblemInformation 224,PropSubscriptionIdentifier 21,PropRequestResponseInformation +// 139,PropWillDelayInterval 6123,PropAuthenticationData +// "\206s\239W\141\227\145\235\131\217\242\RS\DC1E\157`\136\223",PropUserProperty +// "\DLE\153\236E\241\&8i\SUB\241\223\188\185\245Ch\178\n\199\194WT\145&y-=f_7" +// "\197\FSN>\236\237\CANA\193\161\163\&1\252\244\231\154\EMS",PropContentType +// "\168(f\173\199*\188\f\193=0J\157\161D\194\158'MY8\vw\214\199<\138\t\176\DLE",PropContentType +// "\220\249\206\142\STXt3\RS\149k\220\155(",PropWillDelayInterval 13682,PropAuthenticationData "b",PropContentType +// "\136=\217\249\234\251\255=@\138\168\217\248i\STX\249rX+\156\176",PropResponseTopic +// "\bh\EMW[\DC1l\178\FS\ENQ\185\143",PropAuthenticationMethod "\141\242\ENQ\233x=\210\166\&2!\191\166\133\CAN \ETB"] +// [UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubSuccess,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubSuccess,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubNotAuthorized] TEST(UnsubACK5QCTest, Decode13) { - uint8_t pkt[] = {0xb0, 0x90, 0x1, 0x4e, 0x9f, 0x71, 0x1a, 0x0, 0x1, 0x8d, 0x16, 0x0, 0x2, 0x1a, 0xe0, 0x12, 0x0, - 0x1, 0xf3, 0x15, 0x0, 0x1d, 0x91, 0x12, 0xc9, 0x14, 0xfa, 0x99, 0x22, 0x58, 0x6f, 0x30, 0x69, 0x86, - 0x44, 0xd7, 0xdf, 0x20, 0x77, 0x35, 0xd6, 0x8a, 0xd5, 0xa4, 0x66, 0x7e, 0x5c, 0x96, 0xaf, 0xab, 0x3b, - 0x1f, 0x0, 0x11, 0x24, 0xdf, 0xe8, 0x93, 0x83, 0x65, 0xb7, 0xaf, 0x55, 0xc8, 0x44, 0x76, 0xea, 0x53, - 0x81, 0x58, 0xca, 0x15, 0x0, 0xa, 0x1f, 0xa2, 0x77, 0xb5, 0x49, 0x22, 0x3e, 0x70, 0x24, 0xa, 0x2a, - 0xe2, 0x21, 0xd, 0x26, 0x29, 0xe, 0x18, 0x0, 0x0, 0x24, 0xb9, 0x21, 0x5c, 0x73, 0x26, 0x0, 0x7, - 0x9, 0x75, 0x99, 0xfa, 0xfc, 0x11, 0x53, 0x0, 0x6, 0xee, 0xa9, 0xe8, 0x8, 0x92, 0x87, 0x2a, 0x6c, - 0x91, 0x0, 0x83, 0x83, 0x0, 0x80, 0x11, 0x83, 0x91, 0x91, 0x0, 0x8f, 0x8f, 0x87, 0x11, 0x87, 0x80, - 0x0, 0x80, 0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0x3, 0x0, 0x15, 0x88, 0x3d, 0xd9, 0xf9, 0xea, 0xfb, 0xff, 0x3d, + 0x40, 0x8a, 0xa8, 0xd9, 0xf8, 0x69, 0x2, 0xf9, 0x72, 0x58, 0x2b, 0x9c, 0xb0, 0x8, 0x0, 0xc, 0x8, + 0x68, 0x19, 0x57, 0x5b, 0x11, 0x6c, 0xb2, 0x1c, 0x5, 0xb9, 0x8f, 0x15, 0x0, 0x10, 0x8d, 0xf2, 0x5, + 0xe9, 0x78, 0x3d, 0xd2, 0xa6, 0x32, 0x21, 0xbf, 0xa6, 0x85, 0x18, 0x20, 0x17, 0x8f, 0x80, 0x83, 0x0, + 0x83, 0x91, 0x80, 0x80, 0x0, 0x80, 0x83, 0x91, 0x91, 0x83, 0x91, 0x91, 0x91, 0x87}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[28]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 28, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[18]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 18, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 20127); - EXPECT_EQ(count, 28); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(packet_id, 16799); + EXPECT_EQ(count, 18); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[25], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[26], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[27], LWMQTT_UNSUB_SUCCESS); -} - -// UnsubscribeResponse 6820 [PropAssignedClientIdentifier "&l\161Q\197\198\157\":\212o -// \179w\US~\197\144\244.\ETB\233\171",PropTopicAliasMaximum 7609,PropRequestProblemInformation 190,PropReasonString -// "[\209mi\197\160\NAK==\141\139\200 c\244",PropSubscriptionIdentifierAvailable 164] -// [UnsubNotAuthorized,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubSuccess,UnsubSuccess,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubSuccess,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubTopicFilterInvalid] + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NOT_AUTHORIZED); +} + +// UnsubscribeResponse 19000 [PropReceiveMaximum 20861] +// [UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubSuccess] TEST(UnsubACK5QCTest, Decode14) { - uint8_t pkt[] = {0xb0, 0x52, 0x1a, 0xa4, 0x33, 0x12, 0x0, 0x17, 0x26, 0x6c, 0xa1, 0x51, 0xc5, 0xc6, 0x9d, 0x22, 0x3a, - 0xd4, 0x6f, 0x20, 0xb3, 0x77, 0x1f, 0x7e, 0xc5, 0x90, 0xf4, 0x2e, 0x17, 0xe9, 0xab, 0x22, 0x1d, 0xb9, - 0x17, 0xbe, 0x1f, 0x0, 0xf, 0x5b, 0xd1, 0x6d, 0x69, 0xc5, 0xa0, 0x15, 0x3d, 0x3d, 0x8d, 0x8b, 0xc8, - 0x20, 0x63, 0xf4, 0x29, 0xa4, 0x87, 0x80, 0x83, 0x91, 0x91, 0x83, 0x83, 0x87, 0x91, 0x91, 0x91, 0x8f, - 0x0, 0x0, 0x87, 0x83, 0x87, 0x0, 0x87, 0x83, 0x80, 0x80, 0x8f, 0x83, 0x80, 0x83, 0x80, 0x8f}; + uint8_t pkt[] = {0xb0, 0x10, 0x4a, 0x38, 0x3, 0x21, 0x51, 0x7d, 0x91, + 0x80, 0x0, 0x11, 0x87, 0x91, 0x83, 0x87, 0x8f, 0x0}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[28]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 28, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[10]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6820); - EXPECT_EQ(count, 28); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(packet_id, 19000); + EXPECT_EQ(count, 10); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[25], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[26], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[27], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); -} - -// UnsubscribeResponse 20949 [PropCorrelationData -// "\222\218_AT\185\SI\247\STX\156\252\152\SOE\186",PropSessionExpiryInterval 10976,PropAuthenticationData -// "\131I\RS\EOT\213n\135\197\206\129&\209\&4\191)\f\221U\159gR^]\184\173\131\152*\235",PropRequestProblemInformation -// 254,PropTopicAliasMaximum 23485,PropResponseInformation "2Y\223\239\209L\140)\153\144)& \156\164p",PropReceiveMaximum -// 636,PropPayloadFormatIndicator 97,PropMaximumPacketSize 26198,PropContentType "0\220\&5",PropWillDelayInterval -// 14882,PropTopicAlias 20936,PropRequestProblemInformation 127,PropResponseTopic -// "C\214\182\176\151\189\234\237'%g6\235\214\239\&3\246#\155\213\142",PropResponseInformation -// "\224zEl-\188RO\219\140?s\231\GSR\234)\200\197\238",PropContentType "\244\bC\217\SYN\152\&9\SI#\241~\186\214}\198"] -// [UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubSuccess,UnsubUnspecifiedError,UnsubImplementationSpecificError] + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_SUCCESS); +} + +// UnsubscribeResponse 6514 [PropAuthenticationMethod "~\t&F\"m#\216\222",PropPayloadFormatIndicator 130,PropTopicAlias +// 7070,PropResponseInformation "\ACK\200q\188i\204\t\DEL",PropMaximumQoS 192,PropRetainAvailable 56,PropServerKeepAlive +// 16040,PropRetainAvailable 179,PropUserProperty "" "b\237\134(",PropContentType "\169\220\245",PropResponseInformation +// "\253\170\238\188\229\GS\169\&0\DC4\CAN\198\132\164}D\SOH\133\ESCr?x\DC2.\151",PropTopicAlias +// 30069,PropMaximumPacketSize 23905,PropCorrelationData +// "\230\167\244\&0\151n\178\148C\223\209\GS\161\&47\136",PropContentType "\211\140\165Q\218",PropAuthenticationMethod +// "\231\147Ps",PropServerReference "\205\250\248\&6H",PropSessionExpiryInterval 5830,PropSessionExpiryInterval +// 7230,PropSubscriptionIdentifierAvailable 36,PropAuthenticationMethod +// "\168\212\194\DC28\160\r\220.\223\&3\148\251\&5\251+\162\DC4O\160",PropReceiveMaximum +// 19852,PropSharedSubscriptionAvailable 158,PropResponseTopic +// "\211\170\194\209Y6\137NbU\DC3\247U)\152[!R\131\176",PropCorrelationData +// "\164\253\214\180]5\241\147\161\149\174\203n\173"] +// [UnsubUnspecifiedError,UnsubNotAuthorized,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubUnspecifiedError] TEST(UnsubACK5QCTest, Decode15) { - uint8_t pkt[] = {0xb0, 0xb6, 0x1, 0x51, 0xd5, 0xaa, 0x1, 0x9, 0x0, 0xf, 0xde, 0xda, 0x5f, 0x41, 0x54, 0xb9, 0xf, - 0xf7, 0x2, 0x9c, 0xfc, 0x98, 0xe, 0x45, 0xba, 0x11, 0x0, 0x0, 0x2a, 0xe0, 0x16, 0x0, 0x1d, 0x83, - 0x49, 0x1e, 0x4, 0xd5, 0x6e, 0x87, 0xc5, 0xce, 0x81, 0x26, 0xd1, 0x34, 0xbf, 0x29, 0xc, 0xdd, 0x55, - 0x9f, 0x67, 0x52, 0x5e, 0x5d, 0xb8, 0xad, 0x83, 0x98, 0x2a, 0xeb, 0x17, 0xfe, 0x22, 0x5b, 0xbd, 0x1a, - 0x0, 0x10, 0x32, 0x59, 0xdf, 0xef, 0xd1, 0x4c, 0x8c, 0x29, 0x99, 0x90, 0x29, 0x26, 0x20, 0x9c, 0xa4, - 0x70, 0x21, 0x2, 0x7c, 0x1, 0x61, 0x27, 0x0, 0x0, 0x66, 0x56, 0x3, 0x0, 0x3, 0x30, 0xdc, 0x35, - 0x18, 0x0, 0x0, 0x3a, 0x22, 0x23, 0x51, 0xc8, 0x17, 0x7f, 0x8, 0x0, 0x15, 0x43, 0xd6, 0xb6, 0xb0, - 0x97, 0xbd, 0xea, 0xed, 0x27, 0x25, 0x67, 0x36, 0xeb, 0xd6, 0xef, 0x33, 0xf6, 0x23, 0x9b, 0xd5, 0x8e, - 0x1a, 0x0, 0x14, 0xe0, 0x7a, 0x45, 0x6c, 0x2d, 0xbc, 0x52, 0x4f, 0xdb, 0x8c, 0x3f, 0x73, 0xe7, 0x1d, - 0x52, 0xea, 0x29, 0xc8, 0xc5, 0xee, 0x3, 0x0, 0xf, 0xf4, 0x8, 0x43, 0xd9, 0x16, 0x98, 0x39, 0xf, - 0x23, 0xf1, 0x7e, 0xba, 0xd6, 0x7d, 0xc6, 0x83, 0x80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3, 0xaa, 0xc2, 0xd1, 0x59, 0x36, 0x89, 0x4e, + 0x62, 0x55, 0x13, 0xf7, 0x55, 0x29, 0x98, 0x5b, 0x21, 0x52, 0x83, 0xb0, 0x9, 0x0, 0xe, 0xa4, 0xfd, + 0xd6, 0xb4, 0x5d, 0x35, 0xf1, 0x93, 0xa1, 0x95, 0xae, 0xcb, 0x6e, 0xad, 0x80, 0x87, 0x87, 0x83, 0x83, + 0x0, 0x91, 0x8f, 0x11, 0x91, 0x11, 0x91, 0x11, 0x83, 0x80}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[8]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[15]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 15, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 20949); - EXPECT_EQ(count, 8); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(packet_id, 6514); + EXPECT_EQ(count, 15); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); -} - -// UnsubscribeResponse 15084 [PropTopicAliasMaximum 6984,PropUserProperty ",\189 -// \197\190&S,t\241E\ESC\248\211\DC4\177\187\b\238\205w\159\183\USK\148" -// "-\229\131\222\RS\193\171\151c\STX\138\139\214`\144\165\239k\146",PropSessionExpiryInterval -// 2451,PropSessionExpiryInterval 9205,PropAuthenticationMethod -// "\161E:&\206\194Z1\183\139\v~\SOH\255\STXx\SO\SO\ETXz\224R\161\209",PropMaximumQoS 80,PropReceiveMaximum -// 30671,PropAuthenticationData "Ya\157\&1Y\f\"\255*\248\SI\bf\EOTqd\168\USC'8\175\241!",PropResponseInformation -// "\138l\NAK",PropSubscriptionIdentifierAvailable 136,PropMaximumQoS 148,PropSubscriptionIdentifierAvailable -// 244,PropServerKeepAlive 25040,PropTopicAlias 1743,PropAuthenticationMethod -// "\216\201r\175]\219x@i5q\239e\238\160\218\DLE",PropUserProperty "0\164y\143N" "KD",PropReasonString -// "3C\210q\n\CAN{\131\237\224N\FS\170\183u|4R",PropServerKeepAlive 10794,PropMessageExpiryInterval -// 17780,PropSubscriptionIdentifierAvailable 204,PropSessionExpiryInterval 3287,PropRequestProblemInformation -// 246,PropSubscriptionIdentifier 19,PropSubscriptionIdentifier 10,PropContentType -// "\143?}\ESC\249}9\NUL\142\128\210r\SYNA\STX\176\250\132"] -// [UnsubNoSubscriptionExisted,UnsubSuccess,UnsubNotAuthorized,UnsubSuccess,UnsubNotAuthorized,UnsubNotAuthorized] -TEST(UnsubACK5QCTest, Decode19) { - uint8_t pkt[] = {0xb0, 0xa4, 0x1, 0x2d, 0x79, 0x9a, 0x1, 0x1f, 0x0, 0x0, 0x26, 0x0, 0xc, 0x2b, 0xb6, 0xb7, 0xc, - 0x4b, 0x67, 0x68, 0x3, 0x39, 0x81, 0xa6, 0x8d, 0x0, 0x15, 0x1c, 0xa7, 0xc5, 0xc2, 0x11, 0xd0, 0xf4, - 0x22, 0x3c, 0xdd, 0x3e, 0x71, 0x64, 0xa8, 0x1f, 0x43, 0x27, 0x38, 0xaf, 0xf1, 0x21, 0x1a, 0x0, 0x3, - 0x8a, 0x6c, 0x15, 0x29, 0x88, 0x24, 0x94, 0x29, 0xf4, 0x13, 0x61, 0xd0, 0x23, 0x6, 0xcf, 0x15, 0x0, - 0x11, 0xd8, 0xc9, 0x72, 0xaf, 0x5d, 0xdb, 0x78, 0x40, 0x69, 0x35, 0x71, 0xef, 0x65, 0xee, 0xa0, 0xda, - 0x10, 0x26, 0x0, 0x5, 0x30, 0xa4, 0x79, 0x8f, 0x4e, 0x0, 0x2, 0x4b, 0x44, 0x1f, 0x0, 0x12, 0x33, - 0x43, 0xd2, 0x71, 0xa, 0x18, 0x7b, 0x83, 0xed, 0xe0, 0x4e, 0x1c, 0xaa, 0xb7, 0x75, 0x7c, 0x34, 0x52, - 0x13, 0x2a, 0x2a, 0x2, 0x0, 0x0, 0x45, 0x74, 0x29, 0xcc, 0x11, 0x0, 0x0, 0xc, 0xd7, 0x17, 0xf6, - 0xb, 0x13, 0xb, 0xa, 0x3, 0x0, 0x12, 0x8f, 0x3f, 0x7d, 0x1b, 0xf9, 0x7d, 0x39, 0x0, 0x8e, 0x80, - 0xd2, 0x72, 0x16, 0x41, 0x2, 0xb0, 0xfa, 0x84, 0x11, 0x0, 0x87, 0x0, 0x87, 0x87}; +// UnsubscribeResponse 28726 [PropSubscriptionIdentifierAvailable 135,PropServerKeepAlive 13001,PropUserProperty +// "\132\146\RS\158\&0-n,\EOT\172\202\224\234\159" +// "\137\201@\SYN\150\144\188\r*\\:\196,L>vWO\151\188S\159jN\243\246\227c\197\175",PropReasonString +// "d@\234\165\143E\171\157",PropMaximumQoS 251,PropAuthenticationMethod +// "\SOH\135)\130\225u\NAK\230\166\231Y\242\239\136\254nO`{\238Q\247Y",PropCorrelationData +// "T\200l\142\252\221\182\SYN\241J{\216kdj\214\NAKl\203J\139\&5\223",PropRetainAvailable +// 81,PropSharedSubscriptionAvailable 193,PropServerKeepAlive 21372,PropContentType +// "\178\168G\183\185\254\236+e\238\SOH\STX\194\&2",PropAssignedClientIdentifier "u=J\225\128\233v3",PropReasonString +// ".\NUL\234"] [] +TEST(UnsubACK5QCTest, Decode18) { + uint8_t pkt[] = {0xb0, 0xa4, 0x1, 0x70, 0x36, 0xa0, 0x1, 0x29, 0x87, 0x13, 0x32, 0xc9, 0x26, 0x0, 0xe, 0x84, 0x92, + 0x1e, 0x9e, 0x30, 0x2d, 0x6e, 0x2c, 0x4, 0xac, 0xca, 0xe0, 0xea, 0x9f, 0x0, 0x1e, 0x89, 0xc9, 0x40, + 0x16, 0x96, 0x90, 0xbc, 0xd, 0x2a, 0x5c, 0x3a, 0xc4, 0x2c, 0x4c, 0x3e, 0x76, 0x57, 0x4f, 0x97, 0xbc, + 0x53, 0x9f, 0x6a, 0x4e, 0xf3, 0xf6, 0xe3, 0x63, 0xc5, 0xaf, 0x1f, 0x0, 0x8, 0x64, 0x40, 0xea, 0xa5, + 0x8f, 0x45, 0xab, 0x9d, 0x24, 0xfb, 0x15, 0x0, 0x17, 0x1, 0x87, 0x29, 0x82, 0xe1, 0x75, 0x15, 0xe6, + 0xa6, 0xe7, 0x59, 0xf2, 0xef, 0x88, 0xfe, 0x6e, 0x4f, 0x60, 0x7b, 0xee, 0x51, 0xf7, 0x59, 0x9, 0x0, + 0x17, 0x54, 0xc8, 0x6c, 0x8e, 0xfc, 0xdd, 0xb6, 0x16, 0xf1, 0x4a, 0x7b, 0xd8, 0x6b, 0x64, 0x6a, 0xd6, + 0x15, 0x6c, 0xcb, 0x4a, 0x8b, 0x35, 0xdf, 0x25, 0x51, 0x2a, 0xc1, 0x13, 0x53, 0x7c, 0x3, 0x0, 0xe, + 0xb2, 0xa8, 0x47, 0xb7, 0xb9, 0xfe, 0xec, 0x2b, 0x65, 0xee, 0x1, 0x2, 0xc2, 0x32, 0x12, 0x0, 0x8, + 0x75, 0x3d, 0x4a, 0xe1, 0x80, 0xe9, 0x76, 0x33, 0x1f, 0x0, 0x3, 0x2e, 0x0, 0xea}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[6]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[0]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 0, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11641); - EXPECT_EQ(count, 6); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(packet_id, 28726); + EXPECT_EQ(count, 0); } -// UnsubscribeResponse 5146 [PropReasonString -// "\214\192\142\182(b@\215w\222t\145\195\EM\141Er\161\US\255\136m\US\133'\219\164j ",PropCorrelationData -// "\200\USu_+<\195\139\163\156q\EOT\158\\\149\223\SYN\184\221\GS\f\202~\179A\187_"] -// [UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubSuccess,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubSuccess,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted] -TEST(UnsubACK5QCTest, Decode20) { - uint8_t pkt[] = {0xb0, 0x5a, 0x14, 0x1a, 0x3e, 0x1f, 0x0, 0x1d, 0xd6, 0xc0, 0x8e, 0xb6, 0x28, 0x62, 0x40, 0xd7, - 0x77, 0xde, 0x74, 0x91, 0xc3, 0x19, 0x8d, 0x45, 0x72, 0xa1, 0x1f, 0xff, 0x88, 0x6d, 0x1f, 0x85, - 0x27, 0xdb, 0xa4, 0x6a, 0x20, 0x9, 0x0, 0x1b, 0xc8, 0x1f, 0x75, 0x5f, 0x2b, 0x3c, 0xc3, 0x8b, - 0xa3, 0x9c, 0x71, 0x4, 0x9e, 0x5c, 0x95, 0xdf, 0x16, 0xb8, 0xdd, 0x1d, 0xc, 0xca, 0x7e, 0xb3, - 0x41, 0xbb, 0x5f, 0x83, 0x87, 0x87, 0x80, 0x87, 0x0, 0x87, 0x91, 0x11, 0x91, 0x87, 0x91, 0x11, - 0x0, 0x0, 0x91, 0x0, 0x8f, 0x8f, 0x87, 0x0, 0x83, 0x83, 0x11, 0x11}; +// UnsubscribeResponse 21422 [PropWillDelayInterval 28679,PropMaximumQoS 184,PropMessageExpiryInterval +// 20839,PropWillDelayInterval 2905,PropUserProperty +// "\130\251I\242a\199\153\244\181\SUB\217\181}\ETX\184\NUL\188P,\214\212]@\DC4\226\242" +// "X\201\242\201\DC4\178\&0/\NAK\STX\157V\ENQw\STX`?~\SOc\138\232\155|t\200",PropSubscriptionIdentifierAvailable +// 43,PropSubscriptionIdentifier 7,PropAssignedClientIdentifier "\156\STX\133\189\212\STX>",PropMessageExpiryInterval +// 21485,PropAuthenticationData "\158\128\239\142\171\226\228N\251\188\a\147!\203b\193",PropSharedSubscriptionAvailable +// 130,PropAuthenticationData "?\245\193\182\249D$\EM\197\154\193\DLE(",PropResponseTopic +// "r\176\135)~<\ENQ\213\237nfqi\SOH\161\168\235\186\182n\156\146H\250\143\248\212\&8",PropWillDelayInterval +// 21449,PropAuthenticationMethod +// "H\217\134\187\136\GS\136\200\ESC\181\NAK\200+J\212\&6\138\219\173\b\ACK_y#",PropCorrelationData +// "\174f\205\184j*gH",PropRequestProblemInformation 119,PropAssignedClientIdentifier +// "\186\174Z]\144d\252ZHR\ESC\172\218I\137\181\NAK\252ij2\177\SOHq\EOT{8\RSM",PropServerReference +// "7\248)\155\156\FSb\225\&6",PropMaximumPacketSize 3876,PropMessageExpiryInterval 2379] +// [UnsubTopicFilterInvalid,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubNotAuthorized] +TEST(UnsubACK5QCTest, Decode19) { + uint8_t pkt[] = { + 0xb0, 0x9f, 0x2, 0x53, 0xae, 0x84, 0x2, 0x18, 0x0, 0x0, 0x70, 0x7, 0x24, 0xb8, 0x2, 0x0, 0x0, 0x51, 0x67, + 0x18, 0x0, 0x0, 0xb, 0x59, 0x26, 0x0, 0x1a, 0x82, 0xfb, 0x49, 0xf2, 0x61, 0xc7, 0x99, 0xf4, 0xb5, 0x1a, 0xd9, + 0xb5, 0x7d, 0x3, 0xb8, 0x0, 0xbc, 0x50, 0x2c, 0xd6, 0xd4, 0x5d, 0x40, 0x14, 0xe2, 0xf2, 0x0, 0x1a, 0x58, 0xc9, + 0xf2, 0xc9, 0x14, 0xb2, 0x30, 0x2f, 0x15, 0x2, 0x9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x9c, 0x1c, 0x62, 0xe1, 0x36, 0x27, 0x0, 0x0, 0xf, 0x24, 0x2, 0x0, 0x0, 0x9, + 0x4b, 0x8f, 0x0, 0x91, 0x80, 0x83, 0x8f, 0x83, 0x80, 0x11, 0x83, 0x11, 0x91, 0x80, 0x11, 0x80, 0x91, 0x87, 0x91, + 0x87, 0x0, 0x91, 0x11, 0x87}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[25]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 25, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[23]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 23, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 5146); - EXPECT_EQ(count, 25); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(packet_id, 21422); + EXPECT_EQ(count, 23); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_UNSPECIFIED_ERROR); EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NOT_AUTHORIZED); } -// UnsubscribeResponse 19495 [PropReceiveMaximum 12701,PropAuthenticationData "\DC24\224\169"] -// [UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubSuccess,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubSuccess,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubSuccess,UnsubUnspecifiedError,UnsubPacketIdentifierInUse] -TEST(UnsubACK5QCTest, Decode21) { - uint8_t pkt[] = {0xb0, 0x28, 0x4c, 0x27, 0xa, 0x21, 0x31, 0x9d, 0x16, 0x0, 0x4, 0x12, 0x34, 0xe0, - 0xa9, 0x91, 0x8f, 0x83, 0x0, 0x0, 0x11, 0x80, 0x8f, 0x91, 0x0, 0x8f, 0x0, 0x0, - 0x11, 0x87, 0x11, 0x91, 0x91, 0x83, 0x80, 0x11, 0x11, 0x11, 0x0, 0x0, 0x80, 0x91}; +// UnsubscribeResponse 31508 [PropUserProperty "\247{\181C\171{h\188|84\204D\US\165\229#\173\r\230a" +// "0\146\157\236y\NUL\252\203\167_",PropServerReference +// "e\EM\150\222\196\166k\fj\250B\US\245I7\181\b\ETBa\128\239<05\b\163S\140u\\"] +// [UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubSuccess,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNotAuthorized] +TEST(UnsubACK5QCTest, Decode20) { + uint8_t pkt[] = {0xb0, 0x66, 0x7b, 0x14, 0x45, 0x26, 0x0, 0x15, 0xf7, 0x7b, 0xb5, 0x43, 0xab, 0x7b, 0x68, + 0xbc, 0x7c, 0x38, 0x34, 0xcc, 0x44, 0x1f, 0xa5, 0xe5, 0x23, 0xad, 0xd, 0xe6, 0x61, 0x0, + 0xa, 0x30, 0x92, 0x9d, 0xec, 0x79, 0x0, 0xfc, 0xcb, 0xa7, 0x5f, 0x1c, 0x0, 0x1e, 0x65, + 0x19, 0x96, 0xde, 0xc4, 0xa6, 0x6b, 0xc, 0x6a, 0xfa, 0x42, 0x1f, 0xf5, 0x49, 0x37, 0xb5, + 0x8, 0x17, 0x61, 0x80, 0xef, 0x3c, 0x30, 0x35, 0x8, 0xa3, 0x53, 0x8c, 0x75, 0x5c, 0x83, + 0x83, 0x11, 0x91, 0x0, 0x8f, 0x8f, 0x83, 0x91, 0x0, 0x0, 0x87, 0x8f, 0x83, 0x11, 0x91, + 0x87, 0x87, 0x87, 0x80, 0x80, 0x91, 0x0, 0x87, 0x91, 0x80, 0x0, 0x91, 0x8f, 0x87}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[27]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 27, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[30]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 30, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19495); - EXPECT_EQ(count, 27); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(packet_id, 31508); + EXPECT_EQ(count, 30); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[9], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[19], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[25], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[26], LWMQTT_UNSUB_PACKET_ID_IN_USE); -} - -// UnsubscribeResponse 2650 [PropMaximumPacketSize 23567,PropReceiveMaximum 460,PropReceiveMaximum 9781,PropReasonString -// "\223\167\182\215\NUL\210\201\211\218\131",PropServerKeepAlive 9721] -// [UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse] -TEST(UnsubACK5QCTest, Decode22) { - uint8_t pkt[] = {0xb0, 0x2b, 0xa, 0x5a, 0x1b, 0x27, 0x0, 0x0, 0x5c, 0xf, 0x21, 0x1, 0xcc, 0x21, 0x26, - 0x35, 0x1f, 0x0, 0xa, 0xdf, 0xa7, 0xb6, 0xd7, 0x0, 0xd2, 0xc9, 0xd3, 0xda, 0x83, 0x13, - 0x25, 0xf9, 0x83, 0x80, 0x83, 0x8f, 0x80, 0x80, 0x0, 0x11, 0x8f, 0x87, 0x83, 0x11, 0x91}; + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[27], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[28], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[29], LWMQTT_UNSUB_NOT_AUTHORIZED); +} + +// UnsubscribeResponse 6014 [PropRequestProblemInformation 137,PropMaximumQoS 229,PropAssignedClientIdentifier +// "\SO_\160%\201\225{\192",PropPayloadFormatIndicator 244,PropTopicAliasMaximum +// 11438,PropSubscriptionIdentifierAvailable 110,PropResponseTopic "\DLE\155A_\FSF\160\200%\212\212",PropReceiveMaximum +// 18556,PropResponseTopic "9\178\244\NUL\153\129\206\177\128:\253\195",PropRequestProblemInformation +// 31,PropSharedSubscriptionAvailable 65,PropMessageExpiryInterval 25908,PropSharedSubscriptionAvailable +// 157,PropSharedSubscriptionAvailable 160,PropSessionExpiryInterval 12195,PropTopicAliasMaximum +// 11688,PropTopicAliasMaximum 6895,PropWildcardSubscriptionAvailable 56,PropSubscriptionIdentifier 27] +// [UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNoSubscriptionExisted] +TEST(UnsubACK5QCTest, Decode21) { + uint8_t pkt[] = {0xb0, 0x5b, 0x17, 0x7e, 0x52, 0x17, 0x89, 0x24, 0xe5, 0x12, 0x0, 0x8, 0xe, 0x5f, 0xa0, 0x25, + 0xc9, 0xe1, 0x7b, 0xc0, 0x1, 0xf4, 0x22, 0x2c, 0xae, 0x29, 0x6e, 0x8, 0x0, 0xb, 0x10, 0x9b, + 0x41, 0x5f, 0x1c, 0x46, 0xa0, 0xc8, 0x25, 0xd4, 0xd4, 0x21, 0x48, 0x7c, 0x8, 0x0, 0xc, 0x39, + 0xb2, 0xf4, 0x0, 0x99, 0x81, 0xce, 0xb1, 0x80, 0x3a, 0xfd, 0xc3, 0x17, 0x1f, 0x2a, 0x41, 0x2, + 0x0, 0x0, 0x65, 0x34, 0x2a, 0x9d, 0x2a, 0xa0, 0x11, 0x0, 0x0, 0x2f, 0xa3, 0x22, 0x2d, 0xa8, + 0x22, 0x1a, 0xef, 0x28, 0x38, 0xb, 0x1b, 0x8f, 0x83, 0x11, 0x8f, 0x0, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[13]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 13, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[6]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 2650); - EXPECT_EQ(count, 13); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(packet_id, 6014); + EXPECT_EQ(count, 6); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); } -// UnsubscribeResponse 4720 [PropReasonString -// "\130\242\f\SYN\158?\183\229\174\203B\213\\\249\DC3I\134\138\252\129\SO\231\199.",PropReasonString -// "\187\196\213\ESC\128\213t\145OU/",PropServerReference "",PropReasonString -// "\DEL?z+\\\197\200\219\193\152!'\174\137",PropPayloadFormatIndicator 48,PropUserProperty "\202)+\188\172\192\223C" -// "\139\178H!\SUB\253\&8\190!\135]\CAN",PropSharedSubscriptionAvailable 34,PropMaximumPacketSize -// 14585,PropRequestProblemInformation 61,PropAssignedClientIdentifier -// "Xi\247yG\138_v\247-\181",PropRequestProblemInformation 16,PropMaximumPacketSize 13540,PropContentType -// "N\243W[\DEL\181\221H\240#\232",PropAuthenticationMethod -// "\209\131F\129\218\174\131O\220\166\253\238\b\164W(?\189\236\218\v\204M\215\NAKYXo",PropRetainAvailable -// 195,PropReceiveMaximum 20755,PropWildcardSubscriptionAvailable 251,PropUserProperty "\184\EM\148\DC4]\167" -// "",PropAuthenticationData "\175kB\217",PropSubscriptionIdentifierAvailable 154,PropWillDelayInterval -// 23743,PropMaximumQoS 106,PropSubscriptionIdentifier 25,PropSessionExpiryInterval 7290] -// [UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubSuccess] -TEST(UnsubACK5QCTest, Decode23) { - uint8_t pkt[] = { - 0xb0, 0xdb, 0x1, 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- 0x4, 0xaf, 0x6b, 0x42, 0xd9, 0x29, 0x9a, 0x18, 0x0, 0x0, 0x5c, 0xbf, 0x24, 0x6a, 0xb, 0x19, 0x11, 0x0, 0x0, - 0x1c, 0x7a, 0x8f, 0x11, 0x8f, 0x80, 0x8f, 0x0, 0x87, 0x87, 0x80, 0x8f, 0x0}; +// UnsubscribeResponse 21904 [PropMaximumPacketSize 4466,PropMaximumQoS 44,PropWildcardSubscriptionAvailable +// 29,PropMaximumPacketSize 21462,PropSessionExpiryInterval 3915,PropSessionExpiryInterval +// 8258,PropSharedSubscriptionAvailable 173,PropAuthenticationMethod +// "6\230g\170\&4\RS\252}A\140\143\ETB\237O\CAN\158\&4\USO",PropCorrelationData +// "\253\DC3\ETB[\238\132\FSsh\130G\131L7\243Y\174C\170",PropTopicAlias 24650,PropPayloadFormatIndicator +// 80,PropAuthenticationMethod "\187\132\&8\139\US\ACKaBQ\230\179J",PropRetainAvailable +// 64,PropSubscriptionIdentifierAvailable 70,PropResponseTopic +// "\CAN\203B\t\210\238\228\194'\216\NAK\251}\176\205\196",PropResponseInformation +// "\188\245\188@\207\206\237O4\197",PropRetainAvailable 182,PropSubscriptionIdentifier +// 17,PropWildcardSubscriptionAvailable 32,PropWildcardSubscriptionAvailable 207,PropWillDelayInterval 30383] +// [UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode22) { + uint8_t pkt[] = {0xb0, 0x9a, 0x1, 0x55, 0x90, 0x8b, 0x1, 0x27, 0x0, 0x0, 0x11, 0x72, 0x24, 0x2c, 0x28, 0x1d, + 0x27, 0x0, 0x0, 0x53, 0xd6, 0x11, 0x0, 0x0, 0xf, 0x4b, 0x11, 0x0, 0x0, 0x20, 0x42, 0x2a, + 0xad, 0x15, 0x0, 0x13, 0x36, 0xe6, 0x67, 0xaa, 0x34, 0x1e, 0xfc, 0x7d, 0x41, 0x8c, 0x8f, 0x17, + 0xed, 0x4f, 0x18, 0x9e, 0x34, 0x1f, 0x4f, 0x9, 0x0, 0x13, 0xfd, 0x13, 0x17, 0x5b, 0xee, 0x84, + 0x1c, 0x73, 0x68, 0x82, 0x47, 0x83, 0x4c, 0x37, 0xf3, 0x59, 0xae, 0x43, 0xaa, 0x23, 0x60, 0x4a, + 0x1, 0x50, 0x15, 0x0, 0xc, 0xbb, 0x84, 0x38, 0x8b, 0x1f, 0x6, 0x61, 0x42, 0x51, 0xe6, 0xb3, + 0x4a, 0x25, 0x40, 0x29, 0x46, 0x8, 0x0, 0x10, 0x18, 0xcb, 0x42, 0x9, 0xd2, 0xee, 0xe4, 0xc2, + 0x27, 0xd8, 0x15, 0xfb, 0x7d, 0xb0, 0xcd, 0xc4, 0x1a, 0x0, 0xa, 0xbc, 0xf5, 0xbc, 0x40, 0xcf, + 0xce, 0xed, 0x4f, 0x34, 0xc5, 0x25, 0xb6, 0xb, 0x11, 0x28, 0x20, 0x28, 0xcf, 0x18, 0x0, 0x0, + 0x76, 0xaf, 0x8f, 0x11, 0x8f, 0x91, 0x87, 0x83, 0x80, 0x11, 0x11, 0x91, 0x0}; uint16_t packet_id; int count; lwmqtt_unsubscribe_status_t statuses[11]; lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4720); + EXPECT_EQ(packet_id, 21904); EXPECT_EQ(count, 11); EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); } -// UnsubscribeResponse 7392 [PropContentType -// "#\204w\172\159\245\142\174]\141\136\249\183-\SYNO\223\131\202",PropSubscriptionIdentifierAvailable -// 98,PropMessageExpiryInterval 23148,PropAssignedClientIdentifier -// "\252\168\233}\191\225\SI\199\td\207:\n\\\141\228p\b9\187\SUB\195\176\158\243\197l\202\ENQ\244",PropServerKeepAlive -// 18028,PropSubscriptionIdentifierAvailable 242,PropRequestResponseInformation 130] -// [UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubSuccess,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubSuccess,UnsubImplementationSpecificError] -TEST(UnsubACK5QCTest, Decode24) { - uint8_t pkt[] = {0xb0, 0x63, 0x1c, 0xe0, 0x45, 0x3, 0x0, 0x13, 0x23, 0xcc, 0x77, 0xac, 0x9f, 0xf5, 0x8e, 0xae, 0x5d, - 0x8d, 0x88, 0xf9, 0xb7, 0x2d, 0x16, 0x4f, 0xdf, 0x83, 0xca, 0x29, 0x62, 0x2, 0x0, 0x0, 0x5a, 0x6c, - 0x12, 0x0, 0x1e, 0xfc, 0xa8, 0xe9, 0x7d, 0xbf, 0xe1, 0xf, 0xc7, 0x9, 0x64, 0xcf, 0x3a, 0xa, 0x5c, - 0x8d, 0xe4, 0x70, 0x8, 0x39, 0xbb, 0x1a, 0xc3, 0xb0, 0x9e, 0xf3, 0xc5, 0x6c, 0xca, 0x5, 0xf4, 0x13, - 0x46, 0x6c, 0x29, 0xf2, 0x19, 0x82, 0x80, 0x8f, 0x8f, 0x11, 0x87, 0x11, 0x11, 0x87, 0x87, 0x11, 0x80, - 0x83, 0x80, 0x83, 0x8f, 0x0, 0x0, 0x87, 0x91, 0x0, 0x8f, 0x80, 0x83, 0x80, 0x83, 0x0, 0x83}; +// UnsubscribeResponse 4583 [PropSubscriptionIdentifierAvailable 111,PropResponseInformation +// "px\169\170\US\164\251j\US\152\EM\221T:/\ENQ ",PropContentType +// "Od\214%w\135\&3q\DEL\150",PropRequestProblemInformation 163,PropResponseInformation +// "*\222\200\142\244\236q\140X5\154'\251a.Vq\185\ETX\204=\178\178",PropReasonString +// "\200\151\ETB\201'\196&\220\SOH\149/\138vs\246\SUB\238\191c\EM",PropResponseTopic +// "<\168f\134\171S\FS\196X\161\254KiQN",PropRequestResponseInformation 187,PropWildcardSubscriptionAvailable +// 201,PropTopicAlias 546,PropMessageExpiryInterval 2620,PropSharedSubscriptionAvailable 194,PropTopicAliasMaximum +// 32444,PropResponseTopic "\128*\135\226\143\SYN\252",PropRetainAvailable 13,PropUserProperty "\f\137\155Q\DC4\a" +// "t\249\231r\"\142\158\253\195\159",PropReasonString "\233\175",PropSharedSubscriptionAvailable +// 164,PropMessageExpiryInterval 21618,PropMessageExpiryInterval 28659,PropRequestProblemInformation +// 160,PropSharedSubscriptionAvailable 111,PropRequestResponseInformation 254,PropRetainAvailable +// 103,PropMessageExpiryInterval 11371,PropMessageExpiryInterval 17128,PropReasonString +// "\tp\FS!A\188\230",PropMessageExpiryInterval 30871,PropSessionExpiryInterval 15784] +// [UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse] +TEST(UnsubACK5QCTest, Decode23) { + uint8_t pkt[] = { + 0xb0, 0xdc, 0x1, 0x11, 0xe7, 0xd1, 0x1, 0x29, 0x6f, 0x1a, 0x0, 0x11, 0x70, 0x78, 0xa9, 0xaa, 0x1f, 0xa4, 0xfb, + 0x6a, 0x1f, 0x98, 0x19, 0xdd, 0x54, 0x3a, 0x2f, 0x5, 0x20, 0x3, 0x0, 0xa, 0x4f, 0x64, 0xd6, 0x25, 0x77, 0x87, + 0x33, 0x71, 0x7f, 0x96, 0x17, 0xa3, 0x1a, 0x0, 0x17, 0x2a, 0xde, 0xc8, 0x8e, 0xf4, 0xec, 0x71, 0x8c, 0x58, 0x35, + 0x9a, 0x27, 0xfb, 0x61, 0x2e, 0x56, 0x71, 0xb9, 0x3, 0xcc, 0x3d, 0xb2, 0xb2, 0x1f, 0x0, 0x14, 0xc8, 0x97, 0x17, + 0xc9, 0x27, 0xc4, 0x26, 0xdc, 0x1, 0x95, 0x2f, 0x8a, 0x76, 0x73, 0xf6, 0x1a, 0xee, 0xbf, 0x63, 0x19, 0x8, 0x0, + 0xf, 0x3c, 0xa8, 0x66, 0x86, 0xab, 0x53, 0x1c, 0xc4, 0x58, 0xa1, 0xfe, 0x4b, 0x69, 0x51, 0x4e, 0x19, 0xbb, 0x28, + 0xc9, 0x23, 0x2, 0x22, 0x2, 0x0, 0x0, 0xa, 0x3c, 0x2a, 0xc2, 0x22, 0x7e, 0xbc, 0x8, 0x0, 0x7, 0x80, 0x2a, + 0x87, 0xe2, 0x8f, 0x16, 0xfc, 0x25, 0xd, 0x26, 0x0, 0x6, 0xc, 0x89, 0x9b, 0x51, 0x14, 0x7, 0x0, 0xa, 0x74, + 0xf9, 0xe7, 0x72, 0x22, 0x8e, 0x9e, 0xfd, 0xc3, 0x9f, 0x1f, 0x0, 0x2, 0xe9, 0xaf, 0x2a, 0xa4, 0x2, 0x0, 0x0, + 0x54, 0x72, 0x2, 0x0, 0x0, 0x6f, 0xf3, 0x17, 0xa0, 0x2a, 0x6f, 0x19, 0xfe, 0x25, 0x67, 0x2, 0x0, 0x0, 0x2c, + 0x6b, 0x2, 0x0, 0x0, 0x42, 0xe8, 0x1f, 0x0, 0x7, 0x9, 0x70, 0x1c, 0x21, 0x41, 0xbc, 0xe6, 0x2, 0x0, 0x0, + 0x78, 0x97, 0x11, 0x0, 0x0, 0x3d, 0xa8, 0x8f, 0x83, 0x8f, 0x80, 0x83, 0x8f, 0x91}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[27]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 27, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[7]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7392); - EXPECT_EQ(count, 27); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(packet_id, 4583); + EXPECT_EQ(count, 7); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[25], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[26], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); } -// UnsubscribeResponse 18418 [PropPayloadFormatIndicator 73,PropSubscriptionIdentifier 27,PropMessageExpiryInterval -// 17696,PropPayloadFormatIndicator 158,PropRequestProblemInformation 251] -// [UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubSuccess,UnsubSuccess] -TEST(UnsubACK5QCTest, Decode25) { - uint8_t pkt[] = {0xb0, 0x23, 0x47, 0xf2, 0xd, 0x1, 0x49, 0xb, 0x1b, 0x2, 0x0, 0x0, 0x45, - 0x20, 0x1, 0x9e, 0x17, 0xfb, 0x11, 0x87, 0x83, 0x91, 0x11, 0x8f, 0x80, 0x87, - 0x8f, 0x8f, 0x87, 0x80, 0x83, 0x8f, 0x11, 0x80, 0x80, 0x0, 0x0}; +// UnsubscribeResponse 32708 [PropWildcardSubscriptionAvailable 111,PropUserProperty +// "\185\176\218\219]\209\190\&7\199\173\192\201\205\155\STX~\GS\149*\142\169\233\203\&8x" +// "\167F\201\189\159",PropAssignedClientIdentifier "\EM\251\155H\196|\152tN%\157h\CAN\FSC",PropMessageExpiryInterval +// 18180,PropCorrelationData "\206L\219\r\rrp\200:\SOH\153X\207\223\159\DC4\130",PropRequestProblemInformation +// 220,PropSubscriptionIdentifier 18,PropResponseInformation +// "wR\194\203\238\155\141\150Y\142\f\231\195\&5\186\234R&\132\ENQeh\186\253",PropResponseTopic +// "8e\180\131k",PropMessageExpiryInterval 20517,PropMessageExpiryInterval 7199,PropSubscriptionIdentifierAvailable +// 163,PropTopicAlias 15265,PropCorrelationData "2W\169ur\217IA\243\241\NULTW\188>\152\f",PropAssignedClientIdentifier +// ":\227\DC3\az\224\150R\200\157\232\251\189#\f\220r!\208\151Kl\165\f\226\202",PropServerKeepAlive +// 25586,PropContentType "",PropReceiveMaximum 26711,PropAuthenticationMethod +// "C+\205\245\&0,\214\188\&7\171\f02\137\174\255\NUL\169\196\bC",PropUserProperty +// "\238;\ESC\255\174=lTgYVu1\SYNb\171\235\202\140\&0" "\214g\134\187#@\150",PropResponseInformation +// "\233\211\208\156\FS0\FSlD",PropWillDelayInterval 29769,PropCorrelationData +// "\213\211`\tF\136\144\156/\251b\SYN\206\DEL\210\FS",PropTopicAliasMaximum 8182] +// [UnsubTopicFilterInvalid,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode24) { + uint8_t pkt[] = { + 0xb0, 0xa5, 0x2, 0x7f, 0xc4, 0x9f, 0x2, 0x28, 0x6f, 0x26, 0x0, 0x19, 0xb9, 0xb0, 0xda, 0xdb, 0x5d, 0xd1, 0xbe, + 0x37, 0xc7, 0xad, 0xc0, 0xc9, 0xcd, 0x9b, 0x2, 0x7e, 0x1d, 0x95, 0x2a, 0x8e, 0xa9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 0x43, 0x26, 0x0, 0x14, 0xee, 0x3b, + 0x1b, 0xff, 0xae, 0x3d, 0x6c, 0x54, 0x67, 0x59, 0x56, 0x75, 0x31, 0x16, 0x62, 0xab, 0xeb, 0xca, 0x8c, 0x30, 0x0, + 0x7, 0xd6, 0x67, 0x86, 0xbb, 0x23, 0x40, 0x96, 0x1a, 0x0, 0x9, 0xe9, 0xd3, 0xd0, 0x9c, 0x1c, 0x30, 0x1c, 0x6c, + 0x44, 0x18, 0x0, 0x0, 0x74, 0x49, 0x9, 0x0, 0x10, 0xd5, 0xd3, 0x60, 0x9, 0x46, 0x88, 0x90, 0x9c, 0x2f, 0xfb, + 0x62, 0x16, 0xce, 0x7f, 0xd2, 0x1c, 0x22, 0x1f, 0xf6, 0x8f, 0x0}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[19]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 19, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[2]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18418); - EXPECT_EQ(count, 19); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(packet_id, 32708); + EXPECT_EQ(count, 2); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); } -// UnsubscribeResponse 9706 [PropMaximumQoS 251,PropServerKeepAlive 26315,PropSharedSubscriptionAvailable -// 253,PropTopicAliasMaximum 9589,PropResponseInformation "*",PropUserProperty -// "\170\252A\186\171\246)\178\217\236\136\250x\153T\NAK\211W\CAN\214\ACK\208\132\164\&3\175." -// "6\192\t\182\242\160\FSJN",PropServerKeepAlive 1102,PropMaximumPacketSize 12716,PropWildcardSubscriptionAvailable -// 93,PropRequestResponseInformation 111,PropTopicAliasMaximum 7469,PropServerReference -// "}\189Q\204\235\166\&5",PropResponseTopic "\236\DC3\DLE\158Ri\185\176\NUL\136d\139` -// p\171\ENQ",PropSubscriptionIdentifierAvailable 133] -// [UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubSuccess,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubSuccess,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubSuccess,UnsubUnspecifiedError,UnsubSuccess] -TEST(UnsubACK5QCTest, Decode26) { - uint8_t pkt[] = {0xb0, 0x80, 0x1, 0x25, 0xea, 0x66, 0x24, 0xfb, 0x13, 0x66, 0xcb, 0x2a, 0xfd, 0x22, 0x25, 0x75, 0x1a, - 0x0, 0x1, 0x2a, 0x26, 0x0, 0x1b, 0xaa, 0xfc, 0x41, 0xba, 0xab, 0xf6, 0x29, 0xb2, 0xd9, 0xec, 0x88, - 0xfa, 0x78, 0x99, 0x54, 0x15, 0xd3, 0x57, 0x18, 0xd6, 0x6, 0xd0, 0x84, 0xa4, 0x33, 0xaf, 0x2e, 0x0, - 0x9, 0x36, 0xc0, 0x9, 0xb6, 0xf2, 0xa0, 0x1c, 0x4a, 0x4e, 0x13, 0x4, 0x4e, 0x27, 0x0, 0x0, 0x31, - 0xac, 0x28, 0x5d, 0x19, 0x6f, 0x22, 0x1d, 0x2d, 0x1c, 0x0, 0x7, 0x7d, 0xbd, 0x51, 0xcc, 0xeb, 0xa6, - 0x35, 0x8, 0x0, 0x11, 0xec, 0x13, 0x10, 0x9e, 0x52, 0x69, 0xb9, 0xb0, 0x0, 0x88, 0x64, 0x8b, 0x60, - 0x20, 0x70, 0xab, 0x5, 0x29, 0x85, 0x80, 0x8f, 0x83, 0x8f, 0x83, 0x0, 0x8f, 0x83, 0x91, 0x80, 0x83, - 0x8f, 0x87, 0x0, 0x83, 0x87, 0x11, 0x80, 0x8f, 0x87, 0x0, 0x80, 0x0}; +// UnsubscribeResponse 21778 [] +// [UnsubUnspecifiedError,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized] +TEST(UnsubACK5QCTest, Decode25) { + uint8_t pkt[] = {0xb0, 0x16, 0x55, 0x12, 0x0, 0x80, 0x0, 0x91, 0x11, 0x80, 0x8f, 0x0, + 0x91, 0x80, 0x80, 0x91, 0x8f, 0x11, 0x11, 0x91, 0x11, 0x91, 0x0, 0x87}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[23]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 23, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[19]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 19, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9706); - EXPECT_EQ(count, 23); + EXPECT_EQ(packet_id, 21778); + EXPECT_EQ(count, 19); EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); } -// UnsubscribeResponse 5357 [PropServerReference "\206\234\191\NAK: X\146\171\"\144\186M\137\&4\177",PropServerReference -// "\169\149\216\&6\137\215a\221!\132\DC4\240\CAN\DC2\150\138\183\133\169\170\170\218\GS\n\RS\178t\165",PropResponseInformation -// "\220\\@\247\235\229\202\154q\165?",PropCorrelationData -// "5\255\155\163o\236\228\203\143\252\178\&9\129\DC2\172\&1",PropMaximumQoS 160,PropAssignedClientIdentifier -// ":'\n\158{\194\135",PropSubscriptionIdentifierAvailable 169,PropServerReference -// "j\148\240\DEL*\ACK\240\189\219]p<\STX\ETXk2-XJ\145\&1\245",PropCorrelationData -// "B\FS\249\247\176\STXS\250\155:%\DC2\\\t\252_\161",PropServerKeepAlive 9127] -// [UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized,UnsubSuccess,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubTopicFilterInvalid] -TEST(UnsubACK5QCTest, Decode27) { - uint8_t pkt[] = {0xb0, 0xb1, 0x1, 0x14, 0xed, 0x91, 0x1, 0x1c, 0x0, 0x10, 0xce, 0xea, 0xbf, 0x15, 0x3a, 0x20, 0x58, - 0x92, 0xab, 0x22, 0x90, 0xba, 0x4d, 0x89, 0x34, 0xb1, 0x1c, 0x0, 0x1c, 0xa9, 0x95, 0xd8, 0x36, 0x89, - 0xd7, 0x61, 0xdd, 0x21, 0x84, 0x14, 0xf0, 0x18, 0x12, 0x96, 0x8a, 0xb7, 0x85, 0xa9, 0xaa, 0xaa, 0xda, - 0x1d, 0xa, 0x1e, 0xb2, 0x74, 0xa5, 0x1a, 0x0, 0xb, 0xdc, 0x5c, 0x40, 0xf7, 0xeb, 0xe5, 0xca, 0x9a, - 0x71, 0xa5, 0x3f, 0x9, 0x0, 0x10, 0x35, 0xff, 0x9b, 0xa3, 0x6f, 0xec, 0xe4, 0xcb, 0x8f, 0xfc, 0xb2, - 0x39, 0x81, 0x12, 0xac, 0x31, 0x24, 0xa0, 0x12, 0x0, 0x7, 0x3a, 0x27, 0xa, 0x9e, 0x7b, 0xc2, 0x87, - 0x29, 0xa9, 0x1c, 0x0, 0x16, 0x6a, 0x94, 0xf0, 0x7f, 0x2a, 0x6, 0xf0, 0xbd, 0xdb, 0x5d, 0x70, 0x3c, - 0x2, 0x3, 0x6b, 0x32, 0x2d, 0x58, 0x4a, 0x91, 0x31, 0xf5, 0x9, 0x0, 0x11, 0x42, 0x1c, 0xf9, 0xf7, - 0xb0, 0x2, 0x53, 0xfa, 0x9b, 0x3a, 0x25, 0x12, 0x5c, 0x9, 0xfc, 0x5f, 0xa1, 0x13, 0x23, 0xa7, 0x80, - 0x91, 0x83, 0x87, 0x91, 0x80, 0x91, 0x87, 0x0, 0x91, 0x11, 0x83, 0x11, 0x87, 0x83, 0x80, 0x91, 0x0, - 0x87, 0x0, 0x0, 0x91, 0x91, 0x80, 0x80, 0x91, 0x87, 0x8f}; +// UnsubscribeResponse 6986 [PropRequestProblemInformation 189,PropReceiveMaximum 4564,PropReasonString +// "\200Q\147\252D\149\227\180Z(_\182\DC4\162\143\134\DC1\247\RS2\241\186",PropWildcardSubscriptionAvailable +// 197,PropTopicAlias 26196,PropMaximumPacketSize 29545,PropSessionExpiryInterval 12864,PropMaximumPacketSize +// 12547,PropRequestResponseInformation 3,PropRequestResponseInformation 79,PropSharedSubscriptionAvailable +// 120,PropSessionExpiryInterval 997,PropSubscriptionIdentifierAvailable 157,PropContentType +// "Y\164\237\162\134\242B\244I\189\130,@R"] +// [UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubSuccess,UnsubNotAuthorized,UnsubNotAuthorized,UnsubPacketIdentifierInUse] +TEST(UnsubACK5QCTest, Decode26) { + uint8_t pkt[] = {0xb0, 0x6f, 0x1b, 0x4a, 0x50, 0x17, 0xbd, 0x21, 0x11, 0xd4, 0x1f, 0x0, 0x16, 0xc8, 0x51, 0x93, 0xfc, + 0x44, 0x95, 0xe3, 0xb4, 0x5a, 0x28, 0x5f, 0xb6, 0x14, 0xa2, 0x8f, 0x86, 0x11, 0xf7, 0x1e, 0x32, 0xf1, + 0xba, 0x28, 0xc5, 0x23, 0x66, 0x54, 0x27, 0x0, 0x0, 0x73, 0x69, 0x11, 0x0, 0x0, 0x32, 0x40, 0x27, + 0x0, 0x0, 0x31, 0x3, 0x19, 0x3, 0x19, 0x4f, 0x2a, 0x78, 0x11, 0x0, 0x0, 0x3, 0xe5, 0x29, 0x9d, + 0x3, 0x0, 0xe, 0x59, 0xa4, 0xed, 0xa2, 0x86, 0xf2, 0x42, 0xf4, 0x49, 0xbd, 0x82, 0x2c, 0x40, 0x52, + 0x83, 0x87, 0x80, 0x91, 0x0, 0x80, 0x83, 0x8f, 0x83, 0x8f, 0x8f, 0x83, 0x11, 0x80, 0x80, 0x87, 0x80, + 0x80, 0x8f, 0x11, 0x11, 0x80, 0x87, 0x83, 0x0, 0x87, 0x87, 0x91}; uint16_t packet_id; int count; lwmqtt_unsubscribe_status_t statuses[28]; lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 28, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 5357); + EXPECT_EQ(packet_id, 6986); EXPECT_EQ(count, 28); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[27], LWMQTT_UNSUB_PACKET_ID_IN_USE); +} + +// UnsubscribeResponse 24965 [PropMessageExpiryInterval 29871,PropSubscriptionIdentifierAvailable +// 194,PropCorrelationData +// "u\\\213F=\213\184\153\198\244?0\RSD!KqF\STX\234\FS\190\205\141\223\169\199\162",PropRetainAvailable +// 13,PropTopicAlias 15476,PropSubscriptionIdentifierAvailable 222,PropTopicAliasMaximum 1264,PropResponseTopic +// "\ETX\142l",PropMaximumQoS 47,PropAssignedClientIdentifier +// "\239\156\192\248\234\145B:,G4\159",PropMessageExpiryInterval 21251,PropRequestProblemInformation 48,PropReasonString +// "T\165\196\b\147\229K(\253\248\STX\178\STX\167n\ENQ(\148\253\246d\175&",PropAuthenticationData "",PropResponseTopic +// "}",PropContentType "\b\157\&4\213(P3\232g\253`\139Y\131\168 \168\149M\151\192x\DEL\236\185\191X",PropReceiveMaximum +// 20584,PropPayloadFormatIndicator 168,PropMaximumPacketSize 272,PropAssignedClientIdentifier +// "\218\235",PropAuthenticationData "\163\241\200L\232\184c\ESC\152\FS\DC4b\224\&78L\v8\152\166m\169\226C\210rT\223"] +// [UnsubNotAuthorized,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode27) { + uint8_t pkt[] = {0xb0, 0xd8, 0x1, 0x61, 0x85, 0xbb, 0x1, 0x2, 0x0, 0x0, 0x74, 0xaf, 0x29, 0xc2, 0x9, 0x0, 0x1c, + 0x75, 0x5c, 0xd5, 0x46, 0x3d, 0xd5, 0xb8, 0x99, 0xc6, 0xf4, 0x3f, 0x30, 0x1e, 0x44, 0x21, 0x4b, 0x71, + 0x46, 0x2, 0xea, 0x1c, 0xbe, 0xcd, 0x8d, 0xdf, 0xa9, 0xc7, 0xa2, 0x25, 0xd, 0x23, 0x3c, 0x74, 0x29, + 0xde, 0x22, 0x4, 0xf0, 0x8, 0x0, 0x3, 0x3, 0x8e, 0x6c, 0x24, 0x2f, 0x12, 0x0, 0xc, 0xef, 0x9c, + 0xc0, 0xf8, 0xea, 0x91, 0x42, 0x3a, 0x2c, 0x47, 0x34, 0x9f, 0x2, 0x0, 0x0, 0x53, 0x3, 0x17, 0x30, + 0x1f, 0x0, 0x17, 0x54, 0xa5, 0xc4, 0x8, 0x93, 0xe5, 0x4b, 0x28, 0xfd, 0xf8, 0x2, 0xb2, 0x2, 0xa7, + 0x6e, 0x5, 0x28, 0x94, 0xfd, 0xf6, 0x64, 0xaf, 0x26, 0x16, 0x0, 0x0, 0x8, 0x0, 0x1, 0x7d, 0x3, + 0x0, 0x1b, 0x8, 0x9d, 0x34, 0xd5, 0x28, 0x50, 0x33, 0xe8, 0x67, 0xfd, 0x60, 0x8b, 0x59, 0x83, 0xa8, + 0x20, 0xa8, 0x95, 0x4d, 0x97, 0xc0, 0x78, 0x7f, 0xec, 0xb9, 0xbf, 0x58, 0x21, 0x50, 0x68, 0x1, 0xa8, + 0x27, 0x0, 0x0, 0x1, 0x10, 0x12, 0x0, 0x2, 0xda, 0xeb, 0x16, 0x0, 0x1c, 0xa3, 0xf1, 0xc8, 0x4c, + 0xe8, 0xb8, 0x63, 0x1b, 0x98, 0x1c, 0x14, 0x62, 0xe0, 0x37, 0x38, 0x4c, 0xb, 0x38, 0x98, 0xa6, 0x6d, + 0xa9, 0xe2, 0x43, 0xd2, 0x72, 0x54, 0xdf, 0x87, 0x87, 0x8f, 0x91, 0x80, 0x87, 0x87, 0x80, 0x83, 0x83, + 0x11, 0x0, 0x8f, 0x87, 0x8f, 0x8f, 0x80, 0x80, 0x8f, 0x87, 0x8f, 0x87, 0x91, 0x8f, 0x0}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[25]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 25, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 24965); + EXPECT_EQ(count, 25); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[22], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[25], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[26], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[27], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); -} - -// UnsubscribeResponse 25609 [PropMessageExpiryInterval 9067,PropResponseTopic "{\128r\NAK\243",PropContentType -// "\188{7\DC1",PropSubscriptionIdentifierAvailable 61,PropTopicAlias 16945,PropSubscriptionIdentifierAvailable -// 187,PropSharedSubscriptionAvailable 206,PropCorrelationData -// "\233//V\237q\181\252\175\v\228\148T-\148,\177\195\198\129\214",PropAuthenticationMethod "\180n\210j",PropMaximumQoS -// 221,PropSubscriptionIdentifierAvailable 160,PropSubscriptionIdentifier 30,PropCorrelationData -// "m\231x\175M^\208\130\203\253\152\204\186\227\161\204\"\218Ybp9z",PropMessageExpiryInterval 1351,PropResponseTopic -// "L\158\139\DC4#J\165\136k\SUB\129\&7t\227o",PropMessageExpiryInterval 6136,PropReceiveMaximum -// 26201,PropServerReference "\252\176\201>2Q\184H\140\231L\b\163B\221",PropRequestProblemInformation 95,PropContentType -// "\254h\216\EM\140=.\213\168\DC3\245\232V\201'{",PropServerKeepAlive 21516,PropMaximumQoS 182,PropMaximumQoS -// 194,PropMessageExpiryInterval 26010,PropServerReference -// "\rI\194\189\CAN\161\170\&8\161;\189(\139K\216/",PropServerKeepAlive 30668,PropCorrelationData -// "l\246h\220\220\&4k\176\173=\SYN\227\193@a\196\207\ACK\ACK\245\226",PropResponseInformation -// "Z\225\245w",PropTopicAlias 5475] -// [UnsubSuccess,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubSuccess,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNotAuthorized,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubSuccess] + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_SUCCESS); +} + +// UnsubscribeResponse 17537 [PropTopicAlias 14320,PropRequestProblemInformation 21,PropAuthenticationMethod +// "a6\250\141\195\&6\154\rU'\157",PropReasonString "Y\RS\140\133\254",PropSharedSubscriptionAvailable +// 2,PropAuthenticationData "z\204\US\204$'C\SOH\SOH\243J;\171\252\220v\EM\189c\204\129\212^c\131\134 +// \SUB\137\SO",PropReceiveMaximum 30316,PropRequestResponseInformation 220,PropMaximumPacketSize +// 30012,PropServerReference +// "\150\&2\174\US\253\138\193\200\228\177\160\240\v\134\220^\179\215\164\217,\DC2\NAK\186\US",PropReceiveMaximum +// 9910,PropSubscriptionIdentifierAvailable 159,PropContentType +// "\219\DC4\199\137\170\191\255\188\245\RS6/0\254g/",PropRequestProblemInformation 175,PropMaximumQoS +// 45,PropResponseInformation +// "\145\195\&0\218\NAKgN\214\194P\149Z_\195\202\231vo2\161\221\200\223p",PropSubscriptionIdentifierAvailable +// 173,PropMaximumQoS 42,PropContentType +// "\168Q\230\245\220\ETX\177\136\211\209\175\156\248\240\245\151bV\137\\",PropPayloadFormatIndicator +// 83,PropSessionExpiryInterval 11017,PropUserProperty "\154\vvf\198\214DD\DEL" +// "\CANN\167\&1\241\247\203\196\174N3\145a(",PropSessionExpiryInterval 2353,PropReasonString "\200\DC1\t\148smt +// e9",PropCorrelationData "\DC2A",PropResponseInformation "\253\DEL;\160QD\234\DLE",PropUserProperty "\252P" +// "\206\179g\170)iw\DLE\219t\r\SUB\225\ACK"] +// [UnsubSuccess,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubNotAuthorized] TEST(UnsubACK5QCTest, Decode28) { uint8_t pkt[] = { - 0xb0, 0x86, 0x2, 0x64, 0x9, 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0x0, + 0x10, 0xdb, 0x14, 0xc7, 0x89, 0xaa, 0xbf, 0xff, 0xbc, 0xf5, 0x1e, 0x36, 0x2f, 0x30, 0xfe, 0x67, 0x2f, 0x17, 0xaf, + 0x24, 0x2d, 0x1a, 0x0, 0x18, 0x91, 0xc3, 0x30, 0xda, 0x15, 0x67, 0x4e, 0xd6, 0xc2, 0x50, 0x95, 0x5a, 0x5f, 0xc3, + 0xca, 0xe7, 0x76, 0x6f, 0x32, 0xa1, 0xdd, 0xc8, 0xdf, 0x70, 0x29, 0xad, 0x24, 0x2a, 0x3, 0x0, 0x14, 0xa8, 0x51, + 0xe6, 0xf5, 0xdc, 0x3, 0xb1, 0x88, 0xd3, 0xd1, 0xaf, 0x9c, 0xf8, 0xf0, 0xf5, 0x97, 0x62, 0x56, 0x89, 0x5c, 0x1, + 0x53, 0x11, 0x0, 0x0, 0x2b, 0x9, 0x26, 0x0, 0x9, 0x9a, 0xb, 0x76, 0x66, 0xc6, 0xd6, 0x44, 0x44, 0x7f, 0x0, + 0xe, 0x18, 0x4e, 0xa7, 0x31, 0xf1, 0xf7, 0xcb, 0xc4, 0xae, 0x4e, 0x33, 0x91, 0x61, 0x28, 0x11, 0x0, 0x0, 0x9, + 0x31, 0x1f, 0x0, 0xa, 0xc8, 0x11, 0x9, 0x94, 0x73, 0x6d, 0x74, 0x20, 0x65, 0x39, 0x9, 0x0, 0x2, 0x12, 0x41, + 0x1a, 0x0, 0x8, 0xfd, 0x7f, 0x3b, 0xa0, 0x51, 0x44, 0xea, 0x10, 0x26, 0x0, 0x2, 0xfc, 0x50, 0x0, 0xe, 0xce, + 0xb3, 0x67, 0xaa, 0x29, 0x69, 0x77, 0x10, 0xdb, 0x74, 0xd, 0x1a, 0xe1, 0x6, 0x0, 0x87, 0x8f, 0x87}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[28]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 28, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[4]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25609); - EXPECT_EQ(count, 28); + EXPECT_EQ(packet_id, 17537); + EXPECT_EQ(count, 4); EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[25], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[26], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[27], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NOT_AUTHORIZED); } -// UnsubscribeResponse 8043 [PropSubscriptionIdentifier 25,PropContentType -// "\161\&9M\177\b\244KwX\199\205\251P\178\179\232\211\RS\168o1\DLE\ESCB(\\\225\184\146m",PropUserProperty -// "\b\DC4\f&\SYN\228N\DLE3\DLE\160z\DC2f\170\146v" -// "\SO\145\232\139v\159\204\232\154\180\&1}#\r\ENQ\209",PropPayloadFormatIndicator -// 28,PropSubscriptionIdentifierAvailable 64,PropAssignedClientIdentifier "\186\208\242Ce\210\207x\206"] -// [UnsubUnspecifiedError,UnsubSuccess,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubSuccess,UnsubUnspecifiedError] +// UnsubscribeResponse 11936 [PropCorrelationData "B",PropSharedSubscriptionAvailable 187,PropServerKeepAlive +// 22544,PropMessageExpiryInterval 414,PropSessionExpiryInterval 2745,PropSharedSubscriptionAvailable +// 134,PropServerReference "u\145d\221D\224e\183\219\233\224\182\206k:J\FSb\CAN6\v5\153\163]&",PropReasonString +// "8\174\170",PropMaximumQoS 85,PropContentType "\202\202M$\212\218\241\r\224Z\169\b\130\233.",PropResponseInformation +// "#G\174\SUB\r\188\170\233\238\SUB4\218J|\244\250\208\USq",PropRequestProblemInformation +// 175,PropPayloadFormatIndicator 249,PropAuthenticationMethod +// "^\186\229\214\170\CANo\230v\FS\203\134e\239\130\217\141\SYN\186Mud",PropMessageExpiryInterval +// 24407,PropWildcardSubscriptionAvailable 241,PropServerReference "S7j%\153@",PropWildcardSubscriptionAvailable +// 213,PropWildcardSubscriptionAvailable 79,PropSharedSubscriptionAvailable 250,PropSubscriptionIdentifier +// 24,PropSubscriptionIdentifier 6,PropSubscriptionIdentifier 17] +// [UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubSuccess,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubNotAuthorized] TEST(UnsubACK5QCTest, Decode29) { - uint8_t pkt[] = {0xb0, 0x6e, 0x1f, 0x6b, 0x59, 0xb, 0x19, 0x3, 0x0, 0x1e, 0xa1, 0x39, 0x4d, 0xb1, 0x8, 0xf4, - 0x4b, 0x77, 0x58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, 0xaa, 0xe9, 0xee, + 0x1a, 0x34, 0xda, 0x4a, 0x7c, 0xf4, 0xfa, 0xd0, 0x1f, 0x71, 0x17, 0xaf, 0x1, 0xf9, 0x15, 0x0, 0x16, 0x5e, 0xba, + 0xe5, 0xd6, 0xaa, 0x18, 0x6f, 0xe6, 0x76, 0x1c, 0xcb, 0x86, 0x65, 0xef, 0x82, 0xd9, 0x8d, 0x16, 0xba, 0x4d, 0x75, + 0x64, 0x2, 0x0, 0x0, 0x5f, 0x57, 0x28, 0xf1, 0x1c, 0x0, 0x6, 0x53, 0x37, 0x6a, 0x25, 0x99, 0x40, 0x28, 0xd5, + 0x28, 0x4f, 0x2a, 0xfa, 0xb, 0x18, 0xb, 0x6, 0xb, 0x11, 0x91, 0x0, 0x8f, 0x0, 0x87, 0x91, 0x8f, 0x87, 0x91, + 0x83, 0x83, 0x91, 0x80, 0x91, 0x87, 0x80, 0x91, 0x83, 0x0, 0x87, 0x8f, 0x8f, 0x8f, 0x11, 0x8f, 0x87}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[18]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 18, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[26]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 26, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8043); - EXPECT_EQ(count, 18); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(packet_id, 11936); + EXPECT_EQ(count, 26); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_UNSPECIFIED_ERROR); -} - -// UnsubscribeResponse 7204 [PropMaximumPacketSize 20642] -// [UnsubSuccess,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNotAuthorized] + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_NOT_AUTHORIZED); +} + +// UnsubscribeResponse 14068 [PropWildcardSubscriptionAvailable 58,PropUserProperty +// "\224\135\171x6\149\203\184f\174G\246\172b\ESC\232\225\215'\144\163\143n" +// "\DC4\186\238\ENQ\182\&3\SUB\235\167\137eb\140;\242",PropMessageExpiryInterval 472,PropWillDelayInterval +// 28858,PropSubscriptionIdentifierAvailable 233,PropUserProperty "\210\199Z\188;x\139\147" "1",PropAuthenticationMethod +// "\248\136\SUB\FS\aO-\165\253\ENQ",PropAuthenticationData +// "\147\149<_\232FZ\186\177\EM\226\144\252\196\222\\\160r\"\231",PropCorrelationData +// ")w\135)\167\154\205\246\DLE",PropRequestResponseInformation 18,PropSubscriptionIdentifierAvailable +// 203,PropRequestResponseInformation 160,PropAuthenticationMethod "^B\213,8\252\SI\217\236-'x",PropResponseTopic +// "\131\244",PropWildcardSubscriptionAvailable 245] +// [UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubSuccess,UnsubUnspecifiedError,UnsubSuccess,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized] TEST(UnsubACK5QCTest, Decode30) { - uint8_t pkt[] = {0xb0, 0x1a, 0x1c, 0x24, 0x5, 0x27, 0x0, 0x0, 0x50, 0xa2, 0x0, 0x80, 0x11, 0x91, - 0x8f, 0x11, 0x91, 0x80, 0x83, 0x87, 0x11, 0x91, 0x8f, 0x8f, 0x83, 0x8f, 0x0, 0x87}; + uint8_t pkt[] = { + 0xb0, 0xa7, 0x1, 0x36, 0xf4, 0x93, 0x1, 0x28, 0x3a, 0x26, 0x0, 0x17, 0xe0, 0x87, 0xab, 0x78, 0x36, 0x95, 0xcb, + 0xb8, 0x66, 0xae, 0x47, 0xf6, 0xac, 0x62, 0x1b, 0xe8, 0xe1, 0xd7, 0x27, 0x90, 0xa3, 0x8f, 0x6e, 0x0, 0xf, 0x14, + 0xba, 0xee, 0x5, 0xb6, 0x33, 0x1a, 0xeb, 0xa7, 0x89, 0x65, 0x62, 0x8c, 0x3b, 0xf2, 0x2, 0x0, 0x0, 0x1, 0xd8, + 0x18, 0x0, 0x0, 0x70, 0xba, 0x29, 0xe9, 0x26, 0x0, 0x8, 0xd2, 0xc7, 0x5a, 0xbc, 0x3b, 0x78, 0x8b, 0x93, 0x0, + 0x1, 0x31, 0x15, 0x0, 0xa, 0xf8, 0x88, 0x1a, 0x1c, 0x7, 0x4f, 0x2d, 0xa5, 0xfd, 0x5, 0x16, 0x0, 0x14, 0x93, + 0x95, 0x3c, 0x5f, 0xe8, 0x46, 0x5a, 0xba, 0xb1, 0x19, 0xe2, 0x90, 0xfc, 0xc4, 0xde, 0x5c, 0xa0, 0x72, 0x22, 0xe7, + 0x9, 0x0, 0x9, 0x29, 0x77, 0x87, 0x29, 0xa7, 0x9a, 0xcd, 0xf6, 0x10, 0x19, 0x12, 0x29, 0xcb, 0x19, 0xa0, 0x15, + 0x0, 0xc, 0x5e, 0x42, 0xd5, 0x2c, 0x38, 0xfc, 0xf, 0xd9, 0xec, 0x2d, 0x27, 0x78, 0x8, 0x0, 0x2, 0x83, 0xf4, + 0x28, 0xf5, 0x83, 0x87, 0x83, 0x91, 0x11, 0x91, 0x87, 0x83, 0x83, 0x0, 0x80, 0x0, 0x8f, 0x91, 0x0, 0x87}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[18]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 18, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[16]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 16, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7204); - EXPECT_EQ(count, 18); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(packet_id, 14068); + EXPECT_EQ(count, 16); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NOT_AUTHORIZED); } // DisconnectRequest DiscoNormalDisconnection [] @@ -22955,1577 +27411,1650 @@ TEST(Disco311QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoMaximumConnectTime [PropReasonString "\191\242\214\230?\v",PropResponseInformation -// "\227]\205*mi\179\ENQ\196\227",PropMaximumPacketSize 18477,PropPayloadFormatIndicator 55,PropResponseInformation -// "\f\217\229)@Ys\156\135\174}\129!\243\129\ETB\219\172a|\168\v\143",PropAuthenticationMethod -// "\fd\152L0q\214OSP\224\DEL 7\227\182\219\186",PropResponseInformation "",PropMaximumPacketSize -// 13687,PropWildcardSubscriptionAvailable 118,PropPayloadFormatIndicator 51,PropReasonString "",PropCorrelationData -// "u(\184\161}\139\227E\ENQ\249\&8\183\139\240\181\206\223/\172h\128\&7\160\254\178\162\250\147\179\226",PropWildcardSubscriptionAvailable -// 108,PropMessageExpiryInterval 17592,PropRequestResponseInformation 153,PropSessionExpiryInterval -// 23985,PropTopicAliasMaximum 16607,PropSubscriptionIdentifierAvailable 88,PropSessionExpiryInterval -// 11289,PropAuthenticationMethod "\134#\163\160R2\132\&5\176\&4\250\129\192Z\225\143+",PropContentType -// "\200\224",PropAssignedClientIdentifier -// "\204\132\143\226|\135~\240\171T\188\241-P\147\219`\235\178\vi\225\142",PropMaximumPacketSize -// 25765,PropSubscriptionIdentifierAvailable 116,PropResponseInformation -// "\160\154\248\199,\190\ETXZ\SUB&SM\240(\220\244Q\129:\SUB",PropTopicAliasMaximum 588,PropMessageExpiryInterval -// 9192,PropReasonString "\189\183\178\156\DC4\DEL\196w\208\154c\231\a"] +// DisconnectRequest DiscoKeepAliveTimeout [PropSessionExpiryInterval 25450,PropTopicAliasMaximum +// 12609,PropSubscriptionIdentifier 23,PropContentType +// "\198\242\215\161\&7sY#\181\SI\207\136\248c",PropMessageExpiryInterval 28547,PropSubscriptionIdentifier +// 12,PropRetainAvailable 94,PropRetainAvailable 188,PropServerReference +// "\208\230ml\213\243m\247-p\244\RS\217\134,\144\235\&8$\140",PropPayloadFormatIndicator 109,PropServerKeepAlive +// 19461,PropMessageExpiryInterval 4494,PropResponseTopic +// "x\211p4\229\230\139\238=\SOH@\rq",PropSharedSubscriptionAvailable 66,PropRetainAvailable +// 222,PropSessionExpiryInterval 27734,PropMaximumPacketSize 11253,PropRequestResponseInformation 40,PropServerKeepAlive +// 17832,PropResponseTopic ".\156\191\226z\161\227\"\211\197\150\231\243\239J\192\158\RS\137 +// \DC3\175\&4",PropMessageExpiryInterval 1201,PropTopicAliasMaximum 15711,PropMaximumQoS 97,PropAuthenticationMethod +// "@\230tU\244\254\181\&3\128\DLEI\228\SUB\221\241\215uj\129"] TEST(Disco5QCTest, Encode1) { uint8_t pkt[] = { - 0xe0, 0x80, 0x2, 0xa0, 0xfd, 0x1, 0x1f, 0x0, 0x6, 0xbf, 0xf2, 0xd6, 0xe6, 0x3f, 0xb, 0x1a, 0x0, 0xa, 0xe3, - 0x5d, 0xcd, 0x2a, 0x6d, 0x69, 0xb3, 0x5, 0xc4, 0xe3, 0x27, 0x0, 0x0, 0x48, 0x2d, 0x1, 0x37, 0x1a, 0x0, 0x17, - 0xc, 0xd9, 0xe5, 0x29, 0x40, 0x59, 0x73, 0x9c, 0x87, 0xae, 0x7d, 0x81, 0x21, 0xf3, 0x81, 0x17, 0xdb, 0xac, 0x61, - 0x7c, 0xa8, 0xb, 0x8f, 0x15, 0x0, 0x12, 0xc, 0x64, 0x98, 0x4c, 0x30, 0x71, 0xd6, 0x4f, 0x53, 0x50, 0xe0, 0x7f, - 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t) + 10] = {0}; - uint8_t bytesprops0[] = {0xbf, 0xf2, 0xd6, 0xe6, 0x3f, 0xb}; - uint8_t bytesprops1[] = {0xe3, 0x5d, 0xcd, 0x2a, 0x6d, 0x69, 0xb3, 0x5, 0xc4, 0xe3}; - uint8_t bytesprops2[] = {0xc, 0xd9, 0xe5, 0x29, 0x40, 0x59, 0x73, 0x9c, 0x87, 0xae, 0x7d, 0x81, - 0x21, 0xf3, 0x81, 0x17, 0xdb, 0xac, 0x61, 0x7c, 0xa8, 0xb, 0x8f}; - uint8_t bytesprops3[] = {0xc, 0x64, 0x98, 0x4c, 0x30, 0x71, 0xd6, 0x4f, 0x53, - 0x50, 0xe0, 0x7f, 0x20, 0x37, 0xe3, 0xb6, 0xdb, 0xba}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0}; - uint8_t bytesprops6[] = {0x75, 0x28, 0xb8, 0xa1, 0x7d, 0x8b, 0xe3, 0x45, 0x5, 0xf9, 0x38, 0xb7, 0x8b, 0xf0, 0xb5, - 0xce, 0xdf, 0x2f, 0xac, 0x68, 0x80, 0x37, 0xa0, 0xfe, 0xb2, 0xa2, 0xfa, 0x93, 0xb3, 0xe2}; - uint8_t bytesprops7[] = {0x86, 0x23, 0xa3, 0xa0, 0x52, 0x32, 0x84, 0x35, 0xb0, - 0x34, 0xfa, 0x81, 0xc0, 0x5a, 0xe1, 0x8f, 0x2b}; - uint8_t bytesprops8[] = {0xc8, 0xe0}; - uint8_t bytesprops9[] = {0xcc, 0x84, 0x8f, 0xe2, 0x7c, 0x87, 0x7e, 0xf0, 0xab, 0x54, 0xbc, 0xf1, - 0x2d, 0x50, 0x93, 0xdb, 0x60, 0xeb, 0xb2, 0xb, 0x69, 0xe1, 0x8e}; - uint8_t bytesprops10[] = {0xa0, 0x9a, 0xf8, 0xc7, 0x2c, 0xbe, 0x3, 0x5a, 0x1a, 0x26, - 0x53, 0x4d, 0xf0, 0x28, 0xdc, 0xf4, 0x51, 0x81, 0x3a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, 0x81}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc6, 0xf2, 0xd7, 0xa1, 0x37, 0x73, 0x59, 0x23, 0xb5, 0xf, 0xcf, 0x88, 0xf8, 0x63}; + uint8_t bytesprops1[] = {0xd0, 0xe6, 0x6d, 0x6c, 0xd5, 0xf3, 0x6d, 0xf7, 0x2d, 0x70, + 0xf4, 0x1e, 0xd9, 0x86, 0x2c, 0x90, 0xeb, 0x38, 0x24, 0x8c}; + uint8_t bytesprops2[] = {0x78, 0xd3, 0x70, 0x34, 0xe5, 0xe6, 0x8b, 0xee, 0x3d, 0x1, 0x40, 0xd, 0x71}; + uint8_t bytesprops3[] = {0x2e, 0x9c, 0xbf, 0xe2, 0x7a, 0xa1, 0xe3, 0x22, 0xd3, 0xc5, 0x96, 0xe7, + 0xf3, 0xef, 0x4a, 0xc0, 0x9e, 0x1e, 0x89, 0x20, 0x13, 0xaf, 0x34}; + uint8_t bytesprops4[] = {0x40, 0xe6, 0x74, 0x55, 0xf4, 0xfe, 0xb5, 0x33, 0x80, 0x10, + 0x49, 0xe4, 0x1a, 0xdd, 0xf1, 0xd7, 0x75, 0x6a, 0x81}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18477}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13687}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17592}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23985}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16607}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11289}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25765}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 588}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9192}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25450}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12609}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28547}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19461}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4494}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27734}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11253}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17832}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1201}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15711}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 97}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 160, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 141, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoImplementationSpecificError [PropSessionExpiryInterval 15056,PropSharedSubscriptionAvailable -// 72,PropResponseTopic "\129\DC3E",PropTopicAlias 16377,PropResponseInformation -// "\162\159C1O\159\168\197\NAK\157\179",PropSharedSubscriptionAvailable 106,PropMaximumQoS 44,PropTopicAlias -// 9466,PropRequestProblemInformation 78,PropRequestResponseInformation 138,PropSessionExpiryInterval -// 29538,PropRetainAvailable 222] +// DisconnectRequest DiscoAdministrativeAction [PropRequestProblemInformation 156,PropMaximumPacketSize +// 21994,PropAssignedClientIdentifier +// "\251\180\215\162\193\163\165B\FSS\218\&6\223\US\ENQ[N\172",PropSubscriptionIdentifierAvailable +// 165,PropServerKeepAlive 18090,PropMessageExpiryInterval 7428,PropMessageExpiryInterval +// 20100,PropSubscriptionIdentifier 8,PropSessionExpiryInterval 8470,PropUserProperty +// "ho\217@\244\144\215\133b\173\224s\181\227\DC2S6\243\RS\SI" +// "{\134\220\163\r=\201U|.;",PropSubscriptionIdentifierAvailable 91,PropSubscriptionIdentifier +// 22,PropResponseInformation "99\242\155\176\169\DC3m\DC2\179Zv\240R\147\199",PropReasonString +// "\249\198U\242\141O\189\CAN\155x\226b\SIL\179\216-\SUB\150",PropAuthenticationData +// "\229@e\241\SO\EM@\223\239\234t>\137\182\147\209\215\216Z\\\199\209\n\DEL",PropServerKeepAlive +// 20200,PropPayloadFormatIndicator 73,PropAssignedClientIdentifier +// "DK:\143^\216\147\&3dt\212\SOHL",PropTopicAliasMaximum 28734,PropWillDelayInterval 19849,PropResponseTopic -// "\213\164\166B`\157\168\v\236\142~\255",PropUserProperty "1[L\181\174\152\186\STX\186X\175\140 \212\133<" -// "N\STX=\208",PropServerKeepAlive 5878,PropUserProperty -// "\181\210}X\ETB\201|\ETBP\243\NUL.9\233\215\DC3\RS\222\n\161\171" "\180*5\133L\247\237|]",PropMaximumQoS -// 98,PropCorrelationData "^\176\EMIG\188",PropResponseInformation -// "al\134|\237\250Q\157g\235jO\148\234\239`\201-\143oa\198\253|\155\221\&3\128\214^",PropMessageExpiryInterval -// 26521,PropUserProperty "\161\EMz\207u\DC2;\130\197A\ACKvf3o\178\228#K" -// "\214\163:\242\245\216\147y\253A\223\RSQAXx\DC1",PropMaximumPacketSize 17250] +// DisconnectRequest DiscoPacketTooLarge [] TEST(Disco5QCTest, Encode4) { - uint8_t pkt[] = {0xe0, 0xf9, 0x1, 0x97, 0xf6, 0x1, 0x17, 0x76, 0x26, 0x0, 0x19, 0x60, 0x91, 0xbd, 0x91, 0xdc, 0x82, - 0xb3, 0xd5, 0xa2, 0x2e, 0x27, 0x52, 0x60, 0x99, 0xda, 0x3b, 0x22, 0x4b, 0xd6, 0x46, 0x35, 0xf5, 0xda, - 0xcc, 0xc8, 0x0, 0xb, 0x96, 0xcf, 0xff, 0x33, 0x73, 0xa7, 0x24, 0x2a, 0xeb, 0x1b, 0x31, 0x25, 0xe7, - 0x13, 0x58, 0x8f, 0x15, 0x0, 0xe, 0x7d, 0x3e, 0x4b, 0x3a, 0x8f, 0x5e, 0xd8, 0x93, 0x33, 0x64, 0x74, - 0xd4, 0x1, 0x4c, 0x22, 0x70, 0x3e, 0x18, 0x0, 0x0, 0x4d, 0x89, 0x8, 0x0, 0xc, 0xd5, 0xa4, 0xa6, - 0x42, 0x60, 0x9d, 0xa8, 0xb, 0xec, 0x8e, 0x7e, 0xff, 0x26, 0x0, 0x10, 0x31, 0x5b, 0x4c, 0xb5, 0xae, - 0x98, 0xba, 0x2, 0xba, 0x58, 0xaf, 0x8c, 0x20, 0xd4, 0x85, 0x3c, 0x0, 0x4, 0x4e, 0x2, 0x3d, 0xd0, - 0x13, 0x16, 0xf6, 0x26, 0x0, 0x15, 0xb5, 0xd2, 0x7d, 0x58, 0x17, 0xc9, 0x7c, 0x17, 0x50, 0xf3, 0x0, - 0x2e, 0x39, 0xe9, 0xd7, 0x13, 0x1e, 0xde, 0xa, 0xa1, 0xab, 0x0, 0x9, 0xb4, 0x2a, 0x35, 0x85, 0x4c, - 0xf7, 0xed, 0x7c, 0x5d, 0x24, 0x62, 0x9, 0x0, 0x6, 0x5e, 0xb0, 0x19, 0x49, 0x47, 0xbc, 0x1a, 0x0, - 0x1e, 0x61, 0x6c, 0x86, 0x7c, 0xed, 0xfa, 0x51, 0x9d, 0x67, 0xeb, 0x6a, 0x4f, 0x94, 0xea, 0xef, 0x60, - 0xc9, 0x2d, 0x8f, 0x6f, 0x61, 0xc6, 0xfd, 0x7c, 0x9b, 0xdd, 0x33, 0x80, 0xd6, 0x5e, 0x2, 0x0, 0x0, - 0x67, 0x99, 0x26, 0x0, 0x13, 0xa1, 0x19, 0x7a, 0xcf, 0x75, 0x12, 0x3b, 0x82, 0xc5, 0x41, 0x6, 0x76, - 0x66, 0x33, 0x6f, 0xb2, 0xe4, 0x23, 0x4b, 0x0, 0x11, 0xd6, 0xa3, 0x3a, 0xf2, 0xf5, 0xd8, 0x93, 0x79, - 0xfd, 0x41, 0xdf, 0x1e, 0x51, 0x41, 0x58, 0x78, 0x11, 0x27, 0x0, 0x0, 0x43, 0x62}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x96, 0xcf, 0xff, 0x33, 0x73, 0xa7, 0x24, 0x2a, 0xeb, 0x1b, 0x31}; - uint8_t bytesprops0[] = {0x60, 0x91, 0xbd, 0x91, 0xdc, 0x82, 0xb3, 0xd5, 0xa2, 0x2e, 0x27, 0x52, 0x60, - 0x99, 0xda, 0x3b, 0x22, 0x4b, 0xd6, 0x46, 0x35, 0xf5, 0xda, 0xcc, 0xc8}; - uint8_t bytesprops2[] = {0x7d, 0x3e, 0x4b, 0x3a, 0x8f, 0x5e, 0xd8, 0x93, 0x33, 0x64, 0x74, 0xd4, 0x1, 0x4c}; - uint8_t bytesprops3[] = {0xd5, 0xa4, 0xa6, 0x42, 0x60, 0x9d, 0xa8, 0xb, 0xec, 0x8e, 0x7e, 0xff}; - uint8_t bytesprops5[] = {0x4e, 0x2, 0x3d, 0xd0}; - uint8_t bytesprops4[] = {0x31, 0x5b, 0x4c, 0xb5, 0xae, 0x98, 0xba, 0x2, - 0xba, 0x58, 0xaf, 0x8c, 0x20, 0xd4, 0x85, 0x3c}; - uint8_t bytesprops7[] = {0xb4, 0x2a, 0x35, 0x85, 0x4c, 0xf7, 0xed, 0x7c, 0x5d}; - uint8_t bytesprops6[] = {0xb5, 0xd2, 0x7d, 0x58, 0x17, 0xc9, 0x7c, 0x17, 0x50, 0xf3, 0x0, - 0x2e, 0x39, 0xe9, 0xd7, 0x13, 0x1e, 0xde, 0xa, 0xa1, 0xab}; - uint8_t bytesprops8[] = {0x5e, 0xb0, 0x19, 0x49, 0x47, 0xbc}; - uint8_t bytesprops9[] = {0x61, 0x6c, 0x86, 0x7c, 0xed, 0xfa, 0x51, 0x9d, 0x67, 0xeb, 0x6a, 0x4f, 0x94, 0xea, 0xef, - 0x60, 0xc9, 0x2d, 0x8f, 0x6f, 0x61, 0xc6, 0xfd, 0x7c, 0x9b, 0xdd, 0x33, 0x80, 0xd6, 0x5e}; - uint8_t bytesprops11[] = {0xd6, 0xa3, 0x3a, 0xf2, 0xf5, 0xd8, 0x93, 0x79, 0xfd, - 0x41, 0xdf, 0x1e, 0x51, 0x41, 0x58, 0x78, 0x11}; - uint8_t bytesprops10[] = {0xa1, 0x19, 0x7a, 0xcf, 0x75, 0x12, 0x3b, 0x82, 0xc5, 0x41, - 0x6, 0x76, 0x66, 0x33, 0x6f, 0xb2, 0xe4, 0x23, 0x4b}; + uint8_t pkt[] = {0xe0, 0x2, 0x95, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops0}, .v = {11, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22671}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28734}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19849}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops4}, .v = {4, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5878}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops6}, .v = {9, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26521}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {19, (char*)&bytesprops10}, .v = {17, (char*)&bytesprops11}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17250}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 151, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 149, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoServerBusy [PropReceiveMaximum 10661,PropWillDelayInterval 20242,PropAuthenticationMethod -// "\196e\DC2\241?\196D\245U",PropRequestResponseInformation 216,PropWillDelayInterval 4157,PropWillDelayInterval -// 32170,PropContentType "\211\"\138d\157g\225\t\202<\214\164",PropReasonString -// "AL+_\170",PropRequestResponseInformation 236,PropWillDelayInterval 7295,PropAuthenticationMethod -// "Np\254\214C\248\f\209",PropMaximumPacketSize 17116,PropAuthenticationMethod -// "D*\209W\233\253\186\&0~\208\185\147\195\133\163;\218\t\180\172\158\128(",PropRequestResponseInformation -// 91,PropMaximumQoS 177,PropTopicAliasMaximum 29607,PropRetainAvailable 79,PropSharedSubscriptionAvailable -// 194,PropMaximumPacketSize 4393,PropRetainAvailable 94,PropMaximumPacketSize 11798,PropResponseTopic -// "\154\205\233\153\235m\219\DLEJ8icp\RS43\187\243X\143\231\239\217\201\226\248\175\b0\254",PropRequestResponseInformation -// 161,PropMaximumPacketSize 24013,PropPayloadFormatIndicator 6,PropCorrelationData -// "\214\CAN\232\178\221\&8\138/y\251\236\137\225\&0D\f\156X\nQ\201IuU\STXU\t\143",PropSessionExpiryInterval -// 17417,PropWildcardSubscriptionAvailable 30,PropAssignedClientIdentifier "d\SYN\EM -// G\142\DLE\227\DC4i9\172\153\FS^].(\233\142\187p*d",PropMaximumPacketSize 6745] +// DisconnectRequest DiscoNotAuthorized [PropMessageExpiryInterval 15490,PropTopicAliasMaximum +// 24696,PropMaximumPacketSize 14149,PropSubscriptionIdentifier 3] TEST(Disco5QCTest, Encode5) { - uint8_t pkt[] = { - 0xe0, 0xf2, 0x1, 0x89, 0xef, 0x1, 0x21, 0x29, 0xa5, 0x18, 0x0, 0x0, 0x4f, 0x12, 0x15, 0x0, 0x9, 0xc4, 0x65, - 0x12, 0xf1, 0x3f, 0xc4, 0x44, 0xf5, 0x55, 0x19, 0xd8, 0x18, 0x0, 0x0, 0x10, 0x3d, 0x18, 0x0, 0x0, 0x7d, 0xaa, - 0x3, 0x0, 0xc, 0xd3, 0x22, 0x8a, 0x64, 0x9d, 0x67, 0xe1, 0x9, 0xca, 0x3c, 0xd6, 0xa4, 0x1f, 0x0, 0x5, 0x41, - 0x4c, 0x2b, 0x5f, 0xaa, 0x19, 0xec, 0x18, 0x0, 0x0, 0x1c, 0x7f, 0x15, 0x0, 0x8, 0x4e, 0x70, 0xfe, 0xd6, 0x43, - 0xf8, 0xc, 0xd1, 0x27, 0x0, 0x0, 0x42, 0xdc, 0x15, 0x0, 0x17, 0x44, 0x2a, 0xd1, 0x57, 0xe9, 0xfd, 0xba, 0x30, - 0x7e, 0xd0, 0xb9, 0x93, 0xc3, 0x85, 0xa3, 0x3b, 0xda, 0x9, 0xb4, 0xac, 0x9e, 0x80, 0x28, 0x19, 0x5b, 0x24, 0xb1, - 0x22, 0x73, 0xa7, 0x25, 0x4f, 0x2a, 0xc2, 0x27, 0x0, 0x0, 0x11, 0x29, 0x25, 0x5e, 0x27, 0x0, 0x0, 0x2e, 0x16, - 0x8, 0x0, 0x1e, 0x9a, 0xcd, 0xe9, 0x99, 0xeb, 0x6d, 0xdb, 0x10, 0x4a, 0x38, 0x69, 0x63, 0x70, 0x1e, 0x34, 0x33, - 0xbb, 0xf3, 0x58, 0x8f, 0xe7, 0xef, 0xd9, 0xc9, 0xe2, 0xf8, 0xaf, 0x8, 0x30, 0xfe, 0x19, 0xa1, 0x27, 0x0, 0x0, - 0x5d, 0xcd, 0x1, 0x6, 0x9, 0x0, 0x1c, 0xd6, 0x18, 0xe8, 0xb2, 0xdd, 0x38, 0x8a, 0x2f, 0x79, 0xfb, 0xec, 0x89, - 0xe1, 0x30, 0x44, 0xc, 0x9c, 0x58, 0xa, 0x51, 0xc9, 0x49, 0x75, 0x55, 0x2, 0x55, 0x9, 0x8f, 0x11, 0x0, 0x0, - 0x44, 0x9, 0x28, 0x1e, 0x12, 0x0, 0x18, 0x64, 0x16, 0x19, 0x20, 0x47, 0x8e, 0x10, 0xe3, 0x14, 0x69, 0x39, 0xac, - 0x99, 0x1c, 0x5e, 0x5d, 0x2e, 0x28, 0xe9, 0x8e, 0xbb, 0x70, 0x2a, 0x64, 0x27, 0x0, 0x0, 0x1a, 0x59}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xc4, 0x65, 0x12, 0xf1, 0x3f, 0xc4, 0x44, 0xf5, 0x55}; - uint8_t bytesprops1[] = {0xd3, 0x22, 0x8a, 0x64, 0x9d, 0x67, 0xe1, 0x9, 0xca, 0x3c, 0xd6, 0xa4}; - uint8_t bytesprops2[] = {0x41, 0x4c, 0x2b, 0x5f, 0xaa}; - uint8_t bytesprops3[] = {0x4e, 0x70, 0xfe, 0xd6, 0x43, 0xf8, 0xc, 0xd1}; - uint8_t bytesprops4[] = {0x44, 0x2a, 0xd1, 0x57, 0xe9, 0xfd, 0xba, 0x30, 0x7e, 0xd0, 0xb9, 0x93, - 0xc3, 0x85, 0xa3, 0x3b, 0xda, 0x9, 0xb4, 0xac, 0x9e, 0x80, 0x28}; - uint8_t bytesprops5[] = {0x9a, 0xcd, 0xe9, 0x99, 0xeb, 0x6d, 0xdb, 0x10, 0x4a, 0x38, 0x69, 0x63, 0x70, 0x1e, 0x34, - 0x33, 0xbb, 0xf3, 0x58, 0x8f, 0xe7, 0xef, 0xd9, 0xc9, 0xe2, 0xf8, 0xaf, 0x8, 0x30, 0xfe}; - uint8_t bytesprops6[] = {0xd6, 0x18, 0xe8, 0xb2, 0xdd, 0x38, 0x8a, 0x2f, 0x79, 0xfb, 0xec, 0x89, 0xe1, 0x30, - 0x44, 0xc, 0x9c, 0x58, 0xa, 0x51, 0xc9, 0x49, 0x75, 0x55, 0x2, 0x55, 0x9, 0x8f}; - uint8_t bytesprops7[] = {0x64, 0x16, 0x19, 0x20, 0x47, 0x8e, 0x10, 0xe3, 0x14, 0x69, 0x39, 0xac, - 0x99, 0x1c, 0x5e, 0x5d, 0x2e, 0x28, 0xe9, 0x8e, 0xbb, 0x70, 0x2a, 0x64}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10661}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20242}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4157}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32170}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7295}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17116}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29607}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4393}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 94}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11798}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24013}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17417}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6745}}, + uint8_t pkt[] = {0xe0, 0x11, 0x87, 0xf, 0x2, 0x0, 0x0, 0x3c, 0x82, 0x22, + 0x60, 0x78, 0x27, 0x0, 0x0, 0x37, 0x45, 0xb, 0x3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15490}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24696}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14149}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 137, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 135, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoSessiontakenOver [PropMessageExpiryInterval 31530,PropTopicAliasMaximum -// 20641,PropRequestProblemInformation 28,PropRetainAvailable 154,PropSubscriptionIdentifier 22,PropResponseTopic -// "\164$\241\130a\243",PropWildcardSubscriptionAvailable 222,PropCorrelationData "\147\197",PropPayloadFormatIndicator -// 149,PropWildcardSubscriptionAvailable 246,PropSharedSubscriptionAvailable 80,PropRequestProblemInformation -// 82,PropWillDelayInterval 24431,PropCorrelationData -// "M\185rj\222\SOH\NULb\140\166\153\231\181|\231\185\248\DC3{j\DC1\152\153\167\230",PropWillDelayInterval -// 5082,PropRequestResponseInformation 164,PropServerReference -// "\ETX\201pk\210pG\217\168\158\254\190\STX>\152\201Dj\231\&6\252yc",PropCorrelationData -// "xO\163\135\225\212z\220\150",PropServerReference "h\r\189\RS2\138\240\DLE",PropAuthenticationMethod -// "4\a\177\144\190@\162\190\147\&8\226:&\176\206\187",PropWillDelayInterval 16727,PropSessionExpiryInterval -// 30740,PropPayloadFormatIndicator 54] +// DisconnectRequest DiscoConnectionRateExceeded [PropCorrelationData +// "7\203\NULi\150\131\177\SI\CAN\174\233|\a\216\t\162\242\"",PropResponseTopic +// "H#\"A\250\181\182",PropMessageExpiryInterval 25058,PropAuthenticationData +// "\211@\213E1\228\137\169y\"\f\227A\195\198uh\165\153",PropAuthenticationMethod +// "\RS\247z~U\187\178\r\a_eq\193\STX)",PropRetainAvailable 32,PropRequestResponseInformation 178,PropResponseTopic +// "/\201\253\219\180'\136=\220#\148\&9\128\247\206\SUB\215\131"] TEST(Disco5QCTest, Encode6) { - uint8_t pkt[] = {0xe0, 0xa1, 0x1, 0x8e, 0x9e, 0x1, 0x2, 0x0, 0x0, 0x7b, 0x2a, 0x22, 0x50, 0xa1, 0x17, 0x1c, 0x25, - 0x9a, 0xb, 0x16, 0x8, 0x0, 0x6, 0xa4, 0x24, 0xf1, 0x82, 0x61, 0xf3, 0x28, 0xde, 0x9, 0x0, 0x2, - 0x93, 0xc5, 0x1, 0x95, 0x28, 0xf6, 0x2a, 0x50, 0x17, 0x52, 0x18, 0x0, 0x0, 0x5f, 0x6f, 0x9, 0x0, - 0x19, 0x4d, 0xb9, 0x72, 0x6a, 0xde, 0x1, 0x0, 0x62, 0x8c, 0xa6, 0x99, 0xe7, 0xb5, 0x7c, 0xe7, 0xb9, - 0xf8, 0x13, 0x7b, 0x6a, 0x11, 0x98, 0x99, 0xa7, 0xe6, 0x18, 0x0, 0x0, 0x13, 0xda, 0x19, 0xa4, 0x1c, - 0x0, 0x17, 0x3, 0xc9, 0x70, 0x6b, 0xd2, 0x70, 0x47, 0xd9, 0xa8, 0x9e, 0xfe, 0xbe, 0x2, 0x3e, 0x98, - 0xc9, 0x44, 0x6a, 0xe7, 0x36, 0xfc, 0x79, 0x63, 0x9, 0x0, 0x9, 0x78, 0x4f, 0xa3, 0x87, 0xe1, 0xd4, - 0x7a, 0xdc, 0x96, 0x1c, 0x0, 0x8, 0x68, 0xd, 0xbd, 0x1e, 0x32, 0x8a, 0xf0, 0x10, 0x15, 0x0, 0x10, - 0x34, 0x7, 0xb1, 0x90, 0xbe, 0x40, 0xa2, 0xbe, 0x93, 0x38, 0xe2, 0x3a, 0x26, 0xb0, 0xce, 0xbb, 0x18, - 0x0, 0x0, 0x41, 0x57, 0x11, 0x0, 0x0, 0x78, 0x14, 0x1, 0x36}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xa4, 0x24, 0xf1, 0x82, 0x61, 0xf3}; - uint8_t bytesprops1[] = {0x93, 0xc5}; - uint8_t bytesprops2[] = {0x4d, 0xb9, 0x72, 0x6a, 0xde, 0x1, 0x0, 0x62, 0x8c, 0xa6, 0x99, 0xe7, 0xb5, - 0x7c, 0xe7, 0xb9, 0xf8, 0x13, 0x7b, 0x6a, 0x11, 0x98, 0x99, 0xa7, 0xe6}; - uint8_t bytesprops3[] = {0x3, 0xc9, 0x70, 0x6b, 0xd2, 0x70, 0x47, 0xd9, 0xa8, 0x9e, 0xfe, 0xbe, - 0x2, 0x3e, 0x98, 0xc9, 0x44, 0x6a, 0xe7, 0x36, 0xfc, 0x79, 0x63}; - uint8_t bytesprops4[] = {0x78, 0x4f, 0xa3, 0x87, 0xe1, 0xd4, 0x7a, 0xdc, 0x96}; - uint8_t bytesprops5[] = {0x68, 0xd, 0xbd, 0x1e, 0x32, 0x8a, 0xf0, 0x10}; - uint8_t bytesprops6[] = {0x34, 0x7, 0xb1, 0x90, 0xbe, 0x40, 0xa2, 0xbe, - 0x93, 0x38, 0xe2, 0x3a, 0x26, 0xb0, 0xce, 0xbb}; + uint8_t pkt[] = {0xe0, 0x67, 0x9f, 0x65, 0x9, 0x0, 0x12, 0x37, 0xcb, 0x0, 0x69, 0x96, 0x83, 0xb1, 0xf, + 0x18, 0xae, 0xe9, 0x7c, 0x7, 0xd8, 0x9, 0xa2, 0xf2, 0x22, 0x8, 0x0, 0x7, 0x48, 0x23, + 0x22, 0x41, 0xfa, 0xb5, 0xb6, 0x2, 0x0, 0x0, 0x61, 0xe2, 0x16, 0x0, 0x13, 0xd3, 0x40, + 0xd5, 0x45, 0x31, 0xe4, 0x89, 0xa9, 0x79, 0x22, 0xc, 0xe3, 0x41, 0xc3, 0xc6, 0x75, 0x68, + 0xa5, 0x99, 0x15, 0x0, 0xf, 0x1e, 0xf7, 0x7a, 0x7e, 0x55, 0xbb, 0xb2, 0xd, 0x7, 0x5f, + 0x65, 0x71, 0xc1, 0x2, 0x29, 0x25, 0x20, 0x19, 0xb2, 0x8, 0x0, 0x12, 0x2f, 0xc9, 0xfd, + 0xdb, 0xb4, 0x27, 0x88, 0x3d, 0xdc, 0x23, 0x94, 0x39, 0x80, 0xf7, 0xce, 0x1a, 0xd7, 0x83}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x37, 0xcb, 0x0, 0x69, 0x96, 0x83, 0xb1, 0xf, 0x18, + 0xae, 0xe9, 0x7c, 0x7, 0xd8, 0x9, 0xa2, 0xf2, 0x22}; + uint8_t bytesprops1[] = {0x48, 0x23, 0x22, 0x41, 0xfa, 0xb5, 0xb6}; + uint8_t bytesprops2[] = {0xd3, 0x40, 0xd5, 0x45, 0x31, 0xe4, 0x89, 0xa9, 0x79, 0x22, + 0xc, 0xe3, 0x41, 0xc3, 0xc6, 0x75, 0x68, 0xa5, 0x99}; + uint8_t bytesprops3[] = {0x1e, 0xf7, 0x7a, 0x7e, 0x55, 0xbb, 0xb2, 0xd, 0x7, 0x5f, 0x65, 0x71, 0xc1, 0x2, 0x29}; + uint8_t bytesprops4[] = {0x2f, 0xc9, 0xfd, 0xdb, 0xb4, 0x27, 0x88, 0x3d, 0xdc, + 0x23, 0x94, 0x39, 0x80, 0xf7, 0xce, 0x1a, 0xd7, 0x83}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31530}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20641}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 149}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24431}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5082}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16727}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30740}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25058}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 142, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoNotAuthorized [PropRequestResponseInformation 223,PropPayloadFormatIndicator -// 46,PropWillDelayInterval 3656,PropSubscriptionIdentifier 17,PropServerReference -// "\130\186?~>",PropSessionExpiryInterval 18554,PropContentType "",PropResponseInformation -// "\189.\DLE[\184\217Y\129b\144OW'\137i?\166~\216X'$\228",PropAssignedClientIdentifier -// "0\171\ETXf\229\161p\DC1-\227\146\181\178\132\223<\232+\207\160\182\176\190\&6\231K\132",PropServerKeepAlive -// 4852,PropServerKeepAlive 29505,PropTopicAliasMaximum 4105,PropMessageExpiryInterval 24745] +// DisconnectRequest DiscoRetainNotSupported [PropContentType "{B\162\198\231\240jq\233n"] TEST(Disco5QCTest, Encode7) { - uint8_t pkt[] = {0xe0, 0x63, 0x87, 0x61, 0x19, 0xdf, 0x1, 0x2e, 0x18, 0x0, 0x0, 0xe, 0x48, 0xb, 0x11, 0x1c, 0x0, - 0x5, 0x82, 0xba, 0x3f, 0x7e, 0x3e, 0x11, 0x0, 0x0, 0x48, 0x7a, 0x3, 0x0, 0x0, 0x1a, 0x0, 0x17, - 0xbd, 0x2e, 0x10, 0x5b, 0xb8, 0xd9, 0x59, 0x81, 0x62, 0x90, 0x4f, 0x57, 0x27, 0x89, 0x69, 0x3f, 0xa6, - 0x7e, 0xd8, 0x58, 0x27, 0x24, 0xe4, 0x12, 0x0, 0x1b, 0x30, 0xab, 0x3, 0x66, 0xe5, 0xa1, 0x70, 0x11, - 0x2d, 0xe3, 0x92, 0xb5, 0xb2, 0x84, 0xdf, 0x3c, 0xe8, 0x2b, 0xcf, 0xa0, 0xb6, 0xb0, 0xbe, 0x36, 0xe7, - 0x4b, 0x84, 0x13, 0x12, 0xf4, 0x13, 0x73, 0x41, 0x22, 0x10, 0x9, 0x2, 0x0, 0x0, 0x60, 0xa9}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x82, 0xba, 0x3f, 0x7e, 0x3e}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0xbd, 0x2e, 0x10, 0x5b, 0xb8, 0xd9, 0x59, 0x81, 0x62, 0x90, 0x4f, 0x57, - 0x27, 0x89, 0x69, 0x3f, 0xa6, 0x7e, 0xd8, 0x58, 0x27, 0x24, 0xe4}; - uint8_t bytesprops3[] = {0x30, 0xab, 0x3, 0x66, 0xe5, 0xa1, 0x70, 0x11, 0x2d, 0xe3, 0x92, 0xb5, 0xb2, 0x84, - 0xdf, 0x3c, 0xe8, 0x2b, 0xcf, 0xa0, 0xb6, 0xb0, 0xbe, 0x36, 0xe7, 0x4b, 0x84}; + uint8_t pkt[] = {0xe0, 0xf, 0x9a, 0xd, 0x3, 0x0, 0xa, 0x7b, 0x42, 0xa2, 0xc6, 0xe7, 0xf0, 0x6a, 0x71, 0xe9, 0x6e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7b, 0x42, 0xa2, 0xc6, 0xe7, 0xf0, 0x6a, 0x71, 0xe9, 0x6e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 46}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3656}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18554}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4852}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29505}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4105}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24745}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 135, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 154, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoDisconnectWithWill [PropRequestResponseInformation 209,PropMaximumPacketSize -// 3936,PropSharedSubscriptionAvailable 137,PropWildcardSubscriptionAvailable 244,PropRequestResponseInformation -// 55,PropReceiveMaximum 25352,PropTopicAlias 28418,PropReceiveMaximum 11027,PropCorrelationData -// "3@\ac\EM\249",PropSubscriptionIdentifier 10,PropResponseTopic -// "\148\203\180\141Y'\192\226\DC1\n\CAN\254\237-\233d\159\241#\168NH\216/\229:",PropWillDelayInterval -// 1927,PropSessionExpiryInterval 11473,PropRequestResponseInformation 40,PropAssignedClientIdentifier "\192Y; -// A\v\169\190\203\187*\192\193W\210<\212j&H\241\143\151!\231\148\DC2\214\142",PropPayloadFormatIndicator -// 186,PropCorrelationData "o\200\210\164\229P\206\224~\ETX",PropReasonString "\149\&7X<\174I -// \DC2\GS\178\196\206s\140h`\211o"] +// DisconnectRequest DiscoUseAnotherServer [PropPayloadFormatIndicator 31,PropSharedSubscriptionAvailable +// 161,PropSessionExpiryInterval 21301,PropAuthenticationData "\r\SI\218",PropUserProperty "O\227y\195T" +// "[K<\tn",PropSharedSubscriptionAvailable 182,PropResponseTopic +// "\145\"\245\253x\251[\131T\205\191\253\215\136/",PropResponseTopic "%\239\192\162e\160\aPn\234\186 +// \244\217\137x\221{\GSQo\243\136",PropRetainAvailable 12,PropRetainAvailable 61,PropAuthenticationMethod +// "@d\147j\181\177\146\DC1Vw\152K\177,\DC1\251\142\"\179\176\194Z\196:\208\229",PropMaximumPacketSize +// 4523,PropMaximumQoS 28,PropSessionExpiryInterval 19888,PropRetainAvailable 232,PropAuthenticationMethod +// "\ESC_\199\188\159\182\NUL8C?v8",PropAuthenticationMethod "\170a!\215g\131\134S1\234\236",PropTopicAliasMaximum +// 31811,PropMaximumPacketSize 32664,PropAuthenticationData +// "#L\218\218@\228\200\208p\133\160\143t-\197\251J\146\&9\146\129x"] TEST(Disco5QCTest, Encode8) { - uint8_t pkt[] = {0xe0, 0x91, 0x1, 0x4, 0x8e, 0x1, 0x19, 0xd1, 0x27, 0x0, 0x0, 0xf, 0x60, 0x2a, 0x89, 0x28, 0xf4, - 0x19, 0x37, 0x21, 0x63, 0x8, 0x23, 0x6f, 0x2, 0x21, 0x2b, 0x13, 0x9, 0x0, 0x6, 0x33, 0x40, 0x7, - 0x63, 0x19, 0xf9, 0xb, 0xa, 0x8, 0x0, 0x1a, 0x94, 0xcb, 0xb4, 0x8d, 0x59, 0x27, 0xc0, 0xe2, 0x11, - 0xa, 0x18, 0xfe, 0xed, 0x2d, 0xe9, 0x64, 0x9f, 0xf1, 0x23, 0xa8, 0x4e, 0x48, 0xd8, 0x2f, 0xe5, 0x3a, - 0x18, 0x0, 0x0, 0x7, 0x87, 0x11, 0x0, 0x0, 0x2c, 0xd1, 0x19, 0x28, 0x12, 0x0, 0x1d, 0xc0, 0x59, - 0x3b, 0x20, 0x41, 0xb, 0xa9, 0xbe, 0xcb, 0xbb, 0x2a, 0xc0, 0xc1, 0x57, 0xd2, 0x3c, 0xd4, 0x6a, 0x26, - 0x48, 0xf1, 0x8f, 0x97, 0x21, 0xe7, 0x94, 0x12, 0xd6, 0x8e, 0x1, 0xba, 0x9, 0x0, 0xa, 0x6f, 0xc8, - 0xd2, 0xa4, 0xe5, 0x50, 0xce, 0xe0, 0x7e, 0x3, 0x1f, 0x0, 0x12, 0x95, 0x37, 0x58, 0x3c, 0xae, 0x49, - 0x20, 0x12, 0x1d, 0xb2, 0xc4, 0xce, 0x73, 0x8c, 0x68, 0x60, 0xd3, 0x6f}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x33, 0x40, 0x7, 0x63, 0x19, 0xf9}; - uint8_t bytesprops1[] = {0x94, 0xcb, 0xb4, 0x8d, 0x59, 0x27, 0xc0, 0xe2, 0x11, 0xa, 0x18, 0xfe, 0xed, - 0x2d, 0xe9, 0x64, 0x9f, 0xf1, 0x23, 0xa8, 0x4e, 0x48, 0xd8, 0x2f, 0xe5, 0x3a}; - uint8_t bytesprops2[] = {0xc0, 0x59, 0x3b, 0x20, 0x41, 0xb, 0xa9, 0xbe, 0xcb, 0xbb, 0x2a, 0xc0, 0xc1, 0x57, 0xd2, - 0x3c, 0xd4, 0x6a, 0x26, 0x48, 0xf1, 0x8f, 0x97, 0x21, 0xe7, 0x94, 0x12, 0xd6, 0x8e}; - uint8_t bytesprops3[] = {0x6f, 0xc8, 0xd2, 0xa4, 0xe5, 0x50, 0xce, 0xe0, 0x7e, 0x3}; - uint8_t bytesprops4[] = {0x95, 0x37, 0x58, 0x3c, 0xae, 0x49, 0x20, 0x12, 0x1d, - 0xb2, 0xc4, 0xce, 0x73, 0x8c, 0x68, 0x60, 0xd3, 0x6f}; + uint8_t pkt[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x92, 0x39, 0x92, 0x81, 0x78}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xd, 0xf, 0xda}; + uint8_t bytesprops2[] = {0x5b, 0x4b, 0x3c, 0x9, 0x6e}; + uint8_t bytesprops1[] = {0x4f, 0xe3, 0x79, 0xc3, 0x54}; + uint8_t bytesprops3[] = {0x91, 0x22, 0xf5, 0xfd, 0x78, 0xfb, 0x5b, 0x83, 0x54, 0xcd, 0xbf, 0xfd, 0xd7, 0x88, 0x2f}; + uint8_t bytesprops4[] = {0x25, 0xef, 0xc0, 0xa2, 0x65, 0xa0, 0x7, 0x50, 0x6e, 0xea, 0xba, 0x20, + 0xf4, 0xd9, 0x89, 0x78, 0xdd, 0x7b, 0x1d, 0x51, 0x6f, 0xf3, 0x88}; + uint8_t bytesprops5[] = {0x40, 0x64, 0x93, 0x6a, 0xb5, 0xb1, 0x92, 0x11, 0x56, 0x77, 0x98, 0x4b, 0xb1, + 0x2c, 0x11, 0xfb, 0x8e, 0x22, 0xb3, 0xb0, 0xc2, 0x5a, 0xc4, 0x3a, 0xd0, 0xe5}; + uint8_t bytesprops6[] = {0x1b, 0x5f, 0xc7, 0xbc, 0x9f, 0xb6, 0x0, 0x38, 0x43, 0x3f, 0x76, 0x38}; + uint8_t bytesprops7[] = {0xaa, 0x61, 0x21, 0xd7, 0x67, 0x83, 0x86, 0x53, 0x31, 0xea, 0xec}; + uint8_t bytesprops8[] = {0x23, 0x4c, 0xda, 0xda, 0x40, 0xe4, 0xc8, 0xd0, 0x70, 0x85, 0xa0, + 0x8f, 0x74, 0x2d, 0xc5, 0xfb, 0x4a, 0x92, 0x39, 0x92, 0x81, 0x78}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3936}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25352}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28418}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11027}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1927}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11473}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21301}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops1}, .v = {5, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4523}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 28}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19888}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31811}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32664}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 156, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoNormalDisconnection [PropCorrelationData -// "+\199\231\205\129\214\129\220&\240\t\159\DC1N\GSG",PropTopicAlias 21761,PropTopicAlias 11810,PropWillDelayInterval -// 27354,PropAssignedClientIdentifier "\196\238\195\222{z\184\195\200\199_",PropContentType -// "s\241@%\233\216\129\213\246\&9\161)\193\ETB\EOT\149",PropTopicAlias 31127,PropReasonString -// "g*\SUB\214\218\230\"\135\FS\162X\ENQ",PropTopicAliasMaximum 2689,PropMaximumPacketSize -// 16049,PropSubscriptionIdentifier 23,PropSessionExpiryInterval 21820,PropCorrelationData -// "\213\225\173\213\ENQ\141@V\SYN\165\250`",PropServerKeepAlive 9762,PropWillDelayInterval 30730,PropMaximumPacketSize -// 23599,PropMaximumPacketSize 15159,PropServerReference "\v\187",PropReasonString -// "1\r\187\SUB\175U\DC3r}}\ACK\213\GS\248\189\129\193\236gcd\221\156'\132",PropAuthenticationData -// "\144\201\237P\232\211\221b\ESC,\242",PropSubscriptionIdentifier 23,PropRequestProblemInformation -// 95,PropCorrelationData "\170\&3s\225\220\144\223+\ENQ",PropAuthenticationData "~\181\246{\249"] +// DisconnectRequest DiscoImplementationSpecificError [PropResponseTopic +// ")J3'\129_h\148\SUB\172\198\133mV\196\SYN|\ENQ\220\248\138\172\b1",PropMessageExpiryInterval 29415,PropUserProperty +// ";?\154\246\130\144\141\247\225\194~G\204\208\RS" +// "::\155\253\207\SI\185\&8$r\SUBm\v\SUBs\210*\ts\208^{\208",PropAssignedClientIdentifier +// "\ENQn\155\152XL0\207\182)\DEL\171\SOH\222\175\NUL\164q\243p;",PropTopicAliasMaximum 27865,PropReceiveMaximum +// 29170,PropMaximumQoS 196,PropResponseTopic +// "\214\DC4\CAN\131<\195#\SYN'\136)\151\159\ETB\141b\152\193\222",PropResponseTopic "\199\161\213V\EM*",PropTopicAlias +// 2273,PropRetainAvailable 132,PropAuthenticationData +// "\170g\GS\156\224\224\175\166\US\SOHB{-\233\SO:6\220n\242w\EM.21;qp\SI",PropReasonString " +// \153\NUL`\236\143\170\DC1\144\151\164"] TEST(Disco5QCTest, Encode9) { - uint8_t pkt[] = { - 0xe0, 0xcb, 0x1, 0x0, 0xc8, 0x1, 0x9, 0x0, 0x10, 0x2b, 0xc7, 0xe7, 0xcd, 0x81, 0xd6, 0x81, 0xdc, 0x26, 0xf0, - 0x9, 0x9f, 0x11, 0x4e, 0x1d, 0x47, 0x23, 0x55, 0x1, 0x23, 0x2e, 0x22, 0x18, 0x0, 0x0, 0x6a, 0xda, 0x12, 0x0, - 0xb, 0xc4, 0xee, 0xc3, 0xde, 0x7b, 0x7a, 0xb8, 0xc3, 0xc8, 0xc7, 0x5f, 0x3, 0x0, 0x10, 0x73, 0xf1, 0x40, 0x25, - 0xe9, 0xd8, 0x81, 0xd5, 0xf6, 0x39, 0xa1, 0x29, 0xc1, 0x17, 0x4, 0x95, 0x23, 0x79, 0x97, 0x1f, 0x0, 0xc, 0x67, - 0x2a, 0x1a, 0xd6, 0xda, 0xe6, 0x22, 0x87, 0x1c, 0xa2, 0x58, 0x5, 0x22, 0xa, 0x81, 0x27, 0x0, 0x0, 0x3e, 0xb1, - 0xb, 0x17, 0x11, 0x0, 0x0, 0x55, 0x3c, 0x9, 0x0, 0xc, 0xd5, 0xe1, 0xad, 0xd5, 0x5, 0x8d, 0x40, 0x56, 0x16, - 0xa5, 0xfa, 0x60, 0x13, 0x26, 0x22, 0x18, 0x0, 0x0, 0x78, 0xa, 0x27, 0x0, 0x0, 0x5c, 0x2f, 0x27, 0x0, 0x0, - 0x3b, 0x37, 0x1c, 0x0, 0x2, 0xb, 0xbb, 0x1f, 0x0, 0x19, 0x31, 0xd, 0xbb, 0x1a, 0xaf, 0x55, 0x13, 0x72, 0x7d, - 0x7d, 0x6, 0xd5, 0x1d, 0xf8, 0xbd, 0x81, 0xc1, 0xec, 0x67, 0x63, 0x64, 0xdd, 0x9c, 0x27, 0x84, 0x16, 0x0, 0xb, - 0x90, 0xc9, 0xed, 0x50, 0xe8, 0xd3, 0xdd, 0x62, 0x1b, 0x2c, 0xf2, 0xb, 0x17, 0x17, 0x5f, 0x9, 0x0, 0x9, 0xaa, - 0x33, 0x73, 0xe1, 0xdc, 0x90, 0xdf, 0x2b, 0x5, 0x16, 0x0, 0x5, 0x7e, 0xb5, 0xf6, 0x7b, 0xf9}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x2b, 0xc7, 0xe7, 0xcd, 0x81, 0xd6, 0x81, 0xdc, - 0x26, 0xf0, 0x9, 0x9f, 0x11, 0x4e, 0x1d, 0x47}; - uint8_t bytesprops1[] = {0xc4, 0xee, 0xc3, 0xde, 0x7b, 0x7a, 0xb8, 0xc3, 0xc8, 0xc7, 0x5f}; - uint8_t bytesprops2[] = {0x73, 0xf1, 0x40, 0x25, 0xe9, 0xd8, 0x81, 0xd5, - 0xf6, 0x39, 0xa1, 0x29, 0xc1, 0x17, 0x4, 0x95}; - uint8_t bytesprops3[] = {0x67, 0x2a, 0x1a, 0xd6, 0xda, 0xe6, 0x22, 0x87, 0x1c, 0xa2, 0x58, 0x5}; - uint8_t bytesprops4[] = {0xd5, 0xe1, 0xad, 0xd5, 0x5, 0x8d, 0x40, 0x56, 0x16, 0xa5, 0xfa, 0x60}; - uint8_t bytesprops5[] = {0xb, 0xbb}; - uint8_t bytesprops6[] = {0x31, 0xd, 0xbb, 0x1a, 0xaf, 0x55, 0x13, 0x72, 0x7d, 0x7d, 0x6, 0xd5, 0x1d, - 0xf8, 0xbd, 0x81, 0xc1, 0xec, 0x67, 0x63, 0x64, 0xdd, 0x9c, 0x27, 0x84}; - uint8_t bytesprops7[] = {0x90, 0xc9, 0xed, 0x50, 0xe8, 0xd3, 0xdd, 0x62, 0x1b, 0x2c, 0xf2}; - uint8_t bytesprops8[] = {0xaa, 0x33, 0x73, 0xe1, 0xdc, 0x90, 0xdf, 0x2b, 0x5}; - uint8_t bytesprops9[] = {0x7e, 0xb5, 0xf6, 0x7b, 0xf9}; + uint8_t pkt[] = {0xe0, 0xc0, 0x1, 0x83, 0xbd, 0x1, 0x8, 0x0, 0x18, 0x29, 0x4a, 0x33, 0x27, 0x81, 0x5f, 0x68, 0x94, + 0x1a, 0xac, 0xc6, 0x85, 0x6d, 0x56, 0xc4, 0x16, 0x7c, 0x5, 0xdc, 0xf8, 0x8a, 0xac, 0x8, 0x31, 0x2, + 0x0, 0x0, 0x72, 0xe7, 0x26, 0x0, 0xf, 0x3b, 0x3f, 0x9a, 0xf6, 0x82, 0x90, 0x8d, 0xf7, 0xe1, 0xc2, + 0x7e, 0x47, 0xcc, 0xd0, 0x1e, 0x0, 0x17, 0x3a, 0x3a, 0x9b, 0xfd, 0xcf, 0xf, 0xb9, 0x38, 0x24, 0x72, + 0x1a, 0x6d, 0xb, 0x1a, 0x73, 0xd2, 0x2a, 0x9, 0x73, 0xd0, 0x5e, 0x7b, 0xd0, 0x12, 0x0, 0x15, 0x5, + 0x6e, 0x9b, 0x98, 0x58, 0x4c, 0x30, 0xcf, 0xb6, 0x29, 0x7f, 0xab, 0x1, 0xde, 0xaf, 0x0, 0xa4, 0x71, + 0xf3, 0x70, 0x3b, 0x22, 0x6c, 0xd9, 0x21, 0x71, 0xf2, 0x24, 0xc4, 0x8, 0x0, 0x13, 0xd6, 0x14, 0x18, + 0x83, 0x3c, 0xc3, 0x23, 0x16, 0x27, 0x88, 0x29, 0x97, 0x9f, 0x17, 0x8d, 0x62, 0x98, 0xc1, 0xde, 0x8, + 0x0, 0x6, 0xc7, 0xa1, 0xd5, 0x56, 0x19, 0x2a, 0x23, 0x8, 0xe1, 0x25, 0x84, 0x16, 0x0, 0x1d, 0xaa, + 0x67, 0x1d, 0x9c, 0xe0, 0xe0, 0xaf, 0xa6, 0x1f, 0x1, 0x42, 0x7b, 0x2d, 0xe9, 0xe, 0x3a, 0x36, 0xdc, + 0x6e, 0xf2, 0x77, 0x19, 0x2e, 0x32, 0x31, 0x3b, 0x71, 0x70, 0xf, 0x1f, 0x0, 0xb, 0x20, 0x99, 0x0, + 0x60, 0xec, 0x8f, 0xaa, 0x11, 0x90, 0x97, 0xa4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x29, 0x4a, 0x33, 0x27, 0x81, 0x5f, 0x68, 0x94, 0x1a, 0xac, 0xc6, 0x85, + 0x6d, 0x56, 0xc4, 0x16, 0x7c, 0x5, 0xdc, 0xf8, 0x8a, 0xac, 0x8, 0x31}; + uint8_t bytesprops2[] = {0x3a, 0x3a, 0x9b, 0xfd, 0xcf, 0xf, 0xb9, 0x38, 0x24, 0x72, 0x1a, 0x6d, + 0xb, 0x1a, 0x73, 0xd2, 0x2a, 0x9, 0x73, 0xd0, 0x5e, 0x7b, 0xd0}; + uint8_t bytesprops1[] = {0x3b, 0x3f, 0x9a, 0xf6, 0x82, 0x90, 0x8d, 0xf7, 0xe1, 0xc2, 0x7e, 0x47, 0xcc, 0xd0, 0x1e}; + uint8_t bytesprops3[] = {0x5, 0x6e, 0x9b, 0x98, 0x58, 0x4c, 0x30, 0xcf, 0xb6, 0x29, 0x7f, + 0xab, 0x1, 0xde, 0xaf, 0x0, 0xa4, 0x71, 0xf3, 0x70, 0x3b}; + uint8_t bytesprops4[] = {0xd6, 0x14, 0x18, 0x83, 0x3c, 0xc3, 0x23, 0x16, 0x27, 0x88, + 0x29, 0x97, 0x9f, 0x17, 0x8d, 0x62, 0x98, 0xc1, 0xde}; + uint8_t bytesprops5[] = {0xc7, 0xa1, 0xd5, 0x56, 0x19, 0x2a}; + uint8_t bytesprops6[] = {0xaa, 0x67, 0x1d, 0x9c, 0xe0, 0xe0, 0xaf, 0xa6, 0x1f, 0x1, 0x42, 0x7b, 0x2d, 0xe9, 0xe, + 0x3a, 0x36, 0xdc, 0x6e, 0xf2, 0x77, 0x19, 0x2e, 0x32, 0x31, 0x3b, 0x71, 0x70, 0xf}; + uint8_t bytesprops7[] = {0x20, 0x99, 0x0, 0x60, 0xec, 0x8f, 0xaa, 0x11, 0x90, 0x97, 0xa4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21761}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11810}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27354}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31127}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2689}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16049}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21820}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9762}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30730}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23599}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15159}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 95}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29415}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops1}, .v = {23, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27865}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29170}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2273}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 131, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoWildcardSubscriptionsNotSupported [PropRequestProblemInformation 151,PropMaximumQoS -// 174,PropMaximumPacketSize 25264,PropServerKeepAlive 13824,PropSubscriptionIdentifier 30,PropPayloadFormatIndicator -// 105,PropWillDelayInterval 9111,PropResponseTopic "\232@:\241o\NAK$\NAK\139b\219\188>",PropTopicAlias 200] +// DisconnectRequest DiscoUnspecifiedError [PropAuthenticationData "\184\163\&9\198\156",PropTopicAliasMaximum +// 1230,PropSubscriptionIdentifier 13,PropRequestResponseInformation 253,PropUserProperty +// "J,\148\247\205_\163n\RS\142\f\SUBs1\164\193^0\162\136z]\ETB\167O+\f9\n" "\177",PropMaximumPacketSize 4426] TEST(Disco5QCTest, Encode13) { - uint8_t pkt[] = {0xe0, 0x63, 0xa1, 0x61, 0x1, 0xe, 0x28, 0x16, 0x15, 0x0, 0xd, 0xb1, 0x5a, 0x9e, 0x2a, 0x63, 0x50, - 0x27, 0xb, 0xa6, 0x14, 0x7c, 0xc6, 0xc8, 0x28, 0x0, 0x9, 0x0, 0xd, 0xa9, 0x78, 0xca, 0xc2, 0x99, - 0xc0, 0xbd, 0x30, 0x43, 0xe2, 0xef, 0x73, 0x24, 0x22, 0x7f, 0x88, 0x15, 0x0, 0xb, 0x43, 0xcb, 0xdb, - 0x43, 0x4e, 0x72, 0x2e, 0xa6, 0xc3, 0x19, 0xb1, 0x27, 0x0, 0x0, 0x6c, 0xfa, 0x2, 0x0, 0x0, 0x21, - 0x81, 0x19, 0x4e, 0x1, 0x48, 0x28, 0xf5, 0x21, 0x35, 0x1a, 0x24, 0xaa, 0x12, 0x0, 0xf, 0x1a, 0xf6, - 0xd9, 0xdb, 0x9c, 0xa7, 0x11, 0x3e, 0x24, 0x15, 0x8b, 0x62, 0xdb, 0xbc, 0x3e, 0x23, 0x0, 0xc8}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb1, 0x5a, 0x9e, 0x2a, 0x63, 0x50, 0x27, 0xb, 0xa6, 0x14, 0x7c, 0xc6, 0xc8}; - uint8_t bytesprops1[] = {0xa9, 0x78, 0xca, 0xc2, 0x99, 0xc0, 0xbd, 0x30, 0x43, 0xe2, 0xef, 0x73, 0x24}; - uint8_t bytesprops2[] = {0x43, 0xcb, 0xdb, 0x43, 0x4e, 0x72, 0x2e, 0xa6, 0xc3, 0x19, 0xb1}; - uint8_t bytesprops3[] = {0x1a, 0xf6, 0xd9, 0xdb, 0x9c, 0xa7, 0x11, 0x3e, 0x24, 0x15, 0x8b, 0x62, 0xdb, 0xbc, 0x3e}; + uint8_t pkt[] = {0xe0, 0x39, 0x80, 0x37, 0x16, 0x0, 0x5, 0xb8, 0xa3, 0x39, 0xc6, 0x9c, 0x22, 0x4, 0xce, + 0xb, 0xd, 0x19, 0xfd, 0x26, 0x0, 0x1d, 0x4a, 0x2c, 0x94, 0xf7, 0xcd, 0x5f, 0xa3, 0x6e, + 0x1e, 0x8e, 0xc, 0x1a, 0x73, 0x31, 0xa4, 0xc1, 0x5e, 0x30, 0xa2, 0x88, 0x7a, 0x5d, 0x17, + 0xa7, 0x4f, 0x2b, 0xc, 0x39, 0xa, 0x0, 0x1, 0xb1, 0x27, 0x0, 0x0, 0x11, 0x4a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb8, 0xa3, 0x39, 0xc6, 0x9c}; + uint8_t bytesprops2[] = {0xb1}; + uint8_t bytesprops1[] = {0x4a, 0x2c, 0x94, 0xf7, 0xcd, 0x5f, 0xa3, 0x6e, 0x1e, 0x8e, 0xc, 0x1a, 0x73, 0x31, 0xa4, + 0xc1, 0x5e, 0x30, 0xa2, 0x88, 0x7a, 0x5d, 0x17, 0xa7, 0x4f, 0x2b, 0xc, 0x39, 0xa}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32648}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27898}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8577}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13594}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 200}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1230}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {1, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4426}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 161, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 128, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoRetainNotSupported [PropTopicAlias 10921] +// DisconnectRequest DiscoQoSNotSupported [PropServerReference +// "/\157\185n\153\237+P\242\147\140\182N\230|\182\DC2\255\232|_",PropMaximumPacketSize 14512,PropRetainAvailable +// 230,PropSubscriptionIdentifierAvailable 22,PropTopicAliasMaximum 7486,PropAuthenticationData +// "dr\239h\137",PropPayloadFormatIndicator 144,PropRequestResponseInformation 202,PropWillDelayInterval 18416] TEST(Disco5QCTest, Encode14) { - uint8_t pkt[] = {0xe0, 0x5, 0x9a, 0x3, 0x23, 0x2a, 0xa9}; + uint8_t pkt[] = {0xe0, 0x37, 0x9b, 0x35, 0x1c, 0x0, 0x15, 0x2f, 0x9d, 0xb9, 0x6e, 0x99, 0xed, 0x2b, 0x50, + 0xf2, 0x93, 0x8c, 0xb6, 0x4e, 0xe6, 0x7c, 0xb6, 0x12, 0xff, 0xe8, 0x7c, 0x5f, 0x27, 0x0, + 0x0, 0x38, 0xb0, 0x25, 0xe6, 0x29, 0x16, 0x22, 0x1d, 0x3e, 0x16, 0x0, 0x5, 0x64, 0x72, + 0xef, 0x68, 0x89, 0x1, 0x90, 0x19, 0xca, 0x18, 0x0, 0x0, 0x47, 0xf0}; uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x2f, 0x9d, 0xb9, 0x6e, 0x99, 0xed, 0x2b, 0x50, 0xf2, 0x93, 0x8c, + 0xb6, 0x4e, 0xe6, 0x7c, 0xb6, 0x12, 0xff, 0xe8, 0x7c, 0x5f}; + uint8_t bytesprops1[] = {0x64, 0x72, 0xef, 0x68, 0x89}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10921}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14512}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 22}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7486}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18416}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 154, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoKeepAliveTimeout [PropRequestProblemInformation 30,PropResponseInformation -// "",PropRequestProblemInformation 166,PropMessageExpiryInterval 1456,PropSubscriptionIdentifierAvailable -// 66,PropUserProperty ":\SOH|\167\136\182\154'\EML J|\184Rd" -// "\128\ACK\215\191\196\am\243\159\244u\STX\"\b\252U\182p\139\138\r@\152\206\197\220\243",PropRetainAvailable -// 226,PropAssignedClientIdentifier -// ")<\145{\253\196Oi\192\n\181\231\SO9\NUL\GS\164\192\228J\243e\185/A\252\196\153",PropResponseTopic -// "\169f\217\DC2G",PropRequestProblemInformation 51,PropSubscriptionIdentifierAvailable 25] +// DisconnectRequest DiscoSharedSubscriptionsNotSupported [PropAuthenticationData "|\157"] TEST(Disco5QCTest, Encode15) { - uint8_t pkt[] = {0xe0, 0x6d, 0x8d, 0x6b, 0x17, 0x1e, 0x1a, 0x0, 0x0, 0x17, 0xa6, 0x2, 0x0, 0x0, 0x5, 0xb0, - 0x29, 0x42, 0x26, 0x0, 0x10, 0x3a, 0x1, 0x7c, 0xa7, 0x88, 0xb6, 0x9a, 0x27, 0x19, 0x4c, 0x20, - 0x4a, 0x7c, 0xb8, 0x52, 0x64, 0x0, 0x1b, 0x80, 0x6, 0xd7, 0xbf, 0xc4, 0x7, 0x6d, 0xf3, 0x9f, - 0xf4, 0x75, 0x2, 0x22, 0x8, 0xfc, 0x55, 0xb6, 0x70, 0x8b, 0x8a, 0xd, 0x40, 0x98, 0xce, 0xc5, - 0xdc, 0xf3, 0x25, 0xe2, 0x12, 0x0, 0x1c, 0x29, 0x3c, 0x91, 0x7b, 0xfd, 0xc4, 0x4f, 0x69, 0xc0, - 0xa, 0xb5, 0xe7, 0xe, 0x39, 0x0, 0x1d, 0xa4, 0xc0, 0xe4, 0x4a, 0xf3, 0x65, 0xb9, 0x2f, 0x41, - 0xfc, 0xc4, 0x99, 0x8, 0x0, 0x5, 0xa9, 0x66, 0xd9, 0x12, 0x47, 0x17, 0x33, 0x29, 0x19}; + uint8_t pkt[] = {0xe0, 0x7, 0x9e, 0x5, 0x16, 0x0, 0x2, 0x7c, 0x9d}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops2[] = {0x80, 0x6, 0xd7, 0xbf, 0xc4, 0x7, 0x6d, 0xf3, 0x9f, 0xf4, 0x75, 0x2, 0x22, 0x8, - 0xfc, 0x55, 0xb6, 0x70, 0x8b, 0x8a, 0xd, 0x40, 0x98, 0xce, 0xc5, 0xdc, 0xf3}; - uint8_t bytesprops1[] = {0x3a, 0x1, 0x7c, 0xa7, 0x88, 0xb6, 0x9a, 0x27, - 0x19, 0x4c, 0x20, 0x4a, 0x7c, 0xb8, 0x52, 0x64}; - uint8_t bytesprops3[] = {0x29, 0x3c, 0x91, 0x7b, 0xfd, 0xc4, 0x4f, 0x69, 0xc0, 0xa, 0xb5, 0xe7, 0xe, 0x39, - 0x0, 0x1d, 0xa4, 0xc0, 0xe4, 0x4a, 0xf3, 0x65, 0xb9, 0x2f, 0x41, 0xfc, 0xc4, 0x99}; - uint8_t bytesprops4[] = {0xa9, 0x66, 0xd9, 0x12, 0x47}; + uint8_t bytesprops0[] = {0x7c, 0x9d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1456}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 66}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {27, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 51}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 141, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 158, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoWildcardSubscriptionsNotSupported [PropServerKeepAlive 21112,PropAssignedClientIdentifier -// "\203\147\245j!L\236\&9\146G\169\220\229Y\225",PropSharedSubscriptionAvailable 1,PropSessionExpiryInterval -// 27576,PropAuthenticationData "\225\ENQ\249\144H\196PN\166\EM\154\138",PropResponseInformation -// "\152\151\211|\230\CAN\235\248\DC49\\\134:\SUB\NAK\178\181\150LH\212t\253v\214\DC3\208\EOT\207\137",PropRequestProblemInformation -// 73] +// DisconnectRequest DiscoAdministrativeAction [PropRetainAvailable 93,PropTopicAliasMaximum +// 19459,PropSubscriptionIdentifier 1,PropReceiveMaximum 12710,PropAuthenticationMethod +// "\237\243F]\241",PropResponseTopic "\161\CAN\208\226w\182\253\159\&2n\135-\134",PropMessageExpiryInterval +// 13088,PropResponseTopic +// "\250\193\139\252\227$bm\SUB?\STX\ESC\254\237I\216w\213\DEL\241\244\195\US",PropWillDelayInterval +// 957,PropCorrelationData +// "\128\DC4M^\157\159\128'\129\251\253\217\226\255\198m\170z\NUL\222\165{\170^\r\229",PropSessionExpiryInterval +// 4548,PropMessageExpiryInterval 18197,PropTopicAlias 25384,PropSharedSubscriptionAvailable +// 239,PropAuthenticationMethod "+ad\r%\174\DEL\175|#\203\219\247\STX\ACK\ETB\224\139",PropSessionExpiryInterval +// 15062,PropSubscriptionIdentifierAvailable 89,PropTopicAlias 30222,PropAssignedClientIdentifier +// "3@\212\233\STX\244o\254\ETX\239\129",PropPayloadFormatIndicator 147,PropSubscriptionIdentifier +// 23,PropSubscriptionIdentifierAvailable 166,PropAssignedClientIdentifier +// "\179\205\229[\197IGa\220\146Fi\174C\180]ub\161\CANr\158\&7#\182\157Of"] TEST(Disco5QCTest, Encode16) { - uint8_t pkt[] = {0xe0, 0x50, 0xa2, 0x4e, 0x13, 0x52, 0x78, 0x12, 0x0, 0xf, 0xcb, 0x93, 0xf5, 0x6a, 0x21, 0x4c, 0xec, - 0x39, 0x92, 0x47, 0xa9, 0xdc, 0xe5, 0x59, 0xe1, 0x2a, 0x1, 0x11, 0x0, 0x0, 0x6b, 0xb8, 0x16, 0x0, - 0xc, 0xe1, 0x5, 0xf9, 0x90, 0x48, 0xc4, 0x50, 0x4e, 0xa6, 0x19, 0x9a, 0x8a, 0x1a, 0x0, 0x1e, 0x98, - 0x97, 0xd3, 0x7c, 0xe6, 0x18, 0xeb, 0xf8, 0x14, 0x39, 0x5c, 0x86, 0x3a, 0x1a, 0x15, 0xb2, 0xb5, 0x96, - 0x4c, 0x48, 0xd4, 0x74, 0xfd, 0x76, 0xd6, 0x13, 0xd0, 0x4, 0xcf, 0x89, 0x17, 0x49}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xcb, 0x93, 0xf5, 0x6a, 0x21, 0x4c, 0xec, 0x39, 0x92, 0x47, 0xa9, 0xdc, 0xe5, 0x59, 0xe1}; - uint8_t bytesprops1[] = {0xe1, 0x5, 0xf9, 0x90, 0x48, 0xc4, 0x50, 0x4e, 0xa6, 0x19, 0x9a, 0x8a}; - uint8_t bytesprops2[] = {0x98, 0x97, 0xd3, 0x7c, 0xe6, 0x18, 0xeb, 0xf8, 0x14, 0x39, 0x5c, 0x86, 0x3a, 0x1a, 0x15, - 0xb2, 0xb5, 0x96, 0x4c, 0x48, 0xd4, 0x74, 0xfd, 0x76, 0xd6, 0x13, 0xd0, 0x4, 0xcf, 0x89}; + uint8_t pkt[] = {0xe0, 0xc7, 0x1, 0x98, 0xc4, 0x1, 0x25, 0x5d, 0x22, 0x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x37, 0x23, 0xb6, 0x9d, 0x4f, 0x66}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xed, 0xf3, 0x46, 0x5d, 0xf1}; + uint8_t bytesprops1[] = {0xa1, 0x18, 0xd0, 0xe2, 0x77, 0xb6, 0xfd, 0x9f, 0x32, 0x6e, 0x87, 0x2d, 0x86}; + uint8_t bytesprops2[] = {0xfa, 0xc1, 0x8b, 0xfc, 0xe3, 0x24, 0x62, 0x6d, 0x1a, 0x3f, 0x2, 0x1b, + 0xfe, 0xed, 0x49, 0xd8, 0x77, 0xd5, 0x7f, 0xf1, 0xf4, 0xc3, 0x1f}; + uint8_t bytesprops3[] = {0x80, 0x14, 0x4d, 0x5e, 0x9d, 0x9f, 0x80, 0x27, 0x81, 0xfb, 0xfd, 0xd9, 0xe2, + 0xff, 0xc6, 0x6d, 0xaa, 0x7a, 0x0, 0xde, 0xa5, 0x7b, 0xaa, 0x5e, 0xd, 0xe5}; + uint8_t bytesprops4[] = {0x2b, 0x61, 0x64, 0xd, 0x25, 0xae, 0x7f, 0xaf, 0x7c, + 0x23, 0xcb, 0xdb, 0xf7, 0x2, 0x6, 0x17, 0xe0, 0x8b}; + uint8_t bytesprops5[] = {0x33, 0x40, 0xd4, 0xe9, 0x2, 0xf4, 0x6f, 0xfe, 0x3, 0xef, 0x81}; + uint8_t bytesprops6[] = {0xb3, 0xcd, 0xe5, 0x5b, 0xc5, 0x49, 0x47, 0x61, 0xdc, 0x92, 0x46, 0x69, 0xae, 0x43, + 0xb4, 0x5d, 0x75, 0x62, 0xa1, 0x18, 0x72, 0x9e, 0x37, 0x23, 0xb6, 0x9d, 0x4f, 0x66}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21112}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27576}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19459}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12710}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13088}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 957}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4548}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18197}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25384}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15062}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30222}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 166}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 162, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 152, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoMalformedPacket [PropAuthenticationMethod -// "\227\221a\197\144\178J\169\218x\205\239F\156\203S\219\STX"] +// DisconnectRequest DiscoAdministrativeAction [PropWillDelayInterval 17096,PropUserProperty "\157\187\141L\EMf" +// ":\SO+0\131\DC3\STXxw\244\154\185\ETB^\202\218pn!\231\ENQd\250\130\&6\136\233/\155\SI",PropCorrelationData +// "\131\175\220\169\210R\SI\253W$\168\157\227V\241\146\249\174q \208\157\186\251",PropServerKeepAlive +// 13699,PropSubscriptionIdentifier 24,PropServerReference "\EMA\ETB",PropRequestProblemInformation +// 190,PropRequestResponseInformation 140,PropUserProperty "\221\246\207" "\176",PropSessionExpiryInterval +// 16599,PropSessionExpiryInterval 15959,PropAuthenticationMethod +// "\v\246\201\&3Q\213\154\a\221~sZje\177\\=W(\197\244%\243\&2\136F.",PropResponseInformation +// ".\202\ESC\228]\188\247\SUBA\NAK\165%*\ETB\227v\254\245\178\196",PropMessageExpiryInterval 6008,PropWillDelayInterval +// 31345,PropSubscriptionIdentifier 19,PropSubscriptionIdentifierAvailable 135,PropTopicAlias 26339,PropMaximumQoS +// 121,PropContentType "{\156N\224\FS\255u\DC1j\158\NUL\DC4\194\224",PropReceiveMaximum 7053,PropPayloadFormatIndicator +// 198,PropMessageExpiryInterval 17414,PropAuthenticationMethod "\250\235\143\192",PropContentType +// "\221;\146\&1\DC4\SOHP\189)\187\DC4 \t~\216gAf\DC1\147B| >~\210Y\167",PropWillDelayInterval 24883] TEST(Disco5QCTest, Encode17) { - uint8_t pkt[] = {0xe0, 0x17, 0x81, 0x15, 0x15, 0x0, 0x12, 0xe3, 0xdd, 0x61, 0xc5, 0x90, 0xb2, - 0x4a, 0xa9, 0xda, 0x78, 0xcd, 0xef, 0x46, 0x9c, 0xcb, 0x53, 0xdb, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe3, 0xdd, 0x61, 0xc5, 0x90, 0xb2, 0x4a, 0xa9, 0xda, - 0x78, 0xcd, 0xef, 0x46, 0x9c, 0xcb, 0x53, 0xdb, 0x2}; + uint8_t pkt[] = { + 0xe0, 0xfc, 0x1, 0x98, 0xf9, 0x1, 0x18, 0x0, 0x0, 0x42, 0xc8, 0x26, 0x0, 0x6, 0x9d, 0xbb, 0x8d, 0x4c, 0x19, + 0x66, 0x0, 0x1e, 0x3a, 0xe, 0x2b, 0x30, 0x83, 0x13, 0x2, 0x78, 0x77, 0xf4, 0x9a, 0xb9, 0x17, 0x5e, 0xca, 0xda, + 0x70, 0x6e, 0x21, 0xe7, 0x5, 0x64, 0xfa, 0x82, 0x36, 0x88, 0xe9, 0x2f, 0x9b, 0xf, 0x9, 0x0, 0x18, 0x83, 0xaf, + 0xdc, 0xa9, 0xd2, 0x52, 0xf, 0xfd, 0x57, 0x24, 0xa8, 0x9d, 0xe3, 0x56, 0xf1, 0x92, 0xf9, 0xae, 0x71, 0x20, 0xd0, + 0x9d, 0xba, 0xfb, 0x13, 0x35, 0x83, 0xb, 0x18, 0x1c, 0x0, 0x3, 0x19, 0x41, 0x17, 0x17, 0xbe, 0x19, 0x8c, 0x26, + 0x0, 0x3, 0xdd, 0xf6, 0xcf, 0x0, 0x1, 0xb0, 0x11, 0x0, 0x0, 0x40, 0xd7, 0x11, 0x0, 0x0, 0x3e, 0x57, 0x15, + 0x0, 0x1b, 0xb, 0xf6, 0xc9, 0x33, 0x51, 0xd5, 0x9a, 0x7, 0xdd, 0x7e, 0x73, 0x5a, 0x6a, 0x65, 0xb1, 0x5c, 0x3d, + 0x57, 0x28, 0xc5, 0xf4, 0x25, 0xf3, 0x32, 0x88, 0x46, 0x2e, 0x1a, 0x0, 0x14, 0x2e, 0xca, 0x1b, 0xe4, 0x5d, 0xbc, + 0xf7, 0x1a, 0x41, 0x15, 0xa5, 0x25, 0x2a, 0x17, 0xe3, 0x76, 0xfe, 0xf5, 0xb2, 0xc4, 0x2, 0x0, 0x0, 0x17, 0x78, + 0x18, 0x0, 0x0, 0x7a, 0x71, 0xb, 0x13, 0x29, 0x87, 0x23, 0x66, 0xe3, 0x24, 0x79, 0x3, 0x0, 0xe, 0x7b, 0x9c, + 0x4e, 0xe0, 0x1c, 0xff, 0x75, 0x11, 0x6a, 0x9e, 0x0, 0x14, 0xc2, 0xe0, 0x21, 0x1b, 0x8d, 0x1, 0xc6, 0x2, 0x0, + 0x0, 0x44, 0x6, 0x15, 0x0, 0x4, 0xfa, 0xeb, 0x8f, 0xc0, 0x3, 0x0, 0x1c, 0xdd, 0x3b, 0x92, 0x31, 0x14, 0x1, + 0x50, 0xbd, 0x29, 0xbb, 0x14, 0x20, 0x9, 0x7e, 0xd8, 0x67, 0x41, 0x66, 0x11, 0x93, 0x42, 0x7c, 0x20, 0x3e, 0x7e, + 0xd2, 0x59, 0xa7, 0x18, 0x0, 0x0, 0x61, 0x33}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x3a, 0xe, 0x2b, 0x30, 0x83, 0x13, 0x2, 0x78, 0x77, 0xf4, 0x9a, 0xb9, 0x17, 0x5e, 0xca, + 0xda, 0x70, 0x6e, 0x21, 0xe7, 0x5, 0x64, 0xfa, 0x82, 0x36, 0x88, 0xe9, 0x2f, 0x9b, 0xf}; + uint8_t bytesprops0[] = {0x9d, 0xbb, 0x8d, 0x4c, 0x19, 0x66}; + uint8_t bytesprops2[] = {0x83, 0xaf, 0xdc, 0xa9, 0xd2, 0x52, 0xf, 0xfd, 0x57, 0x24, 0xa8, 0x9d, + 0xe3, 0x56, 0xf1, 0x92, 0xf9, 0xae, 0x71, 0x20, 0xd0, 0x9d, 0xba, 0xfb}; + uint8_t bytesprops3[] = {0x19, 0x41, 0x17}; + uint8_t bytesprops5[] = {0xb0}; + uint8_t bytesprops4[] = {0xdd, 0xf6, 0xcf}; + uint8_t bytesprops6[] = {0xb, 0xf6, 0xc9, 0x33, 0x51, 0xd5, 0x9a, 0x7, 0xdd, 0x7e, 0x73, 0x5a, 0x6a, 0x65, + 0xb1, 0x5c, 0x3d, 0x57, 0x28, 0xc5, 0xf4, 0x25, 0xf3, 0x32, 0x88, 0x46, 0x2e}; + uint8_t bytesprops7[] = {0x2e, 0xca, 0x1b, 0xe4, 0x5d, 0xbc, 0xf7, 0x1a, 0x41, 0x15, + 0xa5, 0x25, 0x2a, 0x17, 0xe3, 0x76, 0xfe, 0xf5, 0xb2, 0xc4}; + uint8_t bytesprops8[] = {0x7b, 0x9c, 0x4e, 0xe0, 0x1c, 0xff, 0x75, 0x11, 0x6a, 0x9e, 0x0, 0x14, 0xc2, 0xe0}; + uint8_t bytesprops9[] = {0xfa, 0xeb, 0x8f, 0xc0}; + uint8_t bytesprops10[] = {0xdd, 0x3b, 0x92, 0x31, 0x14, 0x1, 0x50, 0xbd, 0x29, 0xbb, 0x14, 0x20, 0x9, 0x7e, + 0xd8, 0x67, 0x41, 0x66, 0x11, 0x93, 0x42, 0x7c, 0x20, 0x3e, 0x7e, 0xd2, 0x59, 0xa7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17096}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {30, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13699}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops4}, .v = {1, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16599}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15959}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6008}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31345}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26339}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7053}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17414}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24883}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 129, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 152, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoServerBusy [PropCorrelationData -// "\242\168\171&\RS\132\166\131\176\220\230\252\155\RS\ACK\162\&4,s\160\131\&4\197",PropAuthenticationData -// "",PropContentType "m 0\129\192cM\134\143\211\193\168\174\235i3t\219\DEL\149B\165",PropSubscriptionIdentifier -// 2,PropUserProperty "O\164z\NULJC\EM\234\155a3\139\&6kk\214\161\129F\146\&1\140" -// "\156\241",PropRequestResponseInformation 44,PropWillDelayInterval 30451,PropServerKeepAlive 24287] +// DisconnectRequest DiscoPacketTooLarge [PropSharedSubscriptionAvailable 20] TEST(Disco5QCTest, Encode18) { - uint8_t pkt[] = {0xe0, 0x61, 0x89, 0x5f, 0x9, 0x0, 0x17, 0xf2, 0xa8, 0xab, 0x26, 0x1e, 0x84, 0xa6, 0x83, 0xb0, 0xdc, - 0xe6, 0xfc, 0x9b, 0x1e, 0x6, 0xa2, 0x34, 0x2c, 0x73, 0xa0, 0x83, 0x34, 0xc5, 0x16, 0x0, 0x0, 0x3, - 0x0, 0x16, 0x6d, 0x20, 0x30, 0x81, 0xc0, 0x63, 0x4d, 0x86, 0x8f, 0xd3, 0xc1, 0xa8, 0xae, 0xeb, 0x69, - 0x33, 0x74, 0xdb, 0x7f, 0x95, 0x42, 0xa5, 0xb, 0x2, 0x26, 0x0, 0x16, 0x4f, 0xa4, 0x7a, 0x0, 0x4a, - 0x43, 0x19, 0xea, 0x9b, 0x61, 0x33, 0x8b, 0x36, 0x6b, 0x6b, 0xd6, 0xa1, 0x81, 0x46, 0x92, 0x31, 0x8c, - 0x0, 0x2, 0x9c, 0xf1, 0x19, 0x2c, 0x18, 0x0, 0x0, 0x76, 0xf3, 0x13, 0x5e, 0xdf}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf2, 0xa8, 0xab, 0x26, 0x1e, 0x84, 0xa6, 0x83, 0xb0, 0xdc, 0xe6, 0xfc, - 0x9b, 0x1e, 0x6, 0xa2, 0x34, 0x2c, 0x73, 0xa0, 0x83, 0x34, 0xc5}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x6d, 0x20, 0x30, 0x81, 0xc0, 0x63, 0x4d, 0x86, 0x8f, 0xd3, 0xc1, - 0xa8, 0xae, 0xeb, 0x69, 0x33, 0x74, 0xdb, 0x7f, 0x95, 0x42, 0xa5}; - uint8_t bytesprops4[] = {0x9c, 0xf1}; - uint8_t bytesprops3[] = {0x4f, 0xa4, 0x7a, 0x0, 0x4a, 0x43, 0x19, 0xea, 0x9b, 0x61, 0x33, - 0x8b, 0x36, 0x6b, 0x6b, 0xd6, 0xa1, 0x81, 0x46, 0x92, 0x31, 0x8c}; + uint8_t pkt[] = {0xe0, 0x4, 0x95, 0x2, 0x2a, 0x14}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops3}, .v = {2, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30451}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24287}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 137, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 149, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoDisconnectWithWill [PropWillDelayInterval 27833,PropResponseInformation -// "|&d\n\193\232\187\207o9c\230\GS\203\174Y\228\RS\204\152\DLE\RSZk\255v\190",PropAssignedClientIdentifier -// "\244\218eE\228\160\159`\DC2\202\138\143V}\219\&3\152\ETX",PropTopicAliasMaximum 9595,PropSubscriptionIdentifier 7] +// DisconnectRequest DiscoAdministrativeAction [PropReasonString +// "*%\v\STX\204\176\&7\DC1\197`^\235r\131q\134\n\185^\RS\154Bt?k\182",PropResponseInformation +// "@\186\132",PropSubscriptionIdentifier 15,PropReceiveMaximum 18394,PropRequestProblemInformation +// 41,PropServerReference ",\fk",PropRequestProblemInformation 18,PropTopicAlias 6053,PropAssignedClientIdentifier +// "\233\NAKu\136",PropMessageExpiryInterval 4488,PropRequestResponseInformation 96,PropSubscriptionIdentifier +// 11,PropSubscriptionIdentifierAvailable 115,PropAuthenticationData +// "\241\v-\215\166\183,\176\194\216\243\178\168=6e\221y\240Q\167\180\US\NAK\128\DEL\128\146\250\171",PropCorrelationData +// "#dC\CAN\STXC",PropMaximumPacketSize 6841,PropRequestResponseInformation 81,PropTopicAlias 4335,PropUserProperty +// "\161\197\v\212\228\253\173\249r\GSPP:" "8|\243\233V\247\162\203\DC3\161",PropUserProperty +// "\211\&7\200d#\218yQ\229\DEL$\n\209\233\ESC\220\v\191" "{5\241\195",PropRetainAvailable 139,PropServerKeepAlive +// 29153,PropResponseTopic "\241\v\198Z:\202\242\181UB\188\&46",PropTopicAlias 12740,PropAuthenticationData +// "\STX\191\ETB\223\190\SIC}\205\ESCzE"] TEST(Disco5QCTest, Encode19) { - uint8_t pkt[] = {0xe0, 0x3f, 0x4, 0x3d, 0x18, 0x0, 0x0, 0x6c, 0xb9, 0x1a, 0x0, 0x1b, 0x7c, 0x26, 0x64, 0xa, 0xc1, - 0xe8, 0xbb, 0xcf, 0x6f, 0x39, 0x63, 0xe6, 0x1d, 0xcb, 0xae, 0x59, 0xe4, 0x1e, 0xcc, 0x98, 0x10, 0x1e, - 0x5a, 0x6b, 0xff, 0x76, 0xbe, 0x12, 0x0, 0x12, 0xf4, 0xda, 0x65, 0x45, 0xe4, 0xa0, 0x9f, 0x60, 0x12, - 0xca, 0x8a, 0x8f, 0x56, 0x7d, 0xdb, 0x33, 0x98, 0x3, 0x22, 0x25, 0x7b, 0xb, 0x7}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7c, 0x26, 0x64, 0xa, 0xc1, 0xe8, 0xbb, 0xcf, 0x6f, 0x39, 0x63, 0xe6, 0x1d, 0xcb, - 0xae, 0x59, 0xe4, 0x1e, 0xcc, 0x98, 0x10, 0x1e, 0x5a, 0x6b, 0xff, 0x76, 0xbe}; - uint8_t bytesprops1[] = {0xf4, 0xda, 0x65, 0x45, 0xe4, 0xa0, 0x9f, 0x60, 0x12, - 0xca, 0x8a, 0x8f, 0x56, 0x7d, 0xdb, 0x33, 0x98, 0x3}; + uint8_t pkt[] = { + 0xe0, 0xdc, 0x1, 0x98, 0xd9, 0x1, 0x1f, 0x0, 0x1a, 0x2a, 0x25, 0xb, 0x2, 0xcc, 0xb0, 0x37, 0x11, 0xc5, 0x60, + 0x5e, 0xeb, 0x72, 0x83, 0x71, 0x86, 0xa, 0xb9, 0x5e, 0x1e, 0x9a, 0x42, 0x74, 0x3f, 0x6b, 0xb6, 0x1a, 0x0, 0x3, + 0x40, 0xba, 0x84, 0xb, 0xf, 0x21, 0x47, 0xda, 0x17, 0x29, 0x1c, 0x0, 0x3, 0x2c, 0xc, 0x6b, 0x17, 0x12, 0x23, + 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83, 0x71, 0x86, 0xa, 0xb9, 0x5e, 0x1e, 0x9a, 0x42, 0x74, 0x3f, 0x6b, 0xb6}; + uint8_t bytesprops1[] = {0x40, 0xba, 0x84}; + uint8_t bytesprops2[] = {0x2c, 0xc, 0x6b}; + uint8_t bytesprops3[] = {0xe9, 0x15, 0x75, 0x88}; + uint8_t bytesprops4[] = {0xf1, 0xb, 0x2d, 0xd7, 0xa6, 0xb7, 0x2c, 0xb0, 0xc2, 0xd8, 0xf3, 0xb2, 0xa8, 0x3d, 0x36, + 0x65, 0xdd, 0x79, 0xf0, 0x51, 0xa7, 0xb4, 0x1f, 0x15, 0x80, 0x7f, 0x80, 0x92, 0xfa, 0xab}; + uint8_t bytesprops5[] = {0x23, 0x64, 0x43, 0x18, 0x2, 0x43}; + uint8_t bytesprops7[] = {0x38, 0x7c, 0xf3, 0xe9, 0x56, 0xf7, 0xa2, 0xcb, 0x13, 0xa1}; + uint8_t bytesprops6[] = {0xa1, 0xc5, 0xb, 0xd4, 0xe4, 0xfd, 0xad, 0xf9, 0x72, 0x1d, 0x50, 0x50, 0x3a}; + uint8_t bytesprops9[] = {0x7b, 0x35, 0xf1, 0xc3}; + uint8_t bytesprops8[] = {0xd3, 0x37, 0xc8, 0x64, 0x23, 0xda, 0x79, 0x51, 0xe5, + 0x7f, 0x24, 0xa, 0xd1, 0xe9, 0x1b, 0xdc, 0xb, 0xbf}; + uint8_t bytesprops10[] = {0xf1, 0xb, 0xc6, 0x5a, 0x3a, 0xca, 0xf2, 0xb5, 0x55, 0x42, 0xbc, 0x34, 0x36}; + uint8_t bytesprops11[] = {0x2, 0xbf, 0x17, 0xdf, 0xbe, 0xf, 0x43, 0x7d, 0xcd, 0x1b, 0x7a, 0x45}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27833}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9595}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18394}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6053}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4488}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6841}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4335}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops6}, .v = {10, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops8}, .v = {4, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29153}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12740}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 152, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoTopicNameInvalid [PropPayloadFormatIndicator 242,PropTopicAlias -// 3083,PropSubscriptionIdentifier 17] +// DisconnectRequest DiscoNormalDisconnection [PropRetainAvailable 93,PropSubscriptionIdentifier +// 21,PropTopicAliasMaximum 19035,PropWildcardSubscriptionAvailable 184,PropServerReference +// "\133ig\197{\208\129\247\&9\244\&21jr\US:}V\229\188W\143\&7\129",PropRequestProblemInformation 68,PropContentType +// "\251\175\248\187jOr\173\187]\191\201\DLE-;\200v\212\196\224",PropCorrelationData +// "i\167\197\143\129\191\150\RS\r\DC3\223\141\&5\211W\135\132\&1%Y\221\220\215=B^\202rx",PropRequestResponseInformation +// 42,PropTopicAlias 797,PropReceiveMaximum 12309,PropRequestProblemInformation 35,PropServerKeepAlive +// 12065,PropResponseInformation "\153v\212w\132_\221\239\157\208\135",PropSessionExpiryInterval +// 8886,PropAuthenticationData +// "\129<\DELu\EM\207l\200h69B\181\229Z\143\191\191\130\140\238\241\EM",PropMaximumPacketSize 8070,PropWillDelayInterval +// 9412,PropReceiveMaximum 20391,PropResponseInformation +// "\ETB\139\193\223\v\v\177\204\214\252\r\163\157.\\\133",PropWillDelayInterval 19132] TEST(Disco5QCTest, Encode20) { - uint8_t pkt[] = {0xe0, 0x9, 0x90, 0x7, 0x1, 0xf2, 0x23, 0xc, 0xb, 0xb, 0x11}; - uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t pkt[] = { + 0xe0, 0xe0, 0x1, 0x0, 0xdd, 0x1, 0x25, 0x5d, 0xb, 0x15, 0x22, 0x4a, 0x5b, 0x28, 0xb8, 0x1c, 0x0, 0x18, 0x85, + 0x69, 0x67, 0xc5, 0x7b, 0xd0, 0x81, 0xf7, 0x39, 0xf4, 0x32, 0x31, 0x6a, 0x72, 0x1f, 0x3a, 0x7d, 0x56, 0xe5, 0xbc, + 0x57, 0x8f, 0x37, 0x81, 0x17, 0x44, 0x3, 0x0, 0x14, 0xfb, 0xaf, 0xf8, 0xbb, 0x6a, 0x4f, 0x72, 0xad, 0xbb, 0x5d, + 0xbf, 0xc9, 0x10, 0x2d, 0x3b, 0xc8, 0x76, 0xd4, 0xc4, 0xe0, 0x9, 0x0, 0x1d, 0x69, 0xa7, 0xc5, 0x8f, 0x81, 0xbf, + 0x96, 0x1e, 0xd, 0x13, 0xdf, 0x8d, 0x35, 0xd3, 0x57, 0x87, 0x84, 0x31, 0x25, 0x59, 0xdd, 0xdc, 0xd7, 0x3d, 0x42, + 0x5e, 0xca, 0x72, 0x78, 0x19, 0x2a, 0x23, 0x3, 0x1d, 0x21, 0x30, 0x15, 0x17, 0x23, 0x13, 0x2f, 0x21, 0x1a, 0x0, + 0xb, 0x99, 0x76, 0xd4, 0x77, 0x84, 0x5f, 0xdd, 0xef, 0x9d, 0xd0, 0x87, 0x11, 0x0, 0x0, 0x22, 0xb6, 0x16, 0x0, + 0x17, 0x81, 0x3c, 0x7f, 0x75, 0x19, 0xcf, 0x6c, 0xc8, 0x68, 0x36, 0x39, 0x42, 0xb5, 0xe5, 0x5a, 0x8f, 0xbf, 0xbf, + 0x82, 0x8c, 0xee, 0xf1, 0x19, 0x27, 0x0, 0x0, 0x1f, 0x86, 0x18, 0x0, 0x0, 0x24, 0xc4, 0x21, 0x4f, 0xa7, 0x1a, + 0x0, 0x1c, 0x17, 0x8b, 0xc1, 0xdf, 0xb, 0xb, 0xb1, 0xcc, 0xd6, 0xfc, 0x3c, 0x67, 0x8a, 0x63, 0x79, 0x47, 0xa0, + 0x30, 0xef, 0xa6, 0x1d, 0xe8, 0x98, 0x17, 0x27, 0xab, 0xfe, 0xbe, 0x1a, 0x0, 0x12, 0x51, 0x71, 0xf, 0x3, 0xf6, + 0x98, 0xca, 0x8b, 0x42, 0xb9, 0x1, 0x3e, 0xd, 0xa3, 0x9d, 0x2e, 0x5c, 0x85, 0x18, 0x0, 0x0, 0x4a, 0xbc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x85, 0x69, 0x67, 0xc5, 0x7b, 0xd0, 0x81, 0xf7, 0x39, 0xf4, 0x32, 0x31, + 0x6a, 0x72, 0x1f, 0x3a, 0x7d, 0x56, 0xe5, 0xbc, 0x57, 0x8f, 0x37, 0x81}; + uint8_t bytesprops1[] = {0xfb, 0xaf, 0xf8, 0xbb, 0x6a, 0x4f, 0x72, 0xad, 0xbb, 0x5d, + 0xbf, 0xc9, 0x10, 0x2d, 0x3b, 0xc8, 0x76, 0xd4, 0xc4, 0xe0}; + uint8_t bytesprops2[] = {0x69, 0xa7, 0xc5, 0x8f, 0x81, 0xbf, 0x96, 0x1e, 0xd, 0x13, 0xdf, 0x8d, 0x35, 0xd3, 0x57, + 0x87, 0x84, 0x31, 0x25, 0x59, 0xdd, 0xdc, 0xd7, 0x3d, 0x42, 0x5e, 0xca, 0x72, 0x78}; + uint8_t bytesprops3[] = {0x99, 0x76, 0xd4, 0x77, 0x84, 0x5f, 0xdd, 0xef, 0x9d, 0xd0, 0x87}; + uint8_t bytesprops4[] = {0x81, 0x3c, 0x7f, 0x75, 0x19, 0xcf, 0x6c, 0xc8, 0x68, 0x36, 0x39, 0x42, + 0xb5, 0xe5, 0x5a, 0x8f, 0xbf, 0xbf, 0x82, 0x8c, 0xee, 0xf1, 0x19}; + uint8_t bytesprops5[] = {0x17, 0x8b, 0xc1, 0xdf, 0xb, 0xb, 0xb1, 0xcc, 0xd6, 0xfc, 0x3c, 0x67, 0x8a, 0x63, + 0x79, 0x47, 0xa0, 0x30, 0xef, 0xa6, 0x1d, 0xe8, 0x98, 0x17, 0x27, 0xab, 0xfe, 0xbe}; + uint8_t bytesprops6[] = {0x51, 0x71, 0xf, 0x3, 0xf6, 0x98, 0xca, 0x8b, 0x42, + 0xb9, 0x1, 0x3e, 0xd, 0xa3, 0x9d, 0x2e, 0x5c, 0x85}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3083}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19035}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 797}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12309}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12065}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8886}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8070}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9412}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20391}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19132}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoReceiveMaximumExceeded [PropMaximumQoS 118,PropReceiveMaximum 6069,PropServerReference -// "\189\&3`\210\132\222\203\SOH\153>F6\156\244Ll3an.\178\STX\240\227\186: ",PropRequestProblemInformation -// 52,PropServerKeepAlive 8463,PropWillDelayInterval 16370,PropWildcardSubscriptionAvailable -// 78,PropSubscriptionIdentifier 25,PropAuthenticationMethod -// "\150\bs\128\128\233T\US\SI\164\223\ENQ\FS\174^=\153\&2g\136'\190#\254",PropAuthenticationMethod -// "rn\128\&8F\206\154{\185\206\153>@",PropMessageExpiryInterval 25716,PropUserProperty -// "\174F\215\140j\DC1:\183g\171!\155\216\132\244\DC4\229\aQ\176\141\159\&7!" -// "S\162\146\205\n\213\183\174\ACK\154P\\\USg",PropMaximumQoS 90,PropReceiveMaximum -// 16541,PropSharedSubscriptionAvailable 103,PropAssignedClientIdentifier "\250\145\225\187DQ",PropCorrelationData -// "J\SYN7\194S\218\181\"\231\135\\\145\167\186\&0\167Y\b\b\ETBh\US\225",PropMaximumPacketSize -// 14554,PropResponseInformation "\206\GS\195",PropTopicAlias 10203,PropSubscriptionIdentifierAvailable -// 102,PropTopicAliasMaximum 18623,PropContentType -// "\197\173\166\250\171\168\165$|:|\237s\STXL\169x\DC3\232\136\&2\182\254\221\STX\241?\194"] +// DisconnectRequest DiscoUnspecifiedError [PropRequestProblemInformation 0,PropAssignedClientIdentifier +// "\DC4\250y/=U=e\252A\192\223\149\138\242",PropTopicAliasMaximum 15098,PropSubscriptionIdentifier +// 16,PropServerKeepAlive 28733,PropServerReference "\224\DC3\177\f\212\158\168\191\195",PropMaximumPacketSize +// 24280,PropRequestResponseInformation 23,PropContentType "\189@\216\247\SO\137\194\DC3\250\139JD\204 +// \225P\\\234\&9a\203",PropSessionExpiryInterval 20827,PropResponseTopic "Pl;\169S\149",PropContentType +// "\180\251\132\248D\129\139\249z\134\174\154\229\214\215LW",PropUserProperty +// "4A?\231y\240Z\227#*\128\201\190\b\181\250\150\226\191\239\242m\157g\ESC" "z\251\DEL\182",PropServerKeepAlive +// 15182,PropContentType "",PropResponseTopic +// "\DC4g\173\223\151X\219\175*oAp3\139\233z\231\178P\128\215+\250\249\153\137\163\b",PropSharedSubscriptionAvailable +// 20,PropAuthenticationMethod "\163}%\178\155y\201\DC4\146."] TEST(Disco5QCTest, Encode21) { - uint8_t pkt[] = { - 0xe0, 0xeb, 0x1, 0x93, 0xe8, 0x1, 0x24, 0x76, 0x21, 0x17, 0xb5, 0x1c, 0x0, 0x1b, 0xbd, 0x33, 0x60, 0xd2, 0x84, - 0xde, 0xcb, 0x1, 0x99, 0x3e, 0x46, 0x36, 0x9c, 0xf4, 0x4c, 0x6c, 0x33, 0x61, 0x6e, 0x2e, 0xb2, 0x2, 0xf0, 0xe3, - 0xba, 0x3a, 0x20, 0x17, 0x34, 0x13, 0x21, 0xf, 0x18, 0x0, 0x0, 0x3f, 0xf2, 0x28, 0x4e, 0xb, 0x19, 0x15, 0x0, - 0x18, 0x96, 0x8, 0x73, 0x80, 0x80, 0xe9, 0x54, 0x1f, 0xf, 0xa4, 0xdf, 0x5, 0x1c, 0xae, 0x5e, 0x3d, 0x99, 0x32, - 0x67, 0x88, 0x27, 0xbe, 0x23, 0xfe, 0x15, 0x0, 0xd, 0x72, 0x6e, 0x80, 0x38, 0x46, 0xce, 0x9a, 0x7b, 0xb9, 0xce, - 0x99, 0x3e, 0x40, 0x2, 0x0, 0x0, 0x64, 0x74, 0x26, 0x0, 0x18, 0xae, 0x46, 0xd7, 0x8c, 0x6a, 0x11, 0x3a, 0xb7, - 0x67, 0xab, 0x21, 0x9b, 0xd8, 0x84, 0xf4, 0x14, 0xe5, 0x7, 0x51, 0xb0, 0x8d, 0x9f, 0x37, 0x21, 0x0, 0xe, 0x53, - 0xa2, 0x92, 0xcd, 0xa, 0xd5, 0xb7, 0xae, 0x6, 0x9a, 0x50, 0x5c, 0x1f, 0x67, 0x24, 0x5a, 0x21, 0x40, 0x9d, 0x2a, - 0x67, 0x12, 0x0, 0x6, 0xfa, 0x91, 0xe1, 0xbb, 0x44, 0x51, 0x9, 0x0, 0x17, 0x4a, 0x16, 0x37, 0xc2, 0x53, 0xda, - 0xb5, 0x22, 0xe7, 0x87, 0x5c, 0x91, 0xa7, 0xba, 0x30, 0xa7, 0x59, 0x8, 0x8, 0x17, 0x68, 0x1f, 0xe1, 0x27, 0x0, - 0x0, 0x38, 0xda, 0x1a, 0x0, 0x3, 0xce, 0x1d, 0xc3, 0x23, 0x27, 0xdb, 0x29, 0x66, 0x22, 0x48, 0xbf, 0x3, 0x0, - 0x1c, 0xc5, 0xad, 0xa6, 0xfa, 0xab, 0xa8, 0xa5, 0x24, 0x7c, 0x3a, 0x7c, 0xed, 0x73, 0x2, 0x4c, 0xa9, 0x78, 0x13, - 0xe8, 0x88, 0x32, 0xb6, 0xfe, 0xdd, 0x2, 0xf1, 0x3f, 0xc2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xbd, 0x33, 0x60, 0xd2, 0x84, 0xde, 0xcb, 0x1, 0x99, 0x3e, 0x46, 0x36, 0x9c, 0xf4, - 0x4c, 0x6c, 0x33, 0x61, 0x6e, 0x2e, 0xb2, 0x2, 0xf0, 0xe3, 0xba, 0x3a, 0x20}; - uint8_t bytesprops1[] = {0x96, 0x8, 0x73, 0x80, 0x80, 0xe9, 0x54, 0x1f, 0xf, 0xa4, 0xdf, 0x5, - 0x1c, 0xae, 0x5e, 0x3d, 0x99, 0x32, 0x67, 0x88, 0x27, 0xbe, 0x23, 0xfe}; - uint8_t bytesprops2[] = {0x72, 0x6e, 0x80, 0x38, 0x46, 0xce, 0x9a, 0x7b, 0xb9, 0xce, 0x99, 0x3e, 0x40}; - uint8_t bytesprops4[] = {0x53, 0xa2, 0x92, 0xcd, 0xa, 0xd5, 0xb7, 0xae, 0x6, 0x9a, 0x50, 0x5c, 0x1f, 0x67}; - uint8_t bytesprops3[] = {0xae, 0x46, 0xd7, 0x8c, 0x6a, 0x11, 0x3a, 0xb7, 0x67, 0xab, 0x21, 0x9b, - 0xd8, 0x84, 0xf4, 0x14, 0xe5, 0x7, 0x51, 0xb0, 0x8d, 0x9f, 0x37, 0x21}; - uint8_t bytesprops5[] = {0xfa, 0x91, 0xe1, 0xbb, 0x44, 0x51}; - uint8_t bytesprops6[] = {0x4a, 0x16, 0x37, 0xc2, 0x53, 0xda, 0xb5, 0x22, 0xe7, 0x87, 0x5c, 0x91, - 0xa7, 0xba, 0x30, 0xa7, 0x59, 0x8, 0x8, 0x17, 0x68, 0x1f, 0xe1}; - uint8_t bytesprops7[] = {0xce, 0x1d, 0xc3}; - uint8_t bytesprops8[] = {0xc5, 0xad, 0xa6, 0xfa, 0xab, 0xa8, 0xa5, 0x24, 0x7c, 0x3a, 0x7c, 0xed, 0x73, 0x2, - 0x4c, 0xa9, 0x78, 0x13, 0xe8, 0x88, 0x32, 0xb6, 0xfe, 0xdd, 0x2, 0xf1, 0x3f, 0xc2}; + uint8_t pkt[] = {0x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x0, 0xa, + 0xa3, 0x7d, 0x25, 0xb2, 0x9b, 0x79, 0xc9, 0x14, 0x92, 0x2e}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x14, 0xfa, 0x79, 0x2f, 0x3d, 0x55, 0x3d, 0x65, 0xfc, 0x41, 0xc0, 0xdf, 0x95, 0x8a, 0xf2}; + uint8_t bytesprops1[] = {0xe0, 0x13, 0xb1, 0xc, 0xd4, 0x9e, 0xa8, 0xbf, 0xc3}; + uint8_t bytesprops2[] = {0xbd, 0x40, 0xd8, 0xf7, 0xe, 0x89, 0xc2, 0x13, 0xfa, 0x8b, 0x4a, + 0x44, 0xcc, 0x20, 0xe1, 0x50, 0x5c, 0xea, 0x39, 0x61, 0xcb}; + uint8_t bytesprops3[] = {0x50, 0x6c, 0x3b, 0xa9, 0x53, 0x95}; + uint8_t bytesprops4[] = {0xb4, 0xfb, 0x84, 0xf8, 0x44, 0x81, 0x8b, 0xf9, 0x7a, + 0x86, 0xae, 0x9a, 0xe5, 0xd6, 0xd7, 0x4c, 0x57}; + uint8_t bytesprops6[] = {0x7a, 0xfb, 0x7f, 0xb6}; + uint8_t bytesprops5[] = {0x34, 0x41, 0x3f, 0xe7, 0x79, 0xf0, 0x5a, 0xe3, 0x23, 0x2a, 0x80, 0xc9, 0xbe, + 0x8, 0xb5, 0xfa, 0x96, 0xe2, 0xbf, 0xef, 0xf2, 0x6d, 0x9d, 0x67, 0x1b}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops8[] = {0x14, 0x67, 0xad, 0xdf, 0x97, 0x58, 0xdb, 0xaf, 0x2a, 0x6f, 0x41, 0x70, 0x33, 0x8b, + 0xe9, 0x7a, 0xe7, 0xb2, 0x50, 0x80, 0xd7, 0x2b, 0xfa, 0xf9, 0x99, 0x89, 0xa3, 0x8}; + uint8_t bytesprops9[] = {0xa3, 0x7d, 0x25, 0xb2, 0x9b, 0x79, 0xc9, 0x14, 0x92, 0x2e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6069}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8463}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16370}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25716}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops3}, .v = {14, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16541}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14554}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10203}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18623}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15098}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28733}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24280}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20827}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops5}, .v = {4, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15182}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 147, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 128, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoNormalDisconnection [PropAssignedClientIdentifier -// "$\187:\SOH\237\204\231\196G",PropSessionExpiryInterval 18636,PropAssignedClientIdentifier -// "\ETXTo5\144\186",PropMaximumPacketSize 7534,PropReceiveMaximum 16577,PropMessageExpiryInterval -// 6685,PropRetainAvailable 107,PropRequestProblemInformation 90,PropAssignedClientIdentifier -// "*X\SOH\EOTl\US\SUB\148",PropPayloadFormatIndicator 73,PropContentType -// "\171\162\137\USX\b-a\a\190\nt\FS\175\DC4pqNv\208S\152I\159\&0",PropMaximumPacketSize -// 19535,PropSubscriptionIdentifier 9,PropResponseInformation "\228\198qN6\156C\149}\ACK\255)h\152)\155Gs\181\175\246"] +// DisconnectRequest DiscoDisconnectWithWill [PropSessionExpiryInterval 31061,PropSubscriptionIdentifier +// 5,PropMessageExpiryInterval 25869,PropPayloadFormatIndicator 125,PropTopicAlias 20089,PropContentType +// "\tnB",PropWildcardSubscriptionAvailable 185,PropRetainAvailable 120,PropServerReference +// "\GSU\n8?1^\150\231\169C\130\223\222\226\&1\171\149\158",PropAuthenticationMethod +// "\252\USj\163}\SO\185r$\156EE\229\178",PropRequestProblemInformation 135,PropSessionExpiryInterval +// 15470,PropRetainAvailable 5,PropAuthenticationData +// "&\r\242\176\&0\141SB\ESC\132\DEL\213.\a\EOTS\236\193P\DC4",PropReasonString +// "Z\ETB\144\216:\228\159\232\203\150\204R\157\231\253\NUL\133\134\150\237{\167\198\156\195\v\167\&2\SO",PropAuthenticationData +// "\SYNo\207_MF\139o\164W\185\DLE",PropMessageExpiryInterval 7386,PropMessageExpiryInterval +// 16514,PropMessageExpiryInterval 13233,PropSharedSubscriptionAvailable 4,PropSharedSubscriptionAvailable +// 218,PropCorrelationData "\199\&4",PropTopicAlias 1317,PropAuthenticationData +// "\222\ESC\244\229R\FS\255\183\193\GS\161\191\EOT|w\164\230Q",PropMessageExpiryInterval +// 30353,PropMessageExpiryInterval 13107,PropAssignedClientIdentifier "\170F\238",PropServerReference +// "\192\245\207\232\189Z\199\142\DC3\132\212J\217\223/j\b"] TEST(Disco5QCTest, Encode22) { - uint8_t pkt[] = {0xe0, 0x75, 0x0, 0x73, 0x12, 0x0, 0x9, 0x24, 0xbb, 0x3a, 0x1, 0xed, 0xcc, 0xe7, 0xc4, - 0x47, 0x11, 0x0, 0x0, 0x48, 0xcc, 0x12, 0x0, 0x6, 0x3, 0x54, 0x6f, 0x35, 0x90, 0xba, - 0x27, 0x0, 0x0, 0x1d, 0x6e, 0x21, 0x40, 0xc1, 0x2, 0x0, 0x0, 0x1a, 0x1d, 0x25, 0x6b, - 0x17, 0x5a, 0x12, 0x0, 0x8, 0x2a, 0x58, 0x1, 0x4, 0x6c, 0x1f, 0x1a, 0x94, 0x1, 0x49, - 0x3, 0x0, 0x19, 0xab, 0xa2, 0x89, 0x1f, 0x58, 0x8, 0x2d, 0x61, 0x7, 0xbe, 0xa, 0x74, - 0x1c, 0xaf, 0x14, 0x70, 0x71, 0x4e, 0x76, 0xd0, 0x53, 0x98, 0x49, 0x9f, 0x30, 0x27, 0x0, - 0x0, 0x4c, 0x4f, 0xb, 0x9, 0x1a, 0x0, 0x15, 0xe4, 0xc6, 0x71, 0x4e, 0x36, 0x9c, 0x43, - 0x95, 0x7d, 0x6, 0xff, 0x29, 0x68, 0x98, 0x29, 0x9b, 0x47, 0x73, 0xb5, 0xaf, 0xf6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x24, 0xbb, 0x3a, 0x1, 0xed, 0xcc, 0xe7, 0xc4, 0x47}; - uint8_t bytesprops1[] = {0x3, 0x54, 0x6f, 0x35, 0x90, 0xba}; - uint8_t bytesprops2[] = {0x2a, 0x58, 0x1, 0x4, 0x6c, 0x1f, 0x1a, 0x94}; - uint8_t bytesprops3[] = {0xab, 0xa2, 0x89, 0x1f, 0x58, 0x8, 0x2d, 0x61, 0x7, 0xbe, 0xa, 0x74, 0x1c, - 0xaf, 0x14, 0x70, 0x71, 0x4e, 0x76, 0xd0, 0x53, 0x98, 0x49, 0x9f, 0x30}; - uint8_t bytesprops4[] = {0xe4, 0xc6, 0x71, 0x4e, 0x36, 0x9c, 0x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x0, 0x2, 0xc7, 0x34, 0x23, 0x5, 0x25, 0x16, 0x0, 0x12, 0xde, 0x1b, 0xf4, 0xe5, 0x52, 0x1c, + 0xff, 0xb7, 0xc1, 0x1d, 0xa1, 0xbf, 0x4, 0x7c, 0x77, 0xa4, 0xe6, 0x51, 0x2, 0x0, 0x0, 0x76, 0x91, + 0x2, 0x0, 0x0, 0x33, 0x33, 0x12, 0x0, 0x3, 0xaa, 0x46, 0xee, 0x1c, 0x0, 0x11, 0xc0, 0xf5, 0xcf, + 0xe8, 0xbd, 0x5a, 0xc7, 0x8e, 0x13, 0x84, 0xd4, 0x4a, 0xd9, 0xdf, 0x2f, 0x6a, 0x8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x9, 0x6e, 0x42}; + uint8_t bytesprops1[] = {0x1d, 0x55, 0xa, 0x38, 0x3f, 0x31, 0x5e, 0x96, 0xe7, 0xa9, + 0x43, 0x82, 0xdf, 0xde, 0xe2, 0x31, 0xab, 0x95, 0x9e}; + uint8_t bytesprops2[] = {0xfc, 0x1f, 0x6a, 0xa3, 0x7d, 0xe, 0xb9, 0x72, 0x24, 0x9c, 0x45, 0x45, 0xe5, 0xb2}; + uint8_t bytesprops3[] = {0x26, 0xd, 0xf2, 0xb0, 0x30, 0x8d, 0x53, 0x42, 0x1b, 0x84, + 0x7f, 0xd5, 0x2e, 0x7, 0x4, 0x53, 0xec, 0xc1, 0x50, 0x14}; + uint8_t bytesprops4[] = {0x5a, 0x17, 0x90, 0xd8, 0x3a, 0xe4, 0x9f, 0xe8, 0xcb, 0x96, 0xcc, 0x52, 0x9d, 0xe7, 0xfd, + 0x0, 0x85, 0x86, 0x96, 0xed, 0x7b, 0xa7, 0xc6, 0x9c, 0xc3, 0xb, 0xa7, 0x32, 0xe}; + uint8_t bytesprops5[] = {0x16, 0x6f, 0xcf, 0x5f, 0x4d, 0x46, 0x8b, 0x6f, 0xa4, 0x57, 0xb9, 0x10}; + uint8_t bytesprops6[] = {0xc7, 0x34}; + uint8_t bytesprops7[] = {0xde, 0x1b, 0xf4, 0xe5, 0x52, 0x1c, 0xff, 0xb7, 0xc1, + 0x1d, 0xa1, 0xbf, 0x4, 0x7c, 0x77, 0xa4, 0xe6, 0x51}; + uint8_t bytesprops8[] = {0xaa, 0x46, 0xee}; + uint8_t bytesprops9[] = {0xc0, 0xf5, 0xcf, 0xe8, 0xbd, 0x5a, 0xc7, 0x8e, 0x13, + 0x84, 0xd4, 0x4a, 0xd9, 0xdf, 0x2f, 0x6a, 0x8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18636}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7534}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16577}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6685}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 90}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19535}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31061}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25869}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20089}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15470}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7386}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16514}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13233}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1317}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30353}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13107}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoNormalDisconnection [PropAssignedClientIdentifier -// "\239\236\193{\250\139\193O\220\250\EM>\193B",PropMessageExpiryInterval 19122,PropServerKeepAlive -// 32735,PropPayloadFormatIndicator 218,PropMessageExpiryInterval 28266,PropWildcardSubscriptionAvailable -// 233,PropWildcardSubscriptionAvailable 8,PropAssignedClientIdentifier -// "=:\174qX\199\243\226l\\`p\172i\153!-t\DC3DG\169\171\ETXx\239\fr3"] +// DisconnectRequest DiscoTopicAliasInvalid [PropTopicAliasMaximum 31305,PropMaximumPacketSize +// 19902,PropMessageExpiryInterval 13846,PropSubscriptionIdentifierAvailable 13,PropRequestProblemInformation +// 11,PropSubscriptionIdentifierAvailable 64,PropTopicAlias 5928,PropResponseTopic +// "{D\229\137\247\213\252S\150\169p\161\215\254\GS\DC4\USp&=\ETX\181<=+\ETB\217\152\&2!",PropReasonString +// "\SI4\128\208\198\169\168Ur\198@\148\238\161\177G\NAK\142\149\228\144;\254\135\183l\211",PropMessageExpiryInterval +// 21979,PropTopicAlias 7370,PropSessionExpiryInterval 11718,PropUserProperty +// "\193\181sq\EOT\244\139\246\139\251r\STX\\\221A\DC2\190S/" "\141\193\210\155"] TEST(Disco5QCTest, Encode23) { - uint8_t pkt[] = {0xe0, 0x46, 0x0, 0x44, 0x12, 0x0, 0xe, 0xef, 0xec, 0xc1, 0x7b, 0xfa, 0x8b, 0xc1, 0x4f, - 0xdc, 0xfa, 0x19, 0x3e, 0xc1, 0x42, 0x2, 0x0, 0x0, 0x4a, 0xb2, 0x13, 0x7f, 0xdf, 0x1, - 0xda, 0x2, 0x0, 0x0, 0x6e, 0x6a, 0x28, 0xe9, 0x28, 0x8, 0x12, 0x0, 0x1d, 0x3d, 0x3a, - 0xae, 0x71, 0x58, 0xc7, 0xf3, 0xe2, 0x6c, 0x5c, 0x60, 0x70, 0xac, 0x69, 0x99, 0x21, 0x2d, - 0x74, 0x13, 0x44, 0x47, 0xa9, 0xab, 0x3, 0x78, 0xef, 0xc, 0x72, 0x33}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xef, 0xec, 0xc1, 0x7b, 0xfa, 0x8b, 0xc1, 0x4f, 0xdc, 0xfa, 0x19, 0x3e, 0xc1, 0x42}; - uint8_t bytesprops1[] = {0x3d, 0x3a, 0xae, 0x71, 0x58, 0xc7, 0xf3, 0xe2, 0x6c, 0x5c, 0x60, 0x70, 0xac, 0x69, 0x99, - 0x21, 0x2d, 0x74, 0x13, 0x44, 0x47, 0xa9, 0xab, 0x3, 0x78, 0xef, 0xc, 0x72, 0x33}; + uint8_t pkt[] = {0xe0, 0x80, 0x1, 0x94, 0x7e, 0x22, 0x7a, 0x49, 0x27, 0x0, 0x0, 0x4d, 0xbe, 0x2, 0x0, 0x0, 0x36, + 0x16, 0x29, 0xd, 0x17, 0xb, 0x29, 0x40, 0x23, 0x17, 0x28, 0x8, 0x0, 0x1e, 0x7b, 0x44, 0xe5, 0x89, + 0xf7, 0xd5, 0xfc, 0x53, 0x96, 0xa9, 0x70, 0xa1, 0xd7, 0xfe, 0x1d, 0x14, 0x1f, 0x70, 0x26, 0x3d, 0x3, + 0xb5, 0x3c, 0x3d, 0x2b, 0x17, 0xd9, 0x98, 0x32, 0x21, 0x1f, 0x0, 0x1b, 0xf, 0x34, 0x80, 0xd0, 0xc6, + 0xa9, 0xa8, 0x55, 0x72, 0xc6, 0x40, 0x94, 0xee, 0xa1, 0xb1, 0x47, 0x15, 0x8e, 0x95, 0xe4, 0x90, 0x3b, + 0xfe, 0x87, 0xb7, 0x6c, 0xd3, 0x2, 0x0, 0x0, 0x55, 0xdb, 0x23, 0x1c, 0xca, 0x11, 0x0, 0x0, 0x2d, + 0xc6, 0x26, 0x0, 0x13, 0xc1, 0xb5, 0x73, 0x71, 0x4, 0xf4, 0x8b, 0xf6, 0x8b, 0xfb, 0x72, 0x2, 0x5c, + 0xdd, 0x41, 0x12, 0xbe, 0x53, 0x2f, 0x0, 0x4, 0x8d, 0xc1, 0xd2, 0x9b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x7b, 0x44, 0xe5, 0x89, 0xf7, 0xd5, 0xfc, 0x53, 0x96, 0xa9, 0x70, 0xa1, 0xd7, 0xfe, 0x1d, + 0x14, 0x1f, 0x70, 0x26, 0x3d, 0x3, 0xb5, 0x3c, 0x3d, 0x2b, 0x17, 0xd9, 0x98, 0x32, 0x21}; + uint8_t bytesprops1[] = {0xf, 0x34, 0x80, 0xd0, 0xc6, 0xa9, 0xa8, 0x55, 0x72, 0xc6, 0x40, 0x94, 0xee, 0xa1, + 0xb1, 0x47, 0x15, 0x8e, 0x95, 0xe4, 0x90, 0x3b, 0xfe, 0x87, 0xb7, 0x6c, 0xd3}; + uint8_t bytesprops3[] = {0x8d, 0xc1, 0xd2, 0x9b}; + uint8_t bytesprops2[] = {0xc1, 0xb5, 0x73, 0x71, 0x4, 0xf4, 0x8b, 0xf6, 0x8b, 0xfb, + 0x72, 0x2, 0x5c, 0xdd, 0x41, 0x12, 0xbe, 0x53, 0x2f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19122}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32735}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28266}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 8}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31305}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19902}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13846}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5928}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21979}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7370}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11718}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops2}, .v = {4, (char*)&bytesprops3}}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 148, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoProtocolError [PropSharedSubscriptionAvailable 126,PropMessageExpiryInterval -// 22952,PropServerReference "\n\a6\222dV\218",PropPayloadFormatIndicator 241,PropUserProperty "\234\FS\b\EM" -// "\FS\SUBN'\170\191\STXZ\213\133\189K\190V)\160\255\&0",PropTopicAlias 12630,PropResponseInformation -// "\184\217Nw\DC1B\178\153m\164k\151\161 \EOTu",PropMessageExpiryInterval 22385,PropWillDelayInterval -// 8666,PropPayloadFormatIndicator 230,PropSessionExpiryInterval 28458,PropWildcardSubscriptionAvailable -// 22,PropSubscriptionIdentifierAvailable 61,PropResponseInformation "\236",PropAssignedClientIdentifier -// "#\EOT",PropWillDelayInterval 28536,PropServerKeepAlive 27227,PropReasonString -// "P\178\135I2\193\&7\206\209\223;\145\171\DC2\241",PropResponseTopic -// "\169\228\DC2\US\215,\140\226\150\131\143\134>\DC4\172.",PropContentType -// "V\218\247\196+\186x\233|",PropReceiveMaximum 21710,PropRequestProblemInformation 234,PropTopicAlias -// 21200,PropReceiveMaximum 13455,PropPayloadFormatIndicator 98] +// DisconnectRequest DiscoConnectionRateExceeded [PropContentType +// "g\SYN5\222\184\174\217\155\181\204\230\138\177\SUBC\147",PropUserProperty "\178@\SI\222{\DC1\203\154\172\209\154&" +// "\NUL\217z\201\200\139\219O\177%G\208\131d\178f",PropTopicAliasMaximum 28053,PropRequestResponseInformation +// 144,PropAssignedClientIdentifier "D",PropServerReference +// "\155\207\241W\227}\208\174DJ\239",PropWildcardSubscriptionAvailable 36,PropResponseTopic +// "\ETX\207\RS`\180\182\171",PropMaximumPacketSize 10715,PropServerReference +// "\220\243Y\157\161\&2\229\ENQ\156\130\FSr(t",PropSubscriptionIdentifier 22,PropAuthenticationMethod +// "\f\155d&\SOT\t\183q\168\229\234i\172\161@\156",PropServerReference +// "b!\229\SUB\b\216\203w\254$\192\145\191\232w=i$\135\142\241\197O=\229Q4\131",PropReceiveMaximum +// 22291,PropSubscriptionIdentifierAvailable 250,PropContentType +// "\183J\171\207'X_d\135'o\250\&9\222\134\SOH\"\137$H\128\157i\139\211",PropRetainAvailable 151,PropMaximumPacketSize +// 26309,PropSubscriptionIdentifierAvailable 242,PropSubscriptionIdentifierAvailable +// 230,PropWildcardSubscriptionAvailable 194,PropResponseTopic "\131\195R\237",PropTopicAliasMaximum +// 15601,PropSubscriptionIdentifier 15,PropSubscriptionIdentifierAvailable 226,PropReasonString +// "\239\129\240\198a\US\NAK`\242\199a\166\251<\147%\r\SYN\174z",PropAuthenticationMethod +// "vu\DC3\140\FSk\205\226\183v\ETX+\RSY\135\141\CAN\212\148\243\220",PropSessionExpiryInterval 21456,PropUserProperty +// "\180\206" "\NAKs\132"] TEST(Disco5QCTest, Encode24) { - uint8_t pkt[] = {0xe0, 0xab, 0x1, 0x82, 0xa8, 0x1, 0x2a, 0x7e, 0x2, 0x0, 0x0, 0x59, 0xa8, 0x1c, 0x0, 0x7, - 0xa, 0x7, 0x36, 0xde, 0x64, 0x56, 0xda, 0x1, 0xf1, 0x26, 0x0, 0x4, 0xea, 0x1c, 0x8, 0x19, - 0x0, 0x12, 0x1c, 0x1a, 0x4e, 0x27, 0xaa, 0xbf, 0x2, 0x5a, 0xd5, 0x85, 0xbd, 0x4b, 0xbe, 0x56, - 0x29, 0xa0, 0xff, 0x30, 0x23, 0x31, 0x56, 0x1a, 0x0, 0x10, 0xb8, 0xd9, 0x4e, 0x77, 0x11, 0x42, - 0xb2, 0x99, 0x6d, 0xa4, 0x6b, 0x97, 0xa1, 0x20, 0x4, 0x75, 0x2, 0x0, 0x0, 0x57, 0x71, 0x18, - 0x0, 0x0, 0x21, 0xda, 0x1, 0xe6, 0x11, 0x0, 0x0, 0x6f, 0x2a, 0x28, 0x16, 0x29, 0x3d, 0x1a, - 0x0, 0x1, 0xec, 0x12, 0x0, 0x2, 0x23, 0x4, 0x18, 0x0, 0x0, 0x6f, 0x78, 0x13, 0x6a, 0x5b, - 0x1f, 0x0, 0xf, 0x50, 0xb2, 0x87, 0x49, 0x32, 0xc1, 0x37, 0xce, 0xd1, 0xdf, 0x3b, 0x91, 0xab, - 0x12, 0xf1, 0x8, 0x0, 0x10, 0xa9, 0xe4, 0x12, 0x1f, 0xd7, 0x2c, 0x8c, 0xe2, 0x96, 0x83, 0x8f, - 0x86, 0x3e, 0x14, 0xac, 0x2e, 0x3, 0x0, 0x9, 0x56, 0xda, 0xf7, 0xc4, 0x2b, 0xba, 0x78, 0xe9, - 0x7c, 0x21, 0x54, 0xce, 0x17, 0xea, 0x23, 0x52, 0xd0, 0x21, 0x34, 0x8f, 0x1, 0x62}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xa, 0x7, 0x36, 0xde, 0x64, 0x56, 0xda}; - uint8_t bytesprops2[] = {0x1c, 0x1a, 0x4e, 0x27, 0xaa, 0xbf, 0x2, 0x5a, 0xd5, - 0x85, 0xbd, 0x4b, 0xbe, 0x56, 0x29, 0xa0, 0xff, 0x30}; - uint8_t bytesprops1[] = {0xea, 0x1c, 0x8, 0x19}; - uint8_t bytesprops3[] = {0xb8, 0xd9, 0x4e, 0x77, 0x11, 0x42, 0xb2, 0x99, - 0x6d, 0xa4, 0x6b, 0x97, 0xa1, 0x20, 0x4, 0x75}; - uint8_t bytesprops4[] = {0xec}; - uint8_t bytesprops5[] = {0x23, 0x4}; - uint8_t bytesprops6[] = {0x50, 0xb2, 0x87, 0x49, 0x32, 0xc1, 0x37, 0xce, 0xd1, 0xdf, 0x3b, 0x91, 0xab, 0x12, 0xf1}; - uint8_t bytesprops7[] = {0xa9, 0xe4, 0x12, 0x1f, 0xd7, 0x2c, 0x8c, 0xe2, - 0x96, 0x83, 0x8f, 0x86, 0x3e, 0x14, 0xac, 0x2e}; - uint8_t bytesprops8[] = {0x56, 0xda, 0xf7, 0xc4, 0x2b, 0xba, 0x78, 0xe9, 0x7c}; + uint8_t pkt[] = { + 0xe0, 0x9f, 0x2, 0x9f, 0x9c, 0x2, 0x3, 0x0, 0x10, 0x67, 0x16, 0x35, 0xde, 0xb8, 0xae, 0xd9, 0x9b, 0xb5, 0xcc, + 0xe6, 0x8a, 0xb1, 0x1a, 0x43, 0x93, 0x26, 0x0, 0xc, 0xb2, 0x40, 0xf, 0xde, 0x7b, 0x11, 0xcb, 0x9a, 0xac, 0xd1, + 0x9a, 0x26, 0x0, 0x10, 0x0, 0xd9, 0x7a, 0xc9, 0xc8, 0x8b, 0xdb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x15, 0x60, 0xf2, 0xc7, 0x61, 0xa6, 0xfb, 0x3c, 0x93, 0x25, + 0xd, 0x16, 0xae, 0x7a, 0x15, 0x0, 0x15, 0x76, 0x75, 0x13, 0x8c, 0x1c, 0x6b, 0xcd, 0xe2, 0xb7, 0x76, 0x3, 0x2b, + 0x1e, 0x59, 0x87, 0x8d, 0x18, 0xd4, 0x94, 0xf3, 0xdc, 0x11, 0x0, 0x0, 0x53, 0xd0, 0x26, 0x0, 0x2, 0xb4, 0xce, + 0x0, 0x3, 0x15, 0x73, 0x84}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x67, 0x16, 0x35, 0xde, 0xb8, 0xae, 0xd9, 0x9b, + 0xb5, 0xcc, 0xe6, 0x8a, 0xb1, 0x1a, 0x43, 0x93}; + uint8_t bytesprops2[] = {0x0, 0xd9, 0x7a, 0xc9, 0xc8, 0x8b, 0xdb, 0x4f, + 0xb1, 0x25, 0x47, 0xd0, 0x83, 0x64, 0xb2, 0x66}; + uint8_t bytesprops1[] = {0xb2, 0x40, 0xf, 0xde, 0x7b, 0x11, 0xcb, 0x9a, 0xac, 0xd1, 0x9a, 0x26}; + uint8_t bytesprops3[] = {0x44}; + uint8_t bytesprops4[] = {0x9b, 0xcf, 0xf1, 0x57, 0xe3, 0x7d, 0xd0, 0xae, 0x44, 0x4a, 0xef}; + uint8_t bytesprops5[] = {0x3, 0xcf, 0x1e, 0x60, 0xb4, 0xb6, 0xab}; + uint8_t bytesprops6[] = {0xdc, 0xf3, 0x59, 0x9d, 0xa1, 0x32, 0xe5, 0x5, 0x9c, 0x82, 0x1c, 0x72, 0x28, 0x74}; + uint8_t bytesprops7[] = {0xc, 0x9b, 0x64, 0x26, 0xe, 0x54, 0x9, 0xb7, 0x71, + 0xa8, 0xe5, 0xea, 0x69, 0xac, 0xa1, 0x40, 0x9c}; + uint8_t bytesprops8[] = {0x62, 0x21, 0xe5, 0x1a, 0x8, 0xd8, 0xcb, 0x77, 0xfe, 0x24, 0xc0, 0x91, 0xbf, 0xe8, + 0x77, 0x3d, 0x69, 0x24, 0x87, 0x8e, 0xf1, 0xc5, 0x4f, 0x3d, 0xe5, 0x51, 0x34, 0x83}; + uint8_t bytesprops9[] = {0xb7, 0x4a, 0xab, 0xcf, 0x27, 0x58, 0x5f, 0x64, 0x87, 0x27, 0x6f, 0xfa, 0x39, + 0xde, 0x86, 0x1, 0x22, 0x89, 0x24, 0x48, 0x80, 0x9d, 0x69, 0x8b, 0xd3}; + uint8_t bytesprops10[] = {0x83, 0xc3, 0x52, 0xed}; + uint8_t bytesprops11[] = {0xef, 0x81, 0xf0, 0xc6, 0x61, 0x1f, 0x15, 0x60, 0xf2, 0xc7, + 0x61, 0xa6, 0xfb, 0x3c, 0x93, 0x25, 0xd, 0x16, 0xae, 0x7a}; + uint8_t bytesprops12[] = {0x76, 0x75, 0x13, 0x8c, 0x1c, 0x6b, 0xcd, 0xe2, 0xb7, 0x76, 0x3, + 0x2b, 0x1e, 0x59, 0x87, 0x8d, 0x18, 0xd4, 0x94, 0xf3, 0xdc}; + uint8_t bytesprops14[] = {0x15, 0x73, 0x84}; + uint8_t bytesprops13[] = {0xb4, 0xce}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22952}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12630}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22385}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8666}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 28458}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28536}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27227}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21710}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21200}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13455}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops1}, .v = {16, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28053}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10715}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22291}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 250}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26309}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15601}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21456}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops13}, .v = {3, (char*)&bytesprops14}}}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 130, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoMaximumConnectTime [PropRequestProblemInformation 237,PropSharedSubscriptionAvailable -// 191,PropWildcardSubscriptionAvailable 74,PropAssignedClientIdentifier -// "\211%\DEL;\174\234\EOT\128\ETXt,[\177\138O\DLE+\134\220Ut/\212\247\136\&4P\142\181",PropServerReference -// "9u\ENQz\160\172\253\129 \225\240\180\200hO",PropAssignedClientIdentifier -// "^\SOH\135l\163\233L>\bN\154\NUL\ESC\150\131",PropWillDelayInterval 7514,PropWildcardSubscriptionAvailable -// 226,PropSubscriptionIdentifier 29,PropMessageExpiryInterval 23285,PropSubscriptionIdentifier -// 11,PropResponseInformation -// "s\SIj\196\251L\167\ETX\NAK\137`\226\221\183\189\EM\DC1wWs\ETB4p\184\143&",PropSharedSubscriptionAvailable -// 6,PropWillDelayInterval 23559,PropAuthenticationData -// "\166\144\235\195h\240\&6\SOH\DC2\191\STX\153\&6\238\173ldx",PropMaximumQoS 190,PropContentType -// "\151\GS\229\176I\161h\203\172O\213\GS\232W\SOH\238\214\EOT\254\EOTX\f\193\251(\171\164s:\DEL",PropAuthenticationData -// "\208\139K\193\159H",PropRequestResponseInformation 104,PropTopicAliasMaximum 5762,PropReasonString -// "\174\206\147\209\232BH@R\140W\178\173/\165\230\&1\141\233\245\143i/\166\133",PropTopicAlias -// 11912,PropMessageExpiryInterval 5860,PropReceiveMaximum 20067,PropWillDelayInterval 32077,PropResponseTopic -// "\CAN[\DC4\232\176\181C\198\179h\187_\212\237\255\DLE\247\NUL\159\208\146P!\231\159",PropResponseTopic -// "\ETX-\239\169\\\ACKz",PropAuthenticationMethod -// "F\247*\181\NAKs\216\134`\145\220\211;2y\219\NUL",PropSessionExpiryInterval 19023,PropResponseInformation -// "Y\STX\DLEl_\ENQ\175\SO\f\174w-VL\DC3[\211\RS\158\211Z\SUB\DLE\aM"] +// DisconnectRequest DiscoMalformedPacket [PropUserProperty +// "\195\166\180u\189Z\179\181Ab\SIE\255\&1\252\203c\219\174\US\192\DC3\172" +// "R\190\v\227\205\214\"\131D[\128G\163\182\183\RS\228\140\161",PropServerKeepAlive 7736,PropSessionExpiryInterval +// 19120,PropCorrelationData "\251\192\&7=G",PropCorrelationData +// "\DC1\151\221\175k6\232\DC1\DC1\180\223",PropSessionExpiryInterval 18563,PropRequestProblemInformation +// 228,PropCorrelationData "\161\255\EM",PropReceiveMaximum 4326,PropAssignedClientIdentifier +// "yB\247\SO!\t\225\141\219P\215\244`\253",PropAuthenticationMethod "\f\212",PropRetainAvailable +// 154,PropMaximumPacketSize 23032,PropRequestResponseInformation 205,PropMessageExpiryInterval 9326,PropContentType +// "\t\132\144-\225\&3\140\RS\190\211Eb\220 \171\ETXW\254\245",PropReasonString +// "\DC3\162\170\180\STX\243<",PropResponseInformation "\161Z*\DC4\ESC\195\238\185\224\247)x\203\159",PropMaximumQoS +// 11,PropSubscriptionIdentifierAvailable 211,PropResponseTopic "\251",PropAssignedClientIdentifier +// "\228",PropRequestResponseInformation 56,PropUserProperty +// "\193\153\211\229\202\195R\228\214\176\204\234(\SOY\176\177\239\176\225\fB\247\249C\SOH" "-`\219o \SYN\b\247ud\ESC"] TEST(Disco5QCTest, Encode27) { uint8_t pkt[] = { - 0xe0, 0xbb, 0x1, 0x0, 0xb8, 0x1, 0xb, 0x11, 0xb, 0xe, 0x15, 0x0, 0x18, 0xf8, 0xe9, 0x10, 0xdf, 0x41, 0x71, - 0x96, 0x99, 0x83, 0x60, 0x42, 0x6a, 0x24, 0xd0, 0xb1, 0x13, 0x43, 0x87, 0xf5, 0x65, 0xd4, 0x72, 0x93, 0x41, 0x16, - 0x0, 0xc, 0x7f, 0x35, 0xa0, 0x3, 0xc3, 0xe9, 0xbc, 0xdf, 0x2, 0x60, 0x64, 0xd0, 0x12, 0x0, 0x11, 0x2f, 0x34, - 0xe3, 0x19, 0xa2, 0x8d, 0xe1, 0x27, 0x9, 0xff, 0x10, 0x24, 0xc0, 0xf, 0x7b, 0x7a, 0xc1, 0x1f, 0x0, 0x8, 0xd1, - 0x5f, 0x3e, 0x8f, 0x69, 0x2f, 0xa6, 0x85, 0x23, 0x2e, 0x88, 0x2, 0x0, 0x0, 0x16, 0xe4, 0x21, 0x4e, 0x63, 0x18, - 0x0, 0x0, 0x7d, 0x4d, 0x8, 0x0, 0x19, 0x18, 0x5b, 0x14, 0xe8, 0xb0, 0xb5, 0x43, 0xc6, 0xb3, 0x68, 0xbb, 0x5f, - 0xd4, 0xed, 0xff, 0x10, 0xf7, 0x0, 0x9f, 0xd0, 0x92, 0x50, 0x21, 0xe7, 0x9f, 0x8, 0x0, 0x7, 0x3, 0x2d, 0xef, - 0xa9, 0x5c, 0x6, 0x7a, 0x15, 0x0, 0x11, 0x46, 0xf7, 0x2a, 0xb5, 0x15, 0x73, 0xd8, 0x86, 0x60, 0x91, 0xdc, 0xd3, - 0x3b, 0x32, 0x79, 0xdb, 0x0, 0x11, 0x0, 0x0, 0x4a, 0x4f, 0x1a, 0x0, 0x19, 0x59, 0x2, 0x10, 0x6c, 0x5f, 0x5, - 0xaf, 0xe, 0xc, 0xae, 0x77, 0x2d, 0x56, 0x4c, 0x13, 0x5b, 0xd3, 0x1e, 0x9e, 0xd3, 0x5a, 0x1a, 0x10, 0x7, 0x4d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf8, 0xe9, 0x10, 0xdf, 0x41, 0x71, 0x96, 0x99, 0x83, 0x60, 0x42, 0x6a, - 0x24, 0xd0, 0xb1, 0x13, 0x43, 0x87, 0xf5, 0x65, 0xd4, 0x72, 0x93, 0x41}; - uint8_t bytesprops1[] = {0x7f, 0x35, 0xa0, 0x3, 0xc3, 0xe9, 0xbc, 0xdf, 0x2, 0x60, 0x64, 0xd0}; - uint8_t bytesprops2[] = {0x2f, 0x34, 0xe3, 0x19, 0xa2, 0x8d, 0xe1, 0x27, 0x9, - 0xff, 0x10, 0x24, 0xc0, 0xf, 0x7b, 0x7a, 0xc1}; - uint8_t bytesprops3[] = {0xd1, 0x5f, 0x3e, 0x8f, 0x69, 0x2f, 0xa6, 0x85}; - uint8_t bytesprops4[] = {0x18, 0x5b, 0x14, 0xe8, 0xb0, 0xb5, 0x43, 0xc6, 0xb3, 0x68, 0xbb, 0x5f, 0xd4, - 0xed, 0xff, 0x10, 0xf7, 0x0, 0x9f, 0xd0, 0x92, 0x50, 0x21, 0xe7, 0x9f}; - uint8_t bytesprops5[] = {0x3, 0x2d, 0xef, 0xa9, 0x5c, 0x6, 0x7a}; - uint8_t bytesprops6[] = {0x46, 0xf7, 0x2a, 0xb5, 0x15, 0x73, 0xd8, 0x86, 0x60, - 0x91, 0xdc, 0xd3, 0x3b, 0x32, 0x79, 0xdb, 0x0}; - uint8_t bytesprops7[] = {0x59, 0x2, 0x10, 0x6c, 0x5f, 0x5, 0xaf, 0xe, 0xc, 0xae, 0x77, 0x2d, 0x56, - 0x4c, 0x13, 0x5b, 0xd3, 0x1e, 0x9e, 0xd3, 0x5a, 0x1a, 0x10, 0x7, 0x4d}; + 0xe0, 0xed, 0x1, 0x81, 0xea, 0x1, 0x26, 0x0, 0x17, 0xc3, 0xa6, 0xb4, 0x75, 0xbd, 0x5a, 0xb3, 0xb5, 0x41, 0x62, + 0xf, 0x45, 0xff, 0x31, 0xfc, 0xcb, 0x63, 0xdb, 0xae, 0x1f, 0xc0, 0x13, 0xac, 0x0, 0x13, 0x52, 0xbe, 0xb, 0xe3, + 0xcd, 0xd6, 0x22, 0x83, 0x44, 0x5b, 0x80, 0x47, 0xa3, 0xb6, 0xb7, 0x1e, 0xe4, 0x8c, 0xa1, 0x13, 0x1e, 0x38, 0x11, + 0x0, 0x0, 0x4a, 0xb0, 0x9, 0x0, 0x5, 0xfb, 0xc0, 0x37, 0x3d, 0x47, 0x9, 0x0, 0xb, 0x11, 0x97, 0xdd, 0xaf, + 0x6b, 0x36, 0xe8, 0x11, 0x11, 0xb4, 0xdf, 0x11, 0x0, 0x0, 0x48, 0x83, 0x17, 0xe4, 0x9, 0x0, 0x3, 0xa1, 0xff, + 0x19, 0x21, 0x10, 0xe6, 0x12, 0x0, 0xe, 0x79, 0x42, 0xf7, 0xe, 0x21, 0x9, 0xe1, 0x8d, 0xdb, 0x50, 0xd7, 0xf4, + 0x60, 0xfd, 0x15, 0x0, 0x2, 0xc, 0xd4, 0x25, 0x9a, 0x27, 0x0, 0x0, 0x59, 0xf8, 0x19, 0xcd, 0x2, 0x0, 0x0, + 0x24, 0x6e, 0x3, 0x0, 0x13, 0x9, 0x84, 0x90, 0x2d, 0xe1, 0x33, 0x8c, 0x1e, 0xbe, 0xd3, 0x45, 0x62, 0xdc, 0x20, + 0xab, 0x3, 0x57, 0xfe, 0xf5, 0x1f, 0x0, 0x7, 0x13, 0xa2, 0xaa, 0xb4, 0x2, 0xf3, 0x3c, 0x1a, 0x0, 0xe, 0xa1, + 0x5a, 0x2a, 0x14, 0x1b, 0xc3, 0xee, 0xb9, 0xe0, 0xf7, 0x29, 0x78, 0xcb, 0x9f, 0x24, 0xb, 0x29, 0xd3, 0x8, 0x0, + 0x1, 0xfb, 0x12, 0x0, 0x1, 0xe4, 0x19, 0x38, 0x26, 0x0, 0x1a, 0xc1, 0x99, 0xd3, 0xe5, 0xca, 0xc3, 0x52, 0xe4, + 0xd6, 0xb0, 0xcc, 0xea, 0x28, 0xe, 0x59, 0xb0, 0xb1, 0xef, 0xb0, 0xe1, 0xc, 0x42, 0xf7, 0xf9, 0x43, 0x1, 0x0, + 0xb, 0x2d, 0x60, 0xdb, 0x6f, 0x20, 0x16, 0x8, 0xf7, 0x75, 0x64, 0x1b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x52, 0xbe, 0xb, 0xe3, 0xcd, 0xd6, 0x22, 0x83, 0x44, 0x5b, + 0x80, 0x47, 0xa3, 0xb6, 0xb7, 0x1e, 0xe4, 0x8c, 0xa1}; + uint8_t bytesprops0[] = {0xc3, 0xa6, 0xb4, 0x75, 0xbd, 0x5a, 0xb3, 0xb5, 0x41, 0x62, 0xf, 0x45, + 0xff, 0x31, 0xfc, 0xcb, 0x63, 0xdb, 0xae, 0x1f, 0xc0, 0x13, 0xac}; + uint8_t bytesprops2[] = {0xfb, 0xc0, 0x37, 0x3d, 0x47}; + uint8_t bytesprops3[] = {0x11, 0x97, 0xdd, 0xaf, 0x6b, 0x36, 0xe8, 0x11, 0x11, 0xb4, 0xdf}; + uint8_t bytesprops4[] = {0xa1, 0xff, 0x19}; + uint8_t bytesprops5[] = {0x79, 0x42, 0xf7, 0xe, 0x21, 0x9, 0xe1, 0x8d, 0xdb, 0x50, 0xd7, 0xf4, 0x60, 0xfd}; + uint8_t bytesprops6[] = {0xc, 0xd4}; + uint8_t bytesprops7[] = {0x9, 0x84, 0x90, 0x2d, 0xe1, 0x33, 0x8c, 0x1e, 0xbe, 0xd3, + 0x45, 0x62, 0xdc, 0x20, 0xab, 0x3, 0x57, 0xfe, 0xf5}; + uint8_t bytesprops8[] = {0x13, 0xa2, 0xaa, 0xb4, 0x2, 0xf3, 0x3c}; + uint8_t bytesprops9[] = {0xa1, 0x5a, 0x2a, 0x14, 0x1b, 0xc3, 0xee, 0xb9, 0xe0, 0xf7, 0x29, 0x78, 0xcb, 0x9f}; + uint8_t bytesprops10[] = {0xfb}; + uint8_t bytesprops11[] = {0xe4}; + uint8_t bytesprops13[] = {0x2d, 0x60, 0xdb, 0x6f, 0x20, 0x16, 0x8, 0xf7, 0x75, 0x64, 0x1b}; + uint8_t bytesprops12[] = {0xc1, 0x99, 0xd3, 0xe5, 0xca, 0xc3, 0x52, 0xe4, 0xd6, 0xb0, 0xcc, 0xea, 0x28, + 0xe, 0x59, 0xb0, 0xb1, 0xef, 0xb0, 0xe1, 0xc, 0x42, 0xf7, 0xf9, 0x43, 0x1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11912}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5860}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20067}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32077}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19023}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops0}, .v = {19, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7736}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19120}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18563}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4326}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23032}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 205}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9326}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 11}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {26, (char*)&bytesprops12}, .v = {11, (char*)&bytesprops13}}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 129, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoSharedSubscriptionsNotSupported [PropServerReference -// "\EMD\178\rD\ENQ%H\203\DLE\231\ETBh\SO7m\204\196\167K\166\GS\200\&9O\150\215\225\GS",PropRetainAvailable -// 155,PropAuthenticationMethod "19W\242i?r;^z\170\169\f\183\134\168\227\DC4;",PropWildcardSubscriptionAvailable -// 65,PropMessageExpiryInterval 12219,PropRequestResponseInformation 65,PropResponseTopic "",PropMessageExpiryInterval -// 28021,PropRequestResponseInformation 74,PropWillDelayInterval 13573,PropContentType -// "~\195e2\131[\n-\b\162\135Y\DC2\212\167\174",PropReceiveMaximum 27401,PropResponseTopic -// "~\206\a4\129g\228#Z0\NAKN\175^<>\159\ETX;\254\187\250\253\131\174\166\FS\156",PropUserProperty -// "\204hY\237QL'\na]\233\163\DC15'z\165\224h\250\185\137\149\138\GS~\139i" -// "\144\150\SI,\191\206\CAN\133",PropMessageExpiryInterval 23185,PropWildcardSubscriptionAvailable -// 169,PropSubscriptionIdentifier 14,PropSharedSubscriptionAvailable 196,PropRetainAvailable 142,PropUserProperty -// "\156\135\242$}8\RS\214\240\ENQ\212\196\FS\142\171\222\221\ACK\233b " -// "&Z\190\GS\132\NUL\243\177\\\237^U\r\247",PropAuthenticationData -// "/G\162\230J\STX\176\231\176\180\134Y\STX]Z\DLE\200\&6mB"] +// DisconnectRequest DiscoTopicAliasInvalid [PropServerReference "",PropTopicAlias 20930,PropTopicAlias +// 15670,PropAuthenticationMethod "'(\225\139rP~Eq\205umB\216K&\182",PropResponseInformation +// ".e",PropPayloadFormatIndicator 214,PropMaximumQoS 86,PropServerKeepAlive 17262,PropMessageExpiryInterval +// 30402,PropServerKeepAlive 13701,PropContentType +// "\187PR\192\250\&02y\159.\GS\184\ACK\154]\167\SO\132~\252\165wYl\149\216",PropTopicAlias 10414,PropAuthenticationData +// "\145I\206\142-f\159\238 =\167R\199\SOH\249B>:T\169\179\193\&4f\ENQ\248\250\169\SI",PropRequestResponseInformation +// 110,PropMaximumQoS 6,PropWildcardSubscriptionAvailable 104,PropRequestProblemInformation 132,PropContentType +// "\195\151W\\\171y\217\194\141\137\156k\165b>(\SOH\GSz]G\175\251",PropAuthenticationMethod +// "\146E\176\189\225m\128\149J6@1n\v\192\191\159M\t\SI\218\227\239x7\ETB\202=",PropTopicAlias +// 32393,PropWillDelayInterval 26126,PropServerReference "",PropAuthenticationData +// "[K\150\221\199\181}\212\&3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f, 0xce, 0x18, 0x85, 0x2, 0x0, 0x0, 0x5a, 0x91, 0x28, 0xa9, 0xb, 0xe, 0x2a, - 0xc4, 0x25, 0x8e, 0x26, 0x0, 0x15, 0x9c, 0x87, 0xf2, 0x24, 0x7d, 0x38, 0x1e, 0xd6, 0xf0, 0x5, 0xd4, 0xc4, 0x1c, - 0x8e, 0xab, 0xde, 0xdd, 0x6, 0xe9, 0x62, 0x20, 0x0, 0xe, 0x26, 0x5a, 0xbe, 0x1d, 0x84, 0x0, 0xf3, 0xb1, 0x5c, - 0xed, 0x5e, 0x55, 0xd, 0xf7, 0x16, 0x0, 0x14, 0x2f, 0x47, 0xa2, 0xe6, 0x4a, 0x2, 0xb0, 0xe7, 0xb0, 0xb4, 0x86, - 0x59, 0x2, 0x5d, 0x5a, 0x10, 0xc8, 0x36, 0x6d, 0x42}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x19, 0x44, 0xb2, 0xd, 0x44, 0x5, 0x25, 0x48, 0xcb, 0x10, 0xe7, 0x17, 0x68, 0xe, 0x37, - 0x6d, 0xcc, 0xc4, 0xa7, 0x4b, 0xa6, 0x1d, 0xc8, 0x39, 0x4f, 0x96, 0xd7, 0xe1, 0x1d}; - uint8_t bytesprops1[] = {0x31, 0x39, 0x57, 0xf2, 0x69, 0x3f, 0x72, 0x3b, 0x5e, 0x7a, - 0xaa, 0xa9, 0xc, 0xb7, 0x86, 0xa8, 0xe3, 0x14, 0x3b}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x7e, 0xc3, 0x65, 0x32, 0x83, 0x5b, 0xa, 0x2d, - 0x8, 0xa2, 0x87, 0x59, 0x12, 0xd4, 0xa7, 0xae}; - uint8_t bytesprops4[] = {0x7e, 0xce, 0x7, 0x34, 0x81, 0x67, 0xe4, 0x23, 0x5a, 0x30, 0x15, 0x4e, 0xaf, 0x5e, - 0x3c, 0x3e, 0x9f, 0x3, 0x3b, 0xfe, 0xbb, 0xfa, 0xfd, 0x83, 0xae, 0xa6, 0x1c, 0x9c}; - uint8_t bytesprops6[] = {0x90, 0x96, 0xf, 0x2c, 0xbf, 0xce, 0x18, 0x85}; - uint8_t bytesprops5[] = {0xcc, 0x68, 0x59, 0xed, 0x51, 0x4c, 0x27, 0xa, 0x61, 0x5d, 0xe9, 0xa3, 0x11, 0x35, - 0x27, 0x7a, 0xa5, 0xe0, 0x68, 0xfa, 0xb9, 0x89, 0x95, 0x8a, 0x1d, 0x7e, 0x8b, 0x69}; - uint8_t bytesprops8[] = {0x26, 0x5a, 0xbe, 0x1d, 0x84, 0x0, 0xf3, 0xb1, 0x5c, 0xed, 0x5e, 0x55, 0xd, 0xf7}; - uint8_t bytesprops7[] = {0x9c, 0x87, 0xf2, 0x24, 0x7d, 0x38, 0x1e, 0xd6, 0xf0, 0x5, 0xd4, - 0xc4, 0x1c, 0x8e, 0xab, 0xde, 0xdd, 0x6, 0xe9, 0x62, 0x20}; - uint8_t bytesprops9[] = {0x2f, 0x47, 0xa2, 0xe6, 0x4a, 0x2, 0xb0, 0xe7, 0xb0, 0xb4, - 0x86, 0x59, 0x2, 0x5d, 0x5a, 0x10, 0xc8, 0x36, 0x6d, 0x42}; + uint8_t pkt[] = {0xe0, 0xd5, 0x1, 0x94, 0xd2, 0x1, 0x1c, 0x0, 0x0, 0x23, 0x51, 0xc2, 0x23, 0x3d, 0x36, 0x15, 0x0, + 0x11, 0x27, 0x28, 0xe1, 0x8b, 0x72, 0x50, 0x7e, 0x45, 0x71, 0xcd, 0x75, 0x6d, 0x42, 0xd8, 0x4b, 0x26, + 0xb6, 0x1a, 0x0, 0x2, 0x2e, 0x65, 0x1, 0xd6, 0x24, 0x56, 0x13, 0x43, 0x6e, 0x2, 0x0, 0x0, 0x76, + 0xc2, 0x13, 0x35, 0x85, 0x3, 0x0, 0x1a, 0xbb, 0x50, 0x52, 0xc0, 0xfa, 0x30, 0x32, 0x79, 0x9f, 0x2e, + 0x1d, 0xb8, 0x6, 0x9a, 0x5d, 0xa7, 0xe, 0x84, 0x7e, 0xfc, 0xa5, 0x77, 0x59, 0x6c, 0x95, 0xd8, 0x23, + 0x28, 0xae, 0x16, 0x0, 0x1d, 0x91, 0x49, 0xce, 0x8e, 0x2d, 0x66, 0x9f, 0xee, 0x20, 0x3d, 0xa7, 0x52, + 0xc7, 0x1, 0xf9, 0x42, 0x3e, 0x3a, 0x54, 0xa9, 0xb3, 0xc1, 0x34, 0x66, 0x5, 0xf8, 0xfa, 0xa9, 0xf, + 0x19, 0x6e, 0x24, 0x6, 0x28, 0x68, 0x17, 0x84, 0x3, 0x0, 0x17, 0xc3, 0x97, 0x57, 0x5c, 0xab, 0x79, + 0xd9, 0xc2, 0x8d, 0x89, 0x9c, 0x6b, 0xa5, 0x62, 0x3e, 0x28, 0x1, 0x1d, 0x7a, 0x5d, 0x47, 0xaf, 0xfb, + 0x15, 0x0, 0x1c, 0x92, 0x45, 0xb0, 0xbd, 0xe1, 0x6d, 0x80, 0x95, 0x4a, 0x36, 0x40, 0x31, 0x6e, 0xb, + 0xc0, 0xbf, 0x9f, 0x4d, 0x9, 0xf, 0xda, 0xe3, 0xef, 0x78, 0x37, 0x17, 0xca, 0x3d, 0x23, 0x7e, 0x89, + 0x18, 0x0, 0x0, 0x66, 0xe, 0x1c, 0x0, 0x0, 0x16, 0x0, 0x12, 0x5b, 0x4b, 0x96, 0xdd, 0xc7, 0xb5, + 0x7d, 0xd4, 0x33, 0x41, 0x36, 0x9f, 0xb8, 0xde, 0xa1, 0x13, 0x25, 0xaa}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x27, 0x28, 0xe1, 0x8b, 0x72, 0x50, 0x7e, 0x45, 0x71, + 0xcd, 0x75, 0x6d, 0x42, 0xd8, 0x4b, 0x26, 0xb6}; + uint8_t bytesprops2[] = {0x2e, 0x65}; + uint8_t bytesprops3[] = {0xbb, 0x50, 0x52, 0xc0, 0xfa, 0x30, 0x32, 0x79, 0x9f, 0x2e, 0x1d, 0xb8, 0x6, + 0x9a, 0x5d, 0xa7, 0xe, 0x84, 0x7e, 0xfc, 0xa5, 0x77, 0x59, 0x6c, 0x95, 0xd8}; + uint8_t bytesprops4[] = {0x91, 0x49, 0xce, 0x8e, 0x2d, 0x66, 0x9f, 0xee, 0x20, 0x3d, 0xa7, 0x52, 0xc7, 0x1, 0xf9, + 0x42, 0x3e, 0x3a, 0x54, 0xa9, 0xb3, 0xc1, 0x34, 0x66, 0x5, 0xf8, 0xfa, 0xa9, 0xf}; + uint8_t bytesprops5[] = {0xc3, 0x97, 0x57, 0x5c, 0xab, 0x79, 0xd9, 0xc2, 0x8d, 0x89, 0x9c, 0x6b, + 0xa5, 0x62, 0x3e, 0x28, 0x1, 0x1d, 0x7a, 0x5d, 0x47, 0xaf, 0xfb}; + uint8_t bytesprops6[] = {0x92, 0x45, 0xb0, 0xbd, 0xe1, 0x6d, 0x80, 0x95, 0x4a, 0x36, 0x40, 0x31, 0x6e, 0xb, + 0xc0, 0xbf, 0x9f, 0x4d, 0x9, 0xf, 0xda, 0xe3, 0xef, 0x78, 0x37, 0x17, 0xca, 0x3d}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops8[] = {0x5b, 0x4b, 0x96, 0xdd, 0xc7, 0xb5, 0x7d, 0xd4, 0x33, + 0x41, 0x36, 0x9f, 0xb8, 0xde, 0xa1, 0x13, 0x25, 0xaa}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12219}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28021}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13573}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27401}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops5}, .v = {8, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23185}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops7}, .v = {14, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20930}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15670}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17262}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30402}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13701}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10414}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32393}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26126}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 158, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 148, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoProtocolError [PropSessionExpiryInterval 17134,PropReasonString -// "k\149",PropAuthenticationMethod "\177\SOH\241\RSP9\147\174\146\202\142%",PropTopicAlias -// 19959,PropPayloadFormatIndicator 75,PropPayloadFormatIndicator 70,PropTopicAliasMaximum 17295,PropUserProperty -// "`7\248\135\153\220-\219\145\\/\152\FS?O\171\DC4g#[\174D" -// "\181\CAN\204\159\227\159hK\146\189FV^\\\233$Y{\DC2\147\176\&0\ETX\200",PropRetainAvailable 177,PropContentType -// "|\133\238\230\191\255D\ESC\255r9\137\218\184\SUB \239=\218\\\ACK\151xd",PropRequestResponseInformation 222] +// DisconnectRequest DiscoNotAuthorized [PropServerKeepAlive 20971,PropRequestProblemInformation 82,PropCorrelationData +// "\t\194|9N\143vPU\237\162.\NAK\211\169\145_\203\225\241\179\133\174\215\212\n",PropMaximumQoS +// 178,PropRequestResponseInformation 217,PropRequestProblemInformation 4,PropTopicAlias 10045,PropResponseInformation +// "\219\EOT\220\152",PropMaximumQoS 87,PropSharedSubscriptionAvailable 145,PropSubscriptionIdentifier +// 23,PropCorrelationData "9\150\183\ESC\163\138\140\182\249\149\235",PropPayloadFormatIndicator 194,PropReasonString +// "i\231!t)nv\135\n\184\227~dJBW",PropResponseInformation "\136r\206\238\SO1\151\217\240F\241J",PropServerKeepAlive +// 27793,PropSharedSubscriptionAvailable 189,PropReasonString "t\170\&8.fZ\214\153(\SIU\199K`\DLE\166)\STX"] TEST(Disco5QCTest, Encode29) { - uint8_t pkt[] = {0xe0, 0x77, 0x82, 0x75, 0x11, 0x0, 0x0, 0x42, 0xee, 0x1f, 0x0, 0x2, 0x6b, 0x95, 0x15, 0x0, - 0xc, 0xb1, 0x1, 0xf1, 0x1e, 0x50, 0x39, 0x93, 0xae, 0x92, 0xca, 0x8e, 0x25, 0x23, 0x4d, 0xf7, - 0x1, 0x4b, 0x1, 0x46, 0x22, 0x43, 0x8f, 0x26, 0x0, 0x16, 0x60, 0x37, 0xf8, 0x87, 0x99, 0xdc, - 0x2d, 0xdb, 0x91, 0x5c, 0x2f, 0x98, 0x1c, 0x3f, 0x4f, 0xab, 0x14, 0x67, 0x23, 0x5b, 0xae, 0x44, - 0x0, 0x18, 0xb5, 0x18, 0xcc, 0x9f, 0xe3, 0x9f, 0x68, 0x4b, 0x92, 0xbd, 0x46, 0x56, 0x5e, 0x5c, - 0xe9, 0x24, 0x59, 0x7b, 0x12, 0x93, 0xb0, 0x30, 0x3, 0xc8, 0x25, 0xb1, 0x3, 0x0, 0x18, 0x7c, - 0x85, 0xee, 0xe6, 0xbf, 0xff, 0x44, 0x1b, 0xff, 0x72, 0x39, 0x89, 0xda, 0xb8, 0x1a, 0x20, 0xef, - 0x3d, 0xda, 0x5c, 0x6, 0x97, 0x78, 0x64, 0x19, 0xde}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x6b, 0x95}; - uint8_t bytesprops1[] = {0xb1, 0x1, 0xf1, 0x1e, 0x50, 0x39, 0x93, 0xae, 0x92, 0xca, 0x8e, 0x25}; - uint8_t bytesprops3[] = {0xb5, 0x18, 0xcc, 0x9f, 0xe3, 0x9f, 0x68, 0x4b, 0x92, 0xbd, 0x46, 0x56, - 0x5e, 0x5c, 0xe9, 0x24, 0x59, 0x7b, 0x12, 0x93, 0xb0, 0x30, 0x3, 0xc8}; - uint8_t bytesprops2[] = {0x60, 0x37, 0xf8, 0x87, 0x99, 0xdc, 0x2d, 0xdb, 0x91, 0x5c, 0x2f, - 0x98, 0x1c, 0x3f, 0x4f, 0xab, 0x14, 0x67, 0x23, 0x5b, 0xae, 0x44}; - uint8_t bytesprops4[] = {0x7c, 0x85, 0xee, 0xe6, 0xbf, 0xff, 0x44, 0x1b, 0xff, 0x72, 0x39, 0x89, - 0xda, 0xb8, 0x1a, 0x20, 0xef, 0x3d, 0xda, 0x5c, 0x6, 0x97, 0x78, 0x64}; + uint8_t pkt[] = {0xe0, 0x87, 0x1, 0x87, 0x84, 0x1, 0x13, 0x51, 0xeb, 0x17, 0x52, 0x9, 0x0, 0x1a, 0x9, 0xc2, + 0x7c, 0x39, 0x4e, 0x8f, 0x76, 0x50, 0x55, 0xed, 0xa2, 0x2e, 0x15, 0xd3, 0xa9, 0x91, 0x5f, 0xcb, + 0xe1, 0xf1, 0xb3, 0x85, 0xae, 0xd7, 0xd4, 0xa, 0x24, 0xb2, 0x19, 0xd9, 0x17, 0x4, 0x23, 0x27, + 0x3d, 0x1a, 0x0, 0x4, 0xdb, 0x4, 0xdc, 0x98, 0x24, 0x57, 0x2a, 0x91, 0xb, 0x17, 0x9, 0x0, + 0xb, 0x39, 0x96, 0xb7, 0x1b, 0xa3, 0x8a, 0x8c, 0xb6, 0xf9, 0x95, 0xeb, 0x1, 0xc2, 0x1f, 0x0, + 0x10, 0x69, 0xe7, 0x21, 0x74, 0x29, 0x6e, 0x76, 0x87, 0xa, 0xb8, 0xe3, 0x7e, 0x64, 0x4a, 0x42, + 0x57, 0x1a, 0x0, 0xc, 0x88, 0x72, 0xce, 0xee, 0xe, 0x31, 0x97, 0xd9, 0xf0, 0x46, 0xf1, 0x4a, + 0x13, 0x6c, 0x91, 0x2a, 0xbd, 0x1f, 0x0, 0x12, 0x74, 0xaa, 0x38, 0x2e, 0x66, 0x5a, 0xd6, 0x99, + 0x28, 0xf, 0x55, 0xc7, 0x4b, 0x60, 0x10, 0xa6, 0x29, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x9, 0xc2, 0x7c, 0x39, 0x4e, 0x8f, 0x76, 0x50, 0x55, 0xed, 0xa2, 0x2e, 0x15, + 0xd3, 0xa9, 0x91, 0x5f, 0xcb, 0xe1, 0xf1, 0xb3, 0x85, 0xae, 0xd7, 0xd4, 0xa}; + uint8_t bytesprops1[] = {0xdb, 0x4, 0xdc, 0x98}; + uint8_t bytesprops2[] = {0x39, 0x96, 0xb7, 0x1b, 0xa3, 0x8a, 0x8c, 0xb6, 0xf9, 0x95, 0xeb}; + uint8_t bytesprops3[] = {0x69, 0xe7, 0x21, 0x74, 0x29, 0x6e, 0x76, 0x87, + 0xa, 0xb8, 0xe3, 0x7e, 0x64, 0x4a, 0x42, 0x57}; + uint8_t bytesprops4[] = {0x88, 0x72, 0xce, 0xee, 0xe, 0x31, 0x97, 0xd9, 0xf0, 0x46, 0xf1, 0x4a}; + uint8_t bytesprops5[] = {0x74, 0xaa, 0x38, 0x2e, 0x66, 0x5a, 0xd6, 0x99, 0x28, + 0xf, 0x55, 0xc7, 0x4b, 0x60, 0x10, 0xa6, 0x29, 0x2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17134}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19959}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17295}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops2}, .v = {24, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20971}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10045}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 145}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27793}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 130, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 135, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoServerBusy [PropTopicAlias 22226,PropWildcardSubscriptionAvailable -// 179,PropPayloadFormatIndicator 241,PropAuthenticationData "}D#\230\EM\153\170\180\175\198T\ETXI",PropServerReference -// "\186h\174\\\SOH\184\180\&7\180\203\bH\240f",PropTopicAlias 5079,PropServerReference "jZ(\b\RS!O\252*>j{{?%c\""] +// DisconnectRequest DiscoSessiontakenOver [PropResponseInformation +// "\b\255EV`\151k\n\140Q\154\251\143\\6\148\146\179\v",PropMessageExpiryInterval 29816,PropServerKeepAlive +// 23021,PropTopicAlias 15077,PropSharedSubscriptionAvailable 241,PropSubscriptionIdentifierAvailable 12] TEST(Disco5QCTest, Encode30) { - uint8_t pkt[] = {0xe0, 0x41, 0x89, 0x3f, 0x23, 0x56, 0xd2, 0x28, 0xb3, 0x1, 0xf1, 0x16, 0x0, 0xd, 0x7d, 0x44, 0x23, - 0xe6, 0x19, 0x99, 0xaa, 0xb4, 0xaf, 0xc6, 0x54, 0x3, 0x49, 0x1c, 0x0, 0xe, 0xba, 0x68, 0xae, 0x5c, - 0x1, 0xb8, 0xb4, 0x37, 0xb4, 0xcb, 0x8, 0x48, 0xf0, 0x66, 0x23, 0x13, 0xd7, 0x1c, 0x0, 0x11, 0x6a, - 0x5a, 0x28, 0x8, 0x1e, 0x21, 0x4f, 0xfc, 0x2a, 0x3e, 0x6a, 0x7b, 0x7b, 0x3f, 0x25, 0x63, 0x22}; + uint8_t pkt[] = {0xe0, 0x27, 0x8e, 0x25, 0x1a, 0x0, 0x13, 0x8, 0xff, 0x45, 0x56, 0x60, 0x97, 0x6b, + 0xa, 0x8c, 0x51, 0x9a, 0xfb, 0x8f, 0x5c, 0x36, 0x94, 0x92, 0xb3, 0xb, 0x2, 0x0, + 0x0, 0x74, 0x78, 0x13, 0x59, 0xed, 0x23, 0x3a, 0xe5, 0x2a, 0xf1, 0x29, 0xc}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7d, 0x44, 0x23, 0xe6, 0x19, 0x99, 0xaa, 0xb4, 0xaf, 0xc6, 0x54, 0x3, 0x49}; - uint8_t bytesprops1[] = {0xba, 0x68, 0xae, 0x5c, 0x1, 0xb8, 0xb4, 0x37, 0xb4, 0xcb, 0x8, 0x48, 0xf0, 0x66}; - uint8_t bytesprops2[] = {0x6a, 0x5a, 0x28, 0x8, 0x1e, 0x21, 0x4f, 0xfc, 0x2a, - 0x3e, 0x6a, 0x7b, 0x7b, 0x3f, 0x25, 0x63, 0x22}; + uint8_t bytesprops0[] = {0x8, 0xff, 0x45, 0x56, 0x60, 0x97, 0x6b, 0xa, 0x8c, 0x51, + 0x9a, 0xfb, 0x8f, 0x5c, 0x36, 0x94, 0x92, 0xb3, 0xb}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22226}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 179}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5079}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29816}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23021}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15077}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 12}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 137, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 142, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); diff --git a/tests/packet.cpp b/tests/packet.cpp index 0f46ee3..34aae41 100644 --- a/tests/packet.cpp +++ b/tests/packet.cpp @@ -327,7 +327,9 @@ TEST(AckTest, Decode1) { bool dup; uint16_t packet_id; - lwmqtt_err_t err = lwmqtt_decode_ack(pkt, 4, LWMQTT_PUBACK_PACKET, &dup, &packet_id); + uint8_t status; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_ack(pkt, 4, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(dup, false); @@ -344,7 +346,9 @@ TEST(AckTest, DecodeError1) { bool dup; uint16_t packet_id; - lwmqtt_err_t err = lwmqtt_decode_ack(pkt, 4, LWMQTT_PUBACK_PACKET, &dup, &packet_id); + uint8_t status; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_ack(pkt, 4, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_REMAINING_LENGTH_MISMATCH); } @@ -359,7 +363,9 @@ TEST(AckTest, DecodeError2) { bool dup; uint16_t packet_id; - lwmqtt_err_t err = lwmqtt_decode_ack(pkt, 4, LWMQTT_PUBACK_PACKET, &dup, &packet_id); + uint8_t status; + lwmqtt_serialized_properties_t props; + lwmqtt_err_t err = lwmqtt_decode_ack(pkt, 4, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_REMAINING_LENGTH_MISMATCH); } @@ -374,7 +380,7 @@ TEST(AckTest, Encode1) { uint8_t buf[4]; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, 4, &len, LWMQTT_PUBACK_PACKET, 0, 7); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, 4, &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 7, 0, empty_props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); @@ -384,7 +390,7 @@ TEST(AckTest, EncodeError1) { uint8_t buf[2]; // <- too small buffer size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, 2, &len, LWMQTT_PUBACK_PACKET, 0, 7); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, 2, &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 7, 0, empty_props); EXPECT_EQ(err, LWMQTT_BUFFER_TOO_SHORT); } From 4b7da360b2666953d27cf68fae452077eb986978 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Sat, 21 Sep 2019 14:59:30 -0700 Subject: [PATCH 25/26] Consider returned status in pub ACKs. --- gentests/app/Main.hs | 5 +- include/lwmqtt.h | 1 + src/packet.c | 4 + tests/generated.cpp | 39719 ++++++++++++++++++++--------------------- 4 files changed, 18999 insertions(+), 20730 deletions(-) diff --git a/gentests/app/Main.hs b/gentests/app/Main.hs index 97e8482..565f9aa 100644 --- a/gentests/app/Main.hs +++ b/gentests/app/Main.hs @@ -451,7 +451,7 @@ genPubACKTest prot i pkt = enc <> dec "lwmqtt_serialized_properties_t props;\n", "bool dup;\n", "lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), ", protlvl prot, ", ", cname pkt, ", &dup, &packet_id, &status, &props);\n", - "EXPECT_EQ(err, LWMQTT_SUCCESS);\n", + "EXPECT_EQ(err, ", exst st, ");\n", "EXPECT_EQ(packet_id, ", show pid, ");\n", "EXPECT_EQ(status, ", show st, ");\n" ] @@ -466,6 +466,9 @@ genPubACKTest prot i pkt = enc <> dec st = let (_,s,_) = parts pkt in s props = let (_,_,p) = parts pkt in p + exst 0 = "LWMQTT_SUCCESS" + exst _ = "LWMQTT_PUBACK_NACKED" + parts (ACK (PubACK a b p)) = (a,b,p) parts (REC (PubREC a b p)) = (a,b,p) parts (REL (PubREL a b p)) = (a,b,p) diff --git a/include/lwmqtt.h b/include/lwmqtt.h index 5adddcc..bf5090b 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -30,6 +30,7 @@ typedef enum { LWMQTT_SUBACK_ARRAY_OVERFLOW = -12, LWMQTT_PONG_TIMEOUT = -13, LWMQTT_FAILED_UNSUBSCRIPTION = -14, + LWMQTT_PUBACK_NACKED = -15, } lwmqtt_err_t; /** diff --git a/src/packet.c b/src/packet.c index 098c844..ed4bd6c 100644 --- a/src/packet.c +++ b/src/packet.c @@ -374,6 +374,10 @@ lwmqtt_err_t lwmqtt_decode_ack(uint8_t *buf, size_t buf_len, lwmqtt_protocol_t p } } + if (*status != 0) { + return LWMQTT_PUBACK_NACKED; + } + return LWMQTT_SUCCESS; } diff --git a/tests/generated.cpp b/tests/generated.cpp index cb64cd4..96eba40 100644 --- a/tests/generated.cpp +++ b/tests/generated.cpp @@ -21,43 +21,35 @@ extern "C" { } \ } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "W\217\244\199\US\166I\171\225H\165\&0\148+>'\185\243\243\254\182\&3\158\130", _pubPktID = 5484, _pubBody = -// "N\151Gu\207\213\209\175\151\241[\RS\128P\129\237\157\250K", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\201\174\&5}Y\150\209fI\146", _pubProps = []} TEST(Publish311QCTest, Encode1) { - uint8_t pkt[] = {0x3b, 0x2f, 0x0, 0x18, 0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, 0xa5, 0x30, 0x94, - 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82, 0x15, 0x6c, 0x4e, 0x97, 0x47, 0x75, - 0xcf, 0xd5, 0xd1, 0xaf, 0x97, 0xf1, 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; - uint8_t topic_bytes[] = {0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, 0xa5, 0x30, - 0x94, 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82}; - lwmqtt_string_t topic = {24, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0xc, 0x0, 0x0, 0xc9, 0xae, 0x35, 0x7d, 0x59, 0x96, 0xd1, 0x66, 0x49, 0x92}; + uint8_t topic_bytes[] = {0}; + lwmqtt_string_t topic = {0, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x4e, 0x97, 0x47, 0x75, 0xcf, 0xd5, 0xd1, 0xaf, 0x97, 0xf1, - 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; + uint8_t msg_bytes[] = {0xc9, 0xae, 0x35, 0x7d, 0x59, 0x96, 0xd1, 0x66, 0x49, 0x92}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 19; + msg.payload_len = 10; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5484, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "W\217\244\199\US\166I\171\225H\165\&0\148+>'\185\243\243\254\182\&3\158\130", _pubPktID = 5484, _pubBody = -// "N\151Gu\207\213\209\175\151\241[\RS\128P\129\237\157\250K", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\201\174\&5}Y\150\209fI\146", _pubProps = []} TEST(Publish311QCTest, Decode1) { - uint8_t pkt[] = {0x3b, 0x2f, 0x0, 0x18, 0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, 0xa5, 0x30, 0x94, - 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82, 0x15, 0x6c, 0x4e, 0x97, 0x47, 0x75, - 0xcf, 0xd5, 0xd1, 0xaf, 0x97, 0xf1, 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; + uint8_t pkt[] = {0x31, 0xc, 0x0, 0x0, 0xc9, 0xae, 0x35, 0x7d, 0x59, 0x96, 0xd1, 0x66, 0x49, 0x92}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -66,62 +58,57 @@ TEST(Publish311QCTest, Decode1) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x57, 0xd9, 0xf4, 0xc7, 0x1f, 0xa6, 0x49, 0xab, 0xe1, 0x48, 0xa5, 0x30, - 0x94, 0x2b, 0x3e, 0x27, 0xb9, 0xf3, 0xf3, 0xfe, 0xb6, 0x33, 0x9e, 0x82}; - lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4e, 0x97, 0x47, 0x75, 0xcf, 0xd5, 0xd1, 0xaf, 0x97, 0xf1, - 0x5b, 0x1e, 0x80, 0x50, 0x81, 0xed, 0x9d, 0xfa, 0x4b}; - lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + uint8_t exp_topic_bytes[] = {0}; + lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xc9, 0xae, 0x35, 0x7d, 0x59, 0x96, 0xd1, 0x66, 0x49, 0x92}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 5484); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\164_xCoe\161\\\SYN8\247~X\178U\EOT\201\239d\NUL\v\219\239", _pubPktID = 617, _pubBody = -// "\203\"\151M\221\179{\230\DC3c\185\FS\183-\225\169\214\ETX\128\159\170E\186\239\ESC\153\192\142", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\178\&4?\195\154\241'~\229S\255\SO\a40\221\ESC\221:N\212F\r\188l", _pubPktID = 2511, _pubBody = +// "'6\224\138\ETB\f{\166\251\224\EM", _pubProps = []} TEST(Publish311QCTest, Encode2) { - uint8_t pkt[] = {0x3b, 0x37, 0x0, 0x17, 0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, - 0x7e, 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef, 0x2, 0x69, 0xcb, - 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, 0xe1, 0xa9, - 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; - uint8_t topic_bytes[] = {0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, - 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x28, 0x0, 0x19, 0xb2, 0x34, 0x3f, 0xc3, 0x9a, 0xf1, 0x27, 0x7e, 0xe5, 0x53, + 0xff, 0xe, 0x7, 0x34, 0x30, 0xdd, 0x1b, 0xdd, 0x3a, 0x4e, 0xd4, 0x46, 0xd, 0xbc, + 0x6c, 0x9, 0xcf, 0x27, 0x36, 0xe0, 0x8a, 0x17, 0xc, 0x7b, 0xa6, 0xfb, 0xe0, 0x19}; + uint8_t topic_bytes[] = {0xb2, 0x34, 0x3f, 0xc3, 0x9a, 0xf1, 0x27, 0x7e, 0xe5, 0x53, 0xff, 0xe, 0x7, + 0x34, 0x30, 0xdd, 0x1b, 0xdd, 0x3a, 0x4e, 0xd4, 0x46, 0xd, 0xbc, 0x6c}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, - 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; + uint8_t msg_bytes[] = {0x27, 0x36, 0xe0, 0x8a, 0x17, 0xc, 0x7b, 0xa6, 0xfb, 0xe0, 0x19}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 11; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 617, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 2511, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\164_xCoe\161\\\SYN8\247~X\178U\EOT\201\239d\NUL\v\219\239", _pubPktID = 617, _pubBody = -// "\203\"\151M\221\179{\230\DC3c\185\FS\183-\225\169\214\ETX\128\159\170E\186\239\ESC\153\192\142", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\178\&4?\195\154\241'~\229S\255\SO\a40\221\ESC\221:N\212F\r\188l", _pubPktID = 2511, _pubBody = +// "'6\224\138\ETB\f{\166\251\224\EM", _pubProps = []} TEST(Publish311QCTest, Decode2) { - uint8_t pkt[] = {0x3b, 0x37, 0x0, 0x17, 0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, - 0x7e, 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef, 0x2, 0x69, 0xcb, - 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, 0xe1, 0xa9, - 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; + uint8_t pkt[] = {0x33, 0x28, 0x0, 0x19, 0xb2, 0x34, 0x3f, 0xc3, 0x9a, 0xf1, 0x27, 0x7e, 0xe5, 0x53, + 0xff, 0xe, 0x7, 0x34, 0x30, 0xdd, 0x1b, 0xdd, 0x3a, 0x4e, 0xd4, 0x46, 0xd, 0xbc, + 0x6c, 0x9, 0xcf, 0x27, 0x36, 0xe0, 0x8a, 0x17, 0xc, 0x7b, 0xa6, 0xfb, 0xe0, 0x19}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -130,41 +117,39 @@ TEST(Publish311QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, - 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, - 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xb2, 0x34, 0x3f, 0xc3, 0x9a, 0xf1, 0x27, 0x7e, 0xe5, 0x53, 0xff, 0xe, 0x7, + 0x34, 0x30, 0xdd, 0x1b, 0xdd, 0x3a, 0x4e, 0xd4, 0x46, 0xd, 0xbc, 0x6c}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x27, 0x36, 0xe0, 0x8a, 0x17, 0xc, 0x7b, 0xa6, 0xfb, 0xe0, 0x19}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 617); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(packet_id, 2511); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "]\DEL\239p\251\205\214zi\204\179\194Y\158", _pubPktID = 0, _pubBody = -// "|\207v\144\230\175\FSN\178\165\215\DC3\EM\250\162\187\135\181", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "J\178\233\r\ETBB\156\DC4\237T\199\169", _pubPktID = 0, _pubBody = +// "\"\231\233q\224v\140\216\174\175\203\242]\142\187\218", _pubProps = []} TEST(Publish311QCTest, Encode3) { - uint8_t pkt[] = {0x39, 0x22, 0x0, 0xe, 0x5d, 0x7f, 0xef, 0x70, 0xfb, 0xcd, 0xd6, 0x7a, - 0x69, 0xcc, 0xb3, 0xc2, 0x59, 0x9e, 0x7c, 0xcf, 0x76, 0x90, 0xe6, 0xaf, - 0x1c, 0x4e, 0xb2, 0xa5, 0xd7, 0x13, 0x19, 0xfa, 0xa2, 0xbb, 0x87, 0xb5}; - uint8_t topic_bytes[] = {0x5d, 0x7f, 0xef, 0x70, 0xfb, 0xcd, 0xd6, 0x7a, 0x69, 0xcc, 0xb3, 0xc2, 0x59, 0x9e}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x1e, 0x0, 0xc, 0x4a, 0xb2, 0xe9, 0xd, 0x17, 0x42, 0x9c, 0x14, 0xed, 0x54, 0xc7, 0xa9, + 0x22, 0xe7, 0xe9, 0x71, 0xe0, 0x76, 0x8c, 0xd8, 0xae, 0xaf, 0xcb, 0xf2, 0x5d, 0x8e, 0xbb, 0xda}; + uint8_t topic_bytes[] = {0x4a, 0xb2, 0xe9, 0xd, 0x17, 0x42, 0x9c, 0x14, 0xed, 0x54, 0xc7, 0xa9}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x7c, 0xcf, 0x76, 0x90, 0xe6, 0xaf, 0x1c, 0x4e, 0xb2, - 0xa5, 0xd7, 0x13, 0x19, 0xfa, 0xa2, 0xbb, 0x87, 0xb5}; + msg.retained = false; + uint8_t msg_bytes[] = {0x22, 0xe7, 0xe9, 0x71, 0xe0, 0x76, 0x8c, 0xd8, + 0xae, 0xaf, 0xcb, 0xf2, 0x5d, 0x8e, 0xbb, 0xda}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 18; + msg.payload_len = 16; lwmqtt_property_t propslist[] = {}; @@ -176,13 +161,12 @@ TEST(Publish311QCTest, Encode3) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "]\DEL\239p\251\205\214zi\204\179\194Y\158", _pubPktID = 0, _pubBody = -// "|\207v\144\230\175\FSN\178\165\215\DC3\EM\250\162\187\135\181", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "J\178\233\r\ETBB\156\DC4\237T\199\169", _pubPktID = 0, _pubBody = +// "\"\231\233q\224v\140\216\174\175\203\242]\142\187\218", _pubProps = []} TEST(Publish311QCTest, Decode3) { - uint8_t pkt[] = {0x39, 0x22, 0x0, 0xe, 0x5d, 0x7f, 0xef, 0x70, 0xfb, 0xcd, 0xd6, 0x7a, - 0x69, 0xcc, 0xb3, 0xc2, 0x59, 0x9e, 0x7c, 0xcf, 0x76, 0x90, 0xe6, 0xaf, - 0x1c, 0x4e, 0xb2, 0xa5, 0xd7, 0x13, 0x19, 0xfa, 0xa2, 0xbb, 0x87, 0xb5}; + uint8_t pkt[] = {0x38, 0x1e, 0x0, 0xc, 0x4a, 0xb2, 0xe9, 0xd, 0x17, 0x42, 0x9c, 0x14, 0xed, 0x54, 0xc7, 0xa9, + 0x22, 0xe7, 0xe9, 0x71, 0xe0, 0x76, 0x8c, 0xd8, 0xae, 0xaf, 0xcb, 0xf2, 0x5d, 0x8e, 0xbb, 0xda}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -191,51 +175,61 @@ TEST(Publish311QCTest, Decode3) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5d, 0x7f, 0xef, 0x70, 0xfb, 0xcd, 0xd6, 0x7a, 0x69, 0xcc, 0xb3, 0xc2, 0x59, 0x9e}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x7c, 0xcf, 0x76, 0x90, 0xe6, 0xaf, 0x1c, 0x4e, 0xb2, - 0xa5, 0xd7, 0x13, 0x19, 0xfa, 0xa2, 0xbb, 0x87, 0xb5}; - lwmqtt_string_t exp_body = {18, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x4a, 0xb2, 0xe9, 0xd, 0x17, 0x42, 0x9c, 0x14, 0xed, 0x54, 0xc7, 0xa9}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x22, 0xe7, 0xe9, 0x71, 0xe0, 0x76, 0x8c, 0xd8, + 0xae, 0xaf, 0xcb, 0xf2, 0x5d, 0x8e, 0xbb, 0xda}; + lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\&8\RSE", _pubPktID = 14265, -// _pubBody = "OtS\167", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(\166\195\173\148\GS\175\209g\RS\b\244\191\221\186\\Z\149\158\195\NUL\158\202{\242", _pubPktID = 7293, _pubBody = +// "\177?\SI\SI1\226\146\135\CAN\224\SYNIK\STX\237y\n\SUBT\185\&7$\f\253My\202C", _pubProps = []} TEST(Publish311QCTest, Encode4) { - uint8_t pkt[] = {0x3d, 0xc, 0x0, 0x4, 0xff, 0x38, 0x1e, 0x45, 0x37, 0xb9, 0x4f, 0x74, 0x53, 0xa7}; - uint8_t topic_bytes[] = {0xff, 0x38, 0x1e, 0x45}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x39, 0x0, 0x19, 0x28, 0xa6, 0xc3, 0xad, 0x94, 0x1d, 0xaf, 0xd1, 0x67, 0x1e, 0x8, + 0xf4, 0xbf, 0xdd, 0xba, 0x5c, 0x5a, 0x95, 0x9e, 0xc3, 0x0, 0x9e, 0xca, 0x7b, 0xf2, 0x1c, + 0x7d, 0xb1, 0x3f, 0xf, 0xf, 0x31, 0xe2, 0x92, 0x87, 0x18, 0xe0, 0x16, 0x49, 0x4b, 0x2, + 0xed, 0x79, 0xa, 0x1a, 0x54, 0xb9, 0x37, 0x24, 0xc, 0xfd, 0x4d, 0x79, 0xca, 0x43}; + uint8_t topic_bytes[] = {0x28, 0xa6, 0xc3, 0xad, 0x94, 0x1d, 0xaf, 0xd1, 0x67, 0x1e, 0x8, 0xf4, 0xbf, + 0xdd, 0xba, 0x5c, 0x5a, 0x95, 0x9e, 0xc3, 0x0, 0x9e, 0xca, 0x7b, 0xf2}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x4f, 0x74, 0x53, 0xa7}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xb1, 0x3f, 0xf, 0xf, 0x31, 0xe2, 0x92, 0x87, 0x18, 0xe0, 0x16, 0x49, 0x4b, 0x2, + 0xed, 0x79, 0xa, 0x1a, 0x54, 0xb9, 0x37, 0x24, 0xc, 0xfd, 0x4d, 0x79, 0xca, 0x43}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 28; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 14265, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7293, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\&8\RSE", _pubPktID = 14265, -// _pubBody = "OtS\167", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(\166\195\173\148\GS\175\209g\RS\b\244\191\221\186\\Z\149\158\195\NUL\158\202{\242", _pubPktID = 7293, _pubBody = +// "\177?\SI\SI1\226\146\135\CAN\224\SYNIK\STX\237y\n\SUBT\185\&7$\f\253My\202C", _pubProps = []} TEST(Publish311QCTest, Decode4) { - uint8_t pkt[] = {0x3d, 0xc, 0x0, 0x4, 0xff, 0x38, 0x1e, 0x45, 0x37, 0xb9, 0x4f, 0x74, 0x53, 0xa7}; + uint8_t pkt[] = {0x32, 0x39, 0x0, 0x19, 0x28, 0xa6, 0xc3, 0xad, 0x94, 0x1d, 0xaf, 0xd1, 0x67, 0x1e, 0x8, + 0xf4, 0xbf, 0xdd, 0xba, 0x5c, 0x5a, 0x95, 0x9e, 0xc3, 0x0, 0x9e, 0xca, 0x7b, 0xf2, 0x1c, + 0x7d, 0xb1, 0x3f, 0xf, 0xf, 0x31, 0xe2, 0x92, 0x87, 0x18, 0xe0, 0x16, 0x49, 0x4b, 0x2, + 0xed, 0x79, 0xa, 0x1a, 0x54, 0xb9, 0x37, 0x24, 0xc, 0xfd, 0x4d, 0x79, 0xca, 0x43}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -244,57 +238,60 @@ TEST(Publish311QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xff, 0x38, 0x1e, 0x45}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4f, 0x74, 0x53, 0xa7}; - lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 14265); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 4); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + uint8_t exp_topic_bytes[] = {0x28, 0xa6, 0xc3, 0xad, 0x94, 0x1d, 0xaf, 0xd1, 0x67, 0x1e, 0x8, 0xf4, 0xbf, + 0xdd, 0xba, 0x5c, 0x5a, 0x95, 0x9e, 0xc3, 0x0, 0x9e, 0xca, 0x7b, 0xf2}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb1, 0x3f, 0xf, 0xf, 0x31, 0xe2, 0x92, 0x87, 0x18, 0xe0, 0x16, 0x49, 0x4b, 0x2, + 0xed, 0x79, 0xa, 0x1a, 0x54, 0xb9, 0x37, 0x24, 0xc, 0xfd, 0x4d, 0x79, 0xca, 0x43}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7293); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\175\137\vj?Vv\214\&1|l\a\RS\191\237\148\187\223g^\158f\195W\245R\159", _pubPktID = 0, _pubBody = -// "\133\170\157HgVe\197\170\203V\231", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\239!qf)\DC1R\192\227\STX\227\191\ENQ\163\242\172\201\233\225\150\242\USr\DEL", _pubPktID = 8490, _pubBody = +// "Hj(;\171\211\&2\147\237^\SO\175\143\&0\161\182\EM", _pubProps = []} TEST(Publish311QCTest, Encode5) { - uint8_t pkt[] = {0x39, 0x29, 0x0, 0x1b, 0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, - 0x7, 0x1e, 0xbf, 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, - 0x9f, 0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; - uint8_t topic_bytes[] = {0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, 0x7, 0x1e, 0xbf, - 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x2d, 0x0, 0x18, 0xef, 0x21, 0x71, 0x66, 0x29, 0x11, 0x52, 0xc0, 0xe3, 0x2, 0xe3, 0xbf, + 0x5, 0xa3, 0xf2, 0xac, 0xc9, 0xe9, 0xe1, 0x96, 0xf2, 0x1f, 0x72, 0x7f, 0x21, 0x2a, 0x48, 0x6a, + 0x28, 0x3b, 0xab, 0xd3, 0x32, 0x93, 0xed, 0x5e, 0xe, 0xaf, 0x8f, 0x30, 0xa1, 0xb6, 0x19}; + uint8_t topic_bytes[] = {0xef, 0x21, 0x71, 0x66, 0x29, 0x11, 0x52, 0xc0, 0xe3, 0x2, 0xe3, 0xbf, + 0x5, 0xa3, 0xf2, 0xac, 0xc9, 0xe9, 0xe1, 0x96, 0xf2, 0x1f, 0x72, 0x7f}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x48, 0x6a, 0x28, 0x3b, 0xab, 0xd3, 0x32, 0x93, 0xed, + 0x5e, 0xe, 0xaf, 0x8f, 0x30, 0xa1, 0xb6, 0x19}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8490, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\175\137\vj?Vv\214\&1|l\a\RS\191\237\148\187\223g^\158f\195W\245R\159", _pubPktID = 0, _pubBody = -// "\133\170\157HgVe\197\170\203V\231", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\239!qf)\DC1R\192\227\STX\227\191\ENQ\163\242\172\201\233\225\150\242\USr\DEL", _pubPktID = 8490, _pubBody = +// "Hj(;\171\211\&2\147\237^\SO\175\143\&0\161\182\EM", _pubProps = []} TEST(Publish311QCTest, Decode5) { - uint8_t pkt[] = {0x39, 0x29, 0x0, 0x1b, 0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, - 0x7, 0x1e, 0xbf, 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, - 0x9f, 0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; + uint8_t pkt[] = {0x32, 0x2d, 0x0, 0x18, 0xef, 0x21, 0x71, 0x66, 0x29, 0x11, 0x52, 0xc0, 0xe3, 0x2, 0xe3, 0xbf, + 0x5, 0xa3, 0xf2, 0xac, 0xc9, 0xe9, 0xe1, 0x96, 0xf2, 0x1f, 0x72, 0x7f, 0x21, 0x2a, 0x48, 0x6a, + 0x28, 0x3b, 0xab, 0xd3, 0x32, 0x93, 0xed, 0x5e, 0xe, 0xaf, 0x8f, 0x30, 0xa1, 0xb6, 0x19}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -303,53 +300,60 @@ TEST(Publish311QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, 0x7, 0x1e, 0xbf, - 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + uint8_t exp_topic_bytes[] = {0xef, 0x21, 0x71, 0x66, 0x29, 0x11, 0x52, 0xc0, 0xe3, 0x2, 0xe3, 0xbf, + 0x5, 0xa3, 0xf2, 0xac, 0xc9, 0xe9, 0xe1, 0x96, 0xf2, 0x1f, 0x72, 0x7f}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x48, 0x6a, 0x28, 0x3b, 0xab, 0xd3, 0x32, 0x93, 0xed, + 0x5e, 0xe, 0xaf, 0x8f, 0x30, 0xa1, 0xb6, 0x19}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 8490); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\fn)\RS", _pubPktID = 5499, _pubBody -// = "\156I\SUB\231\236b\ENQ\137\237\r\NAK:[\222g\135", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "~\225\DLELiZW,vB\173`\255\CAN+\v\194\238", _pubPktID = 25725, _pubBody = +// "\188\SO\205\140\237\238\138\149\210\239m\246\ACK>\DC4\249\182\183(\131\128\&5\164X\173\&0C", _pubProps = []} TEST(Publish311QCTest, Encode6) { - uint8_t pkt[] = {0x3a, 0x18, 0x0, 0x4, 0xc, 0x6e, 0x29, 0x1e, 0x15, 0x7b, 0x9c, 0x49, 0x1a, - 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; - uint8_t topic_bytes[] = {0xc, 0x6e, 0x29, 0x1e}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x31, 0x0, 0x12, 0x7e, 0xe1, 0x10, 0x4c, 0x69, 0x5a, 0x57, 0x2c, 0x76, 0x42, 0xad, 0x60, 0xff, + 0x18, 0x2b, 0xb, 0xc2, 0xee, 0x64, 0x7d, 0xbc, 0xe, 0xcd, 0x8c, 0xed, 0xee, 0x8a, 0x95, 0xd2, 0xef, + 0x6d, 0xf6, 0x6, 0x3e, 0x14, 0xf9, 0xb6, 0xb7, 0x28, 0x83, 0x80, 0x35, 0xa4, 0x58, 0xad, 0x30, 0x43}; + uint8_t topic_bytes[] = {0x7e, 0xe1, 0x10, 0x4c, 0x69, 0x5a, 0x57, 0x2c, 0x76, + 0x42, 0xad, 0x60, 0xff, 0x18, 0x2b, 0xb, 0xc2, 0xee}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x9c, 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; + uint8_t msg_bytes[] = {0xbc, 0xe, 0xcd, 0x8c, 0xed, 0xee, 0x8a, 0x95, 0xd2, 0xef, 0x6d, 0xf6, 0x6, 0x3e, + 0x14, 0xf9, 0xb6, 0xb7, 0x28, 0x83, 0x80, 0x35, 0xa4, 0x58, 0xad, 0x30, 0x43}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 27; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 5499, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 25725, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\fn)\RS", _pubPktID = 5499, _pubBody -// = "\156I\SUB\231\236b\ENQ\137\237\r\NAK:[\222g\135", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "~\225\DLELiZW,vB\173`\255\CAN+\v\194\238", _pubPktID = 25725, _pubBody = +// "\188\SO\205\140\237\238\138\149\210\239m\246\ACK>\DC4\249\182\183(\131\128\&5\164X\173\&0C", _pubProps = []} TEST(Publish311QCTest, Decode6) { - uint8_t pkt[] = {0x3a, 0x18, 0x0, 0x4, 0xc, 0x6e, 0x29, 0x1e, 0x15, 0x7b, 0x9c, 0x49, 0x1a, - 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; + uint8_t pkt[] = {0x3c, 0x31, 0x0, 0x12, 0x7e, 0xe1, 0x10, 0x4c, 0x69, 0x5a, 0x57, 0x2c, 0x76, 0x42, 0xad, 0x60, 0xff, + 0x18, 0x2b, 0xb, 0xc2, 0xee, 0x64, 0x7d, 0xbc, 0xe, 0xcd, 0x8c, 0xed, 0xee, 0x8a, 0x95, 0xd2, 0xef, + 0x6d, 0xf6, 0x6, 0x3e, 0x14, 0xf9, 0xb6, 0xb7, 0x28, 0x83, 0x80, 0x35, 0xa4, 0x58, 0xad, 0x30, 0x43}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -358,61 +362,59 @@ TEST(Publish311QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc, 0x6e, 0x29, 0x1e}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9c, 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, - 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7e, 0xe1, 0x10, 0x4c, 0x69, 0x5a, 0x57, 0x2c, 0x76, + 0x42, 0xad, 0x60, 0xff, 0x18, 0x2b, 0xb, 0xc2, 0xee}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbc, 0xe, 0xcd, 0x8c, 0xed, 0xee, 0x8a, 0x95, 0xd2, 0xef, 0x6d, 0xf6, 0x6, 0x3e, + 0x14, 0xf9, 0xb6, 0xb7, 0x28, 0x83, 0x80, 0x35, 0xa4, 0x58, 0xad, 0x30, 0x43}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 5499); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(packet_id, 25725); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\213\v\236\218d\193\162h[\237\155\196\145\159\198g\146\138\155\197\164", _pubPktID = 0, _pubBody = -// "\189\233\193\r`$@\171\DC1\230\203j\203\187J\148oG\177\155\SUB\253\232\211\t\DC4#\230", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "_\173\SI\187N\192\141\207\237\228\129\187v\189VY\232b\187N\179\SO", _pubPktID = 26097, _pubBody = +// "\175\134\253\152O\211\174\USV\DC4\249", _pubProps = []} TEST(Publish311QCTest, Encode7) { - uint8_t pkt[] = {0x38, 0x33, 0x0, 0x15, 0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, - 0x9b, 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4, 0xbd, 0xe9, 0xc1, - 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, 0x4a, 0x94, 0x6f, - 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; - uint8_t topic_bytes[] = {0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, 0x9b, - 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x25, 0x0, 0x16, 0x5f, 0xad, 0xf, 0xbb, 0x4e, 0xc0, 0x8d, 0xcf, 0xed, + 0xe4, 0x81, 0xbb, 0x76, 0xbd, 0x56, 0x59, 0xe8, 0x62, 0xbb, 0x4e, 0xb3, 0xe, + 0x65, 0xf1, 0xaf, 0x86, 0xfd, 0x98, 0x4f, 0xd3, 0xae, 0x1f, 0x56, 0x14, 0xf9}; + uint8_t topic_bytes[] = {0x5f, 0xad, 0xf, 0xbb, 0x4e, 0xc0, 0x8d, 0xcf, 0xed, 0xe4, 0x81, + 0xbb, 0x76, 0xbd, 0x56, 0x59, 0xe8, 0x62, 0xbb, 0x4e, 0xb3, 0xe}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, - 0x4a, 0x94, 0x6f, 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; + uint8_t msg_bytes[] = {0xaf, 0x86, 0xfd, 0x98, 0x4f, 0xd3, 0xae, 0x1f, 0x56, 0x14, 0xf9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 11; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 26097, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\213\v\236\218d\193\162h[\237\155\196\145\159\198g\146\138\155\197\164", _pubPktID = 0, _pubBody = -// "\189\233\193\r`$@\171\DC1\230\203j\203\187J\148oG\177\155\SUB\253\232\211\t\DC4#\230", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "_\173\SI\187N\192\141\207\237\228\129\187v\189VY\232b\187N\179\SO", _pubPktID = 26097, _pubBody = +// "\175\134\253\152O\211\174\USV\DC4\249", _pubProps = []} TEST(Publish311QCTest, Decode7) { - uint8_t pkt[] = {0x38, 0x33, 0x0, 0x15, 0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, - 0x9b, 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4, 0xbd, 0xe9, 0xc1, - 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, 0x4a, 0x94, 0x6f, - 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; + uint8_t pkt[] = {0x34, 0x25, 0x0, 0x16, 0x5f, 0xad, 0xf, 0xbb, 0x4e, 0xc0, 0x8d, 0xcf, 0xed, + 0xe4, 0x81, 0xbb, 0x76, 0xbd, 0x56, 0x59, 0xe8, 0x62, 0xbb, 0x4e, 0xb3, 0xe, + 0x65, 0xf1, 0xaf, 0x86, 0xfd, 0x98, 0x4f, 0xd3, 0xae, 0x1f, 0x56, 0x14, 0xf9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -421,60 +423,53 @@ TEST(Publish311QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, 0x9b, - 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, - 0x4a, 0x94, 0x6f, 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + uint8_t exp_topic_bytes[] = {0x5f, 0xad, 0xf, 0xbb, 0x4e, 0xc0, 0x8d, 0xcf, 0xed, 0xe4, 0x81, + 0xbb, 0x76, 0xbd, 0x56, 0x59, 0xe8, 0x62, 0xbb, 0x4e, 0xb3, 0xe}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xaf, 0x86, 0xfd, 0x98, 0x4f, 0xd3, 0xae, 0x1f, 0x56, 0x14, 0xf9}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(packet_id, 26097); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "=\249\252\228\210\187\154\150C8*\146,\US8\152\128\152", _pubPktID = 8421, _pubBody = -// "4O\FS\186T\238#\USg\NULl\152\154\239\249\SUB2>H#\188", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\196L\196\FS8\154\173\EOT\225", +// _pubPktID = 3661, _pubBody = "\223\209u\180\&7\134", _pubProps = []} TEST(Publish311QCTest, Encode8) { - uint8_t pkt[] = {0x32, 0x2b, 0x0, 0x12, 0x3d, 0xf9, 0xfc, 0xe4, 0xd2, 0xbb, 0x9a, 0x96, 0x43, 0x38, 0x2a, - 0x92, 0x2c, 0x1f, 0x38, 0x98, 0x80, 0x98, 0x20, 0xe5, 0x34, 0x4f, 0x1c, 0xba, 0x54, 0xee, - 0x23, 0x1f, 0x67, 0x0, 0x6c, 0x98, 0x9a, 0xef, 0xf9, 0x1a, 0x32, 0x3e, 0x48, 0x23, 0xbc}; - uint8_t topic_bytes[] = {0x3d, 0xf9, 0xfc, 0xe4, 0xd2, 0xbb, 0x9a, 0x96, 0x43, - 0x38, 0x2a, 0x92, 0x2c, 0x1f, 0x38, 0x98, 0x80, 0x98}; - lwmqtt_string_t topic = {18, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x13, 0x0, 0x9, 0xc4, 0x4c, 0xc4, 0x1c, 0x38, 0x9a, 0xad, + 0x4, 0xe1, 0xe, 0x4d, 0xdf, 0xd1, 0x75, 0xb4, 0x37, 0x86}; + uint8_t topic_bytes[] = {0xc4, 0x4c, 0xc4, 0x1c, 0x38, 0x9a, 0xad, 0x4, 0xe1}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = false; - uint8_t msg_bytes[] = {0x34, 0x4f, 0x1c, 0xba, 0x54, 0xee, 0x23, 0x1f, 0x67, 0x0, 0x6c, - 0x98, 0x9a, 0xef, 0xf9, 0x1a, 0x32, 0x3e, 0x48, 0x23, 0xbc}; + uint8_t msg_bytes[] = {0xdf, 0xd1, 0x75, 0xb4, 0x37, 0x86}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 6; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 8421, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 3661, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "=\249\252\228\210\187\154\150C8*\146,\US8\152\128\152", _pubPktID = 8421, _pubBody = -// "4O\FS\186T\238#\USg\NULl\152\154\239\249\SUB2>H#\188", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\196L\196\FS8\154\173\EOT\225", +// _pubPktID = 3661, _pubBody = "\223\209u\180\&7\134", _pubProps = []} TEST(Publish311QCTest, Decode8) { - uint8_t pkt[] = {0x32, 0x2b, 0x0, 0x12, 0x3d, 0xf9, 0xfc, 0xe4, 0xd2, 0xbb, 0x9a, 0x96, 0x43, 0x38, 0x2a, - 0x92, 0x2c, 0x1f, 0x38, 0x98, 0x80, 0x98, 0x20, 0xe5, 0x34, 0x4f, 0x1c, 0xba, 0x54, 0xee, - 0x23, 0x1f, 0x67, 0x0, 0x6c, 0x98, 0x9a, 0xef, 0xf9, 0x1a, 0x32, 0x3e, 0x48, 0x23, 0xbc}; + uint8_t pkt[] = {0x3a, 0x13, 0x0, 0x9, 0xc4, 0x4c, 0xc4, 0x1c, 0x38, 0x9a, 0xad, + 0x4, 0xe1, 0xe, 0x4d, 0xdf, 0xd1, 0x75, 0xb4, 0x37, 0x86}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -483,54 +478,58 @@ TEST(Publish311QCTest, Decode8) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3d, 0xf9, 0xfc, 0xe4, 0xd2, 0xbb, 0x9a, 0x96, 0x43, - 0x38, 0x2a, 0x92, 0x2c, 0x1f, 0x38, 0x98, 0x80, 0x98}; - lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x34, 0x4f, 0x1c, 0xba, 0x54, 0xee, 0x23, 0x1f, 0x67, 0x0, 0x6c, - 0x98, 0x9a, 0xef, 0xf9, 0x1a, 0x32, 0x3e, 0x48, 0x23, 0xbc}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xc4, 0x4c, 0xc4, 0x1c, 0x38, 0x9a, 0xad, 0x4, 0xe1}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xdf, 0xd1, 0x75, 0xb4, 0x37, 0x86}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 8421); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 3661); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\SO\191\141\159\DC1$vw", _pubPktID = -// 301, _pubBody = "`\195\&7\ESC_\216\219\237?~,\244", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\b\201MSc\140\128\CANs\162;\213\155\SO\151\139\229\SOH\229\197", _pubPktID = 30138, _pubBody = +// "`6\148\134s,\US`Z\206\157\252jI5w9\138e\176\183\141}", _pubProps = []} TEST(Publish311QCTest, Encode9) { - uint8_t pkt[] = {0x3b, 0x18, 0x0, 0x8, 0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77, 0x1, - 0x2d, 0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; - uint8_t topic_bytes[] = {0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x2f, 0x0, 0x14, 0x8, 0xc9, 0x4d, 0x53, 0x63, 0x8c, 0x80, 0x18, 0x73, 0xa2, 0x3b, 0xd5, 0x9b, + 0xe, 0x97, 0x8b, 0xe5, 0x1, 0xe5, 0xc5, 0x75, 0xba, 0x60, 0x36, 0x94, 0x86, 0x73, 0x2c, 0x1f, 0x60, + 0x5a, 0xce, 0x9d, 0xfc, 0x6a, 0x49, 0x35, 0x77, 0x39, 0x8a, 0x65, 0xb0, 0xb7, 0x8d, 0x7d}; + uint8_t topic_bytes[] = {0x8, 0xc9, 0x4d, 0x53, 0x63, 0x8c, 0x80, 0x18, 0x73, 0xa2, + 0x3b, 0xd5, 0x9b, 0xe, 0x97, 0x8b, 0xe5, 0x1, 0xe5, 0xc5}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; + uint8_t msg_bytes[] = {0x60, 0x36, 0x94, 0x86, 0x73, 0x2c, 0x1f, 0x60, 0x5a, 0xce, 0x9d, 0xfc, + 0x6a, 0x49, 0x35, 0x77, 0x39, 0x8a, 0x65, 0xb0, 0xb7, 0x8d, 0x7d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 23; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 301, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 30138, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\SO\191\141\159\DC1$vw", _pubPktID = -// 301, _pubBody = "`\195\&7\ESC_\216\219\237?~,\244", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\b\201MSc\140\128\CANs\162;\213\155\SO\151\139\229\SOH\229\197", _pubPktID = 30138, _pubBody = +// "`6\148\134s,\US`Z\206\157\252jI5w9\138e\176\183\141}", _pubProps = []} TEST(Publish311QCTest, Decode9) { - uint8_t pkt[] = {0x3b, 0x18, 0x0, 0x8, 0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77, 0x1, - 0x2d, 0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; + uint8_t pkt[] = {0x3b, 0x2f, 0x0, 0x14, 0x8, 0xc9, 0x4d, 0x53, 0x63, 0x8c, 0x80, 0x18, 0x73, 0xa2, 0x3b, 0xd5, 0x9b, + 0xe, 0x97, 0x8b, 0xe5, 0x1, 0xe5, 0xc5, 0x75, 0xba, 0x60, 0x36, 0x94, 0x86, 0x73, 0x2c, 0x1f, 0x60, + 0x5a, 0xce, 0x9d, 0xfc, 0x6a, 0x49, 0x35, 0x77, 0x39, 0x8a, 0x65, 0xb0, 0xb7, 0x8d, 0x7d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -539,52 +538,54 @@ TEST(Publish311QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x8, 0xc9, 0x4d, 0x53, 0x63, 0x8c, 0x80, 0x18, 0x73, 0xa2, + 0x3b, 0xd5, 0x9b, 0xe, 0x97, 0x8b, 0xe5, 0x1, 0xe5, 0xc5}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x60, 0x36, 0x94, 0x86, 0x73, 0x2c, 0x1f, 0x60, 0x5a, 0xce, 0x9d, 0xfc, + 0x6a, 0x49, 0x35, 0x77, 0x39, 0x8a, 0x65, 0xb0, 0xb7, 0x8d, 0x7d}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 301); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + EXPECT_EQ(packet_id, 30138); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\227=\STX\236\214\&2\250\EM@M^\ENQ\161\aE8", _pubPktID = 19635, _pubBody = "\EOT\EM", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\177\SUB\139\129\ETB\208\148", +// _pubPktID = 30010, _pubBody = "`\USq\198\217\144\199Zp9", _pubProps = []} TEST(Publish311QCTest, Encode10) { - uint8_t pkt[] = {0x3b, 0x16, 0x0, 0x10, 0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, - 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38, 0x4c, 0xb3, 0x4, 0x19}; - uint8_t topic_bytes[] = {0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0x15, 0x0, 0x7, 0xb1, 0x1a, 0x8b, 0x81, 0x17, 0xd0, 0x94, 0x75, + 0x3a, 0x60, 0x1f, 0x71, 0xc6, 0xd9, 0x90, 0xc7, 0x5a, 0x70, 0x39}; + uint8_t topic_bytes[] = {0xb1, 0x1a, 0x8b, 0x81, 0x17, 0xd0, 0x94}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x4, 0x19}; + msg.retained = false; + uint8_t msg_bytes[] = {0x60, 0x1f, 0x71, 0xc6, 0xd9, 0x90, 0xc7, 0x5a, 0x70, 0x39}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 10; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 19635, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 30010, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\227=\STX\236\214\&2\250\EM@M^\ENQ\161\aE8", _pubPktID = 19635, _pubBody = "\EOT\EM", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\177\SUB\139\129\ETB\208\148", +// _pubPktID = 30010, _pubBody = "`\USq\198\217\144\199Zp9", _pubProps = []} TEST(Publish311QCTest, Decode10) { - uint8_t pkt[] = {0x3b, 0x16, 0x0, 0x10, 0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, - 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38, 0x4c, 0xb3, 0x4, 0x19}; + uint8_t pkt[] = {0x32, 0x15, 0x0, 0x7, 0xb1, 0x1a, 0x8b, 0x81, 0x17, 0xd0, 0x94, 0x75, + 0x3a, 0x60, 0x1f, 0x71, 0xc6, 0xd9, 0x90, 0xc7, 0x5a, 0x70, 0x39}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -593,61 +594,55 @@ TEST(Publish311QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, - 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38}; - lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4, 0x19}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xb1, 0x1a, 0x8b, 0x81, 0x17, 0xd0, 0x94}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x60, 0x1f, 0x71, 0xc6, 0xd9, 0x90, 0xc7, 0x5a, 0x70, 0x39}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 19635); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 30010); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\207FX\fp\139\210\201Q\185\161i$\222\214\221\238\n.\134\157L7\178\&1", _pubPktID = 10816, _pubBody = -// "b[\173.*\158(\194-\180ZS\221\236\188\168\182\172p\192\216\246\196\176\200\248\&1\232a", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\203", _pubPktID = 182, _pubBody = +// "\145y\231n\252\238pw\ACK\168Lc~\152\153\129W\\\SIK\134\251\185\SOH\208\EMV\"", _pubProps = []} TEST(Publish311QCTest, Encode11) { - uint8_t pkt[] = {0x34, 0x3a, 0x0, 0x19, 0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, - 0x69, 0x24, 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31, 0x2a, - 0x40, 0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, - 0xbc, 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; - uint8_t topic_bytes[] = {0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, 0x69, 0x24, - 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x21, 0x0, 0x1, 0xcb, 0x0, 0xb6, 0x91, 0x79, 0xe7, 0x6e, 0xfc, + 0xee, 0x70, 0x77, 0x6, 0xa8, 0x4c, 0x63, 0x7e, 0x98, 0x99, 0x81, 0x57, + 0x5c, 0xf, 0x4b, 0x86, 0xfb, 0xb9, 0x1, 0xd0, 0x19, 0x56, 0x22}; + uint8_t topic_bytes[] = {0xcb}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, 0xbc, - 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x91, 0x79, 0xe7, 0x6e, 0xfc, 0xee, 0x70, 0x77, 0x6, 0xa8, 0x4c, 0x63, 0x7e, 0x98, + 0x99, 0x81, 0x57, 0x5c, 0xf, 0x4b, 0x86, 0xfb, 0xb9, 0x1, 0xd0, 0x19, 0x56, 0x22}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 28; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 10816, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 182, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\207FX\fp\139\210\201Q\185\161i$\222\214\221\238\n.\134\157L7\178\&1", _pubPktID = 10816, _pubBody = -// "b[\173.*\158(\194-\180ZS\221\236\188\168\182\172p\192\216\246\196\176\200\248\&1\232a", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\203", _pubPktID = 182, _pubBody = +// "\145y\231n\252\238pw\ACK\168Lc~\152\153\129W\\\SIK\134\251\185\SOH\208\EMV\"", _pubProps = []} TEST(Publish311QCTest, Decode11) { - uint8_t pkt[] = {0x34, 0x3a, 0x0, 0x19, 0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, - 0x69, 0x24, 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31, 0x2a, - 0x40, 0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, - 0xbc, 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; + uint8_t pkt[] = {0x3b, 0x21, 0x0, 0x1, 0xcb, 0x0, 0xb6, 0x91, 0x79, 0xe7, 0x6e, 0xfc, + 0xee, 0x70, 0x77, 0x6, 0xa8, 0x4c, 0x63, 0x7e, 0x98, 0x99, 0x81, 0x57, + 0x5c, 0xf, 0x4b, 0x86, 0xfb, 0xb9, 0x1, 0xd0, 0x19, 0x56, 0x22}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -656,62 +651,53 @@ TEST(Publish311QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, 0x69, 0x24, - 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, 0xbc, - 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10816); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + uint8_t exp_topic_bytes[] = {0xcb}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x91, 0x79, 0xe7, 0x6e, 0xfc, 0xee, 0x70, 0x77, 0x6, 0xa8, 0x4c, 0x63, 0x7e, 0x98, + 0x99, 0x81, 0x57, 0x5c, 0xf, 0x4b, 0x86, 0xfb, 0xb9, 0x1, 0xd0, 0x19, 0x56, 0x22}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 182); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "C:\210I?H\140\153\163\FS\190\141PA\209Z6\210G=S\217\242\219S\237\226\a", _pubPktID = 780, _pubBody = -// "\185b.\FS\147|\157\223\176\240\ENQy\185\208\DC4\186(topic.data), 28); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10741); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "x\170\228C2\140C\ACKD\FS/[\214\EOT\SOH", _pubPktID = 0, _pubBody = "\185", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\180^\180\196\166\GS\142\ETB\np\US\226\226j-\130\242+\138\234A", _pubPktID = 0, _pubBody = +// "\STXN8tdLv\171\220\&3tu\225\159\165V\148\183&W6\202\202\165r\SOH", _pubProps = []} TEST(Publish311QCTest, Encode13) { - uint8_t pkt[] = {0x31, 0x12, 0x0, 0xf, 0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, - 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1, 0xb9}; - uint8_t topic_bytes[] = {0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x31, 0x0, 0x15, 0xb4, 0x5e, 0xb4, 0xc4, 0xa6, 0x1d, 0x8e, 0x17, 0xa, 0x70, 0x1f, 0xe2, 0xe2, + 0x6a, 0x2d, 0x82, 0xf2, 0x2b, 0x8a, 0xea, 0x41, 0x2, 0x4e, 0x38, 0x74, 0x64, 0x4c, 0x76, 0xab, 0xdc, + 0x33, 0x74, 0x75, 0xe1, 0x9f, 0xa5, 0x56, 0x94, 0xb7, 0x26, 0x57, 0x36, 0xca, 0xca, 0xa5, 0x72, 0x1}; + uint8_t topic_bytes[] = {0xb4, 0x5e, 0xb4, 0xc4, 0xa6, 0x1d, 0x8e, 0x17, 0xa, 0x70, 0x1f, + 0xe2, 0xe2, 0x6a, 0x2d, 0x82, 0xf2, 0x2b, 0x8a, 0xea, 0x41}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xb9}; + msg.retained = false; + uint8_t msg_bytes[] = {0x2, 0x4e, 0x38, 0x74, 0x64, 0x4c, 0x76, 0xab, 0xdc, 0x33, 0x74, 0x75, 0xe1, + 0x9f, 0xa5, 0x56, 0x94, 0xb7, 0x26, 0x57, 0x36, 0xca, 0xca, 0xa5, 0x72, 0x1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; + msg.payload_len = 26; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "x\170\228C2\140C\ACKD\FS/[\214\EOT\SOH", _pubPktID = 0, _pubBody = "\185", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\180^\180\196\166\GS\142\ETB\np\US\226\226j-\130\242+\138\234A", _pubPktID = 0, _pubBody = +// "\STXN8tdLv\171\220\&3tu\225\159\165V\148\183&W6\202\202\165r\SOH", _pubProps = []} TEST(Publish311QCTest, Decode13) { - uint8_t pkt[] = {0x31, 0x12, 0x0, 0xf, 0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, - 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1, 0xb9}; + uint8_t pkt[] = {0x38, 0x31, 0x0, 0x15, 0xb4, 0x5e, 0xb4, 0xc4, 0xa6, 0x1d, 0x8e, 0x17, 0xa, 0x70, 0x1f, 0xe2, 0xe2, + 0x6a, 0x2d, 0x82, 0xf2, 0x2b, 0x8a, 0xea, 0x41, 0x2, 0x4e, 0x38, 0x74, 0x64, 0x4c, 0x76, 0xab, 0xdc, + 0x33, 0x74, 0x75, 0xe1, 0x9f, 0xa5, 0x56, 0x94, 0xb7, 0x26, 0x57, 0x36, 0xca, 0xca, 0xa5, 0x72, 0x1}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -776,55 +766,60 @@ TEST(Publish311QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb9}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xb4, 0x5e, 0xb4, 0xc4, 0xa6, 0x1d, 0x8e, 0x17, 0xa, 0x70, 0x1f, + 0xe2, 0xe2, 0x6a, 0x2d, 0x82, 0xf2, 0x2b, 0x8a, 0xea, 0x41}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2, 0x4e, 0x38, 0x74, 0x64, 0x4c, 0x76, 0xab, 0xdc, 0x33, 0x74, 0x75, 0xe1, + 0x9f, 0xa5, 0x56, 0x94, 0xb7, 0x26, 0x57, 0x36, 0xca, 0xca, 0xa5, 0x72, 0x1}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\EM\181N`\v\241\NAKi\133lU\172 -// ~\192\152\DLE2\173\193\158\SOH\252\&8/.\RS", _pubPktID = 21275, _pubBody = "'\189s+\222o/\187^\161", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\243\134\DC4\174\182\NAK\138\171\188\\\180\226\181G\223S\232\138f\172\170", _pubPktID = 0, _pubBody = +// "\b\177(\176\139\216T[#|\147\DC1\157R?$\242", _pubProps = []} TEST(Publish311QCTest, Encode14) { - uint8_t pkt[] = {0x32, 0x29, 0x0, 0x1b, 0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, - 0xac, 0x20, 0x7e, 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, - 0x1e, 0x53, 0x1b, 0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; - uint8_t topic_bytes[] = {0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, 0xac, 0x20, 0x7e, - 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, 0x1e}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x28, 0x0, 0x15, 0xf3, 0x86, 0x14, 0xae, 0xb6, 0x15, 0x8a, 0xab, 0xbc, 0x5c, + 0xb4, 0xe2, 0xb5, 0x47, 0xdf, 0x53, 0xe8, 0x8a, 0x66, 0xac, 0xaa, 0x8, 0xb1, 0x28, + 0xb0, 0x8b, 0xd8, 0x54, 0x5b, 0x23, 0x7c, 0x93, 0x11, 0x9d, 0x52, 0x3f, 0x24, 0xf2}; + uint8_t topic_bytes[] = {0xf3, 0x86, 0x14, 0xae, 0xb6, 0x15, 0x8a, 0xab, 0xbc, 0x5c, 0xb4, + 0xe2, 0xb5, 0x47, 0xdf, 0x53, 0xe8, 0x8a, 0x66, 0xac, 0xaa}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = false; - uint8_t msg_bytes[] = {0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; + msg.qos = LWMQTT_QOS0; + msg.retained = true; + uint8_t msg_bytes[] = {0x8, 0xb1, 0x28, 0xb0, 0x8b, 0xd8, 0x54, 0x5b, 0x23, + 0x7c, 0x93, 0x11, 0x9d, 0x52, 0x3f, 0x24, 0xf2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 10; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 21275, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\EM\181N`\v\241\NAKi\133lU\172 -// ~\192\152\DLE2\173\193\158\SOH\252\&8/.\RS", _pubPktID = 21275, _pubBody = "'\189s+\222o/\187^\161", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\243\134\DC4\174\182\NAK\138\171\188\\\180\226\181G\223S\232\138f\172\170", _pubPktID = 0, _pubBody = +// "\b\177(\176\139\216T[#|\147\DC1\157R?$\242", _pubProps = []} TEST(Publish311QCTest, Decode14) { - uint8_t pkt[] = {0x32, 0x29, 0x0, 0x1b, 0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, - 0xac, 0x20, 0x7e, 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, - 0x1e, 0x53, 0x1b, 0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; + uint8_t pkt[] = {0x31, 0x28, 0x0, 0x15, 0xf3, 0x86, 0x14, 0xae, 0xb6, 0x15, 0x8a, 0xab, 0xbc, 0x5c, + 0xb4, 0xe2, 0xb5, 0x47, 0xdf, 0x53, 0xe8, 0x8a, 0x66, 0xac, 0xaa, 0x8, 0xb1, 0x28, + 0xb0, 0x8b, 0xd8, 0x54, 0x5b, 0x23, 0x7c, 0x93, 0x11, 0x9d, 0x52, 0x3f, 0x24, 0xf2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -833,56 +828,55 @@ TEST(Publish311QCTest, Decode14) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x19, 0xb5, 0x4e, 0x60, 0xb, 0xf1, 0x15, 0x69, 0x85, 0x6c, 0x55, 0xac, 0x20, 0x7e, - 0xc0, 0x98, 0x10, 0x32, 0xad, 0xc1, 0x9e, 0x1, 0xfc, 0x38, 0x2f, 0x2e, 0x1e}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x27, 0xbd, 0x73, 0x2b, 0xde, 0x6f, 0x2f, 0xbb, 0x5e, 0xa1}; - lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xf3, 0x86, 0x14, 0xae, 0xb6, 0x15, 0x8a, 0xab, 0xbc, 0x5c, 0xb4, + 0xe2, 0xb5, 0x47, 0xdf, 0x53, 0xe8, 0x8a, 0x66, 0xac, 0xaa}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x8, 0xb1, 0x28, 0xb0, 0x8b, 0xd8, 0x54, 0x5b, 0x23, + 0x7c, 0x93, 0x11, 0x9d, 0x52, 0x3f, 0x24, 0xf2}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 21275); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\176\EMg\233", _pubPktID = 31111, -// _pubBody = "e\163\181)\SYN\133\198/d\225\216\252\177\&5v[\251\&3\219\232\135\&2\251>E\155#\DLE\254", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\CAN", _pubPktID = 21185, _pubBody = +// "\242\163\&2\173f\171\141\148\172\254\198\166\220=I\223\188q\204S\NUL\207\&8jS", _pubProps = []} TEST(Publish311QCTest, Encode15) { - uint8_t pkt[] = {0x34, 0x25, 0x0, 0x4, 0xb0, 0x19, 0x67, 0xe9, 0x79, 0x87, 0x65, 0xa3, 0xb5, - 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, 0x5b, - 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; - uint8_t topic_bytes[] = {0xb0, 0x19, 0x67, 0xe9}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x1e, 0x0, 0x1, 0x18, 0x52, 0xc1, 0xf2, 0xa3, 0x32, 0xad, 0x66, 0xab, 0x8d, 0x94, 0xac, + 0xfe, 0xc6, 0xa6, 0xdc, 0x3d, 0x49, 0xdf, 0xbc, 0x71, 0xcc, 0x53, 0x0, 0xcf, 0x38, 0x6a, 0x53}; + uint8_t topic_bytes[] = {0x18}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x65, 0xa3, 0xb5, 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, - 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xf2, 0xa3, 0x32, 0xad, 0x66, 0xab, 0x8d, 0x94, 0xac, 0xfe, 0xc6, 0xa6, 0xdc, + 0x3d, 0x49, 0xdf, 0xbc, 0x71, 0xcc, 0x53, 0x0, 0xcf, 0x38, 0x6a, 0x53}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 25; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 31111, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 21185, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\176\EMg\233", _pubPktID = 31111, -// _pubBody = "e\163\181)\SYN\133\198/d\225\216\252\177\&5v[\251\&3\219\232\135\&2\251>E\155#\DLE\254", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\CAN", _pubPktID = 21185, _pubBody = +// "\242\163\&2\173f\171\141\148\172\254\198\166\220=I\223\188q\204S\NUL\207\&8jS", _pubProps = []} TEST(Publish311QCTest, Decode15) { - uint8_t pkt[] = {0x34, 0x25, 0x0, 0x4, 0xb0, 0x19, 0x67, 0xe9, 0x79, 0x87, 0x65, 0xa3, 0xb5, - 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, 0x5b, - 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; + uint8_t pkt[] = {0x3b, 0x1e, 0x0, 0x1, 0x18, 0x52, 0xc1, 0xf2, 0xa3, 0x32, 0xad, 0x66, 0xab, 0x8d, 0x94, 0xac, + 0xfe, 0xc6, 0xa6, 0xdc, 0x3d, 0x49, 0xdf, 0xbc, 0x71, 0xcc, 0x53, 0x0, 0xcf, 0x38, 0x6a, 0x53}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -891,58 +885,54 @@ TEST(Publish311QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb0, 0x19, 0x67, 0xe9}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x65, 0xa3, 0xb5, 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, - 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 31111); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + uint8_t exp_topic_bytes[] = {0x18}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf2, 0xa3, 0x32, 0xad, 0x66, 0xab, 0x8d, 0x94, 0xac, 0xfe, 0xc6, 0xa6, 0xdc, + 0x3d, 0x49, 0xdf, 0xbc, 0x71, 0xcc, 0x53, 0x0, 0xcf, 0x38, 0x6a, 0x53}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 21185); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\169\&0\211V\249\144\&4+[\166\254\135\144\241\n\198\162\233\181\161i\132\132\ENQ\204\191", _pubPktID = 8952, -// _pubBody = "\173A\231|1\170\255\146o\191\190\DC2+uY", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\tW7", _pubPktID = 0, _pubBody = +// "<\173\DLE`;<%6\196ne\143\&7_\DC2&K\177\250\145(topic.data), 26); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\192!\207\251\220\139\197\DC3\237\227", _pubPktID = 0, _pubBody = -// "\245Ha\212\EM\NAK\214Qf\253*\177\142\202P\176\144\184\149N\DC4", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "#rf\225\210\223\183\179#", _pubPktID +// = 0, _pubBody = "\225\141\154:Z\166E\DLEF\164\218\176U\138\191\RSV[\255\160=\DC1@\195r~WH\245", _pubProps = []} TEST(Publish311QCTest, Encode17) { - uint8_t pkt[] = {0x38, 0x21, 0x0, 0xa, 0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, - 0xed, 0xe3, 0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, - 0x2a, 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; - uint8_t topic_bytes[] = {0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x28, 0x0, 0x9, 0x23, 0x72, 0x66, 0xe1, 0xd2, 0xdf, 0xb7, 0xb3, 0x23, 0xe1, + 0x8d, 0x9a, 0x3a, 0x5a, 0xa6, 0x45, 0x10, 0x46, 0xa4, 0xda, 0xb0, 0x55, 0x8a, 0xbf, + 0x1e, 0x56, 0x5b, 0xff, 0xa0, 0x3d, 0x11, 0x40, 0xc3, 0x72, 0x7e, 0x57, 0x48, 0xf5}; + uint8_t topic_bytes[] = {0x23, 0x72, 0x66, 0xe1, 0xd2, 0xdf, 0xb7, 0xb3, 0x23}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, - 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; + msg.retained = true; + uint8_t msg_bytes[] = {0xe1, 0x8d, 0x9a, 0x3a, 0x5a, 0xa6, 0x45, 0x10, 0x46, 0xa4, 0xda, 0xb0, 0x55, 0x8a, 0xbf, + 0x1e, 0x56, 0x5b, 0xff, 0xa0, 0x3d, 0x11, 0x40, 0xc3, 0x72, 0x7e, 0x57, 0x48, 0xf5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 29; lwmqtt_property_t propslist[] = {}; @@ -996,13 +985,12 @@ TEST(Publish311QCTest, Encode17) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\192!\207\251\220\139\197\DC3\237\227", _pubPktID = 0, _pubBody = -// "\245Ha\212\EM\NAK\214Qf\253*\177\142\202P\176\144\184\149N\DC4", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "#rf\225\210\223\183\179#", _pubPktID +// = 0, _pubBody = "\225\141\154:Z\166E\DLEF\164\218\176U\138\191\RSV[\255\160=\DC1@\195r~WH\245", _pubProps = []} TEST(Publish311QCTest, Decode17) { - uint8_t pkt[] = {0x38, 0x21, 0x0, 0xa, 0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, - 0xed, 0xe3, 0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, - 0x2a, 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; + uint8_t pkt[] = {0x39, 0x28, 0x0, 0x9, 0x23, 0x72, 0x66, 0xe1, 0xd2, 0xdf, 0xb7, 0xb3, 0x23, 0xe1, + 0x8d, 0x9a, 0x3a, 0x5a, 0xa6, 0x45, 0x10, 0x46, 0xa4, 0xda, 0xb0, 0x55, 0x8a, 0xbf, + 0x1e, 0x56, 0x5b, 0xff, 0xa0, 0x3d, 0x11, 0x40, 0xc3, 0x72, 0x7e, 0x57, 0x48, 0xf5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1011,58 +999,57 @@ TEST(Publish311QCTest, Decode17) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, - 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x23, 0x72, 0x66, 0xe1, 0xd2, 0xdf, 0xb7, 0xb3, 0x23}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xe1, 0x8d, 0x9a, 0x3a, 0x5a, 0xa6, 0x45, 0x10, 0x46, 0xa4, 0xda, 0xb0, 0x55, 0x8a, 0xbf, + 0x1e, 0x56, 0x5b, 0xff, 0xa0, 0x3d, 0x11, 0x40, 0xc3, 0x72, 0x7e, 0x57, 0x48, 0xf5}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\244\163\195\181~\198`:\150F\212N", -// _pubPktID = 32625, _pubBody = -// "\158m\139\172\171\135\&7\154\136\129\210{\228\197\SI[\STXw\192\242\239k\178\152Q\211\143S\146", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\250\DLE\228\172ZB\231\208\ETX\170e\DC3\177\170\203", _pubPktID = 20110, _pubBody = +// "xx\193Br\133\207:\183_\RS:zx\155", _pubProps = []} TEST(Publish311QCTest, Encode18) { - uint8_t pkt[] = {0x33, 0x2d, 0x0, 0xc, 0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e, - 0x7f, 0x71, 0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, - 0xf, 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; - uint8_t topic_bytes[] = {0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x22, 0x0, 0xf, 0xfa, 0x10, 0xe4, 0xac, 0x5a, 0x42, 0xe7, 0xd0, + 0x3, 0xaa, 0x65, 0x13, 0xb1, 0xaa, 0xcb, 0x4e, 0x8e, 0x78, 0x78, 0xc1, + 0x42, 0x72, 0x85, 0xcf, 0x3a, 0xb7, 0x5f, 0x1e, 0x3a, 0x7a, 0x78, 0x9b}; + uint8_t topic_bytes[] = {0xfa, 0x10, 0xe4, 0xac, 0x5a, 0x42, 0xe7, 0xd0, 0x3, 0xaa, 0x65, 0x13, 0xb1, 0xaa, 0xcb}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, - 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; + msg.retained = false; + uint8_t msg_bytes[] = {0x78, 0x78, 0xc1, 0x42, 0x72, 0x85, 0xcf, 0x3a, 0xb7, 0x5f, 0x1e, 0x3a, 0x7a, 0x78, 0x9b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 15; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32625, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 20110, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\244\163\195\181~\198`:\150F\212N", -// _pubPktID = 32625, _pubBody = -// "\158m\139\172\171\135\&7\154\136\129\210{\228\197\SI[\STXw\192\242\239k\178\152Q\211\143S\146", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\250\DLE\228\172ZB\231\208\ETX\170e\DC3\177\170\203", _pubPktID = 20110, _pubBody = +// "xx\193Br\133\207:\183_\RS:zx\155", _pubProps = []} TEST(Publish311QCTest, Decode18) { - uint8_t pkt[] = {0x33, 0x2d, 0x0, 0xc, 0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e, - 0x7f, 0x71, 0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, - 0xf, 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; + uint8_t pkt[] = {0x3a, 0x22, 0x0, 0xf, 0xfa, 0x10, 0xe4, 0xac, 0x5a, 0x42, 0xe7, 0xd0, + 0x3, 0xaa, 0x65, 0x13, 0xb1, 0xaa, 0xcb, 0x4e, 0x8e, 0x78, 0x78, 0xc1, + 0x42, 0x72, 0x85, 0xcf, 0x3a, 0xb7, 0x5f, 0x1e, 0x3a, 0x7a, 0x78, 0x9b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1071,57 +1058,53 @@ TEST(Publish311QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, - 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xfa, 0x10, 0xe4, 0xac, 0x5a, 0x42, 0xe7, 0xd0, 0x3, 0xaa, 0x65, 0x13, 0xb1, 0xaa, 0xcb}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x78, 0x78, 0xc1, 0x42, 0x72, 0x85, 0xcf, 0x3a, 0xb7, 0x5f, 0x1e, 0x3a, 0x7a, 0x78, 0x9b}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 32625); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 20110); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\156\\\v`\145\USn?\217L\147\211\\\SI\254", _pubPktID = 25006, _pubBody = -// "\207\181\171\145\132\166r/\NUL\137\195|e\244P\185", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\219DL\230\173kI\194", _pubPktID = +// 0, _pubBody = "k@\192\208$\186\173\v\213b\157\255\206\DLE\253xC", _pubProps = []} TEST(Publish311QCTest, Encode19) { - uint8_t pkt[] = {0x33, 0x23, 0x0, 0xf, 0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, - 0x4c, 0x93, 0xd3, 0x5c, 0xf, 0xfe, 0x61, 0xae, 0xcf, 0xb5, 0xab, 0x91, 0x84, - 0xa6, 0x72, 0x2f, 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; - uint8_t topic_bytes[] = {0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, 0x4c, 0x93, 0xd3, 0x5c, 0xf, 0xfe}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x1b, 0x0, 0x8, 0xdb, 0x44, 0x4c, 0xe6, 0xad, 0x6b, 0x49, 0xc2, 0x6b, 0x40, 0xc0, + 0xd0, 0x24, 0xba, 0xad, 0xb, 0xd5, 0x62, 0x9d, 0xff, 0xce, 0x10, 0xfd, 0x78, 0x43}; + uint8_t topic_bytes[] = {0xdb, 0x44, 0x4c, 0xe6, 0xad, 0x6b, 0x49, 0xc2}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xcf, 0xb5, 0xab, 0x91, 0x84, 0xa6, 0x72, 0x2f, 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x6b, 0x40, 0xc0, 0xd0, 0x24, 0xba, 0xad, 0xb, 0xd5, + 0x62, 0x9d, 0xff, 0xce, 0x10, 0xfd, 0x78, 0x43}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 17; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 25006, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\156\\\v`\145\USn?\217L\147\211\\\SI\254", _pubPktID = 25006, _pubBody = -// "\207\181\171\145\132\166r/\NUL\137\195|e\244P\185", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\219DL\230\173kI\194", _pubPktID = +// 0, _pubBody = "k@\192\208$\186\173\v\213b\157\255\206\DLE\253xC", _pubProps = []} TEST(Publish311QCTest, Decode19) { - uint8_t pkt[] = {0x33, 0x23, 0x0, 0xf, 0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, - 0x4c, 0x93, 0xd3, 0x5c, 0xf, 0xfe, 0x61, 0xae, 0xcf, 0xb5, 0xab, 0x91, 0x84, - 0xa6, 0x72, 0x2f, 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; + uint8_t pkt[] = {0x38, 0x1b, 0x0, 0x8, 0xdb, 0x44, 0x4c, 0xe6, 0xad, 0x6b, 0x49, 0xc2, 0x6b, 0x40, 0xc0, + 0xd0, 0x24, 0xba, 0xad, 0xb, 0xd5, 0x62, 0x9d, 0xff, 0xce, 0x10, 0xfd, 0x78, 0x43}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1130,53 +1113,53 @@ TEST(Publish311QCTest, Decode19) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, 0x4c, 0x93, 0xd3, 0x5c, 0xf, 0xfe}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcf, 0xb5, 0xab, 0x91, 0x84, 0xa6, 0x72, 0x2f, - 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 25006); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + uint8_t exp_topic_bytes[] = {0xdb, 0x44, 0x4c, 0xe6, 0xad, 0x6b, 0x49, 0xc2}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x6b, 0x40, 0xc0, 0xd0, 0x24, 0xba, 0xad, 0xb, 0xd5, + 0x62, 0x9d, 0xff, 0xce, 0x10, 0xfd, 0x78, 0x43}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\239p\183", _pubPktID = 0, _pubBody -// = "\STX\249\&8\215\vJ\163\136\174\235\187\163\ESCJ(\246", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "{\153\DLEV", _pubPktID = 16334, +// _pubBody = "\SI\238\166\129\190\133\&2k\213\ETBtC\246", _pubProps = []} TEST(Publish311QCTest, Encode20) { - uint8_t pkt[] = {0x31, 0x15, 0x0, 0x3, 0xef, 0x70, 0xb7, 0x2, 0xf9, 0x38, 0xd7, 0xb, - 0x4a, 0xa3, 0x88, 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; - uint8_t topic_bytes[] = {0xef, 0x70, 0xb7}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x15, 0x0, 0x4, 0x7b, 0x99, 0x10, 0x56, 0x3f, 0xce, 0xf, 0xee, + 0xa6, 0x81, 0xbe, 0x85, 0x32, 0x6b, 0xd5, 0x17, 0x74, 0x43, 0xf6}; + uint8_t topic_bytes[] = {0x7b, 0x99, 0x10, 0x56}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x2, 0xf9, 0x38, 0xd7, 0xb, 0x4a, 0xa3, 0x88, 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xf, 0xee, 0xa6, 0x81, 0xbe, 0x85, 0x32, 0x6b, 0xd5, 0x17, 0x74, 0x43, 0xf6}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 13; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 16334, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\239p\183", _pubPktID = 0, _pubBody -// = "\STX\249\&8\215\vJ\163\136\174\235\187\163\ESCJ(\246", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "{\153\DLEV", _pubPktID = 16334, +// _pubBody = "\SI\238\166\129\190\133\&2k\213\ETBtC\246", _pubProps = []} TEST(Publish311QCTest, Decode20) { - uint8_t pkt[] = {0x31, 0x15, 0x0, 0x3, 0xef, 0x70, 0xb7, 0x2, 0xf9, 0x38, 0xd7, 0xb, - 0x4a, 0xa3, 0x88, 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; + uint8_t pkt[] = {0x3c, 0x15, 0x0, 0x4, 0x7b, 0x99, 0x10, 0x56, 0x3f, 0xce, 0xf, 0xee, + 0xa6, 0x81, 0xbe, 0x85, 0x32, 0x6b, 0xd5, 0x17, 0x74, 0x43, 0xf6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1185,58 +1168,60 @@ TEST(Publish311QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xef, 0x70, 0xb7}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2, 0xf9, 0x38, 0xd7, 0xb, 0x4a, 0xa3, 0x88, - 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + uint8_t exp_topic_bytes[] = {0x7b, 0x99, 0x10, 0x56}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf, 0xee, 0xa6, 0x81, 0xbe, 0x85, 0x32, 0x6b, 0xd5, 0x17, 0x74, 0x43, 0xf6}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 16334); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[\133\227z\244\DC4 -// \\\241\207F|\141\128?F\t\249\DC2\DELs\245", _pubPktID = 23725, _pubBody = ";\229\241\239\169\193\152\160\149\FSQ", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\239\241 \154( +// \247t\"\246\ENQ\203\252\206\225\196\148\STX\222\"(\255\US}\194\188\172", _pubPktID = 17850, _pubBody = +// "\232#X\SOHr.\129\NAK\155\247c\170\231\193Y\254\ESC\ETX\216\&4\235\253EV@\ETB", _pubProps = []} TEST(Publish311QCTest, Encode21) { - uint8_t pkt[] = {0x33, 0x25, 0x0, 0x16, 0x5b, 0x85, 0xe3, 0x7a, 0xf4, 0x14, 0x20, 0x5c, 0xf1, - 0xcf, 0x46, 0x7c, 0x8d, 0x80, 0x3f, 0x46, 0x9, 0xf9, 0x12, 0x7f, 0x73, 0xf5, - 0x5c, 0xad, 0x3b, 0xe5, 0xf1, 0xef, 0xa9, 0xc1, 0x98, 0xa0, 0x95, 0x1c, 0x51}; - uint8_t topic_bytes[] = {0x5b, 0x85, 0xe3, 0x7a, 0xf4, 0x14, 0x20, 0x5c, 0xf1, 0xcf, 0x46, - 0x7c, 0x8d, 0x80, 0x3f, 0x46, 0x9, 0xf9, 0x12, 0x7f, 0x73, 0xf5}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x39, 0x0, 0x1b, 0xef, 0xf1, 0x20, 0x9a, 0x28, 0x20, 0xf7, 0x74, 0x22, 0xf6, 0x5, + 0xcb, 0xfc, 0xce, 0xe1, 0xc4, 0x94, 0x2, 0xde, 0x22, 0x28, 0xff, 0x1f, 0x7d, 0xc2, 0xbc, + 0xac, 0x45, 0xba, 0xe8, 0x23, 0x58, 0x1, 0x72, 0x2e, 0x81, 0x15, 0x9b, 0xf7, 0x63, 0xaa, + 0xe7, 0xc1, 0x59, 0xfe, 0x1b, 0x3, 0xd8, 0x34, 0xeb, 0xfd, 0x45, 0x56, 0x40, 0x17}; + uint8_t topic_bytes[] = {0xef, 0xf1, 0x20, 0x9a, 0x28, 0x20, 0xf7, 0x74, 0x22, 0xf6, 0x5, 0xcb, 0xfc, 0xce, + 0xe1, 0xc4, 0x94, 0x2, 0xde, 0x22, 0x28, 0xff, 0x1f, 0x7d, 0xc2, 0xbc, 0xac}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x3b, 0xe5, 0xf1, 0xef, 0xa9, 0xc1, 0x98, 0xa0, 0x95, 0x1c, 0x51}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xe8, 0x23, 0x58, 0x1, 0x72, 0x2e, 0x81, 0x15, 0x9b, 0xf7, 0x63, 0xaa, 0xe7, + 0xc1, 0x59, 0xfe, 0x1b, 0x3, 0xd8, 0x34, 0xeb, 0xfd, 0x45, 0x56, 0x40, 0x17}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 26; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 23725, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 17850, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[\133\227z\244\DC4 -// \\\241\207F|\141\128?F\t\249\DC2\DELs\245", _pubPktID = 23725, _pubBody = ";\229\241\239\169\193\152\160\149\FSQ", -// _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\239\241 \154( +// \247t\"\246\ENQ\203\252\206\225\196\148\STX\222\"(\255\US}\194\188\172", _pubPktID = 17850, _pubBody = +// "\232#X\SOHr.\129\NAK\155\247c\170\231\193Y\254\ESC\ETX\216\&4\235\253EV@\ETB", _pubProps = []} TEST(Publish311QCTest, Decode21) { - uint8_t pkt[] = {0x33, 0x25, 0x0, 0x16, 0x5b, 0x85, 0xe3, 0x7a, 0xf4, 0x14, 0x20, 0x5c, 0xf1, - 0xcf, 0x46, 0x7c, 0x8d, 0x80, 0x3f, 0x46, 0x9, 0xf9, 0x12, 0x7f, 0x73, 0xf5, - 0x5c, 0xad, 0x3b, 0xe5, 0xf1, 0xef, 0xa9, 0xc1, 0x98, 0xa0, 0x95, 0x1c, 0x51}; + uint8_t pkt[] = {0x3c, 0x39, 0x0, 0x1b, 0xef, 0xf1, 0x20, 0x9a, 0x28, 0x20, 0xf7, 0x74, 0x22, 0xf6, 0x5, + 0xcb, 0xfc, 0xce, 0xe1, 0xc4, 0x94, 0x2, 0xde, 0x22, 0x28, 0xff, 0x1f, 0x7d, 0xc2, 0xbc, + 0xac, 0x45, 0xba, 0xe8, 0x23, 0x58, 0x1, 0x72, 0x2e, 0x81, 0x15, 0x9b, 0xf7, 0x63, 0xaa, + 0xe7, 0xc1, 0x59, 0xfe, 0x1b, 0x3, 0xd8, 0x34, 0xeb, 0xfd, 0x45, 0x56, 0x40, 0x17}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1245,59 +1230,59 @@ TEST(Publish311QCTest, Decode21) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5b, 0x85, 0xe3, 0x7a, 0xf4, 0x14, 0x20, 0x5c, 0xf1, 0xcf, 0x46, - 0x7c, 0x8d, 0x80, 0x3f, 0x46, 0x9, 0xf9, 0x12, 0x7f, 0x73, 0xf5}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x3b, 0xe5, 0xf1, 0xef, 0xa9, 0xc1, 0x98, 0xa0, 0x95, 0x1c, 0x51}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 23725); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + uint8_t exp_topic_bytes[] = {0xef, 0xf1, 0x20, 0x9a, 0x28, 0x20, 0xf7, 0x74, 0x22, 0xf6, 0x5, 0xcb, 0xfc, 0xce, + 0xe1, 0xc4, 0x94, 0x2, 0xde, 0x22, 0x28, 0xff, 0x1f, 0x7d, 0xc2, 0xbc, 0xac}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xe8, 0x23, 0x58, 0x1, 0x72, 0x2e, 0x81, 0x15, 0x9b, 0xf7, 0x63, 0xaa, 0xe7, + 0xc1, 0x59, 0xfe, 0x1b, 0x3, 0xd8, 0x34, 0xeb, 0xfd, 0x45, 0x56, 0x40, 0x17}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 17850); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "D\SO\EOTH\207S\243\176T\n\246\234'~^\ETBtz\220X", _pubPktID = 0, _pubBody = -// "\179>\ENQUu\215k\216\ETX\201m\DC2\251\&2\ETB\187m\200\248\140{\n8", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\161\229m\129\&2\222w}\252\146\169(\STXu\137Z6\133", _pubPktID = 7546, _pubBody = +// "^\ETX\228\176\224]\220i\211(<\144", _pubProps = []} TEST(Publish311QCTest, Encode22) { - uint8_t pkt[] = {0x31, 0x2d, 0x0, 0x14, 0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, 0xf6, 0xea, - 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58, 0xb3, 0x3e, 0x5, 0x55, 0x75, 0xd7, 0x6b, 0xd8, - 0x3, 0xc9, 0x6d, 0x12, 0xfb, 0x32, 0x17, 0xbb, 0x6d, 0xc8, 0xf8, 0x8c, 0x7b, 0xa, 0x38}; - uint8_t topic_bytes[] = {0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, - 0xf6, 0xea, 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x22, 0x0, 0x12, 0xa1, 0xe5, 0x6d, 0x81, 0x32, 0xde, 0x77, 0x7d, + 0xfc, 0x92, 0xa9, 0x28, 0x2, 0x75, 0x89, 0x5a, 0x36, 0x85, 0x1d, 0x7a, + 0x5e, 0x3, 0xe4, 0xb0, 0xe0, 0x5d, 0xdc, 0x69, 0xd3, 0x28, 0x3c, 0x90}; + uint8_t topic_bytes[] = {0xa1, 0xe5, 0x6d, 0x81, 0x32, 0xde, 0x77, 0x7d, 0xfc, + 0x92, 0xa9, 0x28, 0x2, 0x75, 0x89, 0x5a, 0x36, 0x85}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xb3, 0x3e, 0x5, 0x55, 0x75, 0xd7, 0x6b, 0xd8, 0x3, 0xc9, 0x6d, 0x12, - 0xfb, 0x32, 0x17, 0xbb, 0x6d, 0xc8, 0xf8, 0x8c, 0x7b, 0xa, 0x38}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x5e, 0x3, 0xe4, 0xb0, 0xe0, 0x5d, 0xdc, 0x69, 0xd3, 0x28, 0x3c, 0x90}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 12; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 7546, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "D\SO\EOTH\207S\243\176T\n\246\234'~^\ETBtz\220X", _pubPktID = 0, _pubBody = -// "\179>\ENQUu\215k\216\ETX\201m\DC2\251\&2\ETB\187m\200\248\140{\n8", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "\161\229m\129\&2\222w}\252\146\169(\STXu\137Z6\133", _pubPktID = 7546, _pubBody = +// "^\ETX\228\176\224]\220i\211(<\144", _pubProps = []} TEST(Publish311QCTest, Decode22) { - uint8_t pkt[] = {0x31, 0x2d, 0x0, 0x14, 0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, 0xf6, 0xea, - 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58, 0xb3, 0x3e, 0x5, 0x55, 0x75, 0xd7, 0x6b, 0xd8, - 0x3, 0xc9, 0x6d, 0x12, 0xfb, 0x32, 0x17, 0xbb, 0x6d, 0xc8, 0xf8, 0x8c, 0x7b, 0xa, 0x38}; + uint8_t pkt[] = {0x34, 0x22, 0x0, 0x12, 0xa1, 0xe5, 0x6d, 0x81, 0x32, 0xde, 0x77, 0x7d, + 0xfc, 0x92, 0xa9, 0x28, 0x2, 0x75, 0x89, 0x5a, 0x36, 0x85, 0x1d, 0x7a, + 0x5e, 0x3, 0xe4, 0xb0, 0xe0, 0x5d, 0xdc, 0x69, 0xd3, 0x28, 0x3c, 0x90}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1306,59 +1291,53 @@ TEST(Publish311QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, - 0xf6, 0xea, 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb3, 0x3e, 0x5, 0x55, 0x75, 0xd7, 0x6b, 0xd8, 0x3, 0xc9, 0x6d, 0x12, - 0xfb, 0x32, 0x17, 0xbb, 0x6d, 0xc8, 0xf8, 0x8c, 0x7b, 0xa, 0x38}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa1, 0xe5, 0x6d, 0x81, 0x32, 0xde, 0x77, 0x7d, 0xfc, + 0x92, 0xa9, 0x28, 0x2, 0x75, 0x89, 0x5a, 0x36, 0x85}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5e, 0x3, 0xe4, 0xb0, 0xe0, 0x5d, 0xdc, 0x69, 0xd3, 0x28, 0x3c, 0x90}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 23); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7546); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\178\144*)\STX\195\&3\195\193\213~9\191FW\136R", _pubPktID = 0, _pubBody = "\155U0$\ENQ\134dV\214\ts.+\ETX\143", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "zd\230 jdq?\198\154\202x8", +// _pubPktID = 32533, _pubBody = "\255\DC4\132\246=", _pubProps = []} TEST(Publish311QCTest, Encode23) { - uint8_t pkt[] = {0x39, 0x22, 0x0, 0x11, 0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, - 0xc1, 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52, 0x9b, 0x55, 0x30, - 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; - uint8_t topic_bytes[] = {0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, - 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x16, 0x0, 0xd, 0x7a, 0x64, 0xe6, 0x20, 0x6a, 0x64, 0x71, 0x3f, + 0xc6, 0x9a, 0xca, 0x78, 0x38, 0x7f, 0x15, 0xff, 0x14, 0x84, 0xf6, 0x3d}; + uint8_t topic_bytes[] = {0x7a, 0x64, 0xe6, 0x20, 0x6a, 0x64, 0x71, 0x3f, 0xc6, 0x9a, 0xca, 0x78, 0x38}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xff, 0x14, 0x84, 0xf6, 0x3d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; + msg.payload_len = 5; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 32533, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\178\144*)\STX\195\&3\195\193\213~9\191FW\136R", _pubPktID = 0, _pubBody = "\155U0$\ENQ\134dV\214\ts.+\ETX\143", -// _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "zd\230 jdq?\198\154\202x8", +// _pubPktID = 32533, _pubBody = "\255\DC4\132\246=", _pubProps = []} TEST(Publish311QCTest, Decode23) { - uint8_t pkt[] = {0x39, 0x22, 0x0, 0x11, 0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, - 0xc1, 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52, 0x9b, 0x55, 0x30, - 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; + uint8_t pkt[] = {0x34, 0x16, 0x0, 0xd, 0x7a, 0x64, 0xe6, 0x20, 0x6a, 0x64, 0x71, 0x3f, + 0xc6, 0x9a, 0xca, 0x78, 0x38, 0x7f, 0x15, 0xff, 0x14, 0x84, 0xf6, 0x3d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1367,58 +1346,58 @@ TEST(Publish311QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, - 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52}; - lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + uint8_t exp_topic_bytes[] = {0x7a, 0x64, 0xe6, 0x20, 0x6a, 0x64, 0x71, 0x3f, 0xc6, 0x9a, 0xca, 0x78, 0x38}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xff, 0x14, 0x84, 0xf6, 0x3d}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 32533); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "G\195\186\214\239K -// \\\226\162\\\"\182", _pubPktID = 3720, _pubBody = -// "\SYN\172\191'(v\"S#\253\175\191\180\243%y\205\195\143\140\247\239\228\\", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\ETB\147^4}\135\220\179>\250\156\DELi2\SOH\236\193\164n\239\157\189\229t#`4", _pubPktID = 0, _pubBody = +// "\130\204\173\174\157}\164rT\146\220w\DC1H4\164\DLE\255{", _pubProps = []} TEST(Publish311QCTest, Encode24) { - uint8_t pkt[] = {0x33, 0x29, 0x0, 0xd, 0x47, 0xc3, 0xba, 0xd6, 0xef, 0x4b, 0x20, 0x5c, 0xe2, 0xa2, 0x5c, - 0x22, 0xb6, 0xe, 0x88, 0x16, 0xac, 0xbf, 0x27, 0x28, 0x76, 0x22, 0x53, 0x23, 0xfd, 0xaf, - 0xbf, 0xb4, 0xf3, 0x25, 0x79, 0xcd, 0xc3, 0x8f, 0x8c, 0xf7, 0xef, 0xe4, 0x5c}; - uint8_t topic_bytes[] = {0x47, 0xc3, 0xba, 0xd6, 0xef, 0x4b, 0x20, 0x5c, 0xe2, 0xa2, 0x5c, 0x22, 0xb6}; - lwmqtt_string_t topic = {13, (char*)&topic_bytes}; + uint8_t pkt[] = {0x31, 0x30, 0x0, 0x1b, 0x17, 0x93, 0x5e, 0x34, 0x7d, 0x87, 0xdc, 0xb3, 0x3e, 0xfa, 0x9c, 0x7f, 0x69, + 0x32, 0x1, 0xec, 0xc1, 0xa4, 0x6e, 0xef, 0x9d, 0xbd, 0xe5, 0x74, 0x23, 0x60, 0x34, 0x82, 0xcc, 0xad, + 0xae, 0x9d, 0x7d, 0xa4, 0x72, 0x54, 0x92, 0xdc, 0x77, 0x11, 0x48, 0x34, 0xa4, 0x10, 0xff, 0x7b}; + uint8_t topic_bytes[] = {0x17, 0x93, 0x5e, 0x34, 0x7d, 0x87, 0xdc, 0xb3, 0x3e, 0xfa, 0x9c, 0x7f, 0x69, 0x32, + 0x1, 0xec, 0xc1, 0xa4, 0x6e, 0xef, 0x9d, 0xbd, 0xe5, 0x74, 0x23, 0x60, 0x34}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS0; msg.retained = true; - uint8_t msg_bytes[] = {0x16, 0xac, 0xbf, 0x27, 0x28, 0x76, 0x22, 0x53, 0x23, 0xfd, 0xaf, 0xbf, - 0xb4, 0xf3, 0x25, 0x79, 0xcd, 0xc3, 0x8f, 0x8c, 0xf7, 0xef, 0xe4, 0x5c}; + uint8_t msg_bytes[] = {0x82, 0xcc, 0xad, 0xae, 0x9d, 0x7d, 0xa4, 0x72, 0x54, 0x92, + 0xdc, 0x77, 0x11, 0x48, 0x34, 0xa4, 0x10, 0xff, 0x7b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 24; + msg.payload_len = 19; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 3720, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "G\195\186\214\239K -// \\\226\162\\\"\182", _pubPktID = 3720, _pubBody = -// "\SYN\172\191'(v\"S#\253\175\191\180\243%y\205\195\143\140\247\239\228\\", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\ETB\147^4}\135\220\179>\250\156\DELi2\SOH\236\193\164n\239\157\189\229t#`4", _pubPktID = 0, _pubBody = +// "\130\204\173\174\157}\164rT\146\220w\DC1H4\164\DLE\255{", _pubProps = []} TEST(Publish311QCTest, Decode24) { - uint8_t pkt[] = {0x33, 0x29, 0x0, 0xd, 0x47, 0xc3, 0xba, 0xd6, 0xef, 0x4b, 0x20, 0x5c, 0xe2, 0xa2, 0x5c, - 0x22, 0xb6, 0xe, 0x88, 0x16, 0xac, 0xbf, 0x27, 0x28, 0x76, 0x22, 0x53, 0x23, 0xfd, 0xaf, - 0xbf, 0xb4, 0xf3, 0x25, 0x79, 0xcd, 0xc3, 0x8f, 0x8c, 0xf7, 0xef, 0xe4, 0x5c}; + uint8_t pkt[] = {0x31, 0x30, 0x0, 0x1b, 0x17, 0x93, 0x5e, 0x34, 0x7d, 0x87, 0xdc, 0xb3, 0x3e, 0xfa, 0x9c, 0x7f, 0x69, + 0x32, 0x1, 0xec, 0xc1, 0xa4, 0x6e, 0xef, 0x9d, 0xbd, 0xe5, 0x74, 0x23, 0x60, 0x34, 0x82, 0xcc, 0xad, + 0xae, 0x9d, 0x7d, 0xa4, 0x72, 0x54, 0x92, 0xdc, 0x77, 0x11, 0x48, 0x34, 0xa4, 0x10, 0xff, 0x7b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1427,54 +1406,57 @@ TEST(Publish311QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x47, 0xc3, 0xba, 0xd6, 0xef, 0x4b, 0x20, 0x5c, 0xe2, 0xa2, 0x5c, 0x22, 0xb6}; - lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x16, 0xac, 0xbf, 0x27, 0x28, 0x76, 0x22, 0x53, 0x23, 0xfd, 0xaf, 0xbf, - 0xb4, 0xf3, 0x25, 0x79, 0xcd, 0xc3, 0x8f, 0x8c, 0xf7, 0xef, 0xe4, 0x5c}; - lwmqtt_string_t exp_body = {24, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x17, 0x93, 0x5e, 0x34, 0x7d, 0x87, 0xdc, 0xb3, 0x3e, 0xfa, 0x9c, 0x7f, 0x69, 0x32, + 0x1, 0xec, 0xc1, 0xa4, 0x6e, 0xef, 0x9d, 0xbd, 0xe5, 0x74, 0x23, 0x60, 0x34}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x82, 0xcc, 0xad, 0xae, 0x9d, 0x7d, 0xa4, 0x72, 0x54, 0x92, + 0xdc, 0x77, 0x11, 0x48, 0x34, 0xa4, 0x10, 0xff, 0x7b}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 3720); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 9592, _pubBody = -// "\ETX\195\133\tbr,\140\146.tE\159\135\176\168{\162X\178Z", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q:@l\229vEU\235iQ\v", _pubPktID = +// 23637, _pubBody = "\169\252\159\196(\144\135\181\129*7\EOT&B\216\183\244\DC3\129\142\224\229", _pubProps = []} TEST(Publish311QCTest, Encode25) { - uint8_t pkt[] = {0x34, 0x19, 0x0, 0x0, 0x25, 0x78, 0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, - 0x92, 0x2e, 0x74, 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x26, 0x0, 0xc, 0x71, 0x3a, 0x40, 0x6c, 0xe5, 0x76, 0x45, 0x55, 0xeb, 0x69, + 0x51, 0xb, 0x5c, 0x55, 0xa9, 0xfc, 0x9f, 0xc4, 0x28, 0x90, 0x87, 0xb5, 0x81, 0x2a, + 0x37, 0x4, 0x26, 0x42, 0xd8, 0xb7, 0xf4, 0x13, 0x81, 0x8e, 0xe0, 0xe5}; + uint8_t topic_bytes[] = {0x71, 0x3a, 0x40, 0x6c, 0xe5, 0x76, 0x45, 0x55, 0xeb, 0x69, 0x51, 0xb}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, 0x92, 0x2e, 0x74, - 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xa9, 0xfc, 0x9f, 0xc4, 0x28, 0x90, 0x87, 0xb5, 0x81, 0x2a, 0x37, + 0x4, 0x26, 0x42, 0xd8, 0xb7, 0xf4, 0x13, 0x81, 0x8e, 0xe0, 0xe5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 9592, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 23637, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 9592, _pubBody = -// "\ETX\195\133\tbr,\140\146.tE\159\135\176\168{\162X\178Z", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q:@l\229vEU\235iQ\v", _pubPktID = +// 23637, _pubBody = "\169\252\159\196(\144\135\181\129*7\EOT&B\216\183\244\DC3\129\142\224\229", _pubProps = []} TEST(Publish311QCTest, Decode25) { - uint8_t pkt[] = {0x34, 0x19, 0x0, 0x0, 0x25, 0x78, 0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, - 0x92, 0x2e, 0x74, 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; + uint8_t pkt[] = {0x33, 0x26, 0x0, 0xc, 0x71, 0x3a, 0x40, 0x6c, 0xe5, 0x76, 0x45, 0x55, 0xeb, 0x69, + 0x51, 0xb, 0x5c, 0x55, 0xa9, 0xfc, 0x9f, 0xc4, 0x28, 0x90, 0x87, 0xb5, 0x81, 0x2a, + 0x37, 0x4, 0x26, 0x42, 0xd8, 0xb7, 0xf4, 0x13, 0x81, 0x8e, 0xe0, 0xe5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1483,51 +1465,58 @@ TEST(Publish311QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, 0x92, 0x2e, 0x74, - 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x71, 0x3a, 0x40, 0x6c, 0xe5, 0x76, 0x45, 0x55, 0xeb, 0x69, 0x51, 0xb}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa9, 0xfc, 0x9f, 0xc4, 0x28, 0x90, 0x87, 0xb5, 0x81, 0x2a, 0x37, + 0x4, 0x26, 0x42, 0xd8, 0xb7, 0xf4, 0x13, 0x81, 0x8e, 0xe0, 0xe5}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 9592); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 23637); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "y\216", _pubPktID = 27633, _pubBody -// = "\t\219\155@MR", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "n#\187\187\173\198I,k\145\183\237\142\194", _pubPktID = 8993, _pubBody = "\147{\192\230\144\DC3\130j\217\194h +// E\159\201\161s\154\199\201<\227", _pubProps = []} TEST(Publish311QCTest, Encode26) { - uint8_t pkt[] = {0x33, 0xc, 0x0, 0x2, 0x79, 0xd8, 0x6b, 0xf1, 0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; - uint8_t topic_bytes[] = {0x79, 0xd8}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x28, 0x0, 0xe, 0x6e, 0x23, 0xbb, 0xbb, 0xad, 0xc6, 0x49, 0x2c, 0x6b, 0x91, + 0xb7, 0xed, 0x8e, 0xc2, 0x23, 0x21, 0x93, 0x7b, 0xc0, 0xe6, 0x90, 0x13, 0x82, 0x6a, + 0xd9, 0xc2, 0x68, 0x20, 0x45, 0x9f, 0xc9, 0xa1, 0x73, 0x9a, 0xc7, 0xc9, 0x3c, 0xe3}; + uint8_t topic_bytes[] = {0x6e, 0x23, 0xbb, 0xbb, 0xad, 0xc6, 0x49, 0x2c, 0x6b, 0x91, 0xb7, 0xed, 0x8e, 0xc2}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; + uint8_t msg_bytes[] = {0x93, 0x7b, 0xc0, 0xe6, 0x90, 0x13, 0x82, 0x6a, 0xd9, 0xc2, 0x68, + 0x20, 0x45, 0x9f, 0xc9, 0xa1, 0x73, 0x9a, 0xc7, 0xc9, 0x3c, 0xe3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; + msg.payload_len = 22; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 27633, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 8993, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "y\216", _pubPktID = 27633, _pubBody -// = "\t\219\155@MR", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "n#\187\187\173\198I,k\145\183\237\142\194", _pubPktID = 8993, _pubBody = "\147{\192\230\144\DC3\130j\217\194h +// E\159\201\161s\154\199\201<\227", _pubProps = []} TEST(Publish311QCTest, Decode26) { - uint8_t pkt[] = {0x33, 0xc, 0x0, 0x2, 0x79, 0xd8, 0x6b, 0xf1, 0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; + uint8_t pkt[] = {0x3b, 0x28, 0x0, 0xe, 0x6e, 0x23, 0xbb, 0xbb, 0xad, 0xc6, 0x49, 0x2c, 0x6b, 0x91, + 0xb7, 0xed, 0x8e, 0xc2, 0x23, 0x21, 0x93, 0x7b, 0xc0, 0xe6, 0x90, 0x13, 0x82, 0x6a, + 0xd9, 0xc2, 0x68, 0x20, 0x45, 0x9f, 0xc9, 0xa1, 0x73, 0x9a, 0xc7, 0xc9, 0x3c, 0xe3}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1536,50 +1525,56 @@ TEST(Publish311QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x79, 0xd8}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; - lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x6e, 0x23, 0xbb, 0xbb, 0xad, 0xc6, 0x49, 0x2c, 0x6b, 0x91, 0xb7, 0xed, 0x8e, 0xc2}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x93, 0x7b, 0xc0, 0xe6, 0x90, 0x13, 0x82, 0x6a, 0xd9, 0xc2, 0x68, + 0x20, 0x45, 0x9f, 0xc9, 0xa1, 0x73, 0x9a, 0xc7, 0xc9, 0x3c, 0xe3}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 27633); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 6); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + EXPECT_EQ(packet_id, 8993); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\253d\178]\206\DLE\163;", _pubProps = []} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "'w%\200$\223R\DC4`", _pubPktID = +// 8207, _pubBody = "\253\145\215\176fT\SO\155P\211\218(topic.data), 0); - EXPECT_EQ(msg.payload_len, 8); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); - lwmqtt_string_t x = exp_topic; + uint8_t exp_topic_bytes[] = {0x27, 0x77, 0x25, 0xc8, 0x24, 0xdf, 0x52, 0x14, 0x60}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfd, 0x91, 0xd7, 0xb0, 0x66, 0x54, 0xe, 0x9b, 0x50, 0xd3, + 0xda, 0x3c, 0x65, 0xbf, 0xfa, 0xa2, 0xc0, 0xc9, 0x9a}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 8207); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// ";\204\SI\135:\SYN%u\222\217#\130\225N", _pubPktID = 14774, _pubBody = "\250v\SUB", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "m\237T", _pubPktID = 0, _pubBody = +// "K\240\171\DC4,?a}f\GS\244\&7\181\255]\138\150\206|\148\140\128>", _pubProps = []} TEST(Publish311QCTest, Encode28) { - uint8_t pkt[] = {0x35, 0x15, 0x0, 0xe, 0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, - 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e, 0x39, 0xb6, 0xfa, 0x76, 0x1a}; - uint8_t topic_bytes[] = {0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x1c, 0x0, 0x3, 0x6d, 0xed, 0x54, 0x4b, 0xf0, 0xab, 0x14, 0x2c, 0x3f, 0x61, 0x7d, + 0x66, 0x1d, 0xf4, 0x37, 0xb5, 0xff, 0x5d, 0x8a, 0x96, 0xce, 0x7c, 0x94, 0x8c, 0x80, 0x3e}; + uint8_t topic_bytes[] = {0x6d, 0xed, 0x54}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xfa, 0x76, 0x1a}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x4b, 0xf0, 0xab, 0x14, 0x2c, 0x3f, 0x61, 0x7d, 0x66, 0x1d, 0xf4, 0x37, + 0xb5, 0xff, 0x5d, 0x8a, 0x96, 0xce, 0x7c, 0x94, 0x8c, 0x80, 0x3e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 23; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 14774, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// ";\204\SI\135:\SYN%u\222\217#\130\225N", _pubPktID = 14774, _pubBody = "\250v\SUB", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "m\237T", _pubPktID = 0, _pubBody = +// "K\240\171\DC4,?a}f\GS\244\&7\181\255]\138\150\206|\148\140\128>", _pubProps = []} TEST(Publish311QCTest, Decode28) { - uint8_t pkt[] = {0x35, 0x15, 0x0, 0xe, 0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, - 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e, 0x39, 0xb6, 0xfa, 0x76, 0x1a}; + uint8_t pkt[] = {0x38, 0x1c, 0x0, 0x3, 0x6d, 0xed, 0x54, 0x4b, 0xf0, 0xab, 0x14, 0x2c, 0x3f, 0x61, 0x7d, + 0x66, 0x1d, 0xf4, 0x37, 0xb5, 0xff, 0x5d, 0x8a, 0x96, 0xce, 0x7c, 0x94, 0x8c, 0x80, 0x3e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1642,58 +1639,51 @@ TEST(Publish311QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfa, 0x76, 0x1a}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 14774); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + uint8_t exp_topic_bytes[] = {0x6d, 0xed, 0x54}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4b, 0xf0, 0xab, 0x14, 0x2c, 0x3f, 0x61, 0x7d, 0x66, 0x1d, 0xf4, 0x37, + 0xb5, 0xff, 0x5d, 0x8a, 0x96, 0xce, 0x7c, 0x94, 0x8c, 0x80, 0x3e}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "M\189d\165\NAK\165J\222\187)\216\178d^\194{\141\141y\145", _pubPktID = 0, _pubBody = -// "\245\129\188\154\242\232\161\228\255\&1lz\153\252~D\r\222\166\ENQ", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "r\223", _pubPktID = 0, _pubBody = +// "Y&\241\149_\178", _pubProps = []} TEST(Publish311QCTest, Encode29) { - uint8_t pkt[] = {0x30, 0x2a, 0x0, 0x14, 0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, 0xd8, - 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91, 0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, - 0xa1, 0xe4, 0xff, 0x31, 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; - uint8_t topic_bytes[] = {0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, - 0xd8, 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0xa, 0x0, 0x2, 0x72, 0xdf, 0x59, 0x26, 0xf1, 0x95, 0x5f, 0xb2}; + uint8_t topic_bytes[] = {0x72, 0xdf}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, - 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; + msg.retained = true; + uint8_t msg_bytes[] = {0x59, 0x26, 0xf1, 0x95, 0x5f, 0xb2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; + msg.payload_len = 6; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "M\189d\165\NAK\165J\222\187)\216\178d^\194{\141\141y\145", _pubPktID = 0, _pubBody = -// "\245\129\188\154\242\232\161\228\255\&1lz\153\252~D\r\222\166\ENQ", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "r\223", _pubPktID = 0, _pubBody = +// "Y&\241\149_\178", _pubProps = []} TEST(Publish311QCTest, Decode29) { - uint8_t pkt[] = {0x30, 0x2a, 0x0, 0x14, 0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, 0xd8, - 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91, 0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, - 0xa1, 0xe4, 0xff, 0x31, 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; + uint8_t pkt[] = {0x39, 0xa, 0x0, 0x2, 0x72, 0xdf, 0x59, 0x26, 0xf1, 0x95, 0x5f, 0xb2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1702,36 +1692,37 @@ TEST(Publish311QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, - 0xd8, 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, - 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x72, 0xdf}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x59, 0x26, 0xf1, 0x95, 0x5f, 0xb2}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "3V\138y.\181\&0", _pubPktID = 0, -// _pubBody = "2\248\176\206\GS<\197b\195`\241\aH", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\247\220n\163\233a\SO%/\218\186\&6\163Z\GS\ESC3\b\189\140I\131\129\177\185\197\163\188\&6\SYN", _pubPktID = 3711, +// _pubBody = "\205H\232\STX\178\&33\r\237\140\240o\166", _pubProps = []} TEST(Publish311QCTest, Encode30) { - uint8_t pkt[] = {0x31, 0x16, 0x0, 0x7, 0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30, 0x32, - 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; - uint8_t topic_bytes[] = {0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x2f, 0x0, 0x1e, 0xf7, 0xdc, 0x6e, 0xa3, 0xe9, 0x61, 0xe, 0x25, 0x2f, 0xda, 0xba, 0x36, 0xa3, + 0x5a, 0x1d, 0x1b, 0x33, 0x8, 0xbd, 0x8c, 0x49, 0x83, 0x81, 0xb1, 0xb9, 0xc5, 0xa3, 0xbc, 0x36, 0x16, + 0xe, 0x7f, 0xcd, 0x48, 0xe8, 0x2, 0xb2, 0x33, 0x33, 0xd, 0xed, 0x8c, 0xf0, 0x6f, 0xa6}; + uint8_t topic_bytes[] = {0xf7, 0xdc, 0x6e, 0xa3, 0xe9, 0x61, 0xe, 0x25, 0x2f, 0xda, 0xba, 0x36, 0xa3, 0x5a, 0x1d, + 0x1b, 0x33, 0x8, 0xbd, 0x8c, 0x49, 0x83, 0x81, 0xb1, 0xb9, 0xc5, 0xa3, 0xbc, 0x36, 0x16}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; + uint8_t msg_bytes[] = {0xcd, 0x48, 0xe8, 0x2, 0xb2, 0x33, 0x33, 0xd, 0xed, 0x8c, 0xf0, 0x6f, 0xa6}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 13; @@ -1739,17 +1730,19 @@ TEST(Publish311QCTest, Encode30) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT311, true, 3711, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "3V\138y.\181\&0", _pubPktID = 0, -// _pubBody = "2\248\176\206\GS<\197b\195`\241\aH", _pubProps = []} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\247\220n\163\233a\SO%/\218\186\&6\163Z\GS\ESC3\b\189\140I\131\129\177\185\197\163\188\&6\SYN", _pubPktID = 3711, +// _pubBody = "\205H\232\STX\178\&33\r\237\140\240o\166", _pubProps = []} TEST(Publish311QCTest, Decode30) { - uint8_t pkt[] = {0x31, 0x16, 0x0, 0x7, 0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30, 0x32, - 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; + uint8_t pkt[] = {0x3b, 0x2f, 0x0, 0x1e, 0xf7, 0xdc, 0x6e, 0xa3, 0xe9, 0x61, 0xe, 0x25, 0x2f, 0xda, 0xba, 0x36, 0xa3, + 0x5a, 0x1d, 0x1b, 0x33, 0x8, 0xbd, 0x8c, 0x49, 0x83, 0x81, 0xb1, 0xb9, 0xc5, 0xa3, 0xbc, 0x36, 0x16, + 0xe, 0x7f, 0xcd, 0x48, 0xe8, 0x2, 0xb2, 0x33, 0x33, 0xd, 0xed, 0x8c, 0xf0, 0x6f, 0xa6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1758,62 +1751,93 @@ TEST(Publish311QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT311, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; + uint8_t exp_topic_bytes[] = {0xf7, 0xdc, 0x6e, 0xa3, 0xe9, 0x61, 0xe, 0x25, 0x2f, 0xda, + 0xba, 0x36, 0xa3, 0x5a, 0x1d, 0x1b, 0x33, 0x8, 0xbd, 0x8c, + 0x49, 0x83, 0x81, 0xb1, 0xb9, 0xc5, 0xa3, 0xbc, 0x36, 0x16}; + lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcd, 0x48, 0xe8, 0x2, 0xb2, 0x33, 0x33, 0xd, 0xed, 0x8c, 0xf0, 0x6f, 0xa6}; lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(packet_id, 3711); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); EXPECT_EQ(msg.payload_len, 13); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "W\217\244\199\US\166I\171\225H\165\&0\148+>'\185\243\243\254\182\&3\158\130", _pubPktID = 5484, _pubBody = -// "N\151Gu\207\213\209\175\151\241[\RS\128P\129\237\157\250K", _pubProps = [PropReceiveMaximum 26936]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\201\174\&5}Y\150\209fI\146", _pubProps = [PropServerReference +// "\SO\163\208\252\142?\206\ESCT\225\204",PropSubscriptionIdentifierAvailable 224,PropTopicAlias 17121,PropReasonString +// "\165\239'\185\243\243\254\182\&3\158\130", _pubPktID = 5484, _pubBody = -// "N\151Gu\207\213\209\175\151\241[\RS\128P\129\237\157\250K", _pubProps = [PropReceiveMaximum 26936]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = +// "\201\174\&5}Y\150\209fI\146", _pubProps = [PropServerReference +// "\SO\163\208\252\142?\206\ESCT\225\204",PropSubscriptionIdentifierAvailable 224,PropTopicAlias 17121,PropReasonString +// "\165\239(topic.data), 24); - EXPECT_EQ(msg.payload_len, 19); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\164_xCoe\161\\\SYN8\247~X\178U\EOT\201\239d\NUL\v\219\239", _pubPktID = 617, _pubBody = -// "\203\"\151M\221\179{\230\DC3c\185\FS\183-\225\169\214\ETX\128\159\170E\186\239\ESC\153\192\142", _pubProps = -// [PropMaximumQoS 222,PropReceiveMaximum 32352,PropResponseTopic "_-\213",PropSharedSubscriptionAvailable -// 77,PropMessageExpiryInterval 27318,PropSubscriptionIdentifierAvailable 17,PropTopicAlias 4804,PropMaximumQoS -// 245,PropMaximumQoS 33,PropServerReference "\165KJ\219Ap\192\151\200\134\149",PropSharedSubscriptionAvailable -// 196,PropTopicAlias 28672,PropAssignedClientIdentifier "Tl\129`\180&EKq6\201\232\EM(\235\US",PropRetainAvailable -// 117,PropAssignedClientIdentifier "\232\242't\134w\152\212\DC27\155Y\DELx\209s5\197",PropPayloadFormatIndicator -// 133,PropWildcardSubscriptionAvailable 232,PropAuthenticationMethod -// "\227\193\NUL:K\134X\134\245\232\231RB\148\229\214\203\178\186\237\247\252\a9\129lc\DEL\153",PropMaximumQoS -// 231,PropRetainAvailable 124]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\178\&4?\195\154\241'~\229S\255\SO\a40\221\ESC\221:N\212F\r\188l", _pubPktID = 2511, _pubBody = +// "'6\224\138\ETB\f{\166\251\224\EM", _pubProps = []} TEST(Publish5QCTest, Encode2) { - uint8_t pkt[] = { - 0x3b, 0xb9, 0x1, 0x0, 0x17, 0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, 0x58, 0xb2, - 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef, 0x2, 0x69, 0x80, 0x1, 0x24, 0xde, 0x21, 0x7e, 0x60, 0x8, - 0x0, 0x3, 0x5f, 0x2d, 0xd5, 0x2a, 0x4d, 0x2, 0x0, 0x0, 0x6a, 0xb6, 0x29, 0x11, 0x23, 0x12, 0xc4, 0x24, 0xf5, - 0x24, 0x21, 0x1c, 0x0, 0xb, 0xa5, 0x4b, 0x4a, 0xdb, 0x41, 0x70, 0xc0, 0x97, 0xc8, 0x86, 0x95, 0x2a, 0xc4, 0x23, - 0x70, 0x0, 0x12, 0x0, 0x10, 0x54, 0x6c, 0x81, 0x60, 0xb4, 0x26, 0x45, 0x4b, 0x71, 0x36, 0xc9, 0xe8, 0x19, 0x28, - 0xeb, 0x1f, 0x25, 0x75, 0x12, 0x0, 0x12, 0xe8, 0xf2, 0x27, 0x74, 0x86, 0x77, 0x98, 0xd4, 0x12, 0x37, 0x9b, 0x59, - 0x7f, 0x78, 0xd1, 0x73, 0x35, 0xc5, 0x1, 0x85, 0x28, 0xe8, 0x15, 0x0, 0x1d, 0xe3, 0xc1, 0x0, 0x3a, 0x4b, 0x86, - 0x58, 0x86, 0xf5, 0xe8, 0xe7, 0x52, 0x42, 0x94, 0xe5, 0xd6, 0xcb, 0xb2, 0xba, 0xed, 0xf7, 0xfc, 0x7, 0x39, 0x81, - 0x6c, 0x63, 0x7f, 0x99, 0x24, 0xe7, 0x25, 0x7c, 0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, - 0x1c, 0xb7, 0x2d, 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; - uint8_t topic_bytes[] = {0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, - 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef}; - lwmqtt_string_t topic = {23, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x29, 0x0, 0x19, 0xb2, 0x34, 0x3f, 0xc3, 0x9a, 0xf1, 0x27, 0x7e, 0xe5, 0x53, 0xff, + 0xe, 0x7, 0x34, 0x30, 0xdd, 0x1b, 0xdd, 0x3a, 0x4e, 0xd4, 0x46, 0xd, 0xbc, 0x6c, 0x9, + 0xcf, 0x0, 0x27, 0x36, 0xe0, 0x8a, 0x17, 0xc, 0x7b, 0xa6, 0xfb, 0xe0, 0x19}; + uint8_t topic_bytes[] = {0xb2, 0x34, 0x3f, 0xc3, 0x9a, 0xf1, 0x27, 0x7e, 0xe5, 0x53, 0xff, 0xe, 0x7, + 0x34, 0x30, 0xdd, 0x1b, 0xdd, 0x3a, 0x4e, 0xd4, 0x46, 0xd, 0xbc, 0x6c}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, - 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; + uint8_t msg_bytes[] = {0x27, 0x36, 0xe0, 0x8a, 0x17, 0xc, 0x7b, 0xa6, 0xfb, 0xe0, 0x19}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; - - uint8_t bytesprops0[] = {0x5f, 0x2d, 0xd5}; - uint8_t bytesprops1[] = {0xa5, 0x4b, 0x4a, 0xdb, 0x41, 0x70, 0xc0, 0x97, 0xc8, 0x86, 0x95}; - uint8_t bytesprops2[] = {0x54, 0x6c, 0x81, 0x60, 0xb4, 0x26, 0x45, 0x4b, - 0x71, 0x36, 0xc9, 0xe8, 0x19, 0x28, 0xeb, 0x1f}; - uint8_t bytesprops3[] = {0xe8, 0xf2, 0x27, 0x74, 0x86, 0x77, 0x98, 0xd4, 0x12, - 0x37, 0x9b, 0x59, 0x7f, 0x78, 0xd1, 0x73, 0x35, 0xc5}; - uint8_t bytesprops4[] = {0xe3, 0xc1, 0x0, 0x3a, 0x4b, 0x86, 0x58, 0x86, 0xf5, 0xe8, 0xe7, 0x52, 0x42, 0x94, 0xe5, - 0xd6, 0xcb, 0xb2, 0xba, 0xed, 0xf7, 0xfc, 0x7, 0x39, 0x81, 0x6c, 0x63, 0x7f, 0x99}; + msg.payload_len = 11; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32352}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27318}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4804}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28672}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 232}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 124}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 617, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 2511, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\164_xCoe\161\\\SYN8\247~X\178U\EOT\201\239d\NUL\v\219\239", _pubPktID = 617, _pubBody = -// "\203\"\151M\221\179{\230\DC3c\185\FS\183-\225\169\214\ETX\128\159\170E\186\239\ESC\153\192\142", _pubProps = -// [PropMaximumQoS 222,PropReceiveMaximum 32352,PropResponseTopic "_-\213",PropSharedSubscriptionAvailable -// 77,PropMessageExpiryInterval 27318,PropSubscriptionIdentifierAvailable 17,PropTopicAlias 4804,PropMaximumQoS -// 245,PropMaximumQoS 33,PropServerReference "\165KJ\219Ap\192\151\200\134\149",PropSharedSubscriptionAvailable -// 196,PropTopicAlias 28672,PropAssignedClientIdentifier "Tl\129`\180&EKq6\201\232\EM(\235\US",PropRetainAvailable -// 117,PropAssignedClientIdentifier "\232\242't\134w\152\212\DC27\155Y\DELx\209s5\197",PropPayloadFormatIndicator -// 133,PropWildcardSubscriptionAvailable 232,PropAuthenticationMethod -// "\227\193\NUL:K\134X\134\245\232\231RB\148\229\214\203\178\186\237\247\252\a9\129lc\DEL\153",PropMaximumQoS -// 231,PropRetainAvailable 124]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\178\&4?\195\154\241'~\229S\255\SO\a40\221\ESC\221:N\212F\r\188l", _pubPktID = 2511, _pubBody = +// "'6\224\138\ETB\f{\166\251\224\EM", _pubProps = []} TEST(Publish5QCTest, Decode2) { - uint8_t pkt[] = { - 0x3b, 0xb9, 0x1, 0x0, 0x17, 0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, 0x58, 0xb2, - 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef, 0x2, 0x69, 0x80, 0x1, 0x24, 0xde, 0x21, 0x7e, 0x60, 0x8, - 0x0, 0x3, 0x5f, 0x2d, 0xd5, 0x2a, 0x4d, 0x2, 0x0, 0x0, 0x6a, 0xb6, 0x29, 0x11, 0x23, 0x12, 0xc4, 0x24, 0xf5, - 0x24, 0x21, 0x1c, 0x0, 0xb, 0xa5, 0x4b, 0x4a, 0xdb, 0x41, 0x70, 0xc0, 0x97, 0xc8, 0x86, 0x95, 0x2a, 0xc4, 0x23, - 0x70, 0x0, 0x12, 0x0, 0x10, 0x54, 0x6c, 0x81, 0x60, 0xb4, 0x26, 0x45, 0x4b, 0x71, 0x36, 0xc9, 0xe8, 0x19, 0x28, - 0xeb, 0x1f, 0x25, 0x75, 0x12, 0x0, 0x12, 0xe8, 0xf2, 0x27, 0x74, 0x86, 0x77, 0x98, 0xd4, 0x12, 0x37, 0x9b, 0x59, - 0x7f, 0x78, 0xd1, 0x73, 0x35, 0xc5, 0x1, 0x85, 0x28, 0xe8, 0x15, 0x0, 0x1d, 0xe3, 0xc1, 0x0, 0x3a, 0x4b, 0x86, - 0x58, 0x86, 0xf5, 0xe8, 0xe7, 0x52, 0x42, 0x94, 0xe5, 0xd6, 0xcb, 0xb2, 0xba, 0xed, 0xf7, 0xfc, 0x7, 0x39, 0x81, - 0x6c, 0x63, 0x7f, 0x99, 0x24, 0xe7, 0x25, 0x7c, 0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, - 0x1c, 0xb7, 0x2d, 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; + uint8_t pkt[] = {0x33, 0x29, 0x0, 0x19, 0xb2, 0x34, 0x3f, 0xc3, 0x9a, 0xf1, 0x27, 0x7e, 0xe5, 0x53, 0xff, + 0xe, 0x7, 0x34, 0x30, 0xdd, 0x1b, 0xdd, 0x3a, 0x4e, 0xd4, 0x46, 0xd, 0xbc, 0x6c, 0x9, + 0xcf, 0x0, 0x27, 0x36, 0xe0, 0x8a, 0x17, 0xc, 0x7b, 0xa6, 0xfb, 0xe0, 0x19}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -1946,111 +1905,122 @@ TEST(Publish5QCTest, Decode2) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xa4, 0x5f, 0x78, 0x43, 0x6f, 0x65, 0xa1, 0x5c, 0x16, 0x38, 0xf7, 0x7e, - 0x58, 0xb2, 0x55, 0x4, 0xc9, 0xef, 0x64, 0x0, 0xb, 0xdb, 0xef}; - lwmqtt_string_t exp_topic = {23, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcb, 0x22, 0x97, 0x4d, 0xdd, 0xb3, 0x7b, 0xe6, 0x13, 0x63, 0xb9, 0x1c, 0xb7, 0x2d, - 0xe1, 0xa9, 0xd6, 0x3, 0x80, 0x9f, 0xaa, 0x45, 0xba, 0xef, 0x1b, 0x99, 0xc0, 0x8e}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xb2, 0x34, 0x3f, 0xc3, 0x9a, 0xf1, 0x27, 0x7e, 0xe5, 0x53, 0xff, 0xe, 0x7, + 0x34, 0x30, 0xdd, 0x1b, 0xdd, 0x3a, 0x4e, 0xd4, 0x46, 0xd, 0xbc, 0x6c}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x27, 0x36, 0xe0, 0x8a, 0x17, 0xc, 0x7b, 0xa6, 0xfb, 0xe0, 0x19}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 617); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 23); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(packet_id, 2511); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "]\DEL\239p\251\205\214zi\204\179\194Y\158", _pubPktID = 0, _pubBody = -// "|\207v\144\230\175\FSN\178\165\215\DC3\EM\250\162\187\135\181", _pubProps = [PropMaximumPacketSize -// 10488,PropPayloadFormatIndicator 12,PropResponseTopic -// "`n\227\135Df\149W\177\181\204\163\199\167\227\179\153sS\SYN8\EOTo",PropAuthenticationMethod -// "\138s\203u\213",PropSharedSubscriptionAvailable 77,PropWildcardSubscriptionAvailable -// 166,PropSubscriptionIdentifierAvailable 21,PropResponseTopic "}\182,\rz\137?\187\r",PropAuthenticationMethod -// "",PropResponseInformation "*hT\196\138\173\SO3[\153\&1\238[.\155[",PropSubscriptionIdentifier 3,PropRetainAvailable -// 191,PropServerKeepAlive 21972,PropAuthenticationData "\249\200\209\&2/",PropContentType -// "\198-\246s1u\142h\151\153",PropSubscriptionIdentifier 7,PropRetainAvailable 255,PropCorrelationData -// "\157gh\147\193INa\203\FS\a\232\a\200\ENQ\190\201\192\182\166\139\177\CAN\vRu",PropMaximumQoS 193,PropResponseTopic -// "\199\236#\244J\216\&4#!",PropAssignedClientIdentifier -// "\230\163=9\213|\128[\232\152\148\255M\STX\209>\225\131\131ba\181\199\234\206\231\NULl",PropMaximumPacketSize -// 4488,PropTopicAliasMaximum 28636,PropAssignedClientIdentifier -// "\153\236\225\131\131ba\181\199\234\206\231\NULl",PropMaximumPacketSize -// 4488,PropTopicAliasMaximum 28636,PropAssignedClientIdentifier -// "\153\236(topic.data), 14); - EXPECT_EQ(msg.payload_len, 18); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 18); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 16); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\&8\RSE", _pubPktID = 14265, -// _pubBody = "OtS\167", _pubProps = [PropTopicAliasMaximum 24809]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(\166\195\173\148\GS\175\209g\RS\b\244\191\221\186\\Z\149\158\195\NUL\158\202{\242", _pubPktID = 7293, _pubBody = +// "\177?\SI\SI1\226\146\135\CAN\224\SYNIK\STX\237y\n\SUBT\185\&7$\f\253My\202C", _pubProps = [PropWillDelayInterval +// 18682,PropResponseInformation "H}\155#U\190\244\FS\DC2\220d]\CAN\145?*<",PropMessageExpiryInterval +// 22657,PropReceiveMaximum 20643,PropTopicAlias 12097,PropSessionExpiryInterval 278,PropContentType +// "\221a9\153\217$\152\150\DEL\STX\140V\214\DC3\129\234\254\EOT",PropMaximumQoS 172,PropServerReference +// "\228\173\STX",PropReceiveMaximum 16352,PropMessageExpiryInterval 21359,PropContentType +// "\147\226\217\177\149\SO6\247\138P\160\254\149?\129\NAK\RS}\176\203\tU\160S\244\229/B\b\b",PropSubscriptionIdentifier +// 26,PropServerReference "\250\NAK\tv\r\DC3 \185\199\155+\189\222\190\EOT\201\&3\164^\137",PropSessionExpiryInterval +// 27140,PropMessageExpiryInterval 22865]} TEST(Publish5QCTest, Encode4) { - uint8_t pkt[] = {0x3d, 0x10, 0x0, 0x4, 0xff, 0x38, 0x1e, 0x45, 0x37, - 0xb9, 0x3, 0x22, 0x60, 0xe9, 0x4f, 0x74, 0x53, 0xa7}; - uint8_t topic_bytes[] = {0xff, 0x38, 0x1e, 0x45}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x32, 0xcd, 0x1, 0x0, 0x19, 0x28, 0xa6, 0xc3, 0xad, 0x94, 0x1d, 0xaf, 0xd1, 0x67, 0x1e, 0x8, 0xf4, 0xbf, 0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xca, 0x43}; + uint8_t topic_bytes[] = {0x28, 0xa6, 0xc3, 0xad, 0x94, 0x1d, 0xaf, 0xd1, 0x67, 0x1e, 0x8, 0xf4, 0xbf, + 0xdd, 0xba, 0x5c, 0x5a, 0x95, 0x9e, 0xc3, 0x0, 0x9e, 0xca, 0x7b, 0xf2}; + lwmqtt_string_t topic = {25, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0x4f, 0x74, 0x53, 0xa7}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0xb1, 0x3f, 0xf, 0xf, 0x31, 0xe2, 0x92, 0x87, 0x18, 0xe0, 0x16, 0x49, 0x4b, 0x2, + 0xed, 0x79, 0xa, 0x1a, 0x54, 0xb9, 0x37, 0x24, 0xc, 0xfd, 0x4d, 0x79, 0xca, 0x43}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 4; + msg.payload_len = 28; + + uint8_t bytesprops0[] = {0x48, 0x7d, 0x9b, 0x23, 0x55, 0xbe, 0xf4, 0x1c, 0x12, + 0xdc, 0x64, 0x5d, 0x18, 0x91, 0x3f, 0x2a, 0x3c}; + uint8_t bytesprops1[] = {0xdd, 0x61, 0x39, 0x99, 0xd9, 0x24, 0x98, 0x96, 0x7f, + 0x2, 0x8c, 0x56, 0xd6, 0x13, 0x81, 0xea, 0xfe, 0x4}; + uint8_t bytesprops2[] = {0xe4, 0xad, 0x2}; + uint8_t bytesprops3[] = {0x93, 0xe2, 0xd9, 0xb1, 0x95, 0xe, 0x36, 0xf7, 0x8a, 0x50, 0xa0, 0xfe, 0x95, 0x3f, 0x81, + 0x15, 0x1e, 0x7d, 0xb0, 0xcb, 0x9, 0x55, 0xa0, 0x53, 0xf4, 0xe5, 0x2f, 0x42, 0x8, 0x8}; + uint8_t bytesprops4[] = {0xfa, 0x15, 0x9, 0x76, 0xd, 0x13, 0x20, 0xb9, 0xc7, 0x9b, + 0x2b, 0xbd, 0xde, 0xbe, 0x4, 0xc9, 0x33, 0xa4, 0x5e, 0x89}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24809}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18682}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22657}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20643}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12097}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 278}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16352}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21359}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27140}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22865}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 14265, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7293, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = True, _pubTopic = "\255\&8\RSE", _pubPktID = 14265, -// _pubBody = "OtS\167", _pubProps = [PropTopicAliasMaximum 24809]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "(\166\195\173\148\GS\175\209g\RS\b\244\191\221\186\\Z\149\158\195\NUL\158\202{\242", _pubPktID = 7293, _pubBody = +// "\177?\SI\SI1\226\146\135\CAN\224\SYNIK\STX\237y\n\SUBT\185\&7$\f\253My\202C", _pubProps = [PropWillDelayInterval +// 18682,PropResponseInformation "H}\155#U\190\244\FS\DC2\220d]\CAN\145?*<",PropMessageExpiryInterval +// 22657,PropReceiveMaximum 20643,PropTopicAlias 12097,PropSessionExpiryInterval 278,PropContentType +// "\221a9\153\217$\152\150\DEL\STX\140V\214\DC3\129\234\254\EOT",PropMaximumQoS 172,PropServerReference +// "\228\173\STX",PropReceiveMaximum 16352,PropMessageExpiryInterval 21359,PropContentType +// "\147\226\217\177\149\SO6\247\138P\160\254\149?\129\NAK\RS}\176\203\tU\160S\244\229/B\b\b",PropSubscriptionIdentifier +// 26,PropServerReference "\250\NAK\tv\r\DC3 \185\199\155+\189\222\190\EOT\201\&3\164^\137",PropSessionExpiryInterval +// 27140,PropMessageExpiryInterval 22865]} TEST(Publish5QCTest, Decode4) { - uint8_t pkt[] = {0x3d, 0x10, 0x0, 0x4, 0xff, 0x38, 0x1e, 0x45, 0x37, - 0xb9, 0x3, 0x22, 0x60, 0xe9, 0x4f, 0x74, 0x53, 0xa7}; + uint8_t pkt[] = { + 0x32, 0xcd, 0x1, 0x0, 0x19, 0x28, 0xa6, 0xc3, 0xad, 0x94, 0x1d, 0xaf, 0xd1, 0x67, 0x1e, 0x8, 0xf4, 0xbf, 0xdd, + 0xba, 0x5c, 0x5a, 0x95, 0x9e, 0xc3, 0x0, 0x9e, 0xca, 0x7b, 0xf2, 0x1c, 0x7d, 0x92, 0x1, 0x18, 0x0, 0x0, 0x48, + 0xfa, 0x1a, 0x0, 0x11, 0x48, 0x7d, 0x9b, 0x23, 0x55, 0xbe, 0xf4, 0x1c, 0x12, 0xdc, 0x64, 0x5d, 0x18, 0x91, 0x3f, + 0x2a, 0x3c, 0x2, 0x0, 0x0, 0x58, 0x81, 0x21, 0x50, 0xa3, 0x23, 0x2f, 0x41, 0x11, 0x0, 0x0, 0x1, 0x16, 0x3, + 0x0, 0x12, 0xdd, 0x61, 0x39, 0x99, 0xd9, 0x24, 0x98, 0x96, 0x7f, 0x2, 0x8c, 0x56, 0xd6, 0x13, 0x81, 0xea, 0xfe, + 0x4, 0x24, 0xac, 0x1c, 0x0, 0x3, 0xe4, 0xad, 0x2, 0x21, 0x3f, 0xe0, 0x2, 0x0, 0x0, 0x53, 0x6f, 0x3, 0x0, + 0x1e, 0x93, 0xe2, 0xd9, 0xb1, 0x95, 0xe, 0x36, 0xf7, 0x8a, 0x50, 0xa0, 0xfe, 0x95, 0x3f, 0x81, 0x15, 0x1e, 0x7d, + 0xb0, 0xcb, 0x9, 0x55, 0xa0, 0x53, 0xf4, 0xe5, 0x2f, 0x42, 0x8, 0x8, 0xb, 0x1a, 0x1c, 0x0, 0x14, 0xfa, 0x15, + 0x9, 0x76, 0xd, 0x13, 0x20, 0xb9, 0xc7, 0x9b, 0x2b, 0xbd, 0xde, 0xbe, 0x4, 0xc9, 0x33, 0xa4, 0x5e, 0x89, 0x11, + 0x0, 0x0, 0x6a, 0x4, 0x2, 0x0, 0x0, 0x59, 0x51, 0xb1, 0x3f, 0xf, 0xf, 0x31, 0xe2, 0x92, 0x87, 0x18, 0xe0, + 0x16, 0x49, 0x4b, 0x2, 0xed, 0x79, 0xa, 0x1a, 0x54, 0xb9, 0x37, 0x24, 0xc, 0xfd, 0x4d, 0x79, 0xca, 0x43}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2154,102 +2192,108 @@ TEST(Publish5QCTest, Decode4) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xff, 0x38, 0x1e, 0x45}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4f, 0x74, 0x53, 0xa7}; - lwmqtt_string_t exp_body = {4, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 14265); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 4); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 4); + uint8_t exp_topic_bytes[] = {0x28, 0xa6, 0xc3, 0xad, 0x94, 0x1d, 0xaf, 0xd1, 0x67, 0x1e, 0x8, 0xf4, 0xbf, + 0xdd, 0xba, 0x5c, 0x5a, 0x95, 0x9e, 0xc3, 0x0, 0x9e, 0xca, 0x7b, 0xf2}; + lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xb1, 0x3f, 0xf, 0xf, 0x31, 0xe2, 0x92, 0x87, 0x18, 0xe0, 0x16, 0x49, 0x4b, 0x2, + 0xed, 0x79, 0xa, 0x1a, 0x54, 0xb9, 0x37, 0x24, 0xc, 0xfd, 0x4d, 0x79, 0xca, 0x43}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7293); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\175\137\vj?Vv\214\&1|l\a\RS\191\237\148\187\223g^\158f\195W\245R\159", _pubPktID = 0, _pubBody = -// "\133\170\157HgVe\197\170\203V\231", _pubProps = [PropReceiveMaximum 21892,PropTopicAlias -// 15063,PropResponseInformation "\182H\aU\ETX$\176_\214a\178\217;PJN\DC1\237\149\219\EM\155\174\249",PropReceiveMaximum -// 4741,PropWildcardSubscriptionAvailable 144,PropMaximumPacketSize 15811,PropAuthenticationData -// "\159&\DLE\t\236\229\181\205\174\191\247\190\212\182\&8\177\160#\239\230\200a",PropAuthenticationData -// "\191\240\208\200fEkt\239\ESC\162XS3X\ACK\180\241\204\185",PropMessageExpiryInterval 32048,PropRetainAvailable -// 81,PropCorrelationData "\163\233\156\b'\241\197\238\227'\203\&7~\b\202\235q\234\171\213\201WX"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\239!qf)\DC1R\192\227\STX\227\191\ENQ\163\242\172\201\233\225\150\242\USr\DEL", _pubPktID = 8490, _pubBody = +// "Hj(;\171\211\&2\147\237^\SO\175\143\&0\161\182\EM", _pubProps = [PropAuthenticationMethod +// "\155\STXSfY\fa\STXz\ACK\206\226l\168L)\204\196",PropMessageExpiryInterval 19840,PropAssignedClientIdentifier +// "\FS*\218\218\153\&0_\206\235\227\ETBpul\226f\224\180\\S0T\155\SOH`+\228\168\229\&4",PropPayloadFormatIndicator +// 31,PropMessageExpiryInterval 13212,PropSubscriptionIdentifierAvailable 132,PropSubscriptionIdentifierAvailable +// 199,PropWillDelayInterval 1350,PropWillDelayInterval 26412,PropResponseTopic +// "\146\173\SUB{\157\248w+",PropReasonString +// "\170\202\211Z\208\216I\GS\DC4u\r1\134\156<\135+\232K8\164\208R\DEL\217\130\130\SUBU\157"]} TEST(Publish5QCTest, Encode5) { - uint8_t pkt[] = {0x39, 0xa6, 0x1, 0x0, 0x1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0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f}; - lwmqtt_string_t topic = {27, (char*)&topic_bytes}; + uint8_t pkt[] = {0x32, 0xaa, 0x1, 0x0, 0x18, 0xef, 0x21, 0x71, 0x66, 0x29, 0x11, 0x52, 0xc0, 0xe3, 0x2, 0xe3, + 0xbf, 0x5, 0xa3, 0xf2, 0xac, 0xc9, 0xe9, 0xe1, 0x96, 0xf2, 0x1f, 0x72, 0x7f, 0x21, 0x2a, 0x7c, + 0x15, 0x0, 0x12, 0x9b, 0x2, 0x53, 0x66, 0x59, 0xc, 0x61, 0x2, 0x7a, 0x6, 0xce, 0xe2, 0x6c, + 0xa8, 0x4c, 0x29, 0xcc, 0xc4, 0x2, 0x0, 0x0, 0x4d, 0x80, 0x12, 0x0, 0x1e, 0x1c, 0x2a, 0xda, + 0xda, 0x99, 0x30, 0x5f, 0xce, 0xeb, 0xe3, 0x17, 0x70, 0x75, 0x6c, 0xe2, 0x66, 0xe0, 0xb4, 0x5c, + 0x53, 0x30, 0x54, 0x9b, 0x1, 0x60, 0x2b, 0xe4, 0xa8, 0xe5, 0x34, 0x1, 0x1f, 0x2, 0x0, 0x0, + 0x33, 0x9c, 0x29, 0x84, 0x29, 0xc7, 0x18, 0x0, 0x0, 0x5, 0x46, 0x18, 0x0, 0x0, 0x67, 0x2c, + 0x8, 0x0, 0x8, 0x92, 0xad, 0x1a, 0x7b, 0x9d, 0xf8, 0x77, 0x2b, 0x1f, 0x0, 0x1e, 0xaa, 0xca, + 0xd3, 0x5a, 0xd0, 0xd8, 0x49, 0x1d, 0x14, 0x75, 0xd, 0x31, 0x86, 0x9c, 0x3c, 0x87, 0x2b, 0xe8, + 0x4b, 0x38, 0xa4, 0xd0, 0x52, 0x7f, 0xd9, 0x82, 0x82, 0x1a, 0x55, 0x9d, 0x48, 0x6a, 0x28, 0x3b, + 0xab, 0xd3, 0x32, 0x93, 0xed, 0x5e, 0xe, 0xaf, 0x8f, 0x30, 0xa1, 0xb6, 0x19}; + uint8_t topic_bytes[] = {0xef, 0x21, 0x71, 0x66, 0x29, 0x11, 0x52, 0xc0, 0xe3, 0x2, 0xe3, 0xbf, + 0x5, 0xa3, 0xf2, 0xac, 0xc9, 0xe9, 0xe1, 0x96, 0xf2, 0x1f, 0x72, 0x7f}; + lwmqtt_string_t topic = {24, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; + msg.qos = LWMQTT_QOS1; + msg.retained = false; + uint8_t msg_bytes[] = {0x48, 0x6a, 0x28, 0x3b, 0xab, 0xd3, 0x32, 0x93, 0xed, + 0x5e, 0xe, 0xaf, 0x8f, 0x30, 0xa1, 0xb6, 0x19}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 17; - uint8_t bytesprops0[] = {0xb6, 0x48, 0x7, 0x55, 0x3, 0x24, 0xb0, 0x5f, 0xd6, 0x61, 0xb2, 0xd9, - 0x3b, 0x50, 0x4a, 0x4e, 0x11, 0xed, 0x95, 0xdb, 0x19, 0x9b, 0xae, 0xf9}; - uint8_t bytesprops1[] = {0x9f, 0x26, 0x10, 0x9, 0xec, 0xe5, 0xb5, 0xcd, 0xae, 0xbf, 0xf7, - 0xbe, 0xd4, 0xb6, 0x38, 0xb1, 0xa0, 0x23, 0xef, 0xe6, 0xc8, 0x61}; - uint8_t bytesprops2[] = {0xbf, 0xf0, 0xd0, 0xc8, 0x66, 0x45, 0x6b, 0x74, 0xef, 0x1b, - 0xa2, 0x58, 0x53, 0x33, 0x58, 0x6, 0xb4, 0xf1, 0xcc, 0xb9}; - uint8_t bytesprops3[] = {0xa3, 0xe9, 0x9c, 0x8, 0x27, 0xf1, 0xc5, 0xee, 0xe3, 0x27, 0xcb, 0x37, - 0x7e, 0x8, 0xca, 0xeb, 0x71, 0xea, 0xab, 0xd5, 0xc9, 0x57, 0x58}; + uint8_t bytesprops0[] = {0x9b, 0x2, 0x53, 0x66, 0x59, 0xc, 0x61, 0x2, 0x7a, + 0x6, 0xce, 0xe2, 0x6c, 0xa8, 0x4c, 0x29, 0xcc, 0xc4}; + uint8_t bytesprops1[] = {0x1c, 0x2a, 0xda, 0xda, 0x99, 0x30, 0x5f, 0xce, 0xeb, 0xe3, 0x17, 0x70, 0x75, 0x6c, 0xe2, + 0x66, 0xe0, 0xb4, 0x5c, 0x53, 0x30, 0x54, 0x9b, 0x1, 0x60, 0x2b, 0xe4, 0xa8, 0xe5, 0x34}; + uint8_t bytesprops2[] = {0x92, 0xad, 0x1a, 0x7b, 0x9d, 0xf8, 0x77, 0x2b}; + uint8_t bytesprops3[] = {0xaa, 0xca, 0xd3, 0x5a, 0xd0, 0xd8, 0x49, 0x1d, 0x14, 0x75, 0xd, 0x31, 0x86, 0x9c, 0x3c, + 0x87, 0x2b, 0xe8, 0x4b, 0x38, 0xa4, 0xd0, 0x52, 0x7f, 0xd9, 0x82, 0x82, 0x1a, 0x55, 0x9d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21892}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15063}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4741}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15811}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32048}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19840}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13212}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1350}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26412}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, }; lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 8490, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\175\137\vj?Vv\214\&1|l\a\RS\191\237\148\187\223g^\158f\195W\245R\159", _pubPktID = 0, _pubBody = -// "\133\170\157HgVe\197\170\203V\231", _pubProps = [PropReceiveMaximum 21892,PropTopicAlias -// 15063,PropResponseInformation "\182H\aU\ETX$\176_\214a\178\217;PJN\DC1\237\149\219\EM\155\174\249",PropReceiveMaximum -// 4741,PropWildcardSubscriptionAvailable 144,PropMaximumPacketSize 15811,PropAuthenticationData -// "\159&\DLE\t\236\229\181\205\174\191\247\190\212\182\&8\177\160#\239\230\200a",PropAuthenticationData -// "\191\240\208\200fEkt\239\ESC\162XS3X\ACK\180\241\204\185",PropMessageExpiryInterval 32048,PropRetainAvailable -// 81,PropCorrelationData "\163\233\156\b'\241\197\238\227'\203\&7~\b\202\235q\234\171\213\201WX"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\239!qf)\DC1R\192\227\STX\227\191\ENQ\163\242\172\201\233\225\150\242\USr\DEL", _pubPktID = 8490, _pubBody = +// "Hj(;\171\211\&2\147\237^\SO\175\143\&0\161\182\EM", _pubProps = [PropAuthenticationMethod +// "\155\STXSfY\fa\STXz\ACK\206\226l\168L)\204\196",PropMessageExpiryInterval 19840,PropAssignedClientIdentifier +// "\FS*\218\218\153\&0_\206\235\227\ETBpul\226f\224\180\\S0T\155\SOH`+\228\168\229\&4",PropPayloadFormatIndicator +// 31,PropMessageExpiryInterval 13212,PropSubscriptionIdentifierAvailable 132,PropSubscriptionIdentifierAvailable +// 199,PropWillDelayInterval 1350,PropWillDelayInterval 26412,PropResponseTopic +// "\146\173\SUB{\157\248w+",PropReasonString +// "\170\202\211Z\208\216I\GS\DC4u\r1\134\156<\135+\232K8\164\208R\DEL\217\130\130\SUBU\157"]} TEST(Publish5QCTest, Decode5) { - uint8_t pkt[] = {0x39, 0xa6, 0x1, 0x0, 0x1b, 0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, 0x7, - 0x1e, 0xbf, 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f, 0x7c, 0x21, - 0x55, 0x84, 0x23, 0x3a, 0xd7, 0x1a, 0x0, 0x18, 0xb6, 0x48, 0x7, 0x55, 0x3, 0x24, 0xb0, 0x5f, 0xd6, - 0x61, 0xb2, 0xd9, 0x3b, 0x50, 0x4a, 0x4e, 0x11, 0xed, 0x95, 0xdb, 0x19, 0x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, 0x5c, + 0x53, 0x30, 0x54, 0x9b, 0x1, 0x60, 0x2b, 0xe4, 0xa8, 0xe5, 0x34, 0x1, 0x1f, 0x2, 0x0, 0x0, + 0x33, 0x9c, 0x29, 0x84, 0x29, 0xc7, 0x18, 0x0, 0x0, 0x5, 0x46, 0x18, 0x0, 0x0, 0x67, 0x2c, + 0x8, 0x0, 0x8, 0x92, 0xad, 0x1a, 0x7b, 0x9d, 0xf8, 0x77, 0x2b, 0x1f, 0x0, 0x1e, 0xaa, 0xca, + 0xd3, 0x5a, 0xd0, 0xd8, 0x49, 0x1d, 0x14, 0x75, 0xd, 0x31, 0x86, 0x9c, 0x3c, 0x87, 0x2b, 0xe8, + 0x4b, 0x38, 0xa4, 0xd0, 0x52, 0x7f, 0xd9, 0x82, 0x82, 0x1a, 0x55, 0x9d, 0x48, 0x6a, 0x28, 0x3b, + 0xab, 0xd3, 0x32, 0x93, 0xed, 0x5e, 0xe, 0xaf, 0x8f, 0x30, 0xa1, 0xb6, 0x19}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2258,130 +2302,66 @@ TEST(Publish5QCTest, Decode5) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xaf, 0x89, 0xb, 0x6a, 0x3f, 0x56, 0x76, 0xd6, 0x31, 0x7c, 0x6c, 0x7, 0x1e, 0xbf, - 0xed, 0x94, 0xbb, 0xdf, 0x67, 0x5e, 0x9e, 0x66, 0xc3, 0x57, 0xf5, 0x52, 0x9f}; - lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x85, 0xaa, 0x9d, 0x48, 0x67, 0x56, 0x65, 0xc5, 0xaa, 0xcb, 0x56, 0xe7}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + uint8_t exp_topic_bytes[] = {0xef, 0x21, 0x71, 0x66, 0x29, 0x11, 0x52, 0xc0, 0xe3, 0x2, 0xe3, 0xbf, + 0x5, 0xa3, 0xf2, 0xac, 0xc9, 0xe9, 0xe1, 0x96, 0xf2, 0x1f, 0x72, 0x7f}; + lwmqtt_string_t exp_topic = {24, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x48, 0x6a, 0x28, 0x3b, 0xab, 0xd3, 0x32, 0x93, 0xed, + 0x5e, 0xe, 0xaf, 0x8f, 0x30, 0xa1, 0xb6, 0x19}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 8490); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 24); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\fn)\RS", _pubPktID = 5499, _pubBody -// = "\156I\SUB\231\236b\ENQ\137\237\r\NAK:[\222g\135", _pubProps = [PropResponseInformation -// "!mQ\NUL\213\194T\222",PropAuthenticationData -// "L\185\136R\252E\189\233\220\193\SYN;\182\234\239[\188\&1\171\143%\144\242",PropReceiveMaximum 4689,PropResponseTopic -// "\CANgB#\ENQz\195$\SOH\221\164M\STXa\203d8K*",PropSharedSubscriptionAvailable 169,PropMaximumPacketSize -// 5137,PropRequestProblemInformation 210,PropResponseTopic -// "\185$\SO\155\135\151\DLE\ETB\178#\200\\\210\216\SOH\197u\CAN'\n\224\206",PropUserProperty -// "l6\149r\NAK\188\191~\155\128@8c\245\\'\144\169\231" -// "\\\204E\175\SI\156\150XH\185\247\254\RSy",PropSessionExpiryInterval 8146,PropReasonString -// "s\221@M\SI\254",PropReceiveMaximum 14585,PropUserProperty ")H\207\234P\197Pv" -// "s8tQ\163QX\SUB\171\223\149\178\248H\a\243\136\163\183",PropMessageExpiryInterval 11331,PropReasonString -// "(R!\207\172E*-\192\184\227",PropWillDelayInterval 23672]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "~\225\DLELiZW,vB\173`\255\CAN+\v\194\238", _pubPktID = 25725, _pubBody = +// "\188\SO\205\140\237\238\138\149\210\239m\246\ACK>\DC4\249\182\183(\131\128\&5\164X\173\&0C", _pubProps = +// [PropReceiveMaximum 12703]} TEST(Publish5QCTest, Encode6) { - uint8_t pkt[] = {0x3a, 0xe9, 0x1, 0x0, 0x4, 0xc, 0x6e, 0x29, 0x1e, 0x15, 0x7b, 0xcf, 0x1, 0x1a, 0x0, 0x8, 0x21, - 0x6d, 0x51, 0x0, 0xd5, 0xc2, 0x54, 0xde, 0x16, 0x0, 0x17, 0x4c, 0xb9, 0x88, 0x52, 0xfc, 0x45, 0xbd, - 0xe9, 0xdc, 0xc1, 0x16, 0x3b, 0xb6, 0xea, 0xef, 0x5b, 0xbc, 0x31, 0xab, 0x8f, 0x25, 0x90, 0xf2, 0x21, - 0x12, 0x51, 0x8, 0x0, 0x13, 0x18, 0x67, 0x42, 0x23, 0x5, 0x7a, 0xc3, 0x24, 0x1, 0xdd, 0xa4, 0x4d, - 0x2, 0x61, 0xcb, 0x64, 0x38, 0x4b, 0x2a, 0x2a, 0xa9, 0x27, 0x0, 0x0, 0x14, 0x11, 0x17, 0xd2, 0x8, - 0x0, 0x16, 0xb9, 0x24, 0xe, 0x9b, 0x87, 0x97, 0x10, 0x17, 0xb2, 0x23, 0xc8, 0x5c, 0xd2, 0xd8, 0x1, - 0xc5, 0x75, 0x18, 0x27, 0xa, 0xe0, 0xce, 0x26, 0x0, 0x13, 0x6c, 0x36, 0x95, 0x72, 0x15, 0xbc, 0xbf, - 0x7e, 0x9b, 0x80, 0x40, 0x38, 0x63, 0xf5, 0x5c, 0x27, 0x90, 0xa9, 0xe7, 0x0, 0xe, 0x5c, 0xcc, 0x45, - 0xaf, 0xf, 0x9c, 0x96, 0x58, 0x48, 0xb9, 0xf7, 0xfe, 0x1e, 0x79, 0x11, 0x0, 0x0, 0x1f, 0xd2, 0x1f, - 0x0, 0x6, 0x73, 0xdd, 0x40, 0x4d, 0xf, 0xfe, 0x21, 0x38, 0xf9, 0x26, 0x0, 0x8, 0x29, 0x48, 0xcf, - 0xea, 0x50, 0xc5, 0x50, 0x76, 0x0, 0x13, 0x73, 0x38, 0x74, 0x51, 0xa3, 0x51, 0x58, 0x1a, 0xab, 0xdf, - 0x95, 0xb2, 0xf8, 0x48, 0x7, 0xf3, 0x88, 0xa3, 0xb7, 0x2, 0x0, 0x0, 0x2c, 0x43, 0x1f, 0x0, 0xb, - 0x28, 0x52, 0x21, 0xcf, 0xac, 0x45, 0x2a, 0x2d, 0xc0, 0xb8, 0xe3, 0x18, 0x0, 0x0, 0x5c, 0x78, 0x9c, - 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; - uint8_t topic_bytes[] = {0xc, 0x6e, 0x29, 0x1e}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x35, 0x0, 0x12, 0x7e, 0xe1, 0x10, 0x4c, 0x69, 0x5a, 0x57, 0x2c, 0x76, 0x42, + 0xad, 0x60, 0xff, 0x18, 0x2b, 0xb, 0xc2, 0xee, 0x64, 0x7d, 0x3, 0x21, 0x31, 0x9f, + 0xbc, 0xe, 0xcd, 0x8c, 0xed, 0xee, 0x8a, 0x95, 0xd2, 0xef, 0x6d, 0xf6, 0x6, 0x3e, + 0x14, 0xf9, 0xb6, 0xb7, 0x28, 0x83, 0x80, 0x35, 0xa4, 0x58, 0xad, 0x30, 0x43}; + uint8_t topic_bytes[] = {0x7e, 0xe1, 0x10, 0x4c, 0x69, 0x5a, 0x57, 0x2c, 0x76, + 0x42, 0xad, 0x60, 0xff, 0x18, 0x2b, 0xb, 0xc2, 0xee}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0x9c, 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; + uint8_t msg_bytes[] = {0xbc, 0xe, 0xcd, 0x8c, 0xed, 0xee, 0x8a, 0x95, 0xd2, 0xef, 0x6d, 0xf6, 0x6, 0x3e, + 0x14, 0xf9, 0xb6, 0xb7, 0x28, 0x83, 0x80, 0x35, 0xa4, 0x58, 0xad, 0x30, 0x43}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; - - uint8_t bytesprops0[] = {0x21, 0x6d, 0x51, 0x0, 0xd5, 0xc2, 0x54, 0xde}; - uint8_t bytesprops1[] = {0x4c, 0xb9, 0x88, 0x52, 0xfc, 0x45, 0xbd, 0xe9, 0xdc, 0xc1, 0x16, 0x3b, - 0xb6, 0xea, 0xef, 0x5b, 0xbc, 0x31, 0xab, 0x8f, 0x25, 0x90, 0xf2}; - uint8_t bytesprops2[] = {0x18, 0x67, 0x42, 0x23, 0x5, 0x7a, 0xc3, 0x24, 0x1, 0xdd, - 0xa4, 0x4d, 0x2, 0x61, 0xcb, 0x64, 0x38, 0x4b, 0x2a}; - uint8_t bytesprops3[] = {0xb9, 0x24, 0xe, 0x9b, 0x87, 0x97, 0x10, 0x17, 0xb2, 0x23, 0xc8, - 0x5c, 0xd2, 0xd8, 0x1, 0xc5, 0x75, 0x18, 0x27, 0xa, 0xe0, 0xce}; - uint8_t bytesprops5[] = {0x5c, 0xcc, 0x45, 0xaf, 0xf, 0x9c, 0x96, 0x58, 0x48, 0xb9, 0xf7, 0xfe, 0x1e, 0x79}; - uint8_t bytesprops4[] = {0x6c, 0x36, 0x95, 0x72, 0x15, 0xbc, 0xbf, 0x7e, 0x9b, 0x80, - 0x40, 0x38, 0x63, 0xf5, 0x5c, 0x27, 0x90, 0xa9, 0xe7}; - uint8_t bytesprops6[] = {0x73, 0xdd, 0x40, 0x4d, 0xf, 0xfe}; - uint8_t bytesprops8[] = {0x73, 0x38, 0x74, 0x51, 0xa3, 0x51, 0x58, 0x1a, 0xab, 0xdf, - 0x95, 0xb2, 0xf8, 0x48, 0x7, 0xf3, 0x88, 0xa3, 0xb7}; - uint8_t bytesprops7[] = {0x29, 0x48, 0xcf, 0xea, 0x50, 0xc5, 0x50, 0x76}; - uint8_t bytesprops9[] = {0x28, 0x52, 0x21, 0xcf, 0xac, 0x45, 0x2a, 0x2d, 0xc0, 0xb8, 0xe3}; + msg.payload_len = 27; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4689}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5137}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops4}, .v = {14, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8146}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14585}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops7}, .v = {19, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11331}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23672}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12703}}, }; - lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 5499, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 25725, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\fn)\RS", _pubPktID = 5499, _pubBody -// = "\156I\SUB\231\236b\ENQ\137\237\r\NAK:[\222g\135", _pubProps = [PropResponseInformation -// "!mQ\NUL\213\194T\222",PropAuthenticationData -// "L\185\136R\252E\189\233\220\193\SYN;\182\234\239[\188\&1\171\143%\144\242",PropReceiveMaximum 4689,PropResponseTopic -// "\CANgB#\ENQz\195$\SOH\221\164M\STXa\203d8K*",PropSharedSubscriptionAvailable 169,PropMaximumPacketSize -// 5137,PropRequestProblemInformation 210,PropResponseTopic -// "\185$\SO\155\135\151\DLE\ETB\178#\200\\\210\216\SOH\197u\CAN'\n\224\206",PropUserProperty -// "l6\149r\NAK\188\191~\155\128@8c\245\\'\144\169\231" -// "\\\204E\175\SI\156\150XH\185\247\254\RSy",PropSessionExpiryInterval 8146,PropReasonString -// "s\221@M\SI\254",PropReceiveMaximum 14585,PropUserProperty ")H\207\234P\197Pv" -// "s8tQ\163QX\SUB\171\223\149\178\248H\a\243\136\163\183",PropMessageExpiryInterval 11331,PropReasonString -// "(R!\207\172E*-\192\184\227",PropWillDelayInterval 23672]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "~\225\DLELiZW,vB\173`\255\CAN+\v\194\238", _pubPktID = 25725, _pubBody = +// "\188\SO\205\140\237\238\138\149\210\239m\246\ACK>\DC4\249\182\183(\131\128\&5\164X\173\&0C", _pubProps = +// [PropReceiveMaximum 12703]} TEST(Publish5QCTest, Decode6) { - uint8_t pkt[] = {0x3a, 0xe9, 0x1, 0x0, 0x4, 0xc, 0x6e, 0x29, 0x1e, 0x15, 0x7b, 0xcf, 0x1, 0x1a, 0x0, 0x8, 0x21, - 0x6d, 0x51, 0x0, 0xd5, 0xc2, 0x54, 0xde, 0x16, 0x0, 0x17, 0x4c, 0xb9, 0x88, 0x52, 0xfc, 0x45, 0xbd, - 0xe9, 0xdc, 0xc1, 0x16, 0x3b, 0xb6, 0xea, 0xef, 0x5b, 0xbc, 0x31, 0xab, 0x8f, 0x25, 0x90, 0xf2, 0x21, - 0x12, 0x51, 0x8, 0x0, 0x13, 0x18, 0x67, 0x42, 0x23, 0x5, 0x7a, 0xc3, 0x24, 0x1, 0xdd, 0xa4, 0x4d, - 0x2, 0x61, 0xcb, 0x64, 0x38, 0x4b, 0x2a, 0x2a, 0xa9, 0x27, 0x0, 0x0, 0x14, 0x11, 0x17, 0xd2, 0x8, - 0x0, 0x16, 0xb9, 0x24, 0xe, 0x9b, 0x87, 0x97, 0x10, 0x17, 0xb2, 0x23, 0xc8, 0x5c, 0xd2, 0xd8, 0x1, - 0xc5, 0x75, 0x18, 0x27, 0xa, 0xe0, 0xce, 0x26, 0x0, 0x13, 0x6c, 0x36, 0x95, 0x72, 0x15, 0xbc, 0xbf, - 0x7e, 0x9b, 0x80, 0x40, 0x38, 0x63, 0xf5, 0x5c, 0x27, 0x90, 0xa9, 0xe7, 0x0, 0xe, 0x5c, 0xcc, 0x45, - 0xaf, 0xf, 0x9c, 0x96, 0x58, 0x48, 0xb9, 0xf7, 0xfe, 0x1e, 0x79, 0x11, 0x0, 0x0, 0x1f, 0xd2, 0x1f, - 0x0, 0x6, 0x73, 0xdd, 0x40, 0x4d, 0xf, 0xfe, 0x21, 0x38, 0xf9, 0x26, 0x0, 0x8, 0x29, 0x48, 0xcf, - 0xea, 0x50, 0xc5, 0x50, 0x76, 0x0, 0x13, 0x73, 0x38, 0x74, 0x51, 0xa3, 0x51, 0x58, 0x1a, 0xab, 0xdf, - 0x95, 0xb2, 0xf8, 0x48, 0x7, 0xf3, 0x88, 0xa3, 0xb7, 0x2, 0x0, 0x0, 0x2c, 0x43, 0x1f, 0x0, 0xb, - 0x28, 0x52, 0x21, 0xcf, 0xac, 0x45, 0x2a, 0x2d, 0xc0, 0xb8, 0xe3, 0x18, 0x0, 0x0, 0x5c, 0x78, 0x9c, - 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; + uint8_t pkt[] = {0x3c, 0x35, 0x0, 0x12, 0x7e, 0xe1, 0x10, 0x4c, 0x69, 0x5a, 0x57, 0x2c, 0x76, 0x42, + 0xad, 0x60, 0xff, 0x18, 0x2b, 0xb, 0xc2, 0xee, 0x64, 0x7d, 0x3, 0x21, 0x31, 0x9f, + 0xbc, 0xe, 0xcd, 0x8c, 0xed, 0xee, 0x8a, 0x95, 0xd2, 0xef, 0x6d, 0xf6, 0x6, 0x3e, + 0x14, 0xf9, 0xb6, 0xb7, 0x28, 0x83, 0x80, 0x35, 0xa4, 0x58, 0xad, 0x30, 0x43}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2390,138 +2370,69 @@ TEST(Publish5QCTest, Decode6) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc, 0x6e, 0x29, 0x1e}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9c, 0x49, 0x1a, 0xe7, 0xec, 0x62, 0x5, 0x89, - 0xed, 0xd, 0x15, 0x3a, 0x5b, 0xde, 0x67, 0x87}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x7e, 0xe1, 0x10, 0x4c, 0x69, 0x5a, 0x57, 0x2c, 0x76, + 0x42, 0xad, 0x60, 0xff, 0x18, 0x2b, 0xb, 0xc2, 0xee}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xbc, 0xe, 0xcd, 0x8c, 0xed, 0xee, 0x8a, 0x95, 0xd2, 0xef, 0x6d, 0xf6, 0x6, 0x3e, + 0x14, 0xf9, 0xb6, 0xb7, 0x28, 0x83, 0x80, 0x35, 0xa4, 0x58, 0xad, 0x30, 0x43}; + lwmqtt_string_t exp_body = {27, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 5499); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + EXPECT_EQ(packet_id, 25725); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 27); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 27); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\213\v\236\218d\193\162h[\237\155\196\145\159\198g\146\138\155\197\164", _pubPktID = 0, _pubBody = -// "\189\233\193\r`$@\171\DC1\230\203j\203\187J\148oG\177\155\SUB\253\232\211\t\DC4#\230", _pubProps = -// [PropAssignedClientIdentifier "\189Q\242\130\236\n\SI\134\185\171",PropReasonString -// "\131y\173\229O\161\156\238\EM\233\174\174\DC1\FS\DLEQ\158",PropCorrelationData -// "Yz\DC3]\196RY\139y3\194\252\&7\v\221\b\192\228\170\251\132\200\200",PropAuthenticationMethod -// "\243\133e\207\EOT,\198\&3S\151\225\222\US\161f",PropAssignedClientIdentifier -// "\200\195-\140+\SYN#U\249\153",PropAuthenticationMethod ">\211\231Y\154\190XNa)",PropWillDelayInterval -// 21746,PropServerReference "\DC2\150\230P%",PropAuthenticationData "4Up\210\193a",PropSubscriptionIdentifier -// 17,PropMessageExpiryInterval 29495,PropWildcardSubscriptionAvailable 235,PropMessageExpiryInterval -// 30240,PropWildcardSubscriptionAvailable 67,PropAuthenticationData -// "\ETB\141@\176,\234B\164t]l\US\232\RS)\\\SUB\175:,\221Jg>",PropRequestResponseInformation 169,PropServerReference -// "7\\\156U\140b\ESC\248",PropReceiveMaximum 29471,PropAuthenticationData "\149\152\199\&2-8M\229\209\182U\137\241"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "_\173\SI\187N\192\141\207\237\228\129\187v\189VY\232b\187N\179\SO", _pubPktID = 26097, _pubBody = +// "\175\134\253\152O\211\174\USV\DC4\249", _pubProps = [PropSessionExpiryInterval 8242,PropAssignedClientIdentifier +// "=\128<\205\223\254\&0i\134\SI",PropWildcardSubscriptionAvailable 114]} TEST(Publish5QCTest, Encode7) { - uint8_t pkt[] = { - 0x38, 0xfd, 0x1, 0x0, 0x15, 0xd5, 0xb, 0x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 0x3e, 0x19, 0xa9, 0x1c, 0x0, 0x8, 0x37, 0x5c, 0x9c, 0x55, 0x8c, 0x62, 0x1b, 0xf8, - 0x21, 0x73, 0x1f, 0x16, 0x0, 0xd, 0x95, 0x98, 0xc7, 0x32, 0x2d, 0x38, 0x4d, 0xe5, 0xd1, 0xb6, 0x55, 0x89, 0xf1, - 0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, 0x4a, 0x94, 0x6f, 0x47, 0xb1, - 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; - uint8_t topic_bytes[] = {0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, 0x9b, - 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4}; - lwmqtt_string_t topic = {21, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x3a, 0x0, 0x16, 0x5f, 0xad, 0xf, 0xbb, 0x4e, 0xc0, 0x8d, 0xcf, 0xed, 0xe4, 0x81, + 0xbb, 0x76, 0xbd, 0x56, 0x59, 0xe8, 0x62, 0xbb, 0x4e, 0xb3, 0xe, 0x65, 0xf1, 0x14, 0x11, + 0x0, 0x0, 0x20, 0x32, 0x12, 0x0, 0xa, 0x3d, 0x80, 0x3c, 0xcd, 0xdf, 0xfe, 0x30, 0x69, + 0x86, 0xf, 0x28, 0x72, 0xaf, 0x86, 0xfd, 0x98, 0x4f, 0xd3, 0xae, 0x1f, 0x56, 0x14, 0xf9}; + uint8_t topic_bytes[] = {0x5f, 0xad, 0xf, 0xbb, 0x4e, 0xc0, 0x8d, 0xcf, 0xed, 0xe4, 0x81, + 0xbb, 0x76, 0xbd, 0x56, 0x59, 0xe8, 0x62, 0xbb, 0x4e, 0xb3, 0xe}; + lwmqtt_string_t topic = {22, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS2; msg.retained = false; - uint8_t msg_bytes[] = {0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, - 0x4a, 0x94, 0x6f, 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; + uint8_t msg_bytes[] = {0xaf, 0x86, 0xfd, 0x98, 0x4f, 0xd3, 0xae, 0x1f, 0x56, 0x14, 0xf9}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 28; + msg.payload_len = 11; - uint8_t bytesprops0[] = {0xbd, 0x51, 0xf2, 0x82, 0xec, 0xa, 0xf, 0x86, 0xb9, 0xab}; - uint8_t bytesprops1[] = {0x83, 0x79, 0xad, 0xe5, 0x4f, 0xa1, 0x9c, 0xee, 0x19, - 0xe9, 0xae, 0xae, 0x11, 0x1c, 0x10, 0x51, 0x9e}; - uint8_t bytesprops2[] = {0x59, 0x7a, 0x13, 0x5d, 0xc4, 0x52, 0x59, 0x8b, 0x79, 0x33, 0xc2, 0xfc, - 0x37, 0xb, 0xdd, 0x8, 0xc0, 0xe4, 0xaa, 0xfb, 0x84, 0xc8, 0xc8}; - uint8_t bytesprops3[] = {0xf3, 0x85, 0x65, 0xcf, 0x4, 0x2c, 0xc6, 0x33, 0x53, 0x97, 0xe1, 0xde, 0x1f, 0xa1, 0x66}; - uint8_t bytesprops4[] = {0xc8, 0xc3, 0x2d, 0x8c, 0x2b, 0x16, 0x23, 0x55, 0xf9, 0x99}; - uint8_t bytesprops5[] = {0x3e, 0xd3, 0xe7, 0x59, 0x9a, 0xbe, 0x58, 0x4e, 0x61, 0x29}; - uint8_t bytesprops6[] = {0x12, 0x96, 0xe6, 0x50, 0x25}; - uint8_t bytesprops7[] = {0x34, 0x55, 0x70, 0xd2, 0xc1, 0x61}; - uint8_t bytesprops8[] = {0x17, 0x8d, 0x40, 0xb0, 0x2c, 0xea, 0x42, 0xa4, 0x74, 0x5d, 0x6c, 0x1f, - 0xe8, 0x1e, 0x29, 0x5c, 0x1a, 0xaf, 0x3a, 0x2c, 0xdd, 0x4a, 0x67, 0x3e}; - uint8_t bytesprops9[] = {0x37, 0x5c, 0x9c, 0x55, 0x8c, 0x62, 0x1b, 0xf8}; - uint8_t bytesprops10[] = {0x95, 0x98, 0xc7, 0x32, 0x2d, 0x38, 0x4d, 0xe5, 0xd1, 0xb6, 0x55, 0x89, 0xf1}; + uint8_t bytesprops0[] = {0x3d, 0x80, 0x3c, 0xcd, 0xdf, 0xfe, 0x30, 0x69, 0x86, 0xf}; lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8242}}, {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21746}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29495}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30240}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29471}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 114}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 26097, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\213\v\236\218d\193\162h[\237\155\196\145\159\198g\146\138\155\197\164", _pubPktID = 0, _pubBody = -// "\189\233\193\r`$@\171\DC1\230\203j\203\187J\148oG\177\155\SUB\253\232\211\t\DC4#\230", _pubProps = -// [PropAssignedClientIdentifier "\189Q\242\130\236\n\SI\134\185\171",PropReasonString -// "\131y\173\229O\161\156\238\EM\233\174\174\DC1\FS\DLEQ\158",PropCorrelationData -// "Yz\DC3]\196RY\139y3\194\252\&7\v\221\b\192\228\170\251\132\200\200",PropAuthenticationMethod -// "\243\133e\207\EOT,\198\&3S\151\225\222\US\161f",PropAssignedClientIdentifier -// "\200\195-\140+\SYN#U\249\153",PropAuthenticationMethod ">\211\231Y\154\190XNa)",PropWillDelayInterval -// 21746,PropServerReference "\DC2\150\230P%",PropAuthenticationData "4Up\210\193a",PropSubscriptionIdentifier -// 17,PropMessageExpiryInterval 29495,PropWildcardSubscriptionAvailable 235,PropMessageExpiryInterval -// 30240,PropWildcardSubscriptionAvailable 67,PropAuthenticationData -// "\ETB\141@\176,\234B\164t]l\US\232\RS)\\\SUB\175:,\221Jg>",PropRequestResponseInformation 169,PropServerReference -// "7\\\156U\140b\ESC\248",PropReceiveMaximum 29471,PropAuthenticationData "\149\152\199\&2-8M\229\209\182U\137\241"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = +// "_\173\SI\187N\192\141\207\237\228\129\187v\189VY\232b\187N\179\SO", _pubPktID = 26097, _pubBody = +// "\175\134\253\152O\211\174\USV\DC4\249", _pubProps = [PropSessionExpiryInterval 8242,PropAssignedClientIdentifier +// "=\128<\205\223\254\&0i\134\SI",PropWildcardSubscriptionAvailable 114]} TEST(Publish5QCTest, Decode7) { - uint8_t pkt[] = { - 0x38, 0xfd, 0x1, 0x0, 0x15, 0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, 0x9b, 0xc4, 0x91, 0x9f, - 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4, 0xc8, 0x1, 0x12, 0x0, 0xa, 0xbd, 0x51, 0xf2, 0x82, 0xec, 0xa, 0xf, - 0x86, 0xb9, 0xab, 0x1f, 0x0, 0x11, 0x83, 0x79, 0xad, 0xe5, 0x4f, 0xa1, 0x9c, 0xee, 0x19, 0xe9, 0xae, 0xae, 0x11, - 0x1c, 0x10, 0x51, 0x9e, 0x9, 0x0, 0x17, 0x59, 0x7a, 0x13, 0x5d, 0xc4, 0x52, 0x59, 0x8b, 0x79, 0x33, 0xc2, 0xfc, - 0x37, 0xb, 0xdd, 0x8, 0xc0, 0xe4, 0xaa, 0xfb, 0x84, 0xc8, 0xc8, 0x15, 0x0, 0xf, 0xf3, 0x85, 0x65, 0xcf, 0x4, - 0x2c, 0xc6, 0x33, 0x53, 0x97, 0xe1, 0xde, 0x1f, 0xa1, 0x66, 0x12, 0x0, 0xa, 0xc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a, 0x3d, 0x80, 0x3c, 0xcd, 0xdf, 0xfe, 0x30, 0x69, + 0x86, 0xf, 0x28, 0x72, 0xaf, 0x86, 0xfd, 0x98, 0x4f, 0xd3, 0xae, 0x1f, 0x56, 0x14, 0xf9}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2530,185 +2441,185 @@ TEST(Publish5QCTest, Decode7) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xd5, 0xb, 0xec, 0xda, 0x64, 0xc1, 0xa2, 0x68, 0x5b, 0xed, 0x9b, - 0xc4, 0x91, 0x9f, 0xc6, 0x67, 0x92, 0x8a, 0x9b, 0xc5, 0xa4}; - lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xbd, 0xe9, 0xc1, 0xd, 0x60, 0x24, 0x40, 0xab, 0x11, 0xe6, 0xcb, 0x6a, 0xcb, 0xbb, - 0x4a, 0x94, 0x6f, 0x47, 0xb1, 0x9b, 0x1a, 0xfd, 0xe8, 0xd3, 0x9, 0x14, 0x23, 0xe6}; - lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + uint8_t exp_topic_bytes[] = {0x5f, 0xad, 0xf, 0xbb, 0x4e, 0xc0, 0x8d, 0xcf, 0xed, 0xe4, 0x81, + 0xbb, 0x76, 0xbd, 0x56, 0x59, 0xe8, 0x62, 0xbb, 0x4e, 0xb3, 0xe}; + lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xaf, 0x86, 0xfd, 0x98, 0x4f, 0xd3, 0xae, 0x1f, 0x56, 0x14, 0xf9}; + lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(packet_id, 26097); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); + EXPECT_EQ(msg.payload_len, 11); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = -// "=\249\252\228\210\187\154\150C8*\146,\US8\152\128\152", _pubPktID = 8421, _pubBody = -// "4O\FS\186T\238#\USg\NULl\152\154\239\249\SUB2>H#\188", _pubProps = [PropReasonString -// "\191\&3j\158\NUL%\255\ACK\a\180^\EOT\b\211 &H\239\168\"\229X",PropSessionExpiryInterval 27418,PropWillDelayInterval -// 22825,PropRetainAvailable 208,PropSharedSubscriptionAvailable 195,PropSubscriptionIdentifierAvailable -// 100,PropReasonString " -// r\155\221\NUL\139!\219\DC3\153\178|\160\248\210M5!\201\155\bV\232T\144I-",PropPayloadFormatIndicator -// 140,PropUserProperty "@R\"\149\188\183\140\161l\133\175,\249\230\EM\159\141+^\172Ncp\SII'\179*" -// "\218\251\177\193\218b\EM\250\"\222)\192Dx\180\DC2]\179\245\222\246}\135\169\171\152\n\240t",PropSubscriptionIdentifier -// 0,PropAssignedClientIdentifier "|'G\210\215\153\210\203\248\210@\152Ih\NAK90\205q\161&",PropAuthenticationData -// "\RSk%'\253\241",PropAuthenticationMethod "\190",PropAuthenticationData -// "\248k\129\199\250\US\198\\f\158\190\213\144Q\245~\166\205+\\m%\179\"i\\\191",PropAuthenticationData -// "\146\ESC\DLE\152E\151\228u\214_\214EW\143-\219U(df\186\DC1\ETX\208\230O",PropUserProperty -// "\171\235{\242q\162\178E\209\193\136*\195I\151e\177L\165\164\179\b~H#\188", _pubProps = [PropReasonString -// "\191\&3j\158\NUL%\255\ACK\a\180^\EOT\b\211 &H\239\168\"\229X",PropSessionExpiryInterval 27418,PropWillDelayInterval -// 22825,PropRetainAvailable 208,PropSharedSubscriptionAvailable 195,PropSubscriptionIdentifierAvailable -// 100,PropReasonString " -// r\155\221\NUL\139!\219\DC3\153\178|\160\248\210M5!\201\155\bV\232T\144I-",PropPayloadFormatIndicator -// 140,PropUserProperty "@R\"\149\188\183\140\161l\133\175,\249\230\EM\159\141+^\172Ncp\SII'\179*" -// "\218\251\177\193\218b\EM\250\"\222)\192Dx\180\DC2]\179\245\222\246}\135\169\171\152\n\240t",PropSubscriptionIdentifier -// 0,PropAssignedClientIdentifier "|'G\210\215\153\210\203\248\210@\152Ih\NAK90\205q\161&",PropAuthenticationData -// "\RSk%'\253\241",PropAuthenticationMethod "\190",PropAuthenticationData -// "\248k\129\199\250\US\198\\f\158\190\213\144Q\245~\166\205+\\m%\179\"i\\\191",PropAuthenticationData -// "\146\ESC\DLE\152E\151\228u\214_\214EW\143-\219U(df\186\DC1\ETX\208\230O",PropUserProperty -// "\171\235{\242q\162\178E\209\193\136*\195I\151e\177L\165\164\179\b~(topic.data), 18); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(packet_id, 3661); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\SO\191\141\159\DC1$vw", _pubPktID = -// 301, _pubBody = "`\195\&7\ESC_\216\219\237?~,\244", _pubProps = [PropRequestProblemInformation -// 64,PropAuthenticationMethod "\195(Y\170_\225oG\251\178\174",PropSubscriptionIdentifier 23,PropAuthenticationMethod -// "&+E\184\152\135P",PropRequestResponseInformation 211,PropCorrelationData -// "\209\236W\234V0\EM\GS`\168[\NUL",PropSessionExpiryInterval 22216,PropPayloadFormatIndicator 110,PropTopicAlias -// 1570,PropContentType "\190J]\222\198tA\254Y\135\152D\175\DEL\214\217\135h\225",PropMessageExpiryInterval -// 13095,PropContentType "\t{\ACK\234?/\240[\ESC\141\&5b\181\238t\170u\154\176",PropContentType -// "\ESC\USR\241\&4\134\&7\167\RSWIJMl4)S\204\SO_\\\152\173\192",PropRequestProblemInformation 132,PropResponseTopic -// "f\ETB\177\135\237\ETX\NAKb6\166\162\167,Mke\165",PropResponseInformation -// "\f\237-'\145\&7#\145\177\148X",PropServerReference -// "\178,m}\251I\185\250\EM;}d>T(p\253\226\NUL80\141B\r6",PropReceiveMaximum 30594,PropTopicAlias -// 26876,PropWildcardSubscriptionAvailable 211,PropRequestResponseInformation 173,PropMaximumPacketSize -// 2974,PropReceiveMaximum 6700,PropRequestResponseInformation 193,PropTopicAlias 29250,PropAuthenticationData -// "]\240\151\162\&3\175\154\202\221\RS>8\SOH\247c \209\240j\162\191",PropServerReference -// "PQ$\158l\254\DC1",PropMessageExpiryInterval 31929,PropSessionExpiryInterval 31705,PropAssignedClientIdentifier -// "\153\139\247\160\179\134uyzk\243i_H7\r\255\STXg\189(\v"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\b\201MSc\140\128\CANs\162;\213\155\SO\151\139\229\SOH\229\197", _pubPktID = 30138, _pubBody = +// "`6\148\134s,\US`Z\206\157\252jI5w9\138e\176\183\141}", _pubProps = [PropPayloadFormatIndicator +// 239,PropMessageExpiryInterval 25489,PropPayloadFormatIndicator 87,PropCorrelationData +// "\ENQ\204\US\r\STX\\\188qj\SOHE\172\200\250\234\ACK\DC3\232\&2\166\160\211\181\171n",PropResponseTopic +// "V\243\141\153\DC3\251\n\134\151\214j\179\DC4",PropWillDelayInterval 3022,PropSubscriptionIdentifier +// 15,PropMessageExpiryInterval 11715,PropTopicAliasMaximum 13906,PropRetainAvailable 42,PropRetainAvailable +// 76,PropSessionExpiryInterval 27363,PropReceiveMaximum 29328,PropWillDelayInterval 24879,PropServerKeepAlive +// 29253,PropWillDelayInterval 30252,PropMessageExpiryInterval 6762,PropMaximumPacketSize 20996,PropAuthenticationMethod +// "\227",PropRequestResponseInformation 246,PropServerReference +// "\DLE\224oNcK\245R\166\204\226\166\152e8\241\148\187\GS\226\a\178\215\168\&4",PropTopicAlias 4733,PropContentType +// "A\155\212\167\236\169*\253k\DC2\ri\247\246",PropReasonString "-l\234\131"]} TEST(Publish5QCTest, Encode9) { - uint8_t pkt[] = { - 0x3b, 0xb9, 0x2, 0x0, 0x8, 0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77, 0x1, 0x2d, 0x9f, 0x2, 0x17, 0x40, - 0x15, 0x0, 0xb, 0xc3, 0x28, 0x59, 0xaa, 0x5f, 0xe1, 0x6f, 0x47, 0xfb, 0xb2, 0xae, 0xb, 0x17, 0x15, 0x0, 0x7, - 0x26, 0x2b, 0x45, 0xb8, 0x98, 0x87, 0x50, 0x19, 0xd3, 0x9, 0x0, 0xc, 0xd1, 0xec, 0x57, 0xea, 0x56, 0x30, 0x19, - 0x1d, 0x60, 0xa8, 0x5b, 0x0, 0x11, 0x0, 0x0, 0x56, 0xc8, 0x1, 0x6e, 0x23, 0x6, 0x22, 0x3, 0x0, 0x13, 0xbe, - 0x4a, 0x5d, 0xde, 0xc6, 0x74, 0x41, 0xfe, 0x59, 0x87, 0x98, 0x44, 0xaf, 0x7f, 0xd6, 0xd9, 0x87, 0x68, 0xe1, 0x2, - 0x0, 0x0, 0x33, 0x27, 0x3, 0x0, 0x13, 0x9, 0x7b, 0x6, 0xea, 0x3f, 0x2f, 0xf0, 0x5b, 0x1b, 0x8d, 0x35, 0x62, - 0xb5, 0xee, 0x74, 0xaa, 0x75, 0x9a, 0xb0,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5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; - uint8_t topic_bytes[] = {0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77}; - lwmqtt_string_t topic = {8, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0xd5, 0x1, 0x0, 0x14, 0x8, 0xc9, 0x4d, 0x53, 0x63, 0x8c, 0x80, 0x18, 0x73, 0xa2, 0x3b, 0xd5, + 0x9b, 0xe, 0x97, 0x8b, 0xe5, 0x1, 0xe5, 0xc5, 0x75, 0xba, 0xa4, 0x1, 0x1, 0xef, 0x2, 0x0, 0x0, + 0x63, 0x91, 0x1, 0x57, 0x9, 0x0, 0x19, 0x5, 0xcc, 0x1f, 0xd, 0x2, 0x5c, 0xbc, 0x71, 0x6a, 0x1, + 0x45, 0xac, 0xc8, 0xfa, 0xea, 0x6, 0x13, 0xe8, 0x32, 0xa6, 0xa0, 0xd3, 0xb5, 0xab, 0x6e, 0x8, 0x0, + 0xd, 0x56, 0xf3, 0x8d, 0x99, 0x13, 0xfb, 0xa, 0x86, 0x97, 0xd6, 0x6a, 0xb3, 0x14, 0x18, 0x0, 0x0, + 0xb, 0xce, 0xb, 0xf, 0x2, 0x0, 0x0, 0x2d, 0xc3, 0x22, 0x36, 0x52, 0x25, 0x2a, 0x25, 0x4c, 0x11, + 0x0, 0x0, 0x6a, 0xe3, 0x21, 0x72, 0x90, 0x18, 0x0, 0x0, 0x61, 0x2f, 0x13, 0x72, 0x45, 0x18, 0x0, + 0x0, 0x76, 0x2c, 0x2, 0x0, 0x0, 0x1a, 0x6a, 0x27, 0x0, 0x0, 0x52, 0x4, 0x15, 0x0, 0x1, 0xe3, + 0x19, 0xf6, 0x1c, 0x0, 0x19, 0x10, 0xe0, 0x6f, 0x4e, 0x63, 0x4b, 0xf5, 0x52, 0xa6, 0xcc, 0xe2, 0xa6, + 0x98, 0x65, 0x38, 0xf1, 0x94, 0xbb, 0x1d, 0xe2, 0x7, 0xb2, 0xd7, 0xa8, 0x34, 0x23, 0x12, 0x7d, 0x3, + 0x0, 0xe, 0x41, 0x9b, 0xd4, 0xa7, 0xec, 0xa9, 0x2a, 0xfd, 0x6b, 0x12, 0xd, 0x69, 0xf7, 0xf6, 0x1f, + 0x0, 0x4, 0x2d, 0x6c, 0xea, 0x83, 0x60, 0x36, 0x94, 0x86, 0x73, 0x2c, 0x1f, 0x60, 0x5a, 0xce, 0x9d, + 0xfc, 0x6a, 0x49, 0x35, 0x77, 0x39, 0x8a, 0x65, 0xb0, 0xb7, 0x8d, 0x7d}; + uint8_t topic_bytes[] = {0x8, 0xc9, 0x4d, 0x53, 0x63, 0x8c, 0x80, 0x18, 0x73, 0xa2, + 0x3b, 0xd5, 0x9b, 0xe, 0x97, 0x8b, 0xe5, 0x1, 0xe5, 0xc5}; + lwmqtt_string_t topic = {20, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; + uint8_t msg_bytes[] = {0x60, 0x36, 0x94, 0x86, 0x73, 0x2c, 0x1f, 0x60, 0x5a, 0xce, 0x9d, 0xfc, + 0x6a, 0x49, 0x35, 0x77, 0x39, 0x8a, 0x65, 0xb0, 0xb7, 0x8d, 0x7d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 12; + msg.payload_len = 23; - uint8_t bytesprops0[] = {0xc3, 0x28, 0x59, 0xaa, 0x5f, 0xe1, 0x6f, 0x47, 0xfb, 0xb2, 0xae}; - uint8_t bytesprops1[] = {0x26, 0x2b, 0x45, 0xb8, 0x98, 0x87, 0x50}; - uint8_t bytesprops2[] = {0xd1, 0xec, 0x57, 0xea, 0x56, 0x30, 0x19, 0x1d, 0x60, 0xa8, 0x5b, 0x0}; - uint8_t bytesprops3[] = {0xbe, 0x4a, 0x5d, 0xde, 0xc6, 0x74, 0x41, 0xfe, 0x59, 0x87, - 0x98, 0x44, 0xaf, 0x7f, 0xd6, 0xd9, 0x87, 0x68, 0xe1}; - uint8_t bytesprops4[] = {0x9, 0x7b, 0x6, 0xea, 0x3f, 0x2f, 0xf0, 0x5b, 0x1b, 0x8d, - 0x35, 0x62, 0xb5, 0xee, 0x74, 0xaa, 0x75, 0x9a, 0xb0}; - uint8_t bytesprops5[] = {0x1b, 0x1f, 0x52, 0xf1, 0x34, 0x86, 0x37, 0xa7, 0x1e, 0x57, 0x49, 0x4a, - 0x4d, 0x6c, 0x34, 0x29, 0x53, 0xcc, 0xe, 0x5f, 0x5c, 0x98, 0xad, 0xc0}; - uint8_t bytesprops6[] = {0x66, 0x17, 0xb1, 0x87, 0xed, 0x3, 0x15, 0x62, 0x36, - 0xa6, 0xa2, 0xa7, 0x2c, 0x4d, 0x6b, 0x65, 0xa5}; - uint8_t bytesprops7[] = {0xc, 0xed, 0x2d, 0x27, 0x91, 0x37, 0x23, 0x91, 0xb1, 0x94, 0x58}; - uint8_t bytesprops8[] = {0xb2, 0x2c, 0x6d, 0x7d, 0xfb, 0x49, 0xb9, 0xfa, 0x19, 0x3b, 0x7d, 0x64, 0x3e, - 0x54, 0x28, 0x70, 0xfd, 0xe2, 0x0, 0x38, 0x30, 0x8d, 0x42, 0xd, 0x36}; - uint8_t bytesprops9[] = {0x5d, 0xf0, 0x97, 0xa2, 0x33, 0xaf, 0x9a, 0xca, 0xdd, 0x1e, 0x3e, - 0x38, 0x1, 0xf7, 0x63, 0x20, 0xd1, 0xf0, 0x6a, 0xa2, 0xbf}; - uint8_t bytesprops10[] = {0x50, 0x51, 0x24, 0x9e, 0x6c, 0xfe, 0x11}; - uint8_t bytesprops11[] = {0x99, 0x8b, 0xf7, 0xa0, 0xb3, 0x86, 0x75, 0x79, 0x7a, 0x6b, 0xf3, - 0x69, 0x5f, 0x48, 0x37, 0xd, 0xff, 0x2, 0x67, 0xbd, 0x28, 0xb}; + uint8_t bytesprops0[] = {0x5, 0xcc, 0x1f, 0xd, 0x2, 0x5c, 0xbc, 0x71, 0x6a, 0x1, 0x45, 0xac, 0xc8, + 0xfa, 0xea, 0x6, 0x13, 0xe8, 0x32, 0xa6, 0xa0, 0xd3, 0xb5, 0xab, 0x6e}; + uint8_t bytesprops1[] = {0x56, 0xf3, 0x8d, 0x99, 0x13, 0xfb, 0xa, 0x86, 0x97, 0xd6, 0x6a, 0xb3, 0x14}; + uint8_t bytesprops2[] = {0xe3}; + uint8_t bytesprops3[] = {0x10, 0xe0, 0x6f, 0x4e, 0x63, 0x4b, 0xf5, 0x52, 0xa6, 0xcc, 0xe2, 0xa6, 0x98, + 0x65, 0x38, 0xf1, 0x94, 0xbb, 0x1d, 0xe2, 0x7, 0xb2, 0xd7, 0xa8, 0x34}; + uint8_t bytesprops4[] = {0x41, 0x9b, 0xd4, 0xa7, 0xec, 0xa9, 0x2a, 0xfd, 0x6b, 0x12, 0xd, 0x69, 0xf7, 0xf6}; + uint8_t bytesprops5[] = {0x2d, 0x6c, 0xea, 0x83}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22216}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1570}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13095}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30594}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26876}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2974}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6700}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29250}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31929}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31705}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25489}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3022}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11715}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13906}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27363}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29328}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24879}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29253}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30252}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6762}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20996}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4733}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 301, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 30138, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\SO\191\141\159\DC1$vw", _pubPktID = -// 301, _pubBody = "`\195\&7\ESC_\216\219\237?~,\244", _pubProps = [PropRequestProblemInformation -// 64,PropAuthenticationMethod "\195(Y\170_\225oG\251\178\174",PropSubscriptionIdentifier 23,PropAuthenticationMethod -// "&+E\184\152\135P",PropRequestResponseInformation 211,PropCorrelationData -// "\209\236W\234V0\EM\GS`\168[\NUL",PropSessionExpiryInterval 22216,PropPayloadFormatIndicator 110,PropTopicAlias -// 1570,PropContentType "\190J]\222\198tA\254Y\135\152D\175\DEL\214\217\135h\225",PropMessageExpiryInterval -// 13095,PropContentType "\t{\ACK\234?/\240[\ESC\141\&5b\181\238t\170u\154\176",PropContentType -// "\ESC\USR\241\&4\134\&7\167\RSWIJMl4)S\204\SO_\\\152\173\192",PropRequestProblemInformation 132,PropResponseTopic -// "f\ETB\177\135\237\ETX\NAKb6\166\162\167,Mke\165",PropResponseInformation -// "\f\237-'\145\&7#\145\177\148X",PropServerReference -// "\178,m}\251I\185\250\EM;}d>T(p\253\226\NUL80\141B\r6",PropReceiveMaximum 30594,PropTopicAlias -// 26876,PropWildcardSubscriptionAvailable 211,PropRequestResponseInformation 173,PropMaximumPacketSize -// 2974,PropReceiveMaximum 6700,PropRequestResponseInformation 193,PropTopicAlias 29250,PropAuthenticationData -// "]\240\151\162\&3\175\154\202\221\RS>8\SOH\247c \209\240j\162\191",PropServerReference -// "PQ$\158l\254\DC1",PropMessageExpiryInterval 31929,PropSessionExpiryInterval 31705,PropAssignedClientIdentifier -// "\153\139\247\160\179\134uyzk\243i_H7\r\255\STXg\189(\v"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\b\201MSc\140\128\CANs\162;\213\155\SO\151\139\229\SOH\229\197", _pubPktID = 30138, _pubBody = +// "`6\148\134s,\US`Z\206\157\252jI5w9\138e\176\183\141}", _pubProps = [PropPayloadFormatIndicator +// 239,PropMessageExpiryInterval 25489,PropPayloadFormatIndicator 87,PropCorrelationData +// "\ENQ\204\US\r\STX\\\188qj\SOHE\172\200\250\234\ACK\DC3\232\&2\166\160\211\181\171n",PropResponseTopic +// "V\243\141\153\DC3\251\n\134\151\214j\179\DC4",PropWillDelayInterval 3022,PropSubscriptionIdentifier +// 15,PropMessageExpiryInterval 11715,PropTopicAliasMaximum 13906,PropRetainAvailable 42,PropRetainAvailable +// 76,PropSessionExpiryInterval 27363,PropReceiveMaximum 29328,PropWillDelayInterval 24879,PropServerKeepAlive +// 29253,PropWillDelayInterval 30252,PropMessageExpiryInterval 6762,PropMaximumPacketSize 20996,PropAuthenticationMethod +// "\227",PropRequestResponseInformation 246,PropServerReference +// "\DLE\224oNcK\245R\166\204\226\166\152e8\241\148\187\GS\226\a\178\215\168\&4",PropTopicAlias 4733,PropContentType +// "A\155\212\167\236\169*\253k\DC2\ri\247\246",PropReasonString "-l\234\131"]} TEST(Publish5QCTest, Decode9) { - uint8_t pkt[] = { - 0x3b, 0xb9, 0x2, 0x0, 0x8, 0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77, 0x1, 0x2d, 0x9f, 0x2, 0x17, 0x40, - 0x15, 0x0, 0xb, 0xc3, 0x28, 0x59, 0xaa, 0x5f, 0xe1, 0x6f, 0x47, 0xfb, 0xb2, 0xae, 0xb, 0x17, 0x15, 0x0, 0x7, - 0x26, 0x2b, 0x45, 0xb8, 0x98, 0x87, 0x50, 0x19, 0xd3, 0x9, 0x0, 0xc, 0xd1, 0xec, 0x57, 0xea, 0x56, 0x30, 0x19, - 0x1d, 0x60, 0xa8, 0x5b, 0x0, 0x11, 0x0, 0x0, 0x56, 0xc8, 0x1, 0x6e, 0x23, 0x6, 0x22, 0x3, 0x0, 0x13, 0xbe, - 0x4a, 0x5d, 0xde, 0xc6, 0x74, 0x41, 0xfe, 0x59, 0x87, 0x98, 0x44, 0xaf, 0x7f, 0xd6, 0xd9, 0x87, 0x68, 0xe1, 0x2, - 0x0, 0x0, 0x33, 0x27, 0x3, 0x0, 0x13, 0x9, 0x7b, 0x6, 0xea, 0x3f, 0x2f, 0xf0, 0x5b, 0x1b, 0x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7d, 0x3, + 0x0, 0xe, 0x41, 0x9b, 0xd4, 0xa7, 0xec, 0xa9, 0x2a, 0xfd, 0x6b, 0x12, 0xd, 0x69, 0xf7, 0xf6, 0x1f, + 0x0, 0x4, 0x2d, 0x6c, 0xea, 0x83, 0x60, 0x36, 0x94, 0x86, 0x73, 0x2c, 0x1f, 0x60, 0x5a, 0xce, 0x9d, + 0xfc, 0x6a, 0x49, 0x35, 0x77, 0x39, 0x8a, 0x65, 0xb0, 0xb7, 0x8d, 0x7d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2884,94 +2760,136 @@ TEST(Publish5QCTest, Decode9) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe, 0xbf, 0x8d, 0x9f, 0x11, 0x24, 0x76, 0x77}; - lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x60, 0xc3, 0x37, 0x1b, 0x5f, 0xd8, 0xdb, 0xed, 0x3f, 0x7e, 0x2c, 0xf4}; - lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x8, 0xc9, 0x4d, 0x53, 0x63, 0x8c, 0x80, 0x18, 0x73, 0xa2, + 0x3b, 0xd5, 0x9b, 0xe, 0x97, 0x8b, 0xe5, 0x1, 0xe5, 0xc5}; + lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x60, 0x36, 0x94, 0x86, 0x73, 0x2c, 0x1f, 0x60, 0x5a, 0xce, 0x9d, 0xfc, + 0x6a, 0x49, 0x35, 0x77, 0x39, 0x8a, 0x65, 0xb0, 0xb7, 0x8d, 0x7d}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 301); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); - EXPECT_EQ(msg.payload_len, 12); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); + EXPECT_EQ(packet_id, 30138); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\227=\STX\236\214\&2\250\EM@M^\ENQ\161\aE8", _pubPktID = 19635, _pubBody = "\EOT\EM", _pubProps = [PropTopicAlias -// 28762,PropReceiveMaximum 4549,PropCorrelationData "\237o*OO%\201P\232^u[\158",PropAuthenticationData -// "\128\189\154\SO\180\SOH]sH\253s\165w\148\219\215\251\130f\NAK\131\152\208;",PropCorrelationData -// "\214\NAK\214MlRr\138\242\DC4\167e]`X;\ENQ\188A^\218+\DC4>6%\155\255\250O",PropReceiveMaximum -// 6189,PropSubscriptionIdentifier 13,PropMaximumPacketSize 31985,PropServerReference -// "\NUL\229\SOH\tJu\233\131NV\203\168\239\220\203\SOH\166E5\228\141\212\173\250X\DLE>?"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\177\SUB\139\129\ETB\208\148", +// _pubPktID = 30010, _pubBody = "`\USq\198\217\144\199Zp9", _pubProps = [PropPayloadFormatIndicator +// 223,PropServerKeepAlive 24882,PropAuthenticationMethod "[D\239\248j\152?\212.m47\188H\237!\130",PropMaximumQoS +// 41,PropRequestProblemInformation 197,PropUserProperty " \220\STX\DLEiJ+GG[\147\178\EOTy\238#C\222" +// ",Bu\223\&6\211\175\225\206!\158\132 \227\r\242\168]\195\129\DC1\167k\240",PropRequestProblemInformation +// 36,PropResponseInformation "\242\177\"\249\247Y\252\149K._/j\252\190=>\234\130\RSD\201",PropPayloadFormatIndicator +// 101,PropRetainAvailable 243,PropCorrelationData +// "\150m\tSN/\147H\165\224\137\v}\233\137\230",PropRequestResponseInformation 119,PropTopicAliasMaximum +// 25349,PropAuthenticationData "\218Z\183\155z\172M\SUB\195\170\142\133\247\148&l6X\192\155\253",PropServerKeepAlive +// 3471,PropMessageExpiryInterval 11388,PropCorrelationData +// "\GS\167\216\v\128\FS\SOHrz\159E\170\215\196\195X\CANq<;\201pd\SOH",PropSharedSubscriptionAvailable +// 35,PropSubscriptionIdentifierAvailable 68,PropSharedSubscriptionAvailable 181,PropRetainAvailable +// 173,PropSharedSubscriptionAvailable 104]} TEST(Publish5QCTest, Encode10) { - uint8_t pkt[] = {0x3b, 0x92, 0x1, 0x0, 0x10, 0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, 0x40, 0x4d, 0x5e, 0x5, - 0xa1, 0x7, 0x45, 0x38, 0x4c, 0xb3, 0x7b, 0x23, 0x70, 0x5a, 0x21, 0x11, 0xc5, 0x9, 0x0, 0xd, 0xed, - 0x6f, 0x2a, 0x4f, 0x4f, 0x25, 0xc9, 0x50, 0xe8, 0x5e, 0x75, 0x5b, 0x9e, 0x16, 0x0, 0x18, 0x80, 0xbd, - 0x9a, 0xe, 0xb4, 0x1, 0x5d, 0x73, 0x48, 0xfd, 0x73, 0xa5, 0x77, 0x94, 0xdb, 0xd7, 0xfb, 0x82, 0x66, - 0x15, 0x83, 0x98, 0xd0, 0x3b, 0x9, 0x0, 0x1e, 0xd6, 0x15, 0xd6, 0x4d, 0x6c, 0x52, 0x72, 0x8a, 0xf2, - 0x14, 0xa7, 0x65, 0x5d, 0x60, 0x58, 0x3b, 0x5, 0xbc, 0x41, 0x5e, 0xda, 0x2b, 0x14, 0x3e, 0x36, 0x25, - 0x9b, 0xff, 0xfa, 0x4f, 0x21, 0x18, 0x2d, 0xb, 0xd, 0x27, 0x0, 0x0, 0x7c, 0xf1, 0x1c, 0x0, 0x1c, - 0x0, 0xe5, 0x1, 0x9, 0x4a, 0x75, 0xe9, 0x83, 0x4e, 0x56, 0xcb, 0xa8, 0xef, 0xdc, 0xcb, 0x1, 0xa6, - 0x45, 0x35, 0xe4, 0x8d, 0xd4, 0xad, 0xfa, 0x58, 0x10, 0x3e, 0x3f, 0x4, 0x19}; - uint8_t topic_bytes[] = {0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38}; - lwmqtt_string_t topic = {16, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x32, 0xdf, 0x1, 0x0, 0x7, 0xb1, 0x1a, 0x8b, 0x81, 0x17, 0xd0, 0x94, 0x75, 0x3a, 0xc8, 0x1, 0x1, 0xdf, 0x13, + 0x61, 0x32, 0x15, 0x0, 0x11, 0x5b, 0x44, 0xef, 0xf8, 0x6a, 0x98, 0x3f, 0xd4, 0x2e, 0x6d, 0x34, 0x37, 0xbc, 0x48, + 0xed, 0x21, 0x82, 0x24, 0x29, 0x17, 0xc5, 0x26, 0x0, 0x12, 0x20, 0xdc, 0x2, 0x10, 0x69, 0x4a, 0x2b, 0x47, 0x47, + 0x5b, 0x93, 0xb2, 0x4, 0x79, 0xee, 0x23, 0x43, 0xde, 0x0, 0x18, 0x2c, 0x42, 0x75, 0xdf, 0x36, 0xd3, 0xaf, 0xe1, + 0xce, 0x21, 0x9e, 0x84, 0x20, 0xe3, 0xd, 0xf2, 0xa8, 0x5d, 0xc3, 0x81, 0x11, 0xa7, 0x6b, 0xf0, 0x17, 0x24, 0x1a, + 0x0, 0x16, 0xf2, 0xb1, 0x22, 0xf9, 0xf7, 0x59, 0xfc, 0x95, 0x4b, 0x2e, 0x5f, 0x2f, 0x6a, 0xfc, 0xbe, 0x3d, 0x3e, + 0xea, 0x82, 0x1e, 0x44, 0xc9, 0x1, 0x65, 0x25, 0xf3, 0x9, 0x0, 0x10, 0x96, 0x6d, 0x9, 0x53, 0x4e, 0x2f, 0x93, + 0x48, 0xa5, 0xe0, 0x89, 0xb, 0x7d, 0xe9, 0x89, 0xe6, 0x19, 0x77, 0x22, 0x63, 0x5, 0x16, 0x0, 0x15, 0xda, 0x5a, + 0xb7, 0x9b, 0x7a, 0xac, 0x4d, 0x1a, 0xc3, 0xaa, 0x8e, 0x85, 0xf7, 0x94, 0x26, 0x6c, 0x36, 0x58, 0xc0, 0x9b, 0xfd, + 0x13, 0xd, 0x8f, 0x2, 0x0, 0x0, 0x2c, 0x7c, 0x9, 0x0, 0x18, 0x1d, 0xa7, 0xd8, 0xb, 0x80, 0x1c, 0x1, 0x72, + 0x7a, 0x9f, 0x45, 0xaa, 0xd7, 0xc4, 0xc3, 0x58, 0x18, 0x71, 0x3c, 0x3b, 0xc9, 0x70, 0x64, 0x1, 0x2a, 0x23, 0x29, + 0x44, 0x2a, 0xb5, 0x25, 0xad, 0x2a, 0x68, 0x60, 0x1f, 0x71, 0xc6, 0xd9, 0x90, 0xc7, 0x5a, 0x70, 0x39}; + uint8_t topic_bytes[] = {0xb1, 0x1a, 0x8b, 0x81, 0x17, 0xd0, 0x94}; + lwmqtt_string_t topic = {7, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x4, 0x19}; + msg.retained = false; + uint8_t msg_bytes[] = {0x60, 0x1f, 0x71, 0xc6, 0xd9, 0x90, 0xc7, 0x5a, 0x70, 0x39}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 2; + msg.payload_len = 10; - uint8_t bytesprops0[] = {0xed, 0x6f, 0x2a, 0x4f, 0x4f, 0x25, 0xc9, 0x50, 0xe8, 0x5e, 0x75, 0x5b, 0x9e}; - uint8_t bytesprops1[] = {0x80, 0xbd, 0x9a, 0xe, 0xb4, 0x1, 0x5d, 0x73, 0x48, 0xfd, 0x73, 0xa5, - 0x77, 0x94, 0xdb, 0xd7, 0xfb, 0x82, 0x66, 0x15, 0x83, 0x98, 0xd0, 0x3b}; - uint8_t bytesprops2[] = {0xd6, 0x15, 0xd6, 0x4d, 0x6c, 0x52, 0x72, 0x8a, 0xf2, 0x14, 0xa7, 0x65, 0x5d, 0x60, 0x58, - 0x3b, 0x5, 0xbc, 0x41, 0x5e, 0xda, 0x2b, 0x14, 0x3e, 0x36, 0x25, 0x9b, 0xff, 0xfa, 0x4f}; - uint8_t bytesprops3[] = {0x0, 0xe5, 0x1, 0x9, 0x4a, 0x75, 0xe9, 0x83, 0x4e, 0x56, 0xcb, 0xa8, 0xef, 0xdc, - 0xcb, 0x1, 0xa6, 0x45, 0x35, 0xe4, 0x8d, 0xd4, 0xad, 0xfa, 0x58, 0x10, 0x3e, 0x3f}; + uint8_t bytesprops0[] = {0x5b, 0x44, 0xef, 0xf8, 0x6a, 0x98, 0x3f, 0xd4, 0x2e, + 0x6d, 0x34, 0x37, 0xbc, 0x48, 0xed, 0x21, 0x82}; + uint8_t bytesprops2[] = {0x2c, 0x42, 0x75, 0xdf, 0x36, 0xd3, 0xaf, 0xe1, 0xce, 0x21, 0x9e, 0x84, + 0x20, 0xe3, 0xd, 0xf2, 0xa8, 0x5d, 0xc3, 0x81, 0x11, 0xa7, 0x6b, 0xf0}; + uint8_t bytesprops1[] = {0x20, 0xdc, 0x2, 0x10, 0x69, 0x4a, 0x2b, 0x47, 0x47, + 0x5b, 0x93, 0xb2, 0x4, 0x79, 0xee, 0x23, 0x43, 0xde}; + uint8_t bytesprops3[] = {0xf2, 0xb1, 0x22, 0xf9, 0xf7, 0x59, 0xfc, 0x95, 0x4b, 0x2e, 0x5f, + 0x2f, 0x6a, 0xfc, 0xbe, 0x3d, 0x3e, 0xea, 0x82, 0x1e, 0x44, 0xc9}; + uint8_t bytesprops4[] = {0x96, 0x6d, 0x9, 0x53, 0x4e, 0x2f, 0x93, 0x48, + 0xa5, 0xe0, 0x89, 0xb, 0x7d, 0xe9, 0x89, 0xe6}; + uint8_t bytesprops5[] = {0xda, 0x5a, 0xb7, 0x9b, 0x7a, 0xac, 0x4d, 0x1a, 0xc3, 0xaa, 0x8e, + 0x85, 0xf7, 0x94, 0x26, 0x6c, 0x36, 0x58, 0xc0, 0x9b, 0xfd}; + uint8_t bytesprops6[] = {0x1d, 0xa7, 0xd8, 0xb, 0x80, 0x1c, 0x1, 0x72, 0x7a, 0x9f, 0x45, 0xaa, + 0xd7, 0xc4, 0xc3, 0x58, 0x18, 0x71, 0x3c, 0x3b, 0xc9, 0x70, 0x64, 0x1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28762}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4549}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6189}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31985}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24882}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops1}, .v = {24, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 101}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25349}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3471}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11388}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 104}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 19635, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 30010, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\227=\STX\236\214\&2\250\EM@M^\ENQ\161\aE8", _pubPktID = 19635, _pubBody = "\EOT\EM", _pubProps = [PropTopicAlias -// 28762,PropReceiveMaximum 4549,PropCorrelationData "\237o*OO%\201P\232^u[\158",PropAuthenticationData -// "\128\189\154\SO\180\SOH]sH\253s\165w\148\219\215\251\130f\NAK\131\152\208;",PropCorrelationData -// "\214\NAK\214MlRr\138\242\DC4\167e]`X;\ENQ\188A^\218+\DC4>6%\155\255\250O",PropReceiveMaximum -// 6189,PropSubscriptionIdentifier 13,PropMaximumPacketSize 31985,PropServerReference -// "\NUL\229\SOH\tJu\233\131NV\203\168\239\220\203\SOH\166E5\228\141\212\173\250X\DLE>?"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\177\SUB\139\129\ETB\208\148", +// _pubPktID = 30010, _pubBody = "`\USq\198\217\144\199Zp9", _pubProps = [PropPayloadFormatIndicator +// 223,PropServerKeepAlive 24882,PropAuthenticationMethod "[D\239\248j\152?\212.m47\188H\237!\130",PropMaximumQoS +// 41,PropRequestProblemInformation 197,PropUserProperty " \220\STX\DLEiJ+GG[\147\178\EOTy\238#C\222" +// ",Bu\223\&6\211\175\225\206!\158\132 \227\r\242\168]\195\129\DC1\167k\240",PropRequestProblemInformation +// 36,PropResponseInformation "\242\177\"\249\247Y\252\149K._/j\252\190=>\234\130\RSD\201",PropPayloadFormatIndicator +// 101,PropRetainAvailable 243,PropCorrelationData +// "\150m\tSN/\147H\165\224\137\v}\233\137\230",PropRequestResponseInformation 119,PropTopicAliasMaximum +// 25349,PropAuthenticationData "\218Z\183\155z\172M\SUB\195\170\142\133\247\148&l6X\192\155\253",PropServerKeepAlive +// 3471,PropMessageExpiryInterval 11388,PropCorrelationData +// "\GS\167\216\v\128\FS\SOHrz\159E\170\215\196\195X\CANq<;\201pd\SOH",PropSharedSubscriptionAvailable +// 35,PropSubscriptionIdentifierAvailable 68,PropSharedSubscriptionAvailable 181,PropRetainAvailable +// 173,PropSharedSubscriptionAvailable 104]} TEST(Publish5QCTest, Decode10) { - uint8_t pkt[] = {0x3b, 0x92, 0x1, 0x0, 0x10, 0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, 0x40, 0x4d, 0x5e, 0x5, - 0xa1, 0x7, 0x45, 0x38, 0x4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x47, + 0x5b, 0x93, 0xb2, 0x4, 0x79, 0xee, 0x23, 0x43, 0xde, 0x0, 0x18, 0x2c, 0x42, 0x75, 0xdf, 0x36, 0xd3, 0xaf, 0xe1, + 0xce, 0x21, 0x9e, 0x84, 0x20, 0xe3, 0xd, 0xf2, 0xa8, 0x5d, 0xc3, 0x81, 0x11, 0xa7, 0x6b, 0xf0, 0x17, 0x24, 0x1a, + 0x0, 0x16, 0xf2, 0xb1, 0x22, 0xf9, 0xf7, 0x59, 0xfc, 0x95, 0x4b, 0x2e, 0x5f, 0x2f, 0x6a, 0xfc, 0xbe, 0x3d, 0x3e, + 0xea, 0x82, 0x1e, 0x44, 0xc9, 0x1, 0x65, 0x25, 0xf3, 0x9, 0x0, 0x10, 0x96, 0x6d, 0x9, 0x53, 0x4e, 0x2f, 0x93, + 0x48, 0xa5, 0xe0, 0x89, 0xb, 0x7d, 0xe9, 0x89, 0xe6, 0x19, 0x77, 0x22, 0x63, 0x5, 0x16, 0x0, 0x15, 0xda, 0x5a, + 0xb7, 0x9b, 0x7a, 0xac, 0x4d, 0x1a, 0xc3, 0xaa, 0x8e, 0x85, 0xf7, 0x94, 0x26, 0x6c, 0x36, 0x58, 0xc0, 0x9b, 0xfd, + 0x13, 0xd, 0x8f, 0x2, 0x0, 0x0, 0x2c, 0x7c, 0x9, 0x0, 0x18, 0x1d, 0xa7, 0xd8, 0xb, 0x80, 0x1c, 0x1, 0x72, + 0x7a, 0x9f, 0x45, 0xaa, 0xd7, 0xc4, 0xc3, 0x58, 0x18, 0x71, 0x3c, 0x3b, 0xc9, 0x70, 0x64, 0x1, 0x2a, 0x23, 0x29, + 0x44, 0x2a, 0xb5, 0x25, 0xad, 0x2a, 0x68, 0x60, 0x1f, 0x71, 0xc6, 0xd9, 0x90, 0xc7, 0x5a, 0x70, 0x39}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -2980,123 +2898,90 @@ TEST(Publish5QCTest, Decode10) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xe3, 0x3d, 0x2, 0xec, 0xd6, 0x32, 0xfa, 0x19, - 0x40, 0x4d, 0x5e, 0x5, 0xa1, 0x7, 0x45, 0x38}; - lwmqtt_string_t exp_topic = {16, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x4, 0x19}; - lwmqtt_string_t exp_body = {2, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); + uint8_t exp_topic_bytes[] = {0xb1, 0x1a, 0x8b, 0x81, 0x17, 0xd0, 0x94}; + lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x60, 0x1f, 0x71, 0xc6, 0xd9, 0x90, 0xc7, 0x5a, 0x70, 0x39}; + lwmqtt_string_t exp_body = {10, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 19635); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 16); - EXPECT_EQ(msg.payload_len, 2); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 30010); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(msg.payload_len, 10); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\207FX\fp\139\210\201Q\185\161i$\222\214\221\238\n.\134\157L7\178\&1", _pubPktID = 10816, _pubBody = -// "b[\173.*\158(\194-\180ZS\221\236\188\168\182\172p\192\216\246\196\176\200\248\&1\232a", _pubProps = -// [PropReceiveMaximum 25251,PropResponseInformation -// "X\221\143\223\163\136V\DC1\175\145\155\US\\\DC3\ESC\159l\DC2/\a\143v\163\227\n\235",PropMaximumQoS -// 199,PropAssignedClientIdentifier "\ETBk\211",PropMessageExpiryInterval 1041,PropTopicAliasMaximum -// 2064,PropMessageExpiryInterval 14828,PropReasonString -// "x\DLE\ESC\244\138\235\246\137\235:\255\177",PropAuthenticationData -// "\162\233\a\215\148\245\255\148NIrB",PropUserProperty "\225}q\142\171-Z^Bt}\179r\241\SO\ETX2e\ACK0\249" -// "L\160/\NULi\177E%o\191x>",PropMaximumQoS 99,PropSessionExpiryInterval 8860,PropWildcardSubscriptionAvailable -// 211,PropReasonString "\189\253\207\129\167\209VT\SOH}[\t\220\CANAB\146\168",PropAuthenticationMethod ""]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\203", _pubPktID = 182, _pubBody = +// "\145y\231n\252\238pw\ACK\168Lc~\152\153\129W\\\SIK\134\251\185\SOH\208\EMV\"", _pubProps = [PropUserProperty +// "\210\235\181U\238" "\SI\247\164\241\170/\204\161\229",PropResponseInformation +// "}\vGt\204k9\SOH\250>5h\224",PropReasonString "c:\DC1\138\241\188}\NULqN\146'\164v- \NUL",PropSessionExpiryInterval +// 16818,PropAssignedClientIdentifier "6\152]8\141\a<9@\248\174i>\143\245.\EM",PropWildcardSubscriptionAvailable +// 80,PropSharedSubscriptionAvailable 24,PropSharedSubscriptionAvailable 240]} TEST(Publish5QCTest, Encode11) { - uint8_t pkt[] = {0x34, 0xd6, 0x1, 0x0, 0x19, 0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, 0x69, - 0x24, 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31, 0x2a, 0x40, 0x9a, 0x1, - 0x21, 0x62, 0xa3, 0x1a, 0x0, 0x1a, 0x58, 0xdd, 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, 0x51, 0xb9, 0xa1, 0x69, 0x24, - 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31}; - lwmqtt_string_t topic = {25, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x78, 0x0, 0x1, 0xcb, 0x0, 0xb6, 0x56, 0x26, 0x0, 0x5, 0xd2, 0xeb, 0xb5, 0x55, 0xee, + 0x0, 0x9, 0xf, 0xf7, 0xa4, 0xf1, 0xaa, 0x2f, 0xcc, 0xa1, 0xe5, 0x1a, 0x0, 0xd, 0x7d, 0xb, + 0x47, 0x74, 0xcc, 0x6b, 0x39, 0x1, 0xfa, 0x3e, 0x35, 0x68, 0xe0, 0x1f, 0x0, 0x11, 0x63, 0x3a, + 0x11, 0x8a, 0xf1, 0xbc, 0x7d, 0x0, 0x71, 0x4e, 0x92, 0x27, 0xa4, 0x76, 0x2d, 0x20, 0x0, 0x11, + 0x0, 0x0, 0x41, 0xb2, 0x12, 0x0, 0x11, 0x36, 0x98, 0x5d, 0x38, 0x8d, 0x7, 0x3c, 0x39, 0x40, + 0xf8, 0xae, 0x69, 0x3e, 0x8f, 0xf5, 0x2e, 0x19, 0x28, 0x50, 0x2a, 0x18, 0x2a, 0xf0, 0x91, 0x79, + 0xe7, 0x6e, 0xfc, 0xee, 0x70, 0x77, 0x6, 0xa8, 0x4c, 0x63, 0x7e, 0x98, 0x99, 0x81, 0x57, 0x5c, + 0xf, 0x4b, 0x86, 0xfb, 0xb9, 0x1, 0xd0, 0x19, 0x56, 0x22}; + uint8_t topic_bytes[] = {0xcb}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, 0xbc, - 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0x91, 0x79, 0xe7, 0x6e, 0xfc, 0xee, 0x70, 0x77, 0x6, 0xa8, 0x4c, 0x63, 0x7e, 0x98, + 0x99, 0x81, 0x57, 0x5c, 0xf, 0x4b, 0x86, 0xfb, 0xb9, 0x1, 0xd0, 0x19, 0x56, 0x22}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 28; - uint8_t bytesprops0[] = {0x58, 0xdd, 0x8f, 0xdf, 0xa3, 0x88, 0x56, 0x11, 0xaf, 0x91, 0x9b, 0x1f, 0x5c, - 0x13, 0x1b, 0x9f, 0x6c, 0x12, 0x2f, 0x7, 0x8f, 0x76, 0xa3, 0xe3, 0xa, 0xeb}; - uint8_t bytesprops1[] = {0x17, 0x6b, 0xd3}; - uint8_t bytesprops2[] = {0x78, 0x10, 0x1b, 0xf4, 0x8a, 0xeb, 0xf6, 0x89, 0xeb, 0x3a, 0xff, 0xb1}; - uint8_t bytesprops3[] = {0xa2, 0xe9, 0x7, 0xd7, 0x94, 0xf5, 0xff, 0x94, 0x4e, 0x49, 0x72, 0x42}; - uint8_t bytesprops5[] = {0x4c, 0xa0, 0x2f, 0x0, 0x69, 0xb1, 0x45, 0x25, 0x6f, 0xbf, 0x78, 0x3e}; - uint8_t bytesprops4[] = {0xe1, 0x7d, 0x71, 0x8e, 0xab, 0x2d, 0x5a, 0x5e, 0x42, 0x74, 0x7d, - 0xb3, 0x72, 0xf1, 0xe, 0x3, 0x32, 0x65, 0x6, 0x30, 0xf9}; - uint8_t bytesprops6[] = {0xbd, 0xfd, 0xcf, 0x81, 0xa7, 0xd1, 0x56, 0x54, 0x1, - 0x7d, 0x5b, 0x9, 0xdc, 0x18, 0x41, 0x42, 0x92, 0xa8}; - uint8_t bytesprops7[] = {0}; + uint8_t bytesprops1[] = {0xf, 0xf7, 0xa4, 0xf1, 0xaa, 0x2f, 0xcc, 0xa1, 0xe5}; + uint8_t bytesprops0[] = {0xd2, 0xeb, 0xb5, 0x55, 0xee}; + uint8_t bytesprops2[] = {0x7d, 0xb, 0x47, 0x74, 0xcc, 0x6b, 0x39, 0x1, 0xfa, 0x3e, 0x35, 0x68, 0xe0}; + uint8_t bytesprops3[] = {0x63, 0x3a, 0x11, 0x8a, 0xf1, 0xbc, 0x7d, 0x0, 0x71, + 0x4e, 0x92, 0x27, 0xa4, 0x76, 0x2d, 0x20, 0x0}; + uint8_t bytesprops4[] = {0x36, 0x98, 0x5d, 0x38, 0x8d, 0x7, 0x3c, 0x39, 0x40, + 0xf8, 0xae, 0x69, 0x3e, 0x8f, 0xf5, 0x2e, 0x19}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25251}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1041}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2064}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14828}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops4}, .v = {12, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8860}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops0}, .v = {9, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16818}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 80}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 240}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 10816, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 182, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "\207FX\fp\139\210\201Q\185\161i$\222\214\221\238\n.\134\157L7\178\&1", _pubPktID = 10816, _pubBody = -// "b[\173.*\158(\194-\180ZS\221\236\188\168\182\172p\192\216\246\196\176\200\248\&1\232a", _pubProps = -// [PropReceiveMaximum 25251,PropResponseInformation -// "X\221\143\223\163\136V\DC1\175\145\155\US\\\DC3\ESC\159l\DC2/\a\143v\163\227\n\235",PropMaximumQoS -// 199,PropAssignedClientIdentifier "\ETBk\211",PropMessageExpiryInterval 1041,PropTopicAliasMaximum -// 2064,PropMessageExpiryInterval 14828,PropReasonString -// "x\DLE\ESC\244\138\235\246\137\235:\255\177",PropAuthenticationData -// "\162\233\a\215\148\245\255\148NIrB",PropUserProperty "\225}q\142\171-Z^Bt}\179r\241\SO\ETX2e\ACK0\249" -// "L\160/\NULi\177E%o\191x>",PropMaximumQoS 99,PropSessionExpiryInterval 8860,PropWildcardSubscriptionAvailable -// 211,PropReasonString "\189\253\207\129\167\209VT\SOH}[\t\220\CANAB\146\168",PropAuthenticationMethod ""]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\203", _pubPktID = 182, _pubBody = +// "\145y\231n\252\238pw\ACK\168Lc~\152\153\129W\\\SIK\134\251\185\SOH\208\EMV\"", _pubProps = [PropUserProperty +// "\210\235\181U\238" "\SI\247\164\241\170/\204\161\229",PropResponseInformation +// "}\vGt\204k9\SOH\250>5h\224",PropReasonString "c:\DC1\138\241\188}\NULqN\146'\164v- \NUL",PropSessionExpiryInterval +// 16818,PropAssignedClientIdentifier "6\152]8\141\a<9@\248\174i>\143\245.\EM",PropWildcardSubscriptionAvailable +// 80,PropSharedSubscriptionAvailable 24,PropSharedSubscriptionAvailable 240]} TEST(Publish5QCTest, Decode11) { - uint8_t pkt[] = {0x34, 0xd6, 0x1, 0x0, 0x19, 0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, 0x69, - 0x24, 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31, 0x2a, 0x40, 0x9a, 0x1, - 0x21, 0x62, 0xa3, 0x1a, 0x0, 0x1a, 0x58, 0xdd, 0x8f, 0xdf, 0xa3, 0x88, 0x56, 0x11, 0xaf, 0x91, 0x9b, - 0x1f, 0x5c, 0x13, 0x1b, 0x9f, 0x6c, 0x12, 0x2f, 0x7, 0x8f, 0x76, 0xa3, 0xe3, 0xa, 0xeb, 0x24, 0xc7, - 0x12, 0x0, 0x3, 0x17, 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a, 0x3e, 0x35, 0x68, 0xe0, 0x1f, 0x0, 0x11, 0x63, 0x3a, + 0x11, 0x8a, 0xf1, 0xbc, 0x7d, 0x0, 0x71, 0x4e, 0x92, 0x27, 0xa4, 0x76, 0x2d, 0x20, 0x0, 0x11, + 0x0, 0x0, 0x41, 0xb2, 0x12, 0x0, 0x11, 0x36, 0x98, 0x5d, 0x38, 0x8d, 0x7, 0x3c, 0x39, 0x40, + 0xf8, 0xae, 0x69, 0x3e, 0x8f, 0xf5, 0x2e, 0x19, 0x28, 0x50, 0x2a, 0x18, 0x2a, 0xf0, 0x91, 0x79, + 0xe7, 0x6e, 0xfc, 0xee, 0x70, 0x77, 0x6, 0xa8, 0x4c, 0x63, 0x7e, 0x98, 0x99, 0x81, 0x57, 0x5c, + 0xf, 0x4b, 0x86, 0xfb, 0xb9, 0x1, 0xd0, 0x19, 0x56, 0x22}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3105,73 +2990,138 @@ TEST(Publish5QCTest, Decode11) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xcf, 0x46, 0x58, 0xc, 0x70, 0x8b, 0xd2, 0xc9, 0x51, 0xb9, 0xa1, 0x69, 0x24, - 0xde, 0xd6, 0xdd, 0xee, 0xa, 0x2e, 0x86, 0x9d, 0x4c, 0x37, 0xb2, 0x31}; - lwmqtt_string_t exp_topic = {25, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x62, 0x5b, 0xad, 0x2e, 0x2a, 0x9e, 0x28, 0xc2, 0x2d, 0xb4, 0x5a, 0x53, 0xdd, 0xec, 0xbc, - 0xa8, 0xb6, 0xac, 0x70, 0xc0, 0xd8, 0xf6, 0xc4, 0xb0, 0xc8, 0xf8, 0x31, 0xe8, 0x61}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 10816); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 25); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + uint8_t exp_topic_bytes[] = {0xcb}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x91, 0x79, 0xe7, 0x6e, 0xfc, 0xee, 0x70, 0x77, 0x6, 0xa8, 0x4c, 0x63, 0x7e, 0x98, + 0x99, 0x81, 0x57, 0x5c, 0xf, 0x4b, 0x86, 0xfb, 0xb9, 0x1, 0xd0, 0x19, 0x56, 0x22}; + lwmqtt_string_t exp_body = {28, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 182); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 28); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = -// "C:\210I?H\140\153\163\FS\190\141PA\209Z6\210G=S\217\242\219S\237\226\a", _pubPktID = 780, _pubBody = -// "\185b.\FS\147|\157\223\176\240\ENQy\185\208\DC4\186(topic.data), 28); - EXPECT_EQ(msg.payload_len, 28); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 28); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 10741); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 3); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "x\170\228C2\140C\ACKD\FS/[\214\EOT\SOH", _pubPktID = 0, _pubBody = "\185", _pubProps = [PropTopicAliasMaximum -// 21735,PropMaximumPacketSize 23247,PropResponseTopic "\253\195\224\216d\206\EOT\167?\163CZ\163",PropServerKeepAlive -// 1098,PropMessageExpiryInterval 15291,PropWildcardSubscriptionAvailable 116,PropTopicAlias -// 13184,PropSubscriptionIdentifier 23,PropTopicAliasMaximum 22231,PropRetainAvailable 205,PropUserProperty -// "\164\227\165\164\178\EOT.\134X\216\ENQ^\198\&8\206\133\249\131\t]=\208\177\174" "c",PropMaximumPacketSize -// 1168,PropReceiveMaximum 18513]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\180^\180\196\166\GS\142\ETB\np\US\226\226j-\130\242+\138\234A", _pubPktID = 0, _pubBody = +// "\STXN8tdLv\171\220\&3tu\225\159\165V\148\183&W6\202\202\165r\SOH", _pubProps = [PropUserProperty +// "C\242\178\130f\163{W\US'\201m\140\230\EM\162\196" +// "\250\v\ESC\n\NAKw\135b2\164\243\&66n\"\nFF8\207\&1e\136\208s",PropTopicAlias 29241,PropReasonString +// "\203\243?\215\209\n\FS\225\ETBE\131z\252%7x\170\187\SOH\230\DC4\205\153\&6\140",PropContentType +// "\198\209i\134\198\251\EM~\155w\ENQ\255\148",PropAuthenticationMethod "n\148\231p\NAK\222<",PropRetainAvailable +// 172,PropPayloadFormatIndicator 179,PropReasonString +// "H3'\190\ESC#\237w'4!\v\139\210\189\224Zc\175U",PropSubscriptionIdentifier 16,PropReasonString +// "\183\&2iwD\212\148x\255\200(\209\&1\250?",PropRequestProblemInformation 206,PropReasonString +// "vFH\237\135\189D\242(^\201\159\EOT\EOT\148",PropWildcardSubscriptionAvailable 38,PropMessageExpiryInterval +// 17391,PropWildcardSubscriptionAvailable 86]} TEST(Publish5QCTest, Encode13) { - uint8_t pkt[] = {0x31, 0x65, 0x0, 0xf, 0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, - 0x5b, 0xd6, 0x4, 0x1, 0x52, 0x22, 0x54, 0xe7, 0x27, 0x0, 0x0, 0x5a, 0xcf, 0x8, 0x0, - 0xd, 0xfd, 0xc3, 0xe0, 0xd8, 0x64, 0xce, 0x4, 0xa7, 0x3f, 0xa3, 0x43, 0x5a, 0xa3, 0x13, - 0x4, 0x4a, 0x2, 0x0, 0x0, 0x3b, 0xbb, 0x28, 0x74, 0x23, 0x33, 0x80, 0xb, 0x17, 0x22, - 0x56, 0xd7, 0x25, 0xcd, 0x26, 0x0, 0x18, 0xa4, 0xe3, 0xa5, 0xa4, 0xb2, 0x4, 0x2e, 0x86, - 0x58, 0xd8, 0x5, 0x5e, 0xc6, 0x38, 0xce, 0x85, 0xf9, 0x83, 0x9, 0x5d, 0x3d, 0xd0, 0xb1, - 0xae, 0x0, 0x1, 0x63, 0x27, 0x0, 0x0, 0x4, 0x90, 0x21, 0x48, 0x51, 0xb9}; - uint8_t topic_bytes[] = {0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0xe7, 0x1, 0x0, 0x15, 0xb4, 0x5e, 0xb4, 0xc4, 0xa6, 0x1d, 0x8e, 0x17, 0xa, 0x70, 0x1f, 0xe2, + 0xe2, 0x6a, 0x2d, 0x82, 0xf2, 0x2b, 0x8a, 0xea, 0x41, 0xb4, 0x1, 0x26, 0x0, 0x11, 0x43, 0xf2, 0xb2, + 0x82, 0x66, 0xa3, 0x7b, 0x57, 0x1f, 0x27, 0xc9, 0x6d, 0x8c, 0xe6, 0x19, 0xa2, 0xc4, 0x0, 0x19, 0xfa, + 0xb, 0x1b, 0xa, 0x15, 0x77, 0x87, 0x62, 0x32, 0xa4, 0xf3, 0x36, 0x36, 0x6e, 0x22, 0xa, 0x46, 0x46, + 0x38, 0xcf, 0x31, 0x65, 0x88, 0xd0, 0x73, 0x23, 0x72, 0x39, 0x1f, 0x0, 0x19, 0xcb, 0xf3, 0x3f, 0xd7, + 0xd1, 0xa, 0x1c, 0xe1, 0x17, 0x45, 0x83, 0x7a, 0xfc, 0x25, 0x37, 0x78, 0xaa, 0xbb, 0x1, 0xe6, 0x14, + 0xcd, 0x99, 0x36, 0x8c, 0x3, 0x0, 0xd, 0xc6, 0xd1, 0x69, 0x86, 0xc6, 0xfb, 0x19, 0x7e, 0x9b, 0x77, + 0x5, 0xff, 0x94, 0x15, 0x0, 0x7, 0x6e, 0x94, 0xe7, 0x70, 0x15, 0xde, 0x3c, 0x25, 0xac, 0x1, 0xb3, + 0x1f, 0x0, 0x14, 0x48, 0x33, 0x27, 0xbe, 0x1b, 0x23, 0xed, 0x77, 0x27, 0x34, 0x21, 0xb, 0x8b, 0xd2, + 0xbd, 0xe0, 0x5a, 0x63, 0xaf, 0x55, 0xb, 0x10, 0x1f, 0x0, 0xf, 0xb7, 0x32, 0x69, 0x77, 0x44, 0xd4, + 0x94, 0x78, 0xff, 0xc8, 0x28, 0xd1, 0x31, 0xfa, 0x3f, 0x17, 0xce, 0x1f, 0x0, 0xf, 0x76, 0x46, 0x48, + 0xed, 0x87, 0xbd, 0x44, 0xf2, 0x28, 0x5e, 0xc9, 0x9f, 0x4, 0x4, 0x94, 0x28, 0x26, 0x2, 0x0, 0x0, + 0x43, 0xef, 0x28, 0x56, 0x2, 0x4e, 0x38, 0x74, 0x64, 0x4c, 0x76, 0xab, 0xdc, 0x33, 0x74, 0x75, 0xe1, + 0x9f, 0xa5, 0x56, 0x94, 0xb7, 0x26, 0x57, 0x36, 0xca, 0xca, 0xa5, 0x72, 0x1}; + uint8_t topic_bytes[] = {0xb4, 0x5e, 0xb4, 0xc4, 0xa6, 0x1d, 0x8e, 0x17, 0xa, 0x70, 0x1f, + 0xe2, 0xe2, 0x6a, 0x2d, 0x82, 0xf2, 0x2b, 0x8a, 0xea, 0x41}; + lwmqtt_string_t topic = {21, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xb9}; + msg.retained = false; + uint8_t msg_bytes[] = {0x2, 0x4e, 0x38, 0x74, 0x64, 0x4c, 0x76, 0xab, 0xdc, 0x33, 0x74, 0x75, 0xe1, + 0x9f, 0xa5, 0x56, 0x94, 0xb7, 0x26, 0x57, 0x36, 0xca, 0xca, 0xa5, 0x72, 0x1}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 1; - - uint8_t bytesprops0[] = {0xfd, 0xc3, 0xe0, 0xd8, 0x64, 0xce, 0x4, 0xa7, 0x3f, 0xa3, 0x43, 0x5a, 0xa3}; - uint8_t bytesprops2[] = {0x63}; - uint8_t bytesprops1[] = {0xa4, 0xe3, 0xa5, 0xa4, 0xb2, 0x4, 0x2e, 0x86, 0x58, 0xd8, 0x5, 0x5e, - 0xc6, 0x38, 0xce, 0x85, 0xf9, 0x83, 0x9, 0x5d, 0x3d, 0xd0, 0xb1, 0xae}; + msg.payload_len = 26; + + uint8_t bytesprops1[] = {0xfa, 0xb, 0x1b, 0xa, 0x15, 0x77, 0x87, 0x62, 0x32, 0xa4, 0xf3, 0x36, 0x36, + 0x6e, 0x22, 0xa, 0x46, 0x46, 0x38, 0xcf, 0x31, 0x65, 0x88, 0xd0, 0x73}; + uint8_t bytesprops0[] = {0x43, 0xf2, 0xb2, 0x82, 0x66, 0xa3, 0x7b, 0x57, 0x1f, + 0x27, 0xc9, 0x6d, 0x8c, 0xe6, 0x19, 0xa2, 0xc4}; + uint8_t bytesprops2[] = {0xcb, 0xf3, 0x3f, 0xd7, 0xd1, 0xa, 0x1c, 0xe1, 0x17, 0x45, 0x83, 0x7a, 0xfc, + 0x25, 0x37, 0x78, 0xaa, 0xbb, 0x1, 0xe6, 0x14, 0xcd, 0x99, 0x36, 0x8c}; + uint8_t bytesprops3[] = {0xc6, 0xd1, 0x69, 0x86, 0xc6, 0xfb, 0x19, 0x7e, 0x9b, 0x77, 0x5, 0xff, 0x94}; + uint8_t bytesprops4[] = {0x6e, 0x94, 0xe7, 0x70, 0x15, 0xde, 0x3c}; + uint8_t bytesprops5[] = {0x48, 0x33, 0x27, 0xbe, 0x1b, 0x23, 0xed, 0x77, 0x27, 0x34, + 0x21, 0xb, 0x8b, 0xd2, 0xbd, 0xe0, 0x5a, 0x63, 0xaf, 0x55}; + uint8_t bytesprops6[] = {0xb7, 0x32, 0x69, 0x77, 0x44, 0xd4, 0x94, 0x78, 0xff, 0xc8, 0x28, 0xd1, 0x31, 0xfa, 0x3f}; + uint8_t bytesprops7[] = {0x76, 0x46, 0x48, 0xed, 0x87, 0xbd, 0x44, 0xf2, 0x28, 0x5e, 0xc9, 0x9f, 0x4, 0x4, 0x94}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21735}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23247}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1098}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15291}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13184}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22231}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops1}, .v = {1, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1168}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18513}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29241}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17391}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "x\170\228C2\140C\ACKD\FS/[\214\EOT\SOH", _pubPktID = 0, _pubBody = "\185", _pubProps = [PropTopicAliasMaximum -// 21735,PropMaximumPacketSize 23247,PropResponseTopic "\253\195\224\216d\206\EOT\167?\163CZ\163",PropServerKeepAlive -// 1098,PropMessageExpiryInterval 15291,PropWildcardSubscriptionAvailable 116,PropTopicAlias -// 13184,PropSubscriptionIdentifier 23,PropTopicAliasMaximum 22231,PropRetainAvailable 205,PropUserProperty -// "\164\227\165\164\178\EOT.\134X\216\ENQ^\198\&8\206\133\249\131\t]=\208\177\174" "c",PropMaximumPacketSize -// 1168,PropReceiveMaximum 18513]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = +// "\180^\180\196\166\GS\142\ETB\np\US\226\226j-\130\242+\138\234A", _pubPktID = 0, _pubBody = +// "\STXN8tdLv\171\220\&3tu\225\159\165V\148\183&W6\202\202\165r\SOH", _pubProps = [PropUserProperty +// "C\242\178\130f\163{W\US'\201m\140\230\EM\162\196" +// "\250\v\ESC\n\NAKw\135b2\164\243\&66n\"\nFF8\207\&1e\136\208s",PropTopicAlias 29241,PropReasonString +// "\203\243?\215\209\n\FS\225\ETBE\131z\252%7x\170\187\SOH\230\DC4\205\153\&6\140",PropContentType +// "\198\209i\134\198\251\EM~\155w\ENQ\255\148",PropAuthenticationMethod "n\148\231p\NAK\222<",PropRetainAvailable +// 172,PropPayloadFormatIndicator 179,PropReasonString +// "H3'\190\ESC#\237w'4!\v\139\210\189\224Zc\175U",PropSubscriptionIdentifier 16,PropReasonString +// "\183\&2iwD\212\148x\255\200(\209\&1\250?",PropRequestProblemInformation 206,PropReasonString +// "vFH\237\135\189D\242(^\201\159\EOT\EOT\148",PropWildcardSubscriptionAvailable 38,PropMessageExpiryInterval +// 17391,PropWildcardSubscriptionAvailable 86]} TEST(Publish5QCTest, Decode13) { - uint8_t pkt[] = {0x31, 0x65, 0x0, 0xf, 0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, - 0x5b, 0xd6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xbb, 0x1, 0xe6, 0x14, + 0xcd, 0x99, 0x36, 0x8c, 0x3, 0x0, 0xd, 0xc6, 0xd1, 0x69, 0x86, 0xc6, 0xfb, 0x19, 0x7e, 0x9b, 0x77, + 0x5, 0xff, 0x94, 0x15, 0x0, 0x7, 0x6e, 0x94, 0xe7, 0x70, 0x15, 0xde, 0x3c, 0x25, 0xac, 0x1, 0xb3, + 0x1f, 0x0, 0x14, 0x48, 0x33, 0x27, 0xbe, 0x1b, 0x23, 0xed, 0x77, 0x27, 0x34, 0x21, 0xb, 0x8b, 0xd2, + 0xbd, 0xe0, 0x5a, 0x63, 0xaf, 0x55, 0xb, 0x10, 0x1f, 0x0, 0xf, 0xb7, 0x32, 0x69, 0x77, 0x44, 0xd4, + 0x94, 0x78, 0xff, 0xc8, 0x28, 0xd1, 0x31, 0xfa, 0x3f, 0x17, 0xce, 0x1f, 0x0, 0xf, 0x76, 0x46, 0x48, + 0xed, 0x87, 0xbd, 0x44, 0xf2, 0x28, 0x5e, 0xc9, 0x9f, 0x4, 0x4, 0x94, 0x28, 0x26, 0x2, 0x0, 0x0, + 0x43, 0xef, 0x28, 0x56, 0x2, 0x4e, 0x38, 0x74, 0x64, 0x4c, 0x76, 0xab, 0xdc, 0x33, 0x74, 0x75, 0xe1, + 0x9f, 0xa5, 0x56, 0x94, 0xb7, 0x26, 0x57, 0x36, 0xca, 0xca, 0xa5, 0x72, 0x1}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3275,112 +3259,161 @@ TEST(Publish5QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x78, 0xaa, 0xe4, 0x43, 0x32, 0x8c, 0x43, 0x6, 0x44, 0x1c, 0x2f, 0x5b, 0xd6, 0x4, 0x1}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb9}; - lwmqtt_string_t exp_body = {1, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xb4, 0x5e, 0xb4, 0xc4, 0xa6, 0x1d, 0x8e, 0x17, 0xa, 0x70, 0x1f, + 0xe2, 0xe2, 0x6a, 0x2d, 0x82, 0xf2, 0x2b, 0x8a, 0xea, 0x41}; + lwmqtt_string_t exp_topic = {21, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x2, 0x4e, 0x38, 0x74, 0x64, 0x4c, 0x76, 0xab, 0xdc, 0x33, 0x74, 0x75, 0xe1, + 0x9f, 0xa5, 0x56, 0x94, 0xb7, 0x26, 0x57, 0x36, 0xca, 0xca, 0xa5, 0x72, 0x1}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); + EXPECT_EQ(msg.retained, false); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 1); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 1); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "\EM\181N`\v\241\NAKi\133lU\172 -// ~\192\152\DLE2\173\193\158\SOH\252\&8/.\RS", _pubPktID = 21275, _pubBody = "'\189s+\222o/\187^\161", _pubProps = -// [PropTopicAliasMaximum 21929,PropResponseInformation "9\236S.4\nB\SYN",PropMaximumPacketSize 29128,PropUserProperty -// "'\209\DC2\f%l\254\138\"\180;\165\235\174\228f\247$r\ETB\DEL\176\167>#xJm\254" -// "\160\182\229\218|\\\172\216\161Q\SI]\141\252\192\&3\210;\181\236\DC2\191BQ",PropAuthenticationData -// "R='\201\138\DC3c\SUBXM\155\129\200@\189B\186H6\EM]\131x\130\159\215\189\238K",PropUserProperty -// "O\CAN\191\144\250\GSL6\193a\ENQu\ETX\151\EMW\145\r\223\178\ETX" -// "\GSv\248\238L\234\137\SYN\DC2%:V\129yh\199\189\DC3\167N\DC49{\t\137",PropMaximumPacketSize 20573,PropContentType -// "F$'T\241\232\151\161",PropSharedSubscriptionAvailable 97]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\243\134\DC4\174\182\NAK\138\171\188\\\180\226\181G\223S\232\138f\172\170", _pubPktID = 0, _pubBody = +// "\b\177(\176\139\216T[#|\147\DC1\157R?$\242", _pubProps = [PropAssignedClientIdentifier +// ">q\205\132\243\222[\128]{\223\&5g\NUL\201)k~\149G\188\FS\168\DC2~L",PropRequestProblemInformation +// 79,PropRequestResponseInformation 203,PropResponseInformation +// "0\255n\182\ETB)\DC2\179e\219nn\183\209FM3r\191\168+\173\181\205=\EM",PropContentType +// "l\132\200\139`[\207\DC2\NUL\169\195\203\255\196#xJm\254" -// "\160\182\229\218|\\\172\216\161Q\SI]\141\252\192\&3\210;\181\236\DC2\191BQ",PropAuthenticationData -// "R='\201\138\DC3c\SUBXM\155\129\200@\189B\186H6\EM]\131x\130\159\215\189\238K",PropUserProperty -// "O\CAN\191\144\250\GSL6\193a\ENQu\ETX\151\EMW\145\r\223\178\ETX" -// "\GSv\248\238L\234\137\SYN\DC2%:V\129yh\199\189\DC3\167N\DC49{\t\137",PropMaximumPacketSize 20573,PropContentType -// "F$'T\241\232\151\161",PropSharedSubscriptionAvailable 97]} +// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = +// "\243\134\DC4\174\182\NAK\138\171\188\\\180\226\181G\223S\232\138f\172\170", _pubPktID = 0, _pubBody = +// "\b\177(\176\139\216T[#|\147\DC1\157R?$\242", _pubProps = [PropAssignedClientIdentifier +// ">q\205\132\243\222[\128]{\223\&5g\NUL\201)k~\149G\188\FS\168\DC2~L",PropRequestProblemInformation +// 79,PropRequestResponseInformation 203,PropResponseInformation +// "0\255n\182\ETB)\DC2\179e\219nn\183\209FM3r\191\168+\173\181\205=\EM",PropContentType +// "l\132\200\139`[\207\DC2\NUL\169\195\203\255\196(topic.data), 27); - EXPECT_EQ(msg.payload_len, 10); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 10); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 21); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\176\EMg\233", _pubPktID = 31111, -// _pubBody = "e\163\181)\SYN\133\198/d\225\216\252\177\&5v[\251\&3\219\232\135\&2\251>E\155#\DLE\254", _pubProps = -// [PropWillDelayInterval 9651,PropAssignedClientIdentifier -// "\187\193]\153&\208#\238\DLE\180n?\NAK\244n\SYN\248\167\151\135\164\179\183\205",PropServerReference -// "p",PropServerKeepAlive 9508,PropReceiveMaximum 4115,PropContentType -// "\fP\153\219\190\224\GS\229\FS\175\176\202\&8CD\193\131h",PropAuthenticationMethod "w\\",PropTopicAliasMaximum -// 13378,PropWildcardSubscriptionAvailable 106,PropWildcardSubscriptionAvailable 38,PropSessionExpiryInterval -// 1710,PropReceiveMaximum 22280,PropAssignedClientIdentifier ")",PropCorrelationData -// "\a*\163\&9W.\223N\RS\215\170{\a\DC23\"\f\207\129{\212a\bxK",PropAuthenticationMethod -// "i\183\129\NAK\129\v\190\CAN4",PropRetainAvailable 213,PropMaximumPacketSize 11201,PropMessageExpiryInterval -// 14252,PropResponseInformation "w2\248\193",PropTopicAlias 1304,PropReasonString -// "Z\ACK\230\131\214\146\&7\228\141\229\209\&5\214z\221\NAK\244\241y\220\252\193\240p\189\&7J\154\196",PropPayloadFormatIndicator -// 153,PropMaximumPacketSize 11435,PropWildcardSubscriptionAvailable 74,PropMaximumPacketSize -// 23532,PropRequestResponseInformation 85,PropServerReference "\229bn\164\160*X\192\237\195js?\226\163\&8bx\187"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\CAN", _pubPktID = 21185, _pubBody = +// "\242\163\&2\173f\171\141\148\172\254\198\166\220=I\223\188q\204S\NUL\207\&8jS", _pubProps = +// [PropAssignedClientIdentifier +// "\163\179\143\191\207\143\185\145\246\239:cY5;\SOH\207L\150y\176\198",PropSubscriptionIdentifier 13,PropTopicAlias +// 13600,PropServerReference "\ESCjY\169",PropRetainAvailable 92,PropAssignedClientIdentifier +// "\162\147nB\a\131\SUBn\130\RSW\234\FS\164*/G\200\DEL5\ETXr",PropSessionExpiryInterval 9495,PropMessageExpiryInterval +// 17487,PropRetainAvailable 217,PropMessageExpiryInterval 16291,PropServerKeepAlive +// 13809,PropSubscriptionIdentifierAvailable 37,PropReasonString +// "\192i\179\152#\168\157\157\173(\223z\215\171;\152\150\210\214?&p>$\226",PropRequestProblemInformation +// 113,PropTopicAlias 4164]} TEST(Publish5QCTest, Encode15) { - uint8_t pkt[] = { - 0x34, 0x82, 0x2, 0x0, 0x4, 0xb0, 0x19, 0x67, 0xe9, 0x79, 0x87, 0xdb, 0x1, 0x18, 0x0, 0x0, 0x25, 0xb3, 0x12, - 0x0, 0x18, 0xbb, 0xc1, 0x5d, 0x99, 0x26, 0xd0, 0x23, 0xee, 0x10, 0xb4, 0x6e, 0x3f, 0x15, 0xf4, 0x6e, 0x16, 0xf8, - 0xa7, 0x97, 0x87, 0xa4, 0xb3, 0xb7, 0xcd, 0x1c, 0x0, 0x1, 0x70, 0x13, 0x25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 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, - 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; - uint8_t topic_bytes[] = {0xb0, 0x19, 0x67, 0xe9}; - lwmqtt_string_t topic = {4, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0x96, 0x1, 0x0, 0x1, 0x18, 0x52, 0xc1, 0x77, 0x12, 0x0, 0x16, 0xa3, 0xb3, 0x8f, 0xbf, + 0xcf, 0x8f, 0xb9, 0x91, 0xf6, 0xef, 0x3a, 0x63, 0x59, 0x35, 0x3b, 0x1, 0xcf, 0x4c, 0x96, 0x79, + 0xb0, 0xc6, 0xb, 0xd, 0x23, 0x35, 0x20, 0x1c, 0x0, 0x4, 0x1b, 0x6a, 0x59, 0xa9, 0x25, 0x5c, + 0x12, 0x0, 0x16, 0xa2, 0x93, 0x6e, 0x42, 0x7, 0x83, 0x1a, 0x6e, 0x82, 0x1e, 0x57, 0xea, 0x1c, + 0xa4, 0x2a, 0x2f, 0x47, 0xc8, 0x7f, 0x35, 0x3, 0x72, 0x11, 0x0, 0x0, 0x25, 0x17, 0x2, 0x0, + 0x0, 0x44, 0x4f, 0x25, 0xd9, 0x2, 0x0, 0x0, 0x3f, 0xa3, 0x13, 0x35, 0xf1, 0x29, 0x25, 0x1f, + 0x0, 0x19, 0xc0, 0x69, 0xb3, 0x98, 0x23, 0xa8, 0x9d, 0x9d, 0xad, 0x28, 0xdf, 0x7a, 0xd7, 0xab, + 0x3b, 0x98, 0x96, 0xd2, 0xd6, 0x3f, 0x26, 0x70, 0x3e, 0x24, 0xe2, 0x17, 0x71, 0x23, 0x10, 0x44, + 0xf2, 0xa3, 0x32, 0xad, 0x66, 0xab, 0x8d, 0x94, 0xac, 0xfe, 0xc6, 0xa6, 0xdc, 0x3d, 0x49, 0xdf, + 0xbc, 0x71, 0xcc, 0x53, 0x0, 0xcf, 0x38, 0x6a, 0x53}; + uint8_t topic_bytes[] = {0x18}; + lwmqtt_string_t topic = {1, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x65, 0xa3, 0xb5, 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, - 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xf2, 0xa3, 0x32, 0xad, 0x66, 0xab, 0x8d, 0x94, 0xac, 0xfe, 0xc6, 0xa6, 0xdc, + 0x3d, 0x49, 0xdf, 0xbc, 0x71, 0xcc, 0x53, 0x0, 0xcf, 0x38, 0x6a, 0x53}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 25; - uint8_t bytesprops0[] = {0xbb, 0xc1, 0x5d, 0x99, 0x26, 0xd0, 0x23, 0xee, 0x10, 0xb4, 0x6e, 0x3f, - 0x15, 0xf4, 0x6e, 0x16, 0xf8, 0xa7, 0x97, 0x87, 0xa4, 0xb3, 0xb7, 0xcd}; - uint8_t bytesprops1[] = {0x70}; - uint8_t bytesprops2[] = {0xc, 0x50, 0x99, 0xdb, 0xbe, 0xe0, 0x1d, 0xe5, 0x1c, - 0xaf, 0xb0, 0xca, 0x38, 0x43, 0x44, 0xc1, 0x83, 0x68}; - uint8_t bytesprops3[] = {0x77, 0x5c}; - uint8_t bytesprops4[] = {0x29}; - uint8_t bytesprops5[] = {0x7, 0x2a, 0xa3, 0x39, 0x57, 0x2e, 0xdf, 0x4e, 0x1e, 0xd7, 0xaa, 0x7b, 0x7, - 0x12, 0x33, 0x22, 0xc, 0xcf, 0x81, 0x7b, 0xd4, 0x61, 0x8, 0x78, 0x4b}; - uint8_t bytesprops6[] = {0x69, 0xb7, 0x81, 0x15, 0x81, 0xb, 0xbe, 0x18, 0x34}; - uint8_t bytesprops7[] = {0x77, 0x32, 0xf8, 0xc1}; - uint8_t bytesprops8[] = {0x5a, 0x6, 0xe6, 0x83, 0xd6, 0x92, 0x37, 0xe4, 0x8d, 0xe5, 0xd1, 0x35, 0xd6, 0x7a, 0xdd, - 0x15, 0xf4, 0xf1, 0x79, 0xdc, 0xfc, 0xc1, 0xf0, 0x70, 0xbd, 0x37, 0x4a, 0x9a, 0xc4}; - uint8_t bytesprops9[] = {0xe5, 0x62, 0x6e, 0xa4, 0xa0, 0x2a, 0x58, 0xc0, 0xed, 0xc3, - 0x6a, 0x73, 0x3f, 0xe2, 0xa3, 0x38, 0x62, 0x78, 0xbb}; + uint8_t bytesprops0[] = {0xa3, 0xb3, 0x8f, 0xbf, 0xcf, 0x8f, 0xb9, 0x91, 0xf6, 0xef, 0x3a, + 0x63, 0x59, 0x35, 0x3b, 0x1, 0xcf, 0x4c, 0x96, 0x79, 0xb0, 0xc6}; + uint8_t bytesprops1[] = {0x1b, 0x6a, 0x59, 0xa9}; + uint8_t bytesprops2[] = {0xa2, 0x93, 0x6e, 0x42, 0x7, 0x83, 0x1a, 0x6e, 0x82, 0x1e, 0x57, + 0xea, 0x1c, 0xa4, 0x2a, 0x2f, 0x47, 0xc8, 0x7f, 0x35, 0x3, 0x72}; + uint8_t bytesprops3[] = {0xc0, 0x69, 0xb3, 0x98, 0x23, 0xa8, 0x9d, 0x9d, 0xad, 0x28, 0xdf, 0x7a, 0xd7, + 0xab, 0x3b, 0x98, 0x96, 0xd2, 0xd6, 0x3f, 0x26, 0x70, 0x3e, 0x24, 0xe2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9651}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9508}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4115}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13378}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1710}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22280}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11201}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14252}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1304}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11435}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23532}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13600}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9495}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17487}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16291}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13809}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4164}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 31111, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 21185, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\176\EMg\233", _pubPktID = 31111, -// _pubBody = "e\163\181)\SYN\133\198/d\225\216\252\177\&5v[\251\&3\219\232\135\&2\251>E\155#\DLE\254", _pubProps = -// [PropWillDelayInterval 9651,PropAssignedClientIdentifier -// "\187\193]\153&\208#\238\DLE\180n?\NAK\244n\SYN\248\167\151\135\164\179\183\205",PropServerReference -// "p",PropServerKeepAlive 9508,PropReceiveMaximum 4115,PropContentType -// "\fP\153\219\190\224\GS\229\FS\175\176\202\&8CD\193\131h",PropAuthenticationMethod "w\\",PropTopicAliasMaximum -// 13378,PropWildcardSubscriptionAvailable 106,PropWildcardSubscriptionAvailable 38,PropSessionExpiryInterval -// 1710,PropReceiveMaximum 22280,PropAssignedClientIdentifier ")",PropCorrelationData -// "\a*\163\&9W.\223N\RS\215\170{\a\DC23\"\f\207\129{\212a\bxK",PropAuthenticationMethod -// "i\183\129\NAK\129\v\190\CAN4",PropRetainAvailable 213,PropMaximumPacketSize 11201,PropMessageExpiryInterval -// 14252,PropResponseInformation "w2\248\193",PropTopicAlias 1304,PropReasonString -// "Z\ACK\230\131\214\146\&7\228\141\229\209\&5\214z\221\NAK\244\241y\220\252\193\240p\189\&7J\154\196",PropPayloadFormatIndicator -// 153,PropMaximumPacketSize 11435,PropWildcardSubscriptionAvailable 74,PropMaximumPacketSize -// 23532,PropRequestResponseInformation 85,PropServerReference "\229bn\164\160*X\192\237\195js?\226\163\&8bx\187"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\CAN", _pubPktID = 21185, _pubBody = +// "\242\163\&2\173f\171\141\148\172\254\198\166\220=I\223\188q\204S\NUL\207\&8jS", _pubProps = +// [PropAssignedClientIdentifier +// "\163\179\143\191\207\143\185\145\246\239:cY5;\SOH\207L\150y\176\198",PropSubscriptionIdentifier 13,PropTopicAlias +// 13600,PropServerReference "\ESCjY\169",PropRetainAvailable 92,PropAssignedClientIdentifier +// "\162\147nB\a\131\SUBn\130\RSW\234\FS\164*/G\200\DEL5\ETXr",PropSessionExpiryInterval 9495,PropMessageExpiryInterval +// 17487,PropRetainAvailable 217,PropMessageExpiryInterval 16291,PropServerKeepAlive +// 13809,PropSubscriptionIdentifierAvailable 37,PropReasonString +// "\192i\179\152#\168\157\157\173(\223z\215\171;\152\150\210\214?&p>$\226",PropRequestProblemInformation +// 113,PropTopicAlias 4164]} TEST(Publish5QCTest, Decode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, 0x7a, 0xd7, 0xab, + 0x3b, 0x98, 0x96, 0xd2, 0xd6, 0x3f, 0x26, 0x70, 0x3e, 0x24, 0xe2, 0x17, 0x71, 0x23, 0x10, 0x44, + 0xf2, 0xa3, 0x32, 0xad, 0x66, 0xab, 0x8d, 0x94, 0xac, 0xfe, 0xc6, 0xa6, 0xdc, 0x3d, 0x49, 0xdf, + 0xbc, 0x71, 0xcc, 0x53, 0x0, 0xcf, 0x38, 0x6a, 0x53}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3539,134 +3535,77 @@ TEST(Publish5QCTest, Decode15) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb0, 0x19, 0x67, 0xe9}; - lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x65, 0xa3, 0xb5, 0x29, 0x16, 0x85, 0xc6, 0x2f, 0x64, 0xe1, 0xd8, 0xfc, 0xb1, 0x35, 0x76, - 0x5b, 0xfb, 0x33, 0xdb, 0xe8, 0x87, 0x32, 0xfb, 0x3e, 0x45, 0x9b, 0x23, 0x10, 0xfe}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 31111); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + uint8_t exp_topic_bytes[] = {0x18}; + lwmqtt_string_t exp_topic = {1, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf2, 0xa3, 0x32, 0xad, 0x66, 0xab, 0x8d, 0x94, 0xac, 0xfe, 0xc6, 0xa6, 0xdc, + 0x3d, 0x49, 0xdf, 0xbc, 0x71, 0xcc, 0x53, 0x0, 0xcf, 0x38, 0x6a, 0x53}; + lwmqtt_string_t exp_body = {25, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 21185); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 1); + EXPECT_EQ(msg.payload_len, 25); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 25); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\169\&0\211V\249\144\&4+[\166\254\135\144\241\n\198\162\233\181\161i\132\132\ENQ\204\191", _pubPktID = 8952, -// _pubBody = "\173A\231|1\170\255\146o\191\190\DC2+uY", _pubProps = [PropSessionExpiryInterval -// 30113,PropAuthenticationData "F\253?\\\253\158\SYN\SOw\214\165\154\216\150G\189\234\235:\166",PropAuthenticationData -// "\233\DC1\174\158\255L\201\&1\254\155\229\213\228\150\156\220\234\159\&7\131*\249\208z\182\129n$",PropPayloadFormatIndicator -// 15,PropSessionExpiryInterval 21520,PropSubscriptionIdentifierAvailable 118,PropReasonString -// "\238\160|\130\186\233",PropResponseTopic "\165L\199\251m7H\RS\146 N\ESC1\163Pf",PropTopicAliasMaximum -// 10251,PropMaximumQoS 145,PropAuthenticationMethod -// "\155t\149\&8m\SUB\DC3\229\210\139\218\168\226\236,\143\195\DC4\a\RS\NUL2\193",PropTopicAlias -// 14385,PropCorrelationData -// "#\147\235m\194j\255_\202\196\148\166M\189\146\213\128\155K\236\237\150]h\RS6\212\STX\153\189",PropServerReference -// "\242",PropReceiveMaximum 30036,PropSubscriptionIdentifier 7,PropMessageExpiryInterval -// 20179,PropSubscriptionIdentifierAvailable 224,PropServerReference "="]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\tW7", _pubPktID = 0, _pubBody = +// "<\173\DLE`;<%6\196ne\143\&7_\DC2&K\177\250\145(topic.data), 26); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\192!\207\251\220\139\197\DC3\237\227", _pubPktID = 0, _pubBody = -// "\245Ha\212\EM\NAK\214Qf\253*\177\142\202P\176\144\184\149N\DC4", _pubProps = [PropTopicAlias -// 3759,PropResponseInformation -// "\245\164\GS\240\187}\174_\151\ACK?s\DLE2\169+>\151\236\152c\182\b\170\246",PropAssignedClientIdentifier -// "\169\144\210\176\DLE\251Z\157\181.\146\208\224h\194DM\GS\167\NUL\250p\230dN",PropResponseInformation -// "X\142\143\234\134\SUB",PropSharedSubscriptionAvailable 170,PropAssignedClientIdentifier -// "5H\226\179\205\205:\DLE\EOT7\197",PropRequestProblemInformation 49,PropMaximumPacketSize -// 20134,PropAuthenticationData "\248'/Y\163M\183\162wG\"\214O\157\154\241_0\138\221\142\ENQ",PropAuthenticationData -// "\129\142\250\191\157\CANwJP\NUL\234\159\&2v\213{\ENQ\226",PropWillDelayInterval 29261,PropRequestResponseInformation -// 250,PropSubscriptionIdentifierAvailable 166,PropReceiveMaximum 5141,PropContentType -// "\248E\130iq\199\135\148\247\210\249\161\239",PropWillDelayInterval 13294,PropResponseTopic "\192\253\130 -// \186\b\183",PropReasonString "8\209Z\ETX\240uer\136F\242\SYNJZ\202\&2\216&\208\&4M6\146",PropReasonString -// "\242\&9h%\150{\204\238\219\162\231\248\194\216,D\178\194O\230\209\t5\134",PropMessageExpiryInterval 21649]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "#rf\225\210\223\183\179#", _pubPktID +// = 0, _pubBody = "\225\141\154:Z\166E\DLEF\164\218\176U\138\191\RSV[\255\160=\DC1@\195r~WH\245", _pubProps = +// [PropUserProperty "Jn\t\166q\DLE\175\&5\131\ETB\176" +// "\225dt\254\144\DC2\ae\t\209?\232y\248\242Kv\184kAj\145\139-",PropTopicAlias 24033,PropPayloadFormatIndicator +// 94,PropReceiveMaximum 9447,PropReceiveMaximum 23844,PropMessageExpiryInterval 12367,PropTopicAlias 32717]} TEST(Publish5QCTest, Encode17) { - uint8_t pkt[] = { - 0x38, 0x91, 0x2, 0x0, 0xa, 0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3, 0xee, 0x1, 0x23, 0xe, - 0xaf, 0x1a, 0x0, 0x19, 0xf5, 0xa4, 0x1d, 0xf0, 0xbb, 0x7d, 0xae, 0x5f, 0x97, 0x6, 0x3f, 0x73, 0x10, 0x32, 0xa9, - 0x2b, 0x3e, 0x97, 0xec, 0x98, 0x63, 0xb6, 0x8, 0xaa, 0xf6, 0x12, 0x0, 0x19, 0xa9, 0x90, 0xd2, 0xb0, 0x10, 0xfb, - 0x5a, 0x9d, 0xb5, 0x2e, 0x92, 0xd0, 0xe0, 0x68, 0xc2, 0x44, 0x4d, 0x1d, 0xa7, 0x0, 0xfa, 0x70, 0xe6, 0x64, 0x4e, - 0x1a, 0x0, 0x6, 0x58, 0x8e, 0x8f, 0xea, 0x86, 0x1a, 0x2a, 0xaa, 0x12, 0x0, 0xb, 0x35, 0x48, 0xe2, 0xb3, 0xcd, - 0xcd, 0x3a, 0x10, 0x4, 0x37, 0xc5, 0x17, 0x31, 0x27, 0x0, 0x0, 0x4e, 0xa6, 0x16, 0x0, 0x16, 0xf8, 0x27, 0x2f, - 0x59, 0xa3, 0x4d, 0xb7, 0xa2, 0x77, 0x47, 0x22, 0xd6, 0x4f, 0x9d, 0x9a, 0xf1, 0x5f, 0x30, 0x8a, 0xdd, 0x8e, 0x5, - 0x16, 0x0, 0x12, 0x81, 0x8e, 0xfa, 0xbf, 0x9d, 0x18, 0x77, 0x4a, 0x50, 0x0, 0xea, 0x9f, 0x32, 0x76, 0xd5, 0x7b, - 0x5, 0xe2, 0x18, 0x0, 0x0, 0x72, 0x4d, 0x19, 0xfa, 0x29, 0xa6, 0x21, 0x14, 0x15, 0x3, 0x0, 0xd, 0xf8, 0x45, - 0x82, 0x69, 0x71, 0xc7, 0x87, 0x94, 0xf7, 0xd2, 0xf9, 0xa1, 0xef, 0x18, 0x0, 0x0, 0x33, 0xee, 0x8, 0x0, 0x7, - 0xc0, 0xfd, 0x82, 0x20, 0xba, 0x8, 0xb7, 0x1f, 0x0, 0x17, 0x38, 0xd1, 0x5a, 0x3, 0xf0, 0x75, 0x65, 0x72, 0x88, - 0x46, 0xf2, 0x16, 0x4a, 0x5a, 0xca, 0x32, 0xd8, 0x26, 0xd0, 0x34, 0x4d, 0x36, 0x92, 0x1f, 0x0, 0x18, 0xf2, 0x39, - 0x68, 0x25, 0x96, 0x7b, 0xcc, 0xee, 0xdb, 0xa2, 0xe7, 0xf8, 0xc2, 0xd8, 0x2c, 0x44, 0xb2, 0xc2, 0x4f, 0xe6, 0xd1, - 0x9, 0x35, 0x86, 0x2, 0x0, 0x0, 0x54, 0x91, 0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, - 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; - uint8_t topic_bytes[] = {0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3}; - lwmqtt_string_t topic = {10, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x64, 0x0, 0x9, 0x23, 0x72, 0x66, 0xe1, 0xd2, 0xdf, 0xb7, 0xb3, 0x23, 0x3b, 0x26, + 0x0, 0xb, 0x4a, 0x6e, 0x9, 0xa6, 0x71, 0x10, 0xaf, 0x35, 0x83, 0x17, 0xb0, 0x0, 0x18, + 0xe1, 0x64, 0x74, 0xfe, 0x90, 0x12, 0x7, 0x65, 0x9, 0xd1, 0x3f, 0xe8, 0x79, 0xf8, 0xf2, + 0x4b, 0x76, 0xb8, 0x6b, 0x41, 0x6a, 0x91, 0x8b, 0x2d, 0x23, 0x5d, 0xe1, 0x1, 0x5e, 0x21, + 0x24, 0xe7, 0x21, 0x5d, 0x24, 0x2, 0x0, 0x0, 0x30, 0x4f, 0x23, 0x7f, 0xcd, 0xe1, 0x8d, + 0x9a, 0x3a, 0x5a, 0xa6, 0x45, 0x10, 0x46, 0xa4, 0xda, 0xb0, 0x55, 0x8a, 0xbf, 0x1e, 0x56, + 0x5b, 0xff, 0xa0, 0x3d, 0x11, 0x40, 0xc3, 0x72, 0x7e, 0x57, 0x48, 0xf5}; + uint8_t topic_bytes[] = {0x23, 0x72, 0x66, 0xe1, 0xd2, 0xdf, 0xb7, 0xb3, 0x23}; + lwmqtt_string_t topic = {9, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, - 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; + msg.retained = true; + uint8_t msg_bytes[] = {0xe1, 0x8d, 0x9a, 0x3a, 0x5a, 0xa6, 0x45, 0x10, 0x46, 0xa4, 0xda, 0xb0, 0x55, 0x8a, 0xbf, + 0x1e, 0x56, 0x5b, 0xff, 0xa0, 0x3d, 0x11, 0x40, 0xc3, 0x72, 0x7e, 0x57, 0x48, 0xf5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - - uint8_t bytesprops0[] = {0xf5, 0xa4, 0x1d, 0xf0, 0xbb, 0x7d, 0xae, 0x5f, 0x97, 0x6, 0x3f, 0x73, 0x10, - 0x32, 0xa9, 0x2b, 0x3e, 0x97, 0xec, 0x98, 0x63, 0xb6, 0x8, 0xaa, 0xf6}; - uint8_t bytesprops1[] = {0xa9, 0x90, 0xd2, 0xb0, 0x10, 0xfb, 0x5a, 0x9d, 0xb5, 0x2e, 0x92, 0xd0, 0xe0, - 0x68, 0xc2, 0x44, 0x4d, 0x1d, 0xa7, 0x0, 0xfa, 0x70, 0xe6, 0x64, 0x4e}; - uint8_t bytesprops2[] = {0x58, 0x8e, 0x8f, 0xea, 0x86, 0x1a}; - uint8_t bytesprops3[] = {0x35, 0x48, 0xe2, 0xb3, 0xcd, 0xcd, 0x3a, 0x10, 0x4, 0x37, 0xc5}; - uint8_t bytesprops4[] = {0xf8, 0x27, 0x2f, 0x59, 0xa3, 0x4d, 0xb7, 0xa2, 0x77, 0x47, 0x22, - 0xd6, 0x4f, 0x9d, 0x9a, 0xf1, 0x5f, 0x30, 0x8a, 0xdd, 0x8e, 0x5}; - uint8_t bytesprops5[] = {0x81, 0x8e, 0xfa, 0xbf, 0x9d, 0x18, 0x77, 0x4a, 0x50, - 0x0, 0xea, 0x9f, 0x32, 0x76, 0xd5, 0x7b, 0x5, 0xe2}; - uint8_t bytesprops6[] = {0xf8, 0x45, 0x82, 0x69, 0x71, 0xc7, 0x87, 0x94, 0xf7, 0xd2, 0xf9, 0xa1, 0xef}; - uint8_t bytesprops7[] = {0xc0, 0xfd, 0x82, 0x20, 0xba, 0x8, 0xb7}; - uint8_t bytesprops8[] = {0x38, 0xd1, 0x5a, 0x3, 0xf0, 0x75, 0x65, 0x72, 0x88, 0x46, 0xf2, 0x16, - 0x4a, 0x5a, 0xca, 0x32, 0xd8, 0x26, 0xd0, 0x34, 0x4d, 0x36, 0x92}; - uint8_t bytesprops9[] = {0xf2, 0x39, 0x68, 0x25, 0x96, 0x7b, 0xcc, 0xee, 0xdb, 0xa2, 0xe7, 0xf8, - 0xc2, 0xd8, 0x2c, 0x44, 0xb2, 0xc2, 0x4f, 0xe6, 0xd1, 0x9, 0x35, 0x86}; + msg.payload_len = 29; + + uint8_t bytesprops1[] = {0xe1, 0x64, 0x74, 0xfe, 0x90, 0x12, 0x7, 0x65, 0x9, 0xd1, 0x3f, 0xe8, + 0x79, 0xf8, 0xf2, 0x4b, 0x76, 0xb8, 0x6b, 0x41, 0x6a, 0x91, 0x8b, 0x2d}; + uint8_t bytesprops0[] = {0x4a, 0x6e, 0x9, 0xa6, 0x71, 0x10, 0xaf, 0x35, 0x83, 0x17, 0xb0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3759}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20134}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29261}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5141}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13294}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21649}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops0}, .v = {24, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24033}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9447}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23844}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12367}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32717}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); @@ -3782,37 +3677,19 @@ TEST(Publish5QCTest, Encode17) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "\192!\207\251\220\139\197\DC3\237\227", _pubPktID = 0, _pubBody = -// "\245Ha\212\EM\NAK\214Qf\253*\177\142\202P\176\144\184\149N\DC4", _pubProps = [PropTopicAlias -// 3759,PropResponseInformation -// "\245\164\GS\240\187}\174_\151\ACK?s\DLE2\169+>\151\236\152c\182\b\170\246",PropAssignedClientIdentifier -// "\169\144\210\176\DLE\251Z\157\181.\146\208\224h\194DM\GS\167\NUL\250p\230dN",PropResponseInformation -// "X\142\143\234\134\SUB",PropSharedSubscriptionAvailable 170,PropAssignedClientIdentifier -// "5H\226\179\205\205:\DLE\EOT7\197",PropRequestProblemInformation 49,PropMaximumPacketSize -// 20134,PropAuthenticationData "\248'/Y\163M\183\162wG\"\214O\157\154\241_0\138\221\142\ENQ",PropAuthenticationData -// "\129\142\250\191\157\CANwJP\NUL\234\159\&2v\213{\ENQ\226",PropWillDelayInterval 29261,PropRequestResponseInformation -// 250,PropSubscriptionIdentifierAvailable 166,PropReceiveMaximum 5141,PropContentType -// "\248E\130iq\199\135\148\247\210\249\161\239",PropWillDelayInterval 13294,PropResponseTopic "\192\253\130 -// \186\b\183",PropReasonString "8\209Z\ETX\240uer\136F\242\SYNJZ\202\&2\216&\208\&4M6\146",PropReasonString -// "\242\&9h%\150{\204\238\219\162\231\248\194\216,D\178\194O\230\209\t5\134",PropMessageExpiryInterval 21649]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "#rf\225\210\223\183\179#", _pubPktID +// = 0, _pubBody = "\225\141\154:Z\166E\DLEF\164\218\176U\138\191\RSV[\255\160=\DC1@\195r~WH\245", _pubProps = +// [PropUserProperty "Jn\t\166q\DLE\175\&5\131\ETB\176" +// "\225dt\254\144\DC2\ae\t\209?\232y\248\242Kv\184kAj\145\139-",PropTopicAlias 24033,PropPayloadFormatIndicator +// 94,PropReceiveMaximum 9447,PropReceiveMaximum 23844,PropMessageExpiryInterval 12367,PropTopicAlias 32717]} TEST(Publish5QCTest, Decode17) { - uint8_t pkt[] = { - 0x38, 0x91, 0x2, 0x0, 0xa, 0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3, 0xee, 0x1, 0x23, 0xe, - 0xaf, 0x1a, 0x0, 0x19, 0xf5, 0xa4, 0x1d, 0xf0, 0xbb, 0x7d, 0xae, 0x5f, 0x97, 0x6, 0x3f, 0x73, 0x10, 0x32, 0xa9, - 0x2b, 0x3e, 0x97, 0xec, 0x98, 0x63, 0xb6, 0x8, 0xaa, 0xf6, 0x12, 0x0, 0x19, 0xa9, 0x90, 0xd2, 0xb0, 0x10, 0xfb, -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 0xc2, 0x4f, 0xe6, 0xd1, - 0x9, 0x35, 0x86, 0x2, 0x0, 0x0, 0x54, 0x91, 0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, - 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; + uint8_t pkt[] = {0x39, 0x64, 0x0, 0x9, 0x23, 0x72, 0x66, 0xe1, 0xd2, 0xdf, 0xb7, 0xb3, 0x23, 0x3b, 0x26, + 0x0, 0xb, 0x4a, 0x6e, 0x9, 0xa6, 0x71, 0x10, 0xaf, 0x35, 0x83, 0x17, 0xb0, 0x0, 0x18, + 0xe1, 0x64, 0x74, 0xfe, 0x90, 0x12, 0x7, 0x65, 0x9, 0xd1, 0x3f, 0xe8, 0x79, 0xf8, 0xf2, + 0x4b, 0x76, 0xb8, 0x6b, 0x41, 0x6a, 0x91, 0x8b, 0x2d, 0x23, 0x5d, 0xe1, 0x1, 0x5e, 0x21, + 0x24, 0xe7, 0x21, 0x5d, 0x24, 0x2, 0x0, 0x0, 0x30, 0x4f, 0x23, 0x7f, 0xcd, 0xe1, 0x8d, + 0x9a, 0x3a, 0x5a, 0xa6, 0x45, 0x10, 0x46, 0xa4, 0xda, 0xb0, 0x55, 0x8a, 0xbf, 0x1e, 0x56, + 0x5b, 0xff, 0xa0, 0x3d, 0x11, 0x40, 0xc3, 0x72, 0x7e, 0x57, 0x48, 0xf5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3821,87 +3698,100 @@ TEST(Publish5QCTest, Decode17) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xc0, 0x21, 0xcf, 0xfb, 0xdc, 0x8b, 0xc5, 0x13, 0xed, 0xe3}; - lwmqtt_string_t exp_topic = {10, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf5, 0x48, 0x61, 0xd4, 0x19, 0x15, 0xd6, 0x51, 0x66, 0xfd, 0x2a, - 0xb1, 0x8e, 0xca, 0x50, 0xb0, 0x90, 0xb8, 0x95, 0x4e, 0x14}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x23, 0x72, 0x66, 0xe1, 0xd2, 0xdf, 0xb7, 0xb3, 0x23}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xe1, 0x8d, 0x9a, 0x3a, 0x5a, 0xa6, 0x45, 0x10, 0x46, 0xa4, 0xda, 0xb0, 0x55, 0x8a, 0xbf, + 0x1e, 0x56, 0x5b, 0xff, 0xa0, 0x3d, 0x11, 0x40, 0xc3, 0x72, 0x7e, 0x57, 0x48, 0xf5}; + lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 10); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 29); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\244\163\195\181~\198`:\150F\212N", -// _pubPktID = 32625, _pubBody = -// "\158m\139\172\171\135\&7\154\136\129\210{\228\197\SI[\STXw\192\242\239k\178\152Q\211\143S\146", _pubProps = -// [PropRetainAvailable 200,PropUserProperty "%\166w" "",PropReasonString "\237\166:\221\247RP\b",PropResponseTopic -// "F\161\242\a\175\186\140'\182\EOT=\208-\218\EOTL\225",PropAuthenticationData -// "\154?.'<\181\175R\167\197j\217\183\232\r\134\216\215\n\EOT",PropSubscriptionIdentifier 28]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\250\DLE\228\172ZB\231\208\ETX\170e\DC3\177\170\203", _pubPktID = 20110, _pubBody = +// "xx\193Br\133\207:\183_\RS:zx\155", _pubProps = [PropMaximumPacketSize 29548,PropAssignedClientIdentifier +// "e\153\148",PropAuthenticationData "=[\206:\NAK\230\156rO=\NULP\205\172\SUB|\129\204\165",PropAuthenticationMethod +// "V3\b\196\179\r\140\222Qu\157z",PropRequestProblemInformation 94,PropSubscriptionIdentifier 8,PropResponseInformation +// "y\186\EM\211\161\136\181\n\205:\221\DLE8",PropMessageExpiryInterval 27705,PropTopicAliasMaximum +// 28714,PropCorrelationData ";\ENQ\160 +// \133K\ESCl?a\133\142\152\184\154\DC4\254\206\224\r\177\187?S\172\190\130\161",PropResponseTopic ""]} TEST(Publish5QCTest, Encode18) { - uint8_t pkt[] = {0x33, 0x70, 0x0, 0xc, 0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e, 0x7f, - 0x71, 0x42, 0x25, 0xc8, 0x26, 0x0, 0x3, 0x25, 0xa6, 0x77, 0x0, 0x0, 0x1f, 0x0, 0x8, 0xed, 0xa6, - 0x3a, 0xdd, 0xf7, 0x52, 0x50, 0x8, 0x8, 0x0, 0x11, 0x46, 0xa1, 0xf2, 0x7, 0xaf, 0xba, 0x8c, 0x27, - 0xb6, 0x4, 0x3d, 0xd0, 0x2d, 0xda, 0x4, 0x4c, 0xe1, 0x16, 0x0, 0x14, 0x9a, 0x3f, 0x2e, 0x27, 0x3c, - 0xb5, 0xaf, 0x52, 0xa7, 0xc5, 0x6a, 0xd9, 0xb7, 0xe8, 0xd, 0x86, 0xd8, 0xd7, 0xa, 0x4, 0xb, 0x1c, - 0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, 0x5b, 0x2, - 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; - uint8_t topic_bytes[] = {0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e}; - lwmqtt_string_t topic = {12, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3a, 0x91, 0x1, 0x0, 0xf, 0xfa, 0x10, 0xe4, 0xac, 0x5a, 0x42, 0xe7, 0xd0, 0x3, 0xaa, 0x65, 0x13, + 0xb1, 0xaa, 0xcb, 0x4e, 0x8e, 0x6e, 0x27, 0x0, 0x0, 0x73, 0x6c, 0x12, 0x0, 0x3, 0x65, 0x99, 0x94, + 0x16, 0x0, 0x13, 0x3d, 0x5b, 0xce, 0x3a, 0x15, 0xe6, 0x9c, 0x72, 0x4f, 0x3d, 0x0, 0x50, 0xcd, 0xac, + 0x1a, 0x7c, 0x81, 0xcc, 0xa5, 0x15, 0x0, 0xc, 0x56, 0x33, 0x8, 0xc4, 0xb3, 0xd, 0x8c, 0xde, 0x51, + 0x75, 0x9d, 0x7a, 0x17, 0x5e, 0xb, 0x8, 0x1a, 0x0, 0xd, 0x79, 0xba, 0x19, 0xd3, 0xa1, 0x88, 0xb5, + 0xa, 0xcd, 0x3a, 0xdd, 0x10, 0x38, 0x2, 0x0, 0x0, 0x6c, 0x39, 0x22, 0x70, 0x2a, 0x9, 0x0, 0x1c, + 0x3b, 0x5, 0xa0, 0x20, 0x85, 0x4b, 0x1b, 0x6c, 0x3f, 0x61, 0x85, 0x8e, 0x98, 0xb8, 0x9a, 0x14, 0xfe, + 0xce, 0xe0, 0xd, 0xb1, 0xbb, 0x3f, 0x53, 0xac, 0xbe, 0x82, 0xa1, 0x8, 0x0, 0x0, 0x78, 0x78, 0xc1, + 0x42, 0x72, 0x85, 0xcf, 0x3a, 0xb7, 0x5f, 0x1e, 0x3a, 0x7a, 0x78, 0x9b}; + uint8_t topic_bytes[] = {0xfa, 0x10, 0xe4, 0xac, 0x5a, 0x42, 0xe7, 0xd0, 0x3, 0xaa, 0x65, 0x13, 0xb1, 0xaa, 0xcb}; + lwmqtt_string_t topic = {15, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, - 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; + msg.retained = false; + uint8_t msg_bytes[] = {0x78, 0x78, 0xc1, 0x42, 0x72, 0x85, 0xcf, 0x3a, 0xb7, 0x5f, 0x1e, 0x3a, 0x7a, 0x78, 0x9b}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 29; + msg.payload_len = 15; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops0[] = {0x25, 0xa6, 0x77}; - uint8_t bytesprops2[] = {0xed, 0xa6, 0x3a, 0xdd, 0xf7, 0x52, 0x50, 0x8}; - uint8_t bytesprops3[] = {0x46, 0xa1, 0xf2, 0x7, 0xaf, 0xba, 0x8c, 0x27, 0xb6, - 0x4, 0x3d, 0xd0, 0x2d, 0xda, 0x4, 0x4c, 0xe1}; - uint8_t bytesprops4[] = {0x9a, 0x3f, 0x2e, 0x27, 0x3c, 0xb5, 0xaf, 0x52, 0xa7, 0xc5, - 0x6a, 0xd9, 0xb7, 0xe8, 0xd, 0x86, 0xd8, 0xd7, 0xa, 0x4}; + uint8_t bytesprops0[] = {0x65, 0x99, 0x94}; + uint8_t bytesprops1[] = {0x3d, 0x5b, 0xce, 0x3a, 0x15, 0xe6, 0x9c, 0x72, 0x4f, 0x3d, + 0x0, 0x50, 0xcd, 0xac, 0x1a, 0x7c, 0x81, 0xcc, 0xa5}; + uint8_t bytesprops2[] = {0x56, 0x33, 0x8, 0xc4, 0xb3, 0xd, 0x8c, 0xde, 0x51, 0x75, 0x9d, 0x7a}; + uint8_t bytesprops3[] = {0x79, 0xba, 0x19, 0xd3, 0xa1, 0x88, 0xb5, 0xa, 0xcd, 0x3a, 0xdd, 0x10, 0x38}; + uint8_t bytesprops4[] = {0x3b, 0x5, 0xa0, 0x20, 0x85, 0x4b, 0x1b, 0x6c, 0x3f, 0x61, 0x85, 0x8e, 0x98, 0xb8, + 0x9a, 0x14, 0xfe, 0xce, 0xe0, 0xd, 0xb1, 0xbb, 0x3f, 0x53, 0xac, 0xbe, 0x82, 0xa1}; + uint8_t bytesprops5[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops0}, .v = {0, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29548}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27705}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28714}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32625, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 20110, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "\244\163\195\181~\198`:\150F\212N", -// _pubPktID = 32625, _pubBody = -// "\158m\139\172\171\135\&7\154\136\129\210{\228\197\SI[\STXw\192\242\239k\178\152Q\211\143S\146", _pubProps = -// [PropRetainAvailable 200,PropUserProperty "%\166w" "",PropReasonString "\237\166:\221\247RP\b",PropResponseTopic -// "F\161\242\a\175\186\140'\182\EOT=\208-\218\EOTL\225",PropAuthenticationData -// "\154?.'<\181\175R\167\197j\217\183\232\r\134\216\215\n\EOT",PropSubscriptionIdentifier 28]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = False, _pubTopic = +// "\250\DLE\228\172ZB\231\208\ETX\170e\DC3\177\170\203", _pubPktID = 20110, _pubBody = +// "xx\193Br\133\207:\183_\RS:zx\155", _pubProps = [PropMaximumPacketSize 29548,PropAssignedClientIdentifier +// "e\153\148",PropAuthenticationData "=[\206:\NAK\230\156rO=\NULP\205\172\SUB|\129\204\165",PropAuthenticationMethod +// "V3\b\196\179\r\140\222Qu\157z",PropRequestProblemInformation 94,PropSubscriptionIdentifier 8,PropResponseInformation +// "y\186\EM\211\161\136\181\n\205:\221\DLE8",PropMessageExpiryInterval 27705,PropTopicAliasMaximum +// 28714,PropCorrelationData ";\ENQ\160 +// \133K\ESCl?a\133\142\152\184\154\DC4\254\206\224\r\177\187?S\172\190\130\161",PropResponseTopic ""]} TEST(Publish5QCTest, Decode18) { - uint8_t pkt[] = {0x33, 0x70, 0x0, 0xc, 0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e, 0x7f, - 0x71, 0x42, 0x25, 0xc8, 0x26, 0x0, 0x3, 0x25, 0xa6, 0x77, 0x0, 0x0, 0x1f, 0x0, 0x8, 0xed, 0xa6, - 0x3a, 0xdd, 0xf7, 0x52, 0x50, 0x8, 0x8, 0x0, 0x11, 0x46, 0xa1, 0xf2, 0x7, 0xaf, 0xba, 0x8c, 0x27, - 0xb6, 0x4, 0x3d, 0xd0, 0x2d, 0xda, 0x4, 0x4c, 0xe1, 0x16, 0x0, 0x14, 0x9a, 0x3f, 0x2e, 0x27, 0x3c, - 0xb5, 0xaf, 0x52, 0xa7, 0xc5, 0x6a, 0xd9, 0xb7, 0xe8, 0xd, 0x86, 0xd8, 0xd7, 0xa, 0x4, 0xb, 0x1c, - 0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, 0x5b, 0x2, - 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; + uint8_t pkt[] = {0x3a, 0x91, 0x1, 0x0, 0xf, 0xfa, 0x10, 0xe4, 0xac, 0x5a, 0x42, 0xe7, 0xd0, 0x3, 0xaa, 0x65, 0x13, + 0xb1, 0xaa, 0xcb, 0x4e, 0x8e, 0x6e, 0x27, 0x0, 0x0, 0x73, 0x6c, 0x12, 0x0, 0x3, 0x65, 0x99, 0x94, + 0x16, 0x0, 0x13, 0x3d, 0x5b, 0xce, 0x3a, 0x15, 0xe6, 0x9c, 0x72, 0x4f, 0x3d, 0x0, 0x50, 0xcd, 0xac, + 0x1a, 0x7c, 0x81, 0xcc, 0xa5, 0x15, 0x0, 0xc, 0x56, 0x33, 0x8, 0xc4, 0xb3, 0xd, 0x8c, 0xde, 0x51, + 0x75, 0x9d, 0x7a, 0x17, 0x5e, 0xb, 0x8, 0x1a, 0x0, 0xd, 0x79, 0xba, 0x19, 0xd3, 0xa1, 0x88, 0xb5, + 0xa, 0xcd, 0x3a, 0xdd, 0x10, 0x38, 0x2, 0x0, 0x0, 0x6c, 0x39, 0x22, 0x70, 0x2a, 0x9, 0x0, 0x1c, + 0x3b, 0x5, 0xa0, 0x20, 0x85, 0x4b, 0x1b, 0x6c, 0x3f, 0x61, 0x85, 0x8e, 0x98, 0xb8, 0x9a, 0x14, 0xfe, + 0xce, 0xe0, 0xd, 0xb1, 0xbb, 0x3f, 0x53, 0xac, 0xbe, 0x82, 0xa1, 0x8, 0x0, 0x0, 0x78, 0x78, 0xc1, + 0x42, 0x72, 0x85, 0xcf, 0x3a, 0xb7, 0x5f, 0x1e, 0x3a, 0x7a, 0x78, 0x9b}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -3910,165 +3800,134 @@ TEST(Publish5QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xf4, 0xa3, 0xc3, 0xb5, 0x7e, 0xc6, 0x60, 0x3a, 0x96, 0x46, 0xd4, 0x4e}; - lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9e, 0x6d, 0x8b, 0xac, 0xab, 0x87, 0x37, 0x9a, 0x88, 0x81, 0xd2, 0x7b, 0xe4, 0xc5, 0xf, - 0x5b, 0x2, 0x77, 0xc0, 0xf2, 0xef, 0x6b, 0xb2, 0x98, 0x51, 0xd3, 0x8f, 0x53, 0x92}; - lwmqtt_string_t exp_body = {29, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0xfa, 0x10, 0xe4, 0xac, 0x5a, 0x42, 0xe7, 0xd0, 0x3, 0xaa, 0x65, 0x13, 0xb1, 0xaa, 0xcb}; + lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x78, 0x78, 0xc1, 0x42, 0x72, 0x85, 0xcf, 0x3a, 0xb7, 0x5f, 0x1e, 0x3a, 0x7a, 0x78, 0x9b}; + lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 32625); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); - EXPECT_EQ(msg.payload_len, 29); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 29); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 20110); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); + EXPECT_EQ(msg.payload_len, 15); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\156\\\v`\145\USn?\217L\147\211\\\SI\254", _pubPktID = 25006, _pubBody = -// "\207\181\171\145\132\166r/\NUL\137\195|e\244P\185", _pubProps = [PropResponseInformation -// "P\171\221\201qC\168\EMD\255\220@\144\fgX\161",PropSharedSubscriptionAvailable 14,PropWillDelayInterval -// 28881,PropUserProperty "\140\245\172R\142\163\214\f*N\SUB]\196\183\185\&8\242\f\237\184+hL\186\252\182{\162\&4" -// "l\172\&0q\167.",PropMessageExpiryInterval 7945,PropSharedSubscriptionAvailable 254,PropTopicAliasMaximum -// 5168,PropMaximumPacketSize 18305,PropReasonString "\DLEX\154\137\214\187\202\155s&o\172A\204L&zd",PropServerReference -// "t\DC2\222\180\241u\DC1\150\244\NUL\184\184\171\206\231\NUL\242k\163\ETX\EOT\196\224\248\224",PropSubscriptionIdentifierAvailable -// 196,PropMaximumPacketSize 1305,PropSubscriptionIdentifier 26,PropMessageExpiryInterval -// 20834,PropWildcardSubscriptionAvailable 162,PropSubscriptionIdentifier 5,PropAuthenticationMethod -// "\220u\139\169",PropReasonString "\196[",PropSessionExpiryInterval 11673,PropUserProperty -// ":@1b\178\ETB\249,)\129\251\184'Xb\198\DLER\SYN" -// "\153\188F5\215\167\243&P\207V\137\242\DELw\128M'\217\232]\151,T",PropSubscriptionIdentifier -// 16,PropWildcardSubscriptionAvailable 109,PropContentType -// "\137\168\&9{\224\239\138+\226\186\ETB{\243/\182G\239\197/\228\230T ",PropMessageExpiryInterval -// 267,PropMessageExpiryInterval 5907,PropResponseTopic -// "\233{\213\216(\221\150\&0\158\246`u\203\194it\162\135\&3nT\211\SYN\ENQ\179",PropSubscriptionIdentifier 12]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\219DL\230\173kI\194", _pubPktID = +// 0, _pubBody = "k@\192\208$\186\173\v\213b\157\255\206\DLE\253xC", _pubProps = [PropCorrelationData +// "\DC1\208\DC1\216%&aX\DLE\175Y\218",PropMessageExpiryInterval 26517,PropSubscriptionIdentifier +// 23,PropMessageExpiryInterval 15730,PropPayloadFormatIndicator 182,PropAuthenticationMethod +// "\248g\201\230)o\167\158\170\DLE\169",PropRequestProblemInformation 200,PropAuthenticationMethod +// "\201|cS",PropCorrelationData "!t\134M@\SUB\241",PropMessageExpiryInterval 25589,PropRequestProblemInformation +// 35,PropSubscriptionIdentifier 24,PropSessionExpiryInterval 2715,PropMaximumQoS 107,PropSessionExpiryInterval +// 20616,PropSessionExpiryInterval 23806,PropSharedSubscriptionAvailable 218,PropWildcardSubscriptionAvailable +// 120,PropRequestProblemInformation 215,PropPayloadFormatIndicator 99,PropContentType +// "\SOM\186\152\249\253\174\186\CAN\222\135K\t\255\172LFGj\ETB)\244\187",PropMessageExpiryInterval +// 30084,PropSubscriptionIdentifier 27,PropUserProperty "&\DC1\230\138\175\196\200\193uD\US>\152P" +// "L}\144\165\175\ENQ\GS=\236u~\136xkm*\DELE\180\ETX\232\&7S\204]%\219",PropWildcardSubscriptionAvailable +// 207,PropTopicAliasMaximum 30302]} TEST(Publish5QCTest, Encode19) { - uint8_t pkt[] = { - 0x33, 0xc1, 0x2, 0x0, 0xf, 0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, 0x4c, 0x93, 0xd3, 0x5c, - 0xf, 0xfe, 0x61, 0xae, 0x9c, 0x2, 0x1a, 0x0, 0x11, 0x50, 0xab, 0xdd, 0xc9, 0x71, 0x43, 0xa8, 0x19, 0x44, - 0xff, 0xdc, 0x40, 0x90, 0xc, 0x67, 0x58, 0xa1, 0x2a, 0xe, 0x18, 0x0, 0x0, 0x70, 0xd1, 0x26, 0x0, 0x1d, - 0x8c, 0xf5, 0xac, 0x52, 0x8e, 0xa3, 0xd6, 0xc, 0x2a, 0x4e, 0x1a, 0x5d, 0xc4, 0xb7, 0xb9, 0x38, 0xf2, 0xc, - 0xed, 0xb8, 0x2b, 0x68, 0x4c, 0xba, 0xfc, 0xb6, 0x7b, 0xa2, 0x34, 0x0, 0x6, 0x6c, 0xac, 0x30, 0x71, 0xa7, - 0x2e, 0x2, 0x0, 0x0, 0x1f, 0x9, 0x2a, 0xfe, 0x22, 0x14, 0x30, 0x27, 0x0, 0x0, 0x47, 0x81, 0x1f, 0x0, - 0x12, 0x10, 0x58, 0x9a, 0x89, 0xd6, 0xbb, 0xca, 0x9b, 0x73, 0x26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xb, 0xc, 0xcf, 0xb5, 0xab, 0x91, 0x84, 0xa6, 0x72, 0x2f, 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; - uint8_t topic_bytes[] = {0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, 0x4c, 0x93, 0xd3, 0x5c, 0xf, 0xfe}; - lwmqtt_string_t topic = {15, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0xd1, 0x1, 0x0, 0x8, 0xdb, 0x44, 0x4c, 0xe6, 0xad, 0x6b, 0x49, 0xc2, 0xb4, 0x1, 0x9, 0x0, + 0xc, 0x11, 0xd0, 0x11, 0xd8, 0x25, 0x26, 0x61, 0x58, 0x10, 0xaf, 0x59, 0xda, 0x2, 0x0, 0x0, 0x67, + 0x95, 0xb, 0x17, 0x2, 0x0, 0x0, 0x3d, 0x72, 0x1, 0xb6, 0x15, 0x0, 0xb, 0xf8, 0x67, 0xc9, 0xe6, + 0x29, 0x6f, 0xa7, 0x9e, 0xaa, 0x10, 0xa9, 0x17, 0xc8, 0x15, 0x0, 0x4, 0xc9, 0x7c, 0x63, 0x53, 0x9, + 0x0, 0x7, 0x21, 0x74, 0x86, 0x4d, 0x40, 0x1a, 0xf1, 0x2, 0x0, 0x0, 0x63, 0xf5, 0x17, 0x23, 0xb, + 0x18, 0x11, 0x0, 0x0, 0xa, 0x9b, 0x24, 0x6b, 0x11, 0x0, 0x0, 0x50, 0x88, 0x11, 0x0, 0x0, 0x5c, + 0xfe, 0x2a, 0xda, 0x28, 0x78, 0x17, 0xd7, 0x1, 0x63, 0x3, 0x0, 0x17, 0xe, 0x4d, 0xba, 0x98, 0xf9, + 0xfd, 0xae, 0xba, 0x18, 0xde, 0x87, 0x4b, 0x9, 0xff, 0xac, 0x4c, 0x46, 0x47, 0x6a, 0x17, 0x29, 0xf4, + 0xbb, 0x2, 0x0, 0x0, 0x75, 0x84, 0xb, 0x1b, 0x26, 0x0, 0xe, 0x26, 0x11, 0xe6, 0x8a, 0xaf, 0xc4, + 0xc8, 0xc1, 0x75, 0x44, 0x1f, 0x3e, 0x98, 0x50, 0x0, 0x1b, 0x4c, 0x7d, 0x90, 0xa5, 0xaf, 0x5, 0x1d, + 0x3d, 0xec, 0x75, 0x7e, 0x88, 0x78, 0x6b, 0x6d, 0x2a, 0x7f, 0x45, 0xb4, 0x3, 0xe8, 0x37, 0x53, 0xcc, + 0x5d, 0x25, 0xdb, 0x28, 0xcf, 0x22, 0x76, 0x5e, 0x6b, 0x40, 0xc0, 0xd0, 0x24, 0xba, 0xad, 0xb, 0xd5, + 0x62, 0x9d, 0xff, 0xce, 0x10, 0xfd, 0x78, 0x43}; + uint8_t topic_bytes[] = {0xdb, 0x44, 0x4c, 0xe6, 0xad, 0x6b, 0x49, 0xc2}; + lwmqtt_string_t topic = {8, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0xcf, 0xb5, 0xab, 0x91, 0x84, 0xa6, 0x72, 0x2f, 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x6b, 0x40, 0xc0, 0xd0, 0x24, 0xba, 0xad, 0xb, 0xd5, + 0x62, 0x9d, 0xff, 0xce, 0x10, 0xfd, 0x78, 0x43}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; - - uint8_t bytesprops0[] = {0x50, 0xab, 0xdd, 0xc9, 0x71, 0x43, 0xa8, 0x19, 0x44, - 0xff, 0xdc, 0x40, 0x90, 0xc, 0x67, 0x58, 0xa1}; - uint8_t bytesprops2[] = {0x6c, 0xac, 0x30, 0x71, 0xa7, 0x2e}; - uint8_t bytesprops1[] = {0x8c, 0xf5, 0xac, 0x52, 0x8e, 0xa3, 0xd6, 0xc, 0x2a, 0x4e, 0x1a, 0x5d, 0xc4, 0xb7, 0xb9, - 0x38, 0xf2, 0xc, 0xed, 0xb8, 0x2b, 0x68, 0x4c, 0xba, 0xfc, 0xb6, 0x7b, 0xa2, 0x34}; - uint8_t bytesprops3[] = {0x10, 0x58, 0x9a, 0x89, 0xd6, 0xbb, 0xca, 0x9b, 0x73, - 0x26, 0x6f, 0xac, 0x41, 0xcc, 0x4c, 0x26, 0x7a, 0x64}; - uint8_t bytesprops4[] = {0x74, 0x12, 0xde, 0xb4, 0xf1, 0x75, 0x11, 0x96, 0xf4, 0x0, 0xb8, 0xb8, 0xab, - 0xce, 0xe7, 0x0, 0xf2, 0x6b, 0xa3, 0x3, 0x4, 0xc4, 0xe0, 0xf8, 0xe0}; - uint8_t bytesprops5[] = {0xdc, 0x75, 0x8b, 0xa9}; - uint8_t bytesprops6[] = {0xc4, 0x5b}; - uint8_t bytesprops8[] = {0x99, 0xbc, 0x46, 0x35, 0xd7, 0xa7, 0xf3, 0x26, 0x50, 0xcf, 0x56, 0x89, - 0xf2, 0x7f, 0x77, 0x80, 0x4d, 0x27, 0xd9, 0xe8, 0x5d, 0x97, 0x2c, 0x54}; - uint8_t bytesprops7[] = {0x3a, 0x40, 0x31, 0x62, 0xb2, 0x17, 0xf9, 0x2c, 0x29, 0x81, - 0xfb, 0xb8, 0x27, 0x58, 0x62, 0xc6, 0x10, 0x52, 0x16}; - uint8_t bytesprops9[] = {0x89, 0xa8, 0x39, 0x7b, 0xe0, 0xef, 0x8a, 0x2b, 0xe2, 0xba, 0x17, 0x7b, - 0xf3, 0x2f, 0xb6, 0x47, 0xef, 0xc5, 0x2f, 0xe4, 0xe6, 0x54, 0x20}; - uint8_t bytesprops10[] = {0xe9, 0x7b, 0xd5, 0xd8, 0x28, 0xdd, 0x96, 0x30, 0x9e, 0xf6, 0x60, 0x75, 0xcb, - 0xc2, 0x69, 0x74, 0xa2, 0x87, 0x33, 0x6e, 0x54, 0xd3, 0x16, 0x5, 0xb3}; + msg.payload_len = 17; + + uint8_t bytesprops0[] = {0x11, 0xd0, 0x11, 0xd8, 0x25, 0x26, 0x61, 0x58, 0x10, 0xaf, 0x59, 0xda}; + uint8_t bytesprops1[] = {0xf8, 0x67, 0xc9, 0xe6, 0x29, 0x6f, 0xa7, 0x9e, 0xaa, 0x10, 0xa9}; + uint8_t bytesprops2[] = {0xc9, 0x7c, 0x63, 0x53}; + uint8_t bytesprops3[] = {0x21, 0x74, 0x86, 0x4d, 0x40, 0x1a, 0xf1}; + uint8_t bytesprops4[] = {0xe, 0x4d, 0xba, 0x98, 0xf9, 0xfd, 0xae, 0xba, 0x18, 0xde, 0x87, 0x4b, + 0x9, 0xff, 0xac, 0x4c, 0x46, 0x47, 0x6a, 0x17, 0x29, 0xf4, 0xbb}; + uint8_t bytesprops6[] = {0x4c, 0x7d, 0x90, 0xa5, 0xaf, 0x5, 0x1d, 0x3d, 0xec, 0x75, 0x7e, 0x88, 0x78, 0x6b, + 0x6d, 0x2a, 0x7f, 0x45, 0xb4, 0x3, 0xe8, 0x37, 0x53, 0xcc, 0x5d, 0x25, 0xdb}; + uint8_t bytesprops5[] = {0x26, 0x11, 0xe6, 0x8a, 0xaf, 0xc4, 0xc8, 0xc1, 0x75, 0x44, 0x1f, 0x3e, 0x98, 0x50}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28881}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7945}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5168}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18305}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1305}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20834}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11673}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops7}, .v = {24, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 267}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5907}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26517}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15730}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {11, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25589}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2715}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20616}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23806}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30084}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops5}, .v = {27, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30302}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 25006, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = -// "\156\\\v`\145\USn?\217L\147\211\\\SI\254", _pubPktID = 25006, _pubBody = -// "\207\181\171\145\132\166r/\NUL\137\195|e\244P\185", _pubProps = [PropResponseInformation -// "P\171\221\201qC\168\EMD\255\220@\144\fgX\161",PropSharedSubscriptionAvailable 14,PropWillDelayInterval -// 28881,PropUserProperty "\140\245\172R\142\163\214\f*N\SUB]\196\183\185\&8\242\f\237\184+hL\186\252\182{\162\&4" -// "l\172\&0q\167.",PropMessageExpiryInterval 7945,PropSharedSubscriptionAvailable 254,PropTopicAliasMaximum -// 5168,PropMaximumPacketSize 18305,PropReasonString "\DLEX\154\137\214\187\202\155s&o\172A\204L&zd",PropServerReference -// "t\DC2\222\180\241u\DC1\150\244\NUL\184\184\171\206\231\NUL\242k\163\ETX\EOT\196\224\248\224",PropSubscriptionIdentifierAvailable -// 196,PropMaximumPacketSize 1305,PropSubscriptionIdentifier 26,PropMessageExpiryInterval -// 20834,PropWildcardSubscriptionAvailable 162,PropSubscriptionIdentifier 5,PropAuthenticationMethod -// "\220u\139\169",PropReasonString "\196[",PropSessionExpiryInterval 11673,PropUserProperty -// ":@1b\178\ETB\249,)\129\251\184'Xb\198\DLER\SYN" -// "\153\188F5\215\167\243&P\207V\137\242\DELw\128M'\217\232]\151,T",PropSubscriptionIdentifier -// 16,PropWildcardSubscriptionAvailable 109,PropContentType -// "\137\168\&9{\224\239\138+\226\186\ETB{\243/\182G\239\197/\228\230T ",PropMessageExpiryInterval -// 267,PropMessageExpiryInterval 5907,PropResponseTopic -// "\233{\213\216(\221\150\&0\158\246`u\203\194it\162\135\&3nT\211\SYN\ENQ\179",PropSubscriptionIdentifier 12]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "\219DL\230\173kI\194", _pubPktID = +// 0, _pubBody = "k@\192\208$\186\173\v\213b\157\255\206\DLE\253xC", _pubProps = [PropCorrelationData +// "\DC1\208\DC1\216%&aX\DLE\175Y\218",PropMessageExpiryInterval 26517,PropSubscriptionIdentifier +// 23,PropMessageExpiryInterval 15730,PropPayloadFormatIndicator 182,PropAuthenticationMethod +// "\248g\201\230)o\167\158\170\DLE\169",PropRequestProblemInformation 200,PropAuthenticationMethod +// "\201|cS",PropCorrelationData "!t\134M@\SUB\241",PropMessageExpiryInterval 25589,PropRequestProblemInformation +// 35,PropSubscriptionIdentifier 24,PropSessionExpiryInterval 2715,PropMaximumQoS 107,PropSessionExpiryInterval +// 20616,PropSessionExpiryInterval 23806,PropSharedSubscriptionAvailable 218,PropWildcardSubscriptionAvailable +// 120,PropRequestProblemInformation 215,PropPayloadFormatIndicator 99,PropContentType +// "\SOM\186\152\249\253\174\186\CAN\222\135K\t\255\172LFGj\ETB)\244\187",PropMessageExpiryInterval +// 30084,PropSubscriptionIdentifier 27,PropUserProperty "&\DC1\230\138\175\196\200\193uD\US>\152P" +// "L}\144\165\175\ENQ\GS=\236u~\136xkm*\DELE\180\ETX\232\&7S\204]%\219",PropWildcardSubscriptionAvailable +// 207,PropTopicAliasMaximum 30302]} TEST(Publish5QCTest, Decode19) { - uint8_t pkt[] = { - 0x33, 0xc1, 0x2, 0x0, 0xf, 0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, 0x4c, 0x93, 0xd3, 0x5c, - 0xf, 0xfe, 0x61, 0xae, 0x9c, 0x2, 0x1a, 0x0, 0x11, 0x50, 0xab, 0xdd, 0xc9, 0x71, 0x43, 0xa8, 0x19, 0x44, - 0xff, 0xdc, 0x40, 0x90, 0xc, 0x67, 0x58, 0xa1, 0x2a, 0xe, 0x18, 0x0, 0x0, 0x70, 0xd1, 0x26, 0x0, 0x1d, - 0x8c, 0xf5, 0xac, 0x52, 0x8e, 0xa3, 0xd6, 0xc, 0x2a, 0x4e, 0x1a, 0x5d, 0xc4, 0xb7, 0xb9, 0x38, 0xf2, 0xc, - 0xed, 0xb8, 0x2b, 0x68, 0x4c, 0xba, 0xfc, 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0x47, 0x6a, 0x17, 0x29, 0xf4, + 0xbb, 0x2, 0x0, 0x0, 0x75, 0x84, 0xb, 0x1b, 0x26, 0x0, 0xe, 0x26, 0x11, 0xe6, 0x8a, 0xaf, 0xc4, + 0xc8, 0xc1, 0x75, 0x44, 0x1f, 0x3e, 0x98, 0x50, 0x0, 0x1b, 0x4c, 0x7d, 0x90, 0xa5, 0xaf, 0x5, 0x1d, + 0x3d, 0xec, 0x75, 0x7e, 0x88, 0x78, 0x6b, 0x6d, 0x2a, 0x7f, 0x45, 0xb4, 0x3, 0xe8, 0x37, 0x53, 0xcc, + 0x5d, 0x25, 0xdb, 0x28, 0xcf, 0x22, 0x76, 0x5e, 0x6b, 0x40, 0xc0, 0xd0, 0x24, 0xba, 0xad, 0xb, 0xd5, + 0x62, 0x9d, 0xff, 0xce, 0x10, 0xfd, 0x78, 0x43}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4077,134 +3936,105 @@ TEST(Publish5QCTest, Decode19) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x9c, 0x5c, 0xb, 0x60, 0x91, 0x1f, 0x6e, 0x3f, 0xd9, 0x4c, 0x93, 0xd3, 0x5c, 0xf, 0xfe}; - lwmqtt_string_t exp_topic = {15, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xcf, 0xb5, 0xab, 0x91, 0x84, 0xa6, 0x72, 0x2f, - 0x0, 0x89, 0xc3, 0x7c, 0x65, 0xf4, 0x50, 0xb9}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 25006); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 15); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + uint8_t exp_topic_bytes[] = {0xdb, 0x44, 0x4c, 0xe6, 0xad, 0x6b, 0x49, 0xc2}; + lwmqtt_string_t exp_topic = {8, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x6b, 0x40, 0xc0, 0xd0, 0x24, 0xba, 0xad, 0xb, 0xd5, + 0x62, 0x9d, 0xff, 0xce, 0x10, 0xfd, 0x78, 0x43}; + lwmqtt_string_t exp_body = {17, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 8); + EXPECT_EQ(msg.payload_len, 17); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 17); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\239p\183", _pubPktID = 0, _pubBody -// = "\STX\249\&8\215\vJ\163\136\174\235\187\163\ESCJ(\246", _pubProps = [PropResponseInformation -// "\235SGi\157",PropMaximumQoS 13,PropTopicAliasMaximum 11062,PropRetainAvailable 5,PropContentType -// "\225T\209m5\145\241\225\244VH\131\192",PropServerReference -// "\147\213\137%\253\130\240A~=\245\208KQ\252\225\170\182\237\162x\",\\",PropTopicAliasMaximum -// 4266,PropAuthenticationMethod "T\237o\195;\130\&2/",PropSubscriptionIdentifier 26,PropSharedSubscriptionAvailable -// 217,PropMessageExpiryInterval 25018,PropReasonString "\171%",PropSubscriptionIdentifier 12,PropTopicAlias -// 23933,PropServerKeepAlive 18136,PropReasonString -// "\f\141$cR\131\&2f6\157\157R\SO`\238-\f\245m\221\&2\DC1\128C\182\143\250",PropAuthenticationData -// "{\197\227\&1\ETB\SYN\GS\190l\243",PropContentType -// "\245>C;\130\233{R\215\DLED\226K",PropWildcardSubscriptionAvailable 158,PropMessageExpiryInterval -// 14738,PropRequestResponseInformation 28,PropMaximumPacketSize 12465,PropMaximumQoS 234,PropReceiveMaximum -// 4522,PropPayloadFormatIndicator 153,PropTopicAlias 5567,PropRetainAvailable 217]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "{\153\DLEV", _pubPktID = 16334, +// _pubBody = "\SI\238\166\129\190\133\&2k\213\ETBtC\246", _pubProps = [PropMessageExpiryInterval +// 18569,PropResponseTopic "\179\208\211\237\203\142B\EM^\\o]\148\241\&7\204]",PropPayloadFormatIndicator +// 46,PropAuthenticationMethod +// "o??\237\250\155\151\fl`#\b\229\243\221\185\208\237\136\215\&7\217$",PropPayloadFormatIndicator 8,PropMaximumQoS +// 229,PropRequestProblemInformation 140,PropReasonString +// "\228\234\254\154g\192\191\232\t\188V\218M\189\172R\185\203(\196",PropUserProperty +// "\158;0|\DC1e/\228\142\157BG\198H\193\142c\234\NULb\179`\169" "#6x1\245}eK\205~\254\ACKG\CAN`\242",PropMaximumQoS +// 232]} TEST(Publish5QCTest, Encode20) { - uint8_t pkt[] = { - 0x31, 0xca, 0x1, 0x0, 0x3, 0xef, 0x70, 0xb7, 0xb3, 0x1, 0x1a, 0x0, 0x5, 0xeb, 0x53, 0x47, 0x69, 0x9d, 0x24, - 0xd, 0x22, 0x2b, 0x36, 0x25, 0x5, 0x3, 0x0, 0xd, 0xe1, 0x54, 0xd1, 0x6d, 0x35, 0x91, 0xf1, 0xe1, 0xf4, 0x56, - 0x48, 0x83, 0xc0, 0x1c, 0x0, 0x18, 0x93, 0xd5, 0x89, 0x25, 0xfd, 0x82, 0xf0, 0x41, 0x7e, 0x3d, 0xf5, 0xd0, 0x4b, - 0x51, 0xfc, 0xe1, 0xaa, 0xb6, 0xed, 0xa2, 0x78, 0x22, 0x2c, 0x5c, 0x22, 0x10, 0xaa, 0x15, 0x0, 0x8, 0x54, 0xed, - 0x6f, 0xc3, 0x3b, 0x82, 0x32, 0x2f, 0xb, 0x1a, 0x2a, 0xd9, 0x2, 0x0, 0x0, 0x61, 0xba, 0x1f, 0x0, 0x2, 0xab, - 0x25, 0xb, 0xc, 0x23, 0x5d, 0x7d, 0x13, 0x46, 0xd8, 0x1f, 0x0, 0x1b, 0xc, 0x8d, 0x24, 0x63, 0x52, 0x83, 0x32, - 0x66, 0x36, 0x9d, 0x9d, 0x52, 0xe, 0x60, 0xee, 0x2d, 0xc, 0xf5, 0x6d, 0xdd, 0x32, 0x11, 0x80, 0x43, 0xb6, 0x8f, - 0xfa, 0x16, 0x0, 0xa, 0x7b, 0xc5, 0xe3, 0x31, 0x17, 0x16, 0x1d, 0xbe, 0x6c, 0xf3, 0x3, 0x0, 0xd, 0xf5, 0x3e, - 0x43, 0x3b, 0x82, 0xe9, 0x7b, 0x52, 0xd7, 0x10, 0x44, 0xe2, 0x4b, 0x28, 0x9e, 0x2, 0x0, 0x0, 0x39, 0x92, 0x19, - 0x1c, 0x27, 0x0, 0x0, 0x30, 0xb1, 0x24, 0xea, 0x21, 0x11, 0xaa, 0x1, 0x99, 0x23, 0x15, 0xbf, 0x25, 0xd9, 0x2, - 0xf9, 0x38, 0xd7, 0xb, 0x4a, 0xa3, 0x88, 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; - uint8_t topic_bytes[] = {0xef, 0x70, 0xb7}; - lwmqtt_string_t topic = {3, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x97, 0x1, 0x0, 0x4, 0x7b, 0x99, 0x10, 0x56, 0x3f, 0xce, 0x80, 0x1, 0x2, 0x0, 0x0, + 0x48, 0x89, 0x8, 0x0, 0x11, 0xb3, 0xd0, 0xd3, 0xed, 0xcb, 0x8e, 0x42, 0x19, 0x5e, 0x5c, 0x6f, + 0x5d, 0x94, 0xf1, 0x37, 0xcc, 0x5d, 0x1, 0x2e, 0x15, 0x0, 0x17, 0x6f, 0x3f, 0x3f, 0xed, 0xfa, + 0x9b, 0x97, 0xc, 0x6c, 0x60, 0x23, 0x8, 0xe5, 0xf3, 0xdd, 0xb9, 0xd0, 0xed, 0x88, 0xd7, 0x37, + 0xd9, 0x24, 0x1, 0x8, 0x24, 0xe5, 0x17, 0x8c, 0x1f, 0x0, 0x14, 0xe4, 0xea, 0xfe, 0x9a, 0x67, + 0xc0, 0xbf, 0xe8, 0x9, 0xbc, 0x56, 0xda, 0x4d, 0xbd, 0xac, 0x52, 0xb9, 0xcb, 0x28, 0xc4, 0x26, + 0x0, 0x17, 0x9e, 0x3b, 0x30, 0x7c, 0x11, 0x65, 0x2f, 0xe4, 0x8e, 0x9d, 0x42, 0x47, 0xc6, 0x48, + 0xc1, 0x8e, 0x63, 0xea, 0x0, 0x62, 0xb3, 0x60, 0xa9, 0x0, 0x10, 0x23, 0x36, 0x78, 0x31, 0xf5, + 0x7d, 0x65, 0x4b, 0xcd, 0x7e, 0xfe, 0x6, 0x47, 0x18, 0x60, 0xf2, 0x24, 0xe8, 0xf, 0xee, 0xa6, + 0x81, 0xbe, 0x85, 0x32, 0x6b, 0xd5, 0x17, 0x74, 0x43, 0xf6}; + uint8_t topic_bytes[] = {0x7b, 0x99, 0x10, 0x56}; + lwmqtt_string_t topic = {4, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x2, 0xf9, 0x38, 0xd7, 0xb, 0x4a, 0xa3, 0x88, 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xf, 0xee, 0xa6, 0x81, 0xbe, 0x85, 0x32, 0x6b, 0xd5, 0x17, 0x74, 0x43, 0xf6}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 16; + msg.payload_len = 13; - uint8_t bytesprops0[] = {0xeb, 0x53, 0x47, 0x69, 0x9d}; - uint8_t bytesprops1[] = {0xe1, 0x54, 0xd1, 0x6d, 0x35, 0x91, 0xf1, 0xe1, 0xf4, 0x56, 0x48, 0x83, 0xc0}; - uint8_t bytesprops2[] = {0x93, 0xd5, 0x89, 0x25, 0xfd, 0x82, 0xf0, 0x41, 0x7e, 0x3d, 0xf5, 0xd0, - 0x4b, 0x51, 0xfc, 0xe1, 0xaa, 0xb6, 0xed, 0xa2, 0x78, 0x22, 0x2c, 0x5c}; - uint8_t bytesprops3[] = {0x54, 0xed, 0x6f, 0xc3, 0x3b, 0x82, 0x32, 0x2f}; - uint8_t bytesprops4[] = {0xab, 0x25}; - uint8_t bytesprops5[] = {0xc, 0x8d, 0x24, 0x63, 0x52, 0x83, 0x32, 0x66, 0x36, 0x9d, 0x9d, 0x52, 0xe, 0x60, - 0xee, 0x2d, 0xc, 0xf5, 0x6d, 0xdd, 0x32, 0x11, 0x80, 0x43, 0xb6, 0x8f, 0xfa}; - uint8_t bytesprops6[] = {0x7b, 0xc5, 0xe3, 0x31, 0x17, 0x16, 0x1d, 0xbe, 0x6c, 0xf3}; - uint8_t bytesprops7[] = {0xf5, 0x3e, 0x43, 0x3b, 0x82, 0xe9, 0x7b, 0x52, 0xd7, 0x10, 0x44, 0xe2, 0x4b}; + uint8_t bytesprops0[] = {0xb3, 0xd0, 0xd3, 0xed, 0xcb, 0x8e, 0x42, 0x19, 0x5e, + 0x5c, 0x6f, 0x5d, 0x94, 0xf1, 0x37, 0xcc, 0x5d}; + uint8_t bytesprops1[] = {0x6f, 0x3f, 0x3f, 0xed, 0xfa, 0x9b, 0x97, 0xc, 0x6c, 0x60, 0x23, 0x8, + 0xe5, 0xf3, 0xdd, 0xb9, 0xd0, 0xed, 0x88, 0xd7, 0x37, 0xd9, 0x24}; + uint8_t bytesprops2[] = {0xe4, 0xea, 0xfe, 0x9a, 0x67, 0xc0, 0xbf, 0xe8, 0x9, 0xbc, + 0x56, 0xda, 0x4d, 0xbd, 0xac, 0x52, 0xb9, 0xcb, 0x28, 0xc4}; + uint8_t bytesprops4[] = {0x23, 0x36, 0x78, 0x31, 0xf5, 0x7d, 0x65, 0x4b, + 0xcd, 0x7e, 0xfe, 0x6, 0x47, 0x18, 0x60, 0xf2}; + uint8_t bytesprops3[] = {0x9e, 0x3b, 0x30, 0x7c, 0x11, 0x65, 0x2f, 0xe4, 0x8e, 0x9d, 0x42, 0x47, + 0xc6, 0x48, 0xc1, 0x8e, 0x63, 0xea, 0x0, 0x62, 0xb3, 0x60, 0xa9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11062}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4266}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25018}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23933}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18136}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14738}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12465}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4522}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5567}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18569}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops3}, .v = {16, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 232}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 16334, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "\239p\183", _pubPktID = 0, _pubBody -// = "\STX\249\&8\215\vJ\163\136\174\235\187\163\ESCJ(\246", _pubProps = [PropResponseInformation -// "\235SGi\157",PropMaximumQoS 13,PropTopicAliasMaximum 11062,PropRetainAvailable 5,PropContentType -// "\225T\209m5\145\241\225\244VH\131\192",PropServerReference -// "\147\213\137%\253\130\240A~=\245\208KQ\252\225\170\182\237\162x\",\\",PropTopicAliasMaximum -// 4266,PropAuthenticationMethod "T\237o\195;\130\&2/",PropSubscriptionIdentifier 26,PropSharedSubscriptionAvailable -// 217,PropMessageExpiryInterval 25018,PropReasonString "\171%",PropSubscriptionIdentifier 12,PropTopicAlias -// 23933,PropServerKeepAlive 18136,PropReasonString -// "\f\141$cR\131\&2f6\157\157R\SO`\238-\f\245m\221\&2\DC1\128C\182\143\250",PropAuthenticationData -// "{\197\227\&1\ETB\SYN\GS\190l\243",PropContentType -// "\245>C;\130\233{R\215\DLED\226K",PropWildcardSubscriptionAvailable 158,PropMessageExpiryInterval -// 14738,PropRequestResponseInformation 28,PropMaximumPacketSize 12465,PropMaximumQoS 234,PropReceiveMaximum -// 4522,PropPayloadFormatIndicator 153,PropTopicAlias 5567,PropRetainAvailable 217]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "{\153\DLEV", _pubPktID = 16334, +// _pubBody = "\SI\238\166\129\190\133\&2k\213\ETBtC\246", _pubProps = [PropMessageExpiryInterval +// 18569,PropResponseTopic "\179\208\211\237\203\142B\EM^\\o]\148\241\&7\204]",PropPayloadFormatIndicator +// 46,PropAuthenticationMethod +// "o??\237\250\155\151\fl`#\b\229\243\221\185\208\237\136\215\&7\217$",PropPayloadFormatIndicator 8,PropMaximumQoS +// 229,PropRequestProblemInformation 140,PropReasonString +// "\228\234\254\154g\192\191\232\t\188V\218M\189\172R\185\203(\196",PropUserProperty +// "\158;0|\DC1e/\228\142\157BG\198H\193\142c\234\NULb\179`\169" "#6x1\245}eK\205~\254\ACKG\CAN`\242",PropMaximumQoS +// 232]} TEST(Publish5QCTest, Decode20) { - uint8_t pkt[] = { - 0x31, 0xca, 0x1, 0x0, 0x3, 0xef, 0x70, 0xb7, 0xb3, 0x1, 0x1a, 0x0, 0x5, 0xeb, 0x53, 0x47, 0x69, 0x9d, 0x24, - 0xd, 0x22, 0x2b, 0x36, 0x25, 0x5, 0x3, 0x0, 0xd, 0xe1, 0x54, 0xd1, 0x6d, 0x35, 0x91, 0xf1, 0xe1, 0xf4, 0x56, - 0x48, 0x83, 0xc0, 0x1c, 0x0, 0x18, 0x93, 0xd5, 0x89, 0x25, 0xfd, 0x82, 0xf0, 0x41, 0x7e, 0x3d, 0xf5, 0xd0, 0x4b, - 0x51, 0xfc, 0xe1, 0xaa, 0xb6, 0xed, 0xa2, 0x78, 0x22, 0x2c, 0x5c, 0x22, 0x10, 0xaa, 0x15, 0x0, 0x8, 0x54, 0xed, - 0x6f, 0xc3, 0x3b, 0x82, 0x32, 0x2f, 0xb, 0x1a, 0x2a, 0xd9, 0x2, 0x0, 0x0, 0x61, 0xba, 0x1f, 0x0, 0x2, 0xab, - 0x25, 0xb, 0xc, 0x23, 0x5d, 0x7d, 0x13, 0x46, 0xd8, 0x1f, 0x0, 0x1b, 0xc, 0x8d, 0x24, 0x63, 0x52, 0x83, 0x32, - 0x66, 0x36, 0x9d, 0x9d, 0x52, 0xe, 0x60, 0xee, 0x2d, 0xc, 0xf5, 0x6d, 0xdd, 0x32, 0x11, 0x80, 0x43, 0xb6, 0x8f, - 0xfa, 0x16, 0x0, 0xa, 0x7b, 0xc5, 0xe3, 0x31, 0x17, 0x16, 0x1d, 0xbe, 0x6c, 0xf3, 0x3, 0x0, 0xd, 0xf5, 0x3e, - 0x43, 0x3b, 0x82, 0xe9, 0x7b, 0x52, 0xd7, 0x10, 0x44, 0xe2, 0x4b, 0x28, 0x9e, 0x2, 0x0, 0x0, 0x39, 0x92, 0x19, - 0x1c, 0x27, 0x0, 0x0, 0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; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4213,102 +4043,95 @@ TEST(Publish5QCTest, Decode20) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xef, 0x70, 0xb7}; - lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x2, 0xf9, 0x38, 0xd7, 0xb, 0x4a, 0xa3, 0x88, - 0xae, 0xeb, 0xbb, 0xa3, 0x1b, 0x4a, 0x28, 0xf6}; - lwmqtt_string_t exp_body = {16, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); - EXPECT_EQ(msg.payload_len, 16); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 16); + uint8_t exp_topic_bytes[] = {0x7b, 0x99, 0x10, 0x56}; + lwmqtt_string_t exp_topic = {4, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xf, 0xee, 0xa6, 0x81, 0xbe, 0x85, 0x32, 0x6b, 0xd5, 0x17, 0x74, 0x43, 0xf6}; + lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 16334); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 4); + EXPECT_EQ(msg.payload_len, 13); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[\133\227z\244\DC4 -// \\\241\207F|\141\128?F\t\249\DC2\DELs\245", _pubPktID = 23725, _pubBody = ";\229\241\239\169\193\152\160\149\FSQ", -// _pubProps = [PropTopicAliasMaximum 30663,PropContentType "\SIl|\n#E\186\&9^",PropTopicAliasMaximum -// 28043,PropResponseTopic "\150 ",PropSharedSubscriptionAvailable 110,PropAuthenticationMethod -// "\241",PropTopicAliasMaximum 11571,PropRetainAvailable 10,PropPayloadFormatIndicator 44,PropMaximumQoS -// 227,PropCorrelationData "M \206)\128]",PropMaximumQoS 68,PropMessageExpiryInterval 13477,PropContentType -// "\230\&8\192\175Y\255\&9\190\218inU\216",PropMaximumPacketSize 25908,PropSubscriptionIdentifierAvailable -// 248,PropSharedSubscriptionAvailable 222]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\239\241 \154( +// \247t\"\246\ENQ\203\252\206\225\196\148\STX\222\"(\255\US}\194\188\172", _pubPktID = 17850, _pubBody = +// "\232#X\SOHr.\129\NAK\155\247c\170\231\193Y\254\ESC\ETX\216\&4\235\253EV@\ETB", _pubProps = [PropTopicAlias +// 11489,PropMaximumPacketSize 27845,PropMaximumPacketSize 26653,PropAssignedClientIdentifier +// "",PropRequestResponseInformation 165,PropResponseInformation "e>'u\164\222",PropTopicAlias +// 19084,PropWillDelayInterval 7069,PropSubscriptionIdentifier 15,PropRetainAvailable 51,PropRequestProblemInformation +// 61,PropServerKeepAlive 30133,PropTopicAliasMaximum 3576,PropPayloadFormatIndicator 207,PropRequestProblemInformation +// 46]} TEST(Publish5QCTest, Encode21) { - uint8_t pkt[] = {0x33, 0x75, 0x0, 0x16, 0x5b, 0x85, 0xe3, 0x7a, 0xf4, 0x14, 0x20, 0x5c, 0xf1, 0xcf, 0x46, - 0x7c, 0x8d, 0x80, 0x3f, 0x46, 0x9, 0xf9, 0x12, 0x7f, 0x73, 0xf5, 0x5c, 0xad, 0x4f, 0x22, - 0x77, 0xc7, 0x3, 0x0, 0x9, 0xf, 0x6c, 0x7c, 0xa, 0x23, 0x45, 0xba, 0x39, 0x5e, 0x22, - 0x6d, 0x8b, 0x8, 0x0, 0x2, 0x96, 0x20, 0x2a, 0x6e, 0x15, 0x0, 0x1, 0xf1, 0x22, 0x2d, - 0x33, 0x25, 0xa, 0x1, 0x2c, 0x24, 0xe3, 0x9, 0x0, 0x6, 0x4d, 0x20, 0xce, 0x29, 0x80, - 0x5d, 0x24, 0x44, 0x2, 0x0, 0x0, 0x34, 0xa5, 0x3, 0x0, 0xd, 0xe6, 0x38, 0xc0, 0xaf, - 0x59, 0xff, 0x39, 0xbe, 0xda, 0x69, 0x6e, 0x55, 0xd8, 0x27, 0x0, 0x0, 0x65, 0x34, 0x29, - 0xf8, 0x2a, 0xde, 0x3b, 0xe5, 0xf1, 0xef, 0xa9, 0xc1, 0x98, 0xa0, 0x95, 0x1c, 0x51}; - uint8_t topic_bytes[] = {0x5b, 0x85, 0xe3, 0x7a, 0xf4, 0x14, 0x20, 0x5c, 0xf1, 0xcf, 0x46, - 0x7c, 0x8d, 0x80, 0x3f, 0x46, 0x9, 0xf9, 0x12, 0x7f, 0x73, 0xf5}; - lwmqtt_string_t topic = {22, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3c, 0x6d, 0x0, 0x1b, 0xef, 0xf1, 0x20, 0x9a, 0x28, 0x20, 0xf7, 0x74, 0x22, 0xf6, 0x5, 0xcb, + 0xfc, 0xce, 0xe1, 0xc4, 0x94, 0x2, 0xde, 0x22, 0x28, 0xff, 0x1f, 0x7d, 0xc2, 0xbc, 0xac, 0x45, + 0xba, 0x33, 0x23, 0x2c, 0xe1, 0x27, 0x0, 0x0, 0x6c, 0xc5, 0x27, 0x0, 0x0, 0x68, 0x1d, 0x12, + 0x0, 0x0, 0x19, 0xa5, 0x1a, 0x0, 0x6, 0x65, 0x3e, 0x27, 0x75, 0xa4, 0xde, 0x23, 0x4a, 0x8c, + 0x18, 0x0, 0x0, 0x1b, 0x9d, 0xb, 0xf, 0x25, 0x33, 0x17, 0x3d, 0x13, 0x75, 0xb5, 0x22, 0xd, + 0xf8, 0x1, 0xcf, 0x17, 0x2e, 0xe8, 0x23, 0x58, 0x1, 0x72, 0x2e, 0x81, 0x15, 0x9b, 0xf7, 0x63, + 0xaa, 0xe7, 0xc1, 0x59, 0xfe, 0x1b, 0x3, 0xd8, 0x34, 0xeb, 0xfd, 0x45, 0x56, 0x40, 0x17}; + uint8_t topic_bytes[] = {0xef, 0xf1, 0x20, 0x9a, 0x28, 0x20, 0xf7, 0x74, 0x22, 0xf6, 0x5, 0xcb, 0xfc, 0xce, + 0xe1, 0xc4, 0x94, 0x2, 0xde, 0x22, 0x28, 0xff, 0x1f, 0x7d, 0xc2, 0xbc, 0xac}; + lwmqtt_string_t topic = {27, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS1; - msg.retained = true; - uint8_t msg_bytes[] = {0x3b, 0xe5, 0xf1, 0xef, 0xa9, 0xc1, 0x98, 0xa0, 0x95, 0x1c, 0x51}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xe8, 0x23, 0x58, 0x1, 0x72, 0x2e, 0x81, 0x15, 0x9b, 0xf7, 0x63, 0xaa, 0xe7, + 0xc1, 0x59, 0xfe, 0x1b, 0x3, 0xd8, 0x34, 0xeb, 0xfd, 0x45, 0x56, 0x40, 0x17}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 11; + msg.payload_len = 26; - uint8_t bytesprops0[] = {0xf, 0x6c, 0x7c, 0xa, 0x23, 0x45, 0xba, 0x39, 0x5e}; - uint8_t bytesprops1[] = {0x96, 0x20}; - uint8_t bytesprops2[] = {0xf1}; - uint8_t bytesprops3[] = {0x4d, 0x20, 0xce, 0x29, 0x80, 0x5d}; - uint8_t bytesprops4[] = {0xe6, 0x38, 0xc0, 0xaf, 0x59, 0xff, 0x39, 0xbe, 0xda, 0x69, 0x6e, 0x55, 0xd8}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x65, 0x3e, 0x27, 0x75, 0xa4, 0xde}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30663}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28043}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11571}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13477}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25908}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11489}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27845}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26653}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19084}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7069}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 51}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 61}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30133}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3576}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 23725, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 17850, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "[\133\227z\244\DC4 -// \\\241\207F|\141\128?F\t\249\DC2\DELs\245", _pubPktID = 23725, _pubBody = ";\229\241\239\169\193\152\160\149\FSQ", -// _pubProps = [PropTopicAliasMaximum 30663,PropContentType "\SIl|\n#E\186\&9^",PropTopicAliasMaximum -// 28043,PropResponseTopic "\150 ",PropSharedSubscriptionAvailable 110,PropAuthenticationMethod -// "\241",PropTopicAliasMaximum 11571,PropRetainAvailable 10,PropPayloadFormatIndicator 44,PropMaximumQoS -// 227,PropCorrelationData "M \206)\128]",PropMaximumQoS 68,PropMessageExpiryInterval 13477,PropContentType -// "\230\&8\192\175Y\255\&9\190\218inU\216",PropMaximumPacketSize 25908,PropSubscriptionIdentifierAvailable -// 248,PropSharedSubscriptionAvailable 222]} +// PublishRequest {_pubDup = True, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "\239\241 \154( +// \247t\"\246\ENQ\203\252\206\225\196\148\STX\222\"(\255\US}\194\188\172", _pubPktID = 17850, _pubBody = +// "\232#X\SOHr.\129\NAK\155\247c\170\231\193Y\254\ESC\ETX\216\&4\235\253EV@\ETB", _pubProps = [PropTopicAlias +// 11489,PropMaximumPacketSize 27845,PropMaximumPacketSize 26653,PropAssignedClientIdentifier +// "",PropRequestResponseInformation 165,PropResponseInformation "e>'u\164\222",PropTopicAlias +// 19084,PropWillDelayInterval 7069,PropSubscriptionIdentifier 15,PropRetainAvailable 51,PropRequestProblemInformation +// 61,PropServerKeepAlive 30133,PropTopicAliasMaximum 3576,PropPayloadFormatIndicator 207,PropRequestProblemInformation +// 46]} TEST(Publish5QCTest, Decode21) { - uint8_t pkt[] = {0x33, 0x75, 0x0, 0x16, 0x5b, 0x85, 0xe3, 0x7a, 0xf4, 0x14, 0x20, 0x5c, 0xf1, 0xcf, 0x46, - 0x7c, 0x8d, 0x80, 0x3f, 0x46, 0x9, 0xf9, 0x12, 0x7f, 0x73, 0xf5, 0x5c, 0xad, 0x4f, 0x22, - 0x77, 0xc7, 0x3, 0x0, 0x9, 0xf, 0x6c, 0x7c, 0xa, 0x23, 0x45, 0xba, 0x39, 0x5e, 0x22, - 0x6d, 0x8b, 0x8, 0x0, 0x2, 0x96, 0x20, 0x2a, 0x6e, 0x15, 0x0, 0x1, 0xf1, 0x22, 0x2d, - 0x33, 0x25, 0xa, 0x1, 0x2c, 0x24, 0xe3, 0x9, 0x0, 0x6, 0x4d, 0x20, 0xce, 0x29, 0x80, - 0x5d, 0x24, 0x44, 0x2, 0x0, 0x0, 0x34, 0xa5, 0x3, 0x0, 0xd, 0xe6, 0x38, 0xc0, 0xaf, - 0x59, 0xff, 0x39, 0xbe, 0xda, 0x69, 0x6e, 0x55, 0xd8, 0x27, 0x0, 0x0, 0x65, 0x34, 0x29, - 0xf8, 0x2a, 0xde, 0x3b, 0xe5, 0xf1, 0xef, 0xa9, 0xc1, 0x98, 0xa0, 0x95, 0x1c, 0x51}; + uint8_t pkt[] = {0x3c, 0x6d, 0x0, 0x1b, 0xef, 0xf1, 0x20, 0x9a, 0x28, 0x20, 0xf7, 0x74, 0x22, 0xf6, 0x5, 0xcb, + 0xfc, 0xce, 0xe1, 0xc4, 0x94, 0x2, 0xde, 0x22, 0x28, 0xff, 0x1f, 0x7d, 0xc2, 0xbc, 0xac, 0x45, + 0xba, 0x33, 0x23, 0x2c, 0xe1, 0x27, 0x0, 0x0, 0x6c, 0xc5, 0x27, 0x0, 0x0, 0x68, 0x1d, 0x12, + 0x0, 0x0, 0x19, 0xa5, 0x1a, 0x0, 0x6, 0x65, 0x3e, 0x27, 0x75, 0xa4, 0xde, 0x23, 0x4a, 0x8c, + 0x18, 0x0, 0x0, 0x1b, 0x9d, 0xb, 0xf, 0x25, 0x33, 0x17, 0x3d, 0x13, 0x75, 0xb5, 0x22, 0xd, + 0xf8, 0x1, 0xcf, 0x17, 0x2e, 0xe8, 0x23, 0x58, 0x1, 0x72, 0x2e, 0x81, 0x15, 0x9b, 0xf7, 0x63, + 0xaa, 0xe7, 0xc1, 0x59, 0xfe, 0x1b, 0x3, 0xd8, 0x34, 0xeb, 0xfd, 0x45, 0x56, 0x40, 0x17}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4317,146 +4140,82 @@ TEST(Publish5QCTest, Decode21) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x5b, 0x85, 0xe3, 0x7a, 0xf4, 0x14, 0x20, 0x5c, 0xf1, 0xcf, 0x46, - 0x7c, 0x8d, 0x80, 0x3f, 0x46, 0x9, 0xf9, 0x12, 0x7f, 0x73, 0xf5}; - lwmqtt_string_t exp_topic = {22, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x3b, 0xe5, 0xf1, 0xef, 0xa9, 0xc1, 0x98, 0xa0, 0x95, 0x1c, 0x51}; - lwmqtt_string_t exp_body = {11, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS1); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 23725); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 22); - EXPECT_EQ(msg.payload_len, 11); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 11); + uint8_t exp_topic_bytes[] = {0xef, 0xf1, 0x20, 0x9a, 0x28, 0x20, 0xf7, 0x74, 0x22, 0xf6, 0x5, 0xcb, 0xfc, 0xce, + 0xe1, 0xc4, 0x94, 0x2, 0xde, 0x22, 0x28, 0xff, 0x1f, 0x7d, 0xc2, 0xbc, 0xac}; + lwmqtt_string_t exp_topic = {27, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xe8, 0x23, 0x58, 0x1, 0x72, 0x2e, 0x81, 0x15, 0x9b, 0xf7, 0x63, 0xaa, 0xe7, + 0xc1, 0x59, 0xfe, 0x1b, 0x3, 0xd8, 0x34, 0xeb, 0xfd, 0x45, 0x56, 0x40, 0x17}; + lwmqtt_string_t exp_body = {26, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 17850); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 26); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 26); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "D\SO\EOTH\207S\243\176T\n\246\234'~^\ETBtz\220X", _pubPktID = 0, _pubBody = -// "\179>\ENQUu\215k\216\ETX\201m\DC2\251\&2\ETB\187m\200\248\140{\n8", _pubProps = [PropServerReference -// "\DLEE>i\167+\232\177\165\211\CAN\162F4\143*\251\GS\206",PropReceiveMaximum 15189,PropAuthenticationData -// "{Q\174\191\n\216\188",PropSharedSubscriptionAvailable 244,PropResponseInformation -// "#\175^\233\133\154I\187",PropMessageExpiryInterval 854,PropResponseTopic "\248\245\237n",PropResponseTopic -// "\137a\227ZD\136",PropResponseTopic ")\GS",PropRetainAvailable 56,PropWildcardSubscriptionAvailable -// 220,PropSubscriptionIdentifierAvailable 177,PropMaximumQoS 216,PropReceiveMaximum -// 21295,PropSharedSubscriptionAvailable 193,PropWillDelayInterval 30278,PropSessionExpiryInterval 21047,PropMaximumQoS -// 120,PropWillDelayInterval 18244,PropRequestResponseInformation 191,PropMessageExpiryInterval 24947,PropUserProperty -// "\149\165\NUL\253\137\219\t" -// "\146\DC2\216u\164\ESC\153dVP\b\174v\162~\222\140\204\b\STX\143)\245\243H\241\199\154\216\199",PropAuthenticationData -// "c\203\158",PropSubscriptionIdentifierAvailable 114,PropSubscriptionIdentifierAvailable 194,PropAuthenticationMethod -// "\SI",PropCorrelationData "E(\233\128|\205\178\136\SOH\DC3\216\&9\240W\164\f\143\133\ESCU",PropMessageExpiryInterval +// 2283,PropWildcardSubscriptionAvailable 242,PropTopicAlias 20591]} TEST(Publish5QCTest, Encode22) { - uint8_t pkt[] = {0x31, 0xea, 0x1, 0x0, 0x14, 0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, 0xf6, 0xea, - 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58, 0xbb, 0x1, 0x1c, 0x0, 0x13, 0x10, 0x45, 0x3e, 0x69, - 0xa7, 0x2b, 0xe8, 0xb1, 0xa5, 0xd3, 0x18, 0xa2, 0x46, 0x34, 0x8f, 0x2a, 0xfb, 0x1d, 0xce, 0x21, 0x3b, - 0x55, 0x16, 0x0, 0x7, 0x7b, 0x51, 0xae, 0xbf, 0xa, 0xd8, 0xbc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xf6, 0xea, 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x34, 0x51, 0x0, 0x12, 0xa1, 0xe5, 0x6d, 0x81, 0x32, 0xde, 0x77, 0x7d, 0xfc, 0x92, 0xa9, 0x28, 0x2, + 0x75, 0x89, 0x5a, 0x36, 0x85, 0x1d, 0x7a, 0x2e, 0x19, 0xaa, 0x16, 0x0, 0x0, 0x28, 0x79, 0x21, 0x7b, + 0x60, 0x9, 0x0, 0x17, 0x90, 0xdc, 0xdf, 0xb3, 0xcb, 0xd2, 0x56, 0xf7, 0x5, 0x41, 0x19, 0x5f, 0x11, + 0x87, 0x2d, 0xed, 0x3e, 0xa4, 0xc, 0x8f, 0x85, 0x1b, 0x55, 0x2, 0x0, 0x0, 0x8, 0xeb, 0x28, 0xf2, + 0x23, 0x50, 0x6f, 0x5e, 0x3, 0xe4, 0xb0, 0xe0, 0x5d, 0xdc, 0x69, 0xd3, 0x28, 0x3c, 0x90}; + uint8_t topic_bytes[] = {0xa1, 0xe5, 0x6d, 0x81, 0x32, 0xde, 0x77, 0x7d, 0xfc, + 0x92, 0xa9, 0x28, 0x2, 0x75, 0x89, 0x5a, 0x36, 0x85}; + lwmqtt_string_t topic = {18, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0xb3, 0x3e, 0x5, 0x55, 0x75, 0xd7, 0x6b, 0xd8, 0x3, 0xc9, 0x6d, 0x12, - 0xfb, 0x32, 0x17, 0xbb, 0x6d, 0xc8, 0xf8, 0x8c, 0x7b, 0xa, 0x38}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0x5e, 0x3, 0xe4, 0xb0, 0xe0, 0x5d, 0xdc, 0x69, 0xd3, 0x28, 0x3c, 0x90}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 23; + msg.payload_len = 12; - uint8_t bytesprops0[] = {0x10, 0x45, 0x3e, 0x69, 0xa7, 0x2b, 0xe8, 0xb1, 0xa5, 0xd3, - 0x18, 0xa2, 0x46, 0x34, 0x8f, 0x2a, 0xfb, 0x1d, 0xce}; - uint8_t bytesprops1[] = {0x7b, 0x51, 0xae, 0xbf, 0xa, 0xd8, 0xbc}; - uint8_t bytesprops2[] = {0x23, 0xaf, 0x5e, 0xe9, 0x85, 0x9a, 0x49, 0xbb}; - uint8_t bytesprops3[] = {0xf8, 0xf5, 0xed, 0x6e}; - uint8_t bytesprops4[] = {0x89, 0x61, 0xe3, 0x5a, 0x44, 0x88}; - uint8_t bytesprops5[] = {0x29, 0x1d}; - uint8_t bytesprops7[] = {0x92, 0x12, 0xd8, 0x75, 0xa4, 0x1b, 0x99, 0x64, 0x56, 0x50, 0x8, 0xae, 0x76, 0xa2, 0x7e, - 0xde, 0x8c, 0xcc, 0x8, 0x2, 0x8f, 0x29, 0xf5, 0xf3, 0x48, 0xf1, 0xc7, 0x9a, 0xd8, 0xc7}; - uint8_t bytesprops6[] = {0x95, 0xa5, 0x0, 0xfd, 0x89, 0xdb, 0x9}; - uint8_t bytesprops8[] = {0x63, 0xcb, 0x9e}; - uint8_t bytesprops9[] = {0xf}; - uint8_t bytesprops10[] = {0x45, 0x28, 0xe9, 0x80, 0x7c, 0xcd, 0xb2, 0x88, 0x1, - 0x13, 0xd8, 0x39, 0xf0, 0x57, 0x3c, 0x4d, 0x9c}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x90, 0xdc, 0xdf, 0xb3, 0xcb, 0xd2, 0x56, 0xf7, 0x5, 0x41, 0x19, 0x5f, + 0x11, 0x87, 0x2d, 0xed, 0x3e, 0xa4, 0xc, 0x8f, 0x85, 0x1b, 0x55}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15189}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 854}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 177}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21295}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30278}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21047}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18244}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24947}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops6}, .v = {30, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 121}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31584}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2283}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20591}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 7546, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "D\SO\EOTH\207S\243\176T\n\246\234'~^\ETBtz\220X", _pubPktID = 0, _pubBody = -// "\179>\ENQUu\215k\216\ETX\201m\DC2\251\&2\ETB\187m\200\248\140{\n8", _pubProps = [PropServerReference -// "\DLEE>i\167+\232\177\165\211\CAN\162F4\143*\251\GS\206",PropReceiveMaximum 15189,PropAuthenticationData -// "{Q\174\191\n\216\188",PropSharedSubscriptionAvailable 244,PropResponseInformation -// "#\175^\233\133\154I\187",PropMessageExpiryInterval 854,PropResponseTopic "\248\245\237n",PropResponseTopic -// "\137a\227ZD\136",PropResponseTopic ")\GS",PropRetainAvailable 56,PropWildcardSubscriptionAvailable -// 220,PropSubscriptionIdentifierAvailable 177,PropMaximumQoS 216,PropReceiveMaximum -// 21295,PropSharedSubscriptionAvailable 193,PropWillDelayInterval 30278,PropSessionExpiryInterval 21047,PropMaximumQoS -// 120,PropWillDelayInterval 18244,PropRequestResponseInformation 191,PropMessageExpiryInterval 24947,PropUserProperty -// "\149\165\NUL\253\137\219\t" -// "\146\DC2\216u\164\ESC\153dVP\b\174v\162~\222\140\204\b\STX\143)\245\243H\241\199\154\216\199",PropAuthenticationData -// "c\203\158",PropSubscriptionIdentifierAvailable 114,PropSubscriptionIdentifierAvailable 194,PropAuthenticationMethod -// "\SI",PropCorrelationData "E(\233\128|\205\178\136\SOH\DC3\216\&9\240W\164\f\143\133\ESCU",PropMessageExpiryInterval +// 2283,PropWildcardSubscriptionAvailable 242,PropTopicAlias 20591]} TEST(Publish5QCTest, Decode22) { - uint8_t pkt[] = {0x31, 0xea, 0x1, 0x0, 0x14, 0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, 0xf6, 0xea, - 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58, 0xbb, 0x1, 0x1c, 0x0, 0x13, 0x10, 0x45, 0x3e, 0x69, - 0xa7, 0x2b, 0xe8, 0xb1, 0xa5, 0xd3, 0x18, 0xa2, 0x46, 0x34, 0x8f, 0x2a, 0xfb, 0x1d, 0xce, 0x21, 0x3b, - 0x55, 0x16, 0x0, 0x7, 0x7b, 0x51, 0xae, 0xbf, 0xa, 0xd8, 0xbc, 0x2a, 0xf4, 0x1a, 0x0, 0x8, 0x23, - 0xaf, 0x5e, 0xe9, 0x85, 0x9a, 0x49, 0xbb, 0x2, 0x0, 0x0, 0x3, 0x56, 0x8, 0x0, 0x4, 0xf8, 0xf5, - 0xed, 0x6e, 0x8, 0x0, 0x6, 0x89, 0x61, 0xe3, 0x5a, 0x44, 0x88, 0x8, 0x0, 0x2, 0x29, 0x1d, 0x25, - 0x38, 0x28, 0xdc, 0x29, 0xb1, 0x24, 0xd8, 0x21, 0x53, 0x2f, 0x2a, 0xc1, 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x0, 0x8, 0xeb, 0x28, 0xf2, + 0x23, 0x50, 0x6f, 0x5e, 0x3, 0xe4, 0xb0, 0xe0, 0x5d, 0xdc, 0x69, 0xd3, 0x28, 0x3c, 0x90}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4465,99 +4224,119 @@ TEST(Publish5QCTest, Decode22) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x44, 0xe, 0x4, 0x48, 0xcf, 0x53, 0xf3, 0xb0, 0x54, 0xa, - 0xf6, 0xea, 0x27, 0x7e, 0x5e, 0x17, 0x74, 0x7a, 0xdc, 0x58}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xb3, 0x3e, 0x5, 0x55, 0x75, 0xd7, 0x6b, 0xd8, 0x3, 0xc9, 0x6d, 0x12, - 0xfb, 0x32, 0x17, 0xbb, 0x6d, 0xc8, 0xf8, 0x8c, 0x7b, 0xa, 0x38}; - lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0xa1, 0xe5, 0x6d, 0x81, 0x32, 0xde, 0x77, 0x7d, 0xfc, + 0x92, 0xa9, 0x28, 0x2, 0x75, 0x89, 0x5a, 0x36, 0x85}; + lwmqtt_string_t exp_topic = {18, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x5e, 0x3, 0xe4, 0xb0, 0xe0, 0x5d, 0xdc, 0x69, 0xd3, 0x28, 0x3c, 0x90}; + lwmqtt_string_t exp_body = {12, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 23); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 7546); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 18); + EXPECT_EQ(msg.payload_len, 12); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 12); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\178\144*)\STX\195\&3\195\193\213~9\191FW\136R", _pubPktID = 0, _pubBody = "\155U0$\ENQ\134dV\214\ts.+\ETX\143", -// _pubProps = [PropCorrelationData "\208\213\188\228\159~\156\197P\146a",PropResponseInformation "Jk -// ,\178\176\200\140\fi\137p\253k\172E`\139J\221\&4\197p\166AO\180\169\238\198",PropMaximumPacketSize -// 9290,PropUserProperty "o\187\161\DEL;" -// "\200\&1z\DC3\250`\228\&2t?@\DC3\165\131K\USq\GS\170\212S",PropWillDelayInterval 4415,PropResponseTopic -// "\137\173\CAN\ENQ\205B\\\222\SOH~\230a",PropResponseInformation "B\136e&\153\161\f\ESCCP\132\131$\SIj\191"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "zd\230 jdq?\198\154\202x8", +// _pubPktID = 32533, _pubBody = "\255\DC4\132\246=", _pubProps = [PropMaximumPacketSize 15136,PropAuthenticationData +// "\131\&7\153\202F\187\143\DLE\DELp\CAN\\ed\154JK\137\184\192\137\190Z\161\ENQ\181\164",PropAssignedClientIdentifier +// "w\150%\206\129\164\131\203uN+r\206I\SIJr\145\242\247",PropUserProperty "\129i1uD#\224^f\RS\SYN\177Ks>N" +// "@\ETX\DEL\156G\b\128\173\172\&2#",PropMaximumQoS 54,PropAuthenticationMethod +// "\ETX\206\DLE\177Z\255D|\170g\250\133k\254\US\193B\214Jdp9I{L'\ENQ\FS<",PropSessionExpiryInterval +// 31365,PropServerKeepAlive 25016,PropSubscriptionIdentifier 19,PropTopicAlias 18475,PropAuthenticationMethod +// "\f\217\155,\149\231\148\SOH$.\ETX\154g\228mf~",PropServerReference "5\216f\DEL",PropPayloadFormatIndicator +// 225,PropContentType "\179fA\243\179\219\SO\213,\197\189z\201\160\195\163\248n\174\255\234\179\139_1\207{\130x\248"]} TEST(Publish5QCTest, Encode23) { - uint8_t pkt[] = {0x39, 0x9d, 0x1, 0x0, 0x11, 0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, 0xd5, 0x7e, - 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52, 0x7a, 0x9, 0x0, 0xb, 0xd0, 0xd5, 0xbc, 0xe4, 0x9f, 0x7e, - 0x9c, 0xc5, 0x50, 0x92, 0x61, 0x1a, 0x0, 0x1e, 0x4a, 0x6b, 0x20, 0x2c, 0xb2, 0xb0, 0xc8, 0x8c, - 0xc, 0x69, 0x89, 0x70, 0xfd, 0x6b, 0xac, 0x45, 0x60, 0x8b, 0x4a, 0xdd, 0x34, 0xc5, 0x70, 0xa6, - 0x41, 0x4f, 0xb4, 0xa9, 0xee, 0xc6, 0x27, 0x0, 0x0, 0x24, 0x4a, 0x26, 0x0, 0x5, 0x6f, 0xbb, - 0xa1, 0x7f, 0x3b, 0x0, 0x15, 0xc8, 0x31, 0x7a, 0x13, 0xfa, 0x60, 0xe4, 0x32, 0x74, 0x3f, 0x40, - 0x13, 0xa5, 0x83, 0x4b, 0x1f, 0x71, 0x1d, 0xaa, 0xd4, 0x53, 0x18, 0x0, 0x0, 0x11, 0x3f, 0x8, - 0x0, 0xc, 0x89, 0xad, 0x18, 0x5, 0xcd, 0x42, 0x5c, 0xde, 0x1, 0x7e, 0xe6, 0x61, 0x1a, 0x0, - 0x10, 0x42, 0x88, 0x65, 0x26, 0x99, 0xa1, 0xc, 0x1b, 0x43, 0x50, 0x84, 0x83, 0x24, 0xf, 0x6a, - 0xbf, 0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; - uint8_t topic_bytes[] = {0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, - 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52}; - lwmqtt_string_t topic = {17, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x34, 0xdf, 0x1, 0x0, 0xd, 0x7a, 0x64, 0xe6, 0x20, 0x6a, 0x64, 0x71, 0x3f, 0xc6, 0x9a, 0xca, 0x78, 0x38, 0x7f, + 0x15, 0xc7, 0x1, 0x27, 0x0, 0x0, 0x3b, 0x20, 0x16, 0x0, 0x1b, 0x83, 0x37, 0x99, 0xca, 0x46, 0xbb, 0x8f, 0x10, + 0x7f, 0x70, 0x18, 0x5c, 0x65, 0x64, 0x9a, 0x4a, 0x4b, 0x89, 0xb8, 0xc0, 0x89, 0xbe, 0x5a, 0xa1, 0x5, 0xb5, 0xa4, + 0x12, 0x0, 0x14, 0x77, 0x96, 0x25, 0xce, 0x81, 0xa4, 0x83, 0xcb, 0x75, 0x4e, 0x2b, 0x72, 0xce, 0x49, 0xf, 0x4a, + 0x72, 0x91, 0xf2, 0xf7, 0x26, 0x0, 0x10, 0x81, 0x69, 0x31, 0x75, 0x44, 0x23, 0xe0, 0x5e, 0x66, 0x1e, 0x16, 0xb1, + 0x4b, 0x73, 0x3e, 0x4e, 0x0, 0xb, 0x40, 0x3, 0x7f, 0x9c, 0x47, 0x8, 0x80, 0xad, 0xac, 0x32, 0x23, 0x24, 0x36, + 0x15, 0x0, 0x1d, 0x3, 0xce, 0x10, 0xb1, 0x5a, 0xff, 0x44, 0x7c, 0xaa, 0x67, 0xfa, 0x85, 0x6b, 0xfe, 0x1f, 0xc1, + 0x42, 0xd6, 0x4a, 0x64, 0x70, 0x39, 0x49, 0x7b, 0x4c, 0x27, 0x5, 0x1c, 0x3c, 0x11, 0x0, 0x0, 0x7a, 0x85, 0x13, + 0x61, 0xb8, 0xb, 0x13, 0x23, 0x48, 0x2b, 0x15, 0x0, 0x11, 0xc, 0xd9, 0x9b, 0x2c, 0x95, 0xe7, 0x94, 0x1, 0x24, + 0x2e, 0x3, 0x9a, 0x67, 0xe4, 0x6d, 0x66, 0x7e, 0x1c, 0x0, 0x4, 0x35, 0xd8, 0x66, 0x7f, 0x1, 0xe1, 0x3, 0x0, + 0x1e, 0xb3, 0x66, 0x41, 0xf3, 0xb3, 0xdb, 0xe, 0xd5, 0x2c, 0xc5, 0xbd, 0x7a, 0xc9, 0xa0, 0xc3, 0xa3, 0xf8, 0x6e, + 0xae, 0xff, 0xea, 0xb3, 0x8b, 0x5f, 0x31, 0xcf, 0x7b, 0x82, 0x78, 0xf8, 0xff, 0x14, 0x84, 0xf6, 0x3d}; + uint8_t topic_bytes[] = {0x7a, 0x64, 0xe6, 0x20, 0x6a, 0x64, 0x71, 0x3f, 0xc6, 0x9a, 0xca, 0x78, 0x38}; + lwmqtt_string_t topic = {13, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; - msg.retained = true; - uint8_t msg_bytes[] = {0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; + msg.qos = LWMQTT_QOS2; + msg.retained = false; + uint8_t msg_bytes[] = {0xff, 0x14, 0x84, 0xf6, 0x3d}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 15; - - uint8_t bytesprops0[] = {0xd0, 0xd5, 0xbc, 0xe4, 0x9f, 0x7e, 0x9c, 0xc5, 0x50, 0x92, 0x61}; - uint8_t bytesprops1[] = {0x4a, 0x6b, 0x20, 0x2c, 0xb2, 0xb0, 0xc8, 0x8c, 0xc, 0x69, 0x89, 0x70, 0xfd, 0x6b, 0xac, - 0x45, 0x60, 0x8b, 0x4a, 0xdd, 0x34, 0xc5, 0x70, 0xa6, 0x41, 0x4f, 0xb4, 0xa9, 0xee, 0xc6}; - uint8_t bytesprops3[] = {0xc8, 0x31, 0x7a, 0x13, 0xfa, 0x60, 0xe4, 0x32, 0x74, 0x3f, 0x40, - 0x13, 0xa5, 0x83, 0x4b, 0x1f, 0x71, 0x1d, 0xaa, 0xd4, 0x53}; - uint8_t bytesprops2[] = {0x6f, 0xbb, 0xa1, 0x7f, 0x3b}; - uint8_t bytesprops4[] = {0x89, 0xad, 0x18, 0x5, 0xcd, 0x42, 0x5c, 0xde, 0x1, 0x7e, 0xe6, 0x61}; - uint8_t bytesprops5[] = {0x42, 0x88, 0x65, 0x26, 0x99, 0xa1, 0xc, 0x1b, - 0x43, 0x50, 0x84, 0x83, 0x24, 0xf, 0x6a, 0xbf}; + msg.payload_len = 5; + + uint8_t bytesprops0[] = {0x83, 0x37, 0x99, 0xca, 0x46, 0xbb, 0x8f, 0x10, 0x7f, 0x70, 0x18, 0x5c, 0x65, 0x64, + 0x9a, 0x4a, 0x4b, 0x89, 0xb8, 0xc0, 0x89, 0xbe, 0x5a, 0xa1, 0x5, 0xb5, 0xa4}; + uint8_t bytesprops1[] = {0x77, 0x96, 0x25, 0xce, 0x81, 0xa4, 0x83, 0xcb, 0x75, 0x4e, + 0x2b, 0x72, 0xce, 0x49, 0xf, 0x4a, 0x72, 0x91, 0xf2, 0xf7}; + uint8_t bytesprops3[] = {0x40, 0x3, 0x7f, 0x9c, 0x47, 0x8, 0x80, 0xad, 0xac, 0x32, 0x23}; + uint8_t bytesprops2[] = {0x81, 0x69, 0x31, 0x75, 0x44, 0x23, 0xe0, 0x5e, + 0x66, 0x1e, 0x16, 0xb1, 0x4b, 0x73, 0x3e, 0x4e}; + uint8_t bytesprops4[] = {0x3, 0xce, 0x10, 0xb1, 0x5a, 0xff, 0x44, 0x7c, 0xaa, 0x67, 0xfa, 0x85, 0x6b, 0xfe, 0x1f, + 0xc1, 0x42, 0xd6, 0x4a, 0x64, 0x70, 0x39, 0x49, 0x7b, 0x4c, 0x27, 0x5, 0x1c, 0x3c}; + uint8_t bytesprops5[] = {0xc, 0xd9, 0x9b, 0x2c, 0x95, 0xe7, 0x94, 0x1, 0x24, + 0x2e, 0x3, 0x9a, 0x67, 0xe4, 0x6d, 0x66, 0x7e}; + uint8_t bytesprops6[] = {0x35, 0xd8, 0x66, 0x7f}; + uint8_t bytesprops7[] = {0xb3, 0x66, 0x41, 0xf3, 0xb3, 0xdb, 0xe, 0xd5, 0x2c, 0xc5, 0xbd, 0x7a, 0xc9, 0xa0, 0xc3, + 0xa3, 0xf8, 0x6e, 0xae, 0xff, 0xea, 0xb3, 0x8b, 0x5f, 0x31, 0xcf, 0x7b, 0x82, 0x78, 0xf8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9290}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops2}, .v = {21, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4415}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15136}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops2}, .v = {11, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31365}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 25016}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18475}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 225}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 32533, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = -// "\178\144*)\STX\195\&3\195\193\213~9\191FW\136R", _pubPktID = 0, _pubBody = "\155U0$\ENQ\134dV\214\ts.+\ETX\143", -// _pubProps = [PropCorrelationData "\208\213\188\228\159~\156\197P\146a",PropResponseInformation "Jk -// ,\178\176\200\140\fi\137p\253k\172E`\139J\221\&4\197p\166AO\180\169\238\198",PropMaximumPacketSize -// 9290,PropUserProperty "o\187\161\DEL;" -// "\200\&1z\DC3\250`\228\&2t?@\DC3\165\131K\USq\GS\170\212S",PropWillDelayInterval 4415,PropResponseTopic -// "\137\173\CAN\ENQ\205B\\\222\SOH~\230a",PropResponseInformation "B\136e&\153\161\f\ESCCP\132\131$\SIj\191"]} +// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "zd\230 jdq?\198\154\202x8", +// _pubPktID = 32533, _pubBody = "\255\DC4\132\246=", _pubProps = [PropMaximumPacketSize 15136,PropAuthenticationData +// "\131\&7\153\202F\187\143\DLE\DELp\CAN\\ed\154JK\137\184\192\137\190Z\161\ENQ\181\164",PropAssignedClientIdentifier +// "w\150%\206\129\164\131\203uN+r\206I\SIJr\145\242\247",PropUserProperty "\129i1uD#\224^f\RS\SYN\177Ks>N" +// "@\ETX\DEL\156G\b\128\173\172\&2#",PropMaximumQoS 54,PropAuthenticationMethod +// "\ETX\206\DLE\177Z\255D|\170g\250\133k\254\US\193B\214Jdp9I{L'\ENQ\FS<",PropSessionExpiryInterval +// 31365,PropServerKeepAlive 25016,PropSubscriptionIdentifier 19,PropTopicAlias 18475,PropAuthenticationMethod +// "\f\217\155,\149\231\148\SOH$.\ETX\154g\228mf~",PropServerReference "5\216f\DEL",PropPayloadFormatIndicator +// 225,PropContentType "\179fA\243\179\219\SO\213,\197\189z\201\160\195\163\248n\174\255\234\179\139_1\207{\130x\248"]} TEST(Publish5QCTest, Decode23) { - uint8_t pkt[] = {0x39, 0x9d, 0x1, 0x0, 0x11, 0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, 0xd5, 0x7e, - 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52, 0x7a, 0x9, 0x0, 0xb, 0xd0, 0xd5, 0xbc, 0xe4, 0x9f, 0x7e, - 0x9c, 0xc5, 0x50, 0x92, 0x61, 0x1a, 0x0, 0x1e, 0x4a, 0x6b, 0x20, 0x2c, 0xb2, 0xb0, 0xc8, 0x8c, - 0xc, 0x69, 0x89, 0x70, 0xfd, 0x6b, 0xac, 0x45, 0x60, 0x8b, 0x4a, 0xdd, 0x34, 0xc5, 0x70, 0xa6, - 0x41, 0x4f, 0xb4, 0xa9, 0xee, 0xc6, 0x27, 0x0, 0x0, 0x24, 0x4a, 0x26, 0x0, 0x5, 0x6f, 0xbb, - 0xa1, 0x7f, 0x3b, 0x0, 0x15, 0xc8, 0x31, 0x7a, 0x13, 0xfa, 0x60, 0xe4, 0x32, 0x74, 0x3f, 0x40, - 0x13, 0xa5, 0x83, 0x4b, 0x1f, 0x71, 0x1d, 0xaa, 0xd4, 0x53, 0x18, 0x0, 0x0, 0x11, 0x3f, 0x8, - 0x0, 0xc, 0x89, 0xad, 0x18, 0x5, 0xcd, 0x42, 0x5c, 0xde, 0x1, 0x7e, 0xe6, 0x61, 0x1a, 0x0, - 0x10, 0x42, 0x88, 0x65, 0x26, 0x99, 0xa1, 0xc, 0x1b, 0x43, 0x50, 0x84, 0x83, 0x24, 0xf, 0x6a, - 0xbf, 0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; + uint8_t pkt[] = { + 0x34, 0xdf, 0x1, 0x0, 0xd, 0x7a, 0x64, 0xe6, 0x20, 0x6a, 0x64, 0x71, 0x3f, 0xc6, 0x9a, 0xca, 0x78, 0x38, 0x7f, + 0x15, 0xc7, 0x1, 0x27, 0x0, 0x0, 0x3b, 0x20, 0x16, 0x0, 0x1b, 0x83, 0x37, 0x99, 0xca, 0x46, 0xbb, 0x8f, 0x10, + 0x7f, 0x70, 0x18, 0x5c, 0x65, 0x64, 0x9a, 0x4a, 0x4b, 0x89, 0xb8, 0xc0, 0x89, 0xbe, 0x5a, 0xa1, 0x5, 0xb5, 0xa4, + 0x12, 0x0, 0x14, 0x77, 0x96, 0x25, 0xce, 0x81, 0xa4, 0x83, 0xcb, 0x75, 0x4e, 0x2b, 0x72, 0xce, 0x49, 0xf, 0x4a, + 0x72, 0x91, 0xf2, 0xf7, 0x26, 0x0, 0x10, 0x81, 0x69, 0x31, 0x75, 0x44, 0x23, 0xe0, 0x5e, 0x66, 0x1e, 0x16, 0xb1, + 0x4b, 0x73, 0x3e, 0x4e, 0x0, 0xb, 0x40, 0x3, 0x7f, 0x9c, 0x47, 0x8, 0x80, 0xad, 0xac, 0x32, 0x23, 0x24, 0x36, + 0x15, 0x0, 0x1d, 0x3, 0xce, 0x10, 0xb1, 0x5a, 0xff, 0x44, 0x7c, 0xaa, 0x67, 0xfa, 0x85, 0x6b, 0xfe, 0x1f, 0xc1, + 0x42, 0xd6, 0x4a, 0x64, 0x70, 0x39, 0x49, 0x7b, 0x4c, 0x27, 0x5, 0x1c, 0x3c, 0x11, 0x0, 0x0, 0x7a, 0x85, 0x13, + 0x61, 0xb8, 0xb, 0x13, 0x23, 0x48, 0x2b, 0x15, 0x0, 0x11, 0xc, 0xd9, 0x9b, 0x2c, 0x95, 0xe7, 0x94, 0x1, 0x24, + 0x2e, 0x3, 0x9a, 0x67, 0xe4, 0x6d, 0x66, 0x7e, 0x1c, 0x0, 0x4, 0x35, 0xd8, 0x66, 0x7f, 0x1, 0xe1, 0x3, 0x0, + 0x1e, 0xb3, 0x66, 0x41, 0xf3, 0xb3, 0xdb, 0xe, 0xd5, 0x2c, 0xc5, 0xbd, 0x7a, 0xc9, 0xa0, 0xc3, 0xa3, 0xf8, 0x6e, + 0xae, 0xff, 0xea, 0xb3, 0x8b, 0x5f, 0x31, 0xcf, 0x7b, 0x82, 0x78, 0xf8, 0xff, 0x14, 0x84, 0xf6, 0x3d}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4566,167 +4345,127 @@ TEST(Publish5QCTest, Decode23) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0xb2, 0x90, 0x2a, 0x29, 0x2, 0xc3, 0x33, 0xc3, 0xc1, - 0xd5, 0x7e, 0x39, 0xbf, 0x46, 0x57, 0x88, 0x52}; - lwmqtt_string_t exp_topic = {17, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9b, 0x55, 0x30, 0x24, 0x5, 0x86, 0x64, 0x56, 0xd6, 0x9, 0x73, 0x2e, 0x2b, 0x3, 0x8f}; - lwmqtt_string_t exp_body = {15, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, true); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 17); - EXPECT_EQ(msg.payload_len, 15); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 15); + uint8_t exp_topic_bytes[] = {0x7a, 0x64, 0xe6, 0x20, 0x6a, 0x64, 0x71, 0x3f, 0xc6, 0x9a, 0xca, 0x78, 0x38}; + lwmqtt_string_t exp_topic = {13, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xff, 0x14, 0x84, 0xf6, 0x3d}; + lwmqtt_string_t exp_body = {5, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS2); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 32533); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 13); + EXPECT_EQ(msg.payload_len, 5); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 5); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "G\195\186\214\239K -// \\\226\162\\\"\182", _pubPktID = 3720, _pubBody = -// "\SYN\172\191'(v\"S#\253\175\191\180\243%y\205\195\143\140\247\239\228\\", _pubProps = [PropServerReference -// "\DLEH+*\229\139\&6\242\210\b\221}hh6\219Cm\249\130U\230\168d\b\158",PropSubscriptionIdentifierAvailable -// 251,PropAssignedClientIdentifier "\198\DC1\n\161WEz\128",PropMessageExpiryInterval 8698,PropTopicAlias -// 21888,PropRetainAvailable 83,PropSubscriptionIdentifier 3,PropAuthenticationData -// "\203\240wO\tq>\150\163\145c7!Xg\135\\\239/",PropTopicAliasMaximum 20949,PropPayloadFormatIndicator -// 248,PropServerReference "\222\128\154\141\152=\DC3NW'_\222\241\NUL\221",PropSharedSubscriptionAvailable -// 142,PropSessionExpiryInterval 21222,PropAuthenticationMethod "\158B\NAK\210\148v*",PropPayloadFormatIndicator -// 47,PropRetainAvailable 106,PropResponseInformation -// "1Zl\199\205\143\249\234\232\237\214\128\130<\187\228I\EM\186\208\228#\247D\202\226\141",PropResponseTopic -// "a#\152\218C>",PropReceiveMaximum 17584,PropPayloadFormatIndicator 157,PropSubscriptionIdentifier -// 15,PropAuthenticationData "|\220\CAN\250\156\DELi2\SOH\236\193\164n\239\157\189\229t#`4", _pubPktID = 0, _pubBody = +// "\130\204\173\174\157}\164rT\146\220w\DC1H4\164\DLE\255{", _pubProps = [PropSubscriptionIdentifier +// 28,PropRequestProblemInformation 33,PropResponseInformation +// "*\237\238\SYN\179\143\197ci\b\129\254\t\212\249es\201\231[\RSE\215]",PropWildcardSubscriptionAvailable +// 173,PropWildcardSubscriptionAvailable 175,PropSessionExpiryInterval 14786,PropContentType +// "\245u\136R\187y\200\149\138\252:p\151\n\\\234'\132\f\SI\NAK\224b2\208",PropUserProperty +// "\139\182G\198\212V\157\182\230\203d\145\254" +// "q\246\175\&4r\173\ACK7m@\n\210\134\134\SOH\150\153;<\144\NAK\212\frX\174\RSJ\US",PropAssignedClientIdentifier +// "\224\ESC\t\254;n\165w;^\SOw",PropTopicAlias 5234,PropServerKeepAlive 13865,PropCorrelationData +// "\SO\n",PropTopicAlias 23073,PropMaximumPacketSize 19089,PropAuthenticationData +// "\150\163\145c7!Xg\135\\\239/",PropTopicAliasMaximum 20949,PropPayloadFormatIndicator -// 248,PropServerReference "\222\128\154\141\152=\DC3NW'_\222\241\NUL\221",PropSharedSubscriptionAvailable -// 142,PropSessionExpiryInterval 21222,PropAuthenticationMethod "\158B\NAK\210\148v*",PropPayloadFormatIndicator -// 47,PropRetainAvailable 106,PropResponseInformation -// "1Zl\199\205\143\249\234\232\237\214\128\130<\187\228I\EM\186\208\228#\247D\202\226\141",PropResponseTopic -// "a#\152\218C>",PropReceiveMaximum 17584,PropPayloadFormatIndicator 157,PropSubscriptionIdentifier -// 15,PropAuthenticationData "|\220\CAN\250\156\DELi2\SOH\236\193\164n\239\157\189\229t#`4", _pubPktID = 0, _pubBody = +// "\130\204\173\174\157}\164rT\146\220w\DC1H4\164\DLE\255{", _pubProps = [PropSubscriptionIdentifier +// 28,PropRequestProblemInformation 33,PropResponseInformation +// "*\237\238\SYN\179\143\197ci\b\129\254\t\212\249es\201\231[\RSE\215]",PropWildcardSubscriptionAvailable +// 173,PropWildcardSubscriptionAvailable 175,PropSessionExpiryInterval 14786,PropContentType +// "\245u\136R\187y\200\149\138\252:p\151\n\\\234'\132\f\SI\NAK\224b2\208",PropUserProperty +// "\139\182G\198\212V\157\182\230\203d\145\254" +// "q\246\175\&4r\173\ACK7m@\n\210\134\134\SOH\150\153;<\144\NAK\212\frX\174\RSJ\US",PropAssignedClientIdentifier +// "\224\ESC\t\254;n\165w;^\SOw",PropTopicAlias 5234,PropServerKeepAlive 13865,PropCorrelationData +// "\SO\n",PropTopicAlias 23073,PropMaximumPacketSize 19089,PropAuthenticationData +// "(topic.data), 13); - EXPECT_EQ(msg.payload_len, 24); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 24); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 27); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 9592, _pubBody = -// "\ETX\195\133\tbr,\140\146.tE\159\135\176\168{\162X\178Z", _pubProps = [PropRequestResponseInformation -// 55,PropSubscriptionIdentifierAvailable 91,PropRetainAvailable 219,PropResponseTopic -// "\208w#\158(\224\210\EM}m'\b\218N\239I\CAN\232\196\188\148",PropAuthenticationMethod -// "u\215\205\253\146\235\147>\163\254\190\178-\RS\EOT\191UX\RSTi\217\218\187",PropMessageExpiryInterval -// 14822,PropTopicAliasMaximum 7462,PropRequestProblemInformation 58,PropUserProperty -// "\237\217\129\178\170\183s\203\DC2g\162\152\SO\202m\162\219*\179" -// "\238Q?\150\189E[\218\175U\SYN\213\228\179|w\215\&9\EM9\151Y\ENQ_",PropUserProperty "\SI\DC2\166Ml\"$e~\128B" -// "\133\209\242\249\155\SYN\255\134\134\&6'+\194)\131\205\194\175%\US\135\ENQ\ENQ\192\184\219",PropCorrelationData -// "\ENQ\\\216T4\174",PropTopicAliasMaximum 14458,PropMaximumPacketSize 16732,PropMessageExpiryInterval -// 5436,PropSubscriptionIdentifier 4,PropContentType "\t\ESC\DC2\187\213L\236",PropRequestResponseInformation -// 153,PropMessageExpiryInterval 16625,PropTopicAliasMaximum 11137,PropAuthenticationMethod ""]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q:@l\229vEU\235iQ\v", _pubPktID = +// 23637, _pubBody = "\169\252\159\196(\144\135\181\129*7\EOT&B\216\183\244\DC3\129\142\224\229", _pubProps = +// [PropTopicAliasMaximum 21307,PropResponseInformation "\DC3\184\&7\"[\211\238r\163M\tO\183\USU",PropMaximumQoS +// 95,PropWildcardSubscriptionAvailable 148,PropRequestResponseInformation 162,PropWildcardSubscriptionAvailable +// 3,PropAssignedClientIdentifier "%\219\SO4\146l\EM",PropSubscriptionIdentifierAvailable 86]} TEST(Publish5QCTest, Encode25) { - uint8_t pkt[] = {0x34, 0xe7, 0x1, 0x0, 0x0, 0x25, 0x78, 0xcc, 0x1, 0x19, 0x37, 0x29, 0x5b, 0x25, 0xdb, 0x8, 0x0, - 0x15, 0xd0, 0x77, 0x23, 0x9e, 0x28, 0xe0, 0xd2, 0x19, 0x7d, 0x6d, 0x27, 0x8, 0xda, 0x4e, 0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x8c, - 0x92, 0x2e, 0x74, 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; - uint8_t topic_bytes[] = {0}; - lwmqtt_string_t topic = {0, (char*)&topic_bytes}; + uint8_t pkt[] = {0x33, 0x50, 0x0, 0xc, 0x71, 0x3a, 0x40, 0x6c, 0xe5, 0x76, 0x45, 0x55, 0xeb, 0x69, 0x51, 0xb, 0x5c, + 0x55, 0x29, 0x22, 0x53, 0x3b, 0x1a, 0x0, 0xf, 0x13, 0xb8, 0x37, 0x22, 0x5b, 0xd3, 0xee, 0x72, 0xa3, + 0x4d, 0x9, 0x4f, 0xb7, 0x1f, 0x55, 0x24, 0x5f, 0x28, 0x94, 0x19, 0xa2, 0x28, 0x3, 0x12, 0x0, 0x7, + 0x25, 0xdb, 0xe, 0x34, 0x92, 0x6c, 0x19, 0x29, 0x56, 0xa9, 0xfc, 0x9f, 0xc4, 0x28, 0x90, 0x87, 0xb5, + 0x81, 0x2a, 0x37, 0x4, 0x26, 0x42, 0xd8, 0xb7, 0xf4, 0x13, 0x81, 0x8e, 0xe0, 0xe5}; + uint8_t topic_bytes[] = {0x71, 0x3a, 0x40, 0x6c, 0xe5, 0x76, 0x45, 0x55, 0xeb, 0x69, 0x51, 0xb}; + lwmqtt_string_t topic = {12, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = false; - uint8_t msg_bytes[] = {0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, 0x92, 0x2e, 0x74, - 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; + msg.qos = LWMQTT_QOS1; + msg.retained = true; + uint8_t msg_bytes[] = {0xa9, 0xfc, 0x9f, 0xc4, 0x28, 0x90, 0x87, 0xb5, 0x81, 0x2a, 0x37, + 0x4, 0x26, 0x42, 0xd8, 0xb7, 0xf4, 0x13, 0x81, 0x8e, 0xe0, 0xe5}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 21; - - uint8_t bytesprops0[] = {0xd0, 0x77, 0x23, 0x9e, 0x28, 0xe0, 0xd2, 0x19, 0x7d, 0x6d, 0x27, - 0x8, 0xda, 0x4e, 0xef, 0x49, 0x18, 0xe8, 0xc4, 0xbc, 0x94}; - uint8_t bytesprops1[] = {0x75, 0xd7, 0xcd, 0xfd, 0x92, 0xeb, 0x93, 0x3e, 0xa3, 0xfe, 0xbe, 0xb2, - 0x2d, 0x1e, 0x4, 0xbf, 0x55, 0x58, 0x1e, 0x54, 0x69, 0xd9, 0xda, 0xbb}; - uint8_t bytesprops3[] = {0xee, 0x51, 0x3f, 0x96, 0xbd, 0x45, 0x5b, 0xda, 0xaf, 0x55, 0x16, 0xd5, - 0xe4, 0xb3, 0x7c, 0x77, 0xd7, 0x39, 0x19, 0x39, 0x97, 0x59, 0x5, 0x5f}; - uint8_t bytesprops2[] = {0xed, 0xd9, 0x81, 0xb2, 0xaa, 0xb7, 0x73, 0xcb, 0x12, 0x67, - 0xa2, 0x98, 0xe, 0xca, 0x6d, 0xa2, 0xdb, 0x2a, 0xb3}; - uint8_t bytesprops5[] = {0x85, 0xd1, 0xf2, 0xf9, 0x9b, 0x16, 0xff, 0x86, 0x86, 0x36, 0x27, 0x2b, 0xc2, - 0x29, 0x83, 0xcd, 0xc2, 0xaf, 0x25, 0x1f, 0x87, 0x5, 0x5, 0xc0, 0xb8, 0xdb}; - uint8_t bytesprops4[] = {0xf, 0x12, 0xa6, 0x4d, 0x6c, 0x22, 0x24, 0x65, 0x7e, 0x80, 0x42}; - uint8_t bytesprops6[] = {0x5, 0x5c, 0xd8, 0x54, 0x34, 0xae}; - uint8_t bytesprops7[] = {0x9, 0x1b, 0x12, 0xbb, 0xd5, 0x4c, 0xec}; - uint8_t bytesprops8[] = {0}; + msg.payload_len = 22; + + uint8_t bytesprops0[] = {0x13, 0xb8, 0x37, 0x22, 0x5b, 0xd3, 0xee, 0x72, 0xa3, 0x4d, 0x9, 0x4f, 0xb7, 0x1f, 0x55}; + uint8_t bytesprops1[] = {0x25, 0xdb, 0xe, 0x34, 0x92, 0x6c, 0x19}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14822}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7462}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops2}, .v = {24, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops4}, .v = {26, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14458}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16732}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5436}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16625}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11137}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21307}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 162}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 86}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 9592, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 23637, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = False, _pubTopic = "", _pubPktID = 9592, _pubBody = -// "\ETX\195\133\tbr,\140\146.tE\159\135\176\168{\162X\178Z", _pubProps = [PropRequestResponseInformation -// 55,PropSubscriptionIdentifierAvailable 91,PropRetainAvailable 219,PropResponseTopic -// "\208w#\158(\224\210\EM}m'\b\218N\239I\CAN\232\196\188\148",PropAuthenticationMethod -// "u\215\205\253\146\235\147>\163\254\190\178-\RS\EOT\191UX\RSTi\217\218\187",PropMessageExpiryInterval -// 14822,PropTopicAliasMaximum 7462,PropRequestProblemInformation 58,PropUserProperty -// "\237\217\129\178\170\183s\203\DC2g\162\152\SO\202m\162\219*\179" -// "\238Q?\150\189E[\218\175U\SYN\213\228\179|w\215\&9\EM9\151Y\ENQ_",PropUserProperty "\SI\DC2\166Ml\"$e~\128B" -// "\133\209\242\249\155\SYN\255\134\134\&6'+\194)\131\205\194\175%\US\135\ENQ\ENQ\192\184\219",PropCorrelationData -// "\ENQ\\\216T4\174",PropTopicAliasMaximum 14458,PropMaximumPacketSize 16732,PropMessageExpiryInterval -// 5436,PropSubscriptionIdentifier 4,PropContentType "\t\ESC\DC2\187\213L\236",PropRequestResponseInformation -// 153,PropMessageExpiryInterval 16625,PropTopicAliasMaximum 11137,PropAuthenticationMethod ""]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "q:@l\229vEU\235iQ\v", _pubPktID = +// 23637, _pubBody = "\169\252\159\196(\144\135\181\129*7\EOT&B\216\183\244\DC3\129\142\224\229", _pubProps = +// [PropTopicAliasMaximum 21307,PropResponseInformation "\DC3\184\&7\"[\211\238r\163M\tO\183\USU",PropMaximumQoS +// 95,PropWildcardSubscriptionAvailable 148,PropRequestResponseInformation 162,PropWildcardSubscriptionAvailable +// 3,PropAssignedClientIdentifier "%\219\SO4\146l\EM",PropSubscriptionIdentifierAvailable 86]} TEST(Publish5QCTest, Decode25) { - uint8_t pkt[] = {0x34, 0xe7, 0x1, 0x0, 0x0, 0x25, 0x78, 0xcc, 0x1, 0x19, 0x37, 0x29, 0x5b, 0x25, 0xdb, 0x8, 0x0, - 0x15, 0xd0, 0x77, 0x23, 0x9e, 0x28, 0xe0, 0xd2, 0x19, 0x7d, 0x6d, 0x27, 0x8, 0xda, 0x4e, 0xef, 0x49, - 0x18, 0xe8, 0xc4, 0xbc, 0x94, 0x15, 0x0, 0x18, 0x75, 0xd7, 0xcd, 0xfd, 0x92, 0xeb, 0x93, 0x3e, 0xa3, - 0xfe, 0xbe, 0xb2, 0x2d, 0x1e, 0x4, 0xbf, 0x55, 0x58, 0x1e, 0x54, 0x69, 0xd9, 0xda, 0xbb, 0x2, 0x0, - 0x0, 0x39, 0xe6, 0x22, 0x1d, 0x26, 0x17, 0x3a, 0x26, 0x0, 0x13, 0xed, 0xd9, 0x81, 0xb2, 0xaa, 0xb7, - 0x73, 0xcb, 0x12, 0x67, 0xa2, 0x98, 0xe,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 0x19, 0xa2, 0x28, 0x3, 0x12, 0x0, 0x7, + 0x25, 0xdb, 0xe, 0x34, 0x92, 0x6c, 0x19, 0x29, 0x56, 0xa9, 0xfc, 0x9f, 0xc4, 0x28, 0x90, 0x87, 0xb5, + 0x81, 0x2a, 0x37, 0x4, 0x26, 0x42, 0xd8, 0xb7, 0xf4, 0x13, 0x81, 0x8e, 0xe0, 0xe5}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -4871,131 +4555,131 @@ TEST(Publish5QCTest, Decode25) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0}; - lwmqtt_string_t exp_topic = {0, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x3, 0xc3, 0x85, 0x9, 0x62, 0x72, 0x2c, 0x8c, 0x92, 0x2e, 0x74, - 0x45, 0x9f, 0x87, 0xb0, 0xa8, 0x7b, 0xa2, 0x58, 0xb2, 0x5a}; - lwmqtt_string_t exp_body = {21, (char*)&exp_body_bytes}; + uint8_t exp_topic_bytes[] = {0x71, 0x3a, 0x40, 0x6c, 0xe5, 0x76, 0x45, 0x55, 0xeb, 0x69, 0x51, 0xb}; + lwmqtt_string_t exp_topic = {12, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xa9, 0xfc, 0x9f, 0xc4, 0x28, 0x90, 0x87, 0xb5, 0x81, 0x2a, 0x37, + 0x4, 0x26, 0x42, 0xd8, 0xb7, 0xf4, 0x13, 0x81, 0x8e, 0xe0, 0xe5}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, false); - EXPECT_EQ(packet_id, 9592); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 0); - EXPECT_EQ(msg.payload_len, 21); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 21); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, true); + EXPECT_EQ(packet_id, 23637); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 12); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "y\216", _pubPktID = 27633, _pubBody -// = "\t\219\155@MR", _pubProps = [PropMessageExpiryInterval 13541,PropSubscriptionIdentifierAvailable -// 64,PropRequestProblemInformation 165,PropSessionExpiryInterval 19172,PropSubscriptionIdentifierAvailable -// 207,PropSharedSubscriptionAvailable 216,PropReasonString -// "\239\&7\209\&4\"\RS\210\252\152\247w\DELq\137}\231\221\&25\250\166\156\209\215C\232\US,",PropSubscriptionIdentifier -// 17,PropCorrelationData -// "\169`\195\182Q\144Rs\133\247\157\229Q1`o\SYN\NUL1\245S\v\SYN\167\155\129\&6\226\SUB\203",PropPayloadFormatIndicator -// 164,PropTopicAlias 25481,PropTopicAliasMaximum 2367,PropCorrelationData -// "\DC4{\160{\203\130\240\201\r\218\212\168O",PropSubscriptionIdentifier 24,PropAssignedClientIdentifier -// "gfW\212\230\243\228\235\182\223\RSxZ\135\227\163\249\217\177[\218|\194Nt\143\224\239G\t",PropReasonString -// "\239\242\158q#\202\v\221\SYN\191\&2N\218\129]=sa",PropRetainAvailable 139,PropTopicAliasMaximum -// 31979,PropSubscriptionIdentifier 19,PropServerReference -// "\157C\209\r\201\233\136W\195\229\f=\ENQJ\230%.\142\138j\208\175p\146",PropSubscriptionIdentifier 16]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "n#\187\187\173\198I,k\145\183\237\142\194", _pubPktID = 8993, _pubBody = "\147{\192\230\144\DC3\130j\217\194h +// E\159\201\161s\154\199\201<\227", _pubProps = [PropContentType +// "gDe<\244\211\249\144\FS\186\&4.)J|\254\137\STX*\249I",PropResponseTopic +// "\148\ACKL\136}+_\197\134\243`\200F\142\234xP{\225\181\SYNc\143*\DC3",PropReceiveMaximum 24406,PropWillDelayInterval +// 5554,PropResponseTopic "\163\175O\136\235\209\156\178?\NUL\150\ACK+xSp\241",PropReceiveMaximum 8798,PropTopicAlias +// 7024,PropWillDelayInterval 19616,PropRequestProblemInformation 23,PropMessageExpiryInterval +// 32067,PropAuthenticationData "\182z\151\212\192 +// 3\204ci\184\156\n\245\156j\142\162\129\162\DC1\135\154\253\STX]\129\170\247",PropResponseInformation +// "\156,6\197",PropServerReference +// "\246,\195F\168*\184f\248\239\153o8\215\148\241\CAN\168\197]n\181R",PropRequestResponseInformation +// 116,PropPayloadFormatIndicator 245,PropAuthenticationMethod +// "\131?\241\ENQzCk\187\132(zBY\190\175\210!\230?x\166>\186"]} TEST(Publish5QCTest, Encode26) { - uint8_t pkt[] = {0x33, 0xd6, 0x1, 0x0, 0x2, 0x79, 0xd8, 0x6b, 0xf1, 0xc8, 0x1, 0x2, 0x0, 0x0, 0x34, 0xe5, 0x29, - 0x40, 0x17, 0xa5, 0x11, 0x0, 0x0, 0x4a, 0xe4, 0x29, 0xcf, 0x2a, 0xd8, 0x1f, 0x0, 0x1c, 0xef, 0x37, - 0xd1, 0x34, 0x22, 0x1e, 0xd2, 0xfc, 0x98, 0xf7, 0x77, 0x7f, 0x71, 0x89, 0x7d, 0xe7, 0xdd, 0x32, 0x35, - 0xfa, 0xa6, 0x9c, 0xd1, 0xd7, 0x43, 0xe8, 0x1f, 0x2c, 0xb, 0x11, 0x9, 0x0, 0x1e, 0xa9, 0x60, 0xc3, - 0xb6, 0x51, 0x90, 0x52, 0x73, 0x85, 0xf7, 0x9d, 0xe5, 0x51, 0x31, 0x60, 0x6f, 0x16, 0x0, 0x31, 0xf5, - 0x53, 0xb, 0x16, 0xa7, 0x9b, 0x81, 0x36, 0xe2, 0x1a, 0xcb, 0x1, 0xa4, 0x23, 0x63, 0x89, 0x22, 0x9, - 0x3f, 0x9, 0x0, 0xd, 0x14, 0x7b, 0xa0, 0x7b, 0xcb, 0x82, 0xf0, 0xc9, 0xd, 0xda, 0xd4, 0xa8, 0x4f, - 0xb, 0x18, 0x12, 0x0, 0x1e, 0x67, 0x66, 0x57, 0xd4, 0xe6, 0xf3, 0xe4, 0xeb, 0xb6, 0xdf, 0x1e, 0x78, - 0x5a, 0x87, 0xe3, 0xa3, 0xf9, 0xd9, 0xb1, 0x5b, 0xda, 0x7c, 0xc2, 0x4e, 0x74, 0x8f, 0xe0, 0xef, 0x47, - 0x9, 0x1f, 0x0, 0x12, 0xef, 0xf2, 0x9e, 0x71, 0x23, 0xca, 0xb, 0xdd, 0x16, 0xbf, 0x32, 0x4e, 0xda, - 0x81, 0x5d, 0x3d, 0x73, 0x61, 0x25, 0x8b, 0x22, 0x7c, 0xeb, 0xb, 0x13, 0x1c, 0x0, 0x18, 0x9d, 0x43, - 0xd1, 0xd, 0xc9, 0xe9, 0x88, 0x57, 0xc3, 0xe5, 0xc, 0x3d, 0x5, 0x4a, 0xe6, 0x25, 0x2e, 0x8e, 0x8a, - 0x6a, 0xd0, 0xaf, 0x70, 0x92, 0xb, 0x10, 0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; - uint8_t topic_bytes[] = {0x79, 0xd8}; - lwmqtt_string_t topic = {2, (char*)&topic_bytes}; + uint8_t pkt[] = { + 0x3b, 0xeb, 0x1, 0x0, 0xe, 0x6e, 0x23, 0xbb, 0xbb, 0xad, 0xc6, 0x49, 0x2c, 0x6b, 0x91, 0xb7, 0xed, 0x8e, 0xc2, + 0x23, 0x21, 0xc1, 0x1, 0x3, 0x0, 0x15, 0x67, 0x44, 0x65, 0x3c, 0xf4, 0xd3, 0xf9, 0x90, 0x1c, 0xba, 0x34, 0x2e, + 0x29, 0x4a, 0x7c, 0xfe, 0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0x20, + 0x45, 0x9f, 0xc9, 0xa1, 0x73, 0x9a, 0xc7, 0xc9, 0x3c, 0xe3}; + uint8_t topic_bytes[] = {0x6e, 0x23, 0xbb, 0xbb, 0xad, 0xc6, 0x49, 0x2c, 0x6b, 0x91, 0xb7, 0xed, 0x8e, 0xc2}; + lwmqtt_string_t topic = {14, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; + uint8_t msg_bytes[] = {0x93, 0x7b, 0xc0, 0xe6, 0x90, 0x13, 0x82, 0x6a, 0xd9, 0xc2, 0x68, + 0x20, 0x45, 0x9f, 0xc9, 0xa1, 0x73, 0x9a, 0xc7, 0xc9, 0x3c, 0xe3}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 6; - - uint8_t bytesprops0[] = {0xef, 0x37, 0xd1, 0x34, 0x22, 0x1e, 0xd2, 0xfc, 0x98, 0xf7, 0x77, 0x7f, 0x71, 0x89, - 0x7d, 0xe7, 0xdd, 0x32, 0x35, 0xfa, 0xa6, 0x9c, 0xd1, 0xd7, 0x43, 0xe8, 0x1f, 0x2c}; - uint8_t bytesprops1[] = {0xa9, 0x60, 0xc3, 0xb6, 0x51, 0x90, 0x52, 0x73, 0x85, 0xf7, 0x9d, 0xe5, 0x51, 0x31, 0x60, - 0x6f, 0x16, 0x0, 0x31, 0xf5, 0x53, 0xb, 0x16, 0xa7, 0x9b, 0x81, 0x36, 0xe2, 0x1a, 0xcb}; - uint8_t bytesprops2[] = {0x14, 0x7b, 0xa0, 0x7b, 0xcb, 0x82, 0xf0, 0xc9, 0xd, 0xda, 0xd4, 0xa8, 0x4f}; - uint8_t bytesprops3[] = {0x67, 0x66, 0x57, 0xd4, 0xe6, 0xf3, 0xe4, 0xeb, 0xb6, 0xdf, 0x1e, 0x78, 0x5a, 0x87, 0xe3, - 0xa3, 0xf9, 0xd9, 0xb1, 0x5b, 0xda, 0x7c, 0xc2, 0x4e, 0x74, 0x8f, 0xe0, 0xef, 0x47, 0x9}; - uint8_t bytesprops4[] = {0xef, 0xf2, 0x9e, 0x71, 0x23, 0xca, 0xb, 0xdd, 0x16, - 0xbf, 0x32, 0x4e, 0xda, 0x81, 0x5d, 0x3d, 0x73, 0x61}; - uint8_t bytesprops5[] = {0x9d, 0x43, 0xd1, 0xd, 0xc9, 0xe9, 0x88, 0x57, 0xc3, 0xe5, 0xc, 0x3d, - 0x5, 0x4a, 0xe6, 0x25, 0x2e, 0x8e, 0x8a, 0x6a, 0xd0, 0xaf, 0x70, 0x92}; + msg.payload_len = 22; + + uint8_t bytesprops0[] = {0x67, 0x44, 0x65, 0x3c, 0xf4, 0xd3, 0xf9, 0x90, 0x1c, 0xba, 0x34, + 0x2e, 0x29, 0x4a, 0x7c, 0xfe, 0x89, 0x2, 0x2a, 0xf9, 0x49}; + uint8_t bytesprops1[] = {0x94, 0x6, 0x4c, 0x88, 0x7d, 0x2b, 0x5f, 0xc5, 0x86, 0xf3, 0x60, 0xc8, 0x46, + 0x8e, 0xea, 0x78, 0x50, 0x7b, 0xe1, 0xb5, 0x16, 0x63, 0x8f, 0x2a, 0x13}; + uint8_t bytesprops2[] = {0xa3, 0xaf, 0x4f, 0x88, 0xeb, 0xd1, 0x9c, 0xb2, 0x3f, + 0x0, 0x96, 0x6, 0x2b, 0x78, 0x53, 0x70, 0xf1}; + uint8_t bytesprops3[] = {0xb6, 0x7a, 0x97, 0xd4, 0xc0, 0x20, 0x33, 0xcc, 0x63, 0x69, 0xb8, 0x9c, 0xa, 0xf5, 0x9c, + 0x6a, 0x8e, 0xa2, 0x81, 0xa2, 0x11, 0x87, 0x9a, 0xfd, 0x2, 0x5d, 0x81, 0xaa, 0xf7}; + uint8_t bytesprops4[] = {0x9c, 0x2c, 0x36, 0xc5}; + uint8_t bytesprops5[] = {0xf6, 0x2c, 0xc3, 0x46, 0xa8, 0x2a, 0xb8, 0x66, 0xf8, 0xef, 0x99, 0x6f, + 0x38, 0xd7, 0x94, 0xf1, 0x18, 0xa8, 0xc5, 0x5d, 0x6e, 0xb5, 0x52}; + uint8_t bytesprops6[] = {0x83, 0x3f, 0xf1, 0x5, 0x7a, 0x43, 0x6b, 0xbb, 0x84, 0x28, 0x7a, 0x42, + 0x59, 0xbe, 0xaf, 0xd2, 0x21, 0xe6, 0x3f, 0x78, 0xa6, 0x3e, 0xba}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13541}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19172}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25481}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2367}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31979}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24406}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5554}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8798}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7024}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19616}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32067}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 27633, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 8993, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = True, _pubTopic = "y\216", _pubPktID = 27633, _pubBody -// = "\t\219\155@MR", _pubProps = [PropMessageExpiryInterval 13541,PropSubscriptionIdentifierAvailable -// 64,PropRequestProblemInformation 165,PropSessionExpiryInterval 19172,PropSubscriptionIdentifierAvailable -// 207,PropSharedSubscriptionAvailable 216,PropReasonString -// "\239\&7\209\&4\"\RS\210\252\152\247w\DELq\137}\231\221\&25\250\166\156\209\215C\232\US,",PropSubscriptionIdentifier -// 17,PropCorrelationData -// "\169`\195\182Q\144Rs\133\247\157\229Q1`o\SYN\NUL1\245S\v\SYN\167\155\129\&6\226\SUB\203",PropPayloadFormatIndicator -// 164,PropTopicAlias 25481,PropTopicAliasMaximum 2367,PropCorrelationData -// "\DC4{\160{\203\130\240\201\r\218\212\168O",PropSubscriptionIdentifier 24,PropAssignedClientIdentifier -// "gfW\212\230\243\228\235\182\223\RSxZ\135\227\163\249\217\177[\218|\194Nt\143\224\239G\t",PropReasonString -// "\239\242\158q#\202\v\221\SYN\191\&2N\218\129]=sa",PropRetainAvailable 139,PropTopicAliasMaximum -// 31979,PropSubscriptionIdentifier 19,PropServerReference -// "\157C\209\r\201\233\136W\195\229\f=\ENQJ\230%.\142\138j\208\175p\146",PropSubscriptionIdentifier 16]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "n#\187\187\173\198I,k\145\183\237\142\194", _pubPktID = 8993, _pubBody = "\147{\192\230\144\DC3\130j\217\194h +// E\159\201\161s\154\199\201<\227", _pubProps = [PropContentType +// "gDe<\244\211\249\144\FS\186\&4.)J|\254\137\STX*\249I",PropResponseTopic +// "\148\ACKL\136}+_\197\134\243`\200F\142\234xP{\225\181\SYNc\143*\DC3",PropReceiveMaximum 24406,PropWillDelayInterval +// 5554,PropResponseTopic "\163\175O\136\235\209\156\178?\NUL\150\ACK+xSp\241",PropReceiveMaximum 8798,PropTopicAlias +// 7024,PropWillDelayInterval 19616,PropRequestProblemInformation 23,PropMessageExpiryInterval +// 32067,PropAuthenticationData "\182z\151\212\192 +// 3\204ci\184\156\n\245\156j\142\162\129\162\DC1\135\154\253\STX]\129\170\247",PropResponseInformation +// "\156,6\197",PropServerReference +// "\246,\195F\168*\184f\248\239\153o8\215\148\241\CAN\168\197]n\181R",PropRequestResponseInformation +// 116,PropPayloadFormatIndicator 245,PropAuthenticationMethod +// "\131?\241\ENQzCk\187\132(zBY\190\175\210!\230?x\166>\186"]} TEST(Publish5QCTest, Decode26) { - uint8_t pkt[] = {0x33, 0xd6, 0x1, 0x0, 0x2, 0x79, 0xd8, 0x6b, 0xf1, 0xc8, 0x1, 0x2, 0x0, 0x0, 0x34, 0xe5, 0x29, - 0x40, 0x17, 0xa5, 0x11, 0x0, 0x0, 0x4a, 0xe4, 0x29, 0xcf, 0x2a, 0xd8, 0x1f, 0x0, 0x1c, 0xef, 0x37, - 0xd1, 0x34, 0x22, 0x1e, 0xd2, 0xfc, 0x98, 0xf7, 0x77, 0x7f, 0x71, 0x89, 0x7d, 0xe7, 0xdd, 0x32, 0x35, - 0xfa, 0xa6, 0x9c, 0xd1, 0xd7, 0x43, 0xe8, 0x1f, 0x2c, 0xb, 0x11, 0x9, 0x0, 0x1e, 0xa9, 0x60, 0xc3, - 0xb6, 0x51, 0x90, 0x52, 0x73, 0x85, 0xf7, 0x9d, 0xe5, 0x51, 0x31, 0x60, 0x6f, 0x16, 0x0, 0x31, 0xf5, - 0x53, 0xb, 0x16, 0xa7, 0x9b, 0x81, 0x36, 0xe2, 0x1a, 0xcb, 0x1, 0xa4, 0x23, 0x63, 0x89, 0x22, 0x9, - 0x3f, 0x9, 0x0, 0xd, 0x14, 0x7b, 0xa0, 0x7b, 0xcb, 0x82, 0xf0, 0xc9, 0xd, 0xda, 0xd4, 0xa8, 0x4f, - 0xb, 0x18, 0x12, 0x0, 0x1e, 0x67, 0x66, 0x57, 0xd4, 0xe6, 0xf3, 0xe4, 0xeb, 0xb6, 0xdf, 0x1e, 0x78, - 0x5a, 0x87, 0xe3, 0xa3, 0xf9, 0xd9, 0xb1,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, 0x18, 0x0, 0x0, 0x4c, 0xa0, + 0x17, 0x17, 0x2, 0x0, 0x0, 0x7d, 0x43, 0x16, 0x0, 0x1d, 0xb6, 0x7a, 0x97, 0xd4, 0xc0, 0x20, 0x33, 0xcc, 0x63, + 0x69, 0xb8, 0x9c, 0xa, 0xf5, 0x9c, 0x6a, 0x8e, 0xa2, 0x81, 0xa2, 0x11, 0x87, 0x9a, 0xfd, 0x2, 0x5d, 0x81, 0xaa, + 0xf7, 0x1a, 0x0, 0x4, 0x9c, 0x2c, 0x36, 0xc5, 0x1c, 0x0, 0x17, 0xf6, 0x2c, 0xc3, 0x46, 0xa8, 0x2a, 0xb8, 0x66, + 0xf8, 0xef, 0x99, 0x6f, 0x38, 0xd7, 0x94, 0xf1, 0x18, 0xa8, 0xc5, 0x5d, 0x6e, 0xb5, 0x52, 0x19, 0x74, 0x1, 0xf5, + 0x15, 0x0, 0x17, 0x83, 0x3f, 0xf1, 0x5, 0x7a, 0x43, 0x6b, 0xbb, 0x84, 0x28, 0x7a, 0x42, 0x59, 0xbe, 0xaf, 0xd2, + 0x21, 0xe6, 0x3f, 0x78, 0xa6, 0x3e, 0xba, 0x93, 0x7b, 0xc0, 0xe6, 0x90, 0x13, 0x82, 0x6a, 0xd9, 0xc2, 0x68, 0x20, + 0x45, 0x9f, 0xc9, 0xa1, 0x73, 0x9a, 0xc7, 0xc9, 0x3c, 0xe3}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -5004,76 +4688,63 @@ TEST(Publish5QCTest, Decode26) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x79, 0xd8}; - lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x9, 0xdb, 0x9b, 0x40, 0x4d, 0x52}; - lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x6e, 0x23, 0xbb, 0xbb, 0xad, 0xc6, 0x49, 0x2c, 0x6b, 0x91, 0xb7, 0xed, 0x8e, 0xc2}; + lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x93, 0x7b, 0xc0, 0xe6, 0x90, 0x13, 0x82, 0x6a, 0xd9, 0xc2, 0x68, + 0x20, 0x45, 0x9f, 0xc9, 0xa1, 0x73, 0x9a, 0xc7, 0xc9, 0x3c, 0xe3}; + lwmqtt_string_t exp_body = {22, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 27633); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); - EXPECT_EQ(msg.payload_len, 6); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); + EXPECT_EQ(packet_id, 8993); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); + EXPECT_EQ(msg.payload_len, 22); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 22); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "", _pubPktID = 0, _pubBody = -// "\253d\178]\206\DLE\163;", _pubProps = [PropWillDelayInterval 17530,PropTopicAliasMaximum -// 20683,PropMessageExpiryInterval 5805,PropRetainAvailable 19,PropUserProperty -// "\175\144\192\152\231U\141\191\ETB\149\254\227X\149\a\CAN\168Qa2\DLE" -// "\200c\DLE\204\149b\146\231\&4eO\FS\170\145.\253\247o\134'h\160",PropMessageExpiryInterval 804]} +// PublishRequest {_pubDup = False, _pubQoS = QoS1, _pubRetain = False, _pubTopic = "'w%\200$\223R\DC4`", _pubPktID = +// 8207, _pubBody = "\253\145\215\176fT\SO\155P\211\218(topic.data), 0); - EXPECT_EQ(msg.payload_len, 8); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 8); + uint8_t exp_topic_bytes[] = {0x27, 0x77, 0x25, 0xc8, 0x24, 0xdf, 0x52, 0x14, 0x60}; + lwmqtt_string_t exp_topic = {9, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xfd, 0x91, 0xd7, 0xb0, 0x66, 0x54, 0xe, 0x9b, 0x50, 0xd3, + 0xda, 0x3c, 0x65, 0xbf, 0xfa, 0xa2, 0xc0, 0xc9, 0x9a}; + lwmqtt_string_t exp_body = {19, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, false); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 8207); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 9); + EXPECT_EQ(msg.payload_len, 19); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 19); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// ";\204\SI\135:\SYN%u\222\217#\130\225N", _pubPktID = 14774, _pubBody = "\250v\SUB", _pubProps = -// [PropMessageExpiryInterval 2660,PropRequestProblemInformation 166,PropSessionExpiryInterval 11525,PropServerKeepAlive -// 5182,PropMessageExpiryInterval 27872,PropMessageExpiryInterval 24795,PropWillDelayInterval -// 12455,PropMessageExpiryInterval 27092,PropCorrelationData "\165s9\164\151\186",PropPayloadFormatIndicator -// 6,PropReasonString "\DLE%q\242@\130`\133lp\155\179\145"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "m\237T", _pubPktID = 0, _pubBody = +// "K\240\171\DC4,?a}f\GS\244\&7\181\255]\138\150\206|\148\140\128>", _pubProps = [PropSubscriptionIdentifierAvailable +// 120,PropReceiveMaximum 3713,PropMessageExpiryInterval 251,PropSharedSubscriptionAvailable 232,PropTopicAliasMaximum +// 31923,PropMaximumPacketSize 28907,PropAssignedClientIdentifier +// "j\226\188\156\183\196O\rM\212\245\159m\154\198\FS",PropTopicAliasMaximum 29927,PropServerReference "\181\f\CAN"]} TEST(Publish5QCTest, Encode28) { - uint8_t pkt[] = {0x35, 0x54, 0x0, 0xe, 0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, - 0x82, 0xe1, 0x4e, 0x39, 0xb6, 0x3e, 0x2, 0x0, 0x0, 0xa, 0x64, 0x17, 0xa6, 0x11, 0x0, - 0x0, 0x2d, 0x5, 0x13, 0x14, 0x3e, 0x2, 0x0, 0x0, 0x6c, 0xe0, 0x2, 0x0, 0x0, 0x60, - 0xdb, 0x18, 0x0, 0x0, 0x30, 0xa7, 0x2, 0x0, 0x0, 0x69, 0xd4, 0x9, 0x0, 0x6, 0xa5, - 0x73, 0x39, 0xa4, 0x97, 0xba, 0x1, 0x6, 0x1f, 0x0, 0xd, 0x10, 0x25, 0x71, 0xf2, 0x40, - 0x82, 0x60, 0x85, 0x6c, 0x70, 0x9b, 0xb3, 0x91, 0xfa, 0x76, 0x1a}; - uint8_t topic_bytes[] = {0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e}; - lwmqtt_string_t topic = {14, (char*)&topic_bytes}; + uint8_t pkt[] = {0x38, 0x4d, 0x0, 0x3, 0x6d, 0xed, 0x54, 0x30, 0x29, 0x78, 0x21, 0xe, 0x81, 0x2, 0x0, 0x0, + 0x0, 0xfb, 0x2a, 0xe8, 0x22, 0x7c, 0xb3, 0x27, 0x0, 0x0, 0x70, 0xeb, 0x12, 0x0, 0x10, 0x6a, + 0xe2, 0xbc, 0x9c, 0xb7, 0xc4, 0x4f, 0xd, 0x4d, 0xd4, 0xf5, 0x9f, 0x6d, 0x9a, 0xc6, 0x1c, 0x22, + 0x74, 0xe7, 0x1c, 0x0, 0x3, 0xb5, 0xc, 0x18, 0x4b, 0xf0, 0xab, 0x14, 0x2c, 0x3f, 0x61, 0x7d, + 0x66, 0x1d, 0xf4, 0x37, 0xb5, 0xff, 0x5d, 0x8a, 0x96, 0xce, 0x7c, 0x94, 0x8c, 0x80, 0x3e}; + uint8_t topic_bytes[] = {0x6d, 0xed, 0x54}; + lwmqtt_string_t topic = {3, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS2; - msg.retained = true; - uint8_t msg_bytes[] = {0xfa, 0x76, 0x1a}; + msg.qos = LWMQTT_QOS0; + msg.retained = false; + uint8_t msg_bytes[] = {0x4b, 0xf0, 0xab, 0x14, 0x2c, 0x3f, 0x61, 0x7d, 0x66, 0x1d, 0xf4, 0x37, + 0xb5, 0xff, 0x5d, 0x8a, 0x96, 0xce, 0x7c, 0x94, 0x8c, 0x80, 0x3e}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 3; + msg.payload_len = 23; - uint8_t bytesprops0[] = {0xa5, 0x73, 0x39, 0xa4, 0x97, 0xba}; - uint8_t bytesprops1[] = {0x10, 0x25, 0x71, 0xf2, 0x40, 0x82, 0x60, 0x85, 0x6c, 0x70, 0x9b, 0xb3, 0x91}; + uint8_t bytesprops0[] = {0x6a, 0xe2, 0xbc, 0x9c, 0xb7, 0xc4, 0x4f, 0xd, + 0x4d, 0xd4, 0xf5, 0x9f, 0x6d, 0x9a, 0xc6, 0x1c}; + uint8_t bytesprops1[] = {0xb5, 0xc, 0x18}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2660}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11525}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5182}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27872}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24795}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12455}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27092}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3713}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 251}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31923}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28907}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29927}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 14774, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS2, _pubRetain = True, _pubTopic = -// ";\204\SI\135:\SYN%u\222\217#\130\225N", _pubPktID = 14774, _pubBody = "\250v\SUB", _pubProps = -// [PropMessageExpiryInterval 2660,PropRequestProblemInformation 166,PropSessionExpiryInterval 11525,PropServerKeepAlive -// 5182,PropMessageExpiryInterval 27872,PropMessageExpiryInterval 24795,PropWillDelayInterval -// 12455,PropMessageExpiryInterval 27092,PropCorrelationData "\165s9\164\151\186",PropPayloadFormatIndicator -// 6,PropReasonString "\DLE%q\242@\130`\133lp\155\179\145"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = False, _pubTopic = "m\237T", _pubPktID = 0, _pubBody = +// "K\240\171\DC4,?a}f\GS\244\&7\181\255]\138\150\206|\148\140\128>", _pubProps = [PropSubscriptionIdentifierAvailable +// 120,PropReceiveMaximum 3713,PropMessageExpiryInterval 251,PropSharedSubscriptionAvailable 232,PropTopicAliasMaximum +// 31923,PropMaximumPacketSize 28907,PropAssignedClientIdentifier +// "j\226\188\156\183\196O\rM\212\245\159m\154\198\FS",PropTopicAliasMaximum 29927,PropServerReference "\181\f\CAN"]} TEST(Publish5QCTest, Decode28) { - uint8_t pkt[] = {0x35, 0x54, 0x0, 0xe, 0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, - 0x82, 0xe1, 0x4e, 0x39, 0xb6, 0x3e, 0x2, 0x0, 0x0, 0xa, 0x64, 0x17, 0xa6, 0x11, 0x0, - 0x0, 0x2d, 0x5, 0x13, 0x14, 0x3e, 0x2, 0x0, 0x0, 0x6c, 0xe0, 0x2, 0x0, 0x0, 0x60, - 0xdb, 0x18, 0x0, 0x0, 0x30, 0xa7, 0x2, 0x0, 0x0, 0x69, 0xd4, 0x9, 0x0, 0x6, 0xa5, - 0x73, 0x39, 0xa4, 0x97, 0xba, 0x1, 0x6, 0x1f, 0x0, 0xd, 0x10, 0x25, 0x71, 0xf2, 0x40, - 0x82, 0x60, 0x85, 0x6c, 0x70, 0x9b, 0xb3, 0x91, 0xfa, 0x76, 0x1a}; + uint8_t pkt[] = {0x38, 0x4d, 0x0, 0x3, 0x6d, 0xed, 0x54, 0x30, 0x29, 0x78, 0x21, 0xe, 0x81, 0x2, 0x0, 0x0, + 0x0, 0xfb, 0x2a, 0xe8, 0x22, 0x7c, 0xb3, 0x27, 0x0, 0x0, 0x70, 0xeb, 0x12, 0x0, 0x10, 0x6a, + 0xe2, 0xbc, 0x9c, 0xb7, 0xc4, 0x4f, 0xd, 0x4d, 0xd4, 0xf5, 0x9f, 0x6d, 0x9a, 0xc6, 0x1c, 0x22, + 0x74, 0xe7, 0x1c, 0x0, 0x3, 0xb5, 0xc, 0x18, 0x4b, 0xf0, 0xab, 0x14, 0x2c, 0x3f, 0x61, 0x7d, + 0x66, 0x1d, 0xf4, 0x37, 0xb5, 0xff, 0x5d, 0x8a, 0x96, 0xce, 0x7c, 0x94, 0x8c, 0x80, 0x3e}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -5167,136 +4835,59 @@ TEST(Publish5QCTest, Decode28) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x3b, 0xcc, 0xf, 0x87, 0x3a, 0x16, 0x25, 0x75, 0xde, 0xd9, 0x23, 0x82, 0xe1, 0x4e}; - lwmqtt_string_t exp_topic = {14, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xfa, 0x76, 0x1a}; - lwmqtt_string_t exp_body = {3, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS2); - EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 14774); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 14); - EXPECT_EQ(msg.payload_len, 3); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 3); + uint8_t exp_topic_bytes[] = {0x6d, 0xed, 0x54}; + lwmqtt_string_t exp_topic = {3, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x4b, 0xf0, 0xab, 0x14, 0x2c, 0x3f, 0x61, 0x7d, 0x66, 0x1d, 0xf4, 0x37, + 0xb5, 0xff, 0x5d, 0x8a, 0x96, 0xce, 0x7c, 0x94, 0x8c, 0x80, 0x3e}; + lwmqtt_string_t exp_body = {23, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(msg.retained, false); + EXPECT_EQ(packet_id, 0); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 3); + EXPECT_EQ(msg.payload_len, 23); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 23); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "M\189d\165\NAK\165J\222\187)\216\178d^\194{\141\141y\145", _pubPktID = 0, _pubBody = -// "\245\129\188\154\242\232\161\228\255\&1lz\153\252~D\r\222\166\ENQ", _pubProps = [PropPayloadFormatIndicator -// 241,PropPayloadFormatIndicator 35,PropTopicAliasMaximum 26102,PropTopicAlias 18197,PropTopicAlias -// 25483,PropSessionExpiryInterval 27654,PropAssignedClientIdentifier "\206\145\164\154V\DC3!\f(",PropResponseTopic -// "F\233\225\208\172A\218\165ql\212\244\168\174Z\158:Q\ESC\153\245\176\&6\142",PropCorrelationData -// "\146\169!\238\195D\204\250c8(\128\SYN\251\166\239)\138\178\156i\162\156]",PropSharedSubscriptionAvailable -// 64,PropCorrelationData "x2\137\204(\204\222",PropSharedSubscriptionAvailable 227,PropCorrelationData -// "g\STXSE*\131\240-\190\ACK\155%n_\130\226\255dR\162",PropReasonString -// "\193\185pZ\NUL\156\171\185LE\132\253\US\229\185\DEL\211\201i\DLE8\184\228\RS\196S\247\247",PropAuthenticationData -// "\238\172",PropSharedSubscriptionAvailable 148,PropUserProperty -// "\160\193\191\DC2AA\232\150W\161\252\177\227\a\175\160\SYNL\212\239fO\247'<.\ENQ\224{" -// "\184?u*}_F\134\&8(\r\242|a\186O2"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "r\223", _pubPktID = 0, _pubBody = +// "Y&\241\149_\178", _pubProps = [PropTopicAlias 29764,PropReceiveMaximum 12538,PropRequestProblemInformation +// 217,PropRequestProblemInformation 212,PropWillDelayInterval 8708]} TEST(Publish5QCTest, Encode29) { - uint8_t pkt[] = { - 0x30, 0xfe, 0x1, 0x0, 0x14, 0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, 0xd8, 0xb2, 0x64, 0x5e, - 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91, 0xd2, 0x1, 0x1, 0xf1, 0x1, 0x23, 0x22, 0x65, 0xf6, 0x23, 0x47, 0x15, 0x23, - 0x63, 0x8b, 0x11, 0x0, 0x0, 0x6c, 0x6, 0x12, 0x0, 0x9, 0xce, 0x91, 0xa4, 0x9a, 0x56, 0x13, 0x21, 0xc, 0x28, - 0x8, 0x0, 0x18, 0x46, 0xe9, 0xe1, 0xd0, 0xac, 0x41, 0xda, 0xa5, 0x71, 0x6c, 0xd4, 0xf4, 0xa8, 0xae, 0x5a, 0x9e, - 0x3a, 0x51, 0x1b, 0x99, 0xf5, 0xb0, 0x36, 0x8e, 0x9, 0x0, 0x18, 0x92, 0xa9, 0x21, 0xee, 0xc3, 0x44, 0xcc, 0xfa, - 0x63, 0x38, 0x28, 0x80, 0x16, 0xfb, 0xa6, 0xef, 0x29, 0x8a, 0xb2, 0x9c, 0x69, 0xa2, 0x9c, 0x5d, 0x2a, 0x40, 0x9, - 0x0, 0x7, 0x78, 0x32, 0x89, 0xcc, 0x28, 0xcc, 0xde, 0x2a, 0xe3, 0x9, 0x0, 0x14, 0x67, 0x2, 0x53, 0x45, 0x2a, - 0x83, 0xf0, 0x2d, 0xbe, 0x6, 0x9b, 0x25, 0x6e, 0x5f, 0x82, 0xe2, 0xff, 0x64, 0x52, 0xa2, 0x1f, 0x0, 0x1c, 0xc1, - 0xb9, 0x70, 0x5a, 0x0, 0x9c, 0xab, 0xb9, 0x4c, 0x45, 0x84, 0xfd, 0x1f, 0xe5, 0xb9, 0x7f, 0xd3, 0xc9, 0x69, 0x10, - 0x38, 0xb8, 0xe4, 0x1e, 0xc4, 0x53, 0xf7, 0xf7, 0x16, 0x0, 0x2, 0xee, 0xac, 0x2a, 0x94, 0x26, 0x0, 0x1d, 0xa0, - 0xc1, 0xbf, 0x12, 0x41, 0x41, 0xe8, 0x96, 0x57, 0xa1, 0xfc, 0xb1, 0xe3, 0x7, 0xaf, 0xa0, 0x16, 0x4c, 0xd4, 0xef, - 0x66, 0x4f, 0xf7, 0x27, 0x3c, 0x2e, 0x5, 0xe0, 0x7b, 0x0, 0x11, 0xb8, 0x3f, 0x75, 0x2a, 0x7d, 0x5f, 0x46, 0x86, - 0x38, 0x28, 0xd, 0xf2, 0x7c, 0x61, 0xba, 0x4f, 0x32, 0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, - 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; - uint8_t topic_bytes[] = {0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, - 0xd8, 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91}; - lwmqtt_string_t topic = {20, (char*)&topic_bytes}; + uint8_t pkt[] = {0x39, 0x1a, 0x0, 0x2, 0x72, 0xdf, 0xf, 0x23, 0x74, 0x44, 0x21, 0x30, 0xfa, 0x17, + 0xd9, 0x17, 0xd4, 0x18, 0x0, 0x0, 0x22, 0x4, 0x59, 0x26, 0xf1, 0x95, 0x5f, 0xb2}; + uint8_t topic_bytes[] = {0x72, 0xdf}; + lwmqtt_string_t topic = {2, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; msg.qos = LWMQTT_QOS0; - msg.retained = false; - uint8_t msg_bytes[] = {0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, - 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; + msg.retained = true; + uint8_t msg_bytes[] = {0x59, 0x26, 0xf1, 0x95, 0x5f, 0xb2}; msg.payload = (unsigned char*)&msg_bytes; - msg.payload_len = 20; - - uint8_t bytesprops0[] = {0xce, 0x91, 0xa4, 0x9a, 0x56, 0x13, 0x21, 0xc, 0x28}; - uint8_t bytesprops1[] = {0x46, 0xe9, 0xe1, 0xd0, 0xac, 0x41, 0xda, 0xa5, 0x71, 0x6c, 0xd4, 0xf4, - 0xa8, 0xae, 0x5a, 0x9e, 0x3a, 0x51, 0x1b, 0x99, 0xf5, 0xb0, 0x36, 0x8e}; - uint8_t bytesprops2[] = {0x92, 0xa9, 0x21, 0xee, 0xc3, 0x44, 0xcc, 0xfa, 0x63, 0x38, 0x28, 0x80, - 0x16, 0xfb, 0xa6, 0xef, 0x29, 0x8a, 0xb2, 0x9c, 0x69, 0xa2, 0x9c, 0x5d}; - uint8_t bytesprops3[] = {0x78, 0x32, 0x89, 0xcc, 0x28, 0xcc, 0xde}; - uint8_t bytesprops4[] = {0x67, 0x2, 0x53, 0x45, 0x2a, 0x83, 0xf0, 0x2d, 0xbe, 0x6, - 0x9b, 0x25, 0x6e, 0x5f, 0x82, 0xe2, 0xff, 0x64, 0x52, 0xa2}; - uint8_t bytesprops5[] = {0xc1, 0xb9, 0x70, 0x5a, 0x0, 0x9c, 0xab, 0xb9, 0x4c, 0x45, 0x84, 0xfd, 0x1f, 0xe5, - 0xb9, 0x7f, 0xd3, 0xc9, 0x69, 0x10, 0x38, 0xb8, 0xe4, 0x1e, 0xc4, 0x53, 0xf7, 0xf7}; - uint8_t bytesprops6[] = {0xee, 0xac}; - uint8_t bytesprops8[] = {0xb8, 0x3f, 0x75, 0x2a, 0x7d, 0x5f, 0x46, 0x86, 0x38, - 0x28, 0xd, 0xf2, 0x7c, 0x61, 0xba, 0x4f, 0x32}; - uint8_t bytesprops7[] = {0xa0, 0xc1, 0xbf, 0x12, 0x41, 0x41, 0xe8, 0x96, 0x57, 0xa1, 0xfc, 0xb1, 0xe3, 0x7, 0xaf, - 0xa0, 0x16, 0x4c, 0xd4, 0xef, 0x66, 0x4f, 0xf7, 0x27, 0x3c, 0x2e, 0x5, 0xe0, 0x7b}; + msg.payload_len = 6; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26102}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18197}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25483}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27654}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 148}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops7}, .v = {17, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29764}}, {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12538}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 217}}, {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8708}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 0, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = False, _pubTopic = -// "M\189d\165\NAK\165J\222\187)\216\178d^\194{\141\141y\145", _pubPktID = 0, _pubBody = -// "\245\129\188\154\242\232\161\228\255\&1lz\153\252~D\r\222\166\ENQ", _pubProps = [PropPayloadFormatIndicator -// 241,PropPayloadFormatIndicator 35,PropTopicAliasMaximum 26102,PropTopicAlias 18197,PropTopicAlias -// 25483,PropSessionExpiryInterval 27654,PropAssignedClientIdentifier "\206\145\164\154V\DC3!\f(",PropResponseTopic -// "F\233\225\208\172A\218\165ql\212\244\168\174Z\158:Q\ESC\153\245\176\&6\142",PropCorrelationData -// "\146\169!\238\195D\204\250c8(\128\SYN\251\166\239)\138\178\156i\162\156]",PropSharedSubscriptionAvailable -// 64,PropCorrelationData "x2\137\204(\204\222",PropSharedSubscriptionAvailable 227,PropCorrelationData -// "g\STXSE*\131\240-\190\ACK\155%n_\130\226\255dR\162",PropReasonString -// "\193\185pZ\NUL\156\171\185LE\132\253\US\229\185\DEL\211\201i\DLE8\184\228\RS\196S\247\247",PropAuthenticationData -// "\238\172",PropSharedSubscriptionAvailable 148,PropUserProperty -// "\160\193\191\DC2AA\232\150W\161\252\177\227\a\175\160\SYNL\212\239fO\247'<.\ENQ\224{" -// "\184?u*}_F\134\&8(\r\242|a\186O2"]} +// PublishRequest {_pubDup = True, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "r\223", _pubPktID = 0, _pubBody = +// "Y&\241\149_\178", _pubProps = [PropTopicAlias 29764,PropReceiveMaximum 12538,PropRequestProblemInformation +// 217,PropRequestProblemInformation 212,PropWillDelayInterval 8708]} TEST(Publish5QCTest, Decode29) { - uint8_t pkt[] = { - 0x30, 0xfe, 0x1, 0x0, 0x14, 0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, 0xd8, 0xb2, 0x64, 0x5e, - 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91, 0xd2, 0x1, 0x1, 0xf1, 0x1, 0x23, 0x22, 0x65, 0xf6, 0x23, 0x47, 0x15, 0x23, - 0x63, 0x8b, 0x11, 0x0, 0x0, 0x6c, 0x6, 0x12, 0x0, 0x9, 0xce, 0x91, 0xa4, 0x9a, 0x56, 0x13, 0x21, 0xc, 0x28, - 0x8, 0x0, 0x18, 0x46, 0xe9, 0xe1, 0xd0, 0xac, 0x41, 0xda, 0xa5, 0x71, 0x6c, 0xd4, 0xf4, 0xa8, 0xae, 0x5a, 0x9e, - 0x3a, 0x51, 0x1b, 0x99, 0xf5, 0xb0, 0x36, 0x8e, 0x9, 0x0, 0x18, 0x92, 0xa9, 0x21, 0xee, 0xc3, 0x44, 0xcc, 0xfa, - 0x63, 0x38, 0x28, 0x80, 0x16, 0xfb, 0xa6, 0xef, 0x29, 0x8a, 0xb2, 0x9c, 0x69, 0xa2, 0x9c, 0x5d, 0x2a, 0x40, 0x9, - 0x0, 0x7, 0x78, 0x32, 0x89, 0xcc, 0x28, 0xcc, 0xde, 0x2a, 0xe3, 0x9, 0x0, 0x14, 0x67, 0x2, 0x53, 0x45, 0x2a, - 0x83, 0xf0, 0x2d, 0xbe, 0x6, 0x9b, 0x25, 0x6e, 0x5f, 0x82, 0xe2, 0xff, 0x64, 0x52, 0xa2, 0x1f, 0x0, 0x1c, 0xc1, - 0xb9, 0x70, 0x5a, 0x0, 0x9c, 0xab, 0xb9, 0x4c, 0x45, 0x84, 0xfd, 0x1f, 0xe5, 0xb9, 0x7f, 0xd3, 0xc9, 0x69, 0x10, - 0x38, 0xb8, 0xe4, 0x1e, 0xc4, 0x53, 0xf7, 0xf7, 0x16, 0x0, 0x2, 0xee, 0xac, 0x2a, 0x94, 0x26, 0x0, 0x1d, 0xa0, - 0xc1, 0xbf, 0x12, 0x41, 0x41, 0xe8, 0x96, 0x57, 0xa1, 0xfc, 0xb1, 0xe3, 0x7, 0xaf, 0xa0, 0x16, 0x4c, 0xd4, 0xef, - 0x66, 0x4f, 0xf7, 0x27, 0x3c, 0x2e, 0x5, 0xe0, 0x7b, 0x0, 0x11, 0xb8, 0x3f, 0x75, 0x2a, 0x7d, 0x5f, 0x46, 0x86, - 0x38, 0x28, 0xd, 0xf2, 0x7c, 0x61, 0xba, 0x4f, 0x32, 0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, - 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; + uint8_t pkt[] = {0x39, 0x1a, 0x0, 0x2, 0x72, 0xdf, 0xf, 0x23, 0x74, 0x44, 0x21, 0x30, 0xfa, 0x17, + 0xd9, 0x17, 0xd4, 0x18, 0x0, 0x0, 0x22, 0x4, 0x59, 0x26, 0xf1, 0x95, 0x5f, 0xb2}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -5305,56 +4896,114 @@ TEST(Publish5QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x4d, 0xbd, 0x64, 0xa5, 0x15, 0xa5, 0x4a, 0xde, 0xbb, 0x29, - 0xd8, 0xb2, 0x64, 0x5e, 0xc2, 0x7b, 0x8d, 0x8d, 0x79, 0x91}; - lwmqtt_string_t exp_topic = {20, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0xf5, 0x81, 0xbc, 0x9a, 0xf2, 0xe8, 0xa1, 0xe4, 0xff, 0x31, - 0x6c, 0x7a, 0x99, 0xfc, 0x7e, 0x44, 0xd, 0xde, 0xa6, 0x5}; - lwmqtt_string_t exp_body = {20, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); + uint8_t exp_topic_bytes[] = {0x72, 0xdf}; + lwmqtt_string_t exp_topic = {2, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0x59, 0x26, 0xf1, 0x95, 0x5f, 0xb2}; + lwmqtt_string_t exp_body = {6, (char*)&exp_body_bytes}; + EXPECT_EQ(dup, true); EXPECT_EQ(msg.qos, LWMQTT_QOS0); - EXPECT_EQ(msg.retained, false); + EXPECT_EQ(msg.retained, true); EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 20); - EXPECT_EQ(msg.payload_len, 20); - EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 20); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 2); + EXPECT_EQ(msg.payload_len, 6); + EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 6); lwmqtt_string_t x = exp_topic; x = exp_body; } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "3V\138y.\181\&0", _pubPktID = 0, -// _pubBody = "2\248\176\206\GS<\197b\195`\241\aH", _pubProps = [PropRequestProblemInformation 172]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\247\220n\163\233a\SO%/\218\186\&6\163Z\GS\ESC3\b\189\140I\131\129\177\185\197\163\188\&6\SYN", _pubPktID = 3711, +// _pubBody = "\205H\232\STX\178\&33\r\237\140\240o\166", _pubProps = [PropSubscriptionIdentifier 2,PropUserProperty +// "\DC2P\161)\246\227\177(" "L\213\139:1\217\245\&0wnk+\182\138",PropMaximumPacketSize 31983,PropMessageExpiryInterval +// 21025,PropAssignedClientIdentifier +// "\219\244~_'T\131\135\255\&2\182\212\239\254\230\SUB\215\DC12\SUB\128q(\191",PropPayloadFormatIndicator +// 83,PropServerKeepAlive 31084,PropServerReference "\212\148J\147\"t\189\222\250\154\251\US",PropTopicAlias +// 8225,PropResponseInformation "\ACK\234\ETB-\180\205\DEL\ah\159",PropAssignedClientIdentifier +// "\183%$:B\181e\r\235\246\160\SI\209xD\238\227",PropResponseInformation "o\182\&2",PropAuthenticationMethod +// "8\DC2\140\191~\SUBZ<)"]} TEST(Publish5QCTest, Encode30) { - uint8_t pkt[] = {0x31, 0x19, 0x0, 0x7, 0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30, 0x2, 0x17, 0xac, - 0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; - uint8_t topic_bytes[] = {0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30}; - lwmqtt_string_t topic = {7, (char*)&topic_bytes}; + uint8_t pkt[] = {0x3b, 0xbd, 0x1, 0x0, 0x1e, 0xf7, 0xdc, 0x6e, 0xa3, 0xe9, 0x61, 0xe, 0x25, 0x2f, 0xda, 0xba, + 0x36, 0xa3, 0x5a, 0x1d, 0x1b, 0x33, 0x8, 0xbd, 0x8c, 0x49, 0x83, 0x81, 0xb1, 0xb9, 0xc5, 0xa3, + 0xbc, 0x36, 0x16, 0xe, 0x7f, 0x8c, 0x1, 0xb, 0x2, 0x26, 0x0, 0x8, 0x12, 0x50, 0xa1, 0x29, + 0xf6, 0xe3, 0xb1, 0x28, 0x0, 0xe, 0x4c, 0xd5, 0x8b, 0x3a, 0x31, 0xd9, 0xf5, 0x30, 0x77, 0x6e, + 0x6b, 0x2b, 0xb6, 0x8a, 0x27, 0x0, 0x0, 0x7c, 0xef, 0x2, 0x0, 0x0, 0x52, 0x21, 0x12, 0x0, + 0x18, 0xdb, 0xf4, 0x7e, 0x5f, 0x27, 0x54, 0x83, 0x87, 0xff, 0x32, 0xb6, 0xd4, 0xef, 0xfe, 0xe6, + 0x1a, 0xd7, 0x11, 0x32, 0x1a, 0x80, 0x71, 0x28, 0xbf, 0x1, 0x53, 0x13, 0x79, 0x6c, 0x1c, 0x0, + 0xc, 0xd4, 0x94, 0x4a, 0x93, 0x22, 0x74, 0xbd, 0xde, 0xfa, 0x9a, 0xfb, 0x1f, 0x23, 0x20, 0x21, + 0x1a, 0x0, 0xa, 0x6, 0xea, 0x17, 0x2d, 0xb4, 0xcd, 0x7f, 0x7, 0x68, 0x9f, 0x12, 0x0, 0x11, + 0xb7, 0x25, 0x24, 0x3a, 0x42, 0xb5, 0x65, 0xd, 0xeb, 0xf6, 0xa0, 0xf, 0xd1, 0x78, 0x44, 0xee, + 0xe3, 0x1a, 0x0, 0x3, 0x6f, 0xb6, 0x32, 0x15, 0x0, 0x9, 0x38, 0x12, 0x8c, 0xbf, 0x7e, 0x1a, + 0x5a, 0x3c, 0x29, 0xcd, 0x48, 0xe8, 0x2, 0xb2, 0x33, 0x33, 0xd, 0xed, 0x8c, 0xf0, 0x6f, 0xa6}; + uint8_t topic_bytes[] = {0xf7, 0xdc, 0x6e, 0xa3, 0xe9, 0x61, 0xe, 0x25, 0x2f, 0xda, 0xba, 0x36, 0xa3, 0x5a, 0x1d, + 0x1b, 0x33, 0x8, 0xbd, 0x8c, 0x49, 0x83, 0x81, 0xb1, 0xb9, 0xc5, 0xa3, 0xbc, 0x36, 0x16}; + lwmqtt_string_t topic = {30, (char*)&topic_bytes}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_message_t msg = lwmqtt_default_message; - msg.qos = LWMQTT_QOS0; + msg.qos = LWMQTT_QOS1; msg.retained = true; - uint8_t msg_bytes[] = {0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; + uint8_t msg_bytes[] = {0xcd, 0x48, 0xe8, 0x2, 0xb2, 0x33, 0x33, 0xd, 0xed, 0x8c, 0xf0, 0x6f, 0xa6}; msg.payload = (unsigned char*)&msg_bytes; msg.payload_len = 13; + uint8_t bytesprops1[] = {0x4c, 0xd5, 0x8b, 0x3a, 0x31, 0xd9, 0xf5, 0x30, 0x77, 0x6e, 0x6b, 0x2b, 0xb6, 0x8a}; + uint8_t bytesprops0[] = {0x12, 0x50, 0xa1, 0x29, 0xf6, 0xe3, 0xb1, 0x28}; + uint8_t bytesprops2[] = {0xdb, 0xf4, 0x7e, 0x5f, 0x27, 0x54, 0x83, 0x87, 0xff, 0x32, 0xb6, 0xd4, + 0xef, 0xfe, 0xe6, 0x1a, 0xd7, 0x11, 0x32, 0x1a, 0x80, 0x71, 0x28, 0xbf}; + uint8_t bytesprops3[] = {0xd4, 0x94, 0x4a, 0x93, 0x22, 0x74, 0xbd, 0xde, 0xfa, 0x9a, 0xfb, 0x1f}; + uint8_t bytesprops4[] = {0x6, 0xea, 0x17, 0x2d, 0xb4, 0xcd, 0x7f, 0x7, 0x68, 0x9f}; + uint8_t bytesprops5[] = {0xb7, 0x25, 0x24, 0x3a, 0x42, 0xb5, 0x65, 0xd, 0xeb, + 0xf6, 0xa0, 0xf, 0xd1, 0x78, 0x44, 0xee, 0xe3}; + uint8_t bytesprops6[] = {0x6f, 0xb6, 0x32}; + uint8_t bytesprops7[] = {0x38, 0x12, 0x8c, 0xbf, 0x7e, 0x1a, 0x5a, 0x3c, 0x29}; + lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 172}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {8, (char*)&bytesprops0}, .v = {14, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31983}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21025}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31084}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8225}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, false, 0, topic, msg, props); + lwmqtt_err_t err = lwmqtt_encode_publish(buf, sizeof(buf), &len, LWMQTT_MQTT5, true, 3711, topic, msg, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// PublishRequest {_pubDup = False, _pubQoS = QoS0, _pubRetain = True, _pubTopic = "3V\138y.\181\&0", _pubPktID = 0, -// _pubBody = "2\248\176\206\GS<\197b\195`\241\aH", _pubProps = [PropRequestProblemInformation 172]} +// PublishRequest {_pubDup = True, _pubQoS = QoS1, _pubRetain = True, _pubTopic = +// "\247\220n\163\233a\SO%/\218\186\&6\163Z\GS\ESC3\b\189\140I\131\129\177\185\197\163\188\&6\SYN", _pubPktID = 3711, +// _pubBody = "\205H\232\STX\178\&33\r\237\140\240o\166", _pubProps = [PropSubscriptionIdentifier 2,PropUserProperty +// "\DC2P\161)\246\227\177(" "L\213\139:1\217\245\&0wnk+\182\138",PropMaximumPacketSize 31983,PropMessageExpiryInterval +// 21025,PropAssignedClientIdentifier +// "\219\244~_'T\131\135\255\&2\182\212\239\254\230\SUB\215\DC12\SUB\128q(\191",PropPayloadFormatIndicator +// 83,PropServerKeepAlive 31084,PropServerReference "\212\148J\147\"t\189\222\250\154\251\US",PropTopicAlias +// 8225,PropResponseInformation "\ACK\234\ETB-\180\205\DEL\ah\159",PropAssignedClientIdentifier +// "\183%$:B\181e\r\235\246\160\SI\209xD\238\227",PropResponseInformation "o\182\&2",PropAuthenticationMethod +// "8\DC2\140\191~\SUBZ<)"]} TEST(Publish5QCTest, Decode30) { - uint8_t pkt[] = {0x31, 0x19, 0x0, 0x7, 0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30, 0x2, 0x17, 0xac, - 0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; + uint8_t pkt[] = {0x3b, 0xbd, 0x1, 0x0, 0x1e, 0xf7, 0xdc, 0x6e, 0xa3, 0xe9, 0x61, 0xe, 0x25, 0x2f, 0xda, 0xba, + 0x36, 0xa3, 0x5a, 0x1d, 0x1b, 0x33, 0x8, 0xbd, 0x8c, 0x49, 0x83, 0x81, 0xb1, 0xb9, 0xc5, 0xa3, + 0xbc, 0x36, 0x16, 0xe, 0x7f, 0x8c, 0x1, 0xb, 0x2, 0x26, 0x0, 0x8, 0x12, 0x50, 0xa1, 0x29, + 0xf6, 0xe3, 0xb1, 0x28, 0x0, 0xe, 0x4c, 0xd5, 0x8b, 0x3a, 0x31, 0xd9, 0xf5, 0x30, 0x77, 0x6e, + 0x6b, 0x2b, 0xb6, 0x8a, 0x27, 0x0, 0x0, 0x7c, 0xef, 0x2, 0x0, 0x0, 0x52, 0x21, 0x12, 0x0, + 0x18, 0xdb, 0xf4, 0x7e, 0x5f, 0x27, 0x54, 0x83, 0x87, 0xff, 0x32, 0xb6, 0xd4, 0xef, 0xfe, 0xe6, + 0x1a, 0xd7, 0x11, 0x32, 0x1a, 0x80, 0x71, 0x28, 0xbf, 0x1, 0x53, 0x13, 0x79, 0x6c, 0x1c, 0x0, + 0xc, 0xd4, 0x94, 0x4a, 0x93, 0x22, 0x74, 0xbd, 0xde, 0xfa, 0x9a, 0xfb, 0x1f, 0x23, 0x20, 0x21, + 0x1a, 0x0, 0xa, 0x6, 0xea, 0x17, 0x2d, 0xb4, 0xcd, 0x7f, 0x7, 0x68, 0x9f, 0x12, 0x0, 0x11, + 0xb7, 0x25, 0x24, 0x3a, 0x42, 0xb5, 0x65, 0xd, 0xeb, 0xf6, 0xa0, 0xf, 0xd1, 0x78, 0x44, 0xee, + 0xe3, 0x1a, 0x0, 0x3, 0x6f, 0xb6, 0x32, 0x15, 0x0, 0x9, 0x38, 0x12, 0x8c, 0xbf, 0x7e, 0x1a, + 0x5a, 0x3c, 0x29, 0xcd, 0x48, 0xe8, 0x2, 0xb2, 0x33, 0x33, 0xd, 0xed, 0x8c, 0xf0, 0x6f, 0xa6}; bool dup; uint16_t packet_id; lwmqtt_string_t topic; @@ -5363,24 +5012,26 @@ TEST(Publish5QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_publish(pkt, sizeof(pkt), LWMQTT_MQTT5, &dup, &packet_id, &topic, &msg, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - uint8_t exp_topic_bytes[] = {0x33, 0x56, 0x8a, 0x79, 0x2e, 0xb5, 0x30}; - lwmqtt_string_t exp_topic = {7, (char*)&exp_topic_bytes}; - uint8_t exp_body_bytes[] = {0x32, 0xf8, 0xb0, 0xce, 0x1d, 0x3c, 0xc5, 0x62, 0xc3, 0x60, 0xf1, 0x7, 0x48}; + uint8_t exp_topic_bytes[] = {0xf7, 0xdc, 0x6e, 0xa3, 0xe9, 0x61, 0xe, 0x25, 0x2f, 0xda, + 0xba, 0x36, 0xa3, 0x5a, 0x1d, 0x1b, 0x33, 0x8, 0xbd, 0x8c, + 0x49, 0x83, 0x81, 0xb1, 0xb9, 0xc5, 0xa3, 0xbc, 0x36, 0x16}; + lwmqtt_string_t exp_topic = {30, (char*)&exp_topic_bytes}; + uint8_t exp_body_bytes[] = {0xcd, 0x48, 0xe8, 0x2, 0xb2, 0x33, 0x33, 0xd, 0xed, 0x8c, 0xf0, 0x6f, 0xa6}; lwmqtt_string_t exp_body = {13, (char*)&exp_body_bytes}; - EXPECT_EQ(dup, false); - EXPECT_EQ(msg.qos, LWMQTT_QOS0); + EXPECT_EQ(dup, true); + EXPECT_EQ(msg.qos, LWMQTT_QOS1); EXPECT_EQ(msg.retained, true); - EXPECT_EQ(packet_id, 0); - EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 7); + EXPECT_EQ(packet_id, 3711); + EXPECT_ARRAY_EQ(exp_topic_bytes, reinterpret_cast(topic.data), 30); EXPECT_EQ(msg.payload_len, 13); EXPECT_ARRAY_EQ(exp_body_bytes, msg.payload, 13); lwmqtt_string_t x = exp_topic; x = exp_body; } -// ACK (PubACK 14158 0 []) -TEST(PubACKACK311QCTest, Encode1) { - uint8_t pkt[] = {0x40, 0x2, 0x37, 0x4e}; +// REL (PubREL 27662 0 []) +TEST(PubACKREL311QCTest, Encode1) { + uint8_t pkt[] = {0x62, 0x2, 0x6c, 0xe}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5388,59 +5039,58 @@ TEST(PubACKACK311QCTest, Encode1) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 14158, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 27662, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 14158 0 []) -TEST(PubACKACK311QCTest, Decode1) { - uint8_t pkt[] = {0x40, 0x2, 0x37, 0x4e}; +// REL (PubREL 27662 0 []) +TEST(PubACKREL311QCTest, Decode1) { + uint8_t pkt[] = {0x62, 0x2, 0x6c, 0xe}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14158); + EXPECT_EQ(packet_id, 27662); EXPECT_EQ(status, 0); } -// ACK (PubACK 24514 0 []) -TEST(PubACKACK311QCTest, Encode2) { - uint8_t pkt[] = {0x40, 0x2, 0x5f, 0xc2}; +// REL (PubREL 7224 0 []) +TEST(PubACKREL311QCTest, Encode2) { + uint8_t pkt[] = {0x62, 0x2, 0x1c, 0x38}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 24514, 0, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 7224, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 24514 0 []) -TEST(PubACKACK311QCTest, Decode2) { - uint8_t pkt[] = {0x40, 0x2, 0x5f, 0xc2}; +// REL (PubREL 7224 0 []) +TEST(PubACKREL311QCTest, Decode2) { + uint8_t pkt[] = {0x62, 0x2, 0x1c, 0x38}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24514); + EXPECT_EQ(packet_id, 7224); EXPECT_EQ(status, 0); } -// REC (PubREC 28006 0 []) -TEST(PubACKREC311QCTest, Encode3) { - uint8_t pkt[] = {0x50, 0x2, 0x6d, 0x66}; +// COMP (PubCOMP 1305 0 []) +TEST(PubACKCOMP311QCTest, Encode3) { + uint8_t pkt[] = {0x70, 0x2, 0x5, 0x19}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5448,89 +5098,87 @@ TEST(PubACKREC311QCTest, Encode3) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 28006, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 1305, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REC (PubREC 28006 0 []) -TEST(PubACKREC311QCTest, Decode3) { - uint8_t pkt[] = {0x50, 0x2, 0x6d, 0x66}; +// COMP (PubCOMP 1305 0 []) +TEST(PubACKCOMP311QCTest, Decode3) { + uint8_t pkt[] = {0x70, 0x2, 0x5, 0x19}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 28006); + EXPECT_EQ(packet_id, 1305); EXPECT_EQ(status, 0); } -// COMP (PubCOMP 4881 0 []) -TEST(PubACKCOMP311QCTest, Encode4) { - uint8_t pkt[] = {0x70, 0x2, 0x13, 0x11}; +// REL (PubREL 1388 0 []) +TEST(PubACKREL311QCTest, Encode4) { + uint8_t pkt[] = {0x62, 0x2, 0x5, 0x6c}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 4881, 0, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 1388, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 4881 0 []) -TEST(PubACKCOMP311QCTest, Decode4) { - uint8_t pkt[] = {0x70, 0x2, 0x13, 0x11}; +// REL (PubREL 1388 0 []) +TEST(PubACKREL311QCTest, Decode4) { + uint8_t pkt[] = {0x62, 0x2, 0x5, 0x6c}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4881); + EXPECT_EQ(packet_id, 1388); EXPECT_EQ(status, 0); } -// COMP (PubCOMP 4353 0 []) -TEST(PubACKCOMP311QCTest, Encode5) { - uint8_t pkt[] = {0x70, 0x2, 0x11, 0x1}; +// REC (PubREC 6133 0 []) +TEST(PubACKREC311QCTest, Encode5) { + uint8_t pkt[] = {0x50, 0x2, 0x17, 0xf5}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 4353, 0, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 6133, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 4353 0 []) -TEST(PubACKCOMP311QCTest, Decode5) { - uint8_t pkt[] = {0x70, 0x2, 0x11, 0x1}; +// REC (PubREC 6133 0 []) +TEST(PubACKREC311QCTest, Decode5) { + uint8_t pkt[] = {0x50, 0x2, 0x17, 0xf5}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4353); + EXPECT_EQ(packet_id, 6133); EXPECT_EQ(status, 0); } -// ACK (PubACK 15872 0 []) -TEST(PubACKACK311QCTest, Encode6) { - uint8_t pkt[] = {0x40, 0x2, 0x3e, 0x0}; +// REL (PubREL 16008 0 []) +TEST(PubACKREL311QCTest, Encode6) { + uint8_t pkt[] = {0x62, 0x2, 0x3e, 0x88}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5538,29 +5186,29 @@ TEST(PubACKACK311QCTest, Encode6) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 15872, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 16008, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 15872 0 []) -TEST(PubACKACK311QCTest, Decode6) { - uint8_t pkt[] = {0x40, 0x2, 0x3e, 0x0}; +// REL (PubREL 16008 0 []) +TEST(PubACKREL311QCTest, Decode6) { + uint8_t pkt[] = {0x62, 0x2, 0x3e, 0x88}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15872); + EXPECT_EQ(packet_id, 16008); EXPECT_EQ(status, 0); } -// REL (PubREL 21231 0 []) -TEST(PubACKREL311QCTest, Encode7) { - uint8_t pkt[] = {0x62, 0x2, 0x52, 0xef}; +// COMP (PubCOMP 11354 0 []) +TEST(PubACKCOMP311QCTest, Encode7) { + uint8_t pkt[] = {0x70, 0x2, 0x2c, 0x5a}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5568,59 +5216,58 @@ TEST(PubACKREL311QCTest, Encode7) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 21231, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 11354, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 21231 0 []) -TEST(PubACKREL311QCTest, Decode7) { - uint8_t pkt[] = {0x62, 0x2, 0x52, 0xef}; +// COMP (PubCOMP 11354 0 []) +TEST(PubACKCOMP311QCTest, Decode7) { + uint8_t pkt[] = {0x70, 0x2, 0x2c, 0x5a}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21231); + EXPECT_EQ(packet_id, 11354); EXPECT_EQ(status, 0); } -// REL (PubREL 10396 0 []) -TEST(PubACKREL311QCTest, Encode8) { - uint8_t pkt[] = {0x62, 0x2, 0x28, 0x9c}; +// ACK (PubACK 2046 0 []) +TEST(PubACKACK311QCTest, Encode8) { + uint8_t pkt[] = {0x40, 0x2, 0x7, 0xfe}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 10396, 0, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 2046, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 10396 0 []) -TEST(PubACKREL311QCTest, Decode8) { - uint8_t pkt[] = {0x62, 0x2, 0x28, 0x9c}; +// ACK (PubACK 2046 0 []) +TEST(PubACKACK311QCTest, Decode8) { + uint8_t pkt[] = {0x40, 0x2, 0x7, 0xfe}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10396); + EXPECT_EQ(packet_id, 2046); EXPECT_EQ(status, 0); } -// ACK (PubACK 26705 0 []) -TEST(PubACKACK311QCTest, Encode9) { - uint8_t pkt[] = {0x40, 0x2, 0x68, 0x51}; +// COMP (PubCOMP 13802 0 []) +TEST(PubACKCOMP311QCTest, Encode9) { + uint8_t pkt[] = {0x70, 0x2, 0x35, 0xea}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5628,29 +5275,29 @@ TEST(PubACKACK311QCTest, Encode9) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 26705, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 13802, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 26705 0 []) -TEST(PubACKACK311QCTest, Decode9) { - uint8_t pkt[] = {0x40, 0x2, 0x68, 0x51}; +// COMP (PubCOMP 13802 0 []) +TEST(PubACKCOMP311QCTest, Decode9) { + uint8_t pkt[] = {0x70, 0x2, 0x35, 0xea}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26705); + EXPECT_EQ(packet_id, 13802); EXPECT_EQ(status, 0); } -// ACK (PubACK 17554 0 []) -TEST(PubACKACK311QCTest, Encode10) { - uint8_t pkt[] = {0x40, 0x2, 0x44, 0x92}; +// REC (PubREC 16335 0 []) +TEST(PubACKREC311QCTest, Encode10) { + uint8_t pkt[] = {0x50, 0x2, 0x3f, 0xcf}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5658,29 +5305,29 @@ TEST(PubACKACK311QCTest, Encode10) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 17554, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 16335, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 17554 0 []) -TEST(PubACKACK311QCTest, Decode10) { - uint8_t pkt[] = {0x40, 0x2, 0x44, 0x92}; +// REC (PubREC 16335 0 []) +TEST(PubACKREC311QCTest, Decode10) { + uint8_t pkt[] = {0x50, 0x2, 0x3f, 0xcf}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17554); + EXPECT_EQ(packet_id, 16335); EXPECT_EQ(status, 0); } -// ACK (PubACK 24500 0 []) -TEST(PubACKACK311QCTest, Encode11) { - uint8_t pkt[] = {0x40, 0x2, 0x5f, 0xb4}; +// COMP (PubCOMP 5460 0 []) +TEST(PubACKCOMP311QCTest, Encode11) { + uint8_t pkt[] = {0x70, 0x2, 0x15, 0x54}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5688,29 +5335,29 @@ TEST(PubACKACK311QCTest, Encode11) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 24500, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 5460, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 24500 0 []) -TEST(PubACKACK311QCTest, Decode11) { - uint8_t pkt[] = {0x40, 0x2, 0x5f, 0xb4}; +// COMP (PubCOMP 5460 0 []) +TEST(PubACKCOMP311QCTest, Decode11) { + uint8_t pkt[] = {0x70, 0x2, 0x15, 0x54}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24500); + EXPECT_EQ(packet_id, 5460); EXPECT_EQ(status, 0); } -// COMP (PubCOMP 30295 0 []) +// COMP (PubCOMP 15537 0 []) TEST(PubACKCOMP311QCTest, Encode12) { - uint8_t pkt[] = {0x70, 0x2, 0x76, 0x57}; + uint8_t pkt[] = {0x70, 0x2, 0x3c, 0xb1}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5718,15 +5365,15 @@ TEST(PubACKCOMP311QCTest, Encode12) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 30295, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 15537, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 30295 0 []) +// COMP (PubCOMP 15537 0 []) TEST(PubACKCOMP311QCTest, Decode12) { - uint8_t pkt[] = {0x70, 0x2, 0x76, 0x57}; + uint8_t pkt[] = {0x70, 0x2, 0x3c, 0xb1}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; @@ -5734,13 +5381,13 @@ TEST(PubACKCOMP311QCTest, Decode12) { lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 30295); + EXPECT_EQ(packet_id, 15537); EXPECT_EQ(status, 0); } -// ACK (PubACK 17870 0 []) +// ACK (PubACK 28091 0 []) TEST(PubACKACK311QCTest, Encode13) { - uint8_t pkt[] = {0x40, 0x2, 0x45, 0xce}; + uint8_t pkt[] = {0x40, 0x2, 0x6d, 0xbb}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5748,15 +5395,15 @@ TEST(PubACKACK311QCTest, Encode13) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 17870, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 28091, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 17870 0 []) +// ACK (PubACK 28091 0 []) TEST(PubACKACK311QCTest, Decode13) { - uint8_t pkt[] = {0x40, 0x2, 0x45, 0xce}; + uint8_t pkt[] = {0x40, 0x2, 0x6d, 0xbb}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; @@ -5764,13 +5411,13 @@ TEST(PubACKACK311QCTest, Decode13) { lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17870); + EXPECT_EQ(packet_id, 28091); EXPECT_EQ(status, 0); } -// ACK (PubACK 18661 0 []) -TEST(PubACKACK311QCTest, Encode14) { - uint8_t pkt[] = {0x40, 0x2, 0x48, 0xe5}; +// REL (PubREL 10160 0 []) +TEST(PubACKREL311QCTest, Encode14) { + uint8_t pkt[] = {0x62, 0x2, 0x27, 0xb0}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5778,29 +5425,29 @@ TEST(PubACKACK311QCTest, Encode14) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 18661, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 10160, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 18661 0 []) -TEST(PubACKACK311QCTest, Decode14) { - uint8_t pkt[] = {0x40, 0x2, 0x48, 0xe5}; +// REL (PubREL 10160 0 []) +TEST(PubACKREL311QCTest, Decode14) { + uint8_t pkt[] = {0x62, 0x2, 0x27, 0xb0}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18661); + EXPECT_EQ(packet_id, 10160); EXPECT_EQ(status, 0); } -// REC (PubREC 32292 0 []) -TEST(PubACKREC311QCTest, Encode15) { - uint8_t pkt[] = {0x50, 0x2, 0x7e, 0x24}; +// REL (PubREL 30332 0 []) +TEST(PubACKREL311QCTest, Encode15) { + uint8_t pkt[] = {0x62, 0x2, 0x76, 0x7c}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5808,29 +5455,29 @@ TEST(PubACKREC311QCTest, Encode15) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 32292, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 30332, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REC (PubREC 32292 0 []) -TEST(PubACKREC311QCTest, Decode15) { - uint8_t pkt[] = {0x50, 0x2, 0x7e, 0x24}; +// REL (PubREL 30332 0 []) +TEST(PubACKREL311QCTest, Decode15) { + uint8_t pkt[] = {0x62, 0x2, 0x76, 0x7c}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32292); + EXPECT_EQ(packet_id, 30332); EXPECT_EQ(status, 0); } -// ACK (PubACK 11679 0 []) -TEST(PubACKACK311QCTest, Encode16) { - uint8_t pkt[] = {0x40, 0x2, 0x2d, 0x9f}; +// REL (PubREL 16804 0 []) +TEST(PubACKREL311QCTest, Encode16) { + uint8_t pkt[] = {0x62, 0x2, 0x41, 0xa4}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5838,75 +5485,73 @@ TEST(PubACKACK311QCTest, Encode16) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 11679, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 16804, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 11679 0 []) -TEST(PubACKACK311QCTest, Decode16) { - uint8_t pkt[] = {0x40, 0x2, 0x2d, 0x9f}; +// REL (PubREL 16804 0 []) +TEST(PubACKREL311QCTest, Decode16) { + uint8_t pkt[] = {0x62, 0x2, 0x41, 0xa4}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11679); + EXPECT_EQ(packet_id, 16804); EXPECT_EQ(status, 0); } -// COMP (PubCOMP 24709 0 []) -TEST(PubACKCOMP311QCTest, Encode17) { - uint8_t pkt[] = {0x70, 0x2, 0x60, 0x85}; +// REC (PubREC 5882 0 []) +TEST(PubACKREC311QCTest, Encode17) { + uint8_t pkt[] = {0x50, 0x2, 0x16, 0xfa}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 24709, 0, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 5882, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 24709 0 []) -TEST(PubACKCOMP311QCTest, Decode17) { - uint8_t pkt[] = {0x70, 0x2, 0x60, 0x85}; +// REC (PubREC 5882 0 []) +TEST(PubACKREC311QCTest, Decode17) { + uint8_t pkt[] = {0x50, 0x2, 0x16, 0xfa}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24709); + EXPECT_EQ(packet_id, 5882); EXPECT_EQ(status, 0); } -// REL (PubREL 19085 0 []) +// REL (PubREL 9713 0 []) TEST(PubACKREL311QCTest, Encode18) { - uint8_t pkt[] = {0x62, 0x2, 0x4a, 0x8d}; + uint8_t pkt[] = {0x62, 0x2, 0x25, 0xf1}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 19085, 0, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 9713, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 19085 0 []) +// REL (PubREL 9713 0 []) TEST(PubACKREL311QCTest, Decode18) { - uint8_t pkt[] = {0x62, 0x2, 0x4a, 0x8d}; + uint8_t pkt[] = {0x62, 0x2, 0x25, 0xf1}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; @@ -5914,13 +5559,13 @@ TEST(PubACKREL311QCTest, Decode18) { lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19085); + EXPECT_EQ(packet_id, 9713); EXPECT_EQ(status, 0); } -// ACK (PubACK 23245 0 []) -TEST(PubACKACK311QCTest, Encode19) { - uint8_t pkt[] = {0x40, 0x2, 0x5a, 0xcd}; +// REL (PubREL 28230 0 []) +TEST(PubACKREL311QCTest, Encode19) { + uint8_t pkt[] = {0x62, 0x2, 0x6e, 0x46}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5928,29 +5573,29 @@ TEST(PubACKACK311QCTest, Encode19) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 23245, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 28230, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 23245 0 []) -TEST(PubACKACK311QCTest, Decode19) { - uint8_t pkt[] = {0x40, 0x2, 0x5a, 0xcd}; +// REL (PubREL 28230 0 []) +TEST(PubACKREL311QCTest, Decode19) { + uint8_t pkt[] = {0x62, 0x2, 0x6e, 0x46}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 23245); + EXPECT_EQ(packet_id, 28230); EXPECT_EQ(status, 0); } -// REL (PubREL 27855 0 []) -TEST(PubACKREL311QCTest, Encode20) { - uint8_t pkt[] = {0x62, 0x2, 0x6c, 0xcf}; +// COMP (PubCOMP 19063 0 []) +TEST(PubACKCOMP311QCTest, Encode20) { + uint8_t pkt[] = {0x70, 0x2, 0x4a, 0x77}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -5958,116 +5603,118 @@ TEST(PubACKREL311QCTest, Encode20) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 27855, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 19063, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 27855 0 []) -TEST(PubACKREL311QCTest, Decode20) { - uint8_t pkt[] = {0x62, 0x2, 0x6c, 0xcf}; +// COMP (PubCOMP 19063 0 []) +TEST(PubACKCOMP311QCTest, Decode20) { + uint8_t pkt[] = {0x70, 0x2, 0x4a, 0x77}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27855); + EXPECT_EQ(packet_id, 19063); EXPECT_EQ(status, 0); } -// REL (PubREL 3263 0 []) -TEST(PubACKREL311QCTest, Encode21) { - uint8_t pkt[] = {0x62, 0x2, 0xc, 0xbf}; +// ACK (PubACK 459 0 []) +TEST(PubACKACK311QCTest, Encode21) { + uint8_t pkt[] = {0x40, 0x2, 0x1, 0xcb}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 3263, 0, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 459, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 3263 0 []) -TEST(PubACKREL311QCTest, Decode21) { - uint8_t pkt[] = {0x62, 0x2, 0xc, 0xbf}; +// ACK (PubACK 459 0 []) +TEST(PubACKACK311QCTest, Decode21) { + uint8_t pkt[] = {0x40, 0x2, 0x1, 0xcb}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3263); + EXPECT_EQ(packet_id, 459); EXPECT_EQ(status, 0); } -// ACK (PubACK 4790 0 []) -TEST(PubACKACK311QCTest, Encode22) { - uint8_t pkt[] = {0x40, 0x2, 0x12, 0xb6}; +// REC (PubREC 21707 0 []) +TEST(PubACKREC311QCTest, Encode22) { + uint8_t pkt[] = {0x50, 0x2, 0x54, 0xcb}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 4790, 0, props); + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 21707, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 4790 0 []) -TEST(PubACKACK311QCTest, Decode22) { - uint8_t pkt[] = {0x40, 0x2, 0x12, 0xb6}; +// REC (PubREC 21707 0 []) +TEST(PubACKREC311QCTest, Decode22) { + uint8_t pkt[] = {0x50, 0x2, 0x54, 0xcb}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4790); + EXPECT_EQ(packet_id, 21707); EXPECT_EQ(status, 0); } -// REL (PubREL 7224 0 []) -TEST(PubACKREL311QCTest, Encode23) { - uint8_t pkt[] = {0x62, 0x2, 0x1c, 0x38}; +// COMP (PubCOMP 29287 0 []) +TEST(PubACKCOMP311QCTest, Encode23) { + uint8_t pkt[] = {0x70, 0x2, 0x72, 0x67}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 7224, 0, props); + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 29287, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 7224 0 []) -TEST(PubACKREL311QCTest, Decode23) { - uint8_t pkt[] = {0x62, 0x2, 0x1c, 0x38}; +// COMP (PubCOMP 29287 0 []) +TEST(PubACKCOMP311QCTest, Decode23) { + uint8_t pkt[] = {0x70, 0x2, 0x72, 0x67}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7224); + EXPECT_EQ(packet_id, 29287); EXPECT_EQ(status, 0); } -// REL (PubREL 15593 0 []) +// REL (PubREL 18324 0 []) TEST(PubACKREL311QCTest, Encode24) { - uint8_t pkt[] = {0x62, 0x2, 0x3c, 0xe9}; + uint8_t pkt[] = {0x62, 0x2, 0x47, 0x94}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -6075,15 +5722,15 @@ TEST(PubACKREL311QCTest, Encode24) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 15593, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 18324, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 15593 0 []) +// REL (PubREL 18324 0 []) TEST(PubACKREL311QCTest, Decode24) { - uint8_t pkt[] = {0x62, 0x2, 0x3c, 0xe9}; + uint8_t pkt[] = {0x62, 0x2, 0x47, 0x94}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; @@ -6091,102 +5738,101 @@ TEST(PubACKREL311QCTest, Decode24) { lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15593); + EXPECT_EQ(packet_id, 18324); EXPECT_EQ(status, 0); } -// ACK (PubACK 9801 0 []) -TEST(PubACKACK311QCTest, Encode25) { - uint8_t pkt[] = {0x40, 0x2, 0x26, 0x49}; +// REL (PubREL 29610 0 []) +TEST(PubACKREL311QCTest, Encode25) { + uint8_t pkt[] = {0x62, 0x2, 0x73, 0xaa}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 9801, 0, props); + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 29610, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 9801 0 []) -TEST(PubACKACK311QCTest, Decode25) { - uint8_t pkt[] = {0x40, 0x2, 0x26, 0x49}; +// REL (PubREL 29610 0 []) +TEST(PubACKREL311QCTest, Decode25) { + uint8_t pkt[] = {0x62, 0x2, 0x73, 0xaa}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9801); + EXPECT_EQ(packet_id, 29610); EXPECT_EQ(status, 0); } -// ACK (PubACK 19499 0 []) -TEST(PubACKACK311QCTest, Encode26) { - uint8_t pkt[] = {0x40, 0x2, 0x4c, 0x2b}; +// REC (PubREC 5042 0 []) +TEST(PubACKREC311QCTest, Encode26) { + uint8_t pkt[] = {0x50, 0x2, 0x13, 0xb2}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, 0, 19499, 0, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 5042, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 19499 0 []) -TEST(PubACKACK311QCTest, Decode26) { - uint8_t pkt[] = {0x40, 0x2, 0x4c, 0x2b}; +// REC (PubREC 5042 0 []) +TEST(PubACKREC311QCTest, Decode26) { + uint8_t pkt[] = {0x50, 0x2, 0x13, 0xb2}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19499); + EXPECT_EQ(packet_id, 5042); EXPECT_EQ(status, 0); } -// COMP (PubCOMP 13110 0 []) -TEST(PubACKCOMP311QCTest, Encode27) { - uint8_t pkt[] = {0x70, 0x2, 0x33, 0x36}; +// REL (PubREL 2316 0 []) +TEST(PubACKREL311QCTest, Encode27) { + uint8_t pkt[] = {0x62, 0x2, 0x9, 0xc}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 13110, 0, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 2316, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 13110 0 []) -TEST(PubACKCOMP311QCTest, Decode27) { - uint8_t pkt[] = {0x70, 0x2, 0x33, 0x36}; +// REL (PubREL 2316 0 []) +TEST(PubACKREL311QCTest, Decode27) { + uint8_t pkt[] = {0x62, 0x2, 0x9, 0xc}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13110); + EXPECT_EQ(packet_id, 2316); EXPECT_EQ(status, 0); } -// REC (PubREC 25388 0 []) -TEST(PubACKREC311QCTest, Encode28) { - uint8_t pkt[] = {0x50, 0x2, 0x63, 0x2c}; +// REL (PubREL 28050 0 []) +TEST(PubACKREL311QCTest, Encode28) { + uint8_t pkt[] = {0x62, 0x2, 0x6d, 0x92}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -6194,29 +5840,29 @@ TEST(PubACKREC311QCTest, Encode28) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, 0, 25388, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, 0, 28050, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REC (PubREC 25388 0 []) -TEST(PubACKREC311QCTest, Decode28) { - uint8_t pkt[] = {0x50, 0x2, 0x63, 0x2c}; +// REL (PubREL 28050 0 []) +TEST(PubACKREL311QCTest, Decode28) { + uint8_t pkt[] = {0x62, 0x2, 0x6d, 0x92}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25388); + EXPECT_EQ(packet_id, 28050); EXPECT_EQ(status, 0); } -// COMP (PubCOMP 5812 0 []) +// COMP (PubCOMP 17627 0 []) TEST(PubACKCOMP311QCTest, Encode29) { - uint8_t pkt[] = {0x70, 0x2, 0x16, 0xb4}; + uint8_t pkt[] = {0x70, 0x2, 0x44, 0xdb}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -6224,15 +5870,15 @@ TEST(PubACKCOMP311QCTest, Encode29) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 5812, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 17627, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 5812 0 []) +// COMP (PubCOMP 17627 0 []) TEST(PubACKCOMP311QCTest, Decode29) { - uint8_t pkt[] = {0x70, 0x2, 0x16, 0xb4}; + uint8_t pkt[] = {0x70, 0x2, 0x44, 0xdb}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; @@ -6240,13 +5886,13 @@ TEST(PubACKCOMP311QCTest, Decode29) { lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 5812); + EXPECT_EQ(packet_id, 17627); EXPECT_EQ(status, 0); } -// COMP (PubCOMP 30696 0 []) +// COMP (PubCOMP 5627 0 []) TEST(PubACKCOMP311QCTest, Encode30) { - uint8_t pkt[] = {0x70, 0x2, 0x77, 0xe8}; + uint8_t pkt[] = {0x70, 0x2, 0x15, 0xfb}; uint8_t buf[sizeof(pkt) + 10]; lwmqtt_property_t propslist[] = {}; @@ -6254,15 +5900,15 @@ TEST(PubACKCOMP311QCTest, Encode30) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 30696, 0, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, 0, 5627, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 30696 0 []) +// COMP (PubCOMP 5627 0 []) TEST(PubACKCOMP311QCTest, Decode30) { - uint8_t pkt[] = {0x70, 0x2, 0x77, 0xe8}; + uint8_t pkt[] = {0x70, 0x2, 0x15, 0xfb}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; @@ -6270,2518 +5916,2374 @@ TEST(PubACKCOMP311QCTest, Decode30) { lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT311, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 30696); + EXPECT_EQ(packet_id, 5627); EXPECT_EQ(status, 0); } -// ACK (PubACK 14158 242 [PropPayloadFormatIndicator 151,PropAssignedClientIdentifier -// "$\221x7Y6M\132qc\213\177_\129vMq\157j\DEL@\229\186\210\252~\DC1C\ESC\195",PropWildcardSubscriptionAvailable -// 68,PropWildcardSubscriptionAvailable 216,PropAuthenticationMethod -// "\219\159g\228G\204\177X^\STXPU\246Dr\176/\151\n;\176\188\135\145",PropUserProperty -// "\DLE\250\235\241G\199\229?\250\240\218\&8\171\130M\251\244K" -// "-\242\233j\203[\200z\163\136\206\&6^\135\170\169\151\&5\240\217h\174",PropMessageExpiryInterval -// 31665,PropReasonString "\129\215\202\&2\236\142x\136\\\232e\245B\ETB\n",PropReceiveMaximum 23944,PropReasonString -// "\170|\244\a\139\143u}\243\140%\SI`tu\180\CANCF\161\173\129\161 \v\173X\206as",PropContentType "<50\231!M)"]) -TEST(PubACKACK5QCTest, Encode1) { - uint8_t pkt[] = { - 0x40, 0xb9, 0x1, 0x37, 0x4e, 0xf2, 0xb4, 0x1, 0x1, 0x97, 0x12, 0x0, 0x1e, 0x24, 0xdd, 0x78, 0x37, 0x59, 0x36, - 0x4d, 0x84, 0x71, 0x63, 0xd5, 0xb1, 0x5f, 0x81, 0x76, 0x4d, 0x71, 0x9d, 0x6a, 0x7f, 0x40, 0xe5, 0xba, 0xd2, 0xfc, - 0x7e, 0x11, 0x43, 0x1b, 0xc3, 0x28, 0x44, 0x28, 0xd8, 0x15, 0x0, 0x18, 0xdb, 0x9f, 0x67, 0xe4, 0x47, 0xcc, 0xb1, - 0x58, 0x5e, 0x2, 0x50, 0x55, 0xf6, 0x44, 0x72, 0xb0, 0x2f, 0x97, 0xa, 0x3b, 0xb0, 0xbc, 0x87, 0x91, 0x26, 0x0, - 0x12, 0x10, 0xfa, 0xeb, 0xf1, 0x47, 0xc7, 0xe5, 0x3f, 0xfa, 0xf0, 0xda, 0x38, 0xab, 0x82, 0x4d, 0xfb, 0xf4, 0x4b, - 0x0, 0x16, 0x2d, 0xf2, 0xe9, 0x6a, 0xcb, 0x5b, 0xc8, 0x7a, 0xa3, 0x88, 0xce, 0x36, 0x5e, 0x87, 0xaa, 0xa9, 0x97, - 0x35, 0xf0, 0xd9, 0x68, 0xae, 0x2, 0x0, 0x0, 0x7b, 0xb1, 0x1f, 0x0, 0xf, 0x81, 0xd7, 0xca, 0x32, 0xec, 0x8e, - 0x78, 0x88, 0x5c, 0xe8, 0x65, 0xf5, 0x42, 0x17, 0xa, 0x21, 0x5d, 0x88, 0x1f, 0x0, 0x1e, 0xaa, 0x7c, 0xf4, 0x7, - 0x8b, 0x8f, 0x75, 0x7d, 0xf3, 0x8c, 0x25, 0xf, 0x60, 0x74, 0x75, 0xb4, 0x18, 0x43, 0x46, 0xa1, 0xad, 0x81, 0xa1, - 0x20, 0xb, 0xad, 0x58, 0xce, 0x61, 0x73, 0x3, 0x0, 0x7, 0x3c, 0x35, 0x30, 0xe7, 0x21, 0x4d, 0x29}; +// REL (PubREL 27662 206 [PropMessageExpiryInterval 28381,PropServerReference +// "\251\162\EM\218\237)\181\158<\EOT",PropMessageExpiryInterval 11155,PropSharedSubscriptionAvailable +// 164,PropTopicAliasMaximum 16670,PropResponseTopic +// "\255\150\179A{\210\189\239s\NUL\140HNJ\228\249t3\191-\154\174\196\DEL\NUL\DC2\241\232-\183",PropMessageExpiryInterval +// 32084,PropAssignedClientIdentifier "\177`\162\ETX{rF\210\215\&2",PropWildcardSubscriptionAvailable +// 244,PropResponseInformation "\231\&7\153\156\222\235\CANe\208\237\DC3o\r\251",PropMessageExpiryInterval +// 5964,PropTopicAlias 24911,PropSessionExpiryInterval 27473,PropMaximumQoS 105,PropContentType +// "\DC4GEK\200Jc\170\153\142\181c\199\188\&3\249\198Z\n\DEL\250\208\DEL\246*p\239\240\143v",PropRetainAvailable 19]) +TEST(PubACKREL5QCTest, Encode1) { + uint8_t pkt[] = {0x62, 0x99, 0x1, 0x6c, 0xe, 0xce, 0x94, 0x1, 0x2, 0x0, 0x0, 0x6e, 0xdd, 0x1c, 0x0, 0xa, + 0xfb, 0xa2, 0x19, 0xda, 0xed, 0x29, 0xb5, 0x9e, 0x3c, 0x4, 0x2, 0x0, 0x0, 0x2b, 0x93, 0x2a, + 0xa4, 0x22, 0x41, 0x1e, 0x8, 0x0, 0x1e, 0xff, 0x96, 0xb3, 0x41, 0x7b, 0xd2, 0xbd, 0xef, 0x73, + 0x0, 0x8c, 0x48, 0x4e, 0x4a, 0xe4, 0xf9, 0x74, 0x33, 0xbf, 0x2d, 0x9a, 0xae, 0xc4, 0x7f, 0x0, + 0x12, 0xf1, 0xe8, 0x2d, 0xb7, 0x2, 0x0, 0x0, 0x7d, 0x54, 0x12, 0x0, 0xa, 0xb1, 0x60, 0xa2, + 0x3, 0x7b, 0x72, 0x46, 0xd2, 0xd7, 0x32, 0x28, 0xf4, 0x1a, 0x0, 0xe, 0xe7, 0x37, 0x99, 0x9c, + 0xde, 0xeb, 0x18, 0x65, 0xd0, 0xed, 0x13, 0x6f, 0xd, 0xfb, 0x2, 0x0, 0x0, 0x17, 0x4c, 0x23, + 0x61, 0x4f, 0x11, 0x0, 0x0, 0x6b, 0x51, 0x24, 0x69, 0x3, 0x0, 0x1e, 0x14, 0x47, 0x45, 0x4b, + 0xc8, 0x4a, 0x63, 0xaa, 0x99, 0x8e, 0xb5, 0x63, 0xc7, 0xbc, 0x33, 0xf9, 0xc6, 0x5a, 0xa, 0x7f, + 0xfa, 0xd0, 0x7f, 0xf6, 0x2a, 0x70, 0xef, 0xf0, 0x8f, 0x76, 0x25, 0x13}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0x24, 0xdd, 0x78, 0x37, 0x59, 0x36, 0x4d, 0x84, 0x71, 0x63, 0xd5, 0xb1, 0x5f, 0x81, 0x76, - 0x4d, 0x71, 0x9d, 0x6a, 0x7f, 0x40, 0xe5, 0xba, 0xd2, 0xfc, 0x7e, 0x11, 0x43, 0x1b, 0xc3}; - uint8_t bytesprops1[] = {0xdb, 0x9f, 0x67, 0xe4, 0x47, 0xcc, 0xb1, 0x58, 0x5e, 0x2, 0x50, 0x55, - 0xf6, 0x44, 0x72, 0xb0, 0x2f, 0x97, 0xa, 0x3b, 0xb0, 0xbc, 0x87, 0x91}; - uint8_t bytesprops3[] = {0x2d, 0xf2, 0xe9, 0x6a, 0xcb, 0x5b, 0xc8, 0x7a, 0xa3, 0x88, 0xce, - 0x36, 0x5e, 0x87, 0xaa, 0xa9, 0x97, 0x35, 0xf0, 0xd9, 0x68, 0xae}; - uint8_t bytesprops2[] = {0x10, 0xfa, 0xeb, 0xf1, 0x47, 0xc7, 0xe5, 0x3f, 0xfa, - 0xf0, 0xda, 0x38, 0xab, 0x82, 0x4d, 0xfb, 0xf4, 0x4b}; - uint8_t bytesprops4[] = {0x81, 0xd7, 0xca, 0x32, 0xec, 0x8e, 0x78, 0x88, 0x5c, 0xe8, 0x65, 0xf5, 0x42, 0x17, 0xa}; - uint8_t bytesprops5[] = {0xaa, 0x7c, 0xf4, 0x7, 0x8b, 0x8f, 0x75, 0x7d, 0xf3, 0x8c, 0x25, 0xf, 0x60, 0x74, 0x75, - 0xb4, 0x18, 0x43, 0x46, 0xa1, 0xad, 0x81, 0xa1, 0x20, 0xb, 0xad, 0x58, 0xce, 0x61, 0x73}; - uint8_t bytesprops6[] = {0x3c, 0x35, 0x30, 0xe7, 0x21, 0x4d, 0x29}; + uint8_t bytesprops0[] = {0xfb, 0xa2, 0x19, 0xda, 0xed, 0x29, 0xb5, 0x9e, 0x3c, 0x4}; + uint8_t bytesprops1[] = {0xff, 0x96, 0xb3, 0x41, 0x7b, 0xd2, 0xbd, 0xef, 0x73, 0x0, 0x8c, 0x48, 0x4e, 0x4a, 0xe4, + 0xf9, 0x74, 0x33, 0xbf, 0x2d, 0x9a, 0xae, 0xc4, 0x7f, 0x0, 0x12, 0xf1, 0xe8, 0x2d, 0xb7}; + uint8_t bytesprops2[] = {0xb1, 0x60, 0xa2, 0x3, 0x7b, 0x72, 0x46, 0xd2, 0xd7, 0x32}; + uint8_t bytesprops3[] = {0xe7, 0x37, 0x99, 0x9c, 0xde, 0xeb, 0x18, 0x65, 0xd0, 0xed, 0x13, 0x6f, 0xd, 0xfb}; + uint8_t bytesprops4[] = {0x14, 0x47, 0x45, 0x4b, 0xc8, 0x4a, 0x63, 0xaa, 0x99, 0x8e, 0xb5, 0x63, 0xc7, 0xbc, 0x33, + 0xf9, 0xc6, 0x5a, 0xa, 0x7f, 0xfa, 0xd0, 0x7f, 0xf6, 0x2a, 0x70, 0xef, 0xf0, 0x8f, 0x76}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops2}, .v = {22, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31665}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23944}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28381}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11155}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 164}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16670}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32084}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5964}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24911}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27473}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 19}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 14158, 242, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 27662, 206, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 14158 242 [PropPayloadFormatIndicator 151,PropAssignedClientIdentifier -// "$\221x7Y6M\132qc\213\177_\129vMq\157j\DEL@\229\186\210\252~\DC1C\ESC\195",PropWildcardSubscriptionAvailable -// 68,PropWildcardSubscriptionAvailable 216,PropAuthenticationMethod -// "\219\159g\228G\204\177X^\STXPU\246Dr\176/\151\n;\176\188\135\145",PropUserProperty -// "\DLE\250\235\241G\199\229?\250\240\218\&8\171\130M\251\244K" -// "-\242\233j\203[\200z\163\136\206\&6^\135\170\169\151\&5\240\217h\174",PropMessageExpiryInterval -// 31665,PropReasonString "\129\215\202\&2\236\142x\136\\\232e\245B\ETB\n",PropReceiveMaximum 23944,PropReasonString -// "\170|\244\a\139\143u}\243\140%\SI`tu\180\CANCF\161\173\129\161 \v\173X\206as",PropContentType "<50\231!M)"]) -TEST(PubACKACK5QCTest, Decode1) { - uint8_t pkt[] = { - 0x40, 0xb9, 0x1, 0x37, 0x4e, 0xf2, 0xb4, 0x1, 0x1, 0x97, 0x12, 0x0, 0x1e, 0x24, 0xdd, 0x78, 0x37, 0x59, 0x36, - 0x4d, 0x84, 0x71, 0x63, 0xd5, 0xb1, 0x5f, 0x81, 0x76, 0x4d, 0x71, 0x9d, 0x6a, 0x7f, 0x40, 0xe5, 0xba, 0xd2, 0xfc, - 0x7e, 0x11, 0x43, 0x1b, 0xc3, 0x28, 0x44, 0x28, 0xd8, 0x15, 0x0, 0x18, 0xdb, 0x9f, 0x67, 0xe4, 0x47, 0xcc, 0xb1, - 0x58, 0x5e, 0x2, 0x50, 0x55, 0xf6, 0x44, 0x72, 0xb0, 0x2f, 0x97, 0xa, 0x3b, 0xb0, 0xbc, 0x87, 0x91, 0x26, 0x0, - 0x12, 0x10, 0xfa, 0xeb, 0xf1, 0x47, 0xc7, 0xe5, 0x3f, 0xfa, 0xf0, 0xda, 0x38, 0xab, 0x82, 0x4d, 0xfb, 0xf4, 0x4b, - 0x0, 0x16, 0x2d, 0xf2, 0xe9, 0x6a, 0xcb, 0x5b, 0xc8, 0x7a, 0xa3, 0x88, 0xce, 0x36, 0x5e, 0x87, 0xaa, 0xa9, 0x97, - 0x35, 0xf0, 0xd9, 0x68, 0xae, 0x2, 0x0, 0x0, 0x7b, 0xb1, 0x1f, 0x0, 0xf, 0x81, 0xd7, 0xca, 0x32, 0xec, 0x8e, - 0x78, 0x88, 0x5c, 0xe8, 0x65, 0xf5, 0x42, 0x17, 0xa, 0x21, 0x5d, 0x88, 0x1f, 0x0, 0x1e, 0xaa, 0x7c, 0xf4, 0x7, - 0x8b, 0x8f, 0x75, 0x7d, 0xf3, 0x8c, 0x25, 0xf, 0x60, 0x74, 0x75, 0xb4, 0x18, 0x43, 0x46, 0xa1, 0xad, 0x81, 0xa1, - 0x20, 0xb, 0xad, 0x58, 0xce, 0x61, 0x73, 0x3, 0x0, 0x7, 0x3c, 0x35, 0x30, 0xe7, 0x21, 0x4d, 0x29}; +// REL (PubREL 27662 206 [PropMessageExpiryInterval 28381,PropServerReference +// "\251\162\EM\218\237)\181\158<\EOT",PropMessageExpiryInterval 11155,PropSharedSubscriptionAvailable +// 164,PropTopicAliasMaximum 16670,PropResponseTopic +// "\255\150\179A{\210\189\239s\NUL\140HNJ\228\249t3\191-\154\174\196\DEL\NUL\DC2\241\232-\183",PropMessageExpiryInterval +// 32084,PropAssignedClientIdentifier "\177`\162\ETX{rF\210\215\&2",PropWildcardSubscriptionAvailable +// 244,PropResponseInformation "\231\&7\153\156\222\235\CANe\208\237\DC3o\r\251",PropMessageExpiryInterval +// 5964,PropTopicAlias 24911,PropSessionExpiryInterval 27473,PropMaximumQoS 105,PropContentType +// "\DC4GEK\200Jc\170\153\142\181c\199\188\&3\249\198Z\n\DEL\250\208\DEL\246*p\239\240\143v",PropRetainAvailable 19]) +TEST(PubACKREL5QCTest, Decode1) { + uint8_t pkt[] = {0x62, 0x99, 0x1, 0x6c, 0xe, 0xce, 0x94, 0x1, 0x2, 0x0, 0x0, 0x6e, 0xdd, 0x1c, 0x0, 0xa, + 0xfb, 0xa2, 0x19, 0xda, 0xed, 0x29, 0xb5, 0x9e, 0x3c, 0x4, 0x2, 0x0, 0x0, 0x2b, 0x93, 0x2a, + 0xa4, 0x22, 0x41, 0x1e, 0x8, 0x0, 0x1e, 0xff, 0x96, 0xb3, 0x41, 0x7b, 0xd2, 0xbd, 0xef, 0x73, + 0x0, 0x8c, 0x48, 0x4e, 0x4a, 0xe4, 0xf9, 0x74, 0x33, 0xbf, 0x2d, 0x9a, 0xae, 0xc4, 0x7f, 0x0, + 0x12, 0xf1, 0xe8, 0x2d, 0xb7, 0x2, 0x0, 0x0, 0x7d, 0x54, 0x12, 0x0, 0xa, 0xb1, 0x60, 0xa2, + 0x3, 0x7b, 0x72, 0x46, 0xd2, 0xd7, 0x32, 0x28, 0xf4, 0x1a, 0x0, 0xe, 0xe7, 0x37, 0x99, 0x9c, + 0xde, 0xeb, 0x18, 0x65, 0xd0, 0xed, 0x13, 0x6f, 0xd, 0xfb, 0x2, 0x0, 0x0, 0x17, 0x4c, 0x23, + 0x61, 0x4f, 0x11, 0x0, 0x0, 0x6b, 0x51, 0x24, 0x69, 0x3, 0x0, 0x1e, 0x14, 0x47, 0x45, 0x4b, + 0xc8, 0x4a, 0x63, 0xaa, 0x99, 0x8e, 0xb5, 0x63, 0xc7, 0xbc, 0x33, 0xf9, 0xc6, 0x5a, 0xa, 0x7f, + 0xfa, 0xd0, 0x7f, 0xf6, 0x2a, 0x70, 0xef, 0xf0, 0x8f, 0x76, 0x25, 0x13}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14158); - EXPECT_EQ(status, 242); -} - -// ACK (PubACK 24514 112 [PropRetainAvailable 24,PropRetainAvailable 183,PropUserProperty "7\a\a\194~\164\142\SYN\149" -// "\160\a6!\175U>\200\188\228\254s",PropAssignedClientIdentifier -// ":\188\SUB/\NAK\219\183`X\144\&3\167\166\155O\232",PropMaximumQoS 118,PropRetainAvailable 81,PropResponseInformation -// "\253\237\DC3\186\158\STX\197\DELm\FS ",PropSharedSubscriptionAvailable 106,PropSubscriptionIdentifier -// 5,PropReasonString "\232\183H\138\140\DC1%\154\154?\t*X\163",PropTopicAlias 15968,PropAuthenticationMethod -// "\212\168[;t2\b\DELc\216\201\213r\189\226\SOH\227\238\225u\232\&7\158\SOHk\204\171\146",PropRequestProblemInformation -// 163]) -TEST(PubACKACK5QCTest, Encode2) { - uint8_t pkt[] = {0x40, 0x80, 0x1, 0x5f, 0xc2, 0x70, 0x7c, 0x25, 0x18, 0x25, 0xb7, 0x26, 0x0, 0x9, 0x37, 0x7, 0x7, - 0xc2, 0x7e, 0xa4, 0x8e, 0x16, 0x95, 0x0, 0xc, 0xa0, 0x7, 0x36, 0x21, 0xaf, 0x55, 0x3e, 0xc8, 0xbc, - 0xe4, 0xfe, 0x73, 0x12, 0x0, 0x10, 0x3a, 0xbc, 0x1a, 0x2f, 0x15, 0xdb, 0xb7, 0x60, 0x58, 0x90, 0x33, - 0xa7, 0xa6, 0x9b, 0x4f, 0xe8, 0x24, 0x76, 0x25, 0x51, 0x1a, 0x0, 0xb, 0xfd, 0xed, 0x13, 0xba, 0x9e, - 0x2, 0xc5, 0x7f, 0x6d, 0x1c, 0x20, 0x2a, 0x6a, 0xb, 0x5, 0x1f, 0x0, 0xe, 0xe8, 0xb7, 0x48, 0x8a, - 0x8c, 0x11, 0x25, 0x9a, 0x9a, 0x3f, 0x9, 0x2a, 0x58, 0xa3, 0x23, 0x3e, 0x60, 0x15, 0x0, 0x1c, 0xd4, - 0xa8, 0x5b, 0x3b, 0x74, 0x32, 0x8, 0x7f, 0x63, 0xd8, 0xc9, 0xd5, 0x72, 0xbd, 0xe2, 0x1, 0xe3, 0xee, - 0xe1, 0x75, 0xe8, 0x37, 0x9e, 0x1, 0x6b, 0xcc, 0xab, 0x92, 0x17, 0xa3}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 27662); + EXPECT_EQ(status, 206); +} + +// REL (PubREL 7224 232 []) +TEST(PubACKREL5QCTest, Encode2) { + uint8_t pkt[] = {0x62, 0x3, 0x1c, 0x38, 0xe8}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops1[] = {0xa0, 0x7, 0x36, 0x21, 0xaf, 0x55, 0x3e, 0xc8, 0xbc, 0xe4, 0xfe, 0x73}; - uint8_t bytesprops0[] = {0x37, 0x7, 0x7, 0xc2, 0x7e, 0xa4, 0x8e, 0x16, 0x95}; - uint8_t bytesprops2[] = {0x3a, 0xbc, 0x1a, 0x2f, 0x15, 0xdb, 0xb7, 0x60, - 0x58, 0x90, 0x33, 0xa7, 0xa6, 0x9b, 0x4f, 0xe8}; - uint8_t bytesprops3[] = {0xfd, 0xed, 0x13, 0xba, 0x9e, 0x2, 0xc5, 0x7f, 0x6d, 0x1c, 0x20}; - uint8_t bytesprops4[] = {0xe8, 0xb7, 0x48, 0x8a, 0x8c, 0x11, 0x25, 0x9a, 0x9a, 0x3f, 0x9, 0x2a, 0x58, 0xa3}; - uint8_t bytesprops5[] = {0xd4, 0xa8, 0x5b, 0x3b, 0x74, 0x32, 0x8, 0x7f, 0x63, 0xd8, 0xc9, 0xd5, 0x72, 0xbd, - 0xe2, 0x1, 0xe3, 0xee, 0xe1, 0x75, 0xe8, 0x37, 0x9e, 0x1, 0x6b, 0xcc, 0xab, 0x92}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops0}, .v = {12, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15968}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 163}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 24514, 112, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 7224, 232, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 24514 112 [PropRetainAvailable 24,PropRetainAvailable 183,PropUserProperty "7\a\a\194~\164\142\SYN\149" -// "\160\a6!\175U>\200\188\228\254s",PropAssignedClientIdentifier -// ":\188\SUB/\NAK\219\183`X\144\&3\167\166\155O\232",PropMaximumQoS 118,PropRetainAvailable 81,PropResponseInformation -// "\253\237\DC3\186\158\STX\197\DELm\FS ",PropSharedSubscriptionAvailable 106,PropSubscriptionIdentifier -// 5,PropReasonString "\232\183H\138\140\DC1%\154\154?\t*X\163",PropTopicAlias 15968,PropAuthenticationMethod -// "\212\168[;t2\b\DELc\216\201\213r\189\226\SOH\227\238\225u\232\&7\158\SOHk\204\171\146",PropRequestProblemInformation -// 163]) -TEST(PubACKACK5QCTest, Decode2) { - uint8_t pkt[] = {0x40, 0x80, 0x1, 0x5f, 0xc2, 0x70, 0x7c, 0x25, 0x18, 0x25, 0xb7, 0x26, 0x0, 0x9, 0x37, 0x7, 0x7, - 0xc2, 0x7e, 0xa4, 0x8e, 0x16, 0x95, 0x0, 0xc, 0xa0, 0x7, 0x36, 0x21, 0xaf, 0x55, 0x3e, 0xc8, 0xbc, - 0xe4, 0xfe, 0x73, 0x12, 0x0, 0x10, 0x3a, 0xbc, 0x1a, 0x2f, 0x15, 0xdb, 0xb7, 0x60, 0x58, 0x90, 0x33, - 0xa7, 0xa6, 0x9b, 0x4f, 0xe8, 0x24, 0x76, 0x25, 0x51, 0x1a, 0x0, 0xb, 0xfd, 0xed, 0x13, 0xba, 0x9e, - 0x2, 0xc5, 0x7f, 0x6d, 0x1c, 0x20, 0x2a, 0x6a, 0xb, 0x5, 0x1f, 0x0, 0xe, 0xe8, 0xb7, 0x48, 0x8a, - 0x8c, 0x11, 0x25, 0x9a, 0x9a, 0x3f, 0x9, 0x2a, 0x58, 0xa3, 0x23, 0x3e, 0x60, 0x15, 0x0, 0x1c, 0xd4, - 0xa8, 0x5b, 0x3b, 0x74, 0x32, 0x8, 0x7f, 0x63, 0xd8, 0xc9, 0xd5, 0x72, 0xbd, 0xe2, 0x1, 0xe3, 0xee, - 0xe1, 0x75, 0xe8, 0x37, 0x9e, 0x1, 0x6b, 0xcc, 0xab, 0x92, 0x17, 0xa3}; +// REL (PubREL 7224 232 []) +TEST(PubACKREL5QCTest, Decode2) { + uint8_t pkt[] = {0x62, 0x3, 0x1c, 0x38, 0xe8}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24514); - EXPECT_EQ(status, 112); -} - -// REC (PubREC 28006 97 [PropContentType "G\182\185\187}\152\140",PropServerReference -// "5\240\171\174\178kR\175\144\171\CAN]\138K\ACK\NULX\237\203\183r1\182f\156",PropReasonString -// "\244QV\168\&3\168\&7\158\SOH\RS\205\nk",PropServerKeepAlive 524,PropResponseTopic -// "2\246\135C3\200\202x2|E;\156\DLE\207\184\222\212\255\STX\205\196 0G",PropUserProperty -// "\a\251\249\215G\242\&9\NAKW\GS\217\r4JX\184\164\186:@\f\b\181\205" -// "\188nW\NAK;\192\161\229\189\175\EMG\222\&1\ACK\ETB\160",PropSharedSubscriptionAvailable 48,PropServerReference -// "#~\RS\246\ETB1t\206\246F\SUB\161\193\145\224N\154 D\213#",PropRequestResponseInformation 234,PropAuthenticationData -// "\148\194W\253)\169=@\t",PropReasonString -// "\a\173Z\203h\204\168\209)\DEL\SOH\ETX\159`\181-\208\175N_\173",PropTopicAliasMaximum 30918,PropRetainAvailable -// 251,PropResponseTopic -// "\ACKB\US\176[\180\128\210\178\182\236\ACK\236\161\ETX;\209\142-*\241\248\146",PropSessionExpiryInterval -// 12702,PropRequestProblemInformation 195,PropAuthenticationMethod -// "\221D\238F\235]\ETB\145]\137V\226N\179\220",PropRequestResponseInformation 33,PropReasonString -// "\139\177\248\195\&7K\165*Ep\132L\210\&7nN@\r\209",PropAuthenticationMethod -// "\180\255\&7\188\CANdr?m\142\218i\SI\173\222v",PropRequestResponseInformation 216,PropMaximumPacketSize -// 898,PropWillDelayInterval 13715,PropRequestProblemInformation 163,PropWillDelayInterval -// 7662,PropSharedSubscriptionAvailable 214]) -TEST(PubACKREC5QCTest, Encode3) { - uint8_t pkt[] = { - 0x50, 0xc0, 0x2, 0x6d, 0x66, 0x61, 0xbb, 0x2, 0x3, 0x0, 0x7, 0x47, 0xb6, 0xb9, 0xbb, 0x7d, 0x98, 0x8c, 0x1c, - 0x0, 0x19, 0x35, 0xf0, 0xab, 0xae, 0xb2, 0x6b, 0x52, 0xaf, 0x90, 0xab, 0x18, 0x5d, 0x8a, 0x4b, 0x6, 0x0, 0x58, - 0xed, 0xcb, 0xb7, 0x72, 0x31, 0xb6, 0x66, 0x9c, 0x1f, 0x0, 0xd, 0xf4, 0x51, 0x56, 0x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x9e, 0x17, 0xc3, 0x15, 0x0, 0xf, 0xdd, 0x44, 0xee, - 0x46, 0xeb, 0x5d, 0x17, 0x91, 0x5d, 0x89, 0x56, 0xe2, 0x4e, 0xb3, 0xdc, 0x19, 0x21, 0x1f, 0x0, 0x13, 0x8b, 0xb1, - 0xf8, 0xc3, 0x37, 0x4b, 0xa5, 0x2a, 0x45, 0x70, 0x84, 0x4c, 0xd2, 0x37, 0x6e, 0x4e, 0x40, 0xd, 0xd1, 0x15, 0x0, - 0x10, 0xb4, 0xff, 0x37, 0xbc, 0x18, 0x64, 0x72, 0x3f, 0x6d, 0x8e, 0xda, 0x69, 0xf, 0xad, 0xde, 0x76, 0x19, 0xd8, - 0x27, 0x0, 0x0, 0x3, 0x82, 0x18, 0x0, 0x0, 0x35, 0x93, 0x17, 0xa3, 0x18, 0x0, 0x0, 0x1d, 0xee, 0x2a, 0xd6}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 7224); + EXPECT_EQ(status, 232); +} + +// COMP (PubCOMP 1305 131 [PropRequestResponseInformation 131,PropAuthenticationData +// "\202B\131\147\197Nv0\153d\a\251\133\233tY\226\225eE",PropResponseInformation "\129\173[",PropSessionExpiryInterval +// 17545,PropTopicAlias 28775,PropContentType "\223pT\177\129\"\132\246",PropRetainAvailable 145,PropTopicAlias +// 32536,PropSubscriptionIdentifier 24,PropRetainAvailable 230,PropAuthenticationData +// "\CAN\171\&4m\182\235\207\128\163\&5P\242\&8\GS?\\J",PropTopicAliasMaximum 22478,PropResponseInformation "tE+\fk +// \160\DC1JI\235\247\172\208B",PropServerKeepAlive +// 21968,PropWillDelayInterval 18315,PropServerReference "{3\176\205\b\147\213\r\194\130e",PropPayloadFormatIndicator +// 143,PropUserProperty ";\n\NUL\165\183\230\252\198hG[)\v" +// "\238\250\&5\231%\b;\207\222\198\176\240\169\STX\195\198\133\218\214\SO",PropMaximumQoS 136,PropTopicAlias +// 1903,PropMaximumPacketSize 10248,PropRequestResponseInformation 159,PropRequestProblemInformation +// 126,PropRequestProblemInformation 176,PropResponseTopic +// "\235\SIl\251\ACKc\f\vh/\248\166-\198\vQ\246\160\205F\224\226\252\DC1;\177\161T)\200",PropMaximumPacketSize 27165]) +TEST(PubACKREL5QCTest, Encode4) { + uint8_t pkt[] = {0x62, 0xad, 0x1, 0x5, 0x6c, 0xf0, 0xa8, 0x1, 0x19, 0x94, 0x3, 0x0, 0x5, 0xf0, 0x15, 0x9c, + 0xb6, 0x89, 0x21, 0x5a, 0x22, 0x21, 0x57, 0xcf, 0x24, 0xd4, 0x28, 0x19, 0x1c, 0x0, 0x1d, 0xa9, + 0xa, 0xe, 0x42, 0xff, 0x4d, 0x3d, 0x44, 0x8b, 0xe9, 0xa, 0x97, 0xda, 0x63, 0x72, 0x47, 0xda, + 0xcd, 0x51, 0xfc, 0x19, 0x9f, 0x29, 0x3e, 0xeb, 0xf7, 0xac, 0xd0, 0x42, 0x13, 0x55, 0xd0, 0x18, + 0x0, 0x0, 0x47, 0x8b, 0x1c, 0x0, 0xb, 0x7b, 0x33, 0xb0, 0xcd, 0x8, 0x93, 0xd5, 0xd, 0xc2, + 0x82, 0x65, 0x1, 0x8f, 0x26, 0x0, 0xd, 0x3b, 0xa, 0x0, 0xa5, 0xb7, 0xe6, 0xfc, 0xc6, 0x68, + 0x47, 0x5b, 0x29, 0xb, 0x0, 0x14, 0xee, 0xfa, 0x35, 0xe7, 0x25, 0x8, 0x3b, 0xcf, 0xde, 0xc6, + 0xb0, 0xf0, 0xa9, 0x2, 0xc3, 0xc6, 0x85, 0xda, 0xd6, 0xe, 0x24, 0x88, 0x23, 0x7, 0x6f, 0x27, + 0x0, 0x0, 0x28, 0x8, 0x19, 0x9f, 0x17, 0x7e, 0x17, 0xb0, 0x8, 0x0, 0x1e, 0xeb, 0xf, 0x6c, + 0xfb, 0x6, 0x63, 0xc, 0xb, 0x68, 0x2f, 0xf8, 0xa6, 0x2d, 0xc6, 0xb, 0x51, 0xf6, 0xa0, 0xcd, + 0x46, 0xe0, 0xe2, 0xfc, 0x11, 0x3b, 0xb1, 0xa1, 0x54, 0x29, 0xc8, 0x27, 0x0, 0x0, 0x6a, 0x1d}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0x43, 0x60, 0xde, 0x7a, 0x33, 0xc1, 0x3f, 0xb2, - 0x8a, 0x8, 0xdb, 0x8d, 0x60, 0x28, 0xa7, 0x52}; - uint8_t bytesprops2[] = {0xb0, 0x93, 0xeb, 0xdd}; - uint8_t bytesprops1[] = {0x5e, 0xde}; - uint8_t bytesprops3[] = {0xb6, 0x4b, 0x46, 0xcd, 0xa7, 0xb8, 0xa5, 0x78, 0xcd, 0x29, 0x5e, 0xbb, 0xcb, 0x46}; + uint8_t bytesprops0[] = {0xf0, 0x15, 0x9c, 0xb6, 0x89}; + uint8_t bytesprops1[] = {0xa9, 0xa, 0xe, 0x42, 0xff, 0x4d, 0x3d, 0x44, 0x8b, 0xe9, 0xa, 0x97, 0xda, 0x63, 0x72, + 0x47, 0xda, 0xcd, 0x51, 0xfc, 0x19, 0x9f, 0x29, 0x3e, 0xeb, 0xf7, 0xac, 0xd0, 0x42}; + uint8_t bytesprops2[] = {0x7b, 0x33, 0xb0, 0xcd, 0x8, 0x93, 0xd5, 0xd, 0xc2, 0x82, 0x65}; + uint8_t bytesprops4[] = {0xee, 0xfa, 0x35, 0xe7, 0x25, 0x8, 0x3b, 0xcf, 0xde, 0xc6, + 0xb0, 0xf0, 0xa9, 0x2, 0xc3, 0xc6, 0x85, 0xda, 0xd6, 0xe}; + uint8_t bytesprops3[] = {0x3b, 0xa, 0x0, 0xa5, 0xb7, 0xe6, 0xfc, 0xc6, 0x68, 0x47, 0x5b, 0x29, 0xb}; + uint8_t bytesprops5[] = {0xeb, 0xf, 0x6c, 0xfb, 0x6, 0x63, 0xc, 0xb, 0x68, 0x2f, 0xf8, 0xa6, 0x2d, 0xc6, 0xb, + 0x51, 0xf6, 0xa0, 0xcd, 0x46, 0xe0, 0xe2, 0xfc, 0x11, 0x3b, 0xb1, 0xa1, 0x54, 0x29, 0xc8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops1}, .v = {4, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2888}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23074}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22479}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 25}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21968}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18315}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops3}, .v = {20, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1903}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10248}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 159}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27165}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 4881, 118, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 1388, 240, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 4881 118 [PropRequestResponseInformation 20,PropReasonString -// "C`\222z3\193?\178\138\b\219\141`(\167R",PropUserProperty "^\222" "\176\147\235\221",PropTopicAliasMaximum -// 2888,PropReasonString "\182KF\205\167\184\165x\205)^\187\203F",PropMaximumQoS 143]) -TEST(PubACKCOMP5QCTest, Decode4) { - uint8_t pkt[] = {0x70, 0x3a, 0x13, 0x11, 0x76, 0x36, 0x19, 0x14, 0x1f, 0x0, 0x10, 0x43, 0x60, 0xde, 0x7a, - 0x33, 0xc1, 0x3f, 0xb2, 0x8a, 0x8, 0xdb, 0x8d, 0x60, 0x28, 0xa7, 0x52, 0x26, 0x0, 0x2, - 0x5e, 0xde, 0x0, 0x4, 0xb0, 0x93, 0xeb, 0xdd, 0x22, 0xb, 0x48, 0x1f, 0x0, 0xe, 0xb6, - 0x4b, 0x46, 0xcd, 0xa7, 0xb8, 0xa5, 0x78, 0xcd, 0x29, 0x5e, 0xbb, 0xcb, 0x46, 0x24, 0x8f}; +// REL (PubREL 1388 240 [PropRequestResponseInformation 148,PropContentType "\240\NAK\156\182\137",PropReceiveMaximum +// 23074,PropReceiveMaximum 22479,PropMaximumQoS 212,PropWildcardSubscriptionAvailable 25,PropServerReference +// "\169\n\SOB\255M=D\139\233\n\151\218crG\218\205Q\252\EM\159)>\235\247\172\208B",PropServerKeepAlive +// 21968,PropWillDelayInterval 18315,PropServerReference "{3\176\205\b\147\213\r\194\130e",PropPayloadFormatIndicator +// 143,PropUserProperty ";\n\NUL\165\183\230\252\198hG[)\v" +// "\238\250\&5\231%\b;\207\222\198\176\240\169\STX\195\198\133\218\214\SO",PropMaximumQoS 136,PropTopicAlias +// 1903,PropMaximumPacketSize 10248,PropRequestResponseInformation 159,PropRequestProblemInformation +// 126,PropRequestProblemInformation 176,PropResponseTopic +// "\235\SIl\251\ACKc\f\vh/\248\166-\198\vQ\246\160\205F\224\226\252\DC1;\177\161T)\200",PropMaximumPacketSize 27165]) +TEST(PubACKREL5QCTest, Decode4) { + uint8_t pkt[] = {0x62, 0xad, 0x1, 0x5, 0x6c, 0xf0, 0xa8, 0x1, 0x19, 0x94, 0x3, 0x0, 0x5, 0xf0, 0x15, 0x9c, + 0xb6, 0x89, 0x21, 0x5a, 0x22, 0x21, 0x57, 0xcf, 0x24, 0xd4, 0x28, 0x19, 0x1c, 0x0, 0x1d, 0xa9, + 0xa, 0xe, 0x42, 0xff, 0x4d, 0x3d, 0x44, 0x8b, 0xe9, 0xa, 0x97, 0xda, 0x63, 0x72, 0x47, 0xda, + 0xcd, 0x51, 0xfc, 0x19, 0x9f, 0x29, 0x3e, 0xeb, 0xf7, 0xac, 0xd0, 0x42, 0x13, 0x55, 0xd0, 0x18, + 0x0, 0x0, 0x47, 0x8b, 0x1c, 0x0, 0xb, 0x7b, 0x33, 0xb0, 0xcd, 0x8, 0x93, 0xd5, 0xd, 0xc2, + 0x82, 0x65, 0x1, 0x8f, 0x26, 0x0, 0xd, 0x3b, 0xa, 0x0, 0xa5, 0xb7, 0xe6, 0xfc, 0xc6, 0x68, + 0x47, 0x5b, 0x29, 0xb, 0x0, 0x14, 0xee, 0xfa, 0x35, 0xe7, 0x25, 0x8, 0x3b, 0xcf, 0xde, 0xc6, + 0xb0, 0xf0, 0xa9, 0x2, 0xc3, 0xc6, 0x85, 0xda, 0xd6, 0xe, 0x24, 0x88, 0x23, 0x7, 0x6f, 0x27, + 0x0, 0x0, 0x28, 0x8, 0x19, 0x9f, 0x17, 0x7e, 0x17, 0xb0, 0x8, 0x0, 0x1e, 0xeb, 0xf, 0x6c, + 0xfb, 0x6, 0x63, 0xc, 0xb, 0x68, 0x2f, 0xf8, 0xa6, 0x2d, 0xc6, 0xb, 0x51, 0xf6, 0xa0, 0xcd, + 0x46, 0xe0, 0xe2, 0xfc, 0x11, 0x3b, 0xb1, 0xa1, 0x54, 0x29, 0xc8, 0x27, 0x0, 0x0, 0x6a, 0x1d}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4881); - EXPECT_EQ(status, 118); -} - -// COMP (PubCOMP 4353 234 [PropMessageExpiryInterval 2524,PropUserProperty -// "N\146\DC4\220\140+\201\DC4E\159\140J\186\233\230H\161\140\196\171\170vw`" -// "?\190o\214\238*\216\t\158\NUL\198\137",PropServerReference -// "X$\218\\\ESCMB\149\&5\251\152?\FSd6\138\194",PropSharedSubscriptionAvailable 129,PropPayloadFormatIndicator -// 73,PropSubscriptionIdentifier 15,PropReasonString "\172\172N\175\229\&7\154",PropWillDelayInterval -// 10616,PropSubscriptionIdentifierAvailable 208,PropSubscriptionIdentifierAvailable 92,PropRequestResponseInformation -// 184,PropMessageExpiryInterval 25121,PropSharedSubscriptionAvailable 33,PropMessageExpiryInterval 1066]) -TEST(PubACKCOMP5QCTest, Encode5) { - uint8_t pkt[] = {0x70, 0x6d, 0x11, 0x1, 0xea, 0x69, 0x2, 0x0, 0x0, 0x9, 0xdc, 0x26, 0x0, 0x18, 0x4e, 0x92, - 0x14, 0xdc, 0x8c, 0x2b, 0xc9, 0x14, 0x45, 0x9f, 0x8c, 0x4a, 0xba, 0xe9, 0xe6, 0x48, 0xa1, 0x8c, - 0xc4, 0xab, 0xaa, 0x76, 0x77, 0x60, 0x0, 0xc, 0x3f, 0xbe, 0x6f, 0xd6, 0xee, 0x2a, 0xd8, 0x9, - 0x9e, 0x0, 0xc6, 0x89, 0x1c, 0x0, 0x11, 0x58, 0x24, 0xda, 0x5c, 0x1b, 0x4d, 0x42, 0x95, 0x35, - 0xfb, 0x98, 0x3f, 0x1c, 0x64, 0x36, 0x8a, 0xc2, 0x2a, 0x81, 0x1, 0x49, 0xb, 0xf, 0x1f, 0x0, - 0x7, 0xac, 0xac, 0x4e, 0xaf, 0xe5, 0x37, 0x9a, 0x18, 0x0, 0x0, 0x29, 0x78, 0x29, 0xd0, 0x29, - 0x5c, 0x19, 0xb8, 0x2, 0x0, 0x0, 0x62, 0x21, 0x2a, 0x21, 0x2, 0x0, 0x0, 0x4, 0x2a}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 1388); + EXPECT_EQ(status, 240); +} + +// REC (PubREC 6133 154 [PropRetainAvailable 247,PropWildcardSubscriptionAvailable 253,PropContentType +// ")\252\197",PropMaximumPacketSize 20846,PropSharedSubscriptionAvailable 132,PropSubscriptionIdentifier +// 21,PropMaximumQoS 228]) +TEST(PubACKREC5QCTest, Encode5) { + uint8_t pkt[] = {0x50, 0x19, 0x17, 0xf5, 0x9a, 0x15, 0x25, 0xf7, 0x28, 0xfd, 0x3, 0x0, 0x3, 0x29, + 0xfc, 0xc5, 0x27, 0x0, 0x0, 0x51, 0x6e, 0x2a, 0x84, 0xb, 0x15, 0x24, 0xe4}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops1[] = {0x3f, 0xbe, 0x6f, 0xd6, 0xee, 0x2a, 0xd8, 0x9, 0x9e, 0x0, 0xc6, 0x89}; - uint8_t bytesprops0[] = {0x4e, 0x92, 0x14, 0xdc, 0x8c, 0x2b, 0xc9, 0x14, 0x45, 0x9f, 0x8c, 0x4a, - 0xba, 0xe9, 0xe6, 0x48, 0xa1, 0x8c, 0xc4, 0xab, 0xaa, 0x76, 0x77, 0x60}; - uint8_t bytesprops2[] = {0x58, 0x24, 0xda, 0x5c, 0x1b, 0x4d, 0x42, 0x95, 0x35, - 0xfb, 0x98, 0x3f, 0x1c, 0x64, 0x36, 0x8a, 0xc2}; - uint8_t bytesprops3[] = {0xac, 0xac, 0x4e, 0xaf, 0xe5, 0x37, 0x9a}; + uint8_t bytesprops0[] = {0x29, 0xfc, 0xc5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2524}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops0}, .v = {12, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10616}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 92}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25121}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1066}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20846}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 228}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 4353, 234, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, 0, 6133, 154, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 4353 234 [PropMessageExpiryInterval 2524,PropUserProperty -// "N\146\DC4\220\140+\201\DC4E\159\140J\186\233\230H\161\140\196\171\170vw`" -// "?\190o\214\238*\216\t\158\NUL\198\137",PropServerReference -// "X$\218\\\ESCMB\149\&5\251\152?\FSd6\138\194",PropSharedSubscriptionAvailable 129,PropPayloadFormatIndicator -// 73,PropSubscriptionIdentifier 15,PropReasonString "\172\172N\175\229\&7\154",PropWillDelayInterval -// 10616,PropSubscriptionIdentifierAvailable 208,PropSubscriptionIdentifierAvailable 92,PropRequestResponseInformation -// 184,PropMessageExpiryInterval 25121,PropSharedSubscriptionAvailable 33,PropMessageExpiryInterval 1066]) -TEST(PubACKCOMP5QCTest, Decode5) { - uint8_t pkt[] = {0x70, 0x6d, 0x11, 0x1, 0xea, 0x69, 0x2, 0x0, 0x0, 0x9, 0xdc, 0x26, 0x0, 0x18, 0x4e, 0x92, - 0x14, 0xdc, 0x8c, 0x2b, 0xc9, 0x14, 0x45, 0x9f, 0x8c, 0x4a, 0xba, 0xe9, 0xe6, 0x48, 0xa1, 0x8c, - 0xc4, 0xab, 0xaa, 0x76, 0x77, 0x60, 0x0, 0xc, 0x3f, 0xbe, 0x6f, 0xd6, 0xee, 0x2a, 0xd8, 0x9, - 0x9e, 0x0, 0xc6, 0x89, 0x1c, 0x0, 0x11, 0x58, 0x24, 0xda, 0x5c, 0x1b, 0x4d, 0x42, 0x95, 0x35, - 0xfb, 0x98, 0x3f, 0x1c, 0x64, 0x36, 0x8a, 0xc2, 0x2a, 0x81, 0x1, 0x49, 0xb, 0xf, 0x1f, 0x0, - 0x7, 0xac, 0xac, 0x4e, 0xaf, 0xe5, 0x37, 0x9a, 0x18, 0x0, 0x0, 0x29, 0x78, 0x29, 0xd0, 0x29, - 0x5c, 0x19, 0xb8, 0x2, 0x0, 0x0, 0x62, 0x21, 0x2a, 0x21, 0x2, 0x0, 0x0, 0x4, 0x2a}; +// REC (PubREC 6133 154 [PropRetainAvailable 247,PropWildcardSubscriptionAvailable 253,PropContentType +// ")\252\197",PropMaximumPacketSize 20846,PropSharedSubscriptionAvailable 132,PropSubscriptionIdentifier +// 21,PropMaximumQoS 228]) +TEST(PubACKREC5QCTest, Decode5) { + uint8_t pkt[] = {0x50, 0x19, 0x17, 0xf5, 0x9a, 0x15, 0x25, 0xf7, 0x28, 0xfd, 0x3, 0x0, 0x3, 0x29, + 0xfc, 0xc5, 0x27, 0x0, 0x0, 0x51, 0x6e, 0x2a, 0x84, 0xb, 0x15, 0x24, 0xe4}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4353); - EXPECT_EQ(status, 234); -} - -// ACK (PubACK 15872 214 [PropReceiveMaximum 30923,PropServerReference "\191\221u\175",PropUserProperty "4v]\t\n~ -// \t\210a\222\SYNN3\152" "\236\203\217r\161\179\245\ENQu\255\250\152\NAKF\238",PropTopicAlias -// 11786,PropMaximumPacketSize 30163,PropSubscriptionIdentifierAvailable 10,PropSubscriptionIdentifier -// 16,PropAuthenticationMethod ":\v\136\&1\138\183\DC2=\181\SUB\135\&5",PropAssignedClientIdentifier -// "b)\139",PropContentType "T\178\186\134^\149\130\200\a\199\128NtC\184o\156Q\172",PropAssignedClientIdentifier -// "tu/\180\141\191\184*\134\t\165\SOR%\190\243>\138\152 C\233\147e\v\172B\203\132",PropWildcardSubscriptionAvailable -// 205,PropContentType "f\b{\208\232C",PropSessionExpiryInterval 10209,PropMaximumQoS 161,PropReasonString -// "\188\179\240\f/\188Hd\r1\231\144\f\173p\\\134\SO_\213\EOT\253\&3~{\235M\RSZ",PropAuthenticationMethod -// "\205\213u\DLE\n\238"]) -TEST(PubACKACK5QCTest, Encode6) { - uint8_t pkt[] = {0x40, 0xc4, 0x1, 0x3e, 0x0, 0xd6, 0xbf, 0x1, 0x21, 0x78, 0xcb, 0x1c, 0x0, 0x4, 0xbf, 0xdd, 0x75, - 0xaf, 0x26, 0x0, 0xf, 0x34, 0x76, 0x5d, 0x9, 0xa, 0x7e, 0x20, 0x9, 0xd2, 0x61, 0xde, 0x16, 0x4e, - 0x33, 0x98, 0x0, 0xf, 0xec, 0xcb, 0xd9, 0x72, 0xa1, 0xb3, 0xf5, 0x5, 0x75, 0xff, 0xfa, 0x98, 0x15, - 0x46, 0xee, 0x23, 0x2e, 0xa, 0x27, 0x0, 0x0, 0x75, 0xd3, 0x29, 0xa, 0xb, 0x10, 0x15, 0x0, 0xc, - 0x3a, 0xb, 0x88, 0x31, 0x8a, 0xb7, 0x12, 0x3d, 0xb5, 0x1a, 0x87, 0x35, 0x12, 0x0, 0x3, 0x62, 0x29, - 0x8b, 0x3, 0x0, 0x13, 0x54, 0xb2, 0xba, 0x86, 0x5e, 0x95, 0x82, 0xc8, 0x7, 0xc7, 0x80, 0x4e, 0x74, - 0x43, 0xb8, 0x6f, 0x9c, 0x51, 0xac, 0x12, 0x0, 0x1d, 0x74, 0x75, 0x2f, 0xb4, 0x8d, 0xbf, 0xb8, 0x2a, - 0x86, 0x9, 0xa5, 0xe, 0x52, 0x25, 0xbe, 0xf3, 0x3e, 0x8a, 0x98, 0x20, 0x43, 0xe9, 0x93, 0x65, 0xb, - 0xac, 0x42, 0xcb, 0x84, 0x28, 0xcd, 0x3, 0x0, 0x6, 0x66, 0x8, 0x7b, 0xd0, 0xe8, 0x43, 0x11, 0x0, - 0x0, 0x27, 0xe1, 0x24, 0xa1, 0x1f, 0x0, 0x1d, 0xbc, 0xb3, 0xf0, 0xc, 0x2f, 0xbc, 0x48, 0x64, 0xd, - 0x31, 0xe7, 0x90, 0xc, 0xad, 0x70, 0x5c, 0x86, 0xe, 0x5f, 0xd5, 0x4, 0xfd, 0x33, 0x7e, 0x7b, 0xeb, - 0x4d, 0x1e, 0x5a, 0x15, 0x0, 0x6, 0xcd, 0xd5, 0x75, 0x10, 0xa, 0xee}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 6133); + EXPECT_EQ(status, 154); +} + +// REL (PubREL 16008 77 [PropMessageExpiryInterval 24253,PropSubscriptionIdentifier 17,PropCorrelationData +// "+-\bX\211\176yy\158\DC1W\186\214H/V&\189\194B\208\b\142\ENQ\166",PropReasonString +// "\ETB\ENQ\177\US\131\232P",PropMaximumQoS 242,PropRetainAvailable 120,PropResponseTopic +// "\182\208\145\SI\222\199\182\217\128\207\151O\225\RS\253u\ETXa^b\190",PropTopicAlias +// 18988,PropWildcardSubscriptionAvailable 2,PropWillDelayInterval 19083,PropSessionExpiryInterval +// 19792,PropSubscriptionIdentifier 14,PropTopicAlias 26758,PropMessageExpiryInterval 3502,PropMessageExpiryInterval +// 23733,PropCorrelationData +// "H\r4\207l\181\237\212\145\213\DC1n\179\175\189\253\150\237\ACK7t2\247",PropAuthenticationData +// "4\ETB,\229",PropAssignedClientIdentifier "}\219\147\139\177\236\223\160\ACK",PropResponseInformation +// "5Qmm\184\188\232\&4\140\195\187\236\183;\238*\EOT\174"]) +TEST(PubACKREL5QCTest, Encode6) { + uint8_t pkt[] = {0x62, 0xae, 0x1, 0x3e, 0x88, 0x4d, 0xa9, 0x1, 0x2, 0x0, 0x0, 0x5e, 0xbd, 0xb, 0x11, 0x9, 0x0, + 0x19, 0x2b, 0x2d, 0x8, 0x58, 0xd3, 0xb0, 0x79, 0x79, 0x9e, 0x11, 0x57, 0xba, 0xd6, 0x48, 0x2f, 0x56, + 0x26, 0xbd, 0xc2, 0x42, 0xd0, 0x8, 0x8e, 0x5, 0xa6, 0x1f, 0x0, 0x7, 0x17, 0x5, 0xb1, 0x1f, 0x83, + 0xe8, 0x50, 0x24, 0xf2, 0x25, 0x78, 0x8, 0x0, 0x15, 0xb6, 0xd0, 0x91, 0xf, 0xde, 0xc7, 0xb6, 0xd9, + 0x80, 0xcf, 0x97, 0x4f, 0xe1, 0x1e, 0xfd, 0x75, 0x3, 0x61, 0x5e, 0x62, 0xbe, 0x23, 0x4a, 0x2c, 0x28, + 0x2, 0x18, 0x0, 0x0, 0x4a, 0x8b, 0x11, 0x0, 0x0, 0x4d, 0x50, 0xb, 0xe, 0x23, 0x68, 0x86, 0x2, + 0x0, 0x0, 0xd, 0xae, 0x2, 0x0, 0x0, 0x5c, 0xb5, 0x9, 0x0, 0x17, 0x48, 0xd, 0x34, 0xcf, 0x6c, + 0xb5, 0xed, 0xd4, 0x91, 0xd5, 0x11, 0x6e, 0xb3, 0xaf, 0xbd, 0xfd, 0x96, 0xed, 0x6, 0x37, 0x74, 0x32, + 0xf7, 0x16, 0x0, 0x4, 0x34, 0x17, 0x2c, 0xe5, 0x12, 0x0, 0x9, 0x7d, 0xdb, 0x93, 0x8b, 0xb1, 0xec, + 0xdf, 0xa0, 0x6, 0x1a, 0x0, 0x12, 0x35, 0x51, 0x6d, 0x6d, 0xb8, 0xbc, 0xe8, 0x34, 0x8c, 0xc3, 0xbb, + 0xec, 0xb7, 0x3b, 0xee, 0x2a, 0x4, 0xae}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0xbf, 0xdd, 0x75, 0xaf}; - uint8_t bytesprops2[] = {0xec, 0xcb, 0xd9, 0x72, 0xa1, 0xb3, 0xf5, 0x5, 0x75, 0xff, 0xfa, 0x98, 0x15, 0x46, 0xee}; - uint8_t bytesprops1[] = {0x34, 0x76, 0x5d, 0x9, 0xa, 0x7e, 0x20, 0x9, 0xd2, 0x61, 0xde, 0x16, 0x4e, 0x33, 0x98}; - uint8_t bytesprops3[] = {0x3a, 0xb, 0x88, 0x31, 0x8a, 0xb7, 0x12, 0x3d, 0xb5, 0x1a, 0x87, 0x35}; - uint8_t bytesprops4[] = {0x62, 0x29, 0x8b}; - uint8_t bytesprops5[] = {0x54, 0xb2, 0xba, 0x86, 0x5e, 0x95, 0x82, 0xc8, 0x7, 0xc7, - 0x80, 0x4e, 0x74, 0x43, 0xb8, 0x6f, 0x9c, 0x51, 0xac}; - uint8_t bytesprops6[] = {0x74, 0x75, 0x2f, 0xb4, 0x8d, 0xbf, 0xb8, 0x2a, 0x86, 0x9, 0xa5, 0xe, 0x52, 0x25, 0xbe, - 0xf3, 0x3e, 0x8a, 0x98, 0x20, 0x43, 0xe9, 0x93, 0x65, 0xb, 0xac, 0x42, 0xcb, 0x84}; - uint8_t bytesprops7[] = {0x66, 0x8, 0x7b, 0xd0, 0xe8, 0x43}; - uint8_t bytesprops8[] = {0xbc, 0xb3, 0xf0, 0xc, 0x2f, 0xbc, 0x48, 0x64, 0xd, 0x31, 0xe7, 0x90, 0xc, 0xad, 0x70, - 0x5c, 0x86, 0xe, 0x5f, 0xd5, 0x4, 0xfd, 0x33, 0x7e, 0x7b, 0xeb, 0x4d, 0x1e, 0x5a}; - uint8_t bytesprops9[] = {0xcd, 0xd5, 0x75, 0x10, 0xa, 0xee}; + uint8_t bytesprops0[] = {0x2b, 0x2d, 0x8, 0x58, 0xd3, 0xb0, 0x79, 0x79, 0x9e, 0x11, 0x57, 0xba, 0xd6, + 0x48, 0x2f, 0x56, 0x26, 0xbd, 0xc2, 0x42, 0xd0, 0x8, 0x8e, 0x5, 0xa6}; + uint8_t bytesprops1[] = {0x17, 0x5, 0xb1, 0x1f, 0x83, 0xe8, 0x50}; + uint8_t bytesprops2[] = {0xb6, 0xd0, 0x91, 0xf, 0xde, 0xc7, 0xb6, 0xd9, 0x80, 0xcf, 0x97, + 0x4f, 0xe1, 0x1e, 0xfd, 0x75, 0x3, 0x61, 0x5e, 0x62, 0xbe}; + uint8_t bytesprops3[] = {0x48, 0xd, 0x34, 0xcf, 0x6c, 0xb5, 0xed, 0xd4, 0x91, 0xd5, 0x11, 0x6e, + 0xb3, 0xaf, 0xbd, 0xfd, 0x96, 0xed, 0x6, 0x37, 0x74, 0x32, 0xf7}; + uint8_t bytesprops4[] = {0x34, 0x17, 0x2c, 0xe5}; + uint8_t bytesprops5[] = {0x7d, 0xdb, 0x93, 0x8b, 0xb1, 0xec, 0xdf, 0xa0, 0x6}; + uint8_t bytesprops6[] = {0x35, 0x51, 0x6d, 0x6d, 0xb8, 0xbc, 0xe8, 0x34, 0x8c, + 0xc3, 0xbb, 0xec, 0xb7, 0x3b, 0xee, 0x2a, 0x4, 0xae}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30923}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops1}, .v = {15, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11786}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30163}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10209}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24253}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18988}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 2}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19083}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19792}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26758}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3502}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23733}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 15872, 214, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 16008, 77, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 15872 214 [PropReceiveMaximum 30923,PropServerReference "\191\221u\175",PropUserProperty "4v]\t\n~ -// \t\210a\222\SYNN3\152" "\236\203\217r\161\179\245\ENQu\255\250\152\NAKF\238",PropTopicAlias -// 11786,PropMaximumPacketSize 30163,PropSubscriptionIdentifierAvailable 10,PropSubscriptionIdentifier -// 16,PropAuthenticationMethod ":\v\136\&1\138\183\DC2=\181\SUB\135\&5",PropAssignedClientIdentifier -// "b)\139",PropContentType "T\178\186\134^\149\130\200\a\199\128NtC\184o\156Q\172",PropAssignedClientIdentifier -// "tu/\180\141\191\184*\134\t\165\SOR%\190\243>\138\152 C\233\147e\v\172B\203\132",PropWildcardSubscriptionAvailable -// 205,PropContentType "f\b{\208\232C",PropSessionExpiryInterval 10209,PropMaximumQoS 161,PropReasonString -// "\188\179\240\f/\188Hd\r1\231\144\f\173p\\\134\SO_\213\EOT\253\&3~{\235M\RSZ",PropAuthenticationMethod -// "\205\213u\DLE\n\238"]) -TEST(PubACKACK5QCTest, Decode6) { - uint8_t pkt[] = {0x40, 0xc4, 0x1, 0x3e, 0x0, 0xd6, 0xbf, 0x1, 0x21, 0x78, 0xcb, 0x1c, 0x0, 0x4, 0xbf, 0xdd, 0x75, - 0xaf, 0x26, 0x0, 0xf, 0x34, 0x76, 0x5d, 0x9, 0xa, 0x7e, 0x20, 0x9, 0xd2, 0x61, 0xde, 0x16, 0x4e, - 0x33, 0x98, 0x0, 0xf, 0xec, 0xcb, 0xd9, 0x72, 0xa1, 0xb3, 0xf5, 0x5, 0x75, 0xff, 0xfa, 0x98, 0x15, - 0x46, 0xee, 0x23, 0x2e, 0xa, 0x27, 0x0, 0x0, 0x75, 0xd3, 0x29, 0xa, 0xb, 0x10, 0x15, 0x0, 0xc, - 0x3a, 0xb, 0x88, 0x31, 0x8a, 0xb7, 0x12, 0x3d, 0xb5, 0x1a, 0x87, 0x35, 0x12, 0x0, 0x3, 0x62, 0x29, - 0x8b, 0x3, 0x0, 0x13, 0x54, 0xb2, 0xba, 0x86, 0x5e, 0x95, 0x82, 0xc8, 0x7, 0xc7, 0x80, 0x4e, 0x74, - 0x43, 0xb8, 0x6f, 0x9c, 0x51, 0xac, 0x12, 0x0, 0x1d, 0x74, 0x75, 0x2f, 0xb4, 0x8d, 0xbf, 0xb8, 0x2a, - 0x86, 0x9, 0xa5, 0xe, 0x52, 0x25, 0xbe, 0xf3, 0x3e, 0x8a, 0x98, 0x20, 0x43, 0xe9, 0x93, 0x65, 0xb, - 0xac, 0x42, 0xcb, 0x84, 0x28, 0xcd, 0x3, 0x0, 0x6, 0x66, 0x8, 0x7b, 0xd0, 0xe8, 0x43, 0x11, 0x0, - 0x0, 0x27, 0xe1, 0x24, 0xa1, 0x1f, 0x0, 0x1d, 0xbc, 0xb3, 0xf0, 0xc, 0x2f, 0xbc, 0x48, 0x64, 0xd, - 0x31, 0xe7, 0x90, 0xc, 0xad, 0x70, 0x5c, 0x86, 0xe, 0x5f, 0xd5, 0x4, 0xfd, 0x33, 0x7e, 0x7b, 0xeb, - 0x4d, 0x1e, 0x5a, 0x15, 0x0, 0x6, 0xcd, 0xd5, 0x75, 0x10, 0xa, 0xee}; +// REL (PubREL 16008 77 [PropMessageExpiryInterval 24253,PropSubscriptionIdentifier 17,PropCorrelationData +// "+-\bX\211\176yy\158\DC1W\186\214H/V&\189\194B\208\b\142\ENQ\166",PropReasonString +// "\ETB\ENQ\177\US\131\232P",PropMaximumQoS 242,PropRetainAvailable 120,PropResponseTopic +// "\182\208\145\SI\222\199\182\217\128\207\151O\225\RS\253u\ETXa^b\190",PropTopicAlias +// 18988,PropWildcardSubscriptionAvailable 2,PropWillDelayInterval 19083,PropSessionExpiryInterval +// 19792,PropSubscriptionIdentifier 14,PropTopicAlias 26758,PropMessageExpiryInterval 3502,PropMessageExpiryInterval +// 23733,PropCorrelationData +// "H\r4\207l\181\237\212\145\213\DC1n\179\175\189\253\150\237\ACK7t2\247",PropAuthenticationData +// "4\ETB,\229",PropAssignedClientIdentifier "}\219\147\139\177\236\223\160\ACK",PropResponseInformation +// "5Qmm\184\188\232\&4\140\195\187\236\183;\238*\EOT\174"]) +TEST(PubACKREL5QCTest, Decode6) { + uint8_t pkt[] = {0x62, 0xae, 0x1, 0x3e, 0x88, 0x4d, 0xa9, 0x1, 0x2, 0x0, 0x0, 0x5e, 0xbd, 0xb, 0x11, 0x9, 0x0, + 0x19, 0x2b, 0x2d, 0x8, 0x58, 0xd3, 0xb0, 0x79, 0x79, 0x9e, 0x11, 0x57, 0xba, 0xd6, 0x48, 0x2f, 0x56, + 0x26, 0xbd, 0xc2, 0x42, 0xd0, 0x8, 0x8e, 0x5, 0xa6, 0x1f, 0x0, 0x7, 0x17, 0x5, 0xb1, 0x1f, 0x83, + 0xe8, 0x50, 0x24, 0xf2, 0x25, 0x78, 0x8, 0x0, 0x15, 0xb6, 0xd0, 0x91, 0xf, 0xde, 0xc7, 0xb6, 0xd9, + 0x80, 0xcf, 0x97, 0x4f, 0xe1, 0x1e, 0xfd, 0x75, 0x3, 0x61, 0x5e, 0x62, 0xbe, 0x23, 0x4a, 0x2c, 0x28, + 0x2, 0x18, 0x0, 0x0, 0x4a, 0x8b, 0x11, 0x0, 0x0, 0x4d, 0x50, 0xb, 0xe, 0x23, 0x68, 0x86, 0x2, + 0x0, 0x0, 0xd, 0xae, 0x2, 0x0, 0x0, 0x5c, 0xb5, 0x9, 0x0, 0x17, 0x48, 0xd, 0x34, 0xcf, 0x6c, + 0xb5, 0xed, 0xd4, 0x91, 0xd5, 0x11, 0x6e, 0xb3, 0xaf, 0xbd, 0xfd, 0x96, 0xed, 0x6, 0x37, 0x74, 0x32, + 0xf7, 0x16, 0x0, 0x4, 0x34, 0x17, 0x2c, 0xe5, 0x12, 0x0, 0x9, 0x7d, 0xdb, 0x93, 0x8b, 0xb1, 0xec, + 0xdf, 0xa0, 0x6, 0x1a, 0x0, 0x12, 0x35, 0x51, 0x6d, 0x6d, 0xb8, 0xbc, 0xe8, 0x34, 0x8c, 0xc3, 0xbb, + 0xec, 0xb7, 0x3b, 0xee, 0x2a, 0x4, 0xae}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 15872); - EXPECT_EQ(status, 214); -} - -// REL (PubREL 21231 228 [PropUserProperty "\v" -// "\138\213\v=-\147\SYN8\221%\224\240!S\135JEj\210\203\206\217`\202H\ETB+",PropServerKeepAlive -// 5414,PropWillDelayInterval 17971,PropContentType "\244\a",PropTopicAliasMaximum 17656,PropReceiveMaximum -// 9191,PropRetainAvailable 122,PropUserProperty "h\140\179\254\r\232\172\215&\144\189\146\131\SUB@l\255\138\162" -// "\186/-U)\232\245\&2",PropMessageExpiryInterval 660,PropServerKeepAlive 9579,PropPayloadFormatIndicator -// 187,PropPayloadFormatIndicator 214,PropReasonString "\247b\200g\248y\137!\220k8o\221\&6",PropResponseInformation -// "wkdM/\138\232\SO\199\203\US\180\143Qfof\161\RSv\247\233B\132OM"]) -TEST(PubACKREL5QCTest, Encode7) { - uint8_t pkt[] = {0x62, 0x95, 0x1, 0x52, 0xef, 0xe4, 0x90, 0x1, 0x26, 0x0, 0x1, 0xb, 0x0, 0x1b, 0x8a, 0xd5, 0xb, - 0x3d, 0x2d, 0x93, 0x16, 0x38, 0xdd, 0x25, 0xe0, 0xf0, 0x21, 0x53, 0x87, 0x4a, 0x45, 0x6a, 0xd2, 0xcb, - 0xce, 0xd9, 0x60, 0xca, 0x48, 0x17, 0x2b, 0x13, 0x15, 0x26, 0x18, 0x0, 0x0, 0x46, 0x33, 0x3, 0x0, - 0x2, 0xf4, 0x7, 0x22, 0x44, 0xf8, 0x21, 0x23, 0xe7, 0x25, 0x7a, 0x26, 0x0, 0x13, 0x68, 0x8c, 0xb3, - 0xfe, 0xd, 0xe8, 0xac, 0xd7, 0x26, 0x90, 0xbd, 0x92, 0x83, 0x1a, 0x40, 0x6c, 0xff, 0x8a, 0xa2, 0x0, - 0x8, 0xba, 0x2f, 0x2d, 0x55, 0x29, 0xe8, 0xf5, 0x32, 0x2, 0x0, 0x0, 0x2, 0x94, 0x13, 0x25, 0x6b, - 0x1, 0xbb, 0x1, 0xd6, 0x1f, 0x0, 0xe, 0xf7, 0x62, 0xc8, 0x67, 0xf8, 0x79, 0x89, 0x21, 0xdc, 0x6b, - 0x38, 0x6f, 0xdd, 0x36, 0x1a, 0x0, 0x1a, 0x77, 0x6b, 0x64, 0x4d, 0x2f, 0x8a, 0xe8, 0xe, 0xc7, 0xcb, - 0x1f, 0xb4, 0x8f, 0x51, 0x66, 0x6f, 0x66, 0xa1, 0x1e, 0x76, 0xf7, 0xe9, 0x42, 0x84, 0x4f, 0x4d}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 16008); + EXPECT_EQ(status, 77); +} + +// COMP (PubCOMP 11354 201 [PropWildcardSubscriptionAvailable 99,PropWildcardSubscriptionAvailable 193]) +TEST(PubACKCOMP5QCTest, Encode7) { + uint8_t pkt[] = {0x70, 0x8, 0x2c, 0x5a, 0xc9, 0x4, 0x28, 0x63, 0x28, 0xc1}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops1[] = {0x8a, 0xd5, 0xb, 0x3d, 0x2d, 0x93, 0x16, 0x38, 0xdd, 0x25, 0xe0, 0xf0, 0x21, 0x53, - 0x87, 0x4a, 0x45, 0x6a, 0xd2, 0xcb, 0xce, 0xd9, 0x60, 0xca, 0x48, 0x17, 0x2b}; - uint8_t bytesprops0[] = {0xb}; - uint8_t bytesprops2[] = {0xf4, 0x7}; - uint8_t bytesprops4[] = {0xba, 0x2f, 0x2d, 0x55, 0x29, 0xe8, 0xf5, 0x32}; - uint8_t bytesprops3[] = {0x68, 0x8c, 0xb3, 0xfe, 0xd, 0xe8, 0xac, 0xd7, 0x26, 0x90, - 0xbd, 0x92, 0x83, 0x1a, 0x40, 0x6c, 0xff, 0x8a, 0xa2}; - uint8_t bytesprops5[] = {0xf7, 0x62, 0xc8, 0x67, 0xf8, 0x79, 0x89, 0x21, 0xdc, 0x6b, 0x38, 0x6f, 0xdd, 0x36}; - uint8_t bytesprops6[] = {0x77, 0x6b, 0x64, 0x4d, 0x2f, 0x8a, 0xe8, 0xe, 0xc7, 0xcb, 0x1f, 0xb4, 0x8f, - 0x51, 0x66, 0x6f, 0x66, 0xa1, 0x1e, 0x76, 0xf7, 0xe9, 0x42, 0x84, 0x4f, 0x4d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {27, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5414}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17971}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17656}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9191}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops3}, .v = {8, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 660}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9579}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 193}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 21231, 228, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 11354, 201, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 21231 228 [PropUserProperty "\v" -// "\138\213\v=-\147\SYN8\221%\224\240!S\135JEj\210\203\206\217`\202H\ETB+",PropServerKeepAlive -// 5414,PropWillDelayInterval 17971,PropContentType "\244\a",PropTopicAliasMaximum 17656,PropReceiveMaximum -// 9191,PropRetainAvailable 122,PropUserProperty "h\140\179\254\r\232\172\215&\144\189\146\131\SUB@l\255\138\162" -// "\186/-U)\232\245\&2",PropMessageExpiryInterval 660,PropServerKeepAlive 9579,PropPayloadFormatIndicator -// 187,PropPayloadFormatIndicator 214,PropReasonString "\247b\200g\248y\137!\220k8o\221\&6",PropResponseInformation -// "wkdM/\138\232\SO\199\203\US\180\143Qfof\161\RSv\247\233B\132OM"]) -TEST(PubACKREL5QCTest, Decode7) { - uint8_t pkt[] = {0x62, 0x95, 0x1, 0x52, 0xef, 0xe4, 0x90, 0x1, 0x26, 0x0, 0x1, 0xb, 0x0, 0x1b, 0x8a, 0xd5, 0xb, - 0x3d, 0x2d, 0x93, 0x16, 0x38, 0xdd, 0x25, 0xe0, 0xf0, 0x21, 0x53, 0x87, 0x4a, 0x45, 0x6a, 0xd2, 0xcb, - 0xce, 0xd9, 0x60, 0xca, 0x48, 0x17, 0x2b, 0x13, 0x15, 0x26, 0x18, 0x0, 0x0, 0x46, 0x33, 0x3, 0x0, - 0x2, 0xf4, 0x7, 0x22, 0x44, 0xf8, 0x21, 0x23, 0xe7, 0x25, 0x7a, 0x26, 0x0, 0x13, 0x68, 0x8c, 0xb3, - 0xfe, 0xd, 0xe8, 0xac, 0xd7, 0x26, 0x90, 0xbd, 0x92, 0x83, 0x1a, 0x40, 0x6c, 0xff, 0x8a, 0xa2, 0x0, - 0x8, 0xba, 0x2f, 0x2d, 0x55, 0x29, 0xe8, 0xf5, 0x32, 0x2, 0x0, 0x0, 0x2, 0x94, 0x13, 0x25, 0x6b, - 0x1, 0xbb, 0x1, 0xd6, 0x1f, 0x0, 0xe, 0xf7, 0x62, 0xc8, 0x67, 0xf8, 0x79, 0x89, 0x21, 0xdc, 0x6b, - 0x38, 0x6f, 0xdd, 0x36, 0x1a, 0x0, 0x1a, 0x77, 0x6b, 0x64, 0x4d, 0x2f, 0x8a, 0xe8, 0xe, 0xc7, 0xcb, - 0x1f, 0xb4, 0x8f, 0x51, 0x66, 0x6f, 0x66, 0xa1, 0x1e, 0x76, 0xf7, 0xe9, 0x42, 0x84, 0x4f, 0x4d}; +// COMP (PubCOMP 11354 201 [PropWildcardSubscriptionAvailable 99,PropWildcardSubscriptionAvailable 193]) +TEST(PubACKCOMP5QCTest, Decode7) { + uint8_t pkt[] = {0x70, 0x8, 0x2c, 0x5a, 0xc9, 0x4, 0x28, 0x63, 0x28, 0xc1}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21231); - EXPECT_EQ(status, 228); -} - -// REL (PubREL 10396 126 [PropWildcardSubscriptionAvailable 80,PropReceiveMaximum 30778,PropSubscriptionIdentifier -// 13,PropRequestProblemInformation 23,PropMaximumQoS 91,PropContentType -// "\164\248\174\155\177\251\SOH\187\SOH*\179Q\132\146\171\201\254\254\187\223\132\226Z\DC3E",PropServerReference -// "\185\163\188DA\253\SOH\224\239\t\199\136\173\219#\229Ty\151\210)",PropTopicAliasMaximum 15956,PropAuthenticationData -// "\SYN\171U\192\141\251\196\b\196\180p\140C\234aH5\228\241~\165F\245\197\169",PropRequestResponseInformation -// 16,PropReasonString -// "\208U?\187\206S_5\129\215V\255\196q\188e\244L\229W\135\184\247\253",PropRequestProblemInformation 233]) -TEST(PubACKREL5QCTest, Encode8) { - uint8_t pkt[] = {0x62, 0x81, 0x1, 0x28, 0x9c, 0x7e, 0x7d, 0x28, 0x50, 0x21, 0x78, 0x3a, 0xb, 0xd, 0x17, 0x17, 0x24, - 0x5b, 0x3, 0x0, 0x19, 0xa4, 0xf8, 0xae, 0x9b, 0xb1, 0xfb, 0x1, 0xbb, 0x1, 0x2a, 0xb3, 0x51, 0x84, - 0x92, 0xab, 0xc9, 0xfe, 0xfe, 0xbb, 0xdf, 0x84, 0xe2, 0x5a, 0x13, 0x45, 0x1c, 0x0, 0x15, 0xb9, 0xa3, - 0xbc, 0x44, 0x41, 0xfd, 0x1, 0xe0, 0xef, 0x9, 0xc7, 0x88, 0xad, 0xdb, 0x23, 0xe5, 0x54, 0x79, 0x97, - 0xd2, 0x29, 0x22, 0x3e, 0x54, 0x16, 0x0, 0x19, 0x16, 0xab, 0x55, 0xc0, 0x8d, 0xfb, 0xc4, 0x8, 0xc4, - 0xb4, 0x70, 0x8c, 0x43, 0xea, 0x61, 0x48, 0x35, 0xe4, 0xf1, 0x7e, 0xa5, 0x46, 0xf5, 0xc5, 0xa9, 0x19, - 0x10, 0x1f, 0x0, 0x18, 0xd0, 0x55, 0x3f, 0xbb, 0xce, 0x53, 0x5f, 0x35, 0x81, 0xd7, 0x56, 0xff, 0xc4, - 0x71, 0xbc, 0x65, 0xf4, 0x4c, 0xe5, 0x57, 0x87, 0xb8, 0xf7, 0xfd, 0x17, 0xe9}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 11354); + EXPECT_EQ(status, 201); +} + +// ACK (PubACK 2046 206 [PropSessionExpiryInterval 17445,PropCorrelationData +// "\163L\218I<\DLE\173\r\143\v\160",PropResponseTopic "J\198\190\246",PropResponseInformation "2\156\222 +// \212\&9\ETX\228\154",PropReasonString +// "\bX)\a\173\204\150wL\202*`\247E\225\"\171\222.\157\194ocC\252\170\133",PropTopicAlias +// 18914,PropSubscriptionIdentifierAvailable 143,PropCorrelationData "4\172\DC2Y\236",PropMaximumQoS 43]) +TEST(PubACKACK5QCTest, Encode8) { + uint8_t pkt[] = {0x40, 0x57, 0x7, 0xfe, 0xce, 0x53, 0x11, 0x0, 0x0, 0x44, 0x25, 0x9, 0x0, 0xb, 0xa3, + 0x4c, 0xda, 0x49, 0x3c, 0x10, 0xad, 0xd, 0x8f, 0xb, 0xa0, 0x8, 0x0, 0x4, 0x4a, 0xc6, + 0xbe, 0xf6, 0x1a, 0x0, 0x9, 0x32, 0x9c, 0xde, 0x20, 0xd4, 0x39, 0x3, 0xe4, 0x9a, 0x1f, + 0x0, 0x1b, 0x8, 0x58, 0x29, 0x7, 0xad, 0xcc, 0x96, 0x77, 0x4c, 0xca, 0x2a, 0x60, 0xf7, + 0x45, 0xe1, 0x22, 0xab, 0xde, 0x2e, 0x9d, 0xc2, 0x6f, 0x63, 0x43, 0xfc, 0xaa, 0x85, 0x23, + 0x49, 0xe2, 0x29, 0x8f, 0x9, 0x0, 0x5, 0x34, 0xac, 0x12, 0x59, 0xec, 0x24, 0x2b}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0xa4, 0xf8, 0xae, 0x9b, 0xb1, 0xfb, 0x1, 0xbb, 0x1, 0x2a, 0xb3, 0x51, 0x84, - 0x92, 0xab, 0xc9, 0xfe, 0xfe, 0xbb, 0xdf, 0x84, 0xe2, 0x5a, 0x13, 0x45}; - uint8_t bytesprops1[] = {0xb9, 0xa3, 0xbc, 0x44, 0x41, 0xfd, 0x1, 0xe0, 0xef, 0x9, 0xc7, - 0x88, 0xad, 0xdb, 0x23, 0xe5, 0x54, 0x79, 0x97, 0xd2, 0x29}; - uint8_t bytesprops2[] = {0x16, 0xab, 0x55, 0xc0, 0x8d, 0xfb, 0xc4, 0x8, 0xc4, 0xb4, 0x70, 0x8c, 0x43, - 0xea, 0x61, 0x48, 0x35, 0xe4, 0xf1, 0x7e, 0xa5, 0x46, 0xf5, 0xc5, 0xa9}; - uint8_t bytesprops3[] = {0xd0, 0x55, 0x3f, 0xbb, 0xce, 0x53, 0x5f, 0x35, 0x81, 0xd7, 0x56, 0xff, - 0xc4, 0x71, 0xbc, 0x65, 0xf4, 0x4c, 0xe5, 0x57, 0x87, 0xb8, 0xf7, 0xfd}; + uint8_t bytesprops0[] = {0xa3, 0x4c, 0xda, 0x49, 0x3c, 0x10, 0xad, 0xd, 0x8f, 0xb, 0xa0}; + uint8_t bytesprops1[] = {0x4a, 0xc6, 0xbe, 0xf6}; + uint8_t bytesprops2[] = {0x32, 0x9c, 0xde, 0x20, 0xd4, 0x39, 0x3, 0xe4, 0x9a}; + uint8_t bytesprops3[] = {0x8, 0x58, 0x29, 0x7, 0xad, 0xcc, 0x96, 0x77, 0x4c, 0xca, 0x2a, 0x60, 0xf7, 0x45, + 0xe1, 0x22, 0xab, 0xde, 0x2e, 0x9d, 0xc2, 0x6f, 0x63, 0x43, 0xfc, 0xaa, 0x85}; + uint8_t bytesprops4[] = {0x34, 0xac, 0x12, 0x59, 0xec}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30778}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15956}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 16}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17445}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18914}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 143}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 43}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 10396, 126, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 2046, 206, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 10396 126 [PropWildcardSubscriptionAvailable 80,PropReceiveMaximum 30778,PropSubscriptionIdentifier -// 13,PropRequestProblemInformation 23,PropMaximumQoS 91,PropContentType -// "\164\248\174\155\177\251\SOH\187\SOH*\179Q\132\146\171\201\254\254\187\223\132\226Z\DC3E",PropServerReference -// "\185\163\188DA\253\SOH\224\239\t\199\136\173\219#\229Ty\151\210)",PropTopicAliasMaximum 15956,PropAuthenticationData -// "\SYN\171U\192\141\251\196\b\196\180p\140C\234aH5\228\241~\165F\245\197\169",PropRequestResponseInformation -// 16,PropReasonString -// "\208U?\187\206S_5\129\215V\255\196q\188e\244L\229W\135\184\247\253",PropRequestProblemInformation 233]) -TEST(PubACKREL5QCTest, Decode8) { - uint8_t pkt[] = {0x62, 0x81, 0x1, 0x28, 0x9c, 0x7e, 0x7d, 0x28, 0x50, 0x21, 0x78, 0x3a, 0xb, 0xd, 0x17, 0x17, 0x24, - 0x5b, 0x3, 0x0, 0x19, 0xa4, 0xf8, 0xae, 0x9b, 0xb1, 0xfb, 0x1, 0xbb, 0x1, 0x2a, 0xb3, 0x51, 0x84, - 0x92, 0xab, 0xc9, 0xfe, 0xfe, 0xbb, 0xdf, 0x84, 0xe2, 0x5a, 0x13, 0x45, 0x1c, 0x0, 0x15, 0xb9, 0xa3, - 0xbc, 0x44, 0x41, 0xfd, 0x1, 0xe0, 0xef, 0x9, 0xc7, 0x88, 0xad, 0xdb, 0x23, 0xe5, 0x54, 0x79, 0x97, - 0xd2, 0x29, 0x22, 0x3e, 0x54, 0x16, 0x0, 0x19, 0x16, 0xab, 0x55, 0xc0, 0x8d, 0xfb, 0xc4, 0x8, 0xc4, - 0xb4, 0x70, 0x8c, 0x43, 0xea, 0x61, 0x48, 0x35, 0xe4, 0xf1, 0x7e, 0xa5, 0x46, 0xf5, 0xc5, 0xa9, 0x19, - 0x10, 0x1f, 0x0, 0x18, 0xd0, 0x55, 0x3f, 0xbb, 0xce, 0x53, 0x5f, 0x35, 0x81, 0xd7, 0x56, 0xff, 0xc4, - 0x71, 0xbc, 0x65, 0xf4, 0x4c, 0xe5, 0x57, 0x87, 0xb8, 0xf7, 0xfd, 0x17, 0xe9}; +// ACK (PubACK 2046 206 [PropSessionExpiryInterval 17445,PropCorrelationData +// "\163L\218I<\DLE\173\r\143\v\160",PropResponseTopic "J\198\190\246",PropResponseInformation "2\156\222 +// \212\&9\ETX\228\154",PropReasonString +// "\bX)\a\173\204\150wL\202*`\247E\225\"\171\222.\157\194ocC\252\170\133",PropTopicAlias +// 18914,PropSubscriptionIdentifierAvailable 143,PropCorrelationData "4\172\DC2Y\236",PropMaximumQoS 43]) +TEST(PubACKACK5QCTest, Decode8) { + uint8_t pkt[] = {0x40, 0x57, 0x7, 0xfe, 0xce, 0x53, 0x11, 0x0, 0x0, 0x44, 0x25, 0x9, 0x0, 0xb, 0xa3, + 0x4c, 0xda, 0x49, 0x3c, 0x10, 0xad, 0xd, 0x8f, 0xb, 0xa0, 0x8, 0x0, 0x4, 0x4a, 0xc6, + 0xbe, 0xf6, 0x1a, 0x0, 0x9, 0x32, 0x9c, 0xde, 0x20, 0xd4, 0x39, 0x3, 0xe4, 0x9a, 0x1f, + 0x0, 0x1b, 0x8, 0x58, 0x29, 0x7, 0xad, 0xcc, 0x96, 0x77, 0x4c, 0xca, 0x2a, 0x60, 0xf7, + 0x45, 0xe1, 0x22, 0xab, 0xde, 0x2e, 0x9d, 0xc2, 0x6f, 0x63, 0x43, 0xfc, 0xaa, 0x85, 0x23, + 0x49, 0xe2, 0x29, 0x8f, 0x9, 0x0, 0x5, 0x34, 0xac, 0x12, 0x59, 0xec, 0x24, 0x2b}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10396); - EXPECT_EQ(status, 126); -} - -// ACK (PubACK 26705 173 [PropMessageExpiryInterval 20244,PropMessageExpiryInterval 16583,PropTopicAliasMaximum 21731]) -TEST(PubACKACK5QCTest, Encode9) { - uint8_t pkt[] = {0x40, 0x11, 0x68, 0x51, 0xad, 0xd, 0x2, 0x0, 0x0, 0x4f, - 0x14, 0x2, 0x0, 0x0, 0x40, 0xc7, 0x22, 0x54, 0xe3}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 2046); + EXPECT_EQ(status, 206); +} + +// COMP (PubCOMP 13802 137 [PropPayloadFormatIndicator 108,PropCorrelationData +// "2H\163\240\f7]\227\184\tY",PropReasonString "\197\158\221\201\&31",PropPayloadFormatIndicator +// 148,PropResponseInformation "~wQo\ETX\ETX",PropReceiveMaximum 20672,PropUserProperty +// "\210_\nS\SUB\219\217P9\156\188\192\187\209\177\t\STX\"7N\203" +// "\218\233J\142\217\SOH\ETB\181\\B\186",PropServerReference +// "\188~\179\&2z\130\131J\SO\244\223\201\218",PropAssignedClientIdentifier +// "c.\209\DEL\\\208\194\234M",PropMessageExpiryInterval 31572,PropContentType +// "\254{S\158\195\177\220F\239\232a\173\238Az\174~\176\ESC",PropServerReference +// "\247i\132\198)\154w\no*\134pl/\211\149\224\\\a\157\252|\146\197",PropMessageExpiryInterval +// 26929,PropSharedSubscriptionAvailable 94]) +TEST(PubACKCOMP5QCTest, Encode9) { + uint8_t pkt[] = {0x70, 0xaa, 0x1, 0x35, 0xea, 0x89, 0xa5, 0x1, 0x1, 0x6c, 0x9, 0x0, 0xb, 0x32, 0x48, 0xa3, + 0xf0, 0xc, 0x37, 0x5d, 0xe3, 0xb8, 0x9, 0x59, 0x1f, 0x0, 0x6, 0xc5, 0x9e, 0xdd, 0xc9, 0x33, + 0x31, 0x1, 0x94, 0x1a, 0x0, 0x6, 0x7e, 0x77, 0x51, 0x6f, 0x3, 0x3, 0x21, 0x50, 0xc0, 0x26, + 0x0, 0x15, 0xd2, 0x5f, 0xa, 0x53, 0x1a, 0xdb, 0xd9, 0x50, 0x39, 0x9c, 0xbc, 0xc0, 0xbb, 0xd1, + 0xb1, 0x9, 0x2, 0x22, 0x37, 0x4e, 0xcb, 0x0, 0xb, 0xda, 0xe9, 0x4a, 0x8e, 0xd9, 0x1, 0x17, + 0xb5, 0x5c, 0x42, 0xba, 0x1c, 0x0, 0xd, 0xbc, 0x7e, 0xb3, 0x32, 0x7a, 0x82, 0x83, 0x4a, 0xe, + 0xf4, 0xdf, 0xc9, 0xda, 0x12, 0x0, 0x9, 0x63, 0x2e, 0xd1, 0x7f, 0x5c, 0xd0, 0xc2, 0xea, 0x4d, + 0x2, 0x0, 0x0, 0x7b, 0x54, 0x3, 0x0, 0x13, 0xfe, 0x7b, 0x53, 0x9e, 0xc3, 0xb1, 0xdc, 0x46, + 0xef, 0xe8, 0x61, 0xad, 0xee, 0x41, 0x7a, 0xae, 0x7e, 0xb0, 0x1b, 0x1c, 0x0, 0x18, 0xf7, 0x69, + 0x84, 0xc6, 0x29, 0x9a, 0x77, 0xa, 0x6f, 0x2a, 0x86, 0x70, 0x6c, 0x2f, 0xd3, 0x95, 0xe0, 0x5c, + 0x7, 0x9d, 0xfc, 0x7c, 0x92, 0xc5, 0x2, 0x0, 0x0, 0x69, 0x31, 0x2a, 0x5e}; uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0x32, 0x48, 0xa3, 0xf0, 0xc, 0x37, 0x5d, 0xe3, 0xb8, 0x9, 0x59}; + uint8_t bytesprops1[] = {0xc5, 0x9e, 0xdd, 0xc9, 0x33, 0x31}; + uint8_t bytesprops2[] = {0x7e, 0x77, 0x51, 0x6f, 0x3, 0x3}; + uint8_t bytesprops4[] = {0xda, 0xe9, 0x4a, 0x8e, 0xd9, 0x1, 0x17, 0xb5, 0x5c, 0x42, 0xba}; + uint8_t bytesprops3[] = {0xd2, 0x5f, 0xa, 0x53, 0x1a, 0xdb, 0xd9, 0x50, 0x39, 0x9c, 0xbc, + 0xc0, 0xbb, 0xd1, 0xb1, 0x9, 0x2, 0x22, 0x37, 0x4e, 0xcb}; + uint8_t bytesprops5[] = {0xbc, 0x7e, 0xb3, 0x32, 0x7a, 0x82, 0x83, 0x4a, 0xe, 0xf4, 0xdf, 0xc9, 0xda}; + uint8_t bytesprops6[] = {0x63, 0x2e, 0xd1, 0x7f, 0x5c, 0xd0, 0xc2, 0xea, 0x4d}; + uint8_t bytesprops7[] = {0xfe, 0x7b, 0x53, 0x9e, 0xc3, 0xb1, 0xdc, 0x46, 0xef, 0xe8, + 0x61, 0xad, 0xee, 0x41, 0x7a, 0xae, 0x7e, 0xb0, 0x1b}; + uint8_t bytesprops8[] = {0xf7, 0x69, 0x84, 0xc6, 0x29, 0x9a, 0x77, 0xa, 0x6f, 0x2a, 0x86, 0x70, + 0x6c, 0x2f, 0xd3, 0x95, 0xe0, 0x5c, 0x7, 0x9d, 0xfc, 0x7c, 0x92, 0xc5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20244}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16583}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21731}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 148}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20672}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops3}, .v = {11, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31572}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26929}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 94}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 26705, 173, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 13802, 137, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 26705 173 [PropMessageExpiryInterval 20244,PropMessageExpiryInterval 16583,PropTopicAliasMaximum 21731]) -TEST(PubACKACK5QCTest, Decode9) { - uint8_t pkt[] = {0x40, 0x11, 0x68, 0x51, 0xad, 0xd, 0x2, 0x0, 0x0, 0x4f, - 0x14, 0x2, 0x0, 0x0, 0x40, 0xc7, 0x22, 0x54, 0xe3}; +// COMP (PubCOMP 13802 137 [PropPayloadFormatIndicator 108,PropCorrelationData +// "2H\163\240\f7]\227\184\tY",PropReasonString "\197\158\221\201\&31",PropPayloadFormatIndicator +// 148,PropResponseInformation "~wQo\ETX\ETX",PropReceiveMaximum 20672,PropUserProperty +// "\210_\nS\SUB\219\217P9\156\188\192\187\209\177\t\STX\"7N\203" +// "\218\233J\142\217\SOH\ETB\181\\B\186",PropServerReference +// "\188~\179\&2z\130\131J\SO\244\223\201\218",PropAssignedClientIdentifier +// "c.\209\DEL\\\208\194\234M",PropMessageExpiryInterval 31572,PropContentType +// "\254{S\158\195\177\220F\239\232a\173\238Az\174~\176\ESC",PropServerReference +// "\247i\132\198)\154w\no*\134pl/\211\149\224\\\a\157\252|\146\197",PropMessageExpiryInterval +// 26929,PropSharedSubscriptionAvailable 94]) +TEST(PubACKCOMP5QCTest, Decode9) { + uint8_t pkt[] = {0x70, 0xaa, 0x1, 0x35, 0xea, 0x89, 0xa5, 0x1, 0x1, 0x6c, 0x9, 0x0, 0xb, 0x32, 0x48, 0xa3, + 0xf0, 0xc, 0x37, 0x5d, 0xe3, 0xb8, 0x9, 0x59, 0x1f, 0x0, 0x6, 0xc5, 0x9e, 0xdd, 0xc9, 0x33, + 0x31, 0x1, 0x94, 0x1a, 0x0, 0x6, 0x7e, 0x77, 0x51, 0x6f, 0x3, 0x3, 0x21, 0x50, 0xc0, 0x26, + 0x0, 0x15, 0xd2, 0x5f, 0xa, 0x53, 0x1a, 0xdb, 0xd9, 0x50, 0x39, 0x9c, 0xbc, 0xc0, 0xbb, 0xd1, + 0xb1, 0x9, 0x2, 0x22, 0x37, 0x4e, 0xcb, 0x0, 0xb, 0xda, 0xe9, 0x4a, 0x8e, 0xd9, 0x1, 0x17, + 0xb5, 0x5c, 0x42, 0xba, 0x1c, 0x0, 0xd, 0xbc, 0x7e, 0xb3, 0x32, 0x7a, 0x82, 0x83, 0x4a, 0xe, + 0xf4, 0xdf, 0xc9, 0xda, 0x12, 0x0, 0x9, 0x63, 0x2e, 0xd1, 0x7f, 0x5c, 0xd0, 0xc2, 0xea, 0x4d, + 0x2, 0x0, 0x0, 0x7b, 0x54, 0x3, 0x0, 0x13, 0xfe, 0x7b, 0x53, 0x9e, 0xc3, 0xb1, 0xdc, 0x46, + 0xef, 0xe8, 0x61, 0xad, 0xee, 0x41, 0x7a, 0xae, 0x7e, 0xb0, 0x1b, 0x1c, 0x0, 0x18, 0xf7, 0x69, + 0x84, 0xc6, 0x29, 0x9a, 0x77, 0xa, 0x6f, 0x2a, 0x86, 0x70, 0x6c, 0x2f, 0xd3, 0x95, 0xe0, 0x5c, + 0x7, 0x9d, 0xfc, 0x7c, 0x92, 0xc5, 0x2, 0x0, 0x0, 0x69, 0x31, 0x2a, 0x5e}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26705); - EXPECT_EQ(status, 173); -} - -// ACK (PubACK 17554 3 [PropResponseTopic "\236\&7c\190\212%\SI\177\208\201e\220)\251",PropAssignedClientIdentifier -// "\EOTU\155\252e\156\155l\EM\214t\192\170\184_\213\207\SI\SUB\243\152\253\151\FS\210\244\193\235\SYN-",PropMessageExpiryInterval -// 742,PropTopicAliasMaximum 3228,PropServerKeepAlive 28550,PropServerKeepAlive 4076]) -TEST(PubACKACK5QCTest, Encode10) { - uint8_t pkt[] = {0x40, 0x44, 0x44, 0x92, 0x3, 0x40, 0x8, 0x0, 0xe, 0xec, 0x37, 0x63, 0xbe, 0xd4, - 0x25, 0xf, 0xb1, 0xd0, 0xc9, 0x65, 0xdc, 0x29, 0xfb, 0x12, 0x0, 0x1e, 0x4, 0x55, - 0x9b, 0xfc, 0x65, 0x9c, 0x9b, 0x6c, 0x19, 0xd6, 0x74, 0xc0, 0xaa, 0xb8, 0x5f, 0xd5, - 0xcf, 0xf, 0x1a, 0xf3, 0x98, 0xfd, 0x97, 0x1c, 0xd2, 0xf4, 0xc1, 0xeb, 0x16, 0x2d, - 0x2, 0x0, 0x0, 0x2, 0xe6, 0x22, 0xc, 0x9c, 0x13, 0x6f, 0x86, 0x13, 0xf, 0xec}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 13802); + EXPECT_EQ(status, 137); +} + +// REC (PubREC 16335 74 [PropResponseTopic "c\205Wo\244w",PropMessageExpiryInterval 12785,PropUserProperty +// "\213\252\138\142\162\159m9\DC3\SYNm\b,-\255$\143" +// "\244*\SOHw*\216\224\178\n\252\135\193\162%\150\202LZe",PropWildcardSubscriptionAvailable 235,PropUserProperty "\220" +// "\251\246O\SOi\189\128\148\145\128h\208\246a\144\tR\236J\144\175g\170\153_\ETX\206\158",PropTopicAliasMaximum +// 9337,PropSharedSubscriptionAvailable 21,PropServerReference +// "\211s\219\134\133jV*{\208\164\137\210\227\bi",PropSessionExpiryInterval 19679,PropMessageExpiryInterval +// 24758,PropMaximumPacketSize 17805,PropSubscriptionIdentifierAvailable 130,PropSharedSubscriptionAvailable +// 236,PropAuthenticationData "\158\SUB8?F\168",PropRequestProblemInformation 113,PropPayloadFormatIndicator +// 154,PropServerReference +// "\142\167\203h{\177\139\250\204\216\CAN\235X\200\234\209\244#\204\215\246/\222\153\219\212\165\135@",PropResponseInformation +// "w\t\202\177\DC2Ek\235\133\201\160\225",PropAssignedClientIdentifier +// "\222\238\SOH\192f\209.h\ACK?\240\158\210\&0\SYN\a\207\160\227Z\"r\DC13S",PropServerKeepAlive +// 17214,PropMaximumPacketSize 27100,PropReasonString "\194\151t\DEL\178{\162w",PropContentType +// "*U0+\206C(\213\ETB\186W\RS\181\249X\190",PropTopicAlias 27640,PropMessageExpiryInterval 9585,PropReasonString +// ":\SO\192W\180#",PropRequestResponseInformation 233]) +TEST(PubACKREC5QCTest, Encode10) { + uint8_t pkt[] = {0x50, 0x9c, 0x2, 0x3f, 0xcf, 0x4a, 0x97, 0x2, 0x8, 0x0, 0x6, 0x63, 0xcd, 0x57, 0x6f, 0xf4, 0x77, + 0x2, 0x0, 0x0, 0x31, 0xf1, 0x26, 0x0, 0x11, 0xd5, 0xfc, 0x8a, 0x8e, 0xa2, 0x9f, 0x6d, 0x39, 0x13, + 0x16, 0x6d, 0x8, 0x2c, 0x2d, 0xff, 0x24, 0x8f, 0x0, 0x13, 0xf4, 0x2a, 0x1, 0x77, 0x2a, 0xd8, 0xe0, + 0xb2, 0xa, 0xfc, 0x87, 0xc1, 0xa2, 0x25, 0x96, 0xca, 0x4c, 0x5a, 0x65, 0x28, 0xeb, 0x26, 0x0, 0x1, + 0xdc, 0x0, 0x1c, 0xfb, 0xf6, 0x4f, 0xe, 0x69, 0xbd, 0x80, 0x94, 0x91, 0x80, 0x68, 0xd0, 0xf6, 0x61, + 0x90, 0x9, 0x52, 0xec, 0x4a, 0x90, 0xaf, 0x67, 0xaa, 0x99, 0x5f, 0x3, 0xce, 0x9e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 0x19, 0xe9}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0xec, 0x37, 0x63, 0xbe, 0xd4, 0x25, 0xf, 0xb1, 0xd0, 0xc9, 0x65, 0xdc, 0x29, 0xfb}; - uint8_t bytesprops1[] = {0x4, 0x55, 0x9b, 0xfc, 0x65, 0x9c, 0x9b, 0x6c, 0x19, 0xd6, 0x74, 0xc0, 0xaa, 0xb8, 0x5f, - 0xd5, 0xcf, 0xf, 0x1a, 0xf3, 0x98, 0xfd, 0x97, 0x1c, 0xd2, 0xf4, 0xc1, 0xeb, 0x16, 0x2d}; + uint8_t bytesprops0[] = {0x63, 0xcd, 0x57, 0x6f, 0xf4, 0x77}; + uint8_t bytesprops2[] = {0xf4, 0x2a, 0x1, 0x77, 0x2a, 0xd8, 0xe0, 0xb2, 0xa, 0xfc, + 0x87, 0xc1, 0xa2, 0x25, 0x96, 0xca, 0x4c, 0x5a, 0x65}; + uint8_t bytesprops1[] = {0xd5, 0xfc, 0x8a, 0x8e, 0xa2, 0x9f, 0x6d, 0x39, 0x13, + 0x16, 0x6d, 0x8, 0x2c, 0x2d, 0xff, 0x24, 0x8f}; + uint8_t bytesprops4[] = {0xfb, 0xf6, 0x4f, 0xe, 0x69, 0xbd, 0x80, 0x94, 0x91, 0x80, 0x68, 0xd0, 0xf6, 0x61, + 0x90, 0x9, 0x52, 0xec, 0x4a, 0x90, 0xaf, 0x67, 0xaa, 0x99, 0x5f, 0x3, 0xce, 0x9e}; + uint8_t bytesprops3[] = {0xdc}; + uint8_t bytesprops5[] = {0xd3, 0x73, 0xdb, 0x86, 0x85, 0x6a, 0x56, 0x2a, + 0x7b, 0xd0, 0xa4, 0x89, 0xd2, 0xe3, 0x8, 0x69}; + uint8_t bytesprops6[] = {0x9e, 0x1a, 0x38, 0x3f, 0x46, 0xa8}; + uint8_t bytesprops7[] = {0x8e, 0xa7, 0xcb, 0x68, 0x7b, 0xb1, 0x8b, 0xfa, 0xcc, 0xd8, 0x18, 0xeb, 0x58, 0xc8, 0xea, + 0xd1, 0xf4, 0x23, 0xcc, 0xd7, 0xf6, 0x2f, 0xde, 0x99, 0xdb, 0xd4, 0xa5, 0x87, 0x40}; + uint8_t bytesprops8[] = {0x77, 0x9, 0xca, 0xb1, 0x12, 0x45, 0x6b, 0xeb, 0x85, 0xc9, 0xa0, 0xe1}; + uint8_t bytesprops9[] = {0xde, 0xee, 0x1, 0xc0, 0x66, 0xd1, 0x2e, 0x68, 0x6, 0x3f, 0xf0, 0x9e, 0xd2, + 0x30, 0x16, 0x7, 0xcf, 0xa0, 0xe3, 0x5a, 0x22, 0x72, 0x11, 0x33, 0x53}; + uint8_t bytesprops10[] = {0xc2, 0x97, 0x74, 0x7f, 0xb2, 0x7b, 0xa2, 0x77}; + uint8_t bytesprops11[] = {0x2a, 0x55, 0x30, 0x2b, 0xce, 0x43, 0x28, 0xd5, + 0x17, 0xba, 0x57, 0x1e, 0xb5, 0xf9, 0x58, 0xbe}; + uint8_t bytesprops12[] = {0x3a, 0xe, 0xc0, 0x57, 0xb4, 0x23}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 742}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3228}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28550}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4076}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12785}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops1}, .v = {19, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops3}, .v = {28, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9337}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19679}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24758}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17805}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17214}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27100}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27640}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9585}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 233}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 17554, 3, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, 0, 16335, 74, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 17554 3 [PropResponseTopic "\236\&7c\190\212%\SI\177\208\201e\220)\251",PropAssignedClientIdentifier -// "\EOTU\155\252e\156\155l\EM\214t\192\170\184_\213\207\SI\SUB\243\152\253\151\FS\210\244\193\235\SYN-",PropMessageExpiryInterval -// 742,PropTopicAliasMaximum 3228,PropServerKeepAlive 28550,PropServerKeepAlive 4076]) -TEST(PubACKACK5QCTest, Decode10) { - uint8_t pkt[] = {0x40, 0x44, 0x44, 0x92, 0x3, 0x40, 0x8, 0x0, 0xe, 0xec, 0x37, 0x63, 0xbe, 0xd4, - 0x25, 0xf, 0xb1, 0xd0, 0xc9, 0x65, 0xdc, 0x29, 0xfb, 0x12, 0x0, 0x1e, 0x4, 0x55, - 0x9b, 0xfc, 0x65, 0x9c, 0x9b, 0x6c, 0x19, 0xd6, 0x74, 0xc0, 0xaa, 0xb8, 0x5f, 0xd5, - 0xcf, 0xf, 0x1a, 0xf3, 0x98, 0xfd, 0x97, 0x1c, 0xd2, 0xf4, 0xc1, 0xeb, 0x16, 0x2d, - 0x2, 0x0, 0x0, 0x2, 0xe6, 0x22, 0xc, 0x9c, 0x13, 0x6f, 0x86, 0x13, 0xf, 0xec}; +// REC (PubREC 16335 74 [PropResponseTopic "c\205Wo\244w",PropMessageExpiryInterval 12785,PropUserProperty +// "\213\252\138\142\162\159m9\DC3\SYNm\b,-\255$\143" +// "\244*\SOHw*\216\224\178\n\252\135\193\162%\150\202LZe",PropWildcardSubscriptionAvailable 235,PropUserProperty "\220" +// "\251\246O\SOi\189\128\148\145\128h\208\246a\144\tR\236J\144\175g\170\153_\ETX\206\158",PropTopicAliasMaximum +// 9337,PropSharedSubscriptionAvailable 21,PropServerReference +// "\211s\219\134\133jV*{\208\164\137\210\227\bi",PropSessionExpiryInterval 19679,PropMessageExpiryInterval +// 24758,PropMaximumPacketSize 17805,PropSubscriptionIdentifierAvailable 130,PropSharedSubscriptionAvailable +// 236,PropAuthenticationData "\158\SUB8?F\168",PropRequestProblemInformation 113,PropPayloadFormatIndicator +// 154,PropServerReference +// "\142\167\203h{\177\139\250\204\216\CAN\235X\200\234\209\244#\204\215\246/\222\153\219\212\165\135@",PropResponseInformation +// "w\t\202\177\DC2Ek\235\133\201\160\225",PropAssignedClientIdentifier +// "\222\238\SOH\192f\209.h\ACK?\240\158\210\&0\SYN\a\207\160\227Z\"r\DC13S",PropServerKeepAlive +// 17214,PropMaximumPacketSize 27100,PropReasonString "\194\151t\DEL\178{\162w",PropContentType +// "*U0+\206C(\213\ETB\186W\RS\181\249X\190",PropTopicAlias 27640,PropMessageExpiryInterval 9585,PropReasonString +// ":\SO\192W\180#",PropRequestResponseInformation 233]) +TEST(PubACKREC5QCTest, Decode10) { + uint8_t pkt[] = {0x50, 0x9c, 0x2, 0x3f, 0xcf, 0x4a, 0x97, 0x2, 0x8, 0x0, 0x6, 0x63, 0xcd, 0x57, 0x6f, 0xf4, 0x77, + 0x2, 0x0, 0x0, 0x31, 0xf1, 0x26, 0x0, 0x11, 0xd5, 0xfc, 0x8a, 0x8e, 0xa2, 0x9f, 0x6d, 0x39, 0x13, + 0x16, 0x6d, 0x8, 0x2c, 0x2d, 0xff, 0x24, 0x8f, 0x0, 0x13, 0xf4, 0x2a, 0x1, 0x77, 0x2a, 0xd8, 0xe0, + 0xb2, 0xa, 0xfc, 0x87, 0xc1, 0xa2, 0x25, 0x96, 0xca, 0x4c, 0x5a, 0x65, 0x28, 0xeb, 0x26, 0x0, 0x1, + 0xdc, 0x0, 0x1c, 0xfb, 0xf6, 0x4f, 0xe, 0x69, 0xbd, 0x80, 0x94, 0x91, 0x80, 0x68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, 0x23, 0x6b, 0xf8, 0x2, + 0x0, 0x0, 0x25, 0x71, 0x1f, 0x0, 0x6, 0x3a, 0xe, 0xc0, 0x57, 0xb4, 0x23, 0x19, 0xe9}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17554); - EXPECT_EQ(status, 3); -} - -// ACK (PubACK 24500 54 [PropSharedSubscriptionAvailable 63]) -TEST(PubACKACK5QCTest, Encode11) { - uint8_t pkt[] = {0x40, 0x6, 0x5f, 0xb4, 0x36, 0x2, 0x2a, 0x3f}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 16335); + EXPECT_EQ(status, 74); +} + +// COMP (PubCOMP 5460 148 [PropRetainAvailable 100,PropSubscriptionIdentifier 13,PropMaximumQoS 79,PropRetainAvailable +// 87,PropServerReference "\SYN{\196c\225J3\STX\199zBA\128\134\135\USpTL\213|@F",PropRequestResponseInformation +// 114,PropSessionExpiryInterval 4868,PropTopicAlias 4581,PropServerReference "\253\151\&9\ETX +// \249\ETX\140\229\STX\196U\232\&7\174]hV\128RA",PropContentType "\n\145F\171\162>"]) +TEST(PubACKCOMP5QCTest, Encode11) { + uint8_t pkt[] = {0x70, 0x51, 0x15, 0x54, 0x94, 0x4d, 0x25, 0x64, 0xb, 0xd, 0x24, 0x4f, 0x25, 0x57, 0x1c, 0x0, 0x17, + 0x16, 0x7b, 0xc4, 0x63, 0xe1, 0x4a, 0x33, 0x2, 0xc7, 0x7a, 0x42, 0x41, 0x80, 0x86, 0x87, 0x1f, 0x70, + 0x54, 0x4c, 0xd5, 0x7c, 0x40, 0x46, 0x19, 0x72, 0x11, 0x0, 0x0, 0x13, 0x4, 0x23, 0x11, 0xe5, 0x1c, + 0x0, 0x15, 0xfd, 0x97, 0x39, 0x3, 0x20, 0xf9, 0x3, 0x8c, 0xe5, 0x2, 0xc4, 0x55, 0xe8, 0x37, 0xae, + 0x5d, 0x68, 0x56, 0x80, 0x52, 0x41, 0x3, 0x0, 0x6, 0xa, 0x91, 0x46, 0xab, 0xa2, 0x3e}; uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0x16, 0x7b, 0xc4, 0x63, 0xe1, 0x4a, 0x33, 0x2, 0xc7, 0x7a, 0x42, 0x41, + 0x80, 0x86, 0x87, 0x1f, 0x70, 0x54, 0x4c, 0xd5, 0x7c, 0x40, 0x46}; + uint8_t bytesprops1[] = {0xfd, 0x97, 0x39, 0x3, 0x20, 0xf9, 0x3, 0x8c, 0xe5, 0x2, 0xc4, + 0x55, 0xe8, 0x37, 0xae, 0x5d, 0x68, 0x56, 0x80, 0x52, 0x41}; + uint8_t bytesprops2[] = {0xa, 0x91, 0x46, 0xab, 0xa2, 0x3e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 100}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 114}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4868}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4581}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 24500, 54, props); + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 5460, 148, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 24500 54 [PropSharedSubscriptionAvailable 63]) -TEST(PubACKACK5QCTest, Decode11) { - uint8_t pkt[] = {0x40, 0x6, 0x5f, 0xb4, 0x36, 0x2, 0x2a, 0x3f}; +// COMP (PubCOMP 5460 148 [PropRetainAvailable 100,PropSubscriptionIdentifier 13,PropMaximumQoS 79,PropRetainAvailable +// 87,PropServerReference "\SYN{\196c\225J3\STX\199zBA\128\134\135\USpTL\213|@F",PropRequestResponseInformation +// 114,PropSessionExpiryInterval 4868,PropTopicAlias 4581,PropServerReference "\253\151\&9\ETX +// \249\ETX\140\229\STX\196U\232\&7\174]hV\128RA",PropContentType "\n\145F\171\162>"]) +TEST(PubACKCOMP5QCTest, Decode11) { + uint8_t pkt[] = {0x70, 0x51, 0x15, 0x54, 0x94, 0x4d, 0x25, 0x64, 0xb, 0xd, 0x24, 0x4f, 0x25, 0x57, 0x1c, 0x0, 0x17, + 0x16, 0x7b, 0xc4, 0x63, 0xe1, 0x4a, 0x33, 0x2, 0xc7, 0x7a, 0x42, 0x41, 0x80, 0x86, 0x87, 0x1f, 0x70, + 0x54, 0x4c, 0xd5, 0x7c, 0x40, 0x46, 0x19, 0x72, 0x11, 0x0, 0x0, 0x13, 0x4, 0x23, 0x11, 0xe5, 0x1c, + 0x0, 0x15, 0xfd, 0x97, 0x39, 0x3, 0x20, 0xf9, 0x3, 0x8c, 0xe5, 0x2, 0xc4, 0x55, 0xe8, 0x37, 0xae, + 0x5d, 0x68, 0x56, 0x80, 0x52, 0x41, 0x3, 0x0, 0x6, 0xa, 0x91, 0x46, 0xab, 0xa2, 0x3e}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24500); - EXPECT_EQ(status, 54); -} - -// COMP (PubCOMP 30295 75 [PropServerReference -// ".a\212\129`\195`^\245\213\253:Wg9\148\152(\190\189\193",PropServerKeepAlive 2248,PropSubscriptionIdentifier -// 9,PropRequestResponseInformation 218,PropTopicAlias 26472,PropUserProperty -// "\181\217\219\227\249\ENQEk\241f\220m\DC3;\205\137b\EOTm" -// "\237\251\237\174\182\199\246\209MrUky\201\ETB\150'l\155\153\208\FS\171\&2\185\211\DC4",PropWildcardSubscriptionAvailable -// 213,PropRequestProblemInformation 87,PropSessionExpiryInterval 15186,PropPayloadFormatIndicator -// 155,PropServerKeepAlive 6136,PropMessageExpiryInterval 16008,PropRetainAvailable 202,PropTopicAliasMaximum -// 26810,PropReceiveMaximum 2675,PropRetainAvailable 48,PropSharedSubscriptionAvailable 38,PropResponseTopic -// "MF\171\192\203aZ5\SYN\158\239R\SI",PropUserProperty "L\NULa YLB\t\138;F\244\165\164N\SOHi" -// "\210h\166k\195\&9\131O\254\145\148\236H\249z\144\236\137",PropSessionExpiryInterval 17413,PropAuthenticationData -// "[\184"]) + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 5460); + EXPECT_EQ(status, 148); +} + +// COMP (PubCOMP 15537 240 []) TEST(PubACKCOMP5QCTest, Encode12) { - uint8_t pkt[] = { - 0x70, 0xbb, 0x1, 0x76, 0x57, 0x4b, 0xb6, 0x1, 0x1c, 0x0, 0x15, 0x2e, 0x61, 0xd4, 0x81, 0x60, 0xc3, 0x60, 0x5e, - 0xf5, 0xd5, 0xfd, 0x3a, 0x57, 0x67, 0x39, 0x94, 0x98, 0x28, 0xbe, 0xbd, 0xc1, 0x13, 0x8, 0xc8, 0xb, 0x9, 0x19, - 0xda, 0x23, 0x67, 0x68, 0x26, 0x0, 0x13, 0xb5, 0xd9, 0xdb, 0xe3, 0xf9, 0x5, 0x45, 0x6b, 0xf1, 0x66, 0xdc, 0x6d, - 0x13, 0x3b, 0xcd, 0x89, 0x62, 0x4, 0x6d, 0x0, 0x1b, 0xed, 0xfb, 0xed, 0xae, 0xb6, 0xc7, 0xf6, 0xd1, 0x4d, 0x72, - 0x55, 0x6b, 0x79, 0xc9, 0x17, 0x96, 0x27, 0x6c, 0x9b, 0x99, 0xd0, 0x1c, 0xab, 0x32, 0xb9, 0xd3, 0x14, 0x28, 0xd5, - 0x17, 0x57, 0x11, 0x0, 0x0, 0x3b, 0x52, 0x1, 0x9b, 0x13, 0x17, 0xf8, 0x2, 0x0, 0x0, 0x3e, 0x88, 0x25, 0xca, - 0x22, 0x68, 0xba, 0x21, 0xa, 0x73, 0x25, 0x30, 0x2a, 0x26, 0x8, 0x0, 0xd, 0x4d, 0x46, 0xab, 0xc0, 0xcb, 0x61, - 0x5a, 0x35, 0x16, 0x9e, 0xef, 0x52, 0xf, 0x26, 0x0, 0x11, 0x4c, 0x0, 0x61, 0x20, 0x59, 0x4c, 0x42, 0x9, 0x8a, - 0x3b, 0x46, 0xf4, 0xa5, 0xa4, 0x4e, 0x1, 0x69, 0x0, 0x12, 0xd2, 0x68, 0xa6, 0x6b, 0xc3, 0x39, 0x83, 0x4f, 0xfe, - 0x91, 0x94, 0xec, 0x48, 0xf9, 0x7a, 0x90, 0xec, 0x89, 0x11, 0x0, 0x0, 0x44, 0x5, 0x16, 0x0, 0x2, 0x5b, 0xb8}; + uint8_t pkt[] = {0x70, 0x3, 0x3c, 0xb1, 0xf0}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0x2e, 0x61, 0xd4, 0x81, 0x60, 0xc3, 0x60, 0x5e, 0xf5, 0xd5, 0xfd, - 0x3a, 0x57, 0x67, 0x39, 0x94, 0x98, 0x28, 0xbe, 0xbd, 0xc1}; - uint8_t bytesprops2[] = {0xed, 0xfb, 0xed, 0xae, 0xb6, 0xc7, 0xf6, 0xd1, 0x4d, 0x72, 0x55, 0x6b, 0x79, 0xc9, - 0x17, 0x96, 0x27, 0x6c, 0x9b, 0x99, 0xd0, 0x1c, 0xab, 0x32, 0xb9, 0xd3, 0x14}; - uint8_t bytesprops1[] = {0xb5, 0xd9, 0xdb, 0xe3, 0xf9, 0x5, 0x45, 0x6b, 0xf1, 0x66, - 0xdc, 0x6d, 0x13, 0x3b, 0xcd, 0x89, 0x62, 0x4, 0x6d}; - uint8_t bytesprops3[] = {0x4d, 0x46, 0xab, 0xc0, 0xcb, 0x61, 0x5a, 0x35, 0x16, 0x9e, 0xef, 0x52, 0xf}; - uint8_t bytesprops5[] = {0xd2, 0x68, 0xa6, 0x6b, 0xc3, 0x39, 0x83, 0x4f, 0xfe, - 0x91, 0x94, 0xec, 0x48, 0xf9, 0x7a, 0x90, 0xec, 0x89}; - uint8_t bytesprops4[] = {0x4c, 0x0, 0x61, 0x20, 0x59, 0x4c, 0x42, 0x9, 0x8a, - 0x3b, 0x46, 0xf4, 0xa5, 0xa4, 0x4e, 0x1, 0x69}; - uint8_t bytesprops6[] = {0x5b, 0xb8}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2248}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26472}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops1}, .v = {27, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15186}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6136}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16008}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26810}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2675}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 38}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops4}, .v = {18, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17413}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops6}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 30295, 75, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 15537, 240, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 30295 75 [PropServerReference -// ".a\212\129`\195`^\245\213\253:Wg9\148\152(\190\189\193",PropServerKeepAlive 2248,PropSubscriptionIdentifier -// 9,PropRequestResponseInformation 218,PropTopicAlias 26472,PropUserProperty -// "\181\217\219\227\249\ENQEk\241f\220m\DC3;\205\137b\EOTm" -// "\237\251\237\174\182\199\246\209MrUky\201\ETB\150'l\155\153\208\FS\171\&2\185\211\DC4",PropWildcardSubscriptionAvailable -// 213,PropRequestProblemInformation 87,PropSessionExpiryInterval 15186,PropPayloadFormatIndicator -// 155,PropServerKeepAlive 6136,PropMessageExpiryInterval 16008,PropRetainAvailable 202,PropTopicAliasMaximum -// 26810,PropReceiveMaximum 2675,PropRetainAvailable 48,PropSharedSubscriptionAvailable 38,PropResponseTopic -// "MF\171\192\203aZ5\SYN\158\239R\SI",PropUserProperty "L\NULa YLB\t\138;F\244\165\164N\SOHi" -// "\210h\166k\195\&9\131O\254\145\148\236H\249z\144\236\137",PropSessionExpiryInterval 17413,PropAuthenticationData -// "[\184"]) +// COMP (PubCOMP 15537 240 []) TEST(PubACKCOMP5QCTest, Decode12) { - uint8_t pkt[] = { - 0x70, 0xbb, 0x1, 0x76, 0x57, 0x4b, 0xb6, 0x1, 0x1c, 0x0, 0x15, 0x2e, 0x61, 0xd4, 0x81, 0x60, 0xc3, 0x60, 0x5e, - 0xf5, 0xd5, 0xfd, 0x3a, 0x57, 0x67, 0x39, 0x94, 0x98, 0x28, 0xbe, 0xbd, 0xc1, 0x13, 0x8, 0xc8, 0xb, 0x9, 0x19, - 0xda, 0x23, 0x67, 0x68, 0x26, 0x0, 0x13, 0xb5, 0xd9, 0xdb, 0xe3, 0xf9, 0x5, 0x45, 0x6b, 0xf1, 0x66, 0xdc, 0x6d, - 0x13, 0x3b, 0xcd, 0x89, 0x62, 0x4, 0x6d, 0x0, 0x1b, 0xed, 0xfb, 0xed, 0xae, 0xb6, 0xc7, 0xf6, 0xd1, 0x4d, 0x72, - 0x55, 0x6b, 0x79, 0xc9, 0x17, 0x96, 0x27, 0x6c, 0x9b, 0x99, 0xd0, 0x1c, 0xab, 0x32, 0xb9, 0xd3, 0x14, 0x28, 0xd5, - 0x17, 0x57, 0x11, 0x0, 0x0, 0x3b, 0x52, 0x1, 0x9b, 0x13, 0x17, 0xf8, 0x2, 0x0, 0x0, 0x3e, 0x88, 0x25, 0xca, - 0x22, 0x68, 0xba, 0x21, 0xa, 0x73, 0x25, 0x30, 0x2a, 0x26, 0x8, 0x0, 0xd, 0x4d, 0x46, 0xab, 0xc0, 0xcb, 0x61, - 0x5a, 0x35, 0x16, 0x9e, 0xef, 0x52, 0xf, 0x26, 0x0, 0x11, 0x4c, 0x0, 0x61, 0x20, 0x59, 0x4c, 0x42, 0x9, 0x8a, - 0x3b, 0x46, 0xf4, 0xa5, 0xa4, 0x4e, 0x1, 0x69, 0x0, 0x12, 0xd2, 0x68, 0xa6, 0x6b, 0xc3, 0x39, 0x83, 0x4f, 0xfe, - 0x91, 0x94, 0xec, 0x48, 0xf9, 0x7a, 0x90, 0xec, 0x89, 0x11, 0x0, 0x0, 0x44, 0x5, 0x16, 0x0, 0x2, 0x5b, 0xb8}; + uint8_t pkt[] = {0x70, 0x3, 0x3c, 0xb1, 0xf0}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 30295); - EXPECT_EQ(status, 75); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 15537); + EXPECT_EQ(status, 240); } -// ACK (PubACK 17870 173 [PropSubscriptionIdentifier 9,PropTopicAliasMaximum 27702,PropRequestProblemInformation -// 7,PropResponseInformation "\SOHl\191\254\n\r\240\207",PropTopicAliasMaximum 28514,PropMessageExpiryInterval -// 24956,PropWillDelayInterval 28443,PropMaximumQoS 65]) +// ACK (PubACK 28091 75 [PropRequestResponseInformation 147,PropReceiveMaximum 17435,PropTopicAliasMaximum +// 16908,PropReceiveMaximum 12343,PropMaximumPacketSize 29709,PropSessionExpiryInterval +// 15481,PropWildcardSubscriptionAvailable 79,PropServerKeepAlive 16043,PropResponseInformation +// "_\SYNZ4\SO*p\"\FSO\185cv\138"]) TEST(PubACKACK5QCTest, Encode13) { - uint8_t pkt[] = {0x40, 0x25, 0x45, 0xce, 0xad, 0x21, 0xb, 0x9, 0x22, 0x6c, 0x36, 0x17, 0x7, - 0x1a, 0x0, 0x8, 0x1, 0x6c, 0xbf, 0xfe, 0xa, 0xd, 0xf0, 0xcf, 0x22, 0x6f, - 0x62, 0x2, 0x0, 0x0, 0x61, 0x7c, 0x18, 0x0, 0x0, 0x6f, 0x1b, 0x24, 0x41}; + uint8_t pkt[] = {0x40, 0x2f, 0x6d, 0xbb, 0x4b, 0x2b, 0x19, 0x93, 0x21, 0x44, 0x1b, 0x22, 0x42, 0xc, 0x21, 0x30, 0x37, + 0x27, 0x0, 0x0, 0x74, 0xd, 0x11, 0x0, 0x0, 0x3c, 0x79, 0x28, 0x4f, 0x13, 0x3e, 0xab, 0x1a, 0x0, + 0xe, 0x5f, 0x16, 0x5a, 0x34, 0xe, 0x2a, 0x70, 0x22, 0x1c, 0x4f, 0xb9, 0x63, 0x76, 0x8a}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0x1, 0x6c, 0xbf, 0xfe, 0xa, 0xd, 0xf0, 0xcf}; + uint8_t bytesprops0[] = {0x5f, 0x16, 0x5a, 0x34, 0xe, 0x2a, 0x70, 0x22, 0x1c, 0x4f, 0xb9, 0x63, 0x76, 0x8a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27702}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28514}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24956}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28443}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 17435}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16908}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12343}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29709}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15481}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16043}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops0}}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 17870, 173, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 28091, 75, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 17870 173 [PropSubscriptionIdentifier 9,PropTopicAliasMaximum 27702,PropRequestProblemInformation -// 7,PropResponseInformation "\SOHl\191\254\n\r\240\207",PropTopicAliasMaximum 28514,PropMessageExpiryInterval -// 24956,PropWillDelayInterval 28443,PropMaximumQoS 65]) +// ACK (PubACK 28091 75 [PropRequestResponseInformation 147,PropReceiveMaximum 17435,PropTopicAliasMaximum +// 16908,PropReceiveMaximum 12343,PropMaximumPacketSize 29709,PropSessionExpiryInterval +// 15481,PropWildcardSubscriptionAvailable 79,PropServerKeepAlive 16043,PropResponseInformation +// "_\SYNZ4\SO*p\"\FSO\185cv\138"]) TEST(PubACKACK5QCTest, Decode13) { - uint8_t pkt[] = {0x40, 0x25, 0x45, 0xce, 0xad, 0x21, 0xb, 0x9, 0x22, 0x6c, 0x36, 0x17, 0x7, - 0x1a, 0x0, 0x8, 0x1, 0x6c, 0xbf, 0xfe, 0xa, 0xd, 0xf0, 0xcf, 0x22, 0x6f, - 0x62, 0x2, 0x0, 0x0, 0x61, 0x7c, 0x18, 0x0, 0x0, 0x6f, 0x1b, 0x24, 0x41}; + uint8_t pkt[] = {0x40, 0x2f, 0x6d, 0xbb, 0x4b, 0x2b, 0x19, 0x93, 0x21, 0x44, 0x1b, 0x22, 0x42, 0xc, 0x21, 0x30, 0x37, + 0x27, 0x0, 0x0, 0x74, 0xd, 0x11, 0x0, 0x0, 0x3c, 0x79, 0x28, 0x4f, 0x13, 0x3e, 0xab, 0x1a, 0x0, + 0xe, 0x5f, 0x16, 0x5a, 0x34, 0xe, 0x2a, 0x70, 0x22, 0x1c, 0x4f, 0xb9, 0x63, 0x76, 0x8a}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17870); - EXPECT_EQ(status, 173); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 28091); + EXPECT_EQ(status, 75); } -// ACK (PubACK 18661 48 [PropResponseInformation "\208W1\a\216]\131\236U\r\219",PropMessageExpiryInterval -// 16564,PropMessageExpiryInterval 3562,PropWillDelayInterval 4868,PropSubscriptionIdentifier 27,PropTopicAlias 12787]) -TEST(PubACKACK5QCTest, Encode14) { - uint8_t pkt[] = {0x40, 0x26, 0x48, 0xe5, 0x30, 0x22, 0x1a, 0x0, 0xb, 0xd0, 0x57, 0x31, 0x7, 0xd8, - 0x5d, 0x83, 0xec, 0x55, 0xd, 0xdb, 0x2, 0x0, 0x0, 0x40, 0xb4, 0x2, 0x0, 0x0, - 0xd, 0xea, 0x18, 0x0, 0x0, 0x13, 0x4, 0xb, 0x1b, 0x23, 0x31, 0xf3}; +// REL (PubREL 10160 80 [PropContentType +// "\200\206\164\247+\166z<\214\225\rh\224\219p\223\145\US\161,\234\194~\221x\181\ETX,\209v",PropAuthenticationData +// "\244Q\DC2\139\f\196\207\DC3*\210\237\210\GS\185\162\176\169\171\161\fdY\153\253t\156\133\DC3",PropResponseTopic +// "\182\210\179\213\155\218\176\129",PropResponseInformation +// "\179\132\165f\195\189\133\212\&3\149\161\170\155\244X\\O\RS\246\&4\234\165\233)4\147\DC4\129D\DC3",PropMessageExpiryInterval +// 29734,PropSessionExpiryInterval 29184,PropSubscriptionIdentifier 22,PropAssignedClientIdentifier " +// \210\204\DLE\224",PropPayloadFormatIndicator 180,PropRequestResponseInformation 199,PropContentType +// "\255\150",PropMessageExpiryInterval 30373,PropResponseInformation +// "\ESC\177\247\183\137d4\163;u\208\185I\ENQ\197\240\170",PropAssignedClientIdentifier +// "\211\153\USU",PropAuthenticationMethod "e\135\EOT\189M\251",PropTopicAliasMaximum +// 16386,PropSubscriptionIdentifierAvailable 54,PropSessionExpiryInterval 5264,PropContentType +// "T\232\129wV",PropResponseTopic "S\140\234G4\133\208)\233\t6;\148\235h",PropServerKeepAlive 16844]) +TEST(PubACKREL5QCTest, Encode14) { + uint8_t pkt[] = { + 0x62, 0xde, 0x1, 0x27, 0xb0, 0x50, 0xd9, 0x1, 0x3, 0x0, 0x1e, 0xc8, 0xce, 0xa4, 0xf7, 0x2b, 0xa6, 0x7a, 0x3c, + 0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 0x53, 0x8c, + 0xea, 0x47, 0x34, 0x85, 0xd0, 0x29, 0xe9, 0x9, 0x36, 0x3b, 0x94, 0xeb, 0x68, 0x13, 0x41, 0xcc}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0xd0, 0x57, 0x31, 0x7, 0xd8, 0x5d, 0x83, 0xec, 0x55, 0xd, 0xdb}; + uint8_t bytesprops0[] = {0xc8, 0xce, 0xa4, 0xf7, 0x2b, 0xa6, 0x7a, 0x3c, 0xd6, 0xe1, 0xd, 0x68, 0xe0, 0xdb, 0x70, + 0xdf, 0x91, 0x1f, 0xa1, 0x2c, 0xea, 0xc2, 0x7e, 0xdd, 0x78, 0xb5, 0x3, 0x2c, 0xd1, 0x76}; + uint8_t bytesprops1[] = {0xf4, 0x51, 0x12, 0x8b, 0xc, 0xc4, 0xcf, 0x13, 0x2a, 0xd2, 0xed, 0xd2, 0x1d, 0xb9, + 0xa2, 0xb0, 0xa9, 0xab, 0xa1, 0xc, 0x64, 0x59, 0x99, 0xfd, 0x74, 0x9c, 0x85, 0x13}; + uint8_t bytesprops2[] = {0xb6, 0xd2, 0xb3, 0xd5, 0x9b, 0xda, 0xb0, 0x81}; + uint8_t bytesprops3[] = {0xb3, 0x84, 0xa5, 0x66, 0xc3, 0xbd, 0x85, 0xd4, 0x33, 0x95, 0xa1, 0xaa, 0x9b, 0xf4, 0x58, + 0x5c, 0x4f, 0x1e, 0xf6, 0x34, 0xea, 0xa5, 0xe9, 0x29, 0x34, 0x93, 0x14, 0x81, 0x44, 0x13}; + uint8_t bytesprops4[] = {0x20, 0xd2, 0xcc, 0x10, 0xe0}; + uint8_t bytesprops5[] = {0xff, 0x96}; + uint8_t bytesprops6[] = {0x1b, 0xb1, 0xf7, 0xb7, 0x89, 0x64, 0x34, 0xa3, 0x3b, + 0x75, 0xd0, 0xb9, 0x49, 0x5, 0xc5, 0xf0, 0xaa}; + uint8_t bytesprops7[] = {0xd3, 0x99, 0x1f, 0x55}; + uint8_t bytesprops8[] = {0x65, 0x87, 0x4, 0xbd, 0x4d, 0xfb}; + uint8_t bytesprops9[] = {0x54, 0xe8, 0x81, 0x77, 0x56}; + uint8_t bytesprops10[] = {0x53, 0x8c, 0xea, 0x47, 0x34, 0x85, 0xd0, 0x29, 0xe9, 0x9, 0x36, 0x3b, 0x94, 0xeb, 0x68}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16564}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3562}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4868}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12787}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29734}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29184}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30373}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16386}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5264}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16844}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 18661, 48, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 10160, 80, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 18661 48 [PropResponseInformation "\208W1\a\216]\131\236U\r\219",PropMessageExpiryInterval -// 16564,PropMessageExpiryInterval 3562,PropWillDelayInterval 4868,PropSubscriptionIdentifier 27,PropTopicAlias 12787]) -TEST(PubACKACK5QCTest, Decode14) { - uint8_t pkt[] = {0x40, 0x26, 0x48, 0xe5, 0x30, 0x22, 0x1a, 0x0, 0xb, 0xd0, 0x57, 0x31, 0x7, 0xd8, - 0x5d, 0x83, 0xec, 0x55, 0xd, 0xdb, 0x2, 0x0, 0x0, 0x40, 0xb4, 0x2, 0x0, 0x0, - 0xd, 0xea, 0x18, 0x0, 0x0, 0x13, 0x4, 0xb, 0x1b, 0x23, 0x31, 0xf3}; +// REL (PubREL 10160 80 [PropContentType +// "\200\206\164\247+\166z<\214\225\rh\224\219p\223\145\US\161,\234\194~\221x\181\ETX,\209v",PropAuthenticationData +// "\244Q\DC2\139\f\196\207\DC3*\210\237\210\GS\185\162\176\169\171\161\fdY\153\253t\156\133\DC3",PropResponseTopic +// "\182\210\179\213\155\218\176\129",PropResponseInformation +// "\179\132\165f\195\189\133\212\&3\149\161\170\155\244X\\O\RS\246\&4\234\165\233)4\147\DC4\129D\DC3",PropMessageExpiryInterval +// 29734,PropSessionExpiryInterval 29184,PropSubscriptionIdentifier 22,PropAssignedClientIdentifier " +// \210\204\DLE\224",PropPayloadFormatIndicator 180,PropRequestResponseInformation 199,PropContentType +// "\255\150",PropMessageExpiryInterval 30373,PropResponseInformation +// "\ESC\177\247\183\137d4\163;u\208\185I\ENQ\197\240\170",PropAssignedClientIdentifier +// "\211\153\USU",PropAuthenticationMethod "e\135\EOT\189M\251",PropTopicAliasMaximum +// 16386,PropSubscriptionIdentifierAvailable 54,PropSessionExpiryInterval 5264,PropContentType +// "T\232\129wV",PropResponseTopic "S\140\234G4\133\208)\233\t6;\148\235h",PropServerKeepAlive 16844]) +TEST(PubACKREL5QCTest, Decode14) { + uint8_t pkt[] = { + 0x62, 0xde, 0x1, 0x27, 0xb0, 0x50, 0xd9, 0x1, 0x3, 0x0, 0x1e, 0xc8, 0xce, 0xa4, 0xf7, 0x2b, 0xa6, 0x7a, 0x3c, + 0xd6, 0xe1, 0xd, 0x68, 0xe0, 0xdb, 0x70, 0xdf, 0x91, 0x1f, 0xa1, 0x2c, 0xea, 0xc2, 0x7e, 0xdd, 0x78, 0xb5, 0x3, + 0x2c, 0xd1, 0x76, 0x16, 0x0, 0x1c, 0xf4, 0x51, 0x12, 0x8b, 0xc, 0xc4, 0xcf, 0x13, 0x2a, 0xd2, 0xed, 0xd2, 0x1d, + 0xb9, 0xa2, 0xb0, 0xa9, 0xab, 0xa1, 0xc, 0x64, 0x59, 0x99, 0xfd, 0x74, 0x9c, 0x85, 0x13, 0x8, 0x0, 0x8, 0xb6, + 0xd2, 0xb3, 0xd5, 0x9b, 0xda, 0xb0, 0x81, 0x1a, 0x0, 0x1e, 0xb3, 0x84, 0xa5, 0x66, 0xc3, 0xbd, 0x85, 0xd4, 0x33, + 0x95, 0xa1, 0xaa, 0x9b, 0xf4, 0x58, 0x5c, 0x4f, 0x1e, 0xf6, 0x34, 0xea, 0xa5, 0xe9, 0x29, 0x34, 0x93, 0x14, 0x81, + 0x44, 0x13, 0x2, 0x0, 0x0, 0x74, 0x26, 0x11, 0x0, 0x0, 0x72, 0x0, 0xb, 0x16, 0x12, 0x0, 0x5, 0x20, 0xd2, + 0xcc, 0x10, 0xe0, 0x1, 0xb4, 0x19, 0xc7, 0x3, 0x0, 0x2, 0xff, 0x96, 0x2, 0x0, 0x0, 0x76, 0xa5, 0x1a, 0x0, + 0x11, 0x1b, 0xb1, 0xf7, 0xb7, 0x89, 0x64, 0x34, 0xa3, 0x3b, 0x75, 0xd0, 0xb9, 0x49, 0x5, 0xc5, 0xf0, 0xaa, 0x12, + 0x0, 0x4, 0xd3, 0x99, 0x1f, 0x55, 0x15, 0x0, 0x6, 0x65, 0x87, 0x4, 0xbd, 0x4d, 0xfb, 0x22, 0x40, 0x2, 0x29, + 0x36, 0x11, 0x0, 0x0, 0x14, 0x90, 0x3, 0x0, 0x5, 0x54, 0xe8, 0x81, 0x77, 0x56, 0x8, 0x0, 0xf, 0x53, 0x8c, + 0xea, 0x47, 0x34, 0x85, 0xd0, 0x29, 0xe9, 0x9, 0x36, 0x3b, 0x94, 0xeb, 0x68, 0x13, 0x41, 0xcc}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18661); - EXPECT_EQ(status, 48); -} - -// REC (PubREC 32292 34 [PropSessionExpiryInterval 19966,PropSessionExpiryInterval 16597,PropServerKeepAlive -// 16525,PropUserProperty "\214d\189\196\EM\163\224\198D\205\176\DLE\\\220\166\149\162(\176" -// "\DEL\b\216\138Y^.\SOH<\242",PropResponseInformation -// "\193\&6\208]\239\211A\188G\226\152\GS\162{&\221",PropTopicAliasMaximum 5330,PropPayloadFormatIndicator -// 244,PropAssignedClientIdentifier -// "\207\207\180\230uB\228<\208\162I\246\152\169Y\tTB!HQ\ENQ\191\191bP\n\237y\145",PropRequestProblemInformation -// 72,PropWildcardSubscriptionAvailable 53,PropUserProperty "\239#1\142\242\&5\237\173\254\ACK\r\226\137`e~\232" -// "W\SUB",PropReasonString "\214",PropContentType "\159\193+Gt\153|\210\133\218",PropSharedSubscriptionAvailable -// 17,PropSubscriptionIdentifier 6,PropAuthenticationData -// "j\192g\216\&1\208\158\152\238\176\218\164w",PropRetainAvailable 251,PropServerReference -// "\SUB\247\226\ETBpb\255\235_\EM\133\145\198kA\192\188\&5\217\213X\130\170/\208-mv\205",PropWillDelayInterval -// 6096,PropTopicAliasMaximum 27681]) -TEST(PubACKREC5QCTest, Encode15) { - uint8_t pkt[] = {0x50, 0xd8, 0x1, 0x7e, 0x24, 0x22, 0xd3, 0x1, 0x11, 0x0, 0x0, 0x4d, 0xfe, 0x11, 0x0, 0x0, 0x40, - 0xd5, 0x13, 0x40, 0x8d, 0x26, 0x0, 0x13, 0xd6, 0x64, 0xbd, 0xc4, 0x19, 0xa3, 0xe0, 0xc6, 0x44, 0xcd, - 0xb0, 0x10, 0x5c, 0xdc, 0xa6, 0x95, 0xa2, 0x28, 0xb0, 0x0, 0xa, 0x7f, 0x8, 0xd8, 0x8a, 0x59, 0x5e, - 0x2e, 0x1, 0x3c, 0xf2, 0x1a, 0x0, 0x10, 0xc1, 0x36, 0xd0, 0x5d, 0xef, 0xd3, 0x41, 0xbc, 0x47, 0xe2, - 0x98, 0x1d, 0xa2, 0x7b, 0x26, 0xdd, 0x22, 0x14, 0xd2, 0x1, 0xf4, 0x12, 0x0, 0x1e, 0xcf, 0xcf, 0xb4, - 0xe6, 0x75, 0x42, 0xe4, 0x3c, 0xd0, 0xa2, 0x49, 0xf6, 0x98, 0xa9, 0x59, 0x9, 0x54, 0x42, 0x21, 0x48, - 0x51, 0x5, 0xbf, 0xbf, 0x62, 0x50, 0xa, 0xed, 0x79, 0x91, 0x17, 0x48, 0x28, 0x35, 0x26, 0x0, 0x11, - 0xef, 0x23, 0x31, 0x8e, 0xf2, 0x35, 0xed, 0xad, 0xfe, 0x6, 0xd, 0xe2, 0x89, 0x60, 0x65, 0x7e, 0xe8, - 0x0, 0x2, 0x57, 0x1a, 0x1f, 0x0, 0x1, 0xd6, 0x3, 0x0, 0xa, 0x9f, 0xc1, 0x2b, 0x47, 0x74, 0x99, - 0x7c, 0xd2, 0x85, 0xda, 0x2a, 0x11, 0xb, 0x6, 0x16, 0x0, 0xd, 0x6a, 0xc0, 0x67, 0xd8, 0x31, 0xd0, - 0x9e, 0x98, 0xee, 0xb0, 0xda, 0xa4, 0x77, 0x25, 0xfb, 0x1c, 0x0, 0x1d, 0x1a, 0xf7, 0xe2, 0x17, 0x70, - 0x62, 0xff, 0xeb, 0x5f, 0x19, 0x85, 0x91, 0xc6, 0x6b, 0x41, 0xc0, 0xbc, 0x35, 0xd9, 0xd5, 0x58, 0x82, - 0xaa, 0x2f, 0xd0, 0x2d, 0x6d, 0x76, 0xcd, 0x18, 0x0, 0x0, 0x17, 0xd0, 0x22, 0x6c, 0x21}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 10160); + EXPECT_EQ(status, 80); +} + +// REL (PubREL 30332 194 [PropContentType "0\157\150N +// \243|\175\SOH\250{\228\134\193s\189\133ub4\131i\197\207\203",PropMaximumQoS 240,PropSessionExpiryInterval +// 26171,PropReasonString +// "\152!X!S\217\161\ENQW7\248\168\222\231\227\174\201O\SUB<\144\&7\163\154\175Y\ETB\SI",PropReceiveMaximum +// 22904,PropSessionExpiryInterval 18294,PropTopicAlias 25799,PropResponseInformation +// "\198)\141\178\229\195\231(bp",PropServerReference "C\153F\209\136\DC2\209\139\153\196K~",PropCorrelationData +// "\160\212\&1\220%\143yr",PropMessageExpiryInterval 10541,PropTopicAliasMaximum 20624,PropWillDelayInterval +// 32656,PropSubscriptionIdentifierAvailable 215,PropAuthenticationMethod "\220\156\160\169\208\DC16{\b\172 +// \208\213\243",PropAuthenticationMethod +// "\177\154\SUB\163\EM\237\146\201\167\222\DLE*\149\195Y\173*\183.",PropAuthenticationMethod +// "u\165\133\RSc(Tp\220\DC3\229\150\207\DEL\r\n\184\\\145\181khFBR3\212\207",PropUserProperty "Q-O" +// "+\138,*Z\193\ENQ\232L\NAK\NAKy9",PropServerReference +// "c\181^!\253JRU\231\GS\153m\146\160\SYNzT",PropMessageExpiryInterval 15091,PropMessageExpiryInterval +// 10435,PropMessageExpiryInterval 3913,PropWildcardSubscriptionAvailable 37]) +TEST(PubACKREL5QCTest, Encode15) { + uint8_t pkt[] = {0x62, 0x88, 0x2, 0x76, 0x7c, 0xc2, 0x83, 0x2, 0x3, 0x0, 0x19, 0x30, 0x9d, 0x96, 0x4e, 0x20, 0xf3, + 0x7c, 0xaf, 0x1, 0xfa, 0x7b, 0xe4, 0x86, 0xc1, 0x73, 0xbd, 0x85, 0x75, 0x62, 0x34, 0x83, 0x69, 0xc5, + 0xcf, 0xcb, 0x24, 0xf0, 0x11, 0x0, 0x0, 0x66, 0x3b, 0x1f, 0x0, 0x1c, 0x98, 0x21, 0x58, 0x21, 0x53, + 0xd9, 0xa1, 0x5, 0x57, 0x37, 0xf8, 0xa8, 0xde, 0xe7, 0xe3, 0xae, 0xc9, 0x4f, 0x1a, 0x3c, 0x90, 0x37, + 0xa3, 0x9a, 0xaf, 0x59, 0x17, 0xf, 0x21, 0x59, 0x78, 0x11, 0x0, 0x0, 0x47, 0x76, 0x23, 0x64, 0xc7, + 0x1a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props1[] = {0x7f, 0x8, 0xd8, 0x8a, 0x59, 0x5e, 0x2e, 0x1, 0x3c, 0xf2}; - uint8_t bytesprops0[] = {0xd6, 0x64, 0xbd, 0xc4, 0x19, 0xa3, 0xe0, 0xc6, 0x44, 0xcd, - 0xb0, 0x10, 0x5c, 0xdc, 0xa6, 0x95, 0xa2, 0x28, 0xb0}; - uint8_t bytesprops2[] = {0xc1, 0x36, 0xd0, 0x5d, 0xef, 0xd3, 0x41, 0xbc, - 0x47, 0xe2, 0x98, 0x1d, 0xa2, 0x7b, 0x26, 0xdd}; - uint8_t bytesprops3[] = {0xcf, 0xcf, 0xb4, 0xe6, 0x75, 0x42, 0xe4, 0x3c, 0xd0, 0xa2, 0x49, 0xf6, 0x98, 0xa9, 0x59, - 0x9, 0x54, 0x42, 0x21, 0x48, 0x51, 0x5, 0xbf, 0xbf, 0x62, 0x50, 0xa, 0xed, 0x79, 0x91}; - uint8_t bytesprops5[] = {0x57, 0x1a}; - uint8_t bytesprops4[] = {0xef, 0x23, 0x31, 0x8e, 0xf2, 0x35, 0xed, 0xad, 0xfe, - 0x6, 0xd, 0xe2, 0x89, 0x60, 0x65, 0x7e, 0xe8}; - uint8_t bytesprops6[] = {0xd6}; - uint8_t bytesprops7[] = {0x9f, 0xc1, 0x2b, 0x47, 0x74, 0x99, 0x7c, 0xd2, 0x85, 0xda}; - uint8_t bytesprops8[] = {0x6a, 0xc0, 0x67, 0xd8, 0x31, 0xd0, 0x9e, 0x98, 0xee, 0xb0, 0xda, 0xa4, 0x77}; - uint8_t bytesprops9[] = {0x1a, 0xf7, 0xe2, 0x17, 0x70, 0x62, 0xff, 0xeb, 0x5f, 0x19, 0x85, 0x91, 0xc6, 0x6b, 0x41, - 0xc0, 0xbc, 0x35, 0xd9, 0xd5, 0x58, 0x82, 0xaa, 0x2f, 0xd0, 0x2d, 0x6d, 0x76, 0xcd}; + uint8_t bytesprops0[] = {0x30, 0x9d, 0x96, 0x4e, 0x20, 0xf3, 0x7c, 0xaf, 0x1, 0xfa, 0x7b, 0xe4, 0x86, + 0xc1, 0x73, 0xbd, 0x85, 0x75, 0x62, 0x34, 0x83, 0x69, 0xc5, 0xcf, 0xcb}; + uint8_t bytesprops1[] = {0x98, 0x21, 0x58, 0x21, 0x53, 0xd9, 0xa1, 0x5, 0x57, 0x37, 0xf8, 0xa8, 0xde, 0xe7, + 0xe3, 0xae, 0xc9, 0x4f, 0x1a, 0x3c, 0x90, 0x37, 0xa3, 0x9a, 0xaf, 0x59, 0x17, 0xf}; + uint8_t bytesprops2[] = {0xc6, 0x29, 0x8d, 0xb2, 0xe5, 0xc3, 0xe7, 0x28, 0x62, 0x70}; + uint8_t bytesprops3[] = {0x43, 0x99, 0x46, 0xd1, 0x88, 0x12, 0xd1, 0x8b, 0x99, 0xc4, 0x4b, 0x7e}; + uint8_t bytesprops4[] = {0xa0, 0xd4, 0x31, 0xdc, 0x25, 0x8f, 0x79, 0x72}; + uint8_t bytesprops5[] = {0xdc, 0x9c, 0xa0, 0xa9, 0xd0, 0x11, 0x36, 0x7b, 0x8, 0xac, 0x20, 0xd0, 0xd5, 0xf3}; + uint8_t bytesprops6[] = {0xb1, 0x9a, 0x1a, 0xa3, 0x19, 0xed, 0x92, 0xc9, 0xa7, 0xde, + 0x10, 0x2a, 0x95, 0xc3, 0x59, 0xad, 0x2a, 0xb7, 0x2e}; + uint8_t bytesprops7[] = {0x75, 0xa5, 0x85, 0x1e, 0x63, 0x28, 0x54, 0x70, 0xdc, 0x13, 0xe5, 0x96, 0xcf, 0x7f, + 0xd, 0xa, 0xb8, 0x5c, 0x91, 0xb5, 0x6b, 0x68, 0x46, 0x42, 0x52, 0x33, 0xd4, 0xcf}; + uint8_t bytesprops9[] = {0x2b, 0x8a, 0x2c, 0x2a, 0x5a, 0xc1, 0x5, 0xe8, 0x4c, 0x15, 0x15, 0x79, 0x39}; + uint8_t bytesprops8[] = {0x51, 0x2d, 0x4f}; + uint8_t bytesprops10[] = {0x63, 0xb5, 0x5e, 0x21, 0xfd, 0x4a, 0x52, 0x55, 0xe7, + 0x1d, 0x99, 0x6d, 0x92, 0xa0, 0x16, 0x7a, 0x54}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19966}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16597}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16525}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5330}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops4}, .v = {2, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 251}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6096}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27681}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26171}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22904}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18294}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25799}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10541}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20624}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32656}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops8}, .v = {13, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15091}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10435}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3913}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 37}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, 0, 32292, 34, props); + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 30332, 194, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REC (PubREC 32292 34 [PropSessionExpiryInterval 19966,PropSessionExpiryInterval 16597,PropServerKeepAlive -// 16525,PropUserProperty "\214d\189\196\EM\163\224\198D\205\176\DLE\\\220\166\149\162(\176" -// "\DEL\b\216\138Y^.\SOH<\242",PropResponseInformation -// "\193\&6\208]\239\211A\188G\226\152\GS\162{&\221",PropTopicAliasMaximum 5330,PropPayloadFormatIndicator -// 244,PropAssignedClientIdentifier -// "\207\207\180\230uB\228<\208\162I\246\152\169Y\tTB!HQ\ENQ\191\191bP\n\237y\145",PropRequestProblemInformation -// 72,PropWildcardSubscriptionAvailable 53,PropUserProperty "\239#1\142\242\&5\237\173\254\ACK\r\226\137`e~\232" -// "W\SUB",PropReasonString "\214",PropContentType "\159\193+Gt\153|\210\133\218",PropSharedSubscriptionAvailable -// 17,PropSubscriptionIdentifier 6,PropAuthenticationData -// "j\192g\216\&1\208\158\152\238\176\218\164w",PropRetainAvailable 251,PropServerReference -// "\SUB\247\226\ETBpb\255\235_\EM\133\145\198kA\192\188\&5\217\213X\130\170/\208-mv\205",PropWillDelayInterval -// 6096,PropTopicAliasMaximum 27681]) -TEST(PubACKREC5QCTest, Decode15) { - uint8_t pkt[] = {0x50, 0xd8, 0x1, 0x7e, 0x24, 0x22, 0xd3, 0x1, 0x11, 0x0, 0x0, 0x4d, 0xfe, 0x11, 0x0, 0x0, 0x40, - 0xd5, 0x13, 0x40, 0x8d, 0x26, 0x0, 0x13, 0xd6, 0x64, 0xbd, 0xc4, 0x19, 0xa3, 0xe0, 0xc6, 0x44, 0xcd, - 0xb0, 0x10, 0x5c, 0xdc, 0xa6, 0x95, 0xa2, 0x28, 0xb0, 0x0, 0xa, 0x7f, 0x8, 0xd8, 0x8a, 0x59, 0x5e, - 0x2e, 0x1, 0x3c, 0xf2, 0x1a, 0x0, 0x10, 0xc1, 0x36, 0xd0, 0x5d, 0xef, 0xd3, 0x41, 0xbc, 0x47, 0xe2, - 0x98, 0x1d, 0xa2, 0x7b, 0x26, 0xdd, 0x22, 0x14, 0xd2, 0x1, 0xf4, 0x12, 0x0, 0x1e, 0xcf, 0xcf, 0xb4, - 0xe6, 0x75, 0x42, 0xe4, 0x3c, 0xd0, 0xa2, 0x49, 0xf6, 0x98, 0xa9, 0x59, 0x9, 0x54, 0x42, 0x21, 0x48, - 0x51, 0x5, 0xbf, 0xbf, 0x62, 0x50, 0xa, 0xed, 0x79, 0x91, 0x17, 0x48, 0x28, 0x35, 0x26, 0x0, 0x11, - 0xef, 0x23, 0x31, 0x8e, 0xf2, 0x35, 0xed, 0xad, 0xfe, 0x6, 0xd, 0xe2, 0x89, 0x60, 0x65, 0x7e, 0xe8, - 0x0, 0x2, 0x57, 0x1a, 0x1f, 0x0, 0x1, 0xd6, 0x3, 0x0, 0xa, 0x9f, 0xc1, 0x2b, 0x47, 0x74, 0x99, - 0x7c, 0xd2, 0x85, 0xda, 0x2a, 0x11, 0xb, 0x6, 0x16, 0x0, 0xd, 0x6a, 0xc0, 0x67, 0xd8, 0x31, 0xd0, - 0x9e, 0x98, 0xee, 0xb0, 0xda, 0xa4, 0x77, 0x25, 0xfb, 0x1c, 0x0, 0x1d, 0x1a, 0xf7, 0xe2, 0x17, 0x70, - 0x62, 0xff, 0xeb, 0x5f, 0x19, 0x85, 0x91, 0xc6, 0x6b, 0x41, 0xc0, 0xbc, 0x35, 0xd9, 0xd5, 0x58, 0x82, - 0xaa, 0x2f, 0xd0, 0x2d, 0x6d, 0x76, 0xcd, 0x18, 0x0, 0x0, 0x17, 0xd0, 0x22, 0x6c, 0x21}; +// REL (PubREL 30332 194 [PropContentType "0\157\150N +// \243|\175\SOH\250{\228\134\193s\189\133ub4\131i\197\207\203",PropMaximumQoS 240,PropSessionExpiryInterval +// 26171,PropReasonString +// "\152!X!S\217\161\ENQW7\248\168\222\231\227\174\201O\SUB<\144\&7\163\154\175Y\ETB\SI",PropReceiveMaximum +// 22904,PropSessionExpiryInterval 18294,PropTopicAlias 25799,PropResponseInformation +// "\198)\141\178\229\195\231(bp",PropServerReference "C\153F\209\136\DC2\209\139\153\196K~",PropCorrelationData +// "\160\212\&1\220%\143yr",PropMessageExpiryInterval 10541,PropTopicAliasMaximum 20624,PropWillDelayInterval +// 32656,PropSubscriptionIdentifierAvailable 215,PropAuthenticationMethod "\220\156\160\169\208\DC16{\b\172 +// \208\213\243",PropAuthenticationMethod +// "\177\154\SUB\163\EM\237\146\201\167\222\DLE*\149\195Y\173*\183.",PropAuthenticationMethod +// "u\165\133\RSc(Tp\220\DC3\229\150\207\DEL\r\n\184\\\145\181khFBR3\212\207",PropUserProperty "Q-O" +// "+\138,*Z\193\ENQ\232L\NAK\NAKy9",PropServerReference +// "c\181^!\253JRU\231\GS\153m\146\160\SYNzT",PropMessageExpiryInterval 15091,PropMessageExpiryInterval +// 10435,PropMessageExpiryInterval 3913,PropWildcardSubscriptionAvailable 37]) +TEST(PubACKREL5QCTest, Decode15) { + uint8_t pkt[] = {0x62, 0x88, 0x2, 0x76, 0x7c, 0xc2, 0x83, 0x2, 0x3, 0x0, 0x19, 0x30, 0x9d, 0x96, 0x4e, 0x20, 0xf3, + 0x7c, 0xaf, 0x1, 0xfa, 0x7b, 0xe4, 0x86, 0xc1, 0x73, 0xbd, 0x85, 0x75, 0x62, 0x34, 0x83, 0x69, 0xc5, + 0xcf, 0xcb, 0x24, 0xf0, 0x11, 0x0, 0x0, 0x66, 0x3b, 0x1f, 0x0, 0x1c, 0x98, 0x21, 0x58, 0x21, 0x53, + 0xd9, 0xa1, 0x5, 0x57, 0x37, 0xf8, 0xa8, 0xde, 0xe7, 0xe3, 0xae, 0xc9, 0x4f, 0x1a, 0x3c, 0x90, 0x37, + 0xa3, 0x9a, 0xa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, 0x28, 0xc3, 0x2, 0x0, 0x0, 0xf, 0x49, 0x28, 0x25}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32292); - EXPECT_EQ(status, 34); -} - -// ACK (PubACK 11679 6 [PropAssignedClientIdentifier -// "\220\SO\167\167t\180\223\201\n^<\b\r\221\ETX\226\212\RS",PropResponseTopic "\168\SOf",PropMessageExpiryInterval -// 14878,PropRequestResponseInformation 5,PropWillDelayInterval 14209,PropReceiveMaximum 10194,PropSessionExpiryInterval -// 3797,PropResponseInformation "Xc",PropReceiveMaximum 3172,PropRetainAvailable 121,PropRetainAvailable -// 176,PropAssignedClientIdentifier -// "1\211sTO3q\SOH\230\r\142\172\SUB\193\176\133X\135\132\130\246\CAN\153\217\251",PropServerReference -// "-\SOH\140EEI<\184",PropCorrelationData -// "\146\205&\252\217\144|\DC1\151\218O\NUL,\RS\200\218\174\144\DEL\251\247$Z\239T'"]) -TEST(PubACKACK5QCTest, Encode16) { - uint8_t pkt[] = {0x40, 0x83, 0x1, 0x2d, 0x9f, 0x6, 0x7f, 0x12, 0x0, 0x12, 0xdc, 0xe, 0xa7, 0xa7, 0x74, 0xb4, 0xdf, - 0xc9, 0xa, 0x5e, 0x3c, 0x8, 0xd, 0xdd, 0x3, 0xe2, 0xd4, 0x1e, 0x8, 0x0, 0x3, 0xa8, 0xe, 0x66, - 0x2, 0x0, 0x0, 0x3a, 0x1e, 0x19, 0x5, 0x18, 0x0, 0x0, 0x37, 0x81, 0x21, 0x27, 0xd2, 0x11, 0x0, - 0x0, 0xe, 0xd5, 0x1a, 0x0, 0x2, 0x58, 0x63, 0x21, 0xc, 0x64, 0x25, 0x79, 0x25, 0xb0, 0x12, 0x0, - 0x19, 0x31, 0xd3, 0x73, 0x54, 0x4f, 0x33, 0x71, 0x1, 0xe6, 0xd, 0x8e, 0xac, 0x1a, 0xc1, 0xb0, 0x85, - 0x58, 0x87, 0x84, 0x82, 0xf6, 0x18, 0x99, 0xd9, 0xfb, 0x1c, 0x0, 0x8, 0x2d, 0x1, 0x8c, 0x45, 0x45, - 0x49, 0x3c, 0xb8, 0x9, 0x0, 0x1a, 0x92, 0xcd, 0x26, 0xfc, 0xd9, 0x90, 0x7c, 0x11, 0x97, 0xda, 0x4f, - 0x0, 0x2c, 0x1e, 0xc8, 0xda, 0xae, 0x90, 0x7f, 0xfb, 0xf7, 0x24, 0x5a, 0xef, 0x54, 0x27}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 30332); + EXPECT_EQ(status, 194); +} + +// REL (PubREL 16804 216 [PropReceiveMaximum 16204,PropAuthenticationMethod +// "\195\&9\161\244!C\225\r\204O)\n\253\249\244\SUB\140\251\132",PropSharedSubscriptionAvailable 154,PropResponseTopic +// "\228o\241\136\176\222\201\225\163O?\ENQ*30\204k\239",PropRequestResponseInformation 50,PropPayloadFormatIndicator +// 218,PropAuthenticationMethod "\NUL\192T\156"]) +TEST(PubACKREL5QCTest, Encode16) { + uint8_t pkt[] = {0x62, 0x3f, 0x41, 0xa4, 0xd8, 0x3b, 0x21, 0x3f, 0x4c, 0x15, 0x0, 0x13, 0xc3, 0x39, 0xa1, 0xf4, 0x21, + 0x43, 0xe1, 0xd, 0xcc, 0x4f, 0x29, 0xa, 0xfd, 0xf9, 0xf4, 0x1a, 0x8c, 0xfb, 0x84, 0x2a, 0x9a, 0x8, + 0x0, 0x12, 0xe4, 0x6f, 0xf1, 0x88, 0xb0, 0xde, 0xc9, 0xe1, 0xa3, 0x4f, 0x3f, 0x5, 0x2a, 0x33, 0x30, + 0xcc, 0x6b, 0xef, 0x19, 0x32, 0x1, 0xda, 0x15, 0x0, 0x4, 0x0, 0xc0, 0x54, 0x9c}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0xdc, 0xe, 0xa7, 0xa7, 0x74, 0xb4, 0xdf, 0xc9, 0xa, - 0x5e, 0x3c, 0x8, 0xd, 0xdd, 0x3, 0xe2, 0xd4, 0x1e}; - uint8_t bytesprops1[] = {0xa8, 0xe, 0x66}; - uint8_t bytesprops2[] = {0x58, 0x63}; - uint8_t bytesprops3[] = {0x31, 0xd3, 0x73, 0x54, 0x4f, 0x33, 0x71, 0x1, 0xe6, 0xd, 0x8e, 0xac, 0x1a, - 0xc1, 0xb0, 0x85, 0x58, 0x87, 0x84, 0x82, 0xf6, 0x18, 0x99, 0xd9, 0xfb}; - uint8_t bytesprops4[] = {0x2d, 0x1, 0x8c, 0x45, 0x45, 0x49, 0x3c, 0xb8}; - uint8_t bytesprops5[] = {0x92, 0xcd, 0x26, 0xfc, 0xd9, 0x90, 0x7c, 0x11, 0x97, 0xda, 0x4f, 0x0, 0x2c, - 0x1e, 0xc8, 0xda, 0xae, 0x90, 0x7f, 0xfb, 0xf7, 0x24, 0x5a, 0xef, 0x54, 0x27}; + uint8_t bytesprops0[] = {0xc3, 0x39, 0xa1, 0xf4, 0x21, 0x43, 0xe1, 0xd, 0xcc, 0x4f, + 0x29, 0xa, 0xfd, 0xf9, 0xf4, 0x1a, 0x8c, 0xfb, 0x84}; + uint8_t bytesprops1[] = {0xe4, 0x6f, 0xf1, 0x88, 0xb0, 0xde, 0xc9, 0xe1, 0xa3, + 0x4f, 0x3f, 0x5, 0x2a, 0x33, 0x30, 0xcc, 0x6b, 0xef}; + uint8_t bytesprops2[] = {0x0, 0xc0, 0x54, 0x9c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14878}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14209}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10194}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3797}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3172}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16204}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 11679, 6, props); + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 16804, 216, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 11679 6 [PropAssignedClientIdentifier -// "\220\SO\167\167t\180\223\201\n^<\b\r\221\ETX\226\212\RS",PropResponseTopic "\168\SOf",PropMessageExpiryInterval -// 14878,PropRequestResponseInformation 5,PropWillDelayInterval 14209,PropReceiveMaximum 10194,PropSessionExpiryInterval -// 3797,PropResponseInformation "Xc",PropReceiveMaximum 3172,PropRetainAvailable 121,PropRetainAvailable -// 176,PropAssignedClientIdentifier -// "1\211sTO3q\SOH\230\r\142\172\SUB\193\176\133X\135\132\130\246\CAN\153\217\251",PropServerReference -// "-\SOH\140EEI<\184",PropCorrelationData -// "\146\205&\252\217\144|\DC1\151\218O\NUL,\RS\200\218\174\144\DEL\251\247$Z\239T'"]) -TEST(PubACKACK5QCTest, Decode16) { - uint8_t pkt[] = {0x40, 0x83, 0x1, 0x2d, 0x9f, 0x6, 0x7f, 0x12, 0x0, 0x12, 0xdc, 0xe, 0xa7, 0xa7, 0x74, 0xb4, 0xdf, - 0xc9, 0xa, 0x5e, 0x3c, 0x8, 0xd, 0xdd, 0x3, 0xe2, 0xd4, 0x1e, 0x8, 0x0, 0x3, 0xa8, 0xe, 0x66, - 0x2, 0x0, 0x0, 0x3a, 0x1e, 0x19, 0x5, 0x18, 0x0, 0x0, 0x37, 0x81, 0x21, 0x27, 0xd2, 0x11, 0x0, - 0x0, 0xe, 0xd5, 0x1a, 0x0, 0x2, 0x58, 0x63, 0x21, 0xc, 0x64, 0x25, 0x79, 0x25, 0xb0, 0x12, 0x0, - 0x19, 0x31, 0xd3, 0x73, 0x54, 0x4f, 0x33, 0x71, 0x1, 0xe6, 0xd, 0x8e, 0xac, 0x1a, 0xc1, 0xb0, 0x85, - 0x58, 0x87, 0x84, 0x82, 0xf6, 0x18, 0x99, 0xd9, 0xfb, 0x1c, 0x0, 0x8, 0x2d, 0x1, 0x8c, 0x45, 0x45, - 0x49, 0x3c, 0xb8, 0x9, 0x0, 0x1a, 0x92, 0xcd, 0x26, 0xfc, 0xd9, 0x90, 0x7c, 0x11, 0x97, 0xda, 0x4f, - 0x0, 0x2c, 0x1e, 0xc8, 0xda, 0xae, 0x90, 0x7f, 0xfb, 0xf7, 0x24, 0x5a, 0xef, 0x54, 0x27}; +// REL (PubREL 16804 216 [PropReceiveMaximum 16204,PropAuthenticationMethod +// "\195\&9\161\244!C\225\r\204O)\n\253\249\244\SUB\140\251\132",PropSharedSubscriptionAvailable 154,PropResponseTopic +// "\228o\241\136\176\222\201\225\163O?\ENQ*30\204k\239",PropRequestResponseInformation 50,PropPayloadFormatIndicator +// 218,PropAuthenticationMethod "\NUL\192T\156"]) +TEST(PubACKREL5QCTest, Decode16) { + uint8_t pkt[] = {0x62, 0x3f, 0x41, 0xa4, 0xd8, 0x3b, 0x21, 0x3f, 0x4c, 0x15, 0x0, 0x13, 0xc3, 0x39, 0xa1, 0xf4, 0x21, + 0x43, 0xe1, 0xd, 0xcc, 0x4f, 0x29, 0xa, 0xfd, 0xf9, 0xf4, 0x1a, 0x8c, 0xfb, 0x84, 0x2a, 0x9a, 0x8, + 0x0, 0x12, 0xe4, 0x6f, 0xf1, 0x88, 0xb0, 0xde, 0xc9, 0xe1, 0xa3, 0x4f, 0x3f, 0x5, 0x2a, 0x33, 0x30, + 0xcc, 0x6b, 0xef, 0x19, 0x32, 0x1, 0xda, 0x15, 0x0, 0x4, 0x0, 0xc0, 0x54, 0x9c}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11679); - EXPECT_EQ(status, 6); -} - -// COMP (PubCOMP 24709 179 [PropUserProperty "s" "\STX\133&\236f\NUL\137\STXXg\215+!",PropServerReference -// ":\238M<\197\&8\229\&8\168c\150\217\190A\206\a\166\166\DC4[mo",PropTopicAlias 3894,PropTopicAliasMaximum -// 26084,PropRetainAvailable 195,PropServerReference -// "\224\DEL|\149\SI\200\169N\208)Tw\DLE\FS\DEL",PropResponseInformation "\160]\SIL\226\EOT\172mJ\149\184J1~\US\DEL*2 -// \USE\215K\188*h\188\141\151",PropSubscriptionIdentifier 3,PropSessionExpiryInterval -// 25529,PropAssignedClientIdentifier -// "\129a\SUB\233\&2\DC4Pl=F\190Z\DEL7\186\140U\243\213\220\170C",PropSubscriptionIdentifier 19,PropRetainAvailable -// 243,PropServerKeepAlive 4192,PropUserProperty "\228\129\255\131\ENQ\216\211\255D" -// "\215\220V\NAK\249\&8\164\EMqH\143\229\199G}B\186",PropPayloadFormatIndicator 191,PropRequestProblemInformation -// 77,PropServerReference "o\145S\207wq\245G\202\ESC\188\169\139",PropMessageExpiryInterval 4286,PropWillDelayInterval -// 7675,PropPayloadFormatIndicator 79,PropAssignedClientIdentifier "i\253\DELSEQ\t\tze8",PropTopicAliasMaximum -// 28032,PropCorrelationData "C\168\\k\DLE\244\240r\142vRy\132",PropMessageExpiryInterval -// 19088,PropSubscriptionIdentifierAvailable 208,PropResponseInformation -// "EP\143\SYN\ACK\196\152\SI\185`\220&\NAKq%i\206C\168\243C#\202\204\138\154",PropReceiveMaximum 21789]) -TEST(PubACKCOMP5QCTest, Encode17) { - uint8_t pkt[] = { - 0x70, 0x99, 0x2, 0x60, 0x85, 0xb3, 0x94, 0x2, 0x26, 0x0, 0x1, 0x73, 0x0, 0xd, 0x2, 0x85, 0x26, 0xec, 0x66, - 0x0, 0x89, 0x2, 0x58, 0x67, 0xd7, 0x2b, 0x21, 0x1c, 0x0, 0x16, 0x3a, 0xee, 0x4d, 0x3c, 0xc5, 0x38, 0xe5, 0x38, - 0xa8, 0x63, 0x96, 0xd9, 0xbe, 0x41, 0xce, 0x7, 0xa6, 0xa6, 0x14, 0x5b, 0x6d, 0x6f, 0x23, 0xf, 0x36, 0x22, 0x65,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x79, 0x84, 0x2, 0x0, - 0x0, 0x4a, 0x90, 0x29, 0xd0, 0x1a, 0x0, 0x1a, 0x45, 0x50, 0x8f, 0x16, 0x6, 0xc4, 0x98, 0xf, 0xb9, 0x60, 0xdc, - 0x26, 0x15, 0x71, 0x25, 0x69, 0xce, 0x43, 0xa8, 0xf3, 0x43, 0x23, 0xca, 0xcc, 0x8a, 0x9a, 0x21, 0x55, 0x1d}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 16804); + EXPECT_EQ(status, 216); +} + +// REC (PubREC 5882 7 [PropResponseTopic "Zh\223!\177\&2@\254X\243\250f",PropReceiveMaximum 21439,PropUserProperty +// "\SOH\223\139\156mD&\244F\200\DELp7n\182r\f\170\138" +// "\173a\170\159\173\225%\249K\233h\NAK\146\SOH\191\202ZT\238\222X\137",PropResponseTopic "/1\214M",PropRetainAvailable +// 211,PropSharedSubscriptionAvailable 53,PropSubscriptionIdentifierAvailable 232,PropSubscriptionIdentifierAvailable +// 202,PropResponseTopic "\192\134-N\242\173\ACKB",PropAuthenticationMethod +// "\242\"Ww\183H\165}\205\196\174\SOQq\173\&9S\167\189\170\236\234\177\168jB\231q\161",PropWillDelayInterval +// 25352,PropRequestResponseInformation 217,PropMaximumPacketSize 945,PropPayloadFormatIndicator 204,PropMaximumQoS +// 34,PropServerKeepAlive 12947,PropUserProperty "(\204\129" +// "\t\200Q2\137\STX\146B\192\178\176\236\180\133\242\242L\NAK\FS",PropCorrelationData +// "\240\253\&1t\134\a\169\143\234x\229\r"]) +TEST(PubACKREC5QCTest, Encode17) { + uint8_t pkt[] = {0x50, 0xbc, 0x1, 0x16, 0xfa, 0x7, 0xb7, 0x1, 0x8, 0x0, 0xc, 0x5a, 0x68, 0xdf, 0x21, 0xb1, + 0x32, 0x40, 0xfe, 0x58, 0xf3, 0xfa, 0x66, 0x21, 0x53, 0xbf, 0x26, 0x0, 0x13, 0x1, 0xdf, 0x8b, + 0x9c, 0x6d, 0x44, 0x26, 0xf4, 0x46, 0xc8, 0x7f, 0x70, 0x37, 0x6e, 0xb6, 0x72, 0xc, 0xaa, 0x8a, + 0x0, 0x16, 0xad, 0x61, 0xaa, 0x9f, 0xad, 0xe1, 0x25, 0xf9, 0x4b, 0xe9, 0x68, 0x15, 0x92, 0x1, + 0xbf, 0xca, 0x5a, 0x54, 0xee, 0xde, 0x58, 0x89, 0x8, 0x0, 0x4, 0x2f, 0x31, 0xd6, 0x4d, 0x25, + 0xd3, 0x2a, 0x35, 0x29, 0xe8, 0x29, 0xca, 0x8, 0x0, 0x8, 0xc0, 0x86, 0x2d, 0x4e, 0xf2, 0xad, + 0x6, 0x42, 0x15, 0x0, 0x1d, 0xf2, 0x22, 0x57, 0x77, 0xb7, 0x48, 0xa5, 0x7d, 0xcd, 0xc4, 0xae, + 0xe, 0x51, 0x71, 0xad, 0x39, 0x53, 0xa7, 0xbd, 0xaa, 0xec, 0xea, 0xb1, 0xa8, 0x6a, 0x42, 0xe7, + 0x71, 0xa1, 0x18, 0x0, 0x0, 0x63, 0x8, 0x19, 0xd9, 0x27, 0x0, 0x0, 0x3, 0xb1, 0x1, 0xcc, + 0x24, 0x22, 0x13, 0x32, 0x93, 0x26, 0x0, 0x3, 0x28, 0xcc, 0x81, 0x0, 0x13, 0x9, 0xc8, 0x51, + 0x32, 0x89, 0x2, 0x92, 0x42, 0xc0, 0xb2, 0xb0, 0xec, 0xb4, 0x85, 0xf2, 0xf2, 0x4c, 0x15, 0x1c, + 0x9, 0x0, 0xc, 0xf0, 0xfd, 0x31, 0x74, 0x86, 0x7, 0xa9, 0x8f, 0xea, 0x78, 0xe5, 0xd}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops1[] = {0x2, 0x85, 0x26, 0xec, 0x66, 0x0, 0x89, 0x2, 0x58, 0x67, 0xd7, 0x2b, 0x21}; - uint8_t bytesprops0[] = {0x73}; - uint8_t bytesprops2[] = {0x3a, 0xee, 0x4d, 0x3c, 0xc5, 0x38, 0xe5, 0x38, 0xa8, 0x63, 0x96, - 0xd9, 0xbe, 0x41, 0xce, 0x7, 0xa6, 0xa6, 0x14, 0x5b, 0x6d, 0x6f}; - uint8_t bytesprops3[] = {0xe0, 0x7f, 0x7c, 0x95, 0xf, 0xc8, 0xa9, 0x4e, 0xd0, 0x29, 0x54, 0x77, 0x10, 0x1c, 0x7f}; - uint8_t bytesprops4[] = {0xa0, 0x5d, 0xf, 0x4c, 0xe2, 0x4, 0xac, 0x6d, 0x4a, 0x95, 0xb8, 0x4a, 0x31, 0x7e, 0x1f, - 0x7f, 0x2a, 0x32, 0x20, 0x1f, 0x45, 0xd7, 0x4b, 0xbc, 0x2a, 0x68, 0xbc, 0x8d, 0x97}; - uint8_t bytesprops5[] = {0x81, 0x61, 0x1a, 0xe9, 0x32, 0x14, 0x50, 0x6c, 0x3d, 0x46, 0xbe, - 0x5a, 0x7f, 0x37, 0xba, 0x8c, 0x55, 0xf3, 0xd5, 0xdc, 0xaa, 0x43}; - uint8_t bytesprops7[] = {0xd7, 0xdc, 0x56, 0x15, 0xf9, 0x38, 0xa4, 0x19, 0x71, - 0x48, 0x8f, 0xe5, 0xc7, 0x47, 0x7d, 0x42, 0xba}; - uint8_t bytesprops6[] = {0xe4, 0x81, 0xff, 0x83, 0x5, 0xd8, 0xd3, 0xff, 0x44}; - uint8_t bytesprops8[] = {0x6f, 0x91, 0x53, 0xcf, 0x77, 0x71, 0xf5, 0x47, 0xca, 0x1b, 0xbc, 0xa9, 0x8b}; - uint8_t bytesprops9[] = {0x69, 0xfd, 0x7f, 0x53, 0x45, 0x51, 0x9, 0x9, 0x7a, 0x65, 0x38}; - uint8_t bytesprops10[] = {0x43, 0xa8, 0x5c, 0x6b, 0x10, 0xf4, 0xf0, 0x72, 0x8e, 0x76, 0x52, 0x79, 0x84}; - uint8_t bytesprops11[] = {0x45, 0x50, 0x8f, 0x16, 0x6, 0xc4, 0x98, 0xf, 0xb9, 0x60, 0xdc, 0x26, 0x15, - 0x71, 0x25, 0x69, 0xce, 0x43, 0xa8, 0xf3, 0x43, 0x23, 0xca, 0xcc, 0x8a, 0x9a}; + uint8_t bytesprops0[] = {0x5a, 0x68, 0xdf, 0x21, 0xb1, 0x32, 0x40, 0xfe, 0x58, 0xf3, 0xfa, 0x66}; + uint8_t bytesprops2[] = {0xad, 0x61, 0xaa, 0x9f, 0xad, 0xe1, 0x25, 0xf9, 0x4b, 0xe9, 0x68, + 0x15, 0x92, 0x1, 0xbf, 0xca, 0x5a, 0x54, 0xee, 0xde, 0x58, 0x89}; + uint8_t bytesprops1[] = {0x1, 0xdf, 0x8b, 0x9c, 0x6d, 0x44, 0x26, 0xf4, 0x46, 0xc8, + 0x7f, 0x70, 0x37, 0x6e, 0xb6, 0x72, 0xc, 0xaa, 0x8a}; + uint8_t bytesprops3[] = {0x2f, 0x31, 0xd6, 0x4d}; + uint8_t bytesprops4[] = {0xc0, 0x86, 0x2d, 0x4e, 0xf2, 0xad, 0x6, 0x42}; + uint8_t bytesprops5[] = {0xf2, 0x22, 0x57, 0x77, 0xb7, 0x48, 0xa5, 0x7d, 0xcd, 0xc4, 0xae, 0xe, 0x51, 0x71, 0xad, + 0x39, 0x53, 0xa7, 0xbd, 0xaa, 0xec, 0xea, 0xb1, 0xa8, 0x6a, 0x42, 0xe7, 0x71, 0xa1}; + uint8_t bytesprops7[] = {0x9, 0xc8, 0x51, 0x32, 0x89, 0x2, 0x92, 0x42, 0xc0, 0xb2, + 0xb0, 0xec, 0xb4, 0x85, 0xf2, 0xf2, 0x4c, 0x15, 0x1c}; + uint8_t bytesprops6[] = {0x28, 0xcc, 0x81}; + uint8_t bytesprops8[] = {0xf0, 0xfd, 0x31, 0x74, 0x86, 0x7, 0xa9, 0x8f, 0xea, 0x78, 0xe5, 0xd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3894}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26084}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25529}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4192}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops6}, .v = {17, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 77}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {13, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4286}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7675}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28032}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19088}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21789}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21439}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops1}, .v = {22, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25352}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 945}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12947}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops6}, .v = {19, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops8}}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 24709, 179, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, 0, 5882, 7, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 24709 179 [PropUserProperty "s" "\STX\133&\236f\NUL\137\STXXg\215+!",PropServerReference -// ":\238M<\197\&8\229\&8\168c\150\217\190A\206\a\166\166\DC4[mo",PropTopicAlias 3894,PropTopicAliasMaximum -// 26084,PropRetainAvailable 195,PropServerReference -// "\224\DEL|\149\SI\200\169N\208)Tw\DLE\FS\DEL",PropResponseInformation "\160]\SIL\226\EOT\172mJ\149\184J1~\US\DEL*2 -// \USE\215K\188*h\188\141\151",PropSubscriptionIdentifier 3,PropSessionExpiryInterval -// 25529,PropAssignedClientIdentifier -// "\129a\SUB\233\&2\DC4Pl=F\190Z\DEL7\186\140U\243\213\220\170C",PropSubscriptionIdentifier 19,PropRetainAvailable -// 243,PropServerKeepAlive 4192,PropUserProperty "\228\129\255\131\ENQ\216\211\255D" -// "\215\220V\NAK\249\&8\164\EMqH\143\229\199G}B\186",PropPayloadFormatIndicator 191,PropRequestProblemInformation -// 77,PropServerReference "o\145S\207wq\245G\202\ESC\188\169\139",PropMessageExpiryInterval 4286,PropWillDelayInterval -// 7675,PropPayloadFormatIndicator 79,PropAssignedClientIdentifier "i\253\DELSEQ\t\tze8",PropTopicAliasMaximum -// 28032,PropCorrelationData "C\168\\k\DLE\244\240r\142vRy\132",PropMessageExpiryInterval -// 19088,PropSubscriptionIdentifierAvailable 208,PropResponseInformation -// "EP\143\SYN\ACK\196\152\SI\185`\220&\NAKq%i\206C\168\243C#\202\204\138\154",PropReceiveMaximum 21789]) -TEST(PubACKCOMP5QCTest, Decode17) { - uint8_t pkt[] = { - 0x70, 0x99, 0x2, 0x60, 0x85, 0xb3, 0x94, 0x2, 0x26, 0x0, 0x1, 0x73, 0x0, 0xd, 0x2, 0x85, 0x26, 0xec, 0x66, - 0x0,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 0x0, 0x0, 0x1d, - 0xfb, 0x1, 0x4f, 0x12, 0x0, 0xb, 0x69, 0xfd, 0x7f, 0x53, 0x45, 0x51, 0x9, 0x9, 0x7a, 0x65, 0x38, 0x22, 0x6d, - 0x80, 0x9, 0x0, 0xd, 0x43, 0xa8, 0x5c, 0x6b, 0x10, 0xf4, 0xf0, 0x72, 0x8e, 0x76, 0x52, 0x79, 0x84, 0x2, 0x0, - 0x0, 0x4a, 0x90, 0x29, 0xd0, 0x1a, 0x0, 0x1a, 0x45, 0x50, 0x8f, 0x16, 0x6, 0xc4, 0x98, 0xf, 0xb9, 0x60, 0xdc, - 0x26, 0x15, 0x71, 0x25, 0x69, 0xce, 0x43, 0xa8, 0xf3, 0x43, 0x23, 0xca, 0xcc, 0x8a, 0x9a, 0x21, 0x55, 0x1d}; +// REC (PubREC 5882 7 [PropResponseTopic "Zh\223!\177\&2@\254X\243\250f",PropReceiveMaximum 21439,PropUserProperty +// "\SOH\223\139\156mD&\244F\200\DELp7n\182r\f\170\138" +// "\173a\170\159\173\225%\249K\233h\NAK\146\SOH\191\202ZT\238\222X\137",PropResponseTopic "/1\214M",PropRetainAvailable +// 211,PropSharedSubscriptionAvailable 53,PropSubscriptionIdentifierAvailable 232,PropSubscriptionIdentifierAvailable +// 202,PropResponseTopic "\192\134-N\242\173\ACKB",PropAuthenticationMethod +// "\242\"Ww\183H\165}\205\196\174\SOQq\173\&9S\167\189\170\236\234\177\168jB\231q\161",PropWillDelayInterval +// 25352,PropRequestResponseInformation 217,PropMaximumPacketSize 945,PropPayloadFormatIndicator 204,PropMaximumQoS +// 34,PropServerKeepAlive 12947,PropUserProperty "(\204\129" +// "\t\200Q2\137\STX\146B\192\178\176\236\180\133\242\242L\NAK\FS",PropCorrelationData +// "\240\253\&1t\134\a\169\143\234x\229\r"]) +TEST(PubACKREC5QCTest, Decode17) { + uint8_t pkt[] = {0x50, 0xbc, 0x1, 0x16, 0xfa, 0x7, 0xb7, 0x1, 0x8, 0x0, 0xc, 0x5a, 0x68, 0xdf, 0x21, 0xb1, + 0x32, 0x40, 0xfe, 0x58, 0xf3, 0xfa, 0x66, 0x21, 0x53, 0xbf, 0x26, 0x0, 0x13, 0x1, 0xdf, 0x8b, + 0x9c, 0x6d, 0x44, 0x26, 0xf4, 0x46, 0xc8, 0x7f, 0x70, 0x37, 0x6e, 0xb6, 0x72, 0xc, 0xaa, 0x8a, + 0x0, 0x16, 0xad, 0x61, 0xaa, 0x9f, 0xad, 0xe1, 0x25, 0xf9, 0x4b, 0xe9, 0x68, 0x15, 0x92, 0x1, + 0xbf, 0xca, 0x5a, 0x54, 0xee, 0xde, 0x58, 0x89, 0x8, 0x0, 0x4, 0x2f, 0x31, 0xd6, 0x4d, 0x25, + 0xd3, 0x2a, 0x35, 0x29, 0xe8, 0x29, 0xca, 0x8, 0x0, 0x8, 0xc0, 0x86, 0x2d, 0x4e, 0xf2, 0xad, + 0x6, 0x42, 0x15, 0x0, 0x1d, 0xf2, 0x22, 0x57, 0x77, 0xb7, 0x48, 0xa5, 0x7d, 0xcd, 0xc4, 0xae, + 0xe, 0x51, 0x71, 0xad, 0x39, 0x53, 0xa7, 0xbd, 0xaa, 0xec, 0xea, 0xb1, 0xa8, 0x6a, 0x42, 0xe7, + 0x71, 0xa1, 0x18, 0x0, 0x0, 0x63, 0x8, 0x19, 0xd9, 0x27, 0x0, 0x0, 0x3, 0xb1, 0x1, 0xcc, + 0x24, 0x22, 0x13, 0x32, 0x93, 0x26, 0x0, 0x3, 0x28, 0xcc, 0x81, 0x0, 0x13, 0x9, 0xc8, 0x51, + 0x32, 0x89, 0x2, 0x92, 0x42, 0xc0, 0xb2, 0xb0, 0xec, 0xb4, 0x85, 0xf2, 0xf2, 0x4c, 0x15, 0x1c, + 0x9, 0x0, 0xc, 0xf0, 0xfd, 0x31, 0x74, 0x86, 0x7, 0xa9, 0x8f, 0xea, 0x78, 0xe5, 0xd}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24709); - EXPECT_EQ(status, 179); -} - -// REL (PubREL 19085 19 [PropAuthenticationData "\229\EMU\215\170\189\150q\171\133\137\143\GS",PropContentType -// "|\203?\153\139\v\164\NAKo\190\&2y\224\246[\203\156\234\170\149\186\153\241_4\247\252\182\139",PropTopicAliasMaximum -// 23515,PropResponseTopic "\202QE\EM\128\131\254\206w\ETBg",PropServerKeepAlive 2467,PropMessageExpiryInterval -// 23054,PropWildcardSubscriptionAvailable 68,PropSessionExpiryInterval 14963,PropWillDelayInterval -// 26769,PropRequestProblemInformation 93,PropResponseInformation "\142",PropTopicAliasMaximum -// 12142,PropAuthenticationData ")\232\161Yh\138\205\172:\SI\221\tD\238\GSR\135!<\200",PropSessionExpiryInterval -// 26062,PropSubscriptionIdentifier 1,PropRequestProblemInformation 12,PropResponseInformation -// "+\236\139\&6%\170",PropServerKeepAlive 27551,PropSharedSubscriptionAvailable 176,PropAuthenticationData -// "\NAK#\203\137\157\133)E\138\&9\168\142\SOH\228m\221\199\214\240\249\151\215J\233$B\190\161\178",PropWillDelayInterval -// 3405,PropPayloadFormatIndicator 15,PropUserProperty "\244\&6\179" -// "[\187\130LMUA*\STX\168Mk\232\DELe\145\134\137",PropMaximumPacketSize 6947,PropPayloadFormatIndicator 122]) + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 5882); + EXPECT_EQ(status, 7); +} + +// REL (PubREL 9713 122 [PropCorrelationData "\218\184\US\179O\185u\208f^\137\207*\190\135\158\247",PropCorrelationData +// "\251}8\219d\USr\253\211",PropAuthenticationMethod +// "\176\173iZ|[\156\DC3v\253R\190\255",PropRequestResponseInformation 194,PropResponseInformation +// "\226\ETB\SOH\245\215\255\ETX\241\155\173\v\213\&1\190\EOT",PropContentType +// ")\177-\SYNHnl%\202\177\FSI\183\145_\245\140\226\250\&9QS\ACK-\EM",PropWildcardSubscriptionAvailable +// 243,PropUserProperty "xa\231i\199$^\167{%5\228E\DLE\188\198\\" +// "\240J\136\228\138+\248\133F\178\DC2\160\238\164AXb\FS\SIl\223\189\150#i\r\129i\223"]) TEST(PubACKREL5QCTest, Encode18) { - uint8_t pkt[] = {0x62, 0xd9, 0x1, 0x4a, 0x8d, 0x13, 0xd4, 0x1, 0x16, 0x0, 0xd, 0xe5, 0x19, 0x55, 0xd7, 0xaa, 0xbd, - 0x96, 0x71, 0xab, 0x85, 0x89, 0x8f, 0x1d, 0x3, 0x0, 0x1d, 0x7c, 0xcb, 0x3f, 0x99, 0x8b, 0xb, 0xa4, - 0x15, 0x6f, 0xbe, 0x32, 0x79, 0xe0, 0xf6, 0x5b, 0xcb, 0x9c, 0xea, 0xaa, 0x95, 0xba, 0x99, 0xf1, 0x5f, - 0x34, 0xf7, 0xfc, 0xb6, 0x8b, 0x22, 0x5b, 0xdb, 0x8, 0x0, 0xb, 0xca, 0x51, 0x45, 0x19, 0x80, 0x83, - 0xfe, 0xce, 0x77, 0x17, 0x67, 0x13, 0x9, 0xa3, 0x2, 0x0, 0x0, 0x5a, 0xe, 0x28, 0x44, 0x11, 0x0, - 0x0, 0x3a, 0x73, 0x18, 0x0, 0x0, 0x68, 0x91, 0x17, 0x5d, 0x1a, 0x0, 0x1, 0x8e, 0x22, 0x2f, 0x6e, - 0x16, 0x0, 0x14, 0x29, 0xe8, 0xa1, 0x59, 0x68, 0x8a, 0xcd, 0xac, 0x3a, 0xf, 0xdd, 0x9, 0x44, 0xee, - 0x1d, 0x52, 0x87, 0x21, 0x3c, 0xc8, 0x11, 0x0, 0x0, 0x65, 0xce, 0xb, 0x1, 0x17, 0xc, 0x1a, 0x0, -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0x39, 0x51, 0x53, 0x6, 0x2d, 0x19, 0x28, 0xf3, 0x26, 0x0, 0x11, 0x78, 0x61, 0xe7, + 0x69, 0xc7, 0x24, 0x5e, 0xa7, 0x7b, 0x25, 0x35, 0xe4, 0x45, 0x10, 0xbc, 0xc6, 0x5c, 0x0, 0x1d, + 0xf0, 0x4a, 0x88, 0xe4, 0x8a, 0x2b, 0xf8, 0x85, 0x46, 0xb2, 0x12, 0xa0, 0xee, 0xa4, 0x41, 0x58, + 0x62, 0x1c, 0xf, 0x6c, 0xdf, 0xbd, 0x96, 0x23, 0x69, 0xd, 0x81, 0x69, 0xdf}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0xe5, 0x19, 0x55, 0xd7, 0xaa, 0xbd, 0x96, 0x71, 0xab, 0x85, 0x89, 0x8f, 0x1d}; - uint8_t bytesprops1[] = {0x7c, 0xcb, 0x3f, 0x99, 0x8b, 0xb, 0xa4, 0x15, 0x6f, 0xbe, 0x32, 0x79, 0xe0, 0xf6, 0x5b, - 0xcb, 0x9c, 0xea, 0xaa, 0x95, 0xba, 0x99, 0xf1, 0x5f, 0x34, 0xf7, 0xfc, 0xb6, 0x8b}; - uint8_t bytesprops2[] = {0xca, 0x51, 0x45, 0x19, 0x80, 0x83, 0xfe, 0xce, 0x77, 0x17, 0x67}; - uint8_t bytesprops3[] = {0x8e}; - uint8_t bytesprops4[] = {0x29, 0xe8, 0xa1, 0x59, 0x68, 0x8a, 0xcd, 0xac, 0x3a, 0xf, - 0xdd, 0x9, 0x44, 0xee, 0x1d, 0x52, 0x87, 0x21, 0x3c, 0xc8}; - uint8_t bytesprops5[] = {0x2b, 0xec, 0x8b, 0x36, 0x25, 0xaa}; - uint8_t bytesprops6[] = {0x15, 0x23, 0xcb, 0x89, 0x9d, 0x85, 0x29, 0x45, 0x8a, 0x39, 0xa8, 0x8e, 0x1, 0xe4, 0x6d, - 0xdd, 0xc7, 0xd6, 0xf0, 0xf9, 0x97, 0xd7, 0x4a, 0xe9, 0x24, 0x42, 0xbe, 0xa1, 0xb2}; - uint8_t bytesprops8[] = {0x5b, 0xbb, 0x82, 0x4c, 0x4d, 0x55, 0x41, 0x2a, 0x2, - 0xa8, 0x4d, 0x6b, 0xe8, 0x7f, 0x65, 0x91, 0x86, 0x89}; - uint8_t bytesprops7[] = {0xf4, 0x36, 0xb3}; + uint8_t bytesprops0[] = {0xda, 0xb8, 0x1f, 0xb3, 0x4f, 0xb9, 0x75, 0xd0, 0x66, + 0x5e, 0x89, 0xcf, 0x2a, 0xbe, 0x87, 0x9e, 0xf7}; + uint8_t bytesprops1[] = {0xfb, 0x7d, 0x38, 0xdb, 0x64, 0x1f, 0x72, 0xfd, 0xd3}; + uint8_t bytesprops2[] = {0xb0, 0xad, 0x69, 0x5a, 0x7c, 0x5b, 0x9c, 0x13, 0x76, 0xfd, 0x52, 0xbe, 0xff}; + uint8_t bytesprops3[] = {0xe2, 0x17, 0x1, 0xf5, 0xd7, 0xff, 0x3, 0xf1, 0x9b, 0xad, 0xb, 0xd5, 0x31, 0xbe, 0x4}; + uint8_t bytesprops4[] = {0x29, 0xb1, 0x2d, 0x16, 0x48, 0x6e, 0x6c, 0x25, 0xca, 0xb1, 0x1c, 0x49, 0xb7, + 0x91, 0x5f, 0xf5, 0x8c, 0xe2, 0xfa, 0x39, 0x51, 0x53, 0x6, 0x2d, 0x19}; + uint8_t bytesprops6[] = {0xf0, 0x4a, 0x88, 0xe4, 0x8a, 0x2b, 0xf8, 0x85, 0x46, 0xb2, 0x12, 0xa0, 0xee, 0xa4, 0x41, + 0x58, 0x62, 0x1c, 0xf, 0x6c, 0xdf, 0xbd, 0x96, 0x23, 0x69, 0xd, 0x81, 0x69, 0xdf}; + uint8_t bytesprops5[] = {0x78, 0x61, 0xe7, 0x69, 0xc7, 0x24, 0x5e, 0xa7, 0x7b, + 0x25, 0x35, 0xe4, 0x45, 0x10, 0xbc, 0xc6, 0x5c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23515}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2467}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23054}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14963}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26769}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12142}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26062}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 12}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27551}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3405}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops7}, .v = {18, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6947}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops5}, .v = {29, (char*)&bytesprops6}}}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 19085, 19, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 9713, 122, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 19085 19 [PropAuthenticationData "\229\EMU\215\170\189\150q\171\133\137\143\GS",PropContentType -// "|\203?\153\139\v\164\NAKo\190\&2y\224\246[\203\156\234\170\149\186\153\241_4\247\252\182\139",PropTopicAliasMaximum -// 23515,PropResponseTopic "\202QE\EM\128\131\254\206w\ETBg",PropServerKeepAlive 2467,PropMessageExpiryInterval -// 23054,PropWildcardSubscriptionAvailable 68,PropSessionExpiryInterval 14963,PropWillDelayInterval -// 26769,PropRequestProblemInformation 93,PropResponseInformation "\142",PropTopicAliasMaximum -// 12142,PropAuthenticationData ")\232\161Yh\138\205\172:\SI\221\tD\238\GSR\135!<\200",PropSessionExpiryInterval -// 26062,PropSubscriptionIdentifier 1,PropRequestProblemInformation 12,PropResponseInformation -// "+\236\139\&6%\170",PropServerKeepAlive 27551,PropSharedSubscriptionAvailable 176,PropAuthenticationData -// "\NAK#\203\137\157\133)E\138\&9\168\142\SOH\228m\221\199\214\240\249\151\215J\233$B\190\161\178",PropWillDelayInterval -// 3405,PropPayloadFormatIndicator 15,PropUserProperty "\244\&6\179" -// "[\187\130LMUA*\STX\168Mk\232\DELe\145\134\137",PropMaximumPacketSize 6947,PropPayloadFormatIndicator 122]) +// REL (PubREL 9713 122 [PropCorrelationData "\218\184\US\179O\185u\208f^\137\207*\190\135\158\247",PropCorrelationData +// "\251}8\219d\USr\253\211",PropAuthenticationMethod +// "\176\173iZ|[\156\DC3v\253R\190\255",PropRequestResponseInformation 194,PropResponseInformation +// "\226\ETB\SOH\245\215\255\ETX\241\155\173\v\213\&1\190\EOT",PropContentType +// ")\177-\SYNHnl%\202\177\FSI\183\145_\245\140\226\250\&9QS\ACK-\EM",PropWildcardSubscriptionAvailable +// 243,PropUserProperty "xa\231i\199$^\167{%5\228E\DLE\188\198\\" +// "\240J\136\228\138+\248\133F\178\DC2\160\238\164AXb\FS\SIl\223\189\150#i\r\129i\223"]) TEST(PubACKREL5QCTest, Decode18) { - uint8_t pkt[] = {0x62, 0xd9, 0x1, 0x4a, 0x8d, 0x13, 0xd4, 0x1, 0x16, 0x0, 0xd, 0xe5, 0x19, 0x55, 0xd7, 0xaa, 0xbd, - 0x96, 0x71, 0xab, 0x85, 0x89, 0x8f, 0x1d, 0x3, 0x0, 0x1d, 0x7c, 0xcb, 0x3f, 0x99, 0x8b, 0xb, 0xa4, - 0x15, 0x6f, 0xbe, 0x32, 0x79, 0xe0, 0xf6, 0x5b, 0xcb, 0x9c, 0xea, 0xaa, 0x95, 0xba, 0x99, 0xf1, 0x5f, - 0x34, 0xf7, 0xfc, 0xb6, 0x8b, 0x22, 0x5b, 0xdb, 0x8, 0x0, 0xb, 0xca, 0x51, 0x45, 0x19, 0x80, 0x83, - 0xfe, 0xce, 0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0x64, 0x1f, 0x72, 0xfd, 0xd3, 0x15, 0x0, 0xd, 0xb0, 0xad, 0x69, 0x5a, 0x7c, + 0x5b, 0x9c, 0x13, 0x76, 0xfd, 0x52, 0xbe, 0xff, 0x19, 0xc2, 0x1a, 0x0, 0xf, 0xe2, 0x17, 0x1, + 0xf5, 0xd7, 0xff, 0x3, 0xf1, 0x9b, 0xad, 0xb, 0xd5, 0x31, 0xbe, 0x4, 0x3, 0x0, 0x19, 0x29, + 0xb1, 0x2d, 0x16, 0x48, 0x6e, 0x6c, 0x25, 0xca, 0xb1, 0x1c, 0x49, 0xb7, 0x91, 0x5f, 0xf5, 0x8c, + 0xe2, 0xfa, 0x39, 0x51, 0x53, 0x6, 0x2d, 0x19, 0x28, 0xf3, 0x26, 0x0, 0x11, 0x78, 0x61, 0xe7, + 0x69, 0xc7, 0x24, 0x5e, 0xa7, 0x7b, 0x25, 0x35, 0xe4, 0x45, 0x10, 0xbc, 0xc6, 0x5c, 0x0, 0x1d, + 0xf0, 0x4a, 0x88, 0xe4, 0x8a, 0x2b, 0xf8, 0x85, 0x46, 0xb2, 0x12, 0xa0, 0xee, 0xa4, 0x41, 0x58, + 0x62, 0x1c, 0xf, 0x6c, 0xdf, 0xbd, 0x96, 0x23, 0x69, 0xd, 0x81, 0x69, 0xdf}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19085); - EXPECT_EQ(status, 19); -} - -// ACK (PubACK 23245 69 []) -TEST(PubACKACK5QCTest, Encode19) { - uint8_t pkt[] = {0x40, 0x3, 0x5a, 0xcd, 0x45}; + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 9713); + EXPECT_EQ(status, 122); +} + +// REL (PubREL 28230 9 [PropSubscriptionIdentifierAvailable 125,PropMaximumQoS 124,PropResponseTopic +// "\140\169Hh",PropTopicAlias 30053,PropContentType +// "\236\232\241o\154\129\f\149F(\191\CAN\FS\v`\US^<5\177",PropSubscriptionIdentifierAvailable 226,PropUserProperty +// "S\SOH`\NULNl&\181p\244\&3A\213\SIU\GS,\175\251\171\146\238\&9`2" +// "d\169x\EMI]5\144\222\148\185Y\159\253\129\135\173]\252\148",PropUserProperty "\159\179\ENQ\238;\155R" +// ".\245H",PropSubscriptionIdentifier 17,PropReceiveMaximum 12563,PropSharedSubscriptionAvailable +// 182,PropSubscriptionIdentifierAvailable 24,PropRequestProblemInformation 212,PropUserProperty +// "!\221o\163\211D\252\&9ox" "tP\SUB\235\152\SO,'\194\&9\228\134!\190ht\197D\DC2W",PropRequestResponseInformation +// 220,PropResponseInformation "\202I\231\134",PropResponseInformation +// "3\EMr\180V8J6\220\217\DEL,\142I\255J\190\n\175S\140!\STX\158\SOH",PropReceiveMaximum 6076,PropMaximumQoS +// 37,PropWillDelayInterval 9063]) +TEST(PubACKREL5QCTest, Encode19) { + uint8_t pkt[] = { + 0x62, 0xca, 0x1, 0x6e, 0x46, 0x9, 0xc5, 0x1, 0x29, 0x7d, 0x24, 0x7c, 0x8, 0x0, 0x4, 0x8c, 0xa9, 0x48, 0x68, + 0x23, 0x75, 0x65, 0x3, 0x0, 0x14, 0xec, 0xe8, 0xf1, 0x6f, 0x9a, 0x81, 0xc, 0x95, 0x46, 0x28, 0xbf, 0x18, 0x1c, + 0xb, 0x60, 0x1f, 0x5e, 0x3c, 0x35, 0xb1, 0x29, 0xe2, 0x26, 0x0, 0x19, 0x53, 0x1, 0x60, 0x0, 0x4e, 0x6c, 0x26, + 0xb5, 0x70, 0xf4, 0x33, 0x41, 0xd5, 0xf, 0x55, 0x1d, 0x2c, 0xaf, 0xfb, 0xab, 0x92, 0xee, 0x39, 0x60, 0x32, 0x0, + 0x14, 0x64, 0xa9, 0x78, 0x19, 0x49, 0x5d, 0x35, 0x90, 0xde, 0x94, 0xb9, 0x59, 0x9f, 0xfd, 0x81, 0x87, 0xad, 0x5d, + 0xfc, 0x94, 0x26, 0x0, 0x7, 0x9f, 0xb3, 0x5, 0xee, 0x3b, 0x9b, 0x52, 0x0, 0x3, 0x2e, 0xf5, 0x48, 0xb, 0x11, + 0x21, 0x31, 0x13, 0x2a, 0xb6, 0x29, 0x18, 0x17, 0xd4, 0x26, 0x0, 0xa, 0x21, 0xdd, 0x6f, 0xa3, 0xd3, 0x44, 0xfc, + 0x39, 0x6f, 0x78, 0x0, 0x14, 0x74, 0x50, 0x1a, 0xeb, 0x98, 0xe, 0x2c, 0x27, 0xc2, 0x39, 0xe4, 0x86, 0x21, 0xbe, + 0x68, 0x74, 0xc5, 0x44, 0x12, 0x57, 0x19, 0xdc, 0x1a, 0x0, 0x4, 0xca, 0x49, 0xe7, 0x86, 0x1a, 0x0, 0x19, 0x33, + 0x19, 0x72, 0xb4, 0x56, 0x38, 0x4a, 0x36, 0xdc, 0xd9, 0x7f, 0x2c, 0x8e, 0x49, 0xff, 0x4a, 0xbe, 0xa, 0xaf, 0x53, + 0x8c, 0x21, 0x2, 0x9e, 0x1, 0x21, 0x17, 0xbc, 0x24, 0x25, 0x18, 0x0, 0x0, 0x23, 0x67}; uint8_t buf[sizeof(pkt) + 10]; + uint8_t bytesprops0[] = {0x8c, 0xa9, 0x48, 0x68}; + uint8_t bytesprops1[] = {0xec, 0xe8, 0xf1, 0x6f, 0x9a, 0x81, 0xc, 0x95, 0x46, 0x28, + 0xbf, 0x18, 0x1c, 0xb, 0x60, 0x1f, 0x5e, 0x3c, 0x35, 0xb1}; + uint8_t bytesprops3[] = {0x64, 0xa9, 0x78, 0x19, 0x49, 0x5d, 0x35, 0x90, 0xde, 0x94, + 0xb9, 0x59, 0x9f, 0xfd, 0x81, 0x87, 0xad, 0x5d, 0xfc, 0x94}; + uint8_t bytesprops2[] = {0x53, 0x1, 0x60, 0x0, 0x4e, 0x6c, 0x26, 0xb5, 0x70, 0xf4, 0x33, 0x41, 0xd5, + 0xf, 0x55, 0x1d, 0x2c, 0xaf, 0xfb, 0xab, 0x92, 0xee, 0x39, 0x60, 0x32}; + uint8_t bytesprops5[] = {0x2e, 0xf5, 0x48}; + uint8_t bytesprops4[] = {0x9f, 0xb3, 0x5, 0xee, 0x3b, 0x9b, 0x52}; + uint8_t bytesprops7[] = {0x74, 0x50, 0x1a, 0xeb, 0x98, 0xe, 0x2c, 0x27, 0xc2, 0x39, + 0xe4, 0x86, 0x21, 0xbe, 0x68, 0x74, 0xc5, 0x44, 0x12, 0x57}; + uint8_t bytesprops6[] = {0x21, 0xdd, 0x6f, 0xa3, 0xd3, 0x44, 0xfc, 0x39, 0x6f, 0x78}; + uint8_t bytesprops8[] = {0xca, 0x49, 0xe7, 0x86}; + uint8_t bytesprops9[] = {0x33, 0x19, 0x72, 0xb4, 0x56, 0x38, 0x4a, 0x36, 0xdc, 0xd9, 0x7f, 0x2c, 0x8e, + 0x49, 0xff, 0x4a, 0xbe, 0xa, 0xaf, 0x53, 0x8c, 0x21, 0x2, 0x9e, 0x1}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30053}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops2}, .v = {20, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops4}, .v = {3, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12563}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops6}, .v = {20, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6076}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9063}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 23245, 69, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 28230, 9, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 23245 69 []) -TEST(PubACKACK5QCTest, Decode19) { - uint8_t pkt[] = {0x40, 0x3, 0x5a, 0xcd, 0x45}; +// REL (PubREL 28230 9 [PropSubscriptionIdentifierAvailable 125,PropMaximumQoS 124,PropResponseTopic +// "\140\169Hh",PropTopicAlias 30053,PropContentType +// "\236\232\241o\154\129\f\149F(\191\CAN\FS\v`\US^<5\177",PropSubscriptionIdentifierAvailable 226,PropUserProperty +// "S\SOH`\NULNl&\181p\244\&3A\213\SIU\GS,\175\251\171\146\238\&9`2" +// "d\169x\EMI]5\144\222\148\185Y\159\253\129\135\173]\252\148",PropUserProperty "\159\179\ENQ\238;\155R" +// ".\245H",PropSubscriptionIdentifier 17,PropReceiveMaximum 12563,PropSharedSubscriptionAvailable +// 182,PropSubscriptionIdentifierAvailable 24,PropRequestProblemInformation 212,PropUserProperty +// "!\221o\163\211D\252\&9ox" "tP\SUB\235\152\SO,'\194\&9\228\134!\190ht\197D\DC2W",PropRequestResponseInformation +// 220,PropResponseInformation "\202I\231\134",PropResponseInformation +// "3\EMr\180V8J6\220\217\DEL,\142I\255J\190\n\175S\140!\STX\158\SOH",PropReceiveMaximum 6076,PropMaximumQoS +// 37,PropWillDelayInterval 9063]) +TEST(PubACKREL5QCTest, Decode19) { + uint8_t pkt[] = { + 0x62, 0xca, 0x1, 0x6e, 0x46, 0x9, 0xc5, 0x1, 0x29, 0x7d, 0x24, 0x7c, 0x8, 0x0, 0x4, 0x8c, 0xa9, 0x48, 0x68, + 0x23, 0x75, 0x65, 0x3, 0x0, 0x14, 0xec, 0xe8, 0xf1, 0x6f, 0x9a, 0x81, 0xc, 0x95, 0x46, 0x28, 0xbf, 0x18, 0x1c, + 0xb, 0x60, 0x1f, 0x5e, 0x3c, 0x35, 0xb1, 0x29, 0xe2, 0x26, 0x0, 0x19, 0x53, 0x1, 0x60, 0x0, 0x4e, 0x6c, 0x26, + 0xb5, 0x70, 0xf4, 0x33, 0x41, 0xd5, 0xf, 0x55, 0x1d, 0x2c, 0xaf, 0xfb, 0xab, 0x92, 0xee, 0x39, 0x60, 0x32, 0x0, + 0x14, 0x64, 0xa9, 0x78, 0x19, 0x49, 0x5d, 0x35, 0x90, 0xde, 0x94, 0xb9, 0x59, 0x9f, 0xfd, 0x81, 0x87, 0xad, 0x5d, + 0xfc, 0x94, 0x26, 0x0, 0x7, 0x9f, 0xb3, 0x5, 0xee, 0x3b, 0x9b, 0x52, 0x0, 0x3, 0x2e, 0xf5, 0x48, 0xb, 0x11, + 0x21, 0x31, 0x13, 0x2a, 0xb6, 0x29, 0x18, 0x17, 0xd4, 0x26, 0x0, 0xa, 0x21, 0xdd, 0x6f, 0xa3, 0xd3, 0x44, 0xfc, + 0x39, 0x6f, 0x78, 0x0, 0x14, 0x74, 0x50, 0x1a, 0xeb, 0x98, 0xe, 0x2c, 0x27, 0xc2, 0x39, 0xe4, 0x86, 0x21, 0xbe, + 0x68, 0x74, 0xc5, 0x44, 0x12, 0x57, 0x19, 0xdc, 0x1a, 0x0, 0x4, 0xca, 0x49, 0xe7, 0x86, 0x1a, 0x0, 0x19, 0x33, + 0x19, 0x72, 0xb4, 0x56, 0x38, 0x4a, 0x36, 0xdc, 0xd9, 0x7f, 0x2c, 0x8e, 0x49, 0xff, 0x4a, 0xbe, 0xa, 0xaf, 0x53, + 0x8c, 0x21, 0x2, 0x9e, 0x1, 0x21, 0x17, 0xbc, 0x24, 0x25, 0x18, 0x0, 0x0, 0x23, 0x67}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 23245); - EXPECT_EQ(status, 69); -} - -// REL (PubREL 27855 141 [PropServerKeepAlive 19509,PropContentType "m\t\147\154\249\169\\\137V\224\t",PropReasonString -// "J\EMe_\213\196\176\242M4\180\153\246\237\242\fW}\169\246\&5J\151Y",PropReasonString "\216\194'^\203\162#"]) -TEST(PubACKREL5QCTest, Encode20) { - uint8_t pkt[] = {0x62, 0x3a, 0x6c, 0xcf, 0x8d, 0x36, 0x13, 0x4c, 0x35, 0x3, 0x0, 0xb, 0x6d, 0x9, 0x93, - 0x9a, 0xf9, 0xa9, 0x5c, 0x89, 0x56, 0xe0, 0x9, 0x1f, 0x0, 0x18, 0x4a, 0x19, 0x65, 0x5f, - 0xd5, 0xc4, 0xb0, 0xf2, 0x4d, 0x34, 0xb4, 0x99, 0xf6, 0xed, 0xf2, 0xc, 0x57, 0x7d, 0xa9, - 0xf6, 0x35, 0x4a, 0x97, 0x59, 0x1f, 0x0, 0x7, 0xd8, 0xc2, 0x27, 0x5e, 0xcb, 0xa2, 0x23}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 28230); + EXPECT_EQ(status, 9); +} + +// COMP (PubCOMP 19063 157 [PropMessageExpiryInterval 415,PropTopicAlias 12355,PropWildcardSubscriptionAvailable +// 214,PropTopicAliasMaximum 21960,PropContentType "_yx\242\&5\209Sg\156U\244\192\189\238",PropAssignedClientIdentifier +// "0\199Ir\141\SO\217\NUL"]) +TEST(PubACKCOMP5QCTest, Encode20) { + uint8_t pkt[] = {0x70, 0x2d, 0x4a, 0x77, 0x9d, 0x29, 0x2, 0x0, 0x0, 0x1, 0x9f, 0x23, 0x30, 0x43, 0x28, 0xd6, + 0x22, 0x55, 0xc8, 0x3, 0x0, 0xe, 0x5f, 0x79, 0x78, 0xf2, 0x35, 0xd1, 0x53, 0x67, 0x9c, 0x55, + 0xf4, 0xc0, 0xbd, 0xee, 0x12, 0x0, 0x8, 0x30, 0xc7, 0x49, 0x72, 0x8d, 0xe, 0xd9, 0x0}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0x6d, 0x9, 0x93, 0x9a, 0xf9, 0xa9, 0x5c, 0x89, 0x56, 0xe0, 0x9}; - uint8_t bytesprops1[] = {0x4a, 0x19, 0x65, 0x5f, 0xd5, 0xc4, 0xb0, 0xf2, 0x4d, 0x34, 0xb4, 0x99, - 0xf6, 0xed, 0xf2, 0xc, 0x57, 0x7d, 0xa9, 0xf6, 0x35, 0x4a, 0x97, 0x59}; - uint8_t bytesprops2[] = {0xd8, 0xc2, 0x27, 0x5e, 0xcb, 0xa2, 0x23}; + uint8_t bytesprops0[] = {0x5f, 0x79, 0x78, 0xf2, 0x35, 0xd1, 0x53, 0x67, 0x9c, 0x55, 0xf4, 0xc0, 0xbd, 0xee}; + uint8_t bytesprops1[] = {0x30, 0xc7, 0x49, 0x72, 0x8d, 0xe, 0xd9, 0x0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19509}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 415}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12355}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 214}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21960}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 27855, 141, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 19063, 157, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 27855 141 [PropServerKeepAlive 19509,PropContentType "m\t\147\154\249\169\\\137V\224\t",PropReasonString -// "J\EMe_\213\196\176\242M4\180\153\246\237\242\fW}\169\246\&5J\151Y",PropReasonString "\216\194'^\203\162#"]) -TEST(PubACKREL5QCTest, Decode20) { - uint8_t pkt[] = {0x62, 0x3a, 0x6c, 0xcf, 0x8d, 0x36, 0x13, 0x4c, 0x35, 0x3, 0x0, 0xb, 0x6d, 0x9, 0x93, - 0x9a, 0xf9, 0xa9, 0x5c, 0x89, 0x56, 0xe0, 0x9, 0x1f, 0x0, 0x18, 0x4a, 0x19, 0x65, 0x5f, - 0xd5, 0xc4, 0xb0, 0xf2, 0x4d, 0x34, 0xb4, 0x99, 0xf6, 0xed, 0xf2, 0xc, 0x57, 0x7d, 0xa9, - 0xf6, 0x35, 0x4a, 0x97, 0x59, 0x1f, 0x0, 0x7, 0xd8, 0xc2, 0x27, 0x5e, 0xcb, 0xa2, 0x23}; +// COMP (PubCOMP 19063 157 [PropMessageExpiryInterval 415,PropTopicAlias 12355,PropWildcardSubscriptionAvailable +// 214,PropTopicAliasMaximum 21960,PropContentType "_yx\242\&5\209Sg\156U\244\192\189\238",PropAssignedClientIdentifier +// "0\199Ir\141\SO\217\NUL"]) +TEST(PubACKCOMP5QCTest, Decode20) { + uint8_t pkt[] = {0x70, 0x2d, 0x4a, 0x77, 0x9d, 0x29, 0x2, 0x0, 0x0, 0x1, 0x9f, 0x23, 0x30, 0x43, 0x28, 0xd6, + 0x22, 0x55, 0xc8, 0x3, 0x0, 0xe, 0x5f, 0x79, 0x78, 0xf2, 0x35, 0xd1, 0x53, 0x67, 0x9c, 0x55, + 0xf4, 0xc0, 0xbd, 0xee, 0x12, 0x0, 0x8, 0x30, 0xc7, 0x49, 0x72, 0x8d, 0xe, 0xd9, 0x0}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27855); - EXPECT_EQ(status, 141); -} - -// REL (PubREL 3263 165 [PropWillDelayInterval 32544,PropResponseTopic "\137{\DC2\203",PropWillDelayInterval -// 23614,PropUserProperty "\168\DLET\187\239" -// "Mzl\aL~\247-\196\176\128\t\133b\n\139\156\SYN\215$",PropMessageExpiryInterval -// 21151,PropSubscriptionIdentifierAvailable 159,PropServerReference -// "\251p\131\223iH\195\165L*\SO\148\147\163\166aNK4\155?U\DC4j?\EM\245",PropTopicAlias 1847,PropMaximumPacketSize -// 21817,PropSubscriptionIdentifierAvailable 13,PropServerKeepAlive 6055]) -TEST(PubACKREL5QCTest, Encode21) { - uint8_t pkt[] = {0x62, 0x65, 0xc, 0xbf, 0xa5, 0x61, 0x18, 0x0, 0x0, 0x7f, 0x20, 0x8, 0x0, 0x4, 0x89, - 0x7b, 0x12, 0xcb, 0x18, 0x0, 0x0, 0x5c, 0x3e, 0x26, 0x0, 0x5, 0xa8, 0x10, 0x54, 0xbb, - 0xef, 0x0, 0x14, 0x4d, 0x7a, 0x6c, 0x7, 0x4c, 0x7e, 0xf7, 0x2d, 0xc4, 0xb0, 0x80, 0x9, - 0x85, 0x62, 0xa, 0x8b, 0x9c, 0x16, 0xd7, 0x24, 0x2, 0x0, 0x0, 0x52, 0x9f, 0x29, 0x9f, - 0x1c, 0x0, 0x1b, 0xfb, 0x70, 0x83, 0xdf, 0x69, 0x48, 0xc3, 0xa5, 0x4c, 0x2a, 0xe, 0x94, - 0x93, 0xa3, 0xa6, 0x61, 0x4e, 0x4b, 0x34, 0x9b, 0x3f, 0x55, 0x14, 0x6a, 0x3f, 0x19, 0xf5, - 0x23, 0x7, 0x37, 0x27, 0x0, 0x0, 0x55, 0x39, 0x29, 0xd, 0x13, 0x17, 0xa7}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 19063); + EXPECT_EQ(status, 157); +} + +// ACK (PubACK 459 177 [PropAuthenticationData "\146PO",PropRetainAvailable 34,PropContentType +// "Y\186\225\148\168T\b^\173\250\143?\169\166\CAN\DC1\189fQ\DC4Dn\DC2\SIh",PropResponseTopic +// "~2:\251\DLEJ\197@\240g",PropWildcardSubscriptionAvailable 96,PropSubscriptionIdentifier +// 23,PropRequestResponseInformation 91,PropRequestResponseInformation 251,PropAuthenticationMethod +// "\221\140\237{\246u\STX",PropPayloadFormatIndicator 44,PropMaximumPacketSize 26925,PropTopicAliasMaximum +// 769,PropTopicAliasMaximum 5538,PropRetainAvailable 39,PropCorrelationData +// "\254\136O\198\167;r\b\202\157\&0\134\227Nap\181\ETX\195\235p5r\185n\173\f\DC4\215?",PropRetainAvailable +// 141,PropResponseInformation "\n+\"\RSt\143\SOH\241\SOH\240\227^",PropMaximumQoS 108,PropResponseTopic +// "\146\166\162\DC2\173-\216\207m\NUL\221f\240\242\174+ \172\RSm\168"]) +TEST(PubACKACK5QCTest, Encode21) { + uint8_t pkt[] = {0x40, 0xa3, 0x1, 0x1, 0xcb, 0xb1, 0x9e, 0x1, 0x16, 0x0, 0x3, 0x92, 0x50, 0x4f, 0x25, 0x22, 0x3, + 0x0, 0x19, 0x59, 0xba, 0xe1, 0x94, 0xa8, 0x54, 0x8, 0x5e, 0xad, 0xfa, 0x8f, 0x3f, 0xa9, 0xa6, 0x18, + 0x11, 0xbd, 0x66, 0x51, 0x14, 0x44, 0x6e, 0x12, 0xf, 0x68, 0x8, 0x0, 0xa, 0x7e, 0x32, 0x3a, 0xfb, + 0x10, 0x4a, 0xc5, 0x40, 0xf0, 0x67, 0x28, 0x60, 0xb, 0x17, 0x19, 0x5b, 0x19, 0xfb, 0x15, 0x0, 0x7, + 0xdd, 0x8c, 0xed, 0x7b, 0xf6, 0x75, 0x2, 0x1, 0x2c, 0x27, 0x0, 0x0, 0x69, 0x2d, 0x22, 0x3, 0x1, + 0x22, 0x15, 0xa2, 0x25, 0x27, 0x9, 0x0, 0x1e, 0xfe, 0x88, 0x4f, 0xc6, 0xa7, 0x3b, 0x72, 0x8, 0xca, + 0x9d, 0x30, 0x86, 0xe3, 0x4e, 0x61, 0x70, 0xb5, 0x3, 0xc3, 0xeb, 0x70, 0x35, 0x72, 0xb9, 0x6e, 0xad, + 0xc, 0x14, 0xd7, 0x3f, 0x25, 0x8d, 0x1a, 0x0, 0xc, 0xa, 0x2b, 0x22, 0x1e, 0x74, 0x8f, 0x1, 0xf1, + 0x1, 0xf0, 0xe3, 0x5e, 0x24, 0x6c, 0x8, 0x0, 0x15, 0x92, 0xa6, 0xa2, 0x12, 0xad, 0x2d, 0xd8, 0xcf, + 0x6d, 0x0, 0xdd, 0x66, 0xf0, 0xf2, 0xae, 0x2b, 0x20, 0xac, 0x1e, 0x6d, 0xa8}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0x89, 0x7b, 0x12, 0xcb}; - uint8_t bytesprops2[] = {0x4d, 0x7a, 0x6c, 0x7, 0x4c, 0x7e, 0xf7, 0x2d, 0xc4, 0xb0, - 0x80, 0x9, 0x85, 0x62, 0xa, 0x8b, 0x9c, 0x16, 0xd7, 0x24}; - uint8_t bytesprops1[] = {0xa8, 0x10, 0x54, 0xbb, 0xef}; - uint8_t bytesprops3[] = {0xfb, 0x70, 0x83, 0xdf, 0x69, 0x48, 0xc3, 0xa5, 0x4c, 0x2a, 0xe, 0x94, 0x93, 0xa3, - 0xa6, 0x61, 0x4e, 0x4b, 0x34, 0x9b, 0x3f, 0x55, 0x14, 0x6a, 0x3f, 0x19, 0xf5}; + uint8_t bytesprops0[] = {0x92, 0x50, 0x4f}; + uint8_t bytesprops1[] = {0x59, 0xba, 0xe1, 0x94, 0xa8, 0x54, 0x8, 0x5e, 0xad, 0xfa, 0x8f, 0x3f, 0xa9, + 0xa6, 0x18, 0x11, 0xbd, 0x66, 0x51, 0x14, 0x44, 0x6e, 0x12, 0xf, 0x68}; + uint8_t bytesprops2[] = {0x7e, 0x32, 0x3a, 0xfb, 0x10, 0x4a, 0xc5, 0x40, 0xf0, 0x67}; + uint8_t bytesprops3[] = {0xdd, 0x8c, 0xed, 0x7b, 0xf6, 0x75, 0x2}; + uint8_t bytesprops4[] = {0xfe, 0x88, 0x4f, 0xc6, 0xa7, 0x3b, 0x72, 0x8, 0xca, 0x9d, 0x30, 0x86, 0xe3, 0x4e, 0x61, + 0x70, 0xb5, 0x3, 0xc3, 0xeb, 0x70, 0x35, 0x72, 0xb9, 0x6e, 0xad, 0xc, 0x14, 0xd7, 0x3f}; + uint8_t bytesprops5[] = {0xa, 0x2b, 0x22, 0x1e, 0x74, 0x8f, 0x1, 0xf1, 0x1, 0xf0, 0xe3, 0x5e}; + uint8_t bytesprops6[] = {0x92, 0xa6, 0xa2, 0x12, 0xad, 0x2d, 0xd8, 0xcf, 0x6d, 0x0, 0xdd, + 0x66, 0xf0, 0xf2, 0xae, 0x2b, 0x20, 0xac, 0x1e, 0x6d, 0xa8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32544}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 23614}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {5, (char*)&bytesprops1}, .v = {20, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21151}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1847}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21817}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6055}}, - }; - - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 44}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26925}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 769}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5538}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops6}}}, + }; + + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 3263, 165, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 459, 177, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 3263 165 [PropWillDelayInterval 32544,PropResponseTopic "\137{\DC2\203",PropWillDelayInterval -// 23614,PropUserProperty "\168\DLET\187\239" -// "Mzl\aL~\247-\196\176\128\t\133b\n\139\156\SYN\215$",PropMessageExpiryInterval -// 21151,PropSubscriptionIdentifierAvailable 159,PropServerReference -// "\251p\131\223iH\195\165L*\SO\148\147\163\166aNK4\155?U\DC4j?\EM\245",PropTopicAlias 1847,PropMaximumPacketSize -// 21817,PropSubscriptionIdentifierAvailable 13,PropServerKeepAlive 6055]) -TEST(PubACKREL5QCTest, Decode21) { - uint8_t pkt[] = {0x62, 0x65, 0xc, 0xbf, 0xa5, 0x61, 0x18, 0x0, 0x0, 0x7f, 0x20, 0x8, 0x0, 0x4, 0x89, - 0x7b, 0x12, 0xcb, 0x18, 0x0, 0x0, 0x5c, 0x3e, 0x26, 0x0, 0x5, 0xa8, 0x10, 0x54, 0xbb, - 0xef, 0x0, 0x14, 0x4d, 0x7a, 0x6c, 0x7, 0x4c, 0x7e, 0xf7, 0x2d, 0xc4, 0xb0, 0x80, 0x9, - 0x85, 0x62, 0xa, 0x8b, 0x9c, 0x16, 0xd7, 0x24, 0x2, 0x0, 0x0, 0x52, 0x9f, 0x29, 0x9f, - 0x1c, 0x0, 0x1b, 0xfb, 0x70, 0x83, 0xdf, 0x69, 0x48, 0xc3, 0xa5, 0x4c, 0x2a, 0xe, 0x94, - 0x93, 0xa3, 0xa6, 0x61, 0x4e, 0x4b, 0x34, 0x9b, 0x3f, 0x55, 0x14, 0x6a, 0x3f, 0x19, 0xf5, - 0x23, 0x7, 0x37, 0x27, 0x0, 0x0, 0x55, 0x39, 0x29, 0xd, 0x13, 0x17, 0xa7}; +// ACK (PubACK 459 177 [PropAuthenticationData "\146PO",PropRetainAvailable 34,PropContentType +// "Y\186\225\148\168T\b^\173\250\143?\169\166\CAN\DC1\189fQ\DC4Dn\DC2\SIh",PropResponseTopic +// "~2:\251\DLEJ\197@\240g",PropWildcardSubscriptionAvailable 96,PropSubscriptionIdentifier +// 23,PropRequestResponseInformation 91,PropRequestResponseInformation 251,PropAuthenticationMethod +// "\221\140\237{\246u\STX",PropPayloadFormatIndicator 44,PropMaximumPacketSize 26925,PropTopicAliasMaximum +// 769,PropTopicAliasMaximum 5538,PropRetainAvailable 39,PropCorrelationData +// "\254\136O\198\167;r\b\202\157\&0\134\227Nap\181\ETX\195\235p5r\185n\173\f\DC4\215?",PropRetainAvailable +// 141,PropResponseInformation "\n+\"\RSt\143\SOH\241\SOH\240\227^",PropMaximumQoS 108,PropResponseTopic +// "\146\166\162\DC2\173-\216\207m\NUL\221f\240\242\174+ \172\RSm\168"]) +TEST(PubACKACK5QCTest, Decode21) { + uint8_t pkt[] = {0x40, 0xa3, 0x1, 0x1, 0xcb, 0xb1, 0x9e, 0x1, 0x16, 0x0, 0x3, 0x92, 0x50, 0x4f, 0x25, 0x22, 0x3, + 0x0, 0x19, 0x59, 0xba, 0xe1, 0x94, 0xa8, 0x54, 0x8, 0x5e, 0xad, 0xfa, 0x8f, 0x3f, 0xa9, 0xa6, 0x18, + 0x11, 0xbd, 0x66, 0x51, 0x14, 0x44, 0x6e, 0x12, 0xf, 0x68, 0x8, 0x0, 0xa, 0x7e, 0x32, 0x3a, 0xfb, + 0x10, 0x4a, 0xc5, 0x40, 0xf0, 0x67, 0x28, 0x60, 0xb, 0x17, 0x19, 0x5b, 0x19, 0xfb, 0x15, 0x0, 0x7, + 0xdd, 0x8c, 0xed, 0x7b, 0xf6, 0x75, 0x2, 0x1, 0x2c, 0x27, 0x0, 0x0, 0x69, 0x2d, 0x22, 0x3, 0x1, + 0x22, 0x15, 0xa2, 0x25, 0x27, 0x9, 0x0, 0x1e, 0xfe, 0x88, 0x4f, 0xc6, 0xa7, 0x3b, 0x72, 0x8, 0xca, + 0x9d, 0x30, 0x86, 0xe3, 0x4e, 0x61, 0x70, 0xb5, 0x3, 0xc3, 0xeb, 0x70, 0x35, 0x72, 0xb9, 0x6e, 0xad, + 0xc, 0x14, 0xd7, 0x3f, 0x25, 0x8d, 0x1a, 0x0, 0xc, 0xa, 0x2b, 0x22, 0x1e, 0x74, 0x8f, 0x1, 0xf1, + 0x1, 0xf0, 0xe3, 0x5e, 0x24, 0x6c, 0x8, 0x0, 0x15, 0x92, 0xa6, 0xa2, 0x12, 0xad, 0x2d, 0xd8, 0xcf, + 0x6d, 0x0, 0xdd, 0x66, 0xf0, 0xf2, 0xae, 0x2b, 0x20, 0xac, 0x1e, 0x6d, 0xa8}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 3263); - EXPECT_EQ(status, 165); -} - -// ACK (PubACK 4790 175 [PropMaximumQoS 117,PropReasonString -// "\181\DLE\138gK<\208\137\191(\b\171J\248",PropPayloadFormatIndicator 127,PropReasonString -// "\230\227T'",PropAssignedClientIdentifier "\151\246<",PropPayloadFormatIndicator 43,PropRequestResponseInformation -// 68,PropSharedSubscriptionAvailable 86,PropResponseInformation -// "\DC46\138\142\169^\ACKI\169#\158",PropTopicAliasMaximum 10914,PropMaximumPacketSize 27768,PropPayloadFormatIndicator -// 121,PropAuthenticationMethod "\244+",PropMaximumPacketSize 10461,PropPayloadFormatIndicator 40,PropUserProperty -// "\135\n\128\&5\253Q)\189\252\183\149&\146\180\226\254b\181\208B\NUL" -// "\151\230\165\&8\149Z\152\165\182\DC4\175\ETB\247\223Wd\DC3m8\250a&\DC2\147\t6%0jF",PropMessageExpiryInterval -// 8278,PropUserProperty "\211\NUL\164[_,\164\136\254)\178=@\t!MY\243\139j\210F\225}" -// "\164\213\&7M/\212\193\163\164M0\234\145jIi\128\240\178\170\143\SOB\157W\EM",PropUserProperty -// "\DEL\n\198\185\NUL\DEL\217,\234\203\152#" -// "g\NUL\242\ETX\v\255\DC1\220<\235\175\FS\150f\FS\247",PropRequestResponseInformation 215,PropReceiveMaximum -// 27875,PropServerReference -// "{;`\241\188\ACK\229\155\&4H\189\DC4X\199\175\b\157\184\253\&5\141\231\152\142\145\212\211\&6",PropCorrelationData -// "\130@\234U\232\223l\179\185",PropAssignedClientIdentifier -// "[\193A\ENQz#\251\201\179:\213Z\161\ESC7M\SI\193%&",PropAssignedClientIdentifier -// ">\216\141E\166(\SO\172\128\151",PropMessageExpiryInterval 31417,PropMessageExpiryInterval -// 10052,PropWillDelayInterval 26979]) -TEST(PubACKACK5QCTest, Encode22) { - uint8_t pkt[] = { - 0x40, 0xc9, 0x2, 0x12, 0xb6, 0xaf, 0xc4, 0x2, 0x24, 0x75, 0x1f, 0x0, 0xe, 0xb5, 0x10, 0x8a, 0x67, 0x4b, 0x3c, - 0xd0, 0x89, 0xbf, 0x28, 0x8, 0xab, 0x4a, 0xf8, 0x1, 0x7f, 0x1f, 0x0, 0x4, 0xe6, 0xe3, 0x54, 0x27, 0x12, 0x0, - 0x3, 0x97, 0xf6, 0x3c, 0x1, 0x2b, 0x19, 0x44, 0x2a, 0x56, 0x1a, 0x0, 0xb, 0x14, 0x36, 0x8a, 0x8e, 0xa9, 0x5e, - 0x6, 0x49, 0xa9, 0x23, 0x9e, 0x22, 0x2a, 0xa2, 0x27, 0x0, 0x0, 0x6c, 0x78, 0x1, 0x79, 0x15, 0x0, 0x2, 0xf4, - 0x2b, 0x27, 0x0, 0x0, 0x28, 0xdd, 0x1, 0x28, 0x26, 0x0, 0x15, 0x87, 0xa, 0x80, 0x35, 0xfd, 0x51, 0x29, 0xbd, - 0xfc, 0xb7, 0x95, 0x26, 0x92, 0xb4, 0xe2, 0xfe, 0x62, 0xb5, 0xd0, 0x42, 0x0, 0x0, 0x1e, 0x97, 0xe6, 0xa5, 0x38, - 0x95, 0x5a, 0x98, 0xa5, 0xb6, 0x14, 0xaf, 0x17, 0xf7, 0xdf, 0x57, 0x64, 0x13, 0x6d, 0x38, 0xfa, 0x61, 0x26, 0x12,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x2, 0x0, 0x0, 0x7a, 0xb9, 0x2, - 0x0, 0x0, 0x27, 0x44, 0x18, 0x0, 0x0, 0x69, 0x63}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 459); + EXPECT_EQ(status, 177); +} + +// REC (PubREC 21707 53 [PropAuthenticationData +// "X0\169\193\138\EOT\159M\207\209\187\219\149_\239\229|CU\200\255",PropRetainAvailable 123,PropSubscriptionIdentifier +// 24,PropContentType "\157\168\221K\148\251+\201O\239\DLE\217\141\239\SOH",PropSubscriptionIdentifier +// 36,PropAuthenticationData "\233QF\142r\154\211\128\193",PropServerKeepAlive 2597,PropWillDelayInterval +// 21425,PropResponseTopic +// "\254zyD\226\185\216\221~\235\219\191\219\181n\vd:f\171\FSb;\172",PropRequestResponseInformation +// 142,PropAuthenticationData "\n\NAK\195\154\252\145}\237\SI\186Z\183t\DC3\DC4",PropTopicAliasMaximum +// 16617,PropTopicAliasMaximum 26577,PropRetainAvailable 90,PropPayloadFormatIndicator 174,PropReceiveMaximum +// 15007,PropRequestProblemInformation 46,PropResponseInformation "2h\236",PropRetainAvailable 94]) +TEST(PubACKREC5QCTest, Encode22) { + uint8_t pkt[] = {0x50, 0x8f, 0x1, 0x54, 0xcb, 0x35, 0x8a, 0x1, 0x16, 0x0, 0x15, 0x58, 0x30, 0xa9, 0xc1, 0x8a, 0x4, + 0x9f, 0x4d, 0xcf, 0xd1, 0xbb, 0xdb, 0x95, 0x5f, 0xef, 0xe5, 0x7c, 0x43, 0x55, 0xc8, 0xff, 0x25, 0x7b, + 0xb, 0x18, 0x3, 0x0, 0xf, 0x9d, 0xa8, 0xdd, 0x4b, 0x94, 0xfb, 0x2b, 0xc9, 0x4f, 0xef, 0x10, 0xd9, + 0x8d, 0xef, 0x1, 0xb, 0x24, 0x16, 0x0, 0x9, 0xe9, 0x51, 0x46, 0x8e, 0x72, 0x9a, 0xd3, 0x80, 0xc1, + 0x13, 0xa, 0x25, 0x18, 0x0, 0x0, 0x53, 0xb1, 0x8, 0x0, 0x18, 0xfe, 0x7a, 0x79, 0x44, 0xe2, 0xb9, + 0xd8, 0xdd, 0x7e, 0xeb, 0xdb, 0xbf, 0xdb, 0xb5, 0x6e, 0xb, 0x64, 0x3a, 0x66, 0xab, 0x1c, 0x62, 0x3b, + 0xac, 0x19, 0x8e, 0x16, 0x0, 0xf, 0xa, 0x15, 0xc3, 0x9a, 0xfc, 0x91, 0x7d, 0xed, 0xf, 0xba, 0x5a, + 0xb7, 0x74, 0x13, 0x14, 0x22, 0x40, 0xe9, 0x22, 0x67, 0xd1, 0x25, 0x5a, 0x1, 0xae, 0x21, 0x3a, 0x9f, + 0x17, 0x2e, 0x1a, 0x0, 0x3, 0x32, 0x68, 0xec, 0x25, 0x5e}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0xb5, 0x10, 0x8a, 0x67, 0x4b, 0x3c, 0xd0, 0x89, 0xbf, 0x28, 0x8, 0xab, 0x4a, 0xf8}; - uint8_t bytesprops1[] = {0xe6, 0xe3, 0x54, 0x27}; - uint8_t bytesprops2[] = {0x97, 0xf6, 0x3c}; - uint8_t bytesprops3[] = {0x14, 0x36, 0x8a, 0x8e, 0xa9, 0x5e, 0x6, 0x49, 0xa9, 0x23, 0x9e}; - uint8_t bytesprops4[] = {0xf4, 0x2b}; - uint8_t bytesprops6[] = {0x97, 0xe6, 0xa5, 0x38, 0x95, 0x5a, 0x98, 0xa5, 0xb6, 0x14, 0xaf, 0x17, 0xf7, 0xdf, 0x57, - 0x64, 0x13, 0x6d, 0x38, 0xfa, 0x61, 0x26, 0x12, 0x93, 0x9, 0x36, 0x25, 0x30, 0x6a, 0x46}; - uint8_t bytesprops5[] = {0x87, 0xa, 0x80, 0x35, 0xfd, 0x51, 0x29, 0xbd, 0xfc, 0xb7, 0x95, - 0x26, 0x92, 0xb4, 0xe2, 0xfe, 0x62, 0xb5, 0xd0, 0x42, 0x0}; - uint8_t bytesprops8[] = {0xa4, 0xd5, 0x37, 0x4d, 0x2f, 0xd4, 0xc1, 0xa3, 0xa4, 0x4d, 0x30, 0xea, 0x91, - 0x6a, 0x49, 0x69, 0x80, 0xf0, 0xb2, 0xaa, 0x8f, 0xe, 0x42, 0x9d, 0x57, 0x19}; - uint8_t bytesprops7[] = {0xd3, 0x0, 0xa4, 0x5b, 0x5f, 0x2c, 0xa4, 0x88, 0xfe, 0x29, 0xb2, 0x3d, - 0x40, 0x9, 0x21, 0x4d, 0x59, 0xf3, 0x8b, 0x6a, 0xd2, 0x46, 0xe1, 0x7d}; - uint8_t bytesprops10[] = {0x67, 0x0, 0xf2, 0x3, 0xb, 0xff, 0x11, 0xdc, - 0x3c, 0xeb, 0xaf, 0x1c, 0x96, 0x66, 0x1c, 0xf7}; - uint8_t bytesprops9[] = {0x7f, 0xa, 0xc6, 0xb9, 0x0, 0x7f, 0xd9, 0x2c, 0xea, 0xcb, 0x98, 0x23}; - uint8_t bytesprops11[] = {0x7b, 0x3b, 0x60, 0xf1, 0xbc, 0x6, 0xe5, 0x9b, 0x34, 0x48, 0xbd, 0x14, 0x58, 0xc7, - 0xaf, 0x8, 0x9d, 0xb8, 0xfd, 0x35, 0x8d, 0xe7, 0x98, 0x8e, 0x91, 0xd4, 0xd3, 0x36}; - uint8_t bytesprops12[] = {0x82, 0x40, 0xea, 0x55, 0xe8, 0xdf, 0x6c, 0xb3, 0xb9}; - uint8_t bytesprops13[] = {0x5b, 0xc1, 0x41, 0x5, 0x7a, 0x23, 0xfb, 0xc9, 0xb3, 0x3a, - 0xd5, 0x5a, 0xa1, 0x1b, 0x37, 0x4d, 0xf, 0xc1, 0x25, 0x26}; - uint8_t bytesprops14[] = {0x3e, 0xd8, 0x8d, 0x45, 0xa6, 0x28, 0xe, 0xac, 0x80, 0x97}; + uint8_t bytesprops0[] = {0x58, 0x30, 0xa9, 0xc1, 0x8a, 0x4, 0x9f, 0x4d, 0xcf, 0xd1, 0xbb, + 0xdb, 0x95, 0x5f, 0xef, 0xe5, 0x7c, 0x43, 0x55, 0xc8, 0xff}; + uint8_t bytesprops1[] = {0x9d, 0xa8, 0xdd, 0x4b, 0x94, 0xfb, 0x2b, 0xc9, 0x4f, 0xef, 0x10, 0xd9, 0x8d, 0xef, 0x1}; + uint8_t bytesprops2[] = {0xe9, 0x51, 0x46, 0x8e, 0x72, 0x9a, 0xd3, 0x80, 0xc1}; + uint8_t bytesprops3[] = {0xfe, 0x7a, 0x79, 0x44, 0xe2, 0xb9, 0xd8, 0xdd, 0x7e, 0xeb, 0xdb, 0xbf, + 0xdb, 0xb5, 0x6e, 0xb, 0x64, 0x3a, 0x66, 0xab, 0x1c, 0x62, 0x3b, 0xac}; + uint8_t bytesprops4[] = {0xa, 0x15, 0xc3, 0x9a, 0xfc, 0x91, 0x7d, 0xed, 0xf, 0xba, 0x5a, 0xb7, 0x74, 0x13, 0x14}; + uint8_t bytesprops5[] = {0x32, 0x68, 0xec}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 117}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10914}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27768}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10461}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops5}, .v = {30, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8278}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops7}, .v = {26, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops9}, .v = {16, (char*)&bytesprops10}}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27875}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31417}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10052}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26979}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 36}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2597}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21425}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16617}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26577}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 174}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15007}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 46}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 94}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 4790, 175, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, 0, 21707, 53, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 4790 175 [PropMaximumQoS 117,PropReasonString -// "\181\DLE\138gK<\208\137\191(\b\171J\248",PropPayloadFormatIndicator 127,PropReasonString -// "\230\227T'",PropAssignedClientIdentifier "\151\246<",PropPayloadFormatIndicator 43,PropRequestResponseInformation -// 68,PropSharedSubscriptionAvailable 86,PropResponseInformation -// "\DC46\138\142\169^\ACKI\169#\158",PropTopicAliasMaximum 10914,PropMaximumPacketSize 27768,PropPayloadFormatIndicator -// 121,PropAuthenticationMethod "\244+",PropMaximumPacketSize 10461,PropPayloadFormatIndicator 40,PropUserProperty -// "\135\n\128\&5\253Q)\189\252\183\149&\146\180\226\254b\181\208B\NUL" -// "\151\230\165\&8\149Z\152\165\182\DC4\175\ETB\247\223Wd\DC3m8\250a&\DC2\147\t6%0jF",PropMessageExpiryInterval -// 8278,PropUserProperty "\211\NUL\164[_,\164\136\254)\178=@\t!MY\243\139j\210F\225}" -// "\164\213\&7M/\212\193\163\164M0\234\145jIi\128\240\178\170\143\SOB\157W\EM",PropUserProperty -// "\DEL\n\198\185\NUL\DEL\217,\234\203\152#" -// "g\NUL\242\ETX\v\255\DC1\220<\235\175\FS\150f\FS\247",PropRequestResponseInformation 215,PropReceiveMaximum -// 27875,PropServerReference -// "{;`\241\188\ACK\229\155\&4H\189\DC4X\199\175\b\157\184\253\&5\141\231\152\142\145\212\211\&6",PropCorrelationData -// "\130@\234U\232\223l\179\185",PropAssignedClientIdentifier -// "[\193A\ENQz#\251\201\179:\213Z\161\ESC7M\SI\193%&",PropAssignedClientIdentifier -// ">\216\141E\166(\SO\172\128\151",PropMessageExpiryInterval 31417,PropMessageExpiryInterval -// 10052,PropWillDelayInterval 26979]) -TEST(PubACKACK5QCTest, Decode22) { - uint8_t pkt[] = { - 0x40, 0xc9, 0x2, 0x12, 0xb6, 0xaf, 0xc4, 0x2, 0x24, 0x75, 0x1f, 0x0, 0xe, 0xb5, 0x10, 0x8a, 0x67, 0x4b, 0x3c, - 0xd0, 0x89, 0xbf, 0x28, 0x8, 0xab, 0x4a, 0xf8, 0x1, 0x7f, 0x1f, 0x0, 0x4, 0xe6, 0xe3, 0x54, 0x27, 0x12, 0x0, - 0x3, 0x97, 0xf6, 0x3c, 0x1, 0x2b, 0x19, 0x44, 0x2a, 0x56, 0x1a, 0x0, 0xb, 0x14, 0x36, 0x8a, 0x8e, 0xa9, 0x5e, - 0x6, 0x49, 0xa9, 0x23, 0x9e, 0x22, 0x2a, 0xa2, 0x27, 0x0, 0x0, 0x6c, 0x78, 0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0x8, 0x9d, 0xb8, 0xfd, 0x35, 0x8d, 0xe7, 0x98, 0x8e, 0x91, - 0xd4, 0xd3, 0x36, 0x9, 0x0, 0x9, 0x82, 0x40, 0xea, 0x55, 0xe8, 0xdf, 0x6c, 0xb3, 0xb9, 0x12, 0x0, 0x14, 0x5b, - 0xc1, 0x41, 0x5, 0x7a, 0x23, 0xfb, 0xc9, 0xb3, 0x3a, 0xd5, 0x5a, 0xa1, 0x1b, 0x37, 0x4d, 0xf, 0xc1, 0x25, 0x26, - 0x12, 0x0, 0xa, 0x3e, 0xd8, 0x8d, 0x45, 0xa6, 0x28, 0xe, 0xac, 0x80, 0x97, 0x2, 0x0, 0x0, 0x7a, 0xb9, 0x2, - 0x0, 0x0, 0x27, 0x44, 0x18, 0x0, 0x0, 0x69, 0x63}; +// REC (PubREC 21707 53 [PropAuthenticationData +// "X0\169\193\138\EOT\159M\207\209\187\219\149_\239\229|CU\200\255",PropRetainAvailable 123,PropSubscriptionIdentifier +// 24,PropContentType "\157\168\221K\148\251+\201O\239\DLE\217\141\239\SOH",PropSubscriptionIdentifier +// 36,PropAuthenticationData "\233QF\142r\154\211\128\193",PropServerKeepAlive 2597,PropWillDelayInterval +// 21425,PropResponseTopic +// "\254zyD\226\185\216\221~\235\219\191\219\181n\vd:f\171\FSb;\172",PropRequestResponseInformation +// 142,PropAuthenticationData "\n\NAK\195\154\252\145}\237\SI\186Z\183t\DC3\DC4",PropTopicAliasMaximum +// 16617,PropTopicAliasMaximum 26577,PropRetainAvailable 90,PropPayloadFormatIndicator 174,PropReceiveMaximum +// 15007,PropRequestProblemInformation 46,PropResponseInformation "2h\236",PropRetainAvailable 94]) +TEST(PubACKREC5QCTest, Decode22) { + uint8_t pkt[] = {0x50, 0x8f, 0x1, 0x54, 0xcb, 0x35, 0x8a, 0x1, 0x16, 0x0, 0x15, 0x58, 0x30, 0xa9, 0xc1, 0x8a, 0x4, + 0x9f, 0x4d, 0xcf, 0xd1, 0xbb, 0xdb, 0x95, 0x5f, 0xef, 0xe5, 0x7c, 0x43, 0x55, 0xc8, 0xff, 0x25, 0x7b, + 0xb, 0x18, 0x3, 0x0, 0xf, 0x9d, 0xa8, 0xdd, 0x4b, 0x94, 0xfb, 0x2b, 0xc9, 0x4f, 0xef, 0x10, 0xd9, + 0x8d, 0xef, 0x1, 0xb, 0x24, 0x16, 0x0, 0x9, 0xe9, 0x51, 0x46, 0x8e, 0x72, 0x9a, 0xd3, 0x80, 0xc1, + 0x13, 0xa, 0x25, 0x18, 0x0, 0x0, 0x53, 0xb1, 0x8, 0x0, 0x18, 0xfe, 0x7a, 0x79, 0x44, 0xe2, 0xb9, + 0xd8, 0xdd, 0x7e, 0xeb, 0xdb, 0xbf, 0xdb, 0xb5, 0x6e, 0xb, 0x64, 0x3a, 0x66, 0xab, 0x1c, 0x62, 0x3b, + 0xac, 0x19, 0x8e, 0x16, 0x0, 0xf, 0xa, 0x15, 0xc3, 0x9a, 0xfc, 0x91, 0x7d, 0xed, 0xf, 0xba, 0x5a, + 0xb7, 0x74, 0x13, 0x14, 0x22, 0x40, 0xe9, 0x22, 0x67, 0xd1, 0x25, 0x5a, 0x1, 0xae, 0x21, 0x3a, 0x9f, + 0x17, 0x2e, 0x1a, 0x0, 0x3, 0x32, 0x68, 0xec, 0x25, 0x5e}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4790); - EXPECT_EQ(status, 175); -} - -// REL (PubREL 7224 239 [PropResponseInformation "\199[\249",PropServerReference -// "\f\DC3{(\200Z\154\ETBc\215\216\169A8\170\183\DC1\159\209\139\&0[\242\230\143m\242\&2",PropContentType -// "\196~\ESC",PropAuthenticationMethod "\152\&4P\136",PropSessionExpiryInterval 6962,PropWildcardSubscriptionAvailable -// 7,PropPayloadFormatIndicator 79,PropCorrelationData -// "\181\187\SOH\157\180\183m9x\137m\164\166\SUB\248\207D\186\140\162\183\&4\247\158\n\b",PropResponseInformation -// "{\DEL\245\EOT\240!\196\177h\146\SI\203a\CAN\231{G8\231\237wu8\186qq \RS",PropMessageExpiryInterval -// 188,PropTopicAlias 5684,PropSubscriptionIdentifier 3,PropServerReference -// "!L\185\237e\229\213\200\179",PropContentType "\GS\231\156T",PropTopicAliasMaximum 19004,PropMessageExpiryInterval -// 5773,PropRequestResponseInformation 61,PropMessageExpiryInterval 32275,PropTopicAliasMaximum -// 15152,PropSessionExpiryInterval 17393,PropRequestProblemInformation 50,PropSessionExpiryInterval 1871,PropMaximumQoS -// 106,PropAuthenticationMethod "!\SI\DC2L\160\240\215>=\221dyqs\158y\177",PropReasonString -// ")\166Rt\207\180[\215Mt\f\205\138\SOH-T\ACK\196ee\222H]\177\215\175~\193\198",PropSessionExpiryInterval -// 16563,PropSessionExpiryInterval 29528,PropContentType "B\163\DC4/\177q;@? \146{\144"]) -TEST(PubACKREL5QCTest, Encode23) { - uint8_t pkt[] = { - 0x62, 0x87, 0x2, 0x1c, 0x38, 0xef, 0x82, 0x2, 0x1a, 0x0, 0x3, 0xc7, 0x5b, 0xf9, 0x1c, 0x0, 0x1c, 0xc, 0x13, - 0x7b, 0x28, 0xc8, 0x5a, 0x9a, 0x17, 0x63, 0xd7, 0xd8, 0xa9, 0x41, 0x38, 0xaa, 0xb7, 0x11, 0x9f, 0xd1, 0x8b, 0x30, - 0x5b, 0xf2, 0xe6, 0x8f, 0x6d, 0xf2, 0x32, 0x3, 0x0, 0x3, 0xc4, 0x7e, 0x1b, 0x15, 0x0, 0x4, 0x98, 0x34, 0x50, - 0x88, 0x11, 0x0, 0x0, 0x1b, 0x32, 0x28, 0x7, 0x1, 0x4f, 0x9, 0x0, 0x1a, 0xb5, 0xbb, 0x1, 0x9d, 0xb4, 0xb7, - 0x6d, 0x39, 0x78, 0x89, 0x6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ode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 21707); + EXPECT_EQ(status, 53); +} + +// COMP (PubCOMP 29287 222 [PropWildcardSubscriptionAvailable 71,PropPayloadFormatIndicator 233,PropTopicAliasMaximum +// 9323,PropPayloadFormatIndicator 12,PropAssignedClientIdentifier "x\DEL\166#\221\229\RS\EOT\175x",PropRetainAvailable +// 69,PropAuthenticationMethod "\192=\220K\ENQ\234\161\246"]) +TEST(PubACKCOMP5QCTest, Encode23) { + uint8_t pkt[] = {0x70, 0x27, 0x72, 0x67, 0xde, 0x23, 0x28, 0x47, 0x1, 0xe9, 0x22, 0x24, 0x6b, 0x1, + 0xc, 0x12, 0x0, 0xa, 0x78, 0x7f, 0xa6, 0x23, 0xdd, 0xe5, 0x1e, 0x4, 0xaf, 0x78, + 0x25, 0x45, 0x15, 0x0, 0x8, 0xc0, 0x3d, 0xdc, 0x4b, 0x5, 0xea, 0xa1, 0xf6}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0xc7, 0x5b, 0xf9}; - uint8_t bytesprops1[] = {0xc, 0x13, 0x7b, 0x28, 0xc8, 0x5a, 0x9a, 0x17, 0x63, 0xd7, 0xd8, 0xa9, 0x41, 0x38, - 0xaa, 0xb7, 0x11, 0x9f, 0xd1, 0x8b, 0x30, 0x5b, 0xf2, 0xe6, 0x8f, 0x6d, 0xf2, 0x32}; - uint8_t bytesprops2[] = {0xc4, 0x7e, 0x1b}; - uint8_t bytesprops3[] = {0x98, 0x34, 0x50, 0x88}; - uint8_t bytesprops4[] = {0xb5, 0xbb, 0x1, 0x9d, 0xb4, 0xb7, 0x6d, 0x39, 0x78, 0x89, 0x6d, 0xa4, 0xa6, - 0x1a, 0xf8, 0xcf, 0x44, 0xba, 0x8c, 0xa2, 0xb7, 0x34, 0xf7, 0x9e, 0xa, 0x8}; - uint8_t bytesprops5[] = {0x7b, 0x7f, 0xf5, 0x4, 0xf0, 0x21, 0xc4, 0xb1, 0x68, 0x92, 0xf, 0xcb, 0x61, 0x18, - 0xe7, 0x7b, 0x47, 0x38, 0xe7, 0xed, 0x77, 0x75, 0x38, 0xba, 0x71, 0x71, 0x20, 0x1e}; - uint8_t bytesprops6[] = {0x21, 0x4c, 0xb9, 0xed, 0x65, 0xe5, 0xd5, 0xc8, 0xb3}; - uint8_t bytesprops7[] = {0x1d, 0xe7, 0x9c, 0x54}; - uint8_t bytesprops8[] = {0x21, 0xf, 0x12, 0x4c, 0xa0, 0xf0, 0xd7, 0x3e, 0x3d, - 0xdd, 0x64, 0x79, 0x71, 0x73, 0x9e, 0x79, 0xb1}; - uint8_t bytesprops9[] = {0x29, 0xa6, 0x52, 0x74, 0xcf, 0xb4, 0x5b, 0xd7, 0x4d, 0x74, 0xc, 0xcd, 0x8a, 0x1, 0x2d, - 0x54, 0x6, 0xc4, 0x65, 0x65, 0xde, 0x48, 0x5d, 0xb1, 0xd7, 0xaf, 0x7e, 0xc1, 0xc6}; - uint8_t bytesprops10[] = {0x42, 0xa3, 0x14, 0x2f, 0xb1, 0x71, 0x3b, 0x40, 0x3f, 0x20, 0x92, 0x7b, 0x90}; + uint8_t bytesprops0[] = {0x78, 0x7f, 0xa6, 0x23, 0xdd, 0xe5, 0x1e, 0x4, 0xaf, 0x78}; + uint8_t bytesprops1[] = {0xc0, 0x3d, 0xdc, 0x4b, 0x5, 0xea, 0xa1, 0xf6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6962}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 188}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5684}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19004}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5773}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32275}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15152}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17393}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1871}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 106}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16563}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29528}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9323}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 7224, 239, props); + lwmqtt_err_t err = + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 29287, 222, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REL (PubREL 7224 239 [PropResponseInformation "\199[\249",PropServerReference -// "\f\DC3{(\200Z\154\ETBc\215\216\169A8\170\183\DC1\159\209\139\&0[\242\230\143m\242\&2",PropContentType -// "\196~\ESC",PropAuthenticationMethod "\152\&4P\136",PropSessionExpiryInterval 6962,PropWildcardSubscriptionAvailable -// 7,PropPayloadFormatIndicator 79,PropCorrelationData -// "\181\187\SOH\157\180\183m9x\137m\164\166\SUB\248\207D\186\140\162\183\&4\247\158\n\b",PropResponseInformation -// "{\DEL\245\EOT\240!\196\177h\146\SI\203a\CAN\231{G8\231\237wu8\186qq \RS",PropMessageExpiryInterval -// 188,PropTopicAlias 5684,PropSubscriptionIdentifier 3,PropServerReference -// "!L\185\237e\229\213\200\179",PropContentType "\GS\231\156T",PropTopicAliasMaximum 19004,PropMessageExpiryInterval -// 5773,PropRequestResponseInformation 61,PropMessageExpiryInterval 32275,PropTopicAliasMaximum -// 15152,PropSessionExpiryInterval 17393,PropRequestProblemInformation 50,PropSessionExpiryInterval 1871,PropMaximumQoS -// 106,PropAuthenticationMethod "!\SI\DC2L\160\240\215>=\221dyqs\158y\177",PropReasonString -// ")\166Rt\207\180[\215Mt\f\205\138\SOH-T\ACK\196ee\222H]\177\215\175~\193\198",PropSessionExpiryInterval -// 16563,PropSessionExpiryInterval 29528,PropContentType "B\163\DC4/\177q;@? \146{\144"]) -TEST(PubACKREL5QCTest, Decode23) { - uint8_t pkt[] = { - 0x62, 0x87, 0x2, 0x1c, 0x38, 0xef, 0x82, 0x2, 0x1a, 0x0, 0x3, 0xc7, 0x5b, 0xf9, 0x1c, 0x0, 0x1c, 0xc, 0x13, - 0x7b, 0x28, 0xc8, 0x5a, 0x9a, 0x17, 0x63, 0xd7, 0xd8, 0xa9, 0x41, 0x38, 0xaa, 0xb7, 0x11, 0x9f, 0xd1, 0x8b, 0x30, - 0x5b, 0xf2, 0xe6, 0x8f, 0x6d, 0xf2, 0x32, 0x3, 0x0, 0x3, 0xc4, 0x7e, 0x1b, 0x15, 0x0, 0x4, 0x98, 0x34, 0x50, - 0x88, 0x11, 0x0, 0x0, 0x1b, 0x32, 0x28, 0x7, 0x1, 0x4f, 0x9, 0x0, 0x1a, 0xb5, 0xbb, 0x1, 0x9d, 0xb4, 0xb7, - 0x6d, 0x39, 0x78, 0x89, 0x6d, 0xa4, 0xa6, 0x1a, 0xf8, 0xcf, 0x44, 0xba, 0x8c, 0xa2, 0xb7, 0x34, 0xf7, 0x9e, 0xa, - 0x8, 0x1a, 0x0, 0x1c, 0x7b, 0x7f, 0xf5, 0x4, 0xf0, 0x21, 0xc4, 0xb1, 0x68, 0x92, 0xf, 0xcb, 0x61, 0x18, 0xe7, - 0x7b, 0x47, 0x38, 0xe7, 0xed, 0x77, 0x75, 0x38, 0xba, 0x71, 0x71, 0x20, 0x1e, 0x2, 0x0, 0x0, 0x0, 0xbc, 0x23, - 0x16, 0x34, 0xb, 0x3, 0x1c, 0x0, 0x9, 0x21, 0x4c, 0xb9, 0xed, 0x65, 0xe5, 0xd5, 0xc8, 0xb3, 0x3, 0x0, 0x4, - 0x1d, 0xe7, 0x9c, 0x54, 0x22, 0x4a, 0x3c, 0x2, 0x0, 0x0, 0x16, 0x8d, 0x19, 0x3d, 0x2, 0x0, 0x0, 0x7e, 0x13, - 0x22, 0x3b, 0x30, 0x11, 0x0, 0x0, 0x43, 0xf1, 0x17, 0x32, 0x11, 0x0, 0x0, 0x7, 0x4f, 0x24, 0x6a, 0x15, 0x0, - 0x11, 0x21, 0xf, 0x12, 0x4c, 0xa0, 0xf0, 0xd7, 0x3e, 0x3d, 0xdd, 0x64, 0x79, 0x71, 0x73, 0x9e, 0x79, 0xb1, 0x1f, - 0x0, 0x1d, 0x29, 0xa6, 0x52, 0x74, 0xcf, 0xb4, 0x5b, 0xd7, 0x4d, 0x74, 0xc, 0xcd, 0x8a, 0x1, 0x2d, 0x54, 0x6, - 0xc4, 0x65, 0x65, 0xde, 0x48, 0x5d, 0xb1, 0xd7, 0xaf, 0x7e, 0xc1, 0xc6, 0x11, 0x0, 0x0, 0x40, 0xb3, 0x11, 0x0, - 0x0, 0x73, 0x58, 0x3, 0x0, 0xd, 0x42, 0xa3, 0x14, 0x2f, 0xb1, 0x71, 0x3b, 0x40, 0x3f, 0x20, 0x92, 0x7b, 0x90}; +// COMP (PubCOMP 29287 222 [PropWildcardSubscriptionAvailable 71,PropPayloadFormatIndicator 233,PropTopicAliasMaximum +// 9323,PropPayloadFormatIndicator 12,PropAssignedClientIdentifier "x\DEL\166#\221\229\RS\EOT\175x",PropRetainAvailable +// 69,PropAuthenticationMethod "\192=\220K\ENQ\234\161\246"]) +TEST(PubACKCOMP5QCTest, Decode23) { + uint8_t pkt[] = {0x70, 0x27, 0x72, 0x67, 0xde, 0x23, 0x28, 0x47, 0x1, 0xe9, 0x22, 0x24, 0x6b, 0x1, + 0xc, 0x12, 0x0, 0xa, 0x78, 0x7f, 0xa6, 0x23, 0xdd, 0xe5, 0x1e, 0x4, 0xaf, 0x78, + 0x25, 0x45, 0x15, 0x0, 0x8, 0xc0, 0x3d, 0xdc, 0x4b, 0x5, 0xea, 0xa1, 0xf6}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7224); - EXPECT_EQ(status, 239); -} - -// REL (PubREL 15593 241 [PropSubscriptionIdentifier 15,PropServerReference "g\155\204r",PropContentType -// "~\185\214g\196n\162\178j\STX\242\145\130\140\162~j\176\220'\201\163\NAK\131\166\143\GS",PropSubscriptionIdentifierAvailable -// 86,PropServerReference "5;\132zUx\169azP",PropResponseTopic -// "\139\226\248\211R=9\227\&3\195\247-;@k",PropResponseTopic "q\185yDL\184\189\ESC\t\234u\176\197\vf",PropSubscriptionIdentifier 4,PropReasonString +// "\216p\232\SI\213\143\198\158\210IB\138\238Q\148zC\174\b\244\141\224\236U4\229\165\154",PropServerReference +// "\224\207\191"]) +TEST(PubACKREC5QCTest, Encode26) { + uint8_t pkt[] = {0x50, 0xd2, 0x1, 0x13, 0xb2, 0x82, 0xcd, 0x1, 0x1f, 0x0, 0x9, 0x2d, 0x3a, 0x5, 0xc8, 0x80, 0x5d, + 0x51, 0x68, 0x70, 0x23, 0x42, 0x47, 0x27, 0x0, 0x0, 0x4b, 0xdd, 0x15, 0x0, 0x1c, 0x3d, 0xf4, 0xb5, + 0xde, 0x63, 0xa6, 0x9d, 0xa5, 0x8e, 0x5d, 0xc0, 0xc3, 0x78, 0x86, 0x48, 0xd1, 0x72, 0x2e, 0xbc, 0x5c, + 0x94, 0xa1, 0xe9, 0x58, 0xef, 0x41, 0x1c, 0x1c, 0x24, 0xc5, 0x13, 0x39, 0x4a, 0x2, 0x0, 0x0, 0x5a, + 0xd8, 0x2a, 0xb1, 0x1f, 0x0, 0x9, 0xc3, 0x2a, 0x8a, 0xa2, 0xf6, 0x4, 0x6e, 0x42, 0x21, 0x12, 0x0, + 0xe, 0x5b, 0x16, 0xd1, 0xea, 0x2c, 0x2c, 0x8e, 0xce, 0x96, 0x27, 0x69, 0xd2, 0x69, 0x17, 0x22, 0x6a, + 0x4b, 0x23, 0x5d, 0xe5, 0x1, 0x8a, 0x3, 0x0, 0x9, 0x2d, 0x82, 0xcc, 0xf3, 0x63, 0x46, 0x11, 0xaf, + 0x29, 0x29, 0x2b, 0x16, 0x0, 0x2, 0x42, 0x10, 0x9, 0x0, 0x10, 0x97, 0x8f, 0x17, 0xc7, 0xca, 0xb8, + 0xe6, 0xbc, 0xc1, 0x4a, 0xca, 0x7d, 0x28, 0xd0, 0xa6, 0x34, 0x12, 0x0, 0x19, 0x8a, 0x7a, 0xb1, 0x4, + 0xde, 0x37, 0xc2, 0x77, 0xd7, 0x39, 0x3b, 0x5b, 0x30, 0x58, 0x1, 0x8e, 0x3e, 0x1b, 0x9, 0xea, 0x75, + 0xb0, 0xc5, 0xb, 0x66, 0xb, 0x4, 0x1f, 0x0, 0x1c, 0xd8, 0x70, 0xe8, 0xf, 0xd5, 0x8f, 0xc6, 0x9e, + 0xd2, 0x49, 0x42, 0x8a, 0xee, 0x51, 0x94, 0x7a, 0x43, 0xae, 0x8, 0xf4, 0x8d, 0xe0, 0xec, 0x55, 0x34, + 0xe5, 0xa5, 0x9a, 0x1c, 0x0, 0x3, 0xe0, 0xcf, 0xbf}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0x48, 0xb}; - uint8_t bytesprops1[] = {0x35}; - uint8_t bytesprops2[] = {0x5b, 0xf9, 0xd5, 0x6a, 0x76, 0x95, 0x65, 0x5, 0x2b, 0x95, 0x2e, 0x98, 0xc8}; - uint8_t bytesprops3[] = {0xbb, 0x7b, 0x68, 0x98, 0xdf, 0x11, 0xbc, 0x5f, 0xc9, - 0x83, 0x45, 0x75, 0xb4, 0x9e, 0x9c, 0xc3, 0x5e}; - uint8_t bytesprops4[] = {0x31, 0x8c, 0x6f, 0xec, 0xdc, 0x48, 0xbc, 0xcf, 0x1f, 0xcb}; - uint8_t bytesprops6[] = {0x1b, 0x6, 0x1f, 0x3d, 0x74, 0x1b, 0x2f, 0x26, 0xe1, 0x2b}; - uint8_t bytesprops5[] = {0x24, 0x71, 0x12, 0x6, 0xf4, 0xba, 0x73, 0xed, 0xb4, 0xa3, 0x35, 0xff, 0xda, - 0xfb, 0xfd, 0x86, 0xa3, 0xca, 0x18, 0xb6, 0xc4, 0x1b, 0xf4, 0xcd, 0x24, 0x73}; - uint8_t bytesprops7[] = {0xca, 0x6a, 0x8d, 0x9b, 0x9d, 0x4, 0x39, 0xab, 0xdc, 0xe7, 0x2d, 0xfe, - 0x1c, 0x23, 0x40, 0x54, 0xb2, 0x6a, 0xf0, 0xa5, 0x2e, 0xed, 0x62}; - uint8_t bytesprops8[] = {0x4c}; - uint8_t bytesprops10[] = {0xdb, 0x80, 0x67, 0xc5, 0x51, 0xbe, 0x66, 0x68, 0x72, 0x6f, 0xba, 0x6, 0x8b, 0x59, 0x41}; - uint8_t bytesprops9[] = {0x4, 0xe8, 0x97, 0xc9, 0xba, 0x29}; + uint8_t bytesprops0[] = {0x2d, 0x3a, 0x5, 0xc8, 0x80, 0x5d, 0x51, 0x68, 0x70}; + uint8_t bytesprops1[] = {0x3d, 0xf4, 0xb5, 0xde, 0x63, 0xa6, 0x9d, 0xa5, 0x8e, 0x5d, 0xc0, 0xc3, 0x78, 0x86, + 0x48, 0xd1, 0x72, 0x2e, 0xbc, 0x5c, 0x94, 0xa1, 0xe9, 0x58, 0xef, 0x41, 0x1c, 0x1c}; + uint8_t bytesprops2[] = {0xc3, 0x2a, 0x8a, 0xa2, 0xf6, 0x4, 0x6e, 0x42, 0x21}; + uint8_t bytesprops3[] = {0x5b, 0x16, 0xd1, 0xea, 0x2c, 0x2c, 0x8e, 0xce, 0x96, 0x27, 0x69, 0xd2, 0x69, 0x17}; + uint8_t bytesprops4[] = {0x2d, 0x82, 0xcc, 0xf3, 0x63, 0x46, 0x11, 0xaf, 0x29}; + uint8_t bytesprops5[] = {0x42, 0x10}; + uint8_t bytesprops6[] = {0x97, 0x8f, 0x17, 0xc7, 0xca, 0xb8, 0xe6, 0xbc, + 0xc1, 0x4a, 0xca, 0x7d, 0x28, 0xd0, 0xa6, 0x34}; + uint8_t bytesprops7[] = {0x8a, 0x7a, 0xb1, 0x4, 0xde, 0x37, 0xc2, 0x77, 0xd7, 0x39, 0x3b, 0x5b, 0x30, + 0x58, 0x1, 0x8e, 0x3e, 0x1b, 0x9, 0xea, 0x75, 0xb0, 0xc5, 0xb, 0x66}; + uint8_t bytesprops8[] = {0xd8, 0x70, 0xe8, 0xf, 0xd5, 0x8f, 0xc6, 0x9e, 0xd2, 0x49, 0x42, 0x8a, 0xee, 0x51, + 0x94, 0x7a, 0x43, 0xae, 0x8, 0xf4, 0x8d, 0xe0, 0xec, 0x55, 0x34, 0xe5, 0xa5, 0x9a}; + uint8_t bytesprops9[] = {0xe0, 0xcf, 0xbf}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1817}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 381}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops5}, .v = {10, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9888}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18438}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29647}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 300}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 171}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops9}, .v = {15, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16967}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19421}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14666}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23256}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27211}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24037}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {25, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, 0, 19499, 97, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, 0, 5042, 130, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ACK (PubACK 19499 97 [PropSubscriptionIdentifierAvailable 13,PropSessionExpiryInterval 1817,PropContentType -// "H\v",PropMessageExpiryInterval 381,PropContentType "5",PropCorrelationData -// "[\249\213jv\149e\ENQ+\149.\152\200",PropAssignedClientIdentifier -// "\187{h\152\223\DC1\188_\201\131Eu\180\158\156\195^",PropAuthenticationMethod -// "1\140o\236\220H\188\207\US\203",PropRequestProblemInformation 228,PropUserProperty -// "$q\DC2\ACK\244\186s\237\180\163\&5\255\218\251\253\134\163\202\CAN\182\196\ESC\244\205$s" -// "\ESC\ACK\US=t\ESC/&\225+",PropTopicAlias 9888,PropMessageExpiryInterval 18438,PropServerReference -// "\202j\141\155\157\EOT9\171\220\231-\254\FS#@T\178j\240\165.\237b",PropRetainAvailable -// 164,PropRequestProblemInformation 220,PropRequestResponseInformation 86,PropMessageExpiryInterval -// 29647,PropPayloadFormatIndicator 168,PropReasonString "L",PropMaximumQoS 156,PropTopicAlias -// 300,PropPayloadFormatIndicator 9,PropPayloadFormatIndicator 171,PropUserProperty "\EOT\232\151\201\186)" -// "\219\128g\197Q\190fhro\186\ACK\139YA"]) -TEST(PubACKACK5QCTest, Decode26) { - uint8_t pkt[] = { - 0x40, 0xcc, 0x1, 0x4c, 0x2b, 0x61, 0xc7, 0x1, 0x29, 0xd, 0x11, 0x0, 0x0, 0x7, 0x19, 0x3, 0x0, 0x2, 0x48, - 0xb, 0x2, 0x0, 0x0, 0x1, 0x7d, 0x3, 0x0, 0x1, 0x35, 0x9, 0x0, 0xd, 0x5b, 0xf9, 0xd5, 0x6a, 0x76, 0x95, - 0x65, 0x5, 0x2b, 0x95, 0x2e, 0x98, 0xc8, 0x12, 0x0, 0x11, 0xbb, 0x7b, 0x68, 0x98, 0xdf, 0x11, 0xbc, 0x5f, 0xc9, - 0x83, 0x45, 0x75, 0xb4, 0x9e, 0x9c, 0xc3, 0x5e, 0x15, 0x0, 0xa, 0x31, 0x8c, 0x6f, 0xec, 0xdc, 0x48, 0xbc, 0xcf, - 0x1f, 0xcb, 0x17, 0xe4, 0x26, 0x0, 0x1a, 0x24, 0x71, 0x12, 0x6, 0xf4, 0xba, 0x73, 0xed, 0xb4, 0xa3, 0x35, 0xff, - 0xda, 0xfb, 0xfd, 0x86, 0xa3, 0xca, 0x18, 0xb6, 0xc4, 0x1b, 0xf4, 0xcd, 0x24, 0x73, 0x0, 0xa, 0x1b, 0x6, 0x1f, - 0x3d, 0x74, 0x1b, 0x2f, 0x26, 0xe1, 0x2b, 0x23, 0x26, 0xa0, 0x2, 0x0, 0x0, 0x48, 0x6, 0x1c, 0x0, 0x17, 0xca, - 0x6a, 0x8d, 0x9b, 0x9d, 0x4, 0x39, 0xab, 0xdc, 0xe7, 0x2d, 0xfe, 0x1c, 0x23, 0x40, 0x54, 0xb2, 0x6a, 0xf0, 0xa5, - 0x2e, 0xed, 0x62, 0x25, 0xa4, 0x17, 0xdc, 0x19, 0x56, 0x2, 0x0, 0x0, 0x73, 0xcf, 0x1, 0xa8, 0x1f, 0x0, 0x1, - 0x4c, 0x24, 0x9c, 0x23, 0x1, 0x2c, 0x1, 0x9, 0x1, 0xab, 0x26, 0x0, 0x6, 0x4, 0xe8, 0x97, 0xc9, 0xba, 0x29, - 0x0, 0xf, 0xdb, 0x80, 0x67, 0xc5, 0x51, 0xbe, 0x66, 0x68, 0x72, 0x6f, 0xba, 0x6, 0x8b, 0x59, 0x41}; +// REC (PubREC 5042 130 [PropReasonString "-:\ENQ\200\128]Qhp",PropTopicAlias 16967,PropMaximumPacketSize +// 19421,PropAuthenticationMethod +// "=\244\181\222c\166\157\165\142]\192\195x\134H\209r.\188\\\148\161\233X\239A\FS\FS",PropMaximumQoS +// 197,PropServerKeepAlive 14666,PropMessageExpiryInterval 23256,PropSharedSubscriptionAvailable 177,PropReasonString +// "\195*\138\162\246\EOTnB!",PropAssignedClientIdentifier +// "[\SYN\209\234,,\142\206\150'i\210i\ETB",PropTopicAliasMaximum 27211,PropTopicAlias 24037,PropPayloadFormatIndicator +// 138,PropContentType "-\130\204\243cF\DC1\175)",PropSubscriptionIdentifierAvailable 43,PropAuthenticationData +// "B\DLE",PropCorrelationData "\151\143\ETB\199\202\184\230\188\193J\202}(\208\166\&4",PropAssignedClientIdentifier +// "\138z\177\EOT\222\&7\194w\215\&9;[0X\SOH\142>\ESC\t\234u\176\197\vf",PropSubscriptionIdentifier 4,PropReasonString +// "\216p\232\SI\213\143\198\158\210IB\138\238Q\148zC\174\b\244\141\224\236U4\229\165\154",PropServerReference +// "\224\207\191"]) +TEST(PubACKREC5QCTest, Decode26) { + uint8_t pkt[] = {0x50, 0xd2, 0x1, 0x13, 0xb2, 0x82, 0xcd, 0x1, 0x1f, 0x0, 0x9, 0x2d, 0x3a, 0x5, 0xc8, 0x80, 0x5d, + 0x51,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34, + 0xe5, 0xa5, 0x9a, 0x1c, 0x0, 0x3, 0xe0, 0xcf, 0xbf}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBACK_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19499); - EXPECT_EQ(status, 97); -} - -// COMP (PubCOMP 13110 221 [PropReceiveMaximum 13389,PropMaximumQoS 104,PropResponseTopic -// "\167\204\129\136\201\EM\167\219\SYN\212\192\232\SOnI\132",PropWildcardSubscriptionAvailable -// 49,PropSharedSubscriptionAvailable 241,PropSharedSubscriptionAvailable 113,PropReceiveMaximum -// 11896,PropAuthenticationData "z\250^:\194\184\143\221\US8\150\143\164\227",PropRequestResponseInformation -// 55,PropPayloadFormatIndicator 168,PropWillDelayInterval 15344,PropReceiveMaximum 14492,PropRequestProblemInformation -// 195,PropReceiveMaximum 13118,PropTopicAliasMaximum 32101,PropSubscriptionIdentifier 13,PropAssignedClientIdentifier -// "\250x\156J\243\200\&5\DC1T\161\vl\215\131\230\180\182\DEL\173\234lO5",PropMaximumQoS 27,PropMaximumQoS -// 221,PropSessionExpiryInterval 6935,PropTopicAliasMaximum 3750]) -TEST(PubACKCOMP5QCTest, Encode27) { - uint8_t pkt[] = {0x70, 0x72, 0x33, 0x36, 0xdd, 0x6e, 0x21, 0x34, 0x4d, 0x24, 0x68, 0x8, 0x0, 0x10, 0xa7, 0xcc, 0x81, - 0x88, 0xc9, 0x19, 0xa7, 0xdb, 0x16, 0xd4, 0xc0, 0xe8, 0xe, 0x6e, 0x49, 0x84, 0x28, 0x31, 0x2a, 0xf1, - 0x2a, 0x71, 0x21, 0x2e, 0x78, 0x16, 0x0, 0xe, 0x7a, 0xfa, 0x5e, 0x3a, 0xc2, 0xb8, 0x8f, 0xdd, 0x1f, - 0x38, 0x96, 0x8f, 0xa4, 0xe3, 0x19, 0x37, 0x1, 0xa8, 0x18, 0x0, 0x0, 0x3b, 0xf0, 0x21, 0x38, 0x9c, - 0x17, 0xc3, 0x21, 0x33, 0x3e, 0x22, 0x7d, 0x65, 0xb, 0xd, 0x12, 0x0, 0x17, 0xfa, 0x78, 0x9c, 0x4a, - 0xf3, 0xc8, 0x35, 0x11, 0x54, 0xa1, 0xb, 0x6c, 0xd7, 0x83, 0xe6, 0xb4, 0xb6, 0x7f, 0xad, 0xea, 0x6c, - 0x4f, 0x35, 0x24, 0x1b, 0x24, 0xdd, 0x11, 0x0, 0x0, 0x1b, 0x17, 0x22, 0xe, 0xa6}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 5042); + EXPECT_EQ(status, 130); +} + +// REL (PubREL 2316 5 [PropReasonString "\140\&0\t",PropResponseTopic +// "\167\211\185\vB\243\DC3Rv\t\f$9eBk|\222}",PropWillDelayInterval 7302,PropMessageExpiryInterval +// 20574,PropRequestResponseInformation 236,PropMessageExpiryInterval 20490,PropResponseInformation +// "\237\202t|8\137\CAN\DC2/\129",PropTopicAliasMaximum 18528,PropResponseTopic "4P\169\216$",PropCorrelationData +// "\GS\ACK%@\250\220\&2Pm\233\233\196\228\SYN=7)\SO\173(\199\165x\155nQ",PropAuthenticationData +// "\225\253\211\167a\183B6\237k\EMtP-\129\249\231\SO\141\140",PropMessageExpiryInterval 9082,PropMaximumQoS +// 91,PropServerReference "\205\148 Q\141-8\164\178\208{\SI\213\220.\191\147<",PropPayloadFormatIndicator +// 210,PropWillDelayInterval 6198,PropAuthenticationData +// "y\DEL\231\154\135:J$\146^l3@\241\DC26\DEL,A\NAKyp",PropSubscriptionIdentifier 4,PropAuthenticationData +// "\v\175\166\239T\DC3@p\ETX\170\135V\229\236\SI\140*h\211\191D\137\203p\145$",PropSubscriptionIdentifier +// 6,PropWillDelayInterval 37,PropSubscriptionIdentifier 3,PropRequestResponseInformation 196,PropResponseInformation +// "Uw\153\175\ETB\187\138!"]) +TEST(PubACKREL5QCTest, Encode27) { + uint8_t pkt[] = { + 0x62, 0xef, 0x1, 0x9, 0xc, 0x5, 0xea, 0x1, 0x1f, 0x0, 0x3, 0x8c, 0x30, 0x9, 0x8, 0x0, 0x13, 0xa7, 0xd3, + 0xb9, 0xb, 0x42, 0xf3, 0x13, 0x52, 0x76, 0x9, 0xc, 0x24, 0x39, 0x65, 0x42, 0x6b, 0x7c, 0xde, 0x7d, 0x18, 0x0, + 0x0, 0x1c, 0x86, 0x2, 0x0, 0x0, 0x50, 0x5e, 0x19, 0xec, 0x2, 0x0, 0x0, 0x50, 0xa, 0x1a, 0x0, 0xa, 0xed, + 0xca, 0x74, 0x7c, 0x38, 0x89, 0x18, 0x12, 0x2f, 0x81, 0x22, 0x48, 0x60, 0x8, 0x0, 0x5, 0x34, 0x50, 0xa9, 0xd8, + 0x24, 0x9, 0x0, 0x1a, 0x1d, 0x6, 0x25, 0x40, 0xfa, 0xdc, 0x32, 0x50, 0x6d, 0xe9, 0xe9, 0xc4, 0xe4, 0x16, 0x3d, + 0x37, 0x29, 0xe, 0xad, 0x28, 0xc7, 0xa5, 0x78, 0x9b, 0x6e, 0x51, 0x16, 0x0, 0x14, 0xe1, 0xfd, 0xd3, 0xa7, 0x61, + 0xb7, 0x42, 0x36, 0xed, 0x6b, 0x19, 0x74, 0x50, 0x2d, 0x81, 0xf9, 0xe7, 0xe, 0x8d, 0x8c, 0x2, 0x0, 0x0, 0x23, + 0x7a, 0x24, 0x5b, 0x1c, 0x0, 0x12, 0xcd, 0x94, 0x20, 0x51, 0x8d, 0x2d, 0x38, 0xa4, 0xb2, 0xd0, 0x7b, 0xf, 0xd5, + 0xdc, 0x2e, 0xbf, 0x93, 0x3c, 0x1, 0xd2, 0x18, 0x0, 0x0, 0x18, 0x36, 0x16, 0x0, 0x16, 0x79, 0x7f, 0xe7, 0x9a, + 0x87, 0x3a, 0x4a, 0x24, 0x92, 0x5e, 0x6c, 0x33, 0x40, 0xf1, 0x12, 0x36, 0x7f, 0x2c, 0x41, 0x15, 0x79, 0x70, 0xb, + 0x4, 0x16, 0x0, 0x1a, 0xb, 0xaf, 0xa6, 0xef, 0x54, 0x13, 0x40, 0x70, 0x3, 0xaa, 0x87, 0x56, 0xe5, 0xec, 0xf, + 0x8c, 0x2a, 0x68, 0xd3, 0xbf, 0x44, 0x89, 0xcb, 0x70, 0x91, 0x24, 0xb, 0x6, 0x18, 0x0, 0x0, 0x0, 0x25, 0xb, + 0x3, 0x19, 0xc4, 0x1a, 0x0, 0x8, 0x55, 0x77, 0x99, 0xaf, 0x17, 0xbb, 0x8a, 0x21}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0xa7, 0xcc, 0x81, 0x88, 0xc9, 0x19, 0xa7, 0xdb, - 0x16, 0xd4, 0xc0, 0xe8, 0xe, 0x6e, 0x49, 0x84}; - uint8_t bytesprops1[] = {0x7a, 0xfa, 0x5e, 0x3a, 0xc2, 0xb8, 0x8f, 0xdd, 0x1f, 0x38, 0x96, 0x8f, 0xa4, 0xe3}; - uint8_t bytesprops2[] = {0xfa, 0x78, 0x9c, 0x4a, 0xf3, 0xc8, 0x35, 0x11, 0x54, 0xa1, 0xb, 0x6c, - 0xd7, 0x83, 0xe6, 0xb4, 0xb6, 0x7f, 0xad, 0xea, 0x6c, 0x4f, 0x35}; + uint8_t bytesprops0[] = {0x8c, 0x30, 0x9}; + uint8_t bytesprops1[] = {0xa7, 0xd3, 0xb9, 0xb, 0x42, 0xf3, 0x13, 0x52, 0x76, 0x9, + 0xc, 0x24, 0x39, 0x65, 0x42, 0x6b, 0x7c, 0xde, 0x7d}; + uint8_t bytesprops2[] = {0xed, 0xca, 0x74, 0x7c, 0x38, 0x89, 0x18, 0x12, 0x2f, 0x81}; + uint8_t bytesprops3[] = {0x34, 0x50, 0xa9, 0xd8, 0x24}; + uint8_t bytesprops4[] = {0x1d, 0x6, 0x25, 0x40, 0xfa, 0xdc, 0x32, 0x50, 0x6d, 0xe9, 0xe9, 0xc4, 0xe4, + 0x16, 0x3d, 0x37, 0x29, 0xe, 0xad, 0x28, 0xc7, 0xa5, 0x78, 0x9b, 0x6e, 0x51}; + uint8_t bytesprops5[] = {0xe1, 0xfd, 0xd3, 0xa7, 0x61, 0xb7, 0x42, 0x36, 0xed, 0x6b, + 0x19, 0x74, 0x50, 0x2d, 0x81, 0xf9, 0xe7, 0xe, 0x8d, 0x8c}; + uint8_t bytesprops6[] = {0xcd, 0x94, 0x20, 0x51, 0x8d, 0x2d, 0x38, 0xa4, 0xb2, + 0xd0, 0x7b, 0xf, 0xd5, 0xdc, 0x2e, 0xbf, 0x93, 0x3c}; + uint8_t bytesprops7[] = {0x79, 0x7f, 0xe7, 0x9a, 0x87, 0x3a, 0x4a, 0x24, 0x92, 0x5e, 0x6c, + 0x33, 0x40, 0xf1, 0x12, 0x36, 0x7f, 0x2c, 0x41, 0x15, 0x79, 0x70}; + uint8_t bytesprops8[] = {0xb, 0xaf, 0xa6, 0xef, 0x54, 0x13, 0x40, 0x70, 0x3, 0xaa, 0x87, 0x56, 0xe5, + 0xec, 0xf, 0x8c, 0x2a, 0x68, 0xd3, 0xbf, 0x44, 0x89, 0xcb, 0x70, 0x91, 0x24}; + uint8_t bytesprops9[] = {0x55, 0x77, 0x99, 0xaf, 0x17, 0xbb, 0x8a, 0x21}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13389}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11896}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 55}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15344}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14492}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13118}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32101}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 27}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6935}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3750}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {3, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7302}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20574}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20490}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18528}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9082}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6198}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {22, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {26, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 37}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops9}}}, }; - lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 13110, 221, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 2316, 5, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 13110 221 [PropReceiveMaximum 13389,PropMaximumQoS 104,PropResponseTopic -// "\167\204\129\136\201\EM\167\219\SYN\212\192\232\SOnI\132",PropWildcardSubscriptionAvailable -// 49,PropSharedSubscriptionAvailable 241,PropSharedSubscriptionAvailable 113,PropReceiveMaximum -// 11896,PropAuthenticationData "z\250^:\194\184\143\221\US8\150\143\164\227",PropRequestResponseInformation -// 55,PropPayloadFormatIndicator 168,PropWillDelayInterval 15344,PropReceiveMaximum 14492,PropRequestProblemInformation -// 195,PropReceiveMaximum 13118,PropTopicAliasMaximum 32101,PropSubscriptionIdentifier 13,PropAssignedClientIdentifier -// "\250x\156J\243\200\&5\DC1T\161\vl\215\131\230\180\182\DEL\173\234lO5",PropMaximumQoS 27,PropMaximumQoS -// 221,PropSessionExpiryInterval 6935,PropTopicAliasMaximum 3750]) -TEST(PubACKCOMP5QCTest, Decode27) { - uint8_t pkt[] = {0x70, 0x72, 0x33, 0x36, 0xdd, 0x6e, 0x21, 0x34, 0x4d, 0x24, 0x68, 0x8, 0x0, 0x10, 0xa7, 0xcc, 0x81, - 0x88, 0xc9, 0x19, 0xa7, 0xdb, 0x16, 0xd4, 0xc0, 0xe8, 0xe, 0x6e, 0x49, 0x84, 0x28, 0x31, 0x2a, 0xf1, - 0x2a, 0x71, 0x21, 0x2e, 0x78, 0x16, 0x0, 0xe, 0x7a, 0xfa, 0x5e, 0x3a, 0xc2, 0xb8, 0x8f, 0xdd, 0x1f, - 0x38, 0x96, 0x8f, 0xa4, 0xe3, 0x19, 0x37, 0x1, 0xa8, 0x18, 0x0, 0x0, 0x3b, 0xf0, 0x21, 0x38, 0x9c, - 0x17, 0xc3, 0x21, 0x33, 0x3e, 0x22, 0x7d, 0x65, 0xb, 0xd, 0x12, 0x0, 0x17, 0xfa, 0x78, 0x9c, 0x4a, - 0xf3, 0xc8, 0x35, 0x11, 0x54, 0xa1, 0xb, 0x6c, 0xd7, 0x83, 0xe6, 0xb4, 0xb6, 0x7f, 0xad, 0xea, 0x6c, - 0x4f, 0x35, 0x24, 0x1b, 0x24, 0xdd, 0x11, 0x0, 0x0, 0x1b, 0x17, 0x22, 0xe, 0xa6}; +// REL (PubREL 2316 5 [PropReasonString "\140\&0\t",PropResponseTopic +// "\167\211\185\vB\243\DC3Rv\t\f$9eBk|\222}",PropWillDelayInterval 7302,PropMessageExpiryInterval +// 20574,PropRequestResponseInformation 236,PropMessageExpiryInterval 20490,PropResponseInformation +// "\237\202t|8\137\CAN\DC2/\129",PropTopicAliasMaximum 18528,PropResponseTopic "4P\169\216$",PropCorrelationData +// "\GS\ACK%@\250\220\&2Pm\233\233\196\228\SYN=7)\SO\173(\199\165x\155nQ",PropAuthenticationData +// "\225\253\211\167a\183B6\237k\EMtP-\129\249\231\SO\141\140",PropMessageExpiryInterval 9082,PropMaximumQoS +// 91,PropServerReference "\205\148 Q\141-8\164\178\208{\SI\213\220.\191\147<",PropPayloadFormatIndicator +// 210,PropWillDelayInterval 6198,PropAuthenticationData +// "y\DEL\231\154\135:J$\146^l3@\241\DC26\DEL,A\NAKyp",PropSubscriptionIdentifier 4,PropAuthenticationData +// "\v\175\166\239T\DC3@p\ETX\170\135V\229\236\SI\140*h\211\191D\137\203p\145$",PropSubscriptionIdentifier +// 6,PropWillDelayInterval 37,PropSubscriptionIdentifier 3,PropRequestResponseInformation 196,PropResponseInformation +// "Uw\153\175\ETB\187\138!"]) +TEST(PubACKREL5QCTest, Decode27) { + uint8_t pkt[] = { + 0x62, 0xef, 0x1, 0x9, 0xc, 0x5, 0xea, 0x1, 0x1f, 0x0, 0x3, 0x8c, 0x30, 0x9, 0x8, 0x0, 0x13, 0xa7, 0xd3, + 0xb9, 0xb, 0x42, 0xf3, 0x13, 0x52, 0x76, 0x9, 0xc, 0x24, 0x39, 0x65, 0x42, 0x6b, 0x7c, 0xde, 0x7d, 0x18, 0x0, + 0x0, 0x1c, 0x86, 0x2, 0x0, 0x0, 0x50, 0x5e, 0x19, 0xec, 0x2, 0x0, 0x0, 0x50, 0xa, 0x1a, 0x0, 0xa, 0xed, + 0xca, 0x74, 0x7c, 0x38, 0x89, 0x18, 0x12, 0x2f, 0x81, 0x22, 0x48, 0x60, 0x8, 0x0, 0x5, 0x34, 0x50, 0xa9, 0xd8, + 0x24, 0x9, 0x0, 0x1a, 0x1d, 0x6, 0x25, 0x40, 0xfa, 0xdc, 0x32, 0x50, 0x6d, 0xe9, 0xe9, 0xc4, 0xe4, 0x16, 0x3d, + 0x37, 0x29, 0xe, 0xad, 0x28, 0xc7, 0xa5, 0x78, 0x9b, 0x6e, 0x51, 0x16, 0x0, 0x14, 0xe1, 0xfd, 0xd3, 0xa7, 0x61, + 0xb7, 0x42, 0x36, 0xed, 0x6b, 0x19, 0x74, 0x50, 0x2d, 0x81, 0xf9, 0xe7, 0xe, 0x8d, 0x8c, 0x2, 0x0, 0x0, 0x23, + 0x7a, 0x24, 0x5b, 0x1c, 0x0, 0x12, 0xcd, 0x94, 0x20, 0x51, 0x8d, 0x2d, 0x38, 0xa4, 0xb2, 0xd0, 0x7b, 0xf, 0xd5, + 0xdc, 0x2e, 0xbf, 0x93, 0x3c, 0x1, 0xd2, 0x18, 0x0, 0x0, 0x18, 0x36, 0x16, 0x0, 0x16, 0x79, 0x7f, 0xe7, 0x9a, + 0x87, 0x3a, 0x4a, 0x24, 0x92, 0x5e, 0x6c, 0x33, 0x40, 0xf1, 0x12, 0x36, 0x7f, 0x2c, 0x41, 0x15, 0x79, 0x70, 0xb, + 0x4, 0x16, 0x0, 0x1a, 0xb, 0xaf, 0xa6, 0xef, 0x54, 0x13, 0x40, 0x70, 0x3, 0xaa, 0x87, 0x56, 0xe5, 0xec, 0xf, + 0x8c, 0x2a, 0x68, 0xd3, 0xbf, 0x44, 0x89, 0xcb, 0x70, 0x91, 0x24, 0xb, 0x6, 0x18, 0x0, 0x0, 0x0, 0x25, 0xb, + 0x3, 0x19, 0xc4, 0x1a, 0x0, 0x8, 0x55, 0x77, 0x99, 0xaf, 0x17, 0xbb, 0x8a, 0x21}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 13110); - EXPECT_EQ(status, 221); -} - -// REC (PubREC 25388 230 [PropMaximumQoS 62,PropCorrelationData "\185\195",PropMessageExpiryInterval -// 31098,PropServerReference "",PropSubscriptionIdentifier 4,PropResponseTopic -// "GA\182z\195%b\234i\155\176\b\ETB+\149",PropServerReference "1\161\164=",PropSessionExpiryInterval -// 30227,PropResponseTopic "\240i",PropResponseTopic -// "e\EOT\188\148`!\179\194\&2n\245w\150\250(\140\231\205'\ENQ\DC3",PropSubscriptionIdentifierAvailable 57]) -TEST(PubACKREC5QCTest, Encode28) { - uint8_t pkt[] = {0x50, 0x52, 0x63, 0x2c, 0xe6, 0x4e, 0x24, 0x3e, 0x9, 0x0, 0x2, 0xb9, 0xc3, 0x2, 0x0, 0x0, 0x79, - 0x7a, 0x1c, 0x0, 0x0, 0xb, 0x4, 0x8, 0x0, 0xf, 0x47, 0x41, 0xb6, 0x7a, 0xc3, 0x25, 0x62, 0xea, - 0x69, 0x9b, 0xb0, 0x8, 0x17, 0x2b, 0x95, 0x1c, 0x0, 0x4, 0x31, 0xa1, 0xa4, 0x3d, 0x11, 0x0, 0x0, - 0x76, 0x13, 0x8, 0x0, 0x2, 0xf0, 0x69, 0x8, 0x0, 0x15, 0x65, 0x4, 0xbc, 0x94, 0x60, 0x21, 0xb3, - 0xc2, 0x32, 0x6e, 0xf5, 0x77, 0x96, 0xfa, 0x28, 0x8c, 0xe7, 0xcd, 0x27, 0x5, 0x13, 0x29, 0x39}; + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 2316); + EXPECT_EQ(status, 5); +} + +// REL (PubREL 28050 34 [PropReceiveMaximum 9193,PropTopicAliasMaximum 16058,PropRequestProblemInformation +// 229,PropMaximumQoS 173,PropCorrelationData +// "\190\249\146g^\192\234\138\255`\166\134\US\223r\180\239\242\207",PropUserProperty +// "\179\245\tYAyMx\147\190X,\SYN\v^\144}\153\177\162\168\156\172" +// "\152\DC47\189\147.\248\SIA\249\177j\197\198\207J\247\214\221\172#@\174?",PropAuthenticationMethod +// "\217\155\130\162\ENQ\139\229fj\EOTdOCB",PropServerKeepAlive 11033,PropRetainAvailable 90,PropMessageExpiryInterval +// 5639,PropTopicAlias 25349,PropResponseInformation +// "\197\183C\"\220\240\151\137\FS\158}\FS\218+b\249d\176\135\172",PropTopicAlias 15096]) +TEST(PubACKREL5QCTest, Encode28) { + uint8_t pkt[] = {0x62, 0x91, 0x1, 0x6d, 0x92, 0x22, 0x8c, 0x1, 0x21, 0x23, 0xe9, 0x22, 0x3e, 0xba, 0x17, 0xe5, 0x24, + 0xad, 0x9, 0x0, 0x13, 0xbe, 0xf9, 0x92, 0x67, 0x5e, 0xc0, 0xea, 0x8a, 0xff, 0x60, 0xa6, 0x86, 0x1f, + 0xdf, 0x72, 0xb4, 0xef, 0xf2, 0xcf, 0x26, 0x0, 0x17, 0xb3, 0xf5, 0x9, 0x59, 0x41, 0x79, 0x4d, 0x78, + 0x93, 0xbe, 0x58, 0x2c, 0x16, 0xb, 0x5e, 0x90, 0x7d, 0x99, 0xb1, 0xa2, 0xa8, 0x9c, 0xac, 0x0, 0x18, + 0x98, 0x14, 0x37, 0xbd, 0x93, 0x2e, 0xf8, 0xf, 0x41, 0xf9, 0xb1, 0x6a, 0xc5, 0xc6, 0xcf, 0x4a, 0xf7, + 0xd6, 0xdd, 0xac, 0x23, 0x40, 0xae, 0x3f, 0x15, 0x0, 0xe, 0xd9, 0x9b, 0x82, 0xa2, 0x5, 0x8b, 0xe5, + 0x66, 0x6a, 0x4, 0x64, 0x4f, 0x43, 0x42, 0x13, 0x2b, 0x19, 0x25, 0x5a, 0x2, 0x0, 0x0, 0x16, 0x7, + 0x23, 0x63, 0x5, 0x1a, 0x0, 0x14, 0xc5, 0xb7, 0x43, 0x22, 0xdc, 0xf0, 0x97, 0x89, 0x1c, 0x9e, 0x7d, + 0x1c, 0xda, 0x2b, 0x62, 0xf9, 0x64, 0xb0, 0x87, 0xac, 0x23, 0x3a, 0xf8}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0xb9, 0xc3}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x47, 0x41, 0xb6, 0x7a, 0xc3, 0x25, 0x62, 0xea, 0x69, 0x9b, 0xb0, 0x8, 0x17, 0x2b, 0x95}; - uint8_t bytesprops3[] = {0x31, 0xa1, 0xa4, 0x3d}; - uint8_t bytesprops4[] = {0xf0, 0x69}; - uint8_t bytesprops5[] = {0x65, 0x4, 0xbc, 0x94, 0x60, 0x21, 0xb3, 0xc2, 0x32, 0x6e, 0xf5, - 0x77, 0x96, 0xfa, 0x28, 0x8c, 0xe7, 0xcd, 0x27, 0x5, 0x13}; + uint8_t bytesprops0[] = {0xbe, 0xf9, 0x92, 0x67, 0x5e, 0xc0, 0xea, 0x8a, 0xff, 0x60, + 0xa6, 0x86, 0x1f, 0xdf, 0x72, 0xb4, 0xef, 0xf2, 0xcf}; + uint8_t bytesprops2[] = {0x98, 0x14, 0x37, 0xbd, 0x93, 0x2e, 0xf8, 0xf, 0x41, 0xf9, 0xb1, 0x6a, + 0xc5, 0xc6, 0xcf, 0x4a, 0xf7, 0xd6, 0xdd, 0xac, 0x23, 0x40, 0xae, 0x3f}; + uint8_t bytesprops1[] = {0xb3, 0xf5, 0x9, 0x59, 0x41, 0x79, 0x4d, 0x78, 0x93, 0xbe, 0x58, 0x2c, + 0x16, 0xb, 0x5e, 0x90, 0x7d, 0x99, 0xb1, 0xa2, 0xa8, 0x9c, 0xac}; + uint8_t bytesprops3[] = {0xd9, 0x9b, 0x82, 0xa2, 0x5, 0x8b, 0xe5, 0x66, 0x6a, 0x4, 0x64, 0x4f, 0x43, 0x42}; + uint8_t bytesprops4[] = {0xc5, 0xb7, 0x43, 0x22, 0xdc, 0xf0, 0x97, 0x89, 0x1c, 0x9e, + 0x7d, 0x1c, 0xda, 0x2b, 0x62, 0xf9, 0x64, 0xb0, 0x87, 0xac}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 62}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31098}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30227}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9193}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16058}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 173}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops1}, .v = {24, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11033}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5639}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25349}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15096}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, 0, 25388, 230, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, 0, 28050, 34, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// REC (PubREC 25388 230 [PropMaximumQoS 62,PropCorrelationData "\185\195",PropMessageExpiryInterval -// 31098,PropServerReference "",PropSubscriptionIdentifier 4,PropResponseTopic -// "GA\182z\195%b\234i\155\176\b\ETB+\149",PropServerReference "1\161\164=",PropSessionExpiryInterval -// 30227,PropResponseTopic "\240i",PropResponseTopic -// "e\EOT\188\148`!\179\194\&2n\245w\150\250(\140\231\205'\ENQ\DC3",PropSubscriptionIdentifierAvailable 57]) -TEST(PubACKREC5QCTest, Decode28) { - uint8_t pkt[] = {0x50, 0x52, 0x63, 0x2c, 0xe6, 0x4e, 0x24, 0x3e, 0x9, 0x0, 0x2, 0xb9, 0xc3, 0x2, 0x0, 0x0, 0x79, - 0x7a, 0x1c, 0x0, 0x0, 0xb, 0x4, 0x8, 0x0, 0xf, 0x47, 0x41, 0xb6, 0x7a, 0xc3, 0x25, 0x62, 0xea, - 0x69, 0x9b, 0xb0, 0x8, 0x17, 0x2b, 0x95, 0x1c, 0x0, 0x4, 0x31, 0xa1, 0xa4, 0x3d, 0x11, 0x0, 0x0, - 0x76, 0x13, 0x8, 0x0, 0x2, 0xf0, 0x69, 0x8, 0x0, 0x15, 0x65, 0x4, 0xbc, 0x94, 0x60, 0x21, 0xb3, - 0xc2, 0x32, 0x6e, 0xf5, 0x77, 0x96, 0xfa, 0x28, 0x8c, 0xe7, 0xcd, 0x27, 0x5, 0x13, 0x29, 0x39}; +// REL (PubREL 28050 34 [PropReceiveMaximum 9193,PropTopicAliasMaximum 16058,PropRequestProblemInformation +// 229,PropMaximumQoS 173,PropCorrelationData +// "\190\249\146g^\192\234\138\255`\166\134\US\223r\180\239\242\207",PropUserProperty +// "\179\245\tYAyMx\147\190X,\SYN\v^\144}\153\177\162\168\156\172" +// "\152\DC47\189\147.\248\SIA\249\177j\197\198\207J\247\214\221\172#@\174?",PropAuthenticationMethod +// "\217\155\130\162\ENQ\139\229fj\EOTdOCB",PropServerKeepAlive 11033,PropRetainAvailable 90,PropMessageExpiryInterval +// 5639,PropTopicAlias 25349,PropResponseInformation +// "\197\183C\"\220\240\151\137\FS\158}\FS\218+b\249d\176\135\172",PropTopicAlias 15096]) +TEST(PubACKREL5QCTest, Decode28) { + uint8_t pkt[] = {0x62, 0x91, 0x1, 0x6d, 0x92, 0x22, 0x8c, 0x1, 0x21, 0x23, 0xe9, 0x22, 0x3e, 0xba, 0x17, 0xe5, 0x24, + 0xad, 0x9, 0x0, 0x13, 0xbe, 0xf9, 0x92, 0x67, 0x5e, 0xc0, 0xea, 0x8a, 0xff, 0x60, 0xa6, 0x86, 0x1f, + 0xdf, 0x72, 0xb4, 0xef, 0xf2, 0xcf, 0x26, 0x0, 0x17, 0xb3, 0xf5, 0x9, 0x59, 0x41, 0x79, 0x4d, 0x78, + 0x93, 0xbe, 0x58, 0x2c, 0x16, 0xb, 0x5e, 0x90, 0x7d, 0x99, 0xb1, 0xa2, 0xa8, 0x9c, 0xac, 0x0, 0x18, + 0x98, 0x14, 0x37, 0xbd, 0x93, 0x2e, 0xf8, 0xf, 0x41, 0xf9, 0xb1, 0x6a, 0xc5, 0xc6, 0xcf, 0x4a, 0xf7, + 0xd6, 0xdd, 0xac, 0x23, 0x40, 0xae, 0x3f, 0x15, 0x0, 0xe, 0xd9, 0x9b, 0x82, 0xa2, 0x5, 0x8b, 0xe5, + 0x66, 0x6a, 0x4, 0x64, 0x4f, 0x43, 0x42, 0x13, 0x2b, 0x19, 0x25, 0x5a, 0x2, 0x0, 0x0, 0x16, 0x7, + 0x23, 0x63, 0x5, 0x1a, 0x0, 0x14, 0xc5, 0xb7, 0x43, 0x22, 0xdc, 0xf0, 0x97, 0x89, 0x1c, 0x9e, 0x7d, + 0x1c, 0xda, 0x2b, 0x62, 0xf9, 0x64, 0xb0, 0x87, 0xac, 0x23, 0x3a, 0xf8}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = - lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREC_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25388); - EXPECT_EQ(status, 230); + lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBREL_PACKET, &dup, &packet_id, &status, &props); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 28050); + EXPECT_EQ(status, 34); } -// COMP (PubCOMP 5812 238 [PropAuthenticationData "P9\\\230\247",PropSubscriptionIdentifier -// 2,PropSubscriptionIdentifierAvailable 110]) +// COMP (PubCOMP 17627 140 [PropAuthenticationMethod +// "\129\DC4\DC4O\189z\EOT\223\251\219\245\159\252\143D\180Tf\255\DC3\175w\185\r;p",PropSubscriptionIdentifierAvailable +// 9,PropServerKeepAlive 19683,PropWillDelayInterval 5690]) TEST(PubACKCOMP5QCTest, Encode29) { - uint8_t pkt[] = {0x70, 0x10, 0x16, 0xb4, 0xee, 0xc, 0x16, 0x0, 0x5, - 0x50, 0x39, 0x5c, 0xe6, 0xf7, 0xb, 0x2, 0x29, 0x6e}; + uint8_t pkt[] = {0x70, 0x2b, 0x44, 0xdb, 0x8c, 0x27, 0x15, 0x0, 0x1a, 0x81, 0x14, 0x14, 0x4f, 0xbd, 0x7a, + 0x4, 0xdf, 0xfb, 0xdb, 0xf5, 0x9f, 0xfc, 0x8f, 0x44, 0xb4, 0x54, 0x66, 0xff, 0x13, 0xaf, + 0x77, 0xb9, 0xd, 0x3b, 0x70, 0x29, 0x9, 0x13, 0x4c, 0xe3, 0x18, 0x0, 0x0, 0x16, 0x3a}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0x50, 0x39, 0x5c, 0xe6, 0xf7}; + uint8_t bytesprops0[] = {0x81, 0x14, 0x14, 0x4f, 0xbd, 0x7a, 0x4, 0xdf, 0xfb, 0xdb, 0xf5, 0x9f, 0xfc, + 0x8f, 0x44, 0xb4, 0x54, 0x66, 0xff, 0x13, 0xaf, 0x77, 0xb9, 0xd, 0x3b, 0x70}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 110}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19683}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5690}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len; lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 5812, 238, props); + lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 17627, 140, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 5812 238 [PropAuthenticationData "P9\\\230\247",PropSubscriptionIdentifier -// 2,PropSubscriptionIdentifierAvailable 110]) +// COMP (PubCOMP 17627 140 [PropAuthenticationMethod +// "\129\DC4\DC4O\189z\EOT\223\251\219\245\159\252\143D\180Tf\255\DC3\175w\185\r;p",PropSubscriptionIdentifierAvailable +// 9,PropServerKeepAlive 19683,PropWillDelayInterval 5690]) TEST(PubACKCOMP5QCTest, Decode29) { - uint8_t pkt[] = {0x70, 0x10, 0x16, 0xb4, 0xee, 0xc, 0x16, 0x0, 0x5, - 0x50, 0x39, 0x5c, 0xe6, 0xf7, 0xb, 0x2, 0x29, 0x6e}; + uint8_t pkt[] = {0x70, 0x2b, 0x44, 0xdb, 0x8c, 0x27, 0x15, 0x0, 0x1a, 0x81, 0x14, 0x14, 0x4f, 0xbd, 0x7a, + 0x4, 0xdf, 0xfb, 0xdb, 0xf5, 0x9f, 0xfc, 0x8f, 0x44, 0xb4, 0x54, 0x66, 0xff, 0x13, 0xaf, + 0x77, 0xb9, 0xd, 0x3b, 0x70, 0x29, 0x9, 0x13, 0x4c, 0xe3, 0x18, 0x0, 0x0, 0x16, 0x3a}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 5812); - EXPECT_EQ(status, 238); -} - -// COMP (PubCOMP 30696 65 [PropServerKeepAlive 9554,PropContentType "\ESC+\236\172p",PropMaximumPacketSize -// 29701,PropAuthenticationMethod -// "h\254\204\141\200\234\188\&8\242\246\212*B\RS\EM\246\r\168\202\ACKm",PropWillDelayInterval 4219,PropRetainAvailable -// 71,PropRetainAvailable 100,PropMaximumQoS 214,PropSessionExpiryInterval 7076,PropSharedSubscriptionAvailable -// 145,PropServerReference "r\183\253C\157\200k \249w\164\147e=x\179T\134[$\240o\198K",PropRetainAvailable -// 98,PropPayloadFormatIndicator 154,PropServerKeepAlive 31424,PropRequestProblemInformation -// 217,PropSharedSubscriptionAvailable 181,PropPayloadFormatIndicator 219,PropMessageExpiryInterval -// 31400,PropRequestProblemInformation 53,PropServerKeepAlive 18882,PropRequestProblemInformation -// 36,PropSubscriptionIdentifierAvailable 44,PropServerKeepAlive 17813,PropRetainAvailable 254,PropTopicAlias -// 5704,PropAssignedClientIdentifier "|\210\200Vg\247i\133\SUB\221\168y\255",PropMaximumQoS -// 72,PropWildcardSubscriptionAvailable 227,PropSessionExpiryInterval 8466]) + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 17627); + EXPECT_EQ(status, 140); +} + +// COMP (PubCOMP 5627 57 [PropRequestResponseInformation 202]) TEST(PubACKCOMP5QCTest, Encode30) { - uint8_t pkt[] = {0x70, 0x96, 0x1, 0x77, 0xe8, 0x41, 0x91, 0x1, 0x13, 0x25, 0x52, 0x3, 0x0, 0x5, 0x1b, 0x2b, - 0xec, 0xac, 0x70, 0x27, 0x0, 0x0, 0x74, 0x5, 0x15, 0x0, 0x15, 0x68, 0xfe, 0xcc, 0x8d, 0xc8, - 0xea, 0xbc, 0x38, 0xf2, 0xf6, 0xd4, 0x2a, 0x42, 0x1e, 0x19, 0xf6, 0xd, 0xa8, 0xca, 0x6, 0x6d, - 0x18, 0x0, 0x0, 0x10, 0x7b, 0x25, 0x47, 0x25, 0x64, 0x24, 0xd6, 0x11, 0x0, 0x0, 0x1b, 0xa4, - 0x2a, 0x91, 0x1c, 0x0, 0x18, 0x72, 0xb7, 0xfd, 0x43, 0x9d, 0xc8, 0x6b, 0x20, 0xf9, 0x77, 0xa4, - 0x93, 0x65, 0x3d, 0x78, 0xb3, 0x54, 0x86, 0x5b, 0x24, 0xf0, 0x6f, 0xc6, 0x4b, 0x25, 0x62, 0x1, - 0x9a, 0x13, 0x7a, 0xc0, 0x17, 0xd9, 0x2a, 0xb5, 0x1, 0xdb, 0x2, 0x0, 0x0, 0x7a, 0xa8, 0x17, - 0x35, 0x13, 0x49, 0xc2, 0x17, 0x24, 0x29, 0x2c, 0x13, 0x45, 0x95, 0x25, 0xfe, 0x23, 0x16, 0x48, - 0x12, 0x0, 0xd, 0x7c, 0xd2, 0xc8, 0x56, 0x67, 0xf7, 0x69, 0x85, 0x1a, 0xdd, 0xa8, 0x79, 0xff, - 0x24, 0x48, 0x28, 0xe3, 0x11, 0x0, 0x0, 0x21, 0x12}; + uint8_t pkt[] = {0x70, 0x6, 0x15, 0xfb, 0x39, 0x2, 0x19, 0xca}; uint8_t buf[sizeof(pkt) + 10]; - uint8_t bytesprops0[] = {0x1b, 0x2b, 0xec, 0xac, 0x70}; - uint8_t bytesprops1[] = {0x68, 0xfe, 0xcc, 0x8d, 0xc8, 0xea, 0xbc, 0x38, 0xf2, 0xf6, 0xd4, - 0x2a, 0x42, 0x1e, 0x19, 0xf6, 0xd, 0xa8, 0xca, 0x6, 0x6d}; - uint8_t bytesprops2[] = {0x72, 0xb7, 0xfd, 0x43, 0x9d, 0xc8, 0x6b, 0x20, 0xf9, 0x77, 0xa4, 0x93, - 0x65, 0x3d, 0x78, 0xb3, 0x54, 0x86, 0x5b, 0x24, 0xf0, 0x6f, 0xc6, 0x4b}; - uint8_t bytesprops3[] = {0x7c, 0xd2, 0xc8, 0x56, 0x67, 0xf7, 0x69, 0x85, 0x1a, 0xdd, 0xa8, 0x79, 0xff}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9554}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29701}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4219}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 71}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 7076}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 98}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31424}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 181}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31400}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18882}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17813}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5704}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8466}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; size_t len; - lwmqtt_err_t err = - lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 30696, 65, props); + lwmqtt_err_t err = lwmqtt_encode_ack(buf, sizeof(buf), &len, LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, 0, 5627, 57, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// COMP (PubCOMP 30696 65 [PropServerKeepAlive 9554,PropContentType "\ESC+\236\172p",PropMaximumPacketSize -// 29701,PropAuthenticationMethod -// "h\254\204\141\200\234\188\&8\242\246\212*B\RS\EM\246\r\168\202\ACKm",PropWillDelayInterval 4219,PropRetainAvailable -// 71,PropRetainAvailable 100,PropMaximumQoS 214,PropSessionExpiryInterval 7076,PropSharedSubscriptionAvailable -// 145,PropServerReference "r\183\253C\157\200k \249w\164\147e=x\179T\134[$\240o\198K",PropRetainAvailable -// 98,PropPayloadFormatIndicator 154,PropServerKeepAlive 31424,PropRequestProblemInformation -// 217,PropSharedSubscriptionAvailable 181,PropPayloadFormatIndicator 219,PropMessageExpiryInterval -// 31400,PropRequestProblemInformation 53,PropServerKeepAlive 18882,PropRequestProblemInformation -// 36,PropSubscriptionIdentifierAvailable 44,PropServerKeepAlive 17813,PropRetainAvailable 254,PropTopicAlias -// 5704,PropAssignedClientIdentifier "|\210\200Vg\247i\133\SUB\221\168y\255",PropMaximumQoS -// 72,PropWildcardSubscriptionAvailable 227,PropSessionExpiryInterval 8466]) +// COMP (PubCOMP 5627 57 [PropRequestResponseInformation 202]) TEST(PubACKCOMP5QCTest, Decode30) { - uint8_t pkt[] = {0x70, 0x96, 0x1, 0x77, 0xe8, 0x41, 0x91, 0x1, 0x13, 0x25, 0x52, 0x3, 0x0, 0x5, 0x1b, 0x2b, - 0xec, 0xac, 0x70, 0x27, 0x0, 0x0, 0x74, 0x5, 0x15, 0x0, 0x15, 0x68, 0xfe, 0xcc, 0x8d, 0xc8, - 0xea, 0xbc, 0x38, 0xf2, 0xf6, 0xd4, 0x2a, 0x42, 0x1e, 0x19, 0xf6, 0xd, 0xa8, 0xca, 0x6, 0x6d, - 0x18, 0x0, 0x0, 0x10, 0x7b, 0x25, 0x47, 0x25, 0x64, 0x24, 0xd6, 0x11, 0x0, 0x0, 0x1b, 0xa4, - 0x2a, 0x91, 0x1c, 0x0, 0x18, 0x72, 0xb7, 0xfd, 0x43, 0x9d, 0xc8, 0x6b, 0x20, 0xf9, 0x77, 0xa4, - 0x93, 0x65, 0x3d, 0x78, 0xb3, 0x54, 0x86, 0x5b, 0x24, 0xf0, 0x6f, 0xc6, 0x4b, 0x25, 0x62, 0x1, - 0x9a, 0x13, 0x7a, 0xc0, 0x17, 0xd9, 0x2a, 0xb5, 0x1, 0xdb, 0x2, 0x0, 0x0, 0x7a, 0xa8, 0x17, - 0x35, 0x13, 0x49, 0xc2, 0x17, 0x24, 0x29, 0x2c, 0x13, 0x45, 0x95, 0x25, 0xfe, 0x23, 0x16, 0x48, - 0x12, 0x0, 0xd, 0x7c, 0xd2, 0xc8, 0x56, 0x67, 0xf7, 0x69, 0x85, 0x1a, 0xdd, 0xa8, 0x79, 0xff, - 0x24, 0x48, 0x28, 0xe3, 0x11, 0x0, 0x0, 0x21, 0x12}; + uint8_t pkt[] = {0x70, 0x6, 0x15, 0xfb, 0x39, 0x2, 0x19, 0xca}; uint16_t packet_id; uint8_t status; lwmqtt_serialized_properties_t props; bool dup; lwmqtt_err_t err = lwmqtt_decode_ack(pkt, sizeof(pkt), LWMQTT_MQTT5, LWMQTT_PUBCOMP_PACKET, &dup, &packet_id, &status, &props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 30696); - EXPECT_EQ(status, 65); + EXPECT_EQ(err, LWMQTT_PUBACK_NACKED); + EXPECT_EQ(packet_id, 5627); + EXPECT_EQ(status, 57); } -// ConnectRequest {_username = Just "]k\133\158\155\DC3\CANdB\149\244\NAKV\174", _password = Just -// "\243e\SUB\196D\v\196W8P\245\&6", _lastWill = Nothing, _cleanSession = True, _keepAlive = 1258, _connID = -// "q\SOH\220\128\ncN%\188\&7\248FP@\170\NUL\DELN\194\221o", _properties = []} +// ConnectRequest {_username = Just "\153L\a#", _password = Just "\244\162\153\142%\219Js!\226", _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 2234, _connID = "E\DC4X\158P\157\128Y{\243sRl\186'", _properties = []} TEST(Connect311QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0x3f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x4, 0xea, 0x0, 0x15, 0x71, 0x1, 0xdc, - 0x80, 0xa, 0x63, 0x4e, 0x25, 0xbc, 0x37, 0xf8, 0x46, 0x50, 0x40, 0xaa, 0x0, 0x7f, 0x4e, 0xc2, 0xdd, - 0x6f, 0x0, 0xe, 0x5d, 0x6b, 0x85, 0x9e, 0x9b, 0x13, 0x18, 0x64, 0x42, 0x95, 0xf4, 0x15, 0x56, 0xae, - 0x0, 0xc, 0xf3, 0x65, 0x1a, 0xc4, 0x44, 0xb, 0xc4, 0x57, 0x38, 0x50, 0xf5, 0x36}; + uint8_t pkt[] = {0x10, 0x2d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x8, 0xba, 0x0, 0xf, 0x45, 0x14, + 0x58, 0x9e, 0x50, 0x9d, 0x80, 0x59, 0x7b, 0xf3, 0x73, 0x52, 0x6c, 0xba, 0x27, 0x0, 0x4, 0x99, + 0x4c, 0x7, 0x23, 0x0, 0xa, 0xf4, 0xa2, 0x99, 0x8e, 0x25, 0xdb, 0x4a, 0x73, 0x21, 0xe2}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -8790,16 +8292,16 @@ TEST(Connect311QCTest, Encode1) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 1258; - uint8_t client_id_bytes[] = {0x71, 0x1, 0xdc, 0x80, 0xa, 0x63, 0x4e, 0x25, 0xbc, 0x37, 0xf8, - 0x46, 0x50, 0x40, 0xaa, 0x0, 0x7f, 0x4e, 0xc2, 0xdd, 0x6f}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.keep_alive = 2234; + uint8_t client_id_bytes[] = {0x45, 0x14, 0x58, 0x9e, 0x50, 0x9d, 0x80, 0x59, + 0x7b, 0xf3, 0x73, 0x52, 0x6c, 0xba, 0x27}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x5d, 0x6b, 0x85, 0x9e, 0x9b, 0x13, 0x18, 0x64, 0x42, 0x95, 0xf4, 0x15, 0x56, 0xae}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x99, 0x4c, 0x7, 0x23}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xf3, 0x65, 0x1a, 0xc4, 0x44, 0xb, 0xc4, 0x57, 0x38, 0x50, 0xf5, 0x36}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xf4, 0xa2, 0x99, 0x8e, 0x25, 0xdb, 0x4a, 0x73, 0x21, 0xe2}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); @@ -8809,18 +8311,18 @@ TEST(Connect311QCTest, Encode1) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "G>+\146\187X\SUB\205\220Z.\247\207\STX", _password = Just "l\254", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "H\158\252\SO\244\128\177\DC3\140m\154C\228\255\209\SO\252\215Wt\129t}\131", _willMsg = -// ";\228r\149\RS]\243u\250o\247\164,_\199", _willProps = []}), _cleanSession = False, _keepAlive = 6895, _connID = -// "/\215\GS\133\&67\233\250\218\RS\249)\ETB", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just +// "\254\241\198\183\211\244\131\&2\170\194\EOT\SYN\226H\226\&0\134\t\187'", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS1, _willTopic = +// "\228\176\251j\SI\151m\GS}\147\222\ft\169!\153b\159\254\208\202\212\233\153\231\SUB\175\224\138", _willMsg = +// "\EOT\138\DC3b\NUL\226X\227XU\t\166\177\SOHR\DEL\DC4vC\132", _willProps = []}), _cleanSession = True, _keepAlive = +// 6210, _connID = "\194\231\179\200\206\DLE\208\132\139\v\171\161\163\159\153", _properties = []} TEST(Connect311QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x58, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xec, 0x1a, 0xef, 0x0, 0xd, 0x2f, - 0xd7, 0x1d, 0x85, 0x36, 0x37, 0xe9, 0xfa, 0xda, 0x1e, 0xf9, 0x29, 0x17, 0x0, 0x18, 0x48, - 0x9e, 0xfc, 0xe, 0xf4, 0x80, 0xb1, 0x13, 0x8c, 0x6d, 0x9a, 0x43, 0xe4, 0xff, 0xd1, 0xe, - 0xfc, 0xd7, 0x57, 0x74, 0x81, 0x74, 0x7d, 0x83, 0x0, 0xf, 0x3b, 0xe4, 0x72, 0x95, 0x1e, - 0x5d, 0xf3, 0x75, 0xfa, 0x6f, 0xf7, 0xa4, 0x2c, 0x5f, 0xc7, 0x0, 0xe, 0x47, 0x3e, 0x2b, - 0x92, 0xbb, 0x58, 0x1a, 0xcd, 0xdc, 0x5a, 0x2e, 0xf7, 0xcf, 0x2, 0x0, 0x2, 0x6c, 0xfe}; + uint8_t pkt[] = {0x10, 0x50, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2e, 0x18, 0x42, 0x0, 0xf, 0xc2, 0xe7, 0xb3, + 0xc8, 0xce, 0x10, 0xd0, 0x84, 0x8b, 0xb, 0xab, 0xa1, 0xa3, 0x9f, 0x99, 0x0, 0x1d, 0xe4, 0xb0, 0xfb, + 0x6a, 0xf, 0x97, 0x6d, 0x1d, 0x7d, 0x93, 0xde, 0xc, 0x74, 0xa9, 0x21, 0x99, 0x62, 0x9f, 0xfe, 0xd0, + 0xca, 0xd4, 0xe9, 0x99, 0xe7, 0x1a, 0xaf, 0xe0, 0x8a, 0x0, 0x14, 0x4, 0x8a, 0x13, 0x62, 0x0, 0xe2, + 0x58, 0xe3, 0x58, 0x55, 0x9, 0xa6, 0xb1, 0x1, 0x52, 0x7f, 0x14, 0x76, 0x43, 0x84}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -8831,12 +8333,13 @@ TEST(Connect311QCTest, Encode2) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x48, 0x9e, 0xfc, 0xe, 0xf4, 0x80, 0xb1, 0x13, 0x8c, 0x6d, 0x9a, 0x43, - 0xe4, 0xff, 0xd1, 0xe, 0xfc, 0xd7, 0x57, 0x74, 0x81, 0x74, 0x7d, 0x83}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3b, 0xe4, 0x72, 0x95, 0x1e, 0x5d, 0xf3, 0x75, - 0xfa, 0x6f, 0xf7, 0xa4, 0x2c, 0x5f, 0xc7}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xe4, 0xb0, 0xfb, 0x6a, 0xf, 0x97, 0x6d, 0x1d, 0x7d, 0x93, + 0xde, 0xc, 0x74, 0xa9, 0x21, 0x99, 0x62, 0x9f, 0xfe, 0xd0, + 0xca, 0xd4, 0xe9, 0x99, 0xe7, 0x1a, 0xaf, 0xe0, 0x8a}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4, 0x8a, 0x13, 0x62, 0x0, 0xe2, 0x58, 0xe3, 0x58, 0x55, + 0x9, 0xa6, 0xb1, 0x1, 0x52, 0x7f, 0x14, 0x76, 0x43, 0x84}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -8844,16 +8347,14 @@ TEST(Connect311QCTest, Encode2) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 6895; - uint8_t client_id_bytes[] = {0x2f, 0xd7, 0x1d, 0x85, 0x36, 0x37, 0xe9, 0xfa, 0xda, 0x1e, 0xf9, 0x29, 0x17}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 6210; + uint8_t client_id_bytes[] = {0xc2, 0xe7, 0xb3, 0xc8, 0xce, 0x10, 0xd0, 0x84, 0x8b, 0xb, 0xab, 0xa1, 0xa3, 0x9f, 0x99}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x47, 0x3e, 0x2b, 0x92, 0xbb, 0x58, 0x1a, 0xcd, 0xdc, 0x5a, 0x2e, 0xf7, 0xcf, 0x2}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6c, 0xfe}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xfe, 0xf1, 0xc6, 0xb7, 0xd3, 0xf4, 0x83, 0x32, 0xaa, 0xc2, + 0x4, 0x16, 0xe2, 0x48, 0xe2, 0x30, 0x86, 0x9, 0xbb, 0x27}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -8863,71 +8364,40 @@ TEST(Connect311QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "P\174D\148^\175O\GS", _password = Nothing, _lastWill = Just (LastWill {_willRetain -// = True, _willQoS = QoS0, _willTopic = -// "\133\148;\217\ETX\ESCx\227\193\b\220\220\&2^\206\247,\208\184E\206g\130\RS\174\176\224", _willMsg = -// "&2\134`\139\156\254r\254!RA2\206\243\188", _willProps = []}), _cleanSession = False, _keepAlive = 25004, _connID = -// "/}b5\208\133\FS\133\214c\NUL\151\144\NUL\172\SO\168&&\150\174\191N\206", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "3m\161\216\&1\215\GS", _lastWill = Nothing, _cleanSession = +// True, _keepAlive = 22788, _connID = "", _properties = []} TEST(Connect311QCTest, Encode3) { - uint8_t pkt[] = {0x10, 0x5d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa4, 0x61, 0xac, 0x0, 0x18, 0x2f, 0x7d, - 0x62, 0x35, 0xd0, 0x85, 0x1c, 0x85, 0xd6, 0x63, 0x0, 0x97, 0x90, 0x0, 0xac, 0xe, 0xa8, 0x26, - 0x26, 0x96, 0xae, 0xbf, 0x4e, 0xce, 0x0, 0x1b, 0x85, 0x94, 0x3b, 0xd9, 0x3, 0x1b, 0x78, 0xe3, - 0xc1, 0x8, 0xdc, 0xdc, 0x32, 0x5e, 0xce, 0xf7, 0x2c, 0xd0, 0xb8, 0x45, 0xce, 0x67, 0x82, 0x1e, - 0xae, 0xb0, 0xe0, 0x0, 0x10, 0x26, 0x32, 0x86, 0x60, 0x8b, 0x9c, 0xfe, 0x72, 0xfe, 0x21, 0x52, - 0x41, 0x32, 0xce, 0xf3, 0xbc, 0x0, 0x8, 0x50, 0xae, 0x44, 0x94, 0x5e, 0xaf, 0x4f, 0x1d}; + uint8_t pkt[] = {0x10, 0xc, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x59, 0x4, 0x0, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x85, 0x94, 0x3b, 0xd9, 0x3, 0x1b, 0x78, 0xe3, 0xc1, 0x8, 0xdc, 0xdc, 0x32, 0x5e, - 0xce, 0xf7, 0x2c, 0xd0, 0xb8, 0x45, 0xce, 0x67, 0x82, 0x1e, 0xae, 0xb0, 0xe0}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x26, 0x32, 0x86, 0x60, 0x8b, 0x9c, 0xfe, 0x72, - 0xfe, 0x21, 0x52, 0x41, 0x32, 0xce, 0xf3, 0xbc}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 25004; - uint8_t client_id_bytes[] = {0x2f, 0x7d, 0x62, 0x35, 0xd0, 0x85, 0x1c, 0x85, 0xd6, 0x63, 0x0, 0x97, - 0x90, 0x0, 0xac, 0xe, 0xa8, 0x26, 0x26, 0x96, 0xae, 0xbf, 0x4e, 0xce}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 22788; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x50, 0xae, 0x44, 0x94, 0x5e, 0xaf, 0x4f, 0x1d}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; + uint8_t password_bytes[] = {0x33, 0x6d, 0xa1, 0xd8, 0x31, 0xd7, 0x1d}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; + opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "t~B\193\194g\135.\205\195'\202\&4\254\167\130&}\131\SO(", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\167\209\SI\144\184\148\175\153P3\152[\245s\f\160\STX\173\250\248\&6|\vh\134\236\&6\214\237E", _willMsg = -// "K9\178\239\192\180\&4\159\238\219\254cw\137\\K\177\175\230", _willProps = []}), _cleanSession = False, _keepAlive = -// 30510, _connID = "\254\DC1x\142\180\241\164\178u\EMn\150\196Ks\174\214\175\228\181\167\162I=\146!", _willMsg = "2\138c9\234`\186@\186E\164\&9+", -// _willProps = []}), _cleanSession = False, _keepAlive = 19395, _connID = -// "\149n\238G\238\237)\201\164\252\154Z`O\144Gm\245xzg\DC3P", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "\175", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS0, _willTopic = +// "\CAN#\232\218\132C\SOH\233l\168\204\182\128\&1\147\ETX\185\184Y\254<\192\170M\137\143\185", _willMsg = +// "L\\3\170\149\249|cG", _willProps = []}), _cleanSession = False, _keepAlive = 10327, _connID = "\197F\a\173", +// _properties = []} TEST(Connect311QCTest, Encode9) { - uint8_t pkt[] = {0x10, 0x5f, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x4b, 0xc3, 0x0, 0x17, 0x95, 0x6e, 0xee, - 0x47, 0xee, 0xed, 0x29, 0xc9, 0xa4, 0xfc, 0x9a, 0x5a, 0x60, 0x4f, 0x90, 0x47, 0x6d, 0xf5, 0x78, 0x7a, - 0x67, 0x13, 0x50, 0x0, 0x14, 0xb6, 0xd2, 0xd2, 0xd0, 0xa1, 0x2a, 0xa, 0x67, 0x3e, 0xae, 0xd6, 0xaf, - 0xe4, 0xb5, 0xa7, 0xa2, 0x49, 0x3d, 0x92, 0x21, 0x0, 0xd, 0x32, 0x8a, 0x63, 0x39, 0xea, 0x60, 0xba, - 0x40, 0xba, 0x45, 0xa4, 0x39, 0x2b, 0x0, 0x6, 0x3f, 0xd4, 0x9a, 0xea, 0x81, 0x81, 0x0, 0xd, 0x70, - 0x7e, 0x29, 0x7f, 0x56, 0x76, 0xe8, 0x4, 0x2c, 0x1a, 0x8e, 0x61, 0xdf}; + uint8_t pkt[] = {0x10, 0x38, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0x28, 0x57, 0x0, 0x4, 0xc5, + 0x46, 0x7, 0xad, 0x0, 0x1b, 0x18, 0x23, 0xe8, 0xda, 0x84, 0x43, 0x1, 0xe9, 0x6c, 0xa8, + 0xcc, 0xb6, 0x80, 0x31, 0x93, 0x3, 0xb9, 0xb8, 0x59, 0xfe, 0x3c, 0xc0, 0xaa, 0x4d, 0x89, + 0x8f, 0xb9, 0x0, 0x9, 0x4c, 0x5c, 0x33, 0xaa, 0x95, 0xf9, 0x7c, 0x63, 0x47}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9159,29 +8631,25 @@ TEST(Connect311QCTest, Encode9) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb6, 0xd2, 0xd2, 0xd0, 0xa1, 0x2a, 0xa, 0x67, 0x3e, 0xae, - 0xd6, 0xaf, 0xe4, 0xb5, 0xa7, 0xa2, 0x49, 0x3d, 0x92, 0x21}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x32, 0x8a, 0x63, 0x39, 0xea, 0x60, 0xba, 0x40, 0xba, 0x45, 0xa4, 0x39, 0x2b}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x18, 0x23, 0xe8, 0xda, 0x84, 0x43, 0x1, 0xe9, 0x6c, 0xa8, 0xcc, 0xb6, 0x80, 0x31, + 0x93, 0x3, 0xb9, 0xb8, 0x59, 0xfe, 0x3c, 0xc0, 0xaa, 0x4d, 0x89, 0x8f, 0xb9}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4c, 0x5c, 0x33, 0xaa, 0x95, 0xf9, 0x7c, 0x63, 0x47}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 19395; - uint8_t client_id_bytes[] = {0x95, 0x6e, 0xee, 0x47, 0xee, 0xed, 0x29, 0xc9, 0xa4, 0xfc, 0x9a, 0x5a, - 0x60, 0x4f, 0x90, 0x47, 0x6d, 0xf5, 0x78, 0x7a, 0x67, 0x13, 0x50}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 10327; + uint8_t client_id_bytes[] = {0xc5, 0x46, 0x7, 0xad}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x3f, 0xd4, 0x9a, 0xea, 0x81, 0x81}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x70, 0x7e, 0x29, 0x7f, 0x56, 0x76, 0xe8, 0x4, 0x2c, 0x1a, 0x8e, 0x61, 0xdf}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xaf}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9191,73 +8659,54 @@ TEST(Connect311QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\150\213\175\169yq`\DC3\185\158\240\US\228H\158\158\192\153", _password = Just -// "\206c\DC1\187", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "'gY\b\203\149\DC3\206\CAN<\CAN\177\205$a\160\135", _willMsg = -// "\162<\STX\222\185\208\196\140\169\175\155\150\NAK\216\r\145\194\173\159\210/\222\f\180\NAK=", _willProps = []}), -// _cleanSession = True, _keepAlive = 5366, _connID = "\230\209$f\202\238\227", _properties = []} +// ConnectRequest {_username = Just "\161M\139\STX'\150/\148\f\226\225\132", _password = Just "F\225WbF\224\168", +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 18820, _connID = +// "\239\187K\240\&8zO\aU|\SI\206\249i\178\203\168", _properties = []} TEST(Connect311QCTest, Encode10) { - uint8_t pkt[] = {0x10, 0x5c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd6, 0x14, 0xf6, 0x0, 0x7, 0xe6, 0xd1, - 0x24, 0x66, 0xca, 0xee, 0xe3, 0x0, 0x11, 0x27, 0x67, 0x59, 0x8, 0xcb, 0x95, 0x13, 0xce, 0x18, - 0x3c, 0x18, 0xb1, 0xcd, 0x24, 0x61, 0xa0, 0x87, 0x0, 0x1a, 0xa2, 0x3c, 0x2, 0xde, 0xb9, 0xd0, - 0xc4, 0x8c, 0xa9, 0xaf, 0x9b, 0x96, 0x15, 0xd8, 0xd, 0x91, 0xc2, 0xad, 0x9f, 0xd2, 0x2f, 0xde, - 0xc, 0xb4, 0x15, 0x3d, 0x0, 0x12, 0x96, 0xd5, 0xaf, 0xa9, 0x79, 0x71, 0x60, 0x13, 0xb9, 0x9e, - 0xf0, 0x1f, 0xe4, 0x48, 0x9e, 0x9e, 0xc0, 0x99, 0x0, 0x4, 0xce, 0x63, 0x11, 0xbb}; + uint8_t pkt[] = {0x10, 0x34, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x49, 0x84, 0x0, 0x11, + 0xef, 0xbb, 0x4b, 0xf0, 0x38, 0x7a, 0x4f, 0x7, 0x55, 0x7c, 0xf, 0xce, 0xf9, 0x69, + 0xb2, 0xcb, 0xa8, 0x0, 0xc, 0xa1, 0x4d, 0x8b, 0x2, 0x27, 0x96, 0x2f, 0x94, 0xc, + 0xe2, 0xe1, 0x84, 0x0, 0x7, 0x46, 0xe1, 0x57, 0x62, 0x46, 0xe0, 0xa8}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x27, 0x67, 0x59, 0x8, 0xcb, 0x95, 0x13, 0xce, 0x18, - 0x3c, 0x18, 0xb1, 0xcd, 0x24, 0x61, 0xa0, 0x87}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa2, 0x3c, 0x2, 0xde, 0xb9, 0xd0, 0xc4, 0x8c, 0xa9, 0xaf, 0x9b, 0x96, 0x15, - 0xd8, 0xd, 0x91, 0xc2, 0xad, 0x9f, 0xd2, 0x2f, 0xde, 0xc, 0xb4, 0x15, 0x3d}; - lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 5366; - uint8_t client_id_bytes[] = {0xe6, 0xd1, 0x24, 0x66, 0xca, 0xee, 0xe3}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 18820; + uint8_t client_id_bytes[] = {0xef, 0xbb, 0x4b, 0xf0, 0x38, 0x7a, 0x4f, 0x7, 0x55, + 0x7c, 0xf, 0xce, 0xf9, 0x69, 0xb2, 0xcb, 0xa8}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x96, 0xd5, 0xaf, 0xa9, 0x79, 0x71, 0x60, 0x13, 0xb9, - 0x9e, 0xf0, 0x1f, 0xe4, 0x48, 0x9e, 0x9e, 0xc0, 0x99}; - lwmqtt_string_t username = {18, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xa1, 0x4d, 0x8b, 0x2, 0x27, 0x96, 0x2f, 0x94, 0xc, 0xe2, 0xe1, 0x84}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xce, 0x63, 0x11, 0xbb}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x46, 0xe1, 0x57, 0x62, 0x46, 0xe0, 0xa8}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\129\128\161\159\147\245-e\bJ_\149 \184p.t,\236Q\211\160XD\SUB\239\DEL\DC2\144", -// _password = Just "\240\244", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = -// "\135\ETXg\SIO\185\150d\172+QZ", _willMsg = "\232\GS\202P\180x\186\243}<\155\148:\217\145'", _willProps = []}), -// _cleanSession = True, _keepAlive = 30463, _connID = "\171v+\163\172\203\229S\191\242VUR\b\DLE\179J\234", _properties -// = []} +// ConnectRequest {_username = Just "\212\246\v\208Q", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS0, _willTopic = "\DC4\STX\237+\169PM5-\137\&2\143\DC1I\143\ETB8R\205\"+\207'\229\244", _willMsg +// = "*\236\193\FS\231\145S\224#\173\"\224\223\227\142\242*i\131\&8\203\156x\161\231Z", _willProps = []}), _cleanSession +// = True, _keepAlive = 25243, _connID = "\183\141\187\211\227F!\186\233+s9c^7\154\b\193Y\148\174w\216=\234K1", +// _properties = []} TEST(Connect311QCTest, Encode11) { - uint8_t pkt[] = {0x10, 0x61, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x76, 0xff, 0x0, 0x12, 0xab, 0x76, 0x2b, - 0xa3, 0xac, 0xcb, 0xe5, 0x53, 0xbf, 0xf2, 0x56, 0x55, 0x52, 0x8, 0x10, 0xb3, 0x4a, 0xea, 0x0, 0xc, - 0x87, 0x3, 0x67, 0xf, 0x4f, 0xb9, 0x96, 0x64, 0xac, 0x2b, 0x51, 0x5a, 0x0, 0x10, 0xe8, 0x1d, 0xca, - 0x50, 0xb4, 0x78, 0xba, 0xf3, 0x7d, 0x3c, 0x9b, 0x94, 0x3a, 0xd9, 0x91, 0x27, 0x0, 0x1d, 0x81, 0x80, - 0xa1, 0x9f, 0x93, 0xf5, 0x2d, 0x65, 0x8, 0x4a, 0x5f, 0x95, 0x20, 0xb8, 0x70, 0x2e, 0x74, 0x2c, 0xec, - 0x51, 0xd3, 0xa0, 0x58, 0x44, 0x1a, 0xef, 0x7f, 0x12, 0x90, 0x0, 0x2, 0xf0, 0xf4}; + uint8_t pkt[] = {0x10, 0x65, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x86, 0x62, 0x9b, 0x0, 0x1b, 0xb7, + 0x8d, 0xbb, 0xd3, 0xe3, 0x46, 0x21, 0xba, 0xe9, 0x2b, 0x73, 0x39, 0x63, 0x5e, 0x37, 0x9a, + 0x8, 0xc1, 0x59, 0x94, 0xae, 0x77, 0xd8, 0x3d, 0xea, 0x4b, 0x31, 0x0, 0x19, 0x14, 0x2, + 0xed, 0x2b, 0xa9, 0x50, 0x4d, 0x35, 0x2d, 0x89, 0x32, 0x8f, 0x11, 0x49, 0x8f, 0x17, 0x38, + 0x52, 0xcd, 0x22, 0x2b, 0xcf, 0x27, 0xe5, 0xf4, 0x0, 0x1a, 0x2a, 0xec, 0xc1, 0x1c, 0xe7, + 0x91, 0x53, 0xe0, 0x23, 0xad, 0x22, 0xe0, 0xdf, 0xe3, 0x8e, 0xf2, 0x2a, 0x69, 0x83, 0x38, + 0xcb, 0x9c, 0x78, 0xa1, 0xe7, 0x5a, 0x0, 0x5, 0xd4, 0xf6, 0xb, 0xd0, 0x51}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9268,31 +8717,28 @@ TEST(Connect311QCTest, Encode11) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x87, 0x3, 0x67, 0xf, 0x4f, 0xb9, 0x96, 0x64, 0xac, 0x2b, 0x51, 0x5a}; - lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe8, 0x1d, 0xca, 0x50, 0xb4, 0x78, 0xba, 0xf3, - 0x7d, 0x3c, 0x9b, 0x94, 0x3a, 0xd9, 0x91, 0x27}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x14, 0x2, 0xed, 0x2b, 0xa9, 0x50, 0x4d, 0x35, 0x2d, 0x89, 0x32, 0x8f, 0x11, + 0x49, 0x8f, 0x17, 0x38, 0x52, 0xcd, 0x22, 0x2b, 0xcf, 0x27, 0xe5, 0xf4}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2a, 0xec, 0xc1, 0x1c, 0xe7, 0x91, 0x53, 0xe0, 0x23, 0xad, 0x22, 0xe0, 0xdf, + 0xe3, 0x8e, 0xf2, 0x2a, 0x69, 0x83, 0x38, 0xcb, 0x9c, 0x78, 0xa1, 0xe7, 0x5a}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 30463; - uint8_t client_id_bytes[] = {0xab, 0x76, 0x2b, 0xa3, 0xac, 0xcb, 0xe5, 0x53, 0xbf, - 0xf2, 0x56, 0x55, 0x52, 0x8, 0x10, 0xb3, 0x4a, 0xea}; - lwmqtt_string_t client_id = {18, (char*)&client_id_bytes}; + opts.keep_alive = 25243; + uint8_t client_id_bytes[] = {0xb7, 0x8d, 0xbb, 0xd3, 0xe3, 0x46, 0x21, 0xba, 0xe9, 0x2b, 0x73, 0x39, 0x63, 0x5e, + 0x37, 0x9a, 0x8, 0xc1, 0x59, 0x94, 0xae, 0x77, 0xd8, 0x3d, 0xea, 0x4b, 0x31}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x81, 0x80, 0xa1, 0x9f, 0x93, 0xf5, 0x2d, 0x65, 0x8, 0x4a, 0x5f, 0x95, 0x20, 0xb8, 0x70, - 0x2e, 0x74, 0x2c, 0xec, 0x51, 0xd3, 0xa0, 0x58, 0x44, 0x1a, 0xef, 0x7f, 0x12, 0x90}; - lwmqtt_string_t username = {29, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xd4, 0xf6, 0xb, 0xd0, 0x51}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xf0, 0xf4}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9301,18 +8747,16 @@ TEST(Connect311QCTest, Encode11) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just ".2\214\236%\167C\190\248\193\211@$\248", _password = Nothing, _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\211\192\177\134\&8\245\197\148\144\238\147T?", -// _willMsg = "Ws\ETB\210;\DC3\230~\159t\212k(\175\174\"\239\CAN\193\229\255", _willProps = []}), _cleanSession = False, -// _keepAlive = 24806, _connID = "\226W\228\136%h\248C\190\131\204\147f\NAKn\148 \184\208#\240\FSf\FS3T\231", -// _properties = []} +// ConnectRequest {_username = Just "\202\139\128\189r\251\250\210\176K\157gL\180\ESC\252\232\242\141\NULV\217", +// _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = +// "\204\246\221\166\146\242\STXG5", _willMsg = "P\228\ETX:\163\230z\150\184Jo\FS=\189\NUL\196", _willProps = []}), +// _cleanSession = True, _keepAlive = 11253, _connID = "\239\DEL\DC2\154\161@0\234\178\ad", _properties = []} TEST(Connect311QCTest, Encode12) { - uint8_t pkt[] = {0x10, 0x5d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xac, 0x60, 0xe6, 0x0, 0x1b, 0xe2, 0x57, - 0xe4, 0x88, 0x25, 0x68, 0xf8, 0x43, 0xbe, 0x83, 0xcc, 0x93, 0x66, 0x15, 0x6e, 0x94, 0x20, 0xb8, - 0xd0, 0x23, 0xf0, 0x1c, 0x66, 0x1c, 0x33, 0x54, 0xe7, 0x0, 0xd, 0xd3, 0xc0, 0xb1, 0x86, 0x38, - 0xf5, 0xc5, 0x94, 0x90, 0xee, 0x93, 0x54, 0x3f, 0x0, 0x15, 0x57, 0x73, 0x17, 0xd2, 0x3b, 0x13, - 0xe6, 0x7e, 0x9f, 0x74, 0xd4, 0x6b, 0x28, 0xaf, 0xae, 0x22, 0xef, 0x18, 0xc1, 0xe5, 0xff, 0x0, - 0xe, 0x2e, 0x32, 0xd6, 0xec, 0x25, 0xa7, 0x43, 0xbe, 0xf8, 0xc1, 0xd3, 0x40, 0x24, 0xf8}; + uint8_t pkt[] = {0x10, 0x4c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x86, 0x2b, 0xf5, 0x0, 0xb, 0xef, 0x7f, + 0x12, 0x9a, 0xa1, 0x40, 0x30, 0xea, 0xb2, 0x7, 0x64, 0x0, 0x9, 0xcc, 0xf6, 0xdd, 0xa6, 0x92, + 0xf2, 0x2, 0x47, 0x35, 0x0, 0x10, 0x50, 0xe4, 0x3, 0x3a, 0xa3, 0xe6, 0x7a, 0x96, 0xb8, 0x4a, + 0x6f, 0x1c, 0x3d, 0xbd, 0x0, 0xc4, 0x0, 0x16, 0xca, 0x8b, 0x80, 0xbd, 0x72, 0xfb, 0xfa, 0xd2, + 0xb0, 0x4b, 0x9d, 0x67, 0x4c, 0xb4, 0x1b, 0xfc, 0xe8, 0xf2, 0x8d, 0x0, 0x56, 0xd9}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9323,26 +8767,26 @@ TEST(Connect311QCTest, Encode12) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd3, 0xc0, 0xb1, 0x86, 0x38, 0xf5, 0xc5, 0x94, 0x90, 0xee, 0x93, 0x54, 0x3f}; - lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x57, 0x73, 0x17, 0xd2, 0x3b, 0x13, 0xe6, 0x7e, 0x9f, 0x74, 0xd4, - 0x6b, 0x28, 0xaf, 0xae, 0x22, 0xef, 0x18, 0xc1, 0xe5, 0xff}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xcc, 0xf6, 0xdd, 0xa6, 0x92, 0xf2, 0x2, 0x47, 0x35}; + lwmqtt_string_t will_topic = {9, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x50, 0xe4, 0x3, 0x3a, 0xa3, 0xe6, 0x7a, 0x96, + 0xb8, 0x4a, 0x6f, 0x1c, 0x3d, 0xbd, 0x0, 0xc4}; + lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; + will.qos = LWMQTT_QOS0; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 24806; - uint8_t client_id_bytes[] = {0xe2, 0x57, 0xe4, 0x88, 0x25, 0x68, 0xf8, 0x43, 0xbe, 0x83, 0xcc, 0x93, 0x66, 0x15, - 0x6e, 0x94, 0x20, 0xb8, 0xd0, 0x23, 0xf0, 0x1c, 0x66, 0x1c, 0x33, 0x54, 0xe7}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 11253; + uint8_t client_id_bytes[] = {0xef, 0x7f, 0x12, 0x9a, 0xa1, 0x40, 0x30, 0xea, 0xb2, 0x7, 0x64}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2e, 0x32, 0xd6, 0xec, 0x25, 0xa7, 0x43, 0xbe, 0xf8, 0xc1, 0xd3, 0x40, 0x24, 0xf8}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xca, 0x8b, 0x80, 0xbd, 0x72, 0xfb, 0xfa, 0xd2, 0xb0, 0x4b, 0x9d, + 0x67, 0x4c, 0xb4, 0x1b, 0xfc, 0xe8, 0xf2, 0x8d, 0x0, 0x56, 0xd9}; + lwmqtt_string_t username = {22, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9352,15 +8796,16 @@ TEST(Connect311QCTest, Encode12) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\RST\210\144\vR\152\r\144sH\140S\216X\252D\232\156", _lastWill -// = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\DC3\214I\EM\233B\b", _willMsg = -// "iT\rof/\249~4Z(<[iN\168@!g", _willProps = []}), _cleanSession = False, _keepAlive = 10052, _connID = -// "\ENQB\207E\189\199FE\196\245\ACK\135\200N\n\187\177\209\128\171", _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = +// QoS1, _willTopic = "\DC2\EOT\246\144\&2c\156AGN\a\249~", _willMsg = +// "\239~\221\167\215\204Q\f\\\186Q\198<\DC4\220~\217%", _willProps = []}), _cleanSession = False, _keepAlive = 28636, +// _connID = "\GS \174N\196\134\134\164\ACK;!#]\239\168\159\231\208f", _properties = []} TEST(Connect311QCTest, Encode13) { - uint8_t pkt[] = {0x10, 0x3e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x4, 0x27, 0x44, 0x0, 0x14, 0x5, 0x42, - 0xcf, 0x45, 0xbd, 0xc7, 0x46, 0x45, 0xc4, 0xf5, 0x6, 0x87, 0xc8, 0x4e, 0xa, 0xbb, 0xb1, 0xd1, - 0x80, 0xab, 0x0, 0x7, 0x13, 0xd6, 0x49, 0x19, 0xe9, 0x42, 0x8, 0x0, 0x13, 0x69, 0x54, 0xd, - 0x6f, 0x66, 0x2f, 0xf9, 0x7e, 0x34, 0x5a, 0x28, 0x3c, 0x5b, 0x69, 0x4e, 0xa8, 0x40, 0x21, 0x67}; + uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc, 0x6f, 0xdc, 0x0, 0x13, + 0x1d, 0x20, 0xae, 0x4e, 0xc4, 0x86, 0x86, 0xa4, 0x6, 0x3b, 0x21, 0x23, 0x5d, 0xef, + 0xa8, 0x9f, 0xe7, 0xd0, 0x66, 0x0, 0xd, 0x12, 0x4, 0xf6, 0x90, 0x32, 0x63, 0x9c, + 0x41, 0x47, 0x4e, 0x7, 0xf9, 0x7e, 0x0, 0x12, 0xef, 0x7e, 0xdd, 0xa7, 0xd7, 0xcc, + 0x51, 0xc, 0x5c, 0xba, 0x51, 0xc6, 0x3c, 0x14, 0xdc, 0x7e, 0xd9, 0x25}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9371,28 +8816,24 @@ TEST(Connect311QCTest, Encode13) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x13, 0xd6, 0x49, 0x19, 0xe9, 0x42, 0x8}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x69, 0x54, 0xd, 0x6f, 0x66, 0x2f, 0xf9, 0x7e, 0x34, 0x5a, - 0x28, 0x3c, 0x5b, 0x69, 0x4e, 0xa8, 0x40, 0x21, 0x67}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x12, 0x4, 0xf6, 0x90, 0x32, 0x63, 0x9c, 0x41, 0x47, 0x4e, 0x7, 0xf9, 0x7e}; + lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xef, 0x7e, 0xdd, 0xa7, 0xd7, 0xcc, 0x51, 0xc, 0x5c, + 0xba, 0x51, 0xc6, 0x3c, 0x14, 0xdc, 0x7e, 0xd9, 0x25}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 10052; - uint8_t client_id_bytes[] = {0x5, 0x42, 0xcf, 0x45, 0xbd, 0xc7, 0x46, 0x45, 0xc4, 0xf5, - 0x6, 0x87, 0xc8, 0x4e, 0xa, 0xbb, 0xb1, 0xd1, 0x80, 0xab}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.keep_alive = 28636; + uint8_t client_id_bytes[] = {0x1d, 0x20, 0xae, 0x4e, 0xc4, 0x86, 0x86, 0xa4, 0x6, 0x3b, + 0x21, 0x23, 0x5d, 0xef, 0xa8, 0x9f, 0xe7, 0xd0, 0x66}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x1e, 0x54, 0xd2, 0x90, 0xb, 0x52, 0x98, 0xd, 0x90, 0x73, - 0x48, 0x8c, 0x53, 0xd8, 0x58, 0xfc, 0x44, 0xe8, 0x9c}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9401,15 +8842,16 @@ TEST(Connect311QCTest, Encode13) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "jp\210\SYN<%F\215\168\207J\225\152z\151X\253\132\"", _password = Nothing, _lastWill -// = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\181J\251\141\ETX", _willMsg = "|\ETB", -// _willProps = []}), _cleanSession = True, _keepAlive = 2920, _connID = -// "\203M+\171|\132nj\193\FS\a\\\DC1\230\202\DC2Id;\200", _properties = []} +// ConnectRequest {_username = Just "\242\255\248\RSlqy\210\165\223EJs\218\138\195\252~OS0\155s\176", _password = Just +// "+\217", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\251\&3\249*?0\b\223!*\150M", _willMsg = "bZ\SO", _willProps = []}), _cleanSession = False, _keepAlive = 5719, +// _connID = "\222\165\251RK\130'\234\242.*\EOT\200~\"\NULJ", _properties = []} TEST(Connect311QCTest, Encode14) { - uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0xb, 0x68, 0x0, 0x14, 0xcb, 0x4d, 0x2b, - 0xab, 0x7c, 0x84, 0x6e, 0x6a, 0xc1, 0x1c, 0x7, 0x5c, 0x11, 0xe6, 0xca, 0x12, 0x49, 0x64, 0x3b, 0xc8, - 0x0, 0x5, 0xb5, 0x4a, 0xfb, 0x8d, 0x3, 0x0, 0x2, 0x7c, 0x17, 0x0, 0x13, 0x6a, 0x70, 0xd2, 0x16, - 0x3c, 0x25, 0x46, 0xd7, 0xa8, 0xcf, 0x4a, 0xe1, 0x98, 0x7a, 0x97, 0x58, 0xfd, 0x84, 0x22}; + uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xcc, 0x16, 0x57, 0x0, 0x11, 0xde, 0xa5, + 0xfb, 0x52, 0x4b, 0x82, 0x27, 0xea, 0xf2, 0x2e, 0x2a, 0x4, 0xc8, 0x7e, 0x22, 0x0, 0x4a, 0x0, + 0xc, 0xfb, 0x33, 0xf9, 0x2a, 0x3f, 0x30, 0x8, 0xdf, 0x21, 0x2a, 0x96, 0x4d, 0x0, 0x3, 0x62, + 0x5a, 0xe, 0x0, 0x18, 0xf2, 0xff, 0xf8, 0x1e, 0x6c, 0x71, 0x79, 0xd2, 0xa5, 0xdf, 0x45, 0x4a, + 0x73, 0xda, 0x8a, 0xc3, 0xfc, 0x7e, 0x4f, 0x53, 0x30, 0x9b, 0x73, 0xb0, 0x0, 0x2, 0x2b, 0xd9}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9420,10 +8862,10 @@ TEST(Connect311QCTest, Encode14) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb5, 0x4a, 0xfb, 0x8d, 0x3}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7c, 0x17}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xfb, 0x33, 0xf9, 0x2a, 0x3f, 0x30, 0x8, 0xdf, 0x21, 0x2a, 0x96, 0x4d}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x62, 0x5a, 0xe}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -9431,16 +8873,19 @@ TEST(Connect311QCTest, Encode14) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 2920; - uint8_t client_id_bytes[] = {0xcb, 0x4d, 0x2b, 0xab, 0x7c, 0x84, 0x6e, 0x6a, 0xc1, 0x1c, - 0x7, 0x5c, 0x11, 0xe6, 0xca, 0x12, 0x49, 0x64, 0x3b, 0xc8}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 5719; + uint8_t client_id_bytes[] = {0xde, 0xa5, 0xfb, 0x52, 0x4b, 0x82, 0x27, 0xea, 0xf2, + 0x2e, 0x2a, 0x4, 0xc8, 0x7e, 0x22, 0x0, 0x4a}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x6a, 0x70, 0xd2, 0x16, 0x3c, 0x25, 0x46, 0xd7, 0xa8, 0xcf, - 0x4a, 0xe1, 0x98, 0x7a, 0x97, 0x58, 0xfd, 0x84, 0x22}; - lwmqtt_string_t username = {19, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xf2, 0xff, 0xf8, 0x1e, 0x6c, 0x71, 0x79, 0xd2, 0xa5, 0xdf, 0x45, 0x4a, + 0x73, 0xda, 0x8a, 0xc3, 0xfc, 0x7e, 0x4f, 0x53, 0x30, 0x9b, 0x73, 0xb0}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x2b, 0xd9}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9449,16 +8894,18 @@ TEST(Connect311QCTest, Encode14) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\192\STX\129_\195-\215\163\200JG\249<", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "\152e\130\v\SOH\ACK\224\EOT\165\199(&g\SO\ACK\211\169\&1\DC3\243\199\ETB\221\138+", _willMsg = -// "H\197\&7\SOH\253\237", _willProps = []}), _cleanSession = True, _keepAlive = 2714, _connID = -// "\243Q\STX\222\243oB\DC4\136\201n\GS\146", _properties = []} +// ConnectRequest {_username = Just "\172\146\231\253\222^\247\183l\232!\133;\b\FS\253\ETX\f~[\211\SYN(P", _password = +// Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "[\SO\138\&5\217\\\253\149\212\249s\139\SOH\ENQ\DLEw", _willMsg = +// "\a\252\183\167\137\DC4\248\STX^\DLE\249\242\194\ESC\135\165\&5L\205dn\DC2", _willProps = []}), _cleanSession = +// False, _keepAlive = 27552, _connID = "e\185\229", _properties = []} TEST(Connect311QCTest, Encode15) { - uint8_t pkt[] = {0x10, 0x3c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0xa, 0x9a, 0x0, 0xd, 0xf3, 0x51, - 0x2, 0xde, 0xf3, 0x6f, 0x42, 0x14, 0x88, 0xc9, 0x6e, 0x1d, 0x92, 0x0, 0x19, 0x98, 0x65, 0x82, - 0xb, 0x1, 0x6, 0xe0, 0x4, 0xa5, 0xc7, 0x28, 0x26, 0x67, 0xe, 0x6, 0xd3, 0xa9, 0x31, 0x13, - 0xf3, 0xc7, 0x17, 0xdd, 0x8a, 0x2b, 0x0, 0x6, 0x48, 0xc5, 0x37, 0x1, 0xfd, 0xed}; + uint8_t pkt[] = {0x10, 0x53, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xa4, 0x6b, 0xa0, 0x0, 0x3, 0x65, + 0xb9, 0xe5, 0x0, 0x10, 0x5b, 0xe, 0x8a, 0x35, 0xd9, 0x5c, 0xfd, 0x95, 0xd4, 0xf9, 0x73, + 0x8b, 0x1, 0x5, 0x10, 0x77, 0x0, 0x16, 0x7, 0xfc, 0xb7, 0xa7, 0x89, 0x14, 0xf8, 0x2, + 0x5e, 0x10, 0xf9, 0xf2, 0xc2, 0x1b, 0x87, 0xa5, 0x35, 0x4c, 0xcd, 0x64, 0x6e, 0x12, 0x0, + 0x18, 0xac, 0x92, 0xe7, 0xfd, 0xde, 0x5e, 0xf7, 0xb7, 0x6c, 0xe8, 0x21, 0x85, 0x3b, 0x8, + 0x1c, 0xfd, 0x3, 0xc, 0x7e, 0x5b, 0xd3, 0x16, 0x28, 0x50}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9469,26 +8916,28 @@ TEST(Connect311QCTest, Encode15) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x98, 0x65, 0x82, 0xb, 0x1, 0x6, 0xe0, 0x4, 0xa5, 0xc7, 0x28, 0x26, 0x67, - 0xe, 0x6, 0xd3, 0xa9, 0x31, 0x13, 0xf3, 0xc7, 0x17, 0xdd, 0x8a, 0x2b}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x48, 0xc5, 0x37, 0x1, 0xfd, 0xed}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x5b, 0xe, 0x8a, 0x35, 0xd9, 0x5c, 0xfd, 0x95, + 0xd4, 0xf9, 0x73, 0x8b, 0x1, 0x5, 0x10, 0x77}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7, 0xfc, 0xb7, 0xa7, 0x89, 0x14, 0xf8, 0x2, 0x5e, 0x10, 0xf9, + 0xf2, 0xc2, 0x1b, 0x87, 0xa5, 0x35, 0x4c, 0xcd, 0x64, 0x6e, 0x12}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 2714; - uint8_t client_id_bytes[] = {0xf3, 0x51, 0x2, 0xde, 0xf3, 0x6f, 0x42, 0x14, 0x88, 0xc9, 0x6e, 0x1d, 0x92}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 27552; + uint8_t client_id_bytes[] = {0x65, 0xb9, 0xe5}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xc0, 0x2, 0x81, 0x5f, 0xc3, 0x2d, 0xd7, 0xa3, 0xc8, 0x4a, 0x47, 0xf9, 0x3c}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; - opts.password = password; + uint8_t username_bytes[] = {0xac, 0x92, 0xe7, 0xfd, 0xde, 0x5e, 0xf7, 0xb7, 0x6c, 0xe8, 0x21, 0x85, + 0x3b, 0x8, 0x1c, 0xfd, 0x3, 0xc, 0x7e, 0x5b, 0xd3, 0x16, 0x28, 0x50}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9497,11 +8946,14 @@ TEST(Connect311QCTest, Encode15) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = -// 26866, _connID = "^\239\188\197\142\229[\ESC\211E\188\233\195", _properties = []} +// ConnectRequest {_username = Just "\208\186;\142\229\ENQ\DC3", _password = Just "k\STX\218\181\207){\"\180\DLE", +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 28695, _connID = +// "\166'RW'\131!\222\228%N\243\227\158\253sF\r\211L", _properties = []} TEST(Connect311QCTest, Encode16) { - uint8_t pkt[] = {0x10, 0x19, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2, 0x68, 0xf2, 0x0, 0xd, - 0x5e, 0xef, 0xbc, 0xc5, 0x8e, 0xe5, 0x5b, 0x1b, 0xd3, 0x45, 0xbc, 0xe9, 0xc3}; + uint8_t pkt[] = {0x10, 0x35, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc0, 0x70, 0x17, 0x0, 0x14, + 0xa6, 0x27, 0x52, 0x57, 0x27, 0x83, 0x21, 0xde, 0xe4, 0x25, 0x4e, 0xf3, 0xe3, 0x9e, + 0xfd, 0x73, 0x46, 0xd, 0xd3, 0x4c, 0x0, 0x7, 0xd0, 0xba, 0x3b, 0x8e, 0xe5, 0x5, + 0x13, 0x0, 0xa, 0x6b, 0x2, 0xda, 0xb5, 0xcf, 0x29, 0x7b, 0x22, 0xb4, 0x10}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9509,11 +8961,18 @@ TEST(Connect311QCTest, Encode16) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 26866; - uint8_t client_id_bytes[] = {0x5e, 0xef, 0xbc, 0xc5, 0x8e, 0xe5, 0x5b, 0x1b, 0xd3, 0x45, 0xbc, 0xe9, 0xc3}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 28695; + uint8_t client_id_bytes[] = {0xa6, 0x27, 0x52, 0x57, 0x27, 0x83, 0x21, 0xde, 0xe4, 0x25, + 0x4e, 0xf3, 0xe3, 0x9e, 0xfd, 0x73, 0x46, 0xd, 0xd3, 0x4c}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; + uint8_t username_bytes[] = {0xd0, 0xba, 0x3b, 0x8e, 0xe5, 0x5, 0x13}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x6b, 0x2, 0xda, 0xb5, 0xcf, 0x29, 0x7b, 0x22, 0xb4, 0x10}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); @@ -9522,102 +8981,104 @@ TEST(Connect311QCTest, Encode16) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\159\254c\245[\164\r\135bMz\150\205`e\233\140\135YrN\180\GS\186\140\209As", -// _password = Just "<\FS\172b\196\SI\220\203\NUL`\239\135", _willMsg = -// "\232\233\vx\202\163\SOH\188\142\245iS\"H\226\158\228\235\182tA\252\ACK\191\183j8", _willProps = []}), _cleanSession -// = False, _keepAlive = 2005, _connID = "\SODv\236\176\168\ETB \EOT", _properties = []} +// ConnectRequest {_username = Just "\160(\fi\152\189\DC1\183}\167.2[,e\217\&8\238]\207\156\192:B\128\ESC\188\205", +// _password = Just "\223+\207(\246E\243:\221J\144\DLE#\165\162\&3\240\148\196\247\150:@\226\154\174<", _lastWill = +// Nothing, _cleanSession = True, _keepAlive = 19401, _connID = +// "6\204\")V\154L\237\218s#U\227\148\134o\190\&2\ETB\192^\225\201\229\169", _properties = []} TEST(Connect311QCTest, Encode18) { - uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x24, 0x7, 0xd5, 0x0, 0x9, 0xe, 0x44, - 0x76, 0xec, 0xb0, 0xa8, 0x17, 0x20, 0x4, 0x0, 0x1a, 0x23, 0x93, 0x46, 0x1c, 0x9b, 0x14, 0x23, - 0xbe, 0xb5, 0xc5, 0xa4, 0x1b, 0xa6, 0xbf, 0x5a, 0x5, 0xf7, 0x8f, 0xd8, 0xfb, 0x8c, 0xe8, 0xa1, - 0x3e, 0xef, 0x87, 0x0, 0x1b, 0xe8, 0xe9, 0xb, 0x78, 0xca, 0xa3, 0x1, 0xbc, 0x8e, 0xf5, 0x69, - 0x53, 0x22, 0x48, 0xe2, 0x9e, 0xe4, 0xeb, 0xb6, 0x74, 0x41, 0xfc, 0x6, 0xbf, 0xb7, 0x6a, 0x38}; + uint8_t pkt[] = {0x10, 0x60, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x4b, 0xc9, 0x0, 0x19, 0x36, 0xcc, 0x22, + 0x29, 0x56, 0x9a, 0x4c, 0xed, 0xda, 0x73, 0x23, 0x55, 0xe3, 0x94, 0x86, 0x6f, 0xbe, 0x32, 0x17, 0xc0, + 0x5e, 0xe1, 0xc9, 0xe5, 0xa9, 0x0, 0x1c, 0xa0, 0x28, 0xc, 0x69, 0x98, 0xbd, 0x11, 0xb7, 0x7d, 0xa7, + 0x2e, 0x32, 0x5b, 0x2c, 0x65, 0xd9, 0x38, 0xee, 0x5d, 0xcf, 0x9c, 0xc0, 0x3a, 0x42, 0x80, 0x1b, 0xbc, + 0xcd, 0x0, 0x1b, 0xdf, 0x2b, 0xcf, 0x28, 0xf6, 0x45, 0xf3, 0x3a, 0xdd, 0x4a, 0x90, 0x10, 0x23, 0xa5, + 0xa2, 0x33, 0xf0, 0x94, 0xc4, 0xf7, 0x96, 0x3a, 0x40, 0xe2, 0x9a, 0xae, 0x3c}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x23, 0x93, 0x46, 0x1c, 0x9b, 0x14, 0x23, 0xbe, 0xb5, 0xc5, 0xa4, 0x1b, 0xa6, - 0xbf, 0x5a, 0x5, 0xf7, 0x8f, 0xd8, 0xfb, 0x8c, 0xe8, 0xa1, 0x3e, 0xef, 0x87}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe8, 0xe9, 0xb, 0x78, 0xca, 0xa3, 0x1, 0xbc, 0x8e, 0xf5, 0x69, 0x53, 0x22, 0x48, - 0xe2, 0x9e, 0xe4, 0xeb, 0xb6, 0x74, 0x41, 0xfc, 0x6, 0xbf, 0xb7, 0x6a, 0x38}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 2005; - uint8_t client_id_bytes[] = {0xe, 0x44, 0x76, 0xec, 0xb0, 0xa8, 0x17, 0x20, 0x4}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 19401; + uint8_t client_id_bytes[] = {0x36, 0xcc, 0x22, 0x29, 0x56, 0x9a, 0x4c, 0xed, 0xda, 0x73, 0x23, 0x55, 0xe3, + 0x94, 0x86, 0x6f, 0xbe, 0x32, 0x17, 0xc0, 0x5e, 0xe1, 0xc9, 0xe5, 0xa9}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x36, 0x8b, 0xe1, 0xa0, 0xde, 0x59, 0x76, 0x17, - 0xb8, 0x1a, 0x1e, 0xe, 0xea, 0x7d, 0x47, 0xe7}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xa0, 0x28, 0xc, 0x69, 0x98, 0xbd, 0x11, 0xb7, 0x7d, 0xa7, 0x2e, 0x32, 0x5b, 0x2c, + 0x65, 0xd9, 0x38, 0xee, 0x5d, 0xcf, 0x9c, 0xc0, 0x3a, 0x42, 0x80, 0x1b, 0xbc, 0xcd}; + lwmqtt_string_t username = {28, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0xdf, 0x2b, 0xcf, 0x28, 0xf6, 0x45, 0xf3, 0x3a, 0xdd, 0x4a, 0x90, 0x10, 0x23, 0xa5, + 0xa2, 0x33, 0xf0, 0x94, 0xc4, 0xf7, 0x96, 0x3a, 0x40, 0xe2, 0x9a, 0xae, 0x3c}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "5\189\229", _password = Just "\SO\229\SUB\207\196\181|6\242\192@", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "v<3?)\161", _willMsg = -// "\202\&9\147\164]\233\219\201F\146ox)xa", _willProps = []}), _cleanSession = False, _keepAlive = 31959, _connID = -// "K\181", _properties = []} +// ConnectRequest {_username = Just "^u#\159", _password = Just +// "y\"\r/\252\&8\144\156Y\221,;\158\GS\207S\130\174\230\ETB\150\150M\148\159\212", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "\160A\b\242{hJ\240\SOHs\227", _willMsg = +// "+JS\150\209\231\230=\222\231\225\142\244\229\US2\STX\233\240\253\168\RSzG1", _willProps = []}), _cleanSession = +// True, _keepAlive = 22513, _connID = +// "/\179\ENQ:\239\234\242P\129,\b\213A\237\186\243\&9\183\133\147\188\136.\ACK\202\FSS\\", _properties = []} TEST(Connect311QCTest, Encode19) { - uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe4, 0x7c, 0xd7, 0x0, 0x2, 0x4b, - 0xb5, 0x0, 0x6, 0x76, 0x3c, 0x33, 0x3f, 0x29, 0xa1, 0x0, 0xf, 0xca, 0x39, 0x93, 0xa4, - 0x5d, 0xe9, 0xdb, 0xc9, 0x46, 0x92, 0x6f, 0x78, 0x29, 0x78, 0x61, 0x0, 0x3, 0x35, 0xbd, - 0xe5, 0x0, 0xb, 0xe, 0xe5, 0x1a, 0xcf, 0xc4, 0xb5, 0x7c, 0x36, 0xf2, 0xc0, 0x40}; + uint8_t pkt[] = {0x10, 0x72, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc6, 0x57, 0xf1, 0x0, 0x1c, 0x2f, 0xb3, 0x5, + 0x3a, 0xef, 0xea, 0xf2, 0x50, 0x81, 0x2c, 0x8, 0xd5, 0x41, 0xed, 0xba, 0xf3, 0x39, 0xb7, 0x85, 0x93, + 0xbc, 0x88, 0x2e, 0x6, 0xca, 0x1c, 0x53, 0x5c, 0x0, 0xb, 0xa0, 0x41, 0x8, 0xf2, 0x7b, 0x68, 0x4a, + 0xf0, 0x1, 0x73, 0xe3, 0x0, 0x19, 0x2b, 0x4a, 0x53, 0x96, 0xd1, 0xe7, 0xe6, 0x3d, 0xde, 0xe7, 0xe1, + 0x8e, 0xf4, 0xe5, 0x1f, 0x32, 0x2, 0xe9, 0xf0, 0xfd, 0xa8, 0x1e, 0x7a, 0x47, 0x31, 0x0, 0x4, 0x5e, + 0x75, 0x23, 0x9f, 0x0, 0x1a, 0x79, 0x22, 0xd, 0x2f, 0xfc, 0x38, 0x90, 0x9c, 0x59, 0xdd, 0x2c, 0x3b, + 0x9e, 0x1d, 0xcf, 0x53, 0x82, 0xae, 0xe6, 0x17, 0x96, 0x96, 0x4d, 0x94, 0x9f, 0xd4}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9628,28 +9089,30 @@ TEST(Connect311QCTest, Encode19) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x76, 0x3c, 0x33, 0x3f, 0x29, 0xa1}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xca, 0x39, 0x93, 0xa4, 0x5d, 0xe9, 0xdb, 0xc9, - 0x46, 0x92, 0x6f, 0x78, 0x29, 0x78, 0x61}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xa0, 0x41, 0x8, 0xf2, 0x7b, 0x68, 0x4a, 0xf0, 0x1, 0x73, 0xe3}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2b, 0x4a, 0x53, 0x96, 0xd1, 0xe7, 0xe6, 0x3d, 0xde, 0xe7, 0xe1, 0x8e, 0xf4, + 0xe5, 0x1f, 0x32, 0x2, 0xe9, 0xf0, 0xfd, 0xa8, 0x1e, 0x7a, 0x47, 0x31}; + lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 31959; - uint8_t client_id_bytes[] = {0x4b, 0xb5}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 22513; + uint8_t client_id_bytes[] = {0x2f, 0xb3, 0x5, 0x3a, 0xef, 0xea, 0xf2, 0x50, 0x81, 0x2c, 0x8, 0xd5, 0x41, 0xed, + 0xba, 0xf3, 0x39, 0xb7, 0x85, 0x93, 0xbc, 0x88, 0x2e, 0x6, 0xca, 0x1c, 0x53, 0x5c}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x35, 0xbd, 0xe5}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x5e, 0x75, 0x23, 0x9f}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xe, 0xe5, 0x1a, 0xcf, 0xc4, 0xb5, 0x7c, 0x36, 0xf2, 0xc0, 0x40}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x79, 0x22, 0xd, 0x2f, 0xfc, 0x38, 0x90, 0x9c, 0x59, 0xdd, 0x2c, 0x3b, 0x9e, + 0x1d, 0xcf, 0x53, 0x82, 0xae, 0xe6, 0x17, 0x96, 0x96, 0x4d, 0x94, 0x9f, 0xd4}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9659,17 +9122,16 @@ TEST(Connect311QCTest, Encode19) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "$\DC3o!\SI\253}\212\230\FS`\217X\171[", _password = Just "u", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\SOH$\ETB\192\157\196En", _willMsg = -// "\215\209\DLE\STX\164!\185\142\223\197\154\"\159\249\167,[\130", _willProps = []}), _cleanSession = True, _keepAlive -// = 14833, _connID = "\ETX@W\177\213>\v\227\232\224C\r\156\220j\DC4\170\177g\190-&\193", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just +// "\148\203\247(\RS\253m?\172\246]f\150WW\162\137\245\t\255\243\SUB}", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "Q&\199s\163,\145Pk\170\212\r\SOH\210I", _willMsg = +// "/y0\n\222\221\178\SO\241\211d\222\211\&0b", _willProps = []}), _cleanSession = False, _keepAlive = 190, _connID = +// "6Y\188\175\229N\156\168\153V\FS", _properties = []} TEST(Connect311QCTest, Encode20) { - uint8_t pkt[] = {0x10, 0x55, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x39, 0xf1, 0x0, 0x17, 0x3, - 0x40, 0x57, 0xb1, 0xd5, 0x3e, 0xb, 0xe3, 0xe8, 0xe0, 0x43, 0xd, 0x9c, 0xdc, 0x6a, 0x14, - 0xaa, 0xb1, 0x67, 0xbe, 0x2d, 0x26, 0xc1, 0x0, 0x8, 0x1, 0x24, 0x17, 0xc0, 0x9d, 0xc4, - 0x45, 0x6e, 0x0, 0x12, 0xd7, 0xd1, 0x10, 0x2, 0xa4, 0x21, 0xb9, 0x8e, 0xdf, 0xc5, 0x9a, - 0x22, 0x9f, 0xf9, 0xa7, 0x2c, 0x5b, 0x82, 0x0, 0xf, 0x24, 0x13, 0x6f, 0x21, 0xf, 0xfd, - 0x7d, 0xd4, 0xe6, 0x1c, 0x60, 0xd9, 0x58, 0xab, 0x5b, 0x0, 0x1, 0x75}; + uint8_t pkt[] = {0x10, 0x39, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x34, 0x0, 0xbe, 0x0, 0xb, 0x36, + 0x59, 0xbc, 0xaf, 0xe5, 0x4e, 0x9c, 0xa8, 0x99, 0x56, 0x1c, 0x0, 0xf, 0x51, 0x26, 0xc7, + 0x73, 0xa3, 0x2c, 0x91, 0x50, 0x6b, 0xaa, 0xd4, 0xd, 0x1, 0xd2, 0x49, 0x0, 0xf, 0x2f, + 0x79, 0x30, 0xa, 0xde, 0xdd, 0xb2, 0xe, 0xf1, 0xd3, 0x64, 0xde, 0xd3, 0x30, 0x62}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9680,29 +9142,26 @@ TEST(Connect311QCTest, Encode20) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1, 0x24, 0x17, 0xc0, 0x9d, 0xc4, 0x45, 0x6e}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd7, 0xd1, 0x10, 0x2, 0xa4, 0x21, 0xb9, 0x8e, 0xdf, - 0xc5, 0x9a, 0x22, 0x9f, 0xf9, 0xa7, 0x2c, 0x5b, 0x82}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x51, 0x26, 0xc7, 0x73, 0xa3, 0x2c, 0x91, 0x50, 0x6b, 0xaa, 0xd4, 0xd, 0x1, 0xd2, 0x49}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2f, 0x79, 0x30, 0xa, 0xde, 0xdd, 0xb2, 0xe, + 0xf1, 0xd3, 0x64, 0xde, 0xd3, 0x30, 0x62}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 14833; - uint8_t client_id_bytes[] = {0x3, 0x40, 0x57, 0xb1, 0xd5, 0x3e, 0xb, 0xe3, 0xe8, 0xe0, 0x43, 0xd, - 0x9c, 0xdc, 0x6a, 0x14, 0xaa, 0xb1, 0x67, 0xbe, 0x2d, 0x26, 0xc1}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 190; + uint8_t client_id_bytes[] = {0x36, 0x59, 0xbc, 0xaf, 0xe5, 0x4e, 0x9c, 0xa8, 0x99, 0x56, 0x1c}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x24, 0x13, 0x6f, 0x21, 0xf, 0xfd, 0x7d, 0xd4, 0xe6, 0x1c, 0x60, 0xd9, 0x58, 0xab, 0x5b}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x75}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x94, 0xcb, 0xf7, 0x28, 0x1e, 0xfd, 0x6d, 0x3f, 0xac, 0xf6, 0x5d, 0x66, + 0x96, 0x57, 0x57, 0xa2, 0x89, 0xf5, 0x9, 0xff, 0xf3, 0x1a, 0x7d}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9712,18 +9171,15 @@ TEST(Connect311QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\vA%3\NAK\141\215\DC1\202\232\133\157m&\195\DLE\177S\169-s\174ot\177\US\t\176", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = -// "\168\SO\185\228vJA\194DR\140\201\EOT\155\ETB!", _willMsg = "a\EM\252\SYNH\190\200 B\143\EOT\ETXl' \174\145\159n", -// _willProps = []}), _cleanSession = True, _keepAlive = 28777, _connID = -// "+3\250\223\230[8\232\GS\FS\191\141\166\159\EOT", _properties = []} +// ConnectRequest {_username = Just "\DC4d\128<~\133\193\US", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "#\232\214h;\148\233\ESC\f\238c\v*\178\EM\DC2qs", _willMsg = +// "\250\"\228J*O\RS\174IQV(\146\131\255", _willProps = []}), _cleanSession = True, _keepAlive = 11426, _connID = +// "\204\182", _properties = []} TEST(Connect311QCTest, Encode21) { - uint8_t pkt[] = {0x10, 0x60, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0x70, 0x69, 0x0, 0xf, 0x2b, 0x33, 0xfa, - 0xdf, 0xe6, 0x5b, 0x38, 0xe8, 0x1d, 0x1c, 0xbf, 0x8d, 0xa6, 0x9f, 0x4, 0x0, 0x10, 0xa8, 0xe, 0xb9, - 0xe4, 0x76, 0x4a, 0x41, 0xc2, 0x44, 0x52, 0x8c, 0xc9, 0x4, 0x9b, 0x17, 0x21, 0x0, 0x13, 0x61, 0x19, - 0xfc, 0x16, 0x48, 0xbe, 0xc8, 0x20, 0x42, 0x8f, 0x4, 0x3, 0x6c, 0x27, 0x20, 0xae, 0x91, 0x9f, 0x6e, - 0x0, 0x1c, 0xb, 0x41, 0x25, 0x33, 0x15, 0x8d, 0xd7, 0x11, 0xca, 0xe8, 0x85, 0x9d, 0x6d, 0x26, 0xc3, - 0x10, 0xb1, 0x53, 0xa9, 0x2d, 0x73, 0xae, 0x6f, 0x74, 0xb1, 0x1f, 0x9, 0xb0}; + uint8_t pkt[] = {0x10, 0x3d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8e, 0x2c, 0xa2, 0x0, 0x2, 0xcc, 0xb6, + 0x0, 0x12, 0x23, 0xe8, 0xd6, 0x68, 0x3b, 0x94, 0xe9, 0x1b, 0xc, 0xee, 0x63, 0xb, 0x2a, 0xb2, + 0x19, 0x12, 0x71, 0x73, 0x0, 0xf, 0xfa, 0x22, 0xe4, 0x4a, 0x2a, 0x4f, 0x1e, 0xae, 0x49, 0x51, + 0x56, 0x28, 0x92, 0x83, 0xff, 0x0, 0x8, 0x14, 0x64, 0x80, 0x3c, 0x7e, 0x85, 0xc1, 0x1f}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9734,12 +9190,12 @@ TEST(Connect311QCTest, Encode21) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa8, 0xe, 0xb9, 0xe4, 0x76, 0x4a, 0x41, 0xc2, - 0x44, 0x52, 0x8c, 0xc9, 0x4, 0x9b, 0x17, 0x21}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x61, 0x19, 0xfc, 0x16, 0x48, 0xbe, 0xc8, 0x20, 0x42, 0x8f, - 0x4, 0x3, 0x6c, 0x27, 0x20, 0xae, 0x91, 0x9f, 0x6e}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x23, 0xe8, 0xd6, 0x68, 0x3b, 0x94, 0xe9, 0x1b, 0xc, + 0xee, 0x63, 0xb, 0x2a, 0xb2, 0x19, 0x12, 0x71, 0x73}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfa, 0x22, 0xe4, 0x4a, 0x2a, 0x4f, 0x1e, 0xae, + 0x49, 0x51, 0x56, 0x28, 0x92, 0x83, 0xff}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -9748,13 +9204,12 @@ TEST(Connect311QCTest, Encode21) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 28777; - uint8_t client_id_bytes[] = {0x2b, 0x33, 0xfa, 0xdf, 0xe6, 0x5b, 0x38, 0xe8, 0x1d, 0x1c, 0xbf, 0x8d, 0xa6, 0x9f, 0x4}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.keep_alive = 11426; + uint8_t client_id_bytes[] = {0xcc, 0xb6}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb, 0x41, 0x25, 0x33, 0x15, 0x8d, 0xd7, 0x11, 0xca, 0xe8, 0x85, 0x9d, 0x6d, 0x26, - 0xc3, 0x10, 0xb1, 0x53, 0xa9, 0x2d, 0x73, 0xae, 0x6f, 0x74, 0xb1, 0x1f, 0x9, 0xb0}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x14, 0x64, 0x80, 0x3c, 0x7e, 0x85, 0xc1, 0x1f}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9764,17 +9219,13 @@ TEST(Connect311QCTest, Encode21) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\154\187ln", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "\147\234\128\171\v\219\164\138\218W\166", _willMsg = -// "\210\254\161\ENQ\v\192\253\DLE\176\204-\222Uv\154m\FSi+", _willProps = []}), _cleanSession = True, _keepAlive = -// 23669, _connID = "$\237\&8\219\166I\143>\251N\190&hL\173\150*\131\212>\211\244\SI\149\243\SYN\179\154\EOT", -// _properties = []} +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "30\150m;\145\234\188\240\155\227p8<", _willMsg = "k\131\233ZIw", _willProps = []}), _cleanSession +// = True, _keepAlive = 19711, _connID = "\STX\223\144\245\NAK\216/", _properties = []} TEST(Connect311QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0x4b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x36, 0x5c, 0x75, 0x0, 0x1d, 0x24, 0xed, - 0x38, 0xdb, 0xa6, 0x49, 0x8f, 0x3e, 0xfb, 0x4e, 0xbe, 0x26, 0x68, 0x4c, 0xad, 0x96, 0x2a, 0x83, - 0xd4, 0x3e, 0xd3, 0xf4, 0xf, 0x95, 0xf3, 0x16, 0xb3, 0x9a, 0x4, 0x0, 0xb, 0x93, 0xea, 0x80, - 0xab, 0xb, 0xdb, 0xa4, 0x8a, 0xda, 0x57, 0xa6, 0x0, 0x13, 0xd2, 0xfe, 0xa1, 0x5, 0xb, 0xc0, - 0xfd, 0x10, 0xb0, 0xcc, 0x2d, 0xde, 0x55, 0x76, 0x9a, 0x6d, 0x1c, 0x69, 0x2b}; + uint8_t pkt[] = {0x10, 0x2b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x4c, 0xff, 0x0, 0x7, 0x2, + 0xdf, 0x90, 0xf5, 0x15, 0xd8, 0x2f, 0x0, 0xe, 0x33, 0x30, 0x96, 0x6d, 0x3b, 0x91, 0xea, + 0xbc, 0xf0, 0x9b, 0xe3, 0x70, 0x38, 0x3c, 0x0, 0x6, 0x6b, 0x83, 0xe9, 0x5a, 0x49, 0x77}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9785,27 +9236,22 @@ TEST(Connect311QCTest, Encode22) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x93, 0xea, 0x80, 0xab, 0xb, 0xdb, 0xa4, 0x8a, 0xda, 0x57, 0xa6}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd2, 0xfe, 0xa1, 0x5, 0xb, 0xc0, 0xfd, 0x10, 0xb0, 0xcc, - 0x2d, 0xde, 0x55, 0x76, 0x9a, 0x6d, 0x1c, 0x69, 0x2b}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x33, 0x30, 0x96, 0x6d, 0x3b, 0x91, 0xea, 0xbc, 0xf0, 0x9b, 0xe3, 0x70, 0x38, 0x3c}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6b, 0x83, 0xe9, 0x5a, 0x49, 0x77}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 23669; - uint8_t client_id_bytes[] = {0x24, 0xed, 0x38, 0xdb, 0xa6, 0x49, 0x8f, 0x3e, 0xfb, 0x4e, 0xbe, 0x26, 0x68, 0x4c, 0xad, - 0x96, 0x2a, 0x83, 0xd4, 0x3e, 0xd3, 0xf4, 0xf, 0x95, 0xf3, 0x16, 0xb3, 0x9a, 0x4}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.keep_alive = 19711; + uint8_t client_id_bytes[] = {0x2, 0xdf, 0x90, 0xf5, 0x15, 0xd8, 0x2f}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x9a, 0xbb, 0x6c, 0x6e}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9814,69 +9260,56 @@ TEST(Connect311QCTest, Encode22) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\143,\SOH\155g\228PV\DC2<\233\167\240`\US", _password = Just -// "e\nm=f\140\230Dl\161\225\170\162v\164\EOTc\207\195\255\131n$G\179w", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = "\178\225\170J\183\NAK\128\201\233\247\215q\NAK\v\165A\US\228", _willMsg = -// "-\155\216\170\221I\188\147:\179\167:", _willProps = []}), _cleanSession = False, _keepAlive = 24031, _connID = -// "\SI5", _properties = []} +// ConnectRequest {_username = Just "\237\&6f|\US#T\133\189\b", _password = Just +// "\NAK\150YWx\f\184\140\SO3\181\&0[\f\ETB", _lastWill = Nothing, _cleanSession = True, _keepAlive = 23584, _connID = " +// \149\136+\173Ve0s\240\142\225V]\231\US\208\&2\137:.~\229", _properties = []} TEST(Connect311QCTest, Encode23) { - uint8_t pkt[] = {0x10, 0x5d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x5d, 0xdf, 0x0, 0x2, 0xf, 0x35, - 0x0, 0x12, 0xb2, 0xe1, 0xaa, 0x4a, 0xb7, 0x15, 0x80, 0xc9, 0xe9, 0xf7, 0xd7, 0x71, 0x15, 0xb, - 0xa5, 0x41, 0x1f, 0xe4, 0x0, 0xc, 0x2d, 0x9b, 0xd8, 0xaa, 0xdd, 0x49, 0xbc, 0x93, 0x3a, 0xb3, - 0xa7, 0x3a, 0x0, 0xf, 0x8f, 0x2c, 0x1, 0x9b, 0x67, 0xe4, 0x50, 0x56, 0x12, 0x3c, 0xe9, 0xa7, - 0xf0, 0x60, 0x1f, 0x0, 0x1a, 0x65, 0xa, 0x6d, 0x3d, 0x66, 0x8c, 0xe6, 0x44, 0x6c, 0xa1, 0xe1, - 0xaa, 0xa2, 0x76, 0xa4, 0x4, 0x63, 0xcf, 0xc3, 0xff, 0x83, 0x6e, 0x24, 0x47, 0xb3, 0x77}; + uint8_t pkt[] = {0x10, 0x40, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xc2, 0x5c, 0x20, 0x0, 0x17, 0x20, 0x95, 0x88, + 0x2b, 0xad, 0x56, 0x65, 0x30, 0x73, 0xf0, 0x8e, 0xe1, 0x56, 0x5d, 0xe7, 0x1f, 0xd0, 0x32, 0x89, 0x3a, + 0x2e, 0x7e, 0xe5, 0x0, 0xa, 0xed, 0x36, 0x66, 0x7c, 0x1f, 0x23, 0x54, 0x85, 0xbd, 0x8, 0x0, 0xf, + 0x15, 0x96, 0x59, 0x57, 0x78, 0xc, 0xb8, 0x8c, 0xe, 0x33, 0xb5, 0x30, 0x5b, 0xc, 0x17}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - - lwmqtt_property_t willpropslist[] = {}; - - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb2, 0xe1, 0xaa, 0x4a, 0xb7, 0x15, 0x80, 0xc9, 0xe9, - 0xf7, 0xd7, 0x71, 0x15, 0xb, 0xa5, 0x41, 0x1f, 0xe4}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x2d, 0x9b, 0xd8, 0xaa, 0xdd, 0x49, 0xbc, 0x93, 0x3a, 0xb3, 0xa7, 0x3a}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = false; - will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 24031; - uint8_t client_id_bytes[] = {0xf, 0x35}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 23584; + uint8_t client_id_bytes[] = {0x20, 0x95, 0x88, 0x2b, 0xad, 0x56, 0x65, 0x30, 0x73, 0xf0, 0x8e, 0xe1, + 0x56, 0x5d, 0xe7, 0x1f, 0xd0, 0x32, 0x89, 0x3a, 0x2e, 0x7e, 0xe5}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x8f, 0x2c, 0x1, 0x9b, 0x67, 0xe4, 0x50, 0x56, 0x12, 0x3c, 0xe9, 0xa7, 0xf0, 0x60, 0x1f}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xed, 0x36, 0x66, 0x7c, 0x1f, 0x23, 0x54, 0x85, 0xbd, 0x8}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x65, 0xa, 0x6d, 0x3d, 0x66, 0x8c, 0xe6, 0x44, 0x6c, 0xa1, 0xe1, 0xaa, 0xa2, - 0x76, 0xa4, 0x4, 0x63, 0xcf, 0xc3, 0xff, 0x83, 0x6e, 0x24, 0x47, 0xb3, 0x77}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x15, 0x96, 0x59, 0x57, 0x78, 0xc, 0xb8, 0x8c, 0xe, 0x33, 0xb5, 0x30, 0x5b, 0xc, 0x17}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\141\198\185\130\140v\STX\135\128\CAN", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "Y\242i\225Ly\163\177\f\138\135/TW\n\DC3\217\RS\251c\244\DLEs\CAN\178mU>\SO", _willMsg = "Z", _willProps = []}), -// _cleanSession = True, _keepAlive = 14148, _connID = "hRi\ESC\170\202\226\252\ACK\209\SYN\222k\188", _properties = []} +// ConnectRequest {_username = Just "Y\GS\153\146\134\165\&8^,k\\\EM\SYNh\207", _password = Just +// "D\149?\170\EOT\GSQ\216\139\168\210\247O\138\139[\237w\151\255Q{\"\145L~\172", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "}2\216h#\194\242\241G:\190{j\185\DC2\157}l", _willMsg = +// "D\196\243E\229\FS[+K\208\170=]o\152\NAKM\207\151\&8\188\CAN\234kd", _willProps = []}), _cleanSession = True, +// _keepAlive = 21608, _connID = "\130&B\t\131\165\255\248=\203\140\NAK\165\235f\226JC\f\212<\181\191", _properties = +// []} TEST(Connect311QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x3c, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x26, 0x37, 0x44, 0x0, 0xe, 0x68, 0x52, - 0x69, 0x1b, 0xaa, 0xca, 0xe2, 0xfc, 0x6, 0xd1, 0x16, 0xde, 0x6b, 0xbc, 0x0, 0x1d, 0x59, 0xf2, - 0x69, 0xe1, 0x4c, 0x79, 0xa3, 0xb1, 0xc, 0x8a, 0x87, 0x2f, 0x54, 0x57, 0xa, 0x13, 0xd9, 0x1e, - 0xfb, 0x63, 0xf4, 0x10, 0x73, 0x18, 0xb2, 0x6d, 0x55, 0x3e, 0xe, 0x0, 0x1, 0x5a}; + uint8_t pkt[] = {0x10, 0x80, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x54, 0x68, 0x0, 0x17, 0x82, 0x26, + 0x42, 0x9, 0x83, 0xa5, 0xff, 0xf8, 0x3d, 0xcb, 0x8c, 0x15, 0xa5, 0xeb, 0x66, 0xe2, 0x4a, 0x43, 0xc, + 0xd4, 0x3c, 0xb5, 0xbf, 0x0, 0x12, 0x7d, 0x32, 0xd8, 0x68, 0x23, 0xc2, 0xf2, 0xf1, 0x47, 0x3a, 0xbe, + 0x7b, 0x6a, 0xb9, 0x12, 0x9d, 0x7d, 0x6c, 0x0, 0x19, 0x44, 0xc4, 0xf3, 0x45, 0xe5, 0x1c, 0x5b, 0x2b, + 0x4b, 0xd0, 0xaa, 0x3d, 0x5d, 0x6f, 0x98, 0x15, 0x4d, 0xcf, 0x97, 0x38, 0xbc, 0x18, 0xea, 0x6b, 0x64, + 0x0, 0xf, 0x59, 0x1d, 0x99, 0x92, 0x86, 0xa5, 0x38, 0x5e, 0x2c, 0x6b, 0x5c, 0x19, 0x16, 0x68, 0xcf, + 0x0, 0x1b, 0x44, 0x95, 0x3f, 0xaa, 0x4, 0x1d, 0x51, 0xd8, 0x8b, 0xa8, 0xd2, 0xf7, 0x4f, 0x8a, 0x8b, + 0x5b, 0xed, 0x77, 0x97, 0xff, 0x51, 0x7b, 0x22, 0x91, 0x4c, 0x7e, 0xac}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9887,25 +9320,31 @@ TEST(Connect311QCTest, Encode24) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x59, 0xf2, 0x69, 0xe1, 0x4c, 0x79, 0xa3, 0xb1, 0xc, 0x8a, 0x87, 0x2f, 0x54, 0x57, 0xa, - 0x13, 0xd9, 0x1e, 0xfb, 0x63, 0xf4, 0x10, 0x73, 0x18, 0xb2, 0x6d, 0x55, 0x3e, 0xe}; - lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5a}; - lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x7d, 0x32, 0xd8, 0x68, 0x23, 0xc2, 0xf2, 0xf1, 0x47, + 0x3a, 0xbe, 0x7b, 0x6a, 0xb9, 0x12, 0x9d, 0x7d, 0x6c}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x44, 0xc4, 0xf3, 0x45, 0xe5, 0x1c, 0x5b, 0x2b, 0x4b, 0xd0, 0xaa, 0x3d, 0x5d, + 0x6f, 0x98, 0x15, 0x4d, 0xcf, 0x97, 0x38, 0xbc, 0x18, 0xea, 0x6b, 0x64}; + lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 14148; - uint8_t client_id_bytes[] = {0x68, 0x52, 0x69, 0x1b, 0xaa, 0xca, 0xe2, 0xfc, 0x6, 0xd1, 0x16, 0xde, 0x6b, 0xbc}; - lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; + opts.keep_alive = 21608; + uint8_t client_id_bytes[] = {0x82, 0x26, 0x42, 0x9, 0x83, 0xa5, 0xff, 0xf8, 0x3d, 0xcb, 0x8c, 0x15, + 0xa5, 0xeb, 0x66, 0xe2, 0x4a, 0x43, 0xc, 0xd4, 0x3c, 0xb5, 0xbf}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x8d, 0xc6, 0xb9, 0x82, 0x8c, 0x76, 0x2, 0x87, 0x80, 0x18}; - lwmqtt_string_t password = {10, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x59, 0x1d, 0x99, 0x92, 0x86, 0xa5, 0x38, 0x5e, 0x2c, 0x6b, 0x5c, 0x19, 0x16, 0x68, 0xcf}; + lwmqtt_string_t username = {15, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x44, 0x95, 0x3f, 0xaa, 0x4, 0x1d, 0x51, 0xd8, 0x8b, 0xa8, 0xd2, 0xf7, 0x4f, 0x8a, + 0x8b, 0x5b, 0xed, 0x77, 0x97, 0xff, 0x51, 0x7b, 0x22, 0x91, 0x4c, 0x7e, 0xac}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9915,15 +9354,19 @@ TEST(Connect311QCTest, Encode24) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\167\155\251\197h\150N", _lastWill = Just (LastWill -// {_willRetain = True, _willQoS = QoS1, _willTopic = "'m\f$\SI\138a\SInjUa;\229\155Z\157\&2", _willMsg = -// "94H\150\255\251\134\159\242\&1H", _willProps = []}), _cleanSession = True, _keepAlive = 31273, _connID = -// "\211\132J\179\217\&3\245\247\151\a\182", _properties = []} +// ConnectRequest {_username = Just "@\255\f -\161\165\199'wWt4\233\GS|D\153\234\178\201\GS\171c\234\218\227\128yV", +// _password = Just "\GS\f\242\202", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "t\201\133\209\218\232M\211\&6\137\160\250\176\231N\250K\156\n\154)G8m\230?*\204", _willMsg = +// "x\171H\181\148\190T\200\NAKGX-!", _willProps = []}), _cleanSession = False, _keepAlive = 31084, _connID = +// "x\223t=\142\180\166\&1lQ3\134,\179", _properties = []} TEST(Connect311QCTest, Encode25) { - uint8_t pkt[] = {0x10, 0x38, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x2e, 0x7a, 0x29, 0x0, 0xb, 0xd3, - 0x84, 0x4a, 0xb3, 0xd9, 0x33, 0xf5, 0xf7, 0x97, 0x7, 0xb6, 0x0, 0x12, 0x27, 0x6d, 0xc, - 0x24, 0xf, 0x8a, 0x61, 0xf, 0x6e, 0x6a, 0x55, 0x61, 0x3b, 0xe5, 0x9b, 0x5a, 0x9d, 0x32, - 0x0, 0xb, 0x39, 0x34, 0x48, 0x96, 0xff, 0xfb, 0x86, 0x9f, 0xf2, 0x31, 0x48}; + uint8_t pkt[] = {0x10, 0x6d, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xd4, 0x79, 0x6c, 0x0, 0xe, 0x78, 0xdf, + 0x74, 0x3d, 0x8e, 0xb4, 0xa6, 0x31, 0x6c, 0x51, 0x33, 0x86, 0x2c, 0xb3, 0x0, 0x1c, 0x74, 0xc9, + 0x85, 0xd1, 0xda, 0xe8, 0x4d, 0xd3, 0x36, 0x89, 0xa0, 0xfa, 0xb0, 0xe7, 0x4e, 0xfa, 0x4b, 0x9c, + 0xa, 0x9a, 0x29, 0x47, 0x38, 0x6d, 0xe6, 0x3f, 0x2a, 0xcc, 0x0, 0xd, 0x78, 0xab, 0x48, 0xb5, + 0x94, 0xbe, 0x54, 0xc8, 0x15, 0x47, 0x58, 0x2d, 0x21, 0x0, 0x1e, 0x40, 0xff, 0xc, 0x20, 0x2d, + 0xa1, 0xa5, 0xc7, 0x27, 0x77, 0x57, 0x74, 0x34, 0xe9, 0x1d, 0x7c, 0x44, 0x99, 0xea, 0xb2, 0xc9, + 0x1d, 0xab, 0x63, 0xea, 0xda, 0xe3, 0x80, 0x79, 0x56, 0x0, 0x4, 0x1d, 0xc, 0xf2, 0xca}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9934,25 +9377,29 @@ TEST(Connect311QCTest, Encode25) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x27, 0x6d, 0xc, 0x24, 0xf, 0x8a, 0x61, 0xf, 0x6e, - 0x6a, 0x55, 0x61, 0x3b, 0xe5, 0x9b, 0x5a, 0x9d, 0x32}; - lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x39, 0x34, 0x48, 0x96, 0xff, 0xfb, 0x86, 0x9f, 0xf2, 0x31, 0x48}; - lwmqtt_string_t will_payload = {11, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x74, 0xc9, 0x85, 0xd1, 0xda, 0xe8, 0x4d, 0xd3, 0x36, 0x89, 0xa0, 0xfa, 0xb0, 0xe7, + 0x4e, 0xfa, 0x4b, 0x9c, 0xa, 0x9a, 0x29, 0x47, 0x38, 0x6d, 0xe6, 0x3f, 0x2a, 0xcc}; + lwmqtt_string_t will_topic = {28, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x78, 0xab, 0x48, 0xb5, 0x94, 0xbe, 0x54, 0xc8, 0x15, 0x47, 0x58, 0x2d, 0x21}; + lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = true; + will.qos = LWMQTT_QOS2; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 31273; - uint8_t client_id_bytes[] = {0xd3, 0x84, 0x4a, 0xb3, 0xd9, 0x33, 0xf5, 0xf7, 0x97, 0x7, 0xb6}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 31084; + uint8_t client_id_bytes[] = {0x78, 0xdf, 0x74, 0x3d, 0x8e, 0xb4, 0xa6, 0x31, 0x6c, 0x51, 0x33, 0x86, 0x2c, 0xb3}; + lwmqtt_string_t client_id = {14, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xa7, 0x9b, 0xfb, 0xc5, 0x68, 0x96, 0x4e}; - lwmqtt_string_t password = {7, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x40, 0xff, 0xc, 0x20, 0x2d, 0xa1, 0xa5, 0xc7, 0x27, 0x77, 0x57, 0x74, 0x34, 0xe9, 0x1d, + 0x7c, 0x44, 0x99, 0xea, 0xb2, 0xc9, 0x1d, 0xab, 0x63, 0xea, 0xda, 0xe3, 0x80, 0x79, 0x56}; + lwmqtt_string_t username = {30, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x1d, 0xc, 0xf2, 0xca}; + lwmqtt_string_t password = {4, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -9962,18 +9409,14 @@ TEST(Connect311QCTest, Encode25) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\152", _password = Just -// "\174\152x,\214O\183\249,o\"\137\170m\244\164\203\ACK\186\179\217@ _[\r>", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS1, _willTopic = "A\SUB\166x\NUL", _willMsg = "\253\&0\131n\162\236\192\DEL \150.\SI\174\163", -// _willProps = []}), _cleanSession = True, _keepAlive = 11096, _connID = -// "\207\r\183\&5c`\208+\186d/\132'X\238\247\DLEO\130\241\201\158\234", _properties = []} +// ConnectRequest {_username = Just "D", _password = Just "\168\254\f\211N\DC2\190*", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\DC4l'\158\201oAkY#\147\181d\169\216\161\228\t", _willMsg = +// "\208", _willProps = []}), _cleanSession = True, _keepAlive = 11346, _connID = "\ENQ\142\185\198", _properties = []} TEST(Connect311QCTest, Encode26) { - uint8_t pkt[] = {0x10, 0x5a, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xee, 0x2b, 0x58, 0x0, 0x17, 0xcf, 0xd, - 0xb7, 0x35, 0x63, 0x60, 0xd0, 0x2b, 0xba, 0x64, 0x2f, 0x84, 0x27, 0x58, 0xee, 0xf7, 0x10, 0x4f, - 0x82, 0xf1, 0xc9, 0x9e, 0xea, 0x0, 0x5, 0x41, 0x1a, 0xa6, 0x78, 0x0, 0x0, 0xe, 0xfd, 0x30, - 0x83, 0x6e, 0xa2, 0xec, 0xc0, 0x7f, 0x20, 0x96, 0x2e, 0xf, 0xae, 0xa3, 0x0, 0x1, 0x98, 0x0, - 0x1b, 0xae, 0x98, 0x78, 0x2c, 0xd6, 0x4f, 0xb7, 0xf9, 0x2c, 0x6f, 0x22, 0x89, 0xaa, 0x6d, 0xf4, - 0xa4, 0xcb, 0x6, 0xba, 0xb3, 0xd9, 0x40, 0x20, 0x5f, 0x5b, 0xd, 0x3e}; + uint8_t pkt[] = {0x10, 0x34, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x2c, 0x52, 0x0, 0x4, + 0x5, 0x8e, 0xb9, 0xc6, 0x0, 0x12, 0x14, 0x6c, 0x27, 0x9e, 0xc9, 0x6f, 0x41, 0x6b, + 0x59, 0x23, 0x93, 0xb5, 0x64, 0xa9, 0xd8, 0xa1, 0xe4, 0x9, 0x0, 0x1, 0xd0, 0x0, + 0x1, 0x44, 0x0, 0x8, 0xa8, 0xfe, 0xc, 0xd3, 0x4e, 0x12, 0xbe, 0x2a}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -9984,29 +9427,28 @@ TEST(Connect311QCTest, Encode26) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x41, 0x1a, 0xa6, 0x78, 0x0}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfd, 0x30, 0x83, 0x6e, 0xa2, 0xec, 0xc0, 0x7f, 0x20, 0x96, 0x2e, 0xf, 0xae, 0xa3}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x14, 0x6c, 0x27, 0x9e, 0xc9, 0x6f, 0x41, 0x6b, 0x59, + 0x23, 0x93, 0xb5, 0x64, 0xa9, 0xd8, 0xa1, 0xe4, 0x9}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xd0}; + lwmqtt_string_t will_payload = {1, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 11096; - uint8_t client_id_bytes[] = {0xcf, 0xd, 0xb7, 0x35, 0x63, 0x60, 0xd0, 0x2b, 0xba, 0x64, 0x2f, 0x84, - 0x27, 0x58, 0xee, 0xf7, 0x10, 0x4f, 0x82, 0xf1, 0xc9, 0x9e, 0xea}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 11346; + uint8_t client_id_bytes[] = {0x5, 0x8e, 0xb9, 0xc6}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x98}; + uint8_t username_bytes[] = {0x44}; lwmqtt_string_t username = {1, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xae, 0x98, 0x78, 0x2c, 0xd6, 0x4f, 0xb7, 0xf9, 0x2c, 0x6f, 0x22, 0x89, 0xaa, 0x6d, - 0xf4, 0xa4, 0xcb, 0x6, 0xba, 0xb3, 0xd9, 0x40, 0x20, 0x5f, 0x5b, 0xd, 0x3e}; - lwmqtt_string_t password = {27, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xa8, 0xfe, 0xc, 0xd3, 0x4e, 0x12, 0xbe, 0x2a}; + lwmqtt_string_t password = {8, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -10016,15 +9458,18 @@ TEST(Connect311QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\254\216\220\247\151\136\DC1\188~L\248\142", _password = Nothing, _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = -// "U6Dw\178\166\201q\230\187\STX\187>P\180\&1\224[W\181\GS:", _willMsg = "", _willProps = []}), _cleanSession = False, -// _keepAlive = 29562, _connID = "~\233\223\144\214,\GSg\DLE\144\196=<", _properties = []} +// ConnectRequest {_username = Just "\207*R\174r\141;b'{=", _password = Just +// "z\205\192_%@\212\199\151\215c|\247\189\171\&4]G\215\ETB", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS2, _willTopic = "\DC3\145\DC4\145\NUL\135\137|", _willMsg = +// "\161\158s\143&OOq\DC3Z\EM\t\230\252G1A\220j\197i\US5", _willProps = []}), _cleanSession = True, _keepAlive = 13315, +// _connID = "%t\158\172\148\133\248\183\148\DELO\147T\240\DC3+", _properties = []} TEST(Connect311QCTest, Encode27) { - uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8c, 0x73, 0x7a, 0x0, 0xd, 0x7e, 0xe9, 0xdf, - 0x90, 0xd6, 0x2c, 0x1d, 0x67, 0x10, 0x90, 0xc4, 0x3d, 0x3c, 0x0, 0x16, 0x55, 0x36, 0x44, 0x77, 0xb2, - 0xa6, 0xc9, 0x71, 0xe6, 0xbb, 0x2, 0xbb, 0x3e, 0x50, 0xb4, 0x31, 0xe0, 0x5b, 0x57, 0xb5, 0x1d, 0x3a, - 0x0, 0x0, 0x0, 0xc, 0xfe, 0xd8, 0xdc, 0xf7, 0x97, 0x88, 0x11, 0xbc, 0x7e, 0x4c, 0xf8, 0x8e}; + uint8_t pkt[] = {0x10, 0x62, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xf6, 0x34, 0x3, 0x0, 0x10, 0x25, 0x74, 0x9e, + 0xac, 0x94, 0x85, 0xf8, 0xb7, 0x94, 0x7f, 0x4f, 0x93, 0x54, 0xf0, 0x13, 0x2b, 0x0, 0x8, 0x13, 0x91, + 0x14, 0x91, 0x0, 0x87, 0x89, 0x7c, 0x0, 0x17, 0xa1, 0x9e, 0x73, 0x8f, 0x26, 0x4f, 0x4f, 0x71, 0x13, + 0x5a, 0x19, 0x9, 0xe6, 0xfc, 0x47, 0x31, 0x41, 0xdc, 0x6a, 0xc5, 0x69, 0x1f, 0x35, 0x0, 0xb, 0xcf, + 0x2a, 0x52, 0xae, 0x72, 0x8d, 0x3b, 0x62, 0x27, 0x7b, 0x3d, 0x0, 0x14, 0x7a, 0xcd, 0xc0, 0x5f, 0x25, + 0x40, 0xd4, 0xc7, 0x97, 0xd7, 0x63, 0x7c, 0xf7, 0xbd, 0xab, 0x34, 0x5d, 0x47, 0xd7, 0x17}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -10035,26 +9480,31 @@ TEST(Connect311QCTest, Encode27) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x55, 0x36, 0x44, 0x77, 0xb2, 0xa6, 0xc9, 0x71, 0xe6, 0xbb, 0x2, - 0xbb, 0x3e, 0x50, 0xb4, 0x31, 0xe0, 0x5b, 0x57, 0xb5, 0x1d, 0x3a}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x13, 0x91, 0x14, 0x91, 0x0, 0x87, 0x89, 0x7c}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa1, 0x9e, 0x73, 0x8f, 0x26, 0x4f, 0x4f, 0x71, 0x13, 0x5a, 0x19, 0x9, + 0xe6, 0xfc, 0x47, 0x31, 0x41, 0xdc, 0x6a, 0xc5, 0x69, 0x1f, 0x35}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; + will.qos = LWMQTT_QOS2; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 29562; - uint8_t client_id_bytes[] = {0x7e, 0xe9, 0xdf, 0x90, 0xd6, 0x2c, 0x1d, 0x67, 0x10, 0x90, 0xc4, 0x3d, 0x3c}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 13315; + uint8_t client_id_bytes[] = {0x25, 0x74, 0x9e, 0xac, 0x94, 0x85, 0xf8, 0xb7, + 0x94, 0x7f, 0x4f, 0x93, 0x54, 0xf0, 0x13, 0x2b}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xfe, 0xd8, 0xdc, 0xf7, 0x97, 0x88, 0x11, 0xbc, 0x7e, 0x4c, 0xf8, 0x8e}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xcf, 0x2a, 0x52, 0xae, 0x72, 0x8d, 0x3b, 0x62, 0x27, 0x7b, 0x3d}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; opts.username = username; + uint8_t password_bytes[] = {0x7a, 0xcd, 0xc0, 0x5f, 0x25, 0x40, 0xd4, 0xc7, 0x97, 0xd7, + 0x63, 0x7c, 0xf7, 0xbd, 0xab, 0x34, 0x5d, 0x47, 0xd7, 0x17}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -10063,16 +9513,13 @@ TEST(Connect311QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "W\NAK1\208\fP\SYN\143\223", _password = Just -// "-\161\CAN\233\GSA\129\195n,\214\STX\138", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, -// _willTopic = "\163", _willMsg = "^\216\194\&8-V`\191\"\215\247\221\210\t\EOT\SOt\209\205\SI\SO", _willProps = []}), -// _cleanSession = True, _keepAlive = 7229, _connID = "h$3\ESC%\229\134-\RS\205O", _properties = []} +// ConnectRequest {_username = Nothing, _password = Just "9\SUBa", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS1, _willTopic = "\229Zo\akR\167\175\227\&7\152-\t\SO\240(\CAN+\178\193\170%7\140\228\200\241\175N", +// _willMsg = "\\DN", _willProps = []}), _cleanSession = True, _keepAlive = 2663, _connID = "_", _properties = []} TEST(Connect311QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0x4b, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xce, 0x1c, 0x3d, 0x0, 0xb, 0x68, 0x24, - 0x33, 0x1b, 0x25, 0xe5, 0x86, 0x2d, 0x1e, 0xcd, 0x4f, 0x0, 0x1, 0xa3, 0x0, 0x15, 0x5e, 0xd8, - 0xc2, 0x38, 0x2d, 0x56, 0x60, 0xbf, 0x22, 0xd7, 0xf7, 0xdd, 0xd2, 0x9, 0x4, 0xe, 0x74, 0xd1, - 0xcd, 0xf, 0xe, 0x0, 0x9, 0x57, 0x15, 0x31, 0xd0, 0xc, 0x50, 0x16, 0x8f, 0xdf, 0x0, 0xd, - 0x2d, 0xa1, 0x18, 0xe9, 0x1d, 0x41, 0x81, 0xc3, 0x6e, 0x2c, 0xd6, 0x2, 0x8a}; + uint8_t pkt[] = {0x10, 0x31, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0xe, 0xa, 0x67, 0x0, 0x1, 0x5f, 0x0, 0x1d, + 0xe5, 0x5a, 0x6f, 0x7, 0x6b, 0x52, 0xa7, 0xaf, 0xe3, 0x37, 0x98, 0x2d, 0x9, 0xe, 0xf0, 0x28, 0x18, + 0x2b, 0xb2, 0xc1, 0xaa, 0x25, 0x37, 0x8c, 0xe4, 0xc8, 0xf1, 0xaf, 0x4e, 0x0, 0x3, 0x5c, 0x44, 0x4e}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -10083,11 +9530,11 @@ TEST(Connect311QCTest, Encode28) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa3}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5e, 0xd8, 0xc2, 0x38, 0x2d, 0x56, 0x60, 0xbf, 0x22, 0xd7, 0xf7, - 0xdd, 0xd2, 0x9, 0x4, 0xe, 0x74, 0xd1, 0xcd, 0xf, 0xe}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0xe5, 0x5a, 0x6f, 0x7, 0x6b, 0x52, 0xa7, 0xaf, 0xe3, 0x37, 0x98, 0x2d, 0x9, 0xe, 0xf0, + 0x28, 0x18, 0x2b, 0xb2, 0xc1, 0xaa, 0x25, 0x37, 0x8c, 0xe4, 0xc8, 0xf1, 0xaf, 0x4e}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5c, 0x44, 0x4e}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -10096,15 +9543,12 @@ TEST(Connect311QCTest, Encode28) { lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 7229; - uint8_t client_id_bytes[] = {0x68, 0x24, 0x33, 0x1b, 0x25, 0xe5, 0x86, 0x2d, 0x1e, 0xcd, 0x4f}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.keep_alive = 2663; + uint8_t client_id_bytes[] = {0x5f}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x57, 0x15, 0x31, 0xd0, 0xc, 0x50, 0x16, 0x8f, 0xdf}; - lwmqtt_string_t username = {9, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x2d, 0xa1, 0x18, 0xe9, 0x1d, 0x41, 0x81, 0xc3, 0x6e, 0x2c, 0xd6, 0x2, 0x8a}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x39, 0x1a, 0x61}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -10114,17 +9558,16 @@ TEST(Connect311QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "E\158", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS0, _willTopic = "\SUB\167\200rR\DEL\237>\147\&3\t-\134,", _willMsg = -// "\EOT{\DC2S\216=\181\216\SOH\225\153\&6(\205\197\&1\ETX\STX\DEL", _willProps = []}), _cleanSession = True, _keepAlive -// = 27479, _connID = "\237\&2\143\179g\138\189\190\155l\NUL\242~\ETXJ\222^\147-\STX\140\210\198a\249", _properties = -// []} +// ConnectRequest {_username = Just "fF\131\191\&2\166\189\187F", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\ESC\162W>\201\134", _willMsg = +// "\CAN\EOT\254w\EOT&B2\STX\130\DC2\130\234\202\238\&1\DC4\179\ETB\223\169\132GI&\ACK", _willProps = []}), +// _cleanSession = False, _keepAlive = 16611, _connID = "P\213\SOHx\239\228P", _properties = []} TEST(Connect311QCTest, Encode29) { - uint8_t pkt[] = {0x10, 0x4e, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x86, 0x6b, 0x57, 0x0, 0x19, 0xed, 0x32, - 0x8f, 0xb3, 0x67, 0x8a, 0xbd, 0xbe, 0x9b, 0x6c, 0x0, 0xf2, 0x7e, 0x3, 0x4a, 0xde, 0x5e, 0x93, - 0x2d, 0x2, 0x8c, 0xd2, 0xc6, 0x61, 0xf9, 0x0, 0xe, 0x1a, 0xa7, 0xc8, 0x72, 0x52, 0x7f, 0xed, - 0x3e, 0x93, 0x33, 0x9, 0x2d, 0x86, 0x2c, 0x0, 0x13, 0x4, 0x7b, 0x12, 0x53, 0xd8, 0x3d, 0xb5, - 0xd8, 0x1, 0xe1, 0x99, 0x36, 0x28, 0xcd, 0xc5, 0x31, 0x3, 0x2, 0x7f, 0x0, 0x2, 0x45, 0x9e}; + uint8_t pkt[] = {0x10, 0x42, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x4, 0x8c, 0x40, 0xe3, 0x0, 0x7, + 0x50, 0xd5, 0x1, 0x78, 0xef, 0xe4, 0x50, 0x0, 0x6, 0x1b, 0xa2, 0x57, 0x3e, 0xc9, + 0x86, 0x0, 0x1a, 0x18, 0x4, 0xfe, 0x77, 0x4, 0x26, 0x42, 0x32, 0x2, 0x82, 0x12, + 0x82, 0xea, 0xca, 0xee, 0x31, 0x14, 0xb3, 0x17, 0xdf, 0xa9, 0x84, 0x47, 0x49, 0x26, + 0x6, 0x0, 0x9, 0x66, 0x46, 0x83, 0xbf, 0x32, 0xa6, 0xbd, 0xbb, 0x46}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -10135,26 +9578,25 @@ TEST(Connect311QCTest, Encode29) { lwmqtt_property_t willpropslist[] = {}; lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1a, 0xa7, 0xc8, 0x72, 0x52, 0x7f, 0xed, 0x3e, 0x93, 0x33, 0x9, 0x2d, 0x86, 0x2c}; - lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x4, 0x7b, 0x12, 0x53, 0xd8, 0x3d, 0xb5, 0xd8, 0x1, 0xe1, - 0x99, 0x36, 0x28, 0xcd, 0xc5, 0x31, 0x3, 0x2, 0x7f}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x1b, 0xa2, 0x57, 0x3e, 0xc9, 0x86}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x18, 0x4, 0xfe, 0x77, 0x4, 0x26, 0x42, 0x32, 0x2, 0x82, 0x12, 0x82, 0xea, + 0xca, 0xee, 0x31, 0x14, 0xb3, 0x17, 0xdf, 0xa9, 0x84, 0x47, 0x49, 0x26, 0x6}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 27479; - uint8_t client_id_bytes[] = {0xed, 0x32, 0x8f, 0xb3, 0x67, 0x8a, 0xbd, 0xbe, 0x9b, 0x6c, 0x0, 0xf2, 0x7e, - 0x3, 0x4a, 0xde, 0x5e, 0x93, 0x2d, 0x2, 0x8c, 0xd2, 0xc6, 0x61, 0xf9}; - lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 16611; + uint8_t client_id_bytes[] = {0x50, 0xd5, 0x1, 0x78, 0xef, 0xe4, 0x50}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x45, 0x9e}; - lwmqtt_string_t username = {2, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x66, 0x46, 0x83, 0xbf, 0x32, 0xa6, 0xbd, 0xbb, 0x46}; + lwmqtt_string_t username = {9, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT311, opts, &will); @@ -10164,98 +9606,116 @@ TEST(Connect311QCTest, Encode29) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\201\216\NAK\238\243\185\202\212?\188\224\STX/\198h\162\159z\193", _password = Just -// "\220\192\199\173G\186\161\178", _lastWill = Nothing, _cleanSession = True, _keepAlive = 7221, _connID = -// "\191nx\FSO\157\147i\209\143\DC2\STX\160\SI\215", _properties = []} +// ConnectRequest {_username = Just "y\204\237\224r>\158", _password = Nothing, _lastWill = Just (LastWill {_willRetain +// = False, _willQoS = QoS1, _willTopic = +// "[J\196H\203W\CAN\171&\151\152S\228\245A\CAN%\DLE\139+/jE",PropTopicAliasMaximum 23557,PropSubscriptionIdentifierAvailable -// 215,PropReasonString -// "\192|;\RS\214}\216\205\196\151\160q\178\DLE\251\224\201`\209\DLE=\198\EOT-",PropSharedSubscriptionAvailable -// 29,PropReceiveMaximum 13694,PropServerKeepAlive 28821,PropRetainAvailable 74,PropResponseTopic "\190\129\133\208"]} +// ConnectRequest {_username = Just "\153L\a#", _password = Just "\244\162\153\142%\219Js!\226", _lastWill = Nothing, +// _cleanSession = True, _keepAlive = 2234, _connID = "E\DC4X\158P\157\128Y{\243sRl\186'", _properties = +// [PropRetainAvailable 199,PropSubscriptionIdentifierAvailable 24,PropWillDelayInterval +// 16038,PropRequestResponseInformation 243,PropServerKeepAlive 21698,PropPayloadFormatIndicator +// 18,PropWildcardSubscriptionAvailable 142,PropAuthenticationMethod +// "\227\&9\138\&1z\177\DC1lB\211\203r`\220c;\174\&6B\ETX\223\GS\199\152",PropTopicAlias 12038,PropAuthenticationData +// "cAq\152\159\155]j\199\b\133J\252\&4\170\SOQ\r#\"B\193M\177",PropReasonString +// "\EM\154s\215\RS9\208\159\FS\245w\203\161\218d\249J\229S,\159J",PropSubscriptionIdentifierAvailable +// 37,PropAuthenticationData ""]} TEST(Connect5QCTest, Encode1) { - uint8_t pkt[] = {0x10, 0xa4, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x4, 0xea, 0x64, 0x1a, 0x0, 0x13, - 0xce, 0x5a, 0xa7, 0xd2, 0x8d, 0xa4, 0x22, 0xb4, 0xb8, 0x6d, 0x7a, 0x6c, 0x76, 0xb0, 0x95, 0xcf, 0x3f, - 0x89, 0xea, 0x12, 0x0, 0x2, 0x68, 0x66, 0x1c, 0x0, 0x15, 0x61, 0x6a, 0x0, 0xad, 0xc8, 0xe8, 0xd3, - 0x19, 0x43, 0x2c, 0x71, 0x8, 0x5d, 0x79, 0x88, 0x66, 0x4, 0x5, 0x3a, 0x3e, 0x45, 0x22, 0x5c, 0x5, - 0x29, 0xd7, 0x1f, 0x0, 0x18, 0xc0, 0x7c, 0x3b, 0x1e, 0xd6, 0x7d, 0xd8, 0xcd, 0xc4, 0x97, 0xa0, 0x71, - 0xb2, 0x10, 0xfb, 0xe0, 0xc9, 0x60, 0xd1, 0x10, 0x3d, 0xc6, 0x4, 0x2d, 0x2a, 0x1d, 0x21, 0x35, 0x7e, - 0x13, 0x70, 0x95, 0x25, 0x4a, 0x8, 0x0, 0x4, 0xbe, 0x81, 0x85, 0xd0, 0x0, 0x15, 0x71, 0x1, 0xdc, - 0x80, 0xa, 0x63, 0x4e, 0x25, 0xbc, 0x37, 0xf8, 0x46, 0x50, 0x40, 0xaa, 0x0, 0x7f, 0x4e, 0xc2, 0xdd, - 0x6f, 0x0, 0xe, 0x5d, 0x6b, 0x85, 0x9e, 0x9b, 0x13, 0x18, 0x64, 0x42, 0x95, 0xf4, 0x15, 0x56, 0xae, - 0x0, 0xc, 0xf3, 0x65, 0x1a, 0xc4, 0x44, 0xb, 0xc4, 0x57, 0x38, 0x50, 0xf5, 0x36}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xce, 0x5a, 0xa7, 0xd2, 0x8d, 0xa4, 0x22, 0xb4, 0xb8, 0x6d, - 0x7a, 0x6c, 0x76, 0xb0, 0x95, 0xcf, 0x3f, 0x89, 0xea}; - uint8_t bytesprops1[] = {0x68, 0x66}; - uint8_t bytesprops2[] = {0x61, 0x6a, 0x0, 0xad, 0xc8, 0xe8, 0xd3, 0x19, 0x43, 0x2c, 0x71, - 0x8, 0x5d, 0x79, 0x88, 0x66, 0x4, 0x5, 0x3a, 0x3e, 0x45}; - uint8_t bytesprops3[] = {0xc0, 0x7c, 0x3b, 0x1e, 0xd6, 0x7d, 0xd8, 0xcd, 0xc4, 0x97, 0xa0, 0x71, - 0xb2, 0x10, 0xfb, 0xe0, 0xc9, 0x60, 0xd1, 0x10, 0x3d, 0xc6, 0x4, 0x2d}; - uint8_t bytesprops4[] = {0xbe, 0x81, 0x85, 0xd0}; + uint8_t pkt[] = {0x10, 0x97, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x8, 0xba, 0x69, 0x25, 0xc7, + 0x29, 0x18, 0x18, 0x0, 0x0, 0x3e, 0xa6, 0x19, 0xf3, 0x13, 0x54, 0xc2, 0x1, 0x12, 0x28, 0x8e, + 0x15, 0x0, 0x18, 0xe3, 0x39, 0x8a, 0x31, 0x7a, 0xb1, 0x11, 0x6c, 0x42, 0xd3, 0xcb, 0x72, 0x60, + 0xdc, 0x63, 0x3b, 0xae, 0x36, 0x42, 0x3, 0xdf, 0x1d, 0xc7, 0x98, 0x23, 0x2f, 0x6, 0x16, 0x0, + 0x18, 0x63, 0x41, 0x71, 0x98, 0x9f, 0x9b, 0x5d, 0x6a, 0xc7, 0x8, 0x85, 0x4a, 0xfc, 0x34, 0xaa, + 0xe, 0x51, 0xd, 0x23, 0x22, 0x42, 0xc1, 0x4d, 0xb1, 0x1f, 0x0, 0x16, 0x19, 0x9a, 0x73, 0xd7, + 0x1e, 0x39, 0xd0, 0x9f, 0x1c, 0xf5, 0x77, 0xcb, 0xa1, 0xda, 0x64, 0xf9, 0x4a, 0xe5, 0x53, 0x2c, + 0x9f, 0x4a, 0x29, 0x25, 0x16, 0x0, 0x0, 0x0, 0xf, 0x45, 0x14, 0x58, 0x9e, 0x50, 0x9d, 0x80, + 0x59, 0x7b, 0xf3, 0x73, 0x52, 0x6c, 0xba, 0x27, 0x0, 0x4, 0x99, 0x4c, 0x7, 0x23, 0x0, 0xa, + 0xf4, 0xa2, 0x99, 0x8e, 0x25, 0xdb, 0x4a, 0x73, 0x21, 0xe2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe3, 0x39, 0x8a, 0x31, 0x7a, 0xb1, 0x11, 0x6c, 0x42, 0xd3, 0xcb, 0x72, + 0x60, 0xdc, 0x63, 0x3b, 0xae, 0x36, 0x42, 0x3, 0xdf, 0x1d, 0xc7, 0x98}; + uint8_t bytesprops1[] = {0x63, 0x41, 0x71, 0x98, 0x9f, 0x9b, 0x5d, 0x6a, 0xc7, 0x8, 0x85, 0x4a, + 0xfc, 0x34, 0xaa, 0xe, 0x51, 0xd, 0x23, 0x22, 0x42, 0xc1, 0x4d, 0xb1}; + uint8_t bytesprops2[] = {0x19, 0x9a, 0x73, 0xd7, 0x1e, 0x39, 0xd0, 0x9f, 0x1c, 0xf5, 0x77, + 0xcb, 0xa1, 0xda, 0x64, 0xf9, 0x4a, 0xe5, 0x53, 0x2c, 0x9f, 0x4a}; + uint8_t bytesprops3[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23557}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 29}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13694}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28821}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16038}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21698}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12038}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 1258; - uint8_t client_id_bytes[] = {0x71, 0x1, 0xdc, 0x80, 0xa, 0x63, 0x4e, 0x25, 0xbc, 0x37, 0xf8, - 0x46, 0x50, 0x40, 0xaa, 0x0, 0x7f, 0x4e, 0xc2, 0xdd, 0x6f}; - lwmqtt_string_t client_id = {21, (char*)&client_id_bytes}; + opts.keep_alive = 2234; + uint8_t client_id_bytes[] = {0x45, 0x14, 0x58, 0x9e, 0x50, 0x9d, 0x80, 0x59, + 0x7b, 0xf3, 0x73, 0x52, 0x6c, 0xba, 0x27}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x5d, 0x6b, 0x85, 0x9e, 0x9b, 0x13, 0x18, 0x64, 0x42, 0x95, 0xf4, 0x15, 0x56, 0xae}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x99, 0x4c, 0x7, 0x23}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xf3, 0x65, 0x1a, 0xc4, 0x44, 0xb, 0xc4, 0x57, 0x38, 0x50, 0xf5, 0x36}; - lwmqtt_string_t password = {12, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xf4, 0xa2, 0x99, 0x8e, 0x25, 0xdb, 0x4a, 0x73, 0x21, 0xe2}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); @@ -10265,52 +9725,116 @@ TEST(Connect5QCTest, Encode1) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "G>+\146\187X\SUB\205\220Z.\247\207\STX", _password = Just "l\254", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "H\158\252\SO\244\128\177\DC3\140m\154C\228\255\209\SO\252\215Wt\129t}\131", _willMsg = -// ";\228r\149\RS]\243u\250o\247\164,_\199", _willProps = [PropSubscriptionIdentifier 9,PropSessionExpiryInterval -// 20324,PropRequestResponseInformation 35,PropServerReference "",PropRequestProblemInformation -// 170,PropSessionExpiryInterval 14603,PropWillDelayInterval 29990,PropSubscriptionIdentifierAvailable 90]}), -// _cleanSession = False, _keepAlive = 6895, _connID = "/\215\GS\133\&67\233\250\218\RS\249)\ETB", _properties = -// [PropSharedSubscriptionAvailable 226,PropTopicAliasMaximum 13928]} +// ConnectRequest {_username = Nothing, _password = Just +// "\254\241\198\183\211\244\131\&2\170\194\EOT\SYN\226H\226\&0\134\t\187'", _lastWill = Just (LastWill {_willRetain = +// True, _willQoS = QoS1, _willTopic = +// "\228\176\251j\SI\151m\GS}\147\222\ft\169!\153b\159\254\208\202\212\233\153\231\SUB\175\224\138", _willMsg = +// "\EOT\138\DC3b\NUL\226X\227XU\t\166\177\SOHR\DEL\DC4vC\132", _willProps = [PropReceiveMaximum +// 6013,PropAssignedClientIdentifier "O\169\ACK$a\253\132L\224F\253\DC1\159\194\ACK",PropRequestResponseInformation +// 146,PropResponseInformation "g\234\174i\158\212 \163\166\218\136\226\242S\131&f\152\160\n\STX",PropResponseTopic +// "\254\146",PropTopicAliasMaximum 3877,PropWillDelayInterval 17477,PropServerKeepAlive +// 23371,PropPayloadFormatIndicator 201,PropTopicAliasMaximum 29604,PropWillDelayInterval 32640,PropServerKeepAlive +// 4538,PropReasonString "l",PropWillDelayInterval 2457,PropSubscriptionIdentifierAvailable 37,PropReceiveMaximum +// 12805,PropResponseInformation "\185\163N\212",PropAssignedClientIdentifier +// "\RSf\177<\224!\204NE\197f\196\230",PropResponseInformation "L\166\155\174\164\216\&64%@\217\209\132&74"]}), +// _cleanSession = True, _keepAlive = 6210, _connID = "\194\231\179\200\206\DLE\208\132\139\v\171\161\163\159\153", +// _properties = [PropSubscriptionIdentifierAvailable 244,PropAuthenticationData +// "[\223\146\&5\197Y}\210(7\216G\222\DLE\161P{\US`\t\r",PropReceiveMaximum 21437,PropSharedSubscriptionAvailable +// 59,PropResponseTopic "a\190:8b-fl\158\195\EM!",PropRequestProblemInformation 54,PropMessageExpiryInterval +// 7191,PropServerReference +// "\212\189~\180\236\a8\180\180\247c7\236\ETX\139J\221\235\158\209\SOH2\143\GS\144",PropReceiveMaximum +// 25600,PropSharedSubscriptionAvailable 187,PropResponseTopic "\DC1\191o\156\229\170\&3^\189P",PropReceiveMaximum +// 24006,PropServerKeepAlive 28202,PropServerReference "\158X1\197\DC1m\157\224\b\167\134\222\&1\190\172"]} TEST(Connect5QCTest, Encode2) { - uint8_t pkt[] = {0x10, 0x79, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xec, 0x1a, 0xef, 0x5, 0x2a, 0xe2, 0x22, - 0x36, 0x68, 0x0, 0xd, 0x2f, 0xd7, 0x1d, 0x85, 0x36, 0x37, 0xe9, 0xfa, 0xda, 0x1e, 0xf9, 0x29, - 0x17, 0x1a,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d8, 0x36, 0x34, 0x25, 0x40, 0xd9, 0xd1, 0x84, + 0x26, 0x37, 0x34, 0x0, 0x1d, 0xe4, 0xb0, 0xfb, 0x6a, 0xf, 0x97, 0x6d, 0x1d, 0x7d, 0x93, 0xde, 0xc, 0x74, 0xa9, + 0x21, 0x99, 0x62, 0x9f, 0xfe, 0xd0, 0xca, 0xd4, 0xe9, 0x99, 0xe7, 0x1a, 0xaf, 0xe0, 0x8a, 0x0, 0x14, 0x4, 0x8a, + 0x13, 0x62, 0x0, 0xe2, 0x58, 0xe3, 0x58, 0x55, 0x9, 0xa6, 0xb1, 0x1, 0x52, 0x7f, 0x14, 0x76, 0x43, 0x84, 0x0, + 0x14, 0xfe, 0xf1, 0xc6, 0xb7, 0xd3, 0xf4, 0x83, 0x32, 0xaa, 0xc2, 0x4, 0x16, 0xe2, 0x48, 0xe2, 0x30, 0x86, 0x9, + 0xbb, 0x27}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x5b, 0xdf, 0x92, 0x35, 0xc5, 0x59, 0x7d, 0xd2, 0x28, 0x37, 0xd8, + 0x47, 0xde, 0x10, 0xa1, 0x50, 0x7b, 0x1f, 0x60, 0x9, 0xd}; + uint8_t bytesprops1[] = {0x61, 0xbe, 0x3a, 0x38, 0x62, 0x2d, 0x66, 0x6c, 0x9e, 0xc3, 0x19, 0x21}; + uint8_t bytesprops2[] = {0xd4, 0xbd, 0x7e, 0xb4, 0xec, 0x7, 0x38, 0xb4, 0xb4, 0xf7, 0x63, 0x37, 0xec, + 0x3, 0x8b, 0x4a, 0xdd, 0xeb, 0x9e, 0xd1, 0x1, 0x32, 0x8f, 0x1d, 0x90}; + uint8_t bytesprops3[] = {0x11, 0xbf, 0x6f, 0x9c, 0xe5, 0xaa, 0x33, 0x5e, 0xbd, 0x50}; + uint8_t bytesprops4[] = {0x9e, 0x58, 0x31, 0xc5, 0x11, 0x6d, 0x9d, 0xe0, 0x8, 0xa7, 0x86, 0xde, 0x31, 0xbe, 0xac}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13928}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21437}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 54}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7191}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25600}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 187}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24006}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28202}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops4}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops0[] = {0x4f, 0xa9, 0x6, 0x24, 0x61, 0xfd, 0x84, 0x4c, 0xe0, 0x46, 0xfd, 0x11, 0x9f, 0xc2, 0x6}; + uint8_t byteswillprops1[] = {0x67, 0xea, 0xae, 0x69, 0x9e, 0xd4, 0x20, 0xa3, 0xa6, 0xda, 0x88, + 0xe2, 0xf2, 0x53, 0x83, 0x26, 0x66, 0x98, 0xa0, 0xa, 0x2}; + uint8_t byteswillprops2[] = {0xfe, 0x92}; + uint8_t byteswillprops3[] = {0x6c}; + uint8_t byteswillprops4[] = {0xb9, 0xa3, 0x4e, 0xd4}; + uint8_t byteswillprops5[] = {0x1e, 0x66, 0xb1, 0x3c, 0xe0, 0x21, 0xcc, 0x4e, 0x45, 0xc5, 0x66, 0xc4, 0xe6}; + uint8_t byteswillprops6[] = {0x4c, 0xa6, 0x9b, 0xae, 0xa4, 0xd8, 0x36, 0x34, + 0x25, 0x40, 0xd9, 0xd1, 0x84, 0x26, 0x37, 0x34}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20324}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14603}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29990}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6013}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3877}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17477}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23371}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29604}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32640}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4538}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2457}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12805}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops6}}}, }; - lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x48, 0x9e, 0xfc, 0xe, 0xf4, 0x80, 0xb1, 0x13, 0x8c, 0x6d, 0x9a, 0x43, - 0xe4, 0xff, 0xd1, 0xe, 0xfc, 0xd7, 0x57, 0x74, 0x81, 0x74, 0x7d, 0x83}; - lwmqtt_string_t will_topic = {24, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x3b, 0xe4, 0x72, 0x95, 0x1e, 0x5d, 0xf3, 0x75, - 0xfa, 0x6f, 0xf7, 0xa4, 0x2c, 0x5f, 0xc7}; - lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe4, 0xb0, 0xfb, 0x6a, 0xf, 0x97, 0x6d, 0x1d, 0x7d, 0x93, + 0xde, 0xc, 0x74, 0xa9, 0x21, 0x99, 0x62, 0x9f, 0xfe, 0xd0, + 0xca, 0xd4, 0xe9, 0x99, 0xe7, 0x1a, 0xaf, 0xe0, 0x8a}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4, 0x8a, 0x13, 0x62, 0x0, 0xe2, 0x58, 0xe3, 0x58, 0x55, + 0x9, 0xa6, 0xb1, 0x1, 0x52, 0x7f, 0x14, 0x76, 0x43, 0x84}; + lwmqtt_string_t will_payload = {20, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -10318,16 +9842,14 @@ TEST(Connect5QCTest, Encode2) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 6895; - uint8_t client_id_bytes[] = {0x2f, 0xd7, 0x1d, 0x85, 0x36, 0x37, 0xe9, 0xfa, 0xda, 0x1e, 0xf9, 0x29, 0x17}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 6210; + uint8_t client_id_bytes[] = {0xc2, 0xe7, 0xb3, 0xc8, 0xce, 0x10, 0xd0, 0x84, 0x8b, 0xb, 0xab, 0xa1, 0xa3, 0x9f, 0x99}; + lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x47, 0x3e, 0x2b, 0x92, 0xbb, 0x58, 0x1a, 0xcd, 0xdc, 0x5a, 0x2e, 0xf7, 0xcf, 0x2}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x6c, 0xfe}; - lwmqtt_string_t password = {2, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xfe, 0xf1, 0xc6, 0xb7, 0xd3, 0xf4, 0x83, 0x32, 0xaa, 0xc2, + 0x4, 0x16, 0xe2, 0x48, 0xe2, 0x30, 0x86, 0x9, 0xbb, 0x27}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10337,268 +9859,212 @@ TEST(Connect5QCTest, Encode2) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "P\174D\148^\175O\GS", _password = Nothing, _lastWill = Just (LastWill {_willRetain -// = True, _willQoS = QoS0, _willTopic = -// "\133\148;\217\ETX\ESCx\227\193\b\220\220\&2^\206\247,\208\184E\206g\130\RS\174\176\224", _willMsg = -// "&2\134`\139\156\254r\254!RA2\206\243\188", _willProps = [PropRequestResponseInformation 41,PropServerKeepAlive -// 6037,PropWillDelayInterval 27175,PropRequestResponseInformation 221,PropResponseInformation -// "~\DC1?\131\177\194E\176\251mF\241\251\180E\SOH\159",PropServerReference -// "\180'\165\245\215\158",PropWildcardSubscriptionAvailable 180,PropCorrelationData -// "Id\SOH\213\219L\168\173\DC1y",PropSubscriptionIdentifier 9,PropMessageExpiryInterval 13265,PropResponseTopic -// "<\208\227\226Q\vIi\163\231\244\200F\162\&1)\SO\EM\206",PropUserProperty -// "\139\145bW\CAN\204\244\213B\245\245\SO\242\189K\176\137\231T-\\\DC3" -// "cx_\162\173\171+dB\ETB\198Z\216\232jpq\140\211HX:\248\158\US,",PropTopicAlias -// 30639,PropSubscriptionIdentifierAvailable 134,PropWillDelayInterval 32737,PropServerReference -// "\SI\b",PropMessageExpiryInterval 15476,PropCorrelationData "\161\240*\233n\RS\216 -// \213p)\146B\136e\199\158\223\166X\169\183",PropPayloadFormatIndicator 9]}), _cleanSession = False, _keepAlive = -// 25004, _connID = "/}b5\208\133\FS\133\214c\NUL\151\144\NUL\172\SO\168&&\150\174\191N\206", _properties = -// [PropServerReference "Z\160\206\229X\251-H\tu'\NUL\252\RS\244d\238",PropSharedSubscriptionAvailable -// 203,PropSharedSubscriptionAvailable 239,PropContentType "\165\SUBU\206\&5\250;H",PropAssignedClientIdentifier -// "yHF3\182\170\&0\174%\238\SO\152\ESC\191\176\&7Ov",PropMaximumQoS 220,PropServerKeepAlive -// 29952,PropSubscriptionIdentifier 11,PropMaximumQoS 184,PropReasonString -// "\214\136n*\250\233\\m\208\DC3L\a\135\192\EM\201\RSL\228",PropResponseInformation -// "\ETX\137\247F",PropMessageExpiryInterval 6277,PropAuthenticationData "\DC1q\214\&2\206F\137#\240\144D<4p\NUL"]} +// ConnectRequest {_username = Nothing, _password = Just "3m\161\216\&1\215\GS", _lastWill = Nothing, _cleanSession = +// True, _keepAlive = 22788, _connID = "", _properties = [PropReasonString " +// \177KHn\DC1\213\167P\133\195",PropCorrelationData "f\223\174G\148a\213\183R?\163\228Mu",PropAuthenticationMethod +// "",PropMessageExpiryInterval 25071,PropWillDelayInterval 16193,PropMessageExpiryInterval +// 3736,PropAuthenticationMethod "A +// \237Ca6\DC1\131\247\SOH\220\252_u\176@\EOT\170\145/\176\233\216\178\142\&7\226",PropWildcardSubscriptionAvailable +// 13,PropRetainAvailable 113,PropWildcardSubscriptionAvailable 200,PropMessageExpiryInterval 15251,PropReceiveMaximum +// 29555,PropTopicAlias 1586,PropCorrelationData +// "7!\210\ESCG\170\210G]\134\129\221\&5\159\253@\208\146\r",PropSubscriptionIdentifierAvailable +// 234,PropRequestProblemInformation 88,PropTopicAliasMaximum 27297,PropResponseInformation +// "]\163p@vEU\153\DC1i",PropUserProperty "\229\139!\143pY\166a\US\154\SUB" +// "\164*A\EM'\226\152\166:\r53",PropResponseInformation +// "@\a\138\164\DC1590,q\173\ENQ6E\194\237\&1\221\158:\DEL",PropRequestResponseInformation 8,PropMaximumPacketSize +// 20396,PropUserProperty "t\144\158\ENQ\220\176Q\136\140# \182d\178\197\188\224e\171\151/" +// "pP!\t\212l",PropRequestResponseInformation 71,PropMessageExpiryInterval 24599,PropCorrelationData +// "\225W7(\131\SOH\238\189s\135w"]} TEST(Connect5QCTest, Encode3) { uint8_t pkt[] = { - 0x10, 0x8e, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xa4, 0x61, 0xac, 0x75, 0x1c, 0x0, 0x11, 0x5a, 0xa0, - 0xce, 0xe5, 0x58, 0xfb, 0x2d, 0x48, 0x9, 0x75, 0x27, 0x0, 0xfc, 0x1e, 0xf4, 0x64, 0xee, 0x2a, 0xcb, 0x2a, 0xef, - 0x3, 0x0, 0x8, 0xa5, 0x1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49, 0x69, 0xa3, 0xe7, 0xf4, 0xc8, 0x46, 0xa2, 0x31, 0x29, 0xe, 0x19, 0xce, 0x26, 0x0, 0x16, - 0x8b, 0x91, 0x62, 0x57, 0x18, 0xcc, 0xf4, 0xd5, 0x42, 0xf5, 0xf5, 0xe, 0xf2, 0xbd, 0x4b, 0xb0, 0x89, 0xe7, 0x54, - 0x2d, 0x5c, 0x13, 0x0, 0x1a, 0x63, 0x78, 0x5f, 0xa2, 0xad, 0xab, 0x2b, 0x64, 0x42, 0x17, 0xc6, 0x5a, 0xd8, 0xe8, - 0x6a, 0x70, 0x71, 0x8c, 0xd3, 0x48, 0x58, 0x3a, 0xf8, 0x9e, 0x1f, 0x2c, 0x23, 0x77, 0xaf, 0x29, 0x86, 0x18, 0x0, - 0x0, 0x7f, 0xe1, 0x1c, 0x0, 0x2, 0xf, 0x8, 0x2, 0x0, 0x0, 0x3c, 0x74, 0x9, 0x0, 0x16, 0xa1, 0xf0, 0x2a, - 0xe9, 0x6e, 0x1e, 0xd8, 0x20, 0xd5, 0x70, 0x29, 0x92, 0x42, 0x88, 0x65, 0xc7, 0x9e, 0xdf, 0xa6, 0x58, 0xa9, 0xb7, - 0x1, 0x9, 0x0, 0x1b, 0x85, 0x94, 0x3b, 0xd9, 0x3, 0x1b, 0x78, 0xe3, 0xc1, 0x8, 0xdc, 0xdc, 0x32, 0x5e, 0xce, - 0xf7, 0x2c, 0xd0, 0xb8, 0x45, 0xce, 0x67, 0x82, 0x1e, 0xae, 0xb0, 0xe0, 0x0, 0x10, 0x26, 0x32, 0x86, 0x60, 0x8b, - 0x9c, 0xfe, 0x72, 0xfe, 0x21, 0x52, 0x41, 0x32, 0xce, 0xf3, 0xbc, 0x0, 0x8, 0x50, 0xae, 0x44, 0x94, 0x5e, 0xaf, - 0x4f, 0x1d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x5a, 0xa0, 0xce, 0xe5, 0x58, 0xfb, 0x2d, 0x48, 0x9, - 0x75, 0x27, 0x0, 0xfc, 0x1e, 0xf4, 0x64, 0xee}; - uint8_t bytesprops1[] = {0xa5, 0x1a, 0x55, 0xce, 0x35, 0xfa, 0x3b, 0x48}; - uint8_t bytesprops2[] = {0x79, 0x48, 0x46, 0x33, 0xb6, 0xaa, 0x30, 0xae, 0x25, - 0xee, 0xe, 0x98, 0x1b, 0xbf, 0xb0, 0x37, 0x4f, 0x76}; - uint8_t bytesprops3[] = {0xd6, 0x88, 0x6e, 0x2a, 0xfa, 0xe9, 0x5c, 0x6d, 0xd0, 0x13, - 0x4c, 0x7, 0x87, 0xc0, 0x19, 0xc9, 0x1e, 0x4c, 0xe4}; - uint8_t bytesprops4[] = {0x3, 0x89, 0xf7, 0x46}; - uint8_t bytesprops5[] = {0x11, 0x71, 0xd6, 0x32, 0xce, 0x46, 0x89, 0x23, 0xf0, 0x90, 0x44, 0x3c, 0x34, 0x70, 0x0}; + 0x10, 0x91, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x42, 0x59, 0x4, 0xfa, 0x1, 0x1f, 0x0, 0xb, 0x20, + 0xb1, 0x4b, 0x48, 0x6e, 0x11, 0xd5, 0xa7, 0x50, 0x85, 0xc3, 0x9, 0x0, 0xe, 0x66, 0xdf, 0xae, 0x47, 0x94, 0x61, + 0xd5, 0xb7, 0x52, 0x3f, 0xa3, 0xe4, 0x4d, 0x75, 0x15, 0x0, 0x0, 0x2, 0x0, 0x0, 0x61, 0xef, 0x18, 0x0, 0x0, + 0x3f, 0x41, 0x2, 0x0, 0x0, 0xe, 0x98, 0x15, 0x0, 0x1b, 0x41, 0x20, 0xed, 0x43, 0x61, 0x36, 0x11, 0x83, 0xf7, + 0x1, 0xdc, 0xfc, 0x5f, 0x75, 0xb0, 0x40, 0x4, 0xaa, 0x91, 0x2f, 0xb0, 0xe9, 0xd8, 0xb2, 0x8e, 0x37, 0xe2, 0x28, + 0xd, 0x25, 0x71, 0x28, 0xc8, 0x2, 0x0, 0x0, 0x3b, 0x93, 0x21, 0x73, 0x73, 0x23, 0x6, 0x32, 0x9, 0x0, 0x13, + 0x37, 0x21, 0xd2, 0x1b, 0x47, 0xaa, 0xd2, 0x47, 0x5d, 0x86, 0x81, 0xdd, 0x35, 0x9f, 0xfd, 0x40, 0xd0, 0x92, 0xd, + 0x29, 0xea, 0x17, 0x58, 0x22, 0x6a, 0xa1, 0x1a, 0x0, 0xa, 0x5d, 0xa3, 0x70, 0x40, 0x76, 0x45, 0x55, 0x99, 0x11, + 0x69, 0x26, 0x0, 0xb, 0xe5, 0x8b, 0x21, 0x8f, 0x70, 0x59, 0xa6, 0x61, 0x1f, 0x9a, 0x1a, 0x0, 0xc, 0xa4, 0x2a, + 0x41, 0x19, 0x27, 0xe2, 0x98, 0xa6, 0x3a, 0xd, 0x35, 0x33, 0x1a, 0x0, 0x15, 0x40, 0x7, 0x8a, 0xa4, 0x11, 0x35, + 0x39, 0x30, 0x2c, 0x71, 0xad, 0x5, 0x36, 0x45, 0xc2, 0xed, 0x31, 0xdd, 0x9e, 0x3a, 0x7f, 0x19, 0x8, 0x27, 0x0, + 0x0, 0x4f, 0xac, 0x26, 0x0, 0x15, 0x74, 0x90, 0x9e, 0x5, 0xdc, 0xb0, 0x51, 0x88, 0x8c, 0x23, 0x20, 0xb6, 0x64, + 0xb2, 0xc5, 0xbc, 0xe0, 0x65, 0xab, 0x97, 0x2f, 0x0, 0x6, 0x70, 0x50, 0x21, 0x9, 0xd4, 0x6c, 0x19, 0x47, 0x2, + 0x0, 0x0, 0x60, 0x17, 0x9, 0x0, 0xb, 0xe1, 0x57, 0x37, 0x28, 0x83, 0x1, 0xee, 0xbd, 0x73, 0x87, 0x77, 0x0, + 0x0, 0x0, 0x7, 0x33, 0x6d, 0xa1, 0xd8, 0x31, 0xd7, 0x1d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x20, 0xb1, 0x4b, 0x48, 0x6e, 0x11, 0xd5, 0xa7, 0x50, 0x85, 0xc3}; + uint8_t bytesprops1[] = {0x66, 0xdf, 0xae, 0x47, 0x94, 0x61, 0xd5, 0xb7, 0x52, 0x3f, 0xa3, 0xe4, 0x4d, 0x75}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0x41, 0x20, 0xed, 0x43, 0x61, 0x36, 0x11, 0x83, 0xf7, 0x1, 0xdc, 0xfc, 0x5f, 0x75, + 0xb0, 0x40, 0x4, 0xaa, 0x91, 0x2f, 0xb0, 0xe9, 0xd8, 0xb2, 0x8e, 0x37, 0xe2}; + uint8_t bytesprops4[] = {0x37, 0x21, 0xd2, 0x1b, 0x47, 0xaa, 0xd2, 0x47, 0x5d, 0x86, + 0x81, 0xdd, 0x35, 0x9f, 0xfd, 0x40, 0xd0, 0x92, 0xd}; + uint8_t bytesprops5[] = {0x5d, 0xa3, 0x70, 0x40, 0x76, 0x45, 0x55, 0x99, 0x11, 0x69}; + uint8_t bytesprops7[] = {0xa4, 0x2a, 0x41, 0x19, 0x27, 0xe2, 0x98, 0xa6, 0x3a, 0xd, 0x35, 0x33}; + uint8_t bytesprops6[] = {0xe5, 0x8b, 0x21, 0x8f, 0x70, 0x59, 0xa6, 0x61, 0x1f, 0x9a, 0x1a}; + uint8_t bytesprops8[] = {0x40, 0x7, 0x8a, 0xa4, 0x11, 0x35, 0x39, 0x30, 0x2c, 0x71, 0xad, + 0x5, 0x36, 0x45, 0xc2, 0xed, 0x31, 0xdd, 0x9e, 0x3a, 0x7f}; + uint8_t bytesprops10[] = {0x70, 0x50, 0x21, 0x9, 0xd4, 0x6c}; + uint8_t bytesprops9[] = {0x74, 0x90, 0x9e, 0x5, 0xdc, 0xb0, 0x51, 0x88, 0x8c, 0x23, 0x20, + 0xb6, 0x64, 0xb2, 0xc5, 0xbc, 0xe0, 0x65, 0xab, 0x97, 0x2f}; + uint8_t bytesprops11[] = {0xe1, 0x57, 0x37, 0x28, 0x83, 0x1, 0xee, 0xbd, 0x73, 0x87, 0x77}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 220}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29952}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6277}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25071}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16193}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3736}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 13}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15251}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29555}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1586}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 234}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27297}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops6}, .v = {12, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20396}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops9}, .v = {6, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24599}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x7e, 0x11, 0x3f, 0x83, 0xb1, 0xc2, 0x45, 0xb0, 0xfb, - 0x6d, 0x46, 0xf1, 0xfb, 0xb4, 0x45, 0x1, 0x9f}; - uint8_t byteswillprops1[] = {0xb4, 0x27, 0xa5, 0xf5, 0xd7, 0x9e}; - uint8_t byteswillprops2[] = {0x49, 0x64, 0x1, 0xd5, 0xdb, 0x4c, 0xa8, 0xad, 0x11, 0x79}; - uint8_t byteswillprops3[] = {0x3c, 0xd0, 0xe3, 0xe2, 0x51, 0xb, 0x49, 0x69, 0xa3, 0xe7, - 0xf4, 0xc8, 0x46, 0xa2, 0x31, 0x29, 0xe, 0x19, 0xce}; - uint8_t byteswillprops5[] = {0x63, 0x78, 0x5f, 0xa2, 0xad, 0xab, 0x2b, 0x64, 0x42, 0x17, 0xc6, 0x5a, 0xd8, - 0xe8, 0x6a, 0x70, 0x71, 0x8c, 0xd3, 0x48, 0x58, 0x3a, 0xf8, 0x9e, 0x1f, 0x2c}; - uint8_t byteswillprops4[] = {0x8b, 0x91, 0x62, 0x57, 0x18, 0xcc, 0xf4, 0xd5, 0x42, 0xf5, 0xf5, - 0xe, 0xf2, 0xbd, 0x4b, 0xb0, 0x89, 0xe7, 0x54, 0x2d, 0x5c, 0x13}; - uint8_t byteswillprops6[] = {0xf, 0x8}; - uint8_t byteswillprops7[] = {0xa1, 0xf0, 0x2a, 0xe9, 0x6e, 0x1e, 0xd8, 0x20, 0xd5, 0x70, 0x29, - 0x92, 0x42, 0x88, 0x65, 0xc7, 0x9e, 0xdf, 0xa6, 0x58, 0xa9, 0xb7}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6037}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27175}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 180}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13265}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {22, (char*)&byteswillprops4}, .v = {26, (char*)&byteswillprops5}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30639}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32737}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15476}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 9}}, - }; - - lwmqtt_properties_t willprops = {19, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x85, 0x94, 0x3b, 0xd9, 0x3, 0x1b, 0x78, 0xe3, 0xc1, 0x8, 0xdc, 0xdc, 0x32, 0x5e, - 0xce, 0xf7, 0x2c, 0xd0, 0xb8, 0x45, 0xce, 0x67, 0x82, 0x1e, 0xae, 0xb0, 0xe0}; - lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x26, 0x32, 0x86, 0x60, 0x8b, 0x9c, 0xfe, 0x72, - 0xfe, 0x21, 0x52, 0x41, 0x32, 0xce, 0xf3, 0xbc}; - lwmqtt_string_t will_payload = {16, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS0; - will.retained = true; - will.properties = willprops; - lwmqtt_options_t opts = lwmqtt_default_options; - opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 25004; - uint8_t client_id_bytes[] = {0x2f, 0x7d, 0x62, 0x35, 0xd0, 0x85, 0x1c, 0x85, 0xd6, 0x63, 0x0, 0x97, - 0x90, 0x0, 0xac, 0xe, 0xa8, 0x26, 0x26, 0x96, 0xae, 0xbf, 0x4e, 0xce}; - lwmqtt_string_t client_id = {24, (char*)&client_id_bytes}; - opts.client_id = client_id; - uint8_t username_bytes[] = {0x50, 0xae, 0x44, 0x94, 0x5e, 0xaf, 0x4f, 0x1d}; - lwmqtt_string_t username = {8, (char*)&username_bytes}; - opts.username = username; - size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = true; + opts.keep_alive = 22788; + uint8_t client_id_bytes[] = {0}; + lwmqtt_string_t client_id = {0, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t password_bytes[] = {0x33, 0x6d, 0xa1, 0xd8, 0x31, 0xd7, 0x1d}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "t~B\193\194g\135.\205\195'\202\&4\254\167\130&}\131\SO(", -// _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = -// "\167\209\SI\144\184\148\175\153P3\152[\245s\f\160\STX\173\250\248\&6|\vh\134\236\&6\214\237E", _willMsg = -// "K9\178\239\192\180\&4\159\238\219\254cw\137\\K\177\175\230", _willProps = [PropReasonString -// "\CAN<&\222\203P5N\225\250\235\225\186\240<@\227\&6\169\169",PropReasonString -// "\205\n\152#\251\168\162\NUL\f\133\252\b\FS\151\US\180\136\&5\209k\237\154",PropMessageExpiryInterval -// 177,PropSharedSubscriptionAvailable 106,PropResponseInformation -// "c7`F#l\162\173\133\236\v\198\224\DC4E\n\167\ACK",PropMaximumQoS 250,PropReceiveMaximum 1733,PropRetainAvailable -// 190,PropSharedSubscriptionAvailable 152,PropMaximumPacketSize 18199,PropResponseInformation "\166\171\210\207\135 -// \190\134\188\"\SOW4\136\&2~\163\&0\237\195\191\&9\237\189 2",PropSubscriptionIdentifier 6,PropTopicAlias -// 3403,PropServerReference "",PropTopicAliasMaximum 6329,PropSharedSubscriptionAvailable -// 65,PropSubscriptionIdentifierAvailable 0,PropAuthenticationData "_\STX\222?P\253\STX}\165s\141"]}), _cleanSession = -// False, _keepAlive = 30510, _connID = -// "\254\DC1x\142\180\241\164\178u\EMn\150\196Ks\162\161\152\&1\SYN\233Bh\180\177D",PropRetainAvailable 215,PropMessageExpiryInterval -// 7547,PropMessageExpiryInterval 10918]}), _cleanSession = True, _keepAlive = 19375, _connID = -// "/\\r\181\177\142o\161\139@\150@F", _properties = [PropAuthenticationMethod -// "\vo\194$\179o\253LB\SO\ACK\ETB\227T?zh\218\196\158\&5\SI'`B\137",PropAuthenticationData -// "\170\199",PropMaximumPacketSize 21294,PropAuthenticationData -// "\142j\132^\171\191\174U(\249\193\223\SYN-\237\145\128\146",PropAssignedClientIdentifier -// "\239W\rf\218}5\202g\RS\NUL\128-\198\179\223\227\145 \145\b\184",PropServerKeepAlive 9655,PropTopicAliasMaximum -// 23525,PropAuthenticationData "\166\169\&0\b\DEL\251\243\&3\STX\251\140n\224eMvn\ETB",PropRetainAvailable -// 61,PropMessageExpiryInterval 26294,PropSessionExpiryInterval 20677,PropTopicAliasMaximum -// 24479,PropMessageExpiryInterval 4904,PropUserProperty "\249\&0\217#\141\140\DLE\153f\154\CANnZ\DC1VzoY" -// "\216\191\206\168\a'\147\134",PropMaximumQoS 234,PropServerReference -// "V\RST\239\"J\214\128\146\246=bZ\DC3\182r\DLE",PropSharedSubscriptionAvailable 158,PropContentType -// "\tP\222\197\146\ENQ\211L\227D\232\171_h\NAK\146k[\STX\221\n\146",PropWillDelayInterval -// 27789,PropSubscriptionIdentifier 16]} +// ConnectRequest {_username = Just "\175\229\&0\136\198[\249\141a&\148", _password = Nothing, _lastWill = Just +// (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "3\140\244\142\233\187\202\128\209\rE\DC2\231\&3/\195\rY$\137", _willMsg = "\166\EM\167Q_\140\204", _willProps = +// [PropAuthenticationMethod "",PropSubscriptionIdentifierAvailable 117,PropSessionExpiryInterval +// 20939,PropRequestProblemInformation 78,PropAuthenticationData +// "\\\164AaC#h(\164\130\DC2\160\236\ESC\188qo\186\225+\248xd\134\216J\240\192+",PropRetainAvailable 24,PropMaximumQoS +// 156,PropPayloadFormatIndicator 247]}), _cleanSession = False, _keepAlive = 11555, _connID = "tuXU", _properties = +// [PropTopicAliasMaximum 22032,PropServerReference +// "\182\169h\147\137\206.k\156\197\252\243\DC1\237\173\255\DC2b\t\233@\177Ci\f\242\129\NAKS\249",PropRetainAvailable +// 133,PropWildcardSubscriptionAvailable 20,PropWillDelayInterval 22035,PropResponseInformation +// "\139\136\v",PropResponseTopic "\144\217\253\DC38C\147\&1\174\165U^\196\219\&7\161\217o\173"]} TEST(Connect5QCTest, Encode5) { uint8_t pkt[] = { - 0x10, 0xc9, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0x4b, 0xaf, 0xdb, 0x1, 0x15, 0x0, 0x1a, 0xb, - 0x6f, 0xc2, 0x24, 0xb3, 0x6f, 0xfd, 0x4c, 0x42, 0xe, 0x6, 0x17, 0xe3, 0x54, 0x3f, 0x7a, 0x68, 0xda, 0xc4, 0x9e, - 0x35, 0xf, 0x27, 0x60, 0x42, 0x89, 0x16, 0x0, 0x2, 0xaa, 0xc7, 0x27, 0x0, 0x0, 0x53, 0x2e, 0x16, 0x0, 0x12, - 0x8e, 0x6a, 0x84, 0x5e, 0xab, 0xbf, 0xae, 0x55, 0x28, 0xf9, 0xc1, 0xdf, 0x16, 0x2d, 0xed, 0x91, 0x80, 0x92, 0x12, - 0x0, 0x16, 0xef, 0x57, 0xd, 0x66, 0xda, 0x7d, 0x35, 0xca, 0x67, 0x1e, 0x0, 0x80, 0x2d, 0xc6, 0xb3, 0xdf, 0xe3, - 0x91, 0x20, 0x91, 0x8, 0xb8, 0x13, 0x25, 0xb7, 0x22, 0x5b, 0xe5, 0x16, 0x0, 0x12, 0xa6, 0xa9, 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da, 0xc4, 0x9e, 0x35, 0xf, 0x27, 0x60, 0x42, 0x89}; - uint8_t bytesprops1[] = {0xaa, 0xc7}; - uint8_t bytesprops2[] = {0x8e, 0x6a, 0x84, 0x5e, 0xab, 0xbf, 0xae, 0x55, 0x28, - 0xf9, 0xc1, 0xdf, 0x16, 0x2d, 0xed, 0x91, 0x80, 0x92}; - uint8_t bytesprops3[] = {0xef, 0x57, 0xd, 0x66, 0xda, 0x7d, 0x35, 0xca, 0x67, 0x1e, 0x0, - 0x80, 0x2d, 0xc6, 0xb3, 0xdf, 0xe3, 0x91, 0x20, 0x91, 0x8, 0xb8}; - uint8_t bytesprops4[] = {0xa6, 0xa9, 0x30, 0x8, 0x7f, 0xfb, 0xf3, 0x33, 0x2, - 0xfb, 0x8c, 0x6e, 0xe0, 0x65, 0x4d, 0x76, 0x6e, 0x17}; - uint8_t bytesprops6[] = {0xd8, 0xbf, 0xce, 0xa8, 0x7, 0x27, 0x93, 0x86}; - uint8_t bytesprops5[] = {0xf9, 0x30, 0xd9, 0x23, 0x8d, 0x8c, 0x10, 0x99, 0x66, - 0x9a, 0x18, 0x6e, 0x5a, 0x11, 0x56, 0x7a, 0x6f, 0x59}; - uint8_t bytesprops7[] = {0x56, 0x1e, 0x54, 0xef, 0x22, 0x4a, 0xd6, 0x80, 0x92, - 0xf6, 0x3d, 0x62, 0x5a, 0x13, 0xb6, 0x72, 0x10}; - uint8_t bytesprops8[] = {0x9, 0x50, 0xde, 0xc5, 0x92, 0x5, 0xd3, 0x4c, 0xe3, 0x44, 0xe8, - 0xab, 0x5f, 0x68, 0x15, 0x92, 0x6b, 0x5b, 0x2, 0xdd, 0xa, 0x92}; + 0x10, 0xb9, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x94, 0x2d, 0x23, 0x49, 0x22, 0x56, 0x10, 0x1c, 0x0, + 0x1e, 0xb6, 0xa9, 0x68, 0x93, 0x89, 0xce, 0x2e, 0x6b, 0x9c, 0xc5, 0xfc, 0xf3, 0x11, 0xed, 0xad, 0xff, 0x12, 0x62, + 0x9, 0xe9, 0x40, 0xb1, 0x43, 0x69, 0xc, 0xf2, 0x81, 0x15, 0x53, 0xf9, 0x25, 0x85, 0x28, 0x14, 0x18, 0x0, 0x0, + 0x56, 0x13, 0x1a, 0x0, 0x3, 0x8b, 0x88, 0xb, 0x8, 0x0, 0x13, 0x90, 0xd9, 0xfd, 0x13, 0x38, 0x43, 0x93, 0x31, + 0xae, 0xa5, 0x55, 0x5e, 0xc4, 0xdb, 0x37, 0xa1, 0xd9, 0x6f, 0xad, 0x0, 0x4, 0x74, 0x75, 0x58, 0x55, 0x32, 0x15, + 0x0, 0x0, 0x29, 0x75, 0x11, 0x0, 0x0, 0x51, 0xcb, 0x17, 0x4e, 0x16, 0x0, 0x1d, 0x5c, 0xa4, 0x41, 0x61, 0x43, + 0x23, 0x68, 0x28, 0xa4, 0x82, 0x12, 0xa0, 0xec, 0x1b, 0xbc, 0x71, 0x6f, 0xba, 0xe1, 0x2b, 0xf8, 0x78, 0x64, 0x86, + 0xd8, 0x4a, 0xf0, 0xc0, 0x2b, 0x25, 0x18, 0x24, 0x9c, 0x1, 0xf7, 0x0, 0x14, 0x33, 0x8c, 0xf4, 0x8e, 0xe9, 0xbb, + 0xca, 0x80, 0xd1, 0xd, 0x45, 0x12, 0xe7, 0x33, 0x2f, 0xc3, 0xd, 0x59, 0x24, 0x89, 0x0, 0x7, 0xa6, 0x19, 0xa7, + 0x51, 0x5f, 0x8c, 0xcc, 0x0, 0xb, 0xaf, 0xe5, 0x30, 0x88, 0xc6, 0x5b, 0xf9, 0x8d, 0x61, 0x26, 0x94}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb6, 0xa9, 0x68, 0x93, 0x89, 0xce, 0x2e, 0x6b, 0x9c, 0xc5, 0xfc, 0xf3, 0x11, 0xed, 0xad, + 0xff, 0x12, 0x62, 0x9, 0xe9, 0x40, 0xb1, 0x43, 0x69, 0xc, 0xf2, 0x81, 0x15, 0x53, 0xf9}; + uint8_t bytesprops1[] = {0x8b, 0x88, 0xb}; + uint8_t bytesprops2[] = {0x90, 0xd9, 0xfd, 0x13, 0x38, 0x43, 0x93, 0x31, 0xae, 0xa5, + 0x55, 0x5e, 0xc4, 0xdb, 0x37, 0xa1, 0xd9, 0x6f, 0xad}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21294}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9655}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 23525}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26294}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20677}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24479}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4904}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops5}, .v = {8, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27789}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22032}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22035}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x53, 0x4a, 0x95, 0xe3, 0x6a, 0xa1, 0xd7, 0xe6, 0xd1, 0xbe, 0x81, 0xf5, 0xed, - 0x53, 0x3c, 0x97, 0xef, 0x2a, 0x3c, 0xc0, 0xe1, 0x48, 0x66, 0xa7, 0xcd}; - uint8_t byteswillprops2[] = {0xa7, 0x88, 0x66, 0x6c}; - uint8_t byteswillprops1[] = {0xc6, 0x38, 0xf3, 0x91, 0xe, 0x8c, 0x1e, 0x7d, 0x6d, 0xaf}; - uint8_t byteswillprops3[] = {0x71, 0x78, 0x26}; - uint8_t byteswillprops4[] = {0xc6, 0xef, 0x74, 0xd0, 0xf7, 0xca, 0x67, 0x24, 0xbc, 0x4, - 0x6a, 0x7, 0xd7, 0xb6, 0x9f, 0x73, 0xe3, 0xe9, 0x2b, 0x43, - 0xa2, 0x11, 0x3c, 0xe1, 0x4c, 0xe, 0xfd, 0xec, 0x0, 0xd3}; - uint8_t byteswillprops5[] = {0x72, 0xe3, 0x8a, 0x75, 0x25, 0x77, 0xd1, 0xab, 0x3e, 0xa2, - 0xa1, 0x98, 0x31, 0x16, 0xe9, 0x42, 0x68, 0xb4, 0xb1, 0x44}; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops1[] = {0x5c, 0xa4, 0x41, 0x61, 0x43, 0x23, 0x68, 0x28, 0xa4, 0x82, 0x12, 0xa0, 0xec, 0x1b, 0xbc, + 0x71, 0x6f, 0xba, 0xe1, 0x2b, 0xf8, 0x78, 0x64, 0x86, 0xd8, 0x4a, 0xf0, 0xc0, 0x2b}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 105}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15607}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6513}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16736}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24529}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30836}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26676}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2378}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {10, (char*)&byteswillprops1}, .v = {4, (char*)&byteswillprops2}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24188}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29686}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {30, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7547}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10918}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20939}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 24}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 247}}, }; - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x2}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x39, 0xc, 0x98, 0x26, 0xcb, 0xc4, 0x99, 0x9c, 0x5e, - 0xfa, 0x87, 0x87, 0xcb, 0xdd, 0x8b, 0xdc, 0x53}; - lwmqtt_string_t will_payload = {17, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x33, 0x8c, 0xf4, 0x8e, 0xe9, 0xbb, 0xca, 0x80, 0xd1, 0xd, + 0x45, 0x12, 0xe7, 0x33, 0x2f, 0xc3, 0xd, 0x59, 0x24, 0x89}; + lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa6, 0x19, 0xa7, 0x51, 0x5f, 0x8c, 0xcc}; + lwmqtt_string_t will_payload = {7, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 19375; - uint8_t client_id_bytes[] = {0x2f, 0x5c, 0x72, 0xb5, 0xb1, 0x8e, 0x6f, 0xa1, 0x8b, 0x40, 0x96, 0x40, 0x46}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 11555; + uint8_t client_id_bytes[] = {0x74, 0x75, 0x58, 0x55}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2b, 0x61, 0x86, 0x47, 0xad, 0x26, 0x4f, 0xf4, 0xec, - 0x7f, 0x9d, 0xdc, 0xd0, 0x63, 0x4b, 0x25, 0xf4}; - lwmqtt_string_t username = {17, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xaf, 0xe5, 0x30, 0x88, 0xc6, 0x5b, 0xf9, 0x8d, 0x61, 0x26, 0x94}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -10772,167 +10160,171 @@ TEST(Connect5QCTest, Encode5) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\190\145\130w(G[n\144\185\"\138A\235\255GZ\SI\251\136*\210 -// \238$*\DC3\136\223\238", _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "\154\153\177L7?\EM \243\242#e\CAN,\194\180\CANV\230y\\\RS", _willMsg = "\147\239z\187\224\229", _willProps = -// [PropAuthenticationData "\241\210\DC1Z1~\SI\144\145\147\128wM\240j$JO",PropCorrelationData -// "\243~\240\171\SUBIE\146||\180bl*\177Tl\DC2<\166\214m\200n^Z\235%",PropResponseTopic -// "\186\147%X\DLE?\144\190\FS\231\181\235",PropRetainAvailable 229,PropUserProperty "\ENQ\138\178\161+" -// "\ESC\DC3\173\228-\131\243\244\160\168c\185\139t\177\175\235\140B\147\ENQ\DC1",PropSharedSubscriptionAvailable -// 184,PropSubscriptionIdentifierAvailable 161,PropReasonString -// "\134b\131\172\139\167+\193O+\247kz:\NAK\199\&6\175f",PropServerReference -// "\172\ENQ\FS\236\213\210\215\188;%\SO\149",PropResponseTopic "\NUL[T\ETX\140\NAK\206\138",PropMaximumPacketSize -// 6713,PropSessionExpiryInterval 3395,PropMessageExpiryInterval 10996,PropServerKeepAlive 1444,PropReasonString -// "D\158\254YfR\212h\206w\ETXR=\185\142\SOL@\177\221\159\154\166\221\SYN\231%",PropMessageExpiryInterval -// 21083,PropServerReference "\206\r\ACK\SYN\175\238o\SOEO\160.%n\173\SYND\157\226g\209\225Q",PropMessageExpiryInterval -// 6337,PropTopicAliasMaximum 716,PropMessageExpiryInterval 25841,PropSubscriptionIdentifierAvailable -// 229,PropReasonString "\225P\193\&9",PropWildcardSubscriptionAvailable 159,PropMaximumQoS 51,PropTopicAliasMaximum -// 6727,PropReceiveMaximum 11377]}), _cleanSession = True, _keepAlive = 14576, _connID = "m\168E>\DC1\GSp", _properties -// = [PropAuthenticationMethod -// "A%\137\149\&1\210_|\201\174\181\172;\209g&\207\&6\241\134aC\NUL\197\SUBH\191",PropAuthenticationData -// "\185\230\ENQ\152\203\183\SYNc\192\GS{;\b\217\142\255",PropRequestProblemInformation 150,PropResponseTopic -// "\236\250\153\194yY]\167\194\249\157o\241\144*\185[\219\244",PropSharedSubscriptionAvailable -// 15,PropSubscriptionIdentifierAvailable 77,PropRetainAvailable 151,PropSessionExpiryInterval 17635,PropContentType -// "\170wU\187\DC2)/O0\183;\220\140J\193\190r\136",PropServerKeepAlive 30845,PropWillDelayInterval -// 20450,PropAuthenticationMethod -// "\159\227Q\">\223\251'\242e\146v\138\237\&8\140\170\t\ENQP\151\tcc\241\EOT&\224\198\140",PropContentType -// "\139\244",PropRequestProblemInformation 170,PropSharedSubscriptionAvailable 140,PropSubscriptionIdentifierAvailable -// 23,PropTopicAlias 20455,PropPayloadFormatIndicator 187]} +// ConnectRequest {_username = Just "e\138\184\246\212D\182\ETX\161", _password = Just "2\150\175\130\&9\161", _lastWill +// = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = " +// \DC3I\133\229M\236\164\&9\CANY\250\SOH\DC2w\166\185\150\&6Osm\b-RT\156", _willMsg = "\n", _willProps = +// [PropWillDelayInterval 2455,PropContentType +// "I\DEL\159*\231\222TXN\211\175\148HS\SYN\174.\ne,\ACK\182\164",PropMaximumPacketSize +// 3574,PropSharedSubscriptionAvailable 180,PropWillDelayInterval 12319,PropReceiveMaximum 8873,PropUserProperty +// "\247-\182J\ESCJ\176\140" "A\173@4C\r",PropSessionExpiryInterval 12636,PropWildcardSubscriptionAvailable +// 10,PropPayloadFormatIndicator 216,PropPayloadFormatIndicator 66,PropTopicAliasMaximum +// 27102,PropRequestProblemInformation 49,PropResponseInformation "1",PropRequestProblemInformation +// 169,PropMaximumPacketSize 14994,PropSubscriptionIdentifier 12,PropContentType "\160",PropAuthenticationMethod +// "",PropWillDelayInterval 20668,PropTopicAliasMaximum 5655,PropRequestResponseInformation +// 93,PropWildcardSubscriptionAvailable 235,PropCorrelationData +// "\176\146\170L\130J\EMyh*\208\143\a\142@\251\149\142Ce",PropMessageExpiryInterval 8162]}), _cleanSession = False, +// _keepAlive = 7490, _connID = "#\162\232\227\138", _properties = [PropUserProperty "\245\238\163D\222" +// "\150\224\166I\136,\a\248d\221|XAa\217;)r\164P\246\DEL\165v\148A\128",PropContentType +// "\148E\222\165I0\NUL\DLE\206\185W\n",PropWillDelayInterval 29156,PropPayloadFormatIndicator 14,PropAuthenticationData +// "w\146\174\214\175\228\181\167\162I=\146!", _willMsg = "2\138c9\234`\186@\186E\164\&9+", -// _willProps = [PropMaximumPacketSize 25044,PropMaximumQoS 93,PropSubscriptionIdentifierAvailable 130,PropUserProperty -// "\230\188\156\182\145\220mb\fpl\178<\194\&1Hm\132\181?\166|\ACKg\137\&8x\EOT" "\155\&96k",PropResponseTopic -// "\158\239\253j\168\ENQV>\133<\189",PropWildcardSubscriptionAvailable 150,PropSubscriptionIdentifier -// 14,PropCorrelationData "\240\129\155u\164\216\161\178/C",PropSharedSubscriptionAvailable 161,PropServerReference -// "\134*:\200,\219s\EM\253F\255\209.\229\227",PropRequestResponseInformation 96,PropPayloadFormatIndicator -// 45,PropRequestProblemInformation 133,PropRetainAvailable 164,PropServerReference -// "V?rv\237\150\169F\191|\a\162\ENQ\211\193\&4\239\&1\231>",PropRequestResponseInformation -// 227,PropSubscriptionIdentifier 18]}), _cleanSession = False, _keepAlive = 19395, _connID = -// "\149n\238G\238\237)\201\164\252\154Z`O\144Gm\245xzg\DC3P", _properties = [PropSubscriptionIdentifierAvailable -// 150,PropAuthenticationMethod -// "|\ESC\221\172\ESC\171\190\216\190d\154\148i\216\&1\225\&9\211r\185;\FS\fy",PropWildcardSubscriptionAvailable -// 151,PropPayloadFormatIndicator 78,PropAuthenticationMethod "",PropTopicAlias 3919,PropUserProperty -// "\ETB\211\SUBY\224\&1\146\189/\159\ESC" "\245m\175\226\nn\225\164\172(u\r3\152\223\b\227\174Q",PropMaximumQoS -// 237,PropTopicAlias 1648,PropReceiveMaximum 8601,PropAuthenticationData "D\138}\191\133{",PropSessionExpiryInterval -// 12319,PropWildcardSubscriptionAvailable 99,PropReasonString -// "h\231\NULS\DEL6F1?\156`No\ACK$~\191\v\180-KQ\128\228.\171*",PropMaximumPacketSize 16400,PropMessageExpiryInterval -// 3583,PropResponseTopic -// "\205_\ENQ]\130\234_\128\RS\176\235\216\247M\211\234u\aC\161\163\190k\184h",PropServerReference -// "a\167Y4\r\211\196}\236\DELO\156",PropWildcardSubscriptionAvailable 14]} +// ConnectRequest {_username = Nothing, _password = Just "\175", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS0, _willTopic = +// "\CAN#\232\218\132C\SOH\233l\168\204\182\128\&1\147\ETX\185\184Y\254<\192\170M\137\143\185", _willMsg = +// "L\\3\170\149\249|cG", _willProps = [PropUserProperty +// "\b\EOTWUZ\251\192\143\CAN\235:\131S\157x\DC4\253\DELO\f,\SOH\228\151s\232\&13\190" +// "_\223\159\169\210P\DC37\142N(h\\I?\238\GS\199\189",PropResponseInformation +// "\SOf\196\173\165\248\142Hk\252-\168\186\220)\146Mj[D\188l",PropMaximumPacketSize 1862,PropMaximumPacketSize +// 30222,PropServerKeepAlive 17400,PropUserProperty "\134_\206U\USx\201\188/*{t\170\US7\ACK-\ESCR\212\&4\233>W" +// ".\159\135&\149.\187\148\163\DEL\239\254+\154W\225}#",PropRequestProblemInformation 32,PropTopicAliasMaximum +// 22091,PropMessageExpiryInterval 7460,PropAuthenticationData "\221J\212\&6\208\153",PropPayloadFormatIndicator +// 192,PropRequestResponseInformation 137,PropServerKeepAlive 5239,PropReasonString +// "\EOT\227\138\183\GS\245\v\188\162\243\249",PropSessionExpiryInterval 27741,PropMessageExpiryInterval +// 2221,PropSharedSubscriptionAvailable 223,PropTopicAliasMaximum 5638,PropMessageExpiryInterval +// 30883,PropPayloadFormatIndicator 140,PropCorrelationData "\241\US\202\238\&8{\169\ESC\DC4\181"]}), _cleanSession = +// False, _keepAlive = 10327, _connID = "\197F\a\173", _properties = [PropTopicAlias 29372,PropMaximumPacketSize +// 21608,PropReasonString "\n\\:|\189\220,\129/T\130%\243\171\237\186*\DC2.gjk\v\157\253/",PropServerKeepAlive +// 7092,PropResponseTopic "\DC4\165\249\175\153VA\157\r\SO\130G",PropReceiveMaximum +// 18469,PropSubscriptionIdentifierAvailable 50,PropReceiveMaximum 7905,PropRetainAvailable 127,PropTopicAliasMaximum +// 20888,PropAuthenticationData +// "e\201\169\133\DC3\185\166\211\157\223(5\235\160\217\236",PropSubscriptionIdentifierAvailable +// 102,PropRequestProblemInformation 178,PropMessageExpiryInterval 26119,PropTopicAliasMaximum +// 32114,PropRequestProblemInformation 60,PropTopicAliasMaximum 19694,PropAuthenticationMethod +// "x\181F\191\n\ACK\184^\254{{w\191\184\&4d\134\ACKb!\163",PropRetainAvailable 90,PropMaximumQoS +// 161,PropTopicAliasMaximum 17520,PropReceiveMaximum 3344,PropAssignedClientIdentifier "\DC2",PropUserProperty +// "GI\151\166\EOT\211)}\SI\179\228\148N\138" "\233O\189\172[X0\156\208",PropRequestResponseInformation 185]} TEST(Connect5QCTest, Encode9) { uint8_t pkt[] = { - 0x10, 0x9e, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x4b, 0xc3, 0xb7, 0x1, 0x29, 0x96, 0x15, 0x0, - 0x18, 0x7c, 0x1b, 0xdd, 0xac, 0x1b, 0xab, 0xbe, 0xd8, 0xbe, 0x64, 0x9a, 0x94, 0x69, 0xd8, 0x31, 0xe1, 0x39, 0xd3, - 0x72, 0xb9, 0x3b, 0x1c, 0xc, 0x79, 0x28, 0x97, 0x1, 0x4e, 0x15, 0x0, 0x0, 0x23, 0xf, 0x4f, 0x26, 0x0, 0xb, - 0x17, 0xd3, 0x1a, 0x59, 0xe0, 0x31, 0x92, 0xbd, 0x2f, 0x9f, 0x1b, 0x0, 0x13, 0xf5, 0x6d, 0xaf, 0xe2, 0xa, 0x6e, - 0xe1, 0xa4, 0xac, 0x28, 0x75, 0xd, 0x33, 0x98, 0xdf, 0x8, 0xe3, 0xae, 0x51, 0x24, 0xed, 0x23, 0x6, 0x70, 0x21, - 0x21, 0x99, 0x16, 0x0, 0x6, 0x44, 0x8a, 0x7d, 0xbf, 0x85, 0x7b, 0x11, 0x0, 0x0, 0x30, 0x1f, 0x28, 0x63, 0x1f, - 0x0, 0x1b, 0x68, 0xe7, 0x0, 0x53, 0x7f, 0x36, 0x46, 0x31, 0x3f, 0x9c, 0x60, 0x4e, 0x6f, 0x6, 0x24, 0x7e, 0xbf, - 0xb, 0xb4, 0x2d, 0x4b, 0x51, 0x80, 0xe4, 0x2e, 0xab, 0x2a, 0x27, 0x0, 0x0, 0x40, 0x10, 0x2, 0x0, 0x0, 0xd, - 0xff, 0x8, 0x0, 0x19, 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, - 0x7c, 0x7, 0xa2, 0x5, 0xd3, 0xc1, 0x34, 0xef, 0x31, 0xe7, 0x3e, 0x19, 0xe3, 0xb, 0x12, 0x0, 0x14, 0xb6, 0xd2, - 0xd2, 0xd0, 0xa1, 0x2a, 0xa, 0x67, 0x3e, 0xae, 0xd6, 0xaf, 0xe4, 0xb5, 0xa7, 0xa2, 0x49, 0x3d, 0x92, 0x21, 0x0, - 0xd, 0x32, 0x8a, 0x63, 0x39, 0xea, 0x60, 0xba, 0x40, 0xba, 0x45, 0xa4, 0x39, 0x2b, 0x0, 0x6, 0x3f, 0xd4, 0x9a, - 0xea, 0x81, 0x81, 0x0, 0xd, 0x70, 0x7e, 0x29, 0x7f, 0x56, 0x76, 0xe8, 0x4, 0x2c, 0x1a, 0x8e, 0x61, 0xdf}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7c, 0x1b, 0xdd, 0xac, 0x1b, 0xab, 0xbe, 0xd8, 0xbe, 0x64, 0x9a, 0x94, - 0x69, 0xd8, 0x31, 0xe1, 0x39, 0xd3, 0x72, 0xb9, 0x3b, 0x1c, 0xc, 0x79}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops3[] = {0xf5, 0x6d, 0xaf, 0xe2, 0xa, 0x6e, 0xe1, 0xa4, 0xac, 0x28, - 0x75, 0xd, 0x33, 0x98, 0xdf, 0x8, 0xe3, 0xae, 0x51}; - uint8_t bytesprops2[] = {0x17, 0xd3, 0x1a, 0x59, 0xe0, 0x31, 0x92, 0xbd, 0x2f, 0x9f, 0x1b}; - uint8_t bytesprops4[] = {0x44, 0x8a, 0x7d, 0xbf, 0x85, 0x7b}; - uint8_t bytesprops5[] = {0x68, 0xe7, 0x0, 0x53, 0x7f, 0x36, 0x46, 0x31, 0x3f, 0x9c, 0x60, 0x4e, 0x6f, 0x6, - 0x24, 0x7e, 0xbf, 0xb, 0xb4, 0x2d, 0x4b, 0x51, 0x80, 0xe4, 0x2e, 0xab, 0x2a}; - uint8_t bytesprops6[] = {0xcd, 0x5f, 0x5, 0x5d, 0x82, 0xea, 0x5f, 0x80, 0x1e, 0xb0, 0xeb, 0xd8, 0xf7, - 0x4d, 0xd3, 0xea, 0x75, 0x7, 0x43, 0xa1, 0xa3, 0xbe, 0x6b, 0xb8, 0x68}; - uint8_t bytesprops7[] = {0x61, 0xa7, 0x59, 0x34, 0xd, 0xd3, 0xc4, 0x7d, 0xec, 0x7f, 0x4f, 0x9c}; + 0x10, 0xc0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x64, 0x28, 0x57, 0xac, 0x1, 0x23, 0x72, 0xbc, 0x27, + 0x0, 0x0, 0x54, 0x68, 0x1f, 0x0, 0x1a, 0xa, 0x5c, 0x3a, 0x7c, 0xbd, 0xdc, 0x2c, 0x81, 0x2f, 0x54, 0x82, 0x25, + 0xf3, 0xab, 0xed, 0xba, 0x2a, 0x12, 0x2e, 0x67, 0x6a, 0x6b, 0xb, 0x9d, 0xfd, 0x2f, 0x13, 0x1b, 0xb4, 0x8, 0x0, + 0xc, 0x14, 0xa5, 0xf9, 0xaf, 0x99, 0x56, 0x41, 0x9d, 0xd, 0xe, 0x82, 0x47, 0x21, 0x48, 0x25, 0x29, 0x32, 0x21, + 0x1e, 0xe1, 0x25, 0x7f, 0x22, 0x51, 0x98, 0x16, 0x0, 0x10, 0x65, 0xc9, 0xa9, 0x85, 0x13, 0xb9, 0xa6, 0xd3, 0x9d, + 0xdf, 0x28, 0x35, 0xeb, 0xa0, 0xd9, 0xec, 0x29, 0x66, 0x17, 0xb2, 0x2, 0x0, 0x0, 0x66, 0x7, 0x22, 0x7d, 0x72, + 0x17, 0x3c, 0x22, 0x4c, 0xee, 0x15, 0x0, 0x15, 0x78, 0xb5, 0x46, 0xbf, 0xa, 0x6, 0xb8, 0x5e, 0xfe, 0x7b, 0x7b, + 0x77, 0xbf, 0xb8, 0x34, 0x64, 0x86, 0x6, 0x62, 0x21, 0xa3, 0x25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, 0xe1, 0x7d, 0x23, 0x17, 0x20, 0x22, 0x56, 0x4b, 0x2, 0x0, 0x0, 0x1d, + 0x24, 0x16, 0x0, 0x6, 0xdd, 0x4a, 0xd4, 0x36, 0xd0, 0x99, 0x1, 0xc0, 0x19, 0x89, 0x13, 0x14, 0x77, 0x1f, 0x0, + 0xb, 0x4, 0xe3, 0x8a, 0xb7, 0x1d, 0xf5, 0xb, 0xbc, 0xa2, 0xf3, 0xf9, 0x11, 0x0, 0x0, 0x6c, 0x5d, 0x2, 0x0, + 0x0, 0x8, 0xad, 0x2a, 0xdf, 0x22, 0x16, 0x6, 0x2, 0x0, 0x0, 0x78, 0xa3, 0x1, 0x8c, 0x9, 0x0, 0xa, 0xf1, + 0x1f, 0xca, 0xee, 0x38, 0x7b, 0xa9, 0x1b, 0x14, 0xb5, 0x0, 0x1b, 0x18, 0x23, 0xe8, 0xda, 0x84, 0x43, 0x1, 0xe9, + 0x6c, 0xa8, 0xcc, 0xb6, 0x80, 0x31, 0x93, 0x3, 0xb9, 0xb8, 0x59, 0xfe, 0x3c, 0xc0, 0xaa, 0x4d, 0x89, 0x8f, 0xb9, + 0x0, 0x9, 0x4c, 0x5c, 0x33, 0xaa, 0x95, 0xf9, 0x7c, 0x63, 0x47, 0x0, 0x1, 0xaf}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa, 0x5c, 0x3a, 0x7c, 0xbd, 0xdc, 0x2c, 0x81, 0x2f, 0x54, 0x82, 0x25, 0xf3, + 0xab, 0xed, 0xba, 0x2a, 0x12, 0x2e, 0x67, 0x6a, 0x6b, 0xb, 0x9d, 0xfd, 0x2f}; + uint8_t bytesprops1[] = {0x14, 0xa5, 0xf9, 0xaf, 0x99, 0x56, 0x41, 0x9d, 0xd, 0xe, 0x82, 0x47}; + uint8_t bytesprops2[] = {0x65, 0xc9, 0xa9, 0x85, 0x13, 0xb9, 0xa6, 0xd3, + 0x9d, 0xdf, 0x28, 0x35, 0xeb, 0xa0, 0xd9, 0xec}; + uint8_t bytesprops3[] = {0x78, 0xb5, 0x46, 0xbf, 0xa, 0x6, 0xb8, 0x5e, 0xfe, 0x7b, 0x7b, + 0x77, 0xbf, 0xb8, 0x34, 0x64, 0x86, 0x6, 0x62, 0x21, 0xa3}; + uint8_t bytesprops4[] = {0x12}; + uint8_t bytesprops6[] = {0xe9, 0x4f, 0xbd, 0xac, 0x5b, 0x58, 0x30, 0x9c, 0xd0}; + uint8_t bytesprops5[] = {0x47, 0x49, 0x97, 0xa6, 0x4, 0xd3, 0x29, 0x7d, 0xf, 0xb3, 0xe4, 0x94, 0x4e, 0x8a}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3919}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops2}, .v = {19, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1648}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8601}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12319}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 99}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 16400}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3583}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29372}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21608}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7092}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18469}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 50}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7905}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20888}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26119}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32114}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19694}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17520}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3344}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops5}, .v = {9, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 185}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x9b, 0x39, 0x36, 0x6b}; - uint8_t byteswillprops0[] = {0xe6, 0xbc, 0x9c, 0xb6, 0x91, 0xdc, 0x6d, 0x62, 0xc, 0x70, 0x6c, 0xb2, 0x3c, 0xc2, - 0x31, 0x48, 0x6d, 0x84, 0xb5, 0x3f, 0xa6, 0x7c, 0x6, 0x67, 0x89, 0x38, 0x78, 0x4}; - uint8_t byteswillprops2[] = {0x9e, 0xef, 0xfd, 0x6a, 0xa8, 0x5, 0x56, 0x3e, 0x85, 0x3c, 0xbd}; - uint8_t byteswillprops3[] = {0xf0, 0x81, 0x9b, 0x75, 0xa4, 0xd8, 0xa1, 0xb2, 0x2f, 0x43}; - uint8_t byteswillprops4[] = {0x86, 0x2a, 0x3a, 0xc8, 0x2c, 0xdb, 0x73, 0x19, - 0xfd, 0x46, 0xff, 0xd1, 0x2e, 0xe5, 0xe3}; - uint8_t byteswillprops5[] = {0x56, 0x3f, 0x72, 0x76, 0xed, 0x96, 0xa9, 0x46, 0xbf, 0x7c, - 0x7, 0xa2, 0x5, 0xd3, 0xc1, 0x34, 0xef, 0x31, 0xe7, 0x3e}; + uint8_t byteswillprops1[] = {0x5f, 0xdf, 0x9f, 0xa9, 0xd2, 0x50, 0x13, 0x37, 0x8e, 0x4e, + 0x28, 0x68, 0x5c, 0x49, 0x3f, 0xee, 0x1d, 0xc7, 0xbd}; + uint8_t byteswillprops0[] = {0x8, 0x4, 0x57, 0x55, 0x5a, 0xfb, 0xc0, 0x8f, 0x18, 0xeb, 0x3a, 0x83, 0x53, 0x9d, 0x78, + 0x14, 0xfd, 0x7f, 0x4f, 0xc, 0x2c, 0x1, 0xe4, 0x97, 0x73, 0xe8, 0x31, 0x33, 0xbe}; + uint8_t byteswillprops2[] = {0xe, 0x66, 0xc4, 0xad, 0xa5, 0xf8, 0x8e, 0x48, 0x6b, 0xfc, 0x2d, + 0xa8, 0xba, 0xdc, 0x29, 0x92, 0x4d, 0x6a, 0x5b, 0x44, 0xbc, 0x6c}; + uint8_t byteswillprops4[] = {0x2e, 0x9f, 0x87, 0x26, 0x95, 0x2e, 0xbb, 0x94, 0xa3, + 0x7f, 0xef, 0xfe, 0x2b, 0x9a, 0x57, 0xe1, 0x7d, 0x23}; + uint8_t byteswillprops3[] = {0x86, 0x5f, 0xce, 0x55, 0x1f, 0x78, 0xc9, 0xbc, 0x2f, 0x2a, 0x7b, 0x74, + 0xaa, 0x1f, 0x37, 0x6, 0x2d, 0x1b, 0x52, 0xd4, 0x34, 0xe9, 0x3e, 0x57}; + uint8_t byteswillprops5[] = {0xdd, 0x4a, 0xd4, 0x36, 0xd0, 0x99}; + uint8_t byteswillprops6[] = {0x4, 0xe3, 0x8a, 0xb7, 0x1d, 0xf5, 0xb, 0xbc, 0xa2, 0xf3, 0xf9}; + uint8_t byteswillprops7[] = {0xf1, 0x1f, 0xca, 0xee, 0x38, 0x7b, 0xa9, 0x1b, 0x14, 0xb5}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25044}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 130}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {28, (char*)&byteswillprops0}, .v = {4, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 133}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + .value = {.pair = {.k = {29, (char*)&byteswillprops0}, .v = {19, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {22, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1862}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30222}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17400}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {24, (char*)&byteswillprops3}, .v = {18, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22091}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7460}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 192}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5239}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 27741}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2221}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5638}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30883}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&byteswillprops7}}}, }; - lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb6, 0xd2, 0xd2, 0xd0, 0xa1, 0x2a, 0xa, 0x67, 0x3e, 0xae, - 0xd6, 0xaf, 0xe4, 0xb5, 0xa7, 0xa2, 0x49, 0x3d, 0x92, 0x21}; - lwmqtt_string_t will_topic = {20, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x32, 0x8a, 0x63, 0x39, 0xea, 0x60, 0xba, 0x40, 0xba, 0x45, 0xa4, 0x39, 0x2b}; - lwmqtt_string_t will_payload = {13, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x18, 0x23, 0xe8, 0xda, 0x84, 0x43, 0x1, 0xe9, 0x6c, 0xa8, 0xcc, 0xb6, 0x80, 0x31, + 0x93, 0x3, 0xb9, 0xb8, 0x59, 0xfe, 0x3c, 0xc0, 0xaa, 0x4d, 0x89, 0x8f, 0xb9}; + lwmqtt_string_t will_topic = {27, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x4c, 0x5c, 0x33, 0xaa, 0x95, 0xf9, 0x7c, 0x63, 0x47}; + lwmqtt_string_t will_payload = {9, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 19395; - uint8_t client_id_bytes[] = {0x95, 0x6e, 0xee, 0x47, 0xee, 0xed, 0x29, 0xc9, 0xa4, 0xfc, 0x9a, 0x5a, - 0x60, 0x4f, 0x90, 0x47, 0x6d, 0xf5, 0x78, 0x7a, 0x67, 0x13, 0x50}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 10327; + uint8_t client_id_bytes[] = {0xc5, 0x46, 0x7, 0xad}; + lwmqtt_string_t client_id = {4, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x3f, 0xd4, 0x9a, 0xea, 0x81, 0x81}; - lwmqtt_string_t username = {6, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0x70, 0x7e, 0x29, 0x7f, 0x56, 0x76, 0xe8, 0x4, 0x2c, 0x1a, 0x8e, 0x61, 0xdf}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xaf}; + lwmqtt_string_t password = {1, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -11283,195 +10647,199 @@ TEST(Connect5QCTest, Encode9) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\150\213\175\169yq`\DC3\185\158\240\US\228H\158\158\192\153", _password = Just -// "\206c\DC1\187", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = -// "'gY\b\203\149\DC3\206\CAN<\CAN\177\205$a\160\135", _willMsg = -// "\162<\STX\222\185\208\196\140\169\175\155\150\NAK\216\r\145\194\173\159\210/\222\f\180\NAK=", _willProps = -// [PropReceiveMaximum 726,PropMessageExpiryInterval 30408,PropSharedSubscriptionAvailable 87,PropResponseTopic -// "\165\"x\149\130\196\231N\234\222\180]'\RS\241\"K\189\239\213",PropResponseInformation -// "G{($\238\&3\184\135w\r\245\215\237\131\157\ENQ'\140\SYN",PropResponseTopic -// "\160\163\192Sx\193\234\220\164\FS\161\163.\192U\182#=RA",PropSubscriptionIdentifier 7,PropRequestProblemInformation -// 165,PropReceiveMaximum 10578,PropSubscriptionIdentifier 2,PropTopicAliasMaximum 7623,PropSharedSubscriptionAvailable -// 28,PropRequestProblemInformation 169,PropWillDelayInterval 32532,PropAuthenticationData -// "\218\a\152\197)" -// "\202^\229G\149\166\NUL=\186\179\201\216,\185\231\154;\FS\228\241\&8\215M\133",PropAssignedClientIdentifier -// "\153\238_dL}\251\226r\191\145\240>",PropReceiveMaximum 11564,PropResponseInformation -// "\138{\ESC\137A|\240_,H1\202F\243",PropSharedSubscriptionAvailable 196,PropResponseTopic -// "-6p\190\&3\160`\186\247jK,R{-\203\146",PropAuthenticationMethod -// "\251\168\249n\"\STXu\NAK\167!\184h-\255F\170s",PropRequestProblemInformation 50,PropWillDelayInterval -// 8644,PropContentType "9\147]\133s\f2)\EM\168\&5\166\DELNl\242\t\145\&6+\182\223",PropServerKeepAlive -// 28557,PropTopicAlias 12014,PropRetainAvailable 73,PropResponseInformation "6\a\CAN0\EOT.\170\DC1P"]} +// ConnectRequest {_username = Just "\161M\139\STX'\150/\148\f\226\225\132", _password = Just "F\225WbF\224\168", +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 18820, _connID = +// "\239\187K\240\&8zO\aU|\SI\206\249i\178\203\168", _properties = [PropWildcardSubscriptionAvailable +// 123,PropTopicAliasMaximum 30304,PropMaximumPacketSize 20871,PropSharedSubscriptionAvailable 108,PropWillDelayInterval +// 29760,PropSubscriptionIdentifierAvailable 98,PropContentType +// "\249\212\147\143\213\157\b}\215\244\EM",PropAssignedClientIdentifier +// "\RS\r10\246+d\NAK\159\141\152\185\244\224F",PropReasonString +// "\230\204-\198d\232\195\135\233\SUB\221n>\141\180\FS\193",PropUserProperty +// "<\183\191\232\DC1\196\162\GS\154\DC1\255\157\RS\183\169" "B\217\247y\f\252N;T\199V",PropSessionExpiryInterval +// 18786,PropAuthenticationData "\238\SI\130_f;\176\140F\213u",PropCorrelationData +// "\236u\195\255\165h\196%=\254\202>\183<9\NUL\174`\236\206\211",PropSharedSubscriptionAvailable +// 9,PropMessageExpiryInterval 6370,PropServerReference "\RS\150"]} TEST(Connect5QCTest, Encode10) { + uint8_t pkt[] = {0x10, 0xd3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x49, 0x84, 0x9d, 0x1, 0x28, 0x7b, + 0x22, 0x76, 0x60, 0x27, 0x0, 0x0, 0x51, 0x87, 0x2a, 0x6c, 0x18, 0x0, 0x0, 0x74, 0x40, 0x29, 0x62, + 0x3, 0x0, 0xb, 0xf9, 0xd4, 0x93, 0x8f, 0xd5, 0x9d, 0x8, 0x7d, 0xd7, 0xf4, 0x19, 0x12, 0x0, 0xf, + 0x1e, 0xd, 0x31, 0x30, 0xf6, 0x2b, 0x64, 0x15, 0x9f, 0x8d, 0x98, 0xb9, 0xf4, 0xe0, 0x46, 0x1f, 0x0, + 0x11, 0xe6, 0xcc, 0x2d, 0xc6, 0x64, 0xe8, 0xc3, 0x87, 0xe9, 0x1a, 0xdd, 0x6e, 0x3e, 0x8d, 0xb4, 0x1c, + 0xc1, 0x26, 0x0, 0xf, 0x3c, 0xb7, 0xbf, 0xe8, 0x11, 0xc4, 0xa2, 0x1d, 0x9a, 0x11, 0xff, 0x9d, 0x1e, + 0xb7, 0xa9, 0x0, 0xb, 0x42, 0xd9, 0xf7, 0x79, 0xc, 0xfc, 0x4e, 0x3b, 0x54, 0xc7, 0x56, 0x11, 0x0, + 0x0, 0x49, 0x62, 0x16, 0x0, 0xb, 0xee, 0xf, 0x82, 0x5f, 0x66, 0x3b, 0xb0, 0x8c, 0x46, 0xd5, 0x75, + 0x9, 0x0, 0x15, 0xec, 0x75, 0xc3, 0xff, 0xa5, 0x68, 0xc4, 0x25, 0x3d, 0xfe, 0xca, 0x3e, 0xb7, 0x3c, + 0x39, 0x0, 0xae, 0x60, 0xec, 0xce, 0xd3, 0x2a, 0x9, 0x2, 0x0, 0x0, 0x18, 0xe2, 0x1c, 0x0, 0x2, + 0x1e, 0x96, 0x0, 0x11, 0xef, 0xbb, 0x4b, 0xf0, 0x38, 0x7a, 0x4f, 0x7, 0x55, 0x7c, 0xf, 0xce, 0xf9, + 0x69, 0xb2, 0xcb, 0xa8, 0x0, 0xc, 0xa1, 0x4d, 0x8b, 0x2, 0x27, 0x96, 0x2f, 0x94, 0xc, 0xe2, 0xe1, + 0x84, 0x0, 0x7, 0x46, 0xe1, 0x57, 0x62, 0x46, 0xe0, 0xa8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf9, 0xd4, 0x93, 0x8f, 0xd5, 0x9d, 0x8, 0x7d, 0xd7, 0xf4, 0x19}; + uint8_t bytesprops1[] = {0x1e, 0xd, 0x31, 0x30, 0xf6, 0x2b, 0x64, 0x15, 0x9f, 0x8d, 0x98, 0xb9, 0xf4, 0xe0, 0x46}; + uint8_t bytesprops2[] = {0xe6, 0xcc, 0x2d, 0xc6, 0x64, 0xe8, 0xc3, 0x87, 0xe9, + 0x1a, 0xdd, 0x6e, 0x3e, 0x8d, 0xb4, 0x1c, 0xc1}; + uint8_t bytesprops4[] = {0x42, 0xd9, 0xf7, 0x79, 0xc, 0xfc, 0x4e, 0x3b, 0x54, 0xc7, 0x56}; + uint8_t bytesprops3[] = {0x3c, 0xb7, 0xbf, 0xe8, 0x11, 0xc4, 0xa2, 0x1d, 0x9a, 0x11, 0xff, 0x9d, 0x1e, 0xb7, 0xa9}; + uint8_t bytesprops5[] = {0xee, 0xf, 0x82, 0x5f, 0x66, 0x3b, 0xb0, 0x8c, 0x46, 0xd5, 0x75}; + uint8_t bytesprops6[] = {0xec, 0x75, 0xc3, 0xff, 0xa5, 0x68, 0xc4, 0x25, 0x3d, 0xfe, 0xca, + 0x3e, 0xb7, 0x3c, 0x39, 0x0, 0xae, 0x60, 0xec, 0xce, 0xd3}; + uint8_t bytesprops7[] = {0x1e, 0x96}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30304}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20871}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29760}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops3}, .v = {11, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18786}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6370}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops7}}}, + }; + + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_options_t opts = lwmqtt_default_options; + opts.properties = props; + opts.clean_session = false; + opts.keep_alive = 18820; + uint8_t client_id_bytes[] = {0xef, 0xbb, 0x4b, 0xf0, 0x38, 0x7a, 0x4f, 0x7, 0x55, + 0x7c, 0xf, 0xce, 0xf9, 0x69, 0xb2, 0xcb, 0xa8}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; + opts.client_id = client_id; + uint8_t username_bytes[] = {0xa1, 0x4d, 0x8b, 0x2, 0x27, 0x96, 0x2f, 0x94, 0xc, 0xe2, 0xe1, 0x84}; + lwmqtt_string_t username = {12, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x46, 0xe1, 0x57, 0x62, 0x46, 0xe0, 0xa8}; + lwmqtt_string_t password = {7, (char*)&password_bytes}; + opts.password = password; + size_t len = 0; + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(len, sizeof(pkt)); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// ConnectRequest {_username = Just "\212\246\v\208Q", _password = Nothing, _lastWill = Just (LastWill {_willRetain = +// False, _willQoS = QoS0, _willTopic = "\DC4\STX\237+\169PM5-\137\&2\143\DC1I\143\ETB8R\205\"+\207'\229\244", _willMsg +// = "*\236\193\FS\231\145S\224#\173\"\224\223\227\142\242*i\131\&8\203\156x\161\231Z", _willProps = +// [PropAuthenticationData "@F\SI\189^\211\234s|5\146(\168\164\192 \153\180c\220\252",PropRequestProblemInformation +// 232,PropAuthenticationData "\CAN\254\164\"\fI(\228cd\224y;O\SOK!\167)\154\222Ld",PropTopicAlias +// 21484,PropServerKeepAlive 7099,PropPayloadFormatIndicator 206,PropServerReference +// "\162\&6\244\147`\171\147\SI\NAKo+\182\232\254\143A\213\DC2\163\188",PropResponseTopic +// "Y\211\251'\226n\vS\158\253hL-\ETB\CAN2\238\SO\SO3\201_\NUL\144\ETB\138{\149\ESC\245",PropTopicAlias +// 32745,PropAuthenticationData "Dh\n\DC2W\232t\159\162mH",PropReceiveMaximum 15700,PropContentType +// "0\ETB\239",PropMaximumPacketSize 30512]}), _cleanSession = True, _keepAlive = 25243, _connID = +// "\183\141\187\211\227F!\186\233+s9c^7\154\b\193Y\148\174w\216=\234K1", _properties = [PropWillDelayInterval +// 15341,PropServerKeepAlive 22577,PropPayloadFormatIndicator 170,PropSubscriptionIdentifier +// 18,PropAssignedClientIdentifier +// ";j\ETB\162-\196\v\162\159GIM\202\222\156KXAJ\244\164\177g\242\223\154\ENQ\DLE",PropAssignedClientIdentifier +// "^c\253)\152\255\252\DLE\r\218\251)\246\255\197\168\244\DC4?",PropWillDelayInterval 1372,PropMessageExpiryInterval +// 1820,PropReceiveMaximum 31562,PropAuthenticationMethod +// "qsv@\208d\EM\241Y\239\FS:_1)n8\SI\231\145\195",PropMessageExpiryInterval 3761]} +TEST(Connect5QCTest, Encode11) { uint8_t pkt[] = { - 0x10, 0xe7, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd6, 0x14, 0xf6, 0xcd, 0x2, 0x27, 0x0, 0x0, 0x18, - 0xf8, 0x2, 0x0, 0x0, 0x2a, 0x77, 0x21, 0x47, 0x65, 0x28, 0x1c, 0x17, 0xdd, 0x12, 0x0, 0x18, 0xb1, 0x35, 0x5d, - 0x3b, 0xd7, 0xbf, 0xba, 0x43, 0x59, 0xb8, 0x2b, 0xa7, 0xf2, 0x10, 0x85, 0xbe, 0x6e, 0xe1, 0x22, 0xc5, 0xdb, 0xe, - 0xd9, 0xa3, 0x23, 0xb, 0x76, 0x1c, 0x0, 0x9, 0xdd, 0x32, 0x7f, 0xec, 0x99, 0x15, 0xa1, 0xac, 0x43, 0x1c, 0x0, - 0xc, 0x19, 0x23, 0x33, 0xca, 0x27, 0xf, 0x4, 0xb1, 0xd7, 0xd3, 0xe1, 0x1c, 0x8, 0x0, 0x14, 0xd, 0x4d, 0x42, - 0xe7, 0x83, 0x37, 0x57, 0xbb, 0xbd, 0x36, 0x2b, 0x36, 0xf5, 0xd6, 0x73, 0x7, 0xb4, 0x81, 0xba, 0x91, 0x1a, 0x0, - 0x1d, 0x76, 0xa1, 0x8e, 0x24, 0x81, 0xb5, 0xc9, 0x9d, 0x87, 0xc, 0x8, 0x8b, 0x46, 0x4, 0x4d, 0x41, 0x27, 0xae, - 0x29, 0x55, 0xb4, 0x1a, 0x81, 0xd9, 0xd9, 0x71, 0xc0, 0x4, 0x4b, 0x1c, 0x0, 0x4, 0x76, 0xea, 0xe8, 0x6c, 0x9, - 0x0, 0xf, 0x61, 0x49, 0xbb, 0xb8, 0x75, 0xf4, 0xd7, 0x77, 0x17, 0xd8, 0xbc,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0x56, 0x2c, 0xeb, 0xbd, 0x13, 0x59, 0xdc, 0x0, 0x11, 0x27, 0x67, 0x59, 0x8, - 0xcb, 0x95, 0x13, 0xce, 0x18, 0x3c, 0x18, 0xb1, 0xcd, 0x24, 0x61, 0xa0, 0x87, 0x0, 0x1a, 0xa2, 0x3c, 0x2, 0xde, - 0xb9, 0xd0, 0xc4, 0x8c, 0xa9, 0xaf, 0x9b, 0x96, 0x15, 0xd8, 0xd, 0x91, 0xc2, 0xad, 0x9f, 0xd2, 0x2f, 0xde, 0xc, - 0xb4, 0x15, 0x3d, 0x0, 0x12, 0x96, 0xd5, 0xaf, 0xa9, 0x79, 0x71, 0x60, 0x13, 0xb9, 0x9e, 0xf0, 0x1f, 0xe4, 0x48, - 0x9e, 0x9e, 0xc0, 0x99, 0x0, 0x4, 0xce, 0x63, 0x11, 0xbb}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb1, 0x35, 0x5d, 0x3b, 0xd7, 0xbf, 0xba, 0x43, 0x59, 0xb8, 0x2b, 0xa7, - 0xf2, 0x10, 0x85, 0xbe, 0x6e, 0xe1, 0x22, 0xc5, 0xdb, 0xe, 0xd9, 0xa3}; - uint8_t bytesprops1[] = {0xdd, 0x32, 0x7f, 0xec, 0x99, 0x15, 0xa1, 0xac, 0x43}; - uint8_t bytesprops2[] = {0x19, 0x23, 0x33, 0xca, 0x27, 0xf, 0x4, 0xb1, 0xd7, 0xd3, 0xe1, 0x1c}; - uint8_t bytesprops3[] = {0xd, 0x4d, 0x42, 0xe7, 0x83, 0x37, 0x57, 0xbb, 0xbd, 0x36, - 0x2b, 0x36, 0xf5, 0xd6, 0x73, 0x7, 0xb4, 0x81, 0xba, 0x91}; - uint8_t bytesprops4[] = {0x76, 0xa1, 0x8e, 0x24, 0x81, 0xb5, 0xc9, 0x9d, 0x87, 0xc, 0x8, 0x8b, 0x46, 0x4, 0x4d, - 0x41, 0x27, 0xae, 0x29, 0x55, 0xb4, 0x1a, 0x81, 0xd9, 0xd9, 0x71, 0xc0, 0x4, 0x4b}; - uint8_t bytesprops5[] = {0x76, 0xea, 0xe8, 0x6c}; - uint8_t bytesprops6[] = {0x61, 0x49, 0xbb, 0xb8, 0x75, 0xf4, 0xd7, 0x77, 0x17, 0xd8, 0xbc, 0x55, 0x21, 0x19, 0xb7}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops9[] = {0xca, 0x5e, 0xe5, 0x47, 0x95, 0xa6, 0x0, 0x3d, 0xba, 0xb3, 0xc9, 0xd8, - 0x2c, 0xb9, 0xe7, 0x9a, 0x3b, 0x1c, 0xe4, 0xf1, 0x38, 0xd7, 0x4d, 0x85}; - uint8_t bytesprops8[] = {0x0, 0xe3, 0xbe, 0xbf, 0x8c, 0xc0, 0x56, 0xed, 0x4a, 0x6d, 0x3e, 0x7, 0x98, 0xc5, 0x29}; - uint8_t bytesprops10[] = {0x99, 0xee, 0x5f, 0x64, 0x4c, 0x7d, 0xfb, 0xe2, 0x72, 0xbf, 0x91, 0xf0, 0x3e}; - uint8_t bytesprops11[] = {0x8a, 0x7b, 0x1b, 0x89, 0x41, 0x7c, 0xf0, 0x5f, 0x2c, 0x48, 0x31, 0xca, 0x46, 0xf3}; - uint8_t bytesprops12[] = {0x2d, 0x36, 0x70, 0xbe, 0x33, 0xa0, 0x60, 0xba, 0xf7, - 0x6a, 0x4b, 0x2c, 0x52, 0x7b, 0x2d, 0xcb, 0x92}; - uint8_t bytesprops13[] = {0xfb, 0xa8, 0xf9, 0x6e, 0x22, 0x2, 0x75, 0x15, 0xa7, - 0x21, 0xb8, 0x68, 0x2d, 0xff, 0x46, 0xaa, 0x73}; - uint8_t bytesprops14[] = {0x39, 0x93, 0x5d, 0x85, 0x73, 0xc, 0x32, 0x29, 0x19, 0xa8, 0x35, - 0xa6, 0x7f, 0x4e, 0x6c, 0xf2, 0x9, 0x91, 0x36, 0x2b, 0xb6, 0xdf}; - uint8_t bytesprops15[] = {0x36, 0x7, 0x18,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 0xfe, 0xa4, 0x22, 0xc, 0x49, 0x28, 0xe4, 0x63, + 0x64, 0xe0, 0x79, 0x3b, 0x4f, 0xe, 0x4b, 0x21, 0xa7, 0x29, 0x9a, 0xde, 0x4c, 0x64, 0x23, 0x53, 0xec, 0x13, 0x1b, + 0xbb, 0x1, 0xce, 0x1c, 0x0, 0x14, 0xa2, 0x36, 0xf4, 0x93, 0x60, 0xab, 0x93, 0xf, 0x15, 0x6f, 0x2b, 0xb6, 0xe8, + 0xfe, 0x8f, 0x41, 0xd5, 0x12, 0xa3, 0xbc, 0x8, 0x0, 0x1e, 0x59, 0xd3, 0xfb, 0x27, 0xe2, 0x6e, 0xb, 0x53, 0x9e, + 0xfd, 0x68, 0x4c, 0x2d, 0x17, 0x18, 0x32, 0xee, 0xe, 0xe, 0x33, 0xc9, 0x5f, 0x0, 0x90, 0x17, 0x8a, 0x7b, 0x95, + 0x1b, 0xf5, 0x23, 0x7f, 0xe9, 0x16, 0x0, 0xb, 0x44, 0x68, 0xa, 0x12, 0x57, 0xe8, 0x74, 0x9f, 0xa2, 0x6d, 0x48, + 0x21, 0x3d, 0x54, 0x3, 0x0, 0x3, 0x30, 0x17, 0xef, 0x27, 0x0, 0x0, 0x77, 0x30, 0x0, 0x19, 0x14, 0x2, 0xed, + 0x2b, 0xa9, 0x50, 0x4d, 0x35, 0x2d, 0x89, 0x32, 0x8f, 0x11, 0x49, 0x8f, 0x17, 0x38, 0x52, 0xcd, 0x22, 0x2b, 0xcf, + 0x27, 0xe5, 0xf4, 0x0, 0x1a, 0x2a, 0xec, 0xc1, 0x1c, 0xe7, 0x91, 0x53, 0xe0, 0x23, 0xad, 0x22, 0xe0, 0xdf, 0xe3, + 0x8e, 0xf2, 0x2a, 0x69, 0x83, 0x38, 0xcb, 0x9c, 0x78, 0xa1, 0xe7, 0x5a, 0x0, 0x5, 0xd4, 0xf6, 0xb, 0xd0, 0x51}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x3b, 0x6a, 0x17, 0xa2, 0x2d, 0xc4, 0xb, 0xa2, 0x9f, 0x47, 0x49, 0x4d, 0xca, 0xde, + 0x9c, 0x4b, 0x58, 0x41, 0x4a, 0xf4, 0xa4, 0xb1, 0x67, 0xf2, 0xdf, 0x9a, 0x5, 0x10}; + uint8_t bytesprops1[] = {0x5e, 0x63, 0xfd, 0x29, 0x98, 0xff, 0xfc, 0x10, 0xd, 0xda, + 0xfb, 0x29, 0xf6, 0xff, 0xc5, 0xa8, 0xf4, 0x14, 0x3f}; + uint8_t bytesprops2[] = {0x71, 0x73, 0x76, 0x40, 0xd0, 0x64, 0x19, 0xf1, 0x59, 0xef, 0x1c, + 0x3a, 0x5f, 0x31, 0x29, 0x6e, 0x38, 0xf, 0xe7, 0x91, 0xc3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6392}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10871}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18277}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 221}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2934}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 224}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops8}, .v = {24, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11564}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 8644}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28557}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12014}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 15341}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22577}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 1372}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1820}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31562}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3761}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xa5, 0x22, 0x78, 0x95, 0x82, 0xc4, 0xe7, 0x4e, 0xea, 0xde, - 0xb4, 0x5d, 0x27, 0x1e, 0xf1, 0x22, 0x4b, 0xbd, 0xef, 0xd5}; - uint8_t byteswillprops1[] = {0x47, 0x7b, 0x28, 0x24, 0xee, 0x33, 0xb8, 0x87, 0x77, 0xd, - 0xf5, 0xd7, 0xed, 0x83, 0x9d, 0x5, 0x27, 0x8c, 0x16}; - uint8_t byteswillprops2[] = {0xa0, 0xa3, 0xc0, 0x53, 0x78, 0xc1, 0xea, 0xdc, 0xa4, 0x1c, - 0xa1, 0xa3, 0x2e, 0xc0, 0x55, 0xb6, 0x23, 0x3d, 0x52, 0x41}; - uint8_t byteswillprops3[] = {0xda, 0x3c, 0x4e, 0x64, 0xee, 0x68, 0xcd, 0x9c, 0x21, 0x24, 0x5d, 0xdc}; - uint8_t byteswillprops4[] = {0x28, 0x8f, 0x62, 0x85, 0x2f, 0x3f, 0xc1, 0x56, 0xa1, 0xfb, 0xe3, 0x43, 0xcd, 0x4, - 0x73, 0xda, 0xac, 0x21, 0x7f, 0xf4, 0x7d, 0x56, 0xba, 0x47, 0x2c, 0xe5, 0x3d, 0x48}; - uint8_t byteswillprops5[] = {0}; - uint8_t byteswillprops6[] = {0x1e, 0x33, 0xcd, 0xaf, 0xd7, 0x2d, 0x4a, 0xda, 0xfe, 0x56, 0x2c, 0xeb, 0xbd}; + uint8_t byteswillprops0[] = {0x40, 0x46, 0xf, 0xbd, 0x5e, 0xd3, 0xea, 0x73, 0x7c, 0x35, 0x92, + 0x28, 0xa8, 0xa4, 0xc0, 0x20, 0x99, 0xb4, 0x63, 0xdc, 0xfc}; + uint8_t byteswillprops1[] = {0x18, 0xfe, 0xa4, 0x22, 0xc, 0x49, 0x28, 0xe4, 0x63, 0x64, 0xe0, 0x79, + 0x3b, 0x4f, 0xe, 0x4b, 0x21, 0xa7, 0x29, 0x9a, 0xde, 0x4c, 0x64}; + uint8_t byteswillprops2[] = {0xa2, 0x36, 0xf4, 0x93, 0x60, 0xab, 0x93, 0xf, 0x15, 0x6f, + 0x2b, 0xb6, 0xe8, 0xfe, 0x8f, 0x41, 0xd5, 0x12, 0xa3, 0xbc}; + uint8_t byteswillprops3[] = {0x59, 0xd3, 0xfb, 0x27, 0xe2, 0x6e, 0xb, 0x53, 0x9e, 0xfd, + 0x68, 0x4c, 0x2d, 0x17, 0x18, 0x32, 0xee, 0xe, 0xe, 0x33, + 0xc9, 0x5f, 0x0, 0x90, 0x17, 0x8a, 0x7b, 0x95, 0x1b, 0xf5}; + uint8_t byteswillprops4[] = {0x44, 0x68, 0xa, 0x12, 0x57, 0xe8, 0x74, 0x9f, 0xa2, 0x6d, 0x48}; + uint8_t byteswillprops5[] = {0x30, 0x17, 0xef}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 726}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30408}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10578}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7623}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32532}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12084}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 22979}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28253}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14469}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20225}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23004}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21484}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7099}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32745}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15700}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30512}}, }; - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x27, 0x67, 0x59, 0x8, 0xcb, 0x95, 0x13, 0xce, 0x18, - 0x3c, 0x18, 0xb1, 0xcd, 0x24, 0x61, 0xa0, 0x87}; - lwmqtt_string_t will_topic = {17, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xa2, 0x3c, 0x2, 0xde, 0xb9, 0xd0, 0xc4, 0x8c, 0xa9, 0xaf, 0x9b, 0x96, 0x15, - 0xd8, 0xd, 0x91, 0xc2, 0xad, 0x9f, 0xd2, 0x2f, 0xde, 0xc, 0xb4, 0x15, 0x3d}; + lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x14, 0x2, 0xed, 0x2b, 0xa9, 0x50, 0x4d, 0x35, 0x2d, 0x89, 0x32, 0x8f, 0x11, + 0x49, 0x8f, 0x17, 0x38, 0x52, 0xcd, 0x22, 0x2b, 0xcf, 0x27, 0xe5, 0xf4}; + lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2a, 0xec, 0xc1, 0x1c, 0xe7, 0x91, 0x53, 0xe0, 0x23, 0xad, 0x22, 0xe0, 0xdf, + 0xe3, 0x8e, 0xf2, 0x2a, 0x69, 0x83, 0x38, 0xcb, 0x9c, 0x78, 0xa1, 0xe7, 0x5a}; lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS2; + will.qos = LWMQTT_QOS0; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 5366; - uint8_t client_id_bytes[] = {0xe6, 0xd1, 0x24, 0x66, 0xca, 0xee, 0xe3}; - lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; + opts.keep_alive = 25243; + uint8_t client_id_bytes[] = {0xb7, 0x8d, 0xbb, 0xd3, 0xe3, 0x46, 0x21, 0xba, 0xe9, 0x2b, 0x73, 0x39, 0x63, 0x5e, + 0x37, 0x9a, 0x8, 0xc1, 0x59, 0x94, 0xae, 0x77, 0xd8, 0x3d, 0xea, 0x4b, 0x31}; + lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x96, 0xd5, 0xaf, 0xa9, 0x79, 0x71, 0x60, 0x13, 0xb9, - 0x9e, 0xf0, 0x1f, 0xe4, 0x48, 0x9e, 0x9e, 0xc0, 0x99}; - lwmqtt_string_t username = {18, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xd4, 0xf6, 0xb, 0xd0, 0x51}; + lwmqtt_string_t username = {5, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xce, 0x63, 0x11, 0xbb}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -11480,174 +10848,163 @@ TEST(Connect5QCTest, Encode10) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\129\128\161\159\147\245-e\bJ_\149 \184p.t,\236Q\211\160XD\SUB\239\DEL\DC2\144", -// _password = Just "\240\244", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = -// "\135\ETXg\SIO\185\150d\172+QZ", _willMsg = "\232\GS\202P\180x\186\243}<\155\148:\217\145'", _willProps = -// [PropResponseInformation "\156\196\210\158\219\156+'\RS\190\199yd\"\NAK",PropMessageExpiryInterval -// 23010,PropAssignedClientIdentifier "\DEL\231K\158\NUL\FS",PropSubscriptionIdentifier 24,PropAuthenticationData -// "W\EOT\GS\192l",PropRequestProblemInformation 26,PropSubscriptionIdentifierAvailable 196,PropSubscriptionIdentifier -// 7,PropMaximumQoS 107,PropReceiveMaximum 6946,PropSubscriptionIdentifierAvailable -// 74,PropSubscriptionIdentifierAvailable 84,PropRetainAvailable 210,PropRetainAvailable 227,PropCorrelationData -// "4T\235",PropTopicAlias 2606,PropContentType -// "\196_\RSz\218\DC2\129\240\142\SI;\178\128\214\n2Xa\255\152",PropReasonString -// "\188\SO\EOT\153\ETBi\251",PropCorrelationData "\ACK\151j",PropServerKeepAlive 32148,PropResponseTopic -// "\233\244(",PropUserProperty "\144\&4\SOH\DC4\211\148\238p" "\208\142\165],=\178\246",PropSubscriptionIdentifier -// 7,PropAuthenticationData "\213\&3\164\208JRg\195yY\201\186U\DC4w2*\230a\140\194K%\CAN\198\136",PropMaximumPacketSize -// 9903,PropReceiveMaximum 8076,PropRetainAvailable 52]}), _cleanSession = True, _keepAlive = 30463, _connID = -// "\171v+\163\172\203\229S\191\242VUR\b\DLE\179J\234", _properties = [PropSharedSubscriptionAvailable -// 231,PropServerKeepAlive 30540,PropWillDelayInterval 5194,PropWillDelayInterval 15709,PropAuthenticationData -// "\247\&5\f\212\162\r\198\148\245A\191u\188pHR",PropRequestProblemInformation 159,PropAuthenticationData -// "\145<\GSaD\195",PropSharedSubscriptionAvailable 185,PropReasonString -// "!\183\142\222L[8\141\DC1\184c\163\tMb\173\DC3}\133\250\189\183",PropCorrelationData -// "\173\144\163\ENQ%V\221\viP",PropCorrelationData "\251\189\NUL\175\199R\rL\226IT\205",PropPayloadFormatIndicator -// 251,PropSharedSubscriptionAvailable 19,PropAssignedClientIdentifier -// "\221\175\203/ii\241\176\164E\US\196#\180\201A-=q8\242\230f\v`",PropResponseInformation -// "v9m5@\235\192\204\202\246\249\132\238\155Er\234\213]'B9",PropMaximumPacketSize +// 32081,PropSubscriptionIdentifier 1,PropRequestProblemInformation 102,PropAuthenticationMethod +// "\197\235",PropWillDelayInterval 6511,PropResponseTopic "!M\128,\150\163!\143\224\242\EOT\134L",PropReasonString +// "/A\156\166\185\EOTJ\160\237\181>.V\201\224@\242\138(\242\189\f\194",PropAuthenticationData +// "\242\SUB\t\202\181.\DC4\r\215\166\176\214;\\\180\223",PropResponseTopic +// "\158\254\&6D?",PropPayloadFormatIndicator +// 117,PropMaximumQoS 158,PropRetainAvailable 153,PropRetainAvailable 39,PropWildcardSubscriptionAvailable +// 160,PropPayloadFormatIndicator 190,PropMaximumPacketSize 10707,PropCorrelationData +// "\r\212\202\215$\aP\254vA\199\SO",PropAuthenticationData "d+\138\v\214{\130\177|\158\170G\158\190\NUL\156\166"]}), +// _cleanSession = False, _keepAlive = 28636, _connID = "\GS \174N\196\134\134\164\ACK;!#]\239\168\159\231\208f", +// _properties = [PropRetainAvailable 43,PropMessageExpiryInterval 15199,PropServerKeepAlive 3140,PropMaximumQoS +// 195,PropWildcardSubscriptionAvailable 46,PropWillDelayInterval 26473,PropWildcardSubscriptionAvailable +// 10,PropMaximumPacketSize 27203]} +TEST(Connect5QCTest, Encode13) { uint8_t pkt[] = { - 0x10, 0xf3, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xac, 0x60, 0xe6, 0x5b, 0x23, 0x12, 0x66, 0x2, 0x0, - 0x0, 0x64, 0x52, 0x8, 0x0, 0xd, 0x7f, 0xeb, 0x82, 0x6c, 0xe0, 0x53, 0x2b, 0x3f, 0x2d, 0x4, 0x31, 0x66, 0x9a, - 0x26, 0x0, 0xa, 0x1, 0x8b, 0xf5, 0x22, 0xb3, 0xe7, 0xae, 0x96, 0xb0, 0xad, 0x0, 0x1c, 0x5f, 0xcc, 0x8e, 0x76, - 0xd8, 0xb6, 0xfa, 0xba, 0x36, 0xce, 0x1d, 0x1a, 0xec, 0xdf, 0xef, 0x84, 0xb4, 0x3a, 0xfb, 0x5e, 0x17, 0x55, 0xa3, - 0xb6, 0x31, 0xea, 0xff, 0x39, 0x17, 0xeb, 0x25, 0x3f, 0x9, 0x0, 0x11, 0x7b, 0x8e, 0x55, 0xf5, 0xda, 0x8f, 0xd1, - 0x70, 0x1d, 0x7, 0x33, 0xe8, 0x6, 0x34, 0x7, 0x2b, 0xa7, 0x0, 0x1b, 0xe2, 0x57, 0xe4, 0x88, 0x25, 0x68, 0xf8, - 0x43, 0xbe, 0x83, 0xcc, 0x93, 0x66, 0x15, 0x6e, 0x94, 0x20, 0xb8, 0xd0, 0x23, 0xf0, 0x1c, 0x66, 0x1c, 0x33, 0x54, - 0xe7, 0x39, 0x15, 0x0, 0x0, 0x1c, 0x0, 0x14, 0x22, 0x6f, 0xdc, 0xe6, 0x32, 0x9b, 0x92, 0x7b, 0x15, 0xd, 0xc0, - 0x30, 0x80, 0x15, 0x88, 0xee, 0x2a, 0x5, 0xbd, 0x46, 0x12, 0x0, 0x1c, 0x3, 0x6c, 0x45, 0xa1, 0xe9, 0x62, 0x3, - 0x4, 0x8e, 0x8d, 0x5d, 0xed, 0x56, 0xc7, 0x65, 0xc6, 0xda, 0xa2, 0x71, 0x1d, 0x45, 0x98, 0xb3, 0x2b, 0x4b, 0xb2, - 0xd, 0x36, 0x0, 0xd, 0xd3, 0xc0, 0xb1, 0x86, 0x38, 0xf5, 0xc5, 0x94, 0x90, 0xee, 0x93, 0x54, 0x3f, 0x0, 0x15, - 0x57, 0x73, 0x17, 0xd2, 0x3b, 0x13, 0xe6, 0x7e, 0x9f, 0x74, 0xd4, 0x6b, 0x28, 0xaf, 0xae, 0x22, 0xef, 0x18, 0xc1, - 0xe5, 0xff, 0x0, 0xe, 0x2e, 0x32, 0xd6, 0xec, 0x25, 0xa7, 0x43, 0xbe, 0xf8, 0xc1, 0xd3, 0x40, 0x24, 0xf8}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7f, 0xeb, 0x82, 0x6c, 0xe0, 0x53, 0x2b, 0x3f, 0x2d, 0x4, 0x31, 0x66, 0x9a}; - uint8_t bytesprops2[] = {0x5f, 0xcc, 0x8e, 0x76, 0xd8, 0xb6, 0xfa, 0xba, 0x36, 0xce, 0x1d, 0x1a, 0xec, 0xdf, - 0xef, 0x84, 0xb4, 0x3a, 0xfb, 0x5e, 0x17, 0x55, 0xa3, 0xb6, 0x31, 0xea, 0xff, 0x39}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, 0x1f, 0x0, 0xf, 0xd7, 0xe6, 0x64, 0x18, 0x16, 0xec, 0x50, 0xad, 0x2, 0x76, 0x1, 0x80, 0x36, 0x85, 0xcd, + 0x21, 0xc, 0xee, 0x11, 0x0, 0x0, 0x74, 0xc2, 0x23, 0x52, 0xc2, 0x16, 0x0, 0x1e, 0xa5, 0x23, 0x76, 0x41, 0x42, + 0x9c, 0xb, 0x53, 0x1b, 0x9d, 0x8, 0x3, 0x53, 0xe9, 0x9e, 0x30, 0x2a, 0xfe, 0x76, 0xe1, 0x68, 0x36, 0xf0, 0xe7, + 0x3e, 0x9e, 0xfe, 0x36, 0x44, 0x3f, 0x1, 0x75, 0x24, 0x9e, 0x25, 0x99, 0x25, 0x27, 0x28, 0xa0, 0x1, 0xbe, 0x27, + 0x0, 0x0, 0x29, 0xd3, 0x9, 0x0, 0xc, 0xd, 0xd4, 0xca, 0xd7, 0x24, 0x7, 0x50, 0xfe, 0x76, 0x41, 0xc7, 0xe, + 0x16, 0x0, 0x11, 0x64, 0x2b, 0x8a, 0xb, 0xd6, 0x7b, 0x82, 0xb1, 0x7c, 0x9e, 0xaa, 0x47, 0x9e, 0xbe, 0x0, 0x9c, + 0xa6, 0x0, 0xd, 0x12, 0x4, 0xf6, 0x90, 0x32, 0x63, 0x9c, 0x41, 0x47, 0x4e, 0x7, 0xf9, 0x7e, 0x0, 0x12, 0xef, + 0x7e, 0xdd, 0xa7, 0xd7, 0xcc, 0x51, 0xc, 0x5c, 0xba, 0x51, 0xc6, 0x3c, 0x14, 0xdc, 0x7e, 0xd9, 0x25}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4710}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25682}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops1}, .v = {28, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 43}}, {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15199}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3140}}, {.prop = (lwmqtt_prop_t)36, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 46}}, {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26473}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 10}}, {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27203}}, }; - lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0}; - uint8_t byteswillprops1[] = {0x22, 0x6f, 0xdc, 0xe6, 0x32, 0x9b, 0x92, 0x7b, 0x15, 0xd, - 0xc0, 0x30, 0x80, 0x15, 0x88, 0xee, 0x2a, 0x5, 0xbd, 0x46}; - uint8_t byteswillprops2[] = {0x3, 0x6c, 0x45, 0xa1, 0xe9, 0x62, 0x3, 0x4, 0x8e, 0x8d, 0x5d, 0xed, 0x56, 0xc7, - 0x65, 0xc6, 0xda, 0xa2, 0x71, 0x1d, 0x45, 0x98, 0xb3, 0x2b, 0x4b, 0xb2, 0xd, 0x36}; + uint8_t byteswillprops0[] = {0xe9, 0xb7, 0x5a, 0x7, 0xf6, 0xe5, 0x0, 0x8b, 0x18, + 0xd, 0x11, 0x3c, 0xf4, 0xd0, 0x92, 0xcd, 0x69}; + uint8_t byteswillprops1[] = {0xf2, 0xc3, 0x34, 0x5f, 0xe5, 0x7, 0xf9, 0xbe, + 0xb4, 0xce, 0x7, 0xf2, 0xc3, 0xd9, 0xcf, 0xc0}; + uint8_t byteswillprops2[] = {0x5d, 0xb6, 0xd9, 0xb2, 0x56, 0x72, 0x3c, 0xd0, 0x6, 0xd8, 0xb8, 0x3d}; + uint8_t byteswillprops4[] = {0xf3, 0x98, 0xa6, 0x53, 0xbd, 0x33, 0x11}; + uint8_t byteswillprops3[] = {0xbd, 0x68, 0x80, 0xdc, 0x99, 0x58, 0x5f, 0xd5, 0x5, + 0x8e, 0x93, 0x6d, 0x7d, 0x9a, 0xf1, 0xa8, 0x34}; + uint8_t byteswillprops5[] = {0xd7, 0xe6, 0x64, 0x18, 0x16, 0xec, 0x50, 0xad, 0x2, 0x76, 0x1, 0x80, 0x36, 0x85, 0xcd}; + uint8_t byteswillprops6[] = {0xa5, 0x23, 0x76, 0x41, 0x42, 0x9c, 0xb, 0x53, 0x1b, 0x9d, + 0x8, 0x3, 0x53, 0xe9, 0x9e, 0x30, 0x2a, 0xfe, 0x76, 0xe1, + 0x68, 0x36, 0xf0, 0xe7, 0x3e, 0x9e, 0xfe, 0x36, 0x44, 0x3f}; + uint8_t byteswillprops7[] = {0xd, 0xd4, 0xca, 0xd7, 0x24, 0x7, 0x50, 0xfe, 0x76, 0x41, 0xc7, 0xe}; + uint8_t byteswillprops8[] = {0x64, 0x2b, 0x8a, 0xb, 0xd6, 0x7b, 0x82, 0xb1, 0x7c, + 0x9e, 0xaa, 0x47, 0x9e, 0xbe, 0x0, 0x9c, 0xa6}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18936}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 64}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 55}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {17, (char*)&byteswillprops3}, .v = {7, (char*)&byteswillprops4}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3310}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29890}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21186}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10707}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&byteswillprops8}}}, }; - lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xd3, 0xc0, 0xb1, 0x86, 0x38, 0xf5, 0xc5, 0x94, 0x90, 0xee, 0x93, 0x54, 0x3f}; + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x12, 0x4, 0xf6, 0x90, 0x32, 0x63, 0x9c, 0x41, 0x47, 0x4e, 0x7, 0xf9, 0x7e}; lwmqtt_string_t will_topic = {13, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x57, 0x73, 0x17, 0xd2, 0x3b, 0x13, 0xe6, 0x7e, 0x9f, 0x74, 0xd4, - 0x6b, 0x28, 0xaf, 0xae, 0x22, 0xef, 0x18, 0xc1, 0xe5, 0xff}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + uint8_t will_payload_bytes[] = {0xef, 0x7e, 0xdd, 0xa7, 0xd7, 0xcc, 0x51, 0xc, 0x5c, + 0xba, 0x51, 0xc6, 0x3c, 0x14, 0xdc, 0x7e, 0xd9, 0x25}; + lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 24806; - uint8_t client_id_bytes[] = {0xe2, 0x57, 0xe4, 0x88, 0x25, 0x68, 0xf8, 0x43, 0xbe, 0x83, 0xcc, 0x93, 0x66, 0x15, - 0x6e, 0x94, 0x20, 0xb8, 0xd0, 0x23, 0xf0, 0x1c, 0x66, 0x1c, 0x33, 0x54, 0xe7}; - lwmqtt_string_t client_id = {27, (char*)&client_id_bytes}; + opts.keep_alive = 28636; + uint8_t client_id_bytes[] = {0x1d, 0x20, 0xae, 0x4e, 0xc4, 0x86, 0x86, 0xa4, 0x6, 0x3b, + 0x21, 0x23, 0x5d, 0xef, 0xa8, 0x9f, 0xe7, 0xd0, 0x66}; + lwmqtt_string_t client_id = {19, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x2e, 0x32, 0xd6, 0xec, 0x25, 0xa7, 0x43, 0xbe, 0xf8, 0xc1, 0xd3, 0x40, 0x24, 0xf8}; - lwmqtt_string_t username = {14, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -11743,87 +11127,135 @@ TEST(Connect5QCTest, Encode12) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\RST\210\144\vR\152\r\144sH\140S\216X\252D\232\156", _lastWill -// = Just (LastWill {_willRetain = False, _willQoS = QoS0, _willTopic = "\DC3\214I\EM\233B\b", _willMsg = -// "iT\rof/\249~4Z(<[iN\168@!g", _willProps = [PropMaximumQoS 167,PropMaximumPacketSize 12242]}), _cleanSession = False, -// _keepAlive = 10052, _connID = "\ENQB\207E\189\199FE\196\245\ACK\135\200N\n\187\177\209\128\171", _properties = -// [PropServerReference "KI",PropAssignedClientIdentifier "\225\242\&7/?\240\213\232",PropReasonString -// "(\f\SYN\234\199\138\137\244J",PropAuthenticationMethod "\191\&0g\212\184\253\SOH\169\142i\245'\137",PropReasonString -// ">\163\212\151\ENQJ",PropTopicAlias 4538,PropUserProperty "K" -// "NF\225SC\170)\240\174\143\DC4\219\176L.\201\249\238?\227",PropResponseTopic -// "\NUL\169(3\131\&4.\135\&1L\189\191%Y\144\175\196\DLE\ETB\251\223'^[F\238-\172R",PropPayloadFormatIndicator -// 243,PropRetainAvailable 64,PropSharedSubscriptionAvailable 101,PropRequestResponseInformation 30]} -TEST(Connect5QCTest, Encode13) { - uint8_t pkt[] = {0x10, 0xd6, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x44, 0x27, 0x44, 0x7a, 0x1c, 0x0, 0x2, - 0x4b, 0x49, 0x12, 0x0, 0x8, 0xe1, 0xf2, 0x37, 0x2f, 0x3f, 0xf0, 0xd5, 0xe8, 0x1f, 0x0, 0x9, 0x28, - 0xc, 0x16, 0xea, 0xc7, 0x8a, 0x89, 0xf4, 0x4a, 0x15, 0x0, 0xd, 0xbf, 0x30, 0x67, 0xd4, 0xb8, 0xfd, - 0x1, 0xa9, 0x8e, 0x69, 0xf5, 0x27, 0x89, 0x1f, 0x0, 0x6, 0x3e, 0xa3, 0xd4, 0x97, 0x5, 0x4a, 0x23, - 0x11, 0xba, 0x26, 0x0, 0x1, 0x4b, 0x0, 0x14, 0x4e, 0x46, 0xe1, 0x53, 0x43, 0xaa, 0x29, 0xf0, 0xae, - 0x8f, 0x14, 0xdb, 0xb0, 0x4c, 0x2e, 0xc9, 0xf9, 0xee, 0x3f, 0xe3, 0x8, 0x0, 0x1d, 0x0, 0xa9, 0x28, - 0x33, 0x83, 0x34, 0x2e, 0x87, 0x31, 0x4c, 0xbd, 0xbf, 0x25, 0x59, 0x90, 0xaf, 0xc4, 0x10, 0x17, 0xfb, - 0xdf, 0x27, 0x5e, 0x5b, 0x46, 0xee, 0x2d, 0xac, 0x52, 0x1, 0xf3, 0x25, 0x40, 0x2a, 0x65, 0x19, 0x1e, - 0x0, 0x14, 0x5, 0x42, 0xcf, 0x45, 0xbd, 0xc7, 0x46, 0x45, 0xc4, 0xf5, 0x6, 0x87, 0xc8, 0x4e, 0xa, - 0xbb, 0xb1, 0xd1, 0x80, 0xab, 0x7, 0x24, 0xa7, 0x27, 0x0, 0x0, 0x2f, 0xd2, 0x0, 0x7, 0x13, 0xd6, - 0x49, 0x19, 0xe9, 0x42, 0x8, 0x0, 0x13, 0x69, 0x54, 0xd, 0x6f, 0x66, 0x2f, 0xf9, 0x7e, 0x34, 0x5a, - 0x28, 0x3c, 0x5b, 0x69, 0x4e, 0xa8, 0x40, 0x21, 0x67, 0x0, 0x13, 0x1e, 0x54, 0xd2, 0x90, 0xb, 0x52, - 0x98, 0xd, 0x90, 0x73, 0x48, 0x8c, 0x53, 0xd8, 0x58, 0xfc, 0x44, 0xe8, 0x9c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x4b, 0x49}; - uint8_t bytesprops1[] = {0xe1, 0xf2, 0x37, 0x2f, 0x3f, 0xf0, 0xd5, 0xe8}; - uint8_t bytesprops2[] = {0x28, 0xc, 0x16, 0xea, 0xc7, 0x8a, 0x89, 0xf4, 0x4a}; - uint8_t bytesprops3[] = {0xbf, 0x30, 0x67, 0xd4, 0xb8, 0xfd, 0x1, 0xa9, 0x8e, 0x69, 0xf5, 0x27, 0x89}; - uint8_t bytesprops4[] = {0x3e, 0xa3, 0xd4, 0x97, 0x5, 0x4a}; - uint8_t bytesprops6[] = {0x4e, 0x46, 0xe1, 0x53, 0x43, 0xaa, 0x29, 0xf0, 0xae, 0x8f, - 0x14, 0xdb, 0xb0, 0x4c, 0x2e, 0xc9, 0xf9, 0xee, 0x3f, 0xe3}; - uint8_t bytesprops5[] = {0x4b}; - uint8_t bytesprops7[] = {0x0, 0xa9, 0x28, 0x33, 0x83, 0x34, 0x2e, 0x87, 0x31, 0x4c, 0xbd, 0xbf, 0x25, 0x59, 0x90, - 0xaf, 0xc4, 0x10, 0x17, 0xfb, 0xdf, 0x27, 0x5e, 0x5b, 0x46, 0xee, 0x2d, 0xac, 0x52}; +// ConnectRequest {_username = Just "\242\255\248\RSlqy\210\165\223EJs\218\138\195\252~OS0\155s\176", _password = Just +// "+\217", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = +// "\251\&3\249*?0\b\223!*\150M", _willMsg = "bZ\SO", _willProps = [PropCorrelationData "",PropContentType +// "_\a\DC1\220",PropContentType +// "\213\195\133\ESC#\222\159\168\185,\232\DEL%\168\ESC\200\bx_\134\162\142D\248E\140Il\DC1",PropSessionExpiryInterval +// 5768,PropMessageExpiryInterval 13956,PropMessageExpiryInterval 14376,PropSessionExpiryInterval +// 12032,PropReceiveMaximum 23268,PropResponseTopic "",PropPayloadFormatIndicator 223,PropWillDelayInterval +// 25802,PropResponseTopic "",PropTopicAliasMaximum 24689,PropServerReference +// "\182\223(@\170E\190\164\241o\231V\142\t\EM\195\130\189\161\180\245\213\158.",PropSubscriptionIdentifierAvailable +// 122,PropRequestResponseInformation 35,PropReasonString +// "\156\SO/\231\187\207d,q\ESC\194\254c\DC1\128H\149bo\237$\145\USZ\226\200N",PropAuthenticationData +// "R9\140\235\217L\211\239"]}), _cleanSession = False, _keepAlive = 5719, _connID = +// "\222\165\251RK\130'\234\242.*\EOT\200~\"\NULJ", _properties = [PropWildcardSubscriptionAvailable +// 209,PropUserProperty "\STX^\128\CAN\170hj&x<\184\163\245\183\128\147p\174\152~" +// "\240\251\144\209\203\225\n`P\180;\246\192\168",PropContentType +// "\a\207\189\216\190\ETBX\229>\240+\225\246\180Q*{\194\151",PropMessageExpiryInterval +// 24515,PropRequestProblemInformation 168,PropReceiveMaximum 7245,PropCorrelationData +// "\196\\$\209v\EOT\141\157\205\165\198ksR\250\n\224\205\143\213\"\169N\170\STX\245\193q\r?",PropWildcardSubscriptionAvailable +// 188,PropMaximumPacketSize 20784,PropWildcardSubscriptionAvailable 69,PropServerReference +// "\192\240X\221\197\150\143\140\240d#\234C\200J\236\EOT\197\224\NAK\147\244\&4\154\192",PropCorrelationData "_w"]} +TEST(Connect5QCTest, Encode14) { + uint8_t pkt[] = { + 0x10, 0xff, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xcc, 0x16, 0x57, 0x94, 0x1, 0x28, 0xd1, 0x26, 0x0, + 0x14, 0x2, 0x5e, 0x80, 0x18, 0xaa, 0x68, 0x6a, 0x26, 0x78, 0x3c, 0xb8, 0xa3, 0xf5, 0xb7, 0x80, 0x93, 0x70, 0xae, + 0x98, 0x7e, 0x0, 0xe, 0xf0, 0xfb, 0x90, 0xd1, 0xcb, 0xe1, 0xa, 0x60, 0x50, 0xb4, 0x3b, 0xf6, 0xc0, 0xa8, 0x3, + 0x0, 0x13, 0x7, 0xcf, 0xbd, 0xd8, 0xbe, 0x17, 0x58, 0xe5, 0x3e, 0xf0, 0x2b, 0xe1, 0xf6, 0xb4, 0x51, 0x2a, 0x7b, + 0xc2, 0x97, 0x2, 0x0, 0x0, 0x5f, 0xc3, 0x17, 0xa8, 0x21, 0x1c, 0x4d, 0x9, 0x0, 0x1e, 0xc4, 0x5c, 0x24, 0xd1, + 0x76, 0x4, 0x8d, 0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bd, 0xa1, 0xb4, 0xf5, 0xd5, 0x9e, 0x2e, 0x29, 0x7a, 0x19, 0x23, 0x1f, 0x0, 0x1b, 0x9c, 0xe, 0x2f, 0xe7, 0xbb, + 0xcf, 0x64, 0x2c, 0x71, 0x1b, 0xc2, 0xfe, 0x63, 0x11, 0x80, 0x48, 0x95, 0x62, 0x6f, 0xed, 0x24, 0x91, 0x1f, 0x5a, + 0xe2, 0xc8, 0x4e, 0x16, 0x0, 0x8, 0x52, 0x39, 0x8c, 0xeb, 0xd9, 0x4c, 0xd3, 0xef, 0x0, 0xc, 0xfb, 0x33, 0xf9, + 0x2a, 0x3f, 0x30, 0x8, 0xdf, 0x21, 0x2a, 0x96, 0x4d, 0x0, 0x3, 0x62, 0x5a, 0xe, 0x0, 0x18, 0xf2, 0xff, 0xf8, + 0x1e, 0x6c, 0x71, 0x79, 0xd2, 0xa5, 0xdf, 0x45, 0x4a, 0x73, 0xda, 0x8a, 0xc3, 0xfc, 0x7e, 0x4f, 0x53, 0x30, 0x9b, + 0x73, 0xb0, 0x0, 0x2, 0x2b, 0xd9}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0xf0, 0xfb, 0x90, 0xd1, 0xcb, 0xe1, 0xa, 0x60, 0x50, 0xb4, 0x3b, 0xf6, 0xc0, 0xa8}; + uint8_t bytesprops0[] = {0x2, 0x5e, 0x80, 0x18, 0xaa, 0x68, 0x6a, 0x26, 0x78, 0x3c, + 0xb8, 0xa3, 0xf5, 0xb7, 0x80, 0x93, 0x70, 0xae, 0x98, 0x7e}; + uint8_t bytesprops2[] = {0x7, 0xcf, 0xbd, 0xd8, 0xbe, 0x17, 0x58, 0xe5, 0x3e, 0xf0, + 0x2b, 0xe1, 0xf6, 0xb4, 0x51, 0x2a, 0x7b, 0xc2, 0x97}; + uint8_t bytesprops3[] = {0xc4, 0x5c, 0x24, 0xd1, 0x76, 0x4, 0x8d, 0x9d, 0xcd, 0xa5, 0xc6, 0x6b, 0x73, 0x52, 0xfa, + 0xa, 0xe0, 0xcd, 0x8f, 0xd5, 0x22, 0xa9, 0x4e, 0xaa, 0x2, 0xf5, 0xc1, 0x71, 0xd, 0x3f}; + uint8_t bytesprops4[] = {0xc0, 0xf0, 0x58, 0xdd, 0xc5, 0x96, 0x8f, 0x8c, 0xf0, 0x64, 0x23, 0xea, 0x43, + 0xc8, 0x4a, 0xec, 0x4, 0xc5, 0xe0, 0x15, 0x93, 0xf4, 0x34, 0x9a, 0xc0}; + uint8_t bytesprops5[] = {0x5f, 0x77}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4538}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {1, (char*)&bytesprops5}, .v = {20, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 209}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops0}, .v = {14, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24515}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 168}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7245}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20784}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 69}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops5}}}, }; lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0}; + uint8_t byteswillprops1[] = {0x5f, 0x7, 0x11, 0xdc}; + uint8_t byteswillprops2[] = {0xd5, 0xc3, 0x85, 0x1b, 0x23, 0xde, 0x9f, 0xa8, 0xb9, 0x2c, 0xe8, 0x7f, 0x25, 0xa8, 0x1b, + 0xc8, 0x8, 0x78, 0x5f, 0x86, 0xa2, 0x8e, 0x44, 0xf8, 0x45, 0x8c, 0x49, 0x6c, 0x11}; + uint8_t byteswillprops3[] = {0}; + uint8_t byteswillprops4[] = {0}; + uint8_t byteswillprops5[] = {0xb6, 0xdf, 0x28, 0x40, 0xaa, 0x45, 0xbe, 0xa4, 0xf1, 0x6f, 0xe7, 0x56, + 0x8e, 0x9, 0x19, 0xc3, 0x82, 0xbd, 0xa1, 0xb4, 0xf5, 0xd5, 0x9e, 0x2e}; + uint8_t byteswillprops6[] = {0x9c, 0xe, 0x2f, 0xe7, 0xbb, 0xcf, 0x64, 0x2c, 0x71, 0x1b, 0xc2, 0xfe, 0x63, 0x11, + 0x80, 0x48, 0x95, 0x62, 0x6f, 0xed, 0x24, 0x91, 0x1f, 0x5a, 0xe2, 0xc8, 0x4e}; + uint8_t byteswillprops7[] = {0x52, 0x39, 0x8c, 0xeb, 0xd9, 0x4c, 0xd3, 0xef}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12242}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5768}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13956}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14376}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12032}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23268}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 223}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25802}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24689}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&byteswillprops7}}}, }; - lwmqtt_properties_t willprops = {2, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x13, 0xd6, 0x49, 0x19, 0xe9, 0x42, 0x8}; - lwmqtt_string_t will_topic = {7, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x69, 0x54, 0xd, 0x6f, 0x66, 0x2f, 0xf9, 0x7e, 0x34, 0x5a, - 0x28, 0x3c, 0x5b, 0x69, 0x4e, 0xa8, 0x40, 0x21, 0x67}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xfb, 0x33, 0xf9, 0x2a, 0x3f, 0x30, 0x8, 0xdf, 0x21, 0x2a, 0x96, 0x4d}; + lwmqtt_string_t will_topic = {12, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x62, 0x5a, 0xe}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS1; will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 10052; - uint8_t client_id_bytes[] = {0x5, 0x42, 0xcf, 0x45, 0xbd, 0xc7, 0x46, 0x45, 0xc4, 0xf5, - 0x6, 0x87, 0xc8, 0x4e, 0xa, 0xbb, 0xb1, 0xd1, 0x80, 0xab}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.keep_alive = 5719; + uint8_t client_id_bytes[] = {0xde, 0xa5, 0xfb, 0x52, 0x4b, 0x82, 0x27, 0xea, 0xf2, + 0x2e, 0x2a, 0x4, 0xc8, 0x7e, 0x22, 0x0, 0x4a}; + lwmqtt_string_t client_id = {17, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x1e, 0x54, 0xd2, 0x90, 0xb, 0x52, 0x98, 0xd, 0x90, 0x73, - 0x48, 0x8c, 0x53, 0xd8, 0x58, 0xfc, 0x44, 0xe8, 0x9c}; - lwmqtt_string_t password = {19, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xf2, 0xff, 0xf8, 0x1e, 0x6c, 0x71, 0x79, 0xd2, 0xa5, 0xdf, 0x45, 0x4a, + 0x73, 0xda, 0x8a, 0xc3, 0xfc, 0x7e, 0x4f, 0x53, 0x30, 0x9b, 0x73, 0xb0}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x2b, 0xd9}; + lwmqtt_string_t password = {2, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -11833,165 +11265,178 @@ TEST(Connect5QCTest, Encode13) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "jp\210\SYN<%F\215\168\207J\225\152z\151X\253\132\"", _password = Nothing, _lastWill -// = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = "\181J\251\141\ETX", _willMsg = "|\ETB", -// _willProps = [PropMaximumPacketSize 28427,PropUserProperty "#H'\FS\151\161\162\DC2!\DEL$" -// "\249\225yW\183<\204(\CAN\ESC\253\DC2",PropWildcardSubscriptionAvailable 72,PropSessionExpiryInterval -// 30643,PropMaximumPacketSize 19796,PropMaximumPacketSize 29954,PropReceiveMaximum 12271,PropMaximumQoS -// 96,PropReceiveMaximum 15941,PropRequestResponseInformation 113,PropMaximumQoS 138,PropServerReference -// "\213\133\146\239\133\193N\177\249\133\200\243\158\&7\205\187\215\129\"",PropWildcardSubscriptionAvailable -// 169,PropRequestResponseInformation 145,PropContentType -// "\233\134\&6\163\140#/?\161G\b\SOwA\245\186\169\DLE\194\142c\135\161\193\233s\207{R\255",PropSharedSubscriptionAvailable -// 26,PropAssignedClientIdentifier -// "\ACK\ETB!\218a\ENQH\157\192\244\210\178\203\146\212\225\138\&9d\152\253\220\SO\156}\209\159",PropSharedSubscriptionAvailable -// 67,PropPayloadFormatIndicator 111,PropAuthenticationData "\207\234E!\209[\157 -// \"\130K\182\219\215\224\twg\242\229u\149\r\CAN\215J\137\170\188",PropMessageExpiryInterval 27923]}), _cleanSession = -// True, _keepAlive = 2920, _connID = "\203M+\171|\132nj\193\FS\a\\\DC1\230\202\DC2Id;\200", _properties = -// [PropResponseTopic "\152\r_\209\243\142\DC1\147\195\155i~\221]\130\160\156\ETXq\226",PropServerReference -// "@\164\241\EM\US1\250\SI",PropSubscriptionIdentifierAvailable 109,PropAuthenticationMethod -// "\173\138",PropWillDelayInterval 11874,PropSubscriptionIdentifierAvailable 154,PropSubscriptionIdentifierAvailable -// 219,PropServerKeepAlive 11283,PropMaximumQoS 158,PropReasonString -// "&\232\254\190z\234t\EOT\251G\219\232\160Ed",PropServerReference -// "\n\226\nR!\198\234\227\166\130",PropMessageExpiryInterval 2976,PropMessageExpiryInterval 30462,PropServerReference -// "\232\215\237\161\140\"\208a:\DC4g\174\253\217\172e\179\176\v",PropWildcardSubscriptionAvailable 187,PropMaximumQoS -// 52,PropReceiveMaximum 10715,PropAuthenticationMethod "?\194\132\SI\225\203\189\164\220x\229\183@\DC3\ETX -// \a\DELn\159\190\232S\v",PropTopicAlias 23900,PropMaximumPacketSize 1537,PropAuthenticationData -// "\NUL",PropMessageExpiryInterval 8705,PropMaximumPacketSize 19667,PropMessageExpiryInterval -// 2344,PropRequestResponseInformation 137,PropContentType -// "\195\201\&8\174\144\203\146\136^\DLE:n\USN\199\160\&4\ESC:,v4e\161\ETB",PropTopicAliasMaximum 18306]} -TEST(Connect5QCTest, Encode14) { +// ConnectRequest {_username = Just "\172\146\231\253\222^\247\183l\232!\133;\b\FS\253\ETX\f~[\211\SYN(P", _password = +// Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = +// "[\SO\138\&5\217\\\253\149\212\249s\139\SOH\ENQ\DLEw", _willMsg = +// "\a\252\183\167\137\DC4\248\STX^\DLE\249\242\194\ESC\135\165\&5L\205dn\DC2", _willProps = +// [PropSubscriptionIdentifierAvailable 74,PropWillDelayInterval 14383,PropContentType +// "\167\DC2\162\203/\236\172\248\185\215\&5\EM\208\234N53\DC2-",PropWildcardSubscriptionAvailable +// 138,PropAuthenticationData "\172Z",PropMessageExpiryInterval 17095,PropRequestProblemInformation +// 249,PropResponseInformation "\132&\b\181;\SYN\129\ENQPy\171\222\247b\175\192",PropTopicAliasMaximum +// 18402,PropTopicAlias 12058,PropReasonString "",PropServerReference +// "\144\139E\240\202\201\195\187\221\227\138C\v\196\196\220\134g\201\173i",PropWillDelayInterval +// 9923,PropRetainAvailable 190,PropSubscriptionIdentifierAvailable 210,PropSubscriptionIdentifier 8,PropReasonString +// "\206\145o\212\220\209\216f,o\219\175\189t\238\SO\190\168\253\231\&8\203\170\144",PropUserProperty +// "\EM\173\172\132\222\132o\211\154\a\138$\249\145\SO\226\208\t\220\251" +// "Z\185kd6\189&\210y/@\203\DEL?\182\155\&3\SO\SUB\SUB\192\233g\200\SI3\204\DC2",PropResponseTopic +// "\212\RS@\184\221\240\146\237",PropAuthenticationMethod +// "c\186\133#\148j\tL\149Q\RS\248&\247\f\169\204\DC1\179\173a\243B\234P",PropMessageExpiryInterval 24918]}), +// _cleanSession = False, _keepAlive = 27552, _connID = "e\185\229", _properties = [PropAssignedClientIdentifier +// "FB\131\240y\n\GS\229\235\253\&2",PropMessageExpiryInterval 16517,PropSessionExpiryInterval 5054,PropRetainAvailable +// 156,PropSubscriptionIdentifier 15,PropAuthenticationData "\158o\196Ua",PropMaximumPacketSize +// 25051,PropWillDelayInterval 6996,PropAuthenticationData +// "[\136\GS\DC1\CAN\222^dH/\EM\216\253",PropRequestProblemInformation 237,PropReasonString +// "\175\197X\162\SYN-\234\250X\206\190Z\158\225F\US\172\221A\254\177\&1\159}D\168\213",PropContentType +// ",",PropResponseInformation "\254\163",PropReasonString "\167",PropCorrelationData "4k",PropMaximumPacketSize +// 14000,PropRequestProblemInformation 31,PropSubscriptionIdentifier 17,PropSessionExpiryInterval 1316,PropMaximumQoS +// 15,PropUserProperty "i)\ACK\133\158K\164\236d\213\&1+bmJY\DC1" +// "\EMt[\215rJg\183\SOH\196-\SUBv\154\226\&6{|\247\226",PropTopicAlias 32594,PropSubscriptionIdentifier +// 22,PropTopicAlias 19062,PropMessageExpiryInterval 22830,PropRequestProblemInformation +// 240,PropWildcardSubscriptionAvailable 112,PropCorrelationData ";\v\162R"]} +TEST(Connect5QCTest, Encode15) { uint8_t pkt[] = { - 0x10, 0xda, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0xb, 0x68, 0xd4, 0x1, 0x8, 0x0, 0x14, 0x98, - 0xd, 0x5f, 0xd1, 0xf3, 0x8e, 0x11, 0x93, 0xc3, 0x9b, 0x69, 0x7e, 0xdd, 0x5d, 0x82, 0xa0, 0x9c, 0x3, 0x71, 0xe2, - 0x1c, 0x0, 0x8, 0x40, 0xa4, 0xf1, 0x19, 0x1f, 0x31, 0xfa, 0xf, 0x29, 0x6d, 0x15, 0x0, 0x2, 0xad, 0x8a, 0x18, - 0x0, 0x0, 0x2e, 0x62, 0x29, 0x9a, 0x29, 0xdb, 0x13, 0x2c, 0x13, 0x24, 0x9e, 0x1f, 0x0, 0xf, 0x26, 0xe8, 0xfe, - 0xbe, 0x7a, 0xea, 0x74, 0x4, 0xfb, 0x47, 0xdb, 0xe8, 0xa0, 0x45, 0x64, 0x1c, 0x0, 0xa, 0xa, 0xe2, 0xa, 0x52, - 0x21, 0xc6, 0xea, 0xe3, 0xa6, 0x82, 0x2, 0x0, 0x0, 0xb, 0xa0, 0x2, 0x0, 0x0, 0x76, 0xfe, 0x1c, 0x0, 0x13, - 0xe8, 0xd7, 0xed, 0xa1, 0x8c, 0x22, 0xd0, 0x61, 0x3a, 0x14, 0x67, 0xae, 0xfd, 0xd9, 0xac, 0x65, 0xb3, 0xb0, 0xb, - 0x28, 0xbb, 0x24, 0x34, 0x21, 0x29, 0xdb, 0x15, 0x0, 0x18, 0x3f, 0xc2, 0x84, 0xf, 0xe1, 0xcb, 0xbd, 0xa4, 0xdc, - 0x78, 0xe5, 0xb7, 0x40, 0x13, 0x3, 0x20, 0x7, 0x7f, 0x6e, 0x9f, 0xbe, 0xe8, 0x53, 0xb, 0x23, 0x5d, 0x5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, 0x10, 0xc2, - 0x8e, 0x63, 0x87, 0xa1, 0xc1, 0xe9, 0x73, 0xcf, 0x7b, 0x52, 0xff, 0x2a, 0x1a, 0x12, 0x0, 0x1b, 0x6, 0x17, 0x21, - 0xda, 0x61, 0x5, 0x48, 0x9d, 0xc0, 0xf4, 0xd2, 0xb2, 0xcb, 0x92, 0xd4, 0xe1, 0x8a, 0x39, 0x64, 0x98, 0xfd, 0xdc, - 0xe, 0x9c, 0x7d, 0xd1, 0x9f, 0x2a, 0x43, 0x1, 0x6f, 0x16, 0x0, 0x1d, 0xcf, 0xea, 0x45, 0x21, 0xd1, 0x5b, 0x9d, - 0x20, 0x22, 0x82, 0x4b, 0xb6, 0xdb, 0xd7, 0xe0, 0x9, 0x77, 0x67, 0xf2, 0xe5, 0x75, 0x95, 0xd, 0x18, 0xd7, 0x4a, - 0x89, 0xaa, 0xbc, 0x2, 0x0, 0x0, 0x6d, 0x13, 0x0, 0x5, 0xb5, 0x4a, 0xfb, 0x8d, 0x3, 0x0, 0x2, 0x7c, 0x17, - 0x0, 0x13, 0x6a, 0x70, 0xd2, 0x16, 0x3c, 0x25, 0x46, 0xd7, 0xa8, 0xcf, 0x4a, 0xe1, 0x98, 0x7a, 0x97, 0x58, 0xfd, - 0x84, 0x22}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x98, 0xd, 0x5f, 0xd1, 0xf3, 0x8e, 0x11, 0x93, 0xc3, 0x9b, - 0x69, 0x7e, 0xdd, 0x5d, 0x82, 0xa0, 0x9c, 0x3, 0x71, 0xe2}; - uint8_t bytesprops1[] = {0x40, 0xa4, 0xf1, 0x19, 0x1f, 0x31, 0xfa, 0xf}; - uint8_t bytesprops2[] = {0xad, 0x8a}; - uint8_t bytesprops3[] = {0x26, 0xe8, 0xfe, 0xbe, 0x7a, 0xea, 0x74, 0x4, 0xfb, 0x47, 0xdb, 0xe8, 0xa0, 0x45, 0x64}; - uint8_t bytesprops4[] = {0xa, 0xe2, 0xa, 0x52, 0x21, 0xc6, 0xea, 0xe3, 0xa6, 0x82}; - uint8_t bytesprops5[] = {0xe8, 0xd7, 0xed, 0xa1, 0x8c, 0x22, 0xd0, 0x61, 0x3a, 0x14, - 0x67, 0xae, 0xfd, 0xd9, 0xac, 0x65, 0xb3, 0xb0, 0xb}; - uint8_t bytesprops6[] = {0x3f, 0xc2, 0x84, 0xf, 0xe1, 0xcb, 0xbd, 0xa4, 0xdc, 0x78, 0xe5, 0xb7, - 0x40, 0x13, 0x3, 0x20, 0x7, 0x7f, 0x6e, 0x9f, 0xbe, 0xe8, 0x53, 0xb}; - uint8_t bytesprops7[] = {0x0}; - uint8_t bytesprops8[] = {0xc3, 0xc9, 0x38, 0xae, 0x90, 0xcb, 0x92, 0x88, 0x5e, 0x10, 0x3a, 0x6e, 0x1f, - 0x4e, 0xc7, 0xa0, 0x34, 0x1b, 0x3a, 0x2c, 0x76, 0x34, 0x65, 0xa1, 0x17}; + 0x10, 0xff, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xa4, 0x6b, 0xa0, 0xc2, 0x1, 0x12, 0x0, 0xb, 0x46, + 0x42, 0x83, 0xf0, 0x79, 0xa, 0x1d, 0xe5, 0xeb, 0xfd, 0x32, 0x2, 0x0, 0x0, 0x40, 0x85, 0x11, 0x0, 0x0, 0x13, + 0xbe, 0x25, 0x9c, 0xb, 0xf, 0x16, 0x0, 0x5, 0x9e, 0x6f, 0xc4, 0x55, 0x61, 0x27, 0x0, 0x0, 0x61, 0xdb, 0x18, + 0x0, 0x0, 0x1b, 0x54, 0x16, 0x0, 0xd, 0x5b, 0x88, 0x1d, 0x11, 0x18, 0xde, 0x5e, 0x64, 0x48, 0x2f, 0x19, 0xd8, + 0xfd, 0x17, 0xed, 0x1f, 0x0, 0x1b, 0xaf, 0xc5, 0x58, 0xa2, 0x16, 0x2d, 0xea, 0xfa, 0x58, 0xce, 0xbe, 0x5a, 0x9e, + 0xe1, 0x46, 0x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 0xf8, 0x2, 0x5e, + 0x10, 0xf9, 0xf2, 0xc2, 0x1b, 0x87, 0xa5, 0x35, 0x4c, 0xcd, 0x64, 0x6e, 0x12, 0x0, 0x18, 0xac, 0x92, 0xe7, 0xfd, + 0xde, 0x5e, 0xf7, 0xb7, 0x6c, 0xe8, 0x21, 0x85, 0x3b, 0x8, 0x1c, 0xfd, 0x3, 0xc, 0x7e, 0x5b, 0xd3, 0x16, 0x28, + 0x50}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x46, 0x42, 0x83, 0xf0, 0x79, 0xa, 0x1d, 0xe5, 0xeb, 0xfd, 0x32}; + uint8_t bytesprops1[] = {0x9e, 0x6f, 0xc4, 0x55, 0x61}; + uint8_t bytesprops2[] = {0x5b, 0x88, 0x1d, 0x11, 0x18, 0xde, 0x5e, 0x64, 0x48, 0x2f, 0x19, 0xd8, 0xfd}; + uint8_t bytesprops3[] = {0xaf, 0xc5, 0x58, 0xa2, 0x16, 0x2d, 0xea, 0xfa, 0x58, 0xce, 0xbe, 0x5a, 0x9e, 0xe1, + 0x46, 0x1f, 0xac, 0xdd, 0x41, 0xfe, 0xb1, 0x31, 0x9f, 0x7d, 0x44, 0xa8, 0xd5}; + uint8_t bytesprops4[] = {0x2c}; + uint8_t bytesprops5[] = {0xfe, 0xa3}; + uint8_t bytesprops6[] = {0xa7}; + uint8_t bytesprops7[] = {0x34, 0x6b}; + uint8_t bytesprops9[] = {0x19, 0x74, 0x5b, 0xd7, 0x72, 0x4a, 0x67, 0xb7, 0x1, 0xc4, + 0x2d, 0x1a, 0x76, 0x9a, 0xe2, 0x36, 0x7b, 0x7c, 0xf7, 0xe2}; + uint8_t bytesprops8[] = {0x69, 0x29, 0x6, 0x85, 0x9e, 0x4b, 0xa4, 0xec, 0x64, + 0xd5, 0x31, 0x2b, 0x62, 0x6d, 0x4a, 0x59, 0x11}; + uint8_t bytesprops10[] = {0x3b, 0xb, 0xa2, 0x52}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {20, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11874}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11283}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2976}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30462}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10715}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23900}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1537}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8705}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19667}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2344}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18306}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16517}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5054}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25051}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6996}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 237}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14000}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1316}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops8}, .v = {20, (char*)&bytesprops9}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32594}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 19062}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22830}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 112}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops10}}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0xf9, 0xe1, 0x79, 0x57, 0xb7, 0x3c, 0xcc, 0x28, 0x18, 0x1b, 0xfd, 0x12}; - uint8_t byteswillprops0[] = {0x23, 0x48, 0x27, 0x1c, 0x97, 0xa1, 0xa2, 0x12, 0x21, 0x7f, 0x24}; - uint8_t byteswillprops2[] = {0xd5, 0x85, 0x92, 0xef, 0x85, 0xc1, 0x4e, 0xb1, 0xf9, 0x85, - 0xc8, 0xf3, 0x9e, 0x37, 0xcd, 0xbb, 0xd7, 0x81, 0x22}; - uint8_t byteswillprops3[] = {0xe9, 0x86, 0x36, 0xa3, 0x8c, 0x23, 0x2f, 0x3f, 0xa1, 0x47, - 0x8, 0xe, 0x77, 0x41, 0xf5, 0xba, 0xa9, 0x10, 0xc2, 0x8e, - 0x63, 0x87, 0xa1, 0xc1, 0xe9, 0x73, 0xcf, 0x7b, 0x52, 0xff}; - uint8_t byteswillprops4[] = {0x6, 0x17, 0x21, 0xda, 0x61, 0x5, 0x48, 0x9d, 0xc0, 0xf4, 0xd2, 0xb2, 0xcb, 0x92, - 0xd4, 0xe1, 0x8a, 0x39, 0x64, 0x98, 0xfd, 0xdc, 0xe, 0x9c, 0x7d, 0xd1, 0x9f}; - uint8_t byteswillprops5[] = {0xcf, 0xea, 0x45, 0x21, 0xd1, 0x5b, 0x9d, 0x20, 0x22, 0x82, 0x4b, 0xb6, 0xdb, 0xd7, 0xe0, - 0x9, 0x77, 0x67, 0xf2, 0xe5, 0x75, 0x95, 0xd, 0x18, 0xd7, 0x4a, 0x89, 0xaa, 0xbc}; + uint8_t byteswillprops0[] = {0xa7, 0x12, 0xa2, 0xcb, 0x2f, 0xec, 0xac, 0xf8, 0xb9, 0xd7, + 0x35, 0x19, 0xd0, 0xea, 0x4e, 0x35, 0x33, 0x12, 0x2d}; + uint8_t byteswillprops1[] = {0xac, 0x5a}; + uint8_t byteswillprops2[] = {0x84, 0x26, 0x8, 0xb5, 0x3b, 0x16, 0x81, 0x5, + 0x50, 0x79, 0xab, 0xde, 0xf7, 0x62, 0xaf, 0xc0}; + uint8_t byteswillprops3[] = {0}; + uint8_t byteswillprops4[] = {0x90, 0x8b, 0x45, 0xf0, 0xca, 0xc9, 0xc3, 0xbb, 0xdd, 0xe3, 0x8a, + 0x43, 0xb, 0xc4, 0xc4, 0xdc, 0x86, 0x67, 0xc9, 0xad, 0x69}; + uint8_t byteswillprops5[] = {0xce, 0x91, 0x6f, 0xd4, 0xdc, 0xd1, 0xd8, 0x66, 0x2c, 0x6f, 0xdb, 0xaf, + 0xbd, 0x74, 0xee, 0xe, 0xbe, 0xa8, 0xfd, 0xe7, 0x38, 0xcb, 0xaa, 0x90}; + uint8_t byteswillprops7[] = {0x5a, 0xb9, 0x6b, 0x64, 0x36, 0xbd, 0x26, 0xd2, 0x79, 0x2f, 0x40, 0xcb, 0x7f, 0x3f, + 0xb6, 0x9b, 0x33, 0xe, 0x1a, 0x1a, 0xc0, 0xe9, 0x67, 0xc8, 0xf, 0x33, 0xcc, 0x12}; + uint8_t byteswillprops6[] = {0x19, 0xad, 0xac, 0x84, 0xde, 0x84, 0x6f, 0xd3, 0x9a, 0x7, + 0x8a, 0x24, 0xf9, 0x91, 0xe, 0xe2, 0xd0, 0x9, 0xdc, 0xfb}; + uint8_t byteswillprops8[] = {0xd4, 0x1e, 0x40, 0xb8, 0xdd, 0xf0, 0x92, 0xed}; + uint8_t byteswillprops9[] = {0x63, 0xba, 0x85, 0x23, 0x94, 0x6a, 0x9, 0x4c, 0x95, 0x51, 0x1e, 0xf8, 0x26, + 0xf7, 0xc, 0xa9, 0xcc, 0x11, 0xb3, 0xad, 0x61, 0xf3, 0x42, 0xea, 0x50}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28427}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 74}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14383}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17095}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18402}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12058}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9923}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 210}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops5}}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {11, (char*)&byteswillprops0}, .v = {12, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30643}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19796}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29954}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12271}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15941}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27923}}, + .value = {.pair = {.k = {20, (char*)&byteswillprops6}, .v = {28, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24918}}, }; lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb5, 0x4a, 0xfb, 0x8d, 0x3}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x7c, 0x17}; - lwmqtt_string_t will_payload = {2, (char*)&will_payload_bytes}; + uint8_t will_topic_bytes[] = {0x5b, 0xe, 0x8a, 0x35, 0xd9, 0x5c, 0xfd, 0x95, + 0xd4, 0xf9, 0x73, 0x8b, 0x1, 0x5, 0x10, 0x77}; + lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x7, 0xfc, 0xb7, 0xa7, 0x89, 0x14, 0xf8, 0x2, 0x5e, 0x10, 0xf9, + 0xf2, 0xc2, 0x1b, 0x87, 0xa5, 0x35, 0x4c, 0xcd, 0x64, 0x6e, 0x12}; + lwmqtt_string_t will_payload = {22, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 2920; - uint8_t client_id_bytes[] = {0xcb, 0x4d, 0x2b, 0xab, 0x7c, 0x84, 0x6e, 0x6a, 0xc1, 0x1c, - 0x7, 0x5c, 0x11, 0xe6, 0xca, 0x12, 0x49, 0x64, 0x3b, 0xc8}; - lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 27552; + uint8_t client_id_bytes[] = {0x65, 0xb9, 0xe5}; + lwmqtt_string_t client_id = {3, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x6a, 0x70, 0xd2, 0x16, 0x3c, 0x25, 0x46, 0xd7, 0xa8, 0xcf, - 0x4a, 0xe1, 0x98, 0x7a, 0x97, 0x58, 0xfd, 0x84, 0x22}; - lwmqtt_string_t username = {19, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xac, 0x92, 0xe7, 0xfd, 0xde, 0x5e, 0xf7, 0xb7, 0x6c, 0xe8, 0x21, 0x85, + 0x3b, 0x8, 0x1c, 0xfd, 0x3, 0xc, 0x7e, 0x5b, 0xd3, 0x16, 0x28, 0x50}; + lwmqtt_string_t username = {24, (char*)&username_bytes}; opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -12001,328 +11446,219 @@ TEST(Connect5QCTest, Encode14) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\192\STX\129_\195-\215\163\200JG\249<", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS2, _willTopic = -// "\152e\130\v\SOH\ACK\224\EOT\165\199(&g\SO\ACK\211\169\&1\DC3\243\199\ETB\221\138+", _willMsg = -// "H\197\&7\SOH\253\237", _willProps = [PropTopicAlias 18478,PropMessageExpiryInterval 9048,PropUserProperty -// "\CAN\246G" "d\187\128B\136\196",PropWillDelayInterval 13590,PropSubscriptionIdentifierAvailable 146]}), -// _cleanSession = True, _keepAlive = 2714, _connID = "\243Q\STX\222\243oB\DC4\136\201n\GS\146", _properties = -// [PropMessageExpiryInterval 5905,PropWildcardSubscriptionAvailable 81,PropMaximumQoS 39,PropUserProperty -// "_\183o\SOS\ETX\255(\DC4\r3N\159\&5\171\219\210\151\173\215\r0\229\151\132}\187\149;" -// "l\247ax\228\155\195$\EOT\DC3",PropAuthenticationMethod -// "\236\DC1\176;\NAK\NAK\160",PropSubscriptionIdentifierAvailable 215,PropServerKeepAlive 4430,PropResponseInformation -// "\232\182Nh\211\&3\CAN\212\148\220\157\&4\212wR\251Rw>\vJ\v\221",PropMessageExpiryInterval 9422,PropTopicAliasMaximum -// 10403,PropRetainAvailable 248,PropRetainAvailable 204,PropReasonString -// "\242gK\218`&\129\170p`\248c\NAKXC\177\"\b\228g\238\205,\168",PropTopicAliasMaximum 22359,PropReasonString -// "\200\226\191\167K\ACK\206\154\214D(\US\250\231\&7\218\158Q\242\"U\239\STX",PropTopicAlias -// 30940,PropAssignedClientIdentifier "\204r1\fp\SO\NUL`.\166\221e\234Z",PropWildcardSubscriptionAvailable -// 231,PropPayloadFormatIndicator 67,PropSubscriptionIdentifier 26,PropServerReference "N\234\b\175 -// \150&\194Z\va!!\149*\"\143{U\231",PropServerKeepAlive 12428,PropAssignedClientIdentifier -// "\FS\142\245\147\169DU\ETB\242[\245\198\186\132\158\135\164q\173[\210\129\189\165A\\2",PropServerReference -// ">\RS\249\190\132\158\248\192\180\206\131u\168=\SYN\FS!\DELZ\221|\136K\179\162\196\SOH\226e[",PropResponseInformation -// "(\187\187\198\&3\ESC\189r~\DLE\143\204h<",PropAssignedClientIdentifier -// "\248\189\155S6}\128w\160\181\ETB2g]\154\133m/\163\160\ESCW\DC2\181",PropMessageExpiryInterval -// 7073,PropServerReference "\216=\207\233\242R]",PropReceiveMaximum 8978]} -TEST(Connect5QCTest, Encode15) { - uint8_t pkt[] = { - 0x10, 0xbe, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0xa, 0x9a, 0xd3, 0x2, 0x2, 0x0, 0x0, 0x17, - 0x11, 0x28, 0x51, 0x24, 0x27, 0x26, 0x0, 0x1d, 0x5f, 0xb7, 0x6f, 0xe, 0x53, 0x3, 0xff, 0x28, 0x14, 0xd, 0x33, - 0x4e, 0x9f, 0x35, 0xab, 0xdb, 0xd2, 0x97, 0xad, 0xd7, 0xd, 0x30, 0xe5, 0x97, 0x84, 0x7d, 0xbb, 0x95, 0x3b, 0x0, - 0xa, 0x6c, 0xf7, 0x61, 0x78, 0xe4, 0x9b, 0xc3, 0x24, 0x4, 0x13, 0x15, 0x0, 0x7, 0xec, 0x11, 0xb0, 0x3b, 0x15, - 0x15, 0xa0, 0x29, 0xd7, 0x13, 0x11, 0x4e, 0x1a, 0x0, 0x17, 0xe8, 0xb6, 0x4e, 0x68, 0xd3, 0x33, 0x18, 0xd4, 0x94, - 0xdc, 0x9d, 0x34, 0xd4, 0x77, 0x52, 0xfb, 0x52, 0x77, 0x3e, 0xb, 0x4a, 0xb, 0xdd, 0x2, 0x0, 0x0, 0x24, 0xce, - 0x22, 0x28, 0xa3, 0x25, 0xf8, 0x25, 0xcc, 0x1f, 0x0, 0x18, 0xf2, 0x67, 0x4b, 0xda, 0x60, 0x26, 0x81, 0xaa, 0x70, - 0x60, 0xf8, 0x63,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 0xb5, 0x17, - 0x32, 0x67, 0x5d, 0x9a, 0x85, 0x6d, 0x2f, 0xa3, 0xa0, 0x1b, 0x57, 0x12, 0xb5, 0x2, 0x0, 0x0, 0x1b, 0xa1, 0x1c, - 0x0, 0x7, 0xd8, 0x3d, 0xcf, 0xe9, 0xf2, 0x52, 0x5d, 0x21, 0x23, 0x12, 0x0, 0xd, 0xf3, 0x51, 0x2, 0xde, 0xf3, - 0x6f, 0x42, 0x14, 0x88, 0xc9, 0x6e, 0x1d, 0x92, 0x1d, 0x23, 0x48, 0x2e, 0x2, 0x0, 0x0, 0x23, 0x58, 0x26, 0x0, - 0x3, 0x18, 0xf6, 0x47, 0x0, 0x6, 0x64, 0xbb, 0x80, 0x42, 0x88, 0xc4, 0x18, 0x0, 0x0, 0x35, 0x16, 0x29, 0x92, - 0x0, 0x19, 0x98, 0x65, 0x82, 0xb, 0x1, 0x6, 0xe0, 0x4, 0xa5, 0xc7, 0x28, 0x26, 0x67, 0xe, 0x6, 0xd3, 0xa9, - 0x31, 0x13, 0xf3, 0xc7, 0x17, 0xdd, 0x8a, 0x2b, 0x0, 0x6, 0x48, 0xc5, 0x37, 0x1, 0xfd, 0xed, 0x0, 0xd, 0xc0, - 0x2, 0x81, 0x5f, 0xc3, 0x2d, 0xd7, 0xa3, 0xc8, 0x4a, 0x47, 0xf9, 0x3c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x6c, 0xf7, 0x61, 0x78, 0xe4, 0x9b, 0xc3, 0x24, 0x4, 0x13}; - uint8_t bytesprops0[] = {0x5f, 0xb7, 0x6f, 0xe, 0x53, 0x3, 0xff, 0x28, 0x14, 0xd, 0x33, 0x4e, 0x9f, 0x35, 0xab, - 0xdb, 0xd2, 0x97, 0xad, 0xd7, 0xd, 0x30, 0xe5, 0x97, 0x84, 0x7d, 0xbb, 0x95, 0x3b}; - uint8_t bytesprops2[] = {0xec, 0x11, 0xb0, 0x3b, 0x15, 0x15, 0xa0}; - uint8_t bytesprops3[] = {0xe8, 0xb6, 0x4e, 0x68, 0xd3, 0x33, 0x18, 0xd4, 0x94, 0xdc, 0x9d, 0x34, - 0xd4, 0x77, 0x52, 0xfb, 0x52, 0x77, 0x3e, 0xb, 0x4a, 0xb, 0xdd}; - uint8_t bytesprops4[] = {0xf2, 0x67, 0x4b, 0xda, 0x60, 0x26, 0x81, 0xaa, 0x70, 0x60, 0xf8, 0x63, - 0x15, 0x58, 0x43, 0xb1, 0x22, 0x8, 0xe4, 0x67, 0xee, 0xcd, 0x2c, 0xa8}; - uint8_t bytesprops5[] = {0xc8, 0xe2, 0xbf, 0xa7, 0x4b, 0x6, 0xce, 0x9a, 0xd6, 0x44, 0x28, 0x1f, - 0xfa, 0xe7, 0x37, 0xda, 0x9e, 0x51, 0xf2, 0x22, 0x55, 0xef, 0x2}; - uint8_t bytesprops6[] = {0xcc, 0x72, 0x31, 0xc, 0x70, 0xe, 0x0, 0x60, 0x2e, 0xa6, 0xdd, 0x65, 0xea, 0x5a}; - uint8_t bytesprops7[] = {0x4e, 0xea, 0x8, 0xaf, 0x20, 0x96, 0x26, 0xc2, 0x5a, 0xb, - 0x61, 0x21, 0x21, 0x95, 0x2a, 0x22, 0x8f, 0x7b, 0x55, 0xe7}; - uint8_t bytesprops8[] = {0x1c, 0x8e, 0xf5, 0x93, 0xa9, 0x44, 0x55, 0x17, 0xf2, 0x5b, 0xf5, 0xc6, 0xba, 0x84, - 0x9e, 0x87, 0xa4, 0x71, 0xad, 0x5b, 0xd2, 0x81, 0xbd, 0xa5, 0x41, 0x5c, 0x32}; - uint8_t bytesprops9[] = {0x3e, 0x1e, 0xf9, 0xbe, 0x84, 0x9e, 0xf8, 0xc0, 0xb4, 0xce, 0x83, 0x75, 0xa8, 0x3d, 0x16, - 0x1c, 0x21, 0x7f, 0x5a, 0xdd, 0x7c, 0x88, 0x4b, 0xb3, 0xa2, 0xc4, 0x1, 0xe2, 0x65, 0x5b}; - uint8_t bytesprops10[] = {0x28, 0xbb, 0xbb, 0xc6, 0x33, 0x1b, 0xbd, 0x72, 0x7e, 0x10, 0x8f, 0xcc, 0x68, 0x3c}; - uint8_t bytesprops11[] = {0xf8, 0xbd, 0x9b, 0x53, 0x36, 0x7d, 0x80, 0x77, 0xa0, 0xb5, 0x17, 0x32, - 0x67, 0x5d, 0x9a, 0x85, 0x6d, 0x2f, 0xa3, 0xa0, 0x1b, 0x57, 0x12, 0xb5}; - uint8_t bytesprops12[] = {0xd8, 0x3d, 0xcf, 0xe9, 0xf2, 0x52, 0x5d}; +// ConnectRequest {_username = Just "\208\186;\142\229\ENQ\DC3", _password = Just "k\STX\218\181\207){\"\180\DLE", +// _lastWill = Nothing, _cleanSession = False, _keepAlive = 28695, _connID = +// "\166'RW'\131!\222\228%N\243\227\158\253sF\r\211L", _properties = [PropReasonString +// "@\225\239\135\243j\244\208Ql\231\DC4\164\135h\245\241\ESC\DLE\r\231\&3",PropTopicAliasMaximum +// 24530,PropSubscriptionIdentifier 7,PropMaximumQoS 8,PropTopicAliasMaximum 7012,PropUserProperty +// "(\EOT\RSX~\228n\205\215\253" +// "6.\171.\209\168\237\219\203\174\200\201{\142\241-<\ETX\194\SOHsN\223\170",PropMessageExpiryInterval +// 13666,PropTopicAliasMaximum 806,PropPayloadFormatIndicator 137,PropResponseInformation "\168"]} +TEST(Connect5QCTest, Encode16) { + uint8_t pkt[] = {0x10, 0x8e, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x70, 0x17, 0x58, 0x1f, 0x0, 0x16, + 0x40, 0xe1, 0xef, 0x87, 0xf3, 0x6a, 0xf4, 0xd0, 0x51, 0x6c, 0xe7, 0x14, 0xa4, 0x87, 0x68, 0xf5, 0xf1, + 0x1b, 0x10, 0xd, 0xe7, 0x33, 0x22, 0x5f, 0xd2, 0xb, 0x7, 0x24, 0x8, 0x22, 0x1b, 0x64, 0x26, 0x0, + 0xa, 0x28, 0x4, 0x1e, 0x58, 0x7e, 0xe4, 0x6e, 0xcd, 0xd7, 0xfd, 0x0, 0x18, 0x36, 0x2e, 0xab, 0x2e, + 0xd1, 0xa8, 0xed, 0xdb, 0xcb, 0xae, 0xc8, 0xc9, 0x7b, 0x8e, 0xf1, 0x2d, 0x3c, 0x3, 0xc2, 0x1, 0x73, + 0x4e, 0xdf, 0xaa, 0x2, 0x0, 0x0, 0x35, 0x62, 0x22, 0x3, 0x26, 0x1, 0x89, 0x1a, 0x0, 0x1, 0xa8, + 0x0, 0x14, 0xa6, 0x27, 0x52, 0x57, 0x27, 0x83, 0x21, 0xde, 0xe4, 0x25, 0x4e, 0xf3, 0xe3, 0x9e, 0xfd, + 0x73, 0x46, 0xd, 0xd3, 0x4c, 0x0, 0x7, 0xd0, 0xba, 0x3b, 0x8e, 0xe5, 0x5, 0x13, 0x0, 0xa, 0x6b, + 0x2, 0xda, 0xb5, 0xcf, 0x29, 0x7b, 0x22, 0xb4, 0x10}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x40, 0xe1, 0xef, 0x87, 0xf3, 0x6a, 0xf4, 0xd0, 0x51, 0x6c, 0xe7, + 0x14, 0xa4, 0x87, 0x68, 0xf5, 0xf1, 0x1b, 0x10, 0xd, 0xe7, 0x33}; + uint8_t bytesprops2[] = {0x36, 0x2e, 0xab, 0x2e, 0xd1, 0xa8, 0xed, 0xdb, 0xcb, 0xae, 0xc8, 0xc9, + 0x7b, 0x8e, 0xf1, 0x2d, 0x3c, 0x3, 0xc2, 0x1, 0x73, 0x4e, 0xdf, 0xaa}; + uint8_t bytesprops1[] = {0x28, 0x4, 0x1e, 0x58, 0x7e, 0xe4, 0x6e, 0xcd, 0xd7, 0xfd}; + uint8_t bytesprops3[] = {0xa8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5905}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops0}, .v = {10, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 215}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4430}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9422}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10403}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22359}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30940}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 231}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12428}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7073}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 8978}}, - }; - - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops1[] = {0x64, 0xbb, 0x80, 0x42, 0x88, 0xc4}; - uint8_t byteswillprops0[] = {0x18, 0xf6, 0x47}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18478}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9048}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {3, (char*)&byteswillprops0}, .v = {6, (char*)&byteswillprops1}}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13590}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {22, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24530}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7012}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {10, (char*)&bytesprops1}, .v = {24, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13666}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 806}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 137}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x98, 0x65, 0x82, 0xb, 0x1, 0x6, 0xe0, 0x4, 0xa5, 0xc7, 0x28, 0x26, 0x67, - 0xe, 0x6, 0xd3, 0xa9, 0x31, 0x13, 0xf3, 0xc7, 0x17, 0xdd, 0x8a, 0x2b}; - lwmqtt_string_t will_topic = {25, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x48, 0xc5, 0x37, 0x1, 0xfd, 0xed}; - lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 2714; - uint8_t client_id_bytes[] = {0xf3, 0x51, 0x2, 0xde, 0xf3, 0x6f, 0x42, 0x14, 0x88, 0xc9, 0x6e, 0x1d, 0x92}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 28695; + uint8_t client_id_bytes[] = {0xa6, 0x27, 0x52, 0x57, 0x27, 0x83, 0x21, 0xde, 0xe4, 0x25, + 0x4e, 0xf3, 0xe3, 0x9e, 0xfd, 0x73, 0x46, 0xd, 0xd3, 0x4c}; + lwmqtt_string_t client_id = {20, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0xc0, 0x2, 0x81, 0x5f, 0xc3, 0x2d, 0xd7, 0xa3, 0xc8, 0x4a, 0x47, 0xf9, 0x3c}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xd0, 0xba, 0x3b, 0x8e, 0xe5, 0x5, 0x13}; + lwmqtt_string_t username = {7, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x6b, 0x2, 0xda, 0xb5, 0xcf, 0x29, 0x7b, 0x22, 0xb4, 0x10}; + lwmqtt_string_t password = {10, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Nothing, _cleanSession = True, _keepAlive = -// 26866, _connID = "^\239\188\197\142\229[\ESC\211E\188\233\195", _properties = [PropPayloadFormatIndicator -// 176,PropAuthenticationData -// "\158\211w\167\182<\128#\237:{\130\139\247\220\179z\137\NAK&\190\236\ENQ>\210l8\141\241",PropAssignedClientIdentifier -// "IY=\r\180\164\181%{",PropWildcardSubscriptionAvailable 192,PropCorrelationData -// "G\210\STX\231\151h\ENQH\166\RS\254\207y",PropMaximumQoS 165,PropSessionExpiryInterval 9460,PropResponseInformation -// "\238\168f\154\218RA\188\179oo\140\155\DC2d?$p1U\149\230\169\240\DLE\161\188\SOH\176\165",PropReasonString -// "\t!",PropMaximumPacketSize 28298,PropContentType " -// \209\174\146\178\214\141\160n&\DLE\b\154U\234\&9\rn\SI=\158\151\252",PropRequestProblemInformation -// 244,PropRequestProblemInformation 196,PropMessageExpiryInterval 31638,PropPayloadFormatIndicator -// 143,PropSubscriptionIdentifier 26,PropCorrelationData "[\200\152r\ETX"]} -TEST(Connect5QCTest, Encode16) { - uint8_t pkt[] = {0x10, 0xbc, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2, 0x68, 0xf2, 0xa1, 0x1, 0x1, - 0xb0, 0x16, 0x0, 0x1d, 0x9e, 0xd3, 0x77, 0xa7, 0xb6, 0x3c, 0x80, 0x23, 0xed, 0x3a, 0x7b, 0x82, - 0x8b, 0xf7, 0xdc, 0xb3, 0x7a, 0x89, 0x15, 0x26, 0xbe, 0xec, 0x5, 0x3e, 0xd2, 0x6c, 0x38, 0x8d, - 0xf1, 0x12, 0x0, 0x9, 0x49, 0x59, 0x3d, 0xd, 0xb4, 0xa4, 0xb5, 0x25, 0x7b, 0x28, 0xc0, 0x9, - 0x0, 0xd, 0x47, 0xd2, 0x2, 0xe7, 0x97, 0x68, 0x5, 0x48, 0xa6, 0x1e, 0xfe, 0xcf, 0x79, 0x24, - 0xa5, 0x11, 0x0, 0x0, 0x24, 0xf4, 0x1a, 0x0, 0x1e, 0xee, 0xa8, 0x66, 0x9a, 0xda, 0x52, 0x41, - 0xbc, 0xb3, 0x6f, 0x6f, 0x8c, 0x9b, 0x12, 0x64, 0x3f, 0x24, 0x70, 0x31, 0x55, 0x95, 0xe6, 0xa9, - 0xf0, 0x10, 0xa1, 0xbc, 0x1, 0xb0, 0xa5, 0x1f, 0x0, 0x2, 0x9, 0x21, 0x27, 0x0, 0x0, 0x6e, - 0x8a, 0x3, 0x0, 0x17, 0x20, 0xd1, 0xae, 0x92, 0xb2, 0xd6, 0x8d, 0xa0, 0x6e, 0x26, 0x10, 0x8, - 0x9a, 0x55, 0xea, 0x39, 0xd, 0x6e, 0xf, 0x3d, 0x9e, 0x97, 0xfc, 0x17, 0xf4, 0x17, 0xc4, 0x2, - 0x0, 0x0, 0x7b, 0x96, 0x1, 0x8f, 0xb, 0x1a, 0x9, 0x0, 0x5, 0x5b, 0xc8, 0x98, 0x72, 0x3, - 0x0, 0xd, 0x5e, 0xef, 0xbc, 0xc5, 0x8e, 0xe5, 0x5b, 0x1b, 0xd3, 0x45, 0xbc, 0xe9, 0xc3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x9e, 0xd3, 0x77, 0xa7, 0xb6, 0x3c, 0x80, 0x23, 0xed, 0x3a, 0x7b, 0x82, 0x8b, 0xf7, 0xdc, - 0xb3, 0x7a, 0x89, 0x15, 0x26, 0xbe, 0xec, 0x5, 0x3e, 0xd2, 0x6c, 0x38, 0x8d, 0xf1}; - uint8_t bytesprops1[] = {0x49, 0x59, 0x3d, 0xd, 0xb4, 0xa4, 0xb5, 0x25, 0x7b}; - uint8_t bytesprops2[] = {0x47, 0xd2, 0x2, 0xe7, 0x97, 0x68, 0x5, 0x48, 0xa6, 0x1e, 0xfe, 0xcf, 0x79}; - uint8_t bytesprops3[] = {0xee, 0xa8, 0x66, 0x9a, 0xda, 0x52, 0x41, 0xbc, 0xb3, 0x6f, 0x6f, 0x8c, 0x9b, 0x12, 0x64, - 0x3f, 0x24, 0x70, 0x31, 0x55, 0x95, 0xe6, 0xa9, 0xf0, 0x10, 0xa1, 0xbc, 0x1, 0xb0, 0xa5}; - uint8_t bytesprops4[] = {0x9, 0x21}; - uint8_t bytesprops5[] = {0x20, 0xd1, 0xae, 0x92, 0xb2, 0xd6, 0x8d, 0xa0, 0x6e, 0x26, 0x10, 0x8, - 0x9a, 0x55, 0xea, 0x39, 0xd, 0x6e, 0xf, 0x3d, 0x9e, 0x97, 0xfc}; - uint8_t bytesprops6[] = {0x5b, 0xc8, 0x98, 0x72, 0x3}; +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS1, _willTopic = "\226g", _willMsg = "\148\r}\DEL1ZJ\210\CAN\RS\158C~\249\215\205\219\158\211'4\223\ESC", +// _willProps = [PropSharedSubscriptionAvailable 93,PropContentType +// "\DLE\135\211u\187\229\131:\243\144\DC4f8\238\&1\213\247\SO",PropRequestResponseInformation 15,PropTopicAliasMaximum +// 29638,PropSharedSubscriptionAvailable 206]}), _cleanSession = False, _keepAlive = 10322, _connID = +// "\146\226x\204\ESC:q5\ENQ|,`\206", _properties = [PropMaximumPacketSize 3645,PropReasonString +// "LI\224\ENQ\250\DEL\168/\SYN\246<\246\160E \254",PropAuthenticationMethod +// "\174orF\219\&9we7M\202Z\\\214\175Z",PropSubscriptionIdentifierAvailable 179,PropPayloadFormatIndicator +// 7,PropWillDelayInterval 251,PropAuthenticationData "\181N\201\RS\159\US\241\&3r"]} +TEST(Connect5QCTest, Encode17) { + uint8_t pkt[] = {0x10, 0x96, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x2c, 0x28, 0x52, 0x40, 0x27, 0x0, + 0x0, 0xe, 0x3d, 0x1f, 0x0, 0x10, 0x4c, 0x49, 0xe0, 0x5, 0xfa, 0x7f, 0xa8, 0x2f, 0x16, 0xf6, + 0x3c, 0xf6, 0xa0, 0x45, 0x20, 0xfe, 0x15, 0x0, 0x10, 0xae, 0x6f, 0x72, 0x46, 0xdb, 0x39, 0x77, + 0x65, 0x37, 0x4d, 0xca, 0x5a, 0x5c, 0xd6, 0xaf, 0x5a, 0x29, 0xb3, 0x1, 0x7, 0x18, 0x0, 0x0, + 0x0, 0xfb, 0x16, 0x0, 0x9, 0xb5, 0x4e, 0xc9, 0x1e, 0x9f, 0x1f, 0xf1, 0x33, 0x72, 0x0, 0xd, + 0x92, 0xe2, 0x78, 0xcc, 0x1b, 0x3a, 0x71, 0x35, 0x5, 0x7c, 0x2c, 0x60, 0xce, 0x1e, 0x2a, 0x5d, + 0x3, 0x0, 0x12, 0x10, 0x87, 0xd3, 0x75, 0xbb, 0xe5, 0x83, 0x3a, 0xf3, 0x90, 0x14, 0x66, 0x38, + 0xee, 0x31, 0xd5, 0xf7, 0xe, 0x19, 0xf, 0x22, 0x73, 0xc6, 0x2a, 0xce, 0x0, 0x2, 0xe2, 0x67, + 0x0, 0x17, 0x94, 0xd, 0x7d, 0x7f, 0x31, 0x5a, 0x4a, 0xd2, 0x18, 0x1e, 0x9e, 0x43, 0x7e, 0xf9, + 0xd7, 0xcd, 0xdb, 0x9e, 0xd3, 0x27, 0x34, 0xdf, 0x1b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x4c, 0x49, 0xe0, 0x5, 0xfa, 0x7f, 0xa8, 0x2f, + 0x16, 0xf6, 0x3c, 0xf6, 0xa0, 0x45, 0x20, 0xfe}; + uint8_t bytesprops1[] = {0xae, 0x6f, 0x72, 0x46, 0xdb, 0x39, 0x77, 0x65, + 0x37, 0x4d, 0xca, 0x5a, 0x5c, 0xd6, 0xaf, 0x5a}; + uint8_t bytesprops2[] = {0xb5, 0x4e, 0xc9, 0x1e, 0x9f, 0x1f, 0xf1, 0x33, 0x72}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 192}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9460}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28298}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 244}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31638}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 143}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3645}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 251}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops2}}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops0[] = {0x10, 0x87, 0xd3, 0x75, 0xbb, 0xe5, 0x83, 0x3a, 0xf3, + 0x90, 0x14, 0x66, 0x38, 0xee, 0x31, 0xd5, 0xf7, 0xe}; + + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {18, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 15}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29638}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 206}}, + }; + + lwmqtt_properties_t willprops = {5, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe2, 0x67}; + lwmqtt_string_t will_topic = {2, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x94, 0xd, 0x7d, 0x7f, 0x31, 0x5a, 0x4a, 0xd2, 0x18, 0x1e, 0x9e, 0x43, + 0x7e, 0xf9, 0xd7, 0xcd, 0xdb, 0x9e, 0xd3, 0x27, 0x34, 0xdf, 0x1b}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; + will.topic = will_topic; + will.payload = will_payload; + will.qos = LWMQTT_QOS1; + will.retained = true; + will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 26866; - uint8_t client_id_bytes[] = {0x5e, 0xef, 0xbc, 0xc5, 0x8e, 0xe5, 0x5b, 0x1b, 0xd3, 0x45, 0xbc, 0xe9, 0xc3}; + opts.clean_session = false; + opts.keep_alive = 10322; + uint8_t client_id_bytes[] = {0x92, 0xe2, 0x78, 0xcc, 0x1b, 0x3a, 0x71, 0x35, 0x5, 0x7c, 0x2c, 0x60, 0xce}; lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; opts.client_id = client_id; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\159\254c\245[\164\r\135bMz\150\205`e\233\140\135YrN\180\GS\186\140\209As", -// _password = Just "<\FS\172b\196\SI\220\203\NUL`\187\209)9\165<\EOT\174\n\248\135\224m\140~\ar",PropTopicAliasMaximum 25773,PropCorrelationData -// "D\153\200f-\134",PropUserProperty "_\STX\142\230\DC2\227F\255U\NAK\ENQ@[\243\140\243G\195" -// "]\EM\213\167\243\144\187X\188\232\226\183\DLEz|=\196n\236!\235\SOH\223J\182^C)"]} -TEST(Connect5QCTest, Encode17) { +// ConnectRequest {_username = Just "\160(\fi\152\189\DC1\183}\167.2[,e\217\&8\238]\207\156\192:B\128\ESC\188\205", +// _password = Just "\223+\207(\246E\243:\221J\144\DLE#\165\162\&3\240\148\196\247\150:@\226\154\174<", _lastWill = +// Nothing, _cleanSession = True, _keepAlive = 19401, _connID = +// "6\204\")V\154L\237\218s#U\227\148\134o\190\&2\ETB\192^\225\201\229\169", _properties = [PropResponseInformation +// "C\SUB\229\233\223\DEL\202\158\US\EMk\176\213",PropServerReference +// "\DC3=\204@x`8\DC2\t\233\198\221\135\216\SYN",PropAuthenticationMethod +// "\DLE\167\n\179\DC3?r\207\GS\STX\220;by\213\SOp\231\EOT=\CAN\226,",PropSubscriptionIdentifierAvailable +// 71,PropWildcardSubscriptionAvailable 59,PropMaximumQoS 144,PropMessageExpiryInterval 11561,PropReasonString +// "x\ENQ\231\248\ACKhY\168\NAK9Z]fFD\173_h\157\&20\241v\181\205\185\DC4",PropUserProperty +// "\161@\DC2\130\\Pp\230\134\a\FS\235" +// "CF\128\225TL*\230\184Y\218\NUL\209\&2\ESC\156\GSo\222\221\&7\198=\217}\177\DLE\149",PropAuthenticationData +// "=A6a'\239\144\EM\221C\139\SI\233=\"\149W",PropRequestResponseInformation 158,PropResponseTopic +// "A\200o\t\159\150.\171\147\232"]} +TEST(Connect5QCTest, Encode18) { uint8_t pkt[] = { - 0x10, 0xe6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc0, 0x6a, 0xf4, 0x9e, 0x2, 0x27, 0x0, 0x0, 0x3, - 0x91, 0x12, 0x0, 0x0, 0x25, 0xbd, 0x2, 0x0, 0x0, 0x2, 0x16, 0x13, 0x15, 0x4f, 0x2, 0x0, 0x0, 0x4f, 0x21, - 0x26, 0x0, 0x19, 0xc5, 0x3f, 0xf, 0x4e, 0xdf, 0x21, 0xd5, 0x7d, 0x78, 0x63, 0xb0, 0x7, 0x55, 0xb1, 0xc5, 0xed, - 0x42, 0xa9, 0xe9, 0xa1, 0xb6, 0x1b, 0x72, 0x49, 0x39, 0x0, 0xe, 0xa, 0x12, 0xd9, 0xd2, 0xdb, 0x93, 0x94, 0xac, - 0x25, 0x30, 0x89, 0xde, 0xab, 0xcc, 0x2a, 0x82, 0x11, 0x0, 0x0, 0x29, 0xea, 0x9, 0x0, 0x1b, 0x2b, 0x42, 0xd8, - 0xf5, 0x8f, 0xf7, 0xea, 0x40, 0xe2, 0x24, 0xc8, 0x77, 0x66, 0x42, 0x70, 0xbb, 0xca, 0xfd, 0x47, 0x7a, 0xfc, 0xc6, - 0x52, 0x5e, 0x26, 0x25, 0x48, 0x1, 0xa4, 0x24, 0x93, 0x22, 0x67, 0xcb, 0x8, 0x0, 0x4, 0xdc, 0xd3, 0x25, 0xa6, - 0x17, 0x1, 0x18, 0x0, 0x0, 0x4c, 0x8e, 0x1c, 0x0, 0x1a, 0x55, 0x7b, 0x48, 0x59, 0x2a, 0x8b, 0xb7, 0x47, 0xe7, - 0xb2, 0x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x1d, 0xba, 0x8c, 0xd1, - 0x41, 0x73, 0x0, 0xf, 0x3c, 0x1c, 0xac, 0x62, 0xc4, 0xf, 0xdc, 0xcb, 0x0, 0x60, 0x3c, 0x76, 0x86, 0xc3, 0x65}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops2[] = {0xa, 0x12, 0xd9, 0xd2, 0xdb, 0x93, 0x94, 0xac, 0x25, 0x30, 0x89, 0xde, 0xab, 0xcc}; - uint8_t bytesprops1[] = {0xc5, 0x3f, 0xf, 0x4e, 0xdf, 0x21, 0xd5, 0x7d, 0x78, 0x63, 0xb0, 0x7, 0x55, - 0xb1, 0xc5, 0xed, 0x42, 0xa9, 0xe9, 0xa1, 0xb6, 0x1b, 0x72, 0x49, 0x39}; - uint8_t bytesprops3[] = {0x2b, 0x42, 0xd8, 0xf5, 0x8f, 0xf7, 0xea, 0x40, 0xe2, 0x24, 0xc8, 0x77, 0x66, 0x42, - 0x70, 0xbb, 0xca, 0xfd, 0x47, 0x7a, 0xfc, 0xc6, 0x52, 0x5e, 0x26, 0x25, 0x48}; - uint8_t bytesprops4[] = {0xdc, 0xd3, 0x25, 0xa6}; - uint8_t bytesprops5[] = {0x55, 0x7b, 0x48, 0x59, 0x2a, 0x8b, 0xb7, 0x47, 0xe7, 0xb2, 0x44, 0xfc, 0x45, - 0x0, 0x80, 0x7, 0xd1, 0x4a, 0xb3, 0x1f, 0xb2, 0xdb, 0xf7, 0xcd, 0xc0, 0xd7}; - uint8_t bytesprops7[] = {0x94, 0x84, 0x2e, 0xd5, 0x7b, 0x21, 0xde, 0x92, 0x24, 0x15, 0x26, 0xf8, 0x40, - 0x28, 0x8a, 0xa, 0x2b, 0xd2, 0x54, 0xa2, 0x56, 0x3f, 0xf5, 0x8b, 0xe8}; - uint8_t bytesprops6[] = {0x7d, 0x8b}; - uint8_t bytesprops8[] = {0x18, 0xce, 0xc3, 0x85, 0xba, 0xf4, 0xa4}; - uint8_t bytesprops9[] = {0xae, 0x60, 0x3e, 0xbb, 0xd1, 0x29, 0x39, 0xa5, 0x3c, 0x4, - 0xae, 0xa, 0xf8, 0x87, 0xe0, 0x6d, 0x8c, 0x7e, 0x7, 0x72}; - uint8_t bytesprops10[] = {0x44, 0x99, 0xc8, 0x66, 0x2d, 0x86}; - uint8_t bytesprops12[] = {0x5d, 0x19, 0xd5, 0xa7, 0xf3, 0x90, 0xbb, 0x58, 0xbc, 0xe8, 0xe2, 0xb7, 0x10, 0x7a, - 0x7c, 0x3d, 0xc4, 0x6e, 0xec, 0x21, 0xeb, 0x1, 0xdf, 0x4a, 0xb6, 0x5e, 0x43, 0x29}; - uint8_t bytesprops11[] = {0x5f, 0x2, 0x8e, 0xe6, 0x12, 0xe3, 0x46, 0xff, 0x55, - 0x15, 0x5, 0x40, 0x5b, 0xf3, 0x8c, 0xf3, 0x47, 0xc3}; + 0x10, 0x97, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x4b, 0xc9, 0xb5, 0x1, 0x1a, 0x0, 0xd, 0x43, + 0x1a, 0xe5, 0xe9, 0xdf, 0x7f, 0xca, 0x9e, 0x1f, 0x19, 0x6b, 0xb0, 0xd5, 0x1c, 0x0, 0xf, 0x13, 0x3d, 0xcc, 0x40, + 0x78, 0x60, 0x38, 0x12, 0x9, 0xe9, 0xc6, 0xdd, 0x87, 0xd8, 0x16, 0x15, 0x0, 0x17, 0x10, 0xa7, 0xa, 0xb3, 0x13, + 0x3f, 0x72, 0xcf, 0x1d, 0x2, 0xdc, 0x3b, 0x62, 0x79, 0xd5, 0xe, 0x70, 0xe7, 0x4, 0x3d, 0x18, 0xe2, 0x2c, 0x29, + 0x47, 0x28, 0x3b, 0x24, 0x90, 0x2, 0x0, 0x0, 0x2d, 0x29, 0x1f, 0x0, 0x1b, 0x78, 0x5, 0xe7, 0xf8, 0x6, 0x68, + 0x59, 0xa8, 0x15, 0x39, 0x5a, 0x5d, 0x66,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+ uint8_t bytesprops0[] = {0x43, 0x1a, 0xe5, 0xe9, 0xdf, 0x7f, 0xca, 0x9e, 0x1f, 0x19, 0x6b, 0xb0, 0xd5}; + uint8_t bytesprops1[] = {0x13, 0x3d, 0xcc, 0x40, 0x78, 0x60, 0x38, 0x12, 0x9, 0xe9, 0xc6, 0xdd, 0x87, 0xd8, 0x16}; + uint8_t bytesprops2[] = {0x10, 0xa7, 0xa, 0xb3, 0x13, 0x3f, 0x72, 0xcf, 0x1d, 0x2, 0xdc, 0x3b, + 0x62, 0x79, 0xd5, 0xe, 0x70, 0xe7, 0x4, 0x3d, 0x18, 0xe2, 0x2c}; + uint8_t bytesprops3[] = {0x78, 0x5, 0xe7, 0xf8, 0x6, 0x68, 0x59, 0xa8, 0x15, 0x39, 0x5a, 0x5d, 0x66, 0x46, + 0x44, 0xad, 0x5f, 0x68, 0x9d, 0x32, 0x30, 0xf1, 0x76, 0xb5, 0xcd, 0xb9, 0x14}; + uint8_t bytesprops5[] = {0x43, 0x46, 0x80, 0xe1, 0x54, 0x4c, 0x2a, 0xe6, 0xb8, 0x59, 0xda, 0x0, 0xd1, 0x32, + 0x1b, 0x9c, 0x1d, 0x6f, 0xde, 0xdd, 0x37, 0xc6, 0x3d, 0xd9, 0x7d, 0xb1, 0x10, 0x95}; + uint8_t bytesprops4[] = {0xa1, 0x40, 0x12, 0x82, 0x5c, 0x50, 0x70, 0xe6, 0x86, 0x7, 0x1c, 0xeb}; + uint8_t bytesprops6[] = {0x3d, 0x41, 0x36, 0x61, 0x27, 0xef, 0x90, 0x19, 0xdd, + 0x43, 0x8b, 0xf, 0xe9, 0x3d, 0x22, 0x95, 0x57}; + uint8_t bytesprops7[] = {0x41, 0xc8, 0x6f, 0x9, 0x9f, 0x96, 0x2e, 0xab, 0x93, 0xe8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 913}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 534}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5455}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20257}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops1}, .v = {14, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 130}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10730}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26571}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19598}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops6}, .v = {25, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 25773}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {18, (char*)&bytesprops11}, .v = {28, (char*)&bytesprops12}}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 71}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 59}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11561}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops4}, .v = {28, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 27380; - uint8_t client_id_bytes[] = {0xa4, 0xfd, 0xff, 0xbe, 0x2f, 0x50, 0x76, 0xe8, 0x1b, 0x7f, 0x10}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 19401; + uint8_t client_id_bytes[] = {0x36, 0xcc, 0x22, 0x29, 0x56, 0x9a, 0x4c, 0xed, 0xda, 0x73, 0x23, 0x55, 0xe3, + 0x94, 0x86, 0x6f, 0xbe, 0x32, 0x17, 0xc0, 0x5e, 0xe1, 0xc9, 0xe5, 0xa9}; + lwmqtt_string_t client_id = {25, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x9f, 0xfe, 0x63, 0xf5, 0x5b, 0xa4, 0xd, 0x87, 0x62, 0x4d, 0x7a, 0x96, 0xcd, 0x60, - 0x65, 0xe9, 0x8c, 0x87, 0x59, 0x72, 0x4e, 0xb4, 0x1d, 0xba, 0x8c, 0xd1, 0x41, 0x73}; + uint8_t username_bytes[] = {0xa0, 0x28, 0xc, 0x69, 0x98, 0xbd, 0x11, 0xb7, 0x7d, 0xa7, 0x2e, 0x32, 0x5b, 0x2c, + 0x65, 0xd9, 0x38, 0xee, 0x5d, 0xcf, 0x9c, 0xc0, 0x3a, 0x42, 0x80, 0x1b, 0xbc, 0xcd}; lwmqtt_string_t username = {28, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x3c, 0x1c, 0xac, 0x62, 0xc4, 0xf, 0xdc, 0xcb, 0x0, 0x60, 0x3c, 0x76, 0x86, 0xc3, 0x65}; - lwmqtt_string_t password = {15, (char*)&password_bytes}; + uint8_t password_bytes[] = {0xdf, 0x2b, 0xcf, 0x28, 0xf6, 0x45, 0xf3, 0x3a, 0xdd, 0x4a, 0x90, 0x10, 0x23, 0xa5, + 0xa2, 0x33, 0xf0, 0x94, 0xc4, 0xf7, 0x96, 0x3a, 0x40, 0xe2, 0x9a, 0xae, 0x3c}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); @@ -12332,150 +11668,139 @@ TEST(Connect5QCTest, Encode17) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "6\139\225\160\222Yv\ETB\184\SUB\RS\SO\234}G\231", _lastWill = -// Just (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "#\147F\FS\155\DC4#\190\181\197\164\ESC\166\191Z\ENQ\247\143\216\251\140\232\161>\239\135", _willMsg = -// "\232\233\vx\202\163\SOH\188\142\245iS\"H\226\158\228\235\182tA\252\ACK\191\183j8", _willProps = -// [PropRequestProblemInformation 207,PropTopicAlias 4199,PropResponseInformation -// "\183\249\163+\210\167/\229",PropContentType "\191\220\171\CAN\213\&5;\235\140 -// \231HX\248p.\132-\199W\168X\239#oa\172\162g(",PropUserProperty "" -// "\218\&1R\149p\193\226\143",PropAuthenticationMethod "\130",PropSessionExpiryInterval 2593,PropTopicAlias -// 23065,PropSessionExpiryInterval 4102,PropPayloadFormatIndicator 35,PropAuthenticationMethod "1r4"]}), _cleanSession = -// False, _keepAlive = 2005, _connID = "\SODv\236\176\168\ETB \EOT", _properties = [PropAuthenticationData -// "\247v\GS\229TS\208\161\DC1\235_\242\236\147J\175*R]",PropAssignedClientIdentifier "",PropCorrelationData -// "t\185\183\SOH!n\197\215\177\DC1O\fI\167\217(\\\253\138\206\193\213",PropReasonString -// "9\185\FSh\184\223l\134\162\151x\246O\226\216\164",PropTopicAliasMaximum 11736,PropMaximumQoS 32,PropServerReference -// "\199[3\248\148\186\DC4\149\NAK\166\"\132\198\249\v\t\167*H/z\183r\DC4#\191\STXT",PropResponseTopic -// "\236\196\199\207;N\222M\162\f\"\175\221\186",PropResponseTopic -// "\218\139\220f\247\ESC}\132\152\205\149\154\156\RS\ESC\199\223\223\158\&8\230$",PropResponseTopic -// "\STXs\246\190\ENQB`\178o\186\218\153\131\RS",PropAuthenticationData -// "\173V\209T\246\ENQ\v\152\ENQ\152\247\157\DEL\218\186u\202\a\193",PropWillDelayInterval -// 4378,PropMessageExpiryInterval 17537,PropRequestResponseInformation 119,PropReceiveMaximum 18892,PropServerReference -// "\200\132\&4\128W\178\DEL\156\131\182\149\240\GS\GS\182B\225N\152A`^\154P",PropRequestResponseInformation -// 200,PropWildcardSubscriptionAvailable 134,PropMessageExpiryInterval 8274,PropSharedSubscriptionAvailable -// 11,PropMaximumQoS 111,PropCorrelationData "R/\147\191\&1\132\233y\131\136\&0\248F",PropPayloadFormatIndicator -// 50,PropTopicAliasMaximum 2391]} -TEST(Connect5QCTest, Encode18) { +// ConnectRequest {_username = Just "^u#\159", _password = Just +// "y\"\r/\252\&8\144\156Y\221,;\158\GS\207S\130\174\230\ETB\150\150M\148\159\212", _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS0, _willTopic = "\160A\b\242{hJ\240\SOHs\227", _willMsg = +// "+JS\150\209\231\230=\222\231\225\142\244\229\US2\STX\233\240\253\168\RSzG1", _willProps = [PropReasonString +// "'g\155\154%&\DLE_ /2\211\198d",PropResponseTopic "\206!\CAN\143\a$\229",PropSessionExpiryInterval +// 25013,PropSubscriptionIdentifier 5,PropSessionExpiryInterval 24584,PropMessageExpiryInterval +// 23541,PropPayloadFormatIndicator 200,PropMaximumPacketSize 4912,PropTopicAlias 16949,PropTopicAlias +// 16583,PropCorrelationData "v\SUB\ETB\240\236\255\128/\204+\"\b",PropAuthenticationMethod +// "\232\248\205#g\198\132b\236|\GS\192#]",PropMaximumQoS 115,PropPayloadFormatIndicator 136,PropServerKeepAlive +// 4856,PropAuthenticationMethod "\228$]\172\DLE[>\r\DC2\DC2\208\221|\200%\137\247Jf\201\250\246?",PropResponseTopic +// "\140",PropUserProperty "DYe\182\DEL\143R\150\206\187\USD\177\ESC\ETX>Dd:\255" +// "W\201\ETBm)UD9@!\172\201\148\176\EM@\162\128\217\\J"]}), _cleanSession = True, _keepAlive = 22513, _connID = +// "/\179\ENQ:\239\234\242P\129,\b\213A\237\186\243\&9\183\133\147\188\136.\ACK\202\FSS\\", _properties = +// [PropCorrelationData "\202\&4\250\CANN\240\191\152\222",PropTopicAlias 8984,PropSubscriptionIdentifierAvailable +// 29,PropRequestProblemInformation 163,PropReceiveMaximum 18790,PropAuthenticationMethod +// "\176\ENQS&\DC1\191\229+\197\152\162\SOH\DELQ]\235\173A\DEL\223\136\149",PropSubscriptionIdentifier +// 30,PropAuthenticationMethod "9\169\250\234\ESC\220\163\204\171\SUB\182\224",PropRetainAvailable +// 41,PropWillDelayInterval 29889,PropWildcardSubscriptionAvailable 124,PropRequestResponseInformation +// 82,PropContentType "\145 +// \255C_\146\209mA\223\169\FS\216F\247\214\181&\SO2\214\"oE\159`C\SOH\SOH",PropMessageExpiryInterval +// 21434,PropServerKeepAlive 5605,PropMaximumPacketSize 10501]} +TEST(Connect5QCTest, Encode19) { uint8_t pkt[] = { - 0x10, 0xc0, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x64, 0x7, 0xd5, 0x86, 0x2, 0x16, 0x0, 0x13, 0xf7, - 0x76, 0x1d, 0xe5, 0x54, 0x53, 0xd0, 0xa1, 0x11, 0xeb, 0x5f, 0xf2, 0xec, 0x93, 0x4a, 0xaf, 0x2a, 0x52, 0x5d, 0x12, - 0x0, 0x0, 0x9, 0x0, 0x16, 0x74, 0xb9, 0xb7, 0x1, 0x21, 0x6e, 0xc5, 0xd7, 0xb1, 0x11, 0x4f, 0xc, 0x49, 0xa7, - 0xd9, 0x28, 0x5c, 0xfd, 0x8a, 0xce, 0xc1, 0xd5, 0x1f, 0x0, 0x10, 0x39, 0xb9, 0x1c, 0x68, 0xb8, 0xdf, 0x6c, 0x86, - 0xa2, 0x97, 0x78, 0xf6, 0x4f, 0xe2, 0xd8, 0xa4, 0x22, 0x2d, 0xd8, 0x24, 0x20, 0x1c, 0x0, 0x1c, 0xc7, 0x5b, 0x33, - 0xf8, 0x94, 0xba, 0x14, 0x95, 0x15, 0xa6, 0x22, 0x84, 0xc6, 0xf9, 0xb, 0x9, 0xa7, 0x2a, 0x48, 0x2f, 0x7a, 0xb7, - 0x72, 0x14, 0x23, 0xbf, 0x2, 0x54, 0x8, 0x0, 0xe, 0xec, 0xc4, 0xc7, 0xcf, 0x3b, 0x4e, 0xde, 0x4d, 0xa2, 0xc, - 0x22, 0xaf, 0xdd, 0xba, 0x8, 0x0, 0x16, 0xda, 0x8b, 0xdc, 0x66, 0xf7, 0x1b, 0x7d, 0x84, 0x98, 0xcd, 0x95, 0x9a, - 0x9c, 0x1e, 0x1b, 0xc7, 0xdf, 0xdf, 0x9e, 0x38, 0xe6, 0x24, 0x8, 0x0, 0xe, 0x2, 0x73, 0xf6, 0xbe,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x21, 0x23, - 0x5a, 0x19, 0x11, 0x0, 0x0, 0x10, 0x6, 0x1, 0x23, 0x15, 0x0, 0x3, 0x31, 0x72, 0x34, 0x0, 0x1a, 0x23, 0x93, - 0x46, 0x1c, 0x9b, 0x14, 0x23, 0xbe, 0xb5, 0xc5, 0xa4, 0x1b, 0xa6, 0xbf, 0x5a, 0x5, 0xf7, 0x8f, 0xd8, 0xfb, 0x8c, - 0xe8, 0xa1, 0x3e, 0xef, 0x87, 0x0, 0x1b, 0xe8, 0xe9, 0xb, 0x78, 0xca, 0xa3, 0x1, 0xbc, 0x8e, 0xf5, 0x69, 0x53, - 0x22, 0x48, 0xe2, 0x9e, 0xe4, 0xeb, 0xb6, 0x74, 0x41, 0xfc, 0x6, 0xbf, 0xb7, 0x6a, 0x38, 0x0, 0x10, 0x36, 0x8b, - 0xe1, 0xa0, 0xde, 0x59, 0x76, 0x17, 0xb8, 0x1a, 0x1e, 0xe, 0xea, 0x7d, 0x47, 0xe7}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf7, 0x76, 0x1d, 0xe5, 0x54, 0x53, 0xd0, 0xa1, 0x11, 0xeb, - 0x5f, 0xf2, 0xec, 0x93, 0x4a, 0xaf, 0x2a, 0x52, 0x5d}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x74, 0xb9, 0xb7, 0x1, 0x21, 0x6e, 0xc5, 0xd7, 0xb1, 0x11, 0x4f, - 0xc, 0x49, 0xa7, 0xd9, 0x28, 0x5c, 0xfd, 0x8a, 0xce, 0xc1, 0xd5}; - uint8_t bytesprops3[] = {0x39, 0xb9, 0x1c, 0x68, 0xb8, 0xdf, 0x6c, 0x86, - 0xa2, 0x97, 0x78, 0xf6, 0x4f, 0xe2, 0xd8, 0xa4}; - uint8_t bytesprops4[] = {0xc7, 0x5b, 0x33, 0xf8, 0x94, 0xba, 0x14, 0x95, 0x15, 0xa6, 0x22, 0x84, 0xc6, 0xf9, - 0xb, 0x9, 0xa7, 0x2a, 0x48, 0x2f, 0x7a, 0xb7, 0x72, 0x14, 0x23, 0xbf, 0x2, 0x54}; - uint8_t bytesprops5[] = {0xec, 0xc4, 0xc7, 0xcf, 0x3b, 0x4e, 0xde, 0x4d, 0xa2, 0xc, 0x22, 0xaf, 0xdd, 0xba}; - uint8_t bytesprops6[] = {0xda, 0x8b, 0xdc, 0x66, 0xf7, 0x1b, 0x7d, 0x84, 0x98, 0xcd, 0x95, - 0x9a, 0x9c, 0x1e, 0x1b, 0xc7, 0xdf, 0xdf, 0x9e, 0x38, 0xe6, 0x24}; - uint8_t bytesprops7[] = {0x2, 0x73, 0xf6, 0xbe, 0x5, 0x42, 0x60, 0xb2, 0x6f, 0xba, 0xda, 0x99, 0x83, 0x1e}; - uint8_t bytesprops8[] = {0xad, 0x56, 0xd1, 0x54, 0xf6, 0x5, 0xb, 0x98, 0x5, 0x98, - 0xf7, 0x9d, 0x7f, 0xda, 0xba, 0x75, 0xca, 0x7, 0xc1}; - uint8_t bytesprops9[] = {0xc8, 0x84, 0x34, 0x80, 0x57, 0xb2, 0x7f, 0x9c, 0x83, 0xb6, 0x95, 0xf0, - 0x1d, 0x1d, 0xb6, 0x42, 0xe1, 0x4e, 0x98, 0x41, 0x60, 0x5e, 0x9a, 0x50}; - uint8_t bytesprops10[] = {0x52, 0x2f, 0x93, 0xbf, 0x31, 0x84, 0xe9, 0x79, 0x83, 0x88, 0x30, 0xf8, 0x46}; + 0x10, 0x99, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc6, 0x57, 0xf1, 0x78, 0x9, 0x0, 0x9, 0xca, 0x34, + 0xfa, 0x18, 0x4e, 0xf0, 0xbf, 0x98, 0xde, 0x23, 0x23, 0x18, 0x29, 0x1d, 0x17, 0xa3, 0x21, 0x49, 0x66, 0x15, 0x0, + 0x16, 0xb0, 0x5, 0x53, 0x26, 0x11, 0xbf, 0xe5, 0x2b, 0xc5, 0x98, 0xa2, 0x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e, 0xe8, 0xf8, 0xcd, 0x23, 0x67, 0xc6, + 0x84, 0x62, 0xec, 0x7c, 0x1d, 0xc0, 0x23, 0x5d, 0x24, 0x73, 0x1, 0x88, 0x13, 0x12, 0xf8, 0x15, 0x0, 0x17, 0xe4, + 0x24, 0x5d, 0xac, 0x10, 0x5b, 0x3e, 0xd, 0x12, 0x12, 0xd0, 0xdd, 0x7c, 0xc8, 0x25, 0x89, 0xf7, 0x4a, 0x66, 0xc9, + 0xfa, 0xf6, 0x3f, 0x8, 0x0, 0x1, 0x8c, 0x26, 0x0, 0x14, 0x44, 0x59, 0x65, 0xb6, 0x7f, 0x8f, 0x52, 0x96, 0xce, + 0xbb, 0x1f, 0x44, 0xb1, 0x1b, 0x3, 0x3e, 0x44, 0x64, 0x3a, 0xff, 0x0, 0x15, 0x57, 0xc9, 0x17, 0x6d, 0x29, 0x55, + 0x44, 0x39, 0x40, 0x21, 0xac, 0xc9, 0x94, 0xb0, 0x19, 0x40, 0xa2, 0x80, 0xd9, 0x5c, 0x4a, 0x0, 0xb, 0xa0, 0x41, + 0x8, 0xf2, 0x7b, 0x68, 0x4a, 0xf0, 0x1, 0x73, 0xe3, 0x0, 0x19, 0x2b, 0x4a, 0x53, 0x96, 0xd1, 0xe7, 0xe6, 0x3d, + 0xde, 0xe7, 0xe1, 0x8e, 0xf4, 0xe5, 0x1f, 0x32, 0x2, 0xe9, 0xf0, 0xfd, 0xa8, 0x1e, 0x7a, 0x47, 0x31, 0x0, 0x4, + 0x5e, 0x75, 0x23, 0x9f, 0x0, 0x1a, 0x79, 0x22, 0xd, 0x2f, 0xfc, 0x38, 0x90, 0x9c, 0x59, 0xdd, 0x2c, 0x3b, 0x9e, + 0x1d, 0xcf, 0x53, 0x82, 0xae, 0xe6, 0x17, 0x96, 0x96, 0x4d, 0x94, 0x9f, 0xd4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xca, 0x34, 0xfa, 0x18, 0x4e, 0xf0, 0xbf, 0x98, 0xde}; + uint8_t bytesprops1[] = {0xb0, 0x5, 0x53, 0x26, 0x11, 0xbf, 0xe5, 0x2b, 0xc5, 0x98, 0xa2, + 0x1, 0x7f, 0x51, 0x5d, 0xeb, 0xad, 0x41, 0x7f, 0xdf, 0x88, 0x95}; + uint8_t bytesprops2[] = {0x39, 0xa9, 0xfa, 0xea, 0x1b, 0xdc, 0xa3, 0xcc, 0xab, 0x1a, 0xb6, 0xe0}; + uint8_t bytesprops3[] = {0x91, 0x20, 0xff, 0x43, 0x5f, 0x92, 0xd1, 0x6d, 0x41, 0xdf, 0xa9, 0x1c, 0xd8, 0x46, 0xf7, + 0xd6, 0xb5, 0x26, 0xe, 0x32, 0xd6, 0x22, 0x6f, 0x45, 0x9f, 0x60, 0x43, 0x1, 0x1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11736}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4378}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17537}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18892}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8274}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 2391}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8984}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 29}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 163}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18790}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 41}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29889}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21434}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5605}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10501}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xb7, 0xf9, 0xa3, 0x2b, 0xd2, 0xa7, 0x2f, 0xe5}; - uint8_t byteswillprops1[] = {0xbf, 0xdc, 0xab, 0x18, 0xd5, 0x35, 0x3b, 0xeb, 0x8c, 0x20, - 0xe7, 0x48, 0x58, 0xf8, 0x70, 0x2e, 0x84, 0x2d, 0xc7, 0x57, - 0xa8, 0x58, 0xef, 0x23, 0x6f, 0x61, 0xac, 0xa2, 0x67, 0x28}; - uint8_t byteswillprops3[] = {0xda, 0x31, 0x52, 0x95, 0x70, 0xc1, 0xe2, 0x8f}; - uint8_t byteswillprops2[] = {0}; - uint8_t byteswillprops4[] = {0x82}; - uint8_t byteswillprops5[] = {0x31, 0x72, 0x34}; + uint8_t byteswillprops0[] = {0x27, 0x67, 0x9b, 0x9a, 0x25, 0x26, 0x10, 0x5f, 0x20, 0x2f, 0x32, 0xd3, 0xc6, 0x64}; + uint8_t byteswillprops1[] = {0xce, 0x21, 0x18, 0x8f, 0x7, 0x24, 0xe5}; + uint8_t byteswillprops2[] = {0x76, 0x1a, 0x17, 0xf0, 0xec, 0xff, 0x80, 0x2f, 0xcc, 0x2b, 0x22, 0x8}; + uint8_t byteswillprops3[] = {0xe8, 0xf8, 0xcd, 0x23, 0x67, 0xc6, 0x84, 0x62, 0xec, 0x7c, 0x1d, 0xc0, 0x23, 0x5d}; + uint8_t byteswillprops4[] = {0xe4, 0x24, 0x5d, 0xac, 0x10, 0x5b, 0x3e, 0xd, 0x12, 0x12, 0xd0, 0xdd, + 0x7c, 0xc8, 0x25, 0x89, 0xf7, 0x4a, 0x66, 0xc9, 0xfa, 0xf6, 0x3f}; + uint8_t byteswillprops5[] = {0x8c}; + uint8_t byteswillprops7[] = {0x57, 0xc9, 0x17, 0x6d, 0x29, 0x55, 0x44, 0x39, 0x40, 0x21, 0xac, + 0xc9, 0x94, 0xb0, 0x19, 0x40, 0xa2, 0x80, 0xd9, 0x5c, 0x4a}; + uint8_t byteswillprops6[] = {0x44, 0x59, 0x65, 0xb6, 0x7f, 0x8f, 0x52, 0x96, 0xce, 0xbb, + 0x1f, 0x44, 0xb1, 0x1b, 0x3, 0x3e, 0x44, 0x64, 0x3a, 0xff}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4199}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25013}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24584}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23541}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4912}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16949}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16583}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4856}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops5}}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {0, (char*)&byteswillprops2}, .v = {8, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2593}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23065}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4102}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&byteswillprops5}}}, + .value = {.pair = {.k = {20, (char*)&byteswillprops6}, .v = {21, (char*)&byteswillprops7}}}}, }; - lwmqtt_properties_t willprops = {11, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x23, 0x93, 0x46, 0x1c, 0x9b, 0x14, 0x23, 0xbe, 0xb5, 0xc5, 0xa4, 0x1b, 0xa6, - 0xbf, 0x5a, 0x5, 0xf7, 0x8f, 0xd8, 0xfb, 0x8c, 0xe8, 0xa1, 0x3e, 0xef, 0x87}; - lwmqtt_string_t will_topic = {26, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xe8, 0xe9, 0xb, 0x78, 0xca, 0xa3, 0x1, 0xbc, 0x8e, 0xf5, 0x69, 0x53, 0x22, 0x48, - 0xe2, 0x9e, 0xe4, 0xeb, 0xb6, 0x74, 0x41, 0xfc, 0x6, 0xbf, 0xb7, 0x6a, 0x38}; - lwmqtt_string_t will_payload = {27, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {18, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xa0, 0x41, 0x8, 0xf2, 0x7b, 0x68, 0x4a, 0xf0, 0x1, 0x73, 0xe3}; + lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2b, 0x4a, 0x53, 0x96, 0xd1, 0xe7, 0xe6, 0x3d, 0xde, 0xe7, 0xe1, 0x8e, 0xf4, + 0xe5, 0x1f, 0x32, 0x2, 0xe9, 0xf0, 0xfd, 0xa8, 0x1e, 0x7a, 0x47, 0x31}; + lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS0; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 2005; - uint8_t client_id_bytes[] = {0xe, 0x44, 0x76, 0xec, 0xb0, 0xa8, 0x17, 0x20, 0x4}; - lwmqtt_string_t client_id = {9, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 22513; + uint8_t client_id_bytes[] = {0x2f, 0xb3, 0x5, 0x3a, 0xef, 0xea, 0xf2, 0x50, 0x81, 0x2c, 0x8, 0xd5, 0x41, 0xed, + 0xba, 0xf3, 0x39, 0xb7, 0x85, 0x93, 0xbc, 0x88, 0x2e, 0x6, 0xca, 0x1c, 0x53, 0x5c}; + lwmqtt_string_t client_id = {28, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x36, 0x8b, 0xe1, 0xa0, 0xde, 0x59, 0x76, 0x17, - 0xb8, 0x1a, 0x1e, 0xe, 0xea, 0x7d, 0x47, 0xe7}; - lwmqtt_string_t password = {16, (char*)&password_bytes}; + uint8_t username_bytes[] = {0x5e, 0x75, 0x23, 0x9f}; + lwmqtt_string_t username = {4, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x79, 0x22, 0xd, 0x2f, 0xfc, 0x38, 0x90, 0x9c, 0x59, 0xdd, 0x2c, 0x3b, 0x9e, + 0x1d, 0xcf, 0x53, 0x82, 0xae, 0xe6, 0x17, 0x96, 0x96, 0x4d, 0x94, 0x9f, 0xd4}; + lwmqtt_string_t password = {26, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -12485,170 +11810,132 @@ TEST(Connect5QCTest, Encode18) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "5\189\229", _password = Just "\SO\229\SUB\207\196\181|6\242\192@", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = "v<3?)\161", _willMsg = -// "\202\&9\147\164]\233\219\201F\146ox)xa", _willProps = [PropAssignedClientIdentifier -// "Dc\147\242\153",PropResponseTopic "\EM\b-\DELBH@}\187\218\162\213\134",PropResponseInformation -// "\n1b\217:bmW\202_jM\223\157\162\CAN\ETX\168",PropSubscriptionIdentifierAvailable 100,PropAuthenticationData -// "\204z\an",PropSessionExpiryInterval 8296,PropContentType "\235\149\162!\EOT\244 -// \207\170\221\185\238e\174\167:n}A~\172\255*\165\NUL\131\128a",PropAuthenticationMethod "%",PropResponseTopic -// "\DC4\191Y\141\&9\170m",PropMaximumPacketSize 24666,PropPayloadFormatIndicator 239,PropReceiveMaximum -// 30525,PropTopicAliasMaximum 26970,PropRequestProblemInformation 125,PropServerReference -// "\190\205;9?\139\178\185\SYN\SUB\201\a",PropTopicAlias 26971,PropMessageExpiryInterval 5356,PropReceiveMaximum -// 5790,PropRequestResponseInformation 218,PropServerReference "\206",PropServerReference -// "-\SUB\149\226\222",PropSubscriptionIdentifier 12,PropWillDelayInterval 9880,PropRequestResponseInformation 52]}), -// _cleanSession = False, _keepAlive = 31959, _connID = "K\181", _properties = [PropWildcardSubscriptionAvailable -// 193,PropTopicAlias 23844,PropRequestProblemInformation 174,PropWildcardSubscriptionAvailable -// 246,PropResponseInformation "H",PropMessageExpiryInterval 4039,PropTopicAlias 29447,PropMessageExpiryInterval -// 9745,PropContentType "\220b\195\246X\148\GS&\192\211%\136\149",PropCorrelationData -// "\137C\140\217\ETX\165\196\135g\224\196\130\237\NAK\198\224\DEL\179",PropResponseTopic -// "\142\191\170\182\239\131\SUB\251\141\182VI",PropServerReference -// "k&|\204\142\171\220\133\163\248l\247\136,\136`\182e;)\219nY\DC4\129",PropRetainAvailable 42,PropRetainAvailable -// 141,PropResponseTopic "\196\177\&7\243\DC4\245\193\DC4\234",PropMaximumPacketSize 23721,PropAuthenticationMethod -// "\231`@P\184\169U\255|\DLE",PropReasonString "\228/\245lwe)\150\SO\246\ESCT\135>\188\250",PropAuthenticationMethod -// "\158\164\182\SO-O\192\205\162\175\161\172\SI\198B\224WS\207\212\145\DC4",PropSharedSubscriptionAvailable -// 210,PropPayloadFormatIndicator 185,PropMessageExpiryInterval 2096,PropTopicAlias 13639,PropRetainAvailable -// 168,PropTopicAliasMaximum 9785,PropContentType "\v\DC3I",PropAssignedClientIdentifier -// "\176\155\178\141",PropRetainAvailable 76]} -TEST(Connect5QCTest, Encode19) { +// ConnectRequest {_username = Nothing, _password = Just +// "\148\203\247(\RS\253m?\172\246]f\150WW\162\137\245\t\255\243\SUB}", _lastWill = Just (LastWill {_willRetain = True, +// _willQoS = QoS2, _willTopic = "Q&\199s\163,\145Pk\170\212\r\SOH\210I", _willMsg = +// "/y0\n\222\221\178\SO\241\211d\222\211\&0b", _willProps = [PropTopicAliasMaximum 24326,PropTopicAliasMaximum +// 31128,PropReasonString "\EOT(\184q\142\248M\n\231\197\ENQ\145\166Wg6\236\254l",PropRequestResponseInformation +// 127,PropTopicAliasMaximum 24979,PropReasonString " \212 \181\&4\181\183\177\153\&8",PropRetainAvailable +// 93,PropResponseTopic "\249I7z\192\160\139\143y[\ETB\242\209"]}), _cleanSession = False, _keepAlive = 190, _connID = +// "6Y\188\175\229N\156\168\153V\FS", _properties = [PropTopicAliasMaximum 5801,PropMaximumQoS 147,PropReceiveMaximum +// 30524,PropServerKeepAlive 30683,PropCorrelationData +// "]\177\190!\250+\240\237\244\160\249\&4\ETB\172\176\250\172lq\130\246\167\tUA\NAK\137",PropCorrelationData +// "dS\224\235\&7\SYNR",PropResponseTopic "y\221~\245:me,\228(\219$\240]\207q\ETB3\156 \253K",PropAuthenticationMethod +// "t\142\144\&4>\218\246\147\232B\211\139O\245",PropServerKeepAlive 5346,PropTopicAliasMaximum +// 17977,PropRequestProblemInformation 52,PropSharedSubscriptionAvailable 246,PropContentType +// "\161\t\171\r\154\&9\194'p\250]d\205M\190\148\SO#\133\&0|W\201\183\244",PropMaximumPacketSize 19914,PropUserProperty +// "|\212\133R!\tH\254J\140\213\SO\174x\169\FS" "\STX\NUL\EM\RS\155\252\r\188<_(",PropAuthenticationData +// "AZfX\184",PropAuthenticationMethod "{k\222\194\244\156",PropRequestProblemInformation 175,PropSubscriptionIdentifier +// 1,PropMaximumQoS 191,PropServerKeepAlive 18832,PropRequestResponseInformation 70,PropTopicAlias +// 3492,PropRequestResponseInformation 231,PropAuthenticationData +// "\198\174\231U*\NAKko\ACK\170\252\150[\180\163\150",PropWillDelayInterval 31865]} +TEST(Connect5QCTest, Encode20) { uint8_t pkt[] = { - 0x10, 0xbd, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xe4, 0x7c, 0xd7, 0xd8, 0x1, 0x28, 0xc1, 0x23, 0x5d, - 0x24, 0x17, 0xae, 0x28, 0xf6, 0x1a, 0x0, 0x1, 0x48, 0x2, 0x0, 0x0, 0xf, 0xc7, 0x23, 0x73, 0x7, 0x2, 0x0, - 0x0, 0x26, 0x11, 0x3, 0x0, 0xd, 0xdc, 0x62, 0xc3, 0xf6, 0x58, 0x94, 0x1d, 0x26, 0xc0, 0xd3, 0x25, 0x88, 0x95, - 0x9, 0x0, 0x12, 0x89, 0x43, 0x8c, 0xd9, 0x3, 0xa5, 0xc4, 0x87, 0x67, 0xe0, 0xc4, 0x82, 0xed, 0x15, 0xc6, 0xe0, - 0x7f, 0xb3, 0x8, 0x0, 0xc, 0x8e, 0xbf, 0xaa, 0xb6, 0xef, 0x83, 0x1a, 0xfb, 0x8d, 0xb6, 0x56, 0x49, 0x1c, 0x0, - 0x19, 0x6b, 0x26, 0x7c, 0xcc, 0x8e, 0xab, 0xdc, 0x85, 0xa3, 0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0, 0x0, 0x20, 0x68, 0x3, 0x0, 0x1c, 0xeb, 0x95, 0xa2, 0x21, 0x4, - 0xf4, 0x20, 0xcf, 0xaa, 0xdd, 0xb9, 0xee, 0x65, 0xae, 0xa7, 0x3a, 0x6e, 0x7d, 0x41, 0x7e, 0xac, 0xff, 0x2a, 0xa5, - 0x0, 0x83, 0x80, 0x61, 0x15, 0x0, 0x1, 0x25, 0x8, 0x0, 0x7, 0x14, 0xbf, 0x59, 0x8d, 0x39, 0xaa, 0x6d, 0x27, - 0x0, 0x0, 0x60, 0x5a, 0x1, 0xef, 0x21, 0x77, 0x3d, 0x22, 0x69, 0x5a, 0x17, 0x7d, 0x1c, 0x0, 0xc, 0xbe, 0xcd, - 0x3b, 0x39, 0x3f, 0x8b, 0xb2, 0xb9, 0x16, 0x1a, 0xc9, 0x7, 0x23, 0x69, 0x5b, 0x2, 0x0, 0x0, 0x14, 0xec, 0x21, - 0x16, 0x9e, 0x19, 0xda, 0x1c, 0x0, 0x1, 0xce, 0x1c, 0x0, 0x5, 0x2d, 0x1a, 0x95, 0xe2, 0xde, 0xb, 0xc, 0x18, - 0x0, 0x0, 0x26, 0x98, 0x19, 0x34, 0x0, 0x6, 0x76, 0x3c, 0x33, 0x3f, 0x29, 0xa1, 0x0, 0xf, 0xca, 0x39, 0x93, - 0xa4, 0x5d, 0xe9, 0xdb, 0xc9, 0x46, 0x92, 0x6f, 0x78, 0x29, 0x78, 0x61, 0x0, 0x3, 0x35, 0xbd, 0xe5, 0x0, 0xb, - 0xe, 0xe5, 0x1a, 0xcf, 0xc4, 0xb5, 0x7c, 0x36, 0xf2, 0xc0, 0x40}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x48}; - uint8_t bytesprops1[] = {0xdc, 0x62, 0xc3, 0xf6, 0x58, 0x94, 0x1d, 0x26, 0xc0, 0xd3, 0x25, 0x88, 0x95}; - uint8_t bytesprops2[] = {0x89, 0x43, 0x8c, 0xd9, 0x3, 0xa5, 0xc4, 0x87, 0x67, - 0xe0, 0xc4, 0x82, 0xed, 0x15, 0xc6, 0xe0, 0x7f, 0xb3}; - uint8_t bytesprops3[] = {0x8e, 0xbf, 0xaa, 0xb6, 0xef, 0x83, 0x1a, 0xfb, 0x8d, 0xb6, 0x56, 0x49}; - uint8_t bytesprops4[] = {0x6b, 0x26, 0x7c, 0xcc, 0x8e, 0xab, 0xdc, 0x85, 0xa3, 0xf8, 0x6c, 0xf7, 0x88, - 0x2c, 0x88, 0x60, 0xb6, 0x65, 0x3b, 0x29, 0xdb, 0x6e, 0x59, 0x14, 0x81}; - uint8_t bytesprops5[] = {0xc4, 0xb1, 0x37, 0xf3, 0x14, 0xf5, 0xc1, 0x14, 0xea}; - uint8_t bytesprops6[] = {0xe7, 0x60, 0x40, 0x50, 0xb8, 0xa9, 0x55, 0xff, 0x7c, 0x10}; - uint8_t bytesprops7[] = {0xe4, 0x2f, 0xf5, 0x6c, 0x77, 0x65, 0x29, 0x96, - 0xe, 0xf6, 0x1b, 0x54, 0x87, 0x3e, 0xbc, 0xfa}; - uint8_t bytesprops8[] = {0x9e, 0xa4, 0xb6, 0xe, 0x2d, 0x4f, 0xc0, 0xcd, 0xa2, 0xaf, 0xa1, - 0xac, 0xf, 0xc6, 0x42, 0xe0, 0x57, 0x53, 0xcf, 0xd4, 0x91, 0x14}; - uint8_t bytesprops9[] = {0xb, 0x13, 0x49}; - uint8_t bytesprops10[] = {0xb0, 0x9b, 0xb2, 0x8d}; + 0x10, 0xf6, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x74, 0x0, 0xbe, 0xe1, 0x1, 0x22, 0x16, 0xa9, 0x24, + 0x93, 0x21, 0x77, 0x3c, 0x13, 0x77, 0xdb, 0x9, 0x0, 0x1b, 0x5d, 0xb1, 0xbe, 0x21, 0xfa, 0x2b, 0xf0, 0xed, 0xf4, + 0xa0, 0xf9, 0x34, 0x17, 0xac, 0xb0, 0xfa, 0xac, 0x6c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0x96, 0x18, 0x0, 0x0, 0x7c, 0x79, 0x0, 0xb, 0x36, 0x59, 0xbc, 0xaf, 0xe5, + 0x4e, 0x9c, 0xa8, 0x99, 0x56, 0x1c, 0x40, 0x22, 0x5f, 0x6, 0x22, 0x79, 0x98, 0x1f, 0x0, 0x13, 0x4, 0x28, 0xb8, + 0x71, 0x8e, 0xf8, 0x4d, 0xa, 0xe7, 0xc5, 0x5, 0x91, 0xa6, 0x57, 0x67, 0x36, 0xec, 0xfe, 0x6c, 0x19, 0x7f, 0x22, + 0x61, 0x93, 0x1f, 0x0, 0xa, 0x20, 0xd4, 0x20, 0xb5, 0x34, 0xb5, 0xb7, 0xb1, 0x99, 0x38, 0x25, 0x5d, 0x8, 0x0, + 0xd, 0xf9, 0x49, 0x37, 0x7a, 0xc0, 0xa0, 0x8b, 0x8f, 0x79, 0x5b, 0x17, 0xf2, 0xd1, 0x0, 0xf, 0x51, 0x26, 0xc7, + 0x73, 0xa3, 0x2c, 0x91, 0x50, 0x6b, 0xaa, 0xd4, 0xd, 0x1, 0xd2, 0x49, 0x0, 0xf, 0x2f, 0x79, 0x30, 0xa, 0xde, + 0xdd, 0xb2, 0xe, 0xf1, 0xd3, 0x64, 0xde, 0xd3, 0x30, 0x62, 0x0, 0x17, 0x94, 0xcb, 0xf7, 0x28, 0x1e, 0xfd, 0x6d, + 0x3f, 0xac, 0xf6, 0x5d, 0x66, 0x96, 0x57, 0x57, 0xa2, 0x89, 0xf5, 0x9, 0xff, 0xf3, 0x1a, 0x7d}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x5d, 0xb1, 0xbe, 0x21, 0xfa, 0x2b, 0xf0, 0xed, 0xf4, 0xa0, 0xf9, 0x34, 0x17, 0xac, + 0xb0, 0xfa, 0xac, 0x6c, 0x71, 0x82, 0xf6, 0xa7, 0x9, 0x55, 0x41, 0x15, 0x89}; + uint8_t bytesprops1[] = {0x64, 0x53, 0xe0, 0xeb, 0x37, 0x16, 0x52}; + uint8_t bytesprops2[] = {0x79, 0xdd, 0x7e, 0xf5, 0x3a, 0x6d, 0x65, 0x2c, 0xe4, 0x28, 0xdb, + 0x24, 0xf0, 0x5d, 0xcf, 0x71, 0x17, 0x33, 0x9c, 0x20, 0xfd, 0x4b}; + uint8_t bytesprops3[] = {0x74, 0x8e, 0x90, 0x34, 0x3e, 0xda, 0xf6, 0x93, 0xe8, 0x42, 0xd3, 0x8b, 0x4f, 0xf5}; + uint8_t bytesprops4[] = {0xa1, 0x9, 0xab, 0xd, 0x9a, 0x39, 0xc2, 0x27, 0x70, 0xfa, 0x5d, 0x64, 0xcd, + 0x4d, 0xbe, 0x94, 0xe, 0x23, 0x85, 0x30, 0x7c, 0x57, 0xc9, 0xb7, 0xf4}; + uint8_t bytesprops6[] = {0x2, 0x0, 0x19, 0x1e, 0x9b, 0xfc, 0xd, 0xbc, 0x3c, 0x5f, 0x28}; + uint8_t bytesprops5[] = {0x7c, 0xd4, 0x85, 0x52, 0x21, 0x9, 0x48, 0xfe, + 0x4a, 0x8c, 0xd5, 0xe, 0xae, 0x78, 0xa9, 0x1c}; + uint8_t bytesprops7[] = {0x41, 0x5a, 0x66, 0x58, 0xb8}; + uint8_t bytesprops8[] = {0x7b, 0x6b, 0xde, 0xc2, 0xf4, 0x9c}; + uint8_t bytesprops9[] = {0xc6, 0xae, 0xe7, 0x55, 0x2a, 0x15, 0x6b, 0x6f, + 0x6, 0xaa, 0xfc, 0x96, 0x5b, 0xb4, 0xa3, 0x96}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23844}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 246}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4039}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29447}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9745}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23721}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 210}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2096}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13639}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 168}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9785}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5801}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 147}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30524}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30683}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5346}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 17977}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19914}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops5}, .v = {11, (char*)&bytesprops6}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18832}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3492}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31865}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x44, 0x63, 0x93, 0xf2, 0x99}; - uint8_t byteswillprops1[] = {0x19, 0x8, 0x2d, 0x7f, 0x42, 0x48, 0x40, 0x7d, 0xbb, 0xda, 0xa2, 0xd5, 0x86}; - uint8_t byteswillprops2[] = {0xa, 0x31, 0x62, 0xd9, 0x3a, 0x62, 0x6d, 0x57, 0xca, - 0x5f, 0x6a, 0x4d, 0xdf, 0x9d, 0xa2, 0x18, 0x3, 0xa8}; - uint8_t byteswillprops3[] = {0xcc, 0x7a, 0x7, 0x6e}; - uint8_t byteswillprops4[] = {0xeb, 0x95, 0xa2, 0x21, 0x4, 0xf4, 0x20, 0xcf, 0xaa, 0xdd, 0xb9, 0xee, 0x65, 0xae, - 0xa7, 0x3a, 0x6e, 0x7d, 0x41, 0x7e, 0xac, 0xff, 0x2a, 0xa5, 0x0, 0x83, 0x80, 0x61}; - uint8_t byteswillprops5[] = {0x25}; - uint8_t byteswillprops6[] = {0x14, 0xbf, 0x59, 0x8d, 0x39, 0xaa, 0x6d}; - uint8_t byteswillprops7[] = {0xbe, 0xcd, 0x3b, 0x39, 0x3f, 0x8b, 0xb2, 0xb9, 0x16, 0x1a, 0xc9, 0x7}; - uint8_t byteswillprops8[] = {0xce}; - uint8_t byteswillprops9[] = {0x2d, 0x1a, 0x95, 0xe2, 0xde}; + uint8_t byteswillprops0[] = {0x4, 0x28, 0xb8, 0x71, 0x8e, 0xf8, 0x4d, 0xa, 0xe7, 0xc5, + 0x5, 0x91, 0xa6, 0x57, 0x67, 0x36, 0xec, 0xfe, 0x6c}; + uint8_t byteswillprops1[] = {0x20, 0xd4, 0x20, 0xb5, 0x34, 0xb5, 0xb7, 0xb1, 0x99, 0x38}; + uint8_t byteswillprops2[] = {0xf9, 0x49, 0x37, 0x7a, 0xc0, 0xa0, 0x8b, 0x8f, 0x79, 0x5b, 0x17, 0xf2, 0xd1}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 100}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8296}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24666}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30525}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26970}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26971}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5356}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5790}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&byteswillprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&byteswillprops9}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9880}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24326}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31128}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24979}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops2}}}, }; - lwmqtt_properties_t willprops = {24, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x76, 0x3c, 0x33, 0x3f, 0x29, 0xa1}; - lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xca, 0x39, 0x93, 0xa4, 0x5d, 0xe9, 0xdb, 0xc9, - 0x46, 0x92, 0x6f, 0x78, 0x29, 0x78, 0x61}; + lwmqtt_properties_t willprops = {8, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x51, 0x26, 0xc7, 0x73, 0xa3, 0x2c, 0x91, 0x50, 0x6b, 0xaa, 0xd4, 0xd, 0x1, 0xd2, 0x49}; + lwmqtt_string_t will_topic = {15, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x2f, 0x79, 0x30, 0xa, 0xde, 0xdd, 0xb2, 0xe, + 0xf1, 0xd3, 0x64, 0xde, 0xd3, 0x30, 0x62}; lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS0; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = false; - opts.keep_alive = 31959; - uint8_t client_id_bytes[] = {0x4b, 0xb5}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.keep_alive = 190; + uint8_t client_id_bytes[] = {0x36, 0x59, 0xbc, 0xaf, 0xe5, 0x4e, 0x9c, 0xa8, 0x99, 0x56, 0x1c}; + lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x35, 0xbd, 0xe5}; - lwmqtt_string_t username = {3, (char*)&username_bytes}; - opts.username = username; - uint8_t password_bytes[] = {0xe, 0xe5, 0x1a, 0xcf, 0xc4, 0xb5, 0x7c, 0x36, 0xf2, 0xc0, 0x40}; - lwmqtt_string_t password = {11, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x94, 0xcb, 0xf7, 0x28, 0x1e, 0xfd, 0x6d, 0x3f, 0xac, 0xf6, 0x5d, 0x66, + 0x96, 0x57, 0x57, 0xa2, 0x89, 0xf5, 0x9, 0xff, 0xf3, 0x1a, 0x7d}; + lwmqtt_string_t password = {23, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -12658,155 +11945,105 @@ TEST(Connect5QCTest, Encode19) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "$\DC3o!\SI\253}\212\230\FS`\217X\171[", _password = Just "u", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS1, _willTopic = "\SOH$\ETB\192\157\196En", _willMsg = -// "\215\209\DLE\STX\164!\185\142\223\197\154\"\159\249\167,[\130", _willProps = [PropResponseInformation -// "X\203\245\ETX\160\216$T\219\195\ETB\193\226$\226\t\nKAcO\175\191\142\ACK\DC45\177]",PropWildcardSubscriptionAvailable -// 17,PropSubscriptionIdentifierAvailable 13,PropSharedSubscriptionAvailable 69,PropMessageExpiryInterval -// 3564,PropRequestResponseInformation 11,PropRetainAvailable 134,PropServerReference -// "\ETB\224A\152\215\RS\SO",PropSharedSubscriptionAvailable 37,PropRequestProblemInformation -// 119,PropSubscriptionIdentifierAvailable 218,PropResponseTopic "\159W\b\243",PropRequestResponseInformation -// 83,PropMessageExpiryInterval 11545,PropWildcardSubscriptionAvailable 245,PropPayloadFormatIndicator -// 154,PropMaximumQoS 150,PropSubscriptionIdentifier 22,PropServerKeepAlive 19385,PropWildcardSubscriptionAvailable -// 14,PropServerReference "\230",PropTopicAliasMaximum 19038]}), _cleanSession = True, _keepAlive = 14833, _connID = -// "\ETX@W\177\213>\v\227\232\224C\r\156\220j\DC4\170\177g\190-&\193", _properties = [PropTopicAlias -// 5177,PropServerKeepAlive 10636,PropAuthenticationMethod -// "\139\ETB\255\239\DLEL\180m\163I\SYN\233\SI\GS\CAN\155]p3\243\220\&8\243\b\192\SI&B",PropReasonString -// "J\138\STX\NAKz\207\&5\191\b\SUB\163\246R\US\135\211k\DC2)6[",PropMessageExpiryInterval 13679,PropReceiveMaximum -// 379,PropSubscriptionIdentifier 6,PropMessageExpiryInterval 28433,PropSubscriptionIdentifier -// 10,PropAssignedClientIdentifier "\148\177\154",PropReasonString "+\NULN\159\154R2\155R\170\FS",PropServerReference -// "4!+\178\141+\186\&5~\220F\134\GSUH\166\132\171aH",PropAuthenticationMethod -// "\250\209?\194\195\EMzH\224M\182\131\GS\\",PropSharedSubscriptionAvailable 22,PropPayloadFormatIndicator -// 213,PropResponseTopic "e",PropMessageExpiryInterval 30484,PropRequestProblemInformation -// 196,PropPayloadFormatIndicator 191,PropServerReference "\254\216\ACK\159\156\187\255!\234\NUL\r",PropReasonString -// "9Q\r\239\f",PropResponseTopic -// "bR\154\214v\148\139\252\153\225\128\\L\143\131\ESC\f\220\225\238\&8\ETB\201",PropWillDelayInterval -// 18510,PropMessageExpiryInterval 19228]} -TEST(Connect5QCTest, Encode20) { +// ConnectRequest {_username = Just "\DC4d\128<~\133\193\US", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "#\232\214h;\148\233\ESC\f\238c\v*\178\EM\DC2qs", _willMsg = +// "\250\"\228J*O\RS\174IQV(\146\131\255", _willProps = [PropSubscriptionIdentifier 12,PropReceiveMaximum +// 25475,PropRequestProblemInformation 241,PropRequestProblemInformation 120,PropServerReference +// "\178\219\192f\198F\206\185V\210\185X\161\250\165\SUB\210sG\ETB\216\219l",PropRequestProblemInformation +// 149,PropAssignedClientIdentifier +// "\STX^G\144\162\173\131y\216\161h\t\189\132\&8\182\&63+IC\b7\255",PropSubscriptionIdentifier +// 10,PropRequestResponseInformation 176,PropSubscriptionIdentifierAvailable 247,PropAuthenticationMethod +// "\138",PropServerReference +// "\176\178]\142\183v\234\b\178\216(\249\144\r\182\219.\161\191C",PropSubscriptionIdentifierAvailable +// 6,PropSessionExpiryInterval 6630,PropCorrelationData +// "\231pU\204C\DLEV\246=\139\210xt\202\230\DLEk\249|R\n\168\EM\238:\EM\DC4",PropResponseTopic +// "\163\167\190\f\232g5\211_\250\225\SO\232\248V\213\239\222\156\129\reC\247\174\162\138\SIf\175",PropTopicAliasMaximum +// 11311]}), _cleanSession = True, _keepAlive = 11426, _connID = "\204\182", _properties = +// [PropWildcardSubscriptionAvailable 241,PropAuthenticationMethod +// "\171\169\231L\227\ETX\168\184\157x\242\128\171\246\130\bT'!\134",PropTopicAlias 31140]} +TEST(Connect5QCTest, Encode21) { uint8_t pkt[] = { - 0x10, 0x8e, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x39, 0xf1, 0xd5, 0x1, 0x23, 0x14, 0x39, 0x13, - 0x29, 0x8c, 0x15, 0x0, 0x1c, 0x8b, 0x17, 0xff, 0xef, 0x10, 0x4c, 0xb4, 0x6d, 0xa3, 0x49, 0x16, 0xe9, 0xf, 0x1d, - 0x18, 0x9b, 0x5d, 0x70, 0x33, 0xf3, 0xdc, 0x38, 0xf3, 0x8, 0xc0, 0xf, 0x26, 0x42, 0x1f, 0x0, 0x15, 0x4a, 0x8a, - 0x2, 0x15, 0x7a, 0xcf, 0x35, 0xbf, 0x8, 0x1a, 0xa3, 0xf6, 0x52, 0x1f, 0x87, 0xd3, 0x6b, 0x12, 0x29, 0x36, 0x5b, - 0x2, 0x0, 0x0, 0x35, 0x6f, 0x21, 0x1, 0x7b, 0xb, 0x6, 0x2, 0x0, 0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b, 0x41, 0x63, 0x4f, 0xaf, 0xbf, 0x8e, 0x6, 0x14, 0x35, 0xb1, - 0x5d, 0x28, 0x11, 0x29, 0xd, 0x2a, 0x45, 0x2, 0x0, 0x0, 0xd, 0xec, 0x19, 0xb, 0x25, 0x86, 0x1c, 0x0, 0x7, - 0x17, 0xe0, 0x41, 0x98, 0xd7, 0x1e, 0xe, 0x2a, 0x25, 0x17, 0x77, 0x29, 0xda, 0x8, 0x0, 0x4, 0x9f, 0x57, 0x8, - 0xf3, 0x19, 0x53, 0x2, 0x0, 0x0, 0x2d, 0x19, 0x28, 0xf5, 0x1, 0x9a, 0x24, 0x96, 0xb, 0x16, 0x13, 0x4b, 0xb9, - 0x28, 0xe, 0x1c, 0x0, 0x1, 0xe6, 0x22, 0x4a, 0x5e, 0x0, 0x8, 0x1, 0x24, 0x17, 0xc0, 0x9d, 0xc4, 0x45, 0x6e, - 0x0, 0x12, 0xd7, 0xd1, 0x10, 0x2, 0xa4, 0x21, 0xb9, 0x8e, 0xdf, 0xc5, 0x9a, 0x22, 0x9f, 0xf9, 0xa7, 0x2c, 0x5b, - 0x82, 0x0, 0xf, 0x24, 0x13, 0x6f, 0x21, 0xf, 0xfd, 0x7d, 0xd4, 0xe6, 0x1c, 0x60, 0xd9, 0x58, 0xab, 0x5b, 0x0, - 0x1, 0x75}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x8b, 0x17, 0xff, 0xef, 0x10, 0x4c, 0xb4, 0x6d, 0xa3, 0x49, 0x16, 0xe9, 0xf, 0x1d, - 0x18, 0x9b, 0x5d, 0x70, 0x33, 0xf3, 0xdc, 0x38, 0xf3, 0x8, 0xc0, 0xf, 0x26, 0x42}; - uint8_t bytesprops1[] = {0x4a, 0x8a, 0x2, 0x15, 0x7a, 0xcf, 0x35, 0xbf, 0x8, 0x1a, 0xa3, - 0xf6, 0x52, 0x1f, 0x87, 0xd3, 0x6b, 0x12, 0x29, 0x36, 0x5b}; - uint8_t bytesprops2[] = {0x94, 0xb1, 0x9a}; - uint8_t bytesprops3[] = {0x2b, 0x0, 0x4e, 0x9f, 0x9a, 0x52, 0x32, 0x9b, 0x52, 0xaa, 0x1c}; - uint8_t bytesprops4[] = {0x34, 0x21, 0x2b, 0xb2, 0x8d, 0x2b, 0xba, 0x35, 0x7e, 0xdc, - 0x46, 0x86, 0x1d, 0x55, 0x48, 0xa6, 0x84, 0xab, 0x61, 0x48}; - uint8_t bytesprops5[] = {0xfa, 0xd1, 0x3f, 0xc2, 0xc3, 0x19, 0x7a, 0x48, 0xe0, 0x4d, 0xb6, 0x83, 0x1d, 0x5c}; - uint8_t bytesprops6[] = {0x65}; - uint8_t bytesprops7[] = {0xfe, 0xd8, 0x6, 0x9f, 0x9c, 0xbb, 0xff, 0x21, 0xea, 0x0, 0xd}; - uint8_t bytesprops8[] = {0x39, 0x51, 0xd, 0xef, 0xc}; - uint8_t bytesprops9[] = {0x62, 0x52, 0x9a, 0xd6, 0x76, 0x94, 0x8b, 0xfc, 0x99, 0xe1, 0x80, 0x5c, - 0x4c, 0x8f, 0x83, 0x1b, 0xc, 0xdc, 0xe1, 0xee, 0x38, 0x17, 0xc9}; + 0x10, 0x86, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0x2c, 0xa2, 0x1c, 0x28, 0xf1, 0x15, 0x0, 0x14, + 0xab, 0xa9, 0xe7, 0x4c, 0xe3, 0x3, 0xa8, 0xb8, 0x9d, 0x78, 0xf2, 0x80, 0xab, 0xf6, 0x82, 0x8, 0x54, 0x27, 0x21, + 0x86, 0x23, 0x79, 0xa4, 0x0, 0x2, 0xcc, 0xb6, 0xaa, 0x1, 0xb, 0xc, 0x21, 0x63, 0x83, 0x17, 0xf1, 0x17, 0x78, + 0x1c, 0x0, 0x17, 0xb2, 0xdb, 0xc0, 0x66, 0xc6, 0x46, 0xce, 0xb9, 0x56, 0xd2, 0xb9, 0x58, 0xa1, 0xfa, 0xa5, 0x1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0xc1, 0x1f}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xab, 0xa9, 0xe7, 0x4c, 0xe3, 0x3, 0xa8, 0xb8, 0x9d, 0x78, + 0xf2, 0x80, 0xab, 0xf6, 0x82, 0x8, 0x54, 0x27, 0x21, 0x86}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5177}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10636}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13679}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 379}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28433}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30484}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18510}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19228}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31140}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x58, 0xcb, 0xf5, 0x3, 0xa0, 0xd8, 0x24, 0x54, 0xdb, 0xc3, 0x17, 0xc1, 0xe2, 0x24, 0xe2, - 0x9, 0xa, 0x4b, 0x41, 0x63, 0x4f, 0xaf, 0xbf, 0x8e, 0x6, 0x14, 0x35, 0xb1, 0x5d}; - uint8_t byteswillprops1[] = {0x17, 0xe0, 0x41, 0x98, 0xd7, 0x1e, 0xe}; - uint8_t byteswillprops2[] = {0x9f, 0x57, 0x8, 0xf3}; - uint8_t byteswillprops3[] = {0xe6}; + uint8_t byteswillprops0[] = {0xb2, 0xdb, 0xc0, 0x66, 0xc6, 0x46, 0xce, 0xb9, 0x56, 0xd2, 0xb9, 0x58, + 0xa1, 0xfa, 0xa5, 0x1a, 0xd2, 0x73, 0x47, 0x17, 0xd8, 0xdb, 0x6c}; + uint8_t byteswillprops1[] = {0x2, 0x5e, 0x47, 0x90, 0xa2, 0xad, 0x83, 0x79, 0xd8, 0xa1, 0x68, 0x9, + 0xbd, 0x84, 0x38, 0xb6, 0x36, 0x33, 0x2b, 0x49, 0x43, 0x8, 0x37, 0xff}; + uint8_t byteswillprops2[] = {0x8a}; + uint8_t byteswillprops3[] = {0xb0, 0xb2, 0x5d, 0x8e, 0xb7, 0x76, 0xea, 0x8, 0xb2, 0xd8, + 0x28, 0xf9, 0x90, 0xd, 0xb6, 0xdb, 0x2e, 0xa1, 0xbf, 0x43}; + uint8_t byteswillprops4[] = {0xe7, 0x70, 0x55, 0xcc, 0x43, 0x10, 0x56, 0xf6, 0x3d, 0x8b, 0xd2, 0x78, 0x74, 0xca, + 0xe6, 0x10, 0x6b, 0xf9, 0x7c, 0x52, 0xa, 0xa8, 0x19, 0xee, 0x3a, 0x19, 0x14}; + uint8_t byteswillprops5[] = {0xa3, 0xa7, 0xbe, 0xc, 0xe8, 0x67, 0x35, 0xd3, 0x5f, 0xfa, + 0xe1, 0xe, 0xe8, 0xf8, 0x56, 0xd5, 0xef, 0xde, 0x9c, 0x81, + 0xd, 0x65, 0x43, 0xf7, 0xae, 0xa2, 0x8a, 0xf, 0x66, 0xaf}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 69}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3564}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 134}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {7, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11545}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19385}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19038}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25475}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 120}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 149}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 176}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6630}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11311}}, }; - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x1, 0x24, 0x17, 0xc0, 0x9d, 0xc4, 0x45, 0x6e}; - lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd7, 0xd1, 0x10, 0x2, 0xa4, 0x21, 0xb9, 0x8e, 0xdf, - 0xc5, 0x9a, 0x22, 0x9f, 0xf9, 0xa7, 0x2c, 0x5b, 0x82}; - lwmqtt_string_t will_payload = {18, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {17, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x23, 0xe8, 0xd6, 0x68, 0x3b, 0x94, 0xe9, 0x1b, 0xc, + 0xee, 0x63, 0xb, 0x2a, 0xb2, 0x19, 0x12, 0x71, 0x73}; + lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xfa, 0x22, 0xe4, 0x4a, 0x2a, 0x4f, 0x1e, 0xae, + 0x49, 0x51, 0x56, 0x28, 0x92, 0x83, 0xff}; + lwmqtt_string_t will_payload = {15, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; - will.retained = true; + will.retained = false; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 14833; - uint8_t client_id_bytes[] = {0x3, 0x40, 0x57, 0xb1, 0xd5, 0x3e, 0xb, 0xe3, 0xe8, 0xe0, 0x43, 0xd, - 0x9c, 0xdc, 0x6a, 0x14, 0xaa, 0xb1, 0x67, 0xbe, 0x2d, 0x26, 0xc1}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 11426; + uint8_t client_id_bytes[] = {0xcc, 0xb6}; + lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x24, 0x13, 0x6f, 0x21, 0xf, 0xfd, 0x7d, 0xd4, 0xe6, 0x1c, 0x60, 0xd9, 0x58, 0xab, 0x5b}; - lwmqtt_string_t username = {15, (char*)&username_bytes}; + uint8_t username_bytes[] = {0x14, 0x64, 0x80, 0x3c, 0x7e, 0x85, 0xc1, 0x1f}; + lwmqtt_string_t username = {8, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x75}; - lwmqtt_string_t password = {1, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -12815,149 +12052,193 @@ TEST(Connect5QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\vA%3\NAK\141\215\DC1\202\232\133\157m&\195\DLE\177S\169-s\174ot\177\US\t\176", -// _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = -// "\168\SO\185\228vJA\194DR\140\201\EOT\155\ETB!", _willMsg = "a\EM\252\SYNH\190\200 B\143\EOT\ETXl' \174\145\159n", -// _willProps = [PropReasonString -// "\DC3\255\206k\133-D\SYN39\212\\\242iul\tw\239Tn\227I\251R\233Y|\216",PropRetainAvailable -// 252,PropWildcardSubscriptionAvailable 49,PropSubscriptionIdentifier 1,PropTopicAlias 562,PropAuthenticationData -// "\248v4\196\DC2\211^G\189[\178\n\255\148",PropUserProperty -// "R\DC4\176\244\&13a\237\140\214\216:\171\136n\202\170\213\ETB\f%" -// "\195\149J\141RA\209E;H\176\134\179\209\156\164\197\229=<\129\DC4",PropReasonString -// "\DC34\NUL<\245\177\164\CAN?\255nK.[\153\201\233\242\220\135\160\198\149\169",PropTopicAliasMaximum -// 29408,PropSessionExpiryInterval 21193,PropSubscriptionIdentifier 7,PropWildcardSubscriptionAvailable -// 147,PropSharedSubscriptionAvailable 26,PropReasonString "",PropServerKeepAlive 14535,PropWillDelayInterval -// 21614,PropRequestResponseInformation 161,PropAuthenticationData "",PropAuthenticationMethod -// "sV\187\173=\biD\168\181\r_\SO\167\230\208\232V{\254\177]",PropSharedSubscriptionAvailable -// 40,PropMessageExpiryInterval 13486,PropSubscriptionIdentifierAvailable 33]}), _cleanSession = True, _keepAlive = -// 28777, _connID = "+3\250\223\230[8\232\GS\FS\191\141\166\159\EOT", _properties = [PropWildcardSubscriptionAvailable -// 102,PropRequestResponseInformation 196,PropSubscriptionIdentifier 14,PropMessageExpiryInterval -// 15373,PropWillDelayInterval 5915,PropRequestProblemInformation 1,PropAuthenticationMethod -// "\FS\205",PropSubscriptionIdentifierAvailable 112,PropMessageExpiryInterval 14235,PropResponseTopic -// "\DLE\155y\190\200G\220H\248\200`5y\216\243\255\214&\170%\251\DC1\140&\247\249\129",PropServerKeepAlive -// 5011,PropRetainAvailable 132,PropSubscriptionIdentifier 6,PropSubscriptionIdentifier 28,PropTopicAliasMaximum -// 10090,PropSubscriptionIdentifierAvailable 185,PropSharedSubscriptionAvailable 254,PropSubscriptionIdentifierAvailable -// 93,PropTopicAlias 90,PropMessageExpiryInterval 1532,PropResponseInformation -// "\155\171\&5\210J\184K",PropServerKeepAlive 28224]} -TEST(Connect5QCTest, Encode21) { +// ConnectRequest {_username = Nothing, _password = Nothing, _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS0, _willTopic = "30\150m;\145\234\188\240\155\227p8<", _willMsg = "k\131\233ZIw", _willProps = [PropReasonString +// "\224oA\US0\179\133\211\236U\128~\145",PropMessageExpiryInterval 7572,PropUserProperty +// "\NUL~\160/\140-c\183\153\247\136j\EM\255\136\FS\141\EOT\161\208Ue" +// "\221\152\253?\ETXj\172\214\145\196\188\188l\190\230\196\ENQ\\V\166\203\247\221",PropSessionExpiryInterval +// 17732,PropContentType "IM",PropTopicAliasMaximum 8436,PropAuthenticationData "8\145\159\&2",PropMaximumQoS +// 146,PropAuthenticationData "\181(\171\201\171$\240*\173\223\189v7\217\159%ZU\DLE\EM\182_Dy",PropUserProperty +// "\167\223" "Un\219pa\230\tU\DEL\166\135\US\177\211R\196\225\&8",PropMessageExpiryInterval 25984,PropCorrelationData +// "\129\157u\211\197\211\&3|!o\147\156'\244\220",PropTopicAlias 24892,PropTopicAliasMaximum 30008,PropReceiveMaximum +// 4122,PropSharedSubscriptionAvailable 90,PropRequestProblemInformation 230,PropSubscriptionIdentifierAvailable +// 40,PropMessageExpiryInterval 17238,PropRequestProblemInformation 235,PropWildcardSubscriptionAvailable +// 218,PropSessionExpiryInterval 1537,PropContentType +// "\186P\224\158\141\135\t\GS\231\ETB\145B\186p\130c",PropTopicAliasMaximum 28928,PropUserProperty "\152\&2\220" +// "\231\141\238Xa\218\223 \132\187\249*\SO[",PropReceiveMaximum 30305,PropUserProperty +// "\234@\160\233\NUL\174r\176\225}\162\175z]00rs\227 \254\193\185" "_\232\186[1\142\FSd",PropReceiveMaximum 25770]}), +// _cleanSession = True, _keepAlive = 19711, _connID = "\STX\223\144\245\NAK\216/", _properties = +// [PropRequestResponseInformation 33,PropRetainAvailable 140,PropRequestResponseInformation +// 128,PropAuthenticationMethod +// "\ENQ\212,\245\246{\182\239\167v\192L9DB\146\152\v\246\&0\173c\233I\235\v\227\230\223",PropMessageExpiryInterval +// 4083,PropContentType "X\189\151 \177\t\158\146\166\192x+ \CAN\194\199\165BGg\170P",PropMaximumQoS 35,PropUserProperty +// "\DC13\ESC\236\187(\136" +// "\240\n)\ESC~\202\162\CAN\144\198\246\230HQ\SOH\138\&6\246\188i\147\133(\136p\130X",PropRequestResponseInformation +// 178,PropRequestProblemInformation 253,PropContentType +// "\t\134\147\242\144!\150\184\139E[\SOHUP\215\143V\211\178\ETX\DC4;S",PropTopicAlias 24281,PropSubscriptionIdentifier +// 12,PropServerReference "\186\235x",PropWillDelayInterval 26708,PropResponseInformation +// "N\173\NUL\132\128\SYN=\206\249\139\146\227\244q`\ETX3]",PropMessageExpiryInterval 11505,PropUserProperty +// "\170\172YF\197\140\EM\148\CAN\DC4\a\182/v\DC4\215\131\r\202\227\138S\183{m\194\245" +// "{\148\ESCm\186)\228\141c\195Xj4\245i\132\ACK!",PropAssignedClientIdentifier +// "\RS\236X\b\232W\191\RS\b\233}KW\152\225fm!PL\EM\250",PropSharedSubscriptionAvailable 158,PropMessageExpiryInterval +// 6848,PropResponseTopic "\142\129\190\156JY\226\EOT\SO\STXjnr"]} +TEST(Connect5QCTest, Encode22) { uint8_t pkt[] = { - 0x10, 0x8b, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8e, 0x70, 0x69, 0x63, 0x28, 0x66, 0x19, 0xc4, 0xb, - 0xe, 0x2, 0x0, 0x0, 0x3c, 0xd, 0x18, 0x0, 0x0, 0x17, 0x1b, 0x17, 0x1, 0x15, 0x0, 0x2, 0x1c, 0xcd, 0x29, - 0x70, 0x2, 0x0, 0x0, 0x37, 0x9b, 0x8, 0x0, 0x1b, 0x10, 0x9b, 0x79, 0xbe, 0xc8, 0x47, 0xdc, 0x48, 0xf8, 0xc8, - 0x60, 0x35, 0x79, 0xd8, 0xf3, 0xff, 0xd6, 0x26, 0xaa, 0x25, 0xfb, 0x11, 0x8c, 0x26, 0xf7, 0xf9, 0x81, 0x13, 0x13, - 0x93, 0x25, 0x84, 0xb, 0x6, 0xb, 0x1c, 0x22, 0x27, 0x6a, 0x29, 0xb9, 0x2a, 0xfe, 0x29, 0x5d, 0x23, 0x0, 0x5a, - 0x2, 0x0, 0x0, 0x5, 0xfc, 0x1a, 0x0, 0x7, 0x9b, 0xab, 0x35, 0xd2, 0x4a, 0xb8, 0x4b, 0x13, 0x6e, 0x40, 0x0, - 0xf, 0x2b, 0x33, 0xfa, 0xdf, 0xe6, 0x5b, 0x38, 0xe8, 0x1d, 0x1c, 0xbf, 0x8d, 0xa6, 0x9f, 0x4, 0xc5, 0x1, 0x1f, - 0x0, 0x1d, 0x13, 0xff, 0xce, 0x6b, 0x85, 0x2d, 0x44, 0x16, 0x33, 0x39, 0xd4, 0x5c, 0xf2, 0x69, 0x75, 0x6c, 0x9, - 0x77, 0xef, 0x54, 0x6e, 0xe3, 0x49, 0xfb, 0x52, 0xe9, 0x59, 0x7c, 0xd8, 0x25, 0xfc, 0x28, 0x31, 0xb, 0x1, 0x23, - 0x2, 0x32, 0x16, 0x0, 0xe, 0xf8, 0x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0xae, 0x91, 0x9f, 0x6e, 0x0, 0x1c, 0xb, 0x41, 0x25, 0x33, 0x15, 0x8d, 0xd7, 0x11, 0xca, 0xe8, - 0x85, 0x9d, 0x6d, 0x26, 0xc3, 0x10, 0xb1, 0x53, 0xa9, 0x2d, 0x73, 0xae, 0x6f, 0x74, 0xb1, 0x1f, 0x9, 0xb0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1c, 0xcd}; - uint8_t bytesprops1[] = {0x10, 0x9b, 0x79, 0xbe, 0xc8, 0x47, 0xdc, 0x48, 0xf8, 0xc8, 0x60, 0x35, 0x79, 0xd8, - 0xf3, 0xff, 0xd6, 0x26, 0xaa, 0x25, 0xfb, 0x11, 0x8c, 0x26, 0xf7, 0xf9, 0x81}; - uint8_t bytesprops2[] = {0x9b, 0xab, 0x35, 0xd2, 0x4a, 0xb8, 0x4b}; + 0x10, 0xe1, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x26, 0x4c, 0xff, 0x97, 0x2, 0x19, 0x21, 0x25, 0x8c, + 0x19, 0x80, 0x15, 0x0, 0x1d, 0x5, 0xd4, 0x2c, 0xf5, 0xf6, 0x7b, 0xb6, 0xef, 0xa7, 0x76, 0xc0, 0x4c, 0x39, 0x44, + 0x42, 0x92, 0x98, 0xb, 0xf6, 0x30, 0xad, 0x63, 0xe9, 0x49, 0xeb, 0xb, 0xe3, 0xe6, 0xdf, 0x2, 0x0, 0x0, 0xf, + 0xf3, 0x3, 0x0, 0x16, 0x58, 0xbd, 0x97, 0x20, 0xb1, 0x9, 0x9e, 0x92, 0xa6, 0xc0, 0x78, 0x2b, 0x20, 0x18, 0xc2, + 0xc7, 0xa5, 0x42, 0x47, 0x67, 0xaa, 0x50, 0x24, 0x23, 0x26, 0x0, 0x7, 0x11, 0x33, 0x1b, 0xec, 0xbb, 0x28, 0x88, + 0x0, 0x1b, 0xf0, 0xa, 0x29, 0x1b, 0x7e, 0xca, 0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0x38, 0x21, 0x10, 0x1a, 0x2a, 0x5a, 0x17, 0xe6, 0x29, 0x28, 0x2, 0x0, 0x0, 0x43, 0x56, 0x17, + 0xeb, 0x28, 0xda, 0x11, 0x0, 0x0, 0x6, 0x1, 0x3, 0x0, 0x10, 0xba, 0x50, 0xe0, 0x9e, 0x8d, 0x87, 0x9, 0x1d, + 0xe7, 0x17, 0x91, 0x42, 0xba, 0x70, 0x82, 0x63, 0x22, 0x71, 0x0, 0x26, 0x0, 0x3, 0x98, 0x32, 0xdc, 0x0, 0xe, + 0xe7, 0x8d, 0xee, 0x58, 0x61, 0xda, 0xdf, 0x20, 0x84, 0xbb, 0xf9, 0x2a, 0xe, 0x5b, 0x21, 0x76, 0x61, 0x26, 0x0, + 0x17, 0xea, 0x40, 0xa0, 0xe9, 0x0, 0xae, 0x72, 0xb0, 0xe1, 0x7d, 0xa2, 0xaf, 0x7a, 0x5d, 0x30, 0x30, 0x72, 0x73, + 0xe3, 0x20, 0xfe, 0xc1, 0xb9, 0x0, 0x8, 0x5f, 0xe8, 0xba, 0x5b, 0x31, 0x8e, 0x1c, 0x64, 0x21, 0x64, 0xaa, 0x0, + 0xe, 0x33, 0x30, 0x96, 0x6d, 0x3b, 0x91, 0xea, 0xbc, 0xf0, 0x9b, 0xe3, 0x70, 0x38, 0x3c, 0x0, 0x6, 0x6b, 0x83, + 0xe9, 0x5a, 0x49, 0x77}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x5, 0xd4, 0x2c, 0xf5, 0xf6, 0x7b, 0xb6, 0xef, 0xa7, 0x76, 0xc0, 0x4c, 0x39, 0x44, 0x42, + 0x92, 0x98, 0xb, 0xf6, 0x30, 0xad, 0x63, 0xe9, 0x49, 0xeb, 0xb, 0xe3, 0xe6, 0xdf}; + uint8_t bytesprops1[] = {0x58, 0xbd, 0x97, 0x20, 0xb1, 0x9, 0x9e, 0x92, 0xa6, 0xc0, 0x78, + 0x2b, 0x20, 0x18, 0xc2, 0xc7, 0xa5, 0x42, 0x47, 0x67, 0xaa, 0x50}; + uint8_t bytesprops3[] = {0xf0, 0xa, 0x29, 0x1b, 0x7e, 0xca, 0xa2, 0x18, 0x90, 0xc6, 0xf6, 0xe6, 0x48, 0x51, + 0x1, 0x8a, 0x36, 0xf6, 0xbc, 0x69, 0x93, 0x85, 0x28, 0x88, 0x70, 0x82, 0x58}; + uint8_t bytesprops2[] = {0x11, 0x33, 0x1b, 0xec, 0xbb, 0x28, 0x88}; + uint8_t bytesprops4[] = {0x9, 0x86, 0x93, 0xf2, 0x90, 0x21, 0x96, 0xb8, 0x8b, 0x45, 0x5b, 0x1, + 0x55, 0x50, 0xd7, 0x8f, 0x56, 0xd3, 0xb2, 0x3, 0x14, 0x3b, 0x53}; + uint8_t bytesprops5[] = {0xba, 0xeb, 0x78}; + uint8_t bytesprops6[] = {0x4e, 0xad, 0x0, 0x84, 0x80, 0x16, 0x3d, 0xce, 0xf9, + 0x8b, 0x92, 0xe3, 0xf4, 0x71, 0x60, 0x3, 0x33, 0x5d}; + uint8_t bytesprops8[] = {0x7b, 0x94, 0x1b, 0x6d, 0xba, 0x29, 0xe4, 0x8d, 0x63, + 0xc3, 0x58, 0x6a, 0x34, 0xf5, 0x69, 0x84, 0x6, 0x21}; + uint8_t bytesprops7[] = {0xaa, 0xac, 0x59, 0x46, 0xc5, 0x8c, 0x19, 0x94, 0x18, 0x14, 0x7, 0xb6, 0x2f, 0x76, + 0x14, 0xd7, 0x83, 0xd, 0xca, 0xe3, 0x8a, 0x53, 0xb7, 0x7b, 0x6d, 0xc2, 0xf5}; + uint8_t bytesprops9[] = {0x1e, 0xec, 0x58, 0x8, 0xe8, 0x57, 0xbf, 0x1e, 0x8, 0xe9, 0x7d, + 0x4b, 0x57, 0x98, 0xe1, 0x66, 0x6d, 0x21, 0x50, 0x4c, 0x19, 0xfa}; + uint8_t bytesprops10[] = {0x8e, 0x81, 0xbe, 0x9c, 0x4a, 0x59, 0xe2, 0x4, 0xe, 0x2, 0x6a, 0x6e, 0x72}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15373}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5915}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14235}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 5011}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10090}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 90}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1532}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {7, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28224}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4083}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {22, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops2}, .v = {27, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 253}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24281}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26708}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11505}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops7}, .v = {18, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {22, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6848}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops10}}}, }; lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x13, 0xff, 0xce, 0x6b, 0x85, 0x2d, 0x44, 0x16, 0x33, 0x39, 0xd4, 0x5c, 0xf2, 0x69, 0x75, - 0x6c, 0x9, 0x77, 0xef, 0x54, 0x6e, 0xe3, 0x49, 0xfb, 0x52, 0xe9, 0x59, 0x7c, 0xd8}; - uint8_t byteswillprops1[] = {0xf8, 0x76, 0x34, 0xc4, 0x12, 0xd3, 0x5e, 0x47, 0xbd, 0x5b, 0xb2, 0xa, 0xff, 0x94}; - uint8_t byteswillprops3[] = {0xc3, 0x95, 0x4a, 0x8d, 0x52, 0x41, 0xd1, 0x45, 0x3b, 0x48, 0xb0, - 0x86, 0xb3, 0xd1, 0x9c, 0xa4, 0xc5, 0xe5, 0x3d, 0x3c, 0x81, 0x14}; - uint8_t byteswillprops2[] = {0x52, 0x14, 0xb0, 0xf4, 0x31, 0x33, 0x61, 0xed, 0x8c, 0xd6, 0xd8, - 0x3a, 0xab, 0x88, 0x6e, 0xca, 0xaa, 0xd5, 0x17, 0xc, 0x25}; - uint8_t byteswillprops4[] = {0x13, 0x34, 0x0, 0x3c, 0xf5, 0xb1, 0xa4, 0x18, 0x3f, 0xff, 0x6e, 0x4b, - 0x2e, 0x5b, 0x99, 0xc9, 0xe9, 0xf2, 0xdc, 0x87, 0xa0, 0xc6, 0x95, 0xa9}; - uint8_t byteswillprops5[] = {0}; - uint8_t byteswillprops6[] = {0}; - uint8_t byteswillprops7[] = {0x73, 0x56, 0xbb, 0xad, 0x3d, 0x8, 0x69, 0x44, 0xa8, 0xb5, 0xd, - 0x5f, 0xe, 0xa7, 0xe6, 0xd0, 0xe8, 0x56, 0x7b, 0xfe, 0xb1, 0x5d}; + uint8_t byteswillprops0[] = {0xe0, 0x6f, 0x41, 0x1f, 0x30, 0xb3, 0x85, 0xd3, 0xec, 0x55, 0x80, 0x7e, 0x91}; + uint8_t byteswillprops2[] = {0xdd, 0x98, 0xfd, 0x3f, 0x3, 0x6a, 0xac, 0xd6, 0x91, 0xc4, 0xbc, 0xbc, + 0x6c, 0xbe, 0xe6, 0xc4, 0x5, 0x5c, 0x56, 0xa6, 0xcb, 0xf7, 0xdd}; + uint8_t byteswillprops1[] = {0x0, 0x7e, 0xa0, 0x2f, 0x8c, 0x2d, 0x63, 0xb7, 0x99, 0xf7, 0x88, + 0x6a, 0x19, 0xff, 0x88, 0x1c, 0x8d, 0x4, 0xa1, 0xd0, 0x55, 0x65}; + uint8_t byteswillprops3[] = {0x49, 0x4d}; + uint8_t byteswillprops4[] = {0x38, 0x91, 0x9f, 0x32}; + uint8_t byteswillprops5[] = {0xb5, 0x28, 0xab, 0xc9, 0xab, 0x24, 0xf0, 0x2a, 0xad, 0xdf, 0xbd, 0x76, + 0x37, 0xd9, 0x9f, 0x25, 0x5a, 0x55, 0x10, 0x19, 0xb6, 0x5f, 0x44, 0x79}; + uint8_t byteswillprops7[] = {0x55, 0x6e, 0xdb, 0x70, 0x61, 0xe6, 0x9, 0x55, 0x7f, + 0xa6, 0x87, 0x1f, 0xb1, 0xd3, 0x52, 0xc4, 0xe1, 0x38}; + uint8_t byteswillprops6[] = {0xa7, 0xdf}; + uint8_t byteswillprops8[] = {0x81, 0x9d, 0x75, 0xd3, 0xc5, 0xd3, 0x33, 0x7c, + 0x21, 0x6f, 0x93, 0x9c, 0x27, 0xf4, 0xdc}; + uint8_t byteswillprops9[] = {0xba, 0x50, 0xe0, 0x9e, 0x8d, 0x87, 0x9, 0x1d, + 0xe7, 0x17, 0x91, 0x42, 0xba, 0x70, 0x82, 0x63}; + uint8_t byteswillprops11[] = {0xe7, 0x8d, 0xee, 0x58, 0x61, 0xda, 0xdf, 0x20, 0x84, 0xbb, 0xf9, 0x2a, 0xe, 0x5b}; + uint8_t byteswillprops10[] = {0x98, 0x32, 0xdc}; + uint8_t byteswillprops13[] = {0x5f, 0xe8, 0xba, 0x5b, 0x31, 0x8e, 0x1c, 0x64}; + uint8_t byteswillprops12[] = {0xea, 0x40, 0xa0, 0xe9, 0x0, 0xae, 0x72, 0xb0, 0xe1, 0x7d, 0xa2, 0xaf, + 0x7a, 0x5d, 0x30, 0x30, 0x72, 0x73, 0xe3, 0x20, 0xfe, 0xc1, 0xb9}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 562}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7572}}, {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {21, (char*)&byteswillprops2}, .v = {22, (char*)&byteswillprops3}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29408}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21193}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 26}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14535}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 21614}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&byteswillprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13486}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 33}}, + .value = {.pair = {.k = {22, (char*)&byteswillprops1}, .v = {23, (char*)&byteswillprops2}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 17732}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8436}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {2, (char*)&byteswillprops6}, .v = {18, (char*)&byteswillprops7}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25984}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24892}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 30008}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4122}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17238}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 218}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1537}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28928}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {3, (char*)&byteswillprops10}, .v = {14, (char*)&byteswillprops11}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30305}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {23, (char*)&byteswillprops12}, .v = {8, (char*)&byteswillprops13}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25770}}, }; - lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa8, 0xe, 0xb9, 0xe4, 0x76, 0x4a, 0x41, 0xc2, - 0x44, 0x52, 0x8c, 0xc9, 0x4, 0x9b, 0x17, 0x21}; - lwmqtt_string_t will_topic = {16, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x61, 0x19, 0xfc, 0x16, 0x48, 0xbe, 0xc8, 0x20, 0x42, 0x8f, - 0x4, 0x3, 0x6c, 0x27, 0x20, 0xae, 0x91, 0x9f, 0x6e}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {28, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x33, 0x30, 0x96, 0x6d, 0x3b, 0x91, 0xea, 0xbc, 0xf0, 0x9b, 0xe3, 0x70, 0x38, 0x3c}; + lwmqtt_string_t will_topic = {14, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x6b, 0x83, 0xe9, 0x5a, 0x49, 0x77}; + lwmqtt_string_t will_payload = {6, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; - will.retained = false; + will.qos = LWMQTT_QOS0; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 28777; - uint8_t client_id_bytes[] = {0x2b, 0x33, 0xfa, 0xdf, 0xe6, 0x5b, 0x38, 0xe8, 0x1d, 0x1c, 0xbf, 0x8d, 0xa6, 0x9f, 0x4}; - lwmqtt_string_t client_id = {15, (char*)&client_id_bytes}; + opts.keep_alive = 19711; + uint8_t client_id_bytes[] = {0x2, 0xdf, 0x90, 0xf5, 0x15, 0xd8, 0x2f}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xb, 0x41, 0x25, 0x33, 0x15, 0x8d, 0xd7, 0x11, 0xca, 0xe8, 0x85, 0x9d, 0x6d, 0x26, - 0xc3, 0x10, 0xb1, 0x53, 0xa9, 0x2d, 0x73, 0xae, 0x6f, 0x74, 0xb1, 0x1f, 0x9, 0xb0}; - lwmqtt_string_t username = {28, (char*)&username_bytes}; - opts.username = username; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -12966,203 +12247,179 @@ TEST(Connect5QCTest, Encode21) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\154\187ln", _lastWill = Just (LastWill {_willRetain = True, -// _willQoS = QoS2, _willTopic = "\147\234\128\171\v\219\164\138\218W\166", _willMsg = -// "\210\254\161\ENQ\v\192\253\DLE\176\204-\222Uv\154m\FSi+", _willProps = [PropAuthenticationData -// "\133\184W\221\160:\250\209q\DELF",PropMessageExpiryInterval 30765,PropTopicAlias 6533]}), _cleanSession = True, -// _keepAlive = 23669, _connID = -// "$\237\&8\219\166I\143>\251N\190&hL\173\150*\131\212>\211\244\SI\149\243\SYN\179\154\EOT", _properties = -// [PropContentType "\ETX\255)\146\212\218E8\SIt\STX}\203\215\210\DC3\ETB\248\216!\202\169Z\233\151",PropTopicAlias -// 13785,PropRequestProblemInformation 107,PropAssignedClientIdentifier "G\161\SYN\168[\154\210\195f\233n'"]} -TEST(Connect5QCTest, Encode22) { - uint8_t pkt[] = {0x10, 0x99, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x76, 0x5c, 0x75, 0x30, 0x3, 0x0, - 0x19, 0x3, 0xff, 0x29, 0x92, 0xd4, 0xda, 0x45, 0x38, 0xf, 0x74, 0x2, 0x7d, 0xcb, 0xd7, 0xd2, - 0x13, 0x17, 0xf8, 0xd8, 0x21, 0xca, 0xa9, 0x5a, 0xe9, 0x97, 0x23, 0x35, 0xd9, 0x17, 0x6b, 0x12, - 0x0, 0xc, 0x47, 0xa1, 0x16, 0xa8, 0x5b, 0x9a, 0xd2, 0xc3, 0x66, 0xe9, 0x6e, 0x27, 0x0, 0x1d, - 0x24, 0xed, 0x38, 0xdb, 0xa6, 0x49, 0x8f, 0x3e, 0xfb, 0x4e, 0xbe, 0x26, 0x68, 0x4c, 0xad, 0x96, - 0x2a, 0x83, 0xd4, 0x3e, 0xd3, 0xf4, 0xf, 0x95, 0xf3, 0x16, 0xb3, 0x9a, 0x4, 0x16, 0x16, 0x0, - 0xb, 0x85, 0xb8, 0x57, 0xdd, 0xa0, 0x3a, 0xfa, 0xd1, 0x71, 0x7f, 0x46, 0x2, 0x0, 0x0, 0x78, - 0x2d, 0x23, 0x19, 0x85, 0x0, 0xb, 0x93, 0xea, 0x80, 0xab, 0xb, 0xdb, 0xa4, 0x8a, 0xda, 0x57, - 0xa6, 0x0, 0x13, 0xd2, 0xfe, 0xa1, 0x5, 0xb, 0xc0, 0xfd, 0x10, 0xb0, 0xcc, 0x2d, 0xde, 0x55, - 0x76, 0x9a, 0x6d, 0x1c, 0x69, 0x2b, 0x0, 0x4, 0x9a, 0xbb, 0x6c, 0x6e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x3, 0xff, 0x29, 0x92, 0xd4, 0xda, 0x45, 0x38, 0xf, 0x74, 0x2, 0x7d, 0xcb, - 0xd7, 0xd2, 0x13, 0x17, 0xf8, 0xd8, 0x21, 0xca, 0xa9, 0x5a, 0xe9, 0x97}; - uint8_t bytesprops1[] = {0x47, 0xa1, 0x16, 0xa8, 0x5b, 0x9a, 0xd2, 0xc3, 0x66, 0xe9, 0x6e, 0x27}; +// ConnectRequest {_username = Just "\237\&6f|\US#T\133\189\b", _password = Just +// "\NAK\150YWx\f\184\140\SO3\181\&0[\f\ETB", _lastWill = Nothing, _cleanSession = True, _keepAlive = 23584, _connID = " +// \149\136+\173Ve0s\240\142\225V]\231\US\208\&2\137:.~\229", _properties = []} +TEST(Connect5QCTest, Encode23) { + uint8_t pkt[] = {0x10, 0x41, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xc2, 0x5c, 0x20, 0x0, 0x0, 0x17, 0x20, 0x95, + 0x88, 0x2b, 0xad, 0x56, 0x65, 0x30, 0x73, 0xf0, 0x8e, 0xe1, 0x56, 0x5d, 0xe7, 0x1f, 0xd0, 0x32, 0x89, + 0x3a, 0x2e, 0x7e, 0xe5, 0x0, 0xa, 0xed, 0x36, 0x66, 0x7c, 0x1f, 0x23, 0x54, 0x85, 0xbd, 0x8, 0x0, + 0xf, 0x15, 0x96, 0x59, 0x57, 0x78, 0xc, 0xb8, 0x8c, 0xe, 0x33, 0xb5, 0x30, 0x5b, 0xc, 0x17}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13785}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops1}}}, - }; - - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; - lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x85, 0xb8, 0x57, 0xdd, 0xa0, 0x3a, 0xfa, 0xd1, 0x71, 0x7f, 0x46}; - - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30765}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6533}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t willprops = {3, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x93, 0xea, 0x80, 0xab, 0xb, 0xdb, 0xa4, 0x8a, 0xda, 0x57, 0xa6}; - lwmqtt_string_t will_topic = {11, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xd2, 0xfe, 0xa1, 0x5, 0xb, 0xc0, 0xfd, 0x10, 0xb0, 0xcc, - 0x2d, 0xde, 0x55, 0x76, 0x9a, 0x6d, 0x1c, 0x69, 0x2b}; - lwmqtt_string_t will_payload = {19, (char*)&will_payload_bytes}; - will.topic = will_topic; - will.payload = will_payload; - will.qos = LWMQTT_QOS2; - will.retained = true; - will.properties = willprops; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 23669; - uint8_t client_id_bytes[] = {0x24, 0xed, 0x38, 0xdb, 0xa6, 0x49, 0x8f, 0x3e, 0xfb, 0x4e, 0xbe, 0x26, 0x68, 0x4c, 0xad, - 0x96, 0x2a, 0x83, 0xd4, 0x3e, 0xd3, 0xf4, 0xf, 0x95, 0xf3, 0x16, 0xb3, 0x9a, 0x4}; - lwmqtt_string_t client_id = {29, (char*)&client_id_bytes}; + opts.keep_alive = 23584; + uint8_t client_id_bytes[] = {0x20, 0x95, 0x88, 0x2b, 0xad, 0x56, 0x65, 0x30, 0x73, 0xf0, 0x8e, 0xe1, + 0x56, 0x5d, 0xe7, 0x1f, 0xd0, 0x32, 0x89, 0x3a, 0x2e, 0x7e, 0xe5}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t password_bytes[] = {0x9a, 0xbb, 0x6c, 0x6e}; - lwmqtt_string_t password = {4, (char*)&password_bytes}; + uint8_t username_bytes[] = {0xed, 0x36, 0x66, 0x7c, 0x1f, 0x23, 0x54, 0x85, 0xbd, 0x8}; + lwmqtt_string_t username = {10, (char*)&username_bytes}; + opts.username = username; + uint8_t password_bytes[] = {0x15, 0x96, 0x59, 0x57, 0x78, 0xc, 0xb8, 0x8c, 0xe, 0x33, 0xb5, 0x30, 0x5b, 0xc, 0x17}; + lwmqtt_string_t password = {15, (char*)&password_bytes}; opts.password = password; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); + lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, NULL); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\143,\SOH\155g\228PV\DC2<\233\167\240`\US", _password = Just -// "e\nm=f\140\230Dl\161\225\170\162v\164\EOTc\207\195\255\131n$G\179w", _lastWill = Just (LastWill {_willRetain = -// False, _willQoS = QoS2, _willTopic = "\178\225\170J\183\NAK\128\201\233\247\215q\NAK\v\165A\US\228", _willMsg = -// "-\155\216\170\221I\188\147:\179\167:", _willProps = []}), _cleanSession = False, _keepAlive = 24031, _connID = -// "\SI5", _properties = [PropSharedSubscriptionAvailable 174,PropMaximumQoS 176,PropCorrelationData "\216\189j, -// i0djrea&|L<\194\r\190\229\239\174\253\193\GS",PropAssignedClientIdentifier -// "\ESC\234\207\&0kQky\146\132\177R\173C",PropResponseTopic "\fS~\173\230d -// \178\175\197\251K\161I$\226\148\ETB\237g\137~R\US",PropRequestResponseInformation 150,PropServerKeepAlive -// 20269,PropReceiveMaximum 13007,PropSharedSubscriptionAvailable 86,PropWildcardSubscriptionAvailable -// 86,PropSubscriptionIdentifier 9,PropSharedSubscriptionAvailable 61,PropSharedSubscriptionAvailable -// 165,PropWildcardSubscriptionAvailable 74,PropResponseInformation -// "\"<\192&\ENQ\253\215\137-\245\236\US\252`\184\&1\DC3V\t\130d\201\EOTj7",PropRetainAvailable 228,PropUserProperty -// "\SI\224j^J'\204e\214\181\137\162\185}\182\221\204P\179.H" -// "el\244\142B\137C}\CAN+6,\DEL;hg\234\226\151\237\&7\168",PropMaximumQoS 67,PropRequestProblemInformation -// 72,PropAuthenticationMethod "\200C\DLET\192\226h\134\167KO\ACK\132f\US\237",PropCorrelationData -// "\232\251\196\248nH\158\ENQ\192\129\STX\240\203\STX\137w\128\FS.\134Z\NAK\165x\229\"\203\DC3:",PropAuthenticationMethod -// "\159k\224\206\DC2\176\US\183,\216\&7\175\161\150/\227\&7\250s\201\128$K\249\239\151",PropAssignedClientIdentifier -// "\DEL6=\143\SI\246\a\163r\SOH\217\NUL\EMnd!",PropMessageExpiryInterval 25593,PropMaximumPacketSize -// 24532,PropRequestProblemInformation 63,PropSubscriptionIdentifierAvailable 47,PropReceiveMaximum -// 22000,PropMaximumPacketSize 7757,PropRetainAvailable 32]} -TEST(Connect5QCTest, Encode23) { +// ConnectRequest {_username = Just "Y\GS\153\146\134\165\&8^,k\\\EM\SYNh\207", _password = Just +// "D\149?\170\EOT\GSQ\216\139\168\210\247O\138\139[\237w\151\255Q{\"\145L~\172", _lastWill = Just (LastWill +// {_willRetain = True, _willQoS = QoS2, _willTopic = "}2\216h#\194\242\241G:\190{j\185\DC2\157}l", _willMsg = +// "D\196\243E\229\FS[+K\208\170=]o\152\NAKM\207\151\&8\188\CAN\234kd", _willProps = [PropMaximumPacketSize +// 13711,PropServerKeepAlive 18793,PropUserProperty "\223\SI\252\188\151" "\rr3\197",PropMessageExpiryInterval +// 4167,PropMessageExpiryInterval 614,PropSubscriptionIdentifierAvailable 52,PropAuthenticationData +// "\179\136\ENQ",PropAuthenticationData +// "\240}\150x\155\128\210\184\228\&4?\190\167\201r\138\&3\b",PropAuthenticationMethod " +// Wc\193\US",PropMessageExpiryInterval 9391,PropAssignedClientIdentifier +// "\225\246l\223\153\197\131$\STX\174\142J\177\147\174\144\NUL\186\243\160\238\212{\DC1\DC2\209H",PropWillDelayInterval +// 9240,PropSubscriptionIdentifier 30,PropRequestProblemInformation 126,PropServerReference +// ">\192\210\237",PropServerKeepAlive 14417,PropWildcardSubscriptionAvailable 12,PropSubscriptionIdentifier +// 17,PropMessageExpiryInterval 32500,PropTopicAlias 20005,PropCorrelationData "\203(\219\246",PropServerKeepAlive +// 6193]}), _cleanSession = True, _keepAlive = 21608, _connID = +// "\130&B\t\131\165\255\248=\203\140\NAK\165\235f\226JC\f\212<\181\191", _properties = [PropResponseTopic +// "\184t\FS\191a\ACK\171s\191\195\170",PropSubscriptionIdentifier 27,PropMessageExpiryInterval +// 29006,PropWildcardSubscriptionAvailable 211,PropMaximumQoS 66,PropServerKeepAlive 29972,PropServerKeepAlive +// 16839,PropMessageExpiryInterval 18851,PropMessageExpiryInterval 6917,PropMaximumQoS +// 144,PropRequestResponseInformation 177,PropWillDelayInterval 3086,PropMessageExpiryInterval +// 25623,PropAssignedClientIdentifier ":='\EM\229.\140NH\238X\202\232\128\243\193\FS;\222",PropServerKeepAlive +// 10186,PropServerReference "\172\139B\\&b\224\195\221\221p",PropRequestProblemInformation 255,PropReasonString +// "\159qa\254\164\202k\155\184\160\147@t"]} +TEST(Connect5QCTest, Encode24) { uint8_t pkt[] = { - 0x10, 0x8d, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xd4, 0x5d, 0xdf, 0xad, 0x2, 0x2a, 0xae, 0x24, 0xb0, - 0x9, 0x0, 0x19, 0xd8, 0xbd, 0x6a, 0x2c, 0x20, 0x69, 0x30, 0x64, 0x6a, 0x72, 0x65, 0x61, 0x26, 0x7c, 0x4c, 0x3c, - 0xc2, 0xd, 0xbe, 0xe5, 0xef, 0xae, 0xfd, 0xc1, 0x1d, 0x12, 0x0, 0xe, 0x1b, 0xea, 0xcf, 0x30, 0x6b, 0x51, 0x6b, - 0x79, 0x92, 0x84, 0xb1, 0x52, 0xad, 0x43, 0x8, 0x0, 0x18, 0xc, 0x53, 0x7e, 0xad, 0xe6, 0x64, 0x20, 0xb2, 0xaf, - 0xc5, 0xfb, 0x4b, 0xa1, 0x49, 0x24, 0xe2, 0x94, 0x17, 0xed, 0x67, 0x89, 0x7e, 0x52, 0x1f, 0x19, 0x96, 0x13, 0x4f, - 0x2d, 0x21, 0x32, 0xcf, 0x2a, 0x56, 0x28, 0x56, 0xb, 0x9, 0x2a, 0x3d, 0x2a, 0xa5, 0x28, 0x4a, 0x1a, 0x0, 0x19, - 0x22, 0x3c, 0xc0, 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 0x3f, - 0x29, 0x2f, 0x21, 0x55, 0xf0, 0x27, 0x0, 0x0, 0x1e, 0x4d, 0x25, 0x20, 0x0, 0x2, 0xf, 0x35, 0x0, 0x0, 0x12, - 0xb2, 0xe1, 0xaa, 0x4a, 0xb7, 0x15, 0x80, 0xc9, 0xe9, 0xf7, 0xd7, 0x71, 0x15, 0xb, 0xa5, 0x41, 0x1f, 0xe4, 0x0, - 0xc, 0x2d, 0x9b, 0xd8, 0xaa, 0xdd, 0x49, 0xbc, 0x93, 0x3a, 0xb3, 0xa7, 0x3a, 0x0, 0xf, 0x8f, 0x2c, 0x1, 0x9b, - 0x67, 0xe4, 0x50, 0x56, 0x12, 0x3c, 0xe9, 0xa7, 0xf0, 0x60, 0x1f, 0x0, 0x1a, 0x65, 0xa, 0x6d, 0x3d, 0x66, 0x8c, - 0xe6, 0x44, 0x6c, 0xa1, 0xe1, 0xaa, 0xa2, 0x76, 0xa4, 0x4, 0x63, 0xcf, 0xc3, 0xff, 0x83, 0x6e, 0x24, 0x47, 0xb3, - 0x77}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd8, 0xbd, 0x6a, 0x2c, 0x20, 0x69, 0x30, 0x64, 0x6a, 0x72, 0x65, 0x61, 0x26, - 0x7c, 0x4c, 0x3c, 0xc2, 0xd, 0xbe, 0xe5, 0xef, 0xae, 0xfd, 0xc1, 0x1d}; - uint8_t bytesprops1[] = {0x1b, 0xea, 0xcf, 0x30, 0x6b, 0x51, 0x6b, 0x79, 0x92, 0x84, 0xb1, 0x52, 0xad, 0x43}; - uint8_t bytesprops2[] = {0xc, 0x53, 0x7e, 0xad, 0xe6, 0x64, 0x20, 0xb2, 0xaf, 0xc5, 0xfb, 0x4b, - 0xa1, 0x49, 0x24, 0xe2, 0x94, 0x17, 0xed, 0x67, 0x89, 0x7e, 0x52, 0x1f}; - uint8_t bytesprops3[] = {0x22, 0x3c, 0xc0, 0x26, 0x5, 0xfd, 0xd7, 0x89, 0x2d, 0xf5, 0xec, 0x1f, 0xfc, - 0x60, 0xb8, 0x31, 0x13, 0x56, 0x9, 0x82, 0x64, 0xc9, 0x4, 0x6a, 0x37}; - uint8_t bytesprops5[] = {0x65, 0x6c, 0xf4, 0x8e, 0x42, 0x89, 0x43, 0x7d, 0x18, 0x2b, 0x36, - 0x2c, 0x7f, 0x3b, 0x68, 0x67, 0xea, 0xe2, 0x97, 0xed, 0x37, 0xa8}; - uint8_t bytesprops4[] = {0xf, 0xe0, 0x6a, 0x5e, 0x4a, 0x27, 0xcc, 0x65, 0xd6, 0xb5, 0x89, - 0xa2, 0xb9, 0x7d, 0xb6, 0xdd, 0xcc, 0x50, 0xb3, 0x2e, 0x48}; - uint8_t bytesprops6[] = {0xc8, 0x43, 0x10, 0x54, 0xc0, 0xe2, 0x68, 0x86, - 0xa7, 0x4b, 0x4f, 0x6, 0x84, 0x66, 0x1f, 0xed}; - uint8_t bytesprops7[] = {0xe8, 0xfb, 0xc4, 0xf8, 0x6e, 0x48, 0x9e, 0x5, 0xc0, 0x81, 0x2, 0xf0, 0xcb, 0x2, 0x89, - 0x77, 0x80, 0x1c, 0x2e, 0x86, 0x5a, 0x15, 0xa5, 0x78, 0xe5, 0x22, 0xcb, 0x13, 0x3a}; - uint8_t bytesprops8[] = {0x9f, 0x6b, 0xe0, 0xce, 0x12, 0xb0, 0x1f, 0xb7, 0x2c, 0xd8, 0x37, 0xaf, 0xa1, - 0x96, 0x2f, 0xe3, 0x37, 0xfa, 0x73, 0xc9, 0x80, 0x24, 0x4b, 0xf9, 0xef, 0x97}; - uint8_t bytesprops9[] = {0x7f, 0x36, 0x3d, 0x8f, 0xf, 0xf6, 0x7, 0xa3, 0x72, 0x1, 0xd9, 0x0, 0x19, 0x6e, 0x64, 0x21}; + 0x10, 0x84, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x54, 0x68, 0x70, 0x8, 0x0, 0xb, 0xb8, 0x74, + 0x1c, 0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+ uint8_t bytesprops0[] = {0xb8, 0x74, 0x1c, 0xbf, 0x61, 0x6, 0xab, 0x73, 0xbf, 0xc3, 0xaa}; + uint8_t bytesprops1[] = {0x3a, 0x3d, 0x27, 0x19, 0xe5, 0x2e, 0x8c, 0x4e, 0x48, 0xee, + 0x58, 0xca, 0xe8, 0x80, 0xf3, 0xc1, 0x1c, 0x3b, 0xde}; + uint8_t bytesprops2[] = {0xac, 0x8b, 0x42, 0x5c, 0x26, 0x62, 0xe0, 0xc3, 0xdd, 0xdd, 0x70}; + uint8_t bytesprops3[] = {0x9f, 0x71, 0x61, 0xfe, 0xa4, 0xca, 0x6b, 0x9b, 0xb8, 0xa0, 0x93, 0x40, 0x74}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 174}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 176}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20269}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13007}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 9}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 61}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 74}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops4}, .v = {22, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 72}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25593}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24532}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 63}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 47}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22000}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7757}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29006}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 66}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29972}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16839}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18851}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6917}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3086}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25623}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10186}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 255}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; + uint8_t byteswillprops1[] = {0xd, 0x72, 0x33, 0xc5}; + uint8_t byteswillprops0[] = {0xdf, 0xf, 0xfc, 0xbc, 0x97}; + uint8_t byteswillprops2[] = {0xb3, 0x88, 0x5}; + uint8_t byteswillprops3[] = {0xf0, 0x7d, 0x96, 0x78, 0x9b, 0x80, 0xd2, 0xb8, 0xe4, + 0x34, 0x3f, 0xbe, 0xa7, 0xc9, 0x72, 0x8a, 0x33, 0x8}; + uint8_t byteswillprops4[] = {0x20, 0x57, 0x63, 0xc1, 0x1f}; + uint8_t byteswillprops5[] = {0xe1, 0xf6, 0x6c, 0xdf, 0x99, 0xc5, 0x83, 0x24, 0x2, 0xae, 0x8e, 0x4a, 0xb1, 0x93, + 0xae, 0x90, 0x0, 0xba, 0xf3, 0xa0, 0xee, 0xd4, 0x7b, 0x11, 0x12, 0xd1, 0x48}; + uint8_t byteswillprops6[] = {0x3e, 0xc0, 0xd2, 0xed}; + uint8_t byteswillprops7[] = {0xcb, 0x28, 0xdb, 0xf6}; - lwmqtt_property_t willpropslist[] = {}; + lwmqtt_property_t willpropslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13711}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18793}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {5, (char*)&byteswillprops0}, .v = {4, (char*)&byteswillprops1}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4167}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 614}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9391}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9240}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 126}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14417}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32500}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20005}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6193}}, + }; - lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xb2, 0xe1, 0xaa, 0x4a, 0xb7, 0x15, 0x80, 0xc9, 0xe9, - 0xf7, 0xd7, 0x71, 0x15, 0xb, 0xa5, 0x41, 0x1f, 0xe4}; + lwmqtt_properties_t willprops = {22, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x7d, 0x32, 0xd8, 0x68, 0x23, 0xc2, 0xf2, 0xf1, 0x47, + 0x3a, 0xbe, 0x7b, 0x6a, 0xb9, 0x12, 0x9d, 0x7d, 0x6c}; lwmqtt_string_t will_topic = {18, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x2d, 0x9b, 0xd8, 0xaa, 0xdd, 0x49, 0xbc, 0x93, 0x3a, 0xb3, 0xa7, 0x3a}; - lwmqtt_string_t will_payload = {12, (char*)&will_payload_bytes}; + uint8_t will_payload_bytes[] = {0x44, 0xc4, 0xf3, 0x45, 0xe5, 0x1c, 0x5b, 0x2b, 0x4b, 0xd0, 0xaa, 0x3d, 0x5d, + 0x6f, 0x98, 0x15, 0x4d, 0xcf, 0x97, 0x38, 0xbc, 0x18, 0xea, 0x6b, 0x64}; + lwmqtt_string_t will_payload = {25, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS2; - will.retained = false; + will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 24031; - uint8_t client_id_bytes[] = {0xf, 0x35}; - lwmqtt_string_t client_id = {2, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 21608; + uint8_t client_id_bytes[] = {0x82, 0x26, 0x42, 0x9, 0x83, 0xa5, 0xff, 0xf8, 0x3d, 0xcb, 0x8c, 0x15, + 0xa5, 0xeb, 0x66, 0xe2, 0x4a, 0x43, 0xc, 0xd4, 0x3c, 0xb5, 0xbf}; + lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x8f, 0x2c, 0x1, 0x9b, 0x67, 0xe4, 0x50, 0x56, 0x12, 0x3c, 0xe9, 0xa7, 0xf0, 0x60, 0x1f}; + uint8_t username_bytes[] = {0x59, 0x1d, 0x99, 0x92, 0x86, 0xa5, 0x38, 0x5e, 0x2c, 0x6b, 0x5c, 0x19, 0x16, 0x68, 0xcf}; lwmqtt_string_t username = {15, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x65, 0xa, 0x6d, 0x3d, 0x66, 0x8c, 0xe6, 0x44, 0x6c, 0xa1, 0xe1, 0xaa, 0xa2, - 0x76, 0xa4, 0x4, 0x63, 0xcf, 0xc3, 0xff, 0x83, 0x6e, 0x24, 0x47, 0xb3, 0x77}; - lwmqtt_string_t password = {26, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x44, 0x95, 0x3f, 0xaa, 0x4, 0x1d, 0x51, 0xd8, 0x8b, 0xa8, 0xd2, 0xf7, 0x4f, 0x8a, + 0x8b, 0x5b, 0xed, 0x77, 0x97, 0xff, 0x51, 0x7b, 0x22, 0x91, 0x4c, 0x7e, 0xac}; + lwmqtt_string_t password = {27, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -13172,113 +12429,147 @@ TEST(Connect5QCTest, Encode23) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Nothing, _password = Just "\141\198\185\130\140v\STX\135\128\CAN", _lastWill = Just -// (LastWill {_willRetain = True, _willQoS = QoS0, _willTopic = -// "Y\242i\225Ly\163\177\f\138\135/TW\n\DC3\217\RS\251c\244\DLEs\CAN\178mU>\SO", _willMsg = "Z", _willProps = -// [PropSharedSubscriptionAvailable 173,PropRetainAvailable 148,PropAuthenticationData -// "l\225\ETX\t2\EOT>\248~\235\230\191\167\ACK\t\164\198\GS\NAK\243\165\128\130[1\181\210",PropContentType -// "`w\166Xy\224\226\193\153",PropAssignedClientIdentifier -// "!W\150o6\128\137\183\144\FS,c\227\144f\216\157",PropWillDelayInterval 23920,PropRetainAvailable -// 175,PropSharedSubscriptionAvailable 98,PropPayloadFormatIndicator 78,PropResponseInformation -// "\241^n}\171-\fv'\EOT\205_\177",PropAuthenticationMethod "\151,\142\177\133\213",PropServerKeepAlive -// 8086,PropSubscriptionIdentifierAvailable 121,PropMessageExpiryInterval 18973,PropTopicAlias -// 10091,PropMessageExpiryInterval 1594,PropServerKeepAlive 18996,PropWillDelayInterval 5991,PropContentType -// "\ETX\SOH\159Wp\214\187\176\246\166\185\235}\154\141s\178G\208G",PropRequestResponseInformation -// 14,PropMaximumPacketSize 23991,PropMessageExpiryInterval 21828,PropPayloadFormatIndicator -// 18,PropSessionExpiryInterval 24926]}), _cleanSession = True, _keepAlive = 14148, _connID = -// "hRi\ESC\170\202\226\252\ACK\209\SYN\222k\188", _properties = [PropTopicAliasMaximum -// 25143,PropAssignedClientIdentifier -// "\182\214\141\162k(\231?\161I\168\189\220\236\DC4\DLE\131\240!Z\166\183p\a_",PropRetainAvailable -// 207,PropRetainAvailable 84,PropTopicAlias 30203]} -TEST(Connect5QCTest, Encode24) { - uint8_t pkt[] = {0x10, 0x9b, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x66, 0x37, 0x44, 0x26, 0x22, 0x62, 0x37, - 0x12, 0x0, 0x19, 0xb6, 0xd6, 0x8d, 0xa2, 0x6b, 0x28, 0xe7, 0x3f, 0xa1, 0x49, 0xa8, 0xbd, 0xdc, 0xec, - 0x14, 0x10, 0x83, 0xf0, 0x21, 0x5a, 0xa6, 0xb7, 0x70, 0x7, 0x5f, 0x25, 0xcf, 0x25, 0x54, 0x23, 0x75, - 0xfb, 0x0, 0xe, 0x68, 0x52, 0x69, 0x1b, 0xaa, 0xca, 0xe2, 0xfc, 0x6, 0xd1, 0x16, 0xde, 0x6b, 0xbc, - 0xaa, 0x1, 0x2a, 0xad, 0x25, 0x94, 0x16, 0x0, 0x1b, 0x6c, 0xe1, 0x3, 0x9, 0x32, 0x4, 0x3e, 0xf8, - 0x7e, 0xeb, 0xe6, 0xbf, 0xa7, 0x6, 0x9, 0xa4, 0xc6, 0x1d, 0x15, 0xf3, 0xa5, 0x80, 0x82, 0x5b, 0x31, - 0xb5, 0xd2, 0x3, 0x0, 0x9, 0x60, 0x77, 0xa6, 0x58, 0x79, 0xe0, 0xe2, 0xc1, 0x99, 0x12, 0x0, 0x11, - 0x21, 0x57, 0x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x14, 0x10, 0x83, 0xf0, 0x21, 0x5a, 0xa6, 0xb7, 0x70, 0x7, 0x5f}; +// ConnectRequest {_username = Just "@\255\f -\161\165\199'wWt4\233\GS|D\153\234\178\201\GS\171c\234\218\227\128yV", +// _password = Just "\GS\f\242\202", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS2, _willTopic = +// "t\201\133\209\218\232M\211\&6\137\160\250\176\231N\250K\156\n\154)G8m\230?*\204", _willMsg = +// "x\171H\181\148\190T\200\NAKGX-!", _willProps = [PropResponseInformation +// "\SYNn\154\246\\\237\168\161\&11\184\ENQ\137^-\243?\221\&3\232(\SO",PropTopicAliasMaximum 8234,PropUserProperty +// "\205\146\233\SOHu:\133\237v\240\237\164\242\243\246\191[\214\219" +// "14.\207~\159\236\181S\rqM\198\143EA\147\EOT",PropAuthenticationMethod +// "\ACK\232r\ACK\144\135o\168=\188\214\a#\191\251\155,",PropResponseTopic "",PropMessageExpiryInterval +// 25344,PropUserProperty "@\219L", _lastWill = Just (LastWill {_willRetain = -// True, _willQoS = QoS1, _willTopic = "A\SUB\166x\NUL", _willMsg = "\253\&0\131n\162\236\192\DEL \150.\SI\174\163", -// _willProps = [PropTopicAliasMaximum 29074,PropResponseInformation -// "\DC1:\215Jj/]\232k\GS\185\209r\148L\ETB\180{\254D\189\248\b\208\227",PropMessageExpiryInterval -// 29782,PropAssignedClientIdentifier "H\DC1\STXQ>9H\GS\129\243\199\238\168\&7a",PropSessionExpiryInterval -// 30959,PropMessageExpiryInterval 28052,PropTopicAlias 24618,PropRequestProblemInformation 237,PropServerReference -// "Pq#\186\195\246\&8*\132\&1\240]\167E\139\236\NAK\253\EM\130\178\SOSF\RS\146\v>e\147",PropMaximumPacketSize -// 15564,PropCorrelationData "\174\232\166+\155\182\172\ACKX\ACK\154\190\206\182",PropTopicAlias 28312,PropTopicAlias -// 21162,PropMaximumPacketSize 29667,PropSharedSubscriptionAvailable 101,PropTopicAlias 5194,PropCorrelationData -// "\153{\152\231A\216\226\146\ACK\247h9C\194\233",PropPayloadFormatIndicator 112,PropAssignedClientIdentifier -// "@\204\136\246\229\209{c\233\n",PropSubscriptionIdentifierAvailable 156]}), _cleanSession = True, _keepAlive = 11096, -// _connID = "\207\r\183\&5c`\208+\186d/\132'X\238\247\DLEO\130\241\201\158\234", _properties = [PropCorrelationData -// "\248\DC1\135`\136\191\f\199\169>\EMt\SUB\CAN\145I\181\216&",PropUserProperty -// "\DC2\v\219\&7K\147\nL\189\219\163\230\166$\ETB\214kc\178r\236s\231" -// "\140A\244\133\155O\224x\US\138\221\153\176\216\132,\SOH\236\129\253\DELb",PropResponseTopic -// "\213\219nQ/\210@y\173\191\178bk\USs\SOH\197",PropUserProperty "\187\232\149z\147\STXw\178\188;\253" -// "\225W^\187\201n&\t!0\131~\218\ACK\173W]\188\188\f\192\143\SOH\NULBs\160}\154",PropSubscriptionIdentifierAvailable -// 80,PropMaximumQoS 214,PropMaximumPacketSize 30233,PropResponseInformation -// "\186N\SOT\202\163\f\144\241f\130\&5\153:",PropMaximumPacketSize 30201,PropUserProperty -// "\ESC\174\231\185y\167\182E\EM\ESC\DC23p\233\181H\DLE\166\216" -// "3\145\253\180\213\174\228P\n\208\181\SI\146\231I",PropTopicAlias 6216,PropSubscriptionIdentifierAvailable -// 68,PropCorrelationData -// "X\172\&5\ESC\224k`P\USX[\219te\183\188\134\224\227\192\SIT\156\243<\152",PropAuthenticationData -// "\164\248\165\169\&4_\146\230~\143GG\ESC\231\a\221\209\202\223\&8\185db\155>\RS\208\161\US",PropRequestProblemInformation -// 252,PropRequestResponseInformation 153,PropServerKeepAlive 26215,PropServerKeepAlive 322,PropResponseInformation -// "Q\NUL&\198\EMn\165\222\239\160\190\130\186\232\170\225/\\\189\DC1",PropSharedSubscriptionAvailable -// 226,PropRequestProblemInformation 166,PropSharedSubscriptionAvailable 58,PropResponseTopic -// "\149\168\171_s\164\&1S\160\208#C|\195\201\194",PropAuthenticationMethod -// "\176\186\181\ACK\250\218\CAN\ETB\DC3\170\148\ETB",PropMaximumPacketSize 25408,PropAuthenticationMethod -// "^\209\215\243\225]\184n\157\174>\226w@<\228\196\GS\145",PropMaximumPacketSize 28989,PropUserProperty -// "\208\141rK\240\232\NAK" "\SOHZn -// \SYN\219\&7uu<\255\179\DC3r&\152p\166\233\154!L\SUB\SOH!Q\157\135/",PropReceiveMaximum 22326,PropAuthenticationMethod -// "u\191\238\160\165\SUB"]} -TEST(Connect5QCTest, Encode26) { +// ConnectRequest {_username = Just "\207*R\174r\141;b'{=", _password = Just +// "z\205\192_%@\212\199\151\215c|\247\189\171\&4]G\215\ETB", _lastWill = Just (LastWill {_willRetain = True, _willQoS = +// QoS2, _willTopic = "\DC3\145\DC4\145\NUL\135\137|", _willMsg = +// "\161\158s\143&OOq\DC3Z\EM\t\230\252G1A\220j\197i\US5", _willProps = [PropResponseTopic "\171\225\133\ESC\204\168\140 +// L\DC4\141\213\&0",PropSharedSubscriptionAvailable 190,PropRetainAvailable 21,PropTopicAliasMaximum +// 16999,PropMessageExpiryInterval 228,PropTopicAliasMaximum 4211,PropMaximumPacketSize 15085,PropSubscriptionIdentifier +// 21,PropServerReference "\138t\130^\153\134\207\193v\228M",PropSubscriptionIdentifierAvailable 157,PropReasonString +// "\188\215\161\233\204\219'\SO\179\DLE;-\214\183H6!\168\244\207^O6\234",PropReceiveMaximum +// 27860,PropRequestResponseInformation 249,PropCorrelationData "\170Rs\148\235{\tQ",PropMaximumQoS +// 109,PropResponseTopic "\227\243\ACKF\233e\FSCM\SYN\141\177k\244",PropSubscriptionIdentifierAvailable +// 196,PropServerKeepAlive 16056,PropServerReference "9\197",PropResponseInformation +// "\237\235t\221\r\137s\DC1Z\174\180\141\EM\233yB?U\136\NUL7\228\164pk\DEL\STXi\163",PropMaximumPacketSize +// 31149,PropRetainAvailable 124,PropServerKeepAlive 10272]}), _cleanSession = True, _keepAlive = 13315, _connID = +// "%t\158\172\148\133\248\183\148\DELO\147T\240\DC3+", _properties = [PropServerReference +// "\162\152v\133#\240<}\215\221Y_\237\241.\184\243\135M12v\234\147\225\179\199%x",PropWildcardSubscriptionAvailable +// 194,PropResponseTopic "\227\182\225\243\140",PropAssignedClientIdentifier " +// s\155Q\169\149\185[\236k\249(\b\202\191\252\210\220K\210lS \171",PropRequestResponseInformation 78,PropContentType +// "Q\130\137+\180r\152",PropAuthenticationMethod +// "\202\195\153\161\222k#\SUB\196{\SI\160\156\222\235\STX",PropReceiveMaximum 6479,PropTopicAliasMaximum +// 4802,PropResponseInformation "1tgg\156\231\176^\141Y\158\184\&6\216m\227e\129\162\138\218\SUB\220\DC4"]} +TEST(Connect5QCTest, Encode27) { uint8_t pkt[] = { - 0x10, 0xbc, 0x5, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xee, 0x2b, 0x58, 0xaf, 0x3, 0x9, 0x0, 0x13, 0xf8, - 0x11, 0x87, 0x60, 0x88, 0xbf, 0xc, 0xc7, 0xa9, 0x3e, 0x19, 0x74, 0x1a, 0x18, 0x91, 0x49, 0xb5, 0xd8, 0x26, 0x26, - 0x0, 0x17, 0x12, 0xb, 0xdb, 0x37, 0x4b, 0x93, 0xa, 0x4c, 0xbd, 0xdb, 0xa3, 0xe6, 0xa6, 0x24, 0x17, 0xd6, 0x6b, - 0x63, 0xb2, 0x72, 0xec, 0x73, 0xe7, 0x0, 0x16, 0x8c, 0x41, 0xf4, 0x85, 0x9b, 0x4f, 0xe0, 0x78, 0x1f, 0x8a, 0xdd, - 0x99, 0xb0, 0xd8, 0x84, 0x2c, 0x1, 0xec, 0x81, 0xfd, 0x7f, 0x62, 0x8, 0x0, 0x11, 0xd5, 0xdb, 0x6e, 0x51, 0x2f, - 0xd2, 0x40, 0x79, 0xad, 0xbf, 0xb2, 0x62, 0x6b, 0x1f, 0x73, 0x1, 0xc5, 0x26, 0x0, 0xb, 0xbb, 0xe8, 0x95, 0x7a, - 0x93, 0x2, 0x77, 0xb2, 0xbc, 0x3b, 0xfd, 0x0, 0x1d, 0xe1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c, 0x6f, 0x22, 0x89, 0xaa, 0x6d, 0xf4, 0xa4, 0xcb, 0x6, 0xba, 0xb3, 0xd9, 0x40, 0x20, 0x5f, 0x5b, 0xd, 0x3e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf8, 0x11, 0x87, 0x60, 0x88, 0xbf, 0xc, 0xc7, 0xa9, 0x3e, - 0x19, 0x74, 0x1a, 0x18, 0x91, 0x49, 0xb5, 0xd8, 0x26}; - uint8_t bytesprops2[] = {0x8c, 0x41, 0xf4, 0x85, 0x9b, 0x4f, 0xe0, 0x78, 0x1f, 0x8a, 0xdd, - 0x99, 0xb0, 0xd8, 0x84, 0x2c, 0x1, 0xec, 0x81, 0xfd, 0x7f, 0x62}; - uint8_t bytesprops1[] = {0x12, 0xb, 0xdb, 0x37, 0x4b, 0x93, 0xa, 0x4c, 0xbd, 0xdb, 0xa3, 0xe6, - 0xa6, 0x24, 0x17, 0xd6, 0x6b, 0x63, 0xb2, 0x72, 0xec, 0x73, 0xe7}; - uint8_t bytesprops3[] = {0xd5, 0xdb, 0x6e, 0x51, 0x2f, 0xd2, 0x40, 0x79, 0xad, - 0xbf, 0xb2, 0x62, 0x6b, 0x1f, 0x73, 0x1, 0xc5}; - uint8_t bytesprops5[] = {0xe1, 0x57, 0x5e, 0xbb, 0xc9, 0x6e, 0x26, 0x9, 0x21, 0x30, 0x83, 0x7e, 0xda, 0x6, 0xad, - 0x57, 0x5d, 0xbc, 0xbc, 0xc, 0xc0, 0x8f, 0x1, 0x0, 0x42, 0x73, 0xa0, 0x7d, 0x9a}; - uint8_t bytesprops4[] = {0xbb, 0xe8, 0x95, 0x7a, 0x93, 0x2, 0x77, 0xb2, 0xbc, 0x3b, 0xfd}; - uint8_t bytesprops6[] = {0xba, 0x4e, 0xe, 0x54, 0xca, 0xa3, 0xc, 0x90, 0xf1, 0x66, 0x82, 0x35, 0x99, 0x3a}; - uint8_t bytesprops8[] = {0x33, 0x91, 0xfd, 0xb4, 0xd5, 0xae, 0xe4, 0x50, 0xa, 0xd0, 0xb5, 0xf, 0x92, 0xe7, 0x49}; - uint8_t bytesprops7[] = {0x1b, 0xae, 0xe7, 0xb9, 0x79, 0xa7, 0xb6, 0x45, 0x19, 0x1b, - 0x12, 0x33, 0x70, 0xe9, 0xb5, 0x48, 0x10, 0xa6, 0xd8}; - uint8_t bytesprops9[] = {0x58, 0xac, 0x35, 0x1b, 0xe0, 0x6b, 0x60, 0x50, 0x1f, 0x58, 0x5b, 0xdb, 0x74, - 0x65, 0xb7, 0xbc, 0x86, 0xe0, 0xe3, 0xc0, 0xf, 0x54, 0x9c, 0xf3, 0x3c, 0x98}; - uint8_t bytesprops10[] = {0xa4, 0xf8, 0xa5, 0xa9, 0x34, 0x5f, 0x92, 0xe6, 0x7e, 0x8f, 0x47, 0x47, 0x1b, 0xe7, 0x7, - 0xdd, 0xd1, 0xca, 0xdf, 0x38, 0xb9, 0x64, 0x62, 0x9b, 0x3e, 0x1e, 0xd0, 0xa1, 0x1f}; - uint8_t bytesprops11[] = {0x51, 0x0, 0x26, 0xc6, 0x19, 0x6e, 0xa5, 0xde, 0xef, 0xa0, - 0xbe, 0x82, 0xba, 0xe8, 0xaa, 0xe1, 0x2f, 0x5c, 0xbd, 0x11}; - uint8_t bytesprops12[] = {0x95, 0xa8, 0xab, 0x5f, 0x73, 0xa4, 0x31, 0x53, - 0xa0, 0xd0, 0x23, 0x43, 0x7c, 0xc3, 0xc9, 0xc2}; - uint8_t bytesprops13[] = {0xb0, 0xba, 0xb5, 0x6, 0xfa, 0xda, 0x18, 0x17, 0x13, 0xaa, 0x94, 0x17}; - uint8_t bytesprops14[] = {0x5e, 0xd1, 0xd7, 0xf3, 0xe1, 0x5d, 0xb8, 0x6e, 0x9d, 0xae, - 0x3e, 0xe2, 0x77, 0x40, 0x3c, 0xe4, 0xc4, 0x1d, 0x91}; - uint8_t bytesprops16[] = {0x1, 0x5a, 0x6e, 0x20, 0x16, 0xdb, 0x37, 0x75, 0x75, 0x3c, 0xff, 0xb3, 0x13, 0x72, 0x26, - 0x98, 0x70, 0xa6, 0xe9, 0x9a, 0x21, 0x4c, 0x1a, 0x1, 0x21, 0x51, 0x9d, 0x87, 0x2f}; - uint8_t bytesprops15[] = {0xd0, 0x8d, 0x72, 0x4b, 0xf0, 0xe8, 0x15}; - uint8_t bytesprops17[] = {0x75, 0xbf, 0xee, 0xa0, 0xa5, 0x1a}; + 0x10, 0x93, 0x3, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xf6, 0x34, 0x3, 0x85, 0x1, 0x1c, 0x0, 0x1d, 0xa2, + 0x98, 0x76, 0x85, 0x23, 0xf0, 0x3c, 0x7d, 0xd7, 0xdd, 0x59, 0x5f, 0xed, 0xf1, 0x2e, 0xb8, 0xf3, 0x87, 0x4d, 0x31, + 0x32, 0x76, 0xea, 0x93, 0xe1, 0xb3, 0xc7, 0x25, 0x78, 0x28, 0xc2, 0x8, 0x0, 0x5, 0xe3, 0xb6, 0xe1, 0xf3, 0x8c, + 0x12, 0x0, 0x18, 0x20, 0x73, 0x9b, 0x51, 0xa9, 0x95, 0xb9, 0x5b, 0xec, 0x6b, 0xf9, 0x28, 0x8, 0xca, 0xbf, 0xfc, + 0xd2, 0xdc, 0x4b, 0xd2, 0x6c, 0x53, 0x20, 0xab, 0x19, 0x4e, 0x3, 0x0, 0x7, 0x51, 0x82, 0x89, 0x2b, 0xb4, 0x72, + 0x98, 0x15, 0x0, 0x10, 0xca, 0xc3, 0x99, 0xa1, 0xde, 0x6b, 0x23, 0x1a, 0xc4, 0x7b, 0xf, 0xa0, 0x9c, 0xde, 0xeb, + 0x2, 0x21, 0x19, 0x4f, 0x22, 0x12, 0xc2, 0x1a, 0x0, 0x18, 0x31, 0x74, 0x67, 0x67, 0x9c, 0xe7, 0xb0, 0x5e, 0x8d, + 0x59, 0x9e, 0xb8, 0x36, 0xd8, 0x6d, 0xe3, 0x65, 0x81, 0xa2, 0x8a, 0xda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0x25, 0x7c, 0x13, 0x28, 0x20, 0x0, 0x8, 0x13, 0x91, 0x14, 0x91, + 0x0, 0x87, 0x89, 0x7c, 0x0, 0x17, 0xa1, 0x9e, 0x73, 0x8f, 0x26, 0x4f, 0x4f, 0x71, 0x13, 0x5a, 0x19, 0x9, 0xe6, + 0xfc, 0x47, 0x31, 0x41, 0xdc, 0x6a, 0xc5, 0x69, 0x1f, 0x35, 0x0, 0xb, 0xcf, 0x2a, 0x52, 0xae, 0x72, 0x8d, 0x3b, + 0x62, 0x27, 0x7b, 0x3d, 0x0, 0x14, 0x7a, 0xcd, 0xc0, 0x5f, 0x25, 0x40, 0xd4, 0xc7, 0x97, 0xd7, 0x63, 0x7c, 0xf7, + 0xbd, 0xab, 0x34, 0x5d, 0x47, 0xd7, 0x17}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa2, 0x98, 0x76, 0x85, 0x23, 0xf0, 0x3c, 0x7d, 0xd7, 0xdd, 0x59, 0x5f, 0xed, 0xf1, 0x2e, + 0xb8, 0xf3, 0x87, 0x4d, 0x31, 0x32, 0x76, 0xea, 0x93, 0xe1, 0xb3, 0xc7, 0x25, 0x78}; + uint8_t bytesprops1[] = {0xe3, 0xb6, 0xe1, 0xf3, 0x8c}; + uint8_t bytesprops2[] = {0x20, 0x73, 0x9b, 0x51, 0xa9, 0x95, 0xb9, 0x5b, 0xec, 0x6b, 0xf9, 0x28, + 0x8, 0xca, 0xbf, 0xfc, 0xd2, 0xdc, 0x4b, 0xd2, 0x6c, 0x53, 0x20, 0xab}; + uint8_t bytesprops3[] = {0x51, 0x82, 0x89, 0x2b, 0xb4, 0x72, 0x98}; + uint8_t bytesprops4[] = {0xca, 0xc3, 0x99, 0xa1, 0xde, 0x6b, 0x23, 0x1a, + 0xc4, 0x7b, 0xf, 0xa0, 0x9c, 0xde, 0xeb, 0x2}; + uint8_t bytesprops5[] = {0x31, 0x74, 0x67, 0x67, 0x9c, 0xe7, 0xb0, 0x5e, 0x8d, 0x59, 0x9e, 0xb8, + 0x36, 0xd8, 0x6d, 0xe3, 0x65, 0x81, 0xa2, 0x8a, 0xda, 0x1a, 0xdc, 0x14}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops1}, .v = {22, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops4}, .v = {29, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 80}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30233}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30201}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops7}, .v = {15, (char*)&bytesprops8}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6216}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 26215}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 322}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {16, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25408}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28989}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops15}, .v = {29, (char*)&bytesprops16}}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22326}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops17}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 194}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6479}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4802}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x11, 0x3a, 0xd7, 0x4a, 0x6a, 0x2f, 0x5d, 0xe8, 0x6b, 0x1d, 0xb9, 0xd1, 0x72, - 0x94, 0x4c, 0x17, 0xb4, 0x7b, 0xfe, 0x44, 0xbd, 0xf8, 0x8, 0xd0, 0xe3}; - uint8_t byteswillprops1[] = {0x48, 0x11, 0x2, 0x51, 0x3e, 0x39, 0x48, 0x1d, 0x81, 0xf3, 0xc7, 0xee, 0xa8, 0x37, 0x61}; - uint8_t byteswillprops2[] = {0x50, 0x71, 0x23, 0xba, 0xc3, 0xf6, 0x38, 0x2a, 0x84, 0x31, - 0xf0, 0x5d, 0xa7, 0x45, 0x8b, 0xec, 0x15, 0xfd, 0x19, 0x82, - 0xb2, 0xe, 0x53, 0x46, 0x1e, 0x92, 0xb, 0x3e, 0x65, 0x93}; - uint8_t byteswillprops3[] = {0xae, 0xe8, 0xa6, 0x2b, 0x9b, 0xb6, 0xac, 0x6, 0x58, 0x6, 0x9a, 0xbe, 0xce, 0xb6}; - uint8_t byteswillprops4[] = {0x99, 0x7b, 0x98, 0xe7, 0x41, 0xd8, 0xe2, 0x92, 0x6, 0xf7, 0x68, 0x39, 0x43, 0xc2, 0xe9}; - uint8_t byteswillprops5[] = {0x40, 0xcc, 0x88, 0xf6, 0xe5, 0xd1, 0x7b, 0x63, 0xe9, 0xa}; + uint8_t byteswillprops0[] = {0xab, 0xe1, 0x85, 0x1b, 0xcc, 0xa8, 0x8c, 0x20, 0x4c, 0x14, 0x8d, 0xd5, 0x30}; + uint8_t byteswillprops1[] = {0x8a, 0x74, 0x82, 0x5e, 0x99, 0x86, 0xcf, 0xc1, 0x76, 0xe4, 0x4d}; + uint8_t byteswillprops2[] = {0xbc, 0xd7, 0xa1, 0xe9, 0xcc, 0xdb, 0x27, 0xe, 0xb3, 0x10, 0x3b, 0x2d, + 0xd6, 0xb7, 0x48, 0x36, 0x21, 0xa8, 0xf4, 0xcf, 0x5e, 0x4f, 0x36, 0xea}; + uint8_t byteswillprops3[] = {0xaa, 0x52, 0x73, 0x94, 0xeb, 0x7b, 0x9, 0x51}; + uint8_t byteswillprops4[] = {0xe3, 0xf3, 0x6, 0x46, 0xe9, 0x65, 0x1c, 0x43, 0x4d, 0x16, 0x8d, 0xb1, 0x6b, 0xf4}; + uint8_t byteswillprops5[] = {0x39, 0xc5}; + uint8_t byteswillprops6[] = {0xed, 0xeb, 0x74, 0xdd, 0xd, 0x89, 0x73, 0x11, 0x5a, 0xae, 0xb4, 0x8d, 0x19, 0xe9, 0x79, + 0x42, 0x3f, 0x55, 0x88, 0x0, 0x37, 0xe4, 0xa4, 0x70, 0x6b, 0x7f, 0x2, 0x69, 0xa3}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29074}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29782}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 30959}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28052}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 24618}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 237}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15564}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {14, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28312}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21162}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 29667}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5194}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16999}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 228}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4211}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15085}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27860}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 249}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 109}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16056}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&byteswillprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&byteswillprops6}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 31149}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 124}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10272}}, }; - lwmqtt_properties_t willprops = {20, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x41, 0x1a, 0xa6, 0x78, 0x0}; - lwmqtt_string_t will_topic = {5, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0xfd, 0x30, 0x83, 0x6e, 0xa2, 0xec, 0xc0, 0x7f, 0x20, 0x96, 0x2e, 0xf, 0xae, 0xa3}; - lwmqtt_string_t will_payload = {14, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {23, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x13, 0x91, 0x14, 0x91, 0x0, 0x87, 0x89, 0x7c}; + lwmqtt_string_t will_topic = {8, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0xa1, 0x9e, 0x73, 0x8f, 0x26, 0x4f, 0x4f, 0x71, 0x13, 0x5a, 0x19, 0x9, + 0xe6, 0xfc, 0x47, 0x31, 0x41, 0xdc, 0x6a, 0xc5, 0x69, 0x1f, 0x35}; + lwmqtt_string_t will_payload = {23, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; - will.qos = LWMQTT_QOS1; + will.qos = LWMQTT_QOS2; will.retained = true; will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; opts.clean_session = true; - opts.keep_alive = 11096; - uint8_t client_id_bytes[] = {0xcf, 0xd, 0xb7, 0x35, 0x63, 0x60, 0xd0, 0x2b, 0xba, 0x64, 0x2f, 0x84, - 0x27, 0x58, 0xee, 0xf7, 0x10, 0x4f, 0x82, 0xf1, 0xc9, 0x9e, 0xea}; - lwmqtt_string_t client_id = {23, (char*)&client_id_bytes}; + opts.keep_alive = 13315; + uint8_t client_id_bytes[] = {0x25, 0x74, 0x9e, 0xac, 0x94, 0x85, 0xf8, 0xb7, + 0x94, 0x7f, 0x4f, 0x93, 0x54, 0xf0, 0x13, 0x2b}; + lwmqtt_string_t client_id = {16, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x98}; - lwmqtt_string_t username = {1, (char*)&username_bytes}; + uint8_t username_bytes[] = {0xcf, 0x2a, 0x52, 0xae, 0x72, 0x8d, 0x3b, 0x62, 0x27, 0x7b, 0x3d}; + lwmqtt_string_t username = {11, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0xae, 0x98, 0x78, 0x2c, 0xd6, 0x4f, 0xb7, 0xf9, 0x2c, 0x6f, 0x22, 0x89, 0xaa, 0x6d, - 0xf4, 0xa4, 0xcb, 0x6, 0xba, 0xb3, 0xd9, 0x40, 0x20, 0x5f, 0x5b, 0xd, 0x3e}; - lwmqtt_string_t password = {27, (char*)&password_bytes}; + uint8_t password_bytes[] = {0x7a, 0xcd, 0xc0, 0x5f, 0x25, 0x40, 0xd4, 0xc7, 0x97, 0xd7, + 0x63, 0x7c, 0xf7, 0xbd, 0xab, 0x34, 0x5d, 0x47, 0xd7, 0x17}; + lwmqtt_string_t password = {20, (char*)&password_bytes}; opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -13565,91 +12875,167 @@ TEST(Connect5QCTest, Encode26) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "\254\216\220\247\151\136\DC1\188~L\248\142", _password = Nothing, _lastWill = Just -// (LastWill {_willRetain = False, _willQoS = QoS1, _willTopic = -// "U6Dw\178\166\201q\230\187\STX\187>P\180\&1\224[W\181\GS:", _willMsg = "", _willProps = [PropSubscriptionIdentifier -// 25,PropAuthenticationMethod "E\191\190\250<\151\DC1\DC4\224\176\SIg\150",PropMaximumQoS 137,PropTopicAlias -// 21105,PropReceiveMaximum 18226,PropTopicAliasMaximum 5839,PropAssignedClientIdentifier -// "\242D",PropRequestResponseInformation 6,PropPayloadFormatIndicator 144,PropSessionExpiryInterval 500,PropContentType -// "\135F\188K&\177\206-g\SO\EOT\249\143VE+B\196@P5\EOT\230\a\185\228\EM\130",PropRetainAvailable 6,PropServerReference -// "cA\195\179\&0\173\173\220=%;\f\139\158M",PropReasonString "\247Ir\176\"l\128",PropReasonString -// "\179D\192\169\242fb\b-\192\NAK",PropMaximumPacketSize 10906]}), _cleanSession = False, _keepAlive = 29562, _connID = -// "~\233\223\144\214,\GSg\DLE\144\196=<", _properties = [PropSharedSubscriptionAvailable 138,PropWillDelayInterval -// 12879,PropServerKeepAlive 6550,PropReceiveMaximum 10913,PropUserProperty "\234:\143a_\244\"\244\STX3\240\220y\141" -// "!\FS\166\169\238\145\136)\239\199*\208a\175\225\171\230\238\194\144n\ACK\SOH\174\178",PropMessageExpiryInterval -// 30709,PropSharedSubscriptionAvailable 102,PropAuthenticationMethod -// "b0\181\226\ENQ\130\189uwJ\166/\178\176\SOH=\205\&1\240E\190\164\r8G*B"]} -TEST(Connect5QCTest, Encode27) { - uint8_t pkt[] = {0x10, 0x9c, 0x2, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8c, 0x73, 0x7a, 0x5e, 0x2a, 0x8a, 0x18, - 0x0, 0x0, 0x32, 0x4f, 0x13, 0x19, 0x96, 0x21, 0x2a, 0xa1, 0x26, 0x0, 0xe, 0xea, 0x3a, 0x8f, 0x61, - 0x5f, 0xf4, 0x22, 0xf4, 0x2, 0x33, 0xf0, 0xdc, 0x79, 0x8d, 0x0, 0x19, 0x21, 0x1c, 0xa6, 0xa9, 0xee, - 0x91, 0x88, 0x29, 0xef, 0xc7, 0x2a, 0xd0, 0x61, 0xaf, 0xe1, 0xab, 0xe6, 0xee, 0xc2, 0x90, 0x6e, 0x6, - 0x1, 0xae, 0xb2, 0x2, 0x0, 0x0, 0x77, 0xf5, 0x2a, 0x66, 0x15, 0x0, 0x1b, 0x62, 0x30, 0xb5, 0xe2, - 0x5, 0x82, 0xbd, 0x75, 0x77, 0x4a, 0xa6, 0x2f, 0xb2, 0xb0, 0x1, 0x3d, 0xcd, 0x31, 0xf0, 0x45, 0xbe, - 0xa4, 0xd, 0x38, 0x47, 0x2a, 0x42, 0x0, 0xd, 0x7e, 0xe9, 0xdf, 0x90, 0xd6, 0x2c, 0x1d, 0x67, 0x10, - 0x90, 0xc4, 0x3d, 0x3c, 0x7b, 0xb, 0x19, 0x15, 0x0, 0xd, 0x45, 0xbf, 0xbe, 0xfa, 0x3c, 0x97, 0x11, - 0x14, 0xe0, 0xb0, 0xf, 0x67, 0x96, 0x24, 0x89, 0x23, 0x52, 0x71, 0x21, 0x47, 0x32, 0x22, 0x16, 0xcf, - 0x12, 0x0, 0x2, 0xf2, 0x44, 0x19, 0x6, 0x1, 0x90, 0x11, 0x0, 0x0, 0x1, 0xf4, 0x3, 0x0, 0x1c, - 0x87, 0x46, 0xbc, 0x4b, 0x26, 0xb1, 0xce, 0x2d, 0x67, 0xe, 0x4, 0xf9, 0x8f, 0x56, 0x45, 0x2b, 0x42, - 0xc4, 0x40, 0x50, 0x35, 0x4, 0xe6, 0x7, 0xb9, 0xe4, 0x19, 0x82, 0x25, 0x6, 0x1c, 0x0, 0xf, 0x63, - 0x41, 0xc3, 0xb3, 0x30, 0xad, 0xad, 0xdc, 0x3d, 0x25, 0x3b, 0xc, 0x8b, 0x9e, 0x4d, 0x1f, 0x0, 0x7, - 0xf7, 0x49, 0x72, 0xb0, 0x22, 0x6c, 0x80, 0x1f, 0x0, 0xb, 0xb3, 0x44, 0xc0, 0xa9, 0xf2, 0x66, 0x62, - 0x8, 0x2d, 0xc0, 0x15, 0x27, 0x0, 0x0, 0x2a, 0x9a, 0x0, 0x16, 0x55, 0x36, 0x44, 0x77, 0xb2, 0xa6, - 0xc9, 0x71, 0xe6, 0xbb, 0x2, 0xbb, 0x3e, 0x50, 0xb4, 0x31, 0xe0, 0x5b, 0x57, 0xb5, 0x1d, 0x3a, 0x0, - 0x0, 0x0, 0xc, 0xfe, 0xd8, 0xdc, 0xf7, 0x97, 0x88, 0x11, 0xbc, 0x7e, 0x4c, 0xf8, 0x8e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x21, 0x1c, 0xa6, 0xa9, 0xee, 0x91, 0x88, 0x29, 0xef, 0xc7, 0x2a, 0xd0, 0x61, - 0xaf, 0xe1, 0xab, 0xe6, 0xee, 0xc2, 0x90, 0x6e, 0x6, 0x1, 0xae, 0xb2}; - uint8_t bytesprops0[] = {0xea, 0x3a, 0x8f, 0x61, 0x5f, 0xf4, 0x22, 0xf4, 0x2, 0x33, 0xf0, 0xdc, 0x79, 0x8d}; - uint8_t bytesprops2[] = {0x62, 0x30, 0xb5, 0xe2, 0x5, 0x82, 0xbd, 0x75, 0x77, 0x4a, 0xa6, 0x2f, 0xb2, 0xb0, - 0x1, 0x3d, 0xcd, 0x31, 0xf0, 0x45, 0xbe, 0xa4, 0xd, 0x38, 0x47, 0x2a, 0x42}; +// ConnectRequest {_username = Nothing, _password = Just "9\SUBa", _lastWill = Just (LastWill {_willRetain = False, +// _willQoS = QoS1, _willTopic = "\229Zo\akR\167\175\227\&7\152-\t\SO\240(\CAN+\178\193\170%7\140\228\200\241\175N", +// _willMsg = "\\DN", _willProps = [PropMessageExpiryInterval 978,PropTopicAliasMaximum 19950,PropAuthenticationMethod +// "\203\244\187\172*Q\210\CANu\144\SUB\ETX\236C\182\"5V\GS\ETB",PropAssignedClientIdentifier +// "\212a(\205*\SOH\190?|\213\159\225\231~r>\251F/f\173\216\149\252\DC2!",PropAuthenticationData +// "",PropAuthenticationData "o\255\187\207\248\198\150\218\EOT`1\234",PropResponseTopic +// ",\169\214n{\199\229\ESC\203>G\211\188\198<\186\133L",PropUserProperty "j\166\147c\ACK\161\154:" +// "V\225\192\155\218\161\211\188\173r&m\220\222\151\v\226\CAN>o=\SI\v\SUB\255#",PropMaximumPacketSize +// 23390,PropReceiveMaximum 25525,PropRequestResponseInformation 73,PropSessionExpiryInterval +// 29798,PropMaximumPacketSize 783,PropResponseTopic "T",PropResponseTopic +// "\241\128;\167\214\175iX:\255\249",PropRequestResponseInformation 9,PropAuthenticationMethod +// "\229\172zl\183\253\183b\GS:\152l7K\152\rt\240\189\DC1C\165\227\177@",PropRetainAvailable 240,PropSharedSubscriptionAvailable +// 231,PropServerReference +// "\FS\151\STX\SOHG\SYND\243Y\188\138\207\&8V\202\ENQ\154g\203\238\235\177\231",PropMessageExpiryInterval +// 23163,PropMaximumPacketSize 7107,PropSubscriptionIdentifierAvailable 99,PropContentType "",PropAuthenticationMethod +// "\130\185\159m\183\128t-\220\133\227M\207.\SYN_\ETB)\177b\144@\208\150$Qq",PropServerReference +// "\255:\210#1<\"T\132\218\219\DEL\219\EOT\172\247\159`=\134\&7\217",PropSessionExpiryInterval +// 3863,PropTopicAliasMaximum 5913,PropSubscriptionIdentifierAvailable 86,PropMessageExpiryInterval +// 17555,PropSubscriptionIdentifier 16,PropRequestResponseInformation 161,PropRequestProblemInformation 101]} +TEST(Connect5QCTest, Encode28) { + uint8_t pkt[] = { + 0x10, 0x9f, 0x4, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x4e, 0xa, 0x67, 0x90, 0x2, 0x8, 0x0, 0x8, 0x2, + 0x8b, 0x93, 0x11, 0x76, 0x79, 0x82, 0xdd, 0x1, 0xe7, 0x2, 0x0, 0x0, 0x53, 0x43, 0x18, 0x0, 0x0, 0x78, 0xb7, + 0x21, 0x40, 0x5d, 0x9, 0x0, 0x1a, 0x83, 0x32, 0x1c, 0x64, 0xcb, 0xb8, 0x78, 0x4d, 0x71, 0xf1, 0xe6, 0xa1, 0xb4, + 0x5d, 0x64, 0x22, 0xb3, 0x81, 0xd4, 0xba, 0xad, 0x6, 0x79, 0x8a, 0x20, 0xaa, 0x15, 0x0, 0x0, 0x1a, 0x0, 0x0, + 0x2, 0x0, 0x0, 0x7d, 0x92, 0x26, 0x0, 0x1d, 0x2b, 0x68, 0x7f, 0x7, 0xcd, 0x28, 0x44, 0xc1, 0x45, 0x29, 0x5, + 0x7f, 0x50, 0xc, 0x75, 0x31, 0x1f, 0xf0, 0x67, 0x6d, 0x3f, 0x72, 0x25, 0xa6, 0xf8, 0x76, 0x2, 0x8e, 0x14, 0x0, + 0x1c, 0xb4, 0x4d, 0x43, 0x4a, 0xb5, 0x28, 0xda, 0x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cd, 0x89, 0x13, 0x7c, 0xb8, 0xb, 0x2, 0x19, 0x84, 0x0, 0x1d, 0xe5, 0x5a, 0x6f, 0x7, 0x6b, 0x52, + 0xa7, 0xaf, 0xe3, 0x37, 0x98, 0x2d, 0x9, 0xe, 0xf0, 0x28, 0x18, 0x2b, 0xb2, 0xc1, 0xaa, 0x25, 0x37, 0x8c, 0xe4, + 0xc8, 0xf1, 0xaf, 0x4e, 0x0, 0x3, 0x5c, 0x44, 0x4e, 0x0, 0x3, 0x39, 0x1a, 0x61}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x2, 0x8b, 0x93, 0x11, 0x76, 0x79, 0x82, 0xdd}; + uint8_t bytesprops1[] = {0x83, 0x32, 0x1c, 0x64, 0xcb, 0xb8, 0x78, 0x4d, 0x71, 0xf1, 0xe6, 0xa1, 0xb4, + 0x5d, 0x64, 0x22, 0xb3, 0x81, 0xd4, 0xba, 0xad, 0x6, 0x79, 0x8a, 0x20, 0xaa}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops5[] = {0xb4, 0x4d, 0x43, 0x4a, 0xb5, 0x28, 0xda, 0x15, 0x8d, 0x4e, 0xd0, 0x50, 0xdb, 0x63, + 0x4b, 0x2, 0x80, 0x64, 0x62, 0xbd, 0x21, 0x1f, 0x2c, 0x2f, 0xd3, 0x9d, 0x1e, 0xf5}; + uint8_t bytesprops4[] = {0x2b, 0x68, 0x7f, 0x7, 0xcd, 0x28, 0x44, 0xc1, 0x45, 0x29, 0x5, 0x7f, 0x50, 0xc, 0x75, + 0x31, 0x1f, 0xf0, 0x67, 0x6d, 0x3f, 0x72, 0x25, 0xa6, 0xf8, 0x76, 0x2, 0x8e, 0x14}; + uint8_t bytesprops6[] = {0x92, 0xcf, 0x89, 0x3e, 0xd, 0x74, 0xf0, 0xbd, 0x11, 0x43, 0xa5, 0xe3, 0xb1, 0x40}; + uint8_t bytesprops7[] = {0x1c, 0x97, 0x2, 0x1, 0x47, 0x16, 0x44, 0xf3, 0x59, 0xbc, 0x8a, 0xcf, + 0x38, 0x56, 0xca, 0x5, 0x9a, 0x67, 0xcb, 0xee, 0xeb, 0xb1, 0xe7}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0x82, 0xb9, 0x9f, 0x6d, 0xb7, 0x80, 0x74, 0x2d, 0xdc, 0x85, 0xe3, 0x4d, 0xcf, 0x2e, + 0x16, 0x5f, 0x17, 0x29, 0xb1, 0x62, 0x90, 0x40, 0xd0, 0x96, 0x24, 0x51, 0x71}; + uint8_t bytesprops10[] = {0xff, 0x3a, 0xd2, 0x23, 0x31, 0x3c, 0x22, 0x54, 0x84, 0xda, 0xdb, + 0x7f, 0xdb, 0x4, 0xac, 0xf7, 0x9f, 0x60, 0x3d, 0x86, 0x37, 0xd9}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 138}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 12879}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6550}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10913}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops0}, .v = {25, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30709}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 102}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21315}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 30903}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16477}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32146}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops4}, .v = {28, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 60}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23163}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7107}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 99}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3863}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5913}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 86}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17555}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 161}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 101}}, }; - lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0x45, 0xbf, 0xbe, 0xfa, 0x3c, 0x97, 0x11, 0x14, 0xe0, 0xb0, 0xf, 0x67, 0x96}; - uint8_t byteswillprops1[] = {0xf2, 0x44}; - uint8_t byteswillprops2[] = {0x87, 0x46, 0xbc, 0x4b, 0x26, 0xb1, 0xce, 0x2d, 0x67, 0xe, 0x4, 0xf9, 0x8f, 0x56, - 0x45, 0x2b, 0x42, 0xc4, 0x40, 0x50, 0x35, 0x4, 0xe6, 0x7, 0xb9, 0xe4, 0x19, 0x82}; - uint8_t byteswillprops3[] = {0x63, 0x41, 0xc3, 0xb3, 0x30, 0xad, 0xad, 0xdc, 0x3d, 0x25, 0x3b, 0xc, 0x8b, 0x9e, 0x4d}; - uint8_t byteswillprops4[] = {0xf7, 0x49, 0x72, 0xb0, 0x22, 0x6c, 0x80}; - uint8_t byteswillprops5[] = {0xb3, 0x44, 0xc0, 0xa9, 0xf2, 0x66, 0x62, 0x8, 0x2d, 0xc0, 0x15}; + uint8_t byteswillprops0[] = {0xcb, 0xf4, 0xbb, 0xac, 0x2a, 0x51, 0xd2, 0x18, 0x75, 0x90, + 0x1a, 0x3, 0xec, 0x43, 0xb6, 0x22, 0x35, 0x56, 0x1d, 0x17}; + uint8_t byteswillprops1[] = {0xd4, 0x61, 0x28, 0xcd, 0x2a, 0x1, 0xbe, 0x3f, 0x7c, 0xd5, 0x9f, 0xe1, 0xe7, + 0x7e, 0x72, 0x3e, 0xfb, 0x46, 0x2f, 0x66, 0xad, 0xd8, 0x95, 0xfc, 0x12, 0x21}; + uint8_t byteswillprops2[] = {0}; + uint8_t byteswillprops3[] = {0x6f, 0xff, 0xbb, 0xcf, 0xf8, 0xc6, 0x96, 0xda, 0x4, 0x60, 0x31, 0xea}; + uint8_t byteswillprops4[] = {0x2c, 0xa9, 0xd6, 0x6e, 0x7b, 0xc7, 0xe5, 0x1b, 0xcb, + 0x3e, 0x47, 0xd3, 0xbc, 0xc6, 0x3c, 0xba, 0x85, 0x4c}; + uint8_t byteswillprops6[] = {0x56, 0xe1, 0xc0, 0x9b, 0xda, 0xa1, 0xd3, 0xbc, 0xad, 0x72, 0x26, 0x6d, 0xdc, + 0xde, 0x97, 0xb, 0xe2, 0x18, 0x3e, 0x6f, 0x3d, 0xf, 0xb, 0x1a, 0xff, 0x23}; + uint8_t byteswillprops5[] = {0x6a, 0xa6, 0x93, 0x63, 0x6, 0xa1, 0x9a, 0x3a}; + uint8_t byteswillprops7[] = {0x54}; + uint8_t byteswillprops8[] = {0xf1, 0x80, 0x3b, 0xa7, 0xd6, 0xaf, 0x69, 0x58, 0x3a, 0xff, 0xf9}; + uint8_t byteswillprops9[] = {0xe5, 0xac, 0x7a, 0x6c, 0xb7, 0xfd, 0xb7, 0x62, 0x1d, + 0x3a, 0x98, 0x6c, 0x37, 0x4b, 0x98, 0x3c, 0x63, 0x40}; + uint8_t byteswillprops10[] = {0xc2, 0xb9, 0xcd, 0x89}; lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21105}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18226}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5839}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 500}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {15, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10906}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 978}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19950}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&byteswillprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&byteswillprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&byteswillprops2}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&byteswillprops3}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {18, (char*)&byteswillprops4}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {8, (char*)&byteswillprops5}, .v = {26, (char*)&byteswillprops6}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23390}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25525}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 73}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 29798}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 783}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&byteswillprops7}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&byteswillprops8}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&byteswillprops9}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&byteswillprops10}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31928}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 132}}, }; - lwmqtt_properties_t willprops = {16, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0x55, 0x36, 0x44, 0x77, 0xb2, 0xa6, 0xc9, 0x71, 0xe6, 0xbb, 0x2, - 0xbb, 0x3e, 0x50, 0xb4, 0x31, 0xe0, 0x5b, 0x57, 0xb5, 0x1d, 0x3a}; - lwmqtt_string_t will_topic = {22, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0}; - lwmqtt_string_t will_payload = {0, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {21, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0xe5, 0x5a, 0x6f, 0x7, 0x6b, 0x52, 0xa7, 0xaf, 0xe3, 0x37, 0x98, 0x2d, 0x9, 0xe, 0xf0, + 0x28, 0x18, 0x2b, 0xb2, 0xc1, 0xaa, 0x25, 0x37, 0x8c, 0xe4, 0xc8, 0xf1, 0xaf, 0x4e}; + lwmqtt_string_t will_topic = {29, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x5c, 0x44, 0x4e}; + lwmqtt_string_t will_payload = {3, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -13657,14 +13043,14 @@ TEST(Connect5QCTest, Encode27) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = false; - opts.keep_alive = 29562; - uint8_t client_id_bytes[] = {0x7e, 0xe9, 0xdf, 0x90, 0xd6, 0x2c, 0x1d, 0x67, 0x10, 0x90, 0xc4, 0x3d, 0x3c}; - lwmqtt_string_t client_id = {13, (char*)&client_id_bytes}; + opts.clean_session = true; + opts.keep_alive = 2663; + uint8_t client_id_bytes[] = {0x5f}; + lwmqtt_string_t client_id = {1, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0xfe, 0xd8, 0xdc, 0xf7, 0x97, 0x88, 0x11, 0xbc, 0x7e, 0x4c, 0xf8, 0x8e}; - lwmqtt_string_t username = {12, (char*)&username_bytes}; - opts.username = username; + uint8_t password_bytes[] = {0x39, 0x1a, 0x61}; + lwmqtt_string_t password = {3, (char*)&password_bytes}; + opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -13673,75 +13059,31 @@ TEST(Connect5QCTest, Encode27) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "W\NAK1\208\fP\SYN\143\223", _password = Just -// "-\161\CAN\233\GSA\129\195n,\214\STX\138", _lastWill = Just (LastWill {_willRetain = False, _willQoS = QoS1, -// _willTopic = "\163", _willMsg = "^\216\194\&8-V`\191\"\215\247\221\210\t\EOT\SOt\209\205\SI\SO", _willProps = -// [PropContentType "\193\248h\151I\195\152\213\179o\200\169\171^M",PropMaximumPacketSize 9787,PropRetainAvailable -// 109,PropMaximumQoS 223,PropAuthenticationMethod -// "\187G\SYN\192>Z\DEL\211\206\248I@\161c7\149\f\162+\202\129\SI\EOT\176}1$\213\210",PropContentType -// "\135\DC2,=:\ACK\224H\176\207\131\142\240\151\208.",PropReasonString -// "\134_\167\DLE\234",PropSubscriptionIdentifierAvailable 104,PropContentType -// "\150\158\135\212g\132\145\246_5\255!\"g*",PropTopicAliasMaximum 597,PropAuthenticationMethod -// "m\218\166/;\223-\DC2Q\255\150\144\152\242\251\132\223\t\156\212\190ej\217W\n\218\134\182",PropMaximumPacketSize -// 28656,PropRequestResponseInformation 219]}), _cleanSession = True, _keepAlive = 7229, _connID = -// "h$3\ESC%\229\134-\RS\205O", _properties = [PropMessageExpiryInterval 23408]} -TEST(Connect5QCTest, Encode28) { - uint8_t pkt[] = {0x10, 0xe7, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0xce, 0x1c, 0x3d, 0x5, 0x2, 0x0, 0x0, - 0x5b, 0x70, 0x0, 0xb, 0x68, 0x24, 0x33, 0x1b, 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x15, 0x31, 0xd0, 0xc, 0x50, 0x16, 0x8f, 0xdf, 0x0, 0xd, - 0x2d, 0xa1, 0x18, 0xe9, 0x1d, 0x41, 0x81, 0xc3, 0x6e, 0x2c, 0xd6, 0x2, 0x8a}; +// ConnectRequest {_username = Just "fF\131\191\&2\166\189\187F", _password = Nothing, _lastWill = Just (LastWill +// {_willRetain = False, _willQoS = QoS1, _willTopic = "\ESC\162W>\201\134", _willMsg = +// "\CAN\EOT\254w\EOT&B2\STX\130\DC2\130\234\202\238\&1\DC4\179\ETB\223\169\132GI&\ACK", _willProps = []}), +// _cleanSession = False, _keepAlive = 16611, _connID = "P\213\SOHx\239\228P", _properties = []} +TEST(Connect5QCTest, Encode29) { + uint8_t pkt[] = {0x10, 0x44, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x8c, 0x40, 0xe3, 0x0, 0x0, + 0x7, 0x50, 0xd5, 0x1, 0x78, 0xef, 0xe4, 0x50, 0x0, 0x0, 0x6, 0x1b, 0xa2, 0x57, + 0x3e, 0xc9, 0x86, 0x0, 0x1a, 0x18, 0x4, 0xfe, 0x77, 0x4, 0x26, 0x42, 0x32, 0x2, + 0x82, 0x12, 0x82, 0xea, 0xca, 0xee, 0x31, 0x14, 0xb3, 0x17, 0xdf, 0xa9, 0x84, 0x47, + 0x49, 0x26, 0x6, 0x0, 0x9, 0x66, 0x46, 0x83, 0xbf, 0x32, 0xa6, 0xbd, 0xbb, 0x46}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23408}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_will_t will = lwmqtt_default_will; - uint8_t byteswillprops0[] = {0xc1, 0xf8, 0x68, 0x97, 0x49, 0xc3, 0x98, 0xd5, - 0xb3, 0x6f, 0xc8, 0xa9, 0xab, 0x5e, 0x4d}; - uint8_t byteswillprops1[] = {0xbb, 0x47, 0x16, 0xc0, 0x3e, 0x5a, 0x7f, 0xd3, 0xce, 0xf8, 0x49, 0x40, 0xa1, 0x63, 0x37, - 0x95, 0xc, 0xa2, 0x2b, 0xca, 0x81, 0xf, 0x4, 0xb0, 0x7d, 0x31, 0x24, 0xd5, 0xd2}; - uint8_t byteswillprops2[] = {0x87, 0x12, 0x2c, 0x3d, 0x3a, 0x6, 0xe0, 0x48, - 0xb0, 0xcf, 0x83, 0x8e, 0xf0, 0x97, 0xd0, 0x2e}; - uint8_t byteswillprops3[] = {0x86, 0x5f, 0xa7, 0x10, 0xea}; - uint8_t byteswillprops4[] = {0x96, 0x9e, 0x87, 0xd4, 0x67, 0x84, 0x91, 0xf6, - 0x5f, 0x35, 0xff, 0x21, 0x22, 0x67, 0x2a}; - uint8_t byteswillprops5[] = {0x6d, 0xda, 0xa6, 0x2f, 0x3b, 0xdf, 0x2d, 0x12, 0x51, 0xff, 0x96, 0x90, 0x98, 0xf2, 0xfb, - 0x84, 0xdf, 0x9, 0x9c, 0xd4, 0xbe, 0x65, 0x6a, 0xd9, 0x57, 0xa, 0xda, 0x86, 0xb6}; - lwmqtt_property_t willpropslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9787}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 223}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&byteswillprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&byteswillprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {5, (char*)&byteswillprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {15, (char*)&byteswillprops4}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 597}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {29, (char*)&byteswillprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28656}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, - }; + lwmqtt_property_t willpropslist[] = {}; - lwmqtt_properties_t willprops = {13, (lwmqtt_property_t*)&willpropslist}; - uint8_t will_topic_bytes[] = {0xa3}; - lwmqtt_string_t will_topic = {1, (char*)&will_topic_bytes}; - uint8_t will_payload_bytes[] = {0x5e, 0xd8, 0xc2, 0x38, 0x2d, 0x56, 0x60, 0xbf, 0x22, 0xd7, 0xf7, - 0xdd, 0xd2, 0x9, 0x4, 0xe, 0x74, 0xd1, 0xcd, 0xf, 0xe}; - lwmqtt_string_t will_payload = {21, (char*)&will_payload_bytes}; + lwmqtt_properties_t willprops = {0, (lwmqtt_property_t*)&willpropslist}; + uint8_t will_topic_bytes[] = {0x1b, 0xa2, 0x57, 0x3e, 0xc9, 0x86}; + lwmqtt_string_t will_topic = {6, (char*)&will_topic_bytes}; + uint8_t will_payload_bytes[] = {0x18, 0x4, 0xfe, 0x77, 0x4, 0x26, 0x42, 0x32, 0x2, 0x82, 0x12, 0x82, 0xea, + 0xca, 0xee, 0x31, 0x14, 0xb3, 0x17, 0xdf, 0xa9, 0x84, 0x47, 0x49, 0x26, 0x6}; + lwmqtt_string_t will_payload = {26, (char*)&will_payload_bytes}; will.topic = will_topic; will.payload = will_payload; will.qos = LWMQTT_QOS1; @@ -13749,17 +13091,14 @@ TEST(Connect5QCTest, Encode28) { will.properties = willprops; lwmqtt_options_t opts = lwmqtt_default_options; opts.properties = props; - opts.clean_session = true; - opts.keep_alive = 7229; - uint8_t client_id_bytes[] = {0x68, 0x24, 0x33, 0x1b, 0x25, 0xe5, 0x86, 0x2d, 0x1e, 0xcd, 0x4f}; - lwmqtt_string_t client_id = {11, (char*)&client_id_bytes}; + opts.clean_session = false; + opts.keep_alive = 16611; + uint8_t client_id_bytes[] = {0x50, 0xd5, 0x1, 0x78, 0xef, 0xe4, 0x50}; + lwmqtt_string_t client_id = {7, (char*)&client_id_bytes}; opts.client_id = client_id; - uint8_t username_bytes[] = {0x57, 0x15, 0x31, 0xd0, 0xc, 0x50, 0x16, 0x8f, 0xdf}; + uint8_t username_bytes[] = {0x66, 0x46, 0x83, 0xbf, 0x32, 0xa6, 0xbd, 0xbb, 0x46}; lwmqtt_string_t username = {9, (char*)&username_bytes}; opts.username = username; - uint8_t password_bytes[] = {0x2d, 0xa1, 0x18, 0xe9, 0x1d, 0x41, 0x81, 0xc3, 0x6e, 0x2c, 0xd6, 0x2, 0x8a}; - lwmqtt_string_t password = {13, (char*)&password_bytes}; - opts.password = password; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_connect(buf, sizeof(buf), &len, LWMQTT_MQTT5, opts, &will); @@ -13768,215 +13107,178 @@ TEST(Connect5QCTest, Encode28) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// ConnectRequest {_username = Just "E\158", _password = Nothing, _lastWill = Just (LastWill {_willRetain = False, -// _willQoS = QoS0, _willTopic = "\SUB\167\200rR\DEL\237>\147\&3\t-\134,", _willMsg = -// "\EOT{\DC2S\216=\181\216\SOH\225\153\&6(\205\197\&1\ETX\STX\DEL", _willProps = [PropAssignedClientIdentifier -// "\128\147\216",PropResponseTopic "\223\n\ETX\154",PropAuthenticationMethod "",PropMessageExpiryInterval -// 25357,PropRetainAvailable 106,PropUserProperty "\143\RS=-\160\211kh/\145\222\245Y_P\b" -// "\230v\246\"\\",PropRequestProblemInformation 234,PropResponseTopic ",",PropMaximumPacketSize -// 5551,PropSessionExpiryInterval 17112,PropSharedSubscriptionAvailable 218,PropReceiveMaximum -// 12477,PropSharedSubscriptionAvailable 247]}), _cleanSession = True, _keepAlive = 27479, _connID = -// "\237\&2\143\179g\138\189\190\155l\NUL\242~\ETXJ\222^\147-\STX\140\210\198a\249", _properties = [PropRetainAvailable -// 170,PropRequestProblemInformation 45,PropAssignedClientIdentifier -// "\234\177`\245r\153\235\130\209\227-\190a\208\n\195\141\188\RSD",PropRequestResponseInformation 3]} -TEST(Connect5QCTest, Encode29) { - uint8_t pkt[] = {0x10, 0xb5, 0x1, 0x0, 0x4, 0x4d, 0x51, 0x54, 0x54, 0x5, 0x86, 0x6b, 0x57, 0x1d, 0x25, 0xaa, 0x17, - 0x2d, 0x12, 0x0, 0x14, 0xea, 0xb1, 0x60, 0xf5, 0x72, 0x99, 0xeb, 0x82, 0xd1, 0xe3, 0x2d, 0xbe, 0x61, - 0xd0, 0xa, 0xc3, 0x8d, 0xbc, 0x1e, 0x44, 0x19, 0x3, 0x0, 0x19, 0xed, 0x32, 0x8f, 0xb3, 0x67, 0x8a, - 0xbd, 0xbe, 0x9b, 0x6c, 0x0, 0xf2, 0x7e, 0x3, 0x4a, 0xde, 0x5e, 0x93, 0x2d, 0x2, 0x8c, 0xd2, 0xc6, - 0x61, 0xf9, 0x48, 0x12, 0x0, 0x3, 0x80, 0x93, 0xd8, 0x8, 0x0, 0x4, 0xdf, 0xa, 0x3, 0x9a, 0x15, - 0x0, 0x0, 0x2, 0x0, 0x0, 0x63, 0xd, 0x25, 0x6a, 0x26, 0x0, 0x10, 0x8f, 0x1e, 0x3d, 0x2d, 0xa0, - 0xd3, 0x6b, 0x68, 0x2f, 0x91, 0xde, 0xf5, 0x59, 0x5f, 0x50, 0x8, 0x0, 0x5, 0xe6, 0x76, 0xf6, 0x22, - 0x5c, 0x17, 0xea, 0x8, 0x0, 0x1, 0x2c, 0x27, 0x0, 0x0, 0x15, 0xaf, 0x11, 0x0, 0x0, 0x42, 0xd8, - 0x2a, 0xda, 0x21, 0x30, 0xbd, 0x2a, 0xf7, 0x0, 0xe, 0x1a, 0xa7, 0xc8, 0x72, 0x52, 0x7f, 0xed, 0x3e, - 0x93, 0x33, 0x9, 0x2d, 0x86, 0x2c, 0x0, 0x13, 0x4, 0x7b, 0x12, 0x53, 0xd8, 0x3d, 0xb5, 0xd8, 0x1, - 0xe1, 0x99, 0x36, 0x28, 0xcd, 0xc5, 0x31, 0x3, 0x2, 0x7f, 0x0, 0x2, 0x45, 0x9e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xea, 0xb1, 0x60, 0xf5, 0x72, 0x99, 0xeb, 0x82, 0xd1, 0xe3, - 0x2d, 0xbe, 0x61, 0xd0, 0xa, 0xc3, 0x8d, 0xbc, 0x1e, 0x44}; +// ConnectRequest {_username = Just "y\204\237\224r>\158", _password = Nothing, _lastWill = Just (LastWill {_willRetain +// = False, _willQoS = QoS1, _willTopic = +// "[J\196H\203W\CAN\171&\151\152S\228\245A\CAN%\DLE\139+/j\RS\195wS\195p",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\DLE|\233_$",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("\249\204\STX\180\161\213{b_\SOHVAT",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\191\217\230\191\SUB\239\135\250\206K\133\131\159)OE\ACK\DC2#\203\133=~",SubOptions {_retainHandling = +// SubscribeRequest 30435 +// [("`h\241\RSu\235\248\SO\189\SUBS\214\231#\132\DEL\217\130\160\215\151\182j\252\240A",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\t +// \217\148d\224~\204\DEL3L\231\147\139\217",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\167\ESC\138~\151\139\229\133\197\&9\163\238",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("B\a\136\184\225Dtd\170\&1\162\128O\189e\160\233\186\135B\248",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS0}),("\n>\\\198\221l`h\165\131\238\145-\156\v\161\232\183\144=\232v\252\242\198{\140",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("u\191\218\ESC\245\204nb",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = +// QoS0}),("\176\169\&4\190\&0\241\238\237\150\241\162\234\148\RS\133\243\DC1(9\SYNZ\226\184\199",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("jW\202\231\176\GS\252\217\199\151\250\161\248",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Q \v\EM\165d\183\254\EOTw\224",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("N\ESCa1\203j8\230\EOT\160q,\148\239p\225RT\NAK",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode1) { - uint8_t pkt[] = {0x82, 0x7c, 0x3b, 0xd5, 0x0, 0x14, 0xd3, 0x21, 0xdb, 0xf5, 0x7d, 0xbf, 0x4b, 0xc4, 0xb, 0xbc, - 0x22, 0xee, 0xed, 0x52, 0xf2, 0x46, 0xf0, 0xb1, 0x90, 0xe5, 0x1, 0x0, 0x5, 0xc8, 0x63, 0x12, - 0x14, 0xe, 0x1, 0x0, 0x2, 0xa, 0x69, 0x0, 0x0, 0x9, 0x76, 0xd4, 0x3e, 0x1e, 0xc3, 0x77, - 0x53, 0xc3, 0x70, 0x0, 0x0, 0x5, 0x10, 0x7c, 0xe9, 0x5f, 0x24, 0x2, 0x0, 0xd, 0xf9, 0xcc,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, 0xed, 0x96, 0xf1, 0xa2, 0xea, 0x94, 0x1e, 0x85, 0xf3, 0x11, 0x28, 0x39, 0x16, + 0x5a, 0xe2, 0xb8, 0xc7, 0x0, 0x0, 0xd, 0x6a, 0x57, 0xca, 0xe7, 0xb0, 0x1d, 0xfc, 0xd9, 0xc7, 0x97, 0xfa, 0xa1, + 0xf8, 0x2, 0x0, 0xb, 0x51, 0x20, 0xb, 0x19, 0xa5, 0x64, 0xb7, 0xfe, 0x4, 0x77, 0xe0, 0x1, 0x0, 0x13, 0x4e, + 0x1b, 0x61, 0x31, 0xcb, 0x6a, 0x38, 0xe6, 0x4, 0xa0, 0x71, 0x2c, 0x94, 0xef, 0x70, 0xe1, 0x52, 0x54, 0x15, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xd3, 0x21, 0xdb, 0xf5, 0x7d, 0xbf, 0x4b, 0xc4, 0xb, 0xbc, - 0x22, 0xee, 0xed, 0x52, 0xf2, 0x46, 0xf0, 0xb1, 0x90, 0xe5}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x60, 0x68, 0xf1, 0x1e, 0x75, 0xeb, 0xf8, 0xe, 0xbd, 0x1a, 0x53, 0xd6, 0xe7, + 0x23, 0x84, 0x7f, 0xd9, 0x82, 0xa0, 0xd7, 0x97, 0xb6, 0x6a, 0xfc, 0xf0, 0x41}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc8, 0x63, 0x12, 0x14, 0xe}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9, 0x20, 0xd9, 0x94, 0x64, 0xe0, 0x7e, 0xcc, + 0x7f, 0x33, 0x4c, 0xe7, 0x93, 0x8b, 0xd9}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa, 0x69}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa7, 0x1b, 0x8a, 0x7e, 0x97, 0x8b, 0xe5, 0x85, 0xc5, 0x39, 0xa3, 0xee}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x76, 0xd4, 0x3e, 0x1e, 0xc3, 0x77, 0x53, 0xc3, 0x70}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa, 0x3e, 0x5c, 0xc6, 0xdd, 0x6c, 0x60, 0x68, 0xa5, 0x83, 0xee, 0x91, 0x2d, 0x9c, + 0xb, 0xa1, 0xe8, 0xb7, 0x90, 0x3d, 0xe8, 0x76, 0xfc, 0xf2, 0xc6, 0x7b, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x10, 0x7c, 0xe9, 0x5f, 0x24}; - lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x75, 0xbf, 0xda, 0x1b, 0xf5, 0xcc, 0x6e, 0x62}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf9, 0xcc, 0x2, 0xb4, 0xa1, 0xd5, 0x7b, 0x62, 0x5f, 0x1, 0x56, 0x41, 0x54}; - lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbf, 0xd9, 0xe6, 0xbf, 0x1a, 0xef, 0x87, 0xfa, 0xce, 0x4b, 0x85, 0x83, - 0x9f, 0x29, 0x4f, 0x45, 0x6, 0x12, 0x23, 0xcb, 0x85, 0x3d, 0x7e}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb0, 0xa9, 0x34, 0xbe, 0x30, 0xf1, 0xee, 0xed, 0x96, 0xf1, 0xa2, 0xea, + 0x94, 0x1e, 0x85, 0xf3, 0x11, 0x28, 0x39, 0x16, 0x5a, 0xe2, 0xb8, 0xc7}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x42, 0x7, 0x88, 0xb8, 0xe1, 0x44, 0x74, 0x64, 0xaa, 0x31, 0xa2, - 0x80, 0x4f, 0xbd, 0x65, 0xa0, 0xe9, 0xba, 0x87, 0x42, 0xf8}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x6a, 0x57, 0xca, 0xe7, 0xb0, 0x1d, 0xfc, 0xd9, 0xc7, 0x97, 0xfa, 0xa1, 0xf8}; + lwmqtt_string_t topic_filter_s7 = {13, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s8_bytes[] = {0x51, 0x20, 0xb, 0x19, 0xa5, 0x64, 0xb7, 0xfe, 0x4, 0x77, 0xe0}; + lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x4e, 0x1b, 0x61, 0x31, 0xcb, 0x6a, 0x38, 0xe6, 0x4, 0xa0, + 0x71, 0x2c, 0x94, 0xef, 0x70, 0xe1, 0x52, 0x54, 0x15}; + lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -13988,111 +13290,116 @@ TEST(Subscribe311QCTest, Encode1) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].qos = LWMQTT_QOS0; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15317, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30435, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 2981 [("p\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("^w\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS2}),("Q\CANiG\n\136\149\SOH\aL\225\243%\139\253W\156FD)\188r5\236s\179^\166",SubOptions +// SubscribeRequest 2083 +// [("\168\136\255:\130\SUB\133;\147<\234\247\227\169\216d\131:D\219\GS\190\200O2\203\149\212",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\144\145\182\194\&1'\245",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2})] [] +// QoS0}),("\219\203o\224\154\&9\229\144\a\219e\152\161\219hhF\236O\129\192h\ETXY\148\&9\150\204.\250",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode2) { - uint8_t pkt[] = {0x82, 0x36, 0xb, 0xa5, 0x0, 0x2, 0x70, 0xc5, 0x1, 0x0, 0x3, 0x5e, 0x77, 0xba, - 0x2, 0x0, 0x1c, 0x51, 0x18, 0x69, 0x47, 0xa, 0x88, 0x95, 0x1, 0x7, 0x4c, 0xe1, - 0xf3, 0x25, 0x8b, 0xfd, 0x57, 0x9c, 0x46, 0x44, 0x29, 0xbc, 0x72, 0x35, 0xec, 0x73, - 0xb3, 0x5e, 0xa6, 0x1, 0x0, 0x7, 0x90, 0x91, 0xb6, 0xc2, 0x31, 0x27, 0xf5, 0x2}; + uint8_t pkt[] = {0x82, 0x42, 0x8, 0x23, 0x0, 0x1c, 0xa8, 0x88, 0xff, 0x3a, 0x82, 0x1a, 0x85, 0x3b, 0x93, 0x3c, 0xea, + 0xf7, 0xe3, 0xa9, 0xd8, 0x64, 0x83, 0x3a, 0x44, 0xdb, 0x1d, 0xbe, 0xc8, 0x4f, 0x32, 0xcb, 0x95, 0xd4, + 0x0, 0x0, 0x1e, 0xdb, 0xcb, 0x6f, 0xe0, 0x9a, 0x39, 0xe5, 0x90, 0x7, 0xdb, 0x65, 0x98, 0xa1, 0xdb, + 0x68, 0x68, 0x46, 0xec, 0x4f, 0x81, 0xc0, 0x68, 0x3, 0x59, 0x94, 0x39, 0x96, 0xcc, 0x2e, 0xfa, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x70, 0xc5}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xa8, 0x88, 0xff, 0x3a, 0x82, 0x1a, 0x85, 0x3b, 0x93, 0x3c, + 0xea, 0xf7, 0xe3, 0xa9, 0xd8, 0x64, 0x83, 0x3a, 0x44, 0xdb, + 0x1d, 0xbe, 0xc8, 0x4f, 0x32, 0xcb, 0x95, 0xd4}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5e, 0x77, 0xba}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xdb, 0xcb, 0x6f, 0xe0, 0x9a, 0x39, 0xe5, 0x90, 0x7, 0xdb, + 0x65, 0x98, 0xa1, 0xdb, 0x68, 0x68, 0x46, 0xec, 0x4f, 0x81, + 0xc0, 0x68, 0x3, 0x59, 0x94, 0x39, 0x96, 0xcc, 0x2e, 0xfa}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x51, 0x18, 0x69, 0x47, 0xa, 0x88, 0x95, 0x1, 0x7, 0x4c, - 0xe1, 0xf3, 0x25, 0x8b, 0xfd, 0x57, 0x9c, 0x46, 0x44, 0x29, - 0xbc, 0x72, 0x35, 0xec, 0x73, 0xb3, 0x5e, 0xa6}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x90, 0x91, 0xb6, 0xc2, 0x31, 0x27, 0xf5}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2981, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2083, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15094 [("\210\248\243\&0\128\183m\131\255\nK\158\GS\237\168\184^\196\151 -// \163i\204\242\EM/\208",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("\195=\233\&0\253\&5Li\207\224\152Y@mA[\139<\135y;\188",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// SubscribeRequest 7451 [("^\181\143}(\238\228\"\243)\\U\DEL\166\161 \193\176\226P\219\EOT\253\191",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("!g\t\b\193\GS\FS\188!\172",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("D2>\192%7\NUL54",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\172D\201\155j\142)Wc\150\143Cc\217\220\253\GS\238m\161\\f",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0x39, 0x3a, 0xf6, 0x0, 0x1b, 0xd2, 0xf8, 0xf3, 0x30, 0x80, 0xb7, 0x6d, 0x83, 0xff, - 0xa, 0x4b, 0x9e, 0x1d, 0xed, 0xa8, 0xb8, 0x5e, 0xc4, 0x97, 0x20, 0xa3, 0x69, 0xcc, 0xf2, - 0x19, 0x2f, 0xd0, 0x2, 0x0, 0x16, 0xc3, 0x3d, 0xe9, 0x30, 0xfd, 0x35, 0x4c, 0x69, 0xcf, - 0xe0, 0x98, 0x59, 0x40, 0x6d, 0x41, 0x5b, 0x8b, 0x3c, 0x87, 0x79, 0x3b, 0xbc, 0x1}; + uint8_t pkt[] = {0x82, 0x4f, 0x1d, 0x1b, 0x0, 0x18, 0x5e, 0xb5, 0x8f, 0x7d, 0x28, 0xee, 0xe4, 0x22, 0xf3, 0x29, 0x5c, + 0x55, 0x7f, 0xa6, 0xa1, 0x20, 0xc1, 0xb0, 0xe2, 0x50, 0xdb, 0x4, 0xfd, 0xbf, 0x0, 0x0, 0xa, 0x21, + 0x67, 0x9, 0x8, 0xc1, 0x1d, 0x1c, 0xbc, 0x21, 0xac, 0x1, 0x0, 0x9, 0x44, 0x32, 0x3e, 0xc0, 0x25, + 0x37, 0x0, 0x35, 0x34, 0x0, 0x0, 0x16, 0xac, 0x44, 0xc9, 0x9b, 0x6a, 0x8e, 0x29, 0x57, 0x63, 0x96, + 0x8f, 0x43, 0x63, 0xd9, 0xdc, 0xfd, 0x1d, 0xee, 0x6d, 0xa1, 0x5c, 0x66, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xd2, 0xf8, 0xf3, 0x30, 0x80, 0xb7, 0x6d, 0x83, 0xff, 0xa, 0x4b, 0x9e, 0x1d, 0xed, - 0xa8, 0xb8, 0x5e, 0xc4, 0x97, 0x20, 0xa3, 0x69, 0xcc, 0xf2, 0x19, 0x2f, 0xd0}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x5e, 0xb5, 0x8f, 0x7d, 0x28, 0xee, 0xe4, 0x22, 0xf3, 0x29, 0x5c, 0x55, + 0x7f, 0xa6, 0xa1, 0x20, 0xc1, 0xb0, 0xe2, 0x50, 0xdb, 0x4, 0xfd, 0xbf}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc3, 0x3d, 0xe9, 0x30, 0xfd, 0x35, 0x4c, 0x69, 0xcf, 0xe0, 0x98, - 0x59, 0x40, 0x6d, 0x41, 0x5b, 0x8b, 0x3c, 0x87, 0x79, 0x3b, 0xbc}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x21, 0x67, 0x9, 0x8, 0xc1, 0x1d, 0x1c, 0xbc, 0x21, 0xac}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s2_bytes[] = {0x44, 0x32, 0x3e, 0xc0, 0x25, 0x37, 0x0, 0x35, 0x34}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xac, 0x44, 0xc9, 0x9b, 0x6a, 0x8e, 0x29, 0x57, 0x63, 0x96, 0x8f, + 0x43, 0x63, 0xd9, 0xdc, 0xfd, 0x1d, 0xee, 0x6d, 0xa1, 0x5c, 0x66}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -14100,92 +13407,94 @@ TEST(Subscribe311QCTest, Encode3) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15094, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7451, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 31975 [("v\DC3\131\242\151\153\129\216\200a\205\NAK\v\195!\164#\222\225\ESC<",SubOptions +// SubscribeRequest 12482 [("\240\185\219h?\152\186\bA)\215<\169\164\"\193cb\ENQA\175\150%\240PA\255\238",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("a\238tQ\162\133\229\228\DC3<\233\243=Bx`\165\DLE\146J\255",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("*i\190\134\153\235\221\NUL\181\244\166\143\v\164o2",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("{\242\196\145X\GS -// \170E\155\&3m\235\143B\220h-",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\240\182WL\223\230\175\ETX\195gN\NAK\STXM\DC4\SYN\240k\a\229\195\151\248\199",SubOptions +// QoS2}),("\191=\159\232\202\226?4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2}),("E\132\197l\158",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\241\167y\214\226%\t\ETBii\EM\DEL\170\&4g\168",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\144\195e\r\DC2\190\186\229\NUL\DEL\167\202\DC4\190\184X\bB\189\217\236\174<\253\&2\144\US\SYNq",SubOptions +// QoS2}),("\241\224o\202\161\218\237%\226a\207.\254\DC2\153\232\150,\214\&4\f\"\137Q\190\n#Y",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\136\&9\f\v\189\145\182%\141\241\CAN\176>-\209|;",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\191u\SYN\194\143\199\229#\182\174\STX\150\132\152\142\DC3\US{\221}\245\208\241\211B\155\&8",SubOptions +// QoS2}),("\DC4\240C\b\241\141\151\128\ACK\RSY\\\DLE%",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\NULMD\CAN\134\155\213\216\137",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("63\167",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS -// = QoS0})] [] +// QoS2}),("\235v\226a\SOHS\196\195R\194,\230\195lcY\213m\211\GS\239\r",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\177\202\DC4\217\183\255t@4q\RS\194uK",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode4) { - uint8_t pkt[] = { - 0x82, 0xcd, 0x1, 0x7c, 0xe7, 0x0, 0x15, 0x76, 0x13, 0x83, 0xf2, 0x97, 0x99, 0x81, 0xd8, 0xc8, 0x61, 0xcd, 0x15, - 0xb, 0xc3, 0x21, 0xa4, 0x23, 0xde, 0xe1, 0x1b, 0x3c, 0x1, 0x0, 0x15, 0x61, 0xee, 0x74, 0x51, 0xa2, 0x85, 0xe5, - 0xe4, 0x13, 0x3c, 0xe9, 0xf3, 0x3d, 0x42, 0x78, 0x60, 0xa5, 0x10, 0x92, 0x4a, 0xff, 0x1, 0x0, 0x10, 0x2a, 0x69, - 0xbe, 0x86, 0x99, 0xeb, 0xdd, 0x0, 0xb5, 0xf4, 0xa6, 0x8f, 0xb, 0xa4, 0x6f, 0x32, 0x1, 0x0, 0x12, 0x7b, 0xf2, - 0xc4, 0x91, 0x58, 0x1d, 0x20, 0xaa, 0x45, 0x9b, 0x33, 0x6d, 0xeb, 0x8f, 0x42, 0xdc, 0x68, 0x2d, 0x0, 0x0, 0x18, - 0xf0, 0xb6, 0x57, 0x4c, 0xdf, 0xe6, 0xaf, 0x3, 0xc3, 0x67, 0x4e, 0x15, 0x2, 0x4d, 0x14, 0x16, 0xf0, 0x6b, 0x7, - 0xe5, 0xc3, 0x97, 0xf8, 0xc7, 0x1, 0x0, 0x1d, 0x90, 0xc3, 0x65, 0xd, 0x12, 0xbe, 0xba, 0xe5, 0x0, 0x7f, 0xa7, - 0xca, 0x14, 0xbe, 0xb8, 0x58, 0x8, 0x42, 0xbd, 0xd9, 0xec, 0xae, 0x3c, 0xfd, 0x32, 0x90, 0x1f, 0x16, 0x71, 0x1, - 0x0, 0x11, 0x88, 0x39, 0xc, 0xb, 0xbd, 0x91, 0xb6, 0x25, 0x8d, 0xf1, 0x18, 0xb0, 0x3e, 0x2d, 0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0xc2, 0x2c, 0xe6, 0xc3, 0x6c, 0x63, 0x59, 0xd5, 0x6d, 0xd3, 0x1d, 0xef, 0xd, 0x2, 0x0, + 0xe, 0xb1, 0xca, 0x14, 0xd9, 0xb7, 0xff, 0x74, 0x40, 0x34, 0x71, 0x1e, 0xc2, 0x75, 0x4b, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x76, 0x13, 0x83, 0xf2, 0x97, 0x99, 0x81, 0xd8, 0xc8, 0x61, 0xcd, - 0x15, 0xb, 0xc3, 0x21, 0xa4, 0x23, 0xde, 0xe1, 0x1b, 0x3c}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xf0, 0xb9, 0xdb, 0x68, 0x3f, 0x98, 0xba, 0x8, 0x41, 0x29, + 0xd7, 0x3c, 0xa9, 0xa4, 0x22, 0xc1, 0x63, 0x62, 0x5, 0x41, + 0xaf, 0x96, 0x25, 0xf0, 0x50, 0x41, 0xff, 0xee}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x61, 0xee, 0x74, 0x51, 0xa2, 0x85, 0xe5, 0xe4, 0x13, 0x3c, 0xe9, - 0xf3, 0x3d, 0x42, 0x78, 0x60, 0xa5, 0x10, 0x92, 0x4a, 0xff}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbf, 0x3d, 0x9f, 0xe8, 0xca, 0xe2, 0x3f, 0x34}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2a, 0x69, 0xbe, 0x86, 0x99, 0xeb, 0xdd, 0x0, - 0xb5, 0xf4, 0xa6, 0x8f, 0xb, 0xa4, 0x6f, 0x32}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x45, 0x84, 0xc5, 0x6c, 0x9e}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x7b, 0xf2, 0xc4, 0x91, 0x58, 0x1d, 0x20, 0xaa, 0x45, - 0x9b, 0x33, 0x6d, 0xeb, 0x8f, 0x42, 0xdc, 0x68, 0x2d}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf1, 0xa7, 0x79, 0xd6, 0xe2, 0x25, 0x9, 0x17, + 0x69, 0x69, 0x19, 0x7f, 0xaa, 0x34, 0x67, 0xa8}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xf0, 0xb6, 0x57, 0x4c, 0xdf, 0xe6, 0xaf, 0x3, 0xc3, 0x67, 0x4e, 0x15, - 0x2, 0x4d, 0x14, 0x16, 0xf0, 0x6b, 0x7, 0xe5, 0xc3, 0x97, 0xf8, 0xc7}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xf1, 0xe0, 0x6f, 0xca, 0xa1, 0xda, 0xed, 0x25, 0xe2, 0x61, + 0xcf, 0x2e, 0xfe, 0x12, 0x99, 0xe8, 0x96, 0x2c, 0xd6, 0x34, + 0xc, 0x22, 0x89, 0x51, 0xbe, 0xa, 0x23, 0x59}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x90, 0xc3, 0x65, 0xd, 0x12, 0xbe, 0xba, 0xe5, 0x0, 0x7f, - 0xa7, 0xca, 0x14, 0xbe, 0xb8, 0x58, 0x8, 0x42, 0xbd, 0xd9, - 0xec, 0xae, 0x3c, 0xfd, 0x32, 0x90, 0x1f, 0x16, 0x71}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x14, 0xf0, 0x43, 0x8, 0xf1, 0x8d, 0x97, 0x80, 0x6, 0x1e, 0x59, 0x5c, 0x10, 0x25}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x88, 0x39, 0xc, 0xb, 0xbd, 0x91, 0xb6, 0x25, 0x8d, - 0xf1, 0x18, 0xb0, 0x3e, 0x2d, 0xd1, 0x7c, 0x3b}; - lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x0, 0x4d, 0x44, 0x18, 0x86, 0x9b, 0xd5, 0xd8, 0x89}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xbf, 0x75, 0x16, 0xc2, 0x8f, 0xc7, 0xe5, 0x23, 0xb6, 0xae, 0x2, 0x96, 0x84, 0x98, - 0x8e, 0x13, 0x1f, 0x7b, 0xdd, 0x7d, 0xf5, 0xd0, 0xf1, 0xd3, 0x42, 0x9b, 0x38}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xeb, 0x76, 0xe2, 0x61, 0x1, 0x53, 0xc4, 0xc3, 0x52, 0xc2, 0x2c, + 0xe6, 0xc3, 0x6c, 0x63, 0x59, 0xd5, 0x6d, 0xd3, 0x1d, 0xef, 0xd}; + lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x36, 0x33, 0xa7}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xb1, 0xca, 0x14, 0xd9, 0xb7, 0xff, 0x74, + 0x40, 0x34, 0x71, 0x1e, 0xc2, 0x75, 0x4b}; + lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -14193,23 +13502,23 @@ TEST(Subscribe311QCTest, Encode4) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; + sub_opts[7].qos = LWMQTT_QOS2; sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; @@ -14223,189 +13532,208 @@ TEST(Subscribe311QCTest, Encode4) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31975, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12482, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25478 [("\219SY?\CAN\SOHQE\164",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS0}),("\183\ENQ\209\132\194\DELz\220\v\150\RSf\145?a\170\217x\159\172",SubOptions {_retainHandling = +// SubscribeRequest 30449 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS2}),("\141\164\198",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("n\154\FS\SOH\163",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("%+\\\SOH\ETX\139g?h",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("v\193\162\ETX\200\RSE\250\235",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0})] [] +// QoS0}),("\233\208\172\204\212\234\ETXYP\192\163\217x\DC2\154\144\143@1\240\206\161\250",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("-\143",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0x31, 0x63, 0x86, 0x0, 0x9, 0xdb, 0x53, 0x59, 0x3f, 0x18, 0x1, 0x51, 0x45, 0xa4, 0x0, 0x0, - 0x14, 0xb7, 0x5, 0xd1, 0x84, 0xc2, 0x7f, 0x7a, 0xdc, 0xb, 0x96, 0x1e, 0x66, 0x91, 0x3f, 0x61, 0xaa, - 0xd9, 0x78, 0x9f, 0xac, 0x2, 0x0, 0x9, 0x76, 0xc1, 0xa2, 0x3, 0xc8, 0x1e, 0x45, 0xfa, 0xeb, 0x0}; + uint8_t pkt[] = { + 0x82, 0xa8, 0x1, 0x76, 0xf1, 0x0, 0x0, 0x2, 0x0, 0x3, 0x8d, 0xa4, 0xc6, 0x1, 0x0, 0x5, 0x6e, 0x9a, 0x1c, + 0x1, 0xa3, 0x1, 0x0, 0x9, 0x25, 0x2b, 0x5c, 0x1, 0x3, 0x8b, 0x67, 0x3f, 0x68, 0x0, 0x0, 0x1e, 0xe9, 0xd0, + 0xac, 0xcc, 0xd4, 0xea, 0x3, 0x59, 0x50, 0xc0, 0xa3, 0xd9, 0x78, 0x12, 0x9a, 0x90, 0x8f, 0x40, 0x31, 0xf0, 0xce, + 0x3c, 0x43, 0x8b, 0xe9, 0x34, 0x82, 0x31, 0x84, 0xe9, 0x0, 0x0, 0x4, 0x40, 0xf8, 0x55, 0x8e, 0x0, 0x0, 0x1b, + 0x63, 0x26, 0x59, 0x37, 0x8f, 0x2e, 0x93, 0x54, 0x4c, 0x98, 0xa8, 0x9c, 0xb0, 0x4b, 0xce, 0x40, 0x26, 0xf9, 0xf7, + 0xd8, 0x13, 0x55, 0x3, 0x1a, 0xfc, 0x40, 0x57, 0x1, 0x0, 0x3, 0x60, 0x90, 0x37, 0x0, 0x0, 0x1a, 0x1f, 0xcb, + 0x76, 0xd4, 0x8f, 0xb7, 0x17, 0xdb, 0x4b, 0xbd, 0x1e, 0xe8, 0xc9, 0x44, 0x60, 0x7, 0x21, 0xf, 0xc8, 0xfe, 0x6, + 0x59, 0x1e, 0xb7, 0x7c, 0x4d, 0x2, 0x0, 0x18, 0x5b, 0xe, 0xf2, 0xb7, 0x96, 0xdc, 0xe2, 0x8f, 0x15, 0xa1, 0x11, + 0x6a, 0xaf, 0xdd, 0xf0, 0x70, 0x3a, 0x9a, 0x3b, 0x68, 0x5e, 0x3e, 0xa1, 0xfa, 0x2, 0x0, 0x2, 0x2d, 0x8f, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xdb, 0x53, 0x59, 0x3f, 0x18, 0x1, 0x51, 0x45, 0xa4}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb7, 0x5, 0xd1, 0x84, 0xc2, 0x7f, 0x7a, 0xdc, 0xb, 0x96, - 0x1e, 0x66, 0x91, 0x3f, 0x61, 0xaa, 0xd9, 0x78, 0x9f, 0xac}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x8d, 0xa4, 0xc6}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x76, 0xc1, 0xa2, 0x3, 0xc8, 0x1e, 0x45, 0xfa, 0xeb}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6e, 0x9a, 0x1c, 0x1, 0xa3}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s3_bytes[] = {0x25, 0x2b, 0x5c, 0x1, 0x3, 0x8b, 0x67, 0x3f, 0x68}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe9, 0xd0, 0xac, 0xcc, 0xd4, 0xea, 0x3, 0x59, 0x50, 0xc0, + 0xa3, 0xd9, 0x78, 0x12, 0x9a, 0x90, 0x8f, 0x40, 0x31, 0xf0, + 0xce, 0x3c, 0x43, 0x8b, 0xe9, 0x34, 0x82, 0x31, 0x84, 0xe9}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x40, 0xf8, 0x55, 0x8e}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x63, 0x26, 0x59, 0x37, 0x8f, 0x2e, 0x93, 0x54, 0x4c, 0x98, 0xa8, 0x9c, 0xb0, 0x4b, + 0xce, 0x40, 0x26, 0xf9, 0xf7, 0xd8, 0x13, 0x55, 0x3, 0x1a, 0xfc, 0x40, 0x57}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x60, 0x90, 0x37}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x1f, 0xcb, 0x76, 0xd4, 0x8f, 0xb7, 0x17, 0xdb, 0x4b, 0xbd, 0x1e, 0xe8, 0xc9, + 0x44, 0x60, 0x7, 0x21, 0xf, 0xc8, 0xfe, 0x6, 0x59, 0x1e, 0xb7, 0x7c, 0x4d}; + lwmqtt_string_t topic_filter_s8 = {26, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x5b, 0xe, 0xf2, 0xb7, 0x96, 0xdc, 0xe2, 0x8f, 0x15, 0xa1, 0x11, 0x6a, + 0xaf, 0xdd, 0xf0, 0x70, 0x3a, 0x9a, 0x3b, 0x68, 0x5e, 0x3e, 0xa1, 0xfa}; + lwmqtt_string_t topic_filter_s9 = {24, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x2d, 0x8f}; + lwmqtt_string_t topic_filter_s10 = {2, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25478, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30449, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 10292 -// [("\216C\ACK\176Ru\154\153\169y\232\US\188\236\130\166\245\218\&8\219\141\156\&2\174\210\231\171\f",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("F\251\229\161W\204c\GS\232y\155\133\149\FS\RS\168!Ni!\230\225\223\"*",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("z\255\209",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// SubscribeRequest 32182 [("\FS\DC3\128\252X\ETX\252\165T{QD\211\165q\226\248\251q\206\169A",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0x43, 0x28, 0x34, 0x0, 0x1c, 0xd8, 0x43, 0x6, 0xb0, 0x52, 0x75, 0x9a, 0x99, - 0xa9, 0x79, 0xe8, 0x1f, 0xbc, 0xec, 0x82, 0xa6, 0xf5, 0xda, 0x38, 0xdb, 0x8d, 0x9c, - 0x32, 0xae, 0xd2, 0xe7, 0xab, 0xc, 0x2, 0x0, 0x19, 0x46, 0xfb, 0xe5, 0xa1, 0x57, - 0xcc, 0x63, 0x1d, 0xe8, 0x79, 0x9b, 0x85, 0x95, 0x1c, 0x1e, 0xa8, 0x21, 0x4e, 0x69, - 0x21, 0xe6, 0xe1, 0xdf, 0x22, 0x2a, 0x1, 0x0, 0x3, 0x7a, 0xff, 0xd1, 0x0}; + uint8_t pkt[] = {0x82, 0x1b, 0x7d, 0xb6, 0x0, 0x16, 0x1c, 0x13, 0x80, 0xfc, 0x58, 0x3, 0xfc, 0xa5, 0x54, + 0x7b, 0x51, 0x44, 0xd3, 0xa5, 0x71, 0xe2, 0xf8, 0xfb, 0x71, 0xce, 0xa9, 0x41, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xd8, 0x43, 0x6, 0xb0, 0x52, 0x75, 0x9a, 0x99, 0xa9, 0x79, 0xe8, 0x1f, 0xbc, 0xec, - 0x82, 0xa6, 0xf5, 0xda, 0x38, 0xdb, 0x8d, 0x9c, 0x32, 0xae, 0xd2, 0xe7, 0xab, 0xc}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x1c, 0x13, 0x80, 0xfc, 0x58, 0x3, 0xfc, 0xa5, 0x54, 0x7b, 0x51, + 0x44, 0xd3, 0xa5, 0x71, 0xe2, 0xf8, 0xfb, 0x71, 0xce, 0xa9, 0x41}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x46, 0xfb, 0xe5, 0xa1, 0x57, 0xcc, 0x63, 0x1d, 0xe8, 0x79, 0x9b, 0x85, 0x95, - 0x1c, 0x1e, 0xa8, 0x21, 0x4e, 0x69, 0x21, 0xe6, 0xe1, 0xdf, 0x22, 0x2a}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7a, 0xff, 0xd1}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10292, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32182, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28082 -// [("\140\149\246\194\167\STX\161y\249\132\156~\130\254\201\SOH\t]\158a%Ix(\237v\155\239",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\239\191\NAKC\239\fO\ENQ\137\212*j\228\209\255\241\218\177\130",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\249]\224\SUBw\152l\185\139\aYg\DC1\SOHS\133\172",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("9\191\NAK(\225n\196\ETBp\206\175",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\131\SOHT\174\251+&V\131\139\217F\DC1\151\228j\247b\229",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\138\148\167\139=\204k2\161\181/\146\&0\141]\181\151\NUL\r\188\"\v\132\&1",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\202}\DLEqP\f\228\&3\199\161dJk\216\142XIapF0\134_\205\197\141\244\222\135",SubOptions {_retainHandling = +// SubscribeRequest 318 [("J\EM\RS\185P\242\251\199\SI\NAKzfK\180\a\175(t\FS\178N\EM",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\137ya\140\155\\\DEL\204\FS\216\244Xt\190\NULg\242\174\151\160\243",SubOptions {_retainHandling = +// QoS2}),(".y\253\aln\145\149/\203\DLE\135\254_\241\215\231:\192\163",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\251\175[\171\nR\197",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\"\DC4#\179\&1\GS#B\162\161\244\172c\DC4&\225",SubOptions {_retainHandling = SendOnSubscribe, +// QoS0}),("\153\f\DEL0\187\236\132%Lyr\231\f\135\134Mr(f\246",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\193^\197\214\CAN\240\155v(\145\239\174\201\134\236\232l\177\163",SubOptions {_retainHandling = +// QoS1}),("\173t\NUL)\205\182\DC3\CAN\230V\227e\230\128?\177\&1\179V",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\247\129\193tL",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] TEST(Subscribe311QCTest, Encode7) { - uint8_t pkt[] = {0x82, 0xeb, 0x1, 0x6d, 0xb2, 0x0, 0x1c, 0x8c, 0x95, 0xf6, 0xc2, 0xa7, 0x2, 0xa1, 0x79, 0xf9, 0x84, - 0x9c, 0x7e, 0x82, 0xfe, 0xc9, 0x1, 0x9, 0x5d, 0x9e, 0x61, 0x25, 0x49, 0x78, 0x28, 0xed, 0x76, 0x9b, - 0xef, 0x1, 0x0, 0x13, 0xef, 0xbf, 0x15, 0x43, 0xef, 0xc, 0x4f, 0x5, 0x89, 0xd4, 0x2a, 0x6a, 0xe4, - 0xd1, 0xff, 0xf1, 0xda, 0xb1, 0x82, 0x1, 0x0, 0x11, 0xf9, 0x5d, 0xe0, 0x1a, 0x77, 0x98, 0x6c, 0xb9, - 0x8b, 0x7, 0x59, 0x67, 0x11, 0x1, 0x53, 0x85, 0xac, 0x0, 0x0, 0xb, 0x39, 0xbf, 0x15, 0x28, 0xe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14, 0x2e, 0x79, 0xfd, + 0x7, 0x6c, 0x6e, 0x91, 0x95, 0x2f, 0xcb, 0x10, 0x87, 0xfe, 0x5f, 0xf1, 0xd7, 0xe7, 0x3a, 0xc0, 0xa3, + 0x1, 0x0, 0x7, 0xfb, 0xaf, 0x5b, 0xab, 0xa, 0x52, 0xc5, 0x0, 0x0, 0x14, 0x99, 0xc, 0x7f, 0x30, + 0xbb, 0xec, 0x84, 0x25, 0x4c, 0x79, 0x72, 0xe7, 0xc, 0x87, 0x86, 0x4d, 0x72, 0x28, 0x66, 0xf6, 0x1, + 0x0, 0x13, 0xad, 0x74, 0x0, 0x29, 0xcd, 0xb6, 0x13, 0x18, 0xe6, 0x56, 0xe3, 0x65, 0xe6, 0x80, 0x3f, + 0xb1, 0x31, 0xb3, 0x56, 0x0, 0x0, 0x5, 0xf7, 0x81, 0xc1, 0x74, 0x4c, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x8c, 0x95, 0xf6, 0xc2, 0xa7, 0x2, 0xa1, 0x79, 0xf9, 0x84, - 0x9c, 0x7e, 0x82, 0xfe, 0xc9, 0x1, 0x9, 0x5d, 0x9e, 0x61, - 0x25, 0x49, 0x78, 0x28, 0xed, 0x76, 0x9b, 0xef}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x4a, 0x19, 0x1e, 0xb9, 0x50, 0xf2, 0xfb, 0xc7, 0xf, 0x15, 0x7a, + 0x66, 0x4b, 0xb4, 0x7, 0xaf, 0x28, 0x74, 0x1c, 0xb2, 0x4e, 0x19}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xef, 0xbf, 0x15, 0x43, 0xef, 0xc, 0x4f, 0x5, 0x89, 0xd4, - 0x2a, 0x6a, 0xe4, 0xd1, 0xff, 0xf1, 0xda, 0xb1, 0x82}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2e, 0x79, 0xfd, 0x7, 0x6c, 0x6e, 0x91, 0x95, 0x2f, 0xcb, + 0x10, 0x87, 0xfe, 0x5f, 0xf1, 0xd7, 0xe7, 0x3a, 0xc0, 0xa3}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf9, 0x5d, 0xe0, 0x1a, 0x77, 0x98, 0x6c, 0xb9, 0x8b, - 0x7, 0x59, 0x67, 0x11, 0x1, 0x53, 0x85, 0xac}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xfb, 0xaf, 0x5b, 0xab, 0xa, 0x52, 0xc5}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x39, 0xbf, 0x15, 0x28, 0xe1, 0x6e, 0xc4, 0x17, 0x70, 0xce, 0xaf}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x99, 0xc, 0x7f, 0x30, 0xbb, 0xec, 0x84, 0x25, 0x4c, 0x79, + 0x72, 0xe7, 0xc, 0x87, 0x86, 0x4d, 0x72, 0x28, 0x66, 0xf6}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x83, 0x1, 0x54, 0xae, 0xfb, 0x2b, 0x26, 0x56, 0x83, 0x8b, - 0xd9, 0x46, 0x11, 0x97, 0xe4, 0x6a, 0xf7, 0x62, 0xe5}; + uint8_t topic_filter_s4_bytes[] = {0xad, 0x74, 0x0, 0x29, 0xcd, 0xb6, 0x13, 0x18, 0xe6, 0x56, + 0xe3, 0x65, 0xe6, 0x80, 0x3f, 0xb1, 0x31, 0xb3, 0x56}; lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8a, 0x94, 0xa7, 0x8b, 0x3d, 0xcc, 0x6b, 0x32, 0xa1, 0xb5, 0x2f, 0x92, - 0x30, 0x8d, 0x5d, 0xb5, 0x97, 0x0, 0xd, 0xbc, 0x22, 0xb, 0x84, 0x31}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf7, 0x81, 0xc1, 0x74, 0x4c}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xca, 0x7d, 0x10, 0x71, 0x50, 0xc, 0xe4, 0x33, 0xc7, 0xa1, - 0x64, 0x4a, 0x6b, 0xd8, 0x8e, 0x58, 0x49, 0x61, 0x70, 0x46, - 0x30, 0x86, 0x5f, 0xcd, 0xc5, 0x8d, 0xf4, 0xde, 0x87}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x89, 0x79, 0x61, 0x8c, 0x9b, 0x5c, 0x7f, 0xcc, 0x1c, 0xd8, 0xf4, - 0x58, 0x74, 0xbe, 0x0, 0x67, 0xf2, 0xae, 0x97, 0xa0, 0xf3}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x22, 0x14, 0x23, 0xb3, 0x31, 0x1d, 0x23, 0x42, - 0xa2, 0xa1, 0xf4, 0xac, 0x63, 0x14, 0x26, 0xe1}; - lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xc1, 0x5e, 0xc5, 0xd6, 0x18, 0xf0, 0x9b, 0x76, 0x28, 0x91, - 0xef, 0xae, 0xc9, 0x86, 0xec, 0xe8, 0x6c, 0xb1, 0xa3}; - lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -14425,75 +13753,57 @@ TEST(Subscribe311QCTest, Encode7) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28082, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 318, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8250 [("\237(\254^Q",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("=\197G\215j^\203%xY\252S\159\251\180\234\169\174\246\185\251",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\223H\213n$\254\160\161A\252\180\193Z\219\143",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("=\193w\237l:\149\177\EOT\a\200",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\217k\215\DC3\211\248\152\216\156\139\ETBo\175\246\239\183\DC3&\SYN1G\139\196n\164",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +// SubscribeRequest 31558 [("\186\232\r\SYN\DC4\129Eu\DC1]\160\174]",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("]\SO]\180\174O'\150\129\199\150\128\136B\133\198\140\191\138\FS\ETBvk\239\243",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\a0\ACKvKF\251\218J\SUB\ESC\215\200\147\192\231\206\193",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\196\254\198\168\156\215a\242s\210\168\234u\178\ESC\254\160U\214_4U\230&\184\226\GS\156",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0x5e, 0x20, 0x3a, 0x0, 0x5, 0xed, 0x28, 0xfe, 0x5e, 0x51, 0x1, 0x0, 0x15, 0x3d, 0xc5, - 0x47, 0xd7, 0x6a, 0x5e, 0xcb, 0x25, 0x78, 0x59, 0xfc, 0x53, 0x9f, 0xfb, 0xb4, 0xea, 0xa9, 0xae, - 0xf6, 0xb9, 0xfb, 0x2, 0x0, 0xf, 0xdf, 0x48, 0xd5, 0x6e, 0x24, 0xfe, 0xa0, 0xa1, 0x41, 0xfc, - 0xb4, 0xc1, 0x5a, 0xdb, 0x8f, 0x1, 0x0, 0xb, 0x3d, 0xc1, 0x77, 0xed, 0x6c, 0x3a, 0x95, 0xb1, - 0x4, 0x7, 0xc8, 0x0, 0x0, 0x19, 0xd9, 0x6b, 0xd7, 0x13, 0xd3, 0xf8, 0x98, 0xd8, 0x9c, 0x8b, - 0x17, 0x6f, 0xaf, 0xf6, 0xef, 0xb7, 0x13, 0x26, 0x16, 0x31, 0x47, 0x8b, 0xc4, 0x6e, 0xa4, 0x2}; + uint8_t pkt[] = {0x82, 0x62, 0x7b, 0x46, 0x0, 0xd, 0xba, 0xe8, 0xd, 0x16, 0x14, 0x81, 0x45, 0x75, 0x11, 0x5d, 0xa0, + 0xae, 0x5d, 0x0, 0x0, 0x19, 0x5d, 0xe, 0x5d, 0xb4, 0xae, 0x4f, 0x27, 0x96, 0x81, 0xc7, 0x96, 0x80, + 0x88, 0x42, 0x85, 0xc6, 0x8c, 0xbf, 0x8a, 0x1c, 0x17, 0x76, 0x6b, 0xef, 0xf3, 0x2, 0x0, 0x12, 0x7, + 0x30, 0x6, 0x76, 0x4b, 0x46, 0xfb, 0xda, 0x4a, 0x1a, 0x1b, 0xd7, 0xc8, 0x93, 0xc0, 0xe7, 0xce, 0xc1, + 0x2, 0x0, 0x1c, 0xc4, 0xfe, 0xc6, 0xa8, 0x9c, 0xd7, 0x61, 0xf2, 0x73, 0xd2, 0xa8, 0xea, 0x75, 0xb2, + 0x1b, 0xfe, 0xa0, 0x55, 0xd6, 0x5f, 0x34, 0x55, 0xe6, 0x26, 0xb8, 0xe2, 0x1d, 0x9c, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x28, 0xfe, 0x5e, 0x51}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xba, 0xe8, 0xd, 0x16, 0x14, 0x81, 0x45, 0x75, 0x11, 0x5d, 0xa0, 0xae, 0x5d}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3d, 0xc5, 0x47, 0xd7, 0x6a, 0x5e, 0xcb, 0x25, 0x78, 0x59, 0xfc, - 0x53, 0x9f, 0xfb, 0xb4, 0xea, 0xa9, 0xae, 0xf6, 0xb9, 0xfb}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5d, 0xe, 0x5d, 0xb4, 0xae, 0x4f, 0x27, 0x96, 0x81, 0xc7, 0x96, 0x80, 0x88, + 0x42, 0x85, 0xc6, 0x8c, 0xbf, 0x8a, 0x1c, 0x17, 0x76, 0x6b, 0xef, 0xf3}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdf, 0x48, 0xd5, 0x6e, 0x24, 0xfe, 0xa0, 0xa1, - 0x41, 0xfc, 0xb4, 0xc1, 0x5a, 0xdb, 0x8f}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7, 0x30, 0x6, 0x76, 0x4b, 0x46, 0xfb, 0xda, 0x4a, + 0x1a, 0x1b, 0xd7, 0xc8, 0x93, 0xc0, 0xe7, 0xce, 0xc1}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3d, 0xc1, 0x77, 0xed, 0x6c, 0x3a, 0x95, 0xb1, 0x4, 0x7, 0xc8}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc4, 0xfe, 0xc6, 0xa8, 0x9c, 0xd7, 0x61, 0xf2, 0x73, 0xd2, + 0xa8, 0xea, 0x75, 0xb2, 0x1b, 0xfe, 0xa0, 0x55, 0xd6, 0x5f, + 0x34, 0x55, 0xe6, 0x26, 0xb8, 0xe2, 0x1d, 0x9c}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd9, 0x6b, 0xd7, 0x13, 0xd3, 0xf8, 0x98, 0xd8, 0x9c, 0x8b, 0x17, 0x6f, 0xaf, - 0xf6, 0xef, 0xb7, 0x13, 0x26, 0x16, 0x31, 0x47, 0x8b, 0xc4, 0x6e, 0xa4}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -14501,7 +13811,7 @@ TEST(Subscribe311QCTest, Encode8) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -14509,103 +13819,84 @@ TEST(Subscribe311QCTest, Encode8) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8250, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 31558, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 2359 [("\EM\174:\184\155\&9\131\194\148",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0xe, 0x9, 0x37, 0x0, 0x9, 0x19, 0xae, 0x3a, 0xb8, 0x9b, 0x39, 0x83, 0xc2, 0x94, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x19, 0xae, 0x3a, 0xb8, 0x9b, 0x39, 0x83, 0xc2, 0x94}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2359, 1, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 16794 [("K\236r=\152\194\134Z}\181\&3:\143\143u\164\DC1\208\150\146\248\ETB",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\RS\SUB\bJ\131u",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("\195J\198\164\135",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\188\161\156\135\DEL\148\RS\249@\DC3\187",SubOptions {_retainHandling = +// SubscribeRequest 10059 [("cF\140\DC1z\250\a\232\178\255\221\154\NUL\134\244",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\216mP\206\&1\135\r\155\237\&0\DC4R\175$\254h\NAKN\f",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0x53, 0x41, 0x9a, 0x0, 0x16, 0x4b, 0xec, 0x72, 0x3d, 0x98, 0xc2, 0x86, 0x5a, 0x7d, 0xb5, 0x33, - 0x3a, 0x8f, 0x8f, 0x75, 0xa4, 0x11, 0xd0, 0x96, 0x92, 0xf8, 0x17, 0x1, 0x0, 0x6, 0x1e, 0x1a, 0x8, - 0x4a, 0x83, 0x75, 0x1, 0x0, 0x0, 0x0, 0x0, 0x5, 0xc3, 0x4a, 0xc6, 0xa4, 0x87, 0x0, 0x0, 0xb, - 0xbc, 0xa1, 0x9c, 0x87, 0x7f, 0x94, 0x1e, 0xf9, 0x40, 0x13, 0xbb, 0x0, 0x0, 0x13, 0xd8, 0x6d, 0x50, - 0xce, 0x31, 0x87, 0xd, 0x9b, 0xed, 0x30, 0x14, 0x52, 0xaf, 0x24, 0xfe, 0x68, 0x15, 0x4e, 0xc, 0x2}; +// QoS1}),("\172J\178\137\215\158\178n\196\166\\$a\"\143GH\CANW\134Se\bs\162z\153\v",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\146\169\&0\151\152\139\133\211\188\241\SUB\DC2N)\139\165\150",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\243\168\&6\166",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("G\245\200\151Cv\222\205\151\133\243",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\135oO\NUL\183j-",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Y;d\189L\226\200\163\134\156\180\242\218(\DC4\254\238\144 ",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode9) { + uint8_t pkt[] = {0x82, 0x7c, 0x27, 0x4b, 0x0, 0xf, 0x63, 0x46, 0x8c, 0x11, 0x7a, 0xfa, 0x7, 0xe8, 0xb2, 0xff, + 0xdd, 0x9a, 0x0, 0x86, 0xf4, 0x1, 0x0, 0x1c, 0xac, 0x4a, 0xb2, 0x89, 0xd7, 0x9e, 0xb2, 0x6e, + 0xc4, 0xa6, 0x5c, 0x24, 0x61, 0x22, 0x8f, 0x47, 0x48, 0x18, 0x57, 0x86, 0x53, 0x65, 0x8, 0x73, + 0xa2, 0x7a, 0x99, 0xb, 0x0, 0x0, 0x11, 0x92, 0xa9, 0x30, 0x97, 0x98, 0x8b, 0x85, 0xd3, 0xbc, + 0xf1, 0x1a, 0x12, 0x4e, 0x29, 0x8b, 0xa5, 0x96, 0x2, 0x0, 0x4, 0xf3, 0xa8, 0x36, 0xa6, 0x1, + 0x0, 0xb, 0x47, 0xf5, 0xc8, 0x97, 0x43, 0x76, 0xde, 0xcd, 0x97, 0x85, 0xf3, 0x1, 0x0, 0x7, + 0x87, 0x6f, 0x4f, 0x0, 0xb7, 0x6a, 0x2d, 0x2, 0x0, 0x13, 0x59, 0x3b, 0x64, 0xbd, 0x4c, 0xe2, + 0xc8, 0xa3, 0x86, 0x9c, 0xb4, 0xf2, 0xda, 0x28, 0x14, 0xfe, 0xee, 0x90, 0x20, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x4b, 0xec, 0x72, 0x3d, 0x98, 0xc2, 0x86, 0x5a, 0x7d, 0xb5, 0x33, - 0x3a, 0x8f, 0x8f, 0x75, 0xa4, 0x11, 0xd0, 0x96, 0x92, 0xf8, 0x17}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x63, 0x46, 0x8c, 0x11, 0x7a, 0xfa, 0x7, 0xe8, + 0xb2, 0xff, 0xdd, 0x9a, 0x0, 0x86, 0xf4}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1e, 0x1a, 0x8, 0x4a, 0x83, 0x75}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xac, 0x4a, 0xb2, 0x89, 0xd7, 0x9e, 0xb2, 0x6e, 0xc4, 0xa6, 0x5c, 0x24, 0x61, 0x22, + 0x8f, 0x47, 0x48, 0x18, 0x57, 0x86, 0x53, 0x65, 0x8, 0x73, 0xa2, 0x7a, 0x99, 0xb}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x92, 0xa9, 0x30, 0x97, 0x98, 0x8b, 0x85, 0xd3, 0xbc, + 0xf1, 0x1a, 0x12, 0x4e, 0x29, 0x8b, 0xa5, 0x96}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc3, 0x4a, 0xc6, 0xa4, 0x87}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf3, 0xa8, 0x36, 0xa6}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xbc, 0xa1, 0x9c, 0x87, 0x7f, 0x94, 0x1e, 0xf9, 0x40, 0x13, 0xbb}; + uint8_t topic_filter_s4_bytes[] = {0x47, 0xf5, 0xc8, 0x97, 0x43, 0x76, 0xde, 0xcd, 0x97, 0x85, 0xf3}; lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xd8, 0x6d, 0x50, 0xce, 0x31, 0x87, 0xd, 0x9b, 0xed, 0x30, - 0x14, 0x52, 0xaf, 0x24, 0xfe, 0x68, 0x15, 0x4e, 0xc}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x87, 0x6f, 0x4f, 0x0, 0xb7, 0x6a, 0x2d}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0x59, 0x3b, 0x64, 0xbd, 0x4c, 0xe2, 0xc8, 0xa3, 0x86, 0x9c, + 0xb4, 0xf2, 0xda, 0x28, 0x14, 0xfe, 0xee, 0x90, 0x20}; + lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; @@ -14613,112 +13904,105 @@ TEST(Subscribe311QCTest, Encode10) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16794, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10059, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9525 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("Y",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("yTU\212\STX\n0g\ETB\216;\193\141^of\176\131l\247\243\175\226W!\218\226\143&Y",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\129",SubOptions +// SubscribeRequest 17993 [("\174\DC2\180\NUL\142x\203\205\&8\EM\171\148\&3tuFu$\128",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\157\230\179\155\184",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\158\142\237\223\DEL\238TE#\174\&4\RS\247x\152d\195\167u\246\255\201\167\162=\206-",SubOptions +// QoS2}),("\176\146\RS\217\&9zmS\US\159\223ODO\200>\166\vR",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\161@\171\&2\220\208\169\DC1\214\171\191",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\169\195$\148J\198r\134D\151\160\STX%j\191\201\209\170\156t\r\244k\183\198",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\DC4&y\247\168\&1W\NUL\245\&6\237\210\150i",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("cQ_y\200\249",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\STX\217 \170>\EM",SubOptions +// QoS0}),("Q\129\191)\186o\207\155\&4C\134,A;\188i\194^\"]r",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("]CN4\DEL\254S\162\235\148\193\251\183",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\STX\135*",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("]\141\210\RS\186\238\n\ESC\GSj\131\174\190;\136\207Ofzf'",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0xa9, 0x1, 0x25, 0x35, 0x0, 0x0, 0x1, 0x0, 0x1, 0x59, 0x0, 0x0, 0x1e, 0x79, 0x54, - 0x55, 0xd4, 0x2, 0xa, 0x30, 0x67, 0x17, 0xd8, 0x3b, 0xc1, 0x8d, 0x5e, 0x6f, 0x66, 0xb0, 0x83, - 0x6c, 0xf7, 0xf3, 0xaf, 0xe2, 0x57, 0x21, 0xda, 0xe2, 0x8f, 0x26, 0x59, 0x0, 0x0, 0x1, 0x81, - 0x2, 0x0, 0x1b, 0x9e, 0x8e, 0xed, 0xdf, 0x7f, 0xee, 0x54, 0x45, 0x23, 0xae, 0x34, 0x1e, 0xf7, - 0x78, 0x98, 0x64, 0xc3, 0xa7, 0x75, 0xf6, 0xff, 0xc9, 0xa7, 0xa2, 0x3d, 0xce, 0x2d, 0x0, 0x0, - 0x19, 0xa9, 0xc3, 0x24, 0x94, 0x4a, 0xc6, 0x72, 0x86, 0x44, 0x97, 0xa0, 0x2, 0x25, 0x6a, 0xbf, - 0xc9, 0xd1, 0xaa, 0x9c, 0x74, 0xd, 0xf4, 0x6b, 0xb7, 0xc6, 0x1, 0x0, 0xe, 0x14, 0x26, 0x79, - 0xf7, 0xa8, 0x31, 0x57, 0x0, 0xf5, 0x36, 0xed, 0xd2, 0x96, 0x69, 0x2, 0x0, 0x6, 0x63, 0x51, - 0x5f, 0x79, 0xc8, 0xf9, 0x1, 0x0, 0x6, 0x2, 0xd9, 0x20, 0xaa, 0x3e, 0x19, 0x1, 0x0, 0x3, - 0x2, 0x87, 0x2a, 0x0, 0x0, 0x15, 0x5d, 0x8d, 0xd2, 0x1e, 0xba, 0xee, 0xa, 0x1b, 0x1d, 0x6a, - 0x83, 0xae, 0xbe, 0x3b, 0x88, 0xcf, 0x4f, 0x66, 0x7a, 0x66, 0x27, 0x0}; +// QoS2}),("\194c\DC4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS1}),("c\202\169\191\144\165\DC2%\SYN&\SOH\145\184\228\220\227\185]\163T\187D\253\DC2-\169C",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\195\212\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, +// _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode10) { + uint8_t pkt[] = {0x82, 0x96, 0x1, 0x46, 0x49, 0x0, 0x13, 0xae, 0x12, 0xb4, 0x0, 0x8e, 0x78, 0xcb, 0xcd, 0x38, 0x19, + 0xab, 0x94, 0x33, 0x74, 0x75, 0x46, 0x75, 0x24, 0x80, 0x0, 0x0, 0x5, 0x9d, 0xe6, 0xb3, 0x9b, 0xb8, + 0x2, 0x0, 0x13, 0xb0, 0x92, 0x1e, 0xd9, 0x39, 0x7a, 0x6d, 0x53, 0x1f, 0x9f, 0xdf, 0x4f, 0x44, 0x4f, + 0xc8, 0x3e, 0xa6, 0xb, 0x52, 0x1, 0x0, 0xb, 0xa1, 0x40, 0xab, 0x32, 0xdc, 0xd0, 0xa9, 0x11, 0xd6, + 0xab, 0xbf, 0x0, 0x0, 0x15, 0x51, 0x81, 0xbf, 0x29, 0xba, 0x6f, 0xcf, 0x9b, 0x34, 0x43, 0x86, 0x2c, + 0x41, 0x3b, 0xbc, 0x69, 0xc2, 0x5e, 0x22, 0x5d, 0x72, 0x2, 0x0, 0xd, 0x5d, 0x43, 0x4e, 0x34, 0x7f, + 0xfe, 0x53, 0xa2, 0xeb, 0x94, 0xc1, 0xfb, 0xb7, 0x2, 0x0, 0x3, 0xc2, 0x63, 0x14, 0x1, 0x0, 0x1b, + 0x63, 0xca, 0xa9, 0xbf, 0x90, 0xa5, 0x12, 0x25, 0x16, 0x26, 0x1, 0x91, 0xb8, 0xe4, 0xdc, 0xe3, 0xb9, + 0x5d, 0xa3, 0x54, 0xbb, 0x44, 0xfd, 0x12, 0x2d, 0xa9, 0x43, 0x1, 0x0, 0x3, 0xc3, 0xd4, 0x83, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xae, 0x12, 0xb4, 0x0, 0x8e, 0x78, 0xcb, 0xcd, 0x38, 0x19, + 0xab, 0x94, 0x33, 0x74, 0x75, 0x46, 0x75, 0x24, 0x80}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x59}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9d, 0xe6, 0xb3, 0x9b, 0xb8}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x79, 0x54, 0x55, 0xd4, 0x2, 0xa, 0x30, 0x67, 0x17, 0xd8, - 0x3b, 0xc1, 0x8d, 0x5e, 0x6f, 0x66, 0xb0, 0x83, 0x6c, 0xf7, - 0xf3, 0xaf, 0xe2, 0x57, 0x21, 0xda, 0xe2, 0x8f, 0x26, 0x59}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb0, 0x92, 0x1e, 0xd9, 0x39, 0x7a, 0x6d, 0x53, 0x1f, 0x9f, + 0xdf, 0x4f, 0x44, 0x4f, 0xc8, 0x3e, 0xa6, 0xb, 0x52}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x81}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa1, 0x40, 0xab, 0x32, 0xdc, 0xd0, 0xa9, 0x11, 0xd6, 0xab, 0xbf}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9e, 0x8e, 0xed, 0xdf, 0x7f, 0xee, 0x54, 0x45, 0x23, 0xae, 0x34, 0x1e, 0xf7, 0x78, - 0x98, 0x64, 0xc3, 0xa7, 0x75, 0xf6, 0xff, 0xc9, 0xa7, 0xa2, 0x3d, 0xce, 0x2d}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x51, 0x81, 0xbf, 0x29, 0xba, 0x6f, 0xcf, 0x9b, 0x34, 0x43, 0x86, + 0x2c, 0x41, 0x3b, 0xbc, 0x69, 0xc2, 0x5e, 0x22, 0x5d, 0x72}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa9, 0xc3, 0x24, 0x94, 0x4a, 0xc6, 0x72, 0x86, 0x44, 0x97, 0xa0, 0x2, 0x25, - 0x6a, 0xbf, 0xc9, 0xd1, 0xaa, 0x9c, 0x74, 0xd, 0xf4, 0x6b, 0xb7, 0xc6}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x5d, 0x43, 0x4e, 0x34, 0x7f, 0xfe, 0x53, 0xa2, 0xeb, 0x94, 0xc1, 0xfb, 0xb7}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x14, 0x26, 0x79, 0xf7, 0xa8, 0x31, 0x57, 0x0, 0xf5, 0x36, 0xed, 0xd2, 0x96, 0x69}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xc2, 0x63, 0x14}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x63, 0x51, 0x5f, 0x79, 0xc8, 0xf9}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x63, 0xca, 0xa9, 0xbf, 0x90, 0xa5, 0x12, 0x25, 0x16, 0x26, 0x1, 0x91, 0xb8, 0xe4, + 0xdc, 0xe3, 0xb9, 0x5d, 0xa3, 0x54, 0xbb, 0x44, 0xfd, 0x12, 0x2d, 0xa9, 0x43}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x2, 0xd9, 0x20, 0xaa, 0x3e, 0x19}; - lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xc3, 0xd4, 0x83}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x2, 0x87, 0x2a}; - lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x5d, 0x8d, 0xd2, 0x1e, 0xba, 0xee, 0xa, 0x1b, 0x1d, 0x6a, 0x83, - 0xae, 0xbe, 0x3b, 0x88, 0xcf, 0x4f, 0x66, 0x7a, 0x66, 0x27}; - lwmqtt_string_t topic_filter_s10 = {21, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; @@ -14726,104 +14010,67 @@ TEST(Subscribe311QCTest, Encode11) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9525, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17993, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25695 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\186\219\215",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\201bK\187'\a\ENQ\157\250\DLE",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("X\223\196\156",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\244hB>\204s -// 1\US\233\145\133\178:\129\154\238z\SYN\152-\244tq\DC1\146",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\EOT\188\214C\158\190\234\ETBt\229\GSR\139N\217\SO\240\245\ENQ\173G;\153@\183",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("W406\252\156\\\212\&3\b\203$\187\247\DC2\235\v\134\181\231",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\191\ESC+\"q",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("!\138\RS@\137\CANP!\SOH]\f\250\244\251h\232\242\241\241\218",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\STX\134\223\174XA\133.\245g\FS~\224\173\r\158\EOT\165\NAK",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 22386 [("\ESC\146\173A\219\151\151\&3\201\142\247A\240\134\172\207$\SO\214\141\&8J\US\n0",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("%\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS +// = QoS1}),("\136\CAN\SOH\212\NUL\t\207.",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\244\191\194\f?~)r^\197\&8\143^2\137\183\151\164<\SI",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("1\a\ETB\ENQ*\171-\181\195\200\175\177\204.'t\176\205\&1\130",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode12) { - uint8_t pkt[] = {0x82, 0xa4, 0x1, 0x64, 0x5f, 0x0, 0x0, 0x2, 0x0, 0x3, 0xba, 0xdb, 0xd7, 0x0, 0x0, 0xa, 0xc9, - 0x62, 0x4b, 0xbb, 0x27, 0x7, 0x5, 0x9d, 0xfa, 0x10, 0x2, 0x0, 0x4, 0x58, 0xdf, 0xc4, 0x9c, 0x2, - 0x0, 0x1a, 0xf4, 0x68, 0x42, 0x3e, 0xcc, 0x73, 0x20, 0x31, 0x1f, 0xe9, 0x91, 0x85, 0xb2, 0x3a, 0x81, - 0x9a, 0xee, 0x7a, 0x16, 0x98, 0x2d, 0xf4, 0x74, 0x71, 0x11, 0x92, 0x0, 0x0, 0x19, 0x4, 0xbc, 0xd6, - 0x43, 0x9e, 0xbe, 0xea, 0x17, 0x74, 0xe5, 0x1d, 0x52, 0x8b, 0x4e, 0xd9, 0xe, 0xf0, 0xf5, 0x5, 0xad, - 0x47, 0x3b, 0x99, 0x40, 0xb7, 0x1, 0x0, 0x14, 0x57, 0x34, 0x30, 0x36, 0xfc, 0x9c, 0x5c, 0xd4, 0x33, - 0x8, 0xcb, 0x24, 0xbb, 0xf7, 0x12, 0xeb, 0xb, 0x86, 0xb5, 0xe7, 0x1, 0x0, 0x5, 0xbf, 0x1b, 0x2b, - 0x22, 0x71, 0x0, 0x0, 0x14, 0x21, 0x8a, 0x1e, 0x40, 0x89, 0x18, 0x50, 0x21, 0x1, 0x5d, 0xc, 0xfa, - 0xf4, 0xfb, 0x68, 0xe8, 0xf2, 0xf1, 0xf1, 0xda, 0x2, 0x0, 0x13, 0x2, 0x86, 0xdf, 0xae, 0x58, 0x41, - 0x85, 0x2e, 0xf5, 0x67, 0x1c, 0x7e, 0xe0, 0xad, 0xd, 0x9e, 0x4, 0xa5, 0x15, 0x0}; +TEST(Subscribe311QCTest, Encode11) { + uint8_t pkt[] = {0x82, 0x5c, 0x57, 0x72, 0x0, 0x19, 0x1b, 0x92, 0xad, 0x41, 0xdb, 0x97, 0x97, 0x33, 0xc9, 0x8e, + 0xf7, 0x41, 0xf0, 0x86, 0xac, 0xcf, 0x24, 0xe, 0xd6, 0x8d, 0x38, 0x4a, 0x1f, 0xa, 0x30, 0x2, + 0x0, 0x2, 0x25, 0x98, 0x1, 0x0, 0x8, 0x88, 0x18, 0x1, 0xd4, 0x0, 0x9, 0xcf, 0x2e, 0x0, + 0x0, 0x14, 0xf4, 0xbf, 0xc2, 0xc, 0x3f, 0x7e, 0x29, 0x72, 0x5e, 0xc5, 0x38, 0x8f, 0x5e, 0x32, + 0x89, 0xb7, 0x97, 0xa4, 0x3c, 0xf, 0x2, 0x0, 0x14, 0x31, 0x7, 0x17, 0x5, 0x2a, 0xab, 0x2d, + 0xb5, 0xc3, 0xc8, 0xaf, 0xb1, 0xcc, 0x2e, 0x27, 0x74, 0xb0, 0xcd, 0x31, 0x82, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x1b, 0x92, 0xad, 0x41, 0xdb, 0x97, 0x97, 0x33, 0xc9, 0x8e, 0xf7, 0x41, 0xf0, + 0x86, 0xac, 0xcf, 0x24, 0xe, 0xd6, 0x8d, 0x38, 0x4a, 0x1f, 0xa, 0x30}; + lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xba, 0xdb, 0xd7}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x25, 0x98}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc9, 0x62, 0x4b, 0xbb, 0x27, 0x7, 0x5, 0x9d, 0xfa, 0x10}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x88, 0x18, 0x1, 0xd4, 0x0, 0x9, 0xcf, 0x2e}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x58, 0xdf, 0xc4, 0x9c}; - lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf4, 0xbf, 0xc2, 0xc, 0x3f, 0x7e, 0x29, 0x72, 0x5e, 0xc5, + 0x38, 0x8f, 0x5e, 0x32, 0x89, 0xb7, 0x97, 0xa4, 0x3c, 0xf}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xf4, 0x68, 0x42, 0x3e, 0xcc, 0x73, 0x20, 0x31, 0x1f, 0xe9, 0x91, 0x85, 0xb2, - 0x3a, 0x81, 0x9a, 0xee, 0x7a, 0x16, 0x98, 0x2d, 0xf4, 0x74, 0x71, 0x11, 0x92}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x7, 0x17, 0x5, 0x2a, 0xab, 0x2d, 0xb5, 0xc3, 0xc8, + 0xaf, 0xb1, 0xcc, 0x2e, 0x27, 0x74, 0xb0, 0xcd, 0x31, 0x82}; + lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4, 0xbc, 0xd6, 0x43, 0x9e, 0xbe, 0xea, 0x17, 0x74, 0xe5, 0x1d, 0x52, 0x8b, - 0x4e, 0xd9, 0xe, 0xf0, 0xf5, 0x5, 0xad, 0x47, 0x3b, 0x99, 0x40, 0xb7}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x57, 0x34, 0x30, 0x36, 0xfc, 0x9c, 0x5c, 0xd4, 0x33, 0x8, - 0xcb, 0x24, 0xbb, 0xf7, 0x12, 0xeb, 0xb, 0x86, 0xb5, 0xe7}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xbf, 0x1b, 0x2b, 0x22, 0x71}; - lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x21, 0x8a, 0x1e, 0x40, 0x89, 0x18, 0x50, 0x21, 0x1, 0x5d, - 0xc, 0xfa, 0xf4, 0xfb, 0x68, 0xe8, 0xf2, 0xf1, 0xf1, 0xda}; - lwmqtt_string_t topic_filter_s8 = {20, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x2, 0x86, 0xdf, 0xae, 0x58, 0x41, 0x85, 0x2e, 0xf5, 0x67, - 0x1c, 0x7e, 0xe0, 0xad, 0xd, 0x9e, 0x4, 0xa5, 0x15}; - lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; + lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -14835,80 +14082,66 @@ TEST(Subscribe311QCTest, Encode12) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25695, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22386, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 14957 -// [("'\STX-\199\148\232\\4\ETB\240D\\\DC2G\221\175\253\255\200\151\129\253\175\163\209a",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\133%J[\196Z\167\222\147\176\SYN\173\170@h\164",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 7096 [("t\181\243\135\224I\128\&4\216~\NAK",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\214\172\142\169\CANa\255\&7!H+OU`z\"\SUB\129\146[[",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\136`\150!\205",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("Ig\181\204}",SubOptions +// QoS0}),("oi\ETB\249\n\USG<]vF\175@D\"no\DC3\222T\STX\212",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\167-\197\214G\192r\204",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\153!\144t",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\GS\157",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode13) { - uint8_t pkt[] = {0x82, 0x5f, 0x3a, 0x6d, 0x0, 0x1a, 0x27, 0x2, 0x2d, 0xc7, 0x94, 0xe8, 0x5c, 0x34, 0x17, 0xf0, 0x44, - 0x5c, 0x12, 0x47, 0xdd, 0xaf, 0xfd, 0xff, 0xc8, 0x97, 0x81, 0xfd, 0xaf, 0xa3, 0xd1, 0x61, 0x0, 0x0, - 0x10, 0x85, 0x25, 0x4a, 0x5b, 0xc4, 0x5a, 0xa7, 0xde, 0x93, 0xb0, 0x16, 0xad, 0xaa, 0x40, 0x68, 0xa4, - 0x1, 0x0, 0x15, 0xd6, 0xac, 0x8e, 0xa9, 0x18, 0x61, 0xff, 0x37, 0x21, 0x48, 0x2b, 0x4f, 0x55, 0x60, - 0x7a, 0x22, 0x1a, 0x81, 0x92, 0x5b, 0x5b, 0x2, 0x0, 0x5, 0x88, 0x60, 0x96, 0x21, 0xcd, 0x1, 0x0, - 0x5, 0x49, 0x67, 0xb5, 0xcc, 0x7d, 0x0, 0x0, 0x2, 0x1d, 0x9d, 0x2}; +// QoS2}),("\ESC\148<\147\252\182o\137\rT\129\180db\204\246\SOG\227f\167",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\170\134\239w\241\233\GS",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("f2$\160\161\178\217\&0\EM\234&\146\SYN q\167\202\213\236\142\188\152\205\187t\n\237\166",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode12) { + uint8_t pkt[] = {0x82, 0x7c, 0x1b, 0xb8, 0x0, 0xb, 0x74, 0xb5, 0xf3, 0x87, 0xe0, 0x49, 0x80, 0x34, 0xd8, 0x7e, + 0x15, 0x0, 0x0, 0x16, 0x6f, 0x69, 0x17, 0xf9, 0xa, 0x1f, 0x47, 0x3c, 0x5d, 0x76, 0x46, 0xaf, + 0x40, 0x44, 0x22, 0x6e, 0x6f, 0x13, 0xde, 0x54, 0x2, 0xd4, 0x1, 0x0, 0x8, 0xa7, 0x2d, 0xc5, + 0xd6, 0x47, 0xc0, 0x72, 0xcc, 0x2, 0x0, 0x4, 0x99, 0x21, 0x90, 0x74, 0x2, 0x0, 0x15, 0x1b, + 0x94, 0x3c, 0x93, 0xfc, 0xb6, 0x6f, 0x89, 0xd, 0x54, 0x81, 0xb4, 0x64, 0x62, 0xcc, 0xf6, 0xe, + 0x47, 0xe3, 0x66, 0xa7, 0x2, 0x0, 0x7, 0xaa, 0x86, 0xef, 0x77, 0xf1, 0xe9, 0x1d, 0x0, 0x0, + 0x1c, 0x66, 0x32, 0x24, 0xa0, 0xa1, 0xb2, 0xd9, 0x30, 0x19, 0xea, 0x26, 0x92, 0x16, 0x20, 0x71, + 0xa7, 0xca, 0xd5, 0xec, 0x8e, 0xbc, 0x98, 0xcd, 0xbb, 0x74, 0xa, 0xed, 0xa6, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x27, 0x2, 0x2d, 0xc7, 0x94, 0xe8, 0x5c, 0x34, 0x17, 0xf0, 0x44, 0x5c, 0x12, - 0x47, 0xdd, 0xaf, 0xfd, 0xff, 0xc8, 0x97, 0x81, 0xfd, 0xaf, 0xa3, 0xd1, 0x61}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x74, 0xb5, 0xf3, 0x87, 0xe0, 0x49, 0x80, 0x34, 0xd8, 0x7e, 0x15}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x85, 0x25, 0x4a, 0x5b, 0xc4, 0x5a, 0xa7, 0xde, - 0x93, 0xb0, 0x16, 0xad, 0xaa, 0x40, 0x68, 0xa4}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6f, 0x69, 0x17, 0xf9, 0xa, 0x1f, 0x47, 0x3c, 0x5d, 0x76, 0x46, + 0xaf, 0x40, 0x44, 0x22, 0x6e, 0x6f, 0x13, 0xde, 0x54, 0x2, 0xd4}; + lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xd6, 0xac, 0x8e, 0xa9, 0x18, 0x61, 0xff, 0x37, 0x21, 0x48, 0x2b, - 0x4f, 0x55, 0x60, 0x7a, 0x22, 0x1a, 0x81, 0x92, 0x5b, 0x5b}; - lwmqtt_string_t topic_filter_s2 = {21, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa7, 0x2d, 0xc5, 0xd6, 0x47, 0xc0, 0x72, 0xcc}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x88, 0x60, 0x96, 0x21, 0xcd}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x99, 0x21, 0x90, 0x74}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x49, 0x67, 0xb5, 0xcc, 0x7d}; - lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x1b, 0x94, 0x3c, 0x93, 0xfc, 0xb6, 0x6f, 0x89, 0xd, 0x54, 0x81, + 0xb4, 0x64, 0x62, 0xcc, 0xf6, 0xe, 0x47, 0xe3, 0x66, 0xa7}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x1d, 0x9d}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xaa, 0x86, 0xef, 0x77, 0xf1, 0xe9, 0x1d}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0x66, 0x32, 0x24, 0xa0, 0xa1, 0xb2, 0xd9, 0x30, 0x19, 0xea, + 0x26, 0x92, 0x16, 0x20, 0x71, 0xa7, 0xca, 0xd5, 0xec, 0x8e, + 0xbc, 0x98, 0xcd, 0xbb, 0x74, 0xa, 0xed, 0xa6}; + lwmqtt_string_t topic_filter_s6 = {28, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -14921,98 +14154,64 @@ TEST(Subscribe311QCTest, Encode13) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS2; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14957, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 7096, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12087 [("\SOH\160\au5\136\&6\222",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS2}),("\202SR62\ENQ<\140\142k",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\141\ACK\147\209\&2\239\163\250\214V",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\227a\EOT0{ -// \198\DC2\248\240s_m`\210\198~\128e\240\202\SOH",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\197%;s04\250{\144\SIN\157\136\156\157\221\232\250",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions +// SubscribeRequest 12819 [("\r\ACKA\165\FS\187\vpF\231\155>\162q\nM\192\252\f{\178\b\a@v\131\215\152f",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("86f\234\181\141#g\FS]\237x\187\200B\224Q\158\&3\234\STX\a1\233\\\FS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("0\194w\220\142\208!>\246\138\133\163\SOH|\246I\FS$D\252`!\FS@",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\172\226p\DC4E\160\DC3\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\230A<\165\132",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode14) { - uint8_t pkt[] = {0x82, 0xa3, 0x1, 0x2f, 0x37, 0x0, 0x8, 0x1, 0xa0, 0x7, 0x75, 0x35, 0x88, 0x36, 0xde, 0x2, 0x0, - 0xa, 0xca, 0x53, 0x52, 0x36, 0x32, 0x5, 0x3c, 0x8c, 0x8e, 0x6b, 0x1, 0x0, 0xa, 0x8d, 0x6, 0x93, - 0xd1, 0x32, 0xef, 0xa3, 0xfa, 0xd6, 0x56, 0x2, 0x0, 0x16, 0xe3, 0x61, 0x4, 0x30, 0x7b, 0x20, 0xc6, - 0x12, 0xf8, 0xf0, 0x73, 0x5f, 0x6d, 0x60, 0xd2, 0xc6, 0x7e, 0x80, 0x65, 0xf0, 0xca, 0x1, 0x2, 0x0, - 0x12, 0xc5, 0x25, 0x3b, 0x73, 0x30, 0x34, 0xfa, 0x7b, 0x90, 0xf, 0x4e, 0x9d, 0x88, 0x9c, 0x9d, 0xdd, - 0xe8, 0xfa, 0x2, 0x0, 0x0, 0x1, 0x0, 0x1a, 0x38, 0x36, 0x66, 0xea, 0xb5, 0x8d, 0x23, 0x67, 0x1c, - 0x5d, 0xed, 0x78, 0xbb, 0xc8, 0x42, 0xe0, 0x51, 0x9e, 0x33, 0xea, 0x2, 0x7, 0x31, 0xe9, 0x5c, 0x1c, - 0x2, 0x0, 0x18, 0x30, 0xc2, 0x77, 0xdc, 0x8e, 0xd0, 0x21, 0x3e, 0xf6, 0x8a, 0x85, 0xa3, 0x1, 0x7c, - 0xf6, 0x49, 0x1c, 0x24, 0x44, 0xfc, 0x60, 0x21, 0x1c, 0x40, 0x0, 0x0, 0x8, 0xac, 0xe2, 0x70, 0x14, - 0x45, 0xa0, 0x13, 0xe1, 0x0, 0x0, 0x5, 0xe6, 0x41, 0x3c, 0xa5, 0x84, 0x1}; +// QoS2}),("Q\231s7H\ENQ#\143o\a\251\STXW\201\177\196{",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("$\142\140\198",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode13) { + uint8_t pkt[] = {0x82, 0x3d, 0x32, 0x13, 0x0, 0x1d, 0xd, 0x6, 0x41, 0xa5, 0x1c, 0xbb, 0xb, 0x70, 0x46, 0xe7, + 0x9b, 0x3e, 0xa2, 0x71, 0xa, 0x4d, 0xc0, 0xfc, 0xc, 0x7b, 0xb2, 0x8, 0x7, 0x40, 0x76, 0x83, + 0xd7, 0x98, 0x66, 0x2, 0x0, 0x11, 0x51, 0xe7, 0x73, 0x37, 0x48, 0x5, 0x23, 0x8f, 0x6f, 0x7, + 0xfb, 0x2, 0x57, 0xc9, 0xb1, 0xc4, 0x7b, 0x2, 0x0, 0x4, 0x24, 0x8e, 0x8c, 0xc6, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x1, 0xa0, 0x7, 0x75, 0x35, 0x88, 0x36, 0xde}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xd, 0x6, 0x41, 0xa5, 0x1c, 0xbb, 0xb, 0x70, 0x46, 0xe7, + 0x9b, 0x3e, 0xa2, 0x71, 0xa, 0x4d, 0xc0, 0xfc, 0xc, 0x7b, + 0xb2, 0x8, 0x7, 0x40, 0x76, 0x83, 0xd7, 0x98, 0x66}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xca, 0x53, 0x52, 0x36, 0x32, 0x5, 0x3c, 0x8c, 0x8e, 0x6b}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x51, 0xe7, 0x73, 0x37, 0x48, 0x5, 0x23, 0x8f, 0x6f, + 0x7, 0xfb, 0x2, 0x57, 0xc9, 0xb1, 0xc4, 0x7b}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8d, 0x6, 0x93, 0xd1, 0x32, 0xef, 0xa3, 0xfa, 0xd6, 0x56}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x24, 0x8e, 0x8c, 0xc6}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe3, 0x61, 0x4, 0x30, 0x7b, 0x20, 0xc6, 0x12, 0xf8, 0xf0, 0x73, - 0x5f, 0x6d, 0x60, 0xd2, 0xc6, 0x7e, 0x80, 0x65, 0xf0, 0xca, 0x1}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc5, 0x25, 0x3b, 0x73, 0x30, 0x34, 0xfa, 0x7b, 0x90, - 0xf, 0x4e, 0x9d, 0x88, 0x9c, 0x9d, 0xdd, 0xe8, 0xfa}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x38, 0x36, 0x66, 0xea, 0xb5, 0x8d, 0x23, 0x67, 0x1c, 0x5d, 0xed, 0x78, 0xbb, - 0xc8, 0x42, 0xe0, 0x51, 0x9e, 0x33, 0xea, 0x2, 0x7, 0x31, 0xe9, 0x5c, 0x1c}; - lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x30, 0xc2, 0x77, 0xdc, 0x8e, 0xd0, 0x21, 0x3e, 0xf6, 0x8a, 0x85, 0xa3, - 0x1, 0x7c, 0xf6, 0x49, 0x1c, 0x24, 0x44, 0xfc, 0x60, 0x21, 0x1c, 0x40}; - lwmqtt_string_t topic_filter_s7 = {24, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xac, 0xe2, 0x70, 0x14, 0x45, 0xa0, 0x13, 0xe1}; - lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe6, 0x41, 0x3c, 0xa5, 0x84}; - lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; + lwmqtt_sub_options_t sub_opts[3]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -15020,96 +14219,39 @@ TEST(Subscribe311QCTest, Encode14) { sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12087, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12819, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12264 [("\196k\DC4\147L\142U\156\ENQ\US\184Vi",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("v\GSMX\152\167\US\241\&0\144",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("ZW\174\198D$\r\232\220afgJM\NAKe\174\158\192\138\223\ESCs\172d\140M",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\EOT\184\184Pt\214-\228:\SI\193\207\136",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\202\223|X\252\nU\158b~\143\&8\GS#",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\162#D\147((1X ",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\130\219\DC4\157\150w",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("|\141\195",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode15) { - uint8_t pkt[] = {0x82, 0x79, 0x2f, 0xe8, 0x0, 0xd, 0xc4, 0x6b, 0x14, 0x93, 0x4c, 0x8e, 0x55, 0x9c, 0x5, 0x1f, - 0xb8, 0x56, 0x69, 0x0, 0x0, 0xa, 0x76, 0x1d, 0x4d, 0x58, 0x98, 0xa7, 0x1f, 0xf1, 0x30, 0x90, - 0x1, 0x0, 0x1b, 0x5a, 0x57, 0xae, 0xc6, 0x44, 0x24, 0xd, 0xe8, 0xdc, 0x61, 0x66, 0x67, 0x4a, - 0x4d, 0x15, 0x65, 0xae, 0x9e, 0xc0, 0x8a, 0xdf, 0x1b, 0x73, 0xac, 0x64, 0x8c, 0x4d, 0x1, 0x0, - 0xd, 0x4, 0xb8, 0xb8, 0x50, 0x74, 0xd6, 0x2d, 0xe4, 0x3a, 0xf, 0xc1, 0xcf, 0x88, 0x0, 0x0, - 0xe, 0xca, 0xdf, 0x7c, 0x58, 0xfc, 0xa, 0x55, 0x9e, 0x62, 0x7e, 0x8f, 0x38, 0x1d, 0x23, 0x1, - 0x0, 0x9, 0xa2, 0x23, 0x44, 0x93, 0x28, 0x28, 0x31, 0x58, 0x20, 0x1, 0x0, 0x6, 0x82, 0xdb, - 0x14, 0x9d, 0x96, 0x77, 0x2, 0x0, 0x3, 0x7c, 0x8d, 0xc3, 0x1}; +// SubscribeRequest 26406 [("`\aR\230\193\146\183",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\EOT,\142\SOH\170%",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("P\232L\184\219'\fn\160W\t22",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode14) { + uint8_t pkt[] = {0x82, 0x25, 0x67, 0x26, 0x0, 0x7, 0x60, 0x7, 0x52, 0xe6, 0xc1, 0x92, 0xb7, + 0x2, 0x0, 0x6, 0x4, 0x2c, 0x8e, 0x1, 0xaa, 0x25, 0x1, 0x0, 0xd, 0x50, + 0xe8, 0x4c, 0xb8, 0xdb, 0x27, 0xc, 0x6e, 0xa0, 0x57, 0x9, 0x32, 0x32, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xc4, 0x6b, 0x14, 0x93, 0x4c, 0x8e, 0x55, 0x9c, 0x5, 0x1f, 0xb8, 0x56, 0x69}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x60, 0x7, 0x52, 0xe6, 0xc1, 0x92, 0xb7}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x76, 0x1d, 0x4d, 0x58, 0x98, 0xa7, 0x1f, 0xf1, 0x30, 0x90}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4, 0x2c, 0x8e, 0x1, 0xaa, 0x25}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5a, 0x57, 0xae, 0xc6, 0x44, 0x24, 0xd, 0xe8, 0xdc, 0x61, 0x66, 0x67, 0x4a, 0x4d, - 0x15, 0x65, 0xae, 0x9e, 0xc0, 0x8a, 0xdf, 0x1b, 0x73, 0xac, 0x64, 0x8c, 0x4d}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x50, 0xe8, 0x4c, 0xb8, 0xdb, 0x27, 0xc, 0x6e, 0xa0, 0x57, 0x9, 0x32, 0x32}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x4, 0xb8, 0xb8, 0x50, 0x74, 0xd6, 0x2d, 0xe4, 0x3a, 0xf, 0xc1, 0xcf, 0x88}; - lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xca, 0xdf, 0x7c, 0x58, 0xfc, 0xa, 0x55, 0x9e, 0x62, 0x7e, 0x8f, 0x38, 0x1d, 0x23}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa2, 0x23, 0x44, 0x93, 0x28, 0x28, 0x31, 0x58, 0x20}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x82, 0xdb, 0x14, 0x9d, 0x96, 0x77}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7c, 0x8d, 0xc3}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -15117,90 +14259,50 @@ TEST(Subscribe311QCTest, Encode15) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12264, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26406, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23519 [("R\219\&9\207\231\198)2}\160",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\229\250\209",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("P\243-\232\133v`;l\157\243\238\130\251x\239\172\210\144\US2\251@h\138\228Mt\140",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\n\133g\194",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("y\239\128\199)K\206~\242\246\SO*Anb2&\190\169#b",SubOptions {_retainHandling = SendOnSubscribe, +// SubscribeRequest 13914 [("\198\167\141tI\138S\169\224\226\US\159\SIty",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\tz\SI\249\US2%R\176\a\163Kn\141\187\198\211x\246)]",SubOptions {_retainHandling = SendOnSubscribe, +// QoS2}),("1\181Xv\ACK\149\214\232z\136\EOT)\197\DLE\245\&5-\FSK~\SUBO\228\ENQ>1",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\163\252\EOT\234\173\180\EM\\O\240\GS)\232\252=\DC3\152",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode16) { - uint8_t pkt[] = {0x82, 0x6f, 0x5b, 0xdf, 0x0, 0xa, 0x52, 0xdb, 0x39, 0xcf, 0xe7, 0xc6, 0x29, 0x32, 0x7d, 0xa0, 0x0, - 0x0, 0x0, 0x1, 0x0, 0x3, 0xe5, 0xfa, 0xd1, 0x0, 0x0, 0x1d, 0x50, 0xf3, 0x2d, 0xe8, 0x85, 0x76, - 0x60, 0x3b, 0x6c, 0x9d, 0xf3, 0xee, 0x82, 0xfb, 0x78, 0xef, 0xac, 0xd2, 0x90, 0x1f, 0x32, 0xfb, 0x40, - 0x68, 0x8a, 0xe4, 0x4d, 0x74, 0x8c, 0x0, 0x0, 0x4, 0xa, 0x85, 0x67, 0xc2, 0x1, 0x0, 0x15, 0x79, - 0xef, 0x80, 0xc7, 0x29, 0x4b, 0xce, 0x7e, 0xf2, 0xf6, 0xe, 0x2a, 0x41, 0x6e, 0x62, 0x32, 0x26, 0xbe, - 0xa9, 0x23, 0x62, 0x0, 0x0, 0x15, 0x9, 0x7a, 0xf, 0xf9, 0x1f, 0x32, 0x25, 0x52, 0xb0, 0x7, 0xa3, - 0x4b, 0x6e, 0x8d, 0xbb, 0xc6, 0xd3, 0x78, 0xf6, 0x29, 0x5d, 0x2}; +TEST(Subscribe311QCTest, Encode15) { + uint8_t pkt[] = {0x82, 0x45, 0x36, 0x5a, 0x0, 0xf, 0xc6, 0xa7, 0x8d, 0x74, 0x49, 0x8a, 0x53, 0xa9, 0xe0, + 0xe2, 0x1f, 0x9f, 0xf, 0x74, 0x79, 0x2, 0x0, 0x1a, 0x31, 0xb5, 0x58, 0x76, 0x6, 0x95, + 0xd6, 0xe8, 0x7a, 0x88, 0x4, 0x29, 0xc5, 0x10, 0xf5, 0x35, 0x2d, 0x1c, 0x4b, 0x7e, 0x1a, + 0x4f, 0xe4, 0x5, 0x3e, 0x31, 0x1, 0x0, 0x11, 0xa3, 0xfc, 0x4, 0xea, 0xad, 0xb4, 0x19, + 0x5c, 0x4f, 0xf0, 0x1d, 0x29, 0xe8, 0xfc, 0x3d, 0x13, 0x98, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x52, 0xdb, 0x39, 0xcf, 0xe7, 0xc6, 0x29, 0x32, 0x7d, 0xa0}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xc6, 0xa7, 0x8d, 0x74, 0x49, 0x8a, 0x53, 0xa9, + 0xe0, 0xe2, 0x1f, 0x9f, 0xf, 0x74, 0x79}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x31, 0xb5, 0x58, 0x76, 0x6, 0x95, 0xd6, 0xe8, 0x7a, 0x88, 0x4, 0x29, 0xc5, + 0x10, 0xf5, 0x35, 0x2d, 0x1c, 0x4b, 0x7e, 0x1a, 0x4f, 0xe4, 0x5, 0x3e, 0x31}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe5, 0xfa, 0xd1}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa3, 0xfc, 0x4, 0xea, 0xad, 0xb4, 0x19, 0x5c, 0x4f, + 0xf0, 0x1d, 0x29, 0xe8, 0xfc, 0x3d, 0x13, 0x98}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x50, 0xf3, 0x2d, 0xe8, 0x85, 0x76, 0x60, 0x3b, 0x6c, 0x9d, - 0xf3, 0xee, 0x82, 0xfb, 0x78, 0xef, 0xac, 0xd2, 0x90, 0x1f, - 0x32, 0xfb, 0x40, 0x68, 0x8a, 0xe4, 0x4d, 0x74, 0x8c}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa, 0x85, 0x67, 0xc2}; - lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x79, 0xef, 0x80, 0xc7, 0x29, 0x4b, 0xce, 0x7e, 0xf2, 0xf6, 0xe, - 0x2a, 0x41, 0x6e, 0x62, 0x32, 0x26, 0xbe, 0xa9, 0x23, 0x62}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x9, 0x7a, 0xf, 0xf9, 0x1f, 0x32, 0x25, 0x52, 0xb0, 0x7, 0xa3, - 0x4b, 0x6e, 0x8d, 0xbb, 0xc6, 0xd3, 0x78, 0xf6, 0x29, 0x5d}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS0; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; @@ -15208,118 +14310,67 @@ TEST(Subscribe311QCTest, Encode16) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23519, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13914, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29383 [(",\NAK\169\178hV\136\f\td\219\232\130\128\161",SubOptions {_retainHandling = +// SubscribeRequest 2905 [("\158\194\134\209\SOH \176^\221\235\147\182\230\226\157\a\STX\215",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\STX\165?\213\"\ETX@\DC4\ENQ\178\ACKjo\156",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\171sk",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("x\r\128\171A\130\134\&6\DC1oU\179\212\t~\136\247\SO3",SubOptions {_retainHandling = SendOnSubscribe, +// QoS0}),("\171\167\154\213\250eT\\\165\US\US@\174",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\144O\186\216\f'gm{BI",SubOptions {_retainHandling = SendOnSubscribe, // _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),(")o=\233\v\SOH\204,\183\ESCkM^\133\224\&5\200H",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\210\198\219\203\239\165d<\213b\DC4UR\142\235\248\NULp\131\235\184\147\223kF\157\137\150\218\b",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("mm\223\&8\CAN\fO\no",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\192\143D`V'\SYNt\SI\233\133\&5\248\252\145\247C\130\192\218\SUBo",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\173\253\163N\216\207\129+_ \235e2\r5}\146",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\223\ETX\244nSoNK",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("/\239uT\EOT",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("f\241DK\SUB\ETB\DLEfe[\RS\CAN\222\ESCp\230Z\232v9e\246",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode17) { - uint8_t pkt[] = {0x82, 0xc8, 0x1, 0x72, 0xc7, 0x0, 0xf, 0x2c, 0x15, 0xa9, 0xb2, 0x68, 0x56, 0x88, 0xc, 0x9, 0x64, - 0xdb, 0xe8, 0x82, 0x80, 0xa1, 0x1, 0x0, 0x13, 0x78, 0xd, 0x80, 0xab, 0x41, 0x82, 0x86, 0x36, 0x11, - 0x6f, 0x55, 0xb3, 0xd4, 0x9, 0x7e, 0x88, 0xf7, 0xe, 0x33, 0x2, 0x0, 0x12, 0x29, 0x6f, 0x3d, 0xe9, - 0xb, 0x1, 0xcc, 0x2c, 0xb7, 0x1b, 0x6b, 0x4d, 0x5e, 0x85, 0xe0, 0x35, 0xc8, 0x48, 0x0, 0x0, 0x1e, - 0xd2, 0xc6, 0xdb, 0xcb, 0xef, 0xa5, 0x64, 0x3c, 0xd5, 0x62, 0x14, 0x55, 0x52, 0x8e, 0xeb, 0xf8, 0x0, - 0x70, 0x83, 0xeb, 0xb8, 0x93, 0xdf, 0x6b, 0x46, 0x9d, 0x89, 0x96, 0xda, 0x8, 0x1, 0x0, 0x9, 0x6d, - 0x6d, 0xdf, 0x38, 0x18, 0xc, 0x4f, 0xa, 0x6f, 0x0, 0x0, 0x0, 0x2, 0x0, 0x16, 0xc0, 0x8f, 0x44, - 0x60, 0x56, 0x27, 0x16, 0x74, 0xf, 0xe9, 0x85, 0x35, 0xf8, 0xfc, 0x91, 0xf7, 0x43, 0x82, 0xc0, 0xda, - 0x1a, 0x6f, 0x0, 0x0, 0x11, 0xad, 0xfd, 0xa3, 0x4e, 0xd8, 0xcf, 0x81, 0x2b, 0x5f, 0x20, 0xeb, 0x65, - 0x32, 0xd, 0x35, 0x7d, 0x92, 0x1, 0x0, 0x8, 0xdf, 0x3, 0xf4, 0x6e, 0x53, 0x6f, 0x4e, 0x4b, 0x1, - 0x0, 0x5, 0x2f, 0xef, 0x75, 0x54, 0x4, 0x1, 0x0, 0x16, 0x66, 0xf1, 0x44, 0x4b, 0x1a, 0x17, 0x10, - 0x66, 0x65, 0x5b, 0x1e, 0x18, 0xde, 0x1b, 0x70, 0xe6, 0x5a, 0xe8, 0x76, 0x39, 0x65, 0xf6, 0x1}; +// QoS0}),("\GS]\244\240/\177\178.\246\143\SI-\226j\165\SOH\233",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode16) { + uint8_t pkt[] = {0x82, 0x60, 0xb, 0x59, 0x0, 0x12, 0x9e, 0xc2, 0x86, 0xd1, 0x1, 0x20, 0xb0, 0x5e, 0xdd, 0xeb, 0x93, + 0xb6, 0xe6, 0xe2, 0x9d, 0x7, 0x2, 0xd7, 0x2, 0x0, 0xe, 0x2, 0xa5, 0x3f, 0xd5, 0x22, 0x3, 0x40, + 0x14, 0x5, 0xb2, 0x6, 0x6a, 0x6f, 0x9c, 0x1, 0x0, 0x3, 0xab, 0x73, 0x6b, 0x0, 0x0, 0xd, 0xab, + 0xa7, 0x9a, 0xd5, 0xfa, 0x65, 0x54, 0x5c, 0xa5, 0x1f, 0x1f, 0x40, 0xae, 0x1, 0x0, 0xb, 0x90, 0x4f, + 0xba, 0xd8, 0xc, 0x27, 0x67, 0x6d, 0x7b, 0x42, 0x49, 0x0, 0x0, 0x11, 0x1d, 0x5d, 0xf4, 0xf0, 0x2f, + 0xb1, 0xb2, 0x2e, 0xf6, 0x8f, 0xf, 0x2d, 0xe2, 0x6a, 0xa5, 0x1, 0xe9, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x2c, 0x15, 0xa9, 0xb2, 0x68, 0x56, 0x88, 0xc, - 0x9, 0x64, 0xdb, 0xe8, 0x82, 0x80, 0xa1}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x9e, 0xc2, 0x86, 0xd1, 0x1, 0x20, 0xb0, 0x5e, 0xdd, + 0xeb, 0x93, 0xb6, 0xe6, 0xe2, 0x9d, 0x7, 0x2, 0xd7}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x78, 0xd, 0x80, 0xab, 0x41, 0x82, 0x86, 0x36, 0x11, 0x6f, - 0x55, 0xb3, 0xd4, 0x9, 0x7e, 0x88, 0xf7, 0xe, 0x33}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2, 0xa5, 0x3f, 0xd5, 0x22, 0x3, 0x40, 0x14, 0x5, 0xb2, 0x6, 0x6a, 0x6f, 0x9c}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x29, 0x6f, 0x3d, 0xe9, 0xb, 0x1, 0xcc, 0x2c, 0xb7, - 0x1b, 0x6b, 0x4d, 0x5e, 0x85, 0xe0, 0x35, 0xc8, 0x48}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xab, 0x73, 0x6b}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd2, 0xc6, 0xdb, 0xcb, 0xef, 0xa5, 0x64, 0x3c, 0xd5, 0x62, - 0x14, 0x55, 0x52, 0x8e, 0xeb, 0xf8, 0x0, 0x70, 0x83, 0xeb, - 0xb8, 0x93, 0xdf, 0x6b, 0x46, 0x9d, 0x89, 0x96, 0xda, 0x8}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xab, 0xa7, 0x9a, 0xd5, 0xfa, 0x65, 0x54, 0x5c, 0xa5, 0x1f, 0x1f, 0x40, 0xae}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x6d, 0x6d, 0xdf, 0x38, 0x18, 0xc, 0x4f, 0xa, 0x6f}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x90, 0x4f, 0xba, 0xd8, 0xc, 0x27, 0x67, 0x6d, 0x7b, 0x42, 0x49}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x1d, 0x5d, 0xf4, 0xf0, 0x2f, 0xb1, 0xb2, 0x2e, 0xf6, + 0x8f, 0xf, 0x2d, 0xe2, 0x6a, 0xa5, 0x1, 0xe9}; + lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc0, 0x8f, 0x44, 0x60, 0x56, 0x27, 0x16, 0x74, 0xf, 0xe9, 0x85, - 0x35, 0xf8, 0xfc, 0x91, 0xf7, 0x43, 0x82, 0xc0, 0xda, 0x1a, 0x6f}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xad, 0xfd, 0xa3, 0x4e, 0xd8, 0xcf, 0x81, 0x2b, 0x5f, - 0x20, 0xeb, 0x65, 0x32, 0xd, 0x35, 0x7d, 0x92}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xdf, 0x3, 0xf4, 0x6e, 0x53, 0x6f, 0x4e, 0x4b}; - lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x2f, 0xef, 0x75, 0x54, 0x4}; - lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x66, 0xf1, 0x44, 0x4b, 0x1a, 0x17, 0x10, 0x66, 0x65, 0x5b, 0x1e, - 0x18, 0xde, 0x1b, 0x70, 0xe6, 0x5a, 0xe8, 0x76, 0x39, 0x65, 0xf6}; - lwmqtt_string_t topic_filter_s10 = {22, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -15339,92 +14390,67 @@ TEST(Subscribe311QCTest, Encode17) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS1; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29383, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2905, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22596 [("Z\234}C\SUB\171\&5&\204(&\179-\EOTJ4Z\158^\r/\210",SubOptions {_retainHandling = +// SubscribeRequest 10689 [("\199\210\220",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("7\161c\189=\151\t\191\238\214\221\130]\254\133\170S",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\207\&0\141\ETB\132\255\137\214\191x\233o\247\ACK\248\177",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("7\137\ETB\205\231s\136!\DC3B\DC1\151T\175\132\DLE[w\159r\162Tp\145\ENQ",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\155\DLE\244\181\FSv!R\140\a\235\ENQ\187D\133;",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\247\DC267\FS'\131\SI\183\GS(6\151",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("-F\209r\195e^\215\133\254\177R\253\173\165\FS\DLE?\DC3\203Qm\153\228 4\EM\156\228",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("*\206\rj\188y\249\188o\SI\163Sfn\ENQ:II3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1}),("\177B:\171\142\240\238\222",SubOptions {_retainHandling = +// QoS0}),("\177\136\US\209\US\188\SOg\EOTe\246CY^`\DEL3\143\ESC\EOTgMo\253\248\236\RSa*&",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode18) { - uint8_t pkt[] = {0x82, 0x7f, 0x58, 0x44, 0x0, 0x16, 0x5a, 0xea, 0x7d, 0x43, 0x1a, 0xab, 0x35, 0x26, 0xcc, 0x28, 0x26, - 0xb3, 0x2d, 0x4, 0x4a, 0x34, 0x5a, 0x9e, 0x5e, 0xd, 0x2f, 0xd2, 0x1, 0x0, 0x10, 0x9b, 0x10, 0xf4, - 0xb5, 0x1c, 0x76, 0x21, 0x52, 0x8c, 0x7, 0xeb, 0x5, 0xbb, 0x44, 0x85, 0x3b, 0x1, 0x0, 0xd, 0xf7, - 0x12, 0x36, 0x37, 0x1c, 0x27, 0x83, 0xf, 0xb7, 0x1d, 0x28, 0x36, 0x97, 0x0, 0x0, 0x1d, 0x2d, 0x46, - 0xd1, 0x72, 0xc3, 0x65, 0x5e, 0xd7, 0x85, 0xfe, 0xb1, 0x52, 0xfd, 0xad, 0xa5, 0x1c, 0x10, 0x3f, 0x13, - 0xcb, 0x51, 0x6d, 0x99, 0xe4, 0x20, 0x34, 0x19, 0x9c, 0xe4, 0x0, 0x0, 0x13, 0x2a, 0xce, 0xd, 0x6a, - 0xbc, 0x79, 0xf9, 0xbc, 0x6f, 0xf, 0xa3, 0x53, 0x66, 0x6e, 0x5, 0x3a, 0x49, 0x49, 0x33, 0x1, 0x0, - 0x8, 0xb1, 0x42, 0x3a, 0xab, 0x8e, 0xf0, 0xee, 0xde, 0x2}; +TEST(Subscribe311QCTest, Encode17) { + uint8_t pkt[] = {0x82, 0x6c, 0x29, 0xc1, 0x0, 0x3, 0xc7, 0xd2, 0xdc, 0x0, 0x0, 0x11, 0x37, 0xa1, 0x63, 0xbd, + 0x3d, 0x97, 0x9, 0xbf, 0xee, 0xd6, 0xdd, 0x82, 0x5d, 0xfe, 0x85, 0xaa, 0x53, 0x0, 0x0, 0x10, + 0xcf, 0x30, 0x8d, 0x17, 0x84, 0xff, 0x89, 0xd6, 0xbf, 0x78, 0xe9, 0x6f, 0xf7, 0x6, 0xf8, 0xb1, + 0x2, 0x0, 0x19, 0x37, 0x89, 0x17, 0xcd, 0xe7, 0x73, 0x88, 0x21, 0x13, 0x42, 0x11, 0x97, 0x54, + 0xaf, 0x84, 0x10, 0x5b, 0x77, 0x9f, 0x72, 0xa2, 0x54, 0x70, 0x91, 0x5, 0x0, 0x0, 0x1e, 0xb1, + 0x88, 0x1f, 0xd1, 0x1f, 0xbc, 0xe, 0x67, 0x4, 0x65, 0xf6, 0x43, 0x59, 0x5e, 0x60, 0x7f, 0x33, + 0x8f, 0x1b, 0x4, 0x67, 0x4d, 0x6f, 0xfd, 0xf8, 0xec, 0x1e, 0x61, 0x2a, 0x26, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x5a, 0xea, 0x7d, 0x43, 0x1a, 0xab, 0x35, 0x26, 0xcc, 0x28, 0x26, - 0xb3, 0x2d, 0x4, 0x4a, 0x34, 0x5a, 0x9e, 0x5e, 0xd, 0x2f, 0xd2}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xc7, 0xd2, 0xdc}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9b, 0x10, 0xf4, 0xb5, 0x1c, 0x76, 0x21, 0x52, - 0x8c, 0x7, 0xeb, 0x5, 0xbb, 0x44, 0x85, 0x3b}; - lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x37, 0xa1, 0x63, 0xbd, 0x3d, 0x97, 0x9, 0xbf, 0xee, + 0xd6, 0xdd, 0x82, 0x5d, 0xfe, 0x85, 0xaa, 0x53}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf7, 0x12, 0x36, 0x37, 0x1c, 0x27, 0x83, 0xf, 0xb7, 0x1d, 0x28, 0x36, 0x97}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xcf, 0x30, 0x8d, 0x17, 0x84, 0xff, 0x89, 0xd6, + 0xbf, 0x78, 0xe9, 0x6f, 0xf7, 0x6, 0xf8, 0xb1}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2d, 0x46, 0xd1, 0x72, 0xc3, 0x65, 0x5e, 0xd7, 0x85, 0xfe, - 0xb1, 0x52, 0xfd, 0xad, 0xa5, 0x1c, 0x10, 0x3f, 0x13, 0xcb, - 0x51, 0x6d, 0x99, 0xe4, 0x20, 0x34, 0x19, 0x9c, 0xe4}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x37, 0x89, 0x17, 0xcd, 0xe7, 0x73, 0x88, 0x21, 0x13, 0x42, 0x11, 0x97, 0x54, + 0xaf, 0x84, 0x10, 0x5b, 0x77, 0x9f, 0x72, 0xa2, 0x54, 0x70, 0x91, 0x5}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2a, 0xce, 0xd, 0x6a, 0xbc, 0x79, 0xf9, 0xbc, 0x6f, 0xf, - 0xa3, 0x53, 0x66, 0x6e, 0x5, 0x3a, 0x49, 0x49, 0x33}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xb1, 0x88, 0x1f, 0xd1, 0x1f, 0xbc, 0xe, 0x67, 0x4, 0x65, + 0xf6, 0x43, 0x59, 0x5e, 0x60, 0x7f, 0x33, 0x8f, 0x1b, 0x4, + 0x67, 0x4d, 0x6f, 0xfd, 0xf8, 0xec, 0x1e, 0x61, 0x2a, 0x26}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xb1, 0x42, 0x3a, 0xab, 0x8e, 0xf0, 0xee, 0xde}; - lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -15432,66 +14458,66 @@ TEST(Subscribe311QCTest, Encode18) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22596, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10689, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 11045 [("\234\249\222\145'",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0}),("\217Z\205\221w\220\&3\151\252\147\160\134\236\ru\149\189",SubOptions +// SubscribeRequest 8875 [("q|\160X\159\&9\235\ETB\206]\224\ETB\205\209\149\211>e\193#\168\246){_\173L\172",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("J\221\215\236\181\158\210\253l\a\191z\189\211\SOq\150",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("BFVB\232\190z@:\164\132\215)\182\230\141\225\GS",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode19) { - uint8_t pkt[] = {0x82, 0x47, 0x2b, 0x25, 0x0, 0x5, 0xea, 0xf9, 0xde, 0x91, 0x27, 0x0, 0x0, 0x11, 0xd9, - 0x5a, 0xcd, 0xdd, 0x77, 0xdc, 0x33, 0x97, 0xfc, 0x93, 0xa0, 0x86, 0xec, 0xd, 0x75, 0x95, - 0xbd, 0x0, 0x0, 0x11, 0x4a, 0xdd, 0xd7, 0xec, 0xb5, 0x9e, 0xd2, 0xfd, 0x6c, 0x7, 0xbf, - 0x7a, 0xbd, 0xd3, 0xe, 0x71, 0x96, 0x0, 0x0, 0x12, 0x42, 0x46, 0x56, 0x42, 0xe8, 0xbe, - 0x7a, 0x40, 0x3a, 0xa4, 0x84, 0xd7, 0x29, 0xb6, 0xe6, 0x8d, 0xe1, 0x1d, 0x0}; +// QoS0}),("\193\166\246\224\235\201\ACK\187k",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS1}),("\227\247a\181\EOT\235\DC3\222\&1",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("Y\213\224\139\128\253\225\233\238\165\197\166`\174]\204\150\188",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode18) { + uint8_t pkt[] = {0x82, 0x51, 0x22, 0xab, 0x0, 0x1c, 0x71, 0x7c, 0xa0, 0x58, 0x9f, 0x39, 0xeb, 0x17, 0xce, 0x5d, 0xe0, + 0x17, 0xcd, 0xd1, 0x95, 0xd3, 0x3e, 0x65, 0xc1, 0x23, 0xa8, 0xf6, 0x29, 0x7b, 0x5f, 0xad, 0x4c, 0xac, + 0x0, 0x0, 0x9, 0xc1, 0xa6, 0xf6, 0xe0, 0xeb, 0xc9, 0x6, 0xbb, 0x6b, 0x1, 0x0, 0x9, 0xe3, 0xf7, + 0x61, 0xb5, 0x4, 0xeb, 0x13, 0xde, 0x31, 0x2, 0x0, 0x0, 0x0, 0x0, 0x12, 0x59, 0xd5, 0xe0, 0x8b, + 0x80, 0xfd, 0xe1, 0xe9, 0xee, 0xa5, 0xc5, 0xa6, 0x60, 0xae, 0x5d, 0xcc, 0x96, 0xbc, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xea, 0xf9, 0xde, 0x91, 0x27}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x71, 0x7c, 0xa0, 0x58, 0x9f, 0x39, 0xeb, 0x17, 0xce, 0x5d, + 0xe0, 0x17, 0xcd, 0xd1, 0x95, 0xd3, 0x3e, 0x65, 0xc1, 0x23, + 0xa8, 0xf6, 0x29, 0x7b, 0x5f, 0xad, 0x4c, 0xac}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd9, 0x5a, 0xcd, 0xdd, 0x77, 0xdc, 0x33, 0x97, 0xfc, - 0x93, 0xa0, 0x86, 0xec, 0xd, 0x75, 0x95, 0xbd}; - lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xc1, 0xa6, 0xf6, 0xe0, 0xeb, 0xc9, 0x6, 0xbb, 0x6b}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x4a, 0xdd, 0xd7, 0xec, 0xb5, 0x9e, 0xd2, 0xfd, 0x6c, - 0x7, 0xbf, 0x7a, 0xbd, 0xd3, 0xe, 0x71, 0x96}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe3, 0xf7, 0x61, 0xb5, 0x4, 0xeb, 0x13, 0xde, 0x31}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x42, 0x46, 0x56, 0x42, 0xe8, 0xbe, 0x7a, 0x40, 0x3a, - 0xa4, 0x84, 0xd7, 0x29, 0xb6, 0xe6, 0x8d, 0xe1, 0x1d}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0}; + lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + uint8_t topic_filter_s4_bytes[] = {0x59, 0xd5, 0xe0, 0x8b, 0x80, 0xfd, 0xe1, 0xe9, 0xee, + 0xa5, 0xc5, 0xa6, 0x60, 0xae, 0x5d, 0xcc, 0x96, 0xbc}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -15499,170 +14525,89 @@ TEST(Subscribe311QCTest, Encode19) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 11045, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8875, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21249 [("7\141\154\230\129\244\236\138'\RS\208h&Y\170\r\229q",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("Q",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\150+:_xw\178Z\250\SYN\210\178L",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\250z\226\216\161\ETX\ACK\136\206\ESC\173\US\218\247\CAN\SI\213)z>z\188-E\195\128\181L\248'",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("W\185i\STX8n",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS0}),(",\244N\145.o\200\211.\221B{\185",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode20) { - uint8_t pkt[] = {0x82, 0xad, 0x1, 0x53, 0x1, 0x0, 0x12, 0x37, 0x8d, 0x9a, 0xe6, 0x81, 0xf4, 0xec, 0x8a, 0x27, - 0x1e, 0xd0, 0x68, 0x26, 0x59, 0xaa, 0xd, 0xe5, 0x71, 0x1, 0x0, 0x1, 0x51, 0x0, 0x0, 0x16, - 0x96, 0x2b, 0x3a, 0x5f, 0x78, 0x3c, 0x53, 0xa5, 0x6f, 0x22, 0x7d, 0x8a, 0x1d, 0xbd, 0xef, 0xf6, - 0x68, 0xdf, 0xcb, 0xf5, 0x8a, 0xbb, 0x1, 0x0, 0x1a, 0x5a, 0xdc, 0xb, 0x62, 0xaa, 0x2d, 0xf9, - 0xc3, 0xd1, 0xbf, 0x5b, 0xc3, 0x45, 0x95, 0xcd, 0x22, 0xcd, 0x7e, 0xf9, 0xd3, 0x3a, 0xd3, 0x65, - 0x5a, 0xf8, 0x52, 0x2, 0x0, 0x1c, 0xa7, 0xf8, 0xf6, 0x8b, 0x9d, 0x7b, 0x9f, 0x74, 0x62, 0xa3, - 0xcc, 0x5f, 0xd2, 0x38, 0xb1, 0xc, 0xb6, 0xea, 0x1e, 0x3e, 0x77, 0xb2, 0x5a, 0xfa, 0x16, 0xd2, - 0xb2, 0x4c, 0x2, 0x0, 0x1e, 0xfa, 0x7a, 0xe2, 0xd8, 0xa1, 0x3, 0x6, 0x88, 0xce, 0x1b, 0xad, - 0x1f, 0xda, 0xf7, 0x18, 0xf, 0xd5, 0x29, 0x7a, 0x3e, 0x7a, 0xbc, 0x2d, 0x45, 0xc3, 0x80, 0xb5, - 0x4c, 0xf8, 0x27, 0x1, 0x0, 0x6, 0x57, 0xb9, 0x69, 0x2, 0x38, 0x6e, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xd, 0x2c, 0xf4, 0x4e, 0x91, 0x2e, 0x6f, 0xc8, 0xd3, 0x2e, 0xdd, 0x42, 0x7b, 0xb9, 0x2}; +// SubscribeRequest 1380 [("K\EM)\237\196\160&(\251\135w+\192\&7,V[\154\210\195\198L",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\231",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode19) { + uint8_t pkt[] = {0x82, 0x1f, 0x5, 0x64, 0x0, 0x16, 0x4b, 0x19, 0x29, 0xed, 0xc4, 0xa0, 0x26, 0x28, 0xfb, 0x87, 0x77, + 0x2b, 0xc0, 0x37, 0x2c, 0x56, 0x5b, 0x9a, 0xd2, 0xc3, 0xc6, 0x4c, 0x1, 0x0, 0x1, 0xe7, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x37, 0x8d, 0x9a, 0xe6, 0x81, 0xf4, 0xec, 0x8a, 0x27, - 0x1e, 0xd0, 0x68, 0x26, 0x59, 0xaa, 0xd, 0xe5, 0x71}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x4b, 0x19, 0x29, 0xed, 0xc4, 0xa0, 0x26, 0x28, 0xfb, 0x87, 0x77, + 0x2b, 0xc0, 0x37, 0x2c, 0x56, 0x5b, 0x9a, 0xd2, 0xc3, 0xc6, 0x4c}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x51}; + uint8_t topic_filter_s1_bytes[] = {0xe7}; lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x96, 0x2b, 0x3a, 0x5f, 0x78, 0x3c, 0x53, 0xa5, 0x6f, 0x22, 0x7d, - 0x8a, 0x1d, 0xbd, 0xef, 0xf6, 0x68, 0xdf, 0xcb, 0xf5, 0x8a, 0xbb}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x5a, 0xdc, 0xb, 0x62, 0xaa, 0x2d, 0xf9, 0xc3, 0xd1, 0xbf, 0x5b, 0xc3, 0x45, - 0x95, 0xcd, 0x22, 0xcd, 0x7e, 0xf9, 0xd3, 0x3a, 0xd3, 0x65, 0x5a, 0xf8, 0x52}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa7, 0xf8, 0xf6, 0x8b, 0x9d, 0x7b, 0x9f, 0x74, 0x62, 0xa3, - 0xcc, 0x5f, 0xd2, 0x38, 0xb1, 0xc, 0xb6, 0xea, 0x1e, 0x3e, - 0x77, 0xb2, 0x5a, 0xfa, 0x16, 0xd2, 0xb2, 0x4c}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfa, 0x7a, 0xe2, 0xd8, 0xa1, 0x3, 0x6, 0x88, 0xce, 0x1b, - 0xad, 0x1f, 0xda, 0xf7, 0x18, 0xf, 0xd5, 0x29, 0x7a, 0x3e, - 0x7a, 0xbc, 0x2d, 0x45, 0xc3, 0x80, 0xb5, 0x4c, 0xf8, 0x27}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x57, 0xb9, 0x69, 0x2, 0x38, 0x6e}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0}; - lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x2c, 0xf4, 0x4e, 0x91, 0x2e, 0x6f, 0xc8, 0xd3, 0x2e, 0xdd, 0x42, 0x7b, 0xb9}; - lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; + lwmqtt_sub_options_t sub_opts[2]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21249, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1380, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32237 [("4kW\253\213\191\228\173\&8\EM\n",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("n\199=\255]\ETX\237\&4\249V\187\139\228\DELVS\208~\231\232\208\203\187JH\153D\214\183",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("I\199\145I:\210\ETX\150\215N\aE3l\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = -// QoS2}),("\NAK6\182D\195\163\&3y\228P\236\212\201\235T\a\151\SUB4\235\185\ETBs",SubOptions {_retainHandling = +// SubscribeRequest 30364 [("\220f\ENQ\249\ENQv \203Q\135y\NAKd_O\f\253\176",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\a",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\128j\150\163\160%mXs\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode21) { - uint8_t pkt[] = {0x82, 0x69, 0x7d, 0xed, 0x0, 0xb, 0x34, 0x6b, 0x57, 0xfd, 0xd5, 0xbf, 0xe4, 0xad, 0x38, 0x19, - 0xa, 0x1, 0x0, 0x1d, 0x6e, 0xc7, 0x3d, 0xff, 0x5d, 0x3, 0xed, 0x34, 0xf9, 0x56, 0xbb, 0x8b, - 0xe4, 0x7f, 0x56, 0x53, 0xd0, 0x7e, 0xe7, 0xe8, 0xd0, 0xcb, 0xbb, 0x4a, 0x48, 0x99, 0x44, 0xd6, - 0xb7, 0x1, 0x0, 0xf, 0x49, 0xc7, 0x91, 0x49, 0x3a, 0xd2, 0x3, 0x96, 0xd7, 0x4e, 0x7, 0x45, - 0x33, 0x6c, 0xb8, 0x2, 0x0, 0x17, 0x15, 0x36, 0xb6, 0x44, 0xc3, 0xa3, 0x33, 0x79, 0xe4, 0x50, - 0xec, 0xd4, 0xc9, 0xeb, 0x54, 0x7, 0x97, 0x1a, 0x34, 0xeb, 0xb9, 0x17, 0x73, 0x2, 0x0, 0xa, - 0x80, 0x6a, 0x96, 0xa3, 0xa0, 0x25, 0x6d, 0x58, 0x73, 0x98, 0x0}; +// QoS1}),("\139\175\147u,R[\ACK\148\199\154\&6\156\218\&3\167",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\165O\255\"\139\185\135\183C\ACKa\214\143X\173\175\225K\200\247\205\133\145",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode20) { + uint8_t pkt[] = {0x82, 0x48, 0x76, 0x9c, 0x0, 0x12, 0xdc, 0x66, 0x5, 0xf9, 0x5, 0x76, 0x20, 0xcb, 0x51, + 0x87, 0x79, 0x15, 0x64, 0x5f, 0x4f, 0xc, 0xfd, 0xb0, 0x1, 0x0, 0x1, 0x7, 0x1, 0x0, + 0x10, 0x8b, 0xaf, 0x93, 0x75, 0x2c, 0x52, 0x5b, 0x6, 0x94, 0xc7, 0x9a, 0x36, 0x9c, 0xda, + 0x33, 0xa7, 0x0, 0x0, 0x17, 0xa5, 0x4f, 0xff, 0x22, 0x8b, 0xb9, 0x87, 0xb7, 0x43, 0x6, + 0x61, 0xd6, 0x8f, 0x58, 0xad, 0xaf, 0xe1, 0x4b, 0xc8, 0xf7, 0xcd, 0x85, 0x91, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x34, 0x6b, 0x57, 0xfd, 0xd5, 0xbf, 0xe4, 0xad, 0x38, 0x19, 0xa}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xdc, 0x66, 0x5, 0xf9, 0x5, 0x76, 0x20, 0xcb, 0x51, + 0x87, 0x79, 0x15, 0x64, 0x5f, 0x4f, 0xc, 0xfd, 0xb0}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6e, 0xc7, 0x3d, 0xff, 0x5d, 0x3, 0xed, 0x34, 0xf9, 0x56, - 0xbb, 0x8b, 0xe4, 0x7f, 0x56, 0x53, 0xd0, 0x7e, 0xe7, 0xe8, - 0xd0, 0xcb, 0xbb, 0x4a, 0x48, 0x99, 0x44, 0xd6, 0xb7}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x7}; + lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x49, 0xc7, 0x91, 0x49, 0x3a, 0xd2, 0x3, 0x96, - 0xd7, 0x4e, 0x7, 0x45, 0x33, 0x6c, 0xb8}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8b, 0xaf, 0x93, 0x75, 0x2c, 0x52, 0x5b, 0x6, + 0x94, 0xc7, 0x9a, 0x36, 0x9c, 0xda, 0x33, 0xa7}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x15, 0x36, 0xb6, 0x44, 0xc3, 0xa3, 0x33, 0x79, 0xe4, 0x50, 0xec, 0xd4, - 0xc9, 0xeb, 0x54, 0x7, 0x97, 0x1a, 0x34, 0xeb, 0xb9, 0x17, 0x73}; + uint8_t topic_filter_s3_bytes[] = {0xa5, 0x4f, 0xff, 0x22, 0x8b, 0xb9, 0x87, 0xb7, 0x43, 0x6, 0x61, 0xd6, + 0x8f, 0x58, 0xad, 0xaf, 0xe1, 0x4b, 0xc8, 0xf7, 0xcd, 0x85, 0x91}; lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x80, 0x6a, 0x96, 0xa3, 0xa0, 0x25, 0x6d, 0x58, 0x73, 0x98}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; + lwmqtt_sub_options_t sub_opts[4]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; @@ -15671,161 +14616,143 @@ TEST(Subscribe311QCTest, Encode21) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS0; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32237, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30364, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 1376 [(";\183\191\187\221\202\191\DC3FT\197\175\DC4\217>'\224\SIEx\189\194,",SubOptions +// SubscribeRequest 13751 [("\156f\255\253ey\FSZ\232\SUB\185\t\US\178\&8\232f\133\ETB\162|4\206\CAN",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("IaJ\ACK{\144@\ACK)XK\128\\7\ETX\159\146\SYN\141",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("o\209\197\246\162b\NAK\141\232A8\174\ACK\205\242+\ETX\SOHp\129\232\SUB\205\209&",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\US",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode22) { - uint8_t pkt[] = {0x82, 0x52, 0x5, 0x60, 0x0, 0x17, 0x3b, 0xb7, 0xbf, 0xbb, 0xdd, 0xca, 0xbf, 0x13, 0x46, 0x54, 0xc5, - 0xaf, 0x14, 0xd9, 0x3e, 0x27, 0xe0, 0xf, 0x45, 0x78, 0xbd, 0xc2, 0x2c, 0x2, 0x0, 0x13, 0x49, 0x61, - 0x4a, 0x6, 0x7b, 0x90, 0x40, 0x6, 0x29, 0x58, 0x4b, 0x80, 0x5c, 0x37, 0x3, 0x9f, 0x92, 0x16, 0x8d, - 0x0, 0x0, 0x19, 0x6f, 0xd1, 0xc5, 0xf6, 0xa2, 0x62, 0x15, 0x8d, 0xe8, 0x41, 0x38, 0xae, 0x6, 0xcd, - 0xf2, 0x2b, 0x3, 0x1, 0x70, 0x81, 0xe8, 0x1a, 0xcd, 0xd1, 0x26, 0x2, 0x0, 0x1, 0x1f, 0x1}; +// QoS0}),("\177\205\213\234\248\167\223\230\217\206W\NUL",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode21) { + uint8_t pkt[] = {0x82, 0x2c, 0x35, 0xb7, 0x0, 0x18, 0x9c, 0x66, 0xff, 0xfd, 0x65, 0x79, 0x1c, 0x5a, 0xe8, 0x1a, + 0xb9, 0x9, 0x1f, 0xb2, 0x38, 0xe8, 0x66, 0x85, 0x17, 0xa2, 0x7c, 0x34, 0xce, 0x18, 0x0, 0x0, + 0xc, 0xb1, 0xcd, 0xd5, 0xea, 0xf8, 0xa7, 0xdf, 0xe6, 0xd9, 0xce, 0x57, 0x0, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x3b, 0xb7, 0xbf, 0xbb, 0xdd, 0xca, 0xbf, 0x13, 0x46, 0x54, 0xc5, 0xaf, - 0x14, 0xd9, 0x3e, 0x27, 0xe0, 0xf, 0x45, 0x78, 0xbd, 0xc2, 0x2c}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x9c, 0x66, 0xff, 0xfd, 0x65, 0x79, 0x1c, 0x5a, 0xe8, 0x1a, 0xb9, 0x9, + 0x1f, 0xb2, 0x38, 0xe8, 0x66, 0x85, 0x17, 0xa2, 0x7c, 0x34, 0xce, 0x18}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x49, 0x61, 0x4a, 0x6, 0x7b, 0x90, 0x40, 0x6, 0x29, 0x58, - 0x4b, 0x80, 0x5c, 0x37, 0x3, 0x9f, 0x92, 0x16, 0x8d}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb1, 0xcd, 0xd5, 0xea, 0xf8, 0xa7, 0xdf, 0xe6, 0xd9, 0xce, 0x57, 0x0}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6f, 0xd1, 0xc5, 0xf6, 0xa2, 0x62, 0x15, 0x8d, 0xe8, 0x41, 0x38, 0xae, 0x6, - 0xcd, 0xf2, 0x2b, 0x3, 0x1, 0x70, 0x81, 0xe8, 0x1a, 0xcd, 0xd1, 0x26}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1f}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS2; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1376, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13751, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 20213 [("\228\181kq\t",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\217\&9\137\SYN\SUB\221t\182\SImim\223\212]",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\128",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = +// SubscribeRequest 5555 [("IB\226\SO\ENQK\215\237\159\218\ETBzX+z\149#\145\153o\204v\161a",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("6\181{\r\135\131?\223\ETB\141\245\141",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\159\tW\206.OY\144\EOT\239\233\137u\SOH",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("&\186\209i\193\255\239e\229\211\225p\239\155\151Lr\130\&1v\174\220p\203\140",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\182\130\204\SOH\136\244\204\152",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS1}),("\163\SI&zW\202\147_\174~O\152\137\242\205\DC3\131\180w \252\148",SubOptions +// QoS2}),("\203w\ENQI\203\206\251\&5W\154cP\177\182\t\205\240m",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\205\DC4\SYN\172\130\192\ACK\245",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("H\DELG\141Np",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1}),("b\201E\195z\240\\k\177\&0\240\216\209\199=\139\251\222\254\173",SubOptions {_retainHandling = +// QoS2}),("6\179\251\NUL\150\222\176\147y\USL\208\STXG",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("c\130\178\t\141",SubOptions {_retainHandling = // SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("cw,\227\r\161\128\EM:\197/\f\DEL\143\174\169\241\238&",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("-\131\DC3-/\EOTY\146\153]\138\149\250e\132m\EOTrrX\226",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] -TEST(Subscribe311QCTest, Encode23) { - uint8_t pkt[] = {0x82, 0x95, 0x1, 0x4e, 0xf5, 0x0, 0x5, 0xe4, 0xb5, 0x6b, 0x71, 0x9, 0x0, 0x0, 0xf, 0xd9, 0x39, - 0x89, 0x16, 0x1a, 0xdd, 0x74, 0xb6, 0xf, 0x6d, 0x69, 0x6d, 0xdf, 0xd4, 0x5d, 0x1, 0x0, 0x1, 0x80, - 0x0, 0x0, 0x0, 0x2, 0x0, 0x8, 0xb6, 0x82, 0xcc, 0x1, 0x88, 0xf4, 0xcc, 0x98, 0x1, 0x0, 0x16, - 0xa3, 0xf, 0x26, 0x7a, 0x57, 0xca, 0x93, 0x5f, 0xae, 0x7e, 0x4f, 0x98, 0x89, 0xf2, 0xcd, 0x13, 0x83, - 0xb4, 0x77, 0x20, 0xfc, 0x94, 0x2, 0x0, 0x6, 0x48, 0x7f, 0x47, 0x8d, 0x4e, 0x70, 0x1, 0x0, 0x14, - 0x62, 0xc9, 0x45, 0xc3, 0x7a, 0xf0, 0x5c, 0x6b, 0xb1, 0x30, 0xf0, 0xd8, 0xd1, 0xc7, 0x3d, 0x8b, 0xfb, - 0xde, 0xfe, 0xad, 0x2, 0x0, 0x13, 0x63, 0x77, 0x2c, 0xe3, 0xd, 0xa1, 0x80, 0x19, 0x3a, 0xc5, 0x2f, - 0xc, 0x7f, 0x8f, 0xae, 0xa9, 0xf1, 0xee, 0x26, 0x1, 0x0, 0x15, 0x2d, 0x83, 0x13, 0x2d, 0x2f, 0x4, - 0x59, 0x92, 0x99, 0x5d, 0x8a, 0x95, 0xfa, 0x65, 0x84, 0x6d, 0x4, 0x72, 0x72, 0x58, 0xe2, 0x1}; +// QoS2}),("g=E)SZD\234\245\255\SUB:YA\212\146\GS\203\197\NUL\247\187\r-]\177*\245p\222",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("I\207",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode22) { + uint8_t pkt[] = { + 0x82, 0xbb, 0x1, 0x15, 0xb3, 0x0, 0x18, 0x49, 0x42, 0xe2, 0xe, 0x5, 0x4b, 0xd7, 0xed, 0x9f, 0xda, 0x17, 0x7a, + 0x58, 0x2b, 0x7a, 0x95, 0x23, 0x91, 0x99, 0x6f, 0xcc, 0x76, 0xa1, 0x61, 0x2, 0x0, 0xc, 0x36, 0xb5, 0x7b, 0xd, + 0x87, 0x83, 0x3f, 0xdf, 0x17, 0x8d, 0xf5, 0x8d, 0x2, 0x0, 0xe, 0x9f, 0x9, 0x57, 0xce, 0x2e, 0x4f, 0x59, 0x90, + 0x4, 0xef, 0xe9, 0x89, 0x75, 0x1, 0x2, 0x0, 0x19, 0x26, 0xba, 0xd1, 0x69, 0xc1, 0xff, 0xef, 0x65, 0xe5, 0xd3, + 0xe1, 0x70, 0xef, 0x9b, 0x97, 0x4c, 0x72, 0x82, 0x31, 0x76, 0xae, 0xdc, 0x70, 0xcb, 0x8c, 0x2, 0x0, 0x12, 0xcb, + 0x77, 0x5, 0x49, 0xcb, 0xce, 0xfb, 0x35, 0x57, 0x9a, 0x63, 0x50, 0xb1, 0xb6, 0x9, 0xcd, 0xf0, 0x6d, 0x1, 0x0, + 0x8, 0xcd, 0x14, 0x16, 0xac, 0x82, 0xc0, 0x6, 0xf5, 0x2, 0x0, 0xe, 0x36, 0xb3, 0xfb, 0x0, 0x96, 0xde, 0xb0, + 0x93, 0x79, 0x1f, 0x4c, 0xd0, 0x2, 0x47, 0x1, 0x0, 0x5, 0x63, 0x82, 0xb2, 0x9, 0x8d, 0x2, 0x0, 0x1e, 0x67, + 0x3d, 0x45, 0x29, 0x53, 0x5a, 0x44, 0xea, 0xf5, 0xff, 0x1a, 0x3a, 0x59, 0x41, 0xd4, 0x92, 0x1d, 0xcb, 0xc5, 0x0, + 0xf7, 0xbb, 0xd, 0x2d, 0x5d, 0xb1, 0x2a, 0xf5, 0x70, 0xde, 0x1, 0x0, 0x0, 0x1, 0x0, 0x2, 0x49, 0xcf, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xe4, 0xb5, 0x6b, 0x71, 0x9}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x49, 0x42, 0xe2, 0xe, 0x5, 0x4b, 0xd7, 0xed, 0x9f, 0xda, 0x17, 0x7a, + 0x58, 0x2b, 0x7a, 0x95, 0x23, 0x91, 0x99, 0x6f, 0xcc, 0x76, 0xa1, 0x61}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xd9, 0x39, 0x89, 0x16, 0x1a, 0xdd, 0x74, 0xb6, - 0xf, 0x6d, 0x69, 0x6d, 0xdf, 0xd4, 0x5d}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x36, 0xb5, 0x7b, 0xd, 0x87, 0x83, 0x3f, 0xdf, 0x17, 0x8d, 0xf5, 0x8d}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x80}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x9f, 0x9, 0x57, 0xce, 0x2e, 0x4f, 0x59, 0x90, 0x4, 0xef, 0xe9, 0x89, 0x75, 0x1}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x26, 0xba, 0xd1, 0x69, 0xc1, 0xff, 0xef, 0x65, 0xe5, 0xd3, 0xe1, 0x70, 0xef, + 0x9b, 0x97, 0x4c, 0x72, 0x82, 0x31, 0x76, 0xae, 0xdc, 0x70, 0xcb, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xb6, 0x82, 0xcc, 0x1, 0x88, 0xf4, 0xcc, 0x98}; - lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xcb, 0x77, 0x5, 0x49, 0xcb, 0xce, 0xfb, 0x35, 0x57, + 0x9a, 0x63, 0x50, 0xb1, 0xb6, 0x9, 0xcd, 0xf0, 0x6d}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa3, 0xf, 0x26, 0x7a, 0x57, 0xca, 0x93, 0x5f, 0xae, 0x7e, 0x4f, - 0x98, 0x89, 0xf2, 0xcd, 0x13, 0x83, 0xb4, 0x77, 0x20, 0xfc, 0x94}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xcd, 0x14, 0x16, 0xac, 0x82, 0xc0, 0x6, 0xf5}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x48, 0x7f, 0x47, 0x8d, 0x4e, 0x70}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x36, 0xb3, 0xfb, 0x0, 0x96, 0xde, 0xb0, 0x93, 0x79, 0x1f, 0x4c, 0xd0, 0x2, 0x47}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x62, 0xc9, 0x45, 0xc3, 0x7a, 0xf0, 0x5c, 0x6b, 0xb1, 0x30, - 0xf0, 0xd8, 0xd1, 0xc7, 0x3d, 0x8b, 0xfb, 0xde, 0xfe, 0xad}; - lwmqtt_string_t topic_filter_s7 = {20, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x63, 0x82, 0xb2, 0x9, 0x8d}; + lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x63, 0x77, 0x2c, 0xe3, 0xd, 0xa1, 0x80, 0x19, 0x3a, 0xc5, - 0x2f, 0xc, 0x7f, 0x8f, 0xae, 0xa9, 0xf1, 0xee, 0x26}; - lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x67, 0x3d, 0x45, 0x29, 0x53, 0x5a, 0x44, 0xea, 0xf5, 0xff, + 0x1a, 0x3a, 0x59, 0x41, 0xd4, 0x92, 0x1d, 0xcb, 0xc5, 0x0, + 0xf7, 0xbb, 0xd, 0x2d, 0x5d, 0xb1, 0x2a, 0xf5, 0x70, 0xde}; + lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x2d, 0x83, 0x13, 0x2d, 0x2f, 0x4, 0x59, 0x92, 0x99, 0x5d, 0x8a, - 0x95, 0xfa, 0x65, 0x84, 0x6d, 0x4, 0x72, 0x72, 0x58, 0xe2}; - lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0}; + lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s10_bytes[] = {0x49, 0xcf}; + lwmqtt_string_t topic_filter_s10 = {2, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -15857,135 +14784,146 @@ TEST(Subscribe311QCTest, Encode23) { sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20213, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5555, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 2875 [("\171\ESC\137\SO\239\178N8\149$\239",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\n\NUL\183\220@\191 -// \EOTb\199+\141\"\152\234\207\191=\166\f\nR;\249:",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode24) { - uint8_t pkt[] = {0x82, 0x2c, 0xb, 0x3b, 0x0, 0xb, 0xab, 0x1b, 0x89, 0xe, 0xef, 0xb2, 0x4e, 0x38, 0x95, 0x24, - 0xef, 0x1, 0x0, 0x19, 0xa, 0x0, 0xb7, 0xdc, 0x40, 0xbf, 0x20, 0x4, 0x62, 0xc7, 0x2b, 0x8d, - 0x22, 0x98, 0xea, 0xcf, 0xbf, 0x3d, 0xa6, 0xc, 0xa, 0x52, 0x3b, 0xf9, 0x3a, 0x0}; +// SubscribeRequest 10338 [("&N",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = +// False, _subQoS = QoS0}),("L\139",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2}),("\142\DLE ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("o\184\f/M\241\233\236\145",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("1.$\203\166%\139\EOT8\133\134\251j\247\168\&3Z\182pDS\195\&3!",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\239\EM%\FS\EM\DC3v\226cEn",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode23) { + uint8_t pkt[] = {0x82, 0x4a, 0x28, 0x62, 0x0, 0x2, 0x26, 0x4e, 0x0, 0x0, 0x2, 0x4c, 0x8b, 0x2, 0x0, 0x3, + 0x8e, 0x10, 0x20, 0x0, 0x0, 0x9, 0x6f, 0xb8, 0xc, 0x2f, 0x4d, 0xf1, 0xe9, 0xec, 0x91, 0x0, + 0x0, 0x18, 0x31, 0x2e, 0x24, 0xcb, 0xa6, 0x25, 0x8b, 0x4, 0x38, 0x85, 0x86, 0xfb, 0x6a, 0xf7, + 0xa8, 0x33, 0x5a, 0xb6, 0x70, 0x44, 0x53, 0xc3, 0x33, 0x21, 0x2, 0x0, 0x0, 0x0, 0x0, 0xb, + 0xef, 0x19, 0x25, 0x1c, 0x19, 0x13, 0x76, 0xe2, 0x63, 0x45, 0x6e, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xab, 0x1b, 0x89, 0xe, 0xef, 0xb2, 0x4e, 0x38, 0x95, 0x24, 0xef}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x26, 0x4e}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa, 0x0, 0xb7, 0xdc, 0x40, 0xbf, 0x20, 0x4, 0x62, 0xc7, 0x2b, 0x8d, 0x22, - 0x98, 0xea, 0xcf, 0xbf, 0x3d, 0xa6, 0xc, 0xa, 0x52, 0x3b, 0xf9, 0x3a}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4c, 0x8b}; + lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s2_bytes[] = {0x8e, 0x10, 0x20}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x6f, 0xb8, 0xc, 0x2f, 0x4d, 0xf1, 0xe9, 0xec, 0x91}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x31, 0x2e, 0x24, 0xcb, 0xa6, 0x25, 0x8b, 0x4, 0x38, 0x85, 0x86, 0xfb, + 0x6a, 0xf7, 0xa8, 0x33, 0x5a, 0xb6, 0x70, 0x44, 0x53, 0xc3, 0x33, 0x21}; + lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xef, 0x19, 0x25, 0x1c, 0x19, 0x13, 0x76, 0xe2, 0x63, 0x45, 0x6e}; + lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2875, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10338, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 13469 [("\144\198\151\135\DC4%l",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\249\GS\245H\207\198\162qF\184@",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\198\163V\201\199\CANp\234\161a\f",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\212R\209'",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\STX\192\151\241\157\237\211\129SA\NUL\189\a\138\161\204\137\RS",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("a\225rVu\DLE\US\SOH\242\166$5\217\135?,\DLE\229HF\180\"\207\151",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\232\224",SubOptions +// SubscribeRequest 14367 [("\STX\239Z\131\175\220\f\217_\189A\"\149\ETX\141\165-\244h\215\171\166)",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("oI\179\175\197\204\237\STX\216\167",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\146G*\165",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\v\ENQU\202r'\152\228+\231dA\182MS\255*\137\135\175(",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("+\221^T7\161\222\SOHq>U\192R\187\247\201\195\249\165\214\&9\138\&0b",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0xab, 0x1, 0x34, 0x9d, 0x0, 0x7, 0x90, 0xc6, 0x97, 0x87, 0x14, 0x25, 0x6c, 0x1, 0x0, - 0xb, 0xf9, 0x1d, 0xf5, 0x48, 0xcf, 0xc6, 0xa2, 0x71, 0x46, 0xb8, 0x40, 0x1, 0x0, 0xb, 0xc6, - 0xa3, 0x56, 0xc9, 0xc7, 0x18, 0x70, 0xea, 0xa1, 0x61, 0xc, 0x2, 0x0, 0x4, 0xd4, 0x52, 0xd1, - 0x27, 0x1, 0x0, 0x12, 0x2, 0xc0, 0x97, 0xf1, 0x9d, 0xed, 0xd3, 0x81, 0x53, 0x41, 0x0, 0xbd, - 0x7, 0x8a, 0xa1, 0xcc, 0x89, 0x1e, 0x1, 0x0, 0x18, 0x61, 0xe1, 0x72, 0x56, 0x75, 0x10, 0x1f, - 0x1, 0xf2, 0xa6, 0x24, 0x35, 0xd9, 0x87, 0x3f, 0x2c, 0x10, 0xe5, 0x48, 0x46, 0xb4, 0x22, 0xcf, - 0x97, 0x0, 0x0, 0x2, 0xe8, 0xe0, 0x1, 0x0, 0xa, 0x6f, 0x49, 0xb3, 0xaf, 0xc5, 0xcc, 0xed, - 0x2, 0xd8, 0xa7, 0x1, 0x0, 0x4, 0x92, 0x47, 0x2a, 0xa5, 0x2, 0x0, 0x15, 0xb, 0x5, 0x55, - 0xca, 0x72, 0x27, 0x98, 0xe4, 0x2b, 0xe7, 0x64, 0x41, 0xb6, 0x4d, 0x53, 0xff, 0x2a, 0x89, 0x87, - 0xaf, 0x28, 0x2, 0x0, 0x18, 0x2b, 0xdd, 0x5e, 0x54, 0x37, 0xa1, 0xde, 0x1, 0x71, 0x3e, 0x55, - 0xc0, 0x52, 0xbb, 0xf7, 0xc9, 0xc3, 0xf9, 0xa5, 0xd6, 0x39, 0x8a, 0x30, 0x62, 0x2}; +// QoS1}),("\156\b\136\ETX\ETX\r\237\164|",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("\205.YT\176\145C\172\203\204",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\246\226\\.\aA),\171\169\221\214\\\142bC",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\195\191\198\v\219\177\249",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode24) { + uint8_t pkt[] = {0x82, 0x52, 0x38, 0x1f, 0x0, 0x17, 0x2, 0xef, 0x5a, 0x83, 0xaf, 0xdc, 0xc, 0xd9, 0x5f, 0xbd, 0x41, + 0x22, 0x95, 0x3, 0x8d, 0xa5, 0x2d, 0xf4, 0x68, 0xd7, 0xab, 0xa6, 0x29, 0x1, 0x0, 0x9, 0x9c, 0x8, + 0x88, 0x3, 0x3, 0xd, 0xed, 0xa4, 0x7c, 0x0, 0x0, 0xa, 0xcd, 0x2e, 0x59, 0x54, 0xb0, 0x91, 0x43, + 0xac, 0xcb, 0xcc, 0x1, 0x0, 0x10, 0xf6, 0xe2, 0x5c, 0x2e, 0x7, 0x41, 0x29, 0x2c, 0xab, 0xa9, 0xdd, + 0xd6, 0x5c, 0x8e, 0x62, 0x43, 0x1, 0x0, 0x7, 0xc3, 0xbf, 0xc6, 0xb, 0xdb, 0xb1, 0xf9, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x90, 0xc6, 0x97, 0x87, 0x14, 0x25, 0x6c}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x2, 0xef, 0x5a, 0x83, 0xaf, 0xdc, 0xc, 0xd9, 0x5f, 0xbd, 0x41, 0x22, + 0x95, 0x3, 0x8d, 0xa5, 0x2d, 0xf4, 0x68, 0xd7, 0xab, 0xa6, 0x29}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf9, 0x1d, 0xf5, 0x48, 0xcf, 0xc6, 0xa2, 0x71, 0x46, 0xb8, 0x40}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9c, 0x8, 0x88, 0x3, 0x3, 0xd, 0xed, 0xa4, 0x7c}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc6, 0xa3, 0x56, 0xc9, 0xc7, 0x18, 0x70, 0xea, 0xa1, 0x61, 0xc}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xcd, 0x2e, 0x59, 0x54, 0xb0, 0x91, 0x43, 0xac, 0xcb, 0xcc}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd4, 0x52, 0xd1, 0x27}; - lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf6, 0xe2, 0x5c, 0x2e, 0x7, 0x41, 0x29, 0x2c, + 0xab, 0xa9, 0xdd, 0xd6, 0x5c, 0x8e, 0x62, 0x43}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2, 0xc0, 0x97, 0xf1, 0x9d, 0xed, 0xd3, 0x81, 0x53, - 0x41, 0x0, 0xbd, 0x7, 0x8a, 0xa1, 0xcc, 0x89, 0x1e}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc3, 0xbf, 0xc6, 0xb, 0xdb, 0xb1, 0xf9}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x61, 0xe1, 0x72, 0x56, 0x75, 0x10, 0x1f, 0x1, 0xf2, 0xa6, 0x24, 0x35, - 0xd9, 0x87, 0x3f, 0x2c, 0x10, 0xe5, 0x48, 0x46, 0xb4, 0x22, 0xcf, 0x97}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xe8, 0xe0}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6f, 0x49, 0xb3, 0xaf, 0xc5, 0xcc, 0xed, 0x2, 0xd8, 0xa7}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x92, 0x47, 0x2a, 0xa5}; - lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xb, 0x5, 0x55, 0xca, 0x72, 0x27, 0x98, 0xe4, 0x2b, 0xe7, 0x64, - 0x41, 0xb6, 0x4d, 0x53, 0xff, 0x2a, 0x89, 0x87, 0xaf, 0x28}; - lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x2b, 0xdd, 0x5e, 0x54, 0x37, 0xa1, 0xde, 0x1, 0x71, 0x3e, 0x55, 0xc0, - 0x52, 0xbb, 0xf7, 0xc9, 0xc3, 0xf9, 0xa5, 0xd6, 0x39, 0x8a, 0x30, 0x62}; - lwmqtt_string_t topic_filter_s10 = {24, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; + lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -15997,139 +14935,112 @@ TEST(Subscribe311QCTest, Encode25) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[10].retain_as_published = false; - sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13469, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14367, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9632 [("9\192\243\129\177\140\182\244C\213\169\203\&4z!Y\215\&3\200\FS|K\216)",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\150M\179",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2})] [] -TEST(Subscribe311QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x23, 0x25, 0xa0, 0x0, 0x18, 0x39, 0xc0, 0xf3, 0x81, 0xb1, 0x8c, 0xb6, - 0xf4, 0x43, 0xd5, 0xa9, 0xcb, 0x34, 0x7a, 0x21, 0x59, 0xd7, 0x33, 0xc8, 0x1c, - 0x7c, 0x4b, 0xd8, 0x29, 0x1, 0x0, 0x3, 0x96, 0x4d, 0xb3, 0x2}; +// SubscribeRequest 19237 [(">\187+\226\DLE\US\194\164\194\165\171\166\128",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +TEST(Subscribe311QCTest, Encode25) { + uint8_t pkt[] = {0x82, 0x12, 0x4b, 0x25, 0x0, 0xd, 0x3e, 0xbb, 0x2b, 0xe2, + 0x10, 0x1f, 0xc2, 0xa4, 0xc2, 0xa5, 0xab, 0xa6, 0x80, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x39, 0xc0, 0xf3, 0x81, 0xb1, 0x8c, 0xb6, 0xf4, 0x43, 0xd5, 0xa9, 0xcb, - 0x34, 0x7a, 0x21, 0x59, 0xd7, 0x33, 0xc8, 0x1c, 0x7c, 0x4b, 0xd8, 0x29}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x3e, 0xbb, 0x2b, 0xe2, 0x10, 0x1f, 0xc2, 0xa4, 0xc2, 0xa5, 0xab, 0xa6, 0x80}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x96, 0x4d, 0xb3}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 9632, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19237, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32536 [("\STXFdF1}k\173 c{\188a\199\bh$\SYN\179\&1\a6\DLE\DC1\181",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("{\238\131\204\f\255\221\189\217b\165\148-\170\248\223\222\134{\151p\247\153\164\n",SubOptions +// SubscribeRequest 799 [("\156\220HPZ\146\176",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS2}),("\204\t\251\&4\140^\198\158P\165\GS\253\182\234",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\137\236\169\249\206aNj\160O\152b\176\230M\205\GS\146\184\213",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("N=\251\238D\139\DC3\SYNL\154))\182\221\132\150\225",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\223!\135V\191\128\&4\190\223\171\&3\234][\195%\175\f||mp\"\214\252\170",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("r\158\170l\"uyP\tR\f\152\176\140\213\227\&6I\249\187A\177\&7\159\136",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\163\196",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] -TEST(Subscribe311QCTest, Encode27) { - uint8_t pkt[] = {0x82, 0xa3, 0x1, 0x7f, 0x18, 0x0, 0x19, 0x2, 0x46, 0x64, 0x46, 0x31, 0x7d, 0x6b, 0xad, 0x20, 0x63, - 0x7b, 0xbc, 0x61, 0xc7, 0x8, 0x68, 0x24, 0x16, 0xb3, 0x31, 0x7, 0x36, 0x10, 0x11, 0xb5, 0x1, 0x0, - 0x19, 0x7b, 0xee, 0x83, 0xcc, 0xc, 0xff, 0xdd, 0xbd, 0xd9, 0x62, 0xa5, 0x94, 0x2d, 0xaa, 0xf8, 0xdf, - 0xde, 0x86, 0x7b, 0x97, 0x70, 0xf7, 0x99, 0xa4, 0xa, 0x1, 0x0, 0x14, 0x89, 0xec, 0xa9, 0xf9, 0xce, - 0x61, 0x4e, 0x6a, 0xa0, 0x4f, 0x98, 0x62, 0xb0, 0xe6, 0x4d, 0xcd, 0x1d, 0x92, 0xb8, 0xd5, 0x2, 0x0, - 0x11, 0x4e, 0x3d, 0xfb, 0xee, 0x44, 0x8b, 0x13, 0x16, 0x4c, 0x9a, 0x29, 0x29, 0xb6, 0xdd, 0x84, 0x96, - 0xe1, 0x2, 0x0, 0x1a, 0xdf, 0x21, 0x87, 0x56, 0xbf, 0x80, 0x34, 0xbe, 0xdf, 0xab, 0x33, 0xea, 0x5d, - 0x5b, 0xc3, 0x25, 0xaf, 0xc, 0x7c, 0x7c, 0x6d, 0x70, 0x22, 0xd6, 0xfc, 0xaa, 0x2, 0x0, 0x19, 0x72, - 0x9e, 0xaa, 0x6c, 0x22, 0x75, 0x79, 0x50, 0x9, 0x52, 0xc, 0x98, 0xb0, 0x8c, 0xd5, 0xe3, 0x36, 0x49, - 0xf9, 0xbb, 0x41, 0xb1, 0x37, 0x9f, 0x88, 0x2, 0x0, 0x2, 0xa3, 0xc4, 0x0}; +// QoS2}),("\140\173\170.\149\153\144",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("s \171\156/-lV\184 +// \155g\165\198sf\180>\233\133\130\221\220\156\178\244\&9\241\225|",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),(":8\155.\207\150\DC1\180c\182",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\232^\US\247\EMU\223ra\135U+K",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("Py\226\FSi_\194\179\221\138\196\208\239\131r{\173n",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("d\254\197\229\182\216;<*\ETX\ENQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS2}),("\141P\243\129=\177V\214",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\164c",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [] +TEST(Subscribe311QCTest, Encode26) { + uint8_t pkt[] = {0x82, 0x98, 0x1, 0x3, 0x1f, 0x0, 0x7, 0x9c, 0xdc, 0x48, 0x50, 0x5a, 0x92, 0xb0, 0x2, 0x0, + 0xe, 0xcc, 0x9, 0xfb, 0x34, 0x8c, 0x5e, 0xc6, 0x9e, 0x50, 0xa5, 0x1d, 0xfd, 0xb6, 0xea, 0x2, + 0x0, 0x7, 0x8c, 0xad, 0xaa, 0x2e, 0x95, 0x99, 0x90, 0x2, 0x0, 0x1e, 0x73, 0x20, 0xab, 0x9c, + 0x2f, 0x2d, 0x6c, 0x56, 0xb8, 0x20, 0x9b, 0x67, 0xa5, 0xc6, 0x73, 0x66, 0xb4, 0x3e, 0xe9, 0x85, + 0x82, 0xdd, 0xdc, 0x9c, 0xb2, 0xf4, 0x39, 0xf1, 0xe1, 0x7c, 0x2, 0x0, 0xa, 0x3a, 0x38, 0x9b, + 0x2e, 0xcf, 0x96, 0x11, 0xb4, 0x63, 0xb6, 0x2, 0x0, 0xd, 0xe8, 0x5e, 0x1f, 0xf7, 0x19, 0x55, + 0xdf, 0x72, 0x61, 0x87, 0x55, 0x2b, 0x4b, 0x0, 0x0, 0x12, 0x50, 0x79, 0xe2, 0x1c, 0x69, 0x5f, + 0xc2, 0xb3, 0xdd, 0x8a, 0xc4, 0xd0, 0xef, 0x83, 0x72, 0x7b, 0xad, 0x6e, 0x1, 0x0, 0xb, 0x64, + 0xfe, 0xc5, 0xe5, 0xb6, 0xd8, 0x3b, 0x3c, 0x2a, 0x3, 0x5, 0x2, 0x0, 0x8, 0x8d, 0x50, 0xf3, + 0x81, 0x3d, 0xb1, 0x56, 0xd6, 0x1, 0x0, 0x2, 0xa4, 0x63, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x2, 0x46, 0x64, 0x46, 0x31, 0x7d, 0x6b, 0xad, 0x20, 0x63, 0x7b, 0xbc, 0x61, - 0xc7, 0x8, 0x68, 0x24, 0x16, 0xb3, 0x31, 0x7, 0x36, 0x10, 0x11, 0xb5}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x9c, 0xdc, 0x48, 0x50, 0x5a, 0x92, 0xb0}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7b, 0xee, 0x83, 0xcc, 0xc, 0xff, 0xdd, 0xbd, 0xd9, 0x62, 0xa5, 0x94, 0x2d, - 0xaa, 0xf8, 0xdf, 0xde, 0x86, 0x7b, 0x97, 0x70, 0xf7, 0x99, 0xa4, 0xa}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xcc, 0x9, 0xfb, 0x34, 0x8c, 0x5e, 0xc6, 0x9e, 0x50, 0xa5, 0x1d, 0xfd, 0xb6, 0xea}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x89, 0xec, 0xa9, 0xf9, 0xce, 0x61, 0x4e, 0x6a, 0xa0, 0x4f, - 0x98, 0x62, 0xb0, 0xe6, 0x4d, 0xcd, 0x1d, 0x92, 0xb8, 0xd5}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8c, 0xad, 0xaa, 0x2e, 0x95, 0x99, 0x90}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x4e, 0x3d, 0xfb, 0xee, 0x44, 0x8b, 0x13, 0x16, 0x4c, - 0x9a, 0x29, 0x29, 0xb6, 0xdd, 0x84, 0x96, 0xe1}; - lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x73, 0x20, 0xab, 0x9c, 0x2f, 0x2d, 0x6c, 0x56, 0xb8, 0x20, + 0x9b, 0x67, 0xa5, 0xc6, 0x73, 0x66, 0xb4, 0x3e, 0xe9, 0x85, + 0x82, 0xdd, 0xdc, 0x9c, 0xb2, 0xf4, 0x39, 0xf1, 0xe1, 0x7c}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xdf, 0x21, 0x87, 0x56, 0xbf, 0x80, 0x34, 0xbe, 0xdf, 0xab, 0x33, 0xea, 0x5d, - 0x5b, 0xc3, 0x25, 0xaf, 0xc, 0x7c, 0x7c, 0x6d, 0x70, 0x22, 0xd6, 0xfc, 0xaa}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x3a, 0x38, 0x9b, 0x2e, 0xcf, 0x96, 0x11, 0xb4, 0x63, 0xb6}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x72, 0x9e, 0xaa, 0x6c, 0x22, 0x75, 0x79, 0x50, 0x9, 0x52, 0xc, 0x98, 0xb0, - 0x8c, 0xd5, 0xe3, 0x36, 0x49, 0xf9, 0xbb, 0x41, 0xb1, 0x37, 0x9f, 0x88}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe8, 0x5e, 0x1f, 0xf7, 0x19, 0x55, 0xdf, 0x72, 0x61, 0x87, 0x55, 0x2b, 0x4b}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa3, 0xc4}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x50, 0x79, 0xe2, 0x1c, 0x69, 0x5f, 0xc2, 0xb3, 0xdd, + 0x8a, 0xc4, 0xd0, 0xef, 0x83, 0x72, 0x7b, 0xad, 0x6e}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s7_bytes[] = {0x64, 0xfe, 0xc5, 0xe5, 0xb6, 0xd8, 0x3b, 0x3c, 0x2a, 0x3, 0x5}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x8d, 0x50, 0xf3, 0x81, 0x3d, 0xb1, 0x56, 0xd6}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa4, 0x63}; + lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; @@ -16145,82 +15056,156 @@ TEST(Subscribe311QCTest, Encode27) { sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; - - lwmqtt_property_t propslist[] = {}; - - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32536, 7, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 8552 [("]4\248\137\131\225_b\212\169\ETB\r",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\189\197\252R\ESC\GSJu",SubOptions {_retainHandling + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 799, 10, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 2526 [("\211\175",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("a?\SUB\v\176$\210A\128\248oSU\134\STX\236J,w",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\EOTO\245G\249\200\n4\SI1\239\b\NAKto3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = QoS0}),("t[^\ESC",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +TEST(Subscribe311QCTest, Encode27) { + uint8_t pkt[] = {0x82, 0x37, 0x9, 0xde, 0x0, 0x2, 0xd3, 0xaf, 0x1, 0x0, 0x13, 0x61, 0x3f, 0x1a, 0xb, + 0xb0, 0x24, 0xd2, 0x41, 0x80, 0xf8, 0x6f, 0x53, 0x55, 0x86, 0x2, 0xec, 0x4a, 0x2c, 0x77, + 0x0, 0x0, 0x10, 0x4, 0x4f, 0xf5, 0x47, 0xf9, 0xc8, 0xa, 0x34, 0xf, 0x31, 0xef, 0x8, + 0x15, 0x74, 0x6f, 0x33, 0x0, 0x0, 0x4, 0x74, 0x5b, 0x5e, 0x1b, 0x1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xd3, 0xaf}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x61, 0x3f, 0x1a, 0xb, 0xb0, 0x24, 0xd2, 0x41, 0x80, 0xf8, + 0x6f, 0x53, 0x55, 0x86, 0x2, 0xec, 0x4a, 0x2c, 0x77}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4, 0x4f, 0xf5, 0x47, 0xf9, 0xc8, 0xa, 0x34, + 0xf, 0x31, 0xef, 0x8, 0x15, 0x74, 0x6f, 0x33}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x74, 0x5b, 0x5e, 0x1b}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = false; + + lwmqtt_property_t propslist[] = {}; + + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2526, 4, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 20875 [("\204\138\132\154\245\&9=\219v\220Se\229\161Wh\183\183\198zd\248",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\RS\162h\189\t>\133L\199l'\244\164\235\180\194\221\SUB\DEL\226\157",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\254?\146]\b\244ZJ\CAN\SO\132",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("m\186m/\\gx^\145\214|\209B\210\&4\174o\149`",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\SUBq\181A9\r\162p:\RS0\152-\191\GS\b\ESC\CAN{X\231\237:\158T\155>\209\246\247",SubOptions {_retainHandling // = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("8#\221F96b\232\216\162\191\129(\152\184\DEL",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("`\173\EM\193X\175l}[\182\b\194\146S0;0\ESCkSX#:",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\139E\182\226c{\194\248\214N?\196\221\221\195%<\SI9",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\134\147\229\f\251`A\191\GS",SubOptions +// QoS2}),("i\250\186\175\SI\FSa\220\183\EM\160f*o\137n\164\&0",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("6",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("{4[\185\DC1\b\217\STXA\US",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("h\248Ay\190)%\\6\168\199",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\182\ETB\208\179\128\200\169RV\232=S+D\223S",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\172\216\203\210O\225",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] +// QoS1}),("\253J\226,\219z\148\248 \194\152\ENQ\nD\209\164\199\201N\245\231\&7\216\244",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] TEST(Subscribe311QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0x95, 0x1, 0x21, 0x68, 0x0, 0xc, 0x5d, 0x34, 0xf8, 0x89, 0x83, 0xe1, 0x5f, 0x62, 0xd4, 0xa9, - 0x17, 0xd, 0x2, 0x0, 0x8, 0xbd, 0xc5, 0xfc, 0x52, 0x1b, 0x1d, 0x4a, 0x75, 0x2, 0x0, 0x10, 0x38, - 0x23, 0xdd, 0x46, 0x39, 0x36, 0x62, 0xe8, 0xd8, 0xa2, 0xbf, 0x81, 0x28, 0x98, 0xb8, 0x7f, 0x2, 0x0, - 0x17, 0x60, 0xad, 0x19, 0xc1, 0x58, 0xaf, 0x6c, 0x7d, 0x5b, 0xb6, 0x8, 0xc2, 0x92, 0x53, 0x30, 0x3b, - 0x30, 0x1b, 0x6b, 0x53, 0x58, 0x23, 0x3a, 0x1, 0x0, 0x13, 0x8b, 0x45, 0xb6, 0xe2, 0x63, 0x7b, 0xc2, - 0xf8, 0xd6, 0x4e, 0x3f, 0xc4, 0xdd, 0xdd, 0xc3, 0x25, 0x3c, 0xf, 0x39, 0x1, 0x0, 0x9, 0x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 0x1c, 0x61, 0xdc, + 0xb7, 0x19, 0xa0, 0x66, 0x2a, 0x6f, 0x89, 0x6e, 0xa4, 0x30, 0x1, 0x0, 0x1, 0x36, 0x0, 0x0, 0xa, 0x7b, 0x34, + 0x5b, 0xb9, 0x11, 0x8, 0xd9, 0x2, 0x41, 0x1f, 0x1, 0x0, 0x18, 0xfd, 0x4a, 0xe2, 0x2c, 0xdb, 0x7a, 0x94, 0xf8, + 0x20, 0xc2, 0x98, 0x5, 0xa, 0x44, 0xd1, 0xa4, 0xc7, 0xc9, 0x4e, 0xf5, 0xe7, 0x37, 0xd8, 0xf4, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x5d, 0x34, 0xf8, 0x89, 0x83, 0xe1, 0x5f, 0x62, 0xd4, 0xa9, 0x17, 0xd}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xcc, 0x8a, 0x84, 0x9a, 0xf5, 0x39, 0x3d, 0xdb, 0x76, 0xdc, 0x53, + 0x65, 0xe5, 0xa1, 0x57, 0x68, 0xb7, 0xb7, 0xc6, 0x7a, 0x64, 0xf8}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbd, 0xc5, 0xfc, 0x52, 0x1b, 0x1d, 0x4a, 0x75}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0xa2, 0x68, 0xbd, 0x9, 0x3e, 0x85, 0x4c, 0xc7, 0x6c, 0x27, + 0xf4, 0xa4, 0xeb, 0xb4, 0xc2, 0xdd, 0x1a, 0x7f, 0xe2, 0x9d}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x38, 0x23, 0xdd, 0x46, 0x39, 0x36, 0x62, 0xe8, - 0xd8, 0xa2, 0xbf, 0x81, 0x28, 0x98, 0xb8, 0x7f}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xfe, 0x3f, 0x92, 0x5d, 0x8, 0xf4, 0x5a, 0x4a, 0x18, 0xe, 0x84}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x60, 0xad, 0x19, 0xc1, 0x58, 0xaf, 0x6c, 0x7d, 0x5b, 0xb6, 0x8, 0xc2, - 0x92, 0x53, 0x30, 0x3b, 0x30, 0x1b, 0x6b, 0x53, 0x58, 0x23, 0x3a}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6d, 0xba, 0x6d, 0x2f, 0x5c, 0x67, 0x78, 0x5e, 0x91, 0xd6, + 0x7c, 0xd1, 0x42, 0xd2, 0x34, 0xae, 0x6f, 0x95, 0x60}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8b, 0x45, 0xb6, 0xe2, 0x63, 0x7b, 0xc2, 0xf8, 0xd6, 0x4e, - 0x3f, 0xc4, 0xdd, 0xdd, 0xc3, 0x25, 0x3c, 0xf, 0x39}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x1a, 0x71, 0xb5, 0x41, 0x39, 0xd, 0xa2, 0x70, 0x3a, 0x1e, + 0x30, 0x98, 0x2d, 0xbf, 0x1d, 0x8, 0x1b, 0x18, 0x7b, 0x58, + 0xe7, 0xed, 0x3a, 0x9e, 0x54, 0x9b, 0x3e, 0xd1, 0xf6, 0xf7}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x86, 0x93, 0xe5, 0xc, 0xfb, 0x60, 0x41, 0xbf, 0x1d}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x69, 0xfa, 0xba, 0xaf, 0xf, 0x1c, 0x61, 0xdc, 0xb7, + 0x19, 0xa0, 0x66, 0x2a, 0x6f, 0x89, 0x6e, 0xa4, 0x30}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x68, 0xf8, 0x41, 0x79, 0xbe, 0x29, 0x25, 0x5c, 0x36, 0xa8, 0xc7}; - lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x36}; + lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb6, 0x17, 0xd0, 0xb3, 0x80, 0xc8, 0xa9, 0x52, - 0x56, 0xe8, 0x3d, 0x53, 0x2b, 0x44, 0xdf, 0x53}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x7b, 0x34, 0x5b, 0xb9, 0x11, 0x8, 0xd9, 0x2, 0x41, 0x1f}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xac, 0xd8, 0xcb, 0xd2, 0x4f, 0xe1}; - lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xfd, 0x4a, 0xe2, 0x2c, 0xdb, 0x7a, 0x94, 0xf8, 0x20, 0xc2, 0x98, 0x5, + 0xa, 0x44, 0xd1, 0xa4, 0xc7, 0xc9, 0x4e, 0xf5, 0xe7, 0x37, 0xd8, 0xf4}; + lwmqtt_string_t topic_filter_s8 = {24, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS2; @@ -16231,7 +15216,7 @@ TEST(Subscribe311QCTest, Encode28) { sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; @@ -16239,11 +15224,11 @@ TEST(Subscribe311QCTest, Encode28) { sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].qos = LWMQTT_QOS2; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[4].retain_as_published = false; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; @@ -16255,7 +15240,7 @@ TEST(Subscribe311QCTest, Encode28) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; @@ -16265,94 +15250,102 @@ TEST(Subscribe311QCTest, Encode28) { lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8552, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20875, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21918 [("\253`\DLE\211u\248\DLE\EM\254\171\202\139\231",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\232K\189x\159_\CAN>\184'\159\128dT\156,Sx",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\143\f\GS\206\232\253e\EOTnk\201\SOH\129\176\DLE}\249\186\178*\248C\143\134\192\232\DC1T",SubOptions +// SubscribeRequest 22546 [("f\185p\ENQ\162\139-.\158v+^\157\SUB",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\164\243\&8\128l\255}\242i4",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\152\143d\215c\ACK\243*\227%\223e5a\210z}\170=7%c\157",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\213\\n\ETX\EM\163L\232\170",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),(".",SubOptions +// QoS1}),("5\223)'\144\189\195\212k{\GS\165\"\ESC/+%m\175\161\235\NAK\223\142\205\225$\224\ETB\f",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\130$g=T];\221D\158\145\220\214\154",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),(")?Gbx/Ti\252/-\ACK\149\&5\176\184\156\\\CAN\ENQ\GS\191",SubOptions +// QoS1}),("v\167\184F\198B\ENQ\ESC\ACK0\ETB{f6\228\ta\185\207\154\175\171\187~\175\142'",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("\204",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS1}),("\218\246\&2\EOT\168$\EOTK\222\\S[\243",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS1}),("\212\216\165t\tpPa\167\149\147\v\b\SO\163\236\SO\222*@h\158&\239",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\234kp\252kzk\SI\247\243\&2\172\GS\222\ESC]7\232\166\230S\174h\192%w\152",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("(\DEL\146\a\222 ",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\139~1f\212\151\NUL\158C_8P",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS2}),("mt\246\185$\ENQjC\163\161\DC1\CAN\195\SO-i\224\241\208m",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [] +// QoS0}),("\b_\249n\169r0*w\\_ym\195Mp\253\145\200\213\239]q\136\135",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\174'S\r\251\\\252\192\250\128\&4U\184\168\201s\DEL\STXe1\240",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2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e6, 0x53, 0xae, 0x68, + 0xc0, 0x25, 0x77, 0x98, 0x2, 0x0, 0x6, 0x28, 0x7f, 0x92, 0x7, 0xde, 0x20, 0x0, 0x0, 0x19, 0x8, + 0x5f, 0xf9, 0x6e, 0xa9, 0x72, 0x30, 0x2a, 0x77, 0x5c, 0x5f, 0x79, 0x6d, 0xc3, 0x4d, 0x70, 0xfd, 0x91, + 0xc8, 0xd5, 0xef, 0x5d, 0x71, 0x88, 0x87, 0x2, 0x0, 0x15, 0xae, 0x27, 0x53, 0xd, 0xfb, 0x5c, 0xfc, + 0xc0, 0xfa, 0x80, 0x34, 0x55, 0xb8, 0xa8, 0xc9, 0x73, 0x7f, 0x2, 0x65, 0x31, 0xf0, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xfd, 0x60, 0x10, 0xd3, 0x75, 0xf8, 0x10, 0x19, 0xfe, 0xab, 0xca, 0x8b, 0xe7}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x66, 0xb9, 0x70, 0x5, 0xa2, 0x8b, 0x2d, 0x2e, 0x9e, 0x76, 0x2b, 0x5e, 0x9d, 0x1a}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe8, 0x4b, 0xbd, 0x78, 0x9f, 0x5f, 0x18, 0x3e, 0xb8, - 0x27, 0x9f, 0x80, 0x64, 0x54, 0x9c, 0x2c, 0x53, 0x78}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa4, 0xf3, 0x38, 0x80, 0x6c, 0xff, 0x7d, 0xf2, 0x69, 0x34}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8f, 0xc, 0x1d, 0xce, 0xe8, 0xfd, 0x65, 0x4, 0x6e, 0x6b, - 0xc9, 0x1, 0x81, 0xb0, 0x10, 0x7d, 0xf9, 0xba, 0xb2, 0x2a, - 0xf8, 0x43, 0x8f, 0x86, 0xc0, 0xe8, 0x11, 0x54}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x35, 0xdf, 0x29, 0x27, 0x90, 0xbd, 0xc3, 0xd4, 0x6b, 0x7b, + 0x1d, 0xa5, 0x22, 0x1b, 0x2f, 0x2b, 0x25, 0x6d, 0xaf, 0xa1, + 0xeb, 0x15, 0xdf, 0x8e, 0xcd, 0xe1, 0x24, 0xe0, 0x17, 0xc}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x98, 0x8f, 0x64, 0xd7, 0x63, 0x6, 0xf3, 0x2a, 0xe3, 0x25, 0xdf, 0x65, - 0x35, 0x61, 0xd2, 0x7a, 0x7d, 0xaa, 0x3d, 0x37, 0x25, 0x63, 0x9d}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x76, 0xa7, 0xb8, 0x46, 0xc6, 0x42, 0x5, 0x1b, 0x6, 0x30, 0x17, 0x7b, 0x66, 0x36, + 0xe4, 0x9, 0x61, 0xb9, 0xcf, 0x9a, 0xaf, 0xab, 0xbb, 0x7e, 0xaf, 0x8e, 0x27}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd5, 0x5c, 0x6e, 0x3, 0x19, 0xa3, 0x4c, 0xe8, 0xaa}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xcc}; + lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x2e}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xda, 0xf6, 0x32, 0x4, 0xa8, 0x24, 0x4, 0x4b, 0xde, 0x5c, 0x53, 0x5b, 0xf3}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x82, 0x24, 0x67, 0x3d, 0x54, 0x5d, 0x3b, - 0xdd, 0x44, 0x9e, 0x91, 0xdc, 0xd6, 0x9a}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xd4, 0xd8, 0xa5, 0x74, 0x9, 0x70, 0x50, 0x61, 0xa7, 0x95, 0x93, 0xb, + 0x8, 0xe, 0xa3, 0xec, 0xe, 0xde, 0x2a, 0x40, 0x68, 0x9e, 0x26, 0xef}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x29, 0x3f, 0x47, 0x62, 0x78, 0x2f, 0x54, 0x69, 0xfc, 0x2f, 0x2d, - 0x6, 0x95, 0x35, 0xb0, 0xb8, 0x9c, 0x5c, 0x18, 0x5, 0x1d, 0xbf}; - lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xea, 0x6b, 0x70, 0xfc, 0x6b, 0x7a, 0x6b, 0xf, 0xf7, 0xf3, 0x32, 0xac, 0x1d, 0xde, + 0x1b, 0x5d, 0x37, 0xe8, 0xa6, 0xe6, 0x53, 0xae, 0x68, 0xc0, 0x25, 0x77, 0x98}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x8b, 0x7e, 0x31, 0x66, 0xd4, 0x97, 0x0, 0x9e, 0x43, 0x5f, 0x38, 0x50}; - lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x28, 0x7f, 0x92, 0x7, 0xde, 0x20}; + lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x6d, 0x74, 0xf6, 0xb9, 0x24, 0x5, 0x6a, 0x43, 0xa3, 0xa1, - 0x11, 0x18, 0xc3, 0xe, 0x2d, 0x69, 0xe0, 0xf1, 0xd0, 0x6d}; - lwmqtt_string_t topic_filter_s9 = {20, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0x8, 0x5f, 0xf9, 0x6e, 0xa9, 0x72, 0x30, 0x2a, 0x77, 0x5c, 0x5f, 0x79, 0x6d, + 0xc3, 0x4d, 0x70, 0xfd, 0x91, 0xc8, 0xd5, 0xef, 0x5d, 0x71, 0x88, 0x87}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s10_bytes[] = {0xae, 0x27, 0x53, 0xd, 0xfb, 0x5c, 0xfc, 0xc0, 0xfa, 0x80, 0x34, + 0x55, 0xb8, 0xa8, 0xc9, 0x73, 0x7f, 0x2, 0x65, 0x31, 0xf0}; + lwmqtt_string_t topic_filter_s10 = {21, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; @@ -16364,7 +15357,7 @@ TEST(Subscribe311QCTest, Encode29) { sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].qos = LWMQTT_QOS2; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; sub_opts[6].no_local = false; @@ -16372,2901 +15365,2573 @@ TEST(Subscribe311QCTest, Encode29) { sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].qos = LWMQTT_QOS2; sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[10].retain_as_published = false; + sub_opts[10].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21918, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22546, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32402 [("\222d\154J\229\133\152\210\152Q\129\228R\184<\202\149\147\206\245\169",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\195\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS1})] [] +// SubscribeRequest 790 [("uR,E\184\234\156:\161\&7Eb\249x\ACK\255KB\185\162Iu",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1})] [] TEST(Subscribe311QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x1f, 0x7e, 0x92, 0x0, 0x15, 0xde, 0x64, 0x9a, 0x4a, 0xe5, 0x85, 0x98, 0xd2, 0x98, 0x51, 0x81, - 0xe4, 0x52, 0xb8, 0x3c, 0xca, 0x95, 0x93, 0xce, 0xf5, 0xa9, 0x1, 0x0, 0x2, 0xc3, 0xba, 0x1}; + uint8_t pkt[] = {0x82, 0x1b, 0x3, 0x16, 0x0, 0x16, 0x75, 0x52, 0x2c, 0x45, 0xb8, 0xea, 0x9c, 0x3a, 0xa1, + 0x37, 0x45, 0x62, 0xf9, 0x78, 0x6, 0xff, 0x4b, 0x42, 0xb9, 0xa2, 0x49, 0x75, 0x1}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xde, 0x64, 0x9a, 0x4a, 0xe5, 0x85, 0x98, 0xd2, 0x98, 0x51, 0x81, - 0xe4, 0x52, 0xb8, 0x3c, 0xca, 0x95, 0x93, 0xce, 0xf5, 0xa9}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x75, 0x52, 0x2c, 0x45, 0xb8, 0xea, 0x9c, 0x3a, 0xa1, 0x37, 0x45, + 0x62, 0xf9, 0x78, 0x6, 0xff, 0x4b, 0x42, 0xb9, 0xa2, 0x49, 0x75}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc3, 0xba}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; + lwmqtt_sub_options_t sub_opts[1]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 32402, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 790, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15317 [("\211!\219\245}\191K\196\v\188\"\238\237R\242F\240\177\144\229",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\200c\DC2\DC4\SO",SubOptions +// SubscribeRequest 30435 +// [("`h\241\RSu\235\248\SO\189\SUBS\214\231#\132\DEL\217\130\160\215\151\182j\252\240A",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\t +// \217\148d\224~\204\DEL3L\231\147\139\217",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// True, _noLocal = False, _subQoS = QoS2}),("\167\ESC\138~\151\139\229\133\197\&9\163\238",SubOptions {_retainHandling +// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\n>\\\198\221l`h\165\131\238\145-\156\v\161\232\183\144=\232v\252\242\198{\140",SubOptions {_retainHandling +// = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("u\191\218\ESC\245\204nb",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = +// False, _noLocal = False, _subQoS = +// QoS0}),("\176\169\&4\190\&0\241\238\237\150\241\162\234\148\RS\133\243\DC1(9\SYNZ\226\184\199",SubOptions // {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\ni",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("v\212>\RS\195wS\195p",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal -// = False, _subQoS = QoS0}),("\DLE|\233_$",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// False, _noLocal = True, _subQoS = QoS2}),("\249\204\STX\180\161\213{b_\SOHVAT",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\191\217\230\191\SUB\239\135\250\206K\133\131\159)OE\ACK\DC2#\203\133=~",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("B\a\136\184\225Dtd\170\&1\162\128O\189e\160\233\186\135B\248",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropUserProperty "\183\208\ETXh" -// "\218\144)@\207\212",PropAuthenticationMethod "\239r6\SYN0\247\147\148\239\246\140S",PropTopicAliasMaximum -// 24388,PropResponseTopic "\190CB\238O\209U\252\241",PropWildcardSubscriptionAvailable 22,PropMessageExpiryInterval -// 1942,PropSubscriptionIdentifier 10,PropRequestProblemInformation 248,PropWillDelayInterval -// 10721,PropWillDelayInterval 18164,PropWildcardSubscriptionAvailable 164,PropReasonString "n\199@\RS\137\ACK(`\244"] +// QoS0}),("jW\202\231\176\GS\252\217\199\151\250\161\248",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("Q \v\EM\165d\183\254\EOTw\224",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("N\ESCa1\203j8\230\EOT\160q,\148\239p\225RT\NAK",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropPayloadFormatIndicator +// 146,PropResponseInformation "S\186\202^\ACK\175c\230\220\214\186\203\142G\143\217\155",PropAssignedClientIdentifier +// "\143\USS]\209YO\249Vn\US\218\n\214J\183p\188\ACK-\RS",PropAssignedClientIdentifier +// "qO\168\207(\231",PropAssignedClientIdentifier "\DLE\250pO#dg\US",PropAuthenticationData +// "\238\169\249\181T\180",PropSessionExpiryInterval 3239,PropCorrelationData +// "\EM`k\184\179\134\&3\130\247Y\194_<\t\188E\196Y\141\245\212\231~j7\188Hu\192",PropPayloadFormatIndicator +// 123,PropAuthenticationData +// "C!\243\217'\159$\169\GS\242\197z\150\187\159\139\141\&8|\252\201\156IM/",PropSessionExpiryInterval +// 26828,PropRetainAvailable 90,PropRequestResponseInformation 195,PropMaximumQoS 17,PropContentType +// "\192q\229|\b\CAN\235N\145",PropMaximumPacketSize 24089,PropPayloadFormatIndicator +// 200,PropSharedSubscriptionAvailable 68] TEST(Subscribe5QCTest, Encode1) { uint8_t pkt[] = { - 0x82, 0xcd, 0x1, 0x3b, 0xd5, 0x50, 0x26, 0x0, 0x4, 0xb7, 0xd0, 0x3, 0x68, 0x0, 0x6, 0xda, 0x90, 0x29, 0x40, - 0xcf, 0xd4, 0x15, 0x0, 0xc, 0xef, 0x72, 0x36, 0x16, 0x30, 0xf7, 0x93, 0x94, 0xef, 0xf6, 0x8c, 0x53, 0x22, 0x5f, - 0x44, 0x8, 0x0, 0x9, 0xbe, 0x43, 0x42, 0xee, 0x4f, 0xd1, 0x55, 0xfc, 0xf1, 0x28, 0x16, 0x2, 0x0, 0x0, 0x7, - 0x96, 0xb, 0xa, 0x17, 0xf8, 0x18, 0x0, 0x0, 0x29, 0xe1, 0x18, 0x0, 0x0, 0x46, 0xf4, 0x28, 0xa4, 0x1f, 0x0, - 0x9, 0x6e, 0xc7, 0x40, 0x1e, 0x89, 0x6, 0x28, 0x60, 0xf4, 0x0, 0x14, 0xd3, 0x21, 0xdb, 0xf5, 0x7d, 0xbf, 0x4b, - 0xc4, 0xb, 0xbc, 0x22, 0xee, 0xed, 0x52, 0xf2, 0x46, 0xf0, 0xb1, 0x90, 0xe5, 0x1, 0x0, 0x5, 0xc8, 0x63, 0x12, - 0x14, 0xe, 0x29, 0x0, 0x2, 0xa, 0x69, 0x4, 0x0, 0x9, 0x76, 0xd4, 0x3e, 0x1e, 0xc3, 0x77, 0x53, 0xc3, 0x70, - 0x10, 0x0, 0x5, 0x10, 0x7c, 0xe9, 0x5f, 0x24, 0x16, 0x0, 0xd, 0xf9, 0xcc, 0x2, 0xb4, 0xa1, 0xd5,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b8, 0xc7, 0x28, 0x0, 0xd, 0x6a, 0x57, 0xca, 0xe7, 0xb0, 0x1d, 0xfc, + 0xd9, 0xc7, 0x97, 0xfa, 0xa1, 0xf8, 0x2, 0x0, 0xb, 0x51, 0x20, 0xb, 0x19, 0xa5, 0x64, 0xb7, 0xfe, 0x4, 0x77, + 0xe0, 0xd, 0x0, 0x13, 0x4e, 0x1b, 0x61, 0x31, 0xcb, 0x6a, 0x38, 0xe6, 0x4, 0xa0, 0x71, 0x2c, 0x94, 0xef, 0x70, + 0xe1, 0x52, 0x54, 0x15, 0x14}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xd3, 0x21, 0xdb, 0xf5, 0x7d, 0xbf, 0x4b, 0xc4, 0xb, 0xbc, - 0x22, 0xee, 0xed, 0x52, 0xf2, 0x46, 0xf0, 0xb1, 0x90, 0xe5}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x60, 0x68, 0xf1, 0x1e, 0x75, 0xeb, 0xf8, 0xe, 0xbd, 0x1a, 0x53, 0xd6, 0xe7, + 0x23, 0x84, 0x7f, 0xd9, 0x82, 0xa0, 0xd7, 0x97, 0xb6, 0x6a, 0xfc, 0xf0, 0x41}; + lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc8, 0x63, 0x12, 0x14, 0xe}; - lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9, 0x20, 0xd9, 0x94, 0x64, 0xe0, 0x7e, 0xcc, + 0x7f, 0x33, 0x4c, 0xe7, 0x93, 0x8b, 0xd9}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa, 0x69}; - lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa7, 0x1b, 0x8a, 0x7e, 0x97, 0x8b, 0xe5, 0x85, 0xc5, 0x39, 0xa3, 0xee}; + lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x76, 0xd4, 0x3e, 0x1e, 0xc3, 0x77, 0x53, 0xc3, 0x70}; - lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa, 0x3e, 0x5c, 0xc6, 0xdd, 0x6c, 0x60, 0x68, 0xa5, 0x83, 0xee, 0x91, 0x2d, 0x9c, + 0xb, 0xa1, 0xe8, 0xb7, 0x90, 0x3d, 0xe8, 0x76, 0xfc, 0xf2, 0xc6, 0x7b, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x10, 0x7c, 0xe9, 0x5f, 0x24}; - lwmqtt_string_t topic_filter_s4 = {5, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x75, 0xbf, 0xda, 0x1b, 0xf5, 0xcc, 0x6e, 0x62}; + lwmqtt_string_t topic_filter_s4 = {8, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf9, 0xcc, 0x2, 0xb4, 0xa1, 0xd5, 0x7b, 0x62, 0x5f, 0x1, 0x56, 0x41, 0x54}; - lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xbf, 0xd9, 0xe6, 0xbf, 0x1a, 0xef, 0x87, 0xfa, 0xce, 0x4b, 0x85, 0x83, - 0x9f, 0x29, 0x4f, 0x45, 0x6, 0x12, 0x23, 0xcb, 0x85, 0x3d, 0x7e}; - lwmqtt_string_t topic_filter_s6 = {23, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xb0, 0xa9, 0x34, 0xbe, 0x30, 0xf1, 0xee, 0xed, 0x96, 0xf1, 0xa2, 0xea, + 0x94, 0x1e, 0x85, 0xf3, 0x11, 0x28, 0x39, 0x16, 0x5a, 0xe2, 0xb8, 0xc7}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x42, 0x7, 0x88, 0xb8, 0xe1, 0x44, 0x74, 0x64, 0xaa, 0x31, 0xa2, - 0x80, 0x4f, 0xbd, 0x65, 0xa0, 0xe9, 0xba, 0x87, 0x42, 0xf8}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x6a, 0x57, 0xca, 0xe7, 0xb0, 0x1d, 0xfc, 0xd9, 0xc7, 0x97, 0xfa, 0xa1, 0xf8}; + lwmqtt_string_t topic_filter_s7 = {13, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS1; + uint8_t topic_filter_s8_bytes[] = {0x51, 0x20, 0xb, 0x19, 0xa5, 0x64, 0xb7, 0xfe, 0x4, 0x77, 0xe0}; + lwmqtt_string_t topic_filter_s8 = {11, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x4e, 0x1b, 0x61, 0x31, 0xcb, 0x6a, 0x38, 0xe6, 0x4, 0xa0, + 0x71, 0x2c, 0x94, 0xef, 0x70, 0xe1, 0x52, 0x54, 0x15}; + lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = false; sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].qos = LWMQTT_QOS1; sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; + sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = true; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - uint8_t bytesprops1[] = {0xda, 0x90, 0x29, 0x40, 0xcf, 0xd4}; - uint8_t bytesprops0[] = {0xb7, 0xd0, 0x3, 0x68}; - uint8_t bytesprops2[] = {0xef, 0x72, 0x36, 0x16, 0x30, 0xf7, 0x93, 0x94, 0xef, 0xf6, 0x8c, 0x53}; - uint8_t bytesprops3[] = {0xbe, 0x43, 0x42, 0xee, 0x4f, 0xd1, 0x55, 0xfc, 0xf1}; - uint8_t bytesprops4[] = {0x6e, 0xc7, 0x40, 0x1e, 0x89, 0x6, 0x28, 0x60, 0xf4}; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS0; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = true; + uint8_t bytesprops0[] = {0x53, 0xba, 0xca, 0x5e, 0x6, 0xaf, 0x63, 0xe6, 0xdc, + 0xd6, 0xba, 0xcb, 0x8e, 0x47, 0x8f, 0xd9, 0x9b}; + uint8_t bytesprops1[] = {0x8f, 0x1f, 0x53, 0x5d, 0xd1, 0x59, 0x4f, 0xf9, 0x56, 0x6e, 0x1f, + 0xda, 0xa, 0xd6, 0x4a, 0xb7, 0x70, 0xbc, 0x6, 0x2d, 0x1e}; + uint8_t bytesprops2[] = {0x71, 0x4f, 0xa8, 0xcf, 0x28, 0xe7}; + uint8_t bytesprops3[] = {0x10, 0xfa, 0x70, 0x4f, 0x23, 0x64, 0x67, 0x1f}; + uint8_t bytesprops4[] = {0xee, 0xa9, 0xf9, 0xb5, 0x54, 0xb4}; + uint8_t bytesprops5[] = {0x19, 0x60, 0x6b, 0xb8, 0xb3, 0x86, 0x33, 0x82, 0xf7, 0x59, 0xc2, 0x5f, 0x3c, 0x9, 0xbc, + 0x45, 0xc4, 0x59, 0x8d, 0xf5, 0xd4, 0xe7, 0x7e, 0x6a, 0x37, 0xbc, 0x48, 0x75, 0xc0}; + uint8_t bytesprops6[] = {0x43, 0x21, 0xf3, 0xd9, 0x27, 0x9f, 0x24, 0xa9, 0x1d, 0xf2, 0xc5, 0x7a, 0x96, + 0xbb, 0x9f, 0x8b, 0x8d, 0x38, 0x7c, 0xfc, 0xc9, 0x9c, 0x49, 0x4d, 0x2f}; + uint8_t bytesprops7[] = {0xc0, 0x71, 0xe5, 0x7c, 0x8, 0x18, 0xeb, 0x4e, 0x91}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops0}, .v = {6, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24388}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1942}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 10}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10721}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18164}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 164}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3239}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 26828}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 90}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 195}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {9, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24089}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 200}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 68}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15317, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30435, 10, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 2981 [("p\197",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("^w\186",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS2}),("Q\CANiG\n\136\149\SOH\aL\225\243%\139\253W\156FD)\188r5\236s\179^\166",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\144\145\182\194\&1'\245",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS2})] [PropRequestProblemInformation 162,PropAuthenticationData -// "\141L<\210>",PropUserProperty "\217\204b\CAN\139 \167\225\179\&7\128" -// "/I\219\193\\2\237~\ESC\243\247,\238es\225`",PropUserProperty "\220C\150(Y\241\CAN" -// "\232\199\224@\ESC$\193\140\190&\173?r",PropPayloadFormatIndicator 83,PropTopicAlias 1481,PropAuthenticationMethod -// "D-b\187\&5\206",PropServerReference "\199\253\232",PropSubscriptionIdentifierAvailable 142,PropRetainAvailable -// 222,PropReceiveMaximum 20709,PropAssignedClientIdentifier -// "\EOT\202\&0\227TN\202\178E<\139\ESC\249$I\246n\EOTs\216*\210\ESC\155",PropSharedSubscriptionAvailable -// 49,PropSubscriptionIdentifier 6,PropSubscriptionIdentifierAvailable 103] +// SubscribeRequest 2083 +// [("\168\136\255:\130\SUB\133;\147<\234\247\227\169\216d\131:D\219\GS\190\200O2\203\149\212",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\219\203o\224\154\&9\229\144\a\219e\152\161\219hhF\236O\129\192h\ETXY\148\&9\150\204.\250",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] +// [PropMessageExpiryInterval 3245,PropReceiveMaximum 30130,PropSessionExpiryInterval 10678,PropReceiveMaximum +// 15989,PropTopicAliasMaximum 29133,PropMessageExpiryInterval 5541,PropMessageExpiryInterval 1992,PropUserProperty +// "\156\239w\206\DC2S\244V\220\205G\183t\244K\SYN\r\250z\225\168_\175\223\208o\CANM\148\FS" +// "\153\231\158t\GS'",PropAssignedClientIdentifier "0`\228_P\144\200\STX\DC19\160]",PropMaximumQoS 178,PropReasonString +// "h`rHh\137>\138wU\166\200\254\167\219\193\156\148\162\193\224B="] TEST(Subscribe5QCTest, Encode2) { - uint8_t pkt[] = { - 0x82, 0xb8, 0x1, 0xb, 0xa5, 0x80, 0x1, 0x17, 0xa2, 0x16, 0x0, 0x5, 0x8d, 0x4c, 0x3c, 0xd2, 0x3e, 0x26, 0x0, - 0xb, 0xd9, 0xcc, 0x62, 0x18, 0x8b, 0x20, 0xa7, 0xe1, 0xb3, 0x37, 0x80, 0x0, 0x11, 0x2f, 0x49, 0xdb, 0xc1, 0x5c, - 0x32, 0xed, 0x7e, 0x1b, 0xf3, 0xf7, 0x2c, 0xee, 0x65, 0x73, 0xe1, 0x60, 0x26, 0x0, 0x7, 0xdc, 0x43, 0x96, 0x28, - 0x59, 0xf1, 0x18, 0x0, 0xd, 0xe8, 0xc7, 0xe0, 0x40, 0x1b, 0x24, 0xc1, 0x8c, 0xbe, 0x26, 0xad, 0x3f, 0x72, 0x1, - 0x53, 0x23, 0x5, 0xc9, 0x15, 0x0, 0x6, 0x44, 0x2d, 0x62, 0xbb, 0x35, 0xce, 0x1c, 0x0, 0x3, 0xc7, 0xfd, 0xe8, - 0x29, 0x8e, 0x25, 0xde, 0x21, 0x50, 0xe5, 0x12, 0x0, 0x18, 0x4, 0xca, 0x30, 0xe3, 0x54, 0x4e, 0xca, 0xb2, 0x45, - 0x3c, 0x8b, 0x1b, 0xf9, 0x24, 0x49, 0xf6, 0x6e, 0x4, 0x73, 0xd8, 0x2a, 0xd2, 0x1b, 0x9b, 0x2a, 0x31, 0xb, 0x6, - 0x29, 0x67, 0x0, 0x2, 0x70, 0xc5, 0x1, 0x0, 0x3, 0x5e, 0x77, 0xba, 0x26, 0x0, 0x1c, 0x51,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cb, 0x95, 0xd4, 0x4, 0x0, 0x1e, 0xdb, + 0xcb, 0x6f, 0xe0, 0x9a, 0x39, 0xe5, 0x90, 0x7, 0xdb, 0x65, 0x98, 0xa1, 0xdb, 0x68, 0x68, 0x46, 0xec, + 0x4f, 0x81, 0xc0, 0x68, 0x3, 0x59, 0x94, 0x39, 0x96, 0xcc, 0x2e, 0xfa, 0x25}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x70, 0xc5}; - lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0xa8, 0x88, 0xff, 0x3a, 0x82, 0x1a, 0x85, 0x3b, 0x93, 0x3c, + 0xea, 0xf7, 0xe3, 0xa9, 0xd8, 0x64, 0x83, 0x3a, 0x44, 0xdb, + 0x1d, 0xbe, 0xc8, 0x4f, 0x32, 0xcb, 0x95, 0xd4}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x5e, 0x77, 0xba}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xdb, 0xcb, 0x6f, 0xe0, 0x9a, 0x39, 0xe5, 0x90, 0x7, 0xdb, + 0x65, 0x98, 0xa1, 0xdb, 0x68, 0x68, 0x46, 0xec, 0x4f, 0x81, + 0xc0, 0x68, 0x3, 0x59, 0x94, 0x39, 0x96, 0xcc, 0x2e, 0xfa}; + lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x51, 0x18, 0x69, 0x47, 0xa, 0x88, 0x95, 0x1, 0x7, 0x4c, - 0xe1, 0xf3, 0x25, 0x8b, 0xfd, 0x57, 0x9c, 0x46, 0x44, 0x29, - 0xbc, 0x72, 0x35, 0xec, 0x73, 0xb3, 0x5e, 0xa6}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x90, 0x91, 0xb6, 0xc2, 0x31, 0x27, 0xf5}; - lwmqtt_string_t topic_filter_s3 = {7, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - uint8_t bytesprops0[] = {0x8d, 0x4c, 0x3c, 0xd2, 0x3e}; - uint8_t bytesprops2[] = {0x2f, 0x49, 0xdb, 0xc1, 0x5c, 0x32, 0xed, 0x7e, 0x1b, - 0xf3, 0xf7, 0x2c, 0xee, 0x65, 0x73, 0xe1, 0x60}; - uint8_t bytesprops1[] = {0xd9, 0xcc, 0x62, 0x18, 0x8b, 0x20, 0xa7, 0xe1, 0xb3, 0x37, 0x80}; - uint8_t bytesprops4[] = {0xe8, 0xc7, 0xe0, 0x40, 0x1b, 0x24, 0xc1, 0x8c, 0xbe, 0x26, 0xad, 0x3f, 0x72}; - uint8_t bytesprops3[] = {0xdc, 0x43, 0x96, 0x28, 0x59, 0xf1, 0x18}; - uint8_t bytesprops5[] = {0x44, 0x2d, 0x62, 0xbb, 0x35, 0xce}; - uint8_t bytesprops6[] = {0xc7, 0xfd, 0xe8}; - uint8_t bytesprops7[] = {0x4, 0xca, 0x30, 0xe3, 0x54, 0x4e, 0xca, 0xb2, 0x45, 0x3c, 0x8b, 0x1b, - 0xf9, 0x24, 0x49, 0xf6, 0x6e, 0x4, 0x73, 0xd8, 0x2a, 0xd2, 0x1b, 0x9b}; + uint8_t bytesprops1[] = {0x99, 0xe7, 0x9e, 0x74, 0x1d, 0x27}; + uint8_t bytesprops0[] = {0x9c, 0xef, 0x77, 0xce, 0x12, 0x53, 0xf4, 0x56, 0xdc, 0xcd, 0x47, 0xb7, 0x74, 0xf4, 0x4b, + 0x16, 0xd, 0xfa, 0x7a, 0xe1, 0xa8, 0x5f, 0xaf, 0xdf, 0xd0, 0x6f, 0x18, 0x4d, 0x94, 0x1c}; + uint8_t bytesprops2[] = {0x30, 0x60, 0xe4, 0x5f, 0x50, 0x90, 0xc8, 0x2, 0x11, 0x39, 0xa0, 0x5d}; + uint8_t bytesprops3[] = {0x68, 0x60, 0x72, 0x48, 0x68, 0x89, 0x3e, 0x8a, 0x77, 0x55, 0xa6, 0xc8, + 0xfe, 0xa7, 0xdb, 0xc1, 0x9c, 0x94, 0xa2, 0xc1, 0xe0, 0x42, 0x3d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {17, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {13, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 83}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1481}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 142}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 222}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20709}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3245}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30130}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10678}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15989}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29133}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5541}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1992}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops0}, .v = {6, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2981, 4, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2083, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 15094 [("\210\248\243\&0\128\183m\131\255\nK\158\GS\237\168\184^\196\151 -// \163i\204\242\EM/\208",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\195=\233\&0\253\&5Li\207\224\152Y@mA[\139<\135y;\188",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropMaximumQoS -// 158,PropCorrelationData "\236\181\195\200s\249>",PropMessageExpiryInterval 1325,PropServerReference -// "",PropRetainAvailable 7,PropWildcardSubscriptionAvailable 73,PropMessageExpiryInterval 11841,PropRetainAvailable -// 253,PropWillDelayInterval 9896,PropPayloadFormatIndicator 235,PropResponseInformation "\157",PropTopicAlias -// 7986,PropRequestResponseInformation 160,PropServerReference "\182\NUL#\212\223\230a\214\249 -// \199\174\240\177\198J",PropReceiveMaximum 12853,PropResponseTopic -// "A}7X\179\CAN\154\f\184\147o\b\199\217\149\192\SYN\202\161",PropSessionExpiryInterval 25693,PropTopicAlias -// 28576,PropResponseTopic -// "\SO\166\EM\SI\161\183\NUL[\231\&0\STX\168\145\178H\129g\196\FS",PropSubscriptionIdentifierAvailable -// 17,PropTopicAlias 3483,PropMessageExpiryInterval 23576,PropServerReference -// "\251\142",PropWildcardSubscriptionAvailable 154,PropTopicAliasMaximum 8968,PropRequestResponseInformation -// 107,PropReceiveMaximum 23712,PropReceiveMaximum 12987] +// SubscribeRequest 7451 [("^\181\143}(\238\228\"\243)\\U\DEL\166\161 \193\176\226P\219\EOT\253\191",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("!g\t\b\193\GS\FS\188!\172",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("D2>\192%7\NUL54",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\172D\201\155j\142)Wc\150\143Cc\217\220\253\GS\238m\161\\f",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropMessageExpiryInterval +// 3967,PropWildcardSubscriptionAvailable 160,PropWillDelayInterval 11170,PropTopicAlias +// 26969,PropRequestProblemInformation 230,PropSubscriptionIdentifierAvailable 125,PropMessageExpiryInterval +// 656,PropRequestResponseInformation 53,PropServerReference +// "\136\nV\180>s\245\156\231#\209\182\223Y\193\196\130|\DLE\247\188\239/\154\233\nq",PropUserProperty +// "\SOH4K\RSKU\251\164V\176\207\229\228\144\156Z8\222@\172\245\159\147\226\SI#\150" +// "8\183f;\175\222zW\201\218\DC4\187oz2\180\235\r\168H\176\150\&8b\139q",PropMessageExpiryInterval +// 29283,PropMessageExpiryInterval 26688,PropCorrelationData +// "\181\230U\199\247\155E\241\139\254d\215\211S\248|\150\175\128\146x\141",PropWillDelayInterval +// 16284,PropResponseTopic "\173\160S\135\155\220\tg",PropSubscriptionIdentifierAvailable 31,PropReceiveMaximum +// 4328,PropWildcardSubscriptionAvailable 115,PropReceiveMaximum 963,PropRetainAvailable 180,PropMaximumQoS +// 128,PropSubscriptionIdentifier 8] TEST(Subscribe5QCTest, Encode3) { - uint8_t pkt[] = {0x82, 0xd0, 0x1, 0x3a, 0xf6, 0x95, 0x1, 0x24, 0x9e, 0x9, 0x0, 0x7, 0xec, 0xb5, 0xc3, 0xc8, 0x73, - 0xf9, 0x3e, 0x2, 0x0, 0x0, 0x5, 0x2d, 0x1c, 0x0, 0x0, 0x25, 0x7, 0x28, 0x49, 0x2, 0x0, 0x0, - 0x2e, 0x41, 0x25, 0xfd, 0x18, 0x0, 0x0, 0x26, 0xa8, 0x1, 0xeb, 0x1a, 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1, 0x20, 0xc1, 0xb0, 0xe2, + 0x50, 0xdb, 0x4, 0xfd, 0xbf, 0x28, 0x0, 0xa, 0x21, 0x67, 0x9, 0x8, 0xc1, 0x1d, 0x1c, 0xbc, 0x21, 0xac, 0x21, + 0x0, 0x9, 0x44, 0x32, 0x3e, 0xc0, 0x25, 0x37, 0x0, 0x35, 0x34, 0x4, 0x0, 0x16, 0xac, 0x44, 0xc9, 0x9b, 0x6a, + 0x8e, 0x29, 0x57, 0x63, 0x96, 0x8f, 0x43, 0x63, 0xd9, 0xdc, 0xfd, 0x1d, 0xee, 0x6d, 0xa1, 0x5c, 0x66, 0x9}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xd2, 0xf8, 0xf3, 0x30, 0x80, 0xb7, 0x6d, 0x83, 0xff, 0xa, 0x4b, 0x9e, 0x1d, 0xed, - 0xa8, 0xb8, 0x5e, 0xc4, 0x97, 0x20, 0xa3, 0x69, 0xcc, 0xf2, 0x19, 0x2f, 0xd0}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0x5e, 0xb5, 0x8f, 0x7d, 0x28, 0xee, 0xe4, 0x22, 0xf3, 0x29, 0x5c, 0x55, + 0x7f, 0xa6, 0xa1, 0x20, 0xc1, 0xb0, 0xe2, 0x50, 0xdb, 0x4, 0xfd, 0xbf}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc3, 0x3d, 0xe9, 0x30, 0xfd, 0x35, 0x4c, 0x69, 0xcf, 0xe0, 0x98, - 0x59, 0x40, 0x6d, 0x41, 0x5b, 0x8b, 0x3c, 0x87, 0x79, 0x3b, 0xbc}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x21, 0x67, 0x9, 0x8, 0xc1, 0x1d, 0x1c, 0xbc, 0x21, 0xac}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS2; + uint8_t topic_filter_s2_bytes[] = {0x44, 0x32, 0x3e, 0xc0, 0x25, 0x37, 0x0, 0x35, 0x34}; + lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xac, 0x44, 0xc9, 0x9b, 0x6a, 0x8e, 0x29, 0x57, 0x63, 0x96, 0x8f, + 0x43, 0x63, 0xd9, 0xdc, 0xfd, 0x1d, 0xee, 0x6d, 0xa1, 0x5c, 0x66}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - uint8_t bytesprops0[] = {0xec, 0xb5, 0xc3, 0xc8, 0x73, 0xf9, 0x3e}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops2[] = {0x9d}; - uint8_t bytesprops3[] = {0xb6, 0x0, 0x23, 0xd4, 0xdf, 0xe6, 0x61, 0xd6, - 0xf9, 0x20, 0xc7, 0xae, 0xf0, 0xb1, 0xc6, 0x4a}; - uint8_t bytesprops4[] = {0x41, 0x7d, 0x37, 0x58, 0xb3, 0x18, 0x9a, 0xc, 0xb8, 0x93, - 0x6f, 0x8, 0xc7, 0xd9, 0x95, 0xc0, 0x16, 0xca, 0xa1}; - uint8_t bytesprops5[] = {0xe, 0xa6, 0x19, 0xf, 0xa1, 0xb7, 0x0, 0x5b, 0xe7, 0x30, - 0x2, 0xa8, 0x91, 0xb2, 0x48, 0x81, 0x67, 0xc4, 0x1c}; - uint8_t bytesprops6[] = {0xfb, 0x8e}; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + uint8_t bytesprops0[] = {0x88, 0xa, 0x56, 0xb4, 0x3e, 0x73, 0xf5, 0x9c, 0xe7, 0x23, 0xd1, 0xb6, 0xdf, 0x59, + 0xc1, 0xc4, 0x82, 0x7c, 0x10, 0xf7, 0xbc, 0xef, 0x2f, 0x9a, 0xe9, 0xa, 0x71}; + uint8_t bytesprops2[] = {0x38, 0xb7, 0x66, 0x3b, 0xaf, 0xde, 0x7a, 0x57, 0xc9, 0xda, 0x14, 0xbb, 0x6f, + 0x7a, 0x32, 0xb4, 0xeb, 0xd, 0xa8, 0x48, 0xb0, 0x96, 0x38, 0x62, 0x8b, 0x71}; + uint8_t bytesprops1[] = {0x1, 0x34, 0x4b, 0x1e, 0x4b, 0x55, 0xfb, 0xa4, 0x56, 0xb0, 0xcf, 0xe5, 0xe4, 0x90, + 0x9c, 0x5a, 0x38, 0xde, 0x40, 0xac, 0xf5, 0x9f, 0x93, 0xe2, 0xf, 0x23, 0x96}; + uint8_t bytesprops3[] = {0xb5, 0xe6, 0x55, 0xc7, 0xf7, 0x9b, 0x45, 0xf1, 0x8b, 0xfe, 0x64, + 0xd7, 0xd3, 0x53, 0xf8, 0x7c, 0x96, 0xaf, 0x80, 0x92, 0x78, 0x8d}; + uint8_t bytesprops4[] = {0xad, 0xa0, 0x53, 0x87, 0x9b, 0xdc, 0x9, 0x67}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 158}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1325}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11841}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9896}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 235}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7986}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 160}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12853}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25693}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 28576}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {19, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 17}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 3483}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23576}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 8968}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 107}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23712}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12987}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3967}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 160}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11170}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26969}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 656}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops1}, .v = {26, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29283}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26688}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16284}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 31}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4328}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 115}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 963}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 180}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15094, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 7451, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 31975 [("v\DC3\131\242\151\153\129\216\200a\205\NAK\v\195!\164#\222\225\ESC<",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("a\238tQ\162\133\229\228\DC3<\233\243=Bx`\165\DLE\146J\255",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("*i\190\134\153\235\221\NUL\181\244\166\143\v\164o2",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("{\242\196\145X\GS -// \170E\155\&3m\235\143B\220h-",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS0}),("\240\182WL\223\230\175\ETX\195gN\NAK\STXM\DC4\SYN\240k\a\229\195\151\248\199",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\144\195e\r\DC2\190\186\229\NUL\DEL\167\202\DC4\190\184X\bB\189\217\236\174<\253\&2\144\US\SYNq",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\136\&9\f\v\189\145\182%\141\241\CAN\176>-\209|;",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\191u\SYN\194\143\199\229#\182\174\STX\150\132\152\142\DC3\US{\221}\245\208\241\211B\155\&8",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("63\167",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, -// _subQoS = QoS0})] [PropSharedSubscriptionAvailable 156,PropServerReference -// "\137@\183\246\174\160fX(8\171\202\DLEG\129\224`\135\DEL:\158",PropTopicAliasMaximum -// 19848,PropSubscriptionIdentifierAvailable 207,PropSharedSubscriptionAvailable 239,PropMaximumQoS -// 196,PropMessageExpiryInterval 12949,PropWillDelayInterval 19141,PropSubscriptionIdentifierAvailable 84] +// SubscribeRequest 12482 [("\240\185\219h?\152\186\bA)\215<\169\164\"\193cb\ENQA\175\150%\240PA\255\238",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\191=\159\232\202\226?4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal +// = False, _subQoS = QoS2}),("E\132\197l\158",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS1}),("\241\167y\214\226%\t\ETBii\EM\DEL\170\&4g\168",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\241\224o\202\161\218\237%\226a\207.\254\DC2\153\232\150,\214\&4\f\"\137Q\190\n#Y",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\DC4\240C\b\241\141\151\128\ACK\RSY\\\DLE%",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\NULMD\CAN\134\155\213\216\137",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("\235v\226a\SOHS\196\195R\194,\230\195lcY\213m\211\GS\239\r",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\177\202\DC4\217\183\255t@4q\RS\194uK",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = False, _noLocal = False, _subQoS = QoS0})] [PropPayloadFormatIndicator 104,PropServerReference +// "\195\209\223u\154\n\a\140\&5K})/\242\240Z\DC4\149",PropMessageExpiryInterval 8008,PropResponseTopic +// "",PropReceiveMaximum 29528,PropCorrelationData "'\GS^\\6\140t\138\DLE",PropServerReference +// "q\152\237\194\252PN\ACK\247\173\167",PropSubscriptionIdentifier 17,PropResponseTopic "\156\DC2\208",PropContentType +// "\184\209/\139|%",PropSubscriptionIdentifier 25,PropUserProperty "\DEL\224GP<\226\&4" +// "\227\234\190ou\204@\221\157\217\183F\187\b`\212V\245\243}\GS\141\242\151\188",PropReceiveMaximum +// 9250,PropReasonString "\250\247&\183\241\163\200\221\195\US\170\215\173",PropCorrelationData +// "\141\152@\174\189\SOHi\NAK\155\142aX\183\205T\164\US\US?\218\a\249\191\179\250\130\210\185\RS",PropResponseInformation +// "D\186~\143",PropReasonString "\227\SI",PropUserProperty +// "\234\224;\131\DLE\CAN\f\149\148\233iC\213\211\234\NAK\144F\151I\156\160\177\128\203\238" +// "\f+w4\218\246\158F\147Z\191\166\CAN\142\226\254\167Q6G\207H\239\187=\195j",PropRetainAvailable +// 244,PropMessageExpiryInterval 1770,PropResponseInformation "\EOT\139\161\196\251|",PropReasonString +// "g\232_'\228\EM\FSi\217@\155g\vve\250\138$4\146\186\183Y\192\187ak+",PropResponseTopic +// "\255\246U\DC4\SYN$\250",PropMessageExpiryInterval 31299,PropMessageExpiryInterval 13287,PropTopicAlias +// 17495,PropTopicAlias 26693,PropMaximumQoS 133,PropTopicAlias 21058,PropReceiveMaximum 29829] TEST(Subscribe5QCTest, Encode4) { uint8_t pkt[] = { - 0x82, 0xfd, 0x1, 0x7c, 0xe7, 0x2f, 0x2a, 0x9c, 0x1c, 0x0, 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0x44, 0x57, 0x23, 0x68, 0x45, 0x24, 0x85, 0x23, 0x52, 0x42, 0x21, + 0x74, 0x85, 0x0, 0x1c, 0xf0, 0xb9, 0xdb, 0x68, 0x3f, 0x98, 0xba, 0x8, 0x41, 0x29, 0xd7, 0x3c, 0xa9, 0xa4, 0x22, + 0xc1, 0x63, 0x62, 0x5, 0x41, 0xaf, 0x96, 0x25, 0xf0, 0x50, 0x41, 0xff, 0xee, 0x6, 0x0, 0x8, 0xbf, 0x3d, 0x9f, + 0xe8, 0xca, 0xe2, 0x3f, 0x34, 0x2, 0x0, 0x5, 0x45, 0x84, 0xc5, 0x6c, 0x9e, 0xd, 0x0, 0x10, 0xf1, 0xa7, 0x79, + 0xd6, 0xe2, 0x25, 0x9, 0x17, 0x69, 0x69, 0x19, 0x7f, 0xaa, 0x34, 0x67, 0xa8, 0x16, 0x0, 0x1c, 0xf1, 0xe0, 0x6f, + 0xca, 0xa1, 0xda, 0xed, 0x25, 0xe2, 0x61, 0xcf, 0x2e, 0xfe, 0x12, 0x99, 0xe8, 0x96, 0x2c, 0xd6, 0x34, 0xc, 0x22, + 0x89, 0x51, 0xbe, 0xa, 0x23, 0x59, 0x1e, 0x0, 0xe, 0x14, 0xf0, 0x43, 0x8, 0xf1, 0x8d, 0x97, 0x80, 0x6, 0x1e, + 0x59, 0x5c, 0x10, 0x25, 0x2c, 0x0, 0x9, 0x0, 0x4d, 0x44, 0x18, 0x86, 0x9b, 0xd5, 0xd8, 0x89, 0x2, 0x0, 0x16, + 0xeb, 0x76, 0xe2, 0x61, 0x1, 0x53, 0xc4, 0xc3, 0x52, 0xc2, 0x2c, 0xe6, 0xc3, 0x6c, 0x63, 0x59, 0xd5, 0x6d, 0xd3, + 0x1d, 0xef, 0xd, 0x16, 0x0, 0xe, 0xb1, 0xca, 0x14, 0xd9, 0xb7, 0xff, 0x74, 0x40, 0x34, 0x71, 0x1e, 0xc2, 0x75, + 0x4b, 0x10}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x76, 0x13, 0x83, 0xf2, 0x97, 0x99, 0x81, 0xd8, 0xc8, 0x61, 0xcd, - 0x15, 0xb, 0xc3, 0x21, 0xa4, 0x23, 0xde, 0xe1, 0x1b, 0x3c}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xf0, 0xb9, 0xdb, 0x68, 0x3f, 0x98, 0xba, 0x8, 0x41, 0x29, + 0xd7, 0x3c, 0xa9, 0xa4, 0x22, 0xc1, 0x63, 0x62, 0x5, 0x41, + 0xaf, 0x96, 0x25, 0xf0, 0x50, 0x41, 0xff, 0xee}; + lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x61, 0xee, 0x74, 0x51, 0xa2, 0x85, 0xe5, 0xe4, 0x13, 0x3c, 0xe9, - 0xf3, 0x3d, 0x42, 0x78, 0x60, 0xa5, 0x10, 0x92, 0x4a, 0xff}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xbf, 0x3d, 0x9f, 0xe8, 0xca, 0xe2, 0x3f, 0x34}; + lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2a, 0x69, 0xbe, 0x86, 0x99, 0xeb, 0xdd, 0x0, - 0xb5, 0xf4, 0xa6, 0x8f, 0xb, 0xa4, 0x6f, 0x32}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x45, 0x84, 0xc5, 0x6c, 0x9e}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x7b, 0xf2, 0xc4, 0x91, 0x58, 0x1d, 0x20, 0xaa, 0x45, - 0x9b, 0x33, 0x6d, 0xeb, 0x8f, 0x42, 0xdc, 0x68, 0x2d}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf1, 0xa7, 0x79, 0xd6, 0xe2, 0x25, 0x9, 0x17, + 0x69, 0x69, 0x19, 0x7f, 0xaa, 0x34, 0x67, 0xa8}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xf0, 0xb6, 0x57, 0x4c, 0xdf, 0xe6, 0xaf, 0x3, 0xc3, 0x67, 0x4e, 0x15, - 0x2, 0x4d, 0x14, 0x16, 0xf0, 0x6b, 0x7, 0xe5, 0xc3, 0x97, 0xf8, 0xc7}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xf1, 0xe0, 0x6f, 0xca, 0xa1, 0xda, 0xed, 0x25, 0xe2, 0x61, + 0xcf, 0x2e, 0xfe, 0x12, 0x99, 0xe8, 0x96, 0x2c, 0xd6, 0x34, + 0xc, 0x22, 0x89, 0x51, 0xbe, 0xa, 0x23, 0x59}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x90, 0xc3, 0x65, 0xd, 0x12, 0xbe, 0xba, 0xe5, 0x0, 0x7f, - 0xa7, 0xca, 0x14, 0xbe, 0xb8, 0x58, 0x8, 0x42, 0xbd, 0xd9, - 0xec, 0xae, 0x3c, 0xfd, 0x32, 0x90, 0x1f, 0x16, 0x71}; - lwmqtt_string_t topic_filter_s5 = {29, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x14, 0xf0, 0x43, 0x8, 0xf1, 0x8d, 0x97, 0x80, 0x6, 0x1e, 0x59, 0x5c, 0x10, 0x25}; + lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x88, 0x39, 0xc, 0xb, 0xbd, 0x91, 0xb6, 0x25, 0x8d, - 0xf1, 0x18, 0xb0, 0x3e, 0x2d, 0xd1, 0x7c, 0x3b}; - lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x0, 0x4d, 0x44, 0x18, 0x86, 0x9b, 0xd5, 0xd8, 0x89}; + lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xbf, 0x75, 0x16, 0xc2, 0x8f, 0xc7, 0xe5, 0x23, 0xb6, 0xae, 0x2, 0x96, 0x84, 0x98, - 0x8e, 0x13, 0x1f, 0x7b, 0xdd, 0x7d, 0xf5, 0xd0, 0xf1, 0xd3, 0x42, 0x9b, 0x38}; - lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xeb, 0x76, 0xe2, 0x61, 0x1, 0x53, 0xc4, 0xc3, 0x52, 0xc2, 0x2c, + 0xe6, 0xc3, 0x6c, 0x63, 0x59, 0xd5, 0x6d, 0xd3, 0x1d, 0xef, 0xd}; + lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x36, 0x33, 0xa7}; - lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xb1, 0xca, 0x14, 0xd9, 0xb7, 0xff, 0x74, + 0x40, 0x34, 0x71, 0x1e, 0xc2, 0x75, 0x4b}; + lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; lwmqtt_sub_options_t sub_opts[9]; - sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS2; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = true; sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[5].retain_as_published = true; sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = true; sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; - uint8_t bytesprops0[] = {0x89, 0x40, 0xb7, 0xf6, 0xae, 0xa0, 0x66, 0x58, 0x28, 0x38, 0xab, - 0xca, 0x10, 0x47, 0x81, 0xe0, 0x60, 0x87, 0x7f, 0x3a, 0x9e}; + sub_opts[8].no_local = false; + uint8_t bytesprops0[] = {0xc3, 0xd1, 0xdf, 0x75, 0x9a, 0xa, 0x7, 0x8c, 0x35, + 0x4b, 0x7d, 0x29, 0x2f, 0xf2, 0xf0, 0x5a, 0x14, 0x95}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops2[] = {0x27, 0x1d, 0x5e, 0x5c, 0x36, 0x8c, 0x74, 0x8a, 0x10}; + uint8_t bytesprops3[] = {0x71, 0x98, 0xed, 0xc2, 0xfc, 0x50, 0x4e, 0x6, 0xf7, 0xad, 0xa7}; + uint8_t bytesprops4[] = {0x9c, 0x12, 0xd0}; + uint8_t bytesprops5[] = {0xb8, 0xd1, 0x2f, 0x8b, 0x7c, 0x25}; + uint8_t bytesprops7[] = {0xe3, 0xea, 0xbe, 0x6f, 0x75, 0xcc, 0x40, 0xdd, 0x9d, 0xd9, 0xb7, 0x46, 0xbb, + 0x8, 0x60, 0xd4, 0x56, 0xf5, 0xf3, 0x7d, 0x1d, 0x8d, 0xf2, 0x97, 0xbc}; + uint8_t bytesprops6[] = {0x7f, 0xe0, 0x47, 0x50, 0x3c, 0xe2, 0x34}; + uint8_t bytesprops8[] = {0xfa, 0xf7, 0x26, 0xb7, 0xf1, 0xa3, 0xc8, 0xdd, 0xc3, 0x1f, 0xaa, 0xd7, 0xad}; + uint8_t bytesprops9[] = {0x8d, 0x98, 0x40, 0xae, 0xbd, 0x1, 0x69, 0x15, 0x9b, 0x8e, 0x61, 0x58, 0xb7, 0xcd, 0x54, + 0xa4, 0x1f, 0x1f, 0x3f, 0xda, 0x7, 0xf9, 0xbf, 0xb3, 0xfa, 0x82, 0xd2, 0xb9, 0x1e}; + uint8_t bytesprops10[] = {0x44, 0xba, 0x7e, 0x8f}; + uint8_t bytesprops11[] = {0xe3, 0xf}; + uint8_t bytesprops13[] = {0xc, 0x2b, 0x77, 0x34, 0xda, 0xf6, 0x9e, 0x46, 0x93, 0x5a, 0xbf, 0xa6, 0x18, 0x8e, + 0xe2, 0xfe, 0xa7, 0x51, 0x36, 0x47, 0xcf, 0x48, 0xef, 0xbb, 0x3d, 0xc3, 0x6a}; + uint8_t bytesprops12[] = {0xea, 0xe0, 0x3b, 0x83, 0x10, 0x18, 0xc, 0x95, 0x94, 0xe9, 0x69, 0x43, 0xd5, + 0xd3, 0xea, 0x15, 0x90, 0x46, 0x97, 0x49, 0x9c, 0xa0, 0xb1, 0x80, 0xcb, 0xee}; + uint8_t bytesprops14[] = {0x4, 0x8b, 0xa1, 0xc4, 0xfb, 0x7c}; + uint8_t bytesprops15[] = {0x67, 0xe8, 0x5f, 0x27, 0xe4, 0x19, 0x1c, 0x69, 0xd9, 0x40, 0x9b, 0x67, 0xb, 0x76, + 0x65, 0xfa, 0x8a, 0x24, 0x34, 0x92, 0xba, 0xb7, 0x59, 0xc0, 0xbb, 0x61, 0x6b, 0x2b}; + uint8_t bytesprops16[] = {0xff, 0xf6, 0x55, 0x14, 0x16, 0x24, 0xfa}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 156}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19848}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 12949}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19141}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8008}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29528}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops6}, .v = {25, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9250}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)38, + .value = {.pair = {.k = {26, (char*)&bytesprops12}, .v = {27, (char*)&bytesprops13}}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1770}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops14}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops15}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops16}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31299}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13287}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17495}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26693}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 133}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21058}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29829}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31975, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12482, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25478 [("\219SY?\CAN\SOHQE\164",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\183\ENQ\209\132\194\DELz\220\v\150\RSf\145?a\170\217x\159\172",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("v\193\162\ETX\200\RSE\250\235",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// True, _noLocal = True, _subQoS = QoS0})] [PropRequestResponseInformation 169,PropReceiveMaximum -// 141,PropReceiveMaximum 29474,PropMessageExpiryInterval 31401,PropMessageExpiryInterval 5256,PropContentType -// "",PropReasonString "\DC1\STX\191\DC2\170\249@\195\226\146\253\f\219\205\135",PropAuthenticationData -// "\133\234\222\210NY\137\155\DC1\148\208;\216\138\254\166",PropMessageExpiryInterval 7843,PropAuthenticationData -// "\134\150\EMu\202\134\SUB\DC1\DC4N\189\239w\170pWY\212\175i\193\r\216\SYN",PropMaximumPacketSize -// 12152,PropContentType "\215\234\214%\FS\160\195[\"\248",PropSubscriptionIdentifierAvailable 224] +// SubscribeRequest 30449 [("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = +// True, _subQoS = QoS2}),("\141\164\198",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS1}),("n\154\FS\SOH\163",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("%+\\\SOH\ETX\139g?h",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\233\208\172\204\212\234\ETXYP\192\163\217x\DC2\154\144\143@1\240\206\161\250",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("-\143",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] +// [PropReceiveMaximum 10961,PropPayloadFormatIndicator 104,PropContentType "",PropMaximumQoS 93,PropUserProperty +// "\ETB\200\EOT^\253\224" "\187\v\129\137B\156\US_)H\170z[\247\219\152b\189\207\SUB\149c_",PropContentType +// "6r\174\160\168\144+\227\\\144\129\142\164\EOT\161z~\246z\187=(D\216\152$(O",PropTopicAliasMaximum +// 32704,PropSessionExpiryInterval 10073] TEST(Subscribe5QCTest, Encode5) { - uint8_t pkt[] = {0x82, 0xa0, 0x1, 0x63, 0x86, 0x6e, 0x19, 0xa9, 0x21, 0x0, 0x8d, 0x21, 0x73, 0x22, 0x2, 0x0, 0x0, - 0x7a, 0xa9, 0x2, 0x0, 0x0, 0x14, 0x88, 0x3, 0x0, 0x0, 0x1f, 0x0, 0xf, 0x11, 0x2, 0xbf, 0x12, - 0xaa, 0xf9, 0x40, 0xc3, 0xe2, 0x92, 0xfd, 0xc, 0xdb, 0xcd, 0x87, 0x16, 0x0, 0x10, 0x85, 0xea, 0xde, - 0xd2, 0x4e, 0x59, 0x89, 0x9b, 0x11, 0x94, 0xd0, 0x3b, 0xd8, 0x8a, 0xfe, 0xa6, 0x2, 0x0, 0x0, 0x1e, - 0xa3, 0x16, 0x0, 0x18, 0x86, 0x96, 0x19, 0x75, 0xca, 0x86, 0x1a, 0x11, 0x14, 0x4e, 0xbd, 0xef, 0x77, - 0xaa, 0x70, 0x57, 0x59, 0xd4, 0xaf, 0x69, 0xc1, 0xd, 0xd8, 0x16, 0x27, 0x0, 0x0, 0x2f, 0x78, 0x3, - 0x0, 0xa, 0xd7, 0xea, 0xd6, 0x25, 0x1c, 0xa0, 0xc3, 0x5b, 0x22, 0xf8, 0x29, 0xe0, 0x0, 0x9, 0xdb, - 0x53, 0x59, 0x3f, 0x18, 0x1, 0x51, 0x45, 0xa4, 0x2c, 0x0, 0x14, 0xb7, 0x5, 0xd1, 0x84, 0xc2, 0x7f, - 0x7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 0x18, 0x0, 0x1b, 0x63, 0x26, 0x59, 0x37, 0x8f, 0x2e, 0x93, 0x54, 0x4c, 0x98, 0xa8, + 0x9c, 0xb0, 0x4b, 0xce, 0x40, 0x26, 0xf9, 0xf7, 0xd8, 0x13, 0x55, 0x3, 0x1a, 0xfc, 0x40, 0x57, 0x9, 0x0, 0x3, + 0x60, 0x90, 0x37, 0x1c, 0x0, 0x1a, 0x1f, 0xcb, 0x76, 0xd4, 0x8f, 0xb7, 0x17, 0xdb, 0x4b, 0xbd, 0x1e, 0xe8, 0xc9, + 0x44, 0x60, 0x7, 0x21, 0xf, 0xc8, 0xfe, 0x6, 0x59, 0x1e, 0xb7, 0x7c, 0x4d, 0x2, 0x0, 0x18, 0x5b, 0xe, 0xf2, + 0xb7, 0x96, 0xdc, 0xe2, 0x8f, 0x15, 0xa1, 0x11, 0x6a, 0xaf, 0xdd, 0xf0, 0x70, 0x3a, 0x9a, 0x3b, 0x68, 0x5e, 0x3e, + 0xa1, 0xfa, 0x12, 0x0, 0x2, 0x2d, 0x8f, 0x28}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xdb, 0x53, 0x59, 0x3f, 0x18, 0x1, 0x51, 0x45, 0xa4}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb7, 0x5, 0xd1, 0x84, 0xc2, 0x7f, 0x7a, 0xdc, 0xb, 0x96, - 0x1e, 0x66, 0x91, 0x3f, 0x61, 0xaa, 0xd9, 0x78, 0x9f, 0xac}; - lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x8d, 0xa4, 0xc6}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x76, 0xc1, 0xa2, 0x3, 0xc8, 0x1e, 0x45, 0xfa, 0xeb}; - lwmqtt_string_t topic_filter_s2 = {9, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6e, 0x9a, 0x1c, 0x1, 0xa3}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + uint8_t topic_filter_s3_bytes[] = {0x25, 0x2b, 0x5c, 0x1, 0x3, 0x8b, 0x67, 0x3f, 0x68}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0xe9, 0xd0, 0xac, 0xcc, 0xd4, 0xea, 0x3, 0x59, 0x50, 0xc0, + 0xa3, 0xd9, 0x78, 0x12, 0x9a, 0x90, 0x8f, 0x40, 0x31, 0xf0, + 0xce, 0x3c, 0x43, 0x8b, 0xe9, 0x34, 0x82, 0x31, 0x84, 0xe9}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x40, 0xf8, 0x55, 0x8e}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x63, 0x26, 0x59, 0x37, 0x8f, 0x2e, 0x93, 0x54, 0x4c, 0x98, 0xa8, 0x9c, 0xb0, 0x4b, + 0xce, 0x40, 0x26, 0xf9, 0xf7, 0xd8, 0x13, 0x55, 0x3, 0x1a, 0xfc, 0x40, 0x57}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x60, 0x90, 0x37}; + lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x1f, 0xcb, 0x76, 0xd4, 0x8f, 0xb7, 0x17, 0xdb, 0x4b, 0xbd, 0x1e, 0xe8, 0xc9, + 0x44, 0x60, 0x7, 0x21, 0xf, 0xc8, 0xfe, 0x6, 0x59, 0x1e, 0xb7, 0x7c, 0x4d}; + lwmqtt_string_t topic_filter_s8 = {26, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x5b, 0xe, 0xf2, 0xb7, 0x96, 0xdc, 0xe2, 0x8f, 0x15, 0xa1, 0x11, 0x6a, + 0xaf, 0xdd, 0xf0, 0x70, 0x3a, 0x9a, 0x3b, 0x68, 0x5e, 0x3e, 0xa1, 0xfa}; + lwmqtt_string_t topic_filter_s9 = {24, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x2d, 0x8f}; + lwmqtt_string_t topic_filter_s10 = {2, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = true; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; + sub_opts[7].qos = LWMQTT_QOS0; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = false; + sub_opts[8].no_local = false; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + sub_opts[10].qos = LWMQTT_QOS0; + sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = false; uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x11, 0x2, 0xbf, 0x12, 0xaa, 0xf9, 0x40, 0xc3, 0xe2, 0x92, 0xfd, 0xc, 0xdb, 0xcd, 0x87}; - uint8_t bytesprops2[] = {0x85, 0xea, 0xde, 0xd2, 0x4e, 0x59, 0x89, 0x9b, - 0x11, 0x94, 0xd0, 0x3b, 0xd8, 0x8a, 0xfe, 0xa6}; - uint8_t bytesprops3[] = {0x86, 0x96, 0x19, 0x75, 0xca, 0x86, 0x1a, 0x11, 0x14, 0x4e, 0xbd, 0xef, - 0x77, 0xaa, 0x70, 0x57, 0x59, 0xd4, 0xaf, 0x69, 0xc1, 0xd, 0xd8, 0x16}; - uint8_t bytesprops4[] = {0xd7, 0xea, 0xd6, 0x25, 0x1c, 0xa0, 0xc3, 0x5b, 0x22, 0xf8}; + uint8_t bytesprops2[] = {0xbb, 0xb, 0x81, 0x89, 0x42, 0x9c, 0x1f, 0x5f, 0x29, 0x48, 0xaa, 0x7a, + 0x5b, 0xf7, 0xdb, 0x98, 0x62, 0xbd, 0xcf, 0x1a, 0x95, 0x63, 0x5f}; + uint8_t bytesprops1[] = {0x17, 0xc8, 0x4, 0x5e, 0xfd, 0xe0}; + uint8_t bytesprops3[] = {0x36, 0x72, 0xae, 0xa0, 0xa8, 0x90, 0x2b, 0xe3, 0x5c, 0x90, 0x81, 0x8e, 0xa4, 0x4, + 0xa1, 0x7a, 0x7e, 0xf6, 0x7a, 0xbb, 0x3d, 0x28, 0x44, 0xd8, 0x98, 0x24, 0x28, 0x4f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 141}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29474}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31401}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5256}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 10961}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 104}}, {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7843}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {24, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 12152}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 224}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 93}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {23, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32704}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10073}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25478, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30449, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 10292 -// [("\216C\ACK\176Ru\154\153\169y\232\US\188\236\130\166\245\218\&8\219\141\156\&2\174\210\231\171\f",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("F\251\229\161W\204c\GS\232y\155\133\149\FS\RS\168!Ni!\230\225\223\"*",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("z\255\209",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] -// [PropSharedSubscriptionAvailable 81,PropMessageExpiryInterval 27436,PropServerKeepAlive 4051,PropReasonString -// "\f\197\253\156",PropSubscriptionIdentifierAvailable 230,PropAssignedClientIdentifier -// "~q\156\178=8/\244\ETX\212jm\183",PropWillDelayInterval 2198,PropResponseInformation -// "\150\255\CAN\169F8\v\169\199\ACK\tm6\237a\184\212G\185\175\128n\144A\144\DC2}\212",PropSubscriptionIdentifierAvailable -// 233,PropSharedSubscriptionAvailable 118,PropMessageExpiryInterval 2277,PropServerKeepAlive 14258,PropMaximumQoS -// 3,PropTopicAliasMaximum 15364,PropRetainAvailable 21,PropRetainAvailable 110,PropMaximumPacketSize -// 17605,PropMaximumPacketSize 26875,PropSubscriptionIdentifierAvailable 75,PropWillDelayInterval 195,PropReceiveMaximum -// 12419,PropReasonString "+\186\224\238 \239\t\187\200\133\211O#*LD\SYN\244g_5s\143",PropSubscriptionIdentifier -// 6,PropReceiveMaximum 968] +// SubscribeRequest 32182 [("\FS\DC3\128\252X\ETX\252\165T{QD\211\165q\226\248\251q\206\169A",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] +// [PropContentType "VXa\250\218Qr\201\206,\249\143\209(1\180\195\221G\NUL\128X\139\162\&3P\228\225",PropServerReference +// "avZ\231",PropRequestProblemInformation 165,PropReceiveMaximum 26553,PropServerReference +// "\240\STX\212d\171.\bC\145\227\203-\US_\na\211cx\220\205\215\165&o\139\211wg\227",PropSubscriptionIdentifierAvailable +// 184,PropResponseTopic "M#R,\161\247\239w\242\EMd\183gOH\175\DC2\a\151U\254j$I*",PropAuthenticationMethod +// "R\241y\185",PropRequestResponseInformation 201,PropRequestProblemInformation 34,PropMaximumPacketSize +// 8130,PropReceiveMaximum 9709,PropRequestProblemInformation 125,PropResponseInformation +// "\151\213\248\218(eo\210\222S,\DC3\143IN\225\231\DC4\128]\222\236\128\221\211$\209\221d\190",PropResponseInformation +// "l\220r\237\156S\141\196\145\209\155'\235\CAN<\216\175\r\140\206I\173\134\SO\140\186:^\161n",PropContentType +// "7x",PropMessageExpiryInterval 17129] TEST(Subscribe5QCTest, Encode6) { - uint8_t pkt[] = {0x82, 0xd4, 0x1, 0x28, 0x34, 0x8f, 0x1, 0x2a, 0x51, 0x2, 0x0, 0x0, 0x6b, 0x2c, 0x13, 0xf, 0xd3, - 0x1f, 0x0, 0x4, 0xc, 0xc5, 0xfd, 0x9c, 0x29, 0xe6, 0x12, 0x0, 0xd, 0x7e, 0x71, 0x9c, 0xb2, 0x3d, - 0x38, 0x2f, 0xf4, 0x3, 0xd4, 0x6a, 0x6d, 0xb7, 0x18, 0x0, 0x0, 0x8, 0x96, 0x1a, 0x0, 0x1c, 0x96, - 0xff, 0x18, 0xa9, 0x46, 0x38, 0xb, 0xa9, 0xc7, 0x6, 0x9, 0x6d, 0x36, 0xed, 0x61, 0xb8, 0xd4, 0x47, - 0xb9, 0xaf, 0x80, 0x6e, 0x90, 0x41, 0x90, 0x12, 0x7d, 0xd4, 0x29, 0xe9, 0x2a, 0x76, 0x2, 0x0, 0x0, - 0x8, 0xe5, 0x13, 0x37, 0xb2, 0x24, 0x3, 0x22, 0x3c, 0x4, 0x25, 0x15, 0x25, 0x6e, 0x27, 0x0, 0x0, - 0x44, 0xc5, 0x27, 0x0, 0x0, 0x68, 0xfb, 0x29, 0x4b, 0x18, 0x0, 0x0, 0x0, 0xc3, 0x21, 0x30, 0x83, - 0x1f, 0x0, 0x17, 0x2b, 0xba, 0xe0, 0xee, 0x20, 0xef, 0x9, 0xbb, 0xc8, 0x85, 0xd3, 0x4f, 0x23, 0x2a, - 0x4c, 0x44, 0x16, 0xf4, 0x67, 0x5f, 0x35, 0x73, 0x8f, 0xb, 0x6, 0x21, 0x3, 0xc8, 0x0, 0x1c, 0xd8, - 0x43, 0x6, 0xb0, 0x52, 0x75, 0x9a, 0x99, 0xa9, 0x79,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 0x25, 0xed, 0x17, 0x7d, 0x1a, 0x0, + 0x1e, 0x97, 0xd5, 0xf8, 0xda, 0x28, 0x65, 0x6f, 0xd2, 0xde, 0x53, 0x2c, 0x13, 0x8f, 0x49, 0x4e, 0xe1, + 0xe7, 0x14, 0x80, 0x5d, 0xde, 0xec, 0x80, 0xdd, 0xd3, 0x24, 0xd1, 0xdd, 0x64, 0xbe, 0x1a, 0x0, 0x1e, + 0x6c, 0xdc, 0x72, 0xed, 0x9c, 0x53, 0x8d, 0xc4, 0x91, 0xd1, 0x9b, 0x27, 0xeb, 0x18, 0x3c, 0xd8, 0xaf, + 0xd, 0x8c, 0xce, 0x49, 0xad, 0x86, 0xe, 0x8c, 0xba, 0x3a, 0x5e, 0xa1, 0x6e, 0x3, 0x0, 0x2, 0x37, + 0x78, 0x2, 0x0, 0x0, 0x42, 0xe9, 0x0, 0x16, 0x1c, 0x13, 0x80, 0xfc, 0x58, 0x3, 0xfc, 0xa5, 0x54, + 0x7b, 0x51, 0x44, 0xd3, 0xa5, 0x71, 0xe2, 0xf8, 0xfb, 0x71, 0xce, 0xa9, 0x41, 0x19}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[3]; - uint8_t topic_filter_s0_bytes[] = {0xd8, 0x43, 0x6, 0xb0, 0x52, 0x75, 0x9a, 0x99, 0xa9, 0x79, 0xe8, 0x1f, 0xbc, 0xec, - 0x82, 0xa6, 0xf5, 0xda, 0x38, 0xdb, 0x8d, 0x9c, 0x32, 0xae, 0xd2, 0xe7, 0xab, 0xc}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x1c, 0x13, 0x80, 0xfc, 0x58, 0x3, 0xfc, 0xa5, 0x54, 0x7b, 0x51, + 0x44, 0xd3, 0xa5, 0x71, 0xe2, 0xf8, 0xfb, 0x71, 0xce, 0xa9, 0x41}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x46, 0xfb, 0xe5, 0xa1, 0x57, 0xcc, 0x63, 0x1d, 0xe8, 0x79, 0x9b, 0x85, 0x95, - 0x1c, 0x1e, 0xa8, 0x21, 0x4e, 0x69, 0x21, 0xe6, 0xe1, 0xdf, 0x22, 0x2a}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7a, 0xff, 0xd1}; - lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - lwmqtt_sub_options_t sub_opts[3]; - sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - uint8_t bytesprops0[] = {0xc, 0xc5, 0xfd, 0x9c}; - uint8_t bytesprops1[] = {0x7e, 0x71, 0x9c, 0xb2, 0x3d, 0x38, 0x2f, 0xf4, 0x3, 0xd4, 0x6a, 0x6d, 0xb7}; - uint8_t bytesprops2[] = {0x96, 0xff, 0x18, 0xa9, 0x46, 0x38, 0xb, 0xa9, 0xc7, 0x6, 0x9, 0x6d, 0x36, 0xed, - 0x61, 0xb8, 0xd4, 0x47, 0xb9, 0xaf, 0x80, 0x6e, 0x90, 0x41, 0x90, 0x12, 0x7d, 0xd4}; - uint8_t bytesprops3[] = {0x2b, 0xba, 0xe0, 0xee, 0x20, 0xef, 0x9, 0xbb, 0xc8, 0x85, 0xd3, 0x4f, - 0x23, 0x2a, 0x4c, 0x44, 0x16, 0xf4, 0x67, 0x5f, 0x35, 0x73, 0x8f}; + sub_opts[0].no_local = false; + uint8_t bytesprops0[] = {0x56, 0x58, 0x61, 0xfa, 0xda, 0x51, 0x72, 0xc9, 0xce, 0x2c, 0xf9, 0x8f, 0xd1, 0x28, + 0x31, 0xb4, 0xc3, 0xdd, 0x47, 0x0, 0x80, 0x58, 0x8b, 0xa2, 0x33, 0x50, 0xe4, 0xe1}; + uint8_t bytesprops1[] = {0x61, 0x76, 0x5a, 0xe7}; + uint8_t bytesprops2[] = {0xf0, 0x2, 0xd4, 0x64, 0xab, 0x2e, 0x8, 0x43, 0x91, 0xe3, 0xcb, 0x2d, 0x1f, 0x5f, 0xa, + 0x61, 0xd3, 0x63, 0x78, 0xdc, 0xcd, 0xd7, 0xa5, 0x26, 0x6f, 0x8b, 0xd3, 0x77, 0x67, 0xe3}; + uint8_t bytesprops3[] = {0x4d, 0x23, 0x52, 0x2c, 0xa1, 0xf7, 0xef, 0x77, 0xf2, 0x19, 0x64, 0xb7, 0x67, + 0x4f, 0x48, 0xaf, 0x12, 0x7, 0x97, 0x55, 0xfe, 0x6a, 0x24, 0x49, 0x2a}; + uint8_t bytesprops4[] = {0x52, 0xf1, 0x79, 0xb9}; + uint8_t bytesprops5[] = {0x97, 0xd5, 0xf8, 0xda, 0x28, 0x65, 0x6f, 0xd2, 0xde, 0x53, 0x2c, 0x13, 0x8f, 0x49, 0x4e, + 0xe1, 0xe7, 0x14, 0x80, 0x5d, 0xde, 0xec, 0x80, 0xdd, 0xd3, 0x24, 0xd1, 0xdd, 0x64, 0xbe}; + uint8_t bytesprops6[] = {0x6c, 0xdc, 0x72, 0xed, 0x9c, 0x53, 0x8d, 0xc4, 0x91, 0xd1, 0x9b, 0x27, 0xeb, 0x18, 0x3c, + 0xd8, 0xaf, 0xd, 0x8c, 0xce, 0x49, 0xad, 0x86, 0xe, 0x8c, 0xba, 0x3a, 0x5e, 0xa1, 0x6e}; + uint8_t bytesprops7[] = {0x37, 0x78}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27436}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4051}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2198}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 233}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2277}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14258}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15364}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 17605}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26875}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 195}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12419}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 968}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26553}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8130}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9709}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 125}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17129}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10292, 3, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32182, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 28082 -// [("\140\149\246\194\167\STX\161y\249\132\156~\130\254\201\SOH\t]\158a%Ix(\237v\155\239",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\239\191\NAKC\239\fO\ENQ\137\212*j\228\209\255\241\218\177\130",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\249]\224\SUBw\152l\185\139\aYg\DC1\SOHS\133\172",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("9\191\NAK(\225n\196\ETBp\206\175",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\131\SOHT\174\251+&V\131\139\217F\DC1\151\228j\247b\229",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\138\148\167\139=\204k2\161\181/\146\&0\141]\181\151\NUL\r\188\"\v\132\&1",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\202}\DLEqP\f\228\&3\199\161dJk\216\142XIapF0\134_\205\197\141\244\222\135",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\137ya\140\155\\\DEL\204\FS\216\244Xt\190\NULg\242\174\151\160\243",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("\"\DC4#\179\&1\GS#B\162\161\244\172c\DC4&\225",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\193^\197\214\CAN\240\155v(\145\239\174\201\134\236\232l\177\163",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] [PropReasonString -// ";\f\183\150=\237\DLE\162\\H)\183\ENQ\157\DC4\186\224\&0"] +// SubscribeRequest 318 [("J\EM\RS\185P\242\251\199\SI\NAKzfK\180\a\175(t\FS\178N\EM",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),(".y\253\aln\145\149/\203\DLE\135\254_\241\215\231:\192\163",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\251\175[\171\nR\197",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("\153\f\DEL0\187\236\132%Lyr\231\f\135\134Mr(f\246",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\173t\NUL)\205\182\DC3\CAN\230V\227e\230\128?\177\&1\179V",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\247\129\193tL",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropUserProperty +// "B/\199V\128\148\148G.F\243\t\182\SUBC" "\NUL\220\253\150\SO{\ENQ\154\SIUK\241\209-\141\178",PropServerKeepAlive +// 20885,PropReasonString "\185\GSs\254qEx\DC1\245\227",PropTopicAlias 447] TEST(Subscribe5QCTest, Encode7) { - uint8_t pkt[] = { - 0x82, 0x81, 0x2, 0x6d, 0xb2, 0x15, 0x1f, 0x0, 0x12, 0x3b, 0xc, 0xb7, 0x96, 0x3d, 0xed, 0x10, 0xa2, 0x5c, 0x48, - 0x29, 0xb7, 0x5, 0x9d, 0x14, 0xba, 0xe0, 0x30, 0x0, 0x1c, 0x8c, 0x95, 0xf6, 0xc2, 0xa7, 0x2, 0xa1, 0x79, 0xf9, - 0x84, 0x9c, 0x7e, 0x82, 0xfe, 0xc9, 0x1, 0x9, 0x5d, 0x9e, 0x61, 0x25, 0x49, 0x78, 0x28, 0xed, 0x76,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5, 0xf7, 0x81, 0xc1, 0x74, 0x4c, 0x1a}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x8c, 0x95, 0xf6, 0xc2, 0xa7, 0x2, 0xa1, 0x79, 0xf9, 0x84, - 0x9c, 0x7e, 0x82, 0xfe, 0xc9, 0x1, 0x9, 0x5d, 0x9e, 0x61, - 0x25, 0x49, 0x78, 0x28, 0xed, 0x76, 0x9b, 0xef}; - lwmqtt_string_t topic_filter_s0 = {28, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x4a, 0x19, 0x1e, 0xb9, 0x50, 0xf2, 0xfb, 0xc7, 0xf, 0x15, 0x7a, + 0x66, 0x4b, 0xb4, 0x7, 0xaf, 0x28, 0x74, 0x1c, 0xb2, 0x4e, 0x19}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xef, 0xbf, 0x15, 0x43, 0xef, 0xc, 0x4f, 0x5, 0x89, 0xd4, - 0x2a, 0x6a, 0xe4, 0xd1, 0xff, 0xf1, 0xda, 0xb1, 0x82}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2e, 0x79, 0xfd, 0x7, 0x6c, 0x6e, 0x91, 0x95, 0x2f, 0xcb, + 0x10, 0x87, 0xfe, 0x5f, 0xf1, 0xd7, 0xe7, 0x3a, 0xc0, 0xa3}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xf9, 0x5d, 0xe0, 0x1a, 0x77, 0x98, 0x6c, 0xb9, 0x8b, - 0x7, 0x59, 0x67, 0x11, 0x1, 0x53, 0x85, 0xac}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xfb, 0xaf, 0x5b, 0xab, 0xa, 0x52, 0xc5}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x39, 0xbf, 0x15, 0x28, 0xe1, 0x6e, 0xc4, 0x17, 0x70, 0xce, 0xaf}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x99, 0xc, 0x7f, 0x30, 0xbb, 0xec, 0x84, 0x25, 0x4c, 0x79, + 0x72, 0xe7, 0xc, 0x87, 0x86, 0x4d, 0x72, 0x28, 0x66, 0xf6}; + lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x83, 0x1, 0x54, 0xae, 0xfb, 0x2b, 0x26, 0x56, 0x83, 0x8b, - 0xd9, 0x46, 0x11, 0x97, 0xe4, 0x6a, 0xf7, 0x62, 0xe5}; + uint8_t topic_filter_s4_bytes[] = {0xad, 0x74, 0x0, 0x29, 0xcd, 0xb6, 0x13, 0x18, 0xe6, 0x56, + 0xe3, 0x65, 0xe6, 0x80, 0x3f, 0xb1, 0x31, 0xb3, 0x56}; lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x8a, 0x94, 0xa7, 0x8b, 0x3d, 0xcc, 0x6b, 0x32, 0xa1, 0xb5, 0x2f, 0x92, - 0x30, 0x8d, 0x5d, 0xb5, 0x97, 0x0, 0xd, 0xbc, 0x22, 0xb, 0x84, 0x31}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf7, 0x81, 0xc1, 0x74, 0x4c}; + lwmqtt_string_t topic_filter_s5 = {5, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xca, 0x7d, 0x10, 0x71, 0x50, 0xc, 0xe4, 0x33, 0xc7, 0xa1, - 0x64, 0x4a, 0x6b, 0xd8, 0x8e, 0x58, 0x49, 0x61, 0x70, 0x46, - 0x30, 0x86, 0x5f, 0xcd, 0xc5, 0x8d, 0xf4, 0xde, 0x87}; - lwmqtt_string_t topic_filter_s6 = {29, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x89, 0x79, 0x61, 0x8c, 0x9b, 0x5c, 0x7f, 0xcc, 0x1c, 0xd8, 0xf4, - 0x58, 0x74, 0xbe, 0x0, 0x67, 0xf2, 0xae, 0x97, 0xa0, 0xf3}; - lwmqtt_string_t topic_filter_s7 = {21, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x22, 0x14, 0x23, 0xb3, 0x31, 0x1d, 0x23, 0x42, - 0xa2, 0xa1, 0xf4, 0xac, 0x63, 0x14, 0x26, 0xe1}; - lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xc1, 0x5e, 0xc5, 0xd6, 0x18, 0xf0, 0x9b, 0x76, 0x28, 0x91, - 0xef, 0xae, 0xc9, 0x86, 0xec, 0xe8, 0x6c, 0xb1, 0xa3}; - lwmqtt_string_t topic_filter_s9 = {19, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; + sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = true; sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = true; - uint8_t bytesprops0[] = {0x3b, 0xc, 0xb7, 0x96, 0x3d, 0xed, 0x10, 0xa2, 0x5c, - 0x48, 0x29, 0xb7, 0x5, 0x9d, 0x14, 0xba, 0xe0, 0x30}; + sub_opts[5].no_local = false; + uint8_t bytesprops1[] = {0x0, 0xdc, 0xfd, 0x96, 0xe, 0x7b, 0x5, 0x9a, 0xf, 0x55, 0x4b, 0xf1, 0xd1, 0x2d, 0x8d, 0xb2}; + uint8_t bytesprops0[] = {0x42, 0x2f, 0xc7, 0x56, 0x80, 0x94, 0x94, 0x47, 0x2e, 0x46, 0xf3, 0x9, 0xb6, 0x1a, 0x43}; + uint8_t bytesprops2[] = {0xb9, 0x1d, 0x73, 0xfe, 0x71, 0x45, 0x78, 0x11, 0xf5, 0xe3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20885}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 447}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 28082, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 318, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8250 [("\237(\254^Q",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS1}),("=\197G\215j^\203%xY\252S\159\251\180\234\169\174\246\185\251",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\223H\213n$\254\160\161A\252\180\193Z\219\143",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("=\193w\237l:\149\177\EOT\a\200",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\217k\215\DC3\211\248\152\216\156\139\ETBo\175\246\239\183\DC3&\SYN1G\139\196n\164",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS2})] -// [PropSubscriptionIdentifierAvailable 201,PropRetainAvailable 127,PropReceiveMaximum 3921,PropSessionExpiryInterval -// 14620,PropSessionExpiryInterval 13880,PropWillDelayInterval 25317,PropPayloadFormatIndicator 13,PropTopicAliasMaximum -// 29847,PropMessageExpiryInterval 10331,PropRequestProblemInformation 216,PropPayloadFormatIndicator -// 234,PropMaximumPacketSize 3753,PropMessageExpiryInterval 2418,PropSubscriptionIdentifier -// 6,PropRequestProblemInformation 153,PropPayloadFormatIndicator 236,PropWillDelayInterval 7178,PropServerReference -// "yV\198\185\167n0\RS\178\DELs\221\218\163d\186\128h\150\252\246`\189\133\164\166]\210",PropReceiveMaximum -// 16636,PropPayloadFormatIndicator 119,PropCorrelationData "\FS(WY=\235\139\209f\228\NAK",PropPayloadFormatIndicator -// 0,PropReasonString "",PropReasonString "Iv\173\184O\EM|J\DC3\243\"\255ft4"] +// SubscribeRequest 31558 [("\186\232\r\SYN\DC4\129Eu\DC1]\160\174]",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("]\SO]\180\174O'\150\129\199\150\128\136B\133\198\140\191\138\FS\ETBvk\239\243",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\a0\ACKvKF\251\218J\SUB\ESC\215\200\147\192\231\206\193",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\196\254\198\168\156\215a\242s\210\168\234u\178\ESC\254\160U\214_4U\230&\184\226\GS\156",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0})] +// [PropSubscriptionIdentifier 6,PropSessionExpiryInterval 25639,PropSharedSubscriptionAvailable 240,PropMaximumQoS +// 232,PropReceiveMaximum 25892,PropAuthenticationData "X\128@\138s\145K\ACK\231\&8",PropRequestProblemInformation +// 7,PropSubscriptionIdentifier 20,PropSubscriptionIdentifierAvailable 222,PropRequestProblemInformation +// 228,PropWildcardSubscriptionAvailable 156,PropMaximumQoS 151,PropReasonString +// "\178*\149\218BAZ\SYN\243X\250\155%\159\EMn\214",PropResponseTopic +// "\219\155\169\205\153",PropSubscriptionIdentifierAvailable 57,PropSessionExpiryInterval 12500] TEST(Subscribe5QCTest, Encode8) { - uint8_t pkt[] = {0x82, 0xe2, 0x1, 0x20, 0x3a, 0x82, 0x1, 0x29, 0xc9, 0x25, 0x7f, 0x21, 0xf, 0x51, 0x11, 0x0, 0x0, - 0x39, 0x1c, 0x11, 0x0, 0x0, 0x36, 0x38, 0x18, 0x0, 0x0, 0x62, 0xe5, 0x1, 0xd, 0x22, 0x74, 0x97, - 0x2, 0x0, 0x0, 0x28, 0x5b, 0x17, 0xd8, 0x1, 0xea, 0x27, 0x0, 0x0, 0xe, 0xa9, 0x2, 0x0, 0x0, - 0x9, 0x72, 0xb, 0x6, 0x17, 0x99, 0x1, 0xec,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 0x2a, 0xf0, 0x24, + 0xe8, 0x21, 0x65, 0x24, 0x16, 0x0, 0xa, 0x58, 0x80, 0x40, 0x8a, 0x73, 0x91, 0x4b, 0x6, 0xe7, + 0x38, 0x17, 0x7, 0xb, 0x14, 0x29, 0xde, 0x17, 0xe4, 0x28, 0x9c, 0x24, 0x97, 0x1f, 0x0, 0x11, + 0xb2, 0x2a, 0x95, 0xda, 0x42, 0x41, 0x5a, 0x16, 0xf3, 0x58, 0xfa, 0x9b, 0x25, 0x9f, 0x19, 0x6e, + 0xd6, 0x8, 0x0, 0x5, 0xdb, 0x9b, 0xa9, 0xcd, 0x99, 0x29, 0x39, 0x11, 0x0, 0x0, 0x30, 0xd4, + 0x0, 0xd, 0xba, 0xe8, 0xd, 0x16, 0x14, 0x81, 0x45, 0x75, 0x11, 0x5d, 0xa0, 0xae, 0x5d, 0x4, + 0x0, 0x19, 0x5d, 0xe, 0x5d, 0xb4, 0xae, 0x4f, 0x27, 0x96, 0x81, 0xc7, 0x96, 0x80, 0x88, 0x42, + 0x85, 0xc6, 0x8c, 0xbf, 0x8a, 0x1c, 0x17, 0x76, 0x6b, 0xef, 0xf3, 0x16, 0x0, 0x12, 0x7, 0x30, + 0x6, 0x76, 0x4b, 0x46, 0xfb, 0xda, 0x4a, 0x1a, 0x1b, 0xd7, 0xc8, 0x93, 0xc0, 0xe7, 0xce, 0xc1, + 0xe, 0x0, 0x1c, 0xc4, 0xfe, 0xc6, 0xa8, 0x9c, 0xd7, 0x61, 0xf2, 0x73, 0xd2, 0xa8, 0xea, 0x75, + 0xb2, 0x1b, 0xfe, 0xa0, 0x55, 0xd6, 0x5f, 0x34, 0x55, 0xe6, 0x26, 0xb8, 0xe2, 0x1d, 0x9c, 0x2c}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0xed, 0x28, 0xfe, 0x5e, 0x51}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xba, 0xe8, 0xd, 0x16, 0x14, 0x81, 0x45, 0x75, 0x11, 0x5d, 0xa0, 0xae, 0x5d}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3d, 0xc5, 0x47, 0xd7, 0x6a, 0x5e, 0xcb, 0x25, 0x78, 0x59, 0xfc, - 0x53, 0x9f, 0xfb, 0xb4, 0xea, 0xa9, 0xae, 0xf6, 0xb9, 0xfb}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x5d, 0xe, 0x5d, 0xb4, 0xae, 0x4f, 0x27, 0x96, 0x81, 0xc7, 0x96, 0x80, 0x88, + 0x42, 0x85, 0xc6, 0x8c, 0xbf, 0x8a, 0x1c, 0x17, 0x76, 0x6b, 0xef, 0xf3}; + lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xdf, 0x48, 0xd5, 0x6e, 0x24, 0xfe, 0xa0, 0xa1, - 0x41, 0xfc, 0xb4, 0xc1, 0x5a, 0xdb, 0x8f}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7, 0x30, 0x6, 0x76, 0x4b, 0x46, 0xfb, 0xda, 0x4a, + 0x1a, 0x1b, 0xd7, 0xc8, 0x93, 0xc0, 0xe7, 0xce, 0xc1}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x3d, 0xc1, 0x77, 0xed, 0x6c, 0x3a, 0x95, 0xb1, 0x4, 0x7, 0xc8}; - lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc4, 0xfe, 0xc6, 0xa8, 0x9c, 0xd7, 0x61, 0xf2, 0x73, 0xd2, + 0xa8, 0xea, 0x75, 0xb2, 0x1b, 0xfe, 0xa0, 0x55, 0xd6, 0x5f, + 0x34, 0x55, 0xe6, 0x26, 0xb8, 0xe2, 0x1d, 0x9c}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd9, 0x6b, 0xd7, 0x13, 0xd3, 0xf8, 0x98, 0xd8, 0x9c, 0x8b, 0x17, 0x6f, 0xaf, - 0xf6, 0xef, 0xb7, 0x13, 0x26, 0x16, 0x31, 0x47, 0x8b, 0xc4, 0x6e, 0xa4}; - lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = true; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - uint8_t bytesprops0[] = {0x79, 0x56, 0xc6, 0xb9, 0xa7, 0x6e, 0x30, 0x1e, 0xb2, 0x7f, 0x73, 0xdd, 0xda, 0xa3, - 0x64, 0xba, 0x80, 0x68, 0x96, 0xfc, 0xf6, 0x60, 0xbd, 0x85, 0xa4, 0xa6, 0x5d, 0xd2}; - uint8_t bytesprops1[] = {0x1c, 0x28, 0x57, 0x59, 0x3d, 0xeb, 0x8b, 0xd1, 0x66, 0xe4, 0x15}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x49, 0x76, 0xad, 0xb8, 0x4f, 0x19, 0x7c, 0x4a, 0x13, 0xf3, 0x22, 0xff, 0x66, 0x74, 0x34}; + uint8_t bytesprops0[] = {0x58, 0x80, 0x40, 0x8a, 0x73, 0x91, 0x4b, 0x6, 0xe7, 0x38}; + uint8_t bytesprops1[] = {0xb2, 0x2a, 0x95, 0xda, 0x42, 0x41, 0x5a, 0x16, 0xf3, + 0x58, 0xfa, 0x9b, 0x25, 0x9f, 0x19, 0x6e, 0xd6}; + uint8_t bytesprops2[] = {0xdb, 0x9b, 0xa9, 0xcd, 0x99}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 201}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3921}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 14620}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13880}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 25317}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29847}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10331}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 234}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 3753}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2418}}, {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7178}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16636}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 25639}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 232}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 25892}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {10, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 228}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 151}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 57}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 12500}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8250, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 31558, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 2359 [("\EM\174:\184\155\&9\131\194\148",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropSharedSubscriptionAvailable -// 213,PropPayloadFormatIndicator 45,PropRequestProblemInformation 15,PropResponseInformation -// "2Z\216W7\DLEa\ESC4r\DC4h`\EOT\157\&4*Y\181\159\151\201P\152\SYN\245ke",PropTopicAlias 17577,PropMaximumQoS -// 139,PropMessageExpiryInterval 13699,PropRequestResponseInformation 147,PropSubscriptionIdentifierAvailable -// 7,PropSubscriptionIdentifier 25,PropRetainAvailable 108,PropSubscriptionIdentifierAvailable 214,PropContentType -// "M",PropSubscriptionIdentifier 4,PropWildcardSubscriptionAvailable 226,PropReceiveMaximum -// 9422,PropAuthenticationMethod "\242\SO\a\EM",PropWillDelayInterval 26420,PropResponseInformation -// "\\\b(<\201\190\229_\152",PropMessageExpiryInterval 18588,PropAuthenticationData -// "\147\150\&7\241\182\197\209",PropReasonString -// "6\184\&3\145\152\193\242\139\128\201S\224\&9",PropAssignedClientIdentifier -// "\ESC\164\SOH\245\249\197\255\DC3b\155\199\132.",PropWildcardSubscriptionAvailable 76,PropContentType -// "\233\t\166",PropSubscriptionIdentifierAvailable 84,PropMessageExpiryInterval 3926,PropCorrelationData -// "H\172\172\&2\159\\\ETX\164\NAKhc\251\220\206\183 \151\252\140]\166\196",PropTopicAliasMaximum 5271] +// SubscribeRequest 10059 [("cF\140\DC1z\250\a\232\178\255\221\154\NUL\134\244",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\172J\178\137\215\158\178n\196\166\\$a\"\143GH\CANW\134Se\bs\162z\153\v",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\146\169\&0\151\152\139\133\211\188\241\SUB\DC2N)\139\165\150",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\243\168\&6\166",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("G\245\200\151Cv\222\205\151\133\243",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished +// = True, _noLocal = True, _subQoS = QoS1}),("\135oO\NUL\183j-",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("Y;d\189L\226\200\163\134\156\180\242\218(\DC4\254\238\144 ",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropServerKeepAlive 12247,PropPayloadFormatIndicator +// 117,PropRetainAvailable 183,PropWildcardSubscriptionAvailable 146,PropServerReference +// "\RS\248\183\186\152a\177G\250s\250\195`\171\&7\148+2)1_\ESCf$Lr",PropReasonString +// "y\215\162\t\150\254\STX\223\170\197\FS\a\173>k\181O\142\174\148\237\&62\176wA\197:",PropPayloadFormatIndicator +// 156,PropUserProperty "\DC2\243\162\232y\233\178f\176\DC3\133\145\222\140T\136" +// "\205\&7\196\189H_\208\169\t\191>\n\151\188%\150\150Z\176\194\152",PropSubscriptionIdentifier +// 6,PropSharedSubscriptionAvailable 135,PropAuthenticationData +// "wg\172\&4J\141\254yr\DC4dH\a\132\227\143[\NAK-\179\243",PropServerReference +// "\207W\206\212\166-E\168\&3\170h\142\228\202",PropUserProperty +// "wu\128\131\173Z\187/\234\180\128-r\156\197\142\136\224 \160}J" "\216\DC1\164fC",PropAssignedClientIdentifier +// "\CAN\215\158\156a\205\CAN8q\155\157?\138\186\142\DEL\ENQ\224`\DLEf?\RSh~\206\239\\\214\251",PropRetainAvailable +// 251,PropWillDelayInterval 20547,PropSharedSubscriptionAvailable 206,PropServerKeepAlive 17138,PropTopicAliasMaximum +// 29125,PropMessageExpiryInterval 31816,PropResponseInformation +// "{\189*\234ZY\SUB\232\130\GS\216\239\177\159\245\188\186\235\153\184\177\223\CAN\169\218AvH\186\170",PropWildcardSubscriptionAvailable +// 8,PropMaximumPacketSize 8949,PropReceiveMaximum 7552,PropPayloadFormatIndicator 78,PropContentType +// "\SYN&7\213{\193q\153\184X*\194\148\237\211=",PropTopicAliasMaximum 1554,PropRequestProblemInformation 28] TEST(Subscribe5QCTest, Encode9) { - uint8_t pkt[] = {0x82, 0xc6, 0x1, 0x9, 0x37, 0xb6, 0x1, 0x2a, 0xd5, 0x1, 0x2d, 0x17, 0xf, 0x1a, 0x0, 0x1c, 0x32, - 0x5a, 0xd8, 0x57, 0x37, 0x10, 0x61, 0x1b, 0x34, 0x72, 0x14, 0x68, 0x60, 0x4, 0x9d, 0x34, 0x2a, 0x59, - 0xb5, 0x9f, 0x97, 0xc9, 0x50, 0x98, 0x16, 0xf5, 0x6b, 0x65, 0x23, 0x44, 0xa9, 0x24, 0x8b, 0x2, 0x0, - 0x0, 0x35, 0x83, 0x19, 0x93, 0x29, 0x7, 0xb, 0x19, 0x25, 0x6c, 0x29, 0xd6, 0x3, 0x0, 0x1, 0x4d, - 0xb, 0x4, 0x28, 0xe2, 0x21, 0x24, 0xce, 0x15, 0x0, 0x4, 0xf2, 0xe, 0x7, 0x19, 0x18, 0x0, 0x0, - 0x67, 0x34, 0x1a, 0x0, 0x9, 0x5c, 0x8, 0x28, 0x3c, 0xc9, 0xbe, 0xe5, 0x5f, 0x98, 0x2, 0x0, 0x0, - 0x48, 0x9c, 0x16, 0x0, 0x7, 0x93, 0x96, 0x37, 0xf1, 0xb6, 0xc5, 0xd1, 0x1f, 0x0, 0xd, 0x36, 0xb8, - 0x33, 0x91, 0x98, 0xc1, 0xf2, 0x8b, 0x80, 0xc9, 0x53, 0xe0, 0x39, 0x12, 0x0, 0xd, 0x1b, 0xa4, 0x1, - 0xf5, 0xf9, 0xc5, 0xff, 0x13, 0x62, 0x9b, 0xc7, 0x84, 0x2e, 0x28, 0x4c, 0x3, 0x0, 0x3, 0xe9, 0x9, - 0xa6, 0x29, 0x54, 0x2, 0x0, 0x0, 0xf, 0x56, 0x9, 0x0, 0x16, 0x48, 0xac, 0xac, 0x32, 0x9f, 0x5c, - 0x3, 0xa4, 0x15, 0x68, 0x63, 0xfb, 0xdc, 0xce, 0xb7, 0x20, 0x97, 0xfc, 0x8c, 0x5d, 0xa6, 0xc4, 0x22, - 0x14, 0x97, 0x0, 0x9, 0x19, 0xae, 0x3a, 0xb8, 0x9b, 0x39, 0x83, 0xc2, 0x94, 0x24}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0x19, 0xae, 0x3a, 0xb8, 0x9b, 0x39, 0x83, 0xc2, 0x94}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; - topic_filters[0] = topic_filter_s0; - lwmqtt_sub_options_t sub_opts[1]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - uint8_t bytesprops0[] = {0x32, 0x5a, 0xd8, 0x57, 0x37, 0x10, 0x61, 0x1b, 0x34, 0x72, 0x14, 0x68, 0x60, 0x4, - 0x9d, 0x34, 0x2a, 0x59, 0xb5, 0x9f, 0x97, 0xc9, 0x50, 0x98, 0x16, 0xf5, 0x6b, 0x65}; - uint8_t bytesprops1[] = {0x4d}; - uint8_t bytesprops2[] = {0xf2, 0xe, 0x7, 0x19}; - uint8_t bytesprops3[] = {0x5c, 0x8, 0x28, 0x3c, 0xc9, 0xbe, 0xe5, 0x5f, 0x98}; - uint8_t bytesprops4[] = {0x93, 0x96, 0x37, 0xf1, 0xb6, 0xc5, 0xd1}; - uint8_t bytesprops5[] = {0x36, 0xb8, 0x33, 0x91, 0x98, 0xc1, 0xf2, 0x8b, 0x80, 0xc9, 0x53, 0xe0, 0x39}; - uint8_t bytesprops6[] = {0x1b, 0xa4, 0x1, 0xf5, 0xf9, 0xc5, 0xff, 0x13, 0x62, 0x9b, 0xc7, 0x84, 0x2e}; - uint8_t bytesprops7[] = {0xe9, 0x9, 0xa6}; - uint8_t bytesprops8[] = {0x48, 0xac, 0xac, 0x32, 0x9f, 0x5c, 0x3, 0xa4, 0x15, 0x68, 0x63, - 0xfb, 0xdc, 0xce, 0xb7, 0x20, 0x97, 0xfc, 0x8c, 0x5d, 0xa6, 0xc4}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 213}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 15}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17577}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13699}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 25}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 108}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 4}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9422}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26420}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18588}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 76}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 84}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3926}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5271}}, - }; - - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2359, 1, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 16794 [("K\236r=\152\194\134Z}\181\&3:\143\143u\164\DC1\208\150\146\248\ETB",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\RS\SUB\bJ\131u",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = -// True, _subQoS = QoS1}),("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = -// False, _subQoS = QoS0}),("\195J\198\164\135",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = -// True, _noLocal = True, _subQoS = QoS0}),("\188\161\156\135\DEL\148\RS\249@\DC3\187",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\216mP\206\&1\135\r\155\237\&0\DC4R\175$\254h\NAKN\f",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropAssignedClientIdentifier -// "",PropMessageExpiryInterval 18708,PropContentType -// "F1\ETXrk]@\239\211(\SOH\235\143\DC2\ESCiSucsM\184\161$",PropReceiveMaximum 15395,PropServerReference -// "\181\182/\141L\140\237K\DC2\138\183\NAK\193\&7\132\139k\165\213\151",PropMessageExpiryInterval 5921,PropContentType -// "g\197\204z*\206\186\141\195ln\DLE\190m\DC2\235\213",PropResponseInformation -// "\240\FS,\135\203yI\146e\160\133\190",PropRequestProblemInformation 70,PropSessionExpiryInterval 10978,PropMaximumQoS -// 128,PropMaximumQoS 111] -TEST(Subscribe5QCTest, Encode10) { - uint8_t pkt[] = {0x82, 0xc4, 0x1, 0x41, 0x9a, 0x70, 0x12, 0x0, 0x0, 0x2, 0x0, 0x0, 0x49, 0x14, 0x3, 0x0, 0x18, - 0x46, 0x31, 0x3, 0x72, 0x6b, 0x5d, 0x40, 0xef, 0xd3, 0x28, 0x1, 0xeb, 0x8f, 0x12, 0x1b, 0x69, 0x53, - 0x75, 0x63, 0x73, 0x4d, 0xb8, 0xa1, 0x24, 0x21, 0x3c, 0x23, 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97, 0x43, 0x76, 0xde, 0xcd, 0x97, 0x85, 0xf3, 0x2d, 0x0, 0x7, 0x87, 0x6f, 0x4f, 0x0, 0xb7, 0x6a, 0x2d, + 0x12, 0x0, 0x13, 0x59, 0x3b, 0x64, 0xbd, 0x4c, 0xe2, 0xc8, 0xa3, 0x86, 0x9c, 0xb4, 0xf2, 0xda, 0x28, 0x14, 0xfe, + 0xee, 0x90, 0x20, 0xd}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x4b, 0xec, 0x72, 0x3d, 0x98, 0xc2, 0x86, 0x5a, 0x7d, 0xb5, 0x33, - 0x3a, 0x8f, 0x8f, 0x75, 0xa4, 0x11, 0xd0, 0x96, 0x92, 0xf8, 0x17}; - lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x63, 0x46, 0x8c, 0x11, 0x7a, 0xfa, 0x7, 0xe8, + 0xb2, 0xff, 0xdd, 0x9a, 0x0, 0x86, 0xf4}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x1e, 0x1a, 0x8, 0x4a, 0x83, 0x75}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xac, 0x4a, 0xb2, 0x89, 0xd7, 0x9e, 0xb2, 0x6e, 0xc4, 0xa6, 0x5c, 0x24, 0x61, 0x22, + 0x8f, 0x47, 0x48, 0x18, 0x57, 0x86, 0x53, 0x65, 0x8, 0x73, 0xa2, 0x7a, 0x99, 0xb}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x92, 0xa9, 0x30, 0x97, 0x98, 0x8b, 0x85, 0xd3, 0xbc, + 0xf1, 0x1a, 0x12, 0x4e, 0x29, 0x8b, 0xa5, 0x96}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc3, 0x4a, 0xc6, 0xa4, 0x87}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf3, 0xa8, 0x36, 0xa6}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xbc, 0xa1, 0x9c, 0x87, 0x7f, 0x94, 0x1e, 0xf9, 0x40, 0x13, 0xbb}; + uint8_t topic_filter_s4_bytes[] = {0x47, 0xf5, 0xc8, 0x97, 0x43, 0x76, 0xde, 0xcd, 0x97, 0x85, 0xf3}; lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xd8, 0x6d, 0x50, 0xce, 0x31, 0x87, 0xd, 0x9b, 0xed, 0x30, - 0x14, 0x52, 0xaf, 0x24, 0xfe, 0x68, 0x15, 0x4e, 0xc}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x87, 0x6f, 0x4f, 0x0, 0xb7, 0x6a, 0x2d}; + lwmqtt_string_t topic_filter_s5 = {7, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - lwmqtt_sub_options_t sub_opts[6]; + uint8_t topic_filter_s6_bytes[] = {0x59, 0x3b, 0x64, 0xbd, 0x4c, 0xe2, 0xc8, 0xa3, 0x86, 0x9c, + 0xb4, 0xf2, 0xda, 0x28, 0x14, 0xfe, 0xee, 0x90, 0x20}; + lwmqtt_string_t topic_filter_s6 = {19, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + lwmqtt_sub_options_t sub_opts[7]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[2].retain_as_published = true; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = true; + sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].qos = LWMQTT_QOS1; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = true; sub_opts[5].qos = LWMQTT_QOS2; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = true; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x46, 0x31, 0x3, 0x72, 0x6b, 0x5d, 0x40, 0xef, 0xd3, 0x28, 0x1, 0xeb, - 0x8f, 0x12, 0x1b, 0x69, 0x53, 0x75, 0x63, 0x73, 0x4d, 0xb8, 0xa1, 0x24}; - uint8_t bytesprops2[] = {0xb5, 0xb6, 0x2f, 0x8d, 0x4c, 0x8c, 0xed, 0x4b, 0x12, 0x8a, - 0xb7, 0x15, 0xc1, 0x37, 0x84, 0x8b, 0x6b, 0xa5, 0xd5, 0x97}; - uint8_t bytesprops3[] = {0x67, 0xc5, 0xcc, 0x7a, 0x2a, 0xce, 0xba, 0x8d, 0xc3, - 0x6c, 0x6e, 0x10, 0xbe, 0x6d, 0x12, 0xeb, 0xd5}; - uint8_t bytesprops4[] = {0xf0, 0x1c, 0x2c, 0x87, 0xcb, 0x79, 0x49, 0x92, 0x65, 0xa0, 0x85, 0xbe}; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = true; + uint8_t bytesprops0[] = {0x1e, 0xf8, 0xb7, 0xba, 0x98, 0x61, 0xb1, 0x47, 0xfa, 0x73, 0xfa, 0xc3, 0x60, + 0xab, 0x37, 0x94, 0x2b, 0x32, 0x29, 0x31, 0x5f, 0x1b, 0x66, 0x24, 0x4c, 0x72}; + uint8_t bytesprops1[] = {0x79, 0xd7, 0xa2, 0x9, 0x96, 0xfe, 0x2, 0xdf, 0xaa, 0xc5, 0x1c, 0x7, 0xad, 0x3e, + 0x6b, 0xb5, 0x4f, 0x8e, 0xae, 0x94, 0xed, 0x36, 0x32, 0xb0, 0x77, 0x41, 0xc5, 0x3a}; + uint8_t bytesprops3[] = {0xcd, 0x37, 0xc4, 0xbd, 0x48, 0x5f, 0xd0, 0xa9, 0x9, 0xbf, 0x3e, + 0xa, 0x97, 0xbc, 0x25, 0x96, 0x96, 0x5a, 0xb0, 0xc2, 0x98}; + uint8_t bytesprops2[] = {0x12, 0xf3, 0xa2, 0xe8, 0x79, 0xe9, 0xb2, 0x66, + 0xb0, 0x13, 0x85, 0x91, 0xde, 0x8c, 0x54, 0x88}; + uint8_t bytesprops4[] = {0x77, 0x67, 0xac, 0x34, 0x4a, 0x8d, 0xfe, 0x79, 0x72, 0x14, 0x64, + 0x48, 0x7, 0x84, 0xe3, 0x8f, 0x5b, 0x15, 0x2d, 0xb3, 0xf3}; + uint8_t bytesprops5[] = {0xcf, 0x57, 0xce, 0xd4, 0xa6, 0x2d, 0x45, 0xa8, 0x33, 0xaa, 0x68, 0x8e, 0xe4, 0xca}; + uint8_t bytesprops7[] = {0xd8, 0x11, 0xa4, 0x66, 0x43}; + uint8_t bytesprops6[] = {0x77, 0x75, 0x80, 0x83, 0xad, 0x5a, 0xbb, 0x2f, 0xea, 0xb4, 0x80, + 0x2d, 0x72, 0x9c, 0xc5, 0x8e, 0x88, 0xe0, 0x20, 0xa0, 0x7d, 0x4a}; + uint8_t bytesprops8[] = {0x18, 0xd7, 0x9e, 0x9c, 0x61, 0xcd, 0x18, 0x38, 0x71, 0x9b, 0x9d, 0x3f, 0x8a, 0xba, 0x8e, + 0x7f, 0x5, 0xe0, 0x60, 0x10, 0x66, 0x3f, 0x1e, 0x68, 0x7e, 0xce, 0xef, 0x5c, 0xd6, 0xfb}; + uint8_t bytesprops9[] = {0x7b, 0xbd, 0x2a, 0xea, 0x5a, 0x59, 0x1a, 0xe8, 0x82, 0x1d, 0xd8, 0xef, 0xb1, 0x9f, 0xf5, + 0xbc, 0xba, 0xeb, 0x99, 0xb8, 0xb1, 0xdf, 0x18, 0xa9, 0xda, 0x41, 0x76, 0x48, 0xba, 0xaa}; + uint8_t bytesprops10[] = {0x16, 0x26, 0x37, 0xd5, 0x7b, 0xc1, 0x71, 0x99, + 0xb8, 0x58, 0x2a, 0xc2, 0x94, 0xed, 0xd3, 0x3d}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18708}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15395}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5921}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10978}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 111}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12247}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 183}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops2}, .v = {21, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops6}, .v = {5, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 251}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20547}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17138}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29125}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31816}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {30, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8949}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7552}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1554}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 28}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16794, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10059, 7, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9525 [("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("Y",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = -// False, _subQoS = QoS0}),("yTU\212\STX\n0g\ETB\216;\193\141^of\176\131l\247\243\175\226W!\218\226\143&Y",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\129",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2}),("\158\142\237\223\DEL\238TE#\174\&4\RS\247x\152d\195\167u\246\255\201\167\162=\206-",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\169\195$\148J\198r\134D\151\160\STX%j\191\201\209\170\156t\r\244k\183\198",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("\DC4&y\247\168\&1W\NUL\245\&6\237\210\150i",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("cQ_y\200\249",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\STX\217 \170>\EM",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\STX\135*",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, -// _subQoS = QoS0}),("]\141\210\RS\186\238\n\ESC\GSj\131\174\190;\136\207Ofzf'",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] -// [PropWildcardSubscriptionAvailable 205,PropMessageExpiryInterval 18112,PropReceiveMaximum -// 22374,PropPayloadFormatIndicator 97,PropReasonString -// "D:\165\232\200\&4\239=\222\147\149Ck\207\228\130\SOHi\253\161q8\223p\FS\133\SO\156\181\159"] -TEST(Subscribe5QCTest, Encode11) { - uint8_t pkt[] = {0x82, 0xd7, 0x1, 0x25, 0x35, 0x2d, 0x28, 0xcd, 0x2, 0x0, 0x0, 0x46, 0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x1e, 0xba, 0xee, 0xa, 0x1b, - 0x1d, 0x6a, 0x83, 0xae, 0xbe, 0x3b, 0x88, 0xcf, 0x4f, 0x66, 0x7a, 0x66, 0x27, 0x28}; +// SubscribeRequest 17993 [("\174\DC2\180\NUL\142x\203\205\&8\EM\171\148\&3tuFu$\128",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\157\230\179\155\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = +// True, _subQoS = QoS2}),("\176\146\RS\217\&9zmS\US\159\223ODO\200>\166\vR",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\161@\171\&2\220\208\169\DC1\214\171\191",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("Q\129\191)\186o\207\155\&4C\134,A;\188i\194^\"]r",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("]CN4\DEL\254S\162\235\148\193\251\183",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("\194c\DC4",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, +// _subQoS = QoS1}),("c\202\169\191\144\165\DC2%\SYN&\SOH\145\184\228\220\227\185]\163T\187D\253\DC2-\169C",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\195\212\131",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, +// _subQoS = QoS0})] [PropAssignedClientIdentifier "\194",PropResponseTopic +// "vq\253\145\245\205",PropSubscriptionIdentifier 16,PropReasonString +// "\vu\151A\163\245\FS\156\172\170\\\144\145\218mvD\131\252",PropResponseTopic "\151aL",PropPayloadFormatIndicator +// 116,PropAuthenticationData "\ETX\221",PropSharedSubscriptionAvailable 91,PropTopicAlias +// 11087,PropAssignedClientIdentifier "\242\246\248\235\138\198\ETX\152\NUL\151O\"\130\STXG\172\221",PropServerKeepAlive +// 7955,PropMessageExpiryInterval 24117,PropMaximumPacketSize 1501,PropCorrelationData +// "\186O\239\194\234\211\173BT\198",PropResponseInformation +// "\224\239\201\208N\DLE\RS6\155M\200@\175\230\143",PropResponseInformation +// "\156\v\134\243H\228\178,",PropReceiveMaximum 29967,PropServerKeepAlive 30373,PropAssignedClientIdentifier +// "\STX\223FsUx\151&\220 \150\255\214\\\169v>",PropServerReference "\135",PropAuthenticationMethod +// "\185\"\184\&3\NAK",PropReceiveMaximum 1529,PropSubscriptionIdentifier 30,PropSessionExpiryInterval +// 3694,PropServerReference "\164\233\167'\224",PropMaximumPacketSize 20632,PropSessionExpiryInterval +// 13047,PropAuthenticationMethod "6\218\191\\\131\CAN?7[h",PropResponseTopic "T"] +TEST(Subscribe5QCTest, Encode10) { + uint8_t pkt[] = { + 0x82, 0xed, 0x2, 0x46, 0x49, 0xd5, 0x1, 0x12, 0x0, 0x1, 0xc2, 0x8, 0x0, 0x6, 0x76, 0x71, 0xfd, 0x91, 0xf5, + 0xcd, 0xb, 0x10, 0x1f, 0x0, 0x13, 0xb, 0x75, 0x97, 0x41, 0xa3, 0xf5, 0x1c, 0x9c, 0xac, 0xaa, 0x5c, 0x90, 0x91, + 0xda, 0x6d, 0x76, 0x44, 0x83, 0xfc, 0x8, 0x0, 0x3, 0x97, 0x61, 0x4c, 0x1, 0x74, 0x16, 0x0, 0x2, 0x3, 0xdd, + 0x2a, 0x5b, 0x23, 0x2b, 0x4f, 0x12, 0x0, 0x11, 0xf2, 0xf6, 0xf8, 0xeb, 0x8a, 0xc6, 0x3, 0x98, 0x0, 0x97, 0x4f, + 0x22, 0x82, 0x2, 0x47, 0xac, 0xdd, 0x13, 0x1f, 0x13, 0x2, 0x0, 0x0, 0x5e, 0x35, 0x27,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d0, 0xa9, 0x11, 0xd6, 0xab, 0xbf, + 0x10, 0x0, 0x15, 0x51, 0x81, 0xbf, 0x29, 0xba, 0x6f, 0xcf, 0x9b, 0x34, 0x43, 0x86, 0x2c, 0x41, 0x3b, 0xbc, 0x69, + 0xc2, 0x5e, 0x22, 0x5d, 0x72, 0x1e, 0x0, 0xd, 0x5d, 0x43, 0x4e, 0x34, 0x7f, 0xfe, 0x53, 0xa2, 0xeb, 0x94, 0xc1, + 0xfb, 0xb7, 0x2e, 0x0, 0x3, 0xc2, 0x63, 0x14, 0x9, 0x0, 0x1b, 0x63, 0xca, 0xa9, 0xbf, 0x90, 0xa5, 0x12, 0x25, + 0x16, 0x26, 0x1, 0x91, 0xb8, 0xe4, 0xdc, 0xe3, 0xb9, 0x5d, 0xa3, 0x54, 0xbb, 0x44, 0xfd, 0x12, 0x2d, 0xa9, 0x43, + 0x1d, 0x0, 0x3, 0xc3, 0xd4, 0x83, 0x4}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0}; - lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0xae, 0x12, 0xb4, 0x0, 0x8e, 0x78, 0xcb, 0xcd, 0x38, 0x19, + 0xab, 0x94, 0x33, 0x74, 0x75, 0x46, 0x75, 0x24, 0x80}; + lwmqtt_string_t topic_filter_s0 = {19, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x59}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9d, 0xe6, 0xb3, 0x9b, 0xb8}; + lwmqtt_string_t topic_filter_s1 = {5, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x79, 0x54, 0x55, 0xd4, 0x2, 0xa, 0x30, 0x67, 0x17, 0xd8, - 0x3b, 0xc1, 0x8d, 0x5e, 0x6f, 0x66, 0xb0, 0x83, 0x6c, 0xf7, - 0xf3, 0xaf, 0xe2, 0x57, 0x21, 0xda, 0xe2, 0x8f, 0x26, 0x59}; - lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb0, 0x92, 0x1e, 0xd9, 0x39, 0x7a, 0x6d, 0x53, 0x1f, 0x9f, + 0xdf, 0x4f, 0x44, 0x4f, 0xc8, 0x3e, 0xa6, 0xb, 0x52}; + lwmqtt_string_t topic_filter_s2 = {19, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x81}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa1, 0x40, 0xab, 0x32, 0xdc, 0xd0, 0xa9, 0x11, 0xd6, 0xab, 0xbf}; + lwmqtt_string_t topic_filter_s3 = {11, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x9e, 0x8e, 0xed, 0xdf, 0x7f, 0xee, 0x54, 0x45, 0x23, 0xae, 0x34, 0x1e, 0xf7, 0x78, - 0x98, 0x64, 0xc3, 0xa7, 0x75, 0xf6, 0xff, 0xc9, 0xa7, 0xa2, 0x3d, 0xce, 0x2d}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x51, 0x81, 0xbf, 0x29, 0xba, 0x6f, 0xcf, 0x9b, 0x34, 0x43, 0x86, + 0x2c, 0x41, 0x3b, 0xbc, 0x69, 0xc2, 0x5e, 0x22, 0x5d, 0x72}; + lwmqtt_string_t topic_filter_s4 = {21, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa9, 0xc3, 0x24, 0x94, 0x4a, 0xc6, 0x72, 0x86, 0x44, 0x97, 0xa0, 0x2, 0x25, - 0x6a, 0xbf, 0xc9, 0xd1, 0xaa, 0x9c, 0x74, 0xd, 0xf4, 0x6b, 0xb7, 0xc6}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x5d, 0x43, 0x4e, 0x34, 0x7f, 0xfe, 0x53, 0xa2, 0xeb, 0x94, 0xc1, 0xfb, 0xb7}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x14, 0x26, 0x79, 0xf7, 0xa8, 0x31, 0x57, 0x0, 0xf5, 0x36, 0xed, 0xd2, 0x96, 0x69}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xc2, 0x63, 0x14}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x63, 0x51, 0x5f, 0x79, 0xc8, 0xf9}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x63, 0xca, 0xa9, 0xbf, 0x90, 0xa5, 0x12, 0x25, 0x16, 0x26, 0x1, 0x91, 0xb8, 0xe4, + 0xdc, 0xe3, 0xb9, 0x5d, 0xa3, 0x54, 0xbb, 0x44, 0xfd, 0x12, 0x2d, 0xa9, 0x43}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x2, 0xd9, 0x20, 0xaa, 0x3e, 0x19}; - lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xc3, 0xd4, 0x83}; + lwmqtt_string_t topic_filter_s8 = {3, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x2, 0x87, 0x2a}; - lwmqtt_string_t topic_filter_s9 = {3, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x5d, 0x8d, 0xd2, 0x1e, 0xba, 0xee, 0xa, 0x1b, 0x1d, 0x6a, 0x83, - 0xae, 0xbe, 0x3b, 0x88, 0xcf, 0x4f, 0x66, 0x7a, 0x66, 0x27}; - lwmqtt_string_t topic_filter_s10 = {21, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; + lwmqtt_sub_options_t sub_opts[9]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[1].no_local = true; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; + sub_opts[6].qos = LWMQTT_QOS1; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = true; + sub_opts[6].no_local = false; sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[7].retain_as_published = true; sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS0; - sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[10].retain_as_published = true; - sub_opts[10].no_local = false; - uint8_t bytesprops0[] = {0x44, 0x3a, 0xa5, 0xe8, 0xc8, 0x34, 0xef, 0x3d, 0xde, 0x93, 0x95, 0x43, 0x6b, 0xcf, 0xe4, - 0x82, 0x1, 0x69, 0xfd, 0xa1, 0x71, 0x38, 0xdf, 0x70, 0x1c, 0x85, 0xe, 0x9c, 0xb5, 0x9f}; + sub_opts[8].no_local = true; + uint8_t bytesprops0[] = {0xc2}; + uint8_t bytesprops1[] = {0x76, 0x71, 0xfd, 0x91, 0xf5, 0xcd}; + uint8_t bytesprops2[] = {0xb, 0x75, 0x97, 0x41, 0xa3, 0xf5, 0x1c, 0x9c, 0xac, 0xaa, + 0x5c, 0x90, 0x91, 0xda, 0x6d, 0x76, 0x44, 0x83, 0xfc}; + uint8_t bytesprops3[] = {0x97, 0x61, 0x4c}; + uint8_t bytesprops4[] = {0x3, 0xdd}; + uint8_t bytesprops5[] = {0xf2, 0xf6, 0xf8, 0xeb, 0x8a, 0xc6, 0x3, 0x98, 0x0, + 0x97, 0x4f, 0x22, 0x82, 0x2, 0x47, 0xac, 0xdd}; + uint8_t bytesprops6[] = {0xba, 0x4f, 0xef, 0xc2, 0xea, 0xd3, 0xad, 0x42, 0x54, 0xc6}; + uint8_t bytesprops7[] = {0xe0, 0xef, 0xc9, 0xd0, 0x4e, 0x10, 0x1e, 0x36, 0x9b, 0x4d, 0xc8, 0x40, 0xaf, 0xe6, 0x8f}; + uint8_t bytesprops8[] = {0x9c, 0xb, 0x86, 0xf3, 0x48, 0xe4, 0xb2, 0x2c}; + uint8_t bytesprops9[] = {0x2, 0xdf, 0x46, 0x73, 0x55, 0x78, 0x97, 0x26, 0xdc, + 0x20, 0x96, 0xff, 0xd6, 0x5c, 0xa9, 0x76, 0x3e}; + uint8_t bytesprops10[] = {0x87}; + uint8_t bytesprops11[] = {0xb9, 0x22, 0xb8, 0x33, 0x15}; + uint8_t bytesprops12[] = {0xa4, 0xe9, 0xa7, 0x27, 0xe0}; + uint8_t bytesprops13[] = {0x36, 0xda, 0xbf, 0x5c, 0x83, 0x18, 0x3f, 0x37, 0x5b, 0x68}; + uint8_t bytesprops14[] = {0x54}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18112}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22374}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 91}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 11087}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7955}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24117}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 1501}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 29967}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30373}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {1, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 1529}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3694}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20632}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 13047}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops14}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9525, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17993, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 25695 [("",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal -// = True, _subQoS = QoS2}),("\186\219\215",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = False, _subQoS = QoS0}),("\201bK\187'\a\ENQ\157\250\DLE",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("X\223\196\156",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\244hB>\204s -// 1\US\233\145\133\178:\129\154\238z\SYN\152-\244tq\DC1\146",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\EOT\188\214C\158\190\234\ETBt\229\GSR\139N\217\SO\240\245\ENQ\173G;\153@\183",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("W406\252\156\\\212\&3\b\203$\187\247\DC2\235\v\134\181\231",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\191\ESC+\"q",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("!\138\RS@\137\CANP!\SOH]\f\250\244\251h\232\242\241\241\218",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\STX\134\223\174XA\133.\245g\FS~\224\173\r\158\EOT\165\NAK",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] [PropContentType -// "13\214}\186\247\170\vg}",PropSharedSubscriptionAvailable 57,PropReceiveMaximum 1860,PropRequestResponseInformation -// 201,PropServerKeepAlive 31340,PropTopicAliasMaximum 14073,PropRequestProblemInformation 46,PropSessionExpiryInterval -// 7295,PropCorrelationData "\143\&5\135w\134\SOH\211v\141\132\202\187%s\140",PropServerReference -// "\DC1\215\170\&9d\155z\225",PropMessageExpiryInterval 6877,PropServerReference -// "\240Q/",PropSharedSubscriptionAvailable 143,PropSharedSubscriptionAvailable 239,PropServerReference -// "\rwMl\152\198h\219\175\148j\198M\244\EOT\227H}\210",PropReceiveMaximum 26293,PropCorrelationData -// "\241n\226\&0\250e\SOH\165\195\255",PropWillDelayInterval 24693,PropAuthenticationData -// "v\NAKa\240h\162q\nM\192\252\f{\178\b\a@v\131\215\152f",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("Q\231s7H\ENQ#\143o\a\251\STXW\201\177\196{",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("$\142\140\198",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropContentType +// "Wx\137\138\149\213 MO\222\STX\180\209'\134\&3",PropTopicAlias 16280,PropMaximumPacketSize +// 32255,PropTopicAliasMaximum 28531,PropAssignedClientIdentifier +// "\198\219\DC1\214\133\142U",PropSharedSubscriptionAvailable 135,PropUserProperty +// "P\204\216IY\ETX\196I)\166\243\243\207\191g\227\STXSL%\tF\199S\205\204b" +// "\219\&0\241@\GSN9\142B>\242=\152T\240\161\168",PropMaximumPacketSize 18181,PropMaximumPacketSize +// 19439,PropCorrelationData "^\154\173\DC2\148\144\193-a\148x.\DC3\246\162N\SYN\ESC\133",PropMaximumQoS +// 119,PropMaximumQoS 19,PropServerKeepAlive 30628,PropRequestProblemInformation 190,PropServerKeepAlive +// 23203,PropAssignedClientIdentifier "\136r\160t",PropRetainAvailable 240,PropSessionExpiryInterval +// 1968,PropReasonString "7s\210b\252\DEL\147\150\FSp\244\&8%",PropServerKeepAlive 1701,PropResponseInformation +// "\200$\135\220",PropReasonString +// "\FS\218\249D\SI\211\SYN\ACKs\182]\133\171\213\194}\STX\142\208",PropAssignedClientIdentifier +// "9g\132\&6\142\191\233\162AP\176\181\141\179\&8\142HC@\DC3\RS",PropMessageExpiryInterval +// 26022,PropPayloadFormatIndicator 18,PropAuthenticationData +// "1\196\239\194\213\EM-\228\197\SI]\183O\189\255Iwsy",PropWildcardSubscriptionAvailable 197,PropSubscriptionIdentifier +// 11,PropResponseTopic +// "?'\232\v4\213\SYN\171\191\EOT\163_\ACK\135v\DC4\SYN\158u\DEL:\235\ETX\EME\194\&2G",PropServerReference +// "N\DC2\243n\192a+\172t3B@m,h\SUB\248\225Kt\bv\238\254FY\164'"] +TEST(Subscribe5QCTest, Encode13) { + uint8_t pkt[] = { + 0x82, 0xfb, 0x2, 0x32, 0x13, 0xbc, 0x2, 0x3, 0x0, 0x10, 0x57, 0x78, 0x89, 0x8a, 0x95, 0xd5, 0x20, 0x4d, 0x4f, + 0xde, 0x2, 0xb4, 0xd1, 0x27, 0x86, 0x33, 0x23, 0x3f, 0x98, 0x27, 0x0, 0x0, 0x7d, 0xff, 0x22, 0x6f, 0x73, 0x12, + 0x0, 0x7, 0xc6, 0xdb, 0x11, 0xd6, 0x85, 0x8e, 0x55, 0x2a, 0x87, 0x26, 0x0, 0x1b, 0x50, 0xcc, 0xd8, 0x49, 0x59, + 0x3, 0xc4, 0x49, 0x29, 0xa6, 0xf3, 0xf3, 0xcf, 0xbf, 0x67, 0xe3, 0x2, 0x53, 0x4c, 0x25, 0x9, 0x46, 0xc7, 0x53, + 0xcd, 0xcc, 0x62, 0x0, 0x11, 0xdb, 0x30, 0xf1, 0x40, 0x1d, 0x4e, 0x39, 0x8e, 0x42, 0x3e, 0xf2, 0x3d, 0x98, 0x54, + 0xf0, 0xa1, 0xa8, 0x27, 0x0, 0x0, 0x47, 0x5, 0x27, 0x0, 0x0, 0x4b, 0xef, 0x9, 0x0, 0x13, 0x5e, 0x9a, 0xad, + 0x12, 0x94, 0x90, 0xc1, 0x2d, 0x61, 0x94, 0x78, 0x2e, 0x13, 0xf6, 0xa2, 0x4e, 0x16, 0x1b, 0x85, 0x24, 0x77, 0x24, + 0x13, 0x13, 0x77, 0xa4, 0x17, 0xbe, 0x13, 0x5a, 0xa3, 0x12, 0x0, 0x4, 0x88, 0x72, 0xa0, 0x74, 0x25, 0xf0, 0x11, + 0x0, 0x0, 0x7, 0xb0, 0x1f, 0x0, 0xd, 0x37, 0x73, 0xd2, 0x62, 0xfc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83, 0xd7, 0x98, 0x66, 0x6, 0x0, 0x11, 0x51, 0xe7, 0x73, 0x37, + 0x48, 0x5, 0x23, 0x8f, 0x6f, 0x7, 0xfb, 0x2, 0x57, 0xc9, 0xb1, 0xc4, 0x7b, 0x12, 0x0, 0x4, 0x24, 0x8e, 0x8c, + 0xc6, 0x22}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xd, 0x6, 0x41, 0xa5, 0x1c, 0xbb, 0xb, 0x70, 0x46, 0xe7, + 0x9b, 0x3e, 0xa2, 0x71, 0xa, 0x4d, 0xc0, 0xfc, 0xc, 0x7b, + 0xb2, 0x8, 0x7, 0x40, 0x76, 0x83, 0xd7, 0x98, 0x66}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x51, 0xe7, 0x73, 0x37, 0x48, 0x5, 0x23, 0x8f, 0x6f, + 0x7, 0xfb, 0x2, 0x57, 0xc9, 0xb1, 0xc4, 0x7b}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x24, 0x8e, 0x8c, 0xc6}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + uint8_t bytesprops0[] = {0x57, 0x78, 0x89, 0x8a, 0x95, 0xd5, 0x20, 0x4d, + 0x4f, 0xde, 0x2, 0xb4, 0xd1, 0x27, 0x86, 0x33}; + uint8_t bytesprops1[] = {0xc6, 0xdb, 0x11, 0xd6, 0x85, 0x8e, 0x55}; + uint8_t bytesprops3[] = {0xdb, 0x30, 0xf1, 0x40, 0x1d, 0x4e, 0x39, 0x8e, 0x42, + 0x3e, 0xf2, 0x3d, 0x98, 0x54, 0xf0, 0xa1, 0xa8}; + uint8_t bytesprops2[] = {0x50, 0xcc, 0xd8, 0x49, 0x59, 0x3, 0xc4, 0x49, 0x29, 0xa6, 0xf3, 0xf3, 0xcf, 0xbf, + 0x67, 0xe3, 0x2, 0x53, 0x4c, 0x25, 0x9, 0x46, 0xc7, 0x53, 0xcd, 0xcc, 0x62}; + uint8_t bytesprops4[] = {0x5e, 0x9a, 0xad, 0x12, 0x94, 0x90, 0xc1, 0x2d, 0x61, 0x94, + 0x78, 0x2e, 0x13, 0xf6, 0xa2, 0x4e, 0x16, 0x1b, 0x85}; + uint8_t bytesprops5[] = {0x88, 0x72, 0xa0, 0x74}; + uint8_t bytesprops6[] = {0x37, 0x73, 0xd2, 0x62, 0xfc, 0x7f, 0x93, 0x96, 0x1c, 0x70, 0xf4, 0x38, 0x25}; + uint8_t bytesprops7[] = {0xc8, 0x24, 0x87, 0xdc}; + uint8_t bytesprops8[] = {0x1c, 0xda, 0xf9, 0x44, 0xf, 0xd3, 0x16, 0x6, 0x73, 0xb6, + 0x5d, 0x85, 0xab, 0xd5, 0xc2, 0x7d, 0x2, 0x8e, 0xd0}; + uint8_t bytesprops9[] = {0x39, 0x67, 0x84, 0x36, 0x8e, 0xbf, 0xe9, 0xa2, 0x41, 0x50, 0xb0, + 0xb5, 0x8d, 0xb3, 0x38, 0x8e, 0x48, 0x43, 0x40, 0x13, 0x1e}; + uint8_t bytesprops10[] = {0x31, 0xc4, 0xef, 0xc2, 0xd5, 0x19, 0x2d, 0xe4, 0xc5, 0xf, + 0x5d, 0xb7, 0x4f, 0xbd, 0xff, 0x49, 0x77, 0x73, 0x79}; + uint8_t bytesprops11[] = {0x3f, 0x27, 0xe8, 0xb, 0x34, 0xd5, 0x16, 0xab, 0xbf, 0x4, 0xa3, 0x5f, 0x6, 0x87, + 0x76, 0x14, 0x16, 0x9e, 0x75, 0x7f, 0x3a, 0xeb, 0x3, 0x19, 0x45, 0xc2, 0x32, 0x47}; + uint8_t bytesprops12[] = {0x4e, 0x12, 0xf3, 0x6e, 0xc0, 0x61, 0x2b, 0xac, 0x74, 0x33, 0x42, 0x40, 0x6d, 0x2c, + 0x68, 0x1a, 0xf8, 0xe1, 0x4b, 0x74, 0x8, 0x76, 0xee, 0xfe, 0x46, 0x59, 0xa4, 0x27}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16280}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 32255}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28531}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 135}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops2}, .v = {17, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18181}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19439}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 119}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 30628}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23203}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 240}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1968}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 1701}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26022}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops12}}}, + }; + + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14957, 6, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12819, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12087 [("\SOH\160\au5\136\&6\222",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("\202SR62\ENQ<\140\142k",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\141\ACK\147\209\&2\239\163\250\214V",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS2}),("\227a\EOT0{ \198\DC2\248\240s_m`\210\198~\128e\240\202\SOH",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\197%;s04\250{\144\SIN\157\136\156\157\221\232\250",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS2}),("",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("86f\234\181\141#g\FS]\237x\187\200B\224Q\158\&3\234\STX\a1\233\\\FS",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("0\194w\220\142\208!>\246\138\133\163\SOH|\246I\FS$D\252`!\FS@",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\172\226p\DC4E\160\DC3\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS0}),("\230A<\165\132",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = True, _noLocal = False, _subQoS = QoS1})] [PropMaximumPacketSize 27560,PropReasonString -// "\216\&7\160s\166\151\187\239L\146\177`\136\233\176G",PropServerReference "\RS\254!\151\CAN",PropResponseInformation -// "K*H7\NAK\227\131\&8",PropCorrelationData "o\177\168NB\203\DC1\241\189\SO?\202",PropSessionExpiryInterval -// 6634,PropSubscriptionIdentifier 15,PropAuthenticationData "\198x@\ETB#\198\220\248",PropMessageExpiryInterval -// 24925,PropWillDelayInterval 13925,PropSubscriptionIdentifierAvailable 170,PropAuthenticationData -// "g#H\192\183+\SUB\170y`x\216\159\213?\180\254*\ETB\197\158\159\209\&3sPA",PropUserProperty -// "hp\150\177\128$\SO\SOH\219\131\174\&3 g\240e\134\EOT\187A" -// "\150\170\218\217\n(~\161\242\169\141\144\248\211",PropCorrelationData -// "\185\CANR;4\218A\229\&27\EM3o\188\230\&0%;|je'\148W\142\150>&\NAK\216",PropWillDelayInterval 4592] +// SubscribeRequest 26406 [("`\aR\230\193\146\183",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = +// True, _noLocal = True, _subQoS = QoS2}),("\EOT,\142\SOH\170%",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("P\232L\184\219'\fn\160W\t22",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] +// [PropMessageExpiryInterval 2977,PropPayloadFormatIndicator 43,PropAssignedClientIdentifier +// "Q\217vjN\198^\v*\222\f\226\171'",PropMessageExpiryInterval 19765,PropAuthenticationData "\197\154\EM\158>"] TEST(Subscribe5QCTest, Encode14) { - uint8_t pkt[] = { - 0x82, 0xe8, 0x2, 0x2f, 0x37, 0xc3, 0x1, 0x27, 0x0, 0x0, 0x6b, 0xa8, 0x1f, 0x0, 0x10, 0xd8, 0x37, 0xa0, 0x73, - 0xa6, 0x97, 0xbb, 0xef, 0x4c, 0x92, 0xb1, 0x60, 0x88, 0xe9, 0xb0, 0x47, 0x1c, 0x0, 0x5, 0x1e, 0xfe, 0x21, 0x97, - 0x18, 0x1a, 0x0, 0x8, 0x4b, 0x2a, 0x48, 0x37, 0x15, 0xe3, 0x83, 0x38, 0x9, 0x0, 0xc, 0x6f, 0xb1, 0xa8, 0x4e, - 0x42, 0xcb, 0x11, 0xf1, 0xbd, 0xe, 0x3f, 0xca, 0x11, 0x0, 0x0, 0x19, 0xea, 0xb, 0xf, 0x16, 0x0, 0x8, 0xc6, - 0x78, 0x40, 0x17, 0x23, 0xc6, 0xdc, 0xf8, 0x2, 0x0, 0x0, 0x61, 0x5d, 0x18, 0x0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, 0x88, 0x9c, 0x9d, 0xdd, 0xe8, 0xfa, 0x2a, - 0x0, 0x0, 0x19, 0x0, 0x1a, 0x38, 0x36, 0x66, 0xea, 0xb5, 0x8d, 0x23, 0x67, 0x1c, 0x5d, 0xed, 0x78, 0xbb, 0xc8, - 0x42, 0xe0, 0x51, 0x9e, 0x33, 0xea, 0x2, 0x7, 0x31, 0xe9, 0x5c, 0x1c, 0x1a, 0x0, 0x18, 0x30, 0xc2, 0x77, 0xdc, - 0x8e, 0xd0, 0x21, 0x3e, 0xf6, 0x8a, 0x85, 0xa3, 0x1, 0x7c, 0xf6, 0x49, 0x1c, 0x24, 0x44, 0xfc, 0x60, 0x21, 0x1c, - 0x40, 0x4, 0x0, 0x8, 0xac, 0xe2, 0x70, 0x14, 0x45, 0xa0, 0x13, 0xe1, 0xc, 0x0, 0x5, 0xe6, 0x41, 0x3c, 0xa5, - 0x84, 0x9}; + uint8_t pkt[] = {0x82, 0x4b, 0x67, 0x26, 0x25, 0x2, 0x0, 0x0, 0xb, 0xa1, 0x1, 0x2b, 0x12, 0x0, 0xe, 0x51, + 0xd9, 0x76, 0x6a, 0x4e, 0xc6, 0x5e, 0xb, 0x2a, 0xde, 0xc, 0xe2, 0xab, 0x27, 0x2, 0x0, 0x0, + 0x4d, 0x35, 0x16, 0x0, 0x5, 0xc5, 0x9a, 0x19, 0x9e, 0x3e, 0x0, 0x7, 0x60, 0x7, 0x52, 0xe6, + 0xc1, 0x92, 0xb7, 0xe, 0x0, 0x6, 0x4, 0x2c, 0x8e, 0x1, 0xaa, 0x25, 0x1d, 0x0, 0xd, 0x50, + 0xe8, 0x4c, 0xb8, 0xdb, 0x27, 0xc, 0x6e, 0xa0, 0x57, 0x9, 0x32, 0x32, 0x6}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x1, 0xa0, 0x7, 0x75, 0x35, 0x88, 0x36, 0xde}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0x60, 0x7, 0x52, 0xe6, 0xc1, 0x92, 0xb7}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xca, 0x53, 0x52, 0x36, 0x32, 0x5, 0x3c, 0x8c, 0x8e, 0x6b}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x4, 0x2c, 0x8e, 0x1, 0xaa, 0x25}; + lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8d, 0x6, 0x93, 0xd1, 0x32, 0xef, 0xa3, 0xfa, 0xd6, 0x56}; - lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x50, 0xe8, 0x4c, 0xb8, 0xdb, 0x27, 0xc, 0x6e, 0xa0, 0x57, 0x9, 0x32, 0x32}; + lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe3, 0x61, 0x4, 0x30, 0x7b, 0x20, 0xc6, 0x12, 0xf8, 0xf0, 0x73, - 0x5f, 0x6d, 0x60, 0xd2, 0xc6, 0x7e, 0x80, 0x65, 0xf0, 0xca, 0x1}; - lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc5, 0x25, 0x3b, 0x73, 0x30, 0x34, 0xfa, 0x7b, 0x90, - 0xf, 0x4e, 0x9d, 0x88, 0x9c, 0x9d, 0xdd, 0xe8, 0xfa}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x38, 0x36, 0x66, 0xea, 0xb5, 0x8d, 0x23, 0x67, 0x1c, 0x5d, 0xed, 0x78, 0xbb, - 0xc8, 0x42, 0xe0, 0x51, 0x9e, 0x33, 0xea, 0x2, 0x7, 0x31, 0xe9, 0x5c, 0x1c}; - lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x30, 0xc2, 0x77, 0xdc, 0x8e, 0xd0, 0x21, 0x3e, 0xf6, 0x8a, 0x85, 0xa3, - 0x1, 0x7c, 0xf6, 0x49, 0x1c, 0x24, 0x44, 0xfc, 0x60, 0x21, 0x1c, 0x40}; - lwmqtt_string_t topic_filter_s7 = {24, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xac, 0xe2, 0x70, 0x14, 0x45, 0xa0, 0x13, 0xe1}; - lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xe6, 0x41, 0x3c, 0xa5, 0x84}; - lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; + lwmqtt_sub_options_t sub_opts[3]; sub_opts[0].qos = LWMQTT_QOS2; - sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; + sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS0; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = true; - sub_opts[9].no_local = false; - uint8_t bytesprops0[] = {0xd8, 0x37, 0xa0, 0x73, 0xa6, 0x97, 0xbb, 0xef, - 0x4c, 0x92, 0xb1, 0x60, 0x88, 0xe9, 0xb0, 0x47}; - uint8_t bytesprops1[] = {0x1e, 0xfe, 0x21, 0x97, 0x18}; - uint8_t bytesprops2[] = {0x4b, 0x2a, 0x48, 0x37, 0x15, 0xe3, 0x83, 0x38}; - uint8_t bytesprops3[] = {0x6f, 0xb1, 0xa8, 0x4e, 0x42, 0xcb, 0x11, 0xf1, 0xbd, 0xe, 0x3f, 0xca}; - uint8_t bytesprops4[] = {0xc6, 0x78, 0x40, 0x17, 0x23, 0xc6, 0xdc, 0xf8}; - uint8_t bytesprops5[] = {0x67, 0x23, 0x48, 0xc0, 0xb7, 0x2b, 0x1a, 0xaa, 0x79, 0x60, 0x78, 0xd8, 0x9f, 0xd5, - 0x3f, 0xb4, 0xfe, 0x2a, 0x17, 0xc5, 0x9e, 0x9f, 0xd1, 0x33, 0x73, 0x50, 0x41}; - uint8_t bytesprops7[] = {0x96, 0xaa, 0xda, 0xd9, 0xa, 0x28, 0x7e, 0xa1, 0xf2, 0xa9, 0x8d, 0x90, 0xf8, 0xd3}; - uint8_t bytesprops6[] = {0x68, 0x70, 0x96, 0xb1, 0x80, 0x24, 0xe, 0x1, 0xdb, 0x83, - 0xae, 0x33, 0x20, 0x67, 0xf0, 0x65, 0x86, 0x4, 0xbb, 0x41}; - uint8_t bytesprops8[] = {0xb9, 0x18, 0x52, 0x3b, 0x34, 0xda, 0x41, 0xe5, 0x32, 0x37, 0x19, 0x33, 0x6f, 0xbc, 0xe6, - 0x30, 0x25, 0x3b, 0x7c, 0x6a, 0x65, 0x27, 0x94, 0x57, 0x8e, 0x96, 0x3e, 0x26, 0x15, 0xd8}; + sub_opts[2].no_local = true; + uint8_t bytesprops0[] = {0x51, 0xd9, 0x76, 0x6a, 0x4e, 0xc6, 0x5e, 0xb, 0x2a, 0xde, 0xc, 0xe2, 0xab, 0x27}; + uint8_t bytesprops1[] = {0xc5, 0x9a, 0x19, 0x9e, 0x3e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27560}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6634}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24925}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 13925}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 170}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops6}, .v = {14, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4592}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2977}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19765}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12087, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26406, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 12264 [("\196k\DC4\147L\142U\156\ENQ\US\184Vi",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("v\GSMX\152\167\US\241\&0\144",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("ZW\174\198D$\r\232\220afgJM\NAKe\174\158\192\138\223\ESCs\172d\140M",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\EOT\184\184Pt\214-\228:\SI\193\207\136",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\202\223|X\252\nU\158b~\143\&8\GS#",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\162#D\147((1X -// ",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\130\219\DC4\157\150w",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS2}),("|\141\195",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1})] [PropServerReference "\214\STX\ESC[~\135\&4\149\208H\173\SO\233Z -// \156\162\209\207\226>\165\251\247",PropRequestResponseInformation 114,PropResponseTopic -// "\144\131S^\232\227\206{\SO\156\238n\173;\209\246\153\177\136\GS\236\142\220\217",PropServerKeepAlive -// 241,PropRequestProblemInformation 7,PropMaximumQoS 79,PropReasonString -// "\GSHr\217\ETX\211\227\229\197Sg\129?\195D",PropResponseInformation "pZi\157\138\183$J7\150Y<\230 -// \220\182\150g\NAK\239A\165g\222\250\SOC",PropSharedSubscriptionAvailable 18,PropTopicAlias 8978,PropResponseTopic -// "\220\187\SOH'\US\172HL\DC2\226z=;$\157f\161\237\190\CAN\186%\254%U\205\250",PropRequestResponseInformation -// 30,PropAuthenticationMethod "\234",PropCorrelationData "\179\242\211\250\195",PropWildcardSubscriptionAvailable -// 200,PropReasonString "\184\135u\222gG\222v\158",PropRetainAvailable 169,PropSubscriptionIdentifier -// 14,PropMessageExpiryInterval 26125] +// SubscribeRequest 13914 [("\198\167\141tI\138S\169\224\226\US\159\SIty",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("1\181Xv\ACK\149\214\232z\136\EOT)\197\DLE\245\&5-\FSK~\SUBO\228\ENQ>1",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS1}),("\163\252\EOT\234\173\180\EM\\O\240\GS)\232\252=\DC3\152",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropRequestProblemInformation +// 88,PropAssignedClientIdentifier "#\225KF\181\DC2\174",PropReasonString +// "\183\244\143d\213\200eZ\191\156\201XfY\171",PropSubscriptionIdentifier 29,PropMessageExpiryInterval +// 7039,PropSubscriptionIdentifier 19,PropWildcardSubscriptionAvailable 199,PropMaximumQoS 94,PropTopicAliasMaximum +// 13184,PropUserProperty "E\246`\226\145\237`\162\SUB\203\139" +// "S\185j\215\174&\SOHM\192\178\&0\229\191\195\134\233|\SOH\149\212\242",PropReceiveMaximum 48,PropReasonString +// "\243\252\a\171",PropContentType "\r\181*\DEL",PropTopicAlias 5955,PropMessageExpiryInterval +// 31416,PropAssignedClientIdentifier "\243\ENQt#\243\193\221V\253\163\"Zz0\NAK",PropTopicAlias 12949,PropReceiveMaximum +// 13522,PropReasonString "\147\DC1l\226\155\STX\211\177\143\211d\133\132\187\DC2\186\182\207\158\136\r",PropMaximumQoS +// 247,PropSharedSubscriptionAvailable 70] TEST(Subscribe5QCTest, Encode15) { - uint8_t pkt[] = { - 0x82, 0xb2, 0x2, 0x2f, 0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x8b, 0x0, + 0x15, 0x53, 0xb9, 0x6a, 0xd7, 0xae, 0x26, 0x1, 0x4d, 0xc0, 0xb2, 0x30, 0xe5, 0xbf, 0xc3, 0x86, 0xe9, + 0x7c, 0x1, 0x95, 0xd4, 0xf2, 0x21, 0x0, 0x30, 0x1f, 0x0, 0x4, 0xf3, 0xfc, 0x7, 0xab, 0x3, 0x0, + 0x4, 0xd, 0xb5, 0x2a, 0x7f, 0x23, 0x17, 0x43, 0x2, 0x0, 0x0, 0x7a, 0xb8, 0x12, 0x0, 0xf, 0xf3, + 0x5, 0x74, 0x23, 0xf3, 0xc1, 0xdd, 0x56, 0xfd, 0xa3, 0x22, 0x5a, 0x7a, 0x30, 0x15, 0x23, 0x32, 0x95, + 0x21, 0x34, 0xd2, 0x1f, 0x0, 0x15, 0x93, 0x11, 0x6c, 0xe2, 0x9b, 0x2, 0xd3, 0xb1, 0x8f, 0xd3, 0x64, + 0x85, 0x84, 0xbb, 0x12, 0xba, 0xb6, 0xcf, 0x9e, 0x88, 0xd, 0x24, 0xf7, 0x2a, 0x46, 0x0, 0xf, 0xc6, + 0xa7, 0x8d, 0x74, 0x49, 0x8a, 0x53, 0xa9, 0xe0, 0xe2, 0x1f, 0x9f, 0xf, 0x74, 0x79, 0x1a, 0x0, 0x1a, + 0x31, 0xb5, 0x58, 0x76, 0x6, 0x95, 0xd6, 0xe8, 0x7a, 0x88, 0x4, 0x29, 0xc5, 0x10, 0xf5, 0x35, 0x2d, + 0x1c, 0x4b, 0x7e, 0x1a, 0x4f, 0xe4, 0x5, 0x3e, 0x31, 0x1d, 0x0, 0x11, 0xa3, 0xfc, 0x4, 0xea, 0xad, + 0xb4, 0x19, 0x5c, 0x4f, 0xf0, 0x1d, 0x29, 0xe8, 0xfc, 0x3d, 0x13, 0x98, 0x26}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xc4, 0x6b, 0x14, 0x93, 0x4c, 0x8e, 0x55, 0x9c, 0x5, 0x1f, 0xb8, 0x56, 0x69}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xc6, 0xa7, 0x8d, 0x74, 0x49, 0x8a, 0x53, 0xa9, + 0xe0, 0xe2, 0x1f, 0x9f, 0xf, 0x74, 0x79}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x76, 0x1d, 0x4d, 0x58, 0x98, 0xa7, 0x1f, 0xf1, 0x30, 0x90}; - lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x31, 0xb5, 0x58, 0x76, 0x6, 0x95, 0xd6, 0xe8, 0x7a, 0x88, 0x4, 0x29, 0xc5, + 0x10, 0xf5, 0x35, 0x2d, 0x1c, 0x4b, 0x7e, 0x1a, 0x4f, 0xe4, 0x5, 0x3e, 0x31}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5a, 0x57, 0xae, 0xc6, 0x44, 0x24, 0xd, 0xe8, 0xdc, 0x61, 0x66, 0x67, 0x4a, 0x4d, - 0x15, 0x65, 0xae, 0x9e, 0xc0, 0x8a, 0xdf, 0x1b, 0x73, 0xac, 0x64, 0x8c, 0x4d}; - lwmqtt_string_t topic_filter_s2 = {27, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa3, 0xfc, 0x4, 0xea, 0xad, 0xb4, 0x19, 0x5c, 0x4f, + 0xf0, 0x1d, 0x29, 0xe8, 0xfc, 0x3d, 0x13, 0x98}; + lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x4, 0xb8, 0xb8, 0x50, 0x74, 0xd6, 0x2d, 0xe4, 0x3a, 0xf, 0xc1, 0xcf, 0x88}; - lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xca, 0xdf, 0x7c, 0x58, 0xfc, 0xa, 0x55, 0x9e, 0x62, 0x7e, 0x8f, 0x38, 0x1d, 0x23}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xa2, 0x23, 0x44, 0x93, 0x28, 0x28, 0x31, 0x58, 0x20}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x82, 0xdb, 0x14, 0x9d, 0x96, 0x77}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x7c, 0x8d, 0xc3}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - lwmqtt_sub_options_t sub_opts[8]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; + lwmqtt_sub_options_t sub_opts[3]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; + sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].qos = LWMQTT_QOS2; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = false; - sub_opts[7].no_local = false; - uint8_t bytesprops0[] = {0xd6, 0x2, 0x1b, 0x5b, 0x7e, 0x87, 0x34, 0x95, 0xd0, 0x48, 0xad, 0xe, - 0xe9, 0x5a, 0x20, 0x9c, 0xa2, 0xd1, 0xcf, 0xe2, 0x3e, 0xa5, 0xfb, 0xf7}; - uint8_t bytesprops1[] = {0x90, 0x83, 0x53, 0x5e, 0xe8, 0xe3, 0xce, 0x7b, 0xe, 0x9c, 0xee, 0x6e, - 0xad, 0x3b, 0xd1, 0xf6, 0x99, 0xb1, 0x88, 0x1d, 0xec, 0x8e, 0xdc, 0xd9}; - uint8_t bytesprops2[] = {0x1d, 0x48, 0x72, 0xd9, 0x3, 0xd3, 0xe3, 0xe5, 0xc5, 0x53, 0x67, 0x81, 0x3f, 0xc3, 0x44}; - uint8_t bytesprops3[] = {0x70, 0x5a, 0x69, 0x9d, 0x8a, 0xb7, 0x24, 0x4a, 0x37, 0x96, 0x59, 0x3c, 0xe6, 0x20, - 0xdc, 0xb6, 0x96, 0x67, 0x15, 0xef, 0x41, 0xa5, 0x67, 0xde, 0xfa, 0xe, 0x43}; - uint8_t bytesprops4[] = {0xdc, 0xbb, 0x1, 0x27, 0x1f, 0xac, 0x48, 0x4c, 0x12, 0xe2, 0x7a, 0x3d, 0x3b, 0x24, - 0x9d, 0x66, 0xa1, 0xed, 0xbe, 0x18, 0xba, 0x25, 0xfe, 0x25, 0x55, 0xcd, 0xfa}; - uint8_t bytesprops5[] = {0xea}; - uint8_t bytesprops6[] = {0xb3, 0xf2, 0xd3, 0xfa, 0xc3}; - uint8_t bytesprops7[] = {0xb8, 0x87, 0x75, 0xde, 0x67, 0x47, 0xde, 0x76, 0x9e}; + uint8_t bytesprops0[] = {0x23, 0xe1, 0x4b, 0x46, 0xb5, 0x12, 0xae}; + uint8_t bytesprops1[] = {0xb7, 0xf4, 0x8f, 0x64, 0xd5, 0xc8, 0x65, 0x5a, 0xbf, 0x9c, 0xc9, 0x58, 0x66, 0x59, 0xab}; + uint8_t bytesprops3[] = {0x53, 0xb9, 0x6a, 0xd7, 0xae, 0x26, 0x1, 0x4d, 0xc0, 0xb2, 0x30, + 0xe5, 0xbf, 0xc3, 0x86, 0xe9, 0x7c, 0x1, 0x95, 0xd4, 0xf2}; + uint8_t bytesprops2[] = {0x45, 0xf6, 0x60, 0xe2, 0x91, 0xed, 0x60, 0xa2, 0x1a, 0xcb, 0x8b}; + uint8_t bytesprops4[] = {0xf3, 0xfc, 0x7, 0xab}; + uint8_t bytesprops5[] = {0xd, 0xb5, 0x2a, 0x7f}; + uint8_t bytesprops6[] = {0xf3, 0x5, 0x74, 0x23, 0xf3, 0xc1, 0xdd, 0x56, 0xfd, 0xa3, 0x22, 0x5a, 0x7a, 0x30, 0x15}; + uint8_t bytesprops7[] = {0x93, 0x11, 0x6c, 0xe2, 0x9b, 0x2, 0xd3, 0xb1, 0x8f, 0xd3, 0x64, + 0x85, 0x84, 0xbb, 0x12, 0xba, 0xb6, 0xcf, 0x9e, 0x88, 0xd}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 114}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 241}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 79}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8978}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 30}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 169}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 26125}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7039}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 199}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13184}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops2}, .v = {21, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 48}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5955}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31416}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12949}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13522}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 247}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 70}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {21, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12264, 8, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13914, 3, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 23519 [("R\219\&9\207\231\198)2}\160",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("\229\250\209",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("P\243-\232\133v`;l\157\243\238\130\251x\239\172\210\144\US2\251@h\138\228Mt\140",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS0}),("\n\133g\194",SubOptions +// SubscribeRequest 2905 [("\158\194\134\209\SOH \176^\221\235\147\182\230\226\157\a\STX\215",SubOptions // {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("y\239\128\199)K\206~\242\246\SO*Anb2&\190\169#b",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\tz\SI\249\US2%R\176\a\163Kn\141\187\198\211x\246)]",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropAssignedClientIdentifier -// "\ESCd\175\ACK",PropSubscriptionIdentifierAvailable 53,PropMessageExpiryInterval 10167,PropUserProperty "" -// "\240\STX\237\185\239\171\252D\175%\214\231\&2\173$",PropServerKeepAlive 27442,PropServerReference -// ".\190\176F\ACK\"\181-\SYN\150\232O5\242\250\186\171\185EgGt",PropRequestResponseInformation 54,PropResponseTopic -// "\SIwVD\245\239",PropRequestResponseInformation 203,PropServerKeepAlive 27526,PropMessageExpiryInterval -// 14075,PropSharedSubscriptionAvailable 167,PropAuthenticationMethod -// "M\245V\212\136G\132\150\187\166\160hRZ$t%q.?Z\179",PropTopicAlias 8832,PropRequestResponseInformation -// 65,PropMessageExpiryInterval 13256,PropResponseTopic -// "\218\220\184s\219\206\151\169\208\231\131p\ENQ\RS\200\201\DC4\f\224\147\t\168"] +// QoS2}),("\STX\165?\213\"\ETX@\DC4\ENQ\178\ACKjo\156",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\171sk",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("\171\167\154\213\250eT\\\165\US\US@\174",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\144O\186\216\f'gm{BI",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS0}),("\GS]\244\240/\177\178.\246\143\SI-\226j\165\SOH\233",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropServerKeepAlive +// 12808,PropContentType "0O}\206\&1\174\205U\SYNr\242\244\ACK",PropResponseInformation +// "[\246\192",PropAuthenticationData "\213\RS\SIp\138Q\172\231\nT\EM\146",PropReasonString +// "w\170\&7G\216\192\ETX\EOTO;\RS\DC3RsM\133P\233\EMH\240o\249\NAK\191\131D\156\131\237",PropRetainAvailable +// 154,PropCorrelationData "\185Z\184\132u\159\&0\227\176\197\188^\236\214\239",PropTopicAliasMaximum +// 11949,PropWildcardSubscriptionAvailable 190,PropCorrelationData +// "\241b]\222\155\201\159Q<\178i\243(\186\&4\136\138\154\187\174\222\169\241_",PropMaximumPacketSize +// 22371,PropUserProperty "\183\ETB)0MHZ\130\165\248\142z\GS\EOT\230\136e\237,\199\228\218\169_c\v\212" +// "\212\SYN\228\150}N\233\221\234e\151p\255^\165\233\171\170",PropWillDelayInterval 894] TEST(Subscribe5QCTest, Encode16) { - uint8_t pkt[] = { - 0x82, 0x82, 0x2, 0x5b, 0xdf, 0x91, 0x1, 0x12, 0x0, 0x4, 0x1b, 0x64, 0xaf, 0x6, 0x29, 0x35, 0x2, 0x0, 0x0, - 0x27, 0xb7, 0x26, 0x0, 0x0, 0x0, 0xf, 0xf0, 0x2, 0xed, 0x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 0x17, 0x29, 0x30, 0x4d, 0x48, 0x5a, 0x82, 0xa5, 0xf8, 0x8e, 0x7a, 0x1d, + 0x4, 0xe6, 0x88, 0x65, 0xed, 0x2c, 0xc7, 0xe4, 0xda, 0xa9, 0x5f, 0x63, 0xb, 0xd4, 0x0, 0x12, 0xd4, + 0x16, 0xe4, 0x96, 0x7d, 0x4e, 0xe9, 0xdd, 0xea, 0x65, 0x97, 0x70, 0xff, 0x5e, 0xa5, 0xe9, 0xab, 0xaa, + 0x18, 0x0, 0x0, 0x3, 0x7e, 0x0, 0x12, 0x9e, 0xc2, 0x86, 0xd1, 0x1, 0x20, 0xb0, 0x5e, 0xdd, 0xeb, + 0x93, 0xb6, 0xe6, 0xe2, 0x9d, 0x7, 0x2, 0xd7, 0x2, 0x0, 0xe, 0x2, 0xa5, 0x3f, 0xd5, 0x22, 0x3, + 0x40, 0x14, 0x5, 0xb2, 0x6, 0x6a, 0x6f, 0x9c, 0x1d, 0x0, 0x3, 0xab, 0x73, 0x6b, 0x4, 0x0, 0xd, + 0xab, 0xa7, 0x9a, 0xd5, 0xfa, 0x65, 0x54, 0x5c, 0xa5, 0x1f, 0x1f, 0x40, 0xae, 0x19, 0x0, 0xb, 0x90, + 0x4f, 0xba, 0xd8, 0xc, 0x27, 0x67, 0x6d, 0x7b, 0x42, 0x49, 0x28, 0x0, 0x11, 0x1d, 0x5d, 0xf4, 0xf0, + 0x2f, 0xb1, 0xb2, 0x2e, 0xf6, 0x8f, 0xf, 0x2d, 0xe2, 0x6a, 0xa5, 0x1, 0xe9, 0xa}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x52, 0xdb, 0x39, 0xcf, 0xe7, 0xc6, 0x29, 0x32, 0x7d, 0xa0}; - lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x9e, 0xc2, 0x86, 0xd1, 0x1, 0x20, 0xb0, 0x5e, 0xdd, + 0xeb, 0x93, 0xb6, 0xe6, 0xe2, 0x9d, 0x7, 0x2, 0xd7}; + lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x2, 0xa5, 0x3f, 0xd5, 0x22, 0x3, 0x40, 0x14, 0x5, 0xb2, 0x6, 0x6a, 0x6f, 0x9c}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe5, 0xfa, 0xd1}; + uint8_t topic_filter_s2_bytes[] = {0xab, 0x73, 0x6b}; lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x50, 0xf3, 0x2d, 0xe8, 0x85, 0x76, 0x60, 0x3b, 0x6c, 0x9d, - 0xf3, 0xee, 0x82, 0xfb, 0x78, 0xef, 0xac, 0xd2, 0x90, 0x1f, - 0x32, 0xfb, 0x40, 0x68, 0x8a, 0xe4, 0x4d, 0x74, 0x8c}; - lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xab, 0xa7, 0x9a, 0xd5, 0xfa, 0x65, 0x54, 0x5c, 0xa5, 0x1f, 0x1f, 0x40, 0xae}; + lwmqtt_string_t topic_filter_s3 = {13, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa, 0x85, 0x67, 0xc2}; - lwmqtt_string_t topic_filter_s4 = {4, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x90, 0x4f, 0xba, 0xd8, 0xc, 0x27, 0x67, 0x6d, 0x7b, 0x42, 0x49}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x79, 0xef, 0x80, 0xc7, 0x29, 0x4b, 0xce, 0x7e, 0xf2, 0xf6, 0xe, - 0x2a, 0x41, 0x6e, 0x62, 0x32, 0x26, 0xbe, 0xa9, 0x23, 0x62}; - lwmqtt_string_t topic_filter_s5 = {21, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x1d, 0x5d, 0xf4, 0xf0, 0x2f, 0xb1, 0xb2, 0x2e, 0xf6, + 0x8f, 0xf, 0x2d, 0xe2, 0x6a, 0xa5, 0x1, 0xe9}; + lwmqtt_string_t topic_filter_s5 = {17, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x9, 0x7a, 0xf, 0xf9, 0x1f, 0x32, 0x25, 0x52, 0xb0, 0x7, 0xa3, - 0x4b, 0x6e, 0x8d, 0xbb, 0xc6, 0xd3, 0x78, 0xf6, 0x29, 0x5d}; - lwmqtt_string_t topic_filter_s6 = {21, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS0; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + lwmqtt_sub_options_t sub_opts[6]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS0; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = true; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; + sub_opts[3].no_local = false; + sub_opts[4].qos = LWMQTT_QOS0; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; + sub_opts[5].qos = LWMQTT_QOS2; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[5].retain_as_published = true; sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS2; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = true; - uint8_t bytesprops0[] = {0x1b, 0x64, 0xaf, 0x6}; - uint8_t bytesprops2[] = {0xf0, 0x2, 0xed, 0xb9, 0xef, 0xab, 0xfc, 0x44, 0xaf, 0x25, 0xd6, 0xe7, 0x32, 0xad, 0x24}; - uint8_t bytesprops1[] = {0}; - uint8_t bytesprops3[] = {0x2e, 0xbe, 0xb0, 0x46, 0x6, 0x22, 0xb5, 0x2d, 0x16, 0x96, 0xe8, - 0x4f, 0x35, 0xf2, 0xfa, 0xba, 0xab, 0xb9, 0x45, 0x67, 0x47, 0x74}; - uint8_t bytesprops4[] = {0xf, 0x77, 0x56, 0x44, 0xf5, 0xef}; - uint8_t bytesprops5[] = {0x4d, 0xf5, 0x56, 0xd4, 0x88, 0x47, 0x84, 0x96, 0xbb, 0xa6, 0xa0, - 0x68, 0x52, 0x5a, 0x24, 0x74, 0x25, 0x71, 0x2e, 0x3f, 0x5a, 0xb3}; - uint8_t bytesprops6[] = {0xda, 0xdc, 0xb8, 0x73, 0xdb, 0xce, 0x97, 0xa9, 0xd0, 0xe7, 0x83, - 0x70, 0x5, 0x1e, 0xc8, 0xc9, 0x14, 0xc, 0xe0, 0x93, 0x9, 0xa8}; + uint8_t bytesprops0[] = {0x30, 0x4f, 0x7d, 0xce, 0x31, 0xae, 0xcd, 0x55, 0x16, 0x72, 0xf2, 0xf4, 0x6}; + uint8_t bytesprops1[] = {0x5b, 0xf6, 0xc0}; + uint8_t bytesprops2[] = {0xd5, 0x1e, 0xf, 0x70, 0x8a, 0x51, 0xac, 0xe7, 0xa, 0x54, 0x19, 0x92}; + uint8_t bytesprops3[] = {0x77, 0xaa, 0x37, 0x47, 0xd8, 0xc0, 0x3, 0x4, 0x4f, 0x3b, 0x1e, 0x13, 0x52, 0x73, 0x4d, + 0x85, 0x50, 0xe9, 0x19, 0x48, 0xf0, 0x6f, 0xf9, 0x15, 0xbf, 0x83, 0x44, 0x9c, 0x83, 0xed}; + uint8_t bytesprops4[] = {0xb9, 0x5a, 0xb8, 0x84, 0x75, 0x9f, 0x30, 0xe3, 0xb0, 0xc5, 0xbc, 0x5e, 0xec, 0xd6, 0xef}; + uint8_t bytesprops5[] = {0xf1, 0x62, 0x5d, 0xde, 0x9b, 0xc9, 0x9f, 0x51, 0x3c, 0xb2, 0x69, 0xf3, + 0x28, 0xba, 0x34, 0x88, 0x8a, 0x9a, 0xbb, 0xae, 0xde, 0xa9, 0xf1, 0x5f}; + uint8_t bytesprops7[] = {0xd4, 0x16, 0xe4, 0x96, 0x7d, 0x4e, 0xe9, 0xdd, 0xea, + 0x65, 0x97, 0x70, 0xff, 0x5e, 0xa5, 0xe9, 0xab, 0xaa}; + uint8_t bytesprops6[] = {0xb7, 0x17, 0x29, 0x30, 0x4d, 0x48, 0x5a, 0x82, 0xa5, 0xf8, 0x8e, 0x7a, 0x1d, 0x4, + 0xe6, 0x88, 0x65, 0xed, 0x2c, 0xc7, 0xe4, 0xda, 0xa9, 0x5f, 0x63, 0xb, 0xd4}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 53}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10167}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops1}, .v = {15, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27442}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {22, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 54}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 203}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27526}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14075}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 167}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8832}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 65}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13256}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12808}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {15, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11949}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22371}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops6}, .v = {18, (char*)&bytesprops7}}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 894}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23519, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2905, 6, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 29383 [(",\NAK\169\178hV\136\f\td\219\232\130\128\161",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("x\r\128\171A\130\134\&6\DC1oU\179\212\t~\136\247\SO3",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),(")o=\233\v\SOH\204,\183\ESCkM^\133\224\&5\200H",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS0}),("\210\198\219\203\239\165d<\213b\DC4UR\142\235\248\NULp\131\235\184\147\223kF\157\137\150\218\b",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("mm\223\&8\CAN\fO\no",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal -// = True, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS2}),("\192\143D`V'\SYNt\SI\233\133\&5\248\252\145\247C\130\192\218\SUBo",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("\173\253\163N\216\207\129+_ \235e2\r5}\146",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\223\ETX\244nSoNK",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("/\239uT\EOT",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("f\241DK\SUB\ETB\DLEfe[\RS\CAN\222\ESCp\230Z\232v9e\246",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropResponseTopic -// "&.J\226+",PropRequestProblemInformation 153,PropWillDelayInterval 31281,PropRequestProblemInformation 220] +// SubscribeRequest 10689 [("\199\210\220",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = False, _subQoS = QoS0}),("7\161c\189=\151\t\191\238\214\221\130]\254\133\170S",SubOptions {_retainHandling +// = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\207\&0\141\ETB\132\255\137\214\191x\233o\247\ACK\248\177",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("7\137\ETB\205\231s\136!\DC3B\DC1\151T\175\132\DLE[w\159r\162Tp\145\ENQ",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS0}),("\177\136\US\209\US\188\SOg\EOTe\246CY^`\DEL3\143\ESC\EOTgMo\253\248\236\RSa*&",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropAuthenticationData +// "\189\178",PropUserProperty "2\178\\\148h]\158\229\SOH\167\151\222#\191" +// "K\137r'\185\244",PropAssignedClientIdentifier "\154/_\232u\SIW\254\ENQ\SYN)KnO\212`h|'\f\201\&8\134 +// \240\&8\RS\254\&0"] TEST(Subscribe5QCTest, Encode17) { - uint8_t pkt[] = { - 0x82, 0xda, 0x1, 0x72, 0xc7, 0x11, 0x8, 0x0, 0x5, 0x26, 0x2e, 0x4a, 0xe2, 0x2b, 0x17, 0x99, 0x18, 0x0, 0x0, - 0x7a, 0x31, 0x17, 0xdc, 0x0, 0xf, 0x2c, 0x15, 0xa9, 0xb2, 0x68, 0x56, 0x88, 0xc, 0x9, 0x64, 0xdb, 0xe8, 0x82, - 0x80, 0xa1, 0x29, 0x0, 0x13, 0x78, 0xd, 0x80, 0xab, 0x41, 0x82, 0x86, 0x36, 0x11, 0x6f, 0x55, 0xb3, 0xd4, 0x9, - 0x7e, 0x88, 0xf7, 0xe, 0x33, 0xe, 0x0, 0x12, 0x29, 0x6f, 0x3d, 0xe9, 0xb, 0x1, 0xcc, 0x2c, 0xb7, 0x1b, 0x6b, - 0x4d, 0x5e, 0x85, 0xe0, 0x35, 0xc8, 0x48, 0x4, 0x0, 0x1e, 0xd2, 0xc6, 0xdb, 0xcb, 0xef, 0xa5, 0x64, 0x3c, 0xd5, - 0x62, 0x14, 0x55, 0x52, 0x8e, 0xeb, 0xf8, 0x0, 0x70, 0x83, 0xeb, 0xb8, 0x93, 0xdf, 0x6b, 0x46, 0x9d, 0x89, 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xa1, 0x63, 0xbd, + 0x3d, 0x97, 0x9, 0xbf, 0xee, 0xd6, 0xdd, 0x82, 0x5d, 0xfe, 0x85, 0xaa, 0x53, 0x14, 0x0, 0x10, + 0xcf, 0x30, 0x8d, 0x17, 0x84, 0xff, 0x89, 0xd6, 0xbf, 0x78, 0xe9, 0x6f, 0xf7, 0x6, 0xf8, 0xb1, + 0x2e, 0x0, 0x19, 0x37, 0x89, 0x17, 0xcd, 0xe7, 0x73, 0x88, 0x21, 0x13, 0x42, 0x11, 0x97, 0x54, + 0xaf, 0x84, 0x10, 0x5b, 0x77, 0x9f, 0x72, 0xa2, 0x54, 0x70, 0x91, 0x5, 0x20, 0x0, 0x1e, 0xb1, + 0x88, 0x1f, 0xd1, 0x1f, 0xbc, 0xe, 0x67, 0x4, 0x65, 0xf6, 0x43, 0x59, 0x5e, 0x60, 0x7f, 0x33, + 0x8f, 0x1b, 0x4, 0x67, 0x4d, 0x6f, 0xfd, 0xf8, 0xec, 0x1e, 0x61, 0x2a, 0x26, 0x2}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x2c, 0x15, 0xa9, 0xb2, 0x68, 0x56, 0x88, 0xc, - 0x9, 0x64, 0xdb, 0xe8, 0x82, 0x80, 0xa1}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0xc7, 0xd2, 0xdc}; + lwmqtt_string_t topic_filter_s0 = {3, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x78, 0xd, 0x80, 0xab, 0x41, 0x82, 0x86, 0x36, 0x11, 0x6f, - 0x55, 0xb3, 0xd4, 0x9, 0x7e, 0x88, 0xf7, 0xe, 0x33}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x37, 0xa1, 0x63, 0xbd, 0x3d, 0x97, 0x9, 0xbf, 0xee, + 0xd6, 0xdd, 0x82, 0x5d, 0xfe, 0x85, 0xaa, 0x53}; + lwmqtt_string_t topic_filter_s1 = {17, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x29, 0x6f, 0x3d, 0xe9, 0xb, 0x1, 0xcc, 0x2c, 0xb7, - 0x1b, 0x6b, 0x4d, 0x5e, 0x85, 0xe0, 0x35, 0xc8, 0x48}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xcf, 0x30, 0x8d, 0x17, 0x84, 0xff, 0x89, 0xd6, + 0xbf, 0x78, 0xe9, 0x6f, 0xf7, 0x6, 0xf8, 0xb1}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd2, 0xc6, 0xdb, 0xcb, 0xef, 0xa5, 0x64, 0x3c, 0xd5, 0x62, - 0x14, 0x55, 0x52, 0x8e, 0xeb, 0xf8, 0x0, 0x70, 0x83, 0xeb, - 0xb8, 0x93, 0xdf, 0x6b, 0x46, 0x9d, 0x89, 0x96, 0xda, 0x8}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x37, 0x89, 0x17, 0xcd, 0xe7, 0x73, 0x88, 0x21, 0x13, 0x42, 0x11, 0x97, 0x54, + 0xaf, 0x84, 0x10, 0x5b, 0x77, 0x9f, 0x72, 0xa2, 0x54, 0x70, 0x91, 0x5}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x6d, 0x6d, 0xdf, 0x38, 0x18, 0xc, 0x4f, 0xa, 0x6f}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xb1, 0x88, 0x1f, 0xd1, 0x1f, 0xbc, 0xe, 0x67, 0x4, 0x65, + 0xf6, 0x43, 0x59, 0x5e, 0x60, 0x7f, 0x33, 0x8f, 0x1b, 0x4, + 0x67, 0x4d, 0x6f, 0xfd, 0xf8, 0xec, 0x1e, 0x61, 0x2a, 0x26}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0}; - lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc0, 0x8f, 0x44, 0x60, 0x56, 0x27, 0x16, 0x74, 0xf, 0xe9, 0x85, - 0x35, 0xf8, 0xfc, 0x91, 0xf7, 0x43, 0x82, 0xc0, 0xda, 0x1a, 0x6f}; - lwmqtt_string_t topic_filter_s6 = {22, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xad, 0xfd, 0xa3, 0x4e, 0xd8, 0xcf, 0x81, 0x2b, 0x5f, - 0x20, 0xeb, 0x65, 0x32, 0xd, 0x35, 0x7d, 0x92}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xdf, 0x3, 0xf4, 0x6e, 0x53, 0x6f, 0x4e, 0x4b}; - lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x2f, 0xef, 0x75, 0x54, 0x4}; - lwmqtt_string_t topic_filter_s9 = {5, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x66, 0xf1, 0x44, 0x4b, 0x1a, 0x17, 0x10, 0x66, 0x65, 0x5b, 0x1e, - 0x18, 0xde, 0x1b, 0x70, 0xe6, 0x5a, 0xe8, 0x76, 0x39, 0x65, 0xf6}; - lwmqtt_string_t topic_filter_s10 = {22, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + lwmqtt_sub_options_t sub_opts[5]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS0; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].qos = LWMQTT_QOS0; sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[8].retain_as_published = true; - sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS1; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = false; - sub_opts[10].qos = LWMQTT_QOS1; - sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[10].retain_as_published = true; - sub_opts[10].no_local = true; - uint8_t bytesprops0[] = {0x26, 0x2e, 0x4a, 0xe2, 0x2b}; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = false; + uint8_t bytesprops0[] = {0xbd, 0xb2}; + uint8_t bytesprops2[] = {0x4b, 0x89, 0x72, 0x27, 0xb9, 0xf4}; + uint8_t bytesprops1[] = {0x32, 0xb2, 0x5c, 0x94, 0x68, 0x5d, 0x9e, 0xe5, 0x1, 0xa7, 0x97, 0xde, 0x23, 0xbf}; + uint8_t bytesprops3[] = {0x9a, 0x2f, 0x5f, 0xe8, 0x75, 0xf, 0x57, 0xfe, 0x5, 0x16, 0x29, 0x4b, 0x6e, 0x4f, 0xd4, + 0x60, 0x68, 0x7c, 0x27, 0xc, 0xc9, 0x38, 0x86, 0x20, 0xf0, 0x38, 0x1e, 0xfe, 0x30}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31281}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 220}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops1}, .v = {6, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {4, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29383, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10689, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 22596 [("Z\234}C\SUB\171\&5&\204(&\179-\EOTJ4Z\158^\r/\210",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\155\DLE\244\181\FSv!R\140\a\235\ENQ\187D\133;",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\247\DC267\FS'\131\SI\183\GS(6\151",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("-F\209r\195e^\215\133\254\177R\253\173\165\FS\DLE?\DC3\203Qm\153\228 4\EM\156\228",SubOptions +// SubscribeRequest 8875 [("q|\160X\159\&9\235\ETB\206]\224\ETB\205\209\149\211>e\193#\168\246){_\173L\172",SubOptions // {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("*\206\rj\188y\249\188o\SI\163Sfn\ENQ:II3",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished -// = False, _noLocal = False, _subQoS = QoS1}),("\177B:\171\142\240\238\222",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2})] [PropMaximumPacketSize -// 14660,PropUserProperty "\168q\218\252\245\145\&6)\201qf\150\RS\EOT\185v\EOT\209\&2" -// "\209_\132\197]J\t\144?\157\192\219\200##2",PropRetainAvailable 205,PropTopicAliasMaximum -// 27309,PropMessageExpiryInterval 18006,PropSessionExpiryInterval 32484,PropCorrelationData -// "{e\150w\178\ENQ",PropServerReference "\170\158E\aB\211D\171M",PropServerReference -// "]\178\135\US\146\241\227\169\&5@\214\197\252\ESC\140MP\211",PropMessageExpiryInterval 27729,PropMaximumPacketSize -// 31247,PropSharedSubscriptionAvailable 63,PropSubscriptionIdentifier 23,PropSessionExpiryInterval -// 15648,PropRequestProblemInformation 36,PropServerReference -// "\202\229\162\218\NAK\NAK\\\n\DC2\f\217",PropSharedSubscriptionAvailable 93,PropMessageExpiryInterval -// 26613,PropMaximumPacketSize 2627,PropContentType "\DC4\178N\138\225\160",PropPayloadFormatIndicator -// 111,PropReasonString "\215\140\212\192\228\DC3\192\191K\n\221T\129;\169\RS\224",PropRequestProblemInformation -// 176,PropRequestProblemInformation 49,PropResponseTopic "",PropServerKeepAlive 17214,PropSubscriptionIdentifier -// 23,PropSubscriptionIdentifier 27,PropRequestProblemInformation 187,PropCorrelationData "\215iw\146\242x\202\184Q"] +// QoS0}),("\193\166\246\224\235\201\ACK\187k",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = False, _subQoS = QoS1}),("\227\247a\181\EOT\235\DC3\222\&1",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS0}),("Y\213\224\139\128\253\225\233\238\165\197\166`\174]\204\150\188",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropMaximumQoS +// 42,PropRequestResponseInformation 74,PropServerKeepAlive 16546,PropAssignedClientIdentifier +// "C/KZ\144\201\ESC\130)\166MM\241~",PropUserProperty "\EOTT[A2\SUB\161\184\151\239w\178Z\250\SYN\210\178L",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\250z\226\216\161\ETX\ACK\136\206\ESC\173\US\218\247\CAN\SI\213)z>z\188-E\195\128\181L\248'",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("W\185i\STX8n",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = -// False, _subQoS = QoS0}),("",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = -// False, _subQoS = QoS0}),(",\244N\145.o\200\211.\221B{\185",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] [PropWillDelayInterval 2019,PropMessageExpiryInterval -// 19515,PropMaximumPacketSize 11361,PropContentType -// "\202'\227\FS\137\206\&6&\131\231\&6\242\ENQ\169",PropTopicAliasMaximum 14955,PropAuthenticationData -// "\146\131,$`=2\DLE\136M\180\184\204y!}\ETX",PropReasonString -// "G\195\238\\\144\162\231\135\249\140'\152\213\&6\200\&7\180U\227\191\t\182f\DC3v3\249Z",PropRequestProblemInformation -// 101,PropPayloadFormatIndicator 153,PropWillDelayInterval 20161,PropAuthenticationData -// "\248\206\195D\167&H\189aFd,\136",PropMaximumPacketSize 8548] +// QoS0}),("\165O\255\"\139\185\135\183C\ACKa\214\143X\173\175\225K\200\247\205\133\145",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropRequestProblemInformation +// 52,PropRetainAvailable 243,PropRequestProblemInformation 246,PropSubscriptionIdentifierAvailable +// 244,PropSharedSubscriptionAvailable 239,PropTopicAlias 21212,PropRetainAvailable 122,PropMessageExpiryInterval +// 29493,PropResponseTopic "\DLE\203\154=C\ENQ\216\248D\ETX\GS&\140",PropResponseInformation +// "\ETX)\207\129\188\208\238_\189\151\232\133[\191F.\136%b\EOT\ACKn\CAN",PropAssignedClientIdentifier +// "C\SO\164\247UO\135Q\USE\155\221\SO\165\173\185",PropRequestProblemInformation 52,PropReasonString +// "\155\250\225\180\129\189\DC21N\FS\202\215\EM\201\250\237c.j\170<\CANC",PropMessageExpiryInterval +// 32026,PropPayloadFormatIndicator 68,PropTopicAlias 30179] TEST(Subscribe5QCTest, Encode20) { - uint8_t pkt[] = { - 0x82, 0xa2, 0x2, 0x53, 0x1, 0x74, 0x18, 0x0, 0x0, 0x7, 0xe3, 0x2, 0x0, 0x0, 0x4c, 0x3b, 0x27, 0x0, 0x0, - 0x2c, 0x61, 0x3, 0x0, 0xe, 0xca, 0x27, 0xe3, 0x1c, 0x89, 0xce, 0x36, 0x26, 0x83, 0xe7, 0x36, 0xf2, 0x5, 0xa9, - 0x22, 0x3a, 0x6b, 0x16, 0x0, 0x11, 0x92, 0x83, 0x2c, 0x24, 0x60, 0x3d, 0x32, 0x10, 0x88, 0x4d, 0xb4, 0xb8, 0xcc, - 0x79, 0x21, 0x7d, 0x3, 0x1f, 0x0, 0x1c, 0x47, 0xc3, 0xee, 0x5c, 0x90, 0xa2, 0xe7, 0x87, 0xf9, 0x8c, 0x27, 0x98, - 0xd5, 0x36, 0xc8, 0x37, 0xb4, 0x55, 0xe3, 0xbf, 0x9, 0xb6, 0x66, 0x13, 0x76, 0x33, 0xf9, 0x5a, 0x17, 0x65, 0x1, - 0x99, 0x18, 0x0, 0x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ff, 0x22, 0x8b, 0xb9, 0x87, 0xb7, 0x43, 0x6, 0x61, 0xd6, 0x8f, 0x58, 0xad, 0xaf, + 0xe1, 0x4b, 0xc8, 0xf7, 0xcd, 0x85, 0x91, 0x24}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x37, 0x8d, 0x9a, 0xe6, 0x81, 0xf4, 0xec, 0x8a, 0x27, - 0x1e, 0xd0, 0x68, 0x26, 0x59, 0xaa, 0xd, 0xe5, 0x71}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xdc, 0x66, 0x5, 0xf9, 0x5, 0x76, 0x20, 0xcb, 0x51, + 0x87, 0x79, 0x15, 0x64, 0x5f, 0x4f, 0xc, 0xfd, 0xb0}; lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x51}; + uint8_t topic_filter_s1_bytes[] = {0x7}; lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x96, 0x2b, 0x3a, 0x5f, 0x78, 0x3c, 0x53, 0xa5, 0x6f, 0x22, 0x7d, - 0x8a, 0x1d, 0xbd, 0xef, 0xf6, 0x68, 0xdf, 0xcb, 0xf5, 0x8a, 0xbb}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8b, 0xaf, 0x93, 0x75, 0x2c, 0x52, 0x5b, 0x6, + 0x94, 0xc7, 0x9a, 0x36, 0x9c, 0xda, 0x33, 0xa7}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x5a, 0xdc, 0xb, 0x62, 0xaa, 0x2d, 0xf9, 0xc3, 0xd1, 0xbf, 0x5b, 0xc3, 0x45, - 0x95, 0xcd, 0x22, 0xcd, 0x7e, 0xf9, 0xd3, 0x3a, 0xd3, 0x65, 0x5a, 0xf8, 0x52}; - lwmqtt_string_t topic_filter_s3 = {26, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xa5, 0x4f, 0xff, 0x22, 0x8b, 0xb9, 0x87, 0xb7, 0x43, 0x6, 0x61, 0xd6, + 0x8f, 0x58, 0xad, 0xaf, 0xe1, 0x4b, 0xc8, 0xf7, 0xcd, 0x85, 0x91}; + lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa7, 0xf8, 0xf6, 0x8b, 0x9d, 0x7b, 0x9f, 0x74, 0x62, 0xa3, - 0xcc, 0x5f, 0xd2, 0x38, 0xb1, 0xc, 0xb6, 0xea, 0x1e, 0x3e, - 0x77, 0xb2, 0x5a, 0xfa, 0x16, 0xd2, 0xb2, 0x4c}; - lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xfa, 0x7a, 0xe2, 0xd8, 0xa1, 0x3, 0x6, 0x88, 0xce, 0x1b, - 0xad, 0x1f, 0xda, 0xf7, 0x18, 0xf, 0xd5, 0x29, 0x7a, 0x3e, - 0x7a, 0xbc, 0x2d, 0x45, 0xc3, 0x80, 0xb5, 0x4c, 0xf8, 0x27}; - lwmqtt_string_t topic_filter_s5 = {30, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x57, 0xb9, 0x69, 0x2, 0x38, 0x6e}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0}; - lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x2c, 0xf4, 0x4e, 0x91, 0x2e, 0x6f, 0xc8, 0xd3, 0x2e, 0xdd, 0x42, 0x7b, 0xb9}; - lwmqtt_string_t topic_filter_s8 = {13, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - lwmqtt_sub_options_t sub_opts[9]; + lwmqtt_sub_options_t sub_opts[4]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].qos = LWMQTT_QOS1; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS1; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[2].retain_as_published = false; sub_opts[2].no_local = false; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[4].retain_as_published = false; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS0; - sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = false; - uint8_t bytesprops0[] = {0xca, 0x27, 0xe3, 0x1c, 0x89, 0xce, 0x36, 0x26, 0x83, 0xe7, 0x36, 0xf2, 0x5, 0xa9}; - uint8_t bytesprops1[] = {0x92, 0x83, 0x2c, 0x24, 0x60, 0x3d, 0x32, 0x10, 0x88, - 0x4d, 0xb4, 0xb8, 0xcc, 0x79, 0x21, 0x7d, 0x3}; - uint8_t bytesprops2[] = {0x47, 0xc3, 0xee, 0x5c, 0x90, 0xa2, 0xe7, 0x87, 0xf9, 0x8c, 0x27, 0x98, 0xd5, 0x36, - 0xc8, 0x37, 0xb4, 0x55, 0xe3, 0xbf, 0x9, 0xb6, 0x66, 0x13, 0x76, 0x33, 0xf9, 0x5a}; - uint8_t bytesprops3[] = {0xf8, 0xce, 0xc3, 0x44, 0xa7, 0x26, 0x48, 0xbd, 0x61, 0x46, 0x64, 0x2c, 0x88}; + sub_opts[3].no_local = true; + uint8_t bytesprops0[] = {0x10, 0xcb, 0x9a, 0x3d, 0x43, 0x5, 0xd8, 0xf8, 0x44, 0x3, 0x1d, 0x26, 0x8c}; + uint8_t bytesprops1[] = {0x3, 0x29, 0xcf, 0x81, 0xbc, 0xd0, 0xee, 0x5f, 0xbd, 0x97, 0xe8, 0x85, + 0x5b, 0xbf, 0x46, 0x2e, 0x88, 0x25, 0x62, 0x4, 0x6, 0x6e, 0x18}; + uint8_t bytesprops2[] = {0x43, 0xe, 0xa4, 0xf7, 0x55, 0x4f, 0x87, 0x51, + 0x1f, 0x45, 0x9b, 0xdd, 0xe, 0xa5, 0xad, 0xb9}; + uint8_t bytesprops3[] = {0x9b, 0xfa, 0xe1, 0xb4, 0x81, 0xbd, 0x12, 0x31, 0x4e, 0x1c, 0xca, 0xd7, + 0x19, 0xc9, 0xfa, 0xed, 0x63, 0x2e, 0x6a, 0xaa, 0x3c, 0x18, 0x43}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 2019}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19515}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 11361}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14955}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 101}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 20161}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8548}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 243}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 239}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21212}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 122}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29493}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 52}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32026}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 68}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30179}}, }; - lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21249, 9, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 32237 [("4kW\253\213\191\228\173\&8\EM\n",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("n\199=\255]\ETX\237\&4\249V\187\139\228\DELVS\208~\231\232\208\203\187JH\153D\214\183",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("I\199\145I:\210\ETX\150\215N\aE3l\184",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = -// False, _noLocal = True, _subQoS = -// QoS2}),("\NAK6\182D\195\163\&3y\228P\236\212\201\235T\a\151\SUB4\235\185\ETBs",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("\128j\150\163\160%mXs\152",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, -// _noLocal = True, _subQoS = QoS0})] [PropSubscriptionIdentifier 31,PropMaximumQoS 183,PropSubscriptionIdentifier -// 15,PropSessionExpiryInterval 3789,PropReceiveMaximum 2999] + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30364, 4, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 13751 [("\156f\255\253ey\FSZ\232\SUB\185\t\US\178\&8\232f\133\ETB\162|4\206\CAN",SubOptions +// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS0}),("\177\205\213\234\248\167\223\230\217\206W\NUL",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropUserProperty +// "\200\\:\141^\176\246]1\244\221\233'\222\160I" "@\201\129\237\147-I\195Ob\175N\130",PropWildcardSubscriptionAvailable +// 227,PropServerKeepAlive 17266,PropMaximumPacketSize 30941,PropServerKeepAlive 20047,PropAuthenticationMethod +// "\196\228\211c\RS\192\&6\216\231\252",PropServerReference +// "i\134\151\SI\133\174\SI\177\DC4\253\177\f\164M\251\134:G\232\DEL\197N\145idg",PropAuthenticationData "\SUB +// \248\204\140~\241\STX\131\SO\167=!m\240\NAK\152\241:\SOH\ESC\158\180\161\DEL\206k",PropReceiveMaximum +// 16347,PropSubscriptionIdentifierAvailable 104,PropCorrelationData "%\193L+\220K\175\146\229\152\253\182\210\f/\137: +// \SUB\USB\129\198\136\231\251\230\250\222P",PropAuthenticationMethod +// "\217\148\DC4\131\140\212\170\226\t\245B\176\135|/\252\DLE\242\161\NAK\188\174c|",PropReceiveMaximum +// 3101,PropSubscriptionIdentifier 28,PropCorrelationData +// "\233Zy\240\143\133\STXK{Q\158T\239N8N\194\187!\163\r\133[:\236\DLE\139\191\221",PropContentType +// "\211",PropAuthenticationMethod "",PropRetainAvailable 219,PropAssignedClientIdentifier +// "\245:\EOTc(\202\138",PropTopicAliasMaximum 7978,PropResponseInformation "",PropMaximumPacketSize +// 7006,PropRequestResponseInformation 117,PropReceiveMaximum 31618,PropReceiveMaximum +// 20451,PropWildcardSubscriptionAvailable 3,PropMaximumPacketSize 327,PropAssignedClientIdentifier +// "Y\238R\165oj\165\250K\ENQ\ENQE6\240"] TEST(Subscribe5QCTest, Encode21) { - uint8_t pkt[] = {0x82, 0x78, 0x7d, 0xed, 0xe, 0xb, 0x1f, 0x24, 0xb7, 0xb, 0xf, 0x11, 0x0, 0x0, 0xe, 0xcd, - 0x21, 0xb, 0xb7, 0x0, 0xb, 0x34, 0x6b, 0x57, 0xfd, 0xd5, 0xbf, 0xe4, 0xad, 0x38, 0x19, 0xa, - 0x25, 0x0, 0x1d, 0x6e, 0xc7, 0x3d, 0xff, 0x5d, 0x3, 0xed, 0x34, 0xf9, 0x56, 0xbb, 0x8b, 0xe4, - 0x7f, 0x56, 0x53, 0xd0, 0x7e, 0xe7, 0xe8, 0xd0, 0xcb, 0xbb, 0x4a, 0x48, 0x99, 0x44, 0xd6, 0xb7, - 0x1d, 0x0, 0xf, 0x49, 0xc7, 0x91, 0x49, 0x3a, 0xd2, 0x3, 0x96, 0xd7, 0x4e, 0x7, 0x45, 0x33, - 0x6c, 0xb8, 0x6, 0x0, 0x17, 0x15, 0x36, 0xb6, 0x44, 0xc3, 0xa3, 0x33, 0x79, 0xe4, 0x50, 0xec, - 0xd4, 0xc9, 0xeb, 0x54, 0x7, 0x97, 0x1a, 0x34, 0xeb, 0xb9, 0x17, 0x73, 0xa, 0x0, 0xa, 0x80, - 0x6a, 0x96, 0xa3, 0xa0, 0x25, 0x6d, 0x58, 0x73, 0x98, 0x2c}; + uint8_t pkt[] = { + 0x82, 0xc9, 0x2, 0x35, 0xb7, 0x9b, 0x2, 0x26, 0x0, 0x10, 0xc8, 0x5c, 0x3a, 0x8d, 0x5e, 0xb0, 0xf6, 0x5d, 0x31, + 0xf4, 0xdd, 0xe9, 0x27, 0xde, 0xa0, 0x49, 0x0, 0xd, 0x40, 0xc9, 0x81, 0xed, 0x93, 0x2d, 0x49, 0xc3, 0x4f, 0x62, + 0xaf, 0x4e, 0x82, 0x28, 0xe3, 0x13,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xdd, + 0x3, 0x0, 0x1, 0xd3, 0x15, 0x0, 0x0, 0x25, 0xdb, 0x12, 0x0, 0x7, 0xf5, 0x3a, 0x4, 0x63, 0x28, 0xca, 0x8a, + 0x22, 0x1f, 0x2a, 0x1a, 0x0, 0x0, 0x27, 0x0, 0x0, 0x1b, 0x5e, 0x19, 0x75, 0x21, 0x7b, 0x82, 0x21, 0x4f, 0xe3, + 0x28, 0x3, 0x27, 0x0, 0x0, 0x1, 0x47, 0x12, 0x0, 0xe, 0x59, 0xee, 0x52, 0xa5, 0x6f, 0x6a, 0xa5, 0xfa, 0x4b, + 0x5, 0x5, 0x45, 0x36, 0xf0, 0x0, 0x18, 0x9c, 0x66, 0xff, 0xfd, 0x65, 0x79, 0x1c, 0x5a, 0xe8, 0x1a, 0xb9, 0x9, + 0x1f, 0xb2, 0x38, 0xe8, 0x66, 0x85, 0x17, 0xa2, 0x7c, 0x34, 0xce, 0x18, 0x4, 0x0, 0xc, 0xb1, 0xcd, 0xd5, 0xea, + 0xf8, 0xa7, 0xdf, 0xe6, 0xd9, 0xce, 0x57, 0x0, 0x2d}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[5]; - uint8_t topic_filter_s0_bytes[] = {0x34, 0x6b, 0x57, 0xfd, 0xd5, 0xbf, 0xe4, 0xad, 0x38, 0x19, 0xa}; - lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[2]; + uint8_t topic_filter_s0_bytes[] = {0x9c, 0x66, 0xff, 0xfd, 0x65, 0x79, 0x1c, 0x5a, 0xe8, 0x1a, 0xb9, 0x9, + 0x1f, 0xb2, 0x38, 0xe8, 0x66, 0x85, 0x17, 0xa2, 0x7c, 0x34, 0xce, 0x18}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6e, 0xc7, 0x3d, 0xff, 0x5d, 0x3, 0xed, 0x34, 0xf9, 0x56, - 0xbb, 0x8b, 0xe4, 0x7f, 0x56, 0x53, 0xd0, 0x7e, 0xe7, 0xe8, - 0xd0, 0xcb, 0xbb, 0x4a, 0x48, 0x99, 0x44, 0xd6, 0xb7}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xb1, 0xcd, 0xd5, 0xea, 0xf8, 0xa7, 0xdf, 0xe6, 0xd9, 0xce, 0x57, 0x0}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x49, 0xc7, 0x91, 0x49, 0x3a, 0xd2, 0x3, 0x96, - 0xd7, 0x4e, 0x7, 0x45, 0x33, 0x6c, 0xb8}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x15, 0x36, 0xb6, 0x44, 0xc3, 0xa3, 0x33, 0x79, 0xe4, 0x50, 0xec, 0xd4, - 0xc9, 0xeb, 0x54, 0x7, 0x97, 0x1a, 0x34, 0xeb, 0xb9, 0x17, 0x73}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x80, 0x6a, 0x96, 0xa3, 0xa0, 0x25, 0x6d, 0x58, 0x73, 0x98}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - lwmqtt_sub_options_t sub_opts[5]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + lwmqtt_sub_options_t sub_opts[2]; + sub_opts[0].qos = LWMQTT_QOS0; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = true; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS0; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = true; + uint8_t bytesprops1[] = {0x40, 0xc9, 0x81, 0xed, 0x93, 0x2d, 0x49, 0xc3, 0x4f, 0x62, 0xaf, 0x4e, 0x82}; + uint8_t bytesprops0[] = {0xc8, 0x5c, 0x3a, 0x8d, 0x5e, 0xb0, 0xf6, 0x5d, + 0x31, 0xf4, 0xdd, 0xe9, 0x27, 0xde, 0xa0, 0x49}; + uint8_t bytesprops2[] = {0xc4, 0xe4, 0xd3, 0x63, 0x1e, 0xc0, 0x36, 0xd8, 0xe7, 0xfc}; + uint8_t bytesprops3[] = {0x69, 0x86, 0x97, 0xf, 0x85, 0xae, 0xf, 0xb1, 0x14, 0xfd, 0xb1, 0xc, 0xa4, + 0x4d, 0xfb, 0x86, 0x3a, 0x47, 0xe8, 0x7f, 0xc5, 0x4e, 0x91, 0x69, 0x64, 0x67}; + uint8_t bytesprops4[] = {0x1a, 0x20, 0xf8, 0xcc, 0x8c, 0x7e, 0xf1, 0x2, 0x83, 0xe, 0xa7, 0x3d, 0x21, 0x6d, + 0xf0, 0x15, 0x98, 0xf1, 0x3a, 0x1, 0x1b, 0x9e, 0xb4, 0xa1, 0x7f, 0xce, 0x6b}; + uint8_t bytesprops5[] = {0x25, 0xc1, 0x4c, 0x2b, 0xdc, 0x4b, 0xaf, 0x92, 0xe5, 0x98, 0xfd, 0xb6, 0xd2, 0xc, 0x2f, + 0x89, 0x3a, 0x20, 0x1a, 0x1f, 0x42, 0x81, 0xc6, 0x88, 0xe7, 0xfb, 0xe6, 0xfa, 0xde, 0x50}; + uint8_t bytesprops6[] = {0xd9, 0x94, 0x14, 0x83, 0x8c, 0xd4, 0xaa, 0xe2, 0x9, 0xf5, 0x42, 0xb0, + 0x87, 0x7c, 0x2f, 0xfc, 0x10, 0xf2, 0xa1, 0x15, 0xbc, 0xae, 0x63, 0x7c}; + uint8_t bytesprops7[] = {0xe9, 0x5a, 0x79, 0xf0, 0x8f, 0x85, 0x2, 0x4b, 0x7b, 0x51, 0x9e, 0x54, 0xef, 0x4e, 0x38, + 0x4e, 0xc2, 0xbb, 0x21, 0xa3, 0xd, 0x85, 0x5b, 0x3a, 0xec, 0x10, 0x8b, 0xbf, 0xdd}; + uint8_t bytesprops8[] = {0xd3}; + uint8_t bytesprops9[] = {0}; + uint8_t bytesprops10[] = {0xf5, 0x3a, 0x4, 0x63, 0x28, 0xca, 0x8a}; + uint8_t bytesprops11[] = {0}; + uint8_t bytesprops12[] = {0x59, 0xee, 0x52, 0xa5, 0x6f, 0x6a, 0xa5, 0xfa, 0x4b, 0x5, 0x5, 0x45, 0x36, 0xf0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 31}}, {.prop = (lwmqtt_prop_t)36, .value = {.byte = 183}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3789}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2999}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 227}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17266}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 30941}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20047}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 16347}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 104}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 3101}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 28}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {1, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7978}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {0, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 7006}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31618}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20451}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 3}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 327}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops12}}}, }; - lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32237, 5, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13751, 2, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 1376 [(";\183\191\187\221\202\191\DC3FT\197\175\DC4\217>'\224\SIEx\189\194,",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("IaJ\ACK{\144@\ACK)XK\128\\7\ETX\159\146\SYN\141",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS0}),("o\209\197\246\162b\NAK\141\232A8\174\ACK\205\242+\ETX\SOHp\129\232\SUB\205\209&",SubOptions {_retainHandling -// = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\US",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropTopicAliasMaximum -// 3417,PropWildcardSubscriptionAvailable 14,PropAuthenticationMethod -// "\154\196\197Yi\207+\182\&4\179Y\170O\174YW\ETX0*Ga\240'/\144\NAK\DC1",PropCorrelationData -// "\159Mp\235\237\145Z\166}\bOz}H\228sPO\196\150\t\242\231\219\201\235\STX;\140%",PropRequestProblemInformation -// 205,PropSubscriptionIdentifier 14,PropWillDelayInterval 11750,PropAuthenticationMethod -// "\195\190y\139\237\226\177\&9\180\145\250\182\&1yLQ\229\185\245|\205",PropUserProperty -// "\133\144;j\FS\240\ETBCYC\SI\240(\199\151\135\186\241\182-G~\190\192(\206\218\227\252<" "\227$\196 ",PropTopicAlias -// 5360,PropAuthenticationData "\167\215\156\DEL.\221\f\190\141\139B,",PropAuthenticationData -// "\159\ETB",PropReceiveMaximum 13603,PropMessageExpiryInterval 30397,PropMessageExpiryInterval -// 19344,PropMessageExpiryInterval 29512,PropServerKeepAlive 4828,PropMaximumQoS 131,PropSharedSubscriptionAvailable -// 56,PropRetainAvailable 52,PropWillDelayInterval 22307,PropMaximumPacketSize 18923,PropCorrelationData -// "\132\204\197\179\&2\136"] +// SubscribeRequest 5555 [("IB\226\SO\ENQK\215\237\159\218\ETBzX+z\149#\145\153o\204v\161a",SubOptions {_retainHandling +// = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("6\181{\r\135\131?\223\ETB\141\245\141",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished +// = True, _noLocal = True, _subQoS = QoS2}),("\159\tW\206.OY\144\EOT\239\233\137u\SOH",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("&\186\209i\193\255\239e\229\211\225p\239\155\151Lr\130\&1v\174\220p\203\140",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\203w\ENQI\203\206\251\&5W\154cP\177\182\t\205\240m",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\205\DC4\SYN\172\130\192\ACK\245",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = True, _subQoS = +// QoS2}),("6\179\251\NUL\150\222\176\147y\USL\208\STXG",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("c\130\178\t\141",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = +// QoS2}),("g=E)SZD\234\245\255\SUB:YA\212\146\GS\203\197\NUL\247\187\r-]\177*\245p\222",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS1}),("",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("I\207",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] +// [PropContentType "\231Z\155K\188tm\131\206\157\148\157\225\242ie\216\165\145\248c\201\184\246\205",PropReasonString +// "%&_2m\170",PropSharedSubscriptionAvailable 166,PropServerReference +// "\ETX\ETX\147f\227\&2\t\177\204+\208\210\v\151\165\175o\201'\150\CAN\137\131",PropUserProperty "\156\135\211" +// "\164\132n-\158+\209:7\196v\128\180a\199<_\217)\229",PropTopicAlias 7232,PropAuthenticationData +// "\241P",PropSubscriptionIdentifierAvailable 196,PropSessionExpiryInterval 26391,PropPayloadFormatIndicator +// 98,PropWillDelayInterval 30691,PropReasonString +// "\202{\239\165\SOHa\EM<\216\232\143\158\131\STX\142\133\231\GS\210\172A\165\244\\\b",PropUserProperty "\179\212\179" +// "r\245",PropMaximumPacketSize 5578,PropAuthenticationMethod +// "\RS\bS\DC2\211\134\204n`\143\218\227\136\237\RS\216",PropRetainAvailable 172,PropServerKeepAlive +// 14809,PropAuthenticationMethod "\235,\140\186\EOT\247N\202\155\194i\255q\SO\128\198\155 +// \232\178\203\152\195\163\&1)",PropTopicAlias 20988,PropWillDelayInterval 29242,PropRetainAvailable +// 140,PropRequestResponseInformation 27,PropWildcardSubscriptionAvailable 122,PropMaximumPacketSize +// 16756,PropWildcardSubscriptionAvailable 89,PropAuthenticationData +// "\136\224Q\DC4\222\232\168x\224\r\148i/+$\227\SO\214,Z\233",PropCorrelationData ">\ETX?",PropCorrelationData +// "zH\242\150\187\203-\166\v':\166]\190/\SOH\139\133\219+4:'h-\246",PropSubscriptionIdentifier 27] TEST(Subscribe5QCTest, Encode22) { uint8_t pkt[] = { - 0x82, 0xa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0xea, 0xf5, 0xff, + 0x1a, 0x3a, 0x59, 0x41, 0xd4, 0x92, 0x1d, 0xcb, 0xc5, 0x0, 0xf7, 0xbb, 0xd, 0x2d, 0x5d, 0xb1, 0x2a, 0xf5, 0x70, + 0xde, 0x1, 0x0, 0x0, 0x15, 0x0, 0x2, 0x49, 0xcf, 0x28}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x3b, 0xb7, 0xbf, 0xbb, 0xdd, 0xca, 0xbf, 0x13, 0x46, 0x54, 0xc5, 0xaf, - 0x14, 0xd9, 0x3e, 0x27, 0xe0, 0xf, 0x45, 0x78, 0xbd, 0xc2, 0x2c}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x49, 0x42, 0xe2, 0xe, 0x5, 0x4b, 0xd7, 0xed, 0x9f, 0xda, 0x17, 0x7a, + 0x58, 0x2b, 0x7a, 0x95, 0x23, 0x91, 0x99, 0x6f, 0xcc, 0x76, 0xa1, 0x61}; + lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x49, 0x61, 0x4a, 0x6, 0x7b, 0x90, 0x40, 0x6, 0x29, 0x58, - 0x4b, 0x80, 0x5c, 0x37, 0x3, 0x9f, 0x92, 0x16, 0x8d}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x36, 0xb5, 0x7b, 0xd, 0x87, 0x83, 0x3f, 0xdf, 0x17, 0x8d, 0xf5, 0x8d}; + lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x6f, 0xd1, 0xc5, 0xf6, 0xa2, 0x62, 0x15, 0x8d, 0xe8, 0x41, 0x38, 0xae, 0x6, - 0xcd, 0xf2, 0x2b, 0x3, 0x1, 0x70, 0x81, 0xe8, 0x1a, 0xcd, 0xd1, 0x26}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x9f, 0x9, 0x57, 0xce, 0x2e, 0x4f, 0x59, 0x90, 0x4, 0xef, 0xe9, 0x89, 0x75, 0x1}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1f}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x26, 0xba, 0xd1, 0x69, 0xc1, 0xff, 0xef, 0x65, 0xe5, 0xd3, 0xe1, 0x70, 0xef, + 0x9b, 0x97, 0x4c, 0x72, 0x82, 0x31, 0x76, 0xae, 0xdc, 0x70, 0xcb, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {25, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - lwmqtt_sub_options_t sub_opts[4]; + uint8_t topic_filter_s4_bytes[] = {0xcb, 0x77, 0x5, 0x49, 0xcb, 0xce, 0xfb, 0x35, 0x57, + 0x9a, 0x63, 0x50, 0xb1, 0xb6, 0x9, 0xcd, 0xf0, 0x6d}; + lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xcd, 0x14, 0x16, 0xac, 0x82, 0xc0, 0x6, 0xf5}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x36, 0xb3, 0xfb, 0x0, 0x96, 0xde, 0xb0, 0x93, 0x79, 0x1f, 0x4c, 0xd0, 0x2, 0x47}; + lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x63, 0x82, 0xb2, 0x9, 0x8d}; + lwmqtt_string_t topic_filter_s7 = {5, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x67, 0x3d, 0x45, 0x29, 0x53, 0x5a, 0x44, 0xea, 0xf5, 0xff, + 0x1a, 0x3a, 0x59, 0x41, 0xd4, 0x92, 0x1d, 0xcb, 0xc5, 0x0, + 0xf7, 0xbb, 0xd, 0x2d, 0x5d, 0xb1, 0x2a, 0xf5, 0x70, 0xde}; + lwmqtt_string_t topic_filter_s8 = {30, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0}; + lwmqtt_string_t topic_filter_s9 = {0, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x49, 0xcf}; + lwmqtt_string_t topic_filter_s10 = {2, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[0].retain_as_published = true; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS2; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = false; + sub_opts[1].no_local = true; sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS1; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; - uint8_t bytesprops0[] = {0x9a, 0xc4, 0xc5, 0x59, 0x69, 0xcf, 0x2b, 0xb6, 0x34, 0xb3, 0x59, 0xaa, 0x4f, 0xae, - 0x59, 0x57, 0x3, 0x30, 0x2a, 0x47, 0x61, 0xf0, 0x27, 0x2f, 0x90, 0x15, 0x11}; - uint8_t bytesprops1[] = {0x9f, 0x4d, 0x70, 0xeb, 0xed, 0x91, 0x5a, 0xa6, 0x7d, 0x8, 0x4f, 0x7a, 0x7d, 0x48, 0xe4, - 0x73, 0x50, 0x4f, 0xc4, 0x96, 0x9, 0xf2, 0xe7, 0xdb, 0xc9, 0xeb, 0x2, 0x3b, 0x8c, 0x25}; - uint8_t bytesprops2[] = {0xc3, 0xbe, 0x79, 0x8b, 0xed, 0xe2, 0xb1, 0x39, 0xb4, 0x91, 0xfa, - 0xb6, 0x31, 0x79, 0x4c, 0x51, 0xe5, 0xb9, 0xf5, 0x7c, 0xcd}; - uint8_t bytesprops4[] = {0xe3, 0x24, 0xc4, 0x20}; - uint8_t bytesprops3[] = {0x85, 0x90, 0x3b, 0x6a, 0x1c, 0xf0, 0x17, 0x43, 0x59, 0x43, 0xf, 0xf0, 0x28, 0xc7, 0x97, - 0x87, 0xba, 0xf1, 0xb6, 0x2d, 0x47, 0x7e, 0xbe, 0xc0, 0x28, 0xce, 0xda, 0xe3, 0xfc, 0x3c}; - uint8_t bytesprops5[] = {0xa7, 0xd7, 0x9c, 0x7f, 0x2e, 0xdd, 0xc, 0xbe, 0x8d, 0x8b, 0x42, 0x2c}; - uint8_t bytesprops6[] = {0x9f, 0x17}; - uint8_t bytesprops7[] = {0x84, 0xcc, 0xc5, 0xb3, 0x32, 0x88}; - - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3417}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11750}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {30, (char*)&bytesprops3}, .v = {4, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5360}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13603}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30397}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19344}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29512}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4828}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 131}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 52}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22307}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18923}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops7}}}, - }; - - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - size_t len = 0; - lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1376, 4, topic_filters, sub_opts, props); - - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// SubscribeRequest 20213 [("\228\181kq\t",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS0}),("\217\&9\137\SYN\SUB\221t\182\SImim\223\212]",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\128",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\182\130\204\SOH\136\244\204\152",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = -// False, _noLocal = False, _subQoS = QoS1}),("\163\SI&zW\202\147_\174~O\152\137\242\205\DC3\131\180w -// \252\148",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("H\DELG\141Np",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1}),("b\201E\195z\240\\k\177\&0\240\216\209\199=\139\251\222\254\173",SubOptions {_retainHandling -// = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("cw,\227\r\161\128\EM:\197/\f\DEL\143\174\169\241\238&",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("-\131\DC3-/\EOTY\146\153]\138\149\250e\132m\EOTrrX\226",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1})] [PropServerReference -// "\ESC[a\203\142\130h\DC3\241\218\DC2",PropResponseInformation "\131\&5\a\225uB",PropSubscriptionIdentifier -// 29,PropAuthenticationMethod "*\178| -// (\t\230\220\221m\159\194\b\205\r\211\215\159\195\156\245\131\233\187\b\247\&7\183\133I",PropTopicAliasMaximum -// 22977,PropServerReference "\158\SOH\187",PropUserProperty "\163[(Z\241%hh\231m" -// "/\160\220\175Z\US\236\&8\231\EM\167=t\160",PropRequestResponseInformation 47,PropReasonString -// "\229A5\f\NAK\153\150\SYN\206\EM\166Th\219\STX\233",PropWildcardSubscriptionAvailable 148,PropWillDelayInterval -// 2769,PropPayloadFormatIndicator 147,PropSubscriptionIdentifier 5,PropReasonString "\ETB -// h\201A\138H\142\207\240\252\150\a\226\a\255\134*",PropCorrelationData "\198\132@D@*\DC1Q\152",PropWillDelayInterval -// 29082,PropAuthenticationMethod "\ETX\137\r\154\189o0m\202Wn<&\193dl",PropAuthenticationData -// "E!\195B5o\193\&6\212\129\DC2j\141\frEb\229\187a\STX\250\&0\215\214\200\185\233",PropPayloadFormatIndicator -// 107,PropServerReference -// "\220\225\221\DC3\146\190\\^\220\ETXd\EML\143t\157Z\153$p\SYN\222\181",PropAssignedClientIdentifier -// "\199\184\DEL\NUL{/\ETB\244\220\ENQx\229\159\a\188\172",PropMaximumPacketSize 26239,PropResponseInformation -// "\\\GStFU\192R\187\247\201\195\249\165\214\&9\138\&0b",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS2})] [PropMaximumQoS 235] -TEST(Subscribe5QCTest, Encode25) { - uint8_t pkt[] = {0x82, 0xae, 0x1, 0x34, 0x9d, 0x2, 0x24, 0xeb, 0x0, 0x7, 0x90, 0xc6, 0x97, 0x87, 0x14, 0x25, 0x6c, - 0x25, 0x0, 0xb, 0xf9, 0x1d, 0xf5, 0x48, 0xcf, 0xc6, 0xa2, 0x71, 0x46, 0xb8, 0x40, 0x1, 0x0, 0xb, - 0xc6, 0xa3, 0x56, 0xc9, 0xc7, 0x18, 0x70, 0xea, 0xa1, 0x61, 0xc, 0xe, 0x0, 0x4, 0xd4, 0x52, 0xd1, - 0x27, 0x5, 0x0, 0x12, 0x2, 0xc0, 0x97, 0xf1, 0x9d, 0xed, 0xd3, 0x81, 0x53, 0x41, 0x0, 0xbd, 0x7, - 0x8a, 0xa1, 0xcc, 0x89, 0x1e, 0x19, 0x0, 0x18, 0x61, 0xe1, 0x72, 0x56, 0x75, 0x10, 0x1f, 0x1, 0xf2, - 0xa6, 0x24, 0x35, 0xd9, 0x87, 0x3f, 0x2c, 0x10, 0xe5, 0x48, 0x46, 0xb4, 0x22, 0xcf, 0x97, 0x20, 0x0, - 0x2, 0xe8, 0xe0, 0x1, 0x0, 0xa, 0x6f, 0x49, 0xb3, 0xaf, 0xc5, 0xcc, 0xed, 0x2, 0xd8, 0xa7, 0x29, - 0x0, 0x4, 0x92, 0x47, 0x2a, 0xa5, 0x6, 0x0, 0x15, 0xb, 0x5, 0x55, 0xca, 0x72, 0x27, 0x98, 0xe4, - 0x2b, 0xe7, 0x64, 0x41, 0xb6, 0x4d, 0x53, 0xff, 0x2a, 0x89, 0x87, 0xaf, 0x28, 0x6, 0x0, 0x18, 0x2b, - 0xdd, 0x5e, 0x54, 0x37, 0xa1, 0xde, 0x1, 0x71, 0x3e, 0x55, 0xc0, 0x52, 0xbb, 0xf7, 0xc9, 0xc3, 0xf9, - 0xa5, 0xd6, 0x39, 0x8a, 0x30, 0x62, 0x2a}; +// QoS1}),("\195\191\198\v\219\177\249",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS1})] [PropRetainAvailable 65,PropMaximumQoS 196,PropAuthenticationData +// "\DC4\149\208\148\172y\SIe\DC3\163\138\SUB\170y\234\154\SI\SOH\\\247\242\135\&6\252o\192/",PropSubscriptionIdentifier +// 6,PropResponseTopic "\211I\247r\129\147",PropCorrelationData +// "\210O^!y\209\&1v\132\171\v\230\217K\176:ba\ENQ\138\172\252\139",PropPayloadFormatIndicator 40,PropResponseTopic +// "\220\134\254",PropAuthenticationMethod "fx\167\n\245\242\SI\131\&40Y\DLE",PropResponseTopic +// "\189\&7i\149\&5\178\154\147\159g\210\DC2\194\234\237B\131\171\151Rr\177\\k!\CAN"] +TEST(Subscribe5QCTest, Encode24) { + uint8_t pkt[] = { + 0x82, 0xce, 0x1, 0x38, 0x1f, 0x7b, 0x25, 0x41, 0x24, 0xc4, 0x16, 0x0, 0x1b, 0x14, 0x95, 0xd0, 0x94, 0xac, 0x79, + 0xf, 0x65, 0x13, 0xa3, 0x8a, 0x1a, 0xaa, 0x79, 0xea, 0x9a, 0xf, 0x1, 0x5c, 0xf7, 0xf2, 0x87, 0x36, 0xfc, 0x6f, + 0xc0, 0x2f, 0xb, 0x6, 0x8, 0x0, 0x6, 0xd3, 0x49, 0xf7, 0x72, 0x81, 0x93, 0x9, 0x0, 0x17, 0xd2, 0x4f, 0x5e, + 0x21, 0x79, 0xd1, 0x31, 0x76, 0x84, 0xab, 0xb, 0xe6, 0xd9, 0x4b, 0xb0, 0x3a, 0x62, 0x61, 0x5, 0x8a, 0xac, 0xfc, + 0x8b, 0x1, 0x28, 0x8, 0x0, 0x3, 0xdc, 0x86, 0xfe, 0x15, 0x0, 0xc, 0x66, 0x78, 0xa7, 0xa, 0xf5, 0xf2, 0xf, + 0x83, 0x34, 0x30, 0x59, 0x10, 0x8, 0x0, 0x1a, 0xbd, 0x37, 0x69, 0x95, 0x35, 0xb2, 0x9a, 0x93, 0x9f, 0x67, 0xd2, + 0x12, 0xc2, 0xea, 0xed, 0x42, 0x83, 0xab, 0x97, 0x52, 0x72, 0xb1, 0x5c, 0x6b, 0x21, 0x18, 0x0, 0x17, 0x2, 0xef, + 0x5a, 0x83, 0xaf, 0xdc, 0xc, 0xd9, 0x5f, 0xbd, 0x41, 0x22, 0x95, 0x3, 0x8d, 0xa5, 0x2d, 0xf4, 0x68, 0xd7, 0xab, + 0xa6, 0x29, 0x9, 0x0, 0x9, 0x9c, 0x8, 0x88, 0x3, 0x3, 0xd, 0xed, 0xa4, 0x7c, 0x0, 0x0, 0xa, 0xcd, 0x2e, + 0x59, 0x54, 0xb0, 0x91, 0x43, 0xac, 0xcb, 0xcc, 0x15, 0x0, 0x10, 0xf6, 0xe2, 0x5c, 0x2e, 0x7, 0x41, 0x29, 0x2c, + 0xab, 0xa9, 0xdd, 0xd6, 0x5c, 0x8e, 0x62, 0x43, 0x1, 0x0, 0x7, 0xc3, 0xbf, 0xc6, 0xb, 0xdb, 0xb1, 0xf9, 0x25}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x90, 0xc6, 0x97, 0x87, 0x14, 0x25, 0x6c}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x2, 0xef, 0x5a, 0x83, 0xaf, 0xdc, 0xc, 0xd9, 0x5f, 0xbd, 0x41, 0x22, + 0x95, 0x3, 0x8d, 0xa5, 0x2d, 0xf4, 0x68, 0xd7, 0xab, 0xa6, 0x29}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf9, 0x1d, 0xf5, 0x48, 0xcf, 0xc6, 0xa2, 0x71, 0x46, 0xb8, 0x40}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9c, 0x8, 0x88, 0x3, 0x3, 0xd, 0xed, 0xa4, 0x7c}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc6, 0xa3, 0x56, 0xc9, 0xc7, 0x18, 0x70, 0xea, 0xa1, 0x61, 0xc}; - lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xcd, 0x2e, 0x59, 0x54, 0xb0, 0x91, 0x43, 0xac, 0xcb, 0xcc}; + lwmqtt_string_t topic_filter_s2 = {10, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd4, 0x52, 0xd1, 0x27}; - lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xf6, 0xe2, 0x5c, 0x2e, 0x7, 0x41, 0x29, 0x2c, + 0xab, 0xa9, 0xdd, 0xd6, 0x5c, 0x8e, 0x62, 0x43}; + lwmqtt_string_t topic_filter_s3 = {16, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x2, 0xc0, 0x97, 0xf1, 0x9d, 0xed, 0xd3, 0x81, 0x53, - 0x41, 0x0, 0xbd, 0x7, 0x8a, 0xa1, 0xcc, 0x89, 0x1e}; - lwmqtt_string_t topic_filter_s4 = {18, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xc3, 0xbf, 0xc6, 0xb, 0xdb, 0xb1, 0xf9}; + lwmqtt_string_t topic_filter_s4 = {7, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x61, 0xe1, 0x72, 0x56, 0x75, 0x10, 0x1f, 0x1, 0xf2, 0xa6, 0x24, 0x35, - 0xd9, 0x87, 0x3f, 0x2c, 0x10, 0xe5, 0x48, 0x46, 0xb4, 0x22, 0xcf, 0x97}; - lwmqtt_string_t topic_filter_s5 = {24, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xe8, 0xe0}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x6f, 0x49, 0xb3, 0xaf, 0xc5, 0xcc, 0xed, 0x2, 0xd8, 0xa7}; - lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x92, 0x47, 0x2a, 0xa5}; - lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xb, 0x5, 0x55, 0xca, 0x72, 0x27, 0x98, 0xe4, 0x2b, 0xe7, 0x64, - 0x41, 0xb6, 0x4d, 0x53, 0xff, 0x2a, 0x89, 0x87, 0xaf, 0x28}; - lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x2b, 0xdd, 0x5e, 0x54, 0x37, 0xa1, 0xde, 0x1, 0x71, 0x3e, 0x55, 0xc0, - 0x52, 0xbb, 0xf7, 0xc9, 0xc3, 0xf9, 0xa5, 0xd6, 0x39, 0x8a, 0x30, 0x62}; - lwmqtt_string_t topic_filter_s10 = {24, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; - lwmqtt_sub_options_t sub_opts[11]; + lwmqtt_sub_options_t sub_opts[5]; sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = false; + sub_opts[1].qos = LWMQTT_QOS0; sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; - sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[2].retain_as_published = true; + sub_opts[2].qos = LWMQTT_QOS1; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_as_published = false; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[3].retain_as_published = false; - sub_opts[3].no_local = true; + sub_opts[3].no_local = false; sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - sub_opts[7].qos = LWMQTT_QOS1; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[8].retain_as_published = false; - sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS2; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = false; - sub_opts[9].no_local = true; - sub_opts[10].qos = LWMQTT_QOS2; - sub_opts[10].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[10].retain_as_published = true; - sub_opts[10].no_local = false; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + uint8_t bytesprops0[] = {0x14, 0x95, 0xd0, 0x94, 0xac, 0x79, 0xf, 0x65, 0x13, 0xa3, 0x8a, 0x1a, 0xaa, 0x79, + 0xea, 0x9a, 0xf, 0x1, 0x5c, 0xf7, 0xf2, 0x87, 0x36, 0xfc, 0x6f, 0xc0, 0x2f}; + uint8_t bytesprops1[] = {0xd3, 0x49, 0xf7, 0x72, 0x81, 0x93}; + uint8_t bytesprops2[] = {0xd2, 0x4f, 0x5e, 0x21, 0x79, 0xd1, 0x31, 0x76, 0x84, 0xab, 0xb, 0xe6, + 0xd9, 0x4b, 0xb0, 0x3a, 0x62, 0x61, 0x5, 0x8a, 0xac, 0xfc, 0x8b}; + uint8_t bytesprops3[] = {0xdc, 0x86, 0xfe}; + uint8_t bytesprops4[] = {0x66, 0x78, 0xa7, 0xa, 0xf5, 0xf2, 0xf, 0x83, 0x34, 0x30, 0x59, 0x10}; + uint8_t bytesprops5[] = {0xbd, 0x37, 0x69, 0x95, 0x35, 0xb2, 0x9a, 0x93, 0x9f, 0x67, 0xd2, 0x12, 0xc2, + 0xea, 0xed, 0x42, 0x83, 0xab, 0x97, 0x52, 0x72, 0xb1, 0x5c, 0x6b, 0x21, 0x18}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 235}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 65}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 6}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13469, 11, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14367, 5, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 9632 [("9\192\243\129\177\140\182\244C\213\169\203\&4z!Y\215\&3\200\FS|K\216)",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\150M\179",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, -// _subQoS = QoS2})] [PropAuthenticationData "P,\186K+\tq\225\141\&0\242A\243\128:",PropPayloadFormatIndicator 184] -TEST(Subscribe5QCTest, Encode26) { - uint8_t pkt[] = {0x82, 0x38, 0x25, 0xa0, 0x14, 0x16, 0x0, 0xf, 0x50, 0x2c, 0xba, 0x4b, 0x2b, 0x9, 0x71, - 0xe1, 0x8d, 0x30, 0xf2, 0x41, 0xf3, 0x80, 0x3a, 0x1, 0xb8, 0x0, 0x18, 0x39, 0xc0, 0xf3, - 0x81, 0xb1, 0x8c, 0xb6, 0xf4, 0x43, 0xd5, 0xa9, 0xcb, 0x34, 0x7a, 0x21, 0x59, 0xd7, 0x33, - 0xc8, 0x1c, 0x7c, 0x4b, 0xd8, 0x29, 0xd, 0x0, 0x3, 0x96, 0x4d, 0xb3, 0x12}; +// SubscribeRequest 19237 [(">\187+\226\DLE\US\194\164\194\165\171\166\128",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS0})] [PropTopicAliasMaximum +// 972,PropPayloadFormatIndicator 236,PropMaximumQoS 30,PropResponseInformation +// "\162\238\190\132Z\196yDHMt\220|",PropSessionExpiryInterval 4705,PropWillDelayInterval 27408,PropMaximumPacketSize +// 14655,PropAssignedClientIdentifier +// "\139-\213M\131n\162\USO*\226\214\166\&0\189Z`\182\FS\142\195\217\227",PropMessageExpiryInterval +// 19158,PropSubscriptionIdentifier 11,PropMessageExpiryInterval 65,PropServerReference +// "k?\217\255\190\239f#[\162&\162\180\218\146\206",PropResponseTopic "Tb\157\STX\140)e\RS",PropMessageExpiryInterval +// 15384,PropWillDelayInterval 3292,PropMessageExpiryInterval 6013,PropSharedSubscriptionAvailable +// 142,PropMessageExpiryInterval 634,PropPayloadFormatIndicator 136,PropContentType +// "\145\SOH_\FSt\154\166\245\&0)\188\236\SOH>N\196\"\NAK\215\169y",PropSubscriptionIdentifier 0,PropReceiveMaximum +// 822,PropAssignedClientIdentifier +// "\202\208z\173?B\147||-\229\SO\b\138\253Q\244\178\NAK\206z*t\135\134\253",PropMaximumQoS 58,PropServerKeepAlive +// 32474,PropWildcardSubscriptionAvailable 10,PropMessageExpiryInterval 22868,PropAuthenticationData +// "\214r4z\253\201\226L\224\164:\143\CANf\r\145\209\161o"] +TEST(Subscribe5QCTest, Encode25) { + uint8_t pkt[] = { + 0x82, 0xf2, 0x1, 0x4b, 0x25, 0xde, 0x1, 0x22, 0x3, 0xcc, 0x1, 0xec, 0x24, 0x1e, 0x1a, 0x0, 0xd, 0xa2, 0xee, + 0xbe, 0x84, 0x5a, 0xc4, 0x79, 0x44, 0x48, 0x4d, 0x74, 0xdc, 0x7c, 0x11, 0x0, 0x0, 0x12, 0x61, 0x18, 0x0, 0x0, + 0x6b, 0x10, 0x27, 0x0, 0x0, 0x39, 0x3f, 0x12, 0x0, 0x17, 0x8b, 0x2d, 0xd5, 0x4d, 0x83, 0x6e, 0xa2, 0x1f, 0x4f, + 0x2a, 0xe2, 0xd6, 0xa6, 0x30, 0xbd, 0x5a, 0x60, 0xb6, 0x1c, 0x8e, 0xc3, 0xd9, 0xe3, 0x2, 0x0, 0x0, 0x4a, 0xd6, + 0xb, 0xb, 0x2, 0x0, 0x0, 0x0, 0x41, 0x1c, 0x0, 0x10, 0x6b, 0x3f, 0xd9, 0xff, 0xbe, 0xef, 0x66, 0x23, 0x5b, + 0xa2, 0x26, 0xa2, 0xb4, 0xda, 0x92, 0xce, 0x8, 0x0, 0x8, 0x54, 0x62, 0x9d, 0x2, 0x8c, 0x29, 0x65, 0x1e, 0x2, + 0x0, 0x0, 0x3c, 0x18, 0x18, 0x0, 0x0, 0xc, 0xdc, 0x2, 0x0, 0x0, 0x17, 0x7d, 0x2a, 0x8e, 0x2, 0x0, 0x0, + 0x2, 0x7a, 0x1, 0x88, 0x3, 0x0, 0x15, 0x91, 0x1, 0x5f, 0x1c, 0x74, 0x9a, 0xa6, 0xf5, 0x30, 0x29, 0xbc, 0xec, + 0x1, 0x3e, 0x4e, 0xc4, 0x22, 0x15, 0xd7, 0xa9, 0x79, 0xb, 0x0, 0x21, 0x3, 0x36, 0x12, 0x0, 0x1a, 0xca, 0xd0, + 0x7a, 0xad, 0x3f, 0x42, 0x93, 0x7c, 0x7c, 0x2d, 0xe5, 0xe, 0x8, 0x8a, 0xfd, 0x51, 0xf4, 0xb2, 0x15, 0xce, 0x7a, + 0x2a, 0x74, 0x87, 0x86, 0xfd, 0x24, 0x3a, 0x13, 0x7e, 0xda, 0x28, 0xa, 0x2, 0x0, 0x0, 0x59, 0x54, 0x16, 0x0, + 0x13, 0xd6, 0x72, 0x34, 0x7a, 0xfd, 0xc9, 0xe2, 0x4c, 0xe0, 0xa4, 0x3a, 0x8f, 0x18, 0x66, 0xd, 0x91, 0xd1, 0xa1, + 0x6f, 0x0, 0xd, 0x3e, 0xbb, 0x2b, 0xe2, 0x10, 0x1f, 0xc2, 0xa4, 0xc2, 0xa5, 0xab, 0xa6, 0x80, 0x4}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x39, 0xc0, 0xf3, 0x81, 0xb1, 0x8c, 0xb6, 0xf4, 0x43, 0xd5, 0xa9, 0xcb, - 0x34, 0x7a, 0x21, 0x59, 0xd7, 0x33, 0xc8, 0x1c, 0x7c, 0x4b, 0xd8, 0x29}; - lwmqtt_string_t topic_filter_s0 = {24, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x3e, 0xbb, 0x2b, 0xe2, 0x10, 0x1f, 0xc2, 0xa4, 0xc2, 0xa5, 0xab, 0xa6, 0x80}; + lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x96, 0x4d, 0xb3}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; - sub_opts[0].qos = LWMQTT_QOS1; + lwmqtt_sub_options_t sub_opts[1]; + sub_opts[0].qos = LWMQTT_QOS0; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[0].retain_as_published = true; + sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[1].retain_as_published = false; - sub_opts[1].no_local = false; - uint8_t bytesprops0[] = {0x50, 0x2c, 0xba, 0x4b, 0x2b, 0x9, 0x71, 0xe1, 0x8d, 0x30, 0xf2, 0x41, 0xf3, 0x80, 0x3a}; + uint8_t bytesprops0[] = {0xa2, 0xee, 0xbe, 0x84, 0x5a, 0xc4, 0x79, 0x44, 0x48, 0x4d, 0x74, 0xdc, 0x7c}; + uint8_t bytesprops1[] = {0x8b, 0x2d, 0xd5, 0x4d, 0x83, 0x6e, 0xa2, 0x1f, 0x4f, 0x2a, 0xe2, 0xd6, + 0xa6, 0x30, 0xbd, 0x5a, 0x60, 0xb6, 0x1c, 0x8e, 0xc3, 0xd9, 0xe3}; + uint8_t bytesprops2[] = {0x6b, 0x3f, 0xd9, 0xff, 0xbe, 0xef, 0x66, 0x23, + 0x5b, 0xa2, 0x26, 0xa2, 0xb4, 0xda, 0x92, 0xce}; + uint8_t bytesprops3[] = {0x54, 0x62, 0x9d, 0x2, 0x8c, 0x29, 0x65, 0x1e}; + uint8_t bytesprops4[] = {0x91, 0x1, 0x5f, 0x1c, 0x74, 0x9a, 0xa6, 0xf5, 0x30, 0x29, 0xbc, + 0xec, 0x1, 0x3e, 0x4e, 0xc4, 0x22, 0x15, 0xd7, 0xa9, 0x79}; + uint8_t bytesprops5[] = {0xca, 0xd0, 0x7a, 0xad, 0x3f, 0x42, 0x93, 0x7c, 0x7c, 0x2d, 0xe5, 0xe, 0x8, + 0x8a, 0xfd, 0x51, 0xf4, 0xb2, 0x15, 0xce, 0x7a, 0x2a, 0x74, 0x87, 0x86, 0xfd}; + uint8_t bytesprops6[] = {0xd6, 0x72, 0x34, 0x7a, 0xfd, 0xc9, 0xe2, 0x4c, 0xe0, 0xa4, + 0x3a, 0x8f, 0x18, 0x66, 0xd, 0x91, 0xd1, 0xa1, 0x6f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 184}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 972}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {13, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4705}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27408}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14655}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19158}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 65}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15384}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3292}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6013}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 634}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 822}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32474}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 10}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22868}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 9632, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19237, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32536 [("\STXFdF1}k\173 c{\188a\199\bh$\SYN\179\&1\a6\DLE\DC1\181",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS1}),("{\238\131\204\f\255\221\189\217b\165\148-\170\248\223\222\134{\151p\247\153\164\n",SubOptions +// SubscribeRequest 799 [("\156\220HPZ\146\176",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = +// False, _noLocal = True, _subQoS = QoS2}),("\204\t\251\&4\140^\198\158P\165\GS\253\182\234",SubOptions // {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\137\236\169\249\206aNj\160O\152b\176\230M\205\GS\146\184\213",SubOptions {_retainHandling = -// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("N=\251\238D\139\DC3\SYNL\154))\182\221\132\150\225",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\223!\135V\191\128\&4\190\223\171\&3\234][\195%\175\f||mp\"\214\252\170",SubOptions {_retainHandling = -// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS2}),("r\158\170l\"uyP\tR\f\152\176\140\213\227\&6I\249\187A\177\&7\159\136",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),("\163\196",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] -// [PropWillDelayInterval 24166,PropAuthenticationMethod -// "\217\233\133\130\221\220\156\178\244\&9\241\225|",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS2}),(":8\155.\207\150\DC1\180c\182",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\232^\US\247\EMU\223ra\135U+K",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS0}),("Py\226\FSi_\194\179\221\138\196\208\239\131r{\173n",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("d\254\197\229\182\216;<*\ETX\ENQ",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, +// _noLocal = True, _subQoS = QoS2}),("\141P\243\129=\177V\214",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = True, _noLocal = True, _subQoS = QoS1}),("\164c",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = QoS2})] +// [PropWildcardSubscriptionAvailable 139,PropAssignedClientIdentifier "\178\215n\FS\139\147\ETX\EM +// ",PropSubscriptionIdentifierAvailable 226,PropUserProperty "\147\&1%$\222#" +// "\150{\199\241\157\177\&3\ACK\ESC\246\136\FS\172\143\143\207\179\228\224\131\201\154\203\255\242\156\137}",PropSharedSubscriptionAvailable +// 141,PropTopicAliasMaximum 12916,PropSharedSubscriptionAvailable 21,PropUserProperty "\230\&3\189\&6\fl\SYN\NAK\DC2" +// "n8\131b\161\&5\159\154\128\194\194\225>\234O\145\153\&6zV",PropAuthenticationData +// "\221|\143\f",PropPayloadFormatIndicator 153,PropServerKeepAlive 8558,PropSubscriptionIdentifier 26,PropContentType +// "k\172\f\135\155\&7@\142\b\165\154^\144\t,\190\216",PropMessageExpiryInterval 11221,PropMessageExpiryInterval +// 2390,PropUserProperty "" "\128U\206:\255%\145e"] +TEST(Subscribe5QCTest, Encode26) { uint8_t pkt[] = { - 0x82, 0xf6, 0x2, 0x7f, 0x18, 0xd1, 0x1, 0x18, 0x0, 0x0, 0x5e, 0x66, 0x15, 0x0, 0x1b, 0xd9, 0x3c, 0x7a, 0x73, - 0xa8, 0x36, 0xaa, 0x61, 0xc4, 0xe7, 0x70, 0x28, 0xb7, 0xf5, 0xde, 0x81, 0x8a, 0x38, 0x9d, 0x95, 0x21, 0x40, 0xd9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xb2, 0xf4, 0x39, 0xf1, 0xe1, + 0x7c, 0x16, 0x0, 0xa, 0x3a, 0x38, 0x9b, 0x2e, 0xcf, 0x96, 0x11, 0xb4, 0x63, 0xb6, 0x2a, 0x0, 0xd, 0xe8, 0x5e, + 0x1f, 0xf7, 0x19, 0x55, 0xdf, 0x72, 0x61, 0x87, 0x55, 0x2b, 0x4b, 0x14, 0x0, 0x12, 0x50, 0x79, 0xe2, 0x1c, 0x69, + 0x5f, 0xc2, 0xb3, 0xdd, 0x8a, 0xc4, 0xd0, 0xef, 0x83, 0x72, 0x7b, 0xad, 0x6e, 0x5, 0x0, 0xb, 0x64, 0xfe, 0xc5, + 0xe5, 0xb6, 0xd8, 0x3b, 0x3c, 0x2a, 0x3, 0x5, 0x6, 0x0, 0x8, 0x8d, 0x50, 0xf3, 0x81, 0x3d, 0xb1, 0x56, 0xd6, + 0xd, 0x0, 0x2, 0xa4, 0x63, 0x12}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x2, 0x46, 0x64, 0x46, 0x31, 0x7d, 0x6b, 0xad, 0x20, 0x63, 0x7b, 0xbc, 0x61, - 0xc7, 0x8, 0x68, 0x24, 0x16, 0xb3, 0x31, 0x7, 0x36, 0x10, 0x11, 0xb5}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x9c, 0xdc, 0x48, 0x50, 0x5a, 0x92, 0xb0}; + lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7b, 0xee, 0x83, 0xcc, 0xc, 0xff, 0xdd, 0xbd, 0xd9, 0x62, 0xa5, 0x94, 0x2d, - 0xaa, 0xf8, 0xdf, 0xde, 0x86, 0x7b, 0x97, 0x70, 0xf7, 0x99, 0xa4, 0xa}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xcc, 0x9, 0xfb, 0x34, 0x8c, 0x5e, 0xc6, 0x9e, 0x50, 0xa5, 0x1d, 0xfd, 0xb6, 0xea}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x89, 0xec, 0xa9, 0xf9, 0xce, 0x61, 0x4e, 0x6a, 0xa0, 0x4f, - 0x98, 0x62, 0xb0, 0xe6, 0x4d, 0xcd, 0x1d, 0x92, 0xb8, 0xd5}; - lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8c, 0xad, 0xaa, 0x2e, 0x95, 0x99, 0x90}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x4e, 0x3d, 0xfb, 0xee, 0x44, 0x8b, 0x13, 0x16, 0x4c, - 0x9a, 0x29, 0x29, 0xb6, 0xdd, 0x84, 0x96, 0xe1}; - lwmqtt_string_t topic_filter_s3 = {17, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x73, 0x20, 0xab, 0x9c, 0x2f, 0x2d, 0x6c, 0x56, 0xb8, 0x20, + 0x9b, 0x67, 0xa5, 0xc6, 0x73, 0x66, 0xb4, 0x3e, 0xe9, 0x85, + 0x82, 0xdd, 0xdc, 0x9c, 0xb2, 0xf4, 0x39, 0xf1, 0xe1, 0x7c}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xdf, 0x21, 0x87, 0x56, 0xbf, 0x80, 0x34, 0xbe, 0xdf, 0xab, 0x33, 0xea, 0x5d, - 0x5b, 0xc3, 0x25, 0xaf, 0xc, 0x7c, 0x7c, 0x6d, 0x70, 0x22, 0xd6, 0xfc, 0xaa}; - lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x3a, 0x38, 0x9b, 0x2e, 0xcf, 0x96, 0x11, 0xb4, 0x63, 0xb6}; + lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x72, 0x9e, 0xaa, 0x6c, 0x22, 0x75, 0x79, 0x50, 0x9, 0x52, 0xc, 0x98, 0xb0, - 0x8c, 0xd5, 0xe3, 0x36, 0x49, 0xf9, 0xbb, 0x41, 0xb1, 0x37, 0x9f, 0x88}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe8, 0x5e, 0x1f, 0xf7, 0x19, 0x55, 0xdf, 0x72, 0x61, 0x87, 0x55, 0x2b, 0x4b}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa3, 0xc4}; - lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x50, 0x79, 0xe2, 0x1c, 0x69, 0x5f, 0xc2, 0xb3, 0xdd, + 0x8a, 0xc4, 0xd0, 0xef, 0x83, 0x72, 0x7b, 0xad, 0x6e}; + lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - lwmqtt_sub_options_t sub_opts[7]; - sub_opts[0].qos = LWMQTT_QOS1; - sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + uint8_t topic_filter_s7_bytes[] = {0x64, 0xfe, 0xc5, 0xe5, 0xb6, 0xd8, 0x3b, 0x3c, 0x2a, 0x3, 0x5}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x8d, 0x50, 0xf3, 0x81, 0x3d, 0xb1, 0x56, 0xd6}; + lwmqtt_string_t topic_filter_s8 = {8, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0xa4, 0x63}; + lwmqtt_string_t topic_filter_s9 = {2, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + lwmqtt_sub_options_t sub_opts[10]; + sub_opts[0].qos = LWMQTT_QOS2; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[0].retain_as_published = false; sub_opts[0].no_local = true; - sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].qos = LWMQTT_QOS2; sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = false; sub_opts[2].qos = LWMQTT_QOS2; - sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = false; - sub_opts[2].no_local = false; + sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS2; - sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[4].retain_as_published = true; sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS2; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = false; sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS0; + sub_opts[6].qos = LWMQTT_QOS1; sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = false; - sub_opts[6].no_local = false; - uint8_t bytesprops0[] = {0xd9, 0x3c, 0x7a, 0x73, 0xa8, 0x36, 0xaa, 0x61, 0xc4, 0xe7, 0x70, 0x28, 0xb7, 0xf5, - 0xde, 0x81, 0x8a, 0x38, 0x9d, 0x95, 0x21, 0x40, 0xd9, 0x2f, 0x4f, 0x4c, 0x5}; - uint8_t bytesprops1[] = {0x75, 0xff, 0x3c, 0x4, 0x70, 0xfd, 0x9f, 0x46, 0x6, 0xba, 0x1b, 0x1c, 0x80, - 0x8e, 0x81, 0x79, 0x91, 0x3, 0xa0, 0x12, 0x41, 0x6b, 0xe1, 0xf7, 0x54}; - uint8_t bytesprops3[] = {0xee, 0xc4, 0x78, 0xe, 0x55, 0xd8, 0xc, 0x87, 0x41, 0x53, 0xb2, 0x0, 0x8, 0xa2, 0x6d}; - uint8_t bytesprops2[] = {0xaa, 0x4a, 0xe8, 0xc7, 0xa7, 0x65, 0xe0, 0x16, 0xc0, 0x87, 0x93, 0xa6, 0x4b, 0x9b}; - uint8_t bytesprops4[] = {0x50, 0xec, 0x87, 0xca, 0xab, 0x2b, 0x63, 0x75, 0xbe, 0x65, 0x88, 0x41, 0xe5, 0xa6, 0xc6}; - uint8_t bytesprops5[] = {0xcd, 0x2a, 0x9f, 0xe8, 0x78, 0x4c, 0xfc, 0xdf, - 0x15, 0xc0, 0xcd, 0xba, 0xf1, 0xc5, 0x72, 0xb4}; - uint8_t bytesprops6[] = {0x42, 0x75, 0x51, 0x8f}; - uint8_t bytesprops7[] = {0x78, 0xfd, 0x7c, 0xae, 0x70, 0xe8}; - uint8_t bytesprops8[] = {0xde, 0x70, 0xee}; + sub_opts[6].no_local = true; + sub_opts[7].qos = LWMQTT_QOS2; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].retain_as_published = false; + sub_opts[7].no_local = true; + sub_opts[8].qos = LWMQTT_QOS1; + sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[8].retain_as_published = true; + sub_opts[8].no_local = true; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[9].retain_as_published = false; + sub_opts[9].no_local = false; + uint8_t bytesprops0[] = {0xb2, 0xd7, 0x6e, 0x1c, 0x8b, 0x93, 0x3, 0x19, 0x20}; + uint8_t bytesprops2[] = {0x96, 0x7b, 0xc7, 0xf1, 0x9d, 0xb1, 0x33, 0x6, 0x1b, 0xf6, 0x88, 0x1c, 0xac, 0x8f, + 0x8f, 0xcf, 0xb3, 0xe4, 0xe0, 0x83, 0xc9, 0x9a, 0xcb, 0xff, 0xf2, 0x9c, 0x89, 0x7d}; + uint8_t bytesprops1[] = {0x93, 0x31, 0x25, 0x24, 0xde, 0x23}; + uint8_t bytesprops4[] = {0x6e, 0x38, 0x83, 0x62, 0xa1, 0x35, 0x9f, 0x9a, 0x80, 0xc2, + 0xc2, 0xe1, 0x3e, 0xea, 0x4f, 0x91, 0x99, 0x36, 0x7a, 0x56}; + uint8_t bytesprops3[] = {0xe6, 0x33, 0xbd, 0x36, 0xc, 0x6c, 0x16, 0x15, 0x12}; + uint8_t bytesprops5[] = {0xdd, 0x7c, 0x8f, 0xc}; + uint8_t bytesprops6[] = {0x6b, 0xac, 0xc, 0x87, 0x9b, 0x37, 0x40, 0x8e, 0x8, + 0xa5, 0x9a, 0x5e, 0x90, 0x9, 0x2c, 0xbe, 0xd8}; + uint8_t bytesprops8[] = {0x80, 0x55, 0xce, 0x3a, 0xff, 0x25, 0x91, 0x65}; + uint8_t bytesprops7[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24166}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 199}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28652}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18286}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops2}, .v = {15, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 17591}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 88}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26483}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22659}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 187}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10250}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 37}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {6, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 19667}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {3, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {28, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 141}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12916}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops3}, .v = {20, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8558}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 26}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11221}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2390}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops7}, .v = {8, (char*)&bytesprops8}}}}, }; - lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + size_t len = 0; + lwmqtt_err_t err = + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 799, 10, topic_filters, sub_opts, props); + + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// SubscribeRequest 2526 [("\211\175",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal +// = True, _subQoS = QoS1}),("a?\SUB\v\176$\210A\128\248oSU\134\STX\236J,w",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS0}),("\EOTO\245G\249\200\n4\SI1\239\b\NAKto3",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = False, _subQoS = QoS0}),("t[^\ESC",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = QoS1})] [PropPayloadFormatIndicator +// 178,PropWildcardSubscriptionAvailable 190,PropResponseInformation +// "I\159\137k\r\156\168\182\229\221C\b\155\136\\\212|\t",PropAuthenticationMethod +// "\DC2\244o\189z,\EM\214\222\136+\179\252\ENQ\\D^\182\163K.",PropServerKeepAlive 21065,PropMessageExpiryInterval +// 16243,PropCorrelationData "\t\155\238\148\207\157Q+\171\131",PropReceiveMaximum 23618,PropSharedSubscriptionAvailable +// 211,PropMessageExpiryInterval 18766,PropWildcardSubscriptionAvailable 79,PropCorrelationData +// "6e\161\162Q\141\198\SYN\156\189\229\218\135,\216U\136\224\&5",PropUserProperty +// "\248\214\133r^\168\182mw\RS\154g!\245Hm\163\243y*8d\202\228\&6\162\248\208" +// "k\FS\SII\169\EOT\247UD'\140hx\220\ETB",PropServerReference "\SI<:\245",PropMaximumQoS +// 113,PropSharedSubscriptionAvailable 17,PropWildcardSubscriptionAvailable 32,PropResponseInformation +// "\206n8\ACK\174?\DC2\153\194\213:\249m,t\217\&3{\244\157\181\194nV",PropMaximumQoS 30,PropRequestResponseInformation +// 190,PropAuthenticationData "*{Q\SYN\DLE`i3~\210\158~\218i\234\152\227\&0\163\237",PropTopicAlias +// 27790,PropUserProperty "T\SYN5\231B&\t\NAK\251\170)\196&\240\247\253_A\SUB^J_;\238" +// "\247\253\211'\151\229\ETX\153",PropMessageExpiryInterval 4312,PropServerReference +// "]:\SOH\133;o\154\214K\187\161\201\191x\204el\129\131\SOH\137\241ENr\223\192\148",PropSharedSubscriptionAvailable +// 182] +TEST(Subscribe5QCTest, Encode27) { + uint8_t pkt[] = { + 0x82, 0xe2, 0x2, 0x9, 0xde, 0xa9, 0x2, 0x1, 0xb2, 0x28, 0xbe, 0x1a, 0x0, 0x12, 0x49, 0x9f, 0x89, 0x6b, 0xd, + 0x9c, 0xa8, 0xb6, 0xe5, 0xdd, 0x43, 0x8, 0x9b, 0x88, 0x5c, 0xd4, 0x7c, 0x9, 0x15, 0x0, 0x15, 0x12, 0xf4, 0x6f, + 0xbd, 0x7a, 0x2c, 0x19, 0xd6, 0xde, 0x88, 0x2b, 0xb3, 0xfc, 0x5, 0x5c, 0x44, 0x5e, 0xb6, 0xa3, 0x4b, 0x2e, 0x13, + 0x52, 0x49, 0x2, 0x0, 0x0, 0x3f, 0x73, 0x9, 0x0, 0xa, 0x9, 0x9b, 0xee, 0x94, 0xcf, 0x9d, 0x51, 0x2b, 0xab, + 0x83, 0x21, 0x5c, 0x42, 0x2a, 0xd3, 0x2, 0x0, 0x0, 0x49, 0x4e, 0x28, 0x4f, 0x9, 0x0, 0x13, 0x36, 0x65, 0xa1, + 0xa2, 0x51, 0x8d, 0xc6, 0x16, 0x9c, 0xbd, 0xe5, 0xda, 0x87, 0x2c, 0xd8, 0x55, 0x88, 0xe0, 0x35, 0x26, 0x0, 0x1c, + 0xf8, 0xd6, 0x85, 0x72, 0x5e, 0xa8, 0xb6, 0x6d, 0x77, 0x1e, 0x9a, 0x67, 0x21, 0xf5, 0x48, 0x6d, 0xa3, 0xf3, 0x79, + 0x2a, 0x38, 0x64, 0xca, 0xe4, 0x36, 0xa2, 0xf8, 0xd0, 0x0, 0xf, 0x6b, 0x1c, 0xf, 0x49, 0xa9, 0x4, 0xf7, 0x55, + 0x44, 0x27, 0x8c, 0x68, 0x78, 0xdc, 0x17, 0x1c, 0x0, 0x4, 0xf, 0x3c, 0x3a, 0xf5, 0x24, 0x71, 0x2a, 0x11, 0x28, + 0x20, 0x1a, 0x0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pkt) + 10] = {0}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xd3, 0xaf}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + uint8_t topic_filter_s1_bytes[] = {0x61, 0x3f, 0x1a, 0xb, 0xb0, 0x24, 0xd2, 0x41, 0x80, 0xf8, + 0x6f, 0x53, 0x55, 0x86, 0x2, 0xec, 0x4a, 0x2c, 0x77}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; + topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x4, 0x4f, 0xf5, 0x47, 0xf9, 0xc8, 0xa, 0x34, + 0xf, 0x31, 0xef, 0x8, 0x15, 0x74, 0x6f, 0x33}; + lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x74, 0x5b, 0x5e, 0x1b}; + lwmqtt_string_t topic_filter_s3 = {4, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + lwmqtt_sub_options_t sub_opts[4]; + sub_opts[0].qos = LWMQTT_QOS1; + sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[0].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS0; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[1].retain_as_published = true; + sub_opts[1].no_local = false; + sub_opts[2].qos = LWMQTT_QOS0; + sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[2].retain_as_published = false; + sub_opts[2].no_local = false; + sub_opts[3].qos = LWMQTT_QOS1; + sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + uint8_t bytesprops0[] = {0x49, 0x9f, 0x89, 0x6b, 0xd, 0x9c, 0xa8, 0xb6, 0xe5, + 0xdd, 0x43, 0x8, 0x9b, 0x88, 0x5c, 0xd4, 0x7c, 0x9}; + uint8_t bytesprops1[] = {0x12, 0xf4, 0x6f, 0xbd, 0x7a, 0x2c, 0x19, 0xd6, 0xde, 0x88, 0x2b, + 0xb3, 0xfc, 0x5, 0x5c, 0x44, 0x5e, 0xb6, 0xa3, 0x4b, 0x2e}; + uint8_t bytesprops2[] = {0x9, 0x9b, 0xee, 0x94, 0xcf, 0x9d, 0x51, 0x2b, 0xab, 0x83}; + uint8_t bytesprops3[] = {0x36, 0x65, 0xa1, 0xa2, 0x51, 0x8d, 0xc6, 0x16, 0x9c, 0xbd, + 0xe5, 0xda, 0x87, 0x2c, 0xd8, 0x55, 0x88, 0xe0, 0x35}; + uint8_t bytesprops5[] = {0x6b, 0x1c, 0xf, 0x49, 0xa9, 0x4, 0xf7, 0x55, 0x44, 0x27, 0x8c, 0x68, 0x78, 0xdc, 0x17}; + uint8_t bytesprops4[] = {0xf8, 0xd6, 0x85, 0x72, 0x5e, 0xa8, 0xb6, 0x6d, 0x77, 0x1e, 0x9a, 0x67, 0x21, 0xf5, + 0x48, 0x6d, 0xa3, 0xf3, 0x79, 0x2a, 0x38, 0x64, 0xca, 0xe4, 0x36, 0xa2, 0xf8, 0xd0}; + uint8_t bytesprops6[] = {0xf, 0x3c, 0x3a, 0xf5}; + uint8_t bytesprops7[] = {0xce, 0x6e, 0x38, 0x6, 0xae, 0x3f, 0x12, 0x99, 0xc2, 0xd5, 0x3a, 0xf9, + 0x6d, 0x2c, 0x74, 0xd9, 0x33, 0x7b, 0xf4, 0x9d, 0xb5, 0xc2, 0x6e, 0x56}; + uint8_t bytesprops8[] = {0x2a, 0x7b, 0x51, 0x16, 0x10, 0x60, 0x69, 0x33, 0x7e, 0xd2, + 0x9e, 0x7e, 0xda, 0x69, 0xea, 0x98, 0xe3, 0x30, 0xa3, 0xed}; + uint8_t bytesprops10[] = {0xf7, 0xfd, 0xd3, 0x27, 0x97, 0xe5, 0x3, 0x99}; + uint8_t bytesprops9[] = {0x54, 0x16, 0x35, 0xe7, 0x42, 0x26, 0x9, 0x15, 0xfb, 0xaa, 0x29, 0xc4, + 0x26, 0xf0, 0xf7, 0xfd, 0x5f, 0x41, 0x1a, 0x5e, 0x4a, 0x5f, 0x3b, 0xee}; + uint8_t bytesprops11[] = {0x5d, 0x3a, 0x1, 0x85, 0x3b, 0x6f, 0x9a, 0xd6, 0x4b, 0xbb, 0xa1, 0xc9, 0xbf, 0x78, + 0xcc, 0x65, 0x6c, 0x81, 0x83, 0x1, 0x89, 0xf1, 0x45, 0x4e, 0x72, 0xdf, 0xc0, 0x94}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 178}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 21065}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16243}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23618}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18766}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 79}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops4}, .v = {15, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 17}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 32}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 30}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27790}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops9}, .v = {8, (char*)&bytesprops10}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4312}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 182}}, + }; + + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32536, 7, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2526, 4, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 8552 [("]4\248\137\131\225_b\212\169\ETB\r",SubOptions {_retainHandling = SendOnSubscribeNew, -// _retainAsPublished = False, _noLocal = False, _subQoS = QoS2}),("\189\197\252R\ESC\GSJu",SubOptions {_retainHandling +// SubscribeRequest 20875 [("\204\138\132\154\245\&9=\219v\220Se\229\161Wh\183\183\198zd\248",SubOptions +// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS2}),("\RS\162h\189\t>\133L\199l'\244\164\235\180\194\221\SUB\DEL\226\157",SubOptions {_retainHandling = +// SendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS2}),("\254?\146]\b\244ZJ\CAN\SO\132",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, +// _noLocal = True, _subQoS = QoS1}),("m\186m/\\gx^\145\214|\209B\210\&4\174o\149`",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = +// QoS1}),("\SUBq\181A9\r\162p:\RS0\152-\191\GS\b\ESC\CAN{X\231\237:\158T\155>\209\246\247",SubOptions {_retainHandling // = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("8#\221F96b\232\216\162\191\129(\152\184\DEL",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS2}),("`\173\EM\193X\175l}[\182\b\194\146S0;0\ESCkSX#:",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),("\139E\182\226c{\194\248\214N?\196\221\221\195%<\SI9",SubOptions {_retainHandling = DoNotSendOnSubscribe, -// _retainAsPublished = True, _noLocal = False, _subQoS = QoS1}),("\134\147\229\f\251`A\191\GS",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("h\248Ay\190)%\\6\168\199",SubOptions {_retainHandling = SendOnSubscribeNew, _retainAsPublished = True, -// _noLocal = False, _subQoS = QoS0}),("\182\ETB\208\179\128\200\169RV\232=S+D\223S",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\172\216\203\210O\225",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, _noLocal = -// False, _subQoS = QoS1})] [] +// QoS2}),("i\250\186\175\SI\FSa\220\183\EM\160f*o\137n\164\&0",SubOptions {_retainHandling = SendOnSubscribeNew, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("6",SubOptions {_retainHandling = SendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS0}),("{4[\185\DC1\b\217\STXA\US",SubOptions +// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = +// QoS1}),("\253J\226,\219z\148\248 \194\152\ENQ\nD\209\164\199\201N\245\231\&7\216\244",SubOptions {_retainHandling = +// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = QoS0})] [PropAuthenticationMethod +// "\170\tH1\145\f\r*\200\&78,\SUB\188\214\164\247<\153",PropCorrelationData +// "}\193\239\200Gc\195\236\136GO\STXl\161}\FS",PropReasonString "\179W\r\197\158\245\&1",PropPayloadFormatIndicator +// 201,PropAuthenticationMethod "\169",PropCorrelationData +// "\FS*\187\&0\DC3\EM\170G{gF\237\ENQh\162d\137\207v",PropRequestResponseInformation 94] TEST(Subscribe5QCTest, Encode28) { - uint8_t pkt[] = {0x82, 0x96, 0x1, 0x21, 0x68, 0x0, 0x0, 0xc, 0x5d, 0x34, 0xf8, 0x89, 0x83, 0xe1, 0x5f, 0x62, 0xd4, - 0xa9, 0x17, 0xd, 0x12, 0x0, 0x8, 0xbd, 0xc5, 0xfc, 0x52, 0x1b, 0x1d, 0x4a, 0x75, 0x16, 0x0, 0x10, - 0x38, 0x23, 0xdd, 0x46, 0x39, 0x36, 0x62, 0xe8, 0xd8, 0xa2, 0xbf, 0x81, 0x28, 0x98, 0xb8, 0x7f, 0xe, - 0x0, 0x17, 0x60, 0xad, 0x19, 0xc1, 0x58, 0xaf, 0x6c, 0x7d, 0x5b, 0xb6, 0x8, 0xc2, 0x92, 0x53, 0x30, - 0x3b, 0x30, 0x1b, 0x6b, 0x53, 0x58, 0x23, 0x3a, 0x29, 0x0, 0x13, 0x8b, 0x45, 0xb6, 0xe2, 0x63, 0x7b, - 0xc2, 0xf8, 0xd6, 0x4e, 0x3f, 0xc4, 0xdd, 0xdd, 0xc3, 0x25, 0x3c, 0xf, 0x39, 0x29, 0x0, 0x9, 0x86, - 0x93, 0xe5, 0xc, 0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d, 0x6, + 0x0, 0xb, 0xfe, 0x3f, 0x92, 0x5d, 0x8, 0xf4, 0x5a, 0x4a, 0x18, 0xe, 0x84, 0xd, 0x0, 0x13, 0x6d, + 0xba, 0x6d, 0x2f, 0x5c, 0x67, 0x78, 0x5e, 0x91, 0xd6, 0x7c, 0xd1, 0x42, 0xd2, 0x34, 0xae, 0x6f, 0x95, + 0x60, 0x25, 0x0, 0x1e, 0x1a, 0x71, 0xb5, 0x41, 0x39, 0xd, 0xa2, 0x70, 0x3a, 0x1e, 0x30, 0x98, 0x2d, + 0xbf, 0x1d, 0x8, 0x1b, 0x18, 0x7b, 0x58, 0xe7, 0xed, 0x3a, 0x9e, 0x54, 0x9b, 0x3e, 0xd1, 0xf6, 0xf7, + 0x16, 0x0, 0x12, 0x69, 0xfa, 0xba, 0xaf, 0xf, 0x1c, 0x61, 0xdc, 0xb7, 0x19, 0xa0, 0x66, 0x2a, 0x6f, + 0x89, 0x6e, 0xa4, 0x30, 0x15, 0x0, 0x1, 0x36, 0x4, 0x0, 0xa, 0x7b, 0x34, 0x5b, 0xb9, 0x11, 0x8, + 0xd9, 0x2, 0x41, 0x1f, 0x29, 0x0, 0x18, 0xfd, 0x4a, 0xe2, 0x2c, 0xdb, 0x7a, 0x94, 0xf8, 0x20, 0xc2, + 0x98, 0x5, 0xa, 0x44, 0xd1, 0xa4, 0xc7, 0xc9, 0x4e, 0xf5, 0xe7, 0x37, 0xd8, 0xf4, 0x20}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x5d, 0x34, 0xf8, 0x89, 0x83, 0xe1, 0x5f, 0x62, 0xd4, 0xa9, 0x17, 0xd}; - lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xcc, 0x8a, 0x84, 0x9a, 0xf5, 0x39, 0x3d, 0xdb, 0x76, 0xdc, 0x53, + 0x65, 0xe5, 0xa1, 0x57, 0x68, 0xb7, 0xb7, 0xc6, 0x7a, 0x64, 0xf8}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbd, 0xc5, 0xfc, 0x52, 0x1b, 0x1d, 0x4a, 0x75}; - lwmqtt_string_t topic_filter_s1 = {8, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0xa2, 0x68, 0xbd, 0x9, 0x3e, 0x85, 0x4c, 0xc7, 0x6c, 0x27, + 0xf4, 0xa4, 0xeb, 0xb4, 0xc2, 0xdd, 0x1a, 0x7f, 0xe2, 0x9d}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x38, 0x23, 0xdd, 0x46, 0x39, 0x36, 0x62, 0xe8, - 0xd8, 0xa2, 0xbf, 0x81, 0x28, 0x98, 0xb8, 0x7f}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xfe, 0x3f, 0x92, 0x5d, 0x8, 0xf4, 0x5a, 0x4a, 0x18, 0xe, 0x84}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x60, 0xad, 0x19, 0xc1, 0x58, 0xaf, 0x6c, 0x7d, 0x5b, 0xb6, 0x8, 0xc2, - 0x92, 0x53, 0x30, 0x3b, 0x30, 0x1b, 0x6b, 0x53, 0x58, 0x23, 0x3a}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6d, 0xba, 0x6d, 0x2f, 0x5c, 0x67, 0x78, 0x5e, 0x91, 0xd6, + 0x7c, 0xd1, 0x42, 0xd2, 0x34, 0xae, 0x6f, 0x95, 0x60}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8b, 0x45, 0xb6, 0xe2, 0x63, 0x7b, 0xc2, 0xf8, 0xd6, 0x4e, - 0x3f, 0xc4, 0xdd, 0xdd, 0xc3, 0x25, 0x3c, 0xf, 0x39}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x1a, 0x71, 0xb5, 0x41, 0x39, 0xd, 0xa2, 0x70, 0x3a, 0x1e, + 0x30, 0x98, 0x2d, 0xbf, 0x1d, 0x8, 0x1b, 0x18, 0x7b, 0x58, + 0xe7, 0xed, 0x3a, 0x9e, 0x54, 0x9b, 0x3e, 0xd1, 0xf6, 0xf7}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x86, 0x93, 0xe5, 0xc, 0xfb, 0x60, 0x41, 0xbf, 0x1d}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x69, 0xfa, 0xba, 0xaf, 0xf, 0x1c, 0x61, 0xdc, 0xb7, + 0x19, 0xa0, 0x66, 0x2a, 0x6f, 0x89, 0x6e, 0xa4, 0x30}; + lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x68, 0xf8, 0x41, 0x79, 0xbe, 0x29, 0x25, 0x5c, 0x36, 0xa8, 0xc7}; - lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x36}; + lwmqtt_string_t topic_filter_s6 = {1, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb6, 0x17, 0xd0, 0xb3, 0x80, 0xc8, 0xa9, 0x52, - 0x56, 0xe8, 0x3d, 0x53, 0x2b, 0x44, 0xdf, 0x53}; - lwmqtt_string_t topic_filter_s7 = {16, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x7b, 0x34, 0x5b, 0xb9, 0x11, 0x8, 0xd9, 0x2, 0x41, 0x1f}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xac, 0xd8, 0xcb, 0xd2, 0x4f, 0xe1}; - lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xfd, 0x4a, 0xe2, 0x2c, 0xdb, 0x7a, 0x94, 0xf8, 0x20, 0xc2, 0x98, 0x5, + 0xa, 0x44, 0xd1, 0xa4, 0xc7, 0xc9, 0x4e, 0xf5, 0xe7, 0x37, 0xd8, 0xf4}; + lwmqtt_string_t topic_filter_s8 = {24, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; lwmqtt_sub_options_t sub_opts[9]; sub_opts[0].qos = LWMQTT_QOS2; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; sub_opts[1].qos = LWMQTT_QOS2; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; sub_opts[3].qos = LWMQTT_QOS1; sub_opts[3].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; - sub_opts[3].no_local = false; - sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; - sub_opts[5].qos = LWMQTT_QOS0; + sub_opts[3].retain_as_published = false; + sub_opts[3].no_local = true; + sub_opts[4].qos = LWMQTT_QOS2; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; + sub_opts[5].qos = LWMQTT_QOS1; sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; sub_opts[5].retain_as_published = false; - sub_opts[5].no_local = false; + sub_opts[5].no_local = true; sub_opts[6].qos = LWMQTT_QOS0; - sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[6].retain_as_published = false; + sub_opts[6].no_local = true; sub_opts[7].qos = LWMQTT_QOS1; sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[7].retain_as_published = true; - sub_opts[7].no_local = true; - sub_opts[8].qos = LWMQTT_QOS1; - sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; + sub_opts[7].no_local = false; + sub_opts[8].qos = LWMQTT_QOS0; + sub_opts[8].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = false; + uint8_t bytesprops0[] = {0xaa, 0x9, 0x48, 0x31, 0x91, 0xc, 0xd, 0x2a, 0xc8, 0x37, + 0x38, 0x2c, 0x1a, 0xbc, 0xd6, 0xa4, 0xf7, 0x3c, 0x99}; + uint8_t bytesprops1[] = {0x7d, 0xc1, 0xef, 0xc8, 0x47, 0x63, 0xc3, 0xec, + 0x88, 0x47, 0x4f, 0x2, 0x6c, 0xa1, 0x7d, 0x1c}; + uint8_t bytesprops2[] = {0xb3, 0x57, 0xd, 0xc5, 0x9e, 0xf5, 0x31}; + uint8_t bytesprops3[] = {0xa9}; + uint8_t bytesprops4[] = {0x1c, 0x2a, 0xbb, 0x30, 0x13, 0x19, 0xaa, 0x47, 0x7b, 0x67, + 0x46, 0xed, 0x5, 0x68, 0xa2, 0x64, 0x89, 0xcf, 0x76}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 94}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 8552, 9, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20875, 9, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 21918 [("\253`\DLE\211u\248\DLE\EM\254\171\202\139\231",SubOptions {_retainHandling = -// DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS0}),("\232K\189x\159_\CAN>\184'\159\128dT\156,Sx",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS0}),("\143\f\GS\206\232\253e\EOTnk\201\SOH\129\176\DLE}\249\186\178*\248C\143\134\192\232\DC1T",SubOptions +// SubscribeRequest 22546 [("f\185p\ENQ\162\139-.\158v+^\157\SUB",SubOptions {_retainHandling = DoNotSendOnSubscribe, +// _retainAsPublished = False, _noLocal = True, _subQoS = QoS1}),("\164\243\&8\128l\255}\242i4",SubOptions // {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = True, _subQoS = -// QoS2}),("\152\143d\215c\ACK\243*\227%\223e5a\210z}\170=7%c\157",SubOptions {_retainHandling = SendOnSubscribe, -// _retainAsPublished = True, _noLocal = True, _subQoS = QoS2}),("\213\\n\ETX\EM\163L\232\170",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = -// QoS1}),(".",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS = -// QoS1}),("\130$g=T];\221D\158\145\220\214\154",SubOptions {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished -// = True, _noLocal = False, _subQoS = QoS1}),(")?Gbx/Ti\252/-\ACK\149\&5\176\184\156\\\CAN\ENQ\GS\191",SubOptions -// {_retainHandling = DoNotSendOnSubscribe, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS2}),("\139~1f\212\151\NUL\158C_8P",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = False, -// _noLocal = True, _subQoS = QoS2}),("mt\246\185$\ENQjC\163\161\DC1\CAN\195\SO-i\224\241\208m",SubOptions -// {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = False, _subQoS = QoS0})] -// [PropReceiveMaximum 15228,PropPayloadFormatIndicator 153,PropMessageExpiryInterval 10918,PropAuthenticationMethod -// "\253\155)\236",PropAssignedClientIdentifier "\199Oy9\184\130\214SC",PropPayloadFormatIndicator -// 206,PropCorrelationData "\138v>\252\195\147\131\201\248\214W\210",PropRetainAvailable 151,PropPayloadFormatIndicator -// 31,PropMaximumQoS 75,PropReasonString "\212\f",PropSessionExpiryInterval 3402,PropAuthenticationMethod -// "?\181\217\248\DC3gG\177P\232\153\215\182\146\224\197\USyy",PropRequestProblemInformation 35,PropTopicAlias -// 15652,PropAuthenticationData "\DLE3|",PropUserProperty "A\213\211+eKtm2Yi\193\166\138" -// "\220\&4zq&|p\131M\167\NAK\SOHB\168d(u\SOH\254\187\196",PropAuthenticationMethod -// "\DEL",PropWildcardSubscriptionAvailable 87,PropAuthenticationData "\214_\a\ESC\180\155",PropWillDelayInterval -// 16782,PropSubscriptionIdentifier 31,PropCorrelationData "\144\154c\128\FS\142\252\231\234\129:V -// \130\DC3\EOT\149\158\187\200\149",PropWillDelayInterval +// 3768,PropAssignedClientIdentifier "+5Bz\CAN\199p\169\167}\179\137u8fC~e",PropMessageExpiryInterval +// 24032,PropServerKeepAlive 22317,PropAuthenticationMethod "\\\140\SOH\198\130\183",PropMaximumPacketSize +// 4777,PropAssignedClientIdentifier "\DC1\216\198\195",PropRetainAvailable 37,PropResponseTopic +// "#\163\240*o\223\215P>x\STX\SI\243r\DC2\181\249",PropReceiveMaximum 22096,PropResponseTopic +// "\156\137\182H\204o\202\EOT/\146\233\DEL\136^\SO\137\236M\228\DC4\ACK.\233",PropReasonString "+\232\135{\128\222 +// \163Y\EOT\153\134\245\198\162\167\236\DLE\248\213M>\131Q\208x\207w\\",PropWildcardSubscriptionAvailable +// 207,PropTopicAliasMaximum 7002,PropMessageExpiryInterval 14743] TEST(Subscribe5QCTest, Encode29) { uint8_t pkt[] = { - 0x82, 0xf7, 0x2, 0x55, 0x9e, 0xb5, 0x1, 0x21, 0x3b, 0x7c, 0x1, 0x99, 0x2, 0x0, 0x0, 0x2a, 0xa6, 0x15, 0x0, - 0x4, 0xfd, 0x9b, 0x29, 0xec, 0x12, 0x0, 0x9, 0xc7, 0x4f, 0x79, 0x39, 0xb8, 0x82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a, 0x80, 0x34, 0x55, 0xb8, 0xa8, 0xc9, 0x73, 0x7f, 0x2, 0x65, 0x31, 0xf0, 0x1e}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xfd, 0x60, 0x10, 0xd3, 0x75, 0xf8, 0x10, 0x19, 0xfe, 0xab, 0xca, 0x8b, 0xe7}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x66, 0xb9, 0x70, 0x5, 0xa2, 0x8b, 0x2d, 0x2e, 0x9e, 0x76, 0x2b, 0x5e, 0x9d, 0x1a}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe8, 0x4b, 0xbd, 0x78, 0x9f, 0x5f, 0x18, 0x3e, 0xb8, - 0x27, 0x9f, 0x80, 0x64, 0x54, 0x9c, 0x2c, 0x53, 0x78}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa4, 0xf3, 0x38, 0x80, 0x6c, 0xff, 0x7d, 0xf2, 0x69, 0x34}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8f, 0xc, 0x1d, 0xce, 0xe8, 0xfd, 0x65, 0x4, 0x6e, 0x6b, - 0xc9, 0x1, 0x81, 0xb0, 0x10, 0x7d, 0xf9, 0xba, 0xb2, 0x2a, - 0xf8, 0x43, 0x8f, 0x86, 0xc0, 0xe8, 0x11, 0x54}; - lwmqtt_string_t topic_filter_s2 = {28, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x35, 0xdf, 0x29, 0x27, 0x90, 0xbd, 0xc3, 0xd4, 0x6b, 0x7b, + 0x1d, 0xa5, 0x22, 0x1b, 0x2f, 0x2b, 0x25, 0x6d, 0xaf, 0xa1, + 0xeb, 0x15, 0xdf, 0x8e, 0xcd, 0xe1, 0x24, 0xe0, 0x17, 0xc}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x98, 0x8f, 0x64, 0xd7, 0x63, 0x6, 0xf3, 0x2a, 0xe3, 0x25, 0xdf, 0x65, - 0x35, 0x61, 0xd2, 0x7a, 0x7d, 0xaa, 0x3d, 0x37, 0x25, 0x63, 0x9d}; - lwmqtt_string_t topic_filter_s3 = {23, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x76, 0xa7, 0xb8, 0x46, 0xc6, 0x42, 0x5, 0x1b, 0x6, 0x30, 0x17, 0x7b, 0x66, 0x36, + 0xe4, 0x9, 0x61, 0xb9, 0xcf, 0x9a, 0xaf, 0xab, 0xbb, 0x7e, 0xaf, 0x8e, 0x27}; + lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xd5, 0x5c, 0x6e, 0x3, 0x19, 0xa3, 0x4c, 0xe8, 0xaa}; - lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xcc}; + lwmqtt_string_t topic_filter_s4 = {1, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x2e}; - lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xda, 0xf6, 0x32, 0x4, 0xa8, 0x24, 0x4, 0x4b, 0xde, 0x5c, 0x53, 0x5b, 0xf3}; + lwmqtt_string_t topic_filter_s5 = {13, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x82, 0x24, 0x67, 0x3d, 0x54, 0x5d, 0x3b, - 0xdd, 0x44, 0x9e, 0x91, 0xdc, 0xd6, 0x9a}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xd4, 0xd8, 0xa5, 0x74, 0x9, 0x70, 0x50, 0x61, 0xa7, 0x95, 0x93, 0xb, + 0x8, 0xe, 0xa3, 0xec, 0xe, 0xde, 0x2a, 0x40, 0x68, 0x9e, 0x26, 0xef}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x29, 0x3f, 0x47, 0x62, 0x78, 0x2f, 0x54, 0x69, 0xfc, 0x2f, 0x2d, - 0x6, 0x95, 0x35, 0xb0, 0xb8, 0x9c, 0x5c, 0x18, 0x5, 0x1d, 0xbf}; - lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xea, 0x6b, 0x70, 0xfc, 0x6b, 0x7a, 0x6b, 0xf, 0xf7, 0xf3, 0x32, 0xac, 0x1d, 0xde, + 0x1b, 0x5d, 0x37, 0xe8, 0xa6, 0xe6, 0x53, 0xae, 0x68, 0xc0, 0x25, 0x77, 0x98}; + lwmqtt_string_t topic_filter_s7 = {27, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x8b, 0x7e, 0x31, 0x66, 0xd4, 0x97, 0x0, 0x9e, 0x43, 0x5f, 0x38, 0x50}; - lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0x28, 0x7f, 0x92, 0x7, 0xde, 0x20}; + lwmqtt_string_t topic_filter_s8 = {6, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x6d, 0x74, 0xf6, 0xb9, 0x24, 0x5, 0x6a, 0x43, 0xa3, 0xa1, - 0x11, 0x18, 0xc3, 0xe, 0x2d, 0x69, 0xe0, 0xf1, 0xd0, 0x6d}; - lwmqtt_string_t topic_filter_s9 = {20, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0x8, 0x5f, 0xf9, 0x6e, 0xa9, 0x72, 0x30, 0x2a, 0x77, 0x5c, 0x5f, 0x79, 0x6d, + 0xc3, 0x4d, 0x70, 0xfd, 0x91, 0xc8, 0xd5, 0xef, 0x5d, 0x71, 0x88, 0x87}; + lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - lwmqtt_sub_options_t sub_opts[10]; - sub_opts[0].qos = LWMQTT_QOS0; + uint8_t topic_filter_s10_bytes[] = {0xae, 0x27, 0x53, 0xd, 0xfb, 0x5c, 0xfc, 0xc0, 0xfa, 0x80, 0x34, + 0x55, 0xb8, 0xa8, 0xc9, 0x73, 0x7f, 0x2, 0x65, 0x31, 0xf0}; + lwmqtt_string_t topic_filter_s10 = {21, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + lwmqtt_sub_options_t sub_opts[11]; + sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; sub_opts[0].retain_as_published = false; - sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS0; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; + sub_opts[0].no_local = true; + sub_opts[1].qos = LWMQTT_QOS1; + sub_opts[1].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[1].retain_as_published = false; sub_opts[1].no_local = true; - sub_opts[2].qos = LWMQTT_QOS2; + sub_opts[2].qos = LWMQTT_QOS1; sub_opts[2].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[2].retain_as_published = false; + sub_opts[2].retain_as_published = true; sub_opts[2].no_local = true; - sub_opts[3].qos = LWMQTT_QOS2; - sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[3].retain_as_published = true; + sub_opts[3].qos = LWMQTT_QOS0; + sub_opts[3].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[3].retain_as_published = false; sub_opts[3].no_local = true; sub_opts[4].qos = LWMQTT_QOS1; - sub_opts[4].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[4].retain_as_published = true; - sub_opts[4].no_local = false; + sub_opts[4].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[4].retain_as_published = false; + sub_opts[4].no_local = true; sub_opts[5].qos = LWMQTT_QOS1; - sub_opts[5].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; - sub_opts[5].retain_as_published = true; - sub_opts[5].no_local = true; - sub_opts[6].qos = LWMQTT_QOS1; - sub_opts[6].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[5].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[5].retain_as_published = false; + sub_opts[5].no_local = false; + sub_opts[6].qos = LWMQTT_QOS2; + sub_opts[6].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[6].retain_as_published = true; - sub_opts[6].no_local = false; + sub_opts[6].no_local = true; sub_opts[7].qos = LWMQTT_QOS2; - sub_opts[7].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[7].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[7].retain_as_published = false; sub_opts[7].no_local = false; - sub_opts[8].qos = LWMQTT_QOS2; + sub_opts[8].qos = LWMQTT_QOS0; sub_opts[8].retain_handling = LWMQTT_SUB_SEND_ON_SUB; sub_opts[8].retain_as_published = false; sub_opts[8].no_local = true; - sub_opts[9].qos = LWMQTT_QOS0; - sub_opts[9].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[9].retain_as_published = true; + sub_opts[9].qos = LWMQTT_QOS2; + sub_opts[9].retain_handling = LWMQTT_SUB_NO_SEND_ON_SUB; + sub_opts[9].retain_as_published = false; sub_opts[9].no_local = false; - uint8_t bytesprops0[] = {0xfd, 0x9b, 0x29, 0xec}; - uint8_t bytesprops1[] = {0xc7, 0x4f, 0x79, 0x39, 0xb8, 0x82, 0xd6, 0x53, 0x43}; - uint8_t bytesprops2[] = {0x8a, 0x76, 0x3e, 0xfc, 0xc3, 0x93, 0x83, 0xc9, 0xf8, 0xd6, 0x57, 0xd2}; - uint8_t bytesprops3[] = {0xd4, 0xc}; - uint8_t bytesprops4[] = {0x3f, 0xb5, 0xd9, 0xf8, 0x13, 0x67, 0x47, 0xb1, 0x50, 0xe8, - 0x99, 0xd7, 0xb6, 0x92, 0xe0, 0xc5, 0x1f, 0x79, 0x79}; - uint8_t bytesprops5[] = {0x10, 0x33, 0x7c}; - uint8_t bytesprops7[] = {0xdc, 0x34, 0x7a, 0x71, 0x26, 0x7c, 0x70, 0x83, 0x4d, 0xa7, 0x15, - 0x1, 0x42, 0xa8, 0x64, 0x28, 0x75, 0x1, 0xfe, 0xbb, 0xc4}; - uint8_t bytesprops6[] = {0x41, 0xd5, 0xd3, 0x2b, 0x65, 0x4b, 0x74, 0x6d, 0x32, 0x59, 0x69, 0xc1, 0xa6, 0x8a}; - uint8_t bytesprops8[] = {0x7f}; - uint8_t bytesprops9[] = {0xd6, 0x5f, 0x7, 0x1b, 0xb4, 0x9b}; - uint8_t bytesprops10[] = {0x90, 0x9a, 0x63, 0x80, 0x1c, 0x8e, 0xfc, 0xe7, 0xea, 0x81, 0x3a, - 0x56, 0x20, 0x82, 0x13, 0x3c, 0x4e, 0xfb, 0x6a, 0x90, 0x64}; + sub_opts[10].qos = LWMQTT_QOS2; + sub_opts[10].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; + sub_opts[10].retain_as_published = true; + sub_opts[10].no_local = true; + uint8_t bytesprops0[] = {0x6d, 0x22, 0x21, 0xe6, 0xc, 0xd0, 0x10, 0xbe, 0x43, 0xb6, 0x6f, 0x1d, + 0x5c, 0x97, 0xb6, 0xe, 0x5c, 0x3e, 0x4, 0x95, 0x9e, 0xbb, 0xc8, 0x95}; + uint8_t bytesprops1[] = {0x2b, 0x35, 0x42, 0x7a, 0x18, 0xc7, 0x70, 0xa9, 0xa7, + 0x7d, 0xb3, 0x89, 0x75, 0x38, 0x66, 0x43, 0x7e, 0x65}; + uint8_t bytesprops2[] = {0x5c, 0x8c, 0x1, 0xc6, 0x82, 0xb7}; + uint8_t bytesprops3[] = {0x11, 0xd8, 0xc6, 0xc3}; + uint8_t bytesprops4[] = {0x23, 0xa3, 0xf0, 0x2a, 0x6f, 0xdf, 0xd7, 0x50, 0x3e, + 0x78, 0x2, 0xf, 0xf3, 0x72, 0x12, 0xb5, 0xf9}; + uint8_t bytesprops5[] = {0x9c, 0x89, 0xb6, 0x48, 0xcc, 0x6f, 0xca, 0x4, 0x2f, 0x92, 0xe9, 0x7f, + 0x88, 0x5e, 0xe, 0x89, 0xec, 0x4d, 0xe4, 0x14, 0x6, 0x2e, 0xe9}; + uint8_t bytesprops6[] = {0x2b, 0xe8, 0x87, 0x7b, 0x80, 0xde, 0x20, 0xa3, 0x59, 0x4, 0x99, 0x86, 0xf5, 0xc6, 0xa2, + 0xa7, 0xec, 0x10, 0xf8, 0xd5, 0x4d, 0x3e, 0x83, 0x51, 0xd0, 0x78, 0xcf, 0x77, 0x5c}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15228}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10918}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 206}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 31}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3402}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15652}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {3, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {14, (char*)&bytesprops6}, .v = {21, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {1, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {6, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16782}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 31}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 3768}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24032}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22317}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {6, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4777}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 37}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22096}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 207}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7002}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14743}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21918, 10, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22546, 11, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeRequest 32402 [("\222d\154J\229\133\152\210\152Q\129\228R\184<\202\149\147\206\245\169",SubOptions -// {_retainHandling = SendOnSubscribeNew, _retainAsPublished = False, _noLocal = False, _subQoS = -// QoS1}),("\195\186",SubOptions {_retainHandling = SendOnSubscribe, _retainAsPublished = True, _noLocal = True, _subQoS -// = QoS1})] [] +// SubscribeRequest 790 [("uR,E\184\234\156:\161\&7Eb\249x\ACK\255KB\185\162Iu",SubOptions {_retainHandling = +// SendOnSubscribeNew, _retainAsPublished = True, _noLocal = False, _subQoS = QoS1})] [PropMaximumPacketSize +// 2930,PropReceiveMaximum 24517,PropResponseInformation "dj\219\204LK",PropResponseTopic +// "\245\DEL\246\182y\239\196^\164\249\241J\238\ESC\190\137@`\ESC-\241\CAN\235\198B{",PropAssignedClientIdentifier +// "\205\227\216N\191=\191 X#\ESC\\hA\216\129\DELK8\146{",PropReceiveMaximum 32093,PropReasonString +// "\221\197\DEL\247\193\200\233\182\177\SIU\197Z\240\190K\237%\208\192\217\183u\SYN\147",PropServerReference +// "@\DC1\152\173\DC3\219b\133\ETX\f\189\&3",PropAuthenticationData +// "\SYNr\245\249\178\RSRV+\132J",PropRequestProblemInformation 245,PropCorrelationData +// "\154k\147m\155\228\237\ACK\130\SI?\144\180\165\SO<\192\131\198\&1\134",PropResponseTopic +// "N5\GS\211\DLEQ\a\229D\148\ACK\181\248\184\139e8",PropReceiveMaximum 4356,PropAuthenticationData +// "\189\164\215\US\141\163\153_\SUB&\195\209\153C",PropSubscriptionIdentifier 29,PropTopicAlias +// 4405,PropSessionExpiryInterval 2654,PropPayloadFormatIndicator 153,PropMaximumQoS 155] TEST(Subscribe5QCTest, Encode30) { - uint8_t pkt[] = {0x82, 0x20, 0x7e, 0x92, 0x0, 0x0, 0x15, 0xde, 0x64, 0x9a, 0x4a, 0xe5, 0x85, 0x98, 0xd2, 0x98, 0x51, - 0x81, 0xe4, 0x52, 0xb8, 0x3c, 0xca, 0x95, 0x93, 0xce, 0xf5, 0xa9, 0x11, 0x0, 0x2, 0xc3, 0xba, 0xd}; + uint8_t pkt[] = { + 0x82, 0xef, 0x1, 0x3, 0x16, 0xd2, 0x1, 0x27, 0x0, 0x0, 0xb, 0x72, 0x21, 0x5f, 0xc5, 0x1a, 0x0, 0x6, 0x64, + 0x6a, 0xdb, 0xcc, 0x4c, 0x4b, 0x8, 0x0, 0x1a, 0xf5, 0x7f, 0xf6, 0xb6, 0x79, 0xef, 0xc4, 0x5e, 0xa4, 0xf9, 0xf1, + 0x4a, 0xee, 0x1b, 0xbe, 0x89, 0x40, 0x60, 0x1b, 0x2d, 0xf1, 0x18, 0xeb, 0xc6, 0x42, 0x7b, 0x12, 0x0, 0x15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19}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xde, 0x64, 0x9a, 0x4a, 0xe5, 0x85, 0x98, 0xd2, 0x98, 0x51, 0x81, - 0xe4, 0x52, 0xb8, 0x3c, 0xca, 0x95, 0x93, 0xce, 0xf5, 0xa9}; - lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x75, 0x52, 0x2c, 0x45, 0xb8, 0xea, 0x9c, 0x3a, 0xa1, 0x37, 0x45, + 0x62, 0xf9, 0x78, 0x6, 0xff, 0x4b, 0x42, 0xb9, 0xa2, 0x49, 0x75}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc3, 0xba}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - lwmqtt_sub_options_t sub_opts[2]; + lwmqtt_sub_options_t sub_opts[1]; sub_opts[0].qos = LWMQTT_QOS1; sub_opts[0].retain_handling = LWMQTT_SUB_SEND_ON_SUB_NEW; - sub_opts[0].retain_as_published = false; + sub_opts[0].retain_as_published = true; sub_opts[0].no_local = false; - sub_opts[1].qos = LWMQTT_QOS1; - sub_opts[1].retain_handling = LWMQTT_SUB_SEND_ON_SUB; - sub_opts[1].retain_as_published = true; - sub_opts[1].no_local = true; + uint8_t bytesprops0[] = {0x64, 0x6a, 0xdb, 0xcc, 0x4c, 0x4b}; + uint8_t bytesprops1[] = {0xf5, 0x7f, 0xf6, 0xb6, 0x79, 0xef, 0xc4, 0x5e, 0xa4, 0xf9, 0xf1, 0x4a, 0xee, + 0x1b, 0xbe, 0x89, 0x40, 0x60, 0x1b, 0x2d, 0xf1, 0x18, 0xeb, 0xc6, 0x42, 0x7b}; + uint8_t bytesprops2[] = {0xcd, 0xe3, 0xd8, 0x4e, 0xbf, 0x3d, 0xbf, 0x20, 0x58, 0x23, 0x1b, + 0x5c, 0x68, 0x41, 0xd8, 0x81, 0x7f, 0x4b, 0x38, 0x92, 0x7b}; + uint8_t bytesprops3[] = {0xdd, 0xc5, 0x7f, 0xf7, 0xc1, 0xc8, 0xe9, 0xb6, 0xb1, 0xf, 0x55, 0xc5, 0x5a, + 0xf0, 0xbe, 0x4b, 0xed, 0x25, 0xd0, 0xc0, 0xd9, 0xb7, 0x75, 0x16, 0x93}; + uint8_t bytesprops4[] = {0x40, 0x11, 0x98, 0xad, 0x13, 0xdb, 0x62, 0x85, 0x3, 0xc, 0xbd, 0x33}; + uint8_t bytesprops5[] = {0x16, 0x72, 0xf5, 0xf9, 0xb2, 0x1e, 0x52, 0x56, 0x2b, 0x84, 0x4a}; + uint8_t bytesprops6[] = {0x9a, 0x6b, 0x93, 0x6d, 0x9b, 0xe4, 0xed, 0x6, 0x82, 0xf, 0x3f, + 0x90, 0xb4, 0xa5, 0xe, 0x3c, 0xc0, 0x83, 0xc6, 0x31, 0x86}; + uint8_t bytesprops7[] = {0x4e, 0x35, 0x1d, 0xd3, 0x10, 0x51, 0x7, 0xe5, 0x44, + 0x94, 0x6, 0xb5, 0xf8, 0xb8, 0x8b, 0x65, 0x38}; + uint8_t bytesprops8[] = {0xbd, 0xa4, 0xd7, 0x1f, 0x8d, 0xa3, 0x99, 0x5f, 0x1a, 0x26, 0xc3, 0xd1, 0x99, 0x43}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 2930}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24517}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {6, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {21, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 32093}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {25, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {11, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 245}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4356}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {14, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4405}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2654}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 155}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = - lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 32402, 2, topic_filters, sub_opts, props); + lwmqtt_encode_subscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 790, 1, topic_filters, sub_opts, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// SubscribeResponse 9775 [Left SubErrUnspecifiedError,Right QoS1,Left SubErrUnspecifiedError,Left -// SubErrSharedSubscriptionsNotSupported] [] +// SubscribeResponse 30338 [Left SubErrPacketIdentifierInUse,Right QoS0] [] TEST(SubACK311QCTest, Decode1) { - uint8_t pkt[] = {0x90, 0x6, 0x26, 0x2f, 0x80, 0x1, 0x80, 0x9e}; + uint8_t pkt[] = {0x90, 0x4, 0x76, 0x82, 0x91, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9775); - EXPECT_EQ(count, 4); + EXPECT_EQ(packet_id, 30338); + EXPECT_EQ(count, 2); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); } -// SubscribeResponse 5148 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left SubErrQuotaExceeded,Right -// QoS2,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right -// QoS2] [] +// SubscribeResponse 12367 [Right QoS0,Left SubErrImplementationSpecificError] [] TEST(SubACK311QCTest, Decode2) { - uint8_t pkt[] = {0x90, 0xc, 0x14, 0x1c, 0x9e, 0x0, 0x97, 0x2, 0xa2, 0x0, 0x1, 0x0, 0x87, 0x2}; + uint8_t pkt[] = {0x90, 0x4, 0x30, 0x4f, 0x0, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 5148); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 12367); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x80); } -// SubscribeResponse 6967 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS2,Right QoS2] [] +// SubscribeResponse 12800 [Right QoS0,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0x7, 0x1b, 0x37, 0xa2, 0x2, 0x1, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0x7, 0x32, 0x0, 0x0, 0x1, 0x91, 0x0, 0x9e}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[5]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6967); + EXPECT_EQ(packet_id, 12800); EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); } -// SubscribeResponse 10422 [Right QoS1,Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported] [] +// SubscribeResponse 28686 [Right QoS2,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS2,Left SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0x6, 0x28, 0xb6, 0x1, 0x0, 0x2, 0xa2}; + uint8_t pkt[] = {0x90, 0x9, 0x70, 0xe, 0x2, 0xa1, 0x8f, 0xa2, 0x80, 0x2, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10422); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 28686); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x80); } -// SubscribeResponse 9120 [Left SubErrTopicFilterInvalid,Right QoS0,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Left -// SubErrImplementationSpecificError] [] +// SubscribeResponse 25029 [Left SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0x8, 0x23, 0xa0, 0x8f, 0x0, 0x0, 0x97, 0x0, 0x83}; + uint8_t pkt[] = {0x90, 0x3, 0x61, 0xc5, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9120); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 25029); + EXPECT_EQ(count, 1); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], 0x80); } -// SubscribeResponse 32151 [Right QoS2,Left SubErrNotAuthorized,Right QoS1,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS0] [] +// SubscribeResponse 23005 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Right QoS0,Left +// SubErrNotAuthorized,Left SubErrUnspecifiedError,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrNotAuthorized] [] TEST(SubACK311QCTest, Decode6) { - uint8_t pkt[] = {0x90, 0x7, 0x7d, 0x97, 0x2, 0x87, 0x1, 0xa2, 0x0}; + uint8_t pkt[] = {0x90, 0xa, 0x59, 0xdd, 0xa1, 0x8f, 0x0, 0x87, 0x80, 0x1, 0xa2, 0x87}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32151); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 23005); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); } -// SubscribeResponse 26123 [Right QoS1,Right QoS0,Right QoS2] [] +// SubscribeResponse 31483 [Right QoS2,Right QoS1,Right QoS1,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0x5, 0x66, 0xb, 0x1, 0x0, 0x2}; + uint8_t pkt[] = {0x90, 0x7, 0x7a, 0xfb, 0x2, 0x1, 0x1, 0x2, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26123); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 31483); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); } -// SubscribeResponse 29973 [Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrImplementationSpecificError,Right -// QoS0,Right QoS2,Right QoS1] [] +// SubscribeResponse 14121 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS1,Right QoS2] [] TEST(SubACK311QCTest, Decode8) { - uint8_t pkt[] = {0x90, 0x8, 0x75, 0x15, 0x2, 0x91, 0x83, 0x0, 0x2, 0x1}; + uint8_t pkt[] = {0x90, 0x6, 0x37, 0x29, 0xa1, 0x2, 0x1, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29973); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 14121); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); } -// SubscribeResponse 14366 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS1,Left -// SubErrSharedSubscriptionsNotSupported] [] +// SubscribeResponse 16636 [Left SubErrPacketIdentifierInUse] [] TEST(SubACK311QCTest, Decode9) { - uint8_t pkt[] = {0x90, 0x6, 0x38, 0x1e, 0x9e, 0x2, 0x1, 0x9e}; + uint8_t pkt[] = {0x90, 0x3, 0x40, 0xfc, 0x91}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14366); - EXPECT_EQ(count, 4); + EXPECT_EQ(packet_id, 16636); + EXPECT_EQ(count, 1); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x80); } -// SubscribeResponse 10906 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right -// QoS1,Left SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Left SubErrTopicFilterInvalid] [] +// SubscribeResponse 19978 [Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0] [] TEST(SubACK311QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0xd, 0x2a, 0x9a, 0x80, 0xa2, 0x2, 0x1, 0x91, 0x87, 0x83, 0x9e, 0x1, 0x8f, 0x8f}; + uint8_t pkt[] = {0x90, 0x8, 0x4e, 0xa, 0x97, 0x80, 0x91, 0xa1, 0xa2, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10906); - EXPECT_EQ(count, 11); + EXPECT_EQ(packet_id, 19978); + EXPECT_EQ(count, 6); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[9], 0x80); - EXPECT_EQ(granted_qos_levels[10], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); } -// SubscribeResponse 11558 [Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Left -// SubErrUnspecifiedError,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded,Left -// SubErrNotAuthorized,Right QoS0,Right QoS2,Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError] [] +// SubscribeResponse 1639 [Right QoS2,Right QoS1,Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS0,Left +// SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode11) { - uint8_t pkt[] = {0x90, 0xc, 0x2d, 0x26, 0x83, 0x80, 0x80, 0xa1, 0x97, 0x87, 0x0, 0x2, 0x97, 0x83}; + uint8_t pkt[] = {0x90, 0x8, 0x6, 0x67, 0x2, 0x1, 0x2, 0x91, 0x0, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11558); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(packet_id, 1639); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], 0x80); } -// SubscribeResponse 9362 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrPacketIdentifierInUse,Left -// SubErrTopicFilterInvalid] [] +// SubscribeResponse 22530 [Left SubErrQuotaExceeded,Right QoS1,Right QoS1] [] TEST(SubACK311QCTest, Decode12) { - uint8_t pkt[] = {0x90, 0x5, 0x24, 0x92, 0xa1, 0x91, 0x8f}; + uint8_t pkt[] = {0x90, 0x5, 0x58, 0x2, 0x97, 0x1, 0x1}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[3]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9362); + EXPECT_EQ(packet_id, 22530); EXPECT_EQ(count, 3); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); } -// SubscribeResponse 23793 [Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS2,Right QoS0,Left SubErrImplementationSpecificError,Right -// QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Right QoS0] [] +// SubscribeResponse 27526 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Left SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode13) { - uint8_t pkt[] = {0x90, 0xc, 0x5c, 0xf1, 0xa2, 0x9e, 0x1, 0x2, 0x0, 0x83, 0x0, 0x9e, 0x9e, 0x0}; + uint8_t pkt[] = {0x90, 0x5, 0x6b, 0x86, 0x9e, 0x2, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 23793); - EXPECT_EQ(count, 10); + EXPECT_EQ(packet_id, 27526); + EXPECT_EQ(count, 3); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], 0x80); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); } -// SubscribeResponse 11397 [Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError,Left -// SubErrTopicFilterInvalid,Right QoS1,Right QoS0,Right QoS1,Right QoS1] [] +// SubscribeResponse 31498 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrTopicFilterInvalid] [] TEST(SubACK311QCTest, Decode14) { - uint8_t pkt[] = {0x90, 0xd, 0x2c, 0x85, 0x8f, 0xa1, 0x0, 0xa2, 0x1, 0x83, 0x8f, 0x1, 0x0, 0x1, 0x1}; + uint8_t pkt[] = {0x90, 0x6, 0x7b, 0xa, 0x9e, 0x91, 0x9e, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11397); - EXPECT_EQ(count, 11); + EXPECT_EQ(packet_id, 31498); + EXPECT_EQ(count, 4); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], 0x80); EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x80); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS1); } -// SubscribeResponse 5337 [Left SubErrTopicFilterInvalid] [] +// SubscribeResponse 3933 [Left SubErrImplementationSpecificError,Right QoS2] [] TEST(SubACK311QCTest, Decode15) { - uint8_t pkt[] = {0x90, 0x3, 0x14, 0xd9, 0x8f}; + uint8_t pkt[] = {0x90, 0x4, 0xf, 0x5d, 0x83, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 5337); - EXPECT_EQ(count, 1); + EXPECT_EQ(packet_id, 3933); + EXPECT_EQ(count, 2); EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); } -// SubscribeResponse 32213 [Left SubErrQuotaExceeded,Right QoS0,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1] [] +// SubscribeResponse 30590 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Left SubErrQuotaExceeded,Right +// QoS0,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded,Right QoS1,Right QoS2] [] TEST(SubACK311QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0x8, 0x7d, 0xd5, 0x97, 0x0, 0x0, 0x9e, 0xa2, 0x1}; + uint8_t pkt[] = {0x90, 0xb, 0x77, 0x7e, 0xa1, 0x2, 0x97, 0x0, 0x80, 0x91, 0x97, 0x1, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32213); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 30590); + EXPECT_EQ(count, 9); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); } -// SubscribeResponse 1504 [Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS1,Right QoS1] [] +// SubscribeResponse 28125 [Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Right QoS2] [] TEST(SubACK311QCTest, Decode17) { - uint8_t pkt[] = {0x90, 0x8, 0x5, 0xe0, 0xa1, 0x9e, 0x1, 0x8f, 0x1, 0x1}; + uint8_t pkt[] = {0x90, 0x5, 0x6d, 0xdd, 0x80, 0x80, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1504); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 28125); + EXPECT_EQ(count, 3); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); } -// SubscribeResponse 2008 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right -// QoS2,Left SubErrUnspecifiedError] [] +// SubscribeResponse 3160 [Right QoS1,Right QoS0,Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Right QoS1,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Right QoS0] [] TEST(SubACK311QCTest, Decode18) { - uint8_t pkt[] = {0x90, 0x7, 0x7, 0xd8, 0x2, 0x9e, 0x91, 0x2, 0x80}; + uint8_t pkt[] = {0x90, 0xb, 0xc, 0x58, 0x1, 0x0, 0x80, 0x80, 0x1, 0x9e, 0x80, 0x0, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[5]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 2008); - EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(packet_id, 3160); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); } -// SubscribeResponse 19894 [Left SubErrNotAuthorized,Left SubErrSharedSubscriptionsNotSupported,Left -// SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrQuotaExceeded] [] +// SubscribeResponse 13503 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left +// SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS1,Left SubErrUnspecifiedError,Left +// SubErrImplementationSpecificError,Left SubErrPacketIdentifierInUse] [] TEST(SubACK311QCTest, Decode19) { - uint8_t pkt[] = {0x90, 0x8, 0x4d, 0xb6, 0x87, 0x9e, 0xa1, 0x0, 0xa1, 0x97}; + uint8_t pkt[] = {0x90, 0xb, 0x34, 0xbf, 0x1, 0xa1, 0x0, 0xa1, 0x2, 0x1, 0x80, 0x83, 0x91}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19894); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(packet_id, 13503); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], 0x80); - EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); } -// SubscribeResponse 12423 [Left SubErrNotAuthorized,Right QoS0,Right QoS2,Right QoS2] [] +// SubscribeResponse 8170 [Left SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrNotAuthorized,Left +// SubErrImplementationSpecificError,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode20) { - uint8_t pkt[] = {0x90, 0x6, 0x30, 0x87, 0x87, 0x0, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0x8, 0x1f, 0xea, 0x9e, 0x1, 0x87, 0x83, 0xa1, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 12423); - EXPECT_EQ(count, 4); + EXPECT_EQ(packet_id, 8170); + EXPECT_EQ(count, 6); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); } -// SubscribeResponse 21901 [Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError,Right QoS0,Right QoS0] [] +// SubscribeResponse 3809 [Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError,Right QoS2,Right QoS1,Right +// QoS2] [] TEST(SubACK311QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0x6, 0x55, 0x8d, 0x97, 0x83, 0x0, 0x0}; + uint8_t pkt[] = {0x90, 0x7, 0xe, 0xe1, 0x97, 0x83, 0x2, 0x1, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21901); - EXPECT_EQ(count, 4); + EXPECT_EQ(packet_id, 3809); + EXPECT_EQ(count, 5); EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); } -// SubscribeResponse 9953 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1] [] +// SubscribeResponse 6533 [Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrNotAuthorized,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode22) { - uint8_t pkt[] = {0x90, 0x5, 0x26, 0xe1, 0x0, 0xa2, 0x1}; + uint8_t pkt[] = {0x90, 0x7, 0x19, 0x85, 0x91, 0x2, 0x87, 0x0, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9953); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 6533); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); } -// SubscribeResponse 21846 [Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Right QoS2,Right -// QoS1,Right QoS0,Right QoS0,Left SubErrImplementationSpecificError,Left SubErrTopicFilterInvalid,Right QoS2] [] +// SubscribeResponse 28202 [Right QoS1,Left SubErrQuotaExceeded,Left SubErrSharedSubscriptionsNotSupported,Right +// QoS2,Left SubErrUnspecifiedError,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS0,Right QoS1,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS0] [] TEST(SubACK311QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0xb, 0x55, 0x56, 0x8f, 0x83, 0x2, 0x1, 0x0, 0x0, 0x83, 0x8f, 0x2}; + uint8_t pkt[] = {0x90, 0xd, 0x6e, 0x2a, 0x1, 0x97, 0x9e, 0x2, 0x80, 0xa1, 0x1, 0x0, 0x1, 0x9e, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21846); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(packet_id, 28202); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x80); - EXPECT_EQ(granted_qos_levels[7], 0x80); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[9], 0x80); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); } -// SubscribeResponse 25983 [Right QoS2] [] +// SubscribeResponse 10740 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS2,Left +// SubErrSharedSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode24) { - uint8_t pkt[] = {0x90, 0x3, 0x65, 0x7f, 0x2}; + uint8_t pkt[] = {0x90, 0x6, 0x29, 0xf4, 0x9e, 0x2, 0x2, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25983); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 10740); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x80); } -// SubscribeResponse 803 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrNotAuthorized,Right -// QoS2,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [] +// SubscribeResponse 18996 [Left SubErrPacketIdentifierInUse,Left SubErrImplementationSpecificError,Right QoS0,Right +// QoS0,Left SubErrTopicFilterInvalid,Right QoS1,Left SubErrTopicFilterInvalid,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right QoS2,Left +// SubErrSubscriptionIdentifiersNotSupported] [] TEST(SubACK311QCTest, Decode25) { - uint8_t pkt[] = {0x90, 0x8, 0x3, 0x23, 0x0, 0xa2, 0x87, 0x2, 0xa1, 0x1}; + uint8_t pkt[] = {0x90, 0xd, 0x4a, 0x34, 0x91, 0x83, 0x0, 0x0, 0x8f, 0x1, 0x8f, 0xa2, 0x91, 0x2, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 803); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 18996); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x80); EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); EXPECT_EQ(granted_qos_levels[4], 0x80); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); + EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 6677 [Right QoS0,Right QoS1,Left SubErrTopicFilterInvalid,Left -// SubErrImplementationSpecificError,Right QoS0,Right QoS1,Right QoS2,Right QoS2,Left -// SubErrSubscriptionIdentifiersNotSupported,Left SubErrNotAuthorized,Right QoS0] [] +// SubscribeResponse 969 [Left SubErrWildcardSubscriptionsNotSupported,Left SubErrNotAuthorized,Right QoS2,Right +// QoS0,Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS1,Right QoS0,Right QoS2,Left SubErrNotAuthorized,Left +// SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode26) { - uint8_t pkt[] = {0x90, 0xd, 0x1a, 0x15, 0x0, 0x1, 0x8f, 0x83, 0x0, 0x1, 0x2, 0x2, 0xa1, 0x87, 0x0}; + uint8_t pkt[] = {0x90, 0xd, 0x3, 0xc9, 0xa2, 0x87, 0x2, 0x0, 0x2, 0x91, 0x1, 0x0, 0x2, 0x87, 0xa2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[11]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6677); + EXPECT_EQ(packet_id, 969); EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x80); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], 0x80); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[9], 0x80); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[10], 0x80); } -// SubscribeResponse 7481 [Left SubErrNotAuthorized,Right QoS1,Right QoS2,Left SubErrNotAuthorized] [] +// SubscribeResponse 27073 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Right +// QoS1,Right QoS2,Left SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported] [] TEST(SubACK311QCTest, Decode27) { - uint8_t pkt[] = {0x90, 0x6, 0x1d, 0x39, 0x87, 0x1, 0x2, 0x87}; + uint8_t pkt[] = {0x90, 0x8, 0x69, 0xc1, 0xa1, 0x8f, 0x1, 0x2, 0x8f, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7481); - EXPECT_EQ(count, 4); + EXPECT_EQ(packet_id, 27073); + EXPECT_EQ(count, 6); EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); } -// SubscribeResponse 26117 [Right QoS2,Right QoS0,Right QoS0] [] +// SubscribeResponse 9700 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrUnspecifiedError,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported] [] TEST(SubACK311QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0x5, 0x66, 0x5, 0x2, 0x0, 0x0}; + uint8_t pkt[] = {0x90, 0x9, 0x25, 0xe4, 0x1, 0xa1, 0x80, 0xa2, 0x2, 0x0, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26117); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(packet_id, 9700); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0x80); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0x80); } -// SubscribeResponse 4603 [Left SubErrWildcardSubscriptionsNotSupported] [] +// SubscribeResponse 31732 [Left SubErrNotAuthorized,Left SubErrImplementationSpecificError,Right QoS2,Right QoS1,Left +// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrUnspecifiedError] [] TEST(SubACK311QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0x3, 0x11, 0xfb, 0xa2}; + uint8_t pkt[] = {0x90, 0xa, 0x7b, 0xf4, 0x87, 0x83, 0x2, 0x1, 0x83, 0x97, 0xa1, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 8, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4603); - EXPECT_EQ(count, 1); + EXPECT_EQ(packet_id, 31732); + EXPECT_EQ(count, 8); EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x80); + EXPECT_EQ(granted_qos_levels[6], 0x80); + EXPECT_EQ(granted_qos_levels[7], 0x80); } -// SubscribeResponse 32025 [Left SubErrPacketIdentifierInUse] [] +// SubscribeResponse 6520 [Right QoS2,Left SubErrUnspecifiedError,Right QoS2,Left SubErrQuotaExceeded] [] TEST(SubACK311QCTest, Decode30) { - uint8_t pkt[] = {0x90, 0x3, 0x7d, 0x19, 0x91}; + uint8_t pkt[] = {0x90, 0x6, 0x19, 0x78, 0x2, 0x80, 0x2, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT311, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32025); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(packet_id, 6520); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x80); } -// SubscribeResponse 9775 [Left SubErrUnspecifiedError,Right QoS1,Left SubErrUnspecifiedError,Left -// SubErrSharedSubscriptionsNotSupported] [PropAuthenticationData -// "\234\f\220v\216\CAN\145\150Z\136\149e\141\251\177Y",PropMaximumQoS 189,PropMaximumQoS 26,PropServerKeepAlive -// 13776,PropSubscriptionIdentifierAvailable 80,PropReceiveMaximum 20785,PropMaximumQoS -// 175,PropSharedSubscriptionAvailable 235,PropAssignedClientIdentifier "\135\196u\130(",PropAuthenticationData -// "\169=0K\139C\199\228|8a\167A\131\251\170\248\253\173p\GS0\DC1\218:",PropRequestResponseInformation -// 90,PropMessageExpiryInterval 19327,PropAuthenticationMethod -// "\246++\171\157\242\170b\130\146\170\166\196\r\162{e\ETB\139wB\DC4<\ACK",PropReceiveMaximum 22897,PropResponseTopic -// "6\149"] +// SubscribeResponse 30338 [Left SubErrPacketIdentifierInUse,Right QoS0] [PropSubscriptionIdentifier +// 32,PropRetainAvailable 149,PropPayloadFormatIndicator 233,PropPayloadFormatIndicator +// 54,PropSharedSubscriptionAvailable 133,PropServerKeepAlive 19945,PropSubscriptionIdentifierAvailable +// 66,PropMaximumPacketSize 2010,PropWildcardSubscriptionAvailable 232,PropSubscriptionIdentifier 6,PropMaximumQoS +// 157,PropCorrelationData "z",PropResponseTopic "\197\EOTKr\135\195\177\145\241\156\253\133\vs",PropTopicAlias 19346] TEST(SubACK5QCTest, Decode1) { - uint8_t pkt[] = {0x90, 0x78, 0x26, 0x2f, 0x71, 0x16, 0x0, 0x10, 0xea, 0xc, 0xdc, 0x76, 0xd8, 0x18, 0x91, 0x96, - 0x5a, 0x88, 0x95, 0x65, 0x8d, 0xfb, 0xb1, 0x59, 0x24, 0xbd, 0x24, 0x1a, 0x13, 0x35, 0xd0, 0x29, - 0x50, 0x21, 0x51, 0x31, 0x24, 0xaf, 0x2a, 0xeb, 0x12, 0x0, 0x5, 0x87, 0xc4, 0x75, 0x82, 0x28, - 0x16, 0x0, 0x19, 0xa9, 0x3d, 0x30, 0x4b, 0x8b, 0x43, 0xc7, 0xe4, 0x7c, 0x38, 0x61, 0xa7, 0x41, - 0x83, 0xfb, 0xaa, 0xf8, 0xfd, 0xad, 0x70, 0x1d, 0x30, 0x11, 0xda, 0x3a, 0x19, 0x5a, 0x2, 0x0, - 0x0, 0x4b, 0x7f, 0x15, 0x0, 0x18, 0xf6, 0x2b, 0x2b, 0xab, 0x9d, 0xf2, 0xaa, 0x62, 0x82, 0x92, - 0xaa, 0xa6, 0xc4, 0xd, 0xa2, 0x7b, 0x65, 0x17, 0x8b, 0x77, 0x42, 0x14, 0x3c, 0x6, 0x21, 0x59, - 0x71, 0x8, 0x0, 0x2, 0x36, 0x95, 0x80, 0x1, 0x80, 0x9e}; + uint8_t pkt[] = {0x90, 0x37, 0x76, 0x82, 0x32, 0xb, 0x20, 0x25, 0x95, 0x1, 0xe9, 0x1, 0x36, 0x2a, 0x85, + 0x13, 0x4d, 0xe9, 0x29, 0x42, 0x27, 0x0, 0x0, 0x7, 0xda, 0x28, 0xe8, 0xb, 0x6, 0x24, + 0x9d, 0x9, 0x0, 0x1, 0x7a, 0x8, 0x0, 0xe, 0xc5, 0x4, 0x4b, 0x72, 0x87, 0xc3, 0xb1, + 0x91, 0xf1, 0x9c, 0xfd, 0x85, 0xb, 0x73, 0x23, 0x4b, 0x92, 0x91, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9775); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0x9E); + EXPECT_EQ(packet_id, 30338); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); } -// SubscribeResponse 5148 [Left SubErrSharedSubscriptionsNotSupported,Right QoS0,Left SubErrQuotaExceeded,Right -// QoS2,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0,Right QoS1,Right QoS0,Left SubErrNotAuthorized,Right -// QoS2] [PropContentType "\207\134\165\ti\229",PropSharedSubscriptionAvailable 140,PropServerKeepAlive -// 25332,PropRequestResponseInformation 19,PropResponseTopic " -// \246\RS\136I\208\133\STX\153\171\"\249_\193X\b\183PW\SOL\235\215p"] +// SubscribeResponse 12367 [Right QoS0,Left SubErrImplementationSpecificError] [PropReasonString +// "\191\251",PropMessageExpiryInterval 3754,PropPayloadFormatIndicator 23,PropRequestProblemInformation +// 157,PropCorrelationData "\SUB\170\177O]\n\240\170\225\169P\206%\ACK\174\165\GS\145\226\214\232",PropReceiveMaximum +// 2658,PropTopicAlias 23916,PropSubscriptionIdentifier 31,PropRequestResponseInformation 29,PropAuthenticationData +// "il\SO\163\177c\FSm\US_\132",PropCorrelationData +// "P\193\174\DLEo\150\169%=\151\176\132\220\163\189u|\252\197\130\162\f\170/\tz\190R",PropMessageExpiryInterval +// 25397,PropWillDelayInterval 1033,PropSubscriptionIdentifierAvailable 147,PropUserProperty "<\SI\249\132]\226" +// "\149X8\252Y\FS\RS\166\&3\DC4s?\DC1\FS\EOT\142\212\145\142\191\STXs\207\184\217\162\251\&8",PropMessageExpiryInterval +// 27329] TEST(SubACK5QCTest, Decode2) { - uint8_t pkt[] = {0x90, 0x38, 0x14, 0x1c, 0x2b, 0x3, 0x0, 0x6, 0xcf, 0x86, 0xa5, 0x9, 0x69, 0xe5, 0x2a, - 0x8c, 0x13, 0x62, 0xf4, 0x19, 0x13, 0x8, 0x0, 0x18, 0x20, 0xf6, 0x1e, 0x88, 0x49, 0xd0, - 0x85, 0x2, 0x99, 0xab, 0x22, 0xf9, 0x5f, 0xc1, 0x58, 0x8, 0xb7, 0x50, 0x57, 0xe, 0x4c, - 0xeb, 0xd7, 0x70, 0x9e, 0x0, 0x97, 0x2, 0xa2, 0x0, 0x1, 0x0, 0x87, 0x2}; + uint8_t pkt[] = {0x90, 0x9b, 0x1, 0x30, 0x4f, 0x95, 0x1, 0x1f, 0x0, 0x2, 0xbf, 0xfb, 0x2, 0x0, 0x0, 0xe, + 0xaa, 0x1, 0x17, 0x17, 0x9d, 0x9, 0x0, 0x15, 0x1a, 0xaa, 0xb1, 0x4f, 0x5d, 0xa, 0xf0, 0xaa, + 0xe1, 0xa9, 0x50, 0xce, 0x25, 0x6, 0xae, 0xa5, 0x1d, 0x91, 0xe2, 0xd6, 0xe8, 0x21, 0xa, 0x62, + 0x23, 0x5d, 0x6c, 0xb, 0x1f, 0x19, 0x1d, 0x16, 0x0, 0xb, 0x69, 0x6c, 0xe, 0xa3, 0xb1, 0x63, + 0x1c, 0x6d, 0x1f, 0x5f, 0x84, 0x9, 0x0, 0x1c, 0x50, 0xc1, 0xae, 0x10, 0x6f, 0x96, 0xa9, 0x25, + 0x3d, 0x97, 0xb0, 0x84, 0xdc, 0xa3, 0xbd, 0x75, 0x7c, 0xfc, 0xc5, 0x82, 0xa2, 0xc, 0xaa, 0x2f, + 0x9, 0x7a, 0xbe, 0x52, 0x2, 0x0, 0x0, 0x63, 0x35, 0x18, 0x0, 0x0, 0x4, 0x9, 0x29, 0x93, + 0x26, 0x0, 0x6, 0x3c, 0xf, 0xf9, 0x84, 0x5d, 0xe2, 0x0, 0x1c, 0x95, 0x58, 0x38, 0xfc, 0x59, + 0x1c, 0x1e, 0xa6, 0x33, 0x14, 0x73, 0x3f, 0x11, 0x1c, 0x4, 0x8e, 0xd4, 0x91, 0x8e, 0xbf, 0x2, + 0x73, 0xcf, 0xb8, 0xd9, 0xa2, 0xfb, 0x38, 0x2, 0x0, 0x0, 0x6a, 0xc1, 0x0, 0x83}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 5148); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], 0x97); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0xA2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[8], 0x87); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 12367); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], 0x83); } -// SubscribeResponse 6967 [Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS1,Right QoS2,Right QoS2] -// [PropAssignedClientIdentifier "\ENQv\150\148=o\252S\153h",PropCorrelationData "\181\132\131",PropReasonString -// "\175\183\131\164\191\174\r\218g\149\128\222,\213]\188\ACK\131\191\&5",PropTopicAliasMaximum -// 24384,PropSubscriptionIdentifier 14,PropWillDelayInterval 7334,PropRequestProblemInformation 112,PropServerReference -// "\214\154\137\133\160\188\\K"] +// SubscribeResponse 12800 [Right QoS0,Right QoS1,Left SubErrPacketIdentifierInUse,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported] [PropRetainAvailable 56,PropUserProperty "Y\226H\232" +// "n\185:N+*\GS\179\171\142\173>\182\191",PropSharedSubscriptionAvailable 203,PropCorrelationData +// "j\GS\SO\155FA_\220\166\242\180\195\171\148\SUB\136\223\244\247\248\128yo\ETXG\146\RS\145\225",PropWildcardSubscriptionAvailable +// 56,PropSessionExpiryInterval 2749,PropAuthenticationData +// "\n\236rn\180\204)(\156_%\DC4g\219d\EOT>n\170",PropMessageExpiryInterval 2583,PropAssignedClientIdentifier +// "x\n",PropSubscriptionIdentifierAvailable 5,PropContentType +// "9E\SUBB\233M\ETB!\ETX\177c|b\CAN\180Y=\166",PropMaximumPacketSize 20424,PropUserProperty +// "\145\&5\216\161G\DEL[1{\139\192\134Z%\142\t/\128:%Q-\"\145\n\178\180\197" +// "\140\177\203\&6]\f\215\136\215!f,lZ\245",PropRetainAvailable 173,PropMessageExpiryInterval +// 3930,PropRequestProblemInformation 231,PropMessageExpiryInterval 31026] TEST(SubACK5QCTest, Decode3) { - uint8_t pkt[] = {0x90, 0x49, 0x1b, 0x37, 0x41, 0x12, 0x0, 0xa, 0x5, 0x76, 0x96, 0x94, 0x3d, 0x6f, 0xfc, - 0x53, 0x99, 0x68, 0x9, 0x0, 0x3, 0xb5, 0x84, 0x83, 0x1f, 0x0, 0x14, 0xaf, 0xb7, 0x83, - 0xa4, 0xbf, 0xae, 0xd, 0xda, 0x67, 0x95, 0x80, 0xde, 0x2c, 0xd5, 0x5d, 0xbc, 0x6, 0x83, - 0xbf, 0x35, 0x22, 0x5f, 0x40, 0xb, 0xe, 0x18, 0x0, 0x0, 0x1c, 0xa6, 0x17, 0x70, 0x1c, - 0x0, 0x8, 0xd6, 0x9a, 0x89, 0x85, 0xa0, 0xbc, 0x5c, 0x4b, 0xa2, 0x2, 0x1, 0x2, 0x2}; + uint8_t pkt[] = {0x90, 0xc5, 0x1, 0x32, 0x0, 0xbc, 0x1, 0x25, 0x38, 0x26, 0x0, 0x4, 0x59, 0xe2, 0x48, 0xe8, 0x0, + 0xe, 0x6e, 0xb9, 0x3a, 0x4e, 0x2b, 0x2a, 0x1d, 0xb3, 0xab, 0x8e, 0xad, 0x3e, 0xb6, 0xbf, 0x2a, 0xcb, + 0x9, 0x0, 0x1d, 0x6a, 0x1d, 0xe, 0x9b, 0x46, 0x41, 0x5f, 0xdc, 0xa6, 0xf2, 0xb4, 0xc3, 0xab, 0x94, + 0x1a, 0x88, 0xdf, 0xf4, 0xf7, 0xf8, 0x80, 0x79, 0x6f, 0x3, 0x47, 0x92, 0x1e, 0x91, 0xe1, 0x28, 0x38, + 0x11, 0x0, 0x0, 0xa, 0xbd, 0x16, 0x0, 0x13, 0xa, 0xec, 0x72, 0x6e, 0xb4, 0xcc, 0x29, 0x28, 0x9c, + 0x5f, 0x25, 0x14, 0x67, 0xdb, 0x64, 0x4, 0x3e, 0x6e, 0xaa, 0x2, 0x0, 0x0, 0xa, 0x17, 0x12, 0x0, + 0x2, 0x78, 0xa, 0x29, 0x5, 0x3, 0x0, 0x12, 0x39, 0x45, 0x1a, 0x42, 0xe9, 0x4d, 0x17, 0x21, 0x3, + 0xb1, 0x63, 0x7c, 0x62, 0x18, 0xb4, 0x59, 0x3d, 0xa6, 0x27, 0x0, 0x0, 0x4f, 0xc8, 0x26, 0x0, 0x1c, + 0x91, 0x35, 0xd8, 0xa1, 0x47, 0x7f, 0x5b, 0x31, 0x7b, 0x8b, 0xc0, 0x86, 0x5a, 0x25, 0x8e, 0x9, 0x2f, + 0x80, 0x3a, 0x25, 0x51, 0x2d, 0x22, 0x91, 0xa, 0xb2, 0xb4, 0xc5, 0x0, 0xf, 0x8c, 0xb1, 0xcb, 0x36, + 0x5d, 0xc, 0xd7, 0x88, 0xd7, 0x21, 0x66, 0x2c, 0x6c, 0x5a, 0xf5, 0x25, 0xad, 0x2, 0x0, 0x0, 0xf, + 0x5a, 0x17, 0xe7, 0x2, 0x0, 0x0, 0x79, 0x32, 0x0, 0x1, 0x91, 0x0, 0x9e}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[5]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6967); + EXPECT_EQ(packet_id, 12800); EXPECT_EQ(count, 5); - EXPECT_EQ(granted_qos_levels[0], 0xA2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); -} - -// SubscribeResponse 10422 [Right QoS1,Right QoS0,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported] -// [PropCorrelationData "J",PropTopicAliasMaximum 11259,PropReceiveMaximum 24478,PropRetainAvailable -// 69,PropServerKeepAlive 15906,PropMessageExpiryInterval 21672,PropCorrelationData -// "\202\248\217\205\162\240L\181\164\DC2\DC19E\DEL\234\141\171\149/(A\131*",PropRequestResponseInformation -// 152,PropServerReference "\255\190\b\160\242\247\&9\153\191\145\158\SYNX\DC4^\239\145\181\142",PropResponseTopic -// "B2(\229\218\146",PropMessageExpiryInterval 11438,PropMessageExpiryInterval 15978,PropMaximumQoS -// 147,PropWillDelayInterval 27201,PropSubscriptionIdentifierAvailable 166,PropAssignedClientIdentifier -// "]\183\254\191\148\223\138\248\179\DC42_\170",PropWildcardSubscriptionAvailable 168,PropMaximumQoS -// 166,PropResponseInformation "\218\191o\170f\171\230k\242\&3\155\185\218\ESC\191\193E"] + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], 0x91); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x9E); +} + +// SubscribeResponse 28686 [Right QoS2,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS2,Left SubErrTopicFilterInvalid] +// [PropRequestProblemInformation 27,PropServerReference +// "K\161I\135\DLE\162L\169\152I\248\136\191C\233\187\175\ETBU\f\252Qq\CANh\220",PropTopicAliasMaximum +// 12806,PropServerReference "\150\175",PropSessionExpiryInterval 28982,PropRequestResponseInformation +// 5,PropWillDelayInterval 24027,PropRequestResponseInformation 97,PropCorrelationData +// "\ENQ\190\164\195t\184\135\DC2b\183\147",PropReceiveMaximum 5262,PropRequestResponseInformation +// 31,PropWildcardSubscriptionAvailable 84,PropMessageExpiryInterval 10552,PropSubscriptionIdentifier +// 23,PropMaximumPacketSize 1343,PropRequestProblemInformation 197,PropResponseInformation +// "\230\141\DC4%\221\138\129%\147\214'\f\241\157\214\&8\NUL\DC3",PropServerKeepAlive 17321,PropReceiveMaximum +// 19601,PropServerKeepAlive 26403,PropWildcardSubscriptionAvailable 30] TEST(SubACK5QCTest, Decode4) { - uint8_t pkt[] = {0x90, 0x92, 0x1, 0x28, 0xb6, 0x8a, 0x1, 0x9, 0x0, 0x1, 0x4a, 0x22, 0x2b, 0xfb, 0x21, 0x5f, 0x9e, - 0x25, 0x45, 0x13, 0x3e, 0x22, 0x2, 0x0, 0x0, 0x54, 0xa8, 0x9, 0x0, 0x17, 0xca, 0xf8, 0xd9, 0xcd, - 0xa2, 0xf0, 0x4c, 0xb5, 0xa4, 0x12, 0x11, 0x39, 0x45, 0x7f, 0xea, 0x8d, 0xab, 0x95, 0x2f, 0x28, 0x41, - 0x83, 0x2a, 0x19, 0x98, 0x1c, 0x0, 0x13, 0xff, 0xbe, 0x8, 0xa0, 0xf2, 0xf7, 0x39, 0x99, 0xbf, 0x91, - 0x9e, 0x16, 0x58, 0x14, 0x5e, 0xef, 0x91, 0xb5, 0x8e, 0x8, 0x0, 0x6, 0x42, 0x32, 0x28, 0xe5, 0xda, - 0x92, 0x2, 0x0, 0x0, 0x2c, 0xae, 0x2, 0x0, 0x0, 0x3e, 0x6a, 0x24, 0x93, 0x18, 0x0, 0x0, 0x6a, - 0x41, 0x29, 0xa6, 0x12, 0x0, 0xd, 0x5d, 0xb7, 0xfe, 0xbf, 0x94, 0xdf, 0x8a, 0xf8, 0xb3, 0x14, 0x32, - 0x5f, 0xaa, 0x28, 0xa8, 0x24, 0xa6, 0x1a, 0x0, 0x11, 0xda, 0xbf, 0x6f, 0xaa, 0x66, 0xab, 0xe6, 0x6b, - 0xf2, 0x33, 0x9b, 0xb9, 0xda, 0x1b, 0xbf, 0xc1, 0x45, 0x1, 0x0, 0x2, 0xa2}; + uint8_t pkt[] = {0x90, 0x82, 0x1, 0x70, 0xe, 0x78, 0x17, 0x1b, 0x1c, 0x0, 0x1a, 0x4b, 0xa1, 0x49, 0x87, 0x10, 0xa2, + 0x4c, 0xa9, 0x98, 0x49, 0xf8, 0x88, 0xbf, 0x43, 0xe9, 0xbb, 0xaf, 0x17, 0x55, 0xc, 0xfc, 0x51, 0x71, + 0x18, 0x68, 0xdc, 0x22, 0x32, 0x6, 0x1c, 0x0, 0x2, 0x96, 0xaf, 0x11, 0x0, 0x0, 0x71, 0x36, 0x19, + 0x5, 0x18, 0x0, 0x0, 0x5d, 0xdb, 0x19, 0x61, 0x9, 0x0, 0xb, 0x5, 0xbe, 0xa4, 0xc3, 0x74, 0xb8, + 0x87, 0x12, 0x62, 0xb7, 0x93, 0x21, 0x14, 0x8e, 0x19, 0x1f, 0x28, 0x54, 0x2, 0x0, 0x0, 0x29, 0x38, + 0xb, 0x17, 0x27, 0x0, 0x0, 0x5, 0x3f, 0x17, 0xc5, 0x1a, 0x0, 0x12, 0xe6, 0x8d, 0x14, 0x25, 0xdd, + 0x8a, 0x81, 0x25, 0x93, 0xd6, 0x27, 0xc, 0xf1, 0x9d, 0xd6, 0x38, 0x0, 0x13, 0x13, 0x43, 0xa9, 0x21, + 0x4c, 0x91, 0x13, 0x67, 0x23, 0x28, 0x1e, 0x2, 0xa1, 0x8f, 0xa2, 0x80, 0x2, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10422); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 28686); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0xA1); + EXPECT_EQ(granted_qos_levels[2], 0x8F); EXPECT_EQ(granted_qos_levels[3], 0xA2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[6], 0x8F); } -// SubscribeResponse 9120 [Left SubErrTopicFilterInvalid,Right QoS0,Right QoS0,Left SubErrQuotaExceeded,Right QoS0,Left -// SubErrImplementationSpecificError] [PropSubscriptionIdentifierAvailable 68,PropReceiveMaximum 13676] +// SubscribeResponse 25029 [Left SubErrUnspecifiedError] [PropMaximumQoS 150,PropReasonString +// "~\154\146\214qs\165\DC32mKY\EOT\237\148",PropServerKeepAlive 4819,PropServerKeepAlive 30336,PropRetainAvailable +// 197,PropWillDelayInterval 1016] TEST(SubACK5QCTest, Decode5) { - uint8_t pkt[] = {0x90, 0xe, 0x23, 0xa0, 0x5, 0x29, 0x44, 0x21, 0x35, 0x6c, 0x8f, 0x0, 0x0, 0x97, 0x0, 0x83}; + uint8_t pkt[] = {0x90, 0x25, 0x61, 0xc5, 0x21, 0x24, 0x96, 0x1f, 0x0, 0xf, 0x7e, 0x9a, 0x92, + 0xd6, 0x71, 0x73, 0xa5, 0x13, 0x32, 0x6d, 0x4b, 0x59, 0x4, 0xed, 0x94, 0x13, + 0x12, 0xd3, 0x13, 0x76, 0x80, 0x25, 0xc5, 0x18, 0x0, 0x0, 0x3, 0xf8, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9120); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], 0x8F); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x97); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], 0x83); + EXPECT_EQ(packet_id, 25029); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], 0x80); } -// SubscribeResponse 32151 [Right QoS2,Left SubErrNotAuthorized,Right QoS1,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS0] [PropSubscriptionIdentifierAvailable 110,PropAuthenticationMethod -// "\EOT\150\215r\DC4yV\136\161\NAK\221\156\152F\249ROH",PropServerKeepAlive 19882,PropWillDelayInterval -// 1198,PropWillDelayInterval 3411,PropSubscriptionIdentifier 7,PropRequestResponseInformation 86,PropReceiveMaximum -// 19407,PropSubscriptionIdentifier 31,PropAuthenticationData "HLz\144",PropAssignedClientIdentifier -// "\ESC\133\212fS\163P1\238\&5\DC2g\DC3\232T\170\155u\203\202!\DC1\165\189",PropServerKeepAlive -// 25841,PropMessageExpiryInterval 14535,PropResponseTopic "'\228\220\199\175i\171\235V^8M\196X\243\154Q\US\151o\210 -// \158\&0\ETB\178\a_\249",PropMaximumQoS 88] +// SubscribeResponse 23005 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Right QoS0,Left +// SubErrNotAuthorized,Left SubErrUnspecifiedError,Right QoS1,Left SubErrWildcardSubscriptionsNotSupported,Left +// SubErrNotAuthorized] [] TEST(SubACK5QCTest, Decode6) { - uint8_t pkt[] = {0x90, 0x81, 0x1, 0x7d, 0x97, 0x79, 0x29, 0x6e, 0x15, 0x0, 0x12, 0x4, 0x96, 0xd7, 0x72, 0x14, 0x79, - 0x56, 0x88, 0xa1, 0x15, 0xdd, 0x9c, 0x98, 0x46, 0xf9, 0x52, 0x4f, 0x48, 0x13, 0x4d, 0xaa, 0x18, 0x0, - 0x0, 0x4, 0xae, 0x18, 0x0, 0x0, 0xd, 0x53, 0xb, 0x7, 0x19, 0x56, 0x21, 0x4b, 0xcf, 0xb, 0x1f, - 0x16, 0x0, 0x4, 0x48, 0x4c, 0x7a, 0x90, 0x12, 0x0, 0x18, 0x1b, 0x85, 0xd4, 0x66, 0x53, 0xa3, 0x50, - 0x31, 0xee, 0x35, 0x12, 0x67, 0x13, 0xe8, 0x54, 0xaa, 0x9b, 0x75, 0xcb, 0xca, 0x21, 0x11, 0xa5, 0xbd, - 0x13, 0x64, 0xf1, 0x2, 0x0, 0x0, 0x38, 0xc7, 0x8, 0x0, 0x1d, 0x27, 0xe4, 0xdc, 0xc7, 0xaf, 0x69, - 0xab, 0xeb, 0x56, 0x5e, 0x38, 0x4d, 0xc4, 0x58, 0xf3, 0x9a, 0x51, 0x1f, 0x97, 0x6f, 0xd2, 0x20, 0x9e, - 0x30, 0x17, 0xb2, 0x7, 0x5f, 0xf9, 0x24, 0x58, 0x2, 0x87, 0x1, 0xa2, 0x0}; + uint8_t pkt[] = {0x90, 0xb, 0x59, 0xdd, 0x0, 0xa1, 0x8f, 0x0, 0x87, 0x80, 0x1, 0xa2, 0x87}; + uint16_t packet_id; + int count; + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 23005); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], 0x8F); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], 0x87); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[6], 0xA2); + EXPECT_EQ(granted_qos_levels[7], 0x87); +} + +// SubscribeResponse 31483 [Right QoS2,Right QoS1,Right QoS1,Right QoS2,Left SubErrWildcardSubscriptionsNotSupported] +// [PropResponseTopic +// "`\222S@\a\SUB+\168\GSPk\248\ETB\ETB\142H\r\138f\205\164\139\SUB\184\158",PropSharedSubscriptionAvailable +// 1,PropReceiveMaximum 6861,PropTopicAlias 28149,PropMessageExpiryInterval 28231,PropRequestResponseInformation +// 51,PropTopicAlias 7811,PropPayloadFormatIndicator 135,PropAuthenticationMethod +// "[\DC2\163\238\216N\151`\DC2\187\ETX\148^\241\154\&1",PropAuthenticationMethod +// "t\151\174\182L\NUL\238\223\171\164\NUL\SUB\173?\ENQU\160R",PropReasonString +// "Fc\255\221\135\155N3zA_TH6\253K",PropAuthenticationData "\215\EM\176?\245\131",PropSubscriptionIdentifier +// 2,PropUserProperty "\STX\154\237\245S" +// "\"\129\n\163\140\NUL\219\199\NAK\162]kJm<\227\DC3",PropSubscriptionIdentifierAvailable 38,PropMaximumQoS +// 159,PropMessageExpiryInterval 14026,PropRequestProblemInformation 132,PropWillDelayInterval +// 16214,PropRequestResponseInformation 58,PropSubscriptionIdentifierAvailable 54,PropSessionExpiryInterval +// 24579,PropMaximumQoS 170,PropMessageExpiryInterval 27088,PropAuthenticationMethod +// "<\206h\185\223M\250\177",PropUserProperty ")\185\228]W\186\DC2\143" "\146b\255",PropTopicAliasMaximum +// 26682,PropServerReference "g",PropSessionExpiryInterval 10950,PropRequestProblemInformation 122] +TEST(SubACK5QCTest, Decode7) { + uint8_t pkt[] = {0x90, 0xe3, 0x1, 0x7a, 0xfb, 0xda, 0x1, 0x8, 0x0, 0x19, 0x60, 0xde, 0x53, 0x40, 0x7, 0x1a, 0x2b, + 0xa8, 0x1d, 0x50, 0x6b, 0xf8, 0x17, 0x17, 0x8e, 0x48, 0xd, 0x8a, 0x66, 0xcd, 0xa4, 0x8b, 0x1a, 0xb8, + 0x9e, 0x2a, 0x1, 0x21, 0x1a, 0xcd, 0x23, 0x6d, 0xf5, 0x2, 0x0, 0x0, 0x6e, 0x47, 0x19, 0x33, 0x23, + 0x1e, 0x83, 0x1, 0x87, 0x15, 0x0, 0x10, 0x5b, 0x12, 0xa3, 0xee, 0xd8, 0x4e, 0x97, 0x60, 0x12, 0xbb, + 0x3, 0x94, 0x5e, 0xf1, 0x9a, 0x31, 0x15, 0x0, 0x12, 0x74, 0x97, 0xae, 0xb6, 0x4c, 0x0, 0xee, 0xdf, + 0xab, 0xa4, 0x0, 0x1a, 0xad, 0x3f, 0x5, 0x55, 0xa0, 0x52, 0x1f, 0x0, 0x10, 0x46, 0x63, 0xff, 0xdd, + 0x87, 0x9b, 0x4e, 0x33, 0x7a, 0x41, 0x5f, 0x54, 0x48, 0x36, 0xfd, 0x4b, 0x16, 0x0, 0x6, 0xd7, 0x19, + 0xb0, 0x3f, 0xf5, 0x83, 0xb, 0x2, 0x26, 0x0, 0x5, 0x2, 0x9a, 0xed, 0xf5, 0x53, 0x0, 0x11, 0x22, + 0x81, 0xa, 0xa3, 0x8c, 0x0, 0xdb, 0xc7, 0x15, 0xa2, 0x5d, 0x6b, 0x4a, 0x6d, 0x3c, 0xe3, 0x13, 0x29, + 0x26, 0x24, 0x9f, 0x2, 0x0, 0x0, 0x36, 0xca, 0x17, 0x84, 0x18, 0x0, 0x0, 0x3f, 0x56, 0x19, 0x3a, + 0x29, 0x36, 0x11, 0x0, 0x0, 0x60, 0x3, 0x24, 0xaa, 0x2, 0x0, 0x0, 0x69, 0xd0, 0x15, 0x0, 0x8, + 0x3c, 0xce, 0x68, 0xb9, 0xdf, 0x4d, 0xfa, 0xb1, 0x26, 0x0, 0x8, 0x29, 0xb9, 0xe4, 0x5d, 0x57, 0xba, + 0x12, 0x8f, 0x0, 0x3, 0x92, 0x62, 0xff, 0x22, 0x68, 0x3a, 0x1c, 0x0, 0x1, 0x67, 0x11, 0x0, 0x0, + 0x2a, 0xc6, 0x17, 0x7a, 0x2, 0x1, 0x1, 0x2, 0xa2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[5]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32151); + EXPECT_EQ(packet_id, 31483); EXPECT_EQ(count, 5); EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x87); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0xA2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0xA2); } -// SubscribeResponse 26123 [Right QoS1,Right QoS0,Right QoS2] [PropSubscriptionIdentifier 29,PropResponseTopic -// "\211\252\208z\210\233\130\ETB\209?g)@",PropTopicAliasMaximum 12492,PropRetainAvailable 204,PropMessageExpiryInterval -// 130,PropReasonString "\RS4",PropAuthenticationMethod "",PropSessionExpiryInterval 6330,PropServerReference -// "\240\178",PropRequestResponseInformation 108,PropTopicAliasMaximum 7015,PropWillDelayInterval -// 3068,PropSharedSubscriptionAvailable 154,PropTopicAlias 14277,PropRetainAvailable 230] -TEST(SubACK5QCTest, Decode7) { - uint8_t pkt[] = {0x90, 0x45, 0x66, 0xb, 0x3f, 0xb, 0x1d, 0x8, 0x0, 0xd, 0xd3, 0xfc, 0xd0, 0x7a, 0xd2, - 0xe9, 0x82, 0x17, 0xd1, 0x3f, 0x67, 0x29, 0x40, 0x22, 0x30, 0xcc, 0x25, 0xcc, 0x2, 0x0, - 0x0, 0x0, 0x82, 0x1f, 0x0, 0x2, 0x1e, 0x34, 0x15, 0x0, 0x0, 0x11, 0x0, 0x0, 0x18, - 0xba, 0x1c, 0x0, 0x2, 0xf0, 0xb2, 0x19, 0x6c, 0x22, 0x1b, 0x67, 0x18, 0x0, 0x0, 0xb, - 0xfc, 0x2a, 0x9a, 0x23, 0x37, 0xc5, 0x25, 0xe6, 0x1, 0x0, 0x2}; +// SubscribeResponse 14121 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Right QoS1,Right QoS2] +// [PropSessionExpiryInterval 5752,PropResponseTopic "#\216\DEL\241*\DC2\191\&1\229\247\161\EMk\EM",PropContentType +// "\202W\187\191Py`\DC2r\196\209]\240",PropResponseTopic +// "VL\ETB\189\GS`C2\NULY@\DC1\180$\140T\216>7\156\128\221",PropContentType +// "f\220\212p\183\&4\253\141\159\DC2\172\247\232\SYN\r\162\202\211\221\129\142\190\243>",PropTopicAlias +// 24590,PropRetainAvailable 106,PropWildcardSubscriptionAvailable 93,PropWillDelayInterval +// 30960,PropSessionExpiryInterval 2915,PropAuthenticationMethod +// "A\233\252E<\ETBB\207\158AI4\180\210\197\237\140\&2Z}\SOH*s\GS\158e\255\163QI",PropContentType +// "^\200\173\197R\b%\175;\129\190\169\197\ENQ\217\&7\213\SUBZ\158\"\140o\200\240\154\ETXs5",PropSessionExpiryInterval +// 8029,PropServerKeepAlive 6177,PropMessageExpiryInterval 5207,PropSharedSubscriptionAvailable +// 229,PropRequestProblemInformation 236,PropSessionExpiryInterval 14826,PropMessageExpiryInterval 32030] +TEST(SubACK5QCTest, Decode8) { + uint8_t pkt[] = {0x90, 0xcf, 0x1, 0x37, 0x29, 0xc7, 0x1, 0x11, 0x0, 0x0, 0x16, 0x78, 0x8, 0x0, 0xe, 0x23, 0xd8, + 0x7f, 0xf1, 0x2a, 0x12, 0xbf, 0x31, 0xe5, 0xf7, 0xa1, 0x19, 0x6b, 0x19, 0x3, 0x0, 0xd, 0xca, 0x57, + 0xbb, 0xbf, 0x50, 0x79, 0x60, 0x12, 0x72, 0xc4, 0xd1, 0x5d, 0xf0, 0x8, 0x0, 0x16, 0x56, 0x4c, 0x17, + 0xbd, 0x1d, 0x60, 0x43, 0x32, 0x0, 0x59, 0x40, 0x11, 0xb4, 0x24, 0x8c, 0x54, 0xd8, 0x3e, 0x37, 0x9c, + 0x80, 0xdd, 0x3, 0x0, 0x18, 0x66, 0xdc, 0xd4, 0x70, 0xb7, 0x34, 0xfd, 0x8d, 0x9f, 0x12, 0xac, 0xf7, + 0xe8, 0x16, 0xd, 0xa2, 0xca, 0xd3, 0xdd, 0x81, 0x8e, 0xbe, 0xf3, 0x3e, 0x23, 0x60, 0xe, 0x25, 0x6a, + 0x28, 0x5d, 0x18, 0x0, 0x0, 0x78, 0xf0, 0x11, 0x0, 0x0, 0xb, 0x63, 0x15, 0x0, 0x1e, 0x41, 0xe9, + 0xfc, 0x45, 0x3c, 0x17, 0x42, 0xcf, 0x9e, 0x41, 0x49, 0x34, 0xb4, 0xd2, 0xc5, 0xed, 0x8c, 0x32, 0x5a, + 0x7d, 0x1, 0x2a, 0x73, 0x1d, 0x9e, 0x65, 0xff, 0xa3, 0x51, 0x49, 0x3, 0x0, 0x1d, 0x5e, 0xc8, 0xad, + 0xc5, 0x52, 0x8, 0x25, 0xaf, 0x3b, 0x81, 0xbe, 0xa9, 0xc5, 0x5, 0xd9, 0x37, 0xd5, 0x1a, 0x5a, 0x9e, + 0x22, 0x8c, 0x6f, 0xc8, 0xf0, 0x9a, 0x3, 0x73, 0x35, 0x11, 0x0, 0x0, 0x1f, 0x5d, 0x13, 0x18, 0x21, + 0x2, 0x0, 0x0, 0x14, 0x57, 0x2a, 0xe5, 0x17, 0xec, 0x11, 0x0, 0x0, 0x39, 0xea, 0x2, 0x0, 0x0, + 0x7d, 0x1e, 0xa1, 0x2, 0x1, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26123); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); -} - -// SubscribeResponse 29973 [Right QoS2,Left SubErrPacketIdentifierInUse,Left SubErrImplementationSpecificError,Right -// QoS0,Right QoS2,Right QoS1] [PropSharedSubscriptionAvailable 1] -TEST(SubACK5QCTest, Decode8) { - uint8_t pkt[] = {0x90, 0xb, 0x75, 0x15, 0x2, 0x2a, 0x1, 0x2, 0x91, 0x83, 0x0, 0x2, 0x1}; - uint16_t packet_id; - int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 29973); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], 0x91); - EXPECT_EQ(granted_qos_levels[2], 0x83); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 14121); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); } -// SubscribeResponse 14366 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS1,Left -// SubErrSharedSubscriptionsNotSupported] [PropResponseInformation -// "\249\249\190\245\ESC\233z\156\130c\162\SO8?\ESCI\150g\vt\161",PropMessageExpiryInterval 25992,PropContentType -// "\181\v\225\135\SYN\STXUpqu\215\251p\147\DEL\215k\168\r?\GS",PropReasonString -// "\245F\211\152nT\167\232z\216\226\250\NAK\132\232\200\&3",PropAuthenticationMethod -// "\tF\STX\ETB\207.\DC2k\207\181\183c\128e\183\164\225:\198b\131A:\161\216",PropSessionExpiryInterval -// 13747,PropCorrelationData "dJ\150h\185\131\227\172\197;7!\147\151\131\230\ETX\161",PropCorrelationData -// "",PropMessageExpiryInterval 27691,PropSubscriptionIdentifier 2,PropUserProperty ",\224\220U" -// "*\218\139\184\251\223-vb\247\&8&\NAKm;\215\DC11>x\142\250\224$u",PropWildcardSubscriptionAvailable -// 53,PropRequestProblemInformation 219,PropRetainAvailable 131,PropMessageExpiryInterval -// 2028,PropRequestResponseInformation 217,PropRetainAvailable 152,PropRetainAvailable 2,PropRequestResponseInformation -// 108,PropMaximumQoS 202,PropTopicAlias 28925,PropServerKeepAlive 18424] +// SubscribeResponse 16636 [Left SubErrPacketIdentifierInUse] [PropTopicAlias 16976,PropResponseInformation +// "\228-\224\254W0\ESC\DEL\222\194\172N\137OM\129Z",PropWildcardSubscriptionAvailable 101,PropTopicAlias +// 12928,PropReasonString +// "\167\179\209)\157^5T\165\219\192S\248PQ\167Yv\141\131\178\183\196)\US\206F\231E",PropServerReference +// "ocPa~5:}B\136q\235\145\239\223\RS\171L\236",PropMaximumPacketSize 4029,PropWillDelayInterval 24096,PropMaximumQoS +// 15,PropWillDelayInterval 25411,PropMaximumQoS 189,PropUserProperty +// "\158#\213\249e'\174E\171\193zf\170S\223*\ETB\208[\254-\162" +// "\177J\218\235\225\ENQv\164\f\145w5\228&`\231",PropReasonString +// "s\DLE\245\207\184v\STX'L\170\158\190\t\177F\ESCi{\154",PropMessageExpiryInterval 15125,PropWillDelayInterval +// 2760,PropAuthenticationMethod "\188\189\140\215\214t_\182\t\"2l9\205\n\253\237/9",PropSubscriptionIdentifier 3] TEST(SubACK5QCTest, Decode9) { uint8_t pkt[] = { - 0x90, 0xce, 0x1, 0x38, 0x1e, 0xc6, 0x1, 0x1a, 0x0, 0x15, 0xf9, 0xf9, 0xbe, 0xf5, 0x1b, 0xe9, 0x7a, 0x9c, 0x82, - 0x63, 0xa2, 0xe, 0x38, 0x3f, 0x1b, 0x49, 0x96, 0x67, 0xb, 0x74, 0xa1, 0x2, 0x0, 0x0, 0x65, 0x88, 0x3, 0x0, - 0x15, 0xb5, 0xb, 0xe1, 0x87, 0x16, 0x2, 0x55, 0x70, 0x71, 0x75, 0xd7, 0xfb, 0x70, 0x93, 0x7f, 0xd7, 0x6b, 0xa8, - 0xd, 0x3f, 0x1d, 0x1f, 0x0, 0x11, 0xf5, 0x46, 0xd3, 0x98, 0x6e, 0x54, 0xa7, 0xe8, 0x7a, 0xd8, 0xe2, 0xfa, 0x15, - 0x84, 0xe8, 0xc8, 0x33, 0x15, 0x0, 0x19, 0x9, 0x46, 0x2, 0x17, 0xcf, 0x2e, 0x12, 0x6b, 0xcf, 0xb5, 0xb7, 0x63, - 0x80, 0x65, 0xb7, 0xa4, 0xe1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 0x42, 0x88, 0x71, 0xeb, 0x91, 0xef, 0xdf, 0x1e, 0xab, 0x4c, 0xec, 0x27, 0x0, 0x0, 0xf, 0xbd, 0x18, + 0x0, 0x0, 0x5e, 0x20, 0x24, 0xf, 0x18, 0x0, 0x0, 0x63, 0x43, 0x24, 0xbd, 0x26, 0x0, 0x16, 0x9e, 0x23, 0xd5, + 0xf9, 0x65, 0x27, 0xae, 0x45, 0xab, 0xc1, 0x7a, 0x66, 0xaa, 0x53, 0xdf, 0x2a, 0x17, 0xd0, 0x5b, 0xfe, 0x2d, 0xa2, + 0x0, 0x10, 0xb1, 0x4a, 0xda, 0xeb, 0xe1, 0x5, 0x76, 0xa4, 0xc, 0x91, 0x77, 0x35, 0xe4, 0x26, 0x60, 0xe7, 0x1f, + 0x0, 0x13, 0x73, 0x10, 0xf5, 0xcf, 0xb8, 0x76, 0x2, 0x27, 0x4c, 0xaa, 0x9e, 0xbe, 0x9, 0xb1, 0x46, 0x1b, 0x69, + 0x7b, 0x9a, 0x2, 0x0, 0x0, 0x3b, 0x15, 0x18, 0x0, 0x0, 0xa, 0xc8, 0x15, 0x0, 0x13, 0xbc, 0xbd, 0x8c, 0xd7, + 0xd6, 0x74, 0x5f, 0xb6, 0x9, 0x22, 0x32, 0x6c, 0x39, 0xcd, 0xa, 0xfd, 0xed, 0x2f, 0x39, 0xb, 0x3, 0x91}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[1]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 14366); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], 0x9E); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x9E); + EXPECT_EQ(packet_id, 16636); + EXPECT_EQ(count, 1); + EXPECT_EQ(granted_qos_levels[0], 0x91); } -// SubscribeResponse 10906 [Left SubErrUnspecifiedError,Left SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right -// QoS1,Left SubErrPacketIdentifierInUse,Left SubErrNotAuthorized,Left SubErrImplementationSpecificError,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Left SubErrTopicFilterInvalid] -// [PropRequestResponseInformation 143,PropResponseTopic -// "p\DC2\EOT\"\197]\158\199\GS6\US\176\SIK\170\152\134\\\ETXF\231\210\219\195\204\GS\DC3\228A",PropServerKeepAlive -// 19736,PropSubscriptionIdentifier 13,PropAuthenticationMethod "\182>\232\218\NAK\221\DC3 -// \DC3\157\175",PropMaximumPacketSize 28526,PropResponseTopic -// "\214P\235\164\151]\147\STX\b\SYNi\144]&g\142\145U\139q",PropReceiveMaximum 14778,PropRequestProblemInformation -// 80,PropRequestProblemInformation 53,PropSubscriptionIdentifierAvailable 113,PropServerKeepAlive -// 11340,PropReceiveMaximum 3459,PropMaximumQoS 115,PropMessageExpiryInterval 13266,PropAssignedClientIdentifier -// "\DEL\179\247\171h\174\243",PropContentType "\145Z\249W\157\159D\206m}V\250E\234\229",PropAuthenticationData -// "\240\182",PropServerKeepAlive 14931,PropRequestProblemInformation 2,PropMaximumPacketSize 23805] +// SubscribeResponse 19978 [Left SubErrQuotaExceeded,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left +// SubErrSubscriptionIdentifiersNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS0] +// [PropAssignedClientIdentifier "Y&jh\131\&2\131\233\193\171\fD\166\138$w\141\149()\SOHguH\SO\a",PropRetainAvailable +// 79,PropSubscriptionIdentifier 8,PropContentType "\128^\134\152\148\t\SUB\144\&7\203\253\200\146\ACK",PropMaximumQoS +// 122,PropSubscriptionIdentifier 24,PropSubscriptionIdentifier 20,PropMaximumPacketSize 11473] TEST(SubACK5QCTest, Decode10) { - uint8_t pkt[] = {0x90, 0xa1, 0x1, 0x2a, 0x9a, 0x92, 0x1, 0x19, 0x8f, 0x8, 0x0, 0x1d, 0x70, 0x12, 0x4, 0x22, 0xc5, - 0x5d, 0x9e, 0xc7, 0x1d, 0x36, 0x1f, 0xb0, 0xf, 0x4b, 0xaa, 0x98, 0x86, 0x5c, 0x3, 0x46, 0xe7, 0xd2, - 0xdb, 0xc3, 0xcc, 0x1d, 0x13, 0xe4, 0x41, 0x13, 0x4d, 0x18, 0xb, 0xd, 0x15, 0x0, 0xb, 0xb6, 0x3e, - 0xe8, 0xda, 0x15, 0xdd, 0x13, 0x20, 0x13, 0x9d, 0xaf, 0x27, 0x0, 0x0, 0x6f, 0x6e, 0x8, 0x0, 0x14, - 0xd6, 0x50, 0xeb, 0xa4, 0x97, 0x5d, 0x93, 0x2, 0x8, 0x16, 0x69, 0x90, 0x5d, 0x26, 0x67, 0x8e, 0x91, - 0x55, 0x8b, 0x71, 0x21, 0x39, 0xba, 0x17, 0x50, 0x17, 0x35, 0x29, 0x71, 0x13, 0x2c, 0x4c, 0x21, 0xd, - 0x83, 0x24, 0x73, 0x2, 0x0, 0x0, 0x33, 0xd2, 0x12, 0x0, 0x7, 0x7f, 0xb3, 0xf7, 0xab, 0x68, 0xae, - 0xf3, 0x3, 0x0, 0xf, 0x91, 0x5a, 0xf9, 0x57, 0x9d, 0x9f, 0x44, 0xce, 0x6d, 0x7d, 0x56, 0xfa, 0x45, - 0xea, 0xe5, 0x16, 0x0, 0x2, 0xf0, 0xb6, 0x13, 0x3a, 0x53, 0x17, 0x2, 0x27, 0x0, 0x0, 0x5c, 0xfd, - 0x80, 0xa2, 0x2, 0x1, 0x91, 0x87, 0x83, 0x9e, 0x1, 0x8f, 0x8f}; + uint8_t pkt[] = {0x90, 0x46, 0x4e, 0xa, 0x3d, 0x12, 0x0, 0x1a, 0x59, 0x26, 0x6a, 0x68, 0x83, 0x32, 0x83, + 0xe9, 0xc1, 0xab, 0xc, 0x44, 0xa6, 0x8a, 0x24, 0x77, 0x8d, 0x95, 0x28, 0x29, 0x1, 0x67, + 0x75, 0x48, 0xe, 0x7, 0x25, 0x4f, 0xb, 0x8, 0x3, 0x0, 0xe, 0x80, 0x5e, 0x86, 0x98, + 0x94, 0x9, 0x1a, 0x90, 0x37, 0xcb, 0xfd, 0xc8, 0x92, 0x6, 0x24, 0x7a, 0xb, 0x18, 0xb, + 0x14, 0x27, 0x0, 0x0, 0x2c, 0xd1, 0x97, 0x80, 0x91, 0xa1, 0xa2, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10906); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x80); - EXPECT_EQ(granted_qos_levels[1], 0xA2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], 0x91); - EXPECT_EQ(granted_qos_levels[5], 0x87); - EXPECT_EQ(granted_qos_levels[6], 0x83); - EXPECT_EQ(granted_qos_levels[7], 0x9E); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[9], 0x8F); - EXPECT_EQ(granted_qos_levels[10], 0x8F); + EXPECT_EQ(packet_id, 19978); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0x97); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], 0x91); + EXPECT_EQ(granted_qos_levels[3], 0xA1); + EXPECT_EQ(granted_qos_levels[4], 0xA2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); } -// SubscribeResponse 11558 [Left SubErrImplementationSpecificError,Left SubErrUnspecifiedError,Left -// SubErrUnspecifiedError,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrQuotaExceeded,Left -// SubErrNotAuthorized,Right QoS0,Right QoS2,Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError] -// [PropResponseInformation "3\SUB\158\ESC\144g\231\155\234/\171",PropSessionExpiryInterval -// 24450,PropPayloadFormatIndicator 177] +// SubscribeResponse 1639 [Right QoS2,Right QoS1,Right QoS2,Left SubErrPacketIdentifierInUse,Right QoS0,Left +// SubErrTopicFilterInvalid] [PropMessageExpiryInterval 18162,PropRequestProblemInformation 166,PropTopicAlias +// 20962,PropMaximumPacketSize 20480,PropTopicAliasMaximum 17998,PropMaximumQoS 79,PropServerKeepAlive +// 17732,PropTopicAliasMaximum 13320,PropResponseInformation +// "'\253&\166\150\150\188z]+\230\SI\139",PropAuthenticationData "Ks\170\176\171:\135\\\243&",PropTopicAliasMaximum +// 30520,PropMaximumQoS 5,PropUserProperty "3\164cJk\254\170\SO\217\176\&8\190$\156f\245\f\DC2\157\FS" +// "\144\215\172\201*\158K\CAN\SOHH|\SYN\165\203/\147zu\135\244\143Cz \DC3\238\197\204",PropRetainAvailable +// 65,PropMessageExpiryInterval 4670,PropMessageExpiryInterval 6499,PropReceiveMaximum 9076,PropTopicAliasMaximum +// 15026,PropSharedSubscriptionAvailable 56,PropMessageExpiryInterval 29601,PropMaximumPacketSize +// 30923,PropAuthenticationData ")\160,\137aC\197=\218\171\176L\147\236\a",PropRequestProblemInformation +// 105,PropMessageExpiryInterval 8880] TEST(SubACK5QCTest, Decode11) { - uint8_t pkt[] = {0x90, 0x22, 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+ 0x29, 0xa0, 0x2c, 0x89, 0x61, 0x43, 0xc5, 0x3d, 0xda, 0xab, 0xb0, 0x4c, 0x93, 0xec, 0x7, 0x17, 0x69, + 0x2, 0x0, 0x0, 0x22, 0xb0, 0x2, 0x1, 0x2, 0x91, 0x0, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11558); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0x83); - EXPECT_EQ(granted_qos_levels[1], 0x80); - EXPECT_EQ(granted_qos_levels[2], 0x80); - EXPECT_EQ(granted_qos_levels[3], 0xA1); - EXPECT_EQ(granted_qos_levels[4], 0x97); - EXPECT_EQ(granted_qos_levels[5], 0x87); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], 0x97); - EXPECT_EQ(granted_qos_levels[9], 0x83); -} - -// SubscribeResponse 9362 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrPacketIdentifierInUse,Left -// SubErrTopicFilterInvalid] [PropCorrelationData -// "\195\153!\134/\183\202\231\ENQ1\247e\162\&0\202k6",PropTopicAliasMaximum 3409,PropSubscriptionIdentifierAvailable -// 195,PropTopicAliasMaximum 14152,PropSubscriptionIdentifier 16,PropAuthenticationMethod -// "\182\191%p\205JB\254\175\130\SO\235x4Y\ETX\192",PropWillDelayInterval 19872,PropMaximumQoS 150] + EXPECT_EQ(packet_id, 1639); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x91); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[5], 0x8F); +} + +// SubscribeResponse 22530 [Left SubErrQuotaExceeded,Right QoS1,Right QoS1] [PropWildcardSubscriptionAvailable +// 151,PropCorrelationData "\186\212P!&\249\184\&3a\215\182H\160\"\218TA\171G*\DC3\195",PropServerReference +// "hD<\\\155\US\206\201\223\DEL\"\236\149\134^\SYN\132\&2j",PropSharedSubscriptionAvailable 241,PropReceiveMaximum +// 25249,PropServerReference "\232\145\159 +// \188\246X\145\203-l\181\216\ACK\170g\247\224\r\182\200e\160\220\129",PropCorrelationData +// "\230\194J\254I\179\202\SI\STX\226\&3v\167\b\160\188",PropAssignedClientIdentifier +// "y+Eh\191\&6\USbW\200\130\156\191\205^\147mt\176\ACK\223>",PropContentType "",PropReceiveMaximum +// 20599,PropServerKeepAlive 18200,PropSessionExpiryInterval 31439,PropAssignedClientIdentifier +// "\201Ig\245*B\ESC\173\156o\196e\164\172\138\216\176\EOT\149\129E\152\197E&\147Q",PropCorrelationData +// "!\202\133g\195\244\191\&1i=\150@\160\226\233+\130U",PropAssignedClientIdentifier +// "\ETBn(\158\131\SI\155\129\134\193\156\SOU\ACKe\DC2\213",PropResponseInformation +// "\227\134$\RS\220]m\184\165$\141\150\205\146L\201C\224o",PropAssignedClientIdentifier "\134\DLE\253\&2\255\183\SI +// \225q}Qz\RS^\147@",PropSessionExpiryInterval 31819,PropWildcardSubscriptionAvailable 159,PropResponseInformation +// "\200\164\224\233\192^\192\243;\131 \253\130\ETB",PropReceiveMaximum 30788,PropAssignedClientIdentifier +// "\DC2\182\142\SO",PropSubscriptionIdentifierAvailable 172,PropTopicAliasMaximum 17696,PropRequestProblemInformation +// 138,PropAuthenticationMethod "\150\203\207\&1d\190\243\229/\DC2w\141\195\NAKj\243N\229\&6\242\184*3\157\"\180"] TEST(SubACK5QCTest, Decode12) { - uint8_t pkt[] = {0x90, 0x3f, 0x24, 0x92, 0x39, 0x9, 0x0, 0x11, 0xc3, 0x99, 0x21, 0x86, 0x2f, 0xb7, 0xca, 0xe7, 0x5, - 0x31, 0xf7, 0x65, 0xa2, 0x30, 0xca, 0x6b, 0x36, 0x22, 0xd, 0x51, 0x29, 0xc3, 0x22, 0x37, 0x48, 0xb, - 0x10, 0x15, 0x0, 0x11, 0xb6, 0xbf, 0x25, 0x70, 0xcd, 0x4a, 0x42, 0xfe, 0xaf, 0x82, 0xe, 0xeb, 0x78, - 0x34, 0x59, 0x3, 0xc0, 0x18, 0x0, 0x0, 0x4d, 0xa0, 0x24, 0x96, 0xa1, 0x91, 0x8f}; + uint8_t pkt[] = { + 0x90, 0xca, 0x2, 0x58, 0x2, 0xc3, 0x2, 0x28, 0x97, 0x9, 0x0, 0x16, 0xba, 0xd4, 0x50, 0x21, 0x26, 0xf9, 0xb8, + 0x33, 0x61, 0xd7, 0xb6, 0x48, 0xa0, 0x22, 0xda, 0x54, 0x41, 0xab, 0x47, 0x2a, 0x13, 0xc3, 0x1c, 0x0, 0x13, 0x68, + 0x44, 0x3c, 0x5c, 0x9b, 0x1f, 0xce, 0xc9, 0xdf, 0x7f, 0x22, 0xec, 0x95, 0x86, 0x5e, 0x16, 0x84, 0x32, 0x6a, 0x2a, + 0xf1, 0x21, 0x62, 0xa1, 0x1c, 0x0, 0x19, 0xe8, 0x91, 0x9f, 0x20, 0xbc, 0xf6, 0x58, 0x91, 0xcb, 0x2d, 0x6c, 0xb5, + 0xd8, 0x6, 0xaa, 0x67, 0xf7, 0xe0, 0xd, 0xb6, 0xc8, 0x65, 0xa0, 0xdc, 0x81, 0x9, 0x0, 0x10, 0xe6, 0xc2, 0x4a, + 0xfe, 0x49, 0xb3, 0xca, 0xf, 0x2, 0xe2, 0x33, 0x76, 0xa7, 0x8,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, 0xe, 0x29, 0xac, 0x22, 0x45, 0x20, 0x17, 0x8a, 0x15, 0x0, 0x1a, + 0x96, 0xcb, 0xcf, 0x31, 0x64, 0xbe, 0xf3, 0xe5, 0x2f, 0x12, 0x77, 0x8d, 0xc3, 0x15, 0x6a, 0xf3, 0x4e, 0xe5, 0x36, + 0xf2, 0xb8, 0x2a, 0x33, 0x9d, 0x22, 0xb4, 0x97, 0x1, 0x1}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[3]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9362); + EXPECT_EQ(packet_id, 22530); EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], 0xA1); - EXPECT_EQ(granted_qos_levels[1], 0x91); - EXPECT_EQ(granted_qos_levels[2], 0x8F); + EXPECT_EQ(granted_qos_levels[0], 0x97); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); } -// SubscribeResponse 23793 [Left SubErrWildcardSubscriptionsNotSupported,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Right QoS2,Right QoS0,Left SubErrImplementationSpecificError,Right -// QoS0,Left SubErrSharedSubscriptionsNotSupported,Left SubErrSharedSubscriptionsNotSupported,Right QoS0] -// [PropAuthenticationData "\218J\135\ACK]\180\255\&7\144\212\v\167H\249$t\153C\222(TEp\220\156$",PropAuthenticationData -// "\223\165^.3{\SUB\213\151\RS\227w!\144\ACKMY\r\198\158\211\250^[\ENQ\238A\SUB\247",PropCorrelationData -// "qN\171\212\209f\NAK9\157\254\225pZ\156\DLEI\173\185\\",PropMessageExpiryInterval 4328,PropMessageExpiryInterval -// 1128,PropSubscriptionIdentifier 21,PropServerReference "\224\158\nd\221\SO\248\222v",PropServerReference -// "\164\233",PropAssignedClientIdentifier "\NAKm@sFU\170A\232\200\166ha\208",PropContentType -// "e\209P\236\130\184\130\138Yf\152f\ETX5X\175",PropRetainAvailable 24,PropRetainAvailable -// 194,PropMessageExpiryInterval 2103,PropWildcardSubscriptionAvailable 90,PropPayloadFormatIndicator -// 104,PropSubscriptionIdentifier 11,PropWildcardSubscriptionAvailable 69,PropReasonString -// "3\255\243",PropRequestResponseInformation 218,PropWillDelayInterval 8806] +// SubscribeResponse 27526 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Left SubErrUnspecifiedError] +// [PropRequestResponseInformation 117,PropServerReference "\a\176#4s`",PropSessionExpiryInterval +// 2586,PropReceiveMaximum 19098,PropMaximumPacketSize 16262,PropResponseTopic "\241*-"] TEST(SubACK5QCTest, Decode13) { - uint8_t pkt[] = {0x90, 0xc0, 0x1, 0x5c, 0xf1, 0xb2, 0x1, 0x16, 0x0, 0x1a, 0xda, 0x4a, 0x87, 0x6, 0x5d, 0xb4, 0xff, - 0x37, 0x90, 0xd4, 0xb, 0xa7, 0x48, 0xf9, 0x24, 0x74, 0x99, 0x43, 0xde, 0x28, 0x54, 0x45, 0x70, 0xdc, - 0x9c, 0x24, 0x16, 0x0, 0x1d, 0xdf, 0xa5, 0x5e, 0x2e, 0x33, 0x7b, 0x1a, 0xd5, 0x97, 0x1e, 0xe3, 0x77, - 0x21, 0x90, 0x6, 0x4d, 0x59, 0xd, 0xc6, 0x9e, 0xd3, 0xfa, 0x5e, 0x5b, 0x5, 0xee, 0x41, 0x1a, 0xf7, - 0x9, 0x0, 0x13, 0x71, 0x4e, 0xab, 0xd4, 0xd1, 0x66, 0x15, 0x39, 0x9d, 0xfe, 0xe1, 0x70, 0x5a, 0x9c, - 0x10, 0x49, 0xad, 0xb9, 0x5c, 0x2, 0x0, 0x0, 0x10, 0xe8, 0x2, 0x0, 0x0, 0x4, 0x68, 0xb, 0x15, - 0x1c, 0x0, 0x9, 0xe0, 0x9e, 0xa, 0x64, 0xdd, 0xe, 0xf8, 0xde, 0x76, 0x1c, 0x0, 0x2, 0xa4, 0xe9, - 0x12, 0x0, 0xe, 0x15, 0x6d, 0x40, 0x73, 0x46, 0x55, 0xaa, 0x41, 0xe8, 0xc8, 0xa6, 0x68, 0x61, 0xd0, - 0x3, 0x0, 0x10, 0x65, 0xd1, 0x50, 0xec, 0x82, 0xb8, 0x82, 0x8a, 0x59, 0x66, 0x98, 0x66, 0x3, 0x35, - 0x58, 0xaf, 0x25, 0x18, 0x25, 0xc2, 0x2, 0x0, 0x0, 0x8, 0x37, 0x28, 0x5a, 0x1, 0x68, 0xb, 0xb, - 0x28, 0x45, 0x1f, 0x0, 0x3, 0x33, 0xff, 0xf3, 0x19, 0xda, 0x18, 0x0, 0x0, 0x22, 0x66, 0xa2, 0x9e, - 0x1, 0x2, 0x0, 0x83, 0x0, 0x9e, 0x9e, 0x0}; + uint8_t pkt[] = {0x90, 0x24, 0x6b, 0x86, 0x1e, 0x19, 0x75, 0x1c, 0x0, 0x6, 0x7, 0xb0, 0x23, + 0x34, 0x73, 0x60, 0x11, 0x0, 0x0, 0xa, 0x1a, 0x21, 0x4a, 0x9a, 0x27, 0x0, + 0x0, 0x3f, 0x86, 0x8, 0x0, 0x3, 0xf1, 0x2a, 0x2d, 0x9e, 0x2, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[10]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 23793); - EXPECT_EQ(count, 10); - EXPECT_EQ(granted_qos_levels[0], 0xA2); - EXPECT_EQ(granted_qos_levels[1], 0x9E); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], 0x83); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[7], 0x9E); - EXPECT_EQ(granted_qos_levels[8], 0x9E); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS0); -} - -// SubscribeResponse 11397 [Left SubErrTopicFilterInvalid,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS0,Left -// SubErrWildcardSubscriptionsNotSupported,Right QoS1,Left SubErrImplementationSpecificError,Left -// SubErrTopicFilterInvalid,Right QoS1,Right QoS0,Right QoS1,Right QoS1] [PropServerKeepAlive -// 1598,PropSubscriptionIdentifier 11,PropMessageExpiryInterval 3147,PropReasonString -// "W\247\177\220\221\211\134o8\198\199\237\135SW\167eo\174\f\165\165\226\US\v",PropRequestResponseInformation -// 114,PropReasonString "\STX\187\".\226i\180'",PropRequestResponseInformation 81,PropTopicAlias -// 21854,PropResponseInformation "\DEL\254b)A\131\204(\227\194\226\202",PropCorrelationData -// "\235\185\201\&8\152iV",PropMaximumPacketSize 4310,PropMessageExpiryInterval 6070,PropServerReference -// "M\231\232Vv?m0\SO\214#\143\"\238\133\199+sc",PropTopicAlias 26799,PropRequestResponseInformation -// 100,PropServerReference "\220",PropResponseInformation "\254!-\245C",PropContentType -// "\162\197\244\DC4L\RSPM~2P8\217\132\204>\201\227X\251\134\251",PropSharedSubscriptionAvailable 103,PropReceiveMaximum -// 26130,PropCorrelationData "\NUL\153v\179j\197#\192\235t\164\221V\NAK|i0"] + EXPECT_EQ(packet_id, 27526); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x80); +} + +// SubscribeResponse 31498 [Left SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrTopicFilterInvalid] [] TEST(SubACK5QCTest, Decode14) { - uint8_t pkt[] = {0x90, 0xc3, 0x1, 0x2c, 0x85, 0xb4, 0x1, 0x13, 0x6, 0x3e, 0xb, 0xb, 0x2, 0x0, 0x0, 0xc, 0x4b, - 0x1f, 0x0, 0x19, 0x57, 0xf7, 0xb1, 0xdc, 0xdd, 0xd3, 0x86, 0x6f, 0x38, 0xc6, 0xc7, 0xed, 0x87, 0x53, - 0x57, 0xa7, 0x65, 0x6f, 0xae, 0xc, 0xa5, 0xa5, 0xe2, 0x1f, 0xb, 0x19, 0x72, 0x1f, 0x0, 0x8, 0x2, - 0xbb, 0x22, 0x2e, 0xe2, 0x69, 0xb4, 0x27, 0x19, 0x51, 0x23, 0x55, 0x5e, 0x1a, 0x0, 0xc, 0x7f, 0xfe, - 0x62, 0x29, 0x41, 0x83, 0xcc, 0x28, 0xe3, 0xc2, 0xe2, 0xca, 0x9, 0x0, 0x7, 0xeb, 0xb9, 0xc9, 0x38, - 0x98, 0x69, 0x56, 0x27, 0x0, 0x0, 0x10, 0xd6, 0x2, 0x0, 0x0, 0x17, 0xb6, 0x1c, 0x0, 0x13, 0x4d, - 0xe7, 0xe8, 0x56, 0x76, 0x3f, 0x6d, 0x30, 0xe, 0xd6, 0x23, 0x8f, 0x22, 0xee, 0x85, 0xc7, 0x2b, 0x73, - 0x63, 0x23, 0x68, 0xaf, 0x19, 0x64, 0x1c, 0x0, 0x1, 0xdc, 0x1a, 0x0, 0x5, 0xfe, 0x21, 0x2d, 0xf5, - 0x43, 0x3, 0x0, 0x16, 0xa2, 0xc5, 0xf4, 0x14, 0x4c, 0x1e, 0x50, 0x4d, 0x7e, 0x32, 0x50, 0x38, 0xd9, - 0x84, 0xcc, 0x3e, 0xc9, 0xe3, 0x58, 0xfb, 0x86, 0xfb, 0x2a, 0x67, 0x21, 0x66, 0x12, 0x9, 0x0, 0x11, - 0x0, 0x99, 0x76, 0xb3, 0x6a, 0xc5, 0x23, 0xc0, 0xeb, 0x74, 0xa4, 0xdd, 0x56, 0x15, 0x7c, 0x69, 0x30, - 0x8f, 0xa1, 0x0, 0xa2, 0x1, 0x83, 0x8f, 0x1, 0x0, 0x1, 0x1}; + uint8_t pkt[] = {0x90, 0x7, 0x7b, 0xa, 0x0, 0x9e, 0x91, 0x9e, 0x8f}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[11]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11397); - EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], 0x8F); - EXPECT_EQ(granted_qos_levels[1], 0xA1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0xA2); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], 0x83); - EXPECT_EQ(granted_qos_levels[6], 0x8F); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[9], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS1); -} - -// SubscribeResponse 5337 [Left SubErrTopicFilterInvalid] [PropSubscriptionIdentifierAvailable 45,PropCorrelationData -// "\204\r\185L\153\176\USc\190m\215\233\221\NUL\174",PropTopicAlias 5305,PropReasonString "",PropContentType -// "\171\190\177\196\244\164_S3#\229\USc\162H7T\DC19\155_\145\210\203\154\190m5",PropSubscriptionIdentifier -// 26,PropMaximumQoS 122,PropReasonString "q\208\160\130[\213VO\170",PropPayloadFormatIndicator 47,PropMaximumPacketSize -// 10768,PropSubscriptionIdentifier 17,PropSubscriptionIdentifierAvailable 104,PropMessageExpiryInterval -// 27024,PropRequestProblemInformation 236,PropAssignedClientIdentifier -// "\228\SUB\233\ESC",PropWildcardSubscriptionAvailable 194,PropResponseInformation "",PropCorrelationData -// "\237\219\248\"6\v\236\128\NAK\233",PropRequestResponseInformation 80,PropTopicAlias 19929,PropTopicAlias -// 3674,PropAuthenticationMethod "FQp",PropWillDelayInterval 8789,PropSharedSubscriptionAvailable 166,PropTopicAlias -// 17706,PropTopicAlias 3711,PropPayloadFormatIndicator 75,PropAuthenticationData -// "_\133\195\STX:%{\181a\128\204pxv\152\239\170\132\216\139\227",PropReasonString -// "\133\236\146]7c\236a\GS$v\248\230\182\169\165\SO\241\ACK",PropResponseInformation "b;"] + EXPECT_EQ(packet_id, 31498); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], 0x91); + EXPECT_EQ(granted_qos_levels[2], 0x9E); + EXPECT_EQ(granted_qos_levels[3], 0x8F); +} + +// SubscribeResponse 3933 [Left SubErrImplementationSpecificError,Right QoS2] [] TEST(SubACK5QCTest, Decode15) { - uint8_t pkt[] = { - 0x90, 0xc9, 0x1, 0x14, 0xd9, 0xc4, 0x1, 0x29, 0x2d, 0x9, 0x0, 0xf, 0xcc, 0xd, 0xb9, 0x4c, 0x99, 0xb0, 0x1f, - 0x63, 0xbe, 0x6d, 0xd7, 0xe9, 0xdd, 0x0, 0xae, 0x23, 0x14, 0xb9, 0x1f, 0x0, 0x0, 0x3, 0x0, 0x1c, 0xab, 0xbe, - 0xb1, 0xc4, 0xf4, 0xa4, 0x5f, 0x53, 0x33, 0x23, 0xe5, 0x1f, 0x63, 0xa2, 0x48, 0x37, 0x54, 0x11, 0x39, 0x9b, 0x5f, - 0x91, 0xd2, 0xcb, 0x9a, 0xbe, 0x6d, 0x35, 0xb, 0x1a, 0x24, 0x7a, 0x1f, 0x0, 0x9, 0x71, 0xd0, 0xa0, 0x82, 0x5b, - 0xd5, 0x56, 0x4f, 0xaa, 0x1, 0x2f, 0x27, 0x0, 0x0, 0x2a, 0x10, 0xb, 0x11, 0x29, 0x68, 0x2, 0x0, 0x0, 0x69, - 0x90, 0x17, 0xec, 0x12, 0x0, 0x4, 0xe4, 0x1a, 0xe9, 0x1b, 0x28, 0xc2, 0x1a, 0x0, 0x0, 0x9, 0x0, 0xa, 0xed, - 0xdb, 0xf8, 0x22, 0x36, 0xb, 0xec, 0x80, 0x15, 0xe9, 0x19, 0x50, 0x23, 0x4d, 0xd9, 0x23, 0xe, 0x5a, 0x15, 0x0, - 0x3, 0x46, 0x51, 0x70, 0x18, 0x0, 0x0, 0x22, 0x55, 0x2a, 0xa6, 0x23, 0x45, 0x2a, 0x23, 0xe, 0x7f, 0x1, 0x4b, - 0x16, 0x0, 0x15, 0x5f, 0x85, 0xc3, 0x2, 0x3a, 0x25, 0x7b, 0xb5, 0x61, 0x80, 0xcc, 0x70, 0x78, 0x76, 0x98, 0xef, - 0xaa, 0x84, 0xd8, 0x8b, 0xe3, 0x1f, 0x0, 0x13, 0x85, 0xec, 0x92, 0x5d, 0x37, 0x63, 0xec, 0x61, 0x1d, 0x24, 0x76, - 0xf8, 0xe6, 0xb6, 0xa9, 0xa5, 0xe, 0xf1, 0x6, 0x1a, 0x0, 0x2, 0x62, 0x3b, 0x8f}; + uint8_t pkt[] = {0x90, 0x5, 0xf, 0x5d, 0x0, 0x83, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[2]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 5337); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], 0x8F); -} - -// SubscribeResponse 32213 [Left SubErrQuotaExceeded,Right QoS0,Right QoS0,Left -// SubErrSharedSubscriptionsNotSupported,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1] -// [PropRequestResponseInformation 95,PropAuthenticationMethod "R\NAK",PropWillDelayInterval 32360,PropMaximumPacketSize -// 7542,PropResponseInformation -// "S\150\133\ESC\186\136\230\187\237O\232\164\251\236\190,2\146\147\198\139\152\&6",PropMaximumPacketSize -// 8765,PropSubscriptionIdentifier 19,PropAuthenticationMethod -// "\NAKV\239\253\251\DEL\197\250!\f\249\DC2\229<\145\DC2\130\SUB\DC4\168\132\182\250\245\159\193\SUB\SI\214?",PropResponseInformation -// "V5d6\ENQ",PropContentType "R7\136\236T/G",PropRetainAvailable 232,PropServerKeepAlive 16300,PropWillDelayInterval -// 8409,PropPayloadFormatIndicator 63,PropContentType "\229\149'/\STXd\227\200%\254\159W",PropUserProperty -// "Dj\147\209\216\"\226&6S\158\224\SYN@" -// "k\226V\204\207\174\196q\178pQ\162\183\&1\t\239\&2\135\232(\138N\228\&5\153\234&G",PropServerKeepAlive -// 10969,PropRetainAvailable 217,PropReasonString "\210\FS\138\150M",PropTopicAlias 533] + EXPECT_EQ(packet_id, 3933); + EXPECT_EQ(count, 2); + EXPECT_EQ(granted_qos_levels[0], 0x83); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); +} + +// SubscribeResponse 30590 [Left SubErrSubscriptionIdentifiersNotSupported,Right QoS2,Left SubErrQuotaExceeded,Right +// QoS0,Left SubErrUnspecifiedError,Left SubErrPacketIdentifierInUse,Left SubErrQuotaExceeded,Right QoS1,Right QoS2] +// [PropAuthenticationMethod "\\\140\141\250\DLE\ENQ\DC4.\213",PropSubscriptionIdentifierAvailable +// 34,PropCorrelationData "\163",PropServerReference "\152\192\172",PropMessageExpiryInterval +// 22139,PropResponseInformation +// "ze\161\210U\186\203\212\184E\149;w\bbDW\186d\131\ETX}\183\SI\137>u\SO\185",PropWillDelayInterval +// 32115,PropSubscriptionIdentifier 29,PropWillDelayInterval 10222,PropReasonString "\185\STX,",PropCorrelationData +// "1\SOH\\(\227\236\182J\RSU\a\178[\tvFm\203\DEL_",PropResponseTopic +// "\148k\144L\212\195\255\255\&1j\243\177\236'\173",PropContentType +// "\237\249\131k\DELf\186",PropRequestResponseInformation 147,PropUserProperty "" +// "\147\188\206\237\251\&4\EM)\242\244\230)\250\168\US\148\219\239[\189\162o",PropRequestProblemInformation +// 156,PropSubscriptionIdentifierAvailable 196,PropPayloadFormatIndicator 187,PropResponseInformation +// "\167W\128\175\207y\\j\229\185\132",PropSubscriptionIdentifier 29,PropServerKeepAlive +// 26894,PropSubscriptionIdentifier 20] TEST(SubACK5QCTest, Decode16) { - uint8_t pkt[] = {0x90, 0xc9, 0x1, 0x7d, 0xd5, 0xbf, 0x1, 0x19, 0x5f, 0x15, 0x0, 0x2, 0x52, 0x15, 0x18, 0x0, 0x0, - 0x7e, 0x68, 0x27, 0x0, 0x0, 0x1d, 0x76, 0x1a, 0x0, 0x17, 0x53, 0x96, 0x85, 0x1b, 0xba, 0x88, 0xe6, - 0xbb, 0xed, 0x4f, 0xe8, 0xa4, 0xfb, 0xec, 0xbe, 0x2c, 0x32, 0x92, 0x93, 0xc6, 0x8b, 0x98, 0x36, 0x27, - 0x0, 0x0, 0x22, 0x3d, 0xb, 0x13, 0x15, 0x0, 0x1e, 0x15, 0x56, 0xef, 0xfd, 0xfb, 0x7f, 0xc5, 0xfa, - 0x21, 0xc, 0xf9, 0x12, 0xe5, 0x3c, 0x91, 0x12, 0x82, 0x1a, 0x14, 0xa8, 0x84, 0xb6, 0xfa, 0xf5, 0x9f, - 0xc1, 0x1a, 0xf, 0xd6, 0x3f, 0x1a, 0x0, 0x5, 0x56, 0x35, 0x64, 0x36, 0x5, 0x3, 0x0, 0x7, 0x52, - 0x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 0x2c, 0x9, 0x0, 0x14, 0x31, 0x1, 0x5c, 0x28, 0xe3, 0xec, 0xb6, 0x4a, 0x1e, 0x55, 0x7, 0xb2, 0x5b, + 0x9, 0x76, 0x46, 0x6d, 0xcb, 0x7f, 0x5f, 0x8, 0x0, 0xf, 0x94, 0x6b, 0x90, 0x4c, 0xd4, 0xc3, 0xff, + 0xff, 0x31, 0x6a, 0xf3, 0xb1, 0xec, 0x27, 0xad, 0x3, 0x0, 0x7, 0xed, 0xf9, 0x83, 0x6b, 0x7f, 0x66, + 0xba, 0x19, 0x93, 0x26, 0x0, 0x0, 0x0, 0x16, 0x93, 0xbc, 0xce, 0xed, 0xfb, 0x34, 0x19, 0x29, 0xf2, + 0xf4, 0xe6, 0x29, 0xfa, 0xa8, 0x1f, 0x94, 0xdb, 0xef, 0x5b, 0xbd, 0xa2, 0x6f, 0x17, 0x9c, 0x29, 0xc4, + 0x1, 0xbb, 0x1a, 0x0, 0xb, 0xa7, 0x57, 0x80, 0xaf, 0xcf, 0x79, 0x5c, 0x6a, 0xe5, 0xb9, 0x84, 0xb, + 0x1d, 0x13, 0x69, 0xe, 0xb, 0x14, 0xa1, 0x2, 0x97, 0x0, 0x80, 0x91, 0x97, 0x1, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[9]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32213); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], 0x97); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], 0x9E); - EXPECT_EQ(granted_qos_levels[4], 0xA2); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 30590); + EXPECT_EQ(count, 9); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x97); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0x91); + EXPECT_EQ(granted_qos_levels[6], 0x97); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); } -// SubscribeResponse 1504 [Left SubErrSubscriptionIdentifiersNotSupported,Left -// SubErrSharedSubscriptionsNotSupported,Right QoS1,Left SubErrTopicFilterInvalid,Right QoS1,Right QoS1] -// [PropAssignedClientIdentifier -// "]{=K\190\169\DC1\ACK\198O\136\201Q\139A\f\166\129\ENQ_'\129\177-",PropMessageExpiryInterval -// 790,PropWildcardSubscriptionAvailable 36,PropMessageExpiryInterval 14665,PropCorrelationData -// "\DC4z\197\143",PropServerKeepAlive 22506,PropSubscriptionIdentifierAvailable 30,PropSharedSubscriptionAvailable -// 13,PropSharedSubscriptionAvailable 219,PropWildcardSubscriptionAvailable 255,PropMaximumPacketSize -// 14962,PropServerKeepAlive 19142,PropSharedSubscriptionAvailable 249,PropResponseInformation -// "\b$\\\SOH\160",PropAssignedClientIdentifier -// "\EM\157$\ETXj\EOTx\165\212\140@\191\SOH)\148\ENQ\t\129{\SODX\196\US",PropPayloadFormatIndicator -// 195,PropMaximumPacketSize 23289,PropRequestResponseInformation 44,PropResponseTopic -// "\NUL\199\EM{\183\&3h\150-\255\222\220",PropWillDelayInterval 8389,PropUserProperty "\165=\171)`\156\230\219:" -// "]\194",PropAuthenticationData -// "\161US\214\135'c\NUL\ESC\252Qp\DC1,QN_\223\162\EM\197\178bI:",PropMessageExpiryInterval 15146,PropMaximumPacketSize -// 27405,PropCorrelationData "B}\198\SOH\163",PropMessageExpiryInterval 26861,PropAssignedClientIdentifier -// "\159\129\199\236\243\179\b\219\239RU\227\159\149\183b\161r|y\172\202FQ\NUL\"\136\186",PropSessionExpiryInterval -// 30259] +// SubscribeResponse 28125 [Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Right QoS2] [PropRetainAvailable +// 157,PropSharedSubscriptionAvailable 195,PropRequestProblemInformation 101,PropSubscriptionIdentifierAvailable +// 103,PropRequestResponseInformation 216,PropSubscriptionIdentifierAvailable 245,PropReceiveMaximum +// 30247,PropSubscriptionIdentifierAvailable 137,PropPayloadFormatIndicator 102,PropSubscriptionIdentifierAvailable +// 66,PropTopicAliasMaximum 21408,PropReasonString +// "\188\DC3\DLE\211$\134D$2\146\166\224\161Z\155\"\NAK\194\213BWK\193\ESC' d\173",PropSessionExpiryInterval +// 2424,PropResponseTopic "\DC4\f\143\251 ",PropMessageExpiryInterval 20858,PropTopicAliasMaximum +// 32445,PropRequestResponseInformation 243,PropSubscriptionIdentifier 2,PropRetainAvailable +// 111,PropWildcardSubscriptionAvailable 73,PropWildcardSubscriptionAvailable 2,PropContentType +// "\204\162\181\145\221T\DC3\233\153\rA\150#\DLER\246`\255V\154\DC46\231\195\DC1\DC3",PropSharedSubscriptionAvailable +// 70] TEST(SubACK5QCTest, Decode17) { - uint8_t pkt[] = { - 0x90, 0xf4, 0x1, 0x5, 0xe0, 0xea, 0x1, 0x12, 0x0, 0x18, 0x5d, 0x7b, 0x3d, 0x4b, 0xbe, 0xa9, 0x11, 0x6, 0xc6, - 0x4f, 0x88, 0xc9, 0x51, 0x8b, 0x41, 0xc, 0xa6, 0x81, 0x5, 0x5f, 0x27, 0x81, 0xb1, 0x2d, 0x2, 0x0, 0x0, 0x3, - 0x16, 0x28, 0x24, 0x2, 0x0, 0x0, 0x39, 0x49, 0x9, 0x0, 0x4, 0x14, 0x7a, 0xc5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, 0xa1, 0x9e, 0x1, 0x8f, 0x1, 0x1}; + uint8_t pkt[] = {0x90, 0x7b, 0x6d, 0xdd, 0x75, 0x25, 0x9d, 0x2a, 0xc3, 0x17, 0x65, 0x29, 0x67, 0x19, 0xd8, 0x29, + 0xf5, 0x21, 0x76, 0x27, 0x29, 0x89, 0x1, 0x66, 0x29, 0x42, 0x22, 0x53, 0xa0, 0x1f, 0x0, 0x1c, + 0xbc, 0x13, 0x10, 0xd3, 0x24, 0x86, 0x44, 0x24, 0x32, 0x92, 0xa6, 0xe0, 0xa1, 0x5a, 0x9b, 0x22, + 0x15, 0xc2, 0xd5, 0x42, 0x57, 0x4b, 0xc1, 0x1b, 0x27, 0x20, 0x64, 0xad, 0x11, 0x0, 0x0, 0x9, + 0x78, 0x8, 0x0, 0x5, 0x14, 0xc, 0x8f, 0xfb, 0x20, 0x2, 0x0, 0x0, 0x51, 0x7a, 0x22, 0x7e, + 0xbd, 0x19, 0xf3, 0xb, 0x2, 0x25, 0x6f, 0x28, 0x49, 0x28, 0x2, 0x3, 0x0, 0x1a, 0xcc, 0xa2, + 0xb5, 0x91, 0xdd, 0x54, 0x13, 0xe9, 0x99, 0xd, 0x41, 0x96, 0x23, 0x10, 0x52, 0xf6, 0x60, 0xff, + 0x56, 0x9a, 0x14, 0x36, 0xe7, 0xc3, 0x11, 0x13, 0x2a, 0x46, 0x80, 0x80, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[3]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 1504); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], 0xA1); - EXPECT_EQ(granted_qos_levels[1], 0x9E); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[3], 0x8F); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); + EXPECT_EQ(packet_id, 28125); + EXPECT_EQ(count, 3); + EXPECT_EQ(granted_qos_levels[0], 0x80); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); } -// SubscribeResponse 2008 [Right QoS2,Left SubErrSharedSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right -// QoS2,Left SubErrUnspecifiedError] [PropMessageExpiryInterval 29625,PropMessageExpiryInterval -// 15421,PropRequestProblemInformation 41,PropCorrelationData -// "_\233\&9\245\tW<\EMf\218\240v\188\211\DLE\253\141\171\248\214DM\"\149\159}4\167\NUL",PropRequestResponseInformation -// 19,PropReasonString "2\164BN%\a\b\253\242\233\204",PropTopicAlias 26560,PropSharedSubscriptionAvailable -// 21,PropContentType "a\159-\243\&1",PropMessageExpiryInterval 7597,PropRetainAvailable 98,PropPayloadFormatIndicator -// 87,PropSubscriptionIdentifier 31,PropWildcardSubscriptionAvailable 5,PropContentType "",PropUserProperty -// "\ESC\249\SYNna\169" -// "\NAK\221\215\207\r\155Qf\231\194c\177e\226k\187z\191t\212\241D\181\&4\188\f\FS\140",PropSessionExpiryInterval -// 18569,PropSubscriptionIdentifierAvailable 223,PropAssignedClientIdentifier -// "8,\254\&7\160vs\166\&3",PropSharedSubscriptionAvailable 170,PropSharedSubscriptionAvailable 53] +// SubscribeResponse 3160 [Right QoS1,Right QoS0,Left SubErrUnspecifiedError,Left SubErrUnspecifiedError,Right QoS1,Left +// SubErrSharedSubscriptionsNotSupported,Left SubErrUnspecifiedError,Right QoS0,Right QoS0] +// [PropSharedSubscriptionAvailable 76,PropReceiveMaximum 15225,PropUserProperty "U\238\139\214\154\240" +// "\130G\207\183\208\179t\233t_\SIQ",PropResponseTopic "\STX\166\198\157aZ\157h\254\&0\195\168",PropWillDelayInterval +// 2577,PropUserProperty "+\138\&6m\163\222\142x\vh\254\SI+\213\US\217\134\170`" +// "\213\237\FS\138\163",PropServerReference +// "\DLE\177qU\148}\208\204V\DLEO\NUL}\233\DLE\163\191O\240\199\152\191\199\191{",PropContentType +// "\161\130\246\DC3\CAN\t\160\191h\254^6U\140\RS\EM\CAN\245D\DC1W\218\134\&7\r5\EM\NAK\211\186",PropAuthenticationMethod +// "\135",PropSessionExpiryInterval +// 8714,PropMaximumPacketSize 21604,PropRequestResponseInformation 176,PropTopicAliasMaximum +// 9879,PropAuthenticationMethod "cm\179\170\206\232\153\198d\210w\EM|\ETB\131\225V\f\224|k$\176v\208\&5",PropTopicAlias 551,PropMaximumPacketSize -// 28489,PropSessionExpiryInterval 11350,PropTopicAlias 3242,PropRetainAvailable 58] +// SubscribeResponse 3809 [Left SubErrQuotaExceeded,Left SubErrImplementationSpecificError,Right QoS2,Right QoS1,Right +// QoS2] [PropResponseTopic "u1\223\ETXg\161\176\187<:no\149\SO\178K\191\169D\136\180\242\ENQ\167",PropUserProperty +// "2(\SO@\196\223\253" "\166DC;\164\242",PropTopicAliasMaximum 24232,PropAssignedClientIdentifier +// "\245a1\151\RSZxB\241\225]#\209\188\227\223\202Z||35\205\145\251",PropServerKeepAlive +// 25418,PropAssignedClientIdentifier "H\"\EM\161G\DC3Tv",PropTopicAliasMaximum 13091,PropRetainAvailable +// 181,PropRequestProblemInformation 158,PropMessageExpiryInterval 17141,PropSubscriptionIdentifierAvailable +// 173,PropContentType "",PropReceiveMaximum 23469,PropSubscriptionIdentifierAvailable 240,PropResponseInformation +// "\238\US\152\SOHaH",PropReasonString +// "\180\RS\229\218\r\143U\232\RS\232Aw\162\GS0d\246\r\134\GS",PropRequestResponseInformation 143,PropServerReference +// "%!t\230!-\SUBr\226",PropPayloadFormatIndicator 93,PropPayloadFormatIndicator 63,PropMessageExpiryInterval +// 16399,PropPayloadFormatIndicator 224,PropSubscriptionIdentifier 10,PropCorrelationData +// "\229\184@\235\241\239Z\SOH\239\SUBg\133j?/d\235",PropTopicAlias 30988,PropTopicAliasMaximum 16331] TEST(SubACK5QCTest, Decode21) { - uint8_t pkt[] = {0x90, 0xfb, 0x1, 0x55, 0x8d, 0xf3, 0x1, 0x12, 0x0, 0x5, 0xa1, 0xb9, 0xaa, 0xee, 0x6, 0x22, 0x35, - 0x38, 0x8, 0x0, 0x1c, 0x1f, 0x7b, 0x45, 0xf9, 0x86, 0xe, 0x78, 0xd7, 0x4a, 0xf3, 0xfa, 0x23, 0x5d, - 0x82, 0x21, 0xa5, 0xca, 0x65, 0x8f, 0xc2, 0x78, 0x27, 0x43, 0x10, 0xc7, 0xdf, 0xdf, 0x66, 0x2a, 0x20, - 0x23, 0x50, 0xb7, 0x25, 0x9f, 0x8, 0x0, 0xc, 0xef, 0x25, 0xcb, 0xe8, 0xad, 0x20, 0xe6, 0xb1, 0xfc, - 0x65, 0xce, 0x90, 0x15, 0x0, 0x10, 0x84, 0x16, 0x11, 0xf, 0x4a, 0xbd, 0x4a, 0xe1, 0x72, 0x86, 0x11, - 0x82, 0xe8, 0x40, 0x35, 0x6, 0x12, 0x0, 0x4, 0xc7, 0x90, 0xef, 0xc5, 0x21, 0x2f, 0x3, 0x12, 0x0, - 0xe, 0xaa, 0x93, 0x30, 0x23, 0x93, 0xfb, 0x6e, 0x8b, 0xd9, 0x5e, 0x7e, 0x62, 0xe5, 0x81, 0x2, 0x0, - 0x0, 0x43, 0x3d, 0x15, 0x0, 0x18, 0xb4, 0x63, 0xb4, 0xaa, 0xe2, 0x7, 0x86, 0xec, 0x97, 0x5e, 0x4c, - 0x74, 0xcb, 0xaf, 0x1e, 0x77, 0x95, 0x58, 0x34, 0x43, 0x6a, 0x22, 0x67, 0xb, 0x28, 0x76, 0x28, 0x64, - 0x26, 0x0, 0x4, 0x63, 0x7, 0x68, 0x9c, 0x0, 0x1e, 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x19, 0xa1, 0x47, 0x13, + 0x54, 0x76, 0x22, 0x33, 0x23, 0x25, 0xb5, 0x17, 0x9e, 0x2, 0x0, 0x0, 0x42, 0xf5, 0x29, 0xad, 0x3, 0x0, 0x0, + 0x21, 0x5b, 0xad, 0x29, 0xf0, 0x1a, 0x0, 0x6, 0xee, 0x1f, 0x98, 0x1, 0x61, 0x48, 0x1f, 0x0, 0x14, 0xb4, 0x1e, + 0xe5, 0xda, 0xd, 0x8f, 0x55, 0xe8, 0x1e, 0xe8, 0x41, 0x77, 0xa2, 0x1d, 0x30, 0x64, 0xf6, 0xd, 0x86, 0x1d, 0x19, + 0x8f, 0x1c, 0x0, 0x9, 0x25, 0x21, 0x74, 0xe6, 0x21, 0x2d, 0x1a, 0x72, 0xe2, 0x1, 0x5d, 0x1, 0x3f, 0x2, 0x0, + 0x0, 0x40, 0xf, 0x1, 0xe0, 0xb, 0xa, 0x9, 0x0, 0x11, 0xe5, 0xb8, 0x40, 0xeb, 0xf1, 0xef, 0x5a, 0x1, 0xef, + 0x1a, 0x67, 0x85, 0x6a, 0x3f, 0x2f, 0x64, 0xeb, 0x23, 0x79, 0xc, 0x22, 0x3f, 0xcb, 0x97, 0x83, 0x2, 0x1, 0x2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21901); - EXPECT_EQ(count, 4); + EXPECT_EQ(packet_id, 3809); + EXPECT_EQ(count, 5); EXPECT_EQ(granted_qos_levels[0], 0x97); EXPECT_EQ(granted_qos_levels[1], 0x83); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); } -// SubscribeResponse 9953 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Right QoS1] -// [PropSessionExpiryInterval 12233,PropSubscriptionIdentifierAvailable 133,PropTopicAliasMaximum -// 26913,PropReceiveMaximum 13582,PropReceiveMaximum 4922,PropAuthenticationMethod -// "\204\r\b:fo\DC2\160\238\ETX\ENQ\128\139\&0\139\246\218\&8\194",PropMessageExpiryInterval -// 15793,PropAuthenticationMethod "J",PropSubscriptionIdentifierAvailable 80,PropAssignedClientIdentifier -// "",PropResponseTopic "",PropSessionExpiryInterval 23870,PropUserProperty "\185\t" -// "Qi\202\&1\173#\ETB\212L5\226l\DC1H\223\132\157\238\&9\131\184\219\205\t",PropReceiveMaximum -// 16774,PropTopicAliasMaximum 28939,PropResponseInformation -// "\187y\185C\173\136\210\241\209\194X\ETB\212(\197\192\212A\\\226\DC3\206&o0\144\226\173\252)",PropMaximumQoS -// 209,PropTopicAliasMaximum 30629,PropSubscriptionIdentifierAvailable 235,PropMessageExpiryInterval -// 16775,PropWildcardSubscriptionAvailable 24,PropSubscriptionIdentifier 0,PropReasonString -// "\169\255\EOT*\218\131L\182bR@\SO4",PropReasonString "[0qc\193\200\154\181t\USUEF"] +// SubscribeResponse 6533 [Left SubErrPacketIdentifierInUse,Right QoS2,Left SubErrNotAuthorized,Right QoS0,Left +// SubErrSharedSubscriptionsNotSupported] [PropTopicAliasMaximum 13206,PropResponseInformation +// "\190\190\208s",PropCorrelationData "\170\168\249\152\225z\155c\197\181\220z",PropResponseInformation +// "\220~\182[\\'`B\189@O4N\DC4\132",PropServerReference +// "\132U\175\170!bWrenG:\177\253\153R.yM\192\171\238\214\157",PropRetainAvailable 146,PropWildcardSubscriptionAvailable +// 78,PropServerKeepAlive 29048,PropRequestResponseInformation 130] TEST(SubACK5QCTest, Decode22) { - uint8_t pkt[] = { - 0x90, 0xb9, 0x1, 0x26, 0xe1, 0xb2, 0x1, 0x11, 0x0, 0x0, 0x2f, 0xc9, 0x29, 0x85, 0x22, 0x69, 0x21, 0x21, 0x35, - 0xe, 0x21, 0x13, 0x3a, 0x15, 0x0, 0x13, 0xcc, 0xd, 0x8, 0x3a, 0x66, 0x6f, 0x12, 0xa0, 0xee, 0x3, 0x5, 0x80, - 0x8b, 0x30, 0x8b, 0xf6, 0xda, 0x38, 0xc2, 0x2, 0x0, 0x0, 0x3d, 0xb1, 0x15, 0x0, 0x1, 0x4a, 0x29, 0x50, 0x12, - 0x0, 0x0, 0x8, 0x0, 0x0, 0x11, 0x0, 0x0, 0x5d, 0x3e, 0x26, 0x0, 0x2, 0xb9, 0x9, 0x0, 0x18, 0x51, 0x69, - 0xca, 0x31, 0xad, 0x23, 0x17, 0xd4, 0x4c, 0x35, 0xe2, 0x6c, 0x11, 0x48, 0xdf, 0x84, 0x9d, 0xee, 0x39, 0x83, 0xb8, - 0xdb, 0xcd, 0x9, 0x21, 0x41, 0x86, 0x22, 0x71, 0xb, 0x1a, 0x0, 0x1e, 0xbb, 0x79, 0xb9, 0x43, 0xad, 0x88, 0xd2, - 0xf1, 0xd1, 0xc2, 0x58, 0x17, 0xd4, 0x28, 0xc5, 0xc0, 0xd4, 0x41, 0x5c, 0xe2, 0x13, 0xce, 0x26, 0x6f, 0x30, 0x90, - 0xe2, 0xad, 0xfc, 0x29, 0x24, 0xd1, 0x22, 0x77, 0xa5, 0x29, 0xeb, 0x2, 0x0, 0x0, 0x41, 0x87, 0x28, 0x18, 0xb, - 0x0, 0x1f, 0x0, 0xd, 0xa9, 0xff, 0x4, 0x2a, 0xda, 0x83, 0x4c, 0xb6, 0x62, 0x52, 0x40, 0xe, 0x34, 0x1f, 0x0, - 0xd, 0x5b, 0x30, 0x71, 0x63, 0xc1, 0xc8, 0x9a, 0xb5, 0x74, 0x1f, 0x55, 0x45, 0x46, 0x0, 0xa2, 0x1}; + uint8_t pkt[] = {0x90, 0x57, 0x19, 0x85, 0x4f, 0x22, 0x33, 0x96, 0x1a, 0x0, 0x4, 0xbe, 0xbe, 0xd0, 0x73, + 0x9, 0x0, 0xc, 0xaa, 0xa8, 0xf9, 0x98, 0xe1, 0x7a, 0x9b, 0x63, 0xc5, 0xb5, 0xdc, 0x7a, + 0x1a, 0x0, 0xf, 0xdc, 0x7e, 0xb6, 0x5b, 0x5c, 0x27, 0x60, 0x42, 0xbd, 0x40, 0x4f, 0x34, + 0x4e, 0x14, 0x84, 0x1c, 0x0, 0x18, 0x84, 0x55, 0xaf, 0xaa, 0x21, 0x62, 0x57, 0x72, 0x65, + 0x6e, 0x47, 0x3a, 0xb1, 0xfd, 0x99, 0x52, 0x2e, 0x79, 0x4d, 0xc0, 0xab, 0xee, 0xd6, 0x9d, + 0x25, 0x92, 0x28, 0x4e, 0x13, 0x71, 0x78, 0x19, 0x82, 0x91, 0x2, 0x87, 0x0, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[5]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 5, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 9953); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0xA2); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); -} - -// SubscribeResponse 21846 [Left SubErrTopicFilterInvalid,Left SubErrImplementationSpecificError,Right QoS2,Right -// QoS1,Right QoS0,Right QoS0,Left SubErrImplementationSpecificError,Left SubErrTopicFilterInvalid,Right QoS2] -// [PropResponseTopic "1\219\195",PropReceiveMaximum 15914] + EXPECT_EQ(packet_id, 6533); + EXPECT_EQ(count, 5); + EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], 0x87); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x9E); +} + +// SubscribeResponse 28202 [Right QoS1,Left SubErrQuotaExceeded,Left SubErrSharedSubscriptionsNotSupported,Right +// QoS2,Left SubErrUnspecifiedError,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1,Right QoS0,Right QoS1,Left +// SubErrSharedSubscriptionsNotSupported,Right QoS0] [PropContentType +// "\FS\138\DC2\157\187{",PropWildcardSubscriptionAvailable 254,PropRequestResponseInformation 224,PropUserProperty +// "\223<\181\163u\224\SOH\174Q\227\182\&6" +// "gJ\164\252}\161\211\204DT6:\158\SYND\241\189N\208X\246~\199v\189f\219\NUL\138",PropRetainAvailable +// 35,PropSubscriptionIdentifier 27,PropCorrelationData "\130\158\164,\USlz\207<\217",PropMessageExpiryInterval +// 21387,PropRetainAvailable 36,PropSubscriptionIdentifier 16,PropSharedSubscriptionAvailable 64,PropMaximumQoS +// 62,PropAuthenticationData "\255\153@\STX\DC242H",PropMessageExpiryInterval 6125,PropSubscriptionIdentifierAvailable +// 14,PropSubscriptionIdentifierAvailable 59,PropRequestProblemInformation 176,PropMaximumQoS 17,PropAuthenticationData +// "\192C'\146|\253t\232\164\184\183\252\217\197f\tG5\244",PropMaximumQoS 184,PropMaximumPacketSize +// 7475,PropTopicAliasMaximum 11374] TEST(SubACK5QCTest, Decode23) { - uint8_t pkt[] = {0x90, 0x15, 0x55, 0x56, 0x9, 0x8, 0x0, 0x3, 0x31, 0xdb, 0xc3, 0x21, - 0x3e, 0x2a, 0x8f, 0x83, 0x2, 0x1, 0x0, 0x0, 0x83, 0x8f, 0x2}; + uint8_t pkt[] = {0x90, 0xa0, 0x1, 0x6e, 0x2a, 0x91, 0x1, 0x3, 0x0, 0x6, 0x1c, 0x8a, 0x12, 0x9d, 0xbb, 0x7b, 0x28, + 0xfe, 0x19, 0xe0, 0x26, 0x0, 0xc, 0xdf, 0x3c, 0xb5, 0xa3, 0x75, 0xe0, 0x1, 0xae, 0x51, 0xe3, 0xb6, + 0x36, 0x0, 0x1d, 0x67, 0x4a, 0xa4, 0xfc, 0x7d, 0xa1, 0xd3, 0xcc, 0x44, 0x54, 0x36, 0x3a, 0x9e, 0x16, + 0x44, 0xf1, 0xbd, 0x4e, 0xd0, 0x58, 0xf6, 0x7e, 0xc7, 0x76, 0xbd, 0x66, 0xdb, 0x0, 0x8a, 0x25, 0x23, + 0xb, 0x1b, 0x9, 0x0, 0xa, 0x82, 0x9e, 0xa4, 0x2c, 0x1f, 0x6c, 0x7a, 0xcf, 0x3c, 0xd9, 0x2, 0x0, + 0x0, 0x53, 0x8b, 0x25, 0x24, 0xb, 0x10, 0x2a, 0x40, 0x24, 0x3e, 0x16, 0x0, 0x8, 0xff, 0x99, 0x40, + 0x2, 0x12, 0x34, 0x32, 0x48, 0x2, 0x0, 0x0, 0x17, 0xed, 0x29, 0xe, 0x29, 0x3b, 0x17, 0xb0, 0x24, + 0x11, 0x16, 0x0, 0x13, 0xc0, 0x43, 0x27, 0x92, 0x7c, 0xfd, 0x74, 0xe8, 0xa4, 0xb8, 0xb7, 0xfc, 0xd9, + 0xc5, 0x66, 0x9, 0x47, 0x35, 0xf4, 0x24, 0xb8, 0x27, 0x0, 0x0, 0x1d, 0x33, 0x22, 0x2c, 0x6e, 0x1, + 0x97, 0x9e, 0x2, 0x80, 0xa1, 0x1, 0x0, 0x1, 0x9e, 0x0}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[9]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21846); - EXPECT_EQ(count, 9); - EXPECT_EQ(granted_qos_levels[0], 0x8F); - EXPECT_EQ(granted_qos_levels[1], 0x83); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[6], 0x83); - EXPECT_EQ(granted_qos_levels[7], 0x8F); - EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 28202); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0x97); + EXPECT_EQ(granted_qos_levels[2], 0x9E); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x80); + EXPECT_EQ(granted_qos_levels[5], 0xA1); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[9], 0x9E); + EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); } -// SubscribeResponse 25983 [Right QoS2] [PropContentType -// "\226\147\228\236\217\ACK\EM\208\EOT\226\&2R\194\220?o\ESC\195;\167",PropAuthenticationData -// "s);\STX\212}\159\149\EOTojM]X\190\250\243\255\206y\228\247W\184\FS",PropTopicAlias -// 7197,PropSharedSubscriptionAvailable 46,PropRequestResponseInformation 68,PropResponseInformation -// "\133S\SIZy\249@",PropReasonString "8'\180\EOT\178V\144\210\133\198b\\V\146l\US|a\218\&4\v",PropAuthenticationMethod -// "\SOHwl<\204K\233\221\SI",PropReceiveMaximum 20194,PropWildcardSubscriptionAvailable 45,PropMessageExpiryInterval -// 5182,PropContentType "\197\158\212\SOH\163\206\241`\177G\164\238\RS\187\185\v",PropContentType -// "Kb\140.\224\233\144\182E\"B\214\DLE\162Ry\228o\135\180\DC1\SI\139\&4\ESC\168\246\CANE|",PropContentType -// "\172X\191\201\149\166\DC3\212\218\\\137\193\255\179\GS_\230\232\tS\169\137\SOH\202Y\ETBH\208\133",PropWildcardSubscriptionAvailable -// 87,PropTopicAlias 26805,PropReasonString -// "r\ETX\137\EOT@\223,\222\DC4b\EOT\229\152\EOT\ENQ\ENQC\157i\SO\234\DLE\EOT",PropPayloadFormatIndicator -// 16,PropAssignedClientIdentifier "\151\253;#\236\208/;\ENQq\138\157KR\239\169\230.\150\203,l\137\197",PropReasonString -// "\253`j\135K\142\ENQ6\182\t",PropRetainAvailable 151,PropSubscriptionIdentifierAvailable 255,PropResponseInformation -// "",PropReceiveMaximum 23704,PropReasonString "\ACK\235I\SOH\208\254\150l\172",PropAuthenticationMethod -// "e*{\ESC\215H2\SYN!\re1\208G\173[\SYNdX\194\185\FS\DLE\142[dyt",PropAssignedClientIdentifier -// "\227\SYN\147\170O\223\v\RSp\219D\ETB",PropMaximumPacketSize 23197] +// SubscribeResponse 10740 [Left SubErrSharedSubscriptionsNotSupported,Right QoS2,Right QoS2,Left +// SubErrSharedSubscriptionsNotSupported] [PropSessionExpiryInterval 9438,PropReceiveMaximum 17177,PropRetainAvailable +// 22,PropUserProperty "\241v\ETB\220\196\ACK.u\194\203 kR\160\195\204\194\206RJ\173\221\200\169\RS\249\134I=" +// "\219\SO^\178c\NUL%\251J\193\DC4|f\DC4\212u#\129\229R",PropTopicAlias 20170,PropRequestResponseInformation +// 87,PropWillDelayInterval 20823,PropRetainAvailable 50,PropContentType +// "\145n\154\&2\CAN\171\131h\152\153u\178]/\161",PropMessageExpiryInterval 7365,PropServerReference +// "?\194-\197\240\SO1\158\218\FS\236f\160\166\167>\176v`\193\CAN1g#\229\176e\159\GS\RS",PropRequestProblemInformation +// 222,PropCorrelationData "'L\136\\]\160u3\238\227",PropResponseInformation +// "\238\211\150%\167\DLE>\205\190\217\198\186\&1\158\168\250\250\176\143\&6\251\227\SO\221G\211\206X\DC1\238",PropSubscriptionIdentifier +// 25,PropAuthenticationMethod "P\NUL\168\DC4<\147Y5\198i\151\150",PropReasonString +// "\151\195\244\190\164\128V\198\238\nZ",PropServerReference "*|",PropResponseInformation +// "\153v7\ACKp/\a\240",PropCorrelationData "\208\&2q\235!\n#\v\156\&1\ETXT\172\154",PropPayloadFormatIndicator +// 89,PropAssignedClientIdentifier "X\\/\230%`\173\249/\179V\136\&0s\218#'\245",PropCorrelationData +// "q\230#\254\231\NAK\214E\144\&8\172\204\206\216\254\226\171\177"] TEST(SubACK5QCTest, Decode24) { uint8_t pkt[] = { - 0x90, 0xdd, 0x2, 0x65, 0x7f, 0xd8, 0x2, 0x3, 0x0, 0x14, 0xe2, 0x93, 0xe4, 0xec, 0xd9, 0x6, 0x19, 0xd0, 0x4, - 0xe2, 0x32, 0x52, 0xc2, 0xdc, 0x3f, 0x6f, 0x1b, 0xc3, 0x3b, 0xa7, 0x16, 0x0, 0x19, 0x73, 0x29, 0x3b, 0x2, 0xd4, - 0x7d, 0x9f, 0x95, 0x4, 0x6f, 0x6a, 0x4d, 0x5d, 0x58, 0xbe, 0xfa, 0xf3, 0xff, 0xce, 0x79, 0xe4, 0xf7, 0x57, 0xb8, - 0x1c, 0x23, 0x1c, 0x1d, 0x2a, 0x2e, 0x19, 0x44, 0x1a, 0x0, 0x7, 0x85, 0x53, 0xf, 0x5a, 0x79, 0xf9, 0x40, 0x1f, - 0x0, 0x15, 0x38, 0x27, 0xb4, 0x4, 0xb2, 0x56, 0x90, 0xd2, 0x85, 0xc6, 0x62, 0x5c, 0x56, 0x92, 0x6c, 0x1f, 0x7c, -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, 0x1c, 0xec, 0x66, 0xa0, 0xa6, 0xa7, 0x3e, 0xb0, 0x76, 0x60, 0xc1, 0x18, 0x31, 0x67, 0x23, + 0xe5, 0xb0, 0x65, 0x9f, 0x1d, 0x1e, 0x17, 0xde, 0x9, 0x0, 0xa, 0x27, 0x4c, 0x88, 0x5c, 0x5d, 0xa0, 0x75, 0x33, + 0xee, 0xe3, 0x1a, 0x0, 0x1e, 0xee, 0xd3, 0x96, 0x25, 0xa7, 0x10, 0x3e, 0xcd, 0xbe, 0xd9, 0xc6, 0xba, 0x31, 0x9e, + 0xa8, 0xfa, 0xfa, 0xb0, 0x8f, 0x36, 0xfb, 0xe3, 0xe, 0xdd, 0x47, 0xd3, 0xce, 0x58, 0x11, 0xee, 0xb, 0x19, 0x15, + 0x0, 0xc, 0x50, 0x0, 0xa8, 0x14, 0x3c, 0x93, 0x59, 0x35, 0xc6, 0x69, 0x97, 0x96, 0x1f, 0x0, 0xb, 0x97, 0xc3, + 0xf4, 0xbe, 0xa4, 0x80, 0x56, 0xc6, 0xee, 0xa, 0x5a, 0x1c, 0x0, 0x2, 0x2a, 0x7c, 0x1a, 0x0, 0x8, 0x99, 0x76, + 0x37, 0x6, 0x70, 0x2f, 0x7, 0xf0, 0x9, 0x0, 0xe, 0xd0, 0x32, 0x71, 0xeb, 0x21, 0xa, 0x23, 0xb, 0x9c, 0x31, + 0x3, 0x54, 0xac, 0x9a, 0x1, 0x59, 0x12, 0x0, 0x12, 0x58, 0x5c, 0x2f, 0xe6, 0x25, 0x60, 0xad, 0xf9, 0x2f, 0xb3, + 0x56, 0x88, 0x30, 0x73, 0xda, 0x23, 0x27, 0xf5, 0x9, 0x0, 0x12, 0x71, 0xe6, 0x23, 0xfe, 0xe7, 0x15, 0xd6, 0x45, + 0x90, 0x38, 0xac, 0xcc, 0xce, 0xd8, 0xfe, 0xe2, 0xab, 0xb1, 0x9e, 0x2, 0x2, 0x9e}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 25983); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(packet_id, 10740); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], 0x9E); + EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x9E); } -// SubscribeResponse 803 [Right QoS0,Left SubErrWildcardSubscriptionsNotSupported,Left SubErrNotAuthorized,Right -// QoS2,Left SubErrSubscriptionIdentifiersNotSupported,Right QoS1] [PropResponseInformation -// "\198d&ULmk\177@C\ETB\212\229\213\246\193\222\SOH\204",PropRequestResponseInformation 141,PropWillDelayInterval -// 31029,PropMessageExpiryInterval 293,PropMaximumQoS 13,PropUserProperty "\143" -// "a\153Z\DEL\162d\248\129\255\133\173\178R7\173\162\206=\212\DC4",PropAuthenticationData -// "\212%mM\160\229\196\206\140\135\236tC\154>Q\NUL\196|",PropCorrelationData -// "\136.\179z\150\154Z-\232\fL\232",PropMessageExpiryInterval 16324,PropSubscriptionIdentifierAvailable -// 30,PropMessageExpiryInterval 25682,PropWildcardSubscriptionAvailable 61] +// SubscribeResponse 18996 [Left SubErrPacketIdentifierInUse,Left SubErrImplementationSpecificError,Right QoS0,Right +// QoS0,Left SubErrTopicFilterInvalid,Right QoS1,Left SubErrTopicFilterInvalid,Left +// SubErrWildcardSubscriptionsNotSupported,Left SubErrPacketIdentifierInUse,Right QoS2,Left +// SubErrSubscriptionIdentifiersNotSupported] [PropMessageExpiryInterval 6754,PropResponseInformation +// "_Y/r\171\DC2SB\141\195",PropMaximumQoS 246,PropServerKeepAlive 26728,PropContentType +// "5\169b;$U#\t1$Geo\242\246\191\&7,^\232\151\226\&3(=",PropWillDelayInterval 10899,PropRequestResponseInformation +// 14,PropContentType +// "\STX\225JdLV~\SYN\233\252\ACK\"\212\137\128Q\160\218\246\153\215\195\166Z\233FV",PropRetainAvailable +// 209,PropReceiveMaximum 451,PropSessionExpiryInterval 6678,PropRequestProblemInformation 5,PropContentType +// "9\227\170'p\DC1?:W|[\239\151\&0U",PropAssignedClientIdentifier "\224\217\161\227d\248Q{",PropAuthenticationData +// "d.\SUB\151\218=A\188\192\173\248\240b\227\161\214\234\&6j\140B\159\132"] TEST(SubACK5QCTest, Decode25) { - uint8_t pkt[] = {0x90, 0x7a, 0x3, 0x23, 0x71, 0x1a, 0x0, 0x13, 0xc6, 0x64, 0x26, 0x55, 0x4c, 0x6d, 0x6b, 0xb1, - 0x40, 0x43, 0x17, 0xd4, 0xe5, 0xd5, 0xf6, 0xc1, 0xde, 0x1, 0xcc, 0x19, 0x8d, 0x18, 0x0, 0x0, - 0x79, 0x35, 0x2, 0x0, 0x0, 0x1, 0x25, 0x24, 0xd, 0x26, 0x0, 0x1, 0x8f, 0x0, 0x14, 0x61, - 0x99, 0x5a, 0x7f, 0xa2, 0x64, 0xf8, 0x81, 0xff, 0x85, 0xad, 0xb2, 0x52, 0x37, 0xad, 0xa2, 0xce, - 0x3d, 0xd4, 0x14, 0x16, 0x0, 0x13, 0xd4, 0x25, 0x6d, 0x4d, 0xa0, 0xe5, 0xc4, 0xce, 0x8c, 0x87, - 0xec, 0x74, 0x43, 0x9a, 0x3e, 0x51, 0x0, 0xc4, 0x7c, 0x9, 0x0, 0xc, 0x88, 0x2e, 0xb3, 0x7a, - 0x96, 0x9a, 0x5a, 0x2d, 0xe8, 0xc, 0x4c, 0xe8, 0x2, 0x0, 0x0, 0x3f, 0xc4, 0x29, 0x1e, 0x2, -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_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[6]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 803); - EXPECT_EQ(count, 6); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], 0xA2); - EXPECT_EQ(granted_qos_levels[2], 0x87); - EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[4], 0xA1); + lwmqtt_qos_t granted_qos_levels[11]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 18996); + EXPECT_EQ(count, 11); + EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], 0x8F); EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); -} - -// SubscribeResponse 6677 [Right QoS0,Right QoS1,Left SubErrTopicFilterInvalid,Left -// SubErrImplementationSpecificError,Right QoS0,Right QoS1,Right QoS2,Right QoS2,Left -// SubErrSubscriptionIdentifiersNotSupported,Left SubErrNotAuthorized,Right QoS0] [PropTopicAliasMaximum -// 15406,PropMaximumPacketSize 23595,PropReasonString " \193\129.\STXT\160",PropAuthenticationMethod -// "\181\&0",PropCorrelationData "\185\169\158\190V\137\206\aH&l\138\159z\233\RS\254\&6\ENQ\144",PropMaximumPacketSize -// 1098,PropRequestResponseInformation 86,PropMaximumPacketSize 5354,PropSharedSubscriptionAvailable -// 83,PropRequestProblemInformation 221,PropRequestProblemInformation 203,PropRequestResponseInformation -// 204,PropResponseInformation "*>=\DC3z \252",PropContentType -// "$\133:\188N\213\STXk\144@\226\SYNSd\147\ETX\187",PropAuthenticationData -// "\226]\238\t\234,\251\154\153y\b\132",PropMessageExpiryInterval 17116,PropWildcardSubscriptionAvailable -// 4,PropReceiveMaximum 32286,PropWillDelayInterval 16552,PropCorrelationData -// "t\187\179\f\200\178",PropSharedSubscriptionAvailable 251,PropResponseTopic -// "\178\181$\156\245$M\GS\189h\SIy\129\169\204",PropContentType -// "L\v\247\232\254\209a}\140=[\165 \128\245\DEL\161\134n\129\250\b\193ds\217d\208 \f",PropReceiveMaximum +// 5194,PropResponseTopic "%x\222",PropRetainAvailable 84,PropSharedSubscriptionAvailable 98,PropPayloadFormatIndicator +// 151,PropSharedSubscriptionAvailable 202,PropMessageExpiryInterval 22832,PropTopicAlias +// 8014,PropRequestProblemInformation 95,PropContentType +// "\NAK\183o\234\249\240\138\&8\210\138\ESC\242l\138#!\206",PropRequestResponseInformation 74,PropContentType +// "\DC2\152\149W\208\249\173#\195n\r\187"] TEST(SubACK5QCTest, Decode26) { - uint8_t pkt[] = {0x90, 0xd3, 0x1, 0x1a, 0x15, 0xc4, 0x1, 0x22, 0x3c, 0x2e, 0x27, 0x0, 0x0, 0x5c, 0x2b, 0x1f, 0x0, - 0x7, 0x20, 0xc1, 0x81, 0x2e, 0x2, 0x54, 0xa0, 0x15, 0x0, 0x2, 0xb5, 0x30, 0x9, 0x0, 0x14, 0xb9, - 0xa9, 0x9e, 0xbe, 0x56, 0x89, 0xce, 0x7, 0x48, 0x26, 0x6c, 0x8a, 0x9f, 0x7a, 0xe9, 0x1e, 0xfe, 0x36, - 0x5, 0x90, 0x27, 0x0, 0x0, 0x4, 0x4a, 0x19, 0x56, 0x27, 0x0, 0x0, 0x14, 0xea, 0x2a, 0x53, 0x17, - 0xdd, 0x17, 0xcb, 0x19, 0xcc, 0x1a, 0x0, 0x7, 0x2a, 0x3e, 0x3d, 0x13, 0x7a, 0x20,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0x1e, 0x35, 0xa8, 0xe9, 0x48, 0x2c, 0x92, 0x38, 0xcd, 0xa8, 0x3e, + 0x5b, 0xa5, 0x20, 0x80, 0xf5, 0x7f, 0xa1, 0x86, 0x6e, 0x81, 0xfa, 0x8, 0xc1, 0x64, 0x73, 0xd9, + 0x64, 0xd0, 0x20, 0xc, 0x21, 0x14, 0x4a, 0x8, 0x0, 0x3, 0x25, 0x78, 0xde, 0x25, 0x54, 0x2a, + 0x62, 0x1, 0x97, 0x2a, 0xca, 0x2, 0x0, 0x0, 0x59, 0x30, 0x23, 0x1f, 0x4e, 0x17, 0x5f, 0x3, + 0x0, 0x11, 0x15, 0xb7, 0x6f, 0xea, 0xf9, 0xf0, 0x8a, 0x38, 0xd2, 0x8a, 0x1b, 0xf2, 0x6c, 0x8a, + 0x23, 0x21, 0xce, 0x19, 0x4a, 0x3, 0x0, 0xc, 0x12, 0x98, 0x95, 0x57, 0xd0, 0xf9, 0xad, 0x23, + 0xc3, 0x6e, 0xd, 0xbb, 0xa2, 0x87, 0x2, 0x0, 0x2, 0x91, 0x1, 0x0, 0x2, 0x87, 0xa2}; uint16_t packet_id; int count; lwmqtt_qos_t granted_qos_levels[11]; lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6677); + EXPECT_EQ(packet_id, 969); EXPECT_EQ(count, 11); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], 0x8F); - EXPECT_EQ(granted_qos_levels[3], 0x83); - EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[8], 0xA1); + EXPECT_EQ(granted_qos_levels[0], 0xA2); + EXPECT_EQ(granted_qos_levels[1], 0x87); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], 0x91); + EXPECT_EQ(granted_qos_levels[6], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[7], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[8], LWMQTT_QOS2); EXPECT_EQ(granted_qos_levels[9], 0x87); - EXPECT_EQ(granted_qos_levels[10], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[10], 0xA2); } -// SubscribeResponse 7481 [Left SubErrNotAuthorized,Right QoS1,Right QoS2,Left SubErrNotAuthorized] [PropServerKeepAlive -// 8029,PropAuthenticationMethod "rS\179\220\137\207\170\247v8D0\ETBs\206\191\v\156/\158\173",PropServerKeepAlive -// 2400,PropRequestProblemInformation 151,PropAuthenticationMethod -// "\170\139\188\SOH+\130\184\166\189\GS\221J}\230v\ACKU\143\DC4\150\254.}E\SUBj",PropTopicAlias -// 18638,PropMessageExpiryInterval 5512,PropReasonString -// "\195\218\"\223\244\188\a\130\ETB6\211X\230Xt\128v\163",PropWildcardSubscriptionAvailable 58,PropServerKeepAlive -// 17394] +// SubscribeResponse 27073 [Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrTopicFilterInvalid,Right +// QoS1,Right QoS2,Left SubErrTopicFilterInvalid,Left SubErrWildcardSubscriptionsNotSupported] +// [PropMessageExpiryInterval 29081,PropResponseInformation "\184\210\128\CANF\162\218)U\159\182",PropWillDelayInterval +// 16309,PropRetainAvailable 172,PropMaximumPacketSize 9960,PropTopicAliasMaximum 3288,PropResponseInformation +// "\157\178\162\139\163\220\206L\207:\144\242"] TEST(SubACK5QCTest, Decode27) { - uint8_t pkt[] = {0x90, 0x66, 0x1d, 0x39, 0x5f, 0x13, 0x1f, 0x5d, 0x15, 0x0, 0x15, 0x72, 0x53, 0xb3, 0xdc, - 0x89, 0xcf, 0xaa, 0xf7, 0x76, 0x38, 0x44, 0x30, 0x17, 0x73, 0xce, 0xbf, 0xb, 0x9c, 0x2f, - 0x9e, 0xad, 0x13, 0x9, 0x60, 0x17, 0x97, 0x15, 0x0, 0x1a, 0xaa, 0x8b, 0xbc, 0x1, 0x2b, - 0x82, 0xb8, 0xa6, 0xbd, 0x1d, 0xdd, 0x4a, 0x7d, 0xe6, 0x76, 0x6, 0x55, 0x8f, 0x14, 0x96, - 0xfe, 0x2e, 0x7d, 0x45, 0x1a, 0x6a, 0x23, 0x48, 0xce, 0x2, 0x0, 0x0, 0x15, 0x88, 0x1f, - 0x0, 0x12, 0xc3, 0xda, 0x22, 0xdf, 0xf4, 0xbc, 0x7, 0x82, 0x17, 0x36, 0xd3, 0x58, 0xe6, - 0x58, 0x74, 0x80, 0x76, 0xa3, 0x28, 0x3a, 0x13, 0x43, 0xf2, 0x87, 0x1, 0x2, 0x87}; + uint8_t pkt[] = {0x90, 0x3a, 0x69, 0xc1, 0x31, 0x2, 0x0, 0x0, 0x71, 0x99, 0x1a, 0x0, 0xb, 0xb8, 0xd2, + 0x80, 0x18, 0x46, 0xa2, 0xda, 0x29, 0x55, 0x9f, 0xb6, 0x18, 0x0, 0x0, 0x3f, 0xb5, 0x25, + 0xac, 0x27, 0x0, 0x0, 0x26, 0xe8, 0x22, 0xc, 0xd8, 0x1a, 0x0, 0xc, 0x9d, 0xb2, 0xa2, + 0x8b, 0xa3, 0xdc, 0xce, 0x4c, 0xcf, 0x3a, 0x90, 0xf2, 0xa1, 0x8f, 0x1, 0x2, 0x8f, 0xa2}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[4]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[6]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 7481); - EXPECT_EQ(count, 4); - EXPECT_EQ(granted_qos_levels[0], 0x87); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS1); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[3], 0x87); + EXPECT_EQ(packet_id, 27073); + EXPECT_EQ(count, 6); + EXPECT_EQ(granted_qos_levels[0], 0xA1); + EXPECT_EQ(granted_qos_levels[1], 0x8F); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[4], 0x8F); + EXPECT_EQ(granted_qos_levels[5], 0xA2); } -// SubscribeResponse 26117 [Right QoS2,Right QoS0,Right QoS0] [PropReasonString -// "\NAK\203\155",PropRequestProblemInformation 235,PropWildcardSubscriptionAvailable 50,PropContentType -// "\176E\219\128\153\155\152\147\154AT\200T\150\SOH0\RS",PropWildcardSubscriptionAvailable 9,PropResponseInformation -// "%\248\239",PropSharedSubscriptionAvailable 2,PropPayloadFormatIndicator 46,PropAuthenticationData -// "\181\147\SO\237\203\159H\199\v\US\177\129E\221)UD\156\188"] +// SubscribeResponse 9700 [Right QoS1,Left SubErrSubscriptionIdentifiersNotSupported,Left SubErrUnspecifiedError,Left +// SubErrWildcardSubscriptionsNotSupported,Right QoS2,Right QoS0,Left SubErrSubscriptionIdentifiersNotSupported] +// [PropContentType "ZX\249\DEL\aP\179\182\161\&7\tz\199\252\244\DC3\ACKczK~{6\ETX\248\202"] TEST(SubACK5QCTest, Decode28) { - uint8_t pkt[] = {0x90, 0x46, 0x66, 0x5, 0x40, 0x1f, 0x0, 0x3, 0x15, 0xcb, 0x9b, 0x17, 0xeb, 0x28, 0x32, - 0x3, 0x0, 0x11, 0xb0, 0x45, 0xdb, 0x80, 0x99, 0x9b, 0x98, 0x93, 0x9a, 0x41, 0x54, 0xc8, - 0x54, 0x96, 0x1, 0x30, 0x1e, 0x28, 0x9, 0x1a, 0x0, 0x3, 0x25, 0xf8, 0xef, 0x2a, 0x2, - 0x1, 0x2e, 0x16, 0x0, 0x13, 0xb5, 0x93, 0xe, 0xed, 0xcb, 0x9f, 0x48, 0xc7, 0xb, 0x1f, - 0xb1, 0x81, 0x45, 0xdd, 0x29, 0x55, 0x44, 0x9c, 0xbc, 0x2, 0x0, 0x0}; + uint8_t pkt[] = {0x90, 0x27, 0x25, 0xe4, 0x1d, 0x3, 0x0, 0x1a, 0x5a, 0x58, 0xf9, 0x7f, 0x7, 0x50, + 0xb3, 0xb6, 0xa1, 0x37, 0x9, 0x7a, 0xc7, 0xfc, 0xf4, 0x13, 0x6, 0x63, 0x7a, 0x4b, + 0x7e, 0x7b, 0x36, 0x3, 0xf8, 0xca, 0x1, 0xa1, 0x80, 0xa2, 0x2, 0x0, 0xa1}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[3]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[7]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 26117); - EXPECT_EQ(count, 3); - EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); - EXPECT_EQ(granted_qos_levels[1], LWMQTT_QOS0); - EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS0); -} - -// SubscribeResponse 4603 [Left SubErrWildcardSubscriptionsNotSupported] [PropServerReference -// "\226\204`2\212\&4tl\135\151L\154\149&",PropWildcardSubscriptionAvailable 197,PropSessionExpiryInterval -// 21325,PropAssignedClientIdentifier "\ACKc\180\232\225\182N\181\206\169\129<$",PropWildcardSubscriptionAvailable -// 166,PropServerKeepAlive 21338,PropServerKeepAlive 8899,PropWildcardSubscriptionAvailable -// 156,PropMessageExpiryInterval 3096,PropServerKeepAlive 25030,PropSubscriptionIdentifier 29,PropPayloadFormatIndicator -// 59,PropServerKeepAlive 5386,PropWildcardSubscriptionAvailable 67,PropMessageExpiryInterval 14429] + EXPECT_EQ(packet_id, 9700); + EXPECT_EQ(count, 7); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[1], 0xA1); + EXPECT_EQ(granted_qos_levels[2], 0x80); + EXPECT_EQ(granted_qos_levels[3], 0xA2); + EXPECT_EQ(granted_qos_levels[4], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[5], LWMQTT_QOS0); + EXPECT_EQ(granted_qos_levels[6], 0xA1); +} + +// SubscribeResponse 31732 [Left SubErrNotAuthorized,Left SubErrImplementationSpecificError,Right QoS2,Right QoS1,Left +// SubErrImplementationSpecificError,Left SubErrQuotaExceeded,Left SubErrSubscriptionIdentifiersNotSupported,Left +// SubErrUnspecifiedError] [PropTopicAlias 10185,PropRetainAvailable 195,PropRequestResponseInformation +// 115,PropSharedSubscriptionAvailable 45,PropRequestResponseInformation 166,PropMessageExpiryInterval +// 31591,PropCorrelationData "\DC1",PropAssignedClientIdentifier +// "\GS\251\165\159d}\248\140v\220\f\150\245",PropReceiveMaximum 31778,PropRequestResponseInformation +// 16,PropAuthenticationData "F\201\f",PropReasonString "x\234r \149\237\133\178",PropRequestProblemInformation +// 219,PropMaximumPacketSize 24668,PropCorrelationData "\196Q\182\172S\224",PropUserProperty +// "\207zm[\239\ah%\154\253-o\SUB" "|8\234\147G\GSmO\142\239E\235BH\SYN\202:\233v@\136\230 g\tFj",PropCorrelationData +// "\130|`\135\139\195\ESC\252O\EOTsp~aJ\155)\220\198H\\\245\166\148C\133",PropTopicAliasMaximum 5742] TEST(SubACK5QCTest, Decode29) { - uint8_t pkt[] = {0x90, 0x4c, 0x11, 0xfb, 0x48, 0x1c, 0x0, 0xe, 0xe2, 0xcc, 0x60, 0x32, 0xd4, 0x34, 0x74, 0x6c, - 0x87, 0x97, 0x4c, 0x9a, 0x95, 0x26, 0x28, 0xc5, 0x11, 0x0, 0x0, 0x53, 0x4d, 0x12, 0x0, 0xd, - 0x6, 0x63, 0xb4, 0xe8, 0xe1, 0xb6, 0x4e, 0xb5, 0xce, 0xa9, 0x81, 0x3c, 0x24, 0x28, 0xa6, 0x13, - 0x53, 0x5a, 0x13, 0x22, 0xc3, 0x28, 0x9c, 0x2, 0x0, 0x0, 0xc, 0x18, 0x13, 0x61, 0xc6, 0xb, - 0x1d, 0x1, 0x3b, 0x13, 0x15, 0xa, 0x28, 0x43, 0x2, 0x0, 0x0, 0x38, 0x5d, 0xa2}; + uint8_t pkt[] = {0x90, 0xa3, 0x1, 0x7b, 0xf4, 0x97, 0x1, 0x23, 0x27, 0xc9, 0x25, 0xc3, 0x19, 0x73, 0x2a, 0x2d, 0x19, + 0xa6, 0x2, 0x0, 0x0, 0x7b, 0x67, 0x9, 0x0, 0x1, 0x11, 0x12, 0x0, 0xd, 0x1d, 0xfb, 0xa5, 0x9f, + 0x64, 0x7d, 0xf8, 0x8c, 0x76, 0xdc, 0xc, 0x96, 0xf5, 0x21, 0x7c, 0x22, 0x19, 0x10, 0x16, 0x0, 0x3, + 0x46, 0xc9, 0xc, 0x1f, 0x0, 0x8, 0x78, 0xea, 0x72, 0x20, 0x95, 0xed, 0x85, 0xb2, 0x17, 0xdb, 0x27, + 0x0, 0x0, 0x60, 0x5c, 0x9, 0x0, 0x6, 0xc4, 0x51, 0xb6, 0xac, 0x53, 0xe0, 0x26, 0x0, 0xd, 0xcf, + 0x7a, 0x6d, 0x5b, 0xef, 0x7, 0x68, 0x25, 0x9a, 0xfd, 0x2d, 0x6f, 0x1a, 0x0, 0x1b, 0x7c, 0x38, 0xea, + 0x93, 0x47, 0x1d, 0x6d, 0x4f, 0x8e, 0xef, 0x45, 0xeb, 0x42, 0x48, 0x16, 0xca, 0x3a, 0xe9, 0x76, 0x40, + 0x88, 0xe6, 0x20, 0x67, 0x9, 0x46, 0x6a, 0x9, 0x0, 0x1a, 0x82, 0x7c, 0x60, 0x87, 0x8b, 0xc3, 0x1b, + 0xfc, 0x4f, 0x4, 0x73, 0x70, 0x7e, 0x61, 0x4a, 0x9b, 0x29, 0xdc, 0xc6, 0x48, 0x5c, 0xf5, 0xa6, 0x94, + 0x43, 0x85, 0x22, 0x16, 0x6e, 0x87, 0x83, 0x2, 0x1, 0x83, 0x97, 0xa1, 0x80}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[8]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 8, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4603); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], 0xA2); + EXPECT_EQ(packet_id, 31732); + EXPECT_EQ(count, 8); + EXPECT_EQ(granted_qos_levels[0], 0x87); + EXPECT_EQ(granted_qos_levels[1], 0x83); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], LWMQTT_QOS1); + EXPECT_EQ(granted_qos_levels[4], 0x83); + EXPECT_EQ(granted_qos_levels[5], 0x97); + EXPECT_EQ(granted_qos_levels[6], 0xA1); + EXPECT_EQ(granted_qos_levels[7], 0x80); } -// SubscribeResponse 32025 [Left SubErrPacketIdentifierInUse] [PropCorrelationData -// "\NULu\160\251\247\151O\DC4$s4Y\\\252\ESCe=\DC2\223\179X",PropServerReference "\ACKA\194K\128\241 -// \193\192Qj\v",PropRetainAvailable 144,PropUserProperty "\195\208\NUL\148I\GS\137\DLE" -// "\234f\216\145\&6&\ngxp&Q\154*\130w",PropAssignedClientIdentifier -// "\RS\152\226\211\166\134\\\SYN\238\180\ETB17Z\a(\176Y",PropAssignedClientIdentifier -// "\227\188I\254\162\184\193?\210C\141\197\158Z\191\143\196t3\SOH\149\246|,\193\182@~\239\191",PropAuthenticationMethod -// "\218",PropServerKeepAlive 4111,PropWildcardSubscriptionAvailable 115,PropMaximumQoS 93,PropResponseInformation -// "\ESC",PropPayloadFormatIndicator 26,PropCorrelationData -// "\182|\RS\248\191\255\&7\180\220\FS(%\186\160\a\221>\DELS\130\176\&6\CAN>r\196\211\217\209",PropAuthenticationMethod -// "=\228ya-\142\EMD\232\217\137\129=\177\214}\192`\205",PropServerKeepAlive 20374,PropTopicAliasMaximum -// 22407,PropWildcardSubscriptionAvailable 208,PropReceiveMaximum 17593,PropMessageExpiryInterval -// 31603,PropReceiveMaximum 17390,PropCorrelationData "\SOm\151\203y\242\191(\173g\178\&9\199>U\187Z\228"] +// SubscribeResponse 6520 [Right QoS2,Left SubErrUnspecifiedError,Right QoS2,Left SubErrQuotaExceeded] +// [PropRequestProblemInformation 181,PropTopicAliasMaximum 22327,PropMessageExpiryInterval +// 17747,PropSubscriptionIdentifier 2,PropPayloadFormatIndicator 251,PropSubscriptionIdentifierAvailable +// 248,PropMaximumQoS 45,PropSharedSubscriptionAvailable 5,PropSubscriptionIdentifierAvailable 48,PropServerKeepAlive +// 27265,PropAssignedClientIdentifier +// "\200\&1`\198\198\170\207\224\r\179o\219\DC4\228\201\209\222\186\130\174\DC1",PropAssignedClientIdentifier +// "=\233\194^J\a\STXwmv",PropMessageExpiryInterval 16237,PropSessionExpiryInterval 17822,PropRetainAvailable +// 225,PropRequestProblemInformation 76,PropWildcardSubscriptionAvailable 184] TEST(SubACK5QCTest, Decode30) { - uint8_t pkt[] = { - 0x90, 0xf0, 0x1, 0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, - 0x44, 0xe8, 0xd9, 0x89, 0x81, 0x3d, 0xb1, 0xd6, 0x7d, 0xc0, 0x60, 0xcd, 0x13, 0x4f, 0x96, 0x22, 0x57, 0x87, 0x28, - 0xd0, 0x21, 0x44, 0xb9, 0x2, 0x0, 0x0, 0x7b, 0x73, 0x21, 0x43, 0xee, 0x9, 0x0, 0x12, 0xe, 0x6d, 0x97, 0xcb, - 0x79, 0xf2, 0xbf, 0x28, 0xad, 0x67, 0xb2, 0x39, 0xc7, 0x3e, 0x55, 0xbb, 0x5a, 0xe4, 0x91}; + uint8_t pkt[] = {0x90, 0x55, 0x19, 0x78, 0x4e, 0x17, 0xb5, 0x22, 0x57, 0x37, 0x2, 0x0, 0x0, 0x45, 0x53, + 0xb, 0x2, 0x1, 0xfb, 0x29, 0xf8, 0x24, 0x2d, 0x2a, 0x5, 0x29, 0x30, 0x13, 0x6a, 0x81, + 0x12, 0x0, 0x15, 0xc8, 0x31, 0x60, 0xc6, 0xc6, 0xaa, 0xcf, 0xe0, 0xd, 0xb3, 0x6f, 0xdb, + 0x14, 0xe4, 0xc9, 0xd1, 0xde, 0xba, 0x82, 0xae, 0x11, 0x12, 0x0, 0xa, 0x3d, 0xe9, 0xc2, + 0x5e, 0x4a, 0x7, 0x2, 0x77, 0x6d, 0x76, 0x2, 0x0, 0x0, 0x3f, 0x6d, 0x11, 0x0, 0x0, + 0x45, 0x9e, 0x25, 0xe1, 0x17, 0x4c, 0x28, 0xb8, 0x2, 0x80, 0x2, 0x97}; uint16_t packet_id; int count; - lwmqtt_qos_t granted_qos_levels[1]; - lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, granted_qos_levels); + lwmqtt_qos_t granted_qos_levels[4]; + lwmqtt_err_t err = lwmqtt_decode_suback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, granted_qos_levels); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32025); - EXPECT_EQ(count, 1); - EXPECT_EQ(granted_qos_levels[0], 0x91); + EXPECT_EQ(packet_id, 6520); + EXPECT_EQ(count, 4); + EXPECT_EQ(granted_qos_levels[0], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[1], 0x80); + EXPECT_EQ(granted_qos_levels[2], LWMQTT_QOS2); + EXPECT_EQ(granted_qos_levels[3], 0x97); } -// UnsubscribeRequest 24378 ["\214\DC35\253\159\129F#\236\204y?\150\128\DC2u\230\211 -// O\133\185\r\135\163\177","\225\161,\196C\187\132IH\245\164\210!e\185\145e\139\243\181X8\n\242\182\204\151^\228","{\SUBC\158","\252\142\163gsP\ACK\133\234LY\203\&8\183\251\223\147\128\249","G}\173\207o\181\247\NULk\180\255\243\157o\SOH\199\NAKxD6","\220\ACK\170\&3)c\200`\251o\158"] -// [] +// UnsubscribeRequest 22317 +// ["\SUB{\230Y\DC1\b\EM\160\232\SUB\CAN\131\NUL\188t\134\180\194a\152K\153\153\177\DLE1\225\161\225"] [] TEST(Unsubscribe311QCTest, Encode1) { - uint8_t pkt[] = {0xa2, 0x7b, 0x5f, 0x3a, 0x0, 0x1a, 0xd6, 0x13, 0x35, 0xfd, 0x9f, 0x81, 0x46, 0x23, 0xec, 0xcc, - 0x79, 0x3f, 0x96, 0x80, 0x12, 0x75, 0xe6, 0xd3, 0x20, 0x4f, 0x85, 0xb9, 0xd, 0x87, 0xa3, 0xb1, - 0x0, 0x1d, 0xe1, 0xa1, 0x2c, 0xc4, 0x43, 0xbb, 0x84, 0x49, 0x48, 0xf5, 0xa4, 0xd2, 0x21, 0x65, - 0xb9, 0x91, 0x65, 0x8b, 0xf3, 0xb5, 0x58, 0x38, 0xa, 0xf2, 0xb6, 0xcc, 0x97, 0x5e, 0xe4, 0x0, - 0x4, 0x7b, 0x1a, 0x43, 0x9e, 0x0, 0x13, 0xfc, 0x8e, 0xa3, 0x67, 0x73, 0x50, 0x6, 0x85, 0xea, - 0x4c, 0x59, 0xcb, 0x38, 0xb7, 0xfb, 0xdf, 0x93, 0x80, 0xf9, 0x0, 0x14, 0x47, 0x7d, 0xad, 0xcf, - 0x6f, 0xb5, 0xf7, 0x0, 0x6b, 0xb4, 0xff, 0xf3, 0x9d, 0x6f, 0x1, 0xc7, 0x15, 0x78, 0x44, 0x36, - 0x0, 0xb, 0xdc, 0x6, 0xaa, 0x33, 0x29, 0x63, 0xc8, 0x60, 0xfb, 0x6f, 0x9e}; + uint8_t pkt[] = {0xa2, 0x21, 0x57, 0x2d, 0x0, 0x1d, 0x1a, 0x7b, 0xe6, 0x59, 0x11, 0x8, + 0x19, 0xa0, 0xe8, 0x1a, 0x18, 0x83, 0x0, 0xbc, 0x74, 0x86, 0xb4, 0xc2, + 0x61, 0x98, 0x4b, 0x99, 0x99, 0xb1, 0x10, 0x31, 0xe1, 0xa1, 0xe1}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xd6, 0x13, 0x35, 0xfd, 0x9f, 0x81, 0x46, 0x23, 0xec, 0xcc, 0x79, 0x3f, 0x96, - 0x80, 0x12, 0x75, 0xe6, 0xd3, 0x20, 0x4f, 0x85, 0xb9, 0xd, 0x87, 0xa3, 0xb1}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x1a, 0x7b, 0xe6, 0x59, 0x11, 0x8, 0x19, 0xa0, 0xe8, 0x1a, + 0x18, 0x83, 0x0, 0xbc, 0x74, 0x86, 0xb4, 0xc2, 0x61, 0x98, + 0x4b, 0x99, 0x99, 0xb1, 0x10, 0x31, 0xe1, 0xa1, 0xe1}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe1, 0xa1, 0x2c, 0xc4, 0x43, 0xbb, 0x84, 0x49, 0x48, 0xf5, - 0xa4, 0xd2, 0x21, 0x65, 0xb9, 0x91, 0x65, 0x8b, 0xf3, 0xb5, - 0x58, 0x38, 0xa, 0xf2, 0xb6, 0xcc, 0x97, 0x5e, 0xe4}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7b, 0x1a, 0x43, 0x9e}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfc, 0x8e, 0xa3, 0x67, 0x73, 0x50, 0x6, 0x85, 0xea, 0x4c, - 0x59, 0xcb, 0x38, 0xb7, 0xfb, 0xdf, 0x93, 0x80, 0xf9}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x47, 0x7d, 0xad, 0xcf, 0x6f, 0xb5, 0xf7, 0x0, 0x6b, 0xb4, - 0xff, 0xf3, 0x9d, 0x6f, 0x1, 0xc7, 0x15, 0x78, 0x44, 0x36}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xdc, 0x6, 0xaa, 0x33, 0x29, 0x63, 0xc8, 0x60, 0xfb, 0x6f, 0x9e}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24378, 6, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22317, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 2051 -// ["","\193\252\EOT\NAK\244\187T\"A\224\181\EOT\232\248Q\175[\132*\231\160\&9cK\158\209wc1","A3\151\238\144\145\195:\165\&6R\SUB\239\198ypa\225\254\219\245\ETB\225\222e\GS","Q\EM\157\DC2\249\155h\249\139\&89)\243$\186u\190\135t\141\240\&7\164\246","\SUBTW","\132\180L","\212R\181Q4A7m,\SO\SYN\232I\181\207/\180QZX\217\199@","~}\"\182\146\230\151\176\250MD:\144\171\237Q\226X",")\188\182\214\&1\161\144\201>h\192"] // [] TEST(Unsubscribe311QCTest, Encode3) { - uint8_t pkt[] = {0xa2, 0x4a, 0x41, 0x9a, 0x0, 0x6, 0xb4, 0x67, 0x35, 0x31, 0x8e, 0xac, 0x0, 0x1e, 0x3b, 0x2e, - 0x23, 0xb3, 0x9b, 0x2e, 0xde, 0xf4, 0x3f, 0xc7, 0xa4, 0xb2, 0x86, 0xbf, 0xe7, 0x2c, 0x36, 0x8, - 0x3b, 0xc5, 0x43, 0x11, 0x78, 0x4, 0x72, 0x83, 0x69, 0xad, 0x45, 0xb5, 0x0, 0x12, 0x53, 0x82, - 0x90, 0xe4, 0x1d, 0xbc, 0x93, 0x60, 0x35, 0x8f, 0xf3, 0xf6, 0x17, 0x99, 0x52, 0x82, 0xf0, 0xd5, - 0x0, 0xa, 0x2a, 0xe1, 0x5c, 0xea, 0xb8, 0x88, 0x96, 0x4a, 0xdd, 0x9d}; + uint8_t pkt[] = {0xa2, 0x3f, 0x28, 0x59, 0x0, 0x4, 0x3d, 0x5d, 0xe6, 0x40, 0x0, 0xa, 0x3d, 0x34, 0xac, 0x3c, 0xbd, + 0x3f, 0x7f, 0x8e, 0x58, 0xeb, 0x0, 0x8, 0x3e, 0xb4, 0x51, 0x5a, 0x58, 0xd9, 0xc7, 0x40, 0x0, 0x12, + 0x7e, 0x7d, 0x22, 0xb6, 0x92, 0xe6, 0x97, 0xb0, 0xfa, 0x4d, 0x44, 0x3a, 0x90, 0xab, 0xed, 0x51, 0xe2, + 0x58, 0x0, 0xb, 0x29, 0xbc, 0xb6, 0xd6, 0x31, 0xa1, 0x90, 0xc9, 0x3e, 0x68, 0xc0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xb4, 0x67, 0x35, 0x31, 0x8e, 0xac}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x3d, 0x5d, 0xe6, 0x40}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3b, 0x2e, 0x23, 0xb3, 0x9b, 0x2e, 0xde, 0xf4, 0x3f, 0xc7, - 0xa4, 0xb2, 0x86, 0xbf, 0xe7, 0x2c, 0x36, 0x8, 0x3b, 0xc5, - 0x43, 0x11, 0x78, 0x4, 0x72, 0x83, 0x69, 0xad, 0x45, 0xb5}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x3d, 0x34, 0xac, 0x3c, 0xbd, 0x3f, 0x7f, 0x8e, 0x58, 0xeb}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x53, 0x82, 0x90, 0xe4, 0x1d, 0xbc, 0x93, 0x60, 0x35, - 0x8f, 0xf3, 0xf6, 0x17, 0x99, 0x52, 0x82, 0xf0, 0xd5}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x3e, 0xb4, 0x51, 0x5a, 0x58, 0xd9, 0xc7, 0x40}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2a, 0xe1, 0x5c, 0xea, 0xb8, 0x88, 0x96, 0x4a, 0xdd, 0x9d}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x7e, 0x7d, 0x22, 0xb6, 0x92, 0xe6, 0x97, 0xb0, 0xfa, + 0x4d, 0x44, 0x3a, 0x90, 0xab, 0xed, 0x51, 0xe2, 0x58}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x29, 0xbc, 0xb6, 0xd6, 0x31, 0xa1, 0x90, 0xc9, 0x3e, 0x68, 0xc0}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16794, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10329, 5, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 15779 -// ["q\143\179\SUB\203\191\213\177]\DC1\148S\175\ESC\200C5\NAK\246\167r\152\198\254\ETXI","jv\241\208\SUB\210","\183\192\222;F\253\246vU\179\SIO\222","\150T\145\198J\tp\138\137'\ESC\157"] -// [] +// UnsubscribeRequest 1566 ["\248f\177\a\209\171O\234C","\r\207\164\185\187[\175","}\213\235~\236\226x"] [] TEST(Unsubscribe311QCTest, Encode4) { - uint8_t pkt[] = {0xa2, 0x43, 0x3d, 0xa3, 0x0, 0x1a, 0x71, 0x8f, 0xb3, 0x1a, 0xcb, 0xbf, 0xd5, 0xb1, - 0x5d, 0x11, 0x94, 0x53, 0xaf, 0x1b, 0xc8, 0x43, 0x35, 0x15, 0xf6, 0xa7, 0x72, 0x98, - 0xc6, 0xfe, 0x3, 0x49, 0x0, 0x6, 0x6a, 0x76, 0xf1, 0xd0, 0x1a, 0xd2, 0x0, 0xd, - 0xb7, 0xc0, 0xde, 0x3b, 0x46, 0xfd, 0xf6, 0x76, 0x55, 0xb3, 0xf, 0x4f, 0xde, 0x0, - 0xc, 0x96, 0x54, 0x91, 0xc6, 0x4a, 0x9, 0x70, 0x8a, 0x89, 0x27, 0x1b, 0x9d}; + uint8_t pkt[] = {0xa2, 0x1f, 0x6, 0x1e, 0x0, 0x9, 0xf8, 0x66, 0xb1, 0x7, 0xd1, 0xab, 0x4f, 0xea, 0x43, 0x0, 0x7, + 0xd, 0xcf, 0xa4, 0xb9, 0xbb, 0x5b, 0xaf, 0x0, 0x7, 0x7d, 0xd5, 0xeb, 0x7e, 0xec, 0xe2, 0x78}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x71, 0x8f, 0xb3, 0x1a, 0xcb, 0xbf, 0xd5, 0xb1, 0x5d, 0x11, 0x94, 0x53, 0xaf, - 0x1b, 0xc8, 0x43, 0x35, 0x15, 0xf6, 0xa7, 0x72, 0x98, 0xc6, 0xfe, 0x3, 0x49}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xf8, 0x66, 0xb1, 0x7, 0xd1, 0xab, 0x4f, 0xea, 0x43}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6a, 0x76, 0xf1, 0xd0, 0x1a, 0xd2}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd, 0xcf, 0xa4, 0xb9, 0xbb, 0x5b, 0xaf}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb7, 0xc0, 0xde, 0x3b, 0x46, 0xfd, 0xf6, 0x76, 0x55, 0xb3, 0xf, 0x4f, 0xde}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7d, 0xd5, 0xeb, 0x7e, 0xec, 0xe2, 0x78}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x96, 0x54, 0x91, 0xc6, 0x4a, 0x9, 0x70, 0x8a, 0x89, 0x27, 0x1b, 0x9d}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 15779, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1566, 3, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 2710 -// ["\192e\229>\239\247\184\209\158w\SI_X0T","E\243","\225\CAN*E8Q\t-\252B\136.\247\185\250","\144e\204Xj","\195?}\251*\158\210a,W\235\&3\249\219Z\143;","\239\251","","\170/\199\164\194\231\210\t\165(#\r\235i\151d\176QN\SUBX\249\195",",\176%\165\203\137\141\230K\EOT\SUBc\197\155N\202\195\t","5\129\227KZ\180\&7\DC4y^","n\227a\231\134C~\181\163^]\213\146"] +// UnsubscribeRequest 22798 ["\214 +// Y}]\179\173\176\b\251]h\254\ESC\182,\133@\151j\ESC\159\GS","\233.\192\135\197\200\229\&2x\v\225\196\212\CAN}.","<\137}/\159\230\156\167b\178\157\205\GS\185","\198\243\228\142\132\168\RS\131\223\&6\253\217\SYN\SOHZ\159\185\243\244\138\136\SO\178\ESC\235\187\154\137","\213\213\156\129\DC2\206vq\233I\171\193\187}\168b\255\221\EM\253Z\195p\244\130","\SO\131z\DC4,5R\ENQ","\STX\193/\236>\189\241\&2\186v\186V\178\138\n\202\195\244\182\181_\ENQ\222\215\\+\177",")","\161.m\ESC\f\253a\221\167\t\199#","@\213\DC1\188GHQ\153\138\NAK\161A\ESC\161\162I\246Q\200\152?\251"] // [] TEST(Unsubscribe311QCTest, Encode5) { - uint8_t pkt[] = {0xa2, 0x90, 0x1, 0xa, 0x96, 0x0, 0xf, 0xc0, 0x65, 0xe5, 0x3e, 0xef, 0xf7, 0xb8, 0xd1, 0x9e, 0x77, - 0xf, 0x5f, 0x58, 0x30, 0x54, 0x0, 0x2, 0x45, 0xf3, 0x0, 0xf, 0xe1, 0x18, 0x2a, 0x45, 0x38, 0x51, - 0x9, 0x2d, 0xfc, 0x42, 0x88, 0x2e, 0xf7, 0xb9, 0xfa, 0x0, 0x5, 0x90, 0x65, 0xcc, 0x58, 0x6a, 0x0, - 0x11, 0xc3, 0x3f, 0x7d, 0xfb, 0x2a, 0x9e, 0xd2, 0x61, 0x2c, 0x57, 0xeb, 0x33, 0xf9, 0xdb, 0x5a, 0x8f, - 0x3b, 0x0, 0x2, 0xef, 0xfb, 0x0, 0x0, 0x0, 0x17, 0xaa, 0x2f, 0xc7, 0xa4, 0xc2, 0xe7, 0xd2, 0x9, - 0xa5, 0x28, 0x23, 0xd, 0xeb, 0x69, 0x97, 0x64, 0xb0, 0x51, 0x4e, 0x1a, 0x58, 0xf9, 0xc3, 0x0, 0x12, - 0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 0x2f, + 0xec, 0x3e, 0xbd, 0xf1, 0x32, 0xba, 0x76, 0xba, 0x56, 0xb2, 0x8a, 0xa, 0xca, 0xc3, 0xf4, 0xb6, 0xb5, + 0x5f, 0x5, 0xde, 0xd7, 0x5c, 0x2b, 0xb1, 0x0, 0x1, 0x29, 0x0, 0xc, 0xa1, 0x2e, 0x6d, 0x1b, 0xc, + 0xfd, 0x61, 0xdd, 0xa7, 0x9, 0xc7, 0x23, 0x0, 0x16, 0x40, 0xd5, 0x11, 0xbc, 0x47, 0x48, 0x51, 0x99, + 0x8a, 0x15, 0xa1, 0x41, 0x1b, 0xa1, 0xa2, 0x49, 0xf6, 0x51, 0xc8, 0x98, 0x3f, 0xfb}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xc0, 0x65, 0xe5, 0x3e, 0xef, 0xf7, 0xb8, 0xd1, - 0x9e, 0x77, 0xf, 0x5f, 0x58, 0x30, 0x54}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd6, 0x20, 0x59, 0x7d, 0x5d, 0xb3, 0xad, 0xb0, 0x8, 0xfb, 0x5d, 0x68, + 0xfe, 0x1b, 0xb6, 0x2c, 0x85, 0x40, 0x97, 0x6a, 0x1b, 0x9f, 0x1d}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x45, 0xf3}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe9, 0x2e, 0xc0, 0x87, 0xc5, 0xc8, 0xe5, 0x32, + 0x78, 0xb, 0xe1, 0xc4, 0xd4, 0x18, 0x7d, 0x2e}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe1, 0x18, 0x2a, 0x45, 0x38, 0x51, 0x9, 0x2d, - 0xfc, 0x42, 0x88, 0x2e, 0xf7, 0xb9, 0xfa}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x3c, 0x89, 0x7d, 0x2f, 0x9f, 0xe6, 0x9c, + 0xa7, 0x62, 0xb2, 0x9d, 0xcd, 0x1d, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x90, 0x65, 0xcc, 0x58, 0x6a}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc6, 0xf3, 0xe4, 0x8e, 0x84, 0xa8, 0x1e, 0x83, 0xdf, 0x36, + 0xfd, 0xd9, 0x16, 0x1, 0x5a, 0x9f, 0xb9, 0xf3, 0xf4, 0x8a, + 0x88, 0xe, 0xb2, 0x1b, 0xeb, 0xbb, 0x9a, 0x89}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc3, 0x3f, 0x7d, 0xfb, 0x2a, 0x9e, 0xd2, 0x61, 0x2c, - 0x57, 0xeb, 0x33, 0xf9, 0xdb, 0x5a, 0x8f, 0x3b}; - lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd5, 0xd5, 0x9c, 0x81, 0x12, 0xce, 0x76, 0x71, 0xe9, 0x49, 0xab, 0xc1, 0xbb, + 0x7d, 0xa8, 0x62, 0xff, 0xdd, 0x19, 0xfd, 0x5a, 0xc3, 0x70, 0xf4, 0x82}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xef, 0xfb}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe, 0x83, 0x7a, 0x14, 0x2c, 0x35, 0x52, 0x5}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x2, 0xc1, 0x2f, 0xec, 0x3e, 0xbd, 0xf1, 0x32, 0xba, 0x76, 0xba, 0x56, 0xb2, 0x8a, + 0xa, 0xca, 0xc3, 0xf4, 0xb6, 0xb5, 0x5f, 0x5, 0xde, 0xd7, 0x5c, 0x2b, 0xb1}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xaa, 0x2f, 0xc7, 0xa4, 0xc2, 0xe7, 0xd2, 0x9, 0xa5, 0x28, 0x23, 0xd, - 0xeb, 0x69, 0x97, 0x64, 0xb0, 0x51, 0x4e, 0x1a, 0x58, 0xf9, 0xc3}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x29}; + lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x2c, 0xb0, 0x25, 0xa5, 0xcb, 0x89, 0x8d, 0xe6, 0x4b, - 0x4, 0x1a, 0x63, 0xc5, 0x9b, 0x4e, 0xca, 0xc3, 0x9}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xa1, 0x2e, 0x6d, 0x1b, 0xc, 0xfd, 0x61, 0xdd, 0xa7, 0x9, 0xc7, 0x23}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x35, 0x81, 0xe3, 0x4b, 0x5a, 0xb4, 0x37, 0x14, 0x79, 0x5e}; - lwmqtt_string_t topic_filter_s9 = {10, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0x40, 0xd5, 0x11, 0xbc, 0x47, 0x48, 0x51, 0x99, 0x8a, 0x15, 0xa1, + 0x41, 0x1b, 0xa1, 0xa2, 0x49, 0xf6, 0x51, 0xc8, 0x98, 0x3f, 0xfb}; + lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x6e, 0xe3, 0x61, 0xe7, 0x86, 0x43, 0x7e, 0xb5, 0xa3, 0x5e, 0x5d, 0xd5, 0x92}; - lwmqtt_string_t topic_filter_s10 = {13, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 2710, 11, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22798, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5130 -// ["\246\197\169\&5\b\231f\149\170\236\240\171d\142Uq\241\RS\138\&2\222\160F\162\243\176NN\249\208","\STXt(\EM\234#}\242B~\248","","\166\"\128\192\131x\219\194\231\DELs\163","\188\202\DLE\SO\251z!\203\ETB\156.Mu\241\151","s\132\130\222\fE\142T\128\&3\v\230\218\&2\210_G6\128\220\251\STX","\t\171%#\219\251\SOH}\175@O\169","1d\CAN\f\SOH\183\253%F*","\195f\ry\161\STX\235\147\NAK\\\189\168","\SUBq;\RS\183\209\228z\166\187\217\155\EM\133[\133:\252\148\SYN","\207\ETB\179"] -// [] +// UnsubscribeRequest 12540 ["\142\149\170v\174V',D\DELQ=,\212\228v"] [] TEST(Unsubscribe311QCTest, Encode7) { - uint8_t pkt[] = {0xa2, 0x8a, 0x1, 0x27, 0x10, 0x0, 0x1a, 0x1c, 0x82, 0xbf, 0x57, 0x35, 0x4c, 0xb6, 0x9c, 0x24, - 0xa5, 0x96, 0x74, 0x6d, 0xff, 0x6c, 0xea, 0xca, 0xb3, 0xd0, 0x3e, 0xdb, 0xc2, 0xe7, 0x7f, 0x73, - 0xa3, 0x0, 0xf, 0xbc, 0xca, 0x10, 0xe, 0xfb, 0x7a, 0x21, 0xcb, 0x17, 0x9c, 0x2e, 0x4d, 0x75, - 0xf1, 0x97, 0x0, 0x16, 0x73, 0x84, 0x82, 0xde, 0xc, 0x45, 0x8e, 0x54, 0x80, 0x33, 0xb, 0xe6, - 0xda, 0x32, 0xd2, 0x5f, 0x47, 0x36, 0x80, 0xdc, 0xfb, 0x2, 0x0, 0xc, 0x9, 0xab, 0x25, 0x23, - 0xdb, 0xfb, 0x1, 0x7d, 0xaf, 0x40, 0x4f, 0xa9, 0x0, 0xa, 0x31, 0x64, 0x18, 0xc, 0x1, 0xb7, - 0xfd, 0x25, 0x46, 0x2a, 0x0, 0xc, 0xc3, 0x66, 0xd, 0x79, 0xa1, 0x2, 0xeb, 0x93, 0x15, 0x5c, - 0xbd, 0xa8, 0x0, 0x14, 0x1a, 0x71, 0x3b, 0x1e, 0xb7, 0xd1, 0xe4, 0x7a, 0xa6, 0xbb, 0xd9, 0x9b, - 0x19, 0x85, 0x5b, 0x85, 0x3a, 0xfc, 0x94, 0x16, 0x0, 0x3, 0xcf, 0x17, 0xb3}; + uint8_t pkt[] = {0xa2, 0x14, 0x30, 0xfc, 0x0, 0x10, 0x8e, 0x95, 0xaa, 0x76, 0xae, + 0x56, 0x27, 0x2c, 0x44, 0x7f, 0x51, 0x3d, 0x2c, 0xd4, 0xe4, 0x76}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x1c, 0x82, 0xbf, 0x57, 0x35, 0x4c, 0xb6, 0x9c, 0x24, 0xa5, 0x96, 0x74, 0x6d, - 0xff, 0x6c, 0xea, 0xca, 0xb3, 0xd0, 0x3e, 0xdb, 0xc2, 0xe7, 0x7f, 0x73, 0xa3}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x8e, 0x95, 0xaa, 0x76, 0xae, 0x56, 0x27, 0x2c, + 0x44, 0x7f, 0x51, 0x3d, 0x2c, 0xd4, 0xe4, 0x76}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbc, 0xca, 0x10, 0xe, 0xfb, 0x7a, 0x21, 0xcb, - 0x17, 0x9c, 0x2e, 0x4d, 0x75, 0xf1, 0x97}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x73, 0x84, 0x82, 0xde, 0xc, 0x45, 0x8e, 0x54, 0x80, 0x33, 0xb, - 0xe6, 0xda, 0x32, 0xd2, 0x5f, 0x47, 0x36, 0x80, 0xdc, 0xfb, 0x2}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9, 0xab, 0x25, 0x23, 0xdb, 0xfb, 0x1, 0x7d, 0xaf, 0x40, 0x4f, 0xa9}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x31, 0x64, 0x18, 0xc, 0x1, 0xb7, 0xfd, 0x25, 0x46, 0x2a}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc3, 0x66, 0xd, 0x79, 0xa1, 0x2, 0xeb, 0x93, 0x15, 0x5c, 0xbd, 0xa8}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x1a, 0x71, 0x3b, 0x1e, 0xb7, 0xd1, 0xe4, 0x7a, 0xa6, 0xbb, - 0xd9, 0x9b, 0x19, 0x85, 0x5b, 0x85, 0x3a, 0xfc, 0x94, 0x16}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xcf, 0x17, 0xb3}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10000, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12540, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 27754 ["\172U5\DEL\CAN\228","8\240H\r\196\215\174\249;\DEL","\196\130@ -// \243\239\224\EM\205\229\136\207\254\167\223\132\193\tA\194A\245\NUL","\224\222\248\EOT\133p^\181\176C\236i7\193\233","\196\184Q\132\RS\SYN&y-\220\&3\GSN\220\172i\ENQ-\143\&9\b\203\226z\253\SI\ACK","\DC1\DC2\SOH\203\"\201\150\136G\ACK\DC3","Y;\167C\134\239\208\r\219\234J\222\197*R\184\150L.\\\178&\NUL\221\229\185\222]","\252\225\DC2~\145\SUBH\232\240\145\206m_u\146*$\254\SYNI\\\174\rk1\157\&5\253\&3\220","1r\226\USM\210o\252\161=\241","]\201\&9"] -// [] +// UnsubscribeRequest 30589 +// [",\131\ETB\170\237\194/\147\140iM\159*x\159V\134","\STX\142\DC1r\DC1\130\183\v\211\183\147\192\211\194\165\200\139I\DEL\174P\171\255p\201p\237","\188\US\rg\233 +// \140\235\ETX\218ZA","S\ETB\255w\US\250\184\&8E\171\173","\EM\ETB8\ESCN","2\230c\246\211\&1\216\150\202\221\173w\147\232$\132pD\236","\186\157\201\165\158\210\ETB\232\194\236\&2<","\GS]\181\179\142\190\230\242(&\196`\142\131\184\\\243"] +// [] TEST(Unsubscribe311QCTest, Encode9) { - uint8_t pkt[] = {0xa2, 0x10, 0x34, 0xdc, 0x0, 0x7, 0xf0, 0x1c, 0x5b, - 0x98, 0x10, 0xe2, 0x99, 0x0, 0x3, 0xef, 0x3f, 0xaa}; + uint8_t pkt[] = {0xa2, 0x84, 0x1, 0x6b, 0x56, 0x0, 0x17, 0x81, 0x46, 0x14, 0xa5, 0x65, 0x78, 0x87, 0x57, 0x5e, 0xa3, + 0x37, 0x5b, 0x1c, 0x80, 0x1c, 0xbb, 0xee, 0xcb, 0xf3, 0x24, 0xca, 0x1c, 0x7, 0x0, 0x1d, 0xe4, 0x77, + 0x9e, 0xf2, 0xba, 0xf9, 0x11, 0xea, 0x7, 0xdb, 0xc6, 0xc1, 0xac, 0x87, 0x59, 0xa1, 0x89, 0x39, 0x3e, + 0xd, 0x67, 0xe9, 0x20, 0x8c, 0xeb, 0x3, 0xda, 0x5a, 0x41, 0x0, 0xb, 0x53, 0x17, 0xff, 0x77, 0x1f, + 0xfa, 0xb8, 0x38, 0x45, 0xab, 0xad, 0x0, 0x5, 0x19, 0x17, 0x38, 0x1b, 0x4e, 0x0, 0x13, 0x32, 0xe6, + 0x63, 0xf6, 0xd3, 0x31, 0xd8, 0x96, 0xca, 0xdd, 0xad, 0x77, 0x93, 0xe8, 0x24, 0x84, 0x70, 0x44, 0xec, + 0x0, 0xc, 0xba, 0x9d, 0xc9, 0xa5, 0x9e, 0xd2, 0x17, 0xe8, 0xc2, 0xec, 0x32, 0x3c, 0x0, 0x11, 0x1d, + 0x5d, 0xb5, 0xb3, 0x8e, 0xbe, 0xe6, 0xf2, 0x28, 0x26, 0xc4, 0x60, 0x8e, 0x83, 0xb8, 0x5c, 0xf3}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xf0, 0x1c, 0x5b, 0x98, 0x10, 0xe2, 0x99}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x81, 0x46, 0x14, 0xa5, 0x65, 0x78, 0x87, 0x57, 0x5e, 0xa3, 0x37, 0x5b, + 0x1c, 0x80, 0x1c, 0xbb, 0xee, 0xcb, 0xf3, 0x24, 0xca, 0x1c, 0x7}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xef, 0x3f, 0xaa}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe4, 0x77, 0x9e, 0xf2, 0xba, 0xf9, 0x11, 0xea, 0x7, 0xdb, + 0xc6, 0xc1, 0xac, 0x87, 0x59, 0xa1, 0x89, 0x39, 0x3e, 0xd, + 0x67, 0xe9, 0x20, 0x8c, 0xeb, 0x3, 0xda, 0x5a, 0x41}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x53, 0x17, 0xff, 0x77, 0x1f, 0xfa, 0xb8, 0x38, 0x45, 0xab, 0xad}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x19, 0x17, 0x38, 0x1b, 0x4e}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x32, 0xe6, 0x63, 0xf6, 0xd3, 0x31, 0xd8, 0x96, 0xca, 0xdd, + 0xad, 0x77, 0x93, 0xe8, 0x24, 0x84, 0x70, 0x44, 0xec}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xba, 0x9d, 0xc9, 0xa5, 0x9e, 0xd2, 0x17, 0xe8, 0xc2, 0xec, 0x32, 0x3c}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x1d, 0x5d, 0xb5, 0xb3, 0x8e, 0xbe, 0xe6, 0xf2, 0x28, + 0x26, 0xc4, 0x60, 0x8e, 0x83, 0xb8, 0x5c, 0xf3}; + lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 13532, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 27478, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 8446 ["N-\DC2\189\173\241\ETB\177\&9 -// \159\f\fj~\213!7\235\ESCx\194@\217\US[<","-","e\189\238\251\177\189\195\DLE\192\"c\166\SUB\DEL\145\133L\154^\"W\ETB\217\212","\155","X\139\243\DEL","\209\253\253\NUL9D\178\250\155BHo!\229=\135\146","\EM\217\251","\193S","\173M\228Y\v","\DC4>\252W0Y"] +// UnsubscribeRequest 18764 +// ["ui\144\128DK\158\RS-oM\167F\213\134\185\210)\189\188\129\201\220\&1z\155\157","\169\200\213O\SOH\206\141\139\213\236\154}\152u\176\134\227\&0N\207\EOT\156gt;\187k\159H","\206\172\214oS\145\156\204\243\DLE\210\244\SYN\139*\DC2\167B\203&\253\186\f\148\247y","-\DC4\EOTT\178\"\162\b\240\242~n2A","@\138\214D\t>7\224\205.\175\EM\SUB\209\229","\138\r\131\241\214h\241\246\&9N\203\214\a\168z!2\218\192\152wW\224","`s\ESC\204\253\132dr\189^I\148e\253\219Ef_\155\221\157\160ON\239=\148\&3\176\241","\147\146\174g\NAK;=\175\245\251\194\146\SYNT\157lYJ\a\176`\251\222\164\236/\237\214y#\151\242.z","\139\214\221#G*U\227T\173Rn@x\190\128\&5y\194\247\195\175\253wE","\GS\251H\DC4\vJP\189\140\185\154\&6\ETB\ETX","\128","\164\134\216\194\&6\188\138H\199\EOT\183\NULcZ?\216\152\181\221Q\186\186(","N\153\169\195C0fs\136\178\185\191\163\GS\DLE\NUL\163\137\203\244\EM\134","%N\154_","\182\139\236\&1\DEL\208\223\&6&D\244\191\208\GS\155S\221","\133 -// \226-gm\142m\195\143\ACK\187RL\224}\157S=\135\230j\143","\221A\DC405q\245^U\188\239\212","\141\201\141\157\242\ACKk\161\185\131\247\CAN\a\240L\180\218Wn\218%\f\247"] +// UnsubscribeRequest 29340 +// [",8\222l\141\171\228\150%\180\238","f\139\198\250\130\173\198\217v\CAN\177\GS~z\244\167-1\239\240Z","m4\217;\151\147\&9uCw\253tO\US\255W\130\164\&3}#\152\181\143\159QB\174\172\171","2\221\150\187\143\&0\n\170D\151\NAK\209\207\203\NAK6\233\203\160","7\n\f\248\170\129>\255Q])\240\ESC\164L\243\138Z`\202u\183w\n\193}\159.\214\155","\255\206\142`","\208\139\240\191|\DEL\198\233\ETB\CAN\151[\DC2[\175\251vI\ETX;$\162\nv/1\179","\184\196\146D\229\218\FS\DC2\153"] // [] TEST(Unsubscribe311QCTest, Encode11) { - uint8_t pkt[] = {0xa2, 0xd7, 0x1, 0x3e, 0xbe, 0x0, 0x1b, 0x14, 0xc8, 0xb6, 0xd9, 0xa5, 0x60, 0xa8, 0x1a, 0x10, 0x37, - 0xa1, 0x99, 0x3e, 0x60, 0xfb, 0xde, 0xa4, 0xec, 0x2f, 0xed, 0xd6, 0x79, 0x23, 0x97, 0xf2, 0x2e, 0x7a, - 0x0, 0x19, 0x8b, 0xd6, 0xdd, 0x23, 0x47, 0x2a, 0x55, 0xe3, 0x54, 0xad, 0x52, 0x6e, 0x40, 0x78, 0xbe, - 0x80, 0x35, 0x79, 0xc2, 0xf7, 0xc3, 0xaf, 0xfd, 0x77, 0x45, 0x0, 0xe, 0x1d, 0xfb, 0x48, 0x14, 0xb, - 0x4a, 0x50, 0xbd, 0x8c, 0xb9, 0x9a, 0x36, 0x17, 0x3, 0x0, 0x1, 0x80, 0x0, 0x17, 0xa4, 0x86, 0xd8, - 0xc2, 0x36, 0xbc, 0x8a, 0x48, 0xc7, 0x4, 0xb7, 0x0, 0x63, 0x5a, 0x3f, 0xd8, 0x98, 0xb5, 0xdd, 0x51, - 0xba, 0xba, 0x28, 0x0, 0x16, 0x4e, 0x99, 0xa9, 0xc3, 0x43, 0x30, 0x66, 0x73, 0x88, 0xb2, 0xb9, 0xbf, - 0xa3, 0x1d, 0x10, 0x0, 0xa3, 0x89, 0xcb, 0xf4, 0x19, 0x86, 0x0, 0x4, 0x25, 0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, + 0x37, 0xa, 0xc, 0xf8, 0xaa, 0x81, 0x3e, 0xff, 0x51, 0x5d, 0x29, 0xf0, 0x1b, 0xa4, 0x4c, 0xf3, + 0x8a, 0x5a, 0x60, 0xca, 0x75, 0xb7, 0x77, 0xa, 0xc1, 0x7d, 0x9f, 0x2e, 0xd6, 0x9b, 0x0, 0x4, + 0xff, 0xce, 0x8e, 0x60, 0x0, 0x1b, 0xd0, 0x8b, 0xf0, 0xbf, 0x7c, 0x7f, 0xc6, 0xe9, 0x17, 0x18, + 0x97, 0x5b, 0x12, 0x5b, 0xaf, 0xfb, 0x76, 0x49, 0x3, 0x3b, 0x24, 0xa2, 0xa, 0x76, 0x2f, 0x31, + 0xb3, 0x0, 0x9, 0xb8, 0xc4, 0x92, 0x44, 0xe5, 0xda, 0x1c, 0x12, 0x99}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x14, 0xc8, 0xb6, 0xd9, 0xa5, 0x60, 0xa8, 0x1a, 0x10, 0x37, 0xa1, 0x99, 0x3e, 0x60, - 0xfb, 0xde, 0xa4, 0xec, 0x2f, 0xed, 0xd6, 0x79, 0x23, 0x97, 0xf2, 0x2e, 0x7a}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x2c, 0x38, 0xde, 0x6c, 0x8d, 0xab, 0xe4, 0x96, 0x25, 0xb4, 0xee}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8b, 0xd6, 0xdd, 0x23, 0x47, 0x2a, 0x55, 0xe3, 0x54, 0xad, 0x52, 0x6e, 0x40, - 0x78, 0xbe, 0x80, 0x35, 0x79, 0xc2, 0xf7, 0xc3, 0xaf, 0xfd, 0x77, 0x45}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x66, 0x8b, 0xc6, 0xfa, 0x82, 0xad, 0xc6, 0xd9, 0x76, 0x18, 0xb1, + 0x1d, 0x7e, 0x7a, 0xf4, 0xa7, 0x2d, 0x31, 0xef, 0xf0, 0x5a}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1d, 0xfb, 0x48, 0x14, 0xb, 0x4a, 0x50, 0xbd, 0x8c, 0xb9, 0x9a, 0x36, 0x17, 0x3}; - lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6d, 0x34, 0xd9, 0x3b, 0x97, 0x93, 0x39, 0x75, 0x43, 0x77, + 0xfd, 0x74, 0x4f, 0x1f, 0xff, 0x57, 0x82, 0xa4, 0x33, 0x7d, + 0x23, 0x98, 0xb5, 0x8f, 0x9f, 0x51, 0x42, 0xae, 0xac, 0xab}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x80}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x32, 0xdd, 0x96, 0xbb, 0x8f, 0x30, 0xa, 0xaa, 0x44, 0x97, + 0x15, 0xd1, 0xcf, 0xcb, 0x15, 0x36, 0xe9, 0xcb, 0xa0}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa4, 0x86, 0xd8, 0xc2, 0x36, 0xbc, 0x8a, 0x48, 0xc7, 0x4, 0xb7, 0x0, - 0x63, 0x5a, 0x3f, 0xd8, 0x98, 0xb5, 0xdd, 0x51, 0xba, 0xba, 0x28}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x37, 0xa, 0xc, 0xf8, 0xaa, 0x81, 0x3e, 0xff, 0x51, 0x5d, + 0x29, 0xf0, 0x1b, 0xa4, 0x4c, 0xf3, 0x8a, 0x5a, 0x60, 0xca, + 0x75, 0xb7, 0x77, 0xa, 0xc1, 0x7d, 0x9f, 0x2e, 0xd6, 0x9b}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4e, 0x99, 0xa9, 0xc3, 0x43, 0x30, 0x66, 0x73, 0x88, 0xb2, 0xb9, - 0xbf, 0xa3, 0x1d, 0x10, 0x0, 0xa3, 0x89, 0xcb, 0xf4, 0x19, 0x86}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xff, 0xce, 0x8e, 0x60}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x25, 0x4e, 0x9a, 0x5f}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xd0, 0x8b, 0xf0, 0xbf, 0x7c, 0x7f, 0xc6, 0xe9, 0x17, 0x18, 0x97, 0x5b, 0x12, 0x5b, + 0xaf, 0xfb, 0x76, 0x49, 0x3, 0x3b, 0x24, 0xa2, 0xa, 0x76, 0x2f, 0x31, 0xb3}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb6, 0x8b, 0xec, 0x31, 0x7f, 0xd0, 0xdf, 0x36, 0x26, - 0x44, 0xf4, 0xbf, 0xd0, 0x1d, 0x9b, 0x53, 0xdd}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xb8, 0xc4, 0x92, 0x44, 0xe5, 0xda, 0x1c, 0x12, 0x99}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x85, 0x20, 0xe2, 0x2d, 0x67, 0x6d, 0x8e, 0x6d, 0xc3, 0x8f, 0x6, 0xbb, - 0x52, 0x4c, 0xe0, 0x7d, 0x9d, 0x53, 0x3d, 0x87, 0xe6, 0x6a, 0x8f}; - lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xdd, 0x41, 0x14, 0x30, 0x35, 0x71, 0xf5, 0x5e, 0x55, 0xbc, 0xef, 0xd4}; - lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x8d, 0xc9, 0x8d, 0x9d, 0xf2, 0x6, 0x6b, 0xa1, 0xb9, 0x83, 0xf7, 0x18, - 0x7, 0xf0, 0x4c, 0xb4, 0xda, 0x57, 0x6e, 0xda, 0x25, 0xc, 0xf7}; - lwmqtt_string_t topic_filter_s10 = {23, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16062, 11, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29340, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 999 -// ["kz8\"x_\167\&7\"\185\142\244:j\DC1","|","$\185\f4w\233","T\165\216\ETB\180p\NULe\ETX8\144\DLE4\DC4\GS\226\218\129\RS\SOHz","\172|>\168&\208\226\212\228lp\RSw\196\153\ESC\218\178l\207\rqgP\t\155$\145\ENQ","\EOT\244\t\200\GS\218\166\a\ETBL\218\191\198\183\130OR\ENQn\151\"|"] +// UnsubscribeRequest 24289 +// ["\n\b_\177","\SO\173\150\235=\192\GSn\194\230\155","}0\US\\\211\232\235\DC1[\238\231\192\209Z\247","\234\ACK&\142\250","g\nP\ENQ%\231\181O\209\135\180\175q$\ETX75\164\168\EM\128\237\158","\245\184u\183\169S\226\171\US\SI\243\DC4x\154\DC2\228\211\195\243W\202\218\NUL\224\&5\236\132\246","\204\"i\DC4\191\234\255\177|\153\255~","m\211","m\128\ESCiS\128.\143/\172\205\144l\161\DEL[)\168y","!\183*7Kr\181\253\180,\146\166\&9\158\207T5\206\209Wx\225","\229\215Yl={\ETB\216/\212}\170\DEL"] // [] TEST(Unsubscribe311QCTest, Encode12) { - uint8_t pkt[] = {0xa2, 0x6c, 0x3, 0xe7, 0x0, 0xf, 0x6b, 0x7a, 0x38, 0x22, 0x78, 0x5f, 0xa7, 0x37, 0x22, 0xb9, - 0x8e, 0xf4, 0x3a, 0x6a, 0x11, 0x0, 0x1, 0x7c, 0x0, 0x6, 0x24, 0xb9, 0xc, 0x34, 0x77, 0xe9, - 0x0, 0x15, 0x54, 0xa5, 0xd8, 0x17, 0xb4, 0x70, 0x0, 0x65, 0x3, 0x38, 0x90, 0x10, 0x34, 0x14, - 0x1d, 0xe2, 0xda, 0x81, 0x1e, 0x1, 0x7a, 0x0, 0x1d, 0xac, 0x7c, 0x3e, 0xa8, 0x26, 0xd0, 0xe2, - 0xd4, 0xe4, 0x6c, 0x70, 0x1e, 0x77, 0xc4, 0x99, 0x1b, 0xda, 0xb2, 0x6c, 0xcf, 0xd, 0x71, 0x67, - 0x50, 0x9, 0x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 0xa6, 0x39, 0x9e, 0xcf, 0x54, 0x35, 0xce, 0xd1, 0x57, 0x78, 0xe1, 0x0, 0xd, 0xe5, 0xd7, + 0x59, 0x6c, 0x3d, 0x7b, 0x17, 0xd8, 0x2f, 0xd4, 0x7d, 0xaa, 0x7f}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x6b, 0x7a, 0x38, 0x22, 0x78, 0x5f, 0xa7, 0x37, - 0x22, 0xb9, 0x8e, 0xf4, 0x3a, 0x6a, 0x11}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xa, 0x8, 0x5f, 0xb1}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7c}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe, 0xad, 0x96, 0xeb, 0x3d, 0xc0, 0x1d, 0x6e, 0xc2, 0xe6, 0x9b}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x24, 0xb9, 0xc, 0x34, 0x77, 0xe9}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7d, 0x30, 0x1f, 0x5c, 0xd3, 0xe8, 0xeb, 0x11, + 0x5b, 0xee, 0xe7, 0xc0, 0xd1, 0x5a, 0xf7}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x54, 0xa5, 0xd8, 0x17, 0xb4, 0x70, 0x0, 0x65, 0x3, 0x38, 0x90, - 0x10, 0x34, 0x14, 0x1d, 0xe2, 0xda, 0x81, 0x1e, 0x1, 0x7a}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xea, 0x6, 0x26, 0x8e, 0xfa}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xac, 0x7c, 0x3e, 0xa8, 0x26, 0xd0, 0xe2, 0xd4, 0xe4, 0x6c, - 0x70, 0x1e, 0x77, 0xc4, 0x99, 0x1b, 0xda, 0xb2, 0x6c, 0xcf, - 0xd, 0x71, 0x67, 0x50, 0x9, 0x9b, 0x24, 0x91, 0x5}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x67, 0xa, 0x50, 0x5, 0x25, 0xe7, 0xb5, 0x4f, 0xd1, 0x87, 0xb4, 0xaf, + 0x71, 0x24, 0x3, 0x37, 0x35, 0xa4, 0xa8, 0x19, 0x80, 0xed, 0x9e}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4, 0xf4, 0x9, 0xc8, 0x1d, 0xda, 0xa6, 0x7, 0x17, 0x4c, 0xda, - 0xbf, 0xc6, 0xb7, 0x82, 0x4f, 0x52, 0x5, 0x6e, 0x97, 0x22, 0x7c}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf5, 0xb8, 0x75, 0xb7, 0xa9, 0x53, 0xe2, 0xab, 0x1f, 0xf, + 0xf3, 0x14, 0x78, 0x9a, 0x12, 0xe4, 0xd3, 0xc3, 0xf3, 0x57, + 0xca, 0xda, 0x0, 0xe0, 0x35, 0xec, 0x84, 0xf6}; + lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 999, 6, topic_filters, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + uint8_t topic_filter_s6_bytes[] = {0xcc, 0x22, 0x69, 0x14, 0xbf, 0xea, 0xff, 0xb1, 0x7c, 0x99, 0xff, 0x7e}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6d, 0xd3}; + lwmqtt_string_t topic_filter_s7 = {2, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x6d, 0x80, 0x1b, 0x69, 0x53, 0x80, 0x2e, 0x8f, 0x2f, 0xac, + 0xcd, 0x90, 0x6c, 0xa1, 0x7f, 0x5b, 0x29, 0xa8, 0x79}; + lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x21, 0xb7, 0x2a, 0x37, 0x4b, 0x72, 0xb5, 0xfd, 0xb4, 0x2c, 0x92, + 0xa6, 0x39, 0x9e, 0xcf, 0x54, 0x35, 0xce, 0xd1, 0x57, 0x78, 0xe1}; + lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xe5, 0xd7, 0x59, 0x6c, 0x3d, 0x7b, 0x17, 0xd8, 0x2f, 0xd4, 0x7d, 0xaa, 0x7f}; + lwmqtt_string_t topic_filter_s10 = {13, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24289, 11, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} -// UnsubscribeRequest 5737 -// ["\216\200`8N","z\226\248\NULq\EOT\232\158\NUL\178\131\247\130\n\240\192\225^","?x\STX-5\217\158\213\253+\165\134\173`#\190\229\177\228\177\183\\\204V","[Q","\190\180u\222#\171\SUBik\221\246\227\164)\239\210\EOT4[-","f\SO\237iS\197T\247\250\167?\228\242\170\213_b\215\241\221\153\136\138\229\175","E}\SUB\221S\172 -// \FS\189&}v\220"] [] +// UnsubscribeRequest 26276 +// ["U^\138\255\DC2\173G\168Q\178\rw8ZS","\162\\\255\SOHI\247\ETB\199\148e\254\245\221\242\129\161\181_\214\DEL","\166\180j +// ","m\DLEV\240\&7\150\DC1\248lX\136\130\205]\233\142NLy\tB\251ll,`\155E\143\138","\141\GS\195\177)_)w9C\234\132H\154\DC1J\147","\213\215P","\247\239\158","\226\165#\135\230;\245\233\171}","\202>m\132\GS9\145\246\137\NAK\237Q"] +// [] TEST(Unsubscribe311QCTest, Encode13) { - uint8_t pkt[] = {0xa2, 0x7b, 0x16, 0x69, 0x0, 0x5, 0xd8, 0xc8, 0x60, 0x38, 0x4e, 0x0, 0x12, 0x7a, 0xe2, 0xf8, - 0x0, 0x71, 0x4, 0xe8, 0x9e, 0x0, 0xb2, 0x83, 0xf7, 0x82, 0xa, 0xf0, 0xc0, 0xe1, 0x5e, 0x0, - 0x18, 0x3f, 0x78, 0x2, 0x2d, 0x35, 0xd9, 0x9e, 0xd5, 0xfd, 0x2b, 0xa5, 0x86, 0xad, 0x60, 0x23, - 0xbe, 0xe5, 0xb1, 0xe4, 0xb1, 0xb7, 0x5c, 0xcc, 0x56, 0x0, 0x2, 0x5b, 0x51, 0x0, 0x14, 0xbe, - 0xb4, 0x75, 0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x0, 0xc, 0xca, 0x3e, 0x6d, + 0x84, 0x1d, 0x39, 0x91, 0xf6, 0x89, 0x15, 0xed, 0x51}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xd8, 0xc8, 0x60, 0x38, 0x4e}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x55, 0x5e, 0x8a, 0xff, 0x12, 0xad, 0x47, 0xa8, + 0x51, 0xb2, 0xd, 0x77, 0x38, 0x5a, 0x53}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7a, 0xe2, 0xf8, 0x0, 0x71, 0x4, 0xe8, 0x9e, 0x0, - 0xb2, 0x83, 0xf7, 0x82, 0xa, 0xf0, 0xc0, 0xe1, 0x5e}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa2, 0x5c, 0xff, 0x1, 0x49, 0xf7, 0x17, 0xc7, 0x94, 0x65, + 0xfe, 0xf5, 0xdd, 0xf2, 0x81, 0xa1, 0xb5, 0x5f, 0xd6, 0x7f}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x3f, 0x78, 0x2, 0x2d, 0x35, 0xd9, 0x9e, 0xd5, 0xfd, 0x2b, 0xa5, 0x86, - 0xad, 0x60, 0x23, 0xbe, 0xe5, 0xb1, 0xe4, 0xb1, 0xb7, 0x5c, 0xcc, 0x56}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa6, 0xb4, 0x6a, 0x20}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x5b, 0x51}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6d, 0x10, 0x56, 0xf0, 0x37, 0x96, 0x11, 0xf8, 0x6c, 0x58, + 0x88, 0x82, 0xcd, 0x5d, 0xe9, 0x8e, 0x4e, 0x4c, 0x79, 0x9, + 0x42, 0xfb, 0x6c, 0x6c, 0x2c, 0x60, 0x9b, 0x45, 0x8f, 0x8a}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xbe, 0xb4, 0x75, 0xde, 0x23, 0xab, 0x1a, 0x69, 0x6b, 0xdd, - 0xf6, 0xe3, 0xa4, 0x29, 0xef, 0xd2, 0x4, 0x34, 0x5b, 0x2d}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x8d, 0x1d, 0xc3, 0xb1, 0x29, 0x5f, 0x29, 0x77, 0x39, + 0x43, 0xea, 0x84, 0x48, 0x9a, 0x11, 0x4a, 0x93}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x66, 0xe, 0xed, 0x69, 0x53, 0xc5, 0x54, 0xf7, 0xfa, 0xa7, 0x3f, 0xe4, 0xf2, - 0xaa, 0xd5, 0x5f, 0x62, 0xd7, 0xf1, 0xdd, 0x99, 0x88, 0x8a, 0xe5, 0xaf}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xd5, 0xd7, 0x50}; + lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x45, 0x7d, 0x1a, 0xdd, 0x53, 0xac, 0x20, 0x1c, 0xbd, 0x26, 0x7d, 0x76, 0xdc}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xf7, 0xef, 0x9e}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe2, 0xa5, 0x23, 0x87, 0xe6, 0x3b, 0xf5, 0xe9, 0xab, 0x7d}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xca, 0x3e, 0x6d, 0x84, 0x1d, 0x39, 0x91, 0xf6, 0x89, 0x15, 0xed, 0x51}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5737, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26276, 9, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 1255 -// ["\153\GSI\185K\229\aE*T\235?5*(","9\225=)\198\150\245\192\130\194N\204d\137\162(\248\142n","\163\168\DEL\193\254\161\250\166\204\221\231\250\&9\228\202\163\162%\242c\223\217\250\182","\255\201\247\&9\DC4?\255\229\SI\EOT\228fc\ETB\177\225+b\159\&5O\218\ACK\132","\251\n\SYN~\RS\180\172y\RS\f\228\211*\214","Uq\215s\244Y",""] -// [] +// UnsubscribeRequest 10986 ["\211N\246\229\152\243\228\134\131\ETX\138\162\&1\EOT\161\135L\163\147\186\NUL"] [] TEST(Unsubscribe311QCTest, Encode14) { - uint8_t pkt[] = {0xa2, 0x76, 0x4, 0xe7, 0x0, 0xf, 0x99, 0x1d, 0x49, 0xb9, 0x4b, 0xe5, 0x7, 0x45, 0x2a, - 0x54, 0xeb, 0x3f, 0x35, 0x2a, 0x28, 0x0, 0x13, 0x39, 0xe1, 0x3d, 0x29, 0xc6, 0x96, 0xf5, - 0xc0, 0x82, 0xc2, 0x4e, 0xcc, 0x64, 0x89, 0xa2, 0x28, 0xf8, 0x8e, 0x6e, 0x0, 0x18, 0xa3, - 0xa8, 0x7f, 0xc1, 0xfe, 0xa1, 0xfa, 0xa6, 0xcc, 0xdd, 0xe7, 0xfa, 0x39, 0xe4, 0xca, 0xa3, - 0xa2, 0x25, 0xf2, 0x63, 0xdf, 0xd9, 0xfa, 0xb6, 0x0, 0x18, 0xff, 0xc9, 0xf7, 0x39, 0x14, - 0x3f, 0xff, 0xe5, 0xf, 0x4, 0xe4, 0x66, 0x63, 0x17, 0xb1, 0xe1, 0x2b, 0x62, 0x9f, 0x35, - 0x4f, 0xda, 0x6, 0x84, 0x0, 0xe, 0xfb, 0xa, 0x16, 0x7e, 0x1e, 0xb4, 0xac, 0x79, 0x1e, - 0xc, 0xe4, 0xd3, 0x2a, 0xd6, 0x0, 0x6, 0x55, 0x71, 0xd7, 0x73, 0xf4, 0x59, 0x0, 0x0}; + uint8_t pkt[] = {0xa2, 0x19, 0x2a, 0xea, 0x0, 0x15, 0xd3, 0x4e, 0xf6, 0xe5, 0x98, 0xf3, 0xe4, 0x86, + 0x83, 0x3, 0x8a, 0xa2, 0x31, 0x4, 0xa1, 0x87, 0x4c, 0xa3, 0x93, 0xba, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x99, 0x1d, 0x49, 0xb9, 0x4b, 0xe5, 0x7, 0x45, - 0x2a, 0x54, 0xeb, 0x3f, 0x35, 0x2a, 0x28}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xd3, 0x4e, 0xf6, 0xe5, 0x98, 0xf3, 0xe4, 0x86, 0x83, 0x3, 0x8a, + 0xa2, 0x31, 0x4, 0xa1, 0x87, 0x4c, 0xa3, 0x93, 0xba, 0x0}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x39, 0xe1, 0x3d, 0x29, 0xc6, 0x96, 0xf5, 0xc0, 0x82, 0xc2, - 0x4e, 0xcc, 0x64, 0x89, 0xa2, 0x28, 0xf8, 0x8e, 0x6e}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa3, 0xa8, 0x7f, 0xc1, 0xfe, 0xa1, 0xfa, 0xa6, 0xcc, 0xdd, 0xe7, 0xfa, - 0x39, 0xe4, 0xca, 0xa3, 0xa2, 0x25, 0xf2, 0x63, 0xdf, 0xd9, 0xfa, 0xb6}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xff, 0xc9, 0xf7, 0x39, 0x14, 0x3f, 0xff, 0xe5, 0xf, 0x4, 0xe4, 0x66, - 0x63, 0x17, 0xb1, 0xe1, 0x2b, 0x62, 0x9f, 0x35, 0x4f, 0xda, 0x6, 0x84}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xfb, 0xa, 0x16, 0x7e, 0x1e, 0xb4, 0xac, 0x79, 0x1e, 0xc, 0xe4, 0xd3, 0x2a, 0xd6}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x55, 0x71, 0xd7, 0x73, 0xf4, 0x59}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1255, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 10986, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22682 -// ["\DEL\148\206K\136Hx\216\137\137*\209\248*\186\130\163\206@\US%\179s","\232\&0\131\241\219a\152\207V\185\213v\186[\165\191\DC4`K\144\228\194\ETBVgW","\195\211\171c\216\f\DC2\165`\183Pj\228\216~\238@","5\234\US\174\183$\196V\DLE\168\247\255","h7\224\134\254\229\GSn\131_1\200>e","H\ETB\172+\157d!VF\131\157!\EM\201","\179U.\225i\222\SYN\136b\NULw\SOH\187\&1M\135p:","Y\189?\174\nQyM\165.\"\ENQ\140__\192\254\187\228","\239\222\226\181\184\209\133\199\&7O\254\175","\EOT\229\DC4.X\129\129\&5\204;\230"] +// UnsubscribeRequest 4312 +// ["\193\221H\191\161\206J\DC1\180\232?","P\140\182\141z\SOH\RS\130=\215\199\SI\253\203k\169","\230\174","\186c\168Ddi\167\152\197"] // [] TEST(Unsubscribe311QCTest, Encode15) { - uint8_t pkt[] = {0xa2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35, 0xcc, 0x3b, 0xe6}; + uint8_t pkt[] = {0xa2, 0x30, 0x10, 0xd8, 0x0, 0xb, 0xc1, 0xdd, 0x48, 0xbf, 0xa1, 0xce, 0x4a, 0x11, 0xb4, 0xe8, 0x3f, + 0x0, 0x10, 0x50, 0x8c, 0xb6, 0x8d, 0x7a, 0x1, 0x1e, 0x82, 0x3d, 0xd7, 0xc7, 0xf, 0xfd, 0xcb, 0x6b, + 0xa9, 0x0, 0x2, 0xe6, 0xae, 0x0, 0x9, 0xba, 0x63, 0xa8, 0x44, 0x64, 0x69, 0xa7, 0x98, 0xc5}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x7f, 0x94, 0xce, 0x4b, 0x88, 0x48, 0x78, 0xd8, 0x89, 0x89, 0x2a, 0xd1, - 0xf8, 0x2a, 0xba, 0x82, 0xa3, 0xce, 0x40, 0x1f, 0x25, 0xb3, 0x73}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xc1, 0xdd, 0x48, 0xbf, 0xa1, 0xce, 0x4a, 0x11, 0xb4, 0xe8, 0x3f}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe8, 0x30, 0x83, 0xf1, 0xdb, 0x61, 0x98, 0xcf, 0x56, 0xb9, 0xd5, 0x76, 0xba, - 0x5b, 0xa5, 0xbf, 0x14, 0x60, 0x4b, 0x90, 0xe4, 0xc2, 0x17, 0x56, 0x67, 0x57}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x50, 0x8c, 0xb6, 0x8d, 0x7a, 0x1, 0x1e, 0x82, + 0x3d, 0xd7, 0xc7, 0xf, 0xfd, 0xcb, 0x6b, 0xa9}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc3, 0xd3, 0xab, 0x63, 0xd8, 0xc, 0x12, 0xa5, 0x60, - 0xb7, 0x50, 0x6a, 0xe4, 0xd8, 0x7e, 0xee, 0x40}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe6, 0xae}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x35, 0xea, 0x1f, 0xae, 0xb7, 0x24, 0xc4, 0x56, 0x10, 0xa8, 0xf7, 0xff}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xba, 0x63, 0xa8, 0x44, 0x64, 0x69, 0xa7, 0x98, 0xc5}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x68, 0x37, 0xe0, 0x86, 0xfe, 0xe5, 0x1d, - 0x6e, 0x83, 0x5f, 0x31, 0xc8, 0x3e, 0x65}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x48, 0x17, 0xac, 0x2b, 0x9d, 0x64, 0x21, - 0x56, 0x46, 0x83, 0x9d, 0x21, 0x19, 0xc9}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb3, 0x55, 0x2e, 0xe1, 0x69, 0xde, 0x16, 0x88, 0x62, - 0x0, 0x77, 0x1, 0xbb, 0x31, 0x4d, 0x87, 0x70, 0x3a}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x59, 0xbd, 0x3f, 0xae, 0xa, 0x51, 0x79, 0x4d, 0xa5, 0x2e, - 0x22, 0x5, 0x8c, 0x5f, 0x5f, 0xc0, 0xfe, 0xbb, 0xe4}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xef, 0xde, 0xe2, 0xb5, 0xb8, 0xd1, 0x85, 0xc7, 0x37, 0x4f, 0xfe, 0xaf}; - lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x4, 0xe5, 0x14, 0x2e, 0x58, 0x81, 0x81, 0x35, 0xcc, 0x3b, 0xe6}; - lwmqtt_string_t topic_filter_s9 = {11, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22682, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4312, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24213 ["\253g\ETX\138\DLEW\170\231\214\133H\RS\206+f|@C\175*,\178\EM"] [] +// UnsubscribeRequest 12998 ["\f\217\182 +\CAN\154)2\SO"] [] TEST(Unsubscribe311QCTest, Encode16) { - uint8_t pkt[] = {0xa2, 0x1b, 0x5e, 0x95, 0x0, 0x17, 0xfd, 0x67, 0x3, 0x8a, 0x10, 0x57, 0xaa, 0xe7, 0xd6, - 0x85, 0x48, 0x1e, 0xce, 0x2b, 0x66, 0x7c, 0x40, 0x43, 0xaf, 0x2a, 0x2c, 0xb2, 0x19}; + uint8_t pkt[] = {0xa2, 0xe, 0x32, 0xc6, 0x0, 0xa, 0xc, 0xd9, 0xb6, 0x20, 0x2b, 0x18, 0x9a, 0x29, 0x32, 0xe}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xfd, 0x67, 0x3, 0x8a, 0x10, 0x57, 0xaa, 0xe7, 0xd6, 0x85, 0x48, 0x1e, - 0xce, 0x2b, 0x66, 0x7c, 0x40, 0x43, 0xaf, 0x2a, 0x2c, 0xb2, 0x19}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xc, 0xd9, 0xb6, 0x20, 0x2b, 0x18, 0x9a, 0x29, 0x32, 0xe}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24213, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12998, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 26833 ["U\246\DEL\"\254\131\166\165\187} -// \200\GShm\235K\206G\207\253\148\237\168#\193","\250","\234\199f)*\128@\216\214'\215\213","\SO\NULF\227\255\SUBc\189X\168\213\213","\DC2Q\176m\\J","!f2>\204\138\CAN\NUL:\235\222"] +// UnsubscribeRequest 22695 +// ["\US=Q\130p\186\189<~\223\ETB\159\172\RS\"","\154\US\251v\173\148cR#\242{2&OX","","\207\130ja\252\230","w\208\209\&7\221\NAK\201\a\158"," +// \144\157t\SI\181?\209\217\255\240\SUB","\142v\242\219\199","\245v\238\\\DC3D\195\196\EM\a\252\245\160@F\f\226O\180\243YQ7\US\252\242","*\r#(\235\ETX3","\ETB\203\154\ENQ\171sq\ESC","\DC4w\144)\254\161\166\132@\214j\FSn\209A\DLE\fuHCo>\206fKmw"] // [] TEST(Unsubscribe311QCTest, Encode17) { - uint8_t pkt[] = {0xa2, 0x52, 0x68, 0xd1, 0x0, 0x1a, 0x55, 0xf6, 0x7f, 0x22, 0xfe, 0x83, 0xa6, 0xa5, 0xbb, 0x7d, 0x20, - 0xc8, 0x1d, 0x68, 0x6d, 0xeb, 0x4b, 0xce, 0x47, 0xcf, 0xfd, 0x94, 0xed, 0xa8, 0x23, 0xc1, 0x0, 0x1, - 0xfa, 0x0, 0xc, 0xea, 0xc7, 0x66, 0x29, 0x2a, 0x80, 0x40, 0xd8, 0xd6, 0x27, 0xd7, 0xd5, 0x0, 0xc, - 0xe, 0x0, 0x46, 0xe3, 0xff, 0x1a, 0x63, 0xbd, 0x58, 0xa8, 0xd5, 0xd5, 0x0, 0x6, 0x12, 0x51, 0xb0, - 0x6d, 0x5c, 0x4a, 0x0, 0xb, 0x21, 0x66, 0x32, 0x3e, 0xcc, 0x8a, 0x18, 0x0, 0x3a, 0xeb, 0xde}; + uint8_t pkt[] = {0xa2, 0x9a, 0x1, 0x58, 0xa7, 0x0, 0xf, 0x1f, 0x3d, 0x51, 0x82, 0x70, 0xba, 0xbd, 0x3c, 0x7e, + 0xdf, 0x17, 0x9f, 0xac, 0x1e, 0x22, 0x0, 0xf, 0x9a, 0x1f, 0xfb, 0x76, 0xad, 0x94, 0x63, 0x52, + 0x23, 0xf2, 0x7b, 0x32, 0x26, 0x4f, 0x58, 0x0, 0x0, 0x0, 0x6, 0xcf, 0x82, 0x6a, 0x61, 0xfc, + 0xe6, 0x0, 0x9, 0x77, 0xd0, 0xd1, 0x37, 0xdd, 0x15, 0xc9, 0x7, 0x9e, 0x0, 0xc, 0x20, 0x90, + 0x9d, 0x74, 0xf, 0xb5, 0x3f, 0xd1, 0xd9, 0xff, 0xf0, 0x1a, 0x0, 0x5, 0x8e, 0x76, 0xf2, 0xdb, + 0xc7, 0x0, 0x1a, 0xf5, 0x76, 0xee, 0x5c, 0x13, 0x44, 0xc3, 0xc4, 0x19, 0x7, 0xfc, 0xf5, 0xa0, + 0x40, 0x46, 0xc, 0xe2, 0x4f, 0xb4, 0xf3, 0x59, 0x51, 0x37, 0x1f, 0xfc, 0xf2, 0x0, 0x7, 0x2a, + 0xd, 0x23, 0x28, 0xeb, 0x3, 0x33, 0x0, 0x8, 0x17, 0xcb, 0x9a, 0x5, 0xab, 0x73, 0x71, 0x1b, + 0x0, 0x1b, 0x14, 0x77, 0x90, 0x29, 0xfe, 0xa1, 0xa6, 0x84, 0x40, 0xd6, 0x6a, 0x1c, 0x6e, 0xd1, + 0x41, 0x10, 0xc, 0x75, 0x48, 0x43, 0x6f, 0x3e, 0xce, 0x66, 0x4b, 0x6d, 0x77}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x55, 0xf6, 0x7f, 0x22, 0xfe, 0x83, 0xa6, 0xa5, 0xbb, 0x7d, 0x20, 0xc8, 0x1d, - 0x68, 0x6d, 0xeb, 0x4b, 0xce, 0x47, 0xcf, 0xfd, 0x94, 0xed, 0xa8, 0x23, 0xc1}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x1f, 0x3d, 0x51, 0x82, 0x70, 0xba, 0xbd, 0x3c, + 0x7e, 0xdf, 0x17, 0x9f, 0xac, 0x1e, 0x22}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfa}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9a, 0x1f, 0xfb, 0x76, 0xad, 0x94, 0x63, 0x52, + 0x23, 0xf2, 0x7b, 0x32, 0x26, 0x4f, 0x58}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xea, 0xc7, 0x66, 0x29, 0x2a, 0x80, 0x40, 0xd8, 0xd6, 0x27, 0xd7, 0xd5}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe, 0x0, 0x46, 0xe3, 0xff, 0x1a, 0x63, 0xbd, 0x58, 0xa8, 0xd5, 0xd5}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xcf, 0x82, 0x6a, 0x61, 0xfc, 0xe6}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x12, 0x51, 0xb0, 0x6d, 0x5c, 0x4a}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x77, 0xd0, 0xd1, 0x37, 0xdd, 0x15, 0xc9, 0x7, 0x9e}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x21, 0x66, 0x32, 0x3e, 0xcc, 0x8a, 0x18, 0x0, 0x3a, 0xeb, 0xde}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x20, 0x90, 0x9d, 0x74, 0xf, 0xb5, 0x3f, 0xd1, 0xd9, 0xff, 0xf0, 0x1a}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8e, 0x76, 0xf2, 0xdb, 0xc7}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf5, 0x76, 0xee, 0x5c, 0x13, 0x44, 0xc3, 0xc4, 0x19, 0x7, 0xfc, 0xf5, 0xa0, + 0x40, 0x46, 0xc, 0xe2, 0x4f, 0xb4, 0xf3, 0x59, 0x51, 0x37, 0x1f, 0xfc, 0xf2}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x2a, 0xd, 0x23, 0x28, 0xeb, 0x3, 0x33}; + lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x17, 0xcb, 0x9a, 0x5, 0xab, 0x73, 0x71, 0x1b}; + lwmqtt_string_t topic_filter_s9 = {8, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x14, 0x77, 0x90, 0x29, 0xfe, 0xa1, 0xa6, 0x84, 0x40, + 0xd6, 0x6a, 0x1c, 0x6e, 0xd1, 0x41, 0x10, 0xc, 0x75, + 0x48, 0x43, 0x6f, 0x3e, 0xce, 0x66, 0x4b, 0x6d, 0x77}; + lwmqtt_string_t topic_filter_s10 = {27, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26833, 6, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 22695, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24597 ["\t\134\178\219\159\249\235\250\187","\166)\230\184Y\252\r.B"] [] +// UnsubscribeRequest 6495 +// ["\144\187\SI\200\142y'N)^\214\NAK?\219\158\254U\230%dp\180","\136\DC3j\179'\202\200\245\NUL","\203'UwJf\198\144=(\SUB\t2\239\vn\ETX\STX\143\223\198\247","\203\207^\SUB\210\&1\139\213N\188\224\207\190\140","\ETB\201","w\233no\170\133\141i\142\ACK\178rv\222\&1\141\195\143U","12","","\181/"] +// [] TEST(Unsubscribe311QCTest, Encode18) { - uint8_t pkt[] = {0xa2, 0x18, 0x60, 0x15, 0x0, 0x9, 0x9, 0x86, 0xb2, 0xdb, 0x9f, 0xf9, 0xeb, - 0xfa, 0xbb, 0x0, 0x9, 0xa6, 0x29, 0xe6, 0xb8, 0x59, 0xfc, 0xd, 0x2e, 0x42}; + uint8_t pkt[] = {0xa2, 0x70, 0x19, 0x5f, 0x0, 0x16, 0x90, 0xbb, 0xf, 0xc8, 0x8e, 0x79, 0x27, 0x4e, 0x29, 0x5e, 0xd6, + 0x15, 0x3f, 0xdb, 0x9e, 0xfe, 0x55, 0xe6, 0x25, 0x64, 0x70, 0xb4, 0x0, 0x9, 0x88, 0x13, 0x6a, 0xb3, + 0x27, 0xca, 0xc8, 0xf5, 0x0, 0x0, 0x16, 0xcb, 0x27, 0x55, 0x77, 0x4a, 0x66, 0xc6, 0x90, 0x3d, 0x28, + 0x1a, 0x9, 0x32, 0xef, 0xb, 0x6e, 0x3, 0x2, 0x8f, 0xdf, 0xc6, 0xf7, 0x0, 0xe, 0xcb, 0xcf, 0x5e, + 0x1a, 0xd2, 0x31, 0x8b, 0xd5, 0x4e, 0xbc, 0xe0, 0xcf, 0xbe, 0x8c, 0x0, 0x2, 0x17, 0xc9, 0x0, 0x13, + 0x77, 0xe9, 0x6e, 0x6f, 0xaa, 0x85, 0x8d, 0x69, 0x8e, 0x6, 0xb2, 0x72, 0x76, 0xde, 0x31, 0x8d, 0xc3, + 0x8f, 0x55, 0x0, 0x2, 0x31, 0x32, 0x0, 0x0, 0x0, 0x2, 0xb5, 0x2f}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x9, 0x86, 0xb2, 0xdb, 0x9f, 0xf9, 0xeb, 0xfa, 0xbb}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x90, 0xbb, 0xf, 0xc8, 0x8e, 0x79, 0x27, 0x4e, 0x29, 0x5e, 0xd6, + 0x15, 0x3f, 0xdb, 0x9e, 0xfe, 0x55, 0xe6, 0x25, 0x64, 0x70, 0xb4}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa6, 0x29, 0xe6, 0xb8, 0x59, 0xfc, 0xd, 0x2e, 0x42}; + uint8_t topic_filter_s1_bytes[] = {0x88, 0x13, 0x6a, 0xb3, 0x27, 0xca, 0xc8, 0xf5, 0x0}; lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xcb, 0x27, 0x55, 0x77, 0x4a, 0x66, 0xc6, 0x90, 0x3d, 0x28, 0x1a, + 0x9, 0x32, 0xef, 0xb, 0x6e, 0x3, 0x2, 0x8f, 0xdf, 0xc6, 0xf7}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xcb, 0xcf, 0x5e, 0x1a, 0xd2, 0x31, 0x8b, + 0xd5, 0x4e, 0xbc, 0xe0, 0xcf, 0xbe, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x17, 0xc9}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x77, 0xe9, 0x6e, 0x6f, 0xaa, 0x85, 0x8d, 0x69, 0x8e, 0x6, + 0xb2, 0x72, 0x76, 0xde, 0x31, 0x8d, 0xc3, 0x8f, 0x55}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x31, 0x32}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xb5, 0x2f}; + lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24597, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 6495, 9, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 17778 -// ["\136x\150\168\US\251\133\245\161\132","","\156","\b\158G{\v-Ms1\169\219\152\168\DC4\152\236\156\169\r -// L{\144]w<\161","^\n\242r\171T8\161Q\v\135\252\STX8r\191\232\164\NUL\USM\199\151|8G\166","y\b\179\128O\138\242\240@2\163\187~\137\EOT\212\&2\EOT\167\\}f\170:\169x\186~","\b4\215\223kA\248\252\v\173\218\f\217.\171O\210\199\&4\ETX\NULk\f7~\151\&5\142\USL","\223\248\DC3<\163N\164?\DC2%\ENQ\251\214\223\&4\239\&13_3\DEL\SYN*c\NUL\ETX","\215\DC1\218\DC1l\160\ESCV@L\v$\203\195","\221M\253c3\176\146Y\151\250\249^YYC\182n`\ENQg\203s\198\249\232"] +// UnsubscribeRequest 21456 +// ["i\172\235\176yA\168\222\209\r","\207\189\131+\244\149$\n\152\138]\252t\DLE\251\212\SUB\188tMDIz\190>\188ZB","#\r\157z\r6\USl\SUB\142\142\217\US\182f\213\161\240","i\167c\137+A\NAKg\221\&0\217\213'\ESC]mc}\222\157\220>","\144\177\&2@\185\r\242\&08N\243\238\144-\SO\146\248e\148\231\FS\196\ETBk\246\248\167\DC2","\129"] // [] TEST(Unsubscribe311QCTest, Encode19) { - uint8_t pkt[] = {0xa2, 0xd2, 0x1, 0x45, 0x72, 0x0, 0xa, 0x88, 0x78, 0x96, 0xa8, 0x1f, 0xfb, 0x85, 0xf5, 0xa1, 0x84, - 0x0, 0x0, 0x0, 0x1, 0x9c, 0x0, 0x1b, 0x8, 0x9e, 0x47, 0x7b, 0xb, 0x2d, 0x4d, 0x73, 0x31, 0xa9, - 0xdb, 0x98, 0xa8, 0x14, 0x98, 0xec, 0x9c, 0xa9, 0xd, 0x20, 0x4c, 0x7b, 0x90, 0x5d, 0x77, 0x3c, 0xa1, - 0x0, 0x1b, 0x5e, 0xa, 0xf2, 0x72, 0xab, 0x54, 0x38, 0xa1, 0x51, 0xb, 0x87, 0xfc,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, 0x1a, 0xbc, 0x74, 0x4d, 0x44, 0x49, 0x7a, 0xbe, 0x3e, 0xbc, 0x5a, 0x42, 0x0, 0x12, + 0x23, 0xd, 0x9d, 0x7a, 0xd, 0x36, 0x1f, 0x6c, 0x1a, 0x8e, 0x8e, 0xd9, 0x1f, 0xb6, 0x66, 0xd5, + 0xa1, 0xf0, 0x0, 0x16, 0x69, 0xa7, 0x63, 0x89, 0x2b, 0x41, 0x15, 0x67, 0xdd, 0x30, 0xd9, 0xd5, + 0x27, 0x1b, 0x5d, 0x6d, 0x63, 0x7d, 0xde, 0x9d, 0xdc, 0x3e, 0x0, 0x1c, 0x90, 0xb1, 0x32, 0x40, + 0xb9, 0xd, 0xf2, 0x30, 0x38, 0x4e, 0xf3, 0xee, 0x90, 0x2d, 0xe, 0x92, 0xf8, 0x65, 0x94, 0xe7, + 0x1c, 0xc4, 0x17, 0x6b, 0xf6, 0xf8, 0xa7, 0x12, 0x0, 0x1, 0x81}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x88, 0x78, 0x96, 0xa8, 0x1f, 0xfb, 0x85, 0xf5, 0xa1, 0x84}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x69, 0xac, 0xeb, 0xb0, 0x79, 0x41, 0xa8, 0xde, 0xd1, 0xd}; lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xcf, 0xbd, 0x83, 0x2b, 0xf4, 0x95, 0x24, 0xa, 0x98, 0x8a, + 0x5d, 0xfc, 0x74, 0x10, 0xfb, 0xd4, 0x1a, 0xbc, 0x74, 0x4d, + 0x44, 0x49, 0x7a, 0xbe, 0x3e, 0xbc, 0x5a, 0x42}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9c}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x23, 0xd, 0x9d, 0x7a, 0xd, 0x36, 0x1f, 0x6c, 0x1a, + 0x8e, 0x8e, 0xd9, 0x1f, 0xb6, 0x66, 0xd5, 0xa1, 0xf0}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8, 0x9e, 0x47, 0x7b, 0xb, 0x2d, 0x4d, 0x73, 0x31, 0xa9, 0xdb, 0x98, 0xa8, 0x14, - 0x98, 0xec, 0x9c, 0xa9, 0xd, 0x20, 0x4c, 0x7b, 0x90, 0x5d, 0x77, 0x3c, 0xa1}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x69, 0xa7, 0x63, 0x89, 0x2b, 0x41, 0x15, 0x67, 0xdd, 0x30, 0xd9, + 0xd5, 0x27, 0x1b, 0x5d, 0x6d, 0x63, 0x7d, 0xde, 0x9d, 0xdc, 0x3e}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5e, 0xa, 0xf2, 0x72, 0xab, 0x54, 0x38, 0xa1, 0x51, 0xb, 0x87, 0xfc, 0x2, 0x38, - 0x72, 0xbf, 0xe8, 0xa4, 0x0, 0x1f, 0x4d, 0xc7, 0x97, 0x7c, 0x38, 0x47, 0xa6}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x90, 0xb1, 0x32, 0x40, 0xb9, 0xd, 0xf2, 0x30, 0x38, 0x4e, + 0xf3, 0xee, 0x90, 0x2d, 0xe, 0x92, 0xf8, 0x65, 0x94, 0xe7, + 0x1c, 0xc4, 0x17, 0x6b, 0xf6, 0xf8, 0xa7, 0x12}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x79, 0x8, 0xb3, 0x80, 0x4f, 0x8a, 0xf2, 0xf0, 0x40, 0x32, - 0xa3, 0xbb, 0x7e, 0x89, 0x4, 0xd4, 0x32, 0x4, 0xa7, 0x5c, - 0x7d, 0x66, 0xaa, 0x3a, 0xa9, 0x78, 0xba, 0x7e}; - lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x81}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8, 0x34, 0xd7, 0xdf, 0x6b, 0x41, 0xf8, 0xfc, 0xb, 0xad, - 0xda, 0xc, 0xd9, 0x2e, 0xab, 0x4f, 0xd2, 0xc7, 0x34, 0x3, - 0x0, 0x6b, 0xc, 0x37, 0x7e, 0x97, 0x35, 0x8e, 0x1f, 0x4c}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xdf, 0xf8, 0x13, 0x3c, 0xa3, 0x4e, 0xa4, 0x3f, 0x12, 0x25, 0x5, 0xfb, 0xd6, - 0xdf, 0x34, 0xef, 0x31, 0x33, 0x5f, 0x33, 0x7f, 0x16, 0x2a, 0x63, 0x0, 0x3}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd7, 0x11, 0xda, 0x11, 0x6c, 0xa0, 0x1b, 0x56, 0x40, 0x4c, 0xb, 0x24, 0xcb, 0xc3}; - lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xdd, 0x4d, 0xfd, 0x63, 0x33, 0xb0, 0x92, 0x59, 0x97, 0xfa, 0xf9, 0x5e, 0x59, - 0x59, 0x43, 0xb6, 0x6e, 0x60, 0x5, 0x67, 0xcb, 0x73, 0xc6, 0xf9, 0xe8}; - lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 17778, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 21456, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 4976 -// ["_\190\245~5\207\156\SOHtV\FSY\253Gq\220\&8R\"\148","\CAN\141\210\134\ETBEiWm\158\t}\150O\175\CANHzh\157]q\173BuK\182p","\SUB\156\FS\ENQo#V\174\SYN\EM\150\161\a\231S\236\217\251\185\142\186\216\132\DC1I\"\172=5","\200d\202\182\185\147","\196\172'","kx\GS\134,&\222\152\&0\US\188\202zs\141g\170\174\164\SUB\246\184Wd\135\237","\254\207M\NAK\202g\EOT\135\186\213.\229\222\152","=\137\241~\EOTl","&\"","6\239R\208\161@\FS\US\250\170`\SUB\155{"] -// [] +// UnsubscribeRequest 1638 +// ["I\172\254l\194\132\150\DC1\CAN\173\152\&6ms\215\182\145~\176\NAK(\255p\163\238G\163\DC4\164"] [] TEST(Unsubscribe311QCTest, Encode20) { - uint8_t pkt[] = {0xa2, 0xaa, 0x1, 0x13, 0x70, 0x0, 0x14, 0x5f, 0xbe, 0xf5, 0x7e, 0x35, 0xcf, 0x9c, 0x1, 0x74, - 0x56, 0x1c, 0x59, 0xfd, 0x47, 0x71, 0xdc, 0x38, 0x52, 0x22, 0x94, 0x0, 0x1c, 0x18, 0x8d, 0xd2, - 0x86, 0x17, 0x45, 0x69, 0x57, 0x6d, 0x9e, 0x9, 0x7d, 0x96, 0x4f, 0xaf, 0x18, 0x48, 0x7a, 0x68, - 0x9d, 0x5d, 0x71, 0xad, 0x42, 0x75, 0x4b, 0xb6, 0x70, 0x0, 0x1d, 0x1a, 0x9c, 0x1c, 0x5, 0x6f, - 0x23, 0x56, 0xae, 0x16, 0x19, 0x96, 0xa1, 0x7, 0xe7, 0x53, 0xec, 0xd9, 0xfb, 0xb9, 0x8e, 0xba, - 0xd8, 0x84, 0x11, 0x49, 0x22, 0xac, 0x3d, 0x35, 0x0, 0x6, 0xc8, 0x64, 0xca, 0xb6, 0xb9, 0x93, - 0x0, 0x3, 0xc4, 0xac, 0x27, 0x0, 0x1a, 0x6b, 0x78, 0x1d, 0x86, 0x2c, 0x26, 0xde, 0x98, 0x30, - 0x1f, 0xbc, 0xca, 0x7a, 0x73, 0x8d, 0x67, 0xaa, 0xae, 0xa4, 0x1a, 0xf6, 0xb8, 0x57, 0x64, 0x87, - 0xed, 0x0, 0xe, 0xfe, 0xcf, 0x4d, 0x15, 0xca, 0x67, 0x4, 0x87, 0xba, 0xd5, 0x2e, 0xe5, 0xde, - 0x98, 0x0, 0x6, 0x3d, 0x89, 0xf1, 0x7e, 0x4, 0x6c, 0x0, 0x2, 0x26, 0x22, 0x0, 0xe, 0x36, - 0xef, 0x52, 0xd0, 0xa1, 0x40, 0x1c, 0x1f, 0xfa, 0xaa, 0x60, 0x1a, 0x9b, 0x7b}; + uint8_t pkt[] = {0xa2, 0x21, 0x6, 0x66, 0x0, 0x1d, 0x49, 0xac, 0xfe, 0x6c, 0xc2, 0x84, + 0x96, 0x11, 0x18, 0xad, 0x98, 0x36, 0x6d, 0x73, 0xd7, 0xb6, 0x91, 0x7e, + 0xb0, 0x15, 0x28, 0xff, 0x70, 0xa3, 0xee, 0x47, 0xa3, 0x14, 0xa4}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x5f, 0xbe, 0xf5, 0x7e, 0x35, 0xcf, 0x9c, 0x1, 0x74, 0x56, - 0x1c, 0x59, 0xfd, 0x47, 0x71, 0xdc, 0x38, 0x52, 0x22, 0x94}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x49, 0xac, 0xfe, 0x6c, 0xc2, 0x84, 0x96, 0x11, 0x18, 0xad, + 0x98, 0x36, 0x6d, 0x73, 0xd7, 0xb6, 0x91, 0x7e, 0xb0, 0x15, + 0x28, 0xff, 0x70, 0xa3, 0xee, 0x47, 0xa3, 0x14, 0xa4}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x18, 0x8d, 0xd2, 0x86, 0x17, 0x45, 0x69, 0x57, 0x6d, 0x9e, - 0x9, 0x7d, 0x96, 0x4f, 0xaf, 0x18, 0x48, 0x7a, 0x68, 0x9d, - 0x5d, 0x71, 0xad, 0x42, 0x75, 0x4b, 0xb6, 0x70}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1a, 0x9c, 0x1c, 0x5, 0x6f, 0x23, 0x56, 0xae, 0x16, 0x19, - 0x96, 0xa1, 0x7, 0xe7, 0x53, 0xec, 0xd9, 0xfb, 0xb9, 0x8e, - 0xba, 0xd8, 0x84, 0x11, 0x49, 0x22, 0xac, 0x3d, 0x35}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc8, 0x64, 0xca, 0xb6, 0xb9, 0x93}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc4, 0xac, 0x27}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6b, 0x78, 0x1d, 0x86, 0x2c, 0x26, 0xde, 0x98, 0x30, 0x1f, 0xbc, 0xca, 0x7a, - 0x73, 0x8d, 0x67, 0xaa, 0xae, 0xa4, 0x1a, 0xf6, 0xb8, 0x57, 0x64, 0x87, 0xed}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xfe, 0xcf, 0x4d, 0x15, 0xca, 0x67, 0x4, 0x87, 0xba, 0xd5, 0x2e, 0xe5, 0xde, 0x98}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x3d, 0x89, 0xf1, 0x7e, 0x4, 0x6c}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x26, 0x22}; - lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x36, 0xef, 0x52, 0xd0, 0xa1, 0x40, 0x1c, - 0x1f, 0xfa, 0xaa, 0x60, 0x1a, 0x9b, 0x7b}; - lwmqtt_string_t topic_filter_s9 = {14, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4976, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 1638, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 12973 -// ["\DC1As\216\DLE\214\246\194\220\178\DC3\NULON\198\226\147P\205\SO\129\&4\RS\DC3\206","\171\&0\204\160\CAN.\142\255 -// \134\198\220\DEL@\163\216\&2\165\142\225\208","^\163\204\213TZ\"\SO","\136!\167=\170\214\"\232\ESC -// \216\174%\ENQ]\219\133}\226\235","J\182\bT\140Z","\188n\150\191L#\NAK\197\136\194[\192m\141\196\n\211\252","\195\157\173\ACKh\DEL\178\230\r","e(y\DC3\r|+\138\216\196*\227~\180\140DX\250\181\135#\214#;!\225\161\201","1\252\225\175\STX\172\236\SYN\176\&2\"\204\v\RS\b\189","\218\181\178\245x\187\245\167\&5\144\249L:\209\146"] +// UnsubscribeRequest 30931 +// ["\242\153y5V\186\NUL\184\153\206\140\ESC\128Z","\217J\203\FS\129\209\190\129\183\211N\167\STX\EOT\145\216\246\204\195\208","\228e\179_t\DC2\ETX\208\189\199\&7!\150\135\155{\150.4Y","T\229\NAK]\171\166\141\193*\174\ESC\ESC?\198\242\\G\242\209\NULRL\DEL\EM","\227\251","","\247\227>\DC1?\SIm\254f\225","R\194\196\DEL\217j\241\169\&6f\155"] // [] TEST(Unsubscribe311QCTest, Encode21) { - uint8_t pkt[] = {0xa2, 0xbc, 0x1, 0x32, 0xad, 0x0, 0x19, 0x11, 0x41, 0x73, 0xd8, 0x10, 0xd6, 0xf6, 0xc2, 0xdc, - 0xb2, 0x13, 0x0, 0x4f, 0x4e, 0xc6, 0xe2, 0x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0x99, 0xce, + 0x8c, 0x1b, 0x80, 0x5a, 0x0, 0x14, 0xd9, 0x4a, 0xcb, 0x1c, 0x81, 0xd1, 0xbe, 0x81, 0xb7, 0xd3, + 0x4e, 0xa7, 0x2, 0x4, 0x91, 0xd8, 0xf6, 0xcc, 0xc3, 0xd0, 0x0, 0x14, 0xe4, 0x65, 0xb3, 0x5f, + 0x74, 0x12, 0x3, 0xd0, 0xbd, 0xc7, 0x37, 0x21, 0x96, 0x87, 0x9b, 0x7b, 0x96, 0x2e, 0x34, 0x59, + 0x0, 0x18, 0x54, 0xe5, 0x15, 0x5d, 0xab, 0xa6, 0x8d, 0xc1, 0x2a, 0xae, 0x1b, 0x1b, 0x3f, 0xc6, + 0xf2, 0x5c, 0x47, 0xf2, 0xd1, 0x0, 0x52, 0x4c, 0x7f, 0x19, 0x0, 0x2, 0xe3, 0xfb, 0x0, 0x0, + 0x0, 0xa, 0xf7, 0xe3, 0x3e, 0x11, 0x3f, 0xf, 0x6d, 0xfe, 0x66, 0xe1, 0x0, 0xb, 0x52, 0xc2, + 0xc4, 0x7f, 0xd9, 0x6a, 0xf1, 0xa9, 0x36, 0x66, 0x9b}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x11, 0x41, 0x73, 0xd8, 0x10, 0xd6, 0xf6, 0xc2, 0xdc, 0xb2, 0x13, 0x0, 0x4f, - 0x4e, 0xc6, 0xe2, 0x93, 0x50, 0xcd, 0xe, 0x81, 0x34, 0x1e, 0x13, 0xce}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xf2, 0x99, 0x79, 0x35, 0x56, 0xba, 0x0, 0xb8, 0x99, 0xce, 0x8c, 0x1b, 0x80, 0x5a}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xab, 0x30, 0xcc, 0xa0, 0x18, 0x2e, 0x8e, 0xff, 0x20, 0x86, 0xc6, - 0xdc, 0x7f, 0x40, 0xa3, 0xd8, 0x32, 0xa5, 0x8e, 0xe1, 0xd0}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd9, 0x4a, 0xcb, 0x1c, 0x81, 0xd1, 0xbe, 0x81, 0xb7, 0xd3, + 0x4e, 0xa7, 0x2, 0x4, 0x91, 0xd8, 0xf6, 0xcc, 0xc3, 0xd0}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5e, 0xa3, 0xcc, 0xd5, 0x54, 0x5a, 0x22, 0xe}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe4, 0x65, 0xb3, 0x5f, 0x74, 0x12, 0x3, 0xd0, 0xbd, 0xc7, + 0x37, 0x21, 0x96, 0x87, 0x9b, 0x7b, 0x96, 0x2e, 0x34, 0x59}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x88, 0x21, 0xa7, 0x3d, 0xaa, 0xd6, 0x22, 0xe8, 0x1b, 0x20, - 0xd8, 0xae, 0x25, 0x5, 0x5d, 0xdb, 0x85, 0x7d, 0xe2, 0xeb}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x54, 0xe5, 0x15, 0x5d, 0xab, 0xa6, 0x8d, 0xc1, 0x2a, 0xae, 0x1b, 0x1b, + 0x3f, 0xc6, 0xf2, 0x5c, 0x47, 0xf2, 0xd1, 0x0, 0x52, 0x4c, 0x7f, 0x19}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4a, 0xb6, 0x8, 0x54, 0x8c, 0x5a}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xe3, 0xfb}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xbc, 0x6e, 0x96, 0xbf, 0x4c, 0x23, 0x15, 0xc5, 0x88, - 0xc2, 0x5b, 0xc0, 0x6d, 0x8d, 0xc4, 0xa, 0xd3, 0xfc}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc3, 0x9d, 0xad, 0x6, 0x68, 0x7f, 0xb2, 0xe6, 0xd}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xf7, 0xe3, 0x3e, 0x11, 0x3f, 0xf, 0x6d, 0xfe, 0x66, 0xe1}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x65, 0x28, 0x79, 0x13, 0xd, 0x7c, 0x2b, 0x8a, 0xd8, 0xc4, - 0x2a, 0xe3, 0x7e, 0xb4, 0x8c, 0x44, 0x58, 0xfa, 0xb5, 0x87, - 0x23, 0xd6, 0x23, 0x3b, 0x21, 0xe1, 0xa1, 0xc9}; - lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x52, 0xc2, 0xc4, 0x7f, 0xd9, 0x6a, 0xf1, 0xa9, 0x36, 0x66, 0x9b}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x31, 0xfc, 0xe1, 0xaf, 0x2, 0xac, 0xec, 0x16, - 0xb0, 0x32, 0x22, 0xcc, 0xb, 0x1e, 0x8, 0xbd}; - lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xda, 0xb5, 0xb2, 0xf5, 0x78, 0xbb, 0xf5, 0xa7, - 0x35, 0x90, 0xf9, 0x4c, 0x3a, 0xd1, 0x92}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 12973, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 30931, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 26764 -// ["\228\129\194\154UZ\162#\ENQ\166y\194\131\134\146\CAN\249\179\195=\\H\131_\195\ACK","\157>\170,\252e\253\207?\202o\189\&8\149\170\251\138\173}\GS\224\ACK\181\156","\139O+\138\ESC$!\248\160\249K\171\161\214,l\r\191X\ETB*\160\246\a/","","\139\149j\246C\170\168\SI\n\151\SOH\219\243\RS\222\206k\199\ESC\SUB\DC2x(5:!D","\245x0\213\130\200\229\176\SUB$\SOH\ENQ\243\153\147\242\157\219\190","jv\130p\n\255\130\158\213\218O\SYN\194W\191\188","\210\132\229-R&\239\246\ESCe\194\US.\222\DC2&\135$\210YE\129","hM{7","\206N\242@%2\218\216\138\232\155\156\n\US\248z@\207\SYN\211\221\&8\164\239\155"] +// UnsubscribeRequest 14609 +// ["\STX\186","\216\232'\187\247AC\149\141\&7(\219\ACK\245V\NUL\176q\225","\146\EOTs\135\223\183f\130\217i\200\252%\195\232L\233\STX\202\249\219'#\145\182\197","0]\240\US\255\201i\203.]|\DC3\173e\v","\174!\202\147\162\ESC\200\211\216\194WF\212N{'!^~2\ACKQ\157j\228\244","\163x\"\164\183\175$]\242\129\245'\164\\E","*W\240\217\DC1%D\193S\240\168\186\147\190\153$\f\213\182De\167\239\156\227"] // [] TEST(Unsubscribe311QCTest, Encode22) { - uint8_t pkt[] = {0xa2, 0xd2, 0x1, 0x68, 0x8c, 0x0, 0x1a, 0xe4, 0x81, 0xc2, 0x9a, 0x55, 0x5a, 0xa2, 0x23, 0x5, 0xa6, - 0x79, 0xc2, 0x83, 0x86, 0x92, 0x18, 0xf9, 0xb3, 0xc3, 0x3d, 0x5c, 0x48, 0x83, 0x5f, 0xc3, 0x6, 0x0, - 0x18, 0x9d, 0x3e, 0xaa, 0x2c, 0xfc, 0x65, 0xfd, 0xcf, 0x3f, 0xca, 0x6f, 0xbd, 0x38, 0x95, 0xaa, 0xfb, - 0x8a, 0xad, 0x7d, 0x1d, 0xe0, 0x6, 0xb5, 0x9c, 0x0, 0x19, 0x8b, 0x4f, 0x2b, 0x8a, 0x1b, 0x24, 0x21, - 0xf8, 0xa0, 0xf9, 0x4b, 0xab, 0xa1, 0xd6, 0x2c, 0x6c, 0xd, 0xbf, 0x58, 0x17, 0x2a, 0xa0, 0xf6, 0x7, - 0x2f, 0x0, 0x0, 0x0, 0x1b, 0x8b, 0x95, 0x6a, 0xf6, 0x43, 0xaa, 0xa8, 0xf, 0xa, 0x97, 0x1, 0xdb, - 0xf3, 0x1e, 0xde, 0xce, 0x6b, 0xc7, 0x1b, 0x1a, 0x12, 0x78, 0x28, 0x35, 0x3a, 0x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0xc2, 0x57, 0x46, 0xd4, 0x4e, 0x7b, 0x27, 0x21, 0x5e, 0x7e, 0x32, 0x6, 0x51, 0x9d, 0x6a, 0xe4, + 0xf4, 0x0, 0xf, 0xa3, 0x78, 0x22, 0xa4, 0xb7, 0xaf, 0x24, 0x5d, 0xf2, 0x81, 0xf5, 0x27, 0xa4, 0x5c, + 0x45, 0x0, 0x19, 0x2a, 0x57, 0xf0, 0xd9, 0x11, 0x25, 0x44, 0xc1, 0x53, 0xf0, 0xa8, 0xba, 0x93, 0xbe, + 0x99, 0x24, 0xc, 0xd5, 0xb6, 0x44, 0x65, 0xa7, 0xef, 0x9c, 0xe3}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xe4, 0x81, 0xc2, 0x9a, 0x55, 0x5a, 0xa2, 0x23, 0x5, 0xa6, 0x79, 0xc2, 0x83, - 0x86, 0x92, 0x18, 0xf9, 0xb3, 0xc3, 0x3d, 0x5c, 0x48, 0x83, 0x5f, 0xc3, 0x6}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x2, 0xba}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9d, 0x3e, 0xaa, 0x2c, 0xfc, 0x65, 0xfd, 0xcf, 0x3f, 0xca, 0x6f, 0xbd, - 0x38, 0x95, 0xaa, 0xfb, 0x8a, 0xad, 0x7d, 0x1d, 0xe0, 0x6, 0xb5, 0x9c}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd8, 0xe8, 0x27, 0xbb, 0xf7, 0x41, 0x43, 0x95, 0x8d, 0x37, + 0x28, 0xdb, 0x6, 0xf5, 0x56, 0x0, 0xb0, 0x71, 0xe1}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8b, 0x4f, 0x2b, 0x8a, 0x1b, 0x24, 0x21, 0xf8, 0xa0, 0xf9, 0x4b, 0xab, 0xa1, - 0xd6, 0x2c, 0x6c, 0xd, 0xbf, 0x58, 0x17, 0x2a, 0xa0, 0xf6, 0x7, 0x2f}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x92, 0x4, 0x73, 0x87, 0xdf, 0xb7, 0x66, 0x82, 0xd9, 0x69, 0xc8, 0xfc, 0x25, + 0xc3, 0xe8, 0x4c, 0xe9, 0x2, 0xca, 0xf9, 0xdb, 0x27, 0x23, 0x91, 0xb6, 0xc5}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x30, 0x5d, 0xf0, 0x1f, 0xff, 0xc9, 0x69, 0xcb, + 0x2e, 0x5d, 0x7c, 0x13, 0xad, 0x65, 0xb}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8b, 0x95, 0x6a, 0xf6, 0x43, 0xaa, 0xa8, 0xf, 0xa, 0x97, 0x1, 0xdb, 0xf3, 0x1e, - 0xde, 0xce, 0x6b, 0xc7, 0x1b, 0x1a, 0x12, 0x78, 0x28, 0x35, 0x3a, 0x21, 0x44}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xae, 0x21, 0xca, 0x93, 0xa2, 0x1b, 0xc8, 0xd3, 0xd8, 0xc2, 0x57, 0x46, 0xd4, + 0x4e, 0x7b, 0x27, 0x21, 0x5e, 0x7e, 0x32, 0x6, 0x51, 0x9d, 0x6a, 0xe4, 0xf4}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf5, 0x78, 0x30, 0xd5, 0x82, 0xc8, 0xe5, 0xb0, 0x1a, 0x24, - 0x1, 0x5, 0xf3, 0x99, 0x93, 0xf2, 0x9d, 0xdb, 0xbe}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xa3, 0x78, 0x22, 0xa4, 0xb7, 0xaf, 0x24, 0x5d, + 0xf2, 0x81, 0xf5, 0x27, 0xa4, 0x5c, 0x45}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6a, 0x76, 0x82, 0x70, 0xa, 0xff, 0x82, 0x9e, - 0xd5, 0xda, 0x4f, 0x16, 0xc2, 0x57, 0xbf, 0xbc}; - lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x2a, 0x57, 0xf0, 0xd9, 0x11, 0x25, 0x44, 0xc1, 0x53, 0xf0, 0xa8, 0xba, 0x93, + 0xbe, 0x99, 0x24, 0xc, 0xd5, 0xb6, 0x44, 0x65, 0xa7, 0xef, 0x9c, 0xe3}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xd2, 0x84, 0xe5, 0x2d, 0x52, 0x26, 0xef, 0xf6, 0x1b, 0x65, 0xc2, - 0x1f, 0x2e, 0xde, 0x12, 0x26, 0x87, 0x24, 0xd2, 0x59, 0x45, 0x81}; - lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x68, 0x4d, 0x7b, 0x37}; - lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xce, 0x4e, 0xf2, 0x40, 0x25, 0x32, 0xda, 0xd8, 0x8a, 0xe8, 0x9b, 0x9c, 0xa, - 0x1f, 0xf8, 0x7a, 0x40, 0xcf, 0x16, 0xd3, 0xdd, 0x38, 0xa4, 0xef, 0x9b}; - lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 26764, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14609, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 25855 -// ["*\148\DEL\172\179\158\a\ETX\SONJH`\204\245\213\178\t","","\132\212~\"a\157\185J\138:\200\142","\137\206\187\149\181\150l\210\253\178V\167\ESC\239@\GSD\231\139","\219\198\215\184]\249\ESC\146\186\ETB","K\140\254\EOT`\134\206\GS\195\219e\213\200\SIDy\239 -// \164","\164\146\155I\172w\DC3b\DC4qa","1k\NAK\130\DLE\202\GS\191\239B\tL\162z\ETX\213l\194\143\&6\SYN\152/\154\219e\NAKi","\247k3\164\228?\NUL\158\201\136y\202\169\202"] -// [] +// UnsubscribeRequest 4540 +// ["","","\222\229\236","\133\214\163","F\186I\201-\n\246\DC2\234\245\156l\132o\252[\142t\210o\NAK\221\&6F\150\241","\241\183\179\&7\145]\130\189/",",P\144\130\178\b\202\SYNe\145\240 +// f\158\&2\CAN","\234c\GS\SIR\185\&75\159"] [] TEST(Unsubscribe311QCTest, Encode23) { - uint8_t pkt[] = {0xa2, 0x97, 0x1, 0x64, 0xff, 0x0, 0x12, 0x2a, 0x94, 0x7f, 0xac, 0xb3, 0x9e, 0x7, 0x3, 0xe, - 0x4e, 0x4a, 0x48, 0x60, 0xcc, 0xf5, 0xd5, 0xb2, 0x9, 0x0, 0x0, 0x0, 0xc, 0x84, 0xd4, 0x7e, - 0x22, 0x61, 0x9d, 0xb9, 0x4a, 0x8a, 0x3a, 0xc8, 0x8e, 0x0, 0x13, 0x89, 0xce, 0xbb, 0x95, 0xb5, - 0x96, 0x6c, 0xd2, 0xfd, 0xb2, 0x56, 0xa7, 0x1b, 0xef, 0x40, 0x1d, 0x44, 0xe7, 0x8b, 0x0, 0xa, - 0xdb, 0xc6, 0xd7, 0xb8, 0x5d, 0xf9, 0x1b, 0x92, 0xba, 0x17, 0x0, 0x13, 0x4b, 0x8c, 0xfe, 0x4, - 0x60, 0x86, 0xce, 0x1d, 0xc3, 0xdb, 0x65, 0xd5, 0xc8, 0xf, 0x44, 0x79, 0xef, 0x20, 0xa4, 0x0, - 0xb, 0xa4, 0x92, 0x9b, 0x49, 0xac, 0x77, 0x13, 0x62, 0x14, 0x71, 0x61, 0x0, 0x1c, 0x31, 0x6b, - 0x15, 0x82, 0x10, 0xca, 0x1d, 0xbf, 0xef, 0x42, 0x9, 0x4c, 0xa2, 0x7a, 0x3, 0xd5, 0x6c, 0xc2, - 0x8f, 0x36, 0x16, 0x98, 0x2f, 0x9a, 0xdb, 0x65, 0x15, 0x69, 0x0, 0xe, 0xf7, 0x6b, 0x33, 0xa4, - 0xe4, 0x3f, 0x0, 0x9e, 0xc9, 0x88, 0x79, 0xca, 0xa9, 0xca}; + uint8_t pkt[] = {0xa2, 0x54, 0x11, 0xbc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xde, 0xe5, 0xec, 0x0, 0x3, + 0x85, 0xd6, 0xa3, 0x0, 0x1a, 0x46, 0xba, 0x49, 0xc9, 0x2d, 0xa, 0xf6, 0x12, 0xea, 0xf5, + 0x9c, 0x6c, 0x84, 0x6f, 0xfc, 0x5b, 0x8e, 0x74, 0xd2, 0x6f, 0x15, 0xdd, 0x36, 0x46, 0x96, + 0xf1, 0x0, 0x9, 0xf1, 0xb7, 0xb3, 0x37, 0x91, 0x5d, 0x82, 0xbd, 0x2f, 0x0, 0x10, 0x2c, + 0x50, 0x90, 0x82, 0xb2, 0x8, 0xca, 0x16, 0x65, 0x91, 0xf0, 0x20, 0x66, 0x9e, 0x32, 0x18, + 0x0, 0x9, 0xea, 0x63, 0x1d, 0xf, 0x52, 0xb9, 0x37, 0x35, 0x9f}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x2a, 0x94, 0x7f, 0xac, 0xb3, 0x9e, 0x7, 0x3, 0xe, - 0x4e, 0x4a, 0x48, 0x60, 0xcc, 0xf5, 0xd5, 0xb2, 0x9}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; uint8_t topic_filter_s1_bytes[] = {0}; lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x84, 0xd4, 0x7e, 0x22, 0x61, 0x9d, 0xb9, 0x4a, 0x8a, 0x3a, 0xc8, 0x8e}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xde, 0xe5, 0xec}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x89, 0xce, 0xbb, 0x95, 0xb5, 0x96, 0x6c, 0xd2, 0xfd, 0xb2, - 0x56, 0xa7, 0x1b, 0xef, 0x40, 0x1d, 0x44, 0xe7, 0x8b}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x85, 0xd6, 0xa3}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xdb, 0xc6, 0xd7, 0xb8, 0x5d, 0xf9, 0x1b, 0x92, 0xba, 0x17}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x46, 0xba, 0x49, 0xc9, 0x2d, 0xa, 0xf6, 0x12, 0xea, 0xf5, 0x9c, 0x6c, 0x84, + 0x6f, 0xfc, 0x5b, 0x8e, 0x74, 0xd2, 0x6f, 0x15, 0xdd, 0x36, 0x46, 0x96, 0xf1}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4b, 0x8c, 0xfe, 0x4, 0x60, 0x86, 0xce, 0x1d, 0xc3, 0xdb, - 0x65, 0xd5, 0xc8, 0xf, 0x44, 0x79, 0xef, 0x20, 0xa4}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf1, 0xb7, 0xb3, 0x37, 0x91, 0x5d, 0x82, 0xbd, 0x2f}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa4, 0x92, 0x9b, 0x49, 0xac, 0x77, 0x13, 0x62, 0x14, 0x71, 0x61}; - lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x2c, 0x50, 0x90, 0x82, 0xb2, 0x8, 0xca, 0x16, + 0x65, 0x91, 0xf0, 0x20, 0x66, 0x9e, 0x32, 0x18}; + lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x31, 0x6b, 0x15, 0x82, 0x10, 0xca, 0x1d, 0xbf, 0xef, 0x42, - 0x9, 0x4c, 0xa2, 0x7a, 0x3, 0xd5, 0x6c, 0xc2, 0x8f, 0x36, - 0x16, 0x98, 0x2f, 0x9a, 0xdb, 0x65, 0x15, 0x69}; - lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xea, 0x63, 0x1d, 0xf, 0x52, 0xb9, 0x37, 0x35, 0x9f}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xf7, 0x6b, 0x33, 0xa4, 0xe4, 0x3f, 0x0, 0x9e, 0xc9, 0x88, 0x79, 0xca, 0xa9, 0xca}; - lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 25855, 9, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 4540, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 20087 ["","\223$\157\133\154\STXu\172d\221\239W\239\v\142#\151b"] [] +// UnsubscribeRequest 16569 +// ["","\170&\222\191\190a\189\220\226\176\DC1|\130\NAK\210\227\141\218\168\DEL\160\156\202\131\134\164"] [] TEST(Unsubscribe311QCTest, Encode24) { - uint8_t pkt[] = {0xa2, 0x18, 0x4e, 0x77, 0x0, 0x0, 0x0, 0x12, 0xdf, 0x24, 0x9d, 0x85, 0x9a, - 0x2, 0x75, 0xac, 0x64, 0xdd, 0xef, 0x57, 0xef, 0xb, 0x8e, 0x23, 0x97, 0x62}; + uint8_t pkt[] = {0xa2, 0x20, 0x40, 0xb9, 0x0, 0x0, 0x0, 0x1a, 0xaa, 0x26, 0xde, 0xbf, + 0xbe, 0x61, 0xbd, 0xdc, 0xe2, 0xb0, 0x11, 0x7c, 0x82, 0x15, 0xd2, 0xe3, + 0x8d, 0xda, 0xa8, 0x7f, 0xa0, 0x9c, 0xca, 0x83, 0x86, 0xa4}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; @@ -22789,4596 +21581,4406 @@ TEST(Unsubscribe311QCTest, Encode24) { uint8_t topic_filter_s0_bytes[] = {0}; lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xdf, 0x24, 0x9d, 0x85, 0x9a, 0x2, 0x75, 0xac, 0x64, - 0xdd, 0xef, 0x57, 0xef, 0xb, 0x8e, 0x23, 0x97, 0x62}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xaa, 0x26, 0xde, 0xbf, 0xbe, 0x61, 0xbd, 0xdc, 0xe2, 0xb0, 0x11, 0x7c, 0x82, + 0x15, 0xd2, 0xe3, 0x8d, 0xda, 0xa8, 0x7f, 0xa0, 0x9c, 0xca, 0x83, 0x86, 0xa4}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 20087, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 16569, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 23904 -// ["\149\138G<\153B","\176\152\174\227C\212\140\237\176F\225\157","\250\193{\220\129\129\245u\242\229\214\GS\252\173y\184p\165*\244}\215","\ESCB3C\185\170*\235\146\140H11H\198\156\223\DEL\131\144\131\136\224s\209k\b\195\FS"] +// UnsubscribeRequest 14606 +// [".\DEL\196I\165\SIb1R\244ju\238\DC1\166","3\222\158W\247\213i\STXa","j.\\","G\168\128\184kL\181\SOH2J!\DC4F\DEL\198N+2z\nU\DC4\140.\154\222\SI\137\237","K\213\&7"] // [] TEST(Unsubscribe311QCTest, Encode25) { - uint8_t pkt[] = {0xa2, 0x4f, 0x5d, 0x60, 0x0, 0x6, 0x95, 0x8a, 0x47, 0x3c, 0x99, 0x42, 0x0, 0xc, 0xb0, 0x98, 0xae, - 0xe3, 0x43, 0xd4, 0x8c, 0xed, 0xb0, 0x46, 0xe1, 0x9d, 0x0, 0x16, 0xfa, 0xc1, 0x7b, 0xdc, 0x81, 0x81, - 0xf5, 0x75, 0xf2, 0xe5, 0xd6, 0x1d, 0xfc, 0xad, 0x79, 0xb8, 0x70, 0xa5, 0x2a, 0xf4, 0x7d, 0xd7, 0x0, - 0x1d, 0x1b, 0x42, 0x33, 0x43, 0xb9, 0xaa, 0x2a, 0xeb, 0x92, 0x8c, 0x48, 0x31, 0x31, 0x48, 0xc6, 0x9c, - 0xdf, 0x7f, 0x83, 0x90, 0x83, 0x88, 0xe0, 0x73, 0xd1, 0x6b, 0x8, 0xc3, 0x1c}; + uint8_t pkt[] = {0xa2, 0x47, 0x39, 0xe, 0x0, 0xf, 0x2e, 0x7f, 0xc4, 0x49, 0xa5, 0xf, 0x62, 0x31, 0x52, + 0xf4, 0x6a, 0x75, 0xee, 0x11, 0xa6, 0x0, 0x9, 0x33, 0xde, 0x9e, 0x57, 0xf7, 0xd5, 0x69, + 0x2, 0x61, 0x0, 0x3, 0x6a, 0x2e, 0x5c, 0x0, 0x1d, 0x47, 0xa8, 0x80, 0xb8, 0x6b, 0x4c, + 0xb5, 0x1, 0x32, 0x4a, 0x21, 0x14, 0x46, 0x7f, 0xc6, 0x4e, 0x2b, 0x32, 0x7a, 0xa, 0x55, + 0x14, 0x8c, 0x2e, 0x9a, 0xde, 0xf, 0x89, 0xed, 0x0, 0x3, 0x4b, 0xd5, 0x37}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x95, 0x8a, 0x47, 0x3c, 0x99, 0x42}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x2e, 0x7f, 0xc4, 0x49, 0xa5, 0xf, 0x62, 0x31, + 0x52, 0xf4, 0x6a, 0x75, 0xee, 0x11, 0xa6}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb0, 0x98, 0xae, 0xe3, 0x43, 0xd4, 0x8c, 0xed, 0xb0, 0x46, 0xe1, 0x9d}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x33, 0xde, 0x9e, 0x57, 0xf7, 0xd5, 0x69, 0x2, 0x61}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfa, 0xc1, 0x7b, 0xdc, 0x81, 0x81, 0xf5, 0x75, 0xf2, 0xe5, 0xd6, - 0x1d, 0xfc, 0xad, 0x79, 0xb8, 0x70, 0xa5, 0x2a, 0xf4, 0x7d, 0xd7}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6a, 0x2e, 0x5c}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1b, 0x42, 0x33, 0x43, 0xb9, 0xaa, 0x2a, 0xeb, 0x92, 0x8c, - 0x48, 0x31, 0x31, 0x48, 0xc6, 0x9c, 0xdf, 0x7f, 0x83, 0x90, - 0x83, 0x88, 0xe0, 0x73, 0xd1, 0x6b, 0x8, 0xc3, 0x1c}; + uint8_t topic_filter_s3_bytes[] = {0x47, 0xa8, 0x80, 0xb8, 0x6b, 0x4c, 0xb5, 0x1, 0x32, 0x4a, + 0x21, 0x14, 0x46, 0x7f, 0xc6, 0x4e, 0x2b, 0x32, 0x7a, 0xa, + 0x55, 0x14, 0x8c, 0x2e, 0x9a, 0xde, 0xf, 0x89, 0xed}; lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x4b, 0xd5, 0x37}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 23904, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14606, 5, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 18211 ["RU\203\SOH\227Nbl11R~\206d\203\245\&9b\205\253","`\149\SUB<\b\128\137\250\185\176\EM\204"] +// UnsubscribeRequest 14000 +// ["","l\209\US\STX\SId","\186\198#\203t@D","\179\177g\225l","y\192\ESC\206\153\GSTVb\180\254\139\221\&7\255\219\208\234\DC3\240\137\202tp\SYN\158\149","}\b\152\173Sm\225\172\173{#\199\150N\170\136\217S\229\&7\250\155\168\180\134\181","\133q","\216\211GO\136w\142\SI","\135\212\152\253\ETX\232\227\216\DLE\245\131QC-\ETB2&\237I\219{\132\&20|A\148","&\227\176:l([\140;\250\179\157\b\166\137\242\231\EOTw\164\139","\204Q\203\251\SOHMX\193$\139\&12\178y\195V{\206q\FScT"] // [] TEST(Unsubscribe311QCTest, Encode27) { - uint8_t pkt[] = {0xa2, 0x92, 0x1, 0x37, 0x91, 0x0, 0x17, 0x77, 0x39, 0x41, 0xa, 0x3d, 0xc, 0xef, 0x50, 0xf8, 0x69, - 0x6f, 0x6d, 0x56, 0xf6, 0xe6, 0xdb, 0xc, 0xea, 0x69, 0xf5, 0x2c, 0x88, 0x65, 0x0, 0x16, 0xc8, 0x30, - 0x26, 0x56, 0x83, 0x19, 0x25, 0xb0, 0xaa, 0x52, 0xd1, 0xa6, 0x5e, 0x3c, 0xaa, 0xc8, 0xdc, 0x66, 0xde, - 0x7, 0x1c, 0x44, 0x0, 0x7, 0x2e, 0x32, 0x5e, 0x2e, 0xf2, 0xd, 0xc6, 0x0, 0x1e, 0xd, 0xe5, 0xa6, - 0xbb, 0x66, 0xf4, 0xbc, 0x25, 0x97, 0xd5, 0x57, 0xc6, 0x96, 0x7, 0xc, 0xc9, 0xf5, 0x79, 0x48, 0xc1, - 0x89, 0x26, 0x39, 0xf6, 0xd1, 0x4b, 0x61, 0x94, 0x8c, 0x1e, 0x0, 0x18, 0x1e, 0x43, 0x62, 0x2f, 0x62, - 0x8f, 0x97, 0xac, 0x2, 0x4c, 0xa7, 0x81, 0xba, 0x8e,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x2, 0x85, 0x71, 0x0, 0x8, 0xd8, 0xd3, 0x47, 0x4f, + 0x88, 0x77, 0x8e, 0xf, 0x0, 0x1b, 0x87, 0xd4, 0x98, 0xfd, 0x3, 0xe8, 0xe3, 0xd8, 0x10, 0xf5, 0x83, + 0x51, 0x43, 0x2d, 0x17, 0x32, 0x26, 0xed, 0x49, 0xdb, 0x7b, 0x84, 0x32, 0x30, 0x7c, 0x41, 0x94, 0x0, + 0x15, 0x26, 0xe3, 0xb0, 0x3a, 0x6c, 0x28, 0x5b, 0x8c, 0x3b, 0xfa, 0xb3, 0x9d, 0x8, 0xa6, 0x89, 0xf2, + 0xe7, 0x4, 0x77, 0xa4, 0x8b, 0x0, 0x16, 0xcc, 0x51, 0xcb, 0xfb, 0x1, 0x4d, 0x58, 0xc1, 0x24, 0x8b, + 0x31, 0x32, 0xb2, 0x79, 0xc3, 0x56, 0x7b, 0xce, 0x71, 0x1c, 0x63, 0x54}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x77, 0x39, 0x41, 0xa, 0x3d, 0xc, 0xef, 0x50, 0xf8, 0x69, 0x6f, 0x6d, - 0x56, 0xf6, 0xe6, 0xdb, 0xc, 0xea, 0x69, 0xf5, 0x2c, 0x88, 0x65}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x0, 0x76, 0x5f, 0x47, 0x29, 0xdf, 0x6f, 0x38, 0xf1, 0xf0, 0xa5, 0xff}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xc8, 0x30, 0x26, 0x56, 0x83, 0x19, 0x25, 0xb0, 0xaa, 0x52, 0xd1, - 0xa6, 0x5e, 0x3c, 0xaa, 0xc8, 0xdc, 0x66, 0xde, 0x7, 0x1c, 0x44}; - lwmqtt_string_t topic_filter_s1 = {22, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0xb6, 0x64, 0x1c, 0x72, 0xa6, 0x4, 0xbd, 0x9, 0xf4, 0xab, 0x77, 0xed, + 0xf7, 0xa2, 0x71, 0xc8, 0x4b, 0x6f, 0x29, 0xe, 0xbb, 0xd, 0x1f, 0x36, 0x52}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x2e, 0x32, 0x5e, 0x2e, 0xf2, 0xd, 0xc6}; - lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8d, 0x28, 0xa5, 0x2f, 0xd9, 0x38}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xd, 0xe5, 0xa6, 0xbb, 0x66, 0xf4, 0xbc, 0x25, 0x97, 0xd5, - 0x57, 0xc6, 0x96, 0x7, 0xc, 0xc9, 0xf5, 0x79, 0x48, 0xc1, - 0x89, 0x26, 0x39, 0xf6, 0xd1, 0x4b, 0x61, 0x94, 0x8c, 0x1e}; - lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x0, 0x4, 0xde, 0x14, 0x6c, 0x6b, 0xab, 0x5a, 0xde, 0xd0, + 0x9, 0x31, 0xce, 0x7d, 0x29, 0xd8, 0xb0, 0xf1, 0x1a, 0xe2, + 0x29, 0x99, 0x7f, 0xbc, 0x36, 0x57, 0x76, 0xb0, 0x3e}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x1e, 0x43, 0x62, 0x2f, 0x62, 0x8f, 0x97, 0xac, 0x2, 0x4c, 0xa7, 0x81, - 0xba, 0x8e, 0xfc, 0xa0, 0xda, 0x15, 0x9b, 0x86, 0x4, 0xbf, 0xf7, 0x77}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x79, 0xc0, 0x1b, 0xce, 0x99, 0x1d, 0x54, 0x56, 0x62, 0xb4, 0xfe, 0x8b, 0xdd, 0x37, + 0xff, 0xdb, 0xd0, 0xea, 0x13, 0xf0, 0x89, 0xca, 0x74, 0x70, 0x16, 0x9e, 0x95}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xce, 0x41, 0xe7, 0x53, 0xad, 0xfe, 0x4d, 0x39, 0x52, 0x13, 0xb1, 0x24, 0x4f, - 0xe1, 0x64, 0xde, 0xaf, 0x2b, 0xcf, 0x8a, 0x46, 0x4e, 0xf9, 0xe1, 0xe7, 0xfb}; + uint8_t topic_filter_s5_bytes[] = {0x7d, 0x8, 0x98, 0xad, 0x53, 0x6d, 0xe1, 0xac, 0xad, 0x7b, 0x23, 0xc7, 0x96, + 0x4e, 0xaa, 0x88, 0xd9, 0x53, 0xe5, 0x37, 0xfa, 0x9b, 0xa8, 0xb4, 0x86, 0xb5}; lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x85, 0x71}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xd8, 0xd3, 0x47, 0x4f, 0x88, 0x77, 0x8e, 0xf}; + lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x87, 0xd4, 0x98, 0xfd, 0x3, 0xe8, 0xe3, 0xd8, 0x10, 0xf5, 0x83, 0x51, 0x43, 0x2d, + 0x17, 0x32, 0x26, 0xed, 0x49, 0xdb, 0x7b, 0x84, 0x32, 0x30, 0x7c, 0x41, 0x94}; + lwmqtt_string_t topic_filter_s8 = {27, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x26, 0xe3, 0xb0, 0x3a, 0x6c, 0x28, 0x5b, 0x8c, 0x3b, 0xfa, 0xb3, + 0x9d, 0x8, 0xa6, 0x89, 0xf2, 0xe7, 0x4, 0x77, 0xa4, 0x8b}; + lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xcc, 0x51, 0xcb, 0xfb, 0x1, 0x4d, 0x58, 0xc1, 0x24, 0x8b, 0x31, + 0x32, 0xb2, 0x79, 0xc3, 0x56, 0x7b, 0xce, 0x71, 0x1c, 0x63, 0x54}; + lwmqtt_string_t topic_filter_s10 = {22, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 14225, 6, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 29959, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 19016 -// ["Jg\224\251\204?\245=","\241\203b\228\136\148R&\163\232S\US\233R","\202g\168\178\ENQ;\ETB\131\t!4\227\199.E\251","+\200\171{ZW\DC4\ACK\170 -// n\253\171=\157'_\155\tW\163\242\a\223","\224_L\250\174\189\ETB\170\156\243\NUL","#V\247\220\&3\202\129\146s\GS\244\149\158xi\231\149\242\DEL\148\172\159\210]\226\EMN","R\ACK\SOH9\148\244/","\153%\252\231\&9\254\131\161\180\161\151\"\239P!_\141T\EMsz\"0"] -// [] +// UnsubscribeRequest 5839 [""] [] TEST(Unsubscribe311QCTest, Encode28) { - uint8_t pkt[] = {0xa2, 0x94, 0x1, 0x4a, 0x48, 0x0, 0x8, 0x4a, 0x67, 0xe0, 0xfb, 0xcc, 0x3f, 0xf5, 0x3d, 0x0, 0xe, - 0xf1, 0xcb, 0x62, 0xe4, 0x88, 0x94, 0x52, 0x26, 0xa3, 0xe8, 0x53, 0x1f, 0xe9, 0x52, 0x0, 0x10, 0xca, - 0x67, 0xa8, 0xb2, 0x5, 0x3b, 0x17, 0x83, 0x9, 0x21, 0x34, 0xe3, 0xc7, 0x2e, 0x45, 0xfb, 0x0, 0x18, - 0x2b, 0xc8, 0xab, 0x7b, 0x5a, 0x57, 0x14, 0x6, 0xaa, 0x20, 0x6e, 0xfd, 0xab, 0x3d, 0x9d, 0x27, 0x5f, - 0x9b, 0x9, 0x57, 0xa3, 0xf2, 0x7, 0xdf, 0x0, 0xb, 0xe0, 0x5f, 0x4c, 0xfa, 0xae, 0xbd, 0x17, 0xaa, - 0x9c, 0xf3, 0x0, 0x0, 0x1b, 0x23, 0x56, 0xf7, 0xdc, 0x33, 0xca, 0x81, 0x92, 0x73, 0x1d, 0xf4, 0x95, - 0x9e, 0x78, 0x69, 0xe7, 0x95, 0xf2, 0x7f, 0x94, 0xac, 0x9f, 0xd2, 0x5d, 0xe2, 0x19, 0x4e, 0x0, 0x7, - 0x52, 0x6, 0x1, 0x39, 0x94, 0xf4, 0x2f, 0x0, 0x17, 0x99, 0x25, 0xfc, 0xe7, 0x39, 0xfe, 0x83, 0xa1, - 0xb4, 0xa1, 0x97, 0x22, 0xef, 0x50, 0x21, 0x5f, 0x8d, 0x54, 0x19, 0x73, 0x7a, 0x22, 0x30}; + uint8_t pkt[] = {0xa2, 0x4, 0x16, 0xcf, 0x0, 0x0}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x4a, 0x67, 0xe0, 0xfb, 0xcc, 0x3f, 0xf5, 0x3d}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf1, 0xcb, 0x62, 0xe4, 0x88, 0x94, 0x52, - 0x26, 0xa3, 0xe8, 0x53, 0x1f, 0xe9, 0x52}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xca, 0x67, 0xa8, 0xb2, 0x5, 0x3b, 0x17, 0x83, - 0x9, 0x21, 0x34, 0xe3, 0xc7, 0x2e, 0x45, 0xfb}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2b, 0xc8, 0xab, 0x7b, 0x5a, 0x57, 0x14, 0x6, 0xaa, 0x20, 0x6e, 0xfd, - 0xab, 0x3d, 0x9d, 0x27, 0x5f, 0x9b, 0x9, 0x57, 0xa3, 0xf2, 0x7, 0xdf}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe0, 0x5f, 0x4c, 0xfa, 0xae, 0xbd, 0x17, 0xaa, 0x9c, 0xf3, 0x0}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x23, 0x56, 0xf7, 0xdc, 0x33, 0xca, 0x81, 0x92, 0x73, 0x1d, 0xf4, 0x95, 0x9e, 0x78, - 0x69, 0xe7, 0x95, 0xf2, 0x7f, 0x94, 0xac, 0x9f, 0xd2, 0x5d, 0xe2, 0x19, 0x4e}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x52, 0x6, 0x1, 0x39, 0x94, 0xf4, 0x2f}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x99, 0x25, 0xfc, 0xe7, 0x39, 0xfe, 0x83, 0xa1, 0xb4, 0xa1, 0x97, 0x22, - 0xef, 0x50, 0x21, 0x5f, 0x8d, 0x54, 0x19, 0x73, 0x7a, 0x22, 0x30}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 19016, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 5839, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24261 -// ["/\168j\253\190Jy7\185~F\236J","S\225\251?H\DC1\249\DC3\ETX\182\155[\CAN","}\EOT\136\245\&6b\203\202","9\222\252{E\t\SYNK5\162El\EOTA\171\&4\152\ESC","w\157\&9N\nW\242K\NUL\150a\166~\196\168\226\187\DEL\tU\186\218f\168","l\194\247\SOB\246P/\139","?fa\190\246c\DC2|/\206\SO\149\246\149Ar\153\174\EM\168\SOH\150\163\175\&3\236\191\ENQ\f\158","R$\140\171\234d\136\145\221\151\US8|3\254","\DLE\SI_\219/\178\128k\149\188\203\130J%\245\200P","\186\237'\227\&6\220\179\227\170\228\SOH?=\GS\DC3\224\204\166\tj\ESC|-s;\179",""] +// UnsubscribeRequest 8093 +// ["\140\244F\161","k5\NAK\128\246yah\170\t","\154\DC2\209)BN\179P\ETX>:\DC1\174\174\143HZZ","\137\208\145\SO\\\207\ETB\163","\181w4\223bZ\155\243A\162\248\162p\158\190\162\&8\132\v\163\&2\238\"\206k6\132","C\SUB\243\t\186\&0\166\DLE\211\148H\185\196\132\221\228\190%\144@~\243\255","G*","\FS\201\240\&9s\203\239\199\205d","V\\\216CA(\177f\229\172\150R\176r-\217\135","\215\217\143Yxc2f\\\168\229\ETX\SUB\214\207\DEL!\198\223\131%\147\r\ESC\199l8|\159\181"] // [] TEST(Unsubscribe311QCTest, Encode29) { - uint8_t pkt[] = {0xa2, 0xc5, 0x1, 0x5e, 0xc5, 0x0, 0xd, 0x2f, 0xa8, 0x6a, 0xfd, 0xbe, 0x4a, 0x79, 0x37, 0xb9, 0x7e, - 0x46, 0xec, 0x4a, 0x0, 0xd, 0x53, 0xe1, 0xfb, 0x3f, 0x48, 0x11, 0xf9, 0x13, 0x3, 0xb6, 0x9b, 0x5b, - 0x18, 0x0, 0x8, 0x7d, 0x4, 0x88, 0xf5, 0x36, 0x62, 0xcb, 0xca, 0x0, 0x12, 0x39, 0xde, 0xfc, 0x7b, - 0x45, 0x9, 0x16, 0x4b, 0x35, 0xa2, 0x45, 0x6c, 0x4, 0x41, 0xab, 0x34, 0x98, 0x1b, 0x0, 0x18, 0x77, - 0x9d, 0x39, 0x4e, 0xa, 0x57, 0xf2, 0x4b, 0x0, 0x96, 0x61, 0xa6, 0x7e, 0xc4, 0xa8, 0xe2, 0xbb, 0x7f, - 0x9, 0x55, 0xba, 0xda, 0x66, 0xa8, 0x0, 0x9, 0x6c, 0xc2, 0xf7, 0xe, 0x42, 0xf6,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0x0, 0x17, 0x43, 0x1a, 0xf3, 0x9, 0xba, 0x30, 0xa6, 0x10, 0xd3, 0x94, 0x48, 0xb9, + 0xc4, 0x84, 0xdd, 0xe4, 0xbe, 0x25, 0x90, 0x40, 0x7e, 0xf3, 0xff, 0x0, 0x2, 0x47, 0x2a, 0x0, + 0xa, 0x1c, 0xc9, 0xf0, 0x39, 0x73, 0xcb, 0xef, 0xc7, 0xcd, 0x64, 0x0, 0x11, 0x56, 0x5c, 0xd8, + 0x43, 0x41, 0x28, 0xb1, 0x66, 0xe5, 0xac, 0x96, 0x52, 0xb0, 0x72, 0x2d, 0xd9, 0x87, 0x0, 0x1e, + 0xd7, 0xd9, 0x8f, 0x59, 0x78, 0x63, 0x32, 0x66, 0x5c, 0xa8, 0xe5, 0x3, 0x1a, 0xd6, 0xcf, 0x7f, + 0x21, 0xc6, 0xdf, 0x83, 0x25, 0x93, 0xd, 0x1b, 0xc7, 0x6c, 0x38, 0x7c, 0x9f, 0xb5}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x2f, 0xa8, 0x6a, 0xfd, 0xbe, 0x4a, 0x79, 0x37, 0xb9, 0x7e, 0x46, 0xec, 0x4a}; - lwmqtt_string_t topic_filter_s0 = {13, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0x8c, 0xf4, 0x46, 0xa1}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x53, 0xe1, 0xfb, 0x3f, 0x48, 0x11, 0xf9, 0x13, 0x3, 0xb6, 0x9b, 0x5b, 0x18}; - lwmqtt_string_t topic_filter_s1 = {13, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x6b, 0x35, 0x15, 0x80, 0xf6, 0x79, 0x61, 0x68, 0xaa, 0x9}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7d, 0x4, 0x88, 0xf5, 0x36, 0x62, 0xcb, 0xca}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x9a, 0x12, 0xd1, 0x29, 0x42, 0x4e, 0xb3, 0x50, 0x3, + 0x3e, 0x3a, 0x11, 0xae, 0xae, 0x8f, 0x48, 0x5a, 0x5a}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x39, 0xde, 0xfc, 0x7b, 0x45, 0x9, 0x16, 0x4b, 0x35, - 0xa2, 0x45, 0x6c, 0x4, 0x41, 0xab, 0x34, 0x98, 0x1b}; - lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x89, 0xd0, 0x91, 0xe, 0x5c, 0xcf, 0x17, 0xa3}; + lwmqtt_string_t topic_filter_s3 = {8, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x77, 0x9d, 0x39, 0x4e, 0xa, 0x57, 0xf2, 0x4b, 0x0, 0x96, 0x61, 0xa6, - 0x7e, 0xc4, 0xa8, 0xe2, 0xbb, 0x7f, 0x9, 0x55, 0xba, 0xda, 0x66, 0xa8}; - lwmqtt_string_t topic_filter_s4 = {24, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xb5, 0x77, 0x34, 0xdf, 0x62, 0x5a, 0x9b, 0xf3, 0x41, 0xa2, 0xf8, 0xa2, 0x70, 0x9e, + 0xbe, 0xa2, 0x38, 0x84, 0xb, 0xa3, 0x32, 0xee, 0x22, 0xce, 0x6b, 0x36, 0x84}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6c, 0xc2, 0xf7, 0xe, 0x42, 0xf6, 0x50, 0x2f, 0x8b}; - lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x43, 0x1a, 0xf3, 0x9, 0xba, 0x30, 0xa6, 0x10, 0xd3, 0x94, 0x48, 0xb9, + 0xc4, 0x84, 0xdd, 0xe4, 0xbe, 0x25, 0x90, 0x40, 0x7e, 0xf3, 0xff}; + lwmqtt_string_t topic_filter_s5 = {23, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x3f, 0x66, 0x61, 0xbe, 0xf6, 0x63, 0x12, 0x7c, 0x2f, 0xce, - 0xe, 0x95, 0xf6, 0x95, 0x41, 0x72, 0x99, 0xae, 0x19, 0xa8, - 0x1, 0x96, 0xa3, 0xaf, 0x33, 0xec, 0xbf, 0x5, 0xc, 0x9e}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x47, 0x2a}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x52, 0x24, 0x8c, 0xab, 0xea, 0x64, 0x88, 0x91, - 0xdd, 0x97, 0x1f, 0x38, 0x7c, 0x33, 0xfe}; - lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x1c, 0xc9, 0xf0, 0x39, 0x73, 0xcb, 0xef, 0xc7, 0xcd, 0x64}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x10, 0xf, 0x5f, 0xdb, 0x2f, 0xb2, 0x80, 0x6b, 0x95, - 0xbc, 0xcb, 0x82, 0x4a, 0x25, 0xf5, 0xc8, 0x50}; + uint8_t topic_filter_s8_bytes[] = {0x56, 0x5c, 0xd8, 0x43, 0x41, 0x28, 0xb1, 0x66, 0xe5, + 0xac, 0x96, 0x52, 0xb0, 0x72, 0x2d, 0xd9, 0x87}; lwmqtt_string_t topic_filter_s8 = {17, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xba, 0xed, 0x27, 0xe3, 0x36, 0xdc, 0xb3, 0xe3, 0xaa, 0xe4, 0x1, 0x3f, 0x3d, - 0x1d, 0x13, 0xe0, 0xcc, 0xa6, 0x9, 0x6a, 0x1b, 0x7c, 0x2d, 0x73, 0x3b, 0xb3}; - lwmqtt_string_t topic_filter_s9 = {26, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0xd7, 0xd9, 0x8f, 0x59, 0x78, 0x63, 0x32, 0x66, 0x5c, 0xa8, + 0xe5, 0x3, 0x1a, 0xd6, 0xcf, 0x7f, 0x21, 0xc6, 0xdf, 0x83, + 0x25, 0x93, 0xd, 0x1b, 0xc7, 0x6c, 0x38, 0x7c, 0x9f, 0xb5}; + lwmqtt_string_t topic_filter_s9 = {30, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0}; - lwmqtt_string_t topic_filter_s10 = {0, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 24261, 11, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 8093, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 28335 -// ["\131\a\246\226.","-\229QI\184\222\GSz\140","D","","\162\135\151\128\210\134PrL7\213\215\215\238\242\140I\221\230\189b\149\SYN\136\145\&9.\204\r","{\242M\ESCHt\210\SUBS\192\165\128\&00$\247\150y`0\227\181\237\ENQ_\199\253\230","\129\196S\189\178*\221\152}\246\130z\235sE\131\216v\ESC\188prdC\249d"] +// UnsubscribeRequest 18954 +// ["\218\204e\192\250\149/\ENQMK","\241\DLE=","\177\222\GS\183\ETB","","\SUBg^\150\156\ETBMG\237\&0\244\220/\154b\199\DC1\210\161\230\201\129\206\180@","\187","\211\175D\131\203\225\203-\177g&\DC3\RS\214\&1\142\161\&0\ACK\184\217V9f","\238\SI\238\aY\177\140\244\140\203\135\206\131\171\199"] // [] TEST(Unsubscribe311QCTest, Encode30) { - uint8_t pkt[] = {0xa2, 0x72, 0x6e, 0xaf, 0x0, 0x5, 0x83, 0x7, 0xf6, 0xe2, 0x2e, 0x0, 0x9, 0x2d, 0xe5, 0x51, 0x49, - 0xb8, 0xde, 0x1d, 0x7a, 0x8c, 0x0, 0x1, 0x44, 0x0, 0x0, 0x0, 0x1d, 0xa2, 0x87, 0x97, 0x80, 0xd2, - 0x86, 0x50, 0x72, 0x4c, 0x37, 0xd5, 0xd7, 0xd7, 0xee, 0xf2, 0x8c, 0x49, 0xdd, 0xe6, 0xbd, 0x62, 0x95, - 0x16, 0x88, 0x91, 0x39, 0x2e, 0xcc, 0xd, 0x0, 0x1c, 0x7b, 0xf2, 0x4d, 0x1b, 0x48, 0x74, 0xd2, 0x1a, - 0x53, 0xc0, 0xa5, 0x80, 0x30, 0x30, 0x24, 0xf7, 0x96, 0x79, 0x60, 0x30, 0xe3, 0xb5, 0xed, 0x5, 0x5f, - 0xc7, 0xfd, 0xe6, 0x0, 0x1a, 0x81, 0xc4, 0x53, 0xbd, 0xb2, 0x2a, 0xdd, 0x98, 0x7d, 0xf6, 0x82, 0x7a, - 0xeb, 0x73, 0x45, 0x83, 0xd8, 0x76, 0x1b, 0xbc, 0x70, 0x72, 0x64, 0x43, 0xf9, 0x64}; + uint8_t pkt[] = {0xa2, 0x65, 0x4a, 0xa, 0x0, 0xa, 0xda, 0xcc, 0x65, 0xc0, 0xfa, 0x95, 0x2f, 0x5, 0x4d, + 0x4b, 0x0, 0x3, 0xf1, 0x10, 0x3d, 0x0, 0x5, 0xb1, 0xde, 0x1d, 0xb7, 0x17, 0x0, 0x0, + 0x0, 0x19, 0x1a, 0x67, 0x5e, 0x96, 0x9c, 0x17, 0x4d, 0x47, 0xed, 0x30, 0xf4, 0xdc, 0x2f, + 0x9a, 0x62, 0xc7, 0x11, 0xd2, 0xa1, 0xe6, 0xc9, 0x81, 0xce, 0xb4, 0x40, 0x0, 0x1, 0xbb, + 0x0, 0x18, 0xd3, 0xaf, 0x44, 0x83, 0xcb, 0xe1, 0xcb, 0x2d, 0xb1, 0x67, 0x26, 0x13, 0x1e, + 0xd6, 0x31, 0x8e, 0xa1, 0x30, 0x6, 0xb8, 0xd9, 0x56, 0x39, 0x66, 0x0, 0xf, 0xee, 0xf, + 0xee, 0x7, 0x59, 0xb1, 0x8c, 0xf4, 0x8c, 0xcb, 0x87, 0xce, 0x83, 0xab, 0xc7}; uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = {}; lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x83, 0x7, 0xf6, 0xe2, 0x2e}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xda, 0xcc, 0x65, 0xc0, 0xfa, 0x95, 0x2f, 0x5, 0x4d, 0x4b}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2d, 0xe5, 0x51, 0x49, 0xb8, 0xde, 0x1d, 0x7a, 0x8c}; - lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xf1, 0x10, 0x3d}; + lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x44}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xb1, 0xde, 0x1d, 0xb7, 0x17}; + lwmqtt_string_t topic_filter_s2 = {5, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; uint8_t topic_filter_s3_bytes[] = {0}; lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa2, 0x87, 0x97, 0x80, 0xd2, 0x86, 0x50, 0x72, 0x4c, 0x37, - 0xd5, 0xd7, 0xd7, 0xee, 0xf2, 0x8c, 0x49, 0xdd, 0xe6, 0xbd, - 0x62, 0x95, 0x16, 0x88, 0x91, 0x39, 0x2e, 0xcc, 0xd}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x1a, 0x67, 0x5e, 0x96, 0x9c, 0x17, 0x4d, 0x47, 0xed, 0x30, 0xf4, 0xdc, 0x2f, + 0x9a, 0x62, 0xc7, 0x11, 0xd2, 0xa1, 0xe6, 0xc9, 0x81, 0xce, 0xb4, 0x40}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x7b, 0xf2, 0x4d, 0x1b, 0x48, 0x74, 0xd2, 0x1a, 0x53, 0xc0, - 0xa5, 0x80, 0x30, 0x30, 0x24, 0xf7, 0x96, 0x79, 0x60, 0x30, - 0xe3, 0xb5, 0xed, 0x5, 0x5f, 0xc7, 0xfd, 0xe6}; - lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xbb}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x81, 0xc4, 0x53, 0xbd, 0xb2, 0x2a, 0xdd, 0x98, 0x7d, 0xf6, 0x82, 0x7a, 0xeb, - 0x73, 0x45, 0x83, 0xd8, 0x76, 0x1b, 0xbc, 0x70, 0x72, 0x64, 0x43, 0xf9, 0x64}; - lwmqtt_string_t topic_filter_s6 = {26, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xd3, 0xaf, 0x44, 0x83, 0xcb, 0xe1, 0xcb, 0x2d, 0xb1, 0x67, 0x26, 0x13, + 0x1e, 0xd6, 0x31, 0x8e, 0xa1, 0x30, 0x6, 0xb8, 0xd9, 0x56, 0x39, 0x66}; + lwmqtt_string_t topic_filter_s6 = {24, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xee, 0xf, 0xee, 0x7, 0x59, 0xb1, 0x8c, 0xf4, + 0x8c, 0xcb, 0x87, 0xce, 0x83, 0xab, 0xc7}; + lwmqtt_string_t topic_filter_s7 = {15, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 28335, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT311, 18954, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24378 ["\214\DC35\253\159\129F#\236\204y?\150\128\DC2u\230\211 -// O\133\185\r\135\163\177","\225\161,\196C\187\132IH\245\164\210!e\185\145e\139\243\181X8\n\242\182\204\151^\228","{\SUBC\158","\252\142\163gsP\ACK\133\234LY\203\&8\183\251\223\147\128\249","G}\173\207o\181\247\NULk\180\255\243\157o\SOH\199\NAKxD6","\220\ACK\170\&3)c\200`\251o\158"] -// [PropSharedSubscriptionAvailable 212,PropMaximumQoS 50,PropSharedSubscriptionAvailable 163,PropServerReference -// "\182\250",PropTopicAliasMaximum 21621,PropTopicAliasMaximum 5299,PropSharedSubscriptionAvailable -// 40,PropSubscriptionIdentifierAvailable 20,PropAssignedClientIdentifier "\221I\r\179\165\139lK\170\229\183H\241u"] +// UnsubscribeRequest 22317 +// ["\SUB{\230Y\DC1\b\EM\160\232\SUB\CAN\131\NUL\188t\134\180\194a\152K\153\153\177\DLE1\225\161\225"] +// [PropPayloadFormatIndicator 182,PropRequestResponseInformation 171,PropMaximumPacketSize 20003,PropCorrelationData +// "J\SYN\202\172W3\149\236\ENQe8 Q\NUL\163@\227\n\208\142\129\226\156",PropTopicAlias 26285,PropMaximumPacketSize +// 4046,PropTopicAliasMaximum 15854,PropResponseInformation +// "\252\&4\NUL\164\SI\167\&5\162r\227\141\tO\183\203\SYN\196\138\216_\227,\186~\153\139j\DC2",PropWildcardSubscriptionAvailable +// 63,PropAuthenticationMethod +// "\f\227\&5)\177\STXy\233\213\184\184`\220<;+\140\177;\n\SOH\201\148\171p0",PropCorrelationData +// "J\177\169UK\RS7V\163\ACK\129\190\227=D~\132\227\157\ETBtKx7\220\172p[",PropTopicAliasMaximum 9276,PropMaximumQoS +// 204,PropAuthenticationMethod +// "\149\SI4\ACK\181P\ETX\186\190Gj\163\206#\210\bw\237$\141O\215\DC3\SOH",PropPayloadFormatIndicator +// 248,PropWildcardSubscriptionAvailable 203,PropMaximumQoS 70,PropWildcardSubscriptionAvailable 169,PropContentType +// "\204f\197-",PropAssignedClientIdentifier +// "\253W\136\STX3\247\147>\f\156/\223\157\253Cs\129\146q;\149\128\180+\SYN\136j\134N"] TEST(Unsubscribe5QCTest, Encode1) { - uint8_t pkt[] = {0xa2, 0xa2, 0x1, 0x5f, 0x3a, 0x26, 0x2a, 0xd4, 0x24, 0x32, 0x2a, 0xa3, 0x1c, 0x0, 0x2, 0xb6, 0xfa, - 0x22, 0x54, 0x75, 0x22, 0x14, 0xb3, 0x2a, 0x28, 0x29, 0x14, 0x12, 0x0, 0xe, 0xdd, 0x49, 0xd, 0xb3, - 0xa5, 0x8b, 0x6c, 0x4b, 0xaa, 0xe5, 0xb7, 0x48, 0xf1, 0x75, 0x0, 0x1a, 0xd6, 0x13, 0x35, 0xfd, 0x9f, - 0x81, 0x46, 0x23, 0xec, 0xcc, 0x79, 0x3f, 0x96, 0x80, 0x12, 0x75, 0xe6, 0xd3, 0x20, 0x4f, 0x85, 0xb9, - 0xd, 0x87, 0xa3, 0xb1, 0x0, 0x1d, 0xe1, 0xa1, 0x2c, 0xc4, 0x43, 0xbb, 0x84, 0x49, 0x48, 0xf5, 0xa4, - 0xd2, 0x21, 0x65, 0xb9, 0x91, 0x65, 0x8b, 0xf3, 0xb5, 0x58, 0x38, 0xa, 0xf2, 0xb6, 0xcc, 0x97, 0x5e, - 0xe4, 0x0, 0x4, 0x7b, 0x1a, 0x43, 0x9e, 0x0, 0x13, 0xfc, 0x8e, 0xa3, 0x67, 0x73, 0x50, 0x6, 0x85, - 0xea, 0x4c, 0x59, 0xcb, 0x38, 0xb7, 0xfb, 0xdf, 0x93, 0x80, 0xf9, 0x0, 0x14, 0x47, 0x7d, 0xad, 0xcf, - 0x6f, 0xb5, 0xf7, 0x0, 0x6b, 0xb4, 0xff, 0xf3, 0x9d, 0x6f, 0x1, 0xc7, 0x15, 0x78, 0x44, 0x36, 0x0, - 0xb, 0xdc, 0x6, 0xaa, 0x33, 0x29, 0x63, 0xc8, 0x60, 0xfb, 0x6f, 0x9e}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb6, 0xfa}; - uint8_t bytesprops1[] = {0xdd, 0x49, 0xd, 0xb3, 0xa5, 0x8b, 0x6c, 0x4b, 0xaa, 0xe5, 0xb7, 0x48, 0xf1, 0x75}; + uint8_t pkt[] = { + 0xa2, 0xfd, 0x1, 0x57, 0x2d, 0xda, 0x1, 0x1, 0xb6, 0x19, 0xab, 0x27, 0x0, 0x0, 0x4e, 0x23, 0x9, 0x0, 0x17, + 0x4a, 0x16, 0xca, 0xac, 0x57, 0x33, 0x95, 0xec, 0x5, 0x65, 0x38, 0x20, 0x51, 0x0, 0xa3, 0x40, 0xe3, 0xa, 0xd0, + 0x8e, 0x81, 0xe2, 0x9c, 0x23, 0x66, 0xad, 0x27, 0x0, 0x0, 0xf, 0xce, 0x22, 0x3d, 0xee, 0x1a, 0x0, 0x1c, 0xfc, + 0x34, 0x0, 0xa4, 0xf, 0xa7, 0x35, 0xa2, 0x72, 0xe3, 0x8d, 0x9, 0x4f, 0xb7, 0xcb, 0x16, 0xc4, 0x8a, 0xd8, 0x5f, + 0xe3, 0x2c, 0xba, 0x7e, 0x99, 0x8b, 0x6a, 0x12, 0x28, 0x3f, 0x15, 0x0, 0x1a, 0xc, 0xe3, 0x35, 0x29, 0xb1, 0x2, + 0x79, 0xe9, 0xd5, 0xb8, 0xb8, 0x60, 0xdc, 0x3c, 0x3b, 0x2b, 0x8c, 0xb1, 0x3b, 0xa, 0x1, 0xc9, 0x94, 0xab, 0x70, + 0x30, 0x9, 0x0, 0x1c, 0x4a, 0xb1, 0xa9, 0x55, 0x4b, 0x1e, 0x37, 0x56, 0xa3, 0x6, 0x81, 0xbe, 0xe3, 0x3d, 0x44, + 0x7e, 0x84, 0xe3, 0x9d, 0x17, 0x74, 0x4b, 0x78, 0x37, 0xdc, 0xac, 0x70, 0x5b, 0x22, 0x24, 0x3c, 0x24, 0xcc, 0x15, + 0x0, 0x18, 0x95, 0xf, 0x34, 0x6, 0xb5, 0x50, 0x3, 0xba, 0xbe, 0x47, 0x6a, 0xa3, 0xce, 0x23, 0xd2, 0x8, 0x77, + 0xed, 0x24, 0x8d, 0x4f, 0xd7, 0x13, 0x1, 0x1, 0xf8, 0x28, 0xcb, 0x24, 0x46, 0x28, 0xa9, 0x3, 0x0, 0x4, 0xcc, + 0x66, 0xc5, 0x2d, 0x12, 0x0, 0x1d, 0xfd, 0x57, 0x88, 0x2, 0x33, 0xf7, 0x93, 0x3e, 0xc, 0x9c, 0x2f, 0xdf, 0x9d, + 0xfd, 0x43, 0x73, 0x81, 0x92, 0x71, 0x3b, 0x95, 0x80, 0xb4, 0x2b, 0x16, 0x88, 0x6a, 0x86, 0x4e, 0x0, 0x1d, 0x1a, + 0x7b, 0xe6, 0x59, 0x11, 0x8, 0x19, 0xa0, 0xe8, 0x1a, 0x18, 0x83, 0x0, 0xbc, 0x74, 0x86, 0xb4, 0xc2, 0x61, 0x98, + 0x4b, 0x99, 0x99, 0xb1, 0x10, 0x31, 0xe1, 0xa1, 0xe1}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x4a, 0x16, 0xca, 0xac, 0x57, 0x33, 0x95, 0xec, 0x5, 0x65, 0x38, 0x20, + 0x51, 0x0, 0xa3, 0x40, 0xe3, 0xa, 0xd0, 0x8e, 0x81, 0xe2, 0x9c}; + uint8_t bytesprops1[] = {0xfc, 0x34, 0x0, 0xa4, 0xf, 0xa7, 0x35, 0xa2, 0x72, 0xe3, 0x8d, 0x9, 0x4f, 0xb7, + 0xcb, 0x16, 0xc4, 0x8a, 0xd8, 0x5f, 0xe3, 0x2c, 0xba, 0x7e, 0x99, 0x8b, 0x6a, 0x12}; + uint8_t bytesprops2[] = {0xc, 0xe3, 0x35, 0x29, 0xb1, 0x2, 0x79, 0xe9, 0xd5, 0xb8, 0xb8, 0x60, 0xdc, + 0x3c, 0x3b, 0x2b, 0x8c, 0xb1, 0x3b, 0xa, 0x1, 0xc9, 0x94, 0xab, 0x70, 0x30}; + uint8_t bytesprops3[] = {0x4a, 0xb1, 0xa9, 0x55, 0x4b, 0x1e, 0x37, 0x56, 0xa3, 0x6, 0x81, 0xbe, 0xe3, 0x3d, + 0x44, 0x7e, 0x84, 0xe3, 0x9d, 0x17, 0x74, 0x4b, 0x78, 0x37, 0xdc, 0xac, 0x70, 0x5b}; + uint8_t bytesprops4[] = {0x95, 0xf, 0x34, 0x6, 0xb5, 0x50, 0x3, 0xba, 0xbe, 0x47, 0x6a, 0xa3, + 0xce, 0x23, 0xd2, 0x8, 0x77, 0xed, 0x24, 0x8d, 0x4f, 0xd7, 0x13, 0x1}; + uint8_t bytesprops5[] = {0xcc, 0x66, 0xc5, 0x2d}; + uint8_t bytesprops6[] = {0xfd, 0x57, 0x88, 0x2, 0x33, 0xf7, 0x93, 0x3e, 0xc, 0x9c, 0x2f, 0xdf, 0x9d, 0xfd, 0x43, + 0x73, 0x81, 0x92, 0x71, 0x3b, 0x95, 0x80, 0xb4, 0x2b, 0x16, 0x88, 0x6a, 0x86, 0x4e}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 50}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21621}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 5299}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 40}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 182}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 171}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20003}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26285}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4046}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15854}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 63}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 9276}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 204}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 248}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 203}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 70}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 169}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {29, (char*)&bytesprops6}}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0xd6, 0x13, 0x35, 0xfd, 0x9f, 0x81, 0x46, 0x23, 0xec, 0xcc, 0x79, 0x3f, 0x96, - 0x80, 0x12, 0x75, 0xe6, 0xd3, 0x20, 0x4f, 0x85, 0xb9, 0xd, 0x87, 0xa3, 0xb1}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {20, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x1a, 0x7b, 0xe6, 0x59, 0x11, 0x8, 0x19, 0xa0, 0xe8, 0x1a, + 0x18, 0x83, 0x0, 0xbc, 0x74, 0x86, 0xb4, 0xc2, 0x61, 0x98, + 0x4b, 0x99, 0x99, 0xb1, 0x10, 0x31, 0xe1, 0xa1, 0xe1}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe1, 0xa1, 0x2c, 0xc4, 0x43, 0xbb, 0x84, 0x49, 0x48, 0xf5, - 0xa4, 0xd2, 0x21, 0x65, 0xb9, 0x91, 0x65, 0x8b, 0xf3, 0xb5, - 0x58, 0x38, 0xa, 0xf2, 0xb6, 0xcc, 0x97, 0x5e, 0xe4}; - lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x7b, 0x1a, 0x43, 0x9e}; - lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xfc, 0x8e, 0xa3, 0x67, 0x73, 0x50, 0x6, 0x85, 0xea, 0x4c, - 0x59, 0xcb, 0x38, 0xb7, 0xfb, 0xdf, 0x93, 0x80, 0xf9}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x47, 0x7d, 0xad, 0xcf, 0x6f, 0xb5, 0xf7, 0x0, 0x6b, 0xb4, - 0xff, 0xf3, 0x9d, 0x6f, 0x1, 0xc7, 0x15, 0x78, 0x44, 0x36}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xdc, 0x6, 0xaa, 0x33, 0x29, 0x63, 0xc8, 0x60, 0xfb, 0x6f, 0x9e}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24378, 6, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22317, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 2051 -// ["","\193\252\EOT\NAK\244\187T\"A\224\181\EOT\232\248Q\175[\132*\231\160\&9cK\158\209wc1","A3\151\238\144\145\195:\165\&6R\SUB\239\198ypa\225\254\219\245\ETB\225\222e\GS","Q\EM\157\DC2\249\155h\249\139\&89)\243$\186u\190\135t\141\240\&7\164\246","\SUBTW","\132\180L","\212R\181Q4A7m,\SO\SYN\232I\181\207/\180QZX\217\199@","~}\"\182\146\230\151\176\250MD:\144\171\237Q\226X",")\188\182\214\&1\161\144\201>h\192"] +// [PropUserProperty "\219\162J\202\222:V\137\247k\232\239@;f\253`A/\GSSK" +// "\173\GS|\"\ESC\230c\189\GSl\211M\SOH\200",PropMaximumQoS 82,PropMessageExpiryInterval 15648,PropAuthenticationData +// "\152D\195\207\\\210\235\218\175Q`1`\193\DC2(\248\222t",PropResponseTopic +// "3\156]7*\210=ek\176]1\252%\184\205\154\195H\SIW\159v(",PropRetainAvailable 114] TEST(Unsubscribe5QCTest, Encode3) { - uint8_t pkt[] = {0xa2, 0x8e, 0x1, 0x41, 0x9a, 0x43, 0x15, 0x0, 0x19, 0xc7, 0xc0, 0xf1, 0x35, 0x98, 0x63, 0x5e, 0x82, - 0xb0, 0x1e, 0x2e, 0x92, 0xda, 0x39, 0x97, 0x0, 0x1c, 0x82, 0xc3, 0x58, 0xd7, 0xd0, 0x9b, 0x16, 0x8f, - 0x2a, 0x2a, 0x9, 0x0, 0x17, 0x5d, 0x5b, 0x44, 0xd, 0x8, 0x53, 0xb4, 0xf5, 0x15, 0x18, 0x79, 0xf0, - 0x1b, 0x73, 0xb3, 0x92, 0x75, 0xed, 0x3, 0x44, 0x80, 0x3a, 0xdd, 0x2, 0x0, 0x0, 0x64, 0xb5, 0x22, - 0x71, 0xc4, 0x22, 0x3d, 0x9b, 0x0, 0x6, 0xb4, 0x67, 0x35, 0x31, 0x8e, 0xac, 0x0, 0x1e, 0x3b, 0x2e, - 0x23, 0xb3, 0x9b, 0x2e, 0xde, 0xf4, 0x3f, 0xc7, 0xa4, 0xb2, 0x86, 0xbf, 0xe7, 0x2c, 0x36, 0x8, 0x3b, - 0xc5, 0x43, 0x11, 0x78, 0x4, 0x72, 0x83, 0x69, 0xad, 0x45, 0xb5, 0x0, 0x12, 0x53, 0x82, 0x90, 0xe4, - 0x1d, 0xbc, 0x93, 0x60, 0x35, 0x8f, 0xf3, 0xf6, 0x17, 0x99, 0x52, 0x82, 0xf0, 0xd5, 0x0, 0xa, 0x2a, - 0xe1, 0x5c, 0xea, 0xb8, 0x88, 0x96, 0x4a, 0xdd, 0x9d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xc7, 0xc0, 0xf1, 0x35, 0x98, 0x63, 0x5e, 0x82, 0xb0, 0x1e, 0x2e, 0x92, 0xda, - 0x39, 0x97, 0x0, 0x1c, 0x82, 0xc3, 0x58, 0xd7, 0xd0, 0x9b, 0x16, 0x8f}; - uint8_t bytesprops1[] = {0x5d, 0x5b, 0x44, 0xd, 0x8, 0x53, 0xb4, 0xf5, 0x15, 0x18, 0x79, 0xf0, - 0x1b, 0x73, 0xb3, 0x92, 0x75, 0xed, 0x3, 0x44, 0x80, 0x3a, 0xdd}; + uint8_t pkt[] = {0xa2, 0xa3, 0x1, 0x28, 0x59, 0x63, 0x26, 0x0, 0x16, 0xdb, 0xa2, 0x4a, 0xca, 0xde, 0x3a, 0x56, 0x89, + 0xf7, 0x6b, 0xe8, 0xef, 0x40, 0x3b, 0x66, 0xfd, 0x60, 0x41, 0x2f, 0x1d, 0x53, 0x4b, 0x0, 0xe, 0xad, + 0x1d, 0x7c, 0x22, 0x1b, 0xe6, 0x63, 0xbd, 0x1d, 0x6c, 0xd3, 0x4d, 0x1, 0xc8, 0x24, 0x52, 0x2, 0x0, + 0x0, 0x3d, 0x20, 0x16, 0x0, 0x13, 0x98, 0x44, 0xc3, 0xcf, 0x5c, 0xd2, 0xeb, 0xda, 0xaf, 0x51, 0x60, + 0x31, 0x60, 0xc1, 0x12, 0x28, 0xf8, 0xde, 0x74, 0x8, 0x0, 0x18, 0x33, 0x9c, 0x5d, 0x37, 0x2a, 0xd2, + 0x3d, 0x65, 0x6b, 0xb0, 0x5d, 0x31, 0xfc, 0x25, 0xb8, 0xcd, 0x9a, 0xc3, 0x48, 0xf, 0x57, 0x9f, 0x76, + 0x28, 0x25, 0x72, 0x0, 0x4, 0x3d, 0x5d, 0xe6, 0x40, 0x0, 0xa, 0x3d, 0x34, 0xac, 0x3c, 0xbd, 0x3f, + 0x7f, 0x8e, 0x58, 0xeb, 0x0, 0x8, 0x3e, 0xb4, 0x51, 0x5a, 0x58, 0xd9, 0xc7, 0x40, 0x0, 0x12, 0x7e, + 0x7d, 0x22, 0xb6, 0x92, 0xe6, 0x97, 0xb0, 0xfa, 0x4d, 0x44, 0x3a, 0x90, 0xab, 0xed, 0x51, 0xe2, 0x58, + 0x0, 0xb, 0x29, 0xbc, 0xb6, 0xd6, 0x31, 0xa1, 0x90, 0xc9, 0x3e, 0x68, 0xc0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0xad, 0x1d, 0x7c, 0x22, 0x1b, 0xe6, 0x63, 0xbd, 0x1d, 0x6c, 0xd3, 0x4d, 0x1, 0xc8}; + uint8_t bytesprops0[] = {0xdb, 0xa2, 0x4a, 0xca, 0xde, 0x3a, 0x56, 0x89, 0xf7, 0x6b, 0xe8, + 0xef, 0x40, 0x3b, 0x66, 0xfd, 0x60, 0x41, 0x2f, 0x1d, 0x53, 0x4b}; + uint8_t bytesprops2[] = {0x98, 0x44, 0xc3, 0xcf, 0x5c, 0xd2, 0xeb, 0xda, 0xaf, 0x51, + 0x60, 0x31, 0x60, 0xc1, 0x12, 0x28, 0xf8, 0xde, 0x74}; + uint8_t bytesprops3[] = {0x33, 0x9c, 0x5d, 0x37, 0x2a, 0xd2, 0x3d, 0x65, 0x6b, 0xb0, 0x5d, 0x31, + 0xfc, 0x25, 0xb8, 0xcd, 0x9a, 0xc3, 0x48, 0xf, 0x57, 0x9f, 0x76, 0x28}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25781}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29124}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15771}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {22, (char*)&bytesprops0}, .v = {14, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 82}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15648}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {24, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 114}}, }; lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0xb4, 0x67, 0x35, 0x31, 0x8e, 0xac}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x3d, 0x5d, 0xe6, 0x40}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x3b, 0x2e, 0x23, 0xb3, 0x9b, 0x2e, 0xde, 0xf4, 0x3f, 0xc7, - 0xa4, 0xb2, 0x86, 0xbf, 0xe7, 0x2c, 0x36, 0x8, 0x3b, 0xc5, - 0x43, 0x11, 0x78, 0x4, 0x72, 0x83, 0x69, 0xad, 0x45, 0xb5}; - lwmqtt_string_t topic_filter_s1 = {30, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x3d, 0x34, 0xac, 0x3c, 0xbd, 0x3f, 0x7f, 0x8e, 0x58, 0xeb}; + lwmqtt_string_t topic_filter_s1 = {10, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x53, 0x82, 0x90, 0xe4, 0x1d, 0xbc, 0x93, 0x60, 0x35, - 0x8f, 0xf3, 0xf6, 0x17, 0x99, 0x52, 0x82, 0xf0, 0xd5}; - lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x3e, 0xb4, 0x51, 0x5a, 0x58, 0xd9, 0xc7, 0x40}; + lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2a, 0xe1, 0x5c, 0xea, 0xb8, 0x88, 0x96, 0x4a, 0xdd, 0x9d}; - lwmqtt_string_t topic_filter_s3 = {10, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x7e, 0x7d, 0x22, 0xb6, 0x92, 0xe6, 0x97, 0xb0, 0xfa, + 0x4d, 0x44, 0x3a, 0x90, 0xab, 0xed, 0x51, 0xe2, 0x58}; + lwmqtt_string_t topic_filter_s3 = {18, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x29, 0xbc, 0xb6, 0xd6, 0x31, 0xa1, 0x90, 0xc9, 0x3e, 0x68, 0xc0}; + lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16794, 4, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10329, 5, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 15779 -// ["q\143\179\SUB\203\191\213\177]\DC1\148S\175\ESC\200C5\NAK\246\167r\152\198\254\ETXI","jv\241\208\SUB\210","\183\192\222;F\253\246vU\179\SIO\222","\150T\145\198J\tp\138\137'\ESC\157"] -// [PropTopicAlias 20522,PropCorrelationData "\128\138\241\234\135\208\f\231\197\205",PropAssignedClientIdentifier -// "\202\US\242By\224\DC1_U\DC2j\212\215\182\220\\\254\250r\207\197\rS\195\154\ETB\195",PropPayloadFormatIndicator -// 13,PropAuthenticationData "{\165\180\226^\145G,5:\153I\154-I\228>L",PropMessageExpiryInterval -// 5120,PropSubscriptionIdentifierAvailable 159,PropSubscriptionIdentifierAvailable 44,PropRequestProblemInformation -// 81,PropRequestResponseInformation 129,PropResponseTopic "\186\169\233\FS\248\225v\NUL",PropTopicAlias -// 13028,PropSubscriptionIdentifierAvailable 36] +// UnsubscribeRequest 1566 ["\248f\177\a\209\171O\234C","\r\207\164\185\187[\175","}\213\235~\236\226x"] +// [PropPayloadFormatIndicator 43,PropSharedSubscriptionAvailable 23,PropMessageExpiryInterval 84,PropWillDelayInterval +// 19220,PropWillDelayInterval 14718,PropRequestResponseInformation 241,PropRequestResponseInformation +// 131,PropTopicAliasMaximum 18345,PropResponseInformation "@\191\175\182 +// 0\ACK\238E\242\202\226\230iO3\167,\SUBY\167L\192",PropServerKeepAlive 32028,PropServerReference +// "\130e\186\188\244\DLE\141x;\162e\225\DC4\215\147o",PropSessionExpiryInterval 23135,PropTopicAlias +// 14739,PropSubscriptionIdentifier 7,PropWillDelayInterval 32745,PropWillDelayInterval 905,PropAuthenticationMethod +// "kI\237\243\192 u]\240\183\176>\144\161x",PropWildcardSubscriptionAvailable 144,PropSubscriptionIdentifier +// 14,PropTopicAliasMaximum 27090,PropSubscriptionIdentifier 30,PropPayloadFormatIndicator +// 231,PropPayloadFormatIndicator 1,PropServerKeepAlive 17503,PropRequestResponseInformation +// 103,PropSubscriptionIdentifier 3,PropSessionExpiryInterval 2807,PropResponseTopic +// "\244\133d~\141\194F\132ml0\193\148O\242"] TEST(Unsubscribe5QCTest, Encode4) { - uint8_t pkt[] = {0xa2, 0xa6, 0x1, 0x3d, 0xa3, 0x62, 0x23, 0x50, 0x2a, 0x9, 0x0, 0xa, 0x80, 0x8a, 0xf1, 0xea, 0x87, - 0xd0, 0xc, 0xe7, 0xc5, 0xcd, 0x12, 0x0, 0x1b, 0xca, 0x1f, 0xf2, 0x42, 0x79, 0xe0, 0x11, 0x5f, 0x55, - 0x12, 0x6a, 0xd4, 0xd7, 0xb6, 0xdc, 0x5c, 0xfe, 0xfa, 0x72, 0xcf, 0xc5, 0xd, 0x53, 0xc3, 0x9a, 0x17, - 0xc3, 0x1, 0xd, 0x16, 0x0, 0x12, 0x7b, 0xa5, 0xb4, 0xe2, 0x5e, 0x91, 0x47, 0x2c, 0x35, 0x3a, 0x99, - 0x49, 0x9a, 0x2d, 0x49, 0xe4, 0x3e, 0x4c, 0x2, 0x0, 0x0, 0x14, 0x0, 0x29, 0x9f, 0x29, 0x2c, 0x17, - 0x51, 0x19, 0x81, 0x8, 0x0, 0x8, 0xba, 0xa9, 0xe9, 0x1c, 0xf8, 0xe1, 0x76, 0x0, 0x23, 0x32, 0xe4, - 0x29, 0x24, 0x0, 0x1a, 0x71, 0x8f, 0xb3, 0x1a, 0xcb, 0xbf, 0xd5, 0xb1, 0x5d, 0x11, 0x94, 0x53, 0xaf, - 0x1b, 0xc8, 0x43, 0x35, 0x15, 0xf6, 0xa7, 0x72, 0x98, 0xc6, 0xfe, 0x3, 0x49, 0x0, 0x6, 0x6a, 0x76, - 0xf1, 0xd0, 0x1a, 0xd2, 0x0, 0xd, 0xb7, 0xc0, 0xde, 0x3b, 0x46, 0xfd, 0xf6, 0x76, 0x55, 0xb3, 0xf, - 0x4f, 0xde, 0x0, 0xc, 0x96, 0x54, 0x91, 0xc6, 0x4a, 0x9, 0x70, 0x8a, 0x89, 0x27, 0x1b, 0x9d}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x80, 0x8a, 0xf1, 0xea, 0x87, 0xd0, 0xc, 0xe7, 0xc5, 0xcd}; - uint8_t bytesprops1[] = {0xca, 0x1f, 0xf2, 0x42, 0x79, 0xe0, 0x11, 0x5f, 0x55, 0x12, 0x6a, 0xd4, 0xd7, 0xb6, - 0xdc, 0x5c, 0xfe, 0xfa, 0x72, 0xcf, 0xc5, 0xd, 0x53, 0xc3, 0x9a, 0x17, 0xc3}; - uint8_t bytesprops2[] = {0x7b, 0xa5, 0xb4, 0xe2, 0x5e, 0x91, 0x47, 0x2c, 0x35, - 0x3a, 0x99, 0x49, 0x9a, 0x2d, 0x49, 0xe4, 0x3e, 0x4c}; - uint8_t bytesprops3[] = {0xba, 0xa9, 0xe9, 0x1c, 0xf8, 0xe1, 0x76, 0x0}; + uint8_t pkt[] = {0xa2, 0xbc, 0x1, 0x6, 0x1e, 0x9b, 0x1, 0x1, 0x2b, 0x2a, 0x17, 0x2, 0x0, 0x0, 0x0, 0x54, + 0x18, 0x0, 0x0, 0x4b, 0x14, 0x18, 0x0, 0x0, 0x39, 0x7e, 0x19, 0xf1, 0x19, 0x83, 0x22, 0x47, + 0xa9, 0x1a, 0x0, 0x17, 0x40, 0xbf, 0xaf, 0xb6, 0x20, 0x30, 0x6, 0xee, 0x45, 0xf2, 0xca, 0xe2, + 0xe6, 0x69, 0x4f, 0x33, 0xa7, 0x2c, 0x1a, 0x59, 0xa7, 0x4c, 0xc0, 0x13, 0x7d, 0x1c, 0x1c, 0x0, + 0x10, 0x82, 0x65, 0xba, 0xbc, 0xf4, 0x10, 0x8d, 0x78, 0x3b, 0xa2, 0x65, 0xe1, 0x14, 0xd7, 0x93, + 0x6f, 0x11, 0x0, 0x0, 0x5a, 0x5f, 0x23, 0x39, 0x93, 0xb, 0x7, 0x18, 0x0, 0x0, 0x7f, 0xe9, + 0x18, 0x0, 0x0, 0x3, 0x89, 0x15, 0x0, 0xf, 0x6b, 0x49, 0xed, 0xf3, 0xc0, 0x20, 0x75, 0x5d, + 0xf0, 0xb7, 0xb0, 0x3e, 0x90, 0xa1, 0x78, 0x28, 0x90, 0xb, 0xe, 0x22, 0x69, 0xd2, 0xb, 0x1e, + 0x1, 0xe7, 0x1, 0x1, 0x13, 0x44, 0x5f, 0x19, 0x67, 0xb, 0x3, 0x11, 0x0, 0x0, 0xa, 0xf7, + 0x8, 0x0, 0xf, 0xf4, 0x85, 0x64, 0x7e, 0x8d, 0xc2, 0x46, 0x84, 0x6d, 0x6c, 0x30, 0xc1, 0x94, + 0x4f, 0xf2, 0x0, 0x9, 0xf8, 0x66, 0xb1, 0x7, 0xd1, 0xab, 0x4f, 0xea, 0x43, 0x0, 0x7, 0xd, + 0xcf, 0xa4, 0xb9, 0xbb, 0x5b, 0xaf, 0x0, 0x7, 0x7d, 0xd5, 0xeb, 0x7e, 0xec, 0xe2, 0x78}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x40, 0xbf, 0xaf, 0xb6, 0x20, 0x30, 0x6, 0xee, 0x45, 0xf2, 0xca, 0xe2, + 0xe6, 0x69, 0x4f, 0x33, 0xa7, 0x2c, 0x1a, 0x59, 0xa7, 0x4c, 0xc0}; + uint8_t bytesprops1[] = {0x82, 0x65, 0xba, 0xbc, 0xf4, 0x10, 0x8d, 0x78, + 0x3b, 0xa2, 0x65, 0xe1, 0x14, 0xd7, 0x93, 0x6f}; + uint8_t bytesprops2[] = {0x6b, 0x49, 0xed, 0xf3, 0xc0, 0x20, 0x75, 0x5d, 0xf0, 0xb7, 0xb0, 0x3e, 0x90, 0xa1, 0x78}; + uint8_t bytesprops3[] = {0xf4, 0x85, 0x64, 0x7e, 0x8d, 0xc2, 0x46, 0x84, 0x6d, 0x6c, 0x30, 0xc1, 0x94, 0x4f, 0xf2}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20522}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5120}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 129}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 13028}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 36}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 43}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 84}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19220}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14718}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 241}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 131}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18345}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 32028}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 23135}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 14739}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 7}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 32745}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 905}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {15, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 144}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 27090}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17503}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 103}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 2807}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x71, 0x8f, 0xb3, 0x1a, 0xcb, 0xbf, 0xd5, 0xb1, 0x5d, 0x11, 0x94, 0x53, 0xaf, - 0x1b, 0xc8, 0x43, 0x35, 0x15, 0xf6, 0xa7, 0x72, 0x98, 0xc6, 0xfe, 0x3, 0x49}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[3]; + uint8_t topic_filter_s0_bytes[] = {0xf8, 0x66, 0xb1, 0x7, 0xd1, 0xab, 0x4f, 0xea, 0x43}; + lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x6a, 0x76, 0xf1, 0xd0, 0x1a, 0xd2}; - lwmqtt_string_t topic_filter_s1 = {6, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd, 0xcf, 0xa4, 0xb9, 0xbb, 0x5b, 0xaf}; + lwmqtt_string_t topic_filter_s1 = {7, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xb7, 0xc0, 0xde, 0x3b, 0x46, 0xfd, 0xf6, 0x76, 0x55, 0xb3, 0xf, 0x4f, 0xde}; - lwmqtt_string_t topic_filter_s2 = {13, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7d, 0xd5, 0xeb, 0x7e, 0xec, 0xe2, 0x78}; + lwmqtt_string_t topic_filter_s2 = {7, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x96, 0x54, 0x91, 0xc6, 0x4a, 0x9, 0x70, 0x8a, 0x89, 0x27, 0x1b, 0x9d}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 15779, 4, topic_filters, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// UnsubscribeRequest 2710 -// ["\192e\229>\239\247\184\209\158w\SI_X0T","E\243","\225\CAN*E8Q\t-\252B\136.\247\185\250","\144e\204Xj","\195?}\251*\158\210a,W\235\&3\249\219Z\143;","\239\251","","\170/\199\164\194\231\210\t\165(#\r\235i\151d\176QN\SUBX\249\195",",\176%\165\203\137\141\230K\EOT\SUBc\197\155N\202\195\t","5\129\227KZ\180\&7\DC4y^","n\227a\231\134C~\181\163^]\213\146"] -// [PropServerReference "\206\FS\243\193\158ik\ENQ\207^K\233{\227\&3%\222\"\167\217\206\163&\204qn\241",PropUserProperty -// "\150q\131t\134u" "\STXC\\\205J\192\134\241\&3\170",PropRetainAvailable 182,PropRequestProblemInformation -// 103,PropWildcardSubscriptionAvailable 20,PropContentType -// "\249/\251u\250\138\n\133\128\226y\222{\167\137Z\183F\198jaw\SYN\215\252\201L",PropSubscriptionIdentifierAvailable -// 208,PropRetainAvailable 195,PropResponseInformation "4|\179+&\161\148m>g\192'\162\ETXO_\153",PropResponseInformation -// "l\137",PropMessageExpiryInterval 14662,PropSharedSubscriptionAvailable 87,PropServerKeepAlive 31815,PropTopicAlias -// 858,PropReceiveMaximum 19278,PropSubscriptionIdentifierAvailable 48,PropWildcardSubscriptionAvailable -// 33,PropTopicAlias 30007,PropRequestResponseInformation 64,PropAssignedClientIdentifier -// "\190\249\131\132M\145\168\EOT\213\187\183T\155~\147\146",PropAuthenticationMethod -// "\NAK\132\215R\NUL\DC3\208):\SYNZT7#\163c\203\185\138-yrNV\173\146",PropSubscriptionIdentifierAvailable -// 116,PropReceiveMaximum 4013,PropUserProperty "\182U\129\228>/\214\254\204" -// "\161\241|B\202\190\r?a\236\128\n\181^\230@\219p",PropServerKeepAlive 22624,PropMessageExpiryInterval 5586] + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1566, 3, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 22798 ["\214 +// Y}]\179\173\176\b\251]h\254\ESC\182,\133@\151j\ESC\159\GS","\233.\192\135\197\200\229\&2x\v\225\196\212\CAN}.","<\137}/\159\230\156\167b\178\157\205\GS\185","\198\243\228\142\132\168\RS\131\223\&6\253\217\SYN\SOHZ\159\185\243\244\138\136\SO\178\ESC\235\187\154\137","\213\213\156\129\DC2\206vq\233I\171\193\187}\168b\255\221\EM\253Z\195p\244\130","\SO\131z\DC4,5R\ENQ","\STX\193/\236>\189\241\&2\186v\186V\178\138\n\202\195\244\182\181_\ENQ\222\215\\+\177",")","\161.m\ESC\f\253a\221\167\t\199#","@\213\DC1\188GHQ\153\138\NAK\161A\ESC\161\162I\246Q\200\152?\251"] +// [PropMessageExpiryInterval 3679,PropUserProperty "\192\187F\SI" "Y\142\181\r\161\217",PropSharedSubscriptionAvailable +// 190,PropServerReference "-\ESC\171\&8\136\&2\171\179\139/\EOT[h\r4H",PropServerReference +// "^K\ENQ\201\&4\193\190\147\SI\229ws\229\223\250\\Z",PropSessionExpiryInterval 9553,PropRequestResponseInformation +// 33,PropPayloadFormatIndicator 78,PropAuthenticationData +// "u\214z\250F$\242\NUL\205\SOH\vc\147,\DC15\195\RSj\207\199\200\242\&6\202",PropWildcardSubscriptionAvailable +// 105,PropCorrelationData +// "z~o\221\CAN4M\US\166G\206AK,,\SOH\159\213\228(\148\144\CAN\164F",PropWildcardSubscriptionAvailable +// 9,PropRequestProblemInformation 40,PropResponseTopic "\204\&4/\234\232\252\220\235x\171\162\&3\159\240 +// \223\143\255yl9UplP",PropUserProperty "" +// "\SYN\f\165\250\168\&7l\244\234\161`\r\219\v\250\237\v<\218\158\146\203v\187\214\210",PropSubscriptionIdentifier +// 18,PropRequestResponseInformation 170,PropContentType +// "\246I\220\162y\f\197\247\235~\254p\171\221\209{r\GSW\182",PropResponseTopic +// "/\189\DLE{D\224\ETB\")\153\248L\242\164\216@G\DC3X\NAK\233\143y;\244\222",PropReceiveMaximum +// 7194,PropSessionExpiryInterval 3493,PropMessageExpiryInterval 13254,PropMaximumQoS 49,PropSharedSubscriptionAvailable +// 211,PropCorrelationData "\159\212!\144\194\&7\146",PropWillDelayInterval 5617,PropMaximumPacketSize 28573] TEST(Unsubscribe5QCTest, Encode5) { uint8_t pkt[] = { - 0xa2, 0xfc, 0x2, 0xa, 0x96, 0xea, 0x1, 0x1c, 0x0, 0x1b, 0xce, 0x1c, 0xf3, 0xc1, 0x9e, 0x69, 0x6b, 0x5, 0xcf, - 0x5e, 0x4b, 0xe9, 0x7b, 0xe3, 0x33, 0x25, 0xde, 0x22, 0xa7, 0xd9, 0xce, 0xa3, 0x26, 0xcc, 0x71, 0x6e, 0xf1, 0x26, - 0x0, 0x6, 0x96, 0x71, 0x83, 0x74, 0x86, 0x75, 0x0, 0xa, 0x2, 0x43, 0x5c, 0xcd, 0x4a, 0xc0, 0x86, 0xf1, 0x33, - 0xaa, 0x25, 0xb6, 0x17, 0x67, 0x28, 0x14, 0x3, 0x0, 0x1b, 0xf9, 0x2f, 0xfb, 0x75, 0xfa, 0x8a, 0xa, 0x85, 0x80, - 0xe2, 0x79, 0xde, 0x7b, 0xa7, 0x89, 0x5a, 0xb7, 0x46, 0xc6, 0x6a, 0x61, 0x77, 0x16, 0xd7, 0xfc, 0xc9, 0x4c, 0x29, - 0xd0, 0x25, 0xc3, 0x1a, 0x0, 0x11, 0x34, 0x7c, 0xb3, 0x2b, 0x26, 0xa1, 0x94, 0x6d, 0x3e, 0x67, 0xc0, 0x27, 0xa2, - 0x3, 0x4f, 0x5f, 0x99, 0x1a, 0x0, 0x2, 0x6c, 0x89, 0x2, 0x0, 0x0, 0x39, 0x46, 0x2a, 0x57, 0x13, 0x7c, 0x47, - 0x23, 0x3, 0x5a, 0x21, 0x4b, 0x4e, 0x29, 0x30, 0x28, 0x21, 0x23, 0x75, 0x37, 0x19, 0x40, 0x12, 0x0, 0x10, 0xbe, - 0xf9, 0x83, 0x84, 0x4d, 0x91, 0xa8, 0x4, 0xd5, 0xbb, 0xb7, 0x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x1a, 0x63, 0xc5, 0x9b, 0x4e, 0xca, 0xc3, 0x9, 0x0, 0xa, 0x35, 0x81, 0xe3, - 0x4b, 0x5a, 0xb4, 0x37, 0x14, 0x79, 0x5e, 0x0, 0xd, 0x6e, 0xe3, 0x61, 0xe7, 0x86, 0x43, 0x7e, 0xb5, 0xa3, 0x5e, - 0x5d, 0xd5, 0x92}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xce, 0x1c, 0xf3, 0xc1, 0x9e, 0x69, 0x6b, 0x5, 0xcf, 0x5e, 0x4b, 0xe9, 0x7b, 0xe3, - 0x33, 0x25, 0xde, 0x22, 0xa7, 0xd9, 0xce, 0xa3, 0x26, 0xcc, 0x71, 0x6e, 0xf1}; - uint8_t bytesprops2[] = {0x2, 0x43, 0x5c, 0xcd, 0x4a, 0xc0, 0x86, 0xf1, 0x33, 0xaa}; - uint8_t bytesprops1[] = {0x96, 0x71, 0x83, 0x74, 0x86, 0x75}; - uint8_t bytesprops3[] = {0xf9, 0x2f, 0xfb, 0x75, 0xfa, 0x8a, 0xa, 0x85, 0x80, 0xe2, 0x79, 0xde, 0x7b, 0xa7, - 0x89, 0x5a, 0xb7, 0x46, 0xc6, 0x6a, 0x61, 0x77, 0x16, 0xd7, 0xfc, 0xc9, 0x4c}; - uint8_t bytesprops4[] = {0x34, 0x7c, 0xb3, 0x2b, 0x26, 0xa1, 0x94, 0x6d, 0x3e, - 0x67, 0xc0, 0x27, 0xa2, 0x3, 0x4f, 0x5f, 0x99}; - uint8_t bytesprops5[] = {0x6c, 0x89}; - uint8_t bytesprops6[] = {0xbe, 0xf9, 0x83, 0x84, 0x4d, 0x91, 0xa8, 0x4, - 0xd5, 0xbb, 0xb7, 0x54, 0x9b, 0x7e, 0x93, 0x92}; - uint8_t bytesprops7[] = {0x15, 0x84, 0xd7, 0x52, 0x0, 0x13, 0xd0, 0x29, 0x3a, 0x16, 0x5a, 0x54, 0x37, - 0x23, 0xa3, 0x63, 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e1, 0xc4, 0xd4, 0x18, 0x7d, 0x2e, 0x0, 0xe, 0x3c, 0x89, 0x7d, 0x2f, 0x9f, 0xe6, + 0x9c, 0xa7, 0x62, 0xb2, 0x9d, 0xcd, 0x1d, 0xb9, 0x0, 0x1c, 0xc6, 0xf3, 0xe4, 0x8e, 0x84, 0xa8, 0x1e, 0x83, 0xdf, + 0x36, 0xfd, 0xd9, 0x16, 0x1, 0x5a, 0x9f, 0xb9, 0xf3, 0xf4, 0x8a, 0x88, 0xe, 0xb2, 0x1b, 0xeb, 0xbb, 0x9a, 0x89, + 0x0, 0x19, 0xd5, 0xd5, 0x9c, 0x81, 0x12, 0xce, 0x76, 0x71, 0xe9, 0x49, 0xab, 0xc1, 0xbb, 0x7d, 0xa8, 0x62, 0xff, + 0xdd, 0x19, 0xfd, 0x5a, 0xc3, 0x70, 0xf4, 0x82, 0x0, 0x8, 0xe, 0x83, 0x7a, 0x14, 0x2c, 0x35, 0x52, 0x5, 0x0, + 0x1b, 0x2, 0xc1, 0x2f, 0xec, 0x3e, 0xbd, 0xf1, 0x32, 0xba, 0x76, 0xba, 0x56, 0xb2, 0x8a, 0xa, 0xca, 0xc3, 0xf4, + 0xb6, 0xb5, 0x5f, 0x5, 0xde, 0xd7, 0x5c, 0x2b, 0xb1, 0x0, 0x1, 0x29, 0x0, 0xc, 0xa1, 0x2e, 0x6d, 0x1b, 0xc, + 0xfd, 0x61, 0xdd, 0xa7, 0x9, 0xc7, 0x23, 0x0, 0x16, 0x40, 0xd5, 0x11, 0xbc, 0x47, 0x48, 0x51, 0x99, 0x8a, 0x15, + 0xa1, 0x41, 0x1b, 0xa1, 0xa2, 0x49, 0xf6, 0x51, 0xc8, 0x98, 0x3f, 0xfb}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x59, 0x8e, 0xb5, 0xd, 0xa1, 0xd9}; + uint8_t bytesprops0[] = {0xc0, 0xbb, 0x46, 0xf}; + uint8_t bytesprops2[] = {0x2d, 0x1b, 0xab, 0x38, 0x88, 0x32, 0xab, 0xb3, + 0x8b, 0x2f, 0x4, 0x5b, 0x68, 0xd, 0x34, 0x48}; + uint8_t bytesprops3[] = {0x5e, 0x4b, 0x5, 0xc9, 0x34, 0xc1, 0xbe, 0x93, 0xf, + 0xe5, 0x77, 0x73, 0xe5, 0xdf, 0xfa, 0x5c, 0x5a}; + uint8_t bytesprops4[] = {0x75, 0xd6, 0x7a, 0xfa, 0x46, 0x24, 0xf2, 0x0, 0xcd, 0x1, 0xb, 0x63, 0x93, + 0x2c, 0x11, 0x35, 0xc3, 0x1e, 0x6a, 0xcf, 0xc7, 0xc8, 0xf2, 0x36, 0xca}; + uint8_t bytesprops5[] = {0x7a, 0x7e, 0x6f, 0xdd, 0x18, 0x34, 0x4d, 0x1f, 0xa6, 0x47, 0xce, 0x41, 0x4b, + 0x2c, 0x2c, 0x1, 0x9f, 0xd5, 0xe4, 0x28, 0x94, 0x90, 0x18, 0xa4, 0x46}; + uint8_t bytesprops6[] = {0xcc, 0x34, 0x2f, 0xea, 0xe8, 0xfc, 0xdc, 0xeb, 0x78, 0xab, 0xa2, 0x33, 0x9f, + 0xf0, 0x20, 0xdf, 0x8f, 0xff, 0x79, 0x6c, 0x39, 0x55, 0x70, 0x6c, 0x50}; + uint8_t bytesprops8[] = {0x16, 0xc, 0xa5, 0xfa, 0xa8, 0x37, 0x6c, 0xf4, 0xea, 0xa1, 0x60, 0xd, 0xdb, + 0xb, 0xfa, 0xed, 0xb, 0x3c, 0xda, 0x9e, 0x92, 0xcb, 0x76, 0xbb, 0xd6, 0xd2}; + uint8_t bytesprops7[] = {0}; + uint8_t bytesprops9[] = {0xf6, 0x49, 0xdc, 0xa2, 0x79, 0xc, 0xc5, 0xf7, 0xeb, 0x7e, + 0xfe, 0x70, 0xab, 0xdd, 0xd1, 0x7b, 0x72, 0x1d, 0x57, 0xb6}; + uint8_t bytesprops10[] = {0x2f, 0xbd, 0x10, 0x7b, 0x44, 0xe0, 0x17, 0x22, 0x29, 0x99, 0xf8, 0x4c, 0xf2, + 0xa4, 0xd8, 0x40, 0x47, 0x13, 0x58, 0x15, 0xe9, 0x8f, 0x79, 0x3b, 0xf4, 0xde}; + uint8_t bytesprops11[] = {0x9f, 0xd4, 0x21, 0x90, 0xc2, 0x37, 0x92}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops1}, .v = {10, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 182}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 103}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 208}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14662}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31815}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 858}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 19278}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 48}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 33}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30007}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 116}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4013}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {9, (char*)&bytesprops8}, .v = {18, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22624}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 5586}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3679}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {4, (char*)&bytesprops0}, .v = {6, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9553}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 78}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 105}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 40}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops7}, .v = {26, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7194}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3493}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13254}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 211}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5617}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 28573}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0xc0, 0x65, 0xe5, 0x3e, 0xef, 0xf7, 0xb8, 0xd1, - 0x9e, 0x77, 0xf, 0x5f, 0x58, 0x30, 0x54}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {27, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[10]; + uint8_t topic_filter_s0_bytes[] = {0xd6, 0x20, 0x59, 0x7d, 0x5d, 0xb3, 0xad, 0xb0, 0x8, 0xfb, 0x5d, 0x68, + 0xfe, 0x1b, 0xb6, 0x2c, 0x85, 0x40, 0x97, 0x6a, 0x1b, 0x9f, 0x1d}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x45, 0xf3}; - lwmqtt_string_t topic_filter_s1 = {2, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe9, 0x2e, 0xc0, 0x87, 0xc5, 0xc8, 0xe5, 0x32, + 0x78, 0xb, 0xe1, 0xc4, 0xd4, 0x18, 0x7d, 0x2e}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xe1, 0x18, 0x2a, 0x45, 0x38, 0x51, 0x9, 0x2d, - 0xfc, 0x42, 0x88, 0x2e, 0xf7, 0xb9, 0xfa}; - lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x3c, 0x89, 0x7d, 0x2f, 0x9f, 0xe6, 0x9c, + 0xa7, 0x62, 0xb2, 0x9d, 0xcd, 0x1d, 0xb9}; + lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x90, 0x65, 0xcc, 0x58, 0x6a}; - lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xc6, 0xf3, 0xe4, 0x8e, 0x84, 0xa8, 0x1e, 0x83, 0xdf, 0x36, + 0xfd, 0xd9, 0x16, 0x1, 0x5a, 0x9f, 0xb9, 0xf3, 0xf4, 0x8a, + 0x88, 0xe, 0xb2, 0x1b, 0xeb, 0xbb, 0x9a, 0x89}; + lwmqtt_string_t topic_filter_s3 = {28, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc3, 0x3f, 0x7d, 0xfb, 0x2a, 0x9e, 0xd2, 0x61, 0x2c, - 0x57, 0xeb, 0x33, 0xf9, 0xdb, 0x5a, 0x8f, 0x3b}; - lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xd5, 0xd5, 0x9c, 0x81, 0x12, 0xce, 0x76, 0x71, 0xe9, 0x49, 0xab, 0xc1, 0xbb, + 0x7d, 0xa8, 0x62, 0xff, 0xdd, 0x19, 0xfd, 0x5a, 0xc3, 0x70, 0xf4, 0x82}; + lwmqtt_string_t topic_filter_s4 = {25, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xef, 0xfb}; - lwmqtt_string_t topic_filter_s5 = {2, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xe, 0x83, 0x7a, 0x14, 0x2c, 0x35, 0x52, 0x5}; + lwmqtt_string_t topic_filter_s5 = {8, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x2, 0xc1, 0x2f, 0xec, 0x3e, 0xbd, 0xf1, 0x32, 0xba, 0x76, 0xba, 0x56, 0xb2, 0x8a, + 0xa, 0xca, 0xc3, 0xf4, 0xb6, 0xb5, 0x5f, 0x5, 0xde, 0xd7, 0x5c, 0x2b, 0xb1}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xaa, 0x2f, 0xc7, 0xa4, 0xc2, 0xe7, 0xd2, 0x9, 0xa5, 0x28, 0x23, 0xd, - 0xeb, 0x69, 0x97, 0x64, 0xb0, 0x51, 0x4e, 0x1a, 0x58, 0xf9, 0xc3}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x29}; + lwmqtt_string_t topic_filter_s7 = {1, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x2c, 0xb0, 0x25, 0xa5, 0xcb, 0x89, 0x8d, 0xe6, 0x4b, - 0x4, 0x1a, 0x63, 0xc5, 0x9b, 0x4e, 0xca, 0xc3, 0x9}; - lwmqtt_string_t topic_filter_s8 = {18, (char*)&topic_filter_s8_bytes}; + uint8_t topic_filter_s8_bytes[] = {0xa1, 0x2e, 0x6d, 0x1b, 0xc, 0xfd, 0x61, 0xdd, 0xa7, 0x9, 0xc7, 0x23}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x35, 0x81, 0xe3, 0x4b, 0x5a, 0xb4, 0x37, 0x14, 0x79, 0x5e}; - lwmqtt_string_t topic_filter_s9 = {10, (char*)&topic_filter_s9_bytes}; + uint8_t topic_filter_s9_bytes[] = {0x40, 0xd5, 0x11, 0xbc, 0x47, 0x48, 0x51, 0x99, 0x8a, 0x15, 0xa1, + 0x41, 0x1b, 0xa1, 0xa2, 0x49, 0xf6, 0x51, 0xc8, 0x98, 0x3f, 0xfb}; + lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x6e, 0xe3, 0x61, 0xe7, 0x86, 0x43, 0x7e, 0xb5, 0xa3, 0x5e, 0x5d, 0xd5, 0x92}; - lwmqtt_string_t topic_filter_s10 = {13, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 2710, 11, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22798, 10, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5130 -// ["\246\197\169\&5\b\231f\149\170\236\240\171d\142Uq\241\RS\138\&2\222\160F\162\243\176NN\249\208","\STXt(\EM\234#}\242B~\248","","\166\"\128\192\131x\151\250\FS\RS\150\175n~CD0apa[B\212\163",PropRequestResponseInformation 73,PropServerReference -// "\220!\196\255v\205\238\246",PropWillDelayInterval 18917,PropRequestProblemInformation 227,PropAuthenticationMethod -// "\180 \156\EOT\165\ENQ\DC4\173\231\ENQ\DEL\fNsC\148\163\241\221\207\CAN\SOH\209",PropResponseTopic -// "'m\175\213\RSS\131\133F\133+%L;\138M\224",PropSharedSubscriptionAvailable 118,PropResponseInformation -// "\GS/\236\200\FSS\217\210\EM\154\224\217",PropContentType "\252\a\228\NULL<\RS\223\r\186\137\191\253\200\183\ACK"] +// UnsubscribeRequest 24222 +// ["5\171","\213JI\161N\156\190\210I\")\SUB\177f","r\254N;","\150\129\236\130\164\ESC\186o\184[\228\&4\155\160\"9\181\195Ke\DC3k\228\&5Y\EOT\GS\ENQ\ACK\185","x\173\243\136\&49t\232\193M\EMU\245k1\234s\177\148@\SYN\SO\245\STX\228\138","y\248\215"] +// [PropSharedSubscriptionAvailable 157,PropMaximumPacketSize 20413,PropSessionExpiryInterval 3299,PropTopicAlias +// 18064,PropTopicAlias 23902,PropRequestResponseInformation 201,PropPayloadFormatIndicator 200] TEST(Unsubscribe5QCTest, Encode6) { - uint8_t pkt[] = { - 0xa2, 0xe6, 0x2, 0x14, 0xa, 0xde, 0x1, 0x29, 0xf9, 0x15, 0x0, 0xc, 0xd, 0x59, 0x61, 0x34, 0xc6, 0xac, 0x1b, - 0x7d, 0x5, 0xdc, 0xed, 0x23, 0x24, 0xa2, 0x17, 0x55, 0x12, 0x0, 0x1a, 0x6f, 0xd0, 0xda, 0xdf, 0x64, 0x3a, 0xe3, - 0x67, 0x8e, 0xb6, 0xc7, 0xba, 0x43, 0x11, 0x14, 0x6b, 0xd4, 0xe, 0x67, 0x20, 0xd2, 0x4f, 0xe2, 0xd, 0x31, 0x94, - 0x8, 0x0, 0x4, 0xb5, 0x15, 0x80, 0xe2, 0x1f, 0x0, 0x9, 0x46, 0x2d, 0xf, 0xb9, 0xf3, 0x17, 0xf2, 0x55, 0xfe, - 0x1f, 0x0, 0x1, 0x75, 0x2, 0x0, 0x0, 0x47, 0xe1, 0x17, 0xd4, 0x29, 0xf8, 0x17, 0x1, 0x18, 0x0, 0x0, 0x2c, - 0xbb, 0x27, 0x0, 0x0, 0x69, 0x43, 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, 0xb0, 0x42, 0x53, 0x9e, 0x44, 0xb, 0x18, 0x81, 0x98, 0x38, 0x0, 0x13, 0xfb, 0xb5, 0xb2, 0xc9, 0x93, - 0xb0, 0x6e, 0x73, 0x70, 0x9a, 0xb, 0x93, 0x41, 0x31, 0x61, 0xbe, 0xd0, 0x15, 0xde, 0x0, 0xc, 0x3c, 0x7, 0x51, - 0xc8, 0xee, 0x22, 0x84, 0x70, 0x76, 0x2a, 0xca, 0x8f, 0x0, 0x6, 0x4d, 0xc8, 0xc8, 0x5a, 0x8b, 0xee, 0x0, 0x13, - 0x91, 0x8f, 0xc0, 0x54, 0x62, 0x28, 0x2d, 0x79, 0xb8, 0xfc, 0x59, 0x71, 0x40, 0x4a, 0x5f, 0xa, 0xc9, 0x72, 0x45}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xd, 0x59, 0x61, 0x34, 0xc6, 0xac, 0x1b, 0x7d, 0x5, 0xdc, 0xed, 0x23}; - uint8_t bytesprops1[] = {0x6f, 0xd0, 0xda, 0xdf, 0x64, 0x3a, 0xe3, 0x67, 0x8e, 0xb6, 0xc7, 0xba, 0x43, - 0x11, 0x14, 0x6b, 0xd4, 0xe, 0x67, 0x20, 0xd2, 0x4f, 0xe2, 0xd, 0x31, 0x94}; - uint8_t bytesprops2[] = {0xb5, 0x15, 0x80, 0xe2}; - uint8_t bytesprops3[] = {0x46, 0x2d, 0xf, 0xb9, 0xf3, 0x17, 0xf2, 0x55, 0xfe}; - uint8_t bytesprops4[] = {0x75}; - uint8_t bytesprops5[] = {0x32, 0xf2, 0x3e, 0x97, 0xfa, 0x1c, 0x1e, 0x96, 0xaf, 0x6e, 0x7e, - 0x43, 0x44, 0x30, 0x61, 0x70, 0x61, 0x5b, 0x42, 0xd4, 0xa3}; - uint8_t bytesprops6[] = {0xdc, 0x21, 0xc4, 0xff, 0x76, 0xcd, 0xee, 0xf6}; - uint8_t bytesprops7[] = {0xb4, 0x20, 0x9c, 0x4, 0xa5, 0x5, 0x14, 0xad, 0xe7, 0x5, 0x7f, 0xc, - 0x4e, 0x73, 0x43, 0x94, 0xa3, 0xf1, 0xdd, 0xcf, 0x18, 0x1, 0xd1}; - uint8_t bytesprops8[] = {0x27, 0x6d, 0xaf, 0xd5, 0x1e, 0x53, 0x83, 0x85, 0x46, - 0x85, 0x2b, 0x25, 0x4c, 0x3b, 0x8a, 0x4d, 0xe0}; - uint8_t bytesprops9[] = {0x1d, 0x2f, 0xec, 0xc8, 0x1c, 0x53, 0xd9, 0xd2, 0x19, 0x9a, 0xe0, 0xd9}; - uint8_t bytesprops10[] = {0xfc, 0x7, 0xe4, 0x0, 0x4c, 0x3c, 0x1e, 0xdf, 0xd, 0xba, 0x89, 0xbf, 0xfd, 0xc8, 0xb7, 0x6}; + uint8_t pkt[] = {0xa2, 0x74, 0x5e, 0x9e, 0x16, 0x2a, 0x9d, 0x27, 0x0, 0x0, 0x4f, 0xbd, 0x11, 0x0, 0x0, 0xc, 0xe3, + 0x23, 0x46, 0x90, 0x23, 0x5d, 0x5e, 0x19, 0xc9, 0x1, 0xc8, 0x0, 0x2, 0x35, 0xab, 0x0, 0xe, 0xd5, + 0x4a, 0x49, 0xa1, 0x4e, 0x9c, 0xbe, 0xd2, 0x49, 0x22, 0x29, 0x1a, 0xb1, 0x66, 0x0, 0x4, 0x72, 0xfe, + 0x4e, 0x3b, 0x0, 0x1e, 0x96, 0x81, 0xec, 0x82, 0xa4, 0x1b, 0xba, 0x6f, 0xb8, 0x5b, 0xe4, 0x34, 0x9b, + 0xa0, 0x22, 0x39, 0xb5, 0xc3, 0x4b, 0x65, 0x13, 0x6b, 0xe4, 0x35, 0x59, 0x4, 0x1d, 0x5, 0x6, 0xb9, + 0x0, 0x1a, 0x78, 0xad, 0xf3, 0x88, 0x34, 0x39, 0x74, 0xe8, 0xc1, 0x4d, 0x19, 0x55, 0xf5, 0x6b, 0x31, + 0xea, 0x73, 0xb1, 0x94, 0x40, 0x16, 0xe, 0xf5, 0x2, 0xe4, 0x8a, 0x0, 0x3, 0x79, 0xf8, 0xd7}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 249}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 162}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 85}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18401}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 212}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 248}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 1}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 11451}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26947}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18917}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {23, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {17, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 157}}, {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 20413}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3299}}, {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18064}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 23902}}, {.prop = (lwmqtt_prop_t)25, .value = {.byte = 201}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 200}}, }; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0xf6, 0xc5, 0xa9, 0x35, 0x8, 0xe7, 0x66, 0x95, 0xaa, 0xec, - 0xf0, 0xab, 0x64, 0x8e, 0x55, 0x71, 0xf1, 0x1e, 0x8a, 0x32, - 0xde, 0xa0, 0x46, 0xa2, 0xf3, 0xb0, 0x4e, 0x4e, 0xf9, 0xd0}; - lwmqtt_string_t topic_filter_s0 = {30, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x35, 0xab}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x2, 0x74, 0x28, 0x19, 0xea, 0x23, 0x7d, 0xf2, 0x42, 0x7e, 0xf8}; - lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd5, 0x4a, 0x49, 0xa1, 0x4e, 0x9c, 0xbe, + 0xd2, 0x49, 0x22, 0x29, 0x1a, 0xb1, 0x66}; + lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0}; - lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x72, 0xfe, 0x4e, 0x3b}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xa6, 0x22, 0x80, 0xc0, 0x83, 0x78, 0x3c, 0x50, 0x74, 0xb0, - 0x42, 0x53, 0x9e, 0x44, 0xb, 0x18, 0x81, 0x98, 0x38}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x96, 0x81, 0xec, 0x82, 0xa4, 0x1b, 0xba, 0x6f, 0xb8, 0x5b, + 0xe4, 0x34, 0x9b, 0xa0, 0x22, 0x39, 0xb5, 0xc3, 0x4b, 0x65, + 0x13, 0x6b, 0xe4, 0x35, 0x59, 0x4, 0x1d, 0x5, 0x6, 0xb9}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xfb, 0xb5, 0xb2, 0xc9, 0x93, 0xb0, 0x6e, 0x73, 0x70, 0x9a, - 0xb, 0x93, 0x41, 0x31, 0x61, 0xbe, 0xd0, 0x15, 0xde}; - lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x78, 0xad, 0xf3, 0x88, 0x34, 0x39, 0x74, 0xe8, 0xc1, 0x4d, 0x19, 0x55, 0xf5, + 0x6b, 0x31, 0xea, 0x73, 0xb1, 0x94, 0x40, 0x16, 0xe, 0xf5, 0x2, 0xe4, 0x8a}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x3c, 0x7, 0x51, 0xc8, 0xee, 0x22, 0x84, 0x70, 0x76, 0x2a, 0xca, 0x8f}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x79, 0xf8, 0xd7}; + lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x4d, 0xc8, 0xc8, 0x5a, 0x8b, 0xee}; - lwmqtt_string_t topic_filter_s6 = {6, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x91, 0x8f, 0xc0, 0x54, 0x62, 0x28, 0x2d, 0x79, 0xb8, 0xfc, - 0x59, 0x71, 0x40, 0x4a, 0x5f, 0xa, 0xc9, 0x72, 0x45}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5130, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24222, 6, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 10000 -// ["\FS\130\191W5L\182\156$\165\150tm\255l\234\202\179\208>\219\194\231\DELs\163","\188\202\DLE\SO\251z!\203\ETB\156.Mu\241\151","s\132\130\222\fE\142T\128\&3\v\230\218\&2\210_G6\128\220\251\STX","\t\171%#\219\251\SOH}\175@O\169","1d\CAN\f\SOH\183\253%F*","\195f\ry\161\STX\235\147\NAK\\\189\168","\SUBq;\RS\183\209\228z\166\187\217\155\EM\133[\133:\252\148\SYN","\207\ETB\179"] -// [PropRequestResponseInformation 152,PropResponseInformation "\231x\165\\\183hU\131\196\GS\STXo\DC2<\203t\168z\155"] +// UnsubscribeRequest 12540 ["\142\149\170v\174V',D\DELQ=,\212\228v"] [PropResponseInformation +// "\160$\163\&7?\212\217fD{\137\245\195\129\218\223\178\EOTQ\EOT\255\&1i\158\246;\213",PropAuthenticationMethod +// "\150\b\134\180-e\SOKU{4\239\171\DC4\191\STX",PropResponseTopic "\180\191( \176\228\SOH\184\196\154",PropMaximumQoS +// 130,PropTopicAliasMaximum 14742,PropCorrelationData "hf\153\162\181\219\&6\237"] TEST(Unsubscribe5QCTest, Encode7) { - uint8_t pkt[] = {0xa2, 0xa3, 0x1, 0x27, 0x10, 0x18, 0x19, 0x98, 0x1a, 0x0, 0x13, 0xe7, 0x78, 0xa5, 0x5c, 0xb7, 0x68, - 0x55, 0x83, 0xc4, 0x1d, 0x2, 0x6f, 0x12, 0x3c, 0xcb, 0x74, 0xa8, 0x7a, 0x9b, 0x0, 0x1a, 0x1c, 0x82, - 0xbf, 0x57, 0x35, 0x4c, 0xb6, 0x9c, 0x24, 0xa5, 0x96, 0x74, 0x6d, 0xff, 0x6c, 0xea, 0xca, 0xb3, 0xd0, - 0x3e, 0xdb, 0xc2, 0xe7, 0x7f, 0x73, 0xa3, 0x0, 0xf, 0xbc, 0xca, 0x10, 0xe, 0xfb, 0x7a, 0x21, 0xcb, - 0x17, 0x9c, 0x2e, 0x4d, 0x75, 0xf1, 0x97, 0x0, 0x16, 0x73, 0x84, 0x82, 0xde, 0xc, 0x45, 0x8e, 0x54, - 0x80, 0x33, 0xb, 0xe6, 0xda, 0x32, 0xd2, 0x5f, 0x47, 0x36, 0x80, 0xdc, 0xfb, 0x2, 0x0, 0xc, 0x9, - 0xab, 0x25, 0x23, 0xdb, 0xfb, 0x1, 0x7d, 0xaf, 0x40, 0x4f, 0xa9, 0x0, 0xa, 0x31, 0x64, 0x18, 0xc, - 0x1, 0xb7, 0xfd, 0x25, 0x46, 0x2a, 0x0, 0xc, 0xc3, 0x66, 0xd, 0x79, 0xa1, 0x2, 0xeb, 0x93, 0x15, - 0x5c, 0xbd, 0xa8, 0x0, 0x14, 0x1a, 0x71, 0x3b, 0x1e, 0xb7, 0xd1, 0xe4, 0x7a, 0xa6, 0xbb, 0xd9, 0x9b, - 0x19, 0x85, 0x5b, 0x85, 0x3a, 0xfc, 0x94, 0x16, 0x0, 0x3, 0xcf, 0x17, 0xb3}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xe7, 0x78, 0xa5, 0x5c, 0xb7, 0x68, 0x55, 0x83, 0xc4, 0x1d, - 0x2, 0x6f, 0x12, 0x3c, 0xcb, 0x74, 0xa8, 0x7a, 0x9b}; + uint8_t pkt[] = {0xa2, 0x63, 0x30, 0xfc, 0x4e, 0x1a, 0x0, 0x1b, 0xa0, 0x24, 0xa3, 0x37, 0x3f, 0xd4, 0xd9, 0x66, 0x44, + 0x7b, 0x89, 0xf5, 0xc3, 0x81, 0xda, 0xdf, 0xb2, 0x4, 0x51, 0x4, 0xff, 0x31, 0x69, 0x9e, 0xf6, 0x3b, + 0xd5, 0x15, 0x0, 0x10, 0x96, 0x8, 0x86, 0xb4, 0x2d, 0x65, 0xe, 0x4b, 0x55, 0x7b, 0x34, 0xef, 0xab, + 0x14, 0xbf, 0x2, 0x8, 0x0, 0xa, 0xb4, 0xbf, 0x28, 0x20, 0xb0, 0xe4, 0x1, 0xb8, 0xc4, 0x9a, 0x24, + 0x82, 0x22, 0x39, 0x96, 0x9, 0x0, 0x8, 0x68, 0x66, 0x99, 0xa2, 0xb5, 0xdb, 0x36, 0xed, 0x0, 0x10, + 0x8e, 0x95, 0xaa, 0x76, 0xae, 0x56, 0x27, 0x2c, 0x44, 0x7f, 0x51, 0x3d, 0x2c, 0xd4, 0xe4, 0x76}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xa0, 0x24, 0xa3, 0x37, 0x3f, 0xd4, 0xd9, 0x66, 0x44, 0x7b, 0x89, 0xf5, 0xc3, 0x81, + 0xda, 0xdf, 0xb2, 0x4, 0x51, 0x4, 0xff, 0x31, 0x69, 0x9e, 0xf6, 0x3b, 0xd5}; + uint8_t bytesprops1[] = {0x96, 0x8, 0x86, 0xb4, 0x2d, 0x65, 0xe, 0x4b, 0x55, 0x7b, 0x34, 0xef, 0xab, 0x14, 0xbf, 0x2}; + uint8_t bytesprops2[] = {0xb4, 0xbf, 0x28, 0x20, 0xb0, 0xe4, 0x1, 0xb8, 0xc4, 0x9a}; + uint8_t bytesprops3[] = {0x68, 0x66, 0x99, 0xa2, 0xb5, 0xdb, 0x36, 0xed}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 152}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14742}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {8, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x1c, 0x82, 0xbf, 0x57, 0x35, 0x4c, 0xb6, 0x9c, 0x24, 0xa5, 0x96, 0x74, 0x6d, - 0xff, 0x6c, 0xea, 0xca, 0xb3, 0xd0, 0x3e, 0xdb, 0xc2, 0xe7, 0x7f, 0x73, 0xa3}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x8e, 0x95, 0xaa, 0x76, 0xae, 0x56, 0x27, 0x2c, + 0x44, 0x7f, 0x51, 0x3d, 0x2c, 0xd4, 0xe4, 0x76}; + lwmqtt_string_t topic_filter_s0 = {16, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xbc, 0xca, 0x10, 0xe, 0xfb, 0x7a, 0x21, 0xcb, - 0x17, 0x9c, 0x2e, 0x4d, 0x75, 0xf1, 0x97}; - lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x73, 0x84, 0x82, 0xde, 0xc, 0x45, 0x8e, 0x54, 0x80, 0x33, 0xb, - 0xe6, 0xda, 0x32, 0xd2, 0x5f, 0x47, 0x36, 0x80, 0xdc, 0xfb, 0x2}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x9, 0xab, 0x25, 0x23, 0xdb, 0xfb, 0x1, 0x7d, 0xaf, 0x40, 0x4f, 0xa9}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x31, 0x64, 0x18, 0xc, 0x1, 0xb7, 0xfd, 0x25, 0x46, 0x2a}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xc3, 0x66, 0xd, 0x79, 0xa1, 0x2, 0xeb, 0x93, 0x15, 0x5c, 0xbd, 0xa8}; - lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x1a, 0x71, 0x3b, 0x1e, 0xb7, 0xd1, 0xe4, 0x7a, 0xa6, 0xbb, - 0xd9, 0x9b, 0x19, 0x85, 0x5b, 0x85, 0x3a, 0xfc, 0x94, 0x16}; - lwmqtt_string_t topic_filter_s6 = {20, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xcf, 0x17, 0xb3}; - lwmqtt_string_t topic_filter_s7 = {3, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10000, 8, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12540, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 27754 ["\172U5\DEL\CAN\228","8\240H\r\196\215\174\249;\DEL","\196\130@ -// \243\239\224\EM\205\229\136\207\254\167\223\132\193\tA\194A\245\NUL","\224\222\248\EOT\133p^\181\176C\236i7\193\233","\196\184Q\132\RS\SYN&y-\220\&3\GSN\220\172i\ENQ-\143\&9\b\203\226z\253\SI\ACK","\DC1\DC2\SOH\203\"\201\150\136G\ACK\DC3","Y;\167C\134\239\208\r\219\234J\222\197*R\184\150L.\\\178&\NUL\221\229\185\222]","\252\225\DC2~\145\SUBH\232\240\145\206m_u\146*$\254\SYNI\\\174\rk1\157\&5\253\&3\220","1r\226\USM\210o\252\161=\241","]\201\&9"] -// [PropCorrelationData "\236u\137\RS\NAK\136\209{",PropSubscriptionIdentifierAvailable 53,PropAuthenticationData -// "5\255\183l!9\173\162\181\157\159*K\238\131\171\253%\SOH\150\165\226"] +// UnsubscribeRequest 30589 +// [",\131\ETB\170\237\194/\147\140iM\159*x\159V\134","\STX\142\DC1r\DC1\130\183\v\211\183\147\192\211\194\165\200\139I\DEL\174P\171\255p\201p\237","\188\US\DC3\"\224\FSr\215Z\r\207=\155\153\210@\168k\194\b\200Wlh!\US",PropReceiveMaximum -// 5693,PropSharedSubscriptionAvailable 209,PropServerKeepAlive 8126,PropSubscriptionIdentifierAvailable -// 188,PropTopicAliasMaximum 6378,PropWildcardSubscriptionAvailable 112,PropMessageExpiryInterval 9354,PropReasonString -// "L\142K\176\GS\240N*)\198? \241\156\146\218#K\186\195\176-\187\164",PropRetainAvailable 127,PropMessageExpiryInterval -// 13953,PropRequestResponseInformation 67,PropWillDelayInterval 27638,PropResponseInformation -// "\169\ETX\197s\196<\153\151\201\133\137\n\FS\DC4\170\134wL+\ESCp\STX\205",PropTopicAliasMaximum 18649] +// UnsubscribeRequest 27478 +// ["\129F\DC4\165ex\135W^\163\&7[\FS\128\FS\187\238\203\243$\202\FS\a","\228w\158\242\186\249\DC1\234\a\219\198\193\172\135Y\161\137\&9>\rg\233 +// \140\235\ETX\218ZA","S\ETB\255w\US\250\184\&8E\171\173","\EM\ETB8\ESCN","2\230c\246\211\&1\216\150\202\221\173w\147\232$\132pD\236","\186\157\201\165\158\210\ETB\232\194\236\&2<","\GS]\181\179\142\190\230\242(&\196`\142\131\184\\\243"] +// [PropServerKeepAlive 17083,PropTopicAliasMaximum 22420,PropResponseTopic +// "y\224\224\ACKA\DC3L\132~\DC2\ETBz\249\SOH\230\206\191g\a\148\175G\nh8\129\EOTk",PropAssignedClientIdentifier +// "\238\152n\236X\244G\161\144\149\a\128",PropServerReference "\ACK\149W\SI*\240(Y",PropContentType +// "\161,5\SO\228\185\169yz\239Y\DC2\238\141^\DC1\245n\177u\b\158$\US7@\160",PropRetainAvailable +// 84,PropSubscriptionIdentifierAvailable 223] TEST(Unsubscribe5QCTest, Encode9) { - uint8_t pkt[] = { - 0xa2, 0xb9, 0x1, 0x34, 0xdc, 0xa7, 0x1, 0x22, 0x49, 0x52, 0x15, 0x0, 0x12, 0xc3, 0x67, 0x39, 0x8a, 0x69, 0x42, - 0xf, 0x70, 0x17, 0x5, 0xbc, 0x7b, 0x63, 0x6e, 0x41, 0x7d, 0x6e, 0x45, 0x8, 0x0, 0x8, 0x96, 0x90, 0x5, 0xca, - 0xb2, 0xa1, 0xaf, 0xa6, 0x8, 0x0, 0x2, 0xb9, 0x7b, 0x17, 0xf3, 0x28, 0xaf, 0x19, 0x8d, 0x8, 0x0, 0x1c, 0x5a, - 0xe0, 0xf9, 0x3e, 0x13, 0x22, 0xe0, 0x1c, 0x72, 0xd7, 0x5a, 0xd, 0xcf, 0x3d, 0x9b, 0x99, 0xd2, 0x40, 0xa8, 0x6b, - 0xc2, 0x8, 0xc8, 0x57, 0x6c, 0x68, 0x21, 0x1f, 0x21, 0x16, 0x3d, 0x2a, 0xd1, 0x13, 0x1f, 0xbe, 0x29, 0xbc, 0x22, - 0x18, 0xea, 0x28, 0x70, 0x2, 0x0, 0x0, 0x24, 0x8a, 0x1f, 0x0, 0x18, 0x4c, 0x8e, 0x4b, 0xb0, 0x1d, 0xf0, 0x4e, - 0x2a, 0x29, 0xc6, 0x3f, 0x20, 0xf1, 0x9c, 0x92, 0xda, 0x23, 0x4b, 0xba, 0xc3, 0xb0, 0x2d, 0xbb, 0xa4, 0x25, 0x7f, - 0x2, 0x0, 0x0, 0x36, 0x81, 0x19, 0x43, 0x18, 0x0, 0x0, 0x6b, 0xf6, 0x1a, 0x0, 0x17, 0xa9, 0x3, 0xc5, 0x73, - 0xc4, 0x3c, 0x99, 0x97, 0xc9, 0x85, 0x89, 0xa, 0x1c, 0x14, 0xaa, 0x86, 0x77, 0x4c, 0x2b, 0x1b, 0x70, 0x2, 0xcd, - 0x22, 0x48, 0xd9, 0x0, 0x7, 0xf0, 0x1c, 0x5b, 0x98, 0x10, 0xe2, 0x99, 0x0, 0x3, 0xef, 0x3f, 0xaa}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xc3, 0x67, 0x39, 0x8a, 0x69, 0x42, 0xf, 0x70, 0x17, - 0x5, 0xbc, 0x7b, 0x63, 0x6e, 0x41, 0x7d, 0x6e, 0x45}; - uint8_t bytesprops1[] = {0x96, 0x90, 0x5, 0xca, 0xb2, 0xa1, 0xaf, 0xa6}; - uint8_t bytesprops2[] = {0xb9, 0x7b}; - uint8_t bytesprops3[] = {0x5a, 0xe0, 0xf9, 0x3e, 0x13, 0x22, 0xe0, 0x1c, 0x72, 0xd7, 0x5a, 0xd, 0xcf, 0x3d, - 0x9b, 0x99, 0xd2, 0x40, 0xa8, 0x6b, 0xc2, 0x8, 0xc8, 0x57, 0x6c, 0x68, 0x21, 0x1f}; - uint8_t bytesprops4[] = {0x4c, 0x8e, 0x4b, 0xb0, 0x1d, 0xf0, 0x4e, 0x2a, 0x29, 0xc6, 0x3f, 0x20, - 0xf1, 0x9c, 0x92, 0xda, 0x23, 0x4b, 0xba, 0xc3, 0xb0, 0x2d, 0xbb, 0xa4}; - uint8_t bytesprops5[] = {0xa9, 0x3, 0xc5, 0x73, 0xc4, 0x3c, 0x99, 0x97, 0xc9, 0x85, 0x89, 0xa, - 0x1c, 0x14, 0xaa, 0x86, 0x77, 0x4c, 0x2b, 0x1b, 0x70, 0x2, 0xcd}; + uint8_t pkt[] = {0xa2, 0xe6, 0x1, 0x6b, 0x56, 0x61, 0x13, 0x42, 0xbb, 0x22, 0x57, 0x94, 0x8, 0x0, 0x1c, 0x79, 0xe0, + 0xe0, 0x6, 0x41, 0x13, 0x4c, 0x84, 0x7e, 0x12, 0x17, 0x7a, 0xf9, 0x1, 0xe6, 0xce, 0xbf, 0x67, 0x7, + 0x94, 0xaf, 0x47, 0xa, 0x68, 0x38, 0x81, 0x4, 0x6b, 0x12, 0x0, 0xc, 0xee, 0x98, 0x6e, 0xec, 0x58, + 0xf4, 0x47, 0xa1, 0x90, 0x95, 0x7, 0x80, 0x1c, 0x0, 0x8, 0x6, 0x95, 0x57, 0xf, 0x2a, 0xf0, 0x28, + 0x59, 0x3, 0x0, 0x1b, 0xa1, 0x2c, 0x35, 0xe, 0xe4, 0xb9, 0xa9, 0x79, 0x7a, 0xef, 0x59, 0x12, 0xee, + 0x8d, 0x5e, 0x11, 0xf5, 0x6e, 0xb1, 0x75, 0x8, 0x9e, 0x24, 0x1f, 0x37, 0x40, 0xa0, 0x25, 0x54, 0x29, + 0xdf, 0x0, 0x17, 0x81, 0x46, 0x14, 0xa5, 0x65, 0x78, 0x87, 0x57, 0x5e, 0xa3, 0x37, 0x5b, 0x1c, 0x80, + 0x1c, 0xbb, 0xee, 0xcb, 0xf3, 0x24, 0xca, 0x1c, 0x7, 0x0, 0x1d, 0xe4, 0x77, 0x9e, 0xf2, 0xba, 0xf9, + 0x11, 0xea, 0x7, 0xdb, 0xc6, 0xc1, 0xac, 0x87, 0x59, 0xa1, 0x89, 0x39, 0x3e, 0xd, 0x67, 0xe9, 0x20, + 0x8c, 0xeb, 0x3, 0xda, 0x5a, 0x41, 0x0, 0xb, 0x53, 0x17, 0xff, 0x77, 0x1f, 0xfa, 0xb8, 0x38, 0x45, + 0xab, 0xad, 0x0, 0x5, 0x19, 0x17, 0x38, 0x1b, 0x4e, 0x0, 0x13, 0x32, 0xe6, 0x63, 0xf6, 0xd3, 0x31, + 0xd8, 0x96, 0xca, 0xdd, 0xad, 0x77, 0x93, 0xe8, 0x24, 0x84, 0x70, 0x44, 0xec, 0x0, 0xc, 0xba, 0x9d, + 0xc9, 0xa5, 0x9e, 0xd2, 0x17, 0xe8, 0xc2, 0xec, 0x32, 0x3c, 0x0, 0x11, 0x1d, 0x5d, 0xb5, 0xb3, 0x8e, + 0xbe, 0xe6, 0xf2, 0x28, 0x26, 0xc4, 0x60, 0x8e, 0x83, 0xb8, 0x5c, 0xf3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x79, 0xe0, 0xe0, 0x6, 0x41, 0x13, 0x4c, 0x84, 0x7e, 0x12, 0x17, 0x7a, 0xf9, 0x1, + 0xe6, 0xce, 0xbf, 0x67, 0x7, 0x94, 0xaf, 0x47, 0xa, 0x68, 0x38, 0x81, 0x4, 0x6b}; + uint8_t bytesprops1[] = {0xee, 0x98, 0x6e, 0xec, 0x58, 0xf4, 0x47, 0xa1, 0x90, 0x95, 0x7, 0x80}; + uint8_t bytesprops2[] = {0x6, 0x95, 0x57, 0xf, 0x2a, 0xf0, 0x28, 0x59}; + uint8_t bytesprops3[] = {0xa1, 0x2c, 0x35, 0xe, 0xe4, 0xb9, 0xa9, 0x79, 0x7a, 0xef, 0x59, 0x12, 0xee, 0x8d, + 0x5e, 0x11, 0xf5, 0x6e, 0xb1, 0x75, 0x8, 0x9e, 0x24, 0x1f, 0x37, 0x40, 0xa0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18770}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 243}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 175}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 141}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5693}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 209}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 8126}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 6378}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9354}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13953}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 67}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 27638}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18649}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17083}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22420}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {8, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 223}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0xf0, 0x1c, 0x5b, 0x98, 0x10, 0xe2, 0x99}; - lwmqtt_string_t topic_filter_s0 = {7, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x81, 0x46, 0x14, 0xa5, 0x65, 0x78, 0x87, 0x57, 0x5e, 0xa3, 0x37, 0x5b, + 0x1c, 0x80, 0x1c, 0xbb, 0xee, 0xcb, 0xf3, 0x24, 0xca, 0x1c, 0x7}; + lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xef, 0x3f, 0xaa}; - lwmqtt_string_t topic_filter_s1 = {3, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe4, 0x77, 0x9e, 0xf2, 0xba, 0xf9, 0x11, 0xea, 0x7, 0xdb, + 0xc6, 0xc1, 0xac, 0x87, 0x59, 0xa1, 0x89, 0x39, 0x3e, 0xd, + 0x67, 0xe9, 0x20, 0x8c, 0xeb, 0x3, 0xda, 0x5a, 0x41}; + lwmqtt_string_t topic_filter_s1 = {29, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0x53, 0x17, 0xff, 0x77, 0x1f, 0xfa, 0xb8, 0x38, 0x45, 0xab, 0xad}; + lwmqtt_string_t topic_filter_s2 = {11, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0x19, 0x17, 0x38, 0x1b, 0x4e}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x32, 0xe6, 0x63, 0xf6, 0xd3, 0x31, 0xd8, 0x96, 0xca, 0xdd, + 0xad, 0x77, 0x93, 0xe8, 0x24, 0x84, 0x70, 0x44, 0xec}; + lwmqtt_string_t topic_filter_s4 = {19, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0xba, 0x9d, 0xc9, 0xa5, 0x9e, 0xd2, 0x17, 0xe8, 0xc2, 0xec, 0x32, 0x3c}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x1d, 0x5d, 0xb5, 0xb3, 0x8e, 0xbe, 0xe6, 0xf2, 0x28, + 0x26, 0xc4, 0x60, 0x8e, 0x83, 0xb8, 0x5c, 0xf3}; + lwmqtt_string_t topic_filter_s6 = {17, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 13532, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 27478, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 8446 ["N-\DC2\189\173\241\ETB\177\&9 -// \159\f\fj~\213!7\235\ESCx\194@\217\US[<","-","e\189\238\251\177\189\195\DLE\192\"c\166\SUB\DEL\145\133L\154^\"W\ETB\217\212","\155","X\139\243\DEL","\209\253\253\NUL9D\178\250\155BHo!\229=\135\146","\EM\217\251","\193S","\173M\228Y\v","\DC4>\252W0Y"] -// [PropTopicAlias 28644,PropUserProperty "\157\n\137\241G`]\ACK\SOH\236}\185\146\228\251\217\156Za\146\129\162" -// "\206\169\210S\208\244\NAK\191d\187Y1\213\186\241\255\&3\242o\ENQ\229\191\228\DC2\156",PropRetainAvailable -// 98,PropPayloadFormatIndicator 207,PropRequestProblemInformation 63,PropAssignedClientIdentifier -// "\131\173f\CAN\210_\128+\131\235\180\222\218u7K\199\CAN\CAN\190\206\158\152\232\250",PropSubscriptionIdentifier -// 4,PropSharedSubscriptionAvailable 7,PropMaximumPacketSize 9667,PropSubscriptionIdentifierAvailable 158,PropMaximumQoS -// 80,PropCorrelationData "3\189\&5({Pi\175\&8\135\176\198-\162\155\CAN\209I\NAK*/\DC1\186\137",PropMaximumPacketSize -// 9314,PropSharedSubscriptionAvailable 77,PropReceiveMaximum 15880,PropRetainAvailable 172,PropSessionExpiryInterval -// 28303,PropSubscriptionIdentifierAvailable 18,PropWildcardSubscriptionAvailable 20,PropContentType -// "\221\194\221\145\&7\149\156\204\172\252\158\160N.\179\148\FS\220\167",PropRetainAvailable 128,PropCorrelationData -// "\171\NUL\v\SIY\210\174\"\v\134\154\166\199\131",PropSessionExpiryInterval 2186,PropCorrelationData -// "\133w\187\216<\238wcW\149",PropAuthenticationMethod "\196\221\254(\160 \232\181\NAKE"] +// UnsubscribeRequest 18764 +// ["ui\144\128DK\158\RS-oM\167F\213\134\185\210)\189\188\129\201\220\&1z\155\157","\169\200\213O\SOH\206\141\139\213\236\154}\152u\176\134\227\&0N\207\EOT\156gt;\187k\159H","\206\172\214oS\145\156\204\243\DLE\210\244\SYN\139*\DC2\167B\203&\253\186\f\148\247y","-\DC4\EOTT\178\"\162\b\240\242~n2A","@\138\214D\t>7\224\205.\175\EM\SUB\209\229","\138\r\131\241\214h\241\246\&9N\203\214\a\168z!2\218\192\152wW\224","`s\ESC\204\253\132dr\189^I\148e\253\219Ef_\155\221\157\160ON\239=\148\&3\176\241","\147\146\174g\NAK;=\175\245\251\194\146\SYNT\157lYJ\a\176`\251\222\164\236/\237\214y#\151\242.z","\139\214\221#G*U\227T\173Rn@x\190\128\&5y\194\247\195\175\253wE","\GS\251H\DC4\vJP\189\140\185\154\&6\ETB\ETX","\128","\164\134\216\194\&6\188\138H\199\EOT\183\NULcZ?\216\152\181\221Q\186\186(","N\153\169\195C0fs\136\178\185\191\163\GS\DLE\NUL\163\137\203\244\EM\134","%N\154_","\182\139\236\&1\DEL\208\223\&6&D\244\191\208\GS\155S\221","\133 -// \226-gm\142m\195\143\ACK\187RL\224}\157S=\135\230j\143","\221A\DC405q\245^U\188\239\212","\141\201\141\157\242\ACKk\161\185\131\247\CAN\a\240L\180\218Wn\218%\f\247"] -// [PropRetainAvailable 126,PropCorrelationData "\196\225\180\173",PropMaximumPacketSize -// 15050,PropWildcardSubscriptionAvailable 132,PropTopicAlias 5379,PropServerReference -// "\254\250\184vZ\180,Vau\230p\128\ACKO\248B\194\&7B4\240}\218\&4!",PropTopicAlias 12587,PropContentType -// "uO\220\242\162\220Y\161\149\196\229\180=\213\v\FSXU\137:",PropResponseInformation -// "(\NUL\180\&4J\254\154\170",PropCorrelationData "",PropAuthenticationMethod "6\DLE",PropReceiveMaximum -// 21115,PropResponseInformation "y\158\152I\133\133\147?rj\186z\161\&0\143s",PropSharedSubscriptionAvailable -// 14,PropAuthenticationMethod "V\144z\151\156\241<\223\183\171{\200\211k_\210\&32E\215",PropReasonString -// "\222g2v#\247R\158Z\185\236\158",PropMessageExpiryInterval 15220,PropWildcardSubscriptionAvailable -// 112,PropResponseTopic "7",PropRetainAvailable 91,PropResponseInformation -// "\247l\174\144]l\237\134|\238w",PropMessageExpiryInterval 23113,PropSubscriptionIdentifierAvailable -// 9,PropResponseTopic "\184\228q\"\r\232",PropCorrelationData "3\140\192\224\ENQ\224\138\&0\228q -// \251\139\227\239}\135:\254\236\138\DEL\182L\139\SUB\210",PropPayloadFormatIndicator 216,PropServerReference -// "\r\135U\185B\ETBj\200\149\198\SYN\NAK\ACK*\188\r\216\&5\DEL.\SOH4\147",PropContentType -// "\131k\230\193BewT%\251\236",PropRequestResponseInformation 75,PropWillDelayInterval 26761] + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 18764, 9, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 29340 +// [",8\222l\141\171\228\150%\180\238","f\139\198\250\130\173\198\217v\CAN\177\GS~z\244\167-1\239\240Z","m4\217;\151\147\&9uCw\253tO\US\255W\130\164\&3}#\152\181\143\159QB\174\172\171","2\221\150\187\143\&0\n\170D\151\NAK\209\207\203\NAK6\233\203\160","7\n\f\248\170\129>\255Q])\240\ESC\164L\243\138Z`\202u\183w\n\193}\159.\214\155","\255\206\142`","\208\139\240\191|\DEL\198\233\ETB\CAN\151[\DC2[\175\251vI\ETX;$\162\nv/1\179","\184\196\146D\229\218\FS\DC2\153"] +// [PropReceiveMaximum 2080,PropRequestResponseInformation 113,PropCorrelationData +// "giW\242(\SOHZ\222\181E\248\204\196&\DEL2!\195\250g\139\EMs\183\148\199\rS\156",PropMessageExpiryInterval +// 16043,PropWildcardSubscriptionAvailable 175,PropCorrelationData +// "W\146\150\EOT\143Uq\163\225",PropAuthenticationMethod "\140R$l\EOT\150\SO^\169\t",PropServerReference +// "\178\200u=;",PropUserProperty "\146<\vI=\228\166\FS@^\135P\215!\EM4\220\251" "\238]4",PropSubscriptionIdentifier +// 27,PropRequestProblemInformation 129,PropResponseInformation "\167\NUL\166\f",PropWillDelayInterval +// 9937,PropMaximumQoS 0,PropSubscriptionIdentifier 2,PropReceiveMaximum 6500,PropReasonString "\231|\165+"] TEST(Unsubscribe5QCTest, Encode11) { uint8_t pkt[] = { - 0xa2, 0xee, 0x3, 0x3e, 0xbe, 0x95, 0x2, 0x25, 0x7e, 0x9, 0x0, 0x4, 0xc4, 0xe1, 0xb4, 0xad, 0x27, 0x0, 0x0, - 0x3a, 0xca, 0x28, 0x84, 0x23, 0x15, 0x3, 0x1c, 0x0, 0x1a, 0xfe, 0xfa, 0xb8, 0x76, 0x5a, 0xb4, 0x2c, 0x56, 0x61, - 0x75, 0xe6, 0x70, 0x80, 0x6, 0x4f, 0xf8, 0x42, 0xc2, 0x37, 0x42, 0x34, 0xf0, 0x7d, 0xda, 0x34, 0x21, 0x23, 0x31, - 0x2b, 0x3, 0x0, 0x14, 0x75, 0x4f, 0xdc, 0xf2, 0xa2, 0xdc, 0x59, 0xa1, 0x95, 0xc4, 0xe5, 0xb4, 0x3d, 0xd5, 0xb, - 0x1c, 0x58, 0x55, 0x89, 0x3a, 0x1a, 0x0, 0x8, 0x28, 0x0, 0xb4, 0x34, 0x4a, 0xfe, 0x9a, 0xaa, 0x9, 0x0, 0x0, - 0x15, 0x0, 0x2, 0x36, 0x10, 0x21, 0x52, 0x7b, 0x1a, 0x0, 0x10, 0x79, 0x9e, 0x98, 0x49, 0x85, 0x85, 0x93, 0x3f, - 0x72, 0x6a, 0xba, 0x7a, 0xa1, 0x30, 0x8f, 0x73, 0x2a, 0xe, 0x15, 0x0, 0x14, 0x56, 0x90, 0x7a, 0x97, 0x9c, 0xf1, - 0x3c, 0xdf, 0xb7, 0xab, 0x7b, 0xc8, 0xd3, 0x6b, 0x5f, 0xd2, 0x33, 0x32, 0x45, 0xd7, 0x1f, 0x0, 0xc, 0xde,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d, 0x77, 0x45, 0x0, 0xe, - 0x1d, 0xfb, 0x48, 0x14, 0xb, 0x4a, 0x50, 0xbd, 0x8c, 0xb9, 0x9a, 0x36, 0x17, 0x3, 0x0, 0x1, 0x80, 0x0, 0x17, - 0xa4, 0x86, 0xd8, 0xc2, 0x36, 0xbc, 0x8a, 0x48, 0xc7, 0x4, 0xb7, 0x0, 0x63, 0x5a, 0x3f, 0xd8, 0x98, 0xb5, 0xdd, - 0x51, 0xba, 0xba, 0x28, 0x0, 0x16, 0x4e, 0x99, 0xa9, 0xc3, 0x43, 0x30, 0x66, 0x73, 0x88, 0xb2, 0xb9, 0xbf, 0xa3, - 0x1d, 0x10, 0x0, 0xa3, 0x89, 0xcb, 0xf4, 0x19, 0x86, 0x0, 0x4, 0x25, 0x4e, 0x9a, 0x5f, 0x0, 0x11, 0xb6, 0x8b, - 0xec, 0x31, 0x7f, 0xd0, 0xdf, 0x36, 0x26, 0x44, 0xf4, 0xbf, 0xd0, 0x1d, 0x9b, 0x53, 0xdd, 0x0, 0x17, 0x85, 0x20, - 0xe2, 0x2d, 0x67, 0x6d, 0x8e, 0x6d, 0xc3, 0x8f, 0x6, 0xbb, 0x52, 0x4c, 0xe0, 0x7d, 0x9d, 0x53, 0x3d, 0x87, 0xe6, - 0x6a, 0x8f, 0x0, 0xc, 0xdd, 0x41, 0x14, 0x30, 0x35, 0x71, 0xf5, 0x5e, 0x55, 0xbc, 0xef, 0xd4, 0x0, 0x17, 0x8d, - 0xc9, 0x8d, 0x9d, 0xf2, 0x6, 0x6b, 0xa1, 0xb9, 0x83, 0xf7, 0x18, 0x7, 0xf0, 0x4c, 0xb4, 0xda, 0x57, 0x6e, 0xda, - 0x25, 0xc, 0xf7}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xc4, 0xe1, 0xb4, 0xad}; - uint8_t bytesprops1[] = {0xfe, 0xfa, 0xb8, 0x76, 0x5a, 0xb4, 0x2c, 0x56, 0x61, 0x75, 0xe6, 0x70, 0x80, - 0x6, 0x4f, 0xf8, 0x42, 0xc2, 0x37, 0x42, 0x34, 0xf0, 0x7d, 0xda, 0x34, 0x21}; - uint8_t bytesprops2[] = {0x75, 0x4f, 0xdc, 0xf2, 0xa2, 0xdc, 0x59, 0xa1, 0x95, 0xc4, - 0xe5, 0xb4, 0x3d, 0xd5, 0xb, 0x1c, 0x58, 0x55, 0x89, 0x3a}; - uint8_t bytesprops3[] = {0x28, 0x0, 0xb4, 0x34, 0x4a, 0xfe, 0x9a, 0xaa}; - uint8_t bytesprops4[] = {0}; - uint8_t bytesprops5[] = {0x36, 0x10}; - uint8_t bytesprops6[] = {0x79, 0x9e, 0x98, 0x49, 0x85, 0x85, 0x93, 0x3f, - 0x72, 0x6a, 0xba, 0x7a, 0xa1, 0x30, 0x8f, 0x73}; - uint8_t bytesprops7[] = {0x56, 0x90, 0x7a, 0x97, 0x9c, 0xf1, 0x3c, 0xdf, 0xb7, 0xab, - 0x7b, 0xc8, 0xd3, 0x6b, 0x5f, 0xd2, 0x33, 0x32, 0x45, 0xd7}; - uint8_t bytesprops8[] = {0xde, 0x67, 0x32, 0x76, 0x23, 0xf7, 0x52, 0x9e, 0x5a, 0xb9, 0xec, 0x9e}; - uint8_t bytesprops9[] = {0x37}; - uint8_t bytesprops10[] = {0xf7, 0x6c, 0xae, 0x90, 0x5d, 0x6c, 0xed, 0x86, 0x7c, 0xee, 0x77}; - uint8_t bytesprops11[] = {0xb8, 0xe4, 0x71, 0x22, 0xd, 0xe8}; - uint8_t bytesprops12[] = {0x33, 0x8c, 0xc0, 0xe0, 0x5, 0xe0, 0x8a, 0x30, 0xe4, 0x71, 0x20, 0xfb, 0x8b, 0xe3, - 0xef, 0x7d, 0x87, 0x3a, 0xfe, 0xec, 0x8a, 0x7f, 0xb6, 0x4c, 0x8b, 0x1a, 0xd2}; - uint8_t bytesprops13[] = {0xd, 0x87, 0x55, 0xb9, 0x42, 0x17, 0x6a, 0xc8, 0x95, 0xc6, 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, 0xd9, 0x76, 0x18, 0xb1, 0x1d, 0x7e, 0x7a, 0xf4, 0xa7, + 0x2d, 0x31, 0xef, 0xf0, 0x5a, 0x0, 0x1e, 0x6d, 0x34, 0xd9, 0x3b, 0x97, 0x93, 0x39, 0x75, 0x43, 0x77, 0xfd, 0x74, + 0x4f, 0x1f, 0xff, 0x57, 0x82, 0xa4, 0x33, 0x7d, 0x23, 0x98, 0xb5, 0x8f, 0x9f, 0x51, 0x42, 0xae, 0xac, 0xab, 0x0, + 0x13, 0x32, 0xdd, 0x96, 0xbb, 0x8f, 0x30, 0xa, 0xaa, 0x44, 0x97, 0x15, 0xd1, 0xcf, 0xcb, 0x15, 0x36, 0xe9, 0xcb, + 0xa0, 0x0, 0x1e, 0x37, 0xa, 0xc, 0xf8, 0xaa, 0x81, 0x3e, 0xff, 0x51, 0x5d, 0x29, 0xf0, 0x1b, 0xa4, 0x4c, 0xf3, + 0x8a, 0x5a, 0x60, 0xca, 0x75, 0xb7, 0x77, 0xa, 0xc1, 0x7d, 0x9f, 0x2e, 0xd6, 0x9b, 0x0, 0x4, 0xff, 0xce, 0x8e, + 0x60, 0x0, 0x1b, 0xd0, 0x8b, 0xf0, 0xbf, 0x7c, 0x7f, 0xc6, 0xe9, 0x17, 0x18, 0x97, 0x5b, 0x12, 0x5b, 0xaf, 0xfb, + 0x76, 0x49, 0x3, 0x3b, 0x24, 0xa2, 0xa, 0x76, 0x2f, 0x31, 0xb3, 0x0, 0x9, 0xb8, 0xc4, 0x92, 0x44, 0xe5, 0xda, + 0x1c, 0x12, 0x99}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x67, 0x69, 0x57, 0xf2, 0x28, 0x1, 0x5a, 0xde, 0xb5, 0x45, 0xf8, 0xcc, 0xc4, 0x26, 0x7f, + 0x32, 0x21, 0xc3, 0xfa, 0x67, 0x8b, 0x19, 0x73, 0xb7, 0x94, 0xc7, 0xd, 0x53, 0x9c}; + uint8_t bytesprops1[] = {0x57, 0x92, 0x96, 0x4, 0x8f, 0x55, 0x71, 0xa3, 0xe1}; + uint8_t bytesprops2[] = {0x8c, 0x52, 0x24, 0x6c, 0x4, 0x96, 0xe, 0x5e, 0xa9, 0x9}; + uint8_t bytesprops3[] = {0xb2, 0xc8, 0x75, 0x3d, 0x3b}; + uint8_t bytesprops5[] = {0xee, 0x5d, 0x34}; + uint8_t bytesprops4[] = {0x92, 0x3c, 0xb, 0x49, 0x3d, 0xe4, 0xa6, 0x1c, 0x40, + 0x5e, 0x87, 0x50, 0xd7, 0x21, 0x19, 0x34, 0xdc, 0xfb}; + uint8_t bytesprops6[] = {0xa7, 0x0, 0xa6, 0xc}; + uint8_t bytesprops7[] = {0xe7, 0x7c, 0xa5, 0x2b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {4, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15050}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5379}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12587}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21115}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {16, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 14}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {12, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15220}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 112}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23113}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 9}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 216}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {23, (char*)&bytesprops13}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops14}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 75}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26761}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 2080}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 113}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16043}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 175}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops4}, .v = {3, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 129}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9937}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6500}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {4, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[11]; - uint8_t topic_filter_s0_bytes[] = {0x14, 0xc8, 0xb6, 0xd9, 0xa5, 0x60, 0xa8, 0x1a, 0x10, 0x37, 0xa1, 0x99, 0x3e, 0x60, - 0xfb, 0xde, 0xa4, 0xec, 0x2f, 0xed, 0xd6, 0x79, 0x23, 0x97, 0xf2, 0x2e, 0x7a}; - lwmqtt_string_t topic_filter_s0 = {27, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0x2c, 0x38, 0xde, 0x6c, 0x8d, 0xab, 0xe4, 0x96, 0x25, 0xb4, 0xee}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x8b, 0xd6, 0xdd, 0x23, 0x47, 0x2a, 0x55, 0xe3, 0x54, 0xad, 0x52, 0x6e, 0x40, - 0x78, 0xbe, 0x80, 0x35, 0x79, 0xc2, 0xf7, 0xc3, 0xaf, 0xfd, 0x77, 0x45}; - lwmqtt_string_t topic_filter_s1 = {25, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x66, 0x8b, 0xc6, 0xfa, 0x82, 0xad, 0xc6, 0xd9, 0x76, 0x18, 0xb1, + 0x1d, 0x7e, 0x7a, 0xf4, 0xa7, 0x2d, 0x31, 0xef, 0xf0, 0x5a}; + lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1d, 0xfb, 0x48, 0x14, 0xb, 0x4a, 0x50, 0xbd, 0x8c, 0xb9, 0x9a, 0x36, 0x17, 0x3}; - lwmqtt_string_t topic_filter_s2 = {14, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6d, 0x34, 0xd9, 0x3b, 0x97, 0x93, 0x39, 0x75, 0x43, 0x77, + 0xfd, 0x74, 0x4f, 0x1f, 0xff, 0x57, 0x82, 0xa4, 0x33, 0x7d, + 0x23, 0x98, 0xb5, 0x8f, 0x9f, 0x51, 0x42, 0xae, 0xac, 0xab}; + lwmqtt_string_t topic_filter_s2 = {30, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x80}; - lwmqtt_string_t topic_filter_s3 = {1, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x32, 0xdd, 0x96, 0xbb, 0x8f, 0x30, 0xa, 0xaa, 0x44, 0x97, + 0x15, 0xd1, 0xcf, 0xcb, 0x15, 0x36, 0xe9, 0xcb, 0xa0}; + lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xa4, 0x86, 0xd8, 0xc2, 0x36, 0xbc, 0x8a, 0x48, 0xc7, 0x4, 0xb7, 0x0, - 0x63, 0x5a, 0x3f, 0xd8, 0x98, 0xb5, 0xdd, 0x51, 0xba, 0xba, 0x28}; - lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x37, 0xa, 0xc, 0xf8, 0xaa, 0x81, 0x3e, 0xff, 0x51, 0x5d, + 0x29, 0xf0, 0x1b, 0xa4, 0x4c, 0xf3, 0x8a, 0x5a, 0x60, 0xca, + 0x75, 0xb7, 0x77, 0xa, 0xc1, 0x7d, 0x9f, 0x2e, 0xd6, 0x9b}; + lwmqtt_string_t topic_filter_s4 = {30, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4e, 0x99, 0xa9, 0xc3, 0x43, 0x30, 0x66, 0x73, 0x88, 0xb2, 0xb9, - 0xbf, 0xa3, 0x1d, 0x10, 0x0, 0xa3, 0x89, 0xcb, 0xf4, 0x19, 0x86}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xff, 0xce, 0x8e, 0x60}; + lwmqtt_string_t topic_filter_s5 = {4, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x25, 0x4e, 0x9a, 0x5f}; - lwmqtt_string_t topic_filter_s6 = {4, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xd0, 0x8b, 0xf0, 0xbf, 0x7c, 0x7f, 0xc6, 0xe9, 0x17, 0x18, 0x97, 0x5b, 0x12, 0x5b, + 0xaf, 0xfb, 0x76, 0x49, 0x3, 0x3b, 0x24, 0xa2, 0xa, 0x76, 0x2f, 0x31, 0xb3}; + lwmqtt_string_t topic_filter_s6 = {27, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xb6, 0x8b, 0xec, 0x31, 0x7f, 0xd0, 0xdf, 0x36, 0x26, - 0x44, 0xf4, 0xbf, 0xd0, 0x1d, 0x9b, 0x53, 0xdd}; - lwmqtt_string_t topic_filter_s7 = {17, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xb8, 0xc4, 0x92, 0x44, 0xe5, 0xda, 0x1c, 0x12, 0x99}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x85, 0x20, 0xe2, 0x2d, 0x67, 0x6d, 0x8e, 0x6d, 0xc3, 0x8f, 0x6, 0xbb, - 0x52, 0x4c, 0xe0, 0x7d, 0x9d, 0x53, 0x3d, 0x87, 0xe6, 0x6a, 0x8f}; - lwmqtt_string_t topic_filter_s8 = {23, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xdd, 0x41, 0x14, 0x30, 0x35, 0x71, 0xf5, 0x5e, 0x55, 0xbc, 0xef, 0xd4}; - lwmqtt_string_t topic_filter_s9 = {12, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; - uint8_t topic_filter_s10_bytes[] = {0x8d, 0xc9, 0x8d, 0x9d, 0xf2, 0x6, 0x6b, 0xa1, 0xb9, 0x83, 0xf7, 0x18, - 0x7, 0xf0, 0x4c, 0xb4, 0xda, 0x57, 0x6e, 0xda, 0x25, 0xc, 0xf7}; - lwmqtt_string_t topic_filter_s10 = {23, (char*)&topic_filter_s10_bytes}; - topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16062, 11, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29340, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 999 -// ["kz8\"x_\167\&7\"\185\142\244:j\DC1","|","$\185\f4w\233","T\165\216\ETB\180p\NULe\ETX8\144\DLE4\DC4\GS\226\218\129\RS\SOHz","\172|>\168&\208\226\212\228lp\RSw\196\153\ESC\218\178l\207\rqgP\t\155$\145\ENQ","\EOT\244\t\200\GS\218\166\a\ETBL\218\191\198\183\130OR\ENQn\151\"|"] -// [] +// UnsubscribeRequest 24289 +// ["\n\b_\177","\SO\173\150\235=\192\GSn\194\230\155","}0\US\\\211\232\235\DC1[\238\231\192\209Z\247","\234\ACK&\142\250","g\nP\ENQ%\231\181O\209\135\180\175q$\ETX75\164\168\EM\128\237\158","\245\184u\183\169S\226\171\US\SI\243\DC4x\154\DC2\228\211\195\243W\202\218\NUL\224\&5\236\132\246","\204\"i\DC4\191\234\255\177|\153\255~","m\211","m\128\ESCiS\128.\143/\172\205\144l\161\DEL[)\168y","!\183*7Kr\181\253\180,\146\166\&9\158\207T5\206\209Wx\225","\229\215Yl={\ETB\216/\212}\170\DEL"] +// [PropMessageExpiryInterval 6895,PropSubscriptionIdentifierAvailable 6,PropContentType +// "`\134XR",PropPayloadFormatIndicator 244,PropContentType "\189BOp\NUL\132 +// \176P\DC33\NUL\182Z\129*",PropSubscriptionIdentifierAvailable 152,PropCorrelationData +// "\ESCW\229\142C\171\140\236\193\194\177\SYN)\182\152\159C\204\197\&5\DC4\157\169W\241",PropSubscriptionIdentifierAvailable +// 231,PropSharedSubscriptionAvailable 219,PropPayloadFormatIndicator 212,PropRequestResponseInformation +// 233,PropServerReference "\199w\154\209'\216Y\ETB\b\GS1\133z\179\162\SYN",PropRetainAvailable 186,PropUserProperty "" +// "\249\254\252g],/\157M\177\&2u\128\188\154"] TEST(Unsubscribe5QCTest, Encode12) { - uint8_t pkt[] = {0xa2, 0x6d, 0x3, 0xe7, 0x0, 0x0, 0xf, 0x6b, 0x7a, 0x38, 0x22, 0x78, 0x5f, 0xa7, 0x37, 0x22, - 0xb9, 0x8e, 0xf4, 0x3a, 0x6a, 0x11, 0x0, 0x1, 0x7c, 0x0, 0x6, 0x24, 0xb9, 0xc, 0x34, 0x77, - 0xe9, 0x0, 0x15, 0x54, 0xa5, 0xd8, 0x17, 0xb4, 0x70, 0x0, 0x65, 0x3, 0x38, 0x90, 0x10, 0x34, -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] = {0}; + uint8_t bytesprops0[] = {0x60, 0x86, 0x58, 0x52}; + uint8_t bytesprops1[] = {0xbd, 0x42, 0x4f, 0x70, 0x0, 0x84, 0x20, 0xb0, + 0x50, 0x13, 0x33, 0x0, 0xb6, 0x5a, 0x81, 0x2a}; + uint8_t bytesprops2[] = {0x1b, 0x57, 0xe5, 0x8e, 0x43, 0xab, 0x8c, 0xec, 0xc1, 0xc2, 0xb1, 0x16, 0x29, + 0xb6, 0x98, 0x9f, 0x43, 0xcc, 0xc5, 0x35, 0x14, 0x9d, 0xa9, 0x57, 0xf1}; + uint8_t bytesprops3[] = {0xc7, 0x77, 0x9a, 0xd1, 0x27, 0xd8, 0x59, 0x17, + 0x8, 0x1d, 0x31, 0x85, 0x7a, 0xb3, 0xa2, 0x16}; + uint8_t bytesprops5[] = {0xf9, 0xfe, 0xfc, 0x67, 0x5d, 0x2c, 0x2f, 0x9d, 0x4d, 0xb1, 0x32, 0x75, 0x80, 0xbc, 0x9a}; + uint8_t bytesprops4[] = {0}; - lwmqtt_property_t propslist[] = {}; + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6895}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 6}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {4, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 152}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {25, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 231}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 233}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops4}, .v = {15, (char*)&bytesprops5}}}}, + }; - lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x6b, 0x7a, 0x38, 0x22, 0x78, 0x5f, 0xa7, 0x37, - 0x22, 0xb9, 0x8e, 0xf4, 0x3a, 0x6a, 0x11}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {14, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0xa, 0x8, 0x5f, 0xb1}; + lwmqtt_string_t topic_filter_s0 = {4, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7c}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xe, 0xad, 0x96, 0xeb, 0x3d, 0xc0, 0x1d, 0x6e, 0xc2, 0xe6, 0x9b}; + lwmqtt_string_t topic_filter_s1 = {11, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x24, 0xb9, 0xc, 0x34, 0x77, 0xe9}; - lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x7d, 0x30, 0x1f, 0x5c, 0xd3, 0xe8, 0xeb, 0x11, + 0x5b, 0xee, 0xe7, 0xc0, 0xd1, 0x5a, 0xf7}; + lwmqtt_string_t topic_filter_s2 = {15, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x54, 0xa5, 0xd8, 0x17, 0xb4, 0x70, 0x0, 0x65, 0x3, 0x38, 0x90, - 0x10, 0x34, 0x14, 0x1d, 0xe2, 0xda, 0x81, 0x1e, 0x1, 0x7a}; - lwmqtt_string_t topic_filter_s3 = {21, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xea, 0x6, 0x26, 0x8e, 0xfa}; + lwmqtt_string_t topic_filter_s3 = {5, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xac, 0x7c, 0x3e, 0xa8, 0x26, 0xd0, 0xe2, 0xd4, 0xe4, 0x6c, - 0x70, 0x1e, 0x77, 0xc4, 0x99, 0x1b, 0xda, 0xb2, 0x6c, 0xcf, - 0xd, 0x71, 0x67, 0x50, 0x9, 0x9b, 0x24, 0x91, 0x5}; - lwmqtt_string_t topic_filter_s4 = {29, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x67, 0xa, 0x50, 0x5, 0x25, 0xe7, 0xb5, 0x4f, 0xd1, 0x87, 0xb4, 0xaf, + 0x71, 0x24, 0x3, 0x37, 0x35, 0xa4, 0xa8, 0x19, 0x80, 0xed, 0x9e}; + lwmqtt_string_t topic_filter_s4 = {23, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4, 0xf4, 0x9, 0xc8, 0x1d, 0xda, 0xa6, 0x7, 0x17, 0x4c, 0xda, - 0xbf, 0xc6, 0xb7, 0x82, 0x4f, 0x52, 0x5, 0x6e, 0x97, 0x22, 0x7c}; - lwmqtt_string_t topic_filter_s5 = {22, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf5, 0xb8, 0x75, 0xb7, 0xa9, 0x53, 0xe2, 0xab, 0x1f, 0xf, + 0xf3, 0x14, 0x78, 0x9a, 0x12, 0xe4, 0xd3, 0xc3, 0xf3, 0x57, + 0xca, 0xda, 0x0, 0xe0, 0x35, 0xec, 0x84, 0xf6}; + lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0xcc, 0x22, 0x69, 0x14, 0xbf, 0xea, 0xff, 0xb1, 0x7c, 0x99, 0xff, 0x7e}; + lwmqtt_string_t topic_filter_s6 = {12, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0x6d, 0xd3}; + lwmqtt_string_t topic_filter_s7 = {2, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x6d, 0x80, 0x1b, 0x69, 0x53, 0x80, 0x2e, 0x8f, 0x2f, 0xac, + 0xcd, 0x90, 0x6c, 0xa1, 0x7f, 0x5b, 0x29, 0xa8, 0x79}; + lwmqtt_string_t topic_filter_s8 = {19, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x21, 0xb7, 0x2a, 0x37, 0x4b, 0x72, 0xb5, 0xfd, 0xb4, 0x2c, 0x92, + 0xa6, 0x39, 0x9e, 0xcf, 0x54, 0x35, 0xce, 0xd1, 0x57, 0x78, 0xe1}; + lwmqtt_string_t topic_filter_s9 = {22, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xe5, 0xd7, 0x59, 0x6c, 0x3d, 0x7b, 0x17, 0xd8, 0x2f, 0xd4, 0x7d, 0xaa, 0x7f}; + lwmqtt_string_t topic_filter_s10 = {13, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 999, 6, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24289, 11, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 5737 -// ["\216\200`8N","z\226\248\NULq\EOT\232\158\NUL\178\131\247\130\n\240\192\225^","?x\STX-5\217\158\213\253+\165\134\173`#\190\229\177\228\177\183\\\204V","[Q","\190\180u\222#\171\SUBik\221\246\227\164)\239\210\EOT4[-","f\SO\237iS\197T\247\250\167?\228\242\170\213_b\215\241\221\153\136\138\229\175","E}\SUB\221S\172 -// \FS\189&}v\220"] [PropUserProperty "\178\171%\133\134\131\203x\200\180\&4C\236\173\133" -// "`\221\NAKfB\RST\195",PropMaximumPacketSize 15484,PropResponseTopic -// "\242tw\US\r\146\"G\146+\201\140\225\134|d\249\a\151^w\232",PropCorrelationData -// "T\204\188\141$\158)\139?S\ETX\SYNbS\185\DEL\249&\131~\233F\128E\245\201N",PropWildcardSubscriptionAvailable -// 118,PropAuthenticationMethod "\207\211\218\137\138\t\SO\EM",PropSubscriptionIdentifier 20,PropMaximumQoS -// 204,PropSharedSubscriptionAvailable 219,PropWildcardSubscriptionAvailable 204,PropReceiveMaximum -// 30300,PropSharedSubscriptionAvailable 43,PropSubscriptionIdentifierAvailable 32,PropCorrelationData -// "\139\135)\198\226\241\166\165\221\RS\144\166\247\128k@\251\213",PropContentType -// "5S(\134\136!#\202\\\175\a",PropContentType -// "\r\149\141\222\209\159k\133\&5U\157\ACK",PropWildcardSubscriptionAvailable 166,PropMessageExpiryInterval -// 32142,PropContentType "\239\215\172\152\182\206\205\163~ [\134\ETX\228A\185",PropPayloadFormatIndicator -// 241,PropTopicAliasMaximum 28855,PropSharedSubscriptionAvailable 18] +// UnsubscribeRequest 26276 +// ["U^\138\255\DC2\173G\168Q\178\rw8ZS","\162\\\255\SOHI\247\ETB\199\148e\254\245\221\242\129\161\181_\214\DEL","\166\180j +// ","m\DLEV\240\&7\150\DC1\248lX\136\130\205]\233\142NLy\tB\251ll,`\155E\143\138","\141\GS\195\177)_)w9C\234\132H\154\DC1J\147","\213\215P","\247\239\158","\226\165#\135\230;\245\233\171}","\202>m\132\GS9\145\246\137\NAK\237Q"] +// [PropReceiveMaximum 23093,PropPayloadFormatIndicator 98,PropAuthenticationData +// "d\SYN\182X\129Gu{h\ENQ\223\\\SO\DC4+\169\203\196\249\216Z\174\185",PropTopicAlias 20078,PropMaximumPacketSize +// 13310,PropContentType "\NAK\183@\DC2Y\131$\139\131yr$\224\247\189{",PropMessageExpiryInterval 13599] TEST(Unsubscribe5QCTest, Encode13) { - uint8_t pkt[] = { - 0xa2, 0xc4, 0x2, 0x16, 0x69, 0xc7, 0x1, 0x26, 0x0, 0xf, 0xb2, 0xab, 0x25, 0x85, 0x86, 0x83, 0xcb, 0x78, 0xc8, - 0xb4, 0x34, 0x43, 0xec, 0xad, 0x85, 0x0, 0x8, 0x60, 0xdd, 0x15, 0x66, 0x42, 0x1e, 0x54, 0xc3, 0x27, 0x0, 0x0, - 0x3c, 0x7c, 0x8, 0x0, 0x16, 0xf2, 0x74, 0x77, 0x1f, 0xd, 0x92, 0x22, 0x47, 0x92, 0x2b, 0xc9, 0x8c, 0xe1, 0x86, - 0x7c, 0x64, 0xf9, 0x7, 0x97, 0x5e, 0x77, 0xe8, 0x9, 0x0, 0x1b, 0x54, 0xcc, 0xbc, 0x8d, 0x24, 0x9e, 0x29, 0x8b, - 0x3f, 0x53, 0x3, 0x16, 0x62, 0x53, 0xb9, 0x7f, 0xf9, 0x26, 0x83, 0x7e, 0xe9, 0x46, 0x80, 0x45, 0xf5, 0xc9, 0x4e, - 0x28, 0x76, 0x15, 0x0, 0x8, 0xcf, 0xd3, 0xda, 0x89, 0x8a, 0x9, 0xe, 0x19, 0xb, 0x14, 0x24, 0xcc, 0x2a, 0xdb, - 0x28, 0xcc, 0x21, 0x76, 0x5c, 0x2a, 0x2b, 0x29, 0x20, 0x9, 0x0, 0x12, 0x8b, 0x87, 0x29, 0xc6, 0xe2, 0xf1, 0xa6, - 0xa5, 0xdd, 0x1e, 0x90, 0xa6,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0x26, 0x7d, 0x76, 0xdc}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x60, 0xdd, 0x15, 0x66, 0x42, 0x1e, 0x54, 0xc3}; - uint8_t bytesprops0[] = {0xb2, 0xab, 0x25, 0x85, 0x86, 0x83, 0xcb, 0x78, 0xc8, 0xb4, 0x34, 0x43, 0xec, 0xad, 0x85}; - uint8_t bytesprops2[] = {0xf2, 0x74, 0x77, 0x1f, 0xd, 0x92, 0x22, 0x47, 0x92, 0x2b, 0xc9, - 0x8c, 0xe1, 0x86, 0x7c, 0x64, 0xf9, 0x7, 0x97, 0x5e, 0x77, 0xe8}; - uint8_t bytesprops3[] = {0x54, 0xcc, 0xbc, 0x8d, 0x24, 0x9e, 0x29, 0x8b, 0x3f, 0x53, 0x3, 0x16, 0x62, 0x53, - 0xb9, 0x7f, 0xf9, 0x26, 0x83, 0x7e, 0xe9, 0x46, 0x80, 0x45, 0xf5, 0xc9, 0x4e}; - uint8_t bytesprops4[] = {0xcf, 0xd3, 0xda, 0x89, 0x8a, 0x9, 0xe, 0x19}; - uint8_t bytesprops5[] = {0x8b, 0x87, 0x29, 0xc6, 0xe2, 0xf1, 0xa6, 0xa5, 0xdd, - 0x1e, 0x90, 0xa6, 0xf7, 0x80, 0x6b, 0x40, 0xfb, 0xd5}; - uint8_t bytesprops6[] = {0x35, 0x53, 0x28, 0x86, 0x88, 0x21, 0x23, 0xca, 0x5c, 0xaf, 0x7}; - uint8_t bytesprops7[] = {0xd, 0x95, 0x8d, 0xde, 0xd1, 0x9f, 0x6b, 0x85, 0x35, 0x55, 0x9d, 0x6}; - uint8_t bytesprops8[] = {0xef, 0xd7, 0xac, 0x98, 0xb6, 0xce, 0xcd, 0xa3, - 0x7e, 0x20, 0x5b, 0x86, 0x3, 0xe4, 0x41, 0xb9}; + uint8_t pkt[] = {0xa2, 0xc6, 0x1, 0x66, 0xa4, 0x3f, 0x21, 0x5a, 0x35, 0x1, 0x62, 0x16, 0x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15, 0xed, 0x51}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x64, 0x16, 0xb6, 0x58, 0x81, 0x47, 0x75, 0x7b, 0x68, 0x5, 0xdf, 0x5c, + 0xe, 0x14, 0x2b, 0xa9, 0xcb, 0xc4, 0xf9, 0xd8, 0x5a, 0xae, 0xb9}; + uint8_t bytesprops1[] = {0x15, 0xb7, 0x40, 0x12, 0x59, 0x83, 0x24, 0x8b, + 0x83, 0x79, 0x72, 0x24, 0xe0, 0xf7, 0xbd, 0x7b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {15, (char*)&bytesprops0}, .v = {8, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 15484}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 118}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 204}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 30300}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 43}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 32}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {11, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32142}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28855}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 18}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 23093}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 98}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20078}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 13310}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13599}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0xd8, 0xc8, 0x60, 0x38, 0x4e}; - lwmqtt_string_t topic_filter_s0 = {5, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x55, 0x5e, 0x8a, 0xff, 0x12, 0xad, 0x47, 0xa8, + 0x51, 0xb2, 0xd, 0x77, 0x38, 0x5a, 0x53}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x7a, 0xe2, 0xf8, 0x0, 0x71, 0x4, 0xe8, 0x9e, 0x0, - 0xb2, 0x83, 0xf7, 0x82, 0xa, 0xf0, 0xc0, 0xe1, 0x5e}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xa2, 0x5c, 0xff, 0x1, 0x49, 0xf7, 0x17, 0xc7, 0x94, 0x65, + 0xfe, 0xf5, 0xdd, 0xf2, 0x81, 0xa1, 0xb5, 0x5f, 0xd6, 0x7f}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x3f, 0x78, 0x2, 0x2d, 0x35, 0xd9, 0x9e, 0xd5, 0xfd, 0x2b, 0xa5, 0x86, - 0xad, 0x60, 0x23, 0xbe, 0xe5, 0xb1, 0xe4, 0xb1, 0xb7, 0x5c, 0xcc, 0x56}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xa6, 0xb4, 0x6a, 0x20}; + lwmqtt_string_t topic_filter_s2 = {4, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x5b, 0x51}; - lwmqtt_string_t topic_filter_s3 = {2, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x6d, 0x10, 0x56, 0xf0, 0x37, 0x96, 0x11, 0xf8, 0x6c, 0x58, + 0x88, 0x82, 0xcd, 0x5d, 0xe9, 0x8e, 0x4e, 0x4c, 0x79, 0x9, + 0x42, 0xfb, 0x6c, 0x6c, 0x2c, 0x60, 0x9b, 0x45, 0x8f, 0x8a}; + lwmqtt_string_t topic_filter_s3 = {30, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xbe, 0xb4, 0x75, 0xde, 0x23, 0xab, 0x1a, 0x69, 0x6b, 0xdd, - 0xf6, 0xe3, 0xa4, 0x29, 0xef, 0xd2, 0x4, 0x34, 0x5b, 0x2d}; - lwmqtt_string_t topic_filter_s4 = {20, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x8d, 0x1d, 0xc3, 0xb1, 0x29, 0x5f, 0x29, 0x77, 0x39, + 0x43, 0xea, 0x84, 0x48, 0x9a, 0x11, 0x4a, 0x93}; + lwmqtt_string_t topic_filter_s4 = {17, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x66, 0xe, 0xed, 0x69, 0x53, 0xc5, 0x54, 0xf7, 0xfa, 0xa7, 0x3f, 0xe4, 0xf2, - 0xaa, 0xd5, 0x5f, 0x62, 0xd7, 0xf1, 0xdd, 0x99, 0x88, 0x8a, 0xe5, 0xaf}; - lwmqtt_string_t topic_filter_s5 = {25, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xd5, 0xd7, 0x50}; + lwmqtt_string_t topic_filter_s5 = {3, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x45, 0x7d, 0x1a, 0xdd, 0x53, 0xac, 0x20, 0x1c, 0xbd, 0x26, 0x7d, 0x76, 0xdc}; - lwmqtt_string_t topic_filter_s6 = {13, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xf7, 0xef, 0x9e}; + lwmqtt_string_t topic_filter_s6 = {3, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xe2, 0xa5, 0x23, 0x87, 0xe6, 0x3b, 0xf5, 0xe9, 0xab, 0x7d}; + lwmqtt_string_t topic_filter_s7 = {10, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xca, 0x3e, 0x6d, 0x84, 0x1d, 0x39, 0x91, 0xf6, 0x89, 0x15, 0xed, 0x51}; + lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5737, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26276, 9, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 1255 -// ["\153\GSI\185K\229\aE*T\235?5*(","9\225=)\198\150\245\192\130\194N\204d\137\162(\248\142n","\163\168\DEL\193\254\161\250\166\204\221\231\250\&9\228\202\163\162%\242c\223\217\250\182","\255\201\247\&9\DC4?\255\229\SI\EOT\228fc\ETB\177\225+b\159\&5O\218\ACK\132","\251\n\SYN~\RS\180\172y\RS\f\228\211*\214","Uq\215s\244Y",""] -// [PropTopicAlias 4162,PropPayloadFormatIndicator 254,PropUserProperty -// "5\180\&0\209`\241\DC3Q\153\174O\ETX\bc<<\162[\141\129P\220\216\148\220x" -// "\146S\252\226\\\149\181\202\US\145\b\182\223\234\173\224",PropUserProperty "t\185\147" -// "m\251\147\fY\178\145\135\209\199\248-s0",PropReasonString -// "\231\252\248\150I\STX\176\DLEz\222\201\SI\DC2\NUL\193Q\207* ",PropSubscriptionIdentifier 30,PropMaximumQoS -// 59,PropRetainAvailable 10,PropServerKeepAlive 9939] +// UnsubscribeRequest 10986 ["\211N\246\229\152\243\228\134\131\ETX\138\162\&1\EOT\161\135L\163\147\186\NUL"] +// [PropTopicAlias 18907,PropRequestResponseInformation 76,PropMaximumQoS 0,PropUserProperty +// "\139\173\bi-\151rW\178\186\132\&8s\205U\153\230\216\bn7D\136\FS\SUB\fC" +// ";\144\&9\160\&0\173\236{\EOT\156l:\RS",PropWildcardSubscriptionAvailable 142,PropPayloadFormatIndicator +// 8,PropRequestProblemInformation 96] TEST(Unsubscribe5QCTest, Encode14) { - uint8_t pkt[] = { - 0xa2, 0xe0, 0x1, 0x4, 0xe7, 0x69, 0x23, 0x10, 0x42, 0x1, 0xfe, 0x26, 0x0, 0x1a, 0x35, 0xb4, 0x30, 0xd1, 0x60, - 0xf1, 0x13, 0x51, 0x99, 0xae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b4, - 0xac, 0x79, 0x1e, 0xc, 0xe4, 0xd3, 0x2a, 0xd6, 0x0, 0x6, 0x55, 0x71, 0xd7, 0x73, 0xf4, 0x59, 0x0, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x92, 0x53, 0xfc, 0xe2, 0x5c, 0x95, 0xb5, 0xca, - 0x1f, 0x91, 0x8, 0xb6, 0xdf, 0xea, 0xad, 0xe0}; - uint8_t bytesprops0[] = {0x35, 0xb4, 0x30, 0xd1, 0x60, 0xf1, 0x13, 0x51, 0x99, 0xae, 0x4f, 0x3, 0x8, - 0x63, 0x3c, 0x3c, 0xa2, 0x5b, 0x8d, 0x81, 0x50, 0xdc, 0xd8, 0x94, 0xdc, 0x78}; - uint8_t bytesprops3[] = {0x6d, 0xfb, 0x93, 0xc, 0x59, 0xb2, 0x91, 0x87, 0xd1, 0xc7, 0xf8, 0x2d, 0x73, 0x30}; - uint8_t bytesprops2[] = {0x74, 0xb9, 0x93}; - uint8_t bytesprops4[] = {0xe7, 0xfc, 0xf8, 0x96, 0x49, 0x2, 0xb0, 0x10, 0x7a, 0xde, - 0xc9, 0xf, 0x12, 0x0, 0xc1, 0x51, 0xcf, 0x2a, 0x20}; + uint8_t pkt[] = {0xa2, 0x54, 0x2a, 0xea, 0x3a, 0x23, 0x49, 0xdb, 0x19, 0x4c, 0x24, 0x0, 0x26, 0x0, 0x1b, + 0x8b, 0xad, 0x8, 0x69, 0x2d, 0x97, 0x72, 0x57, 0xb2, 0xba, 0x84, 0x38, 0x73, 0xcd, 0x55, + 0x99, 0xe6, 0xd8, 0x8, 0x6e, 0x37, 0x44, 0x88, 0x1c, 0x1a, 0xc, 0x43, 0x0, 0xd, 0x3b, + 0x90, 0x39, 0xa0, 0x30, 0xad, 0xec, 0x7b, 0x4, 0x9c, 0x6c, 0x3a, 0x1e, 0x28, 0x8e, 0x1, + 0x8, 0x17, 0x60, 0x0, 0x15, 0xd3, 0x4e, 0xf6, 0xe5, 0x98, 0xf3, 0xe4, 0x86, 0x83, 0x3, + 0x8a, 0xa2, 0x31, 0x4, 0xa1, 0x87, 0x4c, 0xa3, 0x93, 0xba, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0x3b, 0x90, 0x39, 0xa0, 0x30, 0xad, 0xec, 0x7b, 0x4, 0x9c, 0x6c, 0x3a, 0x1e}; + uint8_t bytesprops0[] = {0x8b, 0xad, 0x8, 0x69, 0x2d, 0x97, 0x72, 0x57, 0xb2, 0xba, 0x84, 0x38, 0x73, 0xcd, + 0x55, 0x99, 0xe6, 0xd8, 0x8, 0x6e, 0x37, 0x44, 0x88, 0x1c, 0x1a, 0xc, 0x43}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4162}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 254}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {26, (char*)&bytesprops0}, .v = {16, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops2}, .v = {14, (char*)&bytesprops3}}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 59}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 10}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 9939}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 18907}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 0}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops0}, .v = {13, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 96}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[7]; - uint8_t topic_filter_s0_bytes[] = {0x99, 0x1d, 0x49, 0xb9, 0x4b, 0xe5, 0x7, 0x45, - 0x2a, 0x54, 0xeb, 0x3f, 0x35, 0x2a, 0x28}; - lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0xd3, 0x4e, 0xf6, 0xe5, 0x98, 0xf3, 0xe4, 0x86, 0x83, 0x3, 0x8a, + 0xa2, 0x31, 0x4, 0xa1, 0x87, 0x4c, 0xa3, 0x93, 0xba, 0x0}; + lwmqtt_string_t topic_filter_s0 = {21, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x39, 0xe1, 0x3d, 0x29, 0xc6, 0x96, 0xf5, 0xc0, 0x82, 0xc2, - 0x4e, 0xcc, 0x64, 0x89, 0xa2, 0x28, 0xf8, 0x8e, 0x6e}; - lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xa3, 0xa8, 0x7f, 0xc1, 0xfe, 0xa1, 0xfa, 0xa6, 0xcc, 0xdd, 0xe7, 0xfa, - 0x39, 0xe4, 0xca, 0xa3, 0xa2, 0x25, 0xf2, 0x63, 0xdf, 0xd9, 0xfa, 0xb6}; - lwmqtt_string_t topic_filter_s2 = {24, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xff, 0xc9, 0xf7, 0x39, 0x14, 0x3f, 0xff, 0xe5, 0xf, 0x4, 0xe4, 0x66, - 0x63, 0x17, 0xb1, 0xe1, 0x2b, 0x62, 0x9f, 0x35, 0x4f, 0xda, 0x6, 0x84}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xfb, 0xa, 0x16, 0x7e, 0x1e, 0xb4, 0xac, 0x79, 0x1e, 0xc, 0xe4, 0xd3, 0x2a, 0xd6}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x55, 0x71, 0xd7, 0x73, 0xf4, 0x59}; - lwmqtt_string_t topic_filter_s5 = {6, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0}; - lwmqtt_string_t topic_filter_s6 = {0, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1255, 7, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 10986, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 22682 -// ["\DEL\148\206K\136Hx\216\137\137*\209\248*\186\130\163\206@\US%\179s","\232\&0\131\241\219a\152\207V\185\213v\186[\165\191\DC4`K\144\228\194\ETBVgW","\195\211\171c\216\f\DC2\165`\183Pj\228\216~\238@","5\234\US\174\183$\196V\DLE\168\247\255","h7\224\134\254\229\GSn\131_1\200>e","H\ETB\172+\157d!VF\131\157!\EM\201","\179U.\225i\222\SYN\136b\NULw\SOH\187\&1M\135p:","Y\189?\174\nQyM\165.\"\ENQ\140__\192\254\187\228","\239\222\226\181\184\209\133\199\&7O\254\175","\EOT\229\DC4.X\129\129\&5\204;\230"] -// [PropTopicAliasMaximum 15955,PropSubscriptionIdentifierAvailable 218,PropAuthenticationData -// ",'\230\136\175\237L^S",PropMessageExpiryInterval 20146,PropSharedSubscriptionAvailable 119,PropMaximumPacketSize -// 717,PropMaximumQoS 165,PropUserProperty "e\\ -// \193\USx\224\213ke\ESC\182\207\&5\145\169\&3\195\165\252\DELw\247l\205tT\147\DC4" -// "\CAN\243\223A\186\155\b\201\206\190m\138\131\252\213<\173\&6\131\184\&5Qc\206",PropAssignedClientIdentifier -// "&\195\165\134\165~UM\243\248\203\&9\ETB|\141*\234\129\149\212",PropServerKeepAlive 16880,PropMessageExpiryInterval -// 32380,PropMessageExpiryInterval 24349,PropTopicAliasMaximum 10485] +// UnsubscribeRequest 4312 +// ["\193\221H\191\161\206J\DC1\180\232?","P\140\182\141z\SOH\RS\130=\215\199\SI\253\203k\169","\230\174","\186c\168Ddi\167\152\197"] +// [PropReasonString "\177\DC1\245i\223\170\f",PropTopicAlias 8170,PropRequestProblemInformation 127,PropUserProperty +// "\r#\170" "!\212| ",PropSessionExpiryInterval 9961,PropCorrelationData "}\CAN\228M_\210.\ACKV",PropMaximumPacketSize +// 23538,PropResponseInformation +// "\231\249\219eT\159\180\203\200\191R\EOTV}\195\252r\157\212\")\146\213\"o\140",PropSubscriptionIdentifier +// 1,PropAssignedClientIdentifier "\SOz\177\229\185\134\132",PropMaximumPacketSize 21322,PropMessageExpiryInterval +// 19426] TEST(Unsubscribe5QCTest, Encode15) { - uint8_t pkt[] = { - 0xa2, 0xbe, 0x2, 0x58, 0x9a, 0x80, 0x1, 0x22, 0x3e, 0x53, 0x29, 0xda, 0x16, 0x0, 0x9, 0x2c, 0x27, 0xe6, 0x88, - 0xaf, 0xed, 0x4c, 0x5e, 0x53, 0x2, 0x0, 0x0, 0x4e, 0xb2, 0x2a, 0x77, 0x27, 0x0, 0x0, 0x2, 0xcd, 0x24, 0xa5, - 0x26, 0x0, 0x1d, 0x65, 0x5c, 0x20, 0xc1, 0x1f, 0x78, 0xe0, 0xd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c8, 0x3e, 0x65, 0x0, 0xe, 0x48, 0x17, 0xac, 0x2b, 0x9d, 0x64, 0x21, 0x56, - 0x46, 0x83, 0x9d, 0x21, 0x19, 0xc9, 0x0, 0x12, 0xb3, 0x55, 0x2e, 0xe1, 0x69, 0xde, 0x16, 0x88, 0x62, 0x0, 0x77, - 0x1, 0xbb, 0x31, 0x4d, 0x87, 0x70, 0x3a, 0x0, 0x13, 0x59, 0xbd, 0x3f, 0xae, 0xa, 0x51, 0x79, 0x4d, 0xa5, 0x2e, - 0x22, 0x5, 0x8c, 0x5f, 0x5f, 0xc0, 0xfe, 0xbb, 0xe4, 0x0, 0xc, 0xef, 0xde, 0xe2, 0xb5, 0xb8, 0xd1, 0x85, 0xc7, - 0x37, 0x4f, 0xfe, 0xaf, 0x0, 0xb, 0x4, 0xe5, 0x14, 0x2e, 0x58, 0x81, 0x81, 0x35, 0xcc, 0x3b, 0xe6}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x2c, 0x27, 0xe6, 0x88, 0xaf, 0xed, 0x4c, 0x5e, 0x53}; - uint8_t bytesprops2[] = {0x18, 0xf3, 0xdf, 0x41, 0xba, 0x9b, 0x8, 0xc9, 0xce, 0xbe, 0x6d, 0x8a, - 0x83, 0xfc, 0xd5, 0x3c, 0xad, 0x36, 0x83, 0xb8, 0x35, 0x51, 0x63, 0xce}; - uint8_t bytesprops1[] = {0x65, 0x5c, 0x20, 0xc1, 0x1f, 0x78, 0xe0, 0xd5, 0x6b, 0x65, 0x1b, 0xb6, 0xcf, 0x35, 0x91, - 0xa9, 0x33, 0xc3, 0xa5, 0xfc, 0x7f, 0x77, 0xf7, 0x6c, 0xcd, 0x74, 0x54, 0x93, 0x14}; - uint8_t bytesprops3[] = {0x26, 0xc3, 0xa5, 0x86, 0xa5, 0x7e, 0x55, 0x4d, 0xf3, 0xf8, - 0xcb, 0x39, 0x17, 0x7c, 0x8d, 0x2a, 0xea, 0x81, 0x95, 0xd4}; + uint8_t pkt[] = {0xa2, 0x95, 0x1, 0x10, 0xd8, 0x64, 0x1f, 0x0, 0x7, 0xb1, 0x11, 0xf5, 0x69, 0xdf, 0xaa, 0xc, 0x23, + 0x1f, 0xea, 0x17, 0x7f, 0x26, 0x0, 0x3, 0xd, 0x23, 0xaa, 0x0, 0x4, 0x21, 0xd4, 0x7c, 0x20, 0x11, + 0x0, 0x0, 0x26, 0xe9, 0x9, 0x0, 0x9, 0x7d, 0x18, 0xe4, 0x4d, 0x5f, 0xd2, 0x2e, 0x6, 0x56, 0x27, + 0x0, 0x0, 0x5b, 0xf2, 0x1a, 0x0, 0x1a, 0xe7, 0xf9, 0xdb, 0x65, 0x54, 0x9f, 0xb4, 0xcb, 0xc8, 0xbf, + 0x52, 0x4, 0x56, 0x7d, 0xc3, 0xfc, 0x72, 0x9d, 0xd4, 0x22, 0x29, 0x92, 0xd5, 0x22, 0x6f, 0x8c, 0xb, + 0x1, 0x12, 0x0, 0x7, 0xe, 0x7a, 0xb1, 0xe5, 0xb9, 0x86, 0x84, 0x27, 0x0, 0x0, 0x53, 0x4a, 0x2, + 0x0, 0x0, 0x4b, 0xe2, 0x0, 0xb, 0xc1, 0xdd, 0x48, 0xbf, 0xa1, 0xce, 0x4a, 0x11, 0xb4, 0xe8, 0x3f, + 0x0, 0x10, 0x50, 0x8c, 0xb6, 0x8d, 0x7a, 0x1, 0x1e, 0x82, 0x3d, 0xd7, 0xc7, 0xf, 0xfd, 0xcb, 0x6b, + 0xa9, 0x0, 0x2, 0xe6, 0xae, 0x0, 0x9, 0xba, 0x63, 0xa8, 0x44, 0x64, 0x69, 0xa7, 0x98, 0xc5}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb1, 0x11, 0xf5, 0x69, 0xdf, 0xaa, 0xc}; + uint8_t bytesprops2[] = {0x21, 0xd4, 0x7c, 0x20}; + uint8_t bytesprops1[] = {0xd, 0x23, 0xaa}; + uint8_t bytesprops3[] = {0x7d, 0x18, 0xe4, 0x4d, 0x5f, 0xd2, 0x2e, 0x6, 0x56}; + uint8_t bytesprops4[] = {0xe7, 0xf9, 0xdb, 0x65, 0x54, 0x9f, 0xb4, 0xcb, 0xc8, 0xbf, 0x52, 0x4, 0x56, + 0x7d, 0xc3, 0xfc, 0x72, 0x9d, 0xd4, 0x22, 0x29, 0x92, 0xd5, 0x22, 0x6f, 0x8c}; + uint8_t bytesprops5[] = {0xe, 0x7a, 0xb1, 0xe5, 0xb9, 0x86, 0x84}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15955}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20146}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 119}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 717}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {24, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 16880}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32380}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24349}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10485}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8170}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops1}, .v = {4, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 9961}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {9, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23538}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {26, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {7, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21322}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19426}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x7f, 0x94, 0xce, 0x4b, 0x88, 0x48, 0x78, 0xd8, 0x89, 0x89, 0x2a, 0xd1, - 0xf8, 0x2a, 0xba, 0x82, 0xa3, 0xce, 0x40, 0x1f, 0x25, 0xb3, 0x73}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[4]; + uint8_t topic_filter_s0_bytes[] = {0xc1, 0xdd, 0x48, 0xbf, 0xa1, 0xce, 0x4a, 0x11, 0xb4, 0xe8, 0x3f}; + lwmqtt_string_t topic_filter_s0 = {11, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xe8, 0x30, 0x83, 0xf1, 0xdb, 0x61, 0x98, 0xcf, 0x56, 0xb9, 0xd5, 0x76, 0xba, - 0x5b, 0xa5, 0xbf, 0x14, 0x60, 0x4b, 0x90, 0xe4, 0xc2, 0x17, 0x56, 0x67, 0x57}; - lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x50, 0x8c, 0xb6, 0x8d, 0x7a, 0x1, 0x1e, 0x82, + 0x3d, 0xd7, 0xc7, 0xf, 0xfd, 0xcb, 0x6b, 0xa9}; + lwmqtt_string_t topic_filter_s1 = {16, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xc3, 0xd3, 0xab, 0x63, 0xd8, 0xc, 0x12, 0xa5, 0x60, - 0xb7, 0x50, 0x6a, 0xe4, 0xd8, 0x7e, 0xee, 0x40}; - lwmqtt_string_t topic_filter_s2 = {17, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe6, 0xae}; + lwmqtt_string_t topic_filter_s2 = {2, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x35, 0xea, 0x1f, 0xae, 0xb7, 0x24, 0xc4, 0x56, 0x10, 0xa8, 0xf7, 0xff}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xba, 0x63, 0xa8, 0x44, 0x64, 0x69, 0xa7, 0x98, 0xc5}; + lwmqtt_string_t topic_filter_s3 = {9, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x68, 0x37, 0xe0, 0x86, 0xfe, 0xe5, 0x1d, - 0x6e, 0x83, 0x5f, 0x31, 0xc8, 0x3e, 0x65}; - lwmqtt_string_t topic_filter_s4 = {14, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x48, 0x17, 0xac, 0x2b, 0x9d, 0x64, 0x21, - 0x56, 0x46, 0x83, 0x9d, 0x21, 0x19, 0xc9}; - lwmqtt_string_t topic_filter_s5 = {14, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xb3, 0x55, 0x2e, 0xe1, 0x69, 0xde, 0x16, 0x88, 0x62, - 0x0, 0x77, 0x1, 0xbb, 0x31, 0x4d, 0x87, 0x70, 0x3a}; - lwmqtt_string_t topic_filter_s6 = {18, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x59, 0xbd, 0x3f, 0xae, 0xa, 0x51, 0x79, 0x4d, 0xa5, 0x2e, - 0x22, 0x5, 0x8c, 0x5f, 0x5f, 0xc0, 0xfe, 0xbb, 0xe4}; - lwmqtt_string_t topic_filter_s7 = {19, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xef, 0xde, 0xe2, 0xb5, 0xb8, 0xd1, 0x85, 0xc7, 0x37, 0x4f, 0xfe, 0xaf}; - lwmqtt_string_t topic_filter_s8 = {12, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x4, 0xe5, 0x14, 0x2e, 0x58, 0x81, 0x81, 0x35, 0xcc, 0x3b, 0xe6}; - lwmqtt_string_t topic_filter_s9 = {11, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22682, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4312, 4, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 24213 ["\253g\ETX\138\DLEW\170\231\214\133H\RS\206+f|@C\175*,\178\EM"] [PropReasonString -// "\186\180\226c\131\202\223\151\STX`",PropServerReference "x\218\225\CAN\220\235E\DC3t",PropContentType -// "\238c\t\181\SOH\159y\196?\EM\228\241\150",PropPayloadFormatIndicator 49,PropReasonString -// "\177u\EOT\140y\182\SIP\159X",PropSessionExpiryInterval 22727,PropSharedSubscriptionAvailable -// 247,PropWillDelayInterval 17613,PropMaximumQoS 207,PropMaximumPacketSize 23689,PropServerKeepAlive -// 3885,PropContentType "\241,$\a\253H\233\190A\241g\"\184Z\171\233\203Q4\186d\"=\163%M\180",PropSessionExpiryInterval -// 24885,PropMaximumQoS 39,PropServerKeepAlive 2980] +// UnsubscribeRequest 12998 ["\f\217\182 +\CAN\154)2\SO"] [PropCorrelationData +// "\232\193\192zR",PropSubscriptionIdentifierAvailable 146,PropAuthenticationMethod +// "\249\140^\USFo\247o\136\211\&7r)Q\159Q3\228\&3\146\136Zl\145\ESC}",PropReceiveMaximum 5706,PropMaximumPacketSize +// 18696,PropResponseTopic +// "\135\224F\CAN\251\251\DC2\251\180!yd/;O\215$\162\ESC\224\&8}g\133\165\DEL",PropSessionExpiryInterval +// 10454,PropWillDelayInterval 4333,PropTopicAlias 1873,PropSubscriptionIdentifier 20,PropMaximumQoS +// 85,PropSharedSubscriptionAvailable 53,PropWildcardSubscriptionAvailable 206,PropServerKeepAlive +// 14411,PropSubscriptionIdentifierAvailable 22] TEST(Unsubscribe5QCTest, Encode16) { - uint8_t pkt[] = {0xa2, 0x92, 0x1, 0x5e, 0x95, 0x76, 0x1f, 0x0, 0xa, 0xba, 0xb4, 0xe2, 0x63, 0x83, 0xca, 0xdf, 0x97, - 0x2, 0x60, 0x1c, 0x0, 0x9, 0x78, 0xda, 0xe1, 0x18, 0xdc, 0xeb, 0x45, 0x13, 0x74, 0x3, 0x0, 0xd, - 0xee, 0x63, 0x9, 0xb5, 0x1, 0x9f, 0x79, 0xc4, 0x3f, 0x19, 0xe4, 0xf1, 0x96, 0x1, 0x31, 0x1f, 0x0, - 0xa, 0xb1, 0x75, 0x4, 0x8c, 0x79, 0xb6, 0xf, 0x50, 0x9f, 0x58, 0x11, 0x0, 0x0, 0x58, 0xc7, 0x2a, - 0xf7, 0x18, 0x0, 0x0, 0x44, 0xcd, 0x24, 0xcf, 0x27, 0x0, 0x0, 0x5c, 0x89, 0x13, 0xf, 0x2d, 0x3, - 0x0, 0x1b, 0xf1, 0x2c, 0x24, 0x7, 0xfd, 0x48, 0xe9, 0xbe, 0x41, 0xf1, 0x67, 0x22, 0xb8, 0x5a, 0xab, - 0xe9, 0xcb, 0x51, 0x34, 0xba, 0x64, 0x22, 0x3d, 0xa3, 0x25, 0x4d, 0xb4, 0x11, 0x0, 0x0, 0x61, 0x35, - 0x24, 0x27, 0x13, 0xb, 0xa4, 0x0, 0x17, 0xfd, 0x67, 0x3, 0x8a, 0x10, 0x57, 0xaa, 0xe7, 0xd6, 0x85, - 0x48, 0x1e, 0xce, 0x2b, 0x66, 0x7c, 0x40, 0x43, 0xaf, 0x2a, 0x2c, 0xb2, 0x19}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xba, 0xb4, 0xe2, 0x63, 0x83, 0xca, 0xdf, 0x97, 0x2, 0x60}; - uint8_t bytesprops1[] = {0x78, 0xda, 0xe1, 0x18, 0xdc, 0xeb, 0x45, 0x13, 0x74}; - uint8_t bytesprops2[] = {0xee, 0x63, 0x9, 0xb5, 0x1, 0x9f, 0x79, 0xc4, 0x3f, 0x19, 0xe4, 0xf1, 0x96}; - uint8_t bytesprops3[] = {0xb1, 0x75, 0x4, 0x8c, 0x79, 0xb6, 0xf, 0x50, 0x9f, 0x58}; - uint8_t bytesprops4[] = {0xf1, 0x2c, 0x24, 0x7, 0xfd, 0x48, 0xe9, 0xbe, 0x41, 0xf1, 0x67, 0x22, 0xb8, 0x5a, - 0xab, 0xe9, 0xcb, 0x51, 0x34, 0xba, 0x64, 0x22, 0x3d, 0xa3, 0x25, 0x4d, 0xb4}; + uint8_t pkt[] = {0xa2, 0x75, 0x32, 0xc6, 0x66, 0x9, 0x0, 0x5, 0xe8, 0xc1, 0xc0, 0x7a, 0x52, 0x29, 0x92, 0x15, 0x0, + 0x1a, 0xf9, 0x8c, 0x5e, 0x1f, 0x46, 0x6f, 0xf7, 0x6f, 0x88, 0xd3, 0x37, 0x72, 0x29, 0x51, 0x9f, 0x51, + 0x33, 0xe4, 0x33, 0x92, 0x88, 0x5a, 0x6c, 0x91, 0x1b, 0x7d, 0x21, 0x16, 0x4a, 0x27, 0x0, 0x0, 0x49, + 0x8, 0x8, 0x0, 0x1a, 0x87, 0xe0, 0x46, 0x18, 0xfb, 0xfb, 0x12, 0xfb, 0xb4, 0x21, 0x79, 0x64, 0x2f, + 0x3b, 0x4f, 0xd7, 0x24, 0xa2, 0x1b, 0xe0, 0x38, 0x7d, 0x67, 0x85, 0xa5, 0x7f, 0x11, 0x0, 0x0, 0x28, + 0xd6, 0x18, 0x0, 0x0, 0x10, 0xed, 0x23, 0x7, 0x51, 0xb, 0x14, 0x24, 0x55, 0x2a, 0x35, 0x28, 0xce, + 0x13, 0x38, 0x4b, 0x29, 0x16, 0x0, 0xa, 0xc, 0xd9, 0xb6, 0x20, 0x2b, 0x18, 0x9a, 0x29, 0x32, 0xe}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe8, 0xc1, 0xc0, 0x7a, 0x52}; + uint8_t bytesprops1[] = {0xf9, 0x8c, 0x5e, 0x1f, 0x46, 0x6f, 0xf7, 0x6f, 0x88, 0xd3, 0x37, 0x72, 0x29, + 0x51, 0x9f, 0x51, 0x33, 0xe4, 0x33, 0x92, 0x88, 0x5a, 0x6c, 0x91, 0x1b, 0x7d}; + uint8_t bytesprops2[] = {0x87, 0xe0, 0x46, 0x18, 0xfb, 0xfb, 0x12, 0xfb, 0xb4, 0x21, 0x79, 0x64, 0x2f, + 0x3b, 0x4f, 0xd7, 0x24, 0xa2, 0x1b, 0xe0, 0x38, 0x7d, 0x67, 0x85, 0xa5, 0x7f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {13, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 49}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 22727}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17613}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 207}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23689}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3885}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {27, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 24885}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 39}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 2980}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 5706}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 18696}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 10454}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 4333}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1873}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 20}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 85}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14411}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 22}}, }; lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[1]; - uint8_t topic_filter_s0_bytes[] = {0xfd, 0x67, 0x3, 0x8a, 0x10, 0x57, 0xaa, 0xe7, 0xd6, 0x85, 0x48, 0x1e, - 0xce, 0x2b, 0x66, 0x7c, 0x40, 0x43, 0xaf, 0x2a, 0x2c, 0xb2, 0x19}; - lwmqtt_string_t topic_filter_s0 = {23, (char*)&topic_filter_s0_bytes}; + uint8_t topic_filter_s0_bytes[] = {0xc, 0xd9, 0xb6, 0x20, 0x2b, 0x18, 0x9a, 0x29, 0x32, 0xe}; + lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24213, 1, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12998, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 26833 ["U\246\DEL\"\254\131\166\165\187} -// \200\GShm\235K\206G\207\253\148\237\168#\193","\250","\234\199f)*\128@\216\214'\215\213","\SO\NULF\227\255\SUBc\189X\168\213\213","\DC2Q\176m\\J","!f2>\204\138\CAN\NUL:\235\222"] -// [PropWildcardSubscriptionAvailable 200,PropSharedSubscriptionAvailable 227,PropMessageExpiryInterval -// 13811,PropSubscriptionIdentifier 14,PropServerKeepAlive 18124,PropRequestResponseInformation -// 22,PropAuthenticationData "3;\135\242nm2\175w\164\185\230 \240\194\209\137J,\SIk\129\235",PropAuthenticationData -// "W2",PropReasonString "",PropAuthenticationMethod -// "\141L\254\172y\221\160\177\162Q\253M\139a\175C\214>\SUB\DC1\144\&9'\188f7\195",PropAuthenticationData -// "\131K\255k\244\226\171\205\241"] +// UnsubscribeRequest 22695 +// ["\US=Q\130p\186\189<~\223\ETB\159\172\RS\"","\154\US\251v\173\148cR#\242{2&OX","","\207\130ja\252\230","w\208\209\&7\221\NAK\201\a\158"," +// \144\157t\SI\181?\209\217\255\240\SUB","\142v\242\219\199","\245v\238\\\DC3D\195\196\EM\a\252\245\160@F\f\226O\180\243YQ7\US\252\242","*\r#(\235\ETX3","\ETB\203\154\ENQ\171sq\ESC","\DC4w\144)\254\161\166\132@\214j\FSn\209A\DLE\fuHCo>\206fKmw"] +// [PropWillDelayInterval 19852,PropReceiveMaximum 13317,PropMessageExpiryInterval 19311,PropAuthenticationMethod +// "\195\206\DC2\n\244\188C\248:y\183\188\214\237\254\249\t\211\137)\"\194\240p\144\229\a",PropPayloadFormatIndicator +// 116,PropRetainAvailable 185,PropReasonString "\155#\US84+\166\138>\196\230\am~%\v\208@H",PropReasonString +// "\171\n\224\246\160+\199\162\239\143y_\205\174",PropMaximumPacketSize 19819,PropReceiveMaximum +// 21214,PropServerReference "",PropTopicAliasMaximum 24480,PropServerKeepAlive 31268,PropReasonString +// "Ru\f\133\174*;\DC2\142!\247o\179\STX\151\181\148\224\SO",PropAssignedClientIdentifier +// "h\181\180\&8\128\233d\175\"\186\180f\244\161\240\133!\188\130u~b\191\151\240=\164DQ\159"] TEST(Unsubscribe5QCTest, Encode17) { - uint8_t pkt[] = {0xa2, 0xaf, 0x1, 0x68, 0xd1, 0x5c, 0x28, 0xc8, 0x2a, 0xe3, 0x2, 0x0, 0x0, 0x35, 0xf3, 0xb, 0xe, - 0x13, 0x46, 0xcc, 0x19, 0x16, 0x16, 0x0, 0x17, 0x33, 0x3b, 0x87, 0xf2, 0x6e, 0x6d, 0x32, 0xaf, 0x77, - 0xa4, 0xb9, 0xe6, 0x20, 0xf0, 0xc2, 0xd1, 0x89, 0x4a, 0x2c, 0xf, 0x6b, 0x81, 0xeb, 0x16, 0x0, 0x2, - 0x57, 0x32, 0x1f, 0x0, 0x0, 0x15, 0x0, 0x1b, 0x8d, 0x4c, 0xfe, 0xac, 0x79, 0xdd, 0xa0, 0xb1, 0xa2, - 0x51, 0xfd, 0x4d, 0x8b, 0x61, 0xaf, 0x43, 0xd6, 0x3e, 0x1a, 0x11, 0x90, 0x39, 0x27, 0xbc, 0x66, 0x37, - 0xc3, 0x16, 0x0, 0x9, 0x83, 0x4b, 0xff, 0x6b, 0xf4, 0xe2, 0xab, 0xcd, 0xf1, 0x0, 0x1a, 0x55, 0xf6, - 0x7f, 0x22, 0xfe, 0x83, 0xa6, 0xa5, 0xbb, 0x7d, 0x20, 0xc8, 0x1d, 0x68, 0x6d, 0xeb, 0x4b, 0xce, 0x47, - 0xcf, 0xfd, 0x94, 0xed, 0xa8, 0x23, 0xc1, 0x0, 0x1, 0xfa, 0x0, 0xc, 0xea, 0xc7, 0x66, 0x29, 0x2a, - 0x80, 0x40, 0xd8, 0xd6, 0x27, 0xd7, 0xd5, 0x0, 0xc, 0xe, 0x0, 0x46, 0xe3, 0xff, 0x1a, 0x63, 0xbd, - 0x58, 0xa8, 0xd5, 0xd5, 0x0, 0x6, 0x12, 0x51, 0xb0, 0x6d, 0x5c, 0x4a, 0x0, 0xb, 0x21, 0x66, 0x32, - 0x3e, 0xcc, 0x8a, 0x18, 0x0, 0x3a, 0xeb, 0xde}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x33, 0x3b, 0x87, 0xf2, 0x6e, 0x6d, 0x32, 0xaf, 0x77, 0xa4, 0xb9, 0xe6, - 0x20, 0xf0, 0xc2, 0xd1, 0x89, 0x4a, 0x2c, 0xf, 0x6b, 0x81, 0xeb}; - uint8_t bytesprops1[] = {0x57, 0x32}; - uint8_t bytesprops2[] = {0}; - uint8_t bytesprops3[] = {0x8d, 0x4c, 0xfe, 0xac, 0x79, 0xdd, 0xa0, 0xb1, 0xa2, 0x51, 0xfd, 0x4d, 0x8b, 0x61, - 0xaf, 0x43, 0xd6, 0x3e, 0x1a, 0x11, 0x90, 0x39, 0x27, 0xbc, 0x66, 0x37, 0xc3}; - uint8_t bytesprops4[] = {0x83, 0x4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7e, 0xdf, 0x17, 0x9f, 0xac, 0x1e, 0x22, 0x0, 0xf, 0x9a, 0x1f, 0xfb, 0x76, 0xad, 0x94, + 0x63, 0x52, 0x23, 0xf2, 0x7b, 0x32, 0x26, 0x4f, 0x58, 0x0, 0x0, 0x0, 0x6, 0xcf, 0x82, 0x6a, 0x61, 0xfc, 0xe6, + 0x0, 0x9, 0x77, 0xd0, 0xd1, 0x37, 0xdd, 0x15, 0xc9, 0x7, 0x9e, 0x0, 0xc, 0x20, 0x90, 0x9d, 0x74, 0xf, 0xb5, + 0x3f, 0xd1, 0xd9, 0xff, 0xf0, 0x1a, 0x0, 0x5, 0x8e, 0x76, 0xf2, 0xdb, 0xc7, 0x0, 0x1a, 0xf5, 0x76, 0xee, 0x5c, + 0x13, 0x44, 0xc3, 0xc4, 0x19, 0x7, 0xfc, 0xf5, 0xa0, 0x40, 0x46, 0xc, 0xe2, 0x4f, 0xb4, 0xf3, 0x59, 0x51, 0x37, + 0x1f, 0xfc, 0xf2, 0x0, 0x7, 0x2a, 0xd, 0x23, 0x28, 0xeb, 0x3, 0x33, 0x0, 0x8, 0x17, 0xcb, 0x9a, 0x5, 0xab, + 0x73, 0x71, 0x1b, 0x0, 0x1b, 0x14, 0x77, 0x90, 0x29, 0xfe, 0xa1, 0xa6, 0x84, 0x40, 0xd6, 0x6a, 0x1c, 0x6e, 0xd1, + 0x41, 0x10, 0xc, 0x75, 0x48, 0x43, 0x6f, 0x3e, 0xce, 0x66, 0x4b, 0x6d, 0x77}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xc3, 0xce, 0x12, 0xa, 0xf4, 0xbc, 0x43, 0xf8, 0x3a, 0x79, 0xb7, 0xbc, 0xd6, 0xed, + 0xfe, 0xf9, 0x9, 0xd3, 0x89, 0x29, 0x22, 0xc2, 0xf0, 0x70, 0x90, 0xe5, 0x7}; + uint8_t bytesprops1[] = {0x9b, 0x23, 0x1f, 0x38, 0x34, 0x2b, 0xa6, 0x8a, 0x3e, 0xc4, + 0xe6, 0x7, 0x6d, 0x7e, 0x25, 0xb, 0xd0, 0x40, 0x48}; + uint8_t bytesprops2[] = {0xab, 0xa, 0xe0, 0xf6, 0xa0, 0x2b, 0xc7, 0xa2, 0xef, 0x8f, 0x79, 0x5f, 0xcd, 0xae}; + uint8_t bytesprops3[] = {0}; + uint8_t bytesprops4[] = {0x52, 0x75, 0xc, 0x85, 0xae, 0x2a, 0x3b, 0x12, 0x8e, 0x21, + 0xf7, 0x6f, 0xb3, 0x2, 0x97, 0xb5, 0x94, 0xe0, 0xe}; + uint8_t bytesprops5[] = {0x68, 0xb5, 0xb4, 0x38, 0x80, 0xe9, 0x64, 0xaf, 0x22, 0xba, 0xb4, 0x66, 0xf4, 0xa1, 0xf0, + 0x85, 0x21, 0xbc, 0x82, 0x75, 0x7e, 0x62, 0xbf, 0x97, 0xf0, 0x3d, 0xa4, 0x44, 0x51, 0x9f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13811}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 14}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 18124}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {9, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19852}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 13317}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19311}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 185}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {14, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19819}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 21214}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24480}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31268}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {19, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops5}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[6]; - uint8_t topic_filter_s0_bytes[] = {0x55, 0xf6, 0x7f, 0x22, 0xfe, 0x83, 0xa6, 0xa5, 0xbb, 0x7d, 0x20, 0xc8, 0x1d, - 0x68, 0x6d, 0xeb, 0x4b, 0xce, 0x47, 0xcf, 0xfd, 0x94, 0xed, 0xa8, 0x23, 0xc1}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x1f, 0x3d, 0x51, 0x82, 0x70, 0xba, 0xbd, 0x3c, + 0x7e, 0xdf, 0x17, 0x9f, 0xac, 0x1e, 0x22}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xfa}; - lwmqtt_string_t topic_filter_s1 = {1, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x9a, 0x1f, 0xfb, 0x76, 0xad, 0x94, 0x63, 0x52, + 0x23, 0xf2, 0x7b, 0x32, 0x26, 0x4f, 0x58}; + lwmqtt_string_t topic_filter_s1 = {15, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xea, 0xc7, 0x66, 0x29, 0x2a, 0x80, 0x40, 0xd8, 0xd6, 0x27, 0xd7, 0xd5}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0}; + lwmqtt_string_t topic_filter_s2 = {0, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xe, 0x0, 0x46, 0xe3, 0xff, 0x1a, 0x63, 0xbd, 0x58, 0xa8, 0xd5, 0xd5}; - lwmqtt_string_t topic_filter_s3 = {12, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0xcf, 0x82, 0x6a, 0x61, 0xfc, 0xe6}; + lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x12, 0x51, 0xb0, 0x6d, 0x5c, 0x4a}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x77, 0xd0, 0xd1, 0x37, 0xdd, 0x15, 0xc9, 0x7, 0x9e}; + lwmqtt_string_t topic_filter_s4 = {9, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x21, 0x66, 0x32, 0x3e, 0xcc, 0x8a, 0x18, 0x0, 0x3a, 0xeb, 0xde}; - lwmqtt_string_t topic_filter_s5 = {11, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x20, 0x90, 0x9d, 0x74, 0xf, 0xb5, 0x3f, 0xd1, 0xd9, 0xff, 0xf0, 0x1a}; + lwmqtt_string_t topic_filter_s5 = {12, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x8e, 0x76, 0xf2, 0xdb, 0xc7}; + lwmqtt_string_t topic_filter_s6 = {5, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0xf5, 0x76, 0xee, 0x5c, 0x13, 0x44, 0xc3, 0xc4, 0x19, 0x7, 0xfc, 0xf5, 0xa0, + 0x40, 0x46, 0xc, 0xe2, 0x4f, 0xb4, 0xf3, 0x59, 0x51, 0x37, 0x1f, 0xfc, 0xf2}; + lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x2a, 0xd, 0x23, 0x28, 0xeb, 0x3, 0x33}; + lwmqtt_string_t topic_filter_s8 = {7, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x17, 0xcb, 0x9a, 0x5, 0xab, 0x73, 0x71, 0x1b}; + lwmqtt_string_t topic_filter_s9 = {8, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0x14, 0x77, 0x90, 0x29, 0xfe, 0xa1, 0xa6, 0x84, 0x40, + 0xd6, 0x6a, 0x1c, 0x6e, 0xd1, 0x41, 0x10, 0xc, 0x75, + 0x48, 0x43, 0x6f, 0x3e, 0xce, 0x66, 0x4b, 0x6d, 0x77}; + lwmqtt_string_t topic_filter_s10 = {27, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26833, 6, topic_filters, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// UnsubscribeRequest 24597 ["\t\134\178\219\159\249\235\250\187","\166)\230\184Y\252\r.B"] [PropContentType -// "\240\211\EOT\253M(\135",PropServerKeepAlive 6586,PropReceiveMaximum 11671,PropAssignedClientIdentifier -// ":\151\235;\153&/d'Y\183V\227\212\200\223\148\238\204o\238\230\235\183\189\DC4\DC1",PropAuthenticationMethod -// "\DC1\DC1\207\184\DC4K\159\227\217\DC2\255\150",PropResponseInformation "^:k\148\222z\132\220&^",PropReceiveMaximum -// 9190,PropAuthenticationData "\219\EM\n\186\192\134\DC2\206/w\164T\STX\SO3>",PropUserProperty -// "\141j\SYN\159\212O\254\a\213\142\161?\NAK\255_\190\146\149'\180\169\214\246K@\154\230X" -// "\184\US\175\158\160\&6\153\SUBRRN\199$\219E4\214",PropSharedSubscriptionAvailable 44,PropContentType -// "\142\136\178\137\180\&23t\185\243a\207nB\200;\162w\193n\vX\163`h",PropSubscriptionIdentifier -// 11,PropMaximumPacketSize 24049,PropReceiveMaximum 24721,PropAssignedClientIdentifier -// "\237\FSGN\132j3%\DC3\vb\222\222aN",PropWildcardSubscriptionAvailable 128,PropWildcardSubscriptionAvailable -// 186,PropResponseInformation "]a]\148$\147\209:\204\164\207\155\251\f\143\194+\241\RS\200",PropPayloadFormatIndicator -// 42,PropMessageExpiryInterval 27416,PropMaximumQoS 5,PropTopicAlias 2410,PropReasonString -// "n\189k\144\152\197`}C_\242\SO\ENQ\240\a\ETXV\145\232\198T"] + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 22695, 11, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 6495 +// ["\144\187\SI\200\142y'N)^\214\NAK?\219\158\254U\230%dp\180","\136\DC3j\179'\202\200\245\NUL","\203'UwJf\198\144=(\SUB\t2\239\vn\ETX\STX\143\223\198\247","\203\207^\SUB\210\&1\139\213N\188\224\207\190\140","\ETB\201","w\233no\170\133\141i\142\ACK\178rv\222\&1\141\195\143U","12","","\181/"] +// [PropAuthenticationData "\ETB\141M\251\\Di",PropTopicAlias 9249,PropRetainAvailable 236,PropCorrelationData +// "0\178\161\SO\235:\233\221\233\181g\232\139",PropUserProperty "" +// "\238\DLE\164s,t\159\NAK\211\SOH\147\141p4\186\166\229\194v\GS\153\218\199\156l\130\160\238\242",PropReasonString +// "\141\NAK\237\131\240*)\SYNGp\157\251\DC3",PropReceiveMaximum 26390,PropWildcardSubscriptionAvailable +// 42,PropRequestResponseInformation 136,PropWildcardSubscriptionAvailable 16,PropMessageExpiryInterval +// 19909,PropAuthenticationMethod "\164\190\213\217\185j\156\214\133>\212x\SI\139\168X",PropRetainAvailable +// 67,PropReasonString "\137\ESC\209\247\203+\146FV",PropServerKeepAlive 24742,PropSubscriptionIdentifierAvailable +// 23,PropResponseTopic "\183\&4\141\SI0/\203=\SOi\GS",PropContentType "|\SUB",PropMessageExpiryInterval +// 1260,PropRequestResponseInformation 179,PropAssignedClientIdentifier "6+S\200l\SYN\211<\195?",PropMaximumQoS +// 9,PropReceiveMaximum 28565,PropRetainAvailable 217,PropReasonString +// "\233\"A\176\ETX\223\221\210B7b7\148s\144\&7\198F}\168\198\&4\SIqD~\228\251E\SUB",PropSubscriptionIdentifier +// 29,PropPayloadFormatIndicator 197,PropCorrelationData "\CAN\NUL.\235B\247\182",PropServerReference +// "V\209",PropServerKeepAlive 6395] TEST(Unsubscribe5QCTest, Encode18) { uint8_t pkt[] = { - 0xa2, 0xa5, 0x2, 0x60, 0x15, 0x8b, 0x2, 0x3, 0x0, 0x7, 0xf0, 0xd3, 0x4, 0xfd, 0x4d, 0x28, 0x87, 0x13, 0x19, - 0xba, 0x21, 0x2d, 0x97, 0x12, 0x0, 0x1b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28, 0x80, 0x28, 0xba, 0x1a, 0x0, 0x14, 0x5d, 0x61, 0x5d, 0x94, 0x24, 0x93, 0xd1, 0x3a, 0xcc, 0xa4, - 0xcf, 0x9b, 0xfb, 0xc, 0x8f, 0xc2, 0x2b, 0xf1, 0x1e, 0xc8, 0x1, 0x2a, 0x2, 0x0, 0x0, 0x6b, 0x18, 0x24, 0x5, - 0x23, 0x9, 0x6a, 0x1f, 0x0, 0x15, 0x6e, 0xbd, 0x6b, 0x90, 0x98, 0xc5, 0x60, 0x7d, 0x43, 0x5f, 0xf2, 0xe, 0x5, - 0xf0, 0x7, 0x3, 0x56, 0x91, 0xe8, 0xc6, 0x54, 0x0, 0x9, 0x9, 0x86, 0xb2, 0xdb, 0x9f, 0xf9, 0xeb, 0xfa, 0xbb, - 0x0, 0x9, 0xa6, 0x29, 0xe6, 0xb8, 0x59, 0xfc, 0xd, 0x2e, 0x42}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xf0, 0xd3, 0x4, 0xfd, 0x4d, 0x28, 0x87}; - uint8_t bytesprops1[] = {0x3a, 0x97, 0xeb, 0x3b, 0x99, 0x26, 0x2f, 0x64, 0x27, 0x59, 0xb7, 0x56, 0xe3, 0xd4, - 0xc8, 0xdf, 0x94, 0xee, 0xcc, 0x6f, 0xee, 0xe6, 0xeb, 0xb7, 0xbd, 0x14, 0x11}; - uint8_t bytesprops2[] = {0x11, 0x11, 0xcf, 0xb8, 0x14, 0x4b, 0x9f, 0xe3, 0xd9, 0x12, 0xff, 0x96}; - uint8_t bytesprops3[] = {0x5e, 0x3a, 0x6b, 0x94, 0xde, 0x7a, 0x84, 0xdc, 0x26, 0x5e}; - uint8_t bytesprops4[] = {0xdb, 0x19, 0xa, 0xba, 0xc0, 0x86, 0x12, 0xce, 0x2f, 0x77, 0xa4, 0x54, 0x2, 0xe, 0x33, 0x3e}; - uint8_t bytesprops6[] = {0xb8, 0x1f, 0xaf, 0x9e, 0xa0, 0x36, 0x99, 0x1a, 0x52, - 0x52, 0x4e, 0xc7, 0x24, 0xdb, 0x45, 0x34, 0xd6}; - uint8_t bytesprops5[] = {0x8d, 0x6a, 0x16, 0x9f, 0xd4, 0x4f, 0xfe, 0x7, 0xd5, 0x8e, 0xa1, 0x3f, 0x15, 0xff, - 0x5f, 0xbe, 0x92, 0x95, 0x27, 0xb4, 0xa9, 0xd6, 0xf6, 0x4b, 0x40, 0x9a, 0xe6, 0x58}; - uint8_t bytesprops7[] = {0x8e, 0x88, 0xb2, 0x89, 0xb4, 0x32, 0x33, 0x74, 0xb9, 0xf3, 0x61, 0xcf, 0x6e, - 0x42, 0xc8, 0x3b, 0xa2, 0x77, 0xc1, 0x6e, 0xb, 0x58, 0xa3, 0x60, 0x68}; - uint8_t bytesprops8[] = {0xed, 0x1c, 0x47, 0x4e, 0x84, 0x6a, 0x33, 0x25, 0x13, 0xb, 0x62, 0xde, 0xde, 0x61, 0x4e}; - uint8_t bytesprops9[] = {0x5d, 0x61, 0x5d, 0x94, 0x24, 0x93, 0xd1, 0x3a, 0xcc, 0xa4, - 0xcf, 0x9b, 0xfb, 0xc, 0x8f, 0xc2, 0x2b, 0xf1, 0x1e, 0xc8}; - uint8_t bytesprops10[] = {0x6e, 0xbd, 0x6b, 0x90, 0x98, 0xc5, 0x60, 0x7d, 0x43, 0x5f, 0xf2, - 0xe, 0x5, 0xf0, 0x7, 0x3, 0x56, 0x91, 0xe8, 0xc6, 0x54}; + 0xa2, 0xdc, 0x2, 0x19, 0x5f, 0xea, 0x1, 0x16, 0x0, 0x7, 0x17, 0x8d, 0x4d, 0xfb, 0x5c, 0x44, 0x69, 0x23, 0x24, + 0x21, 0x25, 0xec, 0x9, 0x0, 0xd, 0x30, 0xb2, 0xa1, 0xe, 0xeb, 0x3a, 0xe9, 0xdd, 0xe9, 0xb5, 0x67, 0xe8, 0x8b, + 0x26, 0x0, 0x0, 0x0, 0x1d, 0xee, 0x10, 0xa4, 0x73, 0x2c, 0x74, 0x9f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, 0xd1, 0x13, 0x18, 0xfb, 0x0, 0x16, 0x90, 0xbb, 0xf, 0xc8, + 0x8e, 0x79, 0x27, 0x4e, 0x29, 0x5e, 0xd6, 0x15, 0x3f, 0xdb, 0x9e, 0xfe, 0x55, 0xe6, 0x25, 0x64, 0x70, 0xb4, 0x0, + 0x9, 0x88, 0x13, 0x6a, 0xb3, 0x27, 0xca, 0xc8, 0xf5, 0x0, 0x0, 0x16, 0xcb, 0x27, 0x55, 0x77, 0x4a, 0x66, 0xc6, + 0x90, 0x3d, 0x28, 0x1a, 0x9, 0x32, 0xef, 0xb, 0x6e, 0x3, 0x2, 0x8f, 0xdf, 0xc6, 0xf7, 0x0, 0xe, 0xcb, 0xcf, + 0x5e, 0x1a, 0xd2, 0x31, 0x8b, 0xd5, 0x4e, 0xbc, 0xe0, 0xcf, 0xbe, 0x8c, 0x0, 0x2, 0x17, 0xc9, 0x0, 0x13, 0x77, + 0xe9, 0x6e, 0x6f, 0xaa, 0x85, 0x8d, 0x69, 0x8e, 0x6, 0xb2, 0x72, 0x76, 0xde, 0x31, 0x8d, 0xc3, 0x8f, 0x55, 0x0, + 0x2, 0x31, 0x32, 0x0, 0x0, 0x0, 0x2, 0xb5, 0x2f}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x17, 0x8d, 0x4d, 0xfb, 0x5c, 0x44, 0x69}; + uint8_t bytesprops1[] = {0x30, 0xb2, 0xa1, 0xe, 0xeb, 0x3a, 0xe9, 0xdd, 0xe9, 0xb5, 0x67, 0xe8, 0x8b}; + uint8_t bytesprops3[] = {0xee, 0x10, 0xa4, 0x73, 0x2c, 0x74, 0x9f, 0x15, 0xd3, 0x1, 0x93, 0x8d, 0x70, 0x34, 0xba, + 0xa6, 0xe5, 0xc2, 0x76, 0x1d, 0x99, 0xda, 0xc7, 0x9c, 0x6c, 0x82, 0xa0, 0xee, 0xf2}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops4[] = {0x8d, 0x15, 0xed, 0x83, 0xf0, 0x2a, 0x29, 0x16, 0x47, 0x70, 0x9d, 0xfb, 0x13}; + uint8_t bytesprops5[] = {0xa4, 0xbe, 0xd5, 0xd9, 0xb9, 0x6a, 0x9c, 0xd6, + 0x85, 0x3e, 0xd4, 0x78, 0xf, 0x8b, 0xa8, 0x58}; + uint8_t bytesprops6[] = {0x89, 0x1b, 0xd1, 0xf7, 0xcb, 0x2b, 0x92, 0x46, 0x56}; + uint8_t bytesprops7[] = {0xb7, 0x34, 0x8d, 0xf, 0x30, 0x2f, 0xcb, 0x3d, 0xe, 0x69, 0x1d}; + uint8_t bytesprops8[] = {0x7c, 0x1a}; + uint8_t bytesprops9[] = {0x36, 0x2b, 0x53, 0xc8, 0x6c, 0x16, 0xd3, 0x3c, 0xc3, 0x3f}; + uint8_t bytesprops10[] = {0xe9, 0x22, 0x41, 0xb0, 0x3, 0xdf, 0xdd, 0xd2, 0x42, 0x37, 0x62, 0x37, 0x94, 0x73, 0x90, + 0x37, 0xc6, 0x46, 0x7d, 0xa8, 0xc6, 0x34, 0xf, 0x71, 0x44, 0x7e, 0xe4, 0xfb, 0x45, 0x1a}; + uint8_t bytesprops11[] = {0x18, 0x0, 0x2e, 0xeb, 0x42, 0xf7, 0xb6}; + uint8_t bytesprops12[] = {0x56, 0xd1}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {7, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6586}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 11671}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 9190}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {28, (char*)&bytesprops5}, .v = {17, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 44}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24049}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24721}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 128}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 186}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27416}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 2410}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {21, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {7, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 9249}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops2}, .v = {29, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 26390}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 42}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 136}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 16}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 19909}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 67}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 24742}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 23}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {2, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1260}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 179}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {10, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 28565}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 217}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {30, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 197}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {7, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {2, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6395}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[2]; - uint8_t topic_filter_s0_bytes[] = {0x9, 0x86, 0xb2, 0xdb, 0x9f, 0xf9, 0xeb, 0xfa, 0xbb}; - lwmqtt_string_t topic_filter_s0 = {9, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[9]; + uint8_t topic_filter_s0_bytes[] = {0x90, 0xbb, 0xf, 0xc8, 0x8e, 0x79, 0x27, 0x4e, 0x29, 0x5e, 0xd6, + 0x15, 0x3f, 0xdb, 0x9e, 0xfe, 0x55, 0xe6, 0x25, 0x64, 0x70, 0xb4}; + lwmqtt_string_t topic_filter_s0 = {22, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xa6, 0x29, 0xe6, 0xb8, 0x59, 0xfc, 0xd, 0x2e, 0x42}; + uint8_t topic_filter_s1_bytes[] = {0x88, 0x13, 0x6a, 0xb3, 0x27, 0xca, 0xc8, 0xf5, 0x0}; lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; + uint8_t topic_filter_s2_bytes[] = {0xcb, 0x27, 0x55, 0x77, 0x4a, 0x66, 0xc6, 0x90, 0x3d, 0x28, 0x1a, + 0x9, 0x32, 0xef, 0xb, 0x6e, 0x3, 0x2, 0x8f, 0xdf, 0xc6, 0xf7}; + lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + topic_filters[2] = topic_filter_s2; + uint8_t topic_filter_s3_bytes[] = {0xcb, 0xcf, 0x5e, 0x1a, 0xd2, 0x31, 0x8b, + 0xd5, 0x4e, 0xbc, 0xe0, 0xcf, 0xbe, 0x8c}; + lwmqtt_string_t topic_filter_s3 = {14, (char*)&topic_filter_s3_bytes}; + topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x17, 0xc9}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; + uint8_t topic_filter_s5_bytes[] = {0x77, 0xe9, 0x6e, 0x6f, 0xaa, 0x85, 0x8d, 0x69, 0x8e, 0x6, + 0xb2, 0x72, 0x76, 0xde, 0x31, 0x8d, 0xc3, 0x8f, 0x55}; + lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + topic_filters[5] = topic_filter_s5; + uint8_t topic_filter_s6_bytes[] = {0x31, 0x32}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; + topic_filters[6] = topic_filter_s6; + uint8_t topic_filter_s7_bytes[] = {0}; + lwmqtt_string_t topic_filter_s7 = {0, (char*)&topic_filter_s7_bytes}; + topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0xb5, 0x2f}; + lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 24597, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 6495, 9, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 17778 -// ["\136x\150\168\US\251\133\245\161\132","","\156","\b\158G{\v-Ms1\169\219\152\168\DC4\152\236\156\169\r -// L{\144]w<\161","^\n\242r\171T8\161Q\v\135\252\STX8r\191\232\164\NUL\USM\199\151|8G\166","y\b\179\128O\138\242\240@2\163\187~\137\EOT\212\&2\EOT\167\\}f\170:\169x\186~","\b4\215\223kA\248\252\v\173\218\f\217.\171O\210\199\&4\ETX\NULk\f7~\151\&5\142\USL","\223\248\DC3<\163N\164?\DC2%\ENQ\251\214\223\&4\239\&13_3\DEL\SYN*c\NUL\ETX","\215\DC1\218\DC1l\160\ESCV@L\v$\203\195","\221M\253c3\176\146Y\151\250\249^YYC\182n`\ENQg\203s\198\249\232"] -// [PropResponseTopic -// "\255\217W=\224\165\251\223b\157q\154l\236\208\160\211\157\155~\175\230\247x\213G\150",PropSessionExpiryInterval -// 21312,PropServerKeepAlive 11757] +// UnsubscribeRequest 21456 +// ["i\172\235\176yA\168\222\209\r","\207\189\131+\244\149$\n\152\138]\252t\DLE\251\212\SUB\188tMDIz\190>\188ZB","#\r\157z\r6\USl\SUB\142\142\217\US\182f\213\161\240","i\167c\137+A\NAKg\221\&0\217\213'\ESC]mc}\222\157\220>","\144\177\&2@\185\r\242\&08N\243\238\144-\SO\146\248e\148\231\FS\196\ETBk\246\248\167\DC2","\129"] +// [PropServerKeepAlive 29657,PropCorrelationData "5\163\186\&9{",PropRequestResponseInformation 4,PropServerKeepAlive +// 28724,PropSubscriptionIdentifierAvailable 87,PropRetainAvailable 48] TEST(Unsubscribe5QCTest, Encode19) { - uint8_t pkt[] = {0xa2, 0xf9, 0x1, 0x45, 0x72, 0x26, 0x8, 0x0, 0x1b, 0xff, 0xd9, 0x57, 0x3d, 0xe0, 0xa5, 0xfb, 0xdf, - 0x62, 0x9d, 0x71, 0x9a, 0x6c, 0xec, 0xd0, 0xa0, 0xd3, 0x9d, 0x9b, 0x7e, 0xaf, 0xe6, 0xf7, 0x78, 0xd5, - 0x47, 0x96, 0x11, 0x0, 0x0, 0x53, 0x40, 0x13, 0x2d, 0xed, 0x0, 0xa, 0x88, 0x78, 0x96, 0xa8, 0x1f, - 0xfb, 0x85, 0xf5, 0xa1, 0x84, 0x0, 0x0, 0x0, 0x1, 0x9c, 0x0, 0x1b, 0x8, 0x9e, 0x47, 0x7b, 0xb, - 0x2d, 0x4d, 0x73, 0x31, 0xa9, 0xdb, 0x98, 0xa8, 0x14, 0x98, 0xec, 0x9c, 0xa9, 0xd, 0x20, 0x4c, 0x7b, - 0x90, 0x5d, 0x77, 0x3c, 0xa1, 0x0, 0x1b, 0x5e, 0xa, 0xf2, 0x72, 0xab, 0x54, 0x38, 0xa1, 0x51, 0xb, - 0x87, 0xfc, 0x2, 0x38, 0x72, 0xbf, 0xe8, 0xa4, 0x0, 0x1f, 0x4d, 0xc7, 0x97, 0x7c, 0x38, 0x47, 0xa6, - 0x0, 0x1c, 0x79, 0x8, 0xb3, 0x80, 0x4f, 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0x34, 0x29, 0x57, 0x25, 0x30, 0x0, 0xa, 0x69, 0xac, 0xeb, 0xb0, 0x79, 0x41, + 0xa8, 0xde, 0xd1, 0xd, 0x0, 0x1c, 0xcf, 0xbd, 0x83, 0x2b, 0xf4, 0x95, 0x24, 0xa, 0x98, 0x8a, 0x5d, + 0xfc, 0x74, 0x10, 0xfb, 0xd4, 0x1a, 0xbc, 0x74, 0x4d, 0x44, 0x49, 0x7a, 0xbe, 0x3e, 0xbc, 0x5a, 0x42, + 0x0, 0x12, 0x23, 0xd, 0x9d, 0x7a, 0xd, 0x36, 0x1f, 0x6c, 0x1a, 0x8e, 0x8e, 0xd9, 0x1f, 0xb6, 0x66, + 0xd5, 0xa1, 0xf0, 0x0, 0x16, 0x69, 0xa7, 0x63, 0x89, 0x2b, 0x41, 0x15, 0x67, 0xdd, 0x30, 0xd9, 0xd5, + 0x27, 0x1b, 0x5d, 0x6d, 0x63, 0x7d, 0xde, 0x9d, 0xdc, 0x3e, 0x0, 0x1c, 0x90, 0xb1, 0x32, 0x40, 0xb9, + 0xd, 0xf2, 0x30, 0x38, 0x4e, 0xf3, 0xee, 0x90, 0x2d, 0xe, 0x92, 0xf8, 0x65, 0x94, 0xe7, 0x1c, 0xc4, + 0x17, 0x6b, 0xf6, 0xf8, 0xa7, 0x12, 0x0, 0x1, 0x81}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x35, 0xa3, 0xba, 0x39, 0x7b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)8, .value = {.str = {27, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21312}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 11757}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29657}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 4}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28724}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 87}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 48}}, }; - lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x88, 0x78, 0x96, 0xa8, 0x1f, 0xfb, 0x85, 0xf5, 0xa1, 0x84}; + lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[6]; + uint8_t topic_filter_s0_bytes[] = {0x69, 0xac, 0xeb, 0xb0, 0x79, 0x41, 0xa8, 0xde, 0xd1, 0xd}; lwmqtt_string_t topic_filter_s0 = {10, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0}; - lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xcf, 0xbd, 0x83, 0x2b, 0xf4, 0x95, 0x24, 0xa, 0x98, 0x8a, + 0x5d, 0xfc, 0x74, 0x10, 0xfb, 0xd4, 0x1a, 0xbc, 0x74, 0x4d, + 0x44, 0x49, 0x7a, 0xbe, 0x3e, 0xbc, 0x5a, 0x42}; + lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x9c}; - lwmqtt_string_t topic_filter_s2 = {1, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x23, 0xd, 0x9d, 0x7a, 0xd, 0x36, 0x1f, 0x6c, 0x1a, + 0x8e, 0x8e, 0xd9, 0x1f, 0xb6, 0x66, 0xd5, 0xa1, 0xf0}; + lwmqtt_string_t topic_filter_s2 = {18, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x8, 0x9e, 0x47, 0x7b, 0xb, 0x2d, 0x4d, 0x73, 0x31, 0xa9, 0xdb, 0x98, 0xa8, 0x14, - 0x98, 0xec, 0x9c, 0xa9, 0xd, 0x20, 0x4c, 0x7b, 0x90, 0x5d, 0x77, 0x3c, 0xa1}; - lwmqtt_string_t topic_filter_s3 = {27, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x69, 0xa7, 0x63, 0x89, 0x2b, 0x41, 0x15, 0x67, 0xdd, 0x30, 0xd9, + 0xd5, 0x27, 0x1b, 0x5d, 0x6d, 0x63, 0x7d, 0xde, 0x9d, 0xdc, 0x3e}; + lwmqtt_string_t topic_filter_s3 = {22, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x5e, 0xa, 0xf2, 0x72, 0xab, 0x54, 0x38, 0xa1, 0x51, 0xb, 0x87, 0xfc, 0x2, 0x38, - 0x72, 0xbf, 0xe8, 0xa4, 0x0, 0x1f, 0x4d, 0xc7, 0x97, 0x7c, 0x38, 0x47, 0xa6}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x90, 0xb1, 0x32, 0x40, 0xb9, 0xd, 0xf2, 0x30, 0x38, 0x4e, + 0xf3, 0xee, 0x90, 0x2d, 0xe, 0x92, 0xf8, 0x65, 0x94, 0xe7, + 0x1c, 0xc4, 0x17, 0x6b, 0xf6, 0xf8, 0xa7, 0x12}; + lwmqtt_string_t topic_filter_s4 = {28, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x79, 0x8, 0xb3, 0x80, 0x4f, 0x8a, 0xf2, 0xf0, 0x40, 0x32, - 0xa3, 0xbb, 0x7e, 0x89, 0x4, 0xd4, 0x32, 0x4, 0xa7, 0x5c, - 0x7d, 0x66, 0xaa, 0x3a, 0xa9, 0x78, 0xba, 0x7e}; - lwmqtt_string_t topic_filter_s5 = {28, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x81}; + lwmqtt_string_t topic_filter_s5 = {1, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x8, 0x34, 0xd7, 0xdf, 0x6b, 0x41, 0xf8, 0xfc, 0xb, 0xad, - 0xda, 0xc, 0xd9, 0x2e, 0xab, 0x4f, 0xd2, 0xc7, 0x34, 0x3, - 0x0, 0x6b, 0xc, 0x37, 0x7e, 0x97, 0x35, 0x8e, 0x1f, 0x4c}; - lwmqtt_string_t topic_filter_s6 = {30, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xdf, 0xf8, 0x13, 0x3c, 0xa3, 0x4e, 0xa4, 0x3f, 0x12, 0x25, 0x5, 0xfb, 0xd6, - 0xdf, 0x34, 0xef, 0x31, 0x33, 0x5f, 0x33, 0x7f, 0x16, 0x2a, 0x63, 0x0, 0x3}; - lwmqtt_string_t topic_filter_s7 = {26, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xd7, 0x11, 0xda, 0x11, 0x6c, 0xa0, 0x1b, 0x56, 0x40, 0x4c, 0xb, 0x24, 0xcb, 0xc3}; - lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xdd, 0x4d, 0xfd, 0x63, 0x33, 0xb0, 0x92, 0x59, 0x97, 0xfa, 0xf9, 0x5e, 0x59, - 0x59, 0x43, 0xb6, 0x6e, 0x60, 0x5, 0x67, 0xcb, 0x73, 0xc6, 0xf9, 0xe8}; - lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 17778, 10, topic_filters, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// UnsubscribeRequest 4976 -// ["_\190\245~5\207\156\SOHtV\FSY\253Gq\220\&8R\"\148","\CAN\141\210\134\ETBEiWm\158\t}\150O\175\CANHzh\157]q\173BuK\182p","\SUB\156\FS\ENQo#V\174\SYN\EM\150\161\a\231S\236\217\251\185\142\186\216\132\DC1I\"\172=5","\200d\202\182\185\147","\196\172'","kx\GS\134,&\222\152\&0\US\188\202zs\141g\170\174\164\SUB\246\184Wd\135\237","\254\207M\NAK\202g\EOT\135\186\213.\229\222\152","=\137\241~\EOTl","&\"","6\239R\208\161@\FS\US\250\170`\SUB\155{"] -// [PropWildcardSubscriptionAvailable 188,PropAssignedClientIdentifier -// ">\243{6\aL\141y\146\192Z\159\&1",PropCorrelationData -// "\223\153\146\190\DC1\155P\EOT\191\211\133+y\218\250\DC31Ah\181\&4",PropMaximumQoS 228,PropTopicAlias -// 31268,PropPayloadFormatIndicator 132,PropSessionExpiryInterval 6581,PropAuthenticationData "F",PropWillDelayInterval -// 5403,PropCorrelationData "\254j\232\SOHY{\251Wg\136r\NUL\193)`\223\241\252fs",PropAuthenticationMethod -// "w\EOT\202\ACK\152\\\US>\211#\ETBm\235\163\&1\233\169a\241)\253\173",PropMaximumPacketSize -// 26144,PropWildcardSubscriptionAvailable 252,PropContentType "\132\ETBvZM\164\195\191;\133\EMt\195\202[\213 -// ",PropContentType -// "\242r\227f\210\SYN\NUL{\255\t\226k_z\161d\161\199\DC3\SI\221\DC2\137\ETB\238\DLE-\157\235X",PropMaximumPacketSize -// 9944,PropRetainAvailable 146] + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 21456, 6, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 1638 +// ["I\172\254l\194\132\150\DC1\CAN\173\152\&6ms\215\182\145~\176\NAK(\255p\163\238G\163\DC4\164"] [PropReasonString +// "",PropSubscriptionIdentifier 18,PropRetainAvailable 191,PropMessageExpiryInterval 13150,PropServerKeepAlive +// 17910,PropAuthenticationMethod +// "\USH\171\242\ETX8\184\204\179\&6D\176h\174\197\227\234\170=",PropWildcardSubscriptionAvailable +// 58,PropServerKeepAlive 13408,PropAuthenticationMethod +// "\147\ENQ\235-\152\145\&7\219Wj%X\218\250*\154\137\&0\203>\b\208%\252\255\&1",PropWillDelayInterval +// 7585,PropSharedSubscriptionAvailable 7,PropCorrelationData +// "Lr\SO\141\212\128\245\230C\241\DEL",PropMessageExpiryInterval 29115,PropUserProperty +// "\246\160\213-\ETX\242\149\222Yc2UX\224)\223\191\159\201\184" +// "\189\a\219\189@\240\170\204fWn\173",PropAssignedClientIdentifier "\157\146\145\172\ENQ",PropAuthenticationData +// "\202t\170\168",PropAuthenticationMethod "",PropResponseTopic +// "e><\148um<\224%\fN\233\159'\199\143\149Y\STX\213\&4\166rC]\146\227]",PropAuthenticationData +// "\153M\174V\246.\US\ACK\191\135\225|uKY\136\255\SYN\230\154\146\149><1",PropMaximumQoS +// 96,PropRequestResponseInformation 170,PropCorrelationData +// "\CAN\250SB\250\163\230\186\189V\128M}\215~\178\199\208\137\155",PropRetainAvailable 102,PropSubscriptionIdentifier +// 30,PropTopicAliasMaximum 12459,PropMaximumQoS 181,PropPayloadFormatIndicator 212,PropSubscriptionIdentifier +// 29,PropSubscriptionIdentifierAvailable 44] TEST(Unsubscribe5QCTest, Encode20) { uint8_t pkt[] = { - 0xa2, 0xde, 0x2, 0x13, 0x70, 0xb2, 0x1, 0x28, 0xbc, 0x12, 0x0, 0xd, 0x3e, 0xf3, 0x7b, 0x36, 0x7, 0x4c, 0x8d, - 0x79, 0x92, 0xc0, 0x5a, 0x9f, 0x31, 0x9, 0x0, 0x15, 0xdf, 0x99, 0x92, 0xbe, 0x11,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x96, 0x4f, 0xaf, 0x18, 0x48, 0x7a, 0x68, - 0x9d, 0x5d, 0x71, 0xad, 0x42, 0x75, 0x4b, 0xb6, 0x70, 0x0, 0x1d, 0x1a, 0x9c, 0x1c, 0x5, 0x6f, 0x23, 0x56, 0xae, - 0x16, 0x19, 0x96, 0xa1, 0x7, 0xe7, 0x53, 0xec, 0xd9, 0xfb, 0xb9, 0x8e, 0xba, 0xd8, 0x84, 0x11, 0x49, 0x22, 0xac, - 0x3d, 0x35, 0x0, 0x6, 0xc8, 0x64, 0xca, 0xb6, 0xb9, 0x93, 0x0, 0x3, 0xc4, 0xac, 0x27, 0x0, 0x1a, 0x6b, 0x78, - 0x1d, 0x86, 0x2c, 0x26, 0xde, 0x98, 0x30, 0x1f, 0xbc, 0xca, 0x7a, 0x73, 0x8d, 0x67, 0xaa, 0xae, 0xa4, 0x1a, 0xf6, - 0xb8, 0x57, 0x64, 0x87, 0xed, 0x0, 0xe, 0xfe, 0xcf, 0x4d, 0x15, 0xca, 0x67, 0x4, 0x87, 0xba, 0xd5, 0x2e, 0xe5, - 0xde, 0x98, 0x0, 0x6, 0x3d, 0x89, 0xf1, 0x7e, 0x4, 0x6c, 0x0, 0x2, 0x26, 0x22, 0x0, 0xe, 0x36, 0xef, 0x52, - 0xd0, 0xa1, 0x40, 0x1c, 0x1f, 0xfa, 0xaa, 0x60, 0x1a, 0x9b, 0x7b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x3e, 0xf3, 0x7b, 0x36, 0x7, 0x4c, 0x8d, 0x79, 0x92, 0xc0, 0x5a, 0x9f, 0x31}; - uint8_t bytesprops1[] = {0xdf, 0x99, 0x92, 0xbe, 0x11, 0x9b, 0x50, 0x4, 0xbf, 0xd3, 0x85, - 0x2b, 0x79, 0xda, 0xfa, 0x13, 0x31, 0x41, 0x68, 0xb5, 0x34}; - uint8_t bytesprops2[] = {0x46}; - uint8_t bytesprops3[] = {0xfe, 0x6a, 0xe8, 0x1, 0x59, 0x7b, 0xfb, 0x57, 0x67, 0x88, - 0x72, 0x0, 0xc1, 0x29, 0x60, 0xdf, 0xf1, 0xfc, 0x66, 0x73}; - uint8_t bytesprops4[] = {0x77, 0x4, 0xca, 0x6, 0x98, 0x5c, 0x1f, 0x3e, 0xd3, 0x23, 0x17, - 0x6d, 0xeb, 0xa3, 0x31, 0xe9, 0xa9, 0x61, 0xf1, 0x29, 0xfd, 0xad}; - uint8_t bytesprops5[] = {0x84, 0x17, 0x76, 0x5a, 0x4d, 0xa4, 0xc3, 0xbf, 0x3b, - 0x85, 0x19, 0x74, 0xc3, 0xca, 0x5b, 0xd5, 0x20}; - uint8_t bytesprops6[] = {0xf2, 0x72, 0xe3, 0x66, 0xd2, 0x16, 0x0, 0x7b, 0xff, 0x9, 0xe2, 0x6b, 0x5f, 0x7a, 0xa1, - 0x64, 0xa1, 0xc7, 0x13, 0xf, 0xdd, 0x12, 0x89, 0x17, 0xee, 0x10, 0x2d, 0x9d, 0xeb, 0x58}; + 0xa2, 0xa0, 0x2, 0x6, 0x66, 0xfd, 0x1, 0x1f, 0x0, 0x0, 0xb, 0x12, 0x25, 0xbf, 0x2, 0x0, 0x0, 0x33, 0x5e, + 0x13, 0x45, 0xf6, 0x15, 0x0, 0x13, 0x1f, 0x48, 0xab, 0xf2, 0x3, 0x38, 0xb8, 0xcc, 0xb3, 0x36, 0x44, 0xb0, 0x68, + 0xae, 0xc5, 0xe3, 0xea, 0xaa, 0x3d, 0x28, 0x3a, 0x13, 0x34, 0x60, 0x15, 0x0, 0x1a, 0x93, 0x5, 0xeb, 0x2d, 0x98, + 0x91, 0x37, 0xdb, 0x57, 0x6a, 0x25, 0x58, 0xda, 0xfa, 0x2a, 0x9a, 0x89, 0x30, 0xcb, 0x3e, 0x8, 0xd0, 0x25, 0xfc, + 0xff, 0x31, 0x18, 0x0, 0x0, 0x1d, 0xa1, 0x2a, 0x7, 0x9, 0x0, 0xb, 0x4c, 0x72, 0xe, 0x8d, 0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 0x7e, 0xb0, 0x15, 0x28, 0xff, 0x70, + 0xa3, 0xee, 0x47, 0xa3, 0x14, 0xa4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x1f, 0x48, 0xab, 0xf2, 0x3, 0x38, 0xb8, 0xcc, 0xb3, 0x36, + 0x44, 0xb0, 0x68, 0xae, 0xc5, 0xe3, 0xea, 0xaa, 0x3d}; + uint8_t bytesprops2[] = {0x93, 0x5, 0xeb, 0x2d, 0x98, 0x91, 0x37, 0xdb, 0x57, 0x6a, 0x25, 0x58, 0xda, + 0xfa, 0x2a, 0x9a, 0x89, 0x30, 0xcb, 0x3e, 0x8, 0xd0, 0x25, 0xfc, 0xff, 0x31}; + uint8_t bytesprops3[] = {0x4c, 0x72, 0xe, 0x8d, 0xd4, 0x80, 0xf5, 0xe6, 0x43, 0xf1, 0x7f}; + uint8_t bytesprops5[] = {0xbd, 0x7, 0xdb, 0xbd, 0x40, 0xf0, 0xaa, 0xcc, 0x66, 0x57, 0x6e, 0xad}; + uint8_t bytesprops4[] = {0xf6, 0xa0, 0xd5, 0x2d, 0x3, 0xf2, 0x95, 0xde, 0x59, 0x63, + 0x32, 0x55, 0x58, 0xe0, 0x29, 0xdf, 0xbf, 0x9f, 0xc9, 0xb8}; + uint8_t bytesprops6[] = {0x9d, 0x92, 0x91, 0xac, 0x5}; + uint8_t bytesprops7[] = {0xca, 0x74, 0xaa, 0xa8}; + uint8_t bytesprops8[] = {0}; + uint8_t bytesprops9[] = {0x65, 0x3e, 0x3c, 0x94, 0x75, 0x6d, 0x3c, 0xe0, 0x25, 0xc, 0x4e, 0xe9, 0x9f, 0x27, + 0xc7, 0x8f, 0x95, 0x59, 0x2, 0xd5, 0x34, 0xa6, 0x72, 0x43, 0x5d, 0x92, 0xe3, 0x5d}; + uint8_t bytesprops10[] = {0x99, 0x4d, 0xae, 0x56, 0xf6, 0x2e, 0x1f, 0x6, 0xbf, 0x87, 0xe1, 0x7c, 0x75, + 0x4b, 0x59, 0x88, 0xff, 0x16, 0xe6, 0x9a, 0x92, 0x95, 0x3e, 0x3c, 0x31}; + uint8_t bytesprops11[] = {0x18, 0xfa, 0x53, 0x42, 0xfa, 0xa3, 0xe6, 0xba, 0xbd, 0x56, + 0x80, 0x4d, 0x7d, 0xd7, 0x7e, 0xb2, 0xc7, 0xd0, 0x89, 0x9b}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 188}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {21, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31268}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6581}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {1, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5403}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26144}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 252}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 9944}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13150}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17910}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {19, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 58}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13408}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 7585}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 7}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29115}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops4}, .v = {12, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {5, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {25, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 96}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 170}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 102}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 30}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 12459}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 181}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 212}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 29}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 44}}, }; - lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x5f, 0xbe, 0xf5, 0x7e, 0x35, 0xcf, 0x9c, 0x1, 0x74, 0x56, - 0x1c, 0x59, 0xfd, 0x47, 0x71, 0xdc, 0x38, 0x52, 0x22, 0x94}; - lwmqtt_string_t topic_filter_s0 = {20, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0x49, 0xac, 0xfe, 0x6c, 0xc2, 0x84, 0x96, 0x11, 0x18, 0xad, + 0x98, 0x36, 0x6d, 0x73, 0xd7, 0xb6, 0x91, 0x7e, 0xb0, 0x15, + 0x28, 0xff, 0x70, 0xa3, 0xee, 0x47, 0xa3, 0x14, 0xa4}; + lwmqtt_string_t topic_filter_s0 = {29, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x18, 0x8d, 0xd2, 0x86, 0x17, 0x45, 0x69, 0x57, 0x6d, 0x9e, - 0x9, 0x7d, 0x96, 0x4f, 0xaf, 0x18, 0x48, 0x7a, 0x68, 0x9d, - 0x5d, 0x71, 0xad, 0x42, 0x75, 0x4b, 0xb6, 0x70}; - lwmqtt_string_t topic_filter_s1 = {28, (char*)&topic_filter_s1_bytes}; - topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x1a, 0x9c, 0x1c, 0x5, 0x6f, 0x23, 0x56, 0xae, 0x16, 0x19, - 0x96, 0xa1, 0x7, 0xe7, 0x53, 0xec, 0xd9, 0xfb, 0xb9, 0x8e, - 0xba, 0xd8, 0x84, 0x11, 0x49, 0x22, 0xac, 0x3d, 0x35}; - lwmqtt_string_t topic_filter_s2 = {29, (char*)&topic_filter_s2_bytes}; - topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0xc8, 0x64, 0xca, 0xb6, 0xb9, 0x93}; - lwmqtt_string_t topic_filter_s3 = {6, (char*)&topic_filter_s3_bytes}; - topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xc4, 0xac, 0x27}; - lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; - topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x6b, 0x78, 0x1d, 0x86, 0x2c, 0x26, 0xde, 0x98, 0x30, 0x1f, 0xbc, 0xca, 0x7a, - 0x73, 0x8d, 0x67, 0xaa, 0xae, 0xa4, 0x1a, 0xf6, 0xb8, 0x57, 0x64, 0x87, 0xed}; - lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; - topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xfe, 0xcf, 0x4d, 0x15, 0xca, 0x67, 0x4, 0x87, 0xba, 0xd5, 0x2e, 0xe5, 0xde, 0x98}; - lwmqtt_string_t topic_filter_s6 = {14, (char*)&topic_filter_s6_bytes}; - topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x3d, 0x89, 0xf1, 0x7e, 0x4, 0x6c}; - lwmqtt_string_t topic_filter_s7 = {6, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x26, 0x22}; - lwmqtt_string_t topic_filter_s8 = {2, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0x36, 0xef, 0x52, 0xd0, 0xa1, 0x40, 0x1c, - 0x1f, 0xfa, 0xaa, 0x60, 0x1a, 0x9b, 0x7b}; - lwmqtt_string_t topic_filter_s9 = {14, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4976, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 1638, 1, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 12973 -// ["\DC1As\216\DLE\214\246\194\220\178\DC3\NULON\198\226\147P\205\SO\129\&4\RS\DC3\206","\171\&0\204\160\CAN.\142\255 -// \134\198\220\DEL@\163\216\&2\165\142\225\208","^\163\204\213TZ\"\SO","\136!\167=\170\214\"\232\ESC -// \216\174%\ENQ]\219\133}\226\235","J\182\bT\140Z","\188n\150\191L#\NAK\197\136\194[\192m\141\196\n\211\252","\195\157\173\ACKh\DEL\178\230\r","e(y\DC3\r|+\138\216\196*\227~\180\140DX\250\181\135#\214#;!\225\161\201","1\252\225\175\STX\172\236\SYN\176\&2\"\204\v\RS\b\189","\218\181\178\245x\187\245\167\&5\144\249L:\209\146"] -// [PropReasonString "\197\173\128\210\&6^E\180y\CAN\152\"\149",PropServerKeepAlive 31457,PropResponseTopic -// "\140\142;]\130\155\161\DEL\179\200\204D9\226\228\193\255\138M^\171\254\141\136v\181\199\135\GS",PropAuthenticationMethod -// "\EM\225\243\176\175?\247\201\ENQ\SOHF\244\NUL\239\&8b\208\220\DEL\240\255%",PropPayloadFormatIndicator -// 109,PropSubscriptionIdentifier 23,PropRequestResponseInformation 219,PropCorrelationData "\DC3\129\EMQ -// Y\DC3R\140\DC1/R\139",PropSubscriptionIdentifierAvailable 137,PropResponseTopic -// "\252{\129\169\EMr\214\&4\205\226O\156\198\GS;}\242_hnG\226\225\EM\219.\215\233\232",PropAssignedClientIdentifier -// "\STXA",PropWildcardSubscriptionAvailable 230,PropAssignedClientIdentifier -// "\238\192\187%a_\SOH\175/x\DEL\162\&4\SO\217\SO\213\242:\170\233O\158\EM[|",PropTopicAlias 26429,PropReasonString -// "\135\\h\193n\214-+2D\180\rg\177r\255`//\186]\206\157D"] +// UnsubscribeRequest 30931 +// ["\242\153y5V\186\NUL\184\153\206\140\ESC\128Z","\217J\203\FS\129\209\190\129\183\211N\167\STX\EOT\145\216\246\204\195\208","\228e\179_t\DC2\ETX\208\189\199\&7!\150\135\155{\150.4Y","T\229\NAK]\171\166\141\193*\174\ESC\ESC?\198\242\\G\242\209\NULRL\DEL\EM","\227\251","","\247\227>\DC1?\SIm\254f\225","R\194\196\DEL\217j\241\169\&6f\155"] +// [PropAuthenticationData "\190\&5\251\181\175F\ENQ\160\DC3\129|\DC1\151A\214k",PropSessionExpiryInterval +// 4940,PropAuthenticationData "x\DC2>v\244\229\GS\212\185\DEL2\146\163"] TEST(Unsubscribe5QCTest, Encode21) { - uint8_t pkt[] = { - 0xa2, 0x84, 0x3, 0x32, 0xad, 0xc6, 0x1, 0x1f, 0x0, 0xd, 0xc5, 0xad, 0x80, 0xd2, 0x36, 0x5e, 0x45, 0xb4, 0x79, - 0x18, 0x98, 0x22, 0x95, 0x13, 0x7a, 0xe1, 0x8, 0x0, 0x1d, 0x8c, 0x8e, 0x3b, 0x5d, 0x82, 0x9b, 0xa1, 0x7f, 0xb3, - 0xc8, 0xcc, 0x44, 0x39, 0xe2, 0xe4, 0xc1, 0xff, 0x8a, 0x4d, 0x5e, 0xab, 0xfe, 0x8d, 0x88, 0x76, 0xb5, 0xc7, 0x87, - 0x1d, 0x15, 0x0, 0x16, 0x19, 0xe1, 0xf3, 0xb0, 0xaf, 0x3f, 0xf7, 0xc9, 0x5, 0x1, 0x46, 0xf4, 0x0, 0xef, 0x38, - 0x62, 0xd0, 0xdc, 0x7f, 0xf0, 0xff, 0x25, 0x1, 0x6d, 0xb, 0x17, 0x19, 0xdb, 0x9, 0x0, 0xd, 0x13, 0x81, 0x19, - 0x51, 0x20, 0x59, 0x13, 0x52, 0x8c, 0x11, 0x2f, 0x52, 0x8b, 0x29, 0x89, 0x8, 0x0, 0x1d, 0xfc, 0x7b, 0x81, 0xa9, - 0x19,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0x6e, 0x96, 0xbf, 0x4c, 0x23, 0x15, - 0xc5, 0x88, 0xc2, 0x5b, 0xc0, 0x6d, 0x8d, 0xc4, 0xa, 0xd3, 0xfc, 0x0, 0x9, 0xc3, 0x9d, 0xad, 0x6, 0x68, 0x7f, - 0xb2, 0xe6, 0xd, 0x0, 0x1c, 0x65, 0x28, 0x79, 0x13, 0xd, 0x7c, 0x2b, 0x8a, 0xd8, 0xc4, 0x2a, 0xe3, 0x7e, 0xb4, - 0x8c, 0x44, 0x58, 0xfa, 0xb5, 0x87, 0x23, 0xd6, 0x23, 0x3b, 0x21, 0xe1, 0xa1, 0xc9, 0x0, 0x10, 0x31, 0xfc, 0xe1, - 0xaf, 0x2, 0xac, 0xec, 0x16, 0xb0, 0x32, 0x22, 0xcc, 0xb, 0x1e, 0x8, 0xbd, 0x0, 0xf, 0xda, 0xb5, 0xb2, 0xf5, - 0x78, 0xbb, 0xf5, 0xa7, 0x35, 0x90, 0xf9, 0x4c, 0x3a, 0xd1, 0x92}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xc5, 0xad, 0x80, 0xd2, 0x36, 0x5e, 0x45, 0xb4, 0x79, 0x18, 0x98, 0x22, 0x95}; - uint8_t bytesprops1[] = {0x8c, 0x8e, 0x3b, 0x5d, 0x82, 0x9b, 0xa1, 0x7f, 0xb3, 0xc8, 0xcc, 0x44, 0x39, 0xe2, 0xe4, - 0xc1, 0xff, 0x8a, 0x4d, 0x5e, 0xab, 0xfe, 0x8d, 0x88, 0x76, 0xb5, 0xc7, 0x87, 0x1d}; - uint8_t bytesprops2[] = {0x19, 0xe1, 0xf3, 0xb0, 0xaf, 0x3f, 0xf7, 0xc9, 0x5, 0x1, 0x46, - 0xf4, 0x0, 0xef, 0x38, 0x62, 0xd0, 0xdc, 0x7f, 0xf0, 0xff, 0x25}; - uint8_t bytesprops3[] = {0x13, 0x81, 0x19, 0x51, 0x20, 0x59, 0x13, 0x52, 0x8c, 0x11, 0x2f, 0x52, 0x8b}; - uint8_t bytesprops4[] = {0xfc, 0x7b, 0x81, 0xa9, 0x19, 0x72, 0xd6, 0x34, 0xcd, 0xe2, 0x4f, 0x9c, 0xc6, 0x1d, 0x3b, - 0x7d, 0xf2, 0x5f, 0x68, 0x6e, 0x47, 0xe2, 0xe1, 0x19, 0xdb, 0x2e, 0xd7, 0xe9, 0xe8}; - uint8_t bytesprops5[] = {0x2, 0x41}; - uint8_t bytesprops6[] = {0xee, 0xc0, 0xbb, 0x25, 0x61, 0x5f, 0x1, 0xaf, 0x2f, 0x78, 0x7f, 0xa2, 0x34, - 0xe, 0xd9, 0xe, 0xd5, 0xf2, 0x3a, 0xaa, 0xe9, 0x4f, 0x9e, 0x19, 0x5b, 0x7c}; - uint8_t bytesprops7[] = {0x87, 0x5c, 0x68, 0xc1, 0x6e, 0xd6, 0x2d, 0x2b, 0x32, 0x44, 0xb4, 0xd, - 0x67, 0xb1, 0x72, 0xff, 0x60, 0x2f, 0x2f, 0xba, 0x5d, 0xce, 0x9d, 0x44}; + uint8_t pkt[] = {0xa2, 0xa0, 0x1, 0x78, 0xd3, 0x28, 0x16, 0x0, 0x10, 0xbe, 0x35, 0xfb, 0xb5, 0xaf, 0x46, 0x5, 0xa0, + 0x13, 0x81, 0x7c, 0x11, 0x97, 0x41, 0xd6, 0x6b, 0x11, 0x0, 0x0, 0x13, 0x4c, 0x16, 0x0, 0xd, 0x78, + 0x12, 0x3e, 0x76, 0xf4, 0xe5, 0x1d, 0xd4, 0xb9, 0x7f, 0x32, 0x92, 0xa3, 0x0, 0xe, 0xf2, 0x99, 0x79, + 0x35, 0x56, 0xba, 0x0, 0xb8, 0x99, 0xce, 0x8c, 0x1b, 0x80, 0x5a, 0x0, 0x14, 0xd9, 0x4a, 0xcb, 0x1c, + 0x81, 0xd1, 0xbe, 0x81, 0xb7, 0xd3, 0x4e, 0xa7, 0x2, 0x4, 0x91, 0xd8, 0xf6, 0xcc, 0xc3, 0xd0, 0x0, + 0x14, 0xe4, 0x65, 0xb3, 0x5f, 0x74, 0x12, 0x3, 0xd0, 0xbd, 0xc7, 0x37, 0x21, 0x96, 0x87, 0x9b, 0x7b, + 0x96, 0x2e, 0x34, 0x59, 0x0, 0x18, 0x54, 0xe5, 0x15, 0x5d, 0xab, 0xa6, 0x8d, 0xc1, 0x2a, 0xae, 0x1b, + 0x1b, 0x3f, 0xc6, 0xf2, 0x5c, 0x47, 0xf2, 0xd1, 0x0, 0x52, 0x4c, 0x7f, 0x19, 0x0, 0x2, 0xe3, 0xfb, + 0x0, 0x0, 0x0, 0xa, 0xf7, 0xe3, 0x3e, 0x11, 0x3f, 0xf, 0x6d, 0xfe, 0x66, 0xe1, 0x0, 0xb, 0x52, + 0xc2, 0xc4, 0x7f, 0xd9, 0x6a, 0xf1, 0xa9, 0x36, 0x66, 0x9b}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xbe, 0x35, 0xfb, 0xb5, 0xaf, 0x46, 0x5, 0xa0, + 0x13, 0x81, 0x7c, 0x11, 0x97, 0x41, 0xd6, 0x6b}; + uint8_t bytesprops1[] = {0x78, 0x12, 0x3e, 0x76, 0xf4, 0xe5, 0x1d, 0xd4, 0xb9, 0x7f, 0x32, 0x92, 0xa3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 31457}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {22, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 109}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {13, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 137}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {2, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26429}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {24, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4940}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {13, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0x11, 0x41, 0x73, 0xd8, 0x10, 0xd6, 0xf6, 0xc2, 0xdc, 0xb2, 0x13, 0x0, 0x4f, - 0x4e, 0xc6, 0xe2, 0x93, 0x50, 0xcd, 0xe, 0x81, 0x34, 0x1e, 0x13, 0xce}; - lwmqtt_string_t topic_filter_s0 = {25, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0xf2, 0x99, 0x79, 0x35, 0x56, 0xba, 0x0, 0xb8, 0x99, 0xce, 0x8c, 0x1b, 0x80, 0x5a}; + lwmqtt_string_t topic_filter_s0 = {14, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xab, 0x30, 0xcc, 0xa0, 0x18, 0x2e, 0x8e, 0xff, 0x20, 0x86, 0xc6, - 0xdc, 0x7f, 0x40, 0xa3, 0xd8, 0x32, 0xa5, 0x8e, 0xe1, 0xd0}; - lwmqtt_string_t topic_filter_s1 = {21, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd9, 0x4a, 0xcb, 0x1c, 0x81, 0xd1, 0xbe, 0x81, 0xb7, 0xd3, + 0x4e, 0xa7, 0x2, 0x4, 0x91, 0xd8, 0xf6, 0xcc, 0xc3, 0xd0}; + lwmqtt_string_t topic_filter_s1 = {20, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x5e, 0xa3, 0xcc, 0xd5, 0x54, 0x5a, 0x22, 0xe}; - lwmqtt_string_t topic_filter_s2 = {8, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xe4, 0x65, 0xb3, 0x5f, 0x74, 0x12, 0x3, 0xd0, 0xbd, 0xc7, + 0x37, 0x21, 0x96, 0x87, 0x9b, 0x7b, 0x96, 0x2e, 0x34, 0x59}; + lwmqtt_string_t topic_filter_s2 = {20, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x88, 0x21, 0xa7, 0x3d, 0xaa, 0xd6, 0x22, 0xe8, 0x1b, 0x20, - 0xd8, 0xae, 0x25, 0x5, 0x5d, 0xdb, 0x85, 0x7d, 0xe2, 0xeb}; - lwmqtt_string_t topic_filter_s3 = {20, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x54, 0xe5, 0x15, 0x5d, 0xab, 0xa6, 0x8d, 0xc1, 0x2a, 0xae, 0x1b, 0x1b, + 0x3f, 0xc6, 0xf2, 0x5c, 0x47, 0xf2, 0xd1, 0x0, 0x52, 0x4c, 0x7f, 0x19}; + lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x4a, 0xb6, 0x8, 0x54, 0x8c, 0x5a}; - lwmqtt_string_t topic_filter_s4 = {6, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xe3, 0xfb}; + lwmqtt_string_t topic_filter_s4 = {2, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xbc, 0x6e, 0x96, 0xbf, 0x4c, 0x23, 0x15, 0xc5, 0x88, - 0xc2, 0x5b, 0xc0, 0x6d, 0x8d, 0xc4, 0xa, 0xd3, 0xfc}; - lwmqtt_string_t topic_filter_s5 = {18, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0}; + lwmqtt_string_t topic_filter_s5 = {0, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xc3, 0x9d, 0xad, 0x6, 0x68, 0x7f, 0xb2, 0xe6, 0xd}; - lwmqtt_string_t topic_filter_s6 = {9, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0xf7, 0xe3, 0x3e, 0x11, 0x3f, 0xf, 0x6d, 0xfe, 0x66, 0xe1}; + lwmqtt_string_t topic_filter_s6 = {10, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x65, 0x28, 0x79, 0x13, 0xd, 0x7c, 0x2b, 0x8a, 0xd8, 0xc4, - 0x2a, 0xe3, 0x7e, 0xb4, 0x8c, 0x44, 0x58, 0xfa, 0xb5, 0x87, - 0x23, 0xd6, 0x23, 0x3b, 0x21, 0xe1, 0xa1, 0xc9}; - lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0x52, 0xc2, 0xc4, 0x7f, 0xd9, 0x6a, 0xf1, 0xa9, 0x36, 0x66, 0x9b}; + lwmqtt_string_t topic_filter_s7 = {11, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x31, 0xfc, 0xe1, 0xaf, 0x2, 0xac, 0xec, 0x16, - 0xb0, 0x32, 0x22, 0xcc, 0xb, 0x1e, 0x8, 0xbd}; - lwmqtt_string_t topic_filter_s8 = {16, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xda, 0xb5, 0xb2, 0xf5, 0x78, 0xbb, 0xf5, 0xa7, - 0x35, 0x90, 0xf9, 0x4c, 0x3a, 0xd1, 0x92}; - lwmqtt_string_t topic_filter_s9 = {15, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 12973, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 30931, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 26764 -// ["\228\129\194\154UZ\162#\ENQ\166y\194\131\134\146\CAN\249\179\195=\\H\131_\195\ACK","\157>\170,\252e\253\207?\202o\189\&8\149\170\251\138\173}\GS\224\ACK\181\156","\139O+\138\ESC$!\248\160\249K\171\161\214,l\r\191X\ETB*\160\246\a/","","\139\149j\246C\170\168\SI\n\151\SOH\219\243\RS\222\206k\199\ESC\SUB\DC2x(5:!D","\245x0\213\130\200\229\176\SUB$\SOH\ENQ\243\153\147\242\157\219\190","jv\130p\n\255\130\158\213\218O\SYN\194W\191\188","\210\132\229-R&\239\246\ESCe\194\US.\222\DC2&\135$\210YE\129","hM{7","\206N\242@%2\218\216\138\232\155\156\n\US\248z@\207\SYN\211\221\&8\164\239\155"] -// [PropRequestProblemInformation 159,PropTopicAlias 26553,PropMaximumPacketSize 21445,PropMessageExpiryInterval -// 30316,PropMessageExpiryInterval 1951,PropRequestResponseInformation 68,PropSharedSubscriptionAvailable -// 111,PropAuthenticationData "",PropMaximumPacketSize 24610,PropRequestResponseInformation 200,PropMaximumQoS -// 96,PropMessageExpiryInterval 27215,PropMaximumQoS 97,PropRequestProblemInformation -// 195,PropSubscriptionIdentifierAvailable 110,PropServerReference "Y\220n\133\153",PropResponseTopic -// "W\199\150\221",PropAssignedClientIdentifier -// "\SYN\227A%q\207\237\NUL\200\197:\157?\247\162\201\128\186",PropContentType -// "\168_\152\181\239\150\248^K\221\190\230"] +// UnsubscribeRequest 14609 +// ["\STX\186","\216\232'\187\247AC\149\141\&7(\219\ACK\245V\NUL\176q\225","\146\EOTs\135\223\183f\130\217i\200\252%\195\232L\233\STX\202\249\219'#\145\182\197","0]\240\US\255\201i\203.]|\DC3\173e\v","\174!\202\147\162\ESC\200\211\216\194WF\212N{'!^~2\ACKQ\157j\228\244","\163x\"\164\183\175$]\242\129\245'\164\\E","*W\240\217\DC1%D\193S\240\168\186\147\190\153$\f\213\182De\167\239\156\227"] +// [PropSharedSubscriptionAvailable 190,PropMessageExpiryInterval 16387,PropTopicAlias 30829,PropTopicAlias +// 29001,PropMessageExpiryInterval 22909,PropResponseTopic "\USU\aP6M\NUL\201\f",PropServerKeepAlive +// 3934,PropSharedSubscriptionAvailable 130,PropContentType +// "\178\DC2\170\NUL\202\215\169\190\150\ETBj\DC4\EMMq\235\155\227\156!\184\246\249\EM2\130~\216\223\150",PropAssignedClientIdentifier +// "y\241:&\EM\196\169Xba\129^2\248\&1qbd\240\198\159\162k",PropMessageExpiryInterval 2662,PropUserProperty +// "\220\DLE\157\152\142`\186\248\250\134t1\186\193\ACKU\145" "h\174\147a\201",PropResponseTopic +// "om\141y\221\SYNG[z(",PropAssignedClientIdentifier " +// \DEL5F\201]pT\221y\128\133\182\224\172\217",PropAuthenticationMethod +// "\186\249\169h\238\135\130:\188\255FT\233\219\254\253\147\151\219\222\FSKK=\163",PropTopicAliasMaximum 4513] TEST(Unsubscribe5QCTest, Encode22) { uint8_t pkt[] = { - 0xa2, 0xb5, 0x2, 0x68, 0x8c, 0x62, 0x17, 0x9f, 0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0x43, 0xaa, 0xa8, 0xf, 0xa, 0x97, 0x1, 0xdb, 0xf3, 0x1e, 0xde, 0xce, 0x6b, 0xc7, 0x1b, 0x1a, - 0x12, 0x78, 0x28, 0x35, 0x3a, 0x21, 0x44, 0x0, 0x13, 0xf5, 0x78, 0x30, 0xd5, 0x82, 0xc8, 0xe5, 0xb0, 0x1a, 0x24, - 0x1, 0x5, 0xf3, 0x99, 0x93, 0xf2, 0x9d, 0xdb, 0xbe, 0x0, 0x10, 0x6a, 0x76, 0x82, 0x70, 0xa, 0xff, 0x82, 0x9e, - 0xd5, 0xda, 0x4f, 0x16, 0xc2, 0x57, 0xbf, 0xbc, 0x0, 0x16, 0xd2, 0x84, 0xe5, 0x2d, 0x52, 0x26, 0xef, 0xf6, 0x1b, - 0x65, 0xc2, 0x1f, 0x2e, 0xde, 0x12, 0x26, 0x87, 0x24, 0xd2, 0x59, 0x45, 0x81, 0x0, 0x4, 0x68, 0x4d, 0x7b, 0x37, - 0x0, 0x19, 0xce, 0x4e, 0xf2, 0x40, 0x25, 0x32, 0xda, 0xd8, 0x8a, 0xe8, 0x9b, 0x9c, 0xa, 0x1f, 0xf8, 0x7a, 0x40, - 0xcf, 0x16, 0xd3, 0xdd, 0x38, 0xa4, 0xef, 0x9b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x59, 0xdc, 0x6e, 0x85, 0x99}; - uint8_t bytesprops2[] = {0x57, 0xc7, 0x96, 0xdd}; - uint8_t bytesprops3[] = {0x16, 0xe3, 0x41, 0x25, 0x71, 0xcf, 0xed, 0x0, 0xc8, - 0xc5, 0x3a, 0x9d, 0x3f, 0xf7, 0xa2, 0xc9, 0x80, 0xba}; - uint8_t bytesprops4[] = {0xa8, 0x5f, 0x98, 0xb5, 0xef, 0x96, 0xf8, 0x5e, 0x4b, 0xdd, 0xbe, 0xe6}; + 0xa2, 0xcf, 0x2, 0x39, 0x11, 0xbd, 0x1, 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a1, 0x0, 0x2, 0x2, 0xba, 0x0, 0x13, 0xd8, 0xe8, 0x27, 0xbb, 0xf7, 0x41, 0x43, + 0x95, 0x8d, 0x37, 0x28, 0xdb, 0x6, 0xf5, 0x56, 0x0, 0xb0, 0x71, 0xe1, 0x0, 0x1a, 0x92, 0x4, 0x73, 0x87, 0xdf, + 0xb7, 0x66, 0x82, 0xd9, 0x69, 0xc8, 0xfc, 0x25, 0xc3, 0xe8, 0x4c, 0xe9, 0x2, 0xca, 0xf9, 0xdb, 0x27, 0x23, 0x91, + 0xb6, 0xc5, 0x0, 0xf, 0x30, 0x5d, 0xf0, 0x1f, 0xff, 0xc9, 0x69, 0xcb, 0x2e, 0x5d, 0x7c, 0x13, 0xad, 0x65, 0xb, + 0x0, 0x1a, 0xae, 0x21, 0xca, 0x93, 0xa2, 0x1b, 0xc8, 0xd3, 0xd8, 0xc2, 0x57, 0x46, 0xd4, 0x4e, 0x7b, 0x27, 0x21, + 0x5e, 0x7e, 0x32, 0x6, 0x51, 0x9d, 0x6a, 0xe4, 0xf4, 0x0, 0xf, 0xa3, 0x78, 0x22, 0xa4, 0xb7, 0xaf, 0x24, 0x5d, + 0xf2, 0x81, 0xf5, 0x27, 0xa4, 0x5c, 0x45, 0x0, 0x19, 0x2a, 0x57, 0xf0, 0xd9, 0x11, 0x25, 0x44, 0xc1, 0x53, 0xf0, + 0xa8, 0xba, 0x93, 0xbe, 0x99, 0x24, 0xc, 0xd5, 0xb6, 0x44, 0x65, 0xa7, 0xef, 0x9c, 0xe3}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x1f, 0x55, 0x7, 0x50, 0x36, 0x4d, 0x0, 0xc9, 0xc}; + uint8_t bytesprops1[] = {0xb2, 0x12, 0xaa, 0x0, 0xca, 0xd7, 0xa9, 0xbe, 0x96, 0x17, 0x6a, 0x14, 0x19, 0x4d, 0x71, + 0xeb, 0x9b, 0xe3, 0x9c, 0x21, 0xb8, 0xf6, 0xf9, 0x19, 0x32, 0x82, 0x7e, 0xd8, 0xdf, 0x96}; + uint8_t bytesprops2[] = {0x79, 0xf1, 0x3a, 0x26, 0x19, 0xc4, 0xa9, 0x58, 0x62, 0x61, 0x81, 0x5e, + 0x32, 0xf8, 0x31, 0x71, 0x62, 0x64, 0xf0, 0xc6, 0x9f, 0xa2, 0x6b}; + uint8_t bytesprops4[] = {0x68, 0xae, 0x93, 0x61, 0xc9}; + uint8_t bytesprops3[] = {0xdc, 0x10, 0x9d, 0x98, 0x8e, 0x60, 0xba, 0xf8, 0xfa, + 0x86, 0x74, 0x31, 0xba, 0xc1, 0x6, 0x55, 0x91}; + uint8_t bytesprops5[] = {0x6f, 0x6d, 0x8d, 0x79, 0xdd, 0x16, 0x47, 0x5b, 0x7a, 0x28}; + uint8_t bytesprops6[] = {0x20, 0x7f, 0x35, 0x46, 0xc9, 0x5d, 0x70, 0x54, + 0xdd, 0x79, 0x80, 0x85, 0xb6, 0xe0, 0xac, 0xd9}; + uint8_t bytesprops7[] = {0xba, 0xf9, 0xa9, 0x68, 0xee, 0x87, 0x82, 0x3a, 0xbc, 0xff, 0x46, 0x54, 0xe9, + 0xdb, 0xfe, 0xfd, 0x93, 0x97, 0xdb, 0xde, 0x1c, 0x4b, 0x4b, 0x3d, 0xa3}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 159}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26553}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 21445}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30316}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1951}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 111}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24610}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 200}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 27215}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 97}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 195}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {18, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {12, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 190}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16387}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30829}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29001}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22909}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 3934}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 130}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {30, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 2662}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {17, (char*)&bytesprops3}, .v = {5, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {25, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 4513}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[10]; - uint8_t topic_filter_s0_bytes[] = {0xe4, 0x81, 0xc2, 0x9a, 0x55, 0x5a, 0xa2, 0x23, 0x5, 0xa6, 0x79, 0xc2, 0x83, - 0x86, 0x92, 0x18, 0xf9, 0xb3, 0xc3, 0x3d, 0x5c, 0x48, 0x83, 0x5f, 0xc3, 0x6}; - lwmqtt_string_t topic_filter_s0 = {26, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {16, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[7]; + uint8_t topic_filter_s0_bytes[] = {0x2, 0xba}; + lwmqtt_string_t topic_filter_s0 = {2, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0x9d, 0x3e, 0xaa, 0x2c, 0xfc, 0x65, 0xfd, 0xcf, 0x3f, 0xca, 0x6f, 0xbd, - 0x38, 0x95, 0xaa, 0xfb, 0x8a, 0xad, 0x7d, 0x1d, 0xe0, 0x6, 0xb5, 0x9c}; - lwmqtt_string_t topic_filter_s1 = {24, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xd8, 0xe8, 0x27, 0xbb, 0xf7, 0x41, 0x43, 0x95, 0x8d, 0x37, + 0x28, 0xdb, 0x6, 0xf5, 0x56, 0x0, 0xb0, 0x71, 0xe1}; + lwmqtt_string_t topic_filter_s1 = {19, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x8b, 0x4f, 0x2b, 0x8a, 0x1b, 0x24, 0x21, 0xf8, 0xa0, 0xf9, 0x4b, 0xab, 0xa1, - 0xd6, 0x2c, 0x6c, 0xd, 0xbf, 0x58, 0x17, 0x2a, 0xa0, 0xf6, 0x7, 0x2f}; - lwmqtt_string_t topic_filter_s2 = {25, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x92, 0x4, 0x73, 0x87, 0xdf, 0xb7, 0x66, 0x82, 0xd9, 0x69, 0xc8, 0xfc, 0x25, + 0xc3, 0xe8, 0x4c, 0xe9, 0x2, 0xca, 0xf9, 0xdb, 0x27, 0x23, 0x91, 0xb6, 0xc5}; + lwmqtt_string_t topic_filter_s2 = {26, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0}; - lwmqtt_string_t topic_filter_s3 = {0, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x30, 0x5d, 0xf0, 0x1f, 0xff, 0xc9, 0x69, 0xcb, + 0x2e, 0x5d, 0x7c, 0x13, 0xad, 0x65, 0xb}; + lwmqtt_string_t topic_filter_s3 = {15, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0x8b, 0x95, 0x6a, 0xf6, 0x43, 0xaa, 0xa8, 0xf, 0xa, 0x97, 0x1, 0xdb, 0xf3, 0x1e, - 0xde, 0xce, 0x6b, 0xc7, 0x1b, 0x1a, 0x12, 0x78, 0x28, 0x35, 0x3a, 0x21, 0x44}; - lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0xae, 0x21, 0xca, 0x93, 0xa2, 0x1b, 0xc8, 0xd3, 0xd8, 0xc2, 0x57, 0x46, 0xd4, + 0x4e, 0x7b, 0x27, 0x21, 0x5e, 0x7e, 0x32, 0x6, 0x51, 0x9d, 0x6a, 0xe4, 0xf4}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0xf5, 0x78, 0x30, 0xd5, 0x82, 0xc8, 0xe5, 0xb0, 0x1a, 0x24, - 0x1, 0x5, 0xf3, 0x99, 0x93, 0xf2, 0x9d, 0xdb, 0xbe}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xa3, 0x78, 0x22, 0xa4, 0xb7, 0xaf, 0x24, 0x5d, + 0xf2, 0x81, 0xf5, 0x27, 0xa4, 0x5c, 0x45}; + lwmqtt_string_t topic_filter_s5 = {15, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x6a, 0x76, 0x82, 0x70, 0xa, 0xff, 0x82, 0x9e, - 0xd5, 0xda, 0x4f, 0x16, 0xc2, 0x57, 0xbf, 0xbc}; - lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x2a, 0x57, 0xf0, 0xd9, 0x11, 0x25, 0x44, 0xc1, 0x53, 0xf0, 0xa8, 0xba, 0x93, + 0xbe, 0x99, 0x24, 0xc, 0xd5, 0xb6, 0x44, 0x65, 0xa7, 0xef, 0x9c, 0xe3}; + lwmqtt_string_t topic_filter_s6 = {25, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0xd2, 0x84, 0xe5, 0x2d, 0x52, 0x26, 0xef, 0xf6, 0x1b, 0x65, 0xc2, - 0x1f, 0x2e, 0xde, 0x12, 0x26, 0x87, 0x24, 0xd2, 0x59, 0x45, 0x81}; - lwmqtt_string_t topic_filter_s7 = {22, (char*)&topic_filter_s7_bytes}; - topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0x68, 0x4d, 0x7b, 0x37}; - lwmqtt_string_t topic_filter_s8 = {4, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; - uint8_t topic_filter_s9_bytes[] = {0xce, 0x4e, 0xf2, 0x40, 0x25, 0x32, 0xda, 0xd8, 0x8a, 0xe8, 0x9b, 0x9c, 0xa, - 0x1f, 0xf8, 0x7a, 0x40, 0xcf, 0x16, 0xd3, 0xdd, 0x38, 0xa4, 0xef, 0x9b}; - lwmqtt_string_t topic_filter_s9 = {25, (char*)&topic_filter_s9_bytes}; - topic_filters[9] = topic_filter_s9; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 26764, 10, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14609, 7, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 25855 -// ["*\148\DEL\172\179\158\a\ETX\SONJH`\204\245\213\178\t","","\132\212~\"a\157\185J\138:\200\142","\137\206\187\149\181\150l\210\253\178V\167\ESC\239@\GSD\231\139","\219\198\215\184]\249\ESC\146\186\ETB","K\140\254\EOT`\134\206\GS\195\219e\213\200\SIDy\239 -// \164","\164\146\155I\172w\DC3b\DC4qa","1k\NAK\130\DLE\202\GS\191\239B\tL\162z\ETX\213l\194\143\&6\SYN\152/\154\219e\NAKi","\247k3\164\228?\NUL\158\201\136y\202\169\202"] -// [PropReceiveMaximum 4746,PropMaximumQoS 155,PropRequestResponseInformation 245,PropMessageExpiryInterval -// 30886,PropTopicAlias 26829,PropServerKeepAlive 27060,PropSubscriptionIdentifierAvailable -// 115,PropSubscriptionIdentifier 19,PropMessageExpiryInterval 15916,PropMaximumQoS 205,PropAuthenticationMethod -// "]\DC1hJ\193\nyLW",PropTopicAlias 1188,PropUserProperty "'EF\DC4\186\211\194W\174r\200\SItbt\148" -// "\\",PropTopicAliasMaximum 18803,PropRetainAvailable 193,PropSessionExpiryInterval -// 31962,PropSubscriptionIdentifierAvailable 70,PropRetainAvailable 34,PropSubscriptionIdentifierAvailable -// 227,PropMaximumPacketSize 19223,PropWildcardSubscriptionAvailable 7,PropWildcardSubscriptionAvailable -// 21,PropMaximumPacketSize 8858,PropMessageExpiryInterval 17787,PropRequestResponseInformation 91,PropServerReference -// "\NAK\166\156B=\185\ESC\205\&7Zh\205\202\255\192\&6\STX\n\179\136_\132\245\187\&7",PropAuthenticationData -// "\180\222X\251",PropRequestProblemInformation 202,PropRequestProblemInformation 194,PropReasonString -// "&\197]$\GS\225f\222\EM"] +// UnsubscribeRequest 4540 +// ["","","\222\229\236","\133\214\163","F\186I\201-\n\246\DC2\234\245\156l\132o\252[\142t\210o\NAK\221\&6F\150\241","\241\183\179\&7\145]\130\189/",",P\144\130\178\b\202\SYNe\145\240 +// f\158\&2\CAN","\234c\GS\SIR\185\&75\159"] [PropAssignedClientIdentifier +// "\ACK\171\175\ACKzK\147\173\ENQR\184\216",PropRetainAvailable 244,PropRetainAvailable +// 246,PropRequestProblemInformation 84,PropReceiveMaximum 14811,PropServerReference +// "\221\n\207\149ku-\151\\W.\DLE\188\DEL\186^-\171MBA",PropTopicAliasMaximum 13793,PropAssignedClientIdentifier +// "\234H\150\207\214\RSt.4\212R{\238\219\253\ESC",PropResponseInformation +// "\184\SO\128\&2k\135\130\231\193\150\173%\RS\"B",PropWildcardSubscriptionAvailable 123,PropTopicAlias +// 26189,PropMaximumPacketSize 25918,PropMessageExpiryInterval 14888,PropTopicAliasMaximum 3934,PropUserProperty +// "\133\ACK\148\221\252I\248" "v}\228\242\217/\193\SUB9\146\252\199",PropTopicAlias 29560,PropResponseInformation +// "8z\166n\181,\231p\185\NUL\204\237\US\212\DC1h\173\FSZ\168\155\206\130\201",PropMessageExpiryInterval +// 29552,PropReasonString "\128\194%\GS\188\248\b9]J\FS5Q`\fd\198es@\146\235C\238\b\248K\202"] TEST(Unsubscribe5QCTest, Encode23) { uint8_t pkt[] = { - 0xa2, 0xb3, 0x2, 0x64, 0xff, 0x9a, 0x1, 0x21, 0x12, 0x8a, 0x24, 0x9b, 0x19, 0xf5, 0x2, 0x0, 0x0, 0x78, 0xa6, - 0x23, 0x68, 0xcd, 0x13, 0x69, 0xb4, 0x29, 0x73, 0xb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7, 0x8b, 0x0, 0xa, 0xdb, 0xc6, 0xd7, 0xb8, 0x5d, 0xf9, 0x1b, 0x92, - 0xba, 0x17, 0x0, 0x13, 0x4b, 0x8c, 0xfe, 0x4, 0x60, 0x86, 0xce, 0x1d, 0xc3, 0xdb, 0x65, 0xd5, 0xc8, 0xf, 0x44, - 0x79, 0xef, 0x20, 0xa4, 0x0, 0xb, 0xa4, 0x92, 0x9b, 0x49, 0xac, 0x77, 0x13, 0x62, 0x14, 0x71, 0x61, 0x0, 0x1c, - 0x31, 0x6b, 0x15, 0x82, 0x10, 0xca, 0x1d, 0xbf, 0xef, 0x42, 0x9, 0x4c, 0xa2, 0x7a, 0x3, 0xd5, 0x6c, 0xc2, 0x8f, - 0x36, 0x16, 0x98, 0x2f, 0x9a, 0xdb, 0x65, 0x15, 0x69, 0x0, 0xe, 0xf7, 0x6b, 0x33, 0xa4, 0xe4, 0x3f, 0x0, 0x9e, - 0xc9, 0x88, 0x79, 0xca, 0xa9, 0xca}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x5d, 0x11, 0x68, 0x4a, 0xc1, 0xa, 0x79, 0x4c, 0x57}; - uint8_t bytesprops2[] = {0x5c}; - uint8_t bytesprops1[] = {0x27, 0x45, 0x46, 0x14, 0xba, 0xd3, 0xc2, 0x57, - 0xae, 0x72, 0xc8, 0xf, 0x74, 0x62, 0x74, 0x94}; - uint8_t bytesprops3[] = {0x15, 0xa6, 0x9c, 0x42, 0x3d, 0xb9, 0x1b, 0xcd, 0x37, 0x5a, 0x68, 0xcd, 0xca, - 0xff, 0xc0, 0x36, 0x2, 0xa, 0xb3, 0x88, 0x5f, 0x84, 0xf5, 0xbb, 0x37}; - uint8_t bytesprops4[] = {0xb4, 0xde, 0x58, 0xfb}; - uint8_t bytesprops5[] = {0x26, 0xc5, 0x5d, 0x24, 0x1d, 0xe1, 0x66, 0xde, 0x19}; + 0xa2, 0x9a, 0x2, 0x11, 0xbc, 0xc4, 0x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73, 0x40, 0x92, 0xeb, 0x43, 0xee, 0x8, 0xf8, 0x4b, 0xca, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, + 0xde, 0xe5, 0xec, 0x0, 0x3, 0x85, 0xd6, 0xa3, 0x0, 0x1a, 0x46, 0xba, 0x49, 0xc9, 0x2d, 0xa, 0xf6, 0x12, 0xea, + 0xf5, 0x9c, 0x6c, 0x84, 0x6f, 0xfc, 0x5b, 0x8e, 0x74, 0xd2, 0x6f, 0x15, 0xdd, 0x36, 0x46, 0x96, 0xf1, 0x0, 0x9, + 0xf1, 0xb7, 0xb3, 0x37, 0x91, 0x5d, 0x82, 0xbd, 0x2f, 0x0, 0x10, 0x2c, 0x50, 0x90, 0x82, 0xb2, 0x8, 0xca, 0x16, + 0x65, 0x91, 0xf0, 0x20, 0x66, 0x9e, 0x32, 0x18, 0x0, 0x9, 0xea, 0x63, 0x1d, 0xf, 0x52, 0xb9, 0x37, 0x35, 0x9f}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x6, 0xab, 0xaf, 0x6, 0x7a, 0x4b, 0x93, 0xad, 0x5, 0x52, 0xb8, 0xd8}; + uint8_t bytesprops1[] = {0xdd, 0xa, 0xcf, 0x95, 0x6b, 0x75, 0x2d, 0x97, 0x5c, 0x57, 0x2e, + 0x10, 0xbc, 0x7f, 0xba, 0x5e, 0x2d, 0xab, 0x4d, 0x42, 0x41}; + uint8_t bytesprops2[] = {0xea, 0x48, 0x96, 0xcf, 0xd6, 0x1e, 0x74, 0x2e, + 0x34, 0xd4, 0x52, 0x7b, 0xee, 0xdb, 0xfd, 0x1b}; + uint8_t bytesprops3[] = {0xb8, 0xe, 0x80, 0x32, 0x6b, 0x87, 0x82, 0xe7, 0xc1, 0x96, 0xad, 0x25, 0x1e, 0x22, 0x42}; + uint8_t bytesprops5[] = {0x76, 0x7d, 0xe4, 0xf2, 0xd9, 0x2f, 0xc1, 0x1a, 0x39, 0x92, 0xfc, 0xc7}; + uint8_t bytesprops4[] = {0x85, 0x6, 0x94, 0xdd, 0xfc, 0x49, 0xf8}; + uint8_t bytesprops6[] = {0x38, 0x7a, 0xa6, 0x6e, 0xb5, 0x2c, 0xe7, 0x70, 0xb9, 0x0, 0xcc, 0xed, + 0x1f, 0xd4, 0x11, 0x68, 0xad, 0x1c, 0x5a, 0xa8, 0x9b, 0xce, 0x82, 0xc9}; + uint8_t bytesprops7[] = {0x80, 0xc2, 0x25, 0x1d, 0xbc, 0xf8, 0x8, 0x39, 0x5d, 0x4a, 0x1c, 0x35, 0x51, 0x60, + 0xc, 0x64, 0xc6, 0x65, 0x73, 0x40, 0x92, 0xeb, 0x43, 0xee, 0x8, 0xf8, 0x4b, 0xca}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4746}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 155}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 245}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30886}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26829}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27060}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15916}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {9, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1188}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {16, (char*)&bytesprops1}, .v = {1, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 18803}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31962}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 70}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 34}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 227}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19223}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 7}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 21}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8858}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17787}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 91}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {25, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {9, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {12, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 246}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 14811}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 13793}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {16, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {15, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 123}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26189}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25918}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14888}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3934}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops4}, .v = {12, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29560}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29552}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {28, (char*)&bytesprops7}}}, }; - lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[9]; - uint8_t topic_filter_s0_bytes[] = {0x2a, 0x94, 0x7f, 0xac, 0xb3, 0x9e, 0x7, 0x3, 0xe, - 0x4e, 0x4a, 0x48, 0x60, 0xcc, 0xf5, 0xd5, 0xb2, 0x9}; - lwmqtt_string_t topic_filter_s0 = {18, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[8]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; uint8_t topic_filter_s1_bytes[] = {0}; lwmqtt_string_t topic_filter_s1 = {0, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0x84, 0xd4, 0x7e, 0x22, 0x61, 0x9d, 0xb9, 0x4a, 0x8a, 0x3a, 0xc8, 0x8e}; - lwmqtt_string_t topic_filter_s2 = {12, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0xde, 0xe5, 0xec}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x89, 0xce, 0xbb, 0x95, 0xb5, 0x96, 0x6c, 0xd2, 0xfd, 0xb2, - 0x56, 0xa7, 0x1b, 0xef, 0x40, 0x1d, 0x44, 0xe7, 0x8b}; - lwmqtt_string_t topic_filter_s3 = {19, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x85, 0xd6, 0xa3}; + lwmqtt_string_t topic_filter_s3 = {3, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xdb, 0xc6, 0xd7, 0xb8, 0x5d, 0xf9, 0x1b, 0x92, 0xba, 0x17}; - lwmqtt_string_t topic_filter_s4 = {10, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x46, 0xba, 0x49, 0xc9, 0x2d, 0xa, 0xf6, 0x12, 0xea, 0xf5, 0x9c, 0x6c, 0x84, + 0x6f, 0xfc, 0x5b, 0x8e, 0x74, 0xd2, 0x6f, 0x15, 0xdd, 0x36, 0x46, 0x96, 0xf1}; + lwmqtt_string_t topic_filter_s4 = {26, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x4b, 0x8c, 0xfe, 0x4, 0x60, 0x86, 0xce, 0x1d, 0xc3, 0xdb, - 0x65, 0xd5, 0xc8, 0xf, 0x44, 0x79, 0xef, 0x20, 0xa4}; - lwmqtt_string_t topic_filter_s5 = {19, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0xf1, 0xb7, 0xb3, 0x37, 0x91, 0x5d, 0x82, 0xbd, 0x2f}; + lwmqtt_string_t topic_filter_s5 = {9, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0xa4, 0x92, 0x9b, 0x49, 0xac, 0x77, 0x13, 0x62, 0x14, 0x71, 0x61}; - lwmqtt_string_t topic_filter_s6 = {11, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x2c, 0x50, 0x90, 0x82, 0xb2, 0x8, 0xca, 0x16, + 0x65, 0x91, 0xf0, 0x20, 0x66, 0x9e, 0x32, 0x18}; + lwmqtt_string_t topic_filter_s6 = {16, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x31, 0x6b, 0x15, 0x82, 0x10, 0xca, 0x1d, 0xbf, 0xef, 0x42, - 0x9, 0x4c, 0xa2, 0x7a, 0x3, 0xd5, 0x6c, 0xc2, 0x8f, 0x36, - 0x16, 0x98, 0x2f, 0x9a, 0xdb, 0x65, 0x15, 0x69}; - lwmqtt_string_t topic_filter_s7 = {28, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xea, 0x63, 0x1d, 0xf, 0x52, 0xb9, 0x37, 0x35, 0x9f}; + lwmqtt_string_t topic_filter_s7 = {9, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; - uint8_t topic_filter_s8_bytes[] = {0xf7, 0x6b, 0x33, 0xa4, 0xe4, 0x3f, 0x0, 0x9e, 0xc9, 0x88, 0x79, 0xca, 0xa9, 0xca}; - lwmqtt_string_t topic_filter_s8 = {14, (char*)&topic_filter_s8_bytes}; - topic_filters[8] = topic_filter_s8; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 25855, 9, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4540, 8, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 20087 ["","\223$\157\133\154\STXu\172d\221\239W\239\v\142#\151b"] [PropRequestResponseInformation -// 3,PropReasonString ")%\140\151\134E\255I\165\DC1\"\184]",PropSubscriptionIdentifierAvailable -// 226,PropResponseInformation -// "\152t\255\184Y[\128\217\FS\143\204S\186g\129W\137\239\224\171S\159\FS;",PropRetainAvailable -// 150,PropResponseInformation "R,\246g\249\&1y\136\219",PropSubscriptionIdentifier 0,PropTopicAlias -// 8160,PropAuthenticationMethod "\135\232\217w\144\SI\133@\128\&2S_d\137\183\140",PropUserProperty "\167\215\240" -// "\197\169\ETB\219\250",PropRetainAvailable 186] +// UnsubscribeRequest 16569 +// ["","\170&\222\191\190a\189\220\226\176\DC1|\130\NAK\210\227\141\218\168\DEL\160\156\202\131\134\164"] +// [PropPayloadFormatIndicator 77,PropContentType +// "\177\246\228y\213\231\219\165\211KT\190*\149@\227",PropRequestResponseInformation 49,PropServerKeepAlive +// 10182,PropCorrelationData "\245\EM\245)m\231\US\165C\244b\226\222\243\DC3\142!\178\206\162\246_"] TEST(Unsubscribe5QCTest, Encode24) { - uint8_t pkt[] = {0xa2, 0x7d, 0x4e, 0x77, 0x64, 0x19, 0x3, 0x1f, 0x0, 0xd, 0x29, 0x25, 0x8c, 0x97, 0x86, 0x45, - 0xff, 0x49, 0xa5, 0x11, 0x22, 0xb8, 0x5d, 0x29, 0xe2, 0x1a, 0x0, 0x18, 0x98, 0x74, 0xff, 0xb8, - 0x59, 0x5b, 0x80, 0xd9, 0x1c, 0x8f, 0xcc, 0x53, 0xba, 0x67, 0x81, 0x57, 0x89, 0xef, 0xe0, 0xab, - 0x53, 0x9f, 0x1c, 0x3b, 0x25, 0x96, 0x1a, 0x0, 0x9, 0x52, 0x2c, 0xf6, 0x67, 0xf9, 0x31, 0x79, - 0x88, 0xdb, 0xb, 0x0, 0x23, 0x1f, 0xe0, 0x15, 0x0, 0x10, 0x87, 0xe8, 0xd9, 0x77, 0x90, 0xf, - 0x85, 0x40, 0x80, 0x32, 0x53, 0x5f, 0x64, 0x89, 0xb7, 0x8c, 0x26, 0x0, 0x3, 0xa7, 0xd7, 0xf0, - 0x0, 0x5, 0xc5, 0xa9, 0x17, 0xdb, 0xfa, 0x25, 0xba, 0x0, 0x0, 0x0, 0x12, 0xdf, 0x24, 0x9d, - 0x85, 0x9a, 0x2, 0x75, 0xac, 0x64, 0xdd, 0xef, 0x57, 0xef, 0xb, 0x8e, 0x23, 0x97, 0x62}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x29, 0x25, 0x8c, 0x97, 0x86, 0x45, 0xff, 0x49, 0xa5, 0x11, 0x22, 0xb8, 0x5d}; - uint8_t bytesprops1[] = {0x98, 0x74, 0xff, 0xb8, 0x59, 0x5b, 0x80, 0xd9, 0x1c, 0x8f, 0xcc, 0x53, - 0xba, 0x67, 0x81, 0x57, 0x89, 0xef, 0xe0, 0xab, 0x53, 0x9f, 0x1c, 0x3b}; - uint8_t bytesprops2[] = {0x52, 0x2c, 0xf6, 0x67, 0xf9, 0x31, 0x79, 0x88, 0xdb}; - uint8_t bytesprops3[] = {0x87, 0xe8, 0xd9, 0x77, 0x90, 0xf, 0x85, 0x40, - 0x80, 0x32, 0x53, 0x5f, 0x64, 0x89, 0xb7, 0x8c}; - uint8_t bytesprops5[] = {0xc5, 0xa9, 0x17, 0xdb, 0xfa}; - uint8_t bytesprops4[] = {0xa7, 0xd7, 0xf0}; + uint8_t pkt[] = {0xa2, 0x54, 0x40, 0xb9, 0x33, 0x1, 0x4d, 0x3, 0x0, 0x10, 0xb1, 0xf6, 0xe4, 0x79, 0xd5, + 0xe7, 0xdb, 0xa5, 0xd3, 0x4b, 0x54, 0xbe, 0x2a, 0x95, 0x40, 0xe3, 0x19, 0x31, 0x13, 0x27, + 0xc6, 0x9, 0x0, 0x16, 0xf5, 0x19, 0xf5, 0x29, 0x6d, 0xe7, 0x1f, 0xa5, 0x43, 0xf4, 0x62, + 0xe2, 0xde, 0xf3, 0x13, 0x8e, 0x21, 0xb2, 0xce, 0xa2, 0xf6, 0x5f, 0x0, 0x0, 0x0, 0x1a, + 0xaa, 0x26, 0xde, 0xbf, 0xbe, 0x61, 0xbd, 0xdc, 0xe2, 0xb0, 0x11, 0x7c, 0x82, 0x15, 0xd2, + 0xe3, 0x8d, 0xda, 0xa8, 0x7f, 0xa0, 0x9c, 0xca, 0x83, 0x86, 0xa4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xb1, 0xf6, 0xe4, 0x79, 0xd5, 0xe7, 0xdb, 0xa5, + 0xd3, 0x4b, 0x54, 0xbe, 0x2a, 0x95, 0x40, 0xe3}; + uint8_t bytesprops1[] = {0xf5, 0x19, 0xf5, 0x29, 0x6d, 0xe7, 0x1f, 0xa5, 0x43, 0xf4, 0x62, + 0xe2, 0xde, 0xf3, 0x13, 0x8e, 0x21, 0xb2, 0xce, 0xa2, 0xf6, 0x5f}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 3}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 150}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 8160}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops4}, .v = {5, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 77}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 49}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 10182}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {22, (char*)&bytesprops1}}}, }; - lwmqtt_properties_t props = {11, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; lwmqtt_string_t topic_filters[2]; uint8_t topic_filter_s0_bytes[] = {0}; lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xdf, 0x24, 0x9d, 0x85, 0x9a, 0x2, 0x75, 0xac, 0x64, - 0xdd, 0xef, 0x57, 0xef, 0xb, 0x8e, 0x23, 0x97, 0x62}; - lwmqtt_string_t topic_filter_s1 = {18, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0xaa, 0x26, 0xde, 0xbf, 0xbe, 0x61, 0xbd, 0xdc, 0xe2, 0xb0, 0x11, 0x7c, 0x82, + 0x15, 0xd2, 0xe3, 0x8d, 0xda, 0xa8, 0x7f, 0xa0, 0x9c, 0xca, 0x83, 0x86, 0xa4}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 20087, 2, topic_filters, props); + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 16569, 2, topic_filters, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_ARRAY_EQ(pkt, buf, len); } -// UnsubscribeRequest 23904 -// ["\149\138G<\153B","\176\152\174\227C\212\140\237\176F\225\157","\250\193{\220\129\129\245u\242\229\214\GS\252\173y\184p\165*\244}\215","\ESCB3C\185\170*\235\146\140H11H\198\156\223\DEL\131\144\131\136\224s\209k\b\195\FS"] -// [PropRequestResponseInformation 126,PropMessageExpiryInterval 20576,PropResponseInformation -// "\GS\210\159\237\184\ETXZx",PropAssignedClientIdentifier -// "f\141?\139F\241<\223\DC2\\\201\166\153!\216\r\174\219\197X|y\251\206 \US\178",PropAuthenticationMethod -// "[)wR)\191\177\239",PropUserProperty "B\162\na(Jq\ETB\164%I\163\187\154s\181\244\&2\n;\166\185&9" -// "\225~\227\214{bd\204\152[)c\SOk\DC4,\156c;\189\169\&3\ACK\142\EOT7",PropSubscriptionIdentifierAvailable -// 121,PropRequestResponseInformation 136,PropSessionExpiryInterval 1977,PropCorrelationData -// "\DC1\158\198\247\f\DC2\164U{\a\172\244Ks\213T\SOH\178\NUL\219H\189&IS\191-\rR\254",PropSubscriptionIdentifier -// 22,PropWillDelayInterval 22819,PropReasonString -// "\r\200Y\248\191\228\153\196,\f\144\143\\\244\SI\145<\214\226\135\f\f\169",PropTopicAlias 25943,PropUserProperty -// "\153\NUL\233\&0\180\203\v" "\203"] +// UnsubscribeRequest 14606 +// [".\DEL\196I\165\SIb1R\244ju\238\DC1\166","3\222\158W\247\213i\STXa","j.\\","G\168\128\184kL\181\SOH2J!\DC4F\DEL\198N+2z\nU\DC4\140.\154\222\SI\137\237","K\213\&7"] +// [PropTopicAlias 21144,PropSubscriptionIdentifierAvailable 107,PropPayloadFormatIndicator 198,PropMaximumPacketSize +// 25428,PropMessageExpiryInterval 23996,PropPayloadFormatIndicator 95,PropMaximumQoS 196,PropSubscriptionIdentifier +// 12,PropAuthenticationData "\SI1\225.\255\172\242\218P\189\159\148Y9\206\&2P\SI\214",PropResponseInformation +// "w\255^\174&\227\237\189\134-\130\153\&3\182\199E\206\224\178\229",PropRequestResponseInformation +// 236,PropTopicAliasMaximum 26590] TEST(Unsubscribe5QCTest, Encode25) { - uint8_t pkt[] = { - 0xa2, 0x9e, 0x2, 0x5d, 0x60, 0xcd, 0x1, 0x19, 0x7e, 0x2, 0x0, 0x0, 0x50, 0x60, 0x1a, 0x0, 0x8, 0x1d, 0xd2, - 0x9f, 0xed, 0xb8, 0x3, 0x5a, 0x78, 0x12, 0x0, 0x1b, 0x66, 0x8d, 0x3f, 0x8b, 0x46, 0xf1, 0x3c, 0xdf, 0x12, 0x5c, - 0xc9, 0xa6, 0x99, 0x21, 0xd8, 0xd, 0xae, 0xdb, 0xc5, 0x58, 0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 0xfa, 0xc1, 0x7b, 0xdc, 0x81, 0x81, 0xf5, 0x75, 0xf2, 0xe5, 0xd6, - 0x1d, 0xfc, 0xad, 0x79, 0xb8, 0x70, 0xa5, 0x2a, 0xf4, 0x7d, 0xd7, 0x0, 0x1d, 0x1b, 0x42, 0x33, 0x43, 0xb9, 0xaa, - 0x2a, 0xeb, 0x92, 0x8c, 0x48, 0x31, 0x31, 0x48, 0xc6, 0x9c, 0xdf, 0x7f, 0x83, 0x90, 0x83, 0x88, 0xe0, 0x73, 0xd1, - 0x6b, 0x8, 0xc3, 0x1c}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x1d, 0xd2, 0x9f, 0xed, 0xb8, 0x3, 0x5a, 0x78}; - uint8_t bytesprops1[] = {0x66, 0x8d, 0x3f, 0x8b, 0x46, 0xf1, 0x3c, 0xdf, 0x12, 0x5c, 0xc9, 0xa6, 0x99, 0x21, - 0xd8, 0xd, 0xae, 0xdb, 0xc5, 0x58, 0x7c, 0x79, 0xfb, 0xce, 0x20, 0x1f, 0xb2}; - uint8_t bytesprops2[] = {0x5b, 0x29, 0x77, 0x52, 0x29, 0xbf, 0xb1, 0xef}; - uint8_t bytesprops4[] = {0xe1, 0x7e, 0xe3, 0xd6, 0x7b, 0x62, 0x64, 0xcc, 0x98, 0x5b, 0x29, 0x63, 0xe, - 0x6b, 0x14, 0x2c, 0x9c, 0x63, 0x3b, 0xbd, 0xa9, 0x33, 0x6, 0x8e, 0x4, 0x37}; - uint8_t bytesprops3[] = {0x42, 0xa2, 0xa, 0x61, 0x28, 0x4a, 0x71, 0x17, 0xa4, 0x25, 0x49, 0xa3, - 0xbb, 0x9a, 0x73, 0xb5, 0xf4, 0x32, 0xa, 0x3b, 0xa6, 0xb9, 0x26, 0x39}; - uint8_t bytesprops5[] = {0x11, 0x9e, 0xc6, 0xf7, 0xc, 0x12, 0xa4, 0x55, 0x7b, 0x7, 0xac, 0xf4, 0x4b, 0x73, 0xd5, - 0x54, 0x1, 0xb2, 0x0, 0xdb, 0x48, 0xbd, 0x26, 0x49, 0x53, 0xbf, 0x2d, 0xd, 0x52, 0xfe}; - uint8_t bytesprops6[] = {0xd, 0xc8, 0x59, 0xf8, 0xbf, 0xe4, 0x99, 0xc4, 0x2c, 0xc, 0x90, 0x8f, - 0x5c, 0xf4, 0xf, 0x91, 0x3c, 0xd6, 0xe2, 0x87, 0xc, 0xc, 0xa9}; - uint8_t bytesprops8[] = {0xcb}; - uint8_t bytesprops7[] = {0x99, 0x0, 0xe9, 0x30, 0xb4, 0xcb, 0xb}; + uint8_t pkt[] = {0xa2, 0x91, 0x1, 0x39, 0xe, 0x49, 0x23, 0x52, 0x98, 0x29, 0x6b, 0x1, 0xc6, 0x27, 0x0, 0x0, 0x63, + 0x54, 0x2, 0x0, 0x0, 0x5d, 0xbc, 0x1, 0x5f, 0x24, 0xc4, 0xb, 0xc, 0x16, 0x0, 0x13, 0xf, 0x31, + 0xe1, 0x2e, 0xff, 0xac, 0xf2, 0xda, 0x50, 0xbd, 0x9f, 0x94, 0x59, 0x39, 0xce, 0x32, 0x50, 0xf, 0xd6, + 0x1a, 0x0, 0x14, 0x77, 0xff, 0x5e, 0xae, 0x26, 0xe3, 0xed, 0xbd, 0x86, 0x2d, 0x82, 0x99, 0x33, 0xb6, + 0xc7, 0x45, 0xce, 0xe0, 0xb2, 0xe5, 0x19, 0xec, 0x22, 0x67, 0xde, 0x0, 0xf, 0x2e, 0x7f, 0xc4, 0x49, + 0xa5, 0xf, 0x62, 0x31, 0x52, 0xf4, 0x6a, 0x75, 0xee, 0x11, 0xa6, 0x0, 0x9, 0x33, 0xde, 0x9e, 0x57, + 0xf7, 0xd5, 0x69, 0x2, 0x61, 0x0, 0x3, 0x6a, 0x2e, 0x5c, 0x0, 0x1d, 0x47, 0xa8, 0x80, 0xb8, 0x6b, + 0x4c, 0xb5, 0x1, 0x32, 0x4a, 0x21, 0x14, 0x46, 0x7f, 0xc6, 0x4e, 0x2b, 0x32, 0x7a, 0xa, 0x55, 0x14, + 0x8c, 0x2e, 0x9a, 0xde, 0xf, 0x89, 0xed, 0x0, 0x3, 0x4b, 0xd5, 0x37}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xf, 0x31, 0xe1, 0x2e, 0xff, 0xac, 0xf2, 0xda, 0x50, 0xbd, + 0x9f, 0x94, 0x59, 0x39, 0xce, 0x32, 0x50, 0xf, 0xd6}; + uint8_t bytesprops1[] = {0x77, 0xff, 0x5e, 0xae, 0x26, 0xe3, 0xed, 0xbd, 0x86, 0x2d, + 0x82, 0x99, 0x33, 0xb6, 0xc7, 0x45, 0xce, 0xe0, 0xb2, 0xe5}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 126}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 20576}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {8, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {8, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {24, (char*)&bytesprops3}, .v = {26, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 136}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1977}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {30, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 22819}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25943}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops7}, .v = {1, (char*)&bytesprops8}}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 21144}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 107}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 198}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25428}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23996}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 95}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 12}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 236}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 26590}}, }; - lwmqtt_properties_t props = {15, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[4]; - uint8_t topic_filter_s0_bytes[] = {0x95, 0x8a, 0x47, 0x3c, 0x99, 0x42}; - lwmqtt_string_t topic_filter_s0 = {6, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {12, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[5]; + uint8_t topic_filter_s0_bytes[] = {0x2e, 0x7f, 0xc4, 0x49, 0xa5, 0xf, 0x62, 0x31, + 0x52, 0xf4, 0x6a, 0x75, 0xee, 0x11, 0xa6}; + lwmqtt_string_t topic_filter_s0 = {15, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xb0, 0x98, 0xae, 0xe3, 0x43, 0xd4, 0x8c, 0xed, 0xb0, 0x46, 0xe1, 0x9d}; - lwmqtt_string_t topic_filter_s1 = {12, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x33, 0xde, 0x9e, 0x57, 0xf7, 0xd5, 0x69, 0x2, 0x61}; + lwmqtt_string_t topic_filter_s1 = {9, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xfa, 0xc1, 0x7b, 0xdc, 0x81, 0x81, 0xf5, 0x75, 0xf2, 0xe5, 0xd6, - 0x1d, 0xfc, 0xad, 0x79, 0xb8, 0x70, 0xa5, 0x2a, 0xf4, 0x7d, 0xd7}; - lwmqtt_string_t topic_filter_s2 = {22, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x6a, 0x2e, 0x5c}; + lwmqtt_string_t topic_filter_s2 = {3, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x1b, 0x42, 0x33, 0x43, 0xb9, 0xaa, 0x2a, 0xeb, 0x92, 0x8c, - 0x48, 0x31, 0x31, 0x48, 0xc6, 0x9c, 0xdf, 0x7f, 0x83, 0x90, - 0x83, 0x88, 0xe0, 0x73, 0xd1, 0x6b, 0x8, 0xc3, 0x1c}; + uint8_t topic_filter_s3_bytes[] = {0x47, 0xa8, 0x80, 0xb8, 0x6b, 0x4c, 0xb5, 0x1, 0x32, 0x4a, + 0x21, 0x14, 0x46, 0x7f, 0xc6, 0x4e, 0x2b, 0x32, 0x7a, 0xa, + 0x55, 0x14, 0x8c, 0x2e, 0x9a, 0xde, 0xf, 0x89, 0xed}; lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; + uint8_t topic_filter_s4_bytes[] = {0x4b, 0xd5, 0x37}; + lwmqtt_string_t topic_filter_s4 = {3, (char*)&topic_filter_s4_bytes}; + topic_filters[4] = topic_filter_s4; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 23904, 4, topic_filters, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} - -// UnsubscribeRequest 18211 ["RU\203\SOH\227Nbl11R~\206d\203\245\&9b\205\253","`\149\SUB<\b\128\137\250\185\176\EM\204"] -// [PropResponseTopic "\228\226;\179\141\151C\192J\132\179M\156#\ENQ\151\ACK/_Vw\209\218\220 ",PropReceiveMaximum -// 9650,PropAuthenticationData "\179\202\rA\NAKH\170[",PropSubscriptionIdentifierAvailable 9,PropSubscriptionIdentifier -// 8,PropRequestResponseInformation 187,PropSubscriptionIdentifierAvailable 252,PropSubscriptionIdentifierAvailable -// 40,PropTopicAliasMaximum 31349,PropSharedSubscriptionAvailable 79,PropMaximumQoS 249,PropResponseInformation -// "\SUB\EOT\154\167",PropReasonString -// "\STX\173\152x\235-\233\166)\244\237$\162\ETB\231\190\147xsk\253\&4\145\193BV\ETB"] + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 14606, 5, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 14000 +// ["","l\209\US\STX\SId","\186\198#\203t@D","\179\177g\225l","y\192\ESC\206\153\GSTVb\180\254\139\221\&7\255\219\208\234\DC3\240\137\202tp\SYN\158\149","}\b\152\173Sm\225\172\173{#\199\150N\170\136\217S\229\&7\250\155\168\180\134\181","\133q","\216\211GO\136w\142\SI","\135\212\152\253\ETX\232\227\216\DLE\245\131QC-\ETB2&\237I\219{\132\&20|A\148","&\227\176:l([\140;\250\179\157\b\166\137\242\231\EOTw\164\139","\204Q\203\251\SOHMX\193$\139\&12\178y\195V{\206q\FScT"] +// [] +TEST(Unsubscribe5QCTest, Encode27) { + uint8_t pkt[] = {0xa2, 0xe7, 0x1, 0x75, 0x7, 0x0, 0x0, 0xc, 0x0, 0x76, 0x5f, 0x47, 0x29, 0xdf, 0x6f, 0x38, 0xf1, + 0xf0, 0xa5, 0xff, 0x0, 0x1a, 0x1e, 0xb6, 0x64, 0x1c, 0x72, 0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c, 0x51, 0xcb, 0xfb, 0x1, 0x4d, 0x58, 0xc1, 0x24, + 0x8b, 0x31, 0x32, 0xb2, 0x79, 0xc3, 0x56, 0x7b, 0xce, 0x71, 0x1c, 0x63, 0x54}; uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23263}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; - lwmqtt_string_t topic_filters[8]; - uint8_t topic_filter_s0_bytes[] = {0x4a, 0x67, 0xe0, 0xfb, 0xcc, 0x3f, 0xf5, 0x3d}; - lwmqtt_string_t topic_filter_s0 = {8, (char*)&topic_filter_s0_bytes}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[11]; + uint8_t topic_filter_s0_bytes[] = {0x0, 0x76, 0x5f, 0x47, 0x29, 0xdf, 0x6f, 0x38, 0xf1, 0xf0, 0xa5, 0xff}; + lwmqtt_string_t topic_filter_s0 = {12, (char*)&topic_filter_s0_bytes}; topic_filters[0] = topic_filter_s0; - uint8_t topic_filter_s1_bytes[] = {0xf1, 0xcb, 0x62, 0xe4, 0x88, 0x94, 0x52, - 0x26, 0xa3, 0xe8, 0x53, 0x1f, 0xe9, 0x52}; - lwmqtt_string_t topic_filter_s1 = {14, (char*)&topic_filter_s1_bytes}; + uint8_t topic_filter_s1_bytes[] = {0x1e, 0xb6, 0x64, 0x1c, 0x72, 0xa6, 0x4, 0xbd, 0x9, 0xf4, 0xab, 0x77, 0xed, + 0xf7, 0xa2, 0x71, 0xc8, 0x4b, 0x6f, 0x29, 0xe, 0xbb, 0xd, 0x1f, 0x36, 0x52}; + lwmqtt_string_t topic_filter_s1 = {26, (char*)&topic_filter_s1_bytes}; topic_filters[1] = topic_filter_s1; - uint8_t topic_filter_s2_bytes[] = {0xca, 0x67, 0xa8, 0xb2, 0x5, 0x3b, 0x17, 0x83, - 0x9, 0x21, 0x34, 0xe3, 0xc7, 0x2e, 0x45, 0xfb}; - lwmqtt_string_t topic_filter_s2 = {16, (char*)&topic_filter_s2_bytes}; + uint8_t topic_filter_s2_bytes[] = {0x8d, 0x28, 0xa5, 0x2f, 0xd9, 0x38}; + lwmqtt_string_t topic_filter_s2 = {6, (char*)&topic_filter_s2_bytes}; topic_filters[2] = topic_filter_s2; - uint8_t topic_filter_s3_bytes[] = {0x2b, 0xc8, 0xab, 0x7b, 0x5a, 0x57, 0x14, 0x6, 0xaa, 0x20, 0x6e, 0xfd, - 0xab, 0x3d, 0x9d, 0x27, 0x5f, 0x9b, 0x9, 0x57, 0xa3, 0xf2, 0x7, 0xdf}; - lwmqtt_string_t topic_filter_s3 = {24, (char*)&topic_filter_s3_bytes}; + uint8_t topic_filter_s3_bytes[] = {0x0, 0x4, 0xde, 0x14, 0x6c, 0x6b, 0xab, 0x5a, 0xde, 0xd0, + 0x9, 0x31, 0xce, 0x7d, 0x29, 0xd8, 0xb0, 0xf1, 0x1a, 0xe2, + 0x29, 0x99, 0x7f, 0xbc, 0x36, 0x57, 0x76, 0xb0, 0x3e}; + lwmqtt_string_t topic_filter_s3 = {29, (char*)&topic_filter_s3_bytes}; topic_filters[3] = topic_filter_s3; - uint8_t topic_filter_s4_bytes[] = {0xe0, 0x5f, 0x4c, 0xfa, 0xae, 0xbd, 0x17, 0xaa, 0x9c, 0xf3, 0x0}; - lwmqtt_string_t topic_filter_s4 = {11, (char*)&topic_filter_s4_bytes}; + uint8_t topic_filter_s4_bytes[] = {0x79, 0xc0, 0x1b, 0xce, 0x99, 0x1d, 0x54, 0x56, 0x62, 0xb4, 0xfe, 0x8b, 0xdd, 0x37, + 0xff, 0xdb, 0xd0, 0xea, 0x13, 0xf0, 0x89, 0xca, 0x74, 0x70, 0x16, 0x9e, 0x95}; + lwmqtt_string_t topic_filter_s4 = {27, (char*)&topic_filter_s4_bytes}; topic_filters[4] = topic_filter_s4; - uint8_t topic_filter_s5_bytes[] = {0x23, 0x56, 0xf7, 0xdc, 0x33, 0xca, 0x81, 0x92, 0x73, 0x1d, 0xf4, 0x95, 0x9e, 0x78, - 0x69, 0xe7, 0x95, 0xf2, 0x7f, 0x94, 0xac, 0x9f, 0xd2, 0x5d, 0xe2, 0x19, 0x4e}; - lwmqtt_string_t topic_filter_s5 = {27, (char*)&topic_filter_s5_bytes}; + uint8_t topic_filter_s5_bytes[] = {0x7d, 0x8, 0x98, 0xad, 0x53, 0x6d, 0xe1, 0xac, 0xad, 0x7b, 0x23, 0xc7, 0x96, + 0x4e, 0xaa, 0x88, 0xd9, 0x53, 0xe5, 0x37, 0xfa, 0x9b, 0xa8, 0xb4, 0x86, 0xb5}; + lwmqtt_string_t topic_filter_s5 = {26, (char*)&topic_filter_s5_bytes}; topic_filters[5] = topic_filter_s5; - uint8_t topic_filter_s6_bytes[] = {0x52, 0x6, 0x1, 0x39, 0x94, 0xf4, 0x2f}; - lwmqtt_string_t topic_filter_s6 = {7, (char*)&topic_filter_s6_bytes}; + uint8_t topic_filter_s6_bytes[] = {0x85, 0x71}; + lwmqtt_string_t topic_filter_s6 = {2, (char*)&topic_filter_s6_bytes}; topic_filters[6] = topic_filter_s6; - uint8_t topic_filter_s7_bytes[] = {0x99, 0x25, 0xfc, 0xe7, 0x39, 0xfe, 0x83, 0xa1, 0xb4, 0xa1, 0x97, 0x22, - 0xef, 0x50, 0x21, 0x5f, 0x8d, 0x54, 0x19, 0x73, 0x7a, 0x22, 0x30}; - lwmqtt_string_t topic_filter_s7 = {23, (char*)&topic_filter_s7_bytes}; + uint8_t topic_filter_s7_bytes[] = {0xd8, 0xd3, 0x47, 0x4f, 0x88, 0x77, 0x8e, 0xf}; + lwmqtt_string_t topic_filter_s7 = {8, (char*)&topic_filter_s7_bytes}; topic_filters[7] = topic_filter_s7; + uint8_t topic_filter_s8_bytes[] = {0x87, 0xd4, 0x98, 0xfd, 0x3, 0xe8, 0xe3, 0xd8, 0x10, 0xf5, 0x83, 0x51, 0x43, 0x2d, + 0x17, 0x32, 0x26, 0xed, 0x49, 0xdb, 0x7b, 0x84, 0x32, 0x30, 0x7c, 0x41, 0x94}; + lwmqtt_string_t topic_filter_s8 = {27, (char*)&topic_filter_s8_bytes}; + topic_filters[8] = topic_filter_s8; + uint8_t topic_filter_s9_bytes[] = {0x26, 0xe3, 0xb0, 0x3a, 0x6c, 0x28, 0x5b, 0x8c, 0x3b, 0xfa, 0xb3, + 0x9d, 0x8, 0xa6, 0x89, 0xf2, 0xe7, 0x4, 0x77, 0xa4, 0x8b}; + lwmqtt_string_t topic_filter_s9 = {21, (char*)&topic_filter_s9_bytes}; + topic_filters[9] = topic_filter_s9; + uint8_t topic_filter_s10_bytes[] = {0xcc, 0x51, 0xcb, 0xfb, 0x1, 0x4d, 0x58, 0xc1, 0x24, 0x8b, 0x31, + 0x32, 0xb2, 0x79, 0xc3, 0x56, 0x7b, 0xce, 0x71, 0x1c, 0x63, 0x54}; + lwmqtt_string_t topic_filter_s10 = {22, (char*)&topic_filter_s10_bytes}; + topic_filters[10] = topic_filter_s10; size_t len; - lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 19016, 8, topic_filters, props); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_ARRAY_EQ(pkt, buf, len); -} + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 29959, 11, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 5839 [""] [PropTopicAlias 20494,PropReasonString +// "\209TK\251\222t\241\153\249\160\137v\173\170\185\\\248",PropMaximumPacketSize 27173,PropAuthenticationData +// "FL\221K\173\149\&8O@T\156\143\DC1\DELL\173\133",PropAuthenticationData +// "\160V\186Q7=\170\r\190\157H\131",PropMessageExpiryInterval 31658,PropResponseInformation +// "\EOT\157v\140+UM.\SI\244\190\218\255\r\CANhF\SOH\241e%",PropCorrelationData +// "\165\141vRF`\252:\143\178\215P\SO(\137\185\129\242r]\235\229v\a\158\n\168\202",PropResponseTopic +// "r<",PropRequestResponseInformation 153,PropRequestResponseInformation 219,PropWildcardSubscriptionAvailable +// 189,PropMessageExpiryInterval 32074,PropRequestResponseInformation 132,PropTopicAlias 30293,PropSessionExpiryInterval +// 18670,PropAuthenticationMethod "\242\\v\226+\158\162",PropCorrelationData +// "\NAK\229\181:\160\215\246R\186\229\196@8gn\142\161-",PropSubscriptionIdentifier 8,PropSessionExpiryInterval +// 1022,PropRequestProblemInformation 139,PropReasonString "m\254iR\242}\220\246\206\&0",PropPayloadFormatIndicator +// 108,PropResponseInformation +// "\GS@\157>iB\206\238O\128\236-\191P)\234\b\CAN\135\242\169\250n\139\SUB",PropAuthenticationData +// "\176\FSs/l\GS\172\165\194;\169\171\ENQ\253\234_\156L(\172",PropAuthenticationMethod +// "7*H\232\235s\US",PropReasonString "v<\197rS\142",PropMaximumQoS 55] +TEST(Unsubscribe5QCTest, Encode28) { + uint8_t pkt[] = { + 0xa2, 0x9a, 0x2, 0x16, 0xcf, 0x94, 0x2, 0x23, 0x50, 0xe, 0x1f, 0x0, 0x11, 0xd1, 0x54, 0x4b, 0xfb, 0xde, 0x74, + 0xf1, 0x99, 0xf9, 0xa0, 0x89, 0x76, 0xad, 0xaa, 0xb9, 0x5c, 0xf8, 0x27, 0x0, 0x0, 0x6a, 0x25, 0x16, 0x0, 0x11, + 0x46, 0x4c, 0xdd, 0x4b, 0xad, 0x95, 0x38, 0x4f, 0x40, 0x54, 0x9c, 0x8f, 0x11, 0x7f, 0x4c, 0xad, 0x85, 0x16, 0x0, + 0xc, 0xa0, 0x56, 0xba, 0x51, 0x37, 0x3d, 0xaa, 0xd, 0xbe, 0x9d, 0x48, 0x83, 0x2, 0x0, 0x0, 0x7b, 0xaa, 0x1a, + 0x0, 0x15, 0x4, 0x9d, 0x76, 0x8c, 0x2b, 0x55,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x73, 0x1f, 0x1f, 0x0, 0x6, 0x76, 0x3c, 0xc5, 0x72, 0x53, 0x8e, 0x24, 0x37, 0x0, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xd1, 0x54, 0x4b, 0xfb, 0xde, 0x74, 0xf1, 0x99, 0xf9, + 0xa0, 0x89, 0x76, 0xad, 0xaa, 0xb9, 0x5c, 0xf8}; + uint8_t bytesprops1[] = {0x46, 0x4c, 0xdd, 0x4b, 0xad, 0x95, 0x38, 0x4f, 0x40, + 0x54, 0x9c, 0x8f, 0x11, 0x7f, 0x4c, 0xad, 0x85}; + uint8_t bytesprops2[] = {0xa0, 0x56, 0xba, 0x51, 0x37, 0x3d, 0xaa, 0xd, 0xbe, 0x9d, 0x48, 0x83}; + uint8_t bytesprops3[] = {0x4, 0x9d, 0x76, 0x8c, 0x2b, 0x55, 0x4d, 0x2e, 0xf, 0xf4, 0xbe, + 0xda, 0xff, 0xd, 0x18, 0x68, 0x46, 0x1, 0xf1, 0x65, 0x25}; + uint8_t bytesprops4[] = {0xa5, 0x8d, 0x76, 0x52, 0x46, 0x60, 0xfc, 0x3a, 0x8f, 0xb2, 0xd7, 0x50, 0xe, 0x28, + 0x89, 0xb9, 0x81, 0xf2, 0x72, 0x5d, 0xeb, 0xe5, 0x76, 0x7, 0x9e, 0xa, 0xa8, 0xca}; + uint8_t bytesprops5[] = {0x72, 0x3c}; + uint8_t bytesprops6[] = {0xf2, 0x5c, 0x76, 0xe2, 0x2b, 0x9e, 0xa2}; + uint8_t bytesprops7[] = {0x15, 0xe5, 0xb5, 0x3a, 0xa0, 0xd7, 0xf6, 0x52, 0xba, + 0xe5, 0xc4, 0x40, 0x38, 0x67, 0x6e, 0x8e, 0xa1, 0x2d}; + uint8_t bytesprops8[] = {0x6d, 0xfe, 0x69, 0x52, 0xf2, 0x7d, 0xdc, 0xf6, 0xce, 0x30}; + uint8_t bytesprops9[] = {0x1d, 0x40, 0x9d, 0x3e, 0x69, 0x42, 0xce, 0xee, 0x4f, 0x80, 0xec, 0x2d, 0xbf, + 0x50, 0x29, 0xea, 0x8, 0x18, 0x87, 0xf2, 0xa9, 0xfa, 0x6e, 0x8b, 0x1a}; + uint8_t bytesprops10[] = {0xb0, 0x1c, 0x73, 0x2f, 0x6c, 0x1d, 0xac, 0xa5, 0xc2, 0x3b, + 0xa9, 0xab, 0x5, 0xfd, 0xea, 0x5f, 0x9c, 0x4c, 0x28, 0xac}; + uint8_t bytesprops11[] = {0x37, 0x2a, 0x48, 0xe8, 0xeb, 0x73, 0x1f}; + uint8_t bytesprops12[] = {0x76, 0x3c, 0xc5, 0x72, 0x53, 0x8e}; + + lwmqtt_property_t propslist[] = { + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20494}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {17, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 27173}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31658}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {21, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {2, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 153}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 219}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 189}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32074}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 132}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30293}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18670}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 1022}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 139}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {10, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 108}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {7, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {6, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 55}}, + }; -// UnsubscribeRequest 24261 -// ["/\168j\253\190Jy7\185~F\236J","S\225\251?H\DC1\249\DC3\ETX\182\155[\CAN","}\EOT\136\245\&6b\203\202","9\222\252{E\t\SYNK5\162El\EOTA\171\&4\152\ESC","w\157\&9N\nW\242K\NUL\150a\166~\196\168\226\187\DEL\tU\186\218f\168","l\194\247\SOB\246P/\139","?fa\190\246c\DC2|/\206\SO\149\246\149Ar\153\174\EM\168\SOH\150\163\175\&3\236\191\ENQ\f\158","R$\140\171\234d\136\145\221\151\US8|3\254","\DLE\SI_\219/\178\128k\149\188\203\130J%\245\200P","\186\237'\227\&6\220\179\227\170\228\SOH?=\GS\DC3\224\204\166\tj\ESC|-s;\179",""] -// [PropUserProperty "p\207\DC1\170\239\132" "\US\195VAb\210\\\RS\160x",PropServerKeepAlive -// 8037,PropSubscriptionIdentifier 4,PropRetainAvailable 158,PropContentType -// "p\210\149\156}\129\157\152'\EOT\255\184\217W\221\165\&9^\ACK\220C\SI\184v\146\ENQ\241\173\208\&4",PropMaximumQoS -// 193,PropTopicAlias 8090] + lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_string_t topic_filters[1]; + uint8_t topic_filter_s0_bytes[] = {0}; + lwmqtt_string_t topic_filter_s0 = {0, (char*)&topic_filter_s0_bytes}; + topic_filters[0] = topic_filter_s0; + size_t len; + lwmqtt_err_t err = lwmqtt_encode_unsubscribe(buf, sizeof(buf), &len, LWMQTT_MQTT5, 5839, 1, topic_filters, props); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_ARRAY_EQ(pkt, buf, len); +} + +// UnsubscribeRequest 8093 +// ["\140\244F\161","k5\NAK\128\246yah\170\t","\154\DC2\209)BN\179P\ETX>:\DC1\174\174\143HZZ","\137\208\145\SO\\\207\ETB\163","\181w4\223bZ\155\243A\162\248\162p\158\190\162\&8\132\v\163\&2\238\"\206k6\132","C\SUB\243\t\186\&0\166\DLE\211\148H\185\196\132\221\228\190%\144@~\243\255","G*","\FS\201\240\&9s\203\239\199\205d","V\\\216CA(\177f\229\172\150R\176r-\217\135","\215\217\143Yxc2f\\\168\229\ETX\SUB\214\207\DEL!\198\223\131%\147\r\ESC\199l8|\159\181"] +// [PropAuthenticationMethod "",PropAssignedClientIdentifier ";\255\n\176\141 +// \212\144\EOT\141\249?ZA\ETX\235a\159\233\150\139%\DC1`\250",PropContentType +// "\222\166\132xw\211\137N\244\215|KH\243\DC3\NAK\238`\253\&8gp" -// "\138\154\167\153\224\195\&01&",PropPayloadFormatIndicator 19,PropSessionExpiryInterval -// 13790,PropSubscriptionIdentifierAvailable 79,PropContentType "\240r\197",PropCorrelationData -// "@\193\190\203\DLE\rE",PropContentType -// "\218\140\t\226\219V\246$#\204e\142s\244\245^\222\173\178!-Wbb\187D",PropSubscriptionIdentifier -// 4,PropRequestResponseInformation 211,PropRequestProblemInformation 122] -// [UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted] +// UnsubscribeResponse 23639 [PropSharedSubscriptionAvailable 142,PropMessageExpiryInterval 12747] +// [UnsubNotAuthorized,UnsubSuccess,UnsubUnspecifiedError,UnsubSuccess,UnsubImplementationSpecificError,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubSuccess,UnsubSuccess,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid] TEST(UnsubACK5QCTest, Decode1) { - uint8_t pkt[] = {0xb0, 0x8a, 0x1, 0x14, 0x46, 0x76, 0x2a, 0xed, 0x29, 0x50, 0x8, 0x0, 0x8, 0x8e, 0x2b, 0xa5, - 0x81, 0x7f, 0x29, 0xaa, 0xd1, 0x1f, 0x0, 0x2, 0xe2, 0xbf, 0x28, 0x9c, 0x26, 0x0, 0x16, 0xa, - 0x22, 0x17, 0x1f, 0xcf, 0xf, 0x71, 0x8e, 0x57, 0x41, 0x3e, 0x4b, 0x48, 0xf3, 0x13, 0x15, 0xee, - 0x60, 0xfd, 0x38, 0x67, 0x70, 0x0, 0x9, 0x8a, 0x9a, 0xa7, 0x99, 0xe0, 0xc3, 0x30, 0x31, 0x26, - 0x1, 0x13, 0x11, 0x0, 0x0, 0x35, 0xde, 0x29, 0x4f, 0x3, 0x0, 0x3, 0xf0, 0x72, 0xc5, 0x9, - 0x0, 0x7, 0x40, 0xc1, 0xbe, 0xcb, 0x10, 0xd, 0x45, 0x3, 0x0, 0x1a, 0xda, 0x8c, 0x9, 0xe2, - 0xdb, 0x56, 0xf6, 0x24, 0x23, 0xcc, 0x65, 0x8e, 0x73, 0xf4, 0xf5, 0x5e, 0xde, 0xad, 0xb2, 0x21, - 0x2d, 0x57, 0x62, 0x62, 0xbb, 0x44, 0xb, 0x4, 0x19, 0xd3, 0x17, 0x7a, 0x91, 0x0, 0x8f, 0x91, - 0x11, 0x80, 0x83, 0x80, 0x83, 0x80, 0x80, 0x11, 0x87, 0x8f, 0x80, 0x91, 0x11}; + uint8_t pkt[] = {0xb0, 0x28, 0x5c, 0x57, 0x7, 0x2a, 0x8e, 0x2, 0x0, 0x0, 0x31, 0xcb, 0x87, 0x0, + 0x80, 0x0, 0x83, 0x0, 0x91, 0x83, 0x91, 0x83, 0x91, 0x91, 0x11, 0x83, 0x8f, 0x83, + 0x8f, 0x80, 0x87, 0x8f, 0x0, 0x0, 0x8f, 0x11, 0x8f, 0x91, 0x91, 0x0, 0x8f, 0x8f}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[17]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 17, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[30]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 30, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 5190); - EXPECT_EQ(count, 17); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(packet_id, 23639); + EXPECT_EQ(count, 30); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); -} - -// UnsubscribeResponse 10905 [PropTopicAliasMaximum 27710,PropResponseInformation -// "\NUL$\160\192\EOT\141V\208\174\135\215\222c",PropSessionExpiryInterval 17495,PropMessageExpiryInterval -// 14281,PropSharedSubscriptionAvailable 37,PropAuthenticationMethod "ix\140",PropWillDelayInterval -// 1500,PropCorrelationData "m\152\227\182\STX\202l\201g\SO\134\187\216\209n%\DELP|\135\135",PropMessageExpiryInterval -// 3420,PropMaximumQoS 39,PropAuthenticationData -// "7\255:\182q\246\RS\248\&5\144\220\154/79\230T\174\ENQ|\222~\146+\223\214\DLE\252\159",PropServerKeepAlive -// 18407,PropUserProperty "\219M\177'_" -// "\228\212l/\211\250z\145\&1\231\224Y:l\129\201\n\208\DEL\133\205\128B5\147\SOp\239\DC3",PropContentType -// "\228]\218\225j\163/\138+^\DLEVsY*\220\202\163\176\191\141\176\&9\SO\155\252\r\177I\185",PropMessageExpiryInterval -// 24830,PropTopicAlias 22210,PropRetainAvailable 94,PropUserProperty -// "\229C9\222\223\156\&8\DC1\191\154\159\241)\ad\240\215\195" "\223\&3\250\240y\230\248@\136",PropAuthenticationMethod -// "\175\f\160\145\SOHV",PropSubscriptionIdentifierAvailable +// 174,PropTopicAlias 11328,PropTopicAliasMaximum 4253,PropSharedSubscriptionAvailable 133,PropMessageExpiryInterval +// 31868] +// [UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubNotAuthorized] TEST(UnsubACK5QCTest, Decode5) { - uint8_t pkt[] = {0xb0, 0x51, 0x19, 0xa2, 0x41, 0x24, 0x84, 0x12, 0x0, 0x10, 0xa4, 0xe5, 0xf1, 0xd5, 0x8a, 0xd7, 0x66, - 0x7b, 0xe7, 0x42, 0xac, 0x9e, 0xad, 0x97, 0xa4, 0x4a, 0x24, 0xf0, 0x28, 0xbf, 0x23, 0x3e, 0xef, 0x21, - 0x6, 0xa5, 0x28, 0x56, 0x16, 0x0, 0x1d, 0x2d, 0x73, 0x42, 0xe5, 0x28, 0xc8, 0x3b, 0xe5, 0x5b, 0x1d, - 0x9b, 0xe9, 0x34, 0xe2, 0xc4, 0xb9, 0x9e, 0xb3, 0x1c, 0xa9, 0xf1, 0xb1, 0x7a, 0x7c, 0xa0, 0x42, 0xe9, - 0x3d, 0xa5, 0x11, 0x0, 0x0, 0x80, 0x87, 0x80, 0x87, 0x80, 0x91, 0x0, 0x11, 0x0, 0x8f}; + uint8_t pkt[] = {0xb0, 0x5e, 0x54, 0xc4, 0x4e, 0x24, 0x4, 0x17, 0x17, 0x21, 0x2a, 0xfa, 0x17, 0x6f, 0x18, 0x0, + 0x0, 0x34, 0x7d, 0xb, 0xd, 0x19, 0xa9, 0x27, 0x0, 0x0, 0x10, 0x32, 0x26, 0x0, 0x5, 0x68, + 0x7a, 0x69, 0xa7, 0x3b, 0x0, 0x1e, 0x6e, 0x77, 0xa9, 0x28, 0xf6, 0x76, 0xfb, 0x4e, 0x9a, 0x33, + 0xa2, 0x53, 0x5, 0x43, 0xff, 0xaf, 0x6e, 0x1d, 0xdb, 0xde, 0x74, 0x37, 0x63, 0x90, 0x49, 0x1a, + 0xd9, 0x7f, 0x3e, 0x56, 0x29, 0xae, 0x23, 0x2c, 0x40, 0x22, 0x10, 0x9d, 0x2a, 0x85, 0x2, 0x0, + 0x0, 0x7c, 0x7c, 0x0, 0x11, 0x11, 0x11, 0x91, 0x11, 0x11, 0x8f, 0x87, 0x8f, 0x87, 0x83, 0x87}; uint16_t packet_id; int count; lwmqtt_unsubscribe_status_t statuses[13]; lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 13, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6562); + EXPECT_EQ(packet_id, 21700); EXPECT_EQ(count, 13); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NOT_AUTHORIZED); } -// UnsubscribeResponse 32484 [PropMessageExpiryInterval 24715,PropSessionExpiryInterval 6744,PropSubscriptionIdentifier -// 7,PropAuthenticationData -// "`\252\187q\147\140\132\210\180\227b\201K\142\183\230\244![+\239-\226h\151\STX",PropSubscriptionIdentifierAvailable -// 20,PropTopicAlias 2199,PropServerReference "\246\&2a'\171",PropResponseTopic -// "C\167]\146\f\135\&3\130\166\FS\128\144\182U}\212\t\210C\186",PropWildcardSubscriptionAvailable +// 1,PropReceiveMaximum 14741,PropPayloadFormatIndicator 144,PropAuthenticationMethod +// "\NAK\"\139\215K\195O\242\182\162\\\248\189P\133n\167\&1\f\206U\201\193\209\203",PropReasonString +// "\144\&9\168,\230\188\208\159\135\236AQp\142\NAK\RS\187\b\131\DEL\241\169",PropMessageExpiryInterval +// 6194,PropCorrelationData +// "\219\147\232\231wg\226p\178#\199\EOT\DC2\231_\210\157\143\203\203\154\SYN\200jop\135\189om",PropUserProperty +// "\198M\161\242_\189?\STX\239" "?\192\189\&2Qx",PropReasonString "\134\243\149\183?Q\255\179\148\134",PropTopicAlias +// 32648,PropTopicAlias 24030,PropAuthenticationData "\239",PropCorrelationData +// "T\188\225\a\237\142Y;s\209\172\&7\237W\208X]",PropWildcardSubscriptionAvailable 92,PropResponseInformation +// "f\187[\194\128",PropSubscriptionIdentifierAvailable 165,PropCorrelationData +// "\SUB\153b\166\SOf\131\v\254\229\&6\DC2q\198\&1~%\141U\203\ACK\ETB\250\215\158\240I",PropWildcardSubscriptionAvailable +// 214,PropTopicAlias 11353] +// [UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubPacketIdentifierInUse] TEST(UnsubACK5QCTest, Decode7) { uint8_t pkt[] = { - 0xb0, 0xa7, 0x2, 0x7a, 0x11, 0x8c, 0x2, 0x21, 0x58, 0xab, 0x27, 0x0, 0x0, 0x2c, 0x17, 0x13, 0x36, 0x3e, 0x27, - 0x0, 0x0, 0x2a, 0xf, 0x1a, 0x0, 0x1e, 0x87, 0x40, 0x28, 0x52, 0xac, 0x81, 0x1a, 0x73, 0x5c, 0x2,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5, 0x36, 0x12, 0x71, 0xc6, 0x31, 0x7e, + 0x25, 0x8d, 0x55, 0xcb, 0x6, 0x17, 0xfa, 0xd7, 0x9e, 0xf0, 0x49, 0x28, 0xd6, 0x23, 0x2c, 0x59, 0x80, 0x11, 0x8f, + 0x83, 0x83, 0x80, 0x83, 0x91, 0x87, 0x11, 0x87, 0x80, 0x83, 0x11, 0x87, 0x91}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[23]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 23, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[16]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 16, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 31249); - EXPECT_EQ(count, 23); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(packet_id, 28996); + EXPECT_EQ(count, 16); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); } -// UnsubscribeResponse 18278 [PropTopicAliasMaximum 29170,PropTopicAliasMaximum 12797,PropSharedSubscriptionAvailable -// 147,PropMaximumPacketSize 27684,PropReasonString -// "\208\DLE\242\174\201\ETX[\170'\DELv\235f\219h\SI\169\228)%J\128\171\178G\208\171\131",PropRequestResponseInformation -// 215,PropSessionExpiryInterval 21356,PropWillDelayInterval 2475,PropAuthenticationData -// "\247\158\ff\177",PropPayloadFormatIndicator 122,PropRequestResponseInformation 195,PropRetainAvailable -// 117,PropResponseInformation -// "\DC1\206\222\194=QL\CAN\GS\133\192\&5:\RS\EM\161\254\n\133\v\211+\254\DC1b",PropReceiveMaximum -// 8036,PropSubscriptionIdentifier 13,PropAuthenticationMethod -// "\176\237-4\165f\DC3j[]4~\186\133\183\&7\150\142k\247{\t\233\DEL\161",PropTopicAlias 26886,PropTopicAlias -// 27587,PropTopicAliasMaximum 22088,PropContentType "\216'\231Y"] -// [UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubImplementationSpecificError] +// UnsubscribeResponse 7059 [PropServerKeepAlive 5109,PropRequestProblemInformation 233,PropContentType +// "\166\EM\175\163zdd\EMl@\145t\151?\239\154\162\212v",PropWillDelayInterval 9912,PropMessageExpiryInterval +// 12965,PropMaximumPacketSize 6332,PropTopicAliasMaximum 30771,PropSubscriptionIdentifier 29,PropMaximumQoS +// 207,PropCorrelationData +// "\159\\\CAN\151\158a\254\218\162\SOH\153\ETBC\t\203*x\191\223\NAKM\207\DEL\149w`",PropServerKeepAlive +// 3449,PropMaximumPacketSize 15149,PropReceiveMaximum 25363,PropPayloadFormatIndicator 60,PropSessionExpiryInterval +// 8805,PropResponseInformation +// "\143\194\NAK\178\247\CAN<\190\176\194(\189\225B\134\239\194\138\192m7",PropPayloadFormatIndicator +// 235,PropWildcardSubscriptionAvailable 177,PropRequestProblemInformation 199,PropMaximumPacketSize +// 24444,PropServerKeepAlive 21766,PropPayloadFormatIndicator 161,PropUserProperty "\180GL\149EJ \159\160g\174\137\179:" +// "V\143\196Y\253",PropAuthenticationData +// "G\218\156\225\239h\184\243|8\179mr\192\DC3I\169\240\205,e*\179\174$\241",PropMaximumQoS 6,PropTopicAliasMaximum +// 215,PropWildcardSubscriptionAvailable 148,PropMessageExpiryInterval 13104,PropAssignedClientIdentifier "["] +// [UnsubSuccess,UnsubSuccess,UnsubSuccess,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubSuccess,UnsubNoSubscriptionExisted] TEST(UnsubACK5QCTest, Decode8) { - uint8_t pkt[] = { - 0xb0, 0xa8, 0x1, 0x47, 0x66, 0x93, 0x1, 0x22, 0x71, 0xf2, 0x22, 0x31, 0xfd, 0x2a, 0x93, 0x27, 0x0, 0x0, 0x6c, - 0x24, 0x1f, 0x0, 0x1c, 0xd0, 0x10, 0xf2, 0xae, 0xc9, 0x3, 0x5b, 0xaa, 0x27, 0x7f, 0x76, 0xeb, 0x66, 0xdb, 0x68, - 0xf, 0xa9, 0xe4, 0x29, 0x25, 0x4a, 0x80, 0xab, 0xb2, 0x47, 0xd0, 0xab, 0x83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 0xa2, + 0x1, 0x99, 0x17, 0x43, 0x9, 0xcb, 0x2a, 0x78, 0xbf, 0xdf, 0x15, 0x4d, 0xcf, 0x7f, 0x95, 0x77, 0x60, + 0x13, 0xd, 0x79, 0x27, 0x0, 0x0, 0x3b, 0x2d, 0x21, 0x63, 0x13, 0x1, 0x3c, 0x11, 0x0, 0x0, 0x22, + 0x65, 0x1a, 0x0, 0x15, 0x8f, 0xc2, 0x15, 0xb2, 0xf7, 0x18, 0x3c, 0xbe, 0xb0, 0xc2, 0x28, 0xbd, 0xe1, + 0x42, 0x86, 0xef, 0xc2, 0x8a, 0xc0, 0x6d, 0x37, 0x1, 0xeb, 0x28, 0xb1, 0x17, 0xc7, 0x27, 0x0, 0x0, + 0x5f, 0x7c, 0x13, 0x55, 0x6, 0x1, 0xa1, 0x26, 0x0, 0xe, 0xb4, 0x47, 0x4c, 0x95, 0x45, 0x4a, 0x20, + 0x9f, 0xa0, 0x67, 0xae, 0x89, 0xb3, 0x3a, 0x0, 0x5, 0x56, 0x8f, 0xc4, 0x59, 0xfd, 0x16, 0x0, 0x1a, + 0x47, 0xda, 0x9c, 0xe1, 0xef, 0x68, 0xb8, 0xf3, 0x7c, 0x38, 0xb3, 0x6d, 0x72, 0xc0, 0x13, 0x49, 0xa9, + 0xf0, 0xcd, 0x2c, 0x65, 0x2a, 0xb3, 0xae, 0x24, 0xf1, 0x24, 0x6, 0x22, 0x0, 0xd7, 0x28, 0x94, 0x2, + 0x0, 0x0, 0x33, 0x30, 0x12, 0x0, 0x1, 0x5b, 0x0, 0x0, 0x0, 0x83, 0x80, 0x87, 0x0, 0x11, 0x91, + 0x0, 0x11, 0x8f, 0x8f, 0x8f, 0x80, 0x8f, 0x91, 0x8f, 0x80, 0x87, 0x0, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[17]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 17, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[22]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 22, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 18278); - EXPECT_EQ(count, 17); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); -} - -// UnsubscribeResponse 8788 [PropServerKeepAlive 26978,PropSessionExpiryInterval 7992,PropMessageExpiryInterval -// 32063,PropAssignedClientIdentifier "\219\202\EOT=1\221\ETX#\206\205\228r\254\230\194`|",PropMaximumPacketSize -// 17219,PropSubscriptionIdentifier 29,PropSubscriptionIdentifierAvailable 175,PropMessageExpiryInterval -// 12813,PropSubscriptionIdentifierAvailable 62,PropSubscriptionIdentifierAvailable 92,PropRequestResponseInformation -// 223,PropReasonString "\SUB\DC3\237\225\130O\142\n\f\232;\221\191\164-\242",PropServerReference -// "\162\245a\NUL0\186%\207&\"\222\238\220\238s\\X\184@k\144\"\229\&9\254\231#\169\228",PropServerKeepAlive -// 10678,PropMaximumQoS 213,PropMaximumQoS 255,PropServerReference "\156\220\&2",PropMaximumPacketSize -// 28763,PropRequestProblemInformation 144] -// [UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted] + EXPECT_EQ(packet_id, 7059); + EXPECT_EQ(count, 22); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_NO_SUB_EXISTED); +} + +// UnsubscribeResponse 29663 [PropServerKeepAlive 20618,PropSharedSubscriptionAvailable 245,PropResponseInformation +// "1r\159\138I\144j\SOH#\144\&3\144H\US\175\161\229z\t\200\170\213\153t\201U\DC4",PropWildcardSubscriptionAvailable +// 168,PropSubscriptionIdentifier 5,PropSubscriptionIdentifier 27,PropContentType +// "\203\DLE\NAK\181h\\:\130\230\176?W\GS\141\221\254\237\196\245s\ACK|\129E]\241\186\230\172",PropRequestResponseInformation +// 126,PropAuthenticationMethod +// "D\137B\229'\249\EOT\SUB\193\237\165\233J/\CAN\FSVFQ\209\167\213~",PropAssignedClientIdentifier +// "\232\179\187\216\197\250@\250\133\184n\134\129p\158 5/\193U{\148MLr\"\199ps\227",PropResponseTopic +// "\201\225\SOH\DC3\254\&8\222A\148\197'\135\&4h\181",PropReasonString +// "\205\141\f\173\209\183\171D\209\210\158\167Z\245h\172\239\189\159\215>\210\200",PropSessionExpiryInterval +// 18085,PropRequestProblemInformation 15,PropMessageExpiryInterval 21889,PropAuthenticationData +// "R\241W}",PropServerReference "\220\134\f\179,\193\n*h\201\167\178[<\SOH\SI*F\208\170\149g",PropSessionExpiryInterval +// 31029] [UnsubImplementationSpecificError,UnsubUnspecifiedError] TEST(UnsubACK5QCTest, Decode9) { - uint8_t pkt[] = {0xb0, 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x79, 0x35, 0x83, 0x80}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[9]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[2]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 8788); - EXPECT_EQ(count, 9); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(packet_id, 29663); + EXPECT_EQ(count, 2); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); } -// UnsubscribeResponse 27653 [PropMessageExpiryInterval 27137,PropCorrelationData -// "\150\&3\172q:\231\135",PropReceiveMaximum 28977,PropMaximumPacketSize 8765,PropCorrelationData -// "u\213\140\152\&7o\181\DLE\145\US*\152\140\135\204,o\151\aO",PropReceiveMaximum 31861,PropMessageExpiryInterval -// 9228,PropSubscriptionIdentifier 21,PropReasonString "]ft\FS2\238\216\204\166\215_\227\142\157\188\179\135\229\146j"] -// [UnsubSuccess,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted] +// UnsubscribeResponse 3853 [PropAuthenticationMethod "\147\249K\209\b\137V\154\v",PropPayloadFormatIndicator +// 182,PropAuthenticationMethod "+Ul\DC3\216",PropUserProperty "\230\193n\DC3p\DEL\"\199 +// \159X\182\169\150\226PA\FS\158\185 \190hs\v!\149\174M" "\193X\167\240\191\176",PropSubscriptionIdentifierAvailable +// 213,PropSubscriptionIdentifier 2,PropAssignedClientIdentifier "{!{\199",PropResponseInformation +// "Vv\244\200\236\&3\129\228*",PropWildcardSubscriptionAvailable 53,PropMessageExpiryInterval +// 18592,PropWillDelayInterval 21248] +// [UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse] TEST(UnsubACK5QCTest, Decode10) { - uint8_t pkt[] = {0xb0, 0x5f, 0x6c, 0x5, 0x4f, 0x2, 0x0, 0x0, 0x6a, 0x1, 0x9, 0x0, 0x7, 0x96, 0x33, 0xac, 0x71, - 0x3a, 0xe7, 0x87, 0x21, 0x71, 0x31, 0x27, 0x0, 0x0, 0x22, 0x3d, 0x9, 0x0, 0x14, 0x75, 0xd5, 0x8c, - 0x98, 0x37, 0x6f, 0xb5, 0x10, 0x91, 0x1f, 0x2a, 0x98, 0x8c, 0x87, 0xcc, 0x2c, 0x6f, 0x97, 0x7, 0x4f, - 0x21, 0x7c, 0x75, 0x2, 0x0, 0x0, 0x24, 0xc, 0xb, 0x15, 0x1f, 0x0, 0x14, 0x5d, 0x66, 0x74, 0x1c, - 0x32, 0xee, 0xd8, 0xcc, 0xa6, 0xd7, 0x5f, 0xe3, 0x8e, 0x9d, 0xbc, 0xb3, 0x87, 0xe5, 0x92, 0x6a, 0x0, - 0x91, 0x11, 0x80, 0x91, 0x0, 0x80, 0x91, 0x0, 0x87, 0x80, 0x0, 0x11}; + uint8_t pkt[] = {0xb0, 0x6e, 0xf, 0xd, 0x61, 0x15, 0x0, 0x9, 0x93, 0xf9, 0x4b, 0xd1, 0x8, 0x89, 0x56, 0x9a, + 0xb, 0x1, 0xb6, 0x15, 0x0, 0x5, 0x2b, 0x55, 0x6c, 0x13, 0xd8, 0x26, 0x0, 0x1d, 0xe6, 0xc1, + 0x6e, 0x13, 0x70, 0x7f, 0x22, 0xc7, 0x20, 0x9f, 0x58, 0xb6, 0xa9, 0x96, 0xe2, 0x50, 0x41, 0x1c, + 0x9e, 0xb9, 0x20, 0xbe, 0x68, 0x73, 0xb, 0x21, 0x95, 0xae, 0x4d, 0x0, 0x6, 0xc1, 0x58, 0xa7, + 0xf0, 0xbf, 0xb0, 0x29, 0xd5, 0xb, 0x2, 0x12, 0x0, 0x4, 0x7b, 0x21, 0x7b, 0xc7, 0x1a, 0x0, + 0x9, 0x56, 0x76, 0xf4, 0xc8, 0xec, 0x33, 0x81, 0xe4, 0x2a, 0x28, 0x35, 0x2, 0x0, 0x0, 0x48, + 0xa0, 0x18, 0x0, 0x0, 0x53, 0x0, 0x91, 0x8f, 0x87, 0x80, 0x87, 0x8f, 0x87, 0x11, 0x8f, 0x91}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[13]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 13, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[10]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 27653); - EXPECT_EQ(count, 13); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(packet_id, 3853); + EXPECT_EQ(count, 10); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); } -// UnsubscribeResponse 11848 [PropTopicAliasMaximum 14660,PropServerReference -// "\200\174\198\133a\207y\236\232J\192\206\SI2\231\209\NAK\v\205\&1",PropResponseTopic -// "H@(\153\SOua\135;!\170K\159",PropAssignedClientIdentifier ".j",PropRequestResponseInformation 196,PropReceiveMaximum -// 7860,PropCorrelationData -// "d\156\193\141\250\128\NUL\NAK\212>\EOT\239\133\143J\201\&2\216\144\"\STX\165",PropTopicAliasMaximum -// 8812,PropRetainAvailable 216] -// [UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubSuccess,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubImplementationSpecificError] +// UnsubscribeResponse 32691 [PropAuthenticationMethod +// "\"O\205\186\241\239\168Y\232\251\&5#\177\NAK\139\136\252\159$&d\DC4p\ETX\217~\242",PropServerKeepAlive +// 9377,PropMaximumPacketSize 31850,PropUserProperty ",9\197\208\229\ETX" "(\205ko\CAN\220\173J`\"\178",PropTopicAlias +// 2593,PropMessageExpiryInterval 19546,PropRequestProblemInformation 119,PropMaximumPacketSize 24476,PropMaximumQoS +// 42,PropServerReference "\as\189d^de\138\t\207\247\171\169I\NUL\EM",PropTopicAlias +// 27200,PropRequestResponseInformation 121,PropServerReference "R\232\EM\STX\177o\RSd",PropServerKeepAlive +// 29644,PropResponseInformation "L",PropSubscriptionIdentifier 20,PropMessageExpiryInterval 27352,PropContentType +// "",PropCorrelationData "r8A\131\DLE\185\CAN\173W\US\169N\246\160;r\SYN\134\159\206",PropWillDelayInterval +// 10386,PropServerKeepAlive 14482,PropSubscriptionIdentifier 29,PropServerReference "\ENQ\237\172"] +// [UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubSuccess,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubNotAuthorized] TEST(UnsubACK5QCTest, Decode11) { - uint8_t pkt[] = {0xb0, 0x66, 0x2e, 0x48, 0x52, 0x22, 0x39, 0x44, 0x1c, 0x0, 0x14, 0xc8, 0xae, 0xc6, 0x85, - 0x61, 0xcf, 0x79, 0xec, 0xe8, 0x4a, 0xc0, 0xce, 0xf, 0x32, 0xe7, 0xd1, 0x15, 0xb, 0xcd, - 0x31, 0x8, 0x0, 0xd, 0x48, 0x40, 0x28, 0x99, 0xe, 0x75, 0x61, 0x87, 0x3b, 0x21, 0xaa, - 0x4b, 0x9f, 0x12, 0x0, 0x2, 0x2e, 0x6a, 0x19, 0xc4, 0x21, 0x1e, 0xb4, 0x9, 0x0, 0x16, - 0x64, 0x9c, 0xc1, 0x8d, 0xfa, 0x80, 0x0, 0x15, 0xd4, 0x3e, 0x4, 0xef, 0x85, 0x8f, 0x4a, - 0xc9, 0x32, 0xd8, 0x90, 0x22, 0x2, 0xa5, 0x22, 0x22, 0x6c, 0x25, 0xd8, 0x80, 0x11, 0x83, - 0x0, 0x11, 0x8f, 0x11, 0x83, 0x0, 0x80, 0x91, 0x0, 0x83, 0x80, 0x91, 0x0, 0x83}; + uint8_t pkt[] = {0xb0, 0xbd, 0x1, 0x7f, 0xb3, 0xa8, 0x1, 0x15, 0x0, 0x1b, 0x22, 0x4f, 0xcd, 0xba, 0xf1, 0xef, + 0xa8, 0x59, 0xe8, 0xfb, 0x35, 0x23, 0xb1, 0x15, 0x8b, 0x88, 0xfc, 0x9f, 0x24, 0x26, 0x64, 0x14, + 0x70, 0x3, 0xd9, 0x7e, 0xf2, 0x13, 0x24, 0xa1, 0x27, 0x0, 0x0, 0x7c, 0x6a, 0x26, 0x0, 0x6, + 0x2c, 0x39, 0xc5, 0xd0, 0xe5, 0x3, 0x0, 0xb, 0x28, 0xcd, 0x6b, 0x6f, 0x18, 0xdc, 0xad, 0x4a, + 0x60, 0x22, 0xb2, 0x23, 0xa, 0x21, 0x2, 0x0, 0x0, 0x4c, 0x5a, 0x17, 0x77, 0x27, 0x0, 0x0, + 0x5f, 0x9c, 0x24, 0x2a, 0x1c, 0x0, 0x10, 0x7, 0x73, 0xbd, 0x64, 0x5e, 0x64, 0x65, 0x8a, 0x9, + 0xcf, 0xf7, 0xab, 0xa9, 0x49, 0x0, 0x19, 0x23, 0x6a, 0x40, 0x19, 0x79, 0x1c, 0x0, 0x8, 0x52, + 0xe8, 0x19, 0x2, 0xb1, 0x6f, 0x1e, 0x64, 0x13, 0x73, 0xcc, 0x1a, 0x0, 0x1, 0x4c, 0xb, 0x14, + 0x2, 0x0, 0x0, 0x6a, 0xd8, 0x3, 0x0, 0x0, 0x9, 0x0, 0x14, 0x72, 0x38, 0x41, 0x83, 0x10, + 0xb9, 0x18, 0xad, 0x57, 0x1f, 0xa9, 0x4e, 0xf6, 0xa0, 0x3b, 0x72, 0x16, 0x86, 0x9f, 0xce, 0x18, + 0x0, 0x0, 0x28, 0x92, 0x13, 0x38, 0x92, 0xb, 0x1d, 0x1c, 0x0, 0x3, 0x5, 0xed, 0xac, 0x8f, + 0x83, 0x11, 0x0, 0x87, 0x87, 0x80, 0x11, 0x0, 0x0, 0x83, 0x8f, 0x91, 0x91, 0x80, 0x83, 0x87}; uint16_t packet_id; int count; lwmqtt_unsubscribe_status_t statuses[17]; lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 17, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11848); + EXPECT_EQ(packet_id, 32691); EXPECT_EQ(count, 17); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); -} - -// UnsubscribeResponse 10434 [PropContentType "\231\153\188v`\178\CAN\142",PropServerReference -// "\STX\144\147\199l5\169=\236\&8\ENQ\218L\247\161\159\172",PropMessageExpiryInterval -// 26774,PropSharedSubscriptionAvailable 189,PropMessageExpiryInterval 150,PropServerReference -// "\141\160\207\&4PJ)\129\138\204\224KB\241\212I\199)s\180\182\FS\194\163\171j\200(^\206",PropAssignedClientIdentifier -// "\227",PropMessageExpiryInterval 627,PropCorrelationData -// "\192\146\252z\140\244&\249S\233\STX\229\DELm",PropContentType "\167\139\DC4\213L7",PropMessageExpiryInterval -// 26701,PropRequestProblemInformation 168,PropSubscriptionIdentifierAvailable 74,PropSubscriptionIdentifierAvailable -// 150,PropResponseInformation "zW\142u\213q\236G\211A\202\"\245\210,\DC4\239\233\245N'",PropMessageExpiryInterval -// 3303,PropUserProperty "\RS\129b\249H~\170ot\143\187I-\211J\199\167\181\212\160\&9\206\216\237\252f^" -// "\145\251|-\183\172\254",PropSessionExpiryInterval 13760,PropMaximumQoS 98] -// [UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubNotAuthorized,UnsubNoSubscriptionExisted] + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NOT_AUTHORIZED); +} + +// UnsubscribeResponse 27806 [PropServerKeepAlive 1965,PropReceiveMaximum 14371,PropRequestResponseInformation +// 200,PropMaximumQoS 1,PropMessageExpiryInterval 6636,PropRequestResponseInformation 193,PropContentType +// "\230f\194\DLEO\DC1\253\231Fn\169a\143\149\239",PropAssignedClientIdentifier "\n\DC4\129\SUB\128",PropRetainAvailable +// 4,PropTopicAlias 17711,PropAuthenticationMethod "\215\141*?\EM\222\173\217\211V)\172\244\166\200;xJ"] +// [UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubSuccess,UnsubSuccess,UnsubImplementationSpecificError] TEST(UnsubACK5QCTest, Decode12) { - uint8_t pkt[] = {0xb0, 0xd7, 0x1, 0x28, 0xc2, 0xc5, 0x1, 0x3, 0x0, 0x8, 0xe7, 0x99, 0xbc, 0x76, 0x60, 0xb2, 0x18, - 0x8e, 0x1c, 0x0, 0x11, 0x2, 0x90, 0x93, 0xc7, 0x6c, 0x35, 0xa9, 0x3d, 0xec, 0x38, 0x5, 0xda, 0x4c, - 0xf7, 0xa1, 0x9f, 0xac, 0x2, 0x0, 0x0, 0x68, 0x96, 0x2a, 0xbd, 0x2, 0x0, 0x0, 0x0, 0x96, 0x1c, - 0x0, 0x1e, 0x8d, 0xa0, 0xcf, 0x34, 0x50, 0x4a, 0x29, 0x81, 0x8a, 0xcc, 0xe0, 0x4b, 0x42, 0xf1, 0xd4, - 0x49, 0xc7, 0x29, 0x73, 0xb4, 0xb6, 0x1c, 0xc2, 0xa3, 0xab, 0x6a, 0xc8, 0x28, 0x5e, 0xce, 0x12, 0x0, - 0x1, 0xe3, 0x2, 0x0, 0x0, 0x2, 0x73, 0x9, 0x0, 0xe, 0xc0, 0x92, 0xfc, 0x7a, 0x8c, 0xf4, 0x26, - 0xf9, 0x53, 0xe9, 0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0x4a, 0x8f, 0x87, 0x80, 0x91, 0x0, 0x11, 0x80, 0x0, 0x0, 0x83}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[14]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 14, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[10]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 10434); - EXPECT_EQ(count, 14); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(packet_id, 27806); + EXPECT_EQ(count, 10); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[2], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); } -// UnsubscribeResponse 16799 [PropAuthenticationMethod -// "\GSx\195\222)\194\238&\181]\238\162\198\144\209\217\185\149\144\225",PropResponseTopic -// "(",PropRequestProblemInformation 224,PropSubscriptionIdentifier 21,PropRequestResponseInformation -// 139,PropWillDelayInterval 6123,PropAuthenticationData -// "\206s\239W\141\227\145\235\131\217\242\RS\DC1E\157`\136\223",PropUserProperty -// "\DLE\153\236E\241\&8i\SUB\241\223\188\185\245Ch\178\n\199\194WT\145&y-=f_7" -// "\197\FSN>\236\237\CANA\193\161\163\&1\252\244\231\154\EMS",PropContentType -// "\168(f\173\199*\188\f\193=0J\157\161D\194\158'MY8\vw\214\199<\138\t\176\DLE",PropContentType -// "\220\249\206\142\STXt3\RS\149k\220\155(",PropWillDelayInterval 13682,PropAuthenticationData "b",PropContentType -// "\136=\217\249\234\251\255=@\138\168\217\248i\STX\249rX+\156\176",PropResponseTopic -// "\bh\EMW[\DC1l\178\FS\ENQ\185\143",PropAuthenticationMethod "\141\242\ENQ\233x=\210\166\&2!\191\166\133\CAN \ETB"] -// [UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubSuccess,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubSuccess,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubNotAuthorized] +// UnsubscribeResponse 22916 [PropServerReference +// "\231g\224o\149\232\\\158\181\135\163t\238\188S\228w",PropRequestResponseInformation +// 80,PropSharedSubscriptionAvailable 3,PropMaximumPacketSize 6506,PropRequestResponseInformation +// 234,PropSubscriptionIdentifierAvailable 12,PropMessageExpiryInterval 7767,PropMaximumPacketSize +// 21548,PropReasonString +// "s\USV&B\ETB\142\180\234\171\179A^8\231\168\178\174\222;\147\180b\194",PropMessageExpiryInterval +// 993,PropRequestProblemInformation 176,PropServerReference +// "\186n[\b\248\194s\149\178\165E\231T\193\242\207\v\STX\139\n\t\185:O\211XA\tb",PropSubscriptionIdentifierAvailable +// 82,PropServerKeepAlive 8934,PropSubscriptionIdentifier 1,PropResponseInformation +// "\179\159C-\185R\146\n\ETBU\231\142\209ed,\SUBs\235\139i\DLEAo\199\ETB\186\143",PropRequestProblemInformation +// 120,PropResponseInformation "",PropPayloadFormatIndicator 241,PropResponseTopic "W\154\184d",PropUserProperty +// "<\163\\\233\EM\EOT" "\221\205\187f`\140\182\SO]\137\142",PropWillDelayInterval 807,PropCorrelationData +// "g\219\162\196_\CAN\180\170a\218'\167\131\130\&7\223\130\\",PropSharedSubscriptionAvailable 183,PropUserProperty +// "\254\&5" "\150n\209\SUBlt2\199pd6M\141",PropAuthenticationMethod +// "\235I\ENQ\249\229]\NULF\141\f\200h\130\149\r\238\&2\SOz\192\155$/\133",PropSessionExpiryInterval 495,PropTopicAlias +// 26739,PropTopicAlias 26496,PropRetainAvailable 156] +// [UnsubSuccess,UnsubSuccess,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid] TEST(UnsubACK5QCTest, Decode13) { - uint8_t pkt[] = {0xb0, 0xf9, 0x1, 0x41, 0x9f, 0xe3, 0x1, 0x15, 0x0, 0x14, 0x1d, 0x78, 0xc3, 0xde, 0x29, 0xc2, 0xee, - 0x26, 0xb5, 0x5d, 0xee, 0xa2, 0xc6, 0x90, 0xd1, 0xd9, 0xb9, 0x95, 0x90, 0xe1, 0x8, 0x0, 0x1, 0x28, - 0x17, 0xe0, 0xb, 0x15, 0x19, 0x8b, 0x18, 0x0, 0x0, 0x17, 0xeb, 0x16, 0x0, 0x12, 0xce, 0x73, 0xef, - 0x57, 0x8d, 0xe3, 0x91, 0xeb, 0x83, 0xd9, 0xf2, 0x1e, 0x11, 0x45, 0x9d, 0x60, 0x88, 0xdf, 0x26, 0x0, - 0x1d, 0x10, 0x99, 0xec, 0x45, 0xf1, 0x38, 0x69, 0x1a, 0xf1, 0xdf, 0xbc, 0xb9, 0xf5, 0x43, 0x68, 0xb2, - 0xa, 0xc7, 0xc2, 0x57, 0x54, 0x91, 0x26, 0x79, 0x2d, 0x3d, 0x66, 0x5f, 0x37, 0x0, 0x12, 0xc5, 0x1c, - 0x4e, 0x3e, 0xec, 0xed, 0x18, 0x41, 0xc1, 0xa1, 0xa3, 0x31, 0xfc, 0xf4, 0xe7, 0x9a, 0x19, 0x53, 0x3, - 0x0, 0x1e, 0xa8, 0x28, 0x66, 0xad, 0xc7, 0x2a, 0xbc, 0xc, 0xc1, 0x3d, 0x30, 0x4a, 0x9d, 0xa1, 0x44, - 0xc2, 0x9e, 0x27, 0x4d, 0x59, 0x38, 0xb, 0x77, 0xd6, 0xc7, 0x3c, 0x8a, 0x9, 0xb0, 0x10, 0x3, 0x0, - 0xd, 0xdc, 0xf9, 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0x0, 0x0, 0x8f, 0x11, 0x83, 0x8f, 0x8f, + 0x83, 0x11, 0x83, 0x0, 0x91, 0x83, 0x8f, 0x83, 0x83, 0x91, 0x83, 0x11, 0x8f}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[18]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 18, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[20]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 20, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 16799); - EXPECT_EQ(count, 18); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(packet_id, 22916); + EXPECT_EQ(count, 20); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); } -// UnsubscribeResponse 19000 [PropReceiveMaximum 20861] -// [UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubSuccess] +// UnsubscribeResponse 23906 [PropMaximumPacketSize 32722,PropTopicAliasMaximum 9751,PropPayloadFormatIndicator +// 52,PropServerReference "}N+\235\190\250\&4\n\220Pa\224\172BA\187",PropMaximumQoS 123,PropSubscriptionIdentifier +// 5,PropReasonString +// "\234\135B\189\189M\215B\162\217ry\183\200\&9\240\181}\f\228(\185\148\v\226\US",PropRetainAvailable +// 214,PropAuthenticationData "Fl\229!\NAK\SOH\nP5\173\219\217Af\150O@=Db/\NAK\240\142\SO",PropRequestProblemInformation +// 82,PropWildcardSubscriptionAvailable 164,PropRetainAvailable 214,PropRequestResponseInformation 75,PropMaximumQoS +// 153,PropWildcardSubscriptionAvailable 0,PropServerKeepAlive 14267,PropUserProperty "" +// "\165\133\CANv\ETB\237X\SI\232~`\128@#\226\200\235\141\234",PropMessageExpiryInterval 13701,PropReceiveMaximum +// 2557,PropContentType "\248\248d(\156\146\157>oG",PropContentType +// "\CAN\145\249\223\151\208\212\NUL\180\177\222*U\187\234\174?\ACKy\249\134\199\CAN\253\&5\SIP\203\238",PropRequestResponseInformation +// 115,PropReasonString "qk\226\192cE",PropRequestResponseInformation 7,PropSubscriptionIdentifier 17,PropReceiveMaximum +// 11114,PropRetainAvailable 203,PropUserProperty "\191!\CAN\155!\206w\137\t" +// ">\166Y1h\207\142\136I/\229\173\"\228\&3$\246Lt\174\189\218\227\&1sWV",PropSubscriptionIdentifier 20] +// [UnsubUnspecifiedError,UnsubSuccess,UnsubSuccess,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubSuccess,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubUnspecifiedError,UnsubSuccess] TEST(UnsubACK5QCTest, Decode14) { - uint8_t pkt[] = {0xb0, 0x10, 0x4a, 0x38, 0x3, 0x21, 0x51, 0x7d, 0x91, - 0x80, 0x0, 0x11, 0x87, 0x91, 0x83, 0x87, 0x8f, 0x0}; + uint8_t pkt[] = { + 0xb0, 0x90, 0x2, 0x5d, 0x62, 0xf7, 0x1, 0x27, 0x0, 0x0, 0x7f, 0xd2, 0x22, 0x26, 0x17, 0x1, 0x34, 0x1c, 0x0, + 0x10, 0x7d, 0x4e, 0x2b, 0xeb, 0xbe, 0xfa, 0x34, 0xa, 0xdc, 0x50, 0x61, 0xe0, 0xac, 0x42, 0x41, 0xbb, 0x24, 0x7b, + 0xb, 0x5, 0x1f, 0x0, 0x1a, 0xea, 0x87, 0x42, 0xbd, 0xbd, 0x4d, 0xd7, 0x42, 0xa2, 0xd9, 0x72, 0x79, 0xb7, 0xc8, + 0x39, 0xf0, 0xb5, 0x7d, 0xc, 0xe4, 0x28, 0xb9, 0x94, 0xb, 0xe2, 0x1f, 0x25, 0xd6, 0x16, 0x0, 0x19, 0x46, 0x6c, + 0xe5, 0x21, 0x15, 0x1, 0xa, 0x50, 0x35, 0xad, 0xdb, 0xd9, 0x41, 0x66, 0x96, 0x4f, 0x40, 0x3d, 0x44, 0x62, 0x2f, + 0x15, 0xf0, 0x8e, 0xe, 0x17, 0x52, 0x28, 0xa4, 0x25, 0xd6, 0x19, 0x4b, 0x24, 0x99, 0x28, 0x0, 0x13, 0x37, 0xbb, + 0x26, 0x0, 0x0, 0x0, 0x13, 0xa5, 0x85, 0x18, 0x76, 0x17, 0xed, 0x58, 0xf, 0xe8, 0x7e, 0x60, 0x80, 0x40, 0x23, + 0xe2, 0xc8, 0xeb, 0x8d, 0xea, 0x2, 0x0, 0x0, 0x35, 0x85, 0x21, 0x9, 0xfd, 0x3, 0x0, 0xa, 0xf8, 0xf8, 0x64, + 0x28, 0x9c, 0x92, 0x9d, 0x3e, 0x6f, 0x47, 0x3, 0x0, 0x1d, 0x18, 0x91, 0xf9, 0xdf, 0x97, 0xd0, 0xd4, 0x0, 0xb4, + 0xb1, 0xde, 0x2a, 0x55, 0xbb, 0xea, 0xae, 0x3f, 0x6, 0x79, 0xf9, 0x86, 0xc7, 0x18, 0xfd, 0x35, 0xf, 0x50, 0xcb, + 0xee, 0x19, 0x73, 0x1f, 0x0, 0x6, 0x71, 0x6b, 0xe2, 0xc0, 0x63, 0x45, 0x19, 0x7, 0xb, 0x11, 0x21, 0x2b, 0x6a, + 0x25, 0xcb, 0x26, 0x0, 0x9, 0xbf, 0x21, 0x18, 0x9b, 0x21, 0xce, 0x77, 0x89, 0x9, 0x0, 0x1b, 0x3e, 0xa6, 0x59, + 0x31, 0x68, 0xcf, 0x8e, 0x88, 0x49, 0x2f, 0xe5, 0xad, 0x22, 0xe4, 0x33, 0x24, 0xf6, 0x4c, 0x74, 0xae, 0xbd, 0xda, + 0xe3, 0x31, 0x73, 0x57, 0x56, 0xb, 0x14, 0x80, 0x0, 0x0, 0x80, 0x11, 0x91, 0x0, 0x8f, 0x8f, 0x80, 0x8f, 0x91, + 0x87, 0x0, 0x83, 0x11, 0x11, 0x11, 0x0, 0x80, 0x0}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[10]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 10, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[21]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 21, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 19000); - EXPECT_EQ(count, 10); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(packet_id, 23906); + EXPECT_EQ(count, 21); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); EXPECT_EQ(statuses[2], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); EXPECT_EQ(statuses[5], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); EXPECT_EQ(statuses[8], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_SUCCESS); } -// UnsubscribeResponse 6514 [PropAuthenticationMethod "~\t&F\"m#\216\222",PropPayloadFormatIndicator 130,PropTopicAlias -// 7070,PropResponseInformation "\ACK\200q\188i\204\t\DEL",PropMaximumQoS 192,PropRetainAvailable 56,PropServerKeepAlive -// 16040,PropRetainAvailable 179,PropUserProperty "" "b\237\134(",PropContentType "\169\220\245",PropResponseInformation -// "\253\170\238\188\229\GS\169\&0\DC4\CAN\198\132\164}D\SOH\133\ESCr?x\DC2.\151",PropTopicAlias -// 30069,PropMaximumPacketSize 23905,PropCorrelationData -// "\230\167\244\&0\151n\178\148C\223\209\GS\161\&47\136",PropContentType "\211\140\165Q\218",PropAuthenticationMethod -// "\231\147Ps",PropServerReference "\205\250\248\&6H",PropSessionExpiryInterval 5830,PropSessionExpiryInterval -// 7230,PropSubscriptionIdentifierAvailable 36,PropAuthenticationMethod -// "\168\212\194\DC28\160\r\220.\223\&3\148\251\&5\251+\162\DC4O\160",PropReceiveMaximum -// 19852,PropSharedSubscriptionAvailable 158,PropResponseTopic -// "\211\170\194\209Y6\137NbU\DC3\247U)\152[!R\131\176",PropCorrelationData -// "\164\253\214\180]5\241\147\161\149\174\203n\173"] -// [UnsubUnspecifiedError,UnsubNotAuthorized,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubUnspecifiedError] +// UnsubscribeResponse 6581 [PropSharedSubscriptionAvailable 165,PropResponseInformation +// "\173\180\173V\DEL\136&$!\182mu.\218\254h\188\241\152^",PropReasonString +// "\214\176\172\214\202\179\212R\151K\199\191\204\DLE\176'\236\132+~\STX\245\147.7?2",PropAuthenticationData +// "\206Y\SO\&H"] [UnsubSuccess,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted] TEST(UnsubACK5QCTest, Decode15) { - uint8_t pkt[] = {0xb0, 0xe4, 0x1, 0x19, 0x72, 0xd1, 0x1, 0x15, 0x0, 0x9, 0x7e, 0x9, 0x26, 0x46, 0x22, 0x6d, 0x23, - 0xd8, 0xde, 0x1, 0x82, 0x23, 0x1b, 0x9e, 0x1a, 0x0, 0x8, 0x6, 0xc8, 0x71, 0xbc, 0x69, 0xcc, 0x9, - 0x7f, 0x24, 0xc0, 0x25, 0x38, 0x13, 0x3e, 0xa8, 0x25, 0xb3, 0x26, 0x0, 0x0, 0x0, 0x4, 0x62, 0xed, - 0x86, 0x28, 0x3, 0x0, 0x3, 0xa9, 0xdc, 0xf5, 0x1a, 0x0, 0x18, 0xfd, 0xaa, 0xee, 0xbc, 0xe5, 0x1d, - 0xa9, 0x30, 0x14, 0x18, 0xc6, 0x84, 0xa4, 0x7d, 0x44, 0x1, 0x85, 0x1b, 0x72, 0x3f, 0x78, 0x12, 0x2e, - 0x97, 0x23, 0x75, 0x75, 0x27, 0x0, 0x0, 0x5d, 0x61, 0x9, 0x0, 0x10, 0xe6, 0xa7, 0xf4, 0x30, 0x97, - 0x6e, 0xb2, 0x94, 0x43, 0xdf, 0xd1, 0x1d, 0xa1, 0x34, 0x37, 0x88, 0x3, 0x0, 0x5, 0xd3, 0x8c, 0xa5, - 0x51, 0xda, 0x15, 0x0, 0x4, 0xe7, 0x93, 0x50, 0x73, 0x1c, 0x0, 0x5, 0xcd, 0xfa, 0xf8, 0x36, 0x48, - 0x11, 0x0, 0x0, 0x16, 0xc6, 0x11, 0x0, 0x0, 0x1c, 0x3e, 0x29, 0x24, 0x15, 0x0, 0x14, 0xa8, 0xd4, - 0xc2, 0x12, 0x38, 0xa0, 0xd, 0xdc, 0x2e, 0xdf, 0x33, 0x94, 0xfb, 0x35, 0xfb, 0x2b, 0xa2, 0x14, 0x4f, - 0xa0, 0x21, 0x4d, 0x8c, 0x2a, 0x9e, 0x8, 0x0, 0x14, 0xd3, 0xaa, 0xc2, 0xd1, 0x59, 0x36, 0x89, 0x4e, - 0x62, 0x55, 0x13, 0xf7, 0x55, 0x29, 0x98, 0x5b, 0x21, 0x52, 0x83, 0xb0, 0x9, 0x0, 0xe, 0xa4, 0xfd, - 0xd6, 0xb4, 0x5d, 0x35, 0xf1, 0x93, 0xa1, 0x95, 0xae, 0xcb, 0x6e, 0xad, 0x80, 0x87, 0x87, 0x83, 0x83, - 0x0, 0x91, 0x8f, 0x11, 0x91, 0x11, 0x91, 0x11, 0x83, 0x80}; + uint8_t pkt[] = {0xb0, 0x44, 0x19, 0xb5, 0x3e, 0x2a, 0xa5, 0x1a, 0x0, 0x14, 0xad, 0xb4, 0xad, 0x56, + 0x7f, 0x88, 0x26, 0x24, 0x21, 0xb6, 0x6d, 0x75, 0x2e, 0xda, 0xfe, 0x68, 0xbc, 0xf1, + 0x98, 0x5e, 0x1f, 0x0, 0x1b, 0xd6, 0xb0, 0xac, 0xd6, 0xca, 0xb3, 0xd4, 0x52, 0x97, + 0x4b, 0xc7, 0xbf, 0xcc, 0x10, 0xb0, 0x27, 0xec, 0x84, 0x2b, 0x7e, 0x2, 0xf5, 0x93, + 0x2e, 0x37, 0x3f, 0x32, 0x16, 0x0, 0x4, 0xce, 0x59, 0xe, 0x48, 0x0, 0x83, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[15]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 15, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[3]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 3, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6514); - EXPECT_EQ(count, 15); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(packet_id, 6581); + EXPECT_EQ(count, 3); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); } -// UnsubscribeResponse 22153 [PropRetainAvailable 112,PropAssignedClientIdentifier -// "\171\235%\188\254f8\164\200#\SUB\198\187\&8\212\173\181#\243\217i\221iC^\EM\203\185",PropWillDelayInterval -// 18288,PropRequestProblemInformation 22,PropRequestProblemInformation 21,PropMaximumQoS -// 53,PropRequestResponseInformation 49,PropCorrelationData -// "\192*,Z<}\r;v\ETB\196\&2\185z\199J\DC4\216\a\SOD\215pW\200",PropTopicAlias 22461,PropSessionExpiryInterval -// 12934,PropSharedSubscriptionAvailable 62,PropUserProperty "\185\t\130\EM\SYN\228k\218\221\163" -// "2}/\186\EOT:\t\128\&1\131\133\"vWO\151\188S\159jN\243\246\227c\197\175",PropReasonString -// "d@\234\165\143E\171\157",PropMaximumQoS 251,PropAuthenticationMethod -// "\SOH\135)\130\225u\NAK\230\166\231Y\242\239\136\254nO`{\238Q\247Y",PropCorrelationData -// "T\200l\142\252\221\182\SYN\241J{\216kdj\214\NAKl\203J\139\&5\223",PropRetainAvailable -// 81,PropSharedSubscriptionAvailable 193,PropServerKeepAlive 21372,PropContentType -// "\178\168G\183\185\254\236+e\238\SOH\STX\194\&2",PropAssignedClientIdentifier "u=J\225\128\233v3",PropReasonString -// ".\NUL\234"] [] +// UnsubscribeResponse 4238 [PropServerKeepAlive 13324,PropReceiveMaximum 25934,PropReceiveMaximum +// 18050,PropSubscriptionIdentifierAvailable 130,PropContentType "\141\159\171w\230\245\208",PropMessageExpiryInterval +// 31646,PropRequestProblemInformation 175,PropWillDelayInterval 6634,PropPayloadFormatIndicator +// 236,PropWillDelayInterval 11738,PropCorrelationData "\248",PropReceiveMaximum 7903,PropSubscriptionIdentifier +// 3,PropResponseInformation +// "\132\189\193\&7\200t\223\139u\165\161\238Y\252\242\222d\SUB\EOT\129\186\142\a\164",PropTopicAlias +// 22856,PropTopicAlias 6361,PropWillDelayInterval 4888,PropTopicAliasMaximum 10791,PropMessageExpiryInterval +// 25990,PropRequestResponseInformation 100,PropPayloadFormatIndicator 94,PropMaximumPacketSize +// 9290,PropSessionExpiryInterval 1190,PropMaximumQoS 96,PropServerKeepAlive 1158,PropTopicAlias +// 10096,PropSubscriptionIdentifierAvailable 189] +// [UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubUnspecifiedError] TEST(UnsubACK5QCTest, Decode18) { - uint8_t pkt[] = {0xb0, 0xa4, 0x1, 0x70, 0x36, 0xa0, 0x1, 0x29, 0x87, 0x13, 0x32, 0xc9, 0x26, 0x0, 0xe, 0x84, 0x92, - 0x1e, 0x9e, 0x30, 0x2d, 0x6e, 0x2c, 0x4, 0xac, 0xca, 0xe0, 0xea, 0x9f, 0x0, 0x1e, 0x89, 0xc9, 0x40, - 0x16, 0x96, 0x90, 0xbc, 0xd, 0x2a, 0x5c, 0x3a, 0xc4, 0x2c, 0x4c, 0x3e, 0x76, 0x57, 0x4f, 0x97, 0xbc, - 0x53, 0x9f, 0x6a, 0x4e, 0xf3, 0xf6, 0xe3, 0x63, 0xc5, 0xaf, 0x1f, 0x0, 0x8, 0x64, 0x40, 0xea, 0xa5, - 0x8f, 0x45, 0xab, 0x9d, 0x24, 0xfb, 0x15, 0x0, 0x17, 0x1, 0x87, 0x29, 0x82, 0xe1, 0x75, 0x15, 0xe6, - 0xa6, 0xe7, 0x59, 0xf2, 0xef, 0x88, 0xfe, 0x6e, 0x4f, 0x60, 0x7b, 0xee, 0x51, 0xf7, 0x59, 0x9, 0x0, - 0x17, 0x54, 0xc8, 0x6c, 0x8e, 0xfc, 0xdd, 0xb6, 0x16, 0xf1, 0x4a, 0x7b, 0xd8, 0x6b, 0x64, 0x6a, 0xd6, - 0x15, 0x6c, 0xcb, 0x4a, 0x8b, 0x35, 0xdf, 0x25, 0x51, 0x2a, 0xc1, 0x13, 0x53, 0x7c, 0x3, 0x0, 0xe, - 0xb2, 0xa8, 0x47, 0xb7, 0xb9, 0xfe, 0xec, 0x2b, 0x65, 0xee, 0x1, 0x2, 0xc2, 0x32, 0x12, 0x0, 0x8, - 0x75, 0x3d, 0x4a, 0xe1, 0x80, 0xe9, 0x76, 0x33, 0x1f, 0x0, 0x3, 0x2e, 0x0, 0xea}; - uint16_t packet_id; - int count; - lwmqtt_unsubscribe_status_t statuses[0]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 0, &count, statuses); - EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 28726); - EXPECT_EQ(count, 0); -} - -// UnsubscribeResponse 21422 [PropWillDelayInterval 28679,PropMaximumQoS 184,PropMessageExpiryInterval -// 20839,PropWillDelayInterval 2905,PropUserProperty -// "\130\251I\242a\199\153\244\181\SUB\217\181}\ETX\184\NUL\188P,\214\212]@\DC4\226\242" -// "X\201\242\201\DC4\178\&0/\NAK\STX\157V\ENQw\STX`?~\SOc\138\232\155|t\200",PropSubscriptionIdentifierAvailable -// 43,PropSubscriptionIdentifier 7,PropAssignedClientIdentifier "\156\STX\133\189\212\STX>",PropMessageExpiryInterval -// 21485,PropAuthenticationData "\158\128\239\142\171\226\228N\251\188\a\147!\203b\193",PropSharedSubscriptionAvailable -// 130,PropAuthenticationData "?\245\193\182\249D$\EM\197\154\193\DLE(",PropResponseTopic -// "r\176\135)~<\ENQ\213\237nfqi\SOH\161\168\235\186\182n\156\146H\250\143\248\212\&8",PropWillDelayInterval -// 21449,PropAuthenticationMethod -// "H\217\134\187\136\GS\136\200\ESC\181\NAK\200+J\212\&6\138\219\173\b\ACK_y#",PropCorrelationData -// "\174f\205\184j*gH",PropRequestProblemInformation 119,PropAssignedClientIdentifier -// "\186\174Z]\144d\252ZHR\ESC\172\218I\137\181\NAK\252ij2\177\SOHq\EOT{8\RSM",PropServerReference -// "7\248)\155\156\FSb\225\&6",PropMaximumPacketSize 3876,PropMessageExpiryInterval 2379] -// [UnsubTopicFilterInvalid,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubNotAuthorized] -TEST(UnsubACK5QCTest, Decode19) { - uint8_t pkt[] = { - 0xb0, 0x9f, 0x2, 0x53, 0xae, 0x84, 0x2, 0x18, 0x0, 0x0, 0x70, 0x7, 0x24, 0xb8, 0x2, 0x0, 0x0, 0x51, 0x67, - 0x18, 0x0, 0x0, 0xb, 0x59, 0x26, 0x0, 0x1a, 0x82, 0xfb, 0x49, 0xf2, 0x61, 0xc7, 0x99, 0xf4, 0xb5, 0x1a, 0xd9, - 0xb5, 0x7d, 0x3, 0xb8, 0x0, 0xbc, 0x50, 0x2c, 0xd6, 0xd4, 0x5d, 0x40, 0x14, 0xe2, 0xf2, 0x0, 0x1a, 0x58, 0xc9, - 0xf2, 0xc9, 0x14, 0xb2, 0x30, 0x2f, 0x15, 0x2, 0x9d, 0x56, 0x5, 0x77, 0x2, 0x60, 0x3f, 0x7e, 0xe, 0x63, 0x8a, - 0xe8, 0x9b, 0x7c, 0x74, 0xc8, 0x29, 0x2b, 0xb, 0x7, 0x12, 0x0, 0x7, 0x9c, 0x2, 0x85, 0xbd, 0xd4, 0x2, 0x3e, - 0x2, 0x0, 0x0, 0x53, 0xed, 0x16, 0x0, 0x10, 0x9e, 0x80, 0xef, 0x8e, 0xab, 0xe2, 0xe4, 0x4e, 0xfb, 0xbc, 0x7, - 0x93, 0x21, 0xcb, 0x62, 0xc1, 0x2a, 0x82, 0x16, 0x0, 0xd, 0x3f, 0xf5, 0xc1, 0xb6, 0xf9, 0x44, 0x24, 0x19, 0xc5, - 0x9a, 0xc1, 0x10, 0x28, 0x8, 0x0, 0x1c, 0x72, 0xb0, 0x87, 0x29, 0x7e, 0x3c, 0x5, 0xd5, 0xed, 0x6e, 0x66, 0x71, - 0x69, 0x1, 0xa1, 0xa8, 0xeb, 0xba, 0xb6, 0x6e, 0x9c, 0x92, 0x48, 0xfa, 0x8f, 0xf8, 0xd4, 0x38, 0x18, 0x0, 0x0, - 0x53, 0xc9, 0x15, 0x0, 0x18, 0x48, 0xd9, 0x86, 0xbb, 0x88, 0x1d, 0x88, 0xc8, 0x1b, 0xb5, 0x15, 0xc8, 0x2b, 0x4a, - 0xd4, 0x36, 0x8a, 0xdb, 0xad, 0x8, 0x6, 0x5f, 0x79, 0x23, 0x9, 0x0, 0x8, 0xae, 0x66, 0xcd, 0xb8, 0x6a, 0x2a, - 0x67, 0x48, 0x17, 0x77, 0x12, 0x0, 0x1d, 0xba, 0xae, 0x5a, 0x5d, 0x90, 0x64, 0xfc, 0x5a, 0x48, 0x52, 0x1b, 0xac, - 0xda, 0x49, 0x89, 0xb5, 0x15, 0xfc, 0x69, 0x6a, 0x32, 0xb1, 0x1, 0x71, 0x4, 0x7b, 0x38, 0x1e, 0x4d, 0x1c, 0x0, - 0x9, 0x37, 0xf8, 0x29, 0x9b, 0x9c, 0x1c, 0x62, 0xe1, 0x36, 0x27, 0x0, 0x0, 0xf, 0x24, 0x2, 0x0, 0x0, 0x9, - 0x4b, 0x8f, 0x0, 0x91, 0x80, 0x83, 0x8f, 0x83, 0x80, 0x11, 0x83, 0x11, 0x91, 0x80, 0x11, 0x80, 0x91, 0x87, 0x91, - 0x87, 0x0, 0x91, 0x11, 0x87}; + uint8_t pkt[] = {0xb0, 0x8a, 0x1, 0x10, 0x8e, 0x77, 0x13, 0x34, 0xc, 0x21, 0x65, 0x4e, 0x21, 0x46, 0x82, 0x29, + 0x82, 0x3, 0x0, 0x7, 0x8d, 0x9f, 0xab, 0x77, 0xe6, 0xf5, 0xd0, 0x2, 0x0, 0x0, 0x7b, 0x9e, + 0x17, 0xaf, 0x18, 0x0, 0x0, 0x19, 0xea, 0x1, 0xec, 0x18, 0x0, 0x0, 0x2d, 0xda, 0x9, 0x0, + 0x1, 0xf8, 0x21, 0x1e, 0xdf, 0xb, 0x3, 0x1a, 0x0, 0x18, 0x84, 0xbd, 0xc1, 0x37, 0xc8, 0x74, + 0xdf, 0x8b, 0x75, 0xa5, 0xa1, 0xee, 0x59, 0xfc, 0xf2, 0xde, 0x64, 0x1a, 0x4, 0x81, 0xba, 0x8e, + 0x7, 0xa4, 0x23, 0x59, 0x48, 0x23, 0x18, 0xd9, 0x18, 0x0, 0x0, 0x13, 0x18, 0x22, 0x2a, 0x27, + 0x2, 0x0, 0x0, 0x65, 0x86, 0x19, 0x64, 0x1, 0x5e, 0x27, 0x0, 0x0, 0x24, 0x4a, 0x11, 0x0, + 0x0, 0x4, 0xa6, 0x24, 0x60, 0x13, 0x4, 0x86, 0x23, 0x27, 0x70, 0x29, 0xbd, 0x87, 0x8f, 0x8f, + 0x11, 0x80, 0x80, 0x83, 0x11, 0x80, 0x80, 0x11, 0x11, 0x8f, 0x87, 0x80, 0x80}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[23]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 23, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[16]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 16, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21422); - EXPECT_EQ(count, 23); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(packet_id, 4238); + EXPECT_EQ(count, 16); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[14], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_UNSPECIFIED_ERROR); } -// UnsubscribeResponse 31508 [PropUserProperty "\247{\181C\171{h\188|84\204D\US\165\229#\173\r\230a" -// "0\146\157\236y\NUL\252\203\167_",PropServerReference -// "e\EM\150\222\196\166k\fj\250B\US\245I7\181\b\ETBa\128\239<05\b\163S\140u\\"] -// [UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubSuccess,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNotAuthorized] -TEST(UnsubACK5QCTest, Decode20) { - uint8_t pkt[] = {0xb0, 0x66, 0x7b, 0x14, 0x45, 0x26, 0x0, 0x15, 0xf7, 0x7b, 0xb5, 0x43, 0xab, 0x7b, 0x68, - 0xbc, 0x7c, 0x38, 0x34, 0xcc, 0x44, 0x1f, 0xa5, 0xe5, 0x23, 0xad, 0xd, 0xe6, 0x61, 0x0, - 0xa, 0x30, 0x92, 0x9d, 0xec, 0x79, 0x0, 0xfc, 0xcb, 0xa7, 0x5f, 0x1c, 0x0, 0x1e, 0x65, - 0x19, 0x96, 0xde, 0xc4, 0xa6, 0x6b, 0xc, 0x6a, 0xfa, 0x42, 0x1f, 0xf5, 0x49, 0x37, 0xb5, - 0x8, 0x17, 0x61, 0x80, 0xef, 0x3c, 0x30, 0x35, 0x8, 0xa3, 0x53, 0x8c, 0x75, 0x5c, 0x83, - 0x83, 0x11, 0x91, 0x0, 0x8f, 0x8f, 0x83, 0x91, 0x0, 0x0, 0x87, 0x8f, 0x83, 0x11, 0x91, - 0x87, 0x87, 0x87, 0x80, 0x80, 0x91, 0x0, 0x87, 0x91, 0x80, 0x0, 0x91, 0x8f, 0x87}; +// UnsubscribeResponse 4066 [PropPayloadFormatIndicator 138,PropRequestProblemInformation 227,PropReasonString +// "9\157\249b\ETB~\207\168\239\172\t$M\SUBg\227\234\SO\161\192N3\163",PropAssignedClientIdentifier +// "\EOT",PropTopicAliasMaximum 18698,PropAuthenticationData +// "z\131\DC1*p\163=d\160\192\155m\241f\183\239\214\223l\ETB\253\168W\136\211\r",PropMaximumQoS 168,PropUserProperty +// "\CAN\185\253\166\213\171\194\202\166\235\254\209\182\238B\212\&2UAA\DC3\250" +// "\217\134[\181\240\132\162\STX\214\229\223L&=\253Y\227Z\rx\253x\b\139\220\158\192\204\152\131",PropMessageExpiryInterval +// 23029,PropCorrelationData "L\171\166\157y\ETXL\135",PropTopicAliasMaximum 15827,PropServerReference +// "`\DC1\199\ETBA\161",PropTopicAlias 21218,PropServerReference "WQPdg\DLE\GS\ACK!B\ACK\143#k4\235\218="] +// [UnsubNoSubscriptionExisted] +TEST(UnsubACK5QCTest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 0xda, 0x3d, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[30]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 30, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[1]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 1, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 31508); - EXPECT_EQ(count, 30); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[25], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[26], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[27], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[28], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[29], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(packet_id, 4066); + EXPECT_EQ(count, 1); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); } -// UnsubscribeResponse 6014 [PropRequestProblemInformation 137,PropMaximumQoS 229,PropAssignedClientIdentifier -// "\SO_\160%\201\225{\192",PropPayloadFormatIndicator 244,PropTopicAliasMaximum -// 11438,PropSubscriptionIdentifierAvailable 110,PropResponseTopic "\DLE\155A_\FSF\160\200%\212\212",PropReceiveMaximum -// 18556,PropResponseTopic "9\178\244\NUL\153\129\206\177\128:\253\195",PropRequestProblemInformation -// 31,PropSharedSubscriptionAvailable 65,PropMessageExpiryInterval 25908,PropSharedSubscriptionAvailable -// 157,PropSharedSubscriptionAvailable 160,PropSessionExpiryInterval 12195,PropTopicAliasMaximum -// 11688,PropTopicAliasMaximum 6895,PropWildcardSubscriptionAvailable 56,PropSubscriptionIdentifier 27] -// [UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNoSubscriptionExisted] -TEST(UnsubACK5QCTest, Decode21) { - uint8_t pkt[] = {0xb0, 0x5b, 0x17, 0x7e, 0x52, 0x17, 0x89, 0x24, 0xe5, 0x12, 0x0, 0x8, 0xe, 0x5f, 0xa0, 0x25, - 0xc9, 0xe1, 0x7b, 0xc0, 0x1, 0xf4, 0x22, 0x2c, 0xae, 0x29, 0x6e, 0x8, 0x0, 0xb, 0x10, 0x9b, - 0x41, 0x5f, 0x1c, 0x46, 0xa0, 0xc8, 0x25, 0xd4, 0xd4, 0x21, 0x48, 0x7c, 0x8, 0x0, 0xc, 0x39, - 0xb2, 0xf4, 0x0, 0x99, 0x81, 0xce, 0xb1, 0x80, 0x3a, 0xfd, 0xc3, 0x17, 0x1f, 0x2a, 0x41, 0x2, - 0x0, 0x0, 0x65, 0x34, 0x2a, 0x9d, 0x2a, 0xa0, 0x11, 0x0, 0x0, 0x2f, 0xa3, 0x22, 0x2d, 0xa8, - 0x22, 0x1a, 0xef, 0x28, 0x38, 0xb, 0x1b, 0x8f, 0x83, 0x11, 0x8f, 0x0, 0x11}; +// UnsubscribeResponse 8672 [PropMaximumPacketSize 4206,PropServerReference +// "Q;+\225njF\167\229\177S\253\ESC\"\234\STX\154\DEL5\243\STX\"*\220\237\157'&\FS",PropResponseInformation +// "C\220\229EM\207\180\138\196VxL\137by\148j\244",PropTopicAlias 9824,PropUserProperty +// "\136$\136\182\136\FS2\161\186wA\SOH\US" "\207\SI\227\135\222m\183L\219\139\131\200B\217\&1"] +// [UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubSuccess] +TEST(UnsubACK5QCTest, Decode20) { + uint8_t pkt[] = {0xb0, 0x6a, 0x21, 0xe0, 0x5e, 0x27, 0x0, 0x0, 0x10, 0x6e, 0x1c, 0x0, 0x1d, 0x51, 0x3b, 0x2b, + 0xe1, 0x6e, 0x6a, 0x46, 0xa7, 0xe5, 0xb1, 0x53, 0xfd, 0x1b, 0x22, 0xea, 0x2, 0x9a, 0x7f, 0x35, + 0xf3, 0x2, 0x22, 0x2a, 0xdc, 0xed, 0x9d, 0x27, 0x26, 0x1c, 0x1a, 0x0, 0x12, 0x43, 0xdc, 0xe5, + 0x45, 0x4d, 0xcf, 0xb4, 0x8a, 0xc4, 0x56, 0x78, 0x4c, 0x89, 0x62, 0x79, 0x94, 0x6a, 0xf4, 0x23, + 0x26, 0x60, 0x26, 0x0, 0xd, 0x88, 0x24, 0x88, 0xb6, 0x88, 0x1c, 0x32, 0xa1, 0xba, 0x77, 0x41, + 0x1, 0x1f, 0x0, 0xf, 0xcf, 0xf, 0xe3, 0x87, 0xde, 0x6d, 0xb7, 0x4c, 0xdb, 0x8b, 0x83, 0xc8, + 0x42, 0xd9, 0x31, 0x8f, 0x8f, 0x87, 0x87, 0x11, 0x80, 0x80, 0x80, 0x0}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[6]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[9]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6014); - EXPECT_EQ(count, 6); + EXPECT_EQ(packet_id, 8672); + EXPECT_EQ(count, 9); EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); } -// UnsubscribeResponse 21904 [PropMaximumPacketSize 4466,PropMaximumQoS 44,PropWildcardSubscriptionAvailable -// 29,PropMaximumPacketSize 21462,PropSessionExpiryInterval 3915,PropSessionExpiryInterval -// 8258,PropSharedSubscriptionAvailable 173,PropAuthenticationMethod -// "6\230g\170\&4\RS\252}A\140\143\ETB\237O\CAN\158\&4\USO",PropCorrelationData -// "\253\DC3\ETB[\238\132\FSsh\130G\131L7\243Y\174C\170",PropTopicAlias 24650,PropPayloadFormatIndicator -// 80,PropAuthenticationMethod "\187\132\&8\139\US\ACKaBQ\230\179J",PropRetainAvailable -// 64,PropSubscriptionIdentifierAvailable 70,PropResponseTopic -// "\CAN\203B\t\210\238\228\194'\216\NAK\251}\176\205\196",PropResponseInformation -// "\188\245\188@\207\206\237O4\197",PropRetainAvailable 182,PropSubscriptionIdentifier -// 17,PropWildcardSubscriptionAvailable 32,PropWildcardSubscriptionAvailable 207,PropWillDelayInterval 30383] -// [UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess] -TEST(UnsubACK5QCTest, Decode22) { - uint8_t pkt[] = {0xb0, 0x9a, 0x1, 0x55, 0x90, 0x8b, 0x1, 0x27, 0x0, 0x0, 0x11, 0x72, 0x24, 0x2c, 0x28, 0x1d, - 0x27, 0x0, 0x0, 0x53, 0xd6, 0x11, 0x0, 0x0, 0xf, 0x4b, 0x11, 0x0, 0x0, 0x20, 0x42, 0x2a, - 0xad, 0x15, 0x0, 0x13, 0x36, 0xe6, 0x67, 0xaa, 0x34, 0x1e, 0xfc, 0x7d, 0x41, 0x8c, 0x8f, 0x17, - 0xed, 0x4f, 0x18, 0x9e, 0x34, 0x1f, 0x4f, 0x9, 0x0, 0x13, 0xfd, 0x13, 0x17, 0x5b, 0xee, 0x84, - 0x1c, 0x73, 0x68, 0x82, 0x47, 0x83, 0x4c, 0x37, 0xf3, 0x59, 0xae, 0x43, 0xaa, 0x23, 0x60, 0x4a, - 0x1, 0x50, 0x15, 0x0, 0xc, 0xbb, 0x84, 0x38, 0x8b, 0x1f, 0x6, 0x61, 0x42, 0x51, 0xe6, 0xb3, - 0x4a, 0x25, 0x40, 0x29, 0x46, 0x8, 0x0, 0x10, 0x18, 0xcb, 0x42, 0x9, 0xd2, 0xee, 0xe4, 0xc2, - 0x27, 0xd8, 0x15, 0xfb, 0x7d, 0xb0, 0xcd, 0xc4, 0x1a, 0x0, 0xa, 0xbc, 0xf5, 0xbc, 0x40, 0xcf, - 0xce, 0xed, 0x4f, 0x34, 0xc5, 0x25, 0xb6, 0xb, 0x11, 0x28, 0x20, 0x28, 0xcf, 0x18, 0x0, 0x0, - 0x76, 0xaf, 0x8f, 0x11, 0x8f, 0x91, 0x87, 0x83, 0x80, 0x11, 0x11, 0x91, 0x0}; +// UnsubscribeResponse 26380 [PropAuthenticationData +// "\175\149\184j\v;`X\191\209\248\191?\ETX\DC3<",PropAuthenticationMethod +// "\130\207\206><\"\193\SO\231T\199&\232\136",PropSharedSubscriptionAvailable 115,PropSharedSubscriptionAvailable +// 12,PropMessageExpiryInterval 25878,PropPayloadFormatIndicator 133,PropSubscriptionIdentifierAvailable +// 184,PropMaximumQoS 14,PropReasonString +// "\211K\202\CAN\205\168\169F\217Xm4\156\NAK,\172\134\EOT,\244\140\a\DC3-6\162<\fC\170",PropRequestProblemInformation +// 93,PropReasonString "\DLE\135k\162\235\128\227\128Z-\132\136 \143\174\DEL\218",PropWillDelayInterval +// 9169,PropReasonString "\ESCk`\194}\133",PropAssignedClientIdentifier +// "\r\243\ENQ\175\253%b\156?\176\245P\198\180\240\159A\216",PropContentType +// ":\227\182R\152\ACK\150\DC1\ETBV\238\158\221\226&\150\ACK\170\DEL+\US\239e\158\212>",PropServerKeepAlive +// 19087,PropServerKeepAlive 1277,PropRetainAvailable 250,PropAuthenticationData "",PropSharedSubscriptionAvailable +// 183,PropSharedSubscriptionAvailable 246,PropMessageExpiryInterval 14131,PropMessageExpiryInterval +// 22025,PropMaximumPacketSize 19055] +// [UnsubSuccess,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid] +TEST(UnsubACK5QCTest, Decode21) { + uint8_t pkt[] = { + 0xb0, 0xdb, 0x1, 0x67, 0xc, 0xc8, 0x1, 0x16, 0x0, 0x10, 0xaf, 0x95, 0xb8, 0x6a, 0xb, 0x3b, 0x60, 0x58, 0xbf, + 0xd1, 0xf8, 0xbf, 0x3f, 0x3, 0x13, 0x3c, 0x15, 0x0, 0xe, 0x82, 0xcf, 0xce, 0x3e, 0x3c, 0x22, 0xc1, 0x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; int count; - lwmqtt_unsubscribe_status_t statuses[11]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 11, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[15]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 15, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21904); - EXPECT_EQ(count, 11); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(packet_id, 26380); + EXPECT_EQ(count, 15); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); } -// UnsubscribeResponse 4583 [PropSubscriptionIdentifierAvailable 111,PropResponseInformation -// "px\169\170\US\164\251j\US\152\EM\221T:/\ENQ ",PropContentType -// "Od\214%w\135\&3q\DEL\150",PropRequestProblemInformation 163,PropResponseInformation -// "*\222\200\142\244\236q\140X5\154'\251a.Vq\185\ETX\204=\178\178",PropReasonString -// "\200\151\ETB\201'\196&\220\SOH\149/\138vs\246\SUB\238\191c\EM",PropResponseTopic -// "<\168f\134\171S\FS\196X\161\254KiQN",PropRequestResponseInformation 187,PropWildcardSubscriptionAvailable -// 201,PropTopicAlias 546,PropMessageExpiryInterval 2620,PropSharedSubscriptionAvailable 194,PropTopicAliasMaximum -// 32444,PropResponseTopic "\128*\135\226\143\SYN\252",PropRetainAvailable 13,PropUserProperty "\f\137\155Q\DC4\a" -// "t\249\231r\"\142\158\253\195\159",PropReasonString "\233\175",PropSharedSubscriptionAvailable -// 164,PropMessageExpiryInterval 21618,PropMessageExpiryInterval 28659,PropRequestProblemInformation -// 160,PropSharedSubscriptionAvailable 111,PropRequestResponseInformation 254,PropRetainAvailable -// 103,PropMessageExpiryInterval 11371,PropMessageExpiryInterval 17128,PropReasonString -// "\tp\FS!A\188\230",PropMessageExpiryInterval 30871,PropSessionExpiryInterval 15784] -// [UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse] -TEST(UnsubACK5QCTest, Decode23) { - uint8_t pkt[] = { - 0xb0, 0xdc, 0x1, 0x11, 0xe7, 0xd1, 0x1, 0x29, 0x6f, 0x1a, 0x0, 0x11, 0x70, 0x78, 0xa9, 0xaa, 0x1f, 0xa4, 0xfb, - 0x6a, 0x1f, 0x98, 0x19, 0xdd, 0x54, 0x3a, 0x2f, 0x5, 0x20, 0x3, 0x0, 0xa, 0x4f, 0x64, 0xd6, 0x25, 0x77, 0x87, - 0x33, 0x71, 0x7f, 0x96, 0x17, 0xa3, 0x1a, 0x0, 0x17, 0x2a, 0xde, 0xc8, 0x8e, 0xf4, 0xec, 0x71, 0x8c, 0x58, 0x35, - 0x9a, 0x27, 0xfb, 0x61, 0x2e, 0x56, 0x71, 0xb9, 0x3, 0xcc, 0x3d, 0xb2, 0xb2, 0x1f, 0x0, 0x14, 0xc8, 0x97, 0x17, - 0xc9, 0x27, 0xc4, 0x26, 0xdc, 0x1, 0x95, 0x2f, 0x8a, 0x76, 0x73, 0xf6, 0x1a, 0xee, 0xbf, 0x63, 0x19, 0x8, 0x0, - 0xf, 0x3c, 0xa8, 0x66, 0x86, 0xab, 0x53, 0x1c, 0xc4, 0x58, 0xa1, 0xfe, 0x4b, 0x69, 0x51, 0x4e, 0x19, 0xbb, 0x28, - 0xc9, 0x23, 0x2, 0x22, 0x2, 0x0, 0x0, 0xa, 0x3c, 0x2a, 0xc2, 0x22, 0x7e, 0xbc, 0x8, 0x0, 0x7, 0x80, 0x2a, - 0x87, 0xe2, 0x8f, 0x16, 0xfc, 0x25, 0xd, 0x26, 0x0, 0x6, 0xc, 0x89, 0x9b, 0x51, 0x14, 0x7, 0x0, 0xa, 0x74, - 0xf9, 0xe7, 0x72, 0x22, 0x8e, 0x9e, 0xfd, 0xc3, 0x9f, 0x1f, 0x0, 0x2, 0xe9, 0xaf, 0x2a, 0xa4, 0x2, 0x0, 0x0, - 0x54, 0x72, 0x2, 0x0, 0x0, 0x6f, 0xf3, 0x17, 0xa0, 0x2a, 0x6f, 0x19, 0xfe, 0x25, 0x67, 0x2, 0x0, 0x0, 0x2c, - 0x6b, 0x2, 0x0, 0x0, 0x42, 0xe8, 0x1f, 0x0, 0x7, 0x9, 0x70, 0x1c, 0x21, 0x41, 0xbc, 0xe6, 0x2, 0x0, 0x0, - 0x78, 0x97, 0x11, 0x0, 0x0, 0x3d, 0xa8, 0x8f, 0x83, 0x8f, 0x80, 0x83, 0x8f, 0x91}; +// UnsubscribeResponse 8446 [PropMessageExpiryInterval 32522,PropAuthenticationMethod "s",PropUserProperty +// "\245\156\167`\196U\134\160\246\204k\NUL\EOT={V\141\211\169\ENQ%" "V\184\146Ug",PropServerReference +// "#^xQ\179",PropCorrelationData "\191\fkMH\184\214%\217",PropResponseInformation +// "Q+h\134>Q\231B\185\242$F\180m~\205\183[A\178\216",PropMessageExpiryInterval 15326,PropServerReference +// "X?\CAN\\I\135!\210Q0\EM\134\246P"] +// [UnsubSuccess,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNoSubscriptionExisted] +TEST(UnsubACK5QCTest, Decode22) { + uint8_t pkt[] = {0xb0, 0x71, 0x20, 0xfe, 0x6a, 0x2, 0x0, 0x0, 0x7f, 0xa, 0x15, 0x0, 0x1, 0x73, 0x26, 0x0, 0x15, + 0xf5, 0x9c, 0xa7, 0x60, 0xc4, 0x55, 0x86, 0xa0, 0xf6, 0xcc, 0x6b, 0x0, 0x4, 0x3d, 0x7b, 0x56, 0x8d, + 0xd3, 0xa9, 0x5, 0x25, 0x0, 0x5, 0x56, 0xb8, 0x92, 0x55, 0x67, 0x1c, 0x0, 0x5, 0x23, 0x5e, 0x78, + 0x51, 0xb3, 0x9, 0x0, 0x9, 0xbf, 0xc, 0x6b, 0x4d, 0x48, 0xb8, 0xd6, 0x25, 0xd9, 0x1a, 0x0, 0x15, + 0x51, 0x2b, 0x68, 0x86, 0x3e, 0x51, 0xe7, 0x42, 0xb9, 0xf2, 0x24, 0x46, 0xb4, 0x6d, 0x7e, 0xcd, 0xb7, + 0x5b, 0x41, 0xb2, 0xd8, 0x2, 0x0, 0x0, 0x3b, 0xde, 0x1c, 0x0, 0xe, 0x58, 0x3f, 0x18, 0x5c, 0x49, + 0x87, 0x21, 0xd2, 0x51, 0x30, 0x19, 0x86, 0xf6, 0x50, 0x0, 0x83, 0x80, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[7]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 7, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[4]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 4583); - EXPECT_EQ(count, 7); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(packet_id, 8446); + EXPECT_EQ(count, 4); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); EXPECT_EQ(statuses[1], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); } -// UnsubscribeResponse 32708 [PropWildcardSubscriptionAvailable 111,PropUserProperty -// "\185\176\218\219]\209\190\&7\199\173\192\201\205\155\STX~\GS\149*\142\169\233\203\&8x" -// "\167F\201\189\159",PropAssignedClientIdentifier "\EM\251\155H\196|\152tN%\157h\CAN\FSC",PropMessageExpiryInterval -// 18180,PropCorrelationData "\206L\219\r\rrp\200:\SOH\153X\207\223\159\DC4\130",PropRequestProblemInformation -// 220,PropSubscriptionIdentifier 18,PropResponseInformation -// "wR\194\203\238\155\141\150Y\142\f\231\195\&5\186\234R&\132\ENQeh\186\253",PropResponseTopic -// "8e\180\131k",PropMessageExpiryInterval 20517,PropMessageExpiryInterval 7199,PropSubscriptionIdentifierAvailable -// 163,PropTopicAlias 15265,PropCorrelationData "2W\169ur\217IA\243\241\NULTW\188>\152\f",PropAssignedClientIdentifier -// ":\227\DC3\az\224\150R\200\157\232\251\189#\f\220r!\208\151Kl\165\f\226\202",PropServerKeepAlive -// 25586,PropContentType "",PropReceiveMaximum 26711,PropAuthenticationMethod -// "C+\205\245\&0,\214\188\&7\171\f02\137\174\255\NUL\169\196\bC",PropUserProperty -// "\238;\ESC\255\174=lTgYVu1\SYNb\171\235\202\140\&0" "\214g\134\187#@\150",PropResponseInformation -// "\233\211\208\156\FS0\FSlD",PropWillDelayInterval 29769,PropCorrelationData -// "\213\211`\tF\136\144\156/\251b\SYN\206\DEL\210\FS",PropTopicAliasMaximum 8182] -// [UnsubTopicFilterInvalid,UnsubSuccess] -TEST(UnsubACK5QCTest, Decode24) { - uint8_t pkt[] = { - 0xb0, 0xa5, 0x2, 0x7f, 0xc4, 0x9f, 0x2, 0x28, 0x6f, 0x26, 0x0, 0x19, 0xb9, 0xb0, 0xda, 0xdb, 0x5d, 0xd1, 0xbe, - 0x37, 0xc7, 0xad, 0xc0, 0xc9, 0xcd, 0x9b, 0x2, 0x7e, 0x1d, 0x95, 0x2a, 0x8e, 0xa9, 0xe9, 0xcb, 0x38, 0x78, 0x0, - 0x5, 0xa7, 0x46, 0xc9, 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d, 0x6c, 0x54, 0x67, 0x59, 0x56, 0x75, 0x31, 0x16, 0x62, 0xab, 0xeb, 0xca, 0x8c, 0x30, 0x0, - 0x7, 0xd6, 0x67, 0x86, 0xbb, 0x23, 0x40, 0x96, 0x1a, 0x0, 0x9, 0xe9, 0xd3, 0xd0, 0x9c, 0x1c, 0x30, 0x1c, 0x6c, - 0x44, 0x18, 0x0, 0x0, 0x74, 0x49, 0x9, 0x0, 0x10, 0xd5, 0xd3, 0x60, 0x9, 0x46, 0x88, 0x90, 0x9c, 0x2f, 0xfb, - 0x62, 0x16, 0xce, 0x7f, 0xd2, 0x1c, 0x22, 0x1f, 0xf6, 0x8f, 0x0}; +// UnsubscribeResponse 19980 [PropServerKeepAlive 7789] +// [UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubSuccess,UnsubUnspecifiedError,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubNotAuthorized,UnsubSuccess,UnsubPacketIdentifierInUse] +TEST(UnsubACK5QCTest, Decode23) { + uint8_t pkt[] = {0xb0, 0x16, 0x4e, 0xc, 0x3, 0x13, 0x1e, 0x6d, 0x87, 0x8f, 0x0, 0x80, + 0x11, 0x11, 0x80, 0x91, 0x0, 0x8f, 0x91, 0x83, 0x11, 0x87, 0x0, 0x91}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[2]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[16]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 16, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 32708); - EXPECT_EQ(count, 2); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(packet_id, 19980); + EXPECT_EQ(count, 16); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_PACKET_ID_IN_USE); } -// UnsubscribeResponse 21778 [] -// [UnsubUnspecifiedError,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized] -TEST(UnsubACK5QCTest, Decode25) { - uint8_t pkt[] = {0xb0, 0x16, 0x55, 0x12, 0x0, 0x80, 0x0, 0x91, 0x11, 0x80, 0x8f, 0x0, - 0x91, 0x80, 0x80, 0x91, 0x8f, 0x11, 0x11, 0x91, 0x11, 0x91, 0x0, 0x87}; +// UnsubscribeResponse 4987 [PropResponseTopic "\ETX>\159\&3z\223\DC1\244",PropTopicAliasMaximum 22200,PropMaximumQoS +// 94,PropServerKeepAlive 31146,PropSharedSubscriptionAvailable 134,PropSubscriptionIdentifierAvailable +// 68,PropCorrelationData "vn\151?d\169\174\205\ETX\n\237\190MkT\251",PropMaximumPacketSize +// 18578,PropSubscriptionIdentifier 27,PropRetainAvailable 254,PropMaximumQoS 196,PropServerReference +// "\168/\224%m\206\224/\128\&8R\139\175\197o^\146\249\SIV\137M\238",PropRequestProblemInformation +// 200,PropRequestResponseInformation 92,PropTopicAliasMaximum 29502,PropTopicAlias 68,PropTopicAlias +// 2438,PropWillDelayInterval 5635,PropWildcardSubscriptionAvailable 62,PropWillDelayInterval 20948] +// [UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubSuccess,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse] +TEST(UnsubACK5QCTest, Decode24) { + uint8_t pkt[] = {0xb0, 0x7e, 0x13, 0x7b, 0x68, 0x8, 0x0, 0x8, 0x3, 0x3e, 0x9f, 0x33, 0x7a, 0xdf, 0x11, 0xf4, + 0x22, 0x56, 0xb8, 0x24, 0x5e, 0x13, 0x79, 0xaa, 0x2a, 0x86, 0x29, 0x44, 0x9, 0x0, 0x10, 0x76, + 0x6e, 0x97, 0x3f, 0x64, 0xa9, 0xae, 0xcd, 0x3, 0xa, 0xed, 0xbe, 0x4d, 0x6b, 0x54, 0xfb, 0x27, + 0x0, 0x0, 0x48, 0x92, 0xb, 0x1b, 0x25, 0xfe, 0x24, 0xc4, 0x1c, 0x0, 0x17, 0xa8, 0x2f, 0xe0, + 0x25, 0x6d, 0xce, 0xe0, 0x2f, 0x80, 0x38, 0x52, 0x8b, 0xaf, 0xc5, 0x6f, 0x5e, 0x92, 0xf9, 0xf, + 0x56, 0x89, 0x4d, 0xee, 0x17, 0xc8, 0x19, 0x5c, 0x22, 0x73, 0x3e, 0x23, 0x0, 0x44, 0x23, 0x9, + 0x86, 0x18, 0x0, 0x0, 0x16, 0x3, 0x28, 0x3e, 0x18, 0x0, 0x0, 0x51, 0xd4, 0x87, 0x91, 0x80, + 0x0, 0x11, 0x8f, 0x80, 0x8f, 0x83, 0x8f, 0x0, 0x8f, 0x80, 0x83, 0x11, 0x83, 0x80, 0x8f, 0x91}; uint16_t packet_id; int count; lwmqtt_unsubscribe_status_t statuses[19]; lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 19, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 21778); + EXPECT_EQ(packet_id, 4987); EXPECT_EQ(count, 19); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); EXPECT_EQ(statuses[5], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_SUCCESS); EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NOT_AUTHORIZED); -} - -// UnsubscribeResponse 6986 [PropRequestProblemInformation 189,PropReceiveMaximum 4564,PropReasonString -// "\200Q\147\252D\149\227\180Z(_\182\DC4\162\143\134\DC1\247\RS2\241\186",PropWildcardSubscriptionAvailable -// 197,PropTopicAlias 26196,PropMaximumPacketSize 29545,PropSessionExpiryInterval 12864,PropMaximumPacketSize -// 12547,PropRequestResponseInformation 3,PropRequestResponseInformation 79,PropSharedSubscriptionAvailable -// 120,PropSessionExpiryInterval 997,PropSubscriptionIdentifierAvailable 157,PropContentType -// "Y\164\237\162\134\242B\244I\189\130,@R"] -// [UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubSuccess,UnsubNotAuthorized,UnsubNotAuthorized,UnsubPacketIdentifierInUse] -TEST(UnsubACK5QCTest, Decode26) { - uint8_t pkt[] = {0xb0, 0x6f, 0x1b, 0x4a, 0x50, 0x17, 0xbd, 0x21, 0x11, 0xd4, 0x1f, 0x0, 0x16, 0xc8, 0x51, 0x93, 0xfc, - 0x44, 0x95, 0xe3, 0xb4, 0x5a, 0x28, 0x5f, 0xb6, 0x14, 0xa2, 0x8f, 0x86, 0x11, 0xf7, 0x1e, 0x32, 0xf1, - 0xba, 0x28, 0xc5, 0x23, 0x66, 0x54, 0x27, 0x0, 0x0, 0x73, 0x69, 0x11, 0x0, 0x0, 0x32, 0x40, 0x27, - 0x0, 0x0, 0x31, 0x3, 0x19, 0x3, 0x19, 0x4f, 0x2a, 0x78, 0x11, 0x0, 0x0, 0x3, 0xe5, 0x29, 0x9d, - 0x3, 0x0, 0xe, 0x59, 0xa4, 0xed, 0xa2, 0x86, 0xf2, 0x42, 0xf4, 0x49, 0xbd, 0x82, 0x2c, 0x40, 0x52, - 0x83, 0x87, 0x80, 0x91, 0x0, 0x80, 0x83, 0x8f, 0x83, 0x8f, 0x8f, 0x83, 0x11, 0x80, 0x80, 0x87, 0x80, - 0x80, 0x8f, 0x11, 0x11, 0x80, 0x87, 0x83, 0x0, 0x87, 0x87, 0x91}; + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_PACKET_ID_IN_USE); +} + +// UnsubscribeResponse 13086 [PropResponseTopic "\215\158\193\237\189\FS\136\172v",PropContentType +// "\EM\191\156,1K\249\189\184\154\ESC\n\202n\STX<\EM{4\218\184\ACK\n-",PropServerKeepAlive 27576,PropCorrelationData +// "^\223\219\DC1\239\&2\251\&0\129pW$c}",PropPayloadFormatIndicator 245,PropReceiveMaximum 2551,PropServerKeepAlive +// 22651,PropWillDelayInterval 31428,PropMessageExpiryInterval 21262,PropSharedSubscriptionAvailable +// 130,PropAuthenticationMethod " \175\SOH\248H\253\192\EOT\RS\168|%",PropSubscriptionIdentifierAvailable +// 85,PropRequestResponseInformation 246,PropRequestResponseInformation 111,PropMaximumQoS 4,PropMessageExpiryInterval +// 13660,PropReceiveMaximum 3025,PropAuthenticationData "\146\146\&8\219\&5Z\244",PropTopicAliasMaximum +// 23621,PropMaximumPacketSize 30340] +// [UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubNotAuthorized,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubSuccess,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubSuccess,UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized,UnsubSuccess,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted] +TEST(UnsubACK5QCTest, Decode25) { + uint8_t pkt[] = {0xb0, 0xa2, 0x1, 0x33, 0x1e, 0x80, 0x1, 0x8, 0x0, 0x9, 0xd7, 0x9e, 0xc1, 0xed, 0xbd, 0x1c, 0x88, + 0xac, 0x76, 0x3, 0x0, 0x18, 0x19, 0xbf, 0x9c, 0x2c, 0x31, 0x4b, 0xf9, 0xbd, 0xb8, 0x9a, 0x1b, 0xa, + 0xca, 0x6e, 0x2, 0x3c, 0x19, 0x7b, 0x34, 0xda, 0xb8, 0x6, 0xa, 0x2d, 0x13, 0x6b, 0xb8, 0x9, 0x0, + 0xe, 0x5e, 0xdf, 0xdb, 0x11, 0xef, 0x32, 0xfb, 0x30, 0x81, 0x70, 0x57, 0x24, 0x63, 0x7d, 0x1, 0xf5, + 0x21, 0x9, 0xf7, 0x13, 0x58, 0x7b, 0x18, 0x0, 0x0, 0x7a, 0xc4, 0x2, 0x0, 0x0, 0x53, 0xe, 0x2a, + 0x82, 0x15, 0x0, 0xc, 0x20, 0xaf, 0x1, 0xf8, 0x48, 0xfd, 0xc0, 0x4, 0x1e, 0xa8, 0x7c, 0x25, 0x29, + 0x55, 0x19, 0xf6, 0x19, 0x6f, 0x24, 0x4, 0x2, 0x0, 0x0, 0x35, 0x5c, 0x21, 0xb, 0xd1, 0x16, 0x0, + 0x7, 0x92, 0x92, 0x38, 0xdb, 0x35, 0x5a, 0xf4, 0x22, 0x5c, 0x45, 0x27, 0x0, 0x0, 0x76, 0x84, 0x80, + 0x91, 0x91, 0x91, 0x11, 0x83, 0x87, 0x87, 0x0, 0x11, 0x8f, 0x0, 0x8f, 0x87, 0x11, 0x0, 0x0, 0x11, + 0x11, 0x0, 0x8f, 0x80, 0x91, 0x0, 0x87, 0x0, 0x83, 0x91, 0x8f, 0x11}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[28]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 28, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[30]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 30, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 6986); - EXPECT_EQ(count, 28); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(packet_id, 13086); + EXPECT_EQ(count, 30); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[15], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[17], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[18], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[19], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[20], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[21], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[22], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[23], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[24], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[25], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[26], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[27], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[28], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[29], LWMQTT_UNSUB_NO_SUB_EXISTED); +} + +// UnsubscribeResponse 16043 [PropRetainAvailable 148,PropAuthenticationData +// "\EM\144\139\238(\185g\156\220\183\188\&7\tK\ACK\184\ETX\t0\rB\203\157+\b\225\240\230`\SOH",PropReceiveMaximum +// 4793,PropRequestProblemInformation 137,PropCorrelationData "\218<\244\153\&8",PropMaximumQoS 97,PropContentType +// "\207*\DLE\RS\SYN\177\218G\155\249\169\150-,\150\237\ACK\134\169\&5L'D\142\139\226\ETX\206L",PropWillDelayInterval +// 23572,PropTopicAliasMaximum 11986,PropMessageExpiryInterval 10904,PropRetainAvailable 197,PropPayloadFormatIndicator +// 134,PropSessionExpiryInterval 25170,PropSessionExpiryInterval 31305,PropServerKeepAlive 4756,PropReasonString +// "\r\199F",PropServerKeepAlive 24387,PropRequestResponseInformation 107,PropSessionExpiryInterval +// 8036,PropReasonString "\238\159I%\147\195\150\&7\208iP|}\241\r\134\159\149\239",PropServerKeepAlive +// 7365,PropMessageExpiryInterval 23950,PropMaximumPacketSize 26632,PropReceiveMaximum 17416] +// [UnsubNoSubscriptionExisted,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubSuccess,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubTopicFilterInvalid] +TEST(UnsubACK5QCTest, Decode26) { + uint8_t pkt[] = {0xb0, 0xbd, 0x1, 0x3e, 0xab, 0xa6, 0x1, 0x25, 0x94, 0x16, 0x0, 0x1e, 0x19, 0x90, 0x8b, 0xee, + 0x28, 0xb9, 0x67, 0x9c, 0xdc, 0xb7, 0xbc, 0x37, 0x9, 0x4b, 0x6, 0xb8, 0x3, 0x9, 0x30, 0xd, + 0x42, 0xcb, 0x9d, 0x2b, 0x8, 0xe1, 0xf0, 0xe6, 0x60, 0x1, 0x21, 0x12, 0xb9, 0x17, 0x89, 0x9, + 0x0, 0x5, 0xda, 0x3c, 0xf4, 0x99, 0x38, 0x24, 0x61, 0x3, 0x0, 0x1d, 0xcf, 0x2a, 0x10, 0x1e, + 0x16, 0xb1, 0xda, 0x47, 0x9b, 0xf9, 0xa9, 0x96, 0x2d, 0x2c, 0x96, 0xed, 0x6, 0x86, 0xa9, 0x35, + 0x4c, 0x27, 0x44, 0x8e, 0x8b, 0xe2, 0x3, 0xce, 0x4c, 0x18, 0x0, 0x0, 0x5c, 0x14, 0x22, 0x2e, + 0xd2, 0x2, 0x0, 0x0, 0x2a, 0x98, 0x25, 0xc5, 0x1, 0x86, 0x11, 0x0, 0x0, 0x62, 0x52, 0x11, + 0x0, 0x0, 0x7a, 0x49, 0x13, 0x12, 0x94, 0x1f, 0x0, 0x3, 0xd, 0xc7, 0x46, 0x13, 0x5f, 0x43, + 0x19, 0x6b, 0x11, 0x0, 0x0, 0x1f, 0x64, 0x1f, 0x0, 0x13, 0xee, 0x9f, 0x49, 0x25, 0x93, 0xc3, + 0x96, 0x37, 0xd0, 0x69, 0x50, 0x7c, 0x7d, 0xf1, 0xd, 0x86, 0x9f, 0x95, 0xef, 0x13, 0x1c, 0xc5, + 0x2, 0x0, 0x0, 0x5d, 0x8e, 0x27, 0x0, 0x0, 0x68, 0x8, 0x21, 0x44, 0x8, 0x11, 0x11, 0x0, + 0x87, 0x91, 0x80, 0x0, 0x83, 0x83, 0x80, 0x87, 0x8f, 0x87, 0x8f, 0x91, 0x87, 0x87, 0x80, 0x8f}; + uint16_t packet_id; + int count; + lwmqtt_unsubscribe_status_t statuses[19]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 19, &count, statuses); + EXPECT_EQ(err, LWMQTT_SUCCESS); + EXPECT_EQ(packet_id, 16043); + EXPECT_EQ(count, 19); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NO_SUB_EXISTED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[5], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[9], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[11], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[12], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[13], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[14], LWMQTT_UNSUB_PACKET_ID_IN_USE); EXPECT_EQ(statuses[15], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[16], LWMQTT_UNSUB_NOT_AUTHORIZED); EXPECT_EQ(statuses[17], LWMQTT_UNSUB_UNSPECIFIED_ERROR); EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[25], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[26], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[27], LWMQTT_UNSUB_PACKET_ID_IN_USE); } -// UnsubscribeResponse 24965 [PropMessageExpiryInterval 29871,PropSubscriptionIdentifierAvailable -// 194,PropCorrelationData -// "u\\\213F=\213\184\153\198\244?0\RSD!KqF\STX\234\FS\190\205\141\223\169\199\162",PropRetainAvailable -// 13,PropTopicAlias 15476,PropSubscriptionIdentifierAvailable 222,PropTopicAliasMaximum 1264,PropResponseTopic -// "\ETX\142l",PropMaximumQoS 47,PropAssignedClientIdentifier -// "\239\156\192\248\234\145B:,G4\159",PropMessageExpiryInterval 21251,PropRequestProblemInformation 48,PropReasonString -// "T\165\196\b\147\229K(\253\248\STX\178\STX\167n\ENQ(\148\253\246d\175&",PropAuthenticationData "",PropResponseTopic -// "}",PropContentType "\b\157\&4\213(P3\232g\253`\139Y\131\168 \168\149M\151\192x\DEL\236\185\191X",PropReceiveMaximum -// 20584,PropPayloadFormatIndicator 168,PropMaximumPacketSize 272,PropAssignedClientIdentifier -// "\218\235",PropAuthenticationData "\163\241\200L\232\184c\ESC\152\FS\DC4b\224\&78L\v8\152\166m\169\226C\210rT\223"] -// [UnsubNotAuthorized,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubNotAuthorized,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubNoSubscriptionExisted,UnsubSuccess,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubUnspecifiedError,UnsubUnspecifiedError,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubSuccess] +// UnsubscribeResponse 31830 [PropWildcardSubscriptionAvailable 73,PropWillDelayInterval 6565,PropPayloadFormatIndicator +// 44,PropReasonString "s\NULj\140\255y1 +// \223\EM\ENQ\248\151\193b\165\130\189f\132\133\182\f\250\248\199\248",PropRequestResponseInformation +// 195,PropMaximumQoS 140,PropMaximumPacketSize 27932,PropResponseInformation +// "\203\154\234=\186\153\n\199\142\207\207\NUL\227~\184\219l+\149\128\166\138\238\185\ETB\218_",PropRequestResponseInformation +// 68,PropPayloadFormatIndicator 154] +// [UnsubUnspecifiedError,UnsubSuccess,UnsubTopicFilterInvalid,UnsubSuccess,UnsubSuccess,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid] TEST(UnsubACK5QCTest, Decode27) { - uint8_t pkt[] = {0xb0, 0xd8, 0x1, 0x61, 0x85, 0xbb, 0x1, 0x2, 0x0, 0x0, 0x74, 0xaf, 0x29, 0xc2, 0x9, 0x0, 0x1c, - 0x75, 0x5c, 0xd5, 0x46, 0x3d, 0xd5, 0xb8, 0x99,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f, 0x87, 0x8f, 0x87, 0x91, 0x8f, 0x0}; + uint8_t pkt[] = {0xb0, 0x5e, 0x7c, 0x56, 0x52, 0x28, 0x49, 0x18, 0x0, 0x0, 0x19, 0xa5, 0x1, 0x2c, 0x1f, 0x0, + 0x1b, 0x73, 0x0, 0x6a, 0x8c, 0xff, 0x79, 0x31, 0x20, 0xdf, 0x19, 0x5, 0xf8, 0x97, 0xc1, 0x62, + 0xa5, 0x82, 0xbd, 0x66, 0x84, 0x85, 0xb6, 0xc, 0xfa, 0xf8, 0xc7, 0xf8, 0x19, 0xc3, 0x24, 0x8c, + 0x27, 0x0, 0x0, 0x6d, 0x1c, 0x1a, 0x0, 0x1b, 0xcb, 0x9a, 0xea, 0x3d, 0xba, 0x99, 0xa, 0xc7, + 0x8e, 0xcf, 0xcf, 0x0, 0xe3, 0x7e, 0xb8, 0xdb, 0x6c, 0x2b, 0x95, 0x80, 0xa6, 0x8a, 0xee, 0xb9, + 0x17, 0xda, 0x5f, 0x19, 0x44, 0x1, 0x9a, 0x80, 0x0, 0x8f, 0x0, 0x0, 0x83, 0x83, 0x91, 0x8f}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[25]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 25, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[9]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 9, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 24965); - EXPECT_EQ(count, 25); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(packet_id, 31830); + EXPECT_EQ(count, 9); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_SUCCESS); -} - -// UnsubscribeResponse 17537 [PropTopicAlias 14320,PropRequestProblemInformation 21,PropAuthenticationMethod -// "a6\250\141\195\&6\154\rU'\157",PropReasonString "Y\RS\140\133\254",PropSharedSubscriptionAvailable -// 2,PropAuthenticationData "z\204\US\204$'C\SOH\SOH\243J;\171\252\220v\EM\189c\204\129\212^c\131\134 -// \SUB\137\SO",PropReceiveMaximum 30316,PropRequestResponseInformation 220,PropMaximumPacketSize -// 30012,PropServerReference -// "\150\&2\174\US\253\138\193\200\228\177\160\240\v\134\220^\179\215\164\217,\DC2\NAK\186\US",PropReceiveMaximum -// 9910,PropSubscriptionIdentifierAvailable 159,PropContentType -// "\219\DC4\199\137\170\191\255\188\245\RS6/0\254g/",PropRequestProblemInformation 175,PropMaximumQoS -// 45,PropResponseInformation -// "\145\195\&0\218\NAKgN\214\194P\149Z_\195\202\231vo2\161\221\200\223p",PropSubscriptionIdentifierAvailable -// 173,PropMaximumQoS 42,PropContentType -// "\168Q\230\245\220\ETX\177\136\211\209\175\156\248\240\245\151bV\137\\",PropPayloadFormatIndicator -// 83,PropSessionExpiryInterval 11017,PropUserProperty "\154\vvf\198\214DD\DEL" -// "\CANN\167\&1\241\247\203\196\174N3\145a(",PropSessionExpiryInterval 2353,PropReasonString "\200\DC1\t\148smt -// e9",PropCorrelationData "\DC2A",PropResponseInformation "\253\DEL;\160QD\234\DLE",PropUserProperty "\252P" -// "\206\179g\170)iw\DLE\219t\r\SUB\225\ACK"] -// [UnsubSuccess,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubNotAuthorized] + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[6], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[7], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[8], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); +} + +// UnsubscribeResponse 13530 [PropMaximumPacketSize 718,PropResponseTopic +// "u3\\\ETB\192\241.\143(@\\\130b\140$\154{G\226\145k\178\144\219",PropServerKeepAlive +// 16210,PropRequestResponseInformation 144,PropMessageExpiryInterval 16424,PropMaximumQoS 70,PropAuthenticationMethod +// "\181\239(=\202\149F\157\\\235:\171\180\153\206\t;\ETB\140{\150b\145\NUL\184\150",PropUserProperty +// "\172m\225vX\209\178\224F\246\213\r\193U'\177\138\SO\ETX\209" +// "\156\218\155\246O\SUB\190'\218\NAK\183E1",PropAuthenticationMethod +// "wK\174\203\215j\244,\178\b",PropAuthenticationData +// "\181\136.\150\141\138\141\248=\194\&6CXp\RS\205\\A\150TR\228\197",PropServerKeepAlive 27438,PropMaximumPacketSize +// 15377,PropRetainAvailable 155,PropReceiveMaximum 2324,PropMessageExpiryInterval 4393,PropSubscriptionIdentifier +// 24,PropSubscriptionIdentifier 11,PropContentType +// "\254-\181\b\188H\248\138G\201V#y\ETX\245\195\&4.\132\USP\249\133u\172\162\EOT\200D",PropUserProperty +// "j\SUB\160\131\190\138\151\140Y3" "\182\ESC\SUB\192",PropUserProperty +// "\151c\169L?Cj\213*@]\247;\ESC>\223\164\DLE\142\\\143\252\EM\212\216A\130#\197\193" +// "\STX\EOT\241",PropCorrelationData "\135f\186\168\138",PropMaximumPacketSize +// 29512,PropSubscriptionIdentifierAvailable 88,PropResponseTopic "\GS",PropMessageExpiryInterval 28440] +// [UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNotAuthorized] TEST(UnsubACK5QCTest, Decode28) { uint8_t pkt[] = { - 0xb0, 0x98, 0x2, 0x44, 0x81, 0x90, 0x2, 0x23, 0x37, 0xf0, 0x17, 0x15, 0x15, 0x0, 0xb, 0x61, 0x36, 0xfa, 0x8d, -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 0x87}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[4]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 4, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[6]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 6, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 17537); - EXPECT_EQ(count, 4); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_SUCCESS); + EXPECT_EQ(packet_id, 13530); + EXPECT_EQ(count, 6); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); EXPECT_EQ(statuses[1], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_NOT_AUTHORIZED); + EXPECT_EQ(statuses[2], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); + EXPECT_EQ(statuses[3], LWMQTT_UNSUB_UNSPECIFIED_ERROR); + EXPECT_EQ(statuses[4], LWMQTT_UNSUB_PACKET_ID_IN_USE); + EXPECT_EQ(statuses[5], LWMQTT_UNSUB_NOT_AUTHORIZED); } -// UnsubscribeResponse 11936 [PropCorrelationData "B",PropSharedSubscriptionAvailable 187,PropServerKeepAlive -// 22544,PropMessageExpiryInterval 414,PropSessionExpiryInterval 2745,PropSharedSubscriptionAvailable -// 134,PropServerReference "u\145d\221D\224e\183\219\233\224\182\206k:J\FSb\CAN6\v5\153\163]&",PropReasonString -// "8\174\170",PropMaximumQoS 85,PropContentType "\202\202M$\212\218\241\r\224Z\169\b\130\233.",PropResponseInformation -// "#G\174\SUB\r\188\170\233\238\SUB4\218J|\244\250\208\USq",PropRequestProblemInformation -// 175,PropPayloadFormatIndicator 249,PropAuthenticationMethod -// "^\186\229\214\170\CANo\230v\FS\203\134e\239\130\217\141\SYN\186Mud",PropMessageExpiryInterval -// 24407,PropWildcardSubscriptionAvailable 241,PropServerReference "S7j%\153@",PropWildcardSubscriptionAvailable -// 213,PropWildcardSubscriptionAvailable 79,PropSharedSubscriptionAvailable 250,PropSubscriptionIdentifier -// 24,PropSubscriptionIdentifier 6,PropSubscriptionIdentifier 17] -// [UnsubPacketIdentifierInUse,UnsubSuccess,UnsubTopicFilterInvalid,UnsubSuccess,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubTopicFilterInvalid,UnsubNotAuthorized,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubUnspecifiedError,UnsubPacketIdentifierInUse,UnsubImplementationSpecificError,UnsubSuccess,UnsubNotAuthorized,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubTopicFilterInvalid,UnsubNoSubscriptionExisted,UnsubTopicFilterInvalid,UnsubNotAuthorized] +// UnsubscribeResponse 29514 [PropMaximumPacketSize 14670,PropServerKeepAlive 4681,PropAuthenticationData +// "\255'\197\248\171\136t\197\204\188\US",PropReceiveMaximum 24642,PropReasonString "y\136\DC1\209",PropResponseTopic +// "F\206\166.1\196",PropRequestProblemInformation 35,PropMessageExpiryInterval 2812,PropTopicAlias +// 27219,PropMaximumPacketSize 29246] [UnsubTopicFilterInvalid,UnsubTopicFilterInvalid] TEST(UnsubACK5QCTest, Decode29) { - uint8_t pkt[] = { - 0xb0, 0xb9, 0x1, 0x2e, 0xa0, 0x9b, 0x1, 0x9, 0x0, 0x1, 0x42, 0x2a, 0xbb, 0x13, 0x58, 0x10, 0x2, 0x0, 0x0, - 0x1, 0x9e, 0x11, 0x0, 0x0, 0xa, 0xb9, 0x2a, 0x86, 0x1c, 0x0, 0x1a, 0x75, 0x91, 0x64, 0xdd, 0x44, 0xe0, 0x65, - 0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d1, 0x8, 0x0, 0x6, 0x46, 0xce, 0xa6, 0x2e, 0x31, 0xc4, 0x17, 0x23, + 0x2, 0x0, 0x0, 0xa, 0xfc, 0x23, 0x6a, 0x53, 0x27, 0x0, 0x0, 0x72, 0x3e, 0x8f, 0x8f}; uint16_t packet_id; int count; - lwmqtt_unsubscribe_status_t statuses[26]; - lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 26, &count, statuses); + lwmqtt_unsubscribe_status_t statuses[2]; + lwmqtt_err_t err = lwmqtt_decode_unsuback(pkt, sizeof(pkt), &packet_id, LWMQTT_MQTT5, 2, &count, statuses); EXPECT_EQ(err, LWMQTT_SUCCESS); - EXPECT_EQ(packet_id, 11936); - EXPECT_EQ(count, 26); - EXPECT_EQ(statuses[0], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[1], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[2], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[3], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[4], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[5], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[6], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[7], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[8], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[9], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[10], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[11], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[12], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[13], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[14], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[15], LWMQTT_UNSUB_UNSPECIFIED_ERROR); - EXPECT_EQ(statuses[16], LWMQTT_UNSUB_PACKET_ID_IN_USE); - EXPECT_EQ(statuses[17], LWMQTT_UNSUB_IMPL_SPECIFIC_ERROR); - EXPECT_EQ(statuses[18], LWMQTT_UNSUB_SUCCESS); - EXPECT_EQ(statuses[19], LWMQTT_UNSUB_NOT_AUTHORIZED); - EXPECT_EQ(statuses[20], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[21], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[22], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[23], LWMQTT_UNSUB_NO_SUB_EXISTED); - EXPECT_EQ(statuses[24], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); - EXPECT_EQ(statuses[25], LWMQTT_UNSUB_NOT_AUTHORIZED); -} - -// UnsubscribeResponse 14068 [PropWildcardSubscriptionAvailable 58,PropUserProperty -// "\224\135\171x6\149\203\184f\174G\246\172b\ESC\232\225\215'\144\163\143n" -// "\DC4\186\238\ENQ\182\&3\SUB\235\167\137eb\140;\242",PropMessageExpiryInterval 472,PropWillDelayInterval -// 28858,PropSubscriptionIdentifierAvailable 233,PropUserProperty "\210\199Z\188;x\139\147" "1",PropAuthenticationMethod -// "\248\136\SUB\FS\aO-\165\253\ENQ",PropAuthenticationData -// "\147\149<_\232FZ\186\177\EM\226\144\252\196\222\\\160r\"\231",PropCorrelationData -// ")w\135)\167\154\205\246\DLE",PropRequestResponseInformation 18,PropSubscriptionIdentifierAvailable -// 203,PropRequestResponseInformation 160,PropAuthenticationMethod "^B\213,8\252\SI\217\236-'x",PropResponseTopic -// "\131\244",PropWildcardSubscriptionAvailable 245] -// [UnsubImplementationSpecificError,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubPacketIdentifierInUse,UnsubNoSubscriptionExisted,UnsubPacketIdentifierInUse,UnsubNotAuthorized,UnsubImplementationSpecificError,UnsubImplementationSpecificError,UnsubSuccess,UnsubUnspecifiedError,UnsubSuccess,UnsubTopicFilterInvalid,UnsubPacketIdentifierInUse,UnsubSuccess,UnsubNotAuthorized] + EXPECT_EQ(packet_id, 29514); + EXPECT_EQ(count, 2); + EXPECT_EQ(statuses[0], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); + EXPECT_EQ(statuses[1], LWMQTT_UNSUB_TOPIC_FILTER_INVALID); +} + +// UnsubscribeResponse 14096 [PropUserProperty "\246\130\240" "H\170Co\215\187hU",PropWildcardSubscriptionAvailable +// 186,PropAssignedClientIdentifier "\150\ACK\EOT\237\193\ETX=\228$\f\214\220\131G\194\200",PropAuthenticationMethod +// ">\153\226\190%\SUB\244\241d?\174\201Uq\187\SUB",PropWildcardSubscriptionAvailable 41,PropWillDelayInterval +// 233,PropAssignedClientIdentifier +// "PRt\DELe\149|\DC3\234\134h\157a\137\182\147\209\215\216Z\\\199\209\n\DEL",PropServerKeepAlive -// 20200,PropPayloadFormatIndicator 73,PropAssignedClientIdentifier -// "D",PropResponseInformation "\246\179M\US\164\214\214\236 +// \203\133e\242\158\139\137\226\170/Z\240>)dp\DEL\225\SOH\204",PropSubscriptionIdentifier 0,PropMessageExpiryInterval +// 16776,PropRetainAvailable 158,PropRequestProblemInformation 157,PropMessageExpiryInterval 3249,PropResponseTopic +// "\SO\nB\198\245\198h}\164\202\255\201\NAK\177\180\211\216c\CANdM\133\170\192b",PropAuthenticationMethod +// "#j\ETB6&\180\207\168S\209\254\192.Cp\214Y\164\241\246\173y\222[",PropSessionExpiryInterval 8286,PropTopicAlias +// 27011,PropMessageExpiryInterval 13397,PropSubscriptionIdentifier 16,PropCorrelationData +// "\214\173\ETB%\204\&3i]%\205\DC4\134\&6`\129\DC1\132U\169",PropCorrelationData +// "\SI2Uk\SI,\227\STX\204]\DLE5\193\&5\174\133\151a\186",PropReasonString +// "v=\211\US\162\223\&1\215\SUB\233\FS",PropRetainAvailable 127,PropReasonString +// "I\196B\213\190p\DC1\205\153\NAKa\219q",PropMaximumQoS 8,PropTopicAliasMaximum 14250] TEST(Disco5QCTest, Encode13) { - uint8_t pkt[] = {0xe0, 0x39, 0x80, 0x37, 0x16, 0x0, 0x5, 0xb8, 0xa3, 0x39, 0xc6, 0x9c, 0x22, 0x4, 0xce, - 0xb, 0xd, 0x19, 0xfd, 0x26, 0x0, 0x1d, 0x4a, 0x2c, 0x94, 0xf7, 0xcd, 0x5f, 0xa3, 0x6e, - 0x1e, 0x8e, 0xc, 0x1a, 0x73, 0x31, 0xa4, 0xc1, 0x5e, 0x30, 0xa2, 0x88, 0x7a, 0x5d, 0x17, - 0xa7, 0x4f, 0x2b, 0xc, 0x39, 0xa, 0x0, 0x1, 0xb1, 0x27, 0x0, 0x0, 0x11, 0x4a}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xb8, 0xa3, 0x39, 0xc6, 0x9c}; - uint8_t bytesprops2[] = {0xb1}; - uint8_t bytesprops1[] = {0x4a, 0x2c, 0x94, 0xf7, 0xcd, 0x5f, 0xa3, 0x6e, 0x1e, 0x8e, 0xc, 0x1a, 0x73, 0x31, 0xa4, - 0xc1, 0x5e, 0x30, 0xa2, 0x88, 0x7a, 0x5d, 0x17, 0xa7, 0x4f, 0x2b, 0xc, 0x39, 0xa}; + uint8_t pkt[] = { + 0xe0, 0xf2, 0x1, 0x83, 0xef, 0x1, 0x29, 0xca, 0x1a, 0x0, 0x9, 0x92, 0x7b, 0x3f, 0xc2, 0x8f, 0x62, 0xa1, 0x5b, + 0x40, 0x9, 0x0, 0x2, 0xe6, 0x3c, 0x2, 0x0, 0x0, 0x6e, 0x2b, 0x15, 0x0, 0xd, 0xb3, 0x5a, 0x74, 0x1, 0x22, + 0x8, 0xb7, 0xb9, 0x73, 0xe0, 0x11, 0xa2, 0x3e, 0x1a, 0x0, 0x1d, 0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, 0x61, 0xdb, 0x71, 0x24, 0x8, 0x22, 0x37, 0xaa}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x92, 0x7b, 0x3f, 0xc2, 0x8f, 0x62, 0xa1, 0x5b, 0x40}; + uint8_t bytesprops1[] = {0xe6, 0x3c}; + uint8_t bytesprops2[] = {0xb3, 0x5a, 0x74, 0x1, 0x22, 0x8, 0xb7, 0xb9, 0x73, 0xe0, 0x11, 0xa2, 0x3e}; + uint8_t bytesprops3[] = {0xf6, 0xb3, 0x4d, 0x1f, 0xa4, 0xd6, 0xd6, 0xec, 0x20, 0xcb, 0x85, 0x65, 0xf2, 0x9e, 0x8b, + 0x89, 0xe2, 0xaa, 0x2f, 0x5a, 0xf0, 0x3e, 0x29, 0x64, 0x70, 0x7f, 0xe1, 0x1, 0xcc}; + uint8_t bytesprops4[] = {0xe, 0xa, 0x42, 0xc6, 0xf5, 0xc6, 0x68, 0x7d, 0xa4, 0xca, 0xff, 0xc9, 0x15, + 0xb1, 0xb4, 0xd3, 0xd8, 0x63, 0x18, 0x64, 0x4d, 0x85, 0xaa, 0xc0, 0x62}; + uint8_t bytesprops5[] = {0x23, 0x6a, 0x17, 0x36, 0x26, 0xb4, 0xcf, 0xa8, 0x53, 0xd1, 0xfe, 0xc0, + 0x2e, 0x43, 0x70, 0xd6, 0x59, 0xa4, 0xf1, 0xf6, 0xad, 0x79, 0xde, 0x5b}; + uint8_t bytesprops6[] = {0xd6, 0xad, 0x17, 0x25, 0xcc, 0x33, 0x69, 0x5d, 0x25, 0xcd, + 0x14, 0x86, 0x36, 0x60, 0x81, 0x11, 0x84, 0x55, 0xa9}; + uint8_t bytesprops7[] = {0xf, 0x32, 0x55, 0x6b, 0xf, 0x2c, 0xe3, 0x2, 0xcc, 0x5d, + 0x10, 0x35, 0xc1, 0x35, 0xae, 0x85, 0x97, 0x61, 0xba}; + uint8_t bytesprops8[] = {0x76, 0x3d, 0xd3, 0x1f, 0xa2, 0xdf, 0x31, 0xd7, 0x1a, 0xe9, 0x1c}; + uint8_t bytesprops9[] = {0x49, 0xc4, 0x42, 0xd5, 0xbe, 0x70, 0x11, 0xcd, 0x99, 0x15, 0x61, 0xdb, 0x71}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 1230}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 253}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops1}, .v = {1, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 4426}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 202}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {9, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 28203}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16776}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 158}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 157}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3249}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {25, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {24, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8286}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27011}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13397}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {19, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {11, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {13, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 14250}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 128, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 131, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoQoSNotSupported [PropServerReference -// "/\157\185n\153\237+P\242\147\140\182N\230|\182\DC2\255\232|_",PropMaximumPacketSize 14512,PropRetainAvailable -// 230,PropSubscriptionIdentifierAvailable 22,PropTopicAliasMaximum 7486,PropAuthenticationData -// "dr\239h\137",PropPayloadFormatIndicator 144,PropRequestResponseInformation 202,PropWillDelayInterval 18416] +// DisconnectRequest DiscoDisconnectWithWill [PropUserProperty "\146\161i\179\130J" +// "\177B",PropWildcardSubscriptionAvailable 138,PropRequestProblemInformation 216,PropTopicAlias +// 29685,PropSubscriptionIdentifier 15,PropAssignedClientIdentifier +// "\200\209\130\SO\184\RSk\184\235*T\197\216\149x\a\182\157\159\192\CAN.\ETBS\129t\250\DC30]",PropRetainAvailable +// 193,PropSubscriptionIdentifier 27,PropPayloadFormatIndicator 191,PropAuthenticationData +// "\253\206]\201\159\&5%\155\221\164\187\236'\179\182\212~",PropServerReference "\240\EM\184\230",PropMaximumQoS +// 14,PropRetainAvailable 127,PropMessageExpiryInterval 11452,PropResponseTopic +// "\135|\\y/\224\&6\168\156\153\SO\149",PropSubscriptionIdentifier 5,PropWildcardSubscriptionAvailable +// 84,PropMaximumQoS 177,PropUserProperty "\GS\232\ACKS\241\202\203\212\&4F\241\SYNIN\204\226\183\136 +// 4\233\ESC\187-[\211\204\128\248" "\201|6B,\237\DLE\DC2\DEL\249p\SI\b\215\224\248\154\210ry\249vrB\180\ACK\244U"] TEST(Disco5QCTest, Encode14) { - uint8_t pkt[] = {0xe0, 0x37, 0x9b, 0x35, 0x1c, 0x0, 0x15, 0x2f, 0x9d, 0xb9, 0x6e, 0x99, 0xed, 0x2b, 0x50, - 0xf2, 0x93, 0x8c, 0xb6, 0x4e, 0xe6, 0x7c, 0xb6, 0x12, 0xff, 0xe8, 0x7c, 0x5f, 0x27, 0x0, - 0x0, 0x38, 0xb0, 0x25, 0xe6, 0x29, 0x16, 0x22, 0x1d, 0x3e, 0x16, 0x0, 0x5, 0x64, 0x72, - 0xef, 0x68, 0x89, 0x1, 0x90, 0x19, 0xca, 0x18, 0x0, 0x0, 0x47, 0xf0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x2f, 0x9d, 0xb9, 0x6e, 0x99, 0xed, 0x2b, 0x50, 0xf2, 0x93, 0x8c, - 0xb6, 0x4e, 0xe6, 0x7c, 0xb6, 0x12, 0xff, 0xe8, 0x7c, 0x5f}; - uint8_t bytesprops1[] = {0x64, 0x72, 0xef, 0x68, 0x89}; + uint8_t pkt[] = {0xe0, 0xb7, 0x1, 0x4, 0xb4, 0x1, 0x26, 0x0, 0x6, 0x92, 0xa1, 0x69, 0xb3, 0x82, 0x4a, 0x0, 0x2, + 0xb1, 0x42, 0x28, 0x8a, 0x17, 0xd8, 0x23, 0x73, 0xf5, 0xb, 0xf, 0x12, 0x0, 0x1e, 0xc8, 0xd1, 0x82, + 0xe, 0xb8, 0x1e, 0x6b, 0xb8, 0xeb, 0x2a, 0x54, 0xc5, 0xd8, 0x95, 0x78, 0x7, 0xb6, 0x9d, 0x9f, 0xc0, + 0x18, 0x2e, 0x17, 0x53, 0x81, 0x74, 0xfa, 0x13, 0x30, 0x5d, 0x25, 0xc1, 0xb, 0x1b, 0x1, 0xbf, 0x16, + 0x0, 0x11, 0xfd, 0xce, 0x5d, 0xc9, 0x9f, 0x35, 0x25, 0x9b, 0xdd, 0xa4, 0xbb, 0xec, 0x27, 0xb3, 0xb6, + 0xd4, 0x7e, 0x1c, 0x0, 0x4, 0xf0, 0x19, 0xb8, 0xe6, 0x24, 0xe, 0x25, 0x7f, 0x2, 0x0, 0x0, 0x2c, + 0xbc, 0x8, 0x0, 0xc, 0x87, 0x7c, 0x5c, 0x79, 0x2f, 0xe0, 0x36, 0xa8, 0x9c, 0x99, 0xe, 0x95, 0xb, + 0x5, 0x28, 0x54, 0x24, 0xb1, 0x26, 0x0, 0x1d, 0x1d, 0xe8, 0x6, 0x53, 0xf1, 0xca, 0xcb, 0xd4, 0x34, + 0x46, 0xf1, 0x16, 0x49, 0x4e, 0xcc, 0xe2, 0xb7, 0x88, 0x20, 0x34, 0xe9, 0x1b, 0xbb, 0x2d, 0x5b, 0xd3, + 0xcc, 0x80, 0xf8, 0x0, 0x1c, 0xc9, 0x7c, 0x36, 0x42, 0x2c, 0xed, 0x10, 0x12, 0x7f, 0xf9, 0x70, 0xf, + 0x8, 0xd7, 0xe0, 0xf8, 0x9a, 0xd2, 0x72, 0x79, 0xf9, 0x76, 0x72, 0x42, 0xb4, 0x6, 0xf4, 0x55}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops1[] = {0xb1, 0x42}; + uint8_t bytesprops0[] = {0x92, 0xa1, 0x69, 0xb3, 0x82, 0x4a}; + uint8_t bytesprops2[] = {0xc8, 0xd1, 0x82, 0xe, 0xb8, 0x1e, 0x6b, 0xb8, 0xeb, 0x2a, 0x54, 0xc5, 0xd8, 0x95, 0x78, + 0x7, 0xb6, 0x9d, 0x9f, 0xc0, 0x18, 0x2e, 0x17, 0x53, 0x81, 0x74, 0xfa, 0x13, 0x30, 0x5d}; + uint8_t bytesprops3[] = {0xfd, 0xce, 0x5d, 0xc9, 0x9f, 0x35, 0x25, 0x9b, 0xdd, + 0xa4, 0xbb, 0xec, 0x27, 0xb3, 0xb6, 0xd4, 0x7e}; + uint8_t bytesprops4[] = {0xf0, 0x19, 0xb8, 0xe6}; + uint8_t bytesprops5[] = {0x87, 0x7c, 0x5c, 0x79, 0x2f, 0xe0, 0x36, 0xa8, 0x9c, 0x99, 0xe, 0x95}; + uint8_t bytesprops7[] = {0xc9, 0x7c, 0x36, 0x42, 0x2c, 0xed, 0x10, 0x12, 0x7f, 0xf9, 0x70, 0xf, 0x8, 0xd7, + 0xe0, 0xf8, 0x9a, 0xd2, 0x72, 0x79, 0xf9, 0x76, 0x72, 0x42, 0xb4, 0x6, 0xf4, 0x55}; + uint8_t bytesprops6[] = {0x1d, 0xe8, 0x6, 0x53, 0xf1, 0xca, 0xcb, 0xd4, 0x34, 0x46, 0xf1, 0x16, 0x49, 0x4e, 0xcc, + 0xe2, 0xb7, 0x88, 0x20, 0x34, 0xe9, 0x1b, 0xbb, 0x2d, 0x5b, 0xd3, 0xcc, 0x80, 0xf8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14512}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 22}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 7486}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {5, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 202}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 18416}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {2, (char*)&bytesprops1}}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 138}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 216}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 29685}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {30, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 193}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 27}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 191}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {4, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 14}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 127}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 11452}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {12, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 84}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 177}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {29, (char*)&bytesprops6}, .v = {28, (char*)&bytesprops7}}}}, }; - lwmqtt_properties_t props = {9, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoSharedSubscriptionsNotSupported [PropAuthenticationData "|\157"] +// DisconnectRequest DiscoMaximumConnectTime [PropMessageExpiryInterval 21495,PropRetainAvailable +// 1,PropMessageExpiryInterval 193,PropCorrelationData "",PropServerKeepAlive 6609,PropSessionExpiryInterval +// 3824,PropCorrelationData "\132\&7F\167\136",PropTopicAlias 676,PropServerKeepAlive 6121,PropMessageExpiryInterval +// 9093] TEST(Disco5QCTest, Encode15) { - uint8_t pkt[] = {0xe0, 0x7, 0x9e, 0x5, 0x16, 0x0, 0x2, 0x7c, 0x9d}; + uint8_t pkt[] = {0xe0, 0x2c, 0xa0, 0x2a, 0x2, 0x0, 0x0, 0x53, 0xf7, 0x25, 0x1, 0x2, 0x0, 0x0, 0x0, 0xc1, + 0x9, 0x0, 0x0, 0x13, 0x19, 0xd1, 0x11, 0x0, 0x0, 0xe, 0xf0, 0x9, 0x0, 0x5, 0x84, 0x37, + 0x46, 0xa7, 0x88, 0x23, 0x2, 0xa4, 0x13, 0x17, 0xe9, 0x2, 0x0, 0x0, 0x23, 0x85}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7c, 0x9d}; + uint8_t bytesprops0[] = {0}; + uint8_t bytesprops1[] = {0x84, 0x37, 0x46, 0xa7, 0x88}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)22, .value = {.str = {2, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21495}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 1}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 193}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {0, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6609}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 3824}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 676}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6121}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9093}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {10, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 158, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 160, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoAdministrativeAction [PropRetainAvailable 93,PropTopicAliasMaximum -// 19459,PropSubscriptionIdentifier 1,PropReceiveMaximum 12710,PropAuthenticationMethod -// "\237\243F]\241",PropResponseTopic "\161\CAN\208\226w\182\253\159\&2n\135-\134",PropMessageExpiryInterval -// 13088,PropResponseTopic -// "\250\193\139\252\227$bm\SUB?\STX\ESC\254\237I\216w\213\DEL\241\244\195\US",PropWillDelayInterval -// 957,PropCorrelationData -// "\128\DC4M^\157\159\128'\129\251\253\217\226\255\198m\170z\NUL\222\165{\170^\r\229",PropSessionExpiryInterval -// 4548,PropMessageExpiryInterval 18197,PropTopicAlias 25384,PropSharedSubscriptionAvailable -// 239,PropAuthenticationMethod "+ad\r%\174\DEL\175|#\203\219\247\STX\ACK\ETB\224\139",PropSessionExpiryInterval -// 15062,PropSubscriptionIdentifierAvailable 89,PropTopicAlias 30222,PropAssignedClientIdentifier -// "3@\212\233\STX\244o\254\ETX\239\129",PropPayloadFormatIndicator 147,PropSubscriptionIdentifier -// 23,PropSubscriptionIdentifierAvailable 166,PropAssignedClientIdentifier -// "\179\205\229[\197IGa\220\146Fi\174C\180]ub\161\CANr\158\&7#\182\157Of"] +// DisconnectRequest DiscoNotAuthorized [PropSubscriptionIdentifier 2,PropRequestResponseInformation 76,PropContentType +// " -\204y\165v(a\232\NAK\148\SI|e}E",PropTopicAliasMaximum 22692,PropCorrelationData +// "o\164\134|^\154\175\SOH\178\244Zx\SOs\128`[\SYN",PropSessionExpiryInterval 5279,PropSessionExpiryInterval 6600] TEST(Disco5QCTest, Encode16) { - uint8_t pkt[] = {0xe0, 0xc7, 0x1, 0x98, 0xc4, 0x1, 0x25, 0x5d, 0x22, 0x4c, 0x3, 0xb, 0x1, 0x21, 0x31, 0xa6, 0x15, - 0x0, 0x5, 0xed, 0xf3, 0x46, 0x5d, 0xf1, 0x8, 0x0, 0xd, 0xa1, 0x18, 0xd0, 0xe2, 0x77, 0xb6, 0xfd, - 0x9f, 0x32, 0x6e, 0x87, 0x2d, 0x86, 0x2, 0x0, 0x0, 0x33, 0x20, 0x8, 0x0, 0x17, 0xfa, 0xc1, 0x8b, - 0xfc, 0xe3, 0x24, 0x62, 0x6d, 0x1a, 0x3f, 0x2, 0x1b, 0xfe, 0xed, 0x49, 0xd8, 0x77, 0xd5, 0x7f, 0xf1, - 0xf4, 0xc3, 0x1f, 0x18, 0x0, 0x0, 0x3, 0xbd, 0x9, 0x0, 0x1a, 0x80, 0x14, 0x4d, 0x5e, 0x9d, 0x9f, - 0x80, 0x27, 0x81, 0xfb, 0xfd, 0xd9, 0xe2, 0xff, 0xc6, 0x6d, 0xaa, 0x7a, 0x0, 0xde, 0xa5, 0x7b, 0xaa, - 0x5e, 0xd, 0xe5, 0x11, 0x0, 0x0, 0x11, 0xc4, 0x2, 0x0, 0x0, 0x47, 0x15, 0x23, 0x63, 0x28, 0x2a, - 0xef, 0x15, 0x0, 0x12, 0x2b, 0x61, 0x64, 0xd, 0x25, 0xae, 0x7f, 0xaf, 0x7c, 0x23, 0xcb, 0xdb, 0xf7, - 0x2, 0x6, 0x17, 0xe0, 0x8b, 0x11, 0x0, 0x0, 0x3a, 0xd6, 0x29, 0x59, 0x23, 0x76, 0xe, 0x12, 0x0, - 0xb, 0x33, 0x40, 0xd4, 0xe9, 0x2, 0xf4, 0x6f, 0xfe, 0x3, 0xef, 0x81, 0x1, 0x93, 0xb, 0x17, 0x29, - 0xa6, 0x12, 0x0, 0x1c, 0xb3, 0xcd, 0xe5, 0x5b, 0xc5, 0x49, 0x47, 0x61, 0xdc, 0x92, 0x46, 0x69, 0xae, - 0x43, 0xb4, 0x5d, 0x75, 0x62, 0xa1, 0x18, 0x72, 0x9e, 0x37, 0x23, 0xb6, 0x9d, 0x4f, 0x66}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0xed, 0xf3, 0x46, 0x5d, 0xf1}; - uint8_t bytesprops1[] = {0xa1, 0x18, 0xd0, 0xe2, 0x77, 0xb6, 0xfd, 0x9f, 0x32, 0x6e, 0x87, 0x2d, 0x86}; - uint8_t bytesprops2[] = {0xfa, 0xc1, 0x8b, 0xfc, 0xe3, 0x24, 0x62, 0x6d, 0x1a, 0x3f, 0x2, 0x1b, - 0xfe, 0xed, 0x49, 0xd8, 0x77, 0xd5, 0x7f, 0xf1, 0xf4, 0xc3, 0x1f}; - uint8_t bytesprops3[] = {0x80, 0x14, 0x4d, 0x5e, 0x9d, 0x9f, 0x80, 0x27, 0x81, 0xfb, 0xfd, 0xd9, 0xe2, - 0xff, 0xc6, 0x6d, 0xaa, 0x7a, 0x0, 0xde, 0xa5, 0x7b, 0xaa, 0x5e, 0xd, 0xe5}; - uint8_t bytesprops4[] = {0x2b, 0x61, 0x64, 0xd, 0x25, 0xae, 0x7f, 0xaf, 0x7c, - 0x23, 0xcb, 0xdb, 0xf7, 0x2, 0x6, 0x17, 0xe0, 0x8b}; - uint8_t bytesprops5[] = {0x33, 0x40, 0xd4, 0xe9, 0x2, 0xf4, 0x6f, 0xfe, 0x3, 0xef, 0x81}; - uint8_t bytesprops6[] = {0xb3, 0xcd, 0xe5, 0x5b, 0xc5, 0x49, 0x47, 0x61, 0xdc, 0x92, 0x46, 0x69, 0xae, 0x43, - 0xb4, 0x5d, 0x75, 0x62, 0xa1, 0x18, 0x72, 0x9e, 0x37, 0x23, 0xb6, 0x9d, 0x4f, 0x66}; + uint8_t pkt[] = {0xe0, 0x3b, 0x87, 0x39, 0xb, 0x2, 0x19, 0x4c, 0x3, 0x0, 0x10, 0x20, 0x2d, 0xcc, 0x79, 0xa5, + 0x76, 0x28, 0x61, 0xe8, 0x15, 0x94, 0xf, 0x7c, 0x65, 0x7d, 0x45, 0x22, 0x58, 0xa4, 0x9, 0x0, + 0x12, 0x6f, 0xa4, 0x86, 0x7c, 0x5e, 0x9a, 0xaf, 0x1, 0xb2, 0xf4, 0x5a, 0x78, 0xe, 0x73, 0x80, + 0x60, 0x5b, 0x16, 0x11, 0x0, 0x0, 0x14, 0x9f, 0x11, 0x0, 0x0, 0x19, 0xc8}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x20, 0x2d, 0xcc, 0x79, 0xa5, 0x76, 0x28, 0x61, + 0xe8, 0x15, 0x94, 0xf, 0x7c, 0x65, 0x7d, 0x45}; + uint8_t bytesprops1[] = {0x6f, 0xa4, 0x86, 0x7c, 0x5e, 0x9a, 0xaf, 0x1, 0xb2, + 0xf4, 0x5a, 0x78, 0xe, 0x73, 0x80, 0x60, 0x5b, 0x16}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19459}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 1}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12710}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {5, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13088}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {23, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 957}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 4548}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 18197}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25384}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 239}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15062}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 89}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30222}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {11, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 147}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 166}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 76}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 22692}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {18, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 5279}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6600}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {7, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 152, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 135, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoAdministrativeAction [PropWillDelayInterval 17096,PropUserProperty "\157\187\141L\EMf" -// ":\SO+0\131\DC3\STXxw\244\154\185\ETB^\202\218pn!\231\ENQd\250\130\&6\136\233/\155\SI",PropCorrelationData -// "\131\175\220\169\210R\SI\253W$\168\157\227V\241\146\249\174q \208\157\186\251",PropServerKeepAlive -// 13699,PropSubscriptionIdentifier 24,PropServerReference "\EMA\ETB",PropRequestProblemInformation -// 190,PropRequestResponseInformation 140,PropUserProperty "\221\246\207" "\176",PropSessionExpiryInterval -// 16599,PropSessionExpiryInterval 15959,PropAuthenticationMethod -// "\v\246\201\&3Q\213\154\a\221~sZje\177\\=W(\197\244%\243\&2\136F.",PropResponseInformation -// ".\202\ESC\228]\188\247\SUBA\NAK\165%*\ETB\227v\254\245\178\196",PropMessageExpiryInterval 6008,PropWillDelayInterval -// 31345,PropSubscriptionIdentifier 19,PropSubscriptionIdentifierAvailable 135,PropTopicAlias 26339,PropMaximumQoS -// 121,PropContentType "{\156N\224\FS\255u\DC1j\158\NUL\DC4\194\224",PropReceiveMaximum 7053,PropPayloadFormatIndicator -// 198,PropMessageExpiryInterval 17414,PropAuthenticationMethod "\250\235\143\192",PropContentType -// "\221;\146\&1\DC4\SOHP\189)\187\DC4 \t~\216gAf\DC1\147B| >~\210Y\167",PropWillDelayInterval 24883] +// DisconnectRequest DiscoSharedSubscriptionsNotSupported [PropMessageExpiryInterval 10770,PropMaximumPacketSize +// 25135,PropTopicAliasMaximum 29884] TEST(Disco5QCTest, Encode17) { - uint8_t pkt[] = { - 0xe0, 0xfc, 0x1, 0x98, 0xf9, 0x1, 0x18, 0x0, 0x0, 0x42, 0xc8, 0x26, 0x0, 0x6, 0x9d,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, 0x21, 0x1b, 0x8d, 0x1, 0xc6, 0x2, 0x0, - 0x0, 0x44, 0x6, 0x15, 0x0, 0x4, 0xfa, 0xeb, 0x8f, 0xc0, 0x3, 0x0, 0x1c, 0xdd, 0x3b, 0x92, 0x31, 0x14, 0x1, - 0x50, 0xbd, 0x29, 0xbb, 0x14, 0x20, 0x9, 0x7e, 0xd8, 0x67, 0x41, 0x66, 0x11, 0x93, 0x42, 0x7c, 0x20, 0x3e, 0x7e, - 0xd2, 0x59, 0xa7, 0x18, 0x0, 0x0, 0x61, 0x33}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x3a, 0xe, 0x2b, 0x30, 0x83, 0x13, 0x2, 0x78, 0x77, 0xf4, 0x9a, 0xb9, 0x17, 0x5e, 0xca, - 0xda, 0x70, 0x6e, 0x21, 0xe7, 0x5, 0x64, 0xfa, 0x82, 0x36, 0x88, 0xe9, 0x2f, 0x9b, 0xf}; - uint8_t bytesprops0[] = {0x9d, 0xbb, 0x8d, 0x4c, 0x19, 0x66}; - uint8_t bytesprops2[] = {0x83, 0xaf, 0xdc, 0xa9, 0xd2, 0x52, 0xf, 0xfd, 0x57, 0x24, 0xa8, 0x9d, - 0xe3, 0x56, 0xf1, 0x92, 0xf9, 0xae, 0x71, 0x20, 0xd0, 0x9d, 0xba, 0xfb}; - uint8_t bytesprops3[] = {0x19, 0x41, 0x17}; - uint8_t bytesprops5[] = {0xb0}; - uint8_t bytesprops4[] = {0xdd, 0xf6, 0xcf}; - uint8_t bytesprops6[] = {0xb, 0xf6, 0xc9, 0x33, 0x51, 0xd5, 0x9a, 0x7, 0xdd, 0x7e, 0x73, 0x5a, 0x6a, 0x65, - 0xb1, 0x5c, 0x3d, 0x57, 0x28, 0xc5, 0xf4, 0x25, 0xf3, 0x32, 0x88, 0x46, 0x2e}; - uint8_t bytesprops7[] = {0x2e, 0xca, 0x1b, 0xe4, 0x5d, 0xbc, 0xf7, 0x1a, 0x41, 0x15, - 0xa5, 0x25, 0x2a, 0x17, 0xe3, 0x76, 0xfe, 0xf5, 0xb2, 0xc4}; - uint8_t bytesprops8[] = {0x7b, 0x9c, 0x4e, 0xe0, 0x1c, 0xff, 0x75, 0x11, 0x6a, 0x9e, 0x0, 0x14, 0xc2, 0xe0}; - uint8_t bytesprops9[] = {0xfa, 0xeb, 0x8f, 0xc0}; - uint8_t bytesprops10[] = {0xdd, 0x3b, 0x92, 0x31, 0x14, 0x1, 0x50, 0xbd, 0x29, 0xbb, 0x14, 0x20, 0x9, 0x7e, - 0xd8, 0x67, 0x41, 0x66, 0x11, 0x93, 0x42, 0x7c, 0x20, 0x3e, 0x7e, 0xd2, 0x59, 0xa7}; + uint8_t pkt[] = {0xe0, 0xf, 0x9e, 0xd, 0x2, 0x0, 0x0, 0x2a, 0x12, 0x27, 0x0, 0x0, 0x62, 0x2f, 0x22, 0x74, 0xbc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 17096}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {6, (char*)&bytesprops0}, .v = {30, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {24, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13699}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 24}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 190}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 140}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {3, (char*)&bytesprops4}, .v = {1, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16599}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15959}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {20, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6008}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 31345}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 26339}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 121}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {14, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 7053}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 198}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17414}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {4, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {28, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 24883}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10770}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 25135}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 29884}}, }; - lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {3, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 152, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 158, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoPacketTooLarge [PropSharedSubscriptionAvailable 20] +// DisconnectRequest DiscoPacketTooLarge [PropTopicAlias 4988,PropRequestProblemInformation 8,PropMessageExpiryInterval +// 10687,PropAuthenticationMethod "\146\145S?$\224\bN\154`\146\253\SUB\186\213\171",PropRetainAvailable +// 92,PropResponseTopic "r\\\DC4\252v\182.\220\ENQ",PropTopicAlias 10477,PropRequestResponseInformation +// 242,PropUserProperty "\196bD\146\254\RS\202(\219\RS_\128\163\144\135\227\239N\131\EOT\CAN\139\195\171\162" +// "Y#\243v",PropResponseTopic +// "\227`\FS\221\182l\198yF\128q-\EOT\ETB\204%RA\203\207\SI\DC4\196\DC4\144\248\253A",PropTopicAlias +// 16910,PropServerKeepAlive 4442,PropResponseInformation +// "{{\243\220N\DC4\ACK\203\154\209\177a\226\FS;\190\176\138",PropSubscriptionIdentifierAvailable +// 35,PropMaximumPacketSize 14453,PropReasonString "\187\199",PropRequestProblemInformation 120] TEST(Disco5QCTest, Encode18) { - uint8_t pkt[] = {0xe0, 0x4, 0x95, 0x2, 0x2a, 0x14}; - uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t pkt[] = {0xe0, 0x9d, 0x1, 0x95, 0x9a, 0x1, 0x23, 0x13, 0x7c, 0x17, 0x8, 0x2, 0x0, 0x0, 0x29, 0xbf, + 0x15, 0x0, 0x10, 0x92, 0x91, 0x53, 0x3f, 0x24, 0xe0, 0x8, 0x4e, 0x9a, 0x60, 0x92, 0xfd, 0x1a, + 0xba, 0xd5, 0xab, 0x25, 0x5c, 0x8, 0x0, 0x9, 0x72, 0x5c, 0x14, 0xfc, 0x76, 0xb6, 0x2e, 0xdc, + 0x5, 0x23, 0x28, 0xed, 0x19, 0xf2, 0x26, 0x0, 0x19, 0xc4, 0x62, 0x44, 0x92, 0xfe, 0x1e, 0xca, + 0x28, 0xdb, 0x1e, 0x5f, 0x80, 0xa3, 0x90, 0x87, 0xe3, 0xef, 0x4e, 0x83, 0x4, 0x18, 0x8b, 0xc3, + 0xab, 0xa2, 0x0, 0x4, 0x59, 0x23, 0xf3, 0x76, 0x8, 0x0, 0x1c, 0xe3, 0x60, 0x1c, 0xdd, 0xb6, + 0x6c, 0xc6, 0x79, 0x46, 0x80, 0x71, 0x2d, 0x4, 0x17, 0xcc, 0x25, 0x52, 0x41, 0xcb, 0xcf, 0xf, + 0x14, 0xc4, 0x14, 0x90, 0xf8, 0xfd, 0x41, 0x23, 0x42, 0xe, 0x13, 0x11, 0x5a, 0x1a, 0x0, 0x12, + 0x7b, 0x7b, 0xf3, 0xdc, 0x4e, 0x14, 0x6, 0xcb, 0x9a, 0xd1, 0xb1, 0x61, 0xe2, 0x1c, 0x3b, 0xbe, + 0xb0, 0x8a, 0x29, 0x23, 0x27, 0x0, 0x0, 0x38, 0x75, 0x1f, 0x0, 0x2, 0xbb, 0xc7, 0x17, 0x78}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x92, 0x91, 0x53, 0x3f, 0x24, 0xe0, 0x8, 0x4e, + 0x9a, 0x60, 0x92, 0xfd, 0x1a, 0xba, 0xd5, 0xab}; + uint8_t bytesprops1[] = {0x72, 0x5c, 0x14, 0xfc, 0x76, 0xb6, 0x2e, 0xdc, 0x5}; + uint8_t bytesprops3[] = {0x59, 0x23, 0xf3, 0x76}; + uint8_t bytesprops2[] = {0xc4, 0x62, 0x44, 0x92, 0xfe, 0x1e, 0xca, 0x28, 0xdb, 0x1e, 0x5f, 0x80, 0xa3, + 0x90, 0x87, 0xe3, 0xef, 0x4e, 0x83, 0x4, 0x18, 0x8b, 0xc3, 0xab, 0xa2}; + uint8_t bytesprops4[] = {0xe3, 0x60, 0x1c, 0xdd, 0xb6, 0x6c, 0xc6, 0x79, 0x46, 0x80, 0x71, 0x2d, 0x4, 0x17, + 0xcc, 0x25, 0x52, 0x41, 0xcb, 0xcf, 0xf, 0x14, 0xc4, 0x14, 0x90, 0xf8, 0xfd, 0x41}; + uint8_t bytesprops5[] = {0x7b, 0x7b, 0xf3, 0xdc, 0x4e, 0x14, 0x6, 0xcb, 0x9a, + 0xd1, 0xb1, 0x61, 0xe2, 0x1c, 0x3b, 0xbe, 0xb0, 0x8a}; + uint8_t bytesprops6[] = {0xbb, 0xc7}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4988}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 8}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 10687}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {16, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 92}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {9, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10477}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 242}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops2}, .v = {4, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 16910}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 4442}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 35}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 14453}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 120}}, }; - lwmqtt_properties_t props = {1, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 149, props); EXPECT_EQ(err, LWMQTT_SUCCESS); @@ -28225,152 +26749,104 @@ TEST(Disco5QCTest, Encode18) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoAdministrativeAction [PropReasonString -// "*%\v\STX\204\176\&7\DC1\197`^\235r\131q\134\n\185^\RS\154Bt?k\182",PropResponseInformation -// "@\186\132",PropSubscriptionIdentifier 15,PropReceiveMaximum 18394,PropRequestProblemInformation -// 41,PropServerReference ",\fk",PropRequestProblemInformation 18,PropTopicAlias 6053,PropAssignedClientIdentifier -// "\233\NAKu\136",PropMessageExpiryInterval 4488,PropRequestResponseInformation 96,PropSubscriptionIdentifier -// 11,PropSubscriptionIdentifierAvailable 115,PropAuthenticationData -// "\241\v-\215\166\183,\176\194\216\243\178\168=6e\221y\240Q\167\180\US\NAK\128\DEL\128\146\250\171",PropCorrelationData -// "#dC\CAN\STXC",PropMaximumPacketSize 6841,PropRequestResponseInformation 81,PropTopicAlias 4335,PropUserProperty -// "\161\197\v\212\228\253\173\249r\GSPP:" "8|\243\233V\247\162\203\DC3\161",PropUserProperty -// "\211\&7\200d#\218yQ\229\DEL$\n\209\233\ESC\220\v\191" "{5\241\195",PropRetainAvailable 139,PropServerKeepAlive -// 29153,PropResponseTopic "\241\v\198Z:\202\242\181UB\188\&46",PropTopicAlias 12740,PropAuthenticationData -// "\STX\191\ETB\223\190\SIC}\205\ESCzE"] +// DisconnectRequest DiscoMessageRateTooHigh [] TEST(Disco5QCTest, Encode19) { - uint8_t pkt[] = { - 0xe0, 0xdc, 0x1, 0x98, 0xd9, 0x1, 0x1f, 0x0, 0x1a, 0x2a, 0x25, 0xb, 0x2, 0xcc, 0xb0, 0x37, 0x11, 0xc5, 0x60, - 0x5e, 0xeb, 0x72, 0x83, 0x71, 0x86, 0xa, 0xb9, 0x5e, 0x1e, 0x9a, 0x42, 0x74, 0x3f, 0x6b, 0xb6, 0x1a, 0x0, 0x3, - 0x40, 0xba, 0x84, 0xb, 0xf, 0x21, 0x47, 0xda, 0x17, 0x29, 0x1c, 0x0, 0x3, 0x2c, 0xc, 0x6b, 0x17, 0x12, 0x23, - 0x17, 0xa5, 0x12, 0x0, 0x4, 0xe9, 0x15, 0x75, 0x88, 0x2, 0x0, 0x0, 0x11, 0x88, 0x19, 0x60, 0xb, 0xb, 0x29, - 0x73, 0x16, 0x0, 0x1e, 0xf1, 0xb, 0x2d, 0xd7, 0xa6, 0xb7, 0x2c, 0xb0, 0xc2, 0xd8, 0xf3, 0xb2, 0xa8, 0x3d, 0x36, - 0x65, 0xdd, 0x79, 0xf0, 0x51, 0xa7, 0xb4, 0x1f, 0x15, 0x80, 0x7f, 0x80, 0x92, 0xfa, 0xab, 0x9, 0x0, 0x6, 0x23, - 0x64, 0x43, 0x18, 0x2, 0x43, 0x27, 0x0, 0x0, 0x1a, 0xb9, 0x19, 0x51, 0x23, 0x10, 0xef, 0x26, 0x0, 0xd, 0xa1, - 0xc5, 0xb, 0xd4, 0xe4, 0xfd, 0xad, 0xf9, 0x72, 0x1d, 0x50, 0x50, 0x3a, 0x0, 0xa, 0x38, 0x7c, 0xf3, 0xe9, 0x56, - 0xf7, 0xa2, 0xcb, 0x13, 0xa1, 0x26, 0x0, 0x12, 0xd3, 0x37, 0xc8, 0x64, 0x23, 0xda, 0x79, 0x51, 0xe5, 0x7f, 0x24, - 0xa, 0xd1, 0xe9, 0x1b, 0xdc, 0xb, 0xbf, 0x0, 0x4, 0x7b, 0x35, 0xf1, 0xc3, 0x25, 0x8b, 0x13, 0x71, 0xe1, 0x8, - 0x0, 0xd, 0xf1, 0xb, 0xc6, 0x5a, 0x3a, 0xca, 0xf2, 0xb5, 0x55, 0x42, 0xbc, 0x34, 0x36, 0x23, 0x31, 0xc4, 0x16, - 0x0, 0xc, 0x2, 0xbf, 0x17, 0xdf, 0xbe, 0xf, 0x43, 0x7d, 0xcd, 0x1b, 0x7a, 0x45}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x2a, 0x25, 0xb, 0x2, 0xcc, 0xb0, 0x37, 0x11, 0xc5, 0x60, 0x5e, 0xeb, 0x72, - 0x83, 0x71, 0x86, 0xa, 0xb9, 0x5e, 0x1e, 0x9a, 0x42, 0x74, 0x3f, 0x6b, 0xb6}; - uint8_t bytesprops1[] = {0x40, 0xba, 0x84}; - uint8_t bytesprops2[] = {0x2c, 0xc, 0x6b}; - uint8_t bytesprops3[] = {0xe9, 0x15, 0x75, 0x88}; - uint8_t bytesprops4[] = {0xf1, 0xb, 0x2d, 0xd7, 0xa6, 0xb7, 0x2c, 0xb0, 0xc2, 0xd8, 0xf3, 0xb2, 0xa8, 0x3d, 0x36, - 0x65, 0xdd, 0x79, 0xf0, 0x51, 0xa7, 0xb4, 0x1f, 0x15, 0x80, 0x7f, 0x80, 0x92, 0xfa, 0xab}; - uint8_t bytesprops5[] = {0x23, 0x64, 0x43, 0x18, 0x2, 0x43}; - uint8_t bytesprops7[] = {0x38, 0x7c, 0xf3, 0xe9, 0x56, 0xf7, 0xa2, 0xcb, 0x13, 0xa1}; - uint8_t bytesprops6[] = {0xa1, 0xc5, 0xb, 0xd4, 0xe4, 0xfd, 0xad, 0xf9, 0x72, 0x1d, 0x50, 0x50, 0x3a}; - uint8_t bytesprops9[] = {0x7b, 0x35, 0xf1, 0xc3}; - uint8_t bytesprops8[] = {0xd3, 0x37, 0xc8, 0x64, 0x23, 0xda, 0x79, 0x51, 0xe5, - 0x7f, 0x24, 0xa, 0xd1, 0xe9, 0x1b, 0xdc, 0xb, 0xbf}; - uint8_t bytesprops10[] = {0xf1, 0xb, 0xc6, 0x5a, 0x3a, 0xca, 0xf2, 0xb5, 0x55, 0x42, 0xbc, 0x34, 0x36}; - uint8_t bytesprops11[] = {0x2, 0xbf, 0x17, 0xdf, 0xbe, 0xf, 0x43, 0x7d, 0xcd, 0x1b, 0x7a, 0x45}; + uint8_t pkt[] = {0xe0, 0x2, 0x96, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)31, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {3, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 18394}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 41}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {3, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 6053}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {4, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 4488}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 96}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 11}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 115}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {30, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {6, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 6841}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 81}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 4335}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {13, (char*)&bytesprops6}, .v = {10, (char*)&bytesprops7}}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {18, (char*)&bytesprops8}, .v = {4, (char*)&bytesprops9}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29153}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {13, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 12740}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops11}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {25, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 152, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 150, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoNormalDisconnection [PropRetainAvailable 93,PropSubscriptionIdentifier -// 21,PropTopicAliasMaximum 19035,PropWildcardSubscriptionAvailable 184,PropServerReference -// "\133ig\197{\208\129\247\&9\244\&21jr\US:}V\229\188W\143\&7\129",PropRequestProblemInformation 68,PropContentType -// "\251\175\248\187jOr\173\187]\191\201\DLE-;\200v\212\196\224",PropCorrelationData -// "i\167\197\143\129\191\150\RS\r\DC3\223\141\&5\211W\135\132\&1%Y\221\220\215=B^\202rx",PropRequestResponseInformation -// 42,PropTopicAlias 797,PropReceiveMaximum 12309,PropRequestProblemInformation 35,PropServerKeepAlive -// 12065,PropResponseInformation "\153v\212w\132_\221\239\157\208\135",PropSessionExpiryInterval -// 8886,PropAuthenticationData -// "\129<\DELu\EM\207l\200h69B\181\229Z\143\191\191\130\140\238\241\EM",PropMaximumPacketSize 8070,PropWillDelayInterval -// 9412,PropReceiveMaximum 20391,PropResponseInformation -// "\ETB\139\193\223\v\v\177\204\214\252\r\163\157.\\\133",PropWillDelayInterval 19132] +// DisconnectRequest DiscoNormalDisconnection [PropTopicAlias 25785,PropResponseTopic +// "&\129,2\231\136c\164\130\b\189",PropPayloadFormatIndicator 186,PropResponseInformation +// "\194y\157M\239\&6;\169A)\189\152 z\SOHk\SUB\240\GS\136\214Nov\155",PropAuthenticationData +// "\211\n\158;\251\219mu\195@\132\227\183\136;\155\234\189" +// "\DC1z\195\138\251\255\251\246\177\&7\ETX\208\215\204\236x\138\134\162\165\135\142'\EM\139",PropMaximumQoS +// 165,PropContentType "\136\240\ACK\ETX~B\223\191\213\199",PropWillDelayInterval 29321,PropAssignedClientIdentifier +// "{'r~6q#\254Jl\214\SOrS\216g\232\171\174\166J\f\227",PropSessionExpiryInterval 32003,PropRequestResponseInformation +// 53,PropAuthenticationData "\131<\143#\\\204\164Lgq\SUBpI\168\SUB\240\157\STX7\ESC",PropServerKeepAlive +// 22451,PropResponseInformation +// "\238H\n\233#J\245\ETBya\189\129\174\227\&0\251\201C\208\187\ENQ\216\172\172\145\252y",PropWillDelayInterval +// 10313,PropServerReference "\248\161\145\a\222m",PropMaximumQoS 33,PropWillDelayInterval +// 14267,PropPayloadFormatIndicator 116,PropRequestProblemInformation 21,PropReasonString +// "\217\&5\FSff\b\227\200z\183\181@-\180\146\160\210\149F]\217Y\218",PropResponseTopic "\166oGm\140\170f7"] TEST(Disco5QCTest, Encode20) { - uint8_t pkt[] = { - 0xe0, 0xe0, 0x1, 0x0, 0xdd, 0x1, 0x25, 0x5d, 0xb, 0x15, 0x22, 0x4a, 0x5b, 0x28, 0xb8, 0x1c, 0x0, 0x18, 0x85, - 0x69, 0x67, 0xc5, 0x7b, 0xd0, 0x81, 0xf7, 0x39, 0xf4, 0x32, 0x31, 0x6a, 0x72, 0x1f, 0x3a, 0x7d, 0x56, 0xe5, 0xbc, - 0x57, 0x8f, 0x37, 0x81, 0x17, 0x44, 0x3, 0x0, 0x14, 0xfb, 0xaf, 0xf8, 0xbb, 0x6a, 0x4f, 0x72, 0xad, 0xbb, 0x5d, - 0xbf, 0xc9, 0x10, 0x2d, 0x3b, 0xc8, 0x76, 0xd4, 0xc4, 0xe0, 0x9, 0x0, 0x1d, 0x69, 0xa7, 0xc5, 0x8f, 0x81, 0xbf, - 0x96, 0x1e, 0xd, 0x13, 0xdf, 0x8d, 0x35, 0xd3, 0x57, 0x87, 0x84, 0x31, 0x25, 0x59, 0xdd, 0xdc, 0xd7, 0x3d, 0x42, - 0x5e, 0xca, 0x72, 0x78, 0x19, 0x2a, 0x23, 0x3, 0x1d, 0x21, 0x30, 0x15, 0x17, 0x23, 0x13, 0x2f, 0x21, 0x1a, 0x0, - 0xb, 0x99, 0x76, 0xd4, 0x77, 0x84, 0x5f, 0xdd, 0xef, 0x9d, 0xd0, 0x87, 0x11, 0x0, 0x0, 0x22, 0xb6, 0x16, 0x0, - 0x17, 0x81, 0x3c, 0x7f, 0x75, 0x19, 0xcf, 0x6c, 0xc8, 0x68, 0x36, 0x39, 0x42, 0xb5, 0xe5, 0x5a, 0x8f, 0xbf, 0xbf, - 0x82, 0x8c, 0xee, 0xf1, 0x19, 0x27, 0x0, 0x0, 0x1f, 0x86, 0x18, 0x0, 0x0, 0x24, 0xc4, 0x21, 0x4f, 0xa7, 0x1a, - 0x0, 0x1c, 0x17, 0x8b, 0xc1, 0xdf, 0xb, 0xb, 0xb1, 0xcc, 0xd6, 0xfc, 0x3c, 0x67, 0x8a, 0x63, 0x79, 0x47, 0xa0, - 0x30, 0xef, 0xa6, 0x1d, 0xe8, 0x98, 0x17, 0x27, 0xab, 0xfe, 0xbe, 0x1a, 0x0, 0x12, 0x51, 0x71, 0xf, 0x3, 0xf6, - 0x98, 0xca, 0x8b, 0x42, 0xb9, 0x1, 0x3e, 0xd, 0xa3, 0x9d, 0x2e, 0x5c, 0x85, 0x18, 0x0, 0x0, 0x4a, 0xbc}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x85, 0x69, 0x67, 0xc5, 0x7b, 0xd0, 0x81, 0xf7, 0x39, 0xf4, 0x32, 0x31, - 0x6a, 0x72, 0x1f, 0x3a, 0x7d, 0x56, 0xe5, 0xbc, 0x57, 0x8f, 0x37, 0x81}; - uint8_t bytesprops1[] = {0xfb, 0xaf, 0xf8, 0xbb, 0x6a, 0x4f, 0x72, 0xad, 0xbb, 0x5d, - 0xbf, 0xc9, 0x10, 0x2d, 0x3b, 0xc8, 0x76, 0xd4, 0xc4, 0xe0}; - uint8_t bytesprops2[] = {0x69, 0xa7, 0xc5, 0x8f, 0x81, 0xbf, 0x96, 0x1e, 0xd, 0x13, 0xdf, 0x8d, 0x35, 0xd3, 0x57, - 0x87, 0x84, 0x31, 0x25, 0x59, 0xdd, 0xdc, 0xd7, 0x3d, 0x42, 0x5e, 0xca, 0x72, 0x78}; - uint8_t bytesprops3[] = {0x99, 0x76, 0xd4, 0x77, 0x84, 0x5f, 0xdd, 0xef, 0x9d, 0xd0, 0x87}; - uint8_t bytesprops4[] = {0x81, 0x3c, 0x7f, 0x75, 0x19, 0xcf, 0x6c, 0xc8, 0x68, 0x36, 0x39, 0x42, - 0xb5, 0xe5, 0x5a, 0x8f, 0xbf, 0xbf, 0x82, 0x8c, 0xee, 0xf1, 0x19}; - uint8_t bytesprops5[] = {0x17, 0x8b, 0xc1, 0xdf, 0xb, 0xb, 0xb1, 0xcc, 0xd6, 0xfc, 0x3c, 0x67, 0x8a, 0x63, - 0x79, 0x47, 0xa0, 0x30, 0xef, 0xa6, 0x1d, 0xe8, 0x98, 0x17, 0x27, 0xab, 0xfe, 0xbe}; - uint8_t bytesprops6[] = {0x51, 0x71, 0xf, 0x3, 0xf6, 0x98, 0xca, 0x8b, 0x42, - 0xb9, 0x1, 0x3e, 0xd, 0xa3, 0x9d, 0x2e, 0x5c, 0x85}; + uint8_t pkt[] = {0xe0, 0xae, 0x2, 0x0, 0xab, 0x2, 0x23, 0x64, 0xb9, 0x8, 0x0, 0xb, 0x26, 0x81, 0x2c, 0x32, 0xe7, + 0x88, 0x63, 0xa4, 0x82, 0x8, 0xbd, 0x1, 0xba, 0x1a, 0x0, 0x19, 0xc2, 0x79, 0x9d, 0x4d, 0xef, 0x36, + 0x3b, 0xa9, 0x41, 0x29, 0xbd, 0x98, 0x20, 0x7a, 0x1, 0x6b, 0x1a, 0xf0, 0x1d, 0x88, 0xd6, 0x4e, 0x6f, + 0x76, 0x9b, 0x16, 0x0, 0x17, 0xd3, 0xa, 0x9e, 0x3b, 0xfb, 0x3c, 0x6d, 0xc6, 0x72, 0x39, 0xe0, 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x91, 0x7, + 0xde, 0x6d, 0x24, 0x21, 0x18, 0x0, 0x0, 0x37, 0xbb, 0x1, 0x74, 0x17, 0x15, 0x1f, 0x0, 0x17, 0xd9, + 0x35, 0x1c, 0x66, 0x66, 0x8, 0xe3, 0xc8, 0x7a, 0xb7, 0xb5, 0x40, 0x2d, 0xb4, 0x92, 0xa0, 0xd2, 0x95, + 0x46, 0x5d, 0xd9, 0x59, 0xda, 0x8, 0x0, 0x8, 0xa6, 0x6f, 0x47, 0x6d, 0x8c, 0xaa, 0x66, 0x37}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x26, 0x81, 0x2c, 0x32, 0xe7, 0x88, 0x63, 0xa4, 0x82, 0x8, 0xbd}; + uint8_t bytesprops1[] = {0xc2, 0x79, 0x9d, 0x4d, 0xef, 0x36, 0x3b, 0xa9, 0x41, 0x29, 0xbd, 0x98, 0x20, + 0x7a, 0x1, 0x6b, 0x1a, 0xf0, 0x1d, 0x88, 0xd6, 0x4e, 0x6f, 0x76, 0x9b}; + uint8_t bytesprops2[] = {0xd3, 0xa, 0x9e, 0x3b, 0xfb, 0x3c, 0x6d, 0xc6, 0x72, 0x39, 0xe0, 0xfe, + 0xc3, 0xf9, 0xd7, 0xbd, 0x47, 0x95, 0x73, 0xc8, 0x41, 0xb0, 0xc}; + uint8_t bytesprops4[] = {0x11, 0x7a, 0xc3, 0x8a, 0xfb, 0xff, 0xfb, 0xf6, 0xb1, 0x37, 0x3, 0xd0, 0xd7, + 0xcc, 0xec, 0x78, 0x8a, 0x86, 0xa2, 0xa5, 0x87, 0x8e, 0x27, 0x19, 0x8b}; + uint8_t bytesprops3[] = {0xea, 0xea, 0x22, 0x39, 0x9f, 0x6a, 0x3e, 0xdb, 0x6d, 0x75, + 0xc3, 0x40, 0x84, 0xe3, 0xb7, 0x88, 0x3b, 0x9b, 0xea, 0xbd}; + uint8_t bytesprops5[] = {0x88, 0xf0, 0x6, 0x3, 0x7e, 0x42, 0xdf, 0xbf, 0xd5, 0xc7}; + uint8_t bytesprops6[] = {0x7b, 0x27, 0x72, 0x7e, 0x36, 0x71, 0x23, 0xfe, 0x4a, 0x6c, 0xd6, 0xe, + 0x72, 0x53, 0xd8, 0x67, 0xe8, 0xab, 0xae, 0xa6, 0x4a, 0xc, 0xe3}; + uint8_t bytesprops7[] = {0x83, 0x3c, 0x8f, 0x23, 0x5c, 0xcc, 0xa4, 0x4c, 0x67, 0x71, + 0x1a, 0x70, 0x49, 0xa8, 0x1a, 0xf0, 0x9d, 0x2, 0x37, 0x1b}; + uint8_t bytesprops8[] = {0xee, 0x48, 0xa, 0xe9, 0x23, 0x4a, 0xf5, 0x17, 0x79, 0x61, 0xbd, 0x81, 0xae, 0xe3, + 0x30, 0xfb, 0xc9, 0x43, 0xd0, 0xbb, 0x5, 0xd8, 0xac, 0xac, 0x91, 0xfc, 0x79}; + uint8_t bytesprops9[] = {0xf8, 0xa1, 0x91, 0x7, 0xde, 0x6d}; + uint8_t bytesprops10[] = {0xd9, 0x35, 0x1c, 0x66, 0x66, 0x8, 0xe3, 0xc8, 0x7a, 0xb7, 0xb5, 0x40, + 0x2d, 0xb4, 0x92, 0xa0, 0xd2, 0x95, 0x46, 0x5d, 0xd9, 0x59, 0xda}; + uint8_t bytesprops11[] = {0xa6, 0x6f, 0x47, 0x6d, 0x8c, 0xaa, 0x66, 0x37}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 93}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 21}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 19035}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 184}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {24, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 68}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {29, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 42}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 797}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 12309}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 35}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 12065}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 8886}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8070}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9412}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 20391}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {18, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19132}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 25785}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {11, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 186}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {25, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {23, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 16362}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {20, (char*)&bytesprops3}, .v = {25, (char*)&bytesprops4}}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 165}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 29321}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {23, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 32003}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 53}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 22451}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {27, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 10313}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {6, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 33}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 14267}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 116}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 21}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {23, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops11}}}, }; - lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; size_t len = 0; lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); @@ -28378,683 +26854,468 @@ TEST(Disco5QCTest, Encode20) { EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoUnspecifiedError [PropRequestProblemInformation 0,PropAssignedClientIdentifier -// "\DC4\250y/=U=e\252A\192\223\149\138\242",PropTopicAliasMaximum 15098,PropSubscriptionIdentifier -// 16,PropServerKeepAlive 28733,PropServerReference "\224\DC3\177\f\212\158\168\191\195",PropMaximumPacketSize -// 24280,PropRequestResponseInformation 23,PropContentType "\189@\216\247\SO\137\194\DC3\250\139JD\204 -// \225P\\\234\&9a\203",PropSessionExpiryInterval 20827,PropResponseTopic "Pl;\169S\149",PropContentType -// "\180\251\132\248D\129\139\249z\134\174\154\229\214\215LW",PropUserProperty -// "4A?\231y\240Z\227#*\128\201\190\b\181\250\150\226\191\239\242m\157g\ESC" "z\251\DEL\182",PropServerKeepAlive -// 15182,PropContentType "",PropResponseTopic -// "\DC4g\173\223\151X\219\175*oAp3\139\233z\231\178P\128\215+\250\249\153\137\163\b",PropSharedSubscriptionAvailable -// 20,PropAuthenticationMethod "\163}%\178\155y\201\DC4\146."] +// DisconnectRequest DiscoSubscriptionIdentifiersNotSupported [PropMaximumQoS 222,PropMessageExpiryInterval +// 6333,PropSessionExpiryInterval 6463,PropServerReference +// "\146G.T\225L!\255N\CAN\238\186\&1\RS\254\&5\r\153L\188\DLE\219\142wq\t",PropPayloadFormatIndicator +// 9,PropRequestProblemInformation 19,PropTopicAliasMaximum 32175,PropResponseTopic +// "\"\FS\b\SO\234\&4\252^/\155\213C\247\231",PropMessageExpiryInterval 22063,PropMaximumPacketSize +// 8213,PropWildcardSubscriptionAvailable 12,PropTopicAliasMaximum 24294,PropRequestProblemInformation +// 140,PropAssignedClientIdentifier +// "\143\215zR?\238\199\193\167w.\199\209\206\164}\192\153U\150M\128\225\174\162\DEL",PropServerKeepAlive +// 29091,PropResponseTopic "\195\STX$\\\218\SI\151)\148I\t\134\&6\239A\SO +// \ETX\205\196w\218",PropRequestResponseInformation 196,PropResponseTopic +// "\SOH\191\185\DEL\179\SUB\146\249\174\241\&9\234\ENQ=\223\&0\STX\178T\220\158",PropResponseTopic +// "\248\143\NAK|pP",PropTopicAliasMaximum 28364,PropReasonString "hHB\158\160Za\200",PropSessionExpiryInterval 11996] TEST(Disco5QCTest, Encode21) { - uint8_t pkt[] = {0xe0, 0xc2, 0x1, 0x80, 0xbf, 0x1, 0x17, 0x0, 0x12, 0x0, 0xf, 0x14, 0xfa, 0x79, 0x2f, 0x3d, 0x55, - 0x3d, 0x65, 0xfc, 0x41, 0xc0, 0xdf, 0x95, 0x8a, 0xf2, 0x22, 0x3a, 0xfa, 0xb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41, 0xc0, 0xdf, 0x95, 0x8a, 0xf2}; - uint8_t bytesprops1[] = {0xe0, 0x13, 0xb1, 0xc, 0xd4, 0x9e, 0xa8, 0xbf, 0xc3}; - uint8_t bytesprops2[] = {0xbd, 0x40, 0xd8, 0xf7, 0xe, 0x89, 0xc2, 0x13, 0xfa, 0x8b, 0x4a, - 0x44, 0xcc, 0x20, 0xe1, 0x50, 0x5c, 0xea, 0x39, 0x61, 0xcb}; - uint8_t bytesprops3[] = {0x50, 0x6c, 0x3b, 0xa9, 0x53, 0x95}; - uint8_t bytesprops4[] = {0xb4, 0xfb, 0x84, 0xf8, 0x44, 0x81, 0x8b, 0xf9, 0x7a, - 0x86, 0xae, 0x9a, 0xe5, 0xd6, 0xd7, 0x4c, 0x57}; - uint8_t bytesprops6[] = {0x7a, 0xfb, 0x7f, 0xb6}; - uint8_t bytesprops5[] = {0x34, 0x41, 0x3f, 0xe7, 0x79, 0xf0, 0x5a, 0xe3, 0x23, 0x2a, 0x80, 0xc9, 0xbe, - 0x8, 0xb5, 0xfa, 0x96, 0xe2, 0xbf, 0xef, 0xf2, 0x6d, 0x9d, 0x67, 0x1b}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops8[] = {0x14, 0x67, 0xad, 0xdf, 0x97, 0x58, 0xdb, 0xaf, 0x2a, 0x6f, 0x41, 0x70, 0x33, 0x8b, - 0xe9, 0x7a, 0xe7, 0xb2, 0x50, 0x80, 0xd7, 0x2b, 0xfa, 0xf9, 0x99, 0x89, 0xa3, 0x8}; - uint8_t bytesprops9[] = {0xa3, 0x7d, 0x25, 0xb2, 0x9b, 0x79, 0xc9, 0x14, 0x92, 0x2e}; + uint8_t pkt[] = {0xe0, 0xc4, 0x1, 0xa1, 0xc1, 0x1, 0x24, 0xde, 0x2, 0x0, 0x0, 0x18, 0xbd, 0x11, 0x0, 0x0, 0x19, + 0x3f, 0x1c, 0x0, 0x1a, 0x92, 0x47, 0x2e, 0x54, 0xe1, 0x4c, 0x21, 0xff, 0x4e, 0x18, 0xee, 0xba, 0x31, + 0x1e, 0xfe, 0x35, 0xd, 0x99, 0x4c, 0xbc, 0x10, 0xdb, 0x8e, 0x77, 0x71, 0x9, 0x1, 0x9, 0x17, 0x13, + 0x22, 0x7d, 0xaf, 0x8, 0x0, 0xe, 0x22, 0x1c, 0x8, 0xe, 0xea, 0x34, 0xfc, 0x5e, 0x2f, 0x9b, 0xd5, + 0x43, 0xf7, 0xe7, 0x2, 0x0, 0x0, 0x56, 0x2f, 0x27, 0x0, 0x0, 0x20, 0x15, 0x28, 0xc, 0x22, 0x5e, + 0xe6, 0x17, 0x8c, 0x12, 0x0, 0x1a, 0x8f, 0xd7, 0x7a, 0x52, 0x3f, 0xee, 0xc7, 0xc1, 0xa7, 0x77, 0x2e, + 0xc7, 0xd1, 0xce, 0xa4, 0x7d, 0xc0, 0x99, 0x55, 0x96, 0x4d, 0x80, 0xe1, 0xae, 0xa2, 0x7f, 0x13, 0x71, + 0xa3, 0x8, 0x0, 0x16, 0xc3, 0x2, 0x24, 0x5c, 0xda, 0xf, 0x97, 0x29, 0x94, 0x49, 0x9, 0x86, 0x36, + 0xef, 0x41, 0xe, 0x20, 0x3, 0xcd, 0xc4, 0x77, 0xda, 0x19, 0xc4, 0x8, 0x0, 0x15, 0x1, 0xbf, 0xb9, + 0x7f, 0xb3, 0x1a, 0x92, 0xf9, 0xae, 0xf1, 0x39, 0xea, 0x5, 0x3d, 0xdf, 0x30, 0x2, 0xb2, 0x54, 0xdc, + 0x9e, 0x8, 0x0, 0x6, 0xf8, 0x8f, 0x15, 0x7c, 0x70, 0x50, 0x22, 0x6e, 0xcc, 0x1f, 0x0, 0x8, 0x68, + 0x48, 0x42, 0x9e, 0xa0, 0x5a, 0x61, 0xc8, 0x11, 0x0, 0x0, 0x2e, 0xdc}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x92, 0x47, 0x2e, 0x54, 0xe1, 0x4c, 0x21, 0xff, 0x4e, 0x18, 0xee, 0xba, 0x31, + 0x1e, 0xfe, 0x35, 0xd, 0x99, 0x4c, 0xbc, 0x10, 0xdb, 0x8e, 0x77, 0x71, 0x9}; + uint8_t bytesprops1[] = {0x22, 0x1c, 0x8, 0xe, 0xea, 0x34, 0xfc, 0x5e, 0x2f, 0x9b, 0xd5, 0x43, 0xf7, 0xe7}; + uint8_t bytesprops2[] = {0x8f, 0xd7, 0x7a, 0x52, 0x3f, 0xee, 0xc7, 0xc1, 0xa7, 0x77, 0x2e, 0xc7, 0xd1, + 0xce, 0xa4, 0x7d, 0xc0, 0x99, 0x55, 0x96, 0x4d, 0x80, 0xe1, 0xae, 0xa2, 0x7f}; + uint8_t bytesprops3[] = {0xc3, 0x2, 0x24, 0x5c, 0xda, 0xf, 0x97, 0x29, 0x94, 0x49, 0x9, + 0x86, 0x36, 0xef, 0x41, 0xe, 0x20, 0x3, 0xcd, 0xc4, 0x77, 0xda}; + uint8_t bytesprops4[] = {0x1, 0xbf, 0xb9, 0x7f, 0xb3, 0x1a, 0x92, 0xf9, 0xae, 0xf1, 0x39, + 0xea, 0x5, 0x3d, 0xdf, 0x30, 0x2, 0xb2, 0x54, 0xdc, 0x9e}; + uint8_t bytesprops5[] = {0xf8, 0x8f, 0x15, 0x7c, 0x70, 0x50}; + uint8_t bytesprops6[] = {0x68, 0x48, 0x42, 0x9e, 0xa0, 0x5a, 0x61, 0xc8}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 0}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {15, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15098}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 16}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 28733}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {9, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24280}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 23}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {21, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 20827}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {17, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {25, (char*)&bytesprops5}, .v = {4, (char*)&bytesprops6}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 15182}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {28, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 20}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 222}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 6333}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 6463}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {26, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 9}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 19}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 32175}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 22063}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 8213}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 24294}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 140}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {26, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 29091}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {22, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 196}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {21, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {6, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28364}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {8, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11996}}, }; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {22, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 128, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 161, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoDisconnectWithWill [PropSessionExpiryInterval 31061,PropSubscriptionIdentifier -// 5,PropMessageExpiryInterval 25869,PropPayloadFormatIndicator 125,PropTopicAlias 20089,PropContentType -// "\tnB",PropWildcardSubscriptionAvailable 185,PropRetainAvailable 120,PropServerReference -// "\GSU\n8?1^\150\231\169C\130\223\222\226\&1\171\149\158",PropAuthenticationMethod -// "\252\USj\163}\SO\185r$\156EE\229\178",PropRequestProblemInformation 135,PropSessionExpiryInterval -// 15470,PropRetainAvailable 5,PropAuthenticationData -// "&\r\242\176\&0\141SB\ESC\132\DEL\213.\a\EOTS\236\193P\DC4",PropReasonString -// "Z\ETB\144\216:\228\159\232\203\150\204R\157\231\253\NUL\133\134\150\237{\167\198\156\195\v\167\&2\SO",PropAuthenticationData -// "\SYNo\207_MF\139o\164W\185\DLE",PropMessageExpiryInterval 7386,PropMessageExpiryInterval -// 16514,PropMessageExpiryInterval 13233,PropSharedSubscriptionAvailable 4,PropSharedSubscriptionAvailable -// 218,PropCorrelationData "\199\&4",PropTopicAlias 1317,PropAuthenticationData -// "\222\ESC\244\229R\FS\255\183\193\GS\161\191\EOT|w\164\230Q",PropMessageExpiryInterval -// 30353,PropMessageExpiryInterval 13107,PropAssignedClientIdentifier "\170F\238",PropServerReference -// "\192\245\207\232\189Z\199\142\DC3\132\212J\217\223/j\b"] +// DisconnectRequest DiscoSubscriptionIdentifiersNotSupported [PropSubscriptionIdentifier 18,PropCorrelationData +// "\226\CAN\153\168-\DLE}\NUL\200\&6\242\EM\170J\t\176o\a\175\164",PropUserProperty "\129\156\226\171 +// \223\EMn\187\CAN?:\GS\243)?\239\SOHj" "c6u\DC3?L!\243\221$",PropSubscriptionIdentifier 19,PropContentType +// "\177\146\254\174\DLE (\235D\146",PropTopicAliasMaximum 16812,PropTopicAliasMaximum 10572,PropMessageExpiryInterval +// 14029] TEST(Disco5QCTest, Encode22) { - uint8_t pkt[] = {0xe0, 0xe8, 0x1, 0x4, 0xe5, 0x1, 0x11, 0x0, 0x0, 0x79, 0x55, 0xb, 0x5, 0x2, 0x0, 0x0, 0x65, - 0xd, 0x1, 0x7d, 0x23, 0x4e, 0x79, 0x3, 0x0, 0x3, 0x9, 0x6e, 0x42, 0x28, 0xb9, 0x25, 0x78, 0x1c, - 0x0, 0x13, 0x1d, 0x55, 0xa, 0x38, 0x3f, 0x31, 0x5e, 0x96, 0xe7, 0xa9, 0x43, 0x82, 0xdf, 0xde, 0xe2, - 0x31, 0xab, 0x95, 0x9e, 0x15, 0x0, 0xe, 0xfc, 0x1f, 0x6a, 0xa3, 0x7d, 0xe, 0xb9, 0x72, 0x24, 0x9c, - 0x45, 0x45, 0xe5, 0xb2, 0x17, 0x87, 0x11, 0x0, 0x0, 0x3c, 0x6e, 0x25, 0x5, 0x16, 0x0, 0x14, 0x26, - 0xd, 0xf2, 0xb0, 0x30, 0x8d, 0x53, 0x42, 0x1b, 0x84, 0x7f, 0xd5, 0x2e, 0x7, 0x4, 0x53, 0xec, 0xc1, - 0x50, 0x14, 0x1f, 0x0, 0x1d, 0x5a, 0x17, 0x90, 0xd8, 0x3a, 0xe4, 0x9f, 0xe8, 0xcb, 0x96, 0xcc, 0x52, - 0x9d, 0xe7, 0xfd, 0x0, 0x85, 0x86, 0x96, 0xed, 0x7b, 0xa7, 0xc6, 0x9c, 0xc3, 0xb, 0xa7, 0x32, 0xe, - 0x16, 0x0, 0xc, 0x16, 0x6f, 0xcf, 0x5f, 0x4d, 0x46, 0x8b, 0x6f, 0xa4, 0x57, 0xb9, 0x10, 0x2, 0x0, - 0x0, 0x1c, 0xda, 0x2, 0x0, 0x0, 0x40, 0x82, 0x2, 0x0, 0x0, 0x33, 0xb1, 0x2a, 0x4, 0x2a, 0xda, - 0x9, 0x0, 0x2, 0xc7, 0x34, 0x23, 0x5, 0x25, 0x16, 0x0, 0x12, 0xde, 0x1b, 0xf4, 0xe5, 0x52, 0x1c, - 0xff, 0xb7, 0xc1, 0x1d, 0xa1, 0xbf, 0x4, 0x7c, 0x77, 0xa4, 0xe6, 0x51, 0x2, 0x0, 0x0, 0x76, 0x91, - 0x2, 0x0, 0x0, 0x33, 0x33, 0x12, 0x0, 0x3, 0xaa, 0x46, 0xee, 0x1c, 0x0, 0x11, 0xc0, 0xf5, 0xcf, - 0xe8, 0xbd, 0x5a, 0xc7, 0x8e, 0x13, 0x84, 0xd4, 0x4a, 0xd9, 0xdf, 0x2f, 0x6a, 0x8}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x9, 0x6e, 0x42}; - uint8_t bytesprops1[] = {0x1d, 0x55, 0xa, 0x38, 0x3f, 0x31, 0x5e, 0x96, 0xe7, 0xa9, - 0x43, 0x82, 0xdf, 0xde, 0xe2, 0x31, 0xab, 0x95, 0x9e}; - uint8_t bytesprops2[] = {0xfc, 0x1f, 0x6a, 0xa3, 0x7d, 0xe, 0xb9, 0x72, 0x24, 0x9c, 0x45, 0x45, 0xe5, 0xb2}; - uint8_t bytesprops3[] = {0x26, 0xd, 0xf2, 0xb0, 0x30, 0x8d, 0x53, 0x42, 0x1b, 0x84, - 0x7f, 0xd5, 0x2e, 0x7, 0x4, 0x53, 0xec, 0xc1, 0x50, 0x14}; - uint8_t bytesprops4[] = {0x5a, 0x17, 0x90, 0xd8, 0x3a, 0xe4, 0x9f, 0xe8, 0xcb, 0x96, 0xcc, 0x52, 0x9d, 0xe7, 0xfd, - 0x0, 0x85, 0x86, 0x96, 0xed, 0x7b, 0xa7, 0xc6, 0x9c, 0xc3, 0xb, 0xa7, 0x32, 0xe}; - uint8_t bytesprops5[] = {0x16, 0x6f, 0xcf, 0x5f, 0x4d, 0x46, 0x8b, 0x6f, 0xa4, 0x57, 0xb9, 0x10}; - uint8_t bytesprops6[] = {0xc7, 0x34}; - uint8_t bytesprops7[] = {0xde, 0x1b, 0xf4, 0xe5, 0x52, 0x1c, 0xff, 0xb7, 0xc1, - 0x1d, 0xa1, 0xbf, 0x4, 0x7c, 0x77, 0xa4, 0xe6, 0x51}; - uint8_t bytesprops8[] = {0xaa, 0x46, 0xee}; - uint8_t bytesprops9[] = {0xc0, 0xf5, 0xcf, 0xe8, 0xbd, 0x5a, 0xc7, 0x8e, 0x13, - 0x84, 0xd4, 0x4a, 0xd9, 0xdf, 0x2f, 0x6a, 0x8}; + uint8_t pkt[] = {0xe0, 0x57, 0xa1, 0x55, 0xb, 0x12, 0x9, 0x0, 0x14, 0xe2, 0x18, 0x99, 0xa8, 0x2d, 0x10, + 0x7d, 0x0, 0xc8, 0x36, 0xf2, 0x19, 0xaa, 0x4a, 0x9, 0xb0, 0x6f, 0x7, 0xaf, 0xa4, 0x26, + 0x0, 0x13, 0x81, 0x9c, 0xe2, 0xab, 0x20, 0xdf, 0x19, 0x6e, 0xbb, 0x18, 0x3f, 0x3a, 0x1d, + 0xf3, 0x29, 0x3f, 0xef, 0x1, 0x6a, 0x0, 0xa, 0x63, 0x36, 0x75, 0x13, 0x3f, 0x4c, 0x21, + 0xf3, 0xdd, 0x24, 0xb, 0x13, 0x3, 0x0, 0xa, 0xb1, 0x92, 0xfe, 0xae, 0x10, 0x20, 0x28, + 0xeb, 0x44, 0x92, 0x22, 0x41, 0xac, 0x22, 0x29, 0x4c, 0x2, 0x0, 0x0, 0x36, 0xcd}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0xe2, 0x18, 0x99, 0xa8, 0x2d, 0x10, 0x7d, 0x0, 0xc8, 0x36, + 0xf2, 0x19, 0xaa, 0x4a, 0x9, 0xb0, 0x6f, 0x7, 0xaf, 0xa4}; + uint8_t bytesprops2[] = {0x63, 0x36, 0x75, 0x13, 0x3f, 0x4c, 0x21, 0xf3, 0xdd, 0x24}; + uint8_t bytesprops1[] = {0x81, 0x9c, 0xe2, 0xab, 0x20, 0xdf, 0x19, 0x6e, 0xbb, 0x18, + 0x3f, 0x3a, 0x1d, 0xf3, 0x29, 0x3f, 0xef, 0x1, 0x6a}; + uint8_t bytesprops3[] = {0xb1, 0x92, 0xfe, 0xae, 0x10, 0x20, 0x28, 0xeb, 0x44, 0x92}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 31061}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 5}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25869}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 125}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20089}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 185}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 120}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {19, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {14, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 135}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 15470}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 5}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {20, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {12, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 7386}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16514}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13233}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 218}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 1317}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30353}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13107}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {3, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {17, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 18}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops1}, .v = {10, (char*)&bytesprops2}}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 19}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {10, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16812}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 10572}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 14029}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {8, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 4, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 161, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoTopicAliasInvalid [PropTopicAliasMaximum 31305,PropMaximumPacketSize -// 19902,PropMessageExpiryInterval 13846,PropSubscriptionIdentifierAvailable 13,PropRequestProblemInformation -// 11,PropSubscriptionIdentifierAvailable 64,PropTopicAlias 5928,PropResponseTopic -// "{D\229\137\247\213\252S\150\169p\161\215\254\GS\DC4\USp&=\ETX\181<=+\ETB\217\152\&2!",PropReasonString -// "\SI4\128\208\198\169\168Ur\198@\148\238\161\177G\NAK\142\149\228\144;\254\135\183l\211",PropMessageExpiryInterval -// 21979,PropTopicAlias 7370,PropSessionExpiryInterval 11718,PropUserProperty -// "\193\181sq\EOT\244\139\246\139\251r\STX\\\221A\DC2\190S/" "\141\193\210\155"] +// DisconnectRequest DiscoTopicNameInvalid [PropCorrelationData +// "g<:\200\251\252\136\153\GS\222\166}\175x0@i\164_W(\177\213",PropSubscriptionIdentifier 8,PropMessageExpiryInterval +// 25949,PropCorrelationData "\157|@\164x\239\231\187\US\156\181 {\246Cv\EM|@\213\245\140x",PropWillDelayInterval +// 5293,PropUserProperty "" "[s>v\vR\167<\SUB5\241\202",PropContentType +// "\154\ETX\225\n\203\242\n\186r\v\221\191;\235HY\174,\178\152\234\226\165\205\194k\187Q\249",PropAuthenticationMethod +// "\DEL\150Y",PropAssignedClientIdentifier ":\SOH\187\185\&9m\142\185\SO",PropServerReference +// "\160\EMp[-'\220\168(\230\SOH0p\133%=",PropReceiveMaximum 27055,PropSharedSubscriptionAvailable +// 150,PropRequestProblemInformation 244,PropAuthenticationMethod "",PropWillDelayInterval 9374,PropMaximumQoS +// 39,PropWildcardSubscriptionAvailable 223] TEST(Disco5QCTest, Encode23) { - uint8_t pkt[] = {0xe0, 0x80, 0x1, 0x94, 0x7e, 0x22, 0x7a, 0x49, 0x27, 0x0, 0x0, 0x4d, 0xbe, 0x2, 0x0, 0x0, 0x36, - 0x16, 0x29, 0xd, 0x17, 0xb, 0x29, 0x40, 0x23, 0x17, 0x28, 0x8, 0x0, 0x1e, 0x7b, 0x44, 0xe5, 0x89, - 0xf7, 0xd5, 0xfc, 0x53, 0x96, 0xa9, 0x70, 0xa1, 0xd7, 0xfe, 0x1d, 0x14, 0x1f, 0x70, 0x26, 0x3d, 0x3, - 0xb5, 0x3c, 0x3d, 0x2b, 0x17, 0xd9, 0x98, 0x32, 0x21, 0x1f, 0x0, 0x1b, 0xf, 0x34, 0x80, 0xd0, 0xc6, - 0xa9, 0xa8, 0x55, 0x72, 0xc6, 0x40, 0x94, 0xee, 0xa1, 0xb1, 0x47, 0x15, 0x8e, 0x95, 0xe4, 0x90, 0x3b, - 0xfe, 0x87, 0xb7, 0x6c, 0xd3, 0x2, 0x0, 0x0, 0x55, 0xdb, 0x23, 0x1c, 0xca, 0x11, 0x0, 0x0, 0x2d, - 0xc6, 0x26, 0x0, 0x13, 0xc1, 0xb5, 0x73, 0x71, 0x4, 0xf4, 0x8b, 0xf6, 0x8b, 0xfb, 0x72, 0x2, 0x5c, - 0xdd, 0x41, 0x12, 0xbe, 0x53, 0x2f, 0x0, 0x4, 0x8d, 0xc1, 0xd2, 0x9b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x7b, 0x44, 0xe5, 0x89, 0xf7, 0xd5, 0xfc, 0x53, 0x96, 0xa9, 0x70, 0xa1, 0xd7, 0xfe, 0x1d, - 0x14, 0x1f, 0x70, 0x26, 0x3d, 0x3, 0xb5, 0x3c, 0x3d, 0x2b, 0x17, 0xd9, 0x98, 0x32, 0x21}; - uint8_t bytesprops1[] = {0xf, 0x34, 0x80, 0xd0, 0xc6, 0xa9, 0xa8, 0x55, 0x72, 0xc6, 0x40, 0x94, 0xee, 0xa1, - 0xb1, 0x47, 0x15, 0x8e, 0x95, 0xe4, 0x90, 0x3b, 0xfe, 0x87, 0xb7, 0x6c, 0xd3}; - uint8_t bytesprops3[] = {0x8d, 0xc1, 0xd2, 0x9b}; - uint8_t bytesprops2[] = {0xc1, 0xb5, 0x73, 0x71, 0x4, 0xf4, 0x8b, 0xf6, 0x8b, 0xfb, - 0x72, 0x2, 0x5c, 0xdd, 0x41, 0x12, 0xbe, 0x53, 0x2f}; + uint8_t pkt[] = {0xe0, 0xac, 0x1, 0x90, 0xa9, 0x1, 0x9, 0x0, 0x17, 0x67, 0x3c, 0x3a, 0xc8, 0xfb, 0xfc, 0x88, + 0x99, 0x1d, 0xde, 0xa6, 0x7d, 0xaf, 0x78, 0x30, 0x40, 0x69, 0xa4, 0x5f, 0x57, 0x28, 0xb1, 0xd5, + 0xb, 0x8, 0x2, 0x0, 0x0, 0x65, 0x5d, 0x9, 0x0, 0x17, 0x9d, 0x7c, 0x40, 0xa4, 0x78, 0xef, + 0xe7, 0xbb, 0x1f, 0x9c, 0xb5, 0x20, 0x7b, 0xf6, 0x43, 0x76, 0x19, 0x7c, 0x40, 0xd5, 0xf5, 0x8c, + 0x78, 0x18, 0x0, 0x0, 0x14, 0xad, 0x26, 0x0, 0x0, 0x0, 0xc, 0x5b, 0x73, 0x3e, 0x76, 0xb, + 0x52, 0xa7, 0x3c, 0x1a, 0x35, 0xf1, 0xca, 0x3, 0x0, 0x1d, 0x9a, 0x3, 0xe1, 0xa, 0xcb, 0xf2, + 0xa, 0xba, 0x72, 0xb, 0xdd, 0xbf, 0x3b, 0xeb, 0x48, 0x59, 0xae, 0x2c, 0xb2, 0x98, 0xea, 0xe2, + 0xa5, 0xcd, 0xc2, 0x6b, 0xbb, 0x51, 0xf9, 0x15, 0x0, 0x3, 0x7f, 0x96, 0x59, 0x12, 0x0, 0x9, + 0x3a, 0x1, 0xbb, 0xb9, 0x39, 0x6d, 0x8e, 0xb9, 0xe, 0x1c, 0x0, 0x10, 0xa0, 0x19, 0x70, 0x5b, + 0x2d, 0x27, 0xdc, 0xa8, 0x28, 0xe6, 0x1, 0x30, 0x70, 0x85, 0x25, 0x3d, 0x21, 0x69, 0xaf, 0x2a, + 0x96, 0x17, 0xf4, 0x15, 0x0, 0x0, 0x18, 0x0, 0x0, 0x24, 0x9e, 0x24, 0x27, 0x28, 0xdf}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x67, 0x3c, 0x3a, 0xc8, 0xfb, 0xfc, 0x88, 0x99, 0x1d, 0xde, 0xa6, 0x7d, + 0xaf, 0x78, 0x30, 0x40, 0x69, 0xa4, 0x5f, 0x57, 0x28, 0xb1, 0xd5}; + uint8_t bytesprops1[] = {0x9d, 0x7c, 0x40, 0xa4, 0x78, 0xef, 0xe7, 0xbb, 0x1f, 0x9c, 0xb5, 0x20, + 0x7b, 0xf6, 0x43, 0x76, 0x19, 0x7c, 0x40, 0xd5, 0xf5, 0x8c, 0x78}; + uint8_t bytesprops3[] = {0x5b, 0x73, 0x3e, 0x76, 0xb, 0x52, 0xa7, 0x3c, 0x1a, 0x35, 0xf1, 0xca}; + uint8_t bytesprops2[] = {0}; + uint8_t bytesprops4[] = {0x9a, 0x3, 0xe1, 0xa, 0xcb, 0xf2, 0xa, 0xba, 0x72, 0xb, 0xdd, 0xbf, 0x3b, 0xeb, 0x48, + 0x59, 0xae, 0x2c, 0xb2, 0x98, 0xea, 0xe2, 0xa5, 0xcd, 0xc2, 0x6b, 0xbb, 0x51, 0xf9}; + uint8_t bytesprops5[] = {0x7f, 0x96, 0x59}; + uint8_t bytesprops6[] = {0x3a, 0x1, 0xbb, 0xb9, 0x39, 0x6d, 0x8e, 0xb9, 0xe}; + uint8_t bytesprops7[] = {0xa0, 0x19, 0x70, 0x5b, 0x2d, 0x27, 0xdc, 0xa8, + 0x28, 0xe6, 0x1, 0x30, 0x70, 0x85, 0x25, 0x3d}; + uint8_t bytesprops8[] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 31305}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 19902}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13846}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 13}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 64}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 5928}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {30, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {27, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 21979}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 7370}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 11718}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {19, (char*)&bytesprops2}, .v = {4, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 8}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 25949}}, + {.prop = (lwmqtt_prop_t)9, .value = {.str = {23, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5293}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {0, (char*)&bytesprops2}, .v = {12, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {29, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {3, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {9, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {16, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 27055}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 150}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 244}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {0, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 9374}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 39}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 223}}, }; - lwmqtt_properties_t props = {13, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {17, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 148, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 144, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoConnectionRateExceeded [PropContentType -// "g\SYN5\222\184\174\217\155\181\204\230\138\177\SUBC\147",PropUserProperty "\178@\SI\222{\DC1\203\154\172\209\154&" -// "\NUL\217z\201\200\139\219O\177%G\208\131d\178f",PropTopicAliasMaximum 28053,PropRequestResponseInformation -// 144,PropAssignedClientIdentifier "D",PropServerReference -// "\155\207\241W\227}\208\174DJ\239",PropWildcardSubscriptionAvailable 36,PropResponseTopic -// "\ETX\207\RS`\180\182\171",PropMaximumPacketSize 10715,PropServerReference -// "\220\243Y\157\161\&2\229\ENQ\156\130\FSr(t",PropSubscriptionIdentifier 22,PropAuthenticationMethod -// "\f\155d&\SOT\t\183q\168\229\234i\172\161@\156",PropServerReference -// "b!\229\SUB\b\216\203w\254$\192\145\191\232w=i$\135\142\241\197O=\229Q4\131",PropReceiveMaximum -// 22291,PropSubscriptionIdentifierAvailable 250,PropContentType -// "\183J\171\207'X_d\135'o\250\&9\222\134\SOH\"\137$H\128\157i\139\211",PropRetainAvailable 151,PropMaximumPacketSize -// 26309,PropSubscriptionIdentifierAvailable 242,PropSubscriptionIdentifierAvailable -// 230,PropWildcardSubscriptionAvailable 194,PropResponseTopic "\131\195R\237",PropTopicAliasMaximum -// 15601,PropSubscriptionIdentifier 15,PropSubscriptionIdentifierAvailable 226,PropReasonString -// "\239\129\240\198a\US\NAK`\242\199a\166\251<\147%\r\SYN\174z",PropAuthenticationMethod -// "vu\DC3\140\FSk\205\226\183v\ETX+\RSY\135\141\CAN\212\148\243\220",PropSessionExpiryInterval 21456,PropUserProperty -// "\180\206" "\NAKs\132"] +// DisconnectRequest DiscoQoSNotSupported [PropMessageExpiryInterval 8720,PropReceiveMaximum +// 31958,PropMessageExpiryInterval 31814,PropMessageExpiryInterval 24040,PropSubscriptionIdentifier 2] TEST(Disco5QCTest, Encode24) { - uint8_t pkt[] = { - 0xe0, 0x9f, 0x2, 0x9f, 0x9c, 0x2, 0x3, 0x0, 0x10, 0x67, 0x16, 0x35, 0xde, 0xb8, 0xae, 0xd9, 0x9b, 0xb5, 0xcc, - 0xe6, 0x8a, 0xb1, 0x1a, 0x43, 0x93, 0x26, 0x0, 0xc, 0xb2, 0x40, 0xf, 0xde, 0x7b, 0x11, 0xcb, 0x9a, 0xac, 0xd1, - 0x9a, 0x26, 0x0, 0x10, 0x0, 0xd9, 0x7a, 0xc9, 0xc8, 0x8b, 0xdb, 0x4f, 0xb1, 0x25, 0x47, 0xd0, 0x83, 0x64, 0xb2, - 0x66, 0x22, 0x6d, 0x95, 0x19, 0x90, 0x12, 0x0, 0x1, 0x44, 0x1c, 0x0, 0xb, 0x9b, 0xcf, 0xf1, 0x57, 0xe3, 0x7d, - 0xd0, 0xae, 0x44, 0x4a, 0xef, 0x28, 0x24, 0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d4, 0x94, 0xf3, 0xdc, 0x11, 0x0, 0x0, 0x53, 0xd0, 0x26, 0x0, 0x2, 0xb4, 0xce, - 0x0, 0x3, 0x15, 0x73, 0x84}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x67, 0x16, 0x35, 0xde, 0xb8, 0xae, 0xd9, 0x9b, - 0xb5, 0xcc, 0xe6, 0x8a, 0xb1, 0x1a, 0x43, 0x93}; - uint8_t bytesprops2[] = {0x0, 0xd9, 0x7a, 0xc9, 0xc8, 0x8b, 0xdb, 0x4f, - 0xb1, 0x25, 0x47, 0xd0, 0x83, 0x64, 0xb2, 0x66}; - uint8_t bytesprops1[] = {0xb2, 0x40, 0xf, 0xde, 0x7b, 0x11, 0xcb, 0x9a, 0xac, 0xd1, 0x9a, 0x26}; - uint8_t bytesprops3[] = {0x44}; - uint8_t bytesprops4[] = {0x9b, 0xcf, 0xf1, 0x57, 0xe3, 0x7d, 0xd0, 0xae, 0x44, 0x4a, 0xef}; - uint8_t bytesprops5[] = {0x3, 0xcf, 0x1e, 0x60, 0xb4, 0xb6, 0xab}; - uint8_t bytesprops6[] = {0xdc, 0xf3, 0x59, 0x9d, 0xa1, 0x32, 0xe5, 0x5, 0x9c, 0x82, 0x1c, 0x72, 0x28, 0x74}; - uint8_t bytesprops7[] = {0xc, 0x9b, 0x64, 0x26, 0xe, 0x54, 0x9, 0xb7, 0x71, - 0xa8, 0xe5, 0xea, 0x69, 0xac, 0xa1, 0x40, 0x9c}; - uint8_t bytesprops8[] = {0x62, 0x21, 0xe5, 0x1a, 0x8, 0xd8, 0xcb, 0x77, 0xfe, 0x24, 0xc0, 0x91, 0xbf, 0xe8, - 0x77, 0x3d, 0x69, 0x24, 0x87, 0x8e, 0xf1, 0xc5, 0x4f, 0x3d, 0xe5, 0x51, 0x34, 0x83}; - uint8_t bytesprops9[] = {0xb7, 0x4a, 0xab, 0xcf, 0x27, 0x58, 0x5f, 0x64, 0x87, 0x27, 0x6f, 0xfa, 0x39, - 0xde, 0x86, 0x1, 0x22, 0x89, 0x24, 0x48, 0x80, 0x9d, 0x69, 0x8b, 0xd3}; - uint8_t bytesprops10[] = {0x83, 0xc3, 0x52, 0xed}; - uint8_t bytesprops11[] = {0xef, 0x81, 0xf0, 0xc6, 0x61, 0x1f, 0x15, 0x60, 0xf2, 0xc7, - 0x61, 0xa6, 0xfb, 0x3c, 0x93, 0x25, 0xd, 0x16, 0xae, 0x7a}; - uint8_t bytesprops12[] = {0x76, 0x75, 0x13, 0x8c, 0x1c, 0x6b, 0xcd, 0xe2, 0xb7, 0x76, 0x3, - 0x2b, 0x1e, 0x59, 0x87, 0x8d, 0x18, 0xd4, 0x94, 0xf3, 0xdc}; - uint8_t bytesprops14[] = {0x15, 0x73, 0x84}; - uint8_t bytesprops13[] = {0xb4, 0xce}; + uint8_t pkt[] = {0xe0, 0x16, 0x9b, 0x14, 0x2, 0x0, 0x0, 0x22, 0x10, 0x21, 0x7c, 0xd6, + 0x2, 0x0, 0x0, 0x7c, 0x46, 0x2, 0x0, 0x0, 0x5d, 0xe8, 0xb, 0x2}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)3, .value = {.str = {16, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {12, (char*)&bytesprops1}, .v = {16, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 28053}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 144}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {11, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 36}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {7, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 10715}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {14, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 22}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 22291}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 250}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {25, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 151}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26309}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 242}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 230}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {4, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 15601}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 15}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 226}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {20, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {21, (char*)&bytesprops12}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21456}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {2, (char*)&bytesprops13}, .v = {3, (char*)&bytesprops14}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8720}}, {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 31958}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31814}}, {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24040}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 2}}, }; - lwmqtt_properties_t props = {29, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 159, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoRetainNotSupported [PropSubscriptionIdentifierAvailable 58,PropRequestProblemInformation -// 217,PropResponseInformation "\DC4\193J\155p\181\135\211[)L",PropSubscriptionIdentifierAvailable -// 58,PropSubscriptionIdentifier 3,PropWildcardSubscriptionAvailable 161,PropSubscriptionIdentifier -// 17,PropResponseInformation "\194\rO\216=dC\161\205|l)\ENQ@\181+E",PropTopicAlias 31601,PropContentType -// "h_\f)\EMG\248\v\221f\ETB!\248I\ETB\169l\129\252",PropAuthenticationMethod -// "S\211s\157\240\135\144;\206\244",PropSharedSubscriptionAvailable 122,PropUserProperty "D\151\249\136\DC4\250\DC4" -// "Y\224\243\EOTR,\157\153\228^",PropWildcardSubscriptionAvailable 247,PropSubscriptionIdentifierAvailable -// 18,PropWillDelayInterval 28646,PropMessageExpiryInterval 8402,PropMessageExpiryInterval 17681,PropMaximumQoS 12] +// DisconnectRequest DiscoMalformedPacket [PropRequestResponseInformation 156,PropMaximumPacketSize 26033,PropTopicAlias +// 30140,PropReasonString "G",PropSubscriptionIdentifierAvailable 12,PropSessionExpiryInterval 861,PropReceiveMaximum +// 6155,PropWillDelayInterval 6406,PropTopicAlias 27382,PropResponseInformation +// "!\214\198CVw\194\239\154\255\&3UK\DC2",PropWildcardSubscriptionAvailable 94,PropSubscriptionIdentifier +// 23,PropResponseInformation +// "S\162\211\150\142\241>.g\248\174\216\206\173\200\131\246]\202U\166Bj\DC1",PropMessageExpiryInterval +// 15853,PropRequestResponseInformation 142,PropSessionExpiryInterval 21968,PropAssignedClientIdentifier +// "\165\244\ETB*\144\241\&7\137\ENQ0p\178`\DC2\131\CAN\ETB",PropRetainAvailable 229,PropAuthenticationMethod +// "\158\194\191\227\234CE\237\179\173f\206\221",PropWildcardSubscriptionAvailable 5,PropAuthenticationMethod +// "\CANc:\211\239\217\234\255\SOJ\ACK\223\189\147\ETB\EM\191\254\SOH N\188e\204\149\132\152",PropServerReference +// "\194\RS\189\&0\200U\147\178-\252\229\159\152erp\174&\167|\n7G\194\244\190\233\&9",PropWildcardSubscriptionAvailable +// 252,PropMessageExpiryInterval 31094,PropAuthenticationData "7*\241#",PropTopicAliasMaximum 20164] TEST(Disco5QCTest, Encode25) { - uint8_t pkt[] = {0xe0, 0x84, 0x1, 0x9a, 0x81, 0x1, 0x29, 0x3a, 0x17, 0xd9, 0x1a, 0x0, 0xb, 0x14, 0xc1, 0x4a, 0x9b, - 0x70, 0xb5, 0x87, 0xd3, 0x5b, 0x29, 0x4c, 0x29, 0x3a, 0xb, 0x3, 0x28, 0xa1, 0xb, 0x11, 0x1a, 0x0, - 0x11, 0xc2, 0xd, 0x4f, 0xd8, 0x3d, 0x64, 0x43, 0xa1, 0xcd, 0x7c, 0x6c, 0x29, 0x5, 0x40, 0xb5, 0x2b, - 0x45, 0x23, 0x7b, 0x71, 0x3, 0x0, 0x13, 0x68, 0x5f, 0xc, 0x29, 0x19, 0x47, 0xf8, 0xb, 0xdd, 0x66, - 0x17, 0x21, 0xf8, 0x49, 0x17, 0xa9, 0x6c, 0x81, 0xfc, 0x15, 0x0, 0xa, 0x53, 0xd3, 0x73, 0x9d, 0xf0, - 0x87, 0x90, 0x3b, 0xce, 0xf4, 0x2a, 0x7a, 0x26, 0x0, 0x7, 0x44, 0x97, 0xf9, 0x88, 0x14, 0xfa, 0x14, - 0x0, 0xa, 0x59, 0xe0, 0xf3, 0x4, 0x52, 0x2c, 0x9d, 0x99, 0xe4, 0x5e, 0x28, 0xf7, 0x29, 0x12, 0x18, - 0x0, 0x0, 0x6f, 0xe6, 0x2, 0x0, 0x0, 0x20, 0xd2, 0x2, 0x0, 0x0, 0x45, 0x11, 0x24, 0xc}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x14, 0xc1, 0x4a, 0x9b, 0x70, 0xb5, 0x87, 0xd3, 0x5b, 0x29, 0x4c}; - uint8_t bytesprops1[] = {0xc2, 0xd, 0x4f, 0xd8, 0x3d, 0x64, 0x43, 0xa1, 0xcd, - 0x7c, 0x6c, 0x29, 0x5, 0x40, 0xb5, 0x2b, 0x45}; - uint8_t bytesprops2[] = {0x68, 0x5f, 0xc, 0x29, 0x19, 0x47, 0xf8, 0xb, 0xdd, 0x66, - 0x17, 0x21, 0xf8, 0x49, 0x17, 0xa9, 0x6c, 0x81, 0xfc}; - uint8_t bytesprops3[] = {0x53, 0xd3, 0x73, 0x9d, 0xf0, 0x87, 0x90, 0x3b, 0xce, 0xf4}; - uint8_t bytesprops5[] = {0x59, 0xe0, 0xf3, 0x4, 0x52, 0x2c, 0x9d, 0x99, 0xe4, 0x5e}; - uint8_t bytesprops4[] = {0x44, 0x97, 0xf9, 0x88, 0x14, 0xfa, 0x14}; + uint8_t pkt[] = {0xe0, 0xd5, 0x1, 0x81, 0xd2, 0x1, 0x19, 0x9c, 0x27, 0x0, 0x0, 0x65, 0xb1, 0x23, 0x75, 0xbc, 0x1f, + 0x0, 0x1, 0x47, 0x29, 0xc, 0x11, 0x0, 0x0, 0x3, 0x5d, 0x21, 0x18, 0xb, 0x18, 0x0, 0x0, 0x19, + 0x6, 0x23, 0x6a, 0xf6, 0x1a, 0x0, 0xe, 0x21, 0xd6, 0xc6, 0x43, 0x56, 0x77, 0xc2, 0xef, 0x9a, 0xff, + 0x33, 0x55, 0x4b, 0x12, 0x28, 0x5e, 0xb, 0x17, 0x1a, 0x0, 0x18, 0x53, 0xa2, 0xd3, 0x96, 0x8e, 0xf1, + 0x3e, 0x2e, 0x67, 0xf8, 0xae, 0xd8, 0xce, 0xad, 0xc8, 0x83, 0xf6, 0x5d, 0xca, 0x55, 0xa6, 0x42, 0x6a, + 0x11, 0x2, 0x0, 0x0, 0x3d, 0xed, 0x19, 0x8e, 0x11, 0x0, 0x0, 0x55, 0xd0, 0x12, 0x0, 0x11, 0xa5, + 0xf4, 0x17, 0x2a, 0x90, 0xf1, 0x37, 0x89, 0x5, 0x30, 0x70, 0xb2, 0x60, 0x12, 0x83, 0x18, 0x17, 0x25, + 0xe5, 0x15, 0x0, 0xd, 0x9e, 0xc2, 0xbf, 0xe3, 0xea, 0x43, 0x45, 0xed, 0xb3, 0xad, 0x66, 0xce, 0xdd, + 0x28, 0x5, 0x15, 0x0, 0x1b, 0x18, 0x63, 0x3a, 0xd3, 0xef, 0xd9, 0xea, 0xff, 0xe, 0x4a, 0x6, 0xdf, + 0xbd, 0x93, 0x17, 0x19, 0xbf, 0xfe, 0x1, 0x20, 0x4e, 0xbc, 0x65, 0xcc, 0x95, 0x84, 0x98, 0x1c, 0x0, + 0x1c, 0xc2, 0x1e, 0xbd, 0x30, 0xc8, 0x55, 0x93, 0xb2, 0x2d, 0xfc, 0xe5, 0x9f, 0x98, 0x65, 0x72, 0x70, + 0xae, 0x26, 0xa7, 0x7c, 0xa, 0x37, 0x47, 0xc2, 0xf4, 0xbe, 0xe9, 0x39, 0x28, 0xfc, 0x2, 0x0, 0x0, + 0x79, 0x76, 0x16, 0x0, 0x4, 0x37, 0x2a, 0xf1, 0x23, 0x22, 0x4e, 0xc4}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x47}; + uint8_t bytesprops1[] = {0x21, 0xd6, 0xc6, 0x43, 0x56, 0x77, 0xc2, 0xef, 0x9a, 0xff, 0x33, 0x55, 0x4b, 0x12}; + uint8_t bytesprops2[] = {0x53, 0xa2, 0xd3, 0x96, 0x8e, 0xf1, 0x3e, 0x2e, 0x67, 0xf8, 0xae, 0xd8, + 0xce, 0xad, 0xc8, 0x83, 0xf6, 0x5d, 0xca, 0x55, 0xa6, 0x42, 0x6a, 0x11}; + uint8_t bytesprops3[] = {0xa5, 0xf4, 0x17, 0x2a, 0x90, 0xf1, 0x37, 0x89, 0x5, + 0x30, 0x70, 0xb2, 0x60, 0x12, 0x83, 0x18, 0x17}; + uint8_t bytesprops4[] = {0x9e, 0xc2, 0xbf, 0xe3, 0xea, 0x43, 0x45, 0xed, 0xb3, 0xad, 0x66, 0xce, 0xdd}; + uint8_t bytesprops5[] = {0x18, 0x63, 0x3a, 0xd3, 0xef, 0xd9, 0xea, 0xff, 0xe, 0x4a, 0x6, 0xdf, 0xbd, 0x93, + 0x17, 0x19, 0xbf, 0xfe, 0x1, 0x20, 0x4e, 0xbc, 0x65, 0xcc, 0x95, 0x84, 0x98}; + uint8_t bytesprops6[] = {0xc2, 0x1e, 0xbd, 0x30, 0xc8, 0x55, 0x93, 0xb2, 0x2d, 0xfc, 0xe5, 0x9f, 0x98, 0x65, + 0x72, 0x70, 0xae, 0x26, 0xa7, 0x7c, 0xa, 0x37, 0x47, 0xc2, 0xf4, 0xbe, 0xe9, 0x39}; + uint8_t bytesprops7[] = {0x37, 0x2a, 0xf1, 0x23}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {11, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 58}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 3}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 161}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 17}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 31601}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {10, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 122}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops4}, .v = {10, (char*)&bytesprops5}}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 247}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 18}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 28646}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8402}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 17681}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 26033}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 30140}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {1, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 861}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 6155}}, + {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 6406}}, + {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 27382}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 94}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {24, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 15853}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 142}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 21968}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {17, (char*)&bytesprops3}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 229}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {13, (char*)&bytesprops4}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 5}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops5}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {28, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)40, .value = {.byte = 252}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 31094}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {4, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 20164}}, }; - lwmqtt_properties_t props = {19, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {26, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 154, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 129, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoSubscriptionIdentifiersNotSupported [PropPayloadFormatIndicator -// 28,PropSharedSubscriptionAvailable 45,PropMessageExpiryInterval 13199,PropWillDelayInterval -// 5231,PropWillDelayInterval 19944,PropAuthenticationMethod -// "U\154\188R\198e\157k1&L\249\224c3\DC2pj",PropMessageExpiryInterval 8745,PropUserProperty -// "+\SOH\DLEJ\240\238\234j\188?I" "\DC1e\173\149K\DC4\193\225\194\207rT\131\145\153?9\SOH",PropRetainAvailable -// 173,PropRequestResponseInformation 24,PropUserProperty "\130@9\aQY\150" "\146\145 -// y9\245\187\FS\244\178\138\ETB\206O1\142\166\254\NAK\165\FS\197\249\243\150u\200\176\USj",PropRetainAvailable -// 139,PropMaximumPacketSize 5314,PropTopicAliasMaximum 3496,PropResponseTopic -// "f\DC3\225\223\SI\220\201\218\DC2R\STX\198\NAKy\210",PropMaximumPacketSize 22692,PropReceiveMaximum -// 15527,PropServerKeepAlive 14795,PropMessageExpiryInterval 23340,PropResponseTopic -// "aE\220\a6\175K\204",PropWildcardSubscriptionAvailable 236,PropRequestProblemInformation -// 163,PropRequestResponseInformation 56,PropPayloadFormatIndicator 73,PropTopicAliasMaximum 21923,PropMaximumPacketSize -// 24460,PropContentType "*\136,",PropSubscriptionIdentifier 0] +// DisconnectRequest DiscoNormalDisconnection [PropAssignedClientIdentifier +// "\ACK\tz\190\DC4\207y\by\201\235\129\145\253\169\231\251\132\148\231\233\&3\217\a",PropContentType +// "",PropUserProperty ")\188\173\181w|^\194+\210/\244\214E%'1*\132\203\NUL" +// "\216\241\222\RS\202H\223\172\214\180d\241p\175Z\DC3#B\183\ESC\GS",PropSessionExpiryInterval 16122,PropReceiveMaximum +// 24484,PropPayloadFormatIndicator 156,PropMessageExpiryInterval 32214,PropTopicAliasMaximum 11695,PropUserProperty +// "\SYN\176R\vjH\131\229p\246\193&A\131\148P\DEL3\171@\DC3k\178\SOH\222\ENQz" +// "\EM\250%\162\189\176n\238\184\235\194MqO\163\168\f\174<\192\217\171",PropReasonString "J\SYN",PropServerReference +// "\DC2\200In\185\170\188\170y|R\252\182A+*\244R\201\165\211",PropResponseInformation +// "\196\181n+\172/\171c\RS\231HyjK\ENQ\CAN\NAKJDN\132\170$\138&\147\134\154\189",PropSharedSubscriptionAvailable +// 88,PropMessageExpiryInterval 3069,PropSubscriptionIdentifier 13,PropRequestResponseInformation +// 117,PropAuthenticationData "Wu/\194\213\237\167\252\251g\185<\244\GS]",PropMessageExpiryInterval 1148,PropMaximumQoS +// 206,PropAuthenticationData "\153\134\GS\184\161*6M\143\192b,\224\EOT\232\GS\181rZ\172\208",PropRetainAvailable +// 56,PropServerKeepAlive 6281,PropResponseInformation "LZ\233\221\205\r1oQ\a0;\247\204\166=<\NUL\EM",PropReasonString +// "\190\226\181\151\128\vC~qZ\187\216\189\224\202",PropAuthenticationMethod +// "\213\242\150\235b\149\155\"\151\246\ENQ\239",PropRequestProblemInformation 146,PropSharedSubscriptionAvailable +// 34,PropPayloadFormatIndicator 230,PropMessageExpiryInterval 16918,PropTopicAliasMaximum 16975] TEST(Disco5QCTest, Encode26) { - uint8_t pkt[] = {0xe0, 0xcf, 0x1, 0xa1, 0xcc, 0x1, 0x1, 0x1c, 0x2a, 0x2d, 0x2, 0x0, 0x0, 0x33, 0x8f, 0x18, 0x0, - 0x0, 0x14, 0x6f, 0x18, 0x0, 0x0, 0x4d, 0xe8, 0x15, 0x0, 0x12, 0x55, 0x9a, 0xbc, 0x52, 0xc6, 0x65, - 0x9d, 0x6b, 0x31, 0x26, 0x4c, 0xf9, 0xe0, 0x63, 0x33, 0x12, 0x70, 0x6a, 0x2, 0x0, 0x0, 0x22, 0x29, - 0x26, 0x0, 0xb, 0x2b, 0x1, 0x10, 0x4a, 0xf0, 0xee, 0xea, 0x6a, 0xbc, 0x3f, 0x49, 0x0, 0x12, 0x11, - 0x65, 0xad, 0x95, 0x4b, 0x14, 0xc1, 0xe1, 0xc2, 0xcf, 0x72, 0x54, 0x83, 0x91, 0x99, 0x3f, 0x39, 0x1, - 0x25, 0xad, 0x19, 0x18, 0x26, 0x0, 0x7, 0x82, 0x40, 0x39, 0x7, 0x51, 0x59, 0x96, 0x0, 0x1e, 0x92, - 0x91, 0x20, 0x79, 0x39, 0xf5, 0xbb, 0x1c, 0xf4, 0xb2, 0x8a, 0x17, 0xce, 0x4f, 0x31, 0x8e, 0xa6, 0xfe, - 0x15, 0xa5, 0x1c, 0xc5, 0xf9, 0xf3, 0x96, 0x75, 0xc8, 0xb0, 0x1f, 0x6a, 0x25, 0x8b, 0x27, 0x0, 0x0, - 0x14, 0xc2, 0x22, 0xd, 0xa8, 0x8, 0x0, 0xf, 0x66, 0x13, 0xe1, 0xdf, 0xf, 0xdc, 0xc9, 0xda, 0x12, - 0x52, 0x2, 0xc6, 0x15, 0x79, 0xd2, 0x27, 0x0, 0x0, 0x58, 0xa4, 0x21, 0x3c, 0xa7, 0x13, 0x39, 0xcb, - 0x2, 0x0, 0x0, 0x5b, 0x2c, 0x8, 0x0, 0x8, 0x61, 0x45, 0xdc, 0x7, 0x36, 0xaf, 0x4b, 0xcc, 0x28, - 0xec, 0x17, 0xa3, 0x19, 0x38, 0x1, 0x49, 0x22, 0x55, 0xa3, 0x27, 0x0, 0x0, 0x5f, 0x8c, 0x3, 0x0, - 0x3, 0x2a, 0x88, 0x2c, 0xb, 0x0}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x55, 0x9a, 0xbc, 0x52, 0xc6, 0x65, 0x9d, 0x6b, 0x31, - 0x26, 0x4c, 0xf9, 0xe0, 0x63, 0x33, 0x12, 0x70, 0x6a}; - uint8_t bytesprops2[] = {0x11, 0x65, 0xad, 0x95, 0x4b, 0x14, 0xc1, 0xe1, 0xc2, - 0xcf, 0x72, 0x54, 0x83, 0x91, 0x99, 0x3f, 0x39, 0x1}; - uint8_t bytesprops1[] = {0x2b, 0x1, 0x10, 0x4a, 0xf0, 0xee, 0xea, 0x6a, 0xbc, 0x3f, 0x49}; - uint8_t bytesprops4[] = {0x92, 0x91, 0x20, 0x79, 0x39, 0xf5, 0xbb, 0x1c, 0xf4, 0xb2, 0x8a, 0x17, 0xce, 0x4f, 0x31, - 0x8e, 0xa6, 0xfe, 0x15, 0xa5, 0x1c, 0xc5, 0xf9, 0xf3, 0x96, 0x75, 0xc8, 0xb0, 0x1f, 0x6a}; - uint8_t bytesprops3[] = {0x82, 0x40, 0x39, 0x7, 0x51, 0x59, 0x96}; - uint8_t bytesprops5[] = {0x66, 0x13, 0xe1, 0xdf, 0xf, 0xdc, 0xc9, 0xda, 0x12, 0x52, 0x2, 0xc6, 0x15, 0x79, 0xd2}; - uint8_t bytesprops6[] = {0x61, 0x45, 0xdc, 0x7, 0x36, 0xaf, 0x4b, 0xcc}; - uint8_t bytesprops7[] = {0x2a, 0x88, 0x2c}; + uint8_t pkt[] = { + 0xe0, 0xdb, 0x2,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7, 0xfb, 0x84, 0x94, 0xe7, 0xe9, 0x33, 0xd9, 0x7}; + uint8_t bytesprops1[] = {0}; + uint8_t bytesprops3[] = {0xd8, 0xf1, 0xde, 0x1e, 0xca, 0x48, 0xdf, 0xac, 0xd6, 0xb4, 0x64, + 0xf1, 0x70, 0xaf, 0x5a, 0x13, 0x23, 0x42, 0xb7, 0x1b, 0x1d}; + uint8_t bytesprops2[] = {0x29, 0xbc, 0xad, 0xb5, 0x77, 0x7c, 0x5e, 0xc2, 0x2b, 0xd2, 0x2f, + 0xf4, 0xd6, 0x45, 0x25, 0x27, 0x31, 0x2a, 0x84, 0xcb, 0x0}; + uint8_t bytesprops5[] = {0x19, 0xfa, 0x25, 0xa2, 0xbd, 0xb0, 0x6e, 0xee, 0xb8, 0xeb, 0xc2, + 0x4d, 0x71, 0x4f, 0xa3, 0xa8, 0xc, 0xae, 0x3c, 0xc0, 0xd9, 0xab}; + uint8_t bytesprops4[] = {0x16, 0xb0, 0x52, 0xb, 0x6a, 0x48, 0x83, 0xe5, 0x70, 0xf6, 0xc1, 0x26, 0x41, 0x83, + 0x94, 0x50, 0x7f, 0x33, 0xab, 0x40, 0x13, 0x6b, 0xb2, 0x1, 0xde, 0x5, 0x7a}; + uint8_t bytesprops6[] = {0x4a, 0x16}; + uint8_t bytesprops7[] = {0x12, 0xc8, 0x49, 0x6e, 0xb9, 0xaa, 0xbc, 0xaa, 0x79, 0x7c, 0x52, + 0xfc, 0xb6, 0x41, 0x2b, 0x2a, 0xf4, 0x52, 0xc9, 0xa5, 0xd3}; + uint8_t bytesprops8[] = {0xc4, 0xb5, 0x6e, 0x2b, 0xac, 0x2f, 0xab, 0x63, 0x1e, 0xe7, 0x48, 0x79, 0x6a, 0x4b, 0x5, + 0x18, 0x15, 0x4a, 0x44, 0x4e, 0x84, 0xaa, 0x24, 0x8a, 0x26, 0x93, 0x86, 0x9a, 0xbd}; + uint8_t bytesprops9[] = {0x57, 0x75, 0x2f, 0xc2, 0xd5, 0xed, 0xa7, 0xfc, 0xfb, 0x67, 0xb9, 0x3c, 0xf4, 0x1d, 0x5d}; + uint8_t bytesprops10[] = {0x99, 0x86, 0x1d, 0xb8, 0xa1, 0x2a, 0x36, 0x4d, 0x8f, 0xc0, 0x62, + 0x2c, 0xe0, 0x4, 0xe8, 0x1d, 0xb5, 0x72, 0x5a, 0xac, 0xd0}; + uint8_t bytesprops11[] = {0x4c, 0x5a, 0xe9, 0xdd, 0xcd, 0xd, 0x31, 0x6f, 0x51, 0x7, + 0x30, 0x3b, 0xf7, 0xcc, 0xa6, 0x3d, 0x3c, 0x0, 0x19}; + uint8_t bytesprops12[] = {0xbe, 0xe2, 0xb5, 0x97, 0x80, 0xb, 0x43, 0x7e, 0x71, 0x5a, 0xbb, 0xd8, 0xbd, 0xe0, 0xca}; + uint8_t bytesprops13[] = {0xd5, 0xf2, 0x96, 0xeb, 0x62, 0x95, 0x9b, 0x22, 0x97, 0xf6, 0x5, 0xef}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 28}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 45}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 13199}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 5231}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 19944}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {18, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 8745}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {11, (char*)&bytesprops1}, .v = {18, (char*)&bytesprops2}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 173}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 24}}, - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {7, (char*)&bytesprops3}, .v = {30, (char*)&bytesprops4}}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 139}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 5314}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 3496}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {15, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 22692}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 15527}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 14795}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 23340}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {8, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 236}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 163}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 73}}, - {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 21923}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 24460}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {3, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 0}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {24, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {0, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {21, (char*)&bytesprops2}, .v = {21, (char*)&bytesprops3}}}}, + {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 16122}}, + {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 24484}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 156}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 32214}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 11695}}, + {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {27, (char*)&bytesprops4}, .v = {22, (char*)&bytesprops5}}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {2, (char*)&bytesprops6}}}, + {.prop = (lwmqtt_prop_t)28, .value = {.str = {21, (char*)&bytesprops7}}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {29, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 88}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 3069}}, + {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 13}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 117}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {15, (char*)&bytesprops9}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 1148}}, + {.prop = (lwmqtt_prop_t)36, .value = {.byte = 206}}, + {.prop = (lwmqtt_prop_t)22, .value = {.str = {21, (char*)&bytesprops10}}}, + {.prop = (lwmqtt_prop_t)37, .value = {.byte = 56}}, + {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 6281}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops11}}}, + {.prop = (lwmqtt_prop_t)31, .value = {.str = {15, (char*)&bytesprops12}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {12, (char*)&bytesprops13}}}, + {.prop = (lwmqtt_prop_t)23, .value = {.byte = 146}}, + {.prop = (lwmqtt_prop_t)42, .value = {.byte = 34}}, + {.prop = (lwmqtt_prop_t)1, .value = {.byte = 230}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16918}}, + {.prop = (lwmqtt_prop_t)34, .value = {.int16 = 16975}}, }; - lwmqtt_properties_t props = {28, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {30, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 161, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 0, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoMalformedPacket [PropUserProperty -// "\195\166\180u\189Z\179\181Ab\SIE\255\&1\252\203c\219\174\US\192\DC3\172" -// "R\190\v\227\205\214\"\131D[\128G\163\182\183\RS\228\140\161",PropServerKeepAlive 7736,PropSessionExpiryInterval -// 19120,PropCorrelationData "\251\192\&7=G",PropCorrelationData -// "\DC1\151\221\175k6\232\DC1\DC1\180\223",PropSessionExpiryInterval 18563,PropRequestProblemInformation -// 228,PropCorrelationData "\161\255\EM",PropReceiveMaximum 4326,PropAssignedClientIdentifier -// "yB\247\SO!\t\225\141\219P\215\244`\253",PropAuthenticationMethod "\f\212",PropRetainAvailable -// 154,PropMaximumPacketSize 23032,PropRequestResponseInformation 205,PropMessageExpiryInterval 9326,PropContentType -// "\t\132\144-\225\&3\140\RS\190\211Eb\220 \171\ETXW\254\245",PropReasonString -// "\DC3\162\170\180\STX\243<",PropResponseInformation "\161Z*\DC4\ESC\195\238\185\224\247)x\203\159",PropMaximumQoS -// 11,PropSubscriptionIdentifierAvailable 211,PropResponseTopic "\251",PropAssignedClientIdentifier -// "\228",PropRequestResponseInformation 56,PropUserProperty -// "\193\153\211\229\202\195R\228\214\176\204\234(\SOY\176\177\239\176\225\fB\247\249C\SOH" "-`\219o \SYN\b\247ud\ESC"] +// DisconnectRequest DiscoMaximumConnectTime [PropMessageExpiryInterval 16379,PropRequestResponseInformation 106] TEST(Disco5QCTest, Encode27) { - uint8_t pkt[] = { - 0xe0, 0xed, 0x1, 0x81, 0xea, 0x1, 0x26, 0x0, 0x17, 0xc3, 0xa6, 0xb4, 0x75, 0xbd, 0x5a, 0xb3, 0xb5, 0x41, 0x62, - 0xf, 0x45, 0xff, 0x31, 0xfc, 0xcb, 0x63, 0xdb, 0xae, 0x1f, 0xc0, 0x13, 0xac, 0x0, 0x13, 0x52, 0xbe, 0xb, 0xe3, - 0xcd, 0xd6, 0x22, 0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xb, 0x2d, 0x60, 0xdb, 0x6f, 0x20, 0x16, 0x8, 0xf7, 0x75, 0x64, 0x1b}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops1[] = {0x52, 0xbe, 0xb, 0xe3, 0xcd, 0xd6, 0x22, 0x83, 0x44, 0x5b, - 0x80, 0x47, 0xa3, 0xb6, 0xb7, 0x1e, 0xe4, 0x8c, 0xa1}; - uint8_t bytesprops0[] = {0xc3, 0xa6, 0xb4, 0x75, 0xbd, 0x5a, 0xb3, 0xb5, 0x41, 0x62, 0xf, 0x45, - 0xff, 0x31, 0xfc, 0xcb, 0x63, 0xdb, 0xae, 0x1f, 0xc0, 0x13, 0xac}; - uint8_t bytesprops2[] = {0xfb, 0xc0, 0x37, 0x3d, 0x47}; - uint8_t bytesprops3[] = {0x11, 0x97, 0xdd, 0xaf, 0x6b, 0x36, 0xe8, 0x11, 0x11, 0xb4, 0xdf}; - uint8_t bytesprops4[] = {0xa1, 0xff, 0x19}; - uint8_t bytesprops5[] = {0x79, 0x42, 0xf7, 0xe, 0x21, 0x9, 0xe1, 0x8d, 0xdb, 0x50, 0xd7, 0xf4, 0x60, 0xfd}; - uint8_t bytesprops6[] = {0xc, 0xd4}; - uint8_t bytesprops7[] = {0x9, 0x84, 0x90, 0x2d, 0xe1, 0x33, 0x8c, 0x1e, 0xbe, 0xd3, - 0x45, 0x62, 0xdc, 0x20, 0xab, 0x3, 0x57, 0xfe, 0xf5}; - uint8_t bytesprops8[] = {0x13, 0xa2, 0xaa, 0xb4, 0x2, 0xf3, 0x3c}; - uint8_t bytesprops9[] = {0xa1, 0x5a, 0x2a, 0x14, 0x1b, 0xc3, 0xee, 0xb9, 0xe0, 0xf7, 0x29, 0x78, 0xcb, 0x9f}; - uint8_t bytesprops10[] = {0xfb}; - uint8_t bytesprops11[] = {0xe4}; - uint8_t bytesprops13[] = {0x2d, 0x60, 0xdb, 0x6f, 0x20, 0x16, 0x8, 0xf7, 0x75, 0x64, 0x1b}; - uint8_t bytesprops12[] = {0xc1, 0x99, 0xd3, 0xe5, 0xca, 0xc3, 0x52, 0xe4, 0xd6, 0xb0, 0xcc, 0xea, 0x28, - 0xe, 0x59, 0xb0, 0xb1, 0xef, 0xb0, 0xe1, 0xc, 0x42, 0xf7, 0xf9, 0x43, 0x1}; + uint8_t pkt[] = {0xe0, 0x9, 0xa0, 0x7, 0x2, 0x0, 0x0, 0x3f, 0xfb, 0x19, 0x6a}; + uint8_t buf[sizeof(pkt) + 10] = {0}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)38, .value = {.pair = {.k = {23, (char*)&bytesprops0}, .v = {19, (char*)&bytesprops1}}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 7736}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 19120}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {5, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)17, .value = {.int32 = 18563}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 228}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {3, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)33, .value = {.int16 = 4326}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {14, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {2, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)37, .value = {.byte = 154}}, - {.prop = (lwmqtt_prop_t)39, .value = {.int32 = 23032}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 205}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 9326}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {19, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {7, (char*)&bytesprops8}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {14, (char*)&bytesprops9}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 11}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 211}}, - {.prop = (lwmqtt_prop_t)8, .value = {.str = {1, (char*)&bytesprops10}}}, - {.prop = (lwmqtt_prop_t)18, .value = {.str = {1, (char*)&bytesprops11}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 56}}, - {.prop = (lwmqtt_prop_t)38, - .value = {.pair = {.k = {26, (char*)&bytesprops12}, .v = {11, (char*)&bytesprops13}}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 16379}}, + {.prop = (lwmqtt_prop_t)25, .value = {.byte = 106}}, }; - lwmqtt_properties_t props = {24, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 129, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 160, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoTopicAliasInvalid [PropServerReference "",PropTopicAlias 20930,PropTopicAlias -// 15670,PropAuthenticationMethod "'(\225\139rP~Eq\205umB\216K&\182",PropResponseInformation -// ".e",PropPayloadFormatIndicator 214,PropMaximumQoS 86,PropServerKeepAlive 17262,PropMessageExpiryInterval -// 30402,PropServerKeepAlive 13701,PropContentType -// "\187PR\192\250\&02y\159.\GS\184\ACK\154]\167\SO\132~\252\165wYl\149\216",PropTopicAlias 10414,PropAuthenticationData -// "\145I\206\142-f\159\238 =\167R\199\SOH\249B>:T\169\179\193\&4f\ENQ\248\250\169\SI",PropRequestResponseInformation -// 110,PropMaximumQoS 6,PropWildcardSubscriptionAvailable 104,PropRequestProblemInformation 132,PropContentType -// "\195\151W\\\171y\217\194\141\137\156k\165b>(\SOH\GSz]G\175\251",PropAuthenticationMethod -// "\146E\176\189\225m\128\149J6@1n\v\192\191\159M\t\SI\218\227\239x7\ETB\202=",PropTopicAlias -// 32393,PropWillDelayInterval 26126,PropServerReference "",PropAuthenticationData -// "[K\150\221\199\181}\212\&3A6\159\184\222\161\DC3%\170"] +// DisconnectRequest DiscoQoSNotSupported [PropContentType +// "R[\"\140\152M\189\226*\178\197c{\204\&8\207\246w\STX\220",PropAuthenticationMethod +// "\211\248\217*\187lq\237\233\&8\158\ENQh\133\214;\135S:\211\211\182/\248>\196\&2",PropResponseTopic +// "OSi\253\219",PropMessageExpiryInterval 24521,PropResponseInformation +// "\SYN\252\&4\251\t\128\174\206\200\253a\162\149\SO\238}\DC1\253\187\145\144\DC4_g\239iL\166"] TEST(Disco5QCTest, Encode28) { - uint8_t pkt[] = {0xe0, 0xd5, 0x1, 0x94, 0xd2, 0x1, 0x1c, 0x0, 0x0, 0x23, 0x51, 0xc2, 0x23, 0x3d, 0x36, 0x15, 0x0, - 0x11, 0x27, 0x28, 0xe1, 0x8b, 0x72, 0x50, 0x7e, 0x45, 0x71, 0xcd, 0x75, 0x6d, 0x42, 0xd8, 0x4b, 0x26, - 0xb6, 0x1a, 0x0, 0x2, 0x2e, 0x65, 0x1, 0xd6, 0x24, 0x56, 0x13, 0x43, 0x6e, 0x2, 0x0, 0x0, 0x76, - 0xc2, 0x13, 0x35, 0x85, 0x3, 0x0, 0x1a, 0xbb, 0x50, 0x52, 0xc0, 0xfa, 0x30, 0x32, 0x79, 0x9f, 0x2e, - 0x1d, 0xb8, 0x6, 0x9a, 0x5d, 0xa7, 0xe, 0x84, 0x7e, 0xfc, 0xa5, 0x77, 0x59, 0x6c, 0x95, 0xd8, 0x23, - 0x28, 0xae, 0x16, 0x0, 0x1d, 0x91, 0x49, 0xce, 0x8e, 0x2d, 0x66, 0x9f, 0xee, 0x20, 0x3d, 0xa7, 0x52, - 0xc7, 0x1, 0xf9, 0x42, 0x3e, 0x3a, 0x54, 0xa9, 0xb3, 0xc1, 0x34, 0x66, 0x5, 0xf8, 0xfa, 0xa9, 0xf, - 0x19, 0x6e, 0x24, 0x6, 0x28, 0x68, 0x17, 0x84, 0x3, 0x0, 0x17, 0xc3, 0x97, 0x57, 0x5c, 0xab, 0x79, - 0xd9, 0xc2, 0x8d, 0x89, 0x9c, 0x6b, 0xa5, 0x62, 0x3e, 0x28, 0x1, 0x1d, 0x7a, 0x5d, 0x47, 0xaf, 0xfb, - 0x15, 0x0, 0x1c, 0x92, 0x45, 0xb0, 0xbd, 0xe1, 0x6d, 0x80, 0x95, 0x4a, 0x36, 0x40, 0x31, 0x6e, 0xb, - 0xc0, 0xbf, 0x9f, 0x4d, 0x9, 0xf, 0xda, 0xe3, 0xef, 0x78, 0x37, 0x17, 0xca, 0x3d, 0x23, 0x7e, 0x89, - 0x18, 0x0, 0x0, 0x66, 0xe, 0x1c, 0x0, 0x0, 0x16, 0x0, 0x12, 0x5b, 0x4b, 0x96, 0xdd, 0xc7, 0xb5, - 0x7d, 0xd4, 0x33, 0x41, 0x36, 0x9f, 0xb8, 0xde, 0xa1, 0x13, 0x25, 0xaa}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0}; - uint8_t bytesprops1[] = {0x27, 0x28, 0xe1, 0x8b, 0x72, 0x50, 0x7e, 0x45, 0x71, - 0xcd, 0x75, 0x6d, 0x42, 0xd8, 0x4b, 0x26, 0xb6}; - uint8_t bytesprops2[] = {0x2e, 0x65}; - uint8_t bytesprops3[] = {0xbb, 0x50, 0x52, 0xc0, 0xfa, 0x30, 0x32, 0x79, 0x9f, 0x2e, 0x1d, 0xb8, 0x6, - 0x9a, 0x5d, 0xa7, 0xe, 0x84, 0x7e, 0xfc, 0xa5, 0x77, 0x59, 0x6c, 0x95, 0xd8}; - uint8_t bytesprops4[] = {0x91, 0x49, 0xce, 0x8e, 0x2d, 0x66, 0x9f, 0xee, 0x20, 0x3d, 0xa7, 0x52, 0xc7, 0x1, 0xf9, - 0x42, 0x3e, 0x3a, 0x54, 0xa9, 0xb3, 0xc1, 0x34, 0x66, 0x5, 0xf8, 0xfa, 0xa9, 0xf}; - uint8_t bytesprops5[] = {0xc3, 0x97, 0x57, 0x5c, 0xab, 0x79, 0xd9, 0xc2, 0x8d, 0x89, 0x9c, 0x6b, - 0xa5, 0x62, 0x3e, 0x28, 0x1, 0x1d, 0x7a, 0x5d, 0x47, 0xaf, 0xfb}; - uint8_t bytesprops6[] = {0x92, 0x45, 0xb0, 0xbd, 0xe1, 0x6d, 0x80, 0x95, 0x4a, 0x36, 0x40, 0x31, 0x6e, 0xb, - 0xc0, 0xbf, 0x9f, 0x4d, 0x9, 0xf, 0xda, 0xe3, 0xef, 0x78, 0x37, 0x17, 0xca, 0x3d}; - uint8_t bytesprops7[] = {0}; - uint8_t bytesprops8[] = {0x5b, 0x4b, 0x96, 0xdd, 0xc7, 0xb5, 0x7d, 0xd4, 0x33, - 0x41, 0x36, 0x9f, 0xb8, 0xde, 0xa1, 0x13, 0x25, 0xaa}; + uint8_t pkt[] = {0xe0, 0x63, 0x9b, 0x61, 0x3, 0x0, 0x14, 0x52, 0x5b, 0x22, 0x8c, 0x98, 0x4d, 0xbd, 0xe2, 0x2a, 0xb2, + 0xc5, 0x63, 0x7b, 0xcc, 0x38, 0xcf, 0xf6, 0x77, 0x2, 0xdc, 0x15, 0x0, 0x1b, 0xd3, 0xf8, 0xd9, 0x2a, + 0xbb, 0x6c, 0x71, 0xed, 0xe9, 0x38, 0x9e, 0x5, 0x68, 0x85, 0xd6, 0x3b, 0x87, 0x53, 0x3a, 0xd3, 0xd3, + 0xb6, 0x2f, 0xf8, 0x3e, 0xc4, 0x32, 0x8, 0x0, 0x5, 0x4f, 0x53, 0x69, 0xfd, 0xdb, 0x2, 0x0, 0x0, + 0x5f, 0xc9, 0x1a, 0x0, 0x1c, 0x16, 0xfc, 0x34, 0xfb, 0x9, 0x80, 0xae, 0xce, 0xc8, 0xfd, 0x61, 0xa2, + 0x95, 0xe, 0xee, 0x7d, 0x11, 0xfd, 0xbb, 0x91, 0x90, 0x14, 0x5f, 0x67, 0xef, 0x69, 0x4c, 0xa6}; + uint8_t buf[sizeof(pkt) + 10] = {0}; + uint8_t bytesprops0[] = {0x52, 0x5b, 0x22, 0x8c, 0x98, 0x4d, 0xbd, 0xe2, 0x2a, 0xb2, + 0xc5, 0x63, 0x7b, 0xcc, 0x38, 0xcf, 0xf6, 0x77, 0x2, 0xdc}; + uint8_t bytesprops1[] = {0xd3, 0xf8, 0xd9, 0x2a, 0xbb, 0x6c, 0x71, 0xed, 0xe9, 0x38, 0x9e, 0x5, 0x68, 0x85, + 0xd6, 0x3b, 0x87, 0x53, 0x3a, 0xd3, 0xd3, 0xb6, 0x2f, 0xf8, 0x3e, 0xc4, 0x32}; + uint8_t bytesprops2[] = {0x4f, 0x53, 0x69, 0xfd, 0xdb}; + uint8_t bytesprops3[] = {0x16, 0xfc, 0x34, 0xfb, 0x9, 0x80, 0xae, 0xce, 0xc8, 0xfd, 0x61, 0xa2, 0x95, 0xe, + 0xee, 0x7d, 0x11, 0xfd, 0xbb, 0x91, 0x90, 0x14, 0x5f, 0x67, 0xef, 0x69, 0x4c, 0xa6}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 20930}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15670}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {17, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {2, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 214}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 86}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 17262}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 30402}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 13701}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {26, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10414}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {29, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 110}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 6}}, - {.prop = (lwmqtt_prop_t)40, .value = {.byte = 104}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 132}}, - {.prop = (lwmqtt_prop_t)3, .value = {.str = {23, (char*)&bytesprops5}}}, - {.prop = (lwmqtt_prop_t)21, .value = {.str = {28, (char*)&bytesprops6}}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 32393}}, - {.prop = (lwmqtt_prop_t)24, .value = {.int32 = 26126}}, - {.prop = (lwmqtt_prop_t)28, .value = {.str = {0, (char*)&bytesprops7}}}, - {.prop = (lwmqtt_prop_t)22, .value = {.str = {18, (char*)&bytesprops8}}}, + {.prop = (lwmqtt_prop_t)3, .value = {.str = {20, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)21, .value = {.str = {27, (char*)&bytesprops1}}}, + {.prop = (lwmqtt_prop_t)8, .value = {.str = {5, (char*)&bytesprops2}}}, + {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 24521}}, + {.prop = (lwmqtt_prop_t)26, .value = {.str = {28, (char*)&bytesprops3}}}, }; - lwmqtt_properties_t props = {23, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {5, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 148, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 155, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoNotAuthorized [PropServerKeepAlive 20971,PropRequestProblemInformation 82,PropCorrelationData -// "\t\194|9N\143vPU\237\162.\NAK\211\169\145_\203\225\241\179\133\174\215\212\n",PropMaximumQoS -// 178,PropRequestResponseInformation 217,PropRequestProblemInformation 4,PropTopicAlias 10045,PropResponseInformation -// "\219\EOT\220\152",PropMaximumQoS 87,PropSharedSubscriptionAvailable 145,PropSubscriptionIdentifier -// 23,PropCorrelationData "9\150\183\ESC\163\138\140\182\249\149\235",PropPayloadFormatIndicator 194,PropReasonString -// "i\231!t)nv\135\n\184\227~dJBW",PropResponseInformation "\136r\206\238\SO1\151\217\240F\241J",PropServerKeepAlive -// 27793,PropSharedSubscriptionAvailable 189,PropReasonString "t\170\&8.fZ\214\153(\SIU\199K`\DLE\166)\STX"] +// DisconnectRequest DiscoMessageRateTooHigh [] TEST(Disco5QCTest, Encode29) { - uint8_t pkt[] = {0xe0, 0x87, 0x1, 0x87, 0x84, 0x1, 0x13, 0x51, 0xeb, 0x17, 0x52, 0x9, 0x0, 0x1a, 0x9, 0xc2, - 0x7c, 0x39, 0x4e, 0x8f, 0x76, 0x50, 0x55, 0xed, 0xa2, 0x2e, 0x15, 0xd3, 0xa9, 0x91, 0x5f, 0xcb, - 0xe1, 0xf1, 0xb3, 0x85, 0xae, 0xd7, 0xd4, 0xa, 0x24, 0xb2, 0x19, 0xd9, 0x17, 0x4, 0x23, 0x27, - 0x3d, 0x1a, 0x0, 0x4, 0xdb, 0x4, 0xdc, 0x98, 0x24, 0x57, 0x2a, 0x91, 0xb, 0x17, 0x9, 0x0, - 0xb, 0x39, 0x96, 0xb7, 0x1b, 0xa3, 0x8a, 0x8c, 0xb6, 0xf9, 0x95, 0xeb, 0x1, 0xc2, 0x1f, 0x0, - 0x10, 0x69, 0xe7, 0x21, 0x74, 0x29, 0x6e, 0x76, 0x87, 0xa, 0xb8, 0xe3, 0x7e, 0x64, 0x4a, 0x42, - 0x57, 0x1a, 0x0, 0xc, 0x88, 0x72, 0xce, 0xee, 0xe, 0x31, 0x97, 0xd9, 0xf0, 0x46, 0xf1, 0x4a, - 0x13, 0x6c, 0x91, 0x2a, 0xbd, 0x1f, 0x0, 0x12, 0x74, 0xaa, 0x38, 0x2e, 0x66, 0x5a, 0xd6, 0x99, - 0x28, 0xf, 0x55, 0xc7, 0x4b, 0x60, 0x10, 0xa6, 0x29, 0x2}; - uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x9, 0xc2, 0x7c, 0x39, 0x4e, 0x8f, 0x76, 0x50, 0x55, 0xed, 0xa2, 0x2e, 0x15, - 0xd3, 0xa9, 0x91, 0x5f, 0xcb, 0xe1, 0xf1, 0xb3, 0x85, 0xae, 0xd7, 0xd4, 0xa}; - uint8_t bytesprops1[] = {0xdb, 0x4, 0xdc, 0x98}; - uint8_t bytesprops2[] = {0x39, 0x96, 0xb7, 0x1b, 0xa3, 0x8a, 0x8c, 0xb6, 0xf9, 0x95, 0xeb}; - uint8_t bytesprops3[] = {0x69, 0xe7, 0x21, 0x74, 0x29, 0x6e, 0x76, 0x87, - 0xa, 0xb8, 0xe3, 0x7e, 0x64, 0x4a, 0x42, 0x57}; - uint8_t bytesprops4[] = {0x88, 0x72, 0xce, 0xee, 0xe, 0x31, 0x97, 0xd9, 0xf0, 0x46, 0xf1, 0x4a}; - uint8_t bytesprops5[] = {0x74, 0xaa, 0x38, 0x2e, 0x66, 0x5a, 0xd6, 0x99, 0x28, - 0xf, 0x55, 0xc7, 0x4b, 0x60, 0x10, 0xa6, 0x29, 0x2}; + uint8_t pkt[] = {0xe0, 0x2, 0x96, 0x0}; + uint8_t buf[sizeof(pkt) + 10] = {0}; - lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 20971}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 82}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {26, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 178}}, - {.prop = (lwmqtt_prop_t)25, .value = {.byte = 217}}, - {.prop = (lwmqtt_prop_t)23, .value = {.byte = 4}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 10045}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {4, (char*)&bytesprops1}}}, - {.prop = (lwmqtt_prop_t)36, .value = {.byte = 87}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 145}}, - {.prop = (lwmqtt_prop_t)11, .value = {.int32 = 23}}, - {.prop = (lwmqtt_prop_t)9, .value = {.str = {11, (char*)&bytesprops2}}}, - {.prop = (lwmqtt_prop_t)1, .value = {.byte = 194}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {16, (char*)&bytesprops3}}}, - {.prop = (lwmqtt_prop_t)26, .value = {.str = {12, (char*)&bytesprops4}}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 27793}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 189}}, - {.prop = (lwmqtt_prop_t)31, .value = {.str = {18, (char*)&bytesprops5}}}, - }; + lwmqtt_property_t propslist[] = {}; - lwmqtt_properties_t props = {18, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {0, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 135, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 150, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); } -// DisconnectRequest DiscoSessiontakenOver [PropResponseInformation -// "\b\255EV`\151k\n\140Q\154\251\143\\6\148\146\179\v",PropMessageExpiryInterval 29816,PropServerKeepAlive -// 23021,PropTopicAlias 15077,PropSharedSubscriptionAvailable 241,PropSubscriptionIdentifierAvailable 12] +// DisconnectRequest DiscoRetainNotSupported [PropAssignedClientIdentifier +// "\169\179\157O\198\141\136jQJ\ESC!\NUL\208\240]\EOT\f\135",PropSubscriptionIdentifierAvailable 24] TEST(Disco5QCTest, Encode30) { - uint8_t pkt[] = {0xe0, 0x27, 0x8e, 0x25, 0x1a, 0x0, 0x13, 0x8, 0xff, 0x45, 0x56, 0x60, 0x97, 0x6b, - 0xa, 0x8c, 0x51, 0x9a, 0xfb, 0x8f, 0x5c, 0x36, 0x94, 0x92, 0xb3, 0xb, 0x2, 0x0, - 0x0, 0x74, 0x78, 0x13, 0x59, 0xed, 0x23, 0x3a, 0xe5, 0x2a, 0xf1, 0x29, 0xc}; + uint8_t pkt[] = {0xe0, 0x1a, 0x9a, 0x18, 0x12, 0x0, 0x13, 0xa9, 0xb3, 0x9d, 0x4f, 0xc6, 0x8d, 0x88, + 0x6a, 0x51, 0x4a, 0x1b, 0x21, 0x0, 0xd0, 0xf0, 0x5d, 0x4, 0xc, 0x87, 0x29, 0x18}; uint8_t buf[sizeof(pkt) + 10] = {0}; - uint8_t bytesprops0[] = {0x8, 0xff, 0x45, 0x56, 0x60, 0x97, 0x6b, 0xa, 0x8c, 0x51, - 0x9a, 0xfb, 0x8f, 0x5c, 0x36, 0x94, 0x92, 0xb3, 0xb}; + uint8_t bytesprops0[] = {0xa9, 0xb3, 0x9d, 0x4f, 0xc6, 0x8d, 0x88, 0x6a, 0x51, 0x4a, + 0x1b, 0x21, 0x0, 0xd0, 0xf0, 0x5d, 0x4, 0xc, 0x87}; lwmqtt_property_t propslist[] = { - {.prop = (lwmqtt_prop_t)26, .value = {.str = {19, (char*)&bytesprops0}}}, - {.prop = (lwmqtt_prop_t)2, .value = {.int32 = 29816}}, - {.prop = (lwmqtt_prop_t)19, .value = {.int16 = 23021}}, - {.prop = (lwmqtt_prop_t)35, .value = {.int16 = 15077}}, - {.prop = (lwmqtt_prop_t)42, .value = {.byte = 241}}, - {.prop = (lwmqtt_prop_t)41, .value = {.byte = 12}}, + {.prop = (lwmqtt_prop_t)18, .value = {.str = {19, (char*)&bytesprops0}}}, + {.prop = (lwmqtt_prop_t)41, .value = {.byte = 24}}, }; - lwmqtt_properties_t props = {6, (lwmqtt_property_t*)&propslist}; + lwmqtt_properties_t props = {2, (lwmqtt_property_t*)&propslist}; size_t len = 0; - lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 142, props); + lwmqtt_err_t err = lwmqtt_encode_disconnect(buf, sizeof(buf), &len, LWMQTT_MQTT5, 154, props); EXPECT_EQ(err, LWMQTT_SUCCESS); EXPECT_EQ(len, sizeof(pkt)); EXPECT_ARRAY_EQ(pkt, buf, len); From 3d1b30ba034f93b998072bfb88de1db604a51562 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Sun, 22 Sep 2019 09:54:33 -0700 Subject: [PATCH 26/26] Plumb properties through subscription functions. --- examples/async.c | 3 ++- examples/sync.c | 3 ++- include/lwmqtt.h | 4 ++-- src/client.c | 7 +++---- tests/client.cpp | 14 +++++++------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/examples/async.c b/examples/async.c index fc87502..7855462 100644 --- a/examples/async.c +++ b/examples/async.c @@ -104,7 +104,8 @@ int main() { // subscribe to topic lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; - err = lwmqtt_subscribe_one(&client, lwmqtt_string("hello"), subopts, COMMAND_TIMEOUT); + lwmqtt_properties_t subprops = lwmqtt_empty_props; + err = lwmqtt_subscribe_one(&client, lwmqtt_string("hello"), subopts, subprops, COMMAND_TIMEOUT); if (err != LWMQTT_SUCCESS) { printf("failed lwmqtt_subscribe: %d\n", err); exit(1); diff --git a/examples/sync.c b/examples/sync.c index 2d4c003..740b2d9 100644 --- a/examples/sync.c +++ b/examples/sync.c @@ -90,7 +90,8 @@ int main() { // subscribe to topic lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; - err = lwmqtt_subscribe_one(&client, lwmqtt_string("hello"), subopts, COMMAND_TIMEOUT); + lwmqtt_properties_t subprops = lwmqtt_empty_props; + err = lwmqtt_subscribe_one(&client, lwmqtt_string("hello"), subopts, subprops, COMMAND_TIMEOUT); if (err != LWMQTT_SUCCESS) { printf("failed lwmqtt_subscribe: %d\n", err); exit(1); diff --git a/include/lwmqtt.h b/include/lwmqtt.h index bf5090b..7bb2a00 100644 --- a/include/lwmqtt.h +++ b/include/lwmqtt.h @@ -400,7 +400,7 @@ lwmqtt_err_t lwmqtt_publish(lwmqtt_client_t *client, lwmqtt_string_t topic, lwmq * @return An error value. */ lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, - lwmqtt_sub_options_t *opts, uint32_t timeout); + lwmqtt_sub_options_t *opts, lwmqtt_properties_t props, uint32_t timeout); /** * Will send a subscribe packet with a single topic filter plus QOS level and wait for the suback to complete. @@ -414,7 +414,7 @@ lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_ * @return An error value. */ lwmqtt_err_t lwmqtt_subscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, lwmqtt_sub_options_t opts, - uint32_t timeout); + lwmqtt_properties_t props, uint32_t timeout); typedef enum { LWMQTT_UNSUB_SUCCESS = 0, diff --git a/src/client.c b/src/client.c index 7c078d9..4896913 100644 --- a/src/client.c +++ b/src/client.c @@ -485,13 +485,12 @@ lwmqtt_err_t lwmqtt_connect(lwmqtt_client_t *client, lwmqtt_options_t options, l } lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, - lwmqtt_sub_options_t *opts, uint32_t timeout) { + lwmqtt_sub_options_t *opts, lwmqtt_properties_t props, uint32_t timeout) { // set command timer client->timer_set(client->command_timer, timeout); // encode subscribe packet size_t len; - lwmqtt_properties_t props = lwmqtt_empty_props; lwmqtt_err_t err = lwmqtt_encode_subscribe(client->write_buf, client->write_buf_size, &len, client->protocol, lwmqtt_get_next_packet_id(client), count, topic_filter, opts, props); if (err != LWMQTT_SUCCESS) { @@ -535,8 +534,8 @@ lwmqtt_err_t lwmqtt_subscribe(lwmqtt_client_t *client, int count, lwmqtt_string_ } lwmqtt_err_t lwmqtt_subscribe_one(lwmqtt_client_t *client, lwmqtt_string_t topic_filter, lwmqtt_sub_options_t opts, - uint32_t timeout) { - return lwmqtt_subscribe(client, 1, &topic_filter, &opts, timeout); + lwmqtt_properties_t props, uint32_t timeout) { + return lwmqtt_subscribe(client, 1, &topic_filter, &opts, props, timeout); } lwmqtt_err_t lwmqtt_unsubscribe(lwmqtt_client_t *client, int count, lwmqtt_string_t *topic_filter, diff --git a/tests/client.cpp b/tests/client.cpp index 3925809..d312647 100644 --- a/tests/client.cpp +++ b/tests/client.cpp @@ -72,7 +72,7 @@ TEST(Client, PublishSubscribeQOS0) { ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0; @@ -133,7 +133,7 @@ TEST(Client, PublishSubscribeQOS1) { lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; subopts.qos = LWMQTT_QOS1; - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0; @@ -194,7 +194,7 @@ TEST(Client, PublishSubscribeQOS2) { lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; subopts.qos = LWMQTT_QOS2; - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0; @@ -254,7 +254,7 @@ TEST(Client, BufferOverflow) { ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_message_t msg = lwmqtt_default_message; @@ -321,7 +321,7 @@ TEST(Client, OverflowDropping) { ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0; @@ -382,7 +382,7 @@ TEST(Client, BigBuffersAndPayload) { ASSERT_EQ(err, LWMQTT_SUCCESS); lwmqtt_sub_options_t subopts = lwmqtt_default_sub_options; - err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, COMMAND_TIMEOUT); + err = lwmqtt_subscribe_one(&client, lwmqtt_string("lwmqtt"), subopts, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0; @@ -445,7 +445,7 @@ TEST(Client, MultipleSubscriptions) { lwmqtt_string_t topic_filters[2] = {lwmqtt_string("foo"), lwmqtt_string("lwmqtt")}; lwmqtt_sub_options_t qos_levels[2] = {subopts, subopts}; - err = lwmqtt_subscribe(&client, 2, topic_filters, qos_levels, COMMAND_TIMEOUT); + err = lwmqtt_subscribe(&client, 2, topic_filters, qos_levels, empty_props, COMMAND_TIMEOUT); ASSERT_EQ(err, LWMQTT_SUCCESS); counter = 0;